[
  {
    "path": ".gitignore",
    "content": "################################\n# Visual Studio Ignore Files\n################################\n*.user\n*.sdf\n*.opensdf\n*.opendb\n.vs/\n\n################################\n# XCode Ignore Files\n################################\nxcuserdata/\nProjects/Libraries/CSBase/build\n*.xcscmblueprint\n\n################################\n# Android Studio Ignore Files\n################################\nProjects/Android/chillisource/build\nProjects/Android/chillisource/src/main/libs/armeabi-v7a\nProjects/Android/chillisource/src/main/libs/armeabi\nProjects/Android/chillisource/src/main/libs/arm64-v8a\nProjects/Android/chillisource/src/main/libs/x86\nProjects/Android/chillisource/src/main/libs/x86_64\nProjects/Android/playapkexpansion/build\nProjects/Android/playlicensing/build\n\n################################\n# Raspberry Pi Ignore Files\n################################\nProjects/RPi/Build\nProjects/RPi/Output\n\n################################\n# General Ignore Files\n################################\nbin/\nobj/\nbuild/\n.DS_Store\nThumbs.db\n*.pyc\n\n\n\n\n\n\n"
  },
  {
    "path": "CSResources/Shaders/Animated-Blinn-Base.csshader",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\nGLSL\n{\n\tVertexShader\n\t{\n\t\t#ifndef GL_ES\n\t\t#define lowp\n\t\t#define mediump\n\t\t#define highp\n\t\t#endif\n\n\n\t\t//attributes\n\t\tattribute highp vec4 a_position;\n\t\tattribute mediump vec2 a_texCoord;\n\t\tattribute highp vec4 a_weights;\n\t\tattribute highp vec4 a_jointIndices;\n\n\t\t//uniforms\n\t\tuniform highp mat4 u_wvpMat;\n\t\tuniform highp vec4 u_joints[100];\n\t\tuniform lowp vec4 u_emissive;\n\t\tuniform lowp vec4 u_ambient;\n\t\tuniform lowp vec4 u_lightCol;\n\n\t\t//varyings\n\t\tvarying mediump vec2 vvTexCoord;\n\t\tvarying lowp vec4 vvColour;\n\n\t\tvoid main()\n\t\t{\n\t\t    //Apply the first joint to the animation transforms\n\t\t\tint jointIndex = int(a_jointIndices.x + 0.5);\n\t\t    vec4 jointVector0 = u_joints[jointIndex * 3 + 0];\n\t\t    vec4 jointVector1 = u_joints[jointIndex * 3 + 1];\n\t\t    vec4 jointVector2 = u_joints[jointIndex * 3 + 2];\n\t\t\tmat4 jointMatrix = mat4(jointVector0.x, jointVector1.x, jointVector2.x, 0.0,\n\t\t                            jointVector0.y, jointVector1.y, jointVector2.y, 0.0,\n\t\t                            jointVector0.z, jointVector1.z, jointVector2.z, 0.0,\n\t\t                            jointVector0.w, jointVector1.w, jointVector2.w, 1.0);\n\t\t    mat4 animationTransform = (jointMatrix * a_weights.x);\n\t\t    \n\t\t    //apply the second joint to the animation transforms\n\t\t    jointIndex = int(a_jointIndices.y + 0.5);\n\t\t    jointVector0 = u_joints[jointIndex * 3 + 0];\n\t\t    jointVector1 = u_joints[jointIndex * 3 + 1];\n\t\t    jointVector2 = u_joints[jointIndex * 3 + 2];\n\t\t\tjointMatrix[0][0] = jointVector0.x; jointMatrix[0][1] = jointVector1.x; jointMatrix[0][2] = jointVector2.x; jointMatrix[0][3] = 0.0;\n\t\t\tjointMatrix[1][0] = jointVector0.y; jointMatrix[1][1] = jointVector1.y; jointMatrix[1][2] = jointVector2.y; jointMatrix[1][3] = 0.0;\n\t\t\tjointMatrix[2][0] = jointVector0.z; jointMatrix[2][1] = jointVector1.z; jointMatrix[2][2] = jointVector2.z; jointMatrix[2][3] = 0.0;\n\t\t\tjointMatrix[3][0] = jointVector0.w; jointMatrix[3][1] = jointVector1.w; jointMatrix[3][2] = jointVector2.w; jointMatrix[3][3] = 1.0;\n\t\t    animationTransform += (jointMatrix * a_weights.y);\n\t\t    \n\t\t    //apply the third joint to the animation transforms\n\t\t    jointIndex = int(a_jointIndices.z + 0.5);\n\t\t    jointVector0 = u_joints[jointIndex * 3 + 0];\n\t\t    jointVector1 = u_joints[jointIndex * 3 + 1];\n\t\t    jointVector2 = u_joints[jointIndex * 3 + 2];\n\t\t\tjointMatrix[0][0] = jointVector0.x; jointMatrix[0][1] = jointVector1.x; jointMatrix[0][2] = jointVector2.x; jointMatrix[0][3] = 0.0;\n\t\t\tjointMatrix[1][0] = jointVector0.y; jointMatrix[1][1] = jointVector1.y; jointMatrix[1][2] = jointVector2.y; jointMatrix[1][3] = 0.0;\n\t\t\tjointMatrix[2][0] = jointVector0.z; jointMatrix[2][1] = jointVector1.z; jointMatrix[2][2] = jointVector2.z; jointMatrix[2][3] = 0.0;\n\t\t\tjointMatrix[3][0] = jointVector0.w; jointMatrix[3][1] = jointVector1.w; jointMatrix[3][2] = jointVector2.w; jointMatrix[3][3] = 1.0;\n\t\t    animationTransform += (jointMatrix * a_weights.z);\n\t\t    \n\t\t    //apply the fourth joint to the animation transforms\n\t\t    jointIndex = int(a_jointIndices.w + 0.5);\n\t\t    jointVector0 = u_joints[jointIndex * 3 + 0];\n\t\t    jointVector1 = u_joints[jointIndex * 3 + 1];\n\t\t    jointVector2 = u_joints[jointIndex * 3 + 2];\n\t\t\tjointMatrix[0][0] = jointVector0.x; jointMatrix[0][1] = jointVector1.x; jointMatrix[0][2] = jointVector2.x; jointMatrix[0][3] = 0.0;\n\t\t\tjointMatrix[1][0] = jointVector0.y; jointMatrix[1][1] = jointVector1.y; jointMatrix[1][2] = jointVector2.y; jointMatrix[1][3] = 0.0;\n\t\t\tjointMatrix[2][0] = jointVector0.z; jointMatrix[2][1] = jointVector1.z; jointMatrix[2][2] = jointVector2.z; jointMatrix[2][3] = 0.0;\n\t\t\tjointMatrix[3][0] = jointVector0.w; jointMatrix[3][1] = jointVector1.w; jointMatrix[3][2] = jointVector2.w; jointMatrix[3][3] = 1.0;\n\t\t    animationTransform += (jointMatrix * (1.0 - a_weights.x - a_weights.y - a_weights.z));\n\n\t\t    //Convert the vertex from local space to projection and world space.\n\t\t\tvec4 localPosition = animationTransform * a_position;\n\t\t    gl_Position = u_wvpMat * localPosition;\n\n\t\t\t//get the tex coord\n\t\t\tvvTexCoord = a_texCoord;\n\t\t    \n\t\t    //calculate the lighting colour\n\t\t    vvColour = (u_emissive + (u_ambient * u_lightCol));\n\t\t}\n\t}\n\t\n\tFragmentShader\n\t{\n\t\t#ifndef GL_ES\n\t\t#define lowp\n\t\t#define mediump\n\t\t#define highp\n\t\t#else\n\t\tprecision lowp float;\n\t\t#endif\n\n\t\t//uniforms\n\t\tuniform lowp sampler2D u_texture0;\n\n\t\t//varyings\n\t\tvarying mediump vec2 vvTexCoord;\n\t\tvarying lowp vec4 vvColour;\n\n\t\tvoid main()\n\t\t{\n\t\t\tgl_FragColor = vvColour * texture2D(u_texture0, vvTexCoord);\n\t\t}\n\t}\n}"
  },
  {
    "path": "CSResources/Shaders/Animated-Blinn-Directional.csshader",
    "content": "//\n//  AnimatedBlinnDirectional.csshader\n//  ChilliSource\n//  Created by I Copland on 29/01/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\nGLSL\n{\n    VertexShader\n    {\n        #ifndef GL_ES\n        #define lowp\n        #define mediump\n        #define highp\n        #endif\n\n        //attributes\n        attribute highp vec4 a_position;\n        attribute mediump vec3 a_normal;\n        attribute mediump vec2 a_texCoord;\n        attribute highp vec4 a_weights;\n        attribute highp vec4 a_jointIndices;\n\n        //uniforms\n        uniform mediump vec3 u_lightDir;\n        uniform highp mat4 u_wvpMat;\n        uniform highp mat4 u_worldMat;\n        uniform highp mat4 u_normalMat;\n        uniform highp vec4 u_joints[100];\n        uniform highp vec3 u_cameraPos;\n\n        //varyings\n        varying mediump vec2 vvTexCoord;\n        varying mediump vec3 vvHalfVector;\n        varying mediump vec3 vvNormal;\n\n        void main()\n        {\n            //Apply the first joint to the animation transforms\n            int jointIndex = int(a_jointIndices.x + 0.5);\n            vec4 jointVector0 = u_joints[jointIndex * 3 + 0];\n            vec4 jointVector1 = u_joints[jointIndex * 3 + 1];\n            vec4 jointVector2 = u_joints[jointIndex * 3 + 2];\n            mat4 jointMatrix = mat4(jointVector0.x, jointVector1.x, jointVector2.x, 0.0,\n                                    jointVector0.y, jointVector1.y, jointVector2.y, 0.0,\n                                    jointVector0.z, jointVector1.z, jointVector2.z, 0.0,\n                                    jointVector0.w, jointVector1.w, jointVector2.w, 1.0);\n            mat4 animationTransform = (jointMatrix * a_weights.x);\n            jointMatrix[3][0] = 0.0;\n            jointMatrix[3][1] = 0.0;\n            jointMatrix[3][2] = 0.0;\n            mat4 normalAnimationTransform = (jointMatrix * a_weights.x);\n            \n            //apply the second joint to the animation transforms\n            jointIndex = int(a_jointIndices.y + 0.5);\n            jointVector0 = u_joints[jointIndex * 3 + 0];\n            jointVector1 = u_joints[jointIndex * 3 + 1];\n            jointVector2 = u_joints[jointIndex * 3 + 2];\n            jointMatrix[0][0] = jointVector0.x; jointMatrix[0][1] = jointVector1.x; jointMatrix[0][2] = jointVector2.x; jointMatrix[0][3] = 0.0;\n            jointMatrix[1][0] = jointVector0.y; jointMatrix[1][1] = jointVector1.y; jointMatrix[1][2] = jointVector2.y; jointMatrix[1][3] = 0.0;\n            jointMatrix[2][0] = jointVector0.z; jointMatrix[2][1] = jointVector1.z; jointMatrix[2][2] = jointVector2.z; jointMatrix[2][3] = 0.0;\n            jointMatrix[3][0] = jointVector0.w; jointMatrix[3][1] = jointVector1.w; jointMatrix[3][2] = jointVector2.w; jointMatrix[3][3] = 1.0;\n            animationTransform += (jointMatrix * a_weights.y);\n            jointMatrix[3][0] = 0.0;\n            jointMatrix[3][1] = 0.0;\n            jointMatrix[3][2] = 0.0;\n            normalAnimationTransform += (jointMatrix * a_weights.y);\n            \n            //apply the third joint to the animation transforms\n            jointIndex = int(a_jointIndices.z + 0.5);\n            jointVector0 = u_joints[jointIndex * 3 + 0];\n            jointVector1 = u_joints[jointIndex * 3 + 1];\n            jointVector2 = u_joints[jointIndex * 3 + 2];\n            jointMatrix[0][0] = jointVector0.x; jointMatrix[0][1] = jointVector1.x; jointMatrix[0][2] = jointVector2.x; jointMatrix[0][3] = 0.0;\n            jointMatrix[1][0] = jointVector0.y; jointMatrix[1][1] = jointVector1.y; jointMatrix[1][2] = jointVector2.y; jointMatrix[1][3] = 0.0;\n            jointMatrix[2][0] = jointVector0.z; jointMatrix[2][1] = jointVector1.z; jointMatrix[2][2] = jointVector2.z; jointMatrix[2][3] = 0.0;\n            jointMatrix[3][0] = jointVector0.w; jointMatrix[3][1] = jointVector1.w; jointMatrix[3][2] = jointVector2.w; jointMatrix[3][3] = 1.0;\n            animationTransform += (jointMatrix * a_weights.z);\n            jointMatrix[3][0] = 0.0;\n            jointMatrix[3][1] = 0.0;\n            jointMatrix[3][2] = 0.0;\n            normalAnimationTransform += (jointMatrix * a_weights.z);\n            \n            //apply the fourth joint to the animation transforms\n            jointIndex = int(a_jointIndices.w + 0.5);\n            jointVector0 = u_joints[jointIndex * 3 + 0];\n            jointVector1 = u_joints[jointIndex * 3 + 1];\n            jointVector2 = u_joints[jointIndex * 3 + 2];\n            jointMatrix[0][0] = jointVector0.x; jointMatrix[0][1] = jointVector1.x; jointMatrix[0][2] = jointVector2.x; jointMatrix[0][3] = 0.0;\n            jointMatrix[1][0] = jointVector0.y; jointMatrix[1][1] = jointVector1.y; jointMatrix[1][2] = jointVector2.y; jointMatrix[1][3] = 0.0;\n            jointMatrix[2][0] = jointVector0.z; jointMatrix[2][1] = jointVector1.z; jointMatrix[2][2] = jointVector2.z; jointMatrix[2][3] = 0.0;\n            jointMatrix[3][0] = jointVector0.w; jointMatrix[3][1] = jointVector1.w; jointMatrix[3][2] = jointVector2.w; jointMatrix[3][3] = 1.0;\n            animationTransform += (jointMatrix * (1.0 - a_weights.x - a_weights.y - a_weights.z));\n            jointMatrix[3][0] = 0.0;\n            jointMatrix[3][1] = 0.0;\n            jointMatrix[3][2] = 0.0;\n            normalAnimationTransform += (jointMatrix * (1.0 - a_weights.x - a_weights.y - a_weights.z));\n            \n            //Convert the vertex from local space to projection and world space.\n            vec4 localPosition = animationTransform * a_position;\n            gl_Position = u_wvpMat * localPosition;\n            vec4 vWorldPosition = u_worldMat * localPosition;\n            \n            // Calculate normal in world space\n            vec4 localNormal = normalAnimationTransform * vec4((a_normal), 1.0);\n            vvNormal = normalize((u_normalMat * localNormal).xyz);\n            \n            //calculate the half vector.\n            vec3 vVertexToEye = normalize(u_cameraPos - vWorldPosition.xyz);\n            vvHalfVector = normalize(-u_lightDir + vVertexToEye);\n            \n            //get the tex coord\n            vvTexCoord = a_texCoord;\n        }\n    }\n    \n    FragmentShader\n    {\n        #ifndef GL_ES\n        #define lowp\n        #define mediump\n        #define highp\n        #else\n        precision lowp float;\n        #endif\n\n        //uniforms\n        uniform lowp sampler2D u_texture0;\n\n        uniform lowp vec4 u_diffuse;\n        uniform lowp vec4 u_specular;\n        uniform lowp vec4 u_lightCol;\n        uniform mediump vec3 u_lightDir;\n\n        //varyings\n        varying mediump vec2 vvTexCoord;\n        varying mediump vec3 vvHalfVector;\n        varying mediump vec3 vvNormal;\n\n        void main()\n        {\n        \tvec3 vNormal = normalize(vvNormal);\n        \tvec3 vHalfVector = normalize(vvHalfVector);\n            \n            //calculate the diffuse colour\n            float fNdotL = max(dot(vNormal, -u_lightDir), 0.0);\n            vec4 vDiffuse = u_diffuse * fNdotL;\n            \n            //calculate the specular colour\n            float fNdotHV = max(dot(vNormal, vHalfVector), 0.0);\n            float fLightSwitch = step(0.001, fNdotL);\n            vec4 vSpecular = vec4(u_specular.xyz * pow(fNdotHV, u_specular.a) * fLightSwitch, 1.0);\n            \n        \t//calculate the final colour\n        \tvec4 vColour = (vDiffuse + vSpecular) * u_lightCol;\n        \tgl_FragColor = vColour * texture2D(u_texture0, vvTexCoord);\n        }\n    }\n}\n"
  },
  {
    "path": "CSResources/Shaders/Animated-Blinn-DirectionalShadows.csshader",
    "content": "//\n//  AnimatedBlinnShadowedDirectional.csshader\n//  ChilliSource\n//  Created by I Copland on 29/01/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\nGLSL\n{\n\tVertexShader\n\t{\n\t\t#ifndef GL_ES\n\t\t#define lowp\n\t\t#define mediump\n\t\t#define highp\n\t\t#endif\n\n\t\t//attributes\n\t\tattribute highp vec4 a_position;\n\t\tattribute mediump vec3 a_normal;\n\t\tattribute mediump vec2 a_texCoord;\n\t\tattribute highp vec4 a_weights;\n\t\tattribute highp vec4 a_jointIndices;\n\n\t\t//uniforms\n\t\tuniform mediump vec3 u_lightDir;\n\t\tuniform highp mat4 u_wvpMat;\n\t\tuniform highp mat4 u_worldMat;\n\t\tuniform highp mat4 u_normalMat;\n\t\tuniform highp vec4 u_joints[100];\n\t\tuniform highp vec3 u_cameraPos;\n\t\tuniform highp mat4 u_lightMat;\n\n\t\t//varyings\n\t\tvarying mediump vec2 vvTexCoord;\n\t\tvarying mediump vec3 vvHalfVector;\n\t\tvarying mediump vec3 vvNormal;\n\t\tvarying highp vec4 vvShadowPosition;\n\n\t\tvoid main()\n\t\t{\n\t\t    //Apply the first joint to the animation transforms\n\t\t\tint jointIndex = int(a_jointIndices.x + 0.5);\n\t\t    vec4 jointVector0 = u_joints[jointIndex * 3 + 0];\n\t\t    vec4 jointVector1 = u_joints[jointIndex * 3 + 1];\n\t\t    vec4 jointVector2 = u_joints[jointIndex * 3 + 2];\n\t\t\tmat4 jointMatrix = mat4(jointVector0.x, jointVector1.x, jointVector2.x, 0.0,\n\t\t                            jointVector0.y, jointVector1.y, jointVector2.y, 0.0,\n\t\t                            jointVector0.z, jointVector1.z, jointVector2.z, 0.0,\n\t\t                            jointVector0.w, jointVector1.w, jointVector2.w, 1.0);\n\t\t    mat4 animationTransform = (jointMatrix * a_weights.x);\n\t\t    jointMatrix[3][0] = 0.0;\n\t\t    jointMatrix[3][1] = 0.0;\n\t\t    jointMatrix[3][2] = 0.0;\n\t\t    mat4 normalAnimationTransform = (jointMatrix * a_weights.x);\n\t\t    \n\t\t    //apply the second joint to the animation transforms\n\t\t    jointIndex = int(a_jointIndices.y + 0.5);\n\t\t    jointVector0 = u_joints[jointIndex * 3 + 0];\n\t\t    jointVector1 = u_joints[jointIndex * 3 + 1];\n\t\t    jointVector2 = u_joints[jointIndex * 3 + 2];\n\t\t\tjointMatrix[0][0] = jointVector0.x; jointMatrix[0][1] = jointVector1.x; jointMatrix[0][2] = jointVector2.x; jointMatrix[0][3] = 0.0;\n\t\t\tjointMatrix[1][0] = jointVector0.y; jointMatrix[1][1] = jointVector1.y; jointMatrix[1][2] = jointVector2.y; jointMatrix[1][3] = 0.0;\n\t\t\tjointMatrix[2][0] = jointVector0.z; jointMatrix[2][1] = jointVector1.z; jointMatrix[2][2] = jointVector2.z; jointMatrix[2][3] = 0.0;\n\t\t\tjointMatrix[3][0] = jointVector0.w; jointMatrix[3][1] = jointVector1.w; jointMatrix[3][2] = jointVector2.w; jointMatrix[3][3] = 1.0;\n\t\t    animationTransform += (jointMatrix * a_weights.y);\n\t\t    jointMatrix[3][0] = 0.0;\n\t\t    jointMatrix[3][1] = 0.0;\n\t\t    jointMatrix[3][2] = 0.0;\n\t\t    normalAnimationTransform += (jointMatrix * a_weights.y);\n\t\t    \n\t\t    //apply the third joint to the animation transforms\n\t\t    jointIndex = int(a_jointIndices.z + 0.5);\n\t\t    jointVector0 = u_joints[jointIndex * 3 + 0];\n\t\t    jointVector1 = u_joints[jointIndex * 3 + 1];\n\t\t    jointVector2 = u_joints[jointIndex * 3 + 2];\n\t\t\tjointMatrix[0][0] = jointVector0.x; jointMatrix[0][1] = jointVector1.x; jointMatrix[0][2] = jointVector2.x; jointMatrix[0][3] = 0.0;\n\t\t\tjointMatrix[1][0] = jointVector0.y; jointMatrix[1][1] = jointVector1.y; jointMatrix[1][2] = jointVector2.y; jointMatrix[1][3] = 0.0;\n\t\t\tjointMatrix[2][0] = jointVector0.z; jointMatrix[2][1] = jointVector1.z; jointMatrix[2][2] = jointVector2.z; jointMatrix[2][3] = 0.0;\n\t\t\tjointMatrix[3][0] = jointVector0.w; jointMatrix[3][1] = jointVector1.w; jointMatrix[3][2] = jointVector2.w; jointMatrix[3][3] = 1.0;\n\t\t    animationTransform += (jointMatrix * a_weights.z);\n\t\t    jointMatrix[3][0] = 0.0;\n\t\t    jointMatrix[3][1] = 0.0;\n\t\t    jointMatrix[3][2] = 0.0;\n\t\t    normalAnimationTransform += (jointMatrix * a_weights.z);\n\t\t    \n\t\t    //apply the fourth joint to the animation transforms\n\t\t    jointIndex = int(a_jointIndices.w + 0.5);\n\t\t    jointVector0 = u_joints[jointIndex * 3 + 0];\n\t\t    jointVector1 = u_joints[jointIndex * 3 + 1];\n\t\t    jointVector2 = u_joints[jointIndex * 3 + 2];\n\t\t\tjointMatrix[0][0] = jointVector0.x; jointMatrix[0][1] = jointVector1.x; jointMatrix[0][2] = jointVector2.x; jointMatrix[0][3] = 0.0;\n\t\t\tjointMatrix[1][0] = jointVector0.y; jointMatrix[1][1] = jointVector1.y; jointMatrix[1][2] = jointVector2.y; jointMatrix[1][3] = 0.0;\n\t\t\tjointMatrix[2][0] = jointVector0.z; jointMatrix[2][1] = jointVector1.z; jointMatrix[2][2] = jointVector2.z; jointMatrix[2][3] = 0.0;\n\t\t\tjointMatrix[3][0] = jointVector0.w; jointMatrix[3][1] = jointVector1.w; jointMatrix[3][2] = jointVector2.w; jointMatrix[3][3] = 1.0;\n\t\t    animationTransform += (jointMatrix * (1.0 - a_weights.x - a_weights.y - a_weights.z));\n\t\t    jointMatrix[3][0] = 0.0;\n\t\t    jointMatrix[3][1] = 0.0;\n\t\t    jointMatrix[3][2] = 0.0;\n\t\t    normalAnimationTransform += (jointMatrix * (1.0 - a_weights.x - a_weights.y - a_weights.z));\n\t\t    \n\t\t    //Convert the vertex from local space to projection and world space.\n\t\t\tvec4 localPosition = animationTransform * a_position;\n\t\t    gl_Position = u_wvpMat * localPosition;\n\t\t\tvec4 vWorldPosition = u_worldMat * localPosition;\n\t\t    vvShadowPosition = u_lightMat * vWorldPosition;\n\t\t    vvShadowPosition = (vvShadowPosition * 0.5 + 0.5);\n\t\t    \n\t\t    // Calculate normal in world space\n\t\t    vec4 localNormal = normalAnimationTransform * vec4((a_normal), 1.0);\n\t\t\tvvNormal = normalize((u_normalMat * localNormal).xyz);\n\t\t    \n\t\t    //calculate the half vector.\n\t\t    vec3 vVertexToEye = normalize(u_cameraPos - vWorldPosition.xyz);\n\t\t    vvHalfVector = normalize(-u_lightDir + vVertexToEye);\n\t\t    \n\t\t\t//get the tex coord\n\t\t\tvvTexCoord = a_texCoord;\n\t\t}\n\t}\n\n\tFragmentShader\n\t{\n\t\t#ifndef GL_ES\n\t\t#define lowp\n\t\t#define mediump\n\t\t#define highp\n\t\t#else\n\t\tprecision lowp float;\n\t\t#endif\n\n\t\t//uniforms\n\t\tuniform lowp sampler2D u_texture0;\n\t\tuniform highp float u_shadowTolerance;\n\t\tuniform highp sampler2D u_shadowMap;\n\n\t\tuniform lowp vec4 u_diffuse;\n\t\tuniform lowp vec4 u_specular;\n\t\tuniform lowp vec4 u_lightCol;\n\t\tuniform mediump vec3 u_lightDir;\n\n\t\t//varyings\n\t\tvarying mediump vec2 vvTexCoord;\n\t\tvarying mediump vec3 vvHalfVector;\n\t\tvarying mediump vec3 vvNormal;\n\t\tvarying highp vec4 vvShadowPosition;\n\n\t\tvoid main()\n\t\t{\n\t\t\tvec3 vNormal = normalize(vvNormal);\n\t\t\tvec3 vHalfVector = normalize(vvHalfVector);\n\t\t    \n\t\t    //calculate the diffuse colour\n\t\t    float fNdotL = max(dot(vNormal, -u_lightDir), 0.0);\n\t\t    vec4 vDiffuse = u_diffuse * fNdotL;\n\t\t    \n\t\t    //calculate the specular colour\n\t\t    float fNdotHV = max(dot(vNormal, vHalfVector), 0.0);\n\t\t    float fLightSwitch = step(0.001, fNdotL);\n\t\t    vec4 vSpecular = vec4(u_specular.xyz * pow(fNdotHV, u_specular.a) * fLightSwitch, 1.0);\n\t\t    \n\t\t    //get the shadow factor\n\t\t    float fMapDepth = texture2D(u_shadowMap, vvShadowPosition.xy).r;\n\t\t\tfloat fShadowFactor = min(ceil(max((fMapDepth + u_shadowTolerance) - vvShadowPosition.z, 0.0)), 1.0);\n\t\t    \n\t\t\t//ensure there is no shadow beyond the borders of the shadow map.\n\t\t\tfloat fBorderXFactor = min(abs(floor(vvShadowPosition.x)), 1.0);\n\t\t\tfloat fBorderYFactor = min(abs(floor(vvShadowPosition.y)), 1.0);\n\t\t\tfloat fBorderZFactor = min(abs(floor(vvShadowPosition.z)), 1.0);\n\t\t\tfShadowFactor = max(max(max(fShadowFactor, fBorderXFactor), fBorderYFactor), fBorderZFactor);\n\t\t    \n\t\t\t//calculate the final colour\n\t\t\tvec4 vColour = (vDiffuse + vSpecular) * u_lightCol * fShadowFactor;\n\t\t\tgl_FragColor = vColour * texture2D(u_texture0, vvTexCoord);\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "CSResources/Shaders/Animated-Blinn-Point.csshader",
    "content": "//\n//  AnimatedBlinnPoint.csshader\n//  ChilliSource\n//  Created by I Copland on 29/01/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\nGLSL\n{\n    VertexShader\n    {\n        #ifndef GL_ES\n        #define lowp\n        #define mediump\n        #define highp\n        #endif\n\n        //attributes\n        attribute highp vec4 a_position;\n        attribute mediump vec3 a_normal;\n        attribute mediump vec2 a_texCoord;\n        attribute highp vec4 a_weights;\n        attribute highp vec4 a_jointIndices;\n\n        //uniforms\n        uniform highp vec3 u_lightPos;\n        uniform highp mat4 u_wvpMat;\n        uniform highp mat4 u_worldMat;\n        uniform highp mat4 u_normalMat;\n        uniform highp vec4 u_joints[100];\n        uniform lowp vec3 u_cameraPos;\n\n        //varyings\n        varying mediump vec3 vvLightDir;\n        varying mediump vec2 vvTexCoord;\n        varying mediump vec3 vvHalfVector;\n        varying mediump vec3 vvNormal;\n        varying mediump float vfLightDistance;\n\n        void main()\n        {\n            //Apply the first joint to the animation transforms\n            int jointIndex = int(a_jointIndices.x + 0.5);\n            vec4 jointVector0 = u_joints[jointIndex * 3 + 0];\n            vec4 jointVector1 = u_joints[jointIndex * 3 + 1];\n            vec4 jointVector2 = u_joints[jointIndex * 3 + 2];\n            mat4 jointMatrix = mat4(jointVector0.x, jointVector1.x, jointVector2.x, 0.0,\n                                    jointVector0.y, jointVector1.y, jointVector2.y, 0.0,\n                                    jointVector0.z, jointVector1.z, jointVector2.z, 0.0,\n                                    jointVector0.w, jointVector1.w, jointVector2.w, 1.0);\n            mat4 animationTransform = (jointMatrix * a_weights.x);\n            jointMatrix[3][0] = 0.0;\n            jointMatrix[3][1] = 0.0;\n            jointMatrix[3][2] = 0.0;\n            mat4 normalAnimationTransform = (jointMatrix * a_weights.x);\n            \n            //apply the second joint to the animation transforms\n            jointIndex = int(a_jointIndices.y + 0.5);\n            jointVector0 = u_joints[jointIndex * 3 + 0];\n            jointVector1 = u_joints[jointIndex * 3 + 1];\n            jointVector2 = u_joints[jointIndex * 3 + 2];\n            jointMatrix[0][0] = jointVector0.x; jointMatrix[0][1] = jointVector1.x; jointMatrix[0][2] = jointVector2.x; jointMatrix[0][3] = 0.0;\n            jointMatrix[1][0] = jointVector0.y; jointMatrix[1][1] = jointVector1.y; jointMatrix[1][2] = jointVector2.y; jointMatrix[1][3] = 0.0;\n            jointMatrix[2][0] = jointVector0.z; jointMatrix[2][1] = jointVector1.z; jointMatrix[2][2] = jointVector2.z; jointMatrix[2][3] = 0.0;\n            jointMatrix[3][0] = jointVector0.w; jointMatrix[3][1] = jointVector1.w; jointMatrix[3][2] = jointVector2.w; jointMatrix[3][3] = 1.0;\n            animationTransform += (jointMatrix * a_weights.y);\n            jointMatrix[3][0] = 0.0;\n            jointMatrix[3][1] = 0.0;\n            jointMatrix[3][2] = 0.0;\n            normalAnimationTransform += (jointMatrix * a_weights.y);\n            \n            //apply the third joint to the animation transforms\n            jointIndex = int(a_jointIndices.z + 0.5);\n            jointVector0 = u_joints[jointIndex * 3 + 0];\n            jointVector1 = u_joints[jointIndex * 3 + 1];\n            jointVector2 = u_joints[jointIndex * 3 + 2];\n            jointMatrix[0][0] = jointVector0.x; jointMatrix[0][1] = jointVector1.x; jointMatrix[0][2] = jointVector2.x; jointMatrix[0][3] = 0.0;\n            jointMatrix[1][0] = jointVector0.y; jointMatrix[1][1] = jointVector1.y; jointMatrix[1][2] = jointVector2.y; jointMatrix[1][3] = 0.0;\n            jointMatrix[2][0] = jointVector0.z; jointMatrix[2][1] = jointVector1.z; jointMatrix[2][2] = jointVector2.z; jointMatrix[2][3] = 0.0;\n            jointMatrix[3][0] = jointVector0.w; jointMatrix[3][1] = jointVector1.w; jointMatrix[3][2] = jointVector2.w; jointMatrix[3][3] = 1.0;\n            animationTransform += (jointMatrix * a_weights.z);\n            jointMatrix[3][0] = 0.0;\n            jointMatrix[3][1] = 0.0;\n            jointMatrix[3][2] = 0.0;\n            normalAnimationTransform += (jointMatrix * a_weights.z);\n            \n            //apply the fourth joint to the animation transforms\n            jointIndex = int(a_jointIndices.w + 0.5);\n            jointVector0 = u_joints[jointIndex * 3 + 0];\n            jointVector1 = u_joints[jointIndex * 3 + 1];\n            jointVector2 = u_joints[jointIndex * 3 + 2];\n            jointMatrix[0][0] = jointVector0.x; jointMatrix[0][1] = jointVector1.x; jointMatrix[0][2] = jointVector2.x; jointMatrix[0][3] = 0.0;\n            jointMatrix[1][0] = jointVector0.y; jointMatrix[1][1] = jointVector1.y; jointMatrix[1][2] = jointVector2.y; jointMatrix[1][3] = 0.0;\n            jointMatrix[2][0] = jointVector0.z; jointMatrix[2][1] = jointVector1.z; jointMatrix[2][2] = jointVector2.z; jointMatrix[2][3] = 0.0;\n            jointMatrix[3][0] = jointVector0.w; jointMatrix[3][1] = jointVector1.w; jointMatrix[3][2] = jointVector2.w; jointMatrix[3][3] = 1.0;\n            animationTransform += (jointMatrix * (1.0 - a_weights.x - a_weights.y - a_weights.z));\n            jointMatrix[3][0] = 0.0;\n            jointMatrix[3][1] = 0.0;\n            jointMatrix[3][2] = 0.0;\n            normalAnimationTransform += (jointMatrix * (1.0 - a_weights.x - a_weights.y - a_weights.z));\n            \n            //Convert the vertex from local space to projection and world space.\n            vec4 localPosition = animationTransform * a_position;\n            gl_Position = u_wvpMat * localPosition;\n            vec4 vWorldPosition = u_worldMat * localPosition;\n            \n            // Calculate normal in world space\n            vec4 localNormal = normalAnimationTransform * vec4((a_normal), 1.0);\n            vvNormal = normalize((u_normalMat * localNormal).xyz);\n            \n            //calculate the light direction.\n            vvLightDir = vWorldPosition.xyz - u_lightPos;\n            vfLightDistance = length(vvLightDir);\n            vvLightDir = normalize(vvLightDir);\n            \n            //calculate the half vector.\n            vec3 vVertexToEye = normalize(u_cameraPos - vWorldPosition.xyz);\n            vvHalfVector = normalize(-vvLightDir + vVertexToEye);\n            \n            //get the tex coord\n            vvTexCoord = a_texCoord;\n        }\n    }\n\n    FragmentShader\n    {\n        #ifndef GL_ES\n        #define lowp\n        #define mediump\n        #define highp\n        #else\n        precision lowp float;\n        #endif\n\n        //uniforms\n        uniform lowp sampler2D u_texture0;\n        uniform highp float u_shadowTolerance;\n        uniform highp sampler2D u_shadowMap;\n\n        uniform lowp vec4 u_diffuse;\n        uniform lowp vec4 u_specular;\n        uniform lowp vec4 u_lightCol;\n\n        uniform mediump float u_attenuationConstant;\n        uniform mediump float u_attenuationLinear;\n        uniform mediump float u_attenuationQuadratic;\n\n\n        //varyings\n        varying mediump vec2 vvTexCoord;\n        varying mediump vec3 vvHalfVector;\n        varying mediump vec3 vvLightDir;\n        varying mediump vec3 vvNormal;\n        varying mediump float vfLightDistance;\n        varying highp vec4 vvShadowPosition;\n\n        void main()\n        {\n            vec3 vNormal = normalize(vvNormal);\n        \tvec3 vLightDir = normalize(vvLightDir);\n        \tvec3 vHalfVector = normalize(vvHalfVector);\n            \n            //calculate the attenuation.\n            float fAttenuation = 1.0 / (u_attenuationConstant + (u_attenuationLinear * vfLightDistance) + (u_attenuationQuadratic * vfLightDistance * vfLightDistance));\n            \n            //calculate the diffuse colour\n            float fNdotL = max(dot(vNormal, -vLightDir), 0.0);\n            vec4 vDiffuse = u_diffuse * fNdotL;\n            \n            //calculate the specular colour\n            float fNdotHV = max(dot(vNormal, vHalfVector), 0.0);\n            float fLightSwitch = step(0.001, fNdotL);\n            vec4 vSpecular = vec4(u_specular.xyz * pow(fNdotHV, u_specular.a) * fLightSwitch, 1.0);\n            \n        \t//calculate the final colour\n        \tvec4 vColour = (vDiffuse + vSpecular) * u_lightCol;\n            vColour.rgb *= fAttenuation;\n        \tgl_FragColor = vColour * texture2D(u_texture0, vvTexCoord);\n        }\n    }\n}\n"
  },
  {
    "path": "CSResources/Shaders/Animated-ShadowMap.csshader",
    "content": "//\n//  AnimatedDirectionalShadowMap.csshader\n//  ChilliSource\n//  Created by I Copland on 29/01/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\nGLSL\n{\n\tVertexShader\n\t{\n\t\t#ifndef GL_ES\n\t\t#define lowp\n\t\t#define mediump\n\t\t#define highp\n\t\t#endif\n\n\t\t//attributes\n\t\tattribute highp vec4 a_position;\n\t\tattribute highp vec4 a_weights;\n\t\tattribute highp vec4 a_jointIndices;\n\n\t\t//uniforms\n\t\tuniform highp mat4 u_wvpMat;\n\t\tuniform highp vec4 u_joints[100];\n\n\t\t//varyings\n\t\tvarying highp float v_depth;\n\n\t\tvoid main()\n\t\t{\n\t\t    //Apply the first joint to the animation transforms\n\t\t\tint jointIndex = int(a_jointIndices.x + 0.5);\n\t\t    vec4 jointVector0 = u_joints[jointIndex * 3 + 0];\n\t\t    vec4 jointVector1 = u_joints[jointIndex * 3 + 1];\n\t\t    vec4 jointVector2 = u_joints[jointIndex * 3 + 2];\n\t\t\tmat4 jointMatrix = mat4(jointVector0.x, jointVector1.x, jointVector2.x, 0.0,\n\t\t                            jointVector0.y, jointVector1.y, jointVector2.y, 0.0,\n\t\t                            jointVector0.z, jointVector1.z, jointVector2.z, 0.0,\n\t\t                            jointVector0.w, jointVector1.w, jointVector2.w, 1.0);\n\t\t    mat4 animationTransform = (jointMatrix * a_weights.x);\n\t\t    \n\t\t    //apply the second joint to the animation transforms\n\t\t    jointIndex = int(a_jointIndices.y + 0.5);\n\t\t    jointVector0 = u_joints[jointIndex * 3 + 0];\n\t\t    jointVector1 = u_joints[jointIndex * 3 + 1];\n\t\t    jointVector2 = u_joints[jointIndex * 3 + 2];\n\t\t\tjointMatrix[0][0] = jointVector0.x; jointMatrix[0][1] = jointVector1.x; jointMatrix[0][2] = jointVector2.x; jointMatrix[0][3] = 0.0;\n\t\t\tjointMatrix[1][0] = jointVector0.y; jointMatrix[1][1] = jointVector1.y; jointMatrix[1][2] = jointVector2.y; jointMatrix[1][3] = 0.0;\n\t\t\tjointMatrix[2][0] = jointVector0.z; jointMatrix[2][1] = jointVector1.z; jointMatrix[2][2] = jointVector2.z; jointMatrix[2][3] = 0.0;\n\t\t\tjointMatrix[3][0] = jointVector0.w; jointMatrix[3][1] = jointVector1.w; jointMatrix[3][2] = jointVector2.w; jointMatrix[3][3] = 1.0;\n\t\t    animationTransform += (jointMatrix * a_weights.y);\n\t\t    \n\t\t    //apply the third joint to the animation transforms\n\t\t    jointIndex = int(a_jointIndices.z + 0.5);\n\t\t    jointVector0 = u_joints[jointIndex * 3 + 0];\n\t\t    jointVector1 = u_joints[jointIndex * 3 + 1];\n\t\t    jointVector2 = u_joints[jointIndex * 3 + 2];\n\t\t\tjointMatrix[0][0] = jointVector0.x; jointMatrix[0][1] = jointVector1.x; jointMatrix[0][2] = jointVector2.x; jointMatrix[0][3] = 0.0;\n\t\t\tjointMatrix[1][0] = jointVector0.y; jointMatrix[1][1] = jointVector1.y; jointMatrix[1][2] = jointVector2.y; jointMatrix[1][3] = 0.0;\n\t\t\tjointMatrix[2][0] = jointVector0.z; jointMatrix[2][1] = jointVector1.z; jointMatrix[2][2] = jointVector2.z; jointMatrix[2][3] = 0.0;\n\t\t\tjointMatrix[3][0] = jointVector0.w; jointMatrix[3][1] = jointVector1.w; jointMatrix[3][2] = jointVector2.w; jointMatrix[3][3] = 1.0;\n\t\t    animationTransform += (jointMatrix * a_weights.z);\n\t\t    \n\t\t    //apply the fourth joint to the animation transforms\n\t\t    jointIndex = int(a_jointIndices.w + 0.5);\n\t\t    jointVector0 = u_joints[jointIndex * 3 + 0];\n\t\t    jointVector1 = u_joints[jointIndex * 3 + 1];\n\t\t    jointVector2 = u_joints[jointIndex * 3 + 2];\n\t\t\tjointMatrix[0][0] = jointVector0.x; jointMatrix[0][1] = jointVector1.x; jointMatrix[0][2] = jointVector2.x; jointMatrix[0][3] = 0.0;\n\t\t\tjointMatrix[1][0] = jointVector0.y; jointMatrix[1][1] = jointVector1.y; jointMatrix[1][2] = jointVector2.y; jointMatrix[1][3] = 0.0;\n\t\t\tjointMatrix[2][0] = jointVector0.z; jointMatrix[2][1] = jointVector1.z; jointMatrix[2][2] = jointVector2.z; jointMatrix[2][3] = 0.0;\n\t\t\tjointMatrix[3][0] = jointVector0.w; jointMatrix[3][1] = jointVector1.w; jointMatrix[3][2] = jointVector2.w; jointMatrix[3][3] = 1.0;\n\t\t    animationTransform += (jointMatrix * (1.0 - a_weights.x - a_weights.y - a_weights.z));\n\n\t\t    //Convert the vertex from local space to projection and world space.\n            vec4 localPosition = animationTransform * a_position;\n\t\t    gl_Position = u_wvpMat * localPosition;\n\t\t    v_depth = gl_Position.z;\n\t\t}\n\t}\n\n\tFragmentShader\n\t{\n\t\t#ifndef GL_ES\n\t\t#define lowp\n\t\t#define mediump\n\t\t#define highp\n\t\t#else\n\t\tprecision lowp float;\n\t\t#endif\n\n\t\t//varyings\n\t\tvarying highp float v_depth;\n\n\t\tvoid main()\n\t\t{\n\t\t\tgl_FragColor = vec4(v_depth, v_depth, v_depth, 1.0);\n\t\t}\n\t}\n}\n\n"
  },
  {
    "path": "CSResources/Shaders/Animated-Unlit.csshader",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\nGLSL\n{\n\tVertexShader\n\t{\n\t\t#ifndef GL_ES\n\t\t#define lowp\n\t\t#define mediump\n\t\t#define highp\n\t\t#endif\n\n\n\t\t//attributes\n\t\tattribute highp vec4 a_position;\n\t\tattribute mediump vec2 a_texCoord;\n\t\tattribute mediump vec4 a_weights;\n\t\tattribute highp vec4 a_jointIndices;\n\n\t\t//uniforms\n\t\tuniform highp mat4 u_wvpMat;\n\t\tuniform highp vec4 u_joints[100];\n\n\t\t//varyings\n\t\tvarying mediump vec2 vvTexCoord;\n\n\t\tvoid main()\n\t\t{\n\t\t    //Apply the first joint to the animation transforms\n\t\t\tint jointIndex = int(a_jointIndices.x + 0.5);\n\t\t    vec4 jointVector0 = u_joints[jointIndex * 3 + 0];\n\t\t    vec4 jointVector1 = u_joints[jointIndex * 3 + 1];\n\t\t    vec4 jointVector2 = u_joints[jointIndex * 3 + 2];\n\t\t\tmat4 jointMatrix = mat4(jointVector0.x, jointVector1.x, jointVector2.x, 0.0,\n\t\t                            jointVector0.y, jointVector1.y, jointVector2.y, 0.0,\n\t\t                            jointVector0.z, jointVector1.z, jointVector2.z, 0.0,\n\t\t                            jointVector0.w, jointVector1.w, jointVector2.w, 1.0);\n\t\t    mat4 animationTransform = (jointMatrix * a_weights.x);\n\t\t    \n\t\t    //apply the second joint to the animation transforms\n\t\t    jointIndex = int(a_jointIndices.y + 0.5);\n\t\t    jointVector0 = u_joints[jointIndex * 3 + 0];\n\t\t    jointVector1 = u_joints[jointIndex * 3 + 1];\n\t\t    jointVector2 = u_joints[jointIndex * 3 + 2];\n\t\t\tjointMatrix[0][0] = jointVector0.x; jointMatrix[0][1] = jointVector1.x; jointMatrix[0][2] = jointVector2.x; jointMatrix[0][3] = 0.0;\n\t\t\tjointMatrix[1][0] = jointVector0.y; jointMatrix[1][1] = jointVector1.y; jointMatrix[1][2] = jointVector2.y; jointMatrix[1][3] = 0.0;\n\t\t\tjointMatrix[2][0] = jointVector0.z; jointMatrix[2][1] = jointVector1.z; jointMatrix[2][2] = jointVector2.z; jointMatrix[2][3] = 0.0;\n\t\t\tjointMatrix[3][0] = jointVector0.w; jointMatrix[3][1] = jointVector1.w; jointMatrix[3][2] = jointVector2.w; jointMatrix[3][3] = 1.0;\n\t\t    animationTransform += (jointMatrix * a_weights.y);\n\t\t    \n\t\t    //apply the third joint to the animation transforms\n\t\t    jointIndex = int(a_jointIndices.z + 0.5);\n\t\t    jointVector0 = u_joints[jointIndex * 3 + 0];\n\t\t    jointVector1 = u_joints[jointIndex * 3 + 1];\n\t\t    jointVector2 = u_joints[jointIndex * 3 + 2];\n\t\t\tjointMatrix[0][0] = jointVector0.x; jointMatrix[0][1] = jointVector1.x; jointMatrix[0][2] = jointVector2.x; jointMatrix[0][3] = 0.0;\n\t\t\tjointMatrix[1][0] = jointVector0.y; jointMatrix[1][1] = jointVector1.y; jointMatrix[1][2] = jointVector2.y; jointMatrix[1][3] = 0.0;\n\t\t\tjointMatrix[2][0] = jointVector0.z; jointMatrix[2][1] = jointVector1.z; jointMatrix[2][2] = jointVector2.z; jointMatrix[2][3] = 0.0;\n\t\t\tjointMatrix[3][0] = jointVector0.w; jointMatrix[3][1] = jointVector1.w; jointMatrix[3][2] = jointVector2.w; jointMatrix[3][3] = 1.0;\n\t\t    animationTransform += (jointMatrix * a_weights.z);\n\t\t    \n\t\t    //apply the fourth joint to the animation transforms\n\t\t    jointIndex = int(a_jointIndices.w + 0.5);\n\t\t    jointVector0 = u_joints[jointIndex * 3 + 0];\n\t\t    jointVector1 = u_joints[jointIndex * 3 + 1];\n\t\t    jointVector2 = u_joints[jointIndex * 3 + 2];\n\t\t\tjointMatrix[0][0] = jointVector0.x; jointMatrix[0][1] = jointVector1.x; jointMatrix[0][2] = jointVector2.x; jointMatrix[0][3] = 0.0;\n\t\t\tjointMatrix[1][0] = jointVector0.y; jointMatrix[1][1] = jointVector1.y; jointMatrix[1][2] = jointVector2.y; jointMatrix[1][3] = 0.0;\n\t\t\tjointMatrix[2][0] = jointVector0.z; jointMatrix[2][1] = jointVector1.z; jointMatrix[2][2] = jointVector2.z; jointMatrix[2][3] = 0.0;\n\t\t\tjointMatrix[3][0] = jointVector0.w; jointMatrix[3][1] = jointVector1.w; jointMatrix[3][2] = jointVector2.w; jointMatrix[3][3] = 1.0;\n\t\t    animationTransform += (jointMatrix * (1.0 - a_weights.x - a_weights.y - a_weights.z));\n\n\t\t    //Convert the vertex from local space to projection and world space.\n\t\t    gl_Position = u_wvpMat * animationTransform * a_position;\n\n\t\t\t//get the tex coord\n\t\t\tvvTexCoord = a_texCoord;\n\t\t}\n\t}\n\t\n\tFragmentShader\n\t{\n\t\t#ifndef GL_ES\n\t\t#define lowp\n\t\t#define mediump\n\t\t#define highp\n\t\t#else\n\t\tprecision lowp float;\n\t\t#endif\n\n\t\t//uniforms\n\t\tuniform lowp sampler2D u_texture0;\n\t\tuniform lowp vec4 u_emissive;\n\n\t\t//varyings\n\t\tvarying mediump vec2 vvTexCoord;\n\n\t\tvoid main()\n\t\t{\n\t\t\tgl_FragColor = texture2D(u_texture0, vvTexCoord) * u_emissive;\n\t\t}\n\t}\n}"
  },
  {
    "path": "CSResources/Shaders/Skybox.csshader",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2017 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\nGLSL\n{\n\tVertexShader\n\t{\n#ifndef GL_ES\n        #define lowp\n        #define mediump\n        #define highp\n#endif\n\n        //attributes\n        attribute highp vec4 a_position;\n        attribute mediump vec2 a_texCoord;\n\n        //uniforms\n        uniform highp mat4 u_wvpMat;\n\n        //varyings\n        varying mediump vec3 v_texCoord;\n\n        void main()\n        {\n        \t//By using'w' as 'z' we ensure that the skybox is always at the maximum depth\n            gl_Position = (u_wvpMat * a_position).xyww;\n            v_texCoord = normalize(a_position.xyz);\n        }\n\t}\n\n\tFragmentShader\n\t{\n#ifndef GL_ES\n\t\t#define lowp\n\t\t#define mediump\n\t\t#define highp\n#else\n\t\tprecision lowp float;\n#endif\n\n\t\t//uniforms\n\t\tuniform lowp samplerCube u_cubemap0;\n\n\t\t//varyings\n\t\tvarying mediump vec3 v_texCoord;\n\n\t\tvoid main()\n\t\t{\n\t\t\tgl_FragColor = textureCube(u_cubemap0, v_texCoord);\n\t\t}\n\t}\n}"
  },
  {
    "path": "CSResources/Shaders/Sprite-Unlit.csshader",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\nGLSL\n{\n\tVertexShader\n\t{\n\t\t#ifndef GL_ES\n\t\t#define lowp\n\t\t#define mediump\n\t\t#define highp\n\t\t#endif\n\n\t\t//attributes\n\t\tattribute highp vec4 a_position;\n\t\tattribute lowp vec4 a_colour;\n\t\tattribute mediump vec2 a_texCoord;\n\n\t\t//uniforms\n\t\tuniform highp mat4 u_wvpMat;\n\t\tuniform lowp vec4 u_emissive;\n\n\t\t//varyings\n\t\tvarying lowp vec4 vvColour;\n\t\tvarying mediump vec2 vvTexCoord;\n\n\t\tvoid main()\n\t\t{\n\t\t    gl_Position = u_wvpMat * a_position;\n\t\t    vvColour = a_colour * u_emissive;\n\t\t    vvTexCoord = a_texCoord;\n\t\t}\n\t}\n\t\n\tFragmentShader\n\t{\n\t\t#ifndef GL_ES\n\t\t#define lowp\n\t\t#define mediump\n\t\t#define highp\n\t\t#else\n\t\tprecision lowp float;\n\t\t#endif\n\n\t\t//uniforms\n\t\tuniform lowp sampler2D u_texture0;\n\n\t\t//varyings\n\t\tvarying lowp vec4 vvColour;\n\t\tvarying mediump vec2 vvTexCoord;\n\n\t\tvoid main()\n\t\t{\n\t\t\tgl_FragColor = texture2D(u_texture0, vvTexCoord) * vvColour;\n\t\t}\n\t}\n}\n\n"
  },
  {
    "path": "CSResources/Shaders/Sprite-UnlitStencil.csshader",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\nGLSL\n{\n\tVertexShader\n\t{\n\t\t#ifndef GL_ES\n\t\t#define lowp\n\t\t#define mediump\n\t\t#define highp\n\t\t#endif\n\n\t\t//attributes\n\t\tattribute highp vec4 a_position;\n\t\tattribute lowp vec4 a_colour;\n\t\tattribute mediump vec2 a_texCoord;\n\n\t\t//uniforms\n\t\tuniform highp mat4 u_wvpMat;\n\t\tuniform lowp vec4 u_emissive;\n\n\t\t//varyings\n\t\tvarying lowp vec4 vvColour;\n\t\tvarying mediump vec2 vvTexCoord;\n\n\t\tvoid main()\n\t\t{\n\t\t    gl_Position = u_wvpMat * a_position;\n\t\t    vvColour = a_colour * u_emissive;\n\t\t    vvTexCoord = a_texCoord;\n\t\t}\n\t}\n\t\n\tFragmentShader\n\t{\n\t\t#ifndef GL_ES\n\t\t#define lowp\n\t\t#define mediump\n\t\t#define highp\n\t\t#else\n\t\tprecision lowp float;\n\t\t#endif\n\n\t\t//uniforms\n\t\tuniform lowp sampler2D u_texture0;\n\n\t\t//varyings\n\t\tvarying lowp vec4 vvColour;\n\t\tvarying mediump vec2 vvTexCoord;\n\n\t\tvoid main()\n\t\t{\n\t\t\tgl_FragColor = texture2D(u_texture0, vvTexCoord) * vvColour;\n\n\t\t\t//Pick a small alpha test value for pixels that are invisble to the eye\n\t\t\tif(gl_FragColor.a < 0.05)\n\t\t\t{\n\t\t\t\tdiscard;\n\t\t\t}\n\t\t}\n\t}\n}\n\n"
  },
  {
    "path": "CSResources/Shaders/Static-Blinn-Base.csshader",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\nGLSL\n{\n\tVertexShader\n\t{\n\t\t#ifndef GL_ES\n\t\t#define lowp\n\t\t#define mediump\n\t\t#define highp\n\t\t#endif\n\n\t\t//attribute\n\t\tattribute highp vec4 a_position;\n\t\tattribute mediump vec2 a_texCoord;\n\n\t\t//uniforms\n\t\tuniform highp mat4 u_wvpMat;\n\t\tuniform lowp vec4 u_emissive;\n\t\tuniform lowp vec4 u_ambient;\n\t\tuniform lowp vec4 u_lightCol;\n\n\t\t//varyings\n\t\tvarying mediump vec2 vvTexCoord;\n\t\tvarying lowp vec4 vvColour;\n\n\t\tvoid main()\n\t\t{\n\t\t    //Convert the vertex from world space to projection\n\t\t    gl_Position = u_wvpMat * a_position;\n\t\t    \n\t\t    //Apply the texture matrix to the texture coordinates\n\t\t    vvTexCoord = a_texCoord;\n\t\t    \n\t\t    //calulate the lighting colour\n\t\t    vvColour = (u_emissive + (u_ambient * u_lightCol));\n\t\t}\n\t}\n\t\n\tFragmentShader\n\t{\n\t\t#ifndef GL_ES\n\t\t#define lowp\n\t\t#define mediump\n\t\t#define highp\n\t\t#else\n\t\tprecision lowp float;\n\t\t#endif\n\n\t\t//uniforms\n\t\tuniform lowp sampler2D u_texture0;\n\n\t\t//varyings\n\t\tvarying mediump vec2 vvTexCoord;\n\t\tvarying lowp vec4 vvColour;\n\n\t\tvoid main()\n\t\t{\n\t\t\tgl_FragColor = vvColour * texture2D(u_texture0, vvTexCoord);\n\t\t}\n\t}\n}\n\n"
  },
  {
    "path": "CSResources/Shaders/Static-Blinn-Directional.csshader",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\nGLSL\n{\n    VertexShader\n    {\n    #ifndef GL_ES\n\t\t#define lowp\n\t\t#define mediump\n\t\t#define highp\n\t\t#endif\n\n\t\t//attributes\n\t\tattribute highp vec4 a_position;\n\t\tattribute mediump vec3 a_normal;\n\t\tattribute mediump vec2 a_texCoord;\n\n\t\t//uniforms\n\t\tuniform mediump vec3 u_lightDir;\n\t\tuniform highp mat4 u_wvpMat;\n\t\tuniform highp mat4 u_worldMat;\n\t\tuniform highp mat4 u_normalMat;\n\n\t\tuniform highp vec3 u_cameraPos;\n\n\t\t//varyings\n\t\tvarying mediump vec2 vvTexCoord;\n\t\tvarying mediump vec3 vvHalfVector;\n\t\tvarying mediump vec3 vvNormal;\n\n\t\tvoid main()\n\t\t{\n\t\t    gl_Position = u_wvpMat * a_position;\n\t\t    vec4 vWorldPosition = u_worldMat * a_position;\n\t\t    \n\t\t    //calculate the normal\n\t\t    vvNormal = (u_normalMat * vec4(a_normal, 1.0)).xyz;\n\t\t    \n\t\t    //calculate the half vector.\n\t\t    vec3 vVertexToEye = normalize(u_cameraPos - vWorldPosition.xyz);\n\t\t    vvHalfVector = normalize(-u_lightDir + vVertexToEye);\n\t\t    \n\t\t\t//get the tex coord\n\t\t\tvvTexCoord = a_texCoord;\n\t\t}\n    }\n\n    FragmentShader\n    {\n        #ifndef GL_ES\n        #define lowp\n        #define mediump\n        #define highp\n        #else\n        precision lowp float;\n        #endif\n\n        //uniforms\n        uniform lowp sampler2D u_texture0;\n\n        uniform lowp vec4 u_diffuse;\n        uniform lowp vec4 u_specular;\n        uniform lowp vec4 u_lightCol;\n        uniform mediump vec3 u_lightDir;\n\n        //varyings\n        varying mediump vec2 vvTexCoord;\n        varying mediump vec3 vvHalfVector;\n        varying mediump vec3 vvNormal;\n\n        void main()\n        {\n        \tvec3 vNormal = normalize(vvNormal);\n        \tvec3 vHalfVector = normalize(vvHalfVector);\n            \n            //calculate the diffuse colour\n            float fNdotL = max(dot(vNormal, -u_lightDir), 0.0);\n            vec4 vDiffuse = u_diffuse * fNdotL;\n            \n            //calculate the specular colour\n            float fNdotHV = max(dot(vNormal, vHalfVector), 0.0);\n            float fLightSwitch = step(0.001, fNdotL);\n            vec4 vSpecular = vec4(u_specular.xyz * pow(fNdotHV, u_specular.a) * fLightSwitch, 1.0);\n            \n        \t//calculate the final colour\n        \tvec4 vColour = (vDiffuse + vSpecular) * u_lightCol;\n        \tgl_FragColor = vColour * texture2D(u_texture0, vvTexCoord);\n        }\n    }\n}"
  },
  {
    "path": "CSResources/Shaders/Static-Blinn-DirectionalShadows.csshader",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\nGLSL\n{\n\tVertexShader\n\t{\n        #ifndef GL_ES\n        #define lowp\n        #define mediump\n        #define highp\n        #endif\n\n        //attributes\n        attribute highp vec4 a_position;\n        attribute mediump vec3 a_normal;\n        attribute mediump vec2 a_texCoord;\n\n        //uniforms\n        uniform mediump vec3 u_lightDir;\n        uniform highp mat4 u_wvpMat;\n        uniform highp mat4 u_worldMat;\n        uniform highp mat4 u_normalMat;\n        uniform highp mat4 u_lightMat;\n\n        uniform highp vec3 u_cameraPos;\n\n        //varyings\n        varying mediump vec2 vvTexCoord;\n        varying mediump vec3 vvHalfVector;\n        varying mediump vec3 vvNormal;\n        varying highp vec4 vvShadowPosition;\n\n        void main()\n        {\n            gl_Position = u_wvpMat * a_position;\n            vec4 vWorldPosition = u_worldMat * a_position;\n            \n            //Convert the vertex to shadow space\n            vvShadowPosition = u_lightMat * vWorldPosition;\n            vvShadowPosition = (vvShadowPosition * 0.5 + 0.5);\n            \n            //calculate the normal\n            vvNormal = (u_normalMat * vec4(a_normal, 1.0)).xyz;\n            \n            //calculate the half vector.\n            vec3 vVertexToEye = normalize(u_cameraPos - vWorldPosition.xyz);\n            vvHalfVector = normalize(-u_lightDir + vVertexToEye);\n            \n            //get the tex coord\n            vvTexCoord = a_texCoord;\n        }\n\t}\n\n\tFragmentShader\n\t{\n\t\t#ifndef GL_ES\n\t\t#define lowp\n\t\t#define mediump\n\t\t#define highp\n\t\t#else\n\t\tprecision lowp float;\n\t\t#endif\n\n\t\t//uniforms\n\t\tuniform lowp sampler2D u_texture0;\n\t\tuniform highp float u_shadowTolerance;\n\t\tuniform highp sampler2D u_shadowMap;\n\n\t\tuniform lowp vec4 u_diffuse;\n\t\tuniform lowp vec4 u_specular;\n\t\tuniform lowp vec4 u_lightCol;\n\t\tuniform mediump vec3 u_lightDir;\n\n\t\t//varyings\n\t\tvarying mediump vec2 vvTexCoord;\n\t\tvarying mediump vec3 vvHalfVector;\n\t\tvarying mediump vec3 vvNormal;\n\t\tvarying highp vec4 vvShadowPosition;\n\n\t\tvoid main()\n\t\t{\n\t\t\tvec3 vNormal = normalize(vvNormal);\n\t\t\tvec3 vHalfVector = normalize(vvHalfVector);\n\t\t    \n\t\t    //calculate the diffuse colour\n\t\t    float fNdotL = max(dot(vNormal, -u_lightDir), 0.0);\n\t\t    vec4 vDiffuse = u_diffuse * fNdotL;\n\t\t    \n\t\t    //calculate the specular colour\n\t\t    float fNdotHV = max(dot(vNormal, vHalfVector), 0.0);\n\t\t    float fLightSwitch = step(0.001, fNdotL);\n\t\t    vec4 vSpecular = vec4(u_specular.xyz * pow(fNdotHV, u_specular.a) * fLightSwitch, 1.0);\n\t\t    \n\t\t    //calculate the shadow factor\n\t\t    float fMapDepth = texture2D(u_shadowMap, vvShadowPosition.xy).r;\n\t\t\tfloat fShadowFactor = min(ceil(max((fMapDepth + u_shadowTolerance) - vvShadowPosition.z, 0.0)), 1.0);\n\t\t    \n\t\t\t//ensure there is no shadow beyond the borders of the shadow map.\n\t\t\tfloat fBorderXFactor = min(abs(floor(vvShadowPosition.x)), 1.0);\n\t\t\tfloat fBorderYFactor = min(abs(floor(vvShadowPosition.y)), 1.0);\n\t\t\tfloat fBorderZFactor = min(abs(floor(vvShadowPosition.z)), 1.0);\n\t\t\tfShadowFactor = max(max(max(fShadowFactor, fBorderXFactor), fBorderYFactor), fBorderZFactor);\n\t\t    \n\t\t\t//calculate the final colour\n\t\t\tvec4 vColour = (vDiffuse + vSpecular) * u_lightCol * fShadowFactor;\n\t\t\tgl_FragColor = vColour * texture2D(u_texture0, vvTexCoord);\n\t\t}\n\t}\n}"
  },
  {
    "path": "CSResources/Shaders/Static-Blinn-Point.csshader",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\nGLSL\n{\n    VertexShader\n    {\n        #ifndef GL_ES\n        #define lowp\n        #define mediump\n        #define highp\n        #endif\n\n        //attributes\n        attribute highp vec4 a_position;\n        attribute mediump vec3 a_normal;\n        attribute mediump vec2 a_texCoord;\n\n        //uniforms\n        uniform highp vec3 u_lightPos;\n        uniform highp mat4 u_wvpMat;\n        uniform highp mat4 u_worldMat;\n        uniform highp mat4 u_normalMat;\n        uniform highp vec3 u_cameraPos;\n\n        //varyings\n        varying mediump vec3 vvLightDir;\n        varying mediump vec2 vvTexCoord;\n        varying mediump vec3 vvHalfVector;\n        varying mediump vec3 vvNormal;\n        varying mediump float vfLightDistance;\n\n        void main()\n        {\n            //calculate the vertex position in world space and in clip space.\n            gl_Position = u_wvpMat * a_position;\n            vec4 vWorldPosition = u_worldMat * a_position;\n            \n            //calculate the normal\n            vvNormal = (u_normalMat * vec4(a_normal, 1.0)).xyz;\n            \n            //calculate the light direction.\n            vvLightDir = vWorldPosition.xyz - u_lightPos;\n            vfLightDistance = length(vvLightDir);\n            vvLightDir = normalize(vvLightDir);\n            \n            //calculate the half vector.\n            vec3 vVertexToEye = normalize(u_cameraPos - vWorldPosition.xyz);\n            vvHalfVector = normalize(-vvLightDir + vVertexToEye);\n            \n            //get the tex coord\n            vvTexCoord = a_texCoord;\n        }\n    }\n    \n    FragmentShader\n    {\n        #ifndef GL_ES\n        #define lowp\n        #define mediump\n        #define highp\n        #else\n        precision lowp float;\n        #endif\n\n        //uniforms\n        uniform lowp sampler2D u_texture0;\n\n        uniform lowp vec4 u_diffuse;\n        uniform lowp vec4 u_specular;\n        uniform lowp vec4 u_lightCol;\n\n        uniform mediump float u_attenuationConstant;\n        uniform mediump float u_attenuationLinear;\n        uniform mediump float u_attenuationQuadratic;\n\n        //varyings\n        varying mediump vec2 vvTexCoord;\n        varying mediump vec3 vvHalfVector;\n        varying mediump vec3 vvLightDir;\n        varying mediump vec3 vvNormal;\n        varying mediump float vfLightDistance;\n\n        void main()\n        {\n            vec3 vNormal = normalize(vvNormal);\n        \tvec3 vLightDir = normalize(vvLightDir);\n        \tvec3 vHalfVector = normalize(vvHalfVector);\n            \n            //calculate the attenuation.\n            float fAttenuation = 1.0 / (u_attenuationConstant + (u_attenuationLinear * vfLightDistance) + (u_attenuationQuadratic * vfLightDistance * vfLightDistance));\n            \n            //calculate the diffuse colour\n            float fNdotL = max(dot(vNormal, -vLightDir), 0.0);\n            vec4 vDiffuse = u_diffuse * fNdotL;\n            \n            //calculate the specular colour\n            float fNdotHV = max(dot(vNormal, vHalfVector), 0.0);\n            float fLightSwitch = step(0.001, fNdotL);\n            vec4 vSpecular = vec4(u_specular.xyz * pow(fNdotHV, u_specular.a) * fLightSwitch, 1.0);\n            \n        \t//calculate the final colour\n        \tvec4 vColour = (vDiffuse + vSpecular) * u_lightCol;\n            vColour.rgb *= fAttenuation;\n        \tgl_FragColor = vColour * texture2D(u_texture0, vvTexCoord);\n        }\n    }\n}"
  },
  {
    "path": "CSResources/Shaders/Static-ShadowMap.csshader",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\nGLSL\n{\n\tVertexShader\n\t{\n\t\t#ifndef GL_ES\n\t\t#define lowp\n\t\t#define mediump\n\t\t#define highp\n\t\t#endif\n\n\t\t//attributes\n\t\tattribute highp vec4 a_position;\n\n\t\t//uniforms\n\t\tuniform highp mat4 u_wvpMat;\n\n\t\t//varyings\n\t\tvarying highp float v_depth;\n\n\t\tvoid main()\n\t\t{\n\t\t\tgl_Position = u_wvpMat * a_position;\n\t\t    v_depth = gl_Position.z;\n\t\t}\n\t}\n\t\n    FragmentShader\n    {\n\t\t#ifndef GL_ES\n\t\t#define lowp\n\t\t#define mediump\n\t\t#define highp\n\t\t#else\n\t\tprecision lowp float;\n\t\t#endif\n\n\t\t//varyings\n\t\tvarying highp float v_depth;\n\n\t\tvoid main()\n\t\t{\n\t\t\tgl_FragColor = vec4(v_depth, v_depth, v_depth, 1.0);\n\t\t}\n\t}\n}\n\n"
  },
  {
    "path": "CSResources/Shaders/Static-Unlit.csshader",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\nGLSL\n{\n\tVertexShader\n\t{\n\t\t#ifndef GL_ES\n\t\t#define lowp\n\t\t#define mediump\n\t\t#define highp\n\t\t#endif\n\n\t\t//attributes\n\t\tattribute highp vec4 a_position;\n\t\tattribute mediump vec2 a_texCoord;\n\n\t\t//uniforms\n\t\tuniform highp mat4 u_wvpMat;\n\n\t\t//varyings\n\t\tvarying mediump vec2 vvTexCoord;\n\n\t\tvoid main()\n\t\t{\n\t\t    //Convert the vertex from world space to projection\n\t\t    gl_Position = u_wvpMat * a_position;\n\t\t    \n\t\t    //Apply the texture matrix to the texture coordinates\n\t\t    vvTexCoord = a_texCoord;\n\t\t}\n\t}\n\t\n\tFragmentShader\n\t{\n\t\t#ifndef GL_ES\n\t\t#define lowp\n\t\t#define mediump\n\t\t#define highp\n\t\t#else\n\t\tprecision lowp float;\n\t\t#endif\n\n\t\t//uniforms\n\t\tuniform lowp sampler2D u_texture0;\n\t\tuniform lowp vec4 u_emissive;\n\n\t\t//varyings\n\t\tvarying mediump vec2 vvTexCoord;\n\n\t\tvoid main()\n\t\t{\n\t\t\tgl_FragColor = texture2D(u_texture0, vvTexCoord) * u_emissive;\n\t\t}\n\t}\n}\n\n"
  },
  {
    "path": "CSResources/Widgets/DefaultCursor.csui",
    "content": "{\n  \"Type\": \"Image\",\n  \"Name\": \"CSCursor\",\n  \"InputEnabled\": \"false\",\n  \"AbsSize\": \"16 16\",\n  \"OriginAnchor\": \"TopLeft\",\n  \"SizePolicy\": \"UseWidthMaintainingAspect\",\n  \"Drawable\": {\n    \"TextureLocation\": \"ChilliSource\",\n    \"TexturePath\": \"Textures/DefaultCursor.png\",\n    \"Type\": \"Standard\"\n  }\n}\n"
  },
  {
    "path": "CSResources/Widgets/EditableLabel.csuidef",
    "content": "{\n  \"Type\": \"EditableLabel\",\n\n  \"Components\": [\n    {\n      \"Type\": \"Text\",\n      \"Name\": \"Text\"\n    },\n    {\n      \"Type\": \"EditableText\",\n      \"Name\": \"EditableText\"\n    }\n  ],\n\n  \"ComponentPropertyLinks\": {\n    \"EditableText\": \"all\",\n\t\"Text\": {\n\t  \"Font\": \"Font\",\n\t  \"TextColour\": \"TextColour\",\n\t  \"HorizontalJustification\": \"HorizontalJustification\",\n\t  \"VerticalJustification\": \"VerticalJustification\",\n\t  \"AbsCharSpacingOffset\": \"AbsCharSpacingOffset\",\n\t  \"AbsLineSpacingOffset\": \"AbsLineSpacingOffset\",\n\t  \"LineSpacingScale\": \"LineSpacingScale\",\n\t  \"MaxNumberOfLines\": \"MaxNumberOfLines\",\n\t  \"TextScale\": \"TextScale\",\n\t  \"MinTextAutoScale\": \"MinTextAutoScale\",\n\t  \"EnableAutoTextScale\": \"EnableAutoTextScale\"\t  \n\t}\n    \n  },\n  \n  \"DefaultPropertyValues\": {\n    \"Name\": \"EditableLabel\",\n    \"InputConsumeEnabled\": \"true\"\n  }\n}"
  },
  {
    "path": "CSResources/Widgets/HighlightButton.csuidef",
    "content": "{\n  \"Type\": \"HighlightButton\",\n\n  \"Components\": [\n    {\n      \"Type\": \"Drawable\",\n      \"Name\": \"Drawable\"\n    },\n    {\n      \"Type\": \"Highlight\",\n      \"Name\": \"Highlight\"\n    }\n  ],\n\n  \"ComponentPropertyLinks\": {\n    \"Drawable\": \"none\",\n    \"Highlight\": \"all\"\n  },\n  \n  \"DefaultPropertyValues\": {\n    \"Name\": \"HighlightButton\",\n    \"InputConsumeEnabled\": \"true\"\n  }\n}"
  },
  {
    "path": "CSResources/Widgets/HorizontalFillProgressBar.csuidef",
    "content": "{\n  \"Type\": \"HorizontalFillProgressBar\",\n\n  \"Components\": [\n    {\n      \"Type\": \"Drawable\",\n      \"Name\": \"Drawable\"\n    },\n    {\n      \"Type\": \"ProgressBar\",\n      \"Name\": \"ProgressBar\",\n      \"BarWidgetName\": \"Bar\",\n      \"BarDirection\": \"Horizontal\",\n      \"BarType\": \"Fill\"\n    }\n  ],\n\n  \"Children\": [\n    {\n      \"Type\": \"Image\",\n      \"Name\": \"Bar\",\n      \"RelSize\": \"0.0 1.0\",\n      \"ParentalAnchor\": \"MiddleLeft\",\n      \"OriginAnchor\": \"MiddleLeft\"\n    }\n  ],\n\n  \"ComponentPropertyLinks\": {\n    \"Drawable\": \"all\",\n    \"ProgressBar\": {\n      \"RelBarSize\": \"RelBarSize\",\n      \"Progress\": \"Progress\"\n    }\n  },\n\n  \"ChildPropertyLinks\": {\n    \"Bar\": {\n      \"BarDrawable\": \"Drawable\"\n    }\n  },\n  \n  \"DefaultPropertyValues\": {\n    \"Name\": \"HorizontalFillProgressBar\"\n  }\n}"
  },
  {
    "path": "CSResources/Widgets/HorizontalSlider.csuidef",
    "content": "{\n  \"Type\": \"HorizontalSlider\",\n\n  \"Components\": [\n    {\n      \"Type\": \"Drawable\",\n      \"Name\": \"Drawable\"\n    },\n    {\n      \"Type\": \"Slider\",\n      \"Name\": \"Slider\",\n      \"SliderWidgetName\": \"Slider\",\n      \"SliderDirection\": \"Horizontal\"\n    }\n  ],\n\n  \"Children\": [\n    {\n      \"Type\": \"Image\",\n      \"Name\": \"Slider\",\n      \"RelPosition\": \"0.5 0.0\",\n      \"RelSize\": \"0.0 1.0\",\n      \"SizePolicy\": \"UseHeightMaintainingAspect\",\n      \"ParentalAnchor\": \"MiddleLeft\",\n      \"OriginAnchor\": \"MiddleLeft\"\n    }\n  ],\n\n  \"ComponentPropertyLinks\": {\n    \"Drawable\": \"all\",\n    \"Slider\": {\n      \"SliderSize\": \"SliderSize\",\n      \"SliderPosition\": \"SliderPosition\"\n    }\n  },\n\n  \"ChildPropertyLinks\": {\n    \"Slider\": {\n      \"SliderDrawable\": \"Drawable\"\n    }\n  },\n  \n  \"DefaultPropertyValues\": {\n    \"Name\": \"HorizontalSlider\",\n    \"InputConsumeEnabled\": \"true\"\n  }\n}"
  },
  {
    "path": "CSResources/Widgets/HorizontalStretchProgressBar.csuidef",
    "content": "{\n  \"Type\": \"HorizontalStretchProgressBar\",\n\n  \"Components\": [\n    {\n      \"Type\": \"Drawable\",\n      \"Name\": \"Drawable\"\n    },\n    {\n      \"Type\": \"ProgressBar\",\n      \"Name\": \"ProgressBar\",\n      \"BarWidgetName\": \"Bar\",\n      \"BarDirection\": \"Horizontal\",\n      \"BarType\": \"Stretch\"\n    }\n  ],\n\n  \"Children\": [\n    {\n      \"Type\": \"Image\",\n      \"Name\": \"Bar\",\n      \"RelSize\": \"0.0 1.0\",\n      \"ParentalAnchor\": \"MiddleLeft\",\n      \"OriginAnchor\": \"MiddleLeft\"\n    }\n  ],\n\n  \"ComponentPropertyLinks\": {\n    \"Drawable\": \"all\",\n    \"ProgressBar\": {\n      \"RelBarSize\": \"RelBarSize\",\n      \"Progress\": \"Progress\"\n    }\n  },\n\n  \"ChildPropertyLinks\": {\n    \"Bar\": {\n      \"BarDrawable\": \"Drawable\"\n    }\n  },\n  \n  \"DefaultPropertyValues\": {\n    \"Name\": \"HorizontalStretchProgressBar\"\n  }\n}"
  },
  {
    "path": "CSResources/Widgets/Image.csuidef",
    "content": "{\n  \"Type\": \"Image\",\n\n  \"Components\": [\n    {\n      \"Type\": \"Drawable\",\n      \"Name\": \"Drawable\"\n    }\n  ],\n\n  \"ComponentPropertyLinks\": {\n    \"Drawable\": \"all\"\n  },\n  \n  \"DefaultPropertyValues\": {\n    \"Name\": \"Image\"\n  }\n}"
  },
  {
    "path": "CSResources/Widgets/Label.csuidef",
    "content": "{\n  \"Type\": \"Label\",\n\n  \"Components\": [\n    {\n      \"Type\": \"Text\",\n      \"Name\": \"Text\"\n    }\n  ],\n\n  \"ComponentPropertyLinks\": {\n    \"Text\": \"all\"\n  },\n  \n  \"DefaultPropertyValues\": {\n    \"Name\": \"Label\"\n  }\n}"
  },
  {
    "path": "CSResources/Widgets/Layout.csuidef",
    "content": "{\n  \"Type\": \"Layout\",\n\n  \"Components\": [\n    {\n      \"Type\": \"Layout\",\n      \"Name\": \"Layout\"\n    }\n  ],\n\n  \"ComponentPropertyLinks\": {\n    \"Layout\": \"all\"\n  },\n  \n  \"DefaultDefaultValues\": {\n    \"Name\": \"Layout\"\n  }\n}"
  },
  {
    "path": "CSResources/Widgets/ToggleButton.csuidef",
    "content": "{\n  \"Type\": \"ToggleButton\",\n\n  \"Components\": [\n    {\n      \"Type\": \"Drawable\",\n      \"Name\": \"Drawable\"\n    },\n    {\n      \"Type\": \"ToggleHighlight\",\n      \"Name\": \"ToggleHighlight\"\n    }\n  ],\n\n  \"ComponentPropertyLinks\": {\n    \"Drawable\": \"none\",\n    \"ToggleHighlight\": \"all\"\n  },\n  \n  \"DefaultPropertyValues\": {\n    \"Name\": \"ToggleButton\",\n    \"InputConsumeEnabled\": \"true\"\n  }\n}"
  },
  {
    "path": "CSResources/Widgets/VerticalFillProgressBar.csuidef",
    "content": "{\n  \"Type\": \"VerticalFillProgressBar\",\n\n  \"Components\": [\n    {\n      \"Type\": \"Drawable\",\n      \"Name\": \"Drawable\"\n    },\n    {\n      \"Type\": \"ProgressBar\",\n      \"Name\": \"ProgressBar\",\n      \"BarWidgetName\": \"Bar\",\n      \"BarDirection\": \"Vertical\",\n      \"BarType\": \"Fill\"\n    }\n  ],\n\n  \"Children\": [\n    {\n      \"Type\": \"Image\",\n      \"Name\": \"Bar\",\n      \"RelSize\": \"0.0 1.0\",\n      \"ParentalAnchor\": \"MiddleLeft\",\n      \"OriginAnchor\": \"MiddleLeft\"\n    }\n  ],\n\n  \"ComponentPropertyLinks\": {\n    \"Drawable\": \"all\",\n    \"ProgressBar\": {\n      \"RelBarSize\": \"RelBarSize\",\n      \"Progress\": \"Progress\"\n    }\n  },\n\n  \"ChildPropertyLinks\": {\n    \"Bar\": {\n      \"BarDrawable\": \"Drawable\"\n    }\n  },\n  \n  \"DefaultPropertyValues\": {\n    \"Name\": \"VerticalFillProgressBar\"\n  }\n}"
  },
  {
    "path": "CSResources/Widgets/VerticalSlider.csuidef",
    "content": "{\n  \"Type\": \"VerticalSlider\",\n\n  \"Components\": [\n    {\n      \"Type\": \"Drawable\",\n      \"Name\": \"Drawable\"\n    },\n    {\n      \"Type\": \"Slider\",\n      \"Name\": \"Slider\",\n      \"SliderWidgetName\": \"Slider\",\n      \"SliderDirection\": \"Vertical\"\n    }\n  ],\n\n  \"Children\": [\n    {\n      \"Type\": \"Image\",\n      \"Name\": \"Slider\",\n      \"RelPosition\": \"0.0 0.5\",\n      \"RelSize\": \"1.0 0.0\",\n      \"SizePolicy\": \"UseWidthMaintainingAspect\",\n      \"ParentalAnchor\": \"BottomCentre\",\n      \"OriginAnchor\": \"BottomCentre\"\n    }\n  ],\n\n  \"ComponentPropertyLinks\": {\n    \"Drawable\": \"all\",\n    \"Slider\": {\n      \"SliderSize\": \"SliderSize\",\n      \"SliderPosition\": \"SliderPosition\"\n    }\n  },\n\n  \"ChildPropertyLinks\": {\n    \"Slider\": {\n      \"SliderDrawable\": \"Drawable\"\n    }\n  },\n  \n  \"DefaultPropertyValues\": {\n    \"Name\": \"VerticalSlider\",\n    \"InputConsumeEnabled\": \"true\"\n  }\n}"
  },
  {
    "path": "CSResources/Widgets/VerticalStretchProgressBar.csuidef",
    "content": "{\n  \"Type\": \"VerticalStretchProgressBar\",\n\n  \"Components\": [\n    {\n      \"Type\": \"Drawable\",\n      \"Name\": \"Drawable\"\n    },\n    {\n      \"Type\": \"ProgressBar\",\n      \"Name\": \"ProgressBar\",\n      \"BarWidgetName\": \"Bar\",\n      \"BarDirection\": \"Vertical\",\n      \"BarType\": \"Stretch\"\n    }\n  ],\n\n  \"Children\": [\n    {\n      \"Type\": \"Image\",\n      \"Name\": \"Bar\",\n      \"RelSize\": \"0.0 1.0\",\n      \"ParentalAnchor\": \"MiddleLeft\",\n      \"OriginAnchor\": \"MiddleLeft\"\n    }\n  ],\n\n  \"ComponentPropertyLinks\": {\n    \"Drawable\": \"all\",\n    \"ProgressBar\": {\n      \"RelBarSize\": \"RelBarSize\",\n      \"Progress\": \"Progress\"\n    }\n  },\n\n  \"ChildPropertLinks\": {\n    \"Bar\": {\n      \"BarDrawable\": \"Drawable\"\n    }\n  },\n  \n  \"DefaultPropertyValues\": {\n    \"Name\": \"VerticalStretchProgressBar\"\n  }\n}"
  },
  {
    "path": "CSResources/Widgets/Widget.csuidef",
    "content": "{\n  \"Type\": \"Widget\",\n  \n  \"DefaultPropertyValues\": {\n    \"Name\": \"Widget\"\n  }\n}"
  },
  {
    "path": "Documents/ChangeLog.md",
    "content": "ChilliSource Change Log\n=======================\n\nVersion 2.2.3,\n-------------------------\n* Fixed: Crash when minimising window on Windows caused by OpenGL continuing to render. Fix is to suspend the application when it loses focus (SFML has no minimise event).\n\nVersion 2.2.2, 2017-03-27\n-------------------------\n* Added: Parsing and ToString methods for Integer2, Integer3 and Integer4\n* Fixed: Some OpenGL analyser warnings caused by setting attributes when they don't exist in shaders\n* Fixed: Issues compiling under case-sensitive file system (i.e. Linux) caused by incorrectly cased includes.\n* Fixed: Typo in Label.csuidef which meant the default name \"Label\" was being ignored.\n\nVersion 2.2.1, 2017-03-14\n-------------------------\n* HotFix: Fix for potential issue of the vertex attribute objects not being rebuilt when the context is lost on Android\n\nVersion 2.2.0, 2017-03-14\n-------------------------\n* Removed: Render component factory. Just use the constructors of the render components instead (to replicate CreatePerspectiveCamera pass screenWidth/screenHeight for aspect ratio)\n* Deprecated: Support for SHA-1\n* Added: SHA-256 hashing support\n* Changed: ContentManagementSystem now uses SHA-256 unless compiler flag CS_USE_SHA1_CHECKSUMS is enabled for legacy applications.\n* Changed: Performance improvement on sprites and UI by using mapbuffer or orphaning buffers rather than a blocking subbuffer call.\n* Changed: GLMesh (static meshes) now use vertex array objects where the extension exists. On Android this requires linking against -lEgl\n* Fixed: Issue with suspending on Android in debug mode sometimes causing an assert\n\nVersion 2.1.4, 2017-02-28\n-------------------------\n* HotFix: With shadows turned on the bound texture list in the renderer was expanding each frame and causing memory leaks and performance slowdown\n\nVersion 2.1.3, 2017-02-27\n-------------------------\n* Added: Thread safe ObjectPoolAllocator that pre allocates objects of a specific type. Now using this within the renderer to reduce allocations.\n* Fix: Longstanding issue where \"Shinniness\" was reciprocated (i.e. 1/Shinniness) in Blinn shaders rather than just Shinniness. Note this will affect existing projects.\n* Fix: Crash in Collada to CSModel tool if the Collada file has no materials.\n* Fix: Issue with Sphere::Transform not considering orientation. This meant that mesh frustum culling was broken\n* Fix: Tweens which play more than once will now utilise the end-delay property every time the end of the tween is reached, instead of just once.\n* Fix: Default background colour is now black.\n* Fix: CS::UniquePtr<T> could not be moved into CS::UniquePtr<const T>\n* Fix: Issue where cull face was ignored in material and always set to back\n* Updated: SFML is now version 2.4.2, on Windows.\n* Updated: Cricket is now version 1.6.3. This now means that bitcode can be enabled on iOS (and is now enabled by default in newly generated projects).\n* Changed: Ray/Plane intersection test is no longer a member function of Plane, but now resides in ShapeIntersection along with the other intersection tests.\n* Changed: Where available the iOS dialogue system is backed by the newer UIAlertController rather than the deprecated UIAlertView\n* Changed: SetParentTransform, AddChildTransform, RemoveChildTransform and RemoveAllChildTransforms in Transform are now private and cannot be accessed outside of Entity.\n* Changed: iOS projects now have deployment target of iOS 8.0\n\nVersion 2.1.2, 2017-01-26\n-------------------------\n\n* Added: Tangents and Bitangents to CSModel format. Accessible in shader vertex declaration as a_tangent and a_bitangent. Model version is now 13. Please rebuild all csmodel files.\n* Added: Skybox support via SkyboxComponent and new Skybox material type.\n* Added: Gyroscope support for iOS and Android using similar system to Accelerometer.\n* Fix: SendToBack in Widget not working properly.\n\nVersion 2.1.1, 2017-01-19\n-------------------------\n\n* Added: Additional blend modes to materials for destCol and oneMinusDestCol\n\nVersion 2.1.0, 2017-01-06\n-------------------------\n* Added: Support for Cubemaps. Accessed in shaders as u_cubemap[N]. This required changes to the material file formats Texture element to specify a type \"Texture\" or \"Cubemap\" and renaming of \"image-name\" to \"file-name\".\n* Added: Support for stencil buffer (introducing new framebuffer format).\n* Added: Support for masking in UI using the stencil buffer (this replaces scissor regions).\n* Added: Render to texture support\n* Added: New logging macros for formatted logs CS_LOG_XXX_FMT.\n* Improved: Added convenience distance method to vector classes.\n* Other minor fixes.\n\nVersion 2.0.1, 2016-07-21\n-------------------------\n* Hotfix for issue in GLDynamicMesh where indices were not being assigned correctly on construction\n\nVersion 2.0.0, 2016-07-15\n-------------------------\n* Added: A new multi-threaded renderer. The previous renderer has been completely stripped out and replaced with a brand new renderer which makes much better use of multi-core devices. The new renderer also allows us to add deferred rendering support in the future.\n* Added: Small mesh batching. This is a major optimisation which combines small meshes into a single draw call where possible. Currently this only supports dynamic sprites but other mesh types will be added in the future.\n* Added: New allocator types, which allow for very efficient allocation of memory.\n* Added: An editable label ui widget type.\n* Improved: As a result of the changes for the multi-threaded renderer, the main thread is no longer the same as the system/render thread. This thread is now solely for scene management and game logic.\n* Improved: The task scheduler has been completely overhauled. It now supports batching of tasks, task depedancies and a number of different task types.\n* Improved: The ChilliSource namespaces have been significantly simplified. The sub-namespaces (For example: ChilliSource::Rendering) have been removed and all classes are now located the ChilliSource namespace. An optional CS:: alias is available, and its use is recommened. As a result of this change, some classes have been renamed, for example CSUI::Drawable is now called CS::UIDrawable. \n* Improved: Materials have been improved such that models with different vertex formats (for example static models and animated models) require different materials. The material type system has been simplified down to three types: Unlit, Blinn and Custom.\n* Improved: The FileStream API has been significantly improved.\n* Improved: Improved the API for manual creation of Textures and Meshes.\n* Improved: StaticMeshComponent and AnimatedMeshComponent have been renamed StaticModelComponent and AnimatedModelComponent, and have had their API improved.\n* Improved: Updated all systems to support the new threading model. Some minor API changes were required to make this work.\n* Improved: Key codes can now request a text description of the key the represent.\n* Fixed: Issues with local notifications on Android.\n* Fixed: Issues with video subtitles on both Android and iOS.\n* Fixed: A problem with keyboard presentation during text entry on Android.\n* Removed: Support for custom render sort predicates. This will be re-added in the future.\n* Removed: Cubemaps. These will be re-added in the future.\n* Removed: Scissor regions. These will be re-added in the future.\n* Removed: Render to texture support. This will be re-added soon.\n* Removed: Facebook support. This will be re-added soon.\n* Removed: Remote notifications on Android.\n* Removed: Mesh Batch.\n* And many other minor improvements and tweaks that would take too long to list.\n\nVersion 1.6.0, 2016-04-01\n-------------------------\n\n* Added: 64-bit Android support. Both arm64-v8a and x86_64 can now be targetted.\n* Added: Support for building music and sound effect files to the default asset pipeline provided in generated projects.\n* Improved: Updated to Visual Studio 2015. Support for Visual Studio 2013 has been dropped, meaning we can now use additional C++11 features such as 'noexcept' and 'constexpr'.\n* Improved: Re-created the windows project with modern settings and improved the output build format.\n* Improved: Re-created the iOS projects with modern settings and fixed all warnings and errors in XCode 7.\n* Improved: Improved the python asset pipeline scripts provided in generated projects.\n* Improved: UI::Drawable properties are now accessbile.\n* Improved: Updated to the latest version of Cricket Audio.\n* Improved: Updated to a more up to date, and unmodified version of Minizip.\n* Improved: Updated to the latest version of SFML on windows.\n* Improved: Updated to the latest version of Glew on windows.\n* Improved: Minor updates to the Android project format.\n* Fixed: An issue where .DS_Store files were not being correctly omitted from the Android APK expansion file. Also added Thumbs.db ignore.\n* Fixed: A crash in the HTTP request system on Android.\n* Fixed: UI input events are no longer received for inactive states.\n* Fixed: Gesture input events are no longer received for inactive states.\n* Fixed: Android notifications are now cleared after they have been selected.\n* Fixed: The standardise path methods no longer break UNC paths.\n* Fixed: OS version is now correctly reported on Android.\n* Fixed: .pyc files are now correctly ignored in generated projects.\n* Fixed: An issue on Android where some libraries still depended on all build variants, resulting in long build times.\n\nVersion 1.5.2, 2016-03-18\n-------------------------\n* Fixed: FileSystem::GetDirectoryPath() now correctly creates parent paths recursively on Windows. This fixes the issue where the Documents/ directory would not be created on start up in certain circumstances.\n\nVersion 1.5.1, 2015-08-14\n-------------------------\n* Added: A new primitive shape model factory. This can be used to create boxes and planes in code.\n* Added: A new primitive shape entity factory. This creates new entities using shapes generated through the primitive shape model factory.\n* Added: Support for \"multi-dex\" applications on Android. This is needed if your application exceeds to 65k method limit.\n* Added: A new way of handling JNI callbacks from Java to Native on Android. The method should now provide a BoxedPointer, which can be used to retreive a pointer to the target native object\n* Improved: The Change Over Lifetime particle affector now supports 'intermediate colours', meaning it can fade through a series of different colours over the lifetime\n* Improved: It is now possible to get the expected size and current progress of a download using the Http Request System\n* Improved: Reimplemented Http Request on Android. It will no longer block the background task queue if several requests are made at the same time.\n* Improved: It is now possible to get the jobject from a JavaClass.\n* Fixed: Row and column major ordering is now the correct way round in a Grid Layout\n* Fixed: Materials used by the Canvas Renderer and now correctly relinquished at the end of each frame, fixing the issue where the textures could not be manually released\n* Fixed: An issue with the minus operator in all math vectors where the vector itself was modified rather than a copy, leading the following returning true: b = -a; return (a == b);\n* Fixed: Vector2::Angle now returns an absolute angle to be consistent with how Vector3::Angle() works\n* Fixed: A crash bug that would occur under certain conditions when using Application::Quit() on Android\n* Fixed: System dialogue boxes now correctly display on Windows\n* Fixed: The main thead id is now correctly updated during the OnDestroy() life cycle event on Android\n* Fixed: An issue where pushing an Apk Expansion file to device would fail becuase a directory doesn't exist.\n* Fixed: A crash related to WebView in Android release builds.\n* Fixed: An issue with clear() in the Java class DynamicByteBuffer\n\nVersion 1.5.0, 2015-07-10\n-------------------------\n* Added: The android build pipeline now includes gradle tasks for packaging resources in the Apk Expansion file and pushing it to device.\n* Added: The APK expansion downloader screen can now be overridden by the user.\n* Added: Implemented a new, much easier to use system for handling JNI calls on Android. Native to Java calls are now all handled through JavaClass or JavaStaticClass. These include a number of sanity checks and provide more intuitive error messages. Java to Native still works as before.\n* Added: Implemented JavaSystem, similar to JavaClass, but specifically for andriod java classes which extend System.\n* Added: The android java class FileUtils now includes separate methods for reading and writing binary and text files.\n* Added: FileSystem now includes methods for checking if a directory exists in the cached or package DLC locations.\n* Added: The java tools ZipUtils now includes the ability to zip the contents of a directory.\n* Added: A new java tool for cross-platform zipping of directories.\n* Removed: The previous android expansion system has been removed.\n* Removed: The android Power Manager is now redundant and has been removed.\n* Removed: The GetAbsolutePathToFile() and GetAbsolutePathToDirectory() methods in FileSystem are no longer relevant with changes made to the system a while ago, and therefore have been removed.\n* Improved: Updated the android projects to Android Studio 1.2. This included updating to gradle 1.2.3, build tools version 22.0.1 and sdk version 22.\n* Improved: Support for Android Expansion files has been greatly improved. Google Play builds will now be automatically downloaded on startup if not already present. This occurs prior to any game code being executed so the user no longer need to handle the case where game assets do not yet exist. The downloaded expansion file is no longer unpacked meaning the app will be much smaller on disc, and a number of possible complications are avoided. A default downloader screen is provided by the engine.\n* Improved: The android file system implementation has been significantly overhauled. Google Play flavoured builds now refer to the main APK expansion file rather than the APK when the Package, ChilliSource or DLC storage locations are requested. Amazon builds still use the APK.\n* Improved: Significantly tidied up and improved the android gradle build scripts. \n* Improved: Restructured the Android backend.\n* Improved: Renamed the android java class NativeInterface and changed it so that it follows the same lifecycle rules as systems in the native side of the engine.\n* Improved: Renamexd JavaInterfaceUtils to JavaUtils.\n* Improved: Simplified the creation and destruction of file streams. Calls to FileSystem::CreateFileStream() will now either return a valid ready to use stream, or null if it failed. A stream is no longer manually closed, instead it will be automatically cleaned up when it goes out of scope.\n* Improved: The LVL key for Android Google Play builds should now be provided once in App.cpp, rather than being provided to each system that needs it in different ways.\n* Improved: It is now possible to get access to the DrawableDef in a UI::DrawableComponent.\n* Improved: Refactored and improved the android java StringUtils class.\n* Improved: Refactored the android java class IQueryableInterface.\n* Improved: The TaggedPathResolver now returns the input path if the path doesn't exist. This means requests to ResourcePool will print more helpful error messages.\n* Improved: Refactored the android VideoPlayer backend so that it uses JavaSystem instead of JavaInterface. \n* Improved: The android manifest builder has been updated to reflect the changes to the Android project structure. Added new option for specifying a custom APK expansion downloader view.\n* Improved: The project generator has been updated to include the new Android project structure changes.\n* Fixed: A number of inconsistencies and bugs in the Android and Windows FileSystem have been fixed.\n* Fixed: A FileStream referring to the Package, ChilliSource or packaged DLC storage locations on Android no longer allows write operations.\n* Fixed: A bug where tagged asset paths were incorrectly handled for CkBank resources has been resolved.\n* Deprecated: JavaInterface and _JavaInteface are both now deprecated and will be removed in the near future.\n\nVersion 1.4.5, 2015-06-26\n-------------------------\n* Added: Additional data on IAPs can now be retreived through the Android and iOS backends for IAPSystem.\n* Fixed: Application and State no longer log a warning if a system couldn't be found using GetSystem<>()\n* Fixed: Fixed a number of fatal errors which were incorrectly reported in the PNG To CSImage tool.\n* Fixed: The Android build process will now correctly halt if there are compiler errors during the native build.\n\nVersion 1.4.4, 2015-06-05\n-------------------------\n* Fixed: A crash when removing Entities with children from the scene.\n* Fixed: Child widgets are now correctly removed from their parent when the parent is deleted.\n* Fixed: An issue that would result in auto-scaling text not rendering.\n\nVersion 1.4.3, 2015-05-21\n-------------------------\n* Removed: The GUI model and animation converter it had a number of issues and was windows specific. It will be replaced with a cross platform equivalent at some point in the future, but for now the command line tools should be used.\n* Fixed: A label which contains icons in the text will no longer crash if label is too small to fit one of the icons.\n* Fixed: Icons in labels are now correctly sized if the icon is from a texture altas.\n* Fixed: SetWorldTransform() in Transform now works correctly.\n* Fixed: An issue where Widgets could receive incorrect input events when moving.\n* Fixed: The Cricket Audio system now correctly works with assets in the DLC storage location.\n* Fixed: The Cricket Audio system, Android Video Player, Android WebView, and Android Email Composer now all work correctly with tagged assets.\n* Fixed: An issue in the Content Management System where some packages would re-downloaded unnecessarily.\n\nVersion 1.4.2, 2015-05-01\n-------------------------\n* Added: Label now supports auto sizing to ensure text will fit inside the label bounds\n* Fixed: Issues with resolution on iPhone 6 Plus\n* Fixed: Changing resolution on windows in code now correctly fires the On Resolution Changed event\n* Fixed: It is no longer possible to try and run in fullscreen mode with an invalid resolution on Windows\n* Fixed: The ChilliSource android project no longer runs proguard, which was causing issues in projects which contain their own Java source\n* Fixed: Animated Collada files exported from Blender should now be correctly converted by the collada conversion tools\n\nVersion 1.4.1, 2015-04-17\n-------------------------\n* Improved: Updated the ChangeLog.md to correct markdown syntax\n* Fixed: The project generator no longer fails if there is a \".git\" directory in the ChilliSource directory\n* Fixed: Windows builds no longer fail during the asset copy python script if there is a space in the path name\n* Fixed: The view frustum is now correctly updated when the screen resolution changes. This fixed an issue with on screen objects being culled\n\nVersion 1.4.0, 2015-04-03\n-------------------------\n* Added: Support for Android Studio. All projects created by the Project Generator now provide an Android Studio project instead of Eclipse ADT.\n* Added: Support for 64-bit builds to Windows and iOS projects. 64-bit Android projects will be coming soon!\n* Added: Double2, Double3, and Double4 math vector types.\n* Removed: Support for Eclipse ADT builds. Eclipse is no longer officially supported as an Android development IDE.\n* Improved: The widget hierarchy is now accessible through Canvas.\n* Improved: DrawableDef no longer requires colour and UVs in their constructor.\n* Improved: Restructured the Android backend to mirror the structure used for different product flavours in Android Studio.\n* Improved: It is now much easier to build Kindle builds.\n* Fixed: Sprite anchors now work correctly.\n* Fixed: Text now correctly changes colour when the parent widget's colour changes.\n* Fixed: Colour can now be pre-multiplied/divided/subtracted/added by a scalar.\n* Fixed: A compiler error on Windows when using the Math::Random::Generate() default parameters.\n* Fixed: CkBank resources are now correctly cleaned up if they still exist during the Application::OnDestroy lifecycle event.\n* Fixed: Projects created by the Project Generator on Windows can now be correctly built in XCode.\n* Fixed: IAP will no longer fail on Android if there are more than 20 available products.\n* Fixed: A compiler error on Windows caused by the lack of virtual destructor in the Event interfaces.\n* Fixed: The project generator no longer leaves git remnants in generated projects.\n\nVersion 1.3.3, 2015-02-24\n-------------------------\n* Labels now support inclusion of Icons in text.\n* Improved the Facebook Post system and updated to the latest version of the Facebook SDK on both iOS and Android. \n* Facebook on Android is now an Android Extension. To use it add CS_ANDROIDEXTENSION_FACEBOOK to the pre-processor definitions in Android.mk and import the Facebook library project into eclipse. This can be found in the engine in the Libraries/Android/Projects/ directory.\n* The Google Play Services android library project is now included in the engine, and can be found in the Libraries/Android/Projects/ directory. This should be used instead of copying a new version into the workspace.\n* The CkAudioPlayer now has separate setters for music and effect volume.\n* Fixed Android compiler errors when building on a linux machine. This was caused by in-correct case in include paths.\n* Change errant log when failing to open file in JsonUtils.\n\nVersion 1.3.2, 2015-01-23\n-------------------------\n* Added new tool which provides a cross platform interface for the Cricket Audio cktool.\n* Made a number of improvements to projects generated by the Project Generator including: improved default asset pipeline, iOS 8 launch images and icons and fixes.\n* Fix: Solved an issue with md5 and sha1 file hashing on Android.\n* Fix: RTT can be used without supplying a UI canvas.\n* Fix: It's now possible to have a null drawable on a ui widget.\n\nVersion 1.3.1, 2015-01-09\n-------------------------\n* Added convenience methods to Widget Factory for building all the in-built widget types.\n* Added a creation method for creating Particle Effect Components to the Render Component Factory.\n* Fixed a crash bug on Android.\n\nVersion 1.3.0, 2015-01-09\n-------------------------\n* Added the new UI system.\n* Added a new particle system.\n* Added a Cricket audio system.\n* Added a new property map for containing heterogeneous types.\n* Added new dynamic_array which is based on std::dynarray which was originally proposed in the C++14 standard, but was later removed to be re-added at a later date.\n* Added Random utilty class for thread-safe random number generation.\n* Added new Json utility class, which provides convenience methods for working with Json.\n* Improved the Tween API.\n* Removed several features that have been superceeded by improved implementations: The old GUI system, the old particle system, MathUtils::FRand() and Utils::ReadJson().\n* Removed the reflection functionality as it was incomplete and only used by the old GUI system.\n* Removed Debug Stats as it relied heavily on the old GUI system. This will be re-implemented in the new system in the not too distant future.\n\nVersion 1.2.1, 2014-11-17\n-------------------------\n* Models exported from Blender can now be converted to CSModel format using the ColladaToCSModel tool.\n* Improved the HTTP Request System API. Also replaced the iOS HTTP Request System internals with NSURLConnection. This resulted in removal of GetBytesRead() from the HTTP interface.\n* Updated iOS Facebook SDK.\n* ContentDownloader now allows a custom hashing delegate to be provided rather than being explicitly MD5.\n* ContentDownloader now defaults to using SHA-1 hash.\n* Fixed a bug in the font maker tool which resulted in different characters that were identical being rendered incorrectly.\n* Fixed a bug that prevented the font maker tool runnning on windows.\n* Fixed a bug with state system that could result in resume/suspend being called out of order causing an assertion.\n* Fix for MakeConnectableDelegate which was crashing due to implicit move.\n\nVersion 1.2.0, 2014-11-07\n-------------------------\n* Replaced the existing Font Builder tool with a new version. Unlike the previous tool this can be run on Windows, OSX and Linux, and fonts can be generated from command line. Fonts can also have a number of effects applied including outlines, glow and drop shadows.\n* Font rendering has been significantly improved. This involved updating the font format so any existing fonts will need to be rebuilt. \n* CSModelExport is now correctly working again.\n* Updated the android backend for Android 5.0.\n* Updated the android backed to use the latest NDK build pipeline.\n\nVersion 1.1.5, 2014-11-03\n-------------------------\n* Fixed a windows specific crash on closing an application.\n\nVersion 1.1.4, 2014-10-24\n-------------------------\n* Changed the Application::GetSystems() method so that it returns a vector of systems rather than taking a vector of systems as an output parameter.\n* Added a GetSystems() method to State.\n* Added constant versions of system getters to Application and State.\n* Changed WorkerQueue to concurrent_blocking_queue and changed its API to ensure it is thread-safe. This solves the thread-safety issues with the TaskScheduler.\n* Fixed issue with missing includes in the Vector classes and StandardMacros.h.\n\nVersion 1.1.3, 2014-10-20\n-------------------------\n* Project generator will now error if the output directory is inside ChilliSource. This was causing recursive file copy issues when copying ChilliSource to the project directory.\n\nVersion 1.1.2, 2014-10-16\n-------------------------\n* Added CSProjectGenerator, a tool for generating new ChilliSource project.\n\nVersion 1.1.1, 2014-10-10\n-------------------------\n* All App Systems now correctly receive life cycle events prior to States.\n* Simplified the command line interface for the ColladaToCSModel and ColladaToCSAnim tools and re-added the ability to change coordinate system handedness.\n* Updated the package name in all java code from com.chillisource.* to com.chilliworks.chillisource.*\n* Fixed a bug in Colour::Clamp() where by default alpha was clamping between 1 and 1 rather than 0 and 1.\n* Swapped the parameters in Timer::OpenConnection() to be more lambda friendly.\n* Fixed typos in the documentation for the CSAtlas Builder.\n\nVersion 1.1.0, 2014-09-26: \n-------------------------\n* Replaced the gesture system.\n* UDIDs on Android are now generated from the Google Play Services Advertising Id when building for Google Play. This requires the inclusion of the Goole Play Services library in all Android projects.\n* Adding accessor to Tween for getting the parametric T value\n* The GUI System no longer allows consumption of moved events.\n* The Pointer System no longer has a filtered version of OnPointerMoved() as this event cannot be filtered.\n* The engine is no longer built with CS_ENABLE_DEBUGSTATS enabled in debug mode. App projects should also remove this flag.\n* Scene::Remove() is no longer public, entities must be removed from the scene using RemoveFromParent().\n* Attempting to add a widget to the scene with a parent which is not in the scene will result in an assert. \n* Fixed bug in TexturePacker algorithm which caused padding to break for atlases and fonts.\n* Fixed iOS 8 issues with Push and Local Notifications. \n* Added new concurrent vector which is thread-safe and allows additions and removals while iterating.\n* Fixed an issue with Android context restoration.\n* Fixed a bug where Scene::RemoveAllEntities() would assert if there was an entity with a parent in the scene.\n"
  },
  {
    "path": "Documents/RPi_GettingStarted.md",
    "content": "# ChilliSource: Getting Started on Raspberry Pi\n\nExciting news - you can now use ChilliSource to create both 2D and 3D games for the Raspberry Pi! ChilliSource brings the features of a professional game engine to a $30 computer the size of a credit card.\n\nThis tutorial will walk you through how to build a ChilliSource game for Raspberry Pi and covers the caveats of Pi development. Please let us know if you encounter any issues or if there are any new features you would like to see.\n\nWe have tested apps running on a Raspberry Pi 3 model B with Raspbian \"Jessie\" (we also have used libraries from \"Jessie\"). Apps may work on other Raspberry Pi models and OS versions but we have yet to test.\n\n## Requirements\n\n- Raspberry Pi 3, Model B\n- [Raspbian \"Jessie\"](https://www.raspberrypi.org/downloads/raspbian/)\n- [Ninja build](https://ninja-build.org/)\n- Python 2.7+\n- GNU g++\n\n## Missing Features\n\nThis is an experimental platform and due to this, and the Pi hardware/software, there are some features of ChilliSource that cannot be used on the Pi. Some of the missing features will be added as part of the continued development of ChilliSource Pi, others will only be added if and when they are supported by the 3rd party libraries we use or by the Pi hardware itself.\n\n- Framebuffer MSAA: In development.\n\n- Shadows: *The Pi GPU does not support the GL depth texture extension that we require for shadows. So as with some Android devices shadows are disabled*\n\n- Cricket Audio: *Cricket currently have no library for Raspberry Pi (although they do have a Linux library). Feel free to make requests to them for RPi support. In the meantime you can always plug in a different audio library or use OpenAL*\n\n- System Dialogue Boxes: *Unlike on Windows the Pi display does not work in conjunction with the window manager and therefore always renders on top of the OS. Any displayed dialogue boxes would be obscured. We are waiting on better integration between the VideoCore window and X11.*\n\n- Video rendering: *This has not been looked into yet but will probably encounter the same issues as with dialogue boxes.*\n\n- Web View: *This has not been looked into yet but will probably encounter the same issues as with dialogue boxes.*\n\n## Pi Setup\n\n### GPU Memory\n\nBy default the Pi allocates the GPU 64 MB of memory. This is enough for games with few textures but anything more advances will require additional resources. We recommend allocating at least 256 MB.\n\nThe allocated memory can be changed in *Preferences > Raspberry Pi Configuration > Performance > GPU Memory*.\n\n### Ninja\n\nNinja is a cross platform build system that we use to create ChilliSource applications. You can download binaries [here](https://ninja-build.org/) or alternatively install it through a package manager. On the Raspberry Pi Ninja can be installed by opening a terminal and typing: \"sudo apt-get install ninja-build\".\n\nNOTE: For the build script to work, Ninja must be added to the path so that typing \"ninja\" into a terminal executes Ninja.\n\n### Compiler and Linker\n\nBy default we use g++ to compile and link. This is usually preinstalled on your Raspberry Pi (as is Python which is required by the build script).\n\n## Compiling\n\nThe build process uses the built in g++ compiler and linker. If you are creating a game from scratch using the project generator then you will already have the build scripts required for Raspberry Pi development. If you have an existing game that you want to build for the Pi then you can use the sample build script (*build.py*) from [CSTest](https://github.com/ChilliWorks/CSTest) or [CSPong](https://github.com/ChilliWorks/CSSamples).\n\nBy default the build script is setup to build on the Raspberry Pi itself so make sure your project is on the Pi. Navigate to */Projects/RPi/* in terminal and type \"python build.py debug\" to start building (you can replace \"debug\" with \"release\" to build in release mode). The script will generate an exe and the required assets in an Output folder in the same directory.\n\nIf you want to clean the build type \"python build.py debug|release clean\".\n\nNOTE: Make sure you have installed Ninja prior to running the build script.\n\n### Cross Compiling\n\nCompiling on the Pi can be tedious so it is probably worth setting up a cross compile toolchain that allows you to compile the exe on a different machine and simply copy the *Output* folder to the Pi.\n\nWe recommend downloading one of the following prebuilt toolchains depending on your development platform:\n\n- [Windows](http://sysprogs.com/files/gnutoolchains/raspberry/raspberry-gcc4.9.2-r4.exe)\n- [Mac OS](https://www.jaredwolff.com/toolchains/rpi-xtools-201402102110.dmg.zip)\n- [Linux](https://github.com/raspberrypi/tools)\n\nOnce you have downloaded the toolchains simply change the variables at the top of *build.py* to point to the cross compiler, archiver and linker instead.\n\nNOTES:\n- If you are compiling on Windows using the downloaded Ninja binary you will need to add Ninja to the PATH environment variable.\n- The default build script limits the number of jobs that Ninja will do in parallel to two (if you don't restrict Ninja it will crash the Pi). If you are cross compiling then feel free to remove this restriction (by setting NUM_JOBS=None in *build.py*) to speed up build times.\n\n### Libraries\n\nAt the moment all the libraries required for building to the Pi have been harvested from Raspbian \"Jessie\" itself. In the future these will be compiled from source as part of the toolchain allowing us to better support other Pi models.\n\n## App Configuration\n\nYou will need to edit your App.config JSON file to add the following to the main root:\n\n```\n\"RPi\": {\n  \"CursorType\": \"NonSystem\",\n  \"WindowDisplayMode\": \"Windowed\"\n}\n```\n\nThe display mode tells ChilliSource whether to start your game \"Windowed\" or whether to start it \"Fullscreen\".\n\nNOTE: If you start the game fullscreen make sure you have some way of calling CS::Application::Get()->Quit() as the window will have no close button.\n\nThe cursor type is required if you want to see a mouse cursor. The OpenGL ES display window always renders on top of the OS and therefore obscures the system mouse cursor. Setting the cursor type to \"NonSystem\" will render a software cursor (NOTE: The cursor is just a UI widget and can be configured to suit your game). If you want to hide the cursor completely just set the cursor type to \"None\".\n\n## Running your Game\n\nIf you want to see debug output from your application you should run it from terminal by navigating to the location of your app in terminal and then typing \"./AppName\" to execute. If you wish to run your app without debug output simply double-click the icon.\n\nNOTE: If you cannot run the app due to \"Permission denied\" you may need to make it executable by typing \"chmod +x AppName\" into a terminal.\n\n## Debugging\n\nYou can debug \"debug\" builds on the Pi using gdb (provided you are using the g++/gcc compiler). You will probably want to read up on how to use gdb from the terminal; for example if you want to grab the stack trace of a crash run the app in the following way:\n\n```\ngdb ./AppName\ncatch throw\nrun\n```\n\nlibCrypto will throw an exception (which is expected apparently) that will stop the debugger so you need to skip that:\n\n```\nsignal SIGILL\n```\n\nOnce the crash is triggered type:\n\n```\nbt\n```\n\nThis will display the call stack.\n\n## Gamepad/Controllers\n\nAs part of the new Raspberry Pi backend we've also added support for gamepads/controllers to both Raspberry Pi and Windows. Checkout the CSRunner sample project for a more in-depth example but here's the main code required:\n\n```\nauto gamepadSystem = CS::Application::Get()->GetSystem<CS::GamepadSystem>();\nif(gamepadSystem != nullptr)\n{\n    gamepadSystem->SetDefaultActionMapping(k_moveGamepadAction, CS::GamepadAxis::k_y);\n    gamepadSystem->SetActionMapping(k_moveGamepadAction, CS::GamepadMappings::PS4::k_name, CS::GamepadMappings::PS4::k_dpadY, true);\n    gamepadSystem->SetActionMapping(k_moveGamepadAction, CS::GamepadMappings::PS4::k_name, CS::GamepadMappings::PS4::k_lStickY);\n\n    m_gamepadAxisEventConnection = gamepadSystem->GetMappedAxisPositionChangedEvent().OpenConnection([=](const CS::Gamepad& gamepad, f64 timestamp, u32 actionId, f32 position) { //AXIS MOVED });\n    m_gamepadButtonEventConnection = gamepadSystem->GetMappedButtonPressureChangedEvent().OpenConnection([=](const CS::Gamepad& gamepad, f64 timestamp, u32 actionId, f32 pressure) { //BUTTON PRESSURE CHANGED });\n}\n```\n\n## Next Steps\n\nThere isn't much more to say other than have fun and let us know how you get on.\n"
  },
  {
    "path": "LICENSE",
    "content": "The MIT License (MIT)\n\nCopyright (c) 2017 Tag Games\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n\n"
  },
  {
    "path": "Libraries/Core/Android/Headers/SHA1/HMAC_SHA1.h",
    "content": "/*\r\n\t100% free public domain implementation of the HMAC-SHA1 algorithm\r\n\tby Chien-Chung, Chung (Jim Chung) <jimchung1221@gmail.com>\r\n*/\r\n\r\n\r\n#ifndef __HMAC_SHA1_H__\r\n#define __HMAC_SHA1_H__\r\n\r\n#include \"SHA1.h\"\r\n\r\ntypedef unsigned char BYTE ;\r\n\r\nclass CHMAC_SHA1 : public CSHA1\r\n{\r\n    private:\r\n\t\tBYTE m_ipad[64];\r\n        BYTE m_opad[64];\r\n\r\n\t\tchar * szReport ;\r\n\t\tchar * SHA1_Key ;\r\n\t\tchar * AppendBuf1 ;\r\n\t\tchar * AppendBuf2 ;\r\n\r\n\r\n\tpublic:\r\n\t\t\r\n\t\tenum {\r\n\t\t\tSHA1_DIGEST_LENGTH\t= 20,\r\n\t\t\tSHA1_BLOCK_SIZE\t\t= 64,\r\n\t\t\tHMAC_BUF_LEN\t\t= 4096\r\n\t\t} ;\r\n\r\n\t\tCHMAC_SHA1()\r\n\t\t\t:szReport(new char[HMAC_BUF_LEN]),\r\n             AppendBuf1(new char[HMAC_BUF_LEN]),\r\n             AppendBuf2(new char[HMAC_BUF_LEN]),\r\n             SHA1_Key(new char[HMAC_BUF_LEN])\r\n\t\t{}\r\n\r\n        ~CHMAC_SHA1()\r\n        {\r\n            delete[] szReport ;\r\n            delete[] AppendBuf1 ;\r\n            delete[] AppendBuf2 ;\r\n            delete[] SHA1_Key ;\r\n        }\r\n\r\n        void HMAC_SHA1(BYTE *text, int text_len, BYTE *key, int key_len, BYTE *digest);\r\n};\r\n\r\n\r\n#endif /* __HMAC_SHA1_H__ */\r\n"
  },
  {
    "path": "Libraries/Core/Android/Headers/SHA1/SHA1.h",
    "content": "/*\r\n  100% free public domain implementation of the SHA-1 algorithm\r\n  by Dominik Reichl <dominik.reichl@t-online.de>\r\n  Web: http://www.dominik-reichl.de/\r\n\r\n  Version 2.1 - 2012-06-19\r\n  - Deconstructor (resetting internal variables) is now only\r\n    implemented if SHA1_WIPE_VARIABLES is defined (which is the\r\n    default).\r\n  - Renamed inclusion guard to contain a GUID.\r\n  - Demo application is now using C++/STL objects and functions.\r\n  - Unicode build of the demo application now outputs the hashes of both\r\n    the ANSI and Unicode representations of strings.\r\n  - Various other demo application improvements.\r\n\r\n  Version 2.0 - 2012-06-14\r\n  - Added 'limits.h' include.\r\n  - Renamed inclusion guard and macros for compliancy (names beginning\r\n    with an underscore are reserved).\r\n\r\n  Version 1.9 - 2011-11-10\r\n  - Added Unicode test vectors.\r\n  - Improved support for hashing files using the HashFile method that\r\n    are larger than 4 GB.\r\n  - Improved file hashing performance (by using a larger buffer).\r\n  - Disabled unnecessary compiler warnings.\r\n  - Internal variables are now private.\r\n\r\n  Version 1.8 - 2009-03-16\r\n  - Converted project files to Visual Studio 2008 format.\r\n  - Added Unicode support for HashFile utility method.\r\n  - Added support for hashing files using the HashFile method that are\r\n    larger than 2 GB.\r\n  - HashFile now returns an error code instead of copying an error\r\n    message into the output buffer.\r\n  - GetHash now returns an error code and validates the input parameter.\r\n  - Added ReportHashStl STL utility method.\r\n  - Added REPORT_HEX_SHORT reporting mode.\r\n  - Improved Linux compatibility of test program.\r\n\r\n  Version 1.7 - 2006-12-21\r\n  - Fixed buffer underrun warning that appeared when compiling with\r\n    Borland C Builder (thanks to Rex Bloom and Tim Gallagher for the\r\n    patch).\r\n  - Breaking change: ReportHash writes the final hash to the start\r\n    of the buffer, i.e. it's not appending it to the string anymore.\r\n  - Made some function parameters const.\r\n  - Added Visual Studio 2005 project files to demo project.\r\n\r\n  Version 1.6 - 2005-02-07 (thanks to Howard Kapustein for patches)\r\n  - You can set the endianness in your files, no need to modify the\r\n    header file of the CSHA1 class anymore.\r\n  - Aligned data support.\r\n  - Made support/compilation of the utility functions (ReportHash and\r\n    HashFile) optional (useful when bytes count, for example in embedded\r\n    environments).\r\n\r\n  Version 1.5 - 2005-01-01\r\n  - 64-bit compiler compatibility added.\r\n  - Made variable wiping optional (define SHA1_WIPE_VARIABLES).\r\n  - Removed unnecessary variable initializations.\r\n  - ROL32 improvement for the Microsoft compiler (using _rotl).\r\n\r\n  Version 1.4 - 2004-07-22\r\n  - CSHA1 now compiles fine with GCC 3.3 under Mac OS X (thanks to Larry\r\n    Hastings).\r\n\r\n  Version 1.3 - 2003-08-17\r\n  - Fixed a small memory bug and made a buffer array a class member to\r\n    ensure correct working when using multiple CSHA1 class instances at\r\n    one time.\r\n\r\n  Version 1.2 - 2002-11-16\r\n  - Borlands C++ compiler seems to have problems with string addition\r\n    using sprintf. Fixed the bug which caused the digest report function\r\n    not to work properly. CSHA1 is now Borland compatible.\r\n\r\n  Version 1.1 - 2002-10-11\r\n  - Removed two unnecessary header file includes and changed BOOL to\r\n    bool. Fixed some minor bugs in the web page contents.\r\n\r\n  Version 1.0 - 2002-06-20\r\n  - First official release.\r\n\r\n  ================ Test Vectors ================\r\n\r\n  SHA1(\"abc\" in ANSI) =\r\n    A9993E36 4706816A BA3E2571 7850C26C 9CD0D89D\r\n  SHA1(\"abc\" in Unicode LE) =\r\n    9F04F41A 84851416 2050E3D6 8C1A7ABB 441DC2B5\r\n\r\n  SHA1(\"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq\"\r\n    in ANSI) =\r\n    84983E44 1C3BD26E BAAE4AA1 F95129E5 E54670F1\r\n  SHA1(\"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq\"\r\n    in Unicode LE) =\r\n    51D7D876 9AC72C40 9C5B0E3F 69C60ADC 9A039014\r\n\r\n  SHA1(A million repetitions of \"a\" in ANSI) =\r\n    34AA973C D4C4DAA4 F61EEB2B DBAD2731 6534016F\r\n  SHA1(A million repetitions of \"a\" in Unicode LE) =\r\n    C4609560 A108A0C6 26AA7F2B 38A65566 739353C5\r\n*/\r\n\r\n#ifndef SHA1_H_A545E61D43E9404E8D736869AB3CBFE7\r\n#define SHA1_H_A545E61D43E9404E8D736869AB3CBFE7\r\n\r\n#if !defined(SHA1_UTILITY_FUNCTIONS) && !defined(SHA1_NO_UTILITY_FUNCTIONS)\r\n#define SHA1_UTILITY_FUNCTIONS\r\n#endif\r\n\r\n#if !defined(SHA1_STL_FUNCTIONS) && !defined(SHA1_NO_STL_FUNCTIONS)\r\n#define SHA1_STL_FUNCTIONS\r\n#if !defined(SHA1_UTILITY_FUNCTIONS)\r\n#error STL functions require SHA1_UTILITY_FUNCTIONS.\r\n#endif\r\n#endif\r\n\r\n#include <memory.h>\r\n#include <limits.h>\r\n\r\n#ifdef SHA1_UTILITY_FUNCTIONS\r\n#include <stdio.h>\r\n#include <string.h>\r\n#endif\r\n\r\n#ifdef SHA1_STL_FUNCTIONS\r\n#include <string>\r\n#endif\r\n\r\n#ifdef _MSC_VER\r\n#include <stdlib.h>\r\n#endif\r\n\r\n// You can define the endian mode in your files without modifying the SHA-1\r\n// source files. Just #define SHA1_LITTLE_ENDIAN or #define SHA1_BIG_ENDIAN\r\n// in your files, before including the SHA1.h header file. If you don't\r\n// define anything, the class defaults to little endian.\r\n#if !defined(SHA1_LITTLE_ENDIAN) && !defined(SHA1_BIG_ENDIAN)\r\n#define SHA1_LITTLE_ENDIAN\r\n#endif\r\n\r\n// If you want variable wiping, #define SHA1_WIPE_VARIABLES, if not,\r\n// #define SHA1_NO_WIPE_VARIABLES. If you don't define anything, it\r\n// defaults to wiping.\r\n#if !defined(SHA1_WIPE_VARIABLES) && !defined(SHA1_NO_WIPE_VARIABLES)\r\n#define SHA1_WIPE_VARIABLES\r\n#endif\r\n\r\n#if defined(SHA1_HAS_TCHAR)\r\n#include <tchar.h>\r\n#else\r\n#ifdef _MSC_VER\r\n#include <tchar.h>\r\n#else\r\n#ifndef TCHAR\r\n#define TCHAR char\r\n#endif\r\n#ifndef _T\r\n#define _T(__x) (__x)\r\n#define _tmain main\r\n#define _tprintf printf\r\n#define _getts gets\r\n#define _tcslen strlen\r\n#define _tfopen fopen\r\n#define _tcscpy strcpy\r\n#define _tcscat strcat\r\n#define _sntprintf snprintf\r\n#endif\r\n#endif\r\n#endif\r\n\r\n///////////////////////////////////////////////////////////////////////////\r\n// Define variable types\r\n\r\n#ifndef UINT_8\r\n#ifdef _MSC_VER // Compiling with Microsoft compiler\r\n#define UINT_8 unsigned __int8\r\n#else // !_MSC_VER\r\n#define UINT_8 unsigned char\r\n#endif // _MSC_VER\r\n#endif\r\n\r\n#ifndef UINT_32\r\n#ifdef _MSC_VER // Compiling with Microsoft compiler\r\n#define UINT_32 unsigned __int32\r\n#else // !_MSC_VER\r\n#if (ULONG_MAX == 0xFFFFFFFFUL)\r\n#define UINT_32 unsigned long\r\n#else\r\n#define UINT_32 unsigned int\r\n#endif\r\n#endif // _MSC_VER\r\n#endif // UINT_32\r\n\r\n#ifndef INT_64\r\n#ifdef _MSC_VER // Compiling with Microsoft compiler\r\n#define INT_64 __int64\r\n#else // !_MSC_VER\r\n#define INT_64 long long\r\n#endif // _MSC_VER\r\n#endif // INT_64\r\n\r\n#ifndef UINT_64\r\n#ifdef _MSC_VER // Compiling with Microsoft compiler\r\n#define UINT_64 unsigned __int64\r\n#else // !_MSC_VER\r\n#define UINT_64 unsigned long long\r\n#endif // _MSC_VER\r\n#endif // UINT_64\r\n\r\n///////////////////////////////////////////////////////////////////////////\r\n// Declare SHA-1 workspace\r\n\r\ntypedef union\r\n{\r\n\tUINT_8 c[64];\r\n\tUINT_32 l[16];\r\n} SHA1_WORKSPACE_BLOCK;\r\n\r\nclass CSHA1\r\n{\r\npublic:\r\n#ifdef SHA1_UTILITY_FUNCTIONS\r\n\t// Different formats for ReportHash(Stl)\r\n\tenum REPORT_TYPE\r\n\t{\r\n\t\tREPORT_HEX = 0,\r\n\t\tREPORT_DIGIT = 1,\r\n\t\tREPORT_HEX_SHORT = 2\r\n\t};\r\n#endif\r\n\r\n\t// Constructor and destructor\r\n\tCSHA1();\r\n\r\n#ifdef SHA1_WIPE_VARIABLES\r\n\t~CSHA1();\r\n#endif\r\n\r\n\tvoid Reset();\r\n\r\n\t// Hash in binary data and strings\r\n\tvoid Update(const UINT_8* pbData, UINT_32 uLen);\r\n\r\n#ifdef SHA1_UTILITY_FUNCTIONS\r\n\t// Hash in file contents\r\n\tbool HashFile(const TCHAR* tszFileName);\r\n#endif\r\n\r\n\t// Finalize hash; call it before using ReportHash(Stl)\r\n\tvoid Final();\r\n\r\n#ifdef SHA1_UTILITY_FUNCTIONS\r\n\tbool ReportHash(TCHAR* tszReport, REPORT_TYPE rtReportType = REPORT_HEX) const;\r\n#endif\r\n\r\n#ifdef SHA1_STL_FUNCTIONS\r\n\tbool ReportHashStl(std::basic_string<TCHAR>& strOut, REPORT_TYPE rtReportType =\r\n\t\tREPORT_HEX) const;\r\n#endif\r\n\r\n\t// Get the raw message digest (20 bytes)\r\n\tbool GetHash(UINT_8* pbDest20) const;\r\n\r\nprivate:\r\n\t// Private SHA-1 transformation\r\n\tvoid Transform(UINT_32* pState, const UINT_8* pBuffer);\r\n\r\n\t// Member variables\r\n\tUINT_32 m_state[5];\r\n\tUINT_32 m_count[2];\r\n\tUINT_32 m_reserved0[1]; // Memory alignment padding\r\n\tUINT_8 m_buffer[64];\r\n\tUINT_8 m_digest[20];\r\n\tUINT_32 m_reserved1[3]; // Memory alignment padding\r\n\r\n\tUINT_8 m_workspace[64];\r\n\tSHA1_WORKSPACE_BLOCK* m_block; // SHA1 pointer to the byte array above\r\n};\r\n\r\n#endif // SHA1_H_A545E61D43E9404E8D736869AB3CBFE7\r\n"
  },
  {
    "path": "Libraries/Core/Android/Headers/SHA256/sha256.h",
    "content": "// //////////////////////////////////////////////////////////\n// sha256.h\n// Copyright (c) 2014,2015 Stephan Brumme. All rights reserved.\n// see http://create.stephan-brumme.com/disclaimer.html\n//\n\n#pragma once\n\n//#include \"hash.h\"\n#include <string>\n\n// define fixed size integer types\n#ifdef _MSC_VER\n// Windows\ntypedef unsigned __int8  uint8_t;\ntypedef unsigned __int32 uint32_t;\ntypedef unsigned __int64 uint64_t;\n#else\n// GCC\n#include <stdint.h>\n#endif\n\n\n/// compute SHA256 hash\n/** Usage:\n    SHA256 sha256;\n    std::string myHash  = sha256(\"Hello World\");     // std::string\n    std::string myHash2 = sha256(\"How are you\", 11); // arbitrary data, 11 bytes\n\n    // or in a streaming fashion:\n\n    SHA256 sha256;\n    while (more data available)\n      sha256.add(pointer to fresh data, number of new bytes);\n    std::string myHash3 = sha256.getHash();\n  */\nclass SHA256 //: public Hash\n{\npublic:\n  /// split into 64 byte blocks (=> 512 bits), hash is 32 bytes long\n  enum { BlockSize = 512 / 8, HashBytes = 32 };\n\n  /// same as reset()\n  SHA256();\n\n  /// compute SHA256 of a memory block\n  std::string operator()(const void* data, size_t numBytes);\n  /// compute SHA256 of a string, excluding final zero\n  std::string operator()(const std::string& text);\n\n  /// add arbitrary number of bytes\n  void add(const void* data, size_t numBytes);\n\n  /// return latest hash as 64 hex characters\n  std::string getHash();\n  /// return latest hash as bytes\n  void        getHash(unsigned char buffer[HashBytes]);\n\n  /// restart\n  void reset();\n\nprivate:\n  /// process 64 bytes\n  void processBlock(const void* data);\n  /// process everything left in the internal buffer\n  void processBuffer();\n\n  /// size of processed data in bytes\n  uint64_t m_numBytes;\n  /// valid bytes in m_buffer\n  size_t   m_bufferSize;\n  /// bytes not processed yet\n  uint8_t  m_buffer[BlockSize];\n\n  enum { HashValues = HashBytes / 4 };\n  /// hash, stored as integers\n  uint32_t m_hash[HashValues];\n};\n"
  },
  {
    "path": "Libraries/Core/Android/Headers/aes/aes.h",
    "content": "/* The MIT License\n\n   Copyright (C) 2011 Zilong Tan (labytan@gmail.com)\n\n   Permission is hereby granted, free of charge, to any person obtaining\n   a copy of this software and associated documentation files (the\n   \"Software\"), to deal in the Software without restriction, including\n   without limitation the rights to use, copy, modify, merge, publish,\n   distribute, sublicense, and/or sell copies of the Software, and to\n   permit persons to whom the Software is furnished to do so, subject to\n   the following conditions:\n\n   The above copyright notice and this permission notice shall be\n   included in all copies or substantial portions of the Software.\n\n   THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n   NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS\n   BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\n   ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\n   CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n   SOFTWARE.\n*/\n\n/*\n * aes.h\n *\n * @version 3.0 (December 2000)\n *\n * Optimised ANSI C code for the Rijndael cipher (now AES)\n *\n * @author Vincent Rijmen <vincent.rijmen@esat.kuleuven.ac.be>\n * @author Antoon Bosselaers <antoon.bosselaers@esat.kuleuven.ac.be>\n * @author Paulo Barreto <paulo.barreto@terra.com.br>\n *\n * This code is hereby placed in the public domain.\n *\n * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ''AS IS'' AND ANY EXPRESS\n * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE\n * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,\n * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\n#ifndef __ULIB_AES_H\n#define __ULIB_AES_H\n\n#include <stdint.h>\n\n#define AES_MAXNR 14\n#define AES_BLOCK_SIZE 16\n\nstruct aes_key_st {\n        uint32_t rd_key[4 *(AES_MAXNR + 1)];\n        int rounds;\n};\n\ntypedef struct aes_key_st AES_KEY;\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n        /* bits can be 128, 192 or 256 */\n        int  AES_set_encrypt_key(const unsigned char *userKey, const int bits,\n                                AES_KEY *key);\n        int  AES_set_decrypt_key(const unsigned char *userKey, const int bits,\n                                AES_KEY *key);\n\n        /* in/out can be the same for ECB encryption/decryption */\n        void AES_encrypt(const unsigned char *in, unsigned char *out,\n                         const AES_KEY *key);\n        void AES_decrypt(const unsigned char *in, unsigned char *out,\n                         const AES_KEY *key);\n\n        /* in/out can be the same */\n        void AES_cbc_encrypt(const unsigned char *in, unsigned char *out, unsigned char *ivec,\n                             unsigned long nblock, const AES_KEY *key);\n\n        /* in/out MUST be DIFFERENT */\n        void AES_cbc_decrypt(const unsigned char *in, unsigned char *out, unsigned char *ivec,\n                             unsigned long nblock, const AES_KEY *key);\n\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "Libraries/Core/Android/Headers/base64/base64.h",
    "content": "#include <string>\n\nstd::string base64_encode(unsigned char const* , unsigned int len);\nstd::string base64_decode(std::string const& s);\n"
  },
  {
    "path": "Libraries/Core/Android/Headers/json/assertions.h",
    "content": "// Copyright 2007-2010 Baptiste Lepilleur\n// Distributed under MIT license, or public domain if desired and\n// recognized in your jurisdiction.\n// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE\n\n#ifndef CPPTL_JSON_ASSERTIONS_H_INCLUDED\n#define CPPTL_JSON_ASSERTIONS_H_INCLUDED\n\n#include <stdlib.h>\n\n#if !defined(JSON_IS_AMALGAMATION)\n#include \"config.h\"\n#endif // if !defined(JSON_IS_AMALGAMATION)\n\n#if JSON_USE_EXCEPTION\n#include <stdexcept>\n#define JSON_ASSERT(condition)                                                 \\\n  assert(condition); // @todo <= change this into an exception throw\n#define JSON_FAIL_MESSAGE(message) throw std::runtime_error(message);\n#else // JSON_USE_EXCEPTION\n#define JSON_ASSERT(condition) assert(condition);\n\n// The call to assert() will show the failure message in debug builds. In\n// release bugs we write to invalid memory in order to crash hard, so that a\n// debugger or crash reporter gets the chance to take over. We still call exit()\n// afterward in order to tell the compiler that this macro doesn't return.\n#define JSON_FAIL_MESSAGE(message)                                             \\\n  {                                                                            \\\n    assert(false &&message);                                                   \\\n    strcpy(reinterpret_cast<char *>(666), message);                            \\\n    exit(123);                                                                 \\\n  }\n\n#endif\n\n#define JSON_ASSERT_MESSAGE(condition, message)                                \\\n  if (!(condition)) {                                                          \\\n    JSON_FAIL_MESSAGE(message)                                                 \\\n  }\n\n#endif // CPPTL_JSON_ASSERTIONS_H_INCLUDED\n"
  },
  {
    "path": "Libraries/Core/Android/Headers/json/autolink.h",
    "content": "// Copyright 2007-2010 Baptiste Lepilleur\n// Distributed under MIT license, or public domain if desired and\n// recognized in your jurisdiction.\n// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE\n\n#ifndef JSON_AUTOLINK_H_INCLUDED\n#define JSON_AUTOLINK_H_INCLUDED\n\n#include \"config.h\"\n\n#ifdef JSON_IN_CPPTL\n#include <cpptl/cpptl_autolink.h>\n#endif\n\n#if !defined(JSON_NO_AUTOLINK) && !defined(JSON_DLL_BUILD) &&                  \\\n    !defined(JSON_IN_CPPTL)\n#define CPPTL_AUTOLINK_NAME \"json\"\n#undef CPPTL_AUTOLINK_DLL\n#ifdef JSON_DLL\n#define CPPTL_AUTOLINK_DLL\n#endif\n#include \"autolink.h\"\n#endif\n\n#endif // JSON_AUTOLINK_H_INCLUDED\n"
  },
  {
    "path": "Libraries/Core/Android/Headers/json/config.h",
    "content": "// Copyright 2007-2010 Baptiste Lepilleur\n// Distributed under MIT license, or public domain if desired and\n// recognized in your jurisdiction.\n// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE\n\n#ifndef JSON_CONFIG_H_INCLUDED\n#define JSON_CONFIG_H_INCLUDED\n\n/// If defined, indicates that json library is embedded in CppTL library.\n//# define JSON_IN_CPPTL 1\n\n/// If defined, indicates that json may leverage CppTL library\n//#  define JSON_USE_CPPTL 1\n/// If defined, indicates that cpptl vector based map should be used instead of\n/// std::map\n/// as Value container.\n//#  define JSON_USE_CPPTL_SMALLMAP 1\n/// If defined, indicates that Json specific container should be used\n/// (hash table & simple deque container with customizable allocator).\n/// THIS FEATURE IS STILL EXPERIMENTAL! There is know bugs: See #3177332\n//#  define JSON_VALUE_USE_INTERNAL_MAP 1\n/// Force usage of standard new/malloc based allocator instead of memory pool\n/// based allocator.\n/// The memory pools allocator used optimization (initializing Value and\n/// ValueInternalLink\n/// as if it was a POD) that may cause some validation tool to report errors.\n/// Only has effects if JSON_VALUE_USE_INTERNAL_MAP is defined.\n//#  define JSON_USE_SIMPLE_INTERNAL_ALLOCATOR 1\n\n// If non-zero, the library uses exceptions to report bad input instead of C\n// assertion macros. The default is to use exceptions.\n#ifndef JSON_USE_EXCEPTION\n#define JSON_USE_EXCEPTION 1\n#endif\n\n/// If defined, indicates that the source file is amalgated\n/// to prevent private header inclusion.\n/// Remarks: it is automatically defined in the generated amalgated header.\n// #define JSON_IS_AMALGAMATION\n\n#ifdef JSON_IN_CPPTL\n#include <cpptl/config.h>\n#ifndef JSON_USE_CPPTL\n#define JSON_USE_CPPTL 1\n#endif\n#endif\n\n#ifdef JSON_IN_CPPTL\n#define JSON_API CPPTL_API\n#elif defined(JSON_DLL_BUILD)\n#if defined(_MSC_VER)\n#define JSON_API __declspec(dllexport)\n#define JSONCPP_DISABLE_DLL_INTERFACE_WARNING\n#endif // if defined(_MSC_VER)\n#elif defined(JSON_DLL)\n#if defined(_MSC_VER)\n#define JSON_API __declspec(dllimport)\n#define JSONCPP_DISABLE_DLL_INTERFACE_WARNING\n#endif // if defined(_MSC_VER)\n#endif // ifdef JSON_IN_CPPTL\n#if !defined(JSON_API)\n#define JSON_API\n#endif\n\n// If JSON_NO_INT64 is defined, then Json only support C++ \"int\" type for\n// integer\n// Storages, and 64 bits integer support is disabled.\n// #define JSON_NO_INT64 1\n\n#if defined(_MSC_VER) && _MSC_VER <= 1200 // MSVC 6\n// Microsoft Visual Studio 6 only support conversion from __int64 to double\n// (no conversion from unsigned __int64).\n#define JSON_USE_INT64_DOUBLE_CONVERSION 1\n// Disable warning 4786 for VS6 caused by STL (identifier was truncated to '255'\n// characters in the debug information)\n// All projects I've ever seen with VS6 were using this globally (not bothering\n// with pragma push/pop).\n#pragma warning(disable : 4786)\n#endif // if defined(_MSC_VER)  &&  _MSC_VER < 1200 // MSVC 6\n\n#if defined(_MSC_VER) && _MSC_VER >= 1500 // MSVC 2008\n/// Indicates that the following function is deprecated.\n#define JSONCPP_DEPRECATED(message) __declspec(deprecated(message))\n#endif\n\n#if !defined(JSONCPP_DEPRECATED)\n#define JSONCPP_DEPRECATED(message)\n#endif // if !defined(JSONCPP_DEPRECATED)\n\nnamespace Json {\ntypedef int Int;\ntypedef unsigned int UInt;\n#if defined(JSON_NO_INT64)\ntypedef int LargestInt;\ntypedef unsigned int LargestUInt;\n#undef JSON_HAS_INT64\n#else                 // if defined(JSON_NO_INT64)\n// For Microsoft Visual use specific types as long long is not supported\n#if defined(_MSC_VER) // Microsoft Visual Studio\ntypedef __int64 Int64;\ntypedef unsigned __int64 UInt64;\n#else                 // if defined(_MSC_VER) // Other platforms, use long long\ntypedef long long int Int64;\ntypedef unsigned long long int UInt64;\n#endif // if defined(_MSC_VER)\ntypedef Int64 LargestInt;\ntypedef UInt64 LargestUInt;\n#define JSON_HAS_INT64\n#endif // if defined(JSON_NO_INT64)\n} // end namespace Json\n\n#endif // JSON_CONFIG_H_INCLUDED\n"
  },
  {
    "path": "Libraries/Core/Android/Headers/json/features.h",
    "content": "// Copyright 2007-2010 Baptiste Lepilleur\n// Distributed under MIT license, or public domain if desired and\n// recognized in your jurisdiction.\n// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE\n\n#ifndef CPPTL_JSON_FEATURES_H_INCLUDED\n#define CPPTL_JSON_FEATURES_H_INCLUDED\n\n#if !defined(JSON_IS_AMALGAMATION)\n#include \"forwards.h\"\n#endif // if !defined(JSON_IS_AMALGAMATION)\n\nnamespace Json {\n\n/** \\brief Configuration passed to reader and writer.\n * This configuration object can be used to force the Reader or Writer\n * to behave in a standard conforming way.\n */\nclass JSON_API Features {\npublic:\n  /** \\brief A configuration that allows all features and assumes all strings\n   * are UTF-8.\n   * - C & C++ comments are allowed\n   * - Root object can be any JSON value\n   * - Assumes Value strings are encoded in UTF-8\n   */\n  static Features all();\n\n  /** \\brief A configuration that is strictly compatible with the JSON\n   * specification.\n   * - Comments are forbidden.\n   * - Root object must be either an array or an object value.\n   * - Assumes Value strings are encoded in UTF-8\n   */\n  static Features strictMode();\n\n  /** \\brief Initialize the configuration like JsonConfig::allFeatures;\n   */\n  Features();\n\n  /// \\c true if comments are allowed. Default: \\c true.\n  bool allowComments_;\n\n  /// \\c true if root must be either an array or an object value. Default: \\c\n  /// false.\n  bool strictRoot_;\n\n  /// \\c true if dropped null placeholders are allowed. Default: \\c false.\n  bool allowDroppedNullPlaceholders_;\n\n  /// \\c true if numeric object key are allowed. Default: \\c false.\n  bool allowNumericKeys_;\n};\n\n} // namespace Json\n\n#endif // CPPTL_JSON_FEATURES_H_INCLUDED\n"
  },
  {
    "path": "Libraries/Core/Android/Headers/json/forwards.h",
    "content": "// Copyright 2007-2010 Baptiste Lepilleur\n// Distributed under MIT license, or public domain if desired and\n// recognized in your jurisdiction.\n// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE\n\n#ifndef JSON_FORWARDS_H_INCLUDED\n#define JSON_FORWARDS_H_INCLUDED\n\n#if !defined(JSON_IS_AMALGAMATION)\n#include \"config.h\"\n#endif // if !defined(JSON_IS_AMALGAMATION)\n\nnamespace Json {\n\n// writer.h\nclass FastWriter;\nclass StyledWriter;\n\n// reader.h\nclass Reader;\n\n// features.h\nclass Features;\n\n// value.h\ntypedef unsigned int ArrayIndex;\nclass StaticString;\nclass Path;\nclass PathArgument;\nclass Value;\nclass ValueIteratorBase;\nclass ValueIterator;\nclass ValueConstIterator;\n#ifdef JSON_VALUE_USE_INTERNAL_MAP\nclass ValueMapAllocator;\nclass ValueInternalLink;\nclass ValueInternalArray;\nclass ValueInternalMap;\n#endif // #ifdef JSON_VALUE_USE_INTERNAL_MAP\n\n} // namespace Json\n\n#endif // JSON_FORWARDS_H_INCLUDED\n"
  },
  {
    "path": "Libraries/Core/Android/Headers/json/json.h",
    "content": "// Copyright 2007-2010 Baptiste Lepilleur\n// Distributed under MIT license, or public domain if desired and\n// recognized in your jurisdiction.\n// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE\n\n#ifndef JSON_JSON_H_INCLUDED\n#define JSON_JSON_H_INCLUDED\n\n#include \"autolink.h\"\n#include \"value.h\"\n#include \"reader.h\"\n#include \"writer.h\"\n#include \"features.h\"\n\n#endif // JSON_JSON_H_INCLUDED\n"
  },
  {
    "path": "Libraries/Core/Android/Headers/json/json_batchallocator.h",
    "content": "// Copyright 2007-2010 Baptiste Lepilleur\n// Distributed under MIT license, or public domain if desired and\n// recognized in your jurisdiction.\n// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE\n\n#ifndef JSONCPP_BATCHALLOCATOR_H_INCLUDED\n#define JSONCPP_BATCHALLOCATOR_H_INCLUDED\n\n#include <stdlib.h>\n#include <assert.h>\n\n#ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION\n\nnamespace Json {\n\n/* Fast memory allocator.\n *\n * This memory allocator allocates memory for a batch of object (specified by\n * the page size, the number of object in each page).\n *\n * It does not allow the destruction of a single object. All the allocated\n * objects can be destroyed at once. The memory can be either released or reused\n * for future allocation.\n *\n * The in-place new operator must be used to construct the object using the\n * pointer returned by allocate.\n */\ntemplate <typename AllocatedType, const unsigned int objectPerAllocation>\nclass BatchAllocator {\npublic:\n  BatchAllocator(unsigned int objectsPerPage = 255)\n      : freeHead_(0), objectsPerPage_(objectsPerPage) {\n    //      printf( \"Size: %d => %s\\n\", sizeof(AllocatedType),\n    // typeid(AllocatedType).name() );\n    assert(sizeof(AllocatedType) * objectPerAllocation >=\n           sizeof(AllocatedType *)); // We must be able to store a slist in the\n                                     // object free space.\n    assert(objectsPerPage >= 16);\n    batches_ = allocateBatch(0); // allocated a dummy page\n    currentBatch_ = batches_;\n  }\n\n  ~BatchAllocator() {\n    for (BatchInfo *batch = batches_; batch;) {\n      BatchInfo *nextBatch = batch->next_;\n      free(batch);\n      batch = nextBatch;\n    }\n  }\n\n  /// allocate space for an array of objectPerAllocation object.\n  /// @warning it is the responsability of the caller to call objects\n  /// constructors.\n  AllocatedType *allocate() {\n    if (freeHead_) // returns node from free list.\n    {\n      AllocatedType *object = freeHead_;\n      freeHead_ = *(AllocatedType **)object;\n      return object;\n    }\n    if (currentBatch_->used_ == currentBatch_->end_) {\n      currentBatch_ = currentBatch_->next_;\n      while (currentBatch_ && currentBatch_->used_ == currentBatch_->end_)\n        currentBatch_ = currentBatch_->next_;\n\n      if (!currentBatch_) // no free batch found, allocate a new one\n      {\n        currentBatch_ = allocateBatch(objectsPerPage_);\n        currentBatch_->next_ = batches_; // insert at the head of the list\n        batches_ = currentBatch_;\n      }\n    }\n    AllocatedType *allocated = currentBatch_->used_;\n    currentBatch_->used_ += objectPerAllocation;\n    return allocated;\n  }\n\n  /// Release the object.\n  /// @warning it is the responsability of the caller to actually destruct the\n  /// object.\n  void release(AllocatedType *object) {\n    assert(object != 0);\n    *(AllocatedType **)object = freeHead_;\n    freeHead_ = object;\n  }\n\nprivate:\n  struct BatchInfo {\n    BatchInfo *next_;\n    AllocatedType *used_;\n    AllocatedType *end_;\n    AllocatedType buffer_[objectPerAllocation];\n  };\n\n  // disabled copy constructor and assignement operator.\n  BatchAllocator(const BatchAllocator &);\n  void operator=(const BatchAllocator &);\n\n  static BatchInfo *allocateBatch(unsigned int objectsPerPage) {\n    const unsigned int mallocSize =\n        sizeof(BatchInfo) - sizeof(AllocatedType) * objectPerAllocation +\n        sizeof(AllocatedType) * objectPerAllocation * objectsPerPage;\n    BatchInfo *batch = static_cast<BatchInfo *>(malloc(mallocSize));\n    batch->next_ = 0;\n    batch->used_ = batch->buffer_;\n    batch->end_ = batch->buffer_ + objectsPerPage;\n    return batch;\n  }\n\n  BatchInfo *batches_;\n  BatchInfo *currentBatch_;\n  /// Head of a single linked list within the allocated space of freeed object\n  AllocatedType *freeHead_;\n  unsigned int objectsPerPage_;\n};\n\n} // namespace Json\n\n#endif // ifndef JSONCPP_DOC_INCLUDE_IMPLEMENTATION\n\n#endif // JSONCPP_BATCHALLOCATOR_H_INCLUDED\n// vim: et ts=2 sts=2 sw=2 tw=0\n"
  },
  {
    "path": "Libraries/Core/Android/Headers/json/json_internalarray.inl",
    "content": "// Copyright 2007-2010 Baptiste Lepilleur\n// Distributed under MIT license, or public domain if desired and\n// recognized in your jurisdiction.\n// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE\n\n// included by json_value.cpp\n\nnamespace Json {\n\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// class ValueInternalArray\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n\nValueArrayAllocator::~ValueArrayAllocator()\n{\n}\n\n// //////////////////////////////////////////////////////////////////\n// class DefaultValueArrayAllocator\n// //////////////////////////////////////////////////////////////////\n#ifdef JSON_USE_SIMPLE_INTERNAL_ALLOCATOR\nclass DefaultValueArrayAllocator : public ValueArrayAllocator\n{\npublic: // overridden from ValueArrayAllocator\n   virtual ~DefaultValueArrayAllocator()\n   {\n   }\n\n   virtual ValueInternalArray *newArray()\n   {\n      return new ValueInternalArray();\n   }\n\n   virtual ValueInternalArray *newArrayCopy( const ValueInternalArray &other )\n   {\n      return new ValueInternalArray( other );\n   }\n\n   virtual void destructArray( ValueInternalArray *array )\n   {\n      delete array;\n   }\n\n   virtual void reallocateArrayPageIndex( Value **&indexes, \n                                          ValueInternalArray::PageIndex &indexCount,\n                                          ValueInternalArray::PageIndex minNewIndexCount )\n   {\n      ValueInternalArray::PageIndex newIndexCount = (indexCount*3)/2 + 1;\n      if ( minNewIndexCount > newIndexCount )\n         newIndexCount = minNewIndexCount;\n      void *newIndexes = realloc( indexes, sizeof(Value*) * newIndexCount );\n      JSON_ASSERT_MESSAGE(newIndexes, \"Couldn't realloc.\");\n      indexCount = newIndexCount;\n      indexes = static_cast<Value **>( newIndexes );\n   }\n   virtual void releaseArrayPageIndex( Value **indexes, \n                                       ValueInternalArray::PageIndex indexCount )\n   {\n      if ( indexes )\n         free( indexes );\n   }\n\n   virtual Value *allocateArrayPage()\n   {\n      return static_cast<Value *>( malloc( sizeof(Value) * ValueInternalArray::itemsPerPage ) );\n   }\n\n   virtual void releaseArrayPage( Value *value )\n   {\n      if ( value )\n         free( value );\n   }\n};\n\n#else // #ifdef JSON_USE_SIMPLE_INTERNAL_ALLOCATOR\n/// @todo make this thread-safe (lock when accessign batch allocator)\nclass DefaultValueArrayAllocator : public ValueArrayAllocator\n{\npublic: // overridden from ValueArrayAllocator\n   virtual ~DefaultValueArrayAllocator()\n   {\n   }\n\n   virtual ValueInternalArray *newArray()\n   {\n      ValueInternalArray *array = arraysAllocator_.allocate();\n      new (array) ValueInternalArray(); // placement new\n      return array;\n   }\n\n   virtual ValueInternalArray *newArrayCopy( const ValueInternalArray &other )\n   {\n      ValueInternalArray *array = arraysAllocator_.allocate();\n      new (array) ValueInternalArray( other ); // placement new\n      return array;\n   }\n\n   virtual void destructArray( ValueInternalArray *array )\n   {\n      if ( array )\n      {\n         array->~ValueInternalArray();\n         arraysAllocator_.release( array );\n      }\n   }\n\n   virtual void reallocateArrayPageIndex( Value **&indexes, \n                                          ValueInternalArray::PageIndex &indexCount,\n                                          ValueInternalArray::PageIndex minNewIndexCount )\n   {\n      ValueInternalArray::PageIndex newIndexCount = (indexCount*3)/2 + 1;\n      if ( minNewIndexCount > newIndexCount )\n         newIndexCount = minNewIndexCount;\n      void *newIndexes = realloc( indexes, sizeof(Value*) * newIndexCount );\n      JSON_ASSERT_MESSAGE(newIndexes, \"Couldn't realloc.\");\n      indexCount = newIndexCount;\n      indexes = static_cast<Value **>( newIndexes );\n   }\n   virtual void releaseArrayPageIndex( Value **indexes, \n                                       ValueInternalArray::PageIndex indexCount )\n   {\n      if ( indexes )\n         free( indexes );\n   }\n\n   virtual Value *allocateArrayPage()\n   {\n      return static_cast<Value *>( pagesAllocator_.allocate() );\n   }\n\n   virtual void releaseArrayPage( Value *value )\n   {\n      if ( value )\n         pagesAllocator_.release( value );\n   }\nprivate:\n   BatchAllocator<ValueInternalArray,1> arraysAllocator_;\n   BatchAllocator<Value,ValueInternalArray::itemsPerPage> pagesAllocator_;\n};\n#endif // #ifdef JSON_USE_SIMPLE_INTERNAL_ALLOCATOR\n\nstatic ValueArrayAllocator *&arrayAllocator()\n{\n   static DefaultValueArrayAllocator defaultAllocator;\n   static ValueArrayAllocator *arrayAllocator = &defaultAllocator;\n   return arrayAllocator;\n}\n\nstatic struct DummyArrayAllocatorInitializer {\n   DummyArrayAllocatorInitializer() \n   {\n      arrayAllocator();      // ensure arrayAllocator() statics are initialized before main().\n   }\n} dummyArrayAllocatorInitializer;\n\n// //////////////////////////////////////////////////////////////////\n// class ValueInternalArray\n// //////////////////////////////////////////////////////////////////\nbool \nValueInternalArray::equals( const IteratorState &x, \n                            const IteratorState &other )\n{\n   return x.array_ == other.array_  \n          &&  x.currentItemIndex_ == other.currentItemIndex_  \n          &&  x.currentPageIndex_ == other.currentPageIndex_;\n}\n\n\nvoid \nValueInternalArray::increment( IteratorState &it )\n{\n   JSON_ASSERT_MESSAGE( it.array_  &&\n      (it.currentPageIndex_ - it.array_->pages_)*itemsPerPage + it.currentItemIndex_\n      != it.array_->size_,\n      \"ValueInternalArray::increment(): moving iterator beyond end\" );\n   ++(it.currentItemIndex_);\n   if ( it.currentItemIndex_ == itemsPerPage )\n   {\n      it.currentItemIndex_ = 0;\n      ++(it.currentPageIndex_);\n   }\n}\n\n\nvoid \nValueInternalArray::decrement( IteratorState &it )\n{\n   JSON_ASSERT_MESSAGE( it.array_  &&  it.currentPageIndex_ == it.array_->pages_ \n                        &&  it.currentItemIndex_ == 0,\n      \"ValueInternalArray::decrement(): moving iterator beyond end\" );\n   if ( it.currentItemIndex_ == 0 )\n   {\n      it.currentItemIndex_ = itemsPerPage-1;\n      --(it.currentPageIndex_);\n   }\n   else\n   {\n      --(it.currentItemIndex_);\n   }\n}\n\n\nValue &\nValueInternalArray::unsafeDereference( const IteratorState &it )\n{\n   return (*(it.currentPageIndex_))[it.currentItemIndex_];\n}\n\n\nValue &\nValueInternalArray::dereference( const IteratorState &it )\n{\n   JSON_ASSERT_MESSAGE( it.array_  &&\n      (it.currentPageIndex_ - it.array_->pages_)*itemsPerPage + it.currentItemIndex_\n      < it.array_->size_,\n      \"ValueInternalArray::dereference(): dereferencing invalid iterator\" );\n   return unsafeDereference( it );\n}\n\nvoid \nValueInternalArray::makeBeginIterator( IteratorState &it ) const\n{\n   it.array_ = const_cast<ValueInternalArray *>( this );\n   it.currentItemIndex_ = 0;\n   it.currentPageIndex_ = pages_;\n}\n\n\nvoid \nValueInternalArray::makeIterator( IteratorState &it, ArrayIndex index ) const\n{\n   it.array_ = const_cast<ValueInternalArray *>( this );\n   it.currentItemIndex_ = index % itemsPerPage;\n   it.currentPageIndex_ = pages_ + index / itemsPerPage;\n}\n\n\nvoid \nValueInternalArray::makeEndIterator( IteratorState &it ) const\n{\n   makeIterator( it, size_ );\n}\n\n\nValueInternalArray::ValueInternalArray()\n   : pages_( 0 )\n   , size_( 0 )\n   , pageCount_( 0 )\n{\n}\n\n\nValueInternalArray::ValueInternalArray( const ValueInternalArray &other )\n   : pages_( 0 )\n   , size_( other.size_ )\n   , pageCount_( 0 )\n{\n   PageIndex minNewPages = other.size_ / itemsPerPage;\n   arrayAllocator()->reallocateArrayPageIndex( pages_, pageCount_, minNewPages );\n   JSON_ASSERT_MESSAGE( pageCount_ >= minNewPages, \n                        \"ValueInternalArray::reserve(): bad reallocation\" );\n   IteratorState itOther;\n   other.makeBeginIterator( itOther );\n   Value *value;\n   for ( ArrayIndex index = 0; index < size_; ++index, increment(itOther) )\n   {\n      if ( index % itemsPerPage == 0 )\n      {\n         PageIndex pageIndex = index / itemsPerPage;\n         value = arrayAllocator()->allocateArrayPage();\n         pages_[pageIndex] = value;\n      }\n      new (value) Value( dereference( itOther ) );\n   }\n}\n\n\nValueInternalArray &\nValueInternalArray::operator=(ValueInternalArray other)\n{\n   swap(other);\n   return *this;\n}\n\n\nValueInternalArray::~ValueInternalArray()\n{\n   // destroy all constructed items\n   IteratorState it;\n   IteratorState itEnd;\n   makeBeginIterator( it);\n   makeEndIterator( itEnd );\n   for ( ; !equals(it,itEnd); increment(it) )\n   {\n      Value *value = &dereference(it);\n      value->~Value();\n   }\n   // release all pages\n   PageIndex lastPageIndex = size_ / itemsPerPage;\n   for ( PageIndex pageIndex = 0; pageIndex < lastPageIndex; ++pageIndex )\n      arrayAllocator()->releaseArrayPage( pages_[pageIndex] );\n   // release pages index\n   arrayAllocator()->releaseArrayPageIndex( pages_, pageCount_ );\n}\n\n\nvoid \nValueInternalArray::swap( ValueInternalArray &other )\n{\n   Value **tempPages = pages_;\n   pages_ = other.pages_;\n   other.pages_ = tempPages;\n   ArrayIndex tempSize = size_;\n   size_ = other.size_;\n   other.size_ = tempSize;\n   PageIndex tempPageCount = pageCount_;\n   pageCount_ = other.pageCount_;\n   other.pageCount_ = tempPageCount;\n}\n\nvoid \nValueInternalArray::clear()\n{\n   ValueInternalArray dummy;\n   swap( dummy );\n}\n\n\nvoid \nValueInternalArray::resize( ArrayIndex newSize )\n{\n   if ( newSize == 0 )\n      clear();\n   else if ( newSize < size_ )\n   {\n      IteratorState it;\n      IteratorState itEnd;\n      makeIterator( it, newSize );\n      makeIterator( itEnd, size_ );\n      for ( ; !equals(it,itEnd); increment(it) )\n      {\n         Value *value = &dereference(it);\n         value->~Value();\n      }\n      PageIndex pageIndex = (newSize + itemsPerPage - 1) / itemsPerPage;\n      PageIndex lastPageIndex = size_ / itemsPerPage;\n      for ( ; pageIndex < lastPageIndex; ++pageIndex )\n         arrayAllocator()->releaseArrayPage( pages_[pageIndex] );\n      size_ = newSize;\n   }\n   else if ( newSize > size_ )\n      resolveReference( newSize );\n}\n\n\nvoid \nValueInternalArray::makeIndexValid( ArrayIndex index )\n{\n   // Need to enlarge page index ?\n   if ( index >= pageCount_ * itemsPerPage )\n   {\n      PageIndex minNewPages = (index + 1) / itemsPerPage;\n      arrayAllocator()->reallocateArrayPageIndex( pages_, pageCount_, minNewPages );\n      JSON_ASSERT_MESSAGE( pageCount_ >= minNewPages, \"ValueInternalArray::reserve(): bad reallocation\" );\n   }\n\n   // Need to allocate new pages ?\n   ArrayIndex nextPageIndex = \n      (size_ % itemsPerPage) != 0 ? size_ - (size_%itemsPerPage) + itemsPerPage\n                                  : size_;\n   if ( nextPageIndex <= index )\n   {\n      PageIndex pageIndex = nextPageIndex / itemsPerPage;\n      PageIndex pageToAllocate = (index - nextPageIndex) / itemsPerPage + 1;\n      for ( ; pageToAllocate-- > 0; ++pageIndex )\n         pages_[pageIndex] = arrayAllocator()->allocateArrayPage();\n   }\n\n   // Initialize all new entries\n   IteratorState it;\n   IteratorState itEnd;\n   makeIterator( it, size_ );\n   size_ = index + 1;\n   makeIterator( itEnd, size_ );\n   for ( ; !equals(it,itEnd); increment(it) )\n   {\n      Value *value = &dereference(it);\n      new (value) Value(); // Construct a default value using placement new\n   }\n}\n\nValue &\nValueInternalArray::resolveReference( ArrayIndex index )\n{\n   if ( index >= size_ )\n      makeIndexValid( index );\n   return pages_[index/itemsPerPage][index%itemsPerPage];\n}\n\nValue *\nValueInternalArray::find( ArrayIndex index ) const\n{\n   if ( index >= size_ )\n      return 0;\n   return &(pages_[index/itemsPerPage][index%itemsPerPage]);\n}\n\nValueInternalArray::ArrayIndex \nValueInternalArray::size() const\n{\n   return size_;\n}\n\nint \nValueInternalArray::distance( const IteratorState &x, const IteratorState &y )\n{\n   return indexOf(y) - indexOf(x);\n}\n\n\nValueInternalArray::ArrayIndex \nValueInternalArray::indexOf( const IteratorState &iterator )\n{\n   if ( !iterator.array_ )\n      return ArrayIndex(-1);\n   return ArrayIndex(\n      (iterator.currentPageIndex_ - iterator.array_->pages_) * itemsPerPage \n      + iterator.currentItemIndex_ );\n}\n\n\nint \nValueInternalArray::compare( const ValueInternalArray &other ) const\n{\n   int sizeDiff( size_ - other.size_ );\n   if ( sizeDiff != 0 )\n      return sizeDiff;\n   \n   for ( ArrayIndex index =0; index < size_; ++index )\n   {\n      int diff = pages_[index/itemsPerPage][index%itemsPerPage].compare( \n         other.pages_[index/itemsPerPage][index%itemsPerPage] );\n      if ( diff != 0 )\n         return diff;\n   }\n   return 0;\n}\n\n} // namespace Json\n// vim: et ts=3 sts=3 sw=3 tw=0\n"
  },
  {
    "path": "Libraries/Core/Android/Headers/json/json_internalmap.inl",
    "content": "// Copyright 2007-2010 Baptiste Lepilleur\n// Distributed under MIT license, or public domain if desired and\n// recognized in your jurisdiction.\n// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE\n\n// included by json_value.cpp\n\nnamespace Json {\n\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// class ValueInternalMap\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n\n/** \\internal MUST be safely initialized using memset( this, 0, sizeof(ValueInternalLink) );\n   * This optimization is used by the fast allocator.\n   */\nValueInternalLink::ValueInternalLink()\n   : previous_( 0 )\n   , next_( 0 )\n{\n}\n\nValueInternalLink::~ValueInternalLink()\n{ \n   for ( int index =0; index < itemPerLink; ++index )\n   {\n      if ( !items_[index].isItemAvailable() )\n      {\n         if ( !items_[index].isMemberNameStatic() )\n            free( keys_[index] );\n      }\n      else\n         break;\n   }\n}\n\n\n\nValueMapAllocator::~ValueMapAllocator()\n{\n}\n\n#ifdef JSON_USE_SIMPLE_INTERNAL_ALLOCATOR\nclass DefaultValueMapAllocator : public ValueMapAllocator\n{\npublic: // overridden from ValueMapAllocator\n   virtual ValueInternalMap *newMap()\n   {\n      return new ValueInternalMap();\n   }\n\n   virtual ValueInternalMap *newMapCopy( const ValueInternalMap &other )\n   {\n      return new ValueInternalMap( other );\n   }\n\n   virtual void destructMap( ValueInternalMap *map )\n   {\n      delete map;\n   }\n\n   virtual ValueInternalLink *allocateMapBuckets( unsigned int size )\n   {\n      return new ValueInternalLink[size];\n   }\n\n   virtual void releaseMapBuckets( ValueInternalLink *links )\n   {\n      delete [] links;\n   }\n\n   virtual ValueInternalLink *allocateMapLink()\n   {\n      return new ValueInternalLink();\n   }\n\n   virtual void releaseMapLink( ValueInternalLink *link )\n   {\n      delete link;\n   }\n};\n#else\n/// @todo make this thread-safe (lock when accessign batch allocator)\nclass DefaultValueMapAllocator : public ValueMapAllocator\n{\npublic: // overridden from ValueMapAllocator\n   virtual ValueInternalMap *newMap()\n   {\n      ValueInternalMap *map = mapsAllocator_.allocate();\n      new (map) ValueInternalMap(); // placement new\n      return map;\n   }\n\n   virtual ValueInternalMap *newMapCopy( const ValueInternalMap &other )\n   {\n      ValueInternalMap *map = mapsAllocator_.allocate();\n      new (map) ValueInternalMap( other ); // placement new\n      return map;\n   }\n\n   virtual void destructMap( ValueInternalMap *map )\n   {\n      if ( map )\n      {\n         map->~ValueInternalMap();\n         mapsAllocator_.release( map );\n      }\n   }\n\n   virtual ValueInternalLink *allocateMapBuckets( unsigned int size )\n   {\n      return new ValueInternalLink[size];\n   }\n\n   virtual void releaseMapBuckets( ValueInternalLink *links )\n   {\n      delete [] links;\n   }\n\n   virtual ValueInternalLink *allocateMapLink()\n   {\n      ValueInternalLink *link = linksAllocator_.allocate();\n      memset( link, 0, sizeof(ValueInternalLink) );\n      return link;\n   }\n\n   virtual void releaseMapLink( ValueInternalLink *link )\n   {\n      link->~ValueInternalLink();\n      linksAllocator_.release( link );\n   }\nprivate:\n   BatchAllocator<ValueInternalMap,1> mapsAllocator_;\n   BatchAllocator<ValueInternalLink,1> linksAllocator_;\n};\n#endif\n\nstatic ValueMapAllocator *&mapAllocator()\n{\n   static DefaultValueMapAllocator defaultAllocator;\n   static ValueMapAllocator *mapAllocator = &defaultAllocator;\n   return mapAllocator;\n}\n\nstatic struct DummyMapAllocatorInitializer {\n   DummyMapAllocatorInitializer() \n   {\n      mapAllocator();      // ensure mapAllocator() statics are initialized before main().\n   }\n} dummyMapAllocatorInitializer;\n\n\n\n// h(K) = value * K >> w ; with w = 32 & K prime w.r.t. 2^32.\n\n/*\nuse linked list hash map. \nbuckets array is a container.\nlinked list element contains 6 key/values. (memory = (16+4) * 6 + 4 = 124)\nvalue have extra state: valid, available, deleted\n*/\n\n\nValueInternalMap::ValueInternalMap()\n   : buckets_( 0 )\n   , tailLink_( 0 )\n   , bucketsSize_( 0 )\n   , itemCount_( 0 )\n{\n}\n\n\nValueInternalMap::ValueInternalMap( const ValueInternalMap &other )\n   : buckets_( 0 )\n   , tailLink_( 0 )\n   , bucketsSize_( 0 )\n   , itemCount_( 0 )\n{\n   reserve( other.itemCount_ );\n   IteratorState it;\n   IteratorState itEnd;\n   other.makeBeginIterator( it );\n   other.makeEndIterator( itEnd );\n   for ( ; !equals(it,itEnd); increment(it) )\n   {\n      bool isStatic;\n      const char *memberName = key( it, isStatic );\n      const Value &aValue = value( it );\n      resolveReference(memberName, isStatic) = aValue;\n   }\n}\n\n\nValueInternalMap &\nValueInternalMap::operator=(ValueInternalMap other)\n{\n   swap(other);\n   return *this;\n}\n\n\nValueInternalMap::~ValueInternalMap()\n{\n   if ( buckets_ )\n   {\n      for ( BucketIndex bucketIndex =0; bucketIndex < bucketsSize_; ++bucketIndex )\n      {\n         ValueInternalLink *link = buckets_[bucketIndex].next_;\n         while ( link )\n         {\n            ValueInternalLink *linkToRelease = link;\n            link = link->next_;\n            mapAllocator()->releaseMapLink( linkToRelease );\n         }\n      }\n      mapAllocator()->releaseMapBuckets( buckets_ );\n   }\n}\n\n\nvoid \nValueInternalMap::swap( ValueInternalMap &other )\n{\n   ValueInternalLink *tempBuckets = buckets_;\n   buckets_ = other.buckets_;\n   other.buckets_ = tempBuckets;\n   ValueInternalLink *tempTailLink = tailLink_;\n   tailLink_ = other.tailLink_;\n   other.tailLink_ = tempTailLink;\n   BucketIndex tempBucketsSize = bucketsSize_;\n   bucketsSize_ = other.bucketsSize_;\n   other.bucketsSize_ = tempBucketsSize;\n   BucketIndex tempItemCount = itemCount_;\n   itemCount_ = other.itemCount_;\n   other.itemCount_ = tempItemCount;\n}\n\n\nvoid \nValueInternalMap::clear()\n{\n   ValueInternalMap dummy;\n   swap( dummy );\n}\n\n\nValueInternalMap::BucketIndex \nValueInternalMap::size() const\n{\n   return itemCount_;\n}\n\nbool \nValueInternalMap::reserveDelta( BucketIndex growth )\n{\n   return reserve( itemCount_ + growth );\n}\n\nbool \nValueInternalMap::reserve( BucketIndex newItemCount )\n{\n   if ( !buckets_  &&  newItemCount > 0 )\n   {\n      buckets_ = mapAllocator()->allocateMapBuckets( 1 );\n      bucketsSize_ = 1;\n      tailLink_ = &buckets_[0];\n   }\n//   BucketIndex idealBucketCount = (newItemCount + ValueInternalLink::itemPerLink) / ValueInternalLink::itemPerLink;\n   return true;\n}\n\n\nconst Value *\nValueInternalMap::find( const char *key ) const\n{\n   if ( !bucketsSize_ )\n      return 0;\n   HashKey hashedKey = hash( key );\n   BucketIndex bucketIndex = hashedKey % bucketsSize_;\n   for ( const ValueInternalLink *current = &buckets_[bucketIndex]; \n         current != 0; \n         current = current->next_ )\n   {\n      for ( BucketIndex index=0; index < ValueInternalLink::itemPerLink; ++index )\n      {\n         if ( current->items_[index].isItemAvailable() )\n            return 0;\n         if ( strcmp( key, current->keys_[index] ) == 0 )\n            return &current->items_[index];\n      }\n   }\n   return 0;\n}\n\n\nValue *\nValueInternalMap::find( const char *key )\n{\n   const ValueInternalMap *constThis = this;\n   return const_cast<Value *>( constThis->find( key ) );\n}\n\n\nValue &\nValueInternalMap::resolveReference( const char *key,\n                                    bool isStatic )\n{\n   HashKey hashedKey = hash( key );\n   if ( bucketsSize_ )\n   {\n      BucketIndex bucketIndex = hashedKey % bucketsSize_;\n      ValueInternalLink **previous = 0;\n      BucketIndex index;\n      for ( ValueInternalLink *current = &buckets_[bucketIndex]; \n            current != 0; \n            previous = &current->next_, current = current->next_ )\n      {\n         for ( index=0; index < ValueInternalLink::itemPerLink; ++index )\n         {\n            if ( current->items_[index].isItemAvailable() )\n               return setNewItem( key, isStatic, current, index );\n            if ( strcmp( key, current->keys_[index] ) == 0 )\n               return current->items_[index];\n         }\n      }\n   }\n\n   reserveDelta( 1 );\n   return unsafeAdd( key, isStatic, hashedKey );\n}\n\n\nvoid \nValueInternalMap::remove( const char *key )\n{\n   HashKey hashedKey = hash( key );\n   if ( !bucketsSize_ )\n      return;\n   BucketIndex bucketIndex = hashedKey % bucketsSize_;\n   for ( ValueInternalLink *link = &buckets_[bucketIndex]; \n         link != 0; \n         link = link->next_ )\n   {\n      BucketIndex index;\n      for ( index =0; index < ValueInternalLink::itemPerLink; ++index )\n      {\n         if ( link->items_[index].isItemAvailable() )\n            return;\n         if ( strcmp( key, link->keys_[index] ) == 0 )\n         {\n            doActualRemove( link, index, bucketIndex );\n            return;\n         }\n      }\n   }\n}\n\nvoid \nValueInternalMap::doActualRemove( ValueInternalLink *link, \n                                  BucketIndex index,\n                                  BucketIndex bucketIndex )\n{\n   // find last item of the bucket and swap it with the 'removed' one.\n   // set removed items flags to 'available'.\n   // if last page only contains 'available' items, then desallocate it (it's empty)\n   ValueInternalLink *&lastLink = getLastLinkInBucket( index );\n   BucketIndex lastItemIndex = 1; // a link can never be empty, so start at 1\n   for ( ;   \n         lastItemIndex < ValueInternalLink::itemPerLink; \n         ++lastItemIndex ) // may be optimized with dicotomic search\n   {\n      if ( lastLink->items_[lastItemIndex].isItemAvailable() )\n         break;\n   }\n   \n   BucketIndex lastUsedIndex = lastItemIndex - 1;\n   Value *valueToDelete = &link->items_[index];\n   Value *valueToPreserve = &lastLink->items_[lastUsedIndex];\n   if ( valueToDelete != valueToPreserve )\n      valueToDelete->swap( *valueToPreserve );\n   if ( lastUsedIndex == 0 )  // page is now empty\n   {  // remove it from bucket linked list and delete it.\n      ValueInternalLink *linkPreviousToLast = lastLink->previous_;\n      if ( linkPreviousToLast != 0 )   // can not deleted bucket link.\n      {\n         mapAllocator()->releaseMapLink( lastLink );\n         linkPreviousToLast->next_ = 0;\n         lastLink = linkPreviousToLast;\n      }\n   }\n   else\n   {\n      Value dummy;\n      valueToPreserve->swap( dummy ); // restore deleted to default Value.\n      valueToPreserve->setItemUsed( false );\n   }\n   --itemCount_;\n}\n\n\nValueInternalLink *&\nValueInternalMap::getLastLinkInBucket( BucketIndex bucketIndex )\n{\n   if ( bucketIndex == bucketsSize_ - 1 )\n      return tailLink_;\n   ValueInternalLink *&previous = buckets_[bucketIndex+1].previous_;\n   if ( !previous )\n      previous = &buckets_[bucketIndex];\n   return previous;\n}\n\n\nValue &\nValueInternalMap::setNewItem( const char *key, \n                              bool isStatic,\n                              ValueInternalLink *link, \n                              BucketIndex index )\n{\n   char *duplicatedKey = makeMemberName( key );\n   ++itemCount_;\n   link->keys_[index] = duplicatedKey;\n   link->items_[index].setItemUsed();\n   link->items_[index].setMemberNameIsStatic( isStatic );\n   return link->items_[index]; // items already default constructed.\n}\n\n\nValue &\nValueInternalMap::unsafeAdd( const char *key, \n                             bool isStatic, \n                             HashKey hashedKey )\n{\n   JSON_ASSERT_MESSAGE( bucketsSize_ > 0, \"ValueInternalMap::unsafeAdd(): internal logic error.\" );\n   BucketIndex bucketIndex = hashedKey % bucketsSize_;\n   ValueInternalLink *&previousLink = getLastLinkInBucket( bucketIndex );\n   ValueInternalLink *link = previousLink;\n   BucketIndex index;\n   for ( index =0; index < ValueInternalLink::itemPerLink; ++index )\n   {\n      if ( link->items_[index].isItemAvailable() )\n         break;\n   }\n   if ( index == ValueInternalLink::itemPerLink ) // need to add a new page\n   {\n      ValueInternalLink *newLink = mapAllocator()->allocateMapLink();\n      index = 0;\n      link->next_ = newLink;\n      previousLink = newLink;\n      link = newLink;\n   }\n   return setNewItem( key, isStatic, link, index );\n}\n\n\nValueInternalMap::HashKey \nValueInternalMap::hash( const char *key ) const\n{\n   HashKey hash = 0;\n   while ( *key )\n      hash += *key++ * 37;\n   return hash;\n}\n\n\nint \nValueInternalMap::compare( const ValueInternalMap &other ) const\n{\n   int sizeDiff( itemCount_ - other.itemCount_ );\n   if ( sizeDiff != 0 )\n      return sizeDiff;\n   // Strict order guaranty is required. Compare all keys FIRST, then compare values.\n   IteratorState it;\n   IteratorState itEnd;\n   makeBeginIterator( it );\n   makeEndIterator( itEnd );\n   for ( ; !equals(it,itEnd); increment(it) )\n   {\n      if ( !other.find( key( it ) ) )\n         return 1;\n   }\n\n   // All keys are equals, let's compare values\n   makeBeginIterator( it );\n   for ( ; !equals(it,itEnd); increment(it) )\n   {\n      const Value *otherValue = other.find( key( it ) );\n      int valueDiff = value(it).compare( *otherValue );\n      if ( valueDiff != 0 )\n         return valueDiff;\n   }\n   return 0;\n}\n\n\nvoid \nValueInternalMap::makeBeginIterator( IteratorState &it ) const\n{\n   it.map_ = const_cast<ValueInternalMap *>( this );\n   it.bucketIndex_ = 0;\n   it.itemIndex_ = 0;\n   it.link_ = buckets_;\n}\n\n\nvoid \nValueInternalMap::makeEndIterator( IteratorState &it ) const\n{\n   it.map_ = const_cast<ValueInternalMap *>( this );\n   it.bucketIndex_ = bucketsSize_;\n   it.itemIndex_ = 0;\n   it.link_ = 0;\n}\n\n\nbool \nValueInternalMap::equals( const IteratorState &x, const IteratorState &other )\n{\n   return x.map_ == other.map_  \n          &&  x.bucketIndex_ == other.bucketIndex_  \n          &&  x.link_ == other.link_\n          &&  x.itemIndex_ == other.itemIndex_;\n}\n\n\nvoid \nValueInternalMap::incrementBucket( IteratorState &iterator )\n{\n   ++iterator.bucketIndex_;\n   JSON_ASSERT_MESSAGE( iterator.bucketIndex_ <= iterator.map_->bucketsSize_,\n      \"ValueInternalMap::increment(): attempting to iterate beyond end.\" );\n   if ( iterator.bucketIndex_ == iterator.map_->bucketsSize_ )\n      iterator.link_ = 0;\n   else\n      iterator.link_ = &(iterator.map_->buckets_[iterator.bucketIndex_]);\n   iterator.itemIndex_ = 0;\n}\n\n\nvoid \nValueInternalMap::increment( IteratorState &iterator )\n{\n   JSON_ASSERT_MESSAGE( iterator.map_, \"Attempting to iterator using invalid iterator.\" );\n   ++iterator.itemIndex_;\n   if ( iterator.itemIndex_ == ValueInternalLink::itemPerLink )\n   {\n      JSON_ASSERT_MESSAGE( iterator.link_ != 0,\n         \"ValueInternalMap::increment(): attempting to iterate beyond end.\" );\n      iterator.link_ = iterator.link_->next_;\n      if ( iterator.link_ == 0 )\n         incrementBucket( iterator );\n   }\n   else if ( iterator.link_->items_[iterator.itemIndex_].isItemAvailable() )\n   {\n      incrementBucket( iterator );\n   }\n}\n\n\nvoid \nValueInternalMap::decrement( IteratorState &iterator )\n{\n   if ( iterator.itemIndex_ == 0 )\n   {\n      JSON_ASSERT_MESSAGE( iterator.map_, \"Attempting to iterate using invalid iterator.\" );\n      if ( iterator.link_ == &iterator.map_->buckets_[iterator.bucketIndex_] )\n      {\n         JSON_ASSERT_MESSAGE( iterator.bucketIndex_ > 0, \"Attempting to iterate beyond beginning.\" );\n         --(iterator.bucketIndex_);\n      }\n      iterator.link_ = iterator.link_->previous_;\n      iterator.itemIndex_ = ValueInternalLink::itemPerLink - 1;\n   }\n}\n\n\nconst char *\nValueInternalMap::key( const IteratorState &iterator )\n{\n   JSON_ASSERT_MESSAGE( iterator.link_, \"Attempting to iterate using invalid iterator.\" );\n   return iterator.link_->keys_[iterator.itemIndex_];\n}\n\nconst char *\nValueInternalMap::key( const IteratorState &iterator, bool &isStatic )\n{\n   JSON_ASSERT_MESSAGE( iterator.link_, \"Attempting to iterate using invalid iterator.\" );\n   isStatic = iterator.link_->items_[iterator.itemIndex_].isMemberNameStatic();\n   return iterator.link_->keys_[iterator.itemIndex_];\n}\n\n\nValue &\nValueInternalMap::value( const IteratorState &iterator )\n{\n   JSON_ASSERT_MESSAGE( iterator.link_, \"Attempting to iterate using invalid iterator.\" );\n   return iterator.link_->items_[iterator.itemIndex_];\n}\n\n\nint \nValueInternalMap::distance( const IteratorState &x, const IteratorState &y )\n{\n   int offset = 0;\n   IteratorState it = x;\n   while ( !equals( it, y ) )\n      increment( it );\n   return offset;\n}\n\n} // namespace Json\n// vim: et ts=3 sts=3 sw=3 tw=0\n"
  },
  {
    "path": "Libraries/Core/Android/Headers/json/json_tool.h",
    "content": "// Copyright 2007-2010 Baptiste Lepilleur\n// Distributed under MIT license, or public domain if desired and\n// recognized in your jurisdiction.\n// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE\n\n#ifndef LIB_JSONCPP_JSON_TOOL_H_INCLUDED\n#define LIB_JSONCPP_JSON_TOOL_H_INCLUDED\n\n/* This header provides common string manipulation support, such as UTF-8,\n * portable conversion from/to string...\n *\n * It is an internal header that must not be exposed.\n */\n\nnamespace Json {\n\n/// Converts a unicode code-point to UTF-8.\nstatic inline std::string codePointToUTF8(unsigned int cp) {\n  std::string result;\n\n  // based on description from http://en.wikipedia.org/wiki/UTF-8\n\n  if (cp <= 0x7f) {\n    result.resize(1);\n    result[0] = static_cast<char>(cp);\n  } else if (cp <= 0x7FF) {\n    result.resize(2);\n    result[1] = static_cast<char>(0x80 | (0x3f & cp));\n    result[0] = static_cast<char>(0xC0 | (0x1f & (cp >> 6)));\n  } else if (cp <= 0xFFFF) {\n    result.resize(3);\n    result[2] = static_cast<char>(0x80 | (0x3f & cp));\n    result[1] = 0x80 | static_cast<char>((0x3f & (cp >> 6)));\n    result[0] = 0xE0 | static_cast<char>((0xf & (cp >> 12)));\n  } else if (cp <= 0x10FFFF) {\n    result.resize(4);\n    result[3] = static_cast<char>(0x80 | (0x3f & cp));\n    result[2] = static_cast<char>(0x80 | (0x3f & (cp >> 6)));\n    result[1] = static_cast<char>(0x80 | (0x3f & (cp >> 12)));\n    result[0] = static_cast<char>(0xF0 | (0x7 & (cp >> 18)));\n  }\n\n  return result;\n}\n\n/// Returns true if ch is a control character (in range [0,32[).\nstatic inline bool isControlCharacter(char ch) { return ch > 0 && ch <= 0x1F; }\n\nenum {\n  /// Constant that specify the size of the buffer that must be passed to\n  /// uintToString.\n  uintToStringBufferSize = 3 * sizeof(LargestUInt) + 1\n};\n\n// Defines a char buffer for use with uintToString().\ntypedef char UIntToStringBuffer[uintToStringBufferSize];\n\n/** Converts an unsigned integer to string.\n * @param value Unsigned interger to convert to string\n * @param current Input/Output string buffer.\n *        Must have at least uintToStringBufferSize chars free.\n */\nstatic inline void uintToString(LargestUInt value, char *&current) {\n  *--current = 0;\n  do {\n    *--current = char(value % 10) + '0';\n    value /= 10;\n  } while (value != 0);\n}\n\n/** Change ',' to '.' everywhere in buffer.\n *\n * We had a sophisticated way, but it did not work in WinCE.\n * @see https://github.com/open-source-parsers/jsoncpp/pull/9\n */\nstatic inline void fixNumericLocale(char* begin, char* end) {\n  while (begin < end) {\n    if (*begin == ',') {\n      *begin = '.';\n    }\n    ++begin;\n  }\n}\n\n} // namespace Json {\n\n#endif // LIB_JSONCPP_JSON_TOOL_H_INCLUDED\n// vim: et ts=2 sts=2 sw=2 tw=0\n"
  },
  {
    "path": "Libraries/Core/Android/Headers/json/json_valueiterator.inl",
    "content": "// Copyright 2007-2010 Baptiste Lepilleur\n// Distributed under MIT license, or public domain if desired and\n// recognized in your jurisdiction.\n// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE\n\n// included by json_value.cpp\n\nnamespace Json {\n\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// class ValueIteratorBase\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n\nValueIteratorBase::ValueIteratorBase()\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\n   : current_()\n   , isNull_( true )\n{\n}\n#else\n   : isArray_( true )\n   , isNull_( true )\n{\n   iterator_.array_ = ValueInternalArray::IteratorState();\n}\n#endif\n\n\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\nValueIteratorBase::ValueIteratorBase( const Value::ObjectValues::iterator &current )\n   : current_( current )\n   , isNull_( false )\n{\n}\n#else\nValueIteratorBase::ValueIteratorBase( const ValueInternalArray::IteratorState &state )\n   : isArray_( true )\n{\n   iterator_.array_ = state;\n}\n\n\nValueIteratorBase::ValueIteratorBase( const ValueInternalMap::IteratorState &state )\n   : isArray_( false )\n{\n   iterator_.map_ = state;\n}\n#endif\n\nValue &\nValueIteratorBase::deref() const\n{\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\n   return current_->second;\n#else\n   if ( isArray_ )\n      return ValueInternalArray::dereference( iterator_.array_ );\n   return ValueInternalMap::value( iterator_.map_ );\n#endif\n}\n\n\nvoid \nValueIteratorBase::increment()\n{\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\n   ++current_;\n#else\n   if ( isArray_ )\n      ValueInternalArray::increment( iterator_.array_ );\n   ValueInternalMap::increment( iterator_.map_ );\n#endif\n}\n\n\nvoid \nValueIteratorBase::decrement()\n{\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\n   --current_;\n#else\n   if ( isArray_ )\n      ValueInternalArray::decrement( iterator_.array_ );\n   ValueInternalMap::decrement( iterator_.map_ );\n#endif\n}\n\n\nValueIteratorBase::difference_type \nValueIteratorBase::computeDistance( const SelfType &other ) const\n{\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\n# ifdef JSON_USE_CPPTL_SMALLMAP\n   return current_ - other.current_;\n# else\n   // Iterator for null value are initialized using the default\n   // constructor, which initialize current_ to the default\n   // std::map::iterator. As begin() and end() are two instance \n   // of the default std::map::iterator, they can not be compared.\n   // To allow this, we handle this comparison specifically.\n   if ( isNull_  &&  other.isNull_ )\n   {\n      return 0;\n   }\n\n\n   // Usage of std::distance is not portable (does not compile with Sun Studio 12 RogueWave STL,\n   // which is the one used by default).\n   // Using a portable hand-made version for non random iterator instead:\n   //   return difference_type( std::distance( current_, other.current_ ) );\n   difference_type myDistance = 0;\n   for ( Value::ObjectValues::iterator it = current_; it != other.current_; ++it )\n   {\n      ++myDistance;\n   }\n   return myDistance;\n# endif\n#else\n   if ( isArray_ )\n      return ValueInternalArray::distance( iterator_.array_, other.iterator_.array_ );\n   return ValueInternalMap::distance( iterator_.map_, other.iterator_.map_ );\n#endif\n}\n\n\nbool \nValueIteratorBase::isEqual( const SelfType &other ) const\n{\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\n   if ( isNull_ )\n   {\n      return other.isNull_;\n   }\n   return current_ == other.current_;\n#else\n   if ( isArray_ )\n      return ValueInternalArray::equals( iterator_.array_, other.iterator_.array_ );\n   return ValueInternalMap::equals( iterator_.map_, other.iterator_.map_ );\n#endif\n}\n\n\nvoid \nValueIteratorBase::copy( const SelfType &other )\n{\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\n   current_ = other.current_;\n   isNull_ = other.isNull_;\n#else\n   if ( isArray_ )\n      iterator_.array_ = other.iterator_.array_;\n   iterator_.map_ = other.iterator_.map_;\n#endif\n}\n\n\nValue \nValueIteratorBase::key() const\n{\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\n   const Value::CZString czstring = (*current_).first;\n   if ( czstring.c_str() )\n   {\n      if ( czstring.isStaticString() )\n         return Value( StaticString( czstring.c_str() ) );\n      return Value( czstring.c_str() );\n   }\n   return Value( czstring.index() );\n#else\n   if ( isArray_ )\n      return Value( ValueInternalArray::indexOf( iterator_.array_ ) );\n   bool isStatic;\n   const char *memberName = ValueInternalMap::key( iterator_.map_, isStatic );\n   if ( isStatic )\n      return Value( StaticString( memberName ) );\n   return Value( memberName );\n#endif\n}\n\n\nUInt \nValueIteratorBase::index() const\n{\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\n   const Value::CZString czstring = (*current_).first;\n   if ( !czstring.c_str() )\n      return czstring.index();\n   return Value::UInt( -1 );\n#else\n   if ( isArray_ )\n      return Value::UInt( ValueInternalArray::indexOf( iterator_.array_ ) );\n   return Value::UInt( -1 );\n#endif\n}\n\n\nconst char *\nValueIteratorBase::memberName() const\n{\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\n   const char *name = (*current_).first.c_str();\n   return name ? name : \"\";\n#else\n   if ( !isArray_ )\n      return ValueInternalMap::key( iterator_.map_ );\n   return \"\";\n#endif\n}\n\n\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// class ValueConstIterator\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n\nValueConstIterator::ValueConstIterator()\n{\n}\n\n\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\nValueConstIterator::ValueConstIterator( const Value::ObjectValues::iterator &current )\n   : ValueIteratorBase( current )\n{\n}\n#else\nValueConstIterator::ValueConstIterator( const ValueInternalArray::IteratorState &state )\n   : ValueIteratorBase( state )\n{\n}\n\nValueConstIterator::ValueConstIterator( const ValueInternalMap::IteratorState &state )\n   : ValueIteratorBase( state )\n{\n}\n#endif\n\nValueConstIterator &\nValueConstIterator::operator =( const ValueIteratorBase &other )\n{\n   copy( other );\n   return *this;\n}\n\n\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// class ValueIterator\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n\nValueIterator::ValueIterator()\n{\n}\n\n\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\nValueIterator::ValueIterator( const Value::ObjectValues::iterator &current )\n   : ValueIteratorBase( current )\n{\n}\n#else\nValueIterator::ValueIterator( const ValueInternalArray::IteratorState &state )\n   : ValueIteratorBase( state )\n{\n}\n\nValueIterator::ValueIterator( const ValueInternalMap::IteratorState &state )\n   : ValueIteratorBase( state )\n{\n}\n#endif\n\nValueIterator::ValueIterator( const ValueConstIterator &other )\n   : ValueIteratorBase( other )\n{\n}\n\nValueIterator::ValueIterator( const ValueIterator &other )\n   : ValueIteratorBase( other )\n{\n}\n\nValueIterator &\nValueIterator::operator =( const SelfType &other )\n{\n   copy( other );\n   return *this;\n}\n\n} // namespace Json\n// vim: et ts=3 sts=3 sw=3 tw=0\n"
  },
  {
    "path": "Libraries/Core/Android/Headers/json/reader.h",
    "content": "// Copyright 2007-2010 Baptiste Lepilleur\n// Distributed under MIT license, or public domain if desired and\n// recognized in your jurisdiction.\n// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE\n\n#ifndef CPPTL_JSON_READER_H_INCLUDED\n#define CPPTL_JSON_READER_H_INCLUDED\n\n#if !defined(JSON_IS_AMALGAMATION)\n#include \"features.h\"\n#include \"value.h\"\n#endif // if !defined(JSON_IS_AMALGAMATION)\n#include <deque>\n#include <iosfwd>\n#include <stack>\n#include <string>\n\n// Disable warning C4251: <data member>: <type> needs to have dll-interface to\n// be used by...\n#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)\n#pragma warning(push)\n#pragma warning(disable : 4251)\n#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)\n\nnamespace Json {\n\n/** \\brief Unserialize a <a HREF=\"http://www.json.org\">JSON</a> document into a\n *Value.\n *\n */\nclass JSON_API Reader {\npublic:\n  typedef char Char;\n  typedef const Char *Location;\n\n  /** \\brief An error tagged with where in the JSON text it was encountered.\n   *\n   * The offsets give the [start, limit) range of bytes within the text. Note\n   * that this is bytes, not codepoints.\n   *\n   */\n  struct StructuredError {\n    size_t offset_start;\n    size_t offset_limit;\n    std::string message;\n  };\n\n  /** \\brief Constructs a Reader allowing all features\n   * for parsing.\n   */\n  Reader();\n\n  /** \\brief Constructs a Reader allowing the specified feature set\n   * for parsing.\n   */\n  Reader(const Features &features);\n\n  /** \\brief Read a Value from a <a HREF=\"http://www.json.org\">JSON</a>\n   * document.\n   * \\param document UTF-8 encoded string containing the document to read.\n   * \\param root [out] Contains the root value of the document if it was\n   *             successfully parsed.\n   * \\param collectComments \\c true to collect comment and allow writing them\n   * back during\n   *                        serialization, \\c false to discard comments.\n   *                        This parameter is ignored if\n   * Features::allowComments_\n   *                        is \\c false.\n   * \\return \\c true if the document was successfully parsed, \\c false if an\n   * error occurred.\n   */\n  bool\n  parse(const std::string &document, Value &root, bool collectComments = true);\n\n  /** \\brief Read a Value from a <a HREF=\"http://www.json.org\">JSON</a>\n   document.\n   * \\param beginDoc Pointer on the beginning of the UTF-8 encoded string of the\n   document to read.\n   * \\param endDoc Pointer on the end of the UTF-8 encoded string of the\n   document to read.\n   \\               Must be >= beginDoc.\n   * \\param root [out] Contains the root value of the document if it was\n   *             successfully parsed.\n   * \\param collectComments \\c true to collect comment and allow writing them\n   back during\n   *                        serialization, \\c false to discard comments.\n   *                        This parameter is ignored if\n   Features::allowComments_\n   *                        is \\c false.\n   * \\return \\c true if the document was successfully parsed, \\c false if an\n   error occurred.\n   */\n  bool parse(const char *beginDoc,\n             const char *endDoc,\n             Value &root,\n             bool collectComments = true);\n\n  /// \\brief Parse from input stream.\n  /// \\see Json::operator>>(std::istream&, Json::Value&).\n  bool parse(std::istream &is, Value &root, bool collectComments = true);\n\n  /** \\brief Returns a user friendly string that list errors in the parsed\n   * document.\n   * \\return Formatted error message with the list of errors with their location\n   * in\n   *         the parsed document. An empty string is returned if no error\n   * occurred\n   *         during parsing.\n   * \\deprecated Use getFormattedErrorMessages() instead (typo fix).\n   */\n  JSONCPP_DEPRECATED(\"Use getFormattedErrorMessages instead\")\n  std::string getFormatedErrorMessages() const;\n\n  /** \\brief Returns a user friendly string that list errors in the parsed\n   * document.\n   * \\return Formatted error message with the list of errors with their location\n   * in\n   *         the parsed document. An empty string is returned if no error\n   * occurred\n   *         during parsing.\n   */\n  std::string getFormattedErrorMessages() const;\n\n  /** \\brief Returns a vector of structured erros encounted while parsing.\n   * \\return A (possibly empty) vector of StructuredError objects. Currently\n   *         only one error can be returned, but the caller should tolerate\n   * multiple\n   *         errors.  This can occur if the parser recovers from a non-fatal\n   *         parse error and then encounters additional errors.\n   */\n  std::vector<StructuredError> getStructuredErrors() const;\n\nprivate:\n  enum TokenType {\n    tokenEndOfStream = 0,\n    tokenObjectBegin,\n    tokenObjectEnd,\n    tokenArrayBegin,\n    tokenArrayEnd,\n    tokenString,\n    tokenNumber,\n    tokenTrue,\n    tokenFalse,\n    tokenNull,\n    tokenArraySeparator,\n    tokenMemberSeparator,\n    tokenComment,\n    tokenError\n  };\n\n  class Token {\n  public:\n    TokenType type_;\n    Location start_;\n    Location end_;\n  };\n\n  class ErrorInfo {\n  public:\n    Token token_;\n    std::string message_;\n    Location extra_;\n  };\n\n  typedef std::deque<ErrorInfo> Errors;\n\n  bool expectToken(TokenType type, Token &token, const char *message);\n  bool readToken(Token &token);\n  void skipSpaces();\n  bool match(Location pattern, int patternLength);\n  bool readComment();\n  bool readCStyleComment();\n  bool readCppStyleComment();\n  bool readString();\n  void readNumber();\n  bool readValue();\n  bool readObject(Token &token);\n  bool readArray(Token &token);\n  bool decodeNumber(Token &token);\n  bool decodeNumber(Token &token, Value &decoded);\n  bool decodeString(Token &token);\n  bool decodeString(Token &token, std::string &decoded);\n  bool decodeDouble(Token &token);\n  bool decodeDouble(Token &token, Value &decoded);\n  bool decodeUnicodeCodePoint(Token &token,\n                              Location &current,\n                              Location end,\n                              unsigned int &unicode);\n  bool decodeUnicodeEscapeSequence(Token &token,\n                                   Location &current,\n                                   Location end,\n                                   unsigned int &unicode);\n  bool addError(const std::string &message, Token &token, Location extra = 0);\n  bool recoverFromError(TokenType skipUntilToken);\n  bool addErrorAndRecover(const std::string &message,\n                          Token &token,\n                          TokenType skipUntilToken);\n  void skipUntilSpace();\n  Value &currentValue();\n  Char getNextChar();\n  void\n  getLocationLineAndColumn(Location location, int &line, int &column) const;\n  std::string getLocationLineAndColumn(Location location) const;\n  void addComment(Location begin, Location end, CommentPlacement placement);\n  void skipCommentTokens(Token &token);\n\n  typedef std::stack<Value *> Nodes;\n  Nodes nodes_;\n  Errors errors_;\n  std::string document_;\n  Location begin_;\n  Location end_;\n  Location current_;\n  Location lastValueEnd_;\n  Value *lastValue_;\n  std::string commentsBefore_;\n  Features features_;\n  bool collectComments_;\n};\n\n/** \\brief Read from 'sin' into 'root'.\n\n Always keep comments from the input JSON.\n\n This can be used to read a file into a particular sub-object.\n For example:\n \\code\n Json::Value root;\n cin >> root[\"dir\"][\"file\"];\n cout << root;\n \\endcode\n Result:\n \\verbatim\n {\n \"dir\": {\n     \"file\": {\n     // The input stream JSON would be nested here.\n     }\n }\n }\n \\endverbatim\n \\throw std::exception on parse error.\n \\see Json::operator<<()\n*/\nJSON_API std::istream &operator>>(std::istream &, Value &);\n\n} // namespace Json\n\n#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)\n#pragma warning(pop)\n#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)\n\n#endif // CPPTL_JSON_READER_H_INCLUDED\n"
  },
  {
    "path": "Libraries/Core/Android/Headers/json/value.h",
    "content": "// Copyright 2007-2010 Baptiste Lepilleur\n// Distributed under MIT license, or public domain if desired and\n// recognized in your jurisdiction.\n// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE\n\n#ifndef CPPTL_JSON_H_INCLUDED\n#define CPPTL_JSON_H_INCLUDED\n\n#if !defined(JSON_IS_AMALGAMATION)\n#include \"forwards.h\"\n#endif // if !defined(JSON_IS_AMALGAMATION)\n#include <string>\n#include <vector>\n\n#ifndef JSON_USE_CPPTL_SMALLMAP\n#include <map>\n#else\n#include <cpptl/smallmap.h>\n#endif\n#ifdef JSON_USE_CPPTL\n#include <cpptl/forwards.h>\n#endif\n\n// Disable warning C4251: <data member>: <type> needs to have dll-interface to\n// be used by...\n#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)\n#pragma warning(push)\n#pragma warning(disable : 4251)\n#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)\n\n/** \\brief JSON (JavaScript Object Notation).\n */\nnamespace Json {\n\n/** \\brief Type of the value held by a Value object.\n */\nenum ValueType {\n  nullValue = 0, ///< 'null' value\n  intValue,      ///< signed integer value\n  uintValue,     ///< unsigned integer value\n  realValue,     ///< double value\n  stringValue,   ///< UTF-8 string value\n  booleanValue,  ///< bool value\n  arrayValue,    ///< array value (ordered list)\n  objectValue    ///< object value (collection of name/value pairs).\n};\n\nenum CommentPlacement {\n  commentBefore = 0,      ///< a comment placed on the line before a value\n  commentAfterOnSameLine, ///< a comment just after a value on the same line\n  commentAfter, ///< a comment on the line after a value (only make sense for\n  /// root value)\n  numberOfCommentPlacement\n};\n\n//# ifdef JSON_USE_CPPTL\n//   typedef CppTL::AnyEnumerator<const char *> EnumMemberNames;\n//   typedef CppTL::AnyEnumerator<const Value &> EnumValues;\n//# endif\n\n/** \\brief Lightweight wrapper to tag static string.\n *\n * Value constructor and objectValue member assignement takes advantage of the\n * StaticString and avoid the cost of string duplication when storing the\n * string or the member name.\n *\n * Example of usage:\n * \\code\n * Json::Value aValue( StaticString(\"some text\") );\n * Json::Value object;\n * static const StaticString code(\"code\");\n * object[code] = 1234;\n * \\endcode\n */\nclass JSON_API StaticString {\npublic:\n  explicit StaticString(const char *czstring) : str_(czstring) {}\n\n  operator const char *() const { return str_; }\n\n  const char *c_str() const { return str_; }\n\nprivate:\n  const char *str_;\n};\n\n/** \\brief Represents a <a HREF=\"http://www.json.org\">JSON</a> value.\n *\n * This class is a discriminated union wrapper that can represents a:\n * - signed integer [range: Value::minInt - Value::maxInt]\n * - unsigned integer (range: 0 - Value::maxUInt)\n * - double\n * - UTF-8 string\n * - boolean\n * - 'null'\n * - an ordered list of Value\n * - collection of name/value pairs (javascript object)\n *\n * The type of the held value is represented by a #ValueType and\n * can be obtained using type().\n *\n * values of an #objectValue or #arrayValue can be accessed using operator[]()\n *methods.\n * Non const methods will automatically create the a #nullValue element\n * if it does not exist.\n * The sequence of an #arrayValue will be automatically resize and initialized\n * with #nullValue. resize() can be used to enlarge or truncate an #arrayValue.\n *\n * The get() methods can be used to obtanis default value in the case the\n *required element\n * does not exist.\n *\n * It is possible to iterate over the list of a #objectValue values using\n * the getMemberNames() method.\n */\nclass JSON_API Value {\n  friend class ValueIteratorBase;\n#ifdef JSON_VALUE_USE_INTERNAL_MAP\n  friend class ValueInternalLink;\n  friend class ValueInternalMap;\n#endif\npublic:\n  typedef std::vector<std::string> Members;\n  typedef ValueIterator iterator;\n  typedef ValueConstIterator const_iterator;\n  typedef Json::UInt UInt;\n  typedef Json::Int Int;\n#if defined(JSON_HAS_INT64)\n  typedef Json::UInt64 UInt64;\n  typedef Json::Int64 Int64;\n#endif // defined(JSON_HAS_INT64)\n  typedef Json::LargestInt LargestInt;\n  typedef Json::LargestUInt LargestUInt;\n  typedef Json::ArrayIndex ArrayIndex;\n\n  static const Value& null;\n  /// Minimum signed integer value that can be stored in a Json::Value.\n  static const LargestInt minLargestInt;\n  /// Maximum signed integer value that can be stored in a Json::Value.\n  static const LargestInt maxLargestInt;\n  /// Maximum unsigned integer value that can be stored in a Json::Value.\n  static const LargestUInt maxLargestUInt;\n\n  /// Minimum signed int value that can be stored in a Json::Value.\n  static const Int minInt;\n  /// Maximum signed int value that can be stored in a Json::Value.\n  static const Int maxInt;\n  /// Maximum unsigned int value that can be stored in a Json::Value.\n  static const UInt maxUInt;\n\n#if defined(JSON_HAS_INT64)\n  /// Minimum signed 64 bits int value that can be stored in a Json::Value.\n  static const Int64 minInt64;\n  /// Maximum signed 64 bits int value that can be stored in a Json::Value.\n  static const Int64 maxInt64;\n  /// Maximum unsigned 64 bits int value that can be stored in a Json::Value.\n  static const UInt64 maxUInt64;\n#endif // defined(JSON_HAS_INT64)\n\nprivate:\n#ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\n  class CZString {\n  public:\n    enum DuplicationPolicy {\n      noDuplication = 0,\n      duplicate,\n      duplicateOnCopy\n    };\n    CZString(ArrayIndex index);\n    CZString(const char *cstr, DuplicationPolicy allocate);\n    CZString(const CZString &other);\n    ~CZString();\n    CZString &operator=(CZString other);\n    bool operator<(const CZString &other) const;\n    bool operator==(const CZString &other) const;\n    ArrayIndex index() const;\n    const char *c_str() const;\n    bool isStaticString() const;\n\n  private:\n    void swap(CZString &other);\n    const char *cstr_;\n    ArrayIndex index_;\n  };\n\npublic:\n#ifndef JSON_USE_CPPTL_SMALLMAP\n  typedef std::map<CZString, Value> ObjectValues;\n#else\n  typedef CppTL::SmallMap<CZString, Value> ObjectValues;\n#endif // ifndef JSON_USE_CPPTL_SMALLMAP\n#endif // ifndef JSON_VALUE_USE_INTERNAL_MAP\n#endif // ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION\n\npublic:\n  /** \\brief Create a default Value of the given type.\n\n    This is a very useful constructor.\n    To create an empty array, pass arrayValue.\n    To create an empty object, pass objectValue.\n    Another Value can then be set to this one by assignment.\nThis is useful since clear() and resize() will not alter types.\n\n    Examples:\n\\code\nJson::Value null_value; // null\nJson::Value arr_value(Json::arrayValue); // []\nJson::Value obj_value(Json::objectValue); // {}\n\\endcode\n  */\n  Value(ValueType type = nullValue);\n  Value(Int value);\n  Value(UInt value);\n#if defined(JSON_HAS_INT64)\n  Value(Int64 value);\n  Value(UInt64 value);\n#endif // if defined(JSON_HAS_INT64)\n  Value(double value);\n  Value(const char *value);\n  Value(const char *beginValue, const char *endValue);\n  /** \\brief Constructs a value from a static string.\n\n   * Like other value string constructor but do not duplicate the string for\n   * internal storage. The given string must remain alive after the call to this\n   * constructor.\n   * Example of usage:\n   * \\code\n   * Json::Value aValue( StaticString(\"some text\") );\n   * \\endcode\n   */\n  Value(const StaticString &value);\n  Value(const std::string &value);\n#ifdef JSON_USE_CPPTL\n  Value(const CppTL::ConstString &value);\n#endif\n  Value(bool value);\n  Value(const Value &other);\n  ~Value();\n\n  Value &operator=(Value other);\n  /// Swap values.\n  /// \\note Currently, comments are intentionally not swapped, for\n  /// both logic and efficiency.\n  void swap(Value &other);\n\n  ValueType type() const;\n\n  bool operator<(const Value &other) const;\n  bool operator<=(const Value &other) const;\n  bool operator>=(const Value &other) const;\n  bool operator>(const Value &other) const;\n\n  bool operator==(const Value &other) const;\n  bool operator!=(const Value &other) const;\n\n  int compare(const Value &other) const;\n\n  const char *asCString() const;\n  std::string asString() const;\n#ifdef JSON_USE_CPPTL\n  CppTL::ConstString asConstString() const;\n#endif\n  Int asInt() const;\n  UInt asUInt() const;\n#if defined(JSON_HAS_INT64)\n  Int64 asInt64() const;\n  UInt64 asUInt64() const;\n#endif // if defined(JSON_HAS_INT64)\n  LargestInt asLargestInt() const;\n  LargestUInt asLargestUInt() const;\n  float asFloat() const;\n  double asDouble() const;\n  bool asBool() const;\n\n  bool isNull() const;\n  bool isBool() const;\n  bool isInt() const;\n  bool isInt64() const;\n  bool isUInt() const;\n  bool isUInt64() const;\n  bool isIntegral() const;\n  bool isDouble() const;\n  bool isNumeric() const;\n  bool isString() const;\n  bool isArray() const;\n  bool isObject() const;\n\n  bool isConvertibleTo(ValueType other) const;\n\n  /// Number of values in array or object\n  ArrayIndex size() const;\n\n  /// \\brief Return true if empty array, empty object, or null;\n  /// otherwise, false.\n  bool empty() const;\n\n  /// Return isNull()\n  bool operator!() const;\n\n  /// Remove all object members and array elements.\n  /// \\pre type() is arrayValue, objectValue, or nullValue\n  /// \\post type() is unchanged\n  void clear();\n\n  /// Resize the array to size elements.\n  /// New elements are initialized to null.\n  /// May only be called on nullValue or arrayValue.\n  /// \\pre type() is arrayValue or nullValue\n  /// \\post type() is arrayValue\n  void resize(ArrayIndex size);\n\n  /// Access an array element (zero based index ).\n  /// If the array contains less than index element, then null value are\n  /// inserted\n  /// in the array so that its size is index+1.\n  /// (You may need to say 'value[0u]' to get your compiler to distinguish\n  ///  this from the operator[] which takes a string.)\n  Value &operator[](ArrayIndex index);\n\n  /// Access an array element (zero based index ).\n  /// If the array contains less than index element, then null value are\n  /// inserted\n  /// in the array so that its size is index+1.\n  /// (You may need to say 'value[0u]' to get your compiler to distinguish\n  ///  this from the operator[] which takes a string.)\n  Value &operator[](int index);\n\n  /// Access an array element (zero based index )\n  /// (You may need to say 'value[0u]' to get your compiler to distinguish\n  ///  this from the operator[] which takes a string.)\n  const Value &operator[](ArrayIndex index) const;\n\n  /// Access an array element (zero based index )\n  /// (You may need to say 'value[0u]' to get your compiler to distinguish\n  ///  this from the operator[] which takes a string.)\n  const Value &operator[](int index) const;\n\n  /// If the array contains at least index+1 elements, returns the element\n  /// value,\n  /// otherwise returns defaultValue.\n  Value get(ArrayIndex index, const Value &defaultValue) const;\n  /// Return true if index < size().\n  bool isValidIndex(ArrayIndex index) const;\n  /// \\brief Append value to array at the end.\n  ///\n  /// Equivalent to jsonvalue[jsonvalue.size()] = value;\n  Value &append(const Value &value);\n\n  /// Access an object value by name, create a null member if it does not exist.\n  Value &operator[](const char *key);\n  /// Access an object value by name, returns null if there is no member with\n  /// that name.\n  const Value &operator[](const char *key) const;\n  /// Access an object value by name, create a null member if it does not exist.\n  Value &operator[](const std::string &key);\n  /// Access an object value by name, returns null if there is no member with\n  /// that name.\n  const Value &operator[](const std::string &key) const;\n  /** \\brief Access an object value by name, create a null member if it does not\n   exist.\n\n   * If the object as no entry for that name, then the member name used to store\n   * the new entry is not duplicated.\n   * Example of use:\n   * \\code\n   * Json::Value object;\n   * static const StaticString code(\"code\");\n   * object[code] = 1234;\n   * \\endcode\n   */\n  Value &operator[](const StaticString &key);\n#ifdef JSON_USE_CPPTL\n  /// Access an object value by name, create a null member if it does not exist.\n  Value &operator[](const CppTL::ConstString &key);\n  /// Access an object value by name, returns null if there is no member with\n  /// that name.\n  const Value &operator[](const CppTL::ConstString &key) const;\n#endif\n  /// Return the member named key if it exist, defaultValue otherwise.\n  Value get(const char *key, const Value &defaultValue) const;\n  /// Return the member named key if it exist, defaultValue otherwise.\n  Value get(const std::string &key, const Value &defaultValue) const;\n#ifdef JSON_USE_CPPTL\n  /// Return the member named key if it exist, defaultValue otherwise.\n  Value get(const CppTL::ConstString &key, const Value &defaultValue) const;\n#endif\n  /// \\brief Remove and return the named member.\n  ///\n  /// Do nothing if it did not exist.\n  /// \\return the removed Value, or null.\n  /// \\pre type() is objectValue or nullValue\n  /// \\post type() is unchanged\n  Value removeMember(const char *key);\n  /// Same as removeMember(const char*)\n  Value removeMember(const std::string &key);\n\n  /// Return true if the object has a member named key.\n  bool isMember(const char *key) const;\n  /// Return true if the object has a member named key.\n  bool isMember(const std::string &key) const;\n#ifdef JSON_USE_CPPTL\n  /// Return true if the object has a member named key.\n  bool isMember(const CppTL::ConstString &key) const;\n#endif\n\n  /// \\brief Return a list of the member names.\n  ///\n  /// If null, return an empty list.\n  /// \\pre type() is objectValue or nullValue\n  /// \\post if type() was nullValue, it remains nullValue\n  Members getMemberNames() const;\n\n  //# ifdef JSON_USE_CPPTL\n  //      EnumMemberNames enumMemberNames() const;\n  //      EnumValues enumValues() const;\n  //# endif\n\n  /// Comments must be //... or /* ... */\n  void setComment(const char *comment, CommentPlacement placement);\n  /// Comments must be //... or /* ... */\n  void setComment(const std::string &comment, CommentPlacement placement);\n  bool hasComment(CommentPlacement placement) const;\n  /// Include delimiters and embedded newlines.\n  std::string getComment(CommentPlacement placement) const;\n\n  std::string toStyledString() const;\n\n  const_iterator begin() const;\n  const_iterator end() const;\n\n  iterator begin();\n  iterator end();\n\n  // Accessors for the [start, limit) range of bytes within the JSON text from\n  // which this value was parsed, if any.\n  void setOffsetStart(size_t start);\n  void setOffsetLimit(size_t limit);\n  size_t getOffsetStart() const;\n  size_t getOffsetLimit() const;\n\nprivate:\n  Value &resolveReference(const char *key, bool isStatic);\n\n#ifdef JSON_VALUE_USE_INTERNAL_MAP\n  inline bool isItemAvailable() const { return itemIsUsed_ == 0; }\n\n  inline void setItemUsed(bool isUsed = true) { itemIsUsed_ = isUsed ? 1 : 0; }\n\n  inline bool isMemberNameStatic() const { return memberNameIsStatic_ == 0; }\n\n  inline void setMemberNameIsStatic(bool isStatic) {\n    memberNameIsStatic_ = isStatic ? 1 : 0;\n  }\n#endif // # ifdef JSON_VALUE_USE_INTERNAL_MAP\n\nprivate:\n  struct CommentInfo {\n    CommentInfo();\n    ~CommentInfo();\n\n    void setComment(const char *text);\n\n    char *comment_;\n  };\n\n  // struct MemberNamesTransform\n  //{\n  //   typedef const char *result_type;\n  //   const char *operator()( const CZString &name ) const\n  //   {\n  //      return name.c_str();\n  //   }\n  //};\n\n  union ValueHolder {\n    LargestInt int_;\n    LargestUInt uint_;\n    double real_;\n    bool bool_;\n    char *string_;\n#ifdef JSON_VALUE_USE_INTERNAL_MAP\n    ValueInternalArray *array_;\n    ValueInternalMap *map_;\n#else\n    ObjectValues *map_;\n#endif\n  } value_;\n  ValueType type_ : 8;\n  int allocated_ : 1; // Notes: if declared as bool, bitfield is useless.\n#ifdef JSON_VALUE_USE_INTERNAL_MAP\n  unsigned int itemIsUsed_ : 1; // used by the ValueInternalMap container.\n  int memberNameIsStatic_ : 1;  // used by the ValueInternalMap container.\n#endif\n  CommentInfo *comments_;\n\n  // [start, limit) byte offsets in the source JSON text from which this Value\n  // was extracted.\n  size_t start_;\n  size_t limit_;\n};\n\n/** \\brief Experimental and untested: represents an element of the \"path\" to\n * access a node.\n */\nclass JSON_API PathArgument {\npublic:\n  friend class Path;\n\n  PathArgument();\n  PathArgument(ArrayIndex index);\n  PathArgument(const char *key);\n  PathArgument(const std::string &key);\n\nprivate:\n  enum Kind {\n    kindNone = 0,\n    kindIndex,\n    kindKey\n  };\n  std::string key_;\n  ArrayIndex index_;\n  Kind kind_;\n};\n\n/** \\brief Experimental and untested: represents a \"path\" to access a node.\n *\n * Syntax:\n * - \".\" => root node\n * - \".[n]\" => elements at index 'n' of root node (an array value)\n * - \".name\" => member named 'name' of root node (an object value)\n * - \".name1.name2.name3\"\n * - \".[0][1][2].name1[3]\"\n * - \".%\" => member name is provided as parameter\n * - \".[%]\" => index is provied as parameter\n */\nclass JSON_API Path {\npublic:\n  Path(const std::string &path,\n       const PathArgument &a1 = PathArgument(),\n       const PathArgument &a2 = PathArgument(),\n       const PathArgument &a3 = PathArgument(),\n       const PathArgument &a4 = PathArgument(),\n       const PathArgument &a5 = PathArgument());\n\n  const Value &resolve(const Value &root) const;\n  Value resolve(const Value &root, const Value &defaultValue) const;\n  /// Creates the \"path\" to access the specified node and returns a reference on\n  /// the node.\n  Value &make(Value &root) const;\n\nprivate:\n  typedef std::vector<const PathArgument *> InArgs;\n  typedef std::vector<PathArgument> Args;\n\n  void makePath(const std::string &path, const InArgs &in);\n  void addPathInArg(const std::string &path,\n                    const InArgs &in,\n                    InArgs::const_iterator &itInArg,\n                    PathArgument::Kind kind);\n  void invalidPath(const std::string &path, int location);\n\n  Args args_;\n};\n\n#ifdef JSON_VALUE_USE_INTERNAL_MAP\n/** \\brief Allocator to customize Value internal map.\n * Below is an example of a simple implementation (default implementation\n actually\n * use memory pool for speed).\n * \\code\n   class DefaultValueMapAllocator : public ValueMapAllocator\n   {\n   public: // overridden from ValueMapAllocator\n      virtual ValueInternalMap *newMap()\n      {\n         return new ValueInternalMap();\n      }\n\n      virtual ValueInternalMap *newMapCopy( const ValueInternalMap &other )\n      {\n         return new ValueInternalMap( other );\n      }\n\n      virtual void destructMap( ValueInternalMap *map )\n      {\n         delete map;\n      }\n\n      virtual ValueInternalLink *allocateMapBuckets( unsigned int size )\n      {\n         return new ValueInternalLink[size];\n      }\n\n      virtual void releaseMapBuckets( ValueInternalLink *links )\n      {\n         delete [] links;\n      }\n\n      virtual ValueInternalLink *allocateMapLink()\n      {\n         return new ValueInternalLink();\n      }\n\n      virtual void releaseMapLink( ValueInternalLink *link )\n      {\n         delete link;\n      }\n   };\n * \\endcode\n */\nclass JSON_API ValueMapAllocator {\npublic:\n  virtual ~ValueMapAllocator();\n  virtual ValueInternalMap *newMap() = 0;\n  virtual ValueInternalMap *newMapCopy(const ValueInternalMap &other) = 0;\n  virtual void destructMap(ValueInternalMap *map) = 0;\n  virtual ValueInternalLink *allocateMapBuckets(unsigned int size) = 0;\n  virtual void releaseMapBuckets(ValueInternalLink *links) = 0;\n  virtual ValueInternalLink *allocateMapLink() = 0;\n  virtual void releaseMapLink(ValueInternalLink *link) = 0;\n};\n\n/** \\brief ValueInternalMap hash-map bucket chain link (for internal use only).\n * \\internal previous_ & next_ allows for bidirectional traversal.\n */\nclass JSON_API ValueInternalLink {\npublic:\n  enum {\n    itemPerLink = 6\n  }; // sizeof(ValueInternalLink) = 128 on 32 bits architecture.\n  enum InternalFlags {\n    flagAvailable = 0,\n    flagUsed = 1\n  };\n\n  ValueInternalLink();\n\n  ~ValueInternalLink();\n\n  Value items_[itemPerLink];\n  char *keys_[itemPerLink];\n  ValueInternalLink *previous_;\n  ValueInternalLink *next_;\n};\n\n/** \\brief A linked page based hash-table implementation used internally by\n *Value.\n * \\internal ValueInternalMap is a tradional bucket based hash-table, with a\n *linked\n * list in each bucket to handle collision. There is an addional twist in that\n * each node of the collision linked list is a page containing a fixed amount of\n * value. This provides a better compromise between memory usage and speed.\n *\n * Each bucket is made up of a chained list of ValueInternalLink. The last\n * link of a given bucket can be found in the 'previous_' field of the following\n *bucket.\n * The last link of the last bucket is stored in tailLink_ as it has no\n *following bucket.\n * Only the last link of a bucket may contains 'available' item. The last link\n *always\n * contains at least one element unless is it the bucket one very first link.\n */\nclass JSON_API ValueInternalMap {\n  friend class ValueIteratorBase;\n  friend class Value;\n\npublic:\n  typedef unsigned int HashKey;\n  typedef unsigned int BucketIndex;\n\n#ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION\n  struct IteratorState {\n    IteratorState() : map_(0), link_(0), itemIndex_(0), bucketIndex_(0) {}\n    ValueInternalMap *map_;\n    ValueInternalLink *link_;\n    BucketIndex itemIndex_;\n    BucketIndex bucketIndex_;\n  };\n#endif // ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION\n\n  ValueInternalMap();\n  ValueInternalMap(const ValueInternalMap &other);\n  ValueInternalMap &operator=(ValueInternalMap other);\n  ~ValueInternalMap();\n\n  void swap(ValueInternalMap &other);\n\n  BucketIndex size() const;\n\n  void clear();\n\n  bool reserveDelta(BucketIndex growth);\n\n  bool reserve(BucketIndex newItemCount);\n\n  const Value *find(const char *key) const;\n\n  Value *find(const char *key);\n\n  Value &resolveReference(const char *key, bool isStatic);\n\n  void remove(const char *key);\n\n  void doActualRemove(ValueInternalLink *link,\n                      BucketIndex index,\n                      BucketIndex bucketIndex);\n\n  ValueInternalLink *&getLastLinkInBucket(BucketIndex bucketIndex);\n\n  Value &setNewItem(const char *key,\n                    bool isStatic,\n                    ValueInternalLink *link,\n                    BucketIndex index);\n\n  Value &unsafeAdd(const char *key, bool isStatic, HashKey hashedKey);\n\n  HashKey hash(const char *key) const;\n\n  int compare(const ValueInternalMap &other) const;\n\nprivate:\n  void makeBeginIterator(IteratorState &it) const;\n  void makeEndIterator(IteratorState &it) const;\n  static bool equals(const IteratorState &x, const IteratorState &other);\n  static void increment(IteratorState &iterator);\n  static void incrementBucket(IteratorState &iterator);\n  static void decrement(IteratorState &iterator);\n  static const char *key(const IteratorState &iterator);\n  static const char *key(const IteratorState &iterator, bool &isStatic);\n  static Value &value(const IteratorState &iterator);\n  static int distance(const IteratorState &x, const IteratorState &y);\n\nprivate:\n  ValueInternalLink *buckets_;\n  ValueInternalLink *tailLink_;\n  BucketIndex bucketsSize_;\n  BucketIndex itemCount_;\n};\n\n/** \\brief A simplified deque implementation used internally by Value.\n* \\internal\n* It is based on a list of fixed \"page\", each page contains a fixed number of\n*items.\n* Instead of using a linked-list, a array of pointer is used for fast item\n*look-up.\n* Look-up for an element is as follow:\n* - compute page index: pageIndex = itemIndex / itemsPerPage\n* - look-up item in page: pages_[pageIndex][itemIndex % itemsPerPage]\n*\n* Insertion is amortized constant time (only the array containing the index of\n*pointers\n* need to be reallocated when items are appended).\n*/\nclass JSON_API ValueInternalArray {\n  friend class Value;\n  friend class ValueIteratorBase;\n\npublic:\n  enum {\n    itemsPerPage = 8\n  }; // should be a power of 2 for fast divide and modulo.\n  typedef Value::ArrayIndex ArrayIndex;\n  typedef unsigned int PageIndex;\n\n#ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION\n  struct IteratorState // Must be a POD\n      {\n    IteratorState() : array_(0), currentPageIndex_(0), currentItemIndex_(0) {}\n    ValueInternalArray *array_;\n    Value **currentPageIndex_;\n    unsigned int currentItemIndex_;\n  };\n#endif // ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION\n\n  ValueInternalArray();\n  ValueInternalArray(const ValueInternalArray &other);\n  ValueInternalArray &operator=(ValueInternalArray other);\n  ~ValueInternalArray();\n  void swap(ValueInternalArray &other);\n\n  void clear();\n  void resize(ArrayIndex newSize);\n\n  Value &resolveReference(ArrayIndex index);\n\n  Value *find(ArrayIndex index) const;\n\n  ArrayIndex size() const;\n\n  int compare(const ValueInternalArray &other) const;\n\nprivate:\n  static bool equals(const IteratorState &x, const IteratorState &other);\n  static void increment(IteratorState &iterator);\n  static void decrement(IteratorState &iterator);\n  static Value &dereference(const IteratorState &iterator);\n  static Value &unsafeDereference(const IteratorState &iterator);\n  static int distance(const IteratorState &x, const IteratorState &y);\n  static ArrayIndex indexOf(const IteratorState &iterator);\n  void makeBeginIterator(IteratorState &it) const;\n  void makeEndIterator(IteratorState &it) const;\n  void makeIterator(IteratorState &it, ArrayIndex index) const;\n\n  void makeIndexValid(ArrayIndex index);\n\n  Value **pages_;\n  ArrayIndex size_;\n  PageIndex pageCount_;\n};\n\n/** \\brief Experimental: do not use. Allocator to customize Value internal\narray.\n * Below is an example of a simple implementation (actual implementation use\n * memory pool).\n   \\code\nclass DefaultValueArrayAllocator : public ValueArrayAllocator\n{\npublic: // overridden from ValueArrayAllocator\nvirtual ~DefaultValueArrayAllocator()\n{\n}\n\nvirtual ValueInternalArray *newArray()\n{\n   return new ValueInternalArray();\n}\n\nvirtual ValueInternalArray *newArrayCopy( const ValueInternalArray &other )\n{\n   return new ValueInternalArray( other );\n}\n\nvirtual void destruct( ValueInternalArray *array )\n{\n   delete array;\n}\n\nvirtual void reallocateArrayPageIndex( Value **&indexes,\n                                       ValueInternalArray::PageIndex\n&indexCount,\n                                       ValueInternalArray::PageIndex\nminNewIndexCount )\n{\n   ValueInternalArray::PageIndex newIndexCount = (indexCount*3)/2 + 1;\n   if ( minNewIndexCount > newIndexCount )\n      newIndexCount = minNewIndexCount;\n   void *newIndexes = realloc( indexes, sizeof(Value*) * newIndexCount );\n   if ( !newIndexes )\n      throw std::bad_alloc();\n   indexCount = newIndexCount;\n   indexes = static_cast<Value **>( newIndexes );\n}\nvirtual void releaseArrayPageIndex( Value **indexes,\n                                    ValueInternalArray::PageIndex indexCount )\n{\n   if ( indexes )\n      free( indexes );\n}\n\nvirtual Value *allocateArrayPage()\n{\n   return static_cast<Value *>( malloc( sizeof(Value) *\nValueInternalArray::itemsPerPage ) );\n}\n\nvirtual void releaseArrayPage( Value *value )\n{\n   if ( value )\n      free( value );\n}\n};\n   \\endcode\n */\nclass JSON_API ValueArrayAllocator {\npublic:\n  virtual ~ValueArrayAllocator();\n  virtual ValueInternalArray *newArray() = 0;\n  virtual ValueInternalArray *newArrayCopy(const ValueInternalArray &other) = 0;\n  virtual void destructArray(ValueInternalArray *array) = 0;\n  /** \\brief Reallocate array page index.\n   * Reallocates an array of pointer on each page.\n   * \\param indexes [input] pointer on the current index. May be \\c NULL.\n   *                [output] pointer on the new index of at least\n   *                         \\a minNewIndexCount pages.\n   * \\param indexCount [input] current number of pages in the index.\n   *                   [output] number of page the reallocated index can handle.\n   *                            \\b MUST be >= \\a minNewIndexCount.\n   * \\param minNewIndexCount Minimum number of page the new index must be able\n   * to\n   *                         handle.\n   */\n  virtual void\n  reallocateArrayPageIndex(Value **&indexes,\n                           ValueInternalArray::PageIndex &indexCount,\n                           ValueInternalArray::PageIndex minNewIndexCount) = 0;\n  virtual void\n  releaseArrayPageIndex(Value **indexes,\n                        ValueInternalArray::PageIndex indexCount) = 0;\n  virtual Value *allocateArrayPage() = 0;\n  virtual void releaseArrayPage(Value *value) = 0;\n};\n#endif // #ifdef JSON_VALUE_USE_INTERNAL_MAP\n\n/** \\brief base class for Value iterators.\n *\n */\nclass JSON_API ValueIteratorBase {\npublic:\n  typedef std::bidirectional_iterator_tag iterator_category;\n  typedef unsigned int size_t;\n  typedef int difference_type;\n  typedef ValueIteratorBase SelfType;\n\n  ValueIteratorBase();\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\n  explicit ValueIteratorBase(const Value::ObjectValues::iterator &current);\n#else\n  ValueIteratorBase(const ValueInternalArray::IteratorState &state);\n  ValueIteratorBase(const ValueInternalMap::IteratorState &state);\n#endif\n\n  bool operator==(const SelfType &other) const { return isEqual(other); }\n\n  bool operator!=(const SelfType &other) const { return !isEqual(other); }\n\n  difference_type operator-(const SelfType &other) const {\n    return computeDistance(other);\n  }\n\n  /// Return either the index or the member name of the referenced value as a\n  /// Value.\n  Value key() const;\n\n  /// Return the index of the referenced Value. -1 if it is not an arrayValue.\n  UInt index() const;\n\n  /// Return the member name of the referenced Value. \"\" if it is not an\n  /// objectValue.\n  const char *memberName() const;\n\nprotected:\n  Value &deref() const;\n\n  void increment();\n\n  void decrement();\n\n  difference_type computeDistance(const SelfType &other) const;\n\n  bool isEqual(const SelfType &other) const;\n\n  void copy(const SelfType &other);\n\nprivate:\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\n  Value::ObjectValues::iterator current_;\n  // Indicates that iterator is for a null value.\n  bool isNull_;\n#else\n  union {\n    ValueInternalArray::IteratorState array_;\n    ValueInternalMap::IteratorState map_;\n  } iterator_;\n  bool isArray_;\n#endif\n};\n\n/** \\brief const iterator for object and array value.\n *\n */\nclass JSON_API ValueConstIterator : public ValueIteratorBase {\n  friend class Value;\n\npublic:\n  typedef const Value value_type;\n  typedef unsigned int size_t;\n  typedef int difference_type;\n  typedef const Value &reference;\n  typedef const Value *pointer;\n  typedef ValueConstIterator SelfType;\n\n  ValueConstIterator();\n\nprivate:\n/*! \\internal Use by Value to create an iterator.\n */\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\n  explicit ValueConstIterator(const Value::ObjectValues::iterator &current);\n#else\n  ValueConstIterator(const ValueInternalArray::IteratorState &state);\n  ValueConstIterator(const ValueInternalMap::IteratorState &state);\n#endif\npublic:\n  SelfType &operator=(const ValueIteratorBase &other);\n\n  SelfType operator++(int) {\n    SelfType temp(*this);\n    ++*this;\n    return temp;\n  }\n\n  SelfType operator--(int) {\n    SelfType temp(*this);\n    --*this;\n    return temp;\n  }\n\n  SelfType &operator--() {\n    decrement();\n    return *this;\n  }\n\n  SelfType &operator++() {\n    increment();\n    return *this;\n  }\n\n  reference operator*() const { return deref(); }\n};\n\n/** \\brief Iterator for object and array value.\n */\nclass JSON_API ValueIterator : public ValueIteratorBase {\n  friend class Value;\n\npublic:\n  typedef Value value_type;\n  typedef unsigned int size_t;\n  typedef int difference_type;\n  typedef Value &reference;\n  typedef Value *pointer;\n  typedef ValueIterator SelfType;\n\n  ValueIterator();\n  ValueIterator(const ValueConstIterator &other);\n  ValueIterator(const ValueIterator &other);\n\nprivate:\n/*! \\internal Use by Value to create an iterator.\n */\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\n  explicit ValueIterator(const Value::ObjectValues::iterator &current);\n#else\n  ValueIterator(const ValueInternalArray::IteratorState &state);\n  ValueIterator(const ValueInternalMap::IteratorState &state);\n#endif\npublic:\n  SelfType &operator=(const SelfType &other);\n\n  SelfType operator++(int) {\n    SelfType temp(*this);\n    ++*this;\n    return temp;\n  }\n\n  SelfType operator--(int) {\n    SelfType temp(*this);\n    --*this;\n    return temp;\n  }\n\n  SelfType &operator--() {\n    decrement();\n    return *this;\n  }\n\n  SelfType &operator++() {\n    increment();\n    return *this;\n  }\n\n  reference operator*() const { return deref(); }\n};\n\n} // namespace Json\n\n#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)\n#pragma warning(pop)\n#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)\n\n#endif // CPPTL_JSON_H_INCLUDED\n"
  },
  {
    "path": "Libraries/Core/Android/Headers/json/writer.h",
    "content": "// Copyright 2007-2010 Baptiste Lepilleur\n// Distributed under MIT license, or public domain if desired and\n// recognized in your jurisdiction.\n// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE\n\n#ifndef JSON_WRITER_H_INCLUDED\n#define JSON_WRITER_H_INCLUDED\n\n#if !defined(JSON_IS_AMALGAMATION)\n#include \"value.h\"\n#endif // if !defined(JSON_IS_AMALGAMATION)\n#include <vector>\n#include <string>\n\n// Disable warning C4251: <data member>: <type> needs to have dll-interface to\n// be used by...\n#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)\n#pragma warning(push)\n#pragma warning(disable : 4251)\n#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)\n\nnamespace Json {\n\nclass Value;\n\n/** \\brief Abstract class for writers.\n */\nclass JSON_API Writer {\npublic:\n  virtual ~Writer();\n\n  virtual std::string write(const Value &root) = 0;\n};\n\n/** \\brief Outputs a Value in <a HREF=\"http://www.json.org\">JSON</a> format\n *without formatting (not human friendly).\n *\n * The JSON document is written in a single line. It is not intended for 'human'\n *consumption,\n * but may be usefull to support feature such as RPC where bandwith is limited.\n * \\sa Reader, Value\n */\nclass JSON_API FastWriter : public Writer {\npublic:\n  FastWriter();\n  virtual ~FastWriter() {}\n\n  void enableYAMLCompatibility();\n\n  /** \\brief Drop the \"null\" string from the writer's output for nullValues.\n   * Strictly speaking, this is not valid JSON. But when the output is being\n   * fed to a browser's Javascript, it makes for smaller output and the\n   * browser can handle the output just fine.\n   */\n  void dropNullPlaceholders();\n\n  void omitEndingLineFeed();\n\npublic: // overridden from Writer\n  virtual std::string write(const Value &root);\n\nprivate:\n  void writeValue(const Value &value);\n\n  std::string document_;\n  bool yamlCompatiblityEnabled_;\n  bool dropNullPlaceholders_;\n  bool omitEndingLineFeed_;\n};\n\n/** \\brief Writes a Value in <a HREF=\"http://www.json.org\">JSON</a> format in a\n *human friendly way.\n *\n * The rules for line break and indent are as follow:\n * - Object value:\n *     - if empty then print {} without indent and line break\n *     - if not empty the print '{', line break & indent, print one value per\n *line\n *       and then unindent and line break and print '}'.\n * - Array value:\n *     - if empty then print [] without indent and line break\n *     - if the array contains no object value, empty array or some other value\n *types,\n *       and all the values fit on one lines, then print the array on a single\n *line.\n *     - otherwise, it the values do not fit on one line, or the array contains\n *       object or non empty array, then print one value per line.\n *\n * If the Value have comments then they are outputed according to their\n *#CommentPlacement.\n *\n * \\sa Reader, Value, Value::setComment()\n */\nclass JSON_API StyledWriter : public Writer {\npublic:\n  StyledWriter();\n  virtual ~StyledWriter() {}\n\npublic: // overridden from Writer\n  /** \\brief Serialize a Value in <a HREF=\"http://www.json.org\">JSON</a> format.\n   * \\param root Value to serialize.\n   * \\return String containing the JSON document that represents the root value.\n   */\n  virtual std::string write(const Value &root);\n\nprivate:\n  void writeValue(const Value &value);\n  void writeArrayValue(const Value &value);\n  bool isMultineArray(const Value &value);\n  void pushValue(const std::string &value);\n  void writeIndent();\n  void writeWithIndent(const std::string &value);\n  void indent();\n  void unindent();\n  void writeCommentBeforeValue(const Value &root);\n  void writeCommentAfterValueOnSameLine(const Value &root);\n  bool hasCommentForValue(const Value &value);\n  static std::string normalizeEOL(const std::string &text);\n\n  typedef std::vector<std::string> ChildValues;\n\n  ChildValues childValues_;\n  std::string document_;\n  std::string indentString_;\n  int rightMargin_;\n  int indentSize_;\n  bool addChildValues_;\n};\n\n/** \\brief Writes a Value in <a HREF=\"http://www.json.org\">JSON</a> format in a\n human friendly way,\n     to a stream rather than to a string.\n *\n * The rules for line break and indent are as follow:\n * - Object value:\n *     - if empty then print {} without indent and line break\n *     - if not empty the print '{', line break & indent, print one value per\n line\n *       and then unindent and line break and print '}'.\n * - Array value:\n *     - if empty then print [] without indent and line break\n *     - if the array contains no object value, empty array or some other value\n types,\n *       and all the values fit on one lines, then print the array on a single\n line.\n *     - otherwise, it the values do not fit on one line, or the array contains\n *       object or non empty array, then print one value per line.\n *\n * If the Value have comments then they are outputed according to their\n #CommentPlacement.\n *\n * \\param indentation Each level will be indented by this amount extra.\n * \\sa Reader, Value, Value::setComment()\n */\nclass JSON_API StyledStreamWriter {\npublic:\n  StyledStreamWriter(std::string indentation = \"\\t\");\n  ~StyledStreamWriter() {}\n\npublic:\n  /** \\brief Serialize a Value in <a HREF=\"http://www.json.org\">JSON</a> format.\n   * \\param out Stream to write to. (Can be ostringstream, e.g.)\n   * \\param root Value to serialize.\n   * \\note There is no point in deriving from Writer, since write() should not\n   * return a value.\n   */\n  void write(std::ostream &out, const Value &root);\n\nprivate:\n  void writeValue(const Value &value);\n  void writeArrayValue(const Value &value);\n  bool isMultineArray(const Value &value);\n  void pushValue(const std::string &value);\n  void writeIndent();\n  void writeWithIndent(const std::string &value);\n  void indent();\n  void unindent();\n  void writeCommentBeforeValue(const Value &root);\n  void writeCommentAfterValueOnSameLine(const Value &root);\n  bool hasCommentForValue(const Value &value);\n  static std::string normalizeEOL(const std::string &text);\n\n  typedef std::vector<std::string> ChildValues;\n\n  ChildValues childValues_;\n  std::ostream *document_;\n  std::string indentString_;\n  int rightMargin_;\n  std::string indentation_;\n  bool addChildValues_;\n};\n\n#if defined(JSON_HAS_INT64)\nstd::string JSON_API valueToString(Int value);\nstd::string JSON_API valueToString(UInt value);\n#endif // if defined(JSON_HAS_INT64)\nstd::string JSON_API valueToString(LargestInt value);\nstd::string JSON_API valueToString(LargestUInt value);\nstd::string JSON_API valueToString(double value);\nstd::string JSON_API valueToString(bool value);\nstd::string JSON_API valueToQuotedString(const char *value);\n\n/// \\brief Output using the StyledStreamWriter.\n/// \\see Json::operator>>()\nJSON_API std::ostream &operator<<(std::ostream &, const Value &root);\n\n} // namespace Json\n\n#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)\n#pragma warning(pop)\n#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)\n\n#endif // JSON_WRITER_H_INCLUDED\n"
  },
  {
    "path": "Libraries/Core/Android/Headers/md5/md5.h",
    "content": "/* MD5\n converted to C++ class by Frank Thilo (thilo@unix-ag.org)\n for bzflag (http://www.bzflag.org)\n\n   based on:\n\n   md5.h and md5.c\n   reference implementation of RFC 1321\n\n   Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All\nrights reserved.\n\nLicense to copy and use this software is granted provided that it\nis identified as the \"RSA Data Security, Inc. MD5 Message-Digest\nAlgorithm\" in all material mentioning or referencing this software\nor this function.\n\nLicense is also granted to make and use derivative works provided\nthat such works are identified as \"derived from the RSA Data\nSecurity, Inc. MD5 Message-Digest Algorithm\" in all material\nmentioning or referencing the derived work.\n\nRSA Data Security, Inc. makes no representations concerning either\nthe merchantability of this software or the suitability of this\nsoftware for any particular purpose. It is provided \"as is\"\nwithout express or implied warranty of any kind.\n\nThese notices must be retained in any copies of any part of this\ndocumentation and/or software.\n\n*/\n\n#ifndef BZF_MD5_H\n#define BZF_MD5_H\n\n#include <cstring>\n#include <iostream>\n\n\n// a small class for calculating MD5 hashes of strings or byte arrays\n// it is not meant to be fast or secure\n//\n// usage: 1) feed it blocks of uchars with update()\n//      2) finalize()\n//      3) get hexdigest() string\n//      or\n//      MD5(std::string).hexdigest()\n//\n// assumes that char is 8 bit and int is 32 bit\nclass MD5\n{\npublic:\n  typedef unsigned int size_type; // must be 32bit\n\n  MD5();\n  MD5(const std::string& text);\n  void update(const unsigned char *buf, size_type length);\n  void update(const char *buf, size_type length);\n  MD5& finalize();\n  std::string hexdigest() const;\n  friend std::ostream& operator<<(std::ostream&, MD5 md5);\n  std::string binarydigest() const {return std::string(reinterpret_cast<const char*>(digest), 16);} //Ian Copland, 09/06/2014: added accessor for the raw digest.\n    \nprivate:\n  void init();\n  typedef unsigned char uint1; //  8bit\n  typedef unsigned int uint4;  // 32bit\n  enum {blocksize = 64}; // VC6 won't eat a const static int here\n\n  void transform(const uint1 block[blocksize]);\n  static void decode(uint4 output[], const uint1 input[], size_type len);\n  static void encode(uint1 output[], const uint4 input[], size_type len);\n\n  bool finalized;\n  uint1 buffer[blocksize]; // bytes that didn't fit in last 64 byte chunk\n  uint4 count[2];   // 64bit counter for number of bits (lo, hi)\n  uint4 state[4];   // digest so far\n  uint1 digest[16]; // the result\n\n  // low level logic operations\n  static inline uint4 F(uint4 x, uint4 y, uint4 z);\n  static inline uint4 G(uint4 x, uint4 y, uint4 z);\n  static inline uint4 H(uint4 x, uint4 y, uint4 z);\n  static inline uint4 I(uint4 x, uint4 y, uint4 z);\n  static inline uint4 rotate_left(uint4 x, int n);\n  static inline void FF(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac);\n  static inline void GG(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac);\n  static inline void HH(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac);\n  static inline void II(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac);\n};\n\nstd::string md5(const std::string str);\n\n#endif\n"
  },
  {
    "path": "Libraries/Core/Android/Headers/minizip/crypt.h",
    "content": "/* crypt.h -- base code for crypt/uncrypt ZIPfile\n\n\n   Version 1.01e, February 12th, 2005\n\n   Copyright (C) 1998-2005 Gilles Vollant\n\n   This code is a modified version of crypting code in Infozip distribution\n\n   The encryption/decryption parts of this source code (as opposed to the\n   non-echoing password parts) were originally written in Europe.  The\n   whole source package can be freely distributed, including from the USA.\n   (Prior to January 2000, re-export from the US was a violation of US law.)\n\n   This encryption code is a direct transcription of the algorithm from\n   Roger Schlafly, described by Phil Katz in the file appnote.txt.  This\n   file (appnote.txt) is distributed with the PKZIP program (even in the\n   version without encryption capabilities).\n\n   If you don't need crypting in your application, just define symbols\n   NOCRYPT and NOUNCRYPT.\n\n   This code support the \"Traditional PKWARE Encryption\".\n\n   The new AES encryption added on Zip format by Winzip (see the page\n   http://www.winzip.com/aes_info.htm ) and PKWare PKZip 5.x Strong\n   Encryption is not supported.\n*/\n\n#define CRC32(c, b) ((*(pcrc_32_tab+(((int)(c) ^ (b)) & 0xff))) ^ ((c) >> 8))\n\n/***********************************************************************\n * Return the next byte in the pseudo-random sequence\n */\nstatic int decrypt_byte(unsigned long* pkeys, const unsigned long* pcrc_32_tab)\n{\n    unsigned temp;  /* POTENTIAL BUG:  temp*(temp^1) may overflow in an\n                     * unpredictable manner on 16-bit systems; not a problem\n                     * with any known compiler so far, though */\n\n    temp = ((unsigned)(*(pkeys+2)) & 0xffff) | 2;\n    return (int)(((temp * (temp ^ 1)) >> 8) & 0xff);\n}\n\n/***********************************************************************\n * Update the encryption keys with the next byte of plain text\n */\nstatic int update_keys(unsigned long* pkeys,const unsigned long* pcrc_32_tab,int c)\n{\n    (*(pkeys+0)) = CRC32((*(pkeys+0)), c);\n    (*(pkeys+1)) += (*(pkeys+0)) & 0xff;\n    (*(pkeys+1)) = (*(pkeys+1)) * 134775813L + 1;\n    {\n      register int keyshift = (int)((*(pkeys+1)) >> 24);\n      (*(pkeys+2)) = CRC32((*(pkeys+2)), keyshift);\n    }\n    return c;\n}\n\n\n/***********************************************************************\n * Initialize the encryption keys and the random header according to\n * the given password.\n */\nstatic void init_keys(const char* passwd,unsigned long* pkeys,const unsigned long* pcrc_32_tab)\n{\n    *(pkeys+0) = 305419896L;\n    *(pkeys+1) = 591751049L;\n    *(pkeys+2) = 878082192L;\n    while (*passwd != '\\0') {\n        update_keys(pkeys,pcrc_32_tab,(int)*passwd);\n        passwd++;\n    }\n}\n\n#define zdecode(pkeys,pcrc_32_tab,c) \\\n    (update_keys(pkeys,pcrc_32_tab,c ^= decrypt_byte(pkeys,pcrc_32_tab)))\n\n#define zencode(pkeys,pcrc_32_tab,c,t) \\\n    (t=decrypt_byte(pkeys,pcrc_32_tab), update_keys(pkeys,pcrc_32_tab,c), t^(c))\n\n#ifdef INCLUDECRYPTINGCODE_IFCRYPTALLOWED\n\n#define RAND_HEAD_LEN  12\n   /* \"last resort\" source for second part of crypt seed pattern */\n#  ifndef ZCR_SEED2\n#    define ZCR_SEED2 3141592654UL     /* use PI as default pattern */\n#  endif\n\nstatic int crypthead(const char* passwd,      /* password string */\n                     unsigned char* buf,      /* where to write header */\n                     int bufSize,\n                     unsigned long* pkeys,\n                     const unsigned long* pcrc_32_tab,\n                     unsigned long crcForCrypting)\n{\n    int n;                       /* index in random header */\n    int t;                       /* temporary */\n    int c;                       /* random byte */\n    unsigned char header[RAND_HEAD_LEN-2]; /* random header */\n    static unsigned calls = 0;   /* ensure different random header each time */\n\n    if (bufSize<RAND_HEAD_LEN)\n      return 0;\n\n    /* First generate RAND_HEAD_LEN-2 random bytes. We encrypt the\n     * output of rand() to get less predictability, since rand() is\n     * often poorly implemented.\n     */\n    if (++calls == 1)\n    {\n        srand((unsigned)(time(NULL) ^ ZCR_SEED2));\n    }\n    init_keys(passwd, pkeys, pcrc_32_tab);\n    for (n = 0; n < RAND_HEAD_LEN-2; n++)\n    {\n        c = (rand() >> 7) & 0xff;\n        header[n] = (unsigned char)zencode(pkeys, pcrc_32_tab, c, t);\n    }\n    /* Encrypt random header (last two bytes is high word of crc) */\n    init_keys(passwd, pkeys, pcrc_32_tab);\n    for (n = 0; n < RAND_HEAD_LEN-2; n++)\n    {\n        buf[n] = (unsigned char)zencode(pkeys, pcrc_32_tab, header[n], t);\n    }\n    buf[n++] = (unsigned char)zencode(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 16) & 0xff, t);\n    buf[n++] = (unsigned char)zencode(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 24) & 0xff, t);\n    return n;\n}\n\n#endif\n"
  },
  {
    "path": "Libraries/Core/Android/Headers/minizip/ioapi.h",
    "content": "/* ioapi.h -- IO base function header for compress/uncompress .zip\n   part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )\n\n         Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html )\n\n         Modifications for Zip64 support\n         Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )\n\n         For more info read MiniZip_info.txt\n\n         Changes\n\n    Oct-2009 - Defined ZPOS64_T to fpos_t on windows and u_int64_t on linux. (might need to find a better why for this)\n    Oct-2009 - Change to fseeko64, ftello64 and fopen64 so large files would work on linux.\n               More if/def section may be needed to support other platforms\n    Oct-2009 - Defined fxxxx64 calls to normal fopen/ftell/fseek so they would compile on windows.\n                          (but you should use iowin32.c for windows instead)\n\n*/\n\n#ifndef _ZLIBIOAPI64_H\n#define _ZLIBIOAPI64_H\n\n#if (!defined(_WIN32)) && (!defined(WIN32))\n\n  // Linux needs this to support file operation on files larger then 4+GB\n  // But might need better if/def to select just the platforms that needs them.\n\n        #ifndef __USE_FILE_OFFSET64\n                #define __USE_FILE_OFFSET64\n        #endif\n        #ifndef __USE_LARGEFILE64\n                #define __USE_LARGEFILE64\n        #endif\n        #ifndef _LARGEFILE64_SOURCE\n                #define _LARGEFILE64_SOURCE\n        #endif\n        #ifndef _FILE_OFFSET_BIT\n                #define _FILE_OFFSET_BIT 64\n        #endif\n#endif\n\n#include <stdio.h>\n#include <stdlib.h>\n#include \"zlib.h\"\n\n#if defined(USE_FILE32API)\n#define fopen64 fopen\n#define ftello64 ftell\n#define fseeko64 fseek\n#else\n#ifdef _MSC_VER\n #define fopen64 fopen\n #if (_MSC_VER >= 1400) && (!(defined(NO_MSCVER_FILE64_FUNC)))\n  #define ftello64 _ftelli64\n  #define fseeko64 _fseeki64\n #else // old MSC\n  #define ftello64 ftell\n  #define fseeko64 fseek\n #endif\n#endif\n#endif\n\n/*\n#ifndef ZPOS64_T\n  #ifdef _WIN32\n                #define ZPOS64_T fpos_t\n  #else\n    #include <stdint.h>\n    #define ZPOS64_T uint64_t\n  #endif\n#endif\n*/\n\n#ifdef HAVE_MINIZIP64_CONF_H\n#include \"mz64conf.h\"\n#endif\n\n/* a type choosen by DEFINE */\n#ifdef HAVE_64BIT_INT_CUSTOM\ntypedef  64BIT_INT_CUSTOM_TYPE ZPOS64_T;\n#else\n#ifdef HAS_STDINT_H\n#include \"stdint.h\"\ntypedef uint64_t ZPOS64_T;\n#else\n\n\n#if defined(_MSC_VER) || defined(__BORLANDC__)\ntypedef unsigned __int64 ZPOS64_T;\n#else\ntypedef unsigned long long int ZPOS64_T;\n#endif\n#endif\n#endif\n\n\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n\n#define ZLIB_FILEFUNC_SEEK_CUR (1)\n#define ZLIB_FILEFUNC_SEEK_END (2)\n#define ZLIB_FILEFUNC_SEEK_SET (0)\n\n#define ZLIB_FILEFUNC_MODE_READ      (1)\n#define ZLIB_FILEFUNC_MODE_WRITE     (2)\n#define ZLIB_FILEFUNC_MODE_READWRITEFILTER (3)\n\n#define ZLIB_FILEFUNC_MODE_EXISTING (4)\n#define ZLIB_FILEFUNC_MODE_CREATE   (8)\n\n\n#ifndef ZCALLBACK\n #if (defined(WIN32) || defined(_WIN32) || defined (WINDOWS) || defined (_WINDOWS)) && defined(CALLBACK) && defined (USEWINDOWS_CALLBACK)\n   #define ZCALLBACK CALLBACK\n #else\n   #define ZCALLBACK\n #endif\n#endif\n\n\n\n\ntypedef voidpf   (ZCALLBACK *open_file_func)      OF((voidpf opaque, const char* filename, int mode));\ntypedef uLong    (ZCALLBACK *read_file_func)      OF((voidpf opaque, voidpf stream, void* buf, uLong size));\ntypedef uLong    (ZCALLBACK *write_file_func)     OF((voidpf opaque, voidpf stream, const void* buf, uLong size));\ntypedef int      (ZCALLBACK *close_file_func)     OF((voidpf opaque, voidpf stream));\ntypedef int      (ZCALLBACK *testerror_file_func) OF((voidpf opaque, voidpf stream));\n\ntypedef long     (ZCALLBACK *tell_file_func)      OF((voidpf opaque, voidpf stream));\ntypedef long     (ZCALLBACK *seek_file_func)      OF((voidpf opaque, voidpf stream, uLong offset, int origin));\n\n\n/* here is the \"old\" 32 bits structure structure */\ntypedef struct zlib_filefunc_def_s\n{\n    open_file_func      zopen_file;\n    read_file_func      zread_file;\n    write_file_func     zwrite_file;\n    tell_file_func      ztell_file;\n    seek_file_func      zseek_file;\n    close_file_func     zclose_file;\n    testerror_file_func zerror_file;\n    voidpf              opaque;\n} zlib_filefunc_def;\n\ntypedef ZPOS64_T (ZCALLBACK *tell64_file_func)    OF((voidpf opaque, voidpf stream));\ntypedef long     (ZCALLBACK *seek64_file_func)    OF((voidpf opaque, voidpf stream, ZPOS64_T offset, int origin));\ntypedef voidpf   (ZCALLBACK *open64_file_func)    OF((voidpf opaque, const void* filename, int mode));\n\ntypedef struct zlib_filefunc64_def_s\n{\n    open64_file_func    zopen64_file;\n    read_file_func      zread_file;\n    write_file_func     zwrite_file;\n    tell64_file_func    ztell64_file;\n    seek64_file_func    zseek64_file;\n    close_file_func     zclose_file;\n    testerror_file_func zerror_file;\n    voidpf              opaque;\n} zlib_filefunc64_def;\n\nvoid fill_fopen64_filefunc OF((zlib_filefunc64_def* pzlib_filefunc_def));\nvoid fill_fopen_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def));\n\n/* now internal definition, only for zip.c and unzip.h */\ntypedef struct zlib_filefunc64_32_def_s\n{\n    zlib_filefunc64_def zfile_func64;\n    open_file_func      zopen32_file;\n    tell_file_func      ztell32_file;\n    seek_file_func      zseek32_file;\n} zlib_filefunc64_32_def;\n\n\n#define ZREAD64(filefunc,filestream,buf,size)     ((*((filefunc).zfile_func64.zread_file))   ((filefunc).zfile_func64.opaque,filestream,buf,size))\n#define ZWRITE64(filefunc,filestream,buf,size)    ((*((filefunc).zfile_func64.zwrite_file))  ((filefunc).zfile_func64.opaque,filestream,buf,size))\n//#define ZTELL64(filefunc,filestream)            ((*((filefunc).ztell64_file)) ((filefunc).opaque,filestream))\n//#define ZSEEK64(filefunc,filestream,pos,mode)   ((*((filefunc).zseek64_file)) ((filefunc).opaque,filestream,pos,mode))\n#define ZCLOSE64(filefunc,filestream)             ((*((filefunc).zfile_func64.zclose_file))  ((filefunc).zfile_func64.opaque,filestream))\n#define ZERROR64(filefunc,filestream)             ((*((filefunc).zfile_func64.zerror_file))  ((filefunc).zfile_func64.opaque,filestream))\n\nvoidpf call_zopen64 OF((const zlib_filefunc64_32_def* pfilefunc,const void*filename,int mode));\nlong    call_zseek64 OF((const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZPOS64_T offset, int origin));\nZPOS64_T call_ztell64 OF((const zlib_filefunc64_32_def* pfilefunc,voidpf filestream));\n\nvoid    fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filefunc64_32,const zlib_filefunc_def* p_filefunc32);\n\n#define ZOPEN64(filefunc,filename,mode)         (call_zopen64((&(filefunc)),(filename),(mode)))\n#define ZTELL64(filefunc,filestream)            (call_ztell64((&(filefunc)),(filestream)))\n#define ZSEEK64(filefunc,filestream,pos,mode)   (call_zseek64((&(filefunc)),(filestream),(pos),(mode)))\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "Libraries/Core/Android/Headers/minizip/mztools.h",
    "content": "/*\n  Additional tools for Minizip\n  Code: Xavier Roche '2004\n  License: Same as ZLIB (www.gzip.org)\n*/\n\n#ifndef _zip_tools_H\n#define _zip_tools_H\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#ifndef _ZLIB_H\n#include \"zlib.h\"\n#endif\n\n#include \"unzip.h\"\n\n/* Repair a ZIP file (missing central directory)\n   file: file to recover\n   fileOut: output file after recovery\n   fileOutTmp: temporary file name used for recovery\n*/\nextern int ZEXPORT unzRepair(const char* file,\n                             const char* fileOut,\n                             const char* fileOutTmp,\n                             uLong* nRecovered,\n                             uLong* bytesRecovered);\n\n#endif\n"
  },
  {
    "path": "Libraries/Core/Android/Headers/minizip/unzip.h",
    "content": "/* unzip.h -- IO for uncompress .zip files using zlib\n   Version 1.1, February 14h, 2010\n   part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )\n\n         Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html )\n\n         Modifications of Unzip for Zip64\n         Copyright (C) 2007-2008 Even Rouault\n\n         Modifications for Zip64 support on both zip and unzip\n         Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )\n\n         For more info read MiniZip_info.txt\n\n         ---------------------------------------------------------------------------------\n\n        Condition of use and distribution are the same than zlib :\n\n  This software is provided 'as-is', without any express or implied\n  warranty.  In no event will the authors be held liable for any damages\n  arising from the use of this software.\n\n  Permission is granted to anyone to use this software for any purpose,\n  including commercial applications, and to alter it and redistribute it\n  freely, subject to the following restrictions:\n\n  1. The origin of this software must not be misrepresented; you must not\n     claim that you wrote the original software. If you use this software\n     in a product, an acknowledgment in the product documentation would be\n     appreciated but is not required.\n  2. Altered source versions must be plainly marked as such, and must not be\n     misrepresented as being the original software.\n  3. This notice may not be removed or altered from any source distribution.\n\n  ---------------------------------------------------------------------------------\n\n        Changes\n\n        See header of unzip64.c\n\n*/\n\n#ifndef _unz64_H\n#define _unz64_H\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#ifndef _ZLIB_H\n#include \"zlib.h\"\n#endif\n\n#ifndef  _ZLIBIOAPI_H\n#include \"ioapi.h\"\n#endif\n\n#ifdef HAVE_BZIP2\n#include \"bzlib.h\"\n#endif\n\n#define Z_BZIP2ED 12\n\n#if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP)\n/* like the STRICT of WIN32, we define a pointer that cannot be converted\n    from (void*) without cast */\ntypedef struct TagunzFile__ { int unused; } unzFile__;\ntypedef unzFile__ *unzFile;\n#else\ntypedef voidp unzFile;\n#endif\n\n\n#define UNZ_OK                          (0)\n#define UNZ_END_OF_LIST_OF_FILE         (-100)\n#define UNZ_ERRNO                       (Z_ERRNO)\n#define UNZ_EOF                         (0)\n#define UNZ_PARAMERROR                  (-102)\n#define UNZ_BADZIPFILE                  (-103)\n#define UNZ_INTERNALERROR               (-104)\n#define UNZ_CRCERROR                    (-105)\n\n/* tm_unz contain date/time info */\ntypedef struct tm_unz_s\n{\n    uInt tm_sec;            /* seconds after the minute - [0,59] */\n    uInt tm_min;            /* minutes after the hour - [0,59] */\n    uInt tm_hour;           /* hours since midnight - [0,23] */\n    uInt tm_mday;           /* day of the month - [1,31] */\n    uInt tm_mon;            /* months since January - [0,11] */\n    uInt tm_year;           /* years - [1980..2044] */\n} tm_unz;\n\n/* unz_global_info structure contain global data about the ZIPfile\n   These data comes from the end of central dir */\ntypedef struct unz_global_info64_s\n{\n    ZPOS64_T number_entry;         /* total number of entries in\n                                     the central dir on this disk */\n    uLong size_comment;         /* size of the global comment of the zipfile */\n} unz_global_info64;\n\ntypedef struct unz_global_info_s\n{\n    uLong number_entry;         /* total number of entries in\n                                     the central dir on this disk */\n    uLong size_comment;         /* size of the global comment of the zipfile */\n} unz_global_info;\n\n/* unz_file_info contain information about a file in the zipfile */\ntypedef struct unz_file_info64_s\n{\n    uLong version;              /* version made by                 2 bytes */\n    uLong version_needed;       /* version needed to extract       2 bytes */\n    uLong flag;                 /* general purpose bit flag        2 bytes */\n    uLong compression_method;   /* compression method              2 bytes */\n    uLong dosDate;              /* last mod file date in Dos fmt   4 bytes */\n    uLong crc;                  /* crc-32                          4 bytes */\n    ZPOS64_T compressed_size;   /* compressed size                 8 bytes */\n    ZPOS64_T uncompressed_size; /* uncompressed size               8 bytes */\n    uLong size_filename;        /* filename length                 2 bytes */\n    uLong size_file_extra;      /* extra field length              2 bytes */\n    uLong size_file_comment;    /* file comment length             2 bytes */\n\n    uLong disk_num_start;       /* disk number start               2 bytes */\n    uLong internal_fa;          /* internal file attributes        2 bytes */\n    uLong external_fa;          /* external file attributes        4 bytes */\n\n    tm_unz tmu_date;\n} unz_file_info64;\n\ntypedef struct unz_file_info_s\n{\n    uLong version;              /* version made by                 2 bytes */\n    uLong version_needed;       /* version needed to extract       2 bytes */\n    uLong flag;                 /* general purpose bit flag        2 bytes */\n    uLong compression_method;   /* compression method              2 bytes */\n    uLong dosDate;              /* last mod file date in Dos fmt   4 bytes */\n    uLong crc;                  /* crc-32                          4 bytes */\n    uLong compressed_size;      /* compressed size                 4 bytes */\n    uLong uncompressed_size;    /* uncompressed size               4 bytes */\n    uLong size_filename;        /* filename length                 2 bytes */\n    uLong size_file_extra;      /* extra field length              2 bytes */\n    uLong size_file_comment;    /* file comment length             2 bytes */\n\n    uLong disk_num_start;       /* disk number start               2 bytes */\n    uLong internal_fa;          /* internal file attributes        2 bytes */\n    uLong external_fa;          /* external file attributes        4 bytes */\n\n    tm_unz tmu_date;\n} unz_file_info;\n\nextern int ZEXPORT unzStringFileNameCompare OF ((const char* fileName1,\n                                                 const char* fileName2,\n                                                 int iCaseSensitivity));\n/*\n   Compare two filename (fileName1,fileName2).\n   If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp)\n   If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi\n                                or strcasecmp)\n   If iCaseSenisivity = 0, case sensitivity is defaut of your operating system\n    (like 1 on Unix, 2 on Windows)\n*/\n\n\nextern unzFile ZEXPORT unzOpen OF((const char *path));\nextern unzFile ZEXPORT unzOpen64 OF((const void *path));\n/*\n  Open a Zip file. path contain the full pathname (by example,\n     on a Windows XP computer \"c:\\\\zlib\\\\zlib113.zip\" or on an Unix computer\n     \"zlib/zlib113.zip\".\n     If the zipfile cannot be opened (file don't exist or in not valid), the\n       return value is NULL.\n     Else, the return value is a unzFile Handle, usable with other function\n       of this unzip package.\n     the \"64\" function take a const void* pointer, because the path is just the\n       value passed to the open64_file_func callback.\n     Under Windows, if UNICODE is defined, using fill_fopen64_filefunc, the path\n       is a pointer to a wide unicode string (LPCTSTR is LPCWSTR), so const char*\n       does not describe the reality\n*/\n\n\nextern unzFile ZEXPORT unzOpen2 OF((const char *path,\n                                    zlib_filefunc_def* pzlib_filefunc_def));\n/*\n   Open a Zip file, like unzOpen, but provide a set of file low level API\n      for read/write the zip file (see ioapi.h)\n*/\n\nextern unzFile ZEXPORT unzOpen2_64 OF((const void *path,\n                                    zlib_filefunc64_def* pzlib_filefunc_def));\n/*\n   Open a Zip file, like unz64Open, but provide a set of file low level API\n      for read/write the zip file (see ioapi.h)\n*/\n\nextern int ZEXPORT unzClose OF((unzFile file));\n/*\n  Close a ZipFile opened with unzipOpen.\n  If there is files inside the .Zip opened with unzOpenCurrentFile (see later),\n    these files MUST be closed with unzipCloseCurrentFile before call unzipClose.\n  return UNZ_OK if there is no problem. */\n\nextern int ZEXPORT unzGetGlobalInfo OF((unzFile file,\n                                        unz_global_info *pglobal_info));\n\nextern int ZEXPORT unzGetGlobalInfo64 OF((unzFile file,\n                                        unz_global_info64 *pglobal_info));\n/*\n  Write info about the ZipFile in the *pglobal_info structure.\n  No preparation of the structure is needed\n  return UNZ_OK if there is no problem. */\n\n\nextern int ZEXPORT unzGetGlobalComment OF((unzFile file,\n                                           char *szComment,\n                                           uLong uSizeBuf));\n/*\n  Get the global comment string of the ZipFile, in the szComment buffer.\n  uSizeBuf is the size of the szComment buffer.\n  return the number of byte copied or an error code <0\n*/\n\n\n/***************************************************************************/\n/* Unzip package allow you browse the directory of the zipfile */\n\nextern int ZEXPORT unzGoToFirstFile OF((unzFile file));\n/*\n  Set the current file of the zipfile to the first file.\n  return UNZ_OK if there is no problem\n*/\n\nextern int ZEXPORT unzGoToNextFile OF((unzFile file));\n/*\n  Set the current file of the zipfile to the next file.\n  return UNZ_OK if there is no problem\n  return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest.\n*/\n\nextern int ZEXPORT unzLocateFile OF((unzFile file,\n                     const char *szFileName,\n                     int iCaseSensitivity));\n/*\n  Try locate the file szFileName in the zipfile.\n  For the iCaseSensitivity signification, see unzStringFileNameCompare\n\n  return value :\n  UNZ_OK if the file is found. It becomes the current file.\n  UNZ_END_OF_LIST_OF_FILE if the file is not found\n*/\n\n\n/* ****************************************** */\n/* Ryan supplied functions */\n/* unz_file_info contain information about a file in the zipfile */\ntypedef struct unz_file_pos_s\n{\n    uLong pos_in_zip_directory;   /* offset in zip file directory */\n    uLong num_of_file;            /* # of file */\n} unz_file_pos;\n\nextern int ZEXPORT unzGetFilePos(\n    unzFile file,\n    unz_file_pos* file_pos);\n\nextern int ZEXPORT unzGoToFilePos(\n    unzFile file,\n    unz_file_pos* file_pos);\n\ntypedef struct unz64_file_pos_s\n{\n    ZPOS64_T pos_in_zip_directory;   /* offset in zip file directory */\n    ZPOS64_T num_of_file;            /* # of file */\n} unz64_file_pos;\n\nextern int ZEXPORT unzGetFilePos64(\n    unzFile file,\n    unz64_file_pos* file_pos);\n\nextern int ZEXPORT unzGoToFilePos64(\n    unzFile file,\n    const unz64_file_pos* file_pos);\n\n/* ****************************************** */\n\nextern int ZEXPORT unzGetCurrentFileInfo64 OF((unzFile file,\n                         unz_file_info64 *pfile_info,\n                         char *szFileName,\n                         uLong fileNameBufferSize,\n                         void *extraField,\n                         uLong extraFieldBufferSize,\n                         char *szComment,\n                         uLong commentBufferSize));\n\nextern int ZEXPORT unzGetCurrentFileInfo OF((unzFile file,\n                         unz_file_info *pfile_info,\n                         char *szFileName,\n                         uLong fileNameBufferSize,\n                         void *extraField,\n                         uLong extraFieldBufferSize,\n                         char *szComment,\n                         uLong commentBufferSize));\n/*\n  Get Info about the current file\n  if pfile_info!=NULL, the *pfile_info structure will contain somes info about\n        the current file\n  if szFileName!=NULL, the filemane string will be copied in szFileName\n            (fileNameBufferSize is the size of the buffer)\n  if extraField!=NULL, the extra field information will be copied in extraField\n            (extraFieldBufferSize is the size of the buffer).\n            This is the Central-header version of the extra field\n  if szComment!=NULL, the comment string of the file will be copied in szComment\n            (commentBufferSize is the size of the buffer)\n*/\n\n\n/** Addition for GDAL : START */\n\nextern ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64 OF((unzFile file));\n\n/** Addition for GDAL : END */\n\n\n/***************************************************************************/\n/* for reading the content of the current zipfile, you can open it, read data\n   from it, and close it (you can close it before reading all the file)\n   */\n\nextern int ZEXPORT unzOpenCurrentFile OF((unzFile file));\n/*\n  Open for reading data the current file in the zipfile.\n  If there is no error, the return value is UNZ_OK.\n*/\n\nextern int ZEXPORT unzOpenCurrentFilePassword OF((unzFile file,\n                                                  const char* password));\n/*\n  Open for reading data the current file in the zipfile.\n  password is a crypting password\n  If there is no error, the return value is UNZ_OK.\n*/\n\nextern int ZEXPORT unzOpenCurrentFile2 OF((unzFile file,\n                                           int* method,\n                                           int* level,\n                                           int raw));\n/*\n  Same than unzOpenCurrentFile, but open for read raw the file (not uncompress)\n    if raw==1\n  *method will receive method of compression, *level will receive level of\n     compression\n  note : you can set level parameter as NULL (if you did not want known level,\n         but you CANNOT set method parameter as NULL\n*/\n\nextern int ZEXPORT unzOpenCurrentFile3 OF((unzFile file,\n                                           int* method,\n                                           int* level,\n                                           int raw,\n                                           const char* password));\n/*\n  Same than unzOpenCurrentFile, but open for read raw the file (not uncompress)\n    if raw==1\n  *method will receive method of compression, *level will receive level of\n     compression\n  note : you can set level parameter as NULL (if you did not want known level,\n         but you CANNOT set method parameter as NULL\n*/\n\n\nextern int ZEXPORT unzCloseCurrentFile OF((unzFile file));\n/*\n  Close the file in zip opened with unzOpenCurrentFile\n  Return UNZ_CRCERROR if all the file was read but the CRC is not good\n*/\n\nextern int ZEXPORT unzReadCurrentFile OF((unzFile file,\n                      voidp buf,\n                      unsigned len));\n/*\n  Read bytes from the current file (opened by unzOpenCurrentFile)\n  buf contain buffer where data must be copied\n  len the size of buf.\n\n  return the number of byte copied if somes bytes are copied\n  return 0 if the end of file was reached\n  return <0 with error code if there is an error\n    (UNZ_ERRNO for IO error, or zLib error for uncompress error)\n*/\n\nextern z_off_t ZEXPORT unztell OF((unzFile file));\n\nextern ZPOS64_T ZEXPORT unztell64 OF((unzFile file));\n/*\n  Give the current position in uncompressed data\n*/\n\nextern int ZEXPORT unzeof OF((unzFile file));\n/*\n  return 1 if the end of file was reached, 0 elsewhere\n*/\n\nextern int ZEXPORT unzGetLocalExtrafield OF((unzFile file,\n                                             voidp buf,\n                                             unsigned len));\n/*\n  Read extra field from the current file (opened by unzOpenCurrentFile)\n  This is the local-header version of the extra field (sometimes, there is\n    more info in the local-header version than in the central-header)\n\n  if buf==NULL, it return the size of the local extra field\n\n  if buf!=NULL, len is the size of the buffer, the extra header is copied in\n    buf.\n  the return value is the number of bytes copied in buf, or (if <0)\n    the error code\n*/\n\n/***************************************************************************/\n\n/* Get the current file offset */\nextern ZPOS64_T ZEXPORT unzGetOffset64 (unzFile file);\nextern uLong ZEXPORT unzGetOffset (unzFile file);\n\n/* Set the current file offset */\nextern int ZEXPORT unzSetOffset64 (unzFile file, ZPOS64_T pos);\nextern int ZEXPORT unzSetOffset (unzFile file, uLong pos);\n\n\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* _unz64_H */\n"
  },
  {
    "path": "Libraries/Core/Android/Headers/minizip/zip.h",
    "content": "/* zip.h -- IO on .zip files using zlib\n   Version 1.1, February 14h, 2010\n   part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )\n\n         Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html )\n\n         Modifications for Zip64 support\n         Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )\n\n         For more info read MiniZip_info.txt\n\n         ---------------------------------------------------------------------------\n\n   Condition of use and distribution are the same than zlib :\n\n  This software is provided 'as-is', without any express or implied\n  warranty.  In no event will the authors be held liable for any damages\n  arising from the use of this software.\n\n  Permission is granted to anyone to use this software for any purpose,\n  including commercial applications, and to alter it and redistribute it\n  freely, subject to the following restrictions:\n\n  1. The origin of this software must not be misrepresented; you must not\n     claim that you wrote the original software. If you use this software\n     in a product, an acknowledgment in the product documentation would be\n     appreciated but is not required.\n  2. Altered source versions must be plainly marked as such, and must not be\n     misrepresented as being the original software.\n  3. This notice may not be removed or altered from any source distribution.\n\n        ---------------------------------------------------------------------------\n\n        Changes\n\n        See header of zip.h\n\n*/\n\n#ifndef _zip12_H\n#define _zip12_H\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n//#define HAVE_BZIP2\n\n#ifndef _ZLIB_H\n#include \"zlib.h\"\n#endif\n\n#ifndef _ZLIBIOAPI_H\n#include \"ioapi.h\"\n#endif\n\n#ifdef HAVE_BZIP2\n#include \"bzlib.h\"\n#endif\n\n#define Z_BZIP2ED 12\n\n#if defined(STRICTZIP) || defined(STRICTZIPUNZIP)\n/* like the STRICT of WIN32, we define a pointer that cannot be converted\n    from (void*) without cast */\ntypedef struct TagzipFile__ { int unused; } zipFile__;\ntypedef zipFile__ *zipFile;\n#else\ntypedef voidp zipFile;\n#endif\n\n#define ZIP_OK                          (0)\n#define ZIP_EOF                         (0)\n#define ZIP_ERRNO                       (Z_ERRNO)\n#define ZIP_PARAMERROR                  (-102)\n#define ZIP_BADZIPFILE                  (-103)\n#define ZIP_INTERNALERROR               (-104)\n\n#ifndef DEF_MEM_LEVEL\n#  if MAX_MEM_LEVEL >= 8\n#    define DEF_MEM_LEVEL 8\n#  else\n#    define DEF_MEM_LEVEL  MAX_MEM_LEVEL\n#  endif\n#endif\n/* default memLevel */\n\n/* tm_zip contain date/time info */\ntypedef struct tm_zip_s\n{\n    uInt tm_sec;            /* seconds after the minute - [0,59] */\n    uInt tm_min;            /* minutes after the hour - [0,59] */\n    uInt tm_hour;           /* hours since midnight - [0,23] */\n    uInt tm_mday;           /* day of the month - [1,31] */\n    uInt tm_mon;            /* months since January - [0,11] */\n    uInt tm_year;           /* years - [1980..2044] */\n} tm_zip;\n\ntypedef struct\n{\n    tm_zip      tmz_date;       /* date in understandable format           */\n    uLong       dosDate;       /* if dos_date == 0, tmu_date is used      */\n/*    uLong       flag;        */   /* general purpose bit flag        2 bytes */\n\n    uLong       internal_fa;    /* internal file attributes        2 bytes */\n    uLong       external_fa;    /* external file attributes        4 bytes */\n} zip_fileinfo;\n\ntypedef const char* zipcharpc;\n\n\n#define APPEND_STATUS_CREATE        (0)\n#define APPEND_STATUS_CREATEAFTER   (1)\n#define APPEND_STATUS_ADDINZIP      (2)\n\nextern zipFile ZEXPORT zipOpen OF((const char *pathname, int append));\nextern zipFile ZEXPORT zipOpen64 OF((const void *pathname, int append));\n/*\n  Create a zipfile.\n     pathname contain on Windows XP a filename like \"c:\\\\zlib\\\\zlib113.zip\" or on\n       an Unix computer \"zlib/zlib113.zip\".\n     if the file pathname exist and append==APPEND_STATUS_CREATEAFTER, the zip\n       will be created at the end of the file.\n         (useful if the file contain a self extractor code)\n     if the file pathname exist and append==APPEND_STATUS_ADDINZIP, we will\n       add files in existing zip (be sure you don't add file that doesn't exist)\n     If the zipfile cannot be opened, the return value is NULL.\n     Else, the return value is a zipFile Handle, usable with other function\n       of this zip package.\n*/\n\n/* Note : there is no delete function into a zipfile.\n   If you want delete file into a zipfile, you must open a zipfile, and create another\n   Of couse, you can use RAW reading and writing to copy the file you did not want delte\n*/\n\nextern zipFile ZEXPORT zipOpen2 OF((const char *pathname,\n                                   int append,\n                                   zipcharpc* globalcomment,\n                                   zlib_filefunc_def* pzlib_filefunc_def));\n\nextern zipFile ZEXPORT zipOpen2_64 OF((const void *pathname,\n                                   int append,\n                                   zipcharpc* globalcomment,\n                                   zlib_filefunc64_def* pzlib_filefunc_def));\n\nextern int ZEXPORT zipOpenNewFileInZip OF((zipFile file,\n                       const char* filename,\n                       const zip_fileinfo* zipfi,\n                       const void* extrafield_local,\n                       uInt size_extrafield_local,\n                       const void* extrafield_global,\n                       uInt size_extrafield_global,\n                       const char* comment,\n                       int method,\n                       int level));\n\nextern int ZEXPORT zipOpenNewFileInZip64 OF((zipFile file,\n                       const char* filename,\n                       const zip_fileinfo* zipfi,\n                       const void* extrafield_local,\n                       uInt size_extrafield_local,\n                       const void* extrafield_global,\n                       uInt size_extrafield_global,\n                       const char* comment,\n                       int method,\n                       int level,\n                       int zip64));\n\n/*\n  Open a file in the ZIP for writing.\n  filename : the filename in zip (if NULL, '-' without quote will be used\n  *zipfi contain supplemental information\n  if extrafield_local!=NULL and size_extrafield_local>0, extrafield_local\n    contains the extrafield data the the local header\n  if extrafield_global!=NULL and size_extrafield_global>0, extrafield_global\n    contains the extrafield data the the local header\n  if comment != NULL, comment contain the comment string\n  method contain the compression method (0 for store, Z_DEFLATED for deflate)\n  level contain the level of compression (can be Z_DEFAULT_COMPRESSION)\n  zip64 is set to 1 if a zip64 extended information block should be added to the local file header.\n                    this MUST be '1' if the uncompressed size is >= 0xffffffff.\n\n*/\n\n\nextern int ZEXPORT zipOpenNewFileInZip2 OF((zipFile file,\n                                            const char* filename,\n                                            const zip_fileinfo* zipfi,\n                                            const void* extrafield_local,\n                                            uInt size_extrafield_local,\n                                            const void* extrafield_global,\n                                            uInt size_extrafield_global,\n                                            const char* comment,\n                                            int method,\n                                            int level,\n                                            int raw));\n\n\nextern int ZEXPORT zipOpenNewFileInZip2_64 OF((zipFile file,\n                                            const char* filename,\n                                            const zip_fileinfo* zipfi,\n                                            const void* extrafield_local,\n                                            uInt size_extrafield_local,\n                                            const void* extrafield_global,\n                                            uInt size_extrafield_global,\n                                            const char* comment,\n                                            int method,\n                                            int level,\n                                            int raw,\n                                            int zip64));\n/*\n  Same than zipOpenNewFileInZip, except if raw=1, we write raw file\n */\n\nextern int ZEXPORT zipOpenNewFileInZip3 OF((zipFile file,\n                                            const char* filename,\n                                            const zip_fileinfo* zipfi,\n                                            const void* extrafield_local,\n                                            uInt size_extrafield_local,\n                                            const void* extrafield_global,\n                                            uInt size_extrafield_global,\n                                            const char* comment,\n                                            int method,\n                                            int level,\n                                            int raw,\n                                            int windowBits,\n                                            int memLevel,\n                                            int strategy,\n                                            const char* password,\n                                            uLong crcForCrypting));\n\nextern int ZEXPORT zipOpenNewFileInZip3_64 OF((zipFile file,\n                                            const char* filename,\n                                            const zip_fileinfo* zipfi,\n                                            const void* extrafield_local,\n                                            uInt size_extrafield_local,\n                                            const void* extrafield_global,\n                                            uInt size_extrafield_global,\n                                            const char* comment,\n                                            int method,\n                                            int level,\n                                            int raw,\n                                            int windowBits,\n                                            int memLevel,\n                                            int strategy,\n                                            const char* password,\n                                            uLong crcForCrypting,\n                                            int zip64\n                                            ));\n\n/*\n  Same than zipOpenNewFileInZip2, except\n    windowBits,memLevel,,strategy : see parameter strategy in deflateInit2\n    password : crypting password (NULL for no crypting)\n    crcForCrypting : crc of file to compress (needed for crypting)\n */\n\nextern int ZEXPORT zipOpenNewFileInZip4 OF((zipFile file,\n                                            const char* filename,\n                                            const zip_fileinfo* zipfi,\n                                            const void* extrafield_local,\n                                            uInt size_extrafield_local,\n                                            const void* extrafield_global,\n                                            uInt size_extrafield_global,\n                                            const char* comment,\n                                            int method,\n                                            int level,\n                                            int raw,\n                                            int windowBits,\n                                            int memLevel,\n                                            int strategy,\n                                            const char* password,\n                                            uLong crcForCrypting,\n                                            uLong versionMadeBy,\n                                            uLong flagBase\n                                            ));\n\n\nextern int ZEXPORT zipOpenNewFileInZip4_64 OF((zipFile file,\n                                            const char* filename,\n                                            const zip_fileinfo* zipfi,\n                                            const void* extrafield_local,\n                                            uInt size_extrafield_local,\n                                            const void* extrafield_global,\n                                            uInt size_extrafield_global,\n                                            const char* comment,\n                                            int method,\n                                            int level,\n                                            int raw,\n                                            int windowBits,\n                                            int memLevel,\n                                            int strategy,\n                                            const char* password,\n                                            uLong crcForCrypting,\n                                            uLong versionMadeBy,\n                                            uLong flagBase,\n                                            int zip64\n                                            ));\n/*\n  Same than zipOpenNewFileInZip4, except\n    versionMadeBy : value for Version made by field\n    flag : value for flag field (compression level info will be added)\n */\n\n\nextern int ZEXPORT zipWriteInFileInZip OF((zipFile file,\n                       const void* buf,\n                       unsigned len));\n/*\n  Write data in the zipfile\n*/\n\nextern int ZEXPORT zipCloseFileInZip OF((zipFile file));\n/*\n  Close the current file in the zipfile\n*/\n\nextern int ZEXPORT zipCloseFileInZipRaw OF((zipFile file,\n                                            uLong uncompressed_size,\n                                            uLong crc32));\n\nextern int ZEXPORT zipCloseFileInZipRaw64 OF((zipFile file,\n                                            ZPOS64_T uncompressed_size,\n                                            uLong crc32));\n\n/*\n  Close the current file in the zipfile, for file opened with\n    parameter raw=1 in zipOpenNewFileInZip2\n  uncompressed_size and crc32 are value for the uncompressed size\n*/\n\nextern int ZEXPORT zipClose OF((zipFile file,\n                const char* global_comment));\n/*\n  Close the zipfile\n*/\n\n\nextern int ZEXPORT zipRemoveExtraInfoBlock OF((char* pData, int* dataLen, short sHeader));\n/*\n  zipRemoveExtraInfoBlock -  Added by Mathias Svensson\n\n  Remove extra information block from a extra information data for the local file header or central directory header\n\n  It is needed to remove ZIP64 extra information blocks when before data is written if using RAW mode.\n\n  0x0001 is the signature header for the ZIP64 extra information blocks\n\n  usage.\n                        Remove ZIP64 Extra information from a central director extra field data\n              zipRemoveExtraInfoBlock(pCenDirExtraFieldData, &nCenDirExtraFieldDataLen, 0x0001);\n\n                        Remove ZIP64 Extra information from a Local File Header extra field data\n        zipRemoveExtraInfoBlock(pLocalHeaderExtraFieldData, &nLocalHeaderExtraFieldDataLen, 0x0001);\n*/\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* _zip64_H */\n"
  },
  {
    "path": "Libraries/Core/Android/Headers/png/png.h",
    "content": "\n/* png.h - header file for PNG reference library\n *\n * libpng version 1.6.10 - March 6, 2014\n * Copyright (c) 1998-2014 Glenn Randers-Pehrson\n * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)\n * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)\n *\n * This code is released under the libpng license (See LICENSE, below)\n *\n * Authors and maintainers:\n *   libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat\n *   libpng versions 0.89c, June 1996, through 0.96, May 1997: Andreas Dilger\n *   libpng versions 0.97, January 1998, through 1.6.10 - March 6, 2014: Glenn\n *   See also \"Contributing Authors\", below.\n *\n * Note about libpng version numbers:\n *\n *   Due to various miscommunications, unforeseen code incompatibilities\n *   and occasional factors outside the authors' control, version numbering\n *   on the library has not always been consistent and straightforward.\n *   The following table summarizes matters since version 0.89c, which was\n *   the first widely used release:\n *\n *    source                 png.h  png.h  shared-lib\n *    version                string   int  version\n *    -------                ------ -----  ----------\n *    0.89c \"1.0 beta 3\"     0.89      89  1.0.89\n *    0.90  \"1.0 beta 4\"     0.90      90  0.90  [should have been 2.0.90]\n *    0.95  \"1.0 beta 5\"     0.95      95  0.95  [should have been 2.0.95]\n *    0.96  \"1.0 beta 6\"     0.96      96  0.96  [should have been 2.0.96]\n *    0.97b \"1.00.97 beta 7\" 1.00.97   97  1.0.1 [should have been 2.0.97]\n *    0.97c                  0.97      97  2.0.97\n *    0.98                   0.98      98  2.0.98\n *    0.99                   0.99      98  2.0.99\n *    0.99a-m                0.99      99  2.0.99\n *    1.00                   1.00     100  2.1.0 [100 should be 10000]\n *    1.0.0      (from here on, the   100  2.1.0 [100 should be 10000]\n *    1.0.1       png.h string is   10001  2.1.0\n *    1.0.1a-e    identical to the  10002  from here on, the shared library\n *    1.0.2       source version)   10002  is 2.V where V is the source code\n *    1.0.2a-b                      10003  version, except as noted.\n *    1.0.3                         10003\n *    1.0.3a-d                      10004\n *    1.0.4                         10004\n *    1.0.4a-f                      10005\n *    1.0.5 (+ 2 patches)           10005\n *    1.0.5a-d                      10006\n *    1.0.5e-r                      10100 (not source compatible)\n *    1.0.5s-v                      10006 (not binary compatible)\n *    1.0.6 (+ 3 patches)           10006 (still binary incompatible)\n *    1.0.6d-f                      10007 (still binary incompatible)\n *    1.0.6g                        10007\n *    1.0.6h                        10007  10.6h (testing xy.z so-numbering)\n *    1.0.6i                        10007  10.6i\n *    1.0.6j                        10007  2.1.0.6j (incompatible with 1.0.0)\n *    1.0.7beta11-14        DLLNUM  10007  2.1.0.7beta11-14 (binary compatible)\n *    1.0.7beta15-18           1    10007  2.1.0.7beta15-18 (binary compatible)\n *    1.0.7rc1-2               1    10007  2.1.0.7rc1-2 (binary compatible)\n *    1.0.7                    1    10007  (still compatible)\n *    1.0.8beta1-4             1    10008  2.1.0.8beta1-4\n *    1.0.8rc1                 1    10008  2.1.0.8rc1\n *    1.0.8                    1    10008  2.1.0.8\n *    1.0.9beta1-6             1    10009  2.1.0.9beta1-6\n *    1.0.9rc1                 1    10009  2.1.0.9rc1\n *    1.0.9beta7-10            1    10009  2.1.0.9beta7-10\n *    1.0.9rc2                 1    10009  2.1.0.9rc2\n *    1.0.9                    1    10009  2.1.0.9\n *    1.0.10beta1              1    10010  2.1.0.10beta1\n *    1.0.10rc1                1    10010  2.1.0.10rc1\n *    1.0.10                   1    10010  2.1.0.10\n *    1.0.11beta1-3            1    10011  2.1.0.11beta1-3\n *    1.0.11rc1                1    10011  2.1.0.11rc1\n *    1.0.11                   1    10011  2.1.0.11\n *    1.0.12beta1-2            2    10012  2.1.0.12beta1-2\n *    1.0.12rc1                2    10012  2.1.0.12rc1\n *    1.0.12                   2    10012  2.1.0.12\n *    1.1.0a-f                 -    10100  2.1.1.0a-f (branch abandoned)\n *    1.2.0beta1-2             2    10200  2.1.2.0beta1-2\n *    1.2.0beta3-5             3    10200  3.1.2.0beta3-5\n *    1.2.0rc1                 3    10200  3.1.2.0rc1\n *    1.2.0                    3    10200  3.1.2.0\n *    1.2.1beta1-4             3    10201  3.1.2.1beta1-4\n *    1.2.1rc1-2               3    10201  3.1.2.1rc1-2\n *    1.2.1                    3    10201  3.1.2.1\n *    1.2.2beta1-6            12    10202  12.so.0.1.2.2beta1-6\n *    1.0.13beta1             10    10013  10.so.0.1.0.13beta1\n *    1.0.13rc1               10    10013  10.so.0.1.0.13rc1\n *    1.2.2rc1                12    10202  12.so.0.1.2.2rc1\n *    1.0.13                  10    10013  10.so.0.1.0.13\n *    1.2.2                   12    10202  12.so.0.1.2.2\n *    1.2.3rc1-6              12    10203  12.so.0.1.2.3rc1-6\n *    1.2.3                   12    10203  12.so.0.1.2.3\n *    1.2.4beta1-3            13    10204  12.so.0.1.2.4beta1-3\n *    1.0.14rc1               13    10014  10.so.0.1.0.14rc1\n *    1.2.4rc1                13    10204  12.so.0.1.2.4rc1\n *    1.0.14                  10    10014  10.so.0.1.0.14\n *    1.2.4                   13    10204  12.so.0.1.2.4\n *    1.2.5beta1-2            13    10205  12.so.0.1.2.5beta1-2\n *    1.0.15rc1-3             10    10015  10.so.0.1.0.15rc1-3\n *    1.2.5rc1-3              13    10205  12.so.0.1.2.5rc1-3\n *    1.0.15                  10    10015  10.so.0.1.0.15\n *    1.2.5                   13    10205  12.so.0.1.2.5\n *    1.2.6beta1-4            13    10206  12.so.0.1.2.6beta1-4\n *    1.0.16                  10    10016  10.so.0.1.0.16\n *    1.2.6                   13    10206  12.so.0.1.2.6\n *    1.2.7beta1-2            13    10207  12.so.0.1.2.7beta1-2\n *    1.0.17rc1               10    10017  12.so.0.1.0.17rc1\n *    1.2.7rc1                13    10207  12.so.0.1.2.7rc1\n *    1.0.17                  10    10017  12.so.0.1.0.17\n *    1.2.7                   13    10207  12.so.0.1.2.7\n *    1.2.8beta1-5            13    10208  12.so.0.1.2.8beta1-5\n *    1.0.18rc1-5             10    10018  12.so.0.1.0.18rc1-5\n *    1.2.8rc1-5              13    10208  12.so.0.1.2.8rc1-5\n *    1.0.18                  10    10018  12.so.0.1.0.18\n *    1.2.8                   13    10208  12.so.0.1.2.8\n *    1.2.9beta1-3            13    10209  12.so.0.1.2.9beta1-3\n *    1.2.9beta4-11           13    10209  12.so.0.9[.0]\n *    1.2.9rc1                13    10209  12.so.0.9[.0]\n *    1.2.9                   13    10209  12.so.0.9[.0]\n *    1.2.10beta1-7           13    10210  12.so.0.10[.0]\n *    1.2.10rc1-2             13    10210  12.so.0.10[.0]\n *    1.2.10                  13    10210  12.so.0.10[.0]\n *    1.4.0beta1-5            14    10400  14.so.0.0[.0]\n *    1.2.11beta1-4           13    10211  12.so.0.11[.0]\n *    1.4.0beta7-8            14    10400  14.so.0.0[.0]\n *    1.2.11                  13    10211  12.so.0.11[.0]\n *    1.2.12                  13    10212  12.so.0.12[.0]\n *    1.4.0beta9-14           14    10400  14.so.0.0[.0]\n *    1.2.13                  13    10213  12.so.0.13[.0]\n *    1.4.0beta15-36          14    10400  14.so.0.0[.0]\n *    1.4.0beta37-87          14    10400  14.so.14.0[.0]\n *    1.4.0rc01               14    10400  14.so.14.0[.0]\n *    1.4.0beta88-109         14    10400  14.so.14.0[.0]\n *    1.4.0rc02-08            14    10400  14.so.14.0[.0]\n *    1.4.0                   14    10400  14.so.14.0[.0]\n *    1.4.1beta01-03          14    10401  14.so.14.1[.0]\n *    1.4.1rc01               14    10401  14.so.14.1[.0]\n *    1.4.1beta04-12          14    10401  14.so.14.1[.0]\n *    1.4.1                   14    10401  14.so.14.1[.0]\n *    1.4.2                   14    10402  14.so.14.2[.0]\n *    1.4.3                   14    10403  14.so.14.3[.0]\n *    1.4.4                   14    10404  14.so.14.4[.0]\n *    1.5.0beta01-58          15    10500  15.so.15.0[.0]\n *    1.5.0rc01-07            15    10500  15.so.15.0[.0]\n *    1.5.0                   15    10500  15.so.15.0[.0]\n *    1.5.1beta01-11          15    10501  15.so.15.1[.0]\n *    1.5.1rc01-02            15    10501  15.so.15.1[.0]\n *    1.5.1                   15    10501  15.so.15.1[.0]\n *    1.5.2beta01-03          15    10502  15.so.15.2[.0]\n *    1.5.2rc01-03            15    10502  15.so.15.2[.0]\n *    1.5.2                   15    10502  15.so.15.2[.0]\n *    1.5.3beta01-10          15    10503  15.so.15.3[.0]\n *    1.5.3rc01-02            15    10503  15.so.15.3[.0]\n *    1.5.3beta11             15    10503  15.so.15.3[.0]\n *    1.5.3 [omitted]\n *    1.5.4beta01-08          15    10504  15.so.15.4[.0]\n *    1.5.4rc01               15    10504  15.so.15.4[.0]\n *    1.5.4                   15    10504  15.so.15.4[.0]\n *    1.5.5beta01-08          15    10505  15.so.15.5[.0]\n *    1.5.5rc01               15    10505  15.so.15.5[.0]\n *    1.5.5                   15    10505  15.so.15.5[.0]\n *    1.5.6beta01-07          15    10506  15.so.15.6[.0]\n *    1.5.6rc01-03            15    10506  15.so.15.6[.0]\n *    1.5.6                   15    10506  15.so.15.6[.0]\n *    1.5.7beta01-05          15    10507  15.so.15.7[.0]\n *    1.5.7rc01-03            15    10507  15.so.15.7[.0]\n *    1.5.7                   15    10507  15.so.15.7[.0]\n *    1.6.0beta01-40          16    10600  16.so.16.0[.0]\n *    1.6.0rc01-08            16    10600  16.so.16.0[.0]\n *    1.6.0                   16    10600  16.so.16.0[.0]\n *    1.6.1beta01-09          16    10601  16.so.16.1[.0]\n *    1.6.1rc01               16    10601  16.so.16.1[.0]\n *    1.6.1                   16    10601  16.so.16.1[.0]\n *    1.6.2beta01             16    10602  16.so.16.2[.0]\n *    1.6.2rc01-06            16    10602  16.so.16.2[.0]\n *    1.6.2                   16    10602  16.so.16.2[.0]\n *    1.6.3beta01-11          16    10603  16.so.16.3[.0]\n *    1.6.3rc01               16    10603  16.so.16.3[.0]\n *    1.6.3                   16    10603  16.so.16.3[.0]\n *    1.6.4beta01-02          16    10604  16.so.16.4[.0]\n *    1.6.4rc01               16    10604  16.so.16.4[.0]\n *    1.6.4                   16    10604  16.so.16.4[.0]\n *    1.6.5                   16    10605  16.so.16.5[.0]\n *    1.6.6                   16    10606  16.so.16.6[.0]\n *    1.6.7beta01-04          16    10607  16.so.16.7[.0]\n *    1.6.7rc01-03            16    10607  16.so.16.7[.0]\n *    1.6.7                   16    10607  16.so.16.7[.0]\n *    1.6.8beta01-02          16    10608  16.so.16.8[.0]\n *    1.6.8rc01-02            16    10608  16.so.16.8[.0]\n *    1.6.8                   16    10608  16.so.16.8[.0]\n *    1.6.9beta01-04          16    10609  16.so.16.9[.0]\n *    1.6.9rc01-02            16    10609  16.so.16.9[.0]\n *    1.6.9                   16    10609  16.so.16.9[.0]\n *    1.6.10beta01-03         16    10610  16.so.16.10[.0]\n *    1.6.10betarc01-04       16    10610  16.so.16.10[.0]\n *    1.6.10beta              16    10610  16.so.16.10[.0]\n *\n *   Henceforth the source version will match the shared-library major\n *   and minor numbers; the shared-library major version number will be\n *   used for changes in backward compatibility, as it is intended.  The\n *   PNG_LIBPNG_VER macro, which is not used within libpng but is available\n *   for applications, is an unsigned integer of the form xyyzz corresponding\n *   to the source version x.y.z (leading zeros in y and z).  Beta versions\n *   were given the previous public release number plus a letter, until\n *   version 1.0.6j; from then on they were given the upcoming public\n *   release number plus \"betaNN\" or \"rcNN\".\n *\n *   Binary incompatibility exists only when applications make direct access\n *   to the info_ptr or png_ptr members through png.h, and the compiled\n *   application is loaded with a different version of the library.\n *\n *   DLLNUM will change each time there are forward or backward changes\n *   in binary compatibility (e.g., when a new feature is added).\n *\n * See libpng-manual.txt or libpng.3 for more information.  The PNG\n * specification is available as a W3C Recommendation and as an ISO\n * Specification, <http://www.w3.org/TR/2003/REC-PNG-20031110/\n */\n\n/*\n * COPYRIGHT NOTICE, DISCLAIMER, and LICENSE:\n *\n * If you modify libpng you may insert additional notices immediately following\n * this sentence.\n *\n * This code is released under the libpng license.\n *\n * libpng versions 1.2.6, August 15, 2004, through 1.6.10, March 6, 2014, are\n * Copyright (c) 2004, 2006-2013 Glenn Randers-Pehrson, and are\n * distributed according to the same disclaimer and license as libpng-1.2.5\n * with the following individual added to the list of Contributing Authors:\n *\n *    Cosmin Truta\n *\n * libpng versions 1.0.7, July 1, 2000, through 1.2.5, October 3, 2002, are\n * Copyright (c) 2000-2002 Glenn Randers-Pehrson, and are\n * distributed according to the same disclaimer and license as libpng-1.0.6\n * with the following individuals added to the list of Contributing Authors:\n *\n *    Simon-Pierre Cadieux\n *    Eric S. Raymond\n *    Gilles Vollant\n *\n * and with the following additions to the disclaimer:\n *\n *    There is no warranty against interference with your enjoyment of the\n *    library or against infringement.  There is no warranty that our\n *    efforts or the library will fulfill any of your particular purposes\n *    or needs.  This library is provided with all faults, and the entire\n *    risk of satisfactory quality, performance, accuracy, and effort is with\n *    the user.\n *\n * libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are\n * Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson, and are\n * distributed according to the same disclaimer and license as libpng-0.96,\n * with the following individuals added to the list of Contributing Authors:\n *\n *    Tom Lane\n *    Glenn Randers-Pehrson\n *    Willem van Schaik\n *\n * libpng versions 0.89, June 1996, through 0.96, May 1997, are\n * Copyright (c) 1996, 1997 Andreas Dilger\n * Distributed according to the same disclaimer and license as libpng-0.88,\n * with the following individuals added to the list of Contributing Authors:\n *\n *    John Bowler\n *    Kevin Bracey\n *    Sam Bushell\n *    Magnus Holmgren\n *    Greg Roelofs\n *    Tom Tanner\n *\n * libpng versions 0.5, May 1995, through 0.88, January 1996, are\n * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.\n *\n * For the purposes of this copyright and license, \"Contributing Authors\"\n * is defined as the following set of individuals:\n *\n *    Andreas Dilger\n *    Dave Martindale\n *    Guy Eric Schalnat\n *    Paul Schmidt\n *    Tim Wegner\n *\n * The PNG Reference Library is supplied \"AS IS\".  The Contributing Authors\n * and Group 42, Inc. disclaim all warranties, expressed or implied,\n * including, without limitation, the warranties of merchantability and of\n * fitness for any purpose.  The Contributing Authors and Group 42, Inc.\n * assume no liability for direct, indirect, incidental, special, exemplary,\n * or consequential damages, which may result from the use of the PNG\n * Reference Library, even if advised of the possibility of such damage.\n *\n * Permission is hereby granted to use, copy, modify, and distribute this\n * source code, or portions hereof, for any purpose, without fee, subject\n * to the following restrictions:\n *\n *   1. The origin of this source code must not be misrepresented.\n *\n *   2. Altered versions must be plainly marked as such and must not\n *      be misrepresented as being the original source.\n *\n *   3. This Copyright notice may not be removed or altered from\n *      any source or altered source distribution.\n *\n * The Contributing Authors and Group 42, Inc. specifically permit, without\n * fee, and encourage the use of this source code as a component to\n * supporting the PNG file format in commercial products.  If you use this\n * source code in a product, acknowledgment is not required but would be\n * appreciated.\n */\n\n/*\n * A \"png_get_copyright\" function is available, for convenient use in \"about\"\n * boxes and the like:\n *\n *     printf(\"%s\", png_get_copyright(NULL));\n *\n * Also, the PNG logo (in PNG format, of course) is supplied in the\n * files \"pngbar.png\" and \"pngbar.jpg (88x31) and \"pngnow.png\" (98x31).\n */\n\n/*\n * Libpng is OSI Certified Open Source Software.  OSI Certified is a\n * certification mark of the Open Source Initiative.\n */\n\n/*\n * The contributing authors would like to thank all those who helped\n * with testing, bug fixes, and patience.  This wouldn't have been\n * possible without all of you.\n *\n * Thanks to Frank J. T. Wojcik for helping with the documentation.\n */\n\n/*\n * Y2K compliance in libpng:\n * =========================\n *\n *    March 6, 2014\n *\n *    Since the PNG Development group is an ad-hoc body, we can't make\n *    an official declaration.\n *\n *    This is your unofficial assurance that libpng from version 0.71 and\n *    upward through 1.6.10 are Y2K compliant.  It is my belief that\n *    earlier versions were also Y2K compliant.\n *\n *    Libpng only has two year fields.  One is a 2-byte unsigned integer\n *    that will hold years up to 65535.  The other, which is deprecated,\n *    holds the date in text format, and will hold years up to 9999.\n *\n *    The integer is\n *        \"png_uint_16 year\" in png_time_struct.\n *\n *    The string is\n *        \"char time_buffer[29]\" in png_struct.  This is no longer used\n *    in libpng-1.6.x and will be removed from libpng-1.7.0.\n *\n *    There are seven time-related functions:\n *        png.c: png_convert_to_rfc_1123_buffer() in png.c\n *          (formerly png_convert_to_rfc_1123() prior to libpng-1.5.x and\n *          png_convert_to_rfc_1152() in error prior to libpng-0.98)\n *        png_convert_from_struct_tm() in pngwrite.c, called in pngwrite.c\n *        png_convert_from_time_t() in pngwrite.c\n *        png_get_tIME() in pngget.c\n *        png_handle_tIME() in pngrutil.c, called in pngread.c\n *        png_set_tIME() in pngset.c\n *        png_write_tIME() in pngwutil.c, called in pngwrite.c\n *\n *    All handle dates properly in a Y2K environment.  The\n *    png_convert_from_time_t() function calls gmtime() to convert from system\n *    clock time, which returns (year - 1900), which we properly convert to\n *    the full 4-digit year.  There is a possibility that libpng applications\n *    are not passing 4-digit years into the png_convert_to_rfc_1123_buffer()\n *    function, or that they are incorrectly passing only a 2-digit year\n *    instead of \"year - 1900\" into the png_convert_from_struct_tm() function,\n *    but this is not under our control.  The libpng documentation has always\n *    stated that it works with 4-digit years, and the APIs have been\n *    documented as such.\n *\n *    The tIME chunk itself is also Y2K compliant.  It uses a 2-byte unsigned\n *    integer to hold the year, and can hold years as large as 65535.\n *\n *    zlib, upon which libpng depends, is also Y2K compliant.  It contains\n *    no date-related code.\n *\n *       Glenn Randers-Pehrson\n *       libpng maintainer\n *       PNG Development Group\n */\n\n#ifndef PNG_H\n#define PNG_H\n\n/* This is not the place to learn how to use libpng. The file libpng-manual.txt\n * describes how to use libpng, and the file example.c summarizes it\n * with some code on which to build.  This file is useful for looking\n * at the actual function definitions and structure components.\n *\n * If you just need to read a PNG file and don't want to read the documentation\n * skip to the end of this file and read the section entitled 'simplified API'.\n */\n\n/* Version information for png.h - this should match the version in png.c */\n#define PNG_LIBPNG_VER_STRING \"1.6.10\"\n#define PNG_HEADER_VERSION_STRING \\\n     \" libpng version 1.6.10 - March 6, 2014\\n\"\n\n#define PNG_LIBPNG_VER_SONUM   16\n#define PNG_LIBPNG_VER_DLLNUM  16\n\n/* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */\n#define PNG_LIBPNG_VER_MAJOR   1\n#define PNG_LIBPNG_VER_MINOR   6\n#define PNG_LIBPNG_VER_RELEASE 10\n\n/* This should match the numeric part of the final component of\n * PNG_LIBPNG_VER_STRING, omitting any leading zero:\n */\n\n#define PNG_LIBPNG_VER_BUILD  0\n\n/* Release Status */\n#define PNG_LIBPNG_BUILD_ALPHA    1\n#define PNG_LIBPNG_BUILD_BETA     2\n#define PNG_LIBPNG_BUILD_RC       3\n#define PNG_LIBPNG_BUILD_STABLE   4\n#define PNG_LIBPNG_BUILD_RELEASE_STATUS_MASK 7\n\n/* Release-Specific Flags */\n#define PNG_LIBPNG_BUILD_PATCH    8 /* Can be OR'ed with\n                                       PNG_LIBPNG_BUILD_STABLE only */\n#define PNG_LIBPNG_BUILD_PRIVATE 16 /* Cannot be OR'ed with\n                                       PNG_LIBPNG_BUILD_SPECIAL */\n#define PNG_LIBPNG_BUILD_SPECIAL 32 /* Cannot be OR'ed with\n                                       PNG_LIBPNG_BUILD_PRIVATE */\n\n#define PNG_LIBPNG_BUILD_BASE_TYPE PNG_LIBPNG_BUILD_STABLE\n\n/* Careful here.  At one time, Guy wanted to use 082, but that would be octal.\n * We must not include leading zeros.\n * Versions 0.7 through 1.0.0 were in the range 0 to 100 here (only\n * version 1.0.0 was mis-numbered 100 instead of 10000).  From\n * version 1.0.1 it's    xxyyzz, where x=major, y=minor, z=release\n */\n#define PNG_LIBPNG_VER 10610 /* 1.6.10 */\n\n/* Library configuration: these options cannot be changed after\n * the library has been built.\n */\n#ifndef PNGLCONF_H\n    /* If pnglibconf.h is missing, you can\n     * copy scripts/pnglibconf.h.prebuilt to pnglibconf.h\n     */\n#   include \"pnglibconf.h\"\n#endif\n\n#ifndef PNG_VERSION_INFO_ONLY\n   /* Machine specific configuration. */\n#  include \"pngconf.h\"\n#endif\n\n/*\n * Added at libpng-1.2.8\n *\n * Ref MSDN: Private as priority over Special\n * VS_FF_PRIVATEBUILD File *was not* built using standard release\n * procedures. If this value is given, the StringFileInfo block must\n * contain a PrivateBuild string.\n *\n * VS_FF_SPECIALBUILD File *was* built by the original company using\n * standard release procedures but is a variation of the standard\n * file of the same version number. If this value is given, the\n * StringFileInfo block must contain a SpecialBuild string.\n */\n\n#ifdef PNG_USER_PRIVATEBUILD /* From pnglibconf.h */\n#  define PNG_LIBPNG_BUILD_TYPE \\\n       (PNG_LIBPNG_BUILD_BASE_TYPE | PNG_LIBPNG_BUILD_PRIVATE)\n#else\n#  ifdef PNG_LIBPNG_SPECIALBUILD\n#    define PNG_LIBPNG_BUILD_TYPE \\\n         (PNG_LIBPNG_BUILD_BASE_TYPE | PNG_LIBPNG_BUILD_SPECIAL)\n#  else\n#    define PNG_LIBPNG_BUILD_TYPE (PNG_LIBPNG_BUILD_BASE_TYPE)\n#  endif\n#endif\n\n#ifndef PNG_VERSION_INFO_ONLY\n\n/* Inhibit C++ name-mangling for libpng functions but not for system calls. */\n#ifdef __cplusplus\nextern \"C\" {\n#endif /* __cplusplus */\n\n/* Version information for C files, stored in png.c.  This had better match\n * the version above.\n */\n#define png_libpng_ver png_get_header_ver(NULL)\n\n/* This file is arranged in several sections:\n *\n * 1. Any configuration options that can be specified by for the application\n *    code when it is built.  (Build time configuration is in pnglibconf.h)\n * 2. Type definitions (base types are defined in pngconf.h), structure\n *    definitions.\n * 3. Exported library functions.\n * 4. Simplified API.\n *\n * The library source code has additional files (principally pngpriv.h) that\n * allow configuration of the library.\n */\n/* Section 1: run time configuration\n * See pnglibconf.h for build time configuration\n *\n * Run time configuration allows the application to choose between\n * implementations of certain arithmetic APIs.  The default is set\n * at build time and recorded in pnglibconf.h, but it is safe to\n * override these (and only these) settings.  Note that this won't\n * change what the library does, only application code, and the\n * settings can (and probably should) be made on a per-file basis\n * by setting the #defines before including png.h\n *\n * Use macros to read integers from PNG data or use the exported\n * functions?\n *   PNG_USE_READ_MACROS: use the macros (see below)  Note that\n *     the macros evaluate their argument multiple times.\n *   PNG_NO_USE_READ_MACROS: call the relevant library function.\n *\n * Use the alternative algorithm for compositing alpha samples that\n * does not use division?\n *   PNG_READ_COMPOSITE_NODIV_SUPPORTED: use the 'no division'\n *      algorithm.\n *   PNG_NO_READ_COMPOSITE_NODIV: use the 'division' algorithm.\n *\n * How to handle benign errors if PNG_ALLOW_BENIGN_ERRORS is\n * false?\n *   PNG_ALLOW_BENIGN_ERRORS: map calls to the benign error\n *      APIs to png_warning.\n * Otherwise the calls are mapped to png_error.\n */\n\n/* Section 2: type definitions, including structures and compile time\n * constants.\n * See pngconf.h for base types that vary by machine/system\n */\n\n/* This triggers a compiler error in png.c, if png.c and png.h\n * do not agree upon the version number.\n */\ntypedef char* png_libpng_version_1_6_10;\n\n/* Basic control structions.  Read libpng-manual.txt or libpng.3 for more info.\n *\n * png_struct is the cache of information used while reading or writing a single\n * PNG file.  One of these is always required, although the simplified API\n * (below) hides the creation and destruction of it.\n */\ntypedef struct png_struct_def png_struct;\ntypedef const png_struct * png_const_structp;\ntypedef png_struct * png_structp;\ntypedef png_struct * * png_structpp;\n\n/* png_info contains information read from or to be written to a PNG file.  One\n * or more of these must exist while reading or creating a PNG file.  The\n * information is not used by libpng during read but is used to control what\n * gets written when a PNG file is created.  \"png_get_\" function calls read\n * information during read and \"png_set_\" functions calls write information\n * when creating a PNG.\n * been moved into a separate header file that is not accessible to\n * applications.  Read libpng-manual.txt or libpng.3 for more info.\n */\ntypedef struct png_info_def png_info;\ntypedef png_info * png_infop;\ntypedef const png_info * png_const_infop;\ntypedef png_info * * png_infopp;\n\n/* Types with names ending 'p' are pointer types.  The corresponding types with\n * names ending 'rp' are identical pointer types except that the pointer is\n * marked 'restrict', which means that it is the only pointer to the object\n * passed to the function.  Applications should not use the 'restrict' types;\n * it is always valid to pass 'p' to a pointer with a function argument of the\n * corresponding 'rp' type.  Different compilers have different rules with\n * regard to type matching in the presence of 'restrict'.  For backward\n * compatibility libpng callbacks never have 'restrict' in their parameters and,\n * consequentially, writing portable application code is extremely difficult if\n * an attempt is made to use 'restrict'.\n */\ntypedef png_struct * PNG_RESTRICT png_structrp;\ntypedef const png_struct * PNG_RESTRICT png_const_structrp;\ntypedef png_info * PNG_RESTRICT png_inforp;\ntypedef const png_info * PNG_RESTRICT png_const_inforp;\n\n/* Three color definitions.  The order of the red, green, and blue, (and the\n * exact size) is not important, although the size of the fields need to\n * be png_byte or png_uint_16 (as defined below).\n */\ntypedef struct png_color_struct\n{\n   png_byte red;\n   png_byte green;\n   png_byte blue;\n} png_color;\ntypedef png_color * png_colorp;\ntypedef const png_color * png_const_colorp;\ntypedef png_color * * png_colorpp;\n\ntypedef struct png_color_16_struct\n{\n   png_byte index;    /* used for palette files */\n   png_uint_16 red;   /* for use in red green blue files */\n   png_uint_16 green;\n   png_uint_16 blue;\n   png_uint_16 gray;  /* for use in grayscale files */\n} png_color_16;\ntypedef png_color_16 * png_color_16p;\ntypedef const png_color_16 * png_const_color_16p;\ntypedef png_color_16 * * png_color_16pp;\n\ntypedef struct png_color_8_struct\n{\n   png_byte red;   /* for use in red green blue files */\n   png_byte green;\n   png_byte blue;\n   png_byte gray;  /* for use in grayscale files */\n   png_byte alpha; /* for alpha channel files */\n} png_color_8;\ntypedef png_color_8 * png_color_8p;\ntypedef const png_color_8 * png_const_color_8p;\ntypedef png_color_8 * * png_color_8pp;\n\n/*\n * The following two structures are used for the in-core representation\n * of sPLT chunks.\n */\ntypedef struct png_sPLT_entry_struct\n{\n   png_uint_16 red;\n   png_uint_16 green;\n   png_uint_16 blue;\n   png_uint_16 alpha;\n   png_uint_16 frequency;\n} png_sPLT_entry;\ntypedef png_sPLT_entry * png_sPLT_entryp;\ntypedef const png_sPLT_entry * png_const_sPLT_entryp;\ntypedef png_sPLT_entry * * png_sPLT_entrypp;\n\n/*  When the depth of the sPLT palette is 8 bits, the color and alpha samples\n *  occupy the LSB of their respective members, and the MSB of each member\n *  is zero-filled.  The frequency member always occupies the full 16 bits.\n */\n\ntypedef struct png_sPLT_struct\n{\n   png_charp name;           /* palette name */\n   png_byte depth;           /* depth of palette samples */\n   png_sPLT_entryp entries;  /* palette entries */\n   png_int_32 nentries;      /* number of palette entries */\n} png_sPLT_t;\ntypedef png_sPLT_t * png_sPLT_tp;\ntypedef const png_sPLT_t * png_const_sPLT_tp;\ntypedef png_sPLT_t * * png_sPLT_tpp;\n\n#ifdef PNG_TEXT_SUPPORTED\n/* png_text holds the contents of a text/ztxt/itxt chunk in a PNG file,\n * and whether that contents is compressed or not.  The \"key\" field\n * points to a regular zero-terminated C string.  The \"text\" fields can be a\n * regular C string, an empty string, or a NULL pointer.\n * However, the structure returned by png_get_text() will always contain\n * the \"text\" field as a regular zero-terminated C string (possibly\n * empty), never a NULL pointer, so it can be safely used in printf() and\n * other string-handling functions.  Note that the \"itxt_length\", \"lang\", and\n * \"lang_key\" members of the structure only exist when the library is built\n * with iTXt chunk support.  Prior to libpng-1.4.0 the library was built by\n * default without iTXt support. Also note that when iTXt *is* supported,\n * the \"lang\" and \"lang_key\" fields contain NULL pointers when the\n * \"compression\" field contains * PNG_TEXT_COMPRESSION_NONE or\n * PNG_TEXT_COMPRESSION_zTXt. Note that the \"compression value\" is not the\n * same as what appears in the PNG tEXt/zTXt/iTXt chunk's \"compression flag\"\n * which is always 0 or 1, or its \"compression method\" which is always 0.\n */\ntypedef struct png_text_struct\n{\n   int  compression;       /* compression value:\n                             -1: tEXt, none\n                              0: zTXt, deflate\n                              1: iTXt, none\n                              2: iTXt, deflate  */\n   png_charp key;          /* keyword, 1-79 character description of \"text\" */\n   png_charp text;         /* comment, may be an empty string (ie \"\")\n                              or a NULL pointer */\n   png_size_t text_length; /* length of the text string */\n   png_size_t itxt_length; /* length of the itxt string */\n   png_charp lang;         /* language code, 0-79 characters\n                              or a NULL pointer */\n   png_charp lang_key;     /* keyword translated UTF-8 string, 0 or more\n                              chars or a NULL pointer */\n} png_text;\ntypedef png_text * png_textp;\ntypedef const png_text * png_const_textp;\ntypedef png_text * * png_textpp;\n#endif\n\n/* Supported compression types for text in PNG files (tEXt, and zTXt).\n * The values of the PNG_TEXT_COMPRESSION_ defines should NOT be changed. */\n#define PNG_TEXT_COMPRESSION_NONE_WR -3\n#define PNG_TEXT_COMPRESSION_zTXt_WR -2\n#define PNG_TEXT_COMPRESSION_NONE    -1\n#define PNG_TEXT_COMPRESSION_zTXt     0\n#define PNG_ITXT_COMPRESSION_NONE     1\n#define PNG_ITXT_COMPRESSION_zTXt     2\n#define PNG_TEXT_COMPRESSION_LAST     3  /* Not a valid value */\n\n/* png_time is a way to hold the time in an machine independent way.\n * Two conversions are provided, both from time_t and struct tm.  There\n * is no portable way to convert to either of these structures, as far\n * as I know.  If you know of a portable way, send it to me.  As a side\n * note - PNG has always been Year 2000 compliant!\n */\ntypedef struct png_time_struct\n{\n   png_uint_16 year; /* full year, as in, 1995 */\n   png_byte month;   /* month of year, 1 - 12 */\n   png_byte day;     /* day of month, 1 - 31 */\n   png_byte hour;    /* hour of day, 0 - 23 */\n   png_byte minute;  /* minute of hour, 0 - 59 */\n   png_byte second;  /* second of minute, 0 - 60 (for leap seconds) */\n} png_time;\ntypedef png_time * png_timep;\ntypedef const png_time * png_const_timep;\ntypedef png_time * * png_timepp;\n\n#if defined(PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED) ||\\\n   defined(PNG_USER_CHUNKS_SUPPORTED)\n/* png_unknown_chunk is a structure to hold queued chunks for which there is\n * no specific support.  The idea is that we can use this to queue\n * up private chunks for output even though the library doesn't actually\n * know about their semantics.\n *\n * The data in the structure is set by libpng on read and used on write.\n */\ntypedef struct png_unknown_chunk_t\n{\n    png_byte name[5]; /* Textual chunk name with '\\0' terminator */\n    png_byte *data;   /* Data, should not be modified on read! */\n    png_size_t size;\n\n    /* On write 'location' must be set using the flag values listed below.\n     * Notice that on read it is set by libpng however the values stored have\n     * more bits set than are listed below.  Always treat the value as a\n     * bitmask.  On write set only one bit - setting multiple bits may cause the\n     * chunk to be written in multiple places.\n     */\n    png_byte location; /* mode of operation at read time */\n}\npng_unknown_chunk;\n\ntypedef png_unknown_chunk * png_unknown_chunkp;\ntypedef const png_unknown_chunk * png_const_unknown_chunkp;\ntypedef png_unknown_chunk * * png_unknown_chunkpp;\n#endif\n\n/* Flag values for the unknown chunk location byte. */\n#define PNG_HAVE_IHDR  0x01\n#define PNG_HAVE_PLTE  0x02\n#define PNG_AFTER_IDAT 0x08\n\n/* Maximum positive integer used in PNG is (2^31)-1 */\n#define PNG_UINT_31_MAX ((png_uint_32)0x7fffffffL)\n#define PNG_UINT_32_MAX ((png_uint_32)(-1))\n#define PNG_SIZE_MAX ((png_size_t)(-1))\n\n/* These are constants for fixed point values encoded in the\n * PNG specification manner (x100000)\n */\n#define PNG_FP_1    100000\n#define PNG_FP_HALF  50000\n#define PNG_FP_MAX  ((png_fixed_point)0x7fffffffL)\n#define PNG_FP_MIN  (-PNG_FP_MAX)\n\n/* These describe the color_type field in png_info. */\n/* color type masks */\n#define PNG_COLOR_MASK_PALETTE    1\n#define PNG_COLOR_MASK_COLOR      2\n#define PNG_COLOR_MASK_ALPHA      4\n\n/* color types.  Note that not all combinations are legal */\n#define PNG_COLOR_TYPE_GRAY 0\n#define PNG_COLOR_TYPE_PALETTE  (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_PALETTE)\n#define PNG_COLOR_TYPE_RGB        (PNG_COLOR_MASK_COLOR)\n#define PNG_COLOR_TYPE_RGB_ALPHA  (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_ALPHA)\n#define PNG_COLOR_TYPE_GRAY_ALPHA (PNG_COLOR_MASK_ALPHA)\n/* aliases */\n#define PNG_COLOR_TYPE_RGBA  PNG_COLOR_TYPE_RGB_ALPHA\n#define PNG_COLOR_TYPE_GA  PNG_COLOR_TYPE_GRAY_ALPHA\n\n/* This is for compression type. PNG 1.0-1.2 only define the single type. */\n#define PNG_COMPRESSION_TYPE_BASE 0 /* Deflate method 8, 32K window */\n#define PNG_COMPRESSION_TYPE_DEFAULT PNG_COMPRESSION_TYPE_BASE\n\n/* This is for filter type. PNG 1.0-1.2 only define the single type. */\n#define PNG_FILTER_TYPE_BASE      0 /* Single row per-byte filtering */\n#define PNG_INTRAPIXEL_DIFFERENCING 64 /* Used only in MNG datastreams */\n#define PNG_FILTER_TYPE_DEFAULT   PNG_FILTER_TYPE_BASE\n\n/* These are for the interlacing type.  These values should NOT be changed. */\n#define PNG_INTERLACE_NONE        0 /* Non-interlaced image */\n#define PNG_INTERLACE_ADAM7       1 /* Adam7 interlacing */\n#define PNG_INTERLACE_LAST        2 /* Not a valid value */\n\n/* These are for the oFFs chunk.  These values should NOT be changed. */\n#define PNG_OFFSET_PIXEL          0 /* Offset in pixels */\n#define PNG_OFFSET_MICROMETER     1 /* Offset in micrometers (1/10^6 meter) */\n#define PNG_OFFSET_LAST           2 /* Not a valid value */\n\n/* These are for the pCAL chunk.  These values should NOT be changed. */\n#define PNG_EQUATION_LINEAR       0 /* Linear transformation */\n#define PNG_EQUATION_BASE_E       1 /* Exponential base e transform */\n#define PNG_EQUATION_ARBITRARY    2 /* Arbitrary base exponential transform */\n#define PNG_EQUATION_HYPERBOLIC   3 /* Hyperbolic sine transformation */\n#define PNG_EQUATION_LAST         4 /* Not a valid value */\n\n/* These are for the sCAL chunk.  These values should NOT be changed. */\n#define PNG_SCALE_UNKNOWN         0 /* unknown unit (image scale) */\n#define PNG_SCALE_METER           1 /* meters per pixel */\n#define PNG_SCALE_RADIAN          2 /* radians per pixel */\n#define PNG_SCALE_LAST            3 /* Not a valid value */\n\n/* These are for the pHYs chunk.  These values should NOT be changed. */\n#define PNG_RESOLUTION_UNKNOWN    0 /* pixels/unknown unit (aspect ratio) */\n#define PNG_RESOLUTION_METER      1 /* pixels/meter */\n#define PNG_RESOLUTION_LAST       2 /* Not a valid value */\n\n/* These are for the sRGB chunk.  These values should NOT be changed. */\n#define PNG_sRGB_INTENT_PERCEPTUAL 0\n#define PNG_sRGB_INTENT_RELATIVE   1\n#define PNG_sRGB_INTENT_SATURATION 2\n#define PNG_sRGB_INTENT_ABSOLUTE   3\n#define PNG_sRGB_INTENT_LAST       4 /* Not a valid value */\n\n/* This is for text chunks */\n#define PNG_KEYWORD_MAX_LENGTH     79\n\n/* Maximum number of entries in PLTE/sPLT/tRNS arrays */\n#define PNG_MAX_PALETTE_LENGTH    256\n\n/* These determine if an ancillary chunk's data has been successfully read\n * from the PNG header, or if the application has filled in the corresponding\n * data in the info_struct to be written into the output file.  The values\n * of the PNG_INFO_<chunk> defines should NOT be changed.\n */\n#define PNG_INFO_gAMA 0x0001\n#define PNG_INFO_sBIT 0x0002\n#define PNG_INFO_cHRM 0x0004\n#define PNG_INFO_PLTE 0x0008\n#define PNG_INFO_tRNS 0x0010\n#define PNG_INFO_bKGD 0x0020\n#define PNG_INFO_hIST 0x0040\n#define PNG_INFO_pHYs 0x0080\n#define PNG_INFO_oFFs 0x0100\n#define PNG_INFO_tIME 0x0200\n#define PNG_INFO_pCAL 0x0400\n#define PNG_INFO_sRGB 0x0800   /* GR-P, 0.96a */\n#define PNG_INFO_iCCP 0x1000   /* ESR, 1.0.6 */\n#define PNG_INFO_sPLT 0x2000   /* ESR, 1.0.6 */\n#define PNG_INFO_sCAL 0x4000   /* ESR, 1.0.6 */\n#define PNG_INFO_IDAT 0x8000   /* ESR, 1.0.6 */\n\n/* This is used for the transformation routines, as some of them\n * change these values for the row.  It also should enable using\n * the routines for other purposes.\n */\ntypedef struct png_row_info_struct\n{\n   png_uint_32 width;    /* width of row */\n   png_size_t rowbytes;  /* number of bytes in row */\n   png_byte color_type;  /* color type of row */\n   png_byte bit_depth;   /* bit depth of row */\n   png_byte channels;    /* number of channels (1, 2, 3, or 4) */\n   png_byte pixel_depth; /* bits per pixel (depth * channels) */\n} png_row_info;\n\ntypedef png_row_info * png_row_infop;\ntypedef png_row_info * * png_row_infopp;\n\n/* These are the function types for the I/O functions and for the functions\n * that allow the user to override the default I/O functions with his or her\n * own.  The png_error_ptr type should match that of user-supplied warning\n * and error functions, while the png_rw_ptr type should match that of the\n * user read/write data functions.  Note that the 'write' function must not\n * modify the buffer it is passed. The 'read' function, on the other hand, is\n * expected to return the read data in the buffer.\n */\ntypedef PNG_CALLBACK(void, *png_error_ptr, (png_structp, png_const_charp));\ntypedef PNG_CALLBACK(void, *png_rw_ptr, (png_structp, png_bytep, png_size_t));\ntypedef PNG_CALLBACK(void, *png_flush_ptr, (png_structp));\ntypedef PNG_CALLBACK(void, *png_read_status_ptr, (png_structp, png_uint_32,\n    int));\ntypedef PNG_CALLBACK(void, *png_write_status_ptr, (png_structp, png_uint_32,\n    int));\n\n#ifdef PNG_PROGRESSIVE_READ_SUPPORTED\ntypedef PNG_CALLBACK(void, *png_progressive_info_ptr, (png_structp, png_infop));\ntypedef PNG_CALLBACK(void, *png_progressive_end_ptr, (png_structp, png_infop));\n\n/* The following callback receives png_uint_32 row_number, int pass for the\n * png_bytep data of the row.  When transforming an interlaced image the\n * row number is the row number within the sub-image of the interlace pass, so\n * the value will increase to the height of the sub-image (not the full image)\n * then reset to 0 for the next pass.\n *\n * Use PNG_ROW_FROM_PASS_ROW(row, pass) and PNG_COL_FROM_PASS_COL(col, pass) to\n * find the output pixel (x,y) given an interlaced sub-image pixel\n * (row,col,pass).  (See below for these macros.)\n */\ntypedef PNG_CALLBACK(void, *png_progressive_row_ptr, (png_structp, png_bytep,\n    png_uint_32, int));\n#endif\n\n#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \\\n    defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)\ntypedef PNG_CALLBACK(void, *png_user_transform_ptr, (png_structp, png_row_infop,\n    png_bytep));\n#endif\n\n#ifdef PNG_USER_CHUNKS_SUPPORTED\ntypedef PNG_CALLBACK(int, *png_user_chunk_ptr, (png_structp,\n    png_unknown_chunkp));\n#endif\n#ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED\n/* not used anywhere */\n/* typedef PNG_CALLBACK(void, *png_unknown_chunk_ptr, (png_structp)); */\n#endif\n\n#ifdef PNG_SETJMP_SUPPORTED\n/* This must match the function definition in <setjmp.h>, and the application\n * must include this before png.h to obtain the definition of jmp_buf.  The\n * function is required to be PNG_NORETURN, but this is not checked.  If the\n * function does return the application will crash via an abort() or similar\n * system level call.\n *\n * If you get a warning here while building the library you may need to make\n * changes to ensure that pnglibconf.h records the calling convention used by\n * your compiler.  This may be very difficult - try using a different compiler\n * to build the library!\n */\nPNG_FUNCTION(void, (PNGCAPI *png_longjmp_ptr), PNGARG((jmp_buf, int)), typedef);\n#endif\n\n/* Transform masks for the high-level interface */\n#define PNG_TRANSFORM_IDENTITY       0x0000    /* read and write */\n#define PNG_TRANSFORM_STRIP_16       0x0001    /* read only */\n#define PNG_TRANSFORM_STRIP_ALPHA    0x0002    /* read only */\n#define PNG_TRANSFORM_PACKING        0x0004    /* read and write */\n#define PNG_TRANSFORM_PACKSWAP       0x0008    /* read and write */\n#define PNG_TRANSFORM_EXPAND         0x0010    /* read only */\n#define PNG_TRANSFORM_INVERT_MONO    0x0020    /* read and write */\n#define PNG_TRANSFORM_SHIFT          0x0040    /* read and write */\n#define PNG_TRANSFORM_BGR            0x0080    /* read and write */\n#define PNG_TRANSFORM_SWAP_ALPHA     0x0100    /* read and write */\n#define PNG_TRANSFORM_SWAP_ENDIAN    0x0200    /* read and write */\n#define PNG_TRANSFORM_INVERT_ALPHA   0x0400    /* read and write */\n#define PNG_TRANSFORM_STRIP_FILLER   0x0800    /* write only */\n/* Added to libpng-1.2.34 */\n#define PNG_TRANSFORM_STRIP_FILLER_BEFORE PNG_TRANSFORM_STRIP_FILLER\n#define PNG_TRANSFORM_STRIP_FILLER_AFTER 0x1000 /* write only */\n/* Added to libpng-1.4.0 */\n#define PNG_TRANSFORM_GRAY_TO_RGB   0x2000      /* read only */\n/* Added to libpng-1.5.4 */\n#define PNG_TRANSFORM_EXPAND_16     0x4000      /* read only */\n#define PNG_TRANSFORM_SCALE_16      0x8000      /* read only */\n\n/* Flags for MNG supported features */\n#define PNG_FLAG_MNG_EMPTY_PLTE     0x01\n#define PNG_FLAG_MNG_FILTER_64      0x04\n#define PNG_ALL_MNG_FEATURES        0x05\n\n/* NOTE: prior to 1.5 these functions had no 'API' style declaration,\n * this allowed the zlib default functions to be used on Windows\n * platforms.  In 1.5 the zlib default malloc (which just calls malloc and\n * ignores the first argument) should be completely compatible with the\n * following.\n */\ntypedef PNG_CALLBACK(png_voidp, *png_malloc_ptr, (png_structp,\n    png_alloc_size_t));\ntypedef PNG_CALLBACK(void, *png_free_ptr, (png_structp, png_voidp));\n\n/* Section 3: exported functions\n * Here are the function definitions most commonly used.  This is not\n * the place to find out how to use libpng.  See libpng-manual.txt for the\n * full explanation, see example.c for the summary.  This just provides\n * a simple one line description of the use of each function.\n *\n * The PNG_EXPORT() and PNG_EXPORTA() macros used below are defined in\n * pngconf.h and in the *.dfn files in the scripts directory.\n *\n *   PNG_EXPORT(ordinal, type, name, (args));\n *\n *       ordinal:    ordinal that is used while building\n *                   *.def files. The ordinal value is only\n *                   relevant when preprocessing png.h with\n *                   the *.dfn files for building symbol table\n *                   entries, and are removed by pngconf.h.\n *       type:       return type of the function\n *       name:       function name\n *       args:       function arguments, with types\n *\n * When we wish to append attributes to a function prototype we use\n * the PNG_EXPORTA() macro instead.\n *\n *   PNG_EXPORTA(ordinal, type, name, (args), attributes);\n *\n *       ordinal, type, name, and args: same as in PNG_EXPORT().\n *       attributes: function attributes\n */\n\n/* Returns the version number of the library */\nPNG_EXPORT(1, png_uint_32, png_access_version_number, (void));\n\n/* Tell lib we have already handled the first <num_bytes> magic bytes.\n * Handling more than 8 bytes from the beginning of the file is an error.\n */\nPNG_EXPORT(2, void, png_set_sig_bytes, (png_structrp png_ptr, int num_bytes));\n\n/* Check sig[start] through sig[start + num_to_check - 1] to see if it's a\n * PNG file.  Returns zero if the supplied bytes match the 8-byte PNG\n * signature, and non-zero otherwise.  Having num_to_check == 0 or\n * start > 7 will always fail (ie return non-zero).\n */\nPNG_EXPORT(3, int, png_sig_cmp, (png_const_bytep sig, png_size_t start,\n    png_size_t num_to_check));\n\n/* Simple signature checking function.  This is the same as calling\n * png_check_sig(sig, n) := !png_sig_cmp(sig, 0, n).\n */\n#define png_check_sig(sig, n) !png_sig_cmp((sig), 0, (n))\n\n/* Allocate and initialize png_ptr struct for reading, and any other memory. */\nPNG_EXPORTA(4, png_structp, png_create_read_struct,\n    (png_const_charp user_png_ver, png_voidp error_ptr,\n    png_error_ptr error_fn, png_error_ptr warn_fn),\n    PNG_ALLOCATED);\n\n/* Allocate and initialize png_ptr struct for writing, and any other memory */\nPNG_EXPORTA(5, png_structp, png_create_write_struct,\n    (png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn,\n    png_error_ptr warn_fn),\n    PNG_ALLOCATED);\n\nPNG_EXPORT(6, png_size_t, png_get_compression_buffer_size,\n    (png_const_structrp png_ptr));\n\nPNG_EXPORT(7, void, png_set_compression_buffer_size, (png_structrp png_ptr,\n    png_size_t size));\n\n/* Moved from pngconf.h in 1.4.0 and modified to ensure setjmp/longjmp\n * match up.\n */\n#ifdef PNG_SETJMP_SUPPORTED\n/* This function returns the jmp_buf built in to *png_ptr.  It must be\n * supplied with an appropriate 'longjmp' function to use on that jmp_buf\n * unless the default error function is overridden in which case NULL is\n * acceptable.  The size of the jmp_buf is checked against the actual size\n * allocated by the library - the call will return NULL on a mismatch\n * indicating an ABI mismatch.\n */\nPNG_EXPORT(8, jmp_buf*, png_set_longjmp_fn, (png_structrp png_ptr,\n    png_longjmp_ptr longjmp_fn, size_t jmp_buf_size));\n#  define png_jmpbuf(png_ptr) \\\n      (*png_set_longjmp_fn((png_ptr), longjmp, (sizeof (jmp_buf))))\n#else\n#  define png_jmpbuf(png_ptr) \\\n      (LIBPNG_WAS_COMPILED_WITH__PNG_NO_SETJMP)\n#endif\n/* This function should be used by libpng applications in place of\n * longjmp(png_ptr->jmpbuf, val).  If longjmp_fn() has been set, it\n * will use it; otherwise it will call PNG_ABORT().  This function was\n * added in libpng-1.5.0.\n */\nPNG_EXPORTA(9, void, png_longjmp, (png_const_structrp png_ptr, int val),\n    PNG_NORETURN);\n\n#ifdef PNG_READ_SUPPORTED\n/* Reset the compression stream */\nPNG_EXPORTA(10, int, png_reset_zstream, (png_structrp png_ptr), PNG_DEPRECATED);\n#endif\n\n/* New functions added in libpng-1.0.2 (not enabled by default until 1.2.0) */\n#ifdef PNG_USER_MEM_SUPPORTED\nPNG_EXPORTA(11, png_structp, png_create_read_struct_2,\n    (png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn,\n    png_error_ptr warn_fn,\n    png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn),\n    PNG_ALLOCATED);\nPNG_EXPORTA(12, png_structp, png_create_write_struct_2,\n    (png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn,\n    png_error_ptr warn_fn,\n    png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn),\n    PNG_ALLOCATED);\n#endif\n\n/* Write the PNG file signature. */\nPNG_EXPORT(13, void, png_write_sig, (png_structrp png_ptr));\n\n/* Write a PNG chunk - size, type, (optional) data, CRC. */\nPNG_EXPORT(14, void, png_write_chunk, (png_structrp png_ptr, png_const_bytep\n    chunk_name, png_const_bytep data, png_size_t length));\n\n/* Write the start of a PNG chunk - length and chunk name. */\nPNG_EXPORT(15, void, png_write_chunk_start, (png_structrp png_ptr,\n    png_const_bytep chunk_name, png_uint_32 length));\n\n/* Write the data of a PNG chunk started with png_write_chunk_start(). */\nPNG_EXPORT(16, void, png_write_chunk_data, (png_structrp png_ptr,\n    png_const_bytep data, png_size_t length));\n\n/* Finish a chunk started with png_write_chunk_start() (includes CRC). */\nPNG_EXPORT(17, void, png_write_chunk_end, (png_structrp png_ptr));\n\n/* Allocate and initialize the info structure */\nPNG_EXPORTA(18, png_infop, png_create_info_struct, (png_const_structrp png_ptr),\n    PNG_ALLOCATED);\n\n/* DEPRECATED: this function allowed init structures to be created using the\n * default allocation method (typically malloc).  Use is deprecated in 1.6.0 and\n * the API will be removed in the future.\n */\nPNG_EXPORTA(19, void, png_info_init_3, (png_infopp info_ptr,\n    png_size_t png_info_struct_size), PNG_DEPRECATED);\n\n/* Writes all the PNG information before the image. */\nPNG_EXPORT(20, void, png_write_info_before_PLTE,\n    (png_structrp png_ptr, png_const_inforp info_ptr));\nPNG_EXPORT(21, void, png_write_info,\n    (png_structrp png_ptr, png_const_inforp info_ptr));\n\n#ifdef PNG_SEQUENTIAL_READ_SUPPORTED\n/* Read the information before the actual image data. */\nPNG_EXPORT(22, void, png_read_info,\n    (png_structrp png_ptr, png_inforp info_ptr));\n#endif\n\n#ifdef PNG_TIME_RFC1123_SUPPORTED\n   /* Convert to a US string format: there is no localization support in this\n    * routine.  The original implementation used a 29 character buffer in\n    * png_struct, this will be removed in future versions.\n    */\n#if PNG_LIBPNG_VER < 10700\n/* To do: remove this from libpng17 (and from libpng17/png.c and pngstruct.h) */\nPNG_EXPORTA(23, png_const_charp, png_convert_to_rfc1123, (png_structrp png_ptr,\n    png_const_timep ptime),PNG_DEPRECATED);\n#endif\nPNG_EXPORT(241, int, png_convert_to_rfc1123_buffer, (char out[29],\n    png_const_timep ptime));\n#endif\n\n#ifdef PNG_CONVERT_tIME_SUPPORTED\n/* Convert from a struct tm to png_time */\nPNG_EXPORT(24, void, png_convert_from_struct_tm, (png_timep ptime,\n    const struct tm * ttime));\n\n/* Convert from time_t to png_time.  Uses gmtime() */\nPNG_EXPORT(25, void, png_convert_from_time_t, (png_timep ptime, time_t ttime));\n#endif /* PNG_CONVERT_tIME_SUPPORTED */\n\n#ifdef PNG_READ_EXPAND_SUPPORTED\n/* Expand data to 24-bit RGB, or 8-bit grayscale, with alpha if available. */\nPNG_EXPORT(26, void, png_set_expand, (png_structrp png_ptr));\nPNG_EXPORT(27, void, png_set_expand_gray_1_2_4_to_8, (png_structrp png_ptr));\nPNG_EXPORT(28, void, png_set_palette_to_rgb, (png_structrp png_ptr));\nPNG_EXPORT(29, void, png_set_tRNS_to_alpha, (png_structrp png_ptr));\n#endif\n\n#ifdef PNG_READ_EXPAND_16_SUPPORTED\n/* Expand to 16-bit channels, forces conversion of palette to RGB and expansion\n * of a tRNS chunk if present.\n */\nPNG_EXPORT(221, void, png_set_expand_16, (png_structrp png_ptr));\n#endif\n\n#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED)\n/* Use blue, green, red order for pixels. */\nPNG_EXPORT(30, void, png_set_bgr, (png_structrp png_ptr));\n#endif\n\n#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED\n/* Expand the grayscale to 24-bit RGB if necessary. */\nPNG_EXPORT(31, void, png_set_gray_to_rgb, (png_structrp png_ptr));\n#endif\n\n#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED\n/* Reduce RGB to grayscale. */\n#define PNG_ERROR_ACTION_NONE  1\n#define PNG_ERROR_ACTION_WARN  2\n#define PNG_ERROR_ACTION_ERROR 3\n#define PNG_RGB_TO_GRAY_DEFAULT (-1)/*for red/green coefficients*/\n\nPNG_FP_EXPORT(32, void, png_set_rgb_to_gray, (png_structrp png_ptr,\n    int error_action, double red, double green))\nPNG_FIXED_EXPORT(33, void, png_set_rgb_to_gray_fixed, (png_structrp png_ptr,\n    int error_action, png_fixed_point red, png_fixed_point green))\n\nPNG_EXPORT(34, png_byte, png_get_rgb_to_gray_status, (png_const_structrp\n    png_ptr));\n#endif\n\n#ifdef PNG_BUILD_GRAYSCALE_PALETTE_SUPPORTED\nPNG_EXPORT(35, void, png_build_grayscale_palette, (int bit_depth,\n    png_colorp palette));\n#endif\n\n#ifdef PNG_READ_ALPHA_MODE_SUPPORTED\n/* How the alpha channel is interpreted - this affects how the color channels\n * of a PNG file are returned to the calling application when an alpha channel,\n * or a tRNS chunk in a palette file, is present.\n *\n * This has no effect on the way pixels are written into a PNG output\n * datastream. The color samples in a PNG datastream are never premultiplied\n * with the alpha samples.\n *\n * The default is to return data according to the PNG specification: the alpha\n * channel is a linear measure of the contribution of the pixel to the\n * corresponding composited pixel, and the color channels are unassociated\n * (not premultiplied).  The gamma encoded color channels must be scaled\n * according to the contribution and to do this it is necessary to undo\n * the encoding, scale the color values, perform the composition and reencode\n * the values.  This is the 'PNG' mode.\n *\n * The alternative is to 'associate' the alpha with the color information by\n * storing color channel values that have been scaled by the alpha.\n * image.  These are the 'STANDARD', 'ASSOCIATED' or 'PREMULTIPLIED' modes\n * (the latter being the two common names for associated alpha color channels).\n *\n * For the 'OPTIMIZED' mode, a pixel is treated as opaque only if the alpha\n * value is equal to the maximum value.\n *\n * The final choice is to gamma encode the alpha channel as well.  This is\n * broken because, in practice, no implementation that uses this choice\n * correctly undoes the encoding before handling alpha composition.  Use this\n * choice only if other serious errors in the software or hardware you use\n * mandate it; the typical serious error is for dark halos to appear around\n * opaque areas of the composited PNG image because of arithmetic overflow.\n *\n * The API function png_set_alpha_mode specifies which of these choices to use\n * with an enumerated 'mode' value and the gamma of the required output:\n */\n#define PNG_ALPHA_PNG           0 /* according to the PNG standard */\n#define PNG_ALPHA_STANDARD      1 /* according to Porter/Duff */\n#define PNG_ALPHA_ASSOCIATED    1 /* as above; this is the normal practice */\n#define PNG_ALPHA_PREMULTIPLIED 1 /* as above */\n#define PNG_ALPHA_OPTIMIZED     2 /* 'PNG' for opaque pixels, else 'STANDARD' */\n#define PNG_ALPHA_BROKEN        3 /* the alpha channel is gamma encoded */\n\nPNG_FP_EXPORT(227, void, png_set_alpha_mode, (png_structrp png_ptr, int mode,\n    double output_gamma))\nPNG_FIXED_EXPORT(228, void, png_set_alpha_mode_fixed, (png_structrp png_ptr,\n    int mode, png_fixed_point output_gamma))\n#endif\n\n#if defined(PNG_GAMMA_SUPPORTED) || defined(PNG_READ_ALPHA_MODE_SUPPORTED)\n/* The output_gamma value is a screen gamma in libpng terminology: it expresses\n * how to decode the output values, not how they are encoded.\n */\n#define PNG_DEFAULT_sRGB -1       /* sRGB gamma and color space */\n#define PNG_GAMMA_MAC_18 -2       /* Old Mac '1.8' gamma and color space */\n#define PNG_GAMMA_sRGB   220000   /* Television standards--matches sRGB gamma */\n#define PNG_GAMMA_LINEAR PNG_FP_1 /* Linear */\n#endif\n\n/* The following are examples of calls to png_set_alpha_mode to achieve the\n * required overall gamma correction and, where necessary, alpha\n * premultiplication.\n *\n * png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_DEFAULT_sRGB);\n *    This is the default libpng handling of the alpha channel - it is not\n *    pre-multiplied into the color components.  In addition the call states\n *    that the output is for a sRGB system and causes all PNG files without gAMA\n *    chunks to be assumed to be encoded using sRGB.\n *\n * png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_GAMMA_MAC);\n *    In this case the output is assumed to be something like an sRGB conformant\n *    display preceeded by a power-law lookup table of power 1.45.  This is how\n *    early Mac systems behaved.\n *\n * png_set_alpha_mode(pp, PNG_ALPHA_STANDARD, PNG_GAMMA_LINEAR);\n *    This is the classic Jim Blinn approach and will work in academic\n *    environments where everything is done by the book.  It has the shortcoming\n *    of assuming that input PNG data with no gamma information is linear - this\n *    is unlikely to be correct unless the PNG files where generated locally.\n *    Most of the time the output precision will be so low as to show\n *    significant banding in dark areas of the image.\n *\n * png_set_expand_16(pp);\n * png_set_alpha_mode(pp, PNG_ALPHA_STANDARD, PNG_DEFAULT_sRGB);\n *    This is a somewhat more realistic Jim Blinn inspired approach.  PNG files\n *    are assumed to have the sRGB encoding if not marked with a gamma value and\n *    the output is always 16 bits per component.  This permits accurate scaling\n *    and processing of the data.  If you know that your input PNG files were\n *    generated locally you might need to replace PNG_DEFAULT_sRGB with the\n *    correct value for your system.\n *\n * png_set_alpha_mode(pp, PNG_ALPHA_OPTIMIZED, PNG_DEFAULT_sRGB);\n *    If you just need to composite the PNG image onto an existing background\n *    and if you control the code that does this you can use the optimization\n *    setting.  In this case you just copy completely opaque pixels to the\n *    output.  For pixels that are not completely transparent (you just skip\n *    those) you do the composition math using png_composite or png_composite_16\n *    below then encode the resultant 8-bit or 16-bit values to match the output\n *    encoding.\n *\n * Other cases\n *    If neither the PNG nor the standard linear encoding work for you because\n *    of the software or hardware you use then you have a big problem.  The PNG\n *    case will probably result in halos around the image.  The linear encoding\n *    will probably result in a washed out, too bright, image (it's actually too\n *    contrasty.)  Try the ALPHA_OPTIMIZED mode above - this will probably\n *    substantially reduce the halos.  Alternatively try:\n *\n * png_set_alpha_mode(pp, PNG_ALPHA_BROKEN, PNG_DEFAULT_sRGB);\n *    This option will also reduce the halos, but there will be slight dark\n *    halos round the opaque parts of the image where the background is light.\n *    In the OPTIMIZED mode the halos will be light halos where the background\n *    is dark.  Take your pick - the halos are unavoidable unless you can get\n *    your hardware/software fixed!  (The OPTIMIZED approach is slightly\n *    faster.)\n *\n * When the default gamma of PNG files doesn't match the output gamma.\n *    If you have PNG files with no gamma information png_set_alpha_mode allows\n *    you to provide a default gamma, but it also sets the ouput gamma to the\n *    matching value.  If you know your PNG files have a gamma that doesn't\n *    match the output you can take advantage of the fact that\n *    png_set_alpha_mode always sets the output gamma but only sets the PNG\n *    default if it is not already set:\n *\n * png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_DEFAULT_sRGB);\n * png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_GAMMA_MAC);\n *    The first call sets both the default and the output gamma values, the\n *    second call overrides the output gamma without changing the default.  This\n *    is easier than achieving the same effect with png_set_gamma.  You must use\n *    PNG_ALPHA_PNG for the first call - internal checking in png_set_alpha will\n *    fire if more than one call to png_set_alpha_mode and png_set_background is\n *    made in the same read operation, however multiple calls with PNG_ALPHA_PNG\n *    are ignored.\n */\n\n#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED\nPNG_EXPORT(36, void, png_set_strip_alpha, (png_structrp png_ptr));\n#endif\n\n#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) || \\\n    defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED)\nPNG_EXPORT(37, void, png_set_swap_alpha, (png_structrp png_ptr));\n#endif\n\n#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) || \\\n    defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED)\nPNG_EXPORT(38, void, png_set_invert_alpha, (png_structrp png_ptr));\n#endif\n\n#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED)\n/* Add a filler byte to 8-bit Gray or 24-bit RGB images. */\nPNG_EXPORT(39, void, png_set_filler, (png_structrp png_ptr, png_uint_32 filler,\n    int flags));\n/* The values of the PNG_FILLER_ defines should NOT be changed */\n#  define PNG_FILLER_BEFORE 0\n#  define PNG_FILLER_AFTER 1\n/* Add an alpha byte to 8-bit Gray or 24-bit RGB images. */\nPNG_EXPORT(40, void, png_set_add_alpha, (png_structrp png_ptr,\n    png_uint_32 filler, int flags));\n#endif /* PNG_READ_FILLER_SUPPORTED || PNG_WRITE_FILLER_SUPPORTED */\n\n#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED)\n/* Swap bytes in 16-bit depth files. */\nPNG_EXPORT(41, void, png_set_swap, (png_structrp png_ptr));\n#endif\n\n#if defined(PNG_READ_PACK_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED)\n/* Use 1 byte per pixel in 1, 2, or 4-bit depth files. */\nPNG_EXPORT(42, void, png_set_packing, (png_structrp png_ptr));\n#endif\n\n#if defined(PNG_READ_PACKSWAP_SUPPORTED) || \\\n    defined(PNG_WRITE_PACKSWAP_SUPPORTED)\n/* Swap packing order of pixels in bytes. */\nPNG_EXPORT(43, void, png_set_packswap, (png_structrp png_ptr));\n#endif\n\n#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED)\n/* Converts files to legal bit depths. */\nPNG_EXPORT(44, void, png_set_shift, (png_structrp png_ptr, png_const_color_8p\n    true_bits));\n#endif\n\n#if defined(PNG_READ_INTERLACING_SUPPORTED) || \\\n    defined(PNG_WRITE_INTERLACING_SUPPORTED)\n/* Have the code handle the interlacing.  Returns the number of passes.\n * MUST be called before png_read_update_info or png_start_read_image,\n * otherwise it will not have the desired effect.  Note that it is still\n * necessary to call png_read_row or png_read_rows png_get_image_height\n * times for each pass.\n*/\nPNG_EXPORT(45, int, png_set_interlace_handling, (png_structrp png_ptr));\n#endif\n\n#if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED)\n/* Invert monochrome files */\nPNG_EXPORT(46, void, png_set_invert_mono, (png_structrp png_ptr));\n#endif\n\n#ifdef PNG_READ_BACKGROUND_SUPPORTED\n/* Handle alpha and tRNS by replacing with a background color.  Prior to\n * libpng-1.5.4 this API must not be called before the PNG file header has been\n * read.  Doing so will result in unexpected behavior and possible warnings or\n * errors if the PNG file contains a bKGD chunk.\n */\nPNG_FP_EXPORT(47, void, png_set_background, (png_structrp png_ptr,\n    png_const_color_16p background_color, int background_gamma_code,\n    int need_expand, double background_gamma))\nPNG_FIXED_EXPORT(215, void, png_set_background_fixed, (png_structrp png_ptr,\n    png_const_color_16p background_color, int background_gamma_code,\n    int need_expand, png_fixed_point background_gamma))\n#endif\n#ifdef PNG_READ_BACKGROUND_SUPPORTED\n#  define PNG_BACKGROUND_GAMMA_UNKNOWN 0\n#  define PNG_BACKGROUND_GAMMA_SCREEN  1\n#  define PNG_BACKGROUND_GAMMA_FILE    2\n#  define PNG_BACKGROUND_GAMMA_UNIQUE  3\n#endif\n\n#ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED\n/* Scale a 16-bit depth file down to 8-bit, accurately. */\nPNG_EXPORT(229, void, png_set_scale_16, (png_structrp png_ptr));\n#endif\n\n#ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED\n#define PNG_READ_16_TO_8 SUPPORTED /* Name prior to 1.5.4 */\n/* Strip the second byte of information from a 16-bit depth file. */\nPNG_EXPORT(48, void, png_set_strip_16, (png_structrp png_ptr));\n#endif\n\n#ifdef PNG_READ_QUANTIZE_SUPPORTED\n/* Turn on quantizing, and reduce the palette to the number of colors\n * available.\n */\nPNG_EXPORT(49, void, png_set_quantize, (png_structrp png_ptr,\n    png_colorp palette, int num_palette, int maximum_colors,\n    png_const_uint_16p histogram, int full_quantize));\n#endif\n\n#ifdef PNG_READ_GAMMA_SUPPORTED\n/* The threshold on gamma processing is configurable but hard-wired into the\n * library.  The following is the floating point variant.\n */\n#define PNG_GAMMA_THRESHOLD (PNG_GAMMA_THRESHOLD_FIXED*.00001)\n\n/* Handle gamma correction. Screen_gamma=(display_exponent).\n * NOTE: this API simply sets the screen and file gamma values. It will\n * therefore override the value for gamma in a PNG file if it is called after\n * the file header has been read - use with care  - call before reading the PNG\n * file for best results!\n *\n * These routines accept the same gamma values as png_set_alpha_mode (described\n * above).  The PNG_GAMMA_ defines and PNG_DEFAULT_sRGB can be passed to either\n * API (floating point or fixed.)  Notice, however, that the 'file_gamma' value\n * is the inverse of a 'screen gamma' value.\n */\nPNG_FP_EXPORT(50, void, png_set_gamma, (png_structrp png_ptr,\n    double screen_gamma, double override_file_gamma))\nPNG_FIXED_EXPORT(208, void, png_set_gamma_fixed, (png_structrp png_ptr,\n    png_fixed_point screen_gamma, png_fixed_point override_file_gamma))\n#endif\n\n#ifdef PNG_WRITE_FLUSH_SUPPORTED\n/* Set how many lines between output flushes - 0 for no flushing */\nPNG_EXPORT(51, void, png_set_flush, (png_structrp png_ptr, int nrows));\n/* Flush the current PNG output buffer */\nPNG_EXPORT(52, void, png_write_flush, (png_structrp png_ptr));\n#endif\n\n/* Optional update palette with requested transformations */\nPNG_EXPORT(53, void, png_start_read_image, (png_structrp png_ptr));\n\n/* Optional call to update the users info structure */\nPNG_EXPORT(54, void, png_read_update_info, (png_structrp png_ptr,\n    png_inforp info_ptr));\n\n#ifdef PNG_SEQUENTIAL_READ_SUPPORTED\n/* Read one or more rows of image data. */\nPNG_EXPORT(55, void, png_read_rows, (png_structrp png_ptr, png_bytepp row,\n    png_bytepp display_row, png_uint_32 num_rows));\n#endif\n\n#ifdef PNG_SEQUENTIAL_READ_SUPPORTED\n/* Read a row of data. */\nPNG_EXPORT(56, void, png_read_row, (png_structrp png_ptr, png_bytep row,\n    png_bytep display_row));\n#endif\n\n#ifdef PNG_SEQUENTIAL_READ_SUPPORTED\n/* Read the whole image into memory at once. */\nPNG_EXPORT(57, void, png_read_image, (png_structrp png_ptr, png_bytepp image));\n#endif\n\n/* Write a row of image data */\nPNG_EXPORT(58, void, png_write_row, (png_structrp png_ptr,\n    png_const_bytep row));\n\n/* Write a few rows of image data: (*row) is not written; however, the type\n * is declared as writeable to maintain compatibility with previous versions\n * of libpng and to allow the 'display_row' array from read_rows to be passed\n * unchanged to write_rows.\n */\nPNG_EXPORT(59, void, png_write_rows, (png_structrp png_ptr, png_bytepp row,\n    png_uint_32 num_rows));\n\n/* Write the image data */\nPNG_EXPORT(60, void, png_write_image, (png_structrp png_ptr, png_bytepp image));\n\n/* Write the end of the PNG file. */\nPNG_EXPORT(61, void, png_write_end, (png_structrp png_ptr,\n    png_inforp info_ptr));\n\n#ifdef PNG_SEQUENTIAL_READ_SUPPORTED\n/* Read the end of the PNG file. */\nPNG_EXPORT(62, void, png_read_end, (png_structrp png_ptr, png_inforp info_ptr));\n#endif\n\n/* Free any memory associated with the png_info_struct */\nPNG_EXPORT(63, void, png_destroy_info_struct, (png_const_structrp png_ptr,\n    png_infopp info_ptr_ptr));\n\n/* Free any memory associated with the png_struct and the png_info_structs */\nPNG_EXPORT(64, void, png_destroy_read_struct, (png_structpp png_ptr_ptr,\n    png_infopp info_ptr_ptr, png_infopp end_info_ptr_ptr));\n\n/* Free any memory associated with the png_struct and the png_info_structs */\nPNG_EXPORT(65, void, png_destroy_write_struct, (png_structpp png_ptr_ptr,\n    png_infopp info_ptr_ptr));\n\n/* Set the libpng method of handling chunk CRC errors */\nPNG_EXPORT(66, void, png_set_crc_action, (png_structrp png_ptr, int crit_action,\n    int ancil_action));\n\n/* Values for png_set_crc_action() say how to handle CRC errors in\n * ancillary and critical chunks, and whether to use the data contained\n * therein.  Note that it is impossible to \"discard\" data in a critical\n * chunk.  For versions prior to 0.90, the action was always error/quit,\n * whereas in version 0.90 and later, the action for CRC errors in ancillary\n * chunks is warn/discard.  These values should NOT be changed.\n *\n *      value                       action:critical     action:ancillary\n */\n#define PNG_CRC_DEFAULT       0  /* error/quit          warn/discard data */\n#define PNG_CRC_ERROR_QUIT    1  /* error/quit          error/quit        */\n#define PNG_CRC_WARN_DISCARD  2  /* (INVALID)           warn/discard data */\n#define PNG_CRC_WARN_USE      3  /* warn/use data       warn/use data     */\n#define PNG_CRC_QUIET_USE     4  /* quiet/use data      quiet/use data    */\n#define PNG_CRC_NO_CHANGE     5  /* use current value   use current value */\n\n/* These functions give the user control over the scan-line filtering in\n * libpng and the compression methods used by zlib.  These functions are\n * mainly useful for testing, as the defaults should work with most users.\n * Those users who are tight on memory or want faster performance at the\n * expense of compression can modify them.  See the compression library\n * header file (zlib.h) for an explination of the compression functions.\n */\n\n/* Set the filtering method(s) used by libpng.  Currently, the only valid\n * value for \"method\" is 0.\n */\nPNG_EXPORT(67, void, png_set_filter, (png_structrp png_ptr, int method,\n    int filters));\n\n/* Flags for png_set_filter() to say which filters to use.  The flags\n * are chosen so that they don't conflict with real filter types\n * below, in case they are supplied instead of the #defined constants.\n * These values should NOT be changed.\n */\n#define PNG_NO_FILTERS     0x00\n#define PNG_FILTER_NONE    0x08\n#define PNG_FILTER_SUB     0x10\n#define PNG_FILTER_UP      0x20\n#define PNG_FILTER_AVG     0x40\n#define PNG_FILTER_PAETH   0x80\n#define PNG_ALL_FILTERS (PNG_FILTER_NONE | PNG_FILTER_SUB | PNG_FILTER_UP | \\\n                         PNG_FILTER_AVG | PNG_FILTER_PAETH)\n\n/* Filter values (not flags) - used in pngwrite.c, pngwutil.c for now.\n * These defines should NOT be changed.\n */\n#define PNG_FILTER_VALUE_NONE  0\n#define PNG_FILTER_VALUE_SUB   1\n#define PNG_FILTER_VALUE_UP    2\n#define PNG_FILTER_VALUE_AVG   3\n#define PNG_FILTER_VALUE_PAETH 4\n#define PNG_FILTER_VALUE_LAST  5\n\n#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED /* EXPERIMENTAL */\n/* The \"heuristic_method\" is given by one of the PNG_FILTER_HEURISTIC_\n * defines, either the default (minimum-sum-of-absolute-differences), or\n * the experimental method (weighted-minimum-sum-of-absolute-differences).\n *\n * Weights are factors >= 1.0, indicating how important it is to keep the\n * filter type consistent between rows.  Larger numbers mean the current\n * filter is that many times as likely to be the same as the \"num_weights\"\n * previous filters.  This is cumulative for each previous row with a weight.\n * There needs to be \"num_weights\" values in \"filter_weights\", or it can be\n * NULL if the weights aren't being specified.  Weights have no influence on\n * the selection of the first row filter.  Well chosen weights can (in theory)\n * improve the compression for a given image.\n *\n * Costs are factors >= 1.0 indicating the relative decoding costs of a\n * filter type.  Higher costs indicate more decoding expense, and are\n * therefore less likely to be selected over a filter with lower computational\n * costs.  There needs to be a value in \"filter_costs\" for each valid filter\n * type (given by PNG_FILTER_VALUE_LAST), or it can be NULL if you aren't\n * setting the costs.  Costs try to improve the speed of decompression without\n * unduly increasing the compressed image size.\n *\n * A negative weight or cost indicates the default value is to be used, and\n * values in the range [0.0, 1.0) indicate the value is to remain unchanged.\n * The default values for both weights and costs are currently 1.0, but may\n * change if good general weighting/cost heuristics can be found.  If both\n * the weights and costs are set to 1.0, this degenerates the WEIGHTED method\n * to the UNWEIGHTED method, but with added encoding time/computation.\n */\nPNG_FP_EXPORT(68, void, png_set_filter_heuristics, (png_structrp png_ptr,\n    int heuristic_method, int num_weights, png_const_doublep filter_weights,\n    png_const_doublep filter_costs))\nPNG_FIXED_EXPORT(209, void, png_set_filter_heuristics_fixed,\n    (png_structrp png_ptr, int heuristic_method, int num_weights,\n    png_const_fixed_point_p filter_weights,\n    png_const_fixed_point_p filter_costs))\n#endif /*  PNG_WRITE_WEIGHTED_FILTER_SUPPORTED */\n\n/* Heuristic used for row filter selection.  These defines should NOT be\n * changed.\n */\n#define PNG_FILTER_HEURISTIC_DEFAULT    0  /* Currently \"UNWEIGHTED\" */\n#define PNG_FILTER_HEURISTIC_UNWEIGHTED 1  /* Used by libpng < 0.95 */\n#define PNG_FILTER_HEURISTIC_WEIGHTED   2  /* Experimental feature */\n#define PNG_FILTER_HEURISTIC_LAST       3  /* Not a valid value */\n\n#ifdef PNG_WRITE_SUPPORTED\n/* Set the library compression level.  Currently, valid values range from\n * 0 - 9, corresponding directly to the zlib compression levels 0 - 9\n * (0 - no compression, 9 - \"maximal\" compression).  Note that tests have\n * shown that zlib compression levels 3-6 usually perform as well as level 9\n * for PNG images, and do considerably fewer caclulations.  In the future,\n * these values may not correspond directly to the zlib compression levels.\n */\nPNG_EXPORT(69, void, png_set_compression_level, (png_structrp png_ptr,\n    int level));\n\nPNG_EXPORT(70, void, png_set_compression_mem_level, (png_structrp png_ptr,\n    int mem_level));\n\nPNG_EXPORT(71, void, png_set_compression_strategy, (png_structrp png_ptr,\n    int strategy));\n\n/* If PNG_WRITE_OPTIMIZE_CMF_SUPPORTED is defined, libpng will use a\n * smaller value of window_bits if it can do so safely.\n */\nPNG_EXPORT(72, void, png_set_compression_window_bits, (png_structrp png_ptr,\n    int window_bits));\n\nPNG_EXPORT(73, void, png_set_compression_method, (png_structrp png_ptr,\n    int method));\n#endif\n\n#ifdef PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED\n/* Also set zlib parameters for compressing non-IDAT chunks */\nPNG_EXPORT(222, void, png_set_text_compression_level, (png_structrp png_ptr,\n    int level));\n\nPNG_EXPORT(223, void, png_set_text_compression_mem_level, (png_structrp png_ptr,\n    int mem_level));\n\nPNG_EXPORT(224, void, png_set_text_compression_strategy, (png_structrp png_ptr,\n    int strategy));\n\n/* If PNG_WRITE_OPTIMIZE_CMF_SUPPORTED is defined, libpng will use a\n * smaller value of window_bits if it can do so safely.\n */\nPNG_EXPORT(225, void, png_set_text_compression_window_bits,\n    (png_structrp png_ptr, int window_bits));\n\nPNG_EXPORT(226, void, png_set_text_compression_method, (png_structrp png_ptr,\n    int method));\n#endif /* PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED */\n\n/* These next functions are called for input/output, memory, and error\n * handling.  They are in the file pngrio.c, pngwio.c, and pngerror.c,\n * and call standard C I/O routines such as fread(), fwrite(), and\n * fprintf().  These functions can be made to use other I/O routines\n * at run time for those applications that need to handle I/O in a\n * different manner by calling png_set_???_fn().  See libpng-manual.txt for\n * more information.\n */\n\n#ifdef PNG_STDIO_SUPPORTED\n/* Initialize the input/output for the PNG file to the default functions. */\nPNG_EXPORT(74, void, png_init_io, (png_structrp png_ptr, png_FILE_p fp));\n#endif\n\n/* Replace the (error and abort), and warning functions with user\n * supplied functions.  If no messages are to be printed you must still\n * write and use replacement functions. The replacement error_fn should\n * still do a longjmp to the last setjmp location if you are using this\n * method of error handling.  If error_fn or warning_fn is NULL, the\n * default function will be used.\n */\n\nPNG_EXPORT(75, void, png_set_error_fn, (png_structrp png_ptr,\n    png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warning_fn));\n\n/* Return the user pointer associated with the error functions */\nPNG_EXPORT(76, png_voidp, png_get_error_ptr, (png_const_structrp png_ptr));\n\n/* Replace the default data output functions with a user supplied one(s).\n * If buffered output is not used, then output_flush_fn can be set to NULL.\n * If PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng compile time\n * output_flush_fn will be ignored (and thus can be NULL).\n * It is probably a mistake to use NULL for output_flush_fn if\n * write_data_fn is not also NULL unless you have built libpng with\n * PNG_WRITE_FLUSH_SUPPORTED undefined, because in this case libpng's\n * default flush function, which uses the standard *FILE structure, will\n * be used.\n */\nPNG_EXPORT(77, void, png_set_write_fn, (png_structrp png_ptr, png_voidp io_ptr,\n    png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn));\n\n/* Replace the default data input function with a user supplied one. */\nPNG_EXPORT(78, void, png_set_read_fn, (png_structrp png_ptr, png_voidp io_ptr,\n    png_rw_ptr read_data_fn));\n\n/* Return the user pointer associated with the I/O functions */\nPNG_EXPORT(79, png_voidp, png_get_io_ptr, (png_const_structrp png_ptr));\n\nPNG_EXPORT(80, void, png_set_read_status_fn, (png_structrp png_ptr,\n    png_read_status_ptr read_row_fn));\n\nPNG_EXPORT(81, void, png_set_write_status_fn, (png_structrp png_ptr,\n    png_write_status_ptr write_row_fn));\n\n#ifdef PNG_USER_MEM_SUPPORTED\n/* Replace the default memory allocation functions with user supplied one(s). */\nPNG_EXPORT(82, void, png_set_mem_fn, (png_structrp png_ptr, png_voidp mem_ptr,\n    png_malloc_ptr malloc_fn, png_free_ptr free_fn));\n/* Return the user pointer associated with the memory functions */\nPNG_EXPORT(83, png_voidp, png_get_mem_ptr, (png_const_structrp png_ptr));\n#endif\n\n#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED\nPNG_EXPORT(84, void, png_set_read_user_transform_fn, (png_structrp png_ptr,\n    png_user_transform_ptr read_user_transform_fn));\n#endif\n\n#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED\nPNG_EXPORT(85, void, png_set_write_user_transform_fn, (png_structrp png_ptr,\n    png_user_transform_ptr write_user_transform_fn));\n#endif\n\n#ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED\nPNG_EXPORT(86, void, png_set_user_transform_info, (png_structrp png_ptr,\n    png_voidp user_transform_ptr, int user_transform_depth,\n    int user_transform_channels));\n/* Return the user pointer associated with the user transform functions */\nPNG_EXPORT(87, png_voidp, png_get_user_transform_ptr,\n    (png_const_structrp png_ptr));\n#endif\n\n#ifdef PNG_USER_TRANSFORM_INFO_SUPPORTED\n/* Return information about the row currently being processed.  Note that these\n * APIs do not fail but will return unexpected results if called outside a user\n * transform callback.  Also note that when transforming an interlaced image the\n * row number is the row number within the sub-image of the interlace pass, so\n * the value will increase to the height of the sub-image (not the full image)\n * then reset to 0 for the next pass.\n *\n * Use PNG_ROW_FROM_PASS_ROW(row, pass) and PNG_COL_FROM_PASS_COL(col, pass) to\n * find the output pixel (x,y) given an interlaced sub-image pixel\n * (row,col,pass).  (See below for these macros.)\n */\nPNG_EXPORT(217, png_uint_32, png_get_current_row_number, (png_const_structrp));\nPNG_EXPORT(218, png_byte, png_get_current_pass_number, (png_const_structrp));\n#endif\n\n#ifdef PNG_READ_USER_CHUNKS_SUPPORTED\n/* This callback is called only for *unknown* chunks.  If\n * PNG_HANDLE_AS_UNKNOWN_SUPPORTED is set then it is possible to set known\n * chunks to be treated as unknown, however in this case the callback must do\n * any processing required by the chunk (e.g. by calling the appropriate\n * png_set_ APIs.)\n *\n * There is no write support - on write, by default, all the chunks in the\n * 'unknown' list are written in the specified position.\n *\n * The integer return from the callback function is interpreted thus:\n *\n * negative: An error occured, png_chunk_error will be called.\n *     zero: The chunk was not handled, the chunk will be saved. A critical\n *           chunk will cause an error at this point unless it is to be saved.\n * positive: The chunk was handled, libpng will ignore/discard it.\n *\n * See \"INTERACTION WTIH USER CHUNK CALLBACKS\" below for important notes about\n * how this behavior will change in libpng 1.7\n */\nPNG_EXPORT(88, void, png_set_read_user_chunk_fn, (png_structrp png_ptr,\n    png_voidp user_chunk_ptr, png_user_chunk_ptr read_user_chunk_fn));\n#endif\n\n#ifdef PNG_USER_CHUNKS_SUPPORTED\nPNG_EXPORT(89, png_voidp, png_get_user_chunk_ptr, (png_const_structrp png_ptr));\n#endif\n\n#ifdef PNG_PROGRESSIVE_READ_SUPPORTED\n/* Sets the function callbacks for the push reader, and a pointer to a\n * user-defined structure available to the callback functions.\n */\nPNG_EXPORT(90, void, png_set_progressive_read_fn, (png_structrp png_ptr,\n    png_voidp progressive_ptr, png_progressive_info_ptr info_fn,\n    png_progressive_row_ptr row_fn, png_progressive_end_ptr end_fn));\n\n/* Returns the user pointer associated with the push read functions */\nPNG_EXPORT(91, png_voidp, png_get_progressive_ptr,\n    (png_const_structrp png_ptr));\n\n/* Function to be called when data becomes available */\nPNG_EXPORT(92, void, png_process_data, (png_structrp png_ptr,\n    png_inforp info_ptr, png_bytep buffer, png_size_t buffer_size));\n\n/* A function which may be called *only* within png_process_data to stop the\n * processing of any more data.  The function returns the number of bytes\n * remaining, excluding any that libpng has cached internally.  A subsequent\n * call to png_process_data must supply these bytes again.  If the argument\n * 'save' is set to true the routine will first save all the pending data and\n * will always return 0.\n */\nPNG_EXPORT(219, png_size_t, png_process_data_pause, (png_structrp, int save));\n\n/* A function which may be called *only* outside (after) a call to\n * png_process_data.  It returns the number of bytes of data to skip in the\n * input.  Normally it will return 0, but if it returns a non-zero value the\n * application must skip than number of bytes of input data and pass the\n * following data to the next call to png_process_data.\n */\nPNG_EXPORT(220, png_uint_32, png_process_data_skip, (png_structrp));\n\n#ifdef PNG_READ_INTERLACING_SUPPORTED\n/* Function that combines rows.  'new_row' is a flag that should come from\n * the callback and be non-NULL if anything needs to be done; the library\n * stores its own version of the new data internally and ignores the passed\n * in value.\n */\nPNG_EXPORT(93, void, png_progressive_combine_row, (png_const_structrp png_ptr,\n    png_bytep old_row, png_const_bytep new_row));\n#endif /* PNG_READ_INTERLACING_SUPPORTED */\n#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */\n\nPNG_EXPORTA(94, png_voidp, png_malloc, (png_const_structrp png_ptr,\n    png_alloc_size_t size), PNG_ALLOCATED);\n/* Added at libpng version 1.4.0 */\nPNG_EXPORTA(95, png_voidp, png_calloc, (png_const_structrp png_ptr,\n    png_alloc_size_t size), PNG_ALLOCATED);\n\n/* Added at libpng version 1.2.4 */\nPNG_EXPORTA(96, png_voidp, png_malloc_warn, (png_const_structrp png_ptr,\n    png_alloc_size_t size), PNG_ALLOCATED);\n\n/* Frees a pointer allocated by png_malloc() */\nPNG_EXPORT(97, void, png_free, (png_const_structrp png_ptr, png_voidp ptr));\n\n/* Free data that was allocated internally */\nPNG_EXPORT(98, void, png_free_data, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 free_me, int num));\n\n/* Reassign responsibility for freeing existing data, whether allocated\n * by libpng or by the application; this works on the png_info structure passed\n * in, it does not change the state for other png_info structures.\n *\n * It is unlikely that this function works correctly as of 1.6.0 and using it\n * may result either in memory leaks or double free of allocated data.\n */\nPNG_EXPORT(99, void, png_data_freer, (png_const_structrp png_ptr,\n    png_inforp info_ptr, int freer, png_uint_32 mask));\n\n/* Assignments for png_data_freer */\n#define PNG_DESTROY_WILL_FREE_DATA 1\n#define PNG_SET_WILL_FREE_DATA 1\n#define PNG_USER_WILL_FREE_DATA 2\n/* Flags for png_ptr->free_me and info_ptr->free_me */\n#define PNG_FREE_HIST 0x0008\n#define PNG_FREE_ICCP 0x0010\n#define PNG_FREE_SPLT 0x0020\n#define PNG_FREE_ROWS 0x0040\n#define PNG_FREE_PCAL 0x0080\n#define PNG_FREE_SCAL 0x0100\n#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED\n#  define PNG_FREE_UNKN 0x0200\n#endif\n/*      PNG_FREE_LIST 0x0400    removed in 1.6.0 because it is ignored */\n#define PNG_FREE_PLTE 0x1000\n#define PNG_FREE_TRNS 0x2000\n#define PNG_FREE_TEXT 0x4000\n#define PNG_FREE_ALL  0x7fff\n#define PNG_FREE_MUL  0x4220 /* PNG_FREE_SPLT|PNG_FREE_TEXT|PNG_FREE_UNKN */\n\n#ifdef PNG_USER_MEM_SUPPORTED\nPNG_EXPORTA(100, png_voidp, png_malloc_default, (png_const_structrp png_ptr,\n    png_alloc_size_t size), PNG_ALLOCATED PNG_DEPRECATED);\nPNG_EXPORTA(101, void, png_free_default, (png_const_structrp png_ptr,\n    png_voidp ptr), PNG_DEPRECATED);\n#endif\n\n#ifdef PNG_ERROR_TEXT_SUPPORTED\n/* Fatal error in PNG image of libpng - can't continue */\nPNG_EXPORTA(102, void, png_error, (png_const_structrp png_ptr,\n    png_const_charp error_message), PNG_NORETURN);\n\n/* The same, but the chunk name is prepended to the error string. */\nPNG_EXPORTA(103, void, png_chunk_error, (png_const_structrp png_ptr,\n    png_const_charp error_message), PNG_NORETURN);\n\n#else\n/* Fatal error in PNG image of libpng - can't continue */\nPNG_EXPORTA(104, void, png_err, (png_const_structrp png_ptr), PNG_NORETURN);\n#  define png_error(s1,s2) png_err(s1)\n#  define png_chunk_error(s1,s2) png_err(s1)\n#endif\n\n#ifdef PNG_WARNINGS_SUPPORTED\n/* Non-fatal error in libpng.  Can continue, but may have a problem. */\nPNG_EXPORT(105, void, png_warning, (png_const_structrp png_ptr,\n    png_const_charp warning_message));\n\n/* Non-fatal error in libpng, chunk name is prepended to message. */\nPNG_EXPORT(106, void, png_chunk_warning, (png_const_structrp png_ptr,\n    png_const_charp warning_message));\n#else\n#  define png_warning(s1,s2) ((void)(s1))\n#  define png_chunk_warning(s1,s2) ((void)(s1))\n#endif\n\n#ifdef PNG_BENIGN_ERRORS_SUPPORTED\n/* Benign error in libpng.  Can continue, but may have a problem.\n * User can choose whether to handle as a fatal error or as a warning. */\nPNG_EXPORT(107, void, png_benign_error, (png_const_structrp png_ptr,\n    png_const_charp warning_message));\n\n#ifdef PNG_READ_SUPPORTED\n/* Same, chunk name is prepended to message (only during read) */\nPNG_EXPORT(108, void, png_chunk_benign_error, (png_const_structrp png_ptr,\n    png_const_charp warning_message));\n#endif\n\nPNG_EXPORT(109, void, png_set_benign_errors,\n    (png_structrp png_ptr, int allowed));\n#else\n#  ifdef PNG_ALLOW_BENIGN_ERRORS\n#    define png_benign_error png_warning\n#    define png_chunk_benign_error png_chunk_warning\n#  else\n#    define png_benign_error png_error\n#    define png_chunk_benign_error png_chunk_error\n#  endif\n#endif\n\n/* The png_set_<chunk> functions are for storing values in the png_info_struct.\n * Similarly, the png_get_<chunk> calls are used to read values from the\n * png_info_struct, either storing the parameters in the passed variables, or\n * setting pointers into the png_info_struct where the data is stored.  The\n * png_get_<chunk> functions return a non-zero value if the data was available\n * in info_ptr, or return zero and do not change any of the parameters if the\n * data was not available.\n *\n * These functions should be used instead of directly accessing png_info\n * to avoid problems with future changes in the size and internal layout of\n * png_info_struct.\n */\n/* Returns \"flag\" if chunk data is valid in info_ptr. */\nPNG_EXPORT(110, png_uint_32, png_get_valid, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr, png_uint_32 flag));\n\n/* Returns number of bytes needed to hold a transformed row. */\nPNG_EXPORT(111, png_size_t, png_get_rowbytes, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr));\n\n#ifdef PNG_INFO_IMAGE_SUPPORTED\n/* Returns row_pointers, which is an array of pointers to scanlines that was\n * returned from png_read_png().\n */\nPNG_EXPORT(112, png_bytepp, png_get_rows, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr));\n\n/* Set row_pointers, which is an array of pointers to scanlines for use\n * by png_write_png().\n */\nPNG_EXPORT(113, void, png_set_rows, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_bytepp row_pointers));\n#endif\n\n/* Returns number of color channels in image. */\nPNG_EXPORT(114, png_byte, png_get_channels, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr));\n\n#ifdef PNG_EASY_ACCESS_SUPPORTED\n/* Returns image width in pixels. */\nPNG_EXPORT(115, png_uint_32, png_get_image_width, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr));\n\n/* Returns image height in pixels. */\nPNG_EXPORT(116, png_uint_32, png_get_image_height, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr));\n\n/* Returns image bit_depth. */\nPNG_EXPORT(117, png_byte, png_get_bit_depth, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr));\n\n/* Returns image color_type. */\nPNG_EXPORT(118, png_byte, png_get_color_type, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr));\n\n/* Returns image filter_type. */\nPNG_EXPORT(119, png_byte, png_get_filter_type, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr));\n\n/* Returns image interlace_type. */\nPNG_EXPORT(120, png_byte, png_get_interlace_type, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr));\n\n/* Returns image compression_type. */\nPNG_EXPORT(121, png_byte, png_get_compression_type, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr));\n\n/* Returns image resolution in pixels per meter, from pHYs chunk data. */\nPNG_EXPORT(122, png_uint_32, png_get_pixels_per_meter,\n    (png_const_structrp png_ptr, png_const_inforp info_ptr));\nPNG_EXPORT(123, png_uint_32, png_get_x_pixels_per_meter,\n    (png_const_structrp png_ptr, png_const_inforp info_ptr));\nPNG_EXPORT(124, png_uint_32, png_get_y_pixels_per_meter,\n    (png_const_structrp png_ptr, png_const_inforp info_ptr));\n\n/* Returns pixel aspect ratio, computed from pHYs chunk data.  */\nPNG_FP_EXPORT(125, float, png_get_pixel_aspect_ratio,\n    (png_const_structrp png_ptr, png_const_inforp info_ptr))\nPNG_FIXED_EXPORT(210, png_fixed_point, png_get_pixel_aspect_ratio_fixed,\n    (png_const_structrp png_ptr, png_const_inforp info_ptr))\n\n/* Returns image x, y offset in pixels or microns, from oFFs chunk data. */\nPNG_EXPORT(126, png_int_32, png_get_x_offset_pixels,\n    (png_const_structrp png_ptr, png_const_inforp info_ptr));\nPNG_EXPORT(127, png_int_32, png_get_y_offset_pixels,\n    (png_const_structrp png_ptr, png_const_inforp info_ptr));\nPNG_EXPORT(128, png_int_32, png_get_x_offset_microns,\n    (png_const_structrp png_ptr, png_const_inforp info_ptr));\nPNG_EXPORT(129, png_int_32, png_get_y_offset_microns,\n    (png_const_structrp png_ptr, png_const_inforp info_ptr));\n\n#endif /* PNG_EASY_ACCESS_SUPPORTED */\n\n#ifdef PNG_READ_SUPPORTED\n/* Returns pointer to signature string read from PNG header */\nPNG_EXPORT(130, png_const_bytep, png_get_signature, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr));\n#endif\n\n#ifdef PNG_bKGD_SUPPORTED\nPNG_EXPORT(131, png_uint_32, png_get_bKGD, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_color_16p *background));\n#endif\n\n#ifdef PNG_bKGD_SUPPORTED\nPNG_EXPORT(132, void, png_set_bKGD, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_const_color_16p background));\n#endif\n\n#ifdef PNG_cHRM_SUPPORTED\nPNG_FP_EXPORT(133, png_uint_32, png_get_cHRM, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr, double *white_x, double *white_y, double *red_x,\n    double *red_y, double *green_x, double *green_y, double *blue_x,\n    double *blue_y))\nPNG_FP_EXPORT(230, png_uint_32, png_get_cHRM_XYZ, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr, double *red_X, double *red_Y, double *red_Z,\n    double *green_X, double *green_Y, double *green_Z, double *blue_X,\n    double *blue_Y, double *blue_Z))\nPNG_FIXED_EXPORT(134, png_uint_32, png_get_cHRM_fixed,\n    (png_const_structrp png_ptr, png_const_inforp info_ptr,\n    png_fixed_point *int_white_x, png_fixed_point *int_white_y,\n    png_fixed_point *int_red_x, png_fixed_point *int_red_y,\n    png_fixed_point *int_green_x, png_fixed_point *int_green_y,\n    png_fixed_point *int_blue_x, png_fixed_point *int_blue_y))\nPNG_FIXED_EXPORT(231, png_uint_32, png_get_cHRM_XYZ_fixed,\n    (png_const_structrp png_ptr, png_const_inforp info_ptr,\n    png_fixed_point *int_red_X, png_fixed_point *int_red_Y,\n    png_fixed_point *int_red_Z, png_fixed_point *int_green_X,\n    png_fixed_point *int_green_Y, png_fixed_point *int_green_Z,\n    png_fixed_point *int_blue_X, png_fixed_point *int_blue_Y,\n    png_fixed_point *int_blue_Z))\n#endif\n\n#ifdef PNG_cHRM_SUPPORTED\nPNG_FP_EXPORT(135, void, png_set_cHRM, (png_const_structrp png_ptr,\n    png_inforp info_ptr,\n    double white_x, double white_y, double red_x, double red_y, double green_x,\n    double green_y, double blue_x, double blue_y))\nPNG_FP_EXPORT(232, void, png_set_cHRM_XYZ, (png_const_structrp png_ptr,\n    png_inforp info_ptr, double red_X, double red_Y, double red_Z,\n    double green_X, double green_Y, double green_Z, double blue_X,\n    double blue_Y, double blue_Z))\nPNG_FIXED_EXPORT(136, void, png_set_cHRM_fixed, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_fixed_point int_white_x,\n    png_fixed_point int_white_y, png_fixed_point int_red_x,\n    png_fixed_point int_red_y, png_fixed_point int_green_x,\n    png_fixed_point int_green_y, png_fixed_point int_blue_x,\n    png_fixed_point int_blue_y))\nPNG_FIXED_EXPORT(233, void, png_set_cHRM_XYZ_fixed, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_fixed_point int_red_X, png_fixed_point int_red_Y,\n    png_fixed_point int_red_Z, png_fixed_point int_green_X,\n    png_fixed_point int_green_Y, png_fixed_point int_green_Z,\n    png_fixed_point int_blue_X, png_fixed_point int_blue_Y,\n    png_fixed_point int_blue_Z))\n#endif\n\n#ifdef PNG_gAMA_SUPPORTED\nPNG_FP_EXPORT(137, png_uint_32, png_get_gAMA, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr, double *file_gamma))\nPNG_FIXED_EXPORT(138, png_uint_32, png_get_gAMA_fixed,\n    (png_const_structrp png_ptr, png_const_inforp info_ptr,\n    png_fixed_point *int_file_gamma))\n#endif\n\n#ifdef PNG_gAMA_SUPPORTED\nPNG_FP_EXPORT(139, void, png_set_gAMA, (png_const_structrp png_ptr,\n    png_inforp info_ptr, double file_gamma))\nPNG_FIXED_EXPORT(140, void, png_set_gAMA_fixed, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_fixed_point int_file_gamma))\n#endif\n\n#ifdef PNG_hIST_SUPPORTED\nPNG_EXPORT(141, png_uint_32, png_get_hIST, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_uint_16p *hist));\n#endif\n\n#ifdef PNG_hIST_SUPPORTED\nPNG_EXPORT(142, void, png_set_hIST, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_const_uint_16p hist));\n#endif\n\nPNG_EXPORT(143, png_uint_32, png_get_IHDR, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr, png_uint_32 *width, png_uint_32 *height,\n    int *bit_depth, int *color_type, int *interlace_method,\n    int *compression_method, int *filter_method));\n\nPNG_EXPORT(144, void, png_set_IHDR, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 width, png_uint_32 height, int bit_depth,\n    int color_type, int interlace_method, int compression_method,\n    int filter_method));\n\n#ifdef PNG_oFFs_SUPPORTED\nPNG_EXPORT(145, png_uint_32, png_get_oFFs, (png_const_structrp png_ptr,\n   png_const_inforp info_ptr, png_int_32 *offset_x, png_int_32 *offset_y,\n   int *unit_type));\n#endif\n\n#ifdef PNG_oFFs_SUPPORTED\nPNG_EXPORT(146, void, png_set_oFFs, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_int_32 offset_x, png_int_32 offset_y,\n    int unit_type));\n#endif\n\n#ifdef PNG_pCAL_SUPPORTED\nPNG_EXPORT(147, png_uint_32, png_get_pCAL, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_charp *purpose, png_int_32 *X0,\n    png_int_32 *X1, int *type, int *nparams, png_charp *units,\n    png_charpp *params));\n#endif\n\n#ifdef PNG_pCAL_SUPPORTED\nPNG_EXPORT(148, void, png_set_pCAL, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_const_charp purpose, png_int_32 X0, png_int_32 X1,\n    int type, int nparams, png_const_charp units, png_charpp params));\n#endif\n\n#ifdef PNG_pHYs_SUPPORTED\nPNG_EXPORT(149, png_uint_32, png_get_pHYs, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr, png_uint_32 *res_x, png_uint_32 *res_y,\n    int *unit_type));\n#endif\n\n#ifdef PNG_pHYs_SUPPORTED\nPNG_EXPORT(150, void, png_set_pHYs, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 res_x, png_uint_32 res_y, int unit_type));\n#endif\n\nPNG_EXPORT(151, png_uint_32, png_get_PLTE, (png_const_structrp png_ptr,\n   png_inforp info_ptr, png_colorp *palette, int *num_palette));\n\nPNG_EXPORT(152, void, png_set_PLTE, (png_structrp png_ptr,\n    png_inforp info_ptr, png_const_colorp palette, int num_palette));\n\n#ifdef PNG_sBIT_SUPPORTED\nPNG_EXPORT(153, png_uint_32, png_get_sBIT, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_color_8p *sig_bit));\n#endif\n\n#ifdef PNG_sBIT_SUPPORTED\nPNG_EXPORT(154, void, png_set_sBIT, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_const_color_8p sig_bit));\n#endif\n\n#ifdef PNG_sRGB_SUPPORTED\nPNG_EXPORT(155, png_uint_32, png_get_sRGB, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr, int *file_srgb_intent));\n#endif\n\n#ifdef PNG_sRGB_SUPPORTED\nPNG_EXPORT(156, void, png_set_sRGB, (png_const_structrp png_ptr,\n    png_inforp info_ptr, int srgb_intent));\nPNG_EXPORT(157, void, png_set_sRGB_gAMA_and_cHRM, (png_const_structrp png_ptr,\n    png_inforp info_ptr, int srgb_intent));\n#endif\n\n#ifdef PNG_iCCP_SUPPORTED\nPNG_EXPORT(158, png_uint_32, png_get_iCCP, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_charpp name, int *compression_type,\n    png_bytepp profile, png_uint_32 *proflen));\n#endif\n\n#ifdef PNG_iCCP_SUPPORTED\nPNG_EXPORT(159, void, png_set_iCCP, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_const_charp name, int compression_type,\n    png_const_bytep profile, png_uint_32 proflen));\n#endif\n\n#ifdef PNG_sPLT_SUPPORTED\nPNG_EXPORT(160, int, png_get_sPLT, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_sPLT_tpp entries));\n#endif\n\n#ifdef PNG_sPLT_SUPPORTED\nPNG_EXPORT(161, void, png_set_sPLT, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_const_sPLT_tp entries, int nentries));\n#endif\n\n#ifdef PNG_TEXT_SUPPORTED\n/* png_get_text also returns the number of text chunks in *num_text */\nPNG_EXPORT(162, int, png_get_text, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_textp *text_ptr, int *num_text));\n#endif\n\n/* Note while png_set_text() will accept a structure whose text,\n * language, and  translated keywords are NULL pointers, the structure\n * returned by png_get_text will always contain regular\n * zero-terminated C strings.  They might be empty strings but\n * they will never be NULL pointers.\n */\n\n#ifdef PNG_TEXT_SUPPORTED\nPNG_EXPORT(163, void, png_set_text, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_const_textp text_ptr, int num_text));\n#endif\n\n#ifdef PNG_tIME_SUPPORTED\nPNG_EXPORT(164, png_uint_32, png_get_tIME, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_timep *mod_time));\n#endif\n\n#ifdef PNG_tIME_SUPPORTED\nPNG_EXPORT(165, void, png_set_tIME, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_const_timep mod_time));\n#endif\n\n#ifdef PNG_tRNS_SUPPORTED\nPNG_EXPORT(166, png_uint_32, png_get_tRNS, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_bytep *trans_alpha, int *num_trans,\n    png_color_16p *trans_color));\n#endif\n\n#ifdef PNG_tRNS_SUPPORTED\nPNG_EXPORT(167, void, png_set_tRNS, (png_structrp png_ptr,\n    png_inforp info_ptr, png_const_bytep trans_alpha, int num_trans,\n    png_const_color_16p trans_color));\n#endif\n\n#ifdef PNG_sCAL_SUPPORTED\nPNG_FP_EXPORT(168, png_uint_32, png_get_sCAL, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr, int *unit, double *width, double *height))\n#if defined(PNG_FLOATING_ARITHMETIC_SUPPORTED) || \\\n   defined(PNG_FLOATING_POINT_SUPPORTED)\n/* NOTE: this API is currently implemented using floating point arithmetic,\n * consequently it can only be used on systems with floating point support.\n * In any case the range of values supported by png_fixed_point is small and it\n * is highly recommended that png_get_sCAL_s be used instead.\n */\nPNG_FIXED_EXPORT(214, png_uint_32, png_get_sCAL_fixed,\n    (png_const_structrp png_ptr, png_const_inforp info_ptr, int *unit,\n    png_fixed_point *width, png_fixed_point *height))\n#endif\nPNG_EXPORT(169, png_uint_32, png_get_sCAL_s,\n    (png_const_structrp png_ptr, png_const_inforp info_ptr, int *unit,\n    png_charpp swidth, png_charpp sheight));\n\nPNG_FP_EXPORT(170, void, png_set_sCAL, (png_const_structrp png_ptr,\n    png_inforp info_ptr, int unit, double width, double height))\nPNG_FIXED_EXPORT(213, void, png_set_sCAL_fixed, (png_const_structrp png_ptr,\n   png_inforp info_ptr, int unit, png_fixed_point width,\n   png_fixed_point height))\nPNG_EXPORT(171, void, png_set_sCAL_s, (png_const_structrp png_ptr,\n    png_inforp info_ptr, int unit,\n    png_const_charp swidth, png_const_charp sheight));\n#endif /* PNG_sCAL_SUPPORTED */\n\n#ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED\n/* Provide the default handling for all unknown chunks or, optionally, for\n * specific unknown chunks.\n *\n * NOTE: prior to 1.6.0 the handling specified for particular chunks on read was\n * ignored and the default was used, the per-chunk setting only had an effect on\n * write.  If you wish to have chunk-specific handling on read in code that must\n * work on earlier versions you must use a user chunk callback to specify the\n * desired handling (keep or discard.)\n *\n * The 'keep' parameter is a PNG_HANDLE_CHUNK_ value as listed below.  The\n * parameter is interpreted as follows:\n *\n * READ:\n *    PNG_HANDLE_CHUNK_AS_DEFAULT:\n *       Known chunks: do normal libpng processing, do not keep the chunk (but\n *          see the comments below about PNG_HANDLE_AS_UNKNOWN_SUPPORTED)\n *       Unknown chunks: for a specific chunk use the global default, when used\n *          as the default discard the chunk data.\n *    PNG_HANDLE_CHUNK_NEVER:\n *       Discard the chunk data.\n *    PNG_HANDLE_CHUNK_IF_SAFE:\n *       Keep the chunk data if the chunk is not critical else raise a chunk\n *       error.\n *    PNG_HANDLE_CHUNK_ALWAYS:\n *       Keep the chunk data.\n *\n * If the chunk data is saved it can be retrieved using png_get_unknown_chunks,\n * below.  Notice that specifying \"AS_DEFAULT\" as a global default is equivalent\n * to specifying \"NEVER\", however when \"AS_DEFAULT\" is used for specific chunks\n * it simply resets the behavior to the libpng default.\n *\n * INTERACTION WTIH USER CHUNK CALLBACKS:\n * The per-chunk handling is always used when there is a png_user_chunk_ptr\n * callback and the callback returns 0; the chunk is then always stored *unless*\n * it is critical and the per-chunk setting is other than ALWAYS.  Notice that\n * the global default is *not* used in this case.  (In effect the per-chunk\n * value is incremented to at least IF_SAFE.)\n *\n * IMPORTANT NOTE: this behavior will change in libpng 1.7 - the global and\n * per-chunk defaults will be honored.  If you want to preserve the current\n * behavior when your callback returns 0 you must set PNG_HANDLE_CHUNK_IF_SAFE\n * as the default - if you don't do this libpng 1.6 will issue a warning.\n *\n * If you want unhandled unknown chunks to be discarded in libpng 1.6 and\n * earlier simply return '1' (handled).\n *\n * PNG_HANDLE_AS_UNKNOWN_SUPPORTED:\n *    If this is *not* set known chunks will always be handled by libpng and\n *    will never be stored in the unknown chunk list.  Known chunks listed to\n *    png_set_keep_unknown_chunks will have no effect.  If it is set then known\n *    chunks listed with a keep other than AS_DEFAULT will *never* be processed\n *    by libpng, in addition critical chunks must either be processed by the\n *    callback or saved.\n *\n *    The IHDR and IEND chunks must not be listed.  Because this turns off the\n *    default handling for chunks that would otherwise be recognized the\n *    behavior of libpng transformations may well become incorrect!\n *\n * WRITE:\n *    When writing chunks the options only apply to the chunks specified by\n *    png_set_unknown_chunks (below), libpng will *always* write known chunks\n *    required by png_set_ calls and will always write the core critical chunks\n *    (as required for PLTE).\n *\n *    Each chunk in the png_set_unknown_chunks list is looked up in the\n *    png_set_keep_unknown_chunks list to find the keep setting, this is then\n *    interpreted as follows:\n *\n *    PNG_HANDLE_CHUNK_AS_DEFAULT:\n *       Write safe-to-copy chunks and write other chunks if the global\n *       default is set to _ALWAYS, otherwise don't write this chunk.\n *    PNG_HANDLE_CHUNK_NEVER:\n *       Do not write the chunk.\n *    PNG_HANDLE_CHUNK_IF_SAFE:\n *       Write the chunk if it is safe-to-copy, otherwise do not write it.\n *    PNG_HANDLE_CHUNK_ALWAYS:\n *       Write the chunk.\n *\n * Note that the default behavior is effectively the opposite of the read case -\n * in read unknown chunks are not stored by default, in write they are written\n * by default.  Also the behavior of PNG_HANDLE_CHUNK_IF_SAFE is very different\n * - on write the safe-to-copy bit is checked, on read the critical bit is\n * checked and on read if the chunk is critical an error will be raised.\n *\n * num_chunks:\n * ===========\n *    If num_chunks is positive, then the \"keep\" parameter specifies the manner\n *    for handling only those chunks appearing in the chunk_list array,\n *    otherwise the chunk list array is ignored.\n *\n *    If num_chunks is 0 the \"keep\" parameter specifies the default behavior for\n *    unknown chunks, as described above.\n *\n *    If num_chunks is negative, then the \"keep\" parameter specifies the manner\n *    for handling all unknown chunks plus all chunks recognized by libpng\n *    except for the IHDR, PLTE, tRNS, IDAT, and IEND chunks (which continue to\n *    be processed by libpng.\n */\nPNG_EXPORT(172, void, png_set_keep_unknown_chunks, (png_structrp png_ptr,\n    int keep, png_const_bytep chunk_list, int num_chunks));\n\n/* The \"keep\" PNG_HANDLE_CHUNK_ parameter for the specified chunk is returned;\n * the result is therefore true (non-zero) if special handling is required,\n * false for the default handling.\n */\nPNG_EXPORT(173, int, png_handle_as_unknown, (png_const_structrp png_ptr,\n    png_const_bytep chunk_name));\n#endif\n\n#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED\nPNG_EXPORT(174, void, png_set_unknown_chunks, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_const_unknown_chunkp unknowns,\n    int num_unknowns));\n   /* NOTE: prior to 1.6.0 this routine set the 'location' field of the added\n    * unknowns to the location currently stored in the png_struct.  This is\n    * invariably the wrong value on write.  To fix this call the following API\n    * for each chunk in the list with the correct location.  If you know your\n    * code won't be compiled on earlier versions you can rely on\n    * png_set_unknown_chunks(write-ptr, png_get_unknown_chunks(read-ptr)) doing\n    * the correct thing.\n    */\n\nPNG_EXPORT(175, void, png_set_unknown_chunk_location,\n    (png_const_structrp png_ptr, png_inforp info_ptr, int chunk, int location));\n\nPNG_EXPORT(176, int, png_get_unknown_chunks, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_unknown_chunkpp entries));\n#endif\n\n/* Png_free_data() will turn off the \"valid\" flag for anything it frees.\n * If you need to turn it off for a chunk that your application has freed,\n * you can use png_set_invalid(png_ptr, info_ptr, PNG_INFO_CHNK);\n */\nPNG_EXPORT(177, void, png_set_invalid, (png_const_structrp png_ptr,\n    png_inforp info_ptr, int mask));\n\n#ifdef PNG_INFO_IMAGE_SUPPORTED\n/* The \"params\" pointer is currently not used and is for future expansion. */\n#ifdef PNG_SEQUENTIAL_READ_SUPPORTED\nPNG_EXPORT(178, void, png_read_png, (png_structrp png_ptr, png_inforp info_ptr,\n    int transforms, png_voidp params));\n#endif\n#ifdef PNG_WRITE_SUPPORTED\nPNG_EXPORT(179, void, png_write_png, (png_structrp png_ptr, png_inforp info_ptr,\n    int transforms, png_voidp params));\n#endif\n#endif\n\nPNG_EXPORT(180, png_const_charp, png_get_copyright,\n    (png_const_structrp png_ptr));\nPNG_EXPORT(181, png_const_charp, png_get_header_ver,\n    (png_const_structrp png_ptr));\nPNG_EXPORT(182, png_const_charp, png_get_header_version,\n    (png_const_structrp png_ptr));\nPNG_EXPORT(183, png_const_charp, png_get_libpng_ver,\n    (png_const_structrp png_ptr));\n\n#ifdef PNG_MNG_FEATURES_SUPPORTED\nPNG_EXPORT(184, png_uint_32, png_permit_mng_features, (png_structrp png_ptr,\n    png_uint_32 mng_features_permitted));\n#endif\n\n/* For use in png_set_keep_unknown, added to version 1.2.6 */\n#define PNG_HANDLE_CHUNK_AS_DEFAULT   0\n#define PNG_HANDLE_CHUNK_NEVER        1\n#define PNG_HANDLE_CHUNK_IF_SAFE      2\n#define PNG_HANDLE_CHUNK_ALWAYS       3\n#define PNG_HANDLE_CHUNK_LAST         4\n\n/* Strip the prepended error numbers (\"#nnn \") from error and warning\n * messages before passing them to the error or warning handler.\n */\n#ifdef PNG_ERROR_NUMBERS_SUPPORTED\nPNG_EXPORT(185, void, png_set_strip_error_numbers, (png_structrp png_ptr,\n    png_uint_32 strip_mode));\n#endif\n\n/* Added in libpng-1.2.6 */\n#ifdef PNG_SET_USER_LIMITS_SUPPORTED\nPNG_EXPORT(186, void, png_set_user_limits, (png_structrp png_ptr,\n    png_uint_32 user_width_max, png_uint_32 user_height_max));\nPNG_EXPORT(187, png_uint_32, png_get_user_width_max,\n    (png_const_structrp png_ptr));\nPNG_EXPORT(188, png_uint_32, png_get_user_height_max,\n    (png_const_structrp png_ptr));\n/* Added in libpng-1.4.0 */\nPNG_EXPORT(189, void, png_set_chunk_cache_max, (png_structrp png_ptr,\n    png_uint_32 user_chunk_cache_max));\nPNG_EXPORT(190, png_uint_32, png_get_chunk_cache_max,\n    (png_const_structrp png_ptr));\n/* Added in libpng-1.4.1 */\nPNG_EXPORT(191, void, png_set_chunk_malloc_max, (png_structrp png_ptr,\n    png_alloc_size_t user_chunk_cache_max));\nPNG_EXPORT(192, png_alloc_size_t, png_get_chunk_malloc_max,\n    (png_const_structrp png_ptr));\n#endif\n\n#if defined(PNG_INCH_CONVERSIONS_SUPPORTED)\nPNG_EXPORT(193, png_uint_32, png_get_pixels_per_inch,\n    (png_const_structrp png_ptr, png_const_inforp info_ptr));\n\nPNG_EXPORT(194, png_uint_32, png_get_x_pixels_per_inch,\n    (png_const_structrp png_ptr, png_const_inforp info_ptr));\n\nPNG_EXPORT(195, png_uint_32, png_get_y_pixels_per_inch,\n    (png_const_structrp png_ptr, png_const_inforp info_ptr));\n\nPNG_FP_EXPORT(196, float, png_get_x_offset_inches,\n    (png_const_structrp png_ptr, png_const_inforp info_ptr))\n#ifdef PNG_FIXED_POINT_SUPPORTED /* otherwise not implemented. */\nPNG_FIXED_EXPORT(211, png_fixed_point, png_get_x_offset_inches_fixed,\n    (png_const_structrp png_ptr, png_const_inforp info_ptr))\n#endif\n\nPNG_FP_EXPORT(197, float, png_get_y_offset_inches, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr))\n#ifdef PNG_FIXED_POINT_SUPPORTED /* otherwise not implemented. */\nPNG_FIXED_EXPORT(212, png_fixed_point, png_get_y_offset_inches_fixed,\n    (png_const_structrp png_ptr, png_const_inforp info_ptr))\n#endif\n\n#  ifdef PNG_pHYs_SUPPORTED\nPNG_EXPORT(198, png_uint_32, png_get_pHYs_dpi, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr, png_uint_32 *res_x, png_uint_32 *res_y,\n    int *unit_type));\n#  endif /* PNG_pHYs_SUPPORTED */\n#endif  /* PNG_INCH_CONVERSIONS_SUPPORTED */\n\n/* Added in libpng-1.4.0 */\n#ifdef PNG_IO_STATE_SUPPORTED\nPNG_EXPORT(199, png_uint_32, png_get_io_state, (png_const_structrp png_ptr));\n\n/* Removed from libpng 1.6; use png_get_io_chunk_type. */\nPNG_REMOVED(200, png_const_bytep, png_get_io_chunk_name, (png_structrp png_ptr),\n    PNG_DEPRECATED)\n\nPNG_EXPORT(216, png_uint_32, png_get_io_chunk_type,\n    (png_const_structrp png_ptr));\n\n/* The flags returned by png_get_io_state() are the following: */\n#  define PNG_IO_NONE        0x0000   /* no I/O at this moment */\n#  define PNG_IO_READING     0x0001   /* currently reading */\n#  define PNG_IO_WRITING     0x0002   /* currently writing */\n#  define PNG_IO_SIGNATURE   0x0010   /* currently at the file signature */\n#  define PNG_IO_CHUNK_HDR   0x0020   /* currently at the chunk header */\n#  define PNG_IO_CHUNK_DATA  0x0040   /* currently at the chunk data */\n#  define PNG_IO_CHUNK_CRC   0x0080   /* currently at the chunk crc */\n#  define PNG_IO_MASK_OP     0x000f   /* current operation: reading/writing */\n#  define PNG_IO_MASK_LOC    0x00f0   /* current location: sig/hdr/data/crc */\n#endif /* ?PNG_IO_STATE_SUPPORTED */\n\n/* Interlace support.  The following macros are always defined so that if\n * libpng interlace handling is turned off the macros may be used to handle\n * interlaced images within the application.\n */\n#define PNG_INTERLACE_ADAM7_PASSES 7\n\n/* Two macros to return the first row and first column of the original,\n * full, image which appears in a given pass.  'pass' is in the range 0\n * to 6 and the result is in the range 0 to 7.\n */\n#define PNG_PASS_START_ROW(pass) (((1&~(pass))<<(3-((pass)>>1)))&7)\n#define PNG_PASS_START_COL(pass) (((1& (pass))<<(3-(((pass)+1)>>1)))&7)\n\n/* A macro to return the offset between pixels in the output row for a pair of\n * pixels in the input - effectively the inverse of the 'COL_SHIFT' macro that\n * follows.  Note that ROW_OFFSET is the offset from one row to the next whereas\n * COL_OFFSET is from one column to the next, within a row.\n */\n#define PNG_PASS_ROW_OFFSET(pass) ((pass)>2?(8>>(((pass)-1)>>1)):8)\n#define PNG_PASS_COL_OFFSET(pass) (1<<((7-(pass))>>1))\n\n/* Two macros to help evaluate the number of rows or columns in each\n * pass.  This is expressed as a shift - effectively log2 of the number or\n * rows or columns in each 8x8 tile of the original image.\n */\n#define PNG_PASS_ROW_SHIFT(pass) ((pass)>2?(8-(pass))>>1:3)\n#define PNG_PASS_COL_SHIFT(pass) ((pass)>1?(7-(pass))>>1:3)\n\n/* Hence two macros to determine the number of rows or columns in a given\n * pass of an image given its height or width.  In fact these macros may\n * return non-zero even though the sub-image is empty, because the other\n * dimension may be empty for a small image.\n */\n#define PNG_PASS_ROWS(height, pass) (((height)+(((1<<PNG_PASS_ROW_SHIFT(pass))\\\n   -1)-PNG_PASS_START_ROW(pass)))>>PNG_PASS_ROW_SHIFT(pass))\n#define PNG_PASS_COLS(width, pass) (((width)+(((1<<PNG_PASS_COL_SHIFT(pass))\\\n   -1)-PNG_PASS_START_COL(pass)))>>PNG_PASS_COL_SHIFT(pass))\n\n/* For the reader row callbacks (both progressive and sequential) it is\n * necessary to find the row in the output image given a row in an interlaced\n * image, so two more macros:\n */\n#define PNG_ROW_FROM_PASS_ROW(y_in, pass) \\\n   (((y_in)<<PNG_PASS_ROW_SHIFT(pass))+PNG_PASS_START_ROW(pass))\n#define PNG_COL_FROM_PASS_COL(x_in, pass) \\\n   (((x_in)<<PNG_PASS_COL_SHIFT(pass))+PNG_PASS_START_COL(pass))\n\n/* Two macros which return a boolean (0 or 1) saying whether the given row\n * or column is in a particular pass.  These use a common utility macro that\n * returns a mask for a given pass - the offset 'off' selects the row or\n * column version.  The mask has the appropriate bit set for each column in\n * the tile.\n */\n#define PNG_PASS_MASK(pass,off) ( \\\n   ((0x110145AF>>(((7-(off))-(pass))<<2)) & 0xF) | \\\n   ((0x01145AF0>>(((7-(off))-(pass))<<2)) & 0xF0))\n\n#define PNG_ROW_IN_INTERLACE_PASS(y, pass) \\\n   ((PNG_PASS_MASK(pass,0) >> ((y)&7)) & 1)\n#define PNG_COL_IN_INTERLACE_PASS(x, pass) \\\n   ((PNG_PASS_MASK(pass,1) >> ((x)&7)) & 1)\n\n#ifdef PNG_READ_COMPOSITE_NODIV_SUPPORTED\n/* With these routines we avoid an integer divide, which will be slower on\n * most machines.  However, it does take more operations than the corresponding\n * divide method, so it may be slower on a few RISC systems.  There are two\n * shifts (by 8 or 16 bits) and an addition, versus a single integer divide.\n *\n * Note that the rounding factors are NOT supposed to be the same!  128 and\n * 32768 are correct for the NODIV code; 127 and 32767 are correct for the\n * standard method.\n *\n * [Optimized code by Greg Roelofs and Mark Adler...blame us for bugs. :-) ]\n */\n\n /* fg and bg should be in `gamma 1.0' space; alpha is the opacity */\n\n#  define png_composite(composite, fg, alpha, bg)         \\\n     { png_uint_16 temp = (png_uint_16)((png_uint_16)(fg) \\\n           * (png_uint_16)(alpha)                         \\\n           + (png_uint_16)(bg)*(png_uint_16)(255          \\\n           - (png_uint_16)(alpha)) + 128);                \\\n       (composite) = (png_byte)((temp + (temp >> 8)) >> 8); }\n\n#  define png_composite_16(composite, fg, alpha, bg)       \\\n     { png_uint_32 temp = (png_uint_32)((png_uint_32)(fg)  \\\n           * (png_uint_32)(alpha)                          \\\n           + (png_uint_32)(bg)*(65535                      \\\n           - (png_uint_32)(alpha)) + 32768);               \\\n       (composite) = (png_uint_16)((temp + (temp >> 16)) >> 16); }\n\n#else  /* Standard method using integer division */\n\n#  define png_composite(composite, fg, alpha, bg)                          \\\n     (composite) = (png_byte)(((png_uint_16)(fg) * (png_uint_16)(alpha) +  \\\n     (png_uint_16)(bg) * (png_uint_16)(255 - (png_uint_16)(alpha)) +       \\\n     127) / 255)\n\n#  define png_composite_16(composite, fg, alpha, bg)                         \\\n     (composite) = (png_uint_16)(((png_uint_32)(fg) * (png_uint_32)(alpha) + \\\n     (png_uint_32)(bg)*(png_uint_32)(65535 - (png_uint_32)(alpha)) +         \\\n     32767) / 65535)\n#endif /* PNG_READ_COMPOSITE_NODIV_SUPPORTED */\n\n#ifdef PNG_READ_INT_FUNCTIONS_SUPPORTED\nPNG_EXPORT(201, png_uint_32, png_get_uint_32, (png_const_bytep buf));\nPNG_EXPORT(202, png_uint_16, png_get_uint_16, (png_const_bytep buf));\nPNG_EXPORT(203, png_int_32, png_get_int_32, (png_const_bytep buf));\n#endif\n\nPNG_EXPORT(204, png_uint_32, png_get_uint_31, (png_const_structrp png_ptr,\n    png_const_bytep buf));\n/* No png_get_int_16 -- may be added if there's a real need for it. */\n\n/* Place a 32-bit number into a buffer in PNG byte order (big-endian). */\n#ifdef PNG_WRITE_INT_FUNCTIONS_SUPPORTED\nPNG_EXPORT(205, void, png_save_uint_32, (png_bytep buf, png_uint_32 i));\n#endif\n#ifdef PNG_SAVE_INT_32_SUPPORTED\nPNG_EXPORT(206, void, png_save_int_32, (png_bytep buf, png_int_32 i));\n#endif\n\n/* Place a 16-bit number into a buffer in PNG byte order.\n * The parameter is declared unsigned int, not png_uint_16,\n * just to avoid potential problems on pre-ANSI C compilers.\n */\n#ifdef PNG_WRITE_INT_FUNCTIONS_SUPPORTED\nPNG_EXPORT(207, void, png_save_uint_16, (png_bytep buf, unsigned int i));\n/* No png_save_int_16 -- may be added if there's a real need for it. */\n#endif\n\n#ifdef PNG_USE_READ_MACROS\n/* Inline macros to do direct reads of bytes from the input buffer.\n * The png_get_int_32() routine assumes we are using two's complement\n * format for negative values, which is almost certainly true.\n */\n#  define PNG_get_uint_32(buf) \\\n     (((png_uint_32)(*(buf)) << 24) + \\\n      ((png_uint_32)(*((buf) + 1)) << 16) + \\\n      ((png_uint_32)(*((buf) + 2)) << 8) + \\\n      ((png_uint_32)(*((buf) + 3))))\n\n   /* From libpng-1.4.0 until 1.4.4, the png_get_uint_16 macro (but not the\n    * function) incorrectly returned a value of type png_uint_32.\n    */\n#  define PNG_get_uint_16(buf) \\\n     ((png_uint_16) \\\n      (((unsigned int)(*(buf)) << 8) + \\\n       ((unsigned int)(*((buf) + 1)))))\n\n#  define PNG_get_int_32(buf) \\\n     ((png_int_32)((*(buf) & 0x80) \\\n      ? -((png_int_32)((png_get_uint_32(buf) ^ 0xffffffffL) + 1)) \\\n      : (png_int_32)png_get_uint_32(buf)))\n\n   /* If PNG_PREFIX is defined the same thing as below happens in pnglibconf.h,\n    * but defining a macro name prefixed with PNG_PREFIX.\n    */\n#  ifndef PNG_PREFIX\n#     define png_get_uint_32(buf) PNG_get_uint_32(buf)\n#     define png_get_uint_16(buf) PNG_get_uint_16(buf)\n#     define png_get_int_32(buf)  PNG_get_int_32(buf)\n#  endif\n#else\n#  ifdef PNG_PREFIX\n      /* No macros; revert to the (redefined) function */\n#     define PNG_get_uint_32 (png_get_uint_32)\n#     define PNG_get_uint_16 (png_get_uint_16)\n#     define PNG_get_int_32  (png_get_int_32)\n#  endif\n#endif\n\n/*******************************************************************************\n *  SIMPLIFIED API\n *******************************************************************************\n *\n * Please read the documentation in libpng-manual.txt (TODO: write said\n * documentation) if you don't understand what follows.\n *\n * The simplified API hides the details of both libpng and the PNG file format\n * itself.  It allows PNG files to be read into a very limited number of\n * in-memory bitmap formats or to be written from the same formats.  If these\n * formats do not accomodate your needs then you can, and should, use the more\n * sophisticated APIs above - these support a wide variety of in-memory formats\n * and a wide variety of sophisticated transformations to those formats as well\n * as a wide variety of APIs to manipulate ancillary information.\n *\n * To read a PNG file using the simplified API:\n *\n * 1) Declare a 'png_image' structure (see below) on the stack and set the\n *    version field to PNG_IMAGE_VERSION.\n * 2) Call the appropriate png_image_begin_read... function.\n * 3) Set the png_image 'format' member to the required sample format.\n * 4) Allocate a buffer for the image and, if required, the color-map.\n * 5) Call png_image_finish_read to read the image and, if required, the\n *    color-map into your buffers.\n *\n * There are no restrictions on the format of the PNG input itself; all valid\n * color types, bit depths, and interlace methods are acceptable, and the\n * input image is transformed as necessary to the requested in-memory format\n * during the png_image_finish_read() step.  The only caveat is that if you\n * request a color-mapped image from a PNG that is full-color or makes\n * complex use of an alpha channel the transformation is extremely lossy and the\n * result may look terrible.\n *\n * To write a PNG file using the simplified API:\n *\n * 1) Declare a 'png_image' structure on the stack and memset() it to all zero.\n * 2) Initialize the members of the structure that describe the image, setting\n *    the 'format' member to the format of the image samples.\n * 3) Call the appropriate png_image_write... function with a pointer to the\n *    image and, if necessary, the color-map to write the PNG data.\n *\n * png_image is a structure that describes the in-memory format of an image\n * when it is being read or defines the in-memory format of an image that you\n * need to write:\n */\n#define PNG_IMAGE_VERSION 1\n\ntypedef struct png_control *png_controlp;\ntypedef struct\n{\n   png_controlp opaque;    /* Initialize to NULL, free with png_image_free */\n   png_uint_32  version;   /* Set to PNG_IMAGE_VERSION */\n   png_uint_32  width;     /* Image width in pixels (columns) */\n   png_uint_32  height;    /* Image height in pixels (rows) */\n   png_uint_32  format;    /* Image format as defined below */\n   png_uint_32  flags;     /* A bit mask containing informational flags */\n   png_uint_32  colormap_entries;\n                           /* Number of entries in the color-map */\n\n   /* In the event of an error or warning the following field will be set to a\n    * non-zero value and the 'message' field will contain a '\\0' terminated\n    * string with the libpng error or warning message.  If both warnings and\n    * an error were encountered, only the error is recorded.  If there\n    * are multiple warnings, only the first one is recorded.\n    *\n    * The upper 30 bits of this value are reserved, the low two bits contain\n    * a value as follows:\n    */\n#  define PNG_IMAGE_WARNING 1\n#  define PNG_IMAGE_ERROR 2\n   /*\n    * The result is a two bit code such that a value more than 1 indicates\n    * a failure in the API just called:\n    *\n    *    0 - no warning or error\n    *    1 - warning\n    *    2 - error\n    *    3 - error preceded by warning\n    */\n#  define PNG_IMAGE_FAILED(png_cntrl) ((((png_cntrl).warning_or_error)&0x03)>1)\n\n   png_uint_32  warning_or_error;\n\n   char         message[64];\n} png_image, *png_imagep;\n\n/* The samples of the image have one to four channels whose components have\n * original values in the range 0 to 1.0:\n *\n * 1: A single gray or luminance channel (G).\n * 2: A gray/luminance channel and an alpha channel (GA).\n * 3: Three red, green, blue color channels (RGB).\n * 4: Three color channels and an alpha channel (RGBA).\n *\n * The components are encoded in one of two ways:\n *\n * a) As a small integer, value 0..255, contained in a single byte.  For the\n * alpha channel the original value is simply value/255.  For the color or\n * luminance channels the value is encoded according to the sRGB specification\n * and matches the 8-bit format expected by typical display devices.\n *\n * The color/gray channels are not scaled (pre-multiplied) by the alpha\n * channel and are suitable for passing to color management software.\n *\n * b) As a value in the range 0..65535, contained in a 2-byte integer.  All\n * channels can be converted to the original value by dividing by 65535; all\n * channels are linear.  Color channels use the RGB encoding (RGB end-points) of\n * the sRGB specification.  This encoding is identified by the\n * PNG_FORMAT_FLAG_LINEAR flag below.\n *\n * When the simplified API needs to convert between sRGB and linear colorspaces,\n * the actual sRGB transfer curve defined in the sRGB specification (see the\n * article at http://en.wikipedia.org/wiki/SRGB) is used, not the gamma=1/2.2\n * approximation used elsewhere in libpng.\n *\n * When an alpha channel is present it is expected to denote pixel coverage\n * of the color or luminance channels and is returned as an associated alpha\n * channel: the color/gray channels are scaled (pre-multiplied) by the alpha\n * value.\n *\n * The samples are either contained directly in the image data, between 1 and 8\n * bytes per pixel according to the encoding, or are held in a color-map indexed\n * by bytes in the image data.  In the case of a color-map the color-map entries\n * are individual samples, encoded as above, and the image data has one byte per\n * pixel to select the relevant sample from the color-map.\n */\n\n/* PNG_FORMAT_*\n *\n * #defines to be used in png_image::format.  Each #define identifies a\n * particular layout of sample data and, if present, alpha values.  There are\n * separate defines for each of the two component encodings.\n *\n * A format is built up using single bit flag values.  All combinations are\n * valid.  Formats can be built up from the flag values or you can use one of\n * the predefined values below.  When testing formats always use the FORMAT_FLAG\n * macros to test for individual features - future versions of the library may\n * add new flags.\n *\n * When reading or writing color-mapped images the format should be set to the\n * format of the entries in the color-map then png_image_{read,write}_colormap\n * called to read or write the color-map and set the format correctly for the\n * image data.  Do not set the PNG_FORMAT_FLAG_COLORMAP bit directly!\n *\n * NOTE: libpng can be built with particular features disabled, if you see\n * compiler errors because the definition of one of the following flags has been\n * compiled out it is because libpng does not have the required support.  It is\n * possible, however, for the libpng configuration to enable the format on just\n * read or just write; in that case you may see an error at run time.  You can\n * guard against this by checking for the definition of the appropriate\n * \"_SUPPORTED\" macro, one of:\n *\n *    PNG_SIMPLIFIED_{READ,WRITE}_{BGR,AFIRST}_SUPPORTED\n */\n#define PNG_FORMAT_FLAG_ALPHA    0x01U /* format with an alpha channel */\n#define PNG_FORMAT_FLAG_COLOR    0x02U /* color format: otherwise grayscale */\n#define PNG_FORMAT_FLAG_LINEAR   0x04U /* 2 byte channels else 1 byte */\n#define PNG_FORMAT_FLAG_COLORMAP 0x08U /* image data is color-mapped */\n\n#ifdef PNG_FORMAT_BGR_SUPPORTED\n#  define PNG_FORMAT_FLAG_BGR    0x10U /* BGR colors, else order is RGB */\n#endif\n\n#ifdef PNG_FORMAT_AFIRST_SUPPORTED\n#  define PNG_FORMAT_FLAG_AFIRST 0x20U /* alpha channel comes first */\n#endif\n\n/* Commonly used formats have predefined macros.\n *\n * First the single byte (sRGB) formats:\n */\n#define PNG_FORMAT_GRAY 0\n#define PNG_FORMAT_GA   PNG_FORMAT_FLAG_ALPHA\n#define PNG_FORMAT_AG   (PNG_FORMAT_GA|PNG_FORMAT_FLAG_AFIRST)\n#define PNG_FORMAT_RGB  PNG_FORMAT_FLAG_COLOR\n#define PNG_FORMAT_BGR  (PNG_FORMAT_FLAG_COLOR|PNG_FORMAT_FLAG_BGR)\n#define PNG_FORMAT_RGBA (PNG_FORMAT_RGB|PNG_FORMAT_FLAG_ALPHA)\n#define PNG_FORMAT_ARGB (PNG_FORMAT_RGBA|PNG_FORMAT_FLAG_AFIRST)\n#define PNG_FORMAT_BGRA (PNG_FORMAT_BGR|PNG_FORMAT_FLAG_ALPHA)\n#define PNG_FORMAT_ABGR (PNG_FORMAT_BGRA|PNG_FORMAT_FLAG_AFIRST)\n\n/* Then the linear 2-byte formats.  When naming these \"Y\" is used to\n * indicate a luminance (gray) channel.\n */\n#define PNG_FORMAT_LINEAR_Y PNG_FORMAT_FLAG_LINEAR\n#define PNG_FORMAT_LINEAR_Y_ALPHA (PNG_FORMAT_FLAG_LINEAR|PNG_FORMAT_FLAG_ALPHA)\n#define PNG_FORMAT_LINEAR_RGB (PNG_FORMAT_FLAG_LINEAR|PNG_FORMAT_FLAG_COLOR)\n#define PNG_FORMAT_LINEAR_RGB_ALPHA \\\n   (PNG_FORMAT_FLAG_LINEAR|PNG_FORMAT_FLAG_COLOR|PNG_FORMAT_FLAG_ALPHA)\n\n/* With color-mapped formats the image data is one byte for each pixel, the byte\n * is an index into the color-map which is formatted as above.  To obtain a\n * color-mapped format it is sufficient just to add the PNG_FOMAT_FLAG_COLORMAP\n * to one of the above definitions, or you can use one of the definitions below.\n */\n#define PNG_FORMAT_RGB_COLORMAP  (PNG_FORMAT_RGB|PNG_FORMAT_FLAG_COLORMAP)\n#define PNG_FORMAT_BGR_COLORMAP  (PNG_FORMAT_BGR|PNG_FORMAT_FLAG_COLORMAP)\n#define PNG_FORMAT_RGBA_COLORMAP (PNG_FORMAT_RGBA|PNG_FORMAT_FLAG_COLORMAP)\n#define PNG_FORMAT_ARGB_COLORMAP (PNG_FORMAT_ARGB|PNG_FORMAT_FLAG_COLORMAP)\n#define PNG_FORMAT_BGRA_COLORMAP (PNG_FORMAT_BGRA|PNG_FORMAT_FLAG_COLORMAP)\n#define PNG_FORMAT_ABGR_COLORMAP (PNG_FORMAT_ABGR|PNG_FORMAT_FLAG_COLORMAP)\n\n/* PNG_IMAGE macros\n *\n * These are convenience macros to derive information from a png_image\n * structure.  The PNG_IMAGE_SAMPLE_ macros return values appropriate to the\n * actual image sample values - either the entries in the color-map or the\n * pixels in the image.  The PNG_IMAGE_PIXEL_ macros return corresponding values\n * for the pixels and will always return 1 for color-mapped formats.  The\n * remaining macros return information about the rows in the image and the\n * complete image.\n *\n * NOTE: All the macros that take a png_image::format parameter are compile time\n * constants if the format parameter is, itself, a constant.  Therefore these\n * macros can be used in array declarations and case labels where required.\n * Similarly the macros are also pre-processor constants (sizeof is not used) so\n * they can be used in #if tests.\n *\n * First the information about the samples.\n */\n#define PNG_IMAGE_SAMPLE_CHANNELS(fmt)\\\n   (((fmt)&(PNG_FORMAT_FLAG_COLOR|PNG_FORMAT_FLAG_ALPHA))+1)\n   /* Return the total number of channels in a given format: 1..4 */\n\n#define PNG_IMAGE_SAMPLE_COMPONENT_SIZE(fmt)\\\n   ((((fmt) & PNG_FORMAT_FLAG_LINEAR) >> 2)+1)\n   /* Return the size in bytes of a single component of a pixel or color-map\n    * entry (as appropriate) in the image: 1 or 2.\n    */\n\n#define PNG_IMAGE_SAMPLE_SIZE(fmt)\\\n   (PNG_IMAGE_SAMPLE_CHANNELS(fmt) * PNG_IMAGE_SAMPLE_COMPONENT_SIZE(fmt))\n   /* This is the size of the sample data for one sample.  If the image is\n    * color-mapped it is the size of one color-map entry (and image pixels are\n    * one byte in size), otherwise it is the size of one image pixel.\n    */\n\n#define PNG_IMAGE_MAXIMUM_COLORMAP_COMPONENTS(fmt)\\\n   (PNG_IMAGE_SAMPLE_CHANNELS(fmt) * 256)\n   /* The maximum size of the color-map required by the format expressed in a\n    * count of components.  This can be used to compile-time allocate a\n    * color-map:\n    *\n    * png_uint_16 colormap[PNG_IMAGE_MAXIMUM_COLORMAP_COMPONENTS(linear_fmt)];\n    *\n    * png_byte colormap[PNG_IMAGE_MAXIMUM_COLORMAP_COMPONENTS(sRGB_fmt)];\n    *\n    * Alternatively use the PNG_IMAGE_COLORMAP_SIZE macro below to use the\n    * information from one of the png_image_begin_read_ APIs and dynamically\n    * allocate the required memory.\n    */\n\n/* Corresponding information about the pixels */\n#define PNG_IMAGE_PIXEL_(test,fmt)\\\n   (((fmt)&PNG_FORMAT_FLAG_COLORMAP)?1:test(fmt))\n\n#define PNG_IMAGE_PIXEL_CHANNELS(fmt)\\\n   PNG_IMAGE_PIXEL_(PNG_IMAGE_SAMPLE_CHANNELS,fmt)\n   /* The number of separate channels (components) in a pixel; 1 for a\n    * color-mapped image.\n    */\n\n#define PNG_IMAGE_PIXEL_COMPONENT_SIZE(fmt)\\\n   PNG_IMAGE_PIXEL_(PNG_IMAGE_SAMPLE_COMPONENT_SIZE,fmt)\n   /* The size, in bytes, of each component in a pixel; 1 for a color-mapped\n    * image.\n    */\n\n#define PNG_IMAGE_PIXEL_SIZE(fmt) PNG_IMAGE_PIXEL_(PNG_IMAGE_SAMPLE_SIZE,fmt)\n   /* The size, in bytes, of a complete pixel; 1 for a color-mapped image. */\n\n/* Information about the whole row, or whole image */\n#define PNG_IMAGE_ROW_STRIDE(image)\\\n   (PNG_IMAGE_PIXEL_CHANNELS((image).format) * (image).width)\n   /* Return the total number of components in a single row of the image; this\n    * is the minimum 'row stride', the minimum count of components between each\n    * row.  For a color-mapped image this is the minimum number of bytes in a\n    * row.\n    */\n\n#define PNG_IMAGE_BUFFER_SIZE(image, row_stride)\\\n   (PNG_IMAGE_PIXEL_COMPONENT_SIZE((image).format)*(image).height*(row_stride))\n   /* Return the size, in bytes, of an image buffer given a png_image and a row\n    * stride - the number of components to leave space for in each row.\n    */\n\n#define PNG_IMAGE_SIZE(image)\\\n   PNG_IMAGE_BUFFER_SIZE(image, PNG_IMAGE_ROW_STRIDE(image))\n   /* Return the size, in bytes, of the image in memory given just a png_image;\n    * the row stride is the minimum stride required for the image.\n    */\n\n#define PNG_IMAGE_COLORMAP_SIZE(image)\\\n   (PNG_IMAGE_SAMPLE_SIZE((image).format) * (image).colormap_entries)\n   /* Return the size, in bytes, of the color-map of this image.  If the image\n    * format is not a color-map format this will return a size sufficient for\n    * 256 entries in the given format; check PNG_FORMAT_FLAG_COLORMAP if\n    * you don't want to allocate a color-map in this case.\n    */\n\n/* PNG_IMAGE_FLAG_*\n *\n * Flags containing additional information about the image are held in the\n * 'flags' field of png_image.\n */\n#define PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB 0x01\n   /* This indicates the the RGB values of the in-memory bitmap do not\n    * correspond to the red, green and blue end-points defined by sRGB.\n    */\n\n#define PNG_IMAGE_FLAG_FAST 0x02\n   /* On write emphasise speed over compression; the resultant PNG file will be\n    * larger but will be produced significantly faster, particular for large\n    * images.  Do not use this option for images which will be distributed, only\n    * used it when producing intermediate files that will be read back in\n    * repeatedly.  For a typical 24-bit image the option will double the read\n    * speed at the cost of increasing the image size by 25%, however for many\n    * more compressible images the PNG file can be 10 times larger with only a\n    * slight speed gain.\n    */\n\n#define PNG_IMAGE_FLAG_16BIT_sRGB 0x04\n   /* On read if the image is a 16-bit per component image and there is no gAMA\n    * or sRGB chunk assume that the components are sRGB encoded.  Notice that\n    * images output by the simplified API always have gamma information; setting\n    * this flag only affects the interpretation of 16-bit images from an\n    * external source.  It is recommended that the application expose this flag\n    * to the user; the user can normally easily recognize the difference between\n    * linear and sRGB encoding.  This flag has no effect on write - the data\n    * passed to the write APIs must have the correct encoding (as defined\n    * above.)\n    *\n    * If the flag is not set (the default) input 16-bit per component data is\n    * assumed to be linear.\n    *\n    * NOTE: the flag can only be set after the png_image_begin_read_ call,\n    * because that call initializes the 'flags' field.\n    */\n\n#ifdef PNG_SIMPLIFIED_READ_SUPPORTED\n/* READ APIs\n * ---------\n *\n * The png_image passed to the read APIs must have been initialized by setting\n * the png_controlp field 'opaque' to NULL (or, safer, memset the whole thing.)\n */\n#ifdef PNG_STDIO_SUPPORTED\nPNG_EXPORT(234, int, png_image_begin_read_from_file, (png_imagep image,\n   const char *file_name));\n   /* The named file is opened for read and the image header is filled in\n    * from the PNG header in the file.\n    */\n\nPNG_EXPORT(235, int, png_image_begin_read_from_stdio, (png_imagep image,\n   FILE* file));\n   /* The PNG header is read from the stdio FILE object. */\n#endif /* PNG_STDIO_SUPPORTED */\n\nPNG_EXPORT(236, int, png_image_begin_read_from_memory, (png_imagep image,\n   png_const_voidp memory, png_size_t size));\n   /* The PNG header is read from the given memory buffer. */\n\nPNG_EXPORT(237, int, png_image_finish_read, (png_imagep image,\n   png_const_colorp background, void *buffer, png_int_32 row_stride,\n   void *colormap));\n   /* Finish reading the image into the supplied buffer and clean up the\n    * png_image structure.\n    *\n    * row_stride is the step, in byte or 2-byte units as appropriate,\n    * between adjacent rows.  A positive stride indicates that the top-most row\n    * is first in the buffer - the normal top-down arrangement.  A negative\n    * stride indicates that the bottom-most row is first in the buffer.\n    *\n    * background need only be supplied if an alpha channel must be removed from\n    * a png_byte format and the removal is to be done by compositing on a solid\n    * color; otherwise it may be NULL and any composition will be done directly\n    * onto the buffer.  The value is an sRGB color to use for the background,\n    * for grayscale output the green channel is used.\n    *\n    * background must be supplied when an alpha channel must be removed from a\n    * single byte color-mapped output format, in other words if:\n    *\n    * 1) The original format from png_image_begin_read_from_* had\n    *    PNG_FORMAT_FLAG_ALPHA set.\n    * 2) The format set by the application does not.\n    * 3) The format set by the application has PNG_FORMAT_FLAG_COLORMAP set and\n    *    PNG_FORMAT_FLAG_LINEAR *not* set.\n    *\n    * For linear output removing the alpha channel is always done by compositing\n    * on black and background is ignored.\n    *\n    * colormap must be supplied when PNG_FORMAT_FLAG_COLORMAP is set.  It must\n    * be at least the size (in bytes) returned by PNG_IMAGE_COLORMAP_SIZE.\n    * image->colormap_entries will be updated to the actual number of entries\n    * written to the colormap; this may be less than the original value.\n    */\n\nPNG_EXPORT(238, void, png_image_free, (png_imagep image));\n   /* Free any data allocated by libpng in image->opaque, setting the pointer to\n    * NULL.  May be called at any time after the structure is initialized.\n    */\n#endif /* PNG_SIMPLIFIED_READ_SUPPORTED */\n\n#ifdef PNG_SIMPLIFIED_WRITE_SUPPORTED\n#ifdef PNG_STDIO_SUPPORTED\n/* WRITE APIS\n * ----------\n * For write you must initialize a png_image structure to describe the image to\n * be written.  To do this use memset to set the whole structure to 0 then\n * initialize fields describing your image.\n *\n * version: must be set to PNG_IMAGE_VERSION\n * opaque: must be initialized to NULL\n * width: image width in pixels\n * height: image height in rows\n * format: the format of the data (image and color-map) you wish to write\n * flags: set to 0 unless one of the defined flags applies; set\n *    PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB for color format images where the RGB\n *    values do not correspond to the colors in sRGB.\n * colormap_entries: set to the number of entries in the color-map (0 to 256)\n */\nPNG_EXPORT(239, int, png_image_write_to_file, (png_imagep image,\n   const char *file, int convert_to_8bit, const void *buffer,\n   png_int_32 row_stride, const void *colormap));\n   /* Write the image to the named file. */\n\nPNG_EXPORT(240, int, png_image_write_to_stdio, (png_imagep image, FILE *file,\n   int convert_to_8_bit, const void *buffer, png_int_32 row_stride,\n   const void *colormap));\n   /* Write the image to the given (FILE*). */\n\n/* With both write APIs if image is in one of the linear formats with 16-bit\n * data then setting convert_to_8_bit will cause the output to be an 8-bit PNG\n * gamma encoded according to the sRGB specification, otherwise a 16-bit linear\n * encoded PNG file is written.\n *\n * With color-mapped data formats the colormap parameter point to a color-map\n * with at least image->colormap_entries encoded in the specified format.  If\n * the format is linear the written PNG color-map will be converted to sRGB\n * regardless of the convert_to_8_bit flag.\n *\n * With all APIs row_stride is handled as in the read APIs - it is the spacing\n * from one row to the next in component sized units (1 or 2 bytes) and if\n * negative indicates a bottom-up row layout in the buffer.\n *\n * Note that the write API does not support interlacing or sub-8-bit pixels.\n */\n#endif /* PNG_STDIO_SUPPORTED */\n#endif /* PNG_SIMPLIFIED_WRITE_SUPPORTED */\n/*******************************************************************************\n *  END OF SIMPLIFIED API\n ******************************************************************************/\n\n#ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED\nPNG_EXPORT(242, void, png_set_check_for_invalid_index,\n    (png_structrp png_ptr, int allowed));\n#  ifdef PNG_GET_PALETTE_MAX_SUPPORTED\nPNG_EXPORT(243, int, png_get_palette_max, (png_const_structp png_ptr,\n    png_const_infop info_ptr));\n#  endif\n#endif /* CHECK_FOR_INVALID_INDEX */\n\n/*******************************************************************************\n *  IMPLEMENTATION OPTIONS\n *******************************************************************************\n *\n * Support for arbitrary implementation-specific optimizations.  The API allows\n * particular options to be turned on or off.  'Option' is the number of the\n * option and 'onoff' is 0 (off) or non-0 (on).  The value returned is given\n * by the PNG_OPTION_ defines below.\n *\n * HARDWARE: normally hardware capabilites, such as the Intel SSE instructions,\n *           are detected at run time, however sometimes it may be impossible\n *           to do this in user mode, in which case it is necessary to discover\n *           the capabilities in an OS specific way.  Such capabilities are\n *           listed here when libpng has support for them and must be turned\n *           ON by the application if present.\n *\n * SOFTWARE: sometimes software optimizations actually result in performance\n *           decrease on some architectures or systems, or with some sets of\n *           PNG images.  'Software' options allow such optimizations to be\n *           selected at run time.\n */\n#ifdef PNG_SET_OPTION_SUPPORTED\n#ifdef PNG_ARM_NEON_API_SUPPORTED\n#  define PNG_ARM_NEON   0 /* HARDWARE: ARM Neon SIMD instructions supported */\n#endif\n#define PNG_MAXIMUM_INFLATE_WINDOW 2 /* SOFTWARE: force maximum window */\n#define PNG_OPTION_NEXT  4 /* Next option - numbers must be even */\n\n/* Return values: NOTE: there are four values and 'off' is *not* zero */\n#define PNG_OPTION_UNSET   0 /* Unset - defaults to off */\n#define PNG_OPTION_INVALID 1 /* Option number out of range */\n#define PNG_OPTION_OFF     2\n#define PNG_OPTION_ON      3\n\nPNG_EXPORT(244, int, png_set_option, (png_structrp png_ptr, int option,\n   int onoff));\n#endif\n\n/*******************************************************************************\n *  END OF HARDWARE OPTIONS\n ******************************************************************************/\n\n/* Maintainer: Put new public prototypes here ^, in libpng.3, and project\n * defs, scripts/pnglibconf.h, and scripts/pnglibconf.h.prebuilt\n */\n\n/* The last ordinal number (this is the *last* one already used; the next\n * one to use is one more than this.)  Maintainer, remember to add an entry to\n * scripts/symbols.def as well.\n */\n#ifdef PNG_EXPORT_LAST_ORDINAL\n  PNG_EXPORT_LAST_ORDINAL(244);\n#endif\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* PNG_VERSION_INFO_ONLY */\n/* Do not put anything past this line */\n#endif /* PNG_H */\n"
  },
  {
    "path": "Libraries/Core/Android/Headers/png/pngconf.h",
    "content": "\n/* pngconf.h - machine configurable file for libpng\n *\n * libpng version 1.6.10 - March 6, 2014\n *\n * Copyright (c) 1998-2013 Glenn Randers-Pehrson\n * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)\n * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)\n *\n * This code is released under the libpng license.\n * For conditions of distribution and use, see the disclaimer\n * and license in png.h\n *\n */\n\n/* Any machine specific code is near the front of this file, so if you\n * are configuring libpng for a machine, you may want to read the section\n * starting here down to where it starts to typedef png_color, png_text,\n * and png_info.\n */\n\n#ifndef PNGCONF_H\n#define PNGCONF_H\n\n/* To do: Do all of this in scripts/pnglibconf.dfa */\n#ifdef PNG_SAFE_LIMITS_SUPPORTED\n#  ifdef PNG_USER_WIDTH_MAX\n#    undef PNG_USER_WIDTH_MAX\n#    define PNG_USER_WIDTH_MAX 1000000L\n#  endif\n#  ifdef PNG_USER_HEIGHT_MAX\n#    undef PNG_USER_HEIGHT_MAX\n#    define PNG_USER_HEIGHT_MAX 1000000L\n#  endif\n#  ifdef PNG_USER_CHUNK_MALLOC_MAX\n#    undef PNG_USER_CHUNK_MALLOC_MAX\n#    define PNG_USER_CHUNK_MALLOC_MAX 4000000L\n#  endif\n#  ifdef PNG_USER_CHUNK_CACHE_MAX\n#    undef PNG_USER_CHUNK_CACHE_MAX\n#    define PNG_USER_CHUNK_CACHE_MAX 128\n#  endif\n#endif\n\n#ifndef PNG_BUILDING_SYMBOL_TABLE /* else includes may cause problems */\n\n/* From libpng 1.6.0 libpng requires an ANSI X3.159-1989 (\"ISOC90\") compliant C\n * compiler for correct compilation.  The following header files are required by\n * the standard.  If your compiler doesn't provide these header files, or they\n * do not match the standard, you will need to provide/improve them.\n */\n#include <limits.h>\n#include <stddef.h>\n\n/* Library header files.  These header files are all defined by ISOC90; libpng\n * expects conformant implementations, however, an ISOC90 conformant system need\n * not provide these header files if the functionality cannot be implemented.\n * In this case it will be necessary to disable the relevant parts of libpng in\n * the build of pnglibconf.h.\n *\n * Prior to 1.6.0 string.h was included here; the API changes in 1.6.0 to not\n * include this unnecessary header file.\n */\n\n#ifdef PNG_STDIO_SUPPORTED\n   /* Required for the definition of FILE: */\n#  include <stdio.h>\n#endif\n\n#ifdef PNG_SETJMP_SUPPORTED\n   /* Required for the definition of jmp_buf and the declaration of longjmp: */\n#  include <setjmp.h>\n#endif\n\n#ifdef PNG_CONVERT_tIME_SUPPORTED\n   /* Required for struct tm: */\n#  include <time.h>\n#endif\n\n#endif /* PNG_BUILDING_SYMBOL_TABLE */\n\n/* Prior to 1.6.0 it was possible to turn off 'const' in declarations using\n * PNG_NO_CONST; this is no longer supported except for data declarations which\n * apparently still cause problems in 2011 on some compilers.\n */\n#define PNG_CONST const /* backward compatibility only */\n\n/* This controls optimization of the reading of 16 and 32 bit values\n * from PNG files.  It can be set on a per-app-file basis - it\n * just changes whether a macro is used when the function is called.\n * The library builder sets the default; if read functions are not\n * built into the library the macro implementation is forced on.\n */\n#ifndef PNG_READ_INT_FUNCTIONS_SUPPORTED\n#  define PNG_USE_READ_MACROS\n#endif\n#if !defined(PNG_NO_USE_READ_MACROS) && !defined(PNG_USE_READ_MACROS)\n#  if PNG_DEFAULT_READ_MACROS\n#    define PNG_USE_READ_MACROS\n#  endif\n#endif\n\n/* COMPILER SPECIFIC OPTIONS.\n *\n * These options are provided so that a variety of difficult compilers\n * can be used.  Some are fixed at build time (e.g. PNG_API_RULE\n * below) but still have compiler specific implementations, others\n * may be changed on a per-file basis when compiling against libpng.\n */\n\n/* The PNGARG macro was used in versions of libpng prior to 1.6.0 to protect\n * against legacy (pre ISOC90) compilers that did not understand function\n * prototypes.  It is not required for modern C compilers.\n */\n#ifndef PNGARG\n#  define PNGARG(arglist) arglist\n#endif\n\n/* Function calling conventions.\n * =============================\n * Normally it is not necessary to specify to the compiler how to call\n * a function - it just does it - however on x86 systems derived from\n * Microsoft and Borland C compilers ('IBM PC', 'DOS', 'Windows' systems\n * and some others) there are multiple ways to call a function and the\n * default can be changed on the compiler command line.  For this reason\n * libpng specifies the calling convention of every exported function and\n * every function called via a user supplied function pointer.  This is\n * done in this file by defining the following macros:\n *\n * PNGAPI    Calling convention for exported functions.\n * PNGCBAPI  Calling convention for user provided (callback) functions.\n * PNGCAPI   Calling convention used by the ANSI-C library (required\n *           for longjmp callbacks and sometimes used internally to\n *           specify the calling convention for zlib).\n *\n * These macros should never be overridden.  If it is necessary to\n * change calling convention in a private build this can be done\n * by setting PNG_API_RULE (which defaults to 0) to one of the values\n * below to select the correct 'API' variants.\n *\n * PNG_API_RULE=0 Use PNGCAPI - the 'C' calling convention - throughout.\n *                This is correct in every known environment.\n * PNG_API_RULE=1 Use the operating system convention for PNGAPI and\n *                the 'C' calling convention (from PNGCAPI) for\n *                callbacks (PNGCBAPI).  This is no longer required\n *                in any known environment - if it has to be used\n *                please post an explanation of the problem to the\n *                libpng mailing list.\n *\n * These cases only differ if the operating system does not use the C\n * calling convention, at present this just means the above cases\n * (x86 DOS/Windows sytems) and, even then, this does not apply to\n * Cygwin running on those systems.\n *\n * Note that the value must be defined in pnglibconf.h so that what\n * the application uses to call the library matches the conventions\n * set when building the library.\n */\n\n/* Symbol export\n * =============\n * When building a shared library it is almost always necessary to tell\n * the compiler which symbols to export.  The png.h macro 'PNG_EXPORT'\n * is used to mark the symbols.  On some systems these symbols can be\n * extracted at link time and need no special processing by the compiler,\n * on other systems the symbols are flagged by the compiler and just\n * the declaration requires a special tag applied (unfortunately) in a\n * compiler dependent way.  Some systems can do either.\n *\n * A small number of older systems also require a symbol from a DLL to\n * be flagged to the program that calls it.  This is a problem because\n * we do not know in the header file included by application code that\n * the symbol will come from a shared library, as opposed to a statically\n * linked one.  For this reason the application must tell us by setting\n * the magic flag PNG_USE_DLL to turn on the special processing before\n * it includes png.h.\n *\n * Four additional macros are used to make this happen:\n *\n * PNG_IMPEXP The magic (if any) to cause a symbol to be exported from\n *            the build or imported if PNG_USE_DLL is set - compiler\n *            and system specific.\n *\n * PNG_EXPORT_TYPE(type) A macro that pre or appends PNG_IMPEXP to\n *                       'type', compiler specific.\n *\n * PNG_DLL_EXPORT Set to the magic to use during a libpng build to\n *                make a symbol exported from the DLL.  Not used in the\n *                public header files; see pngpriv.h for how it is used\n *                in the libpng build.\n *\n * PNG_DLL_IMPORT Set to the magic to force the libpng symbols to come\n *                from a DLL - used to define PNG_IMPEXP when\n *                PNG_USE_DLL is set.\n */\n\n/* System specific discovery.\n * ==========================\n * This code is used at build time to find PNG_IMPEXP, the API settings\n * and PNG_EXPORT_TYPE(), it may also set a macro to indicate the DLL\n * import processing is possible.  On Windows systems it also sets\n * compiler-specific macros to the values required to change the calling\n * conventions of the various functions.\n */\n#if defined(_Windows) || defined(_WINDOWS) || defined(WIN32) ||\\\n    defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)\n  /* Windows system (DOS doesn't support DLLs).  Includes builds under Cygwin or\n   * MinGW on any architecture currently supported by Windows.  Also includes\n   * Watcom builds but these need special treatment because they are not\n   * compatible with GCC or Visual C because of different calling conventions.\n   */\n#  if PNG_API_RULE == 2\n    /* If this line results in an error, either because __watcall is not\n     * understood or because of a redefine just below you cannot use *this*\n     * build of the library with the compiler you are using.  *This* build was\n     * build using Watcom and applications must also be built using Watcom!\n     */\n#    define PNGCAPI __watcall\n#  endif\n\n#  if defined(__GNUC__) || (defined(_MSC_VER) && (_MSC_VER >= 800))\n#    define PNGCAPI __cdecl\n#    if PNG_API_RULE == 1\n       /* If this line results in an error __stdcall is not understood and\n        * PNG_API_RULE should not have been set to '1'.\n        */\n#      define PNGAPI __stdcall\n#    endif\n#  else\n    /* An older compiler, or one not detected (erroneously) above,\n     * if necessary override on the command line to get the correct\n     * variants for the compiler.\n     */\n#    ifndef PNGCAPI\n#      define PNGCAPI _cdecl\n#    endif\n#    if PNG_API_RULE == 1 && !defined(PNGAPI)\n#      define PNGAPI _stdcall\n#    endif\n#  endif /* compiler/api */\n\n  /* NOTE: PNGCBAPI always defaults to PNGCAPI. */\n\n#  if defined(PNGAPI) && !defined(PNG_USER_PRIVATEBUILD)\n#     error \"PNG_USER_PRIVATEBUILD must be defined if PNGAPI is changed\"\n#  endif\n\n#  if (defined(_MSC_VER) && _MSC_VER < 800) ||\\\n      (defined(__BORLANDC__) && __BORLANDC__ < 0x500)\n    /* older Borland and MSC\n     * compilers used '__export' and required this to be after\n     * the type.\n     */\n#    ifndef PNG_EXPORT_TYPE\n#      define PNG_EXPORT_TYPE(type) type PNG_IMPEXP\n#    endif\n#    define PNG_DLL_EXPORT __export\n#  else /* newer compiler */\n#    define PNG_DLL_EXPORT __declspec(dllexport)\n#    ifndef PNG_DLL_IMPORT\n#      define PNG_DLL_IMPORT __declspec(dllimport)\n#    endif\n#  endif /* compiler */\n\n#else /* !Windows */\n#  if (defined(__IBMC__) || defined(__IBMCPP__)) && defined(__OS2__)\n#    define PNGAPI _System\n#  else /* !Windows/x86 && !OS/2 */\n    /* Use the defaults, or define PNG*API on the command line (but\n     * this will have to be done for every compile!)\n     */\n#  endif /* other system, !OS/2 */\n#endif /* !Windows/x86 */\n\n/* Now do all the defaulting . */\n#ifndef PNGCAPI\n#  define PNGCAPI\n#endif\n#ifndef PNGCBAPI\n#  define PNGCBAPI PNGCAPI\n#endif\n#ifndef PNGAPI\n#  define PNGAPI PNGCAPI\n#endif\n\n/* PNG_IMPEXP may be set on the compilation system command line or (if not set)\n * then in an internal header file when building the library, otherwise (when\n * using the library) it is set here.\n */\n#ifndef PNG_IMPEXP\n#  if defined(PNG_USE_DLL) && defined(PNG_DLL_IMPORT)\n     /* This forces use of a DLL, disallowing static linking */\n#    define PNG_IMPEXP PNG_DLL_IMPORT\n#  endif\n\n#  ifndef PNG_IMPEXP\n#    define PNG_IMPEXP\n#  endif\n#endif\n\n/* In 1.5.2 the definition of PNG_FUNCTION has been changed to always treat\n * 'attributes' as a storage class - the attributes go at the start of the\n * function definition, and attributes are always appended regardless of the\n * compiler.  This considerably simplifies these macros but may cause problems\n * if any compilers both need function attributes and fail to handle them as\n * a storage class (this is unlikely.)\n */\n#ifndef PNG_FUNCTION\n#  define PNG_FUNCTION(type, name, args, attributes) attributes type name args\n#endif\n\n#ifndef PNG_EXPORT_TYPE\n#  define PNG_EXPORT_TYPE(type) PNG_IMPEXP type\n#endif\n\n   /* The ordinal value is only relevant when preprocessing png.h for symbol\n    * table entries, so we discard it here.  See the .dfn files in the\n    * scripts directory.\n    */\n#ifndef PNG_EXPORTA\n\n#  define PNG_EXPORTA(ordinal, type, name, args, attributes)\\\n      PNG_FUNCTION(PNG_EXPORT_TYPE(type),(PNGAPI name),PNGARG(args), \\\n        extern attributes)\n#endif\n\n/* ANSI-C (C90) does not permit a macro to be invoked with an empty argument,\n * so make something non-empty to satisfy the requirement:\n */\n#define PNG_EMPTY /*empty list*/\n\n#define PNG_EXPORT(ordinal, type, name, args)\\\n   PNG_EXPORTA(ordinal, type, name, args, PNG_EMPTY)\n\n/* Use PNG_REMOVED to comment out a removed interface. */\n#ifndef PNG_REMOVED\n#  define PNG_REMOVED(ordinal, type, name, args, attributes)\n#endif\n\n#ifndef PNG_CALLBACK\n#  define PNG_CALLBACK(type, name, args) type (PNGCBAPI name) PNGARG(args)\n#endif\n\n/* Support for compiler specific function attributes.  These are used\n * so that where compiler support is available incorrect use of API\n * functions in png.h will generate compiler warnings.\n *\n * Added at libpng-1.2.41.\n */\n\n#ifndef PNG_NO_PEDANTIC_WARNINGS\n#  ifndef PNG_PEDANTIC_WARNINGS_SUPPORTED\n#    define PNG_PEDANTIC_WARNINGS_SUPPORTED\n#  endif\n#endif\n\n#ifdef PNG_PEDANTIC_WARNINGS_SUPPORTED\n  /* Support for compiler specific function attributes.  These are used\n   * so that where compiler support is available, incorrect use of API\n   * functions in png.h will generate compiler warnings.  Added at libpng\n   * version 1.2.41.  Disabling these removes the warnings but may also produce\n   * less efficient code.\n   */\n#  if defined(__clang__)\n     /* Clang defines both __clang__ and __GNUC__. Check __clang__ first. */\n#    if !defined(PNG_USE_RESULT) && __has_attribute(__warn_unused_result__)\n#      define PNG_USE_RESULT __attribute__((__warn_unused_result__))\n#    endif\n#    if !defined(PNG_NORETURN) && __has_attribute(__noreturn__)\n#      define PNG_NORETURN __attribute__((__noreturn__))\n#    endif\n#    if !defined(PNG_ALLOCATED) && __has_attribute(__malloc__)\n#      define PNG_ALLOCATED __attribute__((__malloc__))\n#    endif\n#    if !defined(PNG_DEPRECATED) && __has_attribute(__deprecated__)\n#      define PNG_DEPRECATED __attribute__((__deprecated__))\n#    endif\n#    if !defined(PNG_PRIVATE)\n#      ifdef __has_extension\n#        if __has_extension(attribute_unavailable_with_message)\n#          define PNG_PRIVATE __attribute__((__unavailable__(\\\n             \"This function is not exported by libpng.\")))\n#        endif\n#      endif\n#    endif\n#    ifndef PNG_RESTRICT\n#      define PNG_RESTRICT __restrict\n#    endif\n\n#  elif defined(__GNUC__)\n#    ifndef PNG_USE_RESULT\n#      define PNG_USE_RESULT __attribute__((__warn_unused_result__))\n#    endif\n#    ifndef PNG_NORETURN\n#      define PNG_NORETURN   __attribute__((__noreturn__))\n#    endif\n#    if __GNUC__ >= 3\n#      ifndef PNG_ALLOCATED\n#        define PNG_ALLOCATED  __attribute__((__malloc__))\n#      endif\n#      ifndef PNG_DEPRECATED\n#        define PNG_DEPRECATED __attribute__((__deprecated__))\n#      endif\n#      ifndef PNG_PRIVATE\n#        if 0 /* Doesn't work so we use deprecated instead*/\n#          define PNG_PRIVATE \\\n            __attribute__((warning(\"This function is not exported by libpng.\")))\n#        else\n#          define PNG_PRIVATE \\\n            __attribute__((__deprecated__))\n#        endif\n#      endif\n#      if ((__GNUC__ > 3) || !defined(__GNUC_MINOR__) || (__GNUC_MINOR__ >= 1))\n#        ifndef PNG_RESTRICT\n#          define PNG_RESTRICT __restrict\n#        endif\n#      endif /* __GNUC__.__GNUC_MINOR__ > 3.0 */\n#    endif /* __GNUC__ >= 3 */\n\n#  elif defined(_MSC_VER)  && (_MSC_VER >= 1300)\n#    ifndef PNG_USE_RESULT\n#      define PNG_USE_RESULT /* not supported */\n#    endif\n#    ifndef PNG_NORETURN\n#      define PNG_NORETURN   __declspec(noreturn)\n#    endif\n#    ifndef PNG_ALLOCATED\n#      if (_MSC_VER >= 1400)\n#        define PNG_ALLOCATED __declspec(restrict)\n#      endif\n#    endif\n#    ifndef PNG_DEPRECATED\n#      define PNG_DEPRECATED __declspec(deprecated)\n#    endif\n#    ifndef PNG_PRIVATE\n#      define PNG_PRIVATE __declspec(deprecated)\n#    endif\n#    ifndef PNG_RESTRICT\n#      if (_MSC_VER >= 1400)\n#        define PNG_RESTRICT __restrict\n#      endif\n#    endif\n\n#  elif defined(__WATCOMC__)\n#    ifndef PNG_RESTRICT\n#      define PNG_RESTRICT __restrict\n#    endif\n#  endif\n#endif /* PNG_PEDANTIC_WARNINGS */\n\n#ifndef PNG_DEPRECATED\n#  define PNG_DEPRECATED  /* Use of this function is deprecated */\n#endif\n#ifndef PNG_USE_RESULT\n#  define PNG_USE_RESULT  /* The result of this function must be checked */\n#endif\n#ifndef PNG_NORETURN\n#  define PNG_NORETURN    /* This function does not return */\n#endif\n#ifndef PNG_ALLOCATED\n#  define PNG_ALLOCATED   /* The result of the function is new memory */\n#endif\n#ifndef PNG_PRIVATE\n#  define PNG_PRIVATE     /* This is a private libpng function */\n#endif\n#ifndef PNG_RESTRICT\n#  define PNG_RESTRICT    /* The C99 \"restrict\" feature */\n#endif\n\n#ifndef PNG_FP_EXPORT     /* A floating point API. */\n#  ifdef PNG_FLOATING_POINT_SUPPORTED\n#     define PNG_FP_EXPORT(ordinal, type, name, args)\\\n         PNG_EXPORT(ordinal, type, name, args);\n#  else                   /* No floating point APIs */\n#     define PNG_FP_EXPORT(ordinal, type, name, args)\n#  endif\n#endif\n#ifndef PNG_FIXED_EXPORT  /* A fixed point API. */\n#  ifdef PNG_FIXED_POINT_SUPPORTED\n#     define PNG_FIXED_EXPORT(ordinal, type, name, args)\\\n         PNG_EXPORT(ordinal, type, name, args);\n#  else                   /* No fixed point APIs */\n#     define PNG_FIXED_EXPORT(ordinal, type, name, args)\n#  endif\n#endif\n\n#ifndef PNG_BUILDING_SYMBOL_TABLE\n/* Some typedefs to get us started.  These should be safe on most of the common\n * platforms.\n *\n * png_uint_32 and png_int_32 may, currently, be larger than required to hold a\n * 32-bit value however this is not normally advisable.\n *\n * png_uint_16 and png_int_16 should always be two bytes in size - this is\n * verified at library build time.\n *\n * png_byte must always be one byte in size.\n *\n * The checks below use constants from limits.h, as defined by the ISOC90\n * standard.\n */\n#if CHAR_BIT == 8 && UCHAR_MAX == 255\n   typedef unsigned char png_byte;\n#else\n#  error \"libpng requires 8 bit bytes\"\n#endif\n\n#if INT_MIN == -32768 && INT_MAX == 32767\n   typedef int png_int_16;\n#elif SHRT_MIN == -32768 && SHRT_MAX == 32767\n   typedef short png_int_16;\n#else\n#  error \"libpng requires a signed 16 bit type\"\n#endif\n\n#if UINT_MAX == 65535\n   typedef unsigned int png_uint_16;\n#elif USHRT_MAX == 65535\n   typedef unsigned short png_uint_16;\n#else\n#  error \"libpng requires an unsigned 16 bit type\"\n#endif\n\n#if INT_MIN < -2147483646 && INT_MAX > 2147483646\n   typedef int png_int_32;\n#elif LONG_MIN < -2147483646 && LONG_MAX > 2147483646\n   typedef long int png_int_32;\n#else\n#  error \"libpng requires a signed 32 bit (or more) type\"\n#endif\n\n#if UINT_MAX > 4294967294\n   typedef unsigned int png_uint_32;\n#elif ULONG_MAX > 4294967294\n   typedef unsigned long int png_uint_32;\n#else\n#  error \"libpng requires an unsigned 32 bit (or more) type\"\n#endif\n\n/* Prior to 1.6.0 it was possible to disable the use of size_t, 1.6.0, however,\n * requires an ISOC90 compiler and relies on consistent behavior of sizeof.\n */\ntypedef size_t png_size_t;\ntypedef ptrdiff_t png_ptrdiff_t;\n\n/* libpng needs to know the maximum value of 'size_t' and this controls the\n * definition of png_alloc_size_t, below.  This maximum value of size_t limits\n * but does not control the maximum allocations the library makes - there is\n * direct application control of this through png_set_user_limits().\n */\n#ifndef PNG_SMALL_SIZE_T\n   /* Compiler specific tests for systems where size_t is known to be less than\n    * 32 bits (some of these systems may no longer work because of the lack of\n    * 'far' support; see above.)\n    */\n#  if (defined(__TURBOC__) && !defined(__FLAT__)) ||\\\n   (defined(_MSC_VER) && defined(MAXSEG_64K))\n#     define PNG_SMALL_SIZE_T\n#  endif\n#endif\n\n/* png_alloc_size_t is guaranteed to be no smaller than png_size_t, and no\n * smaller than png_uint_32.  Casts from png_size_t or png_uint_32 to\n * png_alloc_size_t are not necessary; in fact, it is recommended not to use\n * them at all so that the compiler can complain when something turns out to be\n * problematic.\n *\n * Casts in the other direction (from png_alloc_size_t to png_size_t or\n * png_uint_32) should be explicitly applied; however, we do not expect to\n * encounter practical situations that require such conversions.\n *\n * PNG_SMALL_SIZE_T must be defined if the maximum value of size_t is less than\n * 4294967295 - i.e. less than the maximum value of png_uint_32.\n */\n#ifdef PNG_SMALL_SIZE_T\n   typedef png_uint_32 png_alloc_size_t;\n#else\n   typedef png_size_t png_alloc_size_t;\n#endif\n\n/* Prior to 1.6.0 libpng offered limited support for Microsoft C compiler\n * implementations of Intel CPU specific support of user-mode segmented address\n * spaces, where 16-bit pointers address more than 65536 bytes of memory using\n * separate 'segment' registers.  The implementation requires two different\n * types of pointer (only one of which includes the segment value.)\n *\n * If required this support is available in version 1.2 of libpng and may be\n * available in versions through 1.5, although the correctness of the code has\n * not been verified recently.\n */\n\n/* Typedef for floating-point numbers that are converted to fixed-point with a\n * multiple of 100,000, e.g., gamma\n */\ntypedef png_int_32 png_fixed_point;\n\n/* Add typedefs for pointers */\ntypedef void                  * png_voidp;\ntypedef const void            * png_const_voidp;\ntypedef png_byte              * png_bytep;\ntypedef const png_byte        * png_const_bytep;\ntypedef png_uint_32           * png_uint_32p;\ntypedef const png_uint_32     * png_const_uint_32p;\ntypedef png_int_32            * png_int_32p;\ntypedef const png_int_32      * png_const_int_32p;\ntypedef png_uint_16           * png_uint_16p;\ntypedef const png_uint_16     * png_const_uint_16p;\ntypedef png_int_16            * png_int_16p;\ntypedef const png_int_16      * png_const_int_16p;\ntypedef char                  * png_charp;\ntypedef const char            * png_const_charp;\ntypedef png_fixed_point       * png_fixed_point_p;\ntypedef const png_fixed_point * png_const_fixed_point_p;\ntypedef png_size_t            * png_size_tp;\ntypedef const png_size_t      * png_const_size_tp;\n\n#ifdef PNG_STDIO_SUPPORTED\ntypedef FILE            * png_FILE_p;\n#endif\n\n#ifdef PNG_FLOATING_POINT_SUPPORTED\ntypedef double       * png_doublep;\ntypedef const double * png_const_doublep;\n#endif\n\n/* Pointers to pointers; i.e. arrays */\ntypedef png_byte        * * png_bytepp;\ntypedef png_uint_32     * * png_uint_32pp;\ntypedef png_int_32      * * png_int_32pp;\ntypedef png_uint_16     * * png_uint_16pp;\ntypedef png_int_16      * * png_int_16pp;\ntypedef const char      * * png_const_charpp;\ntypedef char            * * png_charpp;\ntypedef png_fixed_point * * png_fixed_point_pp;\n#ifdef PNG_FLOATING_POINT_SUPPORTED\ntypedef double          * * png_doublepp;\n#endif\n\n/* Pointers to pointers to pointers; i.e., pointer to array */\ntypedef char            * * * png_charppp;\n\n#endif /* PNG_BUILDING_SYMBOL_TABLE */\n\n#endif /* PNGCONF_H */\n"
  },
  {
    "path": "Libraries/Core/Android/Headers/png/pngdebug.h",
    "content": "\n/* pngdebug.h - Debugging macros for libpng, also used in pngtest.c\n *\n * Copyright (c) 1998-2013 Glenn Randers-Pehrson\n * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)\n * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)\n *\n * Last changed in libpng 1.6.8 [December 19, 2013]\n *\n * This code is released under the libpng license.\n * For conditions of distribution and use, see the disclaimer\n * and license in png.h\n */\n\n/* Define PNG_DEBUG at compile time for debugging information.  Higher\n * numbers for PNG_DEBUG mean more debugging information.  This has\n * only been added since version 0.95 so it is not implemented throughout\n * libpng yet, but more support will be added as needed.\n *\n * png_debug[1-2]?(level, message ,arg{0-2})\n *   Expands to a statement (either a simple expression or a compound\n *   do..while(0) statement) that outputs a message with parameter\n *   substitution if PNG_DEBUG is defined to 2 or more.  If PNG_DEBUG\n *   is undefined, 0 or 1 every png_debug expands to a simple expression\n *   (actually ((void)0)).\n *\n *   level: level of detail of message, starting at 0.  A level 'n'\n *          message is preceded by 'n' 3-space indentations (not implemented\n *          on Microsoft compilers unless PNG_DEBUG_FILE is also\n *          defined, to allow debug DLL compilation with no standard IO).\n *   message: a printf(3) style text string.  A trailing '\\n' is added\n *            to the message.\n *   arg: 0 to 2 arguments for printf(3) style substitution in message.\n */\n#ifndef PNGDEBUG_H\n#define PNGDEBUG_H\n/* These settings control the formatting of messages in png.c and pngerror.c */\n/* Moved to pngdebug.h at 1.5.0 */\n#  ifndef PNG_LITERAL_SHARP\n#    define PNG_LITERAL_SHARP 0x23\n#  endif\n#  ifndef PNG_LITERAL_LEFT_SQUARE_BRACKET\n#    define PNG_LITERAL_LEFT_SQUARE_BRACKET 0x5b\n#  endif\n#  ifndef PNG_LITERAL_RIGHT_SQUARE_BRACKET\n#    define PNG_LITERAL_RIGHT_SQUARE_BRACKET 0x5d\n#  endif\n#  ifndef PNG_STRING_NEWLINE\n#    define PNG_STRING_NEWLINE \"\\n\"\n#  endif\n\n#ifdef PNG_DEBUG\n#  if (PNG_DEBUG > 0)\n#    if !defined(PNG_DEBUG_FILE) && defined(_MSC_VER)\n#      include <crtdbg.h>\n#      if (PNG_DEBUG > 1)\n#        ifndef _DEBUG\n#          define _DEBUG\n#        endif\n#        ifndef png_debug\n#          define png_debug(l,m)  _RPT0(_CRT_WARN,m PNG_STRING_NEWLINE)\n#        endif\n#        ifndef png_debug1\n#          define png_debug1(l,m,p1)  _RPT1(_CRT_WARN,m PNG_STRING_NEWLINE,p1)\n#        endif\n#        ifndef png_debug2\n#          define png_debug2(l,m,p1,p2) \\\n             _RPT2(_CRT_WARN,m PNG_STRING_NEWLINE,p1,p2)\n#        endif\n#      endif\n#    else /* PNG_DEBUG_FILE || !_MSC_VER */\n#      ifndef PNG_STDIO_SUPPORTED\n#        include <stdio.h> /* not included yet */\n#      endif\n#      ifndef PNG_DEBUG_FILE\n#        define PNG_DEBUG_FILE stderr\n#      endif /* PNG_DEBUG_FILE */\n\n#      if (PNG_DEBUG > 1)\n#        ifdef __STDC__\n#          ifndef png_debug\n#            define png_debug(l,m) \\\n       do { \\\n       int num_tabs=l; \\\n       fprintf(PNG_DEBUG_FILE,\"%s\" m PNG_STRING_NEWLINE,(num_tabs==1 ? \"   \" : \\\n         (num_tabs==2 ? \"      \" : (num_tabs>2 ? \"         \" : \"\")))); \\\n       } while (0)\n#          endif\n#          ifndef png_debug1\n#            define png_debug1(l,m,p1) \\\n       do { \\\n       int num_tabs=l; \\\n       fprintf(PNG_DEBUG_FILE,\"%s\" m PNG_STRING_NEWLINE,(num_tabs==1 ? \"   \" : \\\n         (num_tabs==2 ? \"      \" : (num_tabs>2 ? \"         \" : \"\"))),p1); \\\n       } while (0)\n#          endif\n#          ifndef png_debug2\n#            define png_debug2(l,m,p1,p2) \\\n       do { \\\n       int num_tabs=l; \\\n       fprintf(PNG_DEBUG_FILE,\"%s\" m PNG_STRING_NEWLINE,(num_tabs==1 ? \"   \" : \\\n         (num_tabs==2 ? \"      \" : (num_tabs>2 ? \"         \" : \"\"))),p1,p2);\\\n       } while (0)\n#          endif\n#        else /* __STDC __ */\n#          ifndef png_debug\n#            define png_debug(l,m) \\\n       do { \\\n       int num_tabs=l; \\\n       char format[256]; \\\n       snprintf(format,256,\"%s%s%s\",(num_tabs==1 ? \"\\t\" : \\\n         (num_tabs==2 ? \"\\t\\t\":(num_tabs>2 ? \"\\t\\t\\t\":\"\"))), \\\n         m,PNG_STRING_NEWLINE); \\\n       fprintf(PNG_DEBUG_FILE,format); \\\n       } while (0)\n#          endif\n#          ifndef png_debug1\n#            define png_debug1(l,m,p1) \\\n       do { \\\n       int num_tabs=l; \\\n       char format[256]; \\\n       snprintf(format,256,\"%s%s%s\",(num_tabs==1 ? \"\\t\" : \\\n         (num_tabs==2 ? \"\\t\\t\":(num_tabs>2 ? \"\\t\\t\\t\":\"\"))), \\\n         m,PNG_STRING_NEWLINE); \\\n       fprintf(PNG_DEBUG_FILE,format,p1); \\\n       } while (0)\n#          endif\n#          ifndef png_debug2\n#            define png_debug2(l,m,p1,p2) \\\n       do { \\\n       int num_tabs=l; \\\n       char format[256]; \\\n       snprintf(format,256,\"%s%s%s\",(num_tabs==1 ? \"\\t\" : \\\n         (num_tabs==2 ? \"\\t\\t\":(num_tabs>2 ? \"\\t\\t\\t\":\"\"))), \\\n         m,PNG_STRING_NEWLINE); \\\n       fprintf(PNG_DEBUG_FILE,format,p1,p2); \\\n       } while (0)\n#          endif\n#        endif /* __STDC __ */\n#      endif /* (PNG_DEBUG > 1) */\n\n#    endif /* _MSC_VER */\n#  endif /* (PNG_DEBUG > 0) */\n#endif /* PNG_DEBUG */\n#ifndef png_debug\n#  define png_debug(l, m) ((void)0)\n#endif\n#ifndef png_debug1\n#  define png_debug1(l, m, p1) ((void)0)\n#endif\n#ifndef png_debug2\n#  define png_debug2(l, m, p1, p2) ((void)0)\n#endif\n#endif /* PNGDEBUG_H */\n"
  },
  {
    "path": "Libraries/Core/Android/Headers/png/pnginfo.h",
    "content": "\n/* pnginfo.h - header file for PNG reference library\n *\n * Copyright (c) 1998-2013 Glenn Randers-Pehrson\n * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)\n * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)\n *\n * Last changed in libpng 1.6.1 [March 28, 2013]\n *\n * This code is released under the libpng license.\n * For conditions of distribution and use, see the disclaimer\n * and license in png.h\n */\n\n /* png_info is a structure that holds the information in a PNG file so\n * that the application can find out the characteristics of the image.\n * If you are reading the file, this structure will tell you what is\n * in the PNG file.  If you are writing the file, fill in the information\n * you want to put into the PNG file, using png_set_*() functions, then\n * call png_write_info().\n *\n * The names chosen should be very close to the PNG specification, so\n * consult that document for information about the meaning of each field.\n *\n * With libpng < 0.95, it was only possible to directly set and read the\n * the values in the png_info_struct, which meant that the contents and\n * order of the values had to remain fixed.  With libpng 0.95 and later,\n * however, there are now functions that abstract the contents of\n * png_info_struct from the application, so this makes it easier to use\n * libpng with dynamic libraries, and even makes it possible to use\n * libraries that don't have all of the libpng ancillary chunk-handing\n * functionality.  In libpng-1.5.0 this was moved into a separate private\n * file that is not visible to applications.\n *\n * The following members may have allocated storage attached that should be\n * cleaned up before the structure is discarded: palette, trans, text,\n * pcal_purpose, pcal_units, pcal_params, hist, iccp_name, iccp_profile,\n * splt_palettes, scal_unit, row_pointers, and unknowns.   By default, these\n * are automatically freed when the info structure is deallocated, if they were\n * allocated internally by libpng.  This behavior can be changed by means\n * of the png_data_freer() function.\n *\n * More allocation details: all the chunk-reading functions that\n * change these members go through the corresponding png_set_*\n * functions.  A function to clear these members is available: see\n * png_free_data().  The png_set_* functions do not depend on being\n * able to point info structure members to any of the storage they are\n * passed (they make their own copies), EXCEPT that the png_set_text\n * functions use the same storage passed to them in the text_ptr or\n * itxt_ptr structure argument, and the png_set_rows and png_set_unknowns\n * functions do not make their own copies.\n */\n#ifndef PNGINFO_H\n#define PNGINFO_H\n\nstruct png_info_def\n{\n   /* The following are necessary for every PNG file */\n   png_uint_32 width;  /* width of image in pixels (from IHDR) */\n   png_uint_32 height; /* height of image in pixels (from IHDR) */\n   png_uint_32 valid;  /* valid chunk data (see PNG_INFO_ below) */\n   png_size_t rowbytes; /* bytes needed to hold an untransformed row */\n   png_colorp palette;      /* array of color values (valid & PNG_INFO_PLTE) */\n   png_uint_16 num_palette; /* number of color entries in \"palette\" (PLTE) */\n   png_uint_16 num_trans;   /* number of transparent palette color (tRNS) */\n   png_byte bit_depth;      /* 1, 2, 4, 8, or 16 bits/channel (from IHDR) */\n   png_byte color_type;     /* see PNG_COLOR_TYPE_ below (from IHDR) */\n   /* The following three should have been named *_method not *_type */\n   png_byte compression_type; /* must be PNG_COMPRESSION_TYPE_BASE (IHDR) */\n   png_byte filter_type;    /* must be PNG_FILTER_TYPE_BASE (from IHDR) */\n   png_byte interlace_type; /* One of PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */\n\n   /* The following are set by png_set_IHDR, called from the application on\n    * write, but the are never actually used by the write code.\n    */\n   png_byte channels;       /* number of data channels per pixel (1, 2, 3, 4) */\n   png_byte pixel_depth;    /* number of bits per pixel */\n   png_byte spare_byte;     /* to align the data, and for future use */\n\n#ifdef PNG_READ_SUPPORTED\n   /* This is never set during write */\n   png_byte signature[8];   /* magic bytes read by libpng from start of file */\n#endif\n\n   /* The rest of the data is optional.  If you are reading, check the\n    * valid field to see if the information in these are valid.  If you\n    * are writing, set the valid field to those chunks you want written,\n    * and initialize the appropriate fields below.\n    */\n\n#if defined(PNG_COLORSPACE_SUPPORTED) || defined(PNG_GAMMA_SUPPORTED)\n   /* png_colorspace only contains 'flags' if neither GAMMA or COLORSPACE are\n    * defined.  When COLORSPACE is switched on all the colorspace-defining\n    * chunks should be enabled, when GAMMA is switched on all the gamma-defining\n    * chunks should be enabled.  If this is not done it becomes possible to read\n    * inconsistent PNG files and assign a probably incorrect interpretation to\n    * the information.  (In other words, by carefully choosing which chunks to\n    * recognize the system configuration can select an interpretation for PNG\n    * files containing ambiguous data and this will result in inconsistent\n    * behavior between different libpng builds!)\n    */\n   png_colorspace colorspace;\n#endif\n\n#ifdef PNG_iCCP_SUPPORTED\n   /* iCCP chunk data. */\n   png_charp iccp_name;     /* profile name */\n   png_bytep iccp_profile;  /* International Color Consortium profile data */\n   png_uint_32 iccp_proflen;  /* ICC profile data length */\n#endif\n\n#ifdef PNG_TEXT_SUPPORTED\n   /* The tEXt, and zTXt chunks contain human-readable textual data in\n    * uncompressed, compressed, and optionally compressed forms, respectively.\n    * The data in \"text\" is an array of pointers to uncompressed,\n    * null-terminated C strings. Each chunk has a keyword that describes the\n    * textual data contained in that chunk.  Keywords are not required to be\n    * unique, and the text string may be empty.  Any number of text chunks may\n    * be in an image.\n    */\n   int num_text; /* number of comments read or comments to write */\n   int max_text; /* current size of text array */\n   png_textp text; /* array of comments read or comments to write */\n#endif /* PNG_TEXT_SUPPORTED */\n\n#ifdef PNG_tIME_SUPPORTED\n   /* The tIME chunk holds the last time the displayed image data was\n    * modified.  See the png_time struct for the contents of this struct.\n    */\n   png_time mod_time;\n#endif\n\n#ifdef PNG_sBIT_SUPPORTED\n   /* The sBIT chunk specifies the number of significant high-order bits\n    * in the pixel data.  Values are in the range [1, bit_depth], and are\n    * only specified for the channels in the pixel data.  The contents of\n    * the low-order bits is not specified.  Data is valid if\n    * (valid & PNG_INFO_sBIT) is non-zero.\n    */\n   png_color_8 sig_bit; /* significant bits in color channels */\n#endif\n\n#if defined(PNG_tRNS_SUPPORTED) || defined(PNG_READ_EXPAND_SUPPORTED) || \\\ndefined(PNG_READ_BACKGROUND_SUPPORTED)\n   /* The tRNS chunk supplies transparency data for paletted images and\n    * other image types that don't need a full alpha channel.  There are\n    * \"num_trans\" transparency values for a paletted image, stored in the\n    * same order as the palette colors, starting from index 0.  Values\n    * for the data are in the range [0, 255], ranging from fully transparent\n    * to fully opaque, respectively.  For non-paletted images, there is a\n    * single color specified that should be treated as fully transparent.\n    * Data is valid if (valid & PNG_INFO_tRNS) is non-zero.\n    */\n   png_bytep trans_alpha;    /* alpha values for paletted image */\n   png_color_16 trans_color; /* transparent color for non-palette image */\n#endif\n\n#if defined(PNG_bKGD_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)\n   /* The bKGD chunk gives the suggested image background color if the\n    * display program does not have its own background color and the image\n    * is needs to composited onto a background before display.  The colors\n    * in \"background\" are normally in the same color space/depth as the\n    * pixel data.  Data is valid if (valid & PNG_INFO_bKGD) is non-zero.\n    */\n   png_color_16 background;\n#endif\n\n#ifdef PNG_oFFs_SUPPORTED\n   /* The oFFs chunk gives the offset in \"offset_unit_type\" units rightwards\n    * and downwards from the top-left corner of the display, page, or other\n    * application-specific co-ordinate space.  See the PNG_OFFSET_ defines\n    * below for the unit types.  Valid if (valid & PNG_INFO_oFFs) non-zero.\n    */\n   png_int_32 x_offset; /* x offset on page */\n   png_int_32 y_offset; /* y offset on page */\n   png_byte offset_unit_type; /* offset units type */\n#endif\n\n#ifdef PNG_pHYs_SUPPORTED\n   /* The pHYs chunk gives the physical pixel density of the image for\n    * display or printing in \"phys_unit_type\" units (see PNG_RESOLUTION_\n    * defines below).  Data is valid if (valid & PNG_INFO_pHYs) is non-zero.\n    */\n   png_uint_32 x_pixels_per_unit; /* horizontal pixel density */\n   png_uint_32 y_pixels_per_unit; /* vertical pixel density */\n   png_byte phys_unit_type; /* resolution type (see PNG_RESOLUTION_ below) */\n#endif\n\n#ifdef PNG_hIST_SUPPORTED\n   /* The hIST chunk contains the relative frequency or importance of the\n    * various palette entries, so that a viewer can intelligently select a\n    * reduced-color palette, if required.  Data is an array of \"num_palette\"\n    * values in the range [0,65535]. Data valid if (valid & PNG_INFO_hIST)\n    * is non-zero.\n    */\n   png_uint_16p hist;\n#endif\n\n#ifdef PNG_pCAL_SUPPORTED\n   /* The pCAL chunk describes a transformation between the stored pixel\n    * values and original physical data values used to create the image.\n    * The integer range [0, 2^bit_depth - 1] maps to the floating-point\n    * range given by [pcal_X0, pcal_X1], and are further transformed by a\n    * (possibly non-linear) transformation function given by \"pcal_type\"\n    * and \"pcal_params\" into \"pcal_units\".  Please see the PNG_EQUATION_\n    * defines below, and the PNG-Group's PNG extensions document for a\n    * complete description of the transformations and how they should be\n    * implemented, and for a description of the ASCII parameter strings.\n    * Data values are valid if (valid & PNG_INFO_pCAL) non-zero.\n    */\n   png_charp pcal_purpose;  /* pCAL chunk description string */\n   png_int_32 pcal_X0;      /* minimum value */\n   png_int_32 pcal_X1;      /* maximum value */\n   png_charp pcal_units;    /* Latin-1 string giving physical units */\n   png_charpp pcal_params;  /* ASCII strings containing parameter values */\n   png_byte pcal_type;      /* equation type (see PNG_EQUATION_ below) */\n   png_byte pcal_nparams;   /* number of parameters given in pcal_params */\n#endif\n\n/* New members added in libpng-1.0.6 */\n   png_uint_32 free_me;     /* flags items libpng is responsible for freeing */\n\n#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED\n   /* Storage for unknown chunks that the library doesn't recognize. */\n   png_unknown_chunkp unknown_chunks;\n\n   /* The type of this field is limited by the type of \n    * png_struct::user_chunk_cache_max, else overflow can occur.\n    */\n   int                unknown_chunks_num;\n#endif\n\n#ifdef PNG_sPLT_SUPPORTED\n   /* Data on sPLT chunks (there may be more than one). */\n   png_sPLT_tp splt_palettes;\n   int         splt_palettes_num; /* Match type returned by png_get API */\n#endif\n\n#ifdef PNG_sCAL_SUPPORTED\n   /* The sCAL chunk describes the actual physical dimensions of the\n    * subject matter of the graphic.  The chunk contains a unit specification\n    * a byte value, and two ASCII strings representing floating-point\n    * values.  The values are width and height corresponsing to one pixel\n    * in the image.  Data values are valid if (valid & PNG_INFO_sCAL) is\n    * non-zero.\n    */\n   png_byte scal_unit;         /* unit of physical scale */\n   png_charp scal_s_width;     /* string containing height */\n   png_charp scal_s_height;    /* string containing width */\n#endif\n\n#ifdef PNG_INFO_IMAGE_SUPPORTED\n   /* Memory has been allocated if (valid & PNG_ALLOCATED_INFO_ROWS)\n      non-zero */\n   /* Data valid if (valid & PNG_INFO_IDAT) non-zero */\n   png_bytepp row_pointers;        /* the image bits */\n#endif\n\n};\n#endif /* PNGINFO_H */\n"
  },
  {
    "path": "Libraries/Core/Android/Headers/png/pnglibconf.h",
    "content": "/* libpng 1.6.10 STANDARD API DEFINITION */\n\n/* pnglibconf.h - library build configuration */\n\n/* Libpng version 1.6.10 - March 6, 2014 */\n\n/* Copyright (c) 1998-2013 Glenn Randers-Pehrson */\n\n/* This code is released under the libpng license. */\n/* For conditions of distribution and use, see the disclaimer */\n/* and license in png.h */\n\n/* pnglibconf.h */\n/* Machine generated file: DO NOT EDIT */\n/* Derived from: scripts/pnglibconf.dfa */\n#ifndef PNGLCONF_H\n#define PNGLCONF_H\n/* options */\n#define PNG_16BIT_SUPPORTED\n#define PNG_ALIGNED_MEMORY_SUPPORTED\n/*#undef PNG_ARM_NEON_API_SUPPORTED*/\n/*#undef PNG_ARM_NEON_CHECK_SUPPORTED*/\n#define PNG_BENIGN_ERRORS_SUPPORTED\n#define PNG_BENIGN_READ_ERRORS_SUPPORTED\n/*#undef PNG_BENIGN_WRITE_ERRORS_SUPPORTED*/\n#define PNG_BUILD_GRAYSCALE_PALETTE_SUPPORTED\n#define PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED\n#define PNG_COLORSPACE_SUPPORTED\n#define PNG_CONSOLE_IO_SUPPORTED\n#define PNG_CONVERT_tIME_SUPPORTED\n#define PNG_EASY_ACCESS_SUPPORTED\n/*#undef PNG_ERROR_NUMBERS_SUPPORTED*/\n#define PNG_ERROR_TEXT_SUPPORTED\n#define PNG_FIXED_POINT_SUPPORTED\n#define PNG_FLOATING_ARITHMETIC_SUPPORTED\n#define PNG_FLOATING_POINT_SUPPORTED\n#define PNG_FORMAT_AFIRST_SUPPORTED\n#define PNG_FORMAT_BGR_SUPPORTED\n#define PNG_GAMMA_SUPPORTED\n#define PNG_GET_PALETTE_MAX_SUPPORTED\n#define PNG_HANDLE_AS_UNKNOWN_SUPPORTED\n#define PNG_INCH_CONVERSIONS_SUPPORTED\n#define PNG_INFO_IMAGE_SUPPORTED\n#define PNG_IO_STATE_SUPPORTED\n#define PNG_MNG_FEATURES_SUPPORTED\n#define PNG_POINTER_INDEXING_SUPPORTED\n#define PNG_PROGRESSIVE_READ_SUPPORTED\n#define PNG_READ_16BIT_SUPPORTED\n#define PNG_READ_ALPHA_MODE_SUPPORTED\n#define PNG_READ_ANCILLARY_CHUNKS_SUPPORTED\n#define PNG_READ_BACKGROUND_SUPPORTED\n#define PNG_READ_BGR_SUPPORTED\n#define PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED\n#define PNG_READ_COMPOSITE_NODIV_SUPPORTED\n#define PNG_READ_COMPRESSED_TEXT_SUPPORTED\n#define PNG_READ_EXPAND_16_SUPPORTED\n#define PNG_READ_EXPAND_SUPPORTED\n#define PNG_READ_FILLER_SUPPORTED\n#define PNG_READ_GAMMA_SUPPORTED\n#define PNG_READ_GET_PALETTE_MAX_SUPPORTED\n#define PNG_READ_GRAY_TO_RGB_SUPPORTED\n#define PNG_READ_INTERLACING_SUPPORTED\n#define PNG_READ_INT_FUNCTIONS_SUPPORTED\n#define PNG_READ_INVERT_ALPHA_SUPPORTED\n#define PNG_READ_INVERT_SUPPORTED\n#define PNG_READ_OPT_PLTE_SUPPORTED\n#define PNG_READ_PACKSWAP_SUPPORTED\n#define PNG_READ_PACK_SUPPORTED\n#define PNG_READ_QUANTIZE_SUPPORTED\n#define PNG_READ_RGB_TO_GRAY_SUPPORTED\n#define PNG_READ_SCALE_16_TO_8_SUPPORTED\n#define PNG_READ_SHIFT_SUPPORTED\n#define PNG_READ_STRIP_16_TO_8_SUPPORTED\n#define PNG_READ_STRIP_ALPHA_SUPPORTED\n#define PNG_READ_SUPPORTED\n#define PNG_READ_SWAP_ALPHA_SUPPORTED\n#define PNG_READ_SWAP_SUPPORTED\n#define PNG_READ_TEXT_SUPPORTED\n#define PNG_READ_TRANSFORMS_SUPPORTED\n#define PNG_READ_UNKNOWN_CHUNKS_SUPPORTED\n#define PNG_READ_USER_CHUNKS_SUPPORTED\n#define PNG_READ_USER_TRANSFORM_SUPPORTED\n#define PNG_READ_bKGD_SUPPORTED\n#define PNG_READ_cHRM_SUPPORTED\n#define PNG_READ_gAMA_SUPPORTED\n#define PNG_READ_hIST_SUPPORTED\n#define PNG_READ_iCCP_SUPPORTED\n#define PNG_READ_iTXt_SUPPORTED\n#define PNG_READ_oFFs_SUPPORTED\n#define PNG_READ_pCAL_SUPPORTED\n#define PNG_READ_pHYs_SUPPORTED\n#define PNG_READ_sBIT_SUPPORTED\n#define PNG_READ_sCAL_SUPPORTED\n#define PNG_READ_sPLT_SUPPORTED\n#define PNG_READ_sRGB_SUPPORTED\n#define PNG_READ_tEXt_SUPPORTED\n#define PNG_READ_tIME_SUPPORTED\n#define PNG_READ_tRNS_SUPPORTED\n#define PNG_READ_zTXt_SUPPORTED\n/*#undef PNG_SAFE_LIMITS_SUPPORTED*/\n#define PNG_SAVE_INT_32_SUPPORTED\n#define PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED\n#define PNG_SEQUENTIAL_READ_SUPPORTED\n#define PNG_SETJMP_SUPPORTED\n#define PNG_SET_CHUNK_CACHE_LIMIT_SUPPORTED\n#define PNG_SET_CHUNK_MALLOC_LIMIT_SUPPORTED\n#define PNG_SET_OPTION_SUPPORTED\n#define PNG_SET_UNKNOWN_CHUNKS_SUPPORTED\n#define PNG_SET_USER_LIMITS_SUPPORTED\n#define PNG_SIMPLIFIED_READ_AFIRST_SUPPORTED\n#define PNG_SIMPLIFIED_READ_BGR_SUPPORTED\n#define PNG_SIMPLIFIED_READ_SUPPORTED\n#define PNG_SIMPLIFIED_WRITE_AFIRST_SUPPORTED\n#define PNG_SIMPLIFIED_WRITE_BGR_SUPPORTED\n#define PNG_SIMPLIFIED_WRITE_SUPPORTED\n#define PNG_STDIO_SUPPORTED\n#define PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED\n#define PNG_TEXT_SUPPORTED\n#define PNG_TIME_RFC1123_SUPPORTED\n#define PNG_UNKNOWN_CHUNKS_SUPPORTED\n#define PNG_USER_CHUNKS_SUPPORTED\n#define PNG_USER_LIMITS_SUPPORTED\n#define PNG_USER_MEM_SUPPORTED\n#define PNG_USER_TRANSFORM_INFO_SUPPORTED\n#define PNG_USER_TRANSFORM_PTR_SUPPORTED\n#define PNG_WARNINGS_SUPPORTED\n#define PNG_WRITE_16BIT_SUPPORTED\n#define PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED\n#define PNG_WRITE_BGR_SUPPORTED\n#define PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED\n#define PNG_WRITE_COMPRESSED_TEXT_SUPPORTED\n#define PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED\n#define PNG_WRITE_FILLER_SUPPORTED\n#define PNG_WRITE_FILTER_SUPPORTED\n#define PNG_WRITE_FLUSH_SUPPORTED\n#define PNG_WRITE_GET_PALETTE_MAX_SUPPORTED\n#define PNG_WRITE_INTERLACING_SUPPORTED\n#define PNG_WRITE_INT_FUNCTIONS_SUPPORTED\n#define PNG_WRITE_INVERT_ALPHA_SUPPORTED\n#define PNG_WRITE_INVERT_SUPPORTED\n#define PNG_WRITE_OPTIMIZE_CMF_SUPPORTED\n#define PNG_WRITE_PACKSWAP_SUPPORTED\n#define PNG_WRITE_PACK_SUPPORTED\n#define PNG_WRITE_SHIFT_SUPPORTED\n#define PNG_WRITE_SUPPORTED\n#define PNG_WRITE_SWAP_ALPHA_SUPPORTED\n#define PNG_WRITE_SWAP_SUPPORTED\n#define PNG_WRITE_TEXT_SUPPORTED\n#define PNG_WRITE_TRANSFORMS_SUPPORTED\n#define PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED\n#define PNG_WRITE_USER_TRANSFORM_SUPPORTED\n#define PNG_WRITE_WEIGHTED_FILTER_SUPPORTED\n#define PNG_WRITE_bKGD_SUPPORTED\n#define PNG_WRITE_cHRM_SUPPORTED\n#define PNG_WRITE_gAMA_SUPPORTED\n#define PNG_WRITE_hIST_SUPPORTED\n#define PNG_WRITE_iCCP_SUPPORTED\n#define PNG_WRITE_iTXt_SUPPORTED\n#define PNG_WRITE_oFFs_SUPPORTED\n#define PNG_WRITE_pCAL_SUPPORTED\n#define PNG_WRITE_pHYs_SUPPORTED\n#define PNG_WRITE_sBIT_SUPPORTED\n#define PNG_WRITE_sCAL_SUPPORTED\n#define PNG_WRITE_sPLT_SUPPORTED\n#define PNG_WRITE_sRGB_SUPPORTED\n#define PNG_WRITE_tEXt_SUPPORTED\n#define PNG_WRITE_tIME_SUPPORTED\n#define PNG_WRITE_tRNS_SUPPORTED\n#define PNG_WRITE_zTXt_SUPPORTED\n#define PNG_bKGD_SUPPORTED\n#define PNG_cHRM_SUPPORTED\n#define PNG_gAMA_SUPPORTED\n#define PNG_hIST_SUPPORTED\n#define PNG_iCCP_SUPPORTED\n#define PNG_iTXt_SUPPORTED\n#define PNG_oFFs_SUPPORTED\n#define PNG_pCAL_SUPPORTED\n#define PNG_pHYs_SUPPORTED\n#define PNG_sBIT_SUPPORTED\n#define PNG_sCAL_SUPPORTED\n#define PNG_sPLT_SUPPORTED\n#define PNG_sRGB_SUPPORTED\n#define PNG_tEXt_SUPPORTED\n#define PNG_tIME_SUPPORTED\n#define PNG_tRNS_SUPPORTED\n#define PNG_zTXt_SUPPORTED\n/* end of options */\n/* settings */\n#define PNG_API_RULE 0\n#define PNG_CALLOC_SUPPORTED\n#define PNG_COST_SHIFT 3\n#define PNG_DEFAULT_READ_MACROS 1\n#define PNG_GAMMA_THRESHOLD_FIXED 5000\n#define PNG_IDAT_READ_SIZE PNG_ZBUF_SIZE\n#define PNG_INFLATE_BUF_SIZE 1024\n#define PNG_MAX_GAMMA_8 11\n#define PNG_QUANTIZE_BLUE_BITS 5\n#define PNG_QUANTIZE_GREEN_BITS 5\n#define PNG_QUANTIZE_RED_BITS 5\n#define PNG_TEXT_Z_DEFAULT_COMPRESSION (-1)\n#define PNG_TEXT_Z_DEFAULT_STRATEGY 0\n#define PNG_WEIGHT_SHIFT 8\n#define PNG_ZBUF_SIZE 8192\n#define PNG_ZLIB_VERNUM 0 /* unknown */\n#define PNG_Z_DEFAULT_COMPRESSION (-1)\n#define PNG_Z_DEFAULT_NOFILTER_STRATEGY 0\n#define PNG_Z_DEFAULT_STRATEGY 1\n#define PNG_sCAL_PRECISION 5\n#define PNG_sRGB_PROFILE_CHECKS 2\n/* end of settings */\n#endif /* PNGLCONF_H */\n"
  },
  {
    "path": "Libraries/Core/Android/Headers/png/pngpriv.h",
    "content": "\n/* pngpriv.h - private declarations for use inside libpng\n *\n * For conditions of distribution and use, see copyright notice in png.h\n * Copyright (c) 1998-2014 Glenn Randers-Pehrson\n * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)\n * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)\n *\n * Last changed in libpng 1.6.10 [March 6, 2014]\n *\n * This code is released under the libpng license.\n * For conditions of distribution and use, see the disclaimer\n * and license in png.h\n */\n\n/* The symbols declared in this file (including the functions declared\n * as extern) are PRIVATE.  They are not part of the libpng public\n * interface, and are not recommended for use by regular applications.\n * Some of them may become public in the future; others may stay private,\n * change in an incompatible way, or even disappear.\n * Although the libpng users are not forbidden to include this header,\n * they should be well aware of the issues that may arise from doing so.\n */\n\n#ifndef PNGPRIV_H\n#define PNGPRIV_H\n\n/* Feature Test Macros.  The following are defined here to ensure that correctly\n * implemented libraries reveal the APIs libpng needs to build and hide those\n * that are not needed and potentially damaging to the compilation.\n *\n * Feature Test Macros must be defined before any system header is included (see\n * POSIX 1003.1 2.8.2 \"POSIX Symbols.\"\n *\n * These macros only have an effect if the operating system supports either\n * POSIX 1003.1 or C99, or both.  On other operating systems (particularly\n * Windows/Visual Studio) there is no effect; the OS specific tests below are\n * still required (as of 2011-05-02.)\n */\n#define _POSIX_SOURCE 1 /* Just the POSIX 1003.1 and C89 APIs */\n\n#ifndef PNG_VERSION_INFO_ONLY\n/* Standard library headers not required by png.h: */\n#  include <stdlib.h>\n#  include <string.h>\n#endif\n\n#define PNGLIB_BUILD /*libpng is being built, not used*/\n\n/* If HAVE_CONFIG_H is defined during the build then the build system must\n * provide an appropriate \"config.h\" file on the include path.  The header file\n * must provide definitions as required below (search for \"HAVE_CONFIG_H\");\n * see configure.ac for more details of the requirements.  The macro\n * \"PNG_NO_CONFIG_H\" is provided for maintainers to test for dependencies on\n * 'configure'; define this macro to prevent the configure build including the\n * configure generated config.h.  Libpng is expected to compile without *any*\n * special build system support on a reasonably ANSI-C compliant system.\n */\n#if defined(HAVE_CONFIG_H) && !defined(PNG_NO_CONFIG_H)\n#  include <config.h>\n\n   /* Pick up the definition of 'restrict' from config.h if it was read: */\n#  define PNG_RESTRICT restrict\n#endif\n\n/* To support symbol prefixing it is necessary to know *before* including png.h\n * whether the fixed point (and maybe other) APIs are exported, because if they\n * are not internal definitions may be required.  This is handled below just\n * before png.h is included, but load the configuration now if it is available.\n */\n#ifndef PNGLCONF_H\n#  include \"pnglibconf.h\"\n#endif\n\n/* Local renames may change non-exported API functions from png.h */\n#if defined(PNG_PREFIX) && !defined(PNGPREFIX_H)\n#  include \"pngprefix.h\"\n#endif\n\n#ifdef PNG_USER_CONFIG\n#  include \"pngusr.h\"\n   /* These should have been defined in pngusr.h */\n#  ifndef PNG_USER_PRIVATEBUILD\n#    define PNG_USER_PRIVATEBUILD \"Custom libpng build\"\n#  endif\n#  ifndef PNG_USER_DLLFNAME_POSTFIX\n#    define PNG_USER_DLLFNAME_POSTFIX \"Cb\"\n#  endif\n#endif\n\n/* Compile time options.\n * =====================\n * In a multi-arch build the compiler may compile the code several times for the\n * same object module, producing different binaries for different architectures.\n * When this happens configure-time setting of the target host options cannot be\n * done and this interferes with the handling of the ARM NEON optimizations, and\n * possibly other similar optimizations.  Put additional tests here; in general\n * this is needed when the same option can be changed at both compile time and\n * run time depending on the target OS (i.e. iOS vs Android.)\n *\n * NOTE: symbol prefixing does not pass $(CFLAGS) to the preprocessor, because\n * this is not possible with certain compilers (Oracle SUN OS CC), as a result\n * it is necessary to ensure that all extern functions that *might* be used\n * regardless of $(CFLAGS) get declared in this file.  The test on __ARM_NEON__\n * below is one example of this behavior because it is controlled by the\n * presence or not of -mfpu=neon on the GCC command line, it is possible to do\n * this in $(CC), e.g. \"CC=gcc -mfpu=neon\", but people who build libpng rarely\n * do this.\n */\n#ifndef PNG_ARM_NEON_OPT\n   /* ARM NEON optimizations are being controlled by the compiler settings,\n    * typically the target FPU.  If the FPU has been set to NEON (-mfpu=neon\n    * with GCC) then the compiler will define __ARM_NEON__ and we can rely\n    * unconditionally on NEON instructions not crashing, otherwise we must\n    * disable use of NEON instructions.\n    *\n    * NOTE: at present these optimizations depend on 'ALIGNED_MEMORY', so they\n    * can only be turned on automatically if that is supported too.  If\n    * PNG_ARM_NEON_OPT is set in CPPFLAGS (to >0) then arm/arm_init.c will fail\n    * to compile with an appropriate #error if ALIGNED_MEMORY has been turned\n    * off.\n    */\n#  if defined(__ARM_NEON__) && defined(PNG_ALIGNED_MEMORY_SUPPORTED)\n#     define PNG_ARM_NEON_OPT 2\n#  else\n#     define PNG_ARM_NEON_OPT 0\n#  endif\n#endif\n\n#if PNG_ARM_NEON_OPT > 0\n   /* NEON optimizations are to be at least considered by libpng, so enable the\n    * callbacks to do this.\n    */\n#  define PNG_FILTER_OPTIMIZATIONS png_init_filter_functions_neon\n\n   /* By default the 'intrinsics' code in arm/filter_neon_intrinsics.c is used\n    * if possible - if __ARM_NEON__ is set and the compiler version is not known\n    * to be broken.  This is controlled by PNG_ARM_NEON_IMPLEMENTATION which can\n    * be:\n    *\n    *    1  The intrinsics code (the default with __ARM_NEON__)\n    *    2  The hand coded assembler (the default without __ARM_NEON__)\n    *\n    * It is possible to set PNG_ARM_NEON_IMPLEMENTATION in CPPFLAGS, however\n    * this is *NOT* supported and may cease to work even after a minor revision\n    * to libpng.  It *is* valid to do this for testing purposes, e.g. speed\n    * testing or a new compiler, but the results should be communicated to the\n    * libpng implementation list for incorporation in the next minor release.\n    */\n#  ifndef PNG_ARM_NEON_IMPLEMENTATION\n#     ifdef __ARM_NEON__\n#        if defined(__clang__)\n            /* At present it is unknown by the libpng developers which versions\n             * of clang support the intrinsics, however some or perhaps all\n             * versions do not work with the assembler so this may be\n             * irrelevant, so just use the default (do nothing here.)\n             */\n#        elif defined(__GNUC__)\n            /* GCC 4.5.4 NEON support is known to be broken.  4.6.3 is known to\n             * work, so if this *is* GCC, or G++, look for a version >4.5\n             */\n#           if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 6)\n#              define PNG_ARM_NEON_IMPLEMENTATION 2\n#           endif /* no GNUC support */\n#        endif /* __GNUC__ */\n#     else /* !defined __ARM_NEON__ */\n         /* The 'intrinsics' code simply won't compile without this -mfpu=neon:\n          */\n#        define PNG_ARM_NEON_IMPLEMENTATION 2\n#     endif /* __ARM_NEON__ */\n#  endif /* !defined PNG_ARM_NEON_IMPLEMENTATION */\n\n#  ifndef PNG_ARM_NEON_IMPLEMENTATION\n      /* Use the intrinsics code by default. */\n#     define PNG_ARM_NEON_IMPLEMENTATION 1\n#  endif\n#endif /* PNG_ARM_NEON_OPT > 0 */\n\n/* Is this a build of a DLL where compilation of the object modules requires\n * different preprocessor settings to those required for a simple library?  If\n * so PNG_BUILD_DLL must be set.\n *\n * If libpng is used inside a DLL but that DLL does not export the libpng APIs\n * PNG_BUILD_DLL must not be set.  To avoid the code below kicking in build a\n * static library of libpng then link the DLL against that.\n */\n#ifndef PNG_BUILD_DLL\n#  ifdef DLL_EXPORT\n      /* This is set by libtool when files are compiled for a DLL; libtool\n       * always compiles twice, even on systems where it isn't necessary.  Set\n       * PNG_BUILD_DLL in case it is necessary:\n       */\n#     define PNG_BUILD_DLL\n#  else\n#     ifdef _WINDLL\n         /* This is set by the Microsoft Visual Studio IDE in projects that\n          * build a DLL.  It can't easily be removed from those projects (it\n          * isn't visible in the Visual Studio UI) so it is a fairly reliable\n          * indication that PNG_IMPEXP needs to be set to the DLL export\n          * attributes.\n          */\n#        define PNG_BUILD_DLL\n#     else\n#        ifdef __DLL__\n            /* This is set by the Borland C system when compiling for a DLL\n             * (as above.)\n             */\n#           define PNG_BUILD_DLL\n#        else\n            /* Add additional compiler cases here. */\n#        endif\n#     endif\n#  endif\n#endif /* Setting PNG_BUILD_DLL if required */\n\n/* See pngconf.h for more details: the builder of the library may set this on\n * the command line to the right thing for the specific compilation system or it\n * may be automagically set above (at present we know of no system where it does\n * need to be set on the command line.)\n *\n * PNG_IMPEXP must be set here when building the library to prevent pngconf.h\n * setting it to the \"import\" setting for a DLL build.\n */\n#ifndef PNG_IMPEXP\n#  ifdef PNG_BUILD_DLL\n#     define PNG_IMPEXP PNG_DLL_EXPORT\n#  else\n      /* Not building a DLL, or the DLL doesn't require specific export\n       * definitions.\n       */\n#     define PNG_IMPEXP\n#  endif\n#endif\n\n/* No warnings for private or deprecated functions in the build: */\n#ifndef PNG_DEPRECATED\n#  define PNG_DEPRECATED\n#endif\n#ifndef PNG_PRIVATE\n#  define PNG_PRIVATE\n#endif\n\n/* Symbol preprocessing support.\n *\n * To enable listing global, but internal, symbols the following macros should\n * always be used to declare an extern data or function object in this file.\n */\n#ifndef PNG_INTERNAL_DATA\n#  define PNG_INTERNAL_DATA(type, name, array) extern type name array\n#endif\n\n#ifndef PNG_INTERNAL_FUNCTION\n#  define PNG_INTERNAL_FUNCTION(type, name, args, attributes)\\\n      extern PNG_FUNCTION(type, name, args, PNG_EMPTY attributes)\n#endif\n\n#ifndef PNG_INTERNAL_CALLBACK\n#  define PNG_INTERNAL_CALLBACK(type, name, args, attributes)\\\n      extern PNG_FUNCTION(type, (PNGCBAPI name), args, PNG_EMPTY attributes)\n#endif\n\n/* If floating or fixed point APIs are disabled they may still be compiled\n * internally.  To handle this make sure they are declared as the appropriate\n * internal extern function (otherwise the symbol prefixing stuff won't work and\n * the functions will be used without definitions.)\n *\n * NOTE: although all the API functions are declared here they are not all\n * actually built!  Because the declarations are still made it is necessary to\n * fake out types that they depend on.\n */\n#ifndef PNG_FP_EXPORT\n#  ifndef PNG_FLOATING_POINT_SUPPORTED\n#     define PNG_FP_EXPORT(ordinal, type, name, args)\\\n         PNG_INTERNAL_FUNCTION(type, name, args, PNG_EMPTY);\n#     ifndef PNG_VERSION_INFO_ONLY\n         typedef struct png_incomplete png_double;\n         typedef png_double*           png_doublep;\n         typedef const png_double*     png_const_doublep;\n         typedef png_double**          png_doublepp;\n#     endif\n#  endif\n#endif\n#ifndef PNG_FIXED_EXPORT\n#  ifndef PNG_FIXED_POINT_SUPPORTED\n#     define PNG_FIXED_EXPORT(ordinal, type, name, args)\\\n         PNG_INTERNAL_FUNCTION(type, name, args, PNG_EMPTY);\n#  endif\n#endif\n\n#include \"png.h\"\n\n/* pngconf.h does not set PNG_DLL_EXPORT unless it is required, so: */\n#ifndef PNG_DLL_EXPORT\n#  define PNG_DLL_EXPORT\n#endif\n\n/* SECURITY and SAFETY:\n *\n * By default libpng is built without any internal limits on image size,\n * individual heap (png_malloc) allocations or the total amount of memory used.\n * If PNG_SAFE_LIMITS_SUPPORTED is defined, however, the limits below are used\n * (unless individually overridden).  These limits are believed to be fairly\n * safe, but builders of secure systems should verify the values against the\n * real system capabilities.\n */\n#ifdef PNG_SAFE_LIMITS_SUPPORTED\n   /* 'safe' limits */\n#  ifndef PNG_USER_WIDTH_MAX\n#     define PNG_USER_WIDTH_MAX 1000000\n#  endif\n#  ifndef PNG_USER_HEIGHT_MAX\n#     define PNG_USER_HEIGHT_MAX 1000000\n#  endif\n#  ifndef PNG_USER_CHUNK_CACHE_MAX\n#     define PNG_USER_CHUNK_CACHE_MAX 128\n#  endif\n#  ifndef PNG_USER_CHUNK_MALLOC_MAX\n#     define PNG_USER_CHUNK_MALLOC_MAX 8000000\n#  endif\n#else\n   /* values for no limits */\n#  ifndef PNG_USER_WIDTH_MAX\n#     define PNG_USER_WIDTH_MAX 0x7fffffff\n#  endif\n#  ifndef PNG_USER_HEIGHT_MAX\n#     define PNG_USER_HEIGHT_MAX 0x7fffffff\n#  endif\n#  ifndef PNG_USER_CHUNK_CACHE_MAX\n#     define PNG_USER_CHUNK_CACHE_MAX 0\n#  endif\n#  ifndef PNG_USER_CHUNK_MALLOC_MAX\n#     define PNG_USER_CHUNK_MALLOC_MAX 0\n#  endif\n#endif\n\n/* Moved to pngpriv.h at libpng-1.5.0 */\n/* NOTE: some of these may have been used in external applications as\n * these definitions were exposed in pngconf.h prior to 1.5.\n */\n\n/* If you are running on a machine where you cannot allocate more\n * than 64K of memory at once, uncomment this.  While libpng will not\n * normally need that much memory in a chunk (unless you load up a very\n * large file), zlib needs to know how big of a chunk it can use, and\n * libpng thus makes sure to check any memory allocation to verify it\n * will fit into memory.\n *\n * zlib provides 'MAXSEG_64K' which, if defined, indicates the\n * same limit and pngconf.h (already included) sets the limit\n * if certain operating systems are detected.\n */\n#if defined(MAXSEG_64K) && !defined(PNG_MAX_MALLOC_64K)\n#  define PNG_MAX_MALLOC_64K\n#endif\n\n#ifndef PNG_UNUSED\n/* Unused formal parameter warnings are silenced using the following macro\n * which is expected to have no bad effects on performance (optimizing\n * compilers will probably remove it entirely).  Note that if you replace\n * it with something other than whitespace, you must include the terminating\n * semicolon.\n */\n#  define PNG_UNUSED(param) (void)param;\n#endif\n\n/* Just a little check that someone hasn't tried to define something\n * contradictory.\n */\n#if (PNG_ZBUF_SIZE > 65536L) && defined(PNG_MAX_MALLOC_64K)\n#  undef PNG_ZBUF_SIZE\n#  define PNG_ZBUF_SIZE 65536L\n#endif\n\n/* If warnings or errors are turned off the code is disabled or redirected here.\n * From 1.5.4 functions have been added to allow very limited formatting of\n * error and warning messages - this code will also be disabled here.\n */\n#ifdef PNG_WARNINGS_SUPPORTED\n#  define PNG_WARNING_PARAMETERS(p) png_warning_parameters p;\n#else\n#  define png_warning_parameter(p,number,string) ((void)0)\n#  define png_warning_parameter_unsigned(p,number,format,value) ((void)0)\n#  define png_warning_parameter_signed(p,number,format,value) ((void)0)\n#  define png_formatted_warning(pp,p,message) ((void)(pp))\n#  define PNG_WARNING_PARAMETERS(p)\n#endif\n#ifndef PNG_ERROR_TEXT_SUPPORTED\n#  define png_fixed_error(s1,s2) png_err(s1)\n#endif\n\n/* C allows up-casts from (void*) to any pointer and (const void*) to any\n * pointer to a const object.  C++ regards this as a type error and requires an\n * explicit, static, cast and provides the static_cast<> rune to ensure that\n * const is not cast away.\n */\n#ifdef __cplusplus\n#  define png_voidcast(type, value) static_cast<type>(value)\n#  define png_constcast(type, value) const_cast<type>(value)\n#  define png_aligncast(type, value) \\\n   static_cast<type>(static_cast<void*>(value))\n#  define png_aligncastconst(type, value) \\\n   static_cast<type>(static_cast<const void*>(value))\n#else\n#  define png_voidcast(type, value) (value)\n#  define png_constcast(type, value) ((type)(value))\n#  define png_aligncast(type, value) ((void*)(value))\n#  define png_aligncastconst(type, value) ((const void*)(value))\n#endif /* __cplusplus */\n\n/* Some fixed point APIs are still required even if not exported because\n * they get used by the corresponding floating point APIs.  This magic\n * deals with this:\n */\n#ifdef PNG_FIXED_POINT_SUPPORTED\n#  define PNGFAPI PNGAPI\n#else\n#  define PNGFAPI /* PRIVATE */\n#endif\n\n#ifndef PNG_VERSION_INFO_ONLY\n/* Other defines specific to compilers can go here.  Try to keep\n * them inside an appropriate ifdef/endif pair for portability.\n */\n#if defined(PNG_FLOATING_POINT_SUPPORTED) ||\\\n    defined(PNG_FLOATING_ARITHMETIC_SUPPORTED)\n   /* png.c requires the following ANSI-C constants if the conversion of\n    * floating point to ASCII is implemented therein:\n    *\n    *  DBL_DIG  Maximum number of decimal digits (can be set to any constant)\n    *  DBL_MIN  Smallest normalized fp number (can be set to an arbitrary value)\n    *  DBL_MAX  Maximum floating point number (can be set to an arbitrary value)\n    */\n#  include <float.h>\n\n#  if (defined(__MWERKS__) && defined(macintosh)) || defined(applec) || \\\n    defined(THINK_C) || defined(__SC__) || defined(TARGET_OS_MAC)\n     /* We need to check that <math.h> hasn't already been included earlier\n      * as it seems it doesn't agree with <fp.h>, yet we should really use\n      * <fp.h> if possible.\n      */\n#    if !defined(__MATH_H__) && !defined(__MATH_H) && !defined(__cmath__)\n#      include <fp.h>\n#    endif\n#  else\n#    include <math.h>\n#  endif\n#  if defined(_AMIGA) && defined(__SASC) && defined(_M68881)\n     /* Amiga SAS/C: We must include builtin FPU functions when compiling using\n      * MATH=68881\n      */\n#    include <m68881.h>\n#  endif\n#endif\n\n/* This provides the non-ANSI (far) memory allocation routines. */\n#if defined(__TURBOC__) && defined(__MSDOS__)\n#  include <mem.h>\n#  include <alloc.h>\n#endif\n\n#if defined(WIN32) || defined(_Windows) || defined(_WINDOWS) || \\\n    defined(_WIN32) || defined(__WIN32__)\n#  include <windows.h>  /* defines _WINDOWS_ macro */\n#endif\n#endif /* PNG_VERSION_INFO_ONLY */\n\n/* Moved here around 1.5.0beta36 from pngconf.h */\n/* Users may want to use these so they are not private.  Any library\n * functions that are passed far data must be model-independent.\n */\n\n/* Memory model/platform independent fns */\n#ifndef PNG_ABORT\n#  ifdef _WINDOWS_\n#    define PNG_ABORT() ExitProcess(0)\n#  else\n#    define PNG_ABORT() abort()\n#  endif\n#endif\n\n/* These macros may need to be architecture dependent. */\n#define PNG_ALIGN_NONE   0 /* do not use data alignment */\n#define PNG_ALIGN_ALWAYS 1 /* assume unaligned accesses are OK */\n#ifdef offsetof\n#  define PNG_ALIGN_OFFSET 2 /* use offsetof to determine alignment */\n#else\n#  define PNG_ALIGN_OFFSET -1 /* prevent the use of this */\n#endif\n#define PNG_ALIGN_SIZE   3 /* use sizeof to determine alignment */\n\n#ifndef PNG_ALIGN_TYPE\n   /* Default to using aligned access optimizations and requiring alignment to a\n    * multiple of the data type size.  Override in a compiler specific fashion\n    * if necessary by inserting tests here:\n    */\n#  define PNG_ALIGN_TYPE PNG_ALIGN_SIZE\n#endif\n\n#if PNG_ALIGN_TYPE == PNG_ALIGN_SIZE\n   /* This is used because in some compiler implementations non-aligned\n    * structure members are supported, so the offsetof approach below fails.\n    * Set PNG_ALIGN_SIZE=0 for compiler combinations where unaligned access\n    * is good for performance.  Do not do this unless you have tested the result\n    * and understand it.\n    */\n#  define png_alignof(type) (sizeof (type))\n#else\n#  if PNG_ALIGN_TYPE == PNG_ALIGN_OFFSET\n#     define png_alignof(type) offsetof(struct{char c; type t;}, t)\n#  else\n#     if PNG_ALIGN_TYPE == PNG_ALIGN_ALWAYS\n#        define png_alignof(type) (1)\n#     endif\n      /* Else leave png_alignof undefined to prevent use thereof */\n#  endif\n#endif\n\n/* This implicitly assumes alignment is always to a power of 2. */\n#ifdef png_alignof\n#  define png_isaligned(ptr, type)\\\n   ((((const char*)ptr-(const char*)0) & (png_alignof(type)-1)) == 0)\n#else\n#  define png_isaligned(ptr, type) 0\n#endif\n\n/* End of memory model/platform independent support */\n/* End of 1.5.0beta36 move from pngconf.h */\n\n/* CONSTANTS and UTILITY MACROS\n * These are used internally by libpng and not exposed in the API\n */\n\n/* Various modes of operation.  Note that after an init, mode is set to\n * zero automatically when the structure is created.  Three of these\n * are defined in png.h because they need to be visible to applications\n * that call png_set_unknown_chunk().\n */\n/* #define PNG_HAVE_IHDR            0x01 (defined in png.h) */\n/* #define PNG_HAVE_PLTE            0x02 (defined in png.h) */\n#define PNG_HAVE_IDAT               0x04\n/* #define PNG_AFTER_IDAT           0x08 (defined in png.h) */\n#define PNG_HAVE_IEND               0x10\n                   /*               0x20 (unused) */\n                   /*               0x40 (unused) */\n                   /*               0x80 (unused) */\n#define PNG_HAVE_CHUNK_HEADER      0x100\n#define PNG_WROTE_tIME             0x200\n#define PNG_WROTE_INFO_BEFORE_PLTE 0x400\n#define PNG_BACKGROUND_IS_GRAY     0x800\n#define PNG_HAVE_PNG_SIGNATURE    0x1000\n#define PNG_HAVE_CHUNK_AFTER_IDAT 0x2000 /* Have another chunk after IDAT */\n                   /*             0x4000 (unused) */\n#define PNG_IS_READ_STRUCT        0x8000 /* Else is a write struct */\n\n/* Flags for the transformations the PNG library does on the image data */\n#define PNG_BGR                 0x0001\n#define PNG_INTERLACE           0x0002\n#define PNG_PACK                0x0004\n#define PNG_SHIFT               0x0008\n#define PNG_SWAP_BYTES          0x0010\n#define PNG_INVERT_MONO         0x0020\n#define PNG_QUANTIZE            0x0040\n#define PNG_COMPOSE             0x0080     /* Was PNG_BACKGROUND */\n#define PNG_BACKGROUND_EXPAND   0x0100\n#define PNG_EXPAND_16           0x0200     /* Added to libpng 1.5.2 */\n#define PNG_16_TO_8             0x0400     /* Becomes 'chop' in 1.5.4 */\n#define PNG_RGBA                0x0800\n#define PNG_EXPAND              0x1000\n#define PNG_GAMMA               0x2000\n#define PNG_GRAY_TO_RGB         0x4000\n#define PNG_FILLER              0x8000\n#define PNG_PACKSWAP           0x10000\n#define PNG_SWAP_ALPHA         0x20000\n#define PNG_STRIP_ALPHA        0x40000\n#define PNG_INVERT_ALPHA       0x80000\n#define PNG_USER_TRANSFORM    0x100000\n#define PNG_RGB_TO_GRAY_ERR   0x200000\n#define PNG_RGB_TO_GRAY_WARN  0x400000\n#define PNG_RGB_TO_GRAY       0x600000 /* two bits, RGB_TO_GRAY_ERR|WARN */\n#define PNG_ENCODE_ALPHA      0x800000 /* Added to libpng-1.5.4 */\n#define PNG_ADD_ALPHA         0x1000000 /* Added to libpng-1.2.7 */\n#define PNG_EXPAND_tRNS       0x2000000 /* Added to libpng-1.2.9 */\n#define PNG_SCALE_16_TO_8     0x4000000 /* Added to libpng-1.5.4 */\n                       /*   0x8000000 unused */\n                       /*  0x10000000 unused */\n                       /*  0x20000000 unused */\n                       /*  0x40000000 unused */\n/* Flags for png_create_struct */\n#define PNG_STRUCT_PNG   0x0001\n#define PNG_STRUCT_INFO  0x0002\n\n/* Scaling factor for filter heuristic weighting calculations */\n#define PNG_WEIGHT_FACTOR (1<<(PNG_WEIGHT_SHIFT))\n#define PNG_COST_FACTOR (1<<(PNG_COST_SHIFT))\n\n/* Flags for the png_ptr->flags rather than declaring a byte for each one */\n#define PNG_FLAG_ZLIB_CUSTOM_STRATEGY     0x0001\n#define PNG_FLAG_ZSTREAM_INITIALIZED      0x0002 /* Added to libpng-1.6.0 */\n                                  /*      0x0004    unused */\n#define PNG_FLAG_ZSTREAM_ENDED            0x0008 /* Added to libpng-1.6.0 */\n                                  /*      0x0010    unused */\n                                  /*      0x0020    unused */\n#define PNG_FLAG_ROW_INIT                 0x0040\n#define PNG_FLAG_FILLER_AFTER             0x0080\n#define PNG_FLAG_CRC_ANCILLARY_USE        0x0100\n#define PNG_FLAG_CRC_ANCILLARY_NOWARN     0x0200\n#define PNG_FLAG_CRC_CRITICAL_USE         0x0400\n#define PNG_FLAG_CRC_CRITICAL_IGNORE      0x0800\n#define PNG_FLAG_ASSUME_sRGB              0x1000 /* Added to libpng-1.5.4 */\n#define PNG_FLAG_OPTIMIZE_ALPHA           0x2000 /* Added to libpng-1.5.4 */\n#define PNG_FLAG_DETECT_UNINITIALIZED     0x4000 /* Added to libpng-1.5.4 */\n/* #define PNG_FLAG_KEEP_UNKNOWN_CHUNKS      0x8000 */\n/* #define PNG_FLAG_KEEP_UNSAFE_CHUNKS      0x10000 */\n#define PNG_FLAG_LIBRARY_MISMATCH        0x20000\n#define PNG_FLAG_STRIP_ERROR_NUMBERS     0x40000\n#define PNG_FLAG_STRIP_ERROR_TEXT        0x80000\n#define PNG_FLAG_BENIGN_ERRORS_WARN     0x100000 /* Added to libpng-1.4.0 */\n#define PNG_FLAG_APP_WARNINGS_WARN      0x200000 /* Added to libpng-1.6.0 */\n#define PNG_FLAG_APP_ERRORS_WARN        0x400000 /* Added to libpng-1.6.0 */\n                                  /*    0x800000    unused */\n                                  /*   0x1000000    unused */\n                                  /*   0x2000000    unused */\n                                  /*   0x4000000    unused */\n                                  /*   0x8000000    unused */\n                                  /*  0x10000000    unused */\n                                  /*  0x20000000    unused */\n                                  /*  0x40000000    unused */\n\n#define PNG_FLAG_CRC_ANCILLARY_MASK (PNG_FLAG_CRC_ANCILLARY_USE | \\\n                                     PNG_FLAG_CRC_ANCILLARY_NOWARN)\n\n#define PNG_FLAG_CRC_CRITICAL_MASK  (PNG_FLAG_CRC_CRITICAL_USE | \\\n                                     PNG_FLAG_CRC_CRITICAL_IGNORE)\n\n#define PNG_FLAG_CRC_MASK           (PNG_FLAG_CRC_ANCILLARY_MASK | \\\n                                     PNG_FLAG_CRC_CRITICAL_MASK)\n\n/* Save typing and make code easier to understand */\n\n#define PNG_COLOR_DIST(c1, c2) (abs((int)((c1).red) - (int)((c2).red)) + \\\n   abs((int)((c1).green) - (int)((c2).green)) + \\\n   abs((int)((c1).blue) - (int)((c2).blue)))\n\n/* Added to libpng-1.6.0: scale a 16-bit value in the range 0..65535 to 0..255\n * by dividing by 257 *with rounding*.  This macro is exact for the given range.\n * See the discourse in pngrtran.c png_do_scale_16_to_8.  The values in the\n * macro were established by experiment (modifying the added value).  The macro\n * has a second variant that takes a value already scaled by 255 and divides by\n * 65535 - this has a maximum error of .502.  Over the range 0..65535*65535 it\n * only gives off-by-one errors and only for 0.5% (1 in 200) of the values.\n */\n#define PNG_DIV65535(v24) (((v24) + 32895) >> 16)\n#define PNG_DIV257(v16) PNG_DIV65535((png_uint_32)(v16) * 255)\n\n/* Added to libpng-1.2.6 JB */\n#define PNG_ROWBYTES(pixel_bits, width) \\\n    ((pixel_bits) >= 8 ? \\\n    ((png_size_t)(width) * (((png_size_t)(pixel_bits)) >> 3)) : \\\n    (( ((png_size_t)(width) * ((png_size_t)(pixel_bits))) + 7) >> 3) )\n\n/* PNG_OUT_OF_RANGE returns true if value is outside the range\n * ideal-delta..ideal+delta.  Each argument is evaluated twice.\n * \"ideal\" and \"delta\" should be constants, normally simple\n * integers, \"value\" a variable. Added to libpng-1.2.6 JB\n */\n#define PNG_OUT_OF_RANGE(value, ideal, delta) \\\n   ( (value) < (ideal)-(delta) || (value) > (ideal)+(delta) )\n\n/* Conversions between fixed and floating point, only defined if\n * required (to make sure the code doesn't accidentally use float\n * when it is supposedly disabled.)\n */\n#ifdef PNG_FLOATING_POINT_SUPPORTED\n/* The floating point conversion can't overflow, though it can and\n * does lose accuracy relative to the original fixed point value.\n * In practice this doesn't matter because png_fixed_point only\n * stores numbers with very low precision.  The png_ptr and s\n * arguments are unused by default but are there in case error\n * checking becomes a requirement.\n */\n#define png_float(png_ptr, fixed, s) (.00001 * (fixed))\n\n/* The fixed point conversion performs range checking and evaluates\n * its argument multiple times, so must be used with care.  The\n * range checking uses the PNG specification values for a signed\n * 32 bit fixed point value except that the values are deliberately\n * rounded-to-zero to an integral value - 21474 (21474.83 is roughly\n * (2^31-1) * 100000). 's' is a string that describes the value being\n * converted.\n *\n * NOTE: this macro will raise a png_error if the range check fails,\n * therefore it is normally only appropriate to use this on values\n * that come from API calls or other sources where an out of range\n * error indicates a programming error, not a data error!\n *\n * NOTE: by default this is off - the macro is not used - because the\n * function call saves a lot of code.\n */\n#ifdef PNG_FIXED_POINT_MACRO_SUPPORTED\n#define png_fixed(png_ptr, fp, s) ((fp) <= 21474 && (fp) >= -21474 ?\\\n    ((png_fixed_point)(100000 * (fp))) : (png_fixed_error(png_ptr, s),0))\n#endif\n/* else the corresponding function is defined below, inside the scope of the\n * cplusplus test.\n */\n#endif\n\n/* Constants for known chunk types.  If you need to add a chunk, define the name\n * here.  For historical reasons these constants have the form png_<name>; i.e.\n * the prefix is lower case.  Please use decimal values as the parameters to\n * match the ISO PNG specification and to avoid relying on the C locale\n * interpretation of character values.\n *\n * Prior to 1.5.6 these constants were strings, as of 1.5.6 png_uint_32 values\n * are computed and a new macro (PNG_STRING_FROM_CHUNK) added to allow a string\n * to be generated if required.\n *\n * PNG_32b correctly produces a value shifted by up to 24 bits, even on\n * architectures where (int) is only 16 bits.\n */\n#define PNG_32b(b,s) ((png_uint_32)(b) << (s))\n#define PNG_U32(b1,b2,b3,b4) \\\n   (PNG_32b(b1,24) | PNG_32b(b2,16) | PNG_32b(b3,8) | PNG_32b(b4,0))\n\n/* Constants for known chunk types.\n *\n * MAINTAINERS: If you need to add a chunk, define the name here.\n * For historical reasons these constants have the form png_<name>; i.e.\n * the prefix is lower case.  Please use decimal values as the parameters to\n * match the ISO PNG specification and to avoid relying on the C locale\n * interpretation of character values.  Please keep the list sorted.\n *\n * Notice that PNG_U32 is used to define a 32-bit value for the 4 byte chunk\n * type.  In fact the specification does not express chunk types this way,\n * however using a 32-bit value means that the chunk type can be read from the\n * stream using exactly the same code as used for a 32-bit unsigned value and\n * can be examined far more efficiently (using one arithmetic compare).\n *\n * Prior to 1.5.6 the chunk type constants were expressed as C strings.  The\n * libpng API still uses strings for 'unknown' chunks and a macro,\n * PNG_STRING_FROM_CHUNK, allows a string to be generated if required.  Notice\n * that for portable code numeric values must still be used; the string \"IHDR\"\n * is not portable and neither is PNG_U32('I', 'H', 'D', 'R').\n *\n * In 1.7.0 the definitions will be made public in png.h to avoid having to\n * duplicate the same definitions in application code.\n */\n#define png_IDAT PNG_U32( 73,  68,  65,  84)\n#define png_IEND PNG_U32( 73,  69,  78,  68)\n#define png_IHDR PNG_U32( 73,  72,  68,  82)\n#define png_PLTE PNG_U32( 80,  76,  84,  69)\n#define png_bKGD PNG_U32( 98,  75,  71,  68)\n#define png_cHRM PNG_U32( 99,  72,  82,  77)\n#define png_fRAc PNG_U32(102,  82,  65,  99) /* registered, not defined */\n#define png_gAMA PNG_U32(103,  65,  77,  65)\n#define png_gIFg PNG_U32(103,  73,  70, 103)\n#define png_gIFt PNG_U32(103,  73,  70, 116) /* deprecated */\n#define png_gIFx PNG_U32(103,  73,  70, 120)\n#define png_hIST PNG_U32(104,  73,  83,  84)\n#define png_iCCP PNG_U32(105,  67,  67,  80)\n#define png_iTXt PNG_U32(105,  84,  88, 116)\n#define png_oFFs PNG_U32(111,  70,  70, 115)\n#define png_pCAL PNG_U32(112,  67,  65,  76)\n#define png_pHYs PNG_U32(112,  72,  89, 115)\n#define png_sBIT PNG_U32(115,  66,  73,  84)\n#define png_sCAL PNG_U32(115,  67,  65,  76)\n#define png_sPLT PNG_U32(115,  80,  76,  84)\n#define png_sRGB PNG_U32(115,  82,  71,  66)\n#define png_sTER PNG_U32(115,  84,  69,  82)\n#define png_tEXt PNG_U32(116,  69,  88, 116)\n#define png_tIME PNG_U32(116,  73,  77,  69)\n#define png_tRNS PNG_U32(116,  82,  78,  83)\n#define png_zTXt PNG_U32(122,  84,  88, 116)\n\n/* The following will work on (signed char*) strings, whereas the get_uint_32\n * macro will fail on top-bit-set values because of the sign extension.\n */\n#define PNG_CHUNK_FROM_STRING(s)\\\n   PNG_U32(0xff&(s)[0], 0xff&(s)[1], 0xff&(s)[2], 0xff&(s)[3])\n\n/* This uses (char), not (png_byte) to avoid warnings on systems where (char) is\n * signed and the argument is a (char[])  This macro will fail miserably on\n * systems where (char) is more than 8 bits.\n */\n#define PNG_STRING_FROM_CHUNK(s,c)\\\n   (void)(((char*)(s))[0]=(char)((c)>>24), ((char*)(s))[1]=(char)((c)>>16),\\\n   ((char*)(s))[2]=(char)((c)>>8), ((char*)(s))[3]=(char)((c)))\n\n/* Do the same but terminate with a null character. */\n#define PNG_CSTRING_FROM_CHUNK(s,c)\\\n   (void)(PNG_STRING_FROM_CHUNK(s,c), ((char*)(s))[4] = 0)\n\n/* Test on flag values as defined in the spec (section 5.4): */\n#define PNG_CHUNK_ANCILLARY(c)   (1 & ((c) >> 29))\n#define PNG_CHUNK_CRITICAL(c)     (!PNG_CHUNK_ANCILLARY(c))\n#define PNG_CHUNK_PRIVATE(c)      (1 & ((c) >> 21))\n#define PNG_CHUNK_RESERVED(c)     (1 & ((c) >> 13))\n#define PNG_CHUNK_SAFE_TO_COPY(c) (1 & ((c) >>  5))\n\n/* Gamma values (new at libpng-1.5.4): */\n#define PNG_GAMMA_MAC_OLD 151724  /* Assume '1.8' is really 2.2/1.45! */\n#define PNG_GAMMA_MAC_INVERSE 65909\n#define PNG_GAMMA_sRGB_INVERSE 45455\n\n/* Almost everything below is C specific; the #defines above can be used in\n * non-C code (so long as it is C-preprocessed) the rest of this stuff cannot.\n */\n#ifndef PNG_VERSION_INFO_ONLY\n\n#include \"pngstruct.h\"\n#include \"pnginfo.h\"\n\n/* Validate the include paths - the include path used to generate pnglibconf.h\n * must match that used in the build, or we must be using pnglibconf.h.prebuilt:\n */\n#if PNG_ZLIB_VERNUM != 0 && PNG_ZLIB_VERNUM != ZLIB_VERNUM\n#  error ZLIB_VERNUM != PNG_ZLIB_VERNUM \\\n      \"-I (include path) error: see the notes in pngpriv.h\"\n   /* This means that when pnglibconf.h was built the copy of zlib.h that it\n    * used is not the same as the one being used here.  Because the build of\n    * libpng makes decisions to use inflateInit2 and inflateReset2 based on the\n    * zlib version number and because this affects handling of certain broken\n    * PNG files the -I directives must match.\n    *\n    * The most likely explanation is that you passed a -I in CFLAGS, this will\n    * not work; all the preprocessor directories and in particular all the -I\n    * directives must be in CPPFLAGS.\n    */\n#endif\n\n/* This is used for 16 bit gamma tables -- only the top level pointers are\n * const; this could be changed:\n */\ntypedef const png_uint_16p * png_const_uint_16pp;\n\n/* Added to libpng-1.5.7: sRGB conversion tables */\n#if defined(PNG_SIMPLIFIED_READ_SUPPORTED) ||\\\n   defined(PNG_SIMPLIFIED_WRITE_SUPPORTED)\n#ifdef PNG_SIMPLIFIED_READ_SUPPORTED\nPNG_INTERNAL_DATA(const png_uint_16, png_sRGB_table, [256]);\n   /* Convert from an sRGB encoded value 0..255 to a 16-bit linear value,\n    * 0..65535.  This table gives the closest 16-bit answers (no errors).\n    */\n#endif\n\nPNG_INTERNAL_DATA(const png_uint_16, png_sRGB_base, [512]);\nPNG_INTERNAL_DATA(const png_byte, png_sRGB_delta, [512]);\n\n#define PNG_sRGB_FROM_LINEAR(linear) ((png_byte)((png_sRGB_base[(linear)>>15] +\\\n   ((((linear)&0x7fff)*png_sRGB_delta[(linear)>>15])>>12)) >> 8))\n   /* Given a value 'linear' in the range 0..255*65535 calculate the 8-bit sRGB\n    * encoded value with maximum error 0.646365.  Note that the input is not a\n    * 16-bit value; it has been multiplied by 255! */\n#endif /* PNG_SIMPLIFIED_READ/WRITE */\n\n\n/* Inhibit C++ name-mangling for libpng functions but not for system calls. */\n#ifdef __cplusplus\nextern \"C\" {\n#endif /* __cplusplus */\n\n/* Internal functions; these are not exported from a DLL however because they\n * are used within several of the C source files they have to be C extern.\n *\n * All of these functions must be declared with PNG_INTERNAL_FUNCTION.\n */\n\n/* Zlib support */\n#define PNG_UNEXPECTED_ZLIB_RETURN (-7)\nPNG_INTERNAL_FUNCTION(void, png_zstream_error,(png_structrp png_ptr, int ret),\n   PNG_EMPTY);\n   /* Used by the zlib handling functions to ensure that z_stream::msg is always\n    * set before they return.\n    */\n\n#ifdef PNG_WRITE_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_free_buffer_list,(png_structrp png_ptr,\n   png_compression_bufferp *list),PNG_EMPTY);\n   /* Free the buffer list used by the compressed write code. */\n#endif\n\n#if defined(PNG_FLOATING_POINT_SUPPORTED) && \\\n   !defined(PNG_FIXED_POINT_MACRO_SUPPORTED) && \\\n   (defined(PNG_gAMA_SUPPORTED) || defined(PNG_cHRM_SUPPORTED) || \\\n   defined(PNG_sCAL_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) || \\\n   defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)) || \\\n   (defined(PNG_sCAL_SUPPORTED) && \\\n   defined(PNG_FLOATING_ARITHMETIC_SUPPORTED))\nPNG_INTERNAL_FUNCTION(png_fixed_point,png_fixed,(png_const_structrp png_ptr,\n   double fp, png_const_charp text),PNG_EMPTY);\n#endif\n\n/* Check the user version string for compatibility, returns false if the version\n * numbers aren't compatible.\n */\nPNG_INTERNAL_FUNCTION(int,png_user_version_check,(png_structrp png_ptr,\n   png_const_charp user_png_ver),PNG_EMPTY);\n\n/* Internal base allocator - no messages, NULL on failure to allocate.  This\n * does, however, call the application provided allocator and that could call\n * png_error (although that would be a bug in the application implementation.)\n */\nPNG_INTERNAL_FUNCTION(png_voidp,png_malloc_base,(png_const_structrp png_ptr,\n   png_alloc_size_t size),PNG_ALLOCATED);\n\n#if defined(PNG_TEXT_SUPPORTED) || defined(PNG_sPLT_SUPPORTED) ||\\\n   defined(PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED)\n/* Internal array allocator, outputs no error or warning messages on failure,\n * just returns NULL.  \n */\nPNG_INTERNAL_FUNCTION(png_voidp,png_malloc_array,(png_const_structrp png_ptr,\n   int nelements, size_t element_size),PNG_ALLOCATED);\n\n/* The same but an existing array is extended by add_elements.  This function\n * also memsets the new elements to 0 and copies the old elements.  The old\n * array is not freed or altered.\n */\nPNG_INTERNAL_FUNCTION(png_voidp,png_realloc_array,(png_const_structrp png_ptr,\n   png_const_voidp array, int old_elements, int add_elements,\n   size_t element_size),PNG_ALLOCATED);\n#endif /* text, sPLT or unknown chunks */\n\n/* Magic to create a struct when there is no struct to call the user supplied\n * memory allocators.  Because error handling has not been set up the memory\n * handlers can't safely call png_error, but this is an obscure and undocumented\n * restriction so libpng has to assume that the 'free' handler, at least, might\n * call png_error.\n */\nPNG_INTERNAL_FUNCTION(png_structp,png_create_png_struct,\n   (png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn,\n    png_error_ptr warn_fn, png_voidp mem_ptr, png_malloc_ptr malloc_fn,\n    png_free_ptr free_fn),PNG_ALLOCATED);\n\n/* Free memory from internal libpng struct */\nPNG_INTERNAL_FUNCTION(void,png_destroy_png_struct,(png_structrp png_ptr),\n   PNG_EMPTY);\n\n/* Free an allocated jmp_buf (always succeeds) */\nPNG_INTERNAL_FUNCTION(void,png_free_jmpbuf,(png_structrp png_ptr),PNG_EMPTY);\n\n/* Function to allocate memory for zlib.  PNGAPI is disallowed. */\nPNG_INTERNAL_FUNCTION(voidpf,png_zalloc,(voidpf png_ptr, uInt items, uInt size),\n   PNG_ALLOCATED);\n\n/* Function to free memory for zlib.  PNGAPI is disallowed. */\nPNG_INTERNAL_FUNCTION(void,png_zfree,(voidpf png_ptr, voidpf ptr),PNG_EMPTY);\n\n/* Next four functions are used internally as callbacks.  PNGCBAPI is required\n * but not PNG_EXPORT.  PNGAPI added at libpng version 1.2.3, changed to\n * PNGCBAPI at 1.5.0\n */\n\nPNG_INTERNAL_FUNCTION(void PNGCBAPI,png_default_read_data,(png_structp png_ptr,\n    png_bytep data, png_size_t length),PNG_EMPTY);\n\n#ifdef PNG_PROGRESSIVE_READ_SUPPORTED\nPNG_INTERNAL_FUNCTION(void PNGCBAPI,png_push_fill_buffer,(png_structp png_ptr,\n    png_bytep buffer, png_size_t length),PNG_EMPTY);\n#endif\n\nPNG_INTERNAL_FUNCTION(void PNGCBAPI,png_default_write_data,(png_structp png_ptr,\n    png_bytep data, png_size_t length),PNG_EMPTY);\n\n#ifdef PNG_WRITE_FLUSH_SUPPORTED\n#  ifdef PNG_STDIO_SUPPORTED\nPNG_INTERNAL_FUNCTION(void PNGCBAPI,png_default_flush,(png_structp png_ptr),\n   PNG_EMPTY);\n#  endif\n#endif\n\n/* Reset the CRC variable */\nPNG_INTERNAL_FUNCTION(void,png_reset_crc,(png_structrp png_ptr),PNG_EMPTY);\n\n/* Write the \"data\" buffer to whatever output you are using */\nPNG_INTERNAL_FUNCTION(void,png_write_data,(png_structrp png_ptr,\n    png_const_bytep data, png_size_t length),PNG_EMPTY);\n\n/* Read and check the PNG file signature */\nPNG_INTERNAL_FUNCTION(void,png_read_sig,(png_structrp png_ptr,\n   png_inforp info_ptr),PNG_EMPTY);\n\n/* Read the chunk header (length + type name) */\nPNG_INTERNAL_FUNCTION(png_uint_32,png_read_chunk_header,(png_structrp png_ptr),\n   PNG_EMPTY);\n\n/* Read data from whatever input you are using into the \"data\" buffer */\nPNG_INTERNAL_FUNCTION(void,png_read_data,(png_structrp png_ptr, png_bytep data,\n    png_size_t length),PNG_EMPTY);\n\n/* Read bytes into buf, and update png_ptr->crc */\nPNG_INTERNAL_FUNCTION(void,png_crc_read,(png_structrp png_ptr, png_bytep buf,\n    png_uint_32 length),PNG_EMPTY);\n\n/* Read \"skip\" bytes, read the file crc, and (optionally) verify png_ptr->crc */\nPNG_INTERNAL_FUNCTION(int,png_crc_finish,(png_structrp png_ptr,\n   png_uint_32 skip),PNG_EMPTY);\n\n/* Read the CRC from the file and compare it to the libpng calculated CRC */\nPNG_INTERNAL_FUNCTION(int,png_crc_error,(png_structrp png_ptr),PNG_EMPTY);\n\n/* Calculate the CRC over a section of data.  Note that we are only\n * passing a maximum of 64K on systems that have this as a memory limit,\n * since this is the maximum buffer size we can specify.\n */\nPNG_INTERNAL_FUNCTION(void,png_calculate_crc,(png_structrp png_ptr,\n   png_const_bytep ptr, png_size_t length),PNG_EMPTY);\n\n#ifdef PNG_WRITE_FLUSH_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_flush,(png_structrp png_ptr),PNG_EMPTY);\n#endif\n\n/* Write various chunks */\n\n/* Write the IHDR chunk, and update the png_struct with the necessary\n * information.\n */\nPNG_INTERNAL_FUNCTION(void,png_write_IHDR,(png_structrp png_ptr,\n   png_uint_32 width, png_uint_32 height, int bit_depth, int color_type,\n   int compression_method, int filter_method, int interlace_method),PNG_EMPTY);\n\nPNG_INTERNAL_FUNCTION(void,png_write_PLTE,(png_structrp png_ptr,\n   png_const_colorp palette, png_uint_32 num_pal),PNG_EMPTY);\n\nPNG_INTERNAL_FUNCTION(void,png_compress_IDAT,(png_structrp png_ptr,\n   png_const_bytep row_data, png_alloc_size_t row_data_length, int flush),\n   PNG_EMPTY);\n\nPNG_INTERNAL_FUNCTION(void,png_write_IEND,(png_structrp png_ptr),PNG_EMPTY);\n\n#ifdef PNG_WRITE_gAMA_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_write_gAMA_fixed,(png_structrp png_ptr,\n    png_fixed_point file_gamma),PNG_EMPTY);\n#endif\n\n#ifdef PNG_WRITE_sBIT_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_write_sBIT,(png_structrp png_ptr,\n    png_const_color_8p sbit, int color_type),PNG_EMPTY);\n#endif\n\n#ifdef PNG_WRITE_cHRM_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_write_cHRM_fixed,(png_structrp png_ptr,\n    const png_xy *xy), PNG_EMPTY);\n    /* The xy value must have been previously validated */\n#endif\n\n#ifdef PNG_WRITE_sRGB_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_write_sRGB,(png_structrp png_ptr,\n    int intent),PNG_EMPTY);\n#endif\n\n#ifdef PNG_WRITE_iCCP_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_write_iCCP,(png_structrp png_ptr,\n   png_const_charp name, png_const_bytep profile), PNG_EMPTY);\n   /* The profile must have been previously validated for correctness, the\n    * length comes from the first four bytes.  Only the base, deflate,\n    * compression is supported.\n    */\n#endif\n\n#ifdef PNG_WRITE_sPLT_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_write_sPLT,(png_structrp png_ptr,\n    png_const_sPLT_tp palette),PNG_EMPTY);\n#endif\n\n#ifdef PNG_WRITE_tRNS_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_write_tRNS,(png_structrp png_ptr,\n    png_const_bytep trans, png_const_color_16p values, int number,\n    int color_type),PNG_EMPTY);\n#endif\n\n#ifdef PNG_WRITE_bKGD_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_write_bKGD,(png_structrp png_ptr,\n    png_const_color_16p values, int color_type),PNG_EMPTY);\n#endif\n\n#ifdef PNG_WRITE_hIST_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_write_hIST,(png_structrp png_ptr,\n    png_const_uint_16p hist, int num_hist),PNG_EMPTY);\n#endif\n\n/* Chunks that have keywords */\n#ifdef PNG_WRITE_tEXt_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_write_tEXt,(png_structrp png_ptr,\n   png_const_charp key, png_const_charp text, png_size_t text_len),PNG_EMPTY);\n#endif\n\n#ifdef PNG_WRITE_zTXt_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_write_zTXt,(png_structrp png_ptr, png_const_charp\n    key, png_const_charp text, png_size_t text_len, int compression),PNG_EMPTY);\n#endif\n\n#ifdef PNG_WRITE_iTXt_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_write_iTXt,(png_structrp png_ptr,\n    int compression, png_const_charp key, png_const_charp lang,\n    png_const_charp lang_key, png_const_charp text),PNG_EMPTY);\n#endif\n\n#ifdef PNG_TEXT_SUPPORTED  /* Added at version 1.0.14 and 1.2.4 */\nPNG_INTERNAL_FUNCTION(int,png_set_text_2,(png_const_structrp png_ptr,\n    png_inforp info_ptr, png_const_textp text_ptr, int num_text),PNG_EMPTY);\n#endif\n\n#ifdef PNG_WRITE_oFFs_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_write_oFFs,(png_structrp png_ptr,\n    png_int_32 x_offset, png_int_32 y_offset, int unit_type),PNG_EMPTY);\n#endif\n\n#ifdef PNG_WRITE_pCAL_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_write_pCAL,(png_structrp png_ptr,\n    png_charp purpose, png_int_32 X0, png_int_32 X1, int type, int nparams,\n    png_const_charp units, png_charpp params),PNG_EMPTY);\n#endif\n\n#ifdef PNG_WRITE_pHYs_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_write_pHYs,(png_structrp png_ptr,\n    png_uint_32 x_pixels_per_unit, png_uint_32 y_pixels_per_unit,\n    int unit_type),PNG_EMPTY);\n#endif\n\n#ifdef PNG_WRITE_tIME_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_write_tIME,(png_structrp png_ptr,\n    png_const_timep mod_time),PNG_EMPTY);\n#endif\n\n#ifdef PNG_WRITE_sCAL_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_write_sCAL_s,(png_structrp png_ptr,\n    int unit, png_const_charp width, png_const_charp height),PNG_EMPTY);\n#endif\n\n/* Called when finished processing a row of data */\nPNG_INTERNAL_FUNCTION(void,png_write_finish_row,(png_structrp png_ptr),\n    PNG_EMPTY);\n\n/* Internal use only.   Called before first row of data */\nPNG_INTERNAL_FUNCTION(void,png_write_start_row,(png_structrp png_ptr),\n    PNG_EMPTY);\n\n/* Combine a row of data, dealing with alpha, etc. if requested.  'row' is an\n * array of png_ptr->width pixels.  If the image is not interlaced or this\n * is the final pass this just does a memcpy, otherwise the \"display\" flag\n * is used to determine whether to copy pixels that are not in the current pass.\n *\n * Because 'png_do_read_interlace' (below) replicates pixels this allows this\n * function to achieve the documented 'blocky' appearance during interlaced read\n * if display is 1 and the 'sparkle' appearance, where existing pixels in 'row'\n * are not changed if they are not in the current pass, when display is 0.\n *\n * 'display' must be 0 or 1, otherwise the memcpy will be done regardless.\n *\n * The API always reads from the png_struct row buffer and always assumes that\n * it is full width (png_do_read_interlace has already been called.)\n *\n * This function is only ever used to write to row buffers provided by the\n * caller of the relevant libpng API and the row must have already been\n * transformed by the read transformations.\n *\n * The PNG_USE_COMPILE_TIME_MASKS option causes generation of pre-computed\n * bitmasks for use within the code, otherwise runtime generated masks are used.\n * The default is compile time masks.\n */\n#ifndef PNG_USE_COMPILE_TIME_MASKS\n#  define PNG_USE_COMPILE_TIME_MASKS 1\n#endif\nPNG_INTERNAL_FUNCTION(void,png_combine_row,(png_const_structrp png_ptr,\n    png_bytep row, int display),PNG_EMPTY);\n\n#ifdef PNG_READ_INTERLACING_SUPPORTED\n/* Expand an interlaced row: the 'row_info' describes the pass data that has\n * been read in and must correspond to the pixels in 'row', the pixels are\n * expanded (moved apart) in 'row' to match the final layout, when doing this\n * the pixels are *replicated* to the intervening space.  This is essential for\n * the correct operation of png_combine_row, above.\n */\nPNG_INTERNAL_FUNCTION(void,png_do_read_interlace,(png_row_infop row_info,\n    png_bytep row, int pass, png_uint_32 transformations),PNG_EMPTY);\n#endif\n\n/* GRR TO DO (2.0 or whenever):  simplify other internal calling interfaces */\n\n#ifdef PNG_WRITE_INTERLACING_SUPPORTED\n/* Grab pixels out of a row for an interlaced pass */\nPNG_INTERNAL_FUNCTION(void,png_do_write_interlace,(png_row_infop row_info,\n    png_bytep row, int pass),PNG_EMPTY);\n#endif\n\n/* Unfilter a row: check the filter value before calling this, there is no point\n * calling it for PNG_FILTER_VALUE_NONE.\n */\nPNG_INTERNAL_FUNCTION(void,png_read_filter_row,(png_structrp pp, png_row_infop\n    row_info, png_bytep row, png_const_bytep prev_row, int filter),PNG_EMPTY);\n\nPNG_INTERNAL_FUNCTION(void,png_read_filter_row_up_neon,(png_row_infop row_info,\n    png_bytep row, png_const_bytep prev_row),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub3_neon,(png_row_infop\n    row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub4_neon,(png_row_infop\n    row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_read_filter_row_avg3_neon,(png_row_infop\n    row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_read_filter_row_avg4_neon,(png_row_infop\n    row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth3_neon,(png_row_infop\n    row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth4_neon,(png_row_infop\n    row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);\n\n/* Choose the best filter to use and filter the row data */\nPNG_INTERNAL_FUNCTION(void,png_write_find_filter,(png_structrp png_ptr,\n    png_row_infop row_info),PNG_EMPTY);\n\n#ifdef PNG_SEQUENTIAL_READ_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_read_IDAT_data,(png_structrp png_ptr,\n   png_bytep output, png_alloc_size_t avail_out),PNG_EMPTY);\n   /* Read 'avail_out' bytes of data from the IDAT stream.  If the output buffer\n    * is NULL the function checks, instead, for the end of the stream.  In this\n    * case a benign error will be issued if the stream end is not found or if\n    * extra data has to be consumed.\n    */\nPNG_INTERNAL_FUNCTION(void,png_read_finish_IDAT,(png_structrp png_ptr),\n   PNG_EMPTY);\n   /* This cleans up when the IDAT LZ stream does not end when the last image\n    * byte is read; there is still some pending input.\n    */\n\nPNG_INTERNAL_FUNCTION(void,png_read_finish_row,(png_structrp png_ptr),\n   PNG_EMPTY);\n   /* Finish a row while reading, dealing with interlacing passes, etc. */\n#endif /* PNG_SEQUENTIAL_READ_SUPPORTED */\n\n/* Initialize the row buffers, etc. */\nPNG_INTERNAL_FUNCTION(void,png_read_start_row,(png_structrp png_ptr),PNG_EMPTY);\n\n#ifdef PNG_READ_TRANSFORMS_SUPPORTED\n/* Optional call to update the users info structure */\nPNG_INTERNAL_FUNCTION(void,png_read_transform_info,(png_structrp png_ptr,\n    png_inforp info_ptr),PNG_EMPTY);\n#endif\n\n/* Shared transform functions, defined in pngtran.c */\n#if defined(PNG_WRITE_FILLER_SUPPORTED) || \\\n    defined(PNG_READ_STRIP_ALPHA_SUPPORTED)\nPNG_INTERNAL_FUNCTION(void,png_do_strip_channel,(png_row_infop row_info,\n    png_bytep row, int at_start),PNG_EMPTY);\n#endif\n\n#ifdef PNG_16BIT_SUPPORTED\n#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED)\nPNG_INTERNAL_FUNCTION(void,png_do_swap,(png_row_infop row_info,\n    png_bytep row),PNG_EMPTY);\n#endif\n#endif\n\n#if defined(PNG_READ_PACKSWAP_SUPPORTED) || \\\n    defined(PNG_WRITE_PACKSWAP_SUPPORTED)\nPNG_INTERNAL_FUNCTION(void,png_do_packswap,(png_row_infop row_info,\n    png_bytep row),PNG_EMPTY);\n#endif\n\n#if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED)\nPNG_INTERNAL_FUNCTION(void,png_do_invert,(png_row_infop row_info,\n    png_bytep row),PNG_EMPTY);\n#endif\n\n#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED)\nPNG_INTERNAL_FUNCTION(void,png_do_bgr,(png_row_infop row_info,\n    png_bytep row),PNG_EMPTY);\n#endif\n\n/* The following decodes the appropriate chunks, and does error correction,\n * then calls the appropriate callback for the chunk if it is valid.\n */\n\n/* Decode the IHDR chunk */\nPNG_INTERNAL_FUNCTION(void,png_handle_IHDR,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_handle_PLTE,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_handle_IEND,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\n\n#ifdef PNG_READ_bKGD_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_handle_bKGD,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\n#endif\n\n#ifdef PNG_READ_cHRM_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_handle_cHRM,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\n#endif\n\n#ifdef PNG_READ_gAMA_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_handle_gAMA,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\n#endif\n\n#ifdef PNG_READ_hIST_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_handle_hIST,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\n#endif\n\n#ifdef PNG_READ_iCCP_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_handle_iCCP,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\n#endif /* PNG_READ_iCCP_SUPPORTED */\n\n#ifdef PNG_READ_iTXt_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_handle_iTXt,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\n#endif\n\n#ifdef PNG_READ_oFFs_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_handle_oFFs,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\n#endif\n\n#ifdef PNG_READ_pCAL_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_handle_pCAL,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\n#endif\n\n#ifdef PNG_READ_pHYs_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_handle_pHYs,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\n#endif\n\n#ifdef PNG_READ_sBIT_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_handle_sBIT,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\n#endif\n\n#ifdef PNG_READ_sCAL_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_handle_sCAL,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\n#endif\n\n#ifdef PNG_READ_sPLT_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_handle_sPLT,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\n#endif /* PNG_READ_sPLT_SUPPORTED */\n\n#ifdef PNG_READ_sRGB_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_handle_sRGB,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\n#endif\n\n#ifdef PNG_READ_tEXt_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_handle_tEXt,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\n#endif\n\n#ifdef PNG_READ_tIME_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_handle_tIME,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\n#endif\n\n#ifdef PNG_READ_tRNS_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_handle_tRNS,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\n#endif\n\n#ifdef PNG_READ_zTXt_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_handle_zTXt,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\n#endif\n\nPNG_INTERNAL_FUNCTION(void,png_check_chunk_name,(png_structrp png_ptr,\n    png_uint_32 chunk_name),PNG_EMPTY);\n\nPNG_INTERNAL_FUNCTION(void,png_handle_unknown,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length, int keep),PNG_EMPTY);\n   /* This is the function that gets called for unknown chunks.  The 'keep'\n    * argument is either non-zero for a known chunk that has been set to be\n    * handled as unknown or zero for an unknown chunk.  By default the function\n    * just skips the chunk or errors out if it is critical.\n    */\n\n#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) ||\\\n    defined(PNG_HANDLE_AS_UNKNOWN_SUPPORTED)\nPNG_INTERNAL_FUNCTION(int,png_chunk_unknown_handling,\n    (png_const_structrp png_ptr, png_uint_32 chunk_name),PNG_EMPTY);\n   /* Exactly as the API png_handle_as_unknown() except that the argument is a\n    * 32-bit chunk name, not a string.\n    */\n#endif /* READ_UNKNOWN_CHUNKS || HANDLE_AS_UNKNOWN */\n\n/* Handle the transformations for reading and writing */\n#ifdef PNG_READ_TRANSFORMS_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_do_read_transformations,(png_structrp png_ptr,\n   png_row_infop row_info),PNG_EMPTY);\n#endif\n#ifdef PNG_WRITE_TRANSFORMS_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_do_write_transformations,(png_structrp png_ptr,\n   png_row_infop row_info),PNG_EMPTY);\n#endif\n\n#ifdef PNG_READ_TRANSFORMS_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_init_read_transformations,(png_structrp png_ptr),\n    PNG_EMPTY);\n#endif\n\n#ifdef PNG_PROGRESSIVE_READ_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_push_read_chunk,(png_structrp png_ptr,\n    png_inforp info_ptr),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_push_read_sig,(png_structrp png_ptr,\n    png_inforp info_ptr),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_push_check_crc,(png_structrp png_ptr),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_push_crc_skip,(png_structrp png_ptr,\n    png_uint_32 length),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_push_crc_finish,(png_structrp png_ptr),\n    PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_push_save_buffer,(png_structrp png_ptr),\n    PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_push_restore_buffer,(png_structrp png_ptr,\n    png_bytep buffer, png_size_t buffer_length),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_push_read_IDAT,(png_structrp png_ptr),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_process_IDAT_data,(png_structrp png_ptr,\n    png_bytep buffer, png_size_t buffer_length),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_push_process_row,(png_structrp png_ptr),\n    PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_push_handle_unknown,(png_structrp png_ptr,\n   png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_push_have_info,(png_structrp png_ptr,\n   png_inforp info_ptr),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_push_have_end,(png_structrp png_ptr,\n   png_inforp info_ptr),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_push_have_row,(png_structrp png_ptr,\n     png_bytep row),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_push_read_end,(png_structrp png_ptr,\n    png_inforp info_ptr),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_process_some_data,(png_structrp png_ptr,\n    png_inforp info_ptr),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_read_push_finish_row,(png_structrp png_ptr),\n    PNG_EMPTY);\n#  ifdef PNG_READ_tEXt_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_push_handle_tEXt,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_push_read_tEXt,(png_structrp png_ptr,\n    png_inforp info_ptr),PNG_EMPTY);\n#  endif\n#  ifdef PNG_READ_zTXt_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_push_handle_zTXt,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_push_read_zTXt,(png_structrp png_ptr,\n    png_inforp info_ptr),PNG_EMPTY);\n#  endif\n#  ifdef PNG_READ_iTXt_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_push_handle_iTXt,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_push_read_iTXt,(png_structrp png_ptr,\n    png_inforp info_ptr),PNG_EMPTY);\n#  endif\n\n#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */\n\n/* Added at libpng version 1.6.0 */\n#ifdef PNG_GAMMA_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_colorspace_set_gamma,(png_const_structrp png_ptr,\n    png_colorspacerp colorspace, png_fixed_point gAMA), PNG_EMPTY);\n   /* Set the colorspace gamma with a value provided by the application or by\n    * the gAMA chunk on read.  The value will override anything set by an ICC\n    * profile.\n    */\n\nPNG_INTERNAL_FUNCTION(void,png_colorspace_sync_info,(png_const_structrp png_ptr,\n    png_inforp info_ptr), PNG_EMPTY);\n    /* Synchronize the info 'valid' flags with the colorspace */\n\nPNG_INTERNAL_FUNCTION(void,png_colorspace_sync,(png_const_structrp png_ptr,\n    png_inforp info_ptr), PNG_EMPTY);\n    /* Copy the png_struct colorspace to the info_struct and call the above to\n     * synchronize the flags.  Checks for NULL info_ptr and does nothing.\n     */\n#endif\n\n/* Added at libpng version 1.4.0 */\n#ifdef PNG_COLORSPACE_SUPPORTED\n/* These internal functions are for maintaining the colorspace structure within\n * a png_info or png_struct (or, indeed, both).\n */\nPNG_INTERNAL_FUNCTION(int,png_colorspace_set_chromaticities,\n   (png_const_structrp png_ptr, png_colorspacerp colorspace, const png_xy *xy,\n    int preferred), PNG_EMPTY);\n\nPNG_INTERNAL_FUNCTION(int,png_colorspace_set_endpoints,\n   (png_const_structrp png_ptr, png_colorspacerp colorspace, const png_XYZ *XYZ,\n    int preferred), PNG_EMPTY);\n\n#ifdef PNG_sRGB_SUPPORTED\nPNG_INTERNAL_FUNCTION(int,png_colorspace_set_sRGB,(png_const_structrp png_ptr,\n   png_colorspacerp colorspace, int intent), PNG_EMPTY);\n   /* This does set the colorspace gAMA and cHRM values too, but doesn't set the\n    * flags to write them, if it returns false there was a problem and an error\n    * message has already been output (but the colorspace may still need to be\n    * synced to record the invalid flag).\n    */\n#endif /* sRGB */\n\n#ifdef PNG_iCCP_SUPPORTED\nPNG_INTERNAL_FUNCTION(int,png_colorspace_set_ICC,(png_const_structrp png_ptr,\n   png_colorspacerp colorspace, png_const_charp name,\n   png_uint_32 profile_length, png_const_bytep profile, int color_type),\n   PNG_EMPTY);\n   /* The 'name' is used for information only */\n\n/* Routines for checking parts of an ICC profile. */\nPNG_INTERNAL_FUNCTION(int,png_icc_check_length,(png_const_structrp png_ptr,\n   png_colorspacerp colorspace, png_const_charp name,\n   png_uint_32 profile_length), PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(int,png_icc_check_header,(png_const_structrp png_ptr,\n   png_colorspacerp colorspace, png_const_charp name,\n   png_uint_32 profile_length,\n   png_const_bytep profile /* first 132 bytes only */, int color_type),\n   PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(int,png_icc_check_tag_table,(png_const_structrp png_ptr,\n   png_colorspacerp colorspace, png_const_charp name,\n   png_uint_32 profile_length,\n   png_const_bytep profile /* header plus whole tag table */), PNG_EMPTY);\n#ifdef PNG_sRGB_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_icc_set_sRGB,(\n   png_const_structrp png_ptr, png_colorspacerp colorspace,\n   png_const_bytep profile, uLong adler), PNG_EMPTY);\n   /* 'adler' is the Adler32 checksum of the uncompressed profile data. It may\n    * be zero to indicate that it is not available.  It is used, if provided,\n    * as a fast check on the profile when checking to see if it is sRGB.\n    */\n#endif\n#endif /* iCCP */\n\n#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_colorspace_set_rgb_coefficients,\n   (png_structrp png_ptr), PNG_EMPTY);\n   /* Set the rgb_to_gray coefficients from the colorspace Y values */\n#endif /* READ_RGB_TO_GRAY */\n#endif /* COLORSPACE */\n\n/* Added at libpng version 1.4.0 */\nPNG_INTERNAL_FUNCTION(void,png_check_IHDR,(png_const_structrp png_ptr,\n    png_uint_32 width, png_uint_32 height, int bit_depth,\n    int color_type, int interlace_type, int compression_type,\n    int filter_type),PNG_EMPTY);\n\n/* Added at libpng version 1.5.10 */\n#if defined(PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED) || \\\n    defined(PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED)\nPNG_INTERNAL_FUNCTION(void,png_do_check_palette_indexes,\n   (png_structrp png_ptr, png_row_infop row_info),PNG_EMPTY);\n#endif\n\n#if defined(PNG_FLOATING_POINT_SUPPORTED) && defined(PNG_ERROR_TEXT_SUPPORTED)\nPNG_INTERNAL_FUNCTION(void,png_fixed_error,(png_const_structrp png_ptr,\n   png_const_charp name),PNG_NORETURN);\n#endif\n\n/* Puts 'string' into 'buffer' at buffer[pos], taking care never to overwrite\n * the end.  Always leaves the buffer nul terminated.  Never errors out (and\n * there is no error code.)\n */\nPNG_INTERNAL_FUNCTION(size_t,png_safecat,(png_charp buffer, size_t bufsize,\n   size_t pos, png_const_charp string),PNG_EMPTY);\n\n/* Various internal functions to handle formatted warning messages, currently\n * only implemented for warnings.\n */\n#if defined(PNG_WARNINGS_SUPPORTED) || defined(PNG_TIME_RFC1123_SUPPORTED)\n/* Utility to dump an unsigned value into a buffer, given a start pointer and\n * and end pointer (which should point just *beyond* the end of the buffer!)\n * Returns the pointer to the start of the formatted string.  This utility only\n * does unsigned values.\n */\nPNG_INTERNAL_FUNCTION(png_charp,png_format_number,(png_const_charp start,\n   png_charp end, int format, png_alloc_size_t number),PNG_EMPTY);\n\n/* Convenience macro that takes an array: */\n#define PNG_FORMAT_NUMBER(buffer,format,number) \\\n   png_format_number(buffer, buffer + (sizeof buffer), format, number)\n\n/* Suggested size for a number buffer (enough for 64 bits and a sign!) */\n#define PNG_NUMBER_BUFFER_SIZE 24\n\n/* These are the integer formats currently supported, the name is formed from\n * the standard printf(3) format string.\n */\n#define PNG_NUMBER_FORMAT_u     1 /* chose unsigned API! */\n#define PNG_NUMBER_FORMAT_02u   2\n#define PNG_NUMBER_FORMAT_d     1 /* chose signed API! */\n#define PNG_NUMBER_FORMAT_02d   2\n#define PNG_NUMBER_FORMAT_x     3\n#define PNG_NUMBER_FORMAT_02x   4\n#define PNG_NUMBER_FORMAT_fixed 5 /* choose the signed API */\n#endif\n\n#ifdef PNG_WARNINGS_SUPPORTED\n/* New defines and members adding in libpng-1.5.4 */\n#  define PNG_WARNING_PARAMETER_SIZE 32\n#  define PNG_WARNING_PARAMETER_COUNT 8 /* Maximum 9; see pngerror.c */\n\n/* An l-value of this type has to be passed to the APIs below to cache the\n * values of the parameters to a formatted warning message.\n */\ntypedef char png_warning_parameters[PNG_WARNING_PARAMETER_COUNT][\n   PNG_WARNING_PARAMETER_SIZE];\n\nPNG_INTERNAL_FUNCTION(void,png_warning_parameter,(png_warning_parameters p,\n   int number, png_const_charp string),PNG_EMPTY);\n   /* Parameters are limited in size to PNG_WARNING_PARAMETER_SIZE characters,\n    * including the trailing '\\0'.\n    */\nPNG_INTERNAL_FUNCTION(void,png_warning_parameter_unsigned,\n   (png_warning_parameters p, int number, int format, png_alloc_size_t value),\n   PNG_EMPTY);\n   /* Use png_alloc_size_t because it is an unsigned type as big as any we\n    * need to output.  Use the following for a signed value.\n    */\nPNG_INTERNAL_FUNCTION(void,png_warning_parameter_signed,\n   (png_warning_parameters p, int number, int format, png_int_32 value),\n   PNG_EMPTY);\n\nPNG_INTERNAL_FUNCTION(void,png_formatted_warning,(png_const_structrp png_ptr,\n   png_warning_parameters p, png_const_charp message),PNG_EMPTY);\n   /* 'message' follows the X/Open approach of using @1, @2 to insert\n    * parameters previously supplied using the above functions.  Errors in\n    * specifying the parameters will simply result in garbage substitutions.\n    */\n#endif\n\n#ifdef PNG_BENIGN_ERRORS_SUPPORTED\n/* Application errors (new in 1.6); use these functions (declared below) for\n * errors in the parameters or order of API function calls on read.  The\n * 'warning' should be used for an error that can be handled completely; the\n * 'error' for one which can be handled safely but which may lose application\n * information or settings.\n *\n * By default these both result in a png_error call prior to release, while in a\n * released version the 'warning' is just a warning.  However if the application\n * explicitly disables benign errors (explicitly permitting the code to lose\n * information) they both turn into warnings.\n *\n * If benign errors aren't supported they end up as the corresponding base call\n * (png_warning or png_error.)\n */\nPNG_INTERNAL_FUNCTION(void,png_app_warning,(png_const_structrp png_ptr,\n   png_const_charp message),PNG_EMPTY);\n   /* The application provided invalid parameters to an API function or called\n    * an API function at the wrong time, libpng can completely recover.\n    */\n\nPNG_INTERNAL_FUNCTION(void,png_app_error,(png_const_structrp png_ptr,\n   png_const_charp message),PNG_EMPTY);\n   /* As above but libpng will ignore the call, or attempt some other partial\n    * recovery from the error.\n    */\n#else\n#  define png_app_warning(pp,s) png_warning(pp,s)\n#  define png_app_error(pp,s) png_error(pp,s)\n#endif\n\nPNG_INTERNAL_FUNCTION(void,png_chunk_report,(png_const_structrp png_ptr,\n   png_const_charp message, int error),PNG_EMPTY);\n   /* Report a recoverable issue in chunk data.  On read this is used to report\n    * a problem found while reading a particular chunk and the\n    * png_chunk_benign_error or png_chunk_warning function is used as\n    * appropriate.  On write this is used to report an error that comes from\n    * data set via an application call to a png_set_ API and png_app_error or\n    * png_app_warning is used as appropriate.\n    *\n    * The 'error' parameter must have one of the following values:\n    */\n#define PNG_CHUNK_WARNING     0 /* never an error */\n#define PNG_CHUNK_WRITE_ERROR 1 /* an error only on write */\n#define PNG_CHUNK_ERROR       2 /* always an error */\n\n/* ASCII to FP interfaces, currently only implemented if sCAL\n * support is required.\n */\n#if defined(PNG_sCAL_SUPPORTED)\n/* MAX_DIGITS is actually the maximum number of characters in an sCAL\n * width or height, derived from the precision (number of significant\n * digits - a build time settable option) and assumptions about the\n * maximum ridiculous exponent.\n */\n#define PNG_sCAL_MAX_DIGITS (PNG_sCAL_PRECISION+1/*.*/+1/*E*/+10/*exponent*/)\n\n#ifdef PNG_FLOATING_POINT_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_ascii_from_fp,(png_const_structrp png_ptr,\n   png_charp ascii, png_size_t size, double fp, unsigned int precision),\n   PNG_EMPTY);\n#endif /* FLOATING_POINT */\n\n#ifdef PNG_FIXED_POINT_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_ascii_from_fixed,(png_const_structrp png_ptr,\n   png_charp ascii, png_size_t size, png_fixed_point fp),PNG_EMPTY);\n#endif /* FIXED_POINT */\n#endif /* sCAL */\n\n#if defined(PNG_sCAL_SUPPORTED) || defined(PNG_pCAL_SUPPORTED)\n/* An internal API to validate the format of a floating point number.\n * The result is the index of the next character.  If the number is\n * not valid it will be the index of a character in the supposed number.\n *\n * The format of a number is defined in the PNG extensions specification\n * and this API is strictly conformant to that spec, not anyone elses!\n *\n * The format as a regular expression is:\n *\n * [+-]?[0-9]+.?([Ee][+-]?[0-9]+)?\n *\n * or:\n *\n * [+-]?.[0-9]+(.[0-9]+)?([Ee][+-]?[0-9]+)?\n *\n * The complexity is that either integer or fraction must be present and the\n * fraction is permitted to have no digits only if the integer is present.\n *\n * NOTE: The dangling E problem.\n *   There is a PNG valid floating point number in the following:\n *\n *       PNG floating point numbers are not greedy.\n *\n *   Working this out requires *TWO* character lookahead (because of the\n *   sign), the parser does not do this - it will fail at the 'r' - this\n *   doesn't matter for PNG sCAL chunk values, but it requires more care\n *   if the value were ever to be embedded in something more complex.  Use\n *   ANSI-C strtod if you need the lookahead.\n */\n/* State table for the parser. */\n#define PNG_FP_INTEGER    0  /* before or in integer */\n#define PNG_FP_FRACTION   1  /* before or in fraction */\n#define PNG_FP_EXPONENT   2  /* before or in exponent */\n#define PNG_FP_STATE      3  /* mask for the above */\n#define PNG_FP_SAW_SIGN   4  /* Saw +/- in current state */\n#define PNG_FP_SAW_DIGIT  8  /* Saw a digit in current state */\n#define PNG_FP_SAW_DOT   16  /* Saw a dot in current state */\n#define PNG_FP_SAW_E     32  /* Saw an E (or e) in current state */\n#define PNG_FP_SAW_ANY   60  /* Saw any of the above 4 */\n\n/* These three values don't affect the parser.  They are set but not used.\n */\n#define PNG_FP_WAS_VALID 64  /* Preceding substring is a valid fp number */\n#define PNG_FP_NEGATIVE 128  /* A negative number, including \"-0\" */\n#define PNG_FP_NONZERO  256  /* A non-zero value */\n#define PNG_FP_STICKY   448  /* The above three flags */\n\n/* This is available for the caller to store in 'state' if required.  Do not\n * call the parser after setting it (the parser sometimes clears it.)\n */\n#define PNG_FP_INVALID  512  /* Available for callers as a distinct value */\n\n/* Result codes for the parser (boolean - true meants ok, false means\n * not ok yet.)\n */\n#define PNG_FP_MAYBE      0  /* The number may be valid in the future */\n#define PNG_FP_OK         1  /* The number is valid */\n\n/* Tests on the sticky non-zero and negative flags.  To pass these checks\n * the state must also indicate that the whole number is valid - this is\n * achieved by testing PNG_FP_SAW_DIGIT (see the implementation for why this\n * is equivalent to PNG_FP_OK above.)\n */\n#define PNG_FP_NZ_MASK (PNG_FP_SAW_DIGIT | PNG_FP_NEGATIVE | PNG_FP_NONZERO)\n   /* NZ_MASK: the string is valid and a non-zero negative value */\n#define PNG_FP_Z_MASK (PNG_FP_SAW_DIGIT | PNG_FP_NONZERO)\n   /* Z MASK: the string is valid and a non-zero value. */\n   /* PNG_FP_SAW_DIGIT: the string is valid. */\n#define PNG_FP_IS_ZERO(state) (((state) & PNG_FP_Z_MASK) == PNG_FP_SAW_DIGIT)\n#define PNG_FP_IS_POSITIVE(state) (((state) & PNG_FP_NZ_MASK) == PNG_FP_Z_MASK)\n#define PNG_FP_IS_NEGATIVE(state) (((state) & PNG_FP_NZ_MASK) == PNG_FP_NZ_MASK)\n\n/* The actual parser.  This can be called repeatedly. It updates\n * the index into the string and the state variable (which must\n * be initialized to 0).  It returns a result code, as above.  There\n * is no point calling the parser any more if it fails to advance to\n * the end of the string - it is stuck on an invalid character (or\n * terminated by '\\0').\n *\n * Note that the pointer will consume an E or even an E+ and then leave\n * a 'maybe' state even though a preceding integer.fraction is valid.\n * The PNG_FP_WAS_VALID flag indicates that a preceding substring was\n * a valid number.  It's possible to recover from this by calling\n * the parser again (from the start, with state 0) but with a string\n * that omits the last character (i.e. set the size to the index of\n * the problem character.)  This has not been tested within libpng.\n */\nPNG_INTERNAL_FUNCTION(int,png_check_fp_number,(png_const_charp string,\n   png_size_t size, int *statep, png_size_tp whereami),PNG_EMPTY);\n\n/* This is the same but it checks a complete string and returns true\n * only if it just contains a floating point number.  As of 1.5.4 this\n * function also returns the state at the end of parsing the number if\n * it was valid (otherwise it returns 0.)  This can be used for testing\n * for negative or zero values using the sticky flag.\n */\nPNG_INTERNAL_FUNCTION(int,png_check_fp_string,(png_const_charp string,\n   png_size_t size),PNG_EMPTY);\n#endif /* pCAL || sCAL */\n\n#if defined(PNG_GAMMA_SUPPORTED) ||\\\n    defined(PNG_INCH_CONVERSIONS_SUPPORTED) || defined(PNG_READ_pHYs_SUPPORTED)\n/* Added at libpng version 1.5.0 */\n/* This is a utility to provide a*times/div (rounded) and indicate\n * if there is an overflow.  The result is a boolean - false (0)\n * for overflow, true (1) if no overflow, in which case *res\n * holds the result.\n */\nPNG_INTERNAL_FUNCTION(int,png_muldiv,(png_fixed_point_p res, png_fixed_point a,\n   png_int_32 multiplied_by, png_int_32 divided_by),PNG_EMPTY);\n#endif\n\n#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_INCH_CONVERSIONS_SUPPORTED)\n/* Same deal, but issue a warning on overflow and return 0. */\nPNG_INTERNAL_FUNCTION(png_fixed_point,png_muldiv_warn,\n   (png_const_structrp png_ptr, png_fixed_point a, png_int_32 multiplied_by,\n   png_int_32 divided_by),PNG_EMPTY);\n#endif\n\n#ifdef PNG_GAMMA_SUPPORTED\n/* Calculate a reciprocal - used for gamma values.  This returns\n * 0 if the argument is 0 in order to maintain an undefined value;\n * there are no warnings.\n */\nPNG_INTERNAL_FUNCTION(png_fixed_point,png_reciprocal,(png_fixed_point a),\n   PNG_EMPTY);\n\n#ifdef PNG_READ_GAMMA_SUPPORTED\n/* The same but gives a reciprocal of the product of two fixed point\n * values.  Accuracy is suitable for gamma calculations but this is\n * not exact - use png_muldiv for that.  Only required at present on read.\n */\nPNG_INTERNAL_FUNCTION(png_fixed_point,png_reciprocal2,(png_fixed_point a,\n   png_fixed_point b),PNG_EMPTY);\n#endif\n\n/* Return true if the gamma value is significantly different from 1.0 */\nPNG_INTERNAL_FUNCTION(int,png_gamma_significant,(png_fixed_point gamma_value),\n   PNG_EMPTY);\n#endif\n\n#ifdef PNG_READ_GAMMA_SUPPORTED\n/* Internal fixed point gamma correction.  These APIs are called as\n * required to convert single values - they don't need to be fast,\n * they are not used when processing image pixel values.\n *\n * While the input is an 'unsigned' value it must actually be the\n * correct bit value - 0..255 or 0..65535 as required.\n */\nPNG_INTERNAL_FUNCTION(png_uint_16,png_gamma_correct,(png_structrp png_ptr,\n   unsigned int value, png_fixed_point gamma_value),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(png_uint_16,png_gamma_16bit_correct,(unsigned int value,\n   png_fixed_point gamma_value),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(png_byte,png_gamma_8bit_correct,(unsigned int value,\n   png_fixed_point gamma_value),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_destroy_gamma_table,(png_structrp png_ptr),\n   PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_build_gamma_table,(png_structrp png_ptr,\n   int bit_depth),PNG_EMPTY);\n#endif\n\n/* SIMPLIFIED READ/WRITE SUPPORT */\n#if defined(PNG_SIMPLIFIED_READ_SUPPORTED) ||\\\n   defined(PNG_SIMPLIFIED_WRITE_SUPPORTED)\n/* The internal structure that png_image::opaque points to. */\ntypedef struct png_control\n{\n   png_structp png_ptr;\n   png_infop   info_ptr;\n   png_voidp   error_buf;           /* Always a jmp_buf at present. */\n\n   png_const_bytep memory;          /* Memory buffer. */\n   png_size_t      size;            /* Size of the memory buffer. */\n\n   unsigned int for_write       :1; /* Otherwise it is a read structure */\n   unsigned int owned_file      :1; /* We own the file in io_ptr */\n} png_control;\n\n/* Return the pointer to the jmp_buf from a png_control: necessary because C\n * does not reveal the type of the elements of jmp_buf.\n */\n#ifdef __cplusplus\n#  define png_control_jmp_buf(pc) (((jmp_buf*)((pc)->error_buf))[0])\n#else\n#  define png_control_jmp_buf(pc) ((pc)->error_buf)\n#endif\n\n/* Utility to safely execute a piece of libpng code catching and logging any\n * errors that might occur.  Returns true on success, false on failure (either\n * of the function or as a result of a png_error.)\n */\nPNG_INTERNAL_CALLBACK(void,png_safe_error,(png_structp png_ptr,\n   png_const_charp error_message),PNG_NORETURN);\n\n#ifdef PNG_WARNINGS_SUPPORTED\nPNG_INTERNAL_CALLBACK(void,png_safe_warning,(png_structp png_ptr,\n   png_const_charp warning_message),PNG_EMPTY);\n#else\n#  define png_safe_warning 0/*dummy argument*/\n#endif\n\nPNG_INTERNAL_FUNCTION(int,png_safe_execute,(png_imagep image,\n   int (*function)(png_voidp), png_voidp arg),PNG_EMPTY);\n\n/* Utility to log an error; this also cleans up the png_image; the function\n * always returns 0 (false).\n */\nPNG_INTERNAL_FUNCTION(int,png_image_error,(png_imagep image,\n   png_const_charp error_message),PNG_EMPTY);\n\n#ifndef PNG_SIMPLIFIED_READ_SUPPORTED\n/* png_image_free is used by the write code but not exported */\nPNG_INTERNAL_FUNCTION(void, png_image_free, (png_imagep image), PNG_EMPTY);\n#endif /* !SIMPLIFIED_READ */\n\n#endif /* SIMPLIFIED READ/WRITE */\n\n/* These are initialization functions for hardware specific PNG filter\n * optimizations; list these here then select the appropriate one at compile\n * time using the macro PNG_FILTER_OPTIMIZATIONS.  If the macro is not defined\n * the generic code is used.\n */\n#ifdef PNG_FILTER_OPTIMIZATIONS\nPNG_INTERNAL_FUNCTION(void, PNG_FILTER_OPTIMIZATIONS, (png_structp png_ptr,\n   unsigned int bpp), PNG_EMPTY);\n   /* Just declare the optimization that will be used */\n#else\n   /* List *all* the possible optimizations here - this branch is required if\n    * the builder of libpng passes the definition of PNG_FILTER_OPTIMIZATIONS in\n    * CFLAGS in place of CPPFLAGS *and* uses symbol prefixing.\n    */\nPNG_INTERNAL_FUNCTION(void, png_init_filter_functions_neon,\n   (png_structp png_ptr, unsigned int bpp), PNG_EMPTY);\n#endif\n\n/* Maintainer: Put new private prototypes here ^ */\n\n#include \"pngdebug.h\"\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* PNG_VERSION_INFO_ONLY */\n#endif /* PNGPRIV_H */\n"
  },
  {
    "path": "Libraries/Core/Android/Headers/png/pngstruct.h",
    "content": "\n/* pngstruct.h - header file for PNG reference library\n *\n * Copyright (c) 1998-2013 Glenn Randers-Pehrson\n * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)\n * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)\n *\n * Last changed in libpng 1.6.1 [March 28, 2013]\n *\n * This code is released under the libpng license.\n * For conditions of distribution and use, see the disclaimer\n * and license in png.h\n */\n\n/* The structure that holds the information to read and write PNG files.\n * The only people who need to care about what is inside of this are the\n * people who will be modifying the library for their own special needs.\n * It should NOT be accessed directly by an application.\n */\n\n#ifndef PNGSTRUCT_H\n#define PNGSTRUCT_H\n/* zlib.h defines the structure z_stream, an instance of which is included\n * in this structure and is required for decompressing the LZ compressed\n * data in PNG files.\n */\n#ifndef ZLIB_CONST\n   /* We must ensure that zlib uses 'const' in declarations. */\n#  define ZLIB_CONST\n#endif\n#include \"zlib.h\"\n#ifdef const\n   /* zlib.h sometimes #defines const to nothing, undo this. */\n#  undef const\n#endif\n\n/* zlib.h has mediocre z_const use before 1.2.6, this stuff is for compatibility\n * with older builds.\n */\n#if ZLIB_VERNUM < 0x1260\n#  define PNGZ_MSG_CAST(s) png_constcast(char*,s)\n#  define PNGZ_INPUT_CAST(b) png_constcast(png_bytep,b)\n#else\n#  define PNGZ_MSG_CAST(s) (s)\n#  define PNGZ_INPUT_CAST(b) (b)\n#endif\n\n/* zlib.h declares a magic type 'uInt' that limits the amount of data that zlib\n * can handle at once.  This type need be no larger than 16 bits (so maximum of\n * 65535), this define allows us to discover how big it is, but limited by the\n * maximuum for png_size_t.  The value can be overriden in a library build\n * (pngusr.h, or set it in CPPFLAGS) and it works to set it to a considerably\n * lower value (e.g. 255 works).  A lower value may help memory usage (slightly)\n * and may even improve performance on some systems (and degrade it on others.)\n */\n#ifndef ZLIB_IO_MAX\n#  define ZLIB_IO_MAX ((uInt)-1)\n#endif\n\n#ifdef PNG_WRITE_SUPPORTED\n/* The type of a compression buffer list used by the write code. */\ntypedef struct png_compression_buffer\n{\n   struct png_compression_buffer *next;\n   png_byte                       output[1]; /* actually zbuf_size */\n} png_compression_buffer, *png_compression_bufferp;\n\n#define PNG_COMPRESSION_BUFFER_SIZE(pp)\\\n   (offsetof(png_compression_buffer, output) + (pp)->zbuffer_size)\n#endif\n\n/* Colorspace support; structures used in png_struct, png_info and in internal\n * functions to hold and communicate information about the color space.\n *\n * PNG_COLORSPACE_SUPPORTED is only required if the application will perform\n * colorspace corrections, otherwise all the colorspace information can be\n * skipped and the size of libpng can be reduced (significantly) by compiling\n * out the colorspace support.\n */\n#ifdef PNG_COLORSPACE_SUPPORTED\n/* The chromaticities of the red, green and blue colorants and the chromaticity\n * of the corresponding white point (i.e. of rgb(1.0,1.0,1.0)).\n */\ntypedef struct png_xy\n{\n   png_fixed_point redx, redy;\n   png_fixed_point greenx, greeny;\n   png_fixed_point bluex, bluey;\n   png_fixed_point whitex, whitey;\n} png_xy;\n\n/* The same data as above but encoded as CIE XYZ values.  When this data comes\n * from chromaticities the sum of the Y values is assumed to be 1.0\n */\ntypedef struct png_XYZ\n{\n   png_fixed_point red_X, red_Y, red_Z;\n   png_fixed_point green_X, green_Y, green_Z;\n   png_fixed_point blue_X, blue_Y, blue_Z;\n} png_XYZ;\n#endif /* COLORSPACE */\n\n#if defined(PNG_COLORSPACE_SUPPORTED) || defined(PNG_GAMMA_SUPPORTED)\n/* A colorspace is all the above plus, potentially, profile information,\n * however at present libpng does not use the profile internally so it is only\n * stored in the png_info struct (if iCCP is supported.)  The rendering intent\n * is retained here and is checked.\n *\n * The file gamma encoding information is also stored here and gamma correction\n * is done by libpng, whereas color correction must currently be done by the\n * application.\n */\ntypedef struct png_colorspace\n{\n#ifdef PNG_GAMMA_SUPPORTED\n   png_fixed_point gamma;        /* File gamma */\n#endif\n\n#ifdef PNG_COLORSPACE_SUPPORTED\n   png_xy      end_points_xy;    /* End points as chromaticities */\n   png_XYZ     end_points_XYZ;   /* End points as CIE XYZ colorant values */\n   png_uint_16 rendering_intent; /* Rendering intent of a profile */\n#endif\n\n   /* Flags are always defined to simplify the code. */\n   png_uint_16 flags;            /* As defined below */\n} png_colorspace, * PNG_RESTRICT png_colorspacerp;\n\ntypedef const png_colorspace * PNG_RESTRICT png_const_colorspacerp;\n\n/* General flags for the 'flags' field */\n#define PNG_COLORSPACE_HAVE_GAMMA           0x0001\n#define PNG_COLORSPACE_HAVE_ENDPOINTS       0x0002\n#define PNG_COLORSPACE_HAVE_INTENT          0x0004\n#define PNG_COLORSPACE_FROM_gAMA            0x0008\n#define PNG_COLORSPACE_FROM_cHRM            0x0010\n#define PNG_COLORSPACE_FROM_sRGB            0x0020\n#define PNG_COLORSPACE_ENDPOINTS_MATCH_sRGB 0x0040\n#define PNG_COLORSPACE_MATCHES_sRGB         0x0080 /* exact match on profile */\n#define PNG_COLORSPACE_INVALID              0x8000\n#define PNG_COLORSPACE_CANCEL(flags)        (0xffff ^ (flags))\n#endif /* COLORSPACE || GAMMA */\n\nstruct png_struct_def\n{\n#ifdef PNG_SETJMP_SUPPORTED\n   jmp_buf jmp_buf_local;     /* New name in 1.6.0 for jmp_buf in png_struct */\n   png_longjmp_ptr longjmp_fn;/* setjmp non-local goto function. */\n   jmp_buf *jmp_buf_ptr;      /* passed to longjmp_fn */\n   size_t jmp_buf_size;       /* size of the above, if allocated */\n#endif\n   png_error_ptr error_fn;    /* function for printing errors and aborting */\n#ifdef PNG_WARNINGS_SUPPORTED\n   png_error_ptr warning_fn;  /* function for printing warnings */\n#endif\n   png_voidp error_ptr;       /* user supplied struct for error functions */\n   png_rw_ptr write_data_fn;  /* function for writing output data */\n   png_rw_ptr read_data_fn;   /* function for reading input data */\n   png_voidp io_ptr;          /* ptr to application struct for I/O functions */\n\n#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED\n   png_user_transform_ptr read_user_transform_fn; /* user read transform */\n#endif\n\n#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED\n   png_user_transform_ptr write_user_transform_fn; /* user write transform */\n#endif\n\n/* These were added in libpng-1.0.2 */\n#ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED\n#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \\\n    defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)\n   png_voidp user_transform_ptr; /* user supplied struct for user transform */\n   png_byte user_transform_depth;    /* bit depth of user transformed pixels */\n   png_byte user_transform_channels; /* channels in user transformed pixels */\n#endif\n#endif\n\n   png_uint_32 mode;          /* tells us where we are in the PNG file */\n   png_uint_32 flags;         /* flags indicating various things to libpng */\n   png_uint_32 transformations; /* which transformations to perform */\n\n   png_uint_32 zowner;        /* ID (chunk type) of zstream owner, 0 if none */\n   z_stream    zstream;       /* decompression structure */\n\n#ifdef PNG_WRITE_SUPPORTED\n   png_compression_bufferp zbuffer_list; /* Created on demand during write */\n   uInt                    zbuffer_size; /* size of the actual buffer */\n\n   int zlib_level;            /* holds zlib compression level */\n   int zlib_method;           /* holds zlib compression method */\n   int zlib_window_bits;      /* holds zlib compression window bits */\n   int zlib_mem_level;        /* holds zlib compression memory level */\n   int zlib_strategy;         /* holds zlib compression strategy */\n#endif\n/* Added at libpng 1.5.4 */\n#ifdef PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED\n   int zlib_text_level;            /* holds zlib compression level */\n   int zlib_text_method;           /* holds zlib compression method */\n   int zlib_text_window_bits;      /* holds zlib compression window bits */\n   int zlib_text_mem_level;        /* holds zlib compression memory level */\n   int zlib_text_strategy;         /* holds zlib compression strategy */\n#endif\n/* End of material added at libpng 1.5.4 */\n/* Added at libpng 1.6.0 */\n#ifdef PNG_WRITE_SUPPORTED\n   int zlib_set_level;        /* Actual values set into the zstream on write */\n   int zlib_set_method;\n   int zlib_set_window_bits;\n   int zlib_set_mem_level;\n   int zlib_set_strategy;\n#endif\n\n   png_uint_32 width;         /* width of image in pixels */\n   png_uint_32 height;        /* height of image in pixels */\n   png_uint_32 num_rows;      /* number of rows in current pass */\n   png_uint_32 usr_width;     /* width of row at start of write */\n   png_size_t rowbytes;       /* size of row in bytes */\n   png_uint_32 iwidth;        /* width of current interlaced row in pixels */\n   png_uint_32 row_number;    /* current row in interlace pass */\n   png_uint_32 chunk_name;    /* PNG_CHUNK() id of current chunk */\n   png_bytep prev_row;        /* buffer to save previous (unfiltered) row.\n                               * This is a pointer into big_prev_row\n                               */\n   png_bytep row_buf;         /* buffer to save current (unfiltered) row.\n                               * This is a pointer into big_row_buf\n                               */\n#ifdef PNG_WRITE_SUPPORTED\n   png_bytep sub_row;         /* buffer to save \"sub\" row when filtering */\n   png_bytep up_row;          /* buffer to save \"up\" row when filtering */\n   png_bytep avg_row;         /* buffer to save \"avg\" row when filtering */\n   png_bytep paeth_row;       /* buffer to save \"Paeth\" row when filtering */\n#endif\n   png_size_t info_rowbytes;  /* Added in 1.5.4: cache of updated row bytes */\n\n   png_uint_32 idat_size;     /* current IDAT size for read */\n   png_uint_32 crc;           /* current chunk CRC value */\n   png_colorp palette;        /* palette from the input file */\n   png_uint_16 num_palette;   /* number of color entries in palette */\n\n/* Added at libpng-1.5.10 */\n#ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED\n   int num_palette_max;       /* maximum palette index found in IDAT */\n#endif\n\n   png_uint_16 num_trans;     /* number of transparency values */\n   png_byte compression;      /* file compression type (always 0) */\n   png_byte filter;           /* file filter type (always 0) */\n   png_byte interlaced;       /* PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */\n   png_byte pass;             /* current interlace pass (0 - 6) */\n   png_byte do_filter;        /* row filter flags (see PNG_FILTER_ below ) */\n   png_byte color_type;       /* color type of file */\n   png_byte bit_depth;        /* bit depth of file */\n   png_byte usr_bit_depth;    /* bit depth of users row: write only */\n   png_byte pixel_depth;      /* number of bits per pixel */\n   png_byte channels;         /* number of channels in file */\n#ifdef PNG_WRITE_SUPPORTED\n   png_byte usr_channels;     /* channels at start of write: write only */\n#endif\n   png_byte sig_bytes;        /* magic bytes read/written from start of file */\n   png_byte maximum_pixel_depth;\n                              /* pixel depth used for the row buffers */\n   png_byte transformed_pixel_depth;\n                              /* pixel depth after read/write transforms */\n#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED)\n   png_uint_16 filler;           /* filler bytes for pixel expansion */\n#endif\n\n#if defined(PNG_bKGD_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) ||\\\n   defined(PNG_READ_ALPHA_MODE_SUPPORTED)\n   png_byte background_gamma_type;\n   png_fixed_point background_gamma;\n   png_color_16 background;   /* background color in screen gamma space */\n#ifdef PNG_READ_GAMMA_SUPPORTED\n   png_color_16 background_1; /* background normalized to gamma 1.0 */\n#endif\n#endif /* PNG_bKGD_SUPPORTED */\n\n#ifdef PNG_WRITE_FLUSH_SUPPORTED\n   png_flush_ptr output_flush_fn; /* Function for flushing output */\n   png_uint_32 flush_dist;    /* how many rows apart to flush, 0 - no flush */\n   png_uint_32 flush_rows;    /* number of rows written since last flush */\n#endif\n\n#ifdef PNG_READ_GAMMA_SUPPORTED\n   int gamma_shift;      /* number of \"insignificant\" bits in 16-bit gamma */\n   png_fixed_point screen_gamma; /* screen gamma value (display_exponent) */\n\n   png_bytep gamma_table;     /* gamma table for 8-bit depth files */\n   png_uint_16pp gamma_16_table; /* gamma table for 16-bit depth files */\n#if defined(PNG_READ_BACKGROUND_SUPPORTED) || \\\n   defined(PNG_READ_ALPHA_MODE_SUPPORTED) || \\\n   defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)\n   png_bytep gamma_from_1;    /* converts from 1.0 to screen */\n   png_bytep gamma_to_1;      /* converts from file to 1.0 */\n   png_uint_16pp gamma_16_from_1; /* converts from 1.0 to screen */\n   png_uint_16pp gamma_16_to_1; /* converts from file to 1.0 */\n#endif /* READ_BACKGROUND || READ_ALPHA_MODE || RGB_TO_GRAY */\n#endif\n\n#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_sBIT_SUPPORTED)\n   png_color_8 sig_bit;       /* significant bits in each available channel */\n#endif\n\n#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED)\n   png_color_8 shift;         /* shift for significant bit tranformation */\n#endif\n\n#if defined(PNG_tRNS_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) \\\n || defined(PNG_READ_EXPAND_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)\n   png_bytep trans_alpha;           /* alpha values for paletted files */\n   png_color_16 trans_color;  /* transparent color for non-paletted files */\n#endif\n\n   png_read_status_ptr read_row_fn;   /* called after each row is decoded */\n   png_write_status_ptr write_row_fn; /* called after each row is encoded */\n#ifdef PNG_PROGRESSIVE_READ_SUPPORTED\n   png_progressive_info_ptr info_fn; /* called after header data fully read */\n   png_progressive_row_ptr row_fn;   /* called after a prog. row is decoded */\n   png_progressive_end_ptr end_fn;   /* called after image is complete */\n   png_bytep save_buffer_ptr;        /* current location in save_buffer */\n   png_bytep save_buffer;            /* buffer for previously read data */\n   png_bytep current_buffer_ptr;     /* current location in current_buffer */\n   png_bytep current_buffer;         /* buffer for recently used data */\n   png_uint_32 push_length;          /* size of current input chunk */\n   png_uint_32 skip_length;          /* bytes to skip in input data */\n   png_size_t save_buffer_size;      /* amount of data now in save_buffer */\n   png_size_t save_buffer_max;       /* total size of save_buffer */\n   png_size_t buffer_size;           /* total amount of available input data */\n   png_size_t current_buffer_size;   /* amount of data now in current_buffer */\n   int process_mode;                 /* what push library is currently doing */\n   int cur_palette;                  /* current push library palette index */\n\n#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */\n\n#if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__)\n/* For the Borland special 64K segment handler */\n   png_bytepp offset_table_ptr;\n   png_bytep offset_table;\n   png_uint_16 offset_table_number;\n   png_uint_16 offset_table_count;\n   png_uint_16 offset_table_count_free;\n#endif\n\n#ifdef PNG_READ_QUANTIZE_SUPPORTED\n   png_bytep palette_lookup; /* lookup table for quantizing */\n   png_bytep quantize_index; /* index translation for palette files */\n#endif\n\n#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED\n   png_byte heuristic_method;        /* heuristic for row filter selection */\n   png_byte num_prev_filters;        /* number of weights for previous rows */\n   png_bytep prev_filters;           /* filter type(s) of previous row(s) */\n   png_uint_16p filter_weights;      /* weight(s) for previous line(s) */\n   png_uint_16p inv_filter_weights;  /* 1/weight(s) for previous line(s) */\n   png_uint_16p filter_costs;        /* relative filter calculation cost */\n   png_uint_16p inv_filter_costs;    /* 1/relative filter calculation cost */\n#endif\n\n   /* Options */\n#ifdef PNG_SET_OPTION_SUPPORTED\n   png_byte options;           /* On/off state (up to 4 options) */\n#endif\n\n#if PNG_LIBPNG_VER < 10700\n/* To do: remove this from libpng-1.7 */\n#ifdef PNG_TIME_RFC1123_SUPPORTED\n   char time_buffer[29]; /* String to hold RFC 1123 time text */\n#endif\n#endif\n\n/* New members added in libpng-1.0.6 */\n\n   png_uint_32 free_me;    /* flags items libpng is responsible for freeing */\n\n#ifdef PNG_USER_CHUNKS_SUPPORTED\n   png_voidp user_chunk_ptr;\n#ifdef PNG_READ_USER_CHUNKS_SUPPORTED\n   png_user_chunk_ptr read_user_chunk_fn; /* user read chunk handler */\n#endif\n#endif\n\n#ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED\n   int          unknown_default; /* As PNG_HANDLE_* */\n   unsigned int num_chunk_list;  /* Number of entries in the list */\n   png_bytep    chunk_list;      /* List of png_byte[5]; the textual chunk name\n                                  * followed by a PNG_HANDLE_* byte */\n#endif\n\n/* New members added in libpng-1.0.3 */\n#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED\n   png_byte rgb_to_gray_status;\n   /* Added in libpng 1.5.5 to record setting of coefficients: */\n   png_byte rgb_to_gray_coefficients_set;\n   /* These were changed from png_byte in libpng-1.0.6 */\n   png_uint_16 rgb_to_gray_red_coeff;\n   png_uint_16 rgb_to_gray_green_coeff;\n   /* deleted in 1.5.5: rgb_to_gray_blue_coeff; */\n#endif\n\n/* New member added in libpng-1.0.4 (renamed in 1.0.9) */\n#if defined(PNG_MNG_FEATURES_SUPPORTED)\n/* Changed from png_byte to png_uint_32 at version 1.2.0 */\n   png_uint_32 mng_features_permitted;\n#endif\n\n/* New member added in libpng-1.0.9, ifdef'ed out in 1.0.12, enabled in 1.2.0 */\n#ifdef PNG_MNG_FEATURES_SUPPORTED\n   png_byte filter_type;\n#endif\n\n/* New members added in libpng-1.2.0 */\n\n/* New members added in libpng-1.0.2 but first enabled by default in 1.2.0 */\n#ifdef PNG_USER_MEM_SUPPORTED\n   png_voidp mem_ptr;             /* user supplied struct for mem functions */\n   png_malloc_ptr malloc_fn;      /* function for allocating memory */\n   png_free_ptr free_fn;          /* function for freeing memory */\n#endif\n\n/* New member added in libpng-1.0.13 and 1.2.0 */\n   png_bytep big_row_buf;         /* buffer to save current (unfiltered) row */\n\n#ifdef PNG_READ_QUANTIZE_SUPPORTED\n/* The following three members were added at version 1.0.14 and 1.2.4 */\n   png_bytep quantize_sort;          /* working sort array */\n   png_bytep index_to_palette;       /* where the original index currently is\n                                        in the palette */\n   png_bytep palette_to_index;       /* which original index points to this\n                                         palette color */\n#endif\n\n/* New members added in libpng-1.0.16 and 1.2.6 */\n   png_byte compression_type;\n\n#ifdef PNG_USER_LIMITS_SUPPORTED\n   png_uint_32 user_width_max;\n   png_uint_32 user_height_max;\n\n   /* Added in libpng-1.4.0: Total number of sPLT, text, and unknown\n    * chunks that can be stored (0 means unlimited).\n    */\n   png_uint_32 user_chunk_cache_max;\n\n   /* Total memory that a zTXt, sPLT, iTXt, iCCP, or unknown chunk\n    * can occupy when decompressed.  0 means unlimited.\n    */\n   png_alloc_size_t user_chunk_malloc_max;\n#endif\n\n/* New member added in libpng-1.0.25 and 1.2.17 */\n#ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED\n   /* Temporary storage for unknown chunk that the library doesn't recognize,\n    * used while reading the chunk.\n    */\n   png_unknown_chunk unknown_chunk;\n#endif\n\n/* New member added in libpng-1.2.26 */\n  png_size_t old_big_row_buf_size;\n\n#ifdef PNG_READ_SUPPORTED\n/* New member added in libpng-1.2.30 */\n  png_bytep        read_buffer;      /* buffer for reading chunk data */\n  png_alloc_size_t read_buffer_size; /* current size of the buffer */\n#endif\n#ifdef PNG_SEQUENTIAL_READ_SUPPORTED\n  uInt             IDAT_read_size;   /* limit on read buffer size for IDAT */\n#endif\n\n#ifdef PNG_IO_STATE_SUPPORTED\n/* New member added in libpng-1.4.0 */\n   png_uint_32 io_state;\n#endif\n\n/* New member added in libpng-1.5.6 */\n   png_bytep big_prev_row;\n\n/* New member added in libpng-1.5.7 */\n   void (*read_filter[PNG_FILTER_VALUE_LAST-1])(png_row_infop row_info,\n      png_bytep row, png_const_bytep prev_row);\n\n#ifdef PNG_READ_SUPPORTED\n#if defined(PNG_COLORSPACE_SUPPORTED) || defined(PNG_GAMMA_SUPPORTED)\n   png_colorspace   colorspace;\n#endif\n#endif\n};\n#endif /* PNGSTRUCT_H */\n"
  },
  {
    "path": "Libraries/Core/Android/Headers/rapidxml/rapidxml.hpp",
    "content": "#ifndef RAPIDXML_HPP_INCLUDED\r\n#define RAPIDXML_HPP_INCLUDED\r\n\r\n// Copyright (C) 2006, 2009 Marcin Kalicinski\r\n// Version 1.13\r\n// Revision $DateTime: 2009/05/13 01:46:17 $\r\n//! \\file rapidxml.hpp This file contains rapidxml parser and DOM implementation\r\n\r\n// If standard library is disabled, user must provide implementations of required functions and typedefs\r\n#if !defined(RAPIDXML_NO_STDLIB)\r\n    #include <cstdlib>      // For std::size_t\r\n    #include <cassert>      // For assert\r\n    #include <new>          // For placement new\r\n#endif\r\n\r\n// On MSVC, disable \"conditional expression is constant\" warning (level 4). \r\n// This warning is almost impossible to avoid with certain types of templated code\r\n#ifdef _MSC_VER\r\n    #pragma warning(push)\r\n    #pragma warning(disable:4127)   // Conditional expression is constant\r\n#endif\r\n\r\n///////////////////////////////////////////////////////////////////////////\r\n// RAPIDXML_PARSE_ERROR\r\n    \r\n#if defined(RAPIDXML_NO_EXCEPTIONS)\r\n\r\n#define RAPIDXML_PARSE_ERROR(what, where) { parse_error_handler(what, where); assert(0); }\r\n\r\nnamespace rapidxml\r\n{\r\n    //! When exceptions are disabled by defining RAPIDXML_NO_EXCEPTIONS, \r\n    //! this function is called to notify user about the error.\r\n    //! It must be defined by the user.\r\n    //! <br><br>\r\n    //! This function cannot return. If it does, the results are undefined.\r\n    //! <br><br>\r\n    //! A very simple definition might look like that:\r\n    //! <pre>\r\n    //! void %rapidxml::%parse_error_handler(const char *what, void *where)\r\n    //! {\r\n    //!     std::cout << \"Parse error: \" << what << \"\\n\";\r\n    //!     std::abort();\r\n    //! }\r\n    //! </pre>\r\n    //! \\param what Human readable description of the error.\r\n    //! \\param where Pointer to character data where error was detected.\r\n    void parse_error_handler(const char *what, void *where);\r\n}\r\n\r\n#else\r\n    \r\n#include <exception>    // For std::exception\r\n\r\n#define RAPIDXML_PARSE_ERROR(what, where) throw parse_error(what, where)\r\n\r\nnamespace rapidxml\r\n{\r\n\r\n    //! Parse error exception. \r\n    //! This exception is thrown by the parser when an error occurs. \r\n    //! Use what() function to get human-readable error message. \r\n    //! Use where() function to get a pointer to position within source text where error was detected.\r\n    //! <br><br>\r\n    //! If throwing exceptions by the parser is undesirable, \r\n    //! it can be disabled by defining RAPIDXML_NO_EXCEPTIONS macro before rapidxml.hpp is included.\r\n    //! This will cause the parser to call rapidxml::parse_error_handler() function instead of throwing an exception.\r\n    //! This function must be defined by the user.\r\n    //! <br><br>\r\n    //! This class derives from <code>std::exception</code> class.\r\n    class parse_error: public std::exception\r\n    {\r\n    \r\n    public:\r\n    \r\n        //! Constructs parse error\r\n        parse_error(const char *what, void *where)\r\n            : m_what(what)\r\n            , m_where(where)\r\n        {\r\n        }\r\n\r\n        //! Gets human readable description of error.\r\n        //! \\return Pointer to null terminated description of the error.\r\n        virtual const char *what() const throw()\r\n        {\r\n            return m_what;\r\n        }\r\n\r\n        //! Gets pointer to character data where error happened.\r\n        //! Ch should be the same as char type of xml_document that produced the error.\r\n        //! \\return Pointer to location within the parsed string where error occured.\r\n        template<class Ch>\r\n        Ch *where() const\r\n        {\r\n            return reinterpret_cast<Ch *>(m_where);\r\n        }\r\n\r\n    private:  \r\n\r\n        const char *m_what;\r\n        void *m_where;\r\n\r\n    };\r\n}\r\n\r\n#endif\r\n\r\n///////////////////////////////////////////////////////////////////////////\r\n// Pool sizes\r\n\r\n#ifndef RAPIDXML_STATIC_POOL_SIZE\r\n    // Size of static memory block of memory_pool.\r\n    // Define RAPIDXML_STATIC_POOL_SIZE before including rapidxml.hpp if you want to override the default value.\r\n    // No dynamic memory allocations are performed by memory_pool until static memory is exhausted.\r\n    #define RAPIDXML_STATIC_POOL_SIZE (64 * 1024)\r\n#endif\r\n\r\n#ifndef RAPIDXML_DYNAMIC_POOL_SIZE\r\n    // Size of dynamic memory block of memory_pool.\r\n    // Define RAPIDXML_DYNAMIC_POOL_SIZE before including rapidxml.hpp if you want to override the default value.\r\n    // After the static block is exhausted, dynamic blocks with approximately this size are allocated by memory_pool.\r\n    #define RAPIDXML_DYNAMIC_POOL_SIZE (64 * 1024)\r\n#endif\r\n\r\n#ifndef RAPIDXML_ALIGNMENT\r\n    // Memory allocation alignment.\r\n    // Define RAPIDXML_ALIGNMENT before including rapidxml.hpp if you want to override the default value, which is the size of pointer.\r\n    // All memory allocations for nodes, attributes and strings will be aligned to this value.\r\n    // This must be a power of 2 and at least 1, otherwise memory_pool will not work.\r\n    #define RAPIDXML_ALIGNMENT sizeof(void *)\r\n#endif\r\n\r\nnamespace rapidxml\r\n{\r\n    // Forward declarations\r\n    template<class Ch> class xml_node;\r\n    template<class Ch> class xml_attribute;\r\n    template<class Ch> class xml_document;\r\n    \r\n    //! Enumeration listing all node types produced by the parser.\r\n    //! Use xml_node::type() function to query node type.\r\n    enum node_type\r\n    {\r\n        node_document,      //!< A document node. Name and value are empty.\r\n        node_element,       //!< An element node. Name contains element name. Value contains text of first data node.\r\n        node_data,          //!< A data node. Name is empty. Value contains data text.\r\n        node_cdata,         //!< A CDATA node. Name is empty. Value contains data text.\r\n        node_comment,       //!< A comment node. Name is empty. Value contains comment text.\r\n        node_declaration,   //!< A declaration node. Name and value are empty. Declaration parameters (version, encoding and standalone) are in node attributes.\r\n        node_doctype,       //!< A DOCTYPE node. Name is empty. Value contains DOCTYPE text.\r\n        node_pi             //!< A PI node. Name contains target. Value contains instructions.\r\n    };\r\n\r\n    ///////////////////////////////////////////////////////////////////////\r\n    // Parsing flags\r\n\r\n    //! Parse flag instructing the parser to not create data nodes. \r\n    //! Text of first data node will still be placed in value of parent element, unless rapidxml::parse_no_element_values flag is also specified.\r\n    //! Can be combined with other flags by use of | operator.\r\n    //! <br><br>\r\n    //! See xml_document::parse() function.\r\n    const int parse_no_data_nodes = 0x1;            \r\n\r\n    //! Parse flag instructing the parser to not use text of first data node as a value of parent element.\r\n    //! Can be combined with other flags by use of | operator.\r\n    //! Note that child data nodes of element node take precendence over its value when printing. \r\n    //! That is, if element has one or more child data nodes <em>and</em> a value, the value will be ignored.\r\n    //! Use rapidxml::parse_no_data_nodes flag to prevent creation of data nodes if you want to manipulate data using values of elements.\r\n    //! <br><br>\r\n    //! See xml_document::parse() function.\r\n    const int parse_no_element_values = 0x2;\r\n    \r\n    //! Parse flag instructing the parser to not place zero terminators after strings in the source text.\r\n    //! By default zero terminators are placed, modifying source text.\r\n    //! Can be combined with other flags by use of | operator.\r\n    //! <br><br>\r\n    //! See xml_document::parse() function.\r\n    const int parse_no_string_terminators = 0x4;\r\n    \r\n    //! Parse flag instructing the parser to not translate entities in the source text.\r\n    //! By default entities are translated, modifying source text.\r\n    //! Can be combined with other flags by use of | operator.\r\n    //! <br><br>\r\n    //! See xml_document::parse() function.\r\n    const int parse_no_entity_translation = 0x8;\r\n    \r\n    //! Parse flag instructing the parser to disable UTF-8 handling and assume plain 8 bit characters.\r\n    //! By default, UTF-8 handling is enabled.\r\n    //! Can be combined with other flags by use of | operator.\r\n    //! <br><br>\r\n    //! See xml_document::parse() function.\r\n    const int parse_no_utf8 = 0x10;\r\n    \r\n    //! Parse flag instructing the parser to create XML declaration node.\r\n    //! By default, declaration node is not created.\r\n    //! Can be combined with other flags by use of | operator.\r\n    //! <br><br>\r\n    //! See xml_document::parse() function.\r\n    const int parse_declaration_node = 0x20;\r\n    \r\n    //! Parse flag instructing the parser to create comments nodes.\r\n    //! By default, comment nodes are not created.\r\n    //! Can be combined with other flags by use of | operator.\r\n    //! <br><br>\r\n    //! See xml_document::parse() function.\r\n    const int parse_comment_nodes = 0x40;\r\n    \r\n    //! Parse flag instructing the parser to create DOCTYPE node.\r\n    //! By default, doctype node is not created.\r\n    //! Although W3C specification allows at most one DOCTYPE node, RapidXml will silently accept documents with more than one.\r\n    //! Can be combined with other flags by use of | operator.\r\n    //! <br><br>\r\n    //! See xml_document::parse() function.\r\n    const int parse_doctype_node = 0x80;\r\n    \r\n    //! Parse flag instructing the parser to create PI nodes.\r\n    //! By default, PI nodes are not created.\r\n    //! Can be combined with other flags by use of | operator.\r\n    //! <br><br>\r\n    //! See xml_document::parse() function.\r\n    const int parse_pi_nodes = 0x100;\r\n    \r\n    //! Parse flag instructing the parser to validate closing tag names. \r\n    //! If not set, name inside closing tag is irrelevant to the parser.\r\n    //! By default, closing tags are not validated.\r\n    //! Can be combined with other flags by use of | operator.\r\n    //! <br><br>\r\n    //! See xml_document::parse() function.\r\n    const int parse_validate_closing_tags = 0x200;\r\n    \r\n    //! Parse flag instructing the parser to trim all leading and trailing whitespace of data nodes.\r\n    //! By default, whitespace is not trimmed. \r\n    //! This flag does not cause the parser to modify source text.\r\n    //! Can be combined with other flags by use of | operator.\r\n    //! <br><br>\r\n    //! See xml_document::parse() function.\r\n    const int parse_trim_whitespace = 0x400;\r\n\r\n    //! Parse flag instructing the parser to condense all whitespace runs of data nodes to a single space character.\r\n    //! Trimming of leading and trailing whitespace of data is controlled by rapidxml::parse_trim_whitespace flag.\r\n    //! By default, whitespace is not normalized. \r\n    //! If this flag is specified, source text will be modified.\r\n    //! Can be combined with other flags by use of | operator.\r\n    //! <br><br>\r\n    //! See xml_document::parse() function.\r\n    const int parse_normalize_whitespace = 0x800;\r\n\r\n    // Compound flags\r\n    \r\n    //! Parse flags which represent default behaviour of the parser. \r\n    //! This is always equal to 0, so that all other flags can be simply ored together.\r\n    //! Normally there is no need to inconveniently disable flags by anding with their negated (~) values.\r\n    //! This also means that meaning of each flag is a <i>negation</i> of the default setting. \r\n    //! For example, if flag name is rapidxml::parse_no_utf8, it means that utf-8 is <i>enabled</i> by default,\r\n    //! and using the flag will disable it.\r\n    //! <br><br>\r\n    //! See xml_document::parse() function.\r\n    const int parse_default = 0;\r\n    \r\n    //! A combination of parse flags that forbids any modifications of the source text. \r\n    //! This also results in faster parsing. However, note that the following will occur:\r\n    //! <ul>\r\n    //! <li>names and values of nodes will not be zero terminated, you have to use xml_base::name_size() and xml_base::value_size() functions to determine where name and value ends</li>\r\n    //! <li>entities will not be translated</li>\r\n    //! <li>whitespace will not be normalized</li>\r\n    //! </ul>\r\n    //! See xml_document::parse() function.\r\n    const int parse_non_destructive = parse_no_string_terminators | parse_no_entity_translation;\r\n    \r\n    //! A combination of parse flags resulting in fastest possible parsing, without sacrificing important data.\r\n    //! <br><br>\r\n    //! See xml_document::parse() function.\r\n    const int parse_fastest = parse_non_destructive | parse_no_data_nodes;\r\n    \r\n    //! A combination of parse flags resulting in largest amount of data being extracted. \r\n    //! This usually results in slowest parsing.\r\n    //! <br><br>\r\n    //! See xml_document::parse() function.\r\n    const int parse_full = parse_declaration_node | parse_comment_nodes | parse_doctype_node | parse_pi_nodes | parse_validate_closing_tags;\r\n\r\n    ///////////////////////////////////////////////////////////////////////\r\n    // Internals\r\n\r\n    //! \\cond internal\r\n    namespace internal\r\n    {\r\n\r\n        // Struct that contains lookup tables for the parser\r\n        // It must be a template to allow correct linking (because it has static data members, which are defined in a header file).\r\n        template<int Dummy>\r\n        struct lookup_tables\r\n        {\r\n            static const unsigned char lookup_whitespace[256];              // Whitespace table\r\n            static const unsigned char lookup_node_name[256];               // Node name table\r\n            static const unsigned char lookup_text[256];                    // Text table\r\n            static const unsigned char lookup_text_pure_no_ws[256];         // Text table\r\n            static const unsigned char lookup_text_pure_with_ws[256];       // Text table\r\n            static const unsigned char lookup_attribute_name[256];          // Attribute name table\r\n            static const unsigned char lookup_attribute_data_1[256];        // Attribute data table with single quote\r\n            static const unsigned char lookup_attribute_data_1_pure[256];   // Attribute data table with single quote\r\n            static const unsigned char lookup_attribute_data_2[256];        // Attribute data table with double quotes\r\n            static const unsigned char lookup_attribute_data_2_pure[256];   // Attribute data table with double quotes\r\n            static const unsigned char lookup_digits[256];                  // Digits\r\n            static const unsigned char lookup_upcase[256];                  // To uppercase conversion table for ASCII characters\r\n        };\r\n\r\n        // Find length of the string\r\n        template<class Ch>\r\n        inline std::size_t measure(const Ch *p)\r\n        {\r\n            const Ch *tmp = p;\r\n            while (*tmp) \r\n                ++tmp;\r\n            return tmp - p;\r\n        }\r\n\r\n        // Compare strings for equality\r\n        template<class Ch>\r\n        inline bool compare(const Ch *p1, std::size_t size1, const Ch *p2, std::size_t size2, bool case_sensitive)\r\n        {\r\n            if (size1 != size2)\r\n                return false;\r\n            if (case_sensitive)\r\n            {\r\n                for (const Ch *end = p1 + size1; p1 < end; ++p1, ++p2)\r\n                    if (*p1 != *p2)\r\n                        return false;\r\n            }\r\n            else\r\n            {\r\n                for (const Ch *end = p1 + size1; p1 < end; ++p1, ++p2)\r\n                    if (lookup_tables<0>::lookup_upcase[static_cast<unsigned char>(*p1)] != lookup_tables<0>::lookup_upcase[static_cast<unsigned char>(*p2)])\r\n                        return false;\r\n            }\r\n            return true;\r\n        }\r\n    }\r\n    //! \\endcond\r\n\r\n    ///////////////////////////////////////////////////////////////////////\r\n    // Memory pool\r\n    \r\n    //! This class is used by the parser to create new nodes and attributes, without overheads of dynamic memory allocation.\r\n    //! In most cases, you will not need to use this class directly. \r\n    //! However, if you need to create nodes manually or modify names/values of nodes, \r\n    //! you are encouraged to use memory_pool of relevant xml_document to allocate the memory. \r\n    //! Not only is this faster than allocating them by using <code>new</code> operator, \r\n    //! but also their lifetime will be tied to the lifetime of document, \r\n    //! possibly simplyfing memory management. \r\n    //! <br><br>\r\n    //! Call allocate_node() or allocate_attribute() functions to obtain new nodes or attributes from the pool. \r\n    //! You can also call allocate_string() function to allocate strings.\r\n    //! Such strings can then be used as names or values of nodes without worrying about their lifetime.\r\n    //! Note that there is no <code>free()</code> function -- all allocations are freed at once when clear() function is called, \r\n    //! or when the pool is destroyed.\r\n    //! <br><br>\r\n    //! It is also possible to create a standalone memory_pool, and use it \r\n    //! to allocate nodes, whose lifetime will not be tied to any document.\r\n    //! <br><br>\r\n    //! Pool maintains <code>RAPIDXML_STATIC_POOL_SIZE</code> bytes of statically allocated memory. \r\n    //! Until static memory is exhausted, no dynamic memory allocations are done.\r\n    //! When static memory is exhausted, pool allocates additional blocks of memory of size <code>RAPIDXML_DYNAMIC_POOL_SIZE</code> each,\r\n    //! by using global <code>new[]</code> and <code>delete[]</code> operators. \r\n    //! This behaviour can be changed by setting custom allocation routines. \r\n    //! Use set_allocator() function to set them.\r\n    //! <br><br>\r\n    //! Allocations for nodes, attributes and strings are aligned at <code>RAPIDXML_ALIGNMENT</code> bytes.\r\n    //! This value defaults to the size of pointer on target architecture.\r\n    //! <br><br>\r\n    //! To obtain absolutely top performance from the parser,\r\n    //! it is important that all nodes are allocated from a single, contiguous block of memory.\r\n    //! Otherwise, cache misses when jumping between two (or more) disjoint blocks of memory can slow down parsing quite considerably.\r\n    //! If required, you can tweak <code>RAPIDXML_STATIC_POOL_SIZE</code>, <code>RAPIDXML_DYNAMIC_POOL_SIZE</code> and <code>RAPIDXML_ALIGNMENT</code> \r\n    //! to obtain best wasted memory to performance compromise.\r\n    //! To do it, define their values before rapidxml.hpp file is included.\r\n    //! \\param Ch Character type of created nodes. \r\n    template<class Ch = char>\r\n    class memory_pool\r\n    {\r\n        \r\n    public:\r\n\r\n        //! \\cond internal\r\n        typedef void *(rapidxml_alloc_func)(std::size_t);       // Type of user-defined function used to allocate memory\r\n        typedef void (free_func)(void *);              // Type of user-defined function used to free memory\r\n        //! \\endcond\r\n        \r\n        //! Constructs empty pool with default allocator functions.\r\n        memory_pool()\r\n            : m_rapidxml_alloc_func(0)\r\n            , m_free_func(0)\r\n        {\r\n            init();\r\n        }\r\n\r\n        //! Destroys pool and frees all the memory. \r\n        //! This causes memory occupied by nodes allocated by the pool to be freed.\r\n        //! Nodes allocated from the pool are no longer valid.\r\n        ~memory_pool()\r\n        {\r\n            clear();\r\n        }\r\n\r\n        //! Allocates a new node from the pool, and optionally assigns name and value to it. \r\n        //! If the allocation request cannot be accomodated, this function will throw <code>std::bad_alloc</code>.\r\n        //! If exceptions are disabled by defining RAPIDXML_NO_EXCEPTIONS, this function\r\n        //! will call rapidxml::parse_error_handler() function.\r\n        //! \\param type Type of node to create.\r\n        //! \\param name Name to assign to the node, or 0 to assign no name.\r\n        //! \\param value Value to assign to the node, or 0 to assign no value.\r\n        //! \\param name_size Size of name to assign, or 0 to automatically calculate size from name string.\r\n        //! \\param value_size Size of value to assign, or 0 to automatically calculate size from value string.\r\n        //! \\return Pointer to allocated node. This pointer will never be NULL.\r\n        xml_node<Ch> *allocate_node(node_type type, \r\n                                    const Ch *name = 0, const Ch *value = 0, \r\n                                    std::size_t name_size = 0, std::size_t value_size = 0)\r\n        {\r\n            void *memory = allocate_aligned(sizeof(xml_node<Ch>));\r\n            xml_node<Ch> *node = new(memory) xml_node<Ch>(type);\r\n            if (name)\r\n            {\r\n                if (name_size > 0)\r\n                    node->name(name, name_size);\r\n                else\r\n                    node->name(name);\r\n            }\r\n            if (value)\r\n            {\r\n                if (value_size > 0)\r\n                    node->value(value, value_size);\r\n                else\r\n                    node->value(value);\r\n            }\r\n            return node;\r\n        }\r\n\r\n        //! Allocates a new attribute from the pool, and optionally assigns name and value to it.\r\n        //! If the allocation request cannot be accomodated, this function will throw <code>std::bad_alloc</code>.\r\n        //! If exceptions are disabled by defining RAPIDXML_NO_EXCEPTIONS, this function\r\n        //! will call rapidxml::parse_error_handler() function.\r\n        //! \\param name Name to assign to the attribute, or 0 to assign no name.\r\n        //! \\param value Value to assign to the attribute, or 0 to assign no value.\r\n        //! \\param name_size Size of name to assign, or 0 to automatically calculate size from name string.\r\n        //! \\param value_size Size of value to assign, or 0 to automatically calculate size from value string.\r\n        //! \\return Pointer to allocated attribute. This pointer will never be NULL.\r\n        xml_attribute<Ch> *allocate_attribute(const Ch *name = 0, const Ch *value = 0, \r\n                                              std::size_t name_size = 0, std::size_t value_size = 0)\r\n        {\r\n            void *memory = allocate_aligned(sizeof(xml_attribute<Ch>));\r\n            xml_attribute<Ch> *attribute = new(memory) xml_attribute<Ch>;\r\n            if (name)\r\n            {\r\n                if (name_size > 0)\r\n                    attribute->name(name, name_size);\r\n                else\r\n                    attribute->name(name);\r\n            }\r\n            if (value)\r\n            {\r\n                if (value_size > 0)\r\n                    attribute->value(value, value_size);\r\n                else\r\n                    attribute->value(value);\r\n            }\r\n            return attribute;\r\n        }\r\n\r\n        //! Allocates a char array of given size from the pool, and optionally copies a given string to it.\r\n        //! If the allocation request cannot be accomodated, this function will throw <code>std::bad_alloc</code>.\r\n        //! If exceptions are disabled by defining RAPIDXML_NO_EXCEPTIONS, this function\r\n        //! will call rapidxml::parse_error_handler() function.\r\n        //! \\param source String to initialize the allocated memory with, or 0 to not initialize it.\r\n        //! \\param size Number of characters to allocate, or zero to calculate it automatically from source string length; if size is 0, source string must be specified and null terminated.\r\n        //! \\return Pointer to allocated char array. This pointer will never be NULL.\r\n        Ch *allocate_string(const Ch *source = 0, std::size_t size = 0)\r\n        {\r\n            assert(source || size);     // Either source or size (or both) must be specified\r\n            if (size == 0)\r\n                size = internal::measure(source) + 1;\r\n            Ch *result = static_cast<Ch *>(allocate_aligned(size * sizeof(Ch)));\r\n            if (source)\r\n                for (std::size_t i = 0; i < size; ++i)\r\n                    result[i] = source[i];\r\n            return result;\r\n        }\r\n\r\n        //! Clones an xml_node and its hierarchy of child nodes and attributes.\r\n        //! Nodes and attributes are allocated from this memory pool.\r\n        //! Names and values are not cloned, they are shared between the clone and the source.\r\n        //! Result node can be optionally specified as a second parameter, \r\n        //! in which case its contents will be replaced with cloned source node.\r\n        //! This is useful when you want to clone entire document.\r\n        //! \\param source Node to clone.\r\n        //! \\param result Node to put results in, or 0 to automatically allocate result node\r\n        //! \\return Pointer to cloned node. This pointer will never be NULL.\r\n        xml_node<Ch> *clone_node(const xml_node<Ch> *source, xml_node<Ch> *result = 0)\r\n        {\r\n            // Prepare result node\r\n            if (result)\r\n            {\r\n                result->remove_all_attributes();\r\n                result->remove_all_nodes();\r\n                result->type(source->type());\r\n            }\r\n            else\r\n                result = allocate_node(source->type());\r\n\r\n            // Clone name and value\r\n            result->name(source->name(), source->name_size());\r\n            result->value(source->value(), source->value_size());\r\n\r\n            // Clone child nodes and attributes\r\n            for (xml_node<Ch> *child = source->first_node(); child; child = child->next_sibling())\r\n                result->append_node(clone_node(child));\r\n            for (xml_attribute<Ch> *attr = source->first_attribute(); attr; attr = attr->next_attribute())\r\n                result->append_attribute(allocate_attribute(attr->name(), attr->value(), attr->name_size(), attr->value_size()));\r\n\r\n            return result;\r\n        }\r\n\r\n        //! Clears the pool. \r\n        //! This causes memory occupied by nodes allocated by the pool to be freed.\r\n        //! Any nodes or strings allocated from the pool will no longer be valid.\r\n        void clear()\r\n        {\r\n            while (m_begin != m_static_memory)\r\n            {\r\n                char *previous_begin = reinterpret_cast<header *>(align(m_begin))->previous_begin;\r\n                if (m_free_func)\r\n                    m_free_func(m_begin);\r\n                else\r\n                    delete[] m_begin;\r\n                m_begin = previous_begin;\r\n            }\r\n            init();\r\n        }\r\n\r\n        //! Sets or resets the user-defined memory allocation functions for the pool.\r\n        //! This can only be called when no memory is allocated from the pool yet, otherwise results are undefined.\r\n        //! Allocation function must not return invalid pointer on failure. It should either throw,\r\n        //! stop the program, or use <code>longjmp()</code> function to pass control to other place of program. \r\n        //! If it returns invalid pointer, results are undefined.\r\n        //! <br><br>\r\n        //! User defined allocation functions must have the following forms:\r\n        //! <br><code>\r\n        //! <br>void *allocate(std::size_t size);\r\n        //! <br>void free(void *pointer);\r\n        //! </code><br>\r\n        //! \\param af Allocation function, or 0 to restore default function\r\n        //! \\param ff Free function, or 0 to restore default function\r\n        void set_allocator(rapidxml_alloc_func *af, free_func *ff)\r\n        {\r\n            assert(m_begin == m_static_memory && m_ptr == align(m_begin));    // Verify that no memory is allocated yet\r\n            m_rapidxml_alloc_func = af;\r\n            m_free_func = ff;\r\n        }\r\n\r\n    private:\r\n\r\n        struct header\r\n        {\r\n            char *previous_begin;\r\n        };\r\n\r\n        void init()\r\n        {\r\n            m_begin = m_static_memory;\r\n            m_ptr = align(m_begin);\r\n            m_end = m_static_memory + sizeof(m_static_memory);\r\n        }\r\n        \r\n        char *align(char *ptr)\r\n        {\r\n            std::size_t alignment = ((RAPIDXML_ALIGNMENT - (std::size_t(ptr) & (RAPIDXML_ALIGNMENT - 1))) & (RAPIDXML_ALIGNMENT - 1));\r\n            return ptr + alignment;\r\n        }\r\n        \r\n        char *allocate_raw(std::size_t size)\r\n        {\r\n            // Allocate\r\n            void *memory;   \r\n            if (m_rapidxml_alloc_func)   // Allocate memory using either user-specified allocation function or global operator new[]\r\n            {\r\n                memory = m_rapidxml_alloc_func(size);\r\n                assert(memory); // Allocator is not allowed to return 0, on failure it must either throw, stop the program or use longjmp\r\n            }\r\n            else\r\n            {\r\n                memory = new char[size];\r\n#ifdef RAPIDXML_NO_EXCEPTIONS\r\n                if (!memory)            // If exceptions are disabled, verify memory allocation, because new will not be able to throw bad_alloc\r\n                    RAPIDXML_PARSE_ERROR(\"out of memory\", 0);\r\n#endif\r\n            }\r\n            return static_cast<char *>(memory);\r\n        }\r\n        \r\n        void *allocate_aligned(std::size_t size)\r\n        {\r\n            // Calculate aligned pointer\r\n            char *result = align(m_ptr);\r\n\r\n            // If not enough memory left in current pool, allocate a new pool\r\n            if (result + size > m_end)\r\n            {\r\n                // Calculate required pool size (may be bigger than RAPIDXML_DYNAMIC_POOL_SIZE)\r\n                std::size_t pool_size = RAPIDXML_DYNAMIC_POOL_SIZE;\r\n                if (pool_size < size)\r\n                    pool_size = size;\r\n                \r\n                // Allocate\r\n                std::size_t alloc_size = sizeof(header) + (2 * RAPIDXML_ALIGNMENT - 2) + pool_size;     // 2 alignments required in worst case: one for header, one for actual allocation\r\n                char *raw_memory = allocate_raw(alloc_size);\r\n                    \r\n                // Setup new pool in allocated memory\r\n                char *pool = align(raw_memory);\r\n                header *new_header = reinterpret_cast<header *>(pool);\r\n                new_header->previous_begin = m_begin;\r\n                m_begin = raw_memory;\r\n                m_ptr = pool + sizeof(header);\r\n                m_end = raw_memory + alloc_size;\r\n\r\n                // Calculate aligned pointer again using new pool\r\n                result = align(m_ptr);\r\n            }\r\n\r\n            // Update pool and return aligned pointer\r\n            m_ptr = result + size;\r\n            return result;\r\n        }\r\n\r\n        char *m_begin;                                      // Start of raw memory making up current pool\r\n        char *m_ptr;                                        // First free byte in current pool\r\n        char *m_end;                                        // One past last available byte in current pool\r\n        char m_static_memory[RAPIDXML_STATIC_POOL_SIZE];    // Static raw memory\r\n        rapidxml_alloc_func *m_rapidxml_alloc_func;                           // Allocator function, or 0 if default is to be used\r\n        free_func *m_free_func;                             // Free function, or 0 if default is to be used\r\n    };\r\n\r\n    ///////////////////////////////////////////////////////////////////////////\r\n    // XML base\r\n\r\n    //! Base class for xml_node and xml_attribute implementing common functions: \r\n    //! name(), name_size(), value(), value_size() and parent().\r\n    //! \\param Ch Character type to use\r\n    template<class Ch = char>\r\n    class xml_base\r\n    {\r\n\r\n    public:\r\n        \r\n        ///////////////////////////////////////////////////////////////////////////\r\n        // Construction & destruction\r\n    \r\n        // Construct a base with empty name, value and parent\r\n        xml_base()\r\n            : m_name(0)\r\n            , m_value(0)\r\n            , m_parent(0)\r\n        {\r\n        }\r\n\r\n        ///////////////////////////////////////////////////////////////////////////\r\n        // Node data access\r\n    \r\n        //! Gets name of the node. \r\n        //! Interpretation of name depends on type of node.\r\n        //! Note that name will not be zero-terminated if rapidxml::parse_no_string_terminators option was selected during parse.\r\n        //! <br><br>\r\n        //! Use name_size() function to determine length of the name.\r\n        //! \\return Name of node, or empty string if node has no name.\r\n        Ch *name() const\r\n        {\r\n            return m_name ? m_name : nullstr();\r\n        }\r\n\r\n        //! Gets size of node name, not including terminator character.\r\n        //! This function works correctly irrespective of whether name is or is not zero terminated.\r\n        //! \\return Size of node name, in characters.\r\n        std::size_t name_size() const\r\n        {\r\n            return m_name ? m_name_size : 0;\r\n        }\r\n\r\n        //! Gets value of node. \r\n        //! Interpretation of value depends on type of node.\r\n        //! Note that value will not be zero-terminated if rapidxml::parse_no_string_terminators option was selected during parse.\r\n        //! <br><br>\r\n        //! Use value_size() function to determine length of the value.\r\n        //! \\return Value of node, or empty string if node has no value.\r\n        Ch *value() const\r\n        {\r\n            return m_value ? m_value : nullstr();\r\n        }\r\n\r\n        //! Gets size of node value, not including terminator character.\r\n        //! This function works correctly irrespective of whether value is or is not zero terminated.\r\n        //! \\return Size of node value, in characters.\r\n        std::size_t value_size() const\r\n        {\r\n            return m_value ? m_value_size : 0;\r\n        }\r\n\r\n        ///////////////////////////////////////////////////////////////////////////\r\n        // Node modification\r\n    \r\n        //! Sets name of node to a non zero-terminated string.\r\n        //! See \\ref ownership_of_strings.\r\n        //! <br><br>\r\n        //! Note that node does not own its name or value, it only stores a pointer to it. \r\n        //! It will not delete or otherwise free the pointer on destruction.\r\n        //! It is reponsibility of the user to properly manage lifetime of the string.\r\n        //! The easiest way to achieve it is to use memory_pool of the document to allocate the string -\r\n        //! on destruction of the document the string will be automatically freed.\r\n        //! <br><br>\r\n        //! Size of name must be specified separately, because name does not have to be zero terminated.\r\n        //! Use name(const Ch *) function to have the length automatically calculated (string must be zero terminated).\r\n        //! \\param name Name of node to set. Does not have to be zero terminated.\r\n        //! \\param size Size of name, in characters. This does not include zero terminator, if one is present.\r\n        void name(const Ch *name, std::size_t size)\r\n        {\r\n            m_name = const_cast<Ch *>(name);\r\n            m_name_size = size;\r\n        }\r\n\r\n        //! Sets name of node to a zero-terminated string.\r\n        //! See also \\ref ownership_of_strings and xml_node::name(const Ch *, std::size_t).\r\n        //! \\param name Name of node to set. Must be zero terminated.\r\n        void name(const Ch *name)\r\n        {\r\n            this->name(name, internal::measure(name));\r\n        }\r\n\r\n        //! Sets value of node to a non zero-terminated string.\r\n        //! See \\ref ownership_of_strings.\r\n        //! <br><br>\r\n        //! Note that node does not own its name or value, it only stores a pointer to it. \r\n        //! It will not delete or otherwise free the pointer on destruction.\r\n        //! It is reponsibility of the user to properly manage lifetime of the string.\r\n        //! The easiest way to achieve it is to use memory_pool of the document to allocate the string -\r\n        //! on destruction of the document the string will be automatically freed.\r\n        //! <br><br>\r\n        //! Size of value must be specified separately, because it does not have to be zero terminated.\r\n        //! Use value(const Ch *) function to have the length automatically calculated (string must be zero terminated).\r\n        //! <br><br>\r\n        //! If an element has a child node of type node_data, it will take precedence over element value when printing.\r\n        //! If you want to manipulate data of elements using values, use parser flag rapidxml::parse_no_data_nodes to prevent creation of data nodes by the parser.\r\n        //! \\param value value of node to set. Does not have to be zero terminated.\r\n        //! \\param size Size of value, in characters. This does not include zero terminator, if one is present.\r\n        void value(const Ch *value, std::size_t size)\r\n        {\r\n            m_value = const_cast<Ch *>(value);\r\n            m_value_size = size;\r\n        }\r\n\r\n        //! Sets value of node to a zero-terminated string.\r\n        //! See also \\ref ownership_of_strings and xml_node::value(const Ch *, std::size_t).\r\n        //! \\param value Vame of node to set. Must be zero terminated.\r\n        void value(const Ch *value)\r\n        {\r\n            this->value(value, internal::measure(value));\r\n        }\r\n\r\n        ///////////////////////////////////////////////////////////////////////////\r\n        // Related nodes access\r\n    \r\n        //! Gets node parent.\r\n        //! \\return Pointer to parent node, or 0 if there is no parent.\r\n        xml_node<Ch> *parent() const\r\n        {\r\n            return m_parent;\r\n        }\r\n\r\n    protected:\r\n\r\n        // Return empty string\r\n        static Ch *nullstr()\r\n        {\r\n            static Ch zero = Ch('\\0');\r\n            return &zero;\r\n        }\r\n\r\n        Ch *m_name;                         // Name of node, or 0 if no name\r\n        Ch *m_value;                        // Value of node, or 0 if no value\r\n        std::size_t m_name_size;            // Length of node name, or undefined of no name\r\n        std::size_t m_value_size;           // Length of node value, or undefined if no value\r\n        xml_node<Ch> *m_parent;             // Pointer to parent node, or 0 if none\r\n\r\n    };\r\n\r\n    //! Class representing attribute node of XML document. \r\n    //! Each attribute has name and value strings, which are available through name() and value() functions (inherited from xml_base).\r\n    //! Note that after parse, both name and value of attribute will point to interior of source text used for parsing. \r\n    //! Thus, this text must persist in memory for the lifetime of attribute.\r\n    //! \\param Ch Character type to use.\r\n    template<class Ch = char>\r\n    class xml_attribute: public xml_base<Ch>\r\n    {\r\n\r\n        friend class xml_node<Ch>;\r\n    \r\n    public:\r\n\r\n        ///////////////////////////////////////////////////////////////////////////\r\n        // Construction & destruction\r\n    \r\n        //! Constructs an empty attribute with the specified type. \r\n        //! Consider using memory_pool of appropriate xml_document if allocating attributes manually.\r\n        xml_attribute()\r\n        {\r\n        }\r\n\r\n        ///////////////////////////////////////////////////////////////////////////\r\n        // Related nodes access\r\n    \r\n        //! Gets document of which attribute is a child.\r\n        //! \\return Pointer to document that contains this attribute, or 0 if there is no parent document.\r\n        xml_document<Ch> *document() const\r\n        {\r\n            if (xml_node<Ch> *node = this->parent())\r\n            {\r\n                while (node->parent())\r\n                    node = node->parent();\r\n                return node->type() == node_document ? static_cast<xml_document<Ch> *>(node) : 0;\r\n            }\r\n            else\r\n                return 0;\r\n        }\r\n\r\n        //! Gets previous attribute, optionally matching attribute name. \r\n        //! \\param name Name of attribute to find, or 0 to return previous attribute regardless of its name; this string doesn't have to be zero-terminated if name_size is non-zero\r\n        //! \\param name_size Size of name, in characters, or 0 to have size calculated automatically from string\r\n        //! \\param case_sensitive Should name comparison be case-sensitive; non case-sensitive comparison works properly only for ASCII characters\r\n        //! \\return Pointer to found attribute, or 0 if not found.\r\n        xml_attribute<Ch> *previous_attribute(const Ch *name = 0, std::size_t name_size = 0, bool case_sensitive = true) const\r\n        {\r\n            if (name)\r\n            {\r\n                if (name_size == 0)\r\n                    name_size = internal::measure(name);\r\n                for (xml_attribute<Ch> *attribute = m_prev_attribute; attribute; attribute = attribute->m_prev_attribute)\r\n                    if (internal::compare(attribute->name(), attribute->name_size(), name, name_size, case_sensitive))\r\n                        return attribute;\r\n                return 0;\r\n            }\r\n            else\r\n                return this->m_parent ? m_prev_attribute : 0;\r\n        }\r\n\r\n        //! Gets next attribute, optionally matching attribute name. \r\n        //! \\param name Name of attribute to find, or 0 to return next attribute regardless of its name; this string doesn't have to be zero-terminated if name_size is non-zero\r\n        //! \\param name_size Size of name, in characters, or 0 to have size calculated automatically from string\r\n        //! \\param case_sensitive Should name comparison be case-sensitive; non case-sensitive comparison works properly only for ASCII characters\r\n        //! \\return Pointer to found attribute, or 0 if not found.\r\n        xml_attribute<Ch> *next_attribute(const Ch *name = 0, std::size_t name_size = 0, bool case_sensitive = true) const\r\n        {\r\n            if (name)\r\n            {\r\n                if (name_size == 0)\r\n                    name_size = internal::measure(name);\r\n                for (xml_attribute<Ch> *attribute = m_next_attribute; attribute; attribute = attribute->m_next_attribute)\r\n                    if (internal::compare(attribute->name(), attribute->name_size(), name, name_size, case_sensitive))\r\n                        return attribute;\r\n                return 0;\r\n            }\r\n            else\r\n                return this->m_parent ? m_next_attribute : 0;\r\n        }\r\n\r\n    private:\r\n\r\n        xml_attribute<Ch> *m_prev_attribute;        // Pointer to previous sibling of attribute, or 0 if none; only valid if parent is non-zero\r\n        xml_attribute<Ch> *m_next_attribute;        // Pointer to next sibling of attribute, or 0 if none; only valid if parent is non-zero\r\n    \r\n    };\r\n\r\n    ///////////////////////////////////////////////////////////////////////////\r\n    // XML node\r\n\r\n    //! Class representing a node of XML document. \r\n    //! Each node may have associated name and value strings, which are available through name() and value() functions. \r\n    //! Interpretation of name and value depends on type of the node.\r\n    //! Type of node can be determined by using type() function.\r\n    //! <br><br>\r\n    //! Note that after parse, both name and value of node, if any, will point interior of source text used for parsing. \r\n    //! Thus, this text must persist in the memory for the lifetime of node.\r\n    //! \\param Ch Character type to use.\r\n    template<class Ch = char>\r\n    class xml_node: public xml_base<Ch>\r\n    {\r\n\r\n    public:\r\n\r\n        ///////////////////////////////////////////////////////////////////////////\r\n        // Construction & destruction\r\n    \r\n        //! Constructs an empty node with the specified type. \r\n        //! Consider using memory_pool of appropriate document to allocate nodes manually.\r\n        //! \\param type Type of node to construct.\r\n        xml_node(node_type type)\r\n            : m_type(type)\r\n            , m_first_node(0)\r\n            , m_first_attribute(0)\r\n        {\r\n        }\r\n\r\n        ///////////////////////////////////////////////////////////////////////////\r\n        // Node data access\r\n    \r\n        //! Gets type of node.\r\n        //! \\return Type of node.\r\n        node_type type() const\r\n        {\r\n            return m_type;\r\n        }\r\n\r\n        ///////////////////////////////////////////////////////////////////////////\r\n        // Related nodes access\r\n    \r\n        //! Gets document of which node is a child.\r\n        //! \\return Pointer to document that contains this node, or 0 if there is no parent document.\r\n        xml_document<Ch> *document() const\r\n        {\r\n            xml_node<Ch> *node = const_cast<xml_node<Ch> *>(this);\r\n            while (node->parent())\r\n                node = node->parent();\r\n            return node->type() == node_document ? static_cast<xml_document<Ch> *>(node) : 0;\r\n        }\r\n\r\n        //! Gets first child node, optionally matching node name.\r\n        //! \\param name Name of child to find, or 0 to return first child regardless of its name; this string doesn't have to be zero-terminated if name_size is non-zero\r\n        //! \\param name_size Size of name, in characters, or 0 to have size calculated automatically from string\r\n        //! \\param case_sensitive Should name comparison be case-sensitive; non case-sensitive comparison works properly only for ASCII characters\r\n        //! \\return Pointer to found child, or 0 if not found.\r\n        xml_node<Ch> *first_node(const Ch *name = 0, std::size_t name_size = 0, bool case_sensitive = true) const\r\n        {\r\n            if (name)\r\n            {\r\n                if (name_size == 0)\r\n                    name_size = internal::measure(name);\r\n                for (xml_node<Ch> *child = m_first_node; child; child = child->next_sibling())\r\n                    if (internal::compare(child->name(), child->name_size(), name, name_size, case_sensitive))\r\n                        return child;\r\n                return 0;\r\n            }\r\n            else\r\n                return m_first_node;\r\n        }\r\n\r\n        //! Gets last child node, optionally matching node name. \r\n        //! Behaviour is undefined if node has no children.\r\n        //! Use first_node() to test if node has children.\r\n        //! \\param name Name of child to find, or 0 to return last child regardless of its name; this string doesn't have to be zero-terminated if name_size is non-zero\r\n        //! \\param name_size Size of name, in characters, or 0 to have size calculated automatically from string\r\n        //! \\param case_sensitive Should name comparison be case-sensitive; non case-sensitive comparison works properly only for ASCII characters\r\n        //! \\return Pointer to found child, or 0 if not found.\r\n        xml_node<Ch> *last_node(const Ch *name = 0, std::size_t name_size = 0, bool case_sensitive = true) const\r\n        {\r\n            assert(m_first_node);  // Cannot query for last child if node has no children\r\n            if (name)\r\n            {\r\n                if (name_size == 0)\r\n                    name_size = internal::measure(name);\r\n                for (xml_node<Ch> *child = m_last_node; child; child = child->previous_sibling())\r\n                    if (internal::compare(child->name(), child->name_size(), name, name_size, case_sensitive))\r\n                        return child;\r\n                return 0;\r\n            }\r\n            else\r\n                return m_last_node;\r\n        }\r\n\r\n        //! Gets previous sibling node, optionally matching node name. \r\n        //! Behaviour is undefined if node has no parent.\r\n        //! Use parent() to test if node has a parent.\r\n        //! \\param name Name of sibling to find, or 0 to return previous sibling regardless of its name; this string doesn't have to be zero-terminated if name_size is non-zero\r\n        //! \\param name_size Size of name, in characters, or 0 to have size calculated automatically from string\r\n        //! \\param case_sensitive Should name comparison be case-sensitive; non case-sensitive comparison works properly only for ASCII characters\r\n        //! \\return Pointer to found sibling, or 0 if not found.\r\n        xml_node<Ch> *previous_sibling(const Ch *name = 0, std::size_t name_size = 0, bool case_sensitive = true) const\r\n        {\r\n            assert(this->m_parent);     // Cannot query for siblings if node has no parent\r\n            if (name)\r\n            {\r\n                if (name_size == 0)\r\n                    name_size = internal::measure(name);\r\n                for (xml_node<Ch> *sibling = m_prev_sibling; sibling; sibling = sibling->m_prev_sibling)\r\n                    if (internal::compare(sibling->name(), sibling->name_size(), name, name_size, case_sensitive))\r\n                        return sibling;\r\n                return 0;\r\n            }\r\n            else\r\n                return m_prev_sibling;\r\n        }\r\n\r\n        //! Gets next sibling node, optionally matching node name. \r\n        //! Behaviour is undefined if node has no parent.\r\n        //! Use parent() to test if node has a parent.\r\n        //! \\param name Name of sibling to find, or 0 to return next sibling regardless of its name; this string doesn't have to be zero-terminated if name_size is non-zero\r\n        //! \\param name_size Size of name, in characters, or 0 to have size calculated automatically from string\r\n        //! \\param case_sensitive Should name comparison be case-sensitive; non case-sensitive comparison works properly only for ASCII characters\r\n        //! \\return Pointer to found sibling, or 0 if not found.\r\n        xml_node<Ch> *next_sibling(const Ch *name = 0, std::size_t name_size = 0, bool case_sensitive = true) const\r\n        {\r\n            assert(this->m_parent);     // Cannot query for siblings if node has no parent\r\n            if (name)\r\n            {\r\n                if (name_size == 0)\r\n                    name_size = internal::measure(name);\r\n                for (xml_node<Ch> *sibling = m_next_sibling; sibling; sibling = sibling->m_next_sibling)\r\n                    if (internal::compare(sibling->name(), sibling->name_size(), name, name_size, case_sensitive))\r\n                        return sibling;\r\n                return 0;\r\n            }\r\n            else\r\n                return m_next_sibling;\r\n        }\r\n\r\n        //! Gets first attribute of node, optionally matching attribute name.\r\n        //! \\param name Name of attribute to find, or 0 to return first attribute regardless of its name; this string doesn't have to be zero-terminated if name_size is non-zero\r\n        //! \\param name_size Size of name, in characters, or 0 to have size calculated automatically from string\r\n        //! \\param case_sensitive Should name comparison be case-sensitive; non case-sensitive comparison works properly only for ASCII characters\r\n        //! \\return Pointer to found attribute, or 0 if not found.\r\n        xml_attribute<Ch> *first_attribute(const Ch *name = 0, std::size_t name_size = 0, bool case_sensitive = true) const\r\n        {\r\n            if (name)\r\n            {\r\n                if (name_size == 0)\r\n                    name_size = internal::measure(name);\r\n                for (xml_attribute<Ch> *attribute = m_first_attribute; attribute; attribute = attribute->m_next_attribute)\r\n                    if (internal::compare(attribute->name(), attribute->name_size(), name, name_size, case_sensitive))\r\n                        return attribute;\r\n                return 0;\r\n            }\r\n            else\r\n                return m_first_attribute;\r\n        }\r\n\r\n        //! Gets last attribute of node, optionally matching attribute name.\r\n        //! \\param name Name of attribute to find, or 0 to return last attribute regardless of its name; this string doesn't have to be zero-terminated if name_size is non-zero\r\n        //! \\param name_size Size of name, in characters, or 0 to have size calculated automatically from string\r\n        //! \\param case_sensitive Should name comparison be case-sensitive; non case-sensitive comparison works properly only for ASCII characters\r\n        //! \\return Pointer to found attribute, or 0 if not found.\r\n        xml_attribute<Ch> *last_attribute(const Ch *name = 0, std::size_t name_size = 0, bool case_sensitive = true) const\r\n        {\r\n            if (name)\r\n            {\r\n                if (name_size == 0)\r\n                    name_size = internal::measure(name);\r\n                for (xml_attribute<Ch> *attribute = m_last_attribute; attribute; attribute = attribute->m_prev_attribute)\r\n                    if (internal::compare(attribute->name(), attribute->name_size(), name, name_size, case_sensitive))\r\n                        return attribute;\r\n                return 0;\r\n            }\r\n            else\r\n                return m_first_attribute ? m_last_attribute : 0;\r\n        }\r\n\r\n        ///////////////////////////////////////////////////////////////////////////\r\n        // Node modification\r\n    \r\n        //! Sets type of node.\r\n        //! \\param type Type of node to set.\r\n        void type(node_type type)\r\n        {\r\n            m_type = type;\r\n        }\r\n\r\n        ///////////////////////////////////////////////////////////////////////////\r\n        // Node manipulation\r\n\r\n        //! Prepends a new child node.\r\n        //! The prepended child becomes the first child, and all existing children are moved one position back.\r\n        //! \\param child Node to prepend.\r\n        void prepend_node(xml_node<Ch> *child)\r\n        {\r\n            assert(child && !child->parent() && child->type() != node_document);\r\n            if (first_node())\r\n            {\r\n                child->m_next_sibling = m_first_node;\r\n                m_first_node->m_prev_sibling = child;\r\n            }\r\n            else\r\n            {\r\n                child->m_next_sibling = 0;\r\n                m_last_node = child;\r\n            }\r\n            m_first_node = child;\r\n            child->m_parent = this;\r\n            child->m_prev_sibling = 0;\r\n        }\r\n\r\n        //! Appends a new child node. \r\n        //! The appended child becomes the last child.\r\n        //! \\param child Node to append.\r\n        void append_node(xml_node<Ch> *child)\r\n        {\r\n            assert(child && !child->parent() && child->type() != node_document);\r\n            if (first_node())\r\n            {\r\n                child->m_prev_sibling = m_last_node;\r\n                m_last_node->m_next_sibling = child;\r\n            }\r\n            else\r\n            {\r\n                child->m_prev_sibling = 0;\r\n                m_first_node = child;\r\n            }\r\n            m_last_node = child;\r\n            child->m_parent = this;\r\n            child->m_next_sibling = 0;\r\n        }\r\n\r\n        //! Inserts a new child node at specified place inside the node. \r\n        //! All children after and including the specified node are moved one position back.\r\n        //! \\param where Place where to insert the child, or 0 to insert at the back.\r\n        //! \\param child Node to insert.\r\n        void insert_node(xml_node<Ch> *where, xml_node<Ch> *child)\r\n        {\r\n            assert(!where || where->parent() == this);\r\n            assert(child && !child->parent() && child->type() != node_document);\r\n            if (where == m_first_node)\r\n                prepend_node(child);\r\n            else if (where == 0)\r\n                append_node(child);\r\n            else\r\n            {\r\n                child->m_prev_sibling = where->m_prev_sibling;\r\n                child->m_next_sibling = where;\r\n                where->m_prev_sibling->m_next_sibling = child;\r\n                where->m_prev_sibling = child;\r\n                child->m_parent = this;\r\n            }\r\n        }\r\n\r\n        //! Removes first child node. \r\n        //! If node has no children, behaviour is undefined.\r\n        //! Use first_node() to test if node has children.\r\n        void remove_first_node()\r\n        {\r\n            assert(first_node());\r\n            xml_node<Ch> *child = m_first_node;\r\n            m_first_node = child->m_next_sibling;\r\n            if (child->m_next_sibling)\r\n                child->m_next_sibling->m_prev_sibling = 0;\r\n            else\r\n                m_last_node = 0;\r\n            child->m_parent = 0;\r\n        }\r\n\r\n        //! Removes last child of the node. \r\n        //! If node has no children, behaviour is undefined.\r\n        //! Use first_node() to test if node has children.\r\n        void remove_last_node()\r\n        {\r\n            assert(first_node());\r\n            xml_node<Ch> *child = m_last_node;\r\n            if (child->m_prev_sibling)\r\n            {\r\n                m_last_node = child->m_prev_sibling;\r\n                child->m_prev_sibling->m_next_sibling = 0;\r\n            }\r\n            else\r\n                m_first_node = 0;\r\n            child->m_parent = 0;\r\n        }\r\n\r\n        //! Removes specified child from the node\r\n        // \\param where Pointer to child to be removed.\r\n        void remove_node(xml_node<Ch> *where)\r\n        {\r\n            assert(where && where->parent() == this);\r\n            assert(first_node());\r\n            if (where == m_first_node)\r\n                remove_first_node();\r\n            else if (where == m_last_node)\r\n                remove_last_node();\r\n            else\r\n            {\r\n                where->m_prev_sibling->m_next_sibling = where->m_next_sibling;\r\n                where->m_next_sibling->m_prev_sibling = where->m_prev_sibling;\r\n                where->m_parent = 0;\r\n            }\r\n        }\r\n\r\n        //! Removes all child nodes (but not attributes).\r\n        void remove_all_nodes()\r\n        {\r\n            for (xml_node<Ch> *node = first_node(); node; node = node->m_next_sibling)\r\n                node->m_parent = 0;\r\n            m_first_node = 0;\r\n        }\r\n\r\n        //! Prepends a new attribute to the node.\r\n        //! \\param attribute Attribute to prepend.\r\n        void prepend_attribute(xml_attribute<Ch> *attribute)\r\n        {\r\n            assert(attribute && !attribute->parent());\r\n            if (first_attribute())\r\n            {\r\n                attribute->m_next_attribute = m_first_attribute;\r\n                m_first_attribute->m_prev_attribute = attribute;\r\n            }\r\n            else\r\n            {\r\n                attribute->m_next_attribute = 0;\r\n                m_last_attribute = attribute;\r\n            }\r\n            m_first_attribute = attribute;\r\n            attribute->m_parent = this;\r\n            attribute->m_prev_attribute = 0;\r\n        }\r\n\r\n        //! Appends a new attribute to the node.\r\n        //! \\param attribute Attribute to append.\r\n        void append_attribute(xml_attribute<Ch> *attribute)\r\n        {\r\n            assert(attribute && !attribute->parent());\r\n            if (first_attribute())\r\n            {\r\n                attribute->m_prev_attribute = m_last_attribute;\r\n                m_last_attribute->m_next_attribute = attribute;\r\n            }\r\n            else\r\n            {\r\n                attribute->m_prev_attribute = 0;\r\n                m_first_attribute = attribute;\r\n            }\r\n            m_last_attribute = attribute;\r\n            attribute->m_parent = this;\r\n            attribute->m_next_attribute = 0;\r\n        }\r\n\r\n        //! Inserts a new attribute at specified place inside the node. \r\n        //! All attributes after and including the specified attribute are moved one position back.\r\n        //! \\param where Place where to insert the attribute, or 0 to insert at the back.\r\n        //! \\param attribute Attribute to insert.\r\n        void insert_attribute(xml_attribute<Ch> *where, xml_attribute<Ch> *attribute)\r\n        {\r\n            assert(!where || where->parent() == this);\r\n            assert(attribute && !attribute->parent());\r\n            if (where == m_first_attribute)\r\n                prepend_attribute(attribute);\r\n            else if (where == 0)\r\n                append_attribute(attribute);\r\n            else\r\n            {\r\n                attribute->m_prev_attribute = where->m_prev_attribute;\r\n                attribute->m_next_attribute = where;\r\n                where->m_prev_attribute->m_next_attribute = attribute;\r\n                where->m_prev_attribute = attribute;\r\n                attribute->m_parent = this;\r\n            }\r\n        }\r\n\r\n        //! Removes first attribute of the node. \r\n        //! If node has no attributes, behaviour is undefined.\r\n        //! Use first_attribute() to test if node has attributes.\r\n        void remove_first_attribute()\r\n        {\r\n            assert(first_attribute());\r\n            xml_attribute<Ch> *attribute = m_first_attribute;\r\n            if (attribute->m_next_attribute)\r\n            {\r\n                attribute->m_next_attribute->m_prev_attribute = 0;\r\n            }\r\n            else\r\n                m_last_attribute = 0;\r\n            attribute->m_parent = 0;\r\n            m_first_attribute = attribute->m_next_attribute;\r\n        }\r\n\r\n        //! Removes last attribute of the node. \r\n        //! If node has no attributes, behaviour is undefined.\r\n        //! Use first_attribute() to test if node has attributes.\r\n        void remove_last_attribute()\r\n        {\r\n            assert(first_attribute());\r\n            xml_attribute<Ch> *attribute = m_last_attribute;\r\n            if (attribute->m_prev_attribute)\r\n            {\r\n                attribute->m_prev_attribute->m_next_attribute = 0;\r\n                m_last_attribute = attribute->m_prev_attribute;\r\n            }\r\n            else\r\n                m_first_attribute = 0;\r\n            attribute->m_parent = 0;\r\n        }\r\n\r\n        //! Removes specified attribute from node.\r\n        //! \\param where Pointer to attribute to be removed.\r\n        void remove_attribute(xml_attribute<Ch> *where)\r\n        {\r\n            assert(first_attribute() && where->parent() == this);\r\n            if (where == m_first_attribute)\r\n                remove_first_attribute();\r\n            else if (where == m_last_attribute)\r\n                remove_last_attribute();\r\n            else\r\n            {\r\n                where->m_prev_attribute->m_next_attribute = where->m_next_attribute;\r\n                where->m_next_attribute->m_prev_attribute = where->m_prev_attribute;\r\n                where->m_parent = 0;\r\n            }\r\n        }\r\n\r\n        //! Removes all attributes of node.\r\n        void remove_all_attributes()\r\n        {\r\n            for (xml_attribute<Ch> *attribute = first_attribute(); attribute; attribute = attribute->m_next_attribute)\r\n                attribute->m_parent = 0;\r\n            m_first_attribute = 0;\r\n        }\r\n        \r\n    private:\r\n\r\n        ///////////////////////////////////////////////////////////////////////////\r\n        // Restrictions\r\n\r\n        // No copying\r\n        xml_node(const xml_node &);\r\n        void operator =(const xml_node &);\r\n    \r\n        ///////////////////////////////////////////////////////////////////////////\r\n        // Data members\r\n    \r\n        // Note that some of the pointers below have UNDEFINED values if certain other pointers are 0.\r\n        // This is required for maximum performance, as it allows the parser to omit initialization of \r\n        // unneded/redundant values.\r\n        //\r\n        // The rules are as follows:\r\n        // 1. first_node and first_attribute contain valid pointers, or 0 if node has no children/attributes respectively\r\n        // 2. last_node and last_attribute are valid only if node has at least one child/attribute respectively, otherwise they contain garbage\r\n        // 3. prev_sibling and next_sibling are valid only if node has a parent, otherwise they contain garbage\r\n\r\n        node_type m_type;                       // Type of node; always valid\r\n        xml_node<Ch> *m_first_node;             // Pointer to first child node, or 0 if none; always valid\r\n        xml_node<Ch> *m_last_node;              // Pointer to last child node, or 0 if none; this value is only valid if m_first_node is non-zero\r\n        xml_attribute<Ch> *m_first_attribute;   // Pointer to first attribute of node, or 0 if none; always valid\r\n        xml_attribute<Ch> *m_last_attribute;    // Pointer to last attribute of node, or 0 if none; this value is only valid if m_first_attribute is non-zero\r\n        xml_node<Ch> *m_prev_sibling;           // Pointer to previous sibling of node, or 0 if none; this value is only valid if m_parent is non-zero\r\n        xml_node<Ch> *m_next_sibling;           // Pointer to next sibling of node, or 0 if none; this value is only valid if m_parent is non-zero\r\n\r\n    };\r\n\r\n    ///////////////////////////////////////////////////////////////////////////\r\n    // XML document\r\n    \r\n    //! This class represents root of the DOM hierarchy. \r\n    //! It is also an xml_node and a memory_pool through public inheritance.\r\n    //! Use parse() function to build a DOM tree from a zero-terminated XML text string.\r\n    //! parse() function allocates memory for nodes and attributes by using functions of xml_document, \r\n    //! which are inherited from memory_pool.\r\n    //! To access root node of the document, use the document itself, as if it was an xml_node.\r\n    //! \\param Ch Character type to use.\r\n    template<class Ch = char>\r\n    class xml_document: public xml_node<Ch>, public memory_pool<Ch>\r\n    {\r\n    \r\n    public:\r\n\r\n        //! Constructs empty XML document\r\n        xml_document()\r\n            : xml_node<Ch>(node_document)\r\n        {\r\n        }\r\n\r\n        //! Parses zero-terminated XML string according to given flags.\r\n        //! Passed string will be modified by the parser, unless rapidxml::parse_non_destructive flag is used.\r\n        //! The string must persist for the lifetime of the document.\r\n        //! In case of error, rapidxml::parse_error exception will be thrown.\r\n        //! <br><br>\r\n        //! If you want to parse contents of a file, you must first load the file into the memory, and pass pointer to its beginning.\r\n        //! Make sure that data is zero-terminated.\r\n        //! <br><br>\r\n        //! Document can be parsed into multiple times. \r\n        //! Each new call to parse removes previous nodes and attributes (if any), but does not clear memory pool.\r\n        //! \\param text XML data to parse; pointer is non-const to denote fact that this data may be modified by the parser.\r\n        template<int Flags>\r\n        void parse(Ch *text)\r\n        {\r\n            assert(text);\r\n            \r\n            // Remove current contents\r\n            this->remove_all_nodes();\r\n            this->remove_all_attributes();\r\n            \r\n            // Parse BOM, if any\r\n            parse_bom<Flags>(text);\r\n            \r\n            // Parse children\r\n            while (1)\r\n            {\r\n                // Skip whitespace before node\r\n                skip<whitespace_pred, Flags>(text);\r\n                if (*text == 0)\r\n                    break;\r\n\r\n                // Parse and append new child\r\n                if (*text == Ch('<'))\r\n                {\r\n                    ++text;     // Skip '<'\r\n                    if (xml_node<Ch> *node = parse_node<Flags>(text))\r\n                        this->append_node(node);\r\n                }\r\n                else\r\n                    RAPIDXML_PARSE_ERROR(\"expected <\", text);\r\n            }\r\n\r\n        }\r\n\r\n        //! Clears the document by deleting all nodes and clearing the memory pool.\r\n        //! All nodes owned by document pool are destroyed.\r\n        void clear()\r\n        {\r\n            this->remove_all_nodes();\r\n            this->remove_all_attributes();\r\n            memory_pool<Ch>::clear();\r\n        }\r\n        \r\n    private:\r\n\r\n        ///////////////////////////////////////////////////////////////////////\r\n        // Internal character utility functions\r\n        \r\n        // Detect whitespace character\r\n        struct whitespace_pred\r\n        {\r\n            static unsigned char test(Ch ch)\r\n            {\r\n                return internal::lookup_tables<0>::lookup_whitespace[static_cast<unsigned char>(ch)];\r\n            }\r\n        };\r\n\r\n        // Detect node name character\r\n        struct node_name_pred\r\n        {\r\n            static unsigned char test(Ch ch)\r\n            {\r\n                return internal::lookup_tables<0>::lookup_node_name[static_cast<unsigned char>(ch)];\r\n            }\r\n        };\r\n\r\n        // Detect attribute name character\r\n        struct attribute_name_pred\r\n        {\r\n            static unsigned char test(Ch ch)\r\n            {\r\n                return internal::lookup_tables<0>::lookup_attribute_name[static_cast<unsigned char>(ch)];\r\n            }\r\n        };\r\n\r\n        // Detect text character (PCDATA)\r\n        struct text_pred\r\n        {\r\n            static unsigned char test(Ch ch)\r\n            {\r\n                return internal::lookup_tables<0>::lookup_text[static_cast<unsigned char>(ch)];\r\n            }\r\n        };\r\n\r\n        // Detect text character (PCDATA) that does not require processing\r\n        struct text_pure_no_ws_pred\r\n        {\r\n            static unsigned char test(Ch ch)\r\n            {\r\n                return internal::lookup_tables<0>::lookup_text_pure_no_ws[static_cast<unsigned char>(ch)];\r\n            }\r\n        };\r\n\r\n        // Detect text character (PCDATA) that does not require processing\r\n        struct text_pure_with_ws_pred\r\n        {\r\n            static unsigned char test(Ch ch)\r\n            {\r\n                return internal::lookup_tables<0>::lookup_text_pure_with_ws[static_cast<unsigned char>(ch)];\r\n            }\r\n        };\r\n\r\n        // Detect attribute value character\r\n        template<Ch Quote>\r\n        struct attribute_value_pred\r\n        {\r\n            static unsigned char test(Ch ch)\r\n            {\r\n                if (Quote == Ch('\\''))\r\n                    return internal::lookup_tables<0>::lookup_attribute_data_1[static_cast<unsigned char>(ch)];\r\n                if (Quote == Ch('\\\"'))\r\n                    return internal::lookup_tables<0>::lookup_attribute_data_2[static_cast<unsigned char>(ch)];\r\n                return 0;       // Should never be executed, to avoid warnings on Comeau\r\n            }\r\n        };\r\n\r\n        // Detect attribute value character\r\n        template<Ch Quote>\r\n        struct attribute_value_pure_pred\r\n        {\r\n            static unsigned char test(Ch ch)\r\n            {\r\n                if (Quote == Ch('\\''))\r\n                    return internal::lookup_tables<0>::lookup_attribute_data_1_pure[static_cast<unsigned char>(ch)];\r\n                if (Quote == Ch('\\\"'))\r\n                    return internal::lookup_tables<0>::lookup_attribute_data_2_pure[static_cast<unsigned char>(ch)];\r\n                return 0;       // Should never be executed, to avoid warnings on Comeau\r\n            }\r\n        };\r\n\r\n        // Insert coded character, using UTF8 or 8-bit ASCII\r\n        template<int Flags>\r\n        static void insert_coded_character(Ch *&text, unsigned long code)\r\n        {\r\n            if (Flags & parse_no_utf8)\r\n            {\r\n                // Insert 8-bit ASCII character\r\n                // Todo: possibly verify that code is less than 256 and use replacement char otherwise?\r\n                text[0] = static_cast<unsigned char>(code);\r\n                text += 1;\r\n            }\r\n            else\r\n            {\r\n                // Insert UTF8 sequence\r\n                if (code < 0x80)    // 1 byte sequence\r\n                {\r\n\t                text[0] = static_cast<unsigned char>(code);\r\n                    text += 1;\r\n                }\r\n                else if (code < 0x800)  // 2 byte sequence\r\n                {\r\n\t                text[1] = static_cast<unsigned char>((code | 0x80) & 0xBF); code >>= 6;\r\n\t                text[0] = static_cast<unsigned char>(code | 0xC0);\r\n                    text += 2;\r\n                }\r\n\t            else if (code < 0x10000)    // 3 byte sequence\r\n                {\r\n\t                text[2] = static_cast<unsigned char>((code | 0x80) & 0xBF); code >>= 6;\r\n\t                text[1] = static_cast<unsigned char>((code | 0x80) & 0xBF); code >>= 6;\r\n\t                text[0] = static_cast<unsigned char>(code | 0xE0);\r\n                    text += 3;\r\n                }\r\n\t            else if (code < 0x110000)   // 4 byte sequence\r\n                {\r\n\t                text[3] = static_cast<unsigned char>((code | 0x80) & 0xBF); code >>= 6;\r\n\t                text[2] = static_cast<unsigned char>((code | 0x80) & 0xBF); code >>= 6;\r\n\t                text[1] = static_cast<unsigned char>((code | 0x80) & 0xBF); code >>= 6;\r\n\t                text[0] = static_cast<unsigned char>(code | 0xF0);\r\n                    text += 4;\r\n                }\r\n                else    // Invalid, only codes up to 0x10FFFF are allowed in Unicode\r\n                {\r\n                    RAPIDXML_PARSE_ERROR(\"invalid numeric character entity\", text);\r\n                }\r\n            }\r\n        }\r\n\r\n        // Skip characters until predicate evaluates to true\r\n        template<class StopPred, int Flags>\r\n        static void skip(Ch *&text)\r\n        {\r\n            Ch *tmp = text;\r\n            while (StopPred::test(*tmp))\r\n                ++tmp;\r\n            text = tmp;\r\n        }\r\n\r\n        // Skip characters until predicate evaluates to true while doing the following:\r\n        // - replacing XML character entity references with proper characters (&apos; &amp; &quot; &lt; &gt; &#...;)\r\n        // - condensing whitespace sequences to single space character\r\n        template<class StopPred, class StopPredPure, int Flags>\r\n        static Ch *skip_and_expand_character_refs(Ch *&text)\r\n        {\r\n            // If entity translation, whitespace condense and whitespace trimming is disabled, use plain skip\r\n            if (Flags & parse_no_entity_translation && \r\n                !(Flags & parse_normalize_whitespace) &&\r\n                !(Flags & parse_trim_whitespace))\r\n            {\r\n                skip<StopPred, Flags>(text);\r\n                return text;\r\n            }\r\n            \r\n            // Use simple skip until first modification is detected\r\n            skip<StopPredPure, Flags>(text);\r\n\r\n            // Use translation skip\r\n            Ch *src = text;\r\n            Ch *dest = src;\r\n            while (StopPred::test(*src))\r\n            {\r\n                // If entity translation is enabled    \r\n                if (!(Flags & parse_no_entity_translation))\r\n                {\r\n                    // Test if replacement is needed\r\n                    if (src[0] == Ch('&'))\r\n                    {\r\n                        switch (src[1])\r\n                        {\r\n\r\n                        // &amp; &apos;\r\n                        case Ch('a'): \r\n                            if (src[2] == Ch('m') && src[3] == Ch('p') && src[4] == Ch(';'))\r\n                            {\r\n                                *dest = Ch('&');\r\n                                ++dest;\r\n                                src += 5;\r\n                                continue;\r\n                            }\r\n                            if (src[2] == Ch('p') && src[3] == Ch('o') && src[4] == Ch('s') && src[5] == Ch(';'))\r\n                            {\r\n                                *dest = Ch('\\'');\r\n                                ++dest;\r\n                                src += 6;\r\n                                continue;\r\n                            }\r\n                            break;\r\n\r\n                        // &quot;\r\n                        case Ch('q'): \r\n                            if (src[2] == Ch('u') && src[3] == Ch('o') && src[4] == Ch('t') && src[5] == Ch(';'))\r\n                            {\r\n                                *dest = Ch('\"');\r\n                                ++dest;\r\n                                src += 6;\r\n                                continue;\r\n                            }\r\n                            break;\r\n\r\n                        // &gt;\r\n                        case Ch('g'): \r\n                            if (src[2] == Ch('t') && src[3] == Ch(';'))\r\n                            {\r\n                                *dest = Ch('>');\r\n                                ++dest;\r\n                                src += 4;\r\n                                continue;\r\n                            }\r\n                            break;\r\n\r\n                        // &lt;\r\n                        case Ch('l'): \r\n                            if (src[2] == Ch('t') && src[3] == Ch(';'))\r\n                            {\r\n                                *dest = Ch('<');\r\n                                ++dest;\r\n                                src += 4;\r\n                                continue;\r\n                            }\r\n                            break;\r\n\r\n                        // &#...; - assumes ASCII\r\n                        case Ch('#'): \r\n                            if (src[2] == Ch('x'))\r\n                            {\r\n                                unsigned long code = 0;\r\n                                src += 3;   // Skip &#x\r\n                                while (1)\r\n                                {\r\n                                    unsigned char digit = internal::lookup_tables<0>::lookup_digits[static_cast<unsigned char>(*src)];\r\n                                    if (digit == 0xFF)\r\n                                        break;\r\n                                    code = code * 16 + digit;\r\n                                    ++src;\r\n                                }\r\n                                insert_coded_character<Flags>(dest, code);    // Put character in output\r\n                            }\r\n                            else\r\n                            {\r\n                                unsigned long code = 0;\r\n                                src += 2;   // Skip &#\r\n                                while (1)\r\n                                {\r\n                                    unsigned char digit = internal::lookup_tables<0>::lookup_digits[static_cast<unsigned char>(*src)];\r\n                                    if (digit == 0xFF)\r\n                                        break;\r\n                                    code = code * 10 + digit;\r\n                                    ++src;\r\n                                }\r\n                                insert_coded_character<Flags>(dest, code);    // Put character in output\r\n                            }\r\n                            if (*src == Ch(';'))\r\n                                ++src;\r\n                            else\r\n                                RAPIDXML_PARSE_ERROR(\"expected ;\", src);\r\n                            continue;\r\n\r\n                        // Something else\r\n                        default:\r\n                            // Ignore, just copy '&' verbatim\r\n                            break;\r\n\r\n                        }\r\n                    }\r\n                }\r\n                \r\n                // If whitespace condensing is enabled\r\n                if (Flags & parse_normalize_whitespace)\r\n                {\r\n                    // Test if condensing is needed                 \r\n                    if (whitespace_pred::test(*src))\r\n                    {\r\n                        *dest = Ch(' '); ++dest;    // Put single space in dest\r\n                        ++src;                      // Skip first whitespace char\r\n                        // Skip remaining whitespace chars\r\n                        while (whitespace_pred::test(*src))\r\n                            ++src;\r\n                        continue;\r\n                    }\r\n                }\r\n\r\n                // No replacement, only copy character\r\n                *dest++ = *src++;\r\n\r\n            }\r\n\r\n            // Return new end\r\n            text = src;\r\n            return dest;\r\n\r\n        }\r\n\r\n        ///////////////////////////////////////////////////////////////////////\r\n        // Internal parsing functions\r\n        \r\n        // Parse BOM, if any\r\n        template<int Flags>\r\n        void parse_bom(Ch *&text)\r\n        {\r\n            // UTF-8?\r\n            if (static_cast<unsigned char>(text[0]) == 0xEF && \r\n                static_cast<unsigned char>(text[1]) == 0xBB && \r\n                static_cast<unsigned char>(text[2]) == 0xBF)\r\n            {\r\n                text += 3;      // Skup utf-8 bom\r\n            }\r\n        }\r\n\r\n        // Parse XML declaration (<?xml...)\r\n        template<int Flags>\r\n        xml_node<Ch> *parse_xml_declaration(Ch *&text)\r\n        {\r\n            // If parsing of declaration is disabled\r\n            if (!(Flags & parse_declaration_node))\r\n            {\r\n                // Skip until end of declaration\r\n                while (text[0] != Ch('?') || text[1] != Ch('>'))\r\n                {\r\n                    if (!text[0])\r\n                        RAPIDXML_PARSE_ERROR(\"unexpected end of data\", text);\r\n                    ++text;\r\n                }\r\n                text += 2;    // Skip '?>'\r\n                return 0;\r\n            }\r\n\r\n            // Create declaration\r\n            xml_node<Ch> *declaration = this->allocate_node(node_declaration);\r\n\r\n            // Skip whitespace before attributes or ?>\r\n            skip<whitespace_pred, Flags>(text);\r\n\r\n            // Parse declaration attributes\r\n            parse_node_attributes<Flags>(text, declaration);\r\n            \r\n            // Skip ?>\r\n            if (text[0] != Ch('?') || text[1] != Ch('>'))\r\n                RAPIDXML_PARSE_ERROR(\"expected ?>\", text);\r\n            text += 2;\r\n            \r\n            return declaration;\r\n        }\r\n\r\n        // Parse XML comment (<!--...)\r\n        template<int Flags>\r\n        xml_node<Ch> *parse_comment(Ch *&text)\r\n        {\r\n            // If parsing of comments is disabled\r\n            if (!(Flags & parse_comment_nodes))\r\n            {\r\n                // Skip until end of comment\r\n                while (text[0] != Ch('-') || text[1] != Ch('-') || text[2] != Ch('>'))\r\n                {\r\n                    if (!text[0])\r\n                        RAPIDXML_PARSE_ERROR(\"unexpected end of data\", text);\r\n                    ++text;\r\n                }\r\n                text += 3;     // Skip '-->'\r\n                return 0;      // Do not produce comment node\r\n            }\r\n\r\n            // Remember value start\r\n            Ch *value = text;\r\n\r\n            // Skip until end of comment\r\n            while (text[0] != Ch('-') || text[1] != Ch('-') || text[2] != Ch('>'))\r\n            {\r\n                if (!text[0])\r\n                    RAPIDXML_PARSE_ERROR(\"unexpected end of data\", text);\r\n                ++text;\r\n            }\r\n\r\n            // Create comment node\r\n            xml_node<Ch> *comment = this->allocate_node(node_comment);\r\n            comment->value(value, text - value);\r\n            \r\n            // Place zero terminator after comment value\r\n            if (!(Flags & parse_no_string_terminators))\r\n                *text = Ch('\\0');\r\n            \r\n            text += 3;     // Skip '-->'\r\n            return comment;\r\n        }\r\n\r\n        // Parse DOCTYPE\r\n        template<int Flags>\r\n        xml_node<Ch> *parse_doctype(Ch *&text)\r\n        {\r\n            // Remember value start\r\n            Ch *value = text;\r\n\r\n            // Skip to >\r\n            while (*text != Ch('>'))\r\n            {\r\n                // Determine character type\r\n                switch (*text)\r\n                {\r\n                \r\n                // If '[' encountered, scan for matching ending ']' using naive algorithm with depth\r\n                // This works for all W3C test files except for 2 most wicked\r\n                case Ch('['):\r\n                {\r\n                    ++text;     // Skip '['\r\n                    int depth = 1;\r\n                    while (depth > 0)\r\n                    {\r\n                        switch (*text)\r\n                        {\r\n                            case Ch('['): ++depth; break;\r\n                            case Ch(']'): --depth; break;\r\n                            case 0: RAPIDXML_PARSE_ERROR(\"unexpected end of data\", text);\r\n                        }\r\n                        ++text;\r\n                    }\r\n                    break;\r\n                }\r\n                \r\n                // Error on end of text\r\n                case Ch('\\0'):\r\n                    RAPIDXML_PARSE_ERROR(\"unexpected end of data\", text);\r\n                \r\n                // Other character, skip it\r\n                default:\r\n                    ++text;\r\n\r\n                }\r\n            }\r\n            \r\n            // If DOCTYPE nodes enabled\r\n            if (Flags & parse_doctype_node)\r\n            {\r\n                // Create a new doctype node\r\n                xml_node<Ch> *doctype = this->allocate_node(node_doctype);\r\n                doctype->value(value, text - value);\r\n                \r\n                // Place zero terminator after value\r\n                if (!(Flags & parse_no_string_terminators))\r\n                    *text = Ch('\\0');\r\n\r\n                text += 1;      // skip '>'\r\n                return doctype;\r\n            }\r\n            else\r\n            {\r\n                text += 1;      // skip '>'\r\n                return 0;\r\n            }\r\n\r\n        }\r\n\r\n        // Parse PI\r\n        template<int Flags>\r\n        xml_node<Ch> *parse_pi(Ch *&text)\r\n        {\r\n            // If creation of PI nodes is enabled\r\n            if (Flags & parse_pi_nodes)\r\n            {\r\n                // Create pi node\r\n                xml_node<Ch> *pi = this->allocate_node(node_pi);\r\n\r\n                // Extract PI target name\r\n                Ch *name = text;\r\n                skip<node_name_pred, Flags>(text);\r\n                if (text == name)\r\n                    RAPIDXML_PARSE_ERROR(\"expected PI target\", text);\r\n                pi->name(name, text - name);\r\n                \r\n                // Skip whitespace between pi target and pi\r\n                skip<whitespace_pred, Flags>(text);\r\n\r\n                // Remember start of pi\r\n                Ch *value = text;\r\n                \r\n                // Skip to '?>'\r\n                while (text[0] != Ch('?') || text[1] != Ch('>'))\r\n                {\r\n                    if (*text == Ch('\\0'))\r\n                        RAPIDXML_PARSE_ERROR(\"unexpected end of data\", text);\r\n                    ++text;\r\n                }\r\n\r\n                // Set pi value (verbatim, no entity expansion or whitespace normalization)\r\n                pi->value(value, text - value);     \r\n                \r\n                // Place zero terminator after name and value\r\n                if (!(Flags & parse_no_string_terminators))\r\n                {\r\n                    pi->name()[pi->name_size()] = Ch('\\0');\r\n                    pi->value()[pi->value_size()] = Ch('\\0');\r\n                }\r\n                \r\n                text += 2;                          // Skip '?>'\r\n                return pi;\r\n            }\r\n            else\r\n            {\r\n                // Skip to '?>'\r\n                while (text[0] != Ch('?') || text[1] != Ch('>'))\r\n                {\r\n                    if (*text == Ch('\\0'))\r\n                        RAPIDXML_PARSE_ERROR(\"unexpected end of data\", text);\r\n                    ++text;\r\n                }\r\n                text += 2;    // Skip '?>'\r\n                return 0;\r\n            }\r\n        }\r\n\r\n        // Parse and append data\r\n        // Return character that ends data.\r\n        // This is necessary because this character might have been overwritten by a terminating 0\r\n        template<int Flags>\r\n        Ch parse_and_append_data(xml_node<Ch> *node, Ch *&text, Ch *contents_start)\r\n        {\r\n            // Backup to contents start if whitespace trimming is disabled\r\n            if (!(Flags & parse_trim_whitespace))\r\n                text = contents_start;     \r\n            \r\n            // Skip until end of data\r\n            Ch *value = text, *end;\r\n            if (Flags & parse_normalize_whitespace)\r\n                end = skip_and_expand_character_refs<text_pred, text_pure_with_ws_pred, Flags>(text);   \r\n            else\r\n                end = skip_and_expand_character_refs<text_pred, text_pure_no_ws_pred, Flags>(text);\r\n\r\n            // Trim trailing whitespace if flag is set; leading was already trimmed by whitespace skip after >\r\n            if (Flags & parse_trim_whitespace)\r\n            {\r\n                if (Flags & parse_normalize_whitespace)\r\n                {\r\n                    // Whitespace is already condensed to single space characters by skipping function, so just trim 1 char off the end\r\n                    if (*(end - 1) == Ch(' '))\r\n                        --end;\r\n                }\r\n                else\r\n                {\r\n                    // Backup until non-whitespace character is found\r\n                    while (whitespace_pred::test(*(end - 1)))\r\n                        --end;\r\n                }\r\n            }\r\n            \r\n            // If characters are still left between end and value (this test is only necessary if normalization is enabled)\r\n            // Create new data node\r\n            if (!(Flags & parse_no_data_nodes))\r\n            {\r\n                xml_node<Ch> *data = this->allocate_node(node_data);\r\n                data->value(value, end - value);\r\n                node->append_node(data);\r\n            }\r\n\r\n            // Add data to parent node if no data exists yet\r\n            if (!(Flags & parse_no_element_values)) \r\n                if (*node->value() == Ch('\\0'))\r\n                    node->value(value, end - value);\r\n\r\n            // Place zero terminator after value\r\n            if (!(Flags & parse_no_string_terminators))\r\n            {\r\n                Ch ch = *text;\r\n                *end = Ch('\\0');\r\n                return ch;      // Return character that ends data; this is required because zero terminator overwritten it\r\n            }\r\n\r\n            // Return character that ends data\r\n            return *text;\r\n        }\r\n\r\n        // Parse CDATA\r\n        template<int Flags>\r\n        xml_node<Ch> *parse_cdata(Ch *&text)\r\n        {\r\n            // If CDATA is disabled\r\n            if (Flags & parse_no_data_nodes)\r\n            {\r\n                // Skip until end of cdata\r\n                while (text[0] != Ch(']') || text[1] != Ch(']') || text[2] != Ch('>'))\r\n                {\r\n                    if (!text[0])\r\n                        RAPIDXML_PARSE_ERROR(\"unexpected end of data\", text);\r\n                    ++text;\r\n                }\r\n                text += 3;      // Skip ]]>\r\n                return 0;       // Do not produce CDATA node\r\n            }\r\n\r\n            // Skip until end of cdata\r\n            Ch *value = text;\r\n            while (text[0] != Ch(']') || text[1] != Ch(']') || text[2] != Ch('>'))\r\n            {\r\n                if (!text[0])\r\n                    RAPIDXML_PARSE_ERROR(\"unexpected end of data\", text);\r\n                ++text;\r\n            }\r\n\r\n            // Create new cdata node\r\n            xml_node<Ch> *cdata = this->allocate_node(node_cdata);\r\n            cdata->value(value, text - value);\r\n\r\n            // Place zero terminator after value\r\n            if (!(Flags & parse_no_string_terminators))\r\n                *text = Ch('\\0');\r\n\r\n            text += 3;      // Skip ]]>\r\n            return cdata;\r\n        }\r\n        \r\n        // Parse element node\r\n        template<int Flags>\r\n        xml_node<Ch> *parse_element(Ch *&text)\r\n        {\r\n            // Create element node\r\n            xml_node<Ch> *element = this->allocate_node(node_element);\r\n\r\n            // Extract element name\r\n            Ch *name = text;\r\n            skip<node_name_pred, Flags>(text);\r\n            if (text == name)\r\n                RAPIDXML_PARSE_ERROR(\"expected element name\", text);\r\n            element->name(name, text - name);\r\n            \r\n            // Skip whitespace between element name and attributes or >\r\n            skip<whitespace_pred, Flags>(text);\r\n\r\n            // Parse attributes, if any\r\n            parse_node_attributes<Flags>(text, element);\r\n\r\n            // Determine ending type\r\n            if (*text == Ch('>'))\r\n            {\r\n                ++text;\r\n                parse_node_contents<Flags>(text, element);\r\n            }\r\n            else if (*text == Ch('/'))\r\n            {\r\n                ++text;\r\n                if (*text != Ch('>'))\r\n                    RAPIDXML_PARSE_ERROR(\"expected >\", text);\r\n                ++text;\r\n            }\r\n            else\r\n                RAPIDXML_PARSE_ERROR(\"expected >\", text);\r\n\r\n            // Place zero terminator after name\r\n            if (!(Flags & parse_no_string_terminators))\r\n                element->name()[element->name_size()] = Ch('\\0');\r\n\r\n            // Return parsed element\r\n            return element;\r\n        }\r\n\r\n        // Determine node type, and parse it\r\n        template<int Flags>\r\n        xml_node<Ch> *parse_node(Ch *&text)\r\n        {\r\n            // Parse proper node type\r\n            switch (text[0])\r\n            {\r\n\r\n            // <...\r\n            default: \r\n                // Parse and append element node\r\n                return parse_element<Flags>(text);\r\n\r\n            // <?...\r\n            case Ch('?'): \r\n                ++text;     // Skip ?\r\n                if ((text[0] == Ch('x') || text[0] == Ch('X')) &&\r\n                    (text[1] == Ch('m') || text[1] == Ch('M')) && \r\n                    (text[2] == Ch('l') || text[2] == Ch('L')) &&\r\n                    whitespace_pred::test(text[3]))\r\n                {\r\n                    // '<?xml ' - xml declaration\r\n                    text += 4;      // Skip 'xml '\r\n                    return parse_xml_declaration<Flags>(text);\r\n                }\r\n                else\r\n                {\r\n                    // Parse PI\r\n                    return parse_pi<Flags>(text);\r\n                }\r\n            \r\n            // <!...\r\n            case Ch('!'): \r\n\r\n                // Parse proper subset of <! node\r\n                switch (text[1])    \r\n                {\r\n                \r\n                // <!-\r\n                case Ch('-'):\r\n                    if (text[2] == Ch('-'))\r\n                    {\r\n                        // '<!--' - xml comment\r\n                        text += 3;     // Skip '!--'\r\n                        return parse_comment<Flags>(text);\r\n                    }\r\n                    break;\r\n\r\n                // <![\r\n                case Ch('['):\r\n                    if (text[2] == Ch('C') && text[3] == Ch('D') && text[4] == Ch('A') && \r\n                        text[5] == Ch('T') && text[6] == Ch('A') && text[7] == Ch('['))\r\n                    {\r\n                        // '<![CDATA[' - cdata\r\n                        text += 8;     // Skip '![CDATA['\r\n                        return parse_cdata<Flags>(text);\r\n                    }\r\n                    break;\r\n\r\n                // <!D\r\n                case Ch('D'):\r\n                    if (text[2] == Ch('O') && text[3] == Ch('C') && text[4] == Ch('T') && \r\n                        text[5] == Ch('Y') && text[6] == Ch('P') && text[7] == Ch('E') && \r\n                        whitespace_pred::test(text[8]))\r\n                    {\r\n                        // '<!DOCTYPE ' - doctype\r\n                        text += 9;      // skip '!DOCTYPE '\r\n                        return parse_doctype<Flags>(text);\r\n                    }\r\n\r\n                }   // switch\r\n\r\n                // Attempt to skip other, unrecognized node types starting with <!\r\n                ++text;     // Skip !\r\n                while (*text != Ch('>'))\r\n                {\r\n                    if (*text == 0)\r\n                        RAPIDXML_PARSE_ERROR(\"unexpected end of data\", text);\r\n                    ++text;\r\n                }\r\n                ++text;     // Skip '>'\r\n                return 0;   // No node recognized\r\n\r\n            }\r\n        }\r\n\r\n        // Parse contents of the node - children, data etc.\r\n        template<int Flags>\r\n        void parse_node_contents(Ch *&text, xml_node<Ch> *node)\r\n        {\r\n            // For all children and text\r\n            while (1)\r\n            {\r\n                // Skip whitespace between > and node contents\r\n                Ch *contents_start = text;      // Store start of node contents before whitespace is skipped\r\n                skip<whitespace_pred, Flags>(text);\r\n                Ch next_char = *text;\r\n\r\n            // After data nodes, instead of continuing the loop, control jumps here.\r\n            // This is because zero termination inside parse_and_append_data() function\r\n            // would wreak havoc with the above code.\r\n            // Also, skipping whitespace after data nodes is unnecessary.\r\n            after_data_node:    \r\n                \r\n                // Determine what comes next: node closing, child node, data node, or 0?\r\n                switch (next_char)\r\n                {\r\n                \r\n                // Node closing or child node\r\n                case Ch('<'):\r\n                    if (text[1] == Ch('/'))\r\n                    {\r\n                        // Node closing\r\n                        text += 2;      // Skip '</'\r\n                        if (Flags & parse_validate_closing_tags)\r\n                        {\r\n                            // Skip and validate closing tag name\r\n                            Ch *closing_name = text;\r\n                            skip<node_name_pred, Flags>(text);\r\n                            if (!internal::compare(node->name(), node->name_size(), closing_name, text - closing_name, true))\r\n                                RAPIDXML_PARSE_ERROR(\"invalid closing tag name\", text);\r\n                        }\r\n                        else\r\n                        {\r\n                            // No validation, just skip name\r\n                            skip<node_name_pred, Flags>(text);\r\n                        }\r\n                        // Skip remaining whitespace after node name\r\n                        skip<whitespace_pred, Flags>(text);\r\n                        if (*text != Ch('>'))\r\n                            RAPIDXML_PARSE_ERROR(\"expected >\", text);\r\n                        ++text;     // Skip '>'\r\n                        return;     // Node closed, finished parsing contents\r\n                    }\r\n                    else\r\n                    {\r\n                        // Child node\r\n                        ++text;     // Skip '<'\r\n                        if (xml_node<Ch> *child = parse_node<Flags>(text))\r\n                            node->append_node(child);\r\n                    }\r\n                    break;\r\n\r\n                // End of data - error\r\n                case Ch('\\0'):\r\n                    RAPIDXML_PARSE_ERROR(\"unexpected end of data\", text);\r\n\r\n                // Data node\r\n                default:\r\n                    next_char = parse_and_append_data<Flags>(node, text, contents_start);\r\n                    goto after_data_node;   // Bypass regular processing after data nodes\r\n\r\n                }\r\n            }\r\n        }\r\n        \r\n        // Parse XML attributes of the node\r\n        template<int Flags>\r\n        void parse_node_attributes(Ch *&text, xml_node<Ch> *node)\r\n        {\r\n            // For all attributes \r\n            while (attribute_name_pred::test(*text))\r\n            {\r\n                // Extract attribute name\r\n                Ch *name = text;\r\n                ++text;     // Skip first character of attribute name\r\n                skip<attribute_name_pred, Flags>(text);\r\n                if (text == name)\r\n                    RAPIDXML_PARSE_ERROR(\"expected attribute name\", name);\r\n\r\n                // Create new attribute\r\n                xml_attribute<Ch> *attribute = this->allocate_attribute();\r\n                attribute->name(name, text - name);\r\n                node->append_attribute(attribute);\r\n\r\n                // Skip whitespace after attribute name\r\n                skip<whitespace_pred, Flags>(text);\r\n\r\n                // Skip =\r\n                if (*text != Ch('='))\r\n                    RAPIDXML_PARSE_ERROR(\"expected =\", text);\r\n                ++text;\r\n\r\n                // Add terminating zero after name\r\n                if (!(Flags & parse_no_string_terminators))\r\n                    attribute->name()[attribute->name_size()] = 0;\r\n\r\n                // Skip whitespace after =\r\n                skip<whitespace_pred, Flags>(text);\r\n\r\n                // Skip quote and remember if it was ' or \"\r\n                Ch quote = *text;\r\n                if (quote != Ch('\\'') && quote != Ch('\"'))\r\n                    RAPIDXML_PARSE_ERROR(\"expected ' or \\\"\", text);\r\n                ++text;\r\n\r\n                // Extract attribute value and expand char refs in it\r\n                Ch *value = text, *end;\r\n                const int AttFlags = Flags & ~parse_normalize_whitespace;   // No whitespace normalization in attributes\r\n                if (quote == Ch('\\''))\r\n                    end = skip_and_expand_character_refs<attribute_value_pred<Ch('\\'')>, attribute_value_pure_pred<Ch('\\'')>, AttFlags>(text);\r\n                else\r\n                    end = skip_and_expand_character_refs<attribute_value_pred<Ch('\"')>, attribute_value_pure_pred<Ch('\"')>, AttFlags>(text);\r\n                \r\n                // Set attribute value\r\n                attribute->value(value, end - value);\r\n                \r\n                // Make sure that end quote is present\r\n                if (*text != quote)\r\n                    RAPIDXML_PARSE_ERROR(\"expected ' or \\\"\", text);\r\n                ++text;     // Skip quote\r\n\r\n                // Add terminating zero after value\r\n                if (!(Flags & parse_no_string_terminators))\r\n                    attribute->value()[attribute->value_size()] = 0;\r\n\r\n                // Skip whitespace after attribute value\r\n                skip<whitespace_pred, Flags>(text);\r\n            }\r\n        }\r\n\r\n    };\r\n\r\n    //! \\cond internal\r\n    namespace internal\r\n    {\r\n\r\n        // Whitespace (space \\n \\r \\t)\r\n        template<int Dummy>\r\n        const unsigned char lookup_tables<Dummy>::lookup_whitespace[256] = \r\n        {\r\n          // 0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F\r\n             0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  1,  0,  0,  1,  0,  0,  // 0\r\n             0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  // 1\r\n             1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  // 2\r\n             0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  // 3\r\n             0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  // 4\r\n             0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  // 5\r\n             0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  // 6\r\n             0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  // 7\r\n             0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  // 8\r\n             0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  // 9\r\n             0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  // A\r\n             0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  // B\r\n             0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  // C\r\n             0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  // D\r\n             0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  // E\r\n             0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0   // F\r\n        };\r\n\r\n        // Node name (anything but space \\n \\r \\t / > ? \\0)\r\n        template<int Dummy>\r\n        const unsigned char lookup_tables<Dummy>::lookup_node_name[256] = \r\n        {\r\n          // 0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F\r\n             0,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  1,  1,  0,  1,  1,  // 0\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 1\r\n             0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  // 2\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  // 3\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 4\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 5\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 6\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 7\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 8\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 9\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // A\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // B\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // C\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // D\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // E\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1   // F\r\n        };\r\n\r\n        // Text (i.e. PCDATA) (anything but < \\0)\r\n        template<int Dummy>\r\n        const unsigned char lookup_tables<Dummy>::lookup_text[256] = \r\n        {\r\n          // 0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F\r\n             0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 0\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 1\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 2\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  1,  1,  1,  // 3\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 4\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 5\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 6\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 7\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 8\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 9\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // A\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // B\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // C\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // D\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // E\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1   // F\r\n        };\r\n\r\n        // Text (i.e. PCDATA) that does not require processing when ws normalization is disabled \r\n        // (anything but < \\0 &)\r\n        template<int Dummy>\r\n        const unsigned char lookup_tables<Dummy>::lookup_text_pure_no_ws[256] = \r\n        {\r\n          // 0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F\r\n             0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 0\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 1\r\n             1,  1,  1,  1,  1,  1,  0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 2\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  1,  1,  1,  // 3\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 4\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 5\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 6\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 7\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 8\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 9\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // A\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // B\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // C\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // D\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // E\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1   // F\r\n        };\r\n\r\n        // Text (i.e. PCDATA) that does not require processing when ws normalizationis is enabled\r\n        // (anything but < \\0 & space \\n \\r \\t)\r\n        template<int Dummy>\r\n        const unsigned char lookup_tables<Dummy>::lookup_text_pure_with_ws[256] = \r\n        {\r\n          // 0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F\r\n             0,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  1,  1,  0,  1,  1,  // 0\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 1\r\n             0,  1,  1,  1,  1,  1,  0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 2\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  1,  1,  1,  // 3\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 4\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 5\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 6\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 7\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 8\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 9\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // A\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // B\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // C\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // D\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // E\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1   // F\r\n        };\r\n\r\n        // Attribute name (anything but space \\n \\r \\t / < > = ? ! \\0)\r\n        template<int Dummy>\r\n        const unsigned char lookup_tables<Dummy>::lookup_attribute_name[256] = \r\n        {\r\n          // 0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F\r\n             0,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  1,  1,  0,  1,  1,  // 0\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 1\r\n             0,  0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  // 2\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  // 3\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 4\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 5\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 6\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 7\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 8\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 9\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // A\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // B\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // C\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // D\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // E\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1   // F\r\n        };\r\n\r\n        // Attribute data with single quote (anything but ' \\0)\r\n        template<int Dummy>\r\n        const unsigned char lookup_tables<Dummy>::lookup_attribute_data_1[256] = \r\n        {\r\n          // 0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F\r\n             0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 0\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 1\r\n             1,  1,  1,  1,  1,  1,  1,  0,  1,  1,  1,  1,  1,  1,  1,  1,  // 2\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 3\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 4\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 5\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 6\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 7\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 8\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 9\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // A\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // B\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // C\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // D\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // E\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1   // F\r\n        };\r\n\r\n        // Attribute data with single quote that does not require processing (anything but ' \\0 &)\r\n        template<int Dummy>\r\n        const unsigned char lookup_tables<Dummy>::lookup_attribute_data_1_pure[256] = \r\n        {\r\n          // 0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F\r\n             0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 0\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 1\r\n             1,  1,  1,  1,  1,  1,  0,  0,  1,  1,  1,  1,  1,  1,  1,  1,  // 2\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 3\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 4\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 5\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 6\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 7\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 8\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 9\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // A\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // B\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // C\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // D\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // E\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1   // F\r\n        };\r\n\r\n        // Attribute data with double quote (anything but \" \\0)\r\n        template<int Dummy>\r\n        const unsigned char lookup_tables<Dummy>::lookup_attribute_data_2[256] = \r\n        {\r\n          // 0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F\r\n             0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 0\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 1\r\n             1,  1,  0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 2\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 3\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 4\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 5\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 6\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 7\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 8\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 9\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // A\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // B\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // C\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // D\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // E\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1   // F\r\n        };\r\n\r\n        // Attribute data with double quote that does not require processing (anything but \" \\0 &)\r\n        template<int Dummy>\r\n        const unsigned char lookup_tables<Dummy>::lookup_attribute_data_2_pure[256] = \r\n        {\r\n          // 0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F\r\n             0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 0\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 1\r\n             1,  1,  0,  1,  1,  1,  0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 2\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 3\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 4\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 5\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 6\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 7\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 8\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 9\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // A\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // B\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // C\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // D\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // E\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1   // F\r\n        };\r\n\r\n        // Digits (dec and hex, 255 denotes end of numeric character reference)\r\n        template<int Dummy>\r\n        const unsigned char lookup_tables<Dummy>::lookup_digits[256] = \r\n        {\r\n          // 0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F\r\n           255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  // 0\r\n           255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  // 1\r\n           255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  // 2\r\n             0,  1,  2,  3,  4,  5,  6,  7,  8,  9,255,255,255,255,255,255,  // 3\r\n           255, 10, 11, 12, 13, 14, 15,255,255,255,255,255,255,255,255,255,  // 4\r\n           255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  // 5\r\n           255, 10, 11, 12, 13, 14, 15,255,255,255,255,255,255,255,255,255,  // 6\r\n           255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  // 7\r\n           255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  // 8\r\n           255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  // 9\r\n           255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  // A\r\n           255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  // B\r\n           255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  // C\r\n           255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  // D\r\n           255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  // E\r\n           255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255   // F\r\n        };\r\n    \r\n        // Upper case conversion\r\n        template<int Dummy>\r\n        const unsigned char lookup_tables<Dummy>::lookup_upcase[256] = \r\n        {\r\n          // 0,  1,  2,  3,  4,  5,  6,  7,  8,  9,  A   B   C   D   E   F\r\n           0,  1,  2,  3,  4,  5,  6,  7,  8,  9,  10, 11, 12, 13, 14, 15,   // 0\r\n           16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,   // 1\r\n           32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,   // 2\r\n           48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,   // 3\r\n           64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,   // 4\r\n           80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,   // 5\r\n           96, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,   // 6\r\n           80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 123,124,125,126,127,  // 7\r\n           128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,  // 8\r\n           144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,  // 9\r\n           160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,  // A\r\n           176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,  // B\r\n           192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,  // C\r\n           208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,  // D\r\n           224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,  // E\r\n           240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255   // F\r\n        };\r\n    }\r\n    //! \\endcond\r\n\r\n}\r\n\r\n// Undefine internal macros\r\n#undef RAPIDXML_PARSE_ERROR\r\n\r\n// On MSVC, restore warnings state\r\n#ifdef _MSC_VER\r\n    #pragma warning(pop)\r\n#endif\r\n\r\n#endif\r\n"
  },
  {
    "path": "Libraries/Core/Android/Headers/rapidxml/rapidxml_iterators.hpp",
    "content": "#ifndef RAPIDXML_ITERATORS_HPP_INCLUDED\r\n#define RAPIDXML_ITERATORS_HPP_INCLUDED\r\n\r\n// Copyright (C) 2006, 2009 Marcin Kalicinski\r\n// Version 1.13\r\n// Revision $DateTime: 2009/05/13 01:46:17 $\r\n//! \\file rapidxml_iterators.hpp This file contains rapidxml iterators\r\n\r\n#include \"rapidxml.hpp\"\r\n\r\nnamespace rapidxml\r\n{\r\n\r\n    //! Iterator of child nodes of xml_node\r\n    template<class Ch>\r\n    class node_iterator\r\n    {\r\n    \r\n    public:\r\n\r\n        typedef typename xml_node<Ch> value_type;\r\n        typedef typename xml_node<Ch> &reference;\r\n        typedef typename xml_node<Ch> *pointer;\r\n        typedef std::ptrdiff_t difference_type;\r\n        typedef std::bidirectional_iterator_tag iterator_category;\r\n        \r\n        node_iterator()\r\n            : m_node(0)\r\n        {\r\n        }\r\n\r\n        node_iterator(xml_node<Ch> *node)\r\n            : m_node(node->first_node())\r\n        {\r\n        }\r\n        \r\n        reference operator *() const\r\n        {\r\n            assert(m_node);\r\n            return *m_node;\r\n        }\r\n\r\n        pointer operator->() const\r\n        {\r\n            assert(m_node);\r\n            return m_node;\r\n        }\r\n\r\n        node_iterator& operator++()\r\n        {\r\n            assert(m_node);\r\n            m_node = m_node->next_sibling();\r\n            return *this;\r\n        }\r\n\r\n        node_iterator operator++(int)\r\n        {\r\n            node_iterator tmp = *this;\r\n            ++this;\r\n            return tmp;\r\n        }\r\n\r\n        node_iterator& operator--()\r\n        {\r\n            assert(m_node && m_node->previous_sibling());\r\n            m_node = m_node->previous_sibling();\r\n            return *this;\r\n        }\r\n\r\n        node_iterator operator--(int)\r\n        {\r\n            node_iterator tmp = *this;\r\n            ++this;\r\n            return tmp;\r\n        }\r\n\r\n        bool operator ==(const node_iterator<Ch> &rhs)\r\n        {\r\n            return m_node == rhs.m_node;\r\n        }\r\n\r\n        bool operator !=(const node_iterator<Ch> &rhs)\r\n        {\r\n            return m_node != rhs.m_node;\r\n        }\r\n\r\n    private:\r\n\r\n        xml_node<Ch> *m_node;\r\n\r\n    };\r\n\r\n    //! Iterator of child attributes of xml_node\r\n    template<class Ch>\r\n    class attribute_iterator\r\n    {\r\n    \r\n    public:\r\n\r\n        typedef typename xml_attribute<Ch> value_type;\r\n        typedef typename xml_attribute<Ch> &reference;\r\n        typedef typename xml_attribute<Ch> *pointer;\r\n        typedef std::ptrdiff_t difference_type;\r\n        typedef std::bidirectional_iterator_tag iterator_category;\r\n        \r\n        attribute_iterator()\r\n            : m_attribute(0)\r\n        {\r\n        }\r\n\r\n        attribute_iterator(xml_node<Ch> *node)\r\n            : m_attribute(node->first_attribute())\r\n        {\r\n        }\r\n        \r\n        reference operator *() const\r\n        {\r\n            assert(m_attribute);\r\n            return *m_attribute;\r\n        }\r\n\r\n        pointer operator->() const\r\n        {\r\n            assert(m_attribute);\r\n            return m_attribute;\r\n        }\r\n\r\n        attribute_iterator& operator++()\r\n        {\r\n            assert(m_attribute);\r\n            m_attribute = m_attribute->next_attribute();\r\n            return *this;\r\n        }\r\n\r\n        attribute_iterator operator++(int)\r\n        {\r\n            attribute_iterator tmp = *this;\r\n            ++this;\r\n            return tmp;\r\n        }\r\n\r\n        attribute_iterator& operator--()\r\n        {\r\n            assert(m_attribute && m_attribute->previous_attribute());\r\n            m_attribute = m_attribute->previous_attribute();\r\n            return *this;\r\n        }\r\n\r\n        attribute_iterator operator--(int)\r\n        {\r\n            attribute_iterator tmp = *this;\r\n            ++this;\r\n            return tmp;\r\n        }\r\n\r\n        bool operator ==(const attribute_iterator<Ch> &rhs)\r\n        {\r\n            return m_attribute == rhs.m_attribute;\r\n        }\r\n\r\n        bool operator !=(const attribute_iterator<Ch> &rhs)\r\n        {\r\n            return m_attribute != rhs.m_attribute;\r\n        }\r\n\r\n    private:\r\n\r\n        xml_attribute<Ch> *m_attribute;\r\n\r\n    };\r\n\r\n}\r\n\r\n#endif\r\n"
  },
  {
    "path": "Libraries/Core/Android/Headers/rapidxml/rapidxml_print.hpp",
    "content": "#ifndef RAPIDXML_PRINT_HPP_INCLUDED\r\n#define RAPIDXML_PRINT_HPP_INCLUDED\r\n\r\n// Copyright (C) 2006, 2009 Marcin Kalicinski\r\n// Version 1.13\r\n// Revision $DateTime: 2009/05/13 01:46:17 $\r\n//! \\file rapidxml_print.hpp This file contains rapidxml printer implementation\r\n\r\n#include \"rapidxml.hpp\"\r\n\r\n// Only include streams if not disabled\r\n#ifndef RAPIDXML_NO_STREAMS\r\n    #include <ostream>\r\n    #include <iterator>\r\n#endif\r\n\r\nnamespace rapidxml\r\n{\r\n\r\n    ///////////////////////////////////////////////////////////////////////\r\n    // Printing flags\r\n\r\n    const int print_no_indenting = 0x1;   //!< Printer flag instructing the printer to suppress indenting of XML. See print() function.\r\n\r\n    ///////////////////////////////////////////////////////////////////////\r\n    // Internal\r\n\r\n    //! \\cond internal\r\n    namespace internal\r\n    {\r\n        ///////////////////////////////////////////////////////////////////////////\r\n        // Function declarations\r\n        \r\n        template<class OutIt, class Ch>\r\n        inline OutIt copy_chars(const Ch *begin, const Ch *end, OutIt out);\r\n        \r\n        template<class OutIt, class Ch>\r\n        inline OutIt copy_and_expand_chars(const Ch *begin, const Ch *end, Ch noexpand, OutIt out);\r\n        \r\n        template<class OutIt, class Ch>\r\n        inline OutIt fill_chars(OutIt out, int n, Ch ch);\r\n        \r\n        template<class Ch, Ch ch>\r\n        inline bool find_char(const Ch *begin, const Ch *end);\r\n        \r\n        template<class OutIt, class Ch>\r\n        inline OutIt print_node(OutIt out, const xml_node<Ch> *node, int flags, int indent);\r\n        \r\n        template<class OutIt, class Ch>\r\n        inline OutIt print_children(OutIt out, const xml_node<Ch> *node, int flags, int indent);\r\n        \r\n        template<class OutIt, class Ch>\r\n        inline OutIt print_attributes(OutIt out, const xml_node<Ch> *node, int flags);\r\n        \r\n        template<class OutIt, class Ch>\r\n        inline OutIt print_data_node(OutIt out, const xml_node<Ch> *node, int flags, int indent);\r\n        \r\n        template<class OutIt, class Ch>\r\n        inline OutIt print_cdata_node(OutIt out, const xml_node<Ch> *node, int flags, int indent);\r\n        \r\n        template<class OutIt, class Ch>\r\n        inline OutIt print_element_node(OutIt out, const xml_node<Ch> *node, int flags, int indent);\r\n        \r\n        template<class OutIt, class Ch>\r\n        inline OutIt print_declaration_node(OutIt out, const xml_node<Ch> *node, int flags, int indent);\r\n        \r\n        template<class OutIt, class Ch>\r\n        inline OutIt print_comment_node(OutIt out, const xml_node<Ch> *node, int flags, int indent);\r\n        \r\n        template<class OutIt, class Ch>\r\n        inline OutIt print_doctype_node(OutIt out, const xml_node<Ch> *node, int flags, int indent);\r\n        \r\n        template<class OutIt, class Ch>\r\n        inline OutIt print_pi_node(OutIt out, const xml_node<Ch> *node, int flags, int indent);\r\n        \r\n        ///////////////////////////////////////////////////////////////////////////\r\n        // Internal character operations\r\n    \r\n        // Copy characters from given range to given output iterator\r\n        template<class OutIt, class Ch>\r\n        inline OutIt copy_chars(const Ch *begin, const Ch *end, OutIt out)\r\n        {\r\n            while (begin != end)\r\n                *out++ = *begin++;\r\n            return out;\r\n        }\r\n        \r\n        // Copy characters from given range to given output iterator and expand\r\n        // characters into references (&lt; &gt; &apos; &quot; &amp;)\r\n        template<class OutIt, class Ch>\r\n        inline OutIt copy_and_expand_chars(const Ch *begin, const Ch *end, Ch noexpand, OutIt out)\r\n        {\r\n            while (begin != end)\r\n            {\r\n                if (*begin == noexpand)\r\n                {\r\n                    *out++ = *begin;    // No expansion, copy character\r\n                }\r\n                else\r\n                {\r\n                    switch (*begin)\r\n                    {\r\n                    case Ch('<'):\r\n                        *out++ = Ch('&'); *out++ = Ch('l'); *out++ = Ch('t'); *out++ = Ch(';');\r\n                        break;\r\n                    case Ch('>'): \r\n                        *out++ = Ch('&'); *out++ = Ch('g'); *out++ = Ch('t'); *out++ = Ch(';');\r\n                        break;\r\n                    case Ch('\\''): \r\n                        *out++ = Ch('&'); *out++ = Ch('a'); *out++ = Ch('p'); *out++ = Ch('o'); *out++ = Ch('s'); *out++ = Ch(';');\r\n                        break;\r\n                    case Ch('\"'): \r\n                        *out++ = Ch('&'); *out++ = Ch('q'); *out++ = Ch('u'); *out++ = Ch('o'); *out++ = Ch('t'); *out++ = Ch(';');\r\n                        break;\r\n                    case Ch('&'): \r\n                        *out++ = Ch('&'); *out++ = Ch('a'); *out++ = Ch('m'); *out++ = Ch('p'); *out++ = Ch(';'); \r\n                        break;\r\n                    default:\r\n                        *out++ = *begin;    // No expansion, copy character\r\n                    }\r\n                }\r\n                ++begin;    // Step to next character\r\n            }\r\n            return out;\r\n        }\r\n\r\n        // Fill given output iterator with repetitions of the same character\r\n        template<class OutIt, class Ch>\r\n        inline OutIt fill_chars(OutIt out, int n, Ch ch)\r\n        {\r\n            for (int i = 0; i < n; ++i)\r\n                *out++ = ch;\r\n            return out;\r\n        }\r\n\r\n        // Find character\r\n        template<class Ch, Ch ch>\r\n        inline bool find_char(const Ch *begin, const Ch *end)\r\n        {\r\n            while (begin != end)\r\n                if (*begin++ == ch)\r\n                    return true;\r\n            return false;\r\n        }\r\n\r\n        ///////////////////////////////////////////////////////////////////////////\r\n        // Internal printing operations\r\n    \r\n        // Print node\r\n        template<class OutIt, class Ch>\r\n        inline OutIt print_node(OutIt out, const xml_node<Ch> *node, int flags, int indent)\r\n        {\r\n            // Print proper node type\r\n            switch (node->type())\r\n            {\r\n\r\n            // Document\r\n            case node_document:\r\n                out = print_children(out, node, flags, indent);\r\n                break;\r\n\r\n            // Element\r\n            case node_element:\r\n                out = print_element_node(out, node, flags, indent);\r\n                break;\r\n            \r\n            // Data\r\n            case node_data:\r\n                out = print_data_node(out, node, flags, indent);\r\n                break;\r\n            \r\n            // CDATA\r\n            case node_cdata:\r\n                out = print_cdata_node(out, node, flags, indent);\r\n                break;\r\n\r\n            // Declaration\r\n            case node_declaration:\r\n                out = print_declaration_node(out, node, flags, indent);\r\n                break;\r\n\r\n            // Comment\r\n            case node_comment:\r\n                out = print_comment_node(out, node, flags, indent);\r\n                break;\r\n            \r\n            // Doctype\r\n            case node_doctype:\r\n                out = print_doctype_node(out, node, flags, indent);\r\n                break;\r\n\r\n            // Pi\r\n            case node_pi:\r\n                out = print_pi_node(out, node, flags, indent);\r\n                break;\r\n\r\n                // Unknown\r\n            default:\r\n                assert(0);\r\n                break;\r\n            }\r\n            \r\n            // If indenting not disabled, add line break after node\r\n            if (!(flags & print_no_indenting))\r\n                *out = Ch('\\n'), ++out;\r\n\r\n            // Return modified iterator\r\n            return out;\r\n        }\r\n        \r\n        // Print children of the node                               \r\n        template<class OutIt, class Ch>\r\n        inline OutIt print_children(OutIt out, const xml_node<Ch> *node, int flags, int indent)\r\n        {\r\n            for (xml_node<Ch> *child = node->first_node(); child; child = child->next_sibling())\r\n                out = print_node(out, child, flags, indent);\r\n            return out;\r\n        }\r\n\r\n        // Print attributes of the node\r\n        template<class OutIt, class Ch>\r\n        inline OutIt print_attributes(OutIt out, const xml_node<Ch> *node, int flags)\r\n        {\r\n            for (xml_attribute<Ch> *attribute = node->first_attribute(); attribute; attribute = attribute->next_attribute())\r\n            {\r\n                if (attribute->name() && attribute->value())\r\n                {\r\n                    // Print attribute name\r\n                    *out = Ch(' '), ++out;\r\n                    out = copy_chars(attribute->name(), attribute->name() + attribute->name_size(), out);\r\n                    *out = Ch('='), ++out;\r\n                    // Print attribute value using appropriate quote type\r\n                    if (find_char<Ch, Ch('\"')>(attribute->value(), attribute->value() + attribute->value_size()))\r\n                    {\r\n                        *out = Ch('\\''), ++out;\r\n                        out = copy_and_expand_chars(attribute->value(), attribute->value() + attribute->value_size(), Ch('\"'), out);\r\n                        *out = Ch('\\''), ++out;\r\n                    }\r\n                    else\r\n                    {\r\n                        *out = Ch('\"'), ++out;\r\n                        out = copy_and_expand_chars(attribute->value(), attribute->value() + attribute->value_size(), Ch('\\''), out);\r\n                        *out = Ch('\"'), ++out;\r\n                    }\r\n                }\r\n            }\r\n            return out;\r\n        }\r\n\r\n        // Print data node\r\n        template<class OutIt, class Ch>\r\n        inline OutIt print_data_node(OutIt out, const xml_node<Ch> *node, int flags, int indent)\r\n        {\r\n            assert(node->type() == node_data);\r\n            if (!(flags & print_no_indenting))\r\n                out = fill_chars(out, indent, Ch('\\t'));\r\n            out = copy_and_expand_chars(node->value(), node->value() + node->value_size(), Ch(0), out);\r\n            return out;\r\n        }\r\n\r\n        // Print data node\r\n        template<class OutIt, class Ch>\r\n        inline OutIt print_cdata_node(OutIt out, const xml_node<Ch> *node, int flags, int indent)\r\n        {\r\n            assert(node->type() == node_cdata);\r\n            if (!(flags & print_no_indenting))\r\n                out = fill_chars(out, indent, Ch('\\t'));\r\n            *out = Ch('<'); ++out;\r\n            *out = Ch('!'); ++out;\r\n            *out = Ch('['); ++out;\r\n            *out = Ch('C'); ++out;\r\n            *out = Ch('D'); ++out;\r\n            *out = Ch('A'); ++out;\r\n            *out = Ch('T'); ++out;\r\n            *out = Ch('A'); ++out;\r\n            *out = Ch('['); ++out;\r\n            out = copy_chars(node->value(), node->value() + node->value_size(), out);\r\n            *out = Ch(']'); ++out;\r\n            *out = Ch(']'); ++out;\r\n            *out = Ch('>'); ++out;\r\n            return out;\r\n        }\r\n\r\n        // Print element node\r\n        template<class OutIt, class Ch>\r\n        inline OutIt print_element_node(OutIt out, const xml_node<Ch> *node, int flags, int indent)\r\n        {\r\n            assert(node->type() == node_element);\r\n\r\n            // Print element name and attributes, if any\r\n            if (!(flags & print_no_indenting))\r\n                out = fill_chars(out, indent, Ch('\\t'));\r\n            *out = Ch('<'), ++out;\r\n            out = copy_chars(node->name(), node->name() + node->name_size(), out);\r\n            out = print_attributes(out, node, flags);\r\n            \r\n            // If node is childless\r\n            if (node->value_size() == 0 && !node->first_node())\r\n            {\r\n                // Print childless node tag ending\r\n                *out = Ch('/'), ++out;\r\n                *out = Ch('>'), ++out;\r\n            }\r\n            else\r\n            {\r\n                // Print normal node tag ending\r\n                *out = Ch('>'), ++out;\r\n\r\n                // Test if node contains a single data node only (and no other nodes)\r\n                xml_node<Ch> *child = node->first_node();\r\n                if (!child)\r\n                {\r\n                    // If node has no children, only print its value without indenting\r\n                    out = copy_and_expand_chars(node->value(), node->value() + node->value_size(), Ch(0), out);\r\n                }\r\n                else if (child->next_sibling() == 0 && child->type() == node_data)\r\n                {\r\n                    // If node has a sole data child, only print its value without indenting\r\n                    out = copy_and_expand_chars(child->value(), child->value() + child->value_size(), Ch(0), out);\r\n                }\r\n                else\r\n                {\r\n                    // Print all children with full indenting\r\n                    if (!(flags & print_no_indenting))\r\n                        *out = Ch('\\n'), ++out;\r\n                    out = print_children(out, node, flags, indent + 1);\r\n                    if (!(flags & print_no_indenting))\r\n                        out = fill_chars(out, indent, Ch('\\t'));\r\n                }\r\n\r\n                // Print node end\r\n                *out = Ch('<'), ++out;\r\n                *out = Ch('/'), ++out;\r\n                out = copy_chars(node->name(), node->name() + node->name_size(), out);\r\n                *out = Ch('>'), ++out;\r\n            }\r\n            return out;\r\n        }\r\n\r\n        // Print declaration node\r\n        template<class OutIt, class Ch>\r\n        inline OutIt print_declaration_node(OutIt out, const xml_node<Ch> *node, int flags, int indent)\r\n        {\r\n            // Print declaration start\r\n            if (!(flags & print_no_indenting))\r\n                out = fill_chars(out, indent, Ch('\\t'));\r\n            *out = Ch('<'), ++out;\r\n            *out = Ch('?'), ++out;\r\n            *out = Ch('x'), ++out;\r\n            *out = Ch('m'), ++out;\r\n            *out = Ch('l'), ++out;\r\n\r\n            // Print attributes\r\n            out = print_attributes(out, node, flags);\r\n            \r\n            // Print declaration end\r\n            *out = Ch('?'), ++out;\r\n            *out = Ch('>'), ++out;\r\n            \r\n            return out;\r\n        }\r\n\r\n        // Print comment node\r\n        template<class OutIt, class Ch>\r\n        inline OutIt print_comment_node(OutIt out, const xml_node<Ch> *node, int flags, int indent)\r\n        {\r\n            assert(node->type() == node_comment);\r\n            if (!(flags & print_no_indenting))\r\n                out = fill_chars(out, indent, Ch('\\t'));\r\n            *out = Ch('<'), ++out;\r\n            *out = Ch('!'), ++out;\r\n            *out = Ch('-'), ++out;\r\n            *out = Ch('-'), ++out;\r\n            out = copy_chars(node->value(), node->value() + node->value_size(), out);\r\n            *out = Ch('-'), ++out;\r\n            *out = Ch('-'), ++out;\r\n            *out = Ch('>'), ++out;\r\n            return out;\r\n        }\r\n\r\n        // Print doctype node\r\n        template<class OutIt, class Ch>\r\n        inline OutIt print_doctype_node(OutIt out, const xml_node<Ch> *node, int flags, int indent)\r\n        {\r\n            assert(node->type() == node_doctype);\r\n            if (!(flags & print_no_indenting))\r\n                out = fill_chars(out, indent, Ch('\\t'));\r\n            *out = Ch('<'), ++out;\r\n            *out = Ch('!'), ++out;\r\n            *out = Ch('D'), ++out;\r\n            *out = Ch('O'), ++out;\r\n            *out = Ch('C'), ++out;\r\n            *out = Ch('T'), ++out;\r\n            *out = Ch('Y'), ++out;\r\n            *out = Ch('P'), ++out;\r\n            *out = Ch('E'), ++out;\r\n            *out = Ch(' '), ++out;\r\n            out = copy_chars(node->value(), node->value() + node->value_size(), out);\r\n            *out = Ch('>'), ++out;\r\n            return out;\r\n        }\r\n\r\n        // Print pi node\r\n        template<class OutIt, class Ch>\r\n        inline OutIt print_pi_node(OutIt out, const xml_node<Ch> *node, int flags, int indent)\r\n        {\r\n            assert(node->type() == node_pi);\r\n            if (!(flags & print_no_indenting))\r\n                out = fill_chars(out, indent, Ch('\\t'));\r\n            *out = Ch('<'), ++out;\r\n            *out = Ch('?'), ++out;\r\n            out = copy_chars(node->name(), node->name() + node->name_size(), out);\r\n            *out = Ch(' '), ++out;\r\n            out = copy_chars(node->value(), node->value() + node->value_size(), out);\r\n            *out = Ch('?'), ++out;\r\n            *out = Ch('>'), ++out;\r\n            return out;\r\n        }\r\n\r\n    }\r\n    //! \\endcond\r\n\r\n    ///////////////////////////////////////////////////////////////////////////\r\n    // Printing\r\n\r\n    //! Prints XML to given output iterator.\r\n    //! \\param out Output iterator to print to.\r\n    //! \\param node Node to be printed. Pass xml_document to print entire document.\r\n    //! \\param flags Flags controlling how XML is printed.\r\n    //! \\return Output iterator pointing to position immediately after last character of printed text.\r\n    template<class OutIt, class Ch> \r\n    inline OutIt print(OutIt out, const xml_node<Ch> &node, int flags = 0)\r\n    {\r\n        return internal::print_node(out, &node, flags, 0);\r\n    }\r\n\r\n#ifndef RAPIDXML_NO_STREAMS\r\n\r\n    //! Prints XML to given output stream.\r\n    //! \\param out Output stream to print to.\r\n    //! \\param node Node to be printed. Pass xml_document to print entire document.\r\n    //! \\param flags Flags controlling how XML is printed.\r\n    //! \\return Output stream.\r\n    template<class Ch> \r\n    inline std::basic_ostream<Ch> &print(std::basic_ostream<Ch> &out, const xml_node<Ch> &node, int flags = 0)\r\n    {\r\n        print(std::ostream_iterator<Ch>(out), node, flags);\r\n        return out;\r\n    }\r\n\r\n    //! Prints formatted XML to given output stream. Uses default printing flags. Use print() function to customize printing process.\r\n    //! \\param out Output stream to print to.\r\n    //! \\param node Node to be printed.\r\n    //! \\return Output stream.\r\n    template<class Ch> \r\n    inline std::basic_ostream<Ch> &operator <<(std::basic_ostream<Ch> &out, const xml_node<Ch> &node)\r\n    {\r\n        return print(out, node);\r\n    }\r\n\r\n#endif\r\n\r\n}\r\n\r\n#endif\r\n"
  },
  {
    "path": "Libraries/Core/Android/Headers/rapidxml/rapidxml_utils.hpp",
    "content": "#ifndef RAPIDXML_UTILS_HPP_INCLUDED\r\n#define RAPIDXML_UTILS_HPP_INCLUDED\r\n\r\n// Copyright (C) 2006, 2009 Marcin Kalicinski\r\n// Version 1.13\r\n// Revision $DateTime: 2009/05/13 01:46:17 $\r\n//! \\file rapidxml_utils.hpp This file contains high-level rapidxml utilities that can be useful\r\n//! in certain simple scenarios. They should probably not be used if maximizing performance is the main objective.\r\n\r\n#include \"rapidxml.hpp\"\r\n#include <vector>\r\n#include <string>\r\n#include <fstream>\r\n#include <stdexcept>\r\n\r\nnamespace rapidxml\r\n{\r\n\r\n    //! Represents data loaded from a file\r\n    template<class Ch = char>\r\n    class file\r\n    {\r\n        \r\n    public:\r\n        \r\n        //! Loads file into the memory. Data will be automatically destroyed by the destructor.\r\n        //! \\param filename Filename to load.\r\n        file(const char *filename)\r\n        {\r\n            using namespace std;\r\n\r\n            // Open stream\r\n            basic_ifstream<Ch> stream(filename, ios::binary);\r\n            if (!stream)\r\n                throw runtime_error(string(\"cannot open file \") + filename);\r\n            stream.unsetf(ios::skipws);\r\n            \r\n            // Determine stream size\r\n            stream.seekg(0, ios::end);\r\n            size_t size = stream.tellg();\r\n            stream.seekg(0);   \r\n            \r\n            // Load data and add terminating 0\r\n            m_data.resize(size + 1);\r\n            stream.read(&m_data.front(), static_cast<streamsize>(size));\r\n            m_data[size] = 0;\r\n        }\r\n\r\n        //! Loads file into the memory. Data will be automatically destroyed by the destructor\r\n        //! \\param stream Stream to load from\r\n        file(std::basic_istream<Ch> &stream)\r\n        {\r\n            using namespace std;\r\n\r\n            // Load data and add terminating 0\r\n            stream.unsetf(ios::skipws);\r\n            m_data.assign(istreambuf_iterator<Ch>(stream), istreambuf_iterator<Ch>());\r\n            if (stream.fail() || stream.bad())\r\n                throw runtime_error(\"error reading stream\");\r\n            m_data.push_back(0);\r\n        }\r\n        \r\n        //! Gets file data.\r\n        //! \\return Pointer to data of file.\r\n        Ch *data()\r\n        {\r\n            return &m_data.front();\r\n        }\r\n\r\n        //! Gets file data.\r\n        //! \\return Pointer to data of file.\r\n        const Ch *data() const\r\n        {\r\n            return &m_data.front();\r\n        }\r\n\r\n        //! Gets file data size.\r\n        //! \\return Size of file data, in characters.\r\n        std::size_t size() const\r\n        {\r\n            return m_data.size();\r\n        }\r\n\r\n    private:\r\n\r\n        std::vector<Ch> m_data;   // File data\r\n\r\n    };\r\n\r\n    //! Counts children of node. Time complexity is O(n).\r\n    //! \\return Number of children of node\r\n    template<class Ch>\r\n    inline std::size_t count_children(xml_node<Ch> *node)\r\n    {\r\n        xml_node<Ch> *child = node->first_node();\r\n        std::size_t count = 0;\r\n        while (child)\r\n        {\r\n            ++count;\r\n            child = child->next_sibling();\r\n        }\r\n        return count;\r\n    }\r\n\r\n    //! Counts attributes of node. Time complexity is O(n).\r\n    //! \\return Number of attributes of node\r\n    template<class Ch>\r\n    inline std::size_t count_attributes(xml_node<Ch> *node)\r\n    {\r\n        xml_attribute<Ch> *attr = node->first_attribute();\r\n        std::size_t count = 0;\r\n        while (attr)\r\n        {\r\n            ++count;\r\n            attr = attr->next_attribute();\r\n        }\r\n        return count;\r\n    }\r\n\r\n}\r\n\r\n#endif\r\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/EGL/egl.h",
    "content": "/* -*- mode: c; tab-width: 8; -*- */\n/* vi: set sw=4 ts=8: */\n/* Reference version of egl.h for EGL 1.4.\n * $Revision: 9356 $ on $Date: 2009-10-21 02:52:25 -0700 (Wed, 21 Oct 2009) $\n */\n\n/*\n** Copyright (c) 2007-2009 The Khronos Group Inc.\n**\n** Permission is hereby granted, free of charge, to any person obtaining a\n** copy of this software and/or associated documentation files (the\n** \"Materials\"), to deal in the Materials without restriction, including\n** without limitation the rights to use, copy, modify, merge, publish,\n** distribute, sublicense, and/or sell copies of the Materials, and to\n** permit persons to whom the Materials are furnished to do so, subject to\n** the following conditions:\n**\n** The above copyright notice and this permission notice shall be included\n** in all copies or substantial portions of the Materials.\n**\n** THE MATERIALS ARE PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\n** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\n** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\n** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.\n*/\n\n#ifndef __egl_h_\n#define __egl_h_\n\n/* All platform-dependent types and macro boilerplate (such as EGLAPI\n * and EGLAPIENTRY) should go in eglplatform.h.\n */\n#include \"eglplatform.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* EGL Types */\n/* EGLint is defined in eglplatform.h */\ntypedef unsigned int EGLBoolean;\ntypedef unsigned int EGLenum;\ntypedef void *EGLConfig;\ntypedef void *EGLContext;\ntypedef void *EGLDisplay;\ntypedef void *EGLSurface;\ntypedef void *EGLClientBuffer;\n\n/* EGL Versioning */\n#define EGL_VERSION_1_0\t\t\t1\n#define EGL_VERSION_1_1\t\t\t1\n#define EGL_VERSION_1_2\t\t\t1\n#define EGL_VERSION_1_3\t\t\t1\n#define EGL_VERSION_1_4\t\t\t1\n\n/* EGL Enumerants. Bitmasks and other exceptional cases aside, most\n * enums are assigned unique values starting at 0x3000.\n */\n\n/* EGL aliases */\n#define EGL_FALSE\t\t\t((EGLBoolean)0)\n#define EGL_TRUE\t\t\t((EGLBoolean)1)\n\n/* Out-of-band handle values */\n#define EGL_DEFAULT_DISPLAY\t\t((EGLNativeDisplayType)0)\n#define EGL_NO_CONTEXT\t\t\t((EGLContext)0)\n#define EGL_NO_DISPLAY\t\t\t((EGLDisplay)0)\n#define EGL_NO_SURFACE\t\t\t((EGLSurface)0)\n\n/* Out-of-band attribute value */\n#define EGL_DONT_CARE\t\t\t((EGLint)-1)\n\n/* Errors / GetError return values */\n#define EGL_SUCCESS\t\t\t0x3000\n#define EGL_NOT_INITIALIZED\t\t0x3001\n#define EGL_BAD_ACCESS\t\t\t0x3002\n#define EGL_BAD_ALLOC\t\t\t0x3003\n#define EGL_BAD_ATTRIBUTE\t\t0x3004\n#define EGL_BAD_CONFIG\t\t\t0x3005\n#define EGL_BAD_CONTEXT\t\t\t0x3006\n#define EGL_BAD_CURRENT_SURFACE\t\t0x3007\n#define EGL_BAD_DISPLAY\t\t\t0x3008\n#define EGL_BAD_MATCH\t\t\t0x3009\n#define EGL_BAD_NATIVE_PIXMAP\t\t0x300A\n#define EGL_BAD_NATIVE_WINDOW\t\t0x300B\n#define EGL_BAD_PARAMETER\t\t0x300C\n#define EGL_BAD_SURFACE\t\t\t0x300D\n#define EGL_CONTEXT_LOST\t\t0x300E\t/* EGL 1.1 - IMG_power_management */\n\n/* Reserved 0x300F-0x301F for additional errors */\n\n/* Config attributes */\n#define EGL_BUFFER_SIZE\t\t\t0x3020\n#define EGL_ALPHA_SIZE\t\t\t0x3021\n#define EGL_BLUE_SIZE\t\t\t0x3022\n#define EGL_GREEN_SIZE\t\t\t0x3023\n#define EGL_RED_SIZE\t\t\t0x3024\n#define EGL_DEPTH_SIZE\t\t\t0x3025\n#define EGL_STENCIL_SIZE\t\t0x3026\n#define EGL_CONFIG_CAVEAT\t\t0x3027\n#define EGL_CONFIG_ID\t\t\t0x3028\n#define EGL_LEVEL\t\t\t0x3029\n#define EGL_MAX_PBUFFER_HEIGHT\t\t0x302A\n#define EGL_MAX_PBUFFER_PIXELS\t\t0x302B\n#define EGL_MAX_PBUFFER_WIDTH\t\t0x302C\n#define EGL_NATIVE_RENDERABLE\t\t0x302D\n#define EGL_NATIVE_VISUAL_ID\t\t0x302E\n#define EGL_NATIVE_VISUAL_TYPE\t\t0x302F\n#define EGL_SAMPLES\t\t\t0x3031\n#define EGL_SAMPLE_BUFFERS\t\t0x3032\n#define EGL_SURFACE_TYPE\t\t0x3033\n#define EGL_TRANSPARENT_TYPE\t\t0x3034\n#define EGL_TRANSPARENT_BLUE_VALUE\t0x3035\n#define EGL_TRANSPARENT_GREEN_VALUE\t0x3036\n#define EGL_TRANSPARENT_RED_VALUE\t0x3037\n#define EGL_NONE\t\t\t0x3038\t/* Attrib list terminator */\n#define EGL_BIND_TO_TEXTURE_RGB\t\t0x3039\n#define EGL_BIND_TO_TEXTURE_RGBA\t0x303A\n#define EGL_MIN_SWAP_INTERVAL\t\t0x303B\n#define EGL_MAX_SWAP_INTERVAL\t\t0x303C\n#define EGL_LUMINANCE_SIZE\t\t0x303D\n#define EGL_ALPHA_MASK_SIZE\t\t0x303E\n#define EGL_COLOR_BUFFER_TYPE\t\t0x303F\n#define EGL_RENDERABLE_TYPE\t\t0x3040\n#define EGL_MATCH_NATIVE_PIXMAP\t\t0x3041\t/* Pseudo-attribute (not queryable) */\n#define EGL_CONFORMANT\t\t\t0x3042\n\n/* Reserved 0x3041-0x304F for additional config attributes */\n\n/* Config attribute values */\n#define EGL_SLOW_CONFIG\t\t\t0x3050\t/* EGL_CONFIG_CAVEAT value */\n#define EGL_NON_CONFORMANT_CONFIG\t0x3051\t/* EGL_CONFIG_CAVEAT value */\n#define EGL_TRANSPARENT_RGB\t\t0x3052\t/* EGL_TRANSPARENT_TYPE value */\n#define EGL_RGB_BUFFER\t\t\t0x308E\t/* EGL_COLOR_BUFFER_TYPE value */\n#define EGL_LUMINANCE_BUFFER\t\t0x308F\t/* EGL_COLOR_BUFFER_TYPE value */\n\n/* More config attribute values, for EGL_TEXTURE_FORMAT */\n#define EGL_NO_TEXTURE\t\t\t0x305C\n#define EGL_TEXTURE_RGB\t\t\t0x305D\n#define EGL_TEXTURE_RGBA\t\t0x305E\n#define EGL_TEXTURE_2D\t\t\t0x305F\n\n/* Config attribute mask bits */\n#define EGL_PBUFFER_BIT\t\t\t0x0001\t/* EGL_SURFACE_TYPE mask bits */\n#define EGL_PIXMAP_BIT\t\t\t0x0002\t/* EGL_SURFACE_TYPE mask bits */\n#define EGL_WINDOW_BIT\t\t\t0x0004\t/* EGL_SURFACE_TYPE mask bits */\n#define EGL_VG_COLORSPACE_LINEAR_BIT\t0x0020\t/* EGL_SURFACE_TYPE mask bits */\n#define EGL_VG_ALPHA_FORMAT_PRE_BIT\t0x0040\t/* EGL_SURFACE_TYPE mask bits */\n#define EGL_MULTISAMPLE_RESOLVE_BOX_BIT 0x0200\t/* EGL_SURFACE_TYPE mask bits */\n#define EGL_SWAP_BEHAVIOR_PRESERVED_BIT 0x0400\t/* EGL_SURFACE_TYPE mask bits */\n\n#define EGL_OPENGL_ES_BIT\t\t0x0001\t/* EGL_RENDERABLE_TYPE mask bits */\n#define EGL_OPENVG_BIT\t\t\t0x0002\t/* EGL_RENDERABLE_TYPE mask bits */\n#define EGL_OPENGL_ES2_BIT\t\t0x0004\t/* EGL_RENDERABLE_TYPE mask bits */\n#define EGL_OPENGL_BIT\t\t\t0x0008\t/* EGL_RENDERABLE_TYPE mask bits */\n\n/* QueryString targets */\n#define EGL_VENDOR\t\t\t0x3053\n#define EGL_VERSION\t\t\t0x3054\n#define EGL_EXTENSIONS\t\t\t0x3055\n#define EGL_CLIENT_APIS\t\t\t0x308D\n\n/* QuerySurface / SurfaceAttrib / CreatePbufferSurface targets */\n#define EGL_HEIGHT\t\t\t0x3056\n#define EGL_WIDTH\t\t\t0x3057\n#define EGL_LARGEST_PBUFFER\t\t0x3058\n#define EGL_TEXTURE_FORMAT\t\t0x3080\n#define EGL_TEXTURE_TARGET\t\t0x3081\n#define EGL_MIPMAP_TEXTURE\t\t0x3082\n#define EGL_MIPMAP_LEVEL\t\t0x3083\n#define EGL_RENDER_BUFFER\t\t0x3086\n#define EGL_VG_COLORSPACE\t\t0x3087\n#define EGL_VG_ALPHA_FORMAT\t\t0x3088\n#define EGL_HORIZONTAL_RESOLUTION\t0x3090\n#define EGL_VERTICAL_RESOLUTION\t\t0x3091\n#define EGL_PIXEL_ASPECT_RATIO\t\t0x3092\n#define EGL_SWAP_BEHAVIOR\t\t0x3093\n#define EGL_MULTISAMPLE_RESOLVE\t\t0x3099\n\n/* EGL_RENDER_BUFFER values / BindTexImage / ReleaseTexImage buffer targets */\n#define EGL_BACK_BUFFER\t\t\t0x3084\n#define EGL_SINGLE_BUFFER\t\t0x3085\n\n/* OpenVG color spaces */\n#define EGL_VG_COLORSPACE_sRGB\t\t0x3089\t/* EGL_VG_COLORSPACE value */\n#define EGL_VG_COLORSPACE_LINEAR\t0x308A\t/* EGL_VG_COLORSPACE value */\n\n/* OpenVG alpha formats */\n#define EGL_VG_ALPHA_FORMAT_NONPRE\t0x308B\t/* EGL_ALPHA_FORMAT value */\n#define EGL_VG_ALPHA_FORMAT_PRE\t\t0x308C\t/* EGL_ALPHA_FORMAT value */\n\n/* Constant scale factor by which fractional display resolutions &\n * aspect ratio are scaled when queried as integer values.\n */\n#define EGL_DISPLAY_SCALING\t\t10000\n\n/* Unknown display resolution/aspect ratio */\n#define EGL_UNKNOWN\t\t\t((EGLint)-1)\n\n/* Back buffer swap behaviors */\n#define EGL_BUFFER_PRESERVED\t\t0x3094\t/* EGL_SWAP_BEHAVIOR value */\n#define EGL_BUFFER_DESTROYED\t\t0x3095\t/* EGL_SWAP_BEHAVIOR value */\n\n/* CreatePbufferFromClientBuffer buffer types */\n#define EGL_OPENVG_IMAGE\t\t0x3096\n\n/* QueryContext targets */\n#define EGL_CONTEXT_CLIENT_TYPE\t\t0x3097\n\n/* CreateContext attributes */\n#define EGL_CONTEXT_CLIENT_VERSION\t0x3098\n\n/* Multisample resolution behaviors */\n#define EGL_MULTISAMPLE_RESOLVE_DEFAULT 0x309A\t/* EGL_MULTISAMPLE_RESOLVE value */\n#define EGL_MULTISAMPLE_RESOLVE_BOX\t0x309B\t/* EGL_MULTISAMPLE_RESOLVE value */\n\n/* BindAPI/QueryAPI targets */\n#define EGL_OPENGL_ES_API\t\t0x30A0\n#define EGL_OPENVG_API\t\t\t0x30A1\n#define EGL_OPENGL_API\t\t\t0x30A2\n\n/* GetCurrentSurface targets */\n#define EGL_DRAW\t\t\t0x3059\n#define EGL_READ\t\t\t0x305A\n\n/* WaitNative engines */\n#define EGL_CORE_NATIVE_ENGINE\t\t0x305B\n\n/* EGL 1.2 tokens renamed for consistency in EGL 1.3 */\n#define EGL_COLORSPACE\t\t\tEGL_VG_COLORSPACE\n#define EGL_ALPHA_FORMAT\t\tEGL_VG_ALPHA_FORMAT\n#define EGL_COLORSPACE_sRGB\t\tEGL_VG_COLORSPACE_sRGB\n#define EGL_COLORSPACE_LINEAR\t\tEGL_VG_COLORSPACE_LINEAR\n#define EGL_ALPHA_FORMAT_NONPRE\t\tEGL_VG_ALPHA_FORMAT_NONPRE\n#define EGL_ALPHA_FORMAT_PRE\t\tEGL_VG_ALPHA_FORMAT_PRE\n\n/* EGL extensions must request enum blocks from the Khronos\n * API Registrar, who maintains the enumerant registry. Submit\n * a bug in Khronos Bugzilla against task \"Registry\".\n */\n\n\n\n/* EGL Functions */\n\nEGLAPI EGLint EGLAPIENTRY eglGetError(void);\n\nEGLAPI EGLDisplay EGLAPIENTRY eglGetDisplay(EGLNativeDisplayType display_id);\nEGLAPI EGLBoolean EGLAPIENTRY eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor);\nEGLAPI EGLBoolean EGLAPIENTRY eglTerminate(EGLDisplay dpy);\n\nEGLAPI const char * EGLAPIENTRY eglQueryString(EGLDisplay dpy, EGLint name);\n\nEGLAPI EGLBoolean EGLAPIENTRY eglGetConfigs(EGLDisplay dpy, EGLConfig *configs,\n\t\t\t EGLint config_size, EGLint *num_config);\nEGLAPI EGLBoolean EGLAPIENTRY eglChooseConfig(EGLDisplay dpy, const EGLint *attrib_list,\n\t\t\t   EGLConfig *configs, EGLint config_size,\n\t\t\t   EGLint *num_config);\nEGLAPI EGLBoolean EGLAPIENTRY eglGetConfigAttrib(EGLDisplay dpy, EGLConfig config,\n\t\t\t      EGLint attribute, EGLint *value);\n\nEGLAPI EGLSurface EGLAPIENTRY eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config,\n\t\t\t\t  EGLNativeWindowType win,\n\t\t\t\t  const EGLint *attrib_list);\nEGLAPI EGLSurface EGLAPIENTRY eglCreatePbufferSurface(EGLDisplay dpy, EGLConfig config,\n\t\t\t\t   const EGLint *attrib_list);\nEGLAPI EGLSurface EGLAPIENTRY eglCreatePixmapSurface(EGLDisplay dpy, EGLConfig config,\n\t\t\t\t  EGLNativePixmapType pixmap,\n\t\t\t\t  const EGLint *attrib_list);\nEGLAPI EGLBoolean EGLAPIENTRY eglDestroySurface(EGLDisplay dpy, EGLSurface surface);\nEGLAPI EGLBoolean EGLAPIENTRY eglQuerySurface(EGLDisplay dpy, EGLSurface surface,\n\t\t\t   EGLint attribute, EGLint *value);\n\nEGLAPI EGLBoolean EGLAPIENTRY eglBindAPI(EGLenum api);\nEGLAPI EGLenum EGLAPIENTRY eglQueryAPI(void);\n\nEGLAPI EGLBoolean EGLAPIENTRY eglWaitClient(void);\n\nEGLAPI EGLBoolean EGLAPIENTRY eglReleaseThread(void);\n\nEGLAPI EGLSurface EGLAPIENTRY eglCreatePbufferFromClientBuffer(\n\t      EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer,\n\t      EGLConfig config, const EGLint *attrib_list);\n\nEGLAPI EGLBoolean EGLAPIENTRY eglSurfaceAttrib(EGLDisplay dpy, EGLSurface surface,\n\t\t\t    EGLint attribute, EGLint value);\nEGLAPI EGLBoolean EGLAPIENTRY eglBindTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer);\nEGLAPI EGLBoolean EGLAPIENTRY eglReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer);\n\n\nEGLAPI EGLBoolean EGLAPIENTRY eglSwapInterval(EGLDisplay dpy, EGLint interval);\n\n\nEGLAPI EGLContext EGLAPIENTRY eglCreateContext(EGLDisplay dpy, EGLConfig config,\n\t\t\t    EGLContext share_context,\n\t\t\t    const EGLint *attrib_list);\nEGLAPI EGLBoolean EGLAPIENTRY eglDestroyContext(EGLDisplay dpy, EGLContext ctx);\nEGLAPI EGLBoolean EGLAPIENTRY eglMakeCurrent(EGLDisplay dpy, EGLSurface draw,\n\t\t\t  EGLSurface read, EGLContext ctx);\n\nEGLAPI EGLContext EGLAPIENTRY eglGetCurrentContext(void);\nEGLAPI EGLSurface EGLAPIENTRY eglGetCurrentSurface(EGLint readdraw);\nEGLAPI EGLDisplay EGLAPIENTRY eglGetCurrentDisplay(void);\nEGLAPI EGLBoolean EGLAPIENTRY eglQueryContext(EGLDisplay dpy, EGLContext ctx,\n\t\t\t   EGLint attribute, EGLint *value);\n\nEGLAPI EGLBoolean EGLAPIENTRY eglWaitGL(void);\nEGLAPI EGLBoolean EGLAPIENTRY eglWaitNative(EGLint engine);\nEGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffers(EGLDisplay dpy, EGLSurface surface);\nEGLAPI EGLBoolean EGLAPIENTRY eglCopyBuffers(EGLDisplay dpy, EGLSurface surface,\n\t\t\t  EGLNativePixmapType target);\n\n/* This is a generic function pointer type, whose name indicates it must\n * be cast to the proper type *and calling convention* before use.\n */\ntypedef void (*__eglMustCastToProperFunctionPointerType)(void);\n\n/* Now, define eglGetProcAddress using the generic function ptr. type */\nEGLAPI __eglMustCastToProperFunctionPointerType EGLAPIENTRY\n       eglGetProcAddress(const char *procname);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* __egl_h_ */\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/EGL/eglext.h",
    "content": "#ifndef __eglext_h_\n#define __eglext_h_\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/*\n** Copyright (c) 2007-2009 The Khronos Group Inc.\n**\n** Permission is hereby granted, free of charge, to any person obtaining a\n** copy of this software and/or associated documentation files (the\n** \"Materials\"), to deal in the Materials without restriction, including\n** without limitation the rights to use, copy, modify, merge, publish,\n** distribute, sublicense, and/or sell copies of the Materials, and to\n** permit persons to whom the Materials are furnished to do so, subject to\n** the following conditions:\n**\n** The above copyright notice and this permission notice shall be included\n** in all copies or substantial portions of the Materials.\n**\n** THE MATERIALS ARE PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\n** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\n** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\n** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.\n*/\n\n#include \"eglplatform.h\"\n\n/* We want this */\n#ifndef EGL_EGLEXT_PROTOTYPES\n#define EGL_EGLEXT_PROTOTYPES\n#endif\n\n/*************************************************************/\n\n/* Header file version number */\n/* Current version at http://www.khronos.org/registry/egl/ */\n/* $Revision: 7244 $ on $Date: 2009-01-20 17:06:59 -0800 (Tue, 20 Jan 2009) $ */\n#define EGL_EGLEXT_VERSION 3\n\n#ifndef EGL_KHR_config_attribs\n#define EGL_KHR_config_attribs 1\n#define EGL_CONFORMANT_KHR\t\t\t0x3042\t/* EGLConfig attribute */\n#define EGL_VG_COLORSPACE_LINEAR_BIT_KHR\t0x0020\t/* EGL_SURFACE_TYPE bitfield */\n#define EGL_VG_ALPHA_FORMAT_PRE_BIT_KHR\t\t0x0040\t/* EGL_SURFACE_TYPE bitfield */\n#endif\n\n#ifndef EGL_KHR_lock_surface\n#define EGL_KHR_lock_surface 1\n#define EGL_READ_SURFACE_BIT_KHR\t\t0x0001\t/* EGL_LOCK_USAGE_HINT_KHR bitfield */\n#define EGL_WRITE_SURFACE_BIT_KHR\t\t0x0002\t/* EGL_LOCK_USAGE_HINT_KHR bitfield */\n#define EGL_LOCK_SURFACE_BIT_KHR\t\t0x0080\t/* EGL_SURFACE_TYPE bitfield */\n#define EGL_OPTIMAL_FORMAT_BIT_KHR\t\t0x0100\t/* EGL_SURFACE_TYPE bitfield */\n#define EGL_MATCH_FORMAT_KHR\t\t\t0x3043\t/* EGLConfig attribute */\n#define EGL_FORMAT_RGB_565_EXACT_KHR\t\t0x30C0\t/* EGL_MATCH_FORMAT_KHR value */\n#define EGL_FORMAT_RGB_565_KHR\t\t\t0x30C1\t/* EGL_MATCH_FORMAT_KHR value */\n#define EGL_FORMAT_RGBA_8888_EXACT_KHR\t\t0x30C2\t/* EGL_MATCH_FORMAT_KHR value */\n#define EGL_FORMAT_RGBA_8888_KHR\t\t0x30C3\t/* EGL_MATCH_FORMAT_KHR value */\n#define EGL_MAP_PRESERVE_PIXELS_KHR\t\t0x30C4\t/* eglLockSurfaceKHR attribute */\n#define EGL_LOCK_USAGE_HINT_KHR\t\t\t0x30C5\t/* eglLockSurfaceKHR attribute */\n#define EGL_BITMAP_POINTER_KHR\t\t\t0x30C6\t/* eglQuerySurface attribute */\n#define EGL_BITMAP_PITCH_KHR\t\t\t0x30C7\t/* eglQuerySurface attribute */\n#define EGL_BITMAP_ORIGIN_KHR\t\t\t0x30C8\t/* eglQuerySurface attribute */\n#define EGL_BITMAP_PIXEL_RED_OFFSET_KHR\t\t0x30C9\t/* eglQuerySurface attribute */\n#define EGL_BITMAP_PIXEL_GREEN_OFFSET_KHR\t0x30CA\t/* eglQuerySurface attribute */\n#define EGL_BITMAP_PIXEL_BLUE_OFFSET_KHR\t0x30CB\t/* eglQuerySurface attribute */\n#define EGL_BITMAP_PIXEL_ALPHA_OFFSET_KHR\t0x30CC\t/* eglQuerySurface attribute */\n#define EGL_BITMAP_PIXEL_LUMINANCE_OFFSET_KHR\t0x30CD\t/* eglQuerySurface attribute */\n#define EGL_LOWER_LEFT_KHR\t\t\t0x30CE\t/* EGL_BITMAP_ORIGIN_KHR value */\n#define EGL_UPPER_LEFT_KHR\t\t\t0x30CF\t/* EGL_BITMAP_ORIGIN_KHR value */\n#ifdef EGL_EGLEXT_PROTOTYPES\nEGLAPI EGLBoolean EGLAPIENTRY eglLockSurfaceKHR (EGLDisplay display, EGLSurface surface, const EGLint *attrib_list);\nEGLAPI EGLBoolean EGLAPIENTRY eglUnlockSurfaceKHR (EGLDisplay display, EGLSurface surface);\n#endif /* EGL_EGLEXT_PROTOTYPES */\ntypedef EGLBoolean (EGLAPIENTRYP PFNEGLLOCKSURFACEKHRPROC) (EGLDisplay display, EGLSurface surface, const EGLint *attrib_list);\ntypedef EGLBoolean (EGLAPIENTRYP PFNEGLUNLOCKSURFACEKHRPROC) (EGLDisplay display, EGLSurface surface);\n#endif\n\n#ifndef EGL_KHR_image\n#define EGL_KHR_image 1\n#define EGL_NATIVE_PIXMAP_KHR\t\t\t0x30B0\t/* eglCreateImageKHR target */\ntypedef void *EGLImageKHR;\n#define EGL_NO_IMAGE_KHR\t\t\t((EGLImageKHR)0)\n#ifdef EGL_EGLEXT_PROTOTYPES\nEGLAPI EGLImageKHR EGLAPIENTRY eglCreateImageKHR (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list);\nEGLAPI EGLBoolean EGLAPIENTRY eglDestroyImageKHR (EGLDisplay dpy, EGLImageKHR image);\n#endif /* EGL_EGLEXT_PROTOTYPES */\ntypedef EGLImageKHR (EGLAPIENTRYP PFNEGLCREATEIMAGEKHRPROC) (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list);\ntypedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYIMAGEKHRPROC) (EGLDisplay dpy, EGLImageKHR image);\n#endif\n\n#ifndef EGL_KHR_vg_parent_image\n#define EGL_KHR_vg_parent_image 1\n#define EGL_VG_PARENT_IMAGE_KHR\t\t\t0x30BA\t/* eglCreateImageKHR target */\n#endif\n\n#ifndef EGL_KHR_gl_texture_2D_image\n#define EGL_KHR_gl_texture_2D_image 1\n#define EGL_GL_TEXTURE_2D_KHR\t\t\t0x30B1\t/* eglCreateImageKHR target */\n#define EGL_GL_TEXTURE_LEVEL_KHR\t\t0x30BC\t/* eglCreateImageKHR attribute */\n#endif\n\n#ifndef EGL_KHR_gl_texture_cubemap_image\n#define EGL_KHR_gl_texture_cubemap_image 1\n#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X_KHR\t0x30B3\t/* eglCreateImageKHR target */\n#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_X_KHR\t0x30B4\t/* eglCreateImageKHR target */\n#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Y_KHR\t0x30B5\t/* eglCreateImageKHR target */\n#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_KHR\t0x30B6\t/* eglCreateImageKHR target */\n#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Z_KHR\t0x30B7\t/* eglCreateImageKHR target */\n#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_KHR\t0x30B8\t/* eglCreateImageKHR target */\n#endif\n\n#ifndef EGL_KHR_gl_texture_3D_image\n#define EGL_KHR_gl_texture_3D_image 0\n#define EGL_GL_TEXTURE_3D_KHR\t\t\t0x30B2\t/* eglCreateImageKHR target */\n#define EGL_GL_TEXTURE_ZOFFSET_KHR\t\t0x30BD\t/* eglCreateImageKHR attribute */\n#endif\n\n#ifndef EGL_KHR_gl_renderbuffer_image\n#define EGL_KHR_gl_renderbuffer_image 1\n#define EGL_GL_RENDERBUFFER_KHR\t\t\t0x30B9\t/* eglCreateImageKHR target */\n#endif\n\n#ifndef EGL_KHR_image_base\n#define EGL_KHR_image_base 1\n/* Most interfaces defined by EGL_KHR_image_pixmap above */\n#define EGL_IMAGE_PRESERVED_KHR\t\t\t0x30D2\t/* eglCreateImageKHR attribute */\n#endif\n\n#ifndef EGL_KHR_image_pixmap\n#define EGL_KHR_image_pixmap 1\n/* Interfaces defined by EGL_KHR_image above */\n#endif\n\n#ifndef EGL_KHR_fence_sync\n#define EGL_KHR_fence_sync 1\n#define GL_OES_EGL_sync 1\n#endif\n\n#ifndef EGL_KHR_sync\n#define EGL_KHR_sync 1\n#endif\n\n#if ((EGL_KHR_sync == 1) || (EGL_KHR_fence_sync == 1))\n#define EGL_KHR_sync 1 /* EGL_KHR_fence_sync depends on this stuff */\n/*\n* EGLSyncKHR is an opaque handle to an EGL sync object\n*/\n\ntypedef void* EGLSyncKHR;\n\n/*\n* EGLTimeKHR is a 64-bit unsigned integer representing intervals\n* in nanoseconds.\n*/\n\ntypedef khronos_utime_nanoseconds_t EGLTimeKHR;\n\n#define EGL_SYNC_FENCE_KHR                      0x30F9\n#define EGL_SYNC_REUSABLE_KHR                   0x30FA\n#define EGL_SYNC_TYPE_KHR                       0x30F7\n#define EGL_SYNC_STATUS_KHR                     0x30F1\n#define EGL_SYNC_CONDITION_KHR                  0x30F8\n#define EGL_SIGNALED_KHR                        0x30F2\n#define EGL_UNSIGNALED_KHR                      0x30F3\n#define EGL_SYNC_PRIOR_COMMANDS_COMPLETE_KHR    0x30F0\n#define EGL_SYNC_FLUSH_COMMANDS_BIT_KHR         0x0001\n#define EGL_TIMEOUT_EXPIRED_KHR                 0x30F5\n#define EGL_CONDITION_SATISFIED_KHR             0x30F6\n\n#define EGL_FOREVER_KHR                         0xFFFFFFFFFFFFFFFFull\n\n#define EGL_NO_SYNC_KHR                         ((EGLSyncKHR)0)\n\n#ifdef EGL_EGLEXT_PROTOTYPES\nEGLAPI EGLSyncKHR EGLAPIENTRY eglCreateSyncKHR(EGLDisplay dpy, EGLenum type, const EGLint *attrib_list);\nEGLAPI EGLBoolean EGLAPIENTRY eglDestroySyncKHR(EGLDisplay dpy, EGLSyncKHR sync);\nEGLAPI EGLint EGLAPIENTRY eglClientWaitSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, EGLTimeKHR timeout);\nEGLAPI EGLBoolean EGLAPIENTRY eglSignalSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLenum mode);\nEGLAPI EGLBoolean EGLAPIENTRY eglGetSyncAttribKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint attribute, EGLint *value);\n#endif /* EGL_EGLEXT_PROTOTYPES */\ntypedef EGLSyncKHR (EGLAPIENTRYP PFNEGLCREATESYNCKHRPROC) (EGLDisplay dpy, EGLenum type, const EGLint *attrib_list);\ntypedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYSYNCKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync);\ntypedef EGLint (EGLAPIENTRYP PFNEGLCLIENTWAITSYNCKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, EGLTimeKHR timeout);\ntypedef EGLBoolean (EGLAPIENTRYP PFNEGLSIGNALSYNCKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync, EGLenum mode);\ntypedef EGLBoolean (EGLAPIENTRYP PFNEGLGETSYNCATTRIBKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync, EGLint attribute, EGLint *value);\n#endif\n\n\n#ifdef __cplusplus\n}\n#endif\n\n#include \"eglext_brcm.h\"\n\n#if defined(ANDROID)\n#include \"eglext_android.h\"\n#include \"eglext_nvidia.h\"\n#endif\n\n#endif\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/EGL/eglext_android.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n#if defined(ANDROID)\n\n#ifndef EGLEXT_ANDROID_H\n#define EGLEXT_ANDROID_H\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#ifndef EGL_ANDROID_image_native_buffer\n   #define EGL_ANDROID_image_native_buffer 1\n   #if defined(EGL_EGLEXT_ANDROID_STRUCT_HEADER)\n      #include <system/window.h>\n   #else\n      struct android_native_buffer_t;\n   #endif\n   #define EGL_NATIVE_BUFFER_ANDROID       0x3140  /* eglCreateImageKHR target */\n#endif\n\n/* Structure layout for android native buffers.\n *\n * Note: this will be harmonized with gralloc_brcm.h.\n */\ntypedef enum\n{\n   EGL_BRCM_ANDROID_BUFFER_TYPE_GL_RESOURCE = 0,\n   EGL_BRCM_ANDROID_BUFFER_TYPE_MM_RESOURCE,\n} EGL_BRCM_ANDROID_BUFFER_TYPE_T;\n\n/* By default Android always define this internally, also due to a missing\n** proper pending #define in the Android frameworks/base/opengl/libs/egl/egl.cpp\n** module we cannot actually disable EGL_ANDROID_swap_rectangle support via build\n** configuration (ie setting 'TARGET_GLOBAL_CPPFLAGS += -DEGL_ANDROID_swap_rectangle=0'\n** in our BoardConfig.mk) which would be the preferred mechanism, instead we therefore\n** have to match Android behavior and define by default what is expected to be supported,\n** as well as provide an implementation for it (which implementation may be empty as\n** long as it satisfies Android expectations).\n*/\n#ifndef EGL_ANDROID_swap_rectangle\n#define EGL_ANDROID_swap_rectangle 1\n#endif\n\n#if EGL_ANDROID_swap_rectangle\n#ifdef EGL_EGLEXT_PROTOTYPES\nEGLAPI EGLBoolean EGLAPIENTRY eglSetSwapRectangleANDROID (EGLDisplay dpy, EGLSurface draw, EGLint left, EGLint top, EGLint width, EGLint height);\n#endif /* EGL_EGLEXT_PROTOTYPES */\ntypedef EGLBoolean (EGLAPIENTRYP PFNEGLSETSWAPRECTANGLEANDROIDPROC) (EGLDisplay dpy, EGLSurface draw, EGLint left, EGLint top, EGLint width, EGLint height);\n#endif /* EGL_ANDROID_swap_rectangle */\n\n\n#ifndef EGL_ANDROID_render_buffer\n#define EGL_ANDROID_render_buffer 1\n#endif\n\n#if EGL_ANDROID_render_buffer\n#ifdef EGL_EGLEXT_PROTOTYPES\nEGLAPI EGLClientBuffer EGLAPIENTRY eglGetRenderBufferANDROID (EGLDisplay dpy, EGLSurface sur);\n#endif /* EGL_EGLEXT_PROTOTYPES */\ntypedef EGLClientBuffer (EGLAPIENTRYP PFNEGLGETRENDERBUFFERANDROIDPROC) (EGLDisplay dpy, EGLSurface sur);\n#endif /* EGL_ANDROID_swap_rectangle */\n\n#ifndef EGL_ANDROID_recordable\n#define EGL_ANDROID_recordable   1\n#define EGL_RECORDABLE_ANDROID   0x3142\n#endif\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* EGLEXT_ANDROID_H */\n\n#endif /* defined(ANDROID) */\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/EGL/eglext_brcm.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n#ifndef EGLEXT_BRCM_H\n#define EGLEXT_BRCM_H\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#define EGL_NATIVE_PIXMAP_CLIENT_SIDE_BRCM 0x99930B0\t/* eglCreateImageKHR server-side target */\n#define EGL_IMAGE_FROM_SURFACE_BRCM 0x99930B1 /* eglCreateImageKHR server-side target */\n/* Multimedia target - created by gralloc */\n#define EGL_IMAGE_BRCM_MULTIMEDIA         0x99930B2\n#define EGL_IMAGE_BRCM_DUPLICATE         0x99930B3 /* a new EGL Image pointing at the same underlying object */\n#define EGL_IMAGE_BRCM_RAW_PIXELS        0x99930B4 /* Raw YUV multimedia pixels */\n\n/* Fastpath for creating greyscale textures from a single plane of a\n * MMAL opaque buffers. */\n#define EGL_IMAGE_BRCM_MULTIMEDIA_Y      0x99930C0\n#define EGL_IMAGE_BRCM_MULTIMEDIA_U      0x99930C1\n#define EGL_IMAGE_BRCM_MULTIMEDIA_V      0x99930C2\n\n/* EGL image buffer allocated in shared memory */\n#define EGL_IMAGE_BRCM_VCSM              0x99930C3\nstruct egl_image_brcm_vcsm_info {\n   unsigned width;\n   unsigned height;\n   unsigned int vcsm_handle;\n};\n\n#ifndef EGL_BRCM_sane_choose_config\n#define EGL_BRCM_sane_choose_config 1\n#endif\n#if EGL_BRCM_sane_choose_config\n#ifdef EGL_EGLEXT_PROTOTYPES\nEGLAPI EGLBoolean EGLAPIENTRY eglSaneChooseConfigBRCM(EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config);\n#endif /* EGL_EGLEXT_PROTOTYPES */\ntypedef EGLBoolean (EGLAPIENTRYP PFNEGLSANECHOOSECONFIGBRCM)(EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config);\n#endif\n\n#ifndef EGL_BRCM_global_image\n#define EGL_BRCM_global_image 1\n#endif\n#if EGL_BRCM_global_image\n#define EGL_PIXEL_FORMAT_ARGB_8888_PRE_BRCM 0\n#define EGL_PIXEL_FORMAT_ARGB_8888_BRCM     1\n#define EGL_PIXEL_FORMAT_XRGB_8888_BRCM     2\n#define EGL_PIXEL_FORMAT_RGB_565_BRCM       3\n#define EGL_PIXEL_FORMAT_A_8_BRCM           4\n#define EGL_PIXEL_FORMAT_RENDER_GL_BRCM     (1 << 3)\n#define EGL_PIXEL_FORMAT_RENDER_GLES_BRCM   (1 << 4)\n#define EGL_PIXEL_FORMAT_RENDER_GLES2_BRCM  (1 << 5)\n#define EGL_PIXEL_FORMAT_RENDER_VG_BRCM     (1 << 6)\n#define EGL_PIXEL_FORMAT_RENDER_MASK_BRCM   0x78\n#define EGL_PIXEL_FORMAT_VG_IMAGE_BRCM      (1 << 7)\n#define EGL_PIXEL_FORMAT_GLES_TEXTURE_BRCM  (1 << 8)\n#define EGL_PIXEL_FORMAT_GLES2_TEXTURE_BRCM (1 << 9)\n#define EGL_PIXEL_FORMAT_TEXTURE_MASK_BRCM  0x380\n#define EGL_PIXEL_FORMAT_USAGE_MASK_BRCM    0x3f8\n#ifdef EGL_EGLEXT_PROTOTYPES\nEGLAPI void EGLAPIENTRY eglCreateGlobalImageBRCM(EGLint width, EGLint height, EGLint pixel_format, const void *data, EGLint data_stride, EGLint *id);\nEGLAPI void EGLAPIENTRY eglCreateCopyGlobalImageBRCM(const EGLint *src_id, EGLint *id);\nEGLAPI EGLBoolean EGLAPIENTRY eglDestroyGlobalImageBRCM(const EGLint *id);\nEGLAPI EGLBoolean EGLAPIENTRY eglQueryGlobalImageBRCM(const EGLint *id, EGLint *width_height_pixel_format);\n#endif /* EGL_EGLEXT_PROTOTYPES */\ntypedef void (EGLAPIENTRYP PFNEGLCREATEGLOBALIMAGEBRCMPROC)(EGLint width, EGLint height, EGLint pixel_format, const void *data, EGLint data_stride, EGLint *id);\ntypedef void (EGLAPIENTRYP PFNEGLCREATECOPYGLOBALIMAGEBRCMPROC)(const EGLint *src_id, EGLint *id);\ntypedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYGLOBALIMAGEBRCMPROC)(const EGLint *id);\ntypedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYGLOBALIMAGEBRCMPROC)(const EGLint *id, EGLint *width_height_pixel_format);\n#endif\n\n#ifndef EGL_BRCM_perf_monitor\n#define EGL_BRCM_perf_monitor 0\n#endif\n#if EGL_BRCM_perf_monitor\n#ifdef EGL_EGLEXT_PROTOTYPES\nEGLAPI EGLBoolean EGLAPIENTRY eglInitPerfMonitorBRCM(EGLDisplay display);\nEGLAPI EGLBoolean EGLAPIENTRY eglTermPerfMonitorBRCM(EGLDisplay display);\n#endif /* EGL_EGLEXT_PROTOTYPES */\ntypedef void (EGLAPIENTRYP PFNEGLINITPERFMONITORBRCMPROC)(EGLDisplay display);\ntypedef void (EGLAPIENTRYP PFNEGLTERMPERFMONITORBRCMPROC)(EGLDisplay display);\n#endif\n\n#ifndef EGL_BRCM_driver_monitor\n#define EGL_BRCM_driver_monitor 1\n#endif\n#if EGL_BRCM_driver_monitor\n#ifdef EGL_EGLEXT_PROTOTYPES\nEGLAPI EGLBoolean EGLAPIENTRY eglInitDriverMonitorBRCM(EGLDisplay display, EGLint hw_bank, EGLint l3c_bank);\nEGLAPI void EGLAPIENTRY eglGetDriverMonitorXMLBRCM(EGLDisplay display, EGLint bufSize, EGLint *length, char *xmlStats);\nEGLAPI EGLBoolean EGLAPIENTRY eglTermDriverMonitorBRCM(EGLDisplay display);\n#endif /* EGL_EGLEXT_PROTOTYPES */\ntypedef void (EGLAPIENTRYP PFNEGLINITDRIVERMONITORBRCMPROC)(EGLDisplay display, EGLint hw_bank, EGLint l3c_bank);\ntypedef void (EGLAPIENTRYP PFNEGLGETDRIVERMONITORXMLBRCMPROC)(EGLDisplay display, EGLint bufSize, EGLint *length, char *xmlStats);\ntypedef void (EGLAPIENTRYP PFNEGLTERMDRIVERMONITORBRCMPROC)(EGLDisplay display);\n#endif\n\n#ifndef EGL_BRCM_perf_stats\n#define EGL_BRCM_perf_stats 0\n#endif\n#if EGL_BRCM_perf_stats\n#ifdef EGL_EGLEXT_PROTOTYPES\nEGLAPI void eglPerfStatsResetBRCM(void);\nEGLAPI void eglPerfStatsGetBRCM(char *buffer, EGLint buffer_len, EGLBoolean reset);\n#endif\ntypedef void (EGLAPIENTRYP PFNEGLPERFSTATSRESETBRCM) (void);\ntypedef void (EGLAPIENTRYP PFNEGLPERFSTATSGETBRCM) (char *buffer, EGLint buffer_len, EGLBoolean reset);\n#endif\n\n#ifndef EGL_proc_state_valid\n#define EGL_proc_state_valid 1\n#endif\n#if EGL_proc_state_valid\n#ifdef EGL_EGLEXT_PROTOTYPES\nEGLAPI void EGLAPIENTRY eglProcStateValid( EGLDisplay dpy, EGLBoolean *result );\n#endif\ntypedef void (EGLAPIENTRYP PFNEGLPROCSTATEVALID) ( EGLDisplay dpy, EGLBoolean *valid );\n#endif\n\n#ifndef EGL_BRCM_flush\n#define EGL_BRCM_flush 1\n#endif\n#if EGL_BRCM_flush\n#ifdef EGL_EGLEXT_PROTOTYPES\nEGLAPI void EGLAPIENTRY eglFlushBRCM(void);\n#endif /* EGL_EGLEXT_PROTOTYPES */\ntypedef void (EGLAPIENTRYP PFNEGLFLUSHBRCMPROC)(void);\n#endif\n\n#ifndef EGL_BRCM_image_wrap\n#define EGL_BRCM_image_wrap 1\n#define EGL_IMAGE_WRAP_BRCM 0x9993140\n#endif\n\n#ifndef EGL_BRCM_image_wrap_bcg\n#define EGL_BRCM_image_wrap_bcg 0\n#define EGL_IMAGE_WRAP_BRCM_BCG 0x9993141\n\n#if EGL_BRCM_image_wrap_bcg\ntypedef struct {\n   BEGL_BufferFormat format;\n\n   uint16_t width;\n   uint16_t height;\n\n   int32_t stride; /* in bytes */\n\n   void *storage;\n} EGL_IMAGE_WRAP_BRCM_BCG_IMAGE_T;\n#endif\n\n#endif\n\n#ifndef EGL_BRCM_mem_usage\n#define EGL_BRCM_mem_usage 0\n#endif\n#if EGL_BRCM_mem_usage\n#ifdef EGL_EGLEXT_PROTOTYPES\nEGLAPI void eglProcessMemUsageGetBRCM(uint32_t id_0, uint32_t id_1, char *buffer, uint32_t buffer_len);\n#endif\ntypedef void (EGLAPIENTRYP PFNEGLPROCESSMEMUSAGEGETBRCM) (uint32_t id_0, uint32_t id_1, char *buffer, uint32_t buffer_len);\n#endif\n\n/*\nOnly enable this #define if the application (or wrapper layer) is going to call eglDirectRenderingPointer\nwhen appropriate (i.e. the first time eglMakeCurrent is called, and then at eglSwapBuffers)\n\nOnly used for testing purposes on 2763\n*/\n//#define DIRECT_RENDERING\n\n#ifdef DIRECT_RENDERING\nEGLAPI EGLBoolean EGLAPIENTRY eglDirectRenderingPointer(EGLDisplay dpy, EGLSurface surf, void *image /* KHRN_IMAGE_WRAP_T */);\n#endif\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/EGL/eglext_nvidia.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n#if defined(ANDROID)\n\n#ifndef EGLEXT_NVIDIA_H\n#define EGLEXT_NVIDIA_H\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#ifndef EGL_NV_system_time\n#define EGL_NV_system_time 1\ntypedef khronos_int64_t EGLint64NV;\ntypedef khronos_uint64_t EGLuint64NV;\n#ifdef EGL_EGLEXT_PROTOTYPES\nEGLAPI EGLuint64NV EGLAPIENTRY eglGetSystemTimeFrequencyNV(void);\nEGLAPI EGLuint64NV EGLAPIENTRY eglGetSystemTimeNV(void);\n#endif\ntypedef EGLuint64NV (EGLAPIENTRYP PFNEGLGETSYSTEMTIMEFREQUENCYNVPROC)(void);\ntypedef EGLuint64NV (EGLAPIENTRYP PFNEGLGETSYSTEMTIMENVPROC)(void);\n#endif\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* EGLEXT_NVIDIA_H */\n\n#endif /* defined(ANDROID) */\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/EGL/eglplatform.h",
    "content": "#ifndef __eglplatform_h_\n#define __eglplatform_h_\n\n/*\n** Copyright (c) 2007-2009 The Khronos Group Inc.\n**\n** Permission is hereby granted, free of charge, to any person obtaining a\n** copy of this software and/or associated documentation files (the\n** \"Materials\"), to deal in the Materials without restriction, including\n** without limitation the rights to use, copy, modify, merge, publish,\n** distribute, sublicense, and/or sell copies of the Materials, and to\n** permit persons to whom the Materials are furnished to do so, subject to\n** the following conditions:\n**\n** The above copyright notice and this permission notice shall be included\n** in all copies or substantial portions of the Materials.\n**\n** THE MATERIALS ARE PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\n** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\n** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\n** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.\n*/\n\n/* Platform-specific types and definitions for egl.h\n * $Revision: 12306 $ on $Date: 2010-08-25 09:51:28 -0700 (Wed, 25 Aug 2010) $\n *\n * Adopters may modify khrplatform.h and this file to suit their platform.\n * You are encouraged to submit all modifications to the Khronos group so that\n * they can be included in future versions of this file.  Please submit changes\n * by sending them to the public Khronos Bugzilla (http://khronos.org/bugzilla)\n * by filing a bug against product \"EGL\" component \"Registry\".\n */\n\n#include \"../KHR/khrplatform.h\"\n\n#ifdef ABSTRACT_PLATFORM\n#include \"begl_memplatform.h\"\n#include \"begl_hwplatform.h\"\n#include \"begl_dispplatform.h\"\n#endif /* ABSTRACT_PLATFORM */\n\n/* Macros used in EGL function prototype declarations.\n *\n * EGL functions should be prototyped as:\n *\n * EGLAPI return-type EGLAPIENTRY eglFunction(arguments);\n * typedef return-type (EXPAPIENTRYP PFNEGLFUNCTIONPROC) (arguments);\n *\n * KHRONOS_APICALL and KHRONOS_APIENTRY are defined in KHR/khrplatform.h\n */\n\n#ifndef EGLAPI\n#define EGLAPI KHRONOS_APICALL\n#endif\n\n#ifndef EGLAPIENTRY\n#define EGLAPIENTRY  KHRONOS_APIENTRY\n#endif\n#ifndef EGLAPIENTRYP\n#define EGLAPIENTRYP EGLAPIENTRY *\n#endif\n#ifndef EGLAPI\n#ifdef KHAPI\n#define EGLAPI KHAPI\n#else\n#define EGLAPI extern\n#endif\n#endif\n\n/* The types NativeDisplayType, NativeWindowType, and NativePixmapType\n * are aliases of window-system-dependent types, such as X Display * or\n * Windows Device Context. They must be defined in platform-specific\n * code below. The EGL-prefixed versions of Native*Type are the same\n * types, renamed in EGL 1.3 so all types in the API start with \"EGL\".\n *\n * Khronos STRONGLY RECOMMENDS that you use the default definitions\n * provided below, since these changes affect both binary and source\n * portability of applications using EGL running on different EGL\n * implementations.\n */\n\n/* Unix (tentative)\n    #include <X headers>\n    typedef Display *NativeDisplayType;\n      - or maybe, if encoding \"hostname:display.head\"\n    typedef const char *NativeWindowType;\n        etc.\n */\n#if (defined (__ANDROID__) || defined(ANDROID)) && defined(KHRN_BCG_ANDROID)\n\nstruct android_native_window_t;\nstruct egl_native_pixmap_t;\n\ntypedef struct android_native_window_t* EGLNativeWindowType;\ntypedef struct egl_native_pixmap_t*     EGLNativePixmapType;\ntypedef void *EGLNativeDisplayType;\n\n#else\n\ntypedef void *EGLNativeDisplayType;\ntypedef void *EGLNativePixmapType;\ntypedef void *EGLNativeWindowType;\n#endif\n\n#ifndef EGL_SERVER_SMALLINT\n\n#include \"interface/vmcs_host/vc_dispmanx.h\"\n/* TODO: EGLNativeWindowType is really one of these but I'm leaving it\n * as void* for now, in case changing it would cause problems\n */\ntypedef struct {\n   DISPMANX_ELEMENT_HANDLE_T element;\n   int width;   /* This is necessary because dispmanx elements are not queriable. */\n   int height;\n} EGL_DISPMANX_WINDOW_T;\n#elif defined (ABSTRACT_PLATFORM)\n\n#else\n\n/* window I of a horizontal strip of N WxH windows */\n#define PACK_NATIVE_WINDOW(W, H, I, N) ((NativeWindowType)((W) | ((H) << 12) | ((I) << 24) | ((N) << 28)))\n#define UNPACK_NATIVE_WINDOW_W(WIN) ((unsigned int)(WIN) & 0xfff)\n#define UNPACK_NATIVE_WINDOW_H(WIN) (((unsigned int)(WIN) >> 12) & 0xfff)\n#define UNPACK_NATIVE_WINDOW_I(WIN) (((unsigned int)(WIN) >> 24) & 0xf)\n#define UNPACK_NATIVE_WINDOW_N(WIN) ((unsigned int)(WIN) >> 28)\n\n/* todo: can we change these to use PACK_NATIVE_WINDOW and get rid of platform_canonical_win from platform.h? */\n#define NATIVE_WINDOW_800_480    ((NativeWindowType)0)\n#define NATIVE_WINDOW_640_480    ((NativeWindowType)1)\n#define NATIVE_WINDOW_320_240    ((NativeWindowType)2)\n#define NATIVE_WINDOW_240_320    ((NativeWindowType)3)\n#define NATIVE_WINDOW_64_64      ((NativeWindowType)4)\n#define NATIVE_WINDOW_400_480_A  ((NativeWindowType)5)\n#define NATIVE_WINDOW_400_480_B  ((NativeWindowType)6)\n#define NATIVE_WINDOW_512_512    ((NativeWindowType)7)\n#define NATIVE_WINDOW_360_640    ((NativeWindowType)8)\n#define NATIVE_WINDOW_640_360    ((NativeWindowType)9)\n#define NATIVE_WINDOW_1280_720   ((NativeWindowType)10)\n#define NATIVE_WINDOW_1920_1080  ((NativeWindowType)11)\n#define NATIVE_WINDOW_480_320    ((NativeWindowType)12)\n#define NATIVE_WINDOW_1680_1050  ((NativeWindowType)13)\n#endif\n\n/* EGL 1.2 types, renamed for consistency in EGL 1.3 */\ntypedef EGLNativeDisplayType NativeDisplayType;\ntypedef EGLNativePixmapType  NativePixmapType;\ntypedef EGLNativeWindowType  NativeWindowType;\n\n\n/* Define EGLint. This must be a signed integral type large enough to contain\n * all legal attribute names and values passed into and out of EGL, whether\n * their type is boolean, bitmask, enumerant (symbolic constant), integer,\n * handle, or other.  While in general a 32-bit integer will suffice, if\n * handles are 64 bit types, then EGLint should be defined as a signed 64-bit\n * integer type.\n */\ntypedef khronos_int32_t EGLint;\n\n#ifdef ABSTRACT_PLATFORM\n\n#ifdef __cplusplus\nextern \"C\"\n{\n#endif\n\n/*\nThe client application, or default platform library must register valid versions of each of these\ninterfaces before any EGL or GL functions are invoked, using the following functions provided by the 3D driver.\n*/\ntypedef struct\n{\n   BEGL_MemoryInterface  *memInterface;     /* Memory interface which will called by the 3d driver */\n   BEGL_HWInterface      *hwInterface;      /* Hardware interface which will be called by the driver */\n   BEGL_DisplayInterface *displayInterface; /* Display interface which will be called by the driver */\n\n   BEGL_DisplayCallbacks displayCallbacks; /* Callback pointers set by BEGL_GetDefaultDriverInterfaces, for client to call into driver */\n   int hwInterfaceCloned;\n   int memInterfaceCloned;\n   void *memInterfaceFn;\n   void *hwInterfaceFn;\n} BEGL_DriverInterfaces;\n\n/* Register application level overrides for any or all of the abstract API calls made by the 3D driver. */\nEGLAPI void EGLAPIENTRY BEGL_RegisterDriverInterfaces(BEGL_DriverInterfaces *iface);\n\n/* Get a pointer to the registered driver interfaces, can be used to override partial defaults - see android platform layer(s) for example */\nEGLAPI BEGL_DriverInterfaces * BEGL_GetDriverInterfaces(void);\n\n/* Initializes all interfaces in the structure to NULL, fills out Callbacks with appropriate function pointers */\nEGLAPI void EGLAPIENTRY BEGL_GetDefaultDriverInterfaces(BEGL_DriverInterfaces *iface);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* ABSTRACT_PLATFORM */\n\n#if 0\n#include \"interface/khronos/common/khrn_client_mangle.h\"\n#endif\n\n#endif /* __eglplatform_h */\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/GLES2/gl2.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n#ifndef __gl2_h_\n#define __gl2_h_\n\n/* $Revision: 10602 $ on $Date:: 2010-03-05 06:35:34 +0000 #$ */\n\n#include \"gl2platform.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/*\n * This document is licensed under the SGI Free Software B License Version\n * 2.0. For details, see http://oss.sgi.com/projects/FreeB/ .\n */\n\n/*-------------------------------------------------------------------------\n * Data type definitions\n *-----------------------------------------------------------------------*/\n\n#ifndef __gl_h_\ntypedef void             GLvoid;\ntypedef char             GLchar;\ntypedef unsigned int     GLenum;\ntypedef unsigned char    GLboolean;\ntypedef unsigned int     GLbitfield;\ntypedef khronos_int8_t   GLbyte;\ntypedef short            GLshort;\ntypedef int              GLint;\ntypedef int              GLsizei;\ntypedef khronos_uint8_t  GLubyte;\ntypedef unsigned short   GLushort;\ntypedef unsigned int     GLuint;\ntypedef khronos_float_t  GLfloat;\ntypedef khronos_float_t  GLclampf;\ntypedef khronos_int32_t  GLfixed;\n\n/* GL types for handling large vertex buffer objects */\ntypedef khronos_intptr_t GLintptr;\ntypedef khronos_ssize_t  GLsizeiptr;\n#endif\n\n/* OpenGL ES core versions */\n#define GL_ES_VERSION_2_0                 1\n\n/* ClearBufferMask */\n#define GL_DEPTH_BUFFER_BIT               0x00000100\n#define GL_STENCIL_BUFFER_BIT             0x00000400\n#define GL_COLOR_BUFFER_BIT               0x00004000\n\n/* Boolean */\n#define GL_FALSE                          (GLboolean)0\n#define GL_TRUE                           (GLboolean)1\n\n/* BeginMode */\n#define GL_POINTS                         0x0000\n#define GL_LINES                          0x0001\n#define GL_LINE_LOOP                      0x0002\n#define GL_LINE_STRIP                     0x0003\n#define GL_TRIANGLES                      0x0004\n#define GL_TRIANGLE_STRIP                 0x0005\n#define GL_TRIANGLE_FAN                   0x0006\n\n/* AlphaFunction (not supported in ES20) */\n/*      GL_NEVER */\n/*      GL_LESS */\n/*      GL_EQUAL */\n/*      GL_LEQUAL */\n/*      GL_GREATER */\n/*      GL_NOTEQUAL */\n/*      GL_GEQUAL */\n/*      GL_ALWAYS */\n\n/* BlendingFactorDest */\n#define GL_ZERO                           0\n#define GL_ONE                            1\n#define GL_SRC_COLOR                      0x0300\n#define GL_ONE_MINUS_SRC_COLOR            0x0301\n#define GL_SRC_ALPHA                      0x0302\n#define GL_ONE_MINUS_SRC_ALPHA            0x0303\n#define GL_DST_ALPHA                      0x0304\n#define GL_ONE_MINUS_DST_ALPHA            0x0305\n\n/* BlendingFactorSrc */\n/*      GL_ZERO */\n/*      GL_ONE */\n#define GL_DST_COLOR                      0x0306\n#define GL_ONE_MINUS_DST_COLOR            0x0307\n#define GL_SRC_ALPHA_SATURATE             0x0308\n/*      GL_SRC_ALPHA */\n/*      GL_ONE_MINUS_SRC_ALPHA */\n/*      GL_DST_ALPHA */\n/*      GL_ONE_MINUS_DST_ALPHA */\n\n/* BlendEquationSeparate */\n#define GL_FUNC_ADD                       0x8006\n#define GL_BLEND_EQUATION                 0x8009\n#define GL_BLEND_EQUATION_RGB             0x8009    /* same as BLEND_EQUATION */\n#define GL_BLEND_EQUATION_ALPHA           0x883D\n\n/* BlendSubtract */\n#define GL_FUNC_SUBTRACT                  0x800A\n#define GL_FUNC_REVERSE_SUBTRACT          0x800B\n\n/* Separate Blend Functions */\n#define GL_BLEND_DST_RGB                  0x80C8\n#define GL_BLEND_SRC_RGB                  0x80C9\n#define GL_BLEND_DST_ALPHA                0x80CA\n#define GL_BLEND_SRC_ALPHA                0x80CB\n#define GL_CONSTANT_COLOR                 0x8001\n#define GL_ONE_MINUS_CONSTANT_COLOR       0x8002\n#define GL_CONSTANT_ALPHA                 0x8003\n#define GL_ONE_MINUS_CONSTANT_ALPHA       0x8004\n#define GL_BLEND_COLOR                    0x8005\n\n/* Buffer Objects */\n#define GL_ARRAY_BUFFER                   0x8892\n#define GL_ELEMENT_ARRAY_BUFFER           0x8893\n#define GL_ARRAY_BUFFER_BINDING           0x8894\n#define GL_ELEMENT_ARRAY_BUFFER_BINDING   0x8895\n\n#define GL_STREAM_DRAW                    0x88E0\n#define GL_STATIC_DRAW                    0x88E4\n#define GL_DYNAMIC_DRAW                   0x88E8\n\n#define GL_BUFFER_SIZE                    0x8764\n#define GL_BUFFER_USAGE                   0x8765\n\n#define GL_CURRENT_VERTEX_ATTRIB          0x8626\n\n/* CullFaceMode */\n#define GL_FRONT                          0x0404\n#define GL_BACK                           0x0405\n#define GL_FRONT_AND_BACK                 0x0408\n\n/* DepthFunction */\n/*      GL_NEVER */\n/*      GL_LESS */\n/*      GL_EQUAL */\n/*      GL_LEQUAL */\n/*      GL_GREATER */\n/*      GL_NOTEQUAL */\n/*      GL_GEQUAL */\n/*      GL_ALWAYS */\n\n/* EnableCap */\n#define GL_TEXTURE_2D                     0x0DE1\n#define GL_CULL_FACE                      0x0B44\n#define GL_BLEND                          0x0BE2\n#define GL_DITHER                         0x0BD0\n#define GL_STENCIL_TEST                   0x0B90\n#define GL_DEPTH_TEST                     0x0B71\n#define GL_SCISSOR_TEST                   0x0C11\n#define GL_POLYGON_OFFSET_FILL            0x8037\n#define GL_SAMPLE_ALPHA_TO_COVERAGE       0x809E\n#define GL_SAMPLE_COVERAGE                0x80A0\n\n/* ErrorCode */\n#define GL_NO_ERROR                       0\n#define GL_INVALID_ENUM                   0x0500\n#define GL_INVALID_VALUE                  0x0501\n#define GL_INVALID_OPERATION              0x0502\n#define GL_OUT_OF_MEMORY                  0x0505\n\n/* FrontFaceDirection */\n#define GL_CW                             0x0900\n#define GL_CCW                            0x0901\n\n/* GetPName */\n#define GL_LINE_WIDTH                     0x0B21\n#define GL_ALIASED_POINT_SIZE_RANGE       0x846D\n#define GL_ALIASED_LINE_WIDTH_RANGE       0x846E\n#define GL_CULL_FACE_MODE                 0x0B45\n#define GL_FRONT_FACE                     0x0B46\n#define GL_DEPTH_RANGE                    0x0B70\n#define GL_DEPTH_WRITEMASK                0x0B72\n#define GL_DEPTH_CLEAR_VALUE              0x0B73\n#define GL_DEPTH_FUNC                     0x0B74\n#define GL_STENCIL_CLEAR_VALUE            0x0B91\n#define GL_STENCIL_FUNC                   0x0B92\n#define GL_STENCIL_FAIL                   0x0B94\n#define GL_STENCIL_PASS_DEPTH_FAIL        0x0B95\n#define GL_STENCIL_PASS_DEPTH_PASS        0x0B96\n#define GL_STENCIL_REF                    0x0B97\n#define GL_STENCIL_VALUE_MASK             0x0B93\n#define GL_STENCIL_WRITEMASK              0x0B98\n#define GL_STENCIL_BACK_FUNC              0x8800\n#define GL_STENCIL_BACK_FAIL              0x8801\n#define GL_STENCIL_BACK_PASS_DEPTH_FAIL   0x8802\n#define GL_STENCIL_BACK_PASS_DEPTH_PASS   0x8803\n#define GL_STENCIL_BACK_REF               0x8CA3\n#define GL_STENCIL_BACK_VALUE_MASK        0x8CA4\n#define GL_STENCIL_BACK_WRITEMASK         0x8CA5\n#define GL_VIEWPORT                       0x0BA2\n#define GL_SCISSOR_BOX                    0x0C10\n/*      GL_SCISSOR_TEST */\n#define GL_COLOR_CLEAR_VALUE              0x0C22\n#define GL_COLOR_WRITEMASK                0x0C23\n#define GL_UNPACK_ALIGNMENT               0x0CF5\n#define GL_PACK_ALIGNMENT                 0x0D05\n#define GL_MAX_TEXTURE_SIZE               0x0D33\n#define GL_MAX_VIEWPORT_DIMS              0x0D3A\n#define GL_SUBPIXEL_BITS                  0x0D50\n#define GL_RED_BITS                       0x0D52\n#define GL_GREEN_BITS                     0x0D53\n#define GL_BLUE_BITS                      0x0D54\n#define GL_ALPHA_BITS                     0x0D55\n#define GL_DEPTH_BITS                     0x0D56\n#define GL_STENCIL_BITS                   0x0D57\n#define GL_POLYGON_OFFSET_UNITS           0x2A00\n/*      GL_POLYGON_OFFSET_FILL */\n#define GL_POLYGON_OFFSET_FACTOR          0x8038\n#define GL_TEXTURE_BINDING_2D             0x8069\n#define GL_SAMPLE_BUFFERS                 0x80A8\n#define GL_SAMPLES                        0x80A9\n#define GL_SAMPLE_COVERAGE_VALUE          0x80AA\n#define GL_SAMPLE_COVERAGE_INVERT         0x80AB\n\n/* GetTextureParameter */\n/*      GL_TEXTURE_MAG_FILTER */\n/*      GL_TEXTURE_MIN_FILTER */\n/*      GL_TEXTURE_WRAP_S */\n/*      GL_TEXTURE_WRAP_T */\n\n#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2\n#define GL_COMPRESSED_TEXTURE_FORMATS     0x86A3\n\n/* HintMode */\n#define GL_DONT_CARE                      0x1100\n#define GL_FASTEST                        0x1101\n#define GL_NICEST                         0x1102\n\n/* HintTarget */\n#define GL_GENERATE_MIPMAP_HINT            0x8192\n\n/* DataType */\n#define GL_BYTE                           0x1400\n#define GL_UNSIGNED_BYTE                  0x1401\n#define GL_SHORT                          0x1402\n#define GL_UNSIGNED_SHORT                 0x1403\n#define GL_INT                            0x1404\n#define GL_UNSIGNED_INT                   0x1405\n#define GL_FLOAT                          0x1406\n#define GL_FIXED                          0x140C\n\n/* PixelFormat */\n#define GL_DEPTH_COMPONENT                0x1902\n#define GL_ALPHA                          0x1906\n#define GL_RGB                            0x1907\n#define GL_RGBA                           0x1908\n#define GL_LUMINANCE                      0x1909\n#define GL_LUMINANCE_ALPHA                0x190A\n\n/* PixelType */\n/*      GL_UNSIGNED_BYTE */\n#define GL_UNSIGNED_SHORT_4_4_4_4         0x8033\n#define GL_UNSIGNED_SHORT_5_5_5_1         0x8034\n#define GL_UNSIGNED_SHORT_5_6_5           0x8363\n\n/* Shaders */\n#define GL_FRAGMENT_SHADER                  0x8B30\n#define GL_VERTEX_SHADER                    0x8B31\n#define GL_MAX_VERTEX_ATTRIBS               0x8869\n#define GL_MAX_VERTEX_UNIFORM_VECTORS       0x8DFB\n#define GL_MAX_VARYING_VECTORS              0x8DFC\n#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D\n#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS   0x8B4C\n#define GL_MAX_TEXTURE_IMAGE_UNITS          0x8872\n#define GL_MAX_FRAGMENT_UNIFORM_VECTORS     0x8DFD\n#define GL_SHADER_TYPE                      0x8B4F\n#define GL_DELETE_STATUS                    0x8B80\n#define GL_LINK_STATUS                      0x8B82\n#define GL_VALIDATE_STATUS                  0x8B83\n#define GL_ATTACHED_SHADERS                 0x8B85\n#define GL_ACTIVE_UNIFORMS                  0x8B86\n#define GL_ACTIVE_UNIFORM_MAX_LENGTH        0x8B87\n#define GL_ACTIVE_ATTRIBUTES                0x8B89\n#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH      0x8B8A\n#define GL_SHADING_LANGUAGE_VERSION         0x8B8C\n#define GL_CURRENT_PROGRAM                  0x8B8D\n\n/* StencilFunction */\n#define GL_NEVER                          0x0200\n#define GL_LESS                           0x0201\n#define GL_EQUAL                          0x0202\n#define GL_LEQUAL                         0x0203\n#define GL_GREATER                        0x0204\n#define GL_NOTEQUAL                       0x0205\n#define GL_GEQUAL                         0x0206\n#define GL_ALWAYS                         0x0207\n\n/* StencilOp */\n/*      GL_ZERO */\n#define GL_KEEP                           0x1E00\n#define GL_REPLACE                        0x1E01\n#define GL_INCR                           0x1E02\n#define GL_DECR                           0x1E03\n#define GL_INVERT                         0x150A\n#define GL_INCR_WRAP                      0x8507\n#define GL_DECR_WRAP                      0x8508\n\n/* StringName */\n#define GL_VENDOR                         0x1F00\n#define GL_RENDERER                       0x1F01\n#define GL_VERSION                        0x1F02\n#define GL_EXTENSIONS                     0x1F03\n\n/* TextureMagFilter */\n#define GL_NEAREST                        0x2600\n#define GL_LINEAR                         0x2601\n\n/* TextureMinFilter */\n/*      GL_NEAREST */\n/*      GL_LINEAR */\n#define GL_NEAREST_MIPMAP_NEAREST         0x2700\n#define GL_LINEAR_MIPMAP_NEAREST          0x2701\n#define GL_NEAREST_MIPMAP_LINEAR          0x2702\n#define GL_LINEAR_MIPMAP_LINEAR           0x2703\n\n/* TextureParameterName */\n#define GL_TEXTURE_MAG_FILTER             0x2800\n#define GL_TEXTURE_MIN_FILTER             0x2801\n#define GL_TEXTURE_WRAP_S                 0x2802\n#define GL_TEXTURE_WRAP_T                 0x2803\n\n/* TextureTarget */\n/*      GL_TEXTURE_2D */\n#define GL_TEXTURE                        0x1702\n\n#define GL_TEXTURE_CUBE_MAP               0x8513\n#define GL_TEXTURE_BINDING_CUBE_MAP       0x8514\n#define GL_TEXTURE_CUBE_MAP_POSITIVE_X    0x8515\n#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X    0x8516\n#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y    0x8517\n#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y    0x8518\n#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z    0x8519\n#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z    0x851A\n#define GL_MAX_CUBE_MAP_TEXTURE_SIZE      0x851C\n\n/* TextureUnit */\n#define GL_TEXTURE0                       0x84C0\n#define GL_TEXTURE1                       0x84C1\n#define GL_TEXTURE2                       0x84C2\n#define GL_TEXTURE3                       0x84C3\n#define GL_TEXTURE4                       0x84C4\n#define GL_TEXTURE5                       0x84C5\n#define GL_TEXTURE6                       0x84C6\n#define GL_TEXTURE7                       0x84C7\n#define GL_TEXTURE8                       0x84C8\n#define GL_TEXTURE9                       0x84C9\n#define GL_TEXTURE10                      0x84CA\n#define GL_TEXTURE11                      0x84CB\n#define GL_TEXTURE12                      0x84CC\n#define GL_TEXTURE13                      0x84CD\n#define GL_TEXTURE14                      0x84CE\n#define GL_TEXTURE15                      0x84CF\n#define GL_TEXTURE16                      0x84D0\n#define GL_TEXTURE17                      0x84D1\n#define GL_TEXTURE18                      0x84D2\n#define GL_TEXTURE19                      0x84D3\n#define GL_TEXTURE20                      0x84D4\n#define GL_TEXTURE21                      0x84D5\n#define GL_TEXTURE22                      0x84D6\n#define GL_TEXTURE23                      0x84D7\n#define GL_TEXTURE24                      0x84D8\n#define GL_TEXTURE25                      0x84D9\n#define GL_TEXTURE26                      0x84DA\n#define GL_TEXTURE27                      0x84DB\n#define GL_TEXTURE28                      0x84DC\n#define GL_TEXTURE29                      0x84DD\n#define GL_TEXTURE30                      0x84DE\n#define GL_TEXTURE31                      0x84DF\n#define GL_ACTIVE_TEXTURE                 0x84E0\n\n/* TextureWrapMode */\n#define GL_REPEAT                         0x2901\n#define GL_CLAMP_TO_EDGE                  0x812F\n#define GL_MIRRORED_REPEAT                0x8370\n\n/* Uniform Types */\n#define GL_FLOAT_VEC2                     0x8B50\n#define GL_FLOAT_VEC3                     0x8B51\n#define GL_FLOAT_VEC4                     0x8B52\n#define GL_INT_VEC2                       0x8B53\n#define GL_INT_VEC3                       0x8B54\n#define GL_INT_VEC4                       0x8B55\n#define GL_BOOL                           0x8B56\n#define GL_BOOL_VEC2                      0x8B57\n#define GL_BOOL_VEC3                      0x8B58\n#define GL_BOOL_VEC4                      0x8B59\n#define GL_FLOAT_MAT2                     0x8B5A\n#define GL_FLOAT_MAT3                     0x8B5B\n#define GL_FLOAT_MAT4                     0x8B5C\n#define GL_SAMPLER_2D                     0x8B5E\n#define GL_SAMPLER_CUBE                   0x8B60\n\n/* Vertex Arrays */\n#define GL_VERTEX_ATTRIB_ARRAY_ENABLED        0x8622\n#define GL_VERTEX_ATTRIB_ARRAY_SIZE           0x8623\n#define GL_VERTEX_ATTRIB_ARRAY_STRIDE         0x8624\n#define GL_VERTEX_ATTRIB_ARRAY_TYPE           0x8625\n#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED     0x886A\n#define GL_VERTEX_ATTRIB_ARRAY_POINTER        0x8645\n#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F\n\n/* Read Format */\n#define GL_IMPLEMENTATION_COLOR_READ_TYPE   0x8B9A\n#define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B\n\n/* Shader Source */\n#define GL_COMPILE_STATUS                 0x8B81\n#define GL_INFO_LOG_LENGTH                0x8B84\n#define GL_SHADER_SOURCE_LENGTH           0x8B88\n#define GL_SHADER_COMPILER                0x8DFA\n\n/* Shader Binary */\n#define GL_SHADER_BINARY_FORMATS          0x8DF8\n#define GL_NUM_SHADER_BINARY_FORMATS      0x8DF9\n\n/* Shader Precision-Specified Types */\n#define GL_LOW_FLOAT                      0x8DF0\n#define GL_MEDIUM_FLOAT                   0x8DF1\n#define GL_HIGH_FLOAT                     0x8DF2\n#define GL_LOW_INT                        0x8DF3\n#define GL_MEDIUM_INT                     0x8DF4\n#define GL_HIGH_INT                       0x8DF5\n\n/* Framebuffer Object. */\n#define GL_FRAMEBUFFER                    0x8D40\n#define GL_RENDERBUFFER                   0x8D41\n\n#define GL_RGBA4                          0x8056\n#define GL_RGB5_A1                        0x8057\n#define GL_RGB565                         0x8D62\n#define GL_DEPTH_COMPONENT16              0x81A5\n#define GL_STENCIL_INDEX                  0x1901\n#define GL_STENCIL_INDEX8                 0x8D48\n\n#define GL_RENDERBUFFER_WIDTH             0x8D42\n#define GL_RENDERBUFFER_HEIGHT            0x8D43\n#define GL_RENDERBUFFER_INTERNAL_FORMAT   0x8D44\n#define GL_RENDERBUFFER_RED_SIZE          0x8D50\n#define GL_RENDERBUFFER_GREEN_SIZE        0x8D51\n#define GL_RENDERBUFFER_BLUE_SIZE         0x8D52\n#define GL_RENDERBUFFER_ALPHA_SIZE        0x8D53\n#define GL_RENDERBUFFER_DEPTH_SIZE        0x8D54\n#define GL_RENDERBUFFER_STENCIL_SIZE      0x8D55\n\n#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE           0x8CD0\n#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME           0x8CD1\n#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL         0x8CD2\n#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3\n\n#define GL_COLOR_ATTACHMENT0              0x8CE0\n#define GL_DEPTH_ATTACHMENT               0x8D00\n#define GL_STENCIL_ATTACHMENT             0x8D20\n\n#define GL_NONE                           0\n\n#define GL_FRAMEBUFFER_COMPLETE                      0x8CD5\n#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT         0x8CD6\n#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7\n#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS         0x8CD9\n#define GL_FRAMEBUFFER_UNSUPPORTED                   0x8CDD\n\n#define GL_FRAMEBUFFER_BINDING            0x8CA6\n#define GL_RENDERBUFFER_BINDING           0x8CA7\n#define GL_MAX_RENDERBUFFER_SIZE          0x84E8\n\n#define GL_INVALID_FRAMEBUFFER_OPERATION  0x0506\n\n/*-------------------------------------------------------------------------\n * GL core functions.\n *-----------------------------------------------------------------------*/\n\nGL_APICALL void         GL_APIENTRY glActiveTexture (GLenum texture);\nGL_APICALL void         GL_APIENTRY glAttachShader (GLuint program, GLuint shader);\nGL_APICALL void         GL_APIENTRY glBindAttribLocation (GLuint program, GLuint index, const GLchar* name);\nGL_APICALL void         GL_APIENTRY glBindBuffer (GLenum target, GLuint buffer);\nGL_APICALL void         GL_APIENTRY glBindFramebuffer (GLenum target, GLuint framebuffer);\nGL_APICALL void         GL_APIENTRY glBindRenderbuffer (GLenum target, GLuint renderbuffer);\nGL_APICALL void         GL_APIENTRY glBindTexture (GLenum target, GLuint texture);\nGL_APICALL void         GL_APIENTRY glBlendColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);\nGL_APICALL void         GL_APIENTRY glBlendEquation ( GLenum mode );\nGL_APICALL void         GL_APIENTRY glBlendEquationSeparate (GLenum modeRGB, GLenum modeAlpha);\nGL_APICALL void         GL_APIENTRY glBlendFunc (GLenum sfactor, GLenum dfactor);\nGL_APICALL void         GL_APIENTRY glBlendFuncSeparate (GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);\nGL_APICALL void         GL_APIENTRY glBufferData (GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage);\nGL_APICALL void         GL_APIENTRY glBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid* data);\nGL_APICALL GLenum       GL_APIENTRY glCheckFramebufferStatus (GLenum target);\nGL_APICALL void         GL_APIENTRY glClear (GLbitfield mask);\nGL_APICALL void         GL_APIENTRY glClearColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);\nGL_APICALL void         GL_APIENTRY glClearDepthf (GLclampf depth);\nGL_APICALL void         GL_APIENTRY glClearStencil (GLint s);\nGL_APICALL void         GL_APIENTRY glColorMask (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);\nGL_APICALL void         GL_APIENTRY glCompileShader (GLuint shader);\nGL_APICALL void         GL_APIENTRY glCompressedTexImage2D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid* data);\nGL_APICALL void         GL_APIENTRY glCompressedTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid* data);\nGL_APICALL void         GL_APIENTRY glCopyTexImage2D (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);\nGL_APICALL void         GL_APIENTRY glCopyTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);\nGL_APICALL GLuint       GL_APIENTRY glCreateProgram (void);\nGL_APICALL GLuint       GL_APIENTRY glCreateShader (GLenum type);\nGL_APICALL void         GL_APIENTRY glCullFace (GLenum mode);\nGL_APICALL void         GL_APIENTRY glDeleteBuffers (GLsizei n, const GLuint* buffers);\nGL_APICALL void         GL_APIENTRY glDeleteFramebuffers (GLsizei n, const GLuint* framebuffers);\nGL_APICALL void         GL_APIENTRY glDeleteProgram (GLuint program);\nGL_APICALL void         GL_APIENTRY glDeleteRenderbuffers (GLsizei n, const GLuint* renderbuffers);\nGL_APICALL void         GL_APIENTRY glDeleteShader (GLuint shader);\nGL_APICALL void         GL_APIENTRY glDeleteTextures (GLsizei n, const GLuint* textures);\nGL_APICALL void         GL_APIENTRY glDepthFunc (GLenum func);\nGL_APICALL void         GL_APIENTRY glDepthMask (GLboolean flag);\nGL_APICALL void         GL_APIENTRY glDepthRangef (GLclampf zNear, GLclampf zFar);\nGL_APICALL void         GL_APIENTRY glDetachShader (GLuint program, GLuint shader);\nGL_APICALL void         GL_APIENTRY glDisable (GLenum cap);\nGL_APICALL void         GL_APIENTRY glDisableVertexAttribArray (GLuint index);\nGL_APICALL void         GL_APIENTRY glDrawArrays (GLenum mode, GLint first, GLsizei count);\nGL_APICALL void         GL_APIENTRY glDrawElements (GLenum mode, GLsizei count, GLenum type, const GLvoid* indices);\nGL_APICALL void         GL_APIENTRY glEnable (GLenum cap);\nGL_APICALL void         GL_APIENTRY glEnableVertexAttribArray (GLuint index);\nGL_APICALL void         GL_APIENTRY glFinish (void);\nGL_APICALL void         GL_APIENTRY glFlush (void);\nGL_APICALL void         GL_APIENTRY glFramebufferRenderbuffer (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);\nGL_APICALL void         GL_APIENTRY glFramebufferTexture2D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);\nGL_APICALL void         GL_APIENTRY glFrontFace (GLenum mode);\nGL_APICALL void         GL_APIENTRY glGenBuffers (GLsizei n, GLuint* buffers);\nGL_APICALL void         GL_APIENTRY glGenerateMipmap (GLenum target);\nGL_APICALL void         GL_APIENTRY glGenFramebuffers (GLsizei n, GLuint* framebuffers);\nGL_APICALL void         GL_APIENTRY glGenRenderbuffers (GLsizei n, GLuint* renderbuffers);\nGL_APICALL void         GL_APIENTRY glGenTextures (GLsizei n, GLuint* textures);\nGL_APICALL void         GL_APIENTRY glGetActiveAttrib (GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name);\nGL_APICALL void         GL_APIENTRY glGetActiveUniform (GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name);\nGL_APICALL void         GL_APIENTRY glGetAttachedShaders (GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders);\nGL_APICALL int          GL_APIENTRY glGetAttribLocation (GLuint program, const GLchar* name);\nGL_APICALL void         GL_APIENTRY glGetBooleanv (GLenum pname, GLboolean* params);\nGL_APICALL void         GL_APIENTRY glGetBufferParameteriv (GLenum target, GLenum pname, GLint* params);\nGL_APICALL GLenum       GL_APIENTRY glGetError (void);\nGL_APICALL void         GL_APIENTRY glGetFloatv (GLenum pname, GLfloat* params);\nGL_APICALL void         GL_APIENTRY glGetFramebufferAttachmentParameteriv (GLenum target, GLenum attachment, GLenum pname, GLint* params);\nGL_APICALL void         GL_APIENTRY glGetIntegerv (GLenum pname, GLint* params);\nGL_APICALL void         GL_APIENTRY glGetProgramiv (GLuint program, GLenum pname, GLint* params);\nGL_APICALL void         GL_APIENTRY glGetProgramInfoLog (GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog);\nGL_APICALL void         GL_APIENTRY glGetRenderbufferParameteriv (GLenum target, GLenum pname, GLint* params);\nGL_APICALL void         GL_APIENTRY glGetShaderiv (GLuint shader, GLenum pname, GLint* params);\nGL_APICALL void         GL_APIENTRY glGetShaderInfoLog (GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* infolog);\nGL_APICALL void         GL_APIENTRY glGetShaderPrecisionFormat (GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision);\nGL_APICALL void         GL_APIENTRY glGetShaderSource (GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source);\nGL_APICALL const GLubyte* GL_APIENTRY glGetString (GLenum name);\nGL_APICALL void         GL_APIENTRY glGetTexParameterfv (GLenum target, GLenum pname, GLfloat* params);\nGL_APICALL void         GL_APIENTRY glGetTexParameteriv (GLenum target, GLenum pname, GLint* params);\nGL_APICALL void         GL_APIENTRY glGetUniformfv (GLuint program, GLint location, GLfloat* params);\nGL_APICALL void         GL_APIENTRY glGetUniformiv (GLuint program, GLint location, GLint* params);\nGL_APICALL int          GL_APIENTRY glGetUniformLocation (GLuint program, const GLchar* name);\nGL_APICALL void         GL_APIENTRY glGetVertexAttribfv (GLuint index, GLenum pname, GLfloat* params);\nGL_APICALL void         GL_APIENTRY glGetVertexAttribiv (GLuint index, GLenum pname, GLint* params);\nGL_APICALL void         GL_APIENTRY glGetVertexAttribPointerv (GLuint index, GLenum pname, GLvoid** pointer);\nGL_APICALL void         GL_APIENTRY glHint (GLenum target, GLenum mode);\nGL_APICALL GLboolean    GL_APIENTRY glIsBuffer (GLuint buffer);\nGL_APICALL GLboolean    GL_APIENTRY glIsEnabled (GLenum cap);\nGL_APICALL GLboolean    GL_APIENTRY glIsFramebuffer (GLuint framebuffer);\nGL_APICALL GLboolean    GL_APIENTRY glIsProgram (GLuint program);\nGL_APICALL GLboolean    GL_APIENTRY glIsRenderbuffer (GLuint renderbuffer);\nGL_APICALL GLboolean    GL_APIENTRY glIsShader (GLuint shader);\nGL_APICALL GLboolean    GL_APIENTRY glIsTexture (GLuint texture);\nGL_APICALL void         GL_APIENTRY glLineWidth (GLfloat width);\nGL_APICALL void         GL_APIENTRY glLinkProgram (GLuint program);\nGL_APICALL void         GL_APIENTRY glPixelStorei (GLenum pname, GLint param);\nGL_APICALL void         GL_APIENTRY glPolygonOffset (GLfloat factor, GLfloat units);\nGL_APICALL void         GL_APIENTRY glReadPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* pixels);\nGL_APICALL void         GL_APIENTRY glReleaseShaderCompiler (void);\nGL_APICALL void         GL_APIENTRY glRenderbufferStorage (GLenum target, GLenum internalformat, GLsizei width, GLsizei height);\nGL_APICALL void         GL_APIENTRY glSampleCoverage (GLclampf value, GLboolean invert);\nGL_APICALL void         GL_APIENTRY glScissor (GLint x, GLint y, GLsizei width, GLsizei height);\nGL_APICALL void         GL_APIENTRY glShaderBinary (GLsizei n, const GLuint* shaders, GLenum binaryformat, const GLvoid* binary, GLsizei length);\nGL_APICALL void         GL_APIENTRY glShaderSource (GLuint shader, GLsizei count, const GLchar** string, const GLint* length);\nGL_APICALL void         GL_APIENTRY glStencilFunc (GLenum func, GLint ref, GLuint mask);\nGL_APICALL void         GL_APIENTRY glStencilFuncSeparate (GLenum face, GLenum func, GLint ref, GLuint mask);\nGL_APICALL void         GL_APIENTRY glStencilMask (GLuint mask);\nGL_APICALL void         GL_APIENTRY glStencilMaskSeparate (GLenum face, GLuint mask);\nGL_APICALL void         GL_APIENTRY glStencilOp (GLenum fail, GLenum zfail, GLenum zpass);\nGL_APICALL void         GL_APIENTRY glStencilOpSeparate (GLenum face, GLenum fail, GLenum zfail, GLenum zpass);\nGL_APICALL void         GL_APIENTRY glTexImage2D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid* pixels);\nGL_APICALL void         GL_APIENTRY glTexParameterf (GLenum target, GLenum pname, GLfloat param);\nGL_APICALL void         GL_APIENTRY glTexParameterfv (GLenum target, GLenum pname, const GLfloat* params);\nGL_APICALL void         GL_APIENTRY glTexParameteri (GLenum target, GLenum pname, GLint param);\nGL_APICALL void         GL_APIENTRY glTexParameteriv (GLenum target, GLenum pname, const GLint* params);\nGL_APICALL void         GL_APIENTRY glTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid* pixels);\nGL_APICALL void         GL_APIENTRY glUniform1f (GLint location, GLfloat x);\nGL_APICALL void         GL_APIENTRY glUniform1fv (GLint location, GLsizei count, const GLfloat* v);\nGL_APICALL void         GL_APIENTRY glUniform1i (GLint location, GLint x);\nGL_APICALL void         GL_APIENTRY glUniform1iv (GLint location, GLsizei count, const GLint* v);\nGL_APICALL void         GL_APIENTRY glUniform2f (GLint location, GLfloat x, GLfloat y);\nGL_APICALL void         GL_APIENTRY glUniform2fv (GLint location, GLsizei count, const GLfloat* v);\nGL_APICALL void         GL_APIENTRY glUniform2i (GLint location, GLint x, GLint y);\nGL_APICALL void         GL_APIENTRY glUniform2iv (GLint location, GLsizei count, const GLint* v);\nGL_APICALL void         GL_APIENTRY glUniform3f (GLint location, GLfloat x, GLfloat y, GLfloat z);\nGL_APICALL void         GL_APIENTRY glUniform3fv (GLint location, GLsizei count, const GLfloat* v);\nGL_APICALL void         GL_APIENTRY glUniform3i (GLint location, GLint x, GLint y, GLint z);\nGL_APICALL void         GL_APIENTRY glUniform3iv (GLint location, GLsizei count, const GLint* v);\nGL_APICALL void         GL_APIENTRY glUniform4f (GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w);\nGL_APICALL void         GL_APIENTRY glUniform4fv (GLint location, GLsizei count, const GLfloat* v);\nGL_APICALL void         GL_APIENTRY glUniform4i (GLint location, GLint x, GLint y, GLint z, GLint w);\nGL_APICALL void         GL_APIENTRY glUniform4iv (GLint location, GLsizei count, const GLint* v);\nGL_APICALL void         GL_APIENTRY glUniformMatrix2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);\nGL_APICALL void         GL_APIENTRY glUniformMatrix3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);\nGL_APICALL void         GL_APIENTRY glUniformMatrix4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);\nGL_APICALL void         GL_APIENTRY glUseProgram (GLuint program);\nGL_APICALL void         GL_APIENTRY glValidateProgram (GLuint program);\nGL_APICALL void         GL_APIENTRY glVertexAttrib1f (GLuint indx, GLfloat x);\nGL_APICALL void         GL_APIENTRY glVertexAttrib1fv (GLuint indx, const GLfloat* values);\nGL_APICALL void         GL_APIENTRY glVertexAttrib2f (GLuint indx, GLfloat x, GLfloat y);\nGL_APICALL void         GL_APIENTRY glVertexAttrib2fv (GLuint indx, const GLfloat* values);\nGL_APICALL void         GL_APIENTRY glVertexAttrib3f (GLuint indx, GLfloat x, GLfloat y, GLfloat z);\nGL_APICALL void         GL_APIENTRY glVertexAttrib3fv (GLuint indx, const GLfloat* values);\nGL_APICALL void         GL_APIENTRY glVertexAttrib4f (GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w);\nGL_APICALL void         GL_APIENTRY glVertexAttrib4fv (GLuint indx, const GLfloat* values);\nGL_APICALL void         GL_APIENTRY glVertexAttribPointer (GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* ptr);\nGL_APICALL void         GL_APIENTRY glViewport (GLint x, GLint y, GLsizei width, GLsizei height);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* __gl2_h_ */\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/GLES2/gl2ext.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n#ifndef __gl2ext_h_\n#define __gl2ext_h_\n\n/* $Revision: 15049 $ on $Date:: 2011-07-07 01:28:16 +0100 #$ */\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* We want this */\n#ifndef GL_GLEXT_PROTOTYPES\n#define GL_GLEXT_PROTOTYPES\n#endif\n\n/*\n * This document is licensed under the SGI Free Software B License Version\n * 2.0. For details, see http://oss.sgi.com/projects/FreeB/ .\n */\n\n#ifndef GL_APIENTRYP\n#   define GL_APIENTRYP GL_APIENTRY*\n#endif\n\n/*------------------------------------------------------------------------*\n * OES extension tokens\n *------------------------------------------------------------------------*/\n\n/* GL_OES_compressed_ETC1_RGB8_texture */\n#ifndef GL_OES_compressed_ETC1_RGB8_texture\n#define GL_ETC1_RGB8_OES                                        0x8D64\n#endif\n\n/* GL_OES_compressed_paletted_texture */\n#ifndef GL_OES_compressed_paletted_texture\n#define GL_PALETTE4_RGB8_OES                                    0x8B90\n#define GL_PALETTE4_RGBA8_OES                                   0x8B91\n#define GL_PALETTE4_R5_G6_B5_OES                                0x8B92\n#define GL_PALETTE4_RGBA4_OES                                   0x8B93\n#define GL_PALETTE4_RGB5_A1_OES                                 0x8B94\n#define GL_PALETTE8_RGB8_OES                                    0x8B95\n#define GL_PALETTE8_RGBA8_OES                                   0x8B96\n#define GL_PALETTE8_R5_G6_B5_OES                                0x8B97\n#define GL_PALETTE8_RGBA4_OES                                   0x8B98\n#define GL_PALETTE8_RGB5_A1_OES                                 0x8B99\n#endif\n\n/* GL_OES_depth24 */\n#ifndef GL_OES_depth24\n#define GL_DEPTH_COMPONENT24_OES                                0x81A6\n#endif\n\n/* GL_OES_depth32 */\n#ifndef GL_OES_depth32\n#define GL_DEPTH_COMPONENT32_OES                                0x81A7\n#endif\n\n/* GL_OES_depth_texture */\n/* No new tokens introduced by this extension. */\n\n/* GL_OES_EGL_image */\n#ifndef GL_OES_EGL_image\ntypedef void* GLeglImageOES;\n#endif\n\n/* GL_OES_EGL_image_external */\n#ifndef GL_OES_EGL_image_external\n/* GLeglImageOES defined in GL_OES_EGL_image already. */\n#define GL_TEXTURE_EXTERNAL_OES                                 0x8D65\n#define GL_SAMPLER_EXTERNAL_OES                                 0x8D66\n#define GL_TEXTURE_BINDING_EXTERNAL_OES                         0x8D67\n#define GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES                     0x8D68\n#endif\n\n/* GL_OES_element_index_uint */\n#ifndef GL_OES_element_index_uint\n#define GL_UNSIGNED_INT                                         0x1405\n#endif\n\n/* GL_OES_get_program_binary */\n#ifndef GL_OES_get_program_binary\n#define GL_PROGRAM_BINARY_LENGTH_OES                            0x8741\n#define GL_NUM_PROGRAM_BINARY_FORMATS_OES                       0x87FE\n#define GL_PROGRAM_BINARY_FORMATS_OES                           0x87FF\n#endif\n\n/* GL_OES_mapbuffer */\n#ifndef GL_OES_mapbuffer\n#define GL_WRITE_ONLY_OES                                       0x88B9\n#define GL_BUFFER_ACCESS_OES                                    0x88BB\n#define GL_BUFFER_MAPPED_OES                                    0x88BC\n#define GL_BUFFER_MAP_POINTER_OES                               0x88BD\n#endif\n\n/* GL_OES_packed_depth_stencil */\n#ifndef GL_OES_packed_depth_stencil\n#define GL_DEPTH_STENCIL_OES                                    0x84F9\n#define GL_UNSIGNED_INT_24_8_OES                                0x84FA\n#define GL_DEPTH24_STENCIL8_OES                                 0x88F0\n#endif\n\n/* GL_OES_rgb8_rgba8 */\n#ifndef GL_OES_rgb8_rgba8\n#define GL_RGB8_OES                                             0x8051\n#define GL_RGBA8_OES                                            0x8058\n#endif\n\n/* GL_OES_standard_derivatives */\n#ifndef GL_OES_standard_derivatives\n#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES                  0x8B8B\n#endif\n\n/* GL_OES_stencil1 */\n#ifndef GL_OES_stencil1\n#define GL_STENCIL_INDEX1_OES                                   0x8D46\n#endif\n\n/* GL_OES_stencil4 */\n#ifndef GL_OES_stencil4\n#define GL_STENCIL_INDEX4_OES                                   0x8D47\n#endif\n\n/* GL_OES_texture_3D */\n#ifndef GL_OES_texture_3D\n#define GL_TEXTURE_WRAP_R_OES                                   0x8072\n#define GL_TEXTURE_3D_OES                                       0x806F\n#define GL_TEXTURE_BINDING_3D_OES                               0x806A\n#define GL_MAX_3D_TEXTURE_SIZE_OES                              0x8073\n#define GL_SAMPLER_3D_OES                                       0x8B5F\n#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_OES        0x8CD4\n#endif\n\n/* GL_OES_texture_float */\n/* No new tokens introduced by this extension. */\n\n/* GL_OES_texture_float_linear */\n/* No new tokens introduced by this extension. */\n\n/* GL_OES_texture_half_float */\n#ifndef GL_OES_texture_half_float\n#define GL_HALF_FLOAT_OES                                       0x8D61\n#endif\n\n/* GL_OES_texture_half_float_linear */\n/* No new tokens introduced by this extension. */\n\n/* GL_OES_texture_npot */\n/* No new tokens introduced by this extension. */\n\n/* GL_OES_vertex_array_object */\n#ifndef GL_OES_vertex_array_object\n#define GL_VERTEX_ARRAY_BINDING_OES                             0x85B5\n#endif\n\n/* GL_OES_vertex_half_float */\n/* GL_HALF_FLOAT_OES defined in GL_OES_texture_half_float already. */\n\n/* GL_OES_vertex_type_10_10_10_2 */\n#ifndef GL_OES_vertex_type_10_10_10_2\n#define GL_UNSIGNED_INT_10_10_10_2_OES                          0x8DF6\n#define GL_INT_10_10_10_2_OES                                   0x8DF7\n#endif\n\n/*------------------------------------------------------------------------*\n * AMD extension tokens\n *------------------------------------------------------------------------*/\n\n/* GL_AMD_compressed_3DC_texture */\n#ifndef GL_AMD_compressed_3DC_texture\n#define GL_3DC_X_AMD                                            0x87F9\n#define GL_3DC_XY_AMD                                           0x87FA\n#endif\n\n/* GL_AMD_compressed_ATC_texture */\n#ifndef GL_AMD_compressed_ATC_texture\n#define GL_ATC_RGB_AMD                                          0x8C92\n#define GL_ATC_RGBA_EXPLICIT_ALPHA_AMD                          0x8C93\n#define GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD                      0x87EE\n#endif\n\n/* GL_AMD_performance_monitor */\n#ifndef GL_AMD_performance_monitor\n#define GL_COUNTER_TYPE_AMD                                     0x8BC0\n#define GL_COUNTER_RANGE_AMD                                    0x8BC1\n#define GL_UNSIGNED_INT64_AMD                                   0x8BC2\n#define GL_PERCENTAGE_AMD                                       0x8BC3\n#define GL_PERFMON_RESULT_AVAILABLE_AMD                         0x8BC4\n#define GL_PERFMON_RESULT_SIZE_AMD                              0x8BC5\n#define GL_PERFMON_RESULT_AMD                                   0x8BC6\n#endif\n\n/* GL_AMD_program_binary_Z400 */\n#ifndef GL_AMD_program_binary_Z400\n#define GL_Z400_BINARY_AMD                                      0x8740\n#endif\n\n/*------------------------------------------------------------------------*\n * ANGLE extension tokens\n *------------------------------------------------------------------------*/\n\n/* GL_ANGLE_framebuffer_blit */\n#ifndef GL_ANGLE_framebuffer_blit\n#define GL_READ_FRAMEBUFFER_ANGLE                               0x8CA8\n#define GL_DRAW_FRAMEBUFFER_ANGLE                               0x8CA9\n#define GL_DRAW_FRAMEBUFFER_BINDING_ANGLE                       0x8CA6\n#define GL_READ_FRAMEBUFFER_BINDING_ANGLE                       0x8CAA\n#endif\n\n/* GL_ANGLE_framebuffer_multisample */\n#ifndef GL_ANGLE_framebuffer_multisample\n#define GL_RENDERBUFFER_SAMPLES_ANGLE                           0x8CAB\n#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_ANGLE             0x8D56\n#define GL_MAX_SAMPLES_ANGLE                                    0x8D57\n#endif\n\n/*------------------------------------------------------------------------*\n * APPLE extension tokens\n *------------------------------------------------------------------------*/\n\n/* GL_APPLE_rgb_422 */\n#ifndef GL_APPLE_rgb_422\n#define GL_RGB_422_APPLE                                        0x8A1F\n#define GL_UNSIGNED_SHORT_8_8_APPLE                             0x85BA\n#define GL_UNSIGNED_SHORT_8_8_REV_APPLE                         0x85BB\n#endif\n\n/* GL_APPLE_framebuffer_multisample */\n#ifndef GL_APPLE_framebuffer_multisample\n#define GL_RENDERBUFFER_SAMPLES_APPLE                           0x8CAB\n#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_APPLE             0x8D56\n#define GL_MAX_SAMPLES_APPLE                                    0x8D57\n#define GL_READ_FRAMEBUFFER_APPLE                               0x8CA8\n#define GL_DRAW_FRAMEBUFFER_APPLE                               0x8CA9\n#define GL_DRAW_FRAMEBUFFER_BINDING_APPLE                       0x8CA6\n#define GL_READ_FRAMEBUFFER_BINDING_APPLE                       0x8CAA\n#endif\n\n/* GL_APPLE_texture_format_BGRA8888 */\n#ifndef GL_APPLE_texture_format_BGRA8888\n#define GL_BGRA_EXT                                             0x80E1\n#endif\n\n/* GL_APPLE_texture_max_level */\n#ifndef GL_APPLE_texture_max_level\n#define GL_TEXTURE_MAX_LEVEL_APPLE                              0x813D\n#endif\n\n/*------------------------------------------------------------------------*\n * ARM extension tokens\n *------------------------------------------------------------------------*/\n\n/* GL_ARM_mali_shader_binary */\n#ifndef GL_ARM_mali_shader_binary\n#define GL_MALI_SHADER_BINARY_ARM                               0x8F60\n#endif\n\n/* GL_ARM_rgba8 */\n/* No new tokens introduced by this extension. */\n\n/*------------------------------------------------------------------------*\n * EXT extension tokens\n *------------------------------------------------------------------------*/\n\n/* GL_EXT_blend_minmax */\n#ifndef GL_EXT_blend_minmax\n#define GL_MIN_EXT                                              0x8007\n#define GL_MAX_EXT                                              0x8008\n#endif\n\n/* GL_EXT_discard_framebuffer */\n#ifndef GL_EXT_discard_framebuffer\n#define GL_COLOR_EXT                                            0x1800\n#define GL_DEPTH_EXT                                            0x1801\n#define GL_STENCIL_EXT                                          0x1802\n#endif\n\n/* GL_EXT_multi_draw_arrays */\n/* No new tokens introduced by this extension. */\n\n/* GL_EXT_read_format_bgra */\n#ifndef GL_EXT_read_format_bgra\n#define GL_BGRA_EXT                                             0x80E1\n#define GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT                       0x8365\n#define GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT                       0x8366\n#endif\n\n/* GL_EXT_shader_texture_lod */\n/* No new tokens introduced by this extension. */\n\n/* GL_EXT_texture_filter_anisotropic */\n#ifndef GL_EXT_texture_filter_anisotropic\n#define GL_TEXTURE_MAX_ANISOTROPY_EXT                           0x84FE\n#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT                       0x84FF\n#endif\n\n/* GL_EXT_texture_format_BGRA8888 */\n#ifndef GL_EXT_texture_format_BGRA8888\n#define GL_BGRA_EXT                                             0x80E1\n#endif\n\n#ifndef GL_texture_format_RGBX8888_BRCM\n#define GL_RGBX_BRCM                                            0x80EE\n#endif\n\n/* GL_EXT_texture_type_2_10_10_10_REV */\n#ifndef GL_EXT_texture_type_2_10_10_10_REV\n#define GL_UNSIGNED_INT_2_10_10_10_REV_EXT                      0x8368\n#endif\n\n/* GL_EXT_texture_compression_dxt1 */\n#ifndef GL_EXT_texture_compression_dxt1\n#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT                         0x83F0\n#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT                        0x83F1\n#endif\n\n/* GL_EXT_unpack_subimage */\n#ifndef GL_EXT_unpack_subimage\n#define GL_UNPACK_ROW_LENGTH                                    0x0CF2\n#define GL_UNPACK_SKIP_ROWS                                     0x0CF3\n#define GL_UNPACK_SKIP_PIXELS                                   0x0CF4\n#endif\n\n/*------------------------------------------------------------------------*\n * DMP extension tokens\n *------------------------------------------------------------------------*/\n\n/* GL_DMP_shader_binary */\n#ifndef GL_DMP_shader_binary\n#define GL_SHADER_BINARY_DMP                                    0x9250\n#endif\n\n/*------------------------------------------------------------------------*\n * IMG extension tokens\n *------------------------------------------------------------------------*/\n\n/* GL_IMG_program_binary */\n#ifndef GL_IMG_program_binary\n#define GL_SGX_PROGRAM_BINARY_IMG                               0x9130\n#endif\n\n/* GL_IMG_read_format */\n#ifndef GL_IMG_read_format\n#define GL_BGRA_IMG                                             0x80E1\n#define GL_UNSIGNED_SHORT_4_4_4_4_REV_IMG                       0x8365\n#endif\n\n/* GL_IMG_shader_binary */\n#ifndef GL_IMG_shader_binary\n#define GL_SGX_BINARY_IMG                                       0x8C0A\n#endif\n\n/* GL_IMG_texture_compression_pvrtc */\n#ifndef GL_IMG_texture_compression_pvrtc\n#define GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG                      0x8C00\n#define GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG                      0x8C01\n#define GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG                     0x8C02\n#define GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG                     0x8C03\n#endif\n\n/* GL_IMG_multisampled_render_to_texture */\n#ifndef GL_IMG_multisampled_render_to_texture\n#define GL_RENDERBUFFER_SAMPLES_IMG                             0x9133\n#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_IMG               0x9134\n#define GL_MAX_SAMPLES_IMG                                      0x9135\n#define GL_TEXTURE_SAMPLES_IMG                                  0x9136\n#endif\n\n/*------------------------------------------------------------------------*\n * NV extension tokens\n *------------------------------------------------------------------------*/\n\n/* GL_NV_coverage_sample */\n#ifndef GL_NV_coverage_sample\n#define GL_COVERAGE_COMPONENT_NV                                0x8ED0\n#define GL_COVERAGE_COMPONENT4_NV                               0x8ED1\n#define GL_COVERAGE_ATTACHMENT_NV                               0x8ED2\n#define GL_COVERAGE_BUFFERS_NV                                  0x8ED3\n#define GL_COVERAGE_SAMPLES_NV                                  0x8ED4\n#define GL_COVERAGE_ALL_FRAGMENTS_NV                            0x8ED5\n#define GL_COVERAGE_EDGE_FRAGMENTS_NV                           0x8ED6\n#define GL_COVERAGE_AUTOMATIC_NV                                0x8ED7\n#define GL_COVERAGE_BUFFER_BIT_NV                               0x8000\n#endif\n\n/* GL_NV_depth_nonlinear */\n#ifndef GL_NV_depth_nonlinear\n#define GL_DEPTH_COMPONENT16_NONLINEAR_NV                       0x8E2C\n#endif\n\n/* GL_NV_draw_buffers */\n#ifndef GL_NV_draw_buffers\n#define GL_MAX_DRAW_BUFFERS_NV                                  0x8824\n#define GL_DRAW_BUFFER0_NV                                      0x8825\n#define GL_DRAW_BUFFER1_NV                                      0x8826\n#define GL_DRAW_BUFFER2_NV                                      0x8827\n#define GL_DRAW_BUFFER3_NV                                      0x8828\n#define GL_DRAW_BUFFER4_NV                                      0x8829\n#define GL_DRAW_BUFFER5_NV                                      0x882A\n#define GL_DRAW_BUFFER6_NV                                      0x882B\n#define GL_DRAW_BUFFER7_NV                                      0x882C\n#define GL_DRAW_BUFFER8_NV                                      0x882D\n#define GL_DRAW_BUFFER9_NV                                      0x882E\n#define GL_DRAW_BUFFER10_NV                                     0x882F\n#define GL_DRAW_BUFFER11_NV                                     0x8830\n#define GL_DRAW_BUFFER12_NV                                     0x8831\n#define GL_DRAW_BUFFER13_NV                                     0x8832\n#define GL_DRAW_BUFFER14_NV                                     0x8833\n#define GL_DRAW_BUFFER15_NV                                     0x8834\n#define GL_COLOR_ATTACHMENT0_NV                                 0x8CE0\n#define GL_COLOR_ATTACHMENT1_NV                                 0x8CE1\n#define GL_COLOR_ATTACHMENT2_NV                                 0x8CE2\n#define GL_COLOR_ATTACHMENT3_NV                                 0x8CE3\n#define GL_COLOR_ATTACHMENT4_NV                                 0x8CE4\n#define GL_COLOR_ATTACHMENT5_NV                                 0x8CE5\n#define GL_COLOR_ATTACHMENT6_NV                                 0x8CE6\n#define GL_COLOR_ATTACHMENT7_NV                                 0x8CE7\n#define GL_COLOR_ATTACHMENT8_NV                                 0x8CE8\n#define GL_COLOR_ATTACHMENT9_NV                                 0x8CE9\n#define GL_COLOR_ATTACHMENT10_NV                                0x8CEA\n#define GL_COLOR_ATTACHMENT11_NV                                0x8CEB\n#define GL_COLOR_ATTACHMENT12_NV                                0x8CEC\n#define GL_COLOR_ATTACHMENT13_NV                                0x8CED\n#define GL_COLOR_ATTACHMENT14_NV                                0x8CEE\n#define GL_COLOR_ATTACHMENT15_NV                                0x8CEF\n#endif\n\n/* GL_NV_fbo_color_attachments */\n#ifndef GL_NV_fbo_color_attachments\n#define GL_MAX_COLOR_ATTACHMENTS_NV                             0x8CDF\n/* GL_COLOR_ATTACHMENT{0-15}_NV defined in GL_NV_draw_buffers already. */\n#endif\n\n/* GL_NV_fence */\n#ifndef GL_NV_fence\n#define GL_ALL_COMPLETED_NV                                     0x84F2\n#define GL_FENCE_STATUS_NV                                      0x84F3\n#define GL_FENCE_CONDITION_NV                                   0x84F4\n#endif\n\n/* GL_NV_read_buffer */\n#ifndef GL_NV_read_buffer\n#define GL_READ_BUFFER_NV                                       0x0C02\n#endif\n\n/* GL_NV_read_buffer_front */\n/* No new tokens introduced by this extension. */\n\n/* GL_NV_read_depth */\n/* No new tokens introduced by this extension. */\n\n/* GL_NV_read_depth_stencil */\n/* No new tokens introduced by this extension. */\n\n/* GL_NV_read_stencil */\n/* No new tokens introduced by this extension. */\n\n/* GL_NV_texture_compression_s3tc_update */\n/* No new tokens introduced by this extension. */\n\n/* GL_NV_texture_npot_2D_mipmap */\n/* No new tokens introduced by this extension. */\n\n/*------------------------------------------------------------------------*\n * QCOM extension tokens\n *------------------------------------------------------------------------*/\n\n/* GL_QCOM_alpha_test */\n#ifndef GL_QCOM_alpha_test\n#define GL_ALPHA_TEST_QCOM                                      0x0BC0\n#define GL_ALPHA_TEST_FUNC_QCOM                                 0x0BC1\n#define GL_ALPHA_TEST_REF_QCOM                                  0x0BC2\n#endif\n\n/* GL_QCOM_driver_control */\n/* No new tokens introduced by this extension. */\n\n/* GL_QCOM_extended_get */\n#ifndef GL_QCOM_extended_get\n#define GL_TEXTURE_WIDTH_QCOM                                   0x8BD2\n#define GL_TEXTURE_HEIGHT_QCOM                                  0x8BD3\n#define GL_TEXTURE_DEPTH_QCOM                                   0x8BD4\n#define GL_TEXTURE_INTERNAL_FORMAT_QCOM                         0x8BD5\n#define GL_TEXTURE_FORMAT_QCOM                                  0x8BD6\n#define GL_TEXTURE_TYPE_QCOM                                    0x8BD7\n#define GL_TEXTURE_IMAGE_VALID_QCOM                             0x8BD8\n#define GL_TEXTURE_NUM_LEVELS_QCOM                              0x8BD9\n#define GL_TEXTURE_TARGET_QCOM                                  0x8BDA\n#define GL_TEXTURE_OBJECT_VALID_QCOM                            0x8BDB\n#define GL_STATE_RESTORE                                        0x8BDC\n#endif\n\n/* GL_QCOM_extended_get2 */\n/* No new tokens introduced by this extension. */\n\n/* GL_QCOM_perfmon_global_mode */\n#ifndef GL_QCOM_perfmon_global_mode\n#define GL_PERFMON_GLOBAL_MODE_QCOM                             0x8FA0\n#endif\n\n/* GL_QCOM_writeonly_rendering */\n#ifndef GL_QCOM_writeonly_rendering\n#define GL_WRITEONLY_RENDERING_QCOM                             0x8823\n#endif\n\n/* GL_QCOM_tiled_rendering */\n#ifndef GL_QCOM_tiled_rendering\n#define GL_COLOR_BUFFER_BIT0_QCOM                               0x00000001\n#define GL_COLOR_BUFFER_BIT1_QCOM                               0x00000002\n#define GL_COLOR_BUFFER_BIT2_QCOM                               0x00000004\n#define GL_COLOR_BUFFER_BIT3_QCOM                               0x00000008\n#define GL_COLOR_BUFFER_BIT4_QCOM                               0x00000010\n#define GL_COLOR_BUFFER_BIT5_QCOM                               0x00000020\n#define GL_COLOR_BUFFER_BIT6_QCOM                               0x00000040\n#define GL_COLOR_BUFFER_BIT7_QCOM                               0x00000080\n#define GL_DEPTH_BUFFER_BIT0_QCOM                               0x00000100\n#define GL_DEPTH_BUFFER_BIT1_QCOM                               0x00000200\n#define GL_DEPTH_BUFFER_BIT2_QCOM                               0x00000400\n#define GL_DEPTH_BUFFER_BIT3_QCOM                               0x00000800\n#define GL_DEPTH_BUFFER_BIT4_QCOM                               0x00001000\n#define GL_DEPTH_BUFFER_BIT5_QCOM                               0x00002000\n#define GL_DEPTH_BUFFER_BIT6_QCOM                               0x00004000\n#define GL_DEPTH_BUFFER_BIT7_QCOM                               0x00008000\n#define GL_STENCIL_BUFFER_BIT0_QCOM                             0x00010000\n#define GL_STENCIL_BUFFER_BIT1_QCOM                             0x00020000\n#define GL_STENCIL_BUFFER_BIT2_QCOM                             0x00040000\n#define GL_STENCIL_BUFFER_BIT3_QCOM                             0x00080000\n#define GL_STENCIL_BUFFER_BIT4_QCOM                             0x00100000\n#define GL_STENCIL_BUFFER_BIT5_QCOM                             0x00200000\n#define GL_STENCIL_BUFFER_BIT6_QCOM                             0x00400000\n#define GL_STENCIL_BUFFER_BIT7_QCOM                             0x00800000\n#define GL_MULTISAMPLE_BUFFER_BIT0_QCOM                         0x01000000\n#define GL_MULTISAMPLE_BUFFER_BIT1_QCOM                         0x02000000\n#define GL_MULTISAMPLE_BUFFER_BIT2_QCOM                         0x04000000\n#define GL_MULTISAMPLE_BUFFER_BIT3_QCOM                         0x08000000\n#define GL_MULTISAMPLE_BUFFER_BIT4_QCOM                         0x10000000\n#define GL_MULTISAMPLE_BUFFER_BIT5_QCOM                         0x20000000\n#define GL_MULTISAMPLE_BUFFER_BIT6_QCOM                         0x40000000\n#define GL_MULTISAMPLE_BUFFER_BIT7_QCOM                         0x80000000\n#endif\n\n/*------------------------------------------------------------------------*\n * VIV extension tokens\n *------------------------------------------------------------------------*/\n\n/* GL_VIV_shader_binary */\n#ifndef GL_VIV_shader_binary\n#define GL_SHADER_BINARY_VIV                                    0x8FC4\n#endif\n\n/*------------------------------------------------------------------------*\n * BRCM extension tokens\n * TODO: these aren't official yet\n *------------------------------------------------------------------------*/\n#ifndef GL_BRCM_side_by_side_stero_hint\n#define GL_SIDE_BY_SIDE_STEREO_HINT_BRCM                        0x8193         /* GET AN OFFICIAL ENUM */\n#endif\n\n/*------------------------------------------------------------------------*\n * End of extension tokens, start of corresponding extension functions\n *------------------------------------------------------------------------*/\n\n/*------------------------------------------------------------------------*\n * OES extension functions\n *------------------------------------------------------------------------*/\n\n/* GL_OES_compressed_ETC1_RGB8_texture */\n#ifndef GL_OES_compressed_ETC1_RGB8_texture\n#define GL_OES_compressed_ETC1_RGB8_texture 1\n#endif\n\n/* GL_OES_compressed_paletted_texture */\n#ifndef GL_OES_compressed_paletted_texture\n#define GL_OES_compressed_paletted_texture 1\n#endif\n\n/* GL_OES_depth24 */\n#ifndef GL_OES_depth24\n#define GL_OES_depth24 1\n#endif\n\n/* GL_OES_depth32 */\n#ifndef GL_OES_depth32\n#define GL_OES_depth32 0\n#endif\n\n/* GL_OES_depth_texture */\n#ifndef GL_OES_depth_texture\n#define GL_OES_depth_texture 0\n#endif\n\n/* GL_OES_EGL_image */\n#ifndef GL_OES_EGL_image\n#define GL_OES_EGL_image 1\n#ifdef GL_GLEXT_PROTOTYPES\nGL_APICALL void GL_APIENTRY glEGLImageTargetTexture2DOES (GLenum target, GLeglImageOES image);\nGL_APICALL void GL_APIENTRY glEGLImageTargetRenderbufferStorageOES (GLenum target, GLeglImageOES image);\n#endif\ntypedef void (GL_APIENTRYP PFNGLEGLIMAGETARGETTEXTURE2DOESPROC) (GLenum target, GLeglImageOES image);\ntypedef void (GL_APIENTRYP PFNGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC) (GLenum target, GLeglImageOES image);\n#endif\n\n/* GL_OES_EGL_image_external */\n#ifndef GL_OES_EGL_image_external\n#define GL_OES_EGL_image_external 1\n/* glEGLImageTargetTexture2DOES defined in GL_OES_EGL_image already. */\n#endif\n\n/* GL_OES_element_index_uint */\n#ifndef GL_OES_element_index_uint\n#define GL_OES_element_index_uint 0\n#endif\n\n/* GL_OES_fbo_render_mipmap */\n#ifndef GL_OES_fbo_render_mipmap\n#define GL_OES_fbo_render_mipmap 0\n#endif\n\n/* GL_OES_fragment_precision_high */\n#ifndef GL_OES_fragment_precision_high\n#define GL_OES_fragment_precision_high 0\n#endif\n\n/* GL_OES_get_program_binary */\n#ifndef GL_OES_get_program_binary\n#define GL_OES_get_program_binary 0\n#ifdef GL_GLEXT_PROTOTYPES\nGL_APICALL void GL_APIENTRY glGetProgramBinaryOES (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary);\nGL_APICALL void GL_APIENTRY glProgramBinaryOES (GLuint program, GLenum binaryFormat, const GLvoid *binary, GLint length);\n#endif\ntypedef void (GL_APIENTRYP PFNGLGETPROGRAMBINARYOESPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary);\ntypedef void (GL_APIENTRYP PFNGLPROGRAMBINARYOESPROC) (GLuint program, GLenum binaryFormat, const GLvoid *binary, GLint length);\n#endif\n\n/* GL_OES_mapbuffer */\n#ifndef GL_OES_mapbuffer\n#define GL_OES_mapbuffer 0\n#ifdef GL_GLEXT_PROTOTYPES\nGL_APICALL void* GL_APIENTRY glMapBufferOES (GLenum target, GLenum access);\nGL_APICALL GLboolean GL_APIENTRY glUnmapBufferOES (GLenum target);\nGL_APICALL void GL_APIENTRY glGetBufferPointervOES (GLenum target, GLenum pname, GLvoid** params);\n#endif\ntypedef void* (GL_APIENTRYP PFNGLMAPBUFFEROESPROC) (GLenum target, GLenum access);\ntypedef GLboolean (GL_APIENTRYP PFNGLUNMAPBUFFEROESPROC) (GLenum target);\ntypedef void (GL_APIENTRYP PFNGLGETBUFFERPOINTERVOESPROC) (GLenum target, GLenum pname, GLvoid** params);\n#endif\n\n/* GL_OES_packed_depth_stencil */\n#ifndef GL_OES_packed_depth_stencil\n#define GL_OES_packed_depth_stencil 0\n#endif\n\n/* GL_OES_rgb8_rgba8 */\n#ifndef GL_OES_rgb8_rgba8\n#define GL_OES_rgb8_rgba8 0\n#endif\n\n/* GL_OES_standard_derivatives */\n#ifndef GL_OES_standard_derivatives\n#define GL_OES_standard_derivatives 0\n#endif\n\n/* GL_OES_stencil1 */\n#ifndef GL_OES_stencil1\n#define GL_OES_stencil1 0\n#endif\n\n/* GL_OES_stencil4 */\n#ifndef GL_OES_stencil4\n#define GL_OES_stencil4 0\n#endif\n\n/* GL_OES_texture_3D */\n#ifndef GL_OES_texture_3D\n#define GL_OES_texture_3D 0\n#ifdef GL_GLEXT_PROTOTYPES\nGL_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);\nGL_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);\nGL_APICALL void GL_APIENTRY glCopyTexSubImage3DOES (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);\nGL_APICALL void GL_APIENTRY glCompressedTexImage3DOES (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data);\nGL_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);\nGL_APICALL void GL_APIENTRY glFramebufferTexture3DOES (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset);\n#endif\ntypedef 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);\ntypedef 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);\ntypedef void (GL_APIENTRYP PFNGLCOPYTEXSUBIMAGE3DOESPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);\ntypedef void (GL_APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DOESPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data);\ntypedef 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);\ntypedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DOES) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset);\n#endif\n\n/* GL_OES_texture_float */\n#ifndef GL_OES_texture_float\n#define GL_OES_texture_float 0\n#endif\n\n/* GL_OES_texture_float_linear */\n#ifndef GL_OES_texture_float_linear\n#define GL_OES_texture_float_linear 0\n#endif\n\n/* GL_OES_texture_half_float */\n#ifndef GL_OES_texture_half_float\n#define GL_OES_texture_half_float 0\n#endif\n\n/* GL_OES_texture_half_float_linear */\n#ifndef GL_OES_texture_half_float_linear\n#define GL_OES_texture_half_float_linear 0\n#endif\n\n/* GL_OES_texture_npot */\n#ifndef GL_OES_texture_npot\n#define GL_OES_texture_npot 1\n#endif\n\n/* GL_OES_vertex_array_object */\n#ifndef GL_OES_vertex_array_object\n#define GL_OES_vertex_array_object 0\n#ifdef GL_GLEXT_PROTOTYPES\nGL_APICALL void GL_APIENTRY glBindVertexArrayOES (GLuint array);\nGL_APICALL void GL_APIENTRY glDeleteVertexArraysOES (GLsizei n, const GLuint *arrays);\nGL_APICALL void GL_APIENTRY glGenVertexArraysOES (GLsizei n, GLuint *arrays);\nGL_APICALL GLboolean GL_APIENTRY glIsVertexArrayOES (GLuint array);\n#endif\ntypedef void (GL_APIENTRYP PFNGLBINDVERTEXARRAYOESPROC) (GLuint array);\ntypedef void (GL_APIENTRYP PFNGLDELETEVERTEXARRAYSOESPROC) (GLsizei n, const GLuint *arrays);\ntypedef void (GL_APIENTRYP PFNGLGENVERTEXARRAYSOESPROC) (GLsizei n, GLuint *arrays);\ntypedef GLboolean (GL_APIENTRYP PFNGLISVERTEXARRAYOESPROC) (GLuint array);\n#endif\n\n/* GL_OES_vertex_half_float */\n#ifndef GL_OES_vertex_half_float\n#define GL_OES_vertex_half_float 1\n#endif\n\n/* GL_OES_vertex_type_10_10_10_2 */\n#ifndef GL_OES_vertex_type_10_10_10_2\n#define GL_OES_vertex_type_10_10_10_2 0\n#endif\n\n/*------------------------------------------------------------------------*\n * AMD extension functions\n *------------------------------------------------------------------------*/\n\n/* GL_AMD_compressed_3DC_texture */\n#ifndef GL_AMD_compressed_3DC_texture\n#define GL_AMD_compressed_3DC_texture 0\n#endif\n\n/* GL_AMD_compressed_ATC_texture */\n#ifndef GL_AMD_compressed_ATC_texture\n#define GL_AMD_compressed_ATC_texture 0\n#endif\n\n/* AMD_performance_monitor */\n#ifndef GL_AMD_performance_monitor\n#define GL_AMD_performance_monitor 0\n#ifdef GL_GLEXT_PROTOTYPES\nGL_APICALL void GL_APIENTRY glGetPerfMonitorGroupsAMD (GLint *numGroups, GLsizei groupsSize, GLuint *groups);\nGL_APICALL void GL_APIENTRY glGetPerfMonitorCountersAMD (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters);\nGL_APICALL void GL_APIENTRY glGetPerfMonitorGroupStringAMD (GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString);\nGL_APICALL void GL_APIENTRY glGetPerfMonitorCounterStringAMD (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString);\nGL_APICALL void GL_APIENTRY glGetPerfMonitorCounterInfoAMD (GLuint group, GLuint counter, GLenum pname, GLvoid *data);\nGL_APICALL void GL_APIENTRY glGenPerfMonitorsAMD (GLsizei n, GLuint *monitors);\nGL_APICALL void GL_APIENTRY glDeletePerfMonitorsAMD (GLsizei n, GLuint *monitors);\nGL_APICALL void GL_APIENTRY glSelectPerfMonitorCountersAMD (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *countersList);\nGL_APICALL void GL_APIENTRY glBeginPerfMonitorAMD (GLuint monitor);\nGL_APICALL void GL_APIENTRY glEndPerfMonitorAMD (GLuint monitor);\nGL_APICALL void GL_APIENTRY glGetPerfMonitorCounterDataAMD (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten);\n#endif\ntypedef void (GL_APIENTRYP PFNGLGETPERFMONITORGROUPSAMDPROC) (GLint *numGroups, GLsizei groupsSize, GLuint *groups);\ntypedef void (GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERSAMDPROC) (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters);\ntypedef void (GL_APIENTRYP PFNGLGETPERFMONITORGROUPSTRINGAMDPROC) (GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString);\ntypedef void (GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERSTRINGAMDPROC) (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString);\ntypedef void (GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERINFOAMDPROC) (GLuint group, GLuint counter, GLenum pname, GLvoid *data);\ntypedef void (GL_APIENTRYP PFNGLGENPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors);\ntypedef void (GL_APIENTRYP PFNGLDELETEPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors);\ntypedef void (GL_APIENTRYP PFNGLSELECTPERFMONITORCOUNTERSAMDPROC) (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *countersList);\ntypedef void (GL_APIENTRYP PFNGLBEGINPERFMONITORAMDPROC) (GLuint monitor);\ntypedef void (GL_APIENTRYP PFNGLENDPERFMONITORAMDPROC) (GLuint monitor);\ntypedef void (GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERDATAAMDPROC) (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten);\n#endif\n\n/* GL_AMD_program_binary_Z400 */\n#ifndef GL_AMD_program_binary_Z400\n#define GL_AMD_program_binary_Z400 0\n#endif\n\n/*------------------------------------------------------------------------*\n * ANGLE extension functions\n *------------------------------------------------------------------------*/\n\n/* GL_ANGLE_framebuffer_blit */\n#ifndef GL_ANGLE_framebuffer_blit\n#define GL_ANGLE_framebuffer_blit 0\n#ifdef GL_GLEXT_PROTOTYPES\nGL_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);\n#endif\ntypedef void (GL_APIENTRYP PFNGLBLITFRAMEBUFFERANGLEPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);\n#endif\n\n/* GL_ANGLE_framebuffer_multisample */\n#ifndef GL_ANGLE_framebuffer_multisample\n#define GL_ANGLE_framebuffer_multisample 0\n#ifdef GL_GLEXT_PROTOTYPES\nGL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleANGLE (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);\n#endif\ntypedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEANGLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);\n#endif\n\n/*------------------------------------------------------------------------*\n * APPLE extension functions\n *------------------------------------------------------------------------*/\n\n/* GL_APPLE_rgb_422 */\n#ifndef GL_APPLE_rgb_422\n#define GL_APPLE_rgb_422 0\n#endif\n\n/* GL_APPLE_framebuffer_multisample */\n#ifndef GL_APPLE_framebuffer_multisample\n#define GL_APPLE_framebuffer_multisample 0\n#ifdef GL_GLEXT_PROTOTYPES\nGL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleAPPLE (GLenum, GLsizei, GLenum, GLsizei, GLsizei);\nGL_APICALL void GL_APIENTRY glResolveMultisampleFramebufferAPPLE (void);\n#endif /* GL_GLEXT_PROTOTYPES */\ntypedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEAPPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);\ntypedef void (GL_APIENTRYP PFNGLRESOLVEMULTISAMPLEFRAMEBUFFERAPPLEPROC) (void);\n#endif\n\n/* GL_APPLE_texture_format_BGRA8888 */\n#ifndef GL_APPLE_texture_format_BGRA8888\n#define GL_APPLE_texture_format_BGRA8888 0\n#endif\n\n/* GL_APPLE_texture_max_level */\n#ifndef GL_APPLE_texture_max_level\n#define GL_APPLE_texture_max_level 0\n#endif\n\n/*------------------------------------------------------------------------*\n * ARM extension functions\n *------------------------------------------------------------------------*/\n\n/* GL_ARM_mali_shader_binary */\n#ifndef GL_ARM_mali_shader_binary\n#define GL_ARM_mali_shader_binary 0\n#endif\n\n/* GL_ARM_rgba8 */\n#ifndef GL_ARM_rgba8\n#define GL_ARM_rgba8 0\n#endif\n\n/*------------------------------------------------------------------------*\n * APPLE extension tokens\n *------------------------------------------------------------------------*/\n\n/* GL_APPLE_rgb_422 */\n#ifndef GL_APPLE_rgb_422\n#define GL_APPLE_rgb_422 1\n#define GL_RGB_422_APPLE                                        0x8A1F\n#define GL_UNSIGNED_SHORT_8_8_APPLE                             0x85BA\n#define GL_UNSIGNED_SHORT_8_8_REV_APPLE                         0x85BB\n#endif\n\n/*------------------------------------------------------------------------*\n * EXT extension functions\n *------------------------------------------------------------------------*/\n\n/* GL_EXT_blend_minmax */\n#ifndef GL_EXT_blend_minmax\n#define GL_EXT_blend_minmax 0\n#endif\n\n/* GL_EXT_discard_framebuffer */\n#ifndef GL_EXT_discard_framebuffer\n#define GL_EXT_discard_framebuffer 1\n#ifdef GL_GLEXT_PROTOTYPES\nGL_APICALL void GL_APIENTRY glDiscardFramebufferEXT (GLenum target, GLsizei numAttachments, const GLenum *attachments);\n#endif\ntypedef void (GL_APIENTRYP PFNGLDISCARDFRAMEBUFFEREXTPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments);\n#endif\n\n/* GL_EXT_debug_marker */\n#ifndef GL_EXT_debug_marker\n#define GL_EXT_debug_marker 1\n#ifdef GL_GLEXT_PROTOTYPES\nGL_APICALL void GL_APIENTRY glInsertEventMarkerEXT (GLsizei length, const GLchar *marker);\nGL_APICALL void GL_APIENTRY glPushGroupMarkerEXT (GLsizei length, const GLchar *marker);\nGL_APICALL void GL_APIENTRY glPopGroupMarkerEXT (void);\n#endif\ntypedef void (GL_APIENTRYP PFNGLINSERTEVENTMARKEREXTPROC) (GLsizei length, const GLchar *marker);\ntypedef void (GL_APIENTRYP PFNGLPUSHGROUPMARKEREXTPROC) (GLsizei length, const GLchar *marker);\ntypedef void (GL_APIENTRYP PFNGLPOPGROUPMARKEREXTPROC) (void);\n#endif\n\n#ifndef GL_EXT_multi_draw_arrays\n#define GL_EXT_multi_draw_arrays 0\n#ifdef GL_GLEXT_PROTOTYPES\nGL_APICALL void GL_APIENTRY glMultiDrawArraysEXT (GLenum, GLint *, GLsizei *, GLsizei);\nGL_APICALL void GL_APIENTRY glMultiDrawElementsEXT (GLenum, const GLsizei *, GLenum, const GLvoid* *, GLsizei);\n#endif /* GL_GLEXT_PROTOTYPES */\ntypedef void (GL_APIENTRYP PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, GLint *first, GLsizei *count, GLsizei primcount);\ntypedef void (GL_APIENTRYP PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount);\n#endif\n\n/* GL_EXT_read_format_bgra */\n#ifndef GL_EXT_read_format_bgra\n#define GL_EXT_read_format_bgra 0\n#endif\n\n/* GL_EXT_shader_texture_lod */\n#ifndef GL_EXT_shader_texture_lod\n#define GL_EXT_shader_texture_lod 0\n#endif\n\n/* GL_EXT_texture_filter_anisotropic */\n#ifndef GL_EXT_texture_filter_anisotropic\n#define GL_EXT_texture_filter_anisotropic 0\n#endif\n\n/* GL_EXT_texture_format_BGRA8888 */\n#ifndef GL_EXT_texture_format_BGRA8888\n#define GL_EXT_texture_format_BGRA8888 1\n#endif\n\n#ifndef GL_texture_format_RGBX8888_BRCM\n#define GL_texture_format_RGBX8888_BRCM 1\n#endif\n\n/* GL_EXT_texture_type_2_10_10_10_REV */\n#ifndef GL_EXT_texture_type_2_10_10_10_REV\n#define GL_EXT_texture_type_2_10_10_10_REV 0\n#endif\n\n/* GL_EXT_texture_compression_dxt1 */\n#ifndef GL_EXT_texture_compression_dxt1\n#define GL_EXT_texture_compression_dxt1 0\n#endif\n\n/* GL_EXT_unpack_subimage */\n#ifndef GL_EXT_unpack_subimage\n#define GL_EXT_unpack_subimage 0\n#endif\n\n/*------------------------------------------------------------------------*\n * DMP extension functions\n *------------------------------------------------------------------------*/\n\n/* GL_DMP_shader_binary */\n#ifndef GL_DMP_shader_binary\n#define GL_DMP_shader_binary 0\n#endif\n\n/*------------------------------------------------------------------------*\n * IMG extension functions\n *------------------------------------------------------------------------*/\n\n/* GL_IMG_program_binary */\n#ifndef GL_IMG_program_binary\n#define GL_IMG_program_binary 0\n#endif\n\n/* GL_IMG_read_format */\n#ifndef GL_IMG_read_format\n#define GL_IMG_read_format 0\n#endif\n\n/* GL_IMG_shader_binary */\n#ifndef GL_IMG_shader_binary\n#define GL_IMG_shader_binary 0\n#endif\n\n/* GL_IMG_texture_compression_pvrtc */\n#ifndef GL_IMG_texture_compression_pvrtc\n#define GL_IMG_texture_compression_pvrtc 0\n#endif\n\n/* GL_IMG_multisampled_render_to_texture */\n#ifndef GL_IMG_multisampled_render_to_texture\n#define GL_IMG_multisampled_render_to_texture 0\n#ifdef GL_GLEXT_PROTOTYPES\nGL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleIMG (GLenum, GLsizei, GLenum, GLsizei, GLsizei);\nGL_APICALL void GL_APIENTRY glFramebufferTexture2DMultisampleIMG (GLenum, GLenum, GLenum, GLuint, GLint, GLsizei);\n#endif\ntypedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEIMG) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);\ntypedef void (GL_APIENTRYP PFNGLCLIPPLANEXIMG) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples);\n#endif\n\n/*------------------------------------------------------------------------*\n * NV extension functions\n *------------------------------------------------------------------------*/\n\n/* GL_NV_coverage_sample */\n#ifndef GL_NV_coverage_sample\n#define GL_NV_coverage_sample 0\n#ifdef GL_GLEXT_PROTOTYPES\nGL_APICALL void GL_APIENTRY glCoverageMaskNV (GLboolean mask);\nGL_APICALL void GL_APIENTRY glCoverageOperationNV (GLenum operation);\n#endif\ntypedef void (GL_APIENTRYP PFNGLCOVERAGEMASKNVPROC) (GLboolean mask);\ntypedef void (GL_APIENTRYP PFNGLCOVERAGEOPERATIONNVPROC) (GLenum operation);\n#endif\n\n/* GL_NV_depth_nonlinear */\n#ifndef GL_NV_depth_nonlinear\n#define GL_NV_depth_nonlinear 0\n#endif\n\n/* GL_NV_draw_buffers */\n#ifndef GL_NV_draw_buffers\n#define GL_NV_draw_buffers 0\n#ifdef GL_GLEXT_PROTOTYPES\nGL_APICALL void GL_APIENTRY glDrawBuffersNV (GLsizei n, const GLenum *bufs);\n#endif\ntypedef void (GL_APIENTRYP PFNGLDRAWBUFFERSNVPROC) (GLsizei n, const GLenum *bufs);\n#endif\n\n/* GL_NV_fbo_color_attachments */\n#ifndef GL_NV_fbo_color_attachments\n#define GL_NV_fbo_color_attachments 0\n#endif\n\n/* GL_NV_fence */\n#ifndef GL_NV_fence\n#define GL_NV_fence 0\n#ifdef GL_GLEXT_PROTOTYPES\nGL_APICALL void GL_APIENTRY glDeleteFencesNV (GLsizei, const GLuint *);\nGL_APICALL void GL_APIENTRY glGenFencesNV (GLsizei, GLuint *);\nGL_APICALL GLboolean GL_APIENTRY glIsFenceNV (GLuint);\nGL_APICALL GLboolean GL_APIENTRY glTestFenceNV (GLuint);\nGL_APICALL void GL_APIENTRY glGetFenceivNV (GLuint, GLenum, GLint *);\nGL_APICALL void GL_APIENTRY glFinishFenceNV (GLuint);\nGL_APICALL void GL_APIENTRY glSetFenceNV (GLuint, GLenum);\n#endif\ntypedef void (GL_APIENTRYP PFNGLDELETEFENCESNVPROC) (GLsizei n, const GLuint *fences);\ntypedef void (GL_APIENTRYP PFNGLGENFENCESNVPROC) (GLsizei n, GLuint *fences);\ntypedef GLboolean (GL_APIENTRYP PFNGLISFENCENVPROC) (GLuint fence);\ntypedef GLboolean (GL_APIENTRYP PFNGLTESTFENCENVPROC) (GLuint fence);\ntypedef void (GL_APIENTRYP PFNGLGETFENCEIVNVPROC) (GLuint fence, GLenum pname, GLint *params);\ntypedef void (GL_APIENTRYP PFNGLFINISHFENCENVPROC) (GLuint fence);\ntypedef void (GL_APIENTRYP PFNGLSETFENCENVPROC) (GLuint fence, GLenum condition);\n#endif\n\n/* GL_NV_read_buffer */\n#ifndef GL_NV_read_buffer\n#define GL_NV_read_buffer 0\n#ifdef GL_GLEXT_PROTOTYPES\nGL_APICALL void GL_APIENTRY glReadBufferNV (GLenum mode);\n#endif\ntypedef void (GL_APIENTRYP PFNGLREADBUFFERNVPROC) (GLenum mode);\n#endif\n\n/* GL_NV_read_buffer_front */\n#ifndef GL_NV_read_buffer_front\n#define GL_NV_read_buffer_front 0\n#endif\n\n/* GL_NV_read_depth */\n#ifndef GL_NV_read_depth\n#define GL_NV_read_depth 0\n#endif\n\n/* GL_NV_read_depth_stencil */\n#ifndef GL_NV_read_depth_stencil\n#define GL_NV_read_depth_stencil 0\n#endif\n\n/* GL_NV_read_stencil */\n#ifndef GL_NV_read_stencil\n#define GL_NV_read_stencil 0\n#endif\n\n/* GL_NV_texture_compression_s3tc_update */\n#ifndef GL_NV_texture_compression_s3tc_update\n#define GL_NV_texture_compression_s3tc_update 0\n#endif\n\n/* GL_NV_texture_npot_2D_mipmap */\n#ifndef GL_NV_texture_npot_2D_mipmap\n#define GL_NV_texture_npot_2D_mipmap 0\n#endif\n\n/*------------------------------------------------------------------------*\n * QCOM extension functions\n *------------------------------------------------------------------------*/\n\n/* GL_QCOM_alpha_test */\n#ifndef GL_QCOM_alpha_test\n#define GL_QCOM_alpha_test 0\n#ifdef GL_GLEXT_PROTOTYPES\nGL_APICALL void GL_APIENTRY glAlphaFuncQCOM (GLenum func, GLclampf ref);\n#endif\ntypedef void (GL_APIENTRYP PFNGLALPHAFUNCQCOMPROC) (GLenum func, GLclampf ref);\n#endif\n\n/* GL_QCOM_driver_control */\n#ifndef GL_QCOM_driver_control\n#define GL_QCOM_driver_control 0\n#ifdef GL_GLEXT_PROTOTYPES\nGL_APICALL void GL_APIENTRY glGetDriverControlsQCOM (GLint *num, GLsizei size, GLuint *driverControls);\nGL_APICALL void GL_APIENTRY glGetDriverControlStringQCOM (GLuint driverControl, GLsizei bufSize, GLsizei *length, GLchar *driverControlString);\nGL_APICALL void GL_APIENTRY glEnableDriverControlQCOM (GLuint driverControl);\nGL_APICALL void GL_APIENTRY glDisableDriverControlQCOM (GLuint driverControl);\n#endif\ntypedef void (GL_APIENTRYP PFNGLGETDRIVERCONTROLSQCOMPROC) (GLint *num, GLsizei size, GLuint *driverControls);\ntypedef void (GL_APIENTRYP PFNGLGETDRIVERCONTROLSTRINGQCOMPROC) (GLuint driverControl, GLsizei bufSize, GLsizei *length, GLchar *driverControlString);\ntypedef void (GL_APIENTRYP PFNGLENABLEDRIVERCONTROLQCOMPROC) (GLuint driverControl);\ntypedef void (GL_APIENTRYP PFNGLDISABLEDRIVERCONTROLQCOMPROC) (GLuint driverControl);\n#endif\n\n/* GL_QCOM_extended_get */\n#ifndef GL_QCOM_extended_get\n#define GL_QCOM_extended_get 0\n#ifdef GL_GLEXT_PROTOTYPES\nGL_APICALL void GL_APIENTRY glExtGetTexturesQCOM (GLuint *textures, GLint maxTextures, GLint *numTextures);\nGL_APICALL void GL_APIENTRY glExtGetBuffersQCOM (GLuint *buffers, GLint maxBuffers, GLint *numBuffers);\nGL_APICALL void GL_APIENTRY glExtGetRenderbuffersQCOM (GLuint *renderbuffers, GLint maxRenderbuffers, GLint *numRenderbuffers);\nGL_APICALL void GL_APIENTRY glExtGetFramebuffersQCOM (GLuint *framebuffers, GLint maxFramebuffers, GLint *numFramebuffers);\nGL_APICALL void GL_APIENTRY glExtGetTexLevelParameterivQCOM (GLuint texture, GLenum face, GLint level, GLenum pname, GLint *params);\nGL_APICALL void GL_APIENTRY glExtTexObjectStateOverrideiQCOM (GLenum target, GLenum pname, GLint param);\nGL_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);\nGL_APICALL void GL_APIENTRY glExtGetBufferPointervQCOM (GLenum target, GLvoid **params);\n#endif\ntypedef void (GL_APIENTRYP PFNGLEXTGETTEXTURESQCOMPROC) (GLuint *textures, GLint maxTextures, GLint *numTextures);\ntypedef void (GL_APIENTRYP PFNGLEXTGETBUFFERSQCOMPROC) (GLuint *buffers, GLint maxBuffers, GLint *numBuffers);\ntypedef void (GL_APIENTRYP PFNGLEXTGETRENDERBUFFERSQCOMPROC) (GLuint *renderbuffers, GLint maxRenderbuffers, GLint *numRenderbuffers);\ntypedef void (GL_APIENTRYP PFNGLEXTGETFRAMEBUFFERSQCOMPROC) (GLuint *framebuffers, GLint maxFramebuffers, GLint *numFramebuffers);\ntypedef void (GL_APIENTRYP PFNGLEXTGETTEXLEVELPARAMETERIVQCOMPROC) (GLuint texture, GLenum face, GLint level, GLenum pname, GLint *params);\ntypedef void (GL_APIENTRYP PFNGLEXTTEXOBJECTSTATEOVERRIDEIQCOMPROC) (GLenum target, GLenum pname, GLint param);\ntypedef 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);\ntypedef void (GL_APIENTRYP PFNGLEXTGETBUFFERPOINTERVQCOMPROC) (GLenum target, GLvoid **params);\n#endif\n\n/* GL_QCOM_extended_get2 */\n#ifndef GL_QCOM_extended_get2\n#define GL_QCOM_extended_get2 0\n#ifdef GL_GLEXT_PROTOTYPES\nGL_APICALL void GL_APIENTRY glExtGetShadersQCOM (GLuint *shaders, GLint maxShaders, GLint *numShaders);\nGL_APICALL void GL_APIENTRY glExtGetProgramsQCOM (GLuint *programs, GLint maxPrograms, GLint *numPrograms);\nGL_APICALL GLboolean GL_APIENTRY glExtIsProgramBinaryQCOM (GLuint program);\nGL_APICALL void GL_APIENTRY glExtGetProgramBinarySourceQCOM (GLuint program, GLenum shadertype, GLchar *source, GLint *length);\n#endif\ntypedef void (GL_APIENTRYP PFNGLEXTGETSHADERSQCOMPROC) (GLuint *shaders, GLint maxShaders, GLint *numShaders);\ntypedef void (GL_APIENTRYP PFNGLEXTGETPROGRAMSQCOMPROC) (GLuint *programs, GLint maxPrograms, GLint *numPrograms);\ntypedef GLboolean (GL_APIENTRYP PFNGLEXTISPROGRAMBINARYQCOMPROC) (GLuint program);\ntypedef void (GL_APIENTRYP PFNGLEXTGETPROGRAMBINARYSOURCEQCOMPROC) (GLuint program, GLenum shadertype, GLchar *source, GLint *length);\n#endif\n\n/* GL_QCOM_perfmon_global_mode */\n#ifndef GL_QCOM_perfmon_global_mode\n#define GL_QCOM_perfmon_global_mode 0\n#endif\n\n/* GL_QCOM_writeonly_rendering */\n#ifndef GL_QCOM_writeonly_rendering\n#define GL_QCOM_writeonly_rendering 0\n#endif\n\n/* GL_QCOM_tiled_rendering */\n#ifndef GL_QCOM_tiled_rendering\n#define GL_QCOM_tiled_rendering 0\n#ifdef GL_GLEXT_PROTOTYPES\nGL_APICALL void GL_APIENTRY glStartTilingQCOM (GLuint x, GLuint y, GLuint width, GLuint height, GLbitfield preserveMask);\nGL_APICALL void GL_APIENTRY glEndTilingQCOM (GLbitfield preserveMask);\n#endif\ntypedef void (GL_APIENTRYP PFNGLSTARTTILINGQCOMPROC) (GLuint x, GLuint y, GLuint width, GLuint height, GLbitfield preserveMask);\ntypedef void (GL_APIENTRYP PFNGLENDTILINGQCOMPROC) (GLbitfield preserveMask);\n#endif\n\n/*------------------------------------------------------------------------*\n * VIV extension tokens\n *------------------------------------------------------------------------*/\n\n/* GL_VIV_shader_binary */\n#ifndef GL_VIV_shader_binary\n#define GL_VIV_shader_binary 0\n#endif\n\n/*------------------------------------------------------------------------*\n * BRCM extension functions\n * TODO: these aren't official yet\n *------------------------------------------------------------------------*/\n#ifndef GL_BRCM_side_by_side_stero_hint\n#define GL_BRCM_side_by_side_stero_hint 1\n#endif\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* __gl2ext_h_ */\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/GLES2/gl2platform.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n#ifndef __gl2platform_h_\n#define __gl2platform_h_\n\n/* $Revision: 10602 $ on $Date:: 2010-03-04 22:35:34 -0800 #$ */\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/*\n * This document is licensed under the SGI Free Software B License Version\n * 2.0. For details, see http://oss.sgi.com/projects/FreeB/ .\n */\n\n/* Platform-specific types and definitions for OpenGL ES 2.X  gl2.h\n *\n * Adopters may modify khrplatform.h and this file to suit their platform.\n * You are encouraged to submit all modifications to the Khronos group so that\n * they can be included in future versions of this file.  Please submit changes\n * by sending them to the public Khronos Bugzilla (http://khronos.org/bugzilla)\n * by filing a bug against product \"OpenGL-ES\" component \"Registry\".\n */\n\n#include \"../KHR/khrplatform.h\"\n\n#ifndef GL_APICALL\n#define GL_APICALL  KHRONOS_APICALL\n#endif\n\n#ifndef GL_APIENTRY\n#define GL_APIENTRY KHRONOS_APIENTRY\n#endif\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* __gl2platform_h_ */\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/IL/OMX_Audio.h",
    "content": "/*\n * Copyright (c) 2008 The Khronos Group Inc. \n * \n * Permission is hereby granted, free of charge, to any person obtaining\n * a copy of this software and associated documentation files (the\n * \"Software\"), to deal in the Software without restriction, including\n * without limitation the rights to use, copy, modify, merge, publish,\n * distribute, sublicense, and/or sell copies of the Software, and to\n * permit persons to whom the Software is furnished to do so, subject\n * to the following conditions: \n * The above copyright notice and this permission notice shall be included\n * in all copies or substantial portions of the Software. \n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\n * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\n * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\n * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \n *\n */\n\n/** @file OMX_Audio.h - OpenMax IL version 1.1.2\n *  The structures needed by Audio components to exchange\n *  parameters and configuration data with the componenmilts.\n */\n\n#ifndef OMX_Audio_h\n#define OMX_Audio_h\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif /* __cplusplus */\n\n\n/* Each OMX header must include all required header files to allow the\n *  header to compile without errors.  The includes below are required\n *  for this header file to compile successfully \n */\n\n#include \"OMX_Core.h\"\n\n/** @defgroup midi MIDI\n * @ingroup audio\n */\n \n/** @defgroup effects Audio effects\n * @ingroup audio\n */\n\n/** @defgroup audio OpenMAX IL Audio Domain\n * Structures for OpenMAX IL Audio domain\n * @{\n */\n\n/** Enumeration used to define the possible audio codings.  \n *  If \"OMX_AUDIO_CodingUnused\" is selected, the coding selection must \n *  be done in a vendor specific way.  Since this is for an audio \n *  processing element this enum is relevant.  However, for another \n *  type of component other enums would be in this area.\n */\ntypedef enum OMX_AUDIO_CODINGTYPE {\n    OMX_AUDIO_CodingUnused = 0,  /**< Placeholder value when coding is N/A  */\n    OMX_AUDIO_CodingAutoDetect,  /**< auto detection of audio format */\n    OMX_AUDIO_CodingPCM,         /**< Any variant of PCM coding */\n    OMX_AUDIO_CodingADPCM,       /**< Any variant of ADPCM encoded data */\n    OMX_AUDIO_CodingAMR,         /**< Any variant of AMR encoded data */\n    OMX_AUDIO_CodingGSMFR,       /**< Any variant of GSM fullrate (i.e. GSM610) */\n    OMX_AUDIO_CodingGSMEFR,      /**< Any variant of GSM Enhanced Fullrate encoded data*/\n    OMX_AUDIO_CodingGSMHR,       /**< Any variant of GSM Halfrate encoded data */\n    OMX_AUDIO_CodingPDCFR,       /**< Any variant of PDC Fullrate encoded data */\n    OMX_AUDIO_CodingPDCEFR,      /**< Any variant of PDC Enhanced Fullrate encoded data */\n    OMX_AUDIO_CodingPDCHR,       /**< Any variant of PDC Halfrate encoded data */\n    OMX_AUDIO_CodingTDMAFR,      /**< Any variant of TDMA Fullrate encoded data (TIA/EIA-136-420) */\n    OMX_AUDIO_CodingTDMAEFR,     /**< Any variant of TDMA Enhanced Fullrate encoded data (TIA/EIA-136-410) */\n    OMX_AUDIO_CodingQCELP8,      /**< Any variant of QCELP 8kbps encoded data */\n    OMX_AUDIO_CodingQCELP13,     /**< Any variant of QCELP 13kbps encoded data */\n    OMX_AUDIO_CodingEVRC,        /**< Any variant of EVRC encoded data */\n    OMX_AUDIO_CodingSMV,         /**< Any variant of SMV encoded data */\n    OMX_AUDIO_CodingG711,        /**< Any variant of G.711 encoded data */\n    OMX_AUDIO_CodingG723,        /**< Any variant of G.723 dot 1 encoded data */\n    OMX_AUDIO_CodingG726,        /**< Any variant of G.726 encoded data */\n    OMX_AUDIO_CodingG729,        /**< Any variant of G.729 encoded data */\n    OMX_AUDIO_CodingAAC,         /**< Any variant of AAC encoded data */\n    OMX_AUDIO_CodingMP3,         /**< Any variant of MP3 encoded data */\n    OMX_AUDIO_CodingSBC,         /**< Any variant of SBC encoded data */\n    OMX_AUDIO_CodingVORBIS,      /**< Any variant of VORBIS encoded data */\n    OMX_AUDIO_CodingWMA,         /**< Any variant of WMA encoded data */\n    OMX_AUDIO_CodingRA,          /**< Any variant of RA encoded data */\n    OMX_AUDIO_CodingMIDI,        /**< Any variant of MIDI encoded data */\n    OMX_AUDIO_CodingKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_AUDIO_CodingVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n\n#define OMX_AUDIO_CodingFLAC_Supported 1\n    OMX_AUDIO_CodingFLAC,        /**< Any variant of FLAC */\n#define OMX_AUDIO_CodingDDP_Supported 1\n    OMX_AUDIO_CodingDDP,         /**< Any variant of Dolby Digital Plus */\n#define OMX_AUDIO_CodingDTS_Supported 1\n    OMX_AUDIO_CodingDTS,         /**< Any variant of DTS */\n#define OMX_AUDIO_CodingWMAPRO_Supported 1\n    OMX_AUDIO_CodingWMAPRO,      /**< Any variant of WMA Professional */\n#define OMX_AUDIO_CodingATRAC3_Supported 1\n    OMX_AUDIO_CodingATRAC3,      /**< Sony ATRAC-3 variants */\n#define OMX_AUDIO_CodingATRACX_Supported 1\n    OMX_AUDIO_CodingATRACX,      /**< Sony ATRAC-X variants */\n#define OMX_AUDIO_CodingATRACAAL_Supported 1\n    OMX_AUDIO_CodingATRACAAL,    /**< Sony ATRAC advanced-lossless variants  */\n\n    OMX_AUDIO_CodingMax = 0x7FFFFFFF\n} OMX_AUDIO_CODINGTYPE;\n\n\n/** The PortDefinition structure is used to define all of the parameters \n *  necessary for the compliant component to setup an input or an output audio \n *  path.  If additional information is needed to define the parameters of the\n *  port (such as frequency), additional structures must be sent such as the\n *  OMX_AUDIO_PARAM_PCMMODETYPE structure to supply the extra parameters for the port.\n */\ntypedef struct OMX_AUDIO_PORTDEFINITIONTYPE {\n    OMX_STRING cMIMEType;            /**< MIME type of data for the port */\n    OMX_NATIVE_DEVICETYPE pNativeRender; /** < platform specific reference\n                                               for an output device, \n                                               otherwise this field is 0 */\n    OMX_BOOL bFlagErrorConcealment;  /**< Turns on error concealment if it is \n                                          supported by the OMX component */\n    OMX_AUDIO_CODINGTYPE eEncoding;  /**< Type of data expected for this \n                                          port (e.g. PCM, AMR, MP3, etc) */\n} OMX_AUDIO_PORTDEFINITIONTYPE;\n\n\n/**  Port format parameter.  This structure is used to enumerate\n  *  the various data input/output format supported by the port.\n  */\ntypedef struct OMX_AUDIO_PARAM_PORTFORMATTYPE {\n    OMX_U32 nSize;                  /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion;       /**< OMX specification version information */\n    OMX_U32 nPortIndex;             /**< Indicates which port to set */\n    OMX_U32 nIndex;                 /**< Indicates the enumeration index for the format from 0x0 to N-1 */\n    OMX_AUDIO_CODINGTYPE eEncoding; /**< Type of data expected for this port (e.g. PCM, AMR, MP3, etc) */\n} OMX_AUDIO_PARAM_PORTFORMATTYPE;\n\n\n/** PCM mode type  */ \ntypedef enum OMX_AUDIO_PCMMODETYPE { \n    OMX_AUDIO_PCMModeLinear = 0,  /**< Linear PCM encoded data */ \n    OMX_AUDIO_PCMModeALaw,        /**< A law PCM encoded data (G.711) */ \n    OMX_AUDIO_PCMModeMULaw,       /**< Mu law PCM encoded data (G.711)  */ \n    OMX_AUDIO_PCMModeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_AUDIO_PCMModeVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_AUDIO_PCMModeMax = 0x7FFFFFFF \n} OMX_AUDIO_PCMMODETYPE; \n\n\ntypedef enum OMX_AUDIO_CHANNELTYPE {\n    OMX_AUDIO_ChannelNone = 0x0,    /**< Unused or empty */\n    OMX_AUDIO_ChannelLF   = 0x1,    /**< Left front */\n    OMX_AUDIO_ChannelRF   = 0x2,    /**< Right front */\n    OMX_AUDIO_ChannelCF   = 0x3,    /**< Center front */\n    OMX_AUDIO_ChannelLS   = 0x4,    /**< Left surround */\n    OMX_AUDIO_ChannelRS   = 0x5,    /**< Right surround */\n    OMX_AUDIO_ChannelLFE  = 0x6,    /**< Low frequency effects */\n    OMX_AUDIO_ChannelCS   = 0x7,    /**< Back surround */\n    OMX_AUDIO_ChannelLR   = 0x8,    /**< Left rear. */\n    OMX_AUDIO_ChannelRR   = 0x9,    /**< Right rear. */\n    OMX_AUDIO_ChannelKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_AUDIO_ChannelVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_AUDIO_ChannelMax  = 0x7FFFFFFF \n} OMX_AUDIO_CHANNELTYPE;\n\n#define OMX_AUDIO_MAXCHANNELS 16  /**< maximum number distinct audio channels that a buffer may contain */\n#define OMX_MIN_PCMPAYLOAD_MSEC 5 /**< Minimum audio buffer payload size for uncompressed (PCM) audio */\n\n/** PCM format description */ \ntypedef struct OMX_AUDIO_PARAM_PCMMODETYPE { \n    OMX_U32 nSize;                    /**< Size of this structure, in Bytes */ \n    OMX_VERSIONTYPE nVersion;         /**< OMX specification version information */ \n    OMX_U32 nPortIndex;               /**< port that this structure applies to */ \n    OMX_U32 nChannels;                /**< Number of channels (e.g. 2 for stereo) */ \n    OMX_NUMERICALDATATYPE eNumData;   /**< indicates PCM data as signed or unsigned */ \n    OMX_ENDIANTYPE eEndian;           /**< indicates PCM data as little or big endian */ \n    OMX_BOOL bInterleaved;            /**< True for normal interleaved data; false for \n                                           non-interleaved data (e.g. block data) */ \n    OMX_U32 nBitPerSample;            /**< Bit per sample */ \n    OMX_U32 nSamplingRate;            /**< Sampling rate of the source data.  Use 0 for \n                                           variable or unknown sampling rate. */ \n    OMX_AUDIO_PCMMODETYPE ePCMMode;   /**< PCM mode enumeration */ \n    OMX_AUDIO_CHANNELTYPE eChannelMapping[OMX_AUDIO_MAXCHANNELS]; /**< Slot i contains channel defined by eChannelMap[i] */\n\n} OMX_AUDIO_PARAM_PCMMODETYPE; \n\n\n/** Audio channel mode.  This is used by both AAC and MP3, although the names are more appropriate\n * for the MP3.  For example, JointStereo for MP3 is CouplingChannels for AAC. \n */\ntypedef enum OMX_AUDIO_CHANNELMODETYPE {\n    OMX_AUDIO_ChannelModeStereo = 0,  /**< 2 channels, the bitrate allocation between those \n                                          two channels changes accordingly to each channel information */\n    OMX_AUDIO_ChannelModeJointStereo, /**< mode that takes advantage of what is common between \n                                           2 channels for higher compression gain */\n    OMX_AUDIO_ChannelModeDual,        /**< 2 mono-channels, each channel is encoded with half \n                                           the bitrate of the overall bitrate */\n    OMX_AUDIO_ChannelModeMono,        /**< Mono channel mode */\n    OMX_AUDIO_ChannelModeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_AUDIO_ChannelModeVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_AUDIO_ChannelModeMax = 0x7FFFFFFF\n} OMX_AUDIO_CHANNELMODETYPE;\n\n\ntypedef enum OMX_AUDIO_MP3STREAMFORMATTYPE {\n    OMX_AUDIO_MP3StreamFormatMP1Layer3 = 0, /**< MP3 Audio MPEG 1 Layer 3 Stream format */\n    OMX_AUDIO_MP3StreamFormatMP2Layer3,     /**< MP3 Audio MPEG 2 Layer 3 Stream format */\n    OMX_AUDIO_MP3StreamFormatMP2_5Layer3,   /**< MP3 Audio MPEG2.5 Layer 3 Stream format */\n    OMX_AUDIO_MP3StreamFormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_AUDIO_MP3StreamFormatVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_AUDIO_MP3StreamFormatMax = 0x7FFFFFFF\n} OMX_AUDIO_MP3STREAMFORMATTYPE;\n\n/** MP3 params */\ntypedef struct OMX_AUDIO_PARAM_MP3TYPE {\n    OMX_U32 nSize;                 /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion;      /**< OMX specification version information */\n    OMX_U32 nPortIndex;            /**< port that this structure applies to */\n    OMX_U32 nChannels;             /**< Number of channels */\n    OMX_U32 nBitRate;              /**< Bit rate of the input data.  Use 0 for variable\n                                        rate or unknown bit rates */\n    OMX_U32 nSampleRate;           /**< Sampling rate of the source data.  Use 0 for\n                                        variable or unknown sampling rate. */\n    OMX_U32 nAudioBandWidth;       /**< Audio band width (in Hz) to which an encoder should\n                                        limit the audio signal. Use 0 to let encoder decide */\n    OMX_AUDIO_CHANNELMODETYPE eChannelMode;   /**< Channel mode enumeration */\n    OMX_AUDIO_MP3STREAMFORMATTYPE eFormat;  /**< MP3 stream format */\n} OMX_AUDIO_PARAM_MP3TYPE;\n\ntypedef enum OMX_AUDIO_DDPBITSTREAMID {\n   OMX_AUDIO_DDPBitStreamIdAC3 = 8,\n   OMX_AUDIO_DDPBitStreamIdEAC3 = 16,\n   OMX_AUDIO_DDPBitStreamIdKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n   OMX_AUDIO_DDPBitStreamIdVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n   OMX_AUDIO_DDPBitStreamIdMax = 0x7FFFFFFF\n} OMX_AUDIO_DDPBITSTREAMID;\n\ntypedef enum OMX_AUDIO_DDPBITSTREAMMODE {\n   OMX_AUDIO_DDPBitStreamModeCM = 0,   /**< DDP any main audio service: complete main (CM) */\n   OMX_AUDIO_DDPBitStreamModeME,       /**< DDP any main audio service: music and effects (ME) */\n   OMX_AUDIO_DDPBitStreamModeVI,       /**< DDP any associated service: visually impaired (VI) */\n   OMX_AUDIO_DDPBitStreamModeHI,       /**< DDP any associated service: hearing impaired (HI)  */\n   OMX_AUDIO_DDPBitStreamModeD,        /**< DDP any associated service: dialogue (D)           */\n   OMX_AUDIO_DDPBitStreamModeC,        /**< DDP any associated service: commentary (C)         */\n   OMX_AUDIO_DDPBitStreamModeE,        /**< DDP any associated service: emergency (E)          */\n   OMX_AUDIO_DDPBitStreamModeVO,       /**< DDP associated service: voice over (VO)            */\n   OMX_AUDIO_DDPBitStreamModeK,        /**< DDP main audio service: karaoke                    */\n   OMX_AUDIO_DDPBitStreamModeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n   OMX_AUDIO_DDPBitStreamModeVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n   OMX_AUDIO_DDPBitStreamModeMax = 0x7FFFFFFF\n} OMX_AUDIO_DDPBITSTREAMMODE;\n\ntypedef enum OMX_AUDIO_DDPDOLBYSURROUNDMODE {\n   OMX_AUDIO_DDPDolbySurroundModeNotIndicated = 0,               /**< Not indicated */\n   OMX_AUDIO_DDPDolbySurroundModeNotDolbySurround,               /**< Not Dolby Surround */\n   OMX_AUDIO_DDPDolbySurroundModeDolbySurroundEncoded,           /**< Dolby Surround encoded */\n   OMX_AUDIO_DDPDolbySurroundModeReserverd,                      /**< Reserved */\n   OMX_AUDIO_DDPDolbySurroundModeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n   OMX_AUDIO_DDPDolbySurroundModeVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n   OMX_AUDIO_DDPDolbySurroundModeMax = 0x7FFFFFFF\n} OMX_AUDIO_DDPDOLBYSURROUNDMODE;\n\n/** DDP params */\ntypedef struct OMX_AUDIO_PARAM_DDPTYPE {\n    OMX_U32 nSize;                 /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion;      /**< OMX specification version information */\n    OMX_U32 nPortIndex;            /**< port that this structure applies to */\n    OMX_U32 nChannels;             /**< Number of channels */\n    OMX_U32 nBitRate;              /**< Bit rate of the input data.  Use 0 for variable\n                                        rate or unknown bit rates */\n    OMX_U32 nSampleRate;           /**< Sampling rate of the source data. Use 0 for\n                                        variable or unknown sampling rate. */\n    OMX_AUDIO_DDPBITSTREAMID eBitStreamId;\n    OMX_AUDIO_DDPBITSTREAMMODE eBitStreamMode;\n    OMX_AUDIO_DDPDOLBYSURROUNDMODE eDolbySurroundMode;\n    OMX_AUDIO_CHANNELTYPE eChannelMapping[OMX_AUDIO_MAXCHANNELS]; /**< Slot i contains channel defined by eChannelMapping[i] */    \n} OMX_AUDIO_PARAM_DDPTYPE;\n\n/** DTS params */\ntypedef struct OMX_AUDIO_PARAM_DTSTYPE {\n    OMX_U32 nSize;                 /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion;      /**< OMX specification version information */\n    OMX_U32 nPortIndex;            /**< port that this structure applies to */\n    OMX_U32 nChannels;             /**< Number of channels */\n    OMX_U32 nBitRate;              /**< Bit rate of the input data.  Use 0 for variable\n                                        rate or unknown bit rates */\n    OMX_U32 nSampleRate;           /**< Sampling rate of the source data. Use 0 for\n                                        variable or unknown sampling rate. */\n    OMX_U32 nDtsType;              /** DTS type 1, 2, or 3. */\n    OMX_U32 nFormat;               /** DTS stream is either big/little endian and 16/14 bit packing */\n    OMX_U32 nDtsFrameSizeBytes;    /** DTS frame size in bytes */\n    OMX_AUDIO_CHANNELTYPE eChannelMapping[OMX_AUDIO_MAXCHANNELS]; /**< Slot i contains channel defined by eChannelMapping[i] */\n} OMX_AUDIO_PARAM_DTSTYPE;\n\ntypedef enum OMX_AUDIO_AACSTREAMFORMATTYPE {\n    OMX_AUDIO_AACStreamFormatMP2ADTS = 0, /**< AAC Audio Data Transport Stream 2 format */\n    OMX_AUDIO_AACStreamFormatMP4ADTS,     /**< AAC Audio Data Transport Stream 4 format */\n    OMX_AUDIO_AACStreamFormatMP4LOAS,     /**< AAC Low Overhead Audio Stream format */\n    OMX_AUDIO_AACStreamFormatMP4LATM,     /**< AAC Low overhead Audio Transport Multiplex */\n    OMX_AUDIO_AACStreamFormatADIF,        /**< AAC Audio Data Interchange Format */\n    OMX_AUDIO_AACStreamFormatMP4FF,       /**< AAC inside MPEG-4/ISO File Format */\n    OMX_AUDIO_AACStreamFormatRAW,         /**< AAC Raw Format */\n    OMX_AUDIO_AACStreamFormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_AUDIO_AACStreamFormatVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_AUDIO_AACStreamFormatMax = 0x7FFFFFFF\n} OMX_AUDIO_AACSTREAMFORMATTYPE;\n\n\n/** AAC mode type.  Note that the term profile is used with the MPEG-2\n * standard and the term object type and profile is used with MPEG-4 */\ntypedef enum OMX_AUDIO_AACPROFILETYPE{\n  OMX_AUDIO_AACObjectNull = 0,      /**< Null, not used */\n  OMX_AUDIO_AACObjectMain = 1,      /**< AAC Main object */\n  OMX_AUDIO_AACObjectLC,            /**< AAC Low Complexity object (AAC profile) */\n  OMX_AUDIO_AACObjectSSR,           /**< AAC Scalable Sample Rate object */\n  OMX_AUDIO_AACObjectLTP,           /**< AAC Long Term Prediction object */\n  OMX_AUDIO_AACObjectHE,            /**< AAC High Efficiency (object type SBR, HE-AAC profile) */\n  OMX_AUDIO_AACObjectScalable,      /**< AAC Scalable object */\n  OMX_AUDIO_AACObjectERLC = 17,     /**< ER AAC Low Complexity object (Error Resilient AAC-LC) */\n  OMX_AUDIO_AACObjectLD = 23,       /**< AAC Low Delay object (Error Resilient) */\n  OMX_AUDIO_AACObjectHE_PS = 29,    /**< AAC High Efficiency with Parametric Stereo coding (HE-AAC v2, object type PS) */\n  OMX_AUDIO_AACObjectKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n  OMX_AUDIO_AACObjectVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n  OMX_AUDIO_AACObjectMax = 0x7FFFFFFF\n} OMX_AUDIO_AACPROFILETYPE;\n\n\n/** AAC tool usage (for nAACtools in OMX_AUDIO_PARAM_AACPROFILETYPE).\n * Required for encoder configuration and optional as decoder info output.\n * For MP3, OMX_AUDIO_CHANNELMODETYPE is sufficient. */\n#define OMX_AUDIO_AACToolNone 0x00000000 /**< no AAC tools allowed (encoder config) or active (decoder info output) */\n#define OMX_AUDIO_AACToolMS   0x00000001 /**< MS: Mid/side joint coding tool allowed or active */\n#define OMX_AUDIO_AACToolIS   0x00000002 /**< IS: Intensity stereo tool allowed or active */\n#define OMX_AUDIO_AACToolTNS  0x00000004 /**< TNS: Temporal Noise Shaping tool allowed or active */\n#define OMX_AUDIO_AACToolPNS  0x00000008 /**< PNS: MPEG-4 Perceptual Noise substitution tool allowed or active */\n#define OMX_AUDIO_AACToolLTP  0x00000010 /**< LTP: MPEG-4 Long Term Prediction tool allowed or active */\n#define OMX_AUDIO_AACToolAll  0x7FFFFFFF /**< all AAC tools allowed or active (*/\n\n/** MPEG-4 AAC error resilience (ER) tool usage (for nAACERtools in OMX_AUDIO_PARAM_AACPROFILETYPE).\n * Required for ER encoder configuration and optional as decoder info output */\n#define OMX_AUDIO_AACERNone  0x00000000  /**< no AAC ER tools allowed/used */\n#define OMX_AUDIO_AACERVCB11 0x00000001  /**< VCB11: Virtual Code Books for AAC section data */\n#define OMX_AUDIO_AACERRVLC  0x00000002  /**< RVLC: Reversible Variable Length Coding */\n#define OMX_AUDIO_AACERHCR   0x00000004  /**< HCR: Huffman Codeword Reordering */\n#define OMX_AUDIO_AACERAll   0x7FFFFFFF  /**< all AAC ER tools allowed/used */\n\n\n/** AAC params */\ntypedef struct OMX_AUDIO_PARAM_AACPROFILETYPE {\n    OMX_U32 nSize;                 /**< Size of this structure, in Bytes */\n    OMX_VERSIONTYPE nVersion;      /**< OMX specification version information */\n    OMX_U32 nPortIndex;            /**< Port that this structure applies to */\n    OMX_U32 nChannels;             /**< Number of channels */\n    OMX_U32 nSampleRate;           /**< Sampling rate of the source data.  Use 0 for\n                                        variable or unknown sampling rate. */\n    OMX_U32 nBitRate;              /**< Bit rate of the input data.  Use 0 for variable\n                                        rate or unknown bit rates */\n    OMX_U32 nAudioBandWidth;       /**< Audio band width (in Hz) to which an encoder should\n                                        limit the audio signal. Use 0 to let encoder decide */\n    OMX_U32 nFrameLength;          /**< Frame length (in audio samples per channel) of the codec.\n                                        Can be 1024 or 960 (AAC-LC), 2048 (HE-AAC), 480 or 512 (AAC-LD).\n                                        Use 0 to let encoder decide */\n    OMX_U32 nAACtools;             /**< AAC tool usage */\n    OMX_U32 nAACERtools;           /**< MPEG-4 AAC error resilience tool usage */\n    OMX_AUDIO_AACPROFILETYPE eAACProfile;   /**< AAC profile enumeration */\n    OMX_AUDIO_AACSTREAMFORMATTYPE eAACStreamFormat; /**< AAC stream format enumeration */\n    OMX_AUDIO_CHANNELMODETYPE eChannelMode;   /**< Channel mode enumeration */\n} OMX_AUDIO_PARAM_AACPROFILETYPE;\n\n\n/** VORBIS params */\ntypedef struct OMX_AUDIO_PARAM_VORBISTYPE {\n    OMX_U32 nSize;            /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion; /**< OMX specification version information */\n    OMX_U32 nPortIndex;       /**< port that this structure applies to */\n    OMX_U32 nChannels;        /**< Number of channels */\n    OMX_U32 nBitRate;         /**< Bit rate of the encoded data data.  Use 0 for variable\n                                   rate or unknown bit rates. Encoding is set to the\n                                   bitrate closest to specified  value (in bps) */\n    OMX_U32 nMinBitRate;      /**< Sets minimum bitrate (in bps). */\n    OMX_U32 nMaxBitRate;      /**< Sets maximum bitrate (in bps). */\n\n    OMX_U32 nSampleRate;      /**< Sampling rate of the source data.  Use 0 for\n                                   variable or unknown sampling rate. */\n    OMX_U32 nAudioBandWidth;  /**< Audio band width (in Hz) to which an encoder should\n                                   limit the audio signal. Use 0 to let encoder decide */\n    OMX_S32 nQuality;\t\t  /**< Sets encoding quality to n, between -1 (low) and 10 (high).\n                                   In the default mode of operation, the quality level is 3.\n                                   Normal quality range is 0 - 10. */\n    OMX_BOOL bManaged;\t\t  /**< Set  bitrate  management  mode. This turns off the\n                                   normal VBR encoding, but allows hard or soft bitrate\n                                   constraints to be enforced by the encoder. This mode can\n                                   be slower, and may also be lower quality. It is\n                                   primarily useful for streaming. */\n    OMX_BOOL bDownmix;\t\t  /**< Downmix input from stereo to mono (has no effect on \n                                   non-stereo streams). Useful for lower-bitrate encoding. */     \n} OMX_AUDIO_PARAM_VORBISTYPE;\n\n\n/** WMA Version */\ntypedef enum OMX_AUDIO_WMAFORMATTYPE {\n  OMX_AUDIO_WMAFormatUnused = 0, /**< format unused or unknown */\n  OMX_AUDIO_WMAFormat7,          /**< Windows Media Audio format 7 */\n  OMX_AUDIO_WMAFormat8,          /**< Windows Media Audio format 8 */\n  OMX_AUDIO_WMAFormat9,          /**< Windows Media Audio format 9 */\n  OMX_AUDIO_WMAFormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n  OMX_AUDIO_WMAFormatVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n  OMX_AUDIO_WMAFormatMax = 0x7FFFFFFF\n} OMX_AUDIO_WMAFORMATTYPE;\n\n\n/** WMA Profile */\ntypedef enum OMX_AUDIO_WMAPROFILETYPE {\n  OMX_AUDIO_WMAProfileUnused = 0,  /**< profile unused or unknown */\n  OMX_AUDIO_WMAProfileL1,          /**< Windows Media audio version 9 profile L1 */\n  OMX_AUDIO_WMAProfileL2,          /**< Windows Media audio version 9 profile L2 */\n  OMX_AUDIO_WMAProfileL3,          /**< Windows Media audio version 9 profile L3 */\n  OMX_AUDIO_WMAProfileKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n  OMX_AUDIO_WMAProfileVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n  OMX_AUDIO_WMAProfileMax = 0x7FFFFFFF\n} OMX_AUDIO_WMAPROFILETYPE;\n\n\n/** WMA params */\ntypedef struct OMX_AUDIO_PARAM_WMATYPE {\n    OMX_U32 nSize;            /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion; /**< OMX specification version information */\n    OMX_U32 nPortIndex;       /**< port that this structure applies to */\n    OMX_U16 nChannels;        /**< Number of channels */\n    OMX_U32 nBitRate;         /**< Bit rate of the input data.  Use 0 for variable\n                                   rate or unknown bit rates */\n    OMX_AUDIO_WMAFORMATTYPE eFormat; /**< Version of WMA stream / data */\n\tOMX_AUDIO_WMAPROFILETYPE eProfile;  /**< Profile of WMA stream / data */\n    OMX_U32 nSamplingRate;    /**< Sampling rate of the source data */\n    OMX_U16 nBlockAlign;      /**< is the block alignment, or block size, in bytes of the audio codec */\n    OMX_U16 nEncodeOptions;   /**< WMA Type-specific data */\n    OMX_U32 nSuperBlockAlign; /**< WMA Type-specific data */\n} OMX_AUDIO_PARAM_WMATYPE;\n\n/** \n * RealAudio format\n */\ntypedef enum OMX_AUDIO_RAFORMATTYPE {\n    OMX_AUDIO_RAFormatUnused = 0, /**< Format unused or unknown */\n    OMX_AUDIO_RA8,                /**< RealAudio 8 codec */\n    OMX_AUDIO_RA9,                /**< RealAudio 9 codec */\n    OMX_AUDIO_RA10_AAC,           /**< MPEG-4 AAC codec for bitrates of more than 128kbps */\n    OMX_AUDIO_RA10_CODEC,         /**< RealAudio codec for bitrates less than 128 kbps */\n    OMX_AUDIO_RA10_LOSSLESS,      /**< RealAudio Lossless */\n    OMX_AUDIO_RA10_MULTICHANNEL,  /**< RealAudio Multichannel */\n    OMX_AUDIO_RA10_VOICE,         /**< RealAudio Voice for bitrates below 15 kbps */\n    OMX_AUDIO_RAFormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_AUDIO_RAFormatVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_VIDEO_RAFormatMax = 0x7FFFFFFF\n} OMX_AUDIO_RAFORMATTYPE;\n\n/** RA (Real Audio) params */ \ntypedef struct OMX_AUDIO_PARAM_RATYPE { \n    OMX_U32 nSize;              /**< Size of this structure, in Bytes */ \n    OMX_VERSIONTYPE nVersion;   /**< OMX specification version information */ \n    OMX_U32 nPortIndex;         /**< Port that this structure applies to */ \n    OMX_U32 nChannels;          /**< Number of channels */ \n    OMX_U32 nSamplingRate;      /**< is the sampling rate of the source data */ \n    OMX_U32 nBitsPerFrame;      /**< is the value for bits per frame  */ \n    OMX_U32 nSamplePerFrame;    /**< is the value for samples per frame */ \n    OMX_U32 nCouplingQuantBits; /**< is the number of coupling quantization bits in the stream */ \n    OMX_U32 nCouplingStartRegion;   /**< is the coupling start region in the stream  */ \n    OMX_U32 nNumRegions;        /**< is the number of regions value */ \n    OMX_AUDIO_RAFORMATTYPE eFormat; /**< is the RealAudio audio format */\n} OMX_AUDIO_PARAM_RATYPE; \n\n\n/** SBC Allocation Method Type */\ntypedef enum OMX_AUDIO_SBCALLOCMETHODTYPE {\n  OMX_AUDIO_SBCAllocMethodLoudness, /**< Loudness allocation method */\n  OMX_AUDIO_SBCAllocMethodSNR,      /**< SNR allocation method */\n  OMX_AUDIO_SBCAllocMethodKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n  OMX_AUDIO_SBCAllocMethodVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n  OMX_AUDIO_SBCAllocMethodMax = 0x7FFFFFFF\n} OMX_AUDIO_SBCALLOCMETHODTYPE;\n\n\n/** SBC params */\ntypedef struct OMX_AUDIO_PARAM_SBCTYPE {\n    OMX_U32 nSize;             /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion;  /**< OMX specification version information */\n    OMX_U32 nPortIndex;        /**< port that this structure applies to */\n    OMX_U32 nChannels;         /**< Number of channels */\n    OMX_U32 nBitRate;          /**< Bit rate of the input data.  Use 0 for variable\n                                    rate or unknown bit rates */\n    OMX_U32 nSampleRate;       /**< Sampling rate of the source data.  Use 0 for\n                                    variable or unknown sampling rate. */\n    OMX_U32 nBlocks;           /**< Number of blocks */\n    OMX_U32 nSubbands;         /**< Number of subbands */\n    OMX_U32 nBitPool;          /**< Bitpool value */\n    OMX_BOOL bEnableBitrate;   /**< Use bitrate value instead of bitpool */\n    OMX_AUDIO_CHANNELMODETYPE eChannelMode; /**< Channel mode enumeration */\n    OMX_AUDIO_SBCALLOCMETHODTYPE eSBCAllocType;   /**< SBC Allocation method type */\n} OMX_AUDIO_PARAM_SBCTYPE;\n\n\n/** ADPCM stream format parameters */ \ntypedef struct OMX_AUDIO_PARAM_ADPCMTYPE { \n    OMX_U32 nSize;              /**< size of the structure in bytes */ \n    OMX_VERSIONTYPE nVersion;   /**< OMX specification version information */ \n    OMX_U32 nPortIndex;         /**< port that this structure applies to */ \n    OMX_U32 nChannels;          /**< Number of channels in the data stream (not \n                                     necessarily the same as the number of channels \n                                     to be rendered. */ \n    OMX_U32 nBitsPerSample;     /**< Number of bits in each sample */ \n    OMX_U32 nSampleRate;        /**< Sampling rate of the source data.  Use 0 for \n                                    variable or unknown sampling rate. */ \n} OMX_AUDIO_PARAM_ADPCMTYPE; \n\n\n/** G723 rate */\ntypedef enum OMX_AUDIO_G723RATE {\n    OMX_AUDIO_G723ModeUnused = 0,  /**< AMRNB Mode unused / unknown */\n    OMX_AUDIO_G723ModeLow,         /**< 5300 bps */\n    OMX_AUDIO_G723ModeHigh,        /**< 6300 bps */\n    OMX_AUDIO_G723ModeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_AUDIO_G723ModeVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_AUDIO_G723ModeMax = 0x7FFFFFFF\n} OMX_AUDIO_G723RATE;\n\n\n/** G723 - Sample rate must be 8 KHz */\ntypedef struct OMX_AUDIO_PARAM_G723TYPE { \n    OMX_U32 nSize;                /**< size of the structure in bytes */ \n    OMX_VERSIONTYPE nVersion;     /**< OMX specification version information */ \n    OMX_U32 nPortIndex;           /**< port that this structure applies to */ \n    OMX_U32 nChannels;            /**< Number of channels in the data stream (not \n                                       necessarily the same as the number of channels \n                                       to be rendered. */ \n    OMX_BOOL bDTX;                /**< Enable Discontinuous Transmisssion */ \n    OMX_AUDIO_G723RATE eBitRate;  /**< todo: Should this be moved to a config? */\n    OMX_BOOL bHiPassFilter;       /**< Enable High Pass Filter */ \n    OMX_BOOL bPostFilter;         /**< Enable Post Filter */ \n} OMX_AUDIO_PARAM_G723TYPE; \n\n\n/** ITU G726 (ADPCM) rate */\ntypedef enum OMX_AUDIO_G726MODE {\n    OMX_AUDIO_G726ModeUnused = 0,  /**< G726 Mode unused / unknown */\n    OMX_AUDIO_G726Mode16,          /**< 16 kbps */\n    OMX_AUDIO_G726Mode24,          /**< 24 kbps */\n    OMX_AUDIO_G726Mode32,          /**< 32 kbps, most common rate, also G721 */\n    OMX_AUDIO_G726Mode40,          /**< 40 kbps */\n    OMX_AUDIO_G726ModeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_AUDIO_G726ModeVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_AUDIO_G726ModeMax = 0x7FFFFFFF\n} OMX_AUDIO_G726MODE;\n\n\n/** G.726 stream format parameters - must be at 8KHz */ \ntypedef struct OMX_AUDIO_PARAM_G726TYPE { \n    OMX_U32 nSize;              /**< size of the structure in bytes */ \n    OMX_VERSIONTYPE nVersion;   /**< OMX specification version information */ \n    OMX_U32 nPortIndex;         /**< port that this structure applies to */ \n    OMX_U32 nChannels;          /**< Number of channels in the data stream (not \n                                     necessarily the same as the number of channels \n                                     to be rendered. */ \n     OMX_AUDIO_G726MODE eG726Mode;\n} OMX_AUDIO_PARAM_G726TYPE; \n\n\n/** G729 coder type */\ntypedef enum OMX_AUDIO_G729TYPE {\n    OMX_AUDIO_G729 = 0,           /**< ITU G.729  encoded data */\n    OMX_AUDIO_G729A,              /**< ITU G.729 annex A  encoded data */\n    OMX_AUDIO_G729B,              /**< ITU G.729 with annex B encoded data */\n    OMX_AUDIO_G729AB,             /**< ITU G.729 annexes A and B encoded data */\n    OMX_AUDIO_G729KhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_AUDIO_G729VendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_AUDIO_G729Max = 0x7FFFFFFF\n} OMX_AUDIO_G729TYPE;\n\n\n/** G729 stream format parameters - fixed 6KHz sample rate */\ntypedef struct OMX_AUDIO_PARAM_G729TYPE {\n    OMX_U32 nSize;            /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion; /**< OMX specification version information */\n    OMX_U32 nPortIndex;       /**< port that this structure applies to */\n    OMX_U32 nChannels;        /**< Number of channels in the data stream (not\n                                   necessarily the same as the number of channels\n                                   to be rendered. */\n    OMX_BOOL bDTX;            /**< Enable Discontinuous Transmisssion */\n    OMX_AUDIO_G729TYPE eBitType;\n} OMX_AUDIO_PARAM_G729TYPE;\n\n\n/** AMR Frame format */ \ntypedef enum OMX_AUDIO_AMRFRAMEFORMATTYPE { \n    OMX_AUDIO_AMRFrameFormatConformance = 0,  /**< Frame Format is AMR Conformance \n                                                   (Standard) Format */ \n    OMX_AUDIO_AMRFrameFormatIF1,              /**< Frame Format is AMR Interface \n                                                   Format 1 */ \n    OMX_AUDIO_AMRFrameFormatIF2,              /**< Frame Format is AMR Interface \n                                                   Format 2*/ \n    OMX_AUDIO_AMRFrameFormatFSF,              /**< Frame Format is AMR File Storage \n                                                   Format */ \n    OMX_AUDIO_AMRFrameFormatRTPPayload,       /**< Frame Format is AMR Real-Time \n                                                   Transport Protocol Payload Format */ \n    OMX_AUDIO_AMRFrameFormatITU,              /**< Frame Format is ITU Format (added at Motorola request) */ \n    OMX_AUDIO_AMRFrameFormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_AUDIO_AMRFrameFormatVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_AUDIO_AMRFrameFormatMax = 0x7FFFFFFF \n} OMX_AUDIO_AMRFRAMEFORMATTYPE; \n\n\n/** AMR band mode */\ntypedef enum OMX_AUDIO_AMRBANDMODETYPE {\n    OMX_AUDIO_AMRBandModeUnused = 0,          /**< AMRNB Mode unused / unknown */\n    OMX_AUDIO_AMRBandModeNB0,                 /**< AMRNB Mode 0 =  4750 bps */\n    OMX_AUDIO_AMRBandModeNB1,                 /**< AMRNB Mode 1 =  5150 bps */\n    OMX_AUDIO_AMRBandModeNB2,                 /**< AMRNB Mode 2 =  5900 bps */ \n    OMX_AUDIO_AMRBandModeNB3,                 /**< AMRNB Mode 3 =  6700 bps */\n    OMX_AUDIO_AMRBandModeNB4,                 /**< AMRNB Mode 4 =  7400 bps */\n    OMX_AUDIO_AMRBandModeNB5,                 /**< AMRNB Mode 5 =  7950 bps */\n    OMX_AUDIO_AMRBandModeNB6,                 /**< AMRNB Mode 6 = 10200 bps */\n    OMX_AUDIO_AMRBandModeNB7,                 /**< AMRNB Mode 7 = 12200 bps */\n    OMX_AUDIO_AMRBandModeWB0,                 /**< AMRWB Mode 0 =  6600 bps */\n    OMX_AUDIO_AMRBandModeWB1,                 /**< AMRWB Mode 1 =  8850 bps */\n    OMX_AUDIO_AMRBandModeWB2,                 /**< AMRWB Mode 2 = 12650 bps */ \n    OMX_AUDIO_AMRBandModeWB3,                 /**< AMRWB Mode 3 = 14250 bps */ \n    OMX_AUDIO_AMRBandModeWB4,                 /**< AMRWB Mode 4 = 15850 bps */\n    OMX_AUDIO_AMRBandModeWB5,                 /**< AMRWB Mode 5 = 18250 bps */\n    OMX_AUDIO_AMRBandModeWB6,                 /**< AMRWB Mode 6 = 19850 bps */\n    OMX_AUDIO_AMRBandModeWB7,                 /**< AMRWB Mode 7 = 23050 bps */\n    OMX_AUDIO_AMRBandModeWB8,                 /**< AMRWB Mode 8 = 23850 bps */      \n    OMX_AUDIO_AMRBandModeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_AUDIO_AMRBandModeVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_AUDIO_AMRBandModeMax = 0x7FFFFFFF\n} OMX_AUDIO_AMRBANDMODETYPE;\n     \n\n/** AMR Discontinuous Transmission mode */ \ntypedef enum OMX_AUDIO_AMRDTXMODETYPE { \n    OMX_AUDIO_AMRDTXModeOff = 0,        /**< AMR Discontinuous Transmission Mode is disabled */ \n    OMX_AUDIO_AMRDTXModeOnVAD1,         /**< AMR Discontinuous Transmission Mode using \n                                             Voice Activity Detector 1 (VAD1) is enabled */ \n    OMX_AUDIO_AMRDTXModeOnVAD2,         /**< AMR Discontinuous Transmission Mode using \n                                             Voice Activity Detector 2 (VAD2) is enabled */       \n    OMX_AUDIO_AMRDTXModeOnAuto,         /**< The codec will automatically select between \n                                             Off, VAD1 or VAD2 modes */ \n\n    OMX_AUDIO_AMRDTXasEFR,             /**< DTX as EFR instead of AMR standard (3GPP 26.101, frame type =8,9,10) */\n\n    OMX_AUDIO_AMRDTXModeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_AUDIO_AMRDTXModeVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_AUDIO_AMRDTXModeMax = 0x7FFFFFFF \n} OMX_AUDIO_AMRDTXMODETYPE; \n \n\n/** AMR params */\ntypedef struct OMX_AUDIO_PARAM_AMRTYPE {\n    OMX_U32 nSize;                          /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion;               /**< OMX specification version information */\n    OMX_U32 nPortIndex;                     /**< port that this structure applies to */\n    OMX_U32 nChannels;                      /**< Number of channels */\n    OMX_U32 nBitRate;                       /**< Bit rate read only field */\n    OMX_AUDIO_AMRBANDMODETYPE eAMRBandMode; /**< AMR Band Mode enumeration */ \n    OMX_AUDIO_AMRDTXMODETYPE  eAMRDTXMode;  /**< AMR DTX Mode enumeration */\n    OMX_AUDIO_AMRFRAMEFORMATTYPE eAMRFrameFormat; /**< AMR frame format enumeration */\n} OMX_AUDIO_PARAM_AMRTYPE;\n\n\n/** GSM_FR (ETSI 06.10, 3GPP 46.010) stream format parameters */\ntypedef struct OMX_AUDIO_PARAM_GSMFRTYPE {\n    OMX_U32 nSize;            /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion; /**< OMX specification version information */\n    OMX_U32 nPortIndex;       /**< port that this structure applies to */\n    OMX_BOOL bDTX;            /**< Enable Discontinuous Transmisssion */\n    OMX_BOOL bHiPassFilter;   /**< Enable High Pass Filter */\n} OMX_AUDIO_PARAM_GSMFRTYPE;\n\n\n/** GSM-HR (ETSI 06.20, 3GPP 46.020) stream format parameters */\ntypedef struct OMX_AUDIO_PARAM_GSMHRTYPE {\n    OMX_U32 nSize;            /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion; /**< OMX specification version information */\n    OMX_U32 nPortIndex;       /**< port that this structure applies to */\n    OMX_BOOL bDTX;            /**< Enable Discontinuous Transmisssion */\n    OMX_BOOL bHiPassFilter;   /**< Enable High Pass Filter */\n} OMX_AUDIO_PARAM_GSMHRTYPE;\n\n\n/** GSM-EFR (ETSI 06.60, 3GPP 46.060) stream format parameters */\ntypedef struct OMX_AUDIO_PARAM_GSMEFRTYPE {\n    OMX_U32 nSize;            /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion; /**< OMX specification version information */\n    OMX_U32 nPortIndex;       /**< port that this structure applies to */\n    OMX_BOOL bDTX;            /**< Enable Discontinuous Transmisssion */\n    OMX_BOOL bHiPassFilter;   /**< Enable High Pass Filter */\n} OMX_AUDIO_PARAM_GSMEFRTYPE;\n\n\n/** TDMA FR (TIA/EIA-136-420, VSELP 7.95kbps coder) stream format parameters */\ntypedef struct OMX_AUDIO_PARAM_TDMAFRTYPE {\n    OMX_U32 nSize;                /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion;     /**< OMX specification version information */\n    OMX_U32 nPortIndex;           /**< port that this structure applies to */\n    OMX_U32 nChannels;            /**< Number of channels in the data stream (not\n                                       necessarily the same as the number of channels\n                                       to be rendered. */\n    OMX_BOOL bDTX;                /**< Enable Discontinuous Transmisssion */\n    OMX_BOOL bHiPassFilter;       /**< Enable High Pass Filter */\n} OMX_AUDIO_PARAM_TDMAFRTYPE;\n\n\n/** TDMA EFR (TIA/EIA-136-410, ACELP 7.4kbps coder) stream format parameters */\ntypedef struct OMX_AUDIO_PARAM_TDMAEFRTYPE {\n    OMX_U32 nSize;                /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion;     /**< OMX specification version information */\n    OMX_U32 nPortIndex;           /**< port that this structure applies to */\n    OMX_U32 nChannels;            /**< Number of channels in the data stream (not\n                                       necessarily the same as the number of channels\n                                       to be rendered. */\n    OMX_BOOL bDTX;                /**< Enable Discontinuous Transmisssion */\n    OMX_BOOL bHiPassFilter;       /**< Enable High Pass Filter */\n} OMX_AUDIO_PARAM_TDMAEFRTYPE;\n\n\n/** PDC FR ( RCR-27, VSELP 6.7kbps coder) stream format parameters */\ntypedef struct OMX_AUDIO_PARAM_PDCFRTYPE {\n    OMX_U32 nSize;                /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion;     /**< OMX specification version information */\n    OMX_U32 nPortIndex;           /**< port that this structure applies to */\n    OMX_U32 nChannels;            /**< Number of channels in the data stream (not\n                                       necessarily the same as the number of channels\n                                       to be rendered. */\n    OMX_BOOL bDTX;                /**< Enable Discontinuous Transmisssion */\n    OMX_BOOL bHiPassFilter;       /**< Enable High Pass Filter */\n} OMX_AUDIO_PARAM_PDCFRTYPE;\n\n\n/** PDC EFR ( RCR-27, ACELP 6.7kbps coder) stream format parameters */\ntypedef struct OMX_AUDIO_PARAM_PDCEFRTYPE {\n    OMX_U32 nSize;                /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion;     /**< OMX specification version information */\n    OMX_U32 nPortIndex;           /**< port that this structure applies to */\n    OMX_U32 nChannels;            /**< Number of channels in the data stream (not\n                                       necessarily the same as the number of channels\n                                       to be rendered. */\n    OMX_BOOL bDTX;                /**< Enable Discontinuous Transmisssion */\n    OMX_BOOL bHiPassFilter;       /**< Enable High Pass Filter */\n} OMX_AUDIO_PARAM_PDCEFRTYPE;\n\n/** PDC HR ( RCR-27, PSI-CELP 3.45kbps coder) stream format parameters */\ntypedef struct OMX_AUDIO_PARAM_PDCHRTYPE {\n    OMX_U32 nSize;                /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion;     /**< OMX specification version information */\n    OMX_U32 nPortIndex;           /**< port that this structure applies to */\n    OMX_U32 nChannels;            /**< Number of channels in the data stream (not\n                                       necessarily the same as the number of channels\n                                       to be rendered. */\n    OMX_BOOL bDTX;                /**< Enable Discontinuous Transmisssion */\n    OMX_BOOL bHiPassFilter;       /**< Enable High Pass Filter */\n} OMX_AUDIO_PARAM_PDCHRTYPE;\n\n\n/** CDMA Rate types */\ntypedef enum OMX_AUDIO_CDMARATETYPE {\n    OMX_AUDIO_CDMARateBlank = 0,          /**< CDMA encoded frame is blank */\n    OMX_AUDIO_CDMARateFull,               /**< CDMA encoded frame in full rate */\n    OMX_AUDIO_CDMARateHalf,               /**< CDMA encoded frame in half rate */\n    OMX_AUDIO_CDMARateQuarter,            /**< CDMA encoded frame in quarter rate */\n    OMX_AUDIO_CDMARateEighth,             /**< CDMA encoded frame in eighth rate (DTX)*/\n    OMX_AUDIO_CDMARateErasure,            /**< CDMA erasure frame */\n    OMX_AUDIO_CDMARateKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_AUDIO_CDMARateVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_AUDIO_CDMARateMax = 0x7FFFFFFF\n} OMX_AUDIO_CDMARATETYPE;\n\n\n/** QCELP8 (TIA/EIA-96, up to 8kbps coder) stream format parameters */\ntypedef struct OMX_AUDIO_PARAM_QCELP8TYPE {\n    OMX_U32 nSize;                /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion;     /**< OMX specification version information */\n    OMX_U32 nPortIndex;           /**< port that this structure applies to */\n    OMX_U32 nChannels;            /**< Number of channels in the data stream (not\n                                       necessarily the same as the number of channels\n                                       to be rendered. */\n    OMX_U32 nBitRate;             /**< Bit rate of the input data.  Use 0 for variable\n                                       rate or unknown bit rates */\n    OMX_AUDIO_CDMARATETYPE eCDMARate; /**< Frame rate */\n    OMX_U32 nMinBitRate;          /**< minmal rate for the encoder = 1,2,3,4, default = 1 */\n    OMX_U32 nMaxBitRate;          /**< maximal rate for the encoder = 1,2,3,4, default = 4 */\n} OMX_AUDIO_PARAM_QCELP8TYPE;\n\n\n/** QCELP13 ( CDMA, EIA/TIA-733, 13.3kbps coder) stream format parameters */\ntypedef struct OMX_AUDIO_PARAM_QCELP13TYPE {\n    OMX_U32 nSize;                /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion;     /**< OMX specification version information */\n    OMX_U32 nPortIndex;           /**< port that this structure applies to */\n    OMX_U32 nChannels;            /**< Number of channels in the data stream (not\n                                       necessarily the same as the number of channels\n                                       to be rendered. */\n    OMX_AUDIO_CDMARATETYPE eCDMARate; /**< Frame rate */\n    OMX_U32 nMinBitRate;          /**< minmal rate for the encoder = 1,2,3,4, default = 1 */\n    OMX_U32 nMaxBitRate;          /**< maximal rate for the encoder = 1,2,3,4, default = 4 */\n} OMX_AUDIO_PARAM_QCELP13TYPE;\n\n\n/** EVRC ( CDMA, EIA/TIA-127, RCELP up to 8.55kbps coder) stream format parameters */\ntypedef struct OMX_AUDIO_PARAM_EVRCTYPE {\n    OMX_U32 nSize;                /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion;     /**< OMX specification version information */\n    OMX_U32 nPortIndex;           /**< port that this structure applies to */\n    OMX_U32 nChannels;            /**< Number of channels in the data stream (not\n                                       necessarily the same as the number of channels\n                                       to be rendered. */\n    OMX_AUDIO_CDMARATETYPE eCDMARate; /**< actual Frame rate */\n    OMX_BOOL bRATE_REDUCon;       /**< RATE_REDUCtion is requested for this frame */\n    OMX_U32 nMinBitRate;          /**< minmal rate for the encoder = 1,2,3,4, default = 1 */\n    OMX_U32 nMaxBitRate;          /**< maximal rate for the encoder = 1,2,3,4, default = 4 */\n    OMX_BOOL bHiPassFilter;       /**< Enable encoder's High Pass Filter */\n    OMX_BOOL bNoiseSuppressor;    /**< Enable encoder's noise suppressor pre-processing */\n    OMX_BOOL bPostFilter;         /**< Enable decoder's post Filter */\n} OMX_AUDIO_PARAM_EVRCTYPE;\n\n\n/** SMV ( up to 8.55kbps coder) stream format parameters */\ntypedef struct OMX_AUDIO_PARAM_SMVTYPE {\n    OMX_U32 nSize;                /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion;     /**< OMX specification version information */\n    OMX_U32 nPortIndex;           /**< port that this structure applies to */\n    OMX_U32 nChannels;            /**< Number of channels in the data stream (not\n                                       necessarily the same as the number of channels\n                                       to be rendered. */\n    OMX_AUDIO_CDMARATETYPE eCDMARate; /**< Frame rate */\n    OMX_BOOL bRATE_REDUCon;           /**< RATE_REDUCtion is requested for this frame */\n    OMX_U32 nMinBitRate;          /**< minmal rate for the encoder = 1,2,3,4, default = 1 ??*/\n    OMX_U32 nMaxBitRate;          /**< maximal rate for the encoder = 1,2,3,4, default = 4 ??*/\n    OMX_BOOL bHiPassFilter;       /**< Enable encoder's High Pass Filter ??*/\n    OMX_BOOL bNoiseSuppressor;    /**< Enable encoder's noise suppressor pre-processing */\n    OMX_BOOL bPostFilter;         /**< Enable decoder's post Filter ??*/\n} OMX_AUDIO_PARAM_SMVTYPE;\n\n\n/** MIDI Format \n * @ingroup midi\n */\ntypedef enum OMX_AUDIO_MIDIFORMATTYPE\n{\n    OMX_AUDIO_MIDIFormatUnknown = 0, /**< MIDI Format unknown or don't care */\n    OMX_AUDIO_MIDIFormatSMF0,        /**< Standard MIDI File Type 0 */\n    OMX_AUDIO_MIDIFormatSMF1,        /**< Standard MIDI File Type 1 */\n    OMX_AUDIO_MIDIFormatSMF2,        /**< Standard MIDI File Type 2 */\n    OMX_AUDIO_MIDIFormatSPMIDI,      /**< SP-MIDI */\n    OMX_AUDIO_MIDIFormatXMF0,        /**< eXtensible Music Format type 0 */\n    OMX_AUDIO_MIDIFormatXMF1,        /**< eXtensible Music Format type 1 */\n    OMX_AUDIO_MIDIFormatMobileXMF,   /**< Mobile XMF (eXtensible Music Format type 2) */\n    OMX_AUDIO_MIDIFormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_AUDIO_MIDIFormatVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_AUDIO_MIDIFormatMax = 0x7FFFFFFF\n} OMX_AUDIO_MIDIFORMATTYPE;\n\n\n/** MIDI params \n * @ingroup midi\n */\ntypedef struct OMX_AUDIO_PARAM_MIDITYPE {\n    OMX_U32 nSize;                 /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion;      /**< OMX specification version information */\n    OMX_U32 nPortIndex;            /**< port that this structure applies to */\n    OMX_U32 nFileSize;             /**< size of the MIDI file in bytes, where the entire \n                                        MIDI file passed in, otherwise if 0x0, the MIDI data \n                                        is merged and streamed (instead of passed as an \n                                        entire MIDI file) */\n    OMX_BU32 sMaxPolyphony;        /**< Specifies the maximum simultaneous polyphonic \n                                        voices. A value of zero indicates that the default \n                                        polyphony of the device is used  */                                    \n    OMX_BOOL bLoadDefaultSound;    /**< Whether to load default sound \n                                        bank at initialization */\n    OMX_AUDIO_MIDIFORMATTYPE eMidiFormat; /**< Version of the MIDI file */                                                                           \n} OMX_AUDIO_PARAM_MIDITYPE;\n\n\n/** Type of the MIDI sound bank \n * @ingroup midi\n */\ntypedef enum OMX_AUDIO_MIDISOUNDBANKTYPE {\n    OMX_AUDIO_MIDISoundBankUnused = 0,           /**< unused/unknown soundbank type */\n    OMX_AUDIO_MIDISoundBankDLS1,                 /**< DLS version 1 */\n    OMX_AUDIO_MIDISoundBankDLS2,                 /**< DLS version 2 */\n    OMX_AUDIO_MIDISoundBankMobileDLSBase,        /**< Mobile DLS, using the base functionality */\n    OMX_AUDIO_MIDISoundBankMobileDLSPlusOptions, /**< Mobile DLS, using the specification-defined optional feature set */\n    OMX_AUDIO_MIDISoundBankKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_AUDIO_MIDISoundBankVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_AUDIO_MIDISoundBankMax = 0x7FFFFFFF\n} OMX_AUDIO_MIDISOUNDBANKTYPE;\n\n\n/** Bank Layout describes how bank MSB & LSB are used in the DLS instrument definitions sound bank \n * @ingroup midi\n */\ntypedef enum OMX_AUDIO_MIDISOUNDBANKLAYOUTTYPE {\n   OMX_AUDIO_MIDISoundBankLayoutUnused = 0,   /**< unused/unknown soundbank type */\n   OMX_AUDIO_MIDISoundBankLayoutGM,           /**< GS layout (based on bank MSB 0x00) */\n   OMX_AUDIO_MIDISoundBankLayoutGM2,          /**< General MIDI 2 layout (using MSB 0x78/0x79, LSB 0x00) */\n   OMX_AUDIO_MIDISoundBankLayoutUser,         /**< Does not conform to any bank numbering standards */\n   OMX_AUDIO_MIDISoundBankLayoutKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n   OMX_AUDIO_MIDISoundBankLayoutVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n   OMX_AUDIO_MIDISoundBankLayoutMax = 0x7FFFFFFF\n} OMX_AUDIO_MIDISOUNDBANKLAYOUTTYPE;\n\n\n/** MIDI params to load/unload user soundbank \n * @ingroup midi\n */\ntypedef struct OMX_AUDIO_PARAM_MIDILOADUSERSOUNDTYPE {\n    OMX_U32 nSize;            /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion; /**< OMX specification version information */\n    OMX_U32 nPortIndex;       /**< port that this structure applies to */\n    OMX_U32 nDLSIndex;        /**< DLS file index to be loaded */\n    OMX_U32 nDLSSize;         /**< Size in bytes */\n    OMX_PTR pDLSData;         /**< Pointer to DLS file data */\n    OMX_AUDIO_MIDISOUNDBANKTYPE eMidiSoundBank;   /**< Midi sound bank type enumeration */\n    OMX_AUDIO_MIDISOUNDBANKLAYOUTTYPE eMidiSoundBankLayout; /**< Midi sound bank layout enumeration */\n} OMX_AUDIO_PARAM_MIDILOADUSERSOUNDTYPE;\n\n\n/** Structure for Live MIDI events and MIP messages. \n * (MIP = Maximum Instantaneous Polyphony; part of the SP-MIDI standard.) \n * @ingroup midi\n */\ntypedef struct OMX_AUDIO_CONFIG_MIDIIMMEDIATEEVENTTYPE {\n    OMX_U32 nSize;            /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion; /**< OMX specification version information */\n    OMX_U32 nPortIndex;       /**< Port that this structure applies to */\n    OMX_U32 nMidiEventSize;   /**< Size of immediate MIDI events or MIP message in bytes  */\n    OMX_U8 nMidiEvents[1];    /**< MIDI event array to be rendered immediately, or an\n                                   array for the MIP message buffer, where the size is \n                                   indicated by nMidiEventSize */\n} OMX_AUDIO_CONFIG_MIDIIMMEDIATEEVENTTYPE;\n\n\n/** MIDI sound bank/ program pair in a given channel \n * @ingroup midi\n */\ntypedef struct OMX_AUDIO_CONFIG_MIDISOUNDBANKPROGRAMTYPE {\n    OMX_U32 nSize;              /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion;   /**< OMX specification version information */\n    OMX_U32 nPortIndex;         /**< Port that this structure applies to */\n    OMX_U32 nChannel;           /**< Valid channel values range from 1 to 16 */\n    OMX_U16 nIDProgram;         /**< Valid program ID range is 1 to 128 */\n    OMX_U16 nIDSoundBank;       /**< Sound bank ID */\n    OMX_U32 nUserSoundBankIndex;/**< User soundbank index, easier to access soundbanks \n                                     by index if multiple banks are present */\n} OMX_AUDIO_CONFIG_MIDISOUNDBANKPROGRAMTYPE;\n\n\n/** MIDI control \n * @ingroup midi\n */\ntypedef struct OMX_AUDIO_CONFIG_MIDICONTROLTYPE {\n    OMX_U32 nSize;                /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion;     /**< OMX specification version information */\n    OMX_U32 nPortIndex;           /**< port that this structure applies to */\n    OMX_BS32 sPitchTransposition; /**< Pitch transposition in semitones, stored as Q22.10 \n                                       format based on JAVA MMAPI (JSR-135) requirement */\n    OMX_BU32 sPlayBackRate;       /**< Relative playback rate, stored as Q14.17 fixed-point\n                                       number based on JSR-135 requirement */\n    OMX_BU32 sTempo ;             /**< Tempo in beats per minute (BPM), stored as Q22.10 \n                                       fixed-point number based on JSR-135 requirement */\n    OMX_U32 nMaxPolyphony;        /**< Specifies the maximum simultaneous polyphonic \n                                       voices. A value of zero indicates that the default \n                                       polyphony of the device is used  */\n    OMX_U32 nNumRepeat;           /**< Number of times to repeat playback */\n    OMX_U32 nStopTime;            /**< Time in milliseconds to indicate when playback \n                                       will stop automatically.  Set to zero if not used */\n    OMX_U16 nChannelMuteMask;     /**< 16 bit mask for channel mute status */\n    OMX_U16 nChannelSoloMask;     /**< 16 bit mask for channel solo status */\n    OMX_U32 nTrack0031MuteMask;   /**< 32 bit mask for track mute status. Note: This is for tracks 0-31 */\n    OMX_U32 nTrack3263MuteMask;   /**< 32 bit mask for track mute status. Note: This is for tracks 32-63 */\n    OMX_U32 nTrack0031SoloMask;   /**< 32 bit mask for track solo status. Note: This is for tracks 0-31 */\n    OMX_U32 nTrack3263SoloMask;   /**< 32 bit mask for track solo status. Note: This is for tracks 32-63 */\n\n} OMX_AUDIO_CONFIG_MIDICONTROLTYPE;\n\n\n/** MIDI Playback States \n * @ingroup midi\n */\ntypedef enum OMX_AUDIO_MIDIPLAYBACKSTATETYPE {\n  OMX_AUDIO_MIDIPlayBackStateUnknown = 0,      /**< Unknown state or state does not map to \n  \t\t\t\t\t\t\t\t\t\t\t\t\tother defined states */\n  OMX_AUDIO_MIDIPlayBackStateClosedEngaged,    /**< No MIDI resource is currently open. \n                                                    The MIDI engine is currently processing \n                                                    MIDI events. */\n  OMX_AUDIO_MIDIPlayBackStateParsing,          /**< A MIDI resource is open and is being \n                                                    primed. The MIDI engine is currently \n                                                    processing MIDI events. */\n  OMX_AUDIO_MIDIPlayBackStateOpenEngaged,      /**< A MIDI resource is open and primed but \n                                                    not playing. The MIDI engine is currently\n                                                    processing MIDI events. The transition to\n                                                    this state is only possible from the \n                                                    OMX_AUDIO_MIDIPlayBackStatePlaying state,\n                                                    when the 'playback head' reaches the end\n                                                    of media data or the playback stops due\n                                                    to stop time set.*/\n  OMX_AUDIO_MIDIPlayBackStatePlaying,          /**< A MIDI resource is open and currently\n                                                    playing. The MIDI engine is currently\n                                                    processing MIDI events.*/\n  OMX_AUDIO_MIDIPlayBackStatePlayingPartially, /**< Best-effort playback due to SP-MIDI/DLS\n                                                    resource constraints */\n  OMX_AUDIO_MIDIPlayBackStatePlayingSilently,  /**< Due to system resource constraints and\n                                                    SP-MIDI content constraints, there is\n                                                    no audible MIDI content during playback\n                                                    currently. The situation may change if\n                                                    resources are freed later.*/\n  OMX_AUDIO_MIDIPlayBackStateKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n  OMX_AUDIO_MIDIPlayBackStateVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n  OMX_AUDIO_MIDIPlayBackStateMax = 0x7FFFFFFF\n} OMX_AUDIO_MIDIPLAYBACKSTATETYPE;\n\n\n/** MIDI status \n * @ingroup midi\n */\ntypedef struct OMX_AUDIO_CONFIG_MIDISTATUSTYPE {\n    OMX_U32 nSize;              /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion;   /**< OMX specification version information */\n    OMX_U32 nPortIndex;         /**< port that this structure applies to */\n    OMX_U16 nNumTracks;         /**< Number of MIDI tracks in the file, read only field. \n                                     NOTE: May not return a meaningful value until the entire \n                                     file is parsed and buffered.  */\n    OMX_U32 nDuration;          /**< The length of the currently open MIDI resource \n                                     in milliseconds. NOTE: May not return a meaningful value \n                                     until the entire file is parsed and buffered.  */  \n    OMX_U32 nPosition;          /**< Current Position of the MIDI resource being played \n                                     in milliseconds */\n    OMX_BOOL bVibra;            /**< Does Vibra track exist? NOTE: May not return a meaningful \n                                     value until the entire file is parsed and buffered. */\n    OMX_U32 nNumMetaEvents;     /**< Total number of MIDI Meta Events in the currently \n                                     open MIDI resource. NOTE: May not return a meaningful value \n                                     until the entire file is parsed and buffered.  */\n    OMX_U32 nNumActiveVoices;   /**< Number of active voices in the currently playing \n                                     MIDI resource. NOTE: May not return a meaningful value until \n                                     the entire file is parsed and buffered. */\n    OMX_AUDIO_MIDIPLAYBACKSTATETYPE eMIDIPlayBackState;  /**< MIDI playback state enumeration, read only field */\n} OMX_AUDIO_CONFIG_MIDISTATUSTYPE;\n\n\n/** MIDI Meta Event structure one per Meta Event.\n *  MIDI Meta Events are like audio metadata, except that they are interspersed \n *  with the MIDI content throughout the file and are not localized in the header. \n *  As such, it is necessary to retrieve information about these Meta Events from \n *  the engine, as it encounters these Meta Events within the MIDI content. \n *  For example, SMF files can have up to 14 types of MIDI Meta Events (copyright, \n *  author, default tempo, etc.) scattered throughout the file. \n *  @ingroup midi\n */\ntypedef struct OMX_AUDIO_CONFIG_MIDIMETAEVENTTYPE{ \n    OMX_U32 nSize;            /**< size of the structure in bytes */ \n    OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ \n    OMX_U32 nPortIndex;       /**< port that this structure applies to */ \n    OMX_U32 nIndex;           /**< Index of Meta Event */ \n    OMX_U8 nMetaEventType;    /**< Meta Event Type, 7bits (i.e. 0 - 127) */ \n    OMX_U32 nMetaEventSize;   /**< size of the Meta Event in bytes */ \n    OMX_U32 nTrack;           /**< track number for the meta event */\n    OMX_U32 nPosition;        /**< Position of the meta-event in milliseconds */\n} OMX_AUDIO_CONFIG_MIDIMETAEVENTTYPE; \n\n\n/** MIDI Meta Event Data structure - one per Meta Event. \n * @ingroup midi\n */ \ntypedef struct OMX_AUDIO_CONFIG_MIDIMETAEVENTDATATYPE{ \n    OMX_U32 nSize;            /**< size of the structure in bytes */ \n    OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ \n    OMX_U32 nPortIndex;       /**< port that this structure applies to */ \n    OMX_U32 nIndex;           /**< Index of Meta Event */ \n    OMX_U32 nMetaEventSize;   /**< size of the Meta Event in bytes */ \n    OMX_U8 nData[1];          /**< array of one or more bytes of meta data \n                                   as indicated by the nMetaEventSize field */ \n} OMX_AUDIO_CONFIG__MIDIMETAEVENTDATATYPE; \n\n\n/** Audio Volume adjustment for a port */\ntypedef struct OMX_AUDIO_CONFIG_VOLUMETYPE {\n    OMX_U32 nSize;              /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion;   /**< OMX specification version information */\n    OMX_U32 nPortIndex;         /**< Port index indicating which port to \n                                     set.  Select the input port to set \n                                     just that port's volume.  Select the \n                                     output port to adjust the master \n                                     volume. */\n    OMX_BOOL bLinear;           /**< Is the volume to be set in linear (0.100) \n                                     or logarithmic scale (mB) */\n    OMX_BS32 sVolume;           /**< Volume linear setting in the 0..100 range, OR\n                                     Volume logarithmic setting for this port.  The values\n                                     for volume are in mB (millibels = 1/100 dB) relative\n                                     to a gain of 1 (e.g. the output is the same as the \n                                     input level).  Values are in mB from nMax \n                                     (maximum volume) to nMin mB (typically negative).\n                                     Since the volume is \"voltage\"\n                                     and not a \"power\", it takes a setting of\n                                     -600 mB to decrease the volume by 1/2.  If\n                                     a component cannot accurately set the \n                                     volume to the requested value, it must\n                                     set the volume to the closest value BELOW\n                                     the requested value.  When getting the\n                                     volume setting, the current actual volume\n                                     must be returned. */\n} OMX_AUDIO_CONFIG_VOLUMETYPE;\n\n\n/** Audio Volume adjustment for a channel */\ntypedef struct OMX_AUDIO_CONFIG_CHANNELVOLUMETYPE {\n    OMX_U32 nSize;              /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion;   /**< OMX specification version information */\n    OMX_U32 nPortIndex;         /**< Port index indicating which port to \n                                     set.  Select the input port to set \n                                     just that port's volume.  Select the \n                                     output port to adjust the master \n                                     volume. */\n    OMX_U32 nChannel;           /**< channel to select from 0 to N-1, \n                                     using OMX_ALL to apply volume settings\n                                     to all channels */\n    OMX_BOOL bLinear;           /**< Is the volume to be set in linear (0.100) or \n                                     logarithmic scale (mB) */\n    OMX_BS32 sVolume;           /**< Volume linear setting in the 0..100 range, OR\n                                     Volume logarithmic setting for this port.  \n                                     The values for volume are in mB \n                                     (millibels = 1/100 dB) relative to a gain\n                                     of 1 (e.g. the output is the same as the \n                                     input level).  Values are in mB from nMax \n                                     (maximum volume) to nMin mB (typically negative).  \n                                     Since the volume is \"voltage\"\n                                     and not a \"power\", it takes a setting of\n                                     -600 mB to decrease the volume by 1/2.  If\n                                     a component cannot accurately set the \n                                     volume to the requested value, it must\n                                     set the volume to the closest value BELOW\n                                     the requested value.  When getting the\n                                     volume setting, the current actual volume\n                                     must be returned. */\n    OMX_BOOL bIsMIDI;           /**< TRUE if nChannel refers to a MIDI channel,\n                                     FALSE otherwise */\n} OMX_AUDIO_CONFIG_CHANNELVOLUMETYPE;\n\n\n/** Audio balance setting */\ntypedef struct OMX_AUDIO_CONFIG_BALANCETYPE {\n    OMX_U32 nSize;              /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion;   /**< OMX specification version information */\n    OMX_U32 nPortIndex;         /**< Port index indicating which port to \n                                     set.  Select the input port to set \n                                     just that port's balance.  Select the \n                                     output port to adjust the master \n                                     balance. */\n    OMX_S32 nBalance;           /**< balance setting for this port \n                                     (-100 to 100, where -100 indicates\n                                     all left, and no right */\n} OMX_AUDIO_CONFIG_BALANCETYPE;\n\n\n/** Audio Port mute */\ntypedef struct OMX_AUDIO_CONFIG_MUTETYPE {\n    OMX_U32 nSize;              /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion;   /**< OMX specification version information */\n    OMX_U32 nPortIndex;         /**< Port index indicating which port to \n                                     set.  Select the input port to set \n                                     just that port's mute.  Select the \n                                     output port to adjust the master \n                                     mute. */\n    OMX_BOOL bMute;             /**< Mute setting for this port */\n} OMX_AUDIO_CONFIG_MUTETYPE;\n\n\n/** Audio Channel mute */\ntypedef struct OMX_AUDIO_CONFIG_CHANNELMUTETYPE {\n    OMX_U32 nSize;              /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion;   /**< OMX specification version information */\n    OMX_U32 nPortIndex;         /**< port that this structure applies to */\n    OMX_U32 nChannel;           /**< channel to select from 0 to N-1, \n                                     using OMX_ALL to apply mute settings\n                                     to all channels */\n    OMX_BOOL bMute;             /**< Mute setting for this channel */\n    OMX_BOOL bIsMIDI;           /**< TRUE if nChannel refers to a MIDI channel,\n                                     FALSE otherwise */ \n} OMX_AUDIO_CONFIG_CHANNELMUTETYPE;\n\n\n\n/** Enable / Disable for loudness control, which boosts bass and to a \n *  smaller extent high end frequencies to compensate for hearing\n *  ability at the extreme ends of the audio spectrum\n */ \ntypedef struct OMX_AUDIO_CONFIG_LOUDNESSTYPE {\n    OMX_U32 nSize;             /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion;  /**< OMX specification version information */\n    OMX_U32 nPortIndex;        /**< port that this structure applies to */\n    OMX_BOOL bLoudness;        /**< Enable/disable for loudness */\n} OMX_AUDIO_CONFIG_LOUDNESSTYPE;\n\n\n/** Enable / Disable for bass, which controls low frequencies\n */ \ntypedef struct OMX_AUDIO_CONFIG_BASSTYPE {\n    OMX_U32 nSize;             /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion;  /**< OMX specification version information */\n    OMX_U32 nPortIndex;        /**< port that this structure applies to */\n    OMX_BOOL bEnable;          /**< Enable/disable for bass control */\n    OMX_S32 nBass;             /**< bass setting for the port, as a \n                                    continuous value from -100 to 100  \n                                    (0 means no change in bass level)*/\n} OMX_AUDIO_CONFIG_BASSTYPE;\n\n\n/** Enable / Disable for treble, which controls high frequencies tones\n */ \ntypedef struct OMX_AUDIO_CONFIG_TREBLETYPE {\n    OMX_U32 nSize;             /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion;  /**< OMX specification version information */\n    OMX_U32 nPortIndex;        /**< port that this structure applies to */\n    OMX_BOOL bEnable;          /**< Enable/disable for treble control */\n    OMX_S32  nTreble;          /**< treble setting for the port, as a\n                                    continuous value from -100 to 100  \n                                    (0 means no change in treble level) */\n} OMX_AUDIO_CONFIG_TREBLETYPE;\n\n\n/** An equalizer is typically used for two reasons: to compensate for an \n *  sub-optimal frequency response of a system to make it sound more natural \n *  or to create intentionally some unnatural coloring to the sound to create\n *  an effect.\n *  @ingroup effects\n */\ntypedef struct OMX_AUDIO_CONFIG_EQUALIZERTYPE {\n    OMX_U32 nSize;             /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion;  /**< OMX specification version information */\n    OMX_U32 nPortIndex;        /**< port that this structure applies to */\n    OMX_BOOL bEnable;          /**< Enable/disable for equalizer */\n    OMX_BU32 sBandIndex;       /**< Band number to be set.  Upper Limit is \n                                    N-1, where N is the number of bands, lower limit is 0 */\n    OMX_BU32 sCenterFreq;      /**< Center frequecies in Hz.  This is a\n                                    read only element and is used to determine \n                                    the lower, center and upper frequency of \n                                    this band.  */\n    OMX_BS32 sBandLevel;       /**< band level in millibels */\n} OMX_AUDIO_CONFIG_EQUALIZERTYPE;\n\n\n/** Stereo widening mode type \n * @ingroup effects\n */ \ntypedef enum OMX_AUDIO_STEREOWIDENINGTYPE {\n    OMX_AUDIO_StereoWideningHeadphones,    /**< Stereo widening for loudspeakers */\n    OMX_AUDIO_StereoWideningLoudspeakers,  /**< Stereo widening for closely spaced loudspeakers */\n    OMX_AUDIO_StereoWideningKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_AUDIO_StereoWideningVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_AUDIO_StereoWideningMax = 0x7FFFFFFF\n} OMX_AUDIO_STEREOWIDENINGTYPE;\n\n\n/** Control for stereo widening, which is a special 2-channel\n *  case of the audio virtualizer effect. For example, for 5.1-channel \n *  output, it translates to virtual surround sound. \n * @ingroup effects\n */ \ntypedef struct OMX_AUDIO_CONFIG_STEREOWIDENINGTYPE {\n    OMX_U32 nSize;             /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion;  /**< OMX specification version information */\n    OMX_U32 nPortIndex;        /**< port that this structure applies to */\n    OMX_BOOL bEnable;          /**< Enable/disable for stereo widening control */\n    OMX_AUDIO_STEREOWIDENINGTYPE eWideningType; /**< Stereo widening algorithm type */\n    OMX_U32  nStereoWidening;  /**< stereo widening setting for the port,\n                                    as a continuous value from 0 to 100  */\n} OMX_AUDIO_CONFIG_STEREOWIDENINGTYPE;\n\n\n/** The chorus effect (or ``choralizer'') is any signal processor which makes\n *  one sound source (such as a voice) sound like many such sources singing \n *  (or playing) in unison. Since performance in unison is never exact, chorus \n *  effects simulate this by making independently modified copies of the input \n *  signal. Modifications may include (1) delay, (2) frequency shift, and \n *  (3) amplitude modulation.\n * @ingroup effects\n */\ntypedef struct OMX_AUDIO_CONFIG_CHORUSTYPE {\n    OMX_U32 nSize;             /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion;  /**< OMX specification version information */\n    OMX_U32 nPortIndex;        /**< port that this structure applies to */\n    OMX_BOOL bEnable;          /**< Enable/disable for chorus */\n    OMX_BU32 sDelay;           /**< average delay in milliseconds */\n    OMX_BU32 sModulationRate;  /**< rate of modulation in millihertz */\n    OMX_U32 nModulationDepth;  /**< depth of modulation as a percentage of \n                                    delay (i.e. 0 to 100) */\n    OMX_BU32 nFeedback;        /**< Feedback from chorus output to input in percentage */\n} OMX_AUDIO_CONFIG_CHORUSTYPE;\n\n\n/** Reverberation is part of the reflected sound that follows the early \n *  reflections. In a typical room, this consists of a dense succession of \n *  echoes whose energy decays exponentially. The reverberation effect structure \n *  as defined here includes both (early) reflections as well as (late) reverberations. \n * @ingroup effects\n */\ntypedef struct OMX_AUDIO_CONFIG_REVERBERATIONTYPE {\n    OMX_U32 nSize;                /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion;     /**< OMX specification version information */\n    OMX_U32 nPortIndex;           /**< port that this structure applies to */\n    OMX_BOOL bEnable;             /**< Enable/disable for reverberation control */\n    OMX_BS32 sRoomLevel;          /**< Intensity level for the whole room effect \n                                       (i.e. both early reflections and late \n                                       reverberation) in millibels */\n    OMX_BS32 sRoomHighFreqLevel;  /**< Attenuation at high frequencies\n                                       relative to the intensity at low\n                                       frequencies in millibels */\n    OMX_BS32 sReflectionsLevel;   /**< Intensity level of early reflections\n                                       (relative to room value), in millibels */\n    OMX_BU32 sReflectionsDelay;   /**< Delay time of the first reflection relative \n                                       to the direct path, in milliseconds */\n    OMX_BS32 sReverbLevel;        /**< Intensity level of late reverberation\n                                       relative to room level, in millibels */\n    OMX_BU32 sReverbDelay;        /**< Time delay from the first early reflection \n                                       to the beginning of the late reverberation \n                                       section, in milliseconds */\n    OMX_BU32 sDecayTime;          /**< Late reverberation decay time at low\n                                       frequencies, in milliseconds */\n    OMX_BU32 nDecayHighFreqRatio; /**< Ratio of high frequency decay time relative \n                                       to low frequency decay time in percent  */\n    OMX_U32 nDensity;             /**< Modal density in the late reverberation decay,\n                                       in percent (i.e. 0 - 100) */\n    OMX_U32 nDiffusion;           /**< Echo density in the late reverberation decay,\n                                       in percent (i.e. 0 - 100) */\n    OMX_BU32 sReferenceHighFreq;  /**< Reference high frequency in Hertz. This is \n                                       the frequency used as the reference for all \n                                       the high-frequency settings above */\n\n} OMX_AUDIO_CONFIG_REVERBERATIONTYPE;\n\n\n/** Possible settings for the Echo Cancelation structure to use \n * @ingroup effects\n */\ntypedef enum OMX_AUDIO_ECHOCANTYPE {\n   OMX_AUDIO_EchoCanOff = 0,    /**< Echo Cancellation is disabled */\n   OMX_AUDIO_EchoCanNormal,     /**< Echo Cancellation normal operation - \n                                     echo from plastics and face */\n   OMX_AUDIO_EchoCanHFree,      /**< Echo Cancellation optimized for \n                                     Hands Free operation */\n   OMX_AUDIO_EchoCanCarKit,    /**< Echo Cancellation optimized for \n                                     Car Kit (longer echo) */\n   OMX_AUDIO_EchoCanKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n   OMX_AUDIO_EchoCanVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n   OMX_AUDIO_EchoCanMax = 0x7FFFFFFF\n} OMX_AUDIO_ECHOCANTYPE;\n\n\n/** Enable / Disable for echo cancelation, which removes undesired echo's\n *  from the audio\n * @ingroup effects\n */ \ntypedef struct OMX_AUDIO_CONFIG_ECHOCANCELATIONTYPE {\n    OMX_U32 nSize;             /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion;  /**< OMX specification version information */\n    OMX_U32 nPortIndex;        /**< port that this structure applies to */\n    OMX_AUDIO_ECHOCANTYPE eEchoCancelation; /**< Echo cancelation settings */\n} OMX_AUDIO_CONFIG_ECHOCANCELATIONTYPE;\n\n\n/** Enable / Disable for noise reduction, which undesired noise from\n * the audio\n * @ingroup effects\n */ \ntypedef struct OMX_AUDIO_CONFIG_NOISEREDUCTIONTYPE {\n    OMX_U32 nSize;             /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion;  /**< OMX specification version information */\n    OMX_U32 nPortIndex;        /**< port that this structure applies to */\n    OMX_BOOL bNoiseReduction;  /**< Enable/disable for noise reduction */\n} OMX_AUDIO_CONFIG_NOISEREDUCTIONTYPE;\n\n/** @} */\n\n#ifdef __cplusplus\n}\n#endif /* __cplusplus */\n\n#endif\n/* File EOF */\n\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/IL/OMX_Broadcom.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n// OpenMAX IL - Broadcom specific types\n\n#ifndef OMX_Broadcom_h\n#define OMX_Broadcom_h\n\n#include \"OMX_Component.h\"\n\n// for use in buffer headers - marks the contained data\n// as being a codec header\n#define OMX_BUFFERFLAG_TIME_UNKNOWN 0x00000100\n\n//for use in buffer headers - marks the buffer as being the\n//snapshot preview image from a still capture.\n//Mainly to be used with the DisplayFunction callback from camera.\n#define OMX_BUFFERFLAG_CAPTURE_PREVIEW 0x00000200\n\n/* Mark the end of a NAL unit produced by a video encoder.\n */\n#define OMX_BUFFERFLAG_ENDOFNAL    0x00000400\n\n/* Marks pBuffer in OMX_BUFFERHEADERTYPE as containing a fragment list instead of the actual buffer\n */\n#define OMX_BUFFERFLAG_FRAGMENTLIST 0x00000800\n\n/* Marks the start of a new sequence of data following any kind of seek operation.\n */\n#define OMX_BUFFERFLAG_DISCONTINUITY 0x00001000\n\n/** Codec side information Flag:\n* OMX_BUFFERFLAG_CODECSIDEINFO is an optional flag that is set by an\n* output port when all bytes in the buffer form part or all of a set of\n* codec specific side information. For example, distortion information\n* estimated by H.264 encoder can be sent using this flag to signal\n* the decoder quality\n*/\n#define OMX_BUFFERFLAG_CODECSIDEINFO 0x00002000\n\n// for use in buffer headers - indicated the timestamp is a DTS rather than PTS\n#define OMX_BUFFERFLAG_TIME_IS_DTS 0x000004000\n\n// for use in buffer headers - signals that a video picture is interlaced\n#define OMX_BUFFERFLAG_INTERLACED 0x000010000\n\n// Signals that the top field of the current interlaced frame should be displayed first\n#define OMX_BUFFERFLAG_TOP_FIELD_FIRST 0x000020000\n\n/**\n * Macros to convert to <code>OMX_TICKS</code> from a signed 64 bit value and\n * vice-versa. These macros don't actually do anything unless <code>OMX_TICKS</code>\n * is defined as a two-part structure (instead of a native signed 64-bit type).\n **/\n#ifndef OMX_SKIP64BIT\n   #define omx_ticks_from_s64(s) (s)\n   #define omx_ticks_to_s64(t) (t)\n#else\n   static inline OMX_TICKS omx_ticks_from_s64(signed long long s) { OMX_TICKS t; t.nLowPart = (OMX_U32)s; t.nHighPart = (OMX_U32)(s>>32); return t; }\n   #define omx_ticks_to_s64(t) ((t).nLowPart | ((uint64_t)((t).nHighPart) << 32))\n#endif /* OMX_SKIP64BIT */\n\n/* Buffer fragment descriptor */\ntypedef struct OMX_BUFFERFRAGMENTTYPE {\n   OMX_PTR pBuffer; /**< Pointer to actual block of memory that is acting as the fragment buffer */\n   OMX_U32 nLen;    /**< number of bytes in the buffer */\n} OMX_BUFFERFRAGMENTTYPE;\n\n/* OMX_IndexParamBrcmEnableIJGTableScaling: JPEG Quality Table Setting. */\ntypedef struct OMX_PARAM_IJGSCALINGTYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nPortIndex;\n   OMX_BOOL bEnabled;\n} OMX_PARAM_IJGSCALINGTYPE;\n/*\nThe boolean \\code{bEnabled} value determines whether the component uses\nthe standard IJG quality tables when encoding images.\n*/\n\n\n/* OMX_IndexConfigTimeInvalidStartTime: Invalid Start Times */\n/*\nThis allows clock clients to supply a start time notification to the\nclock whilst indicating that this time is invalid.\n*/\n\n/* OMX_IndexParamBrcmMaxFrameSkips: Frame timestamp jumps */\n/*\nThis number represents the number of times a jump in frame timestamps\nhas been observed that is greater than expected.\n*/\n\n/* OMX_IndexConfigAsynchronousFailureURI: Asynchronous Failure Filename */\n/*\nThis allows the client to query for the filename that cause an asynchronous\noutput error.\n*/\n\n/* OMX_IndexParamAsynchronousOutput: Asynchronous Output */\n/*\nThe allows the client to specify to a component that is writing files\nthat this writing may happen asynchronously, including opening and closing\nof files.\n*/\n\n/* OMX_IndexConfigClockAdjustment: Clock Adjustment */\n/*\nThis allows the client to read from the clock the total time\nadjustment made to the clock whilst running by the reference clock.\nIf the reference clock sends a time that causes the media time to jump\nthis difference is added to the total, which can be reported via this\nindex.  When the stream restarts by setting the clock state to\n\\code{OMX_TIME_ClockStateRunning} or\n\\code{OMX_TIME_ClockStateWaitingForStartTime} this adjustment total is\nset to zero.\n*/\n\n/* OMX_IndexParamBrcmDataUnit: Data Unit */\n/*\nThe data unit is an indication to components connected to this\ncomponent of the type of data delivery available.\n\\code{OMX_DataUnitCodedPicture} indicates that we are able to give\nframing information, using the \\code{OMX_BUFFERFLAG_ENDOFFRAME} flag to\nindicate that the data contained finishes a complete\nframe. \\code{OMX_DataUnitArbitraryStreamSection} indicates that no\nend-of-frame markers will be present, and the decoder should perform\nthe steps necessary to decode the stream. The other enum values are\nnot used.\n*/\n\n/* OMX_IndexConfigPresentationOffset: Presentation Offset */\n/*\nThe value of \\code{nTimestamp} is added to the offset requested for\neach new input frame. Takes effect for all new input frames, and has\nno effect on the offset used for currently-queued frames. A positive\nvalue will make the requested port earlier relative to other streams,\na negative value will make the requested port later relative to other\nstreams.\n*/\n\n/* OMX_IndexConfigSingleStep: Single Step */\n/*\nWhen setting this config on a paused clock, where the \\code{nU32}\nvalue is non-zero and \\code{nPortIndex} is OMX_ALL, the media clock\nwill advance through the next \\code{nU32} next requested media\ntimes. A paused clock is in running state but has a time scale of\n0. This will trigger the display of some video frames, so allowing\nsingle-stepping functionality. This config can be set multiple times,\nand will buffer up stepping requests until we have media requests to\nfulfil, or the clock is stopped or un-paused.\n\nThis config can also be used on some video output ports and, if\n\\code{nU32} is non-zero, requests that the output port forwards the\nnext \\code{nU32} frames appending an EOS marker on the last frame, and\nthen ceases to forward data on this port.  If \\code{nU32} is zero, any\nprevious request to forward a limited number of frames is cancelled\nand the default behaviour of this port will resume.\n*/\n\n/* OMX_IndexParamCameraCamplusId: Camera Subsystem Identification */\n/*\nThis parameter allows the configuration of the identifier to be used\nto initialise the Broadcom Camplus subsystem that sits beneath the\ncamera component. If only one instance of the camera component is\nused, the default value can be used. If more than one instance is\nrequired, they must each have their own unique values for this\nparameter. It is also used to tie the component to the image pool\ncreated with \\code{OMX_Set upCamPools}.\n*/\n\n/* OMX_IndexConfigAudioRenderingLatency: Audio Rendering Latency */\n/*\nThis config allows the client to query the current latency of audio\nrendering.  The latency is returned as the number of samples that\nan audio rendering component has received but have not been played.\n*/\n\n/* OMX_IndexConfigBrcmPoolMemAllocSize: Pool memory usage values */\n/*\nThis config allows the client to query how much memory is being used by\nthe component for any image pools. \n*/\n\n/* OMX_IndexConfigDisplayRegion: Display Region */\ntypedef enum OMX_DISPLAYTRANSFORMTYPE{\n   OMX_DISPLAY_ROT0 = 0,\n   OMX_DISPLAY_MIRROR_ROT0 = 1,\n   OMX_DISPLAY_MIRROR_ROT180 = 2,\n   OMX_DISPLAY_ROT180 = 3,\n   OMX_DISPLAY_MIRROR_ROT90 = 4,\n   OMX_DISPLAY_ROT270 = 5,\n   OMX_DISPLAY_ROT90 = 6,\n   OMX_DISPLAY_MIRROR_ROT270 = 7,\n   OMX_DISPLAY_DUMMY = 0x7FFFFFFF\n} OMX_DISPLAYTRANSFORMTYPE;\n\ntypedef struct OMX_DISPLAYRECTTYPE {\n   OMX_S16 x_offset;\n   OMX_S16 y_offset;\n   OMX_S16 width;\n   OMX_S16 height;\n} OMX_DISPLAYRECTTYPE;\n\ntypedef enum OMX_DISPLAYMODETYPE {\n   OMX_DISPLAY_MODE_FILL = 0,\n   OMX_DISPLAY_MODE_LETTERBOX = 1,\n   // these allow a left eye source->dest to be specified and the right eye mapping will be inferred by symmetry\n   OMX_DISPLAY_MODE_STEREO_LEFT_TO_LEFT = 2,\n   OMX_DISPLAY_MODE_STEREO_TOP_TO_TOP = 3,\n   OMX_DISPLAY_MODE_STEREO_LEFT_TO_TOP = 4,\n   OMX_DISPLAY_MODE_STEREO_TOP_TO_LEFT = 5,\n   OMX_DISPLAY_MODE_DUMMY = 0x7FFFFFFF\n} OMX_DISPLAYMODETYPE;\n\ntypedef enum OMX_DISPLAYSETTYPE {\n   OMX_DISPLAY_SET_NONE = 0,\n   OMX_DISPLAY_SET_NUM = 1,\n   OMX_DISPLAY_SET_FULLSCREEN = 2,\n   OMX_DISPLAY_SET_TRANSFORM = 4,\n   OMX_DISPLAY_SET_DEST_RECT = 8,\n   OMX_DISPLAY_SET_SRC_RECT = 0x10,\n   OMX_DISPLAY_SET_MODE = 0x20,\n   OMX_DISPLAY_SET_PIXEL = 0x40,\n   OMX_DISPLAY_SET_NOASPECT = 0x80,\n   OMX_DISPLAY_SET_LAYER = 0x100,\n   OMX_DISPLAY_SET_COPYPROTECT = 0x200,\n   OMX_DISPLAY_SET_ALPHA = 0x400,\n   OMX_DISPLAY_SET_DUMMY = 0x7FFFFFFF\n} OMX_DISPLAYSETTYPE;\n\ntypedef struct OMX_CONFIG_DISPLAYREGIONTYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nPortIndex;\n   OMX_DISPLAYSETTYPE set;\n   OMX_U32 num;\n   OMX_BOOL fullscreen;\n   OMX_DISPLAYTRANSFORMTYPE transform;\n   OMX_DISPLAYRECTTYPE dest_rect;\n   OMX_DISPLAYRECTTYPE src_rect;\n   OMX_BOOL noaspect;\n   OMX_DISPLAYMODETYPE mode;\n   OMX_U32 pixel_x;\n   OMX_U32 pixel_y;\n   OMX_S32 layer;\n   OMX_BOOL copyprotect_required;\n   OMX_U32 alpha;\n   OMX_U32 wfc_context_width;\n   OMX_U32 wfc_context_height;\n} OMX_CONFIG_DISPLAYREGIONTYPE;\n/*\nThis config sets the output display device, as well as the region used\non the output display, any display transformation, and some flags to\nindicate how to scale the image.\n\nThe structure uses a bitfield, \\code{set}, to indicate which fields are set\nand should be used. All other fields will maintain their current\nvalue.\n\n\\code{num} describes the display output device, with 0 typically being\na directly connected LCD display.\n\n\\code{fullscreen} indicates that we are using the full device screen\narea, rather than a window of the display.  If fullscreen is false,\nthen dest_rect is used to specify a region of the display to use.\n\n\\code{transform} indicates any rotation or flipping used to map frames\nonto the natural display orientation.\n\nThe \\code{src_rect} indicates which area of the frame to display. If\nall values are zero, the whole frame will be used.\n\nThe \\code{noaspect} flag, if set, indicates that any display scaling\nshould disregard the aspect ratio of the frame region being displayed.\n\n\\code{mode} indicates how the image should be scaled to fit the\ndisplay. \\code{OMX_DISPLAY_MODE_FILL} indicates that the image should\nfill the screen by potentially cropping the frames.  Setting\n\\code{mode} to \\code{OMX_DISPLAY_MODE_LETTERBOX} indicates that all\nthe source region should be displayed and black bars added if\nnecessary.\n\nThe \\code{pixel_x} and \\code{pixel_y} values, if non-zero, are used to\ndescribe the size of a source pixel. If values are zero, then pixels\ndefault to being square.\n\nSet the \\code{layer} that the image will appear on with the\n\\code{layer} field.\n*/\n\n\n\n/* OMX_IndexParamSource: Source Image Configuration */\ntypedef enum OMX_SOURCETYPE {\n   OMX_SOURCE_WHITE = 0,    // all white images\n   OMX_SOURCE_BLACK = 1,    // all black images\n   OMX_SOURCE_DIAGONAL = 2, // greyscale diagonal stripes\n   OMX_SOURCE_NOISE = 3,    // random pixel values\n   OMX_SOURCE_RANDOM = 4,   // a shaded random pattern of colours\n   OMX_SOURCE_COLOUR = 5,   // a solid colour determined by nParam\n   OMX_SOURCE_BLOCKS = 6,   // random coloured blocks of 16x16 size\n   OMX_SOURCE_SWIRLY,       // a swirly pattern used for encode testing\n   OMX_SOURCE_DUMMY = 0x7FFFFFFF\n} OMX_SOURCETYPE;\n\ntypedef struct OMX_PARAM_SOURCETYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nPortIndex;\n   OMX_SOURCETYPE eType;\n   OMX_U32 nParam;\n   OMX_U32 nFrameCount;\n   OMX_U32 xFrameRate;\n} OMX_PARAM_SOURCETYPE;\n/*\nThe source type determines the kind of image that is produced. Not all\ncombinations of source type and image type are supported.  The\n\\code{OMX_SOURCE_SWIRLY} setting can only be used with YUV420 packed\nplanar image formats.  When producing RGB565 image format, the\n\\code{OMX_SOURCE_DIAGONAL} and \\code{OMX_SOURCE_RANDOM} modes are\ntreated as \\code{OMX_SOURCE_NOISE}.\n\nThe \\code{nParam} field is used to specify the colour for the source\ncolour mode, and the offset of the diagonal pattern for diagonal mode.\nFor the blocks mode, \\code{nParam} is used as the seed for the random\ncolour generator.\n\nThe \\code{nFrameCount} parameter determines how many frames to send.\nIf it is zero, then frames are sent continuously. For any other value,\nit counts down until it has sent that many frames, and then stops,\nsending out an EOS. The \\code{xFrameRate} setting is used to determine\nthe timestamp for each frame produced, or can be set to zero if\ntimestamps should all remain at zero.\n*/\n\n/* OMX_IndexParamSourceSeed: Source Random Seed */\ntypedef struct OMX_PARAM_SOURCESEEDTYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nPortIndex;\n   OMX_U16 nData[16];\n} OMX_PARAM_SOURCESEEDTYPE;\n/*\nThis structure sets the current state of the random number generator\nused for \\code{OMX_SOURCE_RANDOM} source type, allowing repeatable\nrandom image creation.\n*/\n\n/* OMX_IndexParamResize: Resize Control */\ntypedef enum OMX_RESIZEMODETYPE {\n   OMX_RESIZE_NONE,\n   OMX_RESIZE_CROP,\n   OMX_RESIZE_BOX,\n   OMX_RESIZE_BYTES,\n   OMX_RESIZE_DUMMY = 0x7FFFFFFF\n} OMX_RESIZEMODETYPE;\n\ntypedef struct OMX_PARAM_RESIZETYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nPortIndex;\n   OMX_RESIZEMODETYPE eMode;\n   OMX_U32 nMaxWidth;\n   OMX_U32 nMaxHeight;\n   OMX_U32 nMaxBytes;\n   OMX_BOOL bPreserveAspectRatio;\n   OMX_BOOL bAllowUpscaling;\n} OMX_PARAM_RESIZETYPE;\n/*\nThe mode determines the kind of resize. \\code{OMX_RESIZE_BOX} allow\nthe \\code{nMaxWidth} and \\code{nMaxHeight} to set a bounding box into\nwhich the output must fit. \\code{OMX_RESIZE_BYTES} allows\n\\code{nMaxBytes} to set the maximum number of bytes into which the\nfull output frame must fit.  Two flags aid the setting of the output\nsize. \\code{bPreseveAspectRatio} sets whether the resize should\npreserve the aspect ratio of the incoming\nimage. \\code{bAllowUpscaling} sets whether the resize is allowed to\nincrease the size of the output image compared to the size of the\ninput image.\n*/\n\ntypedef struct OMX_PARAM_TESTINTERFACETYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_BOOL bTest;\n   OMX_BOOL bSetExtra;\n   OMX_U32 nExtra;\n   OMX_BOOL bSetError;\n   OMX_BOOL stateError[2];\n} OMX_PARAM_TESTINTERFACETYPE;\n\n/* OMX_IndexConfigVisualisation: Visualisation Mode */\ntypedef struct OMX_CONFIG_VISUALISATIONTYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nPortIndex;\n   OMX_U8 name[16];\n   OMX_U8 property[64];\n} OMX_CONFIG_VISUALISATIONTYPE;\n\n/*\n\\code{name} is a string of characters specifying the type of\nvisualization. The component appends \\code{\"_vis.vll\"} to the name\nprovided, and attempts to load a visualisation library contained in\nthis VLL.  \\code{property} contains configuration parameters and\nvalues, which is interpreted by the visualisation library. Typically\nall visualisations will accept a property string containing\n\\code{'mode=<number>'}, where \\code{<number>} may be a random 32 bit\ninteger in decimal format. If provided, this may select a random mode\nfrom that visualisation library.\n*/\n\n/*\nThis parameter is used when creating proprietary communication with\nthe display component, and provides the display function for passing\nimages to be displayed, together with a function used to flush all\npending image updates and release all images.\n*/\n\n/* OMX_IndexConfigBrcmAudioDestination: Audio Destination */\ntypedef struct OMX_CONFIG_BRCMAUDIODESTINATIONTYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U8 sName[16];\n} OMX_CONFIG_BRCMAUDIODESTINATIONTYPE;\n/*\nThis config sets the platform-specific audio destination or output\ndevice for audio sink components (e.g. audio_render).\n\n\\code{sName} describes the audio destination, with \\code{\"local\"}\ntypically being directly connected to headphones.\n*/\n\n/* OMX_IndexConfigBrcmAudioSource: Audio Source */\ntypedef struct OMX_CONFIG_BRCMAUDIOSOURCETYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U8 sName[16];\n} OMX_CONFIG_BRCMAUDIOSOURCETYPE;\n/*\nThis config sets the platform-specific audio source or input device\nfor audio source components (e.g. audio_capture).\n\n\\code{sName} describes the audio source, with \\code{\"local\"}\ntypically being directly connected to microphone.\n*/\n\n/* OMX_IndexConfigBrcmAudioDownmixCoefficients: Audio Downmix Coefficients */\ntypedef struct OMX_CONFIG_BRCMAUDIODOWNMIXCOEFFICIENTS {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nPortIndex;\n   OMX_U32 coeff[16];\n} OMX_CONFIG_BRCMAUDIODOWNMIXCOEFFICIENTS;\n/*\nThis config sets the platform-specific audio downmixing coefficients for the \naudio mixer component. The coefficients are 16.16 fixed point.\nThe even coefficients contribute to the left channel. \nThe odd coefficients contribute to the right channel. \nL' = coeff[0] * sample[N] + coeff[2] * sample[N+1] + coeff[4] * sample[N+2] + coeff[6] * sample[N+3] \n   + coeff[8] * sample[N+4] + coeff[10] * sample[N+5] + coeff[12] * sample[N+6] + coeff[14] * sample[N+7]\nR' = coeff[1] * sample[N] + coeff[3] * sample[N+1] + coeff[5] * sample[N+2] + coeff[7] * sample[N+3] \n   + coeff[9] * sample[N+4] + coeff[11] * sample[N+5] + coeff[13] * sample[N+6] + coeff[15] * sample[N+7]\n\n\\code{coeff} describes the downmixing coefficients\n*/\n\n/* OMX_IndexConfigBrcmAudioDownmixCoefficients8x8: Audio Downmix Coefficient matrix */\ntypedef struct OMX_CONFIG_BRCMAUDIODOWNMIXCOEFFICIENTS8x8 {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nPortIndex;\n   OMX_U32 coeff[64];\n} OMX_CONFIG_BRCMAUDIODOWNMIXCOEFFICIENTS8x8;\n/*\nThis config sets the platform-specific audio downmixing coefficients for the \naudio mixer component. The coefficients are 16.16 fixed point.\nThe coefficients are a 8*8 mixing matrix from 8 input channels to 8 outputs channels\n\n\\code{coeff} describes the downmixing coefficients\n*/\n\n/* OMX_IndexConfigBrcmAudioMaxSample: Maximum sample seen */\ntypedef struct OMX_CONFIG_BRCMAUDIOMAXSAMPLE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nPortIndex;\n   OMX_U32 nMaxSample;\n   OMX_TICKS nTimeStamp;\n} OMX_CONFIG_BRCMAUDIOMAXSAMPLE;\n/*\nThis gets the largest sample produced (after downmixing with OMX_CONFIG_BRCMAUDIODOWNMIXCOEFFICIENTS8x8) \nsince this config was last read. The nTimestamp is the earliest timestamp processed. \nThis can be used for DRC schemes \n\n\\code{coeff} maximum sample seen in current block\n*/\n\n/* OMX_IndexConfigPlayMode: Play Mode */\ntypedef enum OMX_PLAYMODETYPE {\n   OMX_PLAYMODE_NORMAL,\n   OMX_PLAYMODE_FF,\n   OMX_PLAYMODE_REW,\n   OMX_PLAYMODE_DUMMY = 0x7FFFFFFF\n} OMX_PLAYMODETYPE;\n\ntypedef struct OMX_CONFIG_PLAYMODETYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_PLAYMODETYPE eMode;\n} OMX_CONFIG_PLAYMODETYPE;\n/*\nThe playmode affects which frames are extracted from the media file\nand passed on the output ports. \\code{OMX_PLAYMODE_NORMAL} will\nextract all frames, \\code{OMX_PLAYMODE_FF} extracts only IDR frames\nwhen video is present, or only occasional packets of audio if no video\nis present. \\code{OMX_PLAYMODE_REW} is similar to\n\\code{OMX_PLAYMODE_FF} but extracts packets in reverse time\norder.\n*/\n\ntypedef enum OMX_DELIVERYFORMATTYPE {\n   OMX_DELIVERYFORMAT_STREAM,         // no framing information is known\n   OMX_DELIVERYFORMAT_SINGLE_PACKET,  // packetised, at most one frame per buffer\n   OMX_DELIVERYFORMAT_DUMMY = 0x7FFFFFFF\n} OMX_DELIVERYFORMATTYPE;\n\ntypedef struct OMX_PARAM_DELIVERYFORMATTYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nPortIndex;\n   OMX_DELIVERYFORMATTYPE eFormat;\n} OMX_PARAM_DELIVERYFORMATTYPE;\n\n/* OMX_IndexParamCodecConfig: Codec Configuration */\n\ntypedef struct OMX_PARAM_CODECCONFIGTYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nPortIndex;\n   OMX_U32 bCodecConfigIsComplete;\n   OMX_U8 nData[1];\n} OMX_PARAM_CODECCONFIGTYPE;\n\n/*\nThis parameter contains opaque data in a format specified by Broadcom\nand allows out-of-band information such as cropping rectangles, aspect\nratio information, codec-specific header bytes, and other essential\ninformation to be passed between connected components.\n\n\\code{bCodecConfigIsCompete} specifies if the codec config is fully\ncontained in here and there is no need to wait for OMX_BUFFERFLAG_CODECCONFIG\nbuffers\n*/\n\ntypedef struct OMX_PARAM_STILLSFUNCTIONTYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_BOOL bBuffer;\n   OMX_PTR (*pOpenFunc)(void);\n   OMX_PTR (*pCloseFunc)(void);\n   OMX_PTR (*pReadFunc)(void);\n   OMX_PTR (*pSeekFunc)(void);\n   OMX_PTR (*pWriteFunc)(void);\n} OMX_PARAM_STILLSFUNCTIONTYPE;\n\ntypedef void* OMX_BUFFERADDRESSHANDLETYPE;\n\ntypedef struct OMX_PARAM_BUFFERADDRESSTYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nPortIndex;\n   OMX_U32 nAllocLen;\n   OMX_BUFFERADDRESSHANDLETYPE handle;\n} OMX_PARAM_BUFFERADDRESSTYPE;\n\ntypedef struct OMX_PARAM_TUNNELSETUPTYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nPortIndex;\n   OMX_TUNNELSETUPTYPE sSetup;\n} OMX_PARAM_TUNNELSETUPTYPE;\n\n/* OMX_IndexParamBrcmPortEGL: Used for querying whether a port is an EGL port or not. */\ntypedef struct OMX_PARAM_BRCMPORTEGLTYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nPortIndex;\n   OMX_BOOL bPortIsEGL;\n} OMX_PARAM_BRCMPORTEGLTYPE;\n/*\n*/\n\n#define OMX_CONFIG_IMAGEFILTERPARAMS_MAXPARAMS 6\n/* OMX_IndexConfigCommonImageFilterParameters: Parameterized Image Filter */\ntypedef struct OMX_CONFIG_IMAGEFILTERPARAMSTYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nPortIndex;\n   OMX_IMAGEFILTERTYPE eImageFilter;\n   OMX_U32 nNumParams;\n   OMX_U32 nParams[OMX_CONFIG_IMAGEFILTERPARAMS_MAXPARAMS];\n} OMX_CONFIG_IMAGEFILTERPARAMSTYPE;\n/*\nThis structure contains optional parameters for some image\nfilters. The following table lists all image filters that support\nparameters.\n\n<table border=\"1\" cellspacing=\"0\" cellpadding=\"2\">\n<tr><td>Filter<td>Parameters<td>Notes\n\n<tr><td>\\code{OMX_ImageFilterSolarize}\n<td>\\code{[x0 y0 y1 y2]}\n<td>Linear mapping of \\code{[0,x0]} to \\code{[0,y0>]}\nand \\code{[x0,255]} to \\code{[y1,y2]}.\nDefault is \\code{\"128 128 128 0\"}.\n\n<tr><td>\\code{OMX_ImageFilterSharpen}\n<td>\\code{[sz [str [th]]}\n<td>\\code{sz} size of filter, either 1 or 2.\n\\code{str} strength of filter.\n\\code{th} threshold of filter.\nDefault is \\code{\"1 40 20\"}.\n\n<tr><td>\\code{OMX_ImageFilterFilm}\n<td>\\code{[[str] [u v]]}\n<td>\\code{str} strength of effect.\n\\code{u} sets u to constant value.\n\\code{v} sets v to constant value.\nDefault is \\code{\"24\"}.\n\n<tr><td>\\code{OMX_ImageFilterBlur}\n<td>\\code{[sz]}\n<td>\\code{sz} size of filter, either 1 or 2.\nDefault is \\code{\"2\"}.\n\n<tr><td>\\code{OMX_ImageFilterSaturation}\n<td>\\code{[str]}\n<td>\\code{str} strength of effect, in 8.8 fixed point format. u/v value\ndifferences from 128 are multiplied by \\code{str}.\nDefault is \\code{\"272\"}.\n</table>\n*/\n\n\n/* OMX_IndexConfigTransitionControl: Transition Control */\ntypedef struct OMX_CONFIG_TRANSITIONCONTROLTYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nPortIndex;\n   OMX_U32 nPosStart;\n   OMX_U32 nPosEnd;\n   OMX_S32 nPosIncrement;\n   OMX_TICKS nFrameIncrement;\n   OMX_BOOL bSwapInputs;\n   OMX_U8 name[16];\n   OMX_U8 property[64];\n} OMX_CONFIG_TRANSITIONCONTROLTYPE;\n/*\nThis structure represents the internal configuration of the\ntransition. Transitions are generated by a loadable plug-in described\nby the \\code{name} field. The component appends \\code{\"_tran.vll\"} to\nthe name provided, and attempts to load a transition library contained\nin this VLL.  The exact type of transition is configured in a\nplug-in-dependent manner with the \\code{property} field. All plug-ins\nshould accept a \\code{property} field equal to\n\\code{\"flags=<number>\"}, where \\code{<number>} can be a random 32 bit\nnumber.  If \\code{bSwapInputs} is false, then the start image is on\nport 210, the stop image on port 211. These are reversed if\n\\code{bSwapInputs} is true.\n\nTransition frames are generated from the plug-in by referencing a\nframe position in [0,65536], where position 0 is the start image,\nposition 65536 is the stop image. The first frame position generated\nis \\code{nPosStart}. The last frame position generated is\n\\code{nPosEnd}. Each frame will increment the position by\n\\code{nPosIncrement}. The timestamp attached to each frame will\nincrement by \\code{nFrameIncrement}.\n*/\n\n\n/*\nThis parameter is used to provide a callback function pointer for\nrelease events. It is used for internal clients on VideoCore.\n*/\n\n\n/* OMX_IndexConfigAudioMonoTrackControl: Dual Mono Control */\ntypedef enum OMX_AUDIOMONOTRACKOPERATIONSTYPE {\n   OMX_AUDIOMONOTRACKOPERATIONS_NOP,\n   OMX_AUDIOMONOTRACKOPERATIONS_L_TO_R,\n   OMX_AUDIOMONOTRACKOPERATIONS_R_TO_L,\n   OMX_AUDIOMONOTRACKOPERATIONS_DUMMY = 0x7FFFFFFF\n} OMX_AUDIOMONOTRACKOPERATIONSTYPE ;\n\ntypedef struct OMX_CONFIG_AUDIOMONOTRACKCONTROLTYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nPortIndex;\n   OMX_AUDIOMONOTRACKOPERATIONSTYPE eMode;\n} OMX_CONFIG_AUDIOMONOTRACKCONTROLTYPE;\n/*\nThis config controls the options to support dual mono audio\nstreams. The output can be unchanged, or the left channel copied over\nthe right channel, or the right channel copied over the left\nchannel. This config can be applied at any time with stereo\n16-bit-per-sample data. Since audio output is typically buffered, any\nchange will not be audible until that buffering has been played out.\n*/\n\n/* OMX_IndexParamCameraImagePool: Camera Image Pools */\ntypedef enum OMX_CAMERAIMAGEPOOLINPUTMODETYPE {\n   OMX_CAMERAIMAGEPOOLINPUTMODE_ONEPOOL,     /*All input images are allocated from one pool\n                                               Works for simple stills capture use cases\n                                               Can not be used with parallel stills capture\n                                               and video encode, as the pool will be sized for\n                                               capture or viewfinder, not both simultaneously.\n                                               The pool wouldn't divide sensibly in this mode\n                                               anyway.\n                                             */\n   OMX_CAMERAIMAGEPOOLINPUTMODE_TWOPOOLS,    /*All stills & video input images are allocated\n                                               from two separate pools.\n                                               This ensures that parallel capture can work, but\n                                               would consume more memory if used on a simple\n                                               stills capture use case.\n                                             */\n} OMX_CAMERAIMAGEPOOLINPUTMODETYPE;\n\ntypedef struct OMX_PARAM_CAMERAIMAGEPOOLTYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nNumHiResVideoFrames;\n   OMX_U32 nHiResVideoWidth;\n   OMX_U32 nHiResVideoHeight;\n   OMX_COLOR_FORMATTYPE eHiResVideoType;\n   OMX_U32 nNumHiResStillsFrames;\n   OMX_U32 nHiResStillsWidth;\n   OMX_U32 nHiResStillsHeight;\n   OMX_COLOR_FORMATTYPE eHiResStillsType;\n   OMX_U32 nNumLoResFrames;\n   OMX_U32 nLoResWidth;\n   OMX_U32 nLoResHeight;\n   OMX_COLOR_FORMATTYPE eLoResType;\n   OMX_U32 nNumSnapshotFrames;\n   OMX_COLOR_FORMATTYPE eSnapshotType;\n   OMX_CAMERAIMAGEPOOLINPUTMODETYPE eInputPoolMode;\n   OMX_U32 nNumInputVideoFrames;\n   OMX_U32 nInputVideoWidth;\n   OMX_U32 nInputVideoHeight;\n   OMX_COLOR_FORMATTYPE eInputVideoType;\n   OMX_U32 nNumInputStillsFrames;\n   OMX_U32 nInputStillsWidth;\n   OMX_U32 nInputStillsHeight;\n   OMX_COLOR_FORMATTYPE eInputStillsType;\n} OMX_PARAM_CAMERAIMAGEPOOLTYPE;\n/*\n\\sloppy This parameter specifies the size, type, and number, of images to\nallow in the images pools required by Camplus. Supported types are\n\\code{OMX_COLOR_FormatYUV420PackedPlanar},\n\\code{OMX_COLOR_FormatYUV422PackedPlanar},\n\\code{OMX_COLOR_FormatRawBayer8bit},\n\\code{OMX_COLOR_FormatRawBayer10bit},\n\\code{OMX_COLOR_FormatRawBayer8bitcompressed}, and 0 (reserved for the\nBroadcom-specific format required by the video encoder). The input\npool width, height, and type can be set as 0 to make the component\nquery Camplus for the sensor mode that would correspond to the largest\nof the viewfinder port definition, the capture port definition, or the\nhigh resolution image pool.\n*/\n\n/* OMX_IndexParamImagePoolSize: Specifying Image Pool Properties */\ntypedef struct OMX_PARAM_IMAGEPOOLSIZETYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 width;\n   OMX_U32 height;\n   OMX_U32 num_pages;\n} OMX_PARAM_IMAGEPOOLSIZETYPE;\n/*\nThis parameter is used to control the size of pool that the component\nwill allocate in the absence of setting an external pool.  The default\ncan be reset by setting this parameter with all three fields set to\nzero.\n*/\n\n\n/* OMX_IndexParamImagePoolExternal: Client Allocated Image Pools */\nstruct opaque_vc_pool_s;\ntypedef struct opaque_vc_pool_s OMX_BRCM_POOL_T;\n\ntypedef struct OMX_PARAM_IMAGEPOOLEXTERNALTYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_BRCM_POOL_T *image_pool;\n   OMX_BRCM_POOL_T *image_pool2;\n   OMX_BRCM_POOL_T *image_pool3;\n   OMX_BRCM_POOL_T *image_pool4;\n   OMX_BRCM_POOL_T *image_pool5;\n} OMX_PARAM_IMAGEPOOLEXTERNALTYPE;\n/*\nThis config allows the client to pass in handles to pre-allocated\nimage pools for use within the component.\n*/\n\n\nstruct _IL_FIFO_T;\ntypedef struct OMX_PARAM_RUTILFIFOINFOTYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nPortIndex;\n   struct _IL_FIFO_T *pILFifo;\n} OMX_PARAM_RUTILFIFOINFOTYPE;\n\n/* OMX_IndexParamILFifoConfig: Allows configuration of the FIFO settings. */\ntypedef struct OMX_PARAM_ILFIFOCONFIG {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nPortIndex;\n   OMX_U32 nDataSize;         /**< The size of the FIFO's data area */\n   OMX_U32 nHeaderCount;      /**< The number of headers allocated */\n} OMX_PARAM_ILFIFOCONFIG;\n/**\n * Allows configuring the size of the ILFIFO used in a component.\n */\n\n/* OMX_IndexConfigCameraSensorModes: Camera Sensor Mode */\ntypedef struct OMX_CONFIG_CAMERASENSORMODETYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nPortIndex;\n   OMX_U32 nModeIndex;\n   OMX_U32 nNumModes;\n   OMX_U32 nWidth;\n   OMX_U32 nHeight;\n   OMX_U32 nPaddingRight;\n   OMX_U32 nPaddingDown;\n   OMX_COLOR_FORMATTYPE eColorFormat;\n   OMX_U32 nFrameRateMax;\n   OMX_U32 nFrameRateMin;\n} OMX_CONFIG_CAMERASENSORMODETYPE;\n/*\nThis parameter is used by clients to determine the sensor mode, and\nhence the memory usage, of the camera module. This is primarily used\nfor determining the size of the input image pool.\n\nIt can be used in two ways dependent on \\code{nPortIndex}. If\n\\code{nPortIndex} is \\code{OMX_ALL}, it returns the sensor mode\ncorresponding to \\code{nModeIndex}, and the number of modes in\n\\code{nNumModes}. If \\code{nModeIndex} is greater than or equal to\n\\code{nNumModes} only \\code{nNumModes} is returned. If\n\\code{nPortIndex} is equal to a camera video output port index, it\nreturns the sensor mode that would be selected for the values\ncurrently in \\code{OMX_IndexParamPortDefinition} for that port.\n\nThe \\code{nPaddingRight} and \\code{nPaddingDown} values determine the\nextra padding the sensor adds to the image. These values must be added\nto \\code{nWidth} and \\code{nHeight} respectively if the client is\nspecifying the input image pool size.\n*/\n\ntypedef struct OMX_BRCMBUFFERSTATSTYPE {\n   OMX_U32 nOrdinal;\n   OMX_TICKS nTimeStamp;\n   OMX_U32 nFilledLen;\n   OMX_U32 nFlags;\n   union\n   {\n      OMX_U32 nU32;\n      struct\n      {\n         OMX_U32 nYpart;\n         OMX_U32 nUVpart;\n      } image;\n   } crc;\n} OMX_BRCMBUFFERSTATSTYPE;\n\n/*\nPorts that gather statistics for debugging and diagnostics\nmight also collect information about buffer header fields\nand data.\n\nNote that:\n\nThe \\code{nOrdinal} field increases monotonically whenever\na new buffer is received or emitted and shall not be reset\nupon a port flush.\n\nThe \\code{nFilledLen} might indicate the size of a data area\nlarger than the data area that actually contributed to the\nchecksums (e.g. when image data is provided with cropping\ninformation).\n*/\n\n/* OMX_IndexConfigBrcmPortBufferStats: Query port buffer stats history */\ntypedef struct OMX_CONFIG_BRCMPORTBUFFERSTATSTYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nPortIndex;\n   OMX_U32 nCount;\n   OMX_BRCMBUFFERSTATSTYPE sData[1];\n} OMX_CONFIG_BRCMPORTBUFFERSTATSTYPE;\n/*\nPorts that gather statistics for debugging and diagnostics\nmight also collect information about buffer header fields\nand data.\n\nThe \\code{sStatsData} field is a variable length array and\nthe number of items is denoted by \\code{nStatsCount}.\n*/\n\n/* OMX_IndexConfigBrcmPortStats: Query port statistics */\ntypedef struct OMX_CONFIG_BRCMPORTSTATSTYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nPortIndex;\n   OMX_U32 nImageCount;\n   OMX_U32 nBufferCount;\n   OMX_U32 nFrameCount;\n   OMX_U32 nFrameSkips;\n   OMX_U32 nDiscards;\n   OMX_U32 nEOS;\n   OMX_U32 nMaxFrameSize;\n\n   OMX_TICKS nByteCount;\n   OMX_TICKS nMaxTimeDelta;\n   OMX_U32 nCorruptMBs;   /**< Number of corrupt macroblocks in the stream */\n} OMX_CONFIG_BRCMPORTSTATSTYPE;\n/*\nSome ports gather various statistics that can be used by clients for\ndebugging purposes.  This structure is the set of all statistics that\nare gathered.\n\nThe \\code{nFrameSkips} field indicates the number of frames that did\nnot have an expected PTS value based on the port frame rate.\n\nThe \\code{nByteCount} field is a 64 bit value, that will either use a\n64 bit type or two 32 bit types, similarly to \\code{OMX_TICKS}.\n*/\n\n/* OMX_IndexConfigBrcmClockMissCount: Missed clock request accounting */\n/*\nFor each port on the clock component, requests for media times may be\nmade.  These are typically done one per video frame to allow for\nscheduling the display of that frame at the correct time.  If a\nrequest is made after the time has occurred, then that frame will be\ndisplayed late, and the clock component keeps a per-port record of the\nnumber of times this occurs.  This record can be read using this\nindex.\n*/\n\ntypedef struct OMX_CONFIG_BRCMCAMERASTATSTYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nOutFrameCount;\n   OMX_U32 nDroppedFrameCount;\n} OMX_CONFIG_BRCMCAMERASTATSTYPE;\n\n// for backward compatibility\ntypedef struct OMX_CONFIG_BRCMCAMERASTATSTYPE OMX_CONFIG_BRCMCAMERASTATS;\n\n\n#define OMX_BRCM_MAXIOPERFBANDS 10\ntypedef struct {\n   OMX_U32 count[OMX_BRCM_MAXIOPERFBANDS];\n   OMX_U32 num[OMX_BRCM_MAXIOPERFBANDS];\n} OMX_BRCM_PERFSTATS;\n\n/* OMX_IndexConfigBrcmIOPerfStats: Query I/O performance statistics */\ntypedef struct OMX_CONFIG_BRCMIOPERFSTATSTYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_BOOL bEnabled;                              /**< Enable/disable I/O performance statistics */\n   OMX_BRCM_PERFSTATS write; /**< count:bytes     num:microseconds */\n   OMX_BRCM_PERFSTATS flush; /**< count:frequency num:microseconds waiting to flush data */\n   OMX_BRCM_PERFSTATS wait;  /**< count:frequency num:microseconds waiting in calling function */\n} OMX_CONFIG_BRCMIOPERFSTATSTYPE;\n/*\nA sink component can gather various statistics about I/O (eg. file media) performance that can be used by\nclients for debugging purposes.  The \\code{bEnabled} field is used to turn the gathering of statistics\non/off.\n*/\n\ntypedef struct OMX_CONFIG_SHARPNESSTYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nPortIndex;\n   OMX_S32 nSharpness;\n} OMX_CONFIG_SHARPNESSTYPE;\n\n/* OMX_IndexConfigCommonFlickerCancellation: Flicker cancellation */\ntypedef enum OMX_COMMONFLICKERCANCELTYPE {\n   OMX_COMMONFLICKERCANCEL_OFF,\n   OMX_COMMONFLICKERCANCEL_AUTO,\n   OMX_COMMONFLICKERCANCEL_50,\n   OMX_COMMONFLICKERCANCEL_60,\n   OMX_COMMONFLICKERCANCEL_DUMMY = 0x7FFFFFFF\n} OMX_COMMONFLICKERCANCELTYPE;\n\ntypedef struct OMX_CONFIG_FLICKERCANCELTYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nPortIndex;\n   OMX_COMMONFLICKERCANCELTYPE eFlickerCancel;\n} OMX_CONFIG_FLICKERCANCELTYPE;\n/*\nQuery / set the flicker cancellation frequency. Values are defined for Off,\n50Hz, 60Hz, or auto. The method for auto detecting the flicker frequency is\nnot defined, and currently results in the feature being turned off.\n*/\n\n/* OMX_IndexConfigCommonRedEyeRemoval: Red eye removal/reduction */\ntypedef enum OMX_REDEYEREMOVALTYPE {\n   OMX_RedEyeRemovalNone,                           /**< No red eye removal */\n   OMX_RedEyeRemovalOn,                             /**< Red eye removal on */\n   OMX_RedEyeRemovalAuto,                           /**< Red eye removal will be done automatically when detected */\n   OMX_RedEyeRemovalKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */\n   OMX_RedEyeRemovalVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n   OMX_RedEyeRemovalSimple,                         /**< Use simple red eye reduction mechanism if supported by algorithm */\n   OMX_RedEyeRemovalMax = 0x7FFFFFFF\n} OMX_REDEYEREMOVALTYPE;\n\ntypedef struct OMX_CONFIG_REDEYEREMOVALTYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nPortIndex;\n   OMX_REDEYEREMOVALTYPE eMode;\n} OMX_CONFIG_REDEYEREMOVALTYPE;\n/*\n   Configures the red eye reduction algorithm in the camera processing\n   pipeline. The stage is only enabled if the flash mode is not FlashOff.\n   The OMX_RedEyeRemovalSimple mode requests that the algorithm uses a\n   reduced complexity algorithm to reduce the processing time.\n*/\n\n\ntypedef enum OMX_FACEDETECTIONCONTROLTYPE {\n   OMX_FaceDetectionControlNone,                           /**< Disables face detection */\n   OMX_FaceDetectionControlOn,                             /**< Enables face detection */\n   OMX_FaceDetectionControlKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */\n   OMX_FaceDetectionControlVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n   OMX_FaceDetectionControlMax = 0x7FFFFFFF\n} OMX_FACEDETECTIONCONTROLTYPE;\n\ntypedef struct OMX_CONFIG_FACEDETECTIONCONTROLTYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nPortIndex;\n   OMX_FACEDETECTIONCONTROLTYPE eMode;\n   OMX_U32 nFrames;      /**< number of frames to apply this setting for,\n                              0 for unlimited */\n   OMX_U32 nMaxRegions;  /**< maximum number of regions to detect, 0 for unlimited */\n   OMX_U32 nQuality;     /**< hint for algorithmic complexity, range is 0-100.\n                              0 for simplest algorithm, 100 for best quality */\n} OMX_CONFIG_FACEDETECTIONCONTROLTYPE;\n\ntypedef enum OMX_FACEREGIONFLAGSTYPE {\n   OMX_FaceRegionFlagsNone    = 0,\n   OMX_FaceRegionFlagsBlink   = 1,\n   OMX_FaceRegionFlagsSmile   = 2,\n   OMX_FaceRegionFlagsKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */\n   OMX_FaceRegionFlagsVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n   OMX_FaceRegionFlagsMax = 0x7FFFFFFF\n} OMX_FACEREGIONFLAGSTYPE;\n\ntypedef struct OMX_FACEREGIONTYPE {\n   OMX_S16 nLeft;              /**< X Coordinate of the top left corner of the rectangle */\n   OMX_S16 nTop;               /**< Y Coordinate of the top left corner of the rectangle */\n   OMX_U16 nWidth;             /**< Width of the rectangle */\n   OMX_U16 nHeight;            /**< Height of the rectangle */\n   OMX_FACEREGIONFLAGSTYPE nFlags;  /**< Flags for the region */\n#ifndef OMX_SKIP64BIT\n   OMX_U64 nFaceRecognitionId; /**< ID returned by face recognition for this face */\n#else\n   struct\n   {\n      OMX_U32 nLowPart;   /**< low bits of the signed 64 bit value */\n      OMX_U32 nHighPart;  /**< high bits of the signed 64 bit value */\n   } nFaceRecognitionId;\n#endif\n} OMX_FACEREGIONTYPE;\n\ntypedef struct OMX_CONFIG_FACEDETECTIONREGIONTYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nPortIndex;            /**< index of port with face detection enabled */\n   OMX_U32 nIndex;                /**< first requested region number, allowing retrieval of many regions\n                                       over several requests */\n   OMX_U32 nDetectedRegions;      /**< total number of detected regions */\n   OMX_S32 nValidRegions;         /**< number of valid regions in sRegion array\n                                       When getting, the client sets this to the number of regions available.\n                                       The component writes region data and updates this field with how many\n                                       regions have been written to. */\n   OMX_U32 nImageWidth;           /**< Width of the image, hence reference for the face coordinates */\n   OMX_U32 nImageHeight;          /**< Height of the image, hence reference for the face coordinates */\n   OMX_FACEREGIONTYPE sRegion[1]; /**< variable length array of face regions */\n} OMX_CONFIG_FACEDETECTIONREGIONTYPE;\n\ntypedef enum OMX_INTERLACETYPE {\n   OMX_InterlaceProgressive,                    /**< The data is not interlaced, it is progressive scan */\n   OMX_InterlaceFieldSingleUpperFirst,          /**< The data is interlaced, fields sent\n                                                     separately in temporal order, with upper field first */\n   OMX_InterlaceFieldSingleLowerFirst,          /**< The data is interlaced, fields sent\n                                                     separately in temporal order, with lower field first */\n   OMX_InterlaceFieldsInterleavedUpperFirst,    /**< The data is interlaced, two fields sent together line\n                                                     interleaved, with the upper field temporally earlier */\n   OMX_InterlaceFieldsInterleavedLowerFirst,    /**< The data is interlaced, two fields sent together line\n                                                     interleaved, with the lower field temporally earlier */\n   OMX_InterlaceMixed,                          /**< The stream may contain a mixture of progressive\n                                                     and interlaced frames */\n   OMX_InterlaceKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */\n   OMX_InterlaceVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n   OMX_InterlaceMax = 0x7FFFFFFF\n} OMX_INTERLACETYPE;\n\ntypedef struct OMX_CONFIG_INTERLACETYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nPortIndex;            /**< index of port emitting or accepting the content */\n   OMX_INTERLACETYPE eMode;       /**< The interlace type of the content */\n   OMX_BOOL bRepeatFirstField;    /**< Whether to repeat the first field */\n} OMX_CONFIG_INTERLACETYPE;\n\n/* OMX_IndexParamIspTuner: Custom ISP tuner */\ntypedef struct OMX_PARAM_CAMERAISPTUNERTYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U8 tuner_name[64];\n} OMX_PARAM_CAMERAISPTUNERTYPE;\n/*\nThis parameter allows a custom ISP tuner to be loaded instead of\nthe default one specified for the camera module. Setting an empty\nstring uses the default value.\n*/\n\n/* OMX_IndexConfigCameraInputFrame: Pointer to the raw input image */\ntypedef struct OMX_CONFIG_IMAGEPTRTYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_PTR pImage;\n} OMX_CONFIG_IMAGEPTRTYPE;\n/*\nThis parameter parameter allows the return of a pointer to a\nVideoCore image resource.\n*/\n\n/* OMX_IndexConfigAFAssistLight: Autofocus assist light mode selection */\ntypedef enum OMX_AFASSISTTYPE {\n   OMX_AFAssistAuto,\n   OMX_AFAssistOn,\n   OMX_AFAssistOff,\n   OMX_AFAssistTorch,\n   OMX_AFAssistKhronosExtensions = 0x6F000000,\n   OMX_AFAssistVendorStartUnused = 0x7F000000,\n   OMX_AFAssistMax = 0x7FFFFFFF\n} OMX_AFASSISTTYPE;\n\ntypedef struct OMX_CONFIG_AFASSISTTYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nPortIndex;\n   OMX_AFASSISTTYPE eMode;\n} OMX_CONFIG_AFASSISTTYPE;\n/*\nSet the mode to adopt for the autofocus assist light.\n\\code{OMX_AFAssistTorch} will turn the AF assist light on permanently, allowing\nit to be used as a torch.\n*/\n\n/* OMX_IndexConfigInputCropPercentage: Specify input crop as a percentage */\ntypedef struct OMX_CONFIG_INPUTCROPTYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nPortIndex;\n   OMX_U32 xLeft;     /**< Fraction of the width for the top left corner of the rectangle */\n   OMX_U32 xTop;      /**< Fraction of the height for the top left corner of the rectangle */\n   OMX_U32 xWidth;    /**< Fraction of the image width desired */\n   OMX_U32 xHeight;   /**< Fraction of the image height desired */\n} OMX_CONFIG_INPUTCROPTYPE;\n/*\nThis parameter allows the input cropping to be specified as a\npercentage of the current width/height.  Required for the camera\ncomponent where the output resolution varies dependent on the port.\nAll percentage values are as 16p16 fixed point numbers (0x10000 =\n100\\%)\n*/\n\n/* OMX_IndexParamCodecRequirements: Advanced codec requirements */\ntypedef struct OMX_PARAM_CODECREQUIREMENTSTYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nCallbackID;\n   OMX_BOOL bTryHWCodec;\n} OMX_PARAM_CODECREQUIREMENTSTYPE;\n/*\nThis parameter allows internal users of RIL components controlling\nvideo codecs to request that the component loads the component and\nqueries for requirements.  The component will perform a callback with\nthe given nCallbackID value passing a pointer to the requirements\nstructure as the data field.\n*/\n\n/* OMX_IndexConfigBrcmEGLImageMemHandle: Mapping from an EGLImage to a VideoCore mem handle */\ntypedef struct OMX_CONFIG_BRCMEGLIMAGEMEMHANDLETYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nPortIndex;\n   OMX_PTR eglImage;\n   OMX_PTR memHandle;\n} OMX_CONFIG_BRCMEGLIMAGEMEMHANDLETYPE;\n/*\nThis config allows the EGL server to notify a RIL component that an\nEGLImage is available for rendering into and to provide a mapping from\nan EGLImage to a mem handle.\n*/\n\n/* OMX_IndexConfigPrivacyIndicator: Privacy indicator control */\ntypedef enum OMX_PRIVACYINDICATORTYPE {\n   OMX_PrivacyIndicatorOff,\n   OMX_PrivacyIndicatorOn,\n   OMX_PrivacyIndicatorForceOn,\n   OMX_PrivacyIndicatorKhronosExtensions = 0x6F000000,\n   OMX_PrivacyIndicatorVendorStartUnused = 0x7F000000,\n   OMX_PrivacyIndicatorMax = 0x7FFFFFFF\n} OMX_PRIVACYINDICATORTYPE;\n\ntypedef struct OMX_CONFIG_PRIVACYINDICATORTYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_PRIVACYINDICATORTYPE ePrivacyIndicatorMode;\n} OMX_CONFIG_PRIVACYINDICATORTYPE;\n/*\nThis config allows control over the privacy indicator light.  This\nlight indicates when a capture is in progress.\n\n\\code{OMX_PrivacyIndicatorOff} indicator is disabled.\n\n\\code{OMX_PrivacyIndicatorOn} indicator will be\nturned on whenever an image is being captured as determined by the\ncapturing bit. Minimum on duration of approx 200ms.\n\n\\code{OMX_PrivacyIndicatorForceOn} results in turning the indicator on\nimmediately, whether an image is being captured or not. The mode will\nautomatically revert to \\code{OMX_PrivacyIndicatorOff} once the\nindicator has been turned on, so \\code{OMX_PrivacyIndicatorForceOn}\nmust be requested at least every 200ms if the indicator is to remain\non.\n*/\n\n\n/* OMX_IndexParamCameraFlashType: Select flash type */\ntypedef enum OMX_CAMERAFLASHTYPE {\n   OMX_CameraFlashDefault,\n   OMX_CameraFlashXenon,\n   OMX_CameraFlashLED,\n   OMX_CameraFlashNone,\n   OMX_CameraFlashKhronosExtensions = 0x6F000000,\n   OMX_CameraFlashVendorStartUnused = 0x7F000000,\n   OMX_CameraFlashMax = 0x7FFFFFFF\n} OMX_CAMERAFLASHTYPE;\n\ntypedef struct OMX_PARAM_CAMERAFLASHTYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nPortIndex;\n   OMX_CAMERAFLASHTYPE eFlashType;\n   OMX_BOOL bRedEyeUsesTorchMode;\n} OMX_PARAM_CAMERAFLASHTYPE;\n/*\nThis parameter allows the selection of xenon or LED flash devices\nto be used with the currently selected camera. If that device is not\navailable, then the component will revert back to whatever flash\ndevice is available for that camera.\n\\code{bRedEyeUsesTorchMode} allows the blinking for red eye reduction to\nbe switched between using the indicator mode, and the torch mode for the\nflash driver.\n*/\n\n/* OMX_IndexConfigCameraFlashConfig: Flash cycle configuration */\ntypedef enum OMX_CAMERAFLASHCONFIGSYNCTYPE {\n   OMX_CameraFlashConfigSyncFrontSlow,\n   OMX_CameraFlashConfigSyncRearSlow,\n   OMX_CameraFlashConfigSyncFrontFast,\n   OMX_CameraFlashConfigSyncKhronosExtensions = 0x6F000000,\n   OMX_CameraFlashConfigSyncVendorStartUnused = 0x7F000000,\n   OMX_CameraFlashConfigSyncMax = 0x7FFFFFFF\n} OMX_CAMERAFLASHCONFIGSYNCTYPE;\n\ntypedef struct OMX_CONFIG_CAMERAFLASHCONFIGTYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nPortIndex;\n   OMX_BOOL bUsePreFlash;\n   OMX_BOOL bUseFocusDistanceInfo;\n   OMX_CAMERAFLASHCONFIGSYNCTYPE eFlashSync;\n   OMX_BOOL bIgnoreChargeState;\n} OMX_CONFIG_CAMERAFLASHCONFIGTYPE;\n/*\nThis parameter allows the configuration of various parameters relating to\nthe flash cycle. Some of the options are only applicable to xenon flash.\n\n\\code{bUsePreFlash} uses a low intensity pre-flash to determine flash intensity. This setting\nis recommended for almost all flash situations.\n\n\\code{bUseFocusDistanceInfo} uses the distance of the subject, as measured by the AF algorithm\nto set the intensity of the flash.\n\n\\code{eFlashSync} configures which edge of the shutter is used to synchronise the flash, and\nthe duration of the exposure.\n\n\\code{eIgnoreChargeState} will make the flash fire, even if it is not fully charged.\n*/\n\n/* OMX_IndexConfigBrcmAudioTrackGaplessPlayback: Encoder/decoder delay and padding information for gapless playback. */\ntypedef struct OMX_CONFIG_BRCMAUDIOTRACKGAPLESSPLAYBACKTYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nPortIndex;\n   OMX_U32 nDelay;   /**< number of samples delay added by the codec */\n   OMX_U32 nPadding; /**< number of silent samples added to the end */\n} OMX_CONFIG_BRCMAUDIOTRACKGAPLESSPLAYBACKTYPE;\n/*\nThis config allows communication between components to facilitate gapless playback.\n*/\n\n\n/* OMX_IndexConfigBrcmAudioTrackChangeControl: Configure gapless/crossfaded audio track change. */\ntypedef struct OMX_CONFIG_BRCMAUDIOTRACKCHANGECONTROLTYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nSrcPortIndex;\n   OMX_U32 nDstPortIndex;\n   OMX_U32 nXFade;\n} OMX_CONFIG_BRCMAUDIOTRACKCHANGECONTROLTYPE;\n/*\nThis config allows the client to specify the gapless or crossfade\nparameters to be used on a track change.  If \\code{nXFade} is 0, then\na normal or gapless track change will result, otherwise a crossfade of\n\\code{nXFade} ms is used.\n*/\n\n/* OMX_IndexParamBrcmPixelValueRange: Describing the pixel value range */\ntypedef enum OMX_BRCMPIXELVALUERANGETYPE\n{\n   OMX_PixelValueRangeUnspecified = 0,\n   OMX_PixelValueRangeITU_R_BT601,\n   OMX_PixelValueRangeFull8Bit,\n   OMX_PixelValueRangeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */\n   OMX_PixelValueRangeVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n   OMX_PixelValueRangeMax = 0x7FFFFFFF\n} OMX_BRCMPIXELVALUERANGETYPE;\n\ntypedef struct OMX_PARAM_BRCMPIXELVALUERANGETYPE\n{\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nPortIndex;\n   OMX_BRCMPIXELVALUERANGETYPE ePixelValueRange;\n} OMX_PARAM_BRCMPIXELVALUERANGETYPE;\n/*\nThis structure allows a description of the range that pixel values may\nhave.  This is typically useful since some standards use the full 8\nbit range, whereas others introduce pedastals which reduce the range\nat the top and bottom end.\n*/\n\n/* OMX_IndexParamCameraDisableAlgorithm: Disabling camera processing stages. */\ntypedef enum OMX_CAMERADISABLEALGORITHMTYPE {\n      OMX_CameraDisableAlgorithmFacetracking,\n      OMX_CameraDisableAlgorithmRedEyeReduction,\n      OMX_CameraDisableAlgorithmVideoStabilisation,\n      OMX_CameraDisableAlgorithmWriteRaw,\n      OMX_CameraDisableAlgorithmVideoDenoise,\n      OMX_CameraDisableAlgorithmStillsDenoise,\n      OMX_CameraDisableAlgorithmAntiShake,\n      OMX_CameraDisableAlgorithmImageEffects,\n      OMX_CameraDisableAlgorithmDarkSubtract,\n      OMX_CameraDisableAlgorithmDynamicRangeExpansion,\n      OMX_CameraDisableAlgorithmFaceRecognition,\n      OMX_CameraDisableAlgorithmFaceBeautification,\n      OMX_CameraDisableAlgorithmSceneDetection,\n      OMX_CameraDisableAlgorithmHighDynamicRange,\n   OMX_CameraDisableAlgorithmKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */\n   OMX_CameraDisableAlgorithmVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n   OMX_CameraDisableAlgorithmMax = 0x7FFFFFFF\n} OMX_CAMERADISABLEALGORITHMTYPE;\n\ntypedef struct OMX_PARAM_CAMERADISABLEALGORITHMTYPE\n{\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_CAMERADISABLEALGORITHMTYPE eAlgorithm;\n   OMX_BOOL bDisabled;\n} OMX_PARAM_CAMERADISABLEALGORITHMTYPE;\n/*\nAllows plugin algorithms to be disabled to save memory\nwithin the camera component\n*/\n\n/* OMX_IndexConfigBrcmAudioEffectControl: Audio Effect Control */\ntypedef struct OMX_CONFIG_BRCMAUDIOEFFECTCONTROLTYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nPortIndex;\n   OMX_BOOL bEnable;\n   OMX_U8 name[16];\n   OMX_U8 property[256];\n} OMX_CONFIG_BRCMAUDIOEFFECTCONTROLTYPE;\n/*\nThis structure represents the internal configuration of an audio effect.\nThe audio effect is provided by a loadable plug-in described\nin the \\code{name} field and is configured in a plug-in-dependent\nmanner with the \\code{property} field. The \\code{bEnable} field is used to\nturn the effect on/off.\n*/\n\n/* OMX_IndexConfigBrcmMinimumProcessingLatency: Processing Latency Bound */\ntypedef struct OMX_CONFIG_BRCMMINIMUMPROCESSINGLATENCY {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_TICKS nOffset;\n} OMX_CONFIG_BRCMMINIMUMPROCESSINGLATENCY;\n/*\nQuery/set the difference between the actual media time and when the\ncomponent receives request fulfillments for media time requests. This\ncan be used with e.g. splitter/mixer components to control when the\ncomponent stops waiting for input or output packets from active\nstreams and continues with processing (to maintain a constant\nprocessing rate).\n*/\n\n/** Enable or disable Supplemental Enhancment Information (SEI) messages to be inserted in\n  * the H.264 bitstream.\n  */\ntypedef struct OMX_PARAM_BRCMVIDEOAVCSEIENABLETYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nPortIndex;\n   OMX_BOOL bEnable;\n} OMX_PARAM_BRCMVIDEOAVCSEIENABLETYPE;\n\n/* OMX_IndexParamBrcmAllowMemChange: Allowing changing memory allocation on state transition */\ntypedef struct OMX_PARAM_BRCMALLOWMEMCHANGETYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_BOOL bEnable;\n} OMX_PARAM_BRCMALLOWMEMCHANGETYPE;\n/*\nLet the component change the amount of memory it has allocated when\ngoing from LOADED to IDLE. By default this is enabled, but if it is\ndisabled the component will fail to transition to IDLE if the\ncomponent requires more memory than has already been allocated.  This\nmight occur if (for example) the component was configured, taken to\nIDLE, then taken back to LOADED, the profile increased and the\ncomponent taken back to IDLE.\n*/\n\ntypedef enum OMX_CONFIG_CAMERAUSECASE {\n   OMX_CameraUseCaseAuto,\n   OMX_CameraUseCaseVideo,\n   OMX_CameraUseCaseStills,\n   OMX_CameraUseCaseKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */\n   OMX_CameraUseCaseVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n   OMX_CameraUseCaseMax = 0x7FFFFFFF\n} OMX_CONFIG_CAMERAUSECASE;\n\ntypedef struct OMX_CONFIG_CAMERAUSECASETYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_CONFIG_CAMERAUSECASE eUseCase;\n} OMX_CONFIG_CAMERAUSECASETYPE;\n\n/* OMX_IndexParamBrcmDisableProprietaryTunnels: Disabling proprietary tunnelling */\ntypedef struct OMX_PARAM_BRCMDISABLEPROPRIETARYTUNNELSTYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nPortIndex;\n   OMX_BOOL bUseBuffers;\n}  OMX_PARAM_BRCMDISABLEPROPRIETARYTUNNELSTYPE;\n/*\nTell a source component to refuse to support proprietary tunnelling. Buffers will be used instead.\n*/\n\n\n//\n// Control for memory allocation and component-internal buffering\n//\n\n/* OMX_IndexParamBrcmRetainMemory: Controlling memory use on state transition */\ntypedef struct OMX_PARAM_BRCMRETAINMEMORYTYPE\n{\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_BOOL bEnable;\n} OMX_PARAM_BRCMRETAINMEMORYTYPE;\n/*\nAsk a component to retain its memory when going from IDLE to LOADED, if possible.\nThis has the benefit that you are then guaranteed that the transition to IDLE cannot\nfail due to lack of memory, but has the disadvantage that you cannot leave the component\nlying around in LOADED, unused, since it is using significant amounts of memory.\n*/\n\n/** Tell write media how large the output buffer should be. This is a hint, and\n  * may be ignored. A good size is bandwidth*<SDcard-delay>, which works out at\n  * around 1Mbyte for up to 16Mbit/s. Sizes may (and probably will) be rounded down\n  * to the nearest power of 2.\n  */\ntypedef struct OMX_PARAM_BRCMOUTPUTBUFFERSIZETYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nBufferSize;\n} OMX_PARAM_BRCMOUTPUTBUFFERSIZETYPE;\n\n/* OMX_IndexConfigCameraInfo: Camera device driver information */\n#define OMX_CONFIG_CAMERAINFOTYPE_NAME_LEN 16\ntypedef struct OMX_CONFIG_LENSCALIBRATIONVALUETYPE\n{\n   OMX_U16  nShutterDelayTime;\n   OMX_U16  nNdTransparency;\n   OMX_U16  nPwmPulseNearEnd;  /**< Num pulses to move lens 1um at near end */\n   OMX_U16  nPwmPulseFarEnd;   /**< Num pulses to move lens 1um at far end */\n   OMX_U16  nVoltagePIOutNearEnd[3];\n   OMX_U16  nVoltagePIOut10cm[3];\n   OMX_U16  nVoltagePIOutInfinity[3];\n   OMX_U16  nVoltagePIOutFarEnd[3];\n   OMX_U32  nAdcConversionNearEnd;\n   OMX_U32  nAdcConversionFarEnd;\n} OMX_CONFIG_LENSCALIBRATIONVALUETYPE;\n/*\nAsk the camera component for the driver info on the current camera device\n*/\n\n#define OMX_CONFIG_CAMERAINFOTYPE_NAME_LEN 16\n#define OMX_CONFIG_CAMERAINFOTYPE_SERIALNUM_LEN 20\n#define OMX_CONFIG_CAMERAINFOTYPE_EPROMVER_LEN 8\ntypedef struct OMX_CONFIG_CAMERAINFOTYPE\n{\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U8 cameraname[OMX_CONFIG_CAMERAINFOTYPE_NAME_LEN];\n   OMX_U8 lensname[OMX_CONFIG_CAMERAINFOTYPE_NAME_LEN];\n   OMX_U16 nModelId;\n   OMX_U8 nManufacturerId;\n   OMX_U8 nRevNum;\n   OMX_U8 sSerialNumber[OMX_CONFIG_CAMERAINFOTYPE_SERIALNUM_LEN];\n   OMX_U8 sEpromVersion[OMX_CONFIG_CAMERAINFOTYPE_EPROMVER_LEN];\n   OMX_CONFIG_LENSCALIBRATIONVALUETYPE sLensCalibration;\n   OMX_U32 xFNumber;\n   OMX_U32 xFocalLength;\n} OMX_CONFIG_CAMERAINFOTYPE;\n\n\ntypedef enum OMX_CONFIG_CAMERAFEATURESSHUTTER {\n   OMX_CameraFeaturesShutterUnknown,\n   OMX_CameraFeaturesShutterNotPresent,\n   OMX_CameraFeaturesShutterPresent,\n   OMX_CameraFeaturesShutterKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */\n   OMX_CameraFeaturesShutterVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n   OMX_CameraFeaturesShutterMax = 0x7FFFFFFF\n} OMX_CONFIG_CAMERAFEATURESSHUTTER;\n\ntypedef struct OMX_CONFIG_CAMERAFEATURESTYPE\n{\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_CONFIG_CAMERAFEATURESSHUTTER eHasMechanicalShutter;\n   OMX_BOOL bHasLens;\n} OMX_CONFIG_CAMERAFEATURESTYPE;\n\n\n//Should be added to the spec as part of IL416c\n/* OMX_IndexConfigRequestCallback: Enable config change notifications. */\ntypedef struct OMX_CONFIG_REQUESTCALLBACKTYPE\n{\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nPortIndex;\n   OMX_INDEXTYPE nIndex;\n   OMX_BOOL bEnable;\n} OMX_CONFIG_REQUESTCALLBACKTYPE;\n/*\nThis config implements IL416c to allow clients to request notification\nof when a config or parameter is changed. When the parameter specified\nin \\code{nIndex} for port \\code{nPortIndex} changes, an\n\\code{OMX_EventParamOrConfigChanged} event is generated for the client.\n*/\n\n/* OMX_IndexConfigCommonFocusRegionXY: Define focus regions */\ntypedef enum OMX_FOCUSREGIONTYPE {\n   OMX_FocusRegionNormal,\n   OMX_FocusRegionFace,\n   OMX_FocusRegionMax\n} OMX_FOCUSREGIONTYPE;\n\ntypedef struct OMX_FOCUSREGIONXY {\n   OMX_U32 xLeft;\n   OMX_U32 xTop;\n   OMX_U32 xWidth;\n   OMX_U32 xHeight;\n   OMX_U32 nWeight;\n   OMX_U32 nMask;\n   OMX_FOCUSREGIONTYPE eType;\n} OMX_FOCUSREGIONXY;\n\ntypedef struct OMX_CONFIG_FOCUSREGIONXYTYPE\n{\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nPortIndex;\n   OMX_U32 nIndex;\n   OMX_U32 nTotalRegions;\n   OMX_S32 nValidRegions;\n   OMX_BOOL bLockToFaces;\n   OMX_U32 xFaceTolerance;\n   OMX_FOCUSREGIONXY sRegion[1];\n} OMX_CONFIG_FOCUSREGIONXYTYPE;\n/*\nQuery / set the focus regions to use as a set of x/y/width/height boxes relative\nto the overall image.\n\n\\code{nIndex} - first region number being set/read, allowing retrieval/setting\nof many regions over several requests.\n\n\\code{nTotalRegions} - total number of regions currently defined.\n\n\\code{nValidRegions} - number of valid regions in the \\code{sRegion} array.\nWhen getting, the client sets this to the number of regions available.\nThe component writes region data and updates this field with how many\nregions have been written to.\nWhen setting, this is the number of regions defined with this structure\n\n\\code{bLockToFaces} - compare the region(s) given to the latest face tracking results.\nIf a face is found within xFaceTolerance of the defined region, then amend the\nregion to correspond to the face.\n\n\\code{xFaceTolerance} - 0p16 value to define the max difference between the region centre\nand face tracking result centre to take the FT results\n\n\\code{sRegions} - variable length array of focus regions.\n*/\n\ntypedef struct OMX_CONFIG_U8TYPE {\n    OMX_U32 nSize;                    /**< Size of this structure, in Bytes */\n    OMX_VERSIONTYPE nVersion;         /**< OMX specification version information */\n    OMX_U32 nPortIndex;               /**< port that this structure applies to */\n    OMX_U8  nU8;                     /**< U8 value */\n} OMX_PARAM_U8TYPE;\n\ntypedef struct OMX_CONFIG_CAMERASETTINGSTYPE {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;               /**< port that this structure applies to */\n    OMX_U32 nExposure;\n    OMX_U32 nAnalogGain;\n    OMX_U32 nDigitalGain;\n    OMX_U32 nLux;\n    OMX_U32 nRedGain;\n    OMX_U32 nBlueGain;\n    OMX_U32 nFocusPosition;\n} OMX_CONFIG_CAMERASETTINGSTYPE;\n\n/* OMX_IndexConfigDrawBoxLineParams: Face box style parameters. */\ntypedef struct OMX_YUVCOLOUR {\n   OMX_U8 nY;\n   OMX_U8 nU;\n   OMX_U8 nV;\n} OMX_YUVCOLOUR;\n\ntypedef struct OMX_CONFIG_DRAWBOXLINEPARAMS {\n    OMX_U32 nSize;                           /**< Size of this structure, in Bytes */\n    OMX_VERSIONTYPE nVersion;                /**< OMX specification version information */\n    OMX_U32 nPortIndex;                      /**< Port to which this config applies */\n    OMX_U32 xCornerSize;                     /**< Size of the corners as a fraction of the complete side */\n    OMX_U32 nPrimaryFaceLineWidth;           /**< Width of the box line for the primary face in pixels */\n    OMX_U32 nOtherFaceLineWidth;             /**< Width of the box line for other faces in pixels */\n    OMX_U32 nFocusRegionLineWidth;           /**< Width of the box line for focus regions in pixels */\n    OMX_YUVCOLOUR sPrimaryFaceColour;        /**< YUV colour for the primary face */\n    OMX_YUVCOLOUR sPrimaryFaceSmileColour;   /**< YUV colour for the primary face if smiling */\n    OMX_YUVCOLOUR sPrimaryFaceBlinkColour;   /**< YUV colour for the primary face if blinking */\n    OMX_YUVCOLOUR sOtherFaceColour;          /**< YUV colour for the all other faces */\n    OMX_YUVCOLOUR sOtherFaceSmileColour;     /**< YUV colour for the all other faces if smiling */\n    OMX_YUVCOLOUR sOtherFaceBlinkColour;     /**< YUV colour for the all other faces if blinking */\n    OMX_BOOL bShowFocusRegionsWhenIdle;      /**< Are focus regions displayed when just in viewfinder/AF idle */\n    OMX_YUVCOLOUR sFocusRegionColour;        /**< YUV colour for focus regions */\n    OMX_BOOL bShowAfState;                   /**< Change to the colours specified below if AF cycle has run */\n    OMX_BOOL bShowOnlyPrimaryAfState;        /**< Only show the primary face when displaying the AF status */\n    OMX_BOOL bCombineNonFaceRegions;         /**< Combine all regions not defined as faces into one single box covering them all */\n    OMX_YUVCOLOUR sAfLockPrimaryFaceColour;  /**< YUV colour for the primary face */\n    OMX_YUVCOLOUR sAfLockOtherFaceColour;    /**< YUV colour for the all other faces */\n    OMX_YUVCOLOUR sAfLockFocusRegionColour;  /**< YUV colour for focus regions */\n    OMX_YUVCOLOUR sAfFailPrimaryFaceColour;  /**< YUV colour for the primary face */\n    OMX_YUVCOLOUR sAfFailOtherFaceColour;    /**< YUV colour for the all other faces */\n    OMX_YUVCOLOUR sAfFailFocusRegionColour;  /**< YUV colour for focus regions */\n } OMX_CONFIG_DRAWBOXLINEPARAMS;\n/*\nQuery / set the parameters for the box to be drawn around faces/focus regions.\n*/\n\n #define OMX_PARAM_CAMERARMITYPE_RMINAME_LEN 16\n //OMX_IndexParamCameraRmiControl\n typedef struct OMX_PARAM_CAMERARMITYPE {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_BOOL bEnabled;\n    OMX_U8 sRmiName[OMX_PARAM_CAMERARMITYPE_RMINAME_LEN];\n    OMX_U32 nInputBufferHeight;\n    OMX_U32 nRmiBufferSize;\n    OMX_BRCM_POOL_T *pImagePool;\n } OMX_PARAM_CAMERARMITYPE;\n\n/* OMX_IndexConfigBrcmSyncOutput: Forcing a write sync */\ntypedef struct OMX_CONFIG_BRCMSYNCOUTPUTTYPE {\n    OMX_U32 nSize;                           /**< Size of this structure, in Bytes */\n    OMX_VERSIONTYPE nVersion;                /**< OMX specification version information */\n}  OMX_CONFIG_BRCMSYNCOUTPUTTYPE;\n/*\nSetting this config forces a sync of data to the filesystem.\n*/\n\n/* OMX_IndexConfigDrmView: View information for DRM rental files */\ntypedef struct OMX_CONFIG_DRMVIEWTYPE {\n   OMX_U32 nSize;             /**< Size of this structure, in Bytes */\n   OMX_VERSIONTYPE nVersion;  /**< OMX specification version information */\n   OMX_U32 nCurrentView;      /**< Current view count */\n   OMX_U32 nMaxView;          /**< Max. no. of view allowed */\n} OMX_CONFIG_DRMVIEWTYPE;\n/*\nThis structure contains information about the number of available\nviews in the selected DRM rental file, which typically have a given\nmaximum view count.  It allows the user to explicitly agree to playing\nthe file, which will increment the number of current views the file\nhas had.\n*/\n\ntypedef struct OMX_PARAM_BRCMU64TYPE {\n    OMX_U32 nSize;                    /**< Size of this structure, in Bytes */\n    OMX_VERSIONTYPE nVersion;         /**< OMX specification version information */\n    OMX_U32 nPortIndex;               /**< port that this structure applies to */\n    OMX_U32 nLowPart;                 /**< low bits of the unsigned 64 bit value */\n    OMX_U32 nHighPart;                /**< high bits of the unsigned 64 bit value */\n} OMX_PARAM_BRCMU64TYPE;\n\n/* OMX_IndexParamBrcmDisableEXIF: Disable generation of EXIF data */\n/*\nThis parameter is used by clients to control the generation of exif\ndata in JPEG images.\n*/\n\n/* OMX_IndexParamBrcmThumbnail: Control generation of thumbnail */\ntypedef struct OMX_PARAM_BRCMTHUMBNAILTYPE {\n    OMX_U32 nSize;                    /**< Size of this structure, in Bytes */\n    OMX_VERSIONTYPE nVersion;         /**< OMX specification version information */\n    OMX_BOOL bEnable;                 /**< Enable generation of thumbnails during still capture */\n    OMX_BOOL bUsePreview;             /**< Use the preview image (as is) as thumbnail */\n    OMX_U32 nWidth;                   /**< Desired width of the thumbnail */\n    OMX_U32 nHeight;                  /**< Desired height of the thumbnail */\n} OMX_PARAM_BRCMTHUMBNAILTYPE;\n/*\nThis parameter is used by clients to control how thumbnails are\ngenerated when creating still images.\n\nThumbnail generation will be turned on or off depending on the\n\\code{bEnable} field.\n\nThe \\code{bUsePreview} field will let the component know whether it\nshould use the low resolution preview image (if the component has one\navailable) as is for the thumbnail. When this is set to true, it should\nmake the generation of thumbnails faster (if a preview image is available)\nand should use less memory as well.\n\nThe \\code{nWidth} and \\code{nHeight} fields allow the client to\nspecify the dimensions of the thumbnail.  If both \\code{nWidth} and\n\\code{nHeight} are 0, we will calculate a sensible size for the\nthumbnail.\n*/\n\ntypedef struct OMX_PARAM_BRCMASPECTRATIOTYPE {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n    OMX_U32 nWidth;\n    OMX_U32 nHeight;\n} OMX_PARAM_BRCMASPECTRATIOTYPE;\n\n/* OMX_IndexParamBrcmVideoDecodeErrorConcealment: Control error concealment for video decode */\ntypedef struct OMX_PARAM_BRCMVIDEODECODEERRORCONCEALMENTTYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_BOOL bStartWithValidFrame; /**< Decoder will only start emitting frames from a non-corrupted frame */\n} OMX_PARAM_BRCMVIDEODECODEERRORCONCEALMENTTYPE;\n/*\n This parameter is used by clients to control the type of error concealment\n that will be done by the video decoder.\n */\n\n#define OMX_CONFIG_FLASHINFOTYPE_NAME_LEN 16\ntypedef struct OMX_CONFIG_FLASHINFOTYPE\n{\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U8 sFlashName[OMX_CONFIG_FLASHINFOTYPE_NAME_LEN];\n   OMX_CAMERAFLASHTYPE eFlashType;\n   OMX_U8 nDeviceId;\n   OMX_U8 nDeviceVersion;\n} OMX_CONFIG_FLASHINFOTYPE;\n\n/* OMX_IndexParamBrcmInterpolateMissingTimestamps: Configure component to interpolate missing timestamps */\n/*\nConfigures a component so that it tries to timestamp all the buffers it outputs.\nIf the timestamp information is missing from the original buffer, the\ncomponent will try its best to interpolate a value for the missing timestamp.\n */\n\n/* OMX_IndexParamBrcmSetCodecPerformanceMonitoring: Configure component to output performance statistics */\n/*\nConfigures a codec component so that it outputs performance statistics to\nthe given DECODE_PROGRESS_REPORT_T structure (passed as a pointer).\nThis structure can then be read by the client to find out where the codec is\nat in its processing.\n */\n\n/* OMX_IndexConfigDynamicRangeExpansion: Configure image dynamic range expansion processing */\ntypedef enum OMX_DYNAMICRANGEEXPANSIONMODETYPE {\n   OMX_DynRangeExpOff,\n   OMX_DynRangeExpLow,\n   OMX_DynRangeExpMedium,\n   OMX_DynRangeExpHigh,\n   OMX_DynRangeExpKhronosExtensions = 0x6F000000,\n   OMX_DynRangeExpVendorStartUnused = 0x7F000000,\n   OMX_DynRangeExpMax = 0x7FFFFFFF\n} OMX_DYNAMICRANGEEXPANSIONMODETYPE;\n\ntypedef struct OMX_CONFIG_DYNAMICRANGEEXPANSIONTYPE\n{\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_DYNAMICRANGEEXPANSIONMODETYPE eMode;\n} OMX_CONFIG_DYNAMICRANGEEXPANSIONTYPE;\n/*\nConfigures the intensity of an image dynamic range expansion processing stage\n*/\n\n/* OMX_IndexParamBrcmTransposeBufferCount: Configure the number of pre-allocated transpose buffers  */\n/*\nThis config allows the client to explicitly set the number of destination buffers pre-allocated for\nports that support 90/270 degree rotation (e.g. in video_render). The buffers will be pre-allocated during\na state transition from LOADED to IDLE (the transition will fail if there is not enough memory available\nfor the buffers).\n.\n*/\n\n\n/* OMX_IndexParamBrcmThreadAffinity: Control the CPU affinity of component thread(s) */\ntypedef enum OMX_BRCMTHREADAFFINITYTYPE {\n   OMX_BrcmThreadAffinityCPU0,\n   OMX_BrcmThreadAffinityCPU1,\n   OMX_BrcmThreadAffinityMax = 0x7FFFFFFF\n} OMX_BRCMTHREADAFFINITYTYPE;\n\ntypedef struct OMX_PARAM_BRCMTHREADAFFINITYTYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_BRCMTHREADAFFINITYTYPE eAffinity;  /**< Thread CPU affinity */\n} OMX_PARAM_BRCMTHREADAFFINITYTYPE;\n/*\n This parameter is used by clients to hint the CPU that a component thread should run on.\n */\n\n /* OMX_IndexConfigCommonSceneDetected: Reports the scene type detected by a scene detection algorithm. */\ntypedef enum OMX_SCENEDETECTTYPE {\n   OMX_SceneDetectUnknown,\n   OMX_SceneDetectLandscape,\n   OMX_SceneDetectPortrait,\n   OMX_SceneDetectMacro,\n   OMX_SceneDetectNight,\n   OMX_SceneDetectPortraitNight,\n   OMX_SceneDetectBacklit,\n   OMX_SceneDetectPortraitBacklit,\n   OMX_SceneDetectSunset,\n   OMX_SceneDetectBeach,\n   OMX_SceneDetectSnow,\n   OMX_SceneDetectFireworks,\n   OMX_SceneDetectMax = 0x7FFFFFFF\n} OMX_SCENEDETECTTYPE;\n\n/* OMX_IndexConfigCommonSceneDetected: Reports the scene type detected by a scene detection algorithm. */\ntypedef struct OMX_CONFIG_SCENEDETECTTYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_SCENEDETECTTYPE eScene;  /**< Scene type detected */\n} OMX_CONFIG_SCENEDETECTTYPE;\n/*\n This config is used to report to clients the scene type that has been detected.\n */\n\n/* OMX_IndexParamNalStreamFormat: Control the NAL unit packaging. This is a Khronos extension. */\ntypedef enum OMX_INDEXEXTTYPE {\n    /* Video parameters and configurations */\n    OMX_IndexExtVideoStartUnused = OMX_IndexKhronosExtensions + 0x00600000,\n    OMX_IndexParamNalStreamFormatSupported,         /**< reference: OMX_NALSTREAMFORMATTYPE */\n    OMX_IndexParamNalStreamFormat,                  /**< reference: OMX_NALSTREAMFORMATTYPE */\n    OMX_IndexParamNalStreamFormatSelect,            /**< reference: OMX_NALSTREAMFORMATTYPE */\n\n    OMX_IndexExtMax = 0x7FFFFFFF\n} OMX_INDEXEXTTYPE;\n\n/* OMX_IndexParamNalStreamFormat: Control the NAL unit packaging. This is a Khronos extension. */\ntypedef enum OMX_NALUFORMATSTYPE {\n    OMX_NaluFormatStartCodes = 1,\n    OMX_NaluFormatOneNaluPerBuffer = 2,\n    OMX_NaluFormatOneByteInterleaveLength = 4,\n    OMX_NaluFormatTwoByteInterleaveLength = 8,\n    OMX_NaluFormatFourByteInterleaveLength = 16,\n    OMX_NaluFormatCodingMax = 0x7FFFFFFF\n} OMX_NALUFORMATSTYPE;\n\n/* OMX_IndexParamNalStreamFormat: Control the NAL unit packaging. This is a Khronos extension. */\ntypedef struct OMX_NALSTREAMFORMATTYPE{\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n    OMX_NALUFORMATSTYPE eNaluFormat;\n} OMX_NALSTREAMFORMATTYPE;\n/*\n This parameter is used to control the NAL unit packaging of an H264 video port.\n */\n\n/* OMX_IndexParamVideoMvc: MVC codec parameters */\ntypedef  struct OMX_VIDEO_PARAM_AVCTYPE  OMX_VIDEO_PARAM_MVCTYPE;\n/*\nThis parameter is currently identical to the AVC parameter type.\n*/\n\n /* OMX_IndexConfigBrcmDrawStaticBox: Define static box to be drawn */\ntypedef enum OMX_STATICBOXTYPE {\n   OMX_StaticBoxNormal,\n   OMX_StaticBoxPrimaryFaceAfIdle,\n   OMX_StaticBoxNonPrimaryFaceAfIdle,\n   OMX_StaticBoxFocusRegionAfIdle,\n   OMX_StaticBoxPrimaryFaceAfSuccess,\n   OMX_StaticBoxNonPrimaryFaceAfSuccess,\n   OMX_StaticBoxFocusRegionAfSuccess,\n   OMX_StaticBoxPrimaryFaceAfFail,\n   OMX_StaticBoxNonPrimaryFaceAfFail,\n   OMX_StaticBoxFocusRegionAfFail,\n   OMX_StaticBoxMax\n} OMX_STATICBOXTYPE;\n\ntypedef struct OMX_STATICBOX {\n   OMX_U32 xLeft;\n   OMX_U32 xTop;\n   OMX_U32 xWidth;\n   OMX_U32 xHeight;\n   OMX_STATICBOXTYPE eType;\n} OMX_STATICBOX;\n\ntypedef struct OMX_CONFIG_STATICBOXTYPE\n{\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nPortIndex;\n   OMX_U32 nIndex;\n   OMX_U32 nTotalBoxes;\n   OMX_S32 nValidBoxes;\n   OMX_BOOL bDrawOtherBoxes;\n   OMX_STATICBOX sBoxes[1];\n} OMX_CONFIG_STATICBOXTYPE;\n/*\nQuery / set the parameters for a box to always be drawn on viewfinder images\nThe x/y/width/height values for the boxes are relative to the overall image.\n\n\\code{nIndex} - first box number being set/read, allowing retrieval/setting\nof many boxes over several requests.\n\n\\code{nValidBoxes} - total number of boxes currently defined.\n\n\\code{nValidBoxes} - number of valid boxes in the \\code{sBoxes} array.\nWhen getting, the client sets this to the number of boxes available.\nThe component writes box data and updates this field with how many\nboxes have been written to.\nWhen setting, this is the number of boxes defined with this structure\n\n\\code{sBoxes} - variable length array of static boxes.\n*/\n\n/* OMX_IndexConfigPortCapturing: Per-port capturing state */\ntypedef struct OMX_CONFIG_PORTBOOLEANTYPE{\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n    OMX_BOOL bEnabled;\n} OMX_CONFIG_PORTBOOLEANTYPE;\n/*\nThis is proposed in IL533f for controlling\nwhich ports of a multi-port camera component are capturing frames.\n*/\n\n/* OMX_IndexConfigCaptureMode: Capturing mode type */\ntypedef enum OMX_CAMERACAPTUREMODETYPE {\n   OMX_CameraCaptureModeWaitForCaptureEnd,\n   OMX_CameraCaptureModeWaitForCaptureEndAndUsePreviousInputImage,\n   OMX_CameraCaptureModeResumeViewfinderImmediately,\n   OMX_CameraCaptureModeMax,\n} OMX_CAMERACAPTUREMODETYPE;\n\ntypedef struct OMX_PARAM_CAMERACAPTUREMODETYPE{\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n    OMX_CAMERACAPTUREMODETYPE eMode;\n} OMX_PARAM_CAMERACAPTUREMODETYPE;\n/*\nThis controls the mode of operation for\nstill image capture in the camera component.\n*/\n\n/* OMX_IndexParamBrcmDrmEncryption: Set DRM encryption scheme */\ntypedef enum OMX_BRCMDRMENCRYPTIONTYPE\n{\n   OMX_DrmEncryptionNone = 0,\n   OMX_DrmEncryptionHdcp2,\n   OMX_DrmEncryptionKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */\n   OMX_DrmEncryptionVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n   OMX_DrmEncryptionRangeMax = 0x7FFFFFFF\n} OMX_BRCMDRMENCRYPTIONTYPE;\n\ntypedef struct OMX_PARAM_BRCMDRMENCRYPTIONTYPE\n{\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nPortIndex;\n   OMX_BRCMDRMENCRYPTIONTYPE eEncryption;\n   OMX_U32 nConfigDataLen;\n   OMX_U8 configData[1];\n} OMX_PARAM_BRCMDRMENCRYPTIONTYPE;\n/*\nQuery/set the DRM encryption scheme used by a port writing out data.\n*/\n\n\n/* OMX_IndexConfigBufferStall: Advertise buffer stall state */\ntypedef struct OMX_CONFIG_BUFFERSTALLTYPE\n{\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nPortIndex;\n   OMX_BOOL bStalled;      /**< Whether we are stalled */\n   OMX_U32 nDelay;         /**< Delay in real time (us) from last buffer to current time */\n} OMX_CONFIG_BUFFERSTALLTYPE;\n/*\nQuery/set the buffer stall threashold.  When set the \\code{nDelay}\nparameter specifies a time to class whether buffer output is stalled.\nWhen get, the \\code{nDelay} parameter indicates the current buffer\ndelay, and the {bStalled} parameter indicates whether this time is\nover a previously set threashold.  When\n\\code{OMX_IndexConfigRequestCallback} is used with this index, a\nnotification is given when \\code{bStalled} changes.\n*/\n\n/* OMX_IndexConfigLatencyTarget: Maintain target latency by adjusting clock speed */\ntypedef struct OMX_CONFIG_LATENCYTARGETTYPE\n{\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nPortIndex;\n   OMX_BOOL bEnabled; /**< whether this mode is enabled */\n   OMX_U32 nFilter; /**< number of latency samples to filter on, good value: 1 */\n   OMX_U32 nTarget; /**< target latency, us */\n   OMX_U32 nShift;  /**< shift for storing latency values, good value: 7 */\n   OMX_S32 nSpeedFactor; /**< multiplier for speed changes, in 24.8 format, good value: 256-512 */\n   OMX_S32 nInterFactor; /**< divider for comparing latency versus gradiant, good value: 300 */\n   OMX_S32 nAdjCap; /**< limit for speed change before nSpeedFactor is applied, good value: 100 */\n} OMX_CONFIG_LATENCYTARGETTYPE;\n/*\nQuery/set parameters used when adjusting clock speed to match the\nmeasured latency to a specified value.\n*/\n\n/* OMX_IndexConfigBrcmUseProprietaryCallback: Force use of proprietary callback */\ntypedef struct OMX_CONFIG_BRCMUSEPROPRIETARYCALLBACKTYPE\n{\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nPortIndex;\n   OMX_BOOL bEnable;\n} OMX_CONFIG_BRCMUSEPROPRIETARYCALLBACKTYPE;\n/*\nDisable/enable the use of proprietary callbacks rather than OpenMAX IL buffer handling.\n*/\n\n/* OMX_IndexParamCommonUseStcTimestamps: Select timestamp mode */\ntypedef enum OMX_TIMESTAMPMODETYPE\n{\n   OMX_TimestampModeZero = 0,       /**< Use a timestamp of 0 */\n   OMX_TimestampModeRawStc,         /**< Use the raw STC as the timestamp */\n   OMX_TimestampModeResetStc,       /**< Store the STC when video capture port goes active, and subtract that from STC for the timestamp */\n   OMX_TimestampModeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */\n   OMX_TimestampModeVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n   OMX_TimestampModeMax = 0x7FFFFFFF\n} OMX_TIMESTAMPMODETYPE;\n\ntypedef struct OMX_PARAM_TIMESTAMPMODETYPE\n{\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_TIMESTAMPMODETYPE eTimestampMode;\n} OMX_PARAM_TIMESTAMPMODETYPE;\n/*\n Specifies what to use as timestamps in the absence of a clock component.\n*/\n\n/* EGL image buffer for passing to video port.\n * Used when port color format is OMX_COLOR_FormatBRCMEGL.\n */\ntypedef struct OMX_BRCMVEGLIMAGETYPE\n{\n   /* Passed between ARM + VC; use fixed width types. */\n   OMX_U32 nWidth;\n   OMX_U32 nHeight;\n   OMX_U32 nStride;\n   OMX_U32 nUmemHandle;\n   OMX_U32 nUmemOffset;\n   OMX_U32 nFlipped;    /* Non-zero -> vertically flipped image */\n} OMX_BRCMVEGLIMAGETYPE;\n\n/* Provides field of view \n */\ntypedef struct OMX_CONFIG_BRCMFOVTYPE\n{\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nPortIndex;\n   OMX_U32 xFieldOfViewHorizontal;  /**< Horizontal field of view in degrees. 16p16 value */\n   OMX_U32 xFieldOfViewVertical;    /**< Vertical field of view in degrees. 16p16 value */\n} OMX_CONFIG_BRCMFOVTYPE;\n\n/* OMX_IndexConfigBrcmDecoderPassThrough: Enabling Audio Passthrough */\n/*\nThis allows an audio decoder to disable decoding the stream and pass through correctly framed\ndata to enable playback of compressed audio to supported output devices.\n*/\n\n/* OMX_IndexConfigBrcmClockReferenceSource: Select Clock Reference Source */\n/*\nThis control allows communicating directly to an audio renderer component whether it should\nact as a clock reference source or act as a slave.\n*/\n\n/* OMX_IndexConfigEncLevelExtension: AVC Override encode capabilities */\ntypedef struct OMX_VIDEO_CONFIG_LEVEL_EXTEND {\n   OMX_U32 nSize; \n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nPortIndex;\n   OMX_U32 nCustomMaxMBPS;     /**< Specifies maximum macro-blocks per second */\n   OMX_U32 nCustomMaxFS;       /**< Specifies maximum frame size (macro-blocks per frame) */\n   OMX_U32 nCustomMaxBRandCPB; /**< Specifies maximum bitrate in units of 1000 bits/s and Codec Picture Buffer (CPB derived from bitrate) */\n} OMX_VIDEO_CONFIG_LEVEL_EXTEND;\n/*\nThis allows finer control of the H264 encode internal parameters.\n*/\n\n/* OMX_IndexParamBrcmEEDEEnable: Enable/Disable end to end distortion estimator */\ntypedef struct OMX_VIDEO_EEDE_ENABLE {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n    OMX_U32 enable;\n} OMX_VIDEO_EEDE_ENABLE;\n/*\nThis enables or disables the use of end to end distortion estimation.\n*/\n\n/* OMX_IndexParamBrcmEEDELossRate: Loss rate configuration for end to end distortion */\ntypedef struct OMX_VIDEO_EEDE_LOSSRATE {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n   OMX_U32 loss_rate; /**< loss rate, 5 means 5% */\n} OMX_VIDEO_EEDE_LOSSRATE;\n/*\nSet the packet loss rate used by the end to end distortion estimator.\n*/\n\n/* OMX_IndexParamColorSpace: Colour space information */\ntypedef enum OMX_COLORSPACETYPE\n{\n   OMX_COLORSPACE_UNKNOWN,\n   OMX_COLORSPACE_JPEG_JFIF,\n   OMX_COLORSPACE_ITU_R_BT601,\n   OMX_COLORSPACE_ITU_R_BT709,\n   OMX_COLORSPACE_FCC,\n   OMX_COLORSPACE_SMPTE240M,\n   OMX_COLORSPACE_BT470_2_M,\n   OMX_COLORSPACE_BT470_2_BG,\n   OMX_COLORSPACE_JFIF_Y16_255,\n   OMX_COLORSPACE_MAX = 0x7FFFFFFF\n} OMX_COLORSPACETYPE;\n\ntypedef struct OMX_PARAM_COLORSPACETYPE\n{\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nPortIndex;\n   OMX_COLORSPACETYPE eColorSpace;\n} OMX_PARAM_COLORSPACETYPE;\n/*\nSets the colourspace with which pixel buffers should be generated / interpreted.\n*/\n\ntypedef enum OMX_CAPTURESTATETYPE\n{\n   OMX_NotCapturing,\n   OMX_CaptureStarted,\n   OMX_CaptureComplete,\n   OMX_CaptureMax = 0x7FFFFFFF\n} OMX_CAPTURESTATETYPE;\n\ntypedef struct OMX_PARAM_CAPTURESTATETYPE\n{\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nPortIndex;\n   OMX_CAPTURESTATETYPE eCaptureState;\n} OMX_PARAM_CAPTURESTATETYPE;\n\n/*\nProvides information on the colour space that's in use during image/video processing.\n*/\n\n/* OMX_IndexConfigMinimiseFragmentation: Minimising Fragmentation */\n/*\nThis control can be supported to enable the client to request that the component works\nto minimise fragmentation of output buffers.\n*/\n\n/* OMX_IndexConfigBrcmBufferFlagFilter: Filter buffers based on flags */\n/*\nThis control can be set to request that buffers are conditionally forwarded on \noutput ports based on matching flags set on that buffer.\n*/\n\n/* OMX_IndexParamPortMaxFrameSize: Specifying maximum frame size */\n/*\nThis control can be used to control the maximum frame size allowed on an output port.\n*/\n\n/* OMX_IndexConfigBrcmCameraRnDPreprocess: Enable use of development ISP software stage */\n/*\nThis control can be used to enable a developmental software stage to be inserted into\nthe preprocessor stage of the ISP.\n*/\n\n/* OMX_IndexConfigBrcmCameraRnDPostprocess: Enable use of development ISP software stage */\n/*\nThis control can be used to enable a developmental software stage to be inserted into\nthe postprocessor stage of the ISP.\n*/\n\n/* OMX_IndexParamDisableVllPool: Controlling use of memory for loadable modules */\n/*\nThis control can be used to control whether loadable modules used a dedicated memory\npool or use heap allocated memory.\n*/\n\n/* OMX_IndexParamBrcmVideoPrecodeForQP: Pre-code 1st frame for QP.*/\n/*\nThis control selects a pre-encode of the first frame to set up a better initial QP value.\n*/\n\n/* OMX_IndexParamBrcmVideoTimestampFifo: Video timestamp FIFO mode. */\n/*\nWhen enabled, the timestamp fifo mode will change the way\nincoming timestamps are associated with output images so the incoming timestamps\nget used without re-ordering on output images.\n*/\n\n/* OMX_IndexParamCameraCustomSensorConfig: Custom camera sensor configuration. */\n/*\nThis parameter is passed down to the camera sensor driver to be interpreted as a\nrequest for a different configuration to normal. How the configuration varies is\nsensor specific.\n*/\n\n/* OMX_IndexParamCameraDeviceNumber: Camera device selection .*/\n/*\nControls which camera driver, or camera peripheral, to use.\n*/\n\n/* OMX_IndexParamBrcmMaxNumCallbacks: Codec callback limit. */\n/*\nThe codec can queue up a significant number of frames internally if the sink is\nnot consuming the output fast enough. This control limits the number of frames\nthat can be queued up.\n*/\n\ntypedef struct OMX_PARAM_BRCMCONFIGFILETYPE {\n   OMX_U32 nSize;                      /**< size of the structure in bytes, including\n                                            actual URI name */\n   OMX_VERSIONTYPE nVersion;           /**< OMX specification version information */\n   OMX_U32 fileSize;                   /**< Size of complete file data */\n} OMX_PARAM_BRCMCONFIGFILETYPE;\n\ntypedef struct OMX_PARAM_BRCMCONFIGFILECHUNKTYPE {\n   OMX_U32 nSize;                      /**< size of the structure in bytes, including\n                                            actual chunk data */\n   OMX_VERSIONTYPE nVersion;           /**< OMX specification version information */\n   OMX_U32 size;                       /**< Number of bytes being transferred in this chunk */\n   OMX_U32 offset;                     /**< Offset of this chunk in the file */\n   OMX_U8 data[1];                     /**< Chunk data */\n} OMX_PARAM_BRCMCONFIGFILECHUNKTYPE;\n\ntypedef struct OMX_PARAM_BRCMFRAMERATERANGETYPE {\n   OMX_U32 nSize;                      /**< size of the structure in bytes, including\n                                            actual chunk data */\n   OMX_VERSIONTYPE nVersion;           /**< OMX specification version information */\n   OMX_U32 nPortIndex;\n   OMX_U32 xFramerateLow;              /**< Low end of framerate range. Q16 format */\n   OMX_U32 xFramerateHigh;             /**< High end of framerate range. Q16 format */\n} OMX_PARAM_BRCMFRAMERATERANGETYPE;\n\ntypedef struct OMX_PARAM_S32TYPE {\n    OMX_U32 nSize;                    /**< Size of this structure, in Bytes */\n    OMX_VERSIONTYPE nVersion;         /**< OMX specification version information */\n    OMX_U32 nPortIndex;               /**< port that this structure applies to */\n    OMX_S32 nS32;                     /**< S32 value */\n} OMX_PARAM_S32TYPE;\n\ntypedef struct OMX_PARAM_BRCMVIDEODRMPROTECTBUFFERTYPE\n{\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n\n   OMX_U32 size_wanted;     /**< Input. Zero size means internal video decoder buffer,\n                                 mem_handle and phys_addr not returned in this case */\n   OMX_U32 protect;         /**< Input. 1 = protect, 0 = unprotect */\n\n   OMX_U32 mem_handle;      /**< Output. Handle for protected buffer */\n   OMX_PTR phys_addr;       /**< Output. Physical memory address of protected buffer */\n} OMX_PARAM_BRCMVIDEODRMPROTECTBUFFERTYPE;\n\ntypedef struct OMX_CONFIG_ZEROSHUTTERLAGTYPE\n{\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n\n   OMX_U32 bZeroShutterMode;        /**< Select ZSL mode from the camera. */\n   OMX_U32 bConcurrentCapture;      /**< Perform concurrent captures for full ZSL. */\n\n} OMX_CONFIG_ZEROSHUTTERLAGTYPE;\n\n/* OMX_IndexParamBrcmVideoDecodeConfigVD3: VDec3 configuration. */\ntypedef struct OMX_PARAM_BRCMVIDEODECODECONFIGVD3TYPE {\n   OMX_U32 nSize;                      /**< size of the structure in bytes, including\n                                            configuration data */\n   OMX_VERSIONTYPE nVersion;           /**< OMX specification version information */\n   OMX_U8 config[1];                   /**< Configuration data (a VD3_CONFIGURE_T) */\n} OMX_PARAM_BRCMVIDEODECODECONFIGVD3TYPE;\n/*\nCodec specific configuration block to set up internal state in a non-standard manner.\n*/\n\ntypedef struct OMX_CONFIG_CUSTOMAWBGAINSTYPE {\n   OMX_U32 nSize;                      /**< size of the structure in bytes, including\n                                            configuration data */\n   OMX_VERSIONTYPE nVersion;           /**< OMX specification version information */\n   OMX_U32 xGainR;                     /**< Red gain - 16p16 */\n   OMX_U32 xGainB;                     /**< Blue gain - 16p16 */\n} OMX_CONFIG_CUSTOMAWBGAINSTYPE;\n\n/* OMX_IndexConfigBrcmRenderStats: Render port statistics */\ntypedef struct OMX_CONFIG_BRCMRENDERSTATSTYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nPortIndex;\n   OMX_BOOL nValid;\n   OMX_U32 nMatch;\n   OMX_U32 nPeriod;\n   OMX_U32 nPhase;\n   OMX_U32 nPixelClockNominal;\n   OMX_U32 nPixelClock;\n   OMX_U32 nHvsStatus;\n   OMX_U32 dummy0[2];\n} OMX_CONFIG_BRCMRENDERSTATSTYPE;\n/*\nThis provides statistics from the renderer to allow more accurate synchronisation\nbetween the scheduler and display VSYNC.\n*/\n\n#define OMX_BRCM_MAXANNOTATETEXTLEN 256\ntypedef struct OMX_CONFIG_BRCMANNOTATETYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_BOOL bEnable;\n   OMX_BOOL bShowShutter;\n   OMX_BOOL bShowAnalogGain;\n   OMX_BOOL bShowLens;\n   OMX_BOOL bShowCaf;\n   OMX_BOOL bShowMotion;\n   OMX_BOOL bShowFrameNum;\n   OMX_BOOL bEnableBackground;\n   OMX_BOOL bCustomBackgroundColour;\n   OMX_U8 nBackgroundY;\n   OMX_U8 nBackgroundU;\n   OMX_U8 nBackgroundV;\n   OMX_U8 dummy1;\n   OMX_BOOL bCustomTextColour;\n   OMX_U8 nTextY;\n   OMX_U8 nTextU;\n   OMX_U8 nTextV;\n   OMX_U8 nTextSize;   /**< Text size: 6-150 pixels */\n   OMX_U8 sText[OMX_BRCM_MAXANNOTATETEXTLEN];\n} OMX_CONFIG_BRCMANNOTATETYPE;\n\n/* OMX_IndexParamBrcmStereoscopicMode: Stereoscopic camera support */\ntypedef enum OMX_BRCMSTEREOSCOPICMODETYPE {\n   OMX_STEREOSCOPIC_NONE = 0,\n   OMX_STEREOSCOPIC_SIDEBYSIDE = 1,\n   OMX_STEREOSCOPIC_TOPBOTTOM = 2,\n   OMX_STEREOSCOPIC_MAX = 0x7FFFFFFF,\n} OMX_BRCMSTEREOSCOPICMODETYPE;\n\ntypedef struct OMX_CONFIG_BRCMSTEREOSCOPICMODETYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n\n   OMX_U32 nPortIndex;                    /**< port that this structure applies to */\n   OMX_BRCMSTEREOSCOPICMODETYPE eMode;    /**< Packing mode */\n   OMX_BOOL bDecimate;                    /**< Half/half mode\n                                          (pixel aspect ratio = 1:2 or 2:1 if set. 1:1 if not set) */\n   OMX_BOOL bSwapEyes;                    /**< False = left eye first. True = right eye first. */\n} OMX_CONFIG_BRCMSTEREOSCOPICMODETYPE;\n/*\nThis control sets up how stereoscopic images should be generated.\n*/\n\n/* OMX_IndexParamCameraInterface: Camera interface type. */\ntypedef enum OMX_CAMERAINTERFACETYPE {\n   OMX_CAMERAINTERFACE_CSI = 0,\n   OMX_CAMERAINTERFACE_CCP2 = 1,\n   OMX_CAMERAINTERFACE_CPI = 2,\n   OMX_CAMERAINTERFACE_MAX = 0x7FFFFFFF,\n} OMX_CAMERAINTERFACETYPE;\n\ntypedef struct OMX_PARAM_CAMERAINTERFACETYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n\n   OMX_U32 nPortIndex;                    /**< port that this structure applies to */\n   OMX_CAMERAINTERFACETYPE eMode;         /**< Interface mode */\n} OMX_PARAM_CAMERAINTERFACETYPE;\n/*\nThis configures the physical camera interface type.\n*/\n\ntypedef enum OMX_CAMERACLOCKINGMODETYPE {\n   OMX_CAMERACLOCKINGMODE_STROBE = 0,\n   OMX_CAMERACLOCKINGMODE_CLOCK = 1,\n   OMX_CAMERACLOCKINGMODE_MAX = 0x7FFFFFFF,\n} OMX_CAMERACLOCKINGMODETYPE;\n\ntypedef struct OMX_PARAM_CAMERACLOCKINGMODETYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n\n   OMX_U32 nPortIndex;                    /**< port that this structure applies to */\n   OMX_CAMERACLOCKINGMODETYPE eMode;      /**< Clocking mode */\n} OMX_PARAM_CAMERACLOCKINGMODETYPE;\n\n/* OMX_IndexParamCameraRxConfig: Camera receiver configuration */\ntypedef enum OMX_CAMERARXDECODETYPE {\n   OMX_CAMERARXDECODE_NONE = 0,\n   OMX_CAMERARXDECODE_DPCM8TO10 = 1,\n   OMX_CAMERARXDECODE_DPCM7TO10 = 2,\n   OMX_CAMERARXDECODE_DPCM6TO10 = 3,\n   OMX_CAMERARXDECODE_DPCM8TO12 = 4,\n   OMX_CAMERARXDECODE_DPCM7TO12 = 5,\n   OMX_CAMERARXDECODE_DPCM6TO12 = 6,\n   OMX_CAMERARXDECODE_DPCM10TO14 = 7,\n   OMX_CAMERARXDECODE_DPCM8TO14 = 8,\n   OMX_CAMERARXDECODE_DPCM12TO16 = 9,\n   OMX_CAMERARXDECODE_DPCM10TO16 = 10,\n   OMX_CAMERARXDECODE_DPCM8TO16 = 11,\n   OMX_CAMERARXDECODE_MAX = 0x7FFFFFFF\n} OMX_CAMERARXDECODETYPE;\n\ntypedef enum OMX_CAMERARXENCODETYPE {\n   OMX_CAMERARXENCODE_NONE = 0,\n   OMX_CAMERARXENCODE_DPCM10TO8 = 1,\n   OMX_CAMERARXENCODE_DPCM12TO8 = 2,\n   OMX_CAMERARXENCODE_DPCM14TO8 = 3,\n   OMX_CAMERARXENCODE_MAX = 0x7FFFFFFF\n} OMX_CAMERARXENCODETYPE;\n\ntypedef enum OMX_CAMERARXUNPACKTYPE {\n   OMX_CAMERARXUNPACK_NONE = 0,\n   OMX_CAMERARXUNPACK_6 = 1,\n   OMX_CAMERARXUNPACK_7 = 2,\n   OMX_CAMERARXUNPACK_8 = 3,\n   OMX_CAMERARXUNPACK_10 = 4,\n   OMX_CAMERARXUNPACK_12 = 5,\n   OMX_CAMERARXUNPACK_14 = 6,\n   OMX_CAMERARXUNPACK_16 = 7,\n   OMX_CAMERARXUNPACK_MAX = 0x7FFFFFFF\n} OMX_CAMERARXUNPACKYPE;\n\ntypedef enum OMX_CAMERARXPACKTYPE {\n   OMX_CAMERARXPACK_NONE = 0,\n   OMX_CAMERARXPACK_8 = 1,\n   OMX_CAMERARXPACK_10 = 2,\n   OMX_CAMERARXPACK_12 = 3,\n   OMX_CAMERARXPACK_14 = 4,\n   OMX_CAMERARXPACK_16 = 5,\n   OMX_CAMERARXPACK_RAW10 = 6,\n   OMX_CAMERARXPACK_RAW12 = 7,\n   OMX_CAMERARXPACK_MAX = 0x7FFFFFFF\n} OMX_CAMERARXPACKTYPE;\n\ntypedef struct OMX_PARAM_CAMERARXCONFIG_TYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n\n   OMX_U32 nPortIndex;                    /**< port that this structure applies to */\n   OMX_CAMERARXDECODETYPE eDecode;\n   OMX_CAMERARXENCODETYPE eEncode;\n   OMX_CAMERARXUNPACKYPE eUnpack;\n   OMX_CAMERARXPACKTYPE ePack;\n   OMX_U32 nDataLanes;\n   OMX_U32 nEncodeBlockLength;\n   OMX_U32 nEmbeddedDataLines;\n   OMX_U32 nImageId;\n} OMX_PARAM_CAMERARXCONFIG_TYPE;\n/*\nConfigures the setup and processing options of the camera receiver peripheral.\n*/\n\ntypedef struct OMX_PARAM_CAMERARXTIMING_TYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n\n   OMX_U32 nPortIndex;                    /**< port that this structure applies to */\n   OMX_U32 nTiming1;\n   OMX_U32 nTiming2;\n   OMX_U32 nTiming3;\n   OMX_U32 nTiming4;\n   OMX_U32 nTiming5;\n   OMX_U32 nTerm1;\n   OMX_U32 nTerm2;\n   OMX_U32 nCpiTiming1;\n   OMX_U32 nCpiTiming2;\n} OMX_PARAM_CAMERARXTIMING_TYPE;\n\n\n/* OMX_IndexParamBrcmBayerOrder: Bayer order */\ntypedef enum OMX_BAYERORDERTYPE {\n   OMX_BayerOrderRGGB = 0,\n   OMX_BayerOrderGBRG = 1,\n   OMX_BayerOrderBGGR = 2,\n   OMX_BayerOrderGRBG = 3,\n\n   OMX_BayerOrderMax = 0x7FFFFFFF\n} OMX_BAYERORDERTYPE;\n\ntypedef struct OMX_PARAM_BAYERORDERTYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n\n   OMX_U32 nPortIndex;                    /**< port that this structure applies to */\n   OMX_BAYERORDERTYPE eBayerOrder;\n} OMX_PARAM_BAYERORDERTYPE;\n/*\nThe IL standard does not support a way to specify the Bayer order of Bayer images.\nThis control adds that missing functionality.\n*/\n\n/* OMX_IndexConfigBrcmPowerMonitor: Deprecated.*/\n/*\nDeprecated. Do not use.\n*/\n\n/* OMX_IndexParamBrcmZeroCopy: Deprecated */\n/*\nDeprecated. Do not use.\n*/\n\n#endif\n/* File EOF */\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/IL/OMX_Component.h",
    "content": "/*\n * Copyright (c) 2008 The Khronos Group Inc. \n * \n * Permission is hereby granted, free of charge, to any person obtaining\n * a copy of this software and associated documentation files (the\n * \"Software\"), to deal in the Software without restriction, including\n * without limitation the rights to use, copy, modify, merge, publish,\n * distribute, sublicense, and/or sell copies of the Software, and to\n * permit persons to whom the Software is furnished to do so, subject\n * to the following conditions: \n * The above copyright notice and this permission notice shall be included\n * in all copies or substantial portions of the Software. \n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\n * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\n * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\n * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \n *\n */\n\n/** OMX_Component.h - OpenMax IL version 1.1.2\n *  The OMX_Component header file contains the definitions used to define\n *  the public interface of a component.  This header file is intended to\n *  be used by both the application and the component.\n */\n\n#ifndef OMX_Component_h\n#define OMX_Component_h\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif /* __cplusplus */\n\n\n\n/* Each OMX header must include all required header files to allow the\n *  header to compile without errors.  The includes below are required\n *  for this header file to compile successfully \n */\n\n#include \"OMX_Audio.h\"\n#include \"OMX_Video.h\"\n#include \"OMX_Image.h\"\n#include \"OMX_Other.h\"\n\n/** @ingroup comp */\ntypedef enum OMX_PORTDOMAINTYPE { \n    OMX_PortDomainAudio, \n    OMX_PortDomainVideo, \n    OMX_PortDomainImage, \n    OMX_PortDomainOther,\n    OMX_PortDomainKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_PortDomainVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_PortDomainMax = 0x7ffffff\n} OMX_PORTDOMAINTYPE;\n\n/** @ingroup comp */\ntypedef struct OMX_PARAM_PORTDEFINITIONTYPE {\n    OMX_U32 nSize;                 /**< Size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion;      /**< OMX specification version information */\n    OMX_U32 nPortIndex;            /**< Port number the structure applies to */\n    OMX_DIRTYPE eDir;              /**< Direction (input or output) of this port */\n    OMX_U32 nBufferCountActual;    /**< The actual number of buffers allocated on this port */\n    OMX_U32 nBufferCountMin;       /**< The minimum number of buffers this port requires */\n    OMX_U32 nBufferSize;           /**< Size, in bytes, for buffers to be used for this channel */\n    OMX_BOOL bEnabled;             /**< Ports default to enabled and are enabled/disabled by\n                                        OMX_CommandPortEnable/OMX_CommandPortDisable.\n                                        When disabled a port is unpopulated. A disabled port\n                                        is not populated with buffers on a transition to IDLE. */\n    OMX_BOOL bPopulated;           /**< Port is populated with all of its buffers as indicated by\n                                        nBufferCountActual. A disabled port is always unpopulated. \n                                        An enabled port is populated on a transition to OMX_StateIdle\n                                        and unpopulated on a transition to loaded. */\n    OMX_PORTDOMAINTYPE eDomain;    /**< Domain of the port. Determines the contents of metadata below. */\n    union {\n        OMX_AUDIO_PORTDEFINITIONTYPE audio;\n        OMX_VIDEO_PORTDEFINITIONTYPE video;\n        OMX_IMAGE_PORTDEFINITIONTYPE image;\n        OMX_OTHER_PORTDEFINITIONTYPE other;\n    } format;\n    OMX_BOOL bBuffersContiguous;\n    OMX_U32 nBufferAlignment;\n} OMX_PARAM_PORTDEFINITIONTYPE;\n\n/** @ingroup comp */\ntypedef struct OMX_PARAM_U32TYPE { \n    OMX_U32 nSize;                    /**< Size of this structure, in Bytes */ \n    OMX_VERSIONTYPE nVersion;         /**< OMX specification version information */ \n    OMX_U32 nPortIndex;               /**< port that this structure applies to */ \n    OMX_U32 nU32;                     /**< U32 value */\n} OMX_PARAM_U32TYPE;\n\n/** @ingroup rpm */\ntypedef enum OMX_SUSPENSIONPOLICYTYPE {\n    OMX_SuspensionDisabled, /**< No suspension; v1.0 behavior */\n    OMX_SuspensionEnabled,  /**< Suspension allowed */   \n    OMX_SuspensionPolicyKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_SuspensionPolicyStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_SuspensionPolicyMax = 0x7fffffff\n} OMX_SUSPENSIONPOLICYTYPE;\n\n/** @ingroup rpm */\ntypedef struct OMX_PARAM_SUSPENSIONPOLICYTYPE {\n    OMX_U32 nSize;                  \n    OMX_VERSIONTYPE nVersion;        \n    OMX_SUSPENSIONPOLICYTYPE ePolicy;\n} OMX_PARAM_SUSPENSIONPOLICYTYPE;\n\n/** @ingroup rpm */\ntypedef enum OMX_SUSPENSIONTYPE {\n    OMX_NotSuspended, /**< component is not suspended */\n    OMX_Suspended,    /**< component is suspended */\n    OMX_SuspensionKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_SuspensionVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_SuspendMax = 0x7FFFFFFF\n} OMX_SUSPENSIONTYPE;\n\n/** @ingroup rpm */\ntypedef struct OMX_PARAM_SUSPENSIONTYPE {\n    OMX_U32 nSize;                  \n    OMX_VERSIONTYPE nVersion;       \n    OMX_SUSPENSIONTYPE eType;             \n} OMX_PARAM_SUSPENSIONTYPE ;\n\ntypedef struct OMX_CONFIG_BOOLEANTYPE {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_BOOL bEnabled;    \n} OMX_CONFIG_BOOLEANTYPE;\n\n/* Parameter specifying the content uri to use. */\n/** @ingroup cp */\ntypedef struct OMX_PARAM_CONTENTURITYPE\n{\n    OMX_U32 nSize;                      /**< size of the structure in bytes, including\n                                             actual URI name */\n    OMX_VERSIONTYPE nVersion;           /**< OMX specification version information */\n    OMX_U8 contentURI[1];               /**< The URI name */\n} OMX_PARAM_CONTENTURITYPE;\n\n/* Parameter specifying the pipe to use. */\n/** @ingroup cp */\ntypedef struct OMX_PARAM_CONTENTPIPETYPE\n{\n    OMX_U32 nSize;              /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion;   /**< OMX specification version information */\n    OMX_HANDLETYPE hPipe;       /**< The pipe handle*/\n} OMX_PARAM_CONTENTPIPETYPE;\n\n/** @ingroup rpm */\ntypedef struct OMX_RESOURCECONCEALMENTTYPE {\n    OMX_U32 nSize;             /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion;  /**< OMX specification version information */\n    OMX_BOOL bResourceConcealmentForbidden; /**< disallow the use of resource concealment \n                                            methods (like degrading algorithm quality to \n                                            lower resource consumption or functional bypass) \n                                            on a component as a resolution to resource conflicts. */\n} OMX_RESOURCECONCEALMENTTYPE;\n\n\n/** @ingroup metadata */\ntypedef enum OMX_METADATACHARSETTYPE {\n    OMX_MetadataCharsetUnknown = 0,\n    OMX_MetadataCharsetASCII,\n    OMX_MetadataCharsetBinary,\n    OMX_MetadataCharsetCodePage1252,\n    OMX_MetadataCharsetUTF8,\n    OMX_MetadataCharsetJavaConformantUTF8,\n    OMX_MetadataCharsetUTF7,\n    OMX_MetadataCharsetImapUTF7,\n    OMX_MetadataCharsetUTF16LE, \n    OMX_MetadataCharsetUTF16BE,\n    OMX_MetadataCharsetGB12345,\n    OMX_MetadataCharsetHZGB2312,\n    OMX_MetadataCharsetGB2312,\n    OMX_MetadataCharsetGB18030,\n    OMX_MetadataCharsetGBK,\n    OMX_MetadataCharsetBig5,\n    OMX_MetadataCharsetISO88591,\n    OMX_MetadataCharsetISO88592,\n    OMX_MetadataCharsetISO88593,\n    OMX_MetadataCharsetISO88594,\n    OMX_MetadataCharsetISO88595,\n    OMX_MetadataCharsetISO88596,\n    OMX_MetadataCharsetISO88597,\n    OMX_MetadataCharsetISO88598,\n    OMX_MetadataCharsetISO88599,\n    OMX_MetadataCharsetISO885910,\n    OMX_MetadataCharsetISO885913,\n    OMX_MetadataCharsetISO885914,\n    OMX_MetadataCharsetISO885915,\n    OMX_MetadataCharsetShiftJIS,\n    OMX_MetadataCharsetISO2022JP,\n    OMX_MetadataCharsetISO2022JP1,\n    OMX_MetadataCharsetISOEUCJP,\n    OMX_MetadataCharsetSMS7Bit,\n    OMX_MetadataCharsetKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_MetadataCharsetVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_MetadataCharsetTypeMax= 0x7FFFFFFF\n} OMX_METADATACHARSETTYPE;\n\n/** @ingroup metadata */\ntypedef enum OMX_METADATASCOPETYPE\n{\n    OMX_MetadataScopeAllLevels,\n    OMX_MetadataScopeTopLevel,\n    OMX_MetadataScopePortLevel,\n    OMX_MetadataScopeNodeLevel,\n    OMX_MetadataScopeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_MetadataScopeVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_MetadataScopeTypeMax = 0x7fffffff\n} OMX_METADATASCOPETYPE;\n\n/** @ingroup metadata */\ntypedef enum OMX_METADATASEARCHMODETYPE\n{\n    OMX_MetadataSearchValueSizeByIndex,\n    OMX_MetadataSearchItemByIndex,\n    OMX_MetadataSearchNextItemByKey,\n    OMX_MetadataSearchKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_MetadataSearchVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_MetadataSearchTypeMax = 0x7fffffff\n} OMX_METADATASEARCHMODETYPE;\n/** @ingroup metadata */\ntypedef struct OMX_CONFIG_METADATAITEMCOUNTTYPE\n{\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_METADATASCOPETYPE eScopeMode;\n    OMX_U32 nScopeSpecifier;\n    OMX_U32 nMetadataItemCount;\n} OMX_CONFIG_METADATAITEMCOUNTTYPE;\n\n/** @ingroup metadata */\ntypedef struct OMX_CONFIG_METADATAITEMTYPE\n{\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_METADATASCOPETYPE eScopeMode;\n    OMX_U32 nScopeSpecifier;\n    OMX_U32 nMetadataItemIndex;  \n    OMX_METADATASEARCHMODETYPE eSearchMode;\n    OMX_METADATACHARSETTYPE eKeyCharset;\n    OMX_U8 nKeySizeUsed;\n    OMX_U8 nKey[128];\n    OMX_METADATACHARSETTYPE eValueCharset;\n    OMX_STRING sLanguageCountry;\n    OMX_U32 nValueMaxSize;\n    OMX_U32 nValueSizeUsed;\n    OMX_U8 nValue[1];\n} OMX_CONFIG_METADATAITEMTYPE;\n\n/* @ingroup metadata */\ntypedef struct OMX_CONFIG_CONTAINERNODECOUNTTYPE\n{\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_BOOL bAllKeys;\n    OMX_U32 nParentNodeID;\n    OMX_U32 nNumNodes;\n} OMX_CONFIG_CONTAINERNODECOUNTTYPE;\n\n/** @ingroup metadata */\ntypedef struct OMX_CONFIG_CONTAINERNODEIDTYPE\n{\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_BOOL bAllKeys;\n    OMX_U32 nParentNodeID;\n    OMX_U32 nNodeIndex; \n    OMX_U32 nNodeID; \n    OMX_STRING cNodeName;\n    OMX_BOOL bIsLeafType;\n} OMX_CONFIG_CONTAINERNODEIDTYPE;\n\n/** @ingroup metadata */\ntypedef struct OMX_PARAM_METADATAFILTERTYPE \n{ \n    OMX_U32 nSize; \n    OMX_VERSIONTYPE nVersion; \n    OMX_BOOL bAllKeys;\t/* if true then this structure refers to all keys and \n                         * the three key fields below are ignored */\n    OMX_METADATACHARSETTYPE eKeyCharset;\n    OMX_U32 nKeySizeUsed; \n    OMX_U8   nKey [128]; \n    OMX_U32 nLanguageCountrySizeUsed;\n    OMX_U8 nLanguageCountry[128];\n    OMX_BOOL bEnabled;\t/* if true then key is part of filter (e.g. \n                         * retained for query later). If false then\n                         * key is not part of filter */\n} OMX_PARAM_METADATAFILTERTYPE; \n\n/** The OMX_HANDLETYPE structure defines the component handle.  The component \n *  handle is used to access all of the component's public methods and also\n *  contains pointers to the component's private data area.  The component\n *  handle is initialized by the OMX core (with help from the component)\n *  during the process of loading the component.  After the component is\n *  successfully loaded, the application can safely access any of the\n *  component's public functions (although some may return an error because\n *  the state is inappropriate for the access).\n * \n *  @ingroup comp\n */\ntypedef struct OMX_COMPONENTTYPE\n{\n    /** The size of this structure, in bytes.  It is the responsibility\n        of the allocator of this structure to fill in this value.  Since\n        this structure is allocated by the GetHandle function, this\n        function will fill in this value. */\n    OMX_U32 nSize;\n\n    /** nVersion is the version of the OMX specification that the structure \n        is built against.  It is the responsibility of the creator of this \n        structure to initialize this value and every user of this structure \n        should verify that it knows how to use the exact version of \n        this structure found herein. */\n    OMX_VERSIONTYPE nVersion;\n\n    /** pComponentPrivate is a pointer to the component private data area.  \n        This member is allocated and initialized by the component when the \n        component is first loaded.  The application should not access this \n        data area. */\n    OMX_PTR pComponentPrivate;\n\n    /** pApplicationPrivate is a pointer that is a parameter to the \n        OMX_GetHandle method, and contains an application private value \n        provided by the IL client.  This application private data is \n        returned to the IL Client by OMX in all callbacks */\n    OMX_PTR pApplicationPrivate;\n\n    /** refer to OMX_GetComponentVersion in OMX_core.h or the OMX IL \n        specification for details on the GetComponentVersion method.\n     */\n    OMX_ERRORTYPE (*GetComponentVersion)(\n            OMX_IN  OMX_HANDLETYPE hComponent,\n            OMX_OUT OMX_STRING pComponentName,\n            OMX_OUT OMX_VERSIONTYPE* pComponentVersion,\n            OMX_OUT OMX_VERSIONTYPE* pSpecVersion,\n            OMX_OUT OMX_UUIDTYPE* pComponentUUID);\n\n    /** refer to OMX_SendCommand in OMX_core.h or the OMX IL \n        specification for details on the SendCommand method.\n     */\n    OMX_ERRORTYPE (*SendCommand)(\n            OMX_IN  OMX_HANDLETYPE hComponent,\n            OMX_IN  OMX_COMMANDTYPE Cmd,\n            OMX_IN  OMX_U32 nParam1,\n            OMX_IN  OMX_PTR pCmdData);\n\n    /** refer to OMX_GetParameter in OMX_core.h or the OMX IL \n        specification for details on the GetParameter method.\n     */\n    OMX_ERRORTYPE (*GetParameter)(\n            OMX_IN  OMX_HANDLETYPE hComponent, \n            OMX_IN  OMX_INDEXTYPE nParamIndex,  \n            OMX_INOUT OMX_PTR pComponentParameterStructure);\n\n\n    /** refer to OMX_SetParameter in OMX_core.h or the OMX IL \n        specification for details on the SetParameter method.\n     */\n    OMX_ERRORTYPE (*SetParameter)(\n            OMX_IN  OMX_HANDLETYPE hComponent, \n            OMX_IN  OMX_INDEXTYPE nIndex,\n            OMX_IN  OMX_PTR pComponentParameterStructure);\n\n\n    /** refer to OMX_GetConfig in OMX_core.h or the OMX IL \n        specification for details on the GetConfig method.\n     */\n    OMX_ERRORTYPE (*GetConfig)(\n            OMX_IN  OMX_HANDLETYPE hComponent,\n            OMX_IN  OMX_INDEXTYPE nIndex, \n            OMX_INOUT OMX_PTR pComponentConfigStructure);\n\n\n    /** refer to OMX_SetConfig in OMX_core.h or the OMX IL \n        specification for details on the SetConfig method.\n     */\n    OMX_ERRORTYPE (*SetConfig)(\n            OMX_IN  OMX_HANDLETYPE hComponent,\n            OMX_IN  OMX_INDEXTYPE nIndex, \n            OMX_IN  OMX_PTR pComponentConfigStructure);\n\n\n    /** refer to OMX_GetExtensionIndex in OMX_core.h or the OMX IL \n        specification for details on the GetExtensionIndex method.\n     */\n    OMX_ERRORTYPE (*GetExtensionIndex)(\n            OMX_IN  OMX_HANDLETYPE hComponent,\n            OMX_IN  OMX_STRING cParameterName,\n            OMX_OUT OMX_INDEXTYPE* pIndexType);\n\n\n    /** refer to OMX_GetState in OMX_core.h or the OMX IL \n        specification for details on the GetState method.\n     */\n    OMX_ERRORTYPE (*GetState)(\n            OMX_IN  OMX_HANDLETYPE hComponent,\n            OMX_OUT OMX_STATETYPE* pState);\n\n    \n    /** The ComponentTunnelRequest method will interact with another OMX\n        component to determine if tunneling is possible and to setup the\n        tunneling.  The return codes for this method can be used to \n        determine if tunneling is not possible, or if tunneling is not\n        supported.  \n        \n        Base profile components (i.e. non-interop) do not support this\n        method and should return OMX_ErrorNotImplemented \n\n        The interop profile component MUST support tunneling to another \n        interop profile component with a compatible port parameters.  \n        A component may also support proprietary communication.\n        \n        If proprietary communication is supported the negotiation of \n        proprietary communication is done outside of OMX in a vendor \n        specific way. It is only required that the proper result be \n        returned and the details of how the setup is done is left \n        to the component implementation.  \n    \n        When this method is invoked when nPort in an output port, the\n        component will:\n        1.  Populate the pTunnelSetup structure with the output port's \n            requirements and constraints for the tunnel.\n\n        When this method is invoked when nPort in an input port, the\n        component will:\n        1.  Query the necessary parameters from the output port to \n            determine if the ports are compatible for tunneling\n        2.  If the ports are compatible, the component should store\n            the tunnel step provided by the output port\n        3.  Determine which port (either input or output) is the buffer\n            supplier, and call OMX_SetParameter on the output port to\n            indicate this selection.\n        \n        The component will return from this call within 5 msec.\n    \n        @param [in] hComp\n            Handle of the component to be accessed.  This is the component\n            handle returned by the call to the OMX_GetHandle method.\n        @param [in] nPort\n            nPort is used to select the port on the component to be used\n            for tunneling.\n        @param [in] hTunneledComp\n            Handle of the component to tunnel with.  This is the component \n            handle returned by the call to the OMX_GetHandle method.  When\n            this parameter is 0x0 the component should setup the port for\n            communication with the application / IL Client.\n        @param [in] nPortOutput\n            nPortOutput is used indicate the port the component should\n            tunnel with.\n        @param [in] pTunnelSetup\n            Pointer to the tunnel setup structure.  When nPort is an output port\n            the component should populate the fields of this structure.  When\n            When nPort is an input port the component should review the setup\n            provided by the component with the output port.\n        @return OMX_ERRORTYPE\n            If the command successfully executes, the return code will be\n            OMX_ErrorNone.  Otherwise the appropriate OMX error will be returned.\n        @ingroup tun\n    */\n\n    OMX_ERRORTYPE (*ComponentTunnelRequest)(\n        OMX_IN  OMX_HANDLETYPE hComp,\n        OMX_IN  OMX_U32 nPort,\n        OMX_IN  OMX_HANDLETYPE hTunneledComp,\n        OMX_IN  OMX_U32 nTunneledPort,\n        OMX_INOUT  OMX_TUNNELSETUPTYPE* pTunnelSetup); \n\n    /** refer to OMX_UseBuffer in OMX_core.h or the OMX IL \n        specification for details on the UseBuffer method.\n        @ingroup buf\n     */\n    OMX_ERRORTYPE (*UseBuffer)(\n            OMX_IN OMX_HANDLETYPE hComponent,\n            OMX_INOUT OMX_BUFFERHEADERTYPE** ppBufferHdr,\n            OMX_IN OMX_U32 nPortIndex,\n            OMX_IN OMX_PTR pAppPrivate,\n            OMX_IN OMX_U32 nSizeBytes,\n            OMX_IN OMX_U8* pBuffer);\n\n    /** refer to OMX_AllocateBuffer in OMX_core.h or the OMX IL \n        specification for details on the AllocateBuffer method.\n        @ingroup buf\n     */\n    OMX_ERRORTYPE (*AllocateBuffer)(\n            OMX_IN OMX_HANDLETYPE hComponent,\n            OMX_INOUT OMX_BUFFERHEADERTYPE** ppBuffer,\n            OMX_IN OMX_U32 nPortIndex,\n            OMX_IN OMX_PTR pAppPrivate,\n            OMX_IN OMX_U32 nSizeBytes);\n\n    /** refer to OMX_FreeBuffer in OMX_core.h or the OMX IL \n        specification for details on the FreeBuffer method.\n        @ingroup buf\n     */\n    OMX_ERRORTYPE (*FreeBuffer)(\n            OMX_IN  OMX_HANDLETYPE hComponent,\n            OMX_IN  OMX_U32 nPortIndex,\n            OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer);\n\n    /** refer to OMX_EmptyThisBuffer in OMX_core.h or the OMX IL \n        specification for details on the EmptyThisBuffer method.\n        @ingroup buf\n     */\n    OMX_ERRORTYPE (*EmptyThisBuffer)(\n            OMX_IN  OMX_HANDLETYPE hComponent,\n            OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer);\n\n    /** refer to OMX_FillThisBuffer in OMX_core.h or the OMX IL \n        specification for details on the FillThisBuffer method.\n        @ingroup buf\n     */\n    OMX_ERRORTYPE (*FillThisBuffer)(\n            OMX_IN  OMX_HANDLETYPE hComponent,\n            OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer);\n\n    /** The SetCallbacks method is used by the core to specify the callback\n        structure from the application to the component.  This is a blocking\n        call.  The component will return from this call within 5 msec.\n        @param [in] hComponent\n            Handle of the component to be accessed.  This is the component\n            handle returned by the call to the GetHandle function.\n        @param [in] pCallbacks\n            pointer to an OMX_CALLBACKTYPE structure used to provide the \n            callback information to the component\n        @param [in] pAppData\n            pointer to an application defined value.  It is anticipated that \n            the application will pass a pointer to a data structure or a \"this\n            pointer\" in this area to allow the callback (in the application)\n            to determine the context of the call\n        @return OMX_ERRORTYPE\n            If the command successfully executes, the return code will be\n            OMX_ErrorNone.  Otherwise the appropriate OMX error will be returned.\n     */\n    OMX_ERRORTYPE (*SetCallbacks)(\n            OMX_IN  OMX_HANDLETYPE hComponent,\n            OMX_IN  OMX_CALLBACKTYPE* pCallbacks, \n            OMX_IN  OMX_PTR pAppData);\n\n    /** ComponentDeInit method is used to deinitialize the component\n        providing a means to free any resources allocated at component\n        initialization.  NOTE:  After this call the component handle is\n        not valid for further use.\n        @param [in] hComponent\n            Handle of the component to be accessed.  This is the component\n            handle returned by the call to the GetHandle function.\n        @return OMX_ERRORTYPE\n            If the command successfully executes, the return code will be\n            OMX_ErrorNone.  Otherwise the appropriate OMX error will be returned.\n     */\n    OMX_ERRORTYPE (*ComponentDeInit)(\n            OMX_IN  OMX_HANDLETYPE hComponent);\n\n    /** @ingroup buf */\n    OMX_ERRORTYPE (*UseEGLImage)(\n            OMX_IN OMX_HANDLETYPE hComponent,\n            OMX_INOUT OMX_BUFFERHEADERTYPE** ppBufferHdr,\n            OMX_IN OMX_U32 nPortIndex,\n            OMX_IN OMX_PTR pAppPrivate,\n            OMX_IN void* eglImage);\n\n    OMX_ERRORTYPE (*ComponentRoleEnum)(\n        OMX_IN OMX_HANDLETYPE hComponent,\n\t\tOMX_OUT OMX_U8 *cRole,\n\t\tOMX_IN OMX_U32 nIndex);\n\n} OMX_COMPONENTTYPE;\n\n#ifdef __cplusplus\n}\n#endif /* __cplusplus */\n\n#endif\n/* File EOF */\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/IL/OMX_Core.h",
    "content": "/*\n * Copyright (c) 2008 The Khronos Group Inc. \n * \n * Permission is hereby granted, free of charge, to any person obtaining\n * a copy of this software and associated documentation files (the\n * \"Software\"), to deal in the Software without restriction, including\n * without limitation the rights to use, copy, modify, merge, publish,\n * distribute, sublicense, and/or sell copies of the Software, and to\n * permit persons to whom the Software is furnished to do so, subject\n * to the following conditions: \n * The above copyright notice and this permission notice shall be included\n * in all copies or substantial portions of the Software. \n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\n * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\n * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\n * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \n *\n */\n\n/** OMX_Core.h - OpenMax IL version 1.1.2\n *  The OMX_Core header file contains the definitions used by both the\n *  application and the component to access common items.\n */\n\n#ifndef OMX_Core_h\n#define OMX_Core_h\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif /* __cplusplus */\n\n#if !defined(OMX_SKIP64BIT) && !defined(_VIDEOCORE)\n  /* The Videocore compiler doesn't enforce 64 bit alignment on 64 bit variables,\n   * which is almost equivalent to OMX_SKIP64BIT.\n   * Annoyingly struct OMX_BUFFERHEADERTYPE doesn't do the sensible thing\n   * and add padding fields or similar to make it the same for all compilers,\n   * so all clients need to define this.\n   * Warn if this isn't set, as the GPU will not interpret your buffers correctly,\n   * or vice versa.\n   */\n  #warning OMX_SKIP64BIT is not defined - this will be incompatible with the VC GPU code.\n#endif\n\n/* Each OMX header shall include all required header files to allow the\n *  header to compile without errors.  The includes below are required\n *  for this header file to compile successfully \n */\n\n#include \"OMX_Index.h\"\n\n\n/** The OMX_COMMANDTYPE enumeration is used to specify the action in the\n *  OMX_SendCommand macro.  \n *  @ingroup core\n */\ntypedef enum OMX_COMMANDTYPE\n{\n    OMX_CommandStateSet,    /**< Change the component state */\n    OMX_CommandFlush,       /**< Flush the data queue(s) of a component */\n    OMX_CommandPortDisable, /**< Disable a port on a component. */\n    OMX_CommandPortEnable,  /**< Enable a port on a component. */\n    OMX_CommandMarkBuffer,  /**< Mark a component/buffer for observation */\n    OMX_CommandKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_CommandVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_CommandMax = 0X7FFFFFFF\n} OMX_COMMANDTYPE;\n\n\n\n/** The OMX_STATETYPE enumeration is used to indicate or change the component\n *  state.  This enumeration reflects the current state of the component when\n *  used with the OMX_GetState macro or becomes the parameter in a state change\n *  command when used with the OMX_SendCommand macro.\n *\n *  The component will be in the Loaded state after the component is initially\n *  loaded into memory.  In the Loaded state, the component is not allowed to\n *  allocate or hold resources other than to build it's internal parameter\n *  and configuration tables.  The application will send one or more\n *  SetParameters/GetParameters and SetConfig/GetConfig commands to the\n *  component and the component will record each of these parameter and\n *  configuration changes for use later.  When the application sends the\n *  Idle command, the component will acquire the resources needed for the\n *  specified configuration and will transition to the idle state if the\n *  allocation is successful.  If the component cannot successfully\n *  transition to the idle state for any reason, the state of the component\n *  shall be fully rolled back to the Loaded state (e.g. all allocated \n *  resources shall be released).  When the component receives the command\n *  to go to the Executing state, it shall begin processing buffers by\n *  sending all input buffers it holds to the application.  While\n *  the component is in the Idle state, the application may also send the\n *  Pause command.  If the component receives the pause command while in the\n *  Idle state, the component shall send all input buffers it holds to the \n *  application, but shall not begin processing buffers.  This will allow the\n *  application to prefill buffers.\n * \n *  @ingroup comp\n */\n\ntypedef enum OMX_STATETYPE\n{\n    OMX_StateInvalid,      /**< component has detected that it's internal data \n                                structures are corrupted to the point that\n                                it cannot determine it's state properly */\n    OMX_StateLoaded,      /**< component has been loaded but has not completed\n                                initialization.  The OMX_SetParameter macro\n                                and the OMX_GetParameter macro are the only \n                                valid macros allowed to be sent to the \n                                component in this state. */\n    OMX_StateIdle,        /**< component initialization has been completed\n                                successfully and the component is ready to\n                                to start. */\n    OMX_StateExecuting,   /**< component has accepted the start command and\n                                is processing data (if data is available) */\n    OMX_StatePause,       /**< component has received pause command */\n    OMX_StateWaitForResources, /**< component is waiting for resources, either after \n                                preemption or before it gets the resources requested.\n                                See specification for complete details. */\n    OMX_StateKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_StateVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_StateMax = 0X7FFFFFFF\n} OMX_STATETYPE;\n\n/** The OMX_ERRORTYPE enumeration defines the standard OMX Errors.  These \n *  errors should cover most of the common failure cases.  However, \n *  vendors are free to add additional error messages of their own as \n *  long as they follow these rules:\n *  1.  Vendor error messages shall be in the range of 0x90000000 to\n *      0x9000FFFF.\n *  2.  Vendor error messages shall be defined in a header file provided\n *      with the component.  No error messages are allowed that are\n *      not defined.\n */\ntypedef enum OMX_ERRORTYPE\n{\n  OMX_ErrorNone = 0,\n\n  /** There were insufficient resources to perform the requested operation */\n  OMX_ErrorInsufficientResources = (OMX_S32) 0x80001000,\n\n  /** There was an error, but the cause of the error could not be determined */\n  OMX_ErrorUndefined = (OMX_S32) 0x80001001,\n\n  /** The component name string was not valid */\n  OMX_ErrorInvalidComponentName = (OMX_S32) 0x80001002,\n\n  /** No component with the specified name string was found */\n  OMX_ErrorComponentNotFound = (OMX_S32) 0x80001003,\n\n  /** The component specified did not have a \"OMX_ComponentInit\" or\n      \"OMX_ComponentDeInit entry point */\n  OMX_ErrorInvalidComponent = (OMX_S32) 0x80001004,\n\n  /** One or more parameters were not valid */\n  OMX_ErrorBadParameter = (OMX_S32) 0x80001005,\n\n  /** The requested function is not implemented */\n  OMX_ErrorNotImplemented = (OMX_S32) 0x80001006,\n\n  /** The buffer was emptied before the next buffer was ready */\n  OMX_ErrorUnderflow = (OMX_S32) 0x80001007,\n\n  /** The buffer was not available when it was needed */\n  OMX_ErrorOverflow = (OMX_S32) 0x80001008,\n\n  /** The hardware failed to respond as expected */\n  OMX_ErrorHardware = (OMX_S32) 0x80001009,\n\n  /** The component is in the state OMX_StateInvalid */\n  OMX_ErrorInvalidState = (OMX_S32) 0x8000100A,\n\n  /** Stream is found to be corrupt */\n  OMX_ErrorStreamCorrupt = (OMX_S32) 0x8000100B,\n\n  /** Ports being connected are not compatible */\n  OMX_ErrorPortsNotCompatible = (OMX_S32) 0x8000100C,\n\n  /** Resources allocated to an idle component have been\n      lost resulting in the component returning to the loaded state */\n  OMX_ErrorResourcesLost = (OMX_S32) 0x8000100D,\n\n  /** No more indicies can be enumerated */\n  OMX_ErrorNoMore = (OMX_S32) 0x8000100E,\n\n  /** The component detected a version mismatch */\n  OMX_ErrorVersionMismatch = (OMX_S32) 0x8000100F,\n\n  /** The component is not ready to return data at this time */\n  OMX_ErrorNotReady = (OMX_S32) 0x80001010,\n\n  /** There was a timeout that occurred */\n  OMX_ErrorTimeout = (OMX_S32) 0x80001011,\n\n  /** This error occurs when trying to transition into the state you are already in */\n  OMX_ErrorSameState = (OMX_S32) 0x80001012,\n\n  /** Resources allocated to an executing or paused component have been \n      preempted, causing the component to return to the idle state */\n  OMX_ErrorResourcesPreempted = (OMX_S32) 0x80001013, \n\n  /** A non-supplier port sends this error to the IL client (via the EventHandler callback) \n      during the allocation of buffers (on a transition from the LOADED to the IDLE state or\n      on a port restart) when it deems that it has waited an unusually long time for the supplier \n      to send it an allocated buffer via a UseBuffer call. */\n  OMX_ErrorPortUnresponsiveDuringAllocation = (OMX_S32) 0x80001014,\n\n  /** A non-supplier port sends this error to the IL client (via the EventHandler callback) \n      during the deallocation of buffers (on a transition from the IDLE to LOADED state or \n      on a port stop) when it deems that it has waited an unusually long time for the supplier \n      to request the deallocation of a buffer header via a FreeBuffer call. */\n  OMX_ErrorPortUnresponsiveDuringDeallocation = (OMX_S32) 0x80001015,\n\n  /** A supplier port sends this error to the IL client (via the EventHandler callback) \n      during the stopping of a port (either on a transition from the IDLE to LOADED \n      state or a port stop) when it deems that it has waited an unusually long time for \n      the non-supplier to return a buffer via an EmptyThisBuffer or FillThisBuffer call. */\n  OMX_ErrorPortUnresponsiveDuringStop = (OMX_S32) 0x80001016,\n\n  /** Attempting a state transtion that is not allowed */\n  OMX_ErrorIncorrectStateTransition = (OMX_S32) 0x80001017,\n\n  /* Attempting a command that is not allowed during the present state. */\n  OMX_ErrorIncorrectStateOperation = (OMX_S32) 0x80001018, \n\n  /** The values encapsulated in the parameter or config structure are not supported. */\n  OMX_ErrorUnsupportedSetting = (OMX_S32) 0x80001019,\n\n  /** The parameter or config indicated by the given index is not supported. */\n  OMX_ErrorUnsupportedIndex = (OMX_S32) 0x8000101A,\n\n  /** The port index supplied is incorrect. */\n  OMX_ErrorBadPortIndex = (OMX_S32) 0x8000101B,\n\n  /** The port has lost one or more of its buffers and it thus unpopulated. */\n  OMX_ErrorPortUnpopulated = (OMX_S32) 0x8000101C,\n\n  /** Component suspended due to temporary loss of resources */\n  OMX_ErrorComponentSuspended = (OMX_S32) 0x8000101D,\n\n  /** Component suspended due to an inability to acquire dynamic resources */\n  OMX_ErrorDynamicResourcesUnavailable = (OMX_S32) 0x8000101E,\n\n  /** When the macroblock error reporting is enabled the component returns new error \n  for every frame that has errors */\n  OMX_ErrorMbErrorsInFrame = (OMX_S32) 0x8000101F,\n\n  /** A component reports this error when it cannot parse or determine the format of an input stream. */\n  OMX_ErrorFormatNotDetected = (OMX_S32) 0x80001020, \n\n  /** The content open operation failed. */\n  OMX_ErrorContentPipeOpenFailed = (OMX_S32) 0x80001021,\n\n  /** The content creation operation failed. */\n  OMX_ErrorContentPipeCreationFailed = (OMX_S32) 0x80001022,\n\n  /** Separate table information is being used */\n  OMX_ErrorSeperateTablesUsed = (OMX_S32) 0x80001023,\n\n  /** Tunneling is unsupported by the component*/\n  OMX_ErrorTunnelingUnsupported = (OMX_S32) 0x80001024,\n\n  OMX_ErrorKhronosExtensions = (OMX_S32)0x8F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n  OMX_ErrorVendorStartUnused = (OMX_S32)0x90000000, /**< Reserved region for introducing Vendor Extensions */\n\n  /** Disk Full error */\n  OMX_ErrorDiskFull = (OMX_S32) 0x90000001,\n \n  /** Max file size is reached */\n  OMX_ErrorMaxFileSize = (OMX_S32) 0x90000002,\n\n  /** Unauthorised to play a DRM protected file */\n  OMX_ErrorDrmUnauthorised = (OMX_S32) 0x90000003,\n\n  /** The DRM protected file has expired */\n  OMX_ErrorDrmExpired = (OMX_S32) 0x90000004,\n\n  /** Some other DRM library error */\n  OMX_ErrorDrmGeneral = (OMX_S32) 0x90000005,\n\n  OMX_ErrorMax = 0x7FFFFFFF\n} OMX_ERRORTYPE;\n\n/** @ingroup core */\ntypedef OMX_ERRORTYPE (* OMX_COMPONENTINITTYPE)(OMX_IN  OMX_HANDLETYPE hComponent);\n\n/** @ingroup core */\ntypedef struct OMX_COMPONENTREGISTERTYPE\n{\n  const char          * pName;       /* Component name, 128 byte limit (including '\\0') applies */\n  OMX_COMPONENTINITTYPE pInitialize; /* Component instance initialization function */\n} OMX_COMPONENTREGISTERTYPE;\n\n/** @ingroup core */\nextern OMX_COMPONENTREGISTERTYPE OMX_ComponentRegistered[];\n\n/** @ingroup rpm */\ntypedef struct OMX_PRIORITYMGMTTYPE {\n OMX_U32 nSize;             /**< size of the structure in bytes */\n OMX_VERSIONTYPE nVersion;  /**< OMX specification version information */\n OMX_U32 nGroupPriority;            /**< Priority of the component group */\n OMX_U32 nGroupID;                  /**< ID of the component group */\n} OMX_PRIORITYMGMTTYPE;\n\n/* Component name and Role names are limited to 128 characters including the terminating '\\0'. */\n#define OMX_MAX_STRINGNAME_SIZE 128\n\n/** @ingroup comp */\ntypedef struct OMX_PARAM_COMPONENTROLETYPE {\n    OMX_U32 nSize;              /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion;   /**< OMX specification version information */\n    OMX_U8 cRole[OMX_MAX_STRINGNAME_SIZE];  /**< name of standard component which defines component role */\n} OMX_PARAM_COMPONENTROLETYPE;\n\n/** End of Stream Buffer Flag: \n  *\n  * A component sets EOS when it has no more data to emit on a particular \n  * output port. Thus an output port shall set EOS on the last buffer it \n  * emits. A component's determination of when an output port should \n  * cease sending data is implemenation specific.\n  * @ingroup buf\n  */\n\n#define OMX_BUFFERFLAG_EOS 0x00000001 \n\n/** Start Time Buffer Flag: \n *\n * The source of a stream (e.g. a demux component) sets the STARTTIME\n * flag on the buffer that contains the starting timestamp for the\n * stream. The starting timestamp corresponds to the first data that\n * should be displayed at startup or after a seek.\n * The first timestamp of the stream is not necessarily the start time.\n * For instance, in the case of a seek to a particular video frame, \n * the target frame may be an interframe. Thus the first buffer of \n * the stream will be the intra-frame preceding the target frame and\n * the starttime will occur with the target frame (with any other\n * required frames required to reconstruct the target intervening).\n *\n * The STARTTIME flag is directly associated with the buffer's \n * timestamp ' thus its association to buffer data and its \n * propagation is identical to the timestamp's.\n *\n * When a Sync Component client receives a buffer with the \n * STARTTIME flag it shall perform a SetConfig on its sync port \n * using OMX_ConfigTimeClientStartTime and passing the buffer's\n * timestamp.\n * \n * @ingroup buf\n */\n\n#define OMX_BUFFERFLAG_STARTTIME 0x00000002\n\n \n\n/** Decode Only Buffer Flag: \n *\n * The source of a stream (e.g. a demux component) sets the DECODEONLY\n * flag on any buffer that should shall be decoded but should not be\n * displayed. This flag is used, for instance, when a source seeks to \n * a target interframe that requires the decode of frames preceding the \n * target to facilitate the target's reconstruction. In this case the \n * source would emit the frames preceding the target downstream \n * but mark them as decode only.\n *\n * The DECODEONLY is associated with buffer data and propagated in a \n * manner identical to the buffer timestamp.\n *\n * A component that renders data should ignore all buffers with \n * the DECODEONLY flag set.\n * \n * @ingroup buf\n */\n\n#define OMX_BUFFERFLAG_DECODEONLY 0x00000004\n\n\n/* Data Corrupt Flag: This flag is set when the IL client believes the data in the associated buffer is corrupt \n * @ingroup buf\n */\n\n#define OMX_BUFFERFLAG_DATACORRUPT 0x00000008\n\n/* End of Frame: The buffer contains exactly one end of frame and no data\n *  occurs after the end of frame. This flag is an optional hint. The absence\n *  of this flag does not imply the absence of an end of frame within the buffer. \n * @ingroup buf\n*/\n#define OMX_BUFFERFLAG_ENDOFFRAME 0x00000010\n\n/* Sync Frame Flag: This flag is set when the buffer content contains a coded sync frame ' \n *  a frame that has no dependency on any other frame information \n *  @ingroup buf\n */\n#define OMX_BUFFERFLAG_SYNCFRAME 0x00000020\n\n/* Extra data present flag: there is extra data appended to the data stream\n * residing in the buffer \n * @ingroup buf  \n */\n#define OMX_BUFFERFLAG_EXTRADATA 0x00000040\n\n/** Codec Config Buffer Flag: \n* OMX_BUFFERFLAG_CODECCONFIG is an optional flag that is set by an\n* output port when all bytes in the buffer form part or all of a set of\n* codec specific configuration data.  Examples include SPS/PPS nal units\n* for OMX_VIDEO_CodingAVC or AudioSpecificConfig data for\n* OMX_AUDIO_CodingAAC.  Any component that for a given stream sets \n* OMX_BUFFERFLAG_CODECCONFIG shall not mix codec configuration bytes\n* with frame data in the same buffer, and shall send all buffers\n* containing codec configuration bytes before any buffers containing\n* frame data that those configurations bytes describe.\n* If the stream format for a particular codec has a frame specific\n* header at the start of each frame, for example OMX_AUDIO_CodingMP3 or\n* OMX_AUDIO_CodingAAC in ADTS mode, then these shall be presented as\n* normal without setting OMX_BUFFERFLAG_CODECCONFIG.\n * @ingroup buf\n */\n#define OMX_BUFFERFLAG_CODECCONFIG 0x00000080\n\n\n\n/** @ingroup buf */\ntypedef struct OMX_BUFFERHEADERTYPE\n{\n    OMX_U32 nSize;              /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion;   /**< OMX specification version information */\n    OMX_U8* pBuffer;            /**< Pointer to actual block of memory \n                                     that is acting as the buffer */\n    OMX_U32 nAllocLen;          /**< size of the buffer allocated, in bytes */\n    OMX_U32 nFilledLen;         /**< number of bytes currently in the \n                                     buffer */\n    OMX_U32 nOffset;            /**< start offset of valid data in bytes from\n                                     the start of the buffer */\n    OMX_PTR pAppPrivate;        /**< pointer to any data the application\n                                     wants to associate with this buffer */\n    OMX_PTR pPlatformPrivate;   /**< pointer to any data the platform\n                                     wants to associate with this buffer */ \n    OMX_PTR pInputPortPrivate;  /**< pointer to any data the input port\n                                     wants to associate with this buffer */\n    OMX_PTR pOutputPortPrivate; /**< pointer to any data the output port\n                                     wants to associate with this buffer */\n    OMX_HANDLETYPE hMarkTargetComponent; /**< The component that will generate a \n                                              mark event upon processing this buffer. */\n    OMX_PTR pMarkData;          /**< Application specific data associated with \n                                     the mark sent on a mark event to disambiguate \n                                     this mark from others. */\n    OMX_U32 nTickCount;         /**< Optional entry that the component and\n                                     application can update with a tick count\n                                     when they access the component.  This\n                                     value should be in microseconds.  Since\n                                     this is a value relative to an arbitrary\n                                     starting point, this value cannot be used \n                                     to determine absolute time.  This is an\n                                     optional entry and not all components\n                                     will update it.*/\n OMX_TICKS nTimeStamp;          /**< Timestamp corresponding to the sample \n                                     starting at the first logical sample \n                                     boundary in the buffer. Timestamps of \n                                     successive samples within the buffer may\n                                     be inferred by adding the duration of the \n                                     of the preceding buffer to the timestamp\n                                     of the preceding buffer.*/\n  OMX_U32     nFlags;           /**< buffer specific flags */\n  OMX_U32 nOutputPortIndex;     /**< The index of the output port (if any) using \n                                     this buffer */\n  OMX_U32 nInputPortIndex;      /**< The index of the input port (if any) using\n                                     this buffer */\n} OMX_BUFFERHEADERTYPE;\n\n/** The OMX_EXTRADATATYPE enumeration is used to define the \n * possible extra data payload types.\n * NB: this enum is binary backwards compatible with the previous\n * OMX_EXTRADATA_QUANT define.  This should be replaced with\n * OMX_ExtraDataQuantization.\n */\ntypedef enum OMX_EXTRADATATYPE\n{\n   OMX_ExtraDataNone = 0,                       /**< Indicates that no more extra data sections follow */        \n   OMX_ExtraDataQuantization,                   /**< The data payload contains quantization data */\n   OMX_ExtraDataKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n   OMX_ExtraDataVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n\n   OMX_ExtraDataSequenceGap,                    /**< Indicates a gap in sequence numbers, data is uint32_t \n                                                     saying how many frames were lost */\n   OMX_ExtraDataDecodeOnlyUntil,                /**< Indicates a timestamp until which all data should be\n                                                     decoded only, and the first packets after should generate\n                                                     a client start time flag.  data is int32_t of seek time\n                                                     in milliseconds */\n\n   OMX_ExtraDataMax = 0x7FFFFFFF\n} OMX_EXTRADATATYPE;\n\n\ntypedef struct OMX_OTHER_EXTRADATATYPE  {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;               \n    OMX_U32 nPortIndex;\n    OMX_EXTRADATATYPE eType;       /* Extra Data type */\n    OMX_U32 nDataSize;   /* Size of the supporting data to follow */\n    OMX_U8  data[1];     /* Supporting data hint  */\n} OMX_OTHER_EXTRADATATYPE;\n\n/** @ingroup comp */\ntypedef struct OMX_PORT_PARAM_TYPE {\n    OMX_U32 nSize;              /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion;   /**< OMX specification version information */\n    OMX_U32 nPorts;             /**< The number of ports for this component */\n    OMX_U32 nStartPortNumber;   /** first port number for this type of port */\n} OMX_PORT_PARAM_TYPE; \n\n/** @ingroup comp */\ntypedef enum OMX_EVENTTYPE\n{\n    OMX_EventCmdComplete,         /**< component has sucessfully completed a command */\n    OMX_EventError,               /**< component has detected an error condition */\n    OMX_EventMark,                /**< component has detected a buffer mark */\n    OMX_EventPortSettingsChanged, /**< component is reported a port settings change */\n    OMX_EventBufferFlag,          /**< component has detected an EOS */ \n    OMX_EventResourcesAcquired,   /**< component has been granted resources and is\n                                       automatically starting the state change from\n                                       OMX_StateWaitForResources to OMX_StateIdle. */\n   OMX_EventComponentResumed,     /**< Component resumed due to reacquisition of resources */\n   OMX_EventDynamicResourcesAvailable, /**< Component has acquired previously unavailable dynamic resources */\n   OMX_EventPortFormatDetected,      /**< Component has detected a supported format. */\n   OMX_EventKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n   OMX_EventVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n   OMX_EventParamOrConfigChanged,   /* Should be added to the main spec as part of IL416c */\n   OMX_EventMax = 0x7FFFFFFF\n} OMX_EVENTTYPE;\n\ntypedef struct OMX_CALLBACKTYPE\n{\n    /** The EventHandler method is used to notify the application when an\n        event of interest occurs.  Events are defined in the OMX_EVENTTYPE\n        enumeration.  Please see that enumeration for details of what will\n        be returned for each type of event. Callbacks should not return\n        an error to the component, so if an error occurs, the application \n        shall handle it internally.  This is a blocking call.\n\n        The application should return from this call within 5 msec to avoid\n        blocking the component for an excessively long period of time.\n\n        @param hComponent\n            handle of the component to access.  This is the component\n            handle returned by the call to the GetHandle function.\n        @param pAppData\n            pointer to an application defined value that was provided in the \n            pAppData parameter to the OMX_GetHandle method for the component.\n            This application defined value is provided so that the application \n            can have a component specific context when receiving the callback.\n        @param eEvent\n            Event that the component wants to notify the application about.\n        @param nData1\n            nData will be the OMX_ERRORTYPE for an error event and will be \n            an OMX_COMMANDTYPE for a command complete event and OMX_INDEXTYPE for a OMX_PortSettingsChanged event.\n         @param nData2\n            nData2 will hold further information related to the event. Can be OMX_STATETYPE for\n            a OMX_CommandStateSet command or port index for a OMX_PortSettingsChanged event.\n            Default value is 0 if not used. )\n        @param pEventData\n            Pointer to additional event-specific data (see spec for meaning).\n      */\n\n   OMX_ERRORTYPE (*EventHandler)(\n        OMX_IN OMX_HANDLETYPE hComponent,\n        OMX_IN OMX_PTR pAppData,\n        OMX_IN OMX_EVENTTYPE eEvent,\n        OMX_IN OMX_U32 nData1,\n        OMX_IN OMX_U32 nData2,\n        OMX_IN OMX_PTR pEventData);\n\n    /** The EmptyBufferDone method is used to return emptied buffers from an\n        input port back to the application for reuse.  This is a blocking call \n        so the application should not attempt to refill the buffers during this\n        call, but should queue them and refill them in another thread.  There\n        is no error return, so the application shall handle any errors generated\n        internally.  \n        \n        The application should return from this call within 5 msec.\n        \n        @param hComponent\n            handle of the component to access.  This is the component\n            handle returned by the call to the GetHandle function.\n        @param pAppData\n            pointer to an application defined value that was provided in the \n            pAppData parameter to the OMX_GetHandle method for the component.\n            This application defined value is provided so that the application \n            can have a component specific context when receiving the callback.\n        @param pBuffer\n            pointer to an OMX_BUFFERHEADERTYPE structure allocated with UseBuffer\n            or AllocateBuffer indicating the buffer that was emptied.\n        @ingroup buf\n     */\n    OMX_ERRORTYPE (*EmptyBufferDone)(\n        OMX_IN OMX_HANDLETYPE hComponent,\n        OMX_IN OMX_PTR pAppData,\n        OMX_IN OMX_BUFFERHEADERTYPE* pBuffer);\n\n    /** The FillBufferDone method is used to return filled buffers from an\n        output port back to the application for emptying and then reuse.  \n        This is a blocking call so the application should not attempt to \n        empty the buffers during this call, but should queue the buffers \n        and empty them in another thread.  There is no error return, so \n        the application shall handle any errors generated internally.  The \n        application shall also update the buffer header to indicate the\n        number of bytes placed into the buffer.  \n\n        The application should return from this call within 5 msec.\n        \n        @param hComponent\n            handle of the component to access.  This is the component\n            handle returned by the call to the GetHandle function.\n        @param pAppData\n            pointer to an application defined value that was provided in the \n            pAppData parameter to the OMX_GetHandle method for the component.\n            This application defined value is provided so that the application \n            can have a component specific context when receiving the callback.\n        @param pBuffer\n            pointer to an OMX_BUFFERHEADERTYPE structure allocated with UseBuffer\n            or AllocateBuffer indicating the buffer that was filled.\n        @ingroup buf\n     */\n    OMX_ERRORTYPE (*FillBufferDone)(\n        OMX_OUT OMX_HANDLETYPE hComponent,\n        OMX_OUT OMX_PTR pAppData,\n        OMX_OUT OMX_BUFFERHEADERTYPE* pBuffer);\n\n} OMX_CALLBACKTYPE;\n\n/** The OMX_BUFFERSUPPLIERTYPE enumeration is used to dictate port supplier\n    preference when tunneling between two ports.\n    @ingroup tun buf\n*/\ntypedef enum OMX_BUFFERSUPPLIERTYPE\n{\n    OMX_BufferSupplyUnspecified = 0x0, /**< port supplying the buffers is unspecified,\n                                              or don't care */\n    OMX_BufferSupplyInput,             /**< input port supplies the buffers */\n    OMX_BufferSupplyOutput,            /**< output port supplies the buffers */\n    OMX_BufferSupplyKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_BufferSupplyVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_BufferSupplyMax = 0x7FFFFFFF\n} OMX_BUFFERSUPPLIERTYPE;\n\n\n/** buffer supplier parameter \n * @ingroup tun\n */\ntypedef struct OMX_PARAM_BUFFERSUPPLIERTYPE {\n    OMX_U32 nSize; /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion; /**< OMX specification version information */\n    OMX_U32 nPortIndex; /**< port that this structure applies to */\n    OMX_BUFFERSUPPLIERTYPE eBufferSupplier; /**< buffer supplier */\n} OMX_PARAM_BUFFERSUPPLIERTYPE;\n\n\n/**< indicates that buffers received by an input port of a tunnel \n     may not modify the data in the buffers \n     @ingroup tun\n */\n#define OMX_PORTTUNNELFLAG_READONLY 0x00000001 \n\n\n/** The OMX_TUNNELSETUPTYPE structure is used to pass data from an output\n    port to an input port as part the two ComponentTunnelRequest calls\n    resulting from a OMX_SetupTunnel call from the IL Client. \n    @ingroup tun\n */   \ntypedef struct OMX_TUNNELSETUPTYPE\n{\n    OMX_U32 nTunnelFlags;             /**< bit flags for tunneling */\n    OMX_BUFFERSUPPLIERTYPE eSupplier; /**< supplier preference */\n} OMX_TUNNELSETUPTYPE; \n\n/* OMX Component headers is included to enable the core to use\n   macros for functions into the component for OMX release 1.0.  \n   Developers should not access any structures or data from within\n   the component header directly */\n/* TO BE REMOVED - #include <OMX_Component.h> */\n\n/** GetComponentVersion will return information about the component.  \n    This is a blocking call.  This macro will go directly from the\n    application to the component (via a core macro).  The\n    component will return from this call within 5 msec.\n    @param [in] hComponent\n        handle of component to execute the command\n    @param [out] pComponentName\n        pointer to an empty string of length 128 bytes.  The component \n        will write its name into this string.  The name will be \n        terminated by a single zero byte.  The name of a component will \n        be 127 bytes or less to leave room for the trailing zero byte.  \n        An example of a valid component name is \"OMX.ABC.ChannelMixer\\0\".\n    @param [out] pComponentVersion\n        pointer to an OMX Version structure that the component will fill \n        in.  The component will fill in a value that indicates the \n        component version.  NOTE: the component version is NOT the same \n        as the OMX Specification version (found in all structures).  The \n        component version is defined by the vendor of the component and \n        its value is entirely up to the component vendor.\n    @param [out] pSpecVersion\n        pointer to an OMX Version structure that the component will fill \n        in.  The SpecVersion is the version of the specification that the \n        component was built against.  Please note that this value may or \n        may not match the structure's version.  For example, if the \n        component was built against the 2.0 specification, but the \n        application (which creates the structure is built against the \n        1.0 specification the versions would be different.\n    @param [out] pComponentUUID\n        pointer to the UUID of the component which will be filled in by \n        the component.  The UUID is a unique identifier that is set at \n        RUN time for the component and is unique to each instantion of \n        the component.\n    @return OMX_ERRORTYPE\n        If the command successfully executes, the return code will be\n        OMX_ErrorNone.  Otherwise the appropriate OMX error will be returned.\n    @ingroup comp\n */\n#define OMX_GetComponentVersion(                            \\\n        hComponent,                                         \\\n        pComponentName,                                     \\\n        pComponentVersion,                                  \\\n        pSpecVersion,                                       \\\n        pComponentUUID)                                     \\\n    ((OMX_COMPONENTTYPE*)hComponent)->GetComponentVersion(  \\\n        hComponent,                                         \\\n        pComponentName,                                     \\\n        pComponentVersion,                                  \\\n        pSpecVersion,                                       \\\n        pComponentUUID)                 /* Macro End */\n\n\n/** Send a command to the component.  This call is a non-blocking call.\n    The component should check the parameters and then queue the command\n    to the component thread to be executed.  The component thread shall \n    send the EventHandler() callback at the conclusion of the command. \n    This macro will go directly from the application to the component (via\n    a core macro).  The component will return from this call within 5 msec.\n    \n    When the command is \"OMX_CommandStateSet\" the component will queue a\n    state transition to the new state idenfied in nParam.\n    \n    When the command is \"OMX_CommandFlush\", to flush a port's buffer queues,\n    the command will force the component to return all buffers NOT CURRENTLY \n    BEING PROCESSED to the application, in the order in which the buffers \n    were received.\n    \n    When the command is \"OMX_CommandPortDisable\" or \n    \"OMX_CommandPortEnable\", the component's port (given by the value of\n    nParam) will be stopped or restarted. \n    \n    When the command \"OMX_CommandMarkBuffer\" is used to mark a buffer, the\n    pCmdData will point to a OMX_MARKTYPE structure containing the component\n    handle of the component to examine the buffer chain for the mark.  nParam1\n    contains the index of the port on which the buffer mark is applied.\n\n    Specification text for more details. \n    \n    @param [in] hComponent\n        handle of component to execute the command\n    @param [in] Cmd\n        Command for the component to execute\n    @param [in] nParam\n        Parameter for the command to be executed.  When Cmd has the value \n        OMX_CommandStateSet, value is a member of OMX_STATETYPE.  When Cmd has \n        the value OMX_CommandFlush, value of nParam indicates which port(s) \n        to flush. -1 is used to flush all ports a single port index will \n        only flush that port.  When Cmd has the value \"OMX_CommandPortDisable\"\n        or \"OMX_CommandPortEnable\", the component's port is given by \n        the value of nParam.  When Cmd has the value \"OMX_CommandMarkBuffer\"\n        the components pot is given by the value of nParam.\n    @param [in] pCmdData\n        Parameter pointing to the OMX_MARKTYPE structure when Cmd has the value\n        \"OMX_CommandMarkBuffer\".     \n    @return OMX_ERRORTYPE\n        If the command successfully executes, the return code will be\n        OMX_ErrorNone.  Otherwise the appropriate OMX error will be returned.\n    @ingroup comp\n */\n#define OMX_SendCommand(                                    \\\n         hComponent,                                        \\\n         Cmd,                                               \\\n         nParam,                                            \\\n         pCmdData)                                          \\\n     ((OMX_COMPONENTTYPE*)hComponent)->SendCommand(         \\\n         hComponent,                                        \\\n         Cmd,                                               \\\n         nParam,                                            \\\n         pCmdData)                          /* Macro End */\n\n\n/** The OMX_GetParameter macro will get one of the current parameter \n    settings from the component.  This macro cannot only be invoked when \n    the component is in the OMX_StateInvalid state.  The nParamIndex\n    parameter is used to indicate which structure is being requested from\n    the component.  The application shall allocate the correct structure \n    and shall fill in the structure size and version information before \n    invoking this macro.  When the parameter applies to a port, the\n    caller shall fill in the appropriate nPortIndex value indicating the\n    port on which the parameter applies. If the component has not had \n    any settings changed, then the component should return a set of \n    valid DEFAULT  parameters for the component.  This is a blocking \n    call.  \n    \n    The component should return from this call within 20 msec.\n    \n    @param [in] hComponent\n        Handle of the component to be accessed.  This is the component\n        handle returned by the call to the OMX_GetHandle function.\n    @param [in] nParamIndex\n        Index of the structure to be filled.  This value is from the\n        OMX_INDEXTYPE enumeration.\n    @param [in,out] pComponentParameterStructure\n        Pointer to application allocated structure to be filled by the \n        component.\n    @return OMX_ERRORTYPE\n        If the command successfully executes, the return code will be\n        OMX_ErrorNone.  Otherwise the appropriate OMX error will be returned.\n    @ingroup comp\n */\n#define OMX_GetParameter(                                   \\\n        hComponent,                                         \\\n        nParamIndex,                                        \\\n        pComponentParameterStructure)                        \\\n    ((OMX_COMPONENTTYPE*)hComponent)->GetParameter(         \\\n        hComponent,                                         \\\n        nParamIndex,                                        \\\n        pComponentParameterStructure)    /* Macro End */\n\n\n/** The OMX_SetParameter macro will send an initialization parameter\n    structure to a component.  Each structure shall be sent one at a time,\n    in a separate invocation of the macro.  This macro can only be\n    invoked when the component is in the OMX_StateLoaded state, or the\n    port is disabled (when the parameter applies to a port). The \n    nParamIndex parameter is used to indicate which structure is being\n    passed to the component.  The application shall allocate the \n    correct structure and shall fill in the structure size and version \n    information (as well as the actual data) before invoking this macro.\n    The application is free to dispose of this structure after the call\n    as the component is required to copy any data it shall retain.  This \n    is a blocking call.  \n    \n    The component should return from this call within 20 msec.\n    \n    @param [in] hComponent\n        Handle of the component to be accessed.  This is the component\n        handle returned by the call to the OMX_GetHandle function.\n    @param [in] nIndex\n        Index of the structure to be sent.  This value is from the\n        OMX_INDEXTYPE enumeration.\n    @param [in] pComponentParameterStructure\n        pointer to application allocated structure to be used for\n        initialization by the component.\n    @return OMX_ERRORTYPE\n        If the command successfully executes, the return code will be\n        OMX_ErrorNone.  Otherwise the appropriate OMX error will be returned.\n    @ingroup comp\n */\n#define OMX_SetParameter(                                   \\\n        hComponent,                                         \\\n        nParamIndex,                                        \\\n        pComponentParameterStructure)                        \\\n    ((OMX_COMPONENTTYPE*)hComponent)->SetParameter(         \\\n        hComponent,                                         \\\n        nParamIndex,                                        \\\n        pComponentParameterStructure)    /* Macro End */\n\n\n/** The OMX_GetConfig macro will get one of the configuration structures \n    from a component.  This macro can be invoked anytime after the \n    component has been loaded.  The nParamIndex call parameter is used to \n    indicate which structure is being requested from the component.  The \n    application shall allocate the correct structure and shall fill in the \n    structure size and version information before invoking this macro.  \n    If the component has not had this configuration parameter sent before, \n    then the component should return a set of valid DEFAULT values for the \n    component.  This is a blocking call.  \n    \n    The component should return from this call within 5 msec.\n    \n    @param [in] hComponent\n        Handle of the component to be accessed.  This is the component\n        handle returned by the call to the OMX_GetHandle function.\n    @param [in] nIndex\n        Index of the structure to be filled.  This value is from the\n        OMX_INDEXTYPE enumeration.\n    @param [in,out] pComponentConfigStructure\n        pointer to application allocated structure to be filled by the \n        component.\n    @return OMX_ERRORTYPE\n        If the command successfully executes, the return code will be\n        OMX_ErrorNone.  Otherwise the appropriate OMX error will be returned.\n    @ingroup comp\n*/        \n#define OMX_GetConfig(                                      \\\n        hComponent,                                         \\\n        nConfigIndex,                                       \\\n        pComponentConfigStructure)                           \\\n    ((OMX_COMPONENTTYPE*)hComponent)->GetConfig(            \\\n        hComponent,                                         \\\n        nConfigIndex,                                       \\\n        pComponentConfigStructure)       /* Macro End */\n\n\n/** The OMX_SetConfig macro will send one of the configuration \n    structures to a component.  Each structure shall be sent one at a time,\n    each in a separate invocation of the macro.  This macro can be invoked \n    anytime after the component has been loaded.  The application shall \n    allocate the correct structure and shall fill in the structure size \n    and version information (as well as the actual data) before invoking \n    this macro.  The application is free to dispose of this structure after \n    the call as the component is required to copy any data it shall retain.  \n    This is a blocking call.  \n    \n    The component should return from this call within 5 msec.\n    \n    @param [in] hComponent\n        Handle of the component to be accessed.  This is the component\n        handle returned by the call to the OMX_GetHandle function.\n    @param [in] nConfigIndex\n        Index of the structure to be sent.  This value is from the\n        OMX_INDEXTYPE enumeration above.\n    @param [in] pComponentConfigStructure\n        pointer to application allocated structure to be used for\n        initialization by the component.\n    @return OMX_ERRORTYPE\n        If the command successfully executes, the return code will be\n        OMX_ErrorNone.  Otherwise the appropriate OMX error will be returned.\n    @ingroup comp\n */\n#define OMX_SetConfig(                                      \\\n        hComponent,                                         \\\n        nConfigIndex,                                       \\\n        pComponentConfigStructure)                           \\\n    ((OMX_COMPONENTTYPE*)hComponent)->SetConfig(            \\\n        hComponent,                                         \\\n        nConfigIndex,                                       \\\n        pComponentConfigStructure)       /* Macro End */\n\n\n/** The OMX_GetExtensionIndex macro will invoke a component to translate \n    a vendor specific configuration or parameter string into an OMX \n    structure index.  There is no requirement for the vendor to support \n    this command for the indexes already found in the OMX_INDEXTYPE \n    enumeration (this is done to save space in small components).  The \n    component shall support all vendor supplied extension indexes not found\n    in the master OMX_INDEXTYPE enumeration.  This is a blocking call.  \n    \n    The component should return from this call within 5 msec.\n    \n    @param [in] hComponent\n        Handle of the component to be accessed.  This is the component\n        handle returned by the call to the GetHandle function.\n    @param [in] cParameterName\n        OMX_STRING that shall be less than 128 characters long including\n        the trailing null byte.  This is the string that will get \n        translated by the component into a configuration index.\n    @param [out] pIndexType\n        a pointer to a OMX_INDEXTYPE to receive the index value.\n    @return OMX_ERRORTYPE\n        If the command successfully executes, the return code will be\n        OMX_ErrorNone.  Otherwise the appropriate OMX error will be returned.\n    @ingroup comp\n */\n#define OMX_GetExtensionIndex(                              \\\n        hComponent,                                         \\\n        cParameterName,                                     \\\n        pIndexType)                                         \\\n    ((OMX_COMPONENTTYPE*)hComponent)->GetExtensionIndex(    \\\n        hComponent,                                         \\\n        cParameterName,                                     \\\n        pIndexType)                     /* Macro End */\n\n\n/** The OMX_GetState macro will invoke the component to get the current \n    state of the component and place the state value into the location\n    pointed to by pState.  \n    \n    The component should return from this call within 5 msec.\n    \n    @param [in] hComponent\n        Handle of the component to be accessed.  This is the component\n        handle returned by the call to the OMX_GetHandle function.\n    @param [out] pState\n        pointer to the location to receive the state.  The value returned\n        is one of the OMX_STATETYPE members \n    @return OMX_ERRORTYPE\n        If the command successfully executes, the return code will be\n        OMX_ErrorNone.  Otherwise the appropriate OMX error will be returned.\n    @ingroup comp\n */\n#define OMX_GetState(                                       \\\n        hComponent,                                         \\\n        pState)                                             \\\n    ((OMX_COMPONENTTYPE*)hComponent)->GetState(             \\\n        hComponent,                                         \\\n        pState)                         /* Macro End */\n\n\n/** The OMX_UseBuffer macro will request that the component use\n    a buffer (and allocate its own buffer header) already allocated \n    by another component, or by the IL Client. This is a blocking \n    call.\n    \n    The component should return from this call within 20 msec.\n    \n    @param [in] hComponent\n        Handle of the component to be accessed.  This is the component\n        handle returned by the call to the OMX_GetHandle function.\n    @param [out] ppBuffer\n        pointer to an OMX_BUFFERHEADERTYPE structure used to receive the \n        pointer to the buffer header\n    @return OMX_ERRORTYPE\n        If the command successfully executes, the return code will be\n        OMX_ErrorNone.  Otherwise the appropriate OMX error will be returned.\n    @ingroup comp buf\n */\n\n#define OMX_UseBuffer(                                      \\\n           hComponent,                                      \\\n           ppBufferHdr,                                     \\\n           nPortIndex,                                      \\\n           pAppPrivate,                                     \\\n           nSizeBytes,                                      \\\n           pBuffer)                                         \\\n    ((OMX_COMPONENTTYPE*)hComponent)->UseBuffer(            \\\n           hComponent,                                      \\\n           ppBufferHdr,                                     \\\n           nPortIndex,                                      \\\n           pAppPrivate,                                     \\\n           nSizeBytes,                                      \\\n           pBuffer)\n\n\n/** The OMX_AllocateBuffer macro will request that the component allocate \n    a new buffer and buffer header.  The component will allocate the \n    buffer and the buffer header and return a pointer to the buffer \n    header.  This is a blocking call.\n    \n    The component should return from this call within 5 msec.\n    \n    @param [in] hComponent\n        Handle of the component to be accessed.  This is the component\n        handle returned by the call to the OMX_GetHandle function.\n    @param [out] ppBuffer\n        pointer to an OMX_BUFFERHEADERTYPE structure used to receive \n        the pointer to the buffer header\n    @param [in] nPortIndex\n        nPortIndex is used to select the port on the component the buffer will\n        be used with.  The port can be found by using the nPortIndex\n        value as an index into the Port Definition array of the component.\n    @param [in] pAppPrivate\n        pAppPrivate is used to initialize the pAppPrivate member of the \n        buffer header structure.\n    @param [in] nSizeBytes\n        size of the buffer to allocate.  Used when bAllocateNew is true.\n    @return OMX_ERRORTYPE\n        If the command successfully executes, the return code will be\n        OMX_ErrorNone.  Otherwise the appropriate OMX error will be returned.\n    @ingroup comp buf\n */    \n#define OMX_AllocateBuffer(                                 \\\n        hComponent,                                         \\\n        ppBuffer,                                           \\\n        nPortIndex,                                         \\\n        pAppPrivate,                                        \\\n        nSizeBytes)                                         \\\n    ((OMX_COMPONENTTYPE*)hComponent)->AllocateBuffer(       \\\n        hComponent,                                         \\\n        ppBuffer,                                           \\\n        nPortIndex,                                         \\\n        pAppPrivate,                                        \\\n        nSizeBytes)                     /* Macro End */\n\n\n/** The OMX_FreeBuffer macro will release a buffer header from the component\n    which was allocated using either OMX_AllocateBuffer or OMX_UseBuffer. If  \n    the component allocated the buffer (see the OMX_UseBuffer macro) then \n    the component shall free the buffer and buffer header. This is a \n    blocking call. \n    \n    The component should return from this call within 20 msec.\n    \n    @param [in] hComponent\n        Handle of the component to be accessed.  This is the component\n        handle returned by the call to the OMX_GetHandle function.\n    @param [in] nPortIndex\n        nPortIndex is used to select the port on the component the buffer will\n        be used with.\n    @param [in] pBuffer\n        pointer to an OMX_BUFFERHEADERTYPE structure allocated with UseBuffer\n        or AllocateBuffer.\n    @return OMX_ERRORTYPE\n        If the command successfully executes, the return code will be\n        OMX_ErrorNone.  Otherwise the appropriate OMX error will be returned.\n    @ingroup comp buf\n */\n#define OMX_FreeBuffer(                                     \\\n        hComponent,                                         \\\n        nPortIndex,                                         \\\n        pBuffer)                                            \\\n    ((OMX_COMPONENTTYPE*)hComponent)->FreeBuffer(           \\\n        hComponent,                                         \\\n        nPortIndex,                                         \\\n        pBuffer)                        /* Macro End */\n\n\n/** The OMX_EmptyThisBuffer macro will send a buffer full of data to an \n    input port of a component.  The buffer will be emptied by the component\n    and returned to the application via the EmptyBufferDone call back.\n    This is a non-blocking call in that the component will record the buffer\n    and return immediately and then empty the buffer, later, at the proper \n    time.  As expected, this macro may be invoked only while the component \n    is in the OMX_StateExecuting.  If nPortIndex does not specify an input\n    port, the component shall return an error.  \n    \n    The component should return from this call within 5 msec.\n    \n    @param [in] hComponent\n        Handle of the component to be accessed.  This is the component\n        handle returned by the call to the OMX_GetHandle function.\n    @param [in] pBuffer\n        pointer to an OMX_BUFFERHEADERTYPE structure allocated with UseBuffer\n        or AllocateBuffer.\n    @return OMX_ERRORTYPE\n        If the command successfully executes, the return code will be\n        OMX_ErrorNone.  Otherwise the appropriate OMX error will be returned.\n    @ingroup comp buf\n */\n#define OMX_EmptyThisBuffer(                                \\\n        hComponent,                                         \\\n        pBuffer)                                            \\\n    ((OMX_COMPONENTTYPE*)hComponent)->EmptyThisBuffer(      \\\n        hComponent,                                         \\\n        pBuffer)                        /* Macro End */\n\n\n/** The OMX_FillThisBuffer macro will send an empty buffer to an \n    output port of a component.  The buffer will be filled by the component\n    and returned to the application via the FillBufferDone call back.\n    This is a non-blocking call in that the component will record the buffer\n    and return immediately and then fill the buffer, later, at the proper \n    time.  As expected, this macro may be invoked only while the component \n    is in the OMX_ExecutingState.  If nPortIndex does not specify an output\n    port, the component shall return an error.  \n    \n    The component should return from this call within 5 msec.\n    \n    @param [in] hComponent\n        Handle of the component to be accessed.  This is the component\n        handle returned by the call to the OMX_GetHandle function.\n    @param [in] pBuffer\n        pointer to an OMX_BUFFERHEADERTYPE structure allocated with UseBuffer\n        or AllocateBuffer.\n    @return OMX_ERRORTYPE\n        If the command successfully executes, the return code will be\n        OMX_ErrorNone.  Otherwise the appropriate OMX error will be returned.\n    @ingroup comp buf\n */\n#define OMX_FillThisBuffer(                                 \\\n        hComponent,                                         \\\n        pBuffer)                                            \\\n    ((OMX_COMPONENTTYPE*)hComponent)->FillThisBuffer(       \\\n        hComponent,                                         \\\n        pBuffer)                        /* Macro End */\n\n\n\n/** The OMX_UseEGLImage macro will request that the component use\n    a EGLImage provided by EGL (and allocate its own buffer header)\n    This is a blocking call.\n    \n    The component should return from this call within 20 msec.\n    \n    @param [in] hComponent\n        Handle of the component to be accessed.  This is the component\n        handle returned by the call to the OMX_GetHandle function.\n    @param [out] ppBuffer\n        pointer to an OMX_BUFFERHEADERTYPE structure used to receive the \n        pointer to the buffer header.  Note that the memory location used\n        for this buffer is NOT visible to the IL Client.\n    @param [in] nPortIndex\n        nPortIndex is used to select the port on the component the buffer will\n        be used with.  The port can be found by using the nPortIndex\n        value as an index into the Port Definition array of the component.\n    @param [in] pAppPrivate\n        pAppPrivate is used to initialize the pAppPrivate member of the \n        buffer header structure.\n    @param [in] eglImage\n        eglImage contains the handle of the EGLImage to use as a buffer on the\n        specified port.  The component is expected to validate properties of \n        the EGLImage against the configuration of the port to ensure the component\n        can use the EGLImage as a buffer.          \n    @return OMX_ERRORTYPE\n        If the command successfully executes, the return code will be\n        OMX_ErrorNone.  Otherwise the appropriate OMX error will be returned.\n    @ingroup comp buf\n */\n#define OMX_UseEGLImage(                                    \\\n           hComponent,                                      \\\n           ppBufferHdr,                                     \\\n           nPortIndex,                                      \\\n           pAppPrivate,                                     \\\n           eglImage)                                        \\\n    ((OMX_COMPONENTTYPE*)hComponent)->UseEGLImage(          \\\n           hComponent,                                      \\\n           ppBufferHdr,                                     \\\n           nPortIndex,                                      \\\n           pAppPrivate,                                     \\\n           eglImage)\n\n/** The OMX_Init method is used to initialize the OMX core.  It shall be the\n    first call made into OMX and it should only be executed one time without\n    an interviening OMX_Deinit call.  \n    \n    The core should return from this call within 20 msec.\n\n    @return OMX_ERRORTYPE\n        If the command successfully executes, the return code will be\n        OMX_ErrorNone.  Otherwise the appropriate OMX error will be returned.\n    @ingroup core\n */\nOMX_API OMX_ERRORTYPE OMX_APIENTRY OMX_Init(void);\n\n\n/** The OMX_Deinit method is used to deinitialize the OMX core.  It shall be \n    the last call made into OMX. In the event that the core determines that \n    thare are components loaded when this call is made, the core may return \n    with an error rather than try to unload the components.\n        \n    The core should return from this call within 20 msec.\n    \n    @return OMX_ERRORTYPE\n        If the command successfully executes, the return code will be\n        OMX_ErrorNone.  Otherwise the appropriate OMX error will be returned.\n    @ingroup core\n */\nOMX_API OMX_ERRORTYPE OMX_APIENTRY OMX_Deinit(void);\n\n\n/** The OMX_ComponentNameEnum method will enumerate through all the names of\n    recognised valid components in the system. This function is provided\n    as a means to detect all the components in the system run-time. There is\n    no strict ordering to the enumeration order of component names, although\n    each name will only be enumerated once.  If the OMX core supports run-time\n    installation of new components, it is only requried to detect newly\n    installed components when the first call to enumerate component names\n    is made (i.e. when nIndex is 0x0).\n    \n    The core should return from this call in 20 msec.\n    \n    @param [out] cComponentName\n        pointer to a null terminated string with the component name.  The\n        names of the components are strings less than 127 bytes in length\n        plus the trailing null for a maximum size of 128 bytes.  An example \n        of a valid component name is \"OMX.TI.AUDIO.DSP.MIXER\\0\".  Names are \n        assigned by the vendor, but shall start with \"OMX.\" and then have \n        the Vendor designation next.\n    @param [in] nNameLength\n        number of characters in the cComponentName string.  With all \n        component name strings restricted to less than 128 characters \n        (including the trailing null) it is recomended that the caller\n        provide a input string for the cComponentName of 128 characters.\n    @param [in] nIndex\n        number containing the enumeration index for the component. \n        Multiple calls to OMX_ComponentNameEnum with increasing values\n        of nIndex will enumerate through the component names in the\n        system until OMX_ErrorNoMore is returned.  The value of nIndex\n        is 0 to (N-1), where N is the number of valid installed components\n        in the system.\n    @return OMX_ERRORTYPE\n        If the command successfully executes, the return code will be\n        OMX_ErrorNone.  When the value of nIndex exceeds the number of \n        components in the system minus 1, OMX_ErrorNoMore will be\n        returned. Otherwise the appropriate OMX error will be returned.\n    @ingroup core\n */\nOMX_API OMX_ERRORTYPE OMX_APIENTRY OMX_ComponentNameEnum(\n    OMX_OUT OMX_STRING cComponentName,\n    OMX_IN  OMX_U32 nNameLength,\n    OMX_IN  OMX_U32 nIndex);\n\n\n/** The OMX_GetHandle method will locate the component specified by the\n    component name given, load that component into memory and then invoke\n    the component's methods to create an instance of the component.  \n    \n    The core should return from this call within 20 msec.\n    \n    @param [out] pHandle\n        pointer to an OMX_HANDLETYPE pointer to be filled in by this method.\n    @param [in] cComponentName\n        pointer to a null terminated string with the component name.  The\n        names of the components are strings less than 127 bytes in length\n        plus the trailing null for a maximum size of 128 bytes.  An example \n        of a valid component name is \"OMX.TI.AUDIO.DSP.MIXER\\0\".  Names are \n        assigned by the vendor, but shall start with \"OMX.\" and then have \n        the Vendor designation next.\n    @param [in] pAppData\n        pointer to an application defined value that will be returned\n        during callbacks so that the application can identify the source\n        of the callback.\n    @param [in] pCallBacks\n        pointer to a OMX_CALLBACKTYPE structure that will be passed to the\n        component to initialize it with.  \n    @return OMX_ERRORTYPE\n        If the command successfully executes, the return code will be\n        OMX_ErrorNone.  Otherwise the appropriate OMX error will be returned.\n    @ingroup core\n */\nOMX_API OMX_ERRORTYPE OMX_APIENTRY OMX_GetHandle(\n    OMX_OUT OMX_HANDLETYPE* pHandle, \n    OMX_IN  OMX_STRING cComponentName,\n    OMX_IN  OMX_PTR pAppData,\n    OMX_IN  OMX_CALLBACKTYPE* pCallBacks);\n\n\n/** The OMX_FreeHandle method will free a handle allocated by the OMX_GetHandle \n    method.  If the component reference count goes to zero, the component will\n    be unloaded from memory.  \n    \n    The core should return from this call within 20 msec when the component is \n    in the OMX_StateLoaded state.\n\n    @param [in] hComponent\n        Handle of the component to be accessed.  This is the component\n        handle returned by the call to the GetHandle function.\n    @return OMX_ERRORTYPE\n        If the command successfully executes, the return code will be\n        OMX_ErrorNone.  Otherwise the appropriate OMX error will be returned.\n    @ingroup core\n */\nOMX_API OMX_ERRORTYPE OMX_APIENTRY OMX_FreeHandle(\n    OMX_IN  OMX_HANDLETYPE hComponent);\n\n\n\n/** The OMX_SetupTunnel method will handle the necessary calls to the components\n    to setup the specified tunnel the two components.  NOTE: This is\n    an actual method (not a #define macro).  This method will make calls into\n    the component ComponentTunnelRequest method to do the actual tunnel \n    connection.  \n\n    The ComponentTunnelRequest method on both components will be called. \n    This method shall not be called unless the component is in the \n    OMX_StateLoaded state except when the ports used for the tunnel are\n    disabled. In this case, the component may be in the OMX_StateExecuting,\n    OMX_StatePause, or OMX_StateIdle states. \n\n    The core should return from this call within 20 msec.\n    \n    @param [in] hOutput\n        Handle of the component to be accessed.  Also this is the handle\n        of the component whose port, specified in the nPortOutput parameter\n        will be used the source for the tunnel. This is the component handle\n        returned by the call to the OMX_GetHandle function.  There is a \n        requirement that hOutput be the source for the data when\n        tunelling (i.e. nPortOutput is an output port).  If 0x0, the component\n        specified in hInput will have it's port specified in nPortInput\n        setup for communication with the application / IL client.\n    @param [in] nPortOutput\n        nPortOutput is used to select the source port on component to be\n        used in the tunnel. \n    @param [in] hInput\n        This is the component to setup the tunnel with. This is the handle\n        of the component whose port, specified in the nPortInput parameter\n        will be used the destination for the tunnel. This is the component handle\n        returned by the call to the OMX_GetHandle function.  There is a \n        requirement that hInput be the destination for the data when\n        tunelling (i.e. nPortInut is an input port).   If 0x0, the component\n        specified in hOutput will have it's port specified in nPortPOutput\n        setup for communication with the application / IL client.\n    @param [in] nPortInput\n        nPortInput is used to select the destination port on component to be\n        used in the tunnel.\n    @return OMX_ERRORTYPE\n        If the command successfully executes, the return code will be\n        OMX_ErrorNone.  Otherwise the appropriate OMX error will be returned.\n        When OMX_ErrorNotImplemented is returned, one or both components is \n        a non-interop component and does not support tunneling.\n        \n        On failure, the ports of both components are setup for communication\n        with the application / IL Client.\n    @ingroup core tun\n */\nOMX_API OMX_ERRORTYPE OMX_APIENTRY OMX_SetupTunnel(\n    OMX_IN  OMX_HANDLETYPE hOutput,\n    OMX_IN  OMX_U32 nPortOutput,\n    OMX_IN  OMX_HANDLETYPE hInput,\n    OMX_IN  OMX_U32 nPortInput);\n    \n/** @ingroup cp */\nOMX_API OMX_ERRORTYPE   OMX_GetContentPipe(\n    OMX_OUT OMX_HANDLETYPE *hPipe,\n    OMX_IN OMX_STRING szURI);\n\n/** The OMX_GetComponentsOfRole method will return the number of components that support the given\n    role and (if the compNames field is non-NULL) the names of those components. The call will fail if \n    an insufficiently sized array of names is supplied. To ensure the array is sufficiently sized the\n    client should:\n        * first call this function with the compNames field NULL to determine the number of component names\n        * second call this function with the compNames field pointing to an array of names allocated \n          according to the number returned by the first call.\n\n    The core should return from this call within 5 msec.\n    \n    @param [in] role\n        This is generic standard component name consisting only of component class \n        name and the type within that class (e.g. 'audio_decoder.aac').\n    @param [inout] pNumComps\n        This is used both as input and output. \n \n        If compNames is NULL, the input is ignored and the output specifies how many components support\n        the given role.\n     \n        If compNames is not NULL, on input it bounds the size of the input structure and \n        on output, it specifies the number of components string names listed within the compNames parameter.\n    @param [inout] compNames\n        If NULL this field is ignored. If non-NULL this points to an array of 128-byte strings which accepts \n        a list of the names of all physical components that implement the specified standard component name. \n        Each name is NULL terminated. numComps indicates the number of names.\n    @ingroup core\n */\nOMX_API OMX_ERRORTYPE OMX_GetComponentsOfRole ( \n\tOMX_IN      OMX_STRING role,\n    OMX_INOUT   OMX_U32 *pNumComps,\n    OMX_INOUT   OMX_U8  **compNames);\n\n/** The OMX_GetRolesOfComponent method will return the number of roles supported by the given\n    component and (if the roles field is non-NULL) the names of those roles. The call will fail if \n    an insufficiently sized array of names is supplied. To ensure the array is sufficiently sized the\n    client should:\n        * first call this function with the roles field NULL to determine the number of role names\n        * second call this function with the roles field pointing to an array of names allocated \n          according to the number returned by the first call.\n\n    The core should return from this call within 5 msec.\n\n    @param [in] compName\n        This is the name of the component being queried about.\n    @param [inout] pNumRoles\n        This is used both as input and output. \n \n        If roles is NULL, the input is ignored and the output specifies how many roles the component supports.\n     \n        If compNames is not NULL, on input it bounds the size of the input structure and \n        on output, it specifies the number of roles string names listed within the roles parameter.\n    @param [out] roles\n        If NULL this field is ignored. If non-NULL this points to an array of 128-byte strings \n        which accepts a list of the names of all standard components roles implemented on the \n        specified component name. numComps indicates the number of names.\n    @ingroup core\n */\nOMX_API OMX_ERRORTYPE OMX_GetRolesOfComponent ( \n\tOMX_IN      OMX_STRING compName, \n    OMX_INOUT   OMX_U32 *pNumRoles,\n    OMX_OUT     OMX_U8 **roles);\n\n#ifdef __cplusplus\n}\n#endif /* __cplusplus */\n\n#endif\n/* File EOF */\n\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/IL/OMX_ILCS.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n// OpenMAX IL - ILCS specific types\n\n#ifndef OMX_ILCS_h\n#define OMX_ILCS_h\n\ntypedef struct OMX_PARAM_PORTSUMMARYTYPE {\n   OMX_U32 nSize;            /**< Size of the structure in bytes */\n   OMX_VERSIONTYPE nVersion; /**< OMX specification version information */\n   OMX_U32 nNumPorts;        /**< Total number of ports */\n   OMX_U32 reqSet;           /**< Which set of ports is details below, portIndex[0] is port reqSet*32 */\n   OMX_U32 portDir;          /**< Bitfield, 1 if output port, 0 if input port, max 256 ports */\n   OMX_U32 portIndex[32];    /**< Port Indexes */\n} OMX_PARAM_PORTSUMMARYTYPE;\n\ntypedef struct OMX_PARAM_MARKCOMPARISONTYPE {\n   OMX_U32 nSize;            /**< Size of the structure in bytes */\n   OMX_VERSIONTYPE nVersion; /**< OMX specification version information */\n   OMX_PTR mark;             /**< Pointer to be used for mark comparisons */\n} OMX_PARAM_MARKCOMPARISONTYPE;\n\ntypedef struct OMX_PARAM_BRCMRECURSIONUNSAFETYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_S32 (*pRecursionUnsafe)(OMX_PTR param);\n   OMX_PTR param;\n} OMX_PARAM_BRCMRECURSIONUNSAFETYPE;\n\ntypedef struct OMX_PARAM_TUNNELSTATUSTYPE {\n   OMX_U32 nSize;            /**< Size of the structure in bytes */\n   OMX_VERSIONTYPE nVersion; /**< OMX specification version information */\n   OMX_U32 nPortIndex;       /**< Port being queried */\n   OMX_U32 nIndex;           /**< Query the nIndex'th port and fill in nPortIndex */\n   OMX_BOOL bUseIndex;       /**< If OMX_TRUE read nIndex, otherwise read nPortIndex */\n   OMX_PTR hTunneledComponent; /**< Component currently tunnelling with */\n   OMX_U32 nTunneledPort;    /**< Port on tunnelled component */\n} OMX_PARAM_TUNNELSTATUSTYPE;\n\n#endif\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/IL/OMX_IVCommon.h",
    "content": "/**\n * Copyright (c) 2008 The Khronos Group Inc. \n * \n * Permission is hereby granted, free of charge, to any person obtaining\n * a copy of this software and associated documentation files (the\n * \"Software\"), to deal in the Software without restriction, including\n * without limitation the rights to use, copy, modify, merge, publish,\n * distribute, sublicense, and/or sell copies of the Software, and to\n * permit persons to whom the Software is furnished to do so, subject\n * to the following conditions: \n * The above copyright notice and this permission notice shall be included\n * in all copies or substantial portions of the Software. \n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\n * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\n * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\n * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \n *\n */\n\n/** \n * @file OMX_IVCommon.h - OpenMax IL version 1.1.2\n *  The structures needed by Video and Image components to exchange\n *  parameters and configuration data with the components.\n */\n#ifndef OMX_IVCommon_h\n#define OMX_IVCommon_h\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif /* __cplusplus */\n\n/**\n * Each OMX header must include all required header files to allow the header\n * to compile without errors.  The includes below are required for this header\n * file to compile successfully \n */\n\n#include \"OMX_Core.h\"\n\n/** @defgroup iv OpenMAX IL Imaging and Video Domain\n * Common structures for OpenMAX IL Imaging and Video domains\n * @{\n */\n\n\n/** \n * Enumeration defining possible uncompressed image/video formats. \n *\n * ENUMS:\n *  Unused                 : Placeholder value when format is N/A\n *  Monochrome             : black and white\n *  8bitRGB332             : Red 7:5, Green 4:2, Blue 1:0\n *  12bitRGB444            : Red 11:8, Green 7:4, Blue 3:0\n *  16bitARGB4444          : Alpha 15:12, Red 11:8, Green 7:4, Blue 3:0\n *  16bitARGB1555          : Alpha 15, Red 14:10, Green 9:5, Blue 4:0\n *  16bitRGB565            : Red 15:11, Green 10:5, Blue 4:0\n *  16bitBGR565            : Blue 15:11, Green 10:5, Red 4:0\n *  18bitRGB666            : Red 17:12, Green 11:6, Blue 5:0\n *  18bitARGB1665          : Alpha 17, Red 16:11, Green 10:5, Blue 4:0\n *  19bitARGB1666          : Alpha 18, Red 17:12, Green 11:6, Blue 5:0\n *  24bitRGB888            : Red 24:16, Green 15:8, Blue 7:0\n *  24bitBGR888            : Blue 24:16, Green 15:8, Red 7:0\n *  24bitARGB1887          : Alpha 23, Red 22:15, Green 14:7, Blue 6:0\n *  25bitARGB1888          : Alpha 24, Red 23:16, Green 15:8, Blue 7:0\n *  32bitBGRA8888          : Blue 31:24, Green 23:16, Red 15:8, Alpha 7:0\n *  32bitARGB8888          : Alpha 31:24, Red 23:16, Green 15:8, Blue 7:0\n *  YUV411Planar           : U,Y are subsampled by a factor of 4 horizontally\n *  YUV411PackedPlanar     : packed per payload in planar slices\n *  YUV420Planar           : Three arrays Y,U,V.\n *  YUV420PackedPlanar     : packed per payload in planar slices\n *  YUV420SemiPlanar       : Two arrays, one is all Y, the other is U and V\n *  YUV422Planar           : Three arrays Y,U,V.\n *  YUV422PackedPlanar     : packed per payload in planar slices\n *  YUV422SemiPlanar       : Two arrays, one is all Y, the other is U and V\n *  YCbYCr                 : Organized as 16bit YUYV (i.e. YCbYCr)\n *  YCrYCb                 : Organized as 16bit YVYU (i.e. YCrYCb)\n *  CbYCrY                 : Organized as 16bit UYVY (i.e. CbYCrY)\n *  CrYCbY                 : Organized as 16bit VYUY (i.e. CrYCbY)\n *  YUV444Interleaved      : Each pixel contains equal parts YUV\n *  RawBayer8bit           : SMIA camera output format\n *  RawBayer10bit          : SMIA camera output format\n *  RawBayer8bitcompressed : SMIA camera output format\n Vendor extensions\n *  32bitABGR888           : Alpha 31:24, Blue 23:16, Green 15:8, Red 7:0\n */\ntypedef enum OMX_COLOR_FORMATTYPE {\n    OMX_COLOR_FormatUnused,\n    OMX_COLOR_FormatMonochrome,\n    OMX_COLOR_Format8bitRGB332,\n    OMX_COLOR_Format12bitRGB444,\n    OMX_COLOR_Format16bitARGB4444,\n    OMX_COLOR_Format16bitARGB1555,\n    OMX_COLOR_Format16bitRGB565,\n    OMX_COLOR_Format16bitBGR565,\n    OMX_COLOR_Format18bitRGB666,\n    OMX_COLOR_Format18bitARGB1665,\n    OMX_COLOR_Format19bitARGB1666, \n    OMX_COLOR_Format24bitRGB888,\n    OMX_COLOR_Format24bitBGR888,\n    OMX_COLOR_Format24bitARGB1887,\n    OMX_COLOR_Format25bitARGB1888,\n    OMX_COLOR_Format32bitBGRA8888,\n    OMX_COLOR_Format32bitARGB8888,\n    OMX_COLOR_FormatYUV411Planar,\n    OMX_COLOR_FormatYUV411PackedPlanar,\n    OMX_COLOR_FormatYUV420Planar,\n    OMX_COLOR_FormatYUV420PackedPlanar,\n    OMX_COLOR_FormatYUV420SemiPlanar,\n    OMX_COLOR_FormatYUV422Planar,\n    OMX_COLOR_FormatYUV422PackedPlanar,\n    OMX_COLOR_FormatYUV422SemiPlanar,\n    OMX_COLOR_FormatYCbYCr,\n    OMX_COLOR_FormatYCrYCb,\n    OMX_COLOR_FormatCbYCrY,\n    OMX_COLOR_FormatCrYCbY,\n    OMX_COLOR_FormatYUV444Interleaved,\n    OMX_COLOR_FormatRawBayer8bit,\n    OMX_COLOR_FormatRawBayer10bit,\n    OMX_COLOR_FormatRawBayer8bitcompressed,\n    OMX_COLOR_FormatL2, \n    OMX_COLOR_FormatL4, \n    OMX_COLOR_FormatL8, \n    OMX_COLOR_FormatL16, \n    OMX_COLOR_FormatL24, \n    OMX_COLOR_FormatL32,\n    OMX_COLOR_FormatYUV420PackedSemiPlanar,\n    OMX_COLOR_FormatYUV422PackedSemiPlanar,\n    OMX_COLOR_Format18BitBGR666,\n    OMX_COLOR_Format24BitARGB6666,\n    OMX_COLOR_Format24BitABGR6666,\n    OMX_COLOR_FormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_COLOR_FormatVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_COLOR_Format32bitABGR8888,\n    OMX_COLOR_Format8bitPalette,\n    OMX_COLOR_FormatYUVUV128,\n    OMX_COLOR_FormatRawBayer12bit,\n    OMX_COLOR_FormatBRCMEGL,\n    OMX_COLOR_FormatBRCMOpaque,\n    OMX_COLOR_FormatYVU420PackedPlanar,\n    OMX_COLOR_FormatYVU420PackedSemiPlanar,\n    OMX_COLOR_FormatRawBayer16bit,\n    OMX_COLOR_FormatMax = 0x7FFFFFFF\n} OMX_COLOR_FORMATTYPE;\n\n\n/** \n * Defines the matrix for conversion from RGB to YUV or vice versa.\n * iColorMatrix should be initialized with the fixed point values \n * used in converting between formats.\n */\ntypedef struct OMX_CONFIG_COLORCONVERSIONTYPE {\n    OMX_U32 nSize;              /**< Size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion;   /**< OMX specification version info */ \n    OMX_U32 nPortIndex;         /**< Port that this struct applies to */\n    OMX_S32 xColorMatrix[3][3]; /**< Stored in signed Q16 format */\n    OMX_S32 xColorOffset[4];    /**< Stored in signed Q16 format */\n}OMX_CONFIG_COLORCONVERSIONTYPE;\n\n\n/** \n * Structure defining percent to scale each frame dimension.  For example:  \n * To make the width 50% larger, use fWidth = 1.5 and to make the width\n * 1/2 the original size, use fWidth = 0.5\n */\ntypedef struct OMX_CONFIG_SCALEFACTORTYPE {\n    OMX_U32 nSize;            /**< Size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion; /**< OMX specification version info */ \n    OMX_U32 nPortIndex;       /**< Port that this struct applies to */\n    OMX_S32 xWidth;           /**< Fixed point value stored as Q16 */\n    OMX_S32 xHeight;          /**< Fixed point value stored as Q16 */\n}OMX_CONFIG_SCALEFACTORTYPE;\n\n\n/** \n * Enumeration of possible image filter types \n */\ntypedef enum OMX_IMAGEFILTERTYPE {\n    OMX_ImageFilterNone,\n    OMX_ImageFilterNoise,\n    OMX_ImageFilterEmboss,\n    OMX_ImageFilterNegative,\n    OMX_ImageFilterSketch,\n    OMX_ImageFilterOilPaint,\n    OMX_ImageFilterHatch,\n    OMX_ImageFilterGpen,\n    OMX_ImageFilterAntialias, \n    OMX_ImageFilterDeRing,       \n    OMX_ImageFilterSolarize,\n    OMX_ImageFilterKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_ImageFilterVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n      \n    /* Broadcom specific image filters */\n    OMX_ImageFilterWatercolor,\n    OMX_ImageFilterPastel,\n    OMX_ImageFilterSharpen,\n    OMX_ImageFilterFilm,\n    OMX_ImageFilterBlur,\n    OMX_ImageFilterSaturation,\n\n    OMX_ImageFilterDeInterlaceLineDouble,\n    OMX_ImageFilterDeInterlaceAdvanced,\n    \n    OMX_ImageFilterColourSwap,\n    OMX_ImageFilterWashedOut,\n    OMX_ImageFilterColourPoint,\n    OMX_ImageFilterPosterise,\n    OMX_ImageFilterColourBalance,\n    OMX_ImageFilterCartoon,\n\n    OMX_ImageFilterAnaglyph,\n    OMX_ImageFilterDeInterlaceFast,\n    OMX_ImageFilterMax = 0x7FFFFFFF\n} OMX_IMAGEFILTERTYPE;\n\ntypedef enum OMX_IMAGEFILTERANAGLYPHTYPE {\n    OMX_ImageFilterAnaglyphNone,\n    OMX_ImageFilterAnaglyphSBStoRedCyan,\n    OMX_ImageFilterAnaglyphSBStoCyanRed,\n    OMX_ImageFilterAnaglyphSBStoGreenMagenta,\n    OMX_ImageFilterAnaglyphSBStoMagentaGreen,\n    OMX_ImageFilterAnaglyphTABtoRedCyan,\n    OMX_ImageFilterAnaglyphTABtoCyanRed,\n    OMX_ImageFilterAnaglyphTABtoGreenMagenta,\n    OMX_ImageFilterAnaglyphTABtoMagentaGreen,\n} OMX_IMAGEFILTERANAGLYPHTYPE;\n\n/** \n * Image filter configuration \n *\n * STRUCT MEMBERS:\n *  nSize        : Size of the structure in bytes       \n *  nVersion     : OMX specification version information\n *  nPortIndex   : Port that this structure applies to \n *  eImageFilter : Image filter type enumeration      \n */\ntypedef struct OMX_CONFIG_IMAGEFILTERTYPE {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n    OMX_IMAGEFILTERTYPE eImageFilter;\n} OMX_CONFIG_IMAGEFILTERTYPE;\n\n\n/** \n * Customized U and V for color enhancement \n *\n * STRUCT MEMBERS:\n *  nSize             : Size of the structure in bytes\n *  nVersion          : OMX specification version information \n *  nPortIndex        : Port that this structure applies to\n *  bColorEnhancement : Enable/disable color enhancement\n *  nCustomizedU      : Practical values: 16-240, range: 0-255, value set for \n *                      U component\n *  nCustomizedV      : Practical values: 16-240, range: 0-255, value set for \n *                      V component\n */\ntypedef struct OMX_CONFIG_COLORENHANCEMENTTYPE {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion; \n    OMX_U32 nPortIndex;\n    OMX_BOOL bColorEnhancement;\n    OMX_U8 nCustomizedU;\n    OMX_U8 nCustomizedV;\n} OMX_CONFIG_COLORENHANCEMENTTYPE;\n\n\n/** \n * Define color key and color key mask \n *\n * STRUCT MEMBERS:\n *  nSize      : Size of the structure in bytes\n *  nVersion   : OMX specification version information \n *  nPortIndex : Port that this structure applies to\n *  nARGBColor : 32bit Alpha, Red, Green, Blue Color\n *  nARGBMask  : 32bit Mask for Alpha, Red, Green, Blue channels\n */\ntypedef struct OMX_CONFIG_COLORKEYTYPE {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n    OMX_U32 nARGBColor;\n    OMX_U32 nARGBMask;\n} OMX_CONFIG_COLORKEYTYPE;\n\n\n/** \n * List of color blend types for pre/post processing \n *\n * ENUMS:\n *  None          : No color blending present\n *  AlphaConstant : Function is (alpha_constant * src) + \n *                  (1 - alpha_constant) * dst)\n *  AlphaPerPixel : Function is (alpha * src) + (1 - alpha) * dst)\n *  Alternate     : Function is alternating pixels from src and dst\n *  And           : Function is (src & dst)\n *  Or            : Function is (src | dst)\n *  Invert        : Function is ~src\n */\ntypedef enum OMX_COLORBLENDTYPE {\n    OMX_ColorBlendNone,\n    OMX_ColorBlendAlphaConstant,\n    OMX_ColorBlendAlphaPerPixel,\n    OMX_ColorBlendAlternate,\n    OMX_ColorBlendAnd,\n    OMX_ColorBlendOr,\n    OMX_ColorBlendInvert,\n    OMX_ColorBlendKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_ColorBlendVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_ColorBlendMax = 0x7FFFFFFF\n} OMX_COLORBLENDTYPE;\n\n\n/** \n * Color blend configuration \n *\n * STRUCT MEMBERS:\n *  nSize             : Size of the structure in bytes                        \n *  nVersion          : OMX specification version information                \n *  nPortIndex        : Port that this structure applies to                   \n *  nRGBAlphaConstant : Constant global alpha values when global alpha is used\n *  eColorBlend       : Color blend type enumeration                         \n */\ntypedef struct OMX_CONFIG_COLORBLENDTYPE {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n    OMX_U32 nRGBAlphaConstant;\n    OMX_COLORBLENDTYPE  eColorBlend;\n} OMX_CONFIG_COLORBLENDTYPE;\n\n\n/** \n * Hold frame dimension\n *\n * STRUCT MEMBERS:\n *  nSize      : Size of the structure in bytes      \n *  nVersion   : OMX specification version information\n *  nPortIndex : Port that this structure applies to     \n *  nWidth     : Frame width in pixels                 \n *  nHeight    : Frame height in pixels                \n */\ntypedef struct OMX_FRAMESIZETYPE {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n    OMX_U32 nWidth;\n    OMX_U32 nHeight;\n} OMX_FRAMESIZETYPE;\n\n\n/**\n * Rotation configuration \n *\n * STRUCT MEMBERS:\n *  nSize      : Size of the structure in bytes             \n *  nVersion   : OMX specification version information\n *  nPortIndex : Port that this structure applies to\n *  nRotation  : +/- integer rotation value               \n */\ntypedef struct OMX_CONFIG_ROTATIONTYPE {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n    OMX_S32 nRotation; \n} OMX_CONFIG_ROTATIONTYPE;\n\n\n/** \n * Possible mirroring directions for pre/post processing \n *\n * ENUMS:\n *  None       : No mirroring                         \n *  Vertical   : Vertical mirroring, flip on X axis   \n *  Horizontal : Horizontal mirroring, flip on Y axis  \n *  Both       : Both vertical and horizontal mirroring\n */\ntypedef enum OMX_MIRRORTYPE {\n    OMX_MirrorNone = 0,\n    OMX_MirrorVertical,\n    OMX_MirrorHorizontal,\n    OMX_MirrorBoth, \n    OMX_MirrorKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_MirrorVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_MirrorMax = 0x7FFFFFFF   \n} OMX_MIRRORTYPE;\n\n\n/** \n * Mirroring configuration \n *\n * STRUCT MEMBERS:\n *  nSize      : Size of the structure in bytes      \n *  nVersion   : OMX specification version information\n *  nPortIndex : Port that this structure applies to  \n *  eMirror    : Mirror type enumeration              \n */\ntypedef struct OMX_CONFIG_MIRRORTYPE {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion; \n    OMX_U32 nPortIndex;\n    OMX_MIRRORTYPE  eMirror;\n} OMX_CONFIG_MIRRORTYPE;\n\n\n/** \n * Position information only \n *\n * STRUCT MEMBERS:\n *  nSize      : Size of the structure in bytes               \n *  nVersion   : OMX specification version information\n *  nPortIndex : Port that this structure applies to\n *  nX         : X coordinate for the point                     \n *  nY         : Y coordinate for the point \n */                      \ntypedef struct OMX_CONFIG_POINTTYPE {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n    OMX_S32 nX;\n    OMX_S32 nY;\n} OMX_CONFIG_POINTTYPE;\n\n\n/** \n * Frame size plus position \n *\n * STRUCT MEMBERS:\n *  nSize      : Size of the structure in bytes                    \n *  nVersion   : OMX specification version information      \n *  nPortIndex : Port that this structure applies to    \n *  nLeft      : X Coordinate of the top left corner of the rectangle\n *  nTop       : Y Coordinate of the top left corner of the rectangle\n *  nWidth     : Width of the rectangle                              \n *  nHeight    : Height of the rectangle                             \n */\ntypedef struct OMX_CONFIG_RECTTYPE {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;  \n    OMX_U32 nPortIndex; \n    OMX_S32 nLeft; \n    OMX_S32 nTop;\n    OMX_U32 nWidth;\n    OMX_U32 nHeight;\n} OMX_CONFIG_RECTTYPE;\n\n\n/** \n * Deblocking state; it is required to be set up before starting the codec \n *\n * STRUCT MEMBERS:\n *  nSize       : Size of the structure in bytes      \n *  nVersion    : OMX specification version information \n *  nPortIndex  : Port that this structure applies to\n *  bDeblocking : Enable/disable deblocking mode    \n */\ntypedef struct OMX_PARAM_DEBLOCKINGTYPE {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n    OMX_BOOL bDeblocking;\n} OMX_PARAM_DEBLOCKINGTYPE;\n\n\n/** \n * Stabilization state \n *\n * STRUCT MEMBERS:\n *  nSize      : Size of the structure in bytes          \n *  nVersion   : OMX specification version information    \n *  nPortIndex : Port that this structure applies to   \n *  bStab      : Enable/disable frame stabilization state\n */\ntypedef struct OMX_CONFIG_FRAMESTABTYPE {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n    OMX_BOOL bStab;\n} OMX_CONFIG_FRAMESTABTYPE;\n\n\n/** \n * White Balance control type \n *\n * STRUCT MEMBERS:\n *  SunLight : Referenced in JSR-234\n *  Flash    : Optimal for device's integrated flash\n */\ntypedef enum OMX_WHITEBALCONTROLTYPE {\n    OMX_WhiteBalControlOff = 0,\n    OMX_WhiteBalControlAuto,\n    OMX_WhiteBalControlSunLight,\n    OMX_WhiteBalControlCloudy,\n    OMX_WhiteBalControlShade,\n    OMX_WhiteBalControlTungsten,\n    OMX_WhiteBalControlFluorescent,\n    OMX_WhiteBalControlIncandescent,\n    OMX_WhiteBalControlFlash,\n    OMX_WhiteBalControlHorizon,\n    OMX_WhiteBalControlKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_WhiteBalControlVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_WhiteBalControlMax = 0x7FFFFFFF\n} OMX_WHITEBALCONTROLTYPE;\n\n\n/** \n * White Balance control configuration \n *\n * STRUCT MEMBERS:\n *  nSize            : Size of the structure in bytes       \n *  nVersion         : OMX specification version information\n *  nPortIndex       : Port that this structure applies to                 \n *  eWhiteBalControl : White balance enumeration            \n */\ntypedef struct OMX_CONFIG_WHITEBALCONTROLTYPE {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n    OMX_WHITEBALCONTROLTYPE eWhiteBalControl;\n} OMX_CONFIG_WHITEBALCONTROLTYPE;\n\n\n/** \n * Exposure control type \n */\ntypedef enum OMX_EXPOSURECONTROLTYPE {\n    OMX_ExposureControlOff = 0,\n    OMX_ExposureControlAuto,\n    OMX_ExposureControlNight,\n    OMX_ExposureControlBackLight,\n    OMX_ExposureControlSpotLight,\n    OMX_ExposureControlSports,\n    OMX_ExposureControlSnow,\n    OMX_ExposureControlBeach,\n    OMX_ExposureControlLargeAperture,\n    OMX_ExposureControlSmallAperture,\n    OMX_ExposureControlKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_ExposureControlVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_ExposureControlVeryLong,\n    OMX_ExposureControlFixedFps,\n    OMX_ExposureControlNightWithPreview,\n    OMX_ExposureControlAntishake,\n    OMX_ExposureControlFireworks,\n    OMX_ExposureControlMax = 0x7FFFFFFF\n} OMX_EXPOSURECONTROLTYPE;\n\n\n/** \n * White Balance control configuration \n *\n * STRUCT MEMBERS:\n *  nSize            : Size of the structure in bytes      \n *  nVersion         : OMX specification version information\n *  nPortIndex       : Port that this structure applies to                \n *  eExposureControl : Exposure control enumeration         \n */\ntypedef struct OMX_CONFIG_EXPOSURECONTROLTYPE {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n    OMX_EXPOSURECONTROLTYPE eExposureControl;\n} OMX_CONFIG_EXPOSURECONTROLTYPE;\n\n\n/** \n * Defines sensor supported mode. \n *\n * STRUCT MEMBERS:\n *  nSize      : Size of the structure in bytes           \n *  nVersion   : OMX specification version information\n *  nPortIndex : Port that this structure applies to \n *  nFrameRate : Single shot mode is indicated by a 0     \n *  bOneShot   : Enable for single shot, disable for streaming\n *  sFrameSize : Framesize                                          \n */\ntypedef struct OMX_PARAM_SENSORMODETYPE {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n    OMX_U32 nFrameRate;\n    OMX_BOOL bOneShot;\n    OMX_FRAMESIZETYPE sFrameSize;\n} OMX_PARAM_SENSORMODETYPE;\n\n\n/** \n * Defines contrast level \n *\n * STRUCT MEMBERS:\n *  nSize      : Size of the structure in bytes                              \n *  nVersion   : OMX specification version information                \n *  nPortIndex : Port that this structure applies to                 \n *  nContrast  : Values allowed for contrast -100 to 100, zero means no change\n */\ntypedef struct OMX_CONFIG_CONTRASTTYPE {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n    OMX_S32 nContrast;\n} OMX_CONFIG_CONTRASTTYPE;\n\n\n/** \n * Defines brightness level \n *\n * STRUCT MEMBERS:\n *  nSize       : Size of the structure in bytes          \n *  nVersion    : OMX specification version information \n *  nPortIndex  : Port that this structure applies to \n *  nBrightness : 0-100%        \n */\ntypedef struct OMX_CONFIG_BRIGHTNESSTYPE {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n    OMX_U32 nBrightness;\n} OMX_CONFIG_BRIGHTNESSTYPE;\n\n\n/** \n * Defines backlight level configuration for a video sink, e.g. LCD panel \n *\n * STRUCT MEMBERS:\n *  nSize      : Size of the structure in bytes\n *  nVersion   : OMX specification version information \n *  nPortIndex : Port that this structure applies to\n *  nBacklight : Values allowed for backlight 0-100%\n *  nTimeout   : Number of milliseconds before backlight automatically turns \n *               off.  A value of 0x0 disables backight timeout \n */\ntypedef struct OMX_CONFIG_BACKLIGHTTYPE {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n    OMX_U32 nBacklight;\n    OMX_U32 nTimeout;\n} OMX_CONFIG_BACKLIGHTTYPE;\n\n\n/** \n * Defines setting for Gamma \n *\n * STRUCT MEMBERS:\n *  nSize      : Size of the structure in bytes\n *  nVersion   : OMX specification version information \n *  nPortIndex : Port that this structure applies to\n *  nGamma     : Values allowed for gamma -100 to 100, zero means no change\n */\ntypedef struct OMX_CONFIG_GAMMATYPE {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n    OMX_S32 nGamma;\n} OMX_CONFIG_GAMMATYPE;\n\n\n/** \n * Define for setting saturation \n * \n * STRUCT MEMBERS:\n *  nSize       : Size of the structure in bytes\n *  nVersion    : OMX specification version information\n *  nPortIndex  : Port that this structure applies to\n *  nSaturation : Values allowed for saturation -100 to 100, zero means \n *                no change\n */\ntypedef struct OMX_CONFIG_SATURATIONTYPE {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n    OMX_S32 nSaturation;\n} OMX_CONFIG_SATURATIONTYPE;\n\n\n/** \n * Define for setting Lightness \n *\n * STRUCT MEMBERS:\n *  nSize      : Size of the structure in bytes\n *  nVersion   : OMX specification version information\n *  nPortIndex : Port that this structure applies to\n *  nLightness : Values allowed for lightness -100 to 100, zero means no \n *               change\n */\ntypedef struct OMX_CONFIG_LIGHTNESSTYPE {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n    OMX_S32 nLightness;\n} OMX_CONFIG_LIGHTNESSTYPE;\n\n\n/** \n * Plane blend configuration \n *\n * STRUCT MEMBERS:\n *  nSize      : Size of the structure in bytes \n *  nVersion   : OMX specification version information\n *  nPortIndex : Index of input port associated with the plane.\n *  nDepth     : Depth of the plane in relation to the screen. Higher \n *               numbered depths are \"behind\" lower number depths.  \n *               This number defaults to the Port Index number.\n *  nAlpha     : Transparency blending component for the entire plane.  \n *               See blending modes for more detail.\n */\ntypedef struct OMX_CONFIG_PLANEBLENDTYPE {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n    OMX_U32 nDepth;\n    OMX_U32 nAlpha;\n} OMX_CONFIG_PLANEBLENDTYPE;\n\n\n/** \n * Define interlace type\n *\n * STRUCT MEMBERS:\n *  nSize                 : Size of the structure in bytes \n *  nVersion              : OMX specification version information \n *  nPortIndex            : Port that this structure applies to\n *  bEnable               : Enable control variable for this functionality \n *                          (see below)\n *  nInterleavePortIndex  : Index of input or output port associated with  \n *                          the interleaved plane. \n *  pPlanarPortIndexes[4] : Index of input or output planar ports.\n */\ntypedef struct OMX_PARAM_INTERLEAVETYPE {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n    OMX_BOOL bEnable;\n    OMX_U32 nInterleavePortIndex;\n} OMX_PARAM_INTERLEAVETYPE;\n\n\n/** \n * Defines the picture effect used for an input picture \n */\ntypedef enum OMX_TRANSITIONEFFECTTYPE {\n    OMX_EffectNone,\n    OMX_EffectFadeFromBlack,\n    OMX_EffectFadeToBlack,\n    OMX_EffectUnspecifiedThroughConstantColor,\n    OMX_EffectDissolve,\n    OMX_EffectWipe,\n    OMX_EffectUnspecifiedMixOfTwoScenes,\n    OMX_EffectKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_EffectVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n\n    OMX_EffectReverseUnspecifiedMixOfTwoScenes,\n    \n#ifndef __VIDEOCORE4__\n    OMX_EffectDiagonalWipe,\n    OMX_EffectDiagonalWipeRotate,\n    OMX_EffectEllipticalWipe,\n    OMX_EffectEllipticalWipeRotate,\n    OMX_EffectInverseEllipticalWipe,\n    OMX_EffectInverseEllipticalWipeRotate,\n    OMX_EffectGlassWipe,\n    OMX_EffectGlassWipeRotate,\n    OMX_EffectWavyWipe,\n    OMX_EffectWavyWipeRotate,\n    OMX_EffectMunchingSquares,\n    OMX_EffectStripeWipe,\n    OMX_EffectStripeWipeRotate,\n    \n    OMX_EffectRotozoomUnmatched,\n    OMX_EffectRotozoomMatched,\n    OMX_EffectRotozoomGentle,\n#endif\n\n    OMX_EffectMunchRandom,\n    OMX_EffectMunchVRandom,\n    OMX_EffectMunchHRandom,\n    OMX_EffectMunchWipe,\n    OMX_EffectMunchMunch,\n    OMX_EffectMunchStripe,\n    OMX_EffectFadeRandom,\n    OMX_EffectFadeVRandom,\n    OMX_EffectFadeHRandom,\n    OMX_EffectFadeWipe,\n    OMX_EffectFadeMunch,\n    OMX_EffectFadeStripe,\n    OMX_EffectColourBlockRandom,\n    OMX_EffectColourBlockVRandom,\n    OMX_EffectColourBlockHRandom,\n    OMX_EffectColourBlockWipe,\n    OMX_EffectColourBlockMunch,\n    OMX_EffectColourBlockStripe,\n    OMX_EffectColourBlock2Random,\n    OMX_EffectColourBlock2VRandom,\n    OMX_EffectColourBlock2HRandom,\n    OMX_EffectColourBlock2Wipe,\n    OMX_EffectColourBlock2Munch,\n    OMX_EffectColourBlock2Stripe,\n    OMX_EffectShadeRandom,\n    OMX_EffectShadeVRandom,\n    OMX_EffectShadeHRandom,\n    OMX_EffectShadeWipe,\n    OMX_EffectShadeMunch,\n    OMX_EffectShadeStripe,\n    OMX_EffectBitmaskRandom,\n    OMX_EffectBitmaskVRandom,\n    OMX_EffectBitmaskHRandom,\n    OMX_EffectBitmaskWipe,\n    OMX_EffectBitmaskMunch,\n    OMX_EffectBitmaskStripe,\n    OMX_EffectBitmask2Random,\n    OMX_EffectBitmask2VRandom,\n    OMX_EffectBitmask2HRandom,\n    OMX_EffectBitmask2Wipe,\n    OMX_EffectBitmask2Munch,\n    OMX_EffectBitmask2Stripe,\n    OMX_EffectBitmask2ColourRandom,\n    OMX_EffectBitmask2ColourVRandom,\n    OMX_EffectBitmask2ColourHRandom,\n    OMX_EffectBitmask2ColourWipe,\n    OMX_EffectBitmask2ColourMunch,\n    OMX_EffectBitmask2ColourStripe,\n\n    OMX_EffectPushRight,\n    OMX_EffectPushLeft,\n    OMX_EffectPushDown,\n    OMX_EffectPushUp,\n    OMX_EffectCoverRight,\n    OMX_EffectCoverLeft,\n    OMX_EffectCoverDown,\n    OMX_EffectCoverUp,\n    OMX_EffectRevealRight,\n    OMX_EffectRevealLeft,\n    OMX_EffectRevealDown,\n    OMX_EffectRevealUp,\n    OMX_EffectWipeRight,\n    OMX_EffectWipeLeft,\n    OMX_EffectWipeDown,\n    OMX_EffectWipeUp,\n    OMX_EffectSpeckle,\n    OMX_EffectCircle,\n    OMX_EffectSpiral,\n    OMX_EffectDiamond,\n    OMX_EffectVert,\n    OMX_EffectPlus,\n    OMX_EffectClock,\n    OMX_EffectPlasma,\n    OMX_EffectDisplace,\n    OMX_EffectGenie,\n    OMX_EffectSide,\n    OMX_EffectMaze,\n    OMX_EffectRipple,\n    OMX_EffectStar,\n    OMX_EffectAlpha,\n    OMX_EffectIntense,\n    OMX_EffectIntenseU,\n    OMX_EffectIntenseV,\n    OMX_EffectInverseIntense,\n    OMX_EffectInverseIntenseU,\n    OMX_EffectInverseIntenseV,\n\n    OMX_EffectPageTurn,\n\n    OMX_EffectFlipPlaneDown,\n    OMX_EffectFlipPlaneDownMid,\n    OMX_EffectFlipPlaneDownHigh,\n    OMX_EffectFlipPlaneLeft,\n    OMX_EffectFlipPlaneLeftMid,\n    OMX_EffectFlipPlaneLeftHigh,\n    OMX_EffectFlipCubeDown,\n    OMX_EffectFlipCubeDownMid,\n    OMX_EffectFlipCubeDownHigh,\n    OMX_EffectFlipCubeLeft,\n    OMX_EffectFlipCubeLeftMid,\n    OMX_EffectFlipCubeLeftHigh,\n\n    OMX_EffectMax = 0x7FFFFFFF\n} OMX_TRANSITIONEFFECTTYPE;\n\n\n/** \n * Structure used to configure current transition effect \n *\n * STRUCT MEMBERS:\n * nSize      : Size of the structure in bytes\n * nVersion   : OMX specification version information \n * nPortIndex : Port that this structure applies to\n * eEffect    : Effect to enable\n */\ntypedef struct OMX_CONFIG_TRANSITIONEFFECTTYPE {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n    OMX_TRANSITIONEFFECTTYPE eEffect;\n} OMX_CONFIG_TRANSITIONEFFECTTYPE;\n\n\n/** \n * Defines possible data unit types for encoded video data. The data unit \n * types are used both for encoded video input for playback as well as\n * encoded video output from recording. \n */\ntypedef enum OMX_DATAUNITTYPE {\n    OMX_DataUnitCodedPicture,\n    OMX_DataUnitVideoSegment,\n    OMX_DataUnitSeveralSegments,\n    OMX_DataUnitArbitraryStreamSection,\n    OMX_DataUnitKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_DataUnitVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_DataUnitMax = 0x7FFFFFFF\n} OMX_DATAUNITTYPE;\n\n\n/** \n * Defines possible encapsulation types for coded video data unit. The \n * encapsulation information is used both for encoded video input for \n * playback as well as encoded video output from recording. \n */\ntypedef enum OMX_DATAUNITENCAPSULATIONTYPE {\n    OMX_DataEncapsulationElementaryStream,\n    OMX_DataEncapsulationGenericPayload,\n    OMX_DataEncapsulationRtpPayload,\n    OMX_DataEncapsulationKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_DataEncapsulationVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_DataEncapsulationMax = 0x7FFFFFFF\n} OMX_DATAUNITENCAPSULATIONTYPE;\n\n\n/** \n * Structure used to configure the type of being decoded/encoded \n */\ntypedef struct OMX_PARAM_DATAUNITTYPE {\n    OMX_U32 nSize;            /**< Size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ \n    OMX_U32 nPortIndex;       /**< Port that this structure applies to */\n    OMX_DATAUNITTYPE eUnitType;\n    OMX_DATAUNITENCAPSULATIONTYPE eEncapsulationType;\n} OMX_PARAM_DATAUNITTYPE;\n\n\n/**\n * Defines dither types \n */\ntypedef enum OMX_DITHERTYPE {\n    OMX_DitherNone,\n    OMX_DitherOrdered,\n    OMX_DitherErrorDiffusion,\n    OMX_DitherOther,\n    OMX_DitherKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_DitherVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_DitherMax = 0x7FFFFFFF\n} OMX_DITHERTYPE;\n\n\n/** \n * Structure used to configure current type of dithering \n */\ntypedef struct OMX_CONFIG_DITHERTYPE {\n    OMX_U32 nSize;            /**< Size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ \n    OMX_U32 nPortIndex;       /**< Port that this structure applies to */\n    OMX_DITHERTYPE eDither;   /**< Type of dithering to use */\n} OMX_CONFIG_DITHERTYPE;\n\ntypedef struct OMX_CONFIG_CAPTUREMODETYPE {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;     /**< Port that this structure applies to */\n    OMX_BOOL bContinuous;   /**< If true then ignore frame rate and emit capture \n                             *   data as fast as possible (otherwise obey port's frame rate). */\n    OMX_BOOL bFrameLimited; /**< If true then terminate capture after the port emits the \n                             *   specified number of frames (otherwise the port does not \n                             *   terminate the capture until instructed to do so by the client). \n                             *   Even if set, the client may manually terminate the capture prior \n                             *   to reaching the limit. */\n    OMX_U32 nFrameLimit;      /**< Limit on number of frames emitted during a capture (only\n                               *   valid if bFrameLimited is set). */\n} OMX_CONFIG_CAPTUREMODETYPE;\n\ntypedef enum OMX_METERINGTYPE {\n \n    OMX_MeteringModeAverage,     /**< Center-weighted average metering. */\n    OMX_MeteringModeSpot,  \t      /**< Spot (partial) metering. */\n    OMX_MeteringModeMatrix,      /**< Matrix or evaluative metering. */\n \n    OMX_MeteringKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_MeteringVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_MeteringModeBacklit,\n    OMX_EVModeMax = 0x7fffffff\n} OMX_METERINGTYPE;\n \ntypedef struct OMX_CONFIG_EXPOSUREVALUETYPE {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n    OMX_METERINGTYPE eMetering;\n    OMX_S32 xEVCompensation;      /**< Fixed point value stored as Q16 */\n    OMX_U32 nApertureFNumber;     /**< e.g. nApertureFNumber = 2 implies \"f/2\" - Q16 format */\n    OMX_BOOL bAutoAperture;\t\t/**< Whether aperture number is defined automatically */\n    OMX_U32 nShutterSpeedMsec;    /**< Shutterspeed in milliseconds */ \n    OMX_BOOL bAutoShutterSpeed;\t/**< Whether shutter speed is defined automatically */ \n    OMX_U32 nSensitivity;         /**< e.g. nSensitivity = 100 implies \"ISO 100\" */\n    OMX_BOOL bAutoSensitivity;\t/**< Whether sensitivity is defined automatically */\n} OMX_CONFIG_EXPOSUREVALUETYPE;\n\n/** \n * Focus region configuration \n *\n * STRUCT MEMBERS:\n *  nSize           : Size of the structure in bytes\n *  nVersion        : OMX specification version information\n *  nPortIndex      : Port that this structure applies to\n *  bCenter         : Use center region as focus region of interest\n *  bLeft           : Use left region as focus region of interest\n *  bRight          : Use right region as focus region of interest\n *  bTop            : Use top region as focus region of interest\n *  bBottom         : Use bottom region as focus region of interest\n *  bTopLeft        : Use top left region as focus region of interest\n *  bTopRight       : Use top right region as focus region of interest\n *  bBottomLeft     : Use bottom left region as focus region of interest\n *  bBottomRight    : Use bottom right region as focus region of interest\n */\ntypedef struct OMX_CONFIG_FOCUSREGIONTYPE {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n    OMX_BOOL bCenter;\n    OMX_BOOL bLeft;\n    OMX_BOOL bRight;\n    OMX_BOOL bTop;\n    OMX_BOOL bBottom;\n    OMX_BOOL bTopLeft;\n    OMX_BOOL bTopRight;\n    OMX_BOOL bBottomLeft;\n    OMX_BOOL bBottomRight;\n} OMX_CONFIG_FOCUSREGIONTYPE;\n\n/** \n * Focus Status type \n */\ntypedef enum OMX_FOCUSSTATUSTYPE {\n    OMX_FocusStatusOff = 0,\n    OMX_FocusStatusRequest,\n    OMX_FocusStatusReached,\n    OMX_FocusStatusUnableToReach,\n    OMX_FocusStatusLost,\n    OMX_FocusStatusKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_FocusStatusVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_FocusStatusCafWatching,\n    OMX_FocusStatusCafSceneChanged,\n    OMX_FocusStatusMax = 0x7FFFFFFF\n} OMX_FOCUSSTATUSTYPE;\n\n/** \n * Focus status configuration \n *\n * STRUCT MEMBERS:\n *  nSize               : Size of the structure in bytes\n *  nVersion            : OMX specification version information\n *  nPortIndex          : Port that this structure applies to\n *  eFocusStatus        : Specifies the focus status\n *  bCenterStatus       : Use center region as focus region of interest\n *  bLeftStatus         : Use left region as focus region of interest\n *  bRightStatus        : Use right region as focus region of interest\n *  bTopStatus          : Use top region as focus region of interest\n *  bBottomStatus       : Use bottom region as focus region of interest\n *  bTopLeftStatus      : Use top left region as focus region of interest\n *  bTopRightStatus     : Use top right region as focus region of interest\n *  bBottomLeftStatus   : Use bottom left region as focus region of interest\n *  bBottomRightStatus  : Use bottom right region as focus region of interest\n */\ntypedef struct OMX_PARAM_FOCUSSTATUSTYPE {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n    OMX_FOCUSSTATUSTYPE eFocusStatus;\n    OMX_BOOL bCenterStatus;\n    OMX_BOOL bLeftStatus;\n    OMX_BOOL bRightStatus;\n    OMX_BOOL bTopStatus;\n    OMX_BOOL bBottomStatus;\n    OMX_BOOL bTopLeftStatus;\n    OMX_BOOL bTopRightStatus;\n    OMX_BOOL bBottomLeftStatus;\n    OMX_BOOL bBottomRightStatus;\n} OMX_PARAM_FOCUSSTATUSTYPE;\n\n/** @} */\n\n#ifdef __cplusplus\n}\n#endif /* __cplusplus */\n\n#endif\n/* File EOF */\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/IL/OMX_Image.h",
    "content": "/**\n * Copyright (c) 2008 The Khronos Group Inc. \n * \n * Permission is hereby granted, free of charge, to any person obtaining\n * a copy of this software and associated documentation files (the\n * \"Software\"), to deal in the Software without restriction, including\n * without limitation the rights to use, copy, modify, merge, publish,\n * distribute, sublicense, and/or sell copies of the Software, and to\n * permit persons to whom the Software is furnished to do so, subject\n * to the following conditions: \n * The above copyright notice and this permission notice shall be included\n * in all copies or substantial portions of the Software. \n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\n * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\n * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\n * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \n */\n\n/** \n * @file OMX_Image.h - OpenMax IL version 1.1.2\n * The structures needed by Image components to exchange parameters and \n * configuration data with the components.\n */\n#ifndef OMX_Image_h\n#define OMX_Image_h\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif /* __cplusplus */\n\n\n/**\n * Each OMX header must include all required header files to allow the \n * header to compile without errors.  The includes below are required  \n * for this header file to compile successfully \n */\n\n#include \"OMX_IVCommon.h\"\n\n/** @defgroup imaging OpenMAX IL Imaging Domain\n * @ingroup iv\n * Structures for OpenMAX IL Imaging domain\n * @{\n */\n\n/** \n * Enumeration used to define the possible image compression coding. \n */\ntypedef enum OMX_IMAGE_CODINGTYPE {\n    OMX_IMAGE_CodingUnused,      /**< Value when format is N/A */\n    OMX_IMAGE_CodingAutoDetect,  /**< Auto detection of image format */\n    OMX_IMAGE_CodingJPEG,        /**< JPEG/JFIF image format */\n    OMX_IMAGE_CodingJPEG2K,      /**< JPEG 2000 image format */\n    OMX_IMAGE_CodingEXIF,        /**< EXIF image format */\n    OMX_IMAGE_CodingTIFF,        /**< TIFF image format */\n    OMX_IMAGE_CodingGIF,         /**< Graphics image format */\n    OMX_IMAGE_CodingPNG,         /**< PNG image format */\n    OMX_IMAGE_CodingLZW,         /**< LZW image format */\n    OMX_IMAGE_CodingBMP,         /**< Windows Bitmap format */\n    OMX_IMAGE_CodingKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_IMAGE_CodingVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n\n    OMX_IMAGE_CodingTGA,\n    OMX_IMAGE_CodingPPM,\n\n    OMX_IMAGE_CodingMax = 0x7FFFFFFF\n} OMX_IMAGE_CODINGTYPE;\n\n\n/**\n * Data structure used to define an image path. The number of image paths \n * for input and output will vary by type of the image component.  \n * \n *  Input (aka Source) : Zero Inputs, one Output,\n *  Splitter           : One Input, 2 or more Outputs,\n *  Processing Element : One Input, one output,\n *  Mixer              : 2 or more inputs, one output,\n *  Output (aka Sink)  : One Input, zero outputs.\n * \n * The PortDefinition structure is used to define all of the parameters \n * necessary for the compliant component to setup an input or an output  \n * image path.  If additional vendor specific data is required, it should  \n * be transmitted to the component using the CustomCommand function.   \n * Compliant components will prepopulate this structure with optimal  \n * values during the OMX_GetParameter() command.\n *\n * STRUCT MEMBERS:\n *  cMIMEType             : MIME type of data for the port\n *  pNativeRender         : Platform specific reference for a display if a \n *                          sync, otherwise this field is 0\n *  nFrameWidth           : Width of frame to be used on port if \n *                          uncompressed format is used.  Use 0 for \n *                          unknown, don't care or variable\n *  nFrameHeight          : Height of frame to be used on port if \n *                          uncompressed format is used. Use 0 for \n *                          unknown, don't care or variable\n *  nStride               : Number of bytes per span of an image (i.e. \n *                          indicates the number of bytes to get from\n *                          span N to span N+1, where negative stride \n *                          indicates the image is bottom up\n *  nSliceHeight          : Height used when encoding in slices\n *  bFlagErrorConcealment : Turns on error concealment if it is supported by \n *                          the OMX component\n *  eCompressionFormat    : Compression format used in this instance of  \n *                          the component. When OMX_IMAGE_CodingUnused is \n *                          specified, eColorFormat is valid\n *  eColorFormat          : Decompressed format used by this component\n *  pNativeWindow         : Platform specific reference for a window object if a \n *                          display sink , otherwise this field is 0x0. \n */\ntypedef struct OMX_IMAGE_PORTDEFINITIONTYPE {\n    OMX_STRING cMIMEType;\n    OMX_NATIVE_DEVICETYPE pNativeRender;\n    OMX_U32 nFrameWidth; \n    OMX_U32 nFrameHeight;\n    OMX_S32 nStride;     \n    OMX_U32 nSliceHeight;\n    OMX_BOOL bFlagErrorConcealment;\n    OMX_IMAGE_CODINGTYPE eCompressionFormat;\n    OMX_COLOR_FORMATTYPE eColorFormat;\n    OMX_NATIVE_WINDOWTYPE pNativeWindow;\n} OMX_IMAGE_PORTDEFINITIONTYPE;\n\n\n/**  \n * Port format parameter.  This structure is used to enumerate the various \n * data input/output format supported by the port.\n * \n * STRUCT MEMBERS:\n *  nSize              : Size of the structure in bytes\n *  nVersion           : OMX specification version information\n *  nPortIndex         : Indicates which port to set\n *  nIndex             : Indicates the enumeration index for the format from \n *                       0x0 to N-1\n *  eCompressionFormat : Compression format used in this instance of the \n *                       component. When OMX_IMAGE_CodingUnused is specified, \n *                       eColorFormat is valid\n *  eColorFormat       : Decompressed format used by this component\n */\ntypedef struct OMX_IMAGE_PARAM_PORTFORMATTYPE {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n    OMX_U32 nIndex;\n    OMX_IMAGE_CODINGTYPE eCompressionFormat;\n    OMX_COLOR_FORMATTYPE eColorFormat;\n} OMX_IMAGE_PARAM_PORTFORMATTYPE;\n\n\n/** \n * Flash control type \n *\n * ENUMS\n *  Torch : Flash forced constantly on\n */\ntypedef enum OMX_IMAGE_FLASHCONTROLTYPE {\n    OMX_IMAGE_FlashControlOn = 0,\n    OMX_IMAGE_FlashControlOff,\n    OMX_IMAGE_FlashControlAuto,\n    OMX_IMAGE_FlashControlRedEyeReduction,\n    OMX_IMAGE_FlashControlFillin,\n    OMX_IMAGE_FlashControlTorch,\n    OMX_IMAGE_FlashControlKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_IMAGE_FlashControlVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_IMAGE_FlashControlMax = 0x7FFFFFFF\n} OMX_IMAGE_FLASHCONTROLTYPE;\n\n\n/** \n * Flash control configuration \n *\n * STRUCT MEMBERS:\n *  nSize         : Size of the structure in bytes\n *  nVersion      : OMX specification version information\n *  nPortIndex    : Port that this structure applies to\n *  eFlashControl : Flash control type\n */\ntypedef struct OMX_IMAGE_PARAM_FLASHCONTROLTYPE {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n    OMX_IMAGE_FLASHCONTROLTYPE eFlashControl;\n} OMX_IMAGE_PARAM_FLASHCONTROLTYPE;\n\n\n/** \n * Focus control type \n */\ntypedef enum OMX_IMAGE_FOCUSCONTROLTYPE {\n    OMX_IMAGE_FocusControlOn = 0,\n    OMX_IMAGE_FocusControlOff,\n    OMX_IMAGE_FocusControlAuto,\n    OMX_IMAGE_FocusControlAutoLock,\n    OMX_IMAGE_FocusControlKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_IMAGE_FocusControlVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_IMAGE_FocusControlHyperfocal,         /* Focus at the hyperfocal point of the lens. */\n    OMX_IMAGE_FocusControlAutoMacro,          /* CF over a macro range (eg 0-50cm) */\n    OMX_IMAGE_FocusControlAutoInfinity,       /* CF over distant range (eg 50cm to infinity) */\n    OMX_IMAGE_FocusControlAutoLockMacro,      /* AF over a macro range (eg 0-50cm) */\n    OMX_IMAGE_FocusControlAutoLockInfinity,   /* AF over distant range (eg 50cm to infinity) */\n    OMX_IMAGE_FocusControlNearFixed,          /* Focus at a fixed near focus point - (50cm-1m) */\n    OMX_IMAGE_FocusControlAutoNear,           /* CF over a near range (eg 0-200cm) */\n    OMX_IMAGE_FocusControlAutoLockNear,       /* AF over a near range (eg 0-200cm) */\n    OMX_IMAGE_FocusControlInfinityFixed,      /* Focus at infinity */\n    OMX_IMAGE_FocusControlMacroFixed,         /* Focus at a macro distance */\n    OMX_IMAGE_FocusControlAutoFast,           /* CF over a full range with fast response */\n    OMX_IMAGE_FocusControlAutoMacroFast,      /* CF over a macro range (eg 0-50cm) with fast response */\n    OMX_IMAGE_FocusControlAutoNearFast,       /* CF over a near range (eg 0-200cm) */\n    OMX_IMAGE_FocusControlAutoInfinityFast,   /* CF over distant range (eg 50cm to infinity) with fast response */\n    OMX_IMAGE_FocusControlCurrentFixed,       /* Stop the lens at the current position */\n    OMX_IMAGE_FocusControlMax = 0x7FFFFFFF\n} OMX_IMAGE_FOCUSCONTROLTYPE;\n\n \n/** \n * Focus control configuration \n *\n * STRUCT MEMBERS:\n *  nSize           : Size of the structure in bytes\n *  nVersion        : OMX specification version information\n *  nPortIndex      : Port that this structure applies to\n *  eFocusControl   : Focus control\n *  nFocusSteps     : Focus can take on values from 0 mm to infinity. \n *                    Interest is only in number of steps over this range.\n *  nFocusStepIndex : Current focus step index\n */\ntypedef struct OMX_IMAGE_CONFIG_FOCUSCONTROLTYPE {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n    OMX_IMAGE_FOCUSCONTROLTYPE eFocusControl;\n    OMX_U32 nFocusSteps;\n    OMX_U32 nFocusStepIndex;\n} OMX_IMAGE_CONFIG_FOCUSCONTROLTYPE;\n\n\n/** \n * Q Factor for JPEG compression, which controls the tradeoff between image\n * quality and size.  Q Factor provides a more simple means of controlling\n * JPEG compression quality, without directly programming Quantization\n * tables for chroma and luma \n *\n * STRUCT MEMBERS:\n *  nSize      : Size of the structure in bytes         \n *  nVersion   : OMX specification version information \n *  nPortIndex : Port that this structure applies to \n *  nQFactor   : JPEG Q factor value in the range of 1-100. A factor of 1 \n *               produces the smallest, worst quality images, and a factor \n *               of 100 produces the largest, best quality images.  A \n *               typical default is 75 for small good quality images               \n */\ntypedef struct OMX_IMAGE_PARAM_QFACTORTYPE {\n    OMX_U32 nSize;            \n    OMX_VERSIONTYPE nVersion; \n    OMX_U32 nPortIndex;       \n    OMX_U32 nQFactor;                                        \n} OMX_IMAGE_PARAM_QFACTORTYPE;\n\n/** \n * Quantization table type \n */\n\ntypedef enum OMX_IMAGE_QUANTIZATIONTABLETYPE {\n    OMX_IMAGE_QuantizationTableLuma = 0,\n    OMX_IMAGE_QuantizationTableChroma,\n    OMX_IMAGE_QuantizationTableChromaCb,\n    OMX_IMAGE_QuantizationTableChromaCr,\n    OMX_IMAGE_QuantizationTableKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_IMAGE_QuantizationTableVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_IMAGE_QuantizationTableMax = 0x7FFFFFFF\n} OMX_IMAGE_QUANTIZATIONTABLETYPE;\n\n/** \n * JPEG quantization tables are used to determine DCT compression for\n * YUV data, as an alternative to specifying Q factor, providing exact \n * control of compression \n *\n * STRUCT MEMBERS:\n *  nSize                   : Size of the structure in bytes\n *  nVersion                : OMX specification version information \n *  nPortIndex              : Port that this structure applies to\n *  eQuantizationTable      : Quantization table type\n *  nQuantizationMatrix[64] : JPEG quantization table of coefficients stored \n *                            in increasing columns then by rows of data (i.e. \n *                            row 1, ... row 8). Quantization values are in \n *                            the range 0-255 and stored in linear order\n *                            (i.e. the component will zig-zag the \n *                            quantization table data if required internally) \n */\ntypedef struct OMX_IMAGE_PARAM_QUANTIZATIONTABLETYPE {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n    OMX_IMAGE_QUANTIZATIONTABLETYPE eQuantizationTable;\n    OMX_U8 nQuantizationMatrix[64];\n} OMX_IMAGE_PARAM_QUANTIZATIONTABLETYPE;\n\n\n/** \n * Huffman table type, the same Huffman table is applied for chroma and \n * luma component \n */\ntypedef enum OMX_IMAGE_HUFFMANTABLETYPE {\n    OMX_IMAGE_HuffmanTableAC = 0,\n    OMX_IMAGE_HuffmanTableDC,\n    OMX_IMAGE_HuffmanTableACLuma,\n    OMX_IMAGE_HuffmanTableACChroma,\n    OMX_IMAGE_HuffmanTableDCLuma,\n    OMX_IMAGE_HuffmanTableDCChroma,\n    OMX_IMAGE_HuffmanTableKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_IMAGE_HuffmanTableVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_IMAGE_HuffmanTableMax = 0x7FFFFFFF\n} OMX_IMAGE_HUFFMANTABLETYPE;\n\n/** \n * JPEG Huffman table \n *\n * STRUCT MEMBERS:\n *  nSize                            : Size of the structure in bytes\n *  nVersion                         : OMX specification version information\n *  nPortIndex                       : Port that this structure applies to\n *  eHuffmanTable                    : Huffman table type\n *  nNumberOfHuffmanCodeOfLength[16] : 0-16, number of Huffman codes of each \n *                                     possible length\n *  nHuffmanTable[256]               : 0-255, the size used for AC and DC \n *                                     HuffmanTable are 16 and 162 \n */\ntypedef struct OMX_IMAGE_PARAM_HUFFMANTTABLETYPE {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n    OMX_IMAGE_HUFFMANTABLETYPE eHuffmanTable;\n    OMX_U8 nNumberOfHuffmanCodeOfLength[16];\n    OMX_U8 nHuffmanTable[256];\n}OMX_IMAGE_PARAM_HUFFMANTTABLETYPE;\n\n/** @} */\n#ifdef __cplusplus\n}\n#endif /* __cplusplus */\n\n#endif\n/* File EOF */\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/IL/OMX_Index.h",
    "content": "/*\n * Copyright (c) 2008 The Khronos Group Inc.\n *\n * Permission is hereby granted, free of charge, to any person obtaining\n * a copy of this software and associated documentation files (the\n * \"Software\"), to deal in the Software without restriction, including\n * without limitation the rights to use, copy, modify, merge, publish,\n * distribute, sublicense, and/or sell copies of the Software, and to\n * permit persons to whom the Software is furnished to do so, subject\n * to the following conditions:\n * The above copyright notice and this permission notice shall be included\n * in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\n * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\n * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\n * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n *\n */\n\n/** @file OMX_Index.h - OpenMax IL version 1.1.2\n *  The OMX_Index header file contains the definitions for both applications\n *  and components .\n */\n\n\n#ifndef OMX_Index_h\n#define OMX_Index_h\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif /* __cplusplus */\n\n\n/* Each OMX header must include all required header files to allow the\n *  header to compile without errors.  The includes below are required\n *  for this header file to compile successfully\n */\n#include \"OMX_Types.h\"\n\n\n/** The OMX_INDEXTYPE enumeration is used to select a structure when either\n *  getting or setting parameters and/or configuration data.  Each entry in\n *  this enumeration maps to an OMX specified structure.  When the\n *  OMX_GetParameter, OMX_SetParameter, OMX_GetConfig or OMX_SetConfig methods\n *  are used, the second parameter will always be an entry from this enumeration\n *  and the third entry will be the structure shown in the comments for the entry.\n *  For example, if the application is initializing a cropping function, the\n *  OMX_SetConfig command would have OMX_IndexConfigCommonInputCrop as the second parameter\n *  and would send a pointer to an initialized OMX_RECTTYPE structure as the\n *  third parameter.\n *\n *  The enumeration entries named with the OMX_Config prefix are sent using\n *  the OMX_SetConfig command and the enumeration entries named with the\n *  OMX_PARAM_ prefix are sent using the OMX_SetParameter command.\n */\ntypedef enum OMX_INDEXTYPE {\n\n    OMX_IndexComponentStartUnused = 0x01000000,\n    OMX_IndexParamPriorityMgmt,             /**< reference: OMX_PRIORITYMGMTTYPE */\n    OMX_IndexParamAudioInit,                /**< reference: OMX_PORT_PARAM_TYPE */\n    OMX_IndexParamImageInit,                /**< reference: OMX_PORT_PARAM_TYPE */\n    OMX_IndexParamVideoInit,                /**< reference: OMX_PORT_PARAM_TYPE */\n    OMX_IndexParamOtherInit,                /**< reference: OMX_PORT_PARAM_TYPE */\n    OMX_IndexParamNumAvailableStreams,      /**< reference: OMX_PARAM_U32TYPE */\n    OMX_IndexParamActiveStream,             /**< reference: OMX_PARAM_U32TYPE */\n    OMX_IndexParamSuspensionPolicy,         /**< reference: OMX_PARAM_SUSPENSIONPOLICYTYPE */\n    OMX_IndexParamComponentSuspended,       /**< reference: OMX_PARAM_SUSPENSIONTYPE */\n    OMX_IndexConfigCapturing,               /**< reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexConfigCaptureMode,             /**< reference: OMX_CONFIG_CAPTUREMODETYPE */\n    OMX_IndexAutoPauseAfterCapture,         /**< reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexParamContentURI,               /**< reference: OMX_PARAM_CONTENTURITYPE */\n    OMX_IndexParamCustomContentPipe,        /**< reference: OMX_PARAM_CONTENTPIPETYPE */\n    OMX_IndexParamDisableResourceConcealment, /**< reference: OMX_RESOURCECONCEALMENTTYPE */\n    OMX_IndexConfigMetadataItemCount,       /**< reference: OMX_CONFIG_METADATAITEMCOUNTTYPE */\n    OMX_IndexConfigContainerNodeCount,      /**< reference: OMX_CONFIG_CONTAINERNODECOUNTTYPE */\n    OMX_IndexConfigMetadataItem,            /**< reference: OMX_CONFIG_METADATAITEMTYPE */\n    OMX_IndexConfigCounterNodeID,           /**< reference: OMX_CONFIG_CONTAINERNODEIDTYPE */\n    OMX_IndexParamMetadataFilterType,       /**< reference: OMX_PARAM_METADATAFILTERTYPE */\n    OMX_IndexParamMetadataKeyFilter,        /**< reference: OMX_PARAM_METADATAFILTERTYPE */\n    OMX_IndexConfigPriorityMgmt,            /**< reference: OMX_PRIORITYMGMTTYPE */\n    OMX_IndexParamStandardComponentRole,    /**< reference: OMX_PARAM_COMPONENTROLETYPE */\n\n    OMX_IndexPortStartUnused = 0x02000000,\n    OMX_IndexParamPortDefinition,           /**< reference: OMX_PARAM_PORTDEFINITIONTYPE */\n    OMX_IndexParamCompBufferSupplier,       /**< reference: OMX_PARAM_BUFFERSUPPLIERTYPE */\n    OMX_IndexReservedStartUnused = 0x03000000,\n\n    /* Audio parameters and configurations */\n    OMX_IndexAudioStartUnused = 0x04000000,\n    OMX_IndexParamAudioPortFormat,          /**< reference: OMX_AUDIO_PARAM_PORTFORMATTYPE */\n    OMX_IndexParamAudioPcm,                 /**< reference: OMX_AUDIO_PARAM_PCMMODETYPE */\n    OMX_IndexParamAudioAac,                 /**< reference: OMX_AUDIO_PARAM_AACPROFILETYPE */\n    OMX_IndexParamAudioRa,                  /**< reference: OMX_AUDIO_PARAM_RATYPE */\n    OMX_IndexParamAudioMp3,                 /**< reference: OMX_AUDIO_PARAM_MP3TYPE */\n    OMX_IndexParamAudioAdpcm,               /**< reference: OMX_AUDIO_PARAM_ADPCMTYPE */\n    OMX_IndexParamAudioG723,                /**< reference: OMX_AUDIO_PARAM_G723TYPE */\n    OMX_IndexParamAudioG729,                /**< reference: OMX_AUDIO_PARAM_G729TYPE */\n    OMX_IndexParamAudioAmr,                 /**< reference: OMX_AUDIO_PARAM_AMRTYPE */\n    OMX_IndexParamAudioWma,                 /**< reference: OMX_AUDIO_PARAM_WMATYPE */\n    OMX_IndexParamAudioSbc,                 /**< reference: OMX_AUDIO_PARAM_SBCTYPE */\n    OMX_IndexParamAudioMidi,                /**< reference: OMX_AUDIO_PARAM_MIDITYPE */\n    OMX_IndexParamAudioGsm_FR,              /**< reference: OMX_AUDIO_PARAM_GSMFRTYPE */\n    OMX_IndexParamAudioMidiLoadUserSound,   /**< reference: OMX_AUDIO_PARAM_MIDILOADUSERSOUNDTYPE */\n    OMX_IndexParamAudioG726,                /**< reference: OMX_AUDIO_PARAM_G726TYPE */\n    OMX_IndexParamAudioGsm_EFR,             /**< reference: OMX_AUDIO_PARAM_GSMEFRTYPE */\n    OMX_IndexParamAudioGsm_HR,              /**< reference: OMX_AUDIO_PARAM_GSMHRTYPE */\n    OMX_IndexParamAudioPdc_FR,              /**< reference: OMX_AUDIO_PARAM_PDCFRTYPE */\n    OMX_IndexParamAudioPdc_EFR,             /**< reference: OMX_AUDIO_PARAM_PDCEFRTYPE */\n    OMX_IndexParamAudioPdc_HR,              /**< reference: OMX_AUDIO_PARAM_PDCHRTYPE */\n    OMX_IndexParamAudioTdma_FR,             /**< reference: OMX_AUDIO_PARAM_TDMAFRTYPE */\n    OMX_IndexParamAudioTdma_EFR,            /**< reference: OMX_AUDIO_PARAM_TDMAEFRTYPE */\n    OMX_IndexParamAudioQcelp8,              /**< reference: OMX_AUDIO_PARAM_QCELP8TYPE */\n    OMX_IndexParamAudioQcelp13,             /**< reference: OMX_AUDIO_PARAM_QCELP13TYPE */\n    OMX_IndexParamAudioEvrc,                /**< reference: OMX_AUDIO_PARAM_EVRCTYPE */\n    OMX_IndexParamAudioSmv,                 /**< reference: OMX_AUDIO_PARAM_SMVTYPE */\n    OMX_IndexParamAudioVorbis,              /**< reference: OMX_AUDIO_PARAM_VORBISTYPE */\n\n    OMX_IndexConfigAudioMidiImmediateEvent, /**< reference: OMX_AUDIO_CONFIG_MIDIIMMEDIATEEVENTTYPE */\n    OMX_IndexConfigAudioMidiControl,        /**< reference: OMX_AUDIO_CONFIG_MIDICONTROLTYPE */\n    OMX_IndexConfigAudioMidiSoundBankProgram, /**< reference: OMX_AUDIO_CONFIG_MIDISOUNDBANKPROGRAMTYPE */\n    OMX_IndexConfigAudioMidiStatus,         /**< reference: OMX_AUDIO_CONFIG_MIDISTATUSTYPE */\n    OMX_IndexConfigAudioMidiMetaEvent,      /**< reference: OMX_AUDIO_CONFIG_MIDIMETAEVENTTYPE */\n    OMX_IndexConfigAudioMidiMetaEventData,  /**< reference: OMX_AUDIO_CONFIG_MIDIMETAEVENTDATATYPE */\n    OMX_IndexConfigAudioVolume,             /**< reference: OMX_AUDIO_CONFIG_VOLUMETYPE */\n    OMX_IndexConfigAudioBalance,            /**< reference: OMX_AUDIO_CONFIG_BALANCETYPE */\n    OMX_IndexConfigAudioChannelMute,        /**< reference: OMX_AUDIO_CONFIG_CHANNELMUTETYPE */\n    OMX_IndexConfigAudioMute,               /**< reference: OMX_AUDIO_CONFIG_MUTETYPE */\n    OMX_IndexConfigAudioLoudness,           /**< reference: OMX_AUDIO_CONFIG_LOUDNESSTYPE */\n    OMX_IndexConfigAudioEchoCancelation,    /**< reference: OMX_AUDIO_CONFIG_ECHOCANCELATIONTYPE */\n    OMX_IndexConfigAudioNoiseReduction,     /**< reference: OMX_AUDIO_CONFIG_NOISEREDUCTIONTYPE */\n    OMX_IndexConfigAudioBass,               /**< reference: OMX_AUDIO_CONFIG_BASSTYPE */\n    OMX_IndexConfigAudioTreble,             /**< reference: OMX_AUDIO_CONFIG_TREBLETYPE */\n    OMX_IndexConfigAudioStereoWidening,     /**< reference: OMX_AUDIO_CONFIG_STEREOWIDENINGTYPE */\n    OMX_IndexConfigAudioChorus,             /**< reference: OMX_AUDIO_CONFIG_CHORUSTYPE */\n    OMX_IndexConfigAudioEqualizer,          /**< reference: OMX_AUDIO_CONFIG_EQUALIZERTYPE */\n    OMX_IndexConfigAudioReverberation,      /**< reference: OMX_AUDIO_CONFIG_REVERBERATIONTYPE */\n    OMX_IndexConfigAudioChannelVolume,      /**< reference: OMX_AUDIO_CONFIG_CHANNELVOLUMETYPE */\n\n    /* Image specific parameters and configurations */\n    OMX_IndexImageStartUnused = 0x05000000,\n    OMX_IndexParamImagePortFormat,          /**< reference: OMX_IMAGE_PARAM_PORTFORMATTYPE */\n    OMX_IndexParamFlashControl,             /**< reference: OMX_IMAGE_PARAM_FLASHCONTROLTYPE */\n    OMX_IndexConfigFocusControl,            /**< reference: OMX_IMAGE_CONFIG_FOCUSCONTROLTYPE */\n    OMX_IndexParamQFactor,                  /**< reference: OMX_IMAGE_PARAM_QFACTORTYPE */\n    OMX_IndexParamQuantizationTable,        /**< reference: OMX_IMAGE_PARAM_QUANTIZATIONTABLETYPE */\n    OMX_IndexParamHuffmanTable,             /**< reference: OMX_IMAGE_PARAM_HUFFMANTTABLETYPE */\n    OMX_IndexConfigFlashControl,            /**< reference: OMX_IMAGE_PARAM_FLASHCONTROLTYPE */\n\n    /* Video specific parameters and configurations */\n    OMX_IndexVideoStartUnused = 0x06000000,\n    OMX_IndexParamVideoPortFormat,          /**< reference: OMX_VIDEO_PARAM_PORTFORMATTYPE */\n    OMX_IndexParamVideoQuantization,        /**< reference: OMX_VIDEO_PARAM_QUANTIZATIONTYPE */\n    OMX_IndexParamVideoFastUpdate,          /**< reference: OMX_VIDEO_PARAM_VIDEOFASTUPDATETYPE */\n    OMX_IndexParamVideoBitrate,             /**< reference: OMX_VIDEO_PARAM_BITRATETYPE */\n    OMX_IndexParamVideoMotionVector,        /**< reference: OMX_VIDEO_PARAM_MOTIONVECTORTYPE */\n    OMX_IndexParamVideoIntraRefresh,        /**< reference: OMX_VIDEO_PARAM_INTRAREFRESHTYPE */\n    OMX_IndexParamVideoErrorCorrection,     /**< reference: OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE */\n    OMX_IndexParamVideoVBSMC,               /**< reference: OMX_VIDEO_PARAM_VBSMCTYPE */\n    OMX_IndexParamVideoMpeg2,               /**< reference: OMX_VIDEO_PARAM_MPEG2TYPE */\n    OMX_IndexParamVideoMpeg4,               /**< reference: OMX_VIDEO_PARAM_MPEG4TYPE */\n    OMX_IndexParamVideoWmv,                 /**< reference: OMX_VIDEO_PARAM_WMVTYPE */\n    OMX_IndexParamVideoRv,                  /**< reference: OMX_VIDEO_PARAM_RVTYPE */\n    OMX_IndexParamVideoAvc,                 /**< reference: OMX_VIDEO_PARAM_AVCTYPE */\n    OMX_IndexParamVideoH263,                /**< reference: OMX_VIDEO_PARAM_H263TYPE */\n    OMX_IndexParamVideoProfileLevelQuerySupported, /**< reference: OMX_VIDEO_PARAM_PROFILELEVELTYPE */\n    OMX_IndexParamVideoProfileLevelCurrent, /**< reference: OMX_VIDEO_PARAM_PROFILELEVELTYPE */\n    OMX_IndexConfigVideoBitrate,            /**< reference: OMX_VIDEO_CONFIG_BITRATETYPE */\n    OMX_IndexConfigVideoFramerate,          /**< reference: OMX_CONFIG_FRAMERATETYPE */\n    OMX_IndexConfigVideoIntraVOPRefresh,    /**< reference: OMX_CONFIG_INTRAREFRESHVOPTYPE */\n    OMX_IndexConfigVideoIntraMBRefresh,     /**< reference: OMX_CONFIG_MACROBLOCKERRORMAPTYPE */\n    OMX_IndexConfigVideoMBErrorReporting,   /**< reference: OMX_CONFIG_MBERRORREPORTINGTYPE */\n    OMX_IndexParamVideoMacroblocksPerFrame, /**< reference: OMX_PARAM_MACROBLOCKSTYPE */\n    OMX_IndexConfigVideoMacroBlockErrorMap, /**< reference: OMX_CONFIG_MACROBLOCKERRORMAPTYPE */\n    OMX_IndexParamVideoSliceFMO,            /**< reference: OMX_VIDEO_PARAM_AVCSLICEFMO */\n    OMX_IndexConfigVideoAVCIntraPeriod,     /**< reference: OMX_VIDEO_CONFIG_AVCINTRAPERIOD */\n    OMX_IndexConfigVideoNalSize,            /**< reference: OMX_VIDEO_CONFIG_NALSIZE */\n\n    /* Image & Video common Configurations */\n    OMX_IndexCommonStartUnused = 0x07000000,\n    OMX_IndexParamCommonDeblocking,         /**< reference: OMX_PARAM_DEBLOCKINGTYPE */\n    OMX_IndexParamCommonSensorMode,         /**< reference: OMX_PARAM_SENSORMODETYPE */\n    OMX_IndexParamCommonInterleave,         /**< reference: OMX_PARAM_INTERLEAVETYPE */\n    OMX_IndexConfigCommonColorFormatConversion, /**< reference: OMX_CONFIG_COLORCONVERSIONTYPE */\n    OMX_IndexConfigCommonScale,             /**< reference: OMX_CONFIG_SCALEFACTORTYPE */\n    OMX_IndexConfigCommonImageFilter,       /**< reference: OMX_CONFIG_IMAGEFILTERTYPE */\n    OMX_IndexConfigCommonColorEnhancement,  /**< reference: OMX_CONFIG_COLORENHANCEMENTTYPE */\n    OMX_IndexConfigCommonColorKey,          /**< reference: OMX_CONFIG_COLORKEYTYPE */\n    OMX_IndexConfigCommonColorBlend,        /**< reference: OMX_CONFIG_COLORBLENDTYPE */\n    OMX_IndexConfigCommonFrameStabilisation,/**< reference: OMX_CONFIG_FRAMESTABTYPE */\n    OMX_IndexConfigCommonRotate,            /**< reference: OMX_CONFIG_ROTATIONTYPE */\n    OMX_IndexConfigCommonMirror,            /**< reference: OMX_CONFIG_MIRRORTYPE */\n    OMX_IndexConfigCommonOutputPosition,    /**< reference: OMX_CONFIG_POINTTYPE */\n    OMX_IndexConfigCommonInputCrop,         /**< reference: OMX_CONFIG_RECTTYPE */\n    OMX_IndexConfigCommonOutputCrop,        /**< reference: OMX_CONFIG_RECTTYPE */\n    OMX_IndexConfigCommonDigitalZoom,       /**< reference: OMX_CONFIG_SCALEFACTORTYPE */\n    OMX_IndexConfigCommonOpticalZoom,       /**< reference: OMX_CONFIG_SCALEFACTORTYPE*/\n    OMX_IndexConfigCommonWhiteBalance,      /**< reference: OMX_CONFIG_WHITEBALCONTROLTYPE */\n    OMX_IndexConfigCommonExposure,          /**< reference: OMX_CONFIG_EXPOSURECONTROLTYPE */\n    OMX_IndexConfigCommonContrast,          /**< reference: OMX_CONFIG_CONTRASTTYPE */\n    OMX_IndexConfigCommonBrightness,        /**< reference: OMX_CONFIG_BRIGHTNESSTYPE */\n    OMX_IndexConfigCommonBacklight,         /**< reference: OMX_CONFIG_BACKLIGHTTYPE */\n    OMX_IndexConfigCommonGamma,             /**< reference: OMX_CONFIG_GAMMATYPE */\n    OMX_IndexConfigCommonSaturation,        /**< reference: OMX_CONFIG_SATURATIONTYPE */\n    OMX_IndexConfigCommonLightness,         /**< reference: OMX_CONFIG_LIGHTNESSTYPE */\n    OMX_IndexConfigCommonExclusionRect,     /**< reference: OMX_CONFIG_RECTTYPE */\n    OMX_IndexConfigCommonDithering,         /**< reference: OMX_CONFIG_DITHERTYPE */\n    OMX_IndexConfigCommonPlaneBlend,        /**< reference: OMX_CONFIG_PLANEBLENDTYPE */\n    OMX_IndexConfigCommonExposureValue,     /**< reference: OMX_CONFIG_EXPOSUREVALUETYPE */\n    OMX_IndexConfigCommonOutputSize,        /**< reference: OMX_FRAMESIZETYPE */\n    OMX_IndexParamCommonExtraQuantData,     /**< reference: OMX_OTHER_EXTRADATATYPE */\n    OMX_IndexConfigCommonFocusRegion,       /**< reference: OMX_CONFIG_FOCUSREGIONTYPE */\n    OMX_IndexConfigCommonFocusStatus,       /**< reference: OMX_PARAM_FOCUSSTATUSTYPE */\n    OMX_IndexConfigCommonTransitionEffect,  /**< reference: OMX_CONFIG_TRANSITIONEFFECTTYPE */\n\n    /* Reserved Configuration range */\n    OMX_IndexOtherStartUnused = 0x08000000,\n    OMX_IndexParamOtherPortFormat,          /**< reference: OMX_OTHER_PARAM_PORTFORMATTYPE */\n    OMX_IndexConfigOtherPower,              /**< reference: OMX_OTHER_CONFIG_POWERTYPE */\n    OMX_IndexConfigOtherStats,              /**< reference: OMX_OTHER_CONFIG_STATSTYPE */\n\n\n    /* Reserved Time range */\n    OMX_IndexTimeStartUnused = 0x09000000,\n    OMX_IndexConfigTimeScale,               /**< reference: OMX_TIME_CONFIG_SCALETYPE */\n    OMX_IndexConfigTimeClockState,          /**< reference: OMX_TIME_CONFIG_CLOCKSTATETYPE */\n    OMX_IndexConfigTimeActiveRefClock,      /**< reference: OMX_TIME_CONFIG_ACTIVEREFCLOCKTYPE */\n    OMX_IndexConfigTimeCurrentMediaTime,    /**< reference: OMX_TIME_CONFIG_TIMESTAMPTYPE (read only) */\n    OMX_IndexConfigTimeCurrentWallTime,     /**< reference: OMX_TIME_CONFIG_TIMESTAMPTYPE (read only) */\n    OMX_IndexConfigTimeCurrentAudioReference, /**< reference: OMX_TIME_CONFIG_TIMESTAMPTYPE (write only) */\n    OMX_IndexConfigTimeCurrentVideoReference, /**< reference: OMX_TIME_CONFIG_TIMESTAMPTYPE (write only) */\n    OMX_IndexConfigTimeMediaTimeRequest,    /**< reference: OMX_TIME_CONFIG_MEDIATIMEREQUESTTYPE (write only) */\n    OMX_IndexConfigTimeClientStartTime,     /**<reference:  OMX_TIME_CONFIG_TIMESTAMPTYPE (write only) */\n    OMX_IndexConfigTimePosition,            /**< reference: OMX_TIME_CONFIG_TIMESTAMPTYPE */\n    OMX_IndexConfigTimeSeekMode,            /**< reference: OMX_TIME_CONFIG_SEEKMODETYPE */\n\n\n    OMX_IndexKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */\n    /* Vendor specific area */\n    OMX_IndexVendorStartUnused = 0x7F000000,\n    /* Vendor specific structures should be in the range of 0x7F000000\n       to 0x7FFFFFFE.  This range is not broken out by vendor, so\n       private indexes are not guaranteed unique and therefore should\n       only be sent to the appropriate component. */\n\n    /* used for ilcs-top communication */\n    OMX_IndexParamMarkComparison,           /**< reference: OMX_PARAM_MARKCOMPARISONTYPE */\n    OMX_IndexParamPortSummary,              /**< reference: OMX_PARAM_PORTSUMMARYTYPE */\n    OMX_IndexParamTunnelStatus,             /**< reference : OMX_PARAM_TUNNELSTATUSTYPE */\n    OMX_IndexParamBrcmRecursionUnsafe,      /**< reference: OMX_PARAM_BRCMRECURSIONUNSAFETYPE */\n\n    /* used for top-ril communication */\n    OMX_IndexParamBufferAddress,            /**< reference : OMX_PARAM_BUFFERADDRESSTYPE */\n    OMX_IndexParamTunnelSetup,              /**< reference : OMX_PARAM_TUNNELSETUPTYPE */\n    OMX_IndexParamBrcmPortEGL,              /**< reference : OMX_PARAM_BRCMPORTEGLTYPE */\n    OMX_IndexParamIdleResourceCount,        /**< reference : OMX_PARAM_U32TYPE */\n\n    /* used for ril-ril communication */\n    OMX_IndexParamImagePoolDisplayFunction, /**<reference : OMX_PARAM_IMAGEDISPLAYFUNCTIONTYPE */\n    OMX_IndexParamBrcmDataUnit,             /**<reference: OMX_PARAM_DATAUNITTYPE */\n    OMX_IndexParamCodecConfig,              /**<reference: OMX_PARAM_CODECCONFIGTYPE */\n    OMX_IndexParamCameraPoolToEncoderFunction, /**<reference : OMX_PARAM_CAMERAPOOLTOENCODERFUNCTIONTYPE */\n    OMX_IndexParamCameraStripeFunction,     /**<reference : OMX_PARAM_CAMERASTRIPEFUNCTIONTYPE */\n    OMX_IndexParamCameraCaptureEventFunction, /**<reference : OMX_PARAM_CAMERACAPTUREEVENTFUNCTIONTYPE */\n\n    /* used for client-ril communication */\n    OMX_IndexParamTestInterface,            /**< reference : OMX_PARAM_TESTINTERFACETYPE */\n\n    // 0x7f000010\n    OMX_IndexConfigDisplayRegion,           /**< reference : OMX_CONFIG_DISPLAYREGIONTYPE */\n    OMX_IndexParamSource,                   /**< reference : OMX_PARAM_SOURCETYPE */\n    OMX_IndexParamSourceSeed,               /**< reference : OMX_PARAM_SOURCESEEDTYPE */\n    OMX_IndexParamResize,                   /**< reference : OMX_PARAM_RESIZETYPE */\n    OMX_IndexConfigVisualisation,           /**< reference : OMX_CONFIG_VISUALISATIONTYPE */\n    OMX_IndexConfigSingleStep,              /**<reference : OMX_PARAM_U32TYPE */\n    OMX_IndexConfigPlayMode,                /**<reference: OMX_CONFIG_PLAYMODETYPE */\n    OMX_IndexParamCameraCamplusId,          /**<reference : OMX_PARAM_U32TYPE */\n    OMX_IndexConfigCommonImageFilterParameters,  /**<reference : OMX_CONFIG_IMAGEFILTERPARAMSTYPE */\n    OMX_IndexConfigTransitionControl,       /**<reference : OMX_CONFIG_TRANSITIONCONTROLTYPE */\n    OMX_IndexConfigPresentationOffset,      /**<reference: OMX_TIME_CONFIG_TIMESTAMPTYPE */\n    OMX_IndexParamSourceFunctions,          /**<reference: OMX_PARAM_STILLSFUNCTIONTYPE */\n    OMX_IndexConfigAudioMonoTrackControl,   /**<reference : OMX_CONFIG_AUDIOMONOTRACKCONTROLTYPE */\n    OMX_IndexParamCameraImagePool,          /**<reference : OMX_PARAM_CAMERAIMAGEPOOLTYPE */\n    OMX_IndexConfigCameraISPOutputPoolHeight,/**<reference : OMX_PARAM_U32TYPE */\n    OMX_IndexParamImagePoolSize,            /**<reference: OMX_PARAM_IMAGEPOOLSIZETYPE */\n\n    // 0x7f000020\n    OMX_IndexParamImagePoolExternal,        /**<reference: OMX_PARAM_IMAGEPOOLEXTERNALTYPE */\n    OMX_IndexParamRUTILFifoInfo,            /**<reference: OMX_PARAM_RUTILFIFOINFOTYPE*/\n    OMX_IndexParamILFifoConfig,             /**<reference: OMX_PARAM_ILFIFOCONFIG */\n    OMX_IndexConfigCameraSensorModes,       /**<reference : OMX_CONFIG_CAMERASENSORMODETYPE */\n    OMX_IndexConfigBrcmPortStats,           /**<reference : OMX_CONFIG_BRCMPORTSTATSTYPE */\n    OMX_IndexConfigBrcmPortBufferStats,     /**<reference : OMX_CONFIG_BRCMPORTBUFFERSTATSTYPE */\n    OMX_IndexConfigBrcmCameraStats,         /**<reference : OMX_CONFIG_BRCMCAMERASTATSTYPE */\n    OMX_IndexConfigBrcmIOPerfStats,         /**<reference : OMX_CONFIG_BRCMIOPERFSTATSTYPE */\n    OMX_IndexConfigCommonSharpness,         /**<reference : OMX_CONFIG_SHARPNESSTYPE */\n    OMX_IndexConfigCommonFlickerCancellation,   /**reference : OMX_CONFIG_FLICKERCANCELTYPE */\n    OMX_IndexParamCameraSwapImagePools,     /**<reference : OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexParamCameraSingleBufferCaptureInput,  /**<reference : OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexConfigCommonRedEyeRemoval,   /**<reference : OMX_CONFIG_REDEYEREMOVALTYPE  */\n    OMX_IndexConfigCommonFaceDetectionControl,  /**<reference : OMX_CONFIG_FACEDETECTIONCONTROLTYPE */\n    OMX_IndexConfigCommonFaceDetectionRegion,   /**<reference : OMX_CONFIG_FACEDETECTIONREGIONTYPE */\n    OMX_IndexConfigCommonInterlace,         /**<reference: OMX_CONFIG_INTERLACETYPE */\n\n    // 0x7f000030\n    OMX_IndexParamISPTunerName,             /**<reference: OMX_PARAM_CAMERAISPTUNERTYPE */\n    OMX_IndexParamCameraDeviceNumber,       /**<reference: OMX_PARAM_U32TYPE */\n    OMX_IndexParamCameraDevicesPresent,     /**<reference: OMX_PARAM_U32TYPE */\n    OMX_IndexConfigCameraInputFrame,        /**<reference: OMX_CONFIG_IMAGEPTRTYPE */\n    OMX_IndexConfigStillColourDenoiseEnable,    /**<reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexConfigVideoColourDenoiseEnable,    /**<reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexConfigAFAssistLight,           /**<reference: OMX_CONFIG_AFASSISTTYPE */\n    OMX_IndexConfigSmartShakeReductionEnable, /**<reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexConfigInputCropPercentages,    /**<reference: OMX_CONFIG_INPUTCROPTYPE */\n    OMX_IndexConfigStillsAntiShakeEnable,   /**<reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexConfigWaitForFocusBeforeCapture,/**<reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexConfigAudioRenderingLatency,   /**<reference: OMX_PARAM_U32TYPE */\n    OMX_IndexConfigDrawBoxAroundFaces,      /**<reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexParamCodecRequirements,        /**<reference: OMX_PARAM_CODECREQUIREMENTSTYPE */\n    OMX_IndexConfigBrcmEGLImageMemHandle,   /**<reference: OMX_CONFIG_BRCMEGLIMAGEMEMHANDLETYPE */\n    OMX_IndexConfigPrivacyIndicator,        /**<reference: OMX_CONFIG_PRIVACYINDICATORTYPE */\n\n    // 0x7f000040\n    OMX_IndexParamCameraFlashType,          /**<reference: OMX_PARAM_CAMERAFLASHTYPE */\n    OMX_IndexConfigCameraEnableStatsPass,   /**<reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexConfigCameraFlashConfig,       /**<reference: OMX_CONFIG_CAMERAFLASHCONFIGTYPE */\n    OMX_IndexConfigCaptureRawImageURI,      /**<reference: OMX_PARAM_CONTENTURITYPE */\n    OMX_IndexConfigCameraStripeFuncMinLines, /**<reference: OMX_PARAM_U32TYPE */\n    OMX_IndexConfigCameraAlgorithmVersionDeprecated,   /**<reference: OMX_PARAM_U32TYPE */\n    OMX_IndexConfigCameraIsoReferenceValue,  /**<reference: OMX_PARAM_U32TYPE */\n    OMX_IndexConfigCameraCaptureAbortsAutoFocus, /**<reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexConfigBrcmClockMissCount,      /**<reference: OMX_PARAM_U32TYPE */\n    OMX_IndexConfigFlashChargeLevel,         /**<reference: OMX_PARAM_U32TYPE */\n    OMX_IndexConfigBrcmVideoEncodedSliceSize, /**<reference: OMX_PARAM_U32TYPE */\n    OMX_IndexConfigBrcmAudioTrackGaplessPlayback,  /**< reference: OMX_CONFIG_BRCMAUDIOTRACKGAPLESSPLAYBACKTYPE */\n    OMX_IndexConfigBrcmAudioTrackChangeControl,    /**< reference: OMX_CONFIG_BRCMAUDIOTRACKCHANGECONTROLTYPE */\n    OMX_IndexParamBrcmPixelAspectRatio,     /**< reference: OMX_CONFIG_POINTTYPE */\n    OMX_IndexParamBrcmPixelValueRange,      /**< reference: OMX_PARAM_BRCMPIXELVALUERANGETYPE */\n    OMX_IndexParamCameraDisableAlgorithm,   /**< reference: OMX_PARAM_CAMERADISABLEALGORITHMTYPE */\n\n    // 0x7f000050\n    OMX_IndexConfigBrcmVideoIntraPeriodTime, /**< reference: OMX_PARAM_U32TYPE */\n    OMX_IndexConfigBrcmVideoIntraPeriod,     /**< reference: OMX_PARAM_U32TYPE */\n    OMX_IndexConfigBrcmAudioEffectControl, /**< reference: OMX_CONFIG_BRCMAUDIOEFFECTCONTROLTYPE */\n    OMX_IndexConfigBrcmMinimumProcessingLatency, /**< reference: OMX_CONFIG_BRCMMINIMUMPROCESSINGLATENCY */\n    OMX_IndexParamBrcmVideoAVCSEIEnable,    /**< reference: OMX_PARAM_BRCMVIDEOAVCSEIENABLETYPE */\n    OMX_IndexParamBrcmAllowMemChange,   /**< reference: OMX_PARAM_BRCMALLOWMEMCHANGETYPE */\n    OMX_IndexConfigBrcmVideoEncoderMBRowsPerSlice, /**< reference: OMX_PARAM_U32TYPE */\n    OMX_IndexParamCameraAFAssistDeviceNumber_Deprecated,   /**< reference: OMX_PARAM_U32TYPE */\n    OMX_IndexParamCameraPrivacyIndicatorDeviceNumber_Deprecated,   /**< reference: OMX_PARAM_U32TYPE */\n    OMX_IndexConfigCameraUseCase,               /**< reference: OMX_CONFIG_CAMERAUSECASETYPE */\n    OMX_IndexParamBrcmDisableProprietaryTunnels,   /**< reference: OMX_PARAM_BRCMDISABLEPROPRIETARYTUNNELSTYPE */\n    OMX_IndexParamBrcmOutputBufferSize,         /**<  reference: OMX_PARAM_BRCMOUTPUTBUFFERSIZETYPE */\n    OMX_IndexParamBrcmRetainMemory,             /**< reference: OMX_PARAM_BRCMRETAINMEMORYTYPE */\n    OMX_IndexConfigCanFocus_Deprecated,                    /**< reference: OMX_PARAM_U32TYPE */\n    OMX_IndexParamBrcmImmutableInput,           /**< reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexParamDynamicParameterFile,        /**< reference: OMX_PARAM_CONTENTURITYPE */\n\n    // 0x7f000060\n    OMX_IndexParamUseDynamicParameterFile,     /**< reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexConfigCameraInfo,                 /**< reference: OMX_CONFIG_CAMERAINFOTYPE */\n    OMX_IndexConfigCameraFeatures,             /**< reference: OMX_CONFIG_CAMERAFEATURESTYPE */\n    OMX_IndexConfigRequestCallback,            /**< reference: OMX_CONFIG_REQUESTCALLBACKTYPE */ //Should be added to the spec as part of IL416c\n    OMX_IndexConfigBrcmOutputBufferFullCount,  /**< reference: OMX_PARAM_U32TYPE */\n    OMX_IndexConfigCommonFocusRegionXY,        /**< reference: OMX_CONFIG_FOCUSREGIONXYTYPE */\n    OMX_IndexParamBrcmDisableEXIF,             /**< reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexConfigUserSettingsId,             /**< reference: OMX_CONFIG_U8TYPE */\n    OMX_IndexConfigCameraSettings,             /**< reference: OMX_CONFIG_CAMERASETTINGSTYPE */\n    OMX_IndexConfigDrawBoxLineParams,          /**< reference: OMX_CONFIG_DRAWBOXLINEPARAMS */\n    OMX_IndexParamCameraRmiControl_Deprecated,            /**< reference: OMX_PARAM_CAMERARMITYPE */\n    OMX_IndexConfigBurstCapture,               /**< reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexParamBrcmEnableIJGTableScaling,   /**< reference: OMX_PARAM_IJGSCALINGTYPE */\n    OMX_IndexConfigPowerDown,                  /**< reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexConfigBrcmSyncOutput,             /**< reference: OMX_CONFIG_BRCMSYNCOUTPUTTYPE */\n    OMX_IndexParamBrcmFlushCallback,           /**< reference: OMX_PARAM_BRCMFLUSHCALLBACK */\n\n    // 0x7f000070\n    OMX_IndexConfigBrcmVideoRequestIFrame,     /**< reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexParamBrcmNALSSeparate,            /**< reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexConfigConfirmView,                /**< reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexConfigDrmView,                    /**< reference: OMX_CONFIG_DRMVIEWTYPE */\n    OMX_IndexConfigBrcmVideoIntraRefresh,      /**< reference: OMX_VIDEO_PARAM_INTRAREFRESHTYPE */\n    OMX_IndexParamBrcmMaxFileSize,             /**< reference: OMX_PARAM_BRCMU64TYPE */\n    OMX_IndexParamBrcmCRCEnable,               /**< reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexParamBrcmCRC,                     /**< reference: OMX_PARAM_U32TYPE */\n    OMX_IndexConfigCameraRmiInUse_Deprecated,             /**< reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexConfigBrcmAudioSource,            /**<reference: OMX_CONFIG_BRCMAUDIOSOURCETYPE */\n    OMX_IndexConfigBrcmAudioDestination,       /**< reference: OMX_CONFIG_BRCMAUDIODESTINATIONTYPE */\n    OMX_IndexParamAudioDdp,                    /**< reference: OMX_AUDIO_PARAM_DDPTYPE */\n    OMX_IndexParamBrcmThumbnail,               /**< reference: OMX_PARAM_BRCMTHUMBNAILTYPE */\n    OMX_IndexParamBrcmDisableLegacyBlocks_Deprecated,     /**< reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexParamBrcmCameraInputAspectRatio,  /**< reference: OMX_PARAM_BRCMASPECTRATIOTYPE */\n    OMX_IndexParamDynamicParameterFileFailFatal,/**< reference: OMX_CONFIG_BOOLEANTYPE */\n\n    // 0x7f000080\n    OMX_IndexParamBrcmVideoDecodeErrorConcealment, /**< reference: OMX_PARAM_BRCMVIDEODECODEERRORCONCEALMENTTYPE */\n    OMX_IndexParamBrcmInterpolateMissingTimestamps, /**< reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexParamBrcmSetCodecPerformanceMonitoring, /**< reference: OMX_PARAM_U32TYPE */\n    OMX_IndexConfigFlashInfo,                  /**< reference: OMX_CONFIG_FLASHINFOTYPE */\n    OMX_IndexParamBrcmMaxFrameSkips,           /**< reference: OMX_PARAM_U32TYPE */\n    OMX_IndexConfigDynamicRangeExpansion,      /**< reference: OMX_CONFIG_DYNAMICRANGEEXPANSIONTYPE */\n    OMX_IndexParamBrcmFlushCallbackId,         /**< reference: OMX_PARAM_U32TYPE */\n    OMX_IndexParamBrcmTransposeBufferCount,    /**< reference: OMX_PARAM_U32TYPE */\n    OMX_IndexConfigFaceRecognitionControl,     /**< reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexConfigFaceRecognitionSaveFace,    /**< reference: OMX_PARAM_BRCMU64TYPE */\n    OMX_IndexConfigFaceRecognitionDatabaseUri, /**< reference: OMX_PARAM_CONTENTURITYPE */\n    OMX_IndexConfigClockAdjustment,            /**< reference: OMX_TIME_CONFIG_TIMESTAMPTYPE */\n    OMX_IndexParamBrcmThreadAffinity,          /**< reference: OMX_PARAM_BRCMTHREADAFFINITYTYPE */\n    OMX_IndexParamAsynchronousOutput,          /**< reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexConfigAsynchronousFailureURI,     /**< reference: OMX_PARAM_CONTENTURITYPE */\n    OMX_IndexConfigCommonFaceBeautification,   /**< reference: OMX_CONFIG_BOOLEANTYPE */\n\n    // 0x7f000090\n    OMX_IndexConfigCommonSceneDetectionControl,/**< reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexConfigCommonSceneDetected,        /**< reference: OMX_CONFIG_SCENEDETECTTYPE */\n    OMX_IndexParamDisableVllPool,              /**< reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexParamVideoMvc,                    /**< reference: OMX_VIDEO_PARAM_MVCTYPE */\n    OMX_IndexConfigBrcmDrawStaticBox,          /**< reference: OMX_CONFIG_STATICBOXTYPE */\n    OMX_IndexConfigBrcmClockReferenceSource,   /**< reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexParamPassBufferMarks,             /**< reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexConfigPortCapturing,              /**< reference: OMX_CONFIG_PORTBOOLEANTYPE */\n    OMX_IndexConfigBrcmDecoderPassThrough,     /**< reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexParamBrcmDecoderPassThrough=OMX_IndexConfigBrcmDecoderPassThrough,  /* deprecated */\n    OMX_IndexParamBrcmMaxCorruptMBs,           /**< reference: OMX_PARAM_U32TYPE */\n    OMX_IndexConfigBrcmGlobalAudioMute,        /**< reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexParamCameraCaptureMode,           /**< reference: OMX_PARAM_CAMERACAPTUREMODETYPE */\n    OMX_IndexParamBrcmDrmEncryption,           /**< reference: OMX_PARAM_BRCMDRMENCRYPTIONTYPE */\n    OMX_IndexConfigBrcmCameraRnDPreprocess,    /**< reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexConfigBrcmCameraRnDPostprocess,   /**< reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexConfigBrcmAudioTrackChangeCount,  /**< reference: OMX_PARAM_U32TYPE */\n\n    // 0x7f0000a0\n    OMX_IndexParamCommonUseStcTimestamps,      /**< reference: OMX_PARAM_TIMESTAMPMODETYPE */\n    OMX_IndexConfigBufferStall,                /**< reference: OMX_CONFIG_BUFFERSTALLTYPE */\n    OMX_IndexConfigRefreshCodec,               /**< reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexParamCaptureStatus,               /**< reference: OMX_PARAM_CAPTURESTATETYPE */\n    OMX_IndexConfigTimeInvalidStartTime,       /**< reference: OMX_TIME_CONFIG_TIMESTAMPTYPE */\n    OMX_IndexConfigLatencyTarget,              /**< reference: OMX_CONFIG_LATENCYTARGETTYPE */\n    OMX_IndexConfigMinimiseFragmentation,      /**< reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexConfigBrcmUseProprietaryCallback, /**< reference: OMX_CONFIG_BRCMUSEPROPRIETARYTUNNELTYPE */\n    OMX_IndexParamPortMaxFrameSize,            /**< reference: OMX_FRAMESIZETYPE */\n    OMX_IndexParamComponentName,               /**< reference: OMX_PARAM_COMPONENTROLETYPE */\n    OMX_IndexConfigEncLevelExtension,          /**< reference: OMX_VIDEO_CONFIG_LEVEL_EXTEND */\n    OMX_IndexConfigTemporalDenoiseEnable,      /**< reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexParamBrcmLazyImagePoolDestroy,    /**< reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexParamBrcmEEDEEnable,              /**< reference: OMX_VIDEO_EEDE_ENABLE */\n    OMX_IndexParamBrcmEEDELossRate,            /**< reference: OMX_VIDEO_EEDE_LOSSRATE */\n    OMX_IndexParamAudioDts,                    /**< reference: OMX_AUDIO_PARAM_DTSTYPE */\n\n    // 0x7f0000b0\n    OMX_IndexParamNumOutputChannels,           /**< reference: OMX_PARAM_U32TYPE */\n    OMX_IndexConfigBrcmHighDynamicRange,       /**< reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexConfigBrcmPoolMemAllocSize,       /**< reference: OMX_PARAM_U32TYPE */\n    OMX_IndexConfigBrcmBufferFlagFilter,       /**< reference: OMX_PARAM_U32TYPE */\n    OMX_IndexParamBrcmVideoEncodeMinQuant,     /**< reference: OMX_PARAM_U32TYPE */\n    OMX_IndexParamBrcmVideoEncodeMaxQuant,     /**< reference: OMX_PARAM_U32TYPE */\n    OMX_IndexParamRateControlModel,            /**< reference: OMX_PARAM_U32TYPE */\n    OMX_IndexParamBrcmExtraBuffers,            /**< reference: OMX_PARAM_U32TYPE */\n    OMX_IndexConfigFieldOfView,                /**< reference: OMX_CONFIG_BRCMFOVTYPE */\n    OMX_IndexParamBrcmAlignHoriz,              /**< reference: OMX_PARAM_U32TYPE */\n    OMX_IndexParamBrcmAlignVert,               /**< reference: OMX_PARAM_U32TYPE */\n    OMX_IndexParamColorSpace,                  /**< reference: OMX_PARAM_COLORSPACETYPE */\n    OMX_IndexParamBrcmDroppablePFrames,        /**< reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexParamBrcmVideoInitialQuant,       /**< reference: OMX_PARAM_U32TYPE */\n    OMX_IndexParamBrcmVideoEncodeQpP,          /**< reference: OMX_PARAM_U32TYPE */\n    OMX_IndexParamBrcmVideoRCSliceDQuant,      /**< reference: OMX_PARAM_U32TYPE */\n\n    // 0x7f0000c0\n    OMX_IndexParamBrcmVideoFrameLimitBits,     /**< reference: OMX_PARAM_U32TYPE */\n    OMX_IndexParamBrcmVideoPeakRate,           /**< reference: OMX_PARAM_U32TYPE */\n    OMX_IndexConfigBrcmVideoH264DisableCABAC,  /**< reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexConfigBrcmVideoH264LowLatency,    /**< reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexConfigBrcmVideoH264AUDelimiters,  /**< reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexConfigBrcmVideoH264DeblockIDC,    /**< reference: OMX_PARAM_U32TYPE */\n    OMX_IndexConfigBrcmVideoH264IntraMBMode,   /**< reference: OMX_PARAM_U32TYPE */\n    OMX_IndexConfigContrastEnhance,            /**< reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexParamCameraCustomSensorConfig,    /**< reference: OMX_PARAM_U32TYPE */\n    OMX_IndexParamBrcmHeaderOnOpen,            /**< reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexConfigBrcmUseRegisterFile,        /**< reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexConfigBrcmRegisterFileFailFatal,  /**< reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexParamBrcmConfigFileRegisters,     /**< reference: OMX_PARAM_BRCMCONFIGFILETYPE */\n    OMX_IndexParamBrcmConfigFileChunkRegisters,/**< reference: OMX_PARAM_BRCMCONFIGFILECHUNKTYPE */\n    OMX_IndexParamBrcmAttachLog,               /**< reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexParamCameraZeroShutterLag,        /**< reference: OMX_CONFIG_ZEROSHUTTERLAGTYPE */\n\n    // 0x7f0000d0\n    OMX_IndexParamBrcmFpsRange,                /**< reference: OMX_PARAM_BRCMFRAMERATERANGETYPE */\n    OMX_IndexParamCaptureExposureCompensation, /**< reference: OMX_PARAM_S32TYPE */\n    OMX_IndexParamBrcmVideoPrecodeForQP,       /**< reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexParamBrcmVideoTimestampFifo,      /**< reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexParamSWSharpenDisable,            /**< reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexConfigBrcmFlashRequired,          /**< reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexParamBrcmVideoDrmProtectBuffer,   /**< reference: OMX_PARAM_BRCMVIDEODRMPROTECTBUFFERTYPE */\n    OMX_IndexParamSWSaturationDisable,         /**< reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexParamBrcmVideoDecodeConfigVD3,    /**< reference: OMX_PARAM_BRCMVIDEODECODECONFIGVD3TYPE */\n    OMX_IndexConfigBrcmPowerMonitor,           /**< reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexParamBrcmZeroCopy,                /**< reference: OMX_CONFIG_PORTBOOLEANTYPE */\n    OMX_IndexParamBrcmVideoEGLRenderDiscardMode,   /**< reference: OMX_CONFIG_PORTBOOLEANTYPE */\n    OMX_IndexParamBrcmVideoAVC_VCLHRDEnable,    /**< reference: OMX_CONFIG_PORTBOOLEANTYPE*/\n    OMX_IndexParamBrcmVideoAVC_LowDelayHRDEnable, /**< reference: OMX_CONFIG_PORTBOOLEANTYPE*/\n    OMX_IndexParamBrcmVideoCroppingDisable,    /**< reference: OMX_CONFIG_PORTBOOLEANTYPE*/\n    OMX_IndexParamBrcmVideoAVCInlineHeaderEnable, /**< reference: OMX_CONFIG_PORTBOOLEANTYPE*/\n\n    // 0x7f0000f0\n    OMX_IndexConfigBrcmAudioDownmixCoefficients = 0x7f0000f0, /**< reference: OMX_CONFIG_BRCMAUDIODOWNMIXCOEFFICIENTS */\n    OMX_IndexConfigBrcmAudioDownmixCoefficients8x8,           /**< reference: OMX_CONFIG_BRCMAUDIODOWNMIXCOEFFICIENTS8x8 */\n    OMX_IndexConfigBrcmAudioMaxSample,                        /**< reference: OMX_CONFIG_BRCMAUDIOMAXSAMPLE */\n    OMX_IndexConfigCustomAwbGains,                            /**< reference: OMX_CONFIG_CUSTOMAWBGAINSTYPE */\n    OMX_IndexParamRemoveImagePadding,                         /**< reference: OMX_CONFIG_PORTBOOLEANTYPE*/\n    OMX_IndexParamBrcmVideoAVCInlineVectorsEnable,            /**< reference: OMX_CONFIG_PORTBOOLEANTYPE */\n    OMX_IndexConfigBrcmRenderStats,                           /**< reference: OMX_CONFIG_BRCMRENDERSTATSTYPE */\n    OMX_IndexConfigBrcmCameraAnnotate,                        /**< reference: OMX_CONFIG_BRCMANNOTATETYPE */\n    OMX_IndexParamBrcmStereoscopicMode,                       /**< reference :OMX_CONFIG_BRCMSTEREOSCOPICMODETYPE */\n    OMX_IndexParamBrcmLockStepEnable,                         /**< reference: OMX_CONFIG_PORTBOOLEANTYPE */\n    OMX_IndexParamBrcmTimeScale,                              /**< reference: OMX_PARAM_U32TYPE */\n    OMX_IndexParamCameraInterface,                            /**< reference: OMX_PARAM_CAMERAINTERFACETYPE */\n    OMX_IndexParamCameraClockingMode,                         /**< reference: OMX_PARAM_CAMERACLOCKINGMODETYPE */\n    OMX_IndexParamCameraRxConfig,                             /**< reference: OMX_PARAM_CAMERARXCONFIG_TYPE */\n    OMX_IndexParamCameraRxTiming,                             /**< reference: OMX_PARAM_CAMERARXTIMING_TYPE */\n    OMX_IndexParamDynamicParameterConfig,                     /**< reference: OMX_PARAM_U32TYPE */\n    OMX_IndexParamBrcmVideoAVCSPSTimingEnable,                /** reference: OMX_CONFIG_PORTBOOLEANTYPE */\n    OMX_IndexParamBrcmBayerOrder,                             /** reference: OMX_PARAM_BAYERORDERTYPE */\n    OMX_IndexParamBrcmMaxNumCallbacks,                        /**< reference: OMX_PARAM_U32TYPE */\n    OMX_IndexParamBrcmJpegRestartInterval,                    /**< reference: OMX_PARAM_U32TYPE */\n    OMX_IndexParamBrcmSupportsSlices,                         /**< reference: OMX_CONFIG_PORT_BOOLEANTYPE */\n    OMX_IndexMax = 0x7FFFFFFF\n} OMX_INDEXTYPE;\n\n#ifdef __cplusplus\n}\n#endif /* __cplusplus */\n\n#endif\n/* File EOF */\n\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/IL/OMX_Other.h",
    "content": "/*\n * Copyright (c) 2008 The Khronos Group Inc. \n * \n * Permission is hereby granted, free of charge, to any person obtaining\n * a copy of this software and associated documentation files (the\n * \"Software\"), to deal in the Software without restriction, including\n * without limitation the rights to use, copy, modify, merge, publish,\n * distribute, sublicense, and/or sell copies of the Software, and to\n * permit persons to whom the Software is furnished to do so, subject\n * to the following conditions: \n * The above copyright notice and this permission notice shall be included\n * in all copies or substantial portions of the Software. \n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\n * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\n * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\n * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \n *\n */\n\n/** @file OMX_Other.h - OpenMax IL version 1.1.2\n *  The structures needed by Other components to exchange\n *  parameters and configuration data with the components.\n */\n\n#ifndef OMX_Other_h\n#define OMX_Other_h\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif /* __cplusplus */\n\n\n/* Each OMX header must include all required header files to allow the\n *  header to compile without errors.  The includes below are required\n *  for this header file to compile successfully \n */\n\n#include \"OMX_Core.h\"\n\n\n/** \n * Enumeration of possible data types which match to multiple domains or no\n * domain at all.  For types which are vendor specific, a value above\n * OMX_OTHER_VENDORTSTART should be used.\n */\ntypedef enum OMX_OTHER_FORMATTYPE {\n    OMX_OTHER_FormatTime = 0, /**< Transmission of various timestamps, elapsed time, \n                                   time deltas, etc */\n    OMX_OTHER_FormatPower,    /**< Perhaps used for enabling/disabling power \n                                   management, setting clocks? */\n    OMX_OTHER_FormatStats,    /**< Could be things such as frame rate, frames \n                                   dropped, etc */\n    OMX_OTHER_FormatBinary,   /**< Arbitrary binary data */\n    OMX_OTHER_FormatVendorReserved = 1000, /**< Starting value for vendor specific \n                                                formats */\n\n    OMX_OTHER_FormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_OTHER_FormatVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n\n    OMX_OTHER_FormatText,\n    OMX_OTHER_FormatTextSKM2,\n    OMX_OTHER_FormatText3GP5,\n\n    OMX_OTHER_FormatMax = 0x7FFFFFFF\n} OMX_OTHER_FORMATTYPE;\n\n/** \n * Enumeration of seek modes.\n */\ntypedef enum OMX_TIME_SEEKMODETYPE {\n    OMX_TIME_SeekModeFast = 0, /**< Prefer seeking to an approximation\n                                * of the requested seek position over   \n                                * the actual seek position if it\n                                * results in a faster seek. */\n    OMX_TIME_SeekModeAccurate, /**< Prefer seeking to the actual seek \n                                * position over an approximation\n                                * of the requested seek position even\n                                * if it results in a slower seek. */\n    OMX_TIME_SeekModeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_TIME_SeekModeVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n\n    OMX_TIME_SeekModeDirectional, /**< Similar to Fast, but if seeking backwards will\n                                   * try and seek to a previous sync position from the\n                                   * current media time. */\n\n    OMX_TIME_SeekModeMax = 0x7FFFFFFF\n} OMX_TIME_SEEKMODETYPE;\n\n/* Structure representing the seekmode of the component */\ntypedef struct OMX_TIME_CONFIG_SEEKMODETYPE {\n    OMX_U32 nSize;                  /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion;       /**< OMX specification version information */\n    OMX_TIME_SEEKMODETYPE eType;    /**< The seek mode */\n} OMX_TIME_CONFIG_SEEKMODETYPE;\n\n/** Structure representing a time stamp used with the following configs \n * on the Clock Component (CC):\n * \n * OMX_IndexConfigTimeCurrentWallTime: query of the CCs current wall  \n *     time\n * OMX_IndexConfigTimeCurrentMediaTime: query of the CCs current media\n *     time\n * OMX_IndexConfigTimeCurrentAudioReference and  \n * OMX_IndexConfigTimeCurrentVideoReference: audio/video reference \n *     clock sending SC its reference time\n * OMX_IndexConfigTimeClientStartTime: a Clock Component client sends \n *     this structure to the Clock Component via a SetConfig on its \n *     client port when it receives a buffer with\n *     OMX_BUFFERFLAG_STARTTIME set. It must use the timestamp\n *     specified by that buffer for nStartTimestamp. \n *\n * Its also used with the following config on components in general:\n *\n * OMX_IndexConfigTimePosition: IL client querying component position \n * (GetConfig) or commanding a component to seek to the given location\n * (SetConfig)\n */\t\ntypedef struct OMX_TIME_CONFIG_TIMESTAMPTYPE {\n    OMX_U32 nSize;               /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion;    /**< OMX specification version\n                                  *   information */\n    OMX_U32 nPortIndex;     /**< port that this structure applies to */\n    OMX_TICKS nTimestamp;  \t     /**< timestamp .*/ \n} OMX_TIME_CONFIG_TIMESTAMPTYPE;  \n\n/** Enumeration of possible reference clocks to the media time. */\ntypedef enum OMX_TIME_UPDATETYPE {\n      OMX_TIME_UpdateRequestFulfillment,    /**< Update is the fulfillment of a media time request. */\n      OMX_TIME_UpdateScaleChanged,\t        /**< Update was generated because the scale chagned. */\n      OMX_TIME_UpdateClockStateChanged,     /**< Update was generated because the clock state changed. */\n      OMX_TIME_UpdateKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n      OMX_TIME_UpdateVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n      OMX_TIME_UpdateMax = 0x7FFFFFFF\n} OMX_TIME_UPDATETYPE;\n\n/** Enumeration of possible reference clocks to the media time. */\ntypedef enum OMX_TIME_REFCLOCKTYPE {\n      OMX_TIME_RefClockNone,    /**< Use no references. */\n      OMX_TIME_RefClockAudio,\t/**< Use references sent through OMX_IndexConfigTimeCurrentAudioReference */\n      OMX_TIME_RefClockVideo,   /**< Use references sent through OMX_IndexConfigTimeCurrentVideoReference */\n      OMX_TIME_RefClockKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n      OMX_TIME_RefClockVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n      OMX_TIME_RefClockMax = 0x7FFFFFFF\n} OMX_TIME_REFCLOCKTYPE;\n\n/** Enumeration of clock states. */\ntypedef enum OMX_TIME_CLOCKSTATE {\n      OMX_TIME_ClockStateRunning,             /**< Clock running. */\n      OMX_TIME_ClockStateWaitingForStartTime, /**< Clock waiting until the \n                                               *   prescribed clients emit their\n                                               *   start time. */\n      OMX_TIME_ClockStateStopped,             /**< Clock stopped. */\n      OMX_TIME_ClockStateKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n      OMX_TIME_ClockStateVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n      OMX_TIME_ClockStateMax = 0x7FFFFFFF\n} OMX_TIME_CLOCKSTATE;\n\n/** Structure representing a media time request to the clock component.\n *\n *  A client component sends this structure to the Clock Component via a SetConfig\n *  on its client port to specify a media timestamp the Clock Component\n *  should emit.  The Clock Component should fulfill the request by sending a\n *  OMX_TIME_MEDIATIMETYPE when its media clock matches the requested \n *  timestamp.\n *\n *  The client may require a media time request be fulfilled slightly\n *  earlier than the media time specified. In this case the client specifies \n *  an offset which is equal to the difference between wall time corresponding \n *  to the requested media time and the wall time when it will be \n *  fulfilled. \n *\n *  A client component may uses these requests and the OMX_TIME_MEDIATIMETYPE to\n *  time events according to timestamps. If a client must perform an operation O at\n *  a time T (e.g. deliver a video frame at its corresponding timestamp), it makes a \n *  media time request at T (perhaps specifying an offset to ensure the request fulfillment\n *  is a little early). When the clock component passes the resulting OMX_TIME_MEDIATIMETYPE\n *  structure back to the client component, the client may perform operation O (perhaps having\n *  to wait a slight amount more time itself as specified by the return values).\n */\n\ntypedef struct OMX_TIME_CONFIG_MEDIATIMEREQUESTTYPE {\n    OMX_U32 nSize;              /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion;   /**< OMX specification version information */\n    OMX_U32 nPortIndex;         /**< port that this structure applies to */\n    OMX_PTR pClientPrivate;     /**< Client private data to disabiguate this media time \n                                 *   from others (e.g. the number of the frame to deliver). \n                                 *   Duplicated in the media time structure that fulfills \n                                 *   this request. A value of zero is reserved for time scale \n                                 *   updates. */\n    OMX_TICKS nMediaTimestamp;  /**< Media timestamp requested.*/ \n    OMX_TICKS nOffset;          /**< Amount of wall clock time by which this\n                                 *   request should be fulfilled early */\n} OMX_TIME_CONFIG_MEDIATIMEREQUESTTYPE;\n\n/**< Structure sent from the clock component client either when fulfilling \n *   a media time request or when the time scale has changed. \n *\n *   In the former case the Clock Component fills this structure and times its emission \n *   to a client component (via the client port) according to the corresponding media \n *   time request sent by the client. The Clock Component should time the emission to occur\n *   when the requested timestamp matches the Clock Component's media time but also the \n *   prescribed offset early. \n *\n *   Upon scale changes the clock component clears the nClientPrivate data, sends the current\n *   media time and sets the nScale to the new scale via the client port. It emits a \n *   OMX_TIME_MEDIATIMETYPE to all clients independent of any requests. This allows clients to \n *   alter processing to accomodate scaling. For instance a video component might skip inter-frames \n *   in the case of extreme fastforward. Likewise an audio component might add or remove samples \n *   from an audio frame to scale audio data. \n *\n *   It is expected that some clock components may not be able to fulfill requests\n *   at exactly the prescribed time. This is acceptable so long as the request is \n *   fulfilled at least as early as described and not later. This structure provides \n *   fields the client may use to wait for the remaining time.\n *\n *   The client may use either the nOffset or nWallTimeAtMedia fields to determine the \n *   wall time until the nMediaTimestamp actually occurs. In the latter case the\n *   client can get a more accurate value for offset by getting the current wall\n *   from the cloc component and subtracting it from nWallTimeAtMedia. \n */\n\ntypedef struct OMX_TIME_MEDIATIMETYPE {\n    OMX_U32 nSize;                  /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion;       /**< OMX specification version information */\n    OMX_U32 nClientPrivate;         /**< Client private data to disabiguate this media time \n                                     *   from others. Copied from the media time request. \n                                     *   A value of zero is reserved for time scale updates. */\n    OMX_TIME_UPDATETYPE eUpdateType; /**< Reason for the update */\n    OMX_TICKS nMediaTimestamp;      /**< Media time requested. If no media time was \n                                     *   requested then this is the current media time. */ \n    OMX_TICKS nOffset;              /**< Amount of wall clock time by which this\n                                     *   request was actually fulfilled early */\n\n    OMX_TICKS nWallTimeAtMediaTime; /**< Wall time corresponding to nMediaTimeStamp.\n                                     *   A client may compare this value to current\n                                     *   media time obtained from the Clock Component to determine\n                                     *   the wall time until the media timestamp is really\n                                     *   current. */\n    OMX_S32 xScale;                 /**< Current media time scale in Q16 format. */\n    OMX_TIME_CLOCKSTATE eState;     /* Seeking Change. Added 7/12.*/\n                                    /**< State of the media time. */\n} OMX_TIME_MEDIATIMETYPE;  \n\n/** Structure representing the current media time scale factor. Applicable only to clock \n *  component, other components see scale changes via OMX_TIME_MEDIATIMETYPE buffers sent via\n *  the clock component client ports. Upon recieving this config the clock component changes \n *  the rate by which the media time increases or decreases effectively implementing trick modes. \n */ \ntypedef struct OMX_TIME_CONFIG_SCALETYPE {\n    OMX_U32 nSize;                  /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion;       /**< OMX specification version information */\n    OMX_S32 xScale;                 /**< This is a value in Q16 format which is used for\n                                     * scaling the media time */\n} OMX_TIME_CONFIG_SCALETYPE;\n \n/** Bits used to identify a clock port. Used in OMX_TIME_CONFIG_CLOCKSTATETYPEs nWaitMask field */\n#define OMX_CLOCKPORT0 0x00000001\n#define OMX_CLOCKPORT1 0x00000002\n#define OMX_CLOCKPORT2 0x00000004\n#define OMX_CLOCKPORT3 0x00000008\n#define OMX_CLOCKPORT4 0x00000010\n#define OMX_CLOCKPORT5 0x00000020\n#define OMX_CLOCKPORT6 0x00000040\n#define OMX_CLOCKPORT7 0x00000080\n\n/** Structure representing the current mode of the media clock. \n *  IL Client uses this config to change or query the mode of the \n *  media clock of the clock component. Applicable only to clock\n *  component. \n *  \n *  On a SetConfig if eState is OMX_TIME_ClockStateRunning media time\n *  starts immediately at the prescribed start time. If\n *  OMX_TIME_ClockStateWaitingForStartTime the Clock Component ignores\n *  the given nStartTime and waits for all clients specified in the \n *  nWaitMask to send starttimes (via \n *  OMX_IndexConfigTimeClientStartTime). The Clock Component then starts \n *  the media clock using the earliest start time supplied. */    \ntypedef struct OMX_TIME_CONFIG_CLOCKSTATETYPE {\n    OMX_U32 nSize;              /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion;   /**< OMX specification version \n                                 *   information */\n    OMX_TIME_CLOCKSTATE eState; /**< State of the media time. */\n    OMX_TICKS nStartTime;       /**< Start time of the media time. */\n    OMX_TICKS nOffset;          /**< Time to offset the media time by \n                                 * (e.g. preroll). Media time will be\n                                 * reported to be nOffset ticks earlier.     \n                                 */\n    OMX_U32 nWaitMask;          /**< Mask of OMX_CLOCKPORT values. */\n} OMX_TIME_CONFIG_CLOCKSTATETYPE;\n\n/** Structure representing the reference clock currently being used to\n *  compute media time. IL client uses this config to change or query the \n *  clock component's active reference clock */\ntypedef struct OMX_TIME_CONFIG_ACTIVEREFCLOCKTYPE {\n    OMX_U32 nSize;                  /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion;       /**< OMX specification version information */\n    OMX_TIME_REFCLOCKTYPE eClock;   /**< Reference clock used to compute media time */                        \n} OMX_TIME_CONFIG_ACTIVEREFCLOCKTYPE;\n\n/** Descriptor for setting specifics of power type.\n *  Note: this structure is listed for backwards compatibility. */\ntypedef struct OMX_OTHER_CONFIG_POWERTYPE {\n    OMX_U32 nSize;            /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion; /**< OMX specification version information */\n    OMX_BOOL bEnablePM;       /**< Flag to enable Power Management */\n} OMX_OTHER_CONFIG_POWERTYPE;\n\n\n/** Descriptor for setting specifics of stats type.\n *  Note: this structure is listed for backwards compatibility. */\ntypedef struct OMX_OTHER_CONFIG_STATSTYPE {\n    OMX_U32 nSize;            /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion; /**< OMX specification version information */\n    /* what goes here */\n} OMX_OTHER_CONFIG_STATSTYPE;\n\n\n/**\n * The PortDefinition structure is used to define all of the parameters \n * necessary for the compliant component to setup an input or an output other \n * path.\n */\ntypedef struct OMX_OTHER_PORTDEFINITIONTYPE {\n    OMX_OTHER_FORMATTYPE eFormat;  /**< Type of data expected for this channel */\n} OMX_OTHER_PORTDEFINITIONTYPE;\n\n/**  Port format parameter.  This structure is used to enumerate\n  *  the various data input/output format supported by the port.\n  */\ntypedef struct OMX_OTHER_PARAM_PORTFORMATTYPE {\n    OMX_U32 nSize; /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion; /**< OMX specification version information */\n    OMX_U32 nPortIndex; /**< Indicates which port to set */\n    OMX_U32 nIndex; /**< Indicates the enumeration index for the format from 0x0 to N-1 */\n    OMX_OTHER_FORMATTYPE eFormat; /**< Type of data expected for this channel */\n} OMX_OTHER_PARAM_PORTFORMATTYPE; \n\n#ifdef __cplusplus\n}\n#endif /* __cplusplus */\n\n#endif\n/* File EOF */\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/IL/OMX_Types.h",
    "content": "/*\n * Copyright (c) 2008 The Khronos Group Inc. \n * \n * Permission is hereby granted, free of charge, to any person obtaining\n * a copy of this software and associated documentation files (the\n * \"Software\"), to deal in the Software without restriction, including\n * without limitation the rights to use, copy, modify, merge, publish,\n * distribute, sublicense, and/or sell copies of the Software, and to\n * permit persons to whom the Software is furnished to do so, subject\n * to the following conditions: \n * The above copyright notice and this permission notice shall be included\n * in all copies or substantial portions of the Software. \n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\n * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\n * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\n * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \n *\n */\n\n/** OMX_Types.h - OpenMax IL version 1.1.2\n *  The OMX_Types header file contains the primitive type definitions used by \n *  the core, the application and the component.  This file may need to be\n *  modified to be used on systems that do not have \"char\" set to 8 bits, \n *  \"short\" set to 16 bits and \"long\" set to 32 bits.\n */\n\n#ifndef OMX_Types_h\n#define OMX_Types_h\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif /* __cplusplus */\n\n/** The OMX_API and OMX_APIENTRY are platform specific definitions used\n *  to declare OMX function prototypes.  They are modified to meet the\n *  requirements for a particular platform */\n#ifdef __SYMBIAN32__   \n#   ifdef __OMX_EXPORTS\n#       define OMX_API __declspec(dllexport)\n#   else\n#       ifdef _WIN32\n#           define OMX_API __declspec(dllexport) \n#       else\n#           define OMX_API __declspec(dllimport)\n#       endif\n#   endif\n#else\n#   if defined(_WIN32) && !defined(__MINGW32__)\n#      ifdef __OMX_EXPORTS\n#          define OMX_API __declspec(dllexport)\n#      else\n#          define OMX_API __declspec(dllimport)\n#      endif\n#   else\n#      ifdef __OMX_EXPORTS\n#          define OMX_API\n#      else\n#          define OMX_API extern\n#      endif\n#   endif\n#endif\n\n#ifndef OMX_APIENTRY\n#define OMX_APIENTRY \n#endif \n\n/** OMX_IN is used to identify inputs to an OMX function.  This designation \n    will also be used in the case of a pointer that points to a parameter \n    that is used as an output. */\n#ifndef OMX_IN\n#define OMX_IN\n#endif\n\n/** OMX_OUT is used to identify outputs from an OMX function.  This \n    designation will also be used in the case of a pointer that points \n    to a parameter that is used as an input. */\n#ifndef OMX_OUT\n#define OMX_OUT\n#endif\n\n\n/** OMX_INOUT is used to identify parameters that may be either inputs or\n    outputs from an OMX function at the same time.  This designation will \n    also be used in the case of a pointer that  points to a parameter that \n    is used both as an input and an output. */\n#ifndef OMX_INOUT\n#define OMX_INOUT\n#endif\n\n/** OMX_ALL is used to as a wildcard to select all entities of the same type\n *  when specifying the index, or referring to a object by an index.  (i.e.\n *  use OMX_ALL to indicate all N channels). When used as a port index\n *  for a config or parameter this OMX_ALL denotes that the config or\n *  parameter applies to the entire component not just one port. */\n#define OMX_ALL 0xFFFFFFFF\n\n/** In the following we define groups that help building doxygen documentation */\n\n/** @defgroup core OpenMAX IL core\n * Functions and structure related to the OMX IL core\n */\n \n /** @defgroup comp OpenMAX IL component\n * Functions and structure related to the OMX IL component\n */\n \n/** @defgroup rpm Resource and Policy Management \n * Structures for resource and policy management of components\n */\n\n/** @defgroup buf Buffer Management\n * Buffer handling functions and structures\n */\n  \n/** @defgroup tun Tunneling\n * @ingroup core comp\n * Structures and functions to manage tunnels among component ports\n */\n \n/** @defgroup cp Content Pipes\n *  @ingroup core\n */\n \n /** @defgroup metadata Metadata handling\n  * \n  */ \n\n#if defined(__GNUC__)\n#include <stdint.h>\n#define STDINT_H_AVAILABLE\n#endif\n\n/** OMX_U8 is an 8 bit unsigned quantity that is byte aligned */\ntypedef unsigned char OMX_U8;\n\n/** OMX_S8 is an 8 bit signed quantity that is byte aligned */\ntypedef signed char OMX_S8;\n\n/** OMX_U16 is a 16 bit unsigned quantity that is 16 bit word aligned */\ntypedef unsigned short OMX_U16;\n\n/** OMX_S16 is a 16 bit signed quantity that is 16 bit word aligned */\ntypedef signed short OMX_S16;\n\n/** OMX_U32 is a 32 bit unsigned quantity that is 32 bit word aligned */\n#ifdef STDINT_H_AVAILABLE\ntypedef uint32_t OMX_U32;\n#else\ntypedef unsigned long OMX_U32;\n#endif\n\n/** OMX_S32 is a 32 bit signed quantity that is 32 bit word aligned */\n#ifdef STDINT_H_AVAILABLE\ntypedef int32_t OMX_S32;\n#else\ntypedef signed long OMX_S32;\n#endif\n\n\n/* Users with compilers that cannot accept the \"long long\" designation should\n   define the OMX_SKIP64BIT macro.  It should be noted that this may cause \n   some components to fail to compile if the component was written to require\n   64 bit integral types.  However, these components would NOT compile anyway\n   since the compiler does not support the way the component was written.\n*/\n#ifndef OMX_SKIP64BIT\n#ifdef __SYMBIAN32__\n/** OMX_U64 is a 64 bit unsigned quantity that is 64 bit word aligned */\ntypedef unsigned long long OMX_U64;\n\n/** OMX_S64 is a 64 bit signed quantity that is 64 bit word aligned */\ntypedef signed long long OMX_S64;\n\n#elif defined(WIN32)\n\n/** OMX_U64 is a 64 bit unsigned quantity that is 64 bit word aligned */   \ntypedef unsigned __int64  OMX_U64;\n\n/** OMX_S64 is a 64 bit signed quantity that is 64 bit word aligned */\ntypedef signed   __int64  OMX_S64;\n\n#else /* WIN32 */\n\n/** OMX_U64 is a 64 bit unsigned quantity that is 64 bit word aligned */\ntypedef unsigned long long OMX_U64;\n\n/** OMX_S64 is a 64 bit signed quantity that is 64 bit word aligned */\ntypedef signed long long OMX_S64;\n\n#endif /* WIN32 */\n#endif\n\n\n/** The OMX_BOOL type is intended to be used to represent a true or a false \n    value when passing parameters to and from the OMX core and components.  The\n    OMX_BOOL is a 32 bit quantity and is aligned on a 32 bit word boundary.\n */\ntypedef enum OMX_BOOL {\n    OMX_FALSE = 0,\n    OMX_TRUE = !OMX_FALSE,\n    OMX_BOOL_MAX = 0x7FFFFFFF\n} OMX_BOOL; \n \n/** The OMX_PTR type is intended to be used to pass pointers between the OMX\n    applications and the OMX Core and components.  This is a 32 bit pointer and\n    is aligned on a 32 bit boundary.\n */\ntypedef void* OMX_PTR;\n\n/** The OMX_STRING type is intended to be used to pass \"C\" type strings between\n    the application and the core and component.  The OMX_STRING type is a 32 \n    bit pointer to a zero terminated string.  The  pointer is word aligned and \n    the string is byte aligned.  \n */\ntypedef char* OMX_STRING;\n\n/** The OMX_BYTE type is intended to be used to pass arrays of bytes such as\n    buffers between the application and the component and core.  The OMX_BYTE \n    type is a 32 bit pointer to a zero terminated string.  The  pointer is word\n    aligned and the string is byte aligned.\n */\ntypedef unsigned char* OMX_BYTE;\n\n/** OMX_UUIDTYPE is a very long unique identifier to uniquely identify\n    at runtime.  This identifier should be generated by a component in a way\n    that guarantees that every instance of the identifier running on the system\n    is unique. */\ntypedef unsigned char OMX_UUIDTYPE[128];\n\n/** The OMX_DIRTYPE enumeration is used to indicate if a port is an input or\n    an output port.  This enumeration is common across all component types.    \n */\ntypedef enum OMX_DIRTYPE\n{\n    OMX_DirInput,              /**< Port is an input port */\n    OMX_DirOutput,             /**< Port is an output port */\n    OMX_DirMax = 0x7FFFFFFF\n} OMX_DIRTYPE;\n\n/** The OMX_ENDIANTYPE enumeration is used to indicate the bit ordering \n    for numerical data (i.e. big endian, or little endian).    \n */\ntypedef enum OMX_ENDIANTYPE\n{\n    OMX_EndianBig, /**< big endian */\n    OMX_EndianLittle, /**< little endian */\n    OMX_EndianMax = 0x7FFFFFFF\n} OMX_ENDIANTYPE;\n\n\n/** The OMX_NUMERICALDATATYPE enumeration is used to indicate if data \n    is signed or unsigned\n */\ntypedef enum OMX_NUMERICALDATATYPE\n{\n    OMX_NumericalDataSigned, /**< signed data */\n    OMX_NumericalDataUnsigned, /**< unsigned data */\n    OMX_NumercialDataMax = 0x7FFFFFFF\n} OMX_NUMERICALDATATYPE;\n\n\n/** Unsigned bounded value type */\ntypedef struct OMX_BU32 {\n    OMX_U32 nValue; /**< actual value */\n    OMX_U32 nMin;   /**< minimum for value (i.e. nValue >= nMin) */\n    OMX_U32 nMax;   /**< maximum for value (i.e. nValue <= nMax) */\n} OMX_BU32;\n\n\n/** Signed bounded value type */\ntypedef struct OMX_BS32 {\n    OMX_S32 nValue; /**< actual value */\n    OMX_S32 nMin;   /**< minimum for value (i.e. nValue >= nMin) */\n    OMX_S32 nMax;   /**< maximum for value (i.e. nValue <= nMax) */\n} OMX_BS32;\n\n\n/** Structure representing some time or duration in microseconds. This structure\n  *  must be interpreted as a signed 64 bit value. The quantity is signed to accommodate \n  *  negative deltas and preroll scenarios. The quantity is represented in microseconds \n  *  to accomodate high resolution timestamps (e.g. DVD presentation timestamps based\n  *  on a 90kHz clock) and to allow more accurate and synchronized delivery (e.g. \n  *  individual audio samples delivered at 192 kHz). The quantity is 64 bit to \n  *  accommodate a large dynamic range (signed 32 bit values would allow only for plus\n  *  or minus 35 minutes).\n  *\n  *  Implementations with limited precision may convert the signed 64 bit value to \n  *  a signed 32 bit value internally but risk loss of precision.  \n  */\n#ifndef OMX_SKIP64BIT\ntypedef OMX_S64 OMX_TICKS;\n#else\ntypedef struct OMX_TICKS\n{\n    OMX_U32 nLowPart;    /** low bits of the signed 64 bit tick value */\n    OMX_U32 nHighPart;   /** high bits of the signed 64 bit tick value */\n} OMX_TICKS;\n#endif\n#define OMX_TICKS_PER_SECOND 1000000\n\n/** Define the public interface for the OMX Handle.  The core will not use\n    this value internally, but the application should only use this value.\n */\ntypedef void* OMX_HANDLETYPE;\n\ntypedef struct OMX_MARKTYPE\n{\n    OMX_HANDLETYPE hMarkTargetComponent;   /**< The component that will \n                                                generate a mark event upon \n                                                processing the mark. */\n    OMX_PTR pMarkData;   /**< Application specific data associated with \n                              the mark sent on a mark event to disambiguate \n                              this mark from others. */\n} OMX_MARKTYPE;\n\n\n/** OMX_NATIVE_DEVICETYPE is used to map a OMX video port to the\n *  platform & operating specific object used to reference the display \n *  or can be used by a audio port for native audio rendering */\ntypedef void* OMX_NATIVE_DEVICETYPE;\n\n/** OMX_NATIVE_WINDOWTYPE is used to map a OMX video port to the\n *  platform & operating specific object used to reference the window */\ntypedef void* OMX_NATIVE_WINDOWTYPE;\n\n\n/** Define the OMX IL version that corresponds to this set of header files.\n *  We also define a combined version that can be used to write or compare\n *  values of the 32bit nVersion field, assuming a little endian architecture */\n#define OMX_VERSION_MAJOR 1\n#define OMX_VERSION_MINOR 1\n#define OMX_VERSION_REVISION 2\n#define OMX_VERSION_STEP 0\n\n#define OMX_VERSION ((OMX_VERSION_STEP<<24) | (OMX_VERSION_REVISION<<16) | (OMX_VERSION_MINOR<<8) | OMX_VERSION_MAJOR)\n\n\n/** The OMX_VERSIONTYPE union is used to specify the version for\n    a structure or component.  For a component, the version is entirely\n    specified by the component vendor.  Components doing the same function\n    from different vendors may or may not have the same version.  For \n    structures, the version shall be set by the entity that allocates the\n    structure.  For structures specified in the OMX 1.1 specification, the\n    value of the version shall be set to 1.1.0.0 in all cases.  Access to the\n    OMX_VERSIONTYPE can be by a single 32 bit access (e.g. by nVersion) or\n    by accessing one of the structure elements to, for example, check only\n    the Major revision.\n */\ntypedef union OMX_VERSIONTYPE\n{\n    struct\n    {\n        OMX_U8 nVersionMajor;   /**< Major version accessor element */\n        OMX_U8 nVersionMinor;   /**< Minor version accessor element */\n        OMX_U8 nRevision;       /**< Revision version accessor element */\n        OMX_U8 nStep;           /**< Step version accessor element */\n    } s;\n    OMX_U32 nVersion;           /**< 32 bit value to make accessing the\n                                    version easily done in a single word\n                                    size copy/compare operation */\n} OMX_VERSIONTYPE;\n\n#ifdef __cplusplus\n}\n#endif /* __cplusplus */\n\n#endif\n/* File EOF */\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/IL/OMX_Video.h",
    "content": "/**\n * Copyright (c) 2008 The Khronos Group Inc. \n * \n * Permission is hereby granted, free of charge, to any person obtaining\n * a copy of this software and associated documentation files (the\n * \"Software\"), to deal in the Software without restriction, including\n * without limitation the rights to use, copy, modify, merge, publish,\n * distribute, sublicense, and/or sell copies of the Software, and to\n * permit persons to whom the Software is furnished to do so, subject\n * to the following conditions: \n * The above copyright notice and this permission notice shall be included\n * in all copies or substantial portions of the Software. \n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\n * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\n * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\n * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \n *\n */\n\n/** \n *  @file OMX_Video.h - OpenMax IL version 1.1.2\n *  The structures is needed by Video components to exchange parameters \n *  and configuration data with OMX components.\n */\n#ifndef OMX_Video_h\n#define OMX_Video_h\n\n/** @defgroup video OpenMAX IL Video Domain\n * @ingroup iv\n * Structures for OpenMAX IL Video domain\n * @{\n */\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif /* __cplusplus */\n\n\n/**\n * Each OMX header must include all required header files to allow the\n * header to compile without errors.  The includes below are required\n * for this header file to compile successfully \n */\n\n#include \"OMX_IVCommon.h\"\n\n\n/**\n * Enumeration used to define the possible video compression codings.  \n * NOTE:  This essentially refers to file extensions. If the coding is \n *        being used to specify the ENCODE type, then additional work \n *        must be done to configure the exact flavor of the compression \n *        to be used.  For decode cases where the user application can \n *        not differentiate between MPEG-4 and H.264 bit streams, it is \n *        up to the codec to handle this.\n */\ntypedef enum OMX_VIDEO_CODINGTYPE {\n    OMX_VIDEO_CodingUnused,     /**< Value when coding is N/A */\n    OMX_VIDEO_CodingAutoDetect, /**< Autodetection of coding type */\n    OMX_VIDEO_CodingMPEG2,      /**< AKA: H.262 */\n    OMX_VIDEO_CodingH263,       /**< H.263 */\n    OMX_VIDEO_CodingMPEG4,      /**< MPEG-4 */\n    OMX_VIDEO_CodingWMV,        /**< all versions of Windows Media Video */\n    OMX_VIDEO_CodingRV,         /**< all versions of Real Video */\n    OMX_VIDEO_CodingAVC,        /**< H.264/AVC */\n    OMX_VIDEO_CodingMJPEG,      /**< Motion JPEG */\n    OMX_VIDEO_CodingKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_VIDEO_CodingVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n\n#define OMX_AUDIO_CodingVP6_Supported 1\n    OMX_VIDEO_CodingVP6,        /**< On2 VP6 */\n#define OMX_AUDIO_CodingVP7_Supported 1\n    OMX_VIDEO_CodingVP7,        /**< On2 VP7 */\n#define OMX_AUDIO_CodingVP8_Supported 1\n    OMX_VIDEO_CodingVP8,        /**< On2 VP8 */\n#define OMX_AUDIO_CodingYUV_Supported 1\n    OMX_VIDEO_CodingYUV,        /* raw YUV video */\n#define OMX_AUDIO_CodingSorenson_Supported 1\n    OMX_VIDEO_CodingSorenson,   /**< Sorenson */\n#define OMX_AUDIO_CodingTheora_Supported 1\n    OMX_VIDEO_CodingTheora,     /**< Theora */\n#define OMX_AUDIO_CodingMVC_Supported 1\n    OMX_VIDEO_CodingMVC,        /**< H.264/MVC */ \t\n    \n    OMX_VIDEO_CodingMax = 0x7FFFFFFF\n} OMX_VIDEO_CODINGTYPE;\n\n\n/**\n * Data structure used to define a video path.  The number of Video paths for \n * input and output will vary by type of the Video component.  \n * \n *    Input (aka Source) : zero Inputs, one Output,\n *    Splitter           : one Input, 2 or more Outputs,\n *    Processing Element : one Input, one output,\n *    Mixer              : 2 or more inputs, one output,\n *    Output (aka Sink)  : one Input, zero outputs.\n * \n * The PortDefinition structure is used to define all of the parameters \n * necessary for the compliant component to setup an input or an output video \n * path.  If additional vendor specific data is required, it should be \n * transmitted to the component using the CustomCommand function.  Compliant \n * components will prepopulate this structure with optimal values during the \n * GetDefaultInitParams command.\n *\n * STRUCT MEMBERS:\n *  cMIMEType             : MIME type of data for the port\n *  pNativeRender         : Platform specific reference for a display if a \n *                          sync, otherwise this field is 0\n *  nFrameWidth           : Width of frame to be used on channel if \n *                          uncompressed format is used.  Use 0 for unknown,\n *                          don't care or variable\n *  nFrameHeight          : Height of frame to be used on channel if \n *                          uncompressed format is used. Use 0 for unknown,\n *                          don't care or variable\n *  nStride               : Number of bytes per span of an image \n *                          (i.e. indicates the number of bytes to get\n *                          from span N to span N+1, where negative stride\n *                          indicates the image is bottom up\n *  nSliceHeight          : Height used when encoding in slices\n *  nBitrate              : Bit rate of frame to be used on channel if \n *                          compressed format is used. Use 0 for unknown, \n *                          don't care or variable\n *  xFramerate            : Frame rate to be used on channel if uncompressed \n *                          format is used. Use 0 for unknown, don't care or \n *                          variable.  Units are Q16 frames per second.\n *  bFlagErrorConcealment : Turns on error concealment if it is supported by \n *                          the OMX component\n *  eCompressionFormat    : Compression format used in this instance of the \n *                          component. When OMX_VIDEO_CodingUnused is \n *                          specified, eColorFormat is used\n *  eColorFormat : Decompressed format used by this component\n *  pNativeWindow : Platform specific reference for a window object if a \n *                          display sink , otherwise this field is 0x0. \n */\ntypedef struct OMX_VIDEO_PORTDEFINITIONTYPE {\n    OMX_STRING cMIMEType;\n    OMX_NATIVE_DEVICETYPE pNativeRender;\n    OMX_U32 nFrameWidth;\n    OMX_U32 nFrameHeight;\n    OMX_S32 nStride;\n    OMX_U32 nSliceHeight;\n    OMX_U32 nBitrate;\n    OMX_U32 xFramerate;\n    OMX_BOOL bFlagErrorConcealment;\n    OMX_VIDEO_CODINGTYPE eCompressionFormat;\n    OMX_COLOR_FORMATTYPE eColorFormat;\n    OMX_NATIVE_WINDOWTYPE pNativeWindow;\n} OMX_VIDEO_PORTDEFINITIONTYPE;\n\n/**  \n * Port format parameter.  This structure is used to enumerate the various \n * data input/output format supported by the port.\n * \n * STRUCT MEMBERS:\n *  nSize              : Size of the structure in bytes\n *  nVersion           : OMX specification version information\n *  nPortIndex         : Indicates which port to set\n *  nIndex             : Indicates the enumeration index for the format from \n *                       0x0 to N-1\n *  eCompressionFormat : Compression format used in this instance of the \n *                       component. When OMX_VIDEO_CodingUnused is specified, \n *                       eColorFormat is used \n *  eColorFormat       : Decompressed format used by this component\n *  xFrameRate         : Indicates the video frame rate in Q16 format\n */\ntypedef struct OMX_VIDEO_PARAM_PORTFORMATTYPE {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n    OMX_U32 nIndex;\n    OMX_VIDEO_CODINGTYPE eCompressionFormat; \n    OMX_COLOR_FORMATTYPE eColorFormat;\n    OMX_U32 xFramerate;\n} OMX_VIDEO_PARAM_PORTFORMATTYPE;\n\n\n/**\n * This is a structure for configuring video compression quantization \n * parameter values.  Codecs may support different QP values for different\n * frame types.\n *\n * STRUCT MEMBERS:\n *  nSize      : Size of the structure in bytes\n *  nVersion   : OMX specification version info\n *  nPortIndex : Port that this structure applies to\n *  nQpI       : QP value to use for index frames\n *  nQpP       : QP value to use for P frames\n *  nQpB       : QP values to use for bidirectional frames \n */\ntypedef struct OMX_VIDEO_PARAM_QUANTIZATIONTYPE {\n    OMX_U32 nSize;            \n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n    OMX_U32 nQpI;\n    OMX_U32 nQpP;\n    OMX_U32 nQpB;\n} OMX_VIDEO_PARAM_QUANTIZATIONTYPE;\n\n\n/** \n * Structure for configuration of video fast update parameters. \n *  \n * STRUCT MEMBERS:\n *  nSize      : Size of the structure in bytes\n *  nVersion   : OMX specification version info \n *  nPortIndex : Port that this structure applies to\n *  bEnableVFU : Enable/Disable video fast update\n *  nFirstGOB  : Specifies the number of the first macroblock row\n *  nFirstMB   : specifies the first MB relative to the specified first GOB\n *  nNumMBs    : Specifies the number of MBs to be refreshed from nFirstGOB \n *               and nFirstMB\n */\ntypedef struct OMX_VIDEO_PARAM_VIDEOFASTUPDATETYPE {\n    OMX_U32 nSize;            \n    OMX_VERSIONTYPE nVersion; \n    OMX_U32 nPortIndex;       \n    OMX_BOOL bEnableVFU;      \n    OMX_U32 nFirstGOB;                            \n    OMX_U32 nFirstMB;                            \n    OMX_U32 nNumMBs;                                  \n} OMX_VIDEO_PARAM_VIDEOFASTUPDATETYPE;\n\n\n/** \n * Enumeration of possible bitrate control types \n */\ntypedef enum OMX_VIDEO_CONTROLRATETYPE {\n    OMX_Video_ControlRateDisable,\n    OMX_Video_ControlRateVariable,\n    OMX_Video_ControlRateConstant,\n    OMX_Video_ControlRateVariableSkipFrames,\n    OMX_Video_ControlRateConstantSkipFrames,\n    OMX_Video_ControlRateKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_Video_ControlRateVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_Video_ControlRateMax = 0x7FFFFFFF\n} OMX_VIDEO_CONTROLRATETYPE;\n\n\n/** \n * Structure for configuring bitrate mode of a codec. \n *\n * STRUCT MEMBERS:\n *  nSize          : Size of the struct in bytes\n *  nVersion       : OMX spec version info\n *  nPortIndex     : Port that this struct applies to\n *  eControlRate   : Control rate type enum\n *  nTargetBitrate : Target bitrate to encode with\n */\ntypedef struct OMX_VIDEO_PARAM_BITRATETYPE {\n    OMX_U32 nSize;                          \n    OMX_VERSIONTYPE nVersion;               \n    OMX_U32 nPortIndex;                     \n    OMX_VIDEO_CONTROLRATETYPE eControlRate; \n    OMX_U32 nTargetBitrate;                 \n} OMX_VIDEO_PARAM_BITRATETYPE;\n\n\n/** \n * Enumeration of possible motion vector (MV) types \n */\ntypedef enum OMX_VIDEO_MOTIONVECTORTYPE {\n    OMX_Video_MotionVectorPixel,\n    OMX_Video_MotionVectorHalfPel,\n    OMX_Video_MotionVectorQuarterPel,\n    OMX_Video_MotionVectorEighthPel,\n    OMX_Video_MotionVectorKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_Video_MotionVectorVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_Video_MotionVectorMax = 0x7FFFFFFF\n} OMX_VIDEO_MOTIONVECTORTYPE;\n\n\n/**\n * Structure for configuring the number of motion vectors used as well\n * as their accuracy.\n * \n * STRUCT MEMBERS:\n *  nSize            : Size of the struct in bytes\n *  nVersion         : OMX spec version info\n *  nPortIndex       : port that this structure applies to\n *  eAccuracy        : Enumerated MV accuracy\n *  bUnrestrictedMVs : Allow unrestricted MVs\n *  bFourMV          : Allow use of 4 MVs\n *  sXSearchRange    : Search range in horizontal direction for MVs\n *  sYSearchRange    : Search range in vertical direction for MVs\n */\ntypedef struct OMX_VIDEO_PARAM_MOTIONVECTORTYPE {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n    OMX_VIDEO_MOTIONVECTORTYPE eAccuracy;\n    OMX_BOOL bUnrestrictedMVs;\n    OMX_BOOL bFourMV;\n    OMX_S32 sXSearchRange;\n    OMX_S32 sYSearchRange;\n} OMX_VIDEO_PARAM_MOTIONVECTORTYPE;\n\n\n/** \n * Enumeration of possible methods to use for Intra Refresh \n */\ntypedef enum OMX_VIDEO_INTRAREFRESHTYPE {\n    OMX_VIDEO_IntraRefreshCyclic,                         /**< Cyclic intra refresh, bit 0 is set*/\n    OMX_VIDEO_IntraRefreshAdaptive,                       /**< Adaptive intra refresh, bit 1 is set*/\n    OMX_VIDEO_IntraRefreshBoth,                           /**< Cyclic + Adaptive intra refresh (no mrows since bit 2 is off)*/\n    OMX_VIDEO_IntraRefreshKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_VIDEO_IntraRefreshVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_VIDEO_IntraRefreshCyclicMrows,                    /**< Cyclic intra refresh, multiple rows at a time bits 0 and 2 are set*/\n    OMX_VIDEO_IntraRefreshPseudoRand,                     /**< Pseudo random intra refresh, uses bit 3*/\n    OMX_VIDEO_IntraRefreshMax = 0x7FFFFFFF\n} OMX_VIDEO_INTRAREFRESHTYPE;\n\n\n/**\n * Structure for configuring intra refresh mode \n * \n * STRUCT MEMBERS:\n *  nSize        : Size of the structure in bytes\n *  nVersion     : OMX specification version information\n *  nPortIndex   : Port that this structure applies to\n *  eRefreshMode : Cyclic, Adaptive, or Both\n *  nAirMBs      : Number of intra macroblocks to refresh in a frame when \n *                 AIR is enabled\n *  nAirRef      : Number of times a motion marked macroblock has to be  \n *                 intra coded\n *  nCirMBs      : Number of consecutive macroblocks to be coded as \"intra\"  \n *                 when CIR is enabled\n */\ntypedef struct OMX_VIDEO_PARAM_INTRAREFRESHTYPE {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n    OMX_VIDEO_INTRAREFRESHTYPE eRefreshMode;\n    OMX_U32 nAirMBs;\n    OMX_U32 nAirRef;\n    OMX_U32 nCirMBs;\n    OMX_U32 nPirMBs;\n} OMX_VIDEO_PARAM_INTRAREFRESHTYPE;\n\n\n/**\n * Structure for enabling various error correction methods for video \n * compression.\n *\n * STRUCT MEMBERS:\n *  nSize                   : Size of the structure in bytes\n *  nVersion                : OMX specification version information \n *  nPortIndex              : Port that this structure applies to \n *  bEnableHEC              : Enable/disable header extension codes (HEC)\n *  bEnableResync           : Enable/disable resynchronization markers\n *  nResynchMarkerSpacing   : Resynch markers interval (in bits) to be \n *                            applied in the stream \n *  bEnableDataPartitioning : Enable/disable data partitioning \n *  bEnableRVLC             : Enable/disable reversible variable length \n *                            coding\n */\ntypedef struct OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n    OMX_BOOL bEnableHEC;\n    OMX_BOOL bEnableResync;\n    OMX_U32  nResynchMarkerSpacing;\n    OMX_BOOL bEnableDataPartitioning;\n    OMX_BOOL bEnableRVLC;\n} OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE;\n\n\n/** \n * Configuration of variable block-size motion compensation (VBSMC) \n * \n * STRUCT MEMBERS:\n *  nSize      : Size of the structure in bytes\n *  nVersion   : OMX specification version information \n *  nPortIndex : Port that this structure applies to\n *  b16x16     : Enable inter block search 16x16\n *  b16x8      : Enable inter block search 16x8\n *  b8x16      : Enable inter block search 8x16\n *  b8x8       : Enable inter block search 8x8\n *  b8x4       : Enable inter block search 8x4\n *  b4x8       : Enable inter block search 4x8\n *  b4x4       : Enable inter block search 4x4\n */\ntypedef struct OMX_VIDEO_PARAM_VBSMCTYPE {\n    OMX_U32 nSize; \n    OMX_VERSIONTYPE nVersion; \n    OMX_U32 nPortIndex;       \n    OMX_BOOL b16x16; \n    OMX_BOOL b16x8; \n    OMX_BOOL b8x16;\n    OMX_BOOL b8x8;\n    OMX_BOOL b8x4;\n    OMX_BOOL b4x8;\n    OMX_BOOL b4x4;\n} OMX_VIDEO_PARAM_VBSMCTYPE;\n\n\n/** \n * H.263 profile types, each profile indicates support for various \n * performance bounds and different annexes.\n *\n * ENUMS:\n *  Baseline           : Baseline Profile: H.263 (V1), no optional modes                                                    \n *  H320 Coding        : H.320 Coding Efficiency Backward Compatibility \n *                       Profile: H.263+ (V2), includes annexes I, J, L.4\n *                       and T\n *  BackwardCompatible : Backward Compatibility Profile: H.263 (V1), \n *                       includes annex F                                    \n *  ISWV2              : Interactive Streaming Wireless Profile: H.263+ \n *                       (V2), includes annexes I, J, K and T                 \n *  ISWV3              : Interactive Streaming Wireless Profile: H.263++  \n *                       (V3), includes profile 3 and annexes V and W.6.3.8   \n *  HighCompression    : Conversational High Compression Profile: H.263++  \n *                       (V3), includes profiles 1 & 2 and annexes D and U   \n *  Internet           : Conversational Internet Profile: H.263++ (V3),  \n *                       includes profile 5 and annex K                       \n *  Interlace          : Conversational Interlace Profile: H.263++ (V3),  \n *                       includes profile 5 and annex W.6.3.11               \n *  HighLatency        : High Latency Profile: H.263++ (V3), includes  \n *                       profile 6 and annexes O.1 and P.5                       \n */\ntypedef enum OMX_VIDEO_H263PROFILETYPE {\n    OMX_VIDEO_H263ProfileBaseline            = 0x01,        \n    OMX_VIDEO_H263ProfileH320Coding          = 0x02,          \n    OMX_VIDEO_H263ProfileBackwardCompatible  = 0x04,  \n    OMX_VIDEO_H263ProfileISWV2               = 0x08,               \n    OMX_VIDEO_H263ProfileISWV3               = 0x10,               \n    OMX_VIDEO_H263ProfileHighCompression     = 0x20,     \n    OMX_VIDEO_H263ProfileInternet            = 0x40,            \n    OMX_VIDEO_H263ProfileInterlace           = 0x80,           \n    OMX_VIDEO_H263ProfileHighLatency         = 0x100,         \n    OMX_VIDEO_H263ProfileKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_VIDEO_H263ProfileVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_VIDEO_H263ProfileMax                 = 0x7FFFFFFF  \n} OMX_VIDEO_H263PROFILETYPE;\n\n\n/** \n * H.263 level types, each level indicates support for various frame sizes, \n * bit rates, decoder frame rates.\n */\ntypedef enum OMX_VIDEO_H263LEVELTYPE {\n    OMX_VIDEO_H263Level10  = 0x01,  \n    OMX_VIDEO_H263Level20  = 0x02,      \n    OMX_VIDEO_H263Level30  = 0x04,      \n    OMX_VIDEO_H263Level40  = 0x08,      \n    OMX_VIDEO_H263Level45  = 0x10,      \n    OMX_VIDEO_H263Level50  = 0x20,      \n    OMX_VIDEO_H263Level60  = 0x40,      \n    OMX_VIDEO_H263Level70  = 0x80, \n    OMX_VIDEO_H263LevelKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_VIDEO_H263LevelVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_VIDEO_H263LevelMax = 0x7FFFFFFF  \n} OMX_VIDEO_H263LEVELTYPE;\n\n\n/** \n * Specifies the picture type. These values should be OR'd to signal all \n * pictures types which are allowed.\n *\n * ENUMS:\n *  Generic Picture Types:          I, P and B\n *  H.263 Specific Picture Types:   SI and SP\n *  H.264 Specific Picture Types:   EI and EP\n *  MPEG-4 Specific Picture Types:  S\n */\ntypedef enum OMX_VIDEO_PICTURETYPE {\n    OMX_VIDEO_PictureTypeI   = 0x01,\n    OMX_VIDEO_PictureTypeP   = 0x02,\n    OMX_VIDEO_PictureTypeB   = 0x04,\n    OMX_VIDEO_PictureTypeSI  = 0x08,\n    OMX_VIDEO_PictureTypeSP  = 0x10,\n    OMX_VIDEO_PictureTypeEI  = 0x11,\n    OMX_VIDEO_PictureTypeEP  = 0x12,\n    OMX_VIDEO_PictureTypeS   = 0x14,\n    OMX_VIDEO_PictureTypeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_VIDEO_PictureTypeVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_VIDEO_PictureTypeMax = 0x7FFFFFFF\n} OMX_VIDEO_PICTURETYPE;\n\n\n/** \n * H.263 Params \n *\n * STRUCT MEMBERS:\n *  nSize                    : Size of the structure in bytes\n *  nVersion                 : OMX specification version information \n *  nPortIndex               : Port that this structure applies to\n *  nPFrames                 : Number of P frames between each I frame\n *  nBFrames                 : Number of B frames between each I frame\n *  eProfile                 : H.263 profile(s) to use\n *  eLevel                   : H.263 level(s) to use\n *  bPLUSPTYPEAllowed        : Indicating that it is allowed to use PLUSPTYPE \n *                             (specified in the 1998 version of H.263) to \n *                             indicate custom picture sizes or clock \n *                             frequencies \n *  nAllowedPictureTypes     : Specifies the picture types allowed in the \n *                             bitstream\n *  bForceRoundingTypeToZero : value of the RTYPE bit (bit 6 of MPPTYPE) is \n *                             not constrained. It is recommended to change \n *                             the value of the RTYPE bit for each reference \n *                             picture in error-free communication\n *  nPictureHeaderRepetition : Specifies the frequency of picture header \n *                             repetition\n *  nGOBHeaderInterval       : Specifies the interval of non-empty GOB  \n *                             headers in units of GOBs\n */\ntypedef struct OMX_VIDEO_PARAM_H263TYPE {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n    OMX_U32 nPFrames;\n    OMX_U32 nBFrames;\n    OMX_VIDEO_H263PROFILETYPE eProfile;\n\tOMX_VIDEO_H263LEVELTYPE eLevel;\n    OMX_BOOL bPLUSPTYPEAllowed;\n    OMX_U32 nAllowedPictureTypes;\n    OMX_BOOL bForceRoundingTypeToZero;\n    OMX_U32 nPictureHeaderRepetition;\n    OMX_U32 nGOBHeaderInterval;\n} OMX_VIDEO_PARAM_H263TYPE;\n\n\n/** \n * MPEG-2 profile types, each profile indicates support for various \n * performance bounds and different annexes.\n */\ntypedef enum OMX_VIDEO_MPEG2PROFILETYPE {\n    OMX_VIDEO_MPEG2ProfileSimple = 0,  /**< Simple Profile */\n    OMX_VIDEO_MPEG2ProfileMain,        /**< Main Profile */\n    OMX_VIDEO_MPEG2Profile422,         /**< 4:2:2 Profile */\n    OMX_VIDEO_MPEG2ProfileSNR,         /**< SNR Profile */\n    OMX_VIDEO_MPEG2ProfileSpatial,     /**< Spatial Profile */\n    OMX_VIDEO_MPEG2ProfileHigh,        /**< High Profile */\n    OMX_VIDEO_MPEG2ProfileKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_VIDEO_MPEG2ProfileVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_VIDEO_MPEG2ProfileMax = 0x7FFFFFFF  \n} OMX_VIDEO_MPEG2PROFILETYPE;\n\n\n/** \n * MPEG-2 level types, each level indicates support for various frame \n * sizes, bit rates, decoder frame rates.  No need \n */\ntypedef enum OMX_VIDEO_MPEG2LEVELTYPE {\n    OMX_VIDEO_MPEG2LevelLL = 0,  /**< Low Level */ \n    OMX_VIDEO_MPEG2LevelML,      /**< Main Level */ \n    OMX_VIDEO_MPEG2LevelH14,     /**< High 1440 */ \n    OMX_VIDEO_MPEG2LevelHL,      /**< High Level */   \n    OMX_VIDEO_MPEG2LevelKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_VIDEO_MPEG2LevelVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_VIDEO_MPEG2LevelMax = 0x7FFFFFFF  \n} OMX_VIDEO_MPEG2LEVELTYPE;\n\n\n/** \n * MPEG-2 params \n *\n * STRUCT MEMBERS:\n *  nSize      : Size of the structure in bytes\n *  nVersion   : OMX specification version information\n *  nPortIndex : Port that this structure applies to\n *  nPFrames   : Number of P frames between each I frame\n *  nBFrames   : Number of B frames between each I frame\n *  eProfile   : MPEG-2 profile(s) to use\n *  eLevel     : MPEG-2 levels(s) to use\n */\ntypedef struct OMX_VIDEO_PARAM_MPEG2TYPE {\n    OMX_U32 nSize;           \n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;      \n    OMX_U32 nPFrames;        \n    OMX_U32 nBFrames;        \n    OMX_VIDEO_MPEG2PROFILETYPE eProfile;\n\tOMX_VIDEO_MPEG2LEVELTYPE eLevel;   \n} OMX_VIDEO_PARAM_MPEG2TYPE;\n\n\n/** \n * MPEG-4 profile types, each profile indicates support for various \n * performance bounds and different annexes.\n * \n * ENUMS:\n *  - Simple Profile, Levels 1-3\n *  - Simple Scalable Profile, Levels 1-2\n *  - Core Profile, Levels 1-2\n *  - Main Profile, Levels 2-4\n *  - N-bit Profile, Level 2\n *  - Scalable Texture Profile, Level 1\n *  - Simple Face Animation Profile, Levels 1-2\n *  - Simple Face and Body Animation (FBA) Profile, Levels 1-2\n *  - Basic Animated Texture Profile, Levels 1-2\n *  - Hybrid Profile, Levels 1-2\n *  - Advanced Real Time Simple Profiles, Levels 1-4\n *  - Core Scalable Profile, Levels 1-3\n *  - Advanced Coding Efficiency Profile, Levels 1-4\n *  - Advanced Core Profile, Levels 1-2\n *  - Advanced Scalable Texture, Levels 2-3\n */\ntypedef enum OMX_VIDEO_MPEG4PROFILETYPE {\n    OMX_VIDEO_MPEG4ProfileSimple           = 0x01,        \n    OMX_VIDEO_MPEG4ProfileSimpleScalable   = 0x02,    \n    OMX_VIDEO_MPEG4ProfileCore             = 0x04,              \n    OMX_VIDEO_MPEG4ProfileMain             = 0x08,             \n    OMX_VIDEO_MPEG4ProfileNbit             = 0x10,              \n    OMX_VIDEO_MPEG4ProfileScalableTexture  = 0x20,   \n    OMX_VIDEO_MPEG4ProfileSimpleFace       = 0x40,        \n    OMX_VIDEO_MPEG4ProfileSimpleFBA        = 0x80,         \n    OMX_VIDEO_MPEG4ProfileBasicAnimated    = 0x100,     \n    OMX_VIDEO_MPEG4ProfileHybrid           = 0x200,            \n    OMX_VIDEO_MPEG4ProfileAdvancedRealTime = 0x400,  \n    OMX_VIDEO_MPEG4ProfileCoreScalable     = 0x800,      \n    OMX_VIDEO_MPEG4ProfileAdvancedCoding   = 0x1000,    \n    OMX_VIDEO_MPEG4ProfileAdvancedCore     = 0x2000,      \n    OMX_VIDEO_MPEG4ProfileAdvancedScalable = 0x4000,\n    OMX_VIDEO_MPEG4ProfileAdvancedSimple   = 0x8000,\n    OMX_VIDEO_MPEG4ProfileKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_VIDEO_MPEG4ProfileVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_VIDEO_MPEG4ProfileMax              = 0x7FFFFFFF  \n} OMX_VIDEO_MPEG4PROFILETYPE;\n\n\n/** \n * MPEG-4 level types, each level indicates support for various frame \n * sizes, bit rates, decoder frame rates.  No need \n */\ntypedef enum OMX_VIDEO_MPEG4LEVELTYPE {\n    OMX_VIDEO_MPEG4Level0  = 0x01,   /**< Level 0 */   \n    OMX_VIDEO_MPEG4Level0b = 0x02,   /**< Level 0b */   \n    OMX_VIDEO_MPEG4Level1  = 0x04,   /**< Level 1 */ \n    OMX_VIDEO_MPEG4Level2  = 0x08,   /**< Level 2 */ \n    OMX_VIDEO_MPEG4Level3  = 0x10,   /**< Level 3 */ \n    OMX_VIDEO_MPEG4Level4  = 0x20,   /**< Level 4 */  \n    OMX_VIDEO_MPEG4Level4a = 0x40,   /**< Level 4a */  \n    OMX_VIDEO_MPEG4Level5  = 0x80,   /**< Level 5 */  \n    OMX_VIDEO_MPEG4Level6  = 0x100,  /**< Level 5 */  \n    OMX_VIDEO_MPEG4LevelKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_VIDEO_MPEG4LevelVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_VIDEO_MPEG4LevelMax = 0x7FFFFFFF  \n} OMX_VIDEO_MPEG4LEVELTYPE;\n\n\n/** \n * MPEG-4 configuration.  This structure handles configuration options\n * which are specific to MPEG4 algorithms\n *\n * STRUCT MEMBERS:\n *  nSize                : Size of the structure in bytes\n *  nVersion             : OMX specification version information\n *  nPortIndex           : Port that this structure applies to\n *  nSliceHeaderSpacing  : Number of macroblocks between slice header (H263+ \n *                         Annex K). Put zero if not used\n *  bSVH                 : Enable Short Video Header mode\n *  bGov                 : Flag to enable GOV\n *  nPFrames             : Number of P frames between each I frame (also called \n *                         GOV period)\n *  nBFrames             : Number of B frames between each I frame\n *  nIDCVLCThreshold     : Value of intra DC VLC threshold\n *  bACPred              : Flag to use ac prediction\n *  nMaxPacketSize       : Maximum size of packet in bytes.\n *  nTimeIncRes          : Used to pass VOP time increment resolution for MPEG4. \n *                         Interpreted as described in MPEG4 standard.\n *  eProfile             : MPEG-4 profile(s) to use.\n *  eLevel               : MPEG-4 level(s) to use.\n *  nAllowedPictureTypes : Specifies the picture types allowed in the bitstream\n *  nHeaderExtension     : Specifies the number of consecutive video packet\n *                         headers within a VOP\n *  bReversibleVLC       : Specifies whether reversible variable length coding \n *                         is in use\n */\ntypedef struct OMX_VIDEO_PARAM_MPEG4TYPE {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n    OMX_U32 nSliceHeaderSpacing;\n    OMX_BOOL bSVH;\n    OMX_BOOL bGov;\n    OMX_U32 nPFrames;\n    OMX_U32 nBFrames;\n    OMX_U32 nIDCVLCThreshold;\n    OMX_BOOL bACPred;\n    OMX_U32 nMaxPacketSize;\n    OMX_U32 nTimeIncRes;\n    OMX_VIDEO_MPEG4PROFILETYPE eProfile;\n    OMX_VIDEO_MPEG4LEVELTYPE eLevel;\n    OMX_U32 nAllowedPictureTypes;\n    OMX_U32 nHeaderExtension;\n    OMX_BOOL bReversibleVLC;\n} OMX_VIDEO_PARAM_MPEG4TYPE;\n\n\n/** \n * WMV Versions \n */\ntypedef enum OMX_VIDEO_WMVFORMATTYPE {\n    OMX_VIDEO_WMVFormatUnused = 0x01,   /**< Format unused or unknown */\n    OMX_VIDEO_WMVFormat7      = 0x02,   /**< Windows Media Video format 7 */\n    OMX_VIDEO_WMVFormat8      = 0x04,   /**< Windows Media Video format 8 */\n    OMX_VIDEO_WMVFormat9      = 0x08,   /**< Windows Media Video format 9 */\n    OMX_VIDEO_WMFFormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_VIDEO_WMFFormatVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_VIDEO_WMVFormatMax    = 0x7FFFFFFF\n} OMX_VIDEO_WMVFORMATTYPE;\n\n\n/** \n * WMV Params \n *\n * STRUCT MEMBERS:\n *  nSize      : Size of the structure in bytes\n *  nVersion   : OMX specification version information\n *  nPortIndex : Port that this structure applies to\n *  eFormat    : Version of WMV stream / data\n */\ntypedef struct OMX_VIDEO_PARAM_WMVTYPE {\n    OMX_U32 nSize; \n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n    OMX_VIDEO_WMVFORMATTYPE eFormat;\n} OMX_VIDEO_PARAM_WMVTYPE;\n\n\n/** \n * Real Video Version \n */\ntypedef enum OMX_VIDEO_RVFORMATTYPE {\n    OMX_VIDEO_RVFormatUnused = 0, /**< Format unused or unknown */\n    OMX_VIDEO_RVFormat8,          /**< Real Video format 8 */\n    OMX_VIDEO_RVFormat9,          /**< Real Video format 9 */\n    OMX_VIDEO_RVFormatG2,         /**< Real Video Format G2 */\n    OMX_VIDEO_RVFormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_VIDEO_RVFormatVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_VIDEO_RVFormatMax = 0x7FFFFFFF\n} OMX_VIDEO_RVFORMATTYPE;\n\n\n/** \n * Real Video Params \n *\n * STUCT MEMBERS:\n *  nSize              : Size of the structure in bytes\n *  nVersion           : OMX specification version information \n *  nPortIndex         : Port that this structure applies to\n *  eFormat            : Version of RV stream / data\n *  nBitsPerPixel      : Bits per pixel coded in the frame\n *  nPaddedWidth       : Padded width in pixel of a video frame\n *  nPaddedHeight      : Padded Height in pixels of a video frame\n *  nFrameRate         : Rate of video in frames per second\n *  nBitstreamFlags    : Flags which internal information about the bitstream\n *  nBitstreamVersion  : Bitstream version\n *  nMaxEncodeFrameSize: Max encoded frame size\n *  bEnablePostFilter  : Turn on/off post filter\n *  bEnableTemporalInterpolation : Turn on/off temporal interpolation\n *  bEnableLatencyMode : When enabled, the decoder does not display a decoded \n *                       frame until it has detected that no enhancement layer \n *  \t\t\t\t\t frames or dependent B frames will be coming. This \n *  \t\t\t\t\t detection usually occurs when a subsequent non-B \n *  \t\t\t\t\t frame is encountered \n */\ntypedef struct OMX_VIDEO_PARAM_RVTYPE {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n    OMX_VIDEO_RVFORMATTYPE eFormat;\n    OMX_U16 nBitsPerPixel;\n    OMX_U16 nPaddedWidth;\n    OMX_U16 nPaddedHeight;\n    OMX_U32 nFrameRate;\n    OMX_U32 nBitstreamFlags;\n    OMX_U32 nBitstreamVersion;\n    OMX_U32 nMaxEncodeFrameSize;\n    OMX_BOOL bEnablePostFilter;\n    OMX_BOOL bEnableTemporalInterpolation;\n    OMX_BOOL bEnableLatencyMode;\n} OMX_VIDEO_PARAM_RVTYPE;\n\n\n/** \n * AVC profile types, each profile indicates support for various \n * performance bounds and different annexes.\n */\ntypedef enum OMX_VIDEO_AVCPROFILETYPE {\n    OMX_VIDEO_AVCProfileBaseline = 0x01,   /**< Baseline profile */\n    OMX_VIDEO_AVCProfileMain     = 0x02,   /**< Main profile */\n    OMX_VIDEO_AVCProfileExtended = 0x04,   /**< Extended profile */\n    OMX_VIDEO_AVCProfileHigh     = 0x08,   /**< High profile */\n    OMX_VIDEO_AVCProfileHigh10   = 0x10,   /**< High 10 profile */\n    OMX_VIDEO_AVCProfileHigh422  = 0x20,   /**< High 4:2:2 profile */\n    OMX_VIDEO_AVCProfileHigh444  = 0x40,   /**< High 4:4:4 profile */\n    OMX_VIDEO_AVCProfileConstrainedBaseline = 0x80, /**< Constrained Baseline Profile   */\n    OMX_VIDEO_AVCProfileKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_VIDEO_AVCProfileVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_VIDEO_AVCProfileMax      = 0x7FFFFFFF  \n} OMX_VIDEO_AVCPROFILETYPE;\n\n\n/** \n * AVC level types, each level indicates support for various frame sizes, \n * bit rates, decoder frame rates.  No need \n */\ntypedef enum OMX_VIDEO_AVCLEVELTYPE {\n    OMX_VIDEO_AVCLevel1   = 0x01,     /**< Level 1 */\n    OMX_VIDEO_AVCLevel1b  = 0x02,     /**< Level 1b */\n    OMX_VIDEO_AVCLevel11  = 0x04,     /**< Level 1.1 */\n    OMX_VIDEO_AVCLevel12  = 0x08,     /**< Level 1.2 */\n    OMX_VIDEO_AVCLevel13  = 0x10,     /**< Level 1.3 */\n    OMX_VIDEO_AVCLevel2   = 0x20,     /**< Level 2 */\n    OMX_VIDEO_AVCLevel21  = 0x40,     /**< Level 2.1 */\n    OMX_VIDEO_AVCLevel22  = 0x80,     /**< Level 2.2 */\n    OMX_VIDEO_AVCLevel3   = 0x100,    /**< Level 3 */\n    OMX_VIDEO_AVCLevel31  = 0x200,    /**< Level 3.1 */\n    OMX_VIDEO_AVCLevel32  = 0x400,    /**< Level 3.2 */\n    OMX_VIDEO_AVCLevel4   = 0x800,    /**< Level 4 */\n    OMX_VIDEO_AVCLevel41  = 0x1000,   /**< Level 4.1 */\n    OMX_VIDEO_AVCLevel42  = 0x2000,   /**< Level 4.2 */\n    OMX_VIDEO_AVCLevel5   = 0x4000,   /**< Level 5 */\n    OMX_VIDEO_AVCLevel51  = 0x8000,   /**< Level 5.1 */\n    OMX_VIDEO_AVCLevelKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_VIDEO_AVCLevelVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_VIDEO_AVCLevelMax = 0x7FFFFFFF  \n} OMX_VIDEO_AVCLEVELTYPE;\n\n\n/** \n * AVC loop filter modes \n *\n * OMX_VIDEO_AVCLoopFilterEnable               : Enable\n * OMX_VIDEO_AVCLoopFilterDisable              : Disable\n * OMX_VIDEO_AVCLoopFilterDisableSliceBoundary : Disabled on slice boundaries\n */\ntypedef enum OMX_VIDEO_AVCLOOPFILTERTYPE {\n    OMX_VIDEO_AVCLoopFilterEnable = 0,\n    OMX_VIDEO_AVCLoopFilterDisable,\n    OMX_VIDEO_AVCLoopFilterDisableSliceBoundary,\n    OMX_VIDEO_AVCLoopFilterKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_VIDEO_AVCLoopFilterVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_VIDEO_AVCLoopFilterMax = 0x7FFFFFFF\n} OMX_VIDEO_AVCLOOPFILTERTYPE;\n\n\n/** \n * AVC params \n *\n * STRUCT MEMBERS:\n *  nSize                     : Size of the structure in bytes\n *  nVersion                  : OMX specification version information\n *  nPortIndex                : Port that this structure applies to\n *  nSliceHeaderSpacing       : Number of macroblocks between slice header, put  \n *                              zero if not used\n *  nPFrames                  : Number of P frames between each I frame\n *  nBFrames                  : Number of B frames between each I frame\n *  bUseHadamard              : Enable/disable Hadamard transform\n *  nRefFrames                : Max number of reference frames to use for inter\n *                              motion search (1-16)\n *  nRefIdxTrailing           : Pic param set ref frame index (index into ref\n *                              frame buffer of trailing frames list), B frame\n *                              support\n *  nRefIdxForward            : Pic param set ref frame index (index into ref\n *                              frame buffer of forward frames list), B frame\n *                              support\n *  bEnableUEP                : Enable/disable unequal error protection. This \n *                              is only valid of data partitioning is enabled.\n *  bEnableFMO                : Enable/disable flexible macroblock ordering\n *  bEnableASO                : Enable/disable arbitrary slice ordering\n *  bEnableRS                 : Enable/disable sending of redundant slices\n *  eProfile                  : AVC profile(s) to use\n *  eLevel                    : AVC level(s) to use\n *  nAllowedPictureTypes      : Specifies the picture types allowed in the \n *                              bitstream\n *  bFrameMBsOnly             : specifies that every coded picture of the \n *                              coded video sequence is a coded frame \n *                              containing only frame macroblocks\n *  bMBAFF                    : Enable/disable switching between frame and \n *                              field macroblocks within a picture\n *  bEntropyCodingCABAC       : Entropy decoding method to be applied for the \n *                              syntax elements for which two descriptors appear \n *                              in the syntax tables\n *  bWeightedPPrediction      : Enable/disable weighted prediction shall not \n *                              be applied to P and SP slices\n *  nWeightedBipredicitonMode : Default weighted prediction is applied to B \n *                              slices \n *  bconstIpred               : Enable/disable intra prediction\n *  bDirect8x8Inference       : Specifies the method used in the derivation \n *                              process for luma motion vectors for B_Skip, \n *                              B_Direct_16x16 and B_Direct_8x8 as specified \n *                              in subclause 8.4.1.2 of the AVC spec \n *  bDirectSpatialTemporal    : Flag indicating spatial or temporal direct\n *                              mode used in B slice coding (related to \n *                              bDirect8x8Inference) . Spatial direct mode is \n *                              more common and should be the default.\n *  nCabacInitIdx             : Index used to init CABAC contexts\n *  eLoopFilterMode           : Enable/disable loop filter\n */\ntypedef struct OMX_VIDEO_PARAM_AVCTYPE {\n    OMX_U32 nSize;                 \n    OMX_VERSIONTYPE nVersion;      \n    OMX_U32 nPortIndex;            \n    OMX_U32 nSliceHeaderSpacing;  \n    OMX_U32 nPFrames;     \n    OMX_U32 nBFrames;     \n    OMX_BOOL bUseHadamard;\n    OMX_U32 nRefFrames;  \n\tOMX_U32 nRefIdx10ActiveMinus1;\n\tOMX_U32 nRefIdx11ActiveMinus1;\n    OMX_BOOL bEnableUEP;  \n    OMX_BOOL bEnableFMO;  \n    OMX_BOOL bEnableASO;  \n    OMX_BOOL bEnableRS;   \n    OMX_VIDEO_AVCPROFILETYPE eProfile;\n\tOMX_VIDEO_AVCLEVELTYPE eLevel; \n    OMX_U32 nAllowedPictureTypes;  \n\tOMX_BOOL bFrameMBsOnly;        \t\t\t\t\t\t\t\t\t\n    OMX_BOOL bMBAFF;               \n    OMX_BOOL bEntropyCodingCABAC;  \n    OMX_BOOL bWeightedPPrediction; \n    OMX_U32 nWeightedBipredicitonMode; \n    OMX_BOOL bconstIpred ;\n    OMX_BOOL bDirect8x8Inference;  \n\tOMX_BOOL bDirectSpatialTemporal;\n\tOMX_U32 nCabacInitIdc;\n\tOMX_VIDEO_AVCLOOPFILTERTYPE eLoopFilterMode;\n} OMX_VIDEO_PARAM_AVCTYPE;\n\ntypedef struct OMX_VIDEO_PARAM_PROFILELEVELTYPE {\n   OMX_U32 nSize;                 \n   OMX_VERSIONTYPE nVersion;      \n   OMX_U32 nPortIndex;            \n   OMX_U32 eProfile;      /**< type is OMX_VIDEO_AVCPROFILETYPE, OMX_VIDEO_H263PROFILETYPE, \n                                 or OMX_VIDEO_MPEG4PROFILETYPE depending on context */\n   OMX_U32 eLevel;        /**< type is OMX_VIDEO_AVCLEVELTYPE, OMX_VIDEO_H263LEVELTYPE, \n                                 or OMX_VIDEO_MPEG4PROFILETYPE depending on context */\n   OMX_U32 nProfileIndex; /**< Used to query for individual profile support information,\n                               This parameter is valid only for \n                               OMX_IndexParamVideoProfileLevelQuerySupported index,\n                               For all other indices this parameter is to be ignored. */\n} OMX_VIDEO_PARAM_PROFILELEVELTYPE;\n\n/** \n * Structure for dynamically configuring bitrate mode of a codec. \n *\n * STRUCT MEMBERS:\n *  nSize          : Size of the struct in bytes\n *  nVersion       : OMX spec version info\n *  nPortIndex     : Port that this struct applies to\n *  nEncodeBitrate : Target average bitrate to be generated in bps\n */\ntypedef struct OMX_VIDEO_CONFIG_BITRATETYPE {\n    OMX_U32 nSize;                          \n    OMX_VERSIONTYPE nVersion;               \n    OMX_U32 nPortIndex;                     \n    OMX_U32 nEncodeBitrate;                 \n} OMX_VIDEO_CONFIG_BITRATETYPE;\n\n/** \n * Defines Encoder Frame Rate setting\n *\n * STRUCT MEMBERS:\n *  nSize            : Size of the structure in bytes\n *  nVersion         : OMX specification version information \n *  nPortIndex       : Port that this structure applies to\n *  xEncodeFramerate : Encoding framerate represented in Q16 format\n */\ntypedef struct OMX_CONFIG_FRAMERATETYPE {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n    OMX_U32 xEncodeFramerate; /* Q16 format */\n} OMX_CONFIG_FRAMERATETYPE;\n\ntypedef struct OMX_CONFIG_INTRAREFRESHVOPTYPE {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n    OMX_BOOL IntraRefreshVOP;\n} OMX_CONFIG_INTRAREFRESHVOPTYPE;\n\ntypedef struct OMX_CONFIG_MACROBLOCKERRORMAPTYPE {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n    OMX_U32 nErrMapSize;           /* Size of the Error Map in bytes */\n    OMX_U8  ErrMap[1];             /* Error map hint */\n} OMX_CONFIG_MACROBLOCKERRORMAPTYPE;\n\ntypedef struct OMX_CONFIG_MBERRORREPORTINGTYPE {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n    OMX_BOOL bEnabled;\n} OMX_CONFIG_MBERRORREPORTINGTYPE;\n\ntypedef struct OMX_PARAM_MACROBLOCKSTYPE {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n    OMX_U32 nMacroblocks;\n} OMX_PARAM_MACROBLOCKSTYPE;\n\n/** \n * AVC Slice Mode modes \n *\n * OMX_VIDEO_SLICEMODE_AVCDefault   : Normal frame encoding, one slice per frame\n * OMX_VIDEO_SLICEMODE_AVCMBSlice   : NAL mode, number of MBs per frame\n * OMX_VIDEO_SLICEMODE_AVCByteSlice : NAL mode, number of bytes per frame\n */\ntypedef enum OMX_VIDEO_AVCSLICEMODETYPE {\n    OMX_VIDEO_SLICEMODE_AVCDefault = 0,\n    OMX_VIDEO_SLICEMODE_AVCMBSlice,\n    OMX_VIDEO_SLICEMODE_AVCByteSlice,\n    OMX_VIDEO_SLICEMODE_AVCKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_VIDEO_SLICEMODE_AVCVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_VIDEO_SLICEMODE_AVCLevelMax = 0x7FFFFFFF\n} OMX_VIDEO_AVCSLICEMODETYPE;\n\n/** \n * AVC FMO Slice Mode Params \n *\n * STRUCT MEMBERS:\n *  nSize      : Size of the structure in bytes\n *  nVersion   : OMX specification version information\n *  nPortIndex : Port that this structure applies to\n *  nNumSliceGroups : Specifies the number of slice groups\n *  nSliceGroupMapType : Specifies the type of slice groups\n *  eSliceMode : Specifies the type of slice\n */\ntypedef struct OMX_VIDEO_PARAM_AVCSLICEFMO {\n    OMX_U32 nSize; \n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n    OMX_U8 nNumSliceGroups;\n    OMX_U8 nSliceGroupMapType;\n    OMX_VIDEO_AVCSLICEMODETYPE eSliceMode;\n} OMX_VIDEO_PARAM_AVCSLICEFMO;\n\n/** \n * AVC IDR Period Configs\n *\n * STRUCT MEMBERS:\n *  nSize      : Size of the structure in bytes\n *  nVersion   : OMX specification version information\n *  nPortIndex : Port that this structure applies to\n *  nIDRPeriod : Specifies periodicity of IDR frames\n *  nPFrames : Specifies internal of coding Intra frames\n */\ntypedef struct OMX_VIDEO_CONFIG_AVCINTRAPERIOD {\n    OMX_U32 nSize; \n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n    OMX_U32 nIDRPeriod;\n    OMX_U32 nPFrames;\n} OMX_VIDEO_CONFIG_AVCINTRAPERIOD;\n\n/** \n * AVC NAL Size Configs\n *\n * STRUCT MEMBERS:\n *  nSize      : Size of the structure in bytes\n *  nVersion   : OMX specification version information\n *  nPortIndex : Port that this structure applies to\n *  nNaluBytes : Specifies the NAL unit size\n */\ntypedef struct OMX_VIDEO_CONFIG_NALSIZE {\n    OMX_U32 nSize; \n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n    OMX_U32 nNaluBytes;\n} OMX_VIDEO_CONFIG_NALSIZE;\n\n\n/** @} */\n\n#ifdef __cplusplus\n}\n#endif /* __cplusplus */\n\n#endif\n/* File EOF */\n\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/KHR/khrplatform.h",
    "content": "#ifndef __khrplatform_h_\n#define __khrplatform_h_\n\n/*\n** Copyright (c) 2008-2009 The Khronos Group Inc.\n**\n** Permission is hereby granted, free of charge, to any person obtaining a\n** copy of this software and/or associated documentation files (the\n** \"Materials\"), to deal in the Materials without restriction, including\n** without limitation the rights to use, copy, modify, merge, publish,\n** distribute, sublicense, and/or sell copies of the Materials, and to\n** permit persons to whom the Materials are furnished to do so, subject to\n** the following conditions:\n**\n** The above copyright notice and this permission notice shall be included\n** in all copies or substantial portions of the Materials.\n**\n** THE MATERIALS ARE PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\n** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\n** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\n** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.\n*/\n\n/* Khronos platform-specific types and definitions.\n *\n * $Revision: 23298 $ on $Date: 2013-09-30 17:07:13 -0700 (Mon, 30 Sep 2013) $\n *\n * Adopters may modify this file to suit their platform. Adopters are\n * encouraged to submit platform specific modifications to the Khronos\n * group so that they can be included in future versions of this file.\n * Please submit changes by sending them to the public Khronos Bugzilla\n * (http://khronos.org/bugzilla) by filing a bug against product\n * \"Khronos (general)\" component \"Registry\".\n *\n * A predefined template which fills in some of the bug fields can be\n * reached using http://tinyurl.com/khrplatform-h-bugreport, but you\n * must create a Bugzilla login first.\n *\n *\n * See the Implementer's Guidelines for information about where this file\n * should be located on your system and for more details of its use:\n *    http://www.khronos.org/registry/implementers_guide.pdf\n *\n * This file should be included as\n *        #include <KHR/khrplatform.h>\n * by Khronos client API header files that use its types and defines.\n *\n * The types in khrplatform.h should only be used to define API-specific types.\n *\n * Types defined in khrplatform.h:\n *    khronos_int8_t              signed   8  bit\n *    khronos_uint8_t             unsigned 8  bit\n *    khronos_int16_t             signed   16 bit\n *    khronos_uint16_t            unsigned 16 bit\n *    khronos_int32_t             signed   32 bit\n *    khronos_uint32_t            unsigned 32 bit\n *    khronos_int64_t             signed   64 bit\n *    khronos_uint64_t            unsigned 64 bit\n *    khronos_intptr_t            signed   same number of bits as a pointer\n *    khronos_uintptr_t           unsigned same number of bits as a pointer\n *    khronos_ssize_t             signed   size\n *    khronos_usize_t             unsigned size\n *    khronos_float_t             signed   32 bit floating point\n *    khronos_time_ns_t           unsigned 64 bit time in nanoseconds\n *    khronos_utime_nanoseconds_t unsigned time interval or absolute time in\n *                                         nanoseconds\n *    khronos_stime_nanoseconds_t signed time interval in nanoseconds\n *    khronos_boolean_enum_t      enumerated boolean type. This should\n *      only be used as a base type when a client API's boolean type is\n *      an enum. Client APIs which use an integer or other type for\n *      booleans cannot use this as the base type for their boolean.\n *\n * Tokens defined in khrplatform.h:\n *\n *    KHRONOS_FALSE, KHRONOS_TRUE Enumerated boolean false/true values.\n *\n *    KHRONOS_SUPPORT_INT64 is 1 if 64 bit integers are supported; otherwise 0.\n *    KHRONOS_SUPPORT_FLOAT is 1 if floats are supported; otherwise 0.\n *\n * Calling convention macros defined in this file:\n *    KHRONOS_APICALL\n *    KHRONOS_APIENTRY\n *    KHRONOS_APIATTRIBUTES\n *\n * These may be used in function prototypes as:\n *\n *      KHRONOS_APICALL void KHRONOS_APIENTRY funcname(\n *                                  int arg1,\n *                                  int arg2) KHRONOS_APIATTRIBUTES;\n */\n\n/*-------------------------------------------------------------------------\n * Definition of KHRONOS_APICALL\n *-------------------------------------------------------------------------\n * This precedes the return type of the function in the function prototype.\n */\n#if defined(_WIN32) && !defined(__SCITECH_SNAP__)\n#   define KHRONOS_APICALL __declspec(dllimport)\n#elif defined (__SYMBIAN32__)\n#   define KHRONOS_APICALL IMPORT_C\n#else\n#   define KHRONOS_APICALL\n#endif\n\n/*-------------------------------------------------------------------------\n * Definition of KHRONOS_APIENTRY\n *-------------------------------------------------------------------------\n * This follows the return type of the function  and precedes the function\n * name in the function prototype.\n */\n#if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(__SCITECH_SNAP__)\n    /* Win32 but not WinCE */\n#   define KHRONOS_APIENTRY __stdcall\n#else\n#   define KHRONOS_APIENTRY\n#endif\n\n/*-------------------------------------------------------------------------\n * Definition of KHRONOS_APIATTRIBUTES\n *-------------------------------------------------------------------------\n * This follows the closing parenthesis of the function prototype arguments.\n */\n#if defined (__ARMCC_2__)\n#define KHRONOS_APIATTRIBUTES __softfp\n#else\n#define KHRONOS_APIATTRIBUTES\n#endif\n\n/*-------------------------------------------------------------------------\n * basic type definitions\n *-----------------------------------------------------------------------*/\n#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__GNUC__) || defined(__SCO__) || defined(__USLC__)\n\n\n/*\n * Using <stdint.h>\n */\n#include <stdint.h>\ntypedef int32_t                 khronos_int32_t;\ntypedef uint32_t                khronos_uint32_t;\ntypedef int64_t                 khronos_int64_t;\ntypedef uint64_t                khronos_uint64_t;\n#define KHRONOS_SUPPORT_INT64   1\n#define KHRONOS_SUPPORT_FLOAT   1\n\n#elif defined(__VMS ) || defined(__sgi)\n\n/*\n * Using <inttypes.h>\n */\n#include <inttypes.h>\ntypedef int32_t                 khronos_int32_t;\ntypedef uint32_t                khronos_uint32_t;\ntypedef int64_t                 khronos_int64_t;\ntypedef uint64_t                khronos_uint64_t;\n#define KHRONOS_SUPPORT_INT64   1\n#define KHRONOS_SUPPORT_FLOAT   1\n\n#elif defined(_WIN32) && !defined(__SCITECH_SNAP__)\n\n/*\n * Win32\n */\ntypedef __int32                 khronos_int32_t;\ntypedef unsigned __int32        khronos_uint32_t;\ntypedef __int64                 khronos_int64_t;\ntypedef unsigned __int64        khronos_uint64_t;\n#define KHRONOS_SUPPORT_INT64   1\n#define KHRONOS_SUPPORT_FLOAT   1\n\n#elif defined(__sun__) || defined(__digital__)\n\n/*\n * Sun or Digital\n */\ntypedef int                     khronos_int32_t;\ntypedef unsigned int            khronos_uint32_t;\n#if defined(__arch64__) || defined(_LP64)\ntypedef long int                khronos_int64_t;\ntypedef unsigned long int       khronos_uint64_t;\n#else\ntypedef long long int           khronos_int64_t;\ntypedef unsigned long long int  khronos_uint64_t;\n#endif /* __arch64__ */\n#define KHRONOS_SUPPORT_INT64   1\n#define KHRONOS_SUPPORT_FLOAT   1\n\n#elif defined(_VIDEOCORE)\n\n/*\n * VideoCore with Metaware compiler\n */\n#include <vcinclude/common.h>\ntypedef int32_t                 khronos_int32_t;\ntypedef uint32_t                khronos_uint32_t;\ntypedef int64_t                 khronos_int64_t;\ntypedef uint64_t                khronos_uint64_t;\n#define KHRONOS_SUPPORT_INT64   1\n#define KHRONOS_SUPPORT_FLOAT   1\n\n#elif 0\n\n/*\n * Hypothetical platform with no float or int64 support\n */\ntypedef int                     khronos_int32_t;\ntypedef unsigned int            khronos_uint32_t;\n#define KHRONOS_SUPPORT_INT64   0\n#define KHRONOS_SUPPORT_FLOAT   0\n\n#else\n\n/*\n * Generic fallback\n */\n#include <stdint.h>\ntypedef int32_t                 khronos_int32_t;\ntypedef uint32_t                khronos_uint32_t;\ntypedef int64_t                 khronos_int64_t;\ntypedef uint64_t                khronos_uint64_t;\n#define KHRONOS_SUPPORT_INT64   1\n#define KHRONOS_SUPPORT_FLOAT   1\n\n#endif\n\n\n/*\n * Types that are (so far) the same on all platforms\n */\ntypedef signed   char          khronos_int8_t;\ntypedef unsigned char          khronos_uint8_t;\ntypedef signed   short int     khronos_int16_t;\ntypedef unsigned short int     khronos_uint16_t;\n\n/*\n * Types that differ between LLP64 and LP64 architectures - in LLP64, \n * pointers are 64 bits, but 'long' is still 32 bits. Win64 appears\n * to be the only LLP64 architecture in current use.\n */\n#ifdef _WIN64\ntypedef signed   long long int khronos_intptr_t;\ntypedef unsigned long long int khronos_uintptr_t;\ntypedef signed   long long int khronos_ssize_t;\ntypedef unsigned long long int khronos_usize_t;\n#else\ntypedef signed   long  int     khronos_intptr_t;\ntypedef unsigned long  int     khronos_uintptr_t;\ntypedef signed   long  int     khronos_ssize_t;\ntypedef unsigned long  int     khronos_usize_t;\n#endif\n\n#if KHRONOS_SUPPORT_FLOAT\n/*\n * Float type\n */\ntypedef          float         khronos_float_t;\n#endif\n\n#if KHRONOS_SUPPORT_INT64\n/* Time types\n *\n * These types can be used to represent a time interval in nanoseconds or\n * an absolute Unadjusted System Time.  Unadjusted System Time is the number\n * of nanoseconds since some arbitrary system event (e.g. since the last\n * time the system booted).  The Unadjusted System Time is an unsigned\n * 64 bit value that wraps back to 0 every 584 years.  Time intervals\n * may be either signed or unsigned.\n */\ntypedef khronos_uint64_t       khronos_utime_nanoseconds_t;\ntypedef khronos_int64_t        khronos_stime_nanoseconds_t;\n#endif\n\n/*\n * Dummy value used to pad enum types to 32 bits.\n */\n#ifndef KHRONOS_MAX_ENUM\n#define KHRONOS_MAX_ENUM 0x7FFFFFFF\n#endif\n\n/*\n * Enumerated boolean type\n *\n * Values other than zero should be considered to be true.  Therefore\n * comparisons should not be made against KHRONOS_TRUE.\n */\ntypedef enum {\n    KHRONOS_FALSE = 0,\n    KHRONOS_TRUE  = 1,\n    KHRONOS_BOOLEAN_ENUM_FORCE_SIZE = KHRONOS_MAX_ENUM\n} khronos_boolean_enum_t;\n\n#endif /* __khrplatform_h_ */\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/SHA1/HMAC_SHA1.h",
    "content": "/*\r\n\t100% free public domain implementation of the HMAC-SHA1 algorithm\r\n\tby Chien-Chung, Chung (Jim Chung) <jimchung1221@gmail.com>\r\n*/\r\n\r\n\r\n#ifndef __HMAC_SHA1_H__\r\n#define __HMAC_SHA1_H__\r\n\r\n#include \"SHA1.h\"\r\n\r\ntypedef unsigned char BYTE ;\r\n\r\nclass CHMAC_SHA1 : public CSHA1\r\n{\r\n    private:\r\n\t\tBYTE m_ipad[64];\r\n        BYTE m_opad[64];\r\n\r\n\t\tchar * szReport ;\r\n\t\tchar * SHA1_Key ;\r\n\t\tchar * AppendBuf1 ;\r\n\t\tchar * AppendBuf2 ;\r\n\r\n\r\n\tpublic:\r\n\t\t\r\n\t\tenum {\r\n\t\t\tSHA1_DIGEST_LENGTH\t= 20,\r\n\t\t\tSHA1_BLOCK_SIZE\t\t= 64,\r\n\t\t\tHMAC_BUF_LEN\t\t= 4096\r\n\t\t} ;\r\n\r\n\t\tCHMAC_SHA1()\r\n\t\t\t:szReport(new char[HMAC_BUF_LEN]),\r\n             AppendBuf1(new char[HMAC_BUF_LEN]),\r\n             AppendBuf2(new char[HMAC_BUF_LEN]),\r\n             SHA1_Key(new char[HMAC_BUF_LEN])\r\n\t\t{}\r\n\r\n        ~CHMAC_SHA1()\r\n        {\r\n            delete[] szReport ;\r\n            delete[] AppendBuf1 ;\r\n            delete[] AppendBuf2 ;\r\n            delete[] SHA1_Key ;\r\n        }\r\n\r\n        void HMAC_SHA1(BYTE *text, int text_len, BYTE *key, int key_len, BYTE *digest);\r\n};\r\n\r\n\r\n#endif /* __HMAC_SHA1_H__ */\r\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/SHA1/SHA1.h",
    "content": "/*\r\n  100% free public domain implementation of the SHA-1 algorithm\r\n  by Dominik Reichl <dominik.reichl@t-online.de>\r\n  Web: http://www.dominik-reichl.de/\r\n\r\n  Version 2.1 - 2012-06-19\r\n  - Deconstructor (resetting internal variables) is now only\r\n    implemented if SHA1_WIPE_VARIABLES is defined (which is the\r\n    default).\r\n  - Renamed inclusion guard to contain a GUID.\r\n  - Demo application is now using C++/STL objects and functions.\r\n  - Unicode build of the demo application now outputs the hashes of both\r\n    the ANSI and Unicode representations of strings.\r\n  - Various other demo application improvements.\r\n\r\n  Version 2.0 - 2012-06-14\r\n  - Added 'limits.h' include.\r\n  - Renamed inclusion guard and macros for compliancy (names beginning\r\n    with an underscore are reserved).\r\n\r\n  Version 1.9 - 2011-11-10\r\n  - Added Unicode test vectors.\r\n  - Improved support for hashing files using the HashFile method that\r\n    are larger than 4 GB.\r\n  - Improved file hashing performance (by using a larger buffer).\r\n  - Disabled unnecessary compiler warnings.\r\n  - Internal variables are now private.\r\n\r\n  Version 1.8 - 2009-03-16\r\n  - Converted project files to Visual Studio 2008 format.\r\n  - Added Unicode support for HashFile utility method.\r\n  - Added support for hashing files using the HashFile method that are\r\n    larger than 2 GB.\r\n  - HashFile now returns an error code instead of copying an error\r\n    message into the output buffer.\r\n  - GetHash now returns an error code and validates the input parameter.\r\n  - Added ReportHashStl STL utility method.\r\n  - Added REPORT_HEX_SHORT reporting mode.\r\n  - Improved Linux compatibility of test program.\r\n\r\n  Version 1.7 - 2006-12-21\r\n  - Fixed buffer underrun warning that appeared when compiling with\r\n    Borland C Builder (thanks to Rex Bloom and Tim Gallagher for the\r\n    patch).\r\n  - Breaking change: ReportHash writes the final hash to the start\r\n    of the buffer, i.e. it's not appending it to the string anymore.\r\n  - Made some function parameters const.\r\n  - Added Visual Studio 2005 project files to demo project.\r\n\r\n  Version 1.6 - 2005-02-07 (thanks to Howard Kapustein for patches)\r\n  - You can set the endianness in your files, no need to modify the\r\n    header file of the CSHA1 class anymore.\r\n  - Aligned data support.\r\n  - Made support/compilation of the utility functions (ReportHash and\r\n    HashFile) optional (useful when bytes count, for example in embedded\r\n    environments).\r\n\r\n  Version 1.5 - 2005-01-01\r\n  - 64-bit compiler compatibility added.\r\n  - Made variable wiping optional (define SHA1_WIPE_VARIABLES).\r\n  - Removed unnecessary variable initializations.\r\n  - ROL32 improvement for the Microsoft compiler (using _rotl).\r\n\r\n  Version 1.4 - 2004-07-22\r\n  - CSHA1 now compiles fine with GCC 3.3 under Mac OS X (thanks to Larry\r\n    Hastings).\r\n\r\n  Version 1.3 - 2003-08-17\r\n  - Fixed a small memory bug and made a buffer array a class member to\r\n    ensure correct working when using multiple CSHA1 class instances at\r\n    one time.\r\n\r\n  Version 1.2 - 2002-11-16\r\n  - Borlands C++ compiler seems to have problems with string addition\r\n    using sprintf. Fixed the bug which caused the digest report function\r\n    not to work properly. CSHA1 is now Borland compatible.\r\n\r\n  Version 1.1 - 2002-10-11\r\n  - Removed two unnecessary header file includes and changed BOOL to\r\n    bool. Fixed some minor bugs in the web page contents.\r\n\r\n  Version 1.0 - 2002-06-20\r\n  - First official release.\r\n\r\n  ================ Test Vectors ================\r\n\r\n  SHA1(\"abc\" in ANSI) =\r\n    A9993E36 4706816A BA3E2571 7850C26C 9CD0D89D\r\n  SHA1(\"abc\" in Unicode LE) =\r\n    9F04F41A 84851416 2050E3D6 8C1A7ABB 441DC2B5\r\n\r\n  SHA1(\"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq\"\r\n    in ANSI) =\r\n    84983E44 1C3BD26E BAAE4AA1 F95129E5 E54670F1\r\n  SHA1(\"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq\"\r\n    in Unicode LE) =\r\n    51D7D876 9AC72C40 9C5B0E3F 69C60ADC 9A039014\r\n\r\n  SHA1(A million repetitions of \"a\" in ANSI) =\r\n    34AA973C D4C4DAA4 F61EEB2B DBAD2731 6534016F\r\n  SHA1(A million repetitions of \"a\" in Unicode LE) =\r\n    C4609560 A108A0C6 26AA7F2B 38A65566 739353C5\r\n*/\r\n\r\n#ifndef SHA1_H_A545E61D43E9404E8D736869AB3CBFE7\r\n#define SHA1_H_A545E61D43E9404E8D736869AB3CBFE7\r\n\r\n#if !defined(SHA1_UTILITY_FUNCTIONS) && !defined(SHA1_NO_UTILITY_FUNCTIONS)\r\n#define SHA1_UTILITY_FUNCTIONS\r\n#endif\r\n\r\n#if !defined(SHA1_STL_FUNCTIONS) && !defined(SHA1_NO_STL_FUNCTIONS)\r\n#define SHA1_STL_FUNCTIONS\r\n#if !defined(SHA1_UTILITY_FUNCTIONS)\r\n#error STL functions require SHA1_UTILITY_FUNCTIONS.\r\n#endif\r\n#endif\r\n\r\n#include <memory.h>\r\n#include <limits.h>\r\n\r\n#ifdef SHA1_UTILITY_FUNCTIONS\r\n#include <stdio.h>\r\n#include <string.h>\r\n#endif\r\n\r\n#ifdef SHA1_STL_FUNCTIONS\r\n#include <string>\r\n#endif\r\n\r\n#ifdef _MSC_VER\r\n#include <stdlib.h>\r\n#endif\r\n\r\n// You can define the endian mode in your files without modifying the SHA-1\r\n// source files. Just #define SHA1_LITTLE_ENDIAN or #define SHA1_BIG_ENDIAN\r\n// in your files, before including the SHA1.h header file. If you don't\r\n// define anything, the class defaults to little endian.\r\n#if !defined(SHA1_LITTLE_ENDIAN) && !defined(SHA1_BIG_ENDIAN)\r\n#define SHA1_LITTLE_ENDIAN\r\n#endif\r\n\r\n// If you want variable wiping, #define SHA1_WIPE_VARIABLES, if not,\r\n// #define SHA1_NO_WIPE_VARIABLES. If you don't define anything, it\r\n// defaults to wiping.\r\n#if !defined(SHA1_WIPE_VARIABLES) && !defined(SHA1_NO_WIPE_VARIABLES)\r\n#define SHA1_WIPE_VARIABLES\r\n#endif\r\n\r\n#if defined(SHA1_HAS_TCHAR)\r\n#include <tchar.h>\r\n#else\r\n#ifdef _MSC_VER\r\n#include <tchar.h>\r\n#else\r\n#ifndef TCHAR\r\n#define TCHAR char\r\n#endif\r\n#ifndef _T\r\n#define _T(__x) (__x)\r\n#define _tmain main\r\n#define _tprintf printf\r\n#define _getts gets\r\n#define _tcslen strlen\r\n#define _tfopen fopen\r\n#define _tcscpy strcpy\r\n#define _tcscat strcat\r\n#define _sntprintf snprintf\r\n#endif\r\n#endif\r\n#endif\r\n\r\n///////////////////////////////////////////////////////////////////////////\r\n// Define variable types\r\n\r\n#ifndef UINT_8\r\n#ifdef _MSC_VER // Compiling with Microsoft compiler\r\n#define UINT_8 unsigned __int8\r\n#else // !_MSC_VER\r\n#define UINT_8 unsigned char\r\n#endif // _MSC_VER\r\n#endif\r\n\r\n#ifndef UINT_32\r\n#ifdef _MSC_VER // Compiling with Microsoft compiler\r\n#define UINT_32 unsigned __int32\r\n#else // !_MSC_VER\r\n#if (ULONG_MAX == 0xFFFFFFFFUL)\r\n#define UINT_32 unsigned long\r\n#else\r\n#define UINT_32 unsigned int\r\n#endif\r\n#endif // _MSC_VER\r\n#endif // UINT_32\r\n\r\n#ifndef INT_64\r\n#ifdef _MSC_VER // Compiling with Microsoft compiler\r\n#define INT_64 __int64\r\n#else // !_MSC_VER\r\n#define INT_64 long long\r\n#endif // _MSC_VER\r\n#endif // INT_64\r\n\r\n#ifndef UINT_64\r\n#ifdef _MSC_VER // Compiling with Microsoft compiler\r\n#define UINT_64 unsigned __int64\r\n#else // !_MSC_VER\r\n#define UINT_64 unsigned long long\r\n#endif // _MSC_VER\r\n#endif // UINT_64\r\n\r\n///////////////////////////////////////////////////////////////////////////\r\n// Declare SHA-1 workspace\r\n\r\ntypedef union\r\n{\r\n\tUINT_8 c[64];\r\n\tUINT_32 l[16];\r\n} SHA1_WORKSPACE_BLOCK;\r\n\r\nclass CSHA1\r\n{\r\npublic:\r\n#ifdef SHA1_UTILITY_FUNCTIONS\r\n\t// Different formats for ReportHash(Stl)\r\n\tenum REPORT_TYPE\r\n\t{\r\n\t\tREPORT_HEX = 0,\r\n\t\tREPORT_DIGIT = 1,\r\n\t\tREPORT_HEX_SHORT = 2\r\n\t};\r\n#endif\r\n\r\n\t// Constructor and destructor\r\n\tCSHA1();\r\n\r\n#ifdef SHA1_WIPE_VARIABLES\r\n\t~CSHA1();\r\n#endif\r\n\r\n\tvoid Reset();\r\n\r\n\t// Hash in binary data and strings\r\n\tvoid Update(const UINT_8* pbData, UINT_32 uLen);\r\n\r\n#ifdef SHA1_UTILITY_FUNCTIONS\r\n\t// Hash in file contents\r\n\tbool HashFile(const TCHAR* tszFileName);\r\n#endif\r\n\r\n\t// Finalize hash; call it before using ReportHash(Stl)\r\n\tvoid Final();\r\n\r\n#ifdef SHA1_UTILITY_FUNCTIONS\r\n\tbool ReportHash(TCHAR* tszReport, REPORT_TYPE rtReportType = REPORT_HEX) const;\r\n#endif\r\n\r\n#ifdef SHA1_STL_FUNCTIONS\r\n\tbool ReportHashStl(std::basic_string<TCHAR>& strOut, REPORT_TYPE rtReportType =\r\n\t\tREPORT_HEX) const;\r\n#endif\r\n\r\n\t// Get the raw message digest (20 bytes)\r\n\tbool GetHash(UINT_8* pbDest20) const;\r\n\r\nprivate:\r\n\t// Private SHA-1 transformation\r\n\tvoid Transform(UINT_32* pState, const UINT_8* pBuffer);\r\n\r\n\t// Member variables\r\n\tUINT_32 m_state[5];\r\n\tUINT_32 m_count[2];\r\n\tUINT_32 m_reserved0[1]; // Memory alignment padding\r\n\tUINT_8 m_buffer[64];\r\n\tUINT_8 m_digest[20];\r\n\tUINT_32 m_reserved1[3]; // Memory alignment padding\r\n\r\n\tUINT_8 m_workspace[64];\r\n\tSHA1_WORKSPACE_BLOCK* m_block; // SHA1 pointer to the byte array above\r\n};\r\n\r\n#endif // SHA1_H_A545E61D43E9404E8D736869AB3CBFE7\r\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/SHA256/sha256.h",
    "content": "// //////////////////////////////////////////////////////////\n// sha256.h\n// Copyright (c) 2014,2015 Stephan Brumme. All rights reserved.\n// see http://create.stephan-brumme.com/disclaimer.html\n//\n\n#pragma once\n\n//#include \"hash.h\"\n#include <string>\n\n// define fixed size integer types\n#ifdef _MSC_VER\n// Windows\ntypedef unsigned __int8  uint8_t;\ntypedef unsigned __int32 uint32_t;\ntypedef unsigned __int64 uint64_t;\n#else\n// GCC\n#include <stdint.h>\n#endif\n\n\n/// compute SHA256 hash\n/** Usage:\n    SHA256 sha256;\n    std::string myHash  = sha256(\"Hello World\");     // std::string\n    std::string myHash2 = sha256(\"How are you\", 11); // arbitrary data, 11 bytes\n\n    // or in a streaming fashion:\n\n    SHA256 sha256;\n    while (more data available)\n      sha256.add(pointer to fresh data, number of new bytes);\n    std::string myHash3 = sha256.getHash();\n  */\nclass SHA256 //: public Hash\n{\npublic:\n  /// split into 64 byte blocks (=> 512 bits), hash is 32 bytes long\n  enum { BlockSize = 512 / 8, HashBytes = 32 };\n\n  /// same as reset()\n  SHA256();\n\n  /// compute SHA256 of a memory block\n  std::string operator()(const void* data, size_t numBytes);\n  /// compute SHA256 of a string, excluding final zero\n  std::string operator()(const std::string& text);\n\n  /// add arbitrary number of bytes\n  void add(const void* data, size_t numBytes);\n\n  /// return latest hash as 64 hex characters\n  std::string getHash();\n  /// return latest hash as bytes\n  void        getHash(unsigned char buffer[HashBytes]);\n\n  /// restart\n  void reset();\n\nprivate:\n  /// process 64 bytes\n  void processBlock(const void* data);\n  /// process everything left in the internal buffer\n  void processBuffer();\n\n  /// size of processed data in bytes\n  uint64_t m_numBytes;\n  /// valid bytes in m_buffer\n  size_t   m_bufferSize;\n  /// bytes not processed yet\n  uint8_t  m_buffer[BlockSize];\n\n  enum { HashValues = HashBytes / 4 };\n  /// hash, stored as integers\n  uint32_t m_hash[HashValues];\n};\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/X11/DECkeysym.h",
    "content": "/***********************************************************\n\nCopyright 1988, 1998  The Open Group\n\nPermission to use, copy, modify, distribute, and sell this software and its\ndocumentation for any purpose is hereby granted without fee, provided that\nthe above copyright notice appear in all copies and that both that\ncopyright notice and this permission notice appear in supporting\ndocumentation.\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE\nOPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN\nAN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\nCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\nExcept as contained in this notice, the name of The Open Group shall not be\nused in advertising or otherwise to promote the sale, use or other dealings\nin this Software without prior written authorization from The Open Group.\n\n\nCopyright 1988 by Digital Equipment Corporation, Maynard, Massachusetts.\n\n                        All Rights Reserved\n\nPermission to use, copy, modify, and distribute this software and its \ndocumentation for any purpose and without fee is hereby granted, \nprovided that the above copyright notice appear in all copies and that\nboth that copyright notice and this permission notice appear in \nsupporting documentation, and that the name of Digital not be\nused in advertising or publicity pertaining to distribution of the\nsoftware without specific, written prior permission.  \n\nDIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING\nALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL\nDIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR\nANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,\nWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,\nARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS\nSOFTWARE.\n\n******************************************************************/\n\n/*\n * DEC private keysyms\n * (29th bit set)\n */\n\n/* two-key compose sequence initiators, chosen to map to Latin1 characters */\n\n#define DXK_ring_accent         0x1000FEB0\n#define DXK_circumflex_accent   0x1000FE5E\n#define DXK_cedilla_accent      0x1000FE2C\n#define DXK_acute_accent        0x1000FE27\n#define DXK_grave_accent        0x1000FE60\n#define DXK_tilde               0x1000FE7E\n#define DXK_diaeresis           0x1000FE22\n\n/* special keysym for LK2** \"Remove\" key on editing keypad */\n\n#define DXK_Remove\t0x1000FF00   /* Remove */\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/X11/HPkeysym.h",
    "content": "/*\n\nCopyright 1987, 1998  The Open Group\n\nPermission to use, copy, modify, distribute, and sell this software and its\ndocumentation for any purpose is hereby granted without fee, provided that\nthe above copyright notice appear in all copies and that both that\ncopyright notice and this permission notice appear in supporting\ndocumentation.\n\nThe above copyright notice and this permission notice shall be included\nin all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\nOR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR\nOTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,\nARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\nOTHER DEALINGS IN THE SOFTWARE.\n\nExcept as contained in this notice, the name of The Open Group shall\nnot be used in advertising or otherwise to promote the sale, use or\nother dealings in this Software without prior written authorization\nfrom The Open Group.\n\nCopyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,\n\n                        All Rights Reserved\n\nPermission to use, copy, modify, and distribute this software and its\ndocumentation for any purpose and without fee is hereby granted,\nprovided that the above copyright notice appear in all copies and that\nboth that copyright notice and this permission notice appear in\nsupporting documentation, and that the names of Hewlett Packard\nor Digital not be\nused in advertising or publicity pertaining to distribution of the\nsoftware without specific, written prior permission.\n\nDIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING\nALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL\nDIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR\nANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,\nWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,\nARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS\nSOFTWARE.\n\nHEWLETT-PACKARD MAKES NO WARRANTY OF ANY KIND WITH REGARD\nTO THIS SOFWARE, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\nPURPOSE.  Hewlett-Packard shall not be liable for errors\ncontained herein or direct, indirect, special, incidental or\nconsequential damages in connection with the furnishing,\nperformance, or use of this material.\n\n*/\n\n#ifndef _HPKEYSYM_H\n\n#define _HPKEYSYM_H\n\n#define hpXK_ClearLine\t\t0x1000FF6F\n#define hpXK_InsertLine\t\t0x1000FF70\n#define hpXK_DeleteLine\t\t0x1000FF71\n#define hpXK_InsertChar\t\t0x1000FF72\n#define hpXK_DeleteChar\t\t0x1000FF73\n#define hpXK_BackTab\t\t0x1000FF74\n#define hpXK_KP_BackTab\t\t0x1000FF75\n#define hpXK_Modelock1\t\t0x1000FF48\n#define hpXK_Modelock2\t\t0x1000FF49\n#define hpXK_Reset\t\t0x1000FF6C\n#define hpXK_System\t\t0x1000FF6D\n#define hpXK_User\t\t0x1000FF6E\n#define hpXK_mute_acute\t\t0x100000A8\n#define hpXK_mute_grave\t\t0x100000A9\n#define hpXK_mute_asciicircum\t0x100000AA\n#define hpXK_mute_diaeresis\t0x100000AB\n#define hpXK_mute_asciitilde\t0x100000AC\n#define hpXK_lira\t\t0x100000AF\n#define hpXK_guilder\t\t0x100000BE\n#define hpXK_Ydiaeresis\t\t0x100000EE\n#define hpXK_IO\t\t\t0x100000EE\n#define hpXK_longminus\t\t0x100000F6\n#define hpXK_block\t\t0x100000FC\n\n\n#ifndef _OSF_Keysyms\n#define _OSF_Keysyms\n\n#define osfXK_Copy\t\t0x1004FF02\n#define osfXK_Cut\t\t0x1004FF03\n#define osfXK_Paste\t\t0x1004FF04\n#define osfXK_BackTab\t\t0x1004FF07\n#define osfXK_BackSpace\t\t0x1004FF08\n#define osfXK_Clear\t\t0x1004FF0B\n#define osfXK_Escape\t\t0x1004FF1B\n#define osfXK_AddMode\t\t0x1004FF31\n#define osfXK_PrimaryPaste\t0x1004FF32\n#define osfXK_QuickPaste\t0x1004FF33\n#define osfXK_PageLeft\t\t0x1004FF40\n#define osfXK_PageUp\t\t0x1004FF41\n#define osfXK_PageDown\t\t0x1004FF42\n#define osfXK_PageRight\t\t0x1004FF43\n#define osfXK_Activate\t\t0x1004FF44\n#define osfXK_MenuBar\t\t0x1004FF45\n#define osfXK_Left\t\t0x1004FF51\n#define osfXK_Up\t\t0x1004FF52\n#define osfXK_Right\t\t0x1004FF53\n#define osfXK_Down\t\t0x1004FF54\n#define osfXK_EndLine\t\t0x1004FF57\n#define osfXK_BeginLine\t\t0x1004FF58\n#define osfXK_EndData\t\t0x1004FF59\n#define osfXK_BeginData\t\t0x1004FF5A\n#define osfXK_PrevMenu\t\t0x1004FF5B\n#define osfXK_NextMenu\t\t0x1004FF5C\n#define osfXK_PrevField\t\t0x1004FF5D\n#define osfXK_NextField\t\t0x1004FF5E\n#define osfXK_Select\t\t0x1004FF60\n#define osfXK_Insert\t\t0x1004FF63\n#define osfXK_Undo\t\t0x1004FF65\n#define osfXK_Menu\t\t0x1004FF67\n#define osfXK_Cancel\t\t0x1004FF69\n#define osfXK_Help\t\t0x1004FF6A\n#define osfXK_SelectAll\t\t0x1004FF71\n#define osfXK_DeselectAll\t0x1004FF72\n#define osfXK_Reselect\t\t0x1004FF73\n#define osfXK_Extend\t\t0x1004FF74\n#define osfXK_Restore\t\t0x1004FF78\n#define osfXK_Delete\t\t0x1004FFFF\n\n#endif /* _OSF_Keysyms */\n\n\n/**************************************************************\n * The use of the following macros is deprecated.\n * They are listed below only for backwards compatibility.\n */\n#define XK_Reset                0x1000FF6C\n#define XK_System               0x1000FF6D\n#define XK_User                 0x1000FF6E\n#define XK_ClearLine            0x1000FF6F\n#define XK_InsertLine           0x1000FF70\n#define XK_DeleteLine           0x1000FF71\n#define XK_InsertChar           0x1000FF72\n#define XK_DeleteChar           0x1000FF73\n#define XK_BackTab              0x1000FF74\n#define XK_KP_BackTab           0x1000FF75\n#define XK_Ext16bit_L           0x1000FF76\n#define XK_Ext16bit_R           0x1000FF77\n#define XK_mute_acute           0x100000a8\n#define XK_mute_grave           0x100000a9\n#define XK_mute_asciicircum     0x100000aa\n#define XK_mute_diaeresis       0x100000ab\n#define XK_mute_asciitilde      0x100000ac\n#define XK_lira                 0x100000af\n#define XK_guilder              0x100000be\n#ifndef XK_Ydiaeresis\n#define XK_Ydiaeresis           0x100000ee\n#endif\n#define XK_IO                   0x100000ee\n#define XK_longminus            0x100000f6\n#define XK_block                0x100000fc\n\n#endif /* _HPKEYSYM_H */\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/X11/ImUtil.h",
    "content": "\n#ifndef _X11_IMUTIL_H_\n#define _X11_IMUTIL_H_\n\nextern int\n_XGetScanlinePad(\n    Display *dpy,\n    int depth);\n\nextern int\n_XGetBitsPerPixel(\n Display *dpy,\n int depth);\n\nextern int\n_XSetImage(\n    XImage *srcimg,\n    register XImage *dstimg,\n    register int x,\n    register int y);\n\nextern int\n_XReverse_Bytes(\n    register unsigned char *bpt,\n    register int nb);\nextern void\n_XInitImageFuncPtrs(\n    register XImage *image);\n\n#endif /* _X11_IMUTIL_H_ */\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/X11/Sunkeysym.h",
    "content": "/*\n * Copyright (c) 1991, Oracle and/or its affiliates. All rights reserved.\n *\n * Permission is hereby granted, free of charge, to any person obtaining a\n * copy of this software and associated documentation files (the \"Software\"),\n * to deal in the Software without restriction, including without limitation\n * the rights to use, copy, modify, merge, publish, distribute, sublicense,\n * and/or sell copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice (including the next\n * paragraph) shall be included in all copies or substantial portions of the\n * Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL\n * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n * DEALINGS IN THE SOFTWARE.\n */\n/************************************************************\n\nCopyright 1991, 1998  The Open Group\n\nPermission to use, copy, modify, distribute, and sell this software and its\ndocumentation for any purpose is hereby granted without fee, provided that\nthe above copyright notice appear in all copies and that both that\ncopyright notice and this permission notice appear in supporting\ndocumentation.\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE\nOPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN\nAN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\nCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\nExcept as contained in this notice, the name of The Open Group shall not be\nused in advertising or otherwise to promote the sale, use or other dealings\nin this Software without prior written authorization from The Open Group.\n\n***********************************************************/\n\n/*\n * Floating Accent\n */\n\n#define\tSunXK_FA_Grave\t\t0x1005FF00\n#define\tSunXK_FA_Circum\t\t0x1005FF01\n#define\tSunXK_FA_Tilde\t\t0x1005FF02\n#define\tSunXK_FA_Acute\t\t0x1005FF03\n#define\tSunXK_FA_Diaeresis\t0x1005FF04\n#define\tSunXK_FA_Cedilla\t0x1005FF05\n\n/*\n * Miscellaneous Functions\n */\n\n#define\tSunXK_F36\t\t0x1005FF10\t/* Labeled F11 */\n#define\tSunXK_F37\t\t0x1005FF11\t/* Labeled F12 */\n\n#define SunXK_Sys_Req   \t0x1005FF60\n#define SunXK_Print_Screen\t0x0000FF61\t/* Same as XK_Print */\n\n/*\n * International & Multi-Key Character Composition\n */\n\n#define SunXK_Compose\t\t0x0000FF20\t/* Same as XK_Multi_key */\n#define SunXK_AltGraph\t\t0x0000FF7E\t/* Same as XK_Mode_switch */\n\n/*\n * Cursor Control\n */\n\n#define SunXK_PageUp\t\t0x0000FF55 \t/* Same as XK_Prior */\n#define SunXK_PageDown\t\t0x0000FF56\t/* Same as XK_Next */\n\n/*\n * Open Look Functions\n */\n\n#define SunXK_Undo\t\t0x0000FF65\t/* Same as XK_Undo */\n#define SunXK_Again\t\t0x0000FF66\t/* Same as XK_Redo */\n#define SunXK_Find\t\t0x0000FF68\t/* Same as XK_Find */\n#define SunXK_Stop\t\t0x0000FF69\t/* Same as XK_Cancel */\n#define SunXK_Props\t\t0x1005FF70\n#define SunXK_Front\t\t0x1005FF71\n#define SunXK_Copy\t\t0x1005FF72\n#define SunXK_Open\t\t0x1005FF73\n#define SunXK_Paste\t\t0x1005FF74\n#define SunXK_Cut\t\t0x1005FF75\n\n#define SunXK_PowerSwitch\t\t0x1005FF76\n#define SunXK_AudioLowerVolume\t\t0x1005FF77\n#define SunXK_AudioMute\t\t\t0x1005FF78\n#define SunXK_AudioRaiseVolume\t\t0x1005FF79\n#define SunXK_VideoDegauss\t\t0x1005FF7A\n#define SunXK_VideoLowerBrightness\t0x1005FF7B\n#define SunXK_VideoRaiseBrightness\t0x1005FF7C\n#define SunXK_PowerSwitchShift\t\t0x1005FF7D\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/X11/X.h",
    "content": "/* Definitions for the X window system likely to be used by applications */\n\n#ifndef X_H\n#define X_H\n\n/***********************************************************\n\nCopyright 1987, 1998  The Open Group\n\nPermission to use, copy, modify, distribute, and sell this software and its\ndocumentation for any purpose is hereby granted without fee, provided that\nthe above copyright notice appear in all copies and that both that\ncopyright notice and this permission notice appear in supporting\ndocumentation.\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE\nOPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN\nAN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\nCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\nExcept as contained in this notice, the name of The Open Group shall not be\nused in advertising or otherwise to promote the sale, use or other dealings\nin this Software without prior written authorization from The Open Group.\n\n\nCopyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.\n\n                        All Rights Reserved\n\nPermission to use, copy, modify, and distribute this software and its \ndocumentation for any purpose and without fee is hereby granted, \nprovided that the above copyright notice appear in all copies and that\nboth that copyright notice and this permission notice appear in \nsupporting documentation, and that the name of Digital not be\nused in advertising or publicity pertaining to distribution of the\nsoftware without specific, written prior permission.  \n\nDIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING\nALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL\nDIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR\nANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,\nWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,\nARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS\nSOFTWARE.\n\n******************************************************************/\n\n#define X_PROTOCOL\t11\t\t/* current protocol version */\n#define X_PROTOCOL_REVISION 0\t\t/* current minor version */\n\n/* Resources */\n\n/*\n * _XSERVER64 must ONLY be defined when compiling X server sources on\n * systems where unsigned long is not 32 bits, must NOT be used in\n * client or library code.\n */\n#ifndef _XSERVER64\n#  ifndef _XTYPEDEF_XID\n#    define _XTYPEDEF_XID\ntypedef unsigned long XID;\n#  endif\n#  ifndef _XTYPEDEF_MASK\n#    define _XTYPEDEF_MASK\ntypedef unsigned long Mask;\n#  endif\n#  ifndef _XTYPEDEF_ATOM\n#    define _XTYPEDEF_ATOM\ntypedef unsigned long Atom;\t\t/* Also in Xdefs.h */\n#  endif\ntypedef unsigned long VisualID;\ntypedef unsigned long Time;\n#else\n#  include <X11/Xmd.h>\n#  ifndef _XTYPEDEF_XID\n#    define _XTYPEDEF_XID\ntypedef CARD32 XID;\n#  endif\n#  ifndef _XTYPEDEF_MASK\n#    define _XTYPEDEF_MASK\ntypedef CARD32 Mask;\n#  endif\n#  ifndef _XTYPEDEF_ATOM\n#    define _XTYPEDEF_ATOM\ntypedef CARD32 Atom;\n#  endif\ntypedef CARD32 VisualID;\ntypedef CARD32 Time;\n#endif\n\ntypedef XID Window;\ntypedef XID Drawable;\n#ifndef _XTYPEDEF_FONT\n#  define _XTYPEDEF_FONT\ntypedef XID Font;\n#endif\ntypedef XID Pixmap;\ntypedef XID Cursor;\ntypedef XID Colormap;\ntypedef XID GContext;\ntypedef XID KeySym;\n\ntypedef unsigned char KeyCode;\n\n/*****************************************************************\n * RESERVED RESOURCE AND CONSTANT DEFINITIONS\n *****************************************************************/\n\n#ifndef None\n#define None                 0L\t/* universal null resource or null atom */\n#endif\n\n#define ParentRelative       1L\t/* background pixmap in CreateWindow\n\t\t\t\t    and ChangeWindowAttributes */\n\n#define CopyFromParent       0L\t/* border pixmap in CreateWindow\n\t\t\t\t       and ChangeWindowAttributes\n\t\t\t\t   special VisualID and special window\n\t\t\t\t       class passed to CreateWindow */\n\n#define PointerWindow        0L\t/* destination window in SendEvent */\n#define InputFocus           1L\t/* destination window in SendEvent */\n\n#define PointerRoot          1L\t/* focus window in SetInputFocus */\n\n#define AnyPropertyType      0L\t/* special Atom, passed to GetProperty */\n\n#define AnyKey\t\t     0L\t/* special Key Code, passed to GrabKey */\n\n#define AnyButton            0L\t/* special Button Code, passed to GrabButton */\n\n#define AllTemporary         0L\t/* special Resource ID passed to KillClient */\n\n#define CurrentTime          0L\t/* special Time */\n\n#define NoSymbol\t     0L\t/* special KeySym */\n\n/***************************************************************** \n * EVENT DEFINITIONS \n *****************************************************************/\n\n/* Input Event Masks. Used as event-mask window attribute and as arguments\n   to Grab requests.  Not to be confused with event names.  */\n\n#define NoEventMask\t\t\t0L\n#define KeyPressMask\t\t\t(1L<<0)  \n#define KeyReleaseMask\t\t\t(1L<<1)  \n#define ButtonPressMask\t\t\t(1L<<2)  \n#define ButtonReleaseMask\t\t(1L<<3)  \n#define EnterWindowMask\t\t\t(1L<<4)  \n#define LeaveWindowMask\t\t\t(1L<<5)  \n#define PointerMotionMask\t\t(1L<<6)  \n#define PointerMotionHintMask\t\t(1L<<7)  \n#define Button1MotionMask\t\t(1L<<8)  \n#define Button2MotionMask\t\t(1L<<9)  \n#define Button3MotionMask\t\t(1L<<10) \n#define Button4MotionMask\t\t(1L<<11) \n#define Button5MotionMask\t\t(1L<<12) \n#define ButtonMotionMask\t\t(1L<<13) \n#define KeymapStateMask\t\t\t(1L<<14)\n#define ExposureMask\t\t\t(1L<<15) \n#define VisibilityChangeMask\t\t(1L<<16) \n#define StructureNotifyMask\t\t(1L<<17) \n#define ResizeRedirectMask\t\t(1L<<18) \n#define SubstructureNotifyMask\t\t(1L<<19) \n#define SubstructureRedirectMask\t(1L<<20) \n#define FocusChangeMask\t\t\t(1L<<21) \n#define PropertyChangeMask\t\t(1L<<22) \n#define ColormapChangeMask\t\t(1L<<23) \n#define OwnerGrabButtonMask\t\t(1L<<24) \n\n/* Event names.  Used in \"type\" field in XEvent structures.  Not to be\nconfused with event masks above.  They start from 2 because 0 and 1\nare reserved in the protocol for errors and replies. */\n\n#define KeyPress\t\t2\n#define KeyRelease\t\t3\n#define ButtonPress\t\t4\n#define ButtonRelease\t\t5\n#define MotionNotify\t\t6\n#define EnterNotify\t\t7\n#define LeaveNotify\t\t8\n#define FocusIn\t\t\t9\n#define FocusOut\t\t10\n#define KeymapNotify\t\t11\n#define Expose\t\t\t12\n#define GraphicsExpose\t\t13\n#define NoExpose\t\t14\n#define VisibilityNotify\t15\n#define CreateNotify\t\t16\n#define DestroyNotify\t\t17\n#define UnmapNotify\t\t18\n#define MapNotify\t\t19\n#define MapRequest\t\t20\n#define ReparentNotify\t\t21\n#define ConfigureNotify\t\t22\n#define ConfigureRequest\t23\n#define GravityNotify\t\t24\n#define ResizeRequest\t\t25\n#define CirculateNotify\t\t26\n#define CirculateRequest\t27\n#define PropertyNotify\t\t28\n#define SelectionClear\t\t29\n#define SelectionRequest\t30\n#define SelectionNotify\t\t31\n#define ColormapNotify\t\t32\n#define ClientMessage\t\t33\n#define MappingNotify\t\t34\n#define GenericEvent\t\t35\n#define LASTEvent\t\t36\t/* must be bigger than any event # */\n\n\n/* Key masks. Used as modifiers to GrabButton and GrabKey, results of QueryPointer,\n   state in various key-, mouse-, and button-related events. */\n\n#define ShiftMask\t\t(1<<0)\n#define LockMask\t\t(1<<1)\n#define ControlMask\t\t(1<<2)\n#define Mod1Mask\t\t(1<<3)\n#define Mod2Mask\t\t(1<<4)\n#define Mod3Mask\t\t(1<<5)\n#define Mod4Mask\t\t(1<<6)\n#define Mod5Mask\t\t(1<<7)\n\n/* modifier names.  Used to build a SetModifierMapping request or\n   to read a GetModifierMapping request.  These correspond to the\n   masks defined above. */\n#define ShiftMapIndex\t\t0\n#define LockMapIndex\t\t1\n#define ControlMapIndex\t\t2\n#define Mod1MapIndex\t\t3\n#define Mod2MapIndex\t\t4\n#define Mod3MapIndex\t\t5\n#define Mod4MapIndex\t\t6\n#define Mod5MapIndex\t\t7\n\n\n/* button masks.  Used in same manner as Key masks above. Not to be confused\n   with button names below. */\n\n#define Button1Mask\t\t(1<<8)\n#define Button2Mask\t\t(1<<9)\n#define Button3Mask\t\t(1<<10)\n#define Button4Mask\t\t(1<<11)\n#define Button5Mask\t\t(1<<12)\n\n#define AnyModifier\t\t(1<<15)  /* used in GrabButton, GrabKey */\n\n\n/* button names. Used as arguments to GrabButton and as detail in ButtonPress\n   and ButtonRelease events.  Not to be confused with button masks above.\n   Note that 0 is already defined above as \"AnyButton\".  */\n\n#define Button1\t\t\t1\n#define Button2\t\t\t2\n#define Button3\t\t\t3\n#define Button4\t\t\t4\n#define Button5\t\t\t5\n\n/* Notify modes */\n\n#define NotifyNormal\t\t0\n#define NotifyGrab\t\t1\n#define NotifyUngrab\t\t2\n#define NotifyWhileGrabbed\t3\n\n#define NotifyHint\t\t1\t/* for MotionNotify events */\n\t\t       \n/* Notify detail */\n\n#define NotifyAncestor\t\t0\n#define NotifyVirtual\t\t1\n#define NotifyInferior\t\t2\n#define NotifyNonlinear\t\t3\n#define NotifyNonlinearVirtual\t4\n#define NotifyPointer\t\t5\n#define NotifyPointerRoot\t6\n#define NotifyDetailNone\t7\n\n/* Visibility notify */\n\n#define VisibilityUnobscured\t\t0\n#define VisibilityPartiallyObscured\t1\n#define VisibilityFullyObscured\t\t2\n\n/* Circulation request */\n\n#define PlaceOnTop\t\t0\n#define PlaceOnBottom\t\t1\n\n/* protocol families */\n\n#define FamilyInternet\t\t0\t/* IPv4 */\n#define FamilyDECnet\t\t1\n#define FamilyChaos\t\t2\n#define FamilyInternet6\t\t6\t/* IPv6 */\n\n/* authentication families not tied to a specific protocol */\n#define FamilyServerInterpreted 5\n\n/* Property notification */\n\n#define PropertyNewValue\t0\n#define PropertyDelete\t\t1\n\n/* Color Map notification */\n\n#define ColormapUninstalled\t0\n#define ColormapInstalled\t1\n\n/* GrabPointer, GrabButton, GrabKeyboard, GrabKey Modes */\n\n#define GrabModeSync\t\t0\n#define GrabModeAsync\t\t1\n\n/* GrabPointer, GrabKeyboard reply status */\n\n#define GrabSuccess\t\t0\n#define AlreadyGrabbed\t\t1\n#define GrabInvalidTime\t\t2\n#define GrabNotViewable\t\t3\n#define GrabFrozen\t\t4\n\n/* AllowEvents modes */\n\n#define AsyncPointer\t\t0\n#define SyncPointer\t\t1\n#define ReplayPointer\t\t2\n#define AsyncKeyboard\t\t3\n#define SyncKeyboard\t\t4\n#define ReplayKeyboard\t\t5\n#define AsyncBoth\t\t6\n#define SyncBoth\t\t7\n\n/* Used in SetInputFocus, GetInputFocus */\n\n#define RevertToNone\t\t(int)None\n#define RevertToPointerRoot\t(int)PointerRoot\n#define RevertToParent\t\t2\n\n/*****************************************************************\n * ERROR CODES \n *****************************************************************/\n\n#define Success\t\t   0\t/* everything's okay */\n#define BadRequest\t   1\t/* bad request code */\n#define BadValue\t   2\t/* int parameter out of range */\n#define BadWindow\t   3\t/* parameter not a Window */\n#define BadPixmap\t   4\t/* parameter not a Pixmap */\n#define BadAtom\t\t   5\t/* parameter not an Atom */\n#define BadCursor\t   6\t/* parameter not a Cursor */\n#define BadFont\t\t   7\t/* parameter not a Font */\n#define BadMatch\t   8\t/* parameter mismatch */\n#define BadDrawable\t   9\t/* parameter not a Pixmap or Window */\n#define BadAccess\t  10\t/* depending on context:\n\t\t\t\t - key/button already grabbed\n\t\t\t\t - attempt to free an illegal \n\t\t\t\t   cmap entry \n\t\t\t\t- attempt to store into a read-only \n\t\t\t\t   color map entry.\n \t\t\t\t- attempt to modify the access control\n\t\t\t\t   list from other than the local host.\n\t\t\t\t*/\n#define BadAlloc\t  11\t/* insufficient resources */\n#define BadColor\t  12\t/* no such colormap */\n#define BadGC\t\t  13\t/* parameter not a GC */\n#define BadIDChoice\t  14\t/* choice not in range or already used */\n#define BadName\t\t  15\t/* font or color name doesn't exist */\n#define BadLength\t  16\t/* Request length incorrect */\n#define BadImplementation 17\t/* server is defective */\n\n#define FirstExtensionError\t128\n#define LastExtensionError\t255\n\n/*****************************************************************\n * WINDOW DEFINITIONS \n *****************************************************************/\n\n/* Window classes used by CreateWindow */\n/* Note that CopyFromParent is already defined as 0 above */\n\n#define InputOutput\t\t1\n#define InputOnly\t\t2\n\n/* Window attributes for CreateWindow and ChangeWindowAttributes */\n\n#define CWBackPixmap\t\t(1L<<0)\n#define CWBackPixel\t\t(1L<<1)\n#define CWBorderPixmap\t\t(1L<<2)\n#define CWBorderPixel           (1L<<3)\n#define CWBitGravity\t\t(1L<<4)\n#define CWWinGravity\t\t(1L<<5)\n#define CWBackingStore          (1L<<6)\n#define CWBackingPlanes\t        (1L<<7)\n#define CWBackingPixel\t        (1L<<8)\n#define CWOverrideRedirect\t(1L<<9)\n#define CWSaveUnder\t\t(1L<<10)\n#define CWEventMask\t\t(1L<<11)\n#define CWDontPropagate\t        (1L<<12)\n#define CWColormap\t\t(1L<<13)\n#define CWCursor\t        (1L<<14)\n\n/* ConfigureWindow structure */\n\n#define CWX\t\t\t(1<<0)\n#define CWY\t\t\t(1<<1)\n#define CWWidth\t\t\t(1<<2)\n#define CWHeight\t\t(1<<3)\n#define CWBorderWidth\t\t(1<<4)\n#define CWSibling\t\t(1<<5)\n#define CWStackMode\t\t(1<<6)\n\n\n/* Bit Gravity */\n\n#define ForgetGravity\t\t0\n#define NorthWestGravity\t1\n#define NorthGravity\t\t2\n#define NorthEastGravity\t3\n#define WestGravity\t\t4\n#define CenterGravity\t\t5\n#define EastGravity\t\t6\n#define SouthWestGravity\t7\n#define SouthGravity\t\t8\n#define SouthEastGravity\t9\n#define StaticGravity\t\t10\n\n/* Window gravity + bit gravity above */\n\n#define UnmapGravity\t\t0\n\n/* Used in CreateWindow for backing-store hint */\n\n#define NotUseful               0\n#define WhenMapped              1\n#define Always                  2\n\n/* Used in GetWindowAttributes reply */\n\n#define IsUnmapped\t\t0\n#define IsUnviewable\t\t1\n#define IsViewable\t\t2\n\n/* Used in ChangeSaveSet */\n\n#define SetModeInsert           0\n#define SetModeDelete           1\n\n/* Used in ChangeCloseDownMode */\n\n#define DestroyAll              0\n#define RetainPermanent         1\n#define RetainTemporary         2\n\n/* Window stacking method (in configureWindow) */\n\n#define Above                   0\n#define Below                   1\n#define TopIf                   2\n#define BottomIf                3\n#define Opposite                4\n\n/* Circulation direction */\n\n#define RaiseLowest             0\n#define LowerHighest            1\n\n/* Property modes */\n\n#define PropModeReplace         0\n#define PropModePrepend         1\n#define PropModeAppend          2\n\n/*****************************************************************\n * GRAPHICS DEFINITIONS\n *****************************************************************/\n\n/* graphics functions, as in GC.alu */\n\n#define\tGXclear\t\t\t0x0\t\t/* 0 */\n#define GXand\t\t\t0x1\t\t/* src AND dst */\n#define GXandReverse\t\t0x2\t\t/* src AND NOT dst */\n#define GXcopy\t\t\t0x3\t\t/* src */\n#define GXandInverted\t\t0x4\t\t/* NOT src AND dst */\n#define\tGXnoop\t\t\t0x5\t\t/* dst */\n#define GXxor\t\t\t0x6\t\t/* src XOR dst */\n#define GXor\t\t\t0x7\t\t/* src OR dst */\n#define GXnor\t\t\t0x8\t\t/* NOT src AND NOT dst */\n#define GXequiv\t\t\t0x9\t\t/* NOT src XOR dst */\n#define GXinvert\t\t0xa\t\t/* NOT dst */\n#define GXorReverse\t\t0xb\t\t/* src OR NOT dst */\n#define GXcopyInverted\t\t0xc\t\t/* NOT src */\n#define GXorInverted\t\t0xd\t\t/* NOT src OR dst */\n#define GXnand\t\t\t0xe\t\t/* NOT src OR NOT dst */\n#define GXset\t\t\t0xf\t\t/* 1 */\n\n/* LineStyle */\n\n#define LineSolid\t\t0\n#define LineOnOffDash\t\t1\n#define LineDoubleDash\t\t2\n\n/* capStyle */\n\n#define CapNotLast\t\t0\n#define CapButt\t\t\t1\n#define CapRound\t\t2\n#define CapProjecting\t\t3\n\n/* joinStyle */\n\n#define JoinMiter\t\t0\n#define JoinRound\t\t1\n#define JoinBevel\t\t2\n\n/* fillStyle */\n\n#define FillSolid\t\t0\n#define FillTiled\t\t1\n#define FillStippled\t\t2\n#define FillOpaqueStippled\t3\n\n/* fillRule */\n\n#define EvenOddRule\t\t0\n#define WindingRule\t\t1\n\n/* subwindow mode */\n\n#define ClipByChildren\t\t0\n#define IncludeInferiors\t1\n\n/* SetClipRectangles ordering */\n\n#define Unsorted\t\t0\n#define YSorted\t\t\t1\n#define YXSorted\t\t2\n#define YXBanded\t\t3\n\n/* CoordinateMode for drawing routines */\n\n#define CoordModeOrigin\t\t0\t/* relative to the origin */\n#define CoordModePrevious       1\t/* relative to previous point */\n\n/* Polygon shapes */\n\n#define Complex\t\t\t0\t/* paths may intersect */\n#define Nonconvex\t\t1\t/* no paths intersect, but not convex */\n#define Convex\t\t\t2\t/* wholly convex */\n\n/* Arc modes for PolyFillArc */\n\n#define ArcChord\t\t0\t/* join endpoints of arc */\n#define ArcPieSlice\t\t1\t/* join endpoints to center of arc */\n\n/* GC components: masks used in CreateGC, CopyGC, ChangeGC, OR'ed into\n   GC.stateChanges */\n\n#define GCFunction              (1L<<0)\n#define GCPlaneMask             (1L<<1)\n#define GCForeground            (1L<<2)\n#define GCBackground            (1L<<3)\n#define GCLineWidth             (1L<<4)\n#define GCLineStyle             (1L<<5)\n#define GCCapStyle              (1L<<6)\n#define GCJoinStyle\t\t(1L<<7)\n#define GCFillStyle\t\t(1L<<8)\n#define GCFillRule\t\t(1L<<9) \n#define GCTile\t\t\t(1L<<10)\n#define GCStipple\t\t(1L<<11)\n#define GCTileStipXOrigin\t(1L<<12)\n#define GCTileStipYOrigin\t(1L<<13)\n#define GCFont \t\t\t(1L<<14)\n#define GCSubwindowMode\t\t(1L<<15)\n#define GCGraphicsExposures     (1L<<16)\n#define GCClipXOrigin\t\t(1L<<17)\n#define GCClipYOrigin\t\t(1L<<18)\n#define GCClipMask\t\t(1L<<19)\n#define GCDashOffset\t\t(1L<<20)\n#define GCDashList\t\t(1L<<21)\n#define GCArcMode\t\t(1L<<22)\n\n#define GCLastBit\t\t22\n/*****************************************************************\n * FONTS \n *****************************************************************/\n\n/* used in QueryFont -- draw direction */\n\n#define FontLeftToRight\t\t0\n#define FontRightToLeft\t\t1\n\n#define FontChange\t\t255\n\n/*****************************************************************\n *  IMAGING \n *****************************************************************/\n\n/* ImageFormat -- PutImage, GetImage */\n\n#define XYBitmap\t\t0\t/* depth 1, XYFormat */\n#define XYPixmap\t\t1\t/* depth == drawable depth */\n#define ZPixmap\t\t\t2\t/* depth == drawable depth */\n\n/*****************************************************************\n *  COLOR MAP STUFF \n *****************************************************************/\n\n/* For CreateColormap */\n\n#define AllocNone\t\t0\t/* create map with no entries */\n#define AllocAll\t\t1\t/* allocate entire map writeable */\n\n\n/* Flags used in StoreNamedColor, StoreColors */\n\n#define DoRed\t\t\t(1<<0)\n#define DoGreen\t\t\t(1<<1)\n#define DoBlue\t\t\t(1<<2)\n\n/*****************************************************************\n * CURSOR STUFF\n *****************************************************************/\n\n/* QueryBestSize Class */\n\n#define CursorShape\t\t0\t/* largest size that can be displayed */\n#define TileShape\t\t1\t/* size tiled fastest */\n#define StippleShape\t\t2\t/* size stippled fastest */\n\n/***************************************************************** \n * KEYBOARD/POINTER STUFF\n *****************************************************************/\n\n#define AutoRepeatModeOff\t0\n#define AutoRepeatModeOn\t1\n#define AutoRepeatModeDefault\t2\n\n#define LedModeOff\t\t0\n#define LedModeOn\t\t1\n\n/* masks for ChangeKeyboardControl */\n\n#define KBKeyClickPercent\t(1L<<0)\n#define KBBellPercent\t\t(1L<<1)\n#define KBBellPitch\t\t(1L<<2)\n#define KBBellDuration\t\t(1L<<3)\n#define KBLed\t\t\t(1L<<4)\n#define KBLedMode\t\t(1L<<5)\n#define KBKey\t\t\t(1L<<6)\n#define KBAutoRepeatMode\t(1L<<7)\n\n#define MappingSuccess     \t0\n#define MappingBusy        \t1\n#define MappingFailed\t\t2\n\n#define MappingModifier\t\t0\n#define MappingKeyboard\t\t1\n#define MappingPointer\t\t2\n\n/*****************************************************************\n * SCREEN SAVER STUFF \n *****************************************************************/\n\n#define DontPreferBlanking\t0\n#define PreferBlanking\t\t1\n#define DefaultBlanking\t\t2\n\n#define DisableScreenSaver\t0\n#define DisableScreenInterval\t0\n\n#define DontAllowExposures\t0\n#define AllowExposures\t\t1\n#define DefaultExposures\t2\n\n/* for ForceScreenSaver */\n\n#define ScreenSaverReset 0\n#define ScreenSaverActive 1\n\n/*****************************************************************\n * HOSTS AND CONNECTIONS\n *****************************************************************/\n\n/* for ChangeHosts */\n\n#define HostInsert\t\t0\n#define HostDelete\t\t1\n\n/* for ChangeAccessControl */\n\n#define EnableAccess\t\t1      \n#define DisableAccess\t\t0\n\n/* Display classes  used in opening the connection \n * Note that the statically allocated ones are even numbered and the\n * dynamically changeable ones are odd numbered */\n\n#define StaticGray\t\t0\n#define GrayScale\t\t1\n#define StaticColor\t\t2\n#define PseudoColor\t\t3\n#define TrueColor\t\t4\n#define DirectColor\t\t5\n\n\n/* Byte order  used in imageByteOrder and bitmapBitOrder */\n\n#define LSBFirst\t\t0\n#define MSBFirst\t\t1\n\n#endif /* X_H */\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/X11/XF86keysym.h",
    "content": "/*\n * XFree86 vendor specific keysyms.\n *\n * The XFree86 keysym range is 0x10080001 - 0x1008FFFF.\n *\n * X.Org will not be adding to the XF86 set of keysyms, though they have\n * been adopted and are considered a \"standard\" part of X keysym definitions.\n * XFree86 never properly commented these keysyms, so we have done our\n * best to explain the semantic meaning of these keys.\n *\n * XFree86 has removed their mail archives of the period, that might have\n * shed more light on some of these definitions. Until/unless we resurrect\n * these archives, these are from memory and usage.\n */\n\n/*\n * ModeLock\n *\n * This one is old, and not really used any more since XKB offers this\n * functionality.\n */\n\n#define XF86XK_ModeLock\t\t0x1008FF01\t/* Mode Switch Lock */\n\n/* Backlight controls. */\n#define XF86XK_MonBrightnessUp   0x1008FF02  /* Monitor/panel brightness */\n#define XF86XK_MonBrightnessDown 0x1008FF03  /* Monitor/panel brightness */\n#define XF86XK_KbdLightOnOff     0x1008FF04  /* Keyboards may be lit     */\n#define XF86XK_KbdBrightnessUp   0x1008FF05  /* Keyboards may be lit     */\n#define XF86XK_KbdBrightnessDown 0x1008FF06  /* Keyboards may be lit     */\n\n/*\n * Keys found on some \"Internet\" keyboards.\n */\n#define XF86XK_Standby\t\t0x1008FF10   /* System into standby mode   */\n#define XF86XK_AudioLowerVolume\t0x1008FF11   /* Volume control down        */\n#define XF86XK_AudioMute\t0x1008FF12   /* Mute sound from the system */\n#define XF86XK_AudioRaiseVolume\t0x1008FF13   /* Volume control up          */\n#define XF86XK_AudioPlay\t0x1008FF14   /* Start playing of audio >   */\n#define XF86XK_AudioStop\t0x1008FF15   /* Stop playing audio         */\n#define XF86XK_AudioPrev\t0x1008FF16   /* Previous track             */\n#define XF86XK_AudioNext\t0x1008FF17   /* Next track                 */\n#define XF86XK_HomePage\t\t0x1008FF18   /* Display user's home page   */\n#define XF86XK_Mail\t\t0x1008FF19   /* Invoke user's mail program */\n#define XF86XK_Start\t\t0x1008FF1A   /* Start application          */\n#define XF86XK_Search\t\t0x1008FF1B   /* Search                     */\n#define XF86XK_AudioRecord\t0x1008FF1C   /* Record audio application   */\n\n/* These are sometimes found on PDA's (e.g. Palm, PocketPC or elsewhere)   */\n#define XF86XK_Calculator\t0x1008FF1D   /* Invoke calculator program  */\n#define XF86XK_Memo\t\t0x1008FF1E   /* Invoke Memo taking program */\n#define XF86XK_ToDoList\t\t0x1008FF1F   /* Invoke To Do List program  */\n#define XF86XK_Calendar\t\t0x1008FF20   /* Invoke Calendar program    */\n#define XF86XK_PowerDown\t0x1008FF21   /* Deep sleep the system      */\n#define XF86XK_ContrastAdjust\t0x1008FF22   /* Adjust screen contrast     */\n#define XF86XK_RockerUp\t\t0x1008FF23   /* Rocker switches exist up   */\n#define XF86XK_RockerDown\t0x1008FF24   /* and down                   */\n#define XF86XK_RockerEnter\t0x1008FF25   /* and let you press them     */\n\n/* Some more \"Internet\" keyboard symbols */\n#define XF86XK_Back\t\t0x1008FF26   /* Like back on a browser     */\n#define XF86XK_Forward\t\t0x1008FF27   /* Like forward on a browser  */\n#define XF86XK_Stop\t\t0x1008FF28   /* Stop current operation     */\n#define XF86XK_Refresh\t\t0x1008FF29   /* Refresh the page           */\n#define XF86XK_PowerOff\t\t0x1008FF2A   /* Power off system entirely  */\n#define XF86XK_WakeUp\t\t0x1008FF2B   /* Wake up system from sleep  */\n#define XF86XK_Eject            0x1008FF2C   /* Eject device (e.g. DVD)    */\n#define XF86XK_ScreenSaver      0x1008FF2D   /* Invoke screensaver         */\n#define XF86XK_WWW              0x1008FF2E   /* Invoke web browser         */\n#define XF86XK_Sleep            0x1008FF2F   /* Put system to sleep        */\n#define XF86XK_Favorites\t0x1008FF30   /* Show favorite locations    */\n#define XF86XK_AudioPause\t0x1008FF31   /* Pause audio playing        */\n#define XF86XK_AudioMedia\t0x1008FF32   /* Launch media collection app */\n#define XF86XK_MyComputer\t0x1008FF33   /* Display \"My Computer\" window */\n#define XF86XK_VendorHome\t0x1008FF34   /* Display vendor home web site */\n#define XF86XK_LightBulb\t0x1008FF35   /* Light bulb keys exist       */\n#define XF86XK_Shop\t\t0x1008FF36   /* Display shopping web site   */\n#define XF86XK_History\t\t0x1008FF37   /* Show history of web surfing */\n#define XF86XK_OpenURL\t\t0x1008FF38   /* Open selected URL           */\n#define XF86XK_AddFavorite\t0x1008FF39   /* Add URL to favorites list   */\n#define XF86XK_HotLinks\t\t0x1008FF3A   /* Show \"hot\" links            */\n#define XF86XK_BrightnessAdjust\t0x1008FF3B   /* Invoke brightness adj. UI   */\n#define XF86XK_Finance\t\t0x1008FF3C   /* Display financial site      */\n#define XF86XK_Community\t0x1008FF3D   /* Display user's community    */\n#define XF86XK_AudioRewind\t0x1008FF3E   /* \"rewind\" audio track        */\n#define XF86XK_BackForward\t0x1008FF3F   /* ??? */\n#define XF86XK_Launch0\t\t0x1008FF40   /* Launch Application          */\n#define XF86XK_Launch1\t\t0x1008FF41   /* Launch Application          */\n#define XF86XK_Launch2\t\t0x1008FF42   /* Launch Application          */\n#define XF86XK_Launch3\t\t0x1008FF43   /* Launch Application          */\n#define XF86XK_Launch4\t\t0x1008FF44   /* Launch Application          */\n#define XF86XK_Launch5\t\t0x1008FF45   /* Launch Application          */\n#define XF86XK_Launch6\t\t0x1008FF46   /* Launch Application          */\n#define XF86XK_Launch7\t\t0x1008FF47   /* Launch Application          */\n#define XF86XK_Launch8\t\t0x1008FF48   /* Launch Application          */\n#define XF86XK_Launch9\t\t0x1008FF49   /* Launch Application          */\n#define XF86XK_LaunchA\t\t0x1008FF4A   /* Launch Application          */\n#define XF86XK_LaunchB\t\t0x1008FF4B   /* Launch Application          */\n#define XF86XK_LaunchC\t\t0x1008FF4C   /* Launch Application          */\n#define XF86XK_LaunchD\t\t0x1008FF4D   /* Launch Application          */\n#define XF86XK_LaunchE\t\t0x1008FF4E   /* Launch Application          */\n#define XF86XK_LaunchF\t\t0x1008FF4F   /* Launch Application          */\n\n#define XF86XK_ApplicationLeft\t0x1008FF50   /* switch to application, left */\n#define XF86XK_ApplicationRight\t0x1008FF51   /* switch to application, right*/\n#define XF86XK_Book\t\t0x1008FF52   /* Launch bookreader           */\n#define XF86XK_CD\t\t0x1008FF53   /* Launch CD/DVD player        */\n#define XF86XK_Calculater\t0x1008FF54   /* Launch Calculater           */\n#define XF86XK_Clear\t\t0x1008FF55   /* Clear window, screen        */\n#define XF86XK_Close\t\t0x1008FF56   /* Close window                */\n#define XF86XK_Copy\t\t0x1008FF57   /* Copy selection              */\n#define XF86XK_Cut\t\t0x1008FF58   /* Cut selection               */\n#define XF86XK_Display\t\t0x1008FF59   /* Output switch key           */\n#define XF86XK_DOS\t\t0x1008FF5A   /* Launch DOS (emulation)      */\n#define XF86XK_Documents\t0x1008FF5B   /* Open documents window       */\n#define XF86XK_Excel\t\t0x1008FF5C   /* Launch spread sheet         */\n#define XF86XK_Explorer\t\t0x1008FF5D   /* Launch file explorer        */\n#define XF86XK_Game\t\t0x1008FF5E   /* Launch game                 */\n#define XF86XK_Go\t\t0x1008FF5F   /* Go to URL                   */\n#define XF86XK_iTouch\t\t0x1008FF60   /* Logitch iTouch- don't use   */\n#define XF86XK_LogOff\t\t0x1008FF61   /* Log off system              */\n#define XF86XK_Market\t\t0x1008FF62   /* ??                          */\n#define XF86XK_Meeting\t\t0x1008FF63   /* enter meeting in calendar   */\n#define XF86XK_MenuKB\t\t0x1008FF65   /* distingush keyboard from PB */\n#define XF86XK_MenuPB\t\t0x1008FF66   /* distinuish PB from keyboard */\n#define XF86XK_MySites\t\t0x1008FF67   /* Favourites                  */\n#define XF86XK_New\t\t0x1008FF68   /* New (folder, document...    */\n#define XF86XK_News\t\t0x1008FF69   /* News                        */\n#define XF86XK_OfficeHome\t0x1008FF6A   /* Office home (old Staroffice)*/\n#define XF86XK_Open\t\t0x1008FF6B   /* Open                        */\n#define XF86XK_Option\t\t0x1008FF6C   /* ?? */\n#define XF86XK_Paste\t\t0x1008FF6D   /* Paste                       */\n#define XF86XK_Phone\t\t0x1008FF6E   /* Launch phone; dial number   */\n#define XF86XK_Q\t\t0x1008FF70   /* Compaq's Q - don't use      */\n#define XF86XK_Reply\t\t0x1008FF72   /* Reply e.g., mail            */\n#define XF86XK_Reload\t\t0x1008FF73   /* Reload web page, file, etc. */\n#define XF86XK_RotateWindows\t0x1008FF74   /* Rotate windows e.g. xrandr  */\n#define XF86XK_RotationPB\t0x1008FF75   /* don't use                   */\n#define XF86XK_RotationKB\t0x1008FF76   /* don't use                   */\n#define XF86XK_Save\t\t0x1008FF77   /* Save (file, document, state */\n#define XF86XK_ScrollUp\t\t0x1008FF78   /* Scroll window/contents up   */\n#define XF86XK_ScrollDown\t0x1008FF79   /* Scrool window/contentd down */\n#define XF86XK_ScrollClick\t0x1008FF7A   /* Use XKB mousekeys instead   */\n#define XF86XK_Send\t\t0x1008FF7B   /* Send mail, file, object     */\n#define XF86XK_Spell\t\t0x1008FF7C   /* Spell checker               */\n#define XF86XK_SplitScreen\t0x1008FF7D   /* Split window or screen      */\n#define XF86XK_Support\t\t0x1008FF7E   /* Get support (??)            */\n#define XF86XK_TaskPane\t\t0x1008FF7F   /* Show tasks */\n#define XF86XK_Terminal\t\t0x1008FF80   /* Launch terminal emulator    */\n#define XF86XK_Tools\t\t0x1008FF81   /* toolbox of desktop/app.     */\n#define XF86XK_Travel\t\t0x1008FF82   /* ?? */\n#define XF86XK_UserPB\t\t0x1008FF84   /* ?? */\n#define XF86XK_User1KB\t\t0x1008FF85   /* ?? */\n#define XF86XK_User2KB\t\t0x1008FF86   /* ?? */\n#define XF86XK_Video\t\t0x1008FF87   /* Launch video player       */\n#define XF86XK_WheelButton\t0x1008FF88   /* button from a mouse wheel */\n#define XF86XK_Word\t\t0x1008FF89   /* Launch word processor     */\n#define XF86XK_Xfer\t\t0x1008FF8A\n#define XF86XK_ZoomIn\t\t0x1008FF8B   /* zoom in view, map, etc.   */\n#define XF86XK_ZoomOut\t\t0x1008FF8C   /* zoom out view, map, etc.  */\n\n#define XF86XK_Away\t\t0x1008FF8D   /* mark yourself as away     */\n#define XF86XK_Messenger\t0x1008FF8E   /* as in instant messaging   */\n#define XF86XK_WebCam\t\t0x1008FF8F   /* Launch web camera app.    */\n#define XF86XK_MailForward\t0x1008FF90   /* Forward in mail           */\n#define XF86XK_Pictures\t\t0x1008FF91   /* Show pictures             */\n#define XF86XK_Music\t\t0x1008FF92   /* Launch music application  */\n\n#define XF86XK_Battery\t\t0x1008FF93   /* Display battery information */\n#define XF86XK_Bluetooth\t0x1008FF94   /* Enable/disable Bluetooth    */\n#define XF86XK_WLAN\t\t0x1008FF95   /* Enable/disable WLAN         */\n#define XF86XK_UWB\t\t0x1008FF96   /* Enable/disable UWB\t    */\n\n#define XF86XK_AudioForward\t0x1008FF97   /* fast-forward audio track    */\n#define XF86XK_AudioRepeat\t0x1008FF98   /* toggle repeat mode          */\n#define XF86XK_AudioRandomPlay\t0x1008FF99   /* toggle shuffle mode         */\n#define XF86XK_Subtitle\t\t0x1008FF9A   /* cycle through subtitle      */\n#define XF86XK_AudioCycleTrack\t0x1008FF9B   /* cycle through audio tracks  */\n#define XF86XK_CycleAngle\t0x1008FF9C   /* cycle through angles        */\n#define XF86XK_FrameBack\t0x1008FF9D   /* video: go one frame back    */\n#define XF86XK_FrameForward\t0x1008FF9E   /* video: go one frame forward */\n#define XF86XK_Time\t\t0x1008FF9F   /* display, or shows an entry for time seeking */\n#define XF86XK_Select\t\t0x1008FFA0   /* Select button on joypads and remotes */\n#define XF86XK_View\t\t0x1008FFA1   /* Show a view options/properties */\n#define XF86XK_TopMenu\t\t0x1008FFA2   /* Go to a top-level menu in a video */\n\n#define XF86XK_Red\t\t0x1008FFA3   /* Red button                  */\n#define XF86XK_Green\t\t0x1008FFA4   /* Green button                */\n#define XF86XK_Yellow\t\t0x1008FFA5   /* Yellow button               */\n#define XF86XK_Blue             0x1008FFA6   /* Blue button                 */\n\n#define XF86XK_Suspend\t\t0x1008FFA7   /* Sleep to RAM                */\n#define XF86XK_Hibernate\t0x1008FFA8   /* Sleep to disk               */\n#define XF86XK_TouchpadToggle\t0x1008FFA9   /* Toggle between touchpad/trackstick */\n#define XF86XK_TouchpadOn\t0x1008FFB0   /* The touchpad got switched on */\n#define XF86XK_TouchpadOff\t0x1008FFB1   /* The touchpad got switched off */\n\n#define XF86XK_AudioMicMute\t0x1008FFB2   /* Mute the Mic from the system */\n\n/* Keys for special action keys (hot keys) */\n/* Virtual terminals on some operating systems */\n#define XF86XK_Switch_VT_1\t0x1008FE01\n#define XF86XK_Switch_VT_2\t0x1008FE02\n#define XF86XK_Switch_VT_3\t0x1008FE03\n#define XF86XK_Switch_VT_4\t0x1008FE04\n#define XF86XK_Switch_VT_5\t0x1008FE05\n#define XF86XK_Switch_VT_6\t0x1008FE06\n#define XF86XK_Switch_VT_7\t0x1008FE07\n#define XF86XK_Switch_VT_8\t0x1008FE08\n#define XF86XK_Switch_VT_9\t0x1008FE09\n#define XF86XK_Switch_VT_10\t0x1008FE0A\n#define XF86XK_Switch_VT_11\t0x1008FE0B\n#define XF86XK_Switch_VT_12\t0x1008FE0C\n\n#define XF86XK_Ungrab\t\t0x1008FE20   /* force ungrab               */\n#define XF86XK_ClearGrab\t0x1008FE21   /* kill application with grab */\n#define XF86XK_Next_VMode\t0x1008FE22   /* next video mode available  */\n#define XF86XK_Prev_VMode\t0x1008FE23   /* prev. video mode available */\n#define XF86XK_LogWindowTree\t0x1008FE24   /* print window tree to log   */\n#define XF86XK_LogGrabInfo\t0x1008FE25   /* print all active grabs to log */\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/X11/XKBlib.h",
    "content": "/************************************************************\nCopyright (c) 1993 by Silicon Graphics Computer Systems, Inc.\n\nPermission to use, copy, modify, and distribute this\nsoftware and its documentation for any purpose and without\nfee is hereby granted, provided that the above copyright\nnotice appear in all copies and that both that copyright\nnotice and this permission notice appear in supporting\ndocumentation, and that the name of Silicon Graphics not be\nused in advertising or publicity pertaining to distribution\nof the software without specific prior written permission.\nSilicon Graphics makes no representation about the suitability\nof this software for any purpose. It is provided \"as is\"\nwithout any express or implied warranty.\n\nSILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS\nSOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\nAND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON\nGRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL\nDAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,\nDATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE\nOR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION  WITH\nTHE USE OR PERFORMANCE OF THIS SOFTWARE.\n\n********************************************************/\n\n#ifndef _X11_XKBLIB_H_\n#define _X11_XKBLIB_H_\n\n#include <X11/Xlib.h>\n#include <X11/extensions/XKBstr.h>\n\ntypedef struct _XkbAnyEvent {\n\tint \t\ttype;\t\t/* XkbAnyEvent */\n\tunsigned long \tserial;\t\t/* # of last req processed by server */\n\tBool \t\tsend_event;\t/* is this from a SendEvent request? */\n\tDisplay *\tdisplay;\t/* Display the event was read from */\n\tTime \t\ttime;\t\t/* milliseconds */\n\tint \t\txkb_type;\t/* XKB event minor code */\n\tunsigned int \tdevice;\t\t/* device ID */\n} XkbAnyEvent;\n\ntypedef struct _XkbNewKeyboardNotify {\n\tint \t\ttype;\t\t/* XkbAnyEvent */\n\tunsigned long \tserial;\t\t/* of last req processed by server */\n\tBool \t\tsend_event;\t/* is this from a SendEvent request? */\n\tDisplay *\tdisplay;\t/* Display the event was read from */\n\tTime \t\ttime;\t\t/* milliseconds */\n\tint \t\txkb_type;\t/* XkbNewKeyboardNotify */\n\tint\t \tdevice;\t\t/* device ID */\n\tint\t \told_device;\t/* device ID of previous keyboard */\n\tint\t \tmin_key_code;\t/* minimum key code */\n\tint\t\tmax_key_code;\t/* maximum key code */\n\tint\t \told_min_key_code;/* min key code of previous kbd */\n\tint\t\told_max_key_code;/* max key code of previous kbd */\n\tunsigned int\tchanged;\t/* changed aspects of the keyboard */\n\tchar\t \treq_major;\t/* major and minor opcode of req */\n\tchar\t \treq_minor;\t/* that caused change, if applicable */\n} XkbNewKeyboardNotifyEvent;\n\ntypedef struct _XkbMapNotifyEvent {\n\tint \t\ttype;\t\t/* XkbAnyEvent */\n\tunsigned long \tserial;\t\t/* of last req processed by server */\n\tBool \t\tsend_event;\t/* is this from a SendEvent request */\n\tDisplay *\tdisplay;\t/* Display the event was read from */\n\tTime \t\ttime;\t\t/* milliseconds */\n\tint \t\txkb_type;\t/* XkbMapNotify */\n\tint \t\tdevice;\t\t/* device ID */\n\tunsigned int \tchanged;\t/* fields which have been changed */\n\tunsigned int \tflags;\t\t/* reserved */\n\tint \t\tfirst_type;\t/* first changed key type */\n\tint \t\tnum_types;\t/* number of changed key types */\n\tKeyCode\t\tmin_key_code;\n\tKeyCode\t\tmax_key_code;\n\tKeyCode\t\tfirst_key_sym;\n\tKeyCode\t\tfirst_key_act;\n\tKeyCode\t\tfirst_key_behavior;\n\tKeyCode\t\tfirst_key_explicit;\n\tKeyCode\t\tfirst_modmap_key;\n\tKeyCode\t\tfirst_vmodmap_key;\n\tint\t\tnum_key_syms;\n\tint\t\tnum_key_acts;\n\tint\t\tnum_key_behaviors;\n\tint\t\tnum_key_explicit;\n\tint \t\tnum_modmap_keys;\n\tint \t\tnum_vmodmap_keys;\n\tunsigned int \tvmods;\t\t/* mask of changed virtual mods */\n} XkbMapNotifyEvent;\n\ntypedef struct _XkbStateNotifyEvent {\n\tint \t\ttype;\t\t/* XkbAnyEvent */\n\tunsigned long \tserial;\t\t/* # of last req processed by server */\n\tBool \t\tsend_event;\t/* is this from a SendEvent request? */\n\tDisplay *\tdisplay;\t/* Display the event was read from */\n\tTime \t\ttime;\t\t/* milliseconds */\n\tint \t\txkb_type;\t/* XkbStateNotify */\n\tint \t\tdevice;\t\t/* device ID */\n\tunsigned int \tchanged;\t/* mask of changed state components */\n\tint \t\tgroup;\t\t/* keyboard group */\n\tint \t\tbase_group;\t/* base keyboard group */\n\tint \t\tlatched_group;\t/* latched keyboard group */\n\tint \t\tlocked_group;\t/* locked keyboard group */\n\tunsigned int\tmods;\t\t/* modifier state */\n\tunsigned int \tbase_mods;\t/* base modifier state */\n\tunsigned int\tlatched_mods;\t/* latched modifiers */\n\tunsigned int\tlocked_mods;\t/* locked modifiers */\n\tint \t\tcompat_state;\t/* compatibility state */\n\tunsigned char\tgrab_mods;\t/* mods used for grabs */\n\tunsigned char\tcompat_grab_mods;/* grab mods for non-XKB clients */\n\tunsigned char\tlookup_mods;\t/* mods sent to clients */\n\tunsigned char\tcompat_lookup_mods; /* mods sent to non-XKB clients */\n\tint \t\tptr_buttons;\t/* pointer button state */\n\tKeyCode\t\tkeycode;\t/* keycode that caused the change */\n\tchar \t\tevent_type;\t/* KeyPress or KeyRelease */\n\tchar \t\treq_major;\t/* Major opcode of request */\n\tchar \t\treq_minor;\t/* Minor opcode of request */\n} XkbStateNotifyEvent;\n\ntypedef struct _XkbControlsNotify {\n\tint \t\ttype;\t\t/* XkbAnyEvent */\n\tunsigned long \tserial;\t\t/* of last req processed by server */\n\tBool \t\tsend_event;\t/* is this from a SendEvent request? */\n\tDisplay *\tdisplay;\t/* Display the event was read from */\n\tTime \t\ttime;\t\t/* milliseconds */\n\tint \t\txkb_type;\t/* XkbControlsNotify */\n\tint \t\tdevice;\t\t/* device ID */\n\tunsigned int\tchanged_ctrls;\t/* controls with changed sub-values */\n\tunsigned int \tenabled_ctrls;\t/* controls currently enabled */\n\tunsigned int\tenabled_ctrl_changes;/* controls just {en,dis}abled */\n\tint \t\tnum_groups;\t/* total groups on keyboard */\n\tKeyCode\t\tkeycode;\t/* key that caused change or 0 */\n\tchar \t\tevent_type;\t/* type of event that caused change */\n\tchar \t\treq_major;\t/* if keycode==0, major and minor */\n\tchar \t\treq_minor;\t/* opcode of req that caused change */\n} XkbControlsNotifyEvent;\n\ntypedef struct _XkbIndicatorNotify {\n\tint \t\ttype;\t\t/* XkbAnyEvent */\n\tunsigned long \tserial;\t\t/* of last req processed by server */\n\tBool \t\tsend_event;\t/* is this from a SendEvent request? */\n\tDisplay *\tdisplay;\t/* Display the event was read from */\n\tTime \t\ttime;\t\t/* milliseconds */\n\tint \t\txkb_type;\t/* XkbIndicatorNotify */\n\tint \t\tdevice;\t\t/* device ID */\n\tunsigned int\tchanged;\t/* indicators with new state or map */\n\tunsigned int\tstate;\t \t/* current state of all indicators */\n} XkbIndicatorNotifyEvent;\n\ntypedef struct _XkbNamesNotify {\n\tint \t\ttype;\t\t/* XkbAnyEvent */\n\tunsigned long \tserial;\t\t/* of last req processed by server */\n\tBool \t\tsend_event;\t/* is this from a SendEvent request? */\n\tDisplay *\tdisplay;\t/* Display the event was read from */\n\tTime \t\ttime;\t\t/* milliseconds */\n\tint \t\txkb_type;\t/* XkbNamesNotify */\n\tint\t \tdevice;\t\t/* device ID */\n\tunsigned int \tchanged;\t/* names that have changed */\n\tint\t \tfirst_type;\t/* first key type with new name */\n\tint\t \tnum_types;\t/* number of key types with new names */\n\tint\t \tfirst_lvl;\t/* first key type new new level names */\n\tint\t \tnum_lvls;\t/* # of key types w/new level names */\n\tint\t \tnum_aliases;\t/* total number of key aliases*/\n\tint\t \tnum_radio_groups;/* total number of radio groups */\n\tunsigned int \tchanged_vmods;\t/* virtual modifiers with new names */\n\tunsigned int \tchanged_groups;\t/* groups with new names */\n\tunsigned int \tchanged_indicators;/* indicators with new names */\n\tint\t\tfirst_key;\t/* first key with new name */\n\tint\t\tnum_keys;\t/* number of keys with new names */\n} XkbNamesNotifyEvent;\n\ntypedef struct _XkbCompatMapNotify {\n\tint \t\ttype;\t\t/* XkbAnyEvent */\n\tunsigned long \tserial;\t\t/* of last req processed by server */\n\tBool \t\tsend_event;\t/* is this from a SendEvent request? */\n\tDisplay *\tdisplay;\t/* Display the event was read from */\n\tTime \t\ttime;\t\t/* milliseconds */\n\tint \t\txkb_type;\t/* XkbCompatMapNotify */\n\tint\t \tdevice;\t\t/* device ID */\n\tunsigned int \tchanged_groups; /* groups with new compat maps */\n\tint\t \tfirst_si;\t/* first new symbol interp */\n\tint\t \tnum_si;\t\t/* number of new symbol interps */\n\tint\t \tnum_total_si;\t/* total # of symbol interps */\n} XkbCompatMapNotifyEvent;\n\ntypedef struct _XkbBellNotify {\n\tint \t\ttype;\t\t/* XkbAnyEvent */\n\tunsigned long \tserial;\t\t/* of last req processed by server */\n\tBool \t\tsend_event;\t/* is this from a SendEvent request? */\n\tDisplay *\tdisplay;\t/* Display the event was read from */\n\tTime \t\ttime;\t\t/* milliseconds */\n\tint \t\txkb_type;\t/* XkbBellNotify */\n\tint\t \tdevice;\t\t/* device ID */\n\tint\t \tpercent;\t/* requested volume as a % of maximum */\n\tint\t \tpitch;\t\t/* requested pitch in Hz */\n\tint\t \tduration;\t/* requested duration in useconds */\n\tint\t \tbell_class;\t/* (input extension) feedback class */\n\tint\t \tbell_id;\t/* (input extension) ID of feedback */\n\tAtom \t\tname;\t\t/* \"name\" of requested bell */\n\tWindow \t\twindow;\t\t/* window associated with event */\n\tBool\t\tevent_only;\t/* \"event only\" requested */\n} XkbBellNotifyEvent;\n\ntypedef struct _XkbActionMessage {\n\tint \t\ttype;\t\t/* XkbAnyEvent */\n\tunsigned long \tserial;\t\t/* of last req processed by server */\n\tBool \t\tsend_event;\t/* is this from a SendEvent request? */\n\tDisplay *\tdisplay;\t/* Display the event was read from */\n\tTime \t\ttime;\t\t/* milliseconds */\n\tint \t\txkb_type;\t/* XkbActionMessage */\n\tint\t \tdevice;\t\t/* device ID */\n\tKeyCode\t\tkeycode;\t/* key that generated the event */\n\tBool \t\tpress;\t\t/* true if act caused by key press */\n\tBool \t\tkey_event_follows;/* true if key event also generated */\n\tint\t\tgroup;\t\t/* effective group */\n\tunsigned int\tmods;\t\t/* effective mods */\n\tchar \t\tmessage[XkbActionMessageLength+1];\n\t\t\t\t\t/* message -- leave space for NUL */\n} XkbActionMessageEvent;\n\ntypedef struct _XkbAccessXNotify {\n\tint \t\ttype;\t\t/* XkbAnyEvent */\n\tunsigned long \tserial;\t\t/* of last req processed by server */\n\tBool \t\tsend_event;\t/* is this from a SendEvent request? */\n\tDisplay *\tdisplay;\t/* Display the event was read from */\n\tTime \t\ttime;\t\t/* milliseconds */\n\tint \t\txkb_type;\t/* XkbAccessXNotify */\n\tint\t \tdevice;\t\t/* device ID */\n\tint\t \tdetail;\t\t/* XkbAXN_* */\n\tint\t \tkeycode;\t/* key of event */\n\tint\t \tsk_delay;\t/* current slow keys delay */\n\tint\t\tdebounce_delay;\t/* current debounce delay */\n} XkbAccessXNotifyEvent;\n\ntypedef struct _XkbExtensionDeviceNotify {\n\tint \t\ttype;\t\t/* XkbAnyEvent */\n\tunsigned long \tserial;\t\t/* of last req processed by server */\n\tBool \t\tsend_event;\t/* is this from a SendEvent request? */\n\tDisplay *\tdisplay;\t/* Display the event was read from */\n\tTime \t\ttime;\t\t/* milliseconds */\n\tint \t\txkb_type;\t/* XkbExtensionDeviceNotify */\n\tint\t \tdevice;\t\t/* device ID */\n\tunsigned int\treason;\t\t/* reason for the event */\n\tunsigned int\tsupported;\t/* mask of supported features */\n\tunsigned int\tunsupported;\t/* mask of unsupported features */\n\t\t\t\t\t/* that some app tried to use */\n\tint\t \tfirst_btn;\t/* first button that changed */\n\tint\t \tnum_btns;\t/* range of buttons changed */\n\tunsigned int\tleds_defined;   /* indicators with names or maps */\n\tunsigned int\tled_state;\t/* current state of the indicators */\n\tint\t\tled_class;\t/* feedback class for led changes */\n\tint\t\tled_id;   \t/* feedback id for led changes */\n} XkbExtensionDeviceNotifyEvent;\n\ntypedef union _XkbEvent {\n\tint\t\t\t\ttype;\n\tXkbAnyEvent\t\t\tany;\n\tXkbNewKeyboardNotifyEvent\tnew_kbd;\n\tXkbMapNotifyEvent\t\tmap;\n\tXkbStateNotifyEvent\t\tstate;\n\tXkbControlsNotifyEvent\t\tctrls;\n\tXkbIndicatorNotifyEvent \tindicators;\n\tXkbNamesNotifyEvent\t\tnames;\n\tXkbCompatMapNotifyEvent\t\tcompat;\n\tXkbBellNotifyEvent\t\tbell;\n\tXkbActionMessageEvent\t\tmessage;\n\tXkbAccessXNotifyEvent\t\taccessx;\n\tXkbExtensionDeviceNotifyEvent \tdevice;\n\tXEvent\t\t\t\tcore;\n} XkbEvent;\n\ntypedef struct\t_XkbKbdDpyState\tXkbKbdDpyStateRec,*XkbKbdDpyStatePtr;\n\n\t/* XkbOpenDisplay error codes */\n#define\tXkbOD_Success\t\t0\n#define\tXkbOD_BadLibraryVersion\t1\n#define\tXkbOD_ConnectionRefused\t2\n#define\tXkbOD_NonXkbServer\t3\n#define\tXkbOD_BadServerVersion\t4\n\n\t/* Values for XlibFlags */\n#define\tXkbLC_ForceLatin1Lookup\t\t(1<<0)\n#define\tXkbLC_ConsumeLookupMods\t\t(1<<1)\n#define\tXkbLC_AlwaysConsumeShiftAndLock (1<<2)\n#define\tXkbLC_IgnoreNewKeyboards\t(1<<3)\n#define\tXkbLC_ControlFallback\t\t(1<<4)\n#define\tXkbLC_ConsumeKeysOnComposeFail\t(1<<29)\n#define\tXkbLC_ComposeLED\t\t(1<<30)\n#define\tXkbLC_BeepOnComposeFail\t\t(1<<31)\n\n#define\tXkbLC_AllComposeControls\t(0xc0000000)\n#define\tXkbLC_AllControls\t\t(0xc000001f)\n\n_XFUNCPROTOBEGIN\n\nextern\tBool\tXkbIgnoreExtension(\n\tBool\t\t\t/* ignore */\n);\n\nextern\tDisplay *XkbOpenDisplay(\n\tchar *\t\t\t/* name */,\n\tint *\t\t\t/* ev_rtrn */,\n\tint *\t\t\t/* err_rtrn */,\n\tint *\t\t\t/* major_rtrn */,\n\tint *\t\t\t/* minor_rtrn */,\n\tint *\t\t\t/* reason */\n);\n\nextern\tBool\tXkbQueryExtension(\n\tDisplay *\t\t/* dpy */,\n\tint *\t\t\t/* opcodeReturn */,\n\tint *\t\t\t/* eventBaseReturn */,\n\tint *\t\t\t/* errorBaseReturn */,\n\tint *\t\t\t/* majorRtrn */,\n\tint *\t\t\t/* minorRtrn */\n);\n\nextern\tBool\tXkbUseExtension(\n\tDisplay *\t\t/* dpy */,\n\tint *\t\t\t/* major_rtrn */,\n\tint *\t\t\t/* minor_rtrn */\n);\n\nextern\tBool\tXkbLibraryVersion(\n\tint *\t\t\t/* libMajorRtrn */,\n\tint *\t\t\t/* libMinorRtrn */\n);\n\nextern\tunsigned int\tXkbSetXlibControls(\n\tDisplay*\t\t/* dpy */,\n\tunsigned int\t\t/* affect */,\n\tunsigned int\t\t/* values */\n);\n\nextern\tunsigned int\tXkbGetXlibControls(\n\tDisplay*\t\t/* dpy */\n);\n\nextern\tunsigned int\tXkbXlibControlsImplemented(void);\n\ntypedef\tAtom\t(*XkbInternAtomFunc)(\n\tDisplay *\t\t/* dpy */,\n\t_Xconst char *\t\t/* name */,\n\tBool\t\t\t/* only_if_exists */\n);\n\ntypedef char *\t(*XkbGetAtomNameFunc)(\n\tDisplay *\t\t/* dpy */,\n\tAtom\t\t\t/* atom */\n);\n\nextern void\t\tXkbSetAtomFuncs(\n\tXkbInternAtomFunc\t/* getAtom */,\n\tXkbGetAtomNameFunc\t/* getName */\n);\n\nextern\tKeySym XkbKeycodeToKeysym(\n\t\tDisplay *\t/* dpy */,\n#if NeedWidePrototypes\n\t\t unsigned int \t/* kc */,\n#else\n\t\t KeyCode \t/* kc */,\n#endif\n\t\t int \t\t/* group */,\n\t\t int\t\t/* level */\n);\n\nextern\tunsigned int\tXkbKeysymToModifiers(\n    Display *\t\t\t/* dpy */,\n    KeySym \t\t\t/* ks */\n);\n\nextern\tBool\t\tXkbLookupKeySym(\n    Display *\t\t\t/* dpy */,\n    KeyCode \t\t\t/* keycode */,\n    unsigned int \t\t/* modifiers */,\n    unsigned int *\t\t/* modifiers_return */,\n    KeySym *\t\t\t/* keysym_return */\n);\n\nextern\tint\t\tXkbLookupKeyBinding(\n    Display *\t\t\t/* dpy */,\n    KeySym \t\t\t/* sym_rtrn */,\n    unsigned int \t\t/* mods */,\n    char *\t\t\t/* buffer */,\n    int \t\t\t/* nbytes */,\n    int * \t\t\t/* extra_rtrn */\n);\n\nextern\tBool\t\tXkbTranslateKeyCode(\n    XkbDescPtr\t\t\t/* xkb */,\n    KeyCode \t\t\t/* keycode */,\n    unsigned int \t\t/* modifiers */,\n    unsigned int *\t\t/* modifiers_return */,\n    KeySym *\t\t\t/* keysym_return */\n);\n\nextern\tint\t\tXkbTranslateKeySym(\n    Display *\t\t\t/* dpy */,\n    register KeySym *\t\t/* sym_return */,\n    unsigned int \t\t/* modifiers */,\n    char *\t\t\t/* buffer */,\n    int \t\t\t/* nbytes */,\n    int *\t\t\t/* extra_rtrn */\n);\n\nextern\tBool\tXkbSetAutoRepeatRate(\n\tDisplay *\t\t/* dpy */,\n\tunsigned int\t\t/* deviceSpec */,\n\tunsigned int\t\t/* delay */,\n\tunsigned int\t\t/* interval */\n);\n\nextern\tBool\tXkbGetAutoRepeatRate(\n\tDisplay *\t\t/* dpy */,\n\tunsigned int\t\t/* deviceSpec */,\n\tunsigned int *\t\t/* delayRtrn */,\n\tunsigned int *\t\t/* intervalRtrn */\n);\n\nextern\tBool\tXkbChangeEnabledControls(\n\tDisplay *\t\t/* dpy */,\n\tunsigned int\t\t/* deviceSpec */,\n\tunsigned int\t\t/* affect */,\n\tunsigned int\t\t/* values */\n);\n\nextern\tBool\tXkbDeviceBell(\n\tDisplay *\t\t/* dpy */,\n\tWindow\t\t\t/* win */,\n\tint\t\t\t/* deviceSpec */,\n\tint\t\t\t/* bellClass */,\n\tint\t\t\t/* bellID */,\n\tint\t\t\t/* percent */,\n\tAtom\t\t\t/* name */\n);\n\nextern\tBool\tXkbForceDeviceBell(\n\tDisplay *\t\t/* dpy */,\n\tint\t\t\t/* deviceSpec */,\n\tint\t\t\t/* bellClass */,\n\tint\t\t\t/* bellID */,\n\tint\t\t\t/* percent */\n);\n\nextern\tBool\tXkbDeviceBellEvent(\n\tDisplay *\t\t/* dpy */,\n\tWindow\t\t\t/* win */,\n\tint\t\t\t/* deviceSpec */,\n\tint\t\t\t/* bellClass */,\n\tint\t\t\t/* bellID */,\n\tint\t\t\t/* percent */,\n\tAtom\t\t\t/* name */\n);\n\nextern\tBool\tXkbBell(\n\tDisplay *\t\t/* dpy */,\n\tWindow\t\t\t/* win */,\n\tint\t\t\t/* percent */,\n\tAtom\t\t\t/* name */\n);\n\nextern\tBool\tXkbForceBell(\n\tDisplay *\t\t/* dpy */,\n\tint\t\t\t/* percent */\n);\n\nextern\tBool\tXkbBellEvent(\n\tDisplay *\t\t/* dpy */,\n\tWindow\t\t\t/* win */,\n\tint\t\t\t/* percent */,\n\tAtom\t\t\t/* name */\n);\n\nextern\tBool\tXkbSelectEvents(\n\tDisplay *\t\t/* dpy */,\n\tunsigned int\t\t/* deviceID */,\n\tunsigned int \t\t/* affect */,\n\tunsigned int \t\t/* values */\n);\n\nextern\tBool\tXkbSelectEventDetails(\n\tDisplay *\t\t/* dpy */,\n\tunsigned int \t\t/* deviceID */,\n\tunsigned int \t\t/* eventType */,\n\tunsigned long \t\t/* affect */,\n\tunsigned long \t\t/* details */\n);\n\nextern\tvoid\tXkbNoteMapChanges(\n    XkbMapChangesPtr\t\t/* old */,\n    XkbMapNotifyEvent\t*\t/* new */,\n    unsigned int\t \t/* wanted */\n);\n\nextern\tvoid\tXkbNoteNameChanges(\n    XkbNameChangesPtr\t\t/* old */,\n    XkbNamesNotifyEvent\t*\t/* new */,\n    unsigned int\t \t/* wanted */\n);\n\nextern\tStatus\tXkbGetIndicatorState(\n\tDisplay *\t\t/* dpy */,\n\tunsigned int\t\t/* deviceSpec */,\n\tunsigned int *\t\t/* pStateRtrn */\n);\n\nextern\tStatus\tXkbGetDeviceIndicatorState(\n\tDisplay *\t\t/* dpy */,\n\tunsigned int\t\t/* deviceSpec */,\n\tunsigned int\t\t/* ledClass */,\n\tunsigned int\t\t/* ledID */,\n\tunsigned int *\t\t/* pStateRtrn */\n);\n\nextern\tStatus\t XkbGetIndicatorMap(\n\tDisplay *\t\t/* dpy */,\n\tunsigned long\t\t/* which */,\n\tXkbDescPtr\t\t/* desc */\n);\n\nextern\tBool\t XkbSetIndicatorMap(\n\tDisplay *\t\t/* dpy */,\n\tunsigned long \t\t/* which */,\n\tXkbDescPtr\t\t/* desc */\n);\n\n#define\tXkbNoteIndicatorMapChanges(o,n,w) \\\n\t\t\t\t((o)->map_changes|=((n)->map_changes&(w)))\n#define\tXkbNoteIndicatorStateChanges(o,n,w)\\\n\t\t\t\t((o)->state_changes|=((n)->state_changes&(w)))\n#define\tXkbGetIndicatorMapChanges(d,x,c) \\\n\t\t\t\t(XkbGetIndicatorMap((d),(c)->map_changes,x))\n#define\tXkbChangeIndicatorMaps(d,x,c) \\\n\t\t\t\t(XkbSetIndicatorMap((d),(c)->map_changes,x))\n\nextern\tBool\tXkbGetNamedIndicator(\n\tDisplay *\t\t/* dpy */,\n\tAtom\t\t\t/* name */,\n\tint *\t\t\t/* pNdxRtrn */,\n\tBool *\t\t\t/* pStateRtrn */,\n\tXkbIndicatorMapPtr\t/* pMapRtrn */,\n\tBool *\t\t\t/* pRealRtrn */\n);\n\nextern\tBool\tXkbGetNamedDeviceIndicator(\n\tDisplay *\t\t/* dpy */,\n\tunsigned int\t\t/* deviceSpec */,\n\tunsigned int\t\t/* ledClass */,\n\tunsigned int\t\t/* ledID */,\n\tAtom\t\t\t/* name */,\n\tint *\t\t\t/* pNdxRtrn */,\n\tBool *\t\t\t/* pStateRtrn */,\n\tXkbIndicatorMapPtr\t/* pMapRtrn */,\n\tBool *\t\t\t/* pRealRtrn */\n);\n\nextern\tBool\tXkbSetNamedIndicator(\n\tDisplay *\t\t/* dpy */,\n\tAtom\t\t\t/* name */,\n\tBool\t\t\t/* changeState */,\n\tBool \t\t\t/* state */,\n\tBool\t\t\t/* createNewMap */,\n\tXkbIndicatorMapPtr\t/* pMap */\n);\n\nextern\tBool\tXkbSetNamedDeviceIndicator(\n\tDisplay *\t\t/* dpy */,\n\tunsigned int\t\t/* deviceSpec */,\n\tunsigned int\t\t/* ledClass */,\n\tunsigned int\t\t/* ledID */,\n\tAtom\t\t\t/* name */,\n\tBool\t\t\t/* changeState */,\n\tBool \t\t\t/* state */,\n\tBool\t\t\t/* createNewMap */,\n\tXkbIndicatorMapPtr\t/* pMap */\n);\n\nextern\tBool\tXkbLockModifiers(\n\tDisplay *\t\t/* dpy */,\n\tunsigned int \t\t/* deviceSpec */,\n\tunsigned int \t\t/* affect */,\n\tunsigned int \t\t/* values */\n);\n\nextern\tBool\tXkbLatchModifiers(\n\tDisplay *\t\t/* dpy */,\n\tunsigned int \t\t/* deviceSpec */,\n\tunsigned int \t\t/* affect */,\n\tunsigned int \t\t/* values */\n);\n\nextern\tBool\tXkbLockGroup(\n\tDisplay *\t\t/* dpy */,\n\tunsigned int \t\t/* deviceSpec */,\n\tunsigned int \t\t/* group */\n);\n\nextern\tBool\tXkbLatchGroup(\n\tDisplay *\t\t/* dpy */,\n\tunsigned int \t\t/* deviceSpec */,\n\tunsigned int \t\t/* group */\n);\n\nextern\tBool\tXkbSetServerInternalMods(\n\tDisplay *\t\t/* dpy */,\n\tunsigned int \t\t/* deviceSpec */,\n\tunsigned int \t\t/* affectReal */,\n\tunsigned int \t\t/* realValues */,\n\tunsigned int\t\t/* affectVirtual */,\n\tunsigned int\t\t/* virtualValues */\n);\n\nextern\tBool\tXkbSetIgnoreLockMods(\n\tDisplay *\t\t/* dpy */,\n\tunsigned int \t\t/* deviceSpec */,\n\tunsigned int \t\t/* affectReal */,\n\tunsigned int \t\t/* realValues */,\n\tunsigned int\t\t/* affectVirtual */,\n\tunsigned int\t\t/* virtualValues */\n);\n\n\nextern\tBool\tXkbVirtualModsToReal(\n\tXkbDescPtr\t\t/* xkb */,\n\tunsigned int\t\t/* virtual_mask */,\n\tunsigned int *\t\t/* mask_rtrn */\n);\n\nextern\tBool\tXkbComputeEffectiveMap(\n\tXkbDescPtr \t\t/* xkb */,\n\tXkbKeyTypePtr\t\t/* type */,\n\tunsigned char *\t\t/* map_rtrn */\n);\n\nextern\tStatus XkbInitCanonicalKeyTypes(\n    XkbDescPtr\t\t\t/* xkb */,\n    unsigned int\t\t/* which */,\n    int\t\t\t\t/* keypadVMod */\n);\n\nextern\tXkbDescPtr XkbAllocKeyboard(\n\tvoid\n);\n\nextern\tvoid\tXkbFreeKeyboard(\n\tXkbDescPtr\t\t/* xkb */,\n\tunsigned int\t\t/* which */,\n\tBool\t\t\t/* freeDesc */\n);\n\nextern\tStatus XkbAllocClientMap(\n\tXkbDescPtr\t\t/* xkb */,\n\tunsigned int\t\t/* which */,\n\tunsigned int\t\t/* nTypes */\n);\n\nextern\tStatus XkbAllocServerMap(\n\tXkbDescPtr\t\t/* xkb */,\n\tunsigned int\t\t/* which */,\n\tunsigned int\t\t/* nActions */\n);\n\nextern\tvoid\tXkbFreeClientMap(\n    XkbDescPtr\t\t\t/* xkb */,\n    unsigned int\t\t/* what */,\n    Bool\t\t\t/* freeMap */\n);\n\nextern\tvoid\tXkbFreeServerMap(\n    XkbDescPtr\t\t\t/* xkb */,\n    unsigned int\t\t/* what */,\n    Bool\t\t\t/* freeMap */\n);\n\nextern\tXkbKeyTypePtr\tXkbAddKeyType(\n    XkbDescPtr\t\t\t/* xkb */,\n    Atom\t\t\t/* name */,\n    int\t\t\t\t/* map_count */,\n    Bool\t\t\t/* want_preserve */,\n    int\t\t\t\t/* num_lvls */\n);\n\nextern\tStatus XkbAllocIndicatorMaps(\n\tXkbDescPtr\t\t/* xkb */\n);\n\nextern\tvoid XkbFreeIndicatorMaps(\n    XkbDescPtr\t\t\t/* xkb */\n);\n\nextern\tXkbDescPtr XkbGetMap(\n\tDisplay *\t\t/* dpy */,\n\tunsigned int \t\t/* which */,\n\tunsigned int \t\t/* deviceSpec */\n);\n\nextern\tStatus\tXkbGetUpdatedMap(\n\tDisplay *\t\t/* dpy */,\n\tunsigned int \t\t/* which */,\n\tXkbDescPtr\t\t/* desc */\n);\n\nextern\tStatus\tXkbGetMapChanges(\n    Display *\t\t\t/* dpy */,\n    XkbDescPtr\t\t\t/* xkb */,\n    XkbMapChangesPtr\t\t/* changes */\n);\n\n\nextern\tStatus\tXkbRefreshKeyboardMapping(\n    XkbMapNotifyEvent *\t\t/* event */\n);\n\nextern\tStatus\tXkbGetKeyTypes(\n    Display *\t\t\t/* dpy */,\n    unsigned int\t\t/* first */,\n    unsigned int \t\t/* num */,\n    XkbDescPtr\t\t\t/* xkb */\n);\n\nextern\tStatus\tXkbGetKeySyms(\n    Display *\t\t\t/* dpy */,\n    unsigned int\t\t/* first */,\n    unsigned int\t\t/* num */,\n    XkbDescPtr\t\t\t/* xkb */\n);\n\nextern\tStatus\tXkbGetKeyActions(\n    Display *\t\t\t/* dpy */,\n    unsigned int \t\t/* first */,\n    unsigned int \t\t/* num */,\n    XkbDescPtr\t\t\t/* xkb */\n);\n\nextern\tStatus\tXkbGetKeyBehaviors(\n\tDisplay *\t\t/* dpy */,\n\tunsigned int \t\t/* firstKey */,\n\tunsigned int\t\t/* nKeys */,\n\tXkbDescPtr\t\t/* desc */\n);\n\nextern\tStatus\tXkbGetVirtualMods(\n\tDisplay *\t\t/* dpy */,\n\tunsigned int \t\t/* which */,\n\tXkbDescPtr\t\t/* desc */\n);\n\nextern\tStatus\tXkbGetKeyExplicitComponents(\n\tDisplay *\t\t/* dpy */,\n\tunsigned int \t\t/* firstKey */,\n\tunsigned int\t\t/* nKeys */,\n\tXkbDescPtr\t\t/* desc */\n);\n\nextern\tStatus\tXkbGetKeyModifierMap(\n\tDisplay *\t\t/* dpy */,\n\tunsigned int \t\t/* firstKey */,\n\tunsigned int\t\t/* nKeys */,\n\tXkbDescPtr\t\t/* desc */\n);\n\nextern\tStatus\tXkbGetKeyVirtualModMap(\n\tDisplay *\t\t/* dpy */,\n\tunsigned int\t\t/* first */,\n\tunsigned int\t\t/* num */,\n\tXkbDescPtr\t\t/* xkb */\n);\n\nextern\tStatus\tXkbAllocControls(\n\tXkbDescPtr\t\t/* xkb */,\n\tunsigned int\t\t/* which*/\n);\n\nextern\tvoid\tXkbFreeControls(\n\tXkbDescPtr\t\t/* xkb */,\n\tunsigned int\t\t/* which */,\n\tBool\t\t\t/* freeMap */\n);\n\nextern\tStatus\tXkbGetControls(\n\tDisplay *\t\t/* dpy */,\n\tunsigned long\t\t/* which */,\n\tXkbDescPtr\t\t/* desc */\n);\n\nextern\tBool\tXkbSetControls(\n\tDisplay *\t\t/* dpy */,\n\tunsigned long\t\t/* which */,\n\tXkbDescPtr\t\t/* desc */\n);\n\nextern\tvoid\tXkbNoteControlsChanges(\n    XkbControlsChangesPtr\t/* old */,\n    XkbControlsNotifyEvent *\t/* new */,\n    unsigned int\t \t/* wanted */\n);\n\n#define\tXkbGetControlsChanges(d,x,c)\tXkbGetControls(d,(c)->changed_ctrls,x)\n#define\tXkbChangeControls(d,x,c)\tXkbSetControls(d,(c)->changed_ctrls,x)\n\nextern\tStatus\tXkbAllocCompatMap(\n    XkbDescPtr\t\t\t/* xkb */,\n    unsigned int\t\t/* which */,\n    unsigned int\t\t/* nInterpret */\n);\n\nextern\tvoid\tXkbFreeCompatMap(\n    XkbDescPtr\t\t\t/* xkb */,\n    unsigned int\t\t/* which */,\n    Bool\t\t\t/* freeMap */\n);\n\nextern Status XkbGetCompatMap(\n\tDisplay *\t\t/* dpy */,\n\tunsigned int \t\t/* which */,\n\tXkbDescPtr \t\t/* xkb */\n);\n\nextern Bool XkbSetCompatMap(\n\tDisplay *\t\t/* dpy */,\n\tunsigned int \t\t/* which */,\n\tXkbDescPtr \t\t/* xkb */,\n\tBool\t\t\t/* updateActions */\n);\n\nextern\tXkbSymInterpretPtr XkbAddSymInterpret(\n\tXkbDescPtr\t\t/* xkb */,\n\tXkbSymInterpretPtr\t/* si */,\n\tBool\t\t\t/* updateMap */,\n\tXkbChangesPtr\t\t/* changes */\n);\n\nextern\tStatus XkbAllocNames(\n\tXkbDescPtr\t\t/* xkb */,\n\tunsigned int\t\t/* which */,\n\tint\t\t\t/* nTotalRG */,\n\tint\t\t\t/* nTotalAliases */\n);\n\nextern\tStatus\tXkbGetNames(\n\tDisplay *\t\t/* dpy */,\n\tunsigned int\t\t/* which */,\n\tXkbDescPtr\t\t/* desc */\n);\n\nextern\tBool\tXkbSetNames(\n\tDisplay *\t\t/* dpy */,\n\tunsigned int\t\t/* which */,\n\tunsigned int\t\t/* firstType */,\n\tunsigned int\t\t/* nTypes */,\n\tXkbDescPtr\t\t/* desc */\n);\n\nextern\tBool\tXkbChangeNames(\n\tDisplay *\t\t/* dpy */,\n\tXkbDescPtr\t\t/* xkb */,\n\tXkbNameChangesPtr\t/* changes */\n);\n\nextern\tvoid XkbFreeNames(\n\tXkbDescPtr\t\t/* xkb */,\n\tunsigned int\t\t/* which */,\n\tBool\t\t\t/* freeMap */\n);\n\n\nextern\tStatus\tXkbGetState(\n\tDisplay *\t\t/* dpy */,\n\tunsigned int \t\t/* deviceSpec */,\n\tXkbStatePtr\t\t/* rtrnState */\n);\n\nextern\tBool\tXkbSetMap(\n\tDisplay *\t\t/* dpy */,\n\tunsigned int\t\t/* which */,\n\tXkbDescPtr\t\t/* desc */\n);\n\nextern\tBool\tXkbChangeMap(\n\tDisplay*\t\t/* dpy */,\n\tXkbDescPtr\t\t/* desc */,\n\tXkbMapChangesPtr\t/* changes */\n);\n\nextern\tBool\tXkbSetDetectableAutoRepeat(\n\tDisplay *\t\t/* dpy */,\n\tBool\t\t\t/* detectable */,\n\tBool *\t\t\t/* supported */\n);\n\nextern\tBool\tXkbGetDetectableAutoRepeat(\n\tDisplay *\t\t/* dpy */,\n\tBool *\t\t\t/* supported */\n);\n\nextern\tBool\tXkbSetAutoResetControls(\n    Display *\t\t\t/* dpy */,\n    unsigned int \t\t/* changes */,\n    unsigned int *\t\t/* auto_ctrls */,\n    unsigned int *\t\t/* auto_values */\n);\n\nextern\tBool\tXkbGetAutoResetControls(\n    Display *\t\t\t/* dpy */,\n    unsigned int *\t\t/* auto_ctrls */,\n    unsigned int *\t\t/* auto_ctrl_values */\n);\n\nextern\tBool\tXkbSetPerClientControls(\n    Display *\t\t\t/* dpy */,\n    unsigned int\t\t/* change */,\n    unsigned int *\t\t/* values */\n);\n\nextern\tBool\tXkbGetPerClientControls(\n    Display *\t\t\t/* dpy */,\n    unsigned int *\t\t/* ctrls */\n);\n\nextern Status XkbCopyKeyType(\n    XkbKeyTypePtr\t/* from */,\n    XkbKeyTypePtr\t/* into */\n);\n\nextern Status XkbCopyKeyTypes(\n    XkbKeyTypePtr\t/* from */,\n    XkbKeyTypePtr\t/* into */,\n    int\t\t\t/* num_types */\n);\n\nextern\tStatus\tXkbResizeKeyType(\n    XkbDescPtr\t\t/* xkb */,\n    int\t\t\t/* type_ndx */,\n    int\t\t\t/* map_count */,\n    Bool\t\t/* want_preserve */,\n    int\t\t\t/* new_num_lvls */\n);\n\nextern\tKeySym *XkbResizeKeySyms(\n\tXkbDescPtr\t\t/* desc */,\n\tint \t\t\t/* forKey */,\n\tint \t\t\t/* symsNeeded */\n);\n\nextern\tXkbAction *XkbResizeKeyActions(\n\tXkbDescPtr\t\t/* desc */,\n\tint \t\t\t/* forKey */,\n\tint \t\t\t/* actsNeeded */\n);\n\nextern\tStatus XkbChangeTypesOfKey(\n\tXkbDescPtr\t\t/* xkb */,\n\tint \t\t\t/* key */,\n\tint\t\t\t/* num_groups */,\n\tunsigned int\t\t/* groups */,\n\tint *\t\t\t/* newTypes */,\n\tXkbMapChangesPtr\t/* pChanges */\n);\n\nextern  Status   XkbChangeKeycodeRange(\n\tXkbDescPtr\t\t/* xkb */,\n\tint\t\t\t/* minKC */,\n\tint\t\t\t/* maxKC */,\n\tXkbChangesPtr\t\t/* changes */\n);\n\n/***====================================================================***/\n\nextern\tXkbComponentListPtr\tXkbListComponents(\n\tDisplay *\t\t/* dpy */,\n\tunsigned int\t\t/* deviceSpec */,\n\tXkbComponentNamesPtr\t/* ptrns */,\n\tint *\t\t\t/* max_inout */\n);\n\nextern\tvoid XkbFreeComponentList(\n\tXkbComponentListPtr\t/* list */\n);\n\nextern\tXkbDescPtr XkbGetKeyboard(\n\tDisplay *\t\t/* dpy */,\n\tunsigned int \t\t/* which */,\n\tunsigned int \t\t/* deviceSpec */\n);\n\nextern XkbDescPtr XkbGetKeyboardByName(\n    Display *\t\t\t/* dpy */,\n    unsigned int\t\t/* deviceSpec */,\n    XkbComponentNamesPtr\t/* names */,\n    unsigned int \t\t/* want */,\n    unsigned int \t\t/* need */,\n    Bool\t\t\t/* load */\n);\n\n/***====================================================================***/\n\nextern\tint\tXkbKeyTypesForCoreSymbols(\t/* returns # of groups */\n    XkbDescPtr\t/* xkb */,\t\t\t/* keyboard device */\n    int\t\t/* map_width */,\t\t/* width of core KeySym array */\n    KeySym *\t/* core_syms */,\t\t/* always mapWidth symbols */\n    unsigned int\t/* protected */,\t/* explicit key types */\n    int *\t/* types_inout */,\t\t/* always four type indices */\n    KeySym * \t/* xkb_syms_rtrn */\t\t/* must have enough space */\n);\n\nextern\tBool\tXkbApplyCompatMapToKey(\t/* False only on error */\n    XkbDescPtr\t\t/* xkb */,\t\t/* keymap to be edited */\n    KeyCode\t\t/* key */,\t\t/* key to be updated */\n    XkbChangesPtr\t/* changes */\t\t/* resulting changes to map */\n);\n\nextern\tBool\tXkbUpdateMapFromCore( /* False only on error */\n    XkbDescPtr\t\t/* xkb */,\t\t/* XKB keyboard to be edited */\n    KeyCode\t\t/* first_key */,\t/* first changed key */\n    int\t\t\t/* num_keys */, \t/* number of changed keys */\n    int\t\t\t/* map_width */,\t/* width of core keymap */\n    KeySym *\t\t/* core_keysyms */,\t/* symbols from core keymap */\n    XkbChangesPtr\t/* changes */\t\t/* resulting changes */\n);\n\n/***====================================================================***/\n\nextern\tXkbDeviceLedInfoPtr\tXkbAddDeviceLedInfo(\n\tXkbDeviceInfoPtr\t/* devi */,\n\tunsigned int\t\t/* ledClass */,\n\tunsigned int\t\t/* ledId */\n);\n\nextern\tStatus\t\t\tXkbResizeDeviceButtonActions(\n\tXkbDeviceInfoPtr\t/* devi */,\n\tunsigned int\t\t/* newTotal */\n);\n\nextern\tXkbDeviceInfoPtr\tXkbAllocDeviceInfo(\n\tunsigned int\t\t/* deviceSpec */,\n\tunsigned int\t\t/* nButtons */,\n\tunsigned int\t\t/* szLeds */\n);\n\nextern\tvoid XkbFreeDeviceInfo(\n\tXkbDeviceInfoPtr\t/* devi */,\n\tunsigned int\t\t/* which */,\n\tBool\t\t\t/* freeDevI */\n);\n\nextern\tvoid\tXkbNoteDeviceChanges(\n    XkbDeviceChangesPtr\t\t\t/* old */,\n    XkbExtensionDeviceNotifyEvent *\t/* new */,\n    unsigned int\t \t\t/* wanted */\n);\n\nextern\tXkbDeviceInfoPtr XkbGetDeviceInfo(\n\tDisplay *\t\t/* dpy */,\n\tunsigned int \t\t/* which */,\n\tunsigned int\t\t/* deviceSpec */,\n\tunsigned int\t\t/* ledClass */,\n\tunsigned int\t\t/* ledID */\n);\n\nextern\tStatus\tXkbGetDeviceInfoChanges(\n\tDisplay *\t\t/* dpy */,\n\tXkbDeviceInfoPtr\t/* devi */,\n\tXkbDeviceChangesPtr \t/* changes */\n);\n\nextern\tStatus\tXkbGetDeviceButtonActions(\n\tDisplay *\t\t/* dpy */,\n\tXkbDeviceInfoPtr\t/* devi */,\n\tBool\t\t\t/* all */,\n\tunsigned int\t\t/* first */,\n\tunsigned int\t\t/* nBtns */\n);\n\nextern\tStatus\tXkbGetDeviceLedInfo(\n\tDisplay *\t\t/* dpy */,\n\tXkbDeviceInfoPtr\t/* devi */,\n\tunsigned int\t\t/* ledClass (class, XIDflt, XIAll) */,\n\tunsigned int\t\t/* ledId (id, XIDflt, XIAll) */,\n\tunsigned int\t\t/* which (XkbXI_Indicator{Names,Map}Mask */\n);\n\nextern\tBool\tXkbSetDeviceInfo(\n\tDisplay *\t\t/* dpy */,\n\tunsigned int\t\t/* which */,\n\tXkbDeviceInfoPtr\t/* devi */\n);\n\nextern\tBool\tXkbChangeDeviceInfo(\n\tDisplay*\t\t/* dpy */,\n\tXkbDeviceInfoPtr\t/* desc */,\n\tXkbDeviceChangesPtr\t/* changes */\n);\n\nextern  Bool XkbSetDeviceLedInfo(\n\tDisplay *\t\t/* dpy */,\n\tXkbDeviceInfoPtr\t/* devi */,\n\tunsigned int \t\t/* ledClass */,\n\tunsigned int\t\t/* ledID */,\n\tunsigned int\t\t/* which */\n);\n\nextern\tBool XkbSetDeviceButtonActions(\n\tDisplay *\t\t/* dpy */,\n\tXkbDeviceInfoPtr\t/* devi */,\n\tunsigned int\t\t/* first */,\n\tunsigned int\t\t/* nBtns */\n);\n\n/***====================================================================***/\n\nextern\tchar\tXkbToControl(\n\tchar\t\t/* c */\n);\n\n/***====================================================================***/\n\nextern\tBool XkbSetDebuggingFlags(\n    Display *\t\t/* dpy */,\n    unsigned int\t/* mask */,\n    unsigned int\t/* flags */,\n    char *\t\t/* msg */,\n    unsigned int\t/* ctrls_mask */,\n    unsigned int\t/* ctrls */,\n    unsigned int *\t/* rtrn_flags */,\n    unsigned int *\t/* rtrn_ctrls */\n);\n\nextern\tBool XkbApplyVirtualModChanges(\n   XkbDescPtr\t\t/* xkb */,\n   unsigned int\t\t/* changed */,\n   XkbChangesPtr\t/* changes */\n);\n\nextern Bool XkbUpdateActionVirtualMods(\n\tXkbDescPtr\t\t/* xkb */,\n\tXkbAction *\t\t/* act */,\n\tunsigned int\t\t/* changed */\n);\n\nextern void XkbUpdateKeyTypeVirtualMods(\n\tXkbDescPtr\t\t/* xkb */,\n\tXkbKeyTypePtr\t\t/* type */,\n\tunsigned int\t\t/* changed */,\n\tXkbChangesPtr\t\t/* changes */\n);\n\n_XFUNCPROTOEND\n\n#endif /* _X11_XKBLIB_H_ */\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/X11/XWDFile.h",
    "content": "/*\n\nCopyright 1985, 1986, 1998  The Open Group\n\nPermission to use, copy, modify, distribute, and sell this software and its\ndocumentation for any purpose is hereby granted without fee, provided that\nthe above copyright notice appear in all copies and that both that\ncopyright notice and this permission notice appear in supporting\ndocumentation.\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE\nOPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN\nAN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\nCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\nExcept as contained in this notice, the name of The Open Group shall not be\nused in advertising or otherwise to promote the sale, use or other dealings\nin this Software without prior written authorization from The Open Group.\n\n*/\n\n/*\n * XWDFile.h\tMIT Project Athena, X Window system window raster\n *\t\timage dumper, dump file format header file.\n *\n *  Author:\tTony Della Fera, DEC\n *\t\t27-Jun-85\n * \n * Modifier:    William F. Wyatt, SAO\n *              18-Nov-86  - version 6 for saving/restoring color maps\n */\n\n#ifndef XWDFILE_H\n#define XWDFILE_H\n\n#include <X11/Xmd.h>\n\n#define XWD_FILE_VERSION 7\n#define sz_XWDheader 100\n#define sz_XWDColor 12\n\ntypedef CARD32 xwdval;\t\t/* for old broken programs */\n\n/* Values in the file are most significant byte first. */\n\ntypedef struct _xwd_file_header {\n\t/* header_size = SIZEOF(XWDheader) + length of null-terminated\n\t * window name. */\n\tCARD32 header_size B32;\t\t\n\n\tCARD32 file_version B32;\t/* = XWD_FILE_VERSION above */\n\tCARD32 pixmap_format B32;\t/* ZPixmap or XYPixmap */\n\tCARD32 pixmap_depth B32;\t/* Pixmap depth */\n\tCARD32 pixmap_width B32;\t/* Pixmap width */\n\tCARD32 pixmap_height B32;\t/* Pixmap height */\n\tCARD32 xoffset B32;\t\t/* Bitmap x offset, normally 0 */\n\tCARD32 byte_order B32;\t\t/* of image data: MSBFirst, LSBFirst */\n\n\t/* bitmap_unit applies to bitmaps (depth 1 format XY) only.\n\t * It is the number of bits that each scanline is padded to. */\n\tCARD32 bitmap_unit B32;\t\t\n\n\tCARD32 bitmap_bit_order B32;\t/* bitmaps only: MSBFirst, LSBFirst */\n\n\t/* bitmap_pad applies to pixmaps (non-bitmaps) only.\n\t * It is the number of bits that each scanline is padded to. */\n\tCARD32 bitmap_pad B32;\t\t\n\n\tCARD32 bits_per_pixel B32;\t/* Bits per pixel */\n\n\t/* bytes_per_line is pixmap_width padded to bitmap_unit (bitmaps)\n\t * or bitmap_pad (pixmaps).  It is the delta (in bytes) to get\n\t * to the same x position on an adjacent row. */\n\tCARD32 bytes_per_line B32;\n\tCARD32 visual_class B32;\t/* Class of colormap */\n\tCARD32 red_mask B32;\t\t/* Z red mask */\n\tCARD32 green_mask B32;\t\t/* Z green mask */\n\tCARD32 blue_mask B32;\t\t/* Z blue mask */\n\tCARD32 bits_per_rgb B32;\t/* Log2 of distinct color values */\n\tCARD32 colormap_entries B32;\t/* Number of entries in colormap; not used? */\n\tCARD32 ncolors B32;\t\t/* Number of XWDColor structures */\n\tCARD32 window_width B32;\t/* Window width */\n\tCARD32 window_height B32;\t/* Window height */\n\tCARD32 window_x B32;\t\t/* Window upper left X coordinate */\n\tCARD32 window_y B32;\t\t/* Window upper left Y coordinate */\n\tCARD32 window_bdrwidth B32;\t/* Window border width */\n} XWDFileHeader;\n\n/* Null-terminated window name follows the above structure. */\n\n/* Next comes XWDColor structures, at offset XWDFileHeader.header_size in\n * the file.  XWDFileHeader.ncolors tells how many XWDColor structures\n * there are.\n */\n\ntypedef struct {\n        CARD32\tpixel B32;\n        CARD16\tred B16;\n\tCARD16\tgreen B16;\n\tCARD16\tblue B16;\n        CARD8\tflags;\n        CARD8\tpad;\n} XWDColor;\n\n/* Last comes the image data in the format described by XWDFileHeader. */\n\n#endif /* XWDFILE_H */\n\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/X11/Xalloca.h",
    "content": "/*\n\nCopyright 1995, 1998  The Open Group\n\nPermission to use, copy, modify, distribute, and sell this software and its\ndocumentation for any purpose is hereby granted without fee, provided that\nthe above copyright notice appear in all copies and that both that\ncopyright notice and this permission notice appear in supporting\ndocumentation.\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR\nOTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,\nARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\nOTHER DEALINGS IN THE SOFTWARE.\n\nExcept as contained in this notice, the name of The Open Group shall\nnot be used in advertising or otherwise to promote the sale, use or\nother dealings in this Software without prior written authorization\nfrom The Open Group.\n\n*/\n/*\n * The purpose of this header is to define the macros ALLOCATE_LOCAL and\n * DEALLOCATE_LOCAL appropriately for the platform being compiled on.\n * These macros are used to make fast, function-local memory allocations.\n * Their characteristics are as follows:\n *\n * void *ALLOCATE_LOCAL(int size)\n *    Returns a pointer to size bytes of memory, or NULL if the allocation\n *    failed.  The memory must be freed with DEALLOCATE_LOCAL before the\n *    function that made the allocation returns.  You should not ask for\n *    large blocks of memory with this function, since on many platforms\n *    the memory comes from the stack, which may have limited size.\n *\n * void DEALLOCATE_LOCAL(void *)\n *    Frees the memory allocated by ALLOCATE_LOCAL.  Omission of this\n *    step may be harmless on some platforms, but will result in\n *    memory leaks or worse on others.\n *\n * Before including this file, you should define two macros,\n * ALLOCATE_LOCAL_FALLBACK and DEALLOCATE_LOCAL_FALLBACK, that have the\n * same characteristics as ALLOCATE_LOCAL and DEALLOCATE_LOCAL.  The\n * header uses the fallbacks if it doesn't know a \"better\" way to define\n * ALLOCATE_LOCAL and DEALLOCATE_LOCAL.  Typical usage would be:\n *\n *    #define ALLOCATE_LOCAL_FALLBACK(_size) malloc(_size)\n *    #define DEALLOCATE_LOCAL_FALLBACK(_ptr) free(_ptr)\n *    #include \"Xalloca.h\"\n */\n\n#ifndef XALLOCA_H\n#define XALLOCA_H 1\n\n#ifndef INCLUDE_ALLOCA_H\n/* Need to add more here to match Imake *.cf's */\n# if defined(HAVE_ALLOCA_H) || defined(__SUNPRO_C) || defined(__SUNPRO_CC)\n#  define INCLUDE_ALLOCA_H\n# endif\n#endif\n\n#ifdef INCLUDE_ALLOCA_H\n#  include <alloca.h>\n#endif\n\n#ifndef NO_ALLOCA\n/*\n * os-dependent definition of local allocation and deallocation\n * If you want something other than (DE)ALLOCATE_LOCAL_FALLBACK\n * for ALLOCATE/DEALLOCATE_LOCAL then you add that in here.\n */\n\n\n#  ifdef __GNUC__\n#    ifndef alloca\n#      define alloca __builtin_alloca\n#    endif /* !alloca */\n#    define ALLOCATE_LOCAL(size) alloca((int)(size))\n#  else /* ! __GNUC__ */\n\n/*\n * warning: old mips alloca (pre 2.10) is unusable, new one is built in\n * Test is easy, the new one is named __builtin_alloca and comes\n * from alloca.h which #defines alloca.\n */\n#      if defined(__sun) || defined(alloca)\n/*\n * Some System V boxes extract alloca.o from /lib/libPW.a; if you\n * decide that you don't want to use alloca, you might want to fix it here.\n */\n/* alloca might be a macro taking one arg (hi, Sun!), so give it one. */\n#        if !defined(__cplusplus)\n#          define __Xnullarg\t\t/* as nothing */\n           extern void *alloca(__Xnullarg);\n#        endif\n#        define ALLOCATE_LOCAL(size) alloca((int)(size))\n#      endif /* who does alloca */\n#  endif /* __GNUC__ */\n\n#endif /* NO_ALLOCA */\n\n#if !defined(ALLOCATE_LOCAL)\n#  if defined(ALLOCATE_LOCAL_FALLBACK) && defined(DEALLOCATE_LOCAL_FALLBACK)\n#    define ALLOCATE_LOCAL(_size)  ALLOCATE_LOCAL_FALLBACK(_size)\n#    define DEALLOCATE_LOCAL(_ptr) DEALLOCATE_LOCAL_FALLBACK(_ptr)\n#  else /* no fallbacks supplied; error */\n#    define ALLOCATE_LOCAL(_size)  ALLOCATE_LOCAL_FALLBACK undefined!\n#    define DEALLOCATE_LOCAL(_ptr) DEALLOCATE_LOCAL_FALLBACK undefined!\n#  endif /* defined(ALLOCATE_LOCAL_FALLBACK && DEALLOCATE_LOCAL_FALLBACK) */\n#else\n#  if !defined(DEALLOCATE_LOCAL)\n#    define DEALLOCATE_LOCAL(_ptr) do {} while(0)\n#  endif\n#endif /* defined(ALLOCATE_LOCAL) */\n\n#endif /* XALLOCA_H */\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/X11/Xarch.h",
    "content": "#ifndef _XARCH_H_\n# define _XARCH_H_\n\n/*\n * Copyright 1997 Metro Link Incorporated\n *\n *                           All Rights Reserved\n *\n * Permission to use, copy, modify, distribute, and sell this software and its\n * documentation for any purpose is hereby granted without fee, provided that\n * the above copyright notice appear in all copies and that both that\n * copyright notice and this permission notice appear in supporting\n * documentation, and that the names of the above listed copyright holder(s)\n * not be used in advertising or publicity pertaining to distribution of\n * the software without specific, written prior permission.  The above listed\n * copyright holder(s) make(s) no representations about the suitability of\n * this software for any purpose.  It is provided \"as is\" without express or\n * implied warranty.\n *\n * THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM(S) ALL WARRANTIES WITH REGARD\n * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\n * AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE\n * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY\n * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER\n * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING\n * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n */\n\n\n/*\n * Determine the machine's byte order.\n */\n\n/* See if it is set in the imake config first */\n# ifdef X_BYTE_ORDER\n\n#  define X_BIG_ENDIAN 4321\n#  define X_LITTLE_ENDIAN 1234\n\n# else\n\n#  if defined(SVR4) || defined(__SVR4)\n#   include <sys/types.h>\n#   include <sys/byteorder.h>\n#  elif defined(CSRG_BASED)\n#   if defined(__NetBSD__) || defined(__OpenBSD__)\n#    include <sys/types.h>\n#   endif\n#   include <machine/endian.h>\n#  elif defined(linux)\n#   if defined __STRICT_ANSI__\n#    undef __STRICT_ANSI__\n#    include <endian.h>\n#    define __STRICT_ANSI__\n#   else\n#    include <endian.h>\n#   endif\n/* 'endian.h' might have been included before 'Xarch.h' */\n#   if !defined(LITTLE_ENDIAN) && defined(__LITTLE_ENDIAN)\n#    define LITTLE_ENDIAN __LITTLE_ENDIAN\n#   endif\n#   if !defined(BIG_ENDIAN) && defined(__BIG_ENDIAN)\n#    define BIG_ENDIAN __BIG_ENDIAN\n#   endif\n#   if !defined(PDP_ENDIAN) && defined(__PDP_ENDIAN)\n#    define PDP_ENDIAN __PDP_ENDIAN\n#   endif\n#   if !defined(BYTE_ORDER) && defined(__BYTE_ORDER)\n#    define BYTE_ORDER __BYTE_ORDER\n#   endif\n#  endif\n\n#  ifndef BYTE_ORDER\n#   define LITTLE_ENDIAN 1234\n#   define BIG_ENDIAN    4321\n\n#   if defined(__sun) && defined(__SVR4)\n#    include <sys/isa_defs.h>\n#    ifdef _LITTLE_ENDIAN\n#     define BYTE_ORDER LITTLE_ENDIAN\n#    endif\n#    ifdef _BIG_ENDIAN\n#     define BYTE_ORDER BIG_ENDIAN\n#    endif\n#   endif /* sun */\n#  endif /* BYTE_ORDER */\n\n#  define X_BYTE_ORDER BYTE_ORDER\n#  define X_BIG_ENDIAN BIG_ENDIAN\n#  define X_LITTLE_ENDIAN LITTLE_ENDIAN\n\n# endif /* not in imake config */\n\n#endif /* _XARCH_H_ */\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/X11/Xatom.h",
    "content": "#ifndef XATOM_H\n#define XATOM_H 1\n\n/* THIS IS A GENERATED FILE\n *\n * Do not change!  Changing this file implies a protocol change!\n */\n\n#define XA_PRIMARY ((Atom) 1)\n#define XA_SECONDARY ((Atom) 2)\n#define XA_ARC ((Atom) 3)\n#define XA_ATOM ((Atom) 4)\n#define XA_BITMAP ((Atom) 5)\n#define XA_CARDINAL ((Atom) 6)\n#define XA_COLORMAP ((Atom) 7)\n#define XA_CURSOR ((Atom) 8)\n#define XA_CUT_BUFFER0 ((Atom) 9)\n#define XA_CUT_BUFFER1 ((Atom) 10)\n#define XA_CUT_BUFFER2 ((Atom) 11)\n#define XA_CUT_BUFFER3 ((Atom) 12)\n#define XA_CUT_BUFFER4 ((Atom) 13)\n#define XA_CUT_BUFFER5 ((Atom) 14)\n#define XA_CUT_BUFFER6 ((Atom) 15)\n#define XA_CUT_BUFFER7 ((Atom) 16)\n#define XA_DRAWABLE ((Atom) 17)\n#define XA_FONT ((Atom) 18)\n#define XA_INTEGER ((Atom) 19)\n#define XA_PIXMAP ((Atom) 20)\n#define XA_POINT ((Atom) 21)\n#define XA_RECTANGLE ((Atom) 22)\n#define XA_RESOURCE_MANAGER ((Atom) 23)\n#define XA_RGB_COLOR_MAP ((Atom) 24)\n#define XA_RGB_BEST_MAP ((Atom) 25)\n#define XA_RGB_BLUE_MAP ((Atom) 26)\n#define XA_RGB_DEFAULT_MAP ((Atom) 27)\n#define XA_RGB_GRAY_MAP ((Atom) 28)\n#define XA_RGB_GREEN_MAP ((Atom) 29)\n#define XA_RGB_RED_MAP ((Atom) 30)\n#define XA_STRING ((Atom) 31)\n#define XA_VISUALID ((Atom) 32)\n#define XA_WINDOW ((Atom) 33)\n#define XA_WM_COMMAND ((Atom) 34)\n#define XA_WM_HINTS ((Atom) 35)\n#define XA_WM_CLIENT_MACHINE ((Atom) 36)\n#define XA_WM_ICON_NAME ((Atom) 37)\n#define XA_WM_ICON_SIZE ((Atom) 38)\n#define XA_WM_NAME ((Atom) 39)\n#define XA_WM_NORMAL_HINTS ((Atom) 40)\n#define XA_WM_SIZE_HINTS ((Atom) 41)\n#define XA_WM_ZOOM_HINTS ((Atom) 42)\n#define XA_MIN_SPACE ((Atom) 43)\n#define XA_NORM_SPACE ((Atom) 44)\n#define XA_MAX_SPACE ((Atom) 45)\n#define XA_END_SPACE ((Atom) 46)\n#define XA_SUPERSCRIPT_X ((Atom) 47)\n#define XA_SUPERSCRIPT_Y ((Atom) 48)\n#define XA_SUBSCRIPT_X ((Atom) 49)\n#define XA_SUBSCRIPT_Y ((Atom) 50)\n#define XA_UNDERLINE_POSITION ((Atom) 51)\n#define XA_UNDERLINE_THICKNESS ((Atom) 52)\n#define XA_STRIKEOUT_ASCENT ((Atom) 53)\n#define XA_STRIKEOUT_DESCENT ((Atom) 54)\n#define XA_ITALIC_ANGLE ((Atom) 55)\n#define XA_X_HEIGHT ((Atom) 56)\n#define XA_QUAD_WIDTH ((Atom) 57)\n#define XA_WEIGHT ((Atom) 58)\n#define XA_POINT_SIZE ((Atom) 59)\n#define XA_RESOLUTION ((Atom) 60)\n#define XA_COPYRIGHT ((Atom) 61)\n#define XA_NOTICE ((Atom) 62)\n#define XA_FONT_NAME ((Atom) 63)\n#define XA_FAMILY_NAME ((Atom) 64)\n#define XA_FULL_NAME ((Atom) 65)\n#define XA_CAP_HEIGHT ((Atom) 66)\n#define XA_WM_CLASS ((Atom) 67)\n#define XA_WM_TRANSIENT_FOR ((Atom) 68)\n\n#define XA_LAST_PREDEFINED ((Atom) 68)\n#endif /* XATOM_H */\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/X11/Xauth.h",
    "content": "/*\n\nCopyright 1988, 1998  The Open Group\n\nPermission to use, copy, modify, distribute, and sell this software and its\ndocumentation for any purpose is hereby granted without fee, provided that\nthe above copyright notice appear in all copies and that both that\ncopyright notice and this permission notice appear in supporting\ndocumentation.\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE\nOPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN\nAN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\nCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\nExcept as contained in this notice, the name of The Open Group shall not be\nused in advertising or otherwise to promote the sale, use or other dealings\nin this Software without prior written authorization from The Open Group.\n\n*/\n\n#ifndef _Xauth_h\n#define _Xauth_h\n\n/* struct xauth is full of implicit padding to properly align the pointers\n   after the length fields.   We can't clean that up without breaking ABI,\n   so tell clang not to bother complaining about it. */\n#ifdef __clang__\n#pragma clang diagnostic push\n#pragma clang diagnostic ignored \"-Wpadded\"\n#endif\n\ntypedef struct xauth {\n    unsigned short   family;\n    unsigned short   address_length;\n    char    \t    *address;\n    unsigned short   number_length;\n    char    \t    *number;\n    unsigned short   name_length;\n    char    \t    *name;\n    unsigned short   data_length;\n    char   \t    *data;\n} Xauth;\n\n#ifdef __clang__\n#pragma clang diagnostic pop\n#endif\n\n#ifndef _XAUTH_STRUCT_ONLY\n\n# include   <X11/Xfuncproto.h>\n# include   <X11/Xfuncs.h>\n\n# include   <stdio.h>\n\n# define FamilyLocal (256)\t/* not part of X standard (i.e. X.h) */\n# define FamilyWild  (65535)\n# define FamilyNetname    (254)   /* not part of X standard */\n# define FamilyKrb5Principal (253) /* Kerberos 5 principal name */\n# define FamilyLocalHost (252)\t/* for local non-net authentication */\n\n\n_XFUNCPROTOBEGIN\n\nchar *XauFileName(void);\n\nXauth *XauReadAuth(\nFILE*\t/* auth_file */\n);\n\nint XauLockAuth(\n_Xconst char*\t/* file_name */,\nint\t\t/* retries */,\nint\t\t/* timeout */,\nlong\t\t/* dead */\n);\n\nint XauUnlockAuth(\n_Xconst char*\t/* file_name */\n);\n\nint XauWriteAuth(\nFILE*\t\t/* auth_file */,\nXauth*\t\t/* auth */\n);\n\nXauth *XauGetAuthByAddr(\n#if NeedWidePrototypes\nunsigned int\t/* family */,\nunsigned int\t/* address_length */,\n#else\nunsigned short\t/* family */,\nunsigned short\t/* address_length */,\n#endif\n_Xconst char*\t/* address */,\n#if NeedWidePrototypes\nunsigned int\t/* number_length */,\n#else\nunsigned short\t/* number_length */,\n#endif\n_Xconst char*\t/* number */,\n#if NeedWidePrototypes\nunsigned int\t/* name_length */,\n#else\nunsigned short\t/* name_length */,\n#endif\n_Xconst char*\t/* name */\n);\n\nXauth *XauGetBestAuthByAddr(\n#if NeedWidePrototypes\nunsigned int\t/* family */,\nunsigned int\t/* address_length */,\n#else\nunsigned short\t/* family */,\nunsigned short\t/* address_length */,\n#endif\n_Xconst char*\t/* address */,\n#if NeedWidePrototypes\nunsigned int\t/* number_length */,\n#else\nunsigned short\t/* number_length */,\n#endif\n_Xconst char*\t/* number */,\nint\t\t/* types_length */,\nchar**\t\t/* type_names */,\n_Xconst int*\t/* type_lengths */\n);\n\nvoid XauDisposeAuth(\nXauth*\t\t/* auth */\n);\n\n_XFUNCPROTOEND\n\n/* Return values from XauLockAuth */\n\n# define LOCK_SUCCESS\t0\t/* lock succeeded */\n# define LOCK_ERROR\t1\t/* lock unexpectely failed, check errno */\n# define LOCK_TIMEOUT\t2\t/* lock failed, timeouts expired */\n\n#endif /* _XAUTH_STRUCT_ONLY */\n\n#endif /* _Xauth_h */\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/X11/Xcms.h",
    "content": "\n/*\n * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.\n * \tAll Rights Reserved\n *\n * This file is a component of an X Window System-specific implementation\n * of Xcms based on the TekColor Color Management System.  Permission is\n * hereby granted to use, copy, modify, sell, and otherwise distribute this\n * software and its documentation for any purpose and without fee, provided\n * that this copyright, permission, and disclaimer notice is reproduced in\n * all copies of this software and in supporting documentation.  TekColor\n * is a trademark of Tektronix, Inc.\n *\n * Tektronix makes no representation about the suitability of this software\n * for any purpose.  It is provided \"as is\" and with all faults.\n *\n * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,\n * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A\n * PARTICULAR PURPOSE.  IN NO EVENT SHALL TEKTRONIX BE LIABLE FOR ANY\n * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER\n * RESULTING FROM LOSS OF USE, DATA, OR PROFITS, WHETHER IN AN ACTION OF\n * CONTRACT, NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN\n * CONNECTION WITH THE USE OR THE PERFORMANCE OF THIS SOFTWARE.\n *\n *\n *\tDESCRIPTION\n *\t\tPublic include file for X Color Management System\n */\n#ifndef _X11_XCMS_H_\n#define _X11_XCMS_H_\n\n#include <X11/Xlib.h>\n\n/* The Xcms structs are full of implicit padding to properly align members.\n   We can't clean that up without breaking ABI, so tell clang not to bother\n   complaining about it. */\n#ifdef __clang__\n#pragma clang diagnostic push\n#pragma clang diagnostic ignored \"-Wpadded\"\n#endif\n\n    /*\n     * XCMS Status Values\n     */\n#define XcmsFailure\t\t\t0\n#define XcmsSuccess\t\t\t1\n#define XcmsSuccessWithCompression\t2\n\n    /*\n     * Color Space Format ID's\n     *    Color Space ID's are of XcmsColorFormat type.\n     *\n     *    bit 31\n     *\t    0 == Device-Independent\n     *\t    1 == Device-Dependent\n     *\n     *    bit 30:\n     *\t    0 == Registered with X Consortium\n     *\t    1 == Unregistered\n     */\n#define XcmsUndefinedFormat\t(XcmsColorFormat)0x00000000\n#define XcmsCIEXYZFormat\t(XcmsColorFormat)0x00000001\n#define XcmsCIEuvYFormat\t(XcmsColorFormat)0x00000002\n#define XcmsCIExyYFormat\t(XcmsColorFormat)0x00000003\n#define XcmsCIELabFormat\t(XcmsColorFormat)0x00000004\n#define XcmsCIELuvFormat\t(XcmsColorFormat)0x00000005\n#define XcmsTekHVCFormat\t(XcmsColorFormat)0x00000006\n#define XcmsRGBFormat\t\t(XcmsColorFormat)0x80000000\n#define XcmsRGBiFormat\t\t(XcmsColorFormat)0x80000001\n\n    /*\n     * State of XcmsPerScrnInfo\n     */\n#define XcmsInitNone\t\t0x00\t/* no initialization attempted */\n#define XcmsInitSuccess\t\t0x01\t/* initialization successful */\n#define XcmsInitFailure\t\t0xff\t/* failure, use defaults */\n\n#define DisplayOfCCC(ccc)\t\t((ccc)->dpy)\n#define ScreenNumberOfCCC(ccc)\t\t((ccc)->screenNumber)\n#define VisualOfCCC(ccc)\t\t((ccc)->visual)\n#define ClientWhitePointOfCCC(ccc)\t(&(ccc)->clientWhitePt)\n#define ScreenWhitePointOfCCC(ccc)\t(&(ccc)->pPerScrnInfo->screenWhitePt)\n#define FunctionSetOfCCC(ccc)\t\t((ccc)->pPerScrnInfo->functionSet)\n\ntypedef unsigned long XcmsColorFormat;\t/* Color Space Format ID */\n\ntypedef double XcmsFloat;\n\n    /*\n     * Device RGB\n     */\ntypedef struct {\n    unsigned short red;\t\t/* scaled from 0x0000 to 0xffff */\n    unsigned short green;\t/* scaled from 0x0000 to 0xffff */\n    unsigned short blue;\t/* scaled from 0x0000 to 0xffff */\n} XcmsRGB;\n\n    /*\n     * RGB Intensity\n     */\ntypedef struct {\n    XcmsFloat red;\t/* 0.0 - 1.0 */\n    XcmsFloat green;\t/* 0.0 - 1.0 */\n    XcmsFloat blue;\t/* 0.0 - 1.0 */\n} XcmsRGBi;\n\n    /*\n     * CIE XYZ\n     */\ntypedef struct {\n    XcmsFloat X;\n    XcmsFloat Y;\n    XcmsFloat Z;\n} XcmsCIEXYZ;\n\n    /*\n     * CIE u'v'Y\n     */\ntypedef struct {\n    XcmsFloat u_prime;\t\t/* 0.0 - 1.0 */\n    XcmsFloat v_prime;\t\t/* 0.0 - 1.0 */\n    XcmsFloat Y;\t\t/* 0.0 - 1.0 */\n} XcmsCIEuvY;\n\n    /*\n     * CIE xyY\n     */\ntypedef struct {\n    XcmsFloat x;\t\t/* 0.0 - 1.0 */\n    XcmsFloat y;\t\t/* 0.0 - 1.0 */\n    XcmsFloat Y;\t\t/* 0.0 - 1.0 */\n} XcmsCIExyY;\n\n    /*\n     * CIE L*a*b*\n     */\ntypedef struct {\n    XcmsFloat L_star;\t\t/* 0.0 - 100.0 */\n    XcmsFloat a_star;\n    XcmsFloat b_star;\n} XcmsCIELab;\n\n    /*\n     * CIE L*u*v*\n     */\ntypedef struct {\n    XcmsFloat L_star;\t\t/* 0.0 - 100.0 */\n    XcmsFloat u_star;\n    XcmsFloat v_star;\n} XcmsCIELuv;\n\n    /*\n     * TekHVC\n     */\ntypedef struct {\n    XcmsFloat H;\t\t/* 0.0 - 360.0 */\n    XcmsFloat V;\t\t/* 0.0 - 100.0 */\n    XcmsFloat C;\t\t/* 0.0 - 100.0 */\n} XcmsTekHVC;\n\n    /*\n     * PAD\n     */\ntypedef struct {\n    XcmsFloat pad0;\n    XcmsFloat pad1;\n    XcmsFloat pad2;\n    XcmsFloat pad3;\n} XcmsPad;\n\n\n    /*\n     * XCMS Color Structure\n     */\ntypedef struct {\n    union {\n\tXcmsRGB RGB;\n\tXcmsRGBi RGBi;\n\tXcmsCIEXYZ CIEXYZ;\n\tXcmsCIEuvY CIEuvY;\n\tXcmsCIExyY CIExyY;\n\tXcmsCIELab CIELab;\n\tXcmsCIELuv CIELuv;\n\tXcmsTekHVC TekHVC;\n\tXcmsPad Pad;\n    } spec;\t\t\t/* the color specification\t*/\n    unsigned long pixel;\t/* pixel value (as needed)\t*/\n    XcmsColorFormat\tformat;\t\t/* the specification format\t*/\n} XcmsColor;\n\n\n    /*\n     * XCMS Per Screen related data\n     */\n\ntypedef struct _XcmsPerScrnInfo {\n    XcmsColor\tscreenWhitePt;\t/* Screen White point */\n    XPointer\tfunctionSet;\t/* pointer to Screen Color Characterization */\n\t\t\t\t/*      Function Set structure\t\t*/\n    XPointer\tscreenData;\t/* pointer to corresponding Screen Color*/\n\t\t\t\t/*\tCharacterization Data\t\t*/\n    unsigned char state;   /* XcmsInitNone, XcmsInitSuccess, XcmsInitFailure */\n    char\tpad[3];\n} XcmsPerScrnInfo;\n\ntypedef struct _XcmsCCC *XcmsCCC;\n\ntypedef Status (*XcmsCompressionProc)(\t\t/* Gamut Compression Proc */\n    XcmsCCC\t\t/* ccc */,\n    XcmsColor*\t\t/* colors_in_out */,\n    unsigned int\t/* ncolors */,\n    unsigned int\t/* index */,\n    Bool*\t\t/* compression_flags_return */\n);\n\ntypedef Status (*XcmsWhiteAdjustProc)(\t \t/* White Point Adjust Proc */\n    XcmsCCC\t\t/* ccc */,\n    XcmsColor*\t\t/* initial_white_point*/,\n    XcmsColor*\t\t/* target_white_point*/,\n    XcmsColorFormat\t/* target_format */,\n    XcmsColor*\t\t/* colors_in_out */,\n    unsigned int\t/* ncolors */,\n    Bool*\t\t/* compression_flags_return */\n);\n\n    /*\n     * XCMS Color Conversion Context\n     */\ntypedef struct _XcmsCCC {\n    Display\t*dpy;\t\t\t/* X Display */\n    int\t\tscreenNumber;\t\t/* X screen number */\n    Visual\t*visual;\t\t/* X Visual */\n    XcmsColor\tclientWhitePt;\t\t/* Client White Point */\n    XcmsCompressionProc\tgamutCompProc;\t/* Gamut Compression Function */\n    XPointer\tgamutCompClientData;\t/* Gamut Comp Func Client Data */\n    XcmsWhiteAdjustProc\twhitePtAdjProc;\t/* White Point Adjustment Function */\n    XPointer\twhitePtAdjClientData;\t/* White Pt Adj Func Client Data */\n    XcmsPerScrnInfo *pPerScrnInfo;\t/* pointer to per screen information */\n\t\t\t\t\t/*  associated with the above display */\n\t\t\t\t\t/*  screenNumber */\n} XcmsCCCRec;\n\ntypedef Status (*XcmsScreenInitProc)(\t/* Screen Initialization Proc */\n    Display*\t\t/* dpy */,\n    int\t\t\t/* screen_number */,\n    XcmsPerScrnInfo*\t/* screen_info */\n);\n\ntypedef void (*XcmsScreenFreeProc)(\n    XPointer\t\t/* screenData */\n);\n\n    /*\n     * Function List Pointer -- pointer to an array of function pointers.\n     *    The end of list is indicated by a NULL pointer.\n     */\n/*\n * XXX:  The use of the XcmsConversionProc type is broken.  The\n *       device-independent colour conversion code uses it as:\n\ntypedef Status (*XcmsConversionProc)(XcmsCCC, XcmsColor *, XcmsColor *,\n\t\t\t\t     unsigned int);\n\n *       while the device-dependent code uses it as:\n\ntypedef Status (*XcmsConversionProc)(XcmsCCC, XcmsColor *, unsigned int,\n\t\t\t\t     Bool *);\n\n *       Until this is reworked, it's probably best to leave it unprotoized.\n *       The code works regardless.\n */\ntypedef Status (*XcmsDDConversionProc)( /* using device-dependent version */\n    XcmsCCC             /* ccc */,\n    XcmsColor*          /* pcolors_in_out */,\n    unsigned int        /* ncolors */,\n    Bool*               /* pCompressed */\n    );\n\ntypedef Status (*XcmsDIConversionProc)( /* using device-independent version */\n    XcmsCCC             /* ccc */,\n    XcmsColor*          /* white_point */,\n    XcmsColor*          /* pcolors_in_out */,\n    unsigned int        /* ncolors */\n    );\n\ntypedef XcmsDIConversionProc XcmsConversionProc;\ntypedef XcmsConversionProc *XcmsFuncListPtr;\n\ntypedef int (*XcmsParseStringProc)(\t/* Color String Parsing Proc */\n    char*\t\t/* color_string */,\n    XcmsColor*\t\t/* color_return */\n);\n\n    /*\n     * Color Space -- per Color Space related data (Device-Independent\n     *    or Device-Dependent)\n     */\ntypedef struct _XcmsColorSpace {\n    const char *prefix;\t\t/* Prefix of string format.\t\t*/\n    XcmsColorFormat id;\t\t/* Format ID number.\t\t\t*/\n    XcmsParseStringProc parseString;\n\t\t\t\t/* String format parsing function\t*/\n    XcmsFuncListPtr to_CIEXYZ;\t/* Pointer to an array of function \t*/\n\t\t\t\t/*   pointers such that when the\t*/\n\t\t\t\t/*   functions are executed in sequence\t*/\n\t\t\t\t/*   will convert a XcmsColor structure\t*/\n\t\t\t\t/*   from this color space to CIEXYZ\t*/\n\t\t\t\t/*   space.\t\t\t\t*/\n    XcmsFuncListPtr from_CIEXYZ;/* Pointer to an array of function \t*/\n\t\t\t\t/*   pointers such that when the\t*/\n\t\t\t\t/*   functions are executed in sequence\t*/\n\t\t\t\t/*   will convert a XcmsColor structure\t*/\n\t\t\t\t/*   from CIEXYZ space to this color\t*/\n\t\t\t\t/*   space.\t\t\t\t*/\n    int inverse_flag;\t\t/* If 1, indicates that for 0 <= i < n\t*/\n\t\t\t\t/*   where n is the number of function\t*/\n\t\t\t\t/*   pointers in the lists to_CIEXYZ\t*/\n\t\t\t\t/*   and from_CIEXYZ; for each function */\n\t\t\t\t/*   to_CIEXYZ[i] its inverse function\t*/\n\t\t\t\t/*   is from_CIEXYZ[n - i].\t\t*/\n\n} XcmsColorSpace;\n\n    /*\n     * Screen Color Characterization Function Set -- per device class\n     *    color space conversion functions.\n     */\ntypedef struct _XcmsFunctionSet {\n    XcmsColorSpace **DDColorSpaces;\n\t\t\t\t/* Pointer to an array of pointers to\t*/\n\t\t\t\t/*   Device-DEPENDENT color spaces\t*/\n\t\t\t\t/*   understood by this SCCFuncSet.\t*/\n    XcmsScreenInitProc screenInitProc;\n\t\t\t\t/* Screen initialization function that\t*/\n\t\t\t\t/*   reads Screen Color Characterization*/\n\t\t\t\t/*   Data off properties on the screen's*/\n\t\t\t\t/*   root window.\t\t\t*/\n    XcmsScreenFreeProc screenFreeProc;\n\t\t\t\t/* Function that frees the SCCData\t*/\n\t\t\t\t/*   structures.\t\t\t*/\n} XcmsFunctionSet;\n\n_XFUNCPROTOBEGIN\n\nextern Status XcmsAddColorSpace (\n    XcmsColorSpace*\t/* pColorSpace */\n);\n\nextern Status XcmsAddFunctionSet (\n    XcmsFunctionSet*\t/* functionSet */\n);\n\nextern Status XcmsAllocColor (\n    Display*\t\t/* dpy */,\n    Colormap\t\t/* colormap */,\n    XcmsColor*\t\t/* color_in_out */,\n    XcmsColorFormat\t\t/* result_format */\n);\n\nextern Status XcmsAllocNamedColor (\n    Display*\t\t/* dpy */,\n    Colormap\t\t/* colormap */,\n    _Xconst char*\t/* color_string */,\n    XcmsColor*\t\t/* color_scrn_return */,\n    XcmsColor*\t\t/* color_exact_return */,\n    XcmsColorFormat\t\t/* result_format */\n);\n\nextern XcmsCCC XcmsCCCOfColormap (\n    Display*\t\t/* dpy */,\n    Colormap\t\t/* colormap */\n);\n\nextern Status XcmsCIELabClipab(\n    XcmsCCC\t\t/* ccc */,\n    XcmsColor*\t\t/* colors_in_out */,\n    unsigned int\t/* ncolors */,\n    unsigned int\t/* index */,\n    Bool*\t\t/* compression_flags_return */\n);\n\nextern Status XcmsCIELabClipL(\n    XcmsCCC\t\t/* ccc */,\n    XcmsColor*\t\t/* colors_in_out */,\n    unsigned int\t/* ncolors */,\n    unsigned int\t/* index */,\n    Bool*\t\t/* compression_flags_return */\n);\n\nextern Status XcmsCIELabClipLab(\n    XcmsCCC\t\t/* ccc */,\n    XcmsColor*\t\t/* colors_in_out */,\n    unsigned int\t/* ncolors */,\n    unsigned int\t/* index */,\n    Bool*\t\t/* compression_flags_return */\n);\n\nextern Status XcmsCIELabQueryMaxC (\n    XcmsCCC\t\t/* ccc */,\n    XcmsFloat\t\t/* hue_angle */,\n    XcmsFloat\t\t/* L_star */,\n    XcmsColor*\t\t/* color_return */\n);\n\nextern Status XcmsCIELabQueryMaxL (\n    XcmsCCC\t\t/* ccc */,\n    XcmsFloat\t\t/* hue_angle */,\n    XcmsFloat\t\t/* chroma */,\n    XcmsColor*\t\t/* color_return */\n);\n\nextern Status XcmsCIELabQueryMaxLC (\n    XcmsCCC\t\t/* ccc */,\n    XcmsFloat\t\t/* hue_angle */,\n    XcmsColor*\t\t/* color_return */\n);\n\nextern Status XcmsCIELabQueryMinL (\n    XcmsCCC\t\t/* ccc */,\n    XcmsFloat\t\t/* hue_angle */,\n    XcmsFloat\t\t/* chroma */,\n    XcmsColor*\t\t/* color_return */\n);\n\nextern Status XcmsCIELabToCIEXYZ (\n    XcmsCCC\t\t/* ccc */,\n    XcmsColor*\t\t/* white_point */,\n    XcmsColor*\t\t/* colors */,\n    unsigned int\t/* ncolors */\n);\n\nextern Status XcmsCIELabWhiteShiftColors(\n    XcmsCCC\t\t/* ccc */,\n    XcmsColor*\t\t/* initial_white_point*/,\n    XcmsColor*\t\t/* target_white_point*/,\n    XcmsColorFormat\t/* target_format */,\n    XcmsColor*\t\t/* colors_in_out */,\n    unsigned int\t/* ncolors */,\n    Bool*\t\t/* compression_flags_return */\n);\n\nextern Status XcmsCIELuvClipL(\n    XcmsCCC\t\t/* ccc */,\n    XcmsColor*\t\t/* colors_in_out */,\n    unsigned int\t/* ncolors */,\n    unsigned int\t/* index */,\n    Bool*\t\t/* compression_flags_return */\n);\n\nextern Status XcmsCIELuvClipLuv(\n    XcmsCCC\t\t/* ccc */,\n    XcmsColor*\t\t/* colors_in_out */,\n    unsigned int\t/* ncolors */,\n    unsigned int\t/* index */,\n    Bool*\t\t/* compression_flags_return */\n);\n\nextern Status XcmsCIELuvClipuv(\n    XcmsCCC\t\t/* ccc */,\n    XcmsColor*\t\t/* colors_in_out */,\n    unsigned int\t/* ncolors */,\n    unsigned int\t/* index */,\n    Bool*\t\t/* compression_flags_return */\n);\n\nextern Status XcmsCIELuvQueryMaxC (\n    XcmsCCC\t\t/* ccc */,\n    XcmsFloat\t\t/* hue_angle */,\n    XcmsFloat\t\t/* L_star */,\n    XcmsColor*\t\t/* color_return */\n);\n\nextern Status XcmsCIELuvQueryMaxL (\n    XcmsCCC\t\t/* ccc */,\n    XcmsFloat\t\t/* hue_angle */,\n    XcmsFloat\t\t/* chroma */,\n    XcmsColor*\t\t/* color_return */\n);\n\nextern Status XcmsCIELuvQueryMaxLC (\n    XcmsCCC\t\t/* ccc */,\n    XcmsFloat\t\t/* hue_angle */,\n    XcmsColor*\t\t/* color_return */\n);\n\nextern Status XcmsCIELuvQueryMinL (\n    XcmsCCC\t\t/* ccc */,\n    XcmsFloat\t\t/* hue_angle */,\n    XcmsFloat\t\t/* chroma */,\n    XcmsColor*\t\t/* color_return */\n);\n\nextern Status XcmsCIELuvToCIEuvY (\n    XcmsCCC\t\t/* ccc */,\n    XcmsColor*\t\t/* white_point */,\n    XcmsColor*\t\t/* colors */,\n    unsigned int\t/* ncolors */\n);\n\nextern Status XcmsCIELuvWhiteShiftColors(\n    XcmsCCC\t\t/* ccc */,\n    XcmsColor*\t\t/* initial_white_point*/,\n    XcmsColor*\t\t/* target_white_point*/,\n    XcmsColorFormat\t/* target_format */,\n    XcmsColor*\t\t/* colors_in_out */,\n    unsigned int\t/* ncolors */,\n    Bool*\t\t/* compression_flags_return */\n);\n\nextern Status XcmsCIEXYZToCIELab (\n    XcmsCCC\t\t/* ccc */,\n    XcmsColor*\t\t/* white_point */,\n    XcmsColor*\t\t/* colors */,\n    unsigned int\t/* ncolors */\n);\n\nextern Status XcmsCIEXYZToCIEuvY (\n    XcmsCCC\t\t/* ccc */,\n    XcmsColor*\t\t/* white_point */,\n    XcmsColor*\t\t/* colors */,\n    unsigned int\t/* ncolors */\n);\n\nextern Status XcmsCIEXYZToCIExyY (\n    XcmsCCC\t\t/* ccc */,\n    XcmsColor*\t\t/* white_point */,\n    XcmsColor*\t\t/* colors */,\n    unsigned int\t/* ncolors */\n);\n\nextern Status XcmsCIEXYZToRGBi (\n    XcmsCCC\t\t/* ccc */,\n    XcmsColor*\t\t/* colors */,\n    unsigned int\t/* ncolors */,\n    Bool*\t\t/* compression_flags_return */\n);\n\nextern Status XcmsCIEuvYToCIELuv (\n    XcmsCCC\t\t/* ccc */,\n    XcmsColor*\t\t/* white_point */,\n    XcmsColor*\t\t/* colors */,\n    unsigned int\t/* ncolors */\n);\n\nextern Status XcmsCIEuvYToCIEXYZ (\n    XcmsCCC\t\t/* ccc */,\n    XcmsColor*\t\t/* white_point */,\n    XcmsColor*\t\t/* colors */,\n    unsigned int\t/* ncolors */\n);\n\nextern Status XcmsCIEuvYToTekHVC (\n    XcmsCCC\t\t/* ccc */,\n    XcmsColor*\t\t/* white_point */,\n    XcmsColor*\t\t/* colors */,\n    unsigned int\t/* ncolors */\n);\n\nextern Status XcmsCIExyYToCIEXYZ (\n    XcmsCCC\t\t/* ccc */,\n    XcmsColor*\t\t/* white_point */,\n    XcmsColor*\t\t/* colors */,\n    unsigned int\t/* ncolors */\n);\n\nextern XcmsColor *XcmsClientWhitePointOfCCC (\n    XcmsCCC\t\t/* ccc */\n);\n\nextern Status XcmsConvertColors (\n    XcmsCCC\t\t/* ccc */,\n    XcmsColor*\t\t/* colorArry_in_out */,\n    unsigned int\t/* nColors */,\n    XcmsColorFormat\t\t/* targetFormat */,\n    Bool*\t\t/* compArry_return */\n);\n\nextern XcmsCCC XcmsCreateCCC (\n    Display*\t\t/* dpy */,\n    int\t\t\t/* screenNumber */,\n    Visual*\t\t/* visual */,\n    XcmsColor*\t\t/* clientWhitePt */,\n    XcmsCompressionProc /* gamutCompProc */,\n    XPointer\t\t/* gamutCompClientData */,\n    XcmsWhiteAdjustProc\t/* whitePtAdjProc */,\n    XPointer\t\t/* whitePtAdjClientData */\n);\n\nextern XcmsCCC XcmsDefaultCCC (\n    Display*\t\t/* dpy */,\n    int\t\t\t/* screenNumber */\n);\n\nextern Display *XcmsDisplayOfCCC (\n    XcmsCCC\t\t/* ccc */\n);\n\nextern XcmsColorFormat XcmsFormatOfPrefix (\n    char*\t\t/* prefix */\n);\n\nextern void XcmsFreeCCC (\n    XcmsCCC\t\t/* ccc */\n);\n\nextern Status XcmsLookupColor (\n    Display*\t\t/* dpy */,\n    Colormap\t\t/* colormap */,\n    _Xconst char*\t/* color_string */,\n    XcmsColor*\t\t/* pColor_exact_in_out */,\n    XcmsColor*\t\t/* pColor_scrn_in_out */,\n    XcmsColorFormat\t\t/* result_format */\n);\n\nextern char *XcmsPrefixOfFormat (\n    XcmsColorFormat\t\t/* id */\n);\n\nextern Status XcmsQueryBlack (\n    XcmsCCC\t\t/* ccc */,\n    XcmsColorFormat\t/* target_format */,\n    XcmsColor*\t\t/* color_return */\n);\n\nextern Status XcmsQueryBlue (\n    XcmsCCC\t\t/* ccc */,\n    XcmsColorFormat\t/* target_format */,\n    XcmsColor*\t\t/* color_return */\n);\n\nextern Status XcmsQueryColor (\n    Display*\t\t/* dpy */,\n    Colormap\t\t/* colormap */,\n    XcmsColor*\t\t/* pColor_in_out */,\n    XcmsColorFormat\t\t/* result_format */\n);\n\nextern Status XcmsQueryColors (\n    Display*\t\t/* dpy */,\n    Colormap\t\t/* colormap */,\n    XcmsColor*\t\t/* colorArry_in_out */,\n    unsigned int\t/* nColors */,\n    XcmsColorFormat\t/* result_format */\n);\n\nextern Status XcmsQueryGreen (\n    XcmsCCC\t\t/* ccc */,\n    XcmsColorFormat\t/* target_format */,\n    XcmsColor*\t\t/* color_return */\n);\n\nextern Status XcmsQueryRed (\n    XcmsCCC\t\t/* ccc */,\n    XcmsColorFormat\t/* target_format */,\n    XcmsColor*\t\t/* color_return */\n);\n\nextern Status XcmsQueryWhite (\n    XcmsCCC\t\t/* ccc */,\n    XcmsColorFormat\t/* target_format */,\n    XcmsColor*\t\t/* color_return */\n);\n\nextern Status XcmsRGBiToCIEXYZ (\n    XcmsCCC\t\t/* ccc */,\n    XcmsColor*\t\t/* colors */,\n    unsigned int\t/* ncolors */,\n    Bool*\t\t/* compression_flags_return */\n);\n\nextern Status XcmsRGBiToRGB (\n    XcmsCCC\t\t/* ccc */,\n    XcmsColor*\t\t/* colors */,\n    unsigned int\t/* ncolors */,\n    Bool*\t\t/* compression_flags_return */\n);\n\nextern Status XcmsRGBToRGBi (\n    XcmsCCC\t\t/* ccc */,\n    XcmsColor*\t\t/* colors */,\n    unsigned int\t/* ncolors */,\n    Bool*\t\t/* compression_flags_return */\n);\n\nextern int XcmsScreenNumberOfCCC (\n    XcmsCCC\t\t/* ccc */\n);\n\nextern XcmsColor *XcmsScreenWhitePointOfCCC (\n    XcmsCCC\t\t/* ccc */\n);\n\nextern XcmsCCC XcmsSetCCCOfColormap(\n    Display*\t\t/* dpy */,\n    Colormap\t\t/* colormap */,\n    XcmsCCC\t\t/* ccc */\n);\n\nextern XcmsCompressionProc XcmsSetCompressionProc (\n    XcmsCCC\t\t/* ccc */,\n    XcmsCompressionProc\t/* compression_proc */,\n    XPointer\t\t/* client_data */\n);\n\nextern XcmsWhiteAdjustProc XcmsSetWhiteAdjustProc (\n    XcmsCCC\t\t/* ccc */,\n    XcmsWhiteAdjustProc\t/* white_adjust_proc */,\n    XPointer\t\t/* client_data */\n);\n\nextern Status XcmsSetWhitePoint (\n    XcmsCCC\t\t/* ccc */,\n    XcmsColor*\t\t/* color */\n);\n\nextern Status XcmsStoreColor (\n    Display*\t\t/* dpy */,\n    Colormap\t\t/* colormap */,\n    XcmsColor*\t\t/* pColor_in */\n);\n\nextern Status XcmsStoreColors (\n    Display*\t\t/* dpy */,\n    Colormap\t\t/* colormap */,\n    XcmsColor*\t\t/* colorArry_in */,\n    unsigned int\t/* nColors */,\n    Bool*\t\t/* compArry_return */\n);\n\nextern Status XcmsTekHVCClipC(\n    XcmsCCC\t\t/* ccc */,\n    XcmsColor*\t\t/* colors_in_out */,\n    unsigned int\t/* ncolors */,\n    unsigned int\t/* index */,\n    Bool*\t\t/* compression_flags_return */\n);\n\nextern Status XcmsTekHVCClipV(\n    XcmsCCC\t\t/* ccc */,\n    XcmsColor*\t\t/* colors_in_out */,\n    unsigned int\t/* ncolors */,\n    unsigned int\t/* index */,\n    Bool*\t\t/* compression_flags_return */\n);\n\nextern Status XcmsTekHVCClipVC(\n    XcmsCCC\t\t/* ccc */,\n    XcmsColor*\t\t/* colors_in_out */,\n    unsigned int\t/* ncolors */,\n    unsigned int\t/* index */,\n    Bool*\t\t/* compression_flags_return */\n);\n\nextern Status XcmsTekHVCQueryMaxC (\n    XcmsCCC\t\t/* ccc */,\n    XcmsFloat\t\t/* hue */,\n    XcmsFloat\t\t/* value */,\n    XcmsColor*\t\t/* color_return */\n);\n\nextern Status XcmsTekHVCQueryMaxV (\n    XcmsCCC\t\t/* ccc */,\n    XcmsFloat\t\t/* hue */,\n    XcmsFloat\t\t/* chroma */,\n    XcmsColor*\t\t/* color_return */\n);\n\nextern Status XcmsTekHVCQueryMaxVC (\n    XcmsCCC\t\t/* ccc */,\n    XcmsFloat\t\t/* hue */,\n    XcmsColor*\t\t/* color_return */\n);\n\nextern Status XcmsTekHVCQueryMaxVSamples (\n    XcmsCCC\t\t/* ccc */,\n    XcmsFloat\t\t/* hue */,\n    XcmsColor*\t\t/* colors_return */,\n    unsigned int\t/* nsamples */\n);\n\nextern Status XcmsTekHVCQueryMinV (\n    XcmsCCC\t\t/* ccc */,\n    XcmsFloat\t\t/* hue */,\n    XcmsFloat\t\t/* chroma */,\n    XcmsColor*\t\t/* color_return */\n);\n\nextern Status XcmsTekHVCToCIEuvY (\n    XcmsCCC\t\t/* ccc */,\n    XcmsColor*\t\t/* white_point */,\n    XcmsColor*\t\t/* colors */,\n    unsigned int\t/* ncolors */\n);\n\nextern Status XcmsTekHVCWhiteShiftColors(\n    XcmsCCC\t\t/* ccc */,\n    XcmsColor*\t\t/* initial_white_point*/,\n    XcmsColor*\t\t/* target_white_point*/,\n    XcmsColorFormat\t/* target_format */,\n    XcmsColor*\t\t/* colors_in_out */,\n    unsigned int\t/* ncolors */,\n    Bool*\t\t/* compression_flags_return */\n);\n\nextern Visual *XcmsVisualOfCCC (\n    XcmsCCC\t\t/* ccc */\n);\n\n#ifdef __clang__\n#pragma clang diagnostic pop\n#endif\n\n_XFUNCPROTOEND\n\n#endif /* _X11_XCMS_H_ */\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/X11/Xdefs.h",
    "content": "/***********************************************************\n\nCopyright (c) 1999  The XFree86 Project Inc.\n\nAll Rights Reserved.\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE\nOPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN\nAN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\nCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\nExcept as contained in this notice, the name of The XFree86 Project\nInc. shall not be used in advertising or otherwise to promote the\nsale, use or other dealings in this Software without prior written\nauthorization from The XFree86 Project Inc..\n\n*/\n\n/**\n ** Types definitions shared between server and clients \n **/\n\n#ifndef _XDEFS_H\n#define _XDEFS_H\n\n#ifdef _XSERVER64\n#include <X11/Xmd.h>\n#endif \n\n#ifndef _XTYPEDEF_ATOM\n#  define _XTYPEDEF_ATOM\n#  ifndef _XSERVER64\ntypedef unsigned long Atom;\n#  else\ntypedef CARD32 Atom;\n#  endif\n#endif\n\n#ifndef Bool\n#  ifndef _XTYPEDEF_BOOL\n#   define _XTYPEDEF_BOOL\ntypedef int Bool;\n#  endif\n#endif\n\n#ifndef _XTYPEDEF_POINTER\n#  define _XTYPEDEF_POINTER\ntypedef void *pointer;\n#endif\n\n#ifndef _XTYPEDEF_CLIENTPTR\ntypedef struct _Client *ClientPtr;\n#  define _XTYPEDEF_CLIENTPTR\n#endif\n\n#ifndef _XTYPEDEF_XID\n#  define _XTYPEDEF_XID\n#  ifndef _XSERVER64\ntypedef unsigned long XID;\n#  else\ntypedef CARD32 XID;\n#  endif\n#endif\n\n#ifndef _XTYPEDEF_MASK\n#  define _XTYPEDEF_MASK\n#  ifndef _XSERVER64\ntypedef unsigned long Mask;\n#  else\ntypedef CARD32 Mask;\n#  endif\n#endif\n\n#ifndef _XTYPEDEF_FONTPTR\n#  define _XTYPEDEF_FONTPTR\ntypedef struct _Font *FontPtr; /* also in fonts/include/font.h */\n#endif\n\n#ifndef _XTYPEDEF_FONT\n#  define _XTYPEDEF_FONT\ntypedef XID\tFont;\n#endif\n\n#ifndef _XTYPEDEF_FSID\n#  ifndef _XSERVER64\ntypedef unsigned long FSID;\n#  else\ntypedef CARD32 FSID;\n#  endif\n#endif\n\ntypedef FSID AccContext;\n\n/* OS independent time value \n   XXX Should probably go in Xos.h */\ntypedef struct timeval **OSTimePtr;\n\n\ntypedef void (* BlockHandlerProcPtr)(void * /* blockData */,\n\t\t\t\t     OSTimePtr /* pTimeout */,\n\t\t\t\t     void * /* pReadmask */);\n\n#endif\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/X11/Xdmcp.h",
    "content": "/*\n * Copyright 1989 Network Computing Devices, Inc., Mountain View, California.\n *\n * Permission to use, copy, modify, and distribute this software and its\n * documentation for any purpose and without fee is hereby granted, provided\n * that the above copyright notice appear in all copies and that both that\n * copyright notice and this permission notice appear in supporting\n * documentation, and that the name of N.C.D. not be used in advertising or\n * publicity pertaining to distribution of the software without specific,\n * written prior permission.  N.C.D. makes no representations about the\n * suitability of this software for any purpose.  It is provided \"as is\"\n * without express or implied warranty.\n *\n */\n\n#ifndef _XDMCP_H_\n#define _XDMCP_H_\n\n#include <X11/Xmd.h>\n\n#include <X11/Xfuncproto.h>\n\n_XFUNCPROTOBEGIN\n\n#define XDM_PROTOCOL_VERSION\t1\n#define XDM_UDP_PORT\t\t177\n\n/* IANA has assigned FF0X:0:0:0:0:0:0:12B as the permanently assigned\n * multicast addresses for XDMCP, where X in the prefix may be replaced\n * by any valid scope identifier, such as 1 for Node-Local, 2 for Link-Local,\n * 5 for Site-Local, and so on.  We set the default here to the Link-Local\n * version to most closely match the old IPv4 subnet broadcast behavior.\n * Both xdm and X -query allow specifying a different address if a different\n * scope is defined.\n */\n#define XDM_DEFAULT_MCAST_ADDR6\t\"ff02:0:0:0:0:0:0:12b\"\n\n#define XDM_MAX_MSGLEN\t\t8192\n#define XDM_MIN_RTX\t\t2\n#define XDM_MAX_RTX\t\t32\n#define XDM_RTX_LIMIT\t\t7\n#define XDM_KA_RTX_LIMIT\t4\n#define XDM_DEF_DORMANCY\t(3 * 60)\t/* 3 minutes */\n#define XDM_MAX_DORMANCY\t(24 * 60 * 60)\t/* 24 hours */\n\ntypedef enum {\n    BROADCAST_QUERY = 1, QUERY, INDIRECT_QUERY, FORWARD_QUERY,\n    WILLING, UNWILLING, REQUEST, ACCEPT, DECLINE, MANAGE, REFUSE,\n    FAILED, KEEPALIVE, ALIVE\n} xdmOpCode;\n\ntypedef enum {\n    XDM_QUERY, XDM_BROADCAST, XDM_INDIRECT, XDM_COLLECT_QUERY,\n    XDM_COLLECT_BROADCAST_QUERY, XDM_COLLECT_INDIRECT_QUERY,\n    XDM_START_CONNECTION, XDM_AWAIT_REQUEST_RESPONSE,\n    XDM_AWAIT_MANAGE_RESPONSE, XDM_MANAGE, XDM_RUN_SESSION, XDM_OFF,\n    XDM_AWAIT_USER_INPUT, XDM_KEEPALIVE, XDM_AWAIT_ALIVE_RESPONSE,\n#if defined(IPv6) && defined(AF_INET6)\n    XDM_MULTICAST, XDM_COLLECT_MULTICAST_QUERY,\n#endif\n    XDM_KEEP_ME_LAST\n} xdmcp_states;\n\n#ifdef NOTDEF\n/* table of hosts */\n\n#define XDM_MAX_STR_LEN 21\n#define XDM_MAX_HOSTS 20\nstruct xdm_host_table {\n  struct sockaddr_in sockaddr;\n  char name[XDM_MAX_STR_LEN];\n  char status[XDM_MAX_STR_LEN];\n};\n#endif /* NOTDEF */\n\ntypedef CARD8\t*CARD8Ptr;\ntypedef CARD16\t*CARD16Ptr;\ntypedef CARD32\t*CARD32Ptr;\n\ntypedef struct _ARRAY8 {\n    CARD16\tlength;\n    CARD8Ptr\tdata;\n} ARRAY8, *ARRAY8Ptr;\n\ntypedef struct _ARRAY16 {\n    CARD8\tlength;\n    CARD16Ptr\tdata;\n} ARRAY16, *ARRAY16Ptr;\n\ntypedef struct _ARRAY32 {\n    CARD8\tlength;\n    CARD32Ptr\tdata;\n} ARRAY32, *ARRAY32Ptr;\n\ntypedef struct _ARRAYofARRAY8 {\n    CARD8\tlength;\n    ARRAY8Ptr\tdata;\n} ARRAYofARRAY8, *ARRAYofARRAY8Ptr;\n\ntypedef struct _XdmcpHeader {\n    CARD16  version, opcode, length;\n} XdmcpHeader, *XdmcpHeaderPtr;\n\ntypedef struct _XdmcpBuffer {\n    BYTE    *data;\n    int\t    size;\t\t/* size of buffer pointed by to data */\n    int\t    pointer;\t\t/* current index into data */\n    int\t    count;\t\t/* bytes read from network into data */\n} XdmcpBuffer, *XdmcpBufferPtr;\n\ntypedef struct _XdmAuthKey {\n    BYTE    data[8];\n} XdmAuthKeyRec, *XdmAuthKeyPtr;\n\n\n/* implementation-independent network address structure.\n   Equiv to sockaddr* for sockets and netbuf* for STREAMS. */\n\ntypedef char *XdmcpNetaddr;\n\nextern int XdmcpWriteARRAY16(XdmcpBufferPtr buffer, const ARRAY16Ptr array);\nextern int XdmcpWriteARRAY32(XdmcpBufferPtr buffer, const ARRAY32Ptr array);\nextern int XdmcpWriteARRAY8(XdmcpBufferPtr buffer, const ARRAY8Ptr array);\nextern int XdmcpWriteARRAYofARRAY8(XdmcpBufferPtr buffer, const ARRAYofARRAY8Ptr array);\nextern int XdmcpWriteCARD16(XdmcpBufferPtr buffer, unsigned value);\nextern int XdmcpWriteCARD32(XdmcpBufferPtr buffer, unsigned value);\nextern int XdmcpWriteCARD8(XdmcpBufferPtr buffer, unsigned value);\nextern int XdmcpWriteHeader(XdmcpBufferPtr  buffer, const XdmcpHeaderPtr  header);\n\nextern int XdmcpFlush(int fd, XdmcpBufferPtr buffer, XdmcpNetaddr to, int tolen);\n\nextern int XdmcpReadARRAY16(XdmcpBufferPtr buffer, ARRAY16Ptr array);\nextern int XdmcpReadARRAY32(XdmcpBufferPtr buffer, ARRAY32Ptr array);\nextern int XdmcpReadARRAY8(XdmcpBufferPtr buffer, ARRAY8Ptr array);\nextern int XdmcpReadARRAYofARRAY8(XdmcpBufferPtr buffer, ARRAYofARRAY8Ptr array);\nextern int XdmcpReadCARD16(XdmcpBufferPtr buffer, CARD16Ptr valuep);\nextern int XdmcpReadCARD32(XdmcpBufferPtr buffer, CARD32Ptr valuep);\nextern int XdmcpReadCARD8(XdmcpBufferPtr buffer, CARD8Ptr valuep);\nextern int XdmcpReadHeader(XdmcpBufferPtr buffer, XdmcpHeaderPtr header);\n\nextern int XdmcpFill(int fd, XdmcpBufferPtr buffer, XdmcpNetaddr from, int *fromlen);\n\nextern int XdmcpReadRemaining(const XdmcpBufferPtr buffer);\n\nextern void XdmcpDisposeARRAY8(ARRAY8Ptr array);\nextern void XdmcpDisposeARRAY16(ARRAY16Ptr array);\nextern void XdmcpDisposeARRAY32(ARRAY32Ptr array);\nextern void XdmcpDisposeARRAYofARRAY8(ARRAYofARRAY8Ptr array);\n\nextern int XdmcpCopyARRAY8(const ARRAY8Ptr src, ARRAY8Ptr dst);\n\nextern int XdmcpARRAY8Equal(const ARRAY8Ptr array1, const ARRAY8Ptr array2);\n\nextern void XdmcpGenerateKey (XdmAuthKeyPtr key);\nextern void XdmcpIncrementKey (XdmAuthKeyPtr key);\nextern void XdmcpDecrementKey (XdmAuthKeyPtr key);\n#ifdef HASXDMAUTH\nextern void XdmcpWrap(unsigned char *input, unsigned char *wrapper, unsigned char *output, int bytes);\nextern void XdmcpUnwrap(unsigned char *input, unsigned char *wrapper, unsigned char *output, int bytes);\n#endif\n\n#ifndef TRUE\n#define TRUE\t1\n#define FALSE\t0\n#endif\n\nextern int XdmcpCompareKeys (const XdmAuthKeyPtr a, const XdmAuthKeyPtr b);\n\nextern int XdmcpAllocARRAY16 (ARRAY16Ptr array, int length);\nextern int XdmcpAllocARRAY32 (ARRAY32Ptr array, int length);\nextern int XdmcpAllocARRAY8 (ARRAY8Ptr array, int length);\nextern int XdmcpAllocARRAYofARRAY8 (ARRAYofARRAY8Ptr array, int length);\n\nextern int XdmcpReallocARRAY16 (ARRAY16Ptr array, int length);\nextern int XdmcpReallocARRAY32 (ARRAY32Ptr array, int length);\nextern int XdmcpReallocARRAY8 (ARRAY8Ptr array, int length);\nextern int XdmcpReallocARRAYofARRAY8 (ARRAYofARRAY8Ptr array, int length);\n\n_XFUNCPROTOEND\n\n#endif /* _XDMCP_H_ */\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/X11/Xfuncproto.h",
    "content": "/* Xfuncproto.h.  Generated from Xfuncproto.h.in by configure.  */\n/*\n *\nCopyright 1989, 1991, 1998  The Open Group\n\nPermission to use, copy, modify, distribute, and sell this software and its\ndocumentation for any purpose is hereby granted without fee, provided that\nthe above copyright notice appear in all copies and that both that\ncopyright notice and this permission notice appear in supporting\ndocumentation.\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE\nOPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN\nAN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\nCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\nExcept as contained in this notice, the name of The Open Group shall not be\nused in advertising or otherwise to promote the sale, use or other dealings\nin this Software without prior written authorization from The Open Group.\n *\n */\n\n/* Definitions to make function prototypes manageable */\n\n#ifndef _XFUNCPROTO_H_\n#define _XFUNCPROTO_H_\n\n#ifndef NeedFunctionPrototypes\n#define NeedFunctionPrototypes 1\n#endif /* NeedFunctionPrototypes */\n\n#ifndef NeedVarargsPrototypes\n#define NeedVarargsPrototypes 1\n#endif /* NeedVarargsPrototypes */\n\n#if NeedFunctionPrototypes\n\n#ifndef NeedNestedPrototypes\n#define NeedNestedPrototypes 1\n#endif /* NeedNestedPrototypes */\n\n#ifndef _Xconst\n#define _Xconst const\n#endif /* _Xconst */\n\n/* Function prototype configuration (see configure for more info) */\n#ifndef NARROWPROTO\n#define NARROWPROTO /**/\n#endif\n#ifndef FUNCPROTO\n#define FUNCPROTO 15\n#endif\n\n#ifndef NeedWidePrototypes\n#ifdef NARROWPROTO\n#define NeedWidePrototypes 0\n#else\n#define NeedWidePrototypes 1\t\t/* default to make interropt. easier */\n#endif\n#endif /* NeedWidePrototypes */\n\n#endif /* NeedFunctionPrototypes */\n\n#ifndef _XFUNCPROTOBEGIN\n#if defined(__cplusplus) || defined(c_plusplus) /* for C++ V2.0 */\n#define _XFUNCPROTOBEGIN extern \"C\" {\t/* do not leave open across includes */\n#define _XFUNCPROTOEND }\n#else\n#define _XFUNCPROTOBEGIN\n#define _XFUNCPROTOEND\n#endif\n#endif /* _XFUNCPROTOBEGIN */\n\n/* http://clang.llvm.org/docs/LanguageExtensions.html#has-attribute */\n#ifndef __has_attribute\n# define __has_attribute(x) 0  /* Compatibility with non-clang compilers. */\n#endif\n#ifndef __has_feature\n# define __has_feature(x) 0    /* Compatibility with non-clang compilers. */\n#endif\n#ifndef __has_extension\n# define __has_extension(x) 0  /* Compatibility with non-clang compilers. */\n#endif\n\n/* Added in X11R6.9, so available in any version of modular xproto */\n#if __has_attribute(__sentinel__) || (defined(__GNUC__) && (__GNUC__ >= 4))\n# define _X_SENTINEL(x) __attribute__ ((__sentinel__(x)))\n#else\n# define _X_SENTINEL(x)\n#endif /* GNUC >= 4 */\n\n/* Added in X11R6.9, so available in any version of modular xproto */\n#if (__has_attribute(visibility) || (defined(__GNUC__) && (__GNUC__ >= 4))) \\\n    && !defined(__CYGWIN__) && !defined(__MINGW32__)\n# define _X_EXPORT      __attribute__((visibility(\"default\")))\n# define _X_HIDDEN      __attribute__((visibility(\"hidden\")))\n# define _X_INTERNAL    __attribute__((visibility(\"internal\")))\n#elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x550)\n# define _X_EXPORT      __global\n# define _X_HIDDEN      __hidden\n# define _X_INTERNAL    __hidden\n#else /* not gcc >= 4 and not Sun Studio >= 8 */\n# define _X_EXPORT\n# define _X_HIDDEN\n# define _X_INTERNAL\n#endif /* GNUC >= 4 */\n\n/* Branch prediction hints for individual conditionals */\n/* requires xproto >= 7.0.9 */\n#if defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 303)\n# define _X_LIKELY(x)   __builtin_expect(!!(x), 1)\n# define _X_UNLIKELY(x) __builtin_expect(!!(x), 0)\n#else /* not gcc >= 3.3 */\n# define _X_LIKELY(x)   (x)\n# define _X_UNLIKELY(x) (x)\n#endif\n\n/* Bulk branch prediction hints via marking error path functions as \"cold\" */\n/* requires xproto >= 7.0.25 */\n#if __has_attribute(__cold__) || \\\n    (defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 403)) /* 4.3+ */\n# define _X_COLD __attribute__((__cold__))\n#else\n# define _X_COLD /* nothing */\n#endif\n\n/* Added in X11R6.9, so available in any version of modular xproto */\n#if __has_attribute(deprecated) \\\n    || (defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 301)) \\\n    || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x5130))\n# define _X_DEPRECATED  __attribute__((deprecated))\n#else /* not gcc >= 3.1 */\n# define _X_DEPRECATED\n#endif\n\n/* requires xproto >= 7.0.30 */\n#if __has_extension(attribute_deprecated_with_message) || \\\n                (defined(__GNUC__) && ((__GNUC__ >= 5) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 5))))\n# define _X_DEPRECATED_MSG(_msg) __attribute__((deprecated(_msg)))\n#else\n# define _X_DEPRECATED_MSG(_msg) _X_DEPRECATED\n#endif\n\n/* requires xproto >= 7.0.17 */\n#if __has_attribute(noreturn) \\\n    || (defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 205)) \\\n    || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590))\n# define _X_NORETURN __attribute((noreturn))\n#else\n# define _X_NORETURN\n#endif /* GNUC  */\n\n/* Added in X11R6.9, so available in any version of modular xproto */\n#if __has_attribute(__format__) \\\n    || defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 203)\n# define _X_ATTRIBUTE_PRINTF(x,y) __attribute__((__format__(__printf__,x,y)))\n#else /* not gcc >= 2.3 */\n# define _X_ATTRIBUTE_PRINTF(x,y)\n#endif\n\n/* requires xproto >= 7.0.22 - since this uses either gcc or C99 variable\n   argument macros, must be only used inside #ifdef _X_NONNULL guards, as\n   many legacy X clients are compiled in C89 mode still. */\n#if __has_attribute(nonnull) \\\n    && defined(__STDC_VERSION__) && (__STDC_VERSION__ - 0 >= 199901L) /* C99 */\n#define _X_NONNULL(...)  __attribute__((nonnull(__VA_ARGS__)))\n#elif __has_attribute(nonnull) \\\n    || defined(__GNUC__) &&  ((__GNUC__ * 100 + __GNUC_MINOR__) >= 303)\n#define _X_NONNULL(args...)  __attribute__((nonnull(args)))\n#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ - 0 >= 199901L) /* C99 */\n#define _X_NONNULL(...)  /* */\n#endif\n\n/* requires xproto >= 7.0.22 */\n#if __has_attribute(__unused__) \\\n    || defined(__GNUC__) &&  ((__GNUC__ * 100 + __GNUC_MINOR__) >= 205)\n#define _X_UNUSED  __attribute__((__unused__))\n#else\n#define _X_UNUSED  /* */\n#endif\n\n/* C99 keyword \"inline\" or equivalent extensions in pre-C99 compilers */\n/* requires xproto >= 7.0.9\n   (introduced in 7.0.8 but didn't support all compilers until 7.0.9) */\n#if defined(inline) /* assume autoconf set it correctly */ || \\\n   (defined(__STDC_VERSION__) && (__STDC_VERSION__ - 0 >= 199901L)) /* C99 */ || \\\n   (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x550))\n# define _X_INLINE inline\n#elif defined(__GNUC__) && !defined(__STRICT_ANSI__) /* gcc w/C89+extensions */\n# define _X_INLINE __inline__\n#else\n# define _X_INLINE\n#endif\n\n/* C99 keyword \"restrict\" or equivalent extensions in pre-C99 compilers */\n/* requires xproto >= 7.0.21 */\n#ifndef _X_RESTRICT_KYWD\n# if defined(restrict) /* assume autoconf set it correctly */ || \\\n    (defined(__STDC_VERSION__) && (__STDC_VERSION__ - 0 >= 199901L) /* C99 */ \\\n     && !defined(__cplusplus)) /* Workaround g++ issue on Solaris */\n#  define _X_RESTRICT_KYWD  restrict\n# elif defined(__GNUC__) && !defined(__STRICT_ANSI__) /* gcc w/C89+extensions */\n#  define _X_RESTRICT_KYWD __restrict__\n# else\n#  define _X_RESTRICT_KYWD\n# endif\n#endif\n\n/* requires xproto >= 7.0.30 */\n#if __has_attribute(no_sanitize_thread)\n# define _X_NOTSAN __attribute__((no_sanitize_thread))\n#else\n# define _X_NOTSAN\n#endif\n\n#endif /* _XFUNCPROTO_H_ */\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/X11/Xfuncs.h",
    "content": "/*\n * \nCopyright 1990, 1998  The Open Group\n\nPermission to use, copy, modify, distribute, and sell this software and its\ndocumentation for any purpose is hereby granted without fee, provided that\nthe above copyright notice appear in all copies and that both that\ncopyright notice and this permission notice appear in supporting\ndocumentation.\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE\nOPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN\nAN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\nCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\nExcept as contained in this notice, the name of The Open Group shall not be\nused in advertising or otherwise to promote the sale, use or other dealings\nin this Software without prior written authorization from The Open Group.\n *\n */\n\n#ifndef _XFUNCS_H_\n# define _XFUNCS_H_\n\n# include <X11/Xosdefs.h>\n\n/* the old Xfuncs.h, for pre-R6 */\n# if !(defined(XFree86LOADER) && defined(IN_MODULE))\n\n#  ifdef X_USEBFUNCS\nvoid bcopy();\nvoid bzero();\nint bcmp();\n#  else\n#   if defined(SYSV) && !defined(__SCO__) && !defined(__sun) && !defined(__UNIXWARE__) && !defined(_AIX)\n#    include <memory.h>\nvoid bcopy();\n#    define bzero(b,len) memset(b, 0, len)\n#    define bcmp(b1,b2,len) memcmp(b1, b2, len)\n#   else\n#    include <string.h>\n#    if defined(__SCO__) || defined(__sun) || defined(__UNIXWARE__) || defined(__CYGWIN__) || defined(_AIX) || defined(__APPLE__)\n#     include <strings.h>\n#    endif\n#    define _XFUNCS_H_INCLUDED_STRING_H\n#   endif\n#  endif /* X_USEBFUNCS */\n\n/* the new Xfuncs.h */\n\n/* the ANSI C way */\n#  ifndef _XFUNCS_H_INCLUDED_STRING_H\n#   include <string.h>\n#  endif\n#  undef bzero\n#  define bzero(b,len) memset(b,0,len)\n\n#  if defined WIN32 && defined __MINGW32__\n#   define bcopy(b1,b2,len) memmove(b2, b1, (size_t)(len))\n#  endif\n\n# endif /* !(defined(XFree86LOADER) && defined(IN_MODULE)) */\n\n#endif /* _XFUNCS_H_ */\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/X11/Xlib.h",
    "content": "/*\n\nCopyright 1985, 1986, 1987, 1991, 1998  The Open Group\n\nPermission to use, copy, modify, distribute, and sell this software and its\ndocumentation for any purpose is hereby granted without fee, provided that\nthe above copyright notice appear in all copies and that both that\ncopyright notice and this permission notice appear in supporting\ndocumentation.\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE\nOPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN\nAN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\nCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\nExcept as contained in this notice, the name of The Open Group shall not be\nused in advertising or otherwise to promote the sale, use or other dealings\nin this Software without prior written authorization from The Open Group.\n\n*/\n\n\n/*\n *\tXlib.h - Header definition and support file for the C subroutine\n *\tinterface library (Xlib) to the X Window System Protocol (V11).\n *\tStructures and symbols starting with \"_\" are private to the library.\n */\n#ifndef _X11_XLIB_H_\n#define _X11_XLIB_H_\n\n#define XlibSpecificationRelease 6\n\n#include <sys/types.h>\n\n#if defined(__SCO__) || defined(__UNIXWARE__)\n#include <stdint.h>\n#endif\n\n#include <X11/X.h>\n\n/* applications should not depend on these two headers being included! */\n#include <X11/Xfuncproto.h>\n#include <X11/Xosdefs.h>\n\n#ifndef X_WCHAR\n#include <stddef.h>\n#else\n#ifdef __UNIXOS2__\n#include <stdlib.h>\n#else\n/* replace this with #include or typedef appropriate for your system */\ntypedef unsigned long wchar_t;\n#endif\n#endif\n\n#if defined(ISC) && defined(USE_XMBTOWC)\n#define wctomb(a,b)\t_Xwctomb(a,b)\n#define mblen(a,b)\t_Xmblen(a,b)\n#ifndef USE_XWCHAR_STRING\n#define mbtowc(a,b,c)\t_Xmbtowc(a,b,c)\n#endif\n#endif\n\nextern int\n_Xmblen(\n#ifdef ISC\n    char const *str,\n    size_t len\n#else\n    char *str,\n    int len\n#endif\n    );\n\n/* API mentioning \"UTF8\" or \"utf8\" is an XFree86 extension, introduced in\n   November 2000. Its presence is indicated through the following macro. */\n#define X_HAVE_UTF8_STRING 1\n\n/* The Xlib structs are full of implicit padding to properly align members.\n   We can't clean that up without breaking ABI, so tell clang not to bother\n   complaining about it. */\n#ifdef __clang__\n#pragma clang diagnostic push\n#pragma clang diagnostic ignored \"-Wpadded\"\n#endif\n\ntypedef char *XPointer;\n\n#define Bool int\n#define Status int\n#define True 1\n#define False 0\n\n#define QueuedAlready 0\n#define QueuedAfterReading 1\n#define QueuedAfterFlush 2\n\n#define ConnectionNumber(dpy) \t(((_XPrivDisplay)dpy)->fd)\n#define RootWindow(dpy, scr) \t(ScreenOfDisplay(dpy,scr)->root)\n#define DefaultScreen(dpy) \t(((_XPrivDisplay)dpy)->default_screen)\n#define DefaultRootWindow(dpy) \t(ScreenOfDisplay(dpy,DefaultScreen(dpy))->root)\n#define DefaultVisual(dpy, scr) (ScreenOfDisplay(dpy,scr)->root_visual)\n#define DefaultGC(dpy, scr) \t(ScreenOfDisplay(dpy,scr)->default_gc)\n#define BlackPixel(dpy, scr) \t(ScreenOfDisplay(dpy,scr)->black_pixel)\n#define WhitePixel(dpy, scr) \t(ScreenOfDisplay(dpy,scr)->white_pixel)\n#define AllPlanes \t\t((unsigned long)~0L)\n#define QLength(dpy) \t\t(((_XPrivDisplay)dpy)->qlen)\n#define DisplayWidth(dpy, scr) \t(ScreenOfDisplay(dpy,scr)->width)\n#define DisplayHeight(dpy, scr) (ScreenOfDisplay(dpy,scr)->height)\n#define DisplayWidthMM(dpy, scr)(ScreenOfDisplay(dpy,scr)->mwidth)\n#define DisplayHeightMM(dpy, scr)(ScreenOfDisplay(dpy,scr)->mheight)\n#define DisplayPlanes(dpy, scr) (ScreenOfDisplay(dpy,scr)->root_depth)\n#define DisplayCells(dpy, scr) \t(DefaultVisual(dpy,scr)->map_entries)\n#define ScreenCount(dpy) \t(((_XPrivDisplay)dpy)->nscreens)\n#define ServerVendor(dpy) \t(((_XPrivDisplay)dpy)->vendor)\n#define ProtocolVersion(dpy) \t(((_XPrivDisplay)dpy)->proto_major_version)\n#define ProtocolRevision(dpy) \t(((_XPrivDisplay)dpy)->proto_minor_version)\n#define VendorRelease(dpy) \t(((_XPrivDisplay)dpy)->release)\n#define DisplayString(dpy) \t(((_XPrivDisplay)dpy)->display_name)\n#define DefaultDepth(dpy, scr) \t(ScreenOfDisplay(dpy,scr)->root_depth)\n#define DefaultColormap(dpy, scr)(ScreenOfDisplay(dpy,scr)->cmap)\n#define BitmapUnit(dpy) \t(((_XPrivDisplay)dpy)->bitmap_unit)\n#define BitmapBitOrder(dpy) \t(((_XPrivDisplay)dpy)->bitmap_bit_order)\n#define BitmapPad(dpy) \t\t(((_XPrivDisplay)dpy)->bitmap_pad)\n#define ImageByteOrder(dpy) \t(((_XPrivDisplay)dpy)->byte_order)\n#define NextRequest(dpy)\t(((_XPrivDisplay)dpy)->request + 1)\n#define LastKnownRequestProcessed(dpy)\t(((_XPrivDisplay)dpy)->last_request_read)\n\n/* macros for screen oriented applications (toolkit) */\n#define ScreenOfDisplay(dpy, scr)(&((_XPrivDisplay)dpy)->screens[scr])\n#define DefaultScreenOfDisplay(dpy) ScreenOfDisplay(dpy,DefaultScreen(dpy))\n#define DisplayOfScreen(s)\t((s)->display)\n#define RootWindowOfScreen(s)\t((s)->root)\n#define BlackPixelOfScreen(s)\t((s)->black_pixel)\n#define WhitePixelOfScreen(s)\t((s)->white_pixel)\n#define DefaultColormapOfScreen(s)((s)->cmap)\n#define DefaultDepthOfScreen(s)\t((s)->root_depth)\n#define DefaultGCOfScreen(s)\t((s)->default_gc)\n#define DefaultVisualOfScreen(s)((s)->root_visual)\n#define WidthOfScreen(s)\t((s)->width)\n#define HeightOfScreen(s)\t((s)->height)\n#define WidthMMOfScreen(s)\t((s)->mwidth)\n#define HeightMMOfScreen(s)\t((s)->mheight)\n#define PlanesOfScreen(s)\t((s)->root_depth)\n#define CellsOfScreen(s)\t(DefaultVisualOfScreen((s))->map_entries)\n#define MinCmapsOfScreen(s)\t((s)->min_maps)\n#define MaxCmapsOfScreen(s)\t((s)->max_maps)\n#define DoesSaveUnders(s)\t((s)->save_unders)\n#define DoesBackingStore(s)\t((s)->backing_store)\n#define EventMaskOfScreen(s)\t((s)->root_input_mask)\n\n/*\n * Extensions need a way to hang private data on some structures.\n */\ntypedef struct _XExtData {\n\tint number;\t\t/* number returned by XRegisterExtension */\n\tstruct _XExtData *next;\t/* next item on list of data for structure */\n\tint (*free_private)(\t/* called to free private storage */\n\tstruct _XExtData *extension\n\t);\n\tXPointer private_data;\t/* data private to this extension. */\n} XExtData;\n\n/*\n * This file contains structures used by the extension mechanism.\n */\ntypedef struct {\t\t/* public to extension, cannot be changed */\n\tint extension;\t\t/* extension number */\n\tint major_opcode;\t/* major op-code assigned by server */\n\tint first_event;\t/* first event number for the extension */\n\tint first_error;\t/* first error number for the extension */\n} XExtCodes;\n\n/*\n * Data structure for retrieving info about pixmap formats.\n */\n\ntypedef struct {\n    int depth;\n    int bits_per_pixel;\n    int scanline_pad;\n} XPixmapFormatValues;\n\n\n/*\n * Data structure for setting graphics context.\n */\ntypedef struct {\n\tint function;\t\t/* logical operation */\n\tunsigned long plane_mask;/* plane mask */\n\tunsigned long foreground;/* foreground pixel */\n\tunsigned long background;/* background pixel */\n\tint line_width;\t\t/* line width */\n\tint line_style;\t \t/* LineSolid, LineOnOffDash, LineDoubleDash */\n\tint cap_style;\t  \t/* CapNotLast, CapButt,\n\t\t\t\t   CapRound, CapProjecting */\n\tint join_style;\t \t/* JoinMiter, JoinRound, JoinBevel */\n\tint fill_style;\t \t/* FillSolid, FillTiled,\n\t\t\t\t   FillStippled, FillOpaeueStippled */\n\tint fill_rule;\t  \t/* EvenOddRule, WindingRule */\n\tint arc_mode;\t\t/* ArcChord, ArcPieSlice */\n\tPixmap tile;\t\t/* tile pixmap for tiling operations */\n\tPixmap stipple;\t\t/* stipple 1 plane pixmap for stipping */\n\tint ts_x_origin;\t/* offset for tile or stipple operations */\n\tint ts_y_origin;\n        Font font;\t        /* default text font for text operations */\n\tint subwindow_mode;     /* ClipByChildren, IncludeInferiors */\n\tBool graphics_exposures;/* boolean, should exposures be generated */\n\tint clip_x_origin;\t/* origin for clipping */\n\tint clip_y_origin;\n\tPixmap clip_mask;\t/* bitmap clipping; other calls for rects */\n\tint dash_offset;\t/* patterned/dashed line information */\n\tchar dashes;\n} XGCValues;\n\n/*\n * Graphics context.  The contents of this structure are implementation\n * dependent.  A GC should be treated as opaque by application code.\n */\n\ntypedef struct _XGC\n#ifdef XLIB_ILLEGAL_ACCESS\n{\n    XExtData *ext_data;\t/* hook for extension to hang data */\n    GContext gid;\t/* protocol ID for graphics context */\n    /* there is more to this structure, but it is private to Xlib */\n}\n#endif\n*GC;\n\n/*\n * Visual structure; contains information about colormapping possible.\n */\ntypedef struct {\n\tXExtData *ext_data;\t/* hook for extension to hang data */\n\tVisualID visualid;\t/* visual id of this visual */\n#if defined(__cplusplus) || defined(c_plusplus)\n\tint c_class;\t\t/* C++ class of screen (monochrome, etc.) */\n#else\n\tint class;\t\t/* class of screen (monochrome, etc.) */\n#endif\n\tunsigned long red_mask, green_mask, blue_mask;\t/* mask values */\n\tint bits_per_rgb;\t/* log base 2 of distinct color values */\n\tint map_entries;\t/* color map entries */\n} Visual;\n\n/*\n * Depth structure; contains information for each possible depth.\n */\ntypedef struct {\n\tint depth;\t\t/* this depth (Z) of the depth */\n\tint nvisuals;\t\t/* number of Visual types at this depth */\n\tVisual *visuals;\t/* list of visuals possible at this depth */\n} Depth;\n\n/*\n * Information about the screen.  The contents of this structure are\n * implementation dependent.  A Screen should be treated as opaque\n * by application code.\n */\n\nstruct _XDisplay;\t\t/* Forward declare before use for C++ */\n\ntypedef struct {\n\tXExtData *ext_data;\t/* hook for extension to hang data */\n\tstruct _XDisplay *display;/* back pointer to display structure */\n\tWindow root;\t\t/* Root window id. */\n\tint width, height;\t/* width and height of screen */\n\tint mwidth, mheight;\t/* width and height of  in millimeters */\n\tint ndepths;\t\t/* number of depths possible */\n\tDepth *depths;\t\t/* list of allowable depths on the screen */\n\tint root_depth;\t\t/* bits per pixel */\n\tVisual *root_visual;\t/* root visual */\n\tGC default_gc;\t\t/* GC for the root root visual */\n\tColormap cmap;\t\t/* default color map */\n\tunsigned long white_pixel;\n\tunsigned long black_pixel;\t/* White and Black pixel values */\n\tint max_maps, min_maps;\t/* max and min color maps */\n\tint backing_store;\t/* Never, WhenMapped, Always */\n\tBool save_unders;\n\tlong root_input_mask;\t/* initial root input mask */\n} Screen;\n\n/*\n * Format structure; describes ZFormat data the screen will understand.\n */\ntypedef struct {\n\tXExtData *ext_data;\t/* hook for extension to hang data */\n\tint depth;\t\t/* depth of this image format */\n\tint bits_per_pixel;\t/* bits/pixel at this depth */\n\tint scanline_pad;\t/* scanline must padded to this multiple */\n} ScreenFormat;\n\n/*\n * Data structure for setting window attributes.\n */\ntypedef struct {\n    Pixmap background_pixmap;\t/* background or None or ParentRelative */\n    unsigned long background_pixel;\t/* background pixel */\n    Pixmap border_pixmap;\t/* border of the window */\n    unsigned long border_pixel;\t/* border pixel value */\n    int bit_gravity;\t\t/* one of bit gravity values */\n    int win_gravity;\t\t/* one of the window gravity values */\n    int backing_store;\t\t/* NotUseful, WhenMapped, Always */\n    unsigned long backing_planes;/* planes to be preseved if possible */\n    unsigned long backing_pixel;/* value to use in restoring planes */\n    Bool save_under;\t\t/* should bits under be saved? (popups) */\n    long event_mask;\t\t/* set of events that should be saved */\n    long do_not_propagate_mask;\t/* set of events that should not propagate */\n    Bool override_redirect;\t/* boolean value for override-redirect */\n    Colormap colormap;\t\t/* color map to be associated with window */\n    Cursor cursor;\t\t/* cursor to be displayed (or None) */\n} XSetWindowAttributes;\n\ntypedef struct {\n    int x, y;\t\t\t/* location of window */\n    int width, height;\t\t/* width and height of window */\n    int border_width;\t\t/* border width of window */\n    int depth;          \t/* depth of window */\n    Visual *visual;\t\t/* the associated visual structure */\n    Window root;        \t/* root of screen containing window */\n#if defined(__cplusplus) || defined(c_plusplus)\n    int c_class;\t\t/* C++ InputOutput, InputOnly*/\n#else\n    int class;\t\t\t/* InputOutput, InputOnly*/\n#endif\n    int bit_gravity;\t\t/* one of bit gravity values */\n    int win_gravity;\t\t/* one of the window gravity values */\n    int backing_store;\t\t/* NotUseful, WhenMapped, Always */\n    unsigned long backing_planes;/* planes to be preserved if possible */\n    unsigned long backing_pixel;/* value to be used when restoring planes */\n    Bool save_under;\t\t/* boolean, should bits under be saved? */\n    Colormap colormap;\t\t/* color map to be associated with window */\n    Bool map_installed;\t\t/* boolean, is color map currently installed*/\n    int map_state;\t\t/* IsUnmapped, IsUnviewable, IsViewable */\n    long all_event_masks;\t/* set of events all people have interest in*/\n    long your_event_mask;\t/* my event mask */\n    long do_not_propagate_mask; /* set of events that should not propagate */\n    Bool override_redirect;\t/* boolean value for override-redirect */\n    Screen *screen;\t\t/* back pointer to correct screen */\n} XWindowAttributes;\n\n/*\n * Data structure for host setting; getting routines.\n *\n */\n\ntypedef struct {\n\tint family;\t\t/* for example FamilyInternet */\n\tint length;\t\t/* length of address, in bytes */\n\tchar *address;\t\t/* pointer to where to find the bytes */\n} XHostAddress;\n\n/*\n * Data structure for ServerFamilyInterpreted addresses in host routines\n */\ntypedef struct {\n\tint typelength;\t\t/* length of type string, in bytes */\n\tint valuelength;\t/* length of value string, in bytes */\n\tchar *type;\t\t/* pointer to where to find the type string */\n\tchar *value;\t\t/* pointer to where to find the address */\n} XServerInterpretedAddress;\n\n/*\n * Data structure for \"image\" data, used by image manipulation routines.\n */\ntypedef struct _XImage {\n    int width, height;\t\t/* size of image */\n    int xoffset;\t\t/* number of pixels offset in X direction */\n    int format;\t\t\t/* XYBitmap, XYPixmap, ZPixmap */\n    char *data;\t\t\t/* pointer to image data */\n    int byte_order;\t\t/* data byte order, LSBFirst, MSBFirst */\n    int bitmap_unit;\t\t/* quant. of scanline 8, 16, 32 */\n    int bitmap_bit_order;\t/* LSBFirst, MSBFirst */\n    int bitmap_pad;\t\t/* 8, 16, 32 either XY or ZPixmap */\n    int depth;\t\t\t/* depth of image */\n    int bytes_per_line;\t\t/* accelarator to next line */\n    int bits_per_pixel;\t\t/* bits per pixel (ZPixmap) */\n    unsigned long red_mask;\t/* bits in z arrangment */\n    unsigned long green_mask;\n    unsigned long blue_mask;\n    XPointer obdata;\t\t/* hook for the object routines to hang on */\n    struct funcs {\t\t/* image manipulation routines */\n\tstruct _XImage *(*create_image)(\n\t\tstruct _XDisplay* /* display */,\n\t\tVisual*\t\t/* visual */,\n\t\tunsigned int\t/* depth */,\n\t\tint\t\t/* format */,\n\t\tint\t\t/* offset */,\n\t\tchar*\t\t/* data */,\n\t\tunsigned int\t/* width */,\n\t\tunsigned int\t/* height */,\n\t\tint\t\t/* bitmap_pad */,\n\t\tint\t\t/* bytes_per_line */);\n\tint (*destroy_image)        (struct _XImage *);\n\tunsigned long (*get_pixel)  (struct _XImage *, int, int);\n\tint (*put_pixel)            (struct _XImage *, int, int, unsigned long);\n\tstruct _XImage *(*sub_image)(struct _XImage *, int, int, unsigned int, unsigned int);\n\tint (*add_pixel)            (struct _XImage *, long);\n\t} f;\n} XImage;\n\n/*\n * Data structure for XReconfigureWindow\n */\ntypedef struct {\n    int x, y;\n    int width, height;\n    int border_width;\n    Window sibling;\n    int stack_mode;\n} XWindowChanges;\n\n/*\n * Data structure used by color operations\n */\ntypedef struct {\n\tunsigned long pixel;\n\tunsigned short red, green, blue;\n\tchar flags;  /* do_red, do_green, do_blue */\n\tchar pad;\n} XColor;\n\n/*\n * Data structures for graphics operations.  On most machines, these are\n * congruent with the wire protocol structures, so reformatting the data\n * can be avoided on these architectures.\n */\ntypedef struct {\n    short x1, y1, x2, y2;\n} XSegment;\n\ntypedef struct {\n    short x, y;\n} XPoint;\n\ntypedef struct {\n    short x, y;\n    unsigned short width, height;\n} XRectangle;\n\ntypedef struct {\n    short x, y;\n    unsigned short width, height;\n    short angle1, angle2;\n} XArc;\n\n\n/* Data structure for XChangeKeyboardControl */\n\ntypedef struct {\n        int key_click_percent;\n        int bell_percent;\n        int bell_pitch;\n        int bell_duration;\n        int led;\n        int led_mode;\n        int key;\n        int auto_repeat_mode;   /* On, Off, Default */\n} XKeyboardControl;\n\n/* Data structure for XGetKeyboardControl */\n\ntypedef struct {\n        int key_click_percent;\n\tint bell_percent;\n\tunsigned int bell_pitch, bell_duration;\n\tunsigned long led_mask;\n\tint global_auto_repeat;\n\tchar auto_repeats[32];\n} XKeyboardState;\n\n/* Data structure for XGetMotionEvents.  */\n\ntypedef struct {\n        Time time;\n\tshort x, y;\n} XTimeCoord;\n\n/* Data structure for X{Set,Get}ModifierMapping */\n\ntypedef struct {\n \tint max_keypermod;\t/* The server's max # of keys per modifier */\n \tKeyCode *modifiermap;\t/* An 8 by max_keypermod array of modifiers */\n} XModifierKeymap;\n\n\n/*\n * Display datatype maintaining display specific data.\n * The contents of this structure are implementation dependent.\n * A Display should be treated as opaque by application code.\n */\n#ifndef XLIB_ILLEGAL_ACCESS\ntypedef struct _XDisplay Display;\n#endif\n\nstruct _XPrivate;\t\t/* Forward declare before use for C++ */\nstruct _XrmHashBucketRec;\n\ntypedef struct\n#ifdef XLIB_ILLEGAL_ACCESS\n_XDisplay\n#endif\n{\n\tXExtData *ext_data;\t/* hook for extension to hang data */\n\tstruct _XPrivate *private1;\n\tint fd;\t\t\t/* Network socket. */\n\tint private2;\n\tint proto_major_version;/* major version of server's X protocol */\n\tint proto_minor_version;/* minor version of servers X protocol */\n\tchar *vendor;\t\t/* vendor of the server hardware */\n        XID private3;\n\tXID private4;\n\tXID private5;\n\tint private6;\n\tXID (*resource_alloc)(\t/* allocator function */\n\t\tstruct _XDisplay*\n\t);\n\tint byte_order;\t\t/* screen byte order, LSBFirst, MSBFirst */\n\tint bitmap_unit;\t/* padding and data requirements */\n\tint bitmap_pad;\t\t/* padding requirements on bitmaps */\n\tint bitmap_bit_order;\t/* LeastSignificant or MostSignificant */\n\tint nformats;\t\t/* number of pixmap formats in list */\n\tScreenFormat *pixmap_format;\t/* pixmap format list */\n\tint private8;\n\tint release;\t\t/* release of the server */\n\tstruct _XPrivate *private9, *private10;\n\tint qlen;\t\t/* Length of input event queue */\n\tunsigned long last_request_read; /* seq number of last event read */\n\tunsigned long request;\t/* sequence number of last request. */\n\tXPointer private11;\n\tXPointer private12;\n\tXPointer private13;\n\tXPointer private14;\n\tunsigned max_request_size; /* maximum number 32 bit words in request*/\n\tstruct _XrmHashBucketRec *db;\n\tint (*private15)(\n\t\tstruct _XDisplay*\n\t\t);\n\tchar *display_name;\t/* \"host:display\" string used on this connect*/\n\tint default_screen;\t/* default screen for operations */\n\tint nscreens;\t\t/* number of screens on this server*/\n\tScreen *screens;\t/* pointer to list of screens */\n\tunsigned long motion_buffer;\t/* size of motion buffer */\n\tunsigned long private16;\n\tint min_keycode;\t/* minimum defined keycode */\n\tint max_keycode;\t/* maximum defined keycode */\n\tXPointer private17;\n\tXPointer private18;\n\tint private19;\n\tchar *xdefaults;\t/* contents of defaults from server */\n\t/* there is more to this structure, but it is private to Xlib */\n}\n#ifdef XLIB_ILLEGAL_ACCESS\nDisplay,\n#endif\n*_XPrivDisplay;\n\n#undef _XEVENT_\n#ifndef _XEVENT_\n/*\n * Definitions of specific events.\n */\ntypedef struct {\n\tint type;\t\t/* of event */\n\tunsigned long serial;\t/* # of last request processed by server */\n\tBool send_event;\t/* true if this came from a SendEvent request */\n\tDisplay *display;\t/* Display the event was read from */\n\tWindow window;\t        /* \"event\" window it is reported relative to */\n\tWindow root;\t        /* root window that the event occurred on */\n\tWindow subwindow;\t/* child window */\n\tTime time;\t\t/* milliseconds */\n\tint x, y;\t\t/* pointer x, y coordinates in event window */\n\tint x_root, y_root;\t/* coordinates relative to root */\n\tunsigned int state;\t/* key or button mask */\n\tunsigned int keycode;\t/* detail */\n\tBool same_screen;\t/* same screen flag */\n} XKeyEvent;\ntypedef XKeyEvent XKeyPressedEvent;\ntypedef XKeyEvent XKeyReleasedEvent;\n\ntypedef struct {\n\tint type;\t\t/* of event */\n\tunsigned long serial;\t/* # of last request processed by server */\n\tBool send_event;\t/* true if this came from a SendEvent request */\n\tDisplay *display;\t/* Display the event was read from */\n\tWindow window;\t        /* \"event\" window it is reported relative to */\n\tWindow root;\t        /* root window that the event occurred on */\n\tWindow subwindow;\t/* child window */\n\tTime time;\t\t/* milliseconds */\n\tint x, y;\t\t/* pointer x, y coordinates in event window */\n\tint x_root, y_root;\t/* coordinates relative to root */\n\tunsigned int state;\t/* key or button mask */\n\tunsigned int button;\t/* detail */\n\tBool same_screen;\t/* same screen flag */\n} XButtonEvent;\ntypedef XButtonEvent XButtonPressedEvent;\ntypedef XButtonEvent XButtonReleasedEvent;\n\ntypedef struct {\n\tint type;\t\t/* of event */\n\tunsigned long serial;\t/* # of last request processed by server */\n\tBool send_event;\t/* true if this came from a SendEvent request */\n\tDisplay *display;\t/* Display the event was read from */\n\tWindow window;\t        /* \"event\" window reported relative to */\n\tWindow root;\t        /* root window that the event occurred on */\n\tWindow subwindow;\t/* child window */\n\tTime time;\t\t/* milliseconds */\n\tint x, y;\t\t/* pointer x, y coordinates in event window */\n\tint x_root, y_root;\t/* coordinates relative to root */\n\tunsigned int state;\t/* key or button mask */\n\tchar is_hint;\t\t/* detail */\n\tBool same_screen;\t/* same screen flag */\n} XMotionEvent;\ntypedef XMotionEvent XPointerMovedEvent;\n\ntypedef struct {\n\tint type;\t\t/* of event */\n\tunsigned long serial;\t/* # of last request processed by server */\n\tBool send_event;\t/* true if this came from a SendEvent request */\n\tDisplay *display;\t/* Display the event was read from */\n\tWindow window;\t        /* \"event\" window reported relative to */\n\tWindow root;\t        /* root window that the event occurred on */\n\tWindow subwindow;\t/* child window */\n\tTime time;\t\t/* milliseconds */\n\tint x, y;\t\t/* pointer x, y coordinates in event window */\n\tint x_root, y_root;\t/* coordinates relative to root */\n\tint mode;\t\t/* NotifyNormal, NotifyGrab, NotifyUngrab */\n\tint detail;\n\t/*\n\t * NotifyAncestor, NotifyVirtual, NotifyInferior,\n\t * NotifyNonlinear,NotifyNonlinearVirtual\n\t */\n\tBool same_screen;\t/* same screen flag */\n\tBool focus;\t\t/* boolean focus */\n\tunsigned int state;\t/* key or button mask */\n} XCrossingEvent;\ntypedef XCrossingEvent XEnterWindowEvent;\ntypedef XCrossingEvent XLeaveWindowEvent;\n\ntypedef struct {\n\tint type;\t\t/* FocusIn or FocusOut */\n\tunsigned long serial;\t/* # of last request processed by server */\n\tBool send_event;\t/* true if this came from a SendEvent request */\n\tDisplay *display;\t/* Display the event was read from */\n\tWindow window;\t\t/* window of event */\n\tint mode;\t\t/* NotifyNormal, NotifyWhileGrabbed,\n\t\t\t\t   NotifyGrab, NotifyUngrab */\n\tint detail;\n\t/*\n\t * NotifyAncestor, NotifyVirtual, NotifyInferior,\n\t * NotifyNonlinear,NotifyNonlinearVirtual, NotifyPointer,\n\t * NotifyPointerRoot, NotifyDetailNone\n\t */\n} XFocusChangeEvent;\ntypedef XFocusChangeEvent XFocusInEvent;\ntypedef XFocusChangeEvent XFocusOutEvent;\n\n/* generated on EnterWindow and FocusIn  when KeyMapState selected */\ntypedef struct {\n\tint type;\n\tunsigned long serial;\t/* # of last request processed by server */\n\tBool send_event;\t/* true if this came from a SendEvent request */\n\tDisplay *display;\t/* Display the event was read from */\n\tWindow window;\n\tchar key_vector[32];\n} XKeymapEvent;\n\ntypedef struct {\n\tint type;\n\tunsigned long serial;\t/* # of last request processed by server */\n\tBool send_event;\t/* true if this came from a SendEvent request */\n\tDisplay *display;\t/* Display the event was read from */\n\tWindow window;\n\tint x, y;\n\tint width, height;\n\tint count;\t\t/* if non-zero, at least this many more */\n} XExposeEvent;\n\ntypedef struct {\n\tint type;\n\tunsigned long serial;\t/* # of last request processed by server */\n\tBool send_event;\t/* true if this came from a SendEvent request */\n\tDisplay *display;\t/* Display the event was read from */\n\tDrawable drawable;\n\tint x, y;\n\tint width, height;\n\tint count;\t\t/* if non-zero, at least this many more */\n\tint major_code;\t\t/* core is CopyArea or CopyPlane */\n\tint minor_code;\t\t/* not defined in the core */\n} XGraphicsExposeEvent;\n\ntypedef struct {\n\tint type;\n\tunsigned long serial;\t/* # of last request processed by server */\n\tBool send_event;\t/* true if this came from a SendEvent request */\n\tDisplay *display;\t/* Display the event was read from */\n\tDrawable drawable;\n\tint major_code;\t\t/* core is CopyArea or CopyPlane */\n\tint minor_code;\t\t/* not defined in the core */\n} XNoExposeEvent;\n\ntypedef struct {\n\tint type;\n\tunsigned long serial;\t/* # of last request processed by server */\n\tBool send_event;\t/* true if this came from a SendEvent request */\n\tDisplay *display;\t/* Display the event was read from */\n\tWindow window;\n\tint state;\t\t/* Visibility state */\n} XVisibilityEvent;\n\ntypedef struct {\n\tint type;\n\tunsigned long serial;\t/* # of last request processed by server */\n\tBool send_event;\t/* true if this came from a SendEvent request */\n\tDisplay *display;\t/* Display the event was read from */\n\tWindow parent;\t\t/* parent of the window */\n\tWindow window;\t\t/* window id of window created */\n\tint x, y;\t\t/* window location */\n\tint width, height;\t/* size of window */\n\tint border_width;\t/* border width */\n\tBool override_redirect;\t/* creation should be overridden */\n} XCreateWindowEvent;\n\ntypedef struct {\n\tint type;\n\tunsigned long serial;\t/* # of last request processed by server */\n\tBool send_event;\t/* true if this came from a SendEvent request */\n\tDisplay *display;\t/* Display the event was read from */\n\tWindow event;\n\tWindow window;\n} XDestroyWindowEvent;\n\ntypedef struct {\n\tint type;\n\tunsigned long serial;\t/* # of last request processed by server */\n\tBool send_event;\t/* true if this came from a SendEvent request */\n\tDisplay *display;\t/* Display the event was read from */\n\tWindow event;\n\tWindow window;\n\tBool from_configure;\n} XUnmapEvent;\n\ntypedef struct {\n\tint type;\n\tunsigned long serial;\t/* # of last request processed by server */\n\tBool send_event;\t/* true if this came from a SendEvent request */\n\tDisplay *display;\t/* Display the event was read from */\n\tWindow event;\n\tWindow window;\n\tBool override_redirect;\t/* boolean, is override set... */\n} XMapEvent;\n\ntypedef struct {\n\tint type;\n\tunsigned long serial;\t/* # of last request processed by server */\n\tBool send_event;\t/* true if this came from a SendEvent request */\n\tDisplay *display;\t/* Display the event was read from */\n\tWindow parent;\n\tWindow window;\n} XMapRequestEvent;\n\ntypedef struct {\n\tint type;\n\tunsigned long serial;\t/* # of last request processed by server */\n\tBool send_event;\t/* true if this came from a SendEvent request */\n\tDisplay *display;\t/* Display the event was read from */\n\tWindow event;\n\tWindow window;\n\tWindow parent;\n\tint x, y;\n\tBool override_redirect;\n} XReparentEvent;\n\ntypedef struct {\n\tint type;\n\tunsigned long serial;\t/* # of last request processed by server */\n\tBool send_event;\t/* true if this came from a SendEvent request */\n\tDisplay *display;\t/* Display the event was read from */\n\tWindow event;\n\tWindow window;\n\tint x, y;\n\tint width, height;\n\tint border_width;\n\tWindow above;\n\tBool override_redirect;\n} XConfigureEvent;\n\ntypedef struct {\n\tint type;\n\tunsigned long serial;\t/* # of last request processed by server */\n\tBool send_event;\t/* true if this came from a SendEvent request */\n\tDisplay *display;\t/* Display the event was read from */\n\tWindow event;\n\tWindow window;\n\tint x, y;\n} XGravityEvent;\n\ntypedef struct {\n\tint type;\n\tunsigned long serial;\t/* # of last request processed by server */\n\tBool send_event;\t/* true if this came from a SendEvent request */\n\tDisplay *display;\t/* Display the event was read from */\n\tWindow window;\n\tint width, height;\n} XResizeRequestEvent;\n\ntypedef struct {\n\tint type;\n\tunsigned long serial;\t/* # of last request processed by server */\n\tBool send_event;\t/* true if this came from a SendEvent request */\n\tDisplay *display;\t/* Display the event was read from */\n\tWindow parent;\n\tWindow window;\n\tint x, y;\n\tint width, height;\n\tint border_width;\n\tWindow above;\n\tint detail;\t\t/* Above, Below, TopIf, BottomIf, Opposite */\n\tunsigned long value_mask;\n} XConfigureRequestEvent;\n\ntypedef struct {\n\tint type;\n\tunsigned long serial;\t/* # of last request processed by server */\n\tBool send_event;\t/* true if this came from a SendEvent request */\n\tDisplay *display;\t/* Display the event was read from */\n\tWindow event;\n\tWindow window;\n\tint place;\t\t/* PlaceOnTop, PlaceOnBottom */\n} XCirculateEvent;\n\ntypedef struct {\n\tint type;\n\tunsigned long serial;\t/* # of last request processed by server */\n\tBool send_event;\t/* true if this came from a SendEvent request */\n\tDisplay *display;\t/* Display the event was read from */\n\tWindow parent;\n\tWindow window;\n\tint place;\t\t/* PlaceOnTop, PlaceOnBottom */\n} XCirculateRequestEvent;\n\ntypedef struct {\n\tint type;\n\tunsigned long serial;\t/* # of last request processed by server */\n\tBool send_event;\t/* true if this came from a SendEvent request */\n\tDisplay *display;\t/* Display the event was read from */\n\tWindow window;\n\tAtom atom;\n\tTime time;\n\tint state;\t\t/* NewValue, Deleted */\n} XPropertyEvent;\n\ntypedef struct {\n\tint type;\n\tunsigned long serial;\t/* # of last request processed by server */\n\tBool send_event;\t/* true if this came from a SendEvent request */\n\tDisplay *display;\t/* Display the event was read from */\n\tWindow window;\n\tAtom selection;\n\tTime time;\n} XSelectionClearEvent;\n\ntypedef struct {\n\tint type;\n\tunsigned long serial;\t/* # of last request processed by server */\n\tBool send_event;\t/* true if this came from a SendEvent request */\n\tDisplay *display;\t/* Display the event was read from */\n\tWindow owner;\n\tWindow requestor;\n\tAtom selection;\n\tAtom target;\n\tAtom property;\n\tTime time;\n} XSelectionRequestEvent;\n\ntypedef struct {\n\tint type;\n\tunsigned long serial;\t/* # of last request processed by server */\n\tBool send_event;\t/* true if this came from a SendEvent request */\n\tDisplay *display;\t/* Display the event was read from */\n\tWindow requestor;\n\tAtom selection;\n\tAtom target;\n\tAtom property;\t\t/* ATOM or None */\n\tTime time;\n} XSelectionEvent;\n\ntypedef struct {\n\tint type;\n\tunsigned long serial;\t/* # of last request processed by server */\n\tBool send_event;\t/* true if this came from a SendEvent request */\n\tDisplay *display;\t/* Display the event was read from */\n\tWindow window;\n\tColormap colormap;\t/* COLORMAP or None */\n#if defined(__cplusplus) || defined(c_plusplus)\n\tBool c_new;\t\t/* C++ */\n#else\n\tBool new;\n#endif\n\tint state;\t\t/* ColormapInstalled, ColormapUninstalled */\n} XColormapEvent;\n\ntypedef struct {\n\tint type;\n\tunsigned long serial;\t/* # of last request processed by server */\n\tBool send_event;\t/* true if this came from a SendEvent request */\n\tDisplay *display;\t/* Display the event was read from */\n\tWindow window;\n\tAtom message_type;\n\tint format;\n\tunion {\n\t\tchar b[20];\n\t\tshort s[10];\n\t\tlong l[5];\n\t\t} data;\n} XClientMessageEvent;\n\ntypedef struct {\n\tint type;\n\tunsigned long serial;\t/* # of last request processed by server */\n\tBool send_event;\t/* true if this came from a SendEvent request */\n\tDisplay *display;\t/* Display the event was read from */\n\tWindow window;\t\t/* unused */\n\tint request;\t\t/* one of MappingModifier, MappingKeyboard,\n\t\t\t\t   MappingPointer */\n\tint first_keycode;\t/* first keycode */\n\tint count;\t\t/* defines range of change w. first_keycode*/\n} XMappingEvent;\n\ntypedef struct {\n\tint type;\n\tDisplay *display;\t/* Display the event was read from */\n\tXID resourceid;\t\t/* resource id */\n\tunsigned long serial;\t/* serial number of failed request */\n\tunsigned char error_code;\t/* error code of failed request */\n\tunsigned char request_code;\t/* Major op-code of failed request */\n\tunsigned char minor_code;\t/* Minor op-code of failed request */\n} XErrorEvent;\n\ntypedef struct {\n\tint type;\n\tunsigned long serial;\t/* # of last request processed by server */\n\tBool send_event;\t/* true if this came from a SendEvent request */\n\tDisplay *display;/* Display the event was read from */\n\tWindow window;\t/* window on which event was requested in event mask */\n} XAnyEvent;\n\n\n/***************************************************************\n *\n * GenericEvent.  This event is the standard event for all newer extensions.\n */\n\ntypedef struct\n    {\n    int            type;         /* of event. Always GenericEvent */\n    unsigned long  serial;       /* # of last request processed */\n    Bool           send_event;   /* true if from SendEvent request */\n    Display        *display;     /* Display the event was read from */\n    int            extension;    /* major opcode of extension that caused the event */\n    int            evtype;       /* actual event type. */\n    } XGenericEvent;\n\ntypedef struct {\n    int            type;         /* of event. Always GenericEvent */\n    unsigned long  serial;       /* # of last request processed */\n    Bool           send_event;   /* true if from SendEvent request */\n    Display        *display;     /* Display the event was read from */\n    int            extension;    /* major opcode of extension that caused the event */\n    int            evtype;       /* actual event type. */\n    unsigned int   cookie;\n    void           *data;\n} XGenericEventCookie;\n\n/*\n * this union is defined so Xlib can always use the same sized\n * event structure internally, to avoid memory fragmentation.\n */\ntypedef union _XEvent {\n        int type;\t\t/* must not be changed; first element */\n\tXAnyEvent xany;\n\tXKeyEvent xkey;\n\tXButtonEvent xbutton;\n\tXMotionEvent xmotion;\n\tXCrossingEvent xcrossing;\n\tXFocusChangeEvent xfocus;\n\tXExposeEvent xexpose;\n\tXGraphicsExposeEvent xgraphicsexpose;\n\tXNoExposeEvent xnoexpose;\n\tXVisibilityEvent xvisibility;\n\tXCreateWindowEvent xcreatewindow;\n\tXDestroyWindowEvent xdestroywindow;\n\tXUnmapEvent xunmap;\n\tXMapEvent xmap;\n\tXMapRequestEvent xmaprequest;\n\tXReparentEvent xreparent;\n\tXConfigureEvent xconfigure;\n\tXGravityEvent xgravity;\n\tXResizeRequestEvent xresizerequest;\n\tXConfigureRequestEvent xconfigurerequest;\n\tXCirculateEvent xcirculate;\n\tXCirculateRequestEvent xcirculaterequest;\n\tXPropertyEvent xproperty;\n\tXSelectionClearEvent xselectionclear;\n\tXSelectionRequestEvent xselectionrequest;\n\tXSelectionEvent xselection;\n\tXColormapEvent xcolormap;\n\tXClientMessageEvent xclient;\n\tXMappingEvent xmapping;\n\tXErrorEvent xerror;\n\tXKeymapEvent xkeymap;\n\tXGenericEvent xgeneric;\n\tXGenericEventCookie xcookie;\n\tlong pad[24];\n} XEvent;\n#endif\n\n#define XAllocID(dpy) ((*((_XPrivDisplay)dpy)->resource_alloc)((dpy)))\n\n/*\n * per character font metric information.\n */\ntypedef struct {\n    short\tlbearing;\t/* origin to left edge of raster */\n    short\trbearing;\t/* origin to right edge of raster */\n    short\twidth;\t\t/* advance to next char's origin */\n    short\tascent;\t\t/* baseline to top edge of raster */\n    short\tdescent;\t/* baseline to bottom edge of raster */\n    unsigned short attributes;\t/* per char flags (not predefined) */\n} XCharStruct;\n\n/*\n * To allow arbitrary information with fonts, there are additional properties\n * returned.\n */\ntypedef struct {\n    Atom name;\n    unsigned long card32;\n} XFontProp;\n\ntypedef struct {\n    XExtData\t*ext_data;\t/* hook for extension to hang data */\n    Font        fid;            /* Font id for this font */\n    unsigned\tdirection;\t/* hint about direction the font is painted */\n    unsigned\tmin_char_or_byte2;/* first character */\n    unsigned\tmax_char_or_byte2;/* last character */\n    unsigned\tmin_byte1;\t/* first row that exists */\n    unsigned\tmax_byte1;\t/* last row that exists */\n    Bool\tall_chars_exist;/* flag if all characters have non-zero size*/\n    unsigned\tdefault_char;\t/* char to print for undefined character */\n    int         n_properties;   /* how many properties there are */\n    XFontProp\t*properties;\t/* pointer to array of additional properties*/\n    XCharStruct\tmin_bounds;\t/* minimum bounds over all existing char*/\n    XCharStruct\tmax_bounds;\t/* maximum bounds over all existing char*/\n    XCharStruct\t*per_char;\t/* first_char to last_char information */\n    int\t\tascent;\t\t/* log. extent above baseline for spacing */\n    int\t\tdescent;\t/* log. descent below baseline for spacing */\n} XFontStruct;\n\n/*\n * PolyText routines take these as arguments.\n */\ntypedef struct {\n    char *chars;\t\t/* pointer to string */\n    int nchars;\t\t\t/* number of characters */\n    int delta;\t\t\t/* delta between strings */\n    Font font;\t\t\t/* font to print it in, None don't change */\n} XTextItem;\n\ntypedef struct {\t\t/* normal 16 bit characters are two bytes */\n    unsigned char byte1;\n    unsigned char byte2;\n} XChar2b;\n\ntypedef struct {\n    XChar2b *chars;\t\t/* two byte characters */\n    int nchars;\t\t\t/* number of characters */\n    int delta;\t\t\t/* delta between strings */\n    Font font;\t\t\t/* font to print it in, None don't change */\n} XTextItem16;\n\n\ntypedef union { Display *display;\n\t\tGC gc;\n\t\tVisual *visual;\n\t\tScreen *screen;\n\t\tScreenFormat *pixmap_format;\n\t\tXFontStruct *font; } XEDataObject;\n\ntypedef struct {\n    XRectangle      max_ink_extent;\n    XRectangle      max_logical_extent;\n} XFontSetExtents;\n\n/* unused:\ntypedef void (*XOMProc)();\n */\n\ntypedef struct _XOM *XOM;\ntypedef struct _XOC *XOC, *XFontSet;\n\ntypedef struct {\n    char           *chars;\n    int             nchars;\n    int             delta;\n    XFontSet        font_set;\n} XmbTextItem;\n\ntypedef struct {\n    wchar_t        *chars;\n    int             nchars;\n    int             delta;\n    XFontSet        font_set;\n} XwcTextItem;\n\n#define XNRequiredCharSet \"requiredCharSet\"\n#define XNQueryOrientation \"queryOrientation\"\n#define XNBaseFontName \"baseFontName\"\n#define XNOMAutomatic \"omAutomatic\"\n#define XNMissingCharSet \"missingCharSet\"\n#define XNDefaultString \"defaultString\"\n#define XNOrientation \"orientation\"\n#define XNDirectionalDependentDrawing \"directionalDependentDrawing\"\n#define XNContextualDrawing \"contextualDrawing\"\n#define XNFontInfo \"fontInfo\"\n\ntypedef struct {\n    int charset_count;\n    char **charset_list;\n} XOMCharSetList;\n\ntypedef enum {\n    XOMOrientation_LTR_TTB,\n    XOMOrientation_RTL_TTB,\n    XOMOrientation_TTB_LTR,\n    XOMOrientation_TTB_RTL,\n    XOMOrientation_Context\n} XOrientation;\n\ntypedef struct {\n    int num_orientation;\n    XOrientation *orientation;\t/* Input Text description */\n} XOMOrientation;\n\ntypedef struct {\n    int num_font;\n    XFontStruct **font_struct_list;\n    char **font_name_list;\n} XOMFontInfo;\n\ntypedef struct _XIM *XIM;\ntypedef struct _XIC *XIC;\n\ntypedef void (*XIMProc)(\n    XIM,\n    XPointer,\n    XPointer\n);\n\ntypedef Bool (*XICProc)(\n    XIC,\n    XPointer,\n    XPointer\n);\n\ntypedef void (*XIDProc)(\n    Display*,\n    XPointer,\n    XPointer\n);\n\ntypedef unsigned long XIMStyle;\n\ntypedef struct {\n    unsigned short count_styles;\n    XIMStyle *supported_styles;\n} XIMStyles;\n\n#define XIMPreeditArea\t\t0x0001L\n#define XIMPreeditCallbacks\t0x0002L\n#define XIMPreeditPosition\t0x0004L\n#define XIMPreeditNothing\t0x0008L\n#define XIMPreeditNone\t\t0x0010L\n#define XIMStatusArea\t\t0x0100L\n#define XIMStatusCallbacks\t0x0200L\n#define XIMStatusNothing\t0x0400L\n#define XIMStatusNone\t\t0x0800L\n\n#define XNVaNestedList \"XNVaNestedList\"\n#define XNQueryInputStyle \"queryInputStyle\"\n#define XNClientWindow \"clientWindow\"\n#define XNInputStyle \"inputStyle\"\n#define XNFocusWindow \"focusWindow\"\n#define XNResourceName \"resourceName\"\n#define XNResourceClass \"resourceClass\"\n#define XNGeometryCallback \"geometryCallback\"\n#define XNDestroyCallback \"destroyCallback\"\n#define XNFilterEvents \"filterEvents\"\n#define XNPreeditStartCallback \"preeditStartCallback\"\n#define XNPreeditDoneCallback \"preeditDoneCallback\"\n#define XNPreeditDrawCallback \"preeditDrawCallback\"\n#define XNPreeditCaretCallback \"preeditCaretCallback\"\n#define XNPreeditStateNotifyCallback \"preeditStateNotifyCallback\"\n#define XNPreeditAttributes \"preeditAttributes\"\n#define XNStatusStartCallback \"statusStartCallback\"\n#define XNStatusDoneCallback \"statusDoneCallback\"\n#define XNStatusDrawCallback \"statusDrawCallback\"\n#define XNStatusAttributes \"statusAttributes\"\n#define XNArea \"area\"\n#define XNAreaNeeded \"areaNeeded\"\n#define XNSpotLocation \"spotLocation\"\n#define XNColormap \"colorMap\"\n#define XNStdColormap \"stdColorMap\"\n#define XNForeground \"foreground\"\n#define XNBackground \"background\"\n#define XNBackgroundPixmap \"backgroundPixmap\"\n#define XNFontSet \"fontSet\"\n#define XNLineSpace \"lineSpace\"\n#define XNCursor \"cursor\"\n\n#define XNQueryIMValuesList \"queryIMValuesList\"\n#define XNQueryICValuesList \"queryICValuesList\"\n#define XNVisiblePosition \"visiblePosition\"\n#define XNR6PreeditCallback \"r6PreeditCallback\"\n#define XNStringConversionCallback \"stringConversionCallback\"\n#define XNStringConversion \"stringConversion\"\n#define XNResetState \"resetState\"\n#define XNHotKey \"hotKey\"\n#define XNHotKeyState \"hotKeyState\"\n#define XNPreeditState \"preeditState\"\n#define XNSeparatorofNestedList \"separatorofNestedList\"\n\n#define XBufferOverflow\t\t-1\n#define XLookupNone\t\t1\n#define XLookupChars\t\t2\n#define XLookupKeySym\t\t3\n#define XLookupBoth\t\t4\n\ntypedef void *XVaNestedList;\n\ntypedef struct {\n    XPointer client_data;\n    XIMProc callback;\n} XIMCallback;\n\ntypedef struct {\n    XPointer client_data;\n    XICProc callback;\n} XICCallback;\n\ntypedef unsigned long XIMFeedback;\n\n#define XIMReverse\t\t1L\n#define XIMUnderline\t\t(1L<<1)\n#define XIMHighlight\t\t(1L<<2)\n#define XIMPrimary\t \t(1L<<5)\n#define XIMSecondary\t\t(1L<<6)\n#define XIMTertiary\t \t(1L<<7)\n#define XIMVisibleToForward \t(1L<<8)\n#define XIMVisibleToBackword \t(1L<<9)\n#define XIMVisibleToCenter \t(1L<<10)\n\ntypedef struct _XIMText {\n    unsigned short length;\n    XIMFeedback *feedback;\n    Bool encoding_is_wchar;\n    union {\n\tchar *multi_byte;\n\twchar_t *wide_char;\n    } string;\n} XIMText;\n\ntypedef\tunsigned long\t XIMPreeditState;\n\n#define\tXIMPreeditUnKnown\t0L\n#define\tXIMPreeditEnable\t1L\n#define\tXIMPreeditDisable\t(1L<<1)\n\ntypedef\tstruct\t_XIMPreeditStateNotifyCallbackStruct {\n    XIMPreeditState state;\n} XIMPreeditStateNotifyCallbackStruct;\n\ntypedef\tunsigned long\t XIMResetState;\n\n#define\tXIMInitialState\t\t1L\n#define\tXIMPreserveState\t(1L<<1)\n\ntypedef unsigned long XIMStringConversionFeedback;\n\n#define\tXIMStringConversionLeftEdge\t(0x00000001)\n#define\tXIMStringConversionRightEdge\t(0x00000002)\n#define\tXIMStringConversionTopEdge\t(0x00000004)\n#define\tXIMStringConversionBottomEdge\t(0x00000008)\n#define\tXIMStringConversionConcealed\t(0x00000010)\n#define\tXIMStringConversionWrapped\t(0x00000020)\n\ntypedef struct _XIMStringConversionText {\n    unsigned short length;\n    XIMStringConversionFeedback *feedback;\n    Bool encoding_is_wchar;\n    union {\n\tchar *mbs;\n\twchar_t *wcs;\n    } string;\n} XIMStringConversionText;\n\ntypedef\tunsigned short\tXIMStringConversionPosition;\n\ntypedef\tunsigned short\tXIMStringConversionType;\n\n#define\tXIMStringConversionBuffer\t(0x0001)\n#define\tXIMStringConversionLine\t\t(0x0002)\n#define\tXIMStringConversionWord\t\t(0x0003)\n#define\tXIMStringConversionChar\t\t(0x0004)\n\ntypedef\tunsigned short\tXIMStringConversionOperation;\n\n#define\tXIMStringConversionSubstitution\t(0x0001)\n#define\tXIMStringConversionRetrieval\t(0x0002)\n\ntypedef enum {\n    XIMForwardChar, XIMBackwardChar,\n    XIMForwardWord, XIMBackwardWord,\n    XIMCaretUp, XIMCaretDown,\n    XIMNextLine, XIMPreviousLine,\n    XIMLineStart, XIMLineEnd,\n    XIMAbsolutePosition,\n    XIMDontChange\n} XIMCaretDirection;\n\ntypedef struct _XIMStringConversionCallbackStruct {\n    XIMStringConversionPosition position;\n    XIMCaretDirection direction;\n    XIMStringConversionOperation operation;\n    unsigned short factor;\n    XIMStringConversionText *text;\n} XIMStringConversionCallbackStruct;\n\ntypedef struct _XIMPreeditDrawCallbackStruct {\n    int caret;\t\t/* Cursor offset within pre-edit string */\n    int chg_first;\t/* Starting change position */\n    int chg_length;\t/* Length of the change in character count */\n    XIMText *text;\n} XIMPreeditDrawCallbackStruct;\n\ntypedef enum {\n    XIMIsInvisible,\t/* Disable caret feedback */\n    XIMIsPrimary,\t/* UI defined caret feedback */\n    XIMIsSecondary\t/* UI defined caret feedback */\n} XIMCaretStyle;\n\ntypedef struct _XIMPreeditCaretCallbackStruct {\n    int position;\t\t /* Caret offset within pre-edit string */\n    XIMCaretDirection direction; /* Caret moves direction */\n    XIMCaretStyle style;\t /* Feedback of the caret */\n} XIMPreeditCaretCallbackStruct;\n\ntypedef enum {\n    XIMTextType,\n    XIMBitmapType\n} XIMStatusDataType;\n\ntypedef struct _XIMStatusDrawCallbackStruct {\n    XIMStatusDataType type;\n    union {\n\tXIMText *text;\n\tPixmap  bitmap;\n    } data;\n} XIMStatusDrawCallbackStruct;\n\ntypedef struct _XIMHotKeyTrigger {\n    KeySym\t keysym;\n    int\t\t modifier;\n    int\t\t modifier_mask;\n} XIMHotKeyTrigger;\n\ntypedef struct _XIMHotKeyTriggers {\n    int\t\t\t num_hot_key;\n    XIMHotKeyTrigger\t*key;\n} XIMHotKeyTriggers;\n\ntypedef\tunsigned long\t XIMHotKeyState;\n\n#define\tXIMHotKeyStateON\t(0x0001L)\n#define\tXIMHotKeyStateOFF\t(0x0002L)\n\ntypedef struct {\n    unsigned short count_values;\n    char **supported_values;\n} XIMValuesList;\n\n_XFUNCPROTOBEGIN\n\n#if defined(WIN32) && !defined(_XLIBINT_)\n#define _Xdebug (*_Xdebug_p)\n#endif\n\nextern int _Xdebug;\n\nextern XFontStruct *XLoadQueryFont(\n    Display*\t\t/* display */,\n    _Xconst char*\t/* name */\n);\n\nextern XFontStruct *XQueryFont(\n    Display*\t\t/* display */,\n    XID\t\t\t/* font_ID */\n);\n\n\nextern XTimeCoord *XGetMotionEvents(\n    Display*\t\t/* display */,\n    Window\t\t/* w */,\n    Time\t\t/* start */,\n    Time\t\t/* stop */,\n    int*\t\t/* nevents_return */\n);\n\nextern XModifierKeymap *XDeleteModifiermapEntry(\n    XModifierKeymap*\t/* modmap */,\n#if NeedWidePrototypes\n    unsigned int\t/* keycode_entry */,\n#else\n    KeyCode\t\t/* keycode_entry */,\n#endif\n    int\t\t\t/* modifier */\n);\n\nextern XModifierKeymap\t*XGetModifierMapping(\n    Display*\t\t/* display */\n);\n\nextern XModifierKeymap\t*XInsertModifiermapEntry(\n    XModifierKeymap*\t/* modmap */,\n#if NeedWidePrototypes\n    unsigned int\t/* keycode_entry */,\n#else\n    KeyCode\t\t/* keycode_entry */,\n#endif\n    int\t\t\t/* modifier */\n);\n\nextern XModifierKeymap *XNewModifiermap(\n    int\t\t\t/* max_keys_per_mod */\n);\n\nextern XImage *XCreateImage(\n    Display*\t\t/* display */,\n    Visual*\t\t/* visual */,\n    unsigned int\t/* depth */,\n    int\t\t\t/* format */,\n    int\t\t\t/* offset */,\n    char*\t\t/* data */,\n    unsigned int\t/* width */,\n    unsigned int\t/* height */,\n    int\t\t\t/* bitmap_pad */,\n    int\t\t\t/* bytes_per_line */\n);\nextern Status XInitImage(\n    XImage*\t\t/* image */\n);\nextern XImage *XGetImage(\n    Display*\t\t/* display */,\n    Drawable\t\t/* d */,\n    int\t\t\t/* x */,\n    int\t\t\t/* y */,\n    unsigned int\t/* width */,\n    unsigned int\t/* height */,\n    unsigned long\t/* plane_mask */,\n    int\t\t\t/* format */\n);\nextern XImage *XGetSubImage(\n    Display*\t\t/* display */,\n    Drawable\t\t/* d */,\n    int\t\t\t/* x */,\n    int\t\t\t/* y */,\n    unsigned int\t/* width */,\n    unsigned int\t/* height */,\n    unsigned long\t/* plane_mask */,\n    int\t\t\t/* format */,\n    XImage*\t\t/* dest_image */,\n    int\t\t\t/* dest_x */,\n    int\t\t\t/* dest_y */\n);\n\n/*\n * X function declarations.\n */\nextern Display *XOpenDisplay(\n    _Xconst char*\t/* display_name */\n);\n\nextern void XrmInitialize(\n    void\n);\n\nextern char *XFetchBytes(\n    Display*\t\t/* display */,\n    int*\t\t/* nbytes_return */\n);\nextern char *XFetchBuffer(\n    Display*\t\t/* display */,\n    int*\t\t/* nbytes_return */,\n    int\t\t\t/* buffer */\n);\nextern char *XGetAtomName(\n    Display*\t\t/* display */,\n    Atom\t\t/* atom */\n);\nextern Status XGetAtomNames(\n    Display*\t\t/* dpy */,\n    Atom*\t\t/* atoms */,\n    int\t\t\t/* count */,\n    char**\t\t/* names_return */\n);\nextern char *XGetDefault(\n    Display*\t\t/* display */,\n    _Xconst char*\t/* program */,\n    _Xconst char*\t/* option */\n);\nextern char *XDisplayName(\n    _Xconst char*\t/* string */\n);\nextern char *XKeysymToString(\n    KeySym\t\t/* keysym */\n);\n\nextern int (*XSynchronize(\n    Display*\t\t/* display */,\n    Bool\t\t/* onoff */\n))(\n    Display*\t\t/* display */\n);\nextern int (*XSetAfterFunction(\n    Display*\t\t/* display */,\n    int (*) (\n\t     Display*\t/* display */\n            )\t\t/* procedure */\n))(\n    Display*\t\t/* display */\n);\nextern Atom XInternAtom(\n    Display*\t\t/* display */,\n    _Xconst char*\t/* atom_name */,\n    Bool\t\t/* only_if_exists */\n);\nextern Status XInternAtoms(\n    Display*\t\t/* dpy */,\n    char**\t\t/* names */,\n    int\t\t\t/* count */,\n    Bool\t\t/* onlyIfExists */,\n    Atom*\t\t/* atoms_return */\n);\nextern Colormap XCopyColormapAndFree(\n    Display*\t\t/* display */,\n    Colormap\t\t/* colormap */\n);\nextern Colormap XCreateColormap(\n    Display*\t\t/* display */,\n    Window\t\t/* w */,\n    Visual*\t\t/* visual */,\n    int\t\t\t/* alloc */\n);\nextern Cursor XCreatePixmapCursor(\n    Display*\t\t/* display */,\n    Pixmap\t\t/* source */,\n    Pixmap\t\t/* mask */,\n    XColor*\t\t/* foreground_color */,\n    XColor*\t\t/* background_color */,\n    unsigned int\t/* x */,\n    unsigned int\t/* y */\n);\nextern Cursor XCreateGlyphCursor(\n    Display*\t\t/* display */,\n    Font\t\t/* source_font */,\n    Font\t\t/* mask_font */,\n    unsigned int\t/* source_char */,\n    unsigned int\t/* mask_char */,\n    XColor _Xconst *\t/* foreground_color */,\n    XColor _Xconst *\t/* background_color */\n);\nextern Cursor XCreateFontCursor(\n    Display*\t\t/* display */,\n    unsigned int\t/* shape */\n);\nextern Font XLoadFont(\n    Display*\t\t/* display */,\n    _Xconst char*\t/* name */\n);\nextern GC XCreateGC(\n    Display*\t\t/* display */,\n    Drawable\t\t/* d */,\n    unsigned long\t/* valuemask */,\n    XGCValues*\t\t/* values */\n);\nextern GContext XGContextFromGC(\n    GC\t\t\t/* gc */\n);\nextern void XFlushGC(\n    Display*\t\t/* display */,\n    GC\t\t\t/* gc */\n);\nextern Pixmap XCreatePixmap(\n    Display*\t\t/* display */,\n    Drawable\t\t/* d */,\n    unsigned int\t/* width */,\n    unsigned int\t/* height */,\n    unsigned int\t/* depth */\n);\nextern Pixmap XCreateBitmapFromData(\n    Display*\t\t/* display */,\n    Drawable\t\t/* d */,\n    _Xconst char*\t/* data */,\n    unsigned int\t/* width */,\n    unsigned int\t/* height */\n);\nextern Pixmap XCreatePixmapFromBitmapData(\n    Display*\t\t/* display */,\n    Drawable\t\t/* d */,\n    char*\t\t/* data */,\n    unsigned int\t/* width */,\n    unsigned int\t/* height */,\n    unsigned long\t/* fg */,\n    unsigned long\t/* bg */,\n    unsigned int\t/* depth */\n);\nextern Window XCreateSimpleWindow(\n    Display*\t\t/* display */,\n    Window\t\t/* parent */,\n    int\t\t\t/* x */,\n    int\t\t\t/* y */,\n    unsigned int\t/* width */,\n    unsigned int\t/* height */,\n    unsigned int\t/* border_width */,\n    unsigned long\t/* border */,\n    unsigned long\t/* background */\n);\nextern Window XGetSelectionOwner(\n    Display*\t\t/* display */,\n    Atom\t\t/* selection */\n);\nextern Window XCreateWindow(\n    Display*\t\t/* display */,\n    Window\t\t/* parent */,\n    int\t\t\t/* x */,\n    int\t\t\t/* y */,\n    unsigned int\t/* width */,\n    unsigned int\t/* height */,\n    unsigned int\t/* border_width */,\n    int\t\t\t/* depth */,\n    unsigned int\t/* class */,\n    Visual*\t\t/* visual */,\n    unsigned long\t/* valuemask */,\n    XSetWindowAttributes*\t/* attributes */\n);\nextern Colormap *XListInstalledColormaps(\n    Display*\t\t/* display */,\n    Window\t\t/* w */,\n    int*\t\t/* num_return */\n);\nextern char **XListFonts(\n    Display*\t\t/* display */,\n    _Xconst char*\t/* pattern */,\n    int\t\t\t/* maxnames */,\n    int*\t\t/* actual_count_return */\n);\nextern char **XListFontsWithInfo(\n    Display*\t\t/* display */,\n    _Xconst char*\t/* pattern */,\n    int\t\t\t/* maxnames */,\n    int*\t\t/* count_return */,\n    XFontStruct**\t/* info_return */\n);\nextern char **XGetFontPath(\n    Display*\t\t/* display */,\n    int*\t\t/* npaths_return */\n);\nextern char **XListExtensions(\n    Display*\t\t/* display */,\n    int*\t\t/* nextensions_return */\n);\nextern Atom *XListProperties(\n    Display*\t\t/* display */,\n    Window\t\t/* w */,\n    int*\t\t/* num_prop_return */\n);\nextern XHostAddress *XListHosts(\n    Display*\t\t/* display */,\n    int*\t\t/* nhosts_return */,\n    Bool*\t\t/* state_return */\n);\n_X_DEPRECATED\nextern KeySym XKeycodeToKeysym(\n    Display*\t\t/* display */,\n#if NeedWidePrototypes\n    unsigned int\t/* keycode */,\n#else\n    KeyCode\t\t/* keycode */,\n#endif\n    int\t\t\t/* index */\n);\nextern KeySym XLookupKeysym(\n    XKeyEvent*\t\t/* key_event */,\n    int\t\t\t/* index */\n);\nextern KeySym *XGetKeyboardMapping(\n    Display*\t\t/* display */,\n#if NeedWidePrototypes\n    unsigned int\t/* first_keycode */,\n#else\n    KeyCode\t\t/* first_keycode */,\n#endif\n    int\t\t\t/* keycode_count */,\n    int*\t\t/* keysyms_per_keycode_return */\n);\nextern KeySym XStringToKeysym(\n    _Xconst char*\t/* string */\n);\nextern long XMaxRequestSize(\n    Display*\t\t/* display */\n);\nextern long XExtendedMaxRequestSize(\n    Display*\t\t/* display */\n);\nextern char *XResourceManagerString(\n    Display*\t\t/* display */\n);\nextern char *XScreenResourceString(\n\tScreen*\t\t/* screen */\n);\nextern unsigned long XDisplayMotionBufferSize(\n    Display*\t\t/* display */\n);\nextern VisualID XVisualIDFromVisual(\n    Visual*\t\t/* visual */\n);\n\n/* multithread routines */\n\nextern Status XInitThreads(\n    void\n);\n\nextern void XLockDisplay(\n    Display*\t\t/* display */\n);\n\nextern void XUnlockDisplay(\n    Display*\t\t/* display */\n);\n\n/* routines for dealing with extensions */\n\nextern XExtCodes *XInitExtension(\n    Display*\t\t/* display */,\n    _Xconst char*\t/* name */\n);\n\nextern XExtCodes *XAddExtension(\n    Display*\t\t/* display */\n);\nextern XExtData *XFindOnExtensionList(\n    XExtData**\t\t/* structure */,\n    int\t\t\t/* number */\n);\nextern XExtData **XEHeadOfExtensionList(\n    XEDataObject\t/* object */\n);\n\n/* these are routines for which there are also macros */\nextern Window XRootWindow(\n    Display*\t\t/* display */,\n    int\t\t\t/* screen_number */\n);\nextern Window XDefaultRootWindow(\n    Display*\t\t/* display */\n);\nextern Window XRootWindowOfScreen(\n    Screen*\t\t/* screen */\n);\nextern Visual *XDefaultVisual(\n    Display*\t\t/* display */,\n    int\t\t\t/* screen_number */\n);\nextern Visual *XDefaultVisualOfScreen(\n    Screen*\t\t/* screen */\n);\nextern GC XDefaultGC(\n    Display*\t\t/* display */,\n    int\t\t\t/* screen_number */\n);\nextern GC XDefaultGCOfScreen(\n    Screen*\t\t/* screen */\n);\nextern unsigned long XBlackPixel(\n    Display*\t\t/* display */,\n    int\t\t\t/* screen_number */\n);\nextern unsigned long XWhitePixel(\n    Display*\t\t/* display */,\n    int\t\t\t/* screen_number */\n);\nextern unsigned long XAllPlanes(\n    void\n);\nextern unsigned long XBlackPixelOfScreen(\n    Screen*\t\t/* screen */\n);\nextern unsigned long XWhitePixelOfScreen(\n    Screen*\t\t/* screen */\n);\nextern unsigned long XNextRequest(\n    Display*\t\t/* display */\n);\nextern unsigned long XLastKnownRequestProcessed(\n    Display*\t\t/* display */\n);\nextern char *XServerVendor(\n    Display*\t\t/* display */\n);\nextern char *XDisplayString(\n    Display*\t\t/* display */\n);\nextern Colormap XDefaultColormap(\n    Display*\t\t/* display */,\n    int\t\t\t/* screen_number */\n);\nextern Colormap XDefaultColormapOfScreen(\n    Screen*\t\t/* screen */\n);\nextern Display *XDisplayOfScreen(\n    Screen*\t\t/* screen */\n);\nextern Screen *XScreenOfDisplay(\n    Display*\t\t/* display */,\n    int\t\t\t/* screen_number */\n);\nextern Screen *XDefaultScreenOfDisplay(\n    Display*\t\t/* display */\n);\nextern long XEventMaskOfScreen(\n    Screen*\t\t/* screen */\n);\n\nextern int XScreenNumberOfScreen(\n    Screen*\t\t/* screen */\n);\n\ntypedef int (*XErrorHandler) (\t    /* WARNING, this type not in Xlib spec */\n    Display*\t\t/* display */,\n    XErrorEvent*\t/* error_event */\n);\n\nextern XErrorHandler XSetErrorHandler (\n    XErrorHandler\t/* handler */\n);\n\n\ntypedef int (*XIOErrorHandler) (    /* WARNING, this type not in Xlib spec */\n    Display*\t\t/* display */\n);\n\nextern XIOErrorHandler XSetIOErrorHandler (\n    XIOErrorHandler\t/* handler */\n);\n\n\nextern XPixmapFormatValues *XListPixmapFormats(\n    Display*\t\t/* display */,\n    int*\t\t/* count_return */\n);\nextern int *XListDepths(\n    Display*\t\t/* display */,\n    int\t\t\t/* screen_number */,\n    int*\t\t/* count_return */\n);\n\n/* ICCCM routines for things that don't require special include files; */\n/* other declarations are given in Xutil.h                             */\nextern Status XReconfigureWMWindow(\n    Display*\t\t/* display */,\n    Window\t\t/* w */,\n    int\t\t\t/* screen_number */,\n    unsigned int\t/* mask */,\n    XWindowChanges*\t/* changes */\n);\n\nextern Status XGetWMProtocols(\n    Display*\t\t/* display */,\n    Window\t\t/* w */,\n    Atom**\t\t/* protocols_return */,\n    int*\t\t/* count_return */\n);\nextern Status XSetWMProtocols(\n    Display*\t\t/* display */,\n    Window\t\t/* w */,\n    Atom*\t\t/* protocols */,\n    int\t\t\t/* count */\n);\nextern Status XIconifyWindow(\n    Display*\t\t/* display */,\n    Window\t\t/* w */,\n    int\t\t\t/* screen_number */\n);\nextern Status XWithdrawWindow(\n    Display*\t\t/* display */,\n    Window\t\t/* w */,\n    int\t\t\t/* screen_number */\n);\nextern Status XGetCommand(\n    Display*\t\t/* display */,\n    Window\t\t/* w */,\n    char***\t\t/* argv_return */,\n    int*\t\t/* argc_return */\n);\nextern Status XGetWMColormapWindows(\n    Display*\t\t/* display */,\n    Window\t\t/* w */,\n    Window**\t\t/* windows_return */,\n    int*\t\t/* count_return */\n);\nextern Status XSetWMColormapWindows(\n    Display*\t\t/* display */,\n    Window\t\t/* w */,\n    Window*\t\t/* colormap_windows */,\n    int\t\t\t/* count */\n);\nextern void XFreeStringList(\n    char**\t\t/* list */\n);\nextern int XSetTransientForHint(\n    Display*\t\t/* display */,\n    Window\t\t/* w */,\n    Window\t\t/* prop_window */\n);\n\n/* The following are given in alphabetical order */\n\nextern int XActivateScreenSaver(\n    Display*\t\t/* display */\n);\n\nextern int XAddHost(\n    Display*\t\t/* display */,\n    XHostAddress*\t/* host */\n);\n\nextern int XAddHosts(\n    Display*\t\t/* display */,\n    XHostAddress*\t/* hosts */,\n    int\t\t\t/* num_hosts */\n);\n\nextern int XAddToExtensionList(\n    struct _XExtData**\t/* structure */,\n    XExtData*\t\t/* ext_data */\n);\n\nextern int XAddToSaveSet(\n    Display*\t\t/* display */,\n    Window\t\t/* w */\n);\n\nextern Status XAllocColor(\n    Display*\t\t/* display */,\n    Colormap\t\t/* colormap */,\n    XColor*\t\t/* screen_in_out */\n);\n\nextern Status XAllocColorCells(\n    Display*\t\t/* display */,\n    Colormap\t\t/* colormap */,\n    Bool\t        /* contig */,\n    unsigned long*\t/* plane_masks_return */,\n    unsigned int\t/* nplanes */,\n    unsigned long*\t/* pixels_return */,\n    unsigned int \t/* npixels */\n);\n\nextern Status XAllocColorPlanes(\n    Display*\t\t/* display */,\n    Colormap\t\t/* colormap */,\n    Bool\t\t/* contig */,\n    unsigned long*\t/* pixels_return */,\n    int\t\t\t/* ncolors */,\n    int\t\t\t/* nreds */,\n    int\t\t\t/* ngreens */,\n    int\t\t\t/* nblues */,\n    unsigned long*\t/* rmask_return */,\n    unsigned long*\t/* gmask_return */,\n    unsigned long*\t/* bmask_return */\n);\n\nextern Status XAllocNamedColor(\n    Display*\t\t/* display */,\n    Colormap\t\t/* colormap */,\n    _Xconst char*\t/* color_name */,\n    XColor*\t\t/* screen_def_return */,\n    XColor*\t\t/* exact_def_return */\n);\n\nextern int XAllowEvents(\n    Display*\t\t/* display */,\n    int\t\t\t/* event_mode */,\n    Time\t\t/* time */\n);\n\nextern int XAutoRepeatOff(\n    Display*\t\t/* display */\n);\n\nextern int XAutoRepeatOn(\n    Display*\t\t/* display */\n);\n\nextern int XBell(\n    Display*\t\t/* display */,\n    int\t\t\t/* percent */\n);\n\nextern int XBitmapBitOrder(\n    Display*\t\t/* display */\n);\n\nextern int XBitmapPad(\n    Display*\t\t/* display */\n);\n\nextern int XBitmapUnit(\n    Display*\t\t/* display */\n);\n\nextern int XCellsOfScreen(\n    Screen*\t\t/* screen */\n);\n\nextern int XChangeActivePointerGrab(\n    Display*\t\t/* display */,\n    unsigned int\t/* event_mask */,\n    Cursor\t\t/* cursor */,\n    Time\t\t/* time */\n);\n\nextern int XChangeGC(\n    Display*\t\t/* display */,\n    GC\t\t\t/* gc */,\n    unsigned long\t/* valuemask */,\n    XGCValues*\t\t/* values */\n);\n\nextern int XChangeKeyboardControl(\n    Display*\t\t/* display */,\n    unsigned long\t/* value_mask */,\n    XKeyboardControl*\t/* values */\n);\n\nextern int XChangeKeyboardMapping(\n    Display*\t\t/* display */,\n    int\t\t\t/* first_keycode */,\n    int\t\t\t/* keysyms_per_keycode */,\n    KeySym*\t\t/* keysyms */,\n    int\t\t\t/* num_codes */\n);\n\nextern int XChangePointerControl(\n    Display*\t\t/* display */,\n    Bool\t\t/* do_accel */,\n    Bool\t\t/* do_threshold */,\n    int\t\t\t/* accel_numerator */,\n    int\t\t\t/* accel_denominator */,\n    int\t\t\t/* threshold */\n);\n\nextern int XChangeProperty(\n    Display*\t\t/* display */,\n    Window\t\t/* w */,\n    Atom\t\t/* property */,\n    Atom\t\t/* type */,\n    int\t\t\t/* format */,\n    int\t\t\t/* mode */,\n    _Xconst unsigned char*\t/* data */,\n    int\t\t\t/* nelements */\n);\n\nextern int XChangeSaveSet(\n    Display*\t\t/* display */,\n    Window\t\t/* w */,\n    int\t\t\t/* change_mode */\n);\n\nextern int XChangeWindowAttributes(\n    Display*\t\t/* display */,\n    Window\t\t/* w */,\n    unsigned long\t/* valuemask */,\n    XSetWindowAttributes* /* attributes */\n);\n\nextern Bool XCheckIfEvent(\n    Display*\t\t/* display */,\n    XEvent*\t\t/* event_return */,\n    Bool (*) (\n\t       Display*\t\t\t/* display */,\n               XEvent*\t\t\t/* event */,\n               XPointer\t\t\t/* arg */\n             )\t\t/* predicate */,\n    XPointer\t\t/* arg */\n);\n\nextern Bool XCheckMaskEvent(\n    Display*\t\t/* display */,\n    long\t\t/* event_mask */,\n    XEvent*\t\t/* event_return */\n);\n\nextern Bool XCheckTypedEvent(\n    Display*\t\t/* display */,\n    int\t\t\t/* event_type */,\n    XEvent*\t\t/* event_return */\n);\n\nextern Bool XCheckTypedWindowEvent(\n    Display*\t\t/* display */,\n    Window\t\t/* w */,\n    int\t\t\t/* event_type */,\n    XEvent*\t\t/* event_return */\n);\n\nextern Bool XCheckWindowEvent(\n    Display*\t\t/* display */,\n    Window\t\t/* w */,\n    long\t\t/* event_mask */,\n    XEvent*\t\t/* event_return */\n);\n\nextern int XCirculateSubwindows(\n    Display*\t\t/* display */,\n    Window\t\t/* w */,\n    int\t\t\t/* direction */\n);\n\nextern int XCirculateSubwindowsDown(\n    Display*\t\t/* display */,\n    Window\t\t/* w */\n);\n\nextern int XCirculateSubwindowsUp(\n    Display*\t\t/* display */,\n    Window\t\t/* w */\n);\n\nextern int XClearArea(\n    Display*\t\t/* display */,\n    Window\t\t/* w */,\n    int\t\t\t/* x */,\n    int\t\t\t/* y */,\n    unsigned int\t/* width */,\n    unsigned int\t/* height */,\n    Bool\t\t/* exposures */\n);\n\nextern int XClearWindow(\n    Display*\t\t/* display */,\n    Window\t\t/* w */\n);\n\nextern int XCloseDisplay(\n    Display*\t\t/* display */\n);\n\nextern int XConfigureWindow(\n    Display*\t\t/* display */,\n    Window\t\t/* w */,\n    unsigned int\t/* value_mask */,\n    XWindowChanges*\t/* values */\n);\n\nextern int XConnectionNumber(\n    Display*\t\t/* display */\n);\n\nextern int XConvertSelection(\n    Display*\t\t/* display */,\n    Atom\t\t/* selection */,\n    Atom \t\t/* target */,\n    Atom\t\t/* property */,\n    Window\t\t/* requestor */,\n    Time\t\t/* time */\n);\n\nextern int XCopyArea(\n    Display*\t\t/* display */,\n    Drawable\t\t/* src */,\n    Drawable\t\t/* dest */,\n    GC\t\t\t/* gc */,\n    int\t\t\t/* src_x */,\n    int\t\t\t/* src_y */,\n    unsigned int\t/* width */,\n    unsigned int\t/* height */,\n    int\t\t\t/* dest_x */,\n    int\t\t\t/* dest_y */\n);\n\nextern int XCopyGC(\n    Display*\t\t/* display */,\n    GC\t\t\t/* src */,\n    unsigned long\t/* valuemask */,\n    GC\t\t\t/* dest */\n);\n\nextern int XCopyPlane(\n    Display*\t\t/* display */,\n    Drawable\t\t/* src */,\n    Drawable\t\t/* dest */,\n    GC\t\t\t/* gc */,\n    int\t\t\t/* src_x */,\n    int\t\t\t/* src_y */,\n    unsigned int\t/* width */,\n    unsigned int\t/* height */,\n    int\t\t\t/* dest_x */,\n    int\t\t\t/* dest_y */,\n    unsigned long\t/* plane */\n);\n\nextern int XDefaultDepth(\n    Display*\t\t/* display */,\n    int\t\t\t/* screen_number */\n);\n\nextern int XDefaultDepthOfScreen(\n    Screen*\t\t/* screen */\n);\n\nextern int XDefaultScreen(\n    Display*\t\t/* display */\n);\n\nextern int XDefineCursor(\n    Display*\t\t/* display */,\n    Window\t\t/* w */,\n    Cursor\t\t/* cursor */\n);\n\nextern int XDeleteProperty(\n    Display*\t\t/* display */,\n    Window\t\t/* w */,\n    Atom\t\t/* property */\n);\n\nextern int XDestroyWindow(\n    Display*\t\t/* display */,\n    Window\t\t/* w */\n);\n\nextern int XDestroySubwindows(\n    Display*\t\t/* display */,\n    Window\t\t/* w */\n);\n\nextern int XDoesBackingStore(\n    Screen*\t\t/* screen */\n);\n\nextern Bool XDoesSaveUnders(\n    Screen*\t\t/* screen */\n);\n\nextern int XDisableAccessControl(\n    Display*\t\t/* display */\n);\n\n\nextern int XDisplayCells(\n    Display*\t\t/* display */,\n    int\t\t\t/* screen_number */\n);\n\nextern int XDisplayHeight(\n    Display*\t\t/* display */,\n    int\t\t\t/* screen_number */\n);\n\nextern int XDisplayHeightMM(\n    Display*\t\t/* display */,\n    int\t\t\t/* screen_number */\n);\n\nextern int XDisplayKeycodes(\n    Display*\t\t/* display */,\n    int*\t\t/* min_keycodes_return */,\n    int*\t\t/* max_keycodes_return */\n);\n\nextern int XDisplayPlanes(\n    Display*\t\t/* display */,\n    int\t\t\t/* screen_number */\n);\n\nextern int XDisplayWidth(\n    Display*\t\t/* display */,\n    int\t\t\t/* screen_number */\n);\n\nextern int XDisplayWidthMM(\n    Display*\t\t/* display */,\n    int\t\t\t/* screen_number */\n);\n\nextern int XDrawArc(\n    Display*\t\t/* display */,\n    Drawable\t\t/* d */,\n    GC\t\t\t/* gc */,\n    int\t\t\t/* x */,\n    int\t\t\t/* y */,\n    unsigned int\t/* width */,\n    unsigned int\t/* height */,\n    int\t\t\t/* angle1 */,\n    int\t\t\t/* angle2 */\n);\n\nextern int XDrawArcs(\n    Display*\t\t/* display */,\n    Drawable\t\t/* d */,\n    GC\t\t\t/* gc */,\n    XArc*\t\t/* arcs */,\n    int\t\t\t/* narcs */\n);\n\nextern int XDrawImageString(\n    Display*\t\t/* display */,\n    Drawable\t\t/* d */,\n    GC\t\t\t/* gc */,\n    int\t\t\t/* x */,\n    int\t\t\t/* y */,\n    _Xconst char*\t/* string */,\n    int\t\t\t/* length */\n);\n\nextern int XDrawImageString16(\n    Display*\t\t/* display */,\n    Drawable\t\t/* d */,\n    GC\t\t\t/* gc */,\n    int\t\t\t/* x */,\n    int\t\t\t/* y */,\n    _Xconst XChar2b*\t/* string */,\n    int\t\t\t/* length */\n);\n\nextern int XDrawLine(\n    Display*\t\t/* display */,\n    Drawable\t\t/* d */,\n    GC\t\t\t/* gc */,\n    int\t\t\t/* x1 */,\n    int\t\t\t/* y1 */,\n    int\t\t\t/* x2 */,\n    int\t\t\t/* y2 */\n);\n\nextern int XDrawLines(\n    Display*\t\t/* display */,\n    Drawable\t\t/* d */,\n    GC\t\t\t/* gc */,\n    XPoint*\t\t/* points */,\n    int\t\t\t/* npoints */,\n    int\t\t\t/* mode */\n);\n\nextern int XDrawPoint(\n    Display*\t\t/* display */,\n    Drawable\t\t/* d */,\n    GC\t\t\t/* gc */,\n    int\t\t\t/* x */,\n    int\t\t\t/* y */\n);\n\nextern int XDrawPoints(\n    Display*\t\t/* display */,\n    Drawable\t\t/* d */,\n    GC\t\t\t/* gc */,\n    XPoint*\t\t/* points */,\n    int\t\t\t/* npoints */,\n    int\t\t\t/* mode */\n);\n\nextern int XDrawRectangle(\n    Display*\t\t/* display */,\n    Drawable\t\t/* d */,\n    GC\t\t\t/* gc */,\n    int\t\t\t/* x */,\n    int\t\t\t/* y */,\n    unsigned int\t/* width */,\n    unsigned int\t/* height */\n);\n\nextern int XDrawRectangles(\n    Display*\t\t/* display */,\n    Drawable\t\t/* d */,\n    GC\t\t\t/* gc */,\n    XRectangle*\t\t/* rectangles */,\n    int\t\t\t/* nrectangles */\n);\n\nextern int XDrawSegments(\n    Display*\t\t/* display */,\n    Drawable\t\t/* d */,\n    GC\t\t\t/* gc */,\n    XSegment*\t\t/* segments */,\n    int\t\t\t/* nsegments */\n);\n\nextern int XDrawString(\n    Display*\t\t/* display */,\n    Drawable\t\t/* d */,\n    GC\t\t\t/* gc */,\n    int\t\t\t/* x */,\n    int\t\t\t/* y */,\n    _Xconst char*\t/* string */,\n    int\t\t\t/* length */\n);\n\nextern int XDrawString16(\n    Display*\t\t/* display */,\n    Drawable\t\t/* d */,\n    GC\t\t\t/* gc */,\n    int\t\t\t/* x */,\n    int\t\t\t/* y */,\n    _Xconst XChar2b*\t/* string */,\n    int\t\t\t/* length */\n);\n\nextern int XDrawText(\n    Display*\t\t/* display */,\n    Drawable\t\t/* d */,\n    GC\t\t\t/* gc */,\n    int\t\t\t/* x */,\n    int\t\t\t/* y */,\n    XTextItem*\t\t/* items */,\n    int\t\t\t/* nitems */\n);\n\nextern int XDrawText16(\n    Display*\t\t/* display */,\n    Drawable\t\t/* d */,\n    GC\t\t\t/* gc */,\n    int\t\t\t/* x */,\n    int\t\t\t/* y */,\n    XTextItem16*\t/* items */,\n    int\t\t\t/* nitems */\n);\n\nextern int XEnableAccessControl(\n    Display*\t\t/* display */\n);\n\nextern int XEventsQueued(\n    Display*\t\t/* display */,\n    int\t\t\t/* mode */\n);\n\nextern Status XFetchName(\n    Display*\t\t/* display */,\n    Window\t\t/* w */,\n    char**\t\t/* window_name_return */\n);\n\nextern int XFillArc(\n    Display*\t\t/* display */,\n    Drawable\t\t/* d */,\n    GC\t\t\t/* gc */,\n    int\t\t\t/* x */,\n    int\t\t\t/* y */,\n    unsigned int\t/* width */,\n    unsigned int\t/* height */,\n    int\t\t\t/* angle1 */,\n    int\t\t\t/* angle2 */\n);\n\nextern int XFillArcs(\n    Display*\t\t/* display */,\n    Drawable\t\t/* d */,\n    GC\t\t\t/* gc */,\n    XArc*\t\t/* arcs */,\n    int\t\t\t/* narcs */\n);\n\nextern int XFillPolygon(\n    Display*\t\t/* display */,\n    Drawable\t\t/* d */,\n    GC\t\t\t/* gc */,\n    XPoint*\t\t/* points */,\n    int\t\t\t/* npoints */,\n    int\t\t\t/* shape */,\n    int\t\t\t/* mode */\n);\n\nextern int XFillRectangle(\n    Display*\t\t/* display */,\n    Drawable\t\t/* d */,\n    GC\t\t\t/* gc */,\n    int\t\t\t/* x */,\n    int\t\t\t/* y */,\n    unsigned int\t/* width */,\n    unsigned int\t/* height */\n);\n\nextern int XFillRectangles(\n    Display*\t\t/* display */,\n    Drawable\t\t/* d */,\n    GC\t\t\t/* gc */,\n    XRectangle*\t\t/* rectangles */,\n    int\t\t\t/* nrectangles */\n);\n\nextern int XFlush(\n    Display*\t\t/* display */\n);\n\nextern int XForceScreenSaver(\n    Display*\t\t/* display */,\n    int\t\t\t/* mode */\n);\n\nextern int XFree(\n    void*\t\t/* data */\n);\n\nextern int XFreeColormap(\n    Display*\t\t/* display */,\n    Colormap\t\t/* colormap */\n);\n\nextern int XFreeColors(\n    Display*\t\t/* display */,\n    Colormap\t\t/* colormap */,\n    unsigned long*\t/* pixels */,\n    int\t\t\t/* npixels */,\n    unsigned long\t/* planes */\n);\n\nextern int XFreeCursor(\n    Display*\t\t/* display */,\n    Cursor\t\t/* cursor */\n);\n\nextern int XFreeExtensionList(\n    char**\t\t/* list */\n);\n\nextern int XFreeFont(\n    Display*\t\t/* display */,\n    XFontStruct*\t/* font_struct */\n);\n\nextern int XFreeFontInfo(\n    char**\t\t/* names */,\n    XFontStruct*\t/* free_info */,\n    int\t\t\t/* actual_count */\n);\n\nextern int XFreeFontNames(\n    char**\t\t/* list */\n);\n\nextern int XFreeFontPath(\n    char**\t\t/* list */\n);\n\nextern int XFreeGC(\n    Display*\t\t/* display */,\n    GC\t\t\t/* gc */\n);\n\nextern int XFreeModifiermap(\n    XModifierKeymap*\t/* modmap */\n);\n\nextern int XFreePixmap(\n    Display*\t\t/* display */,\n    Pixmap\t\t/* pixmap */\n);\n\nextern int XGeometry(\n    Display*\t\t/* display */,\n    int\t\t\t/* screen */,\n    _Xconst char*\t/* position */,\n    _Xconst char*\t/* default_position */,\n    unsigned int\t/* bwidth */,\n    unsigned int\t/* fwidth */,\n    unsigned int\t/* fheight */,\n    int\t\t\t/* xadder */,\n    int\t\t\t/* yadder */,\n    int*\t\t/* x_return */,\n    int*\t\t/* y_return */,\n    int*\t\t/* width_return */,\n    int*\t\t/* height_return */\n);\n\nextern int XGetErrorDatabaseText(\n    Display*\t\t/* display */,\n    _Xconst char*\t/* name */,\n    _Xconst char*\t/* message */,\n    _Xconst char*\t/* default_string */,\n    char*\t\t/* buffer_return */,\n    int\t\t\t/* length */\n);\n\nextern int XGetErrorText(\n    Display*\t\t/* display */,\n    int\t\t\t/* code */,\n    char*\t\t/* buffer_return */,\n    int\t\t\t/* length */\n);\n\nextern Bool XGetFontProperty(\n    XFontStruct*\t/* font_struct */,\n    Atom\t\t/* atom */,\n    unsigned long*\t/* value_return */\n);\n\nextern Status XGetGCValues(\n    Display*\t\t/* display */,\n    GC\t\t\t/* gc */,\n    unsigned long\t/* valuemask */,\n    XGCValues*\t\t/* values_return */\n);\n\nextern Status XGetGeometry(\n    Display*\t\t/* display */,\n    Drawable\t\t/* d */,\n    Window*\t\t/* root_return */,\n    int*\t\t/* x_return */,\n    int*\t\t/* y_return */,\n    unsigned int*\t/* width_return */,\n    unsigned int*\t/* height_return */,\n    unsigned int*\t/* border_width_return */,\n    unsigned int*\t/* depth_return */\n);\n\nextern Status XGetIconName(\n    Display*\t\t/* display */,\n    Window\t\t/* w */,\n    char**\t\t/* icon_name_return */\n);\n\nextern int XGetInputFocus(\n    Display*\t\t/* display */,\n    Window*\t\t/* focus_return */,\n    int*\t\t/* revert_to_return */\n);\n\nextern int XGetKeyboardControl(\n    Display*\t\t/* display */,\n    XKeyboardState*\t/* values_return */\n);\n\nextern int XGetPointerControl(\n    Display*\t\t/* display */,\n    int*\t\t/* accel_numerator_return */,\n    int*\t\t/* accel_denominator_return */,\n    int*\t\t/* threshold_return */\n);\n\nextern int XGetPointerMapping(\n    Display*\t\t/* display */,\n    unsigned char*\t/* map_return */,\n    int\t\t\t/* nmap */\n);\n\nextern int XGetScreenSaver(\n    Display*\t\t/* display */,\n    int*\t\t/* timeout_return */,\n    int*\t\t/* interval_return */,\n    int*\t\t/* prefer_blanking_return */,\n    int*\t\t/* allow_exposures_return */\n);\n\nextern Status XGetTransientForHint(\n    Display*\t\t/* display */,\n    Window\t\t/* w */,\n    Window*\t\t/* prop_window_return */\n);\n\nextern int XGetWindowProperty(\n    Display*\t\t/* display */,\n    Window\t\t/* w */,\n    Atom\t\t/* property */,\n    long\t\t/* long_offset */,\n    long\t\t/* long_length */,\n    Bool\t\t/* delete */,\n    Atom\t\t/* req_type */,\n    Atom*\t\t/* actual_type_return */,\n    int*\t\t/* actual_format_return */,\n    unsigned long*\t/* nitems_return */,\n    unsigned long*\t/* bytes_after_return */,\n    unsigned char**\t/* prop_return */\n);\n\nextern Status XGetWindowAttributes(\n    Display*\t\t/* display */,\n    Window\t\t/* w */,\n    XWindowAttributes*\t/* window_attributes_return */\n);\n\nextern int XGrabButton(\n    Display*\t\t/* display */,\n    unsigned int\t/* button */,\n    unsigned int\t/* modifiers */,\n    Window\t\t/* grab_window */,\n    Bool\t\t/* owner_events */,\n    unsigned int\t/* event_mask */,\n    int\t\t\t/* pointer_mode */,\n    int\t\t\t/* keyboard_mode */,\n    Window\t\t/* confine_to */,\n    Cursor\t\t/* cursor */\n);\n\nextern int XGrabKey(\n    Display*\t\t/* display */,\n    int\t\t\t/* keycode */,\n    unsigned int\t/* modifiers */,\n    Window\t\t/* grab_window */,\n    Bool\t\t/* owner_events */,\n    int\t\t\t/* pointer_mode */,\n    int\t\t\t/* keyboard_mode */\n);\n\nextern int XGrabKeyboard(\n    Display*\t\t/* display */,\n    Window\t\t/* grab_window */,\n    Bool\t\t/* owner_events */,\n    int\t\t\t/* pointer_mode */,\n    int\t\t\t/* keyboard_mode */,\n    Time\t\t/* time */\n);\n\nextern int XGrabPointer(\n    Display*\t\t/* display */,\n    Window\t\t/* grab_window */,\n    Bool\t\t/* owner_events */,\n    unsigned int\t/* event_mask */,\n    int\t\t\t/* pointer_mode */,\n    int\t\t\t/* keyboard_mode */,\n    Window\t\t/* confine_to */,\n    Cursor\t\t/* cursor */,\n    Time\t\t/* time */\n);\n\nextern int XGrabServer(\n    Display*\t\t/* display */\n);\n\nextern int XHeightMMOfScreen(\n    Screen*\t\t/* screen */\n);\n\nextern int XHeightOfScreen(\n    Screen*\t\t/* screen */\n);\n\nextern int XIfEvent(\n    Display*\t\t/* display */,\n    XEvent*\t\t/* event_return */,\n    Bool (*) (\n\t       Display*\t\t\t/* display */,\n               XEvent*\t\t\t/* event */,\n               XPointer\t\t\t/* arg */\n             )\t\t/* predicate */,\n    XPointer\t\t/* arg */\n);\n\nextern int XImageByteOrder(\n    Display*\t\t/* display */\n);\n\nextern int XInstallColormap(\n    Display*\t\t/* display */,\n    Colormap\t\t/* colormap */\n);\n\nextern KeyCode XKeysymToKeycode(\n    Display*\t\t/* display */,\n    KeySym\t\t/* keysym */\n);\n\nextern int XKillClient(\n    Display*\t\t/* display */,\n    XID\t\t\t/* resource */\n);\n\nextern Status XLookupColor(\n    Display*\t\t/* display */,\n    Colormap\t\t/* colormap */,\n    _Xconst char*\t/* color_name */,\n    XColor*\t\t/* exact_def_return */,\n    XColor*\t\t/* screen_def_return */\n);\n\nextern int XLowerWindow(\n    Display*\t\t/* display */,\n    Window\t\t/* w */\n);\n\nextern int XMapRaised(\n    Display*\t\t/* display */,\n    Window\t\t/* w */\n);\n\nextern int XMapSubwindows(\n    Display*\t\t/* display */,\n    Window\t\t/* w */\n);\n\nextern int XMapWindow(\n    Display*\t\t/* display */,\n    Window\t\t/* w */\n);\n\nextern int XMaskEvent(\n    Display*\t\t/* display */,\n    long\t\t/* event_mask */,\n    XEvent*\t\t/* event_return */\n);\n\nextern int XMaxCmapsOfScreen(\n    Screen*\t\t/* screen */\n);\n\nextern int XMinCmapsOfScreen(\n    Screen*\t\t/* screen */\n);\n\nextern int XMoveResizeWindow(\n    Display*\t\t/* display */,\n    Window\t\t/* w */,\n    int\t\t\t/* x */,\n    int\t\t\t/* y */,\n    unsigned int\t/* width */,\n    unsigned int\t/* height */\n);\n\nextern int XMoveWindow(\n    Display*\t\t/* display */,\n    Window\t\t/* w */,\n    int\t\t\t/* x */,\n    int\t\t\t/* y */\n);\n\nextern int XNextEvent(\n    Display*\t\t/* display */,\n    XEvent*\t\t/* event_return */\n);\n\nextern int XNoOp(\n    Display*\t\t/* display */\n);\n\nextern Status XParseColor(\n    Display*\t\t/* display */,\n    Colormap\t\t/* colormap */,\n    _Xconst char*\t/* spec */,\n    XColor*\t\t/* exact_def_return */\n);\n\nextern int XParseGeometry(\n    _Xconst char*\t/* parsestring */,\n    int*\t\t/* x_return */,\n    int*\t\t/* y_return */,\n    unsigned int*\t/* width_return */,\n    unsigned int*\t/* height_return */\n);\n\nextern int XPeekEvent(\n    Display*\t\t/* display */,\n    XEvent*\t\t/* event_return */\n);\n\nextern int XPeekIfEvent(\n    Display*\t\t/* display */,\n    XEvent*\t\t/* event_return */,\n    Bool (*) (\n\t       Display*\t\t/* display */,\n               XEvent*\t\t/* event */,\n               XPointer\t\t/* arg */\n             )\t\t/* predicate */,\n    XPointer\t\t/* arg */\n);\n\nextern int XPending(\n    Display*\t\t/* display */\n);\n\nextern int XPlanesOfScreen(\n    Screen*\t\t/* screen */\n);\n\nextern int XProtocolRevision(\n    Display*\t\t/* display */\n);\n\nextern int XProtocolVersion(\n    Display*\t\t/* display */\n);\n\n\nextern int XPutBackEvent(\n    Display*\t\t/* display */,\n    XEvent*\t\t/* event */\n);\n\nextern int XPutImage(\n    Display*\t\t/* display */,\n    Drawable\t\t/* d */,\n    GC\t\t\t/* gc */,\n    XImage*\t\t/* image */,\n    int\t\t\t/* src_x */,\n    int\t\t\t/* src_y */,\n    int\t\t\t/* dest_x */,\n    int\t\t\t/* dest_y */,\n    unsigned int\t/* width */,\n    unsigned int\t/* height */\n);\n\nextern int XQLength(\n    Display*\t\t/* display */\n);\n\nextern Status XQueryBestCursor(\n    Display*\t\t/* display */,\n    Drawable\t\t/* d */,\n    unsigned int        /* width */,\n    unsigned int\t/* height */,\n    unsigned int*\t/* width_return */,\n    unsigned int*\t/* height_return */\n);\n\nextern Status XQueryBestSize(\n    Display*\t\t/* display */,\n    int\t\t\t/* class */,\n    Drawable\t\t/* which_screen */,\n    unsigned int\t/* width */,\n    unsigned int\t/* height */,\n    unsigned int*\t/* width_return */,\n    unsigned int*\t/* height_return */\n);\n\nextern Status XQueryBestStipple(\n    Display*\t\t/* display */,\n    Drawable\t\t/* which_screen */,\n    unsigned int\t/* width */,\n    unsigned int\t/* height */,\n    unsigned int*\t/* width_return */,\n    unsigned int*\t/* height_return */\n);\n\nextern Status XQueryBestTile(\n    Display*\t\t/* display */,\n    Drawable\t\t/* which_screen */,\n    unsigned int\t/* width */,\n    unsigned int\t/* height */,\n    unsigned int*\t/* width_return */,\n    unsigned int*\t/* height_return */\n);\n\nextern int XQueryColor(\n    Display*\t\t/* display */,\n    Colormap\t\t/* colormap */,\n    XColor*\t\t/* def_in_out */\n);\n\nextern int XQueryColors(\n    Display*\t\t/* display */,\n    Colormap\t\t/* colormap */,\n    XColor*\t\t/* defs_in_out */,\n    int\t\t\t/* ncolors */\n);\n\nextern Bool XQueryExtension(\n    Display*\t\t/* display */,\n    _Xconst char*\t/* name */,\n    int*\t\t/* major_opcode_return */,\n    int*\t\t/* first_event_return */,\n    int*\t\t/* first_error_return */\n);\n\nextern int XQueryKeymap(\n    Display*\t\t/* display */,\n    char [32]\t\t/* keys_return */\n);\n\nextern Bool XQueryPointer(\n    Display*\t\t/* display */,\n    Window\t\t/* w */,\n    Window*\t\t/* root_return */,\n    Window*\t\t/* child_return */,\n    int*\t\t/* root_x_return */,\n    int*\t\t/* root_y_return */,\n    int*\t\t/* win_x_return */,\n    int*\t\t/* win_y_return */,\n    unsigned int*       /* mask_return */\n);\n\nextern int XQueryTextExtents(\n    Display*\t\t/* display */,\n    XID\t\t\t/* font_ID */,\n    _Xconst char*\t/* string */,\n    int\t\t\t/* nchars */,\n    int*\t\t/* direction_return */,\n    int*\t\t/* font_ascent_return */,\n    int*\t\t/* font_descent_return */,\n    XCharStruct*\t/* overall_return */\n);\n\nextern int XQueryTextExtents16(\n    Display*\t\t/* display */,\n    XID\t\t\t/* font_ID */,\n    _Xconst XChar2b*\t/* string */,\n    int\t\t\t/* nchars */,\n    int*\t\t/* direction_return */,\n    int*\t\t/* font_ascent_return */,\n    int*\t\t/* font_descent_return */,\n    XCharStruct*\t/* overall_return */\n);\n\nextern Status XQueryTree(\n    Display*\t\t/* display */,\n    Window\t\t/* w */,\n    Window*\t\t/* root_return */,\n    Window*\t\t/* parent_return */,\n    Window**\t\t/* children_return */,\n    unsigned int*\t/* nchildren_return */\n);\n\nextern int XRaiseWindow(\n    Display*\t\t/* display */,\n    Window\t\t/* w */\n);\n\nextern int XReadBitmapFile(\n    Display*\t\t/* display */,\n    Drawable \t\t/* d */,\n    _Xconst char*\t/* filename */,\n    unsigned int*\t/* width_return */,\n    unsigned int*\t/* height_return */,\n    Pixmap*\t\t/* bitmap_return */,\n    int*\t\t/* x_hot_return */,\n    int*\t\t/* y_hot_return */\n);\n\nextern int XReadBitmapFileData(\n    _Xconst char*\t/* filename */,\n    unsigned int*\t/* width_return */,\n    unsigned int*\t/* height_return */,\n    unsigned char**\t/* data_return */,\n    int*\t\t/* x_hot_return */,\n    int*\t\t/* y_hot_return */\n);\n\nextern int XRebindKeysym(\n    Display*\t\t/* display */,\n    KeySym\t\t/* keysym */,\n    KeySym*\t\t/* list */,\n    int\t\t\t/* mod_count */,\n    _Xconst unsigned char*\t/* string */,\n    int\t\t\t/* bytes_string */\n);\n\nextern int XRecolorCursor(\n    Display*\t\t/* display */,\n    Cursor\t\t/* cursor */,\n    XColor*\t\t/* foreground_color */,\n    XColor*\t\t/* background_color */\n);\n\nextern int XRefreshKeyboardMapping(\n    XMappingEvent*\t/* event_map */\n);\n\nextern int XRemoveFromSaveSet(\n    Display*\t\t/* display */,\n    Window\t\t/* w */\n);\n\nextern int XRemoveHost(\n    Display*\t\t/* display */,\n    XHostAddress*\t/* host */\n);\n\nextern int XRemoveHosts(\n    Display*\t\t/* display */,\n    XHostAddress*\t/* hosts */,\n    int\t\t\t/* num_hosts */\n);\n\nextern int XReparentWindow(\n    Display*\t\t/* display */,\n    Window\t\t/* w */,\n    Window\t\t/* parent */,\n    int\t\t\t/* x */,\n    int\t\t\t/* y */\n);\n\nextern int XResetScreenSaver(\n    Display*\t\t/* display */\n);\n\nextern int XResizeWindow(\n    Display*\t\t/* display */,\n    Window\t\t/* w */,\n    unsigned int\t/* width */,\n    unsigned int\t/* height */\n);\n\nextern int XRestackWindows(\n    Display*\t\t/* display */,\n    Window*\t\t/* windows */,\n    int\t\t\t/* nwindows */\n);\n\nextern int XRotateBuffers(\n    Display*\t\t/* display */,\n    int\t\t\t/* rotate */\n);\n\nextern int XRotateWindowProperties(\n    Display*\t\t/* display */,\n    Window\t\t/* w */,\n    Atom*\t\t/* properties */,\n    int\t\t\t/* num_prop */,\n    int\t\t\t/* npositions */\n);\n\nextern int XScreenCount(\n    Display*\t\t/* display */\n);\n\nextern int XSelectInput(\n    Display*\t\t/* display */,\n    Window\t\t/* w */,\n    long\t\t/* event_mask */\n);\n\nextern Status XSendEvent(\n    Display*\t\t/* display */,\n    Window\t\t/* w */,\n    Bool\t\t/* propagate */,\n    long\t\t/* event_mask */,\n    XEvent*\t\t/* event_send */\n);\n\nextern int XSetAccessControl(\n    Display*\t\t/* display */,\n    int\t\t\t/* mode */\n);\n\nextern int XSetArcMode(\n    Display*\t\t/* display */,\n    GC\t\t\t/* gc */,\n    int\t\t\t/* arc_mode */\n);\n\nextern int XSetBackground(\n    Display*\t\t/* display */,\n    GC\t\t\t/* gc */,\n    unsigned long\t/* background */\n);\n\nextern int XSetClipMask(\n    Display*\t\t/* display */,\n    GC\t\t\t/* gc */,\n    Pixmap\t\t/* pixmap */\n);\n\nextern int XSetClipOrigin(\n    Display*\t\t/* display */,\n    GC\t\t\t/* gc */,\n    int\t\t\t/* clip_x_origin */,\n    int\t\t\t/* clip_y_origin */\n);\n\nextern int XSetClipRectangles(\n    Display*\t\t/* display */,\n    GC\t\t\t/* gc */,\n    int\t\t\t/* clip_x_origin */,\n    int\t\t\t/* clip_y_origin */,\n    XRectangle*\t\t/* rectangles */,\n    int\t\t\t/* n */,\n    int\t\t\t/* ordering */\n);\n\nextern int XSetCloseDownMode(\n    Display*\t\t/* display */,\n    int\t\t\t/* close_mode */\n);\n\nextern int XSetCommand(\n    Display*\t\t/* display */,\n    Window\t\t/* w */,\n    char**\t\t/* argv */,\n    int\t\t\t/* argc */\n);\n\nextern int XSetDashes(\n    Display*\t\t/* display */,\n    GC\t\t\t/* gc */,\n    int\t\t\t/* dash_offset */,\n    _Xconst char*\t/* dash_list */,\n    int\t\t\t/* n */\n);\n\nextern int XSetFillRule(\n    Display*\t\t/* display */,\n    GC\t\t\t/* gc */,\n    int\t\t\t/* fill_rule */\n);\n\nextern int XSetFillStyle(\n    Display*\t\t/* display */,\n    GC\t\t\t/* gc */,\n    int\t\t\t/* fill_style */\n);\n\nextern int XSetFont(\n    Display*\t\t/* display */,\n    GC\t\t\t/* gc */,\n    Font\t\t/* font */\n);\n\nextern int XSetFontPath(\n    Display*\t\t/* display */,\n    char**\t\t/* directories */,\n    int\t\t\t/* ndirs */\n);\n\nextern int XSetForeground(\n    Display*\t\t/* display */,\n    GC\t\t\t/* gc */,\n    unsigned long\t/* foreground */\n);\n\nextern int XSetFunction(\n    Display*\t\t/* display */,\n    GC\t\t\t/* gc */,\n    int\t\t\t/* function */\n);\n\nextern int XSetGraphicsExposures(\n    Display*\t\t/* display */,\n    GC\t\t\t/* gc */,\n    Bool\t\t/* graphics_exposures */\n);\n\nextern int XSetIconName(\n    Display*\t\t/* display */,\n    Window\t\t/* w */,\n    _Xconst char*\t/* icon_name */\n);\n\nextern int XSetInputFocus(\n    Display*\t\t/* display */,\n    Window\t\t/* focus */,\n    int\t\t\t/* revert_to */,\n    Time\t\t/* time */\n);\n\nextern int XSetLineAttributes(\n    Display*\t\t/* display */,\n    GC\t\t\t/* gc */,\n    unsigned int\t/* line_width */,\n    int\t\t\t/* line_style */,\n    int\t\t\t/* cap_style */,\n    int\t\t\t/* join_style */\n);\n\nextern int XSetModifierMapping(\n    Display*\t\t/* display */,\n    XModifierKeymap*\t/* modmap */\n);\n\nextern int XSetPlaneMask(\n    Display*\t\t/* display */,\n    GC\t\t\t/* gc */,\n    unsigned long\t/* plane_mask */\n);\n\nextern int XSetPointerMapping(\n    Display*\t\t/* display */,\n    _Xconst unsigned char*\t/* map */,\n    int\t\t\t/* nmap */\n);\n\nextern int XSetScreenSaver(\n    Display*\t\t/* display */,\n    int\t\t\t/* timeout */,\n    int\t\t\t/* interval */,\n    int\t\t\t/* prefer_blanking */,\n    int\t\t\t/* allow_exposures */\n);\n\nextern int XSetSelectionOwner(\n    Display*\t\t/* display */,\n    Atom\t        /* selection */,\n    Window\t\t/* owner */,\n    Time\t\t/* time */\n);\n\nextern int XSetState(\n    Display*\t\t/* display */,\n    GC\t\t\t/* gc */,\n    unsigned long \t/* foreground */,\n    unsigned long\t/* background */,\n    int\t\t\t/* function */,\n    unsigned long\t/* plane_mask */\n);\n\nextern int XSetStipple(\n    Display*\t\t/* display */,\n    GC\t\t\t/* gc */,\n    Pixmap\t\t/* stipple */\n);\n\nextern int XSetSubwindowMode(\n    Display*\t\t/* display */,\n    GC\t\t\t/* gc */,\n    int\t\t\t/* subwindow_mode */\n);\n\nextern int XSetTSOrigin(\n    Display*\t\t/* display */,\n    GC\t\t\t/* gc */,\n    int\t\t\t/* ts_x_origin */,\n    int\t\t\t/* ts_y_origin */\n);\n\nextern int XSetTile(\n    Display*\t\t/* display */,\n    GC\t\t\t/* gc */,\n    Pixmap\t\t/* tile */\n);\n\nextern int XSetWindowBackground(\n    Display*\t\t/* display */,\n    Window\t\t/* w */,\n    unsigned long\t/* background_pixel */\n);\n\nextern int XSetWindowBackgroundPixmap(\n    Display*\t\t/* display */,\n    Window\t\t/* w */,\n    Pixmap\t\t/* background_pixmap */\n);\n\nextern int XSetWindowBorder(\n    Display*\t\t/* display */,\n    Window\t\t/* w */,\n    unsigned long\t/* border_pixel */\n);\n\nextern int XSetWindowBorderPixmap(\n    Display*\t\t/* display */,\n    Window\t\t/* w */,\n    Pixmap\t\t/* border_pixmap */\n);\n\nextern int XSetWindowBorderWidth(\n    Display*\t\t/* display */,\n    Window\t\t/* w */,\n    unsigned int\t/* width */\n);\n\nextern int XSetWindowColormap(\n    Display*\t\t/* display */,\n    Window\t\t/* w */,\n    Colormap\t\t/* colormap */\n);\n\nextern int XStoreBuffer(\n    Display*\t\t/* display */,\n    _Xconst char*\t/* bytes */,\n    int\t\t\t/* nbytes */,\n    int\t\t\t/* buffer */\n);\n\nextern int XStoreBytes(\n    Display*\t\t/* display */,\n    _Xconst char*\t/* bytes */,\n    int\t\t\t/* nbytes */\n);\n\nextern int XStoreColor(\n    Display*\t\t/* display */,\n    Colormap\t\t/* colormap */,\n    XColor*\t\t/* color */\n);\n\nextern int XStoreColors(\n    Display*\t\t/* display */,\n    Colormap\t\t/* colormap */,\n    XColor*\t\t/* color */,\n    int\t\t\t/* ncolors */\n);\n\nextern int XStoreName(\n    Display*\t\t/* display */,\n    Window\t\t/* w */,\n    _Xconst char*\t/* window_name */\n);\n\nextern int XStoreNamedColor(\n    Display*\t\t/* display */,\n    Colormap\t\t/* colormap */,\n    _Xconst char*\t/* color */,\n    unsigned long\t/* pixel */,\n    int\t\t\t/* flags */\n);\n\nextern int XSync(\n    Display*\t\t/* display */,\n    Bool\t\t/* discard */\n);\n\nextern int XTextExtents(\n    XFontStruct*\t/* font_struct */,\n    _Xconst char*\t/* string */,\n    int\t\t\t/* nchars */,\n    int*\t\t/* direction_return */,\n    int*\t\t/* font_ascent_return */,\n    int*\t\t/* font_descent_return */,\n    XCharStruct*\t/* overall_return */\n);\n\nextern int XTextExtents16(\n    XFontStruct*\t/* font_struct */,\n    _Xconst XChar2b*\t/* string */,\n    int\t\t\t/* nchars */,\n    int*\t\t/* direction_return */,\n    int*\t\t/* font_ascent_return */,\n    int*\t\t/* font_descent_return */,\n    XCharStruct*\t/* overall_return */\n);\n\nextern int XTextWidth(\n    XFontStruct*\t/* font_struct */,\n    _Xconst char*\t/* string */,\n    int\t\t\t/* count */\n);\n\nextern int XTextWidth16(\n    XFontStruct*\t/* font_struct */,\n    _Xconst XChar2b*\t/* string */,\n    int\t\t\t/* count */\n);\n\nextern Bool XTranslateCoordinates(\n    Display*\t\t/* display */,\n    Window\t\t/* src_w */,\n    Window\t\t/* dest_w */,\n    int\t\t\t/* src_x */,\n    int\t\t\t/* src_y */,\n    int*\t\t/* dest_x_return */,\n    int*\t\t/* dest_y_return */,\n    Window*\t\t/* child_return */\n);\n\nextern int XUndefineCursor(\n    Display*\t\t/* display */,\n    Window\t\t/* w */\n);\n\nextern int XUngrabButton(\n    Display*\t\t/* display */,\n    unsigned int\t/* button */,\n    unsigned int\t/* modifiers */,\n    Window\t\t/* grab_window */\n);\n\nextern int XUngrabKey(\n    Display*\t\t/* display */,\n    int\t\t\t/* keycode */,\n    unsigned int\t/* modifiers */,\n    Window\t\t/* grab_window */\n);\n\nextern int XUngrabKeyboard(\n    Display*\t\t/* display */,\n    Time\t\t/* time */\n);\n\nextern int XUngrabPointer(\n    Display*\t\t/* display */,\n    Time\t\t/* time */\n);\n\nextern int XUngrabServer(\n    Display*\t\t/* display */\n);\n\nextern int XUninstallColormap(\n    Display*\t\t/* display */,\n    Colormap\t\t/* colormap */\n);\n\nextern int XUnloadFont(\n    Display*\t\t/* display */,\n    Font\t\t/* font */\n);\n\nextern int XUnmapSubwindows(\n    Display*\t\t/* display */,\n    Window\t\t/* w */\n);\n\nextern int XUnmapWindow(\n    Display*\t\t/* display */,\n    Window\t\t/* w */\n);\n\nextern int XVendorRelease(\n    Display*\t\t/* display */\n);\n\nextern int XWarpPointer(\n    Display*\t\t/* display */,\n    Window\t\t/* src_w */,\n    Window\t\t/* dest_w */,\n    int\t\t\t/* src_x */,\n    int\t\t\t/* src_y */,\n    unsigned int\t/* src_width */,\n    unsigned int\t/* src_height */,\n    int\t\t\t/* dest_x */,\n    int\t\t\t/* dest_y */\n);\n\nextern int XWidthMMOfScreen(\n    Screen*\t\t/* screen */\n);\n\nextern int XWidthOfScreen(\n    Screen*\t\t/* screen */\n);\n\nextern int XWindowEvent(\n    Display*\t\t/* display */,\n    Window\t\t/* w */,\n    long\t\t/* event_mask */,\n    XEvent*\t\t/* event_return */\n);\n\nextern int XWriteBitmapFile(\n    Display*\t\t/* display */,\n    _Xconst char*\t/* filename */,\n    Pixmap\t\t/* bitmap */,\n    unsigned int\t/* width */,\n    unsigned int\t/* height */,\n    int\t\t\t/* x_hot */,\n    int\t\t\t/* y_hot */\n);\n\nextern Bool XSupportsLocale (void);\n\nextern char *XSetLocaleModifiers(\n    const char*\t\t/* modifier_list */\n);\n\nextern XOM XOpenOM(\n    Display*\t\t\t/* display */,\n    struct _XrmHashBucketRec*\t/* rdb */,\n    _Xconst char*\t\t/* res_name */,\n    _Xconst char*\t\t/* res_class */\n);\n\nextern Status XCloseOM(\n    XOM\t\t\t/* om */\n);\n\nextern char *XSetOMValues(\n    XOM\t\t\t/* om */,\n    ...\n) _X_SENTINEL(0);\n\nextern char *XGetOMValues(\n    XOM\t\t\t/* om */,\n    ...\n) _X_SENTINEL(0);\n\nextern Display *XDisplayOfOM(\n    XOM\t\t\t/* om */\n);\n\nextern char *XLocaleOfOM(\n    XOM\t\t\t/* om */\n);\n\nextern XOC XCreateOC(\n    XOM\t\t\t/* om */,\n    ...\n) _X_SENTINEL(0);\n\nextern void XDestroyOC(\n    XOC\t\t\t/* oc */\n);\n\nextern XOM XOMOfOC(\n    XOC\t\t\t/* oc */\n);\n\nextern char *XSetOCValues(\n    XOC\t\t\t/* oc */,\n    ...\n) _X_SENTINEL(0);\n\nextern char *XGetOCValues(\n    XOC\t\t\t/* oc */,\n    ...\n) _X_SENTINEL(0);\n\nextern XFontSet XCreateFontSet(\n    Display*\t\t/* display */,\n    _Xconst char*\t/* base_font_name_list */,\n    char***\t\t/* missing_charset_list */,\n    int*\t\t/* missing_charset_count */,\n    char**\t\t/* def_string */\n);\n\nextern void XFreeFontSet(\n    Display*\t\t/* display */,\n    XFontSet\t\t/* font_set */\n);\n\nextern int XFontsOfFontSet(\n    XFontSet\t\t/* font_set */,\n    XFontStruct***\t/* font_struct_list */,\n    char***\t\t/* font_name_list */\n);\n\nextern char *XBaseFontNameListOfFontSet(\n    XFontSet\t\t/* font_set */\n);\n\nextern char *XLocaleOfFontSet(\n    XFontSet\t\t/* font_set */\n);\n\nextern Bool XContextDependentDrawing(\n    XFontSet\t\t/* font_set */\n);\n\nextern Bool XDirectionalDependentDrawing(\n    XFontSet\t\t/* font_set */\n);\n\nextern Bool XContextualDrawing(\n    XFontSet\t\t/* font_set */\n);\n\nextern XFontSetExtents *XExtentsOfFontSet(\n    XFontSet\t\t/* font_set */\n);\n\nextern int XmbTextEscapement(\n    XFontSet\t\t/* font_set */,\n    _Xconst char*\t/* text */,\n    int\t\t\t/* bytes_text */\n);\n\nextern int XwcTextEscapement(\n    XFontSet\t\t/* font_set */,\n    _Xconst wchar_t*\t/* text */,\n    int\t\t\t/* num_wchars */\n);\n\nextern int Xutf8TextEscapement(\n    XFontSet\t\t/* font_set */,\n    _Xconst char*\t/* text */,\n    int\t\t\t/* bytes_text */\n);\n\nextern int XmbTextExtents(\n    XFontSet\t\t/* font_set */,\n    _Xconst char*\t/* text */,\n    int\t\t\t/* bytes_text */,\n    XRectangle*\t\t/* overall_ink_return */,\n    XRectangle*\t\t/* overall_logical_return */\n);\n\nextern int XwcTextExtents(\n    XFontSet\t\t/* font_set */,\n    _Xconst wchar_t*\t/* text */,\n    int\t\t\t/* num_wchars */,\n    XRectangle*\t\t/* overall_ink_return */,\n    XRectangle*\t\t/* overall_logical_return */\n);\n\nextern int Xutf8TextExtents(\n    XFontSet\t\t/* font_set */,\n    _Xconst char*\t/* text */,\n    int\t\t\t/* bytes_text */,\n    XRectangle*\t\t/* overall_ink_return */,\n    XRectangle*\t\t/* overall_logical_return */\n);\n\nextern Status XmbTextPerCharExtents(\n    XFontSet\t\t/* font_set */,\n    _Xconst char*\t/* text */,\n    int\t\t\t/* bytes_text */,\n    XRectangle*\t\t/* ink_extents_buffer */,\n    XRectangle*\t\t/* logical_extents_buffer */,\n    int\t\t\t/* buffer_size */,\n    int*\t\t/* num_chars */,\n    XRectangle*\t\t/* overall_ink_return */,\n    XRectangle*\t\t/* overall_logical_return */\n);\n\nextern Status XwcTextPerCharExtents(\n    XFontSet\t\t/* font_set */,\n    _Xconst wchar_t*\t/* text */,\n    int\t\t\t/* num_wchars */,\n    XRectangle*\t\t/* ink_extents_buffer */,\n    XRectangle*\t\t/* logical_extents_buffer */,\n    int\t\t\t/* buffer_size */,\n    int*\t\t/* num_chars */,\n    XRectangle*\t\t/* overall_ink_return */,\n    XRectangle*\t\t/* overall_logical_return */\n);\n\nextern Status Xutf8TextPerCharExtents(\n    XFontSet\t\t/* font_set */,\n    _Xconst char*\t/* text */,\n    int\t\t\t/* bytes_text */,\n    XRectangle*\t\t/* ink_extents_buffer */,\n    XRectangle*\t\t/* logical_extents_buffer */,\n    int\t\t\t/* buffer_size */,\n    int*\t\t/* num_chars */,\n    XRectangle*\t\t/* overall_ink_return */,\n    XRectangle*\t\t/* overall_logical_return */\n);\n\nextern void XmbDrawText(\n    Display*\t\t/* display */,\n    Drawable\t\t/* d */,\n    GC\t\t\t/* gc */,\n    int\t\t\t/* x */,\n    int\t\t\t/* y */,\n    XmbTextItem*\t/* text_items */,\n    int\t\t\t/* nitems */\n);\n\nextern void XwcDrawText(\n    Display*\t\t/* display */,\n    Drawable\t\t/* d */,\n    GC\t\t\t/* gc */,\n    int\t\t\t/* x */,\n    int\t\t\t/* y */,\n    XwcTextItem*\t/* text_items */,\n    int\t\t\t/* nitems */\n);\n\nextern void Xutf8DrawText(\n    Display*\t\t/* display */,\n    Drawable\t\t/* d */,\n    GC\t\t\t/* gc */,\n    int\t\t\t/* x */,\n    int\t\t\t/* y */,\n    XmbTextItem*\t/* text_items */,\n    int\t\t\t/* nitems */\n);\n\nextern void XmbDrawString(\n    Display*\t\t/* display */,\n    Drawable\t\t/* d */,\n    XFontSet\t\t/* font_set */,\n    GC\t\t\t/* gc */,\n    int\t\t\t/* x */,\n    int\t\t\t/* y */,\n    _Xconst char*\t/* text */,\n    int\t\t\t/* bytes_text */\n);\n\nextern void XwcDrawString(\n    Display*\t\t/* display */,\n    Drawable\t\t/* d */,\n    XFontSet\t\t/* font_set */,\n    GC\t\t\t/* gc */,\n    int\t\t\t/* x */,\n    int\t\t\t/* y */,\n    _Xconst wchar_t*\t/* text */,\n    int\t\t\t/* num_wchars */\n);\n\nextern void Xutf8DrawString(\n    Display*\t\t/* display */,\n    Drawable\t\t/* d */,\n    XFontSet\t\t/* font_set */,\n    GC\t\t\t/* gc */,\n    int\t\t\t/* x */,\n    int\t\t\t/* y */,\n    _Xconst char*\t/* text */,\n    int\t\t\t/* bytes_text */\n);\n\nextern void XmbDrawImageString(\n    Display*\t\t/* display */,\n    Drawable\t\t/* d */,\n    XFontSet\t\t/* font_set */,\n    GC\t\t\t/* gc */,\n    int\t\t\t/* x */,\n    int\t\t\t/* y */,\n    _Xconst char*\t/* text */,\n    int\t\t\t/* bytes_text */\n);\n\nextern void XwcDrawImageString(\n    Display*\t\t/* display */,\n    Drawable\t\t/* d */,\n    XFontSet\t\t/* font_set */,\n    GC\t\t\t/* gc */,\n    int\t\t\t/* x */,\n    int\t\t\t/* y */,\n    _Xconst wchar_t*\t/* text */,\n    int\t\t\t/* num_wchars */\n);\n\nextern void Xutf8DrawImageString(\n    Display*\t\t/* display */,\n    Drawable\t\t/* d */,\n    XFontSet\t\t/* font_set */,\n    GC\t\t\t/* gc */,\n    int\t\t\t/* x */,\n    int\t\t\t/* y */,\n    _Xconst char*\t/* text */,\n    int\t\t\t/* bytes_text */\n);\n\nextern XIM XOpenIM(\n    Display*\t\t\t/* dpy */,\n    struct _XrmHashBucketRec*\t/* rdb */,\n    char*\t\t\t/* res_name */,\n    char*\t\t\t/* res_class */\n);\n\nextern Status XCloseIM(\n    XIM /* im */\n);\n\nextern char *XGetIMValues(\n    XIM /* im */, ...\n) _X_SENTINEL(0);\n\nextern char *XSetIMValues(\n    XIM /* im */, ...\n) _X_SENTINEL(0);\n\nextern Display *XDisplayOfIM(\n    XIM /* im */\n);\n\nextern char *XLocaleOfIM(\n    XIM /* im*/\n);\n\nextern XIC XCreateIC(\n    XIM /* im */, ...\n) _X_SENTINEL(0);\n\nextern void XDestroyIC(\n    XIC /* ic */\n);\n\nextern void XSetICFocus(\n    XIC /* ic */\n);\n\nextern void XUnsetICFocus(\n    XIC /* ic */\n);\n\nextern wchar_t *XwcResetIC(\n    XIC /* ic */\n);\n\nextern char *XmbResetIC(\n    XIC /* ic */\n);\n\nextern char *Xutf8ResetIC(\n    XIC /* ic */\n);\n\nextern char *XSetICValues(\n    XIC /* ic */, ...\n) _X_SENTINEL(0);\n\nextern char *XGetICValues(\n    XIC /* ic */, ...\n) _X_SENTINEL(0);\n\nextern XIM XIMOfIC(\n    XIC /* ic */\n);\n\nextern Bool XFilterEvent(\n    XEvent*\t/* event */,\n    Window\t/* window */\n);\n\nextern int XmbLookupString(\n    XIC\t\t\t/* ic */,\n    XKeyPressedEvent*\t/* event */,\n    char*\t\t/* buffer_return */,\n    int\t\t\t/* bytes_buffer */,\n    KeySym*\t\t/* keysym_return */,\n    Status*\t\t/* status_return */\n);\n\nextern int XwcLookupString(\n    XIC\t\t\t/* ic */,\n    XKeyPressedEvent*\t/* event */,\n    wchar_t*\t\t/* buffer_return */,\n    int\t\t\t/* wchars_buffer */,\n    KeySym*\t\t/* keysym_return */,\n    Status*\t\t/* status_return */\n);\n\nextern int Xutf8LookupString(\n    XIC\t\t\t/* ic */,\n    XKeyPressedEvent*\t/* event */,\n    char*\t\t/* buffer_return */,\n    int\t\t\t/* bytes_buffer */,\n    KeySym*\t\t/* keysym_return */,\n    Status*\t\t/* status_return */\n);\n\nextern XVaNestedList XVaCreateNestedList(\n    int /*unused*/, ...\n) _X_SENTINEL(0);\n\n/* internal connections for IMs */\n\nextern Bool XRegisterIMInstantiateCallback(\n    Display*\t\t\t/* dpy */,\n    struct _XrmHashBucketRec*\t/* rdb */,\n    char*\t\t\t/* res_name */,\n    char*\t\t\t/* res_class */,\n    XIDProc\t\t\t/* callback */,\n    XPointer\t\t\t/* client_data */\n);\n\nextern Bool XUnregisterIMInstantiateCallback(\n    Display*\t\t\t/* dpy */,\n    struct _XrmHashBucketRec*\t/* rdb */,\n    char*\t\t\t/* res_name */,\n    char*\t\t\t/* res_class */,\n    XIDProc\t\t\t/* callback */,\n    XPointer\t\t\t/* client_data */\n);\n\ntypedef void (*XConnectionWatchProc)(\n    Display*\t\t\t/* dpy */,\n    XPointer\t\t\t/* client_data */,\n    int\t\t\t\t/* fd */,\n    Bool\t\t\t/* opening */,\t /* open or close flag */\n    XPointer*\t\t\t/* watch_data */ /* open sets, close uses */\n);\n\n\nextern Status XInternalConnectionNumbers(\n    Display*\t\t\t/* dpy */,\n    int**\t\t\t/* fd_return */,\n    int*\t\t\t/* count_return */\n);\n\nextern void XProcessInternalConnection(\n    Display*\t\t\t/* dpy */,\n    int\t\t\t\t/* fd */\n);\n\nextern Status XAddConnectionWatch(\n    Display*\t\t\t/* dpy */,\n    XConnectionWatchProc\t/* callback */,\n    XPointer\t\t\t/* client_data */\n);\n\nextern void XRemoveConnectionWatch(\n    Display*\t\t\t/* dpy */,\n    XConnectionWatchProc\t/* callback */,\n    XPointer\t\t\t/* client_data */\n);\n\nextern void XSetAuthorization(\n    char *\t\t\t/* name */,\n    int\t\t\t\t/* namelen */,\n    char *\t\t\t/* data */,\n    int\t\t\t\t/* datalen */\n);\n\nextern int _Xmbtowc(\n    wchar_t *\t\t\t/* wstr */,\n#ifdef ISC\n    char const *\t\t/* str */,\n    size_t\t\t\t/* len */\n#else\n    char *\t\t\t/* str */,\n    int\t\t\t\t/* len */\n#endif\n);\n\nextern int _Xwctomb(\n    char *\t\t\t/* str */,\n    wchar_t\t\t\t/* wc */\n);\n\nextern Bool XGetEventData(\n    Display*\t\t\t/* dpy */,\n    XGenericEventCookie*\t/* cookie*/\n);\n\nextern void XFreeEventData(\n    Display*\t\t\t/* dpy */,\n    XGenericEventCookie*\t/* cookie*/\n);\n\n#ifdef __clang__\n#pragma clang diagnostic pop\n#endif\n\n_XFUNCPROTOEND\n\n#endif /* _X11_XLIB_H_ */\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/X11/XlibConf.h",
    "content": "/* include/X11/XlibConf.h.  Generated from XlibConf.h.in by configure.  */\n/*\n * Copyright © 2005 Keith Packard\n *\n * Permission to use, copy, modify, distribute, and sell this software and its\n * documentation for any purpose is hereby granted without fee, provided that\n * the above copyright notice appear in all copies and that both that\n * copyright notice and this permission notice appear in supporting\n * documentation, and that the name of Keith Packard not be used in\n * advertising or publicity pertaining to distribution of the software without\n * specific, written prior permission.  Keith Packard makes no\n * representations about the suitability of this software for any purpose.  It\n * is provided \"as is\" without express or implied warranty.\n *\n * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,\n * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO\n * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR\n * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,\n * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER\n * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\n * PERFORMANCE OF THIS SOFTWARE.\n */\n\n#ifndef _XLIBCONF_H_\n#define _XLIBCONF_H_\n/*\n * This header file exports defines necessary to correctly\n * use Xlibint.h both inside Xlib and by external libraries\n * such as extensions.\n */\n\n/* Threading support? */\n#define XTHREADS 1\n\n/* Use multi-threaded libc functions? */\n#define XUSE_MTSAFE_API 1\n\n#endif /* _XLIBCONF_H_ */\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/X11/Xlibint.h",
    "content": "\n/*\n\nCopyright 1984, 1985, 1987, 1989, 1998  The Open Group\n\nPermission to use, copy, modify, distribute, and sell this software and its\ndocumentation for any purpose is hereby granted without fee, provided that\nthe above copyright notice appear in all copies and that both that\ncopyright notice and this permission notice appear in supporting\ndocumentation.\n\nThe above copyright notice and this permission notice shall be included\nin all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\nOR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR\nOTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,\nARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\nOTHER DEALINGS IN THE SOFTWARE.\n\nExcept as contained in this notice, the name of The Open Group shall\nnot be used in advertising or otherwise to promote the sale, use or\nother dealings in this Software without prior written authorization\nfrom The Open Group.\n\n*/\n\n#ifndef _X11_XLIBINT_H_\n#define _X11_XLIBINT_H_ 1\n\n/*\n *\tXlibint.h - Header definition and support file for the internal\n *\tsupport routines used by the C subroutine interface\n *\tlibrary (Xlib) to the X Window System.\n *\n *\tWarning, there be dragons here....\n */\n\n#include <X11/Xlib.h>\n#include <X11/Xproto.h>\t\t/* to declare xEvent */\n#include <X11/XlibConf.h>\t/* for configured options like XTHREADS */\n\n/* The Xlib structs are full of implicit padding to properly align members.\n   We can't clean that up without breaking ABI, so tell clang not to bother\n   complaining about it. */\n#ifdef __clang__\n#pragma clang diagnostic push\n#pragma clang diagnostic ignored \"-Wpadded\"\n#endif\n\n#ifdef WIN32\n#define _XFlush _XFlushIt\n#endif\n\n/*\n * If your BytesReadable correctly detects broken connections, then\n * you should NOT define XCONN_CHECK_FREQ.\n */\n#ifndef XCONN_CHECK_FREQ\n#define XCONN_CHECK_FREQ 256\n#endif\n\nstruct _XGC\n{\n    XExtData *ext_data;\t/* hook for extension to hang data */\n    GContext gid;\t/* protocol ID for graphics context */\n    Bool rects;\t\t/* boolean: TRUE if clipmask is list of rectangles */\n    Bool dashes;\t/* boolean: TRUE if dash-list is really a list */\n    unsigned long dirty;/* cache dirty bits */\n    XGCValues values;\t/* shadow structure of values */\n};\n\nstruct _XDisplay\n{\n\tXExtData *ext_data;\t/* hook for extension to hang data */\n\tstruct _XFreeFuncs *free_funcs; /* internal free functions */\n\tint fd;\t\t\t/* Network socket. */\n\tint conn_checker;         /* ugly thing used by _XEventsQueued */\n\tint proto_major_version;/* maj. version of server's X protocol */\n\tint proto_minor_version;/* minor version of server's X protocol */\n\tchar *vendor;\t\t/* vendor of the server hardware */\n        XID resource_base;\t/* resource ID base */\n\tXID resource_mask;\t/* resource ID mask bits */\n\tXID resource_id;\t/* allocator current ID */\n\tint resource_shift;\t/* allocator shift to correct bits */\n\tXID (*resource_alloc)(\t/* allocator function */\n\t\tstruct _XDisplay*\n\t\t);\n\tint byte_order;\t\t/* screen byte order, LSBFirst, MSBFirst */\n\tint bitmap_unit;\t/* padding and data requirements */\n\tint bitmap_pad;\t\t/* padding requirements on bitmaps */\n\tint bitmap_bit_order;\t/* LeastSignificant or MostSignificant */\n\tint nformats;\t\t/* number of pixmap formats in list */\n\tScreenFormat *pixmap_format;\t/* pixmap format list */\n\tint vnumber;\t\t/* Xlib's X protocol version number. */\n\tint release;\t\t/* release of the server */\n\tstruct _XSQEvent *head, *tail;\t/* Input event queue. */\n\tint qlen;\t\t/* Length of input event queue */\n\tunsigned long last_request_read; /* seq number of last event read */\n\tunsigned long request;\t/* sequence number of last request. */\n\tchar *last_req;\t\t/* beginning of last request, or dummy */\n\tchar *buffer;\t\t/* Output buffer starting address. */\n\tchar *bufptr;\t\t/* Output buffer index pointer. */\n\tchar *bufmax;\t\t/* Output buffer maximum+1 address. */\n\tunsigned max_request_size; /* maximum number 32 bit words in request*/\n\tstruct _XrmHashBucketRec *db;\n\tint (*synchandler)(\t/* Synchronization handler */\n\t\tstruct _XDisplay*\n\t\t);\n\tchar *display_name;\t/* \"host:display\" string used on this connect*/\n\tint default_screen;\t/* default screen for operations */\n\tint nscreens;\t\t/* number of screens on this server*/\n\tScreen *screens;\t/* pointer to list of screens */\n\tunsigned long motion_buffer;\t/* size of motion buffer */\n\tvolatile unsigned long flags;\t   /* internal connection flags */\n\tint min_keycode;\t/* minimum defined keycode */\n\tint max_keycode;\t/* maximum defined keycode */\n\tKeySym *keysyms;\t/* This server's keysyms */\n\tXModifierKeymap *modifiermap;\t/* This server's modifier keymap */\n\tint keysyms_per_keycode;/* number of rows */\n\tchar *xdefaults;\t/* contents of defaults from server */\n\tchar *scratch_buffer;\t/* place to hang scratch buffer */\n\tunsigned long scratch_length;\t/* length of scratch buffer */\n\tint ext_number;\t\t/* extension number on this display */\n\tstruct _XExten *ext_procs; /* extensions initialized on this display */\n\t/*\n\t * the following can be fixed size, as the protocol defines how\n\t * much address space is available.\n\t * While this could be done using the extension vector, there\n\t * may be MANY events processed, so a search through the extension\n\t * list to find the right procedure for each event might be\n\t * expensive if many extensions are being used.\n\t */\n\tBool (*event_vec[128])(\t/* vector for wire to event */\n\t\tDisplay *\t/* dpy */,\n\t\tXEvent *\t/* re */,\n\t\txEvent *\t/* event */\n\t\t);\n\tStatus (*wire_vec[128])( /* vector for event to wire */\n\t\tDisplay *\t/* dpy */,\n\t\tXEvent *\t/* re */,\n\t\txEvent *\t/* event */\n\t\t);\n\tKeySym lock_meaning;\t   /* for XLookupString */\n\tstruct _XLockInfo *lock;   /* multi-thread state, display lock */\n\tstruct _XInternalAsync *async_handlers; /* for internal async */\n\tunsigned long bigreq_size; /* max size of big requests */\n\tstruct _XLockPtrs *lock_fns; /* pointers to threads functions */\n\tvoid (*idlist_alloc)(\t   /* XID list allocator function */\n\t\tDisplay *\t/* dpy */,\n\t\tXID *\t\t/* ids */,\n\t\tint\t\t/* count */\n\t\t);\n\t/* things above this line should not move, for binary compatibility */\n\tstruct _XKeytrans *key_bindings; /* for XLookupString */\n\tFont cursor_font;\t   /* for XCreateFontCursor */\n\tstruct _XDisplayAtoms *atoms; /* for XInternAtom */\n\tunsigned int mode_switch;  /* keyboard group modifiers */\n\tunsigned int num_lock;  /* keyboard numlock modifiers */\n\tstruct _XContextDB *context_db; /* context database */\n\tBool (**error_vec)(\t/* vector for wire to error */\n\t\tDisplay     *\t/* display */,\n\t\tXErrorEvent *\t/* he */,\n\t\txError      *\t/* we */\n\t\t);\n\t/*\n\t * Xcms information\n\t */\n\tstruct {\n\t   XPointer defaultCCCs;  /* pointer to an array of default XcmsCCC */\n\t   XPointer clientCmaps;  /* pointer to linked list of XcmsCmapRec */\n\t   XPointer perVisualIntensityMaps;\n\t\t\t\t  /* linked list of XcmsIntensityMap */\n\t} cms;\n\tstruct _XIMFilter *im_filters;\n\tstruct _XSQEvent *qfree; /* unallocated event queue elements */\n\tunsigned long next_event_serial_num; /* inserted into next queue elt */\n\tstruct _XExten *flushes; /* Flush hooks */\n\tstruct _XConnectionInfo *im_fd_info; /* _XRegisterInternalConnection */\n\tint im_fd_length;\t/* number of im_fd_info */\n\tstruct _XConnWatchInfo *conn_watchers; /* XAddConnectionWatch */\n\tint watcher_count;\t/* number of conn_watchers */\n\tXPointer filedes;\t/* struct pollfd cache for _XWaitForReadable */\n\tint (*savedsynchandler)( /* user synchandler when Xlib usurps */\n\t\tDisplay *\t/* dpy */\n\t\t);\n\tXID resource_max;\t/* allocator max ID */\n\tint xcmisc_opcode;\t/* major opcode for XC-MISC */\n\tstruct _XkbInfoRec *xkb_info; /* XKB info */\n\tstruct _XtransConnInfo *trans_conn; /* transport connection object */\n\tstruct _X11XCBPrivate *xcb; /* XCB glue private data */\n\n\t/* Generic event cookie handling */\n\tunsigned int next_cookie; /* next event cookie */\n\t/* vector for wire to generic event, index is (extension - 128) */\n\tBool (*generic_event_vec[128])(\n\t\tDisplay *\t/* dpy */,\n\t\tXGenericEventCookie *\t/* Xlib event */,\n\t\txEvent *\t/* wire event */);\n\t/* vector for event copy, index is (extension - 128) */\n\tBool (*generic_event_copy_vec[128])(\n\t\tDisplay *\t/* dpy */,\n\t\tXGenericEventCookie *\t/* in */,\n\t\tXGenericEventCookie *   /* out*/);\n\tvoid *cookiejar;  /* cookie events returned but not claimed */\n};\n\n#define XAllocIDs(dpy,ids,n) (*(dpy)->idlist_alloc)(dpy,ids,n)\n\n#ifndef _XEVENT_\n/*\n * _QEvent datatype for use in input queueing.\n */\ntypedef struct _XSQEvent\n{\n    struct _XSQEvent *next;\n    XEvent event;\n    unsigned long qserial_num;\t/* so multi-threaded code can find new ones */\n} _XQEvent;\n#endif\n\n#include <X11/Xproto.h>\n#ifdef __sgi\n#define _SGI_MP_SOURCE  /* turn this on to get MP safe errno */\n#endif\n#include <errno.h>\n#define _XBCOPYFUNC _Xbcopy\n#include <X11/Xfuncs.h>\n#include <X11/Xosdefs.h>\n\n/* Utek leaves kernel macros around in include files (bleah) */\n#ifdef dirty\n#undef dirty\n#endif\n\n#include <stdlib.h>\n#include <string.h>\n\n#include <X11/Xfuncproto.h>\n\n_XFUNCPROTOBEGIN\n\n/*\n * The following definitions can be used for locking requests in multi-threaded\n * address spaces.\n */\n#ifdef XTHREADS\n/* Author: Stephen Gildea, MIT X Consortium\n *\n * declarations for C Threads locking\n */\n\ntypedef struct _LockInfoRec *LockInfoPtr;\n\n/* interfaces for locking.c */\nstruct _XLockPtrs {\n    /* used by all, including extensions; do not move */\n    void (*lock_display)(\n\t\tDisplay *dpy\n#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)\n\t\t, char *file\n\t\t, int line\n#endif\n\t);\n    void (*unlock_display)(\n\t\tDisplay *dpy\n#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)\n\t\t, char *file\n\t\t, int line\n#endif\n\t);\n};\n\n#if defined(WIN32) && !defined(_XLIBINT_)\n#define _XCreateMutex_fn (*_XCreateMutex_fn_p)\n#define _XFreeMutex_fn (*_XFreeMutex_fn_p)\n#define _XLockMutex_fn (*_XLockMutex_fn_p)\n#define _XUnlockMutex_fn (*_XUnlockMutex_fn_p)\n#define _Xglobal_lock (*_Xglobal_lock_p)\n#endif\n\n/* in XlibInt.c */\nextern void (*_XCreateMutex_fn)(\n    LockInfoPtr /* lock */\n);\nextern void (*_XFreeMutex_fn)(\n    LockInfoPtr /* lock */\n);\nextern void (*_XLockMutex_fn)(\n    LockInfoPtr\t/* lock */\n#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)\n    , char * /* file */\n    , int /* line */\n#endif\n);\nextern void (*_XUnlockMutex_fn)(\n    LockInfoPtr\t/* lock */\n#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)\n    , char * /* file */\n    , int /* line */\n#endif\n);\n\nextern LockInfoPtr _Xglobal_lock;\n\n#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)\n#define LockDisplay(d)\t     if ((d)->lock_fns) (*(d)->lock_fns->lock_display)((d),__FILE__,__LINE__)\n#define UnlockDisplay(d)     if ((d)->lock_fns) (*(d)->lock_fns->unlock_display)((d),__FILE__,__LINE__)\n#define _XLockMutex(lock)\t\tif (_XLockMutex_fn) (*_XLockMutex_fn)(lock,__FILE__,__LINE__)\n#define _XUnlockMutex(lock)\tif (_XUnlockMutex_fn) (*_XUnlockMutex_fn)(lock,__FILE__,__LINE__)\n#else\n/* used everywhere, so must be fast if not using threads */\n#define LockDisplay(d)\t     if ((d)->lock_fns) (*(d)->lock_fns->lock_display)(d)\n#define UnlockDisplay(d)     if ((d)->lock_fns) (*(d)->lock_fns->unlock_display)(d)\n#define _XLockMutex(lock)\t\tif (_XLockMutex_fn) (*_XLockMutex_fn)(lock)\n#define _XUnlockMutex(lock)\tif (_XUnlockMutex_fn) (*_XUnlockMutex_fn)(lock)\n#endif\n#define _XCreateMutex(lock)\tif (_XCreateMutex_fn) (*_XCreateMutex_fn)(lock);\n#define _XFreeMutex(lock)\tif (_XFreeMutex_fn) (*_XFreeMutex_fn)(lock);\n\n#else /* XTHREADS */\n#define LockDisplay(dis)\n#define _XLockMutex(lock)\n#define _XUnlockMutex(lock)\n#define UnlockDisplay(dis)\n#define _XCreateMutex(lock)\n#define _XFreeMutex(lock)\n#endif\n\n#define Xfree(ptr) free((ptr))\n\n/*\n * Note that some machines do not return a valid pointer for malloc(0), in\n * which case we provide an alternate under the control of the\n * define MALLOC_0_RETURNS_NULL.  This is necessary because some\n * Xlib code expects malloc(0) to return a valid pointer to storage.\n */\n#if defined(MALLOC_0_RETURNS_NULL) || defined(__clang_analyzer__)\n\n# define Xmalloc(size) malloc(((size) == 0 ? 1 : (size)))\n# define Xrealloc(ptr, size) realloc((ptr), ((size) == 0 ? 1 : (size)))\n# define Xcalloc(nelem, elsize) calloc(((nelem) == 0 ? 1 : (nelem)), (elsize))\n\n#else\n\n# define Xmalloc(size) malloc((size))\n# define Xrealloc(ptr, size) realloc((ptr), (size))\n# define Xcalloc(nelem, elsize) calloc((nelem), (elsize))\n\n#endif\n\n#include <stddef.h>\n\n#define LOCKED 1\n#define UNLOCKED 0\n\n#ifndef BUFSIZE\n#define BUFSIZE 2048\t\t\t/* X output buffer size. */\n#endif\n#ifndef PTSPERBATCH\n#define PTSPERBATCH 1024\t\t/* point batching */\n#endif\n#ifndef WLNSPERBATCH\n#define WLNSPERBATCH 50\t\t\t/* wide line batching */\n#endif\n#ifndef ZLNSPERBATCH\n#define ZLNSPERBATCH 1024\t\t/* thin line batching */\n#endif\n#ifndef WRCTSPERBATCH\n#define WRCTSPERBATCH 10\t\t/* wide line rectangle batching */\n#endif\n#ifndef ZRCTSPERBATCH\n#define ZRCTSPERBATCH 256\t\t/* thin line rectangle batching */\n#endif\n#ifndef FRCTSPERBATCH\n#define FRCTSPERBATCH 256\t\t/* filled rectangle batching */\n#endif\n#ifndef FARCSPERBATCH\n#define FARCSPERBATCH 256\t\t/* filled arc batching */\n#endif\n#ifndef CURSORFONT\n#define CURSORFONT \"cursor\"\t\t/* standard cursor fonts */\n#endif\n\n/*\n * Display flags\n */\n#define XlibDisplayIOError\t(1L << 0)\n#define XlibDisplayClosing\t(1L << 1)\n#define XlibDisplayNoXkb\t(1L << 2)\n#define XlibDisplayPrivSync\t(1L << 3)\n#define XlibDisplayProcConni\t(1L << 4) /* in _XProcessInternalConnection */\n#define XlibDisplayReadEvents\t(1L << 5) /* in _XReadEvents */\n#define XlibDisplayReply\t(1L << 5) /* in _XReply */\n#define XlibDisplayWriting\t(1L << 6) /* in _XFlushInt, _XSend */\n#define XlibDisplayDfltRMDB     (1L << 7) /* mark if RM db from XGetDefault */\n\n/*\n * X Protocol packetizing macros.\n */\n\n/* Leftover from CRAY support - was defined empty on all non-Cray systems */\n#define WORD64ALIGN\n\n/**\n * Return a len-sized request buffer for the request type. This function may\n * flush the output queue.\n *\n * @param dpy The display connection\n * @param type The request type\n * @param len Length of the request in bytes\n *\n * @returns A pointer to the request buffer with a few default values\n * initialized.\n */\nextern void *_XGetRequest(Display *dpy, CARD8 type, size_t len);\n\n/* GetReqSized is the same as GetReq but allows the caller to specify the\n * size in bytes. 'sz' must be a multiple of 4! */\n\n#define GetReqSized(name, sz, req) \\\n\treq = (x##name##Req *) _XGetRequest(dpy, X_##name, sz)\n\n/*\n * GetReq - Get the next available X request packet in the buffer and\n * return it.\n *\n * \"name\" is the name of the request, e.g. CreatePixmap, OpenFont, etc.\n * \"req\" is the name of the request pointer.\n *\n */\n\n#define GetReq(name, req) \\\n\tGetReqSized(name, SIZEOF(x##name##Req), req)\n\n/* GetReqExtra is the same as GetReq, but allocates \"n\" additional\n   bytes after the request. \"n\" must be a multiple of 4!  */\n\n#define GetReqExtra(name, n, req) \\\n        GetReqSized(name, SIZEOF(x##name##Req) + n, req)\n\n/*\n * GetResReq is for those requests that have a resource ID\n * (Window, Pixmap, GContext, etc.) as their single argument.\n * \"rid\" is the name of the resource.\n */\n\n#define GetResReq(name, rid, req) \\\n\treq = (xResourceReq *) _XGetRequest(dpy, X_##name, SIZEOF(xResourceReq)); \\\n\treq->id = (rid)\n\n/*\n * GetEmptyReq is for those requests that have no arguments\n * at all.\n */\n\n#define GetEmptyReq(name, req) \\\n\treq = (xReq *) _XGetRequest(dpy, X_##name, SIZEOF(xReq))\n\n/*\n * MakeBigReq sets the CARD16 \"req->length\" to 0 and inserts a new CARD32\n * length, after req->length, before the data in the request.  The new length\n * includes the \"n\" extra 32-bit words.\n *\n * Do not use MakeBigReq if there is no data already in the request.\n * req->length must already be >= 2.\n */\n#ifdef LONG64\n#define MakeBigReq(req,n) \\\n    { \\\n    CARD64 _BRdat; \\\n    CARD32 _BRlen = req->length - 1; \\\n    req->length = 0; \\\n    _BRdat = ((CARD32 *)req)[_BRlen]; \\\n    memmove(((char *)req) + 8, ((char *)req) + 4, (_BRlen - 1) << 2); \\\n    ((CARD32 *)req)[1] = _BRlen + n + 2; \\\n    Data32(dpy, &_BRdat, 4); \\\n    }\n#else\n#define MakeBigReq(req,n) \\\n    { \\\n    CARD32 _BRdat; \\\n    CARD32 _BRlen = req->length - 1; \\\n    req->length = 0; \\\n    _BRdat = ((CARD32 *)req)[_BRlen]; \\\n    memmove(((char *)req) + 8, ((char *)req) + 4, (_BRlen - 1) << 2); \\\n    ((CARD32 *)req)[1] = _BRlen + n + 2; \\\n    Data32(dpy, &_BRdat, 4); \\\n    }\n#endif\n\n/*\n * SetReqLen increases the count of 32-bit words in the request by \"n\",\n * or by \"badlen\" if \"n\" is too large.\n *\n * Do not use SetReqLen if \"req\" does not already have data after the\n * xReq header.  req->length must already be >= 2.\n */\n#ifndef __clang_analyzer__\n#define SetReqLen(req,n,badlen) \\\n    if ((req->length + n) > (unsigned)65535) { \\\n\tif (dpy->bigreq_size) { \\\n\t    MakeBigReq(req,n) \\\n\t} else { \\\n\t    n = badlen; \\\n\t    req->length += n; \\\n\t} \\\n    } else \\\n\treq->length += n\n#else\n#define SetReqLen(req,n,badlen) \\\n    req->length += n\n#endif\n\n#define SyncHandle() \\\n\tif (dpy->synchandler) (*dpy->synchandler)(dpy)\n\nextern void _XFlushGCCache(Display *dpy, GC gc);\n#define FlushGC(dpy, gc) \\\n\tif ((gc)->dirty) _XFlushGCCache((dpy), (gc))\n/*\n * Data - Place data in the buffer and pad the end to provide\n * 32 bit word alignment.  Transmit if the buffer fills.\n *\n * \"dpy\" is a pointer to a Display.\n * \"data\" is a pointer to a data buffer.\n * \"len\" is the length of the data buffer.\n */\n#ifndef DataRoutineIsProcedure\n#define Data(dpy, data, len) {\\\n\tif (dpy->bufptr + (len) <= dpy->bufmax) {\\\n\t\tmemcpy(dpy->bufptr, data, (int)len);\\\n\t\tdpy->bufptr += ((len) + 3) & ~3;\\\n\t} else\\\n\t\t_XSend(dpy, data, len);\\\n}\n#endif /* DataRoutineIsProcedure */\n\n\n/* Allocate bytes from the buffer.  No padding is done, so if\n * the length is not a multiple of 4, the caller must be\n * careful to leave the buffer aligned after sending the\n * current request.\n *\n * \"type\" is the type of the pointer being assigned to.\n * \"ptr\" is the pointer being assigned to.\n * \"n\" is the number of bytes to allocate.\n *\n * Example:\n *    xTextElt *elt;\n *    BufAlloc (xTextElt *, elt, nbytes)\n */\n\n#define BufAlloc(type, ptr, n) \\\n    if (dpy->bufptr + (n) > dpy->bufmax) \\\n        _XFlush (dpy); \\\n    ptr = (type) dpy->bufptr; \\\n    memset(ptr, '\\0', n); \\\n    dpy->bufptr += (n);\n\n#define Data16(dpy, data, len) Data((dpy), (_Xconst char *)(data), (len))\n#define _XRead16Pad(dpy, data, len) _XReadPad((dpy), (char *)(data), (len))\n#define _XRead16(dpy, data, len) _XRead((dpy), (char *)(data), (len))\n#ifdef LONG64\n#define Data32(dpy, data, len) _XData32(dpy, (_Xconst long *)data, len)\nextern int _XData32(\n\t     Display *dpy,\n\t     register _Xconst long *data,\n\t     unsigned len\n);\nextern void _XRead32(\n\t     Display *dpy,\n\t     register long *data,\n\t     long len\n);\n#else\n#define Data32(dpy, data, len) Data((dpy), (_Xconst char *)(data), (len))\n#define _XRead32(dpy, data, len) _XRead((dpy), (char *)(data), (len))\n#endif\n\n#define PackData16(dpy,data,len) Data16 (dpy, data, len)\n#define PackData32(dpy,data,len) Data32 (dpy, data, len)\n\n/* Xlib manual is bogus */\n#define PackData(dpy,data,len) PackData16 (dpy, data, len)\n\n#define min(a,b) (((a) < (b)) ? (a) : (b))\n#define max(a,b) (((a) > (b)) ? (a) : (b))\n\n#define CI_NONEXISTCHAR(cs) (((cs)->width == 0) && \\\n\t\t\t     (((cs)->rbearing|(cs)->lbearing| \\\n\t\t\t       (cs)->ascent|(cs)->descent) == 0))\n\n/*\n * CI_GET_CHAR_INFO_1D - return the charinfo struct for the indicated 8bit\n * character.  If the character is in the column and exists, then return the\n * appropriate metrics (note that fonts with common per-character metrics will\n * return min_bounds).  If none of these hold true, try again with the default\n * char.\n */\n#define CI_GET_CHAR_INFO_1D(fs,col,def,cs) \\\n{ \\\n    cs = def; \\\n    if (col >= fs->min_char_or_byte2 && col <= fs->max_char_or_byte2) { \\\n\tif (fs->per_char == NULL) { \\\n\t    cs = &fs->min_bounds; \\\n\t} else { \\\n\t    cs = &fs->per_char[(col - fs->min_char_or_byte2)]; \\\n\t    if (CI_NONEXISTCHAR(cs)) cs = def; \\\n\t} \\\n    } \\\n}\n\n#define CI_GET_DEFAULT_INFO_1D(fs,cs) \\\n  CI_GET_CHAR_INFO_1D (fs, fs->default_char, NULL, cs)\n\n\n\n/*\n * CI_GET_CHAR_INFO_2D - return the charinfo struct for the indicated row and\n * column.  This is used for fonts that have more than row zero.\n */\n#define CI_GET_CHAR_INFO_2D(fs,row,col,def,cs) \\\n{ \\\n    cs = def; \\\n    if (row >= fs->min_byte1 && row <= fs->max_byte1 && \\\n\tcol >= fs->min_char_or_byte2 && col <= fs->max_char_or_byte2) { \\\n\tif (fs->per_char == NULL) { \\\n\t    cs = &fs->min_bounds; \\\n\t} else { \\\n\t    cs = &fs->per_char[((row - fs->min_byte1) * \\\n\t\t\t        (fs->max_char_or_byte2 - \\\n\t\t\t\t fs->min_char_or_byte2 + 1)) + \\\n\t\t\t       (col - fs->min_char_or_byte2)]; \\\n\t    if (CI_NONEXISTCHAR(cs)) cs = def; \\\n        } \\\n    } \\\n}\n\n#define CI_GET_DEFAULT_INFO_2D(fs,cs) \\\n{ \\\n    unsigned int r = (fs->default_char >> 8); \\\n    unsigned int c = (fs->default_char & 0xff); \\\n    CI_GET_CHAR_INFO_2D (fs, r, c, NULL, cs); \\\n}\n\n\n/* srcvar must be a variable for large architecture version */\n#define OneDataCard32(dpy,dstaddr,srcvar) \\\n  { *(CARD32 *)(dstaddr) = (srcvar); }\n\n\ntypedef struct _XInternalAsync {\n    struct _XInternalAsync *next;\n    /*\n     * handler arguments:\n     * rep is the generic reply that caused this handler\n     * to be invoked.  It must also be passed to _XGetAsyncReply.\n     * buf and len are opaque values that must be passed to\n     * _XGetAsyncReply or _XGetAsyncData.\n     * data is the closure stored in this struct.\n     * The handler returns True iff it handled this reply.\n     */\n    Bool (*handler)(\n\t\t    Display*\t/* dpy */,\n\t\t    xReply*\t/* rep */,\n\t\t    char*\t/* buf */,\n\t\t    int\t\t/* len */,\n\t\t    XPointer\t/* data */\n\t\t    );\n    XPointer data;\n} _XAsyncHandler;\n\ntypedef struct _XAsyncEState {\n    unsigned long min_sequence_number;\n    unsigned long max_sequence_number;\n    unsigned char error_code;\n    unsigned char major_opcode;\n    unsigned short minor_opcode;\n    unsigned char last_error_received;\n    int error_count;\n} _XAsyncErrorState;\n\nextern void _XDeqAsyncHandler(Display *dpy, _XAsyncHandler *handler);\n#define DeqAsyncHandler(dpy,handler) { \\\n    if (dpy->async_handlers == (handler)) \\\n\tdpy->async_handlers = (handler)->next; \\\n    else \\\n\t_XDeqAsyncHandler(dpy, handler); \\\n    }\n\ntypedef void (*FreeFuncType) (\n    Display*\t/* display */\n);\n\ntypedef int (*FreeModmapType) (\n    XModifierKeymap*\t/* modmap */\n);\n\n/*\n * This structure is private to the library.\n */\ntypedef struct _XFreeFuncs {\n    FreeFuncType atoms;\t\t/* _XFreeAtomTable */\n    FreeModmapType modifiermap;\t/* XFreeModifiermap */\n    FreeFuncType key_bindings;\t/* _XFreeKeyBindings */\n    FreeFuncType context_db;\t/* _XFreeContextDB */\n    FreeFuncType defaultCCCs;\t/* _XcmsFreeDefaultCCCs */\n    FreeFuncType clientCmaps;\t/* _XcmsFreeClientCmaps */\n    FreeFuncType intensityMaps;\t/* _XcmsFreeIntensityMaps */\n    FreeFuncType im_filters;\t/* _XFreeIMFilters */\n    FreeFuncType xkb;\t\t/* _XkbFreeInfo */\n} _XFreeFuncRec;\n\n/* types for InitExt.c */\ntypedef int (*CreateGCType) (\n    Display*\t/* display */,\n    GC\t\t/* gc */,\n    XExtCodes*\t/* codes */\n);\n\ntypedef int (*CopyGCType)(\n    Display*\t/* display */,\n    GC\t\t/* gc */,\n    XExtCodes*\t/* codes */\n);\n\ntypedef int (*FlushGCType) (\n    Display*\t/* display */,\n    GC\t\t/* gc */,\n    XExtCodes*\t/* codes */\n);\n\ntypedef int (*FreeGCType) (\n    Display*\t/* display */,\n    GC\t\t/* gc */,\n    XExtCodes*\t/* codes */\n);\n\ntypedef int (*CreateFontType) (\n    Display*\t/* display */,\n    XFontStruct* /* fs */,\n    XExtCodes*\t/* codes */\n);\n\ntypedef int (*FreeFontType) (\n    Display*\t/* display */,\n    XFontStruct* /* fs */,\n    XExtCodes*\t/* codes */\n);\n\ntypedef int (*CloseDisplayType) (\n    Display*\t/* display */,\n    XExtCodes*\t/* codes */\n);\n\ntypedef int (*ErrorType) (\n    Display*\t/* display */,\n    xError*\t/* err */,\n    XExtCodes*\t/* codes */,\n    int*\t/* ret_code */\n);\n\ntypedef char* (*ErrorStringType) (\n    Display*\t/* display */,\n    int\t\t/* code */,\n    XExtCodes*\t/* codes */,\n    char*\t/* buffer */,\n    int\t\t/* nbytes */\n);\n\ntypedef void (*PrintErrorType)(\n    Display*\t/* display */,\n    XErrorEvent* /* ev */,\n    void*\t/* fp */\n);\n\ntypedef void (*BeforeFlushType)(\n    Display*\t/* display */,\n    XExtCodes*\t/* codes */,\n    _Xconst char* /* data */,\n    long\t/* len */\n);\n\n/*\n * This structure is private to the library.\n */\ntypedef struct _XExten {\t\t/* private to extension mechanism */\n\tstruct _XExten *next;\t\t/* next in list */\n\tXExtCodes codes;\t\t/* public information, all extension told */\n\tCreateGCType create_GC;\t\t/* routine to call when GC created */\n\tCopyGCType copy_GC;\t\t/* routine to call when GC copied */\n\tFlushGCType flush_GC;\t\t/* routine to call when GC flushed */\n\tFreeGCType free_GC;\t\t/* routine to call when GC freed */\n\tCreateFontType create_Font;\t/* routine to call when Font created */\n\tFreeFontType free_Font;\t\t/* routine to call when Font freed */\n\tCloseDisplayType close_display;\t/* routine to call when connection closed */\n\tErrorType error;\t\t/* who to call when an error occurs */\n\tErrorStringType error_string;\t/* routine to supply error string */\n\tchar *name;\t\t\t/* name of this extension */\n\tPrintErrorType error_values;\t/* routine to supply error values */\n\tBeforeFlushType before_flush;\t/* routine to call when sending data */\n\tstruct _XExten *next_flush;\t/* next in list of those with flushes */\n} _XExtension;\n\n/* Temporary definition until we can depend on an xproto release with it */\n#ifdef _X_COLD\n# define _XLIB_COLD _X_COLD\n#elif defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 403) /* 4.3+ */\n# define _XLIB_COLD __attribute__((__cold__))\n#else\n# define _XLIB_COLD /* nothing */\n#endif\n\n/* extension hooks */\n\n#ifdef DataRoutineIsProcedure\nextern void Data(Display *dpy, char *data, long len);\n#endif\nextern int _XError(\n    Display*\t/* dpy */,\n    xError*\t/* rep */\n);\nextern int _XIOError(\n    Display*\t/* dpy */\n) _X_NORETURN;\nextern int (*_XIOErrorFunction)(\n    Display*\t/* dpy */\n);\nextern int (*_XErrorFunction)(\n    Display*\t\t/* dpy */,\n    XErrorEvent*\t/* error_event */\n);\nextern void _XEatData(\n    Display*\t\t/* dpy */,\n    unsigned long\t/* n */\n) _XLIB_COLD;\nextern void _XEatDataWords(\n    Display*\t\t/* dpy */,\n    unsigned long\t/* n */\n) _XLIB_COLD;\n#if defined(__SUNPRO_C) /* Studio compiler alternative to \"cold\" attribute */\n# pragma rarely_called(_XEatData, _XEatDataWords)\n#endif\nextern char *_XAllocScratch(\n    Display*\t\t/* dpy */,\n    unsigned long\t/* nbytes */\n);\nextern char *_XAllocTemp(\n    Display*\t\t/* dpy */,\n    unsigned long\t/* nbytes */\n);\nextern void _XFreeTemp(\n    Display*\t\t/* dpy */,\n    char*\t\t/* buf */,\n    unsigned long\t/* nbytes */\n);\nextern Visual *_XVIDtoVisual(\n    Display*\t/* dpy */,\n    VisualID\t/* id */\n);\nextern unsigned long _XSetLastRequestRead(\n    Display*\t\t/* dpy */,\n    xGenericReply*\t/* rep */\n);\nextern int _XGetHostname(\n    char*\t/* buf */,\n    int\t\t/* maxlen */\n);\nextern Screen *_XScreenOfWindow(\n    Display*\t/* dpy */,\n    Window\t/* w */\n);\nextern Bool _XAsyncErrorHandler(\n    Display*\t/* dpy */,\n    xReply*\t/* rep */,\n    char*\t/* buf */,\n    int\t\t/* len */,\n    XPointer\t/* data */\n);\nextern char *_XGetAsyncReply(\n    Display*\t/* dpy */,\n    char*\t/* replbuf */,\n    xReply*\t/* rep */,\n    char*\t/* buf */,\n    int\t\t/* len */,\n    int\t\t/* extra */,\n    Bool\t/* discard */\n);\nextern void _XGetAsyncData(\n    Display*\t/* dpy */,\n    char *\t/* data */,\n    char *\t/* buf */,\n    int\t\t/* len */,\n    int\t\t/* skip */,\n    int\t\t/* datalen */,\n    int\t\t/* discardtotal */\n);\nextern void _XFlush(\n    Display*\t/* dpy */\n);\nextern int _XEventsQueued(\n    Display*\t/* dpy */,\n    int \t/* mode */\n);\nextern void _XReadEvents(\n    Display*\t/* dpy */\n);\nextern int _XRead(\n    Display*\t/* dpy */,\n    char*\t/* data */,\n    long\t/* size */\n);\nextern void _XReadPad(\n    Display*\t/* dpy */,\n    char*\t/* data */,\n    long\t/* size */\n);\nextern void _XSend(\n    Display*\t\t/* dpy */,\n    _Xconst char*\t/* data */,\n    long\t\t/* size */\n);\nextern Status _XReply(\n    Display*\t/* dpy */,\n    xReply*\t/* rep */,\n    int\t\t/* extra */,\n    Bool\t/* discard */\n);\nextern void _XEnq(\n    Display*\t/* dpy */,\n    xEvent*\t/* event */\n);\nextern void _XDeq(\n    Display*\t/* dpy */,\n    _XQEvent*\t/* prev */,\n    _XQEvent*\t/* qelt */\n);\n\nextern Bool _XUnknownWireEvent(\n    Display*\t/* dpy */,\n    XEvent*\t/* re */,\n    xEvent*\t/* event */\n);\n\nextern Bool _XUnknownWireEventCookie(\n    Display*\t/* dpy */,\n    XGenericEventCookie*\t/* re */,\n    xEvent*\t/* event */\n);\n\nextern Bool _XUnknownCopyEventCookie(\n    Display*\t/* dpy */,\n    XGenericEventCookie*\t/* in */,\n    XGenericEventCookie*\t/* out */\n);\n\nextern Status _XUnknownNativeEvent(\n    Display*\t/* dpy */,\n    XEvent*\t/* re */,\n    xEvent*\t/* event */\n);\n\nextern Bool _XWireToEvent(Display *dpy, XEvent *re, xEvent *event);\nextern Bool _XDefaultWireError(Display *display, XErrorEvent *he, xError *we);\nextern Bool _XPollfdCacheInit(Display *dpy);\nextern void _XPollfdCacheAdd(Display *dpy, int fd);\nextern void _XPollfdCacheDel(Display *dpy, int fd);\nextern XID _XAllocID(Display *dpy);\nextern void _XAllocIDs(Display *dpy, XID *ids, int count);\n\nextern int _XFreeExtData(\n    XExtData*\t/* extension */\n);\n\nextern int (*XESetCreateGC(\n    Display*\t\t/* display */,\n    int\t\t\t/* extension */,\n    int (*) (\n\t      Display*\t\t\t/* display */,\n\t      GC\t\t\t/* gc */,\n\t      XExtCodes*\t\t/* codes */\n\t    )\t\t/* proc */\n))(\n    Display*, GC, XExtCodes*\n);\n\nextern int (*XESetCopyGC(\n    Display*\t\t/* display */,\n    int\t\t\t/* extension */,\n    int (*) (\n\t      Display*\t\t\t/* display */,\n              GC\t\t\t/* gc */,\n              XExtCodes*\t\t/* codes */\n            )\t\t/* proc */\n))(\n    Display*, GC, XExtCodes*\n);\n\nextern int (*XESetFlushGC(\n    Display*\t\t/* display */,\n    int\t\t\t/* extension */,\n    int (*) (\n\t      Display*\t\t\t/* display */,\n              GC\t\t\t/* gc */,\n              XExtCodes*\t\t/* codes */\n            )\t\t/* proc */\n))(\n    Display*, GC, XExtCodes*\n);\n\nextern int (*XESetFreeGC(\n    Display*\t\t/* display */,\n    int\t\t\t/* extension */,\n    int (*) (\n\t      Display*\t\t\t/* display */,\n              GC\t\t\t/* gc */,\n              XExtCodes*\t\t/* codes */\n            )\t\t/* proc */\n))(\n    Display*, GC, XExtCodes*\n);\n\nextern int (*XESetCreateFont(\n    Display*\t\t/* display */,\n    int\t\t\t/* extension */,\n    int (*) (\n\t      Display*\t\t\t/* display */,\n              XFontStruct*\t\t/* fs */,\n              XExtCodes*\t\t/* codes */\n            )\t\t/* proc */\n))(\n    Display*, XFontStruct*, XExtCodes*\n);\n\nextern int (*XESetFreeFont(\n    Display*\t\t/* display */,\n    int\t\t\t/* extension */,\n    int (*) (\n\t      Display*\t\t\t/* display */,\n              XFontStruct*\t\t/* fs */,\n              XExtCodes*\t\t/* codes */\n            )\t\t/* proc */\n))(\n    Display*, XFontStruct*, XExtCodes*\n);\n\nextern int (*XESetCloseDisplay(\n    Display*\t\t/* display */,\n    int\t\t\t/* extension */,\n    int (*) (\n\t      Display*\t\t\t/* display */,\n              XExtCodes*\t\t/* codes */\n            )\t\t/* proc */\n))(\n    Display*, XExtCodes*\n);\n\nextern int (*XESetError(\n    Display*\t\t/* display */,\n    int\t\t\t/* extension */,\n    int (*) (\n\t      Display*\t\t\t/* display */,\n              xError*\t\t\t/* err */,\n              XExtCodes*\t\t/* codes */,\n              int*\t\t\t/* ret_code */\n            )\t\t/* proc */\n))(\n    Display*, xError*, XExtCodes*, int*\n);\n\nextern char* (*XESetErrorString(\n    Display*\t\t/* display */,\n    int\t\t\t/* extension */,\n    char* (*) (\n\t        Display*\t\t/* display */,\n                int\t\t\t/* code */,\n                XExtCodes*\t\t/* codes */,\n                char*\t\t\t/* buffer */,\n                int\t\t\t/* nbytes */\n              )\t\t/* proc */\n))(\n    Display*, int, XExtCodes*, char*, int\n);\n\nextern void (*XESetPrintErrorValues (\n    Display*\t\t/* display */,\n    int\t\t\t/* extension */,\n    void (*)(\n\t      Display*\t\t\t/* display */,\n\t      XErrorEvent*\t\t/* ev */,\n\t      void*\t\t\t/* fp */\n\t     )\t\t/* proc */\n))(\n    Display*, XErrorEvent*, void*\n);\n\nextern Bool (*XESetWireToEvent(\n    Display*\t\t/* display */,\n    int\t\t\t/* event_number */,\n    Bool (*) (\n\t       Display*\t\t\t/* display */,\n               XEvent*\t\t\t/* re */,\n               xEvent*\t\t\t/* event */\n             )\t\t/* proc */\n))(\n    Display*, XEvent*, xEvent*\n);\n\nextern Bool (*XESetWireToEventCookie(\n    Display*\t\t/* display */,\n    int\t\t\t/* extension */,\n    Bool (*) (\n\t       Display*\t\t\t/* display */,\n               XGenericEventCookie*\t/* re */,\n               xEvent*\t\t\t/* event */\n             )\t\t/* proc */\n))(\n    Display*, XGenericEventCookie*, xEvent*\n);\n\nextern Bool (*XESetCopyEventCookie(\n    Display*\t\t/* display */,\n    int\t\t\t/* extension */,\n    Bool (*) (\n\t       Display*\t\t\t/* display */,\n               XGenericEventCookie*\t/* in */,\n               XGenericEventCookie*\t/* out */\n             )\t\t/* proc */\n))(\n    Display*, XGenericEventCookie*, XGenericEventCookie*\n);\n\n\nextern Status (*XESetEventToWire(\n    Display*\t\t/* display */,\n    int\t\t\t/* event_number */,\n    Status (*) (\n\t      Display*\t\t\t/* display */,\n              XEvent*\t\t\t/* re */,\n              xEvent*\t\t\t/* event */\n            )\t\t/* proc */\n))(\n    Display*, XEvent*, xEvent*\n);\n\nextern Bool (*XESetWireToError(\n    Display*\t\t/* display */,\n    int\t\t\t/* error_number */,\n    Bool (*) (\n\t       Display*\t\t\t/* display */,\n\t       XErrorEvent*\t\t/* he */,\n\t       xError*\t\t\t/* we */\n            )\t\t/* proc */\n))(\n    Display*, XErrorEvent*, xError*\n);\n\nextern void (*XESetBeforeFlush(\n    Display*\t\t/* display */,\n    int\t\t\t/* error_number */,\n    void (*) (\n\t       Display*\t\t\t/* display */,\n\t       XExtCodes*\t\t/* codes */,\n\t       _Xconst char*\t\t/* data */,\n\t       long\t\t\t/* len */\n            )\t\t/* proc */\n))(\n    Display*, XExtCodes*, _Xconst char*, long\n);\n\n/* internal connections for IMs */\n\ntypedef void (*_XInternalConnectionProc)(\n    Display*\t\t\t/* dpy */,\n    int\t\t\t\t/* fd */,\n    XPointer\t\t\t/* call_data */\n);\n\n\nextern Status _XRegisterInternalConnection(\n    Display*\t\t\t/* dpy */,\n    int\t\t\t\t/* fd */,\n    _XInternalConnectionProc\t/* callback */,\n    XPointer\t\t\t/* call_data */\n);\n\nextern void _XUnregisterInternalConnection(\n    Display*\t\t\t/* dpy */,\n    int\t\t\t\t/* fd */\n);\n\nextern void _XProcessInternalConnection(\n    Display*\t\t\t/* dpy */,\n    struct _XConnectionInfo*\t/* conn_info */\n);\n\n/* Display structure has pointers to these */\n\nstruct _XConnectionInfo {\t/* info from _XRegisterInternalConnection */\n    int fd;\n    _XInternalConnectionProc read_callback;\n    XPointer call_data;\n    XPointer *watch_data;\t/* set/used by XConnectionWatchProc */\n    struct _XConnectionInfo *next;\n};\n\nstruct _XConnWatchInfo {\t/* info from XAddConnectionWatch */\n    XConnectionWatchProc fn;\n    XPointer client_data;\n    struct _XConnWatchInfo *next;\n};\n\n#ifdef __UNIXOS2__\nextern char* __XOS2RedirRoot(\n    char*\n);\n#endif\n\nextern int _XTextHeight(\n    XFontStruct*\t/* font_struct */,\n    _Xconst char*\t/* string */,\n    int\t\t\t/* count */\n);\n\nextern int _XTextHeight16(\n    XFontStruct*\t/* font_struct */,\n    _Xconst XChar2b*\t/* string */,\n    int\t\t\t/* count */\n);\n\n#if defined(WIN32)\n\nextern int _XOpenFile(\n    _Xconst char*\t/* path */,\n    int\t\t\t/* flags */\n);\n\nextern int _XOpenFileMode(\n    _Xconst char*\t/* path */,\n    int\t\t\t/* flags */,\n    mode_t              /* mode */\n);\n\nextern void* _XFopenFile(\n    _Xconst char*\t/* path */,\n    _Xconst char*\t/* mode */\n);\n\nextern int _XAccessFile(\n    _Xconst char*\t/* path */\n);\n#else\n#define _XOpenFile(path,flags) open(path,flags)\n#define _XOpenFileMode(path,flags,mode) open(path,flags,mode)\n#define _XFopenFile(path,mode) fopen(path,mode)\n#endif\n\n/* EvToWire.c */\nextern Status _XEventToWire(Display *dpy, XEvent *re, xEvent *event);\n\nextern int _XF86LoadQueryLocaleFont(\n    Display*\t\t/* dpy */,\n    _Xconst char*\t/* name*/,\n    XFontStruct**\t/* xfp*/,\n    Font*\t\t/* fidp */\n);\n\nextern void _XProcessWindowAttributes (\n    register Display *dpy,\n    xChangeWindowAttributesReq *req,\n    register unsigned long valuemask,\n    register XSetWindowAttributes *attributes);\n\nextern int _XDefaultError(\n        Display *dpy,\n        XErrorEvent *event);\n\nextern int _XDefaultIOError(\n        Display *dpy);\n\nextern void _XSetClipRectangles (\n    register Display *dpy,\n    GC gc,\n    int clip_x_origin, int clip_y_origin,\n    XRectangle *rectangles,\n    int n,\n    int ordering);\n\nStatus _XGetWindowAttributes(\n    register Display *dpy,\n    Window w,\n    XWindowAttributes *attr);\n\nint _XPutBackEvent (\n    register Display *dpy,\n    register XEvent *event);\n\nextern Bool _XIsEventCookie(\n        Display *dpy,\n        XEvent *ev);\n\nextern void _XFreeEventCookies(\n        Display *dpy);\n\nextern void _XStoreEventCookie(\n        Display *dpy,\n        XEvent *ev);\n\nextern Bool _XFetchEventCookie(\n        Display *dpy,\n        XGenericEventCookie *ev);\n\nextern Bool _XCopyEventCookie(\n        Display *dpy,\n        XGenericEventCookie *in,\n        XGenericEventCookie *out);\n\n/* lcFile.c */\n\nextern void xlocaledir(\n    char *buf,\n    int buf_len\n);\n\n#ifdef __clang__\n#pragma clang diagnostic pop\n#endif\n\n_XFUNCPROTOEND\n\n#endif /* _X11_XLIBINT_H_ */\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/X11/Xlocale.h",
    "content": "/*\n\nCopyright 1991, 1998  The Open Group\n\nPermission to use, copy, modify, distribute, and sell this software and its\ndocumentation for any purpose is hereby granted without fee, provided that\nthe above copyright notice appear in all copies and that both that\ncopyright notice and this permission notice appear in supporting\ndocumentation.\n\nThe above copyright notice and this permission notice shall be included\nin all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\nOR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR\nOTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,\nARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\nOTHER DEALINGS IN THE SOFTWARE.\n\nExcept as contained in this notice, the name of The Open Group shall\nnot be used in advertising or otherwise to promote the sale, use or\nother dealings in this Software without prior written authorization\nfrom The Open Group.\n\n*/\n\n#ifndef _X11_XLOCALE_H_\n#define _X11_XLOCALE_H_\n\n#include <X11/Xfuncproto.h>\n#include <X11/Xosdefs.h>\n\n#ifndef X_LOCALE\n#include <locale.h>\n#else\n\n#define LC_ALL      0\n#define LC_COLLATE  1\n#define LC_CTYPE    2\n#define LC_MONETARY 3\n#define LC_NUMERIC  4\n#define LC_TIME     5\n\n_XFUNCPROTOBEGIN\nextern char *_Xsetlocale(\n    int /* category */,\n    _Xconst char* /* name */\n);\n_XFUNCPROTOEND\n\n#define setlocale _Xsetlocale\n\n#include <stddef.h>\n\n#endif /* X_LOCALE */\n\n#endif /* _X11_XLOCALE_H_ */\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/X11/Xmd.h",
    "content": "/***********************************************************\n\nCopyright 1987, 1998  The Open Group\n\nPermission to use, copy, modify, distribute, and sell this software and its\ndocumentation for any purpose is hereby granted without fee, provided that\nthe above copyright notice appear in all copies and that both that\ncopyright notice and this permission notice appear in supporting\ndocumentation.\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE\nOPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN\nAN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\nCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\nExcept as contained in this notice, the name of The Open Group shall not be\nused in advertising or otherwise to promote the sale, use or other dealings\nin this Software without prior written authorization from The Open Group.\n\n\nCopyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.\n\n                        All Rights Reserved\n\nPermission to use, copy, modify, and distribute this software and its\ndocumentation for any purpose and without fee is hereby granted,\nprovided that the above copyright notice appear in all copies and that\nboth that copyright notice and this permission notice appear in\nsupporting documentation, and that the name of Digital not be\nused in advertising or publicity pertaining to distribution of the\nsoftware without specific, written prior permission.\n\nDIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING\nALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL\nDIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR\nANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,\nWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,\nARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS\nSOFTWARE.\n\n******************************************************************/\n#ifndef XMD_H\n# define XMD_H 1\n/*\n *  Xmd.h: MACHINE DEPENDENT DECLARATIONS.\n */\n\n/*\n * Special per-machine configuration flags.\n */\n# if defined(__sun) && defined(__SVR4)\n#  include <sys/isa_defs.h> /* Solaris: defines _LP64 if necessary */\n# endif\n\n# if defined (_LP64) || defined(__LP64__) || \\\n     defined(__alpha) || defined(__alpha__) || \\\n     defined(__ia64__) || defined(ia64) || \\\n     defined(__sparc64__) || \\\n     defined(__s390x__) || \\\n     defined(__amd64__) || defined(amd64) || \\\n     defined(__powerpc64__)\n#  if !defined(__ILP32__) /* amd64-x32 is 32bit */\n#   define LONG64\t\t\t\t/* 32/64-bit architecture */\n#  endif /* !__ILP32__ */\n# endif\n\n/*\n * Definition of macro used to set constants for size of network structures;\n * machines with preprocessors that can't handle all of the sz_ symbols\n * can define this macro to be sizeof(x) if and only if their compiler doesn't\n * pad out structures (esp. the xTextElt structure which contains only two\n * one-byte fields).  Network structures should always define sz_symbols.\n *\n * The sz_ prefix is used instead of something more descriptive so that the\n * symbols are no more than 32 characters long (which causes problems for some\n * compilers and preprocessors).\n *\n * The extra indirection is to get macro arguments to expand correctly before\n * the concatenation, rather than afterward.\n */\n# define _SIZEOF(x) sz_##x\n# define SIZEOF(x) _SIZEOF(x)\n\n/*\n * Bitfield suffixes for the protocol structure elements, if you\n * need them.  Note that bitfields are not guaranteed to be signed\n * (or even unsigned) according to ANSI C.\n */\n# define B32 /* bitfield not needed on architectures with native 32-bit type */\n# define B16 /* bitfield not needed on architectures with native 16-bit type */\n# ifdef LONG64\ntypedef long INT64;\ntypedef int INT32;\n# else\ntypedef long INT32;\n# endif\ntypedef short INT16;\n\ntypedef signed char    INT8;\n\n# ifdef LONG64\ntypedef unsigned long CARD64;\ntypedef unsigned int CARD32;\n# else\ntypedef unsigned long long CARD64;\ntypedef unsigned long CARD32;\n# endif\ntypedef unsigned short CARD16;\ntypedef unsigned char  CARD8;\n\ntypedef CARD32\t\tBITS32;\ntypedef CARD16\t\tBITS16;\n\ntypedef CARD8\t\tBYTE;\ntypedef CARD8\t\tBOOL;\n\n/*\n * was definitions for sign-extending bitfields on architectures without\n * native types smaller than 64-bit, now just backwards compatibility\n */\n# define cvtINT8toInt(val) (val)\n# define cvtINT16toInt(val) (val)\n# define cvtINT32toInt(val) (val)\n# define cvtINT8toShort(val) (val)\n# define cvtINT16toShort(val) (val)\n# define cvtINT32toShort(val) (val)\n# define cvtINT8toLong(val) (val)\n# define cvtINT16toLong(val) (val)\n# define cvtINT32toLong(val) (val)\n\n/*\n * this version should leave result of type (t *), but that should only be\n * used when not in MUSTCOPY\n */\n# define NEXTPTR(p,t) (((t *)(p)) + 1)\n\n#endif /* XMD_H */\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/X11/Xos.h",
    "content": "/*\n *\nCopyright 1987, 1998  The Open Group\n\nPermission to use, copy, modify, distribute, and sell this software and its\ndocumentation for any purpose is hereby granted without fee, provided that\nthe above copyright notice appear in all copies and that both that\ncopyright notice and this permission notice appear in supporting\ndocumentation.\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE\nOPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN\nAN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\nCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\nExcept as contained in this notice, the name of The Open Group shall not be\nused in advertising or otherwise to promote the sale, use or other dealings\nin this Software without prior written authorization from The Open Group.\n *\n * The X Window System is a Trademark of The Open Group.\n *\n */\n\n/* This is a collection of things to try and minimize system dependencies\n * in a \"significant\" number of source files.\n */\n\n#ifndef _XOS_H_\n# define _XOS_H_\n\n# include <X11/Xosdefs.h>\n\n/*\n * Get major data types (esp. caddr_t)\n */\n\n# include <sys/types.h>\n\n# if defined(__SCO__) || defined(__UNIXWARE__)\n#  include <stdint.h>\n# endif\n\n\n/*\n * Just about everyone needs the strings routines.  We provide both forms here,\n * index/rindex and strchr/strrchr, so any systems that don't provide them all\n * need to have #defines here.\n *\n * These macros are defined this way, rather than, e.g.:\n *    #defined index(s,c) strchr(s,c)\n * because someone might be using them as function pointers, and such\n * a change would break compatibility for anyone who's relying on them\n * being the way they currently are. So we're stuck with them this way,\n * which can be really inconvenient. :-(\n */\n\n# include <string.h>\n# if defined(__SCO__) || defined(__UNIXWARE__) || defined(__sun) || defined(__CYGWIN__) || defined(_AIX) || defined(__APPLE__)\n#  include <strings.h>\n# else\n#  ifndef index\n#   define index(s,c) (strchr((s),(c)))\n#  endif\n#  ifndef rindex\n#   define rindex(s,c) (strrchr((s),(c)))\n#  endif\n# endif\n\n/*\n * Get open(2) constants\n */\n# if defined(X_NOT_POSIX)\n#  include <fcntl.h>\n#  if defined(USL) || defined(__i386__) && (defined(SYSV) || defined(SVR4))\n#   include <unistd.h>\n#  endif\n#  ifdef WIN32\n#   include <X11/Xw32defs.h>\n#  else\n#   include <sys/file.h>\n#  endif\n# else /* X_NOT_POSIX */\n#  include <fcntl.h>\n#  include <unistd.h>\n# endif /* X_NOT_POSIX else */\n\n/*\n * Get struct timeval and struct tm\n */\n\n# if defined(_POSIX_SOURCE) && defined(SVR4)\n/* need to omit _POSIX_SOURCE in order to get what we want in SVR4 */\n#  undef _POSIX_SOURCE\n#  include <sys/time.h>\n#  define _POSIX_SOURCE\n# elif defined(WIN32)\n#  include <time.h>\n#  if !defined(_WINSOCKAPI_) && !defined(_WILLWINSOCK_) && !defined(_TIMEVAL_DEFINED) && !defined(_STRUCT_TIMEVAL)\nstruct timeval {\n    long    tv_sec;         /* seconds */\n    long    tv_usec;        /* and microseconds */\n};\n#   define _TIMEVAL_DEFINED\n#  endif\n#  include <sys/timeb.h>\n#  define gettimeofday(t) \\\n{ \\\n    struct _timeb _gtodtmp; \\\n    _ftime (&_gtodtmp); \\\n    (t)->tv_sec = _gtodtmp.time; \\\n    (t)->tv_usec = _gtodtmp.millitm * 1000; \\\n}\n# else\n#  include <sys/time.h>\n#  include <time.h>\n# endif /* defined(_POSIX_SOURCE) && defined(SVR4) */\n\n/* define X_GETTIMEOFDAY macro, a portable gettimeofday() */\n# if defined(_XOPEN_XPG4) || defined(_XOPEN_UNIX) /* _XOPEN_UNIX is XPG4.2 */\n#  define X_GETTIMEOFDAY(t) gettimeofday(t, (struct timezone*)0)\n# else\n#  if defined(SVR4) || defined(__SVR4) || defined(WIN32)\n#   define X_GETTIMEOFDAY(t) gettimeofday(t)\n#  else\n#   define X_GETTIMEOFDAY(t) gettimeofday(t, (struct timezone*)0)\n#  endif\n# endif /* XPG4 else */\n\n\n# ifdef __GNU__\n#  define PATH_MAX 4096\n#  define MAXPATHLEN 4096\n#  define OPEN_MAX 256 /* We define a reasonable limit.  */\n# endif\n\n/* use POSIX name for signal */\n# if defined(X_NOT_POSIX) && defined(SYSV) && !defined(SIGCHLD)\n#  define SIGCHLD SIGCLD\n# endif\n\n# include <X11/Xarch.h>\n\n#endif /* _XOS_H_ */\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/X11/Xos_r.h",
    "content": "/*\nCopyright 1996, 1998  The Open Group\n\nPermission to use, copy, modify, distribute, and sell this software and its\ndocumentation for any purpose is hereby granted without fee, provided that\nthe above copyright notice appear in all copies and that both that\ncopyright notice and this permission notice appear in supporting\ndocumentation.\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE\nOPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN\nAN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\nCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\nExcept as contained in this notice, the name of The Open Group shall not be\nused in advertising or otherwise to promote the sale, use or other dealings\nin this Software without prior written authorization from The Open Group.\n*/\n\n/*\n * Various and sundry Thread-Safe functions used by X11, Motif, and CDE.\n *\n * Use this file in MT-safe code where you would have included\n *\t<dirent.h>\tfor readdir()\n *\t<grp.h>\t\tfor getgrgid() or getgrnam()\n *\t<netdb.h>\tfor gethostbyname(), gethostbyaddr(), or getservbyname()\n *\t<pwd.h>\t\tfor getpwnam() or getpwuid()\n *\t<string.h>\tfor strtok()\n *\t<time.h>\tfor asctime(), ctime(), localtime(), or gmtime()\n *\t<unistd.h>\tfor getlogin() or ttyname()\n * or their thread-safe analogs.\n *\n * If you are on a platform that defines XTHREADS but does not have\n * MT-safe system API (e.g. UnixWare) you must define _Xos_processLock\n * and _Xos_processUnlock macros before including this header.\n *\n * For convenience XOS_USE_XLIB_LOCKING or XOS_USE_XT_LOCKING may be defined\n * to obtain either Xlib-only or Xt-based versions of these macros.  These\n * macros won't result in truly thread-safe calls, but they are better than\n * nothing.  If you do not want locking in this situation define\n * XOS_USE_NO_LOCKING.\n *\n * NOTE: On systems lacking appropriate _r functions Gethostbyname(),\n *\tGethostbyaddr(), and Getservbyname() do NOT copy the host or\n *\tprotocol lists!\n *\n * NOTE: On systems lacking appropriate _r functions Getgrgid() and\n *\tGetgrnam() do NOT copy the list of group members!\n *\n * This header is nominally intended to simplify porting X11, Motif, and\n * CDE; it may be useful to other people too.  The structure below is\n * complicated, mostly because P1003.1c (the IEEE POSIX Threads spec)\n * went through lots of drafts, and some vendors shipped systems based\n * on draft API that were changed later.  Unfortunately POSIX did not\n * provide a feature-test macro for distinguishing each of the drafts.\n */\n\n/*\n * This header has several parts.  Search for \"Effective prototypes\"\n * to locate the beginning of a section.\n */\n\n/* This header can be included multiple times with different defines! */\n#ifndef _XOS_R_H_\n# define _XOS_R_H_\n\n# include <X11/Xos.h>\n# include <X11/Xfuncs.h>\n\n# ifndef X_NOT_POSIX\n#  ifdef _POSIX_SOURCE\n#   include <limits.h>\n#  else\n#   define _POSIX_SOURCE\n#   include <limits.h>\n#   undef _POSIX_SOURCE\n#  endif\n#  ifndef LINE_MAX\n#   define X_LINE_MAX 2048\n#  else\n#   define X_LINE_MAX LINE_MAX\n#  endif\n# endif\n#endif /* _XOS_R_H */\n\n#ifndef WIN32\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n# if defined(XOS_USE_XLIB_LOCKING)\n#  ifndef XAllocIDs /* Xlibint.h does not have multiple include protection */\ntypedef struct _LockInfoRec *LockInfoPtr;\nextern LockInfoPtr _Xglobal_lock;\n#  endif\n#  ifndef _Xos_isThreadInitialized\n#   define _Xos_isThreadInitialized\t(_Xglobal_lock)\n#  endif\n#  if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)\n#   ifndef XAllocIDs /* Xlibint.h does not have multiple include protection */\n#    include <X11/Xfuncproto.h>\t/* for NeedFunctionPrototypes */\nextern void (*_XLockMutex_fn)(\n#    if NeedFunctionPrototypes\n    LockInfoPtr\t/* lock */, char * /* file */, int /* line */\n#    endif\n);\nextern void (*_XUnlockMutex_fn)(\n#    if NeedFunctionPrototypes\n    LockInfoPtr\t/* lock */, char * /* file */, int /* line */\n#    endif\n);\n#   endif\n#   ifndef _Xos_processLock\n#    define _Xos_processLock\t\\\n  (_XLockMutex_fn ? (*_XLockMutex_fn)(_Xglobal_lock,__FILE__,__LINE__) : 0)\n#   endif\n#   ifndef _Xos_processUnlock\n#    define _Xos_processUnlock\t\\\n  (_XUnlockMutex_fn ? (*_XUnlockMutex_fn)(_Xglobal_lock,__FILE__,__LINE__) : 0)\n#   endif\n#  else\n#   ifndef XAllocIDs /* Xlibint.h does not have multiple include protection */\n#    include <X11/Xfuncproto.h>\t/* for NeedFunctionPrototypes */\nextern void (*_XLockMutex_fn)(\n#    if NeedFunctionPrototypes\n    LockInfoPtr\t/* lock */\n#    endif\n);\nextern void (*_XUnlockMutex_fn)(\n#    if NeedFunctionPrototypes\n    LockInfoPtr\t/* lock */\n#    endif\n);\n#   endif\n#   ifndef _Xos_processLock\n#    define _Xos_processLock\t\\\n  (_XLockMutex_fn ? ((*_XLockMutex_fn)(_Xglobal_lock), 0) : 0)\n#   endif\n#   ifndef _Xos_processUnlock\n#    define _Xos_processUnlock\t\\\n  (_XUnlockMutex_fn ? ((*_XUnlockMutex_fn)(_Xglobal_lock), 0) : 0)\n#   endif\n#  endif\n# elif defined(XOS_USE_XT_LOCKING)\n#  ifndef _XtThreadsI_h\nextern void (*_XtProcessLock)(void);\n#  endif\n#  ifndef _XtintrinsicP_h\n#   include <X11/Xfuncproto.h>\t/* for NeedFunctionPrototypes */\nextern void XtProcessLock(\n#   if NeedFunctionPrototypes\n    void\n#   endif\n);\nextern void XtProcessUnlock(\n#   if NeedFunctionPrototypes\n    void\n#   endif\n);\n#  endif\n#  ifndef _Xos_isThreadInitialized\n#   define _Xos_isThreadInitialized\t_XtProcessLock\n#  endif\n#  ifndef _Xos_processLock\n#   define _Xos_processLock\t\tXtProcessLock()\n#  endif\n#  ifndef _Xos_processUnlock\n#   define _Xos_processUnlock\t\tXtProcessUnlock()\n#  endif\n# elif defined(XOS_USE_NO_LOCKING)\n#  ifndef _Xos_isThreadInitialized\n#   define _Xos_isThreadInitialized\t0\n#  endif\n#  ifndef _Xos_processLock\n#   define _Xos_processLock\t\t0\n#  endif\n#  ifndef _Xos_processUnlock\n#   define _Xos_processUnlock\t\t0\n#  endif\n# endif\n\n#endif /* !defined WIN32 */\n\n/*\n * Solaris defines the POSIX thread-safe feature test macro, but\n * uses the older SVR4 thread-safe functions unless the POSIX ones\n * are specifically requested.  Fix the feature test macro.\n */\n#if defined(__sun) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && \\\n\t(_POSIX_C_SOURCE - 0 < 199506L) && !defined(_POSIX_PTHREAD_SEMANTICS)\n# undef _POSIX_THREAD_SAFE_FUNCTIONS\n#endif\n\n/***** <pwd.h> wrappers *****/\n\n/*\n * Effective prototypes for <pwd.h> wrappers:\n *\n * #define X_INCLUDE_PWD_H\n * #define XOS_USE_..._LOCKING\n * #include <X11/Xos_r.h>\n *\n * typedef ... _Xgetpwparams;\n *\n * struct passwd* _XGetpwnam(const char *name, _Xgetpwparams);\n * struct passwd* _XGetpwuid(uid_t uid, _Xgetpwparams);\n */\n\n#if defined(X_INCLUDE_PWD_H) && !defined(_XOS_INCLUDED_PWD_H)\n# include <pwd.h>\n# if defined(XUSE_MTSAFE_API) || defined(XUSE_MTSAFE_PWDAPI)\n#  define XOS_USE_MTSAFE_PWDAPI 1\n# endif\n#endif\n\n#undef X_NEEDS_PWPARAMS\n#if !defined(X_INCLUDE_PWD_H) || defined(_XOS_INCLUDED_PWD_H)\n/* Do nothing */\n\n#elif !defined(XTHREADS) && !defined(X_FORCE_USE_MTSAFE_API)\n/* Use regular, unsafe API. */\n# if defined(X_NOT_POSIX) && !defined(__i386__) && !defined(SYSV)\nextern struct passwd *getpwuid(), *getpwnam();\n# endif\ntypedef int _Xgetpwparams;\t/* dummy */\n# define _XGetpwuid(u,p)\tgetpwuid((u))\n# define _XGetpwnam(u,p)\tgetpwnam((u))\n\n#elif !defined(XOS_USE_MTSAFE_PWDAPI) || defined(XNO_MTSAFE_PWDAPI)\n/* UnixWare 2.0, or other systems with thread support but no _r API. */\n# define X_NEEDS_PWPARAMS\ntypedef struct {\n  struct passwd pws;\n  char   pwbuf[1024];\n  struct passwd* pwp;\n  size_t len;\n} _Xgetpwparams;\n\n/*\n * NetBSD and FreeBSD, at least, are missing several of the unixware passwd\n * fields.\n */\n\n#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__) || \\\n    defined(__APPLE__) || defined(__DragonFly__)\nstatic __inline__ void _Xpw_copyPasswd(_Xgetpwparams p)\n{\n   memcpy(&(p).pws, (p).pwp, sizeof(struct passwd));\n\n   (p).pws.pw_name = (p).pwbuf;\n   (p).len = strlen((p).pwp->pw_name);\n   strcpy((p).pws.pw_name, (p).pwp->pw_name);\n\n   (p).pws.pw_passwd = (p).pws.pw_name + (p).len + 1;\n   (p).len = strlen((p).pwp->pw_passwd);\n   strcpy((p).pws.pw_passwd,(p).pwp->pw_passwd);\n\n   (p).pws.pw_class = (p).pws.pw_passwd + (p).len + 1;\n   (p).len = strlen((p).pwp->pw_class);\n   strcpy((p).pws.pw_class, (p).pwp->pw_class);\n\n   (p).pws.pw_gecos = (p).pws.pw_class + (p).len + 1;\n   (p).len = strlen((p).pwp->pw_gecos);\n   strcpy((p).pws.pw_gecos, (p).pwp->pw_gecos);\n\n   (p).pws.pw_dir = (p).pws.pw_gecos + (p).len + 1;\n   (p).len = strlen((p).pwp->pw_dir);\n   strcpy((p).pws.pw_dir, (p).pwp->pw_dir);\n\n   (p).pws.pw_shell = (p).pws.pw_dir + (p).len + 1;\n   (p).len = strlen((p).pwp->pw_shell);\n   strcpy((p).pws.pw_shell, (p).pwp->pw_shell);\n\n   (p).pwp = &(p).pws;\n}\n\n#else\n# define _Xpw_copyPasswd(p) \\\n   (memcpy(&(p).pws, (p).pwp, sizeof(struct passwd)), \\\n    ((p).pws.pw_name = (p).pwbuf), \\\n    ((p).len = strlen((p).pwp->pw_name)), \\\n    strcpy((p).pws.pw_name, (p).pwp->pw_name), \\\n    ((p).pws.pw_passwd = (p).pws.pw_name + (p).len + 1), \\\n    ((p).len = strlen((p).pwp->pw_passwd)), \\\n    strcpy((p).pws.pw_passwd,(p).pwp->pw_passwd), \\\n    ((p).pws.pw_age = (p).pws.pw_passwd + (p).len + 1), \\\n    ((p).len = strlen((p).pwp->pw_age)), \\\n    strcpy((p).pws.pw_age, (p).pwp->pw_age), \\\n    ((p).pws.pw_comment = (p).pws.pw_age + (p).len + 1), \\\n    ((p).len = strlen((p).pwp->pw_comment)), \\\n    strcpy((p).pws.pw_comment, (p).pwp->pw_comment), \\\n    ((p).pws.pw_gecos = (p).pws.pw_comment + (p).len + 1), \\\n    ((p).len = strlen((p).pwp->pw_gecos)), \\\n    strcpy((p).pws.pw_gecos, (p).pwp->pw_gecos), \\\n    ((p).pws.pw_dir = (p).pws.pw_comment + (p).len + 1), \\\n    ((p).len = strlen((p).pwp->pw_dir)), \\\n    strcpy((p).pws.pw_dir, (p).pwp->pw_dir), \\\n    ((p).pws.pw_shell = (p).pws.pw_dir + (p).len + 1), \\\n    ((p).len = strlen((p).pwp->pw_shell)), \\\n    strcpy((p).pws.pw_shell, (p).pwp->pw_shell), \\\n    ((p).pwp = &(p).pws), \\\n    0 )\n#endif\n# define _XGetpwuid(u,p) \\\n( (_Xos_processLock), \\\n  (((p).pwp = getpwuid((u))) ? _Xpw_copyPasswd(p), 0 : 0), \\\n  (_Xos_processUnlock), \\\n  (p).pwp )\n# define _XGetpwnam(u,p) \\\n( (_Xos_processLock), \\\n  (((p).pwp = getpwnam((u))) ? _Xpw_copyPasswd(p), 0 : 0), \\\n  (_Xos_processUnlock), \\\n  (p).pwp )\n\n#elif !defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(__APPLE__)\n# define X_NEEDS_PWPARAMS\ntypedef struct {\n  struct passwd pws;\n  char pwbuf[X_LINE_MAX];\n} _Xgetpwparams;\n# if defined(_POSIX_REENTRANT_FUNCTIONS) || !defined(SVR4)\n#   define _XGetpwuid(u,p) \\\n((getpwuid_r((u),&(p).pws,(p).pwbuf,sizeof((p).pwbuf)) == -1) ? NULL : &(p).pws)\n#   define _XGetpwnam(u,p) \\\n((getpwnam_r((u),&(p).pws,(p).pwbuf,sizeof((p).pwbuf)) == -1) ? NULL : &(p).pws)\n# else /* SVR4 */\n#  define _XGetpwuid(u,p) \\\n((getpwuid_r((u),&(p).pws,(p).pwbuf,sizeof((p).pwbuf)) == NULL) ? NULL : &(p).pws)\n#  define _XGetpwnam(u,p) \\\n((getpwnam_r((u),&(p).pws,(p).pwbuf,sizeof((p).pwbuf)) == NULL) ? NULL : &(p).pws)\n# endif /* SVR4 */\n\n#else /* _POSIX_THREAD_SAFE_FUNCTIONS */\n# define X_NEEDS_PWPARAMS\ntypedef struct {\n  struct passwd pws;\n  char pwbuf[X_LINE_MAX];\n  struct passwd* pwp;\n} _Xgetpwparams;\ntypedef int _Xgetpwret;\n# define _XGetpwuid(u,p) \\\n((getpwuid_r((u),&(p).pws,(p).pwbuf,sizeof((p).pwbuf),&(p).pwp) == 0) ? \\\n (p).pwp : NULL)\n# define _XGetpwnam(u,p) \\\n((getpwnam_r((u),&(p).pws,(p).pwbuf,sizeof((p).pwbuf),&(p).pwp) == 0) ? \\\n (p).pwp : NULL)\n#endif /* X_INCLUDE_PWD_H */\n\n#if defined(X_INCLUDE_PWD_H) && !defined(_XOS_INCLUDED_PWD_H)\n# define _XOS_INCLUDED_PWD_H\n#endif\n\n\n/***** <netdb.h> wrappers *****/\n\n/*\n * Effective prototypes for <netdb.h> wrappers:\n *\n * NOTE: On systems lacking the appropriate _r functions Gethostbyname(),\n *\tGethostbyaddr(), and Getservbyname() do NOT copy the host or\n *\tprotocol lists!\n *\n * #define X_INCLUDE_NETDB_H\n * #define XOS_USE_..._LOCKING\n * #include <X11/Xos_r.h>\n *\n * typedef ... _Xgethostbynameparams;\n * typedef ... _Xgetservbynameparams;\n *\n * struct hostent* _XGethostbyname(const char* name,_Xgethostbynameparams);\n * struct hostent* _XGethostbyaddr(const char* addr, int len, int type,\n *\t\t\t\t   _Xgethostbynameparams);\n * struct servent* _XGetservbyname(const char* name, const char* proto,\n *\t\t\t\t _Xgetservbynameparams);\n */\n\n#undef XTHREADS_NEEDS_BYNAMEPARAMS\n#if defined(X_INCLUDE_NETDB_H) && !defined(_XOS_INCLUDED_NETDB_H) \\\n    && !defined(WIN32)\n# include <netdb.h>\n# if defined(XUSE_MTSAFE_API) || defined(XUSE_MTSAFE_NETDBAPI)\n#  define XOS_USE_MTSAFE_NETDBAPI 1\n# endif\n#endif\n\n#if !defined(X_INCLUDE_NETDB_H) || defined(_XOS_INCLUDED_NETDB_H)\n/* Do nothing. */\n\n#elif !defined(XTHREADS) && !defined(X_FORCE_USE_MTSAFE_API)\n/* Use regular, unsafe API. */\ntypedef int _Xgethostbynameparams; /* dummy */\ntypedef int _Xgetservbynameparams; /* dummy */\n# define _XGethostbyname(h,hp)\t\tgethostbyname((h))\n# define _XGethostbyaddr(a,al,t,hp)\tgethostbyaddr((a),(al),(t))\n# define _XGetservbyname(s,p,sp)\tgetservbyname((s),(p))\n\n#elif !defined(XOS_USE_MTSAFE_NETDBAPI) || defined(XNO_MTSAFE_NETDBAPI)\n/* WARNING:  The h_addr_list and s_aliases values are *not* copied! */\n\n#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__DragonFly__)\n#include <sys/param.h>\n#endif\n\ntypedef struct {\n  struct hostent hent;\n  char           h_name[MAXHOSTNAMELEN];\n  struct hostent *hptr;\n} _Xgethostbynameparams;\ntypedef struct {\n  struct servent sent;\n  char           s_name[255];\n  char\t\t s_proto[255];\n  struct servent *sptr;\n} _Xgetservbynameparams;\n\n# define XTHREADS_NEEDS_BYNAMEPARAMS\n\n# define _Xg_copyHostent(hp) \\\n   (memcpy(&(hp).hent, (hp).hptr, sizeof(struct hostent)), \\\n    strcpy((hp).h_name, (hp).hptr->h_name), \\\n    ((hp).hent.h_name = (hp).h_name), \\\n    ((hp).hptr = &(hp).hent), \\\n     0 )\n# define _Xg_copyServent(sp) \\\n   (memcpy(&(sp).sent, (sp).sptr, sizeof(struct servent)), \\\n    strcpy((sp).s_name, (sp).sptr->s_name), \\\n    ((sp).sent.s_name = (sp).s_name), \\\n    strcpy((sp).s_proto, (sp).sptr->s_proto), \\\n    ((sp).sent.s_proto = (sp).s_proto), \\\n    ((sp).sptr = &(sp).sent), \\\n    0 )\n# define _XGethostbyname(h,hp) \\\n   ((_Xos_processLock), \\\n    (((hp).hptr = gethostbyname((h))) ? _Xg_copyHostent(hp) : 0), \\\n    (_Xos_processUnlock), \\\n    (hp).hptr )\n# define _XGethostbyaddr(a,al,t,hp) \\\n   ((_Xos_processLock), \\\n    (((hp).hptr = gethostbyaddr((a),(al),(t))) ? _Xg_copyHostent(hp) : 0), \\\n    (_Xos_processUnlock), \\\n    (hp).hptr )\n# define _XGetservbyname(s,p,sp) \\\n   ((_Xos_processLock), \\\n    (((sp).sptr = getservbyname((s),(p))) ? _Xg_copyServent(sp) : 0), \\\n    (_Xos_processUnlock), \\\n    (sp).sptr )\n\n#elif defined(XUSE_NETDB_R_API)\n/*\n * POSIX does not specify _r equivalents for <netdb.h> API, but some\n * vendors provide them anyway.  Use them only when explicitly asked.\n */\n# ifdef _POSIX_REENTRANT_FUNCTIONS\n#  ifndef _POSIX_THREAD_SAFE_FUNCTIONS\n#  endif\n# endif\n# ifdef _POSIX_THREAD_SAFE_FUNCTIONS\n#  define X_POSIX_THREAD_SAFE_FUNCTIONS 1\n# endif\n\n# define XTHREADS_NEEDS_BYNAMEPARAMS\n\n# ifndef X_POSIX_THREAD_SAFE_FUNCTIONS\ntypedef struct {\n    struct hostent      hent;\n    char                hbuf[X_LINE_MAX];\n    int                 herr;\n} _Xgethostbynameparams;\ntypedef struct {\n    struct servent      sent;\n    char                sbuf[X_LINE_MAX];\n} _Xgetservbynameparams;\n#  define _XGethostbyname(h,hp) \\\n  gethostbyname_r((h),&(hp).hent,(hp).hbuf,sizeof((hp).hbuf),&(hp).herr)\n#  define _XGethostbyaddr(a,al,t,hp) \\\n  gethostbyaddr_r((a),(al),(t),&(hp).hent,(hp).hbuf,sizeof((hp).hbuf),&(hp).herr)\n#  define _XGetservbyname(s,p,sp) \\\n  getservbyname_r((s),(p),&(sp).sent,(sp).sbuf,sizeof((sp).sbuf))\n# else\ntypedef struct {\n  struct hostent      hent;\n  struct hostent_data hdata;\n} _Xgethostbynameparams;\ntypedef struct {\n  struct servent      sent;\n  struct servent_data sdata;\n} _Xgetservbynameparams;\n#  define _XGethostbyname(h,hp) \\\n  (bzero((char*)&(hp).hdata,sizeof((hp).hdata)),\t\\\n   ((gethostbyname_r((h),&(hp).hent,&(hp).hdata) == -1) ? NULL : &(hp).hent))\n#  define _XGethostbyaddr(a,al,t,hp) \\\n  (bzero((char*)&(hp).hdata,sizeof((hp).hdata)),\t\\\n   ((gethostbyaddr_r((a),(al),(t),&(hp).hent,&(hp).hdata) == -1) ? NULL : &(hp).hent))\n#  define _XGetservbyname(s,p,sp) \\\n  (bzero((char*)&(sp).sdata,sizeof((sp).sdata)),\t\\\n   ((getservbyname_r((s),(p),&(sp).sent,&(sp).sdata) == -1) ? NULL : &(sp).sent) )\n# endif\n# ifdef X_POSIX_THREAD_SAFE_FUNCTIONS\n#  undef X_POSIX_THREAD_SAFE_FUNCTIONS\n# endif\n\n#else\n/* The regular API is assumed to be MT-safe under POSIX. */\ntypedef int _Xgethostbynameparams; /* dummy */\ntypedef int _Xgetservbynameparams; /* dummy */\n# define _XGethostbyname(h,hp)\t\tgethostbyname((h))\n# define _XGethostbyaddr(a,al,t,hp)\tgethostbyaddr((a),(al),(t))\n# define _XGetservbyname(s,p,sp)\tgetservbyname((s),(p))\n#endif /* X_INCLUDE_NETDB_H */\n\n#if defined(X_INCLUDE_NETDB_H) && !defined(_XOS_INCLUDED_NETDB_H)\n# define _XOS_INCLUDED_NETDB_H\n#endif\n\n\n/***** <dirent.h> wrappers *****/\n\n/*\n * Effective prototypes for <dirent.h> wrappers:\n *\n * #define X_INCLUDE_DIRENT_H\n * #define XOS_USE_..._LOCKING\n * #include <X11/Xos_r.h>\n *\n * typedef ... _Xreaddirparams;\n *\n * struct dirent *_XReaddir(DIR *dir_pointer, _Xreaddirparams);\n */\n\n#if defined(X_INCLUDE_DIRENT_H) && !defined(_XOS_INCLUDED_DIRENT_H)\n# include <sys/types.h>\n# if !defined(X_NOT_POSIX) || defined(SYSV)\n#  include <dirent.h>\n# else\n#  include <sys/dir.h>\n#  ifndef dirent\n#   define dirent direct\n#  endif\n# endif\n# if defined(XUSE_MTSAFE_API) || defined(XUSE_MTSAFE_DIRENTAPI)\n#  define XOS_USE_MTSAFE_DIRENTAPI 1\n# endif\n#endif\n\n#if !defined(X_INCLUDE_DIRENT_H) || defined(_XOS_INCLUDED_DIRENT_H)\n/* Do nothing. */\n\n#elif !defined(XTHREADS) && !defined(X_FORCE_USE_MTSAFE_API)\n/* Use regular, unsafe API. */\ntypedef int _Xreaddirparams;\t/* dummy */\n# define _XReaddir(d,p)\treaddir(d)\n\n#elif !defined(XOS_USE_MTSAFE_DIRENTAPI) || defined(XNO_MTSAFE_DIRENTAPI)\n/* Systems with thread support but no _r API. */\ntypedef struct {\n  struct dirent *result;\n  struct dirent dir_entry;\n# ifdef _POSIX_PATH_MAX\n  char buf[_POSIX_PATH_MAX];\n# elif defined(NAME_MAX)\n  char buf[NAME_MAX];\n# else\n  char buf[255];\n# endif\n} _Xreaddirparams;\n\n# define _XReaddir(d,p)\t\\\n ( (_Xos_processLock),\t\t\t\t\t\t \\\n   (((p).result = readdir((d))) ?\t\t\t\t \\\n    (memcpy(&((p).dir_entry), (p).result, (p).result->d_reclen), \\\n     ((p).result = &(p).dir_entry), 0) :\t\t\t \\\n    0),\t\t\t\t\t\t\t\t \\\n   (_Xos_processUnlock),\t\t\t\t\t \\\n   (p).result )\n\n#else\ntypedef struct {\n  struct dirent *result;\n  struct dirent dir_entry;\n# ifdef _POSIX_PATH_MAX\n  char buf[_POSIX_PATH_MAX];\n# elif defined(NAME_MAX)\n  char buf[NAME_MAX];\n# else\n  char buf[255];\n# endif\n} _Xreaddirparams;\n\n# if defined(_POSIX_THREAD_SAFE_FUNCTIONS) || defined(__APPLE__)\n/* POSIX final API, returns (int)0 on success. */\n#  define _XReaddir(d,p)\t\t\t\t\t\t\\\n    (readdir_r((d), &((p).dir_entry), &((p).result)) ? NULL : (p).result)\n# elif defined(_POSIX_REENTRANT_FUNCTIONS)\n/* POSIX draft API, returns (int)0 on success. */\n#  define _XReaddir(d,p)\t\\\n    (readdir_r((d),&((p).dir_entry)) ? NULL : &((p).dir_entry))\n# elif defined(SVR4)\n/* Pre-POSIX API, returns non-NULL on success. */\n#  define _XReaddir(d,p)\t(readdir_r((d), &(p).dir_entry))\n# else\n/* We have no idea what is going on.  Fake it all using process locks. */\n#  define _XReaddir(d,p)\t\\\n    ( (_Xos_processLock),\t\t\t\t\t\t\\\n      (((p).result = readdir((d))) ?\t\t\t\t\t\\\n       (memcpy(&((p).dir_entry), (p).result, (p).result->d_reclen),\t\\\n\t((p).result = &(p).dir_entry), 0) :\t\t\t\t\\\n       0),\t\t\t\t\t\t\t\t\\\n      (_Xos_processUnlock),\t\t\t\t\t\t\\\n      (p).result )\n# endif\n#endif /* X_INCLUDE_DIRENT_H */\n\n#if defined(X_INCLUDE_DIRENT_H) && !defined(_XOS_INCLUDED_DIRENT_H)\n# define _XOS_INCLUDED_DIRENT_H\n#endif\n\n\n/***** <unistd.h> wrappers *****/\n\n/*\n * Effective prototypes for <unistd.h> wrappers:\n *\n * #define X_INCLUDE_UNISTD_H\n * #define XOS_USE_..._LOCKING\n * #include <X11/Xos_r.h>\n *\n * typedef ... _Xgetloginparams;\n * typedef ... _Xttynameparams;\n *\n * char *_XGetlogin(_Xgetloginparams);\n * char *_XTtyname(int, _Xttynameparams);\n */\n\n#if defined(X_INCLUDE_UNISTD_H) && !defined(_XOS_INCLUDED_UNISTD_H)\n/* <unistd.h> already included by <X11/Xos.h> */\n# if defined(XUSE_MTSAFE_API) || defined(XUSE_MTSAFE_UNISTDAPI)\n#  define XOS_USE_MTSAFE_UNISTDAPI 1\n# endif\n#endif\n\n#if !defined(X_INCLUDE_UNISTD_H) || defined(_XOS_INCLUDED_UNISTD_H)\n/* Do nothing. */\n\n#elif !defined(XTHREADS) && !defined(X_FORCE_USE_MTSAFE_API)\n/* Use regular, unsafe API. */\ntypedef int _Xgetloginparams;\t/* dummy */\ntypedef int _Xttynameparams;\t/* dummy */\n# define _XGetlogin(p)\tgetlogin()\n# define _XTtyname(f)\tttyname((f))\n\n#elif !defined(XOS_USE_MTSAFE_UNISTDAPI) || defined(XNO_MTSAFE_UNISTDAPI)\n/* Systems with thread support but no _r API. */\ntypedef struct {\n  char *result;\n# if defined(MAXLOGNAME)\n  char buf[MAXLOGNAME];\n# elif defined(LOGIN_NAME_MAX)\n  char buf[LOGIN_NAME_MAX];\n# else\n  char buf[64];\n# endif\n} _Xgetloginparams;\ntypedef struct {\n  char *result;\n# ifdef TTY_NAME_MAX\n  char buf[TTY_NAME_MAX];\n# elif defined(_POSIX_TTY_NAME_MAX)\n  char buf[_POSIX_TTY_NAME_MAX];\n# elif defined(_POSIX_PATH_MAX)\n  char buf[_POSIX_PATH_MAX];\n# else\n  char buf[256];\n# endif\n} _Xttynameparams;\n\n# define _XGetlogin(p) \\\n ( (_Xos_processLock), \\\n   (((p).result = getlogin()) ? \\\n    (strncpy((p).buf, (p).result, sizeof((p).buf)), \\\n     ((p).buf[sizeof((p).buf)-1] = '\\0'), \\\n     ((p).result = (p).buf), 0) : 0), \\\n   (_Xos_processUnlock), \\\n   (p).result )\n#define _XTtyname(f,p) \\\n ( (_Xos_processLock), \\\n   (((p).result = ttyname(f)) ? \\\n    (strncpy((p).buf, (p).result, sizeof((p).buf)), \\\n     ((p).buf[sizeof((p).buf)-1] = '\\0'), \\\n     ((p).result = (p).buf), 0) : 0), \\\n   (_Xos_processUnlock), \\\n   (p).result )\n\n#elif defined(_POSIX_THREAD_SAFE_FUNCTIONS) || defined(_POSIX_REENTRANT_FUNCTIONS)\n/* POSIX API.\n *\n * extern int getlogin_r(char *, size_t);\n * extern int ttyname_r(int, char *, size_t);\n */\ntypedef struct {\n# if defined(MAXLOGNAME)\n  char buf[MAXLOGNAME];\n# elif defined(LOGIN_NAME_MAX)\n  char buf[LOGIN_NAME_MAX];\n# else\n  char buf[64];\n# endif\n} _Xgetloginparams;\ntypedef struct {\n# ifdef TTY_NAME_MAX\n  char buf[TTY_NAME_MAX];\n# elif defined(_POSIX_TTY_NAME_MAX)\n  char buf[_POSIX_TTY_NAME_MAX];\n# elif defined(_POSIX_PATH_MAX)\n  char buf[_POSIX_PATH_MAX];\n# else\n  char buf[256];\n# endif\n} _Xttynameparams;\n\n# define _XGetlogin(p)\t(getlogin_r((p).buf, sizeof((p).buf)) ? NULL : (p).buf)\n# define _XTtyname(f,p)\t\\\n\t(ttyname_r((f), (p).buf, sizeof((p).buf)) ? NULL : (p).buf)\n\n#else\n/* Pre-POSIX API.\n *\n * extern char *getlogin_r(char *, size_t);\n * extern char *ttyname_r(int, char *, size_t);\n */\ntypedef struct {\n# if defined(MAXLOGNAME)\n  char buf[MAXLOGNAME];\n# elif defined(LOGIN_NAME_MAX)\n  char buf[LOGIN_NAME_MAX];\n# else\n  char buf[64];\n# endif\n} _Xgetloginparams;\ntypedef struct {\n# ifdef TTY_NAME_MAX\n  char buf[TTY_NAME_MAX];\n# elif defined(_POSIX_TTY_NAME_MAX)\n  char buf[_POSIX_TTY_NAME_MAX];\n# elif defined(_POSIX_PATH_MAX)\n  char buf[_POSIX_PATH_MAX];\n# else\n  char buf[256];\n# endif\n} _Xttynameparams;\n\n# define _XGetlogin(p)\tgetlogin_r((p).buf, sizeof((p).buf))\n# define _XTtyname(f,p)\tttyname_r((f), (p).buf, sizeof((p).buf))\n#endif /* X_INCLUDE_UNISTD_H */\n\n#if defined(X_INCLUDE_UNISTD_H) && !defined(_XOS_INCLUDED_UNISTD_H)\n# define _XOS_INCLUDED_UNISTD_H\n#endif\n\n\n/***** <string.h> wrappers *****/\n\n/*\n * Effective prototypes for <string.h> wrappers:\n *\n * #define X_INCLUDE_STRING_H\n * #define XOS_USE_..._LOCKING\n * #include <X11/Xos_r.h>\n *\n * typedef ... _Xstrtokparams;\n *\n * char *_XStrtok(char *, const char*, _Xstrtokparams);\n */\n\n#if defined(X_INCLUDE_STRING_H) && !defined(_XOS_INCLUDED_STRING_H)\n/* <string.h> has already been included by <X11/Xos.h> */\n# if defined(XUSE_MTSAFE_API) || defined(XUSE_MTSAFE_STRINGAPI)\n#  define XOS_USE_MTSAFE_STRINGAPI 1\n# endif\n#endif\n\n#if !defined(X_INCLUDE_STRING_H) || defined(_XOS_INCLUDED_STRING_H)\n/* Do nothing. */\n\n#elif !defined(XTHREADS) && !defined(X_FORCE_USE_MTSAFE_API)\n/* Use regular, unsafe API. */\ntypedef int _Xstrtokparams;\t/* dummy */\n# define _XStrtok(s1,s2,p) \\\n ( p = 0, (void)p, strtok((s1),(s2)) )\n\n#elif !defined(XOS_USE_MTSAFE_STRINGAPI) || defined(XNO_MTSAFE_STRINGAPI)\n/* Systems with thread support but no _r API. */\ntypedef char *_Xstrtokparams;\n# define _XStrtok(s1,s2,p) \\\n ( (_Xos_processLock), \\\n   ((p) = strtok((s1),(s2))), \\\n   (_Xos_processUnlock), \\\n   (p) )\n\n#else\n/* POSIX or pre-POSIX API. */\ntypedef char * _Xstrtokparams;\n# define _XStrtok(s1,s2,p)\tstrtok_r((s1),(s2),&(p))\n#endif /* X_INCLUDE_STRING_H */\n\n\n/***** <time.h> wrappers *****/\n\n/*\n * Effective prototypes for <time.h> wrappers:\n *\n * #define X_INCLUDE_TIME_H\n * #define XOS_USE_..._LOCKING\n * #include <X11/Xos_r.h>\n *\n * typedef ... _Xatimeparams;\n * typedef ... _Xctimeparams;\n * typedef ... _Xgtimeparams;\n * typedef ... _Xltimeparams;\n *\n * char *_XAsctime(const struct tm *, _Xatimeparams);\n * char *_XCtime(const time_t *, _Xctimeparams);\n * struct tm *_XGmtime(const time_t *, _Xgtimeparams);\n * struct tm *_XLocaltime(const time_t *, _Xltimeparams);\n */\n\n#if defined(X_INCLUDE_TIME_H) && !defined(_XOS_INCLUDED_TIME_H)\n# include <time.h>\n# if defined(XUSE_MTSAFE_API) || defined(XUSE_MTSAFE_TIMEAPI)\n#  define XOS_USE_MTSAFE_TIMEAPI 1\n# endif\n#endif\n\n#if !defined(X_INCLUDE_TIME_H) || defined(_XOS_INCLUDED_TIME_H)\n/* Do nothing. */\n\n#elif !defined(XTHREADS) && !defined(X_FORCE_USE_MTSAFE_API)\n/* Use regular, unsafe API. */\ntypedef int _Xatimeparams;\t/* dummy */\n# define _XAsctime(t,p)\t\tasctime((t))\ntypedef int _Xctimeparams;\t/* dummy */\n# define _XCtime(t,p)\t\tctime((t))\ntypedef int _Xgtimeparams;\t/* dummy */\n# define _XGmtime(t,p)\t\tgmtime((t))\ntypedef int _Xltimeparams;\t/* dummy */\n# define _XLocaltime(t,p)\tlocaltime((t))\n\n#elif !defined(XOS_USE_MTSAFE_TIMEAPI) || defined(XNO_MTSAFE_TIMEAPI)\n/* Systems with thread support but no _r API. */\ntypedef struct {\n# ifdef TIMELEN\n  char buf[TIMELEN];\n# else\n  char buf[26];\n# endif\n  char *result;\n} _Xctimeparams, _Xatimeparams;\ntypedef struct {\n  struct tm buf;\n  struct tm *result;\n} _Xgtimeparams, _Xltimeparams;\n# define _XAsctime(t,p) \\\n ( (_Xos_processLock), \\\n   (((p).result = asctime((t))) ? \\\n    (strncpy((p).buf, (p).result, sizeof((p).buf)), (p).result = &(p).buf) : \\\n    0), \\\n   (_Xos_processUnlock), \\\n   (p).result )\n# define _XCtime(t,p) \\\n ( (_Xos_processLock), \\\n   (((p).result = ctime((t))) ? \\\n    (strncpy((p).buf, (p).result, sizeof((p).buf)), (p).result = &(p).buf) : \\\n    0), \\\n   (_Xos_processUnlock), \\\n   (p).result )\n# define _XGmtime(t,p) \\\n ( (_Xos_processLock), \\\n   (((p).result = gmtime(t)) ? \\\n    (memcpy(&(p).buf, (p).result, sizeof((p).buf)), (p).result = &(p).buf) : \\\n    0), \\\n   (_Xos_processUnlock), \\\n   (p).result )\n# define _XLocaltime(t,p) \\\n ( (_Xos_processLock), \\\n   (((p).result = localtime(t)) ? \\\n    (memcpy(&(p).buf, (p).result, sizeof((p).buf)), (p).result = &(p).buf) : \\\n    0), \\\n   (_Xos_processUnlock), \\\n   (p).result )\n\n#elif !defined(_POSIX_THREAD_SAFE_FUNCTIONS) &&  defined(hpV4)\n/* Returns (int)0 on success.\n *\n * extern int asctime_r(const struct tm *timeptr, char *buffer, int buflen);\n * extern int ctime_r(const time_t *timer, char *buffer, int buflen);\n * extern int gmtime_r(const time_t *timer, struct tm *result);\n * extern int localtime_r(const time_t *timer, struct tm *result);\n */\n# ifdef TIMELEN\ntypedef char _Xatimeparams[TIMELEN];\ntypedef char _Xctimeparams[TIMELEN];\n# else\ntypedef char _Xatimeparams[26];\ntypedef char _Xctimeparams[26];\n# endif\ntypedef struct tm _Xgtimeparams;\ntypedef struct tm _Xltimeparams;\n# define _XAsctime(t,p)\t\t(asctime_r((t),(p),sizeof((p))) ? NULL : (p))\n# define _XCtime(t,p)\t\t(ctime_r((t),(p),sizeof((p))) ? NULL : (p))\n# define _XGmtime(t,p)\t\t(gmtime_r((t),&(p)) ? NULL : &(p))\n# define _XLocaltime(t,p)\t(localtime_r((t),&(p)) ? NULL : &(p))\n\n#elif !defined(_POSIX_THREAD_SAFE_FUNCTIONS) && defined(__sun)\n/* Returns NULL on failure.  Solaris 2.5\n *\n * extern char *asctime_r(const struct tm *tm,char *buf, int buflen);\n * extern char *ctime_r(const time_t *clock, char *buf, int buflen);\n * extern struct tm *gmtime_r(const time_t *clock, struct tm *res);\n * extern struct tm *localtime_r(const time_t *clock, struct tm *res);\n */\n# ifdef TIMELEN\ntypedef char _Xatimeparams[TIMELEN];\ntypedef char _Xctimeparams[TIMELEN];\n# else\ntypedef char _Xatimeparams[26];\ntypedef char _Xctimeparams[26];\n# endif\ntypedef struct tm _Xgtimeparams;\ntypedef struct tm _Xltimeparams;\n# define _XAsctime(t,p)\t\tasctime_r((t),(p),sizeof((p)))\n# define _XCtime(t,p)\t\tctime_r((t),(p),sizeof((p)))\n# define _XGmtime(t,p)\t\tgmtime_r((t),&(p))\n# define _XLocaltime(t,p)\tlocaltime_r((t),&(p))\n\n#else /* defined(_POSIX_THREAD_SAFE_FUNCTIONS) */\n/* POSIX final API.\n * extern char *asctime_r(const struct tm *timeptr, char *buffer);\n * extern char *ctime_r(const time_t *timer, char *buffer);\n * extern struct tm *gmtime_r(const time_t *timer, struct tm *result);\n * extern struct tm *localtime_r(const time_t *timer, struct tm *result);\n */\n# ifdef TIMELEN\ntypedef char _Xatimeparams[TIMELEN];\ntypedef char _Xctimeparams[TIMELEN];\n# else\ntypedef char _Xatimeparams[26];\ntypedef char _Xctimeparams[26];\n# endif\ntypedef struct tm _Xgtimeparams;\ntypedef struct tm _Xltimeparams;\n# define _XAsctime(t,p)\t\tasctime_r((t),(p))\n# define _XCtime(t,p)\t\tctime_r((t),(p))\n# define _XGmtime(t,p)\t\tgmtime_r((t),&(p))\n# define _XLocaltime(t,p)\tlocaltime_r((t),&(p))\n#endif /* X_INCLUDE_TIME_H */\n\n#if defined(X_INCLUDE_TIME_H) && !defined(_XOS_INCLUDED_TIME_H)\n# define _XOS_INCLUDED_TIME_H\n#endif\n\n\n/***** <grp.h> wrappers *****/\n\n/*\n * Effective prototypes for <grp.h> wrappers:\n *\n * NOTE: On systems lacking appropriate _r functions Getgrgid() and\n *\tGetgrnam() do NOT copy the list of group members!\n *\n * Remember that fgetgrent(), setgrent(), getgrent(), and endgrent()\n * are not included in POSIX.\n *\n * #define X_INCLUDE_GRP_H\n * #define XOS_USE_..._LOCKING\n * #include <X11/Xos_r.h>\n *\n * typedef ... _Xgetgrparams;\n *\n * struct group *_XGetgrgid(gid_t, _Xgetgrparams);\n * struct group *_XGetgrnam(const char *, _Xgetgrparams);\n */\n\n#if defined(X_INCLUDE_GRP_H) && !defined(_XOS_INCLUDED_GRP_H)\n# include <grp.h>\n# if defined(XUSE_MTSAFE_API) || defined(XUSE_MTSAFE_GRPAPI)\n#  define XOS_USE_MTSAFE_GRPAPI 1\n# endif\n#endif\n\n#if !defined(X_INCLUDE_GRP_H) || defined(_XOS_INCLUDED_GRP_H)\n/* Do nothing. */\n\n#elif !defined(XTHREADS) && !defined(X_FORCE_USE_MTSAFE_API)\n/* Use regular, unsafe API. */\ntypedef int _Xgetgrparams;\t/* dummy */\n#define _XGetgrgid(g,p)\tgetgrgid((g))\n#define _XGetgrnam(n,p)\tgetgrnam((n))\n\n#elif !defined(XOS_USE_MTSAFE_GRPAPI) || defined(XNO_MTSAFE_GRPAPI)\n/* Systems with thread support but no _r API.  UnixWare 2.0. */\ntypedef struct {\n  struct group grp;\n  char buf[X_LINE_MAX];\t/* Should be sysconf(_SC_GETGR_R_SIZE_MAX)? */\n  struct group *pgrp;\n  size_t len;\n} _Xgetgrparams;\n#ifdef SVR4\n/* Copy the gr_passwd field too. */\n# define _Xgrp_copyGroup(p) \\\n ( memcpy(&(p).grp, (p).pgrp, sizeof(struct group)), \\\n   ((p).grp.gr_name = (p).buf), \\\n   ((p).len = strlen((p).pgrp->gr_name)), \\\n   strcpy((p).grp.gr_name, (p).pgrp->gr_name), \\\n   ((p).grp.gr_passwd = (p).grp.gr_name + (p).len + 1), \\\n   ((p).pgrp = &(p).grp), \\\n   0 )\n#else\n# define _Xgrp_copyGroup(p) \\\n ( memcpy(&(p).grp, (p).pgrp, sizeof(struct group)), \\\n   ((p).grp.gr_name = (p).buf), \\\n   strcpy((p).grp.gr_name, (p).pgrp->gr_name), \\\n   ((p).pgrp = &(p).grp), \\\n   0 )\n#endif\n#define _XGetgrgid(g,p) \\\n ( (_Xos_processLock), \\\n   (((p).pgrp = getgrgid((g))) ? _Xgrp_copyGroup(p) : 0), \\\n   (_Xos_processUnlock), \\\n   (p).pgrp )\n#define _XGetgrnam(n,p) \\\n ( (_Xos_processLock), \\\n   (((p).pgrp = getgrnam((n))) ? _Xgrp_copyGroup(p) : 0), \\\n   (_Xos_processUnlock), \\\n   (p).pgrp )\n\n#elif !defined(_POSIX_THREAD_SAFE_FUNCTIONS) && defined(__sun)\n/* Non-POSIX API.  Solaris.\n *\n * extern struct group *getgrgid_r(gid_t, struct group *, char *, int);\n * extern struct group *getgrnam_r(const char *, struct group *, char *, int);\n */\ntypedef struct {\n  struct group grp;\n  char buf[X_LINE_MAX];\t/* Should be sysconf(_SC_GETGR_R_SIZE_MAX)? */\n} _Xgetgrparams;\n#define _XGetgrgid(g,p)\tgetgrgid_r((g), &(p).grp, (p).buf, sizeof((p).buf))\n#define _XGetgrnam(n,p)\tgetgrnam_r((n), &(p).grp, (p).buf, sizeof((p).buf))\n\n#elif !defined(_POSIX_THREAD_SAFE_FUNCTIONS)\n/* Non-POSIX API.\n * extern int getgrgid_r(gid_t, struct group *, char *, int);\n * extern int getgrnam_r(const char *, struct group *, char *, int);\n */\ntypedef struct {\n  struct group grp;\n  char buf[X_LINE_MAX];\t/* Should be sysconf(_SC_GETGR_R_SIZE_MAX)? */\n} _Xgetgrparams;\n#define _XGetgrgid(g,p)\t\\\n ((getgrgid_r((g), &(p).grp, (p).buf, sizeof((p).buf)) ? NULL : &(p).grp))\n#define _XGetgrnam(n,p)\t\\\n ((getgrnam_r((n), &(p).grp, (p).buf, sizeof((p).buf)) ? NULL : &(p).grp))\n\n#else\n/* POSIX final API.\n *\n * int getgrgid_r(gid_t, struct group *, char *, size_t, struct group **);\n * int getgrnam_r(const char *, struct group *, char *, size_t, struct group **);\n */\ntypedef struct {\n  struct group grp;\n  char buf[X_LINE_MAX];\t/* Should be sysconf(_SC_GETGR_R_SIZE_MAX)? */\n  struct group *result;\n} _Xgetgrparams;\n\n#define _XGetgrgid(g,p)\t\\\n ((getgrgid_r((g), &(p).grp, (p).buf, sizeof((p).buf), &(p).result) ? \\\n   NULL : (p).result))\n#define _XGetgrnam(n,p)\t\\\n ((getgrnam_r((n), &(p).grp, (p).buf, sizeof((p).buf), &(p).result) ? \\\n   NULL : (p).result))\n#endif\n\n#if defined(X_INCLUDE_GRP_H) && !defined(_XOS_INCLUDED_GRP_H)\n# define _XOS_INCLUDED_GRP_H\n#endif\n\n\n#ifdef __cplusplus\n}  /* Close scope of 'extern \"C\"' declaration which encloses file. */\n#endif\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/X11/Xosdefs.h",
    "content": "/*\n * O/S-dependent (mis)feature macro definitions\n *\nCopyright 1991, 1998  The Open Group\n\nPermission to use, copy, modify, distribute, and sell this software and its\ndocumentation for any purpose is hereby granted without fee, provided that\nthe above copyright notice appear in all copies and that both that\ncopyright notice and this permission notice appear in supporting\ndocumentation.\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE\nOPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN\nAN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\nCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\nExcept as contained in this notice, the name of The Open Group shall not be\nused in advertising or otherwise to promote the sale, use or other dealings\nin this Software without prior written authorization from The Open Group.\n */\n\n#ifndef _XOSDEFS_H_\n# define _XOSDEFS_H_\n\n/*\n * X_NOT_POSIX means does not have POSIX header files.  Lack of this\n * symbol does NOT mean that the POSIX environment is the default.\n * You may still have to define _POSIX_SOURCE to get it.\n */\n\n\n# ifdef _SCO_DS\n#  ifndef __SCO__\n#   define __SCO__\n#  endif\n# endif\n\n# ifdef __i386__\n#  ifdef SYSV\n#   if !defined(__SCO__) && \\\n\t!defined(__UNIXWARE__) && !defined(__sun)\n#    if !defined(_POSIX_SOURCE)\n#     define X_NOT_POSIX\n#    endif\n#   endif\n#  endif\n# endif\n\n# ifdef __sun\n/* Imake configs define SVR4 on Solaris, but cc & gcc only define __SVR4\n * This check allows non-Imake configured programs to build correctly.\n */\n#  if defined(__SVR4) && !defined(SVR4)\n#   define SVR4 1\n#  endif\n#  ifdef SVR4\n/* define this to whatever it needs to be */\n#   define X_POSIX_C_SOURCE 199300L\n#  endif\n# endif\n\n# ifdef WIN32\n#  ifndef _POSIX_\n#   define X_NOT_POSIX\n#  endif\n# endif\n\n\n# ifdef __APPLE__\n#  define NULL_NOT_ZERO\n\n/* Defining any of these will sanitize the namespace to JUST want is defined by\n * that particular standard.  If that happens, we don't get some expected\n * prototypes, typedefs, etc (like fd_mask).  We can define _DARWIN_C_SOURCE to\n * loosen our belts a tad.\n */\n#  if defined(_XOPEN_SOURCE) || defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE)\n#   ifndef _DARWIN_C_SOURCE\n#    define _DARWIN_C_SOURCE\n#   endif\n#  endif\n\n# endif\n\n# ifdef __GNU__\n#  ifndef PATH_MAX\n#   define PATH_MAX 4096\n#  endif\n#  ifndef MAXPATHLEN\n#   define MAXPATHLEN 4096\n#  endif\n# endif\n\n# if defined(__SCO__) || defined(__UNIXWARE__)\n#  ifndef PATH_MAX\n#   define PATH_MAX\t1024\n#  endif\n#  ifndef MAXPATHLEN\n#   define MAXPATHLEN\t1024\n#  endif\n# endif\n\n# if defined(__OpenBSD__) || defined(__NetBSD__) || defined(__FreeBSD__) \\\n\t|| defined(__APPLE__) || defined(__DragonFly__)\n#  ifndef CSRG_BASED\n#   define CSRG_BASED\n#  endif\n# endif\n\n#endif /* _XOSDEFS_H_ */\n\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/X11/Xpoll.h",
    "content": "/*\n\nCopyright 1994, 1998  The Open Group\n\nPermission to use, copy, modify, distribute, and sell this software and its\ndocumentation for any purpose is hereby granted without fee, provided that\nthe above copyright notice appear in all copies and that both that\ncopyright notice and this permission notice appear in supporting\ndocumentation.\n\nThe above copyright notice and this permission notice shall be included\nin all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\nOR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR\nOTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,\nARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\nOTHER DEALINGS IN THE SOFTWARE.\n\nExcept as contained in this notice, the name of The Open Group shall\nnot be used in advertising or otherwise to promote the sale, use or\nother dealings in this Software without prior written authorization\nfrom The Open Group.\n\n*/\n\n/*\n * Copyright © 2005 Daniel Stone\n * \n * Permission to use, copy, modify, distribute, and sell this software and its\n * documentation for any purpose is hereby granted without fee, provided that\n * the above copyright notice appear in all copies and that both that\n * copyright notice and this permission notice appear in supporting\n * documentation, and that the name of Daniel Stone not be used in advertising\n * or publicity pertaining to distribution of the software without specific,\n * written prior permission.  Daniel Stone makes no representations about the\n * suitability of this software for any purpose.  It is provided \"as is\"\n * without express or implied warranty.\n *\n * DANIEL STONE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING\n * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL\n * DANIEL STONE BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR\n * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER\n * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF\n * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n*/\n\n#ifndef _XPOLL_H_\n#define _XPOLL_H_\n\n#if !defined(WIN32) || defined(__CYGWIN__)\n\n#ifndef USE_POLL\n\n#include <X11/Xos.h>\n\n#include <sys/select.h>  /* Get the FD_* macros. */\n\n#include <X11/Xmd.h>\n\n#ifdef CSRG_BASED\n#include <sys/param.h>\n# if BSD < 199103\ntypedef long fd_mask;\n# endif\n#endif\n\n#if defined(FD_SETSIZE) && FD_SETSIZE < 512\n# define XFD_SETSIZE\tFD_SETSIZE\n#else\n# define XFD_SETSIZE\t512\n# ifndef FD_SETSIZE\n#  define FD_SETSIZE\tXFD_SETSIZE\n# endif\n#endif\n\n#ifndef NBBY\n#define NBBY\t8\t\t/* number of bits in a byte */\n#endif\n\n#ifndef NFDBITS\n#define NFDBITS (sizeof(fd_mask) * NBBY)\t/* bits per mask */\n#endif\n\n#ifndef howmany\n#define howmany(x,y)\t(((x)+((y)-1))/(y))\n#endif\n\n#if defined(BSD) && BSD < 198911 \ntypedef struct fd_set {\n\tfd_mask fds_bits[howmany(FD_SETSIZE, NFDBITS)];\n} fd_set;\n#endif\n\n# define Select(n,r,w,e,t) select(n,(fd_set*)r,(fd_set*)w,(fd_set*)e,(struct timeval*)t)\n\n#define __X_FDS_BITS __fds_bits\n\n#ifndef __FDS_BITS\n# define __FDS_BITS(p)  ((p)->__X_FDS_BITS)\n#endif\n\n#define __XFDS_BITS(p, n) (__FDS_BITS(p))[n]\n\n#ifndef FD_SET\n#define FD_SET(n, p)    (__XFDS_BITS(p, ((n)/NFDBITS)) |= ((fd_mask)1 << ((n) % NFDBITS)))\n#endif\n#ifndef FD_CLR\n#define FD_CLR(n, p)    (__XFDS_BITS((p), ((n)/NFDBITS)) &= ~((fd_mask)1 << ((n) % NFDBITS)))\n#endif\n#ifndef FD_ISSET\n#define FD_ISSET(n, p)  ((__XFDS_BITS((p), ((n)/NFDBITS))) & ((fd_mask)1 << ((n) % NFDBITS)))\n#endif\n#ifndef FD_ZERO\n#define FD_ZERO(p)      bzero((char *)(p), sizeof(*(p)))\n#endif\n\n/*\n * The howmany(FD_SETSIZE, NFDBITS) computes the number of elements in the\n * array. before accessing an element in the array we check it exists.\n * If it does not exist then the compiler discards the code to access it. \n */\n#define XFD_ANYSET(p) \\\n        ((howmany(FD_SETSIZE, NFDBITS) > 0 && (__XFDS_BITS(p, 0))) || \\\n        (howmany(FD_SETSIZE, NFDBITS) > 1 && (__XFDS_BITS(p, 1))) || \\\n        (howmany(FD_SETSIZE, NFDBITS) > 2 && (__XFDS_BITS(p, 2))) || \\\n        (howmany(FD_SETSIZE, NFDBITS) > 3 && (__XFDS_BITS(p, 3))) || \\\n        (howmany(FD_SETSIZE, NFDBITS) > 4 && (__XFDS_BITS(p, 4))) || \\\n        (howmany(FD_SETSIZE, NFDBITS) > 5 && (__XFDS_BITS(p, 5))) || \\\n        (howmany(FD_SETSIZE, NFDBITS) > 6 && (__XFDS_BITS(p, 6))) || \\\n        (howmany(FD_SETSIZE, NFDBITS) > 7 && (__XFDS_BITS(p, 7))) || \\\n        (howmany(FD_SETSIZE, NFDBITS) > 8 && (__XFDS_BITS(p, 8))) || \\\n        (howmany(FD_SETSIZE, NFDBITS) > 9 && (__XFDS_BITS(p, 9))) || \\\n        (howmany(FD_SETSIZE, NFDBITS) > 10 && (__XFDS_BITS(p, 10))) || \\\n        (howmany(FD_SETSIZE, NFDBITS) > 11 && (__XFDS_BITS(p, 11))) || \\\n        (howmany(FD_SETSIZE, NFDBITS) > 12 && (__XFDS_BITS(p, 12))) || \\\n        (howmany(FD_SETSIZE, NFDBITS) > 13 && (__XFDS_BITS(p, 13))) || \\\n        (howmany(FD_SETSIZE, NFDBITS) > 14 && (__XFDS_BITS(p, 14))) || \\\n        (howmany(FD_SETSIZE, NFDBITS) > 15 && (__XFDS_BITS(p, 15))))\n\n\n#define XFD_COPYSET(src,dst) { \\\n        int __i__; \\\n\t\tfor (__i__ = 0; __i__ < howmany(FD_SETSIZE, NFDBITS); __i__++) \\\n            __XFDS_BITS((dst), __i__) = __XFDS_BITS((src), __i__); \\\n        }\n#define XFD_ANDSET(dst,b1,b2) { \\\n        int __i__; \\\n        for (__i__ = 0; __i__ < howmany(FD_SETSIZE, NFDBITS); __i__++) \\\n            __XFDS_BITS((dst), __i__) = ((__XFDS_BITS((b1), __i__)) & (__XFDS_BITS((b2), __i__))); \\\n        }\n#define XFD_ORSET(dst,b1,b2) { \\\n        int __i__; \\\n        for (__i__ = 0; __i__ < howmany(FD_SETSIZE, NFDBITS); __i__++) \\\n\t\t__XFDS_BITS((dst), __i__) = ((__XFDS_BITS((b1), __i__)) | (__XFDS_BITS((b2), __i__))); \\\n        }        \n#define XFD_UNSET(dst,b1) { \\\n        int __i__; \\\n        for (__i__ = 0; __i__ < howmany(FD_SETSIZE, NFDBITS); __i__++) \\\n    \t\t__XFDS_BITS((dst), __i__) &= ~(__XFDS_BITS((b1), __i__)); \\\n        }\n\n#else /* USE_POLL */\n#include <sys/poll.h>\n#endif /* USE_POLL */\n\n#else /* WIN32 */\n\n#define XFD_SETSIZE\t512\n#ifndef FD_SETSIZE\n#define FD_SETSIZE\tXFD_SETSIZE\n#endif\n#include <X11/Xwinsock.h>\n\n#define Select(n,r,w,e,t) select(0,(fd_set*)r,(fd_set*)w,(fd_set*)e,(struct timeval*)t)\n\n#define XFD_SETCOUNT(p)\t(((fd_set FAR *)(p))->fd_count)\n#define XFD_FD(p,i) (((fd_set FAR *)(p))->fd_array[i])\n#define XFD_ANYSET(p)\tXFD_SETCOUNT(p)\n\n#define XFD_COPYSET(src,dst) { \\\n    u_int __i; \\\n    FD_ZERO(dst); \\\n    for (__i = 0; __i < XFD_SETCOUNT(src) ; __i++) { \\\n        XFD_FD(dst,__i) = XFD_FD(src,__i); \\\n    } \\\n    XFD_SETCOUNT(dst) = XFD_SETCOUNT(src); \\\n}\n\n#define XFD_ANDSET(dst,b1,b2) { \\\n    u_int __i; \\\n    FD_ZERO(dst); \\\n    for (__i = 0; __i < XFD_SETCOUNT(b1) ; __i++) { \\\n        if (FD_ISSET(XFD_FD(b1,__i), b2)) \\\n\t   FD_SET(XFD_FD(b1,__i), dst); \\\n    } \\\n}\n\n#define XFD_ORSET(dst,b1,b2) { \\\n    u_int __i; \\\n    if (dst != b1) XFD_COPYSET(b1,dst); \\\n    for (__i = 0; __i < XFD_SETCOUNT(b2) ; __i++) { \\\n        if (!FD_ISSET(XFD_FD(b2,__i), dst)) \\\n\t   FD_SET(XFD_FD(b2,__i), dst); \\\n    } \\\n}\n\n/* this one is really sub-optimal */\n#define XFD_UNSET(dst,b1) { \\\n    u_int __i; \\\n    for (__i = 0; __i < XFD_SETCOUNT(b1) ; __i++) { \\\n\tFD_CLR(XFD_FD(b1,__i), dst); \\\n    } \\\n}\n\n/* we have to pay the price of having an array here, unlike with bitmasks\n   calling twice FD_SET with the same fd is not transparent, so be careful */\n#undef FD_SET\n#define FD_SET(fd,set) do { \\\n    if (XFD_SETCOUNT(set) < FD_SETSIZE && !FD_ISSET(fd,set)) \\\n        XFD_FD(set,XFD_SETCOUNT(set)++)=(fd); \\\n} while(0)\n\n#define getdtablesize() FD_SETSIZE \n\n#endif /* WIN32 */\n\n#endif /* _XPOLL_H_ */\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/X11/Xproto.h",
    "content": "/* Definitions for the X window system used by server and c bindings */\n\n/*\n * This packet-construction scheme makes the following assumptions:\n *\n * 1. The compiler is able\n * to generate code which addresses one- and two-byte quantities.\n * In the worst case, this would be done with bit-fields.  If bit-fields\n * are used it may be necessary to reorder the request fields in this file,\n * depending on the order in which the machine assigns bit fields to\n * machine words.  There may also be a problem with sign extension,\n * as K+R specify that bitfields are always unsigned.\n *\n * 2. 2- and 4-byte fields in packet structures must be ordered by hand\n * such that they are naturally-aligned, so that no compiler will ever\n * insert padding bytes.\n *\n * 3. All packets are hand-padded to a multiple of 4 bytes, for\n * the same reason.\n */\n\n#ifndef XPROTO_H\n#define XPROTO_H\n\n/***********************************************************\n\nCopyright 1987, 1998  The Open Group\n\nPermission to use, copy, modify, distribute, and sell this software and its\ndocumentation for any purpose is hereby granted without fee, provided that\nthe above copyright notice appear in all copies and that both that\ncopyright notice and this permission notice appear in supporting\ndocumentation.\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE\nOPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN\nAN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\nCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\nExcept as contained in this notice, the name of The Open Group shall not be\nused in advertising or otherwise to promote the sale, use or other dealings\nin this Software without prior written authorization from The Open Group.\n\n\nCopyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.\n\n                        All Rights Reserved\n\nPermission to use, copy, modify, and distribute this software and its \ndocumentation for any purpose and without fee is hereby granted, \nprovided that the above copyright notice appear in all copies and that\nboth that copyright notice and this permission notice appear in \nsupporting documentation, and that the name of Digital not be\nused in advertising or publicity pertaining to distribution of the\nsoftware without specific, written prior permission.  \n\nDIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING\nALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL\nDIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR\nANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,\nWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,\nARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS\nSOFTWARE.\n\n******************************************************************/\n\n#include <X11/Xmd.h>\n#include <X11/Xprotostr.h>\n\n/*\n * Define constants for the sizes of the network packets.  The sz_ prefix is\n * used instead of something more descriptive so that the symbols are no more\n * than 32 characters in length (which causes problems for some compilers).\n */\n#define sz_xSegment 8\n#define sz_xPoint 4\n#define sz_xRectangle 8\n#define sz_xArc 12\n#define sz_xConnClientPrefix 12\n#define sz_xConnSetupPrefix 8\n#define sz_xConnSetup 32\n#define sz_xPixmapFormat 8\n#define sz_xDepth 8\n#define sz_xVisualType 24\n#define sz_xWindowRoot 40\n#define sz_xTimecoord 8\n#define sz_xHostEntry 4\n#define sz_xCharInfo 12\n#define sz_xFontProp 8\n#define sz_xTextElt 2\n#define sz_xColorItem 12\n#define sz_xrgb 8\n#define sz_xGenericReply 32\n#define sz_xGetWindowAttributesReply 44\n#define sz_xGetGeometryReply 32\n#define sz_xQueryTreeReply 32\n#define sz_xInternAtomReply 32\n#define sz_xGetAtomNameReply 32\n#define sz_xGetPropertyReply 32\n#define sz_xListPropertiesReply 32\n#define sz_xGetSelectionOwnerReply 32\n#define sz_xGrabPointerReply 32\n#define sz_xQueryPointerReply 32\n#define sz_xGetMotionEventsReply 32\n#define sz_xTranslateCoordsReply 32\n#define sz_xGetInputFocusReply 32\n#define sz_xQueryKeymapReply 40\n#define sz_xQueryFontReply 60\n#define sz_xQueryTextExtentsReply 32\n#define sz_xListFontsReply 32\n#define sz_xGetFontPathReply 32\n#define sz_xGetImageReply 32\n#define sz_xListInstalledColormapsReply 32\n#define sz_xAllocColorReply 32\n#define sz_xAllocNamedColorReply 32\n#define sz_xAllocColorCellsReply 32\n#define sz_xAllocColorPlanesReply 32\n#define sz_xQueryColorsReply 32\n#define sz_xLookupColorReply 32\n#define sz_xQueryBestSizeReply 32\n#define sz_xQueryExtensionReply 32\n#define sz_xListExtensionsReply 32\n#define sz_xSetMappingReply 32\n#define sz_xGetKeyboardControlReply 52\n#define sz_xGetPointerControlReply 32\n#define sz_xGetScreenSaverReply 32\n#define sz_xListHostsReply 32\n#define sz_xSetModifierMappingReply 32\n#define sz_xError 32\n#define sz_xEvent 32\n#define sz_xKeymapEvent 32\n#define sz_xReq 4\n#define sz_xResourceReq 8\n#define sz_xCreateWindowReq 32\n#define sz_xChangeWindowAttributesReq 12\n#define sz_xChangeSaveSetReq 8\n#define sz_xReparentWindowReq 16\n#define sz_xConfigureWindowReq 12\n#define sz_xCirculateWindowReq 8\n#define sz_xInternAtomReq 8\n#define sz_xChangePropertyReq 24\n#define sz_xDeletePropertyReq 12\n#define sz_xGetPropertyReq 24\n#define sz_xSetSelectionOwnerReq 16\n#define sz_xConvertSelectionReq 24\n#define sz_xSendEventReq 44\n#define sz_xGrabPointerReq 24\n#define sz_xGrabButtonReq 24\n#define sz_xUngrabButtonReq 12\n#define sz_xChangeActivePointerGrabReq 16\n#define sz_xGrabKeyboardReq 16\n#define sz_xGrabKeyReq 16\n#define sz_xUngrabKeyReq 12\n#define sz_xAllowEventsReq 8\n#define sz_xGetMotionEventsReq 16\n#define sz_xTranslateCoordsReq 16\n#define sz_xWarpPointerReq 24\n#define sz_xSetInputFocusReq 12\n#define sz_xOpenFontReq 12\n#define sz_xQueryTextExtentsReq 8\n#define sz_xListFontsReq 8\n#define sz_xSetFontPathReq 8\n#define sz_xCreatePixmapReq 16\n#define sz_xCreateGCReq 16\n#define sz_xChangeGCReq 12\n#define sz_xCopyGCReq 16\n#define sz_xSetDashesReq 12\n#define sz_xSetClipRectanglesReq 12\n#define sz_xCopyAreaReq 28\n#define sz_xCopyPlaneReq 32\n#define sz_xPolyPointReq 12\n#define sz_xPolySegmentReq 12\n#define sz_xFillPolyReq 16\n#define sz_xPutImageReq 24\n#define sz_xGetImageReq 20\n#define sz_xPolyTextReq 16\n#define sz_xImageTextReq 16\n#define sz_xCreateColormapReq 16\n#define sz_xCopyColormapAndFreeReq 12\n#define sz_xAllocColorReq 16\n#define sz_xAllocNamedColorReq 12\n#define sz_xAllocColorCellsReq 12\n#define sz_xAllocColorPlanesReq 16\n#define sz_xFreeColorsReq 12\n#define sz_xStoreColorsReq 8\n#define sz_xStoreNamedColorReq 16\n#define sz_xQueryColorsReq 8\n#define sz_xLookupColorReq 12\n#define sz_xCreateCursorReq 32\n#define sz_xCreateGlyphCursorReq 32\n#define sz_xRecolorCursorReq 20\n#define sz_xQueryBestSizeReq 12\n#define sz_xQueryExtensionReq 8\n#define sz_xChangeKeyboardControlReq 8\n#define sz_xBellReq 4\n#define sz_xChangePointerControlReq 12\n#define sz_xSetScreenSaverReq 12\n#define sz_xChangeHostsReq 8\n#define sz_xListHostsReq 4\n#define sz_xChangeModeReq 4\n#define sz_xRotatePropertiesReq 12\n#define sz_xReply 32\n#define sz_xGrabKeyboardReply 32\n#define sz_xListFontsWithInfoReply 60\n#define sz_xSetPointerMappingReply 32\n#define sz_xGetKeyboardMappingReply 32\n#define sz_xGetPointerMappingReply 32\n#define sz_xGetModifierMappingReply 32\n#define sz_xListFontsWithInfoReq 8\n#define sz_xPolyLineReq 12\n#define sz_xPolyArcReq 12\n#define sz_xPolyRectangleReq 12\n#define sz_xPolyFillRectangleReq 12\n#define sz_xPolyFillArcReq 12\n#define sz_xPolyText8Req 16\n#define sz_xPolyText16Req 16\n#define sz_xImageText8Req 16\n#define sz_xImageText16Req 16\n#define sz_xSetPointerMappingReq 4\n#define sz_xForceScreenSaverReq 4\n#define sz_xSetCloseDownModeReq 4\n#define sz_xClearAreaReq 16\n#define sz_xSetAccessControlReq 4\n#define sz_xGetKeyboardMappingReq 8\n#define sz_xSetModifierMappingReq 4\n#define sz_xPropIconSize 24\n#define sz_xChangeKeyboardMappingReq 8\n\n\n/* For the purpose of the structure definitions in this file,\nwe must redefine the following types in terms of Xmd.h's types, which may\ninclude bit fields.  All of these are #undef'd at the end of this file,\nrestoring the definitions in X.h.  */\n\n#define Window CARD32\n#define Drawable CARD32\n#define Font CARD32\n#define Pixmap CARD32\n#define Cursor CARD32\n#define Colormap CARD32\n#define GContext CARD32\n#define Atom CARD32\n#define VisualID CARD32\n#define Time CARD32\n#define KeyCode CARD8\n#define KeySym CARD32\n\n#define X_TCP_PORT 6000     /* add display number */\n\n#define xTrue        1\n#define xFalse       0\n\n\ntypedef CARD16 KeyButMask;\n\n/***************** \n   Connection setup structures.  See Chapter 8: Connection Setup\n   of the X Window System Protocol specification for details.\n*****************/\n\n/* Client initiates handshake with this data, followed by the strings\n * for the auth protocol & data.\n */\ntypedef struct {\n    CARD8\tbyteOrder;\n    BYTE\tpad;\n    CARD16\tmajorVersion B16, minorVersion B16;\n    CARD16\tnbytesAuthProto B16;\t/* Authorization protocol */\n    CARD16\tnbytesAuthString B16;\t/* Authorization string */\n    CARD16\tpad2 B16;\n} xConnClientPrefix;\n\n/* Server response to xConnClientPrefix.\n *\n * If success == Success, this is followed by xConnSetup and\n * numRoots xWindowRoot structs.\n *\n * If success == Failure, this is followed by a reason string.\n *\n * The protocol also defines a case of success == Authenticate, but\n * that doesn't seem to have ever been implemented by the X Consortium.\n */\ntypedef struct {\n    CARD8          success;\n    BYTE           lengthReason; /*num bytes in string following if failure */\n    CARD16         majorVersion B16, \n                   minorVersion B16;\n    CARD16         length B16;  /* 1/4 additional bytes in setup info */\n} xConnSetupPrefix;\n\n\ntypedef struct {\n    CARD32         release B32;\n    CARD32         ridBase B32, \n                   ridMask B32;\n    CARD32         motionBufferSize B32;\n    CARD16         nbytesVendor B16;  /* number of bytes in vendor string */\n    CARD16         maxRequestSize B16;\n    CARD8          numRoots;          /* number of roots structs to follow */\n    CARD8          numFormats;        /* number of pixmap formats */\n    CARD8          imageByteOrder;        /* LSBFirst, MSBFirst */\n    CARD8          bitmapBitOrder;        /* LeastSignificant, MostSign...*/\n    CARD8          bitmapScanlineUnit,     /* 8, 16, 32 */\n                   bitmapScanlinePad;     /* 8, 16, 32 */\n    KeyCode\t   minKeyCode, maxKeyCode;\n    CARD32\t   pad2 B32;\n} xConnSetup;\n\ntypedef struct {\n    CARD8          depth;\n    CARD8          bitsPerPixel;\n    CARD8          scanLinePad;\n    CARD8          pad1;\n    CARD32\t   pad2 B32;\n} xPixmapFormat;\n\n/* window root */\n\ntypedef struct {\n    CARD8 \tdepth;\n    CARD8 \tpad1;\n    CARD16\tnVisuals B16;  /* number of xVisualType structures following */\n    CARD32\tpad2 B32;\n    } xDepth;\n\ntypedef struct {\n    VisualID visualID B32;\n#if defined(__cplusplus) || defined(c_plusplus)\n    CARD8 c_class;\n#else\n    CARD8 class;\n#endif\n    CARD8 bitsPerRGB;\n    CARD16 colormapEntries B16;\n    CARD32 redMask B32, greenMask B32, blueMask B32;\n    CARD32 pad B32;\n    } xVisualType;\n\ntypedef struct {\n    Window         windowId B32;\n    Colormap       defaultColormap B32;\n    CARD32         whitePixel B32, blackPixel B32;\n    CARD32         currentInputMask B32;   \n    CARD16         pixWidth B16, pixHeight B16;\n    CARD16         mmWidth B16, mmHeight B16;\n    CARD16         minInstalledMaps B16, maxInstalledMaps B16;\n    VisualID       rootVisualID B32;\n    CARD8          backingStore;\n    BOOL           saveUnders;\n    CARD8          rootDepth;\n    CARD8          nDepths;  /* number of xDepth structures following */\n} xWindowRoot;\n\f\n\n/*****************************************************************\n * Structure Defns\n *   Structures needed for replies \n *****************************************************************/\n\n/* Used in GetMotionEvents */\n\ntypedef struct {\n    CARD32 time B32;\n    INT16 x B16, y B16;\n} xTimecoord;\n\ntypedef struct {\n    CARD8 family;\n    BYTE pad;\n    CARD16 length B16;\n} xHostEntry;\n\ntypedef struct {\n    INT16 leftSideBearing B16,\n\t  rightSideBearing B16,\n\t  characterWidth B16,\n\t  ascent B16,\n\t  descent B16;\n    CARD16 attributes B16;\n} xCharInfo;\n\ntypedef struct {\n    Atom name B32;\n    CARD32 value B32;\n} xFontProp;\n\n/*\n * non-aligned big-endian font ID follows this struct\n */\ntypedef struct {           /* followed by string */\n    CARD8 len;\t/* number of *characters* in string, or FontChange (255)\n\t\t   for font change, or 0 if just delta given */\n    INT8 delta;\n} xTextElt;\n\n\ntypedef struct {        \n    CARD32 pixel B32;\n    CARD16 red B16, green B16, blue B16;\n    CARD8 flags;  /* DoRed, DoGreen, DoBlue booleans */\n    CARD8 pad;\n} xColorItem;\n\n\ntypedef struct {\n    CARD16 red B16, green B16, blue B16, pad B16;\n} xrgb;\n\ntypedef CARD8 KEYCODE;\n\f\n\n/*****************\n * XRep:\n *    meant to be 32 byte quantity \n *****************/\n\n/* GenericReply is the common format of all replies.  The \"data\" items\n   are specific to each individual reply type. */\n\ntypedef struct {\t\n    BYTE type;              /* X_Reply */\n    BYTE data1;             /* depends on reply type */\n    CARD16 sequenceNumber B16;  /* of last request received by server */\n    CARD32 length B32;      /* 4 byte quantities beyond size of GenericReply */\n    CARD32 data00 B32;\n    CARD32 data01 B32;\n    CARD32 data02 B32;\n    CARD32 data03 B32;\n    CARD32 data04 B32;\n    CARD32 data05 B32;\n    } xGenericReply;\n\n/* Individual reply formats. */\n\ntypedef struct {\n    BYTE type;  /* X_Reply */\n    CARD8 backingStore;\n    CARD16 sequenceNumber B16;\n    CARD32 length B32;\t/* NOT 0; this is an extra-large reply */\n    VisualID visualID B32;\n#if defined(__cplusplus) || defined(c_plusplus)\n    CARD16 c_class B16;\n#else\n    CARD16 class B16;\n#endif\n    CARD8 bitGravity;\n    CARD8 winGravity;\n    CARD32 backingBitPlanes B32;\n    CARD32 backingPixel B32;\n    BOOL saveUnder;\n    BOOL mapInstalled;\n    CARD8 mapState;\n    BOOL override;\n    Colormap colormap B32;\n    CARD32 allEventMasks B32;\n    CARD32 yourEventMask B32;\n    CARD16 doNotPropagateMask B16;\n    CARD16 pad B16;\n    } xGetWindowAttributesReply;\n\ntypedef struct {\n    BYTE type;   /* X_Reply */\n    CARD8 depth;\n    CARD16 sequenceNumber B16;\n    CARD32 length B32;  /* 0 */\n    Window root B32;\n    INT16 x B16, y B16;\n    CARD16 width B16, height B16;\n    CARD16 borderWidth B16;\n    CARD16 pad1 B16;\n    CARD32 pad2 B32;\n    CARD32 pad3 B32;\n    } xGetGeometryReply;\n\ntypedef struct {\n    BYTE type;  /* X_Reply */\n    BYTE pad1;\n    CARD16 sequenceNumber B16;\n    CARD32 length B32;\n    Window root B32, parent B32;\n    CARD16 nChildren B16;\n    CARD16 pad2 B16;\n    CARD32 pad3 B32;\n    CARD32 pad4 B32;\n    CARD32 pad5 B32;\n    } xQueryTreeReply;\n\ntypedef struct {\n    BYTE type;  /* X_Reply */\n    BYTE pad1;\n    CARD16 sequenceNumber B16;\n    CARD32 length B32; /* 0 */\n    Atom atom B32;\n    CARD32 pad2 B32;\n    CARD32 pad3 B32;\n    CARD32 pad4 B32;\n    CARD32 pad5 B32;\n    CARD32 pad6 B32;\n    } xInternAtomReply;\n\ntypedef struct {\n    BYTE type;  /* X_Reply */\n    BYTE pad1;\n    CARD16 sequenceNumber B16;\n    CARD32 length B32;  /* of additional bytes */\n    CARD16 nameLength B16;  /* # of characters in name */\n    CARD16 pad2 B16;\n    CARD32 pad3 B32;\n    CARD32 pad4 B32;\n    CARD32 pad5 B32;\n    CARD32 pad6 B32;\n    CARD32 pad7 B32;\n    } xGetAtomNameReply;\n\ntypedef struct {\n    BYTE type;  /* X_Reply */\n    CARD8 format;\n    CARD16 sequenceNumber B16;\n    CARD32 length B32; /* of additional bytes */\n    Atom propertyType B32;\n    CARD32 bytesAfter B32;\n    CARD32 nItems B32; /* # of 8, 16, or 32-bit entities in reply */\n    CARD32 pad1 B32;\n    CARD32 pad2 B32;\n    CARD32 pad3 B32;\n    } xGetPropertyReply;\n\ntypedef struct {\n    BYTE type;  /* X_Reply */\n    BYTE pad1;\n    CARD16 sequenceNumber B16;\n    CARD32 length B32;\n    CARD16 nProperties B16;\n    CARD16 pad2 B16;\n    CARD32 pad3 B32;\n    CARD32 pad4 B32;\n    CARD32 pad5 B32;\n    CARD32 pad6 B32;\n    CARD32 pad7 B32;\n    } xListPropertiesReply;\n\ntypedef struct {\n    BYTE type;  /* X_Reply */\n    BYTE pad1;\n    CARD16 sequenceNumber B16;\n    CARD32 length B32;  /* 0 */\n    Window owner B32;\n    CARD32 pad2 B32;\n    CARD32 pad3 B32;\n    CARD32 pad4 B32;\n    CARD32 pad5 B32;\n    CARD32 pad6 B32;\n    } xGetSelectionOwnerReply;\n\ntypedef struct {\n    BYTE type;  /* X_Reply */\n    BYTE status;\n    CARD16 sequenceNumber B16;\n    CARD32 length B32;  /* 0 */\n    CARD32 pad1 B32;\n    CARD32 pad2 B32;\n    CARD32 pad3 B32;\n    CARD32 pad4 B32;\n    CARD32 pad5 B32;\n    CARD32 pad6 B32;\n    } xGrabPointerReply;\n\ntypedef xGrabPointerReply xGrabKeyboardReply;\n\ntypedef struct {\n    BYTE type;  /* X_Reply */\n    BOOL sameScreen;\n    CARD16 sequenceNumber B16;\n    CARD32 length B32;  /* 0 */\n    Window root B32, child B32;\n    INT16 rootX B16, rootY B16, winX B16, winY B16;\n    CARD16 mask B16;\n    CARD16 pad1 B16;\n    CARD32 pad B32;\n    } xQueryPointerReply;\n\ntypedef struct {\n    BYTE type;  /* X_Reply */\n    BYTE pad1;\n    CARD16 sequenceNumber B16;\n    CARD32 length B32;\n    CARD32 nEvents B32;\n    CARD32 pad2 B32;\n    CARD32 pad3 B32;\n    CARD32 pad4 B32;\n    CARD32 pad5 B32;\n    CARD32 pad6 B32;\n    } xGetMotionEventsReply;\n\ntypedef struct {\n    BYTE type;  /* X_Reply */\n    BOOL sameScreen;\n    CARD16 sequenceNumber B16;\n    CARD32 length B32; /* 0 */\n    Window child B32;\n    INT16 dstX B16, dstY B16;\n    CARD32 pad2 B32;\n    CARD32 pad3 B32;\n    CARD32 pad4 B32;\n    CARD32 pad5 B32;\n    } xTranslateCoordsReply;\n\ntypedef struct {\n    BYTE type;  /* X_Reply */\n    CARD8 revertTo;\n    CARD16 sequenceNumber B16;\n    CARD32 length B32;  /* 0 */\n    Window focus B32;\n    CARD32 pad1 B32;\n    CARD32 pad2 B32;\n    CARD32 pad3 B32;\n    CARD32 pad4 B32;\n    CARD32 pad5 B32;\n    } xGetInputFocusReply;\n\ntypedef struct {\n    BYTE type;  /* X_Reply */\n    BYTE pad1;\n    CARD16 sequenceNumber B16;\n    CARD32 length B32;  /* 2, NOT 0; this is an extra-large reply */\n    BYTE map[32];\n    } xQueryKeymapReply;\n\n/* Warning: this MUST match (up to component renaming) xListFontsWithInfoReply */\ntypedef struct _xQueryFontReply {\n    BYTE type;  /* X_Reply */\n    BYTE pad1;\n    CARD16 sequenceNumber B16;\n    CARD32 length B32;  /* definitely > 0, even if \"nCharInfos\" is 0 */\n    xCharInfo minBounds; \n    CARD32 walign1 B32;\n    xCharInfo maxBounds; \n    CARD32 walign2 B32;\n    CARD16 minCharOrByte2 B16, maxCharOrByte2 B16;\n    CARD16 defaultChar B16;\n    CARD16 nFontProps B16;  /* followed by this many xFontProp structures */\n    CARD8 drawDirection;\n    CARD8 minByte1, maxByte1;\n    BOOL allCharsExist;\n    INT16 fontAscent B16, fontDescent B16;\n    CARD32 nCharInfos B32; /* followed by this many xCharInfo structures */\n} xQueryFontReply;\n\ntypedef struct {\n    BYTE type;  /* X_Reply */\n    CARD8 drawDirection;\n    CARD16 sequenceNumber B16;\n    CARD32 length B32;  /* 0 */\n    INT16 fontAscent B16, fontDescent B16;\n    INT16 overallAscent B16, overallDescent B16;\n    INT32 overallWidth B32, overallLeft B32, overallRight B32;\n    CARD32 pad B32;\n    } xQueryTextExtentsReply;\n\ntypedef struct {\n    BYTE type;  /* X_Reply */\n    BYTE pad1;\n    CARD16 sequenceNumber B16;\n    CARD32 length B32;\n    CARD16 nFonts B16;\n    CARD16 pad2 B16;\n    CARD32 pad3 B32;\n    CARD32 pad4 B32;\n    CARD32 pad5 B32;\n    CARD32 pad6 B32;\n    CARD32 pad7 B32;\n    } xListFontsReply;\n\n/* Warning: this MUST match (up to component renaming) xQueryFontReply */\ntypedef struct {\n    BYTE type;  /* X_Reply */\n    CARD8 nameLength;  /* 0 indicates end-of-reply-sequence */\n    CARD16 sequenceNumber B16;\n    CARD32 length B32;  /* definitely > 0, even if \"nameLength\" is 0 */\n    xCharInfo minBounds; \n    CARD32 walign1 B32;\n    xCharInfo maxBounds; \n    CARD32 walign2 B32;\n    CARD16 minCharOrByte2 B16, maxCharOrByte2 B16;\n    CARD16 defaultChar B16;\n    CARD16 nFontProps B16;  /* followed by this many xFontProp structures */\n    CARD8 drawDirection;\n    CARD8 minByte1, maxByte1;\n    BOOL allCharsExist;\n    INT16 fontAscent B16, fontDescent B16;\n    CARD32 nReplies B32;   /* hint as to how many more replies might be coming */\n} xListFontsWithInfoReply;\n\ntypedef struct {\n    BYTE type;  /* X_Reply */\n    BYTE pad1;\n    CARD16 sequenceNumber B16;\n    CARD32 length B32;\n    CARD16 nPaths B16;\n    CARD16 pad2 B16;\n    CARD32 pad3 B32;\n    CARD32 pad4 B32;\n    CARD32 pad5 B32;\n    CARD32 pad6 B32;\n    CARD32 pad7 B32;\n    } xGetFontPathReply;\n\ntypedef struct {\n    BYTE type;  /* X_Reply */\n    CARD8 depth;\n    CARD16 sequenceNumber B16;\n    CARD32 length B32;\n    VisualID visual B32;\n    CARD32 pad3 B32;\n    CARD32 pad4 B32;\n    CARD32 pad5 B32;\n    CARD32 pad6 B32;\n    CARD32 pad7 B32;\n    } xGetImageReply;\n\ntypedef struct {\n    BYTE type;  /* X_Reply */\n    BYTE pad1;\n    CARD16 sequenceNumber B16;\n    CARD32 length B32;\n    CARD16 nColormaps B16;\n    CARD16 pad2 B16;\n    CARD32 pad3 B32;\n    CARD32 pad4 B32;\n    CARD32 pad5 B32;\n    CARD32 pad6 B32;\n    CARD32 pad7 B32;\n    } xListInstalledColormapsReply;\n\ntypedef struct {\n    BYTE type; /* X_Reply */\n    BYTE pad1;\n    CARD16 sequenceNumber B16;\n    CARD32 length B32;   /* 0 */\n    CARD16 red B16, green B16, blue B16;\n    CARD16 pad2 B16;\n    CARD32 pixel B32;\n    CARD32 pad3 B32;\n    CARD32 pad4 B32;\n    CARD32 pad5 B32;\n    } xAllocColorReply;\n\ntypedef struct {\n    BYTE type; /* X_Reply */\n    BYTE pad1;\n    CARD16 sequenceNumber B16;\n    CARD32 length B32;  /* 0 */\n    CARD32 pixel B32;\n    CARD16 exactRed B16, exactGreen B16, exactBlue B16;\n    CARD16 screenRed B16, screenGreen B16, screenBlue B16;\n    CARD32 pad2 B32;\n    CARD32 pad3 B32;\n    } xAllocNamedColorReply;\n\ntypedef struct {\n    BYTE type;  /* X_Reply */\n    BYTE pad1;\n    CARD16 sequenceNumber B16;\n    CARD32 length B32;\n    CARD16 nPixels B16, nMasks B16;\n    CARD32 pad3 B32;\n    CARD32 pad4 B32;\n    CARD32 pad5 B32;\n    CARD32 pad6 B32;\n    CARD32 pad7 B32;\n    } xAllocColorCellsReply;\n\ntypedef struct {\n    BYTE type; /* X_Reply */\n    BYTE pad1;\n    CARD16 sequenceNumber B16;\n    CARD32 length B32;\n    CARD16 nPixels B16;\n    CARD16 pad2 B16;\n    CARD32 redMask B32, greenMask B32, blueMask B32;\n    CARD32 pad3 B32;\n    CARD32 pad4 B32;\n    } xAllocColorPlanesReply;\n\ntypedef struct {\n    BYTE type; /* X_Reply */\n    BYTE pad1;\n    CARD16 sequenceNumber B16;\n    CARD32 length B32;\n    CARD16 nColors B16;\n    CARD16 pad2 B16;\n    CARD32 pad3 B32;\n    CARD32 pad4 B32;\n    CARD32 pad5 B32;\n    CARD32 pad6 B32;\n    CARD32 pad7 B32;\n    } xQueryColorsReply;\n\ntypedef struct {\n    BYTE type;  /* X_Reply */\n    BYTE pad1;\n    CARD16 sequenceNumber B16;\n    CARD32 length B32;  /* 0 */\n    CARD16 exactRed B16, exactGreen B16, exactBlue B16;\n    CARD16 screenRed B16, screenGreen B16, screenBlue B16;\n    CARD32 pad3 B32;\n    CARD32 pad4 B32;\n    CARD32 pad5 B32;\n    } xLookupColorReply;\n\ntypedef struct {\n    BYTE type;  /* X_Reply */\n    BYTE pad1;\n    CARD16 sequenceNumber B16;\n    CARD32 length B32;  /* 0 */\n    CARD16 width B16, height B16;\n    CARD32 pad3 B32;\n    CARD32 pad4 B32;\n    CARD32 pad5 B32;\n    CARD32 pad6 B32;\n    CARD32 pad7 B32;\n    } xQueryBestSizeReply;\n\ntypedef struct {\n    BYTE type;  /* X_Reply */\n    BYTE pad1;\n    CARD16 sequenceNumber B16;\n    CARD32 length B32; /* 0 */\n    BOOL  present;\n    CARD8 major_opcode;\n    CARD8 first_event;\n    CARD8 first_error;\n    CARD32 pad3 B32;\n    CARD32 pad4 B32;\n    CARD32 pad5 B32;\n    CARD32 pad6 B32;\n    CARD32 pad7 B32;\n    } xQueryExtensionReply;\n\ntypedef struct {\n    BYTE type;  /* X_Reply */\n    CARD8 nExtensions;\n    CARD16 sequenceNumber B16;\n    CARD32 length B32;\n    CARD32 pad2 B32;\n    CARD32 pad3 B32;\n    CARD32 pad4 B32;\n    CARD32 pad5 B32;\n    CARD32 pad6 B32;\n    CARD32 pad7 B32;\n    } xListExtensionsReply;\n\n\ntypedef struct {\n    BYTE   type;  /* X_Reply */\n    CARD8  success;\n    CARD16 sequenceNumber B16;\n    CARD32 length B32;\n    CARD32 pad2 B32;\n    CARD32 pad3 B32;\n    CARD32 pad4 B32;\n    CARD32 pad5 B32;\n    CARD32 pad6 B32;\n    CARD32 pad7 B32;\n    } xSetMappingReply;\ntypedef xSetMappingReply xSetPointerMappingReply;\ntypedef xSetMappingReply xSetModifierMappingReply;\n\ntypedef struct {\n    BYTE type;  /* X_Reply */\n    CARD8 nElts;  /* how many elements does the map have */\n    CARD16 sequenceNumber B16;\n    CARD32 length B32;\n    CARD32 pad2 B32;\n    CARD32 pad3 B32;\n    CARD32 pad4 B32;\n    CARD32 pad5 B32;\n    CARD32 pad6 B32;\n    CARD32 pad7 B32;\n    } xGetPointerMappingReply;\n\ntypedef struct {\n    BYTE type;\n    CARD8 keySymsPerKeyCode;\n    CARD16 sequenceNumber B16;\n    CARD32 length B32;\n    CARD32 pad2 B32;\n    CARD32 pad3 B32;\n    CARD32 pad4 B32;\n    CARD32 pad5 B32;\n    CARD32 pad6 B32;\n    CARD32 pad7 B32;\n} xGetKeyboardMappingReply;    \n\ntypedef struct {\n    BYTE type;\n    CARD8 numKeyPerModifier;\n    CARD16 sequenceNumber B16;\n    CARD32 length B32;\n    CARD32 pad1 B32;\n    CARD32 pad2 B32;\n    CARD32 pad3 B32;\n    CARD32 pad4 B32;\n    CARD32 pad5 B32;\n    CARD32 pad6 B32;\n} xGetModifierMappingReply;\n\ntypedef struct {\n    BYTE type;  /* X_Reply */\n    BOOL globalAutoRepeat;\n    CARD16 sequenceNumber B16;\n    CARD32 length B32;  /* 5 */\n    CARD32 ledMask B32;\n    CARD8 keyClickPercent, bellPercent;\n    CARD16 bellPitch B16, bellDuration B16;\n    CARD16 pad B16;\n    BYTE map[32];  /* bit masks start here */\n    } xGetKeyboardControlReply;\n\ntypedef struct {\n    BYTE type;  /* X_Reply */\n    BYTE pad1;\n    CARD16 sequenceNumber B16;\n    CARD32 length B32;  /* 0 */\n    CARD16 accelNumerator B16, accelDenominator B16;\n    CARD16 threshold B16;\n    CARD16 pad2 B16;\n    CARD32 pad3 B32;\n    CARD32 pad4 B32;\n    CARD32 pad5 B32;\n    CARD32 pad6 B32;\n    } xGetPointerControlReply;\n\ntypedef struct {\n    BYTE type;  /* X_Reply */\n    BYTE pad1;\n    CARD16 sequenceNumber B16;\n    CARD32 length B32;  /* 0 */\n    CARD16 timeout B16, interval B16;\n    BOOL preferBlanking;\n    BOOL allowExposures;\n    CARD16 pad2 B16;\n    CARD32 pad3 B32;\n    CARD32 pad4 B32;\n    CARD32 pad5 B32;\n    CARD32 pad6 B32;\n    } xGetScreenSaverReply;\n\ntypedef struct {\n    BYTE type;  /* X_Reply */\n    BOOL enabled;\n    CARD16 sequenceNumber B16;\n    CARD32 length B32;\n    CARD16 nHosts B16;\n    CARD16 pad1 B16;\n    CARD32 pad3 B32;\n    CARD32 pad4 B32;\n    CARD32 pad5 B32;\n    CARD32 pad6 B32;\n    CARD32 pad7 B32;\n    } xListHostsReply;\n\n\f\n\n\n/*****************************************************************\n * Xerror\n *    All errors  are 32 bytes \n *****************************************************************/\n\ntypedef struct {\n    BYTE type;                  /* X_Error */\n    BYTE errorCode;\n    CARD16 sequenceNumber B16;       /* the nth request from this client */\n    CARD32 resourceID B32;\n    CARD16 minorCode B16;\n    CARD8 majorCode;\n    BYTE pad1;\n    CARD32 pad3 B32;\n    CARD32 pad4 B32;\n    CARD32 pad5 B32;\n    CARD32 pad6 B32;\n    CARD32 pad7 B32;\n} xError;\n\n/*****************************************************************\n * xEvent\n *    All events are 32 bytes\n *****************************************************************/\n\ntypedef struct _xEvent {\n    union {\n\tstruct {\n\t    BYTE type;\n\t    BYTE detail;\n\t    CARD16 sequenceNumber B16;\n\t    } u;\n\tstruct {\n            CARD32 pad00 B32;\n\t    Time time B32;\n\t    Window root B32, event B32, child B32;\n\t    INT16 rootX B16, rootY B16, eventX B16, eventY B16;\n\t    KeyButMask state B16;\n\t    BOOL sameScreen;\t\t\n\t    BYTE pad1;\n\t} keyButtonPointer;\n\tstruct {\n            CARD32 pad00 B32;\n            Time time B32;\n\t    Window root B32, event B32, child B32;\n\t    INT16 rootX B16, rootY B16, eventX B16, eventY B16;\n\t    KeyButMask state B16;\n\t    BYTE mode; \t\t\t/* really XMode */\n\t    BYTE flags;\t\t/* sameScreen and focus booleans, packed together */\n#define ELFlagFocus        (1<<0)\n#define ELFlagSameScreen   (1<<1)\n\t} enterLeave;\n\tstruct {\n            CARD32 pad00 B32;\n\t    Window window B32;\n\t    BYTE mode; \t\t\t/* really XMode */\n\t    BYTE pad1, pad2, pad3;\n\t} focus;\n\tstruct {\n            CARD32 pad00 B32;\n\t    Window window B32;\n\t    CARD16 x B16, y B16, width B16, height B16;\n\t    CARD16 count B16;\n\t    CARD16 pad2 B16;\n\t} expose;\n\tstruct {\n            CARD32 pad00 B32;\n\t    Drawable drawable B32;\n\t    CARD16 x B16, y B16, width B16, height B16;\n\t    CARD16 minorEvent B16;\n\t    CARD16 count B16;\n\t    BYTE majorEvent;\n\t    BYTE pad1, pad2, pad3;\n\t} graphicsExposure;\n\tstruct {\n            CARD32 pad00 B32;\n\t    Drawable drawable B32;\n\t    CARD16 minorEvent B16;\n\t    BYTE majorEvent;\n\t    BYTE bpad;\n\t} noExposure;\n\tstruct {\n            CARD32 pad00 B32;\n\t    Window window B32;\n\t    CARD8 state;\n\t    BYTE pad1, pad2, pad3;\n\t} visibility;\n\tstruct {\n            CARD32 pad00 B32;\n\t    Window parent B32, window B32;\n\t    INT16 x B16, y B16;\n\t    CARD16 width B16, height B16, borderWidth B16;\n\t    BOOL override;\n\t    BYTE bpad;\n        } createNotify;\n/*\n * The event fields in the structures for DestroyNotify, UnmapNotify,\n * MapNotify, ReparentNotify, ConfigureNotify, CirculateNotify, GravityNotify,\n * must be at the same offset because server internal code is depending upon\n * this to patch up the events before they are delivered.\n * Also note that MapRequest, ConfigureRequest and CirculateRequest have\n * the same offset for the event window.\n */\n\tstruct {\n            CARD32 pad00 B32;\n\t    Window event B32, window B32;\n\t} destroyNotify;\n\tstruct {\n            CARD32 pad00 B32;\n\t    Window event B32, window B32;\n\t    BOOL fromConfigure;\n\t    BYTE pad1, pad2, pad3;\n        } unmapNotify;\n\tstruct {\n            CARD32 pad00 B32;\n\t    Window event B32, window B32;\n\t    BOOL override;\n\t    BYTE pad1, pad2, pad3;\n        } mapNotify;\n\tstruct {\n            CARD32 pad00 B32;\n\t    Window parent B32, window B32;\n        } mapRequest;\n\tstruct {\n            CARD32 pad00 B32;\n\t    Window event B32, window B32, parent B32;\n\t    INT16 x B16, y B16;\n\t    BOOL override;\n\t    BYTE pad1, pad2, pad3;\n\t} reparent;\n\tstruct {\n            CARD32 pad00 B32;\n\t    Window event B32, window B32, aboveSibling B32;\n\t    INT16 x B16, y B16;\n\t    CARD16 width B16, height B16, borderWidth B16;\n\t    BOOL override;\t\t\n\t    BYTE bpad;\n\t} configureNotify;\n\tstruct {\n            CARD32 pad00 B32;\n\t    Window parent B32, window B32, sibling B32;\n\t    INT16 x B16, y B16;\n\t    CARD16 width B16, height B16, borderWidth B16;\n\t    CARD16 valueMask B16;\n\t    CARD32 pad1 B32;\n\t} configureRequest;\n\tstruct {\n            CARD32 pad00 B32;\n\t    Window event B32, window B32;\n\t    INT16 x B16, y B16;\n\t    CARD32 pad1 B32, pad2 B32, pad3 B32, pad4 B32;\n\t} gravity;\n\tstruct {\n            CARD32 pad00 B32;\n\t    Window window B32;\n\t    CARD16 width B16, height B16;\n\t} resizeRequest;\n\tstruct {\n/* The event field in the circulate record is really the parent when this\n   is used as a CirculateRequest instead of a CirculateNotify */\n            CARD32 pad00 B32;\n\t    Window event B32, window B32, parent B32;\n\t    BYTE place;\t\t\t/* Top or Bottom */\n\t    BYTE pad1, pad2, pad3;\n\t} circulate;\n\tstruct {\n            CARD32 pad00 B32;\n\t    Window window B32;\n\t    Atom atom B32;\n\t    Time time B32;\n\t    BYTE state;\t\t\t/* NewValue or Deleted */\n\t    BYTE pad1;\n\t    CARD16 pad2 B16;\n\t} property;\n\tstruct {\n            CARD32 pad00 B32;\n            Time time B32;     \n\t    Window window B32;\n\t    Atom atom B32;\n\t} selectionClear;\n\tstruct {\n            CARD32 pad00 B32;\n            Time time B32;    \n\t    Window owner B32, requestor B32;\n\t    Atom selection B32, target B32, property B32;\n\t} selectionRequest;\n\tstruct {\n            CARD32 pad00 B32;\n            Time time B32;   \n\t    Window requestor B32;\n\t    Atom selection B32, target B32, property B32;\n\t} selectionNotify;\n\tstruct {\n            CARD32 pad00 B32;\n\t    Window window B32;\n\t    Colormap colormap B32;\n#if defined(__cplusplus) || defined(c_plusplus)\n\t    BOOL c_new;\n#else\n\t    BOOL new;\n#endif\n\t    BYTE state;\t\t\t/* Installed or UnInstalled */\n\t    BYTE pad1, pad2;\n\t} colormap;\n\tstruct {\n\t    CARD32 pad00 B32;\n\t    CARD8 request;\n\t    KeyCode firstKeyCode;\n\t    CARD8 count;\n\t    BYTE pad1;\n\t} mappingNotify;\n\tstruct {\n            CARD32 pad00 B32;\n\t    Window window B32;\n\t    union {\n\t\tstruct {\n\t\t    Atom type B32;\n\t\t    INT32 longs0 B32;\n\t\t    INT32 longs1 B32;\n\t\t    INT32 longs2 B32;\n\t\t    INT32 longs3 B32;\n\t\t    INT32 longs4 B32;\n\t\t} l;\n\t\tstruct {\n\t\t    Atom type B32;\n\t\t    INT16 shorts0 B16;\n\t\t    INT16 shorts1 B16;\n\t\t    INT16 shorts2 B16;\n\t\t    INT16 shorts3 B16;\n\t\t    INT16 shorts4 B16;\n\t\t    INT16 shorts5 B16;\n\t\t    INT16 shorts6 B16;\n\t\t    INT16 shorts7 B16;\n\t\t    INT16 shorts8 B16;\n\t\t    INT16 shorts9 B16;\n\t\t} s;\n\t\tstruct {\n\t\t    Atom type B32;\n\t\t    INT8 bytes[20];\n\t\t} b;\n\t    } u; \n\t} clientMessage;\n    } u;\n} xEvent;\n\n/*********************************************************\n *\n * Generic event\n * \n * Those events are not part of the core protocol spec and can be used by\n * various extensions.\n * type is always GenericEvent\n * extension is the minor opcode of the extension the event belongs to.\n * evtype is the actual event type, unique __per extension__. \n *\n * GenericEvents can be longer than 32 bytes, with the length field\n * specifying the number of 4 byte blocks after the first 32 bytes. \n *\n *\n */\ntypedef struct \n{\n    BYTE    type;\n    CARD8   extension;\n    CARD16  sequenceNumber B16;\n    CARD32  length B32;\n    CARD16  evtype B16;\n    CARD16  pad2 B16;\n    CARD32  pad3 B32;\n    CARD32  pad4 B32;\n    CARD32  pad5 B32;\n    CARD32  pad6 B32;\n    CARD32  pad7 B32;\n} xGenericEvent;\n\n\n\n/* KeymapNotify events are not included in the above union because they\n   are different from all other events: they do not have a \"detail\"\n   or \"sequenceNumber\", so there is room for a 248-bit key mask. */\n\ntypedef struct {\n    BYTE type;\n    BYTE map[31];\n    } xKeymapEvent;\n\n#define XEventSize (sizeof(xEvent))\n\n/* XReply is the union of all the replies above whose \"fixed part\"\nfits in 32 bytes.  It does NOT include GetWindowAttributesReply,\nQueryFontReply, QueryKeymapReply, or GetKeyboardControlReply \nListFontsWithInfoReply */\n\ntypedef union {\n    xGenericReply generic;\n    xGetGeometryReply geom;\n    xQueryTreeReply tree;\n    xInternAtomReply atom;\n    xGetAtomNameReply atomName;\n    xGetPropertyReply property;\n    xListPropertiesReply listProperties;\n    xGetSelectionOwnerReply selection;\n    xGrabPointerReply grabPointer;\n    xGrabKeyboardReply grabKeyboard;\n    xQueryPointerReply pointer;\n    xGetMotionEventsReply motionEvents;\n    xTranslateCoordsReply coords;\n    xGetInputFocusReply inputFocus;\n    xQueryTextExtentsReply textExtents;\n    xListFontsReply fonts;\n    xGetFontPathReply fontPath;\n    xGetImageReply image;\n    xListInstalledColormapsReply colormaps;\n    xAllocColorReply allocColor;\n    xAllocNamedColorReply allocNamedColor;\n    xAllocColorCellsReply colorCells;\n    xAllocColorPlanesReply colorPlanes;\n    xQueryColorsReply colors;\n    xLookupColorReply lookupColor;\n    xQueryBestSizeReply bestSize;\n    xQueryExtensionReply extension;\n    xListExtensionsReply extensions;\n    xSetModifierMappingReply setModifierMapping;\n    xGetModifierMappingReply getModifierMapping;\n    xSetPointerMappingReply setPointerMapping;\n    xGetKeyboardMappingReply getKeyboardMapping;\n    xGetPointerMappingReply getPointerMapping;\n    xGetPointerControlReply pointerControl;\n    xGetScreenSaverReply screenSaver;\n    xListHostsReply hosts;\n    xError error;\n    xEvent event;\n} xReply;\n\n\f\n\n/*****************************************************************\n * REQUESTS\n *****************************************************************/\n\n\n/* Request structure */\n\ntypedef struct _xReq {\n\tCARD8 reqType;\n\tCARD8 data;            /* meaning depends on request type */\n\tCARD16 length B16;         /* length in 4 bytes quantities \n\t\t\t\t  of whole request, including this header */\n} xReq;\n\n/*****************************************************************\n *  structures that follow request. \n *****************************************************************/\n\n/* ResourceReq is used for any request which has a resource ID \n   (or Atom or Time) as its one and only argument.  */\n\ntypedef struct {\n    CARD8 reqType;\n    BYTE pad;\n    CARD16 length B16;\n    CARD32 id B32;  /* a Window, Drawable, Font, GContext, Pixmap, etc. */\n    } xResourceReq;\n\ntypedef struct {\n    CARD8 reqType;\n    CARD8 depth;\n    CARD16 length B16;\n    Window wid B32, parent B32;\n    INT16 x B16, y B16;\n    CARD16 width B16, height B16, borderWidth B16;  \n#if defined(__cplusplus) || defined(c_plusplus)\n    CARD16 c_class B16;\n#else\n    CARD16 class B16;\n#endif\n    VisualID visual B32;\n    CARD32 mask B32;\n} xCreateWindowReq;\n\ntypedef struct {\n    CARD8 reqType;\n    BYTE pad;\n    CARD16 length B16;\n    Window window B32;\n    CARD32 valueMask B32; \n} xChangeWindowAttributesReq;\n\ntypedef struct {\n    CARD8 reqType;\n    BYTE mode;\n    CARD16 length B16;\n    Window window B32;\n} xChangeSaveSetReq;\n\ntypedef struct {\n    CARD8 reqType;\n    BYTE pad;\n    CARD16 length B16;\n    Window window B32, parent B32;\n    INT16 x B16, y B16;\n} xReparentWindowReq;\n\ntypedef struct {\n    CARD8 reqType;\n    CARD8 pad;\n    CARD16 length B16;\n    Window window B32;\n    CARD16 mask B16;\n    CARD16 pad2 B16;\n} xConfigureWindowReq;\n\ntypedef struct {\n    CARD8 reqType;\n    CARD8 direction;\n    CARD16 length B16;\n    Window window B32;\n} xCirculateWindowReq;\n\ntypedef struct {    /* followed by padded string */\n    CARD8 reqType;\n    BOOL onlyIfExists;\n    CARD16 length B16;\n    CARD16 nbytes  B16;    /* number of bytes in string */\n    CARD16 pad B16;\n} xInternAtomReq;\n\ntypedef struct {\n    CARD8 reqType;\n    CARD8 mode;\n    CARD16 length B16;\n    Window window B32;\n    Atom property B32, type B32;\n    CARD8 format;\n    BYTE pad[3];\n    CARD32 nUnits B32;     /* length of stuff following, depends on format */\n} xChangePropertyReq;\n\ntypedef struct {\n    CARD8 reqType;\n    BYTE pad;\n    CARD16 length B16;\n    Window window B32;\n    Atom property B32;\n} xDeletePropertyReq;\n\ntypedef struct {\n    CARD8 reqType;\n#if defined(__cplusplus) || defined(c_plusplus)\n    BOOL c_delete;\n#else\n    BOOL delete;\n#endif\n    CARD16 length B16;\n    Window window B32;\n    Atom property B32, type B32;\n    CARD32 longOffset B32;\n    CARD32 longLength B32;\n} xGetPropertyReq;\n \ntypedef struct {\n    CARD8 reqType;\n    BYTE pad;\n    CARD16 length B16;\n    Window window B32;\n    Atom selection B32;\n    Time time B32;\n} xSetSelectionOwnerReq;\n\ntypedef struct {\n    CARD8 reqType;\n    BYTE pad;\n    CARD16 length B16;\n    Window requestor B32;\n    Atom selection B32, target B32, property B32;\n    Time time B32;\n    } xConvertSelectionReq;\n\ntypedef struct {\n    CARD8 reqType;\n    BOOL propagate;\n    CARD16 length B16;\n    Window destination B32;\n    CARD32 eventMask B32;\n    xEvent event;\n} xSendEventReq;\n\ntypedef struct {\n    CARD8 reqType;\n    BOOL ownerEvents;\n    CARD16 length B16;\n    Window grabWindow B32;\n    CARD16 eventMask B16;\n    BYTE pointerMode, keyboardMode;\n    Window confineTo B32;\n    Cursor cursor B32;\n    Time time B32;\n} xGrabPointerReq;\n\ntypedef struct {\n    CARD8 reqType;\n    BOOL ownerEvents;\n    CARD16 length B16;\n    Window grabWindow B32;\n    CARD16 eventMask B16;\n    BYTE pointerMode, keyboardMode;\n    Window confineTo B32;\n    Cursor cursor B32;\n    CARD8 button;\n    BYTE pad;\n    CARD16 modifiers B16;\n} xGrabButtonReq;\n\ntypedef struct {\n    CARD8 reqType;\n    CARD8 button;\n    CARD16 length B16;\n    Window grabWindow B32;\n    CARD16 modifiers B16;\n    CARD16 pad B16;\n} xUngrabButtonReq;\n\ntypedef struct {\n    CARD8 reqType;\n    BYTE pad;\n    CARD16 length B16;\n    Cursor cursor B32;\n    Time time B32;\n    CARD16 eventMask B16;\n    CARD16 pad2 B16;\n} xChangeActivePointerGrabReq;\n\ntypedef struct {\n    CARD8 reqType;\n    BOOL ownerEvents;\n    CARD16 length B16;\n    Window grabWindow B32;\n    Time time B32;\n    BYTE pointerMode, keyboardMode;  \n    CARD16 pad B16;\n} xGrabKeyboardReq;\n\ntypedef struct {\n    CARD8 reqType;\n    BOOL ownerEvents;\n    CARD16 length B16;\n    Window grabWindow B32;\n    CARD16 modifiers B16;\n    CARD8 key;\n    BYTE pointerMode, keyboardMode;  \n    BYTE pad1, pad2, pad3;\n} xGrabKeyReq;\n\ntypedef struct {\n    CARD8 reqType;\n    CARD8 key;\n    CARD16 length B16;\n    Window grabWindow B32;\n    CARD16 modifiers B16;\n    CARD16 pad B16;\n} xUngrabKeyReq;\n\ntypedef struct {\n    CARD8 reqType;\n    CARD8 mode;\n    CARD16 length B16;\n    Time time B32;\n} xAllowEventsReq;\n\ntypedef struct {\n    CARD8 reqType;\n    BYTE pad;\n    CARD16 length B16;\n    Window window B32;\n    Time start B32, stop B32;\n} xGetMotionEventsReq;\n\ntypedef struct {\n    CARD8 reqType;\n    BYTE pad;\n    CARD16 length B16;\n    Window srcWid B32, dstWid B32;\n    INT16 srcX B16, srcY B16;\n} xTranslateCoordsReq;\n\ntypedef struct {\n    CARD8 reqType;\n    BYTE pad;\n    CARD16 length B16;\n    Window srcWid B32, dstWid B32;\n    INT16 srcX B16, srcY B16;\n    CARD16 srcWidth B16, srcHeight B16;\n    INT16 dstX B16, dstY B16;\n} xWarpPointerReq;\n\ntypedef struct {\n    CARD8 reqType;\n    CARD8 revertTo;\n    CARD16 length B16;\n    Window focus B32;\n    Time time B32;\n} xSetInputFocusReq;\n\ntypedef struct {\n    CARD8 reqType;\n    BYTE pad;\n    CARD16 length B16;\n    Font fid B32;\n    CARD16 nbytes B16;\n    BYTE pad1, pad2;\t/* string follows on word boundary */\n} xOpenFontReq;\n\ntypedef struct {\n    CARD8 reqType;\n    BOOL oddLength;\n    CARD16 length B16;\n    Font fid B32;\n    } xQueryTextExtentsReq;\n\ntypedef struct {\n    CARD8 reqType;\n    BYTE pad;\n    CARD16 length B16;\n    CARD16 maxNames B16;\n    CARD16 nbytes B16;  /* followed immediately by string bytes */\n} xListFontsReq;\n\ntypedef xListFontsReq xListFontsWithInfoReq;\n\ntypedef struct {\n    CARD8 reqType;\n    BYTE pad;\n    CARD16 length B16;\n    CARD16 nFonts B16;\n    BYTE pad1, pad2;\t/* LISTofSTRING8 follows on word boundary */\n} xSetFontPathReq;\n\ntypedef struct {\n    CARD8 reqType;\n    CARD8 depth;\n    CARD16 length B16;\n    Pixmap pid B32;\n    Drawable drawable B32;\n    CARD16 width B16, height B16;\n} xCreatePixmapReq;\n\ntypedef struct {\n    CARD8 reqType;\n    BYTE pad;\n    CARD16 length B16;\n    GContext gc B32;\n    Drawable drawable B32;\n    CARD32 mask B32;\n} xCreateGCReq;\n\ntypedef struct {\n    CARD8 reqType;\n    BYTE pad;\n    CARD16 length B16;\n    GContext gc B32;\n    CARD32 mask B32;\n} xChangeGCReq;    \n\ntypedef struct {\n    CARD8 reqType;\n    BYTE pad;\n    CARD16 length B16;\n    GContext srcGC B32, dstGC B32;\n    CARD32 mask B32;\n} xCopyGCReq;    \n\ntypedef struct {\n    CARD8 reqType;\n    BYTE pad;\n    CARD16 length B16;\n    GContext gc B32;\n    CARD16 dashOffset B16;\n    CARD16 nDashes B16;        /* length LISTofCARD8 of values following */\n} xSetDashesReq;    \n\ntypedef struct {\n    CARD8 reqType;\n    BYTE ordering;\n    CARD16 length B16;\n    GContext gc B32;\n    INT16 xOrigin B16, yOrigin B16;\n} xSetClipRectanglesReq;    \n\ntypedef struct {\n    CARD8 reqType;\n    BOOL exposures;\n    CARD16 length B16;\n    Window window B32;\n    INT16 x B16, y B16;\n    CARD16 width B16, height B16;\n} xClearAreaReq;\n\ntypedef struct {\n    CARD8 reqType;\n    BYTE pad;\n    CARD16 length B16;\n    Drawable srcDrawable B32, dstDrawable B32;\n    GContext gc B32;\n    INT16 srcX B16, srcY B16, dstX B16, dstY B16;\n    CARD16 width B16, height B16;\n} xCopyAreaReq;    \n\ntypedef struct {\n    CARD8 reqType;\n    BYTE pad;\n    CARD16 length B16;\n    Drawable srcDrawable B32, dstDrawable B32;\n    GContext gc B32;\n    INT16 srcX B16, srcY B16, dstX B16, dstY B16;\n    CARD16 width B16, height B16;\n    CARD32 bitPlane B32;\n} xCopyPlaneReq;    \n\ntypedef struct {\n    CARD8 reqType;\n    BYTE coordMode;\n    CARD16 length B16;\n    Drawable drawable B32;\n    GContext gc B32;\n} xPolyPointReq;    \n\ntypedef xPolyPointReq xPolyLineReq;  /* same request structure */\n\n/* The following used for PolySegment, PolyRectangle, PolyArc, PolyFillRectangle, PolyFillArc */\n\ntypedef struct {\n    CARD8 reqType;\n    BYTE pad;\n    CARD16 length B16;\n    Drawable drawable B32;\n    GContext gc B32;\n} xPolySegmentReq;    \n\ntypedef xPolySegmentReq xPolyArcReq;\ntypedef xPolySegmentReq xPolyRectangleReq;\ntypedef xPolySegmentReq xPolyFillRectangleReq;\ntypedef xPolySegmentReq xPolyFillArcReq;\n\ntypedef struct _FillPolyReq {\n    CARD8 reqType;\n    BYTE pad;\n    CARD16 length B16;\n    Drawable drawable B32;\n    GContext gc B32;\n    BYTE shape;\n    BYTE coordMode;\n    CARD16 pad1 B16;\n} xFillPolyReq;    \n\n\ntypedef struct _PutImageReq {\n    CARD8 reqType;\n    CARD8 format;\n    CARD16 length B16;\n    Drawable drawable B32;\n    GContext gc B32;\n    CARD16 width B16, height B16;\n    INT16 dstX B16, dstY B16;\n    CARD8 leftPad;\n    CARD8 depth;\n    CARD16 pad B16;\n} xPutImageReq;    \n\ntypedef struct {\n    CARD8 reqType;\n    CARD8 format;\n    CARD16 length B16;\n    Drawable drawable B32;\n    INT16 x B16, y B16;\n    CARD16 width B16, height B16;\n    CARD32 planeMask B32;\n} xGetImageReq;    \n\n/* the following used by PolyText8 and PolyText16 */\n\ntypedef struct {\n    CARD8 reqType;\n    CARD8 pad;\n    CARD16 length B16;\n    Drawable drawable B32;\n    GContext gc B32;\n    INT16 x B16, y B16;\t\t/* items (xTextElt) start after struct */\n} xPolyTextReq;    \n\ntypedef xPolyTextReq xPolyText8Req;\ntypedef xPolyTextReq xPolyText16Req;\n\ntypedef struct {\n    CARD8 reqType;\n    BYTE nChars;\n    CARD16 length B16;\n    Drawable drawable B32;\n    GContext gc B32;\n    INT16 x B16, y B16;\n} xImageTextReq;    \n\ntypedef xImageTextReq xImageText8Req;\ntypedef xImageTextReq xImageText16Req;\n\ntypedef struct {\n    CARD8 reqType;\n    BYTE alloc;\n    CARD16 length B16;\n    Colormap mid B32;\n    Window window B32;\n    VisualID visual B32;\n} xCreateColormapReq;    \n\ntypedef struct {\n    CARD8 reqType;\n    BYTE pad;\n    CARD16 length B16;\n    Colormap mid B32;\n    Colormap srcCmap B32;\n} xCopyColormapAndFreeReq;    \n\ntypedef struct {\n    CARD8 reqType;\n    BYTE pad;\n    CARD16 length B16;\n    Colormap cmap B32;\n    CARD16 red B16, green B16, blue B16;\n    CARD16 pad2 B16;\n} xAllocColorReq;    \n\ntypedef struct {\n    CARD8 reqType;\n    BYTE pad;\n    CARD16 length B16;\n    Colormap cmap B32;\n    CARD16 nbytes B16;  /* followed by structure */\n    BYTE pad1, pad2;\n} xAllocNamedColorReq;    \n\ntypedef struct {\n    CARD8 reqType;\n    BOOL contiguous;\n    CARD16 length B16;\n    Colormap cmap B32;\n    CARD16 colors B16, planes B16;\n} xAllocColorCellsReq;    \n\ntypedef struct {\n    CARD8 reqType;\n    BOOL contiguous;\n    CARD16 length B16;\n    Colormap cmap B32;\n    CARD16 colors B16, red B16, green B16, blue B16;\n} xAllocColorPlanesReq;    \n\ntypedef struct {\n    CARD8 reqType;\n    BYTE pad;\n    CARD16 length B16;\n    Colormap cmap B32;\n    CARD32 planeMask B32;\n} xFreeColorsReq;    \n\ntypedef struct {\n    CARD8 reqType;\n    BYTE pad;\n    CARD16 length B16;\n    Colormap cmap B32;\n} xStoreColorsReq;    \n\ntypedef struct {\n    CARD8 reqType;\n    CARD8 flags;   /* DoRed, DoGreen, DoBlue, as in xColorItem */\n    CARD16 length B16;\n    Colormap cmap B32;\n    CARD32 pixel B32;\n    CARD16 nbytes B16;  /* number of name string bytes following structure */\n    BYTE pad1, pad2;\n    } xStoreNamedColorReq;\n\ntypedef struct {\n    CARD8 reqType;\n    BYTE pad;\n    CARD16 length B16;\n    Colormap cmap B32;\n} xQueryColorsReq;    \n\ntypedef struct {    /* followed  by string of length len */\n    CARD8 reqType;\n    BYTE pad;\n    CARD16 length B16;\n    Colormap cmap B32;\n    CARD16 nbytes B16;  /* number of string bytes following structure*/\n    BYTE pad1, pad2;\n} xLookupColorReq;    \n\ntypedef struct {\n    CARD8 reqType;\n    BYTE pad;\n    CARD16 length B16;\n    Cursor cid B32;\n    Pixmap source B32, mask B32;\n    CARD16 foreRed B16, foreGreen B16, foreBlue B16;\n    CARD16 backRed B16, backGreen B16, backBlue B16;\n    CARD16 x B16, y B16;\n} xCreateCursorReq;    \n\ntypedef struct {\n    CARD8 reqType;\n    BYTE pad;\n    CARD16 length B16;\n    Cursor cid B32;\n    Font source B32, mask B32;\n    CARD16 sourceChar B16, maskChar B16;\n    CARD16 foreRed B16, foreGreen B16, foreBlue B16;\n    CARD16 backRed B16, backGreen B16, backBlue B16;\n} xCreateGlyphCursorReq;    \n\ntypedef struct {\n    CARD8 reqType;\n    BYTE pad;\n    CARD16 length B16;\n    Cursor cursor B32;\n    CARD16 foreRed B16, foreGreen B16, foreBlue B16;\n    CARD16 backRed B16, backGreen B16, backBlue B16;\n} xRecolorCursorReq;    \n\ntypedef struct {\n    CARD8 reqType;\n#if defined(__cplusplus) || defined(c_plusplus)\n    CARD8 c_class;\n#else\n    CARD8 class;\n#endif\n    CARD16 length B16;\n    Drawable drawable B32;\n    CARD16 width B16, height B16;\n} xQueryBestSizeReq;    \n\ntypedef struct {\n    CARD8 reqType;\n    BYTE pad;\n    CARD16 length B16;\n    CARD16 nbytes B16;  /* number of string bytes following structure */\n    BYTE pad1, pad2;\n} xQueryExtensionReq;\n\ntypedef struct {\n    CARD8   reqType;\n    CARD8   numKeyPerModifier;\n    CARD16  length B16;\n} xSetModifierMappingReq;\n\ntypedef struct {\n    CARD8 reqType;\n    CARD8 nElts;  /* how many elements in the map */\n    CARD16 length B16;\n} xSetPointerMappingReq;\n\ntypedef struct {\n    CARD8 reqType;\n    BYTE pad;\n    CARD16 length B16;\n    KeyCode firstKeyCode;\n    CARD8 count;\n    CARD16 pad1 B16;\n} xGetKeyboardMappingReq;    \n\ntypedef struct {\n    CARD8 reqType;\n    CARD8 keyCodes;\n    CARD16 length B16;\n    KeyCode firstKeyCode;\n    CARD8 keySymsPerKeyCode;\n    CARD16 pad1 B16;\n} xChangeKeyboardMappingReq;\n\ntypedef struct {\n    CARD8 reqType;\n    BYTE pad;\n    CARD16 length B16;\n    CARD32 mask B32;\n} xChangeKeyboardControlReq;    \n\ntypedef struct {\n    CARD8 reqType;\n    INT8 percent;  /* -100 to 100 */\n    CARD16 length B16;\n} xBellReq;    \n\ntypedef struct {\n    CARD8 reqType;\n    BYTE pad;\n    CARD16 length B16;\n    INT16 accelNum B16, accelDenum B16;\n    INT16 threshold B16;             \n    BOOL doAccel, doThresh;\n} xChangePointerControlReq;    \n\ntypedef struct {\n    CARD8 reqType;\n    BYTE pad;\n    CARD16 length B16;\n    INT16 timeout B16, interval B16;\n    BYTE preferBlank, allowExpose;  \n    CARD16 pad2 B16;\n} xSetScreenSaverReq;    \n\ntypedef struct {\n    CARD8 reqType;\n    BYTE mode;\n    CARD16 length B16;\n    CARD8 hostFamily;\n    BYTE pad;\n    CARD16 hostLength B16;\n} xChangeHostsReq;    \n\ntypedef struct {\n    CARD8 reqType;\n    BYTE pad;\n    CARD16 length B16;\n    } xListHostsReq;\n\ntypedef struct {\n    CARD8 reqType;\n    BYTE mode;\n    CARD16 length B16;\n    } xChangeModeReq;\n\ntypedef xChangeModeReq xSetAccessControlReq;\ntypedef xChangeModeReq xSetCloseDownModeReq;\ntypedef xChangeModeReq xForceScreenSaverReq;\n\ntypedef struct { /* followed by LIST of ATOM */\n    CARD8 reqType;\n    BYTE pad;\n    CARD16 length B16;\n    Window window B32;\n    CARD16 nAtoms B16;\n    INT16 nPositions B16;\n    } xRotatePropertiesReq;\n    \n\f\n\n/* Reply codes */\n\n#define X_Reply\t\t1\t\t/* Normal reply */\n#define X_Error\t\t0\t\t/* Error */\n\n/* Request codes */\n\n#define X_CreateWindow                  1              \n#define X_ChangeWindowAttributes        2        \n#define X_GetWindowAttributes           3     \n#define X_DestroyWindow                 4\n#define X_DestroySubwindows             5   \n#define X_ChangeSaveSet                 6\n#define X_ReparentWindow                7\n#define X_MapWindow                     8\n#define X_MapSubwindows                 9\n#define X_UnmapWindow                  10\n#define X_UnmapSubwindows              11  \n#define X_ConfigureWindow              12  \n#define X_CirculateWindow              13  \n#define X_GetGeometry                  14\n#define X_QueryTree                    15\n#define X_InternAtom                   16\n#define X_GetAtomName                  17\n#define X_ChangeProperty               18 \n#define X_DeleteProperty               19 \n#define X_GetProperty                  20\n#define X_ListProperties               21 \n#define X_SetSelectionOwner            22    \n#define X_GetSelectionOwner            23    \n#define X_ConvertSelection             24   \n#define X_SendEvent                    25\n#define X_GrabPointer                  26\n#define X_UngrabPointer                27\n#define X_GrabButton                   28\n#define X_UngrabButton                 29\n#define X_ChangeActivePointerGrab      30          \n#define X_GrabKeyboard                 31\n#define X_UngrabKeyboard               32 \n#define X_GrabKey                      33\n#define X_UngrabKey                    34\n#define X_AllowEvents                  35       \n#define X_GrabServer                   36      \n#define X_UngrabServer                 37        \n#define X_QueryPointer                 38        \n#define X_GetMotionEvents              39           \n#define X_TranslateCoords              40                \n#define X_WarpPointer                  41       \n#define X_SetInputFocus                42         \n#define X_GetInputFocus                43         \n#define X_QueryKeymap                  44       \n#define X_OpenFont                     45    \n#define X_CloseFont                    46     \n#define X_QueryFont                    47\n#define X_QueryTextExtents             48     \n#define X_ListFonts                    49  \n#define X_ListFontsWithInfo    \t       50 \n#define X_SetFontPath                  51 \n#define X_GetFontPath                  52 \n#define X_CreatePixmap                 53        \n#define X_FreePixmap                   54      \n#define X_CreateGC                     55    \n#define X_ChangeGC                     56    \n#define X_CopyGC                       57  \n#define X_SetDashes                    58     \n#define X_SetClipRectangles            59             \n#define X_FreeGC                       60  \n#define X_ClearArea                    61             \n#define X_CopyArea                     62    \n#define X_CopyPlane                    63     \n#define X_PolyPoint                    64     \n#define X_PolyLine                     65    \n#define X_PolySegment                  66       \n#define X_PolyRectangle                67         \n#define X_PolyArc                      68   \n#define X_FillPoly                     69    \n#define X_PolyFillRectangle            70             \n#define X_PolyFillArc                  71       \n#define X_PutImage                     72    \n#define X_GetImage                     73 \n#define X_PolyText8                    74     \n#define X_PolyText16                   75      \n#define X_ImageText8                   76      \n#define X_ImageText16                  77       \n#define X_CreateColormap               78          \n#define X_FreeColormap                 79        \n#define X_CopyColormapAndFree          80               \n#define X_InstallColormap              81           \n#define X_UninstallColormap            82             \n#define X_ListInstalledColormaps       83                  \n#define X_AllocColor                   84      \n#define X_AllocNamedColor              85           \n#define X_AllocColorCells              86           \n#define X_AllocColorPlanes             87            \n#define X_FreeColors                   88      \n#define X_StoreColors                  89       \n#define X_StoreNamedColor              90           \n#define X_QueryColors                  91       \n#define X_LookupColor                  92       \n#define X_CreateCursor                 93        \n#define X_CreateGlyphCursor            94             \n#define X_FreeCursor                   95      \n#define X_RecolorCursor                96         \n#define X_QueryBestSize                97         \n#define X_QueryExtension               98          \n#define X_ListExtensions               99          \n#define X_ChangeKeyboardMapping        100\n#define X_GetKeyboardMapping           101\n#define X_ChangeKeyboardControl        102                \n#define X_GetKeyboardControl           103             \n#define X_Bell                         104\n#define X_ChangePointerControl         105\n#define X_GetPointerControl            106\n#define X_SetScreenSaver               107          \n#define X_GetScreenSaver               108          \n#define X_ChangeHosts                  109       \n#define X_ListHosts                    110     \n#define X_SetAccessControl             111               \n#define X_SetCloseDownMode             112\n#define X_KillClient                   113 \n#define X_RotateProperties\t       114\n#define X_ForceScreenSaver\t       115\n#define X_SetPointerMapping            116\n#define X_GetPointerMapping            117\n#define X_SetModifierMapping\t       118\n#define X_GetModifierMapping\t       119\n#define X_NoOperation                  127\n\n/* restore these definitions back to the typedefs in X.h */\n#undef Window\n#undef Drawable\n#undef Font\n#undef Pixmap\n#undef Cursor\n#undef Colormap\n#undef GContext\n#undef Atom\n#undef VisualID\n#undef Time\n#undef KeyCode\n#undef KeySym\n\n#endif /* XPROTO_H */\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/X11/Xprotostr.h",
    "content": "#ifndef XPROTOSTRUCTS_H\n#define XPROTOSTRUCTS_H\n\n/***********************************************************\n\nCopyright 1987, 1998  The Open Group\n\nPermission to use, copy, modify, distribute, and sell this software and its\ndocumentation for any purpose is hereby granted without fee, provided that\nthe above copyright notice appear in all copies and that both that\ncopyright notice and this permission notice appear in supporting\ndocumentation.\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE\nOPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN\nAN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\nCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\nExcept as contained in this notice, the name of The Open Group shall not be\nused in advertising or otherwise to promote the sale, use or other dealings\nin this Software without prior written authorization from The Open Group.\n\n\nCopyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.\n\n                        All Rights Reserved\n\nPermission to use, copy, modify, and distribute this software and its \ndocumentation for any purpose and without fee is hereby granted, \nprovided that the above copyright notice appear in all copies and that\nboth that copyright notice and this permission notice appear in \nsupporting documentation, and that the name of Digital not be\nused in advertising or publicity pertaining to distribution of the\nsoftware without specific, written prior permission.  \n\nDIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING\nALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL\nDIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR\nANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,\nWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,\nARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS\nSOFTWARE.\n\n******************************************************************/\n#include <X11/Xmd.h>\n\n/* Used by PolySegment */\n\ntypedef struct _xSegment {\n    INT16 x1 B16, y1 B16, x2 B16, y2 B16;\n} xSegment;\n\n/* POINT */\n\ntypedef struct _xPoint {\n\tINT16\t\tx B16, y B16;\n} xPoint;\n\ntypedef struct _xRectangle {\n    INT16 x B16, y B16;\n    CARD16  width B16, height B16;\n} xRectangle;\n\n/*  ARC  */\n\ntypedef struct _xArc {\n    INT16 x B16, y B16;\n    CARD16   width B16, height B16;\n    INT16   angle1 B16, angle2 B16;\n} xArc;\n\n#endif /* XPROTOSTRUCTS_H */\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/X11/Xregion.h",
    "content": "/************************************************************************\n\nCopyright 1987, 1998  The Open Group\n\nPermission to use, copy, modify, distribute, and sell this software and its\ndocumentation for any purpose is hereby granted without fee, provided that\nthe above copyright notice appear in all copies and that both that\ncopyright notice and this permission notice appear in supporting\ndocumentation.\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE\nOPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN\nAN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\nCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\nExcept as contained in this notice, the name of The Open Group shall not be\nused in advertising or otherwise to promote the sale, use or other dealings\nin this Software without prior written authorization from The Open Group.\n\n\nCopyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.\n\n                        All Rights Reserved\n\nPermission to use, copy, modify, and distribute this software and its\ndocumentation for any purpose and without fee is hereby granted,\nprovided that the above copyright notice appear in all copies and that\nboth that copyright notice and this permission notice appear in\nsupporting documentation, and that the name of Digital not be\nused in advertising or publicity pertaining to distribution of the\nsoftware without specific, written prior permission.\n\nDIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING\nALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL\nDIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR\nANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,\nWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,\nARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS\nSOFTWARE.\n\n************************************************************************/\n\n#ifndef _X11_XREGION_H_\n#define _X11_XREGION_H_\n\ntypedef struct {\n    short x1, x2, y1, y2;\n} Box, BOX, BoxRec, *BoxPtr;\n\ntypedef struct {\n    short x, y, width, height;\n}RECTANGLE, RectangleRec, *RectanglePtr;\n\n#define TRUE 1\n#define FALSE 0\n#define MAXSHORT 32767\n#define MINSHORT -MAXSHORT\n#ifndef MAX\n#define MAX(a,b) (((a) > (b)) ? (a) : (b))\n#endif\n#ifndef MIN\n#define MIN(a,b) (((a) < (b)) ? (a) : (b))\n#endif\n\n\n/*\n *   clip region\n */\n\ntypedef struct _XRegion {\n    long size;\n    long numRects;\n    BOX *rects;\n    BOX extents;\n} REGION;\n\n/* Xutil.h contains the declaration:\n * typedef struct _XRegion *Region;\n */\n\n/*  1 if two BOXs overlap.\n *  0 if two BOXs do not overlap.\n *  Remember, x2 and y2 are not in the region\n */\n#define EXTENTCHECK(r1, r2) \\\n\t((r1)->x2 > (r2)->x1 && \\\n\t (r1)->x1 < (r2)->x2 && \\\n\t (r1)->y2 > (r2)->y1 && \\\n\t (r1)->y1 < (r2)->y2)\n\n/*\n *  update region extents\n */\n#define EXTENTS(r,idRect){\\\n            if((r)->x1 < (idRect)->extents.x1)\\\n              (idRect)->extents.x1 = (r)->x1;\\\n            if((r)->y1 < (idRect)->extents.y1)\\\n              (idRect)->extents.y1 = (r)->y1;\\\n            if((r)->x2 > (idRect)->extents.x2)\\\n              (idRect)->extents.x2 = (r)->x2;\\\n            if((r)->y2 > (idRect)->extents.y2)\\\n              (idRect)->extents.y2 = (r)->y2;\\\n        }\n\n/*\n *   Check to see if there is enough memory in the present region.\n */\n#define MEMCHECK(reg, rect, firstrect){\\\n        if ((reg)->numRects >= ((reg)->size - 1)){\\\n          BoxPtr tmpRect = Xrealloc ((firstrect), \\\n                                     (2 * (sizeof(BOX)) * ((reg)->size))); \\\n          if (tmpRect == NULL) \\\n            return(0);\\\n          (firstrect) = tmpRect; \\\n          (reg)->size *= 2;\\\n          (rect) = &(firstrect)[(reg)->numRects];\\\n         }\\\n       }\n\n/*  this routine checks to see if the previous rectangle is the same\n *  or subsumes the new rectangle to add.\n */\n\n#define CHECK_PREVIOUS(Reg, R, Rx1, Ry1, Rx2, Ry2)\\\n               (!(((Reg)->numRects > 0)&&\\\n                  ((R-1)->y1 == (Ry1)) &&\\\n                  ((R-1)->y2 == (Ry2)) &&\\\n                  ((R-1)->x1 <= (Rx1)) &&\\\n                  ((R-1)->x2 >= (Rx2))))\n\n/*  add a rectangle to the given Region */\n#define ADDRECT(reg, r, rx1, ry1, rx2, ry2){\\\n    if (((rx1) < (rx2)) && ((ry1) < (ry2)) &&\\\n        CHECK_PREVIOUS((reg), (r), (rx1), (ry1), (rx2), (ry2))){\\\n              (r)->x1 = (rx1);\\\n              (r)->y1 = (ry1);\\\n              (r)->x2 = (rx2);\\\n              (r)->y2 = (ry2);\\\n              EXTENTS((r), (reg));\\\n              (reg)->numRects++;\\\n              (r)++;\\\n            }\\\n        }\n\n\n\n/*  add a rectangle to the given Region */\n#define ADDRECTNOX(reg, r, rx1, ry1, rx2, ry2){\\\n            if ((rx1 < rx2) && (ry1 < ry2) &&\\\n                CHECK_PREVIOUS((reg), (r), (rx1), (ry1), (rx2), (ry2))){\\\n              (r)->x1 = (rx1);\\\n              (r)->y1 = (ry1);\\\n              (r)->x2 = (rx2);\\\n              (r)->y2 = (ry2);\\\n              (reg)->numRects++;\\\n              (r)++;\\\n            }\\\n        }\n\n#define EMPTY_REGION(pReg) pReg->numRects = 0\n\n#define REGION_NOT_EMPTY(pReg) pReg->numRects\n\n#define INBOX(r, x, y) \\\n      ( ( ((r).x2 >  x)) && \\\n        ( ((r).x1 <= x)) && \\\n        ( ((r).y2 >  y)) && \\\n        ( ((r).y1 <= y)) )\n\n/*\n * number of points to buffer before sending them off\n * to scanlines() :  Must be an even number\n */\n#define NUMPTSTOBUFFER 200\n\n/*\n * used to allocate buffers for points and link\n * the buffers together\n */\ntypedef struct _POINTBLOCK {\n    XPoint pts[NUMPTSTOBUFFER];\n    struct _POINTBLOCK *next;\n} POINTBLOCK;\n\n#endif /* _X11_XREGION_H_ */\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/X11/Xresource.h",
    "content": "\n/***********************************************************\n\nCopyright 1987, 1988, 1998  The Open Group\n\nPermission to use, copy, modify, distribute, and sell this software and its\ndocumentation for any purpose is hereby granted without fee, provided that\nthe above copyright notice appear in all copies and that both that\ncopyright notice and this permission notice appear in supporting\ndocumentation.\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE\nOPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN\nAN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\nCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\nExcept as contained in this notice, the name of The Open Group shall not be\nused in advertising or otherwise to promote the sale, use or other dealings\nin this Software without prior written authorization from The Open Group.\n\n\nCopyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts.\n\n                        All Rights Reserved\n\nPermission to use, copy, modify, and distribute this software and its\ndocumentation for any purpose and without fee is hereby granted,\nprovided that the above copyright notice appear in all copies and that\nboth that copyright notice and this permission notice appear in\nsupporting documentation, and that the name of Digital not be\nused in advertising or publicity pertaining to distribution of the\nsoftware without specific, written prior permission.\n\nDIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING\nALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL\nDIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR\nANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,\nWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,\nARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS\nSOFTWARE.\n\n******************************************************************/\n\n#ifndef _X11_XRESOURCE_H_\n#define _X11_XRESOURCE_H_\n\n#ifndef _XP_PRINT_SERVER_\n#include <X11/Xlib.h>\n#endif\n\n/****************************************************************\n ****************************************************************\n ***                                                          ***\n ***                                                          ***\n ***          X Resource Manager Intrinsics                   ***\n ***                                                          ***\n ***                                                          ***\n ****************************************************************\n ****************************************************************/\n\n_XFUNCPROTOBEGIN\n\n/****************************************************************\n *\n * Memory Management\n *\n ****************************************************************/\n\nextern char *Xpermalloc(\n    unsigned int\t/* size */\n);\n\n/****************************************************************\n *\n * Quark Management\n *\n ****************************************************************/\n\ntypedef int       XrmQuark, *XrmQuarkList;\n#define NULLQUARK ((XrmQuark) 0)\n\ntypedef char *XrmString;\n#define NULLSTRING ((XrmString) 0)\n\n/* find quark for string, create new quark if none already exists */\nextern XrmQuark XrmStringToQuark(\n    _Xconst char* \t/* string */\n);\n\nextern XrmQuark XrmPermStringToQuark(\n    _Xconst char* \t/* string */\n);\n\n/* find string for quark */\nextern XrmString XrmQuarkToString(\n    XrmQuark \t\t/* quark */\n);\n\nextern XrmQuark XrmUniqueQuark(\n    void\n);\n\n#define XrmStringsEqual(a1, a2) (strcmp(a1, a2) == 0)\n\n\n/****************************************************************\n *\n * Conversion of Strings to Lists\n *\n ****************************************************************/\n\ntypedef enum {XrmBindTightly, XrmBindLoosely} XrmBinding, *XrmBindingList;\n\nextern void XrmStringToQuarkList(\n    _Xconst char*\t/* string */,\n    XrmQuarkList\t/* quarks_return */\n);\n\nextern void XrmStringToBindingQuarkList(\n    _Xconst char*\t/* string */,\n    XrmBindingList\t/* bindings_return */,\n    XrmQuarkList\t/* quarks_return */\n);\n\n/****************************************************************\n *\n * Name and Class lists.\n *\n ****************************************************************/\n\ntypedef XrmQuark     XrmName;\ntypedef XrmQuarkList XrmNameList;\n#define XrmNameToString(name)\t\tXrmQuarkToString(name)\n#define XrmStringToName(string)\t\tXrmStringToQuark(string)\n#define XrmStringToNameList(str, name)\tXrmStringToQuarkList(str, name)\n\ntypedef XrmQuark     XrmClass;\ntypedef XrmQuarkList XrmClassList;\n#define XrmClassToString(c_class)\tXrmQuarkToString(c_class)\n#define XrmStringToClass(c_class)\tXrmStringToQuark(c_class)\n#define XrmStringToClassList(str,c_class) XrmStringToQuarkList(str, c_class)\n\n\n\n/****************************************************************\n *\n * Resource Representation Types and Values\n *\n ****************************************************************/\n\ntypedef XrmQuark     XrmRepresentation;\n#define XrmStringToRepresentation(string)   XrmStringToQuark(string)\n#define\tXrmRepresentationToString(type)   XrmQuarkToString(type)\n\ntypedef struct {\n    unsigned int    size;\n    XPointer\t    addr;\n} XrmValue, *XrmValuePtr;\n\n\n/****************************************************************\n *\n * Resource Manager Functions\n *\n ****************************************************************/\n\ntypedef struct _XrmHashBucketRec *XrmHashBucket;\ntypedef XrmHashBucket *XrmHashTable;\ntypedef XrmHashTable XrmSearchList[];\ntypedef struct _XrmHashBucketRec *XrmDatabase;\n\n\nextern void XrmDestroyDatabase(\n    XrmDatabase\t\t/* database */\n);\n\nextern void XrmQPutResource(\n    XrmDatabase*\t/* database */,\n    XrmBindingList\t/* bindings */,\n    XrmQuarkList\t/* quarks */,\n    XrmRepresentation\t/* type */,\n    XrmValue*\t\t/* value */\n);\n\nextern void XrmPutResource(\n    XrmDatabase*\t/* database */,\n    _Xconst char*\t/* specifier */,\n    _Xconst char*\t/* type */,\n    XrmValue*\t\t/* value */\n);\n\nextern void XrmQPutStringResource(\n    XrmDatabase*\t/* database */,\n    XrmBindingList      /* bindings */,\n    XrmQuarkList\t/* quarks */,\n    _Xconst char*\t/* value */\n);\n\nextern void XrmPutStringResource(\n    XrmDatabase*\t/* database */,\n    _Xconst char*\t/* specifier */,\n    _Xconst char*\t/* value */\n);\n\nextern void XrmPutLineResource(\n    XrmDatabase*\t/* database */,\n    _Xconst char*\t/* line */\n);\n\nextern Bool XrmQGetResource(\n    XrmDatabase\t\t/* database */,\n    XrmNameList\t\t/* quark_name */,\n    XrmClassList\t/* quark_class */,\n    XrmRepresentation*\t/* quark_type_return */,\n    XrmValue*\t\t/* value_return */\n);\n\nextern Bool XrmGetResource(\n    XrmDatabase\t\t/* database */,\n    _Xconst char*\t/* str_name */,\n    _Xconst char*\t/* str_class */,\n    char**\t\t/* str_type_return */,\n    XrmValue*\t\t/* value_return */\n);\n\nextern Bool XrmQGetSearchList(\n    XrmDatabase\t\t/* database */,\n    XrmNameList\t\t/* names */,\n    XrmClassList\t/* classes */,\n    XrmSearchList\t/* list_return */,\n    int\t\t\t/* list_length */\n);\n\nextern Bool XrmQGetSearchResource(\n    XrmSearchList\t/* list */,\n    XrmName\t\t/* name */,\n    XrmClass\t\t/* class */,\n    XrmRepresentation*\t/* type_return */,\n    XrmValue*\t\t/* value_return */\n);\n\n/****************************************************************\n *\n * Resource Database Management\n *\n ****************************************************************/\n\n#ifndef _XP_PRINT_SERVER_\n\nextern void XrmSetDatabase(\n    Display*\t\t/* display */,\n    XrmDatabase\t\t/* database */\n);\n\nextern XrmDatabase XrmGetDatabase(\n    Display*\t\t/* display */\n);\n\n#endif /* !_XP_PRINT_SERVER_ */\n\nextern XrmDatabase XrmGetFileDatabase(\n    _Xconst char*\t/* filename */\n);\n\nextern Status XrmCombineFileDatabase(\n    _Xconst char* \t/* filename */,\n    XrmDatabase*\t/* target */,\n    Bool\t\t/* override */\n);\n\nextern XrmDatabase XrmGetStringDatabase(\n    _Xconst char*\t/* data */  /*  null terminated string */\n);\n\nextern void XrmPutFileDatabase(\n    XrmDatabase\t\t/* database */,\n    _Xconst char*\t/* filename */\n);\n\nextern void XrmMergeDatabases(\n    XrmDatabase\t\t/* source_db */,\n    XrmDatabase*\t/* target_db */\n);\n\nextern void XrmCombineDatabase(\n    XrmDatabase\t\t/* source_db */,\n    XrmDatabase*\t/* target_db */,\n    Bool\t\t/* override */\n);\n\n#define XrmEnumAllLevels 0\n#define XrmEnumOneLevel  1\n\nextern Bool XrmEnumerateDatabase(\n    XrmDatabase\t\t/* db */,\n    XrmNameList\t\t/* name_prefix */,\n    XrmClassList\t/* class_prefix */,\n    int\t\t\t/* mode */,\n    Bool (*)(\n\t     XrmDatabase*\t/* db */,\n\t     XrmBindingList\t/* bindings */,\n\t     XrmQuarkList\t/* quarks */,\n\t     XrmRepresentation*\t/* type */,\n\t     XrmValue*\t\t/* value */,\n\t     XPointer\t\t/* closure */\n\t     )\t\t/* proc */,\n    XPointer\t\t/* closure */\n);\n\nextern const char *XrmLocaleOfDatabase(\n    XrmDatabase \t/* database */\n);\n\n\n/****************************************************************\n *\n * Command line option mapping to resource entries\n *\n ****************************************************************/\n\ntypedef enum {\n    XrmoptionNoArg,\t/* Value is specified in OptionDescRec.value\t    */\n    XrmoptionIsArg,     /* Value is the option string itself\t\t    */\n    XrmoptionStickyArg, /* Value is characters immediately following option */\n    XrmoptionSepArg,    /* Value is next argument in argv\t\t    */\n    XrmoptionResArg,\t/* Resource and value in next argument in argv      */\n    XrmoptionSkipArg,   /* Ignore this option and the next argument in argv */\n    XrmoptionSkipLine,  /* Ignore this option and the rest of argv\t    */\n    XrmoptionSkipNArgs\t/* Ignore this option and the next\n\t\t\t   OptionDescRes.value arguments in argv */\n} XrmOptionKind;\n\ntypedef struct {\n    char\t    *option;\t    /* Option abbreviation in argv\t    */\n    char\t    *specifier;     /* Resource specifier\t\t    */\n    XrmOptionKind   argKind;\t    /* Which style of option it is\t    */\n    XPointer\t    value;\t    /* Value to provide if XrmoptionNoArg   */\n} XrmOptionDescRec, *XrmOptionDescList;\n\n\nextern void XrmParseCommand(\n    XrmDatabase*\t/* database */,\n    XrmOptionDescList\t/* table */,\n    int\t\t\t/* table_count */,\n    _Xconst char*\t/* name */,\n    int*\t\t/* argc_in_out */,\n    char**\t\t/* argv_in_out */\n);\n\n_XFUNCPROTOEND\n\n#endif /* _X11_XRESOURCE_H_ */\n/* DON'T ADD STUFF AFTER THIS #endif */\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/X11/Xthreads.h",
    "content": "/*\n *\nCopyright 1993, 1998  The Open Group\n\nPermission to use, copy, modify, distribute, and sell this software and its\ndocumentation for any purpose is hereby granted without fee, provided that\nthe above copyright notice appear in all copies and that both that\ncopyright notice and this permission notice appear in supporting\ndocumentation.\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE\nOPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN\nAN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\nCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\nExcept as contained in this notice, the name of The Open Group shall not be\nused in advertising or otherwise to promote the sale, use or other dealings\nin this Software without prior written authorization from The Open Group.\n * *\n */\n\n#ifndef _XTHREADS_H_\n# define _XTHREADS_H_\n\n/* Redefine these to XtMalloc/XtFree or whatever you want before including\n * this header file.\n */\n# ifndef xmalloc\n#  define xmalloc malloc\n# endif\n# ifndef xfree\n#  define xfree free\n# endif\n\n# ifdef CTHREADS\n#  include <cthreads.h>\ntypedef cthread_t xthread_t;\ntypedef struct condition xcondition_rec;\ntypedef struct mutex xmutex_rec;\n#  define xthread_init() cthread_init()\n#  define xthread_self cthread_self\n#  define xthread_fork(func,closure) cthread_fork(func,closure)\n#  define xthread_yield() cthread_yield()\n#  define xthread_exit(v) cthread_exit(v)\n#  define xthread_set_name(t,str) cthread_set_name(t,str)\n#  define xmutex_init(m) mutex_init(m)\n#  define xmutex_clear(m) mutex_clear(m)\n#  define xmutex_lock(m) mutex_lock(m)\n#  define xmutex_unlock(m) mutex_unlock(m)\n#  define xmutex_set_name(m,str) mutex_set_name(m,str)\n#  define xcondition_init(cv) condition_init(cv)\n#  define xcondition_clear(cv) condition_clear(cv)\n#  define xcondition_wait(cv,m) condition_wait(cv,m)\n#  define xcondition_signal(cv) condition_signal(cv)\n#  define xcondition_broadcast(cv) condition_broadcast(cv)\n#  define xcondition_set_name(cv,str) condition_set_name(cv,str)\n# else /* !CTHREADS */\n#  if defined(SVR4)\n#   include <thread.h>\n#   include <synch.h>\ntypedef thread_t xthread_t;\ntypedef thread_key_t xthread_key_t;\ntypedef cond_t xcondition_rec;\ntypedef mutex_t xmutex_rec;\n#   if defined(__UNIXWARE__)\nextern xthread_t (*_x11_thr_self)();\n#    define xthread_self  (_x11_thr_self)\n#   else\n#    define xthread_self thr_self\n#   endif\n#   define xthread_fork(func,closure) thr_create(NULL,0,func,closure,THR_NEW_LWP|THR_DETACHED,NULL)\n#   define xthread_yield() thr_yield()\n#   define xthread_exit(v) thr_exit(v)\n#   define xthread_key_create(kp,d) thr_keycreate(kp,d)\n#   ifdef __sun\n#    define xthread_key_delete(k) 0\n#   else\n#    define xthread_key_delete(k) thr_keydelete(k)\n#   endif\n#   define xthread_set_specific(k,v) thr_setspecific(k,v)\n#   define xthread_get_specific(k,vp) thr_getspecific(k,vp)\n#   define xmutex_init(m) mutex_init(m,USYNC_THREAD,0)\n#   define xmutex_clear(m) mutex_destroy(m)\n#   define xmutex_lock(m) mutex_lock(m)\n#   define xmutex_unlock(m) mutex_unlock(m)\n#   define xcondition_init(cv) cond_init(cv,USYNC_THREAD,0)\n#   define xcondition_clear(cv) cond_destroy(cv)\n#   define xcondition_wait(cv,m) cond_wait(cv,m)\n#   define xcondition_signal(cv) cond_signal(cv)\n#   define xcondition_broadcast(cv) cond_broadcast(cv)\n#  else /* !SVR4 */\n#   ifdef WIN32\n#    include <X11/Xwindows.h>\ntypedef DWORD xthread_t;\ntypedef DWORD xthread_key_t;\nstruct _xthread_waiter {\n    HANDLE sem;\n    struct _xthread_waiter *next;\n};\ntypedef struct {\n    CRITICAL_SECTION cs;\n    struct _xthread_waiter *waiters;\n} xcondition_rec;\ntypedef CRITICAL_SECTION xmutex_rec;\nextern void _Xthread_init(void);\n#    define xthread_init() _Xthread_init()\n#    define xthread_self GetCurrentThreadId\n#    define xthread_fork(func,closure) { \\\n    DWORD _tmptid; \\\n    CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)func, (LPVOID)closure, 0, \\\n\t\t &_tmptid); \\\n}\n#    define xthread_yield() Sleep(0)\n#    define xthread_exit(v) ExitThread((DWORD)(v))\n#    define xthread_key_create(kp,d) *(kp) = TlsAlloc()\n#    define xthread_key_delete(k) TlsFree(k)\n#    define xthread_set_specific(k,v) TlsSetValue(k,v)\n#    define xthread_get_specific(k,vp) TlsGetValue(k)\n#    define xmutex_init(m) InitializeCriticalSection(m)\n#    define xmutex_clear(m) DeleteCriticalSection(m)\n#    define _XMUTEX_NESTS\n#    define xmutex_lock(m) EnterCriticalSection(m)\n#    define xmutex_unlock(m) LeaveCriticalSection(m)\n#    define xcondition_init(cv) { \\\n    InitializeCriticalSection(&(cv)->cs); \\\n    (cv)->waiters = NULL; \\\n}\n#    define xcondition_clear(cv) DeleteCriticalSection(&(cv)->cs)\nextern struct _xthread_waiter *_Xthread_waiter();\n#    define xcondition_wait(cv,m) { \\\n    struct _xthread_waiter *_tmpthr = _Xthread_waiter(); \\\n    EnterCriticalSection(&(cv)->cs); \\\n    _tmpthr->next = (cv)->waiters; \\\n    (cv)->waiters = _tmpthr; \\\n    LeaveCriticalSection(&(cv)->cs); \\\n    LeaveCriticalSection(m); \\\n    WaitForSingleObject(_tmpthr->sem, INFINITE); \\\n    EnterCriticalSection(m); \\\n}\n#    define xcondition_signal(cv) { \\\n    EnterCriticalSection(&(cv)->cs); \\\n    if ((cv)->waiters) { \\\n        ReleaseSemaphore((cv)->waiters->sem, 1, NULL); \\\n\t(cv)->waiters = (cv)->waiters->next; \\\n    } \\\n    LeaveCriticalSection(&(cv)->cs); \\\n}\n#    define xcondition_broadcast(cv) { \\\n    struct _xthread_waiter *_tmpthr; \\\n    EnterCriticalSection(&(cv)->cs); \\\n    for (_tmpthr = (cv)->waiters; _tmpthr; _tmpthr = _tmpthr->next) \\\n\tReleaseSemaphore(_tmpthr->sem, 1, NULL); \\\n    (cv)->waiters = NULL; \\\n    LeaveCriticalSection(&(cv)->cs); \\\n}\n#   else /* !WIN32 */\n#    ifdef USE_TIS_SUPPORT\n/*\n * TIS support is intended for thread safe libraries.\n * This should not be used for general client programming.\n */\n#     include <tis.h>\ntypedef pthread_t xthread_t;\ntypedef pthread_key_t xthread_key_t;\ntypedef pthread_cond_t xcondition_rec;\ntypedef pthread_mutex_t xmutex_rec;\n#     define xthread_self tis_self\n#     define xthread_fork(func,closure) { pthread_t _tmpxthr; \\\n        pthread_create(&_tmpxthr,NULL,func,closure); }\n#     define xthread_yield() pthread_yield_np()\n#     define xthread_exit(v) pthread_exit(v)\n#     define xthread_key_create(kp,d) tis_key_create(kp,d)\n#     define xthread_key_delete(k) tis_key_delete(k)\n#     define xthread_set_specific(k,v) tis_setspecific(k,v)\n#     define xthread_get_specific(k,vp) *(vp) = tis_getspecific(k)\n#     define XMUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER\n#     define xmutex_init(m) tis_mutex_init(m)\n#     define xmutex_clear(m) tis_mutex_destroy(m)\n#     define xmutex_lock(m) tis_mutex_lock(m)\n#     define xmutex_unlock(m) tis_mutex_unlock(m)\n#     define xcondition_init(c) tis_cond_init(c)\n#     define xcondition_clear(c) tis_cond_destroy(c)\n#     define xcondition_wait(c,m) tis_cond_wait(c,m)\n#     define xcondition_signal(c) tis_cond_signal(c)\n#     define xcondition_broadcast(c) tis_cond_broadcast(c)\n#    else\n#     ifdef USE_NBSD_THREADLIB\n/*\n * NetBSD threadlib support is intended for thread safe libraries.\n * This should not be used for general client programming.\n */\n#      include <threadlib.h>\ntypedef thr_t xthread_t;\ntypedef thread_key_t xthread_key_t;\ntypedef cond_t xcondition_rec;\ntypedef mutex_t xmutex_rec;\n#      define xthread_self thr_self\n#      define xthread_fork(func,closure) { thr_t _tmpxthr; \\\n\t/* XXX Create it detached?  --thorpej */ \\\n\tthr_create(&_tmpxthr,NULL,func,closure); }\n#      define xthread_yield() thr_yield()\n#      define xthread_exit(v) thr_exit(v)\n#      define xthread_key_create(kp,d) thr_keycreate(kp,d)\n#      define xthread_key_delete(k) thr_keydelete(k)\n#      define xthread_set_specific(k,v) thr_setspecific(k,v)\n#      define xthread_get_specific(k,vp) *(vp) = thr_getspecific(k)\n#      define XMUTEX_INITIALIZER MUTEX_INITIALIZER\n#      define xmutex_init(m) mutex_init(m, 0)\n#      define xmutex_clear(m) mutex_destroy(m)\n#      define xmutex_lock(m) mutex_lock(m)\n#      define xmutex_unlock(m) mutex_unlock(m)\n#      define xcondition_init(c) cond_init(c, 0, 0)\n#      define xcondition_clear(c) cond_destroy(c)\n#      define xcondition_wait(c,m) cond_wait(c,m)\n#      define xcondition_signal(c) cond_signal(c)\n#      define xcondition_broadcast(c) cond_broadcast(c)\n#     else\n#      include <pthread.h>\ntypedef pthread_t xthread_t;\ntypedef pthread_key_t xthread_key_t;\ntypedef pthread_cond_t xcondition_rec;\ntypedef pthread_mutex_t xmutex_rec;\n#      define xthread_self pthread_self\n#      define xthread_yield() pthread_yield()\n#      define xthread_exit(v) pthread_exit(v)\n#      define xthread_set_specific(k,v) pthread_setspecific(k,v)\n#      define xmutex_clear(m) pthread_mutex_destroy(m)\n#      define xmutex_lock(m) pthread_mutex_lock(m)\n#      define xmutex_unlock(m) pthread_mutex_unlock(m)\n#      ifndef XPRE_STANDARD_API\n#       define xthread_key_create(kp,d) pthread_key_create(kp,d)\n#       define xthread_key_delete(k) pthread_key_delete(k)\n#       define xthread_get_specific(k,vp) *(vp) = pthread_getspecific(k)\n#       define xthread_fork(func,closure) { pthread_t _tmpxthr; \\\n\tpthread_create(&_tmpxthr,NULL,func,closure); }\n#       define XMUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER\n#       define xmutex_init(m) pthread_mutex_init(m, NULL)\n#       define xcondition_init(c) pthread_cond_init(c, NULL)\n#      else /* XPRE_STANDARD_API */\n#       define xthread_key_create(kp,d) pthread_keycreate(kp,d)\n#       define xthread_key_delete(k) 0\n#       define xthread_get_specific(k,vp) pthread_getspecific(k,vp)\n#       define xthread_fork(func,closure) { pthread_t _tmpxthr; \\\n\tpthread_create(&_tmpxthr,pthread_attr_default,func,closure); }\n#       define xmutex_init(m) pthread_mutex_init(m, pthread_mutexattr_default)\n#       define xcondition_init(c) pthread_cond_init(c, pthread_condattr_default)\n#      endif /* XPRE_STANDARD_API */\n#      define xcondition_clear(c) pthread_cond_destroy(c)\n#      define xcondition_wait(c,m) pthread_cond_wait(c,m)\n#      define xcondition_signal(c) pthread_cond_signal(c)\n#      define xcondition_broadcast(c) pthread_cond_broadcast(c)\n#      if defined(_DECTHREADS_)\nstatic xthread_t _X_no_thread_id;\n#       define xthread_have_id(id) !pthread_equal(id, _X_no_thread_id)\n#       define xthread_clear_id(id) id = _X_no_thread_id\n#       define xthread_equal(id1,id2) pthread_equal(id1, id2)\n#      endif /* _DECTHREADS_ */\n#      if defined(__linux__)\n#       define xthread_have_id(id) !pthread_equal(id, 0)\n#       define xthread_clear_id(id) id = 0\n#       define xthread_equal(id1,id2) pthread_equal(id1, id2)\n#      endif /* linux */\n#      if defined(_CMA_VENDOR_) && defined(_CMA__IBM) && (_CMA_VENDOR_ == _CMA__IBM)\n#       ifdef DEBUG\t\t/* too much of a hack to enable normally */\n/* see also cma__obj_set_name() */\n#        define xmutex_set_name(m,str) ((char**)(m)->field1)[5] = (str)\n#        define xcondition_set_name(cv,str) ((char**)(cv)->field1)[5] = (str)\n#       endif /* DEBUG */\n#      endif /* _CMA_VENDOR_ == _CMA__IBM */\n#     endif /* USE_NBSD_THREADLIB */\n#    endif /* USE_TIS_SUPPORT */\n#   endif /* WIN32 */\n#  endif /* SVR4 */\n# endif /* CTHREADS */\ntypedef xcondition_rec *xcondition_t;\ntypedef xmutex_rec *xmutex_t;\n# ifndef xcondition_malloc\n#  define xcondition_malloc() (xcondition_t)xmalloc(sizeof(xcondition_rec))\n# endif\n# ifndef xcondition_free\n#  define xcondition_free(c) xfree((char *)c)\n# endif\n# ifndef xmutex_malloc\n#  define xmutex_malloc() (xmutex_t)xmalloc(sizeof(xmutex_rec))\n# endif\n# ifndef xmutex_free\n#  define xmutex_free(m) xfree((char *)m)\n# endif\n# ifndef xthread_have_id\n#  define xthread_have_id(id) id\n# endif\n# ifndef xthread_clear_id\n#  define xthread_clear_id(id) id = 0\n# endif\n# ifndef xthread_equal\n#  define xthread_equal(id1,id2) ((id1) == (id2))\n# endif\n/* aids understood by some debuggers */\n# ifndef xthread_set_name\n#  define xthread_set_name(t,str)\n# endif\n# ifndef xmutex_set_name\n#  define xmutex_set_name(m,str)\n# endif\n# ifndef xcondition_set_name\n#  define xcondition_set_name(cv,str)\n# endif\n\n#endif /* _XTHREADS_H_ */\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/X11/Xtrans/Xtrans.c",
    "content": "/*\n\nCopyright 1993, 1994, 1998  The Open Group\n\nPermission to use, copy, modify, distribute, and sell this software and its\ndocumentation for any purpose is hereby granted without fee, provided that\nthe above copyright notice appear in all copies and that both that\ncopyright notice and this permission notice appear in supporting\ndocumentation.\n\nThe above copyright notice and this permission notice shall be included\nin all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\nOR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR\nOTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,\nARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\nOTHER DEALINGS IN THE SOFTWARE.\n\nExcept as contained in this notice, the name of The Open Group shall\nnot be used in advertising or otherwise to promote the sale, use or\nother dealings in this Software without prior written authorization\nfrom The Open Group.\n\n * Copyright 1993, 1994 NCR Corporation - Dayton, Ohio, USA\n *\n * All Rights Reserved\n *\n * Permission to use, copy, modify, and distribute this software and its\n * documentation for any purpose and without fee is hereby granted, provided\n * that the above copyright notice appear in all copies and that both that\n * copyright notice and this permission notice appear in supporting\n * documentation, and that the name NCR not be used in advertising\n * or publicity pertaining to distribution of the software without specific,\n * written prior permission.  NCR makes no representations about the\n * suitability of this software for any purpose.  It is provided \"as is\"\n * without express or implied warranty.\n *\n * NCR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,\n * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN\n * NO EVENT SHALL NCR BE LIABLE FOR ANY SPECIAL, INDIRECT OR\n * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS\n * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,\n * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN\n * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n */\n\n#include <ctype.h>\n#include <stdlib.h>\n#include <string.h>\n#ifdef HAVE_SYSTEMD_DAEMON\n#include <systemd/sd-daemon.h>\n#endif\n\n/*\n * The transport table contains a definition for every transport (protocol)\n * family. All operations that can be made on the transport go through this\n * table.\n *\n * Each transport is assigned a unique transport id.\n *\n * New transports can be added by adding an entry in this table.\n * For compatiblity, the transport ids should never be renumbered.\n * Always add to the end of the list.\n */\n\n#define TRANS_TLI_INET_INDEX\t\t1\n#define TRANS_TLI_TCP_INDEX\t\t2\n#define TRANS_TLI_TLI_INDEX\t\t3\n#define TRANS_SOCKET_UNIX_INDEX\t\t4\n#define TRANS_SOCKET_LOCAL_INDEX\t5\n#define TRANS_SOCKET_INET_INDEX\t\t6\n#define TRANS_SOCKET_TCP_INDEX\t\t7\n#define TRANS_DNET_INDEX\t\t8\n#define TRANS_LOCAL_LOCAL_INDEX\t\t9\n#define TRANS_LOCAL_PTS_INDEX\t\t10\n#define TRANS_LOCAL_NAMED_INDEX\t\t11\n/* 12 used to be ISC, but that's gone. */\n#define TRANS_LOCAL_SCO_INDEX\t\t13\n#define TRANS_SOCKET_INET6_INDEX\t14\n#define TRANS_LOCAL_PIPE_INDEX\t\t15\n\n\nstatic\nXtransport_table Xtransports[] = {\n#if defined(TCPCONN)\n    { &TRANS(SocketTCPFuncs),\tTRANS_SOCKET_TCP_INDEX },\n#if defined(IPv6) && defined(AF_INET6)\n    { &TRANS(SocketINET6Funcs),\tTRANS_SOCKET_INET6_INDEX },\n#endif /* IPv6 */\n    { &TRANS(SocketINETFuncs),\tTRANS_SOCKET_INET_INDEX },\n#endif /* TCPCONN */\n#if defined(UNIXCONN)\n#if !defined(LOCALCONN)\n    { &TRANS(SocketLocalFuncs),\tTRANS_SOCKET_LOCAL_INDEX },\n#endif /* !LOCALCONN */\n    { &TRANS(SocketUNIXFuncs),\tTRANS_SOCKET_UNIX_INDEX },\n#endif /* UNIXCONN */\n#if defined(LOCALCONN)\n    { &TRANS(LocalFuncs),\tTRANS_LOCAL_LOCAL_INDEX },\n#ifndef sun\n    { &TRANS(PTSFuncs),\t\tTRANS_LOCAL_PTS_INDEX },\n#endif /* sun */\n#if defined(SVR4) || defined(__SVR4)\n    { &TRANS(NAMEDFuncs),\tTRANS_LOCAL_NAMED_INDEX },\n#endif\n#ifdef sun\n    { &TRANS(PIPEFuncs),\tTRANS_LOCAL_PIPE_INDEX },\n#endif /* sun */\n#if defined(__SCO__) || defined(__UNIXWARE__)\n    { &TRANS(SCOFuncs),\t\tTRANS_LOCAL_SCO_INDEX },\n#endif /* __SCO__ || __UNIXWARE__ */\n#endif /* LOCALCONN */\n};\n\n#define NUMTRANS\t(sizeof(Xtransports)/sizeof(Xtransport_table))\n\n\n#ifdef WIN32\n#define ioctl ioctlsocket\n#endif\n\n\n\f\n/*\n * These are a few utility function used by the public interface functions.\n */\n\nvoid\nTRANS(FreeConnInfo) (XtransConnInfo ciptr)\n\n{\n    prmsg (3,\"FreeConnInfo(%p)\\n\", ciptr);\n\n    if (ciptr->addr)\n\tfree (ciptr->addr);\n\n    if (ciptr->peeraddr)\n\tfree (ciptr->peeraddr);\n\n    if (ciptr->port)\n\tfree (ciptr->port);\n\n    free (ciptr);\n}\n\n\n#define PROTOBUFSIZE\t20\n\nstatic Xtransport *\nTRANS(SelectTransport) (const char *protocol)\n\n{\n    char \tprotobuf[PROTOBUFSIZE];\n    int\t\ti;\n\n    prmsg (3,\"SelectTransport(%s)\\n\", protocol);\n\n    /*\n     * Force Protocol to be lowercase as a way of doing\n     * a case insensitive match.\n     */\n\n    strncpy (protobuf, protocol, PROTOBUFSIZE - 1);\n    protobuf[PROTOBUFSIZE-1] = '\\0';\n\n    for (i = 0; i < PROTOBUFSIZE && protobuf[i] != '\\0'; i++)\n\tif (isupper ((unsigned char)protobuf[i]))\n\t    protobuf[i] = tolower ((unsigned char)protobuf[i]);\n\n    /* Look at all of the configured protocols */\n\n    for (i = 0; i < NUMTRANS; i++)\n    {\n\tif (!strcmp (protobuf, Xtransports[i].transport->TransName))\n\t    return Xtransports[i].transport;\n    }\n\n    return NULL;\n}\n\n#ifndef TEST_t\nstatic\n#endif /* TEST_t */\nint\nTRANS(ParseAddress) (const char *address,\n                     char **protocol, char **host, char **port)\n\n{\n    /*\n     * For the font library, the address is a string formatted\n     * as \"protocol/host:port[/catalogue]\".  Note that the catologue\n     * is optional.  At this time, the catologue info is ignored, but\n     * we have to parse it anyways.\n     *\n     * Other than fontlib, the address is a string formatted\n     * as \"protocol/host:port\".\n     *\n     * If the protocol part is missing, then assume TCP.\n     * If the protocol part and host part are missing, then assume local.\n     * If a \"::\" is found then assume DNET.\n     */\n\n    char\t*mybuf, *tmpptr;\n    const char\t*_protocol;\n    char\t*_host, *_port;\n    char\thostnamebuf[256];\n    int\t\t_host_len;\n\n    prmsg (3,\"ParseAddress(%s)\\n\", address);\n\n    /* Copy the string so it can be changed */\n\n    tmpptr = mybuf = strdup (address);\n\n    /* Parse the string to get each component */\n\n    /* Get the protocol part */\n\n    _protocol = mybuf;\n\n\n   if ( ((mybuf = strchr (mybuf,'/')) == NULL) &&\n      ((mybuf = strrchr (tmpptr,':')) == NULL) )\n   {\n\t/* address is in a bad format */\n\t*protocol = NULL;\n\t*host = NULL;\n\t*port = NULL;\n\tfree (tmpptr);\n\treturn 0;\n    }\n\n    if (*mybuf == ':')\n    {\n\t/*\n\t * If there is a hostname, then assume tcp, otherwise\n\t * it must be local.\n\t */\n\tif (mybuf == tmpptr)\n\t{\n\t    /* There is neither a protocol or host specified */\n\t    _protocol = \"local\";\n\t}\n\telse\n\t{\n\t    /* There is a hostname specified */\n\t    _protocol = \"tcp\";\n\t    mybuf = tmpptr;\t/* reset to the begining of the host ptr */\n\t}\n    }\n    else\n    {\n\t/* *mybuf == '/' */\n\n\t*mybuf ++= '\\0'; /* put a null at the end of the protocol */\n\n\tif (strlen(_protocol) == 0)\n\t{\n\t    /*\n\t     * If there is a hostname, then assume tcp, otherwise\n\t     * it must be local.\n\t     */\n\t    if (*mybuf != ':')\n\t\t_protocol = \"tcp\";\n\t    else\n\t\t_protocol = \"local\";\n\t}\n    }\n\n    /* Get the host part */\n\n    _host = mybuf;\n\n    if ((mybuf = strrchr (mybuf,':')) == NULL)\n    {\n\t*protocol = NULL;\n\t*host = NULL;\n\t*port = NULL;\n\tfree (tmpptr);\n\treturn 0;\n    }\n\n    *mybuf ++= '\\0';\n\n    _host_len = strlen(_host);\n    if (_host_len == 0)\n    {\n\tTRANS(GetHostname) (hostnamebuf, sizeof (hostnamebuf));\n\t_host = hostnamebuf;\n    }\n#if defined(IPv6) && defined(AF_INET6)\n    /* hostname in IPv6 [numeric_addr]:0 form? */\n    else if ( (_host_len > 3) &&\n      ((strcmp(_protocol, \"tcp\") == 0) || (strcmp(_protocol, \"inet6\") == 0))\n      && (*_host == '[') && (*(_host + _host_len - 1) == ']') ) {\n\tstruct sockaddr_in6 sin6;\n\n\t*(_host + _host_len - 1) = '\\0';\n\n\t/* Verify address is valid IPv6 numeric form */\n\tif (inet_pton(AF_INET6, _host + 1, &sin6) == 1) {\n\t    /* It is. Use it as such. */\n\t    _host++;\n\t    _protocol = \"inet6\";\n\t} else {\n\t    /* It's not, restore it just in case some other code can use it. */\n\t    *(_host + _host_len - 1) = ']';\n\t}\n    }\n#endif\n\n\n    /* Get the port */\n\n    _port = mybuf;\n\n#if defined(FONT_t) || defined(FS_t)\n    /*\n     * Is there an optional catalogue list?\n     */\n\n    if ((mybuf = strchr (mybuf,'/')) != NULL)\n\t*mybuf ++= '\\0';\n\n    /*\n     * The rest, if any, is the (currently unused) catalogue list.\n     *\n     * _catalogue = mybuf;\n     */\n#endif\n\n#ifdef HAVE_LAUNCHD\n    /* launchd sockets will look like 'local//tmp/launch-XgkNns/:0' */\n    if(address != NULL && strlen(address)>8 && (!strncmp(address,\"local//\",7))) {\n      _protocol=\"local\";\n      _host=\"\";\n      _port=address+6;\n    }\n#endif\n\n    /*\n     * Now that we have all of the components, allocate new\n     * string space for them.\n     */\n\n    if ((*protocol = strdup (_protocol)) == NULL)\n    {\n\t/* Malloc failed */\n\t*port = NULL;\n\t*host = NULL;\n\t*protocol = NULL;\n\tfree (tmpptr);\n\treturn 0;\n    }\n\n    if ((*host = strdup (_host)) == NULL)\n    {\n\t/* Malloc failed */\n\t*port = NULL;\n\t*host = NULL;\n\tfree (*protocol);\n\t*protocol = NULL;\n\tfree (tmpptr);\n\treturn 0;\n    }\n\n    if ((*port = strdup (_port)) == NULL)\n    {\n\t/* Malloc failed */\n\t*port = NULL;\n\tfree (*host);\n\t*host = NULL;\n\tfree (*protocol);\n\t*protocol = NULL;\n\tfree (tmpptr);\n\treturn 0;\n    }\n\n    free (tmpptr);\n\n    return 1;\n}\n\n\n/*\n * TRANS(Open) does all of the real work opening a connection. The only\n * funny part about this is the type parameter which is used to decide which\n * type of open to perform.\n */\n\nstatic XtransConnInfo\nTRANS(Open) (int type, const char *address)\n\n{\n    char \t\t*protocol = NULL, *host = NULL, *port = NULL;\n    XtransConnInfo\tciptr = NULL;\n    Xtransport\t\t*thistrans;\n\n    prmsg (2,\"Open(%d,%s)\\n\", type, address);\n\n#if defined(WIN32) && defined(TCPCONN)\n    if (TRANS(WSAStartup)())\n    {\n\tprmsg (1,\"Open: WSAStartup failed\\n\");\n\treturn NULL;\n    }\n#endif\n\n    /* Parse the Address */\n\n    if (TRANS(ParseAddress) (address, &protocol, &host, &port) == 0)\n    {\n\tprmsg (1,\"Open: Unable to Parse address %s\\n\", address);\n\treturn NULL;\n    }\n\n    /* Determine the transport type */\n\n    if ((thistrans = TRANS(SelectTransport) (protocol)) == NULL)\n    {\n\tprmsg (1,\"Open: Unable to find transport for %s\\n\",\n\t       protocol);\n\n\tfree (protocol);\n\tfree (host);\n\tfree (port);\n\treturn NULL;\n    }\n\n    /* Open the transport */\n\n    switch (type)\n    {\n    case XTRANS_OPEN_COTS_CLIENT:\n#ifdef TRANS_CLIENT\n\tciptr = thistrans->OpenCOTSClient(thistrans, protocol, host, port);\n#endif /* TRANS_CLIENT */\n\tbreak;\n    case XTRANS_OPEN_COTS_SERVER:\n#ifdef TRANS_SERVER\n\tciptr = thistrans->OpenCOTSServer(thistrans, protocol, host, port);\n#endif /* TRANS_SERVER */\n\tbreak;\n    case XTRANS_OPEN_CLTS_CLIENT:\n#ifdef TRANS_CLIENT\n\tciptr = thistrans->OpenCLTSClient(thistrans, protocol, host, port);\n#endif /* TRANS_CLIENT */\n\tbreak;\n    case XTRANS_OPEN_CLTS_SERVER:\n#ifdef TRANS_SERVER\n\tciptr = thistrans->OpenCLTSServer(thistrans, protocol, host, port);\n#endif /* TRANS_SERVER */\n\tbreak;\n    default:\n\tprmsg (1,\"Open: Unknown Open type %d\\n\", type);\n    }\n\n    if (ciptr == NULL)\n    {\n\tif (!(thistrans->flags & TRANS_DISABLED))\n\t{\n\t    prmsg (1,\"Open: transport open failed for %s/%s:%s\\n\",\n\t           protocol, host, port);\n\t}\n\tfree (protocol);\n\tfree (host);\n\tfree (port);\n\treturn NULL;\n    }\n\n    ciptr->transptr = thistrans;\n    ciptr->port = port;\t\t\t/* We need this for TRANS(Reopen) */\n\n    free (protocol);\n    free (host);\n\n    return ciptr;\n}\n\n\n#ifdef TRANS_REOPEN\n\n/*\n * We might want to create an XtransConnInfo object based on a previously\n * opened connection.  For example, the font server may clone itself and\n * pass file descriptors to the parent.\n */\n\nstatic XtransConnInfo\nTRANS(Reopen) (int type, int trans_id, int fd, const char *port)\n\n{\n    XtransConnInfo\tciptr = NULL;\n    Xtransport\t\t*thistrans = NULL;\n    char\t\t*save_port;\n    int\t\t\ti;\n\n    prmsg (2,\"Reopen(%d,%d,%s)\\n\", trans_id, fd, port);\n\n    /* Determine the transport type */\n\n    for (i = 0; i < NUMTRANS; i++)\n\tif (Xtransports[i].transport_id == trans_id)\n\t{\n\t    thistrans = Xtransports[i].transport;\n\t    break;\n\t}\n\n    if (thistrans == NULL)\n    {\n\tprmsg (1,\"Reopen: Unable to find transport id %d\\n\",\n\t       trans_id);\n\n\treturn NULL;\n    }\n\n    if ((save_port = strdup (port)) == NULL)\n    {\n\tprmsg (1,\"Reopen: Unable to malloc port string\\n\");\n\n\treturn NULL;\n    }\n\n    /* Get a new XtransConnInfo object */\n\n    switch (type)\n    {\n    case XTRANS_OPEN_COTS_SERVER:\n\tciptr = thistrans->ReopenCOTSServer(thistrans, fd, port);\n\tbreak;\n    case XTRANS_OPEN_CLTS_SERVER:\n\tciptr = thistrans->ReopenCLTSServer(thistrans, fd, port);\n\tbreak;\n    default:\n\tprmsg (1,\"Reopen: Bad Open type %d\\n\", type);\n    }\n\n    if (ciptr == NULL)\n    {\n\tprmsg (1,\"Reopen: transport open failed\\n\");\n\tfree (save_port);\n\treturn NULL;\n    }\n\n    ciptr->transptr = thistrans;\n    ciptr->port = save_port;\n\n    return ciptr;\n}\n\n#endif /* TRANS_REOPEN */\n\n\n\f\n/*\n * These are the public interfaces to this Transport interface.\n * These are the only functions that should have knowledge of the transport\n * table.\n */\n\n#ifdef TRANS_CLIENT\n\nXtransConnInfo\nTRANS(OpenCOTSClient) (const char *address)\n\n{\n    prmsg (2,\"OpenCOTSClient(%s)\\n\", address);\n    return TRANS(Open) (XTRANS_OPEN_COTS_CLIENT, address);\n}\n\n#endif /* TRANS_CLIENT */\n\n\n#ifdef TRANS_SERVER\n\nXtransConnInfo\nTRANS(OpenCOTSServer) (const char *address)\n\n{\n    prmsg (2,\"OpenCOTSServer(%s)\\n\", address);\n    return TRANS(Open) (XTRANS_OPEN_COTS_SERVER, address);\n}\n\n#endif /* TRANS_SERVER */\n\n\n#ifdef TRANS_CLIENT\n\nXtransConnInfo\nTRANS(OpenCLTSClient) (const char *address)\n\n{\n    prmsg (2,\"OpenCLTSClient(%s)\\n\", address);\n    return TRANS(Open) (XTRANS_OPEN_CLTS_CLIENT, address);\n}\n\n#endif /* TRANS_CLIENT */\n\n\n#ifdef TRANS_SERVER\n\nXtransConnInfo\nTRANS(OpenCLTSServer) (const char *address)\n\n{\n    prmsg (2,\"OpenCLTSServer(%s)\\n\", address);\n    return TRANS(Open) (XTRANS_OPEN_CLTS_SERVER, address);\n}\n\n#endif /* TRANS_SERVER */\n\n\n#ifdef TRANS_REOPEN\n\nXtransConnInfo\nTRANS(ReopenCOTSServer) (int trans_id, int fd, const char *port)\n\n{\n    prmsg (2,\"ReopenCOTSServer(%d, %d, %s)\\n\", trans_id, fd, port);\n    return TRANS(Reopen) (XTRANS_OPEN_COTS_SERVER, trans_id, fd, port);\n}\n\nXtransConnInfo\nTRANS(ReopenCLTSServer) (int trans_id, int fd, const char *port)\n\n{\n    prmsg (2,\"ReopenCLTSServer(%d, %d, %s)\\n\", trans_id, fd, port);\n    return TRANS(Reopen) (XTRANS_OPEN_CLTS_SERVER, trans_id, fd, port);\n}\n\n\nint\nTRANS(GetReopenInfo) (XtransConnInfo ciptr,\n\t\t      int *trans_id, int *fd, char **port)\n\n{\n    int i;\n\n    for (i = 0; i < NUMTRANS; i++)\n\tif (Xtransports[i].transport == ciptr->transptr)\n\t{\n\t    *trans_id = Xtransports[i].transport_id;\n\t    *fd = ciptr->fd;\n\n\t    if ((*port = strdup (ciptr->port)) == NULL)\n\t\treturn 0;\n\t    else\n\t\treturn 1;\n\t}\n\n    return 0;\n}\n\n#endif /* TRANS_REOPEN */\n\n\nint\nTRANS(SetOption) (XtransConnInfo ciptr, int option, int arg)\n\n{\n    int\tfd = ciptr->fd;\n    int\tret = 0;\n\n    prmsg (2,\"SetOption(%d,%d,%d)\\n\", fd, option, arg);\n\n    /*\n     * For now, all transport type use the same stuff for setting options.\n     * As long as this is true, we can put the common code here. Once a more\n     * complicated transport such as shared memory or an OSI implementation\n     * that uses the session and application libraries is implemented, this\n     * code may have to move to a transport dependent function.\n     *\n     * ret = ciptr->transptr->SetOption (ciptr, option, arg);\n     */\n\n    switch (option)\n    {\n    case TRANS_NONBLOCKING:\n\tswitch (arg)\n\t{\n\tcase 0:\n\t    /* Set to blocking mode */\n\t    break;\n\tcase 1: /* Set to non-blocking mode */\n\n#if defined(O_NONBLOCK) && !defined(SCO325)\n\t    ret = fcntl (fd, F_GETFL, 0);\n\t    if (ret != -1)\n\t\tret = fcntl (fd, F_SETFL, ret | O_NONBLOCK);\n#else\n#ifdef FIOSNBIO\n\t{\n\t    int arg;\n\t    arg = 1;\n\t    ret = ioctl (fd, FIOSNBIO, &arg);\n\t}\n#else\n#if defined(WIN32)\n\t{\n#ifdef WIN32\n\t    u_long arg;\n#else\n\t    int arg;\n#endif\n\t    arg = 1;\n/* IBM TCP/IP understands this option too well: it causes TRANS(Read) to fail\n * eventually with EWOULDBLOCK */\n\t    ret = ioctl (fd, FIONBIO, &arg);\n\t}\n#else\n\t    ret = fcntl (fd, F_GETFL, 0);\n#ifdef FNDELAY\n\t    ret = fcntl (fd, F_SETFL, ret | FNDELAY);\n#else\n\t    ret = fcntl (fd, F_SETFL, ret | O_NDELAY);\n#endif\n#endif /* AIXV3  || uniosu */\n#endif /* FIOSNBIO */\n#endif /* O_NONBLOCK */\n\t    break;\n\tdefault:\n\t    /* Unknown option */\n\t    break;\n\t}\n\tbreak;\n    case TRANS_CLOSEONEXEC:\n#ifdef F_SETFD\n#ifdef FD_CLOEXEC\n\tret = fcntl (fd, F_SETFD, FD_CLOEXEC);\n#else\n\tret = fcntl (fd, F_SETFD, 1);\n#endif /* FD_CLOEXEC */\n#endif /* F_SETFD */\n\tbreak;\n    }\n\n    return ret;\n}\n\n#ifdef TRANS_SERVER\n\nint\nTRANS(CreateListener) (XtransConnInfo ciptr, const char *port, unsigned int flags)\n\n{\n    return ciptr->transptr->CreateListener (ciptr, port, flags);\n}\n\nint\nTRANS(Received) (const char * protocol)\n\n{\n   Xtransport *trans;\n   int i = 0, ret = 0;\n\n   prmsg (5, \"Received(%s)\\n\", protocol);\n\n   if ((trans = TRANS(SelectTransport)(protocol)) == NULL)\n   {\n\tprmsg (1,\"Received: unable to find transport: %s\\n\",\n\t       protocol);\n\n\treturn -1;\n   }\n   if (trans->flags & TRANS_ALIAS) {\n       if (trans->nolisten)\n\t   while (trans->nolisten[i]) {\n\t       ret |= TRANS(Received)(trans->nolisten[i]);\n\t       i++;\n       }\n   }\n\n   trans->flags |= TRANS_RECEIVED;\n   return ret;\n}\n\nint\nTRANS(NoListen) (const char * protocol)\n\n{\n   Xtransport *trans;\n   int i = 0, ret = 0;\n\n   if ((trans = TRANS(SelectTransport)(protocol)) == NULL)\n   {\n\tprmsg (1,\"TransNoListen: unable to find transport: %s\\n\",\n\t       protocol);\n\n\treturn -1;\n   }\n   if (trans->flags & TRANS_ALIAS) {\n       if (trans->nolisten)\n\t   while (trans->nolisten[i]) {\n\t       ret |= TRANS(NoListen)(trans->nolisten[i]);\n\t       i++;\n       }\n   }\n\n   trans->flags |= TRANS_NOLISTEN;\n   return ret;\n}\n\nint\nTRANS(Listen) (const char * protocol)\n{\n   Xtransport *trans;\n   int i = 0, ret = 0;\n\n   if ((trans = TRANS(SelectTransport)(protocol)) == NULL)\n   {\n\tprmsg (1,\"TransListen: unable to find transport: %s\\n\",\n\t       protocol);\n\n\treturn -1;\n   }\n   if (trans->flags & TRANS_ALIAS) {\n       if (trans->nolisten)\n\t   while (trans->nolisten[i]) {\n\t       ret |= TRANS(Listen)(trans->nolisten[i]);\n\t       i++;\n       }\n   }\n\n   trans->flags &= ~TRANS_NOLISTEN;\n   return ret;\n}\n\nint\nTRANS(IsListening) (const char * protocol)\n{\n   Xtransport *trans;\n\n   if ((trans = TRANS(SelectTransport)(protocol)) == NULL)\n   {\n\tprmsg (1,\"TransIsListening: unable to find transport: %s\\n\",\n\t       protocol);\n\n\treturn 0;\n   }\n\n   return !(trans->flags & TRANS_NOLISTEN);\n}\n\nint\nTRANS(ResetListener) (XtransConnInfo ciptr)\n\n{\n    if (ciptr->transptr->ResetListener)\n\treturn ciptr->transptr->ResetListener (ciptr);\n    else\n\treturn TRANS_RESET_NOOP;\n}\n\n\nXtransConnInfo\nTRANS(Accept) (XtransConnInfo ciptr, int *status)\n\n{\n    XtransConnInfo\tnewciptr;\n\n    prmsg (2,\"Accept(%d)\\n\", ciptr->fd);\n\n    newciptr = ciptr->transptr->Accept (ciptr, status);\n\n    if (newciptr)\n\tnewciptr->transptr = ciptr->transptr;\n\n    return newciptr;\n}\n\n#endif /* TRANS_SERVER */\n\n\n#ifdef TRANS_CLIENT\n\nint\nTRANS(Connect) (XtransConnInfo ciptr, const char *address)\n\n{\n    char\t*protocol;\n    char\t*host;\n    char\t*port;\n    int\t\tret;\n\n    prmsg (2,\"Connect(%d,%s)\\n\", ciptr->fd, address);\n\n    if (TRANS(ParseAddress) (address, &protocol, &host, &port) == 0)\n    {\n\tprmsg (1,\"Connect: Unable to Parse address %s\\n\",\n\t       address);\n\treturn -1;\n    }\n\n#ifdef HAVE_LAUNCHD\n    if (!host) host=strdup(\"\");\n#endif\n\n    if (!port || !*port)\n    {\n\tprmsg (1,\"Connect: Missing port specification in %s\\n\",\n\t      address);\n\tif (protocol) free (protocol);\n\tif (host) free (host);\n\treturn -1;\n    }\n\n    ret = ciptr->transptr->Connect (ciptr, host, port);\n\n    if (protocol) free (protocol);\n    if (host) free (host);\n    if (port) free (port);\n\n    return ret;\n}\n\n#endif /* TRANS_CLIENT */\n\n\nint\nTRANS(BytesReadable) (XtransConnInfo ciptr, BytesReadable_t *pend)\n\n{\n    return ciptr->transptr->BytesReadable (ciptr, pend);\n}\n\nint\nTRANS(Read) (XtransConnInfo ciptr, char *buf, int size)\n\n{\n    return ciptr->transptr->Read (ciptr, buf, size);\n}\n\nint\nTRANS(Write) (XtransConnInfo ciptr, char *buf, int size)\n\n{\n    return ciptr->transptr->Write (ciptr, buf, size);\n}\n\nint\nTRANS(Readv) (XtransConnInfo ciptr, struct iovec *buf, int size)\n\n{\n    return ciptr->transptr->Readv (ciptr, buf, size);\n}\n\nint\nTRANS(Writev) (XtransConnInfo ciptr, struct iovec *buf, int size)\n\n{\n    return ciptr->transptr->Writev (ciptr, buf, size);\n}\n\n#if XTRANS_SEND_FDS\nint\nTRANS(SendFd) (XtransConnInfo ciptr, int fd, int do_close)\n{\n    return ciptr->transptr->SendFd(ciptr, fd, do_close);\n}\n\nint\nTRANS(RecvFd) (XtransConnInfo ciptr)\n{\n    return ciptr->transptr->RecvFd(ciptr);\n}\n#endif\n\nint\nTRANS(Disconnect) (XtransConnInfo ciptr)\n\n{\n    return ciptr->transptr->Disconnect (ciptr);\n}\n\nint\nTRANS(Close) (XtransConnInfo ciptr)\n\n{\n    int ret;\n\n    prmsg (2,\"Close(%d)\\n\", ciptr->fd);\n\n    ret = ciptr->transptr->Close (ciptr);\n\n    TRANS(FreeConnInfo) (ciptr);\n\n    return ret;\n}\n\nint\nTRANS(CloseForCloning) (XtransConnInfo ciptr)\n\n{\n    int ret;\n\n    prmsg (2,\"CloseForCloning(%d)\\n\", ciptr->fd);\n\n    ret = ciptr->transptr->CloseForCloning (ciptr);\n\n    TRANS(FreeConnInfo) (ciptr);\n\n    return ret;\n}\n\nint\nTRANS(IsLocal) (XtransConnInfo ciptr)\n\n{\n    return (ciptr->family == AF_UNIX);\n}\n\n\nint\nTRANS(GetMyAddr) (XtransConnInfo ciptr, int *familyp, int *addrlenp,\n\t\t  Xtransaddr **addrp)\n\n{\n    prmsg (2,\"GetMyAddr(%d)\\n\", ciptr->fd);\n\n    *familyp = ciptr->family;\n    *addrlenp = ciptr->addrlen;\n\n    if ((*addrp = malloc (ciptr->addrlen)) == NULL)\n    {\n\tprmsg (1,\"GetMyAddr: malloc failed\\n\");\n\treturn -1;\n    }\n    memcpy(*addrp, ciptr->addr, ciptr->addrlen);\n\n    return 0;\n}\n\nint\nTRANS(GetPeerAddr) (XtransConnInfo ciptr, int *familyp, int *addrlenp,\n\t\t    Xtransaddr **addrp)\n\n{\n    prmsg (2,\"GetPeerAddr(%d)\\n\", ciptr->fd);\n\n    *familyp = ciptr->family;\n    *addrlenp = ciptr->peeraddrlen;\n\n    if ((*addrp = malloc (ciptr->peeraddrlen)) == NULL)\n    {\n\tprmsg (1,\"GetPeerAddr: malloc failed\\n\");\n\treturn -1;\n    }\n    memcpy(*addrp, ciptr->peeraddr, ciptr->peeraddrlen);\n\n    return 0;\n}\n\n\nint\nTRANS(GetConnectionNumber) (XtransConnInfo ciptr)\n\n{\n    return ciptr->fd;\n}\n\n\f\n/*\n * These functions are really utility functions, but they require knowledge\n * of the internal data structures, so they have to be part of the Transport\n * Independant API.\n */\n\n#ifdef TRANS_SERVER\n\nstatic int\ncomplete_network_count (void)\n\n{\n    int count = 0;\n    int found_local = 0;\n    int i;\n\n    /*\n     * For a complete network, we only need one LOCALCONN transport to work\n     */\n\n    for (i = 0; i < NUMTRANS; i++)\n    {\n\tif (Xtransports[i].transport->flags & TRANS_ALIAS\n   \t || Xtransports[i].transport->flags & TRANS_NOLISTEN)\n\t    continue;\n\n\tif (Xtransports[i].transport->flags & TRANS_LOCAL)\n\t    found_local = 1;\n\telse\n\t    count++;\n    }\n\n    return (count + found_local);\n}\n\n\nstatic int\nreceive_listening_fds(const char* port, XtransConnInfo* temp_ciptrs,\n                      int* count_ret)\n\n{\n#ifdef HAVE_SYSTEMD_DAEMON\n    XtransConnInfo ciptr;\n    int i, systemd_listen_fds;\n\n    systemd_listen_fds = sd_listen_fds(1);\n    if (systemd_listen_fds < 0)\n    {\n        prmsg (1, \"receive_listening_fds: sd_listen_fds error: %s\\n\",\n               strerror(-systemd_listen_fds));\n        return -1;\n    }\n\n    for (i = 0; i < systemd_listen_fds && *count_ret < NUMTRANS; i++)\n    {\n        struct sockaddr_storage a;\n        int ti;\n        const char* tn;\n        socklen_t al;\n\n        al = sizeof(a);\n        if (getsockname(i + SD_LISTEN_FDS_START, (struct sockaddr*)&a, &al) < 0) {\n            prmsg (1, \"receive_listening_fds: getsockname error: %s\\n\",\n                   strerror(errno));\n            return -1;\n        }\n\n        switch (a.ss_family)\n        {\n        case AF_UNIX:\n            ti = TRANS_SOCKET_UNIX_INDEX;\n            if (*((struct sockaddr_un*)&a)->sun_path == '\\0' &&\n                al > sizeof(sa_family_t))\n                tn = \"local\";\n            else\n                tn = \"unix\";\n            break;\n        case AF_INET:\n            ti = TRANS_SOCKET_INET_INDEX;\n            tn = \"inet\";\n            break;\n#if defined(IPv6) && defined(AF_INET6)\n        case AF_INET6:\n            ti = TRANS_SOCKET_INET6_INDEX;\n            tn = \"inet6\";\n            break;\n#endif /* IPv6 */\n        default:\n            prmsg (1, \"receive_listening_fds:\"\n                   \"Got unknown socket address family\\n\");\n            return -1;\n        }\n\n        ciptr = TRANS(ReopenCOTSServer)(ti, i + SD_LISTEN_FDS_START, port);\n        if (!ciptr)\n        {\n            prmsg (1, \"receive_listening_fds:\"\n                   \"Got NULL while trying to reopen socket received from systemd.\\n\");\n            return -1;\n        }\n\n        prmsg (5, \"receive_listening_fds: received listener for %s, %d\\n\",\n               tn, ciptr->fd);\n        temp_ciptrs[(*count_ret)++] = ciptr;\n        TRANS(Received)(tn);\n    }\n#endif /* HAVE_SYSTEMD_DAEMON */\n    return 0;\n}\n\n#ifdef XQUARTZ_EXPORTS_LAUNCHD_FD\nextern int xquartz_launchd_fd;\n#endif\n\nint\nTRANS(MakeAllCOTSServerListeners) (const char *port, int *partial,\n                                   int *count_ret, XtransConnInfo **ciptrs_ret)\n\n{\n    char\t\tbuffer[256]; /* ??? What size ?? */\n    XtransConnInfo\tciptr, temp_ciptrs[NUMTRANS];\n    int\t\t\tstatus, i, j;\n\n#if defined(IPv6) && defined(AF_INET6)\n    int\t\tipv6_succ = 0;\n#endif\n    prmsg (2,\"MakeAllCOTSServerListeners(%s,%p)\\n\",\n\t   port ? port : \"NULL\", ciptrs_ret);\n\n    *count_ret = 0;\n\n#ifdef XQUARTZ_EXPORTS_LAUNCHD_FD\n    fprintf(stderr, \"Launchd socket fd: %d\\n\", xquartz_launchd_fd);\n    if(xquartz_launchd_fd != -1) {\n        if((ciptr = TRANS(ReopenCOTSServer(TRANS_SOCKET_LOCAL_INDEX,\n                                           xquartz_launchd_fd, getenv(\"DISPLAY\"))))==NULL)\n            fprintf(stderr,\"Got NULL while trying to Reopen launchd port\\n\");\n        else\n            temp_ciptrs[(*count_ret)++] = ciptr;\n    }\n#endif\n\n    if (receive_listening_fds(port, temp_ciptrs, count_ret) < 0)\n\treturn -1;\n\n    for (i = 0; i < NUMTRANS; i++)\n    {\n\tXtransport *trans = Xtransports[i].transport;\n\tunsigned int flags = 0;\n\n\tif (trans->flags&TRANS_ALIAS || trans->flags&TRANS_NOLISTEN ||\n\t    trans->flags&TRANS_RECEIVED)\n\t    continue;\n\n\tsnprintf(buffer, sizeof(buffer), \"%s/:%s\",\n\t\t trans->TransName, port ? port : \"\");\n\n\tprmsg (5,\"MakeAllCOTSServerListeners: opening %s\\n\",\n\t       buffer);\n\n\tif ((ciptr = TRANS(OpenCOTSServer(buffer))) == NULL)\n\t{\n\t    if (trans->flags & TRANS_DISABLED)\n\t\tcontinue;\n\n\t    prmsg (1,\n\t  \"MakeAllCOTSServerListeners: failed to open listener for %s\\n\",\n\t\t  trans->TransName);\n\t    continue;\n\t}\n#if defined(IPv6) && defined(AF_INET6)\n\t\tif ((Xtransports[i].transport_id == TRANS_SOCKET_INET_INDEX\n\t\t     && ipv6_succ))\n\t\t    flags |= ADDR_IN_USE_ALLOWED;\n#endif\n\n\tif ((status = TRANS(CreateListener (ciptr, port, flags))) < 0)\n\t{\n\t    if (status == TRANS_ADDR_IN_USE)\n\t    {\n\t\t/*\n\t\t * We failed to bind to the specified address because the\n\t\t * address is in use.  It must be that a server is already\n\t\t * running at this address, and this function should fail.\n\t\t */\n\n\t\tprmsg (1,\n\t\t\"MakeAllCOTSServerListeners: server already running\\n\");\n\n\t\tfor (j = 0; j < *count_ret; j++)\n\t\t    TRANS(Close) (temp_ciptrs[j]);\n\n\t\t*count_ret = 0;\n\t\t*ciptrs_ret = NULL;\n\t\t*partial = 0;\n\t\treturn -1;\n\t    }\n\t    else\n\t    {\n\t\tprmsg (1,\n\t\"MakeAllCOTSServerListeners: failed to create listener for %s\\n\",\n\t\t  trans->TransName);\n\n\t\tcontinue;\n\t    }\n\t}\n\n#if defined(IPv6) && defined(AF_INET6)\n\tif (Xtransports[i].transport_id == TRANS_SOCKET_INET6_INDEX)\n\t    ipv6_succ = 1;\n#endif\n\n\tprmsg (5,\n\t      \"MakeAllCOTSServerListeners: opened listener for %s, %d\\n\",\n\t      trans->TransName, ciptr->fd);\n\n\ttemp_ciptrs[*count_ret] = ciptr;\n\t(*count_ret)++;\n    }\n\n    *partial = (*count_ret < complete_network_count());\n\n    prmsg (5,\n     \"MakeAllCOTSServerListeners: partial=%d, actual=%d, complete=%d \\n\",\n\t*partial, *count_ret, complete_network_count());\n\n    if (*count_ret > 0)\n    {\n\tif ((*ciptrs_ret = malloc (\n\t    *count_ret * sizeof (XtransConnInfo))) == NULL)\n\t{\n\t    return -1;\n\t}\n\n\tfor (i = 0; i < *count_ret; i++)\n\t{\n\t    (*ciptrs_ret)[i] = temp_ciptrs[i];\n\t}\n    }\n    else\n\t*ciptrs_ret = NULL;\n\n    return 0;\n}\n\nint\nTRANS(MakeAllCLTSServerListeners) (const char *port, int *partial,\n                                   int *count_ret, XtransConnInfo **ciptrs_ret)\n\n{\n    char\t\tbuffer[256]; /* ??? What size ?? */\n    XtransConnInfo\tciptr, temp_ciptrs[NUMTRANS];\n    int\t\t\tstatus, i, j;\n\n    prmsg (2,\"MakeAllCLTSServerListeners(%s,%p)\\n\",\n\tport ? port : \"NULL\", ciptrs_ret);\n\n    *count_ret = 0;\n\n    for (i = 0; i < NUMTRANS; i++)\n    {\n\tXtransport *trans = Xtransports[i].transport;\n\n\tif (trans->flags&TRANS_ALIAS || trans->flags&TRANS_NOLISTEN)\n\t    continue;\n\n\tsnprintf(buffer, sizeof(buffer), \"%s/:%s\",\n\t\t trans->TransName, port ? port : \"\");\n\n\tprmsg (5,\"MakeAllCLTSServerListeners: opening %s\\n\",\n\t    buffer);\n\n\tif ((ciptr = TRANS(OpenCLTSServer (buffer))) == NULL)\n\t{\n\t    prmsg (1,\n\t\"MakeAllCLTSServerListeners: failed to open listener for %s\\n\",\n\t\t  trans->TransName);\n\t    continue;\n\t}\n\n\tif ((status = TRANS(CreateListener (ciptr, port, 0))) < 0)\n\t{\n\t    if (status == TRANS_ADDR_IN_USE)\n\t    {\n\t\t/*\n\t\t * We failed to bind to the specified address because the\n\t\t * address is in use.  It must be that a server is already\n\t\t * running at this address, and this function should fail.\n\t\t */\n\n\t\tprmsg (1,\n\t\t\"MakeAllCLTSServerListeners: server already running\\n\");\n\n\t\tfor (j = 0; j < *count_ret; j++)\n\t\t    TRANS(Close) (temp_ciptrs[j]);\n\n\t\t*count_ret = 0;\n\t\t*ciptrs_ret = NULL;\n\t\t*partial = 0;\n\t\treturn -1;\n\t    }\n\t    else\n\t    {\n\t\tprmsg (1,\n\t\"MakeAllCLTSServerListeners: failed to create listener for %s\\n\",\n\t\t  trans->TransName);\n\n\t\tcontinue;\n\t    }\n\t}\n\n\tprmsg (5,\n\t\"MakeAllCLTSServerListeners: opened listener for %s, %d\\n\",\n\t      trans->TransName, ciptr->fd);\n\ttemp_ciptrs[*count_ret] = ciptr;\n\t(*count_ret)++;\n    }\n\n    *partial = (*count_ret < complete_network_count());\n\n    prmsg (5,\n     \"MakeAllCLTSServerListeners: partial=%d, actual=%d, complete=%d \\n\",\n\t*partial, *count_ret, complete_network_count());\n\n    if (*count_ret > 0)\n    {\n\tif ((*ciptrs_ret = malloc (\n\t    *count_ret * sizeof (XtransConnInfo))) == NULL)\n\t{\n\t    return -1;\n\t}\n\n\tfor (i = 0; i < *count_ret; i++)\n\t{\n\t    (*ciptrs_ret)[i] = temp_ciptrs[i];\n\t}\n    }\n    else\n\t*ciptrs_ret = NULL;\n\n    return 0;\n}\n\n#endif /* TRANS_SERVER */\n\n\n\f\n/*\n * These routines are not part of the X Transport Interface, but they\n * may be used by it.\n */\n\n\n#if defined(SYSV) && defined(__i386__) && !defined(__SCO__) && !defined(sun) || defined(WIN32)\n\n/*\n * emulate readv\n */\n\nstatic int TRANS(ReadV) (XtransConnInfo ciptr, struct iovec *iov, int iovcnt)\n\n{\n    int i, len, total;\n    char *base;\n\n    ESET(0);\n    for (i = 0, total = 0;  i < iovcnt;  i++, iov++) {\n\tlen = iov->iov_len;\n\tbase = iov->iov_base;\n\twhile (len > 0) {\n\t    register int nbytes;\n\t    nbytes = TRANS(Read) (ciptr, base, len);\n\t    if (nbytes < 0 && total == 0)  return -1;\n\t    if (nbytes <= 0)  return total;\n\t    ESET(0);\n\t    len   -= nbytes;\n\t    total += nbytes;\n\t    base  += nbytes;\n\t}\n    }\n    return total;\n}\n\n#endif /* SYSV && __i386__ || WIN32 || __sxg__ */\n\n#if defined(SYSV) && defined(__i386__) && !defined(__SCO__) && !defined(sun) || defined(WIN32)\n\n/*\n * emulate writev\n */\n\nstatic int TRANS(WriteV) (XtransConnInfo ciptr, struct iovec *iov, int iovcnt)\n\n{\n    int i, len, total;\n    char *base;\n\n    ESET(0);\n    for (i = 0, total = 0;  i < iovcnt;  i++, iov++) {\n\tlen = iov->iov_len;\n\tbase = iov->iov_base;\n\twhile (len > 0) {\n\t    register int nbytes;\n\t    nbytes = TRANS(Write) (ciptr, base, len);\n\t    if (nbytes < 0 && total == 0)  return -1;\n\t    if (nbytes <= 0)  return total;\n\t    ESET(0);\n\t    len   -= nbytes;\n\t    total += nbytes;\n\t    base  += nbytes;\n\t}\n    }\n    return total;\n}\n\n#endif /* SYSV && __i386__ || WIN32 || __sxg__ */\n\n\n#if defined(_POSIX_SOURCE) || defined(USG) || defined(SVR4) || defined(__SVR4) || defined(__SCO__)\n#ifndef NEED_UTSNAME\n#define NEED_UTSNAME\n#endif\n#include <sys/utsname.h>\n#endif\n\n/*\n * TRANS(GetHostname) - similar to gethostname but allows special processing.\n */\n\nint TRANS(GetHostname) (char *buf, int maxlen)\n\n{\n    int len;\n\n#ifdef NEED_UTSNAME\n    struct utsname name;\n\n    uname (&name);\n    len = strlen (name.nodename);\n    if (len >= maxlen) len = maxlen - 1;\n    strncpy (buf, name.nodename, len);\n    buf[len] = '\\0';\n#else\n    buf[0] = '\\0';\n    (void) gethostname (buf, maxlen);\n    buf [maxlen - 1] = '\\0';\n    len = strlen(buf);\n#endif /* NEED_UTSNAME */\n    return len;\n}\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/X11/Xtrans/Xtrans.h",
    "content": "/*\n\nCopyright 1993, 1994, 1998  The Open Group\n\nPermission to use, copy, modify, distribute, and sell this software and its\ndocumentation for any purpose is hereby granted without fee, provided that\nthe above copyright notice appear in all copies and that both that\ncopyright notice and this permission notice appear in supporting\ndocumentation.\n\nThe above copyright notice and this permission notice shall be included\nin all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\nOR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR\nOTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,\nARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\nOTHER DEALINGS IN THE SOFTWARE.\n\nExcept as contained in this notice, the name of The Open Group shall\nnot be used in advertising or otherwise to promote the sale, use or\nother dealings in this Software without prior written authorization\nfrom The Open Group.\n\n * Copyright 1993, 1994 NCR Corporation - Dayton, Ohio, USA\n *\n * All Rights Reserved\n *\n * Permission to use, copy, modify, and distribute this software and its\n * documentation for any purpose and without fee is hereby granted, provided\n * that the above copyright notice appear in all copies and that both that\n * copyright notice and this permission notice appear in supporting\n * documentation, and that the name NCR not be used in advertising\n * or publicity pertaining to distribution of the software without specific,\n * written prior permission.  NCR makes no representations about the\n * suitability of this software for any purpose.  It is provided \"as is\"\n * without express or implied warranty.\n *\n * NCR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,\n * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN\n * NO EVENT SHALL NCR BE LIABLE FOR ANY SPECIAL, INDIRECT OR\n * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS\n * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,\n * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN\n * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n */\n\n#ifndef _XTRANS_H_\n#define _XTRANS_H_\n\n#include <X11/Xfuncproto.h>\n#include <X11/Xos.h>\n\n#ifndef WIN32\n#include <sys/socket.h>\n#endif\n\n#ifdef __clang__\n/* Not all clients make use of all provided statics */\n#pragma clang diagnostic push\n#pragma clang diagnostic ignored \"-Wunused-function\"\n#endif\n\n/*\n * Set the functions names according to where this code is being compiled.\n */\n\n#ifdef X11_t\n#define TRANS(func) _X11Trans##func\n#ifdef XTRANSDEBUG\nstatic const char *__xtransname = \"_X11Trans\";\n#endif\n#endif /* X11_t */\n\n#ifdef XSERV_t\n#define TRANS(func) _XSERVTrans##func\n#ifdef XTRANSDEBUG\nstatic const char *__xtransname = \"_XSERVTrans\";\n#endif\n#define X11_t\n#endif /* XSERV_t */\n\n#ifdef XIM_t\n#define TRANS(func) _XimXTrans##func\n#ifdef XTRANSDEBUG\nstatic const char *__xtransname = \"_XimTrans\";\n#endif\n#endif /* XIM_t */\n\n#ifdef FS_t\n#define TRANS(func) _FSTrans##func\n#ifdef XTRANSDEBUG\nstatic const char *__xtransname = \"_FSTrans\";\n#endif\n#endif /* FS_t */\n\n#ifdef FONT_t\n#define TRANS(func) _FontTrans##func\n#ifdef XTRANSDEBUG\nstatic const char *__xtransname = \"_FontTrans\";\n#endif\n#endif /* FONT_t */\n\n#ifdef ICE_t\n#define TRANS(func) _IceTrans##func\n#ifdef XTRANSDEBUG\nstatic const char *__xtransname = \"_IceTrans\";\n#endif\n#endif /* ICE_t */\n\n#ifdef TEST_t\n#define TRANS(func) _TESTTrans##func\n#ifdef XTRANSDEBUG\nstatic const char *__xtransname = \"_TESTTrans\";\n#endif\n#endif /* TEST_t */\n\n#ifdef LBXPROXY_t\n#define TRANS(func) _LBXPROXYTrans##func\n#define X11_t\t\t/* The server defines this - so should the LBX proxy */\n#ifdef XTRANSDEBUG\nstatic const char *__xtransname = \"_LBXPROXYTrans\";\n#endif\n#endif /* LBXPROXY_t */\n\n#if !defined(TRANS)\n#define TRANS(func) _XTrans##func\n#ifdef XTRANSDEBUG\nstatic const char *__xtransname = \"_XTrans\";\n#endif\n#endif /* !TRANS */\n\n#ifdef __clang__\n#pragma clang diagnostic pop\n#endif\n\n/*\n * Create a single address structure that can be used wherever\n * an address structure is needed. struct sockaddr is not big enough\n * to hold a sockadd_un, so we create this definition to have a single\n * structure that is big enough for all the structures we might need.\n *\n * This structure needs to be independent of the socket/TLI interface used.\n */\n\n#if defined(IPv6) && defined(AF_INET6)\ntypedef struct sockaddr_storage Xtransaddr;\n#else\n#define XTRANS_MAX_ADDR_LEN\t128\t/* large enough to hold sun_path */\n\ntypedef\tstruct {\n    unsigned char\taddr[XTRANS_MAX_ADDR_LEN];\n} Xtransaddr;\n#endif\n\n#ifdef LONG64\ntypedef int BytesReadable_t;\n#else\ntypedef long BytesReadable_t;\n#endif\n\n\n#if defined(WIN32) || defined(USG)\n\n/*\n *      TRANS(Readv) and TRANS(Writev) use struct iovec, normally found\n *      in Berkeley systems in <sys/uio.h>.  See the readv(2) and writev(2)\n *      manual pages for details.\n */\n\nstruct iovec {\n    caddr_t iov_base;\n    int iov_len;\n};\n\n#else\n#include <sys/uio.h>\n#endif\n\ntypedef struct _XtransConnInfo *XtransConnInfo;\n\n\n/*\n * Transport Option definitions\n */\n\n#define TRANS_NONBLOCKING\t1\n#define\tTRANS_CLOSEONEXEC\t2\n\n\n/*\n * Return values of Connect (0 is success)\n */\n\n#define TRANS_CONNECT_FAILED \t-1\n#define TRANS_TRY_CONNECT_AGAIN -2\n#define TRANS_IN_PROGRESS\t-3\n\n\n/*\n * Return values of CreateListener (0 is success)\n */\n\n#define TRANS_CREATE_LISTENER_FAILED \t-1\n#define TRANS_ADDR_IN_USE\t\t-2\n\n\n/*\n * Return values of Accept (0 is success)\n */\n\n#define TRANS_ACCEPT_BAD_MALLOC\t\t\t-1\n#define TRANS_ACCEPT_FAILED \t\t\t-2\n#define TRANS_ACCEPT_MISC_ERROR\t\t\t-3\n\n\n/*\n * ResetListener return values\n */\n\n#define TRANS_RESET_NOOP\t1\n#define TRANS_RESET_NEW_FD\t2\n#define TRANS_RESET_FAILURE\t3\n\n\n/*\n * Function prototypes for the exposed interface\n */\n\nvoid TRANS(FreeConnInfo) (\n    XtransConnInfo \t/* ciptr */\n);\n\n#ifdef TRANS_CLIENT\n\nXtransConnInfo TRANS(OpenCOTSClient)(\n    const char *\t/* address */\n);\n\n#endif /* TRANS_CLIENT */\n\n#ifdef TRANS_SERVER\n\nXtransConnInfo TRANS(OpenCOTSServer)(\n    const char *\t/* address */\n);\n\n#endif /* TRANS_SERVER */\n\n#ifdef TRANS_CLIENT\n\nXtransConnInfo TRANS(OpenCLTSClient)(\n    const char *\t/* address */\n);\n\n#endif /* TRANS_CLIENT */\n\n#ifdef TRANS_SERVER\n\nXtransConnInfo TRANS(OpenCLTSServer)(\n    const char *\t/* address */\n);\n\n#endif /* TRANS_SERVER */\n\n#ifdef TRANS_REOPEN\n\nXtransConnInfo TRANS(ReopenCOTSServer)(\n    int,\t\t/* trans_id */\n    int,\t\t/* fd */\n    const char *\t/* port */\n);\n\nXtransConnInfo TRANS(ReopenCLTSServer)(\n    int,\t\t/* trans_id */\n    int,\t\t/* fd */\n    const char *\t/* port */\n);\n\nint TRANS(GetReopenInfo)(\n    XtransConnInfo,\t/* ciptr */\n    int *,\t\t/* trans_id */\n    int *,\t\t/* fd */\n    char **\t\t/* port */\n);\n\n#endif /* TRANS_REOPEN */\n\n\nint TRANS(SetOption)(\n    XtransConnInfo,\t/* ciptr */\n    int,\t\t/* option */\n    int\t\t\t/* arg */\n);\n\n#ifdef TRANS_SERVER\n\nint TRANS(CreateListener)(\n    XtransConnInfo,\t/* ciptr */\n    const char *,\t/* port */\n    unsigned int\t/* flags */\n);\n\nint TRANS(Received) (\n    const char*         /* protocol*/\n);\n\nint TRANS(NoListen) (\n    const char*         /* protocol*/\n);\n\nint TRANS(Listen) (\n    const char*         /* protocol*/\n);\n\nint TRANS(IsListening) (\n    const char*         /* protocol*/\n);\n\nint TRANS(ResetListener)(\n    XtransConnInfo\t/* ciptr */\n);\n\nXtransConnInfo TRANS(Accept)(\n    XtransConnInfo,\t/* ciptr */\n    int *\t\t/* status */\n);\n\n#endif /* TRANS_SERVER */\n\n#ifdef TRANS_CLIENT\n\nint TRANS(Connect)(\n    XtransConnInfo,\t/* ciptr */\n    const char *\t/* address */\n);\n\n#endif /* TRANS_CLIENT */\n\nint TRANS(BytesReadable)(\n    XtransConnInfo,\t/* ciptr */\n    BytesReadable_t *\t/* pend */\n);\n\nint TRANS(Read)(\n    XtransConnInfo,\t/* ciptr */\n    char *,\t\t/* buf */\n    int\t\t\t/* size */\n);\n\nint TRANS(Write)(\n    XtransConnInfo,\t/* ciptr */\n    char *,\t\t/* buf */\n    int\t\t\t/* size */\n);\n\nint TRANS(Readv)(\n    XtransConnInfo,\t/* ciptr */\n    struct iovec *,\t/* buf */\n    int\t\t\t/* size */\n);\n\nint TRANS(Writev)(\n    XtransConnInfo,\t/* ciptr */\n    struct iovec *,\t/* buf */\n    int\t\t\t/* size */\n);\n\nint TRANS(SendFd) (XtransConnInfo ciptr, int fd, int do_close);\n\nint TRANS(RecvFd) (XtransConnInfo ciptr);\n\nint TRANS(Disconnect)(\n    XtransConnInfo\t/* ciptr */\n);\n\nint TRANS(Close)(\n    XtransConnInfo\t/* ciptr */\n);\n\nint TRANS(CloseForCloning)(\n    XtransConnInfo\t/* ciptr */\n);\n\nint TRANS(IsLocal)(\n    XtransConnInfo\t/* ciptr */\n);\n\nint TRANS(GetMyAddr)(\n    XtransConnInfo,\t/* ciptr */\n    int *,\t\t/* familyp */\n    int *,\t\t/* addrlenp */\n    Xtransaddr **\t/* addrp */\n);\n\nint TRANS(GetPeerAddr)(\n    XtransConnInfo,\t/* ciptr */\n    int *,\t\t/* familyp */\n    int *,\t\t/* addrlenp */\n    Xtransaddr **\t/* addrp */\n);\n\nint TRANS(GetConnectionNumber)(\n    XtransConnInfo\t/* ciptr */\n);\n\n#ifdef TRANS_SERVER\n\nint TRANS(MakeAllCOTSServerListeners)(\n    const char *,\t/* port */\n    int *,\t\t/* partial */\n    int *,\t\t/* count_ret */\n    XtransConnInfo **\t/* ciptrs_ret */\n);\n\nint TRANS(MakeAllCLTSServerListeners)(\n    const char *,\t/* port */\n    int *,\t\t/* partial */\n    int *,\t\t/* count_ret */\n    XtransConnInfo **\t/* ciptrs_ret */\n);\n\n#endif /* TRANS_SERVER */\n\n\n/*\n * Function Prototypes for Utility Functions.\n */\n\n#ifdef X11_t\n\nint TRANS(ConvertAddress)(\n    int *,\t\t/* familyp */\n    int *,\t\t/* addrlenp */\n    Xtransaddr **\t/* addrp */\n);\n\n#endif /* X11_t */\n\n#ifdef ICE_t\n\nchar *\nTRANS(GetMyNetworkId)(\n    XtransConnInfo\t/* ciptr */\n);\n\nchar *\nTRANS(GetPeerNetworkId)(\n    XtransConnInfo\t/* ciptr */\n);\n\n#endif /* ICE_t */\n\nint\nTRANS(GetHostname) (\n    char *\t/* buf */,\n    int \t/* maxlen */\n);\n\n#if defined(WIN32) && defined(TCPCONN)\nint TRANS(WSAStartup)();\n#endif\n\n#endif /* _XTRANS_H_ */\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/X11/Xtrans/Xtransint.h",
    "content": "/*\n\nCopyright 1993, 1994, 1998  The Open Group\n\nPermission to use, copy, modify, distribute, and sell this software and its\ndocumentation for any purpose is hereby granted without fee, provided that\nthe above copyright notice appear in all copies and that both that\ncopyright notice and this permission notice appear in supporting\ndocumentation.\n\nThe above copyright notice and this permission notice shall be included\nin all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\nOR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR\nOTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,\nARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\nOTHER DEALINGS IN THE SOFTWARE.\n\nExcept as contained in this notice, the name of The Open Group shall\nnot be used in advertising or otherwise to promote the sale, use or\nother dealings in this Software without prior written authorization\nfrom The Open Group.\n\n * Copyright 1993, 1994 NCR Corporation - Dayton, Ohio, USA\n *\n * All Rights Reserved\n *\n * Permission to use, copy, modify, and distribute this software and its\n * documentation for any purpose and without fee is hereby granted, provided\n * that the above copyright notice appear in all copies and that both that\n * copyright notice and this permission notice appear in supporting\n * documentation, and that the name NCR not be used in advertising\n * or publicity pertaining to distribution of the software without specific,\n * written prior permission.  NCR makes no representations about the\n * suitability of this software for any purpose.  It is provided \"as is\"\n * without express or implied warranty.\n *\n * NCR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,\n * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN\n * NO EVENT SHALL NCR BE LIABLE FOR ANY SPECIAL, INDIRECT OR\n * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS\n * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,\n * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN\n * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n */\n\n#ifndef _XTRANSINT_H_\n#define _XTRANSINT_H_\n\n/*\n * XTRANSDEBUG will enable the PRMSG() macros used in the X Transport\n * Interface code. Each use of the PRMSG macro has a level associated with\n * it. XTRANSDEBUG is defined to be a level. If the invocation level is =<\n * the value of XTRANSDEBUG, then the message will be printed out to stderr.\n * Recommended levels are:\n *\n *\tXTRANSDEBUG=1\tError messages\n *\tXTRANSDEBUG=2 API Function Tracing\n *\tXTRANSDEBUG=3 All Function Tracing\n *\tXTRANSDEBUG=4 printing of intermediate values\n *\tXTRANSDEBUG=5 really detailed stuff\n#define XTRANSDEBUG 2\n *\n * Defining XTRANSDEBUGTIMESTAMP will cause printing timestamps with each\n * message.\n */\n\n#if !defined(XTRANSDEBUG) && defined(XTRANS_TRANSPORT_C)\n#  define XTRANSDEBUG 1\n#endif\n\n#ifdef WIN32\n# define _WILLWINSOCK_\n#endif\n\n#include \"Xtrans.h\"\n\n#ifndef _X_UNUSED  /* Defined in Xfuncproto.h in xproto >= 7.0.22 */\n# define _X_UNUSED  /* */\n#endif\n\n#ifdef XTRANSDEBUG\n# include <stdio.h>\n#endif /* XTRANSDEBUG */\n\n#include <errno.h>\n\n#ifndef WIN32\n#  include <sys/socket.h>\n# include <netinet/in.h>\n# include <arpa/inet.h>\n\n/*\n * Moved the setting of NEED_UTSNAME to this header file from Xtrans.c,\n * to avoid a race condition. JKJ (6/5/97)\n */\n\n# if defined(_POSIX_SOURCE) || defined(USG) || defined(SVR4) || defined(__SVR4) || defined(__SCO__)\n#  ifndef NEED_UTSNAME\n#   define NEED_UTSNAME\n#  endif\n#  include <sys/utsname.h>\n# endif\n\n#  define ESET(val) errno = val\n# define EGET() errno\n\n#else /* WIN32 */\n\n# include <limits.h>\t/* for USHRT_MAX */\n\n# define ESET(val) WSASetLastError(val)\n# define EGET() WSAGetLastError()\n\n#endif /* WIN32 */\n\n#include <stddef.h>\n\n#ifdef X11_t\n#define X_TCP_PORT\t6000\n#endif\n\n#if XTRANS_SEND_FDS\n\nstruct _XtransConnFd {\n    struct _XtransConnFd   *next;\n    int                    fd;\n    int                    do_close;\n};\n\n#endif\n\nstruct _XtransConnInfo {\n    struct _Xtransport     *transptr;\n    int\t\tindex;\n    char\t*priv;\n    int\t\tflags;\n    int\t\tfd;\n    char\t*port;\n    int\t\tfamily;\n    char\t*addr;\n    int\t\taddrlen;\n    char\t*peeraddr;\n    int\t\tpeeraddrlen;\n    struct _XtransConnFd        *recv_fds;\n    struct _XtransConnFd        *send_fds;\n};\n\n#define XTRANS_OPEN_COTS_CLIENT       1\n#define XTRANS_OPEN_COTS_SERVER       2\n#define XTRANS_OPEN_CLTS_CLIENT       3\n#define XTRANS_OPEN_CLTS_SERVER       4\n\n\ntypedef struct _Xtransport {\n    const char\t*TransName;\n    int\t\tflags;\n\n#ifdef TRANS_CLIENT\n\n    XtransConnInfo (*OpenCOTSClient)(\n\tstruct _Xtransport *,\t/* transport */\n\tconst char *,\t\t/* protocol */\n\tconst char *,\t\t/* host */\n\tconst char *\t\t/* port */\n    );\n\n#endif /* TRANS_CLIENT */\n\n#ifdef TRANS_SERVER\n    const char **\tnolisten;\n    XtransConnInfo (*OpenCOTSServer)(\n\tstruct _Xtransport *,\t/* transport */\n\tconst char *,\t\t/* protocol */\n\tconst char *,\t\t/* host */\n\tconst char *\t\t/* port */\n    );\n\n#endif /* TRANS_SERVER */\n\n#ifdef TRANS_CLIENT\n\n    XtransConnInfo (*OpenCLTSClient)(\n\tstruct _Xtransport *,\t/* transport */\n\tconst char *,\t\t/* protocol */\n\tconst char *,\t\t/* host */\n\tconst char *\t\t/* port */\n    );\n\n#endif /* TRANS_CLIENT */\n\n#ifdef TRANS_SERVER\n\n    XtransConnInfo (*OpenCLTSServer)(\n\tstruct _Xtransport *,\t/* transport */\n\tconst char *,\t\t/* protocol */\n\tconst char *,\t\t/* host */\n\tconst char *\t\t/* port */\n    );\n\n#endif /* TRANS_SERVER */\n\n\n#ifdef TRANS_REOPEN\n\n    XtransConnInfo (*ReopenCOTSServer)(\n\tstruct _Xtransport *,\t/* transport */\n        int,\t\t\t/* fd */\n        const char *\t\t/* port */\n    );\n\n    XtransConnInfo (*ReopenCLTSServer)(\n\tstruct _Xtransport *,\t/* transport */\n        int,\t\t\t/* fd */\n        const char *\t\t/* port */\n    );\n\n#endif /* TRANS_REOPEN */\n\n\n    int\t(*SetOption)(\n\tXtransConnInfo,\t\t/* connection */\n\tint,\t\t\t/* option */\n\tint\t\t\t/* arg */\n    );\n\n#ifdef TRANS_SERVER\n/* Flags */\n# define ADDR_IN_USE_ALLOWED\t1\n\n    int\t(*CreateListener)(\n\tXtransConnInfo,\t\t/* connection */\n\tconst char *,\t\t/* port */\n\tunsigned int\t\t/* flags */\n    );\n\n    int\t(*ResetListener)(\n\tXtransConnInfo\t\t/* connection */\n    );\n\n    XtransConnInfo (*Accept)(\n\tXtransConnInfo,\t\t/* connection */\n        int *\t\t\t/* status */\n    );\n\n#endif /* TRANS_SERVER */\n\n#ifdef TRANS_CLIENT\n\n    int\t(*Connect)(\n\tXtransConnInfo,\t\t/* connection */\n\tconst char *,\t\t/* host */\n\tconst char *\t\t/* port */\n    );\n\n#endif /* TRANS_CLIENT */\n\n    int\t(*BytesReadable)(\n\tXtransConnInfo,\t\t/* connection */\n\tBytesReadable_t *\t/* pend */\n    );\n\n    int\t(*Read)(\n\tXtransConnInfo,\t\t/* connection */\n\tchar *,\t\t\t/* buf */\n\tint\t\t\t/* size */\n    );\n\n    int\t(*Write)(\n\tXtransConnInfo,\t\t/* connection */\n\tchar *,\t\t\t/* buf */\n\tint\t\t\t/* size */\n    );\n\n    int\t(*Readv)(\n\tXtransConnInfo,\t\t/* connection */\n\tstruct iovec *,\t\t/* buf */\n\tint\t\t\t/* size */\n    );\n\n    int\t(*Writev)(\n\tXtransConnInfo,\t\t/* connection */\n\tstruct iovec *,\t\t/* buf */\n\tint\t\t\t/* size */\n    );\n\n#if XTRANS_SEND_FDS\n    int (*SendFd)(\n\tXtransConnInfo,\t\t/* connection */\n        int,                    /* fd */\n        int                     /* do_close */\n    );\n\n    int (*RecvFd)(\n\tXtransConnInfo\t\t/* connection */\n    );\n#endif\n\n    int\t(*Disconnect)(\n\tXtransConnInfo\t\t/* connection */\n    );\n\n    int\t(*Close)(\n\tXtransConnInfo\t\t/* connection */\n    );\n\n    int\t(*CloseForCloning)(\n\tXtransConnInfo\t\t/* connection */\n    );\n\n} Xtransport;\n\n\ntypedef struct _Xtransport_table {\n    Xtransport\t*transport;\n    int\t\ttransport_id;\n} Xtransport_table;\n\n\n/*\n * Flags for the flags member of Xtransport.\n */\n\n#define TRANS_ALIAS\t(1<<0)\t/* record is an alias, don't create server */\n#define TRANS_LOCAL\t(1<<1)\t/* local transport */\n#define TRANS_DISABLED\t(1<<2)\t/* Don't open this one */\n#define TRANS_NOLISTEN  (1<<3)  /* Don't listen on this one */\n#define TRANS_NOUNLINK\t(1<<4)\t/* Don't unlink transport endpoints */\n#define TRANS_ABSTRACT\t(1<<5)\t/* Use abstract sockets if available */\n#define TRANS_NOXAUTH\t(1<<6)\t/* Don't verify authentication (because it's secure some other way at the OS layer) */\n#define TRANS_RECEIVED\t(1<<7)  /* The fd for this has already been opened by someone else. */\n\n/* Flags to preserve when setting others */\n#define TRANS_KEEPFLAGS\t(TRANS_NOUNLINK|TRANS_ABSTRACT)\n\n#ifdef XTRANS_TRANSPORT_C /* only provide static function prototypes when\n\t\t\t     building the transport.c file that has them in */\n\n#ifdef __clang__\n/* Not all clients make use of all provided statics */\n#pragma clang diagnostic push\n#pragma clang diagnostic ignored \"-Wunused-function\"\n#endif\n\n/*\n * readv() and writev() don't exist or don't work correctly on some\n * systems, so they may be emulated.\n */\n\n#if defined(SYSV) && defined(__i386__) && !defined(__SCO__) && !defined(sun) || defined(WIN32)\n\n#define READV(ciptr, iov, iovcnt)\tTRANS(ReadV)(ciptr, iov, iovcnt)\n\nstatic\tint TRANS(ReadV)(\n    XtransConnInfo,\t/* ciptr */\n    struct iovec *,\t/* iov */\n    int\t\t\t/* iovcnt */\n);\n\n#else\n\n#define READV(ciptr, iov, iovcnt)\treadv(ciptr->fd, iov, iovcnt)\n\n#endif /* CRAY || (SYSV && __i386__) || WIN32 || __sxg__ || */\n\n\n#if defined(SYSV) && defined(__i386__) && !defined(__SCO__) && !defined(sun) || defined(WIN32)\n\n#define WRITEV(ciptr, iov, iovcnt)\tTRANS(WriteV)(ciptr, iov, iovcnt)\n\nstatic int TRANS(WriteV)(\n    XtransConnInfo,\t/* ciptr */\n    struct iovec *,\t/* iov */\n    int \t\t/* iovcnt */\n);\n\n#else\n\n#define WRITEV(ciptr, iov, iovcnt)\twritev(ciptr->fd, iov, iovcnt)\n\n#endif /* CRAY || WIN32 || __sxg__ */\n\n\nstatic int is_numeric (\n    const char *\t/* str */\n);\n\n#ifdef TRANS_SERVER\nstatic int trans_mkdir (\n    const char *,\t/* path */\n    int\t\t\t/* mode */\n);\n#endif\n\n#ifdef __clang__\n#pragma clang diagnostic pop\n#endif\n\n/*\n * Some XTRANSDEBUG stuff\n */\n\n#ifdef XTRANSDEBUG\n#include <stdarg.h>\n\n/*\n * The X server provides ErrorF() & VErrorF(), for other software that uses\n * xtrans, we provide our own simple versions.\n */\n# if defined(XSERV_t) && defined(TRANS_SERVER)\n#  include \"os.h\"\n# else\nstatic inline void _X_ATTRIBUTE_PRINTF(1, 0)\nVErrorF(const char *f, va_list args)\n{\n    vfprintf(stderr, f, args);\n    fflush(stderr);\n}\n\nstatic inline void  _X_ATTRIBUTE_PRINTF(1, 2)\nErrorF(const char *f, ...)\n{\n    va_list args;\n\n    va_start(args, f);\n    VErrorF(f, args);\n    va_end(args);\n}\n# endif /* xserver */\n#endif /* XTRANSDEBUG */\n\nstatic inline void  _X_ATTRIBUTE_PRINTF(2, 3)\nprmsg(int lvl, const char *f, ...)\n{\n#ifdef XTRANSDEBUG\n    va_list args;\n\n    va_start(args, f);\n    if (lvl <= XTRANSDEBUG) {\n\tint saveerrno = errno;\n\n\tErrorF(\"%s\", __xtransname);\n\tVErrorF(f, args);\n\n# ifdef XTRANSDEBUGTIMESTAMP\n\t{\n\t    struct timeval tp;\n\t    gettimeofday(&tp, 0);\n\t    ErrorF(\"timestamp (ms): %d\\n\",\n\t\t   tp.tv_sec * 1000 + tp.tv_usec / 1000);\n\t}\n# endif\n\terrno = saveerrno;\n    }\n    va_end(args);\n#endif /* XTRANSDEBUG */\n}\n\n#endif /* XTRANS_TRANSPORT_C */\n\n#endif /* _XTRANSINT_H_ */\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/X11/Xtrans/Xtranslcl.c",
    "content": "/*\n\nCopyright 1993, 1994, 1998  The Open Group\n\nPermission to use, copy, modify, distribute, and sell this software and its\ndocumentation for any purpose is hereby granted without fee, provided that\nthe above copyright notice appear in all copies and that both that\ncopyright notice and this permission notice appear in supporting\ndocumentation.\n\nThe above copyright notice and this permission notice shall be included\nin all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\nOR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR\nOTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,\nARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\nOTHER DEALINGS IN THE SOFTWARE.\n\nExcept as contained in this notice, the name of The Open Group shall\nnot be used in advertising or otherwise to promote the sale, use or\nother dealings in this Software without prior written authorization\nfrom The Open Group.\n\n * Copyright 1993, 1994 NCR Corporation - Dayton, Ohio, USA\n *\n * All Rights Reserved\n *\n * Permission to use, copy, modify, and distribute this software and its\n * documentation for any purpose and without fee is hereby granted, provided\n * that the above copyright notice appear in all copies and that both that\n * copyright notice and this permission notice appear in supporting\n * documentation, and that the name NCR not be used in advertising\n * or publicity pertaining to distribution of the software without specific,\n * written prior permission.  NCR makes no representations about the\n * suitability of this software for any purpose.  It is provided \"as is\"\n * without express or implied warranty.\n *\n * NCR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,\n * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN\n * NO EVENT SHALL NCR BE LIABLE FOR ANY SPECIAL, INDIRECT OR\n * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS\n * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,\n * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN\n * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n */\n\n/*\n *\n * The connection code/ideas in lib/X and server/os for SVR4/Intel\n * environments was contributed by the following companies/groups:\n *\n *\tMetroLink Inc\n *\tNCR\n *\tPittsburgh Powercomputing Corporation (PPc)/Quarterdeck Office Systems\n *\tSGCS\n *\tUnix System Laboratories (USL) / Novell\n *\tXFree86\n *\n * The goal is to have common connection code among all SVR4/Intel vendors.\n *\n * ALL THE ABOVE COMPANIES DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS\n * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,\n * IN NO EVENT SHALL THESE COMPANIES * BE LIABLE FOR ANY SPECIAL, INDIRECT\n * OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS\n * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE\n * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE\n * OR PERFORMANCE OF THIS SOFTWARE.\n */\n\n#include <errno.h>\n#include <ctype.h>\n#include <sys/signal.h>\n#include <sys/ioctl.h>\n#include <sys/stat.h>\n#if defined(SVR4) || defined(__SVR4)\n#include <sys/filio.h>\n#endif\n#ifdef sun\n# include <stropts.h>\n#else\n# include <sys/stropts.h>\n#endif\n#include <sys/wait.h>\n#include <sys/types.h>\n\n/*\n * The local transports should be treated the same as a UNIX domain socket\n * wrt authentication, etc. Because of this, we will use struct sockaddr_un\n * for the address format. This will simplify the code in other places like\n * The X Server.\n */\n\n#include <sys/socket.h>\n#ifndef X_NO_SYS_UN\n#include <sys/un.h>\n#endif\n\n\n/* Types of local connections supported:\n *  - PTS\n *  - named pipes\n *  - SCO\n */\n#if !defined(sun)\n# define LOCAL_TRANS_PTS\n#endif\n#if defined(SVR4) || defined(__SVR4)\n# define LOCAL_TRANS_NAMED\n#endif\n#if defined(__SCO__) || defined(__UNIXWARE__)\n# define LOCAL_TRANS_SCO\n#endif\n\nstatic int TRANS(LocalClose)(XtransConnInfo ciptr);\n\n/*\n * These functions actually implement the local connection mechanisms.\n */\n\n/* Type Not Supported */\n\nstatic int\nTRANS(OpenFail)(XtransConnInfo ciptr _X_UNUSED, const char *port _X_UNUSED)\n\n{\n    return -1;\n}\n\n#ifdef TRANS_REOPEN\n\nstatic int\nTRANS(ReopenFail)(XtransConnInfo ciptr _X_UNUSED, int fd _X_UNUSED,\n                  const char *port _X_UNUSED)\n\n{\n    return 0;\n}\n\n#endif /* TRANS_REOPEN */\n\n#if XTRANS_SEND_FDS\nstatic int\nTRANS(LocalRecvFdInvalid)(XtransConnInfo ciptr)\n{\n    errno = EINVAL;\n    return -1;\n}\n\nstatic int\nTRANS(LocalSendFdInvalid)(XtransConnInfo ciptr, int fd, int do_close)\n{\n    errno = EINVAL;\n    return -1;\n}\n#endif\n\n\f\nstatic int\nTRANS(FillAddrInfo)(XtransConnInfo ciptr,\n                    const char *sun_path, const char *peer_sun_path)\n\n{\n    struct sockaddr_un\t*sunaddr;\n    struct sockaddr_un\t*p_sunaddr;\n\n    ciptr->family = AF_UNIX;\n    ciptr->addrlen = sizeof (struct sockaddr_un);\n\n    if ((sunaddr = malloc (ciptr->addrlen)) == NULL)\n    {\n\tprmsg(1,\"FillAddrInfo: failed to allocate memory for addr\\n\");\n\treturn 0;\n    }\n\n    sunaddr->sun_family = AF_UNIX;\n\n    if (strlen(sun_path) > sizeof(sunaddr->sun_path) - 1) {\n\tprmsg(1, \"FillAddrInfo: path too long\\n\");\n\tfree((char *) sunaddr);\n\treturn 0;\n    }\n    strcpy (sunaddr->sun_path, sun_path);\n#if defined(BSD44SOCKETS)\n    sunaddr->sun_len = strlen (sunaddr->sun_path);\n#endif\n\n    ciptr->addr = (char *) sunaddr;\n\n    ciptr->peeraddrlen = sizeof (struct sockaddr_un);\n\n    if ((p_sunaddr = malloc (ciptr->peeraddrlen)) == NULL)\n    {\n\tprmsg(1,\n\t   \"FillAddrInfo: failed to allocate memory for peer addr\\n\");\n\tfree (sunaddr);\n\tciptr->addr = NULL;\n\n\treturn 0;\n    }\n\n    p_sunaddr->sun_family = AF_UNIX;\n\n    if (strlen(peer_sun_path) > sizeof(p_sunaddr->sun_path) - 1) {\n\tprmsg(1, \"FillAddrInfo: peer path too long\\n\");\n\tfree((char *) p_sunaddr);\n\treturn 0;\n    }\n    strcpy (p_sunaddr->sun_path, peer_sun_path);\n#if defined(BSD44SOCKETS)\n    p_sunaddr->sun_len = strlen (p_sunaddr->sun_path);\n#endif\n\n    ciptr->peeraddr = (char *) p_sunaddr;\n\n    return 1;\n}\n\n\n\f\n#ifdef LOCAL_TRANS_PTS\n/* PTS */\n\n#if defined(SYSV) && !defined(__SCO__)\n#define SIGNAL_T int\n#else\n#define SIGNAL_T void\n#endif /* SYSV */\n\ntypedef SIGNAL_T (*PFV)();\n\nextern PFV signal();\n\nextern char *ptsname(\n    int\n);\n\nstatic void _dummy(int sig _X_UNUSED)\n\n{\n}\n#endif /* LOCAL_TRANS_PTS */\n\n#ifndef sun\n#define X_STREAMS_DIR\t\"/dev/X\"\n#define DEV_SPX\t\t\"/dev/spx\"\n#else\n#ifndef X11_t\n#define X_STREAMS_DIR\t\"/dev/X\"\n#else\n#define X_STREAMS_DIR\t\"/tmp/.X11-pipe\"\n#endif\n#endif\n\n#define DEV_PTMX\t\"/dev/ptmx\"\n\n#if defined(X11_t)\n\n#define PTSNODENAME \"/dev/X/server.\"\n#ifdef sun\n#define NAMEDNODENAME \"/tmp/.X11-pipe/X\"\n#else\n#define NAMEDNODENAME \"/dev/X/Nserver.\"\n\n#define SCORNODENAME\t\"/dev/X%1sR\"\n#define SCOSNODENAME\t\"/dev/X%1sS\"\n#endif /* !sun */\n#endif\n#if defined(XIM_t)\n#ifdef sun\n#define NAMEDNODENAME \"/tmp/.XIM-pipe/XIM\"\n#else\n#define PTSNODENAME\t\"/dev/X/XIM.\"\n#define NAMEDNODENAME\t\"/dev/X/NXIM.\"\n#define SCORNODENAME\t\"/dev/XIM.%sR\"\n#define SCOSNODENAME\t\"/dev/XIM.%sS\"\n#endif\n#endif\n#if defined(FS_t) || defined (FONT_t)\n#ifdef sun\n#define NAMEDNODENAME\t\"/tmp/.font-pipe/fs\"\n#else\n/*\n * USL has already defined something here. We need to check with them\n * and see if their choice is usable here.\n */\n#define PTSNODENAME\t\"/dev/X/fontserver.\"\n#define NAMEDNODENAME\t\"/dev/X/Nfontserver.\"\n#define SCORNODENAME\t\"/dev/fontserver.%sR\"\n#define SCOSNODENAME\t\"/dev/fontserver.%sS\"\n#endif\n#endif\n#if defined(ICE_t)\n#ifdef sun\n#define NAMEDNODENAME\t\"/tmp/.ICE-pipe/\"\n#else\n#define PTSNODENAME\t\"/dev/X/ICE.\"\n#define NAMEDNODENAME\t\"/dev/X/NICE.\"\n#define SCORNODENAME\t\"/dev/ICE.%sR\"\n#define SCOSNODENAME\t\"/dev/ICE.%sS\"\n#endif\n#endif\n#if defined(TEST_t)\n#ifdef sun\n#define NAMEDNODENAME\t\"/tmp/.Test-unix/test\"\n#endif\n#define PTSNODENAME\t\"/dev/X/transtest.\"\n#define NAMEDNODENAME\t\"/dev/X/Ntranstest.\"\n#define SCORNODENAME\t\"/dev/transtest.%sR\"\n#define SCOSNODENAME\t\"/dev/transtest.%sS\"\n#endif\n\n\n\f\n#ifdef LOCAL_TRANS_PTS\n#ifdef TRANS_CLIENT\n\nstatic int\nTRANS(PTSOpenClient)(XtransConnInfo ciptr, const char *port)\n\n{\n#ifdef PTSNODENAME\n    int\t\t\tfd,server,exitval,alarm_time,ret;\n    char\t\tserver_path[64];\n    char\t\t*slave, namelen;\n    char\t\tbuf[20]; /* MAX_PATH_LEN?? */\n    PFV\t\t\tsavef;\n    pid_t\t\tsaved_pid;\n#endif\n\n    prmsg(2,\"PTSOpenClient(%s)\\n\", port);\n\n#if !defined(PTSNODENAME)\n    prmsg(1,\"PTSOpenClient: Protocol is not supported by a pts connection\\n\");\n    return -1;\n#else\n    if (port && *port ) {\n\tif( *port == '/' ) { /* A full pathname */\n\t    snprintf(server_path, sizeof(server_path), \"%s\", port);\n\t} else {\n\t    snprintf(server_path, sizeof(server_path), \"%s%s\",\n\t\t     PTSNODENAME, port);\n\t}\n    } else {\n\tsnprintf(server_path, sizeof(server_path), \"%s%d\",\n\t\t PTSNODENAME, getpid());\n    }\n\n\n    /*\n     * Open the node the on which the server is listening.\n     */\n\n    if ((server = open (server_path, O_RDWR)) < 0) {\n\tprmsg(1,\"PTSOpenClient: failed to open %s\\n\", server_path);\n\treturn -1;\n    }\n\n\n    /*\n     * Open the streams based pipe that will be this connection.\n     */\n\n    if ((fd = open(DEV_PTMX, O_RDWR)) < 0) {\n\tprmsg(1,\"PTSOpenClient: failed to open %s\\n\", DEV_PTMX);\n\tclose(server);\n\treturn(-1);\n    }\n\n    (void) grantpt(fd);\n    (void) unlockpt(fd);\n\n    slave = ptsname(fd); /* get name */\n\n    if( slave == NULL ) {\n\tprmsg(1,\"PTSOpenClient: failed to get ptsname()\\n\");\n\tclose(fd);\n\tclose(server);\n\treturn -1;\n    }\n\n    /*\n     * This is neccesary for the case where a program is setuid to non-root.\n     * grantpt() calls /usr/lib/pt_chmod which is set-uid root. This program will\n     * set the owner of the pt device incorrectly if the uid is not restored\n     * before it is called. The problem is that once it gets restored, it\n     * cannot be changed back to its original condition, hence the fork().\n     */\n\n    if(!(saved_pid=fork())) {\n\tuid_t       saved_euid;\n\n\tsaved_euid = geteuid();\n\t/** sets the euid to the actual/real uid **/\n\tif (setuid( getuid() ) == -1) {\n\t\texit(1);\n\t}\n\tif( chown( slave, saved_euid, -1 ) < 0 ) {\n\t\texit( 1 );\n\t\t}\n\n\texit( 0 );\n    }\n\n    waitpid(saved_pid, &exitval, 0);\n    if (WIFEXITED(exitval) && WEXITSTATUS(exitval) != 0) {\n\tclose(fd);\n\tclose(server);\n\tprmsg(1, \"PTSOpenClient: cannot set the owner of %s\\n\",\n\t      slave);\n\treturn(-1);\n    }\n    if (chmod(slave, 0666) < 0) {\n\tclose(fd);\n\tclose(server);\n\tprmsg(1,\"PTSOpenClient: Cannot chmod %s\\n\", slave);\n\treturn(-1);\n    }\n\n    /*\n     * write slave name to server\n     */\n\n    namelen = strlen(slave);\n    buf[0] = namelen;\n    (void) sprintf(&buf[1], slave);\n    (void) write(server, buf, namelen+1);\n    (void) close(server);\n\n    /*\n     * wait for server to respond\n     */\n\n    savef = signal(SIGALRM, _dummy);\n    alarm_time = alarm (30); /* CONNECT_TIMEOUT */\n\n    ret = read(fd, buf, 1);\n\n    (void) alarm(alarm_time);\n    (void) signal(SIGALRM, savef);\n\n    if (ret != 1) {\n\tprmsg(1,\n\t\"PTSOpenClient: failed to get acknoledgement from server\\n\");\n\t(void) close(fd);\n\tfd = -1;\n    }\n\n    /*\n     * Everything looks good: fill in the XtransConnInfo structure.\n     */\n\n    if (TRANS(FillAddrInfo) (ciptr, slave, server_path) == 0)\n    {\n\tprmsg(1,\"PTSOpenClient: failed to fill in addr info\\n\");\n\tclose(fd);\n\treturn -1;\n    }\n\n    return(fd);\n\n#endif /* !PTSNODENAME */\n}\n\n#endif /* TRANS_CLIENT */\n\n\n#ifdef TRANS_SERVER\n\nstatic int\nTRANS(PTSOpenServer)(XtransConnInfo ciptr, const char *port)\n\n{\n#ifdef PTSNODENAME\n    int fd, server;\n    char server_path[64], *slave;\n    int mode;\n#endif\n\n    prmsg(2,\"PTSOpenServer(%s)\\n\", port);\n\n#if !defined(PTSNODENAME)\n    prmsg(1,\"PTSOpenServer: Protocol is not supported by a pts connection\\n\");\n    return -1;\n#else\n    if (port && *port ) {\n\tif( *port == '/' ) { /* A full pathname */\n\t\t(void) sprintf(server_path, \"%s\", port);\n\t    } else {\n\t\t(void) sprintf(server_path, \"%s%s\", PTSNODENAME, port);\n\t    }\n    } else {\n\t(void) sprintf(server_path, \"%s%d\", PTSNODENAME, getpid());\n    }\n\n#ifdef HAS_STICKY_DIR_BIT\n    mode = 01777;\n#else\n    mode = 0777;\n#endif\n    if (trans_mkdir(X_STREAMS_DIR, mode) == -1) {\n\tprmsg (1, \"PTSOpenServer: mkdir(%s) failed, errno = %d\\n\",\n\t       X_STREAMS_DIR, errno);\n\treturn(-1);\n    }\n\n#if 0\n    if( (fd=open(server_path, O_RDWR)) >= 0 ) {\n\t/*\n\t * This doesn't prevent the server from starting up, and doesn't\n\t * prevent clients from trying to connect to the in-use PTS (which\n\t * is often in use by something other than another server).\n\t */\n\tprmsg(1, \"PTSOpenServer: A server is already running on port %s\\n\", port);\n\tprmsg(1, \"PTSOpenServer: Remove %s if this is incorrect.\\n\", server_path);\n\tclose(fd);\n\treturn(-1);\n    }\n#else\n    /* Just remove the old path (which is what happens with UNIXCONN) */\n#endif\n\n    unlink(server_path);\n\n    if( (fd=open(DEV_PTMX, O_RDWR)) < 0) {\n\tprmsg(1, \"PTSOpenServer: Unable to open %s\\n\", DEV_PTMX);\n\treturn(-1);\n    }\n\n    grantpt(fd);\n    unlockpt(fd);\n\n    if( (slave=ptsname(fd)) == NULL) {\n\tprmsg(1, \"PTSOpenServer: Unable to get slave device name\\n\");\n\tclose(fd);\n\treturn(-1);\n    }\n\n    if( link(slave,server_path) < 0 ) {\n\tprmsg(1, \"PTSOpenServer: Unable to link %s to %s\\n\", slave, server_path);\n\tclose(fd);\n\treturn(-1);\n    }\n\n    if( chmod(server_path, 0666) < 0 ) {\n\tprmsg(1, \"PTSOpenServer: Unable to chmod %s to 0666\\n\", server_path);\n\tclose(fd);\n\treturn(-1);\n    }\n\n    if( (server=open(server_path, O_RDWR)) < 0 ) {\n\tprmsg(1, \"PTSOpenServer: Unable to open server device %s\\n\", server_path);\n\tclose(fd);\n\treturn(-1);\n    }\n\n    close(server);\n\n    /*\n     * Everything looks good: fill in the XtransConnInfo structure.\n     */\n\n    if (TRANS(FillAddrInfo) (ciptr, server_path, server_path) == 0)\n    {\n\tprmsg(1,\"PTSOpenServer: failed to fill in addr info\\n\");\n\tclose(fd);\n\treturn -1;\n    }\n\n    return fd;\n\n#endif /* !PTSNODENAME */\n}\n\nstatic int\nTRANS(PTSAccept)(XtransConnInfo ciptr, XtransConnInfo newciptr, int *status)\n\n{\n    int\t\t\tnewfd;\n    int\t\t\tin;\n    unsigned char\tlength;\n    char\t\tbuf[256];\n    struct sockaddr_un\t*sunaddr;\n\n    prmsg(2,\"PTSAccept(%x->%d)\\n\",ciptr,ciptr->fd);\n\n    if( (in=read(ciptr->fd,&length,1)) <= 0 ){\n\tif( !in ) {\n\t\tprmsg(2,\n\t\t\"PTSAccept: Incoming connection closed\\n\");\n\t\t}\n\telse {\n\t\tprmsg(1,\n\t\"PTSAccept: Error reading incoming connection. errno=%d \\n\",\n\t\t\t\t\t\t\t\terrno);\n\t\t}\n\t*status = TRANS_ACCEPT_MISC_ERROR;\n\treturn -1;\n    }\n\n    if( (in=read(ciptr->fd,buf,length)) <= 0 ){\n\tif( !in ) {\n\t\tprmsg(2,\n\t\t\"PTSAccept: Incoming connection closed\\n\");\n\t\t}\n\telse {\n\t\tprmsg(1,\n\"PTSAccept: Error reading device name for new connection. errno=%d \\n\",\n\t\t\t\t\t\t\t\terrno);\n\t\t}\n\t*status = TRANS_ACCEPT_MISC_ERROR;\n\treturn -1;\n    }\n\n    buf[length] = '\\0';\n\n    if( (newfd=open(buf,O_RDWR)) < 0 ) {\n\tprmsg(1, \"PTSAccept: Failed to open %s\\n\",buf);\n\t*status = TRANS_ACCEPT_MISC_ERROR;\n\treturn -1;\n    }\n\n    write(newfd,\"1\",1);\n\n    /*\n     * Everything looks good: fill in the XtransConnInfo structure.\n     */\n\n    newciptr->addrlen=ciptr->addrlen;\n    if( (newciptr->addr = malloc(newciptr->addrlen)) == NULL ) {\n\tprmsg(1,\"PTSAccept: failed to allocate memory for peer addr\\n\");\n\tclose(newfd);\n\t*status = TRANS_ACCEPT_BAD_MALLOC;\n\treturn -1;\n    }\n\n    memcpy(newciptr->addr,ciptr->addr,newciptr->addrlen);\n\n    newciptr->peeraddrlen=sizeof(struct sockaddr_un);\n    if( (sunaddr = malloc(newciptr->peeraddrlen)) == NULL ) {\n\tprmsg(1,\"PTSAccept: failed to allocate memory for peer addr\\n\");\n\tfree(newciptr->addr);\n\tclose(newfd);\n\t*status = TRANS_ACCEPT_BAD_MALLOC;\n\treturn -1;\n    }\n\n    sunaddr->sun_family=AF_UNIX;\n    strcpy(sunaddr->sun_path,buf);\n#if defined(BSD44SOCKETS)\n    sunaddr->sun_len=strlen(sunaddr->sun_path);\n#endif\n\n    newciptr->peeraddr=(char *)sunaddr;\n\n    *status = 0;\n\n    return newfd;\n}\n\n#endif /* TRANS_SERVER */\n#endif /* LOCAL_TRANS_PTS */\n\n\f\n#ifdef LOCAL_TRANS_NAMED\n\n/* NAMED */\n\n#ifdef TRANS_CLIENT\n\nstatic int\nTRANS(NAMEDOpenClient)(XtransConnInfo ciptr, const char *port)\n\n{\n#ifdef NAMEDNODENAME\n    int\t\t\tfd;\n    char\t\tserver_path[64];\n    struct stat\t\tfilestat;\n# ifndef sun\n    extern int\t\tisastream(int);\n# endif\n#endif\n\n    prmsg(2,\"NAMEDOpenClient(%s)\\n\", port);\n\n#if !defined(NAMEDNODENAME)\n    prmsg(1,\"NAMEDOpenClient: Protocol is not supported by a NAMED connection\\n\");\n    return -1;\n#else\n    if ( port && *port ) {\n\tif( *port == '/' ) { /* A full pathname */\n\t\t(void) snprintf(server_path, sizeof(server_path), \"%s\", port);\n\t    } else {\n\t\t(void) snprintf(server_path, sizeof(server_path), \"%s%s\", NAMEDNODENAME, port);\n\t    }\n    } else {\n\t(void) snprintf(server_path, sizeof(server_path), \"%s%ld\", NAMEDNODENAME, (long)getpid());\n    }\n\n    if ((fd = open(server_path, O_RDWR)) < 0) {\n\tprmsg(1,\"NAMEDOpenClient: Cannot open %s for NAMED connection\\n\", server_path);\n\treturn -1;\n    }\n\n    if (fstat(fd, &filestat) < 0 ) {\n\tprmsg(1,\"NAMEDOpenClient: Cannot stat %s for NAMED connection\\n\", server_path);\n\t(void) close(fd);\n\treturn -1;\n    }\n\n    if ((filestat.st_mode & S_IFMT) != S_IFIFO) {\n\tprmsg(1,\"NAMEDOpenClient: Device %s is not a FIFO\\n\", server_path);\n\t/* Is this really a failure? */\n\t(void) close(fd);\n\treturn -1;\n    }\n\n\n    if (isastream(fd) <= 0) {\n\tprmsg(1,\"NAMEDOpenClient: %s is not a streams device\\n\", server_path);\n\t(void) close(fd);\n\treturn -1;\n    }\n\n    /*\n     * Everything looks good: fill in the XtransConnInfo structure.\n     */\n\n    if (TRANS(FillAddrInfo) (ciptr, server_path, server_path) == 0)\n    {\n\tprmsg(1,\"NAMEDOpenClient: failed to fill in addr info\\n\");\n\tclose(fd);\n\treturn -1;\n    }\n\n    return(fd);\n\n#endif /* !NAMEDNODENAME */\n}\n\n#endif /* TRANS_CLIENT */\n\n\n#ifdef TRANS_SERVER\n\n\n#ifdef NAMEDNODENAME\nstatic int\nTRANS(NAMEDOpenPipe)(const char *server_path)\n{\n    int\t\t\tfd, pipefd[2];\n    struct stat\t\tsbuf;\n    int\t\t\tmode;\n\n    prmsg(2,\"NAMEDOpenPipe(%s)\\n\", server_path);\n\n#ifdef HAS_STICKY_DIR_BIT\n    mode = 01777;\n#else\n    mode = 0777;\n#endif\n    if (trans_mkdir(X_STREAMS_DIR, mode) == -1) {\n\tprmsg (1, \"NAMEDOpenPipe: mkdir(%s) failed, errno = %d\\n\",\n\t       X_STREAMS_DIR, errno);\n\treturn(-1);\n    }\n\n    if(stat(server_path, &sbuf) != 0) {\n\tif (errno == ENOENT) {\n\t    if ((fd = creat(server_path, (mode_t)0666)) == -1) {\n\t\tprmsg(1, \"NAMEDOpenPipe: Can't open %s\\n\", server_path);\n\t\treturn(-1);\n\t    }\n\t    close(fd);\n\t    if (chmod(server_path, (mode_t)0666) < 0) {\n\t\tprmsg(1, \"NAMEDOpenPipe: Can't open %s\\n\", server_path);\n\t\treturn(-1);\n\t    }\n\t} else {\n\t    prmsg(1, \"NAMEDOpenPipe: stat on %s failed\\n\", server_path);\n\t    return(-1);\n\t}\n    }\n\n    if( pipe(pipefd) != 0) {\n\tprmsg(1, \"NAMEDOpenPipe: pipe() failed, errno=%d\\n\",errno);\n\treturn(-1);\n    }\n\n    if( ioctl(pipefd[0], I_PUSH, \"connld\") != 0) {\n\tprmsg(1, \"NAMEDOpenPipe: ioctl(I_PUSH,\\\"connld\\\") failed, errno=%d\\n\",errno);\n\tclose(pipefd[0]);\n\tclose(pipefd[1]);\n\treturn(-1);\n    }\n\n    if( fattach(pipefd[0], server_path) != 0) {\n\tprmsg(1, \"NAMEDOpenPipe: fattach(%s) failed, errno=%d\\n\", server_path,errno);\n\tclose(pipefd[0]);\n\tclose(pipefd[1]);\n\treturn(-1);\n    }\n\n    return(pipefd[1]);\n}\n#endif\n\nstatic int\nTRANS(NAMEDOpenServer)(XtransConnInfo ciptr, const char *port)\n{\n#ifdef NAMEDNODENAME\n    int\t\t\tfd;\n    char\t\tserver_path[64];\n#endif\n\n    prmsg(2,\"NAMEDOpenServer(%s)\\n\", port);\n\n#if !defined(NAMEDNODENAME)\n    prmsg(1,\"NAMEDOpenServer: Protocol is not supported by a NAMED connection\\n\");\n    return -1;\n#else\n    if ( port && *port ) {\n\tif( *port == '/' ) { /* A full pathname */\n\t    (void) snprintf(server_path, sizeof(server_path), \"%s\", port);\n\t} else {\n\t    (void) snprintf(server_path, sizeof(server_path), \"%s%s\",\n\t\t\t    NAMEDNODENAME, port);\n\t}\n    } else {\n\t(void) snprintf(server_path, sizeof(server_path), \"%s%ld\",\n\t\t       NAMEDNODENAME, (long)getpid());\n    }\n\n    fd = TRANS(NAMEDOpenPipe)(server_path);\n    if (fd < 0) {\n\treturn -1;\n    }\n\n    /*\n     * Everything looks good: fill in the XtransConnInfo structure.\n     */\n\n    if (TRANS(FillAddrInfo) (ciptr, server_path, server_path) == 0)\n    {\n\tprmsg(1,\"NAMEDOpenServer: failed to fill in addr info\\n\");\n\tTRANS(LocalClose)(ciptr);\n\treturn -1;\n    }\n\n    return fd;\n\n#endif /* !NAMEDNODENAME */\n}\n\nstatic int\nTRANS(NAMEDResetListener) (XtransConnInfo ciptr)\n\n{\n  struct sockaddr_un      *sockname=(struct sockaddr_un *) ciptr->addr;\n  struct stat     statb;\n\n  prmsg(2,\"NAMEDResetListener(%p, %d)\\n\", ciptr, ciptr->fd);\n\n  if (ciptr->fd != -1) {\n    /*\n     * see if the pipe has disappeared\n     */\n\n    if (stat (sockname->sun_path, &statb) == -1 ||\n\t(statb.st_mode & S_IFMT) != S_IFIFO) {\n      prmsg(3, \"Pipe %s trashed, recreating\\n\", sockname->sun_path);\n      TRANS(LocalClose)(ciptr);\n      ciptr->fd = TRANS(NAMEDOpenPipe)(sockname->sun_path);\n      if (ciptr->fd >= 0)\n\t  return TRANS_RESET_NEW_FD;\n      else\n\t  return TRANS_CREATE_LISTENER_FAILED;\n    }\n  }\n  return TRANS_RESET_NOOP;\n}\n\nstatic int\nTRANS(NAMEDAccept)(XtransConnInfo ciptr, XtransConnInfo newciptr, int *status)\n\n{\n    struct strrecvfd str;\n\n    prmsg(2,\"NAMEDAccept(%p->%d)\\n\", ciptr, ciptr->fd);\n\n    if( ioctl(ciptr->fd, I_RECVFD, &str ) < 0 ) {\n\tprmsg(1, \"NAMEDAccept: ioctl(I_RECVFD) failed, errno=%d\\n\", errno);\n\t*status = TRANS_ACCEPT_MISC_ERROR;\n\treturn(-1);\n    }\n\n    /*\n     * Everything looks good: fill in the XtransConnInfo structure.\n     */\n    newciptr->family=ciptr->family;\n    newciptr->addrlen=ciptr->addrlen;\n    if( (newciptr->addr = malloc(newciptr->addrlen)) == NULL ) {\n\tprmsg(1,\n\t      \"NAMEDAccept: failed to allocate memory for pipe addr\\n\");\n\tclose(str.fd);\n\t*status = TRANS_ACCEPT_BAD_MALLOC;\n\treturn -1;\n    }\n\n    memcpy(newciptr->addr,ciptr->addr,newciptr->addrlen);\n\n    newciptr->peeraddrlen=newciptr->addrlen;\n    if( (newciptr->peeraddr = malloc(newciptr->peeraddrlen)) == NULL ) {\n\tprmsg(1,\n\t\"NAMEDAccept: failed to allocate memory for peer addr\\n\");\n\tfree(newciptr->addr);\n\tclose(str.fd);\n\t*status = TRANS_ACCEPT_BAD_MALLOC;\n\treturn -1;\n    }\n\n    memcpy(newciptr->peeraddr,newciptr->addr,newciptr->peeraddrlen);\n\n    *status = 0;\n\n    return str.fd;\n}\n\n#endif /* TRANS_SERVER */\n\n#endif /* LOCAL_TRANS_NAMED */\n\n\n\f\n#if defined(LOCAL_TRANS_SCO)\n\n/*\n * connect_spipe is used by the SCO connection type.\n */\nstatic int\nconnect_spipe(int fd1, int fd2)\n{\n    long temp;\n    struct strfdinsert sbuf;\n\n    sbuf.databuf.maxlen = -1;\n    sbuf.databuf.len = -1;\n    sbuf.databuf.buf = NULL;\n    sbuf.ctlbuf.maxlen = sizeof(long);\n    sbuf.ctlbuf.len = sizeof(long);\n    sbuf.ctlbuf.buf = (caddr_t)&temp;\n    sbuf.offset = 0;\n    sbuf.fildes = fd2;\n    sbuf.flags = 0;\n\n    if( ioctl(fd1, I_FDINSERT, &sbuf) < 0 )\n\treturn(-1);\n\n    return(0);\n}\n\n/*\n * named_spipe is used by the SCO connection type.\n */\n\nstatic int\nnamed_spipe(int fd, char *path)\n\n{\n    int oldUmask, ret;\n    struct stat sbuf;\n\n    oldUmask = umask(0);\n\n    (void) fstat(fd, &sbuf);\n    ret = mknod(path, 0020666, sbuf.st_rdev);\n\n    umask(oldUmask);\n\n    if (ret < 0) {\n\tret = -1;\n    } else {\n\tret = fd;\n    }\n\n    return(ret);\n}\n\n#endif /* defined(LOCAL_TRANS_SCO) */\n\n\n\n\f\n#ifdef LOCAL_TRANS_SCO\n/* SCO */\n\n/*\n * 2002-11-09 (jkj@sco.com)\n *\n * This code has been modified to match what is in the actual SCO X server.\n * This greatly helps inter-operability between X11R6 and X11R5 (the native\n * SCO server). Mainly, it relies on streams nodes existing in /dev, not\n * creating them or unlinking them, which breaks the native X server.\n *\n * However, this is only for the X protocol. For all other protocols, we\n * do in fact create the nodes, as only X11R6 will use them, and this makes\n * it possible to have both types of clients running, otherwise we get all\n * kinds of nasty errors on startup for anything that doesnt use the X\n * protocol (like SM, when KDE starts up).\n */\n\n#ifdef TRANS_CLIENT\n\nstatic int\nTRANS(SCOOpenClient)(XtransConnInfo ciptr, const char *port)\n{\n#ifdef SCORNODENAME\n    int\t\t\tfd, server, fl, ret;\n    char\t\tserver_path[64];\n    struct strbuf\tctlbuf;\n    unsigned long\talarm_time;\n    void\t\t(*savef)();\n    long\t\ttemp;\n    extern int\tgetmsg(), putmsg();\n#endif\n\n    prmsg(2,\"SCOOpenClient(%s)\\n\", port);\n    if (!port || !port[0])\n\tport = \"0\";\n\n#if !defined(SCORNODENAME)\n    prmsg(2,\"SCOOpenClient: Protocol is not supported by a SCO connection\\n\");\n    return -1;\n#else\n    (void) sprintf(server_path, SCORNODENAME, port);\n\n    if ((server = open(server_path, O_RDWR)) < 0) {\n\tprmsg(1,\"SCOOpenClient: failed to open %s\\n\", server_path);\n\treturn -1;\n    }\n\n    if ((fd = open(DEV_SPX, O_RDWR)) < 0) {\n\tprmsg(1,\"SCOOpenClient: failed to open %s\\n\", DEV_SPX);\n\tclose(server);\n\treturn -1;\n    }\n\n    (void) write(server, &server, 1);\n    ctlbuf.len = 0;\n    ctlbuf.maxlen = sizeof(long);\n    ctlbuf.buf = (caddr_t)&temp;\n    fl = 0;\n\n    savef = signal(SIGALRM, _dummy);\n    alarm_time = alarm(10);\n\n    ret = getmsg(server, &ctlbuf, 0, &fl);\n\n    (void) alarm(alarm_time);\n    (void) signal(SIGALRM, savef);\n\n    if (ret < 0) {\n\tprmsg(1,\"SCOOpenClient: error from getmsg\\n\");\n\tclose(fd);\n\tclose(server);\n\treturn -1;\n    }\n\n    /* The msg we got via getmsg is the result of an\n     * I_FDINSERT, so if we do a putmsg with whatever\n     * we recieved, we're doing another I_FDINSERT ...\n     */\n    (void) putmsg(fd, &ctlbuf, 0, 0);\n    (void) fcntl(fd,F_SETFL,fcntl(fd,F_GETFL,0)|O_NDELAY);\n\n    (void) close(server);\n\n    /*\n     * Everything looks good: fill in the XtransConnInfo structure.\n     */\n\n#if defined(X11_t) && defined(__SCO__)\n    ciptr->flags |= TRANS_NOUNLINK;\n#endif\n    if (TRANS(FillAddrInfo) (ciptr, server_path, server_path) == 0)\n    {\n\tprmsg(1,\"SCOOpenClient: failed to fill addr info\\n\");\n\tclose(fd);\n\treturn -1;\n    }\n\n    return(fd);\n\n#endif  /* !SCORNODENAME */\n}\n\n#endif /* TRANS_CLIENT */\n\n\n#ifdef TRANS_SERVER\n\nstatic int\nTRANS(SCOOpenServer)(XtransConnInfo ciptr, const char *port)\n{\n#ifdef SCORNODENAME\n    char\t\tserverR_path[64];\n    char\t\tserverS_path[64];\n    struct flock\tmylock;\n    int\t\t\tfdr = -1;\n    int\t\t\tfds = -1;\n#endif\n\n    prmsg(2,\"SCOOpenServer(%s)\\n\", port);\n    if (!port || !port[0])\n\tport = \"0\";\n\n#if !defined(SCORNODENAME)\n    prmsg(1,\"SCOOpenServer: Protocol is not supported by a SCO connection\\n\");\n    return -1;\n#else\n    (void) sprintf(serverR_path, SCORNODENAME, port);\n    (void) sprintf(serverS_path, SCOSNODENAME, port);\n\n#if !defined(X11_t) || !defined(__SCO__)\n    unlink(serverR_path);\n    unlink(serverS_path);\n\n    if ((fds = open(DEV_SPX, O_RDWR)) < 0 ||\n\t(fdr = open(DEV_SPX, O_RDWR)) < 0 ) {\n\tprmsg(1,\"SCOOpenServer: failed to open %s\\n\", DEV_SPX);\n\tif (fds >= 0)\n\t\tclose(fds);\n\tif (fdr >= 0)\n\t\tclose(fdr);\n\treturn -1;\n    }\n\n    if (named_spipe (fds, serverS_path) == -1) {\n\tprmsg(1,\"SCOOpenServer: failed to create %s\\n\", serverS_path);\n\tclose (fdr);\n\tclose (fds);\n\treturn -1;\n    }\n\n    if (named_spipe (fdr, serverR_path) == -1) {\n\tprmsg(1,\"SCOOpenServer: failed to create %s\\n\", serverR_path);\n\tclose (fdr);\n\tclose (fds);\n\treturn -1;\n    }\n#else /* X11_t */\n\n    fds = open (serverS_path, O_RDWR | O_NDELAY);\n    if (fds < 0) {\n\tprmsg(1,\"SCOOpenServer: failed to open %s\\n\", serverS_path);\n\treturn -1;\n    }\n\n    /*\n     * Lock the connection device for the duration of the server.\n     * This resolves multiple server starts especially on SMP machines.\n     */\n    mylock.l_type\t= F_WRLCK;\n    mylock.l_whence\t= 0;\n    mylock.l_start\t= 0;\n    mylock.l_len\t= 0;\n    if (fcntl (fds, F_SETLK, &mylock) < 0) {\n\tprmsg(1,\"SCOOpenServer: failed to lock %s\\n\", serverS_path);\n\tclose (fds);\n\treturn -1;\n    }\n\n    fdr = open (serverR_path, O_RDWR | O_NDELAY);\n    if (fdr < 0) {\n\tprmsg(1,\"SCOOpenServer: failed to open %s\\n\", serverR_path);\n\tclose (fds);\n\treturn -1;\n    }\n#endif /* X11_t */\n\n    if (connect_spipe(fds, fdr)) {\n\tprmsg(1,\"SCOOpenServer: ioctl(I_FDINSERT) failed on %s\\n\",\n\t      serverS_path);\n\tclose (fdr);\n\tclose (fds);\n\treturn -1;\n    }\n\n    /*\n     * Everything looks good: fill in the XtransConnInfo structure.\n     */\n\n#if defined(X11_t) && defined(__SCO__)\n    ciptr->flags |= TRANS_NOUNLINK;\n#endif\n    if (TRANS(FillAddrInfo) (ciptr, serverS_path, serverR_path) == 0) {\n\tprmsg(1,\"SCOOpenServer: failed to fill in addr info\\n\");\n\tclose(fds);\n\tclose(fdr);\n\treturn -1;\n    }\n\n    return(fds);\n\n#endif /* !SCORNODENAME */\n}\n\nstatic int\nTRANS(SCOAccept)(XtransConnInfo ciptr, XtransConnInfo newciptr, int *status)\n{\n    char\t\tc;\n    int\t\t\tfd;\n\n    prmsg(2,\"SCOAccept(%d)\\n\", ciptr->fd);\n\n    if (read(ciptr->fd, &c, 1) < 0) {\n\tprmsg(1,\"SCOAccept: can't read from client\\n\");\n\t*status = TRANS_ACCEPT_MISC_ERROR;\n\treturn(-1);\n    }\n\n    if( (fd = open(DEV_SPX, O_RDWR)) < 0 ) {\n\tprmsg(1,\"SCOAccept: can't open \\\"%s\\\"\\n\",DEV_SPX);\n\t*status = TRANS_ACCEPT_MISC_ERROR;\n\treturn(-1);\n    }\n\n    if (connect_spipe (ciptr->fd, fd) < 0) {\n\tprmsg(1,\"SCOAccept: ioctl(I_FDINSERT) failed\\n\");\n\tclose (fd);\n\t*status = TRANS_ACCEPT_MISC_ERROR;\n\treturn -1;\n    }\n\n    /*\n     * Everything looks good: fill in the XtransConnInfo structure.\n     */\n\n    newciptr->addrlen=ciptr->addrlen;\n    if( (newciptr->addr = malloc(newciptr->addrlen)) == NULL ) {\n\tprmsg(1,\n\t      \"SCOAccept: failed to allocate memory for peer addr\\n\");\n\tclose(fd);\n\t*status = TRANS_ACCEPT_BAD_MALLOC;\n\treturn -1;\n    }\n\n    memcpy(newciptr->addr,ciptr->addr,newciptr->addrlen);\n#if defined(__SCO__)\n    newciptr->flags |= TRANS_NOUNLINK;\n#endif\n\n    newciptr->peeraddrlen=newciptr->addrlen;\n    if( (newciptr->peeraddr = malloc(newciptr->peeraddrlen)) == NULL ) {\n\tprmsg(1,\n\t      \"SCOAccept: failed to allocate memory for peer addr\\n\");\n\tfree(newciptr->addr);\n\tclose(fd);\n\t*status = TRANS_ACCEPT_BAD_MALLOC;\n\treturn -1;\n    }\n\n    memcpy(newciptr->peeraddr,newciptr->addr,newciptr->peeraddrlen);\n\n    *status = 0;\n\n    return(fd);\n}\n\n#endif /* TRANS_SERVER */\n#endif /* LOCAL_TRANS_SCO */\n\n\n\f\n#ifdef TRANS_REOPEN\n#ifdef LOCAL_TRANS_PTS\n\nstatic int\nTRANS(PTSReopenServer)(XtransConnInfo ciptr, int fd, const char *port)\n\n{\n#ifdef PTSNODENAME\n    char server_path[64];\n#endif\n\n    prmsg(2,\"PTSReopenServer(%d,%s)\\n\", fd, port);\n\n#if !defined(PTSNODENAME)\n    prmsg(1,\"PTSReopenServer: Protocol is not supported by a pts connection\\n\");\n    return 0;\n#else\n    if (port && *port ) {\n\tif( *port == '/' ) { /* A full pathname */\n\t    snprintf(server_path, sizeof(server_path), \"%s\", port);\n\t} else {\n\t    snprintf(server_path, sizeof(server_path), \"%s%s\",\n\t\t     PTSNODENAME, port);\n\t}\n    } else {\n\tsnprintf(server_path, sizeof(server_path), \"%s%ld\",\n\t\tPTSNODENAME, (long)getpid());\n    }\n\n    if (TRANS(FillAddrInfo) (ciptr, server_path, server_path) == 0)\n    {\n\tprmsg(1,\"PTSReopenServer: failed to fill in addr info\\n\");\n\treturn 0;\n    }\n\n    return 1;\n\n#endif /* !PTSNODENAME */\n}\n\n#endif /* LOCAL_TRANS_PTS */\n\n#ifdef LOCAL_TRANS_NAMED\n\nstatic int\nTRANS(NAMEDReopenServer)(XtransConnInfo ciptr, int fd _X_UNUSED, const char *port)\n\n{\n#ifdef NAMEDNODENAME\n    char server_path[64];\n#endif\n\n    prmsg(2,\"NAMEDReopenServer(%s)\\n\", port);\n\n#if !defined(NAMEDNODENAME)\n    prmsg(1,\"NAMEDReopenServer: Protocol is not supported by a NAMED connection\\n\");\n    return 0;\n#else\n    if ( port && *port ) {\n\tif( *port == '/' ) { /* A full pathname */\n\t    snprintf(server_path, sizeof(server_path),\"%s\", port);\n\t} else {\n\t    snprintf(server_path, sizeof(server_path), \"%s%s\",\n\t\t     NAMEDNODENAME, port);\n\t}\n    } else {\n\tsnprintf(server_path, sizeof(server_path), \"%s%ld\",\n\t\tNAMEDNODENAME, (long)getpid());\n    }\n\n    if (TRANS(FillAddrInfo) (ciptr, server_path, server_path) == 0)\n    {\n\tprmsg(1,\"NAMEDReopenServer: failed to fill in addr info\\n\");\n\treturn 0;\n    }\n\n    return 1;\n\n#endif /* !NAMEDNODENAME */\n}\n\n#endif /* LOCAL_TRANS_NAMED */\n\n\n#ifdef LOCAL_TRANS_SCO\nstatic int\nTRANS(SCOReopenServer)(XtransConnInfo ciptr, int fd, const char *port)\n\n{\n#ifdef SCORNODENAME\n    char serverR_path[64], serverS_path[64];\n#endif\n\n    prmsg(2,\"SCOReopenServer(%s)\\n\", port);\n    if (!port || !port[0])\n      port = \"0\";\n\n#if !defined(SCORNODENAME)\n    prmsg(2,\"SCOReopenServer: Protocol is not supported by a SCO connection\\n\");\n    return 0;\n#else\n    (void) sprintf(serverR_path, SCORNODENAME, port);\n    (void) sprintf(serverS_path, SCOSNODENAME, port);\n\n#if defined(X11_t) && defined(__SCO__)\n    ciptr->flags |= TRANS_NOUNLINK;\n#endif\n    if (TRANS(FillAddrInfo) (ciptr, serverS_path, serverR_path) == 0)\n    {\n\tprmsg(1, \"SCOReopenServer: failed to fill in addr info\\n\");\n\treturn 0;\n    }\n\n    return 1;\n\n#endif /* SCORNODENAME */\n}\n\n#endif /* LOCAL_TRANS_SCO */\n\n#endif /* TRANS_REOPEN */\n\n\n\f\n/*\n * This table contains all of the entry points for the different local\n * connection mechanisms.\n */\n\ntypedef struct _LOCALtrans2dev {\n    const char\t*transname;\n\n#ifdef TRANS_CLIENT\n\n    int\t(*devcotsopenclient)(\n\tXtransConnInfo, const char * /*port*/\n);\n\n#endif /* TRANS_CLIENT */\n\n#ifdef TRANS_SERVER\n\n    int\t(*devcotsopenserver)(\n\tXtransConnInfo, const char * /*port*/\n);\n\n#endif /* TRANS_SERVER */\n\n#ifdef TRANS_CLIENT\n\n    int\t(*devcltsopenclient)(\n\tXtransConnInfo, const char * /*port*/\n);\n\n#endif /* TRANS_CLIENT */\n\n#ifdef TRANS_SERVER\n\n    int\t(*devcltsopenserver)(\n\tXtransConnInfo, const char * /*port*/\n);\n\n#endif /* TRANS_SERVER */\n\n#ifdef TRANS_REOPEN\n\n    int\t(*devcotsreopenserver)(\n\tXtransConnInfo,\n\tint, \t/* fd */\n\tconst char * \t/* port */\n);\n\n    int\t(*devcltsreopenserver)(\n\tXtransConnInfo,\n\tint, \t/* fd */\n\tconst char *\t/* port */\n);\n\n#endif /* TRANS_REOPEN */\n\n#ifdef TRANS_SERVER\n\n    int (*devreset)(\n\tXtransConnInfo /* ciptr */\n);\n\n    int\t(*devaccept)(\n\tXtransConnInfo, XtransConnInfo, int *\n);\n\n#endif /* TRANS_SERVER */\n\n} LOCALtrans2dev;\n\nstatic LOCALtrans2dev LOCALtrans2devtab[] = {\n#ifdef LOCAL_TRANS_PTS\n{\"\",\n#ifdef TRANS_CLIENT\n     TRANS(PTSOpenClient),\n#endif /* TRANS_CLIENT */\n#ifdef TRANS_SERVER\n     TRANS(PTSOpenServer),\n#endif /* TRANS_SERVER */\n#ifdef TRANS_CLIENT\n     TRANS(OpenFail),\n#endif /* TRANS_CLIENT */\n#ifdef TRANS_SERVER\n     TRANS(OpenFail),\n#endif /* TRANS_SERVER */\n#ifdef TRANS_REOPEN\n     TRANS(PTSReopenServer),\n     TRANS(ReopenFail),\n#endif\n#ifdef TRANS_SERVER\n     NULL,\t\t/* ResetListener */\n     TRANS(PTSAccept)\n#endif /* TRANS_SERVER */\n},\n\n{\"local\",\n#ifdef TRANS_CLIENT\n     TRANS(PTSOpenClient),\n#endif /* TRANS_CLIENT */\n#ifdef TRANS_SERVER\n     TRANS(PTSOpenServer),\n#endif /* TRANS_SERVER */\n#ifdef TRANS_CLIENT\n     TRANS(OpenFail),\n#endif /* TRANS_CLIENT */\n#ifdef TRANS_SERVER\n     TRANS(OpenFail),\n#endif /* TRANS_SERVER */\n#ifdef TRANS_REOPEN\n     TRANS(PTSReopenServer),\n     TRANS(ReopenFail),\n#endif\n#ifdef TRANS_SERVER\n     NULL,\t\t/* ResetListener */\n     TRANS(PTSAccept)\n#endif /* TRANS_SERVER */\n},\n\n{\"pts\",\n#ifdef TRANS_CLIENT\n     TRANS(PTSOpenClient),\n#endif /* TRANS_CLIENT */\n#ifdef TRANS_SERVER\n     TRANS(PTSOpenServer),\n#endif /* TRANS_SERVER */\n#ifdef TRANS_CLIENT\n     TRANS(OpenFail),\n#endif /* TRANS_CLIENT */\n#ifdef TRANS_SERVER\n     TRANS(OpenFail),\n#endif /* TRANS_SERVER */\n#ifdef TRANS_REOPEN\n     TRANS(PTSReopenServer),\n     TRANS(ReopenFail),\n#endif\n#ifdef TRANS_SERVER\n     NULL,\t\t/* ResetListener */\n     TRANS(PTSAccept)\n#endif /* TRANS_SERVER */\n},\n#else /* !LOCAL_TRANS_PTS */\n{\"\",\n#ifdef TRANS_CLIENT\n     TRANS(NAMEDOpenClient),\n#endif /* TRANS_CLIENT */\n#ifdef TRANS_SERVER\n     TRANS(NAMEDOpenServer),\n#endif /* TRANS_SERVER */\n#ifdef TRANS_CLIENT\n     TRANS(OpenFail),\n#endif /* TRANS_CLIENT */\n#ifdef TRANS_SERVER\n     TRANS(OpenFail),\n#endif /* TRANS_SERVER */\n#ifdef TRANS_REOPEN\n     TRANS(NAMEDReopenServer),\n     TRANS(ReopenFail),\n#endif\n#ifdef TRANS_SERVER\n     TRANS(NAMEDResetListener),\n     TRANS(NAMEDAccept)\n#endif /* TRANS_SERVER */\n},\n\n{\"local\",\n#ifdef TRANS_CLIENT\n     TRANS(NAMEDOpenClient),\n#endif /* TRANS_CLIENT */\n#ifdef TRANS_SERVER\n     TRANS(NAMEDOpenServer),\n#endif /* TRANS_SERVER */\n#ifdef TRANS_CLIENT\n     TRANS(OpenFail),\n#endif /* TRANS_CLIENT */\n#ifdef TRANS_SERVER\n     TRANS(OpenFail),\n#endif /* TRANS_SERVER */\n#ifdef TRANS_REOPEN\n     TRANS(NAMEDReopenServer),\n     TRANS(ReopenFail),\n#endif\n#ifdef TRANS_SERVER\n     TRANS(NAMEDResetListener),\n     TRANS(NAMEDAccept)\n#endif /* TRANS_SERVER */\n},\n#endif /* !LOCAL_TRANS_PTS */\n\n#ifdef LOCAL_TRANS_NAMED\n{\"named\",\n#ifdef TRANS_CLIENT\n     TRANS(NAMEDOpenClient),\n#endif /* TRANS_CLIENT */\n#ifdef TRANS_SERVER\n     TRANS(NAMEDOpenServer),\n#endif /* TRANS_SERVER */\n#ifdef TRANS_CLIENT\n     TRANS(OpenFail),\n#endif /* TRANS_CLIENT */\n#ifdef TRANS_SERVER\n     TRANS(OpenFail),\n#endif /* TRANS_SERVER */\n#ifdef TRANS_REOPEN\n     TRANS(NAMEDReopenServer),\n     TRANS(ReopenFail),\n#endif\n#ifdef TRANS_SERVER\n     TRANS(NAMEDResetListener),\n     TRANS(NAMEDAccept)\n#endif /* TRANS_SERVER */\n},\n\n#ifdef sun /* Alias \"pipe\" to named, since that's what Solaris called it */\n{\"pipe\",\n#ifdef TRANS_CLIENT\n     TRANS(NAMEDOpenClient),\n#endif /* TRANS_CLIENT */\n#ifdef TRANS_SERVER\n     TRANS(NAMEDOpenServer),\n#endif /* TRANS_SERVER */\n#ifdef TRANS_CLIENT\n     TRANS(OpenFail),\n#endif /* TRANS_CLIENT */\n#ifdef TRANS_SERVER\n     TRANS(OpenFail),\n#endif /* TRANS_SERVER */\n#ifdef TRANS_REOPEN\n     TRANS(NAMEDReopenServer),\n     TRANS(ReopenFail),\n#endif\n#ifdef TRANS_SERVER\n     TRANS(NAMEDResetListener),\n     TRANS(NAMEDAccept)\n#endif /* TRANS_SERVER */\n},\n#endif /* sun */\n#endif /* LOCAL_TRANS_NAMED */\n\n\n#ifdef LOCAL_TRANS_SCO\n{\"sco\",\n#ifdef TRANS_CLIENT\n     TRANS(SCOOpenClient),\n#endif /* TRANS_CLIENT */\n#ifdef TRANS_SERVER\n     TRANS(SCOOpenServer),\n#endif /* TRANS_SERVER */\n#ifdef TRANS_CLIENT\n     TRANS(OpenFail),\n#endif /* TRANS_CLIENT */\n#ifdef TRANS_SERVER\n     TRANS(OpenFail),\n#endif /* TRANS_SERVER */\n#ifdef TRANS_REOPEN\n     TRANS(SCOReopenServer),\n     TRANS(ReopenFail),\n#endif\n#ifdef TRANS_SERVER\n     NULL,\t\t/* ResetListener */\n     TRANS(SCOAccept)\n#endif /* TRANS_SERVER */\n},\n#endif /* LOCAL_TRANS_SCO */\n};\n\n#define NUMTRANSPORTS\t(sizeof(LOCALtrans2devtab)/sizeof(LOCALtrans2dev))\n\nstatic const char\t*XLOCAL=NULL;\nstatic\tchar\t*workingXLOCAL=NULL;\nstatic\tchar\t*freeXLOCAL=NULL;\n\n#if defined(__SCO__)\n#define DEF_XLOCAL \"SCO:UNIX:PTS\"\n#elif defined(__UNIXWARE__)\n#define DEF_XLOCAL \"UNIX:PTS:NAMED:SCO\"\n#elif defined(sun)\n#define DEF_XLOCAL \"UNIX:NAMED\"\n#else\n#define DEF_XLOCAL \"UNIX:PTS:NAMED:SCO\"\n#endif\n\nstatic void\nTRANS(LocalInitTransports)(const char *protocol)\n\n{\n    prmsg(3,\"LocalInitTransports(%s)\\n\", protocol);\n\n    if( strcmp(protocol,\"local\") && strcmp(protocol,\"LOCAL\") )\n    {\n\tworkingXLOCAL = freeXLOCAL = strdup (protocol);\n    }\n    else {\n\tXLOCAL=(char *)getenv(\"XLOCAL\");\n\tif(XLOCAL==NULL)\n\t    XLOCAL=DEF_XLOCAL;\n\tworkingXLOCAL = freeXLOCAL = strdup (XLOCAL);\n    }\n}\n\nstatic void\nTRANS(LocalEndTransports)(void)\n\n{\n    prmsg(3,\"LocalEndTransports()\\n\");\n    free(freeXLOCAL);\n}\n\n#define TYPEBUFSIZE\t32\n\n#ifdef TRANS_CLIENT\n\nstatic LOCALtrans2dev *\nTRANS(LocalGetNextTransport)(void)\n\n{\n    int\ti,j;\n    char\t*typetocheck;\n    char\ttypebuf[TYPEBUFSIZE];\n    prmsg(3,\"LocalGetNextTransport()\\n\");\n\n    while(1)\n    {\n\tif( workingXLOCAL == NULL || *workingXLOCAL == '\\0' )\n\t    return NULL;\n\n\ttypetocheck=workingXLOCAL;\n\tworkingXLOCAL=strchr(workingXLOCAL,':');\n\tif(workingXLOCAL && *workingXLOCAL)\n\t    *workingXLOCAL++='\\0';\n\n\tfor(i=0;i<NUMTRANSPORTS;i++)\n\t{\n\t    /*\n\t     * This is equivalent to a case insensitive strcmp(),\n\t     * but should be more portable.\n\t     */\n\t    strncpy(typebuf,typetocheck,TYPEBUFSIZE);\n\t    for(j=0;j<TYPEBUFSIZE;j++)\n\t\tif (isupper(typebuf[j]))\n\t\t    typebuf[j]=tolower(typebuf[j]);\n\n\t    /* Now, see if they match */\n\t    if(!strcmp(LOCALtrans2devtab[i].transname,typebuf))\n\t\treturn &LOCALtrans2devtab[i];\n\t}\n    }\n#if 0\n    /*NOTREACHED*/\n    return NULL;\n#endif\n}\n\n#ifdef NEED_UTSNAME\n#include <sys/utsname.h>\n#endif\n\n/*\n * Make sure 'host' is really local.\n */\n\nstatic int\nHostReallyLocal (const char *host)\n\n{\n    /*\n     * The 'host' passed to this function may have been generated\n     * by either uname() or gethostname().  We try both if possible.\n     */\n\n#ifdef NEED_UTSNAME\n    struct utsname name;\n#endif\n    char buf[256];\n\n#ifdef NEED_UTSNAME\n    if (uname (&name) >= 0 && strcmp (host, name.nodename) == 0)\n\treturn (1);\n#endif\n\n    buf[0] = '\\0';\n    (void) gethostname (buf, 256);\n    buf[255] = '\\0';\n\n    if (strcmp (host, buf) == 0)\n\treturn (1);\n\n    return (0);\n}\n\n\nstatic XtransConnInfo\nTRANS(LocalOpenClient)(int type, const char *protocol,\n                       const char *host, const char *port)\n\n{\n    LOCALtrans2dev *transptr;\n    XtransConnInfo ciptr;\n    int index;\n\n    prmsg(3,\"LocalOpenClient()\\n\");\n\n    /*\n     * Make sure 'host' is really local.  If not, we return failure.\n     * The reason we make this check is because a process may advertise\n     * a \"local\" address for which it can accept connections, but if a\n     * process on a remote machine tries to connect to this address,\n     * we know for sure it will fail.\n     */\n\n    if (strcmp (host, \"unix\") != 0 && !HostReallyLocal (host))\n    {\n\tprmsg (1,\n\t   \"LocalOpenClient: Cannot connect to non-local host %s\\n\",\n\t       host);\n\treturn NULL;\n    }\n\n\n#if defined(X11_t)\n    /*\n     * X has a well known port, that is transport dependant. It is easier\n     * to handle it here, than try and come up with a transport independent\n     * representation that can be passed in and resolved the usual way.\n     *\n     * The port that is passed here is really a string containing the idisplay\n     * from ConnectDisplay(). Since that is what we want for the local transports,\n     * we don't have to do anything special.\n     */\n#endif /* X11_t */\n\n    if( (ciptr = calloc(1,sizeof(struct _XtransConnInfo))) == NULL )\n    {\n\tprmsg(1,\"LocalOpenClient: calloc(1,%lu) failed\\n\",\n\t      sizeof(struct _XtransConnInfo));\n\treturn NULL;\n    }\n\n    ciptr->fd = -1;\n\n    TRANS(LocalInitTransports)(protocol);\n\n    index = 0;\n    for(transptr=TRANS(LocalGetNextTransport)();\n\ttransptr!=NULL;transptr=TRANS(LocalGetNextTransport)(), index++)\n    {\n\tswitch( type )\n\t{\n\tcase XTRANS_OPEN_COTS_CLIENT:\n\t    ciptr->fd=transptr->devcotsopenclient(ciptr,port);\n\t    break;\n\tcase XTRANS_OPEN_CLTS_CLIENT:\n\t    ciptr->fd=transptr->devcltsopenclient(ciptr,port);\n\t    break;\n\tcase XTRANS_OPEN_COTS_SERVER:\n\tcase XTRANS_OPEN_CLTS_SERVER:\n\t    prmsg(1,\n\t\t  \"LocalOpenClient: Should not be opening a server with this function\\n\");\n\t    break;\n\tdefault:\n\t    prmsg(1,\n\t\t  \"LocalOpenClient: Unknown Open type %d\\n\",\n\t\t  type);\n\t}\n\tif( ciptr->fd >= 0 )\n\t    break;\n    }\n\n    TRANS(LocalEndTransports)();\n\n    if( ciptr->fd < 0 )\n    {\n\tfree(ciptr);\n\treturn NULL;\n    }\n\n    ciptr->priv=(char *)transptr;\n    ciptr->index = index;\n\n    return ciptr;\n}\n\n#endif /* TRANS_CLIENT */\n\n\n#ifdef TRANS_SERVER\n\nstatic XtransConnInfo\nTRANS(LocalOpenServer)(int type, const char *protocol,\n                       const char *host _X_UNUSED, const char *port)\n\n{\n    int\ti;\n    XtransConnInfo ciptr;\n\n    prmsg(2,\"LocalOpenServer(%d,%s,%s)\\n\", type, protocol, port);\n\n#if defined(X11_t)\n    /*\n     * For X11, the port will be in the format xserverN where N is the\n     * display number. All of the local connections just need to know\n     * the display number because they don't do any name resolution on\n     * the port. This just truncates port to the display portion.\n     */\n#endif /* X11_t */\n\n    if( (ciptr = calloc(1,sizeof(struct _XtransConnInfo))) == NULL )\n    {\n\tprmsg(1,\"LocalOpenServer: calloc(1,%lu) failed\\n\",\n\t      sizeof(struct _XtransConnInfo));\n\treturn NULL;\n    }\n\n    for(i=1;i<NUMTRANSPORTS;i++)\n    {\n\tif( strcmp(protocol,LOCALtrans2devtab[i].transname) != 0 )\n\t    continue;\n\tswitch( type )\n\t{\n\tcase XTRANS_OPEN_COTS_CLIENT:\n\tcase XTRANS_OPEN_CLTS_CLIENT:\n\t    prmsg(1,\n\t\t  \"LocalOpenServer: Should not be opening a client with this function\\n\");\n\t    break;\n\tcase XTRANS_OPEN_COTS_SERVER:\n\t    ciptr->fd=LOCALtrans2devtab[i].devcotsopenserver(ciptr,port);\n\t    break;\n\tcase XTRANS_OPEN_CLTS_SERVER:\n\t    ciptr->fd=LOCALtrans2devtab[i].devcltsopenserver(ciptr,port);\n\t    break;\n\tdefault:\n\t    prmsg(1,\"LocalOpenServer: Unknown Open type %d\\n\",\n\t\t  type );\n\t}\n\tif( ciptr->fd >= 0 ) {\n\t    ciptr->priv=(char *)&LOCALtrans2devtab[i];\n\t    ciptr->index=i;\n\t    ciptr->flags = 1 | (ciptr->flags & TRANS_KEEPFLAGS);\n\t    return ciptr;\n\t}\n    }\n\n    free(ciptr);\n    return NULL;\n}\n\n#endif /* TRANS_SERVER */\n\n\n#ifdef TRANS_REOPEN\n\nstatic XtransConnInfo\nTRANS(LocalReopenServer)(int type, int index, int fd, const char *port)\n\n{\n    XtransConnInfo ciptr;\n    int stat = 0;\n\n    prmsg(2,\"LocalReopenServer(%d,%d,%d)\\n\", type, index, fd);\n\n    if( (ciptr = calloc(1,sizeof(struct _XtransConnInfo))) == NULL )\n    {\n\tprmsg(1,\"LocalReopenServer: calloc(1,%lu) failed\\n\",\n\t      sizeof(struct _XtransConnInfo));\n\treturn NULL;\n    }\n\n    ciptr->fd = fd;\n\n    switch( type )\n    {\n    case XTRANS_OPEN_COTS_SERVER:\n\tstat = LOCALtrans2devtab[index].devcotsreopenserver(ciptr,fd,port);\n\tbreak;\n    case XTRANS_OPEN_CLTS_SERVER:\n\tstat = LOCALtrans2devtab[index].devcltsreopenserver(ciptr,fd,port);\n\tbreak;\n    default:\n\tprmsg(1,\"LocalReopenServer: Unknown Open type %d\\n\",\n\t  type );\n    }\n\n    if( stat > 0 ) {\n\tciptr->priv=(char *)&LOCALtrans2devtab[index];\n\tciptr->index=index;\n\tciptr->flags = 1 | (ciptr->flags & TRANS_KEEPFLAGS);\n\treturn ciptr;\n    }\n\n    free(ciptr);\n    return NULL;\n}\n\n#endif /* TRANS_REOPEN */\n\n\n\f\n/*\n * This is the Local implementation of the X Transport service layer\n */\n\n#ifdef TRANS_CLIENT\n\nstatic XtransConnInfo\nTRANS(LocalOpenCOTSClient)(Xtransport *thistrans _X_UNUSED, const char *protocol,\n\t\t\t   const char *host, const char *port)\n\n{\n    prmsg(2,\"LocalOpenCOTSClient(%s,%s,%s)\\n\",protocol,host,port);\n\n    return TRANS(LocalOpenClient)(XTRANS_OPEN_COTS_CLIENT, protocol, host, port);\n}\n\n#endif /* TRANS_CLIENT */\n\n\n#ifdef TRANS_SERVER\n\nstatic XtransConnInfo\nTRANS(LocalOpenCOTSServer)(Xtransport *thistrans, const char *protocol,\n\t\t\t   const char *host, const char *port)\n\n{\n    char *typetocheck = NULL;\n    int found = 0;\n    char typebuf[TYPEBUFSIZE];\n\n    prmsg(2,\"LocalOpenCOTSServer(%s,%s,%s)\\n\",protocol,host,port);\n\n    /* Check if this local type is in the XLOCAL list */\n    TRANS(LocalInitTransports)(\"local\");\n    typetocheck = workingXLOCAL;\n    while (typetocheck && !found) {\n\tint j;\n\n\tworkingXLOCAL = strchr(workingXLOCAL, ':');\n\tif (workingXLOCAL && *workingXLOCAL)\n\t    *workingXLOCAL++ = '\\0';\n\tstrncpy(typebuf, typetocheck, TYPEBUFSIZE);\n\tfor (j = 0; j < TYPEBUFSIZE; j++)\n\t    if (isupper(typebuf[j]))\n\t\ttypebuf[j] = tolower(typebuf[j]);\n\tif (!strcmp(thistrans->TransName, typebuf))\n\t    found = 1;\n\ttypetocheck = workingXLOCAL;\n    }\n    TRANS(LocalEndTransports)();\n\n    if (!found) {\n\tprmsg(3,\"LocalOpenCOTSServer: disabling %s\\n\",thistrans->TransName);\n\tthistrans->flags |= TRANS_DISABLED;\n\treturn NULL;\n    }\n\n    return TRANS(LocalOpenServer)(XTRANS_OPEN_COTS_SERVER, protocol, host, port);\n}\n\n#endif /* TRANS_SERVER */\n\n\n#ifdef TRANS_CLIENT\n\nstatic XtransConnInfo\nTRANS(LocalOpenCLTSClient)(Xtransport *thistrans _X_UNUSED, const char *protocol,\n\t\t\t   const char *host, const char *port)\n\n{\n    prmsg(2,\"LocalOpenCLTSClient(%s,%s,%s)\\n\",protocol,host,port);\n\n    return TRANS(LocalOpenClient)(XTRANS_OPEN_CLTS_CLIENT, protocol, host, port);\n}\n\n#endif /* TRANS_CLIENT */\n\n\n#ifdef TRANS_SERVER\n\nstatic XtransConnInfo\nTRANS(LocalOpenCLTSServer)(Xtransport *thistrans _X_UNUSED, const char *protocol,\n\t\t\t   const char *host, const char *port)\n\n{\n    prmsg(2,\"LocalOpenCLTSServer(%s,%s,%s)\\n\",protocol,host,port);\n\n    return TRANS(LocalOpenServer)(XTRANS_OPEN_CLTS_SERVER, protocol, host, port);\n}\n\n#endif /* TRANS_SERVER */\n\n\n#ifdef TRANS_REOPEN\n\nstatic XtransConnInfo\nTRANS(LocalReopenCOTSServer)(Xtransport *thistrans, int fd, const char *port)\n\n{\n    int index;\n\n    prmsg(2,\"LocalReopenCOTSServer(%d,%s)\\n\", fd, port);\n\n    for(index=1;index<NUMTRANSPORTS;index++)\n    {\n\tif( strcmp(thistrans->TransName,\n\t    LOCALtrans2devtab[index].transname) == 0 )\n\t    break;\n    }\n\n    if (index >= NUMTRANSPORTS)\n    {\n\treturn (NULL);\n    }\n\n    return TRANS(LocalReopenServer)(XTRANS_OPEN_COTS_SERVER,\n\tindex, fd, port);\n}\n\nstatic XtransConnInfo\nTRANS(LocalReopenCLTSServer)(Xtransport *thistrans, int fd, const char *port)\n\n{\n    int index;\n\n    prmsg(2,\"LocalReopenCLTSServer(%d,%s)\\n\", fd, port);\n\n    for(index=1;index<NUMTRANSPORTS;index++)\n    {\n\tif( strcmp(thistrans->TransName,\n\t    LOCALtrans2devtab[index].transname) == 0 )\n\t    break;\n    }\n\n    if (index >= NUMTRANSPORTS)\n    {\n\treturn (NULL);\n    }\n\n    return TRANS(LocalReopenServer)(XTRANS_OPEN_CLTS_SERVER,\n\tindex, fd, port);\n}\n\n#endif /* TRANS_REOPEN */\n\n\n\nstatic int\nTRANS(LocalSetOption)(XtransConnInfo ciptr, int option, int arg)\n\n{\n    prmsg(2,\"LocalSetOption(%d,%d,%d)\\n\",ciptr->fd,option,arg);\n\n    return -1;\n}\n\n\n#ifdef TRANS_SERVER\n\nstatic int\nTRANS(LocalCreateListener)(XtransConnInfo ciptr, const char *port,\n                           unsigned int flags _X_UNUSED)\n\n{\n    prmsg(2,\"LocalCreateListener(%p->%d,%s)\\n\",ciptr,ciptr->fd,port);\n\n    return 0;\n}\n\nstatic int\nTRANS(LocalResetListener)(XtransConnInfo ciptr)\n\n{\n    LOCALtrans2dev\t*transptr;\n\n    prmsg(2,\"LocalResetListener(%p)\\n\",ciptr);\n\n    transptr=(LOCALtrans2dev *)ciptr->priv;\n    if (transptr->devreset != NULL) {\n\treturn transptr->devreset(ciptr);\n    }\n    return TRANS_RESET_NOOP;\n}\n\n\nstatic XtransConnInfo\nTRANS(LocalAccept)(XtransConnInfo ciptr, int *status)\n\n{\n    XtransConnInfo\tnewciptr;\n    LOCALtrans2dev\t*transptr;\n\n    prmsg(2,\"LocalAccept(%p->%d)\\n\", ciptr, ciptr->fd);\n\n    transptr=(LOCALtrans2dev *)ciptr->priv;\n\n    if( (newciptr = calloc(1,sizeof(struct _XtransConnInfo)))==NULL )\n    {\n\tprmsg(1,\"LocalAccept: calloc(1,%lu) failed\\n\",\n\t      sizeof(struct _XtransConnInfo));\n\t*status = TRANS_ACCEPT_BAD_MALLOC;\n\treturn NULL;\n    }\n\n    newciptr->fd=transptr->devaccept(ciptr,newciptr,status);\n\n    if( newciptr->fd < 0 )\n    {\n\tfree(newciptr);\n\treturn NULL;\n    }\n\n    newciptr->priv=(char *)transptr;\n    newciptr->index = ciptr->index;\n\n    *status = 0;\n\n    return newciptr;\n}\n\n#endif /* TRANS_SERVER */\n\n\n#ifdef TRANS_CLIENT\n\nstatic int\nTRANS(LocalConnect)(XtransConnInfo ciptr,\n                    const char *host _X_UNUSED, const char *port)\n\n{\n    prmsg(2,\"LocalConnect(%p->%d,%s)\\n\", ciptr, ciptr->fd, port);\n\n    return 0;\n}\n\n#endif /* TRANS_CLIENT */\n\n\nstatic int\nTRANS(LocalBytesReadable)(XtransConnInfo ciptr, BytesReadable_t *pend )\n\n{\n    prmsg(2,\"LocalBytesReadable(%p->%d,%p)\\n\", ciptr, ciptr->fd, pend);\n\n#if defined(SCO325)\n    return ioctl(ciptr->fd, I_NREAD, (char *)pend);\n#else\n    return ioctl(ciptr->fd, FIONREAD, (char *)pend);\n#endif\n}\n\nstatic int\nTRANS(LocalRead)(XtransConnInfo ciptr, char *buf, int size)\n\n{\n    prmsg(2,\"LocalRead(%d,%p,%d)\\n\", ciptr->fd, buf, size );\n\n    return read(ciptr->fd,buf,size);\n}\n\nstatic int\nTRANS(LocalWrite)(XtransConnInfo ciptr, char *buf, int size)\n\n{\n    prmsg(2,\"LocalWrite(%d,%p,%d)\\n\", ciptr->fd, buf, size );\n\n    return write(ciptr->fd,buf,size);\n}\n\nstatic int\nTRANS(LocalReadv)(XtransConnInfo ciptr, struct iovec *buf, int size)\n\n{\n    prmsg(2,\"LocalReadv(%d,%p,%d)\\n\", ciptr->fd, buf, size );\n\n    return READV(ciptr,buf,size);\n}\n\nstatic int\nTRANS(LocalWritev)(XtransConnInfo ciptr, struct iovec *buf, int size)\n\n{\n    prmsg(2,\"LocalWritev(%d,%p,%d)\\n\", ciptr->fd, buf, size );\n\n    return WRITEV(ciptr,buf,size);\n}\n\nstatic int\nTRANS(LocalDisconnect)(XtransConnInfo ciptr)\n\n{\n    prmsg(2,\"LocalDisconnect(%p->%d)\\n\", ciptr, ciptr->fd);\n\n    return 0;\n}\n\nstatic int\nTRANS(LocalClose)(XtransConnInfo ciptr)\n\n{\n    struct sockaddr_un      *sockname=(struct sockaddr_un *) ciptr->addr;\n    int\tret;\n\n    prmsg(2,\"LocalClose(%p->%d)\\n\", ciptr, ciptr->fd );\n\n    ret=close(ciptr->fd);\n\n    if(ciptr->flags\n       && sockname\n       && sockname->sun_family == AF_UNIX\n       && sockname->sun_path[0] )\n    {\n\tif (!(ciptr->flags & TRANS_NOUNLINK))\n\t    unlink(sockname->sun_path);\n    }\n\n    return ret;\n}\n\nstatic int\nTRANS(LocalCloseForCloning)(XtransConnInfo ciptr)\n\n{\n    int ret;\n\n    prmsg(2,\"LocalCloseForCloning(%p->%d)\\n\", ciptr, ciptr->fd );\n\n    /* Don't unlink path */\n\n    ret=close(ciptr->fd);\n\n    return ret;\n}\n\n\n/*\n * MakeAllCOTSServerListeners() will go through the entire Xtransports[]\n * array defined in Xtrans.c and try to OpenCOTSServer() for each entry.\n * We will add duplicate entries to that table so that the OpenCOTSServer()\n * function will get called once for each type of local transport.\n *\n * The TransName is in lowercase, so it will never match during a normal\n * call to SelectTransport() in Xtrans.c.\n */\n\n#ifdef TRANS_SERVER\nstatic const char * local_aliases[] = {\n# ifdef LOCAL_TRANS_PTS\n                                  \"pts\",\n# endif\n\t\t\t\t  \"named\",\n# ifdef sun\n\t\t\t\t  \"pipe\", /* compatibility with Solaris Xlib */\n# endif\n# ifdef LOCAL_TRANS_SCO\n\t\t\t\t  \"sco\",\n# endif\n\t\t\t\t  NULL };\n#endif\n\nXtransport\tTRANS(LocalFuncs) = {\n\t/* Local Interface */\n\t\"local\",\n\tTRANS_ALIAS | TRANS_LOCAL,\n#ifdef TRANS_CLIENT\n\tTRANS(LocalOpenCOTSClient),\n#endif /* TRANS_CLIENT */\n#ifdef TRANS_SERVER\n\tlocal_aliases,\n\tTRANS(LocalOpenCOTSServer),\n#endif /* TRANS_SERVER */\n#ifdef TRANS_CLIENT\n\tTRANS(LocalOpenCLTSClient),\n#endif /* TRANS_CLIENT */\n#ifdef TRANS_SERVER\n\tTRANS(LocalOpenCLTSServer),\n#endif /* TRANS_SERVER */\n#ifdef TRANS_REOPEN\n\tTRANS(LocalReopenCOTSServer),\n\tTRANS(LocalReopenCLTSServer),\n#endif\n\tTRANS(LocalSetOption),\n#ifdef TRANS_SERVER\n\tTRANS(LocalCreateListener),\n\tTRANS(LocalResetListener),\n\tTRANS(LocalAccept),\n#endif /* TRANS_SERVER */\n#ifdef TRANS_CLIENT\n\tTRANS(LocalConnect),\n#endif /* TRANS_CLIENT */\n\tTRANS(LocalBytesReadable),\n\tTRANS(LocalRead),\n\tTRANS(LocalWrite),\n\tTRANS(LocalReadv),\n\tTRANS(LocalWritev),\n#if XTRANS_SEND_FDS\n\tTRANS(LocalSendFdInvalid),\n\tTRANS(LocalRecvFdInvalid),\n#endif\n\tTRANS(LocalDisconnect),\n\tTRANS(LocalClose),\n\tTRANS(LocalCloseForCloning),\n};\n\n#ifdef LOCAL_TRANS_PTS\n\nXtransport\tTRANS(PTSFuncs) = {\n\t/* Local Interface */\n\t\"pts\",\n\tTRANS_LOCAL,\n#ifdef TRANS_CLIENT\n\tTRANS(LocalOpenCOTSClient),\n#endif /* TRANS_CLIENT */\n#ifdef TRANS_SERVER\n\tNULL,\n\tTRANS(LocalOpenCOTSServer),\n#endif /* TRANS_SERVER */\n#ifdef TRANS_CLIENT\n\tTRANS(LocalOpenCLTSClient),\n#endif /* TRANS_CLIENT */\n#ifdef TRANS_SERVER\n\tTRANS(LocalOpenCLTSServer),\n#endif /* TRANS_SERVER */\n#ifdef TRANS_REOPEN\n\tTRANS(LocalReopenCOTSServer),\n\tTRANS(LocalReopenCLTSServer),\n#endif\n\tTRANS(LocalSetOption),\n#ifdef TRANS_SERVER\n\tTRANS(LocalCreateListener),\n\tTRANS(LocalResetListener),\n\tTRANS(LocalAccept),\n#endif /* TRANS_SERVER */\n#ifdef TRANS_CLIENT\n\tTRANS(LocalConnect),\n#endif /* TRANS_CLIENT */\n\tTRANS(LocalBytesReadable),\n\tTRANS(LocalRead),\n\tTRANS(LocalWrite),\n\tTRANS(LocalReadv),\n\tTRANS(LocalWritev),\n#if XTRANS_SEND_FDS\n\tTRANS(LocalSendFdInvalid),\n\tTRANS(LocalRecvFdInvalid),\n#endif\n\tTRANS(LocalDisconnect),\n\tTRANS(LocalClose),\n\tTRANS(LocalCloseForCloning),\n};\n\n#endif /* LOCAL_TRANS_PTS */\n\n#ifdef LOCAL_TRANS_NAMED\n\nXtransport\tTRANS(NAMEDFuncs) = {\n\t/* Local Interface */\n\t\"named\",\n\tTRANS_LOCAL,\n#ifdef TRANS_CLIENT\n\tTRANS(LocalOpenCOTSClient),\n#endif /* TRANS_CLIENT */\n#ifdef TRANS_SERVER\n\tNULL,\n\tTRANS(LocalOpenCOTSServer),\n#endif /* TRANS_SERVER */\n#ifdef TRANS_CLIENT\n\tTRANS(LocalOpenCLTSClient),\n#endif /* TRANS_CLIENT */\n#ifdef TRANS_SERVER\n\tTRANS(LocalOpenCLTSServer),\n#endif /* TRANS_SERVER */\n#ifdef TRANS_REOPEN\n\tTRANS(LocalReopenCOTSServer),\n\tTRANS(LocalReopenCLTSServer),\n#endif\n\tTRANS(LocalSetOption),\n#ifdef TRANS_SERVER\n\tTRANS(LocalCreateListener),\n\tTRANS(LocalResetListener),\n\tTRANS(LocalAccept),\n#endif /* TRANS_SERVER */\n#ifdef TRANS_CLIENT\n\tTRANS(LocalConnect),\n#endif /* TRANS_CLIENT */\n\tTRANS(LocalBytesReadable),\n\tTRANS(LocalRead),\n\tTRANS(LocalWrite),\n\tTRANS(LocalReadv),\n\tTRANS(LocalWritev),\n#if XTRANS_SEND_FDS\n\tTRANS(LocalSendFdInvalid),\n\tTRANS(LocalRecvFdInvalid),\n#endif\n\tTRANS(LocalDisconnect),\n\tTRANS(LocalClose),\n\tTRANS(LocalCloseForCloning),\n};\n\n#ifdef sun\nXtransport\tTRANS(PIPEFuncs) = {\n\t/* Local Interface */\n\t\"pipe\",\n\tTRANS_ALIAS | TRANS_LOCAL,\n#ifdef TRANS_CLIENT\n\tTRANS(LocalOpenCOTSClient),\n#endif /* TRANS_CLIENT */\n#ifdef TRANS_SERVER\n\tNULL,\n\tTRANS(LocalOpenCOTSServer),\n#endif /* TRANS_SERVER */\n#ifdef TRANS_CLIENT\n\tTRANS(LocalOpenCLTSClient),\n#endif /* TRANS_CLIENT */\n#ifdef TRANS_SERVER\n\tTRANS(LocalOpenCLTSServer),\n#endif /* TRANS_SERVER */\n#ifdef TRANS_REOPEN\n\tTRANS(LocalReopenCOTSServer),\n\tTRANS(LocalReopenCLTSServer),\n#endif\n\tTRANS(LocalSetOption),\n#ifdef TRANS_SERVER\n\tTRANS(LocalCreateListener),\n\tTRANS(LocalResetListener),\n\tTRANS(LocalAccept),\n#endif /* TRANS_SERVER */\n#ifdef TRANS_CLIENT\n\tTRANS(LocalConnect),\n#endif /* TRANS_CLIENT */\n\tTRANS(LocalBytesReadable),\n\tTRANS(LocalRead),\n\tTRANS(LocalWrite),\n\tTRANS(LocalReadv),\n\tTRANS(LocalWritev),\n#if XTRANS_SEND_FDS\n\tTRANS(LocalSendFdInvalid),\n\tTRANS(LocalRecvFdInvalid),\n#endif\n\tTRANS(LocalDisconnect),\n\tTRANS(LocalClose),\n\tTRANS(LocalCloseForCloning),\n};\n#endif /* sun */\n#endif /* LOCAL_TRANS_NAMED */\n\n\n#ifdef LOCAL_TRANS_SCO\nXtransport\tTRANS(SCOFuncs) = {\n\t/* Local Interface */\n\t\"sco\",\n\tTRANS_LOCAL,\n#ifdef TRANS_CLIENT\n\tTRANS(LocalOpenCOTSClient),\n#endif /* TRANS_CLIENT */\n#ifdef TRANS_SERVER\n\tNULL,\n\tTRANS(LocalOpenCOTSServer),\n#endif /* TRANS_SERVER */\n#ifdef TRANS_CLIENT\n\tTRANS(LocalOpenCLTSClient),\n#endif /* TRANS_CLIENT */\n#ifdef TRANS_SERVER\n\tTRANS(LocalOpenCLTSServer),\n#endif /* TRANS_SERVER */\n#ifdef TRANS_REOPEN\n\tTRANS(LocalReopenCOTSServer),\n\tTRANS(LocalReopenCLTSServer),\n#endif\n\tTRANS(LocalSetOption),\n#ifdef TRANS_SERVER\n\tTRANS(LocalCreateListener),\n\tTRANS(LocalResetListener),\n\tTRANS(LocalAccept),\n#endif /* TRANS_SERVER */\n#ifdef TRANS_CLIENT\n\tTRANS(LocalConnect),\n#endif /* TRANS_CLIENT */\n\tTRANS(LocalBytesReadable),\n\tTRANS(LocalRead),\n\tTRANS(LocalWrite),\n\tTRANS(LocalReadv),\n\tTRANS(LocalWritev),\n#if XTRANS_SEND_FDS\n\tTRANS(LocalSendFdInvalid),\n\tTRANS(LocalRecvFdInvalid),\n#endif\n\tTRANS(LocalDisconnect),\n\tTRANS(LocalClose),\n\tTRANS(LocalCloseForCloning),\n};\n#endif /* LOCAL_TRANS_SCO */\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/X11/Xtrans/Xtranssock.c",
    "content": "/*\n * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.\n *\n * Permission is hereby granted, free of charge, to any person obtaining a\n * copy of this software and associated documentation files (the \"Software\"),\n * to deal in the Software without restriction, including without limitation\n * the rights to use, copy, modify, merge, publish, distribute, sublicense,\n * and/or sell copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice (including the next\n * paragraph) shall be included in all copies or substantial portions of the\n * Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL\n * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n * DEALINGS IN THE SOFTWARE.\n */\n/*\n\nCopyright 1993, 1994, 1998  The Open Group\n\nPermission to use, copy, modify, distribute, and sell this software and its\ndocumentation for any purpose is hereby granted without fee, provided that\nthe above copyright notice appear in all copies and that both that\ncopyright notice and this permission notice appear in supporting\ndocumentation.\n\nThe above copyright notice and this permission notice shall be included\nin all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\nOR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR\nOTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,\nARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\nOTHER DEALINGS IN THE SOFTWARE.\n\nExcept as contained in this notice, the name of the copyright holders shall\nnot be used in advertising or otherwise to promote the sale, use or\nother dealings in this Software without prior written authorization\nfrom the copyright holders.\n\n * Copyright 1993, 1994 NCR Corporation - Dayton, Ohio, USA\n *\n * All Rights Reserved\n *\n * Permission to use, copy, modify, and distribute this software and its\n * documentation for any purpose and without fee is hereby granted, provided\n * that the above copyright notice appear in all copies and that both that\n * copyright notice and this permission notice appear in supporting\n * documentation, and that the name NCR not be used in advertising\n * or publicity pertaining to distribution of the software without specific,\n * written prior permission.  NCR makes no representations about the\n * suitability of this software for any purpose.  It is provided \"as is\"\n * without express or implied warranty.\n *\n * NCR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,\n * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN\n * NO EVENT SHALL NCR BE LIABLE FOR ANY SPECIAL, INDIRECT OR\n * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS\n * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,\n * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN\n * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n */\n\n#include <ctype.h>\n#ifdef XTHREADS\n#include <X11/Xthreads.h>\n#endif\n\n#ifndef WIN32\n\n#if defined(TCPCONN) || defined(UNIXCONN)\n#include <sys/socket.h>\n#include <netinet/in.h>\n#include <arpa/inet.h>\n#endif\n\n#if defined(TCPCONN) || defined(UNIXCONN)\n#define X_INCLUDE_NETDB_H\n#define XOS_USE_NO_LOCKING\n#include <X11/Xos_r.h>\n#endif\n\n#ifdef UNIXCONN\n#ifndef X_NO_SYS_UN\n#include <sys/un.h>\n#endif\n#include <sys/stat.h>\n#endif\n\n\n#ifndef NO_TCP_H\n#if defined(linux) || defined(__GLIBC__)\n#include <sys/param.h>\n#endif /* osf */\n#if defined(__NetBSD__) || defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__DragonFly__)\n#include <sys/param.h>\n#include <machine/endian.h>\n#endif /* __NetBSD__ || __OpenBSD__ || __FreeBSD__ || __DragonFly__ */\n#include <netinet/tcp.h>\n#endif /* !NO_TCP_H */\n\n#include <sys/ioctl.h>\n#if defined(SVR4) || defined(__SVR4)\n#include <sys/filio.h>\n#endif\n\n#if (defined(__i386__) && defined(SYSV)) && !defined(SCO325) && !defined(sun)\n#include <net/errno.h>\n#endif\n\n#if defined(__i386__) && defined(SYSV)\n#include <sys/stropts.h>\n#endif\n\n#include <unistd.h>\n\n#else /* !WIN32 */\n\n#include <X11/Xwinsock.h>\n#include <X11/Xwindows.h>\n#include <X11/Xw32defs.h>\n#undef close\n#define close closesocket\n#define ECONNREFUSED WSAECONNREFUSED\n#define EADDRINUSE WSAEADDRINUSE\n#define EPROTOTYPE WSAEPROTOTYPE\n#undef EWOULDBLOCK\n#define EWOULDBLOCK WSAEWOULDBLOCK\n#define EINPROGRESS WSAEINPROGRESS\n#undef EINTR\n#define EINTR WSAEINTR\n#define X_INCLUDE_NETDB_H\n#define XOS_USE_MTSAFE_NETDBAPI\n#include <X11/Xos_r.h>\n#endif /* WIN32 */\n\n#if defined(SO_DONTLINGER) && defined(SO_LINGER)\n#undef SO_DONTLINGER\n#endif\n\n/* others don't need this */\n#define SocketInitOnce() /**/\n\n#ifdef linux\n#define HAVE_ABSTRACT_SOCKETS\n#endif\n\n#define MIN_BACKLOG 128\n#ifdef SOMAXCONN\n#if SOMAXCONN > MIN_BACKLOG\n#define BACKLOG SOMAXCONN\n#endif\n#endif\n#ifndef BACKLOG\n#define BACKLOG MIN_BACKLOG\n#endif\n\n/*\n * This is the Socket implementation of the X Transport service layer\n *\n * This file contains the implementation for both the UNIX and INET domains,\n * and can be built for either one, or both.\n *\n */\n\ntypedef struct _Sockettrans2dev {\n    const char\t*transname;\n    int\t\tfamily;\n    int\t\tdevcotsname;\n    int\t\tdevcltsname;\n    int\t\tprotocol;\n} Sockettrans2dev;\n\nstatic Sockettrans2dev Sockettrans2devtab[] = {\n#ifdef TCPCONN\n    {\"inet\",AF_INET,SOCK_STREAM,SOCK_DGRAM,0},\n#if !defined(IPv6) || !defined(AF_INET6)\n    {\"tcp\",AF_INET,SOCK_STREAM,SOCK_DGRAM,0},\n#else /* IPv6 */\n    {\"tcp\",AF_INET6,SOCK_STREAM,SOCK_DGRAM,0},\n    {\"tcp\",AF_INET,SOCK_STREAM,SOCK_DGRAM,0}, /* fallback */\n    {\"inet6\",AF_INET6,SOCK_STREAM,SOCK_DGRAM,0},\n#endif\n#endif /* TCPCONN */\n#ifdef UNIXCONN\n    {\"unix\",AF_UNIX,SOCK_STREAM,SOCK_DGRAM,0},\n#if !defined(LOCALCONN)\n    {\"local\",AF_UNIX,SOCK_STREAM,SOCK_DGRAM,0},\n#endif /* !LOCALCONN */\n#endif /* UNIXCONN */\n};\n\n#define NUMSOCKETFAMILIES (sizeof(Sockettrans2devtab)/sizeof(Sockettrans2dev))\n\n#ifdef TCPCONN\nstatic int TRANS(SocketINETClose) (XtransConnInfo ciptr);\n#endif\n\n#ifdef UNIXCONN\n\n\n#if defined(X11_t)\n#define UNIX_PATH \"/tmp/.X11-unix/X\"\n#define UNIX_DIR \"/tmp/.X11-unix\"\n#endif /* X11_t */\n#if defined(XIM_t)\n#define UNIX_PATH \"/tmp/.XIM-unix/XIM\"\n#define UNIX_DIR \"/tmp/.XIM-unix\"\n#endif /* XIM_t */\n#if defined(FS_t) || defined(FONT_t)\n#define UNIX_PATH \"/tmp/.font-unix/fs\"\n#define UNIX_DIR \"/tmp/.font-unix\"\n#endif /* FS_t || FONT_t */\n#if defined(ICE_t)\n#define UNIX_PATH \"/tmp/.ICE-unix/\"\n#define UNIX_DIR \"/tmp/.ICE-unix\"\n#endif /* ICE_t */\n#if defined(TEST_t)\n#define UNIX_PATH \"/tmp/.Test-unix/test\"\n#define UNIX_DIR \"/tmp/.Test-unix\"\n#endif\n#if defined(LBXPROXY_t)\n#define UNIX_PATH \"/tmp/.X11-unix/X\"\n#define UNIX_DIR  \"/tmp/.X11-unix\"\n#endif\n\n\n#endif /* UNIXCONN */\n\n#define PORTBUFSIZE\t32\n\n#ifndef MAXHOSTNAMELEN\n#define MAXHOSTNAMELEN 255\n#endif\n\n#if defined HAVE_SOCKLEN_T || (defined(IPv6) && defined(AF_INET6))\n# define SOCKLEN_T socklen_t\n#elif defined(SVR4) || defined(__SVR4) || defined(__SCO__)\n# define SOCKLEN_T size_t\n#else\n# define SOCKLEN_T int\n#endif\n\n/*\n * These are some utility function used by the real interface function below.\n */\n\nstatic int\nTRANS(SocketSelectFamily) (int first, const char *family)\n\n{\n    int     i;\n\n    prmsg (3,\"SocketSelectFamily(%s)\\n\", family);\n\n    for (i = first + 1; i < NUMSOCKETFAMILIES;i++)\n    {\n        if (!strcmp (family, Sockettrans2devtab[i].transname))\n\t    return i;\n    }\n\n    return (first == -1 ? -2 : -1);\n}\n\n\n/*\n * This function gets the local address of the socket and stores it in the\n * XtransConnInfo structure for the connection.\n */\n\nstatic int\nTRANS(SocketINETGetAddr) (XtransConnInfo ciptr)\n\n{\n#if defined(IPv6) && defined(AF_INET6)\n    struct sockaddr_storage socknamev6;\n#else\n    struct sockaddr_in socknamev4;\n#endif\n    void *socknamePtr;\n    SOCKLEN_T namelen;\n\n    prmsg (3,\"SocketINETGetAddr(%p)\\n\", ciptr);\n\n#if defined(IPv6) && defined(AF_INET6)\n    namelen = sizeof(socknamev6);\n    socknamePtr = &socknamev6;\n#else\n    namelen = sizeof(socknamev4);\n    socknamePtr = &socknamev4;\n#endif\n\n    bzero(socknamePtr, namelen);\n\n    if (getsockname (ciptr->fd,(struct sockaddr *) socknamePtr,\n\t\t     (void *)&namelen) < 0)\n    {\n#ifdef WIN32\n\terrno = WSAGetLastError();\n#endif\n\tprmsg (1,\"SocketINETGetAddr: getsockname() failed: %d\\n\",\n\t    EGET());\n\treturn -1;\n    }\n\n    /*\n     * Everything looks good: fill in the XtransConnInfo structure.\n     */\n\n    if ((ciptr->addr = malloc (namelen)) == NULL)\n    {\n        prmsg (1,\n\t    \"SocketINETGetAddr: Can't allocate space for the addr\\n\");\n        return -1;\n    }\n\n#if defined(IPv6) && defined(AF_INET6)\n    ciptr->family = ((struct sockaddr *)socknamePtr)->sa_family;\n#else\n    ciptr->family = socknamev4.sin_family;\n#endif\n    ciptr->addrlen = namelen;\n    memcpy (ciptr->addr, socknamePtr, ciptr->addrlen);\n\n    return 0;\n}\n\n\n/*\n * This function gets the remote address of the socket and stores it in the\n * XtransConnInfo structure for the connection.\n */\n\nstatic int\nTRANS(SocketINETGetPeerAddr) (XtransConnInfo ciptr)\n\n{\n#if defined(IPv6) && defined(AF_INET6)\n    struct sockaddr_storage socknamev6;\n#endif\n    struct sockaddr_in \tsocknamev4;\n    void *socknamePtr;\n    SOCKLEN_T namelen;\n\n#if defined(IPv6) && defined(AF_INET6)\n    if (ciptr->family == AF_INET6)\n    {\n\tnamelen = sizeof(socknamev6);\n\tsocknamePtr = &socknamev6;\n    }\n    else\n#endif\n    {\n\tnamelen = sizeof(socknamev4);\n\tsocknamePtr = &socknamev4;\n    }\n\n    bzero(socknamePtr, namelen);\n\n    prmsg (3,\"SocketINETGetPeerAddr(%p)\\n\", ciptr);\n\n    if (getpeername (ciptr->fd, (struct sockaddr *) socknamePtr,\n\t\t     (void *)&namelen) < 0)\n    {\n#ifdef WIN32\n\terrno = WSAGetLastError();\n#endif\n\tprmsg (1,\"SocketINETGetPeerAddr: getpeername() failed: %d\\n\",\n\t    EGET());\n\treturn -1;\n    }\n\n    /*\n     * Everything looks good: fill in the XtransConnInfo structure.\n     */\n\n    if ((ciptr->peeraddr = malloc (namelen)) == NULL)\n    {\n        prmsg (1,\n\t   \"SocketINETGetPeerAddr: Can't allocate space for the addr\\n\");\n        return -1;\n    }\n\n    ciptr->peeraddrlen = namelen;\n    memcpy (ciptr->peeraddr, socknamePtr, ciptr->peeraddrlen);\n\n    return 0;\n}\n\n\nstatic XtransConnInfo\nTRANS(SocketOpen) (int i, int type)\n\n{\n    XtransConnInfo\tciptr;\n\n    prmsg (3,\"SocketOpen(%d,%d)\\n\", i, type);\n\n    if ((ciptr = calloc (1, sizeof(struct _XtransConnInfo))) == NULL)\n    {\n\tprmsg (1, \"SocketOpen: malloc failed\\n\");\n\treturn NULL;\n    }\n\n    if ((ciptr->fd = socket(Sockettrans2devtab[i].family, type,\n\tSockettrans2devtab[i].protocol)) < 0\n#ifndef WIN32\n#if (defined(X11_t) && !defined(USE_POLL)) || defined(FS_t) || defined(FONT_t)\n       || ciptr->fd >= sysconf(_SC_OPEN_MAX)\n#endif\n#endif\n      ) {\n#ifdef WIN32\n\terrno = WSAGetLastError();\n#endif\n\tprmsg (2, \"SocketOpen: socket() failed for %s\\n\",\n\t    Sockettrans2devtab[i].transname);\n\n\tfree (ciptr);\n\treturn NULL;\n    }\n\n#ifdef TCP_NODELAY\n    if (Sockettrans2devtab[i].family == AF_INET\n#if defined(IPv6) && defined(AF_INET6)\n      || Sockettrans2devtab[i].family == AF_INET6\n#endif\n    )\n    {\n\t/*\n\t * turn off TCP coalescence for INET sockets\n\t */\n\n\tint tmp = 1;\n\tsetsockopt (ciptr->fd, IPPROTO_TCP, TCP_NODELAY,\n\t    (char *) &tmp, sizeof (int));\n    }\n#endif\n\n    /*\n     * Some systems provide a really small default buffer size for\n     * UNIX sockets.  Bump it up a bit such that large transfers don't\n     * proceed at glacial speed.\n     */\n#ifdef SO_SNDBUF\n    if (Sockettrans2devtab[i].family == AF_UNIX)\n    {\n\tSOCKLEN_T len = sizeof (int);\n\tint val;\n\n\tif (getsockopt (ciptr->fd, SOL_SOCKET, SO_SNDBUF,\n\t    (char *) &val, &len) == 0 && val < 64 * 1024)\n\t{\n\t    val = 64 * 1024;\n\t    setsockopt (ciptr->fd, SOL_SOCKET, SO_SNDBUF,\n\t        (char *) &val, sizeof (int));\n\t}\n    }\n#endif\n\n    return ciptr;\n}\n\n\n#ifdef TRANS_REOPEN\n\nstatic XtransConnInfo\nTRANS(SocketReopen) (int i _X_UNUSED, int type, int fd, const char *port)\n\n{\n    XtransConnInfo\tciptr;\n    int portlen;\n    struct sockaddr *addr;\n    size_t addrlen;\n\n    prmsg (3,\"SocketReopen(%d,%d,%s)\\n\", type, fd, port);\n\n    if (port == NULL) {\n      prmsg (1, \"SocketReopen: port was null!\\n\");\n      return NULL;\n    }\n\n    portlen = strlen(port) + 1; // include space for trailing null\n#ifdef SOCK_MAXADDRLEN\n    if (portlen < 0 || portlen > (SOCK_MAXADDRLEN + 2)) {\n      prmsg (1, \"SocketReopen: invalid portlen %d\\n\", portlen);\n      return NULL;\n    }\n    if (portlen < 14) portlen = 14;\n#else\n    if (portlen < 0 || portlen > 14) {\n      prmsg (1, \"SocketReopen: invalid portlen %d\\n\", portlen);\n      return NULL;\n    }\n#endif /*SOCK_MAXADDRLEN*/\n\n    if ((ciptr = calloc (1, sizeof(struct _XtransConnInfo))) == NULL)\n    {\n\tprmsg (1, \"SocketReopen: malloc(ciptr) failed\\n\");\n\treturn NULL;\n    }\n\n    ciptr->fd = fd;\n\n    addrlen = portlen + offsetof(struct sockaddr, sa_data);\n    if ((addr = calloc (1, addrlen)) == NULL) {\n\tprmsg (1, \"SocketReopen: malloc(addr) failed\\n\");\n\tfree (ciptr);\n\treturn NULL;\n    }\n    ciptr->addr = (char *) addr;\n    ciptr->addrlen = addrlen;\n\n    if ((ciptr->peeraddr = calloc (1, addrlen)) == NULL) {\n\tprmsg (1, \"SocketReopen: malloc(portaddr) failed\\n\");\n\tfree (addr);\n\tfree (ciptr);\n\treturn NULL;\n    }\n    ciptr->peeraddrlen = addrlen;\n\n    /* Initialize ciptr structure as if it were a normally-opened unix socket */\n    ciptr->flags = TRANS_LOCAL | TRANS_NOUNLINK;\n#ifdef BSD44SOCKETS\n    addr->sa_len = addrlen;\n#endif\n    addr->sa_family = AF_UNIX;\n#ifdef HAS_STRLCPY\n    strlcpy(addr->sa_data, port, portlen);\n#else\n    strncpy(addr->sa_data, port, portlen);\n#endif\n    ciptr->family = AF_UNIX;\n    memcpy(ciptr->peeraddr, ciptr->addr, addrlen);\n    ciptr->port = rindex(addr->sa_data, ':');\n    if (ciptr->port == NULL) {\n\tif (is_numeric(addr->sa_data)) {\n\t    ciptr->port = addr->sa_data;\n\t}\n    } else if (ciptr->port[0] == ':') {\n\tciptr->port++;\n    }\n    /* port should now point to portnum or NULL */\n    return ciptr;\n}\n\n#endif /* TRANS_REOPEN */\n\n\n/*\n * These functions are the interface supplied in the Xtransport structure\n */\n\n#ifdef TRANS_CLIENT\n\nstatic XtransConnInfo\nTRANS(SocketOpenCOTSClientBase) (const char *transname, const char *protocol,\n\t\t\t   const char *host, const char *port, int previndex)\n{\n    XtransConnInfo\tciptr;\n    int\t\t\ti = previndex;\n\n    prmsg (2, \"SocketOpenCOTSClient(%s,%s,%s)\\n\",\n\tprotocol, host, port);\n\n    SocketInitOnce();\n\n    while ((i = TRANS(SocketSelectFamily) (i, transname)) >= 0) {\n\tif ((ciptr = TRANS(SocketOpen) (\n\t\ti, Sockettrans2devtab[i].devcotsname)) != NULL) {\n\t    /* Save the index for later use */\n\n\t    ciptr->index = i;\n\t    break;\n\t}\n    }\n    if (i < 0) {\n\tif (i == -1)\n\t    prmsg (1,\"SocketOpenCOTSClient: Unable to open socket for %s\\n\",\n\t\t   transname);\n\telse\n\t    prmsg (1,\"SocketOpenCOTSClient: Unable to determine socket type for %s\\n\",\n\t\t   transname);\n\treturn NULL;\n    }\n\n    return ciptr;\n}\n\nstatic XtransConnInfo\nTRANS(SocketOpenCOTSClient) (Xtransport *thistrans, const char *protocol,\n\t\t\t     const char *host, const char *port)\n{\n    return TRANS(SocketOpenCOTSClientBase)(\n\t\t\tthistrans->TransName, protocol, host, port, -1);\n}\n\n\n#endif /* TRANS_CLIENT */\n\n\n#ifdef TRANS_SERVER\n\nstatic XtransConnInfo\nTRANS(SocketOpenCOTSServer) (Xtransport *thistrans, const char *protocol,\n\t\t\t     const char *host, const char *port)\n\n{\n    XtransConnInfo\tciptr;\n    int\ti = -1;\n\n    prmsg (2,\"SocketOpenCOTSServer(%s,%s,%s)\\n\", protocol, host, port);\n\n    SocketInitOnce();\n\n    while ((i = TRANS(SocketSelectFamily) (i, thistrans->TransName)) >= 0) {\n\tif ((ciptr = TRANS(SocketOpen) (\n\t\t i, Sockettrans2devtab[i].devcotsname)) != NULL)\n\t    break;\n    }\n    if (i < 0) {\n\tif (i == -1)\n\t    prmsg (1,\"SocketOpenCOTSServer: Unable to open socket for %s\\n\",\n\t\t   thistrans->TransName);\n\telse\n\t    prmsg (1,\"SocketOpenCOTSServer: Unable to determine socket type for %s\\n\",\n\t\t   thistrans->TransName);\n\treturn NULL;\n    }\n\n    /*\n     * Using this prevents the bind() check for an existing server listening\n     * on the same port, but it is required for other reasons.\n     */\n#ifdef SO_REUSEADDR\n\n    /*\n     * SO_REUSEADDR only applied to AF_INET && AF_INET6\n     */\n\n    if (Sockettrans2devtab[i].family == AF_INET\n#if defined(IPv6) && defined(AF_INET6)\n      || Sockettrans2devtab[i].family == AF_INET6\n#endif\n    )\n    {\n\tint one = 1;\n\tsetsockopt (ciptr->fd, SOL_SOCKET, SO_REUSEADDR,\n\t\t    (char *) &one, sizeof (int));\n    }\n#endif\n#ifdef IPV6_V6ONLY\n    if (Sockettrans2devtab[i].family == AF_INET6)\n    {\n\tint one = 1;\n\tsetsockopt(ciptr->fd, IPPROTO_IPV6, IPV6_V6ONLY, &one, sizeof(int));\n    }\n#endif\n    /* Save the index for later use */\n\n    ciptr->index = i;\n\n    return ciptr;\n}\n\n#endif /* TRANS_SERVER */\n\n\n#ifdef TRANS_CLIENT\n\nstatic XtransConnInfo\nTRANS(SocketOpenCLTSClient) (Xtransport *thistrans, const char *protocol,\n\t\t\t     const char *host, const char *port)\n\n{\n    XtransConnInfo\tciptr;\n    int\t\t\ti = -1;\n\n    prmsg (2,\"SocketOpenCLTSClient(%s,%s,%s)\\n\", protocol, host, port);\n\n    SocketInitOnce();\n\n    while ((i = TRANS(SocketSelectFamily) (i, thistrans->TransName)) >= 0) {\n\tif ((ciptr = TRANS(SocketOpen) (\n\t\t i, Sockettrans2devtab[i].devcotsname)) != NULL)\n\t    break;\n    }\n    if (i < 0) {\n\tif (i == -1)\n\t    prmsg (1,\"SocketOpenCLTSClient: Unable to open socket for %s\\n\",\n\t\t   thistrans->TransName);\n\telse\n\t    prmsg (1,\"SocketOpenCLTSClient: Unable to determine socket type for %s\\n\",\n\t\t   thistrans->TransName);\n\treturn NULL;\n    }\n\n    /* Save the index for later use */\n\n    ciptr->index = i;\n\n    return ciptr;\n}\n\n#endif /* TRANS_CLIENT */\n\n\n#ifdef TRANS_SERVER\n\nstatic XtransConnInfo\nTRANS(SocketOpenCLTSServer) (Xtransport *thistrans, const char *protocol,\n\t\t\t     const char *host, const char *port)\n\n{\n    XtransConnInfo\tciptr;\n    int\ti = -1;\n\n    prmsg (2,\"SocketOpenCLTSServer(%s,%s,%s)\\n\", protocol, host, port);\n\n    SocketInitOnce();\n\n    while ((i = TRANS(SocketSelectFamily) (i, thistrans->TransName)) >= 0) {\n\tif ((ciptr = TRANS(SocketOpen) (\n\t\t i, Sockettrans2devtab[i].devcotsname)) != NULL)\n\t    break;\n    }\n    if (i < 0) {\n\tif (i == -1)\n\t    prmsg (1,\"SocketOpenCLTSServer: Unable to open socket for %s\\n\",\n\t\t   thistrans->TransName);\n\telse\n\t    prmsg (1,\"SocketOpenCLTSServer: Unable to determine socket type for %s\\n\",\n\t\t   thistrans->TransName);\n\treturn NULL;\n    }\n\n#ifdef IPV6_V6ONLY\n    if (Sockettrans2devtab[i].family == AF_INET6)\n    {\n\tint one = 1;\n\tsetsockopt(ciptr->fd, IPPROTO_IPV6, IPV6_V6ONLY, &one, sizeof(int));\n    }\n#endif\n    /* Save the index for later use */\n\n    ciptr->index = i;\n\n    return ciptr;\n}\n\n#endif /* TRANS_SERVER */\n\n\n#ifdef TRANS_REOPEN\n\nstatic XtransConnInfo\nTRANS(SocketReopenCOTSServer) (Xtransport *thistrans, int fd, const char *port)\n\n{\n    XtransConnInfo\tciptr;\n    int\t\t\ti = -1;\n\n    prmsg (2,\n\t\"SocketReopenCOTSServer(%d, %s)\\n\", fd, port);\n\n    SocketInitOnce();\n\n    while ((i = TRANS(SocketSelectFamily) (i, thistrans->TransName)) >= 0) {\n\tif ((ciptr = TRANS(SocketReopen) (\n\t\t i, Sockettrans2devtab[i].devcotsname, fd, port)) != NULL)\n\t    break;\n    }\n    if (i < 0) {\n\tif (i == -1)\n\t    prmsg (1,\"SocketReopenCOTSServer: Unable to open socket for %s\\n\",\n\t\t   thistrans->TransName);\n\telse\n\t    prmsg (1,\"SocketReopenCOTSServer: Unable to determine socket type for %s\\n\",\n\t\t   thistrans->TransName);\n\treturn NULL;\n    }\n\n    /* Save the index for later use */\n\n    ciptr->index = i;\n\n    return ciptr;\n}\n\nstatic XtransConnInfo\nTRANS(SocketReopenCLTSServer) (Xtransport *thistrans, int fd, const char *port)\n\n{\n    XtransConnInfo\tciptr;\n    int\t\t\ti = -1;\n\n    prmsg (2,\n\t\"SocketReopenCLTSServer(%d, %s)\\n\", fd, port);\n\n    SocketInitOnce();\n\n    while ((i = TRANS(SocketSelectFamily) (i, thistrans->TransName)) >= 0) {\n\tif ((ciptr = TRANS(SocketReopen) (\n\t\t i, Sockettrans2devtab[i].devcotsname, fd, port)) != NULL)\n\t    break;\n    }\n    if (i < 0) {\n\tif (i == -1)\n\t    prmsg (1,\"SocketReopenCLTSServer: Unable to open socket for %s\\n\",\n\t\t   thistrans->TransName);\n\telse\n\t    prmsg (1,\"SocketReopenCLTSServer: Unable to determine socket type for %s\\n\",\n\t\t   thistrans->TransName);\n\treturn NULL;\n    }\n\n    /* Save the index for later use */\n\n    ciptr->index = i;\n\n    return ciptr;\n}\n\n#endif /* TRANS_REOPEN */\n\n\nstatic int\nTRANS(SocketSetOption) (XtransConnInfo ciptr, int option, int arg)\n\n{\n    prmsg (2,\"SocketSetOption(%d,%d,%d)\\n\", ciptr->fd, option, arg);\n\n    return -1;\n}\n\n#ifdef UNIXCONN\nstatic int\nset_sun_path(const char *port, const char *upath, char *path, int abstract)\n{\n    struct sockaddr_un s;\n    int maxlen = sizeof(s.sun_path) - 1;\n    const char *at = \"\";\n\n    if (!port || !*port || !path)\n\treturn -1;\n\n#ifdef HAVE_ABSTRACT_SOCKETS\n    if (port[0] == '@')\n\tupath = \"\";\n    else if (abstract)\n\tat = \"@\";\n#endif\n\n    if (*port == '/') /* a full pathname */\n\tupath = \"\";\n\n    if (strlen(port) + strlen(upath) > maxlen)\n\treturn -1;\n    snprintf(path, sizeof(s.sun_path), \"%s%s%s\", at, upath, port);\n    return 0;\n}\n#endif\n\n#ifdef TRANS_SERVER\n\nstatic int\nTRANS(SocketCreateListener) (XtransConnInfo ciptr,\n\t\t\t     struct sockaddr *sockname,\n\t\t\t     int socknamelen, unsigned int flags)\n\n{\n    SOCKLEN_T namelen = socknamelen;\n    int\tfd = ciptr->fd;\n    int\tretry;\n\n    prmsg (3, \"SocketCreateListener(%p,%d)\\n\", ciptr, fd);\n\n    if (Sockettrans2devtab[ciptr->index].family == AF_INET\n#if defined(IPv6) && defined(AF_INET6)\n      || Sockettrans2devtab[ciptr->index].family == AF_INET6\n#endif\n\t)\n\tretry = 20;\n    else\n\tretry = 0;\n\n    while (bind (fd, (struct sockaddr *) sockname, namelen) < 0)\n    {\n\tif (errno == EADDRINUSE) {\n\t    if (flags & ADDR_IN_USE_ALLOWED)\n\t\tbreak;\n\t    else\n\t\treturn TRANS_ADDR_IN_USE;\n\t}\n\n\tif (retry-- == 0) {\n\t    prmsg (1, \"SocketCreateListener: failed to bind listener\\n\");\n\t    close (fd);\n\t    return TRANS_CREATE_LISTENER_FAILED;\n\t}\n#ifdef SO_REUSEADDR\n\tsleep (1);\n#else\n\tsleep (10);\n#endif /* SO_REUSEDADDR */\n    }\n\n    if (Sockettrans2devtab[ciptr->index].family == AF_INET\n#if defined(IPv6) && defined(AF_INET6)\n      || Sockettrans2devtab[ciptr->index].family == AF_INET6\n#endif\n\t) {\n#ifdef SO_DONTLINGER\n\tsetsockopt (fd, SOL_SOCKET, SO_DONTLINGER, (char *) NULL, 0);\n#else\n#ifdef SO_LINGER\n    {\n\tstatic int linger[2] = { 0, 0 };\n\tsetsockopt (fd, SOL_SOCKET, SO_LINGER,\n\t\t(char *) linger, sizeof (linger));\n    }\n#endif\n#endif\n}\n\n    if (listen (fd, BACKLOG) < 0)\n    {\n\tprmsg (1, \"SocketCreateListener: listen() failed\\n\");\n\tclose (fd);\n\treturn TRANS_CREATE_LISTENER_FAILED;\n    }\n\n    /* Set a flag to indicate that this connection is a listener */\n\n    ciptr->flags = 1 | (ciptr->flags & TRANS_KEEPFLAGS);\n\n    return 0;\n}\n\n#ifdef TCPCONN\nstatic int\nTRANS(SocketINETCreateListener) (XtransConnInfo ciptr, const char *port,\n                                 unsigned int flags)\n\n{\n#if defined(IPv6) && defined(AF_INET6)\n    struct sockaddr_storage sockname;\n#else\n    struct sockaddr_in\t    sockname;\n#endif\n    unsigned short\t    sport;\n    SOCKLEN_T\tnamelen = sizeof(sockname);\n    int\t\tstatus;\n    long\ttmpport;\n#ifdef XTHREADS_NEEDS_BYNAMEPARAMS\n    _Xgetservbynameparams sparams;\n#endif\n    struct servent *servp;\n\n#ifdef X11_t\n    char\tportbuf[PORTBUFSIZE];\n#endif\n\n    prmsg (2, \"SocketINETCreateListener(%s)\\n\", port);\n\n#ifdef X11_t\n    /*\n     * X has a well known port, that is transport dependent. It is easier\n     * to handle it here, than try and come up with a transport independent\n     * representation that can be passed in and resolved the usual way.\n     *\n     * The port that is passed here is really a string containing the idisplay\n     * from ConnectDisplay().\n     */\n\n    if (is_numeric (port))\n    {\n\t/* fixup the server port address */\n\ttmpport = X_TCP_PORT + strtol (port, (char**)NULL, 10);\n\tsnprintf (portbuf, sizeof(portbuf), \"%lu\", tmpport);\n\tport = portbuf;\n    }\n#endif\n\n    if (port && *port)\n    {\n\t/* Check to see if the port string is just a number (handles X11) */\n\n\tif (!is_numeric (port))\n\t{\n\t    if ((servp = _XGetservbyname (port,\"tcp\",sparams)) == NULL)\n\t    {\n\t\tprmsg (1,\n\t     \"SocketINETCreateListener: Unable to get service for %s\\n\",\n\t\t      port);\n\t\treturn TRANS_CREATE_LISTENER_FAILED;\n\t    }\n\t    /* we trust getservbyname to return a valid number */\n\t    sport = servp->s_port;\n\t}\n\telse\n\t{\n\t    tmpport = strtol (port, (char**)NULL, 10);\n\t    /*\n\t     * check that somehow the port address isn't negative or in\n\t     * the range of reserved port addresses. This can happen and\n\t     * be very bad if the server is suid-root and the user does\n\t     * something (dumb) like `X :60049`.\n\t     */\n\t    if (tmpport < 1024 || tmpport > USHRT_MAX)\n\t\treturn TRANS_CREATE_LISTENER_FAILED;\n\n\t    sport = (unsigned short) tmpport;\n\t}\n    }\n    else\n\tsport = 0;\n\n    bzero(&sockname, sizeof(sockname));\n#if defined(IPv6) && defined(AF_INET6)\n    if (Sockettrans2devtab[ciptr->index].family == AF_INET) {\n\tnamelen = sizeof (struct sockaddr_in);\n#ifdef BSD44SOCKETS\n\t((struct sockaddr_in *)&sockname)->sin_len = namelen;\n#endif\n\t((struct sockaddr_in *)&sockname)->sin_family = AF_INET;\n\t((struct sockaddr_in *)&sockname)->sin_port = htons(sport);\n\t((struct sockaddr_in *)&sockname)->sin_addr.s_addr = htonl(INADDR_ANY);\n    } else {\n\tnamelen = sizeof (struct sockaddr_in6);\n#ifdef SIN6_LEN\n\t((struct sockaddr_in6 *)&sockname)->sin6_len = sizeof(sockname);\n#endif\n\t((struct sockaddr_in6 *)&sockname)->sin6_family = AF_INET6;\n\t((struct sockaddr_in6 *)&sockname)->sin6_port = htons(sport);\n\t((struct sockaddr_in6 *)&sockname)->sin6_addr = in6addr_any;\n    }\n#else\n#ifdef BSD44SOCKETS\n    sockname.sin_len = sizeof (sockname);\n#endif\n    sockname.sin_family = AF_INET;\n    sockname.sin_port = htons (sport);\n    sockname.sin_addr.s_addr = htonl (INADDR_ANY);\n#endif\n\n    if ((status = TRANS(SocketCreateListener) (ciptr,\n\t(struct sockaddr *) &sockname, namelen, flags)) < 0)\n    {\n\tprmsg (1,\n    \"SocketINETCreateListener: ...SocketCreateListener() failed\\n\");\n\treturn status;\n    }\n\n    if (TRANS(SocketINETGetAddr) (ciptr) < 0)\n    {\n\tprmsg (1,\n       \"SocketINETCreateListener: ...SocketINETGetAddr() failed\\n\");\n\treturn TRANS_CREATE_LISTENER_FAILED;\n    }\n\n    return 0;\n}\n\n#endif /* TCPCONN */\n\n\n#ifdef UNIXCONN\n\nstatic int\nTRANS(SocketUNIXCreateListener) (XtransConnInfo ciptr, const char *port,\n\t\t\t\t unsigned int flags)\n\n{\n    struct sockaddr_un\tsockname;\n    int\t\t\tnamelen;\n    int\t\t\toldUmask;\n    int\t\t\tstatus;\n    unsigned int\tmode;\n    char\t\ttmpport[108];\n\n    int\t\t\tabstract = 0;\n#ifdef HAVE_ABSTRACT_SOCKETS\n    abstract = ciptr->transptr->flags & TRANS_ABSTRACT;\n#endif\n\n    prmsg (2, \"SocketUNIXCreateListener(%s)\\n\",\n\tport ? port : \"NULL\");\n\n    /* Make sure the directory is created */\n\n    oldUmask = umask (0);\n\n#ifdef UNIX_DIR\n#ifdef HAS_STICKY_DIR_BIT\n    mode = 01777;\n#else\n    mode = 0777;\n#endif\n    if (!abstract && trans_mkdir(UNIX_DIR, mode) == -1) {\n\tprmsg (1, \"SocketUNIXCreateListener: mkdir(%s) failed, errno = %d\\n\",\n\t       UNIX_DIR, errno);\n\t(void) umask (oldUmask);\n\treturn TRANS_CREATE_LISTENER_FAILED;\n    }\n#endif\n\n    memset(&sockname, 0, sizeof(sockname));\n    sockname.sun_family = AF_UNIX;\n\n    if (!(port && *port)) {\n\tsnprintf (tmpport, sizeof(tmpport), \"%s%ld\", UNIX_PATH, (long)getpid());\n\tport = tmpport;\n    }\n    if (set_sun_path(port, UNIX_PATH, sockname.sun_path, abstract) != 0) {\n\tprmsg (1, \"SocketUNIXCreateListener: path too long\\n\");\n\treturn TRANS_CREATE_LISTENER_FAILED;\n    }\n\n#if (defined(BSD44SOCKETS) || defined(__UNIXWARE__))\n    sockname.sun_len = strlen(sockname.sun_path);\n#endif\n\n#if defined(BSD44SOCKETS) || defined(SUN_LEN)\n    namelen = SUN_LEN(&sockname);\n#else\n    namelen = strlen(sockname.sun_path) + offsetof(struct sockaddr_un, sun_path);\n#endif\n\n    if (abstract) {\n\tsockname.sun_path[0] = '\\0';\n\tnamelen = offsetof(struct sockaddr_un, sun_path) + 1 + strlen(&sockname.sun_path[1]);\n    }\n    else\n\tunlink (sockname.sun_path);\n\n    if ((status = TRANS(SocketCreateListener) (ciptr,\n\t(struct sockaddr *) &sockname, namelen, flags)) < 0)\n    {\n\tprmsg (1,\n    \"SocketUNIXCreateListener: ...SocketCreateListener() failed\\n\");\n\t(void) umask (oldUmask);\n\treturn status;\n    }\n\n    /*\n     * Now that the listener is esablished, create the addr info for\n     * this connection. getpeername() doesn't work for UNIX Domain Sockets\n     * on some systems (hpux at least), so we will just do it manually, instead\n     * of calling something like TRANS(SocketUNIXGetAddr).\n     */\n\n    namelen = sizeof (sockname); /* this will always make it the same size */\n\n    if ((ciptr->addr = malloc (namelen)) == NULL)\n    {\n        prmsg (1,\n        \"SocketUNIXCreateListener: Can't allocate space for the addr\\n\");\n\t(void) umask (oldUmask);\n        return TRANS_CREATE_LISTENER_FAILED;\n    }\n\n    if (abstract)\n\tsockname.sun_path[0] = '@';\n\n    ciptr->family = sockname.sun_family;\n    ciptr->addrlen = namelen;\n    memcpy (ciptr->addr, &sockname, ciptr->addrlen);\n\n    (void) umask (oldUmask);\n\n    return 0;\n}\n\n\nstatic int\nTRANS(SocketUNIXResetListener) (XtransConnInfo ciptr)\n\n{\n    /*\n     * See if the unix domain socket has disappeared.  If it has, recreate it.\n     */\n\n    struct sockaddr_un \t*unsock = (struct sockaddr_un *) ciptr->addr;\n    struct stat\t\tstatb;\n    int \t\tstatus = TRANS_RESET_NOOP;\n    unsigned int\tmode;\n    int abstract = 0;\n#ifdef HAVE_ABSTRACT_SOCKETS\n    abstract = ciptr->transptr->flags & TRANS_ABSTRACT;\n#endif\n\n    prmsg (3, \"SocketUNIXResetListener(%p,%d)\\n\", ciptr, ciptr->fd);\n\n    if (!abstract && (\n\tstat (unsock->sun_path, &statb) == -1 ||\n        ((statb.st_mode & S_IFMT) !=\n#if defined(NCR) || defined(SCO325) || !defined(S_IFSOCK)\n\t  \t\tS_IFIFO\n#else\n\t\t\tS_IFSOCK\n#endif\n\t\t\t\t)))\n    {\n\tint oldUmask = umask (0);\n\n#ifdef UNIX_DIR\n#ifdef HAS_STICKY_DIR_BIT\n\tmode = 01777;\n#else\n\tmode = 0777;\n#endif\n        if (trans_mkdir(UNIX_DIR, mode) == -1) {\n            prmsg (1, \"SocketUNIXResetListener: mkdir(%s) failed, errno = %d\\n\",\n\t    UNIX_DIR, errno);\n\t    (void) umask (oldUmask);\n\t    return TRANS_RESET_FAILURE;\n        }\n#endif\n\n\tclose (ciptr->fd);\n\tunlink (unsock->sun_path);\n\n\tif ((ciptr->fd = socket (AF_UNIX, SOCK_STREAM, 0)) < 0)\n\t{\n\t    TRANS(FreeConnInfo) (ciptr);\n\t    (void) umask (oldUmask);\n\t    return TRANS_RESET_FAILURE;\n\t}\n\n\tif (bind (ciptr->fd, (struct sockaddr *) unsock, ciptr->addrlen) < 0)\n\t{\n\t    close (ciptr->fd);\n\t    TRANS(FreeConnInfo) (ciptr);\n\t    return TRANS_RESET_FAILURE;\n\t}\n\n\tif (listen (ciptr->fd, BACKLOG) < 0)\n\t{\n\t    close (ciptr->fd);\n\t    TRANS(FreeConnInfo) (ciptr);\n\t    (void) umask (oldUmask);\n\t    return TRANS_RESET_FAILURE;\n\t}\n\n\tumask (oldUmask);\n\n\tstatus = TRANS_RESET_NEW_FD;\n    }\n\n    return status;\n}\n\n#endif /* UNIXCONN */\n\n\n#ifdef TCPCONN\n\nstatic XtransConnInfo\nTRANS(SocketINETAccept) (XtransConnInfo ciptr, int *status)\n\n{\n    XtransConnInfo\tnewciptr;\n    struct sockaddr_in\tsockname;\n    SOCKLEN_T\t\tnamelen = sizeof(sockname);\n\n    prmsg (2, \"SocketINETAccept(%p,%d)\\n\", ciptr, ciptr->fd);\n\n    if ((newciptr = calloc (1, sizeof(struct _XtransConnInfo))) == NULL)\n    {\n\tprmsg (1, \"SocketINETAccept: malloc failed\\n\");\n\t*status = TRANS_ACCEPT_BAD_MALLOC;\n\treturn NULL;\n    }\n\n    if ((newciptr->fd = accept (ciptr->fd,\n\t(struct sockaddr *) &sockname, (void *)&namelen)) < 0)\n    {\n#ifdef WIN32\n\terrno = WSAGetLastError();\n#endif\n\tprmsg (1, \"SocketINETAccept: accept() failed\\n\");\n\tfree (newciptr);\n\t*status = TRANS_ACCEPT_FAILED;\n\treturn NULL;\n    }\n\n#ifdef TCP_NODELAY\n    {\n\t/*\n\t * turn off TCP coalescence for INET sockets\n\t */\n\n\tint tmp = 1;\n\tsetsockopt (newciptr->fd, IPPROTO_TCP, TCP_NODELAY,\n\t    (char *) &tmp, sizeof (int));\n    }\n#endif\n\n    /*\n     * Get this address again because the transport may give a more\n     * specific address now that a connection is established.\n     */\n\n    if (TRANS(SocketINETGetAddr) (newciptr) < 0)\n    {\n\tprmsg (1,\n\t    \"SocketINETAccept: ...SocketINETGetAddr() failed:\\n\");\n\tclose (newciptr->fd);\n\tfree (newciptr);\n\t*status = TRANS_ACCEPT_MISC_ERROR;\n        return NULL;\n    }\n\n    if (TRANS(SocketINETGetPeerAddr) (newciptr) < 0)\n    {\n\tprmsg (1,\n\t  \"SocketINETAccept: ...SocketINETGetPeerAddr() failed:\\n\");\n\tclose (newciptr->fd);\n\tif (newciptr->addr) free (newciptr->addr);\n\tfree (newciptr);\n\t*status = TRANS_ACCEPT_MISC_ERROR;\n        return NULL;\n    }\n\n    *status = 0;\n\n    return newciptr;\n}\n\n#endif /* TCPCONN */\n\n\n#ifdef UNIXCONN\nstatic XtransConnInfo\nTRANS(SocketUNIXAccept) (XtransConnInfo ciptr, int *status)\n\n{\n    XtransConnInfo\tnewciptr;\n    struct sockaddr_un\tsockname;\n    SOCKLEN_T \t\tnamelen = sizeof sockname;\n\n    prmsg (2, \"SocketUNIXAccept(%p,%d)\\n\", ciptr, ciptr->fd);\n\n    if ((newciptr = calloc (1, sizeof(struct _XtransConnInfo))) == NULL)\n    {\n\tprmsg (1, \"SocketUNIXAccept: malloc() failed\\n\");\n\t*status = TRANS_ACCEPT_BAD_MALLOC;\n\treturn NULL;\n    }\n\n    if ((newciptr->fd = accept (ciptr->fd,\n\t(struct sockaddr *) &sockname, (void *)&namelen)) < 0)\n    {\n\tprmsg (1, \"SocketUNIXAccept: accept() failed\\n\");\n\tfree (newciptr);\n\t*status = TRANS_ACCEPT_FAILED;\n\treturn NULL;\n    }\n\n\tciptr->addrlen = namelen;\n    /*\n     * Get the socket name and the peer name from the listener socket,\n     * since this is unix domain.\n     */\n\n    if ((newciptr->addr = malloc (ciptr->addrlen)) == NULL)\n    {\n        prmsg (1,\n        \"SocketUNIXAccept: Can't allocate space for the addr\\n\");\n\tclose (newciptr->fd);\n\tfree (newciptr);\n\t*status = TRANS_ACCEPT_BAD_MALLOC;\n        return NULL;\n    }\n\n    /*\n     * if the socket is abstract, we already modified the address to have a\n     * @ instead of the initial NUL, so no need to do that again here.\n     */\n\n    newciptr->addrlen = ciptr->addrlen;\n    memcpy (newciptr->addr, ciptr->addr, newciptr->addrlen);\n\n    if ((newciptr->peeraddr = malloc (ciptr->addrlen)) == NULL)\n    {\n        prmsg (1,\n\t      \"SocketUNIXAccept: Can't allocate space for the addr\\n\");\n\tclose (newciptr->fd);\n\tif (newciptr->addr) free (newciptr->addr);\n\tfree (newciptr);\n\t*status = TRANS_ACCEPT_BAD_MALLOC;\n        return NULL;\n    }\n\n    newciptr->peeraddrlen = ciptr->addrlen;\n    memcpy (newciptr->peeraddr, ciptr->addr, newciptr->addrlen);\n\n    newciptr->family = AF_UNIX;\n\n    *status = 0;\n\n    return newciptr;\n}\n\n#endif /* UNIXCONN */\n\n#endif /* TRANS_SERVER */\n\n\n#ifdef TRANS_CLIENT\n\n#ifdef TCPCONN\n\n#if defined(IPv6) && defined(AF_INET6)\nstruct addrlist {\n    struct addrinfo *\taddr;\n    struct addrinfo *\tfirstaddr;\n    char \t\tport[PORTBUFSIZE];\n    char \t\thost[MAXHOSTNAMELEN];\n};\nstatic struct addrlist  *addrlist = NULL;\n#endif\n\n\nstatic int\nTRANS(SocketINETConnect) (XtransConnInfo ciptr,\n                          const char *host, const char *port)\n\n{\n    struct sockaddr *\tsocketaddr = NULL;\n    int\t\t\tsocketaddrlen = 0;\n    int\t\t\tres;\n#if defined(IPv6) && defined(AF_INET6)\n    struct addrinfo \thints;\n    char\t\tntopbuf[INET6_ADDRSTRLEN];\n    int\t\t\tresetonce = 0;\n#else\n    struct sockaddr_in\tsockname;\n    struct hostent\t*hostp;\n    struct servent\t*servp;\n    unsigned long \ttmpaddr;\n#endif\n#ifdef XTHREADS_NEEDS_BYNAMEPARAMS\n    _Xgethostbynameparams hparams;\n    _Xgetservbynameparams sparams;\n#endif\n#ifdef X11_t\n    char\tportbuf[PORTBUFSIZE];\n#endif\n\n    char \t\thostnamebuf[256];\t\t/* tmp space */\n\n    prmsg (2,\"SocketINETConnect(%d,%s,%s)\\n\", ciptr->fd, host, port);\n\n    if (!host)\n    {\n\thostnamebuf[0] = '\\0';\n\t(void) TRANS(GetHostname) (hostnamebuf, sizeof hostnamebuf);\n\thost = hostnamebuf;\n    }\n\n#ifdef X11_t\n    /*\n     * X has a well known port, that is transport dependent. It is easier\n     * to handle it here, than try and come up with a transport independent\n     * representation that can be passed in and resolved the usual way.\n     *\n     * The port that is passed here is really a string containing the idisplay\n     * from ConnectDisplay().\n     */\n\n    if (is_numeric (port))\n    {\n\tlong tmpport = X_TCP_PORT + strtol (port, (char**)NULL, 10);\n\tsnprintf (portbuf, sizeof(portbuf), \"%lu\", tmpport);\n\tport = portbuf;\n    }\n#endif\n\n#if defined(IPv6) && defined(AF_INET6)\n    {\n\tif (addrlist != NULL) {\n\t    if (strcmp(host,addrlist->host) || strcmp(port,addrlist->port)) {\n\t\tif (addrlist->firstaddr)\n\t\t    freeaddrinfo(addrlist->firstaddr);\n\t\taddrlist->firstaddr = NULL;\n\t    }\n\t} else {\n\t    addrlist = malloc(sizeof(struct addrlist));\n\t    addrlist->firstaddr = NULL;\n\t}\n\n\tif (addrlist->firstaddr == NULL) {\n\t    strncpy(addrlist->port, port, sizeof(addrlist->port));\n\t    addrlist->port[sizeof(addrlist->port) - 1] = '\\0';\n\t    strncpy(addrlist->host, host, sizeof(addrlist->host));\n\t    addrlist->host[sizeof(addrlist->host) - 1] = '\\0';\n\n\t    bzero(&hints,sizeof(hints));\n\t    hints.ai_socktype = Sockettrans2devtab[ciptr->index].devcotsname;\n\n\t    res = getaddrinfo(host,port,&hints,&addrlist->firstaddr);\n\t    if (res != 0) {\n\t\tprmsg (1, \"SocketINETConnect() can't get address \"\n\t\t\t\"for %s:%s: %s\\n\", host, port, gai_strerror(res));\n\t\tESET(EINVAL);\n\t\treturn TRANS_CONNECT_FAILED;\n\t    }\n\t    for (res = 0, addrlist->addr = addrlist->firstaddr;\n\t\t addrlist->addr ; res++) {\n\t\taddrlist->addr = addrlist->addr->ai_next;\n\t    }\n\t    prmsg(4,\"Got New Address list with %d addresses\\n\", res);\n\t    res = 0;\n\t    addrlist->addr = NULL;\n\t}\n\n\twhile (socketaddr == NULL) {\n\t    if (addrlist->addr == NULL) {\n\t\tif (resetonce) {\n\t\t    /* Already checked entire list - no usable addresses */\n\t\t    prmsg (1, \"SocketINETConnect() no usable address \"\n\t\t\t   \"for %s:%s\\n\", host, port);\n\t\t    return TRANS_CONNECT_FAILED;\n\t\t} else {\n\t\t    /* Go back to beginning of list */\n\t\t    resetonce = 1;\n\t\t    addrlist->addr = addrlist->firstaddr;\n\t\t}\n\t    }\n\n\t    socketaddr = addrlist->addr->ai_addr;\n\t    socketaddrlen = addrlist->addr->ai_addrlen;\n\n\t    if (addrlist->addr->ai_family == AF_INET) {\n\t\tstruct sockaddr_in *sin = (struct sockaddr_in *) socketaddr;\n\n\t\tprmsg (4,\"SocketINETConnect() sockname.sin_addr = %s\\n\",\n\t\t\tinet_ntop(addrlist->addr->ai_family,&sin->sin_addr,\n\t\t\tntopbuf,sizeof(ntopbuf)));\n\n\t\tprmsg (4,\"SocketINETConnect() sockname.sin_port = %d\\n\",\n\t\t\tntohs(sin->sin_port));\n\n\t\tif (Sockettrans2devtab[ciptr->index].family == AF_INET6) {\n\t\t    if (strcmp(Sockettrans2devtab[ciptr->index].transname,\n\t\t\t\t\"tcp\") == 0) {\n\t\t\tXtransConnInfo newciptr;\n\n\t\t\t/*\n\t\t\t * Our socket is an IPv6 socket, but the address is\n\t\t\t * IPv4.  Close it and get an IPv4 socket.  This is\n\t\t\t * needed for IPv4 connections to work on platforms\n\t\t\t * that don't allow IPv4 over IPv6 sockets.\n\t\t\t */\n\t\t\tTRANS(SocketINETClose)(ciptr);\n\t\t\tnewciptr = TRANS(SocketOpenCOTSClientBase)(\n\t\t\t\t\t\"tcp\", \"tcp\", host, port, ciptr->index);\n\t\t\tif (newciptr)\n\t\t\t    ciptr->fd = newciptr->fd;\n\t\t\tif (!newciptr ||\n\t\t\t    Sockettrans2devtab[newciptr->index].family !=\n\t\t\t\tAF_INET) {\n\t\t\t    socketaddr = NULL;\n\t\t\t    prmsg (4,\"SocketINETConnect() Cannot get IPv4 \"\n\t\t\t\t\t\" socketfor IPv4 address\\n\");\n\t\t\t}\n\t\t\tif (newciptr)\n\t\t\t    free(newciptr);\n\t\t    } else {\n\t\t\tsocketaddr = NULL;\n\t\t\tprmsg (4,\"SocketINETConnect Skipping IPv4 address\\n\");\n\t\t    }\n\t\t}\n\t    } else if (addrlist->addr->ai_family == AF_INET6) {\n\t\tstruct sockaddr_in6 *sin6 = (struct sockaddr_in6 *) socketaddr;\n\n\t\tprmsg (4,\"SocketINETConnect() sockname.sin6_addr = %s\\n\",\n\t\t\tinet_ntop(addrlist->addr->ai_family,\n\t\t\t\t  &sin6->sin6_addr,ntopbuf,sizeof(ntopbuf)));\n\t\tprmsg (4,\"SocketINETConnect() sockname.sin6_port = %d\\n\",\n\t\t\tntohs(sin6->sin6_port));\n\n\t\tif (Sockettrans2devtab[ciptr->index].family == AF_INET) {\n\t\t    if (strcmp(Sockettrans2devtab[ciptr->index].transname,\n\t\t\t\t\"tcp\") == 0) {\n\t\t\tXtransConnInfo newciptr;\n\n\t\t\t/*\n\t\t\t * Close the IPv4 socket and try to open an IPv6 socket.\n\t\t\t */\n\t\t\tTRANS(SocketINETClose)(ciptr);\n\t\t\tnewciptr = TRANS(SocketOpenCOTSClientBase)(\n\t\t\t\t\t\"tcp\", \"tcp\", host, port, -1);\n\t\t\tif (newciptr)\n\t\t\t    ciptr->fd = newciptr->fd;\n\t\t\tif (!newciptr ||\n\t\t\t    Sockettrans2devtab[newciptr->index].family !=\n\t\t\t\t\tAF_INET6) {\n\t\t\t    socketaddr = NULL;\n\t\t\t    prmsg (4,\"SocketINETConnect() Cannot get IPv6 \"\n\t\t\t\t   \"socket for IPv6 address\\n\");\n\t\t\t}\n\t\t\tif (newciptr)\n\t\t\t    free(newciptr);\n\t\t    }\n\t\t    else\n\t\t    {\n\t\t\tsocketaddr = NULL;\n\t\t\tprmsg (4,\"SocketINETConnect() Skipping IPv6 address\\n\");\n\t\t    }\n\t\t}\n\t    } else {\n\t\tsocketaddr = NULL; /* Unsupported address type */\n\t    }\n\t    if (socketaddr == NULL) {\n\t\taddrlist->addr = addrlist->addr->ai_next;\n\t    }\n\t}\n    }\n#else\n    {\n\t/*\n\t * Build the socket name.\n\t */\n\n#ifdef BSD44SOCKETS\n\tsockname.sin_len = sizeof (struct sockaddr_in);\n#endif\n\tsockname.sin_family = AF_INET;\n\n\t/*\n\t * fill in sin_addr\n\t */\n\n#ifndef INADDR_NONE\n#define INADDR_NONE ((in_addr_t) 0xffffffff)\n#endif\n\n\t/* check for ww.xx.yy.zz host string */\n\n\tif (isascii (host[0]) && isdigit (host[0])) {\n\t    tmpaddr = inet_addr (host); /* returns network byte order */\n\t} else {\n\t    tmpaddr = INADDR_NONE;\n\t}\n\n\tprmsg (4,\"SocketINETConnect() inet_addr(%s) = %x\\n\", host, tmpaddr);\n\n\tif (tmpaddr == INADDR_NONE) {\n\t    if ((hostp = _XGethostbyname(host,hparams)) == NULL) {\n\t\tprmsg (1,\"SocketINETConnect: Can't get address for %s\\n\",\n\t\t\thost);\n\t\tESET(EINVAL);\n\t\treturn TRANS_CONNECT_FAILED;\n\t    }\n\t    if (hostp->h_addrtype != AF_INET) {  /* is IP host? */\n\t\tprmsg (1,\"SocketINETConnect: not INET host%s\\n\", host);\n\t\tESET(EPROTOTYPE);\n\t\treturn TRANS_CONNECT_FAILED;\n\t    }\n\n\t    memcpy ((char *) &sockname.sin_addr, (char *) hostp->h_addr,\n\t\t    sizeof (sockname.sin_addr));\n\n\t} else {\n\t    sockname.sin_addr.s_addr = tmpaddr;\n        }\n\n\t/*\n\t * fill in sin_port\n\t */\n\n\t/* Check for number in the port string */\n\n\tif (!is_numeric (port)) {\n\t    if ((servp = _XGetservbyname (port,\"tcp\",sparams)) == NULL) {\n\t\tprmsg (1,\"SocketINETConnect: can't get service for %s\\n\",\n\t\t\tport);\n\t\treturn TRANS_CONNECT_FAILED;\n\t    }\n\t    sockname.sin_port = htons (servp->s_port);\n\t} else {\n\t    long tmpport = strtol (port, (char**)NULL, 10);\n\t    if (tmpport < 1024 || tmpport > USHRT_MAX)\n\t\treturn TRANS_CONNECT_FAILED;\n\t    sockname.sin_port = htons (((unsigned short) tmpport));\n\t}\n\n\tprmsg (4,\"SocketINETConnect: sockname.sin_port = %d\\n\",\n\t\tntohs(sockname.sin_port));\n\tsocketaddr = (struct sockaddr *) &sockname;\n\tsocketaddrlen = sizeof(sockname);\n    }\n#endif\n\n    /*\n     * Turn on socket keepalive so the client process will eventually\n     * be notified with a SIGPIPE signal if the display server fails\n     * to respond to a periodic transmission of messages\n     * on the connected socket.\n     * This is useful to avoid hung application processes when the\n     * processes are not spawned from the xdm session and\n     * the display server terminates abnormally.\n     * (Someone turned off the power switch.)\n     */\n\n    {\n\tint tmp = 1;\n\tsetsockopt (ciptr->fd, SOL_SOCKET, SO_KEEPALIVE,\n\t\t(char *) &tmp, sizeof (int));\n    }\n\n    /*\n     * Do the connect()\n     */\n\n    if (connect (ciptr->fd, socketaddr, socketaddrlen ) < 0)\n    {\n#ifdef WIN32\n\tint olderrno = WSAGetLastError();\n#else\n\tint olderrno = errno;\n#endif\n\n\t/*\n\t * If the error was ECONNREFUSED, the server may be overloaded\n\t * and we should try again.\n\t *\n\t * If the error was EWOULDBLOCK or EINPROGRESS then the socket\n\t * was non-blocking and we should poll using select\n\t *\n\t * If the error was EINTR, the connect was interrupted and we\n\t * should try again.\n\t *\n\t * If multiple addresses are found for a host then we should\n\t * try to connect again with a different address for a larger\n\t * number of errors that made us quit before, since those\n\t * could be caused by trying to use an IPv6 address to contact\n\t * a machine with an IPv4-only server or other reasons that\n\t * only affect one of a set of addresses.\n\t */\n\n\tif (olderrno == ECONNREFUSED || olderrno == EINTR\n#if defined(IPv6) && defined(AF_INET6)\n\t  || (((addrlist->addr->ai_next != NULL) ||\n\t        (addrlist->addr != addrlist->firstaddr)) &&\n               (olderrno == ENETUNREACH || olderrno == EAFNOSUPPORT ||\n\t\t olderrno == EADDRNOTAVAIL || olderrno == ETIMEDOUT\n#if defined(EHOSTDOWN)\n\t\t   || olderrno == EHOSTDOWN\n#endif\n\t       ))\n#endif\n\t    )\n\t    res = TRANS_TRY_CONNECT_AGAIN;\n\telse if (olderrno == EWOULDBLOCK || olderrno == EINPROGRESS)\n\t    res = TRANS_IN_PROGRESS;\n\telse\n\t{\n\t    prmsg (2,\"SocketINETConnect: Can't connect: errno = %d\\n\",\n\t\t   olderrno);\n\n\t    res = TRANS_CONNECT_FAILED;\n\t}\n    } else {\n\tres = 0;\n\n\n\t/*\n\t * Sync up the address fields of ciptr.\n\t */\n\n\tif (TRANS(SocketINETGetAddr) (ciptr) < 0)\n\t{\n\t    prmsg (1,\n\t     \"SocketINETConnect: ...SocketINETGetAddr() failed:\\n\");\n\t    res = TRANS_CONNECT_FAILED;\n\t}\n\n\telse if (TRANS(SocketINETGetPeerAddr) (ciptr) < 0)\n\t{\n\t    prmsg (1,\n\t      \"SocketINETConnect: ...SocketINETGetPeerAddr() failed:\\n\");\n\t    res = TRANS_CONNECT_FAILED;\n\t}\n    }\n\n#if defined(IPv6) && defined(AF_INET6)\n   if (res != 0) {\n\taddrlist->addr = addrlist->addr->ai_next;\n   }\n#endif\n\n    return res;\n}\n\n#endif /* TCPCONN */\n\n\n\f\n#ifdef UNIXCONN\n\n/*\n * Make sure 'host' is really local.\n */\n\nstatic int\nUnixHostReallyLocal (const char *host)\n\n{\n    char hostnamebuf[256];\n\n    TRANS(GetHostname) (hostnamebuf, sizeof (hostnamebuf));\n\n    if (strcmp (hostnamebuf, host) == 0)\n    {\n\treturn (1);\n    } else {\n#if defined(IPv6) && defined(AF_INET6)\n\tstruct addrinfo *localhostaddr;\n\tstruct addrinfo *otherhostaddr;\n\tstruct addrinfo *i, *j;\n\tint equiv = 0;\n\n\tif (getaddrinfo(hostnamebuf, NULL, NULL, &localhostaddr) != 0)\n\t    return 0;\n\tif (getaddrinfo(host, NULL, NULL, &otherhostaddr) != 0) {\n\t    freeaddrinfo(localhostaddr);\n\t    return 0;\n\t}\n\n\tfor (i = localhostaddr; i != NULL && equiv == 0; i = i->ai_next) {\n\t    for (j = otherhostaddr; j != NULL && equiv == 0; j = j->ai_next) {\n\t\tif (i->ai_family == j->ai_family) {\n\t\t    if (i->ai_family == AF_INET) {\n\t\t\tstruct sockaddr_in *sinA\n\t\t\t  = (struct sockaddr_in *) i->ai_addr;\n\t\t\tstruct sockaddr_in *sinB\n\t\t\t  = (struct sockaddr_in *) j->ai_addr;\n\t\t\tstruct in_addr *A = &sinA->sin_addr;\n\t\t\tstruct in_addr *B = &sinB->sin_addr;\n\n\t\t\tif (memcmp(A,B,sizeof(struct in_addr)) == 0) {\n\t\t\t    equiv = 1;\n\t\t\t}\n\t\t    } else if (i->ai_family == AF_INET6) {\n\t\t\tstruct sockaddr_in6 *sinA\n\t\t\t  = (struct sockaddr_in6 *) i->ai_addr;\n\t\t\tstruct sockaddr_in6 *sinB\n\t\t\t  = (struct sockaddr_in6 *) j->ai_addr;\n\t\t\tstruct in6_addr *A = &sinA->sin6_addr;\n\t\t\tstruct in6_addr *B = &sinB->sin6_addr;\n\n\t\t\tif (memcmp(A,B,sizeof(struct in6_addr)) == 0) {\n\t\t\t    equiv = 1;\n\t\t\t}\n\t\t    }\n\t\t}\n\t    }\n\t}\n\n\tfreeaddrinfo(localhostaddr);\n\tfreeaddrinfo(otherhostaddr);\n\treturn equiv;\n#else\n\t/*\n\t * A host may have more than one network address.  If any of the\n\t * network addresses of 'host' (specified to the connect call)\n\t * match any of the network addresses of 'hostname' (determined\n\t * by TRANS(GetHostname)), then the two hostnames are equivalent,\n\t * and we know that 'host' is really a local host.\n\t */\n\tchar specified_local_addr_list[10][4];\n\tint scount, equiv, i, j;\n#ifdef XTHREADS_NEEDS_BYNAMEPARAMS\n\t_Xgethostbynameparams hparams;\n#endif\n\tstruct hostent *hostp;\n\n\tif ((hostp = _XGethostbyname (host,hparams)) == NULL)\n\t    return (0);\n\n\tscount = 0;\n\twhile (hostp->h_addr_list[scount] && scount <= 8)\n\t{\n\t    /*\n\t     * The 2nd call to gethostname() overrides the data\n\t     * from the 1st call, so we must save the address list.\n\t     */\n\n\t    specified_local_addr_list[scount][0] =\n\t\t\t\thostp->h_addr_list[scount][0];\n\t    specified_local_addr_list[scount][1] =\n\t\t\t\thostp->h_addr_list[scount][1];\n\t    specified_local_addr_list[scount][2] =\n\t\t\t\thostp->h_addr_list[scount][2];\n\t    specified_local_addr_list[scount][3] =\n\t\t\t\thostp->h_addr_list[scount][3];\n\t    scount++;\n\t}\n\tif ((hostp = _XGethostbyname (hostnamebuf,hparams)) == NULL)\n\t    return (0);\n\n\tequiv = 0;\n\ti = 0;\n\n\twhile (i < scount && !equiv)\n\t{\n\t    j = 0;\n\n\t    while (hostp->h_addr_list[j])\n\t    {\n\t\tif ((specified_local_addr_list[i][0] ==\n\t\t\t\t\thostp->h_addr_list[j][0]) &&\n\t\t    (specified_local_addr_list[i][1] ==\n\t\t\t\t\thostp->h_addr_list[j][1]) &&\n\t\t    (specified_local_addr_list[i][2] ==\n\t\t\t\t\thostp->h_addr_list[j][2]) &&\n\t\t    (specified_local_addr_list[i][3] ==\n\t\t\t\t\thostp->h_addr_list[j][3]))\n\t\t{\n\t\t    /* They're equal, so we're done */\n\n\t\t    equiv = 1;\n\t\t    break;\n\t\t}\n\n\t\tj++;\n\t    }\n\n\t    i++;\n\t}\n\treturn (equiv);\n#endif\n    }\n}\n\nstatic int\nTRANS(SocketUNIXConnect) (XtransConnInfo ciptr,\n                          const char *host, const char *port)\n\n{\n    struct sockaddr_un\tsockname;\n    SOCKLEN_T\t\tnamelen;\n\n\n    int abstract = 0;\n#ifdef HAVE_ABSTRACT_SOCKETS\n    abstract = ciptr->transptr->flags & TRANS_ABSTRACT;\n#endif\n\n    prmsg (2,\"SocketUNIXConnect(%d,%s,%s)\\n\", ciptr->fd, host, port);\n\n    /*\n     * Make sure 'host' is really local.  If not, we return failure.\n     * The reason we make this check is because a process may advertise\n     * a \"local\" network ID for which it can accept connections, but if\n     * a process on a remote machine tries to connect to this network ID,\n     * we know for sure it will fail.\n     */\n\n    if (host && *host && host[0]!='/' && strcmp (host, \"unix\") != 0 && !UnixHostReallyLocal (host))\n    {\n\tprmsg (1,\n\t   \"SocketUNIXConnect: Cannot connect to non-local host %s\\n\",\n\t       host);\n\treturn TRANS_CONNECT_FAILED;\n    }\n\n\n    /*\n     * Check the port.\n     */\n\n    if (!port || !*port)\n    {\n\tprmsg (1,\"SocketUNIXConnect: Missing port specification\\n\");\n\treturn TRANS_CONNECT_FAILED;\n    }\n\n    /*\n     * Build the socket name.\n     */\n\n    sockname.sun_family = AF_UNIX;\n\n    if (set_sun_path(port, UNIX_PATH, sockname.sun_path, abstract) != 0) {\n\tprmsg (1, \"SocketUNIXConnect: path too long\\n\");\n\treturn TRANS_CONNECT_FAILED;\n    }\n\n#if (defined(BSD44SOCKETS) || defined(__UNIXWARE__))\n    sockname.sun_len = strlen (sockname.sun_path);\n#endif\n\n#if defined(BSD44SOCKETS) || defined(SUN_LEN)\n    namelen = SUN_LEN (&sockname);\n#else\n    namelen = strlen (sockname.sun_path) + offsetof(struct sockaddr_un, sun_path);\n#endif\n\n\n\n    /*\n     * Adjust the socket path if using abstract sockets.\n     * Done here because otherwise all the strlen() calls above would fail.\n     */\n\n    if (abstract) {\n\tsockname.sun_path[0] = '\\0';\n    }\n\n    /*\n     * Do the connect()\n     */\n\n    if (connect (ciptr->fd, (struct sockaddr *) &sockname, namelen) < 0)\n    {\n\tint olderrno = errno;\n\tint connected = 0;\n\n\tif (!connected)\n\t{\n\t    errno = olderrno;\n\n\t    /*\n\t     * If the error was ENOENT, the server may be starting up; we used\n\t     * to suggest to try again in this case with\n\t     * TRANS_TRY_CONNECT_AGAIN, but this introduced problems for\n\t     * processes still referencing stale sockets in their environment.\n\t     * Hence, we now return a hard error, TRANS_CONNECT_FAILED, and it\n\t     * is suggested that higher level stacks handle retries on their\n\t     * level when they face a slow starting server.\n\t     *\n\t     * If the error was EWOULDBLOCK or EINPROGRESS then the socket\n\t     * was non-blocking and we should poll using select\n\t     *\n\t     * If the error was EINTR, the connect was interrupted and we\n\t     * should try again.\n\t     */\n\n\t    if (olderrno == EWOULDBLOCK || olderrno == EINPROGRESS)\n\t\treturn TRANS_IN_PROGRESS;\n\t    else if (olderrno == EINTR)\n\t\treturn TRANS_TRY_CONNECT_AGAIN;\n\t    else if (olderrno == ENOENT || olderrno == ECONNREFUSED) {\n\t\t/* If opening as abstract socket failed, try again normally */\n\t\tif (abstract) {\n\t\t    ciptr->transptr->flags &= ~(TRANS_ABSTRACT);\n\t\t    return TRANS_TRY_CONNECT_AGAIN;\n\t\t} else {\n\t\t    return TRANS_CONNECT_FAILED;\n\t\t}\n\t    } else {\n\t\tprmsg (2,\"SocketUNIXConnect: Can't connect: errno = %d\\n\",\n\t\t       EGET());\n\n\t\treturn TRANS_CONNECT_FAILED;\n\t    }\n\t}\n    }\n\n    /*\n     * Get the socket name and the peer name from the connect socket,\n     * since this is unix domain.\n     */\n\n    if ((ciptr->addr = malloc(namelen)) == NULL ||\n       (ciptr->peeraddr = malloc(namelen)) == NULL)\n    {\n        prmsg (1,\n\t\"SocketUNIXCreateListener: Can't allocate space for the addr\\n\");\n        return TRANS_CONNECT_FAILED;\n    }\n\n    if (abstract)\n\tsockname.sun_path[0] = '@';\n\n    ciptr->family = AF_UNIX;\n    ciptr->addrlen = namelen;\n    ciptr->peeraddrlen = namelen;\n    memcpy (ciptr->addr, &sockname, ciptr->addrlen);\n    memcpy (ciptr->peeraddr, &sockname, ciptr->peeraddrlen);\n\n    return 0;\n}\n\n#endif /* UNIXCONN */\n\n#endif /* TRANS_CLIENT */\n\n\nstatic int\nTRANS(SocketBytesReadable) (XtransConnInfo ciptr, BytesReadable_t *pend)\n\n{\n    prmsg (2,\"SocketBytesReadable(%p,%d,%p)\\n\",\n\tciptr, ciptr->fd, pend);\n#ifdef WIN32\n    {\n\tint ret = ioctlsocket ((SOCKET) ciptr->fd, FIONREAD, (u_long *) pend);\n\tif (ret == SOCKET_ERROR) errno = WSAGetLastError();\n\treturn ret;\n    }\n#else\n#if defined(__i386__) && defined(SYSV) && !defined(SCO325)\n    return ioctl (ciptr->fd, I_NREAD, (char *) pend);\n#else\n    return ioctl (ciptr->fd, FIONREAD, (char *) pend);\n#endif /* __i386__ && SYSV || _SEQUENT_ && _SOCKET_VERSION == 1 */\n#endif /* WIN32 */\n}\n\n#if XTRANS_SEND_FDS\n\nstatic void\nappendFd(struct _XtransConnFd **prev, int fd, int do_close)\n{\n    struct _XtransConnFd *cf, *new;\n\n    new = malloc (sizeof (struct _XtransConnFd));\n    if (!new) {\n        /* XXX mark connection as broken */\n        close(fd);\n        return;\n    }\n    new->next = 0;\n    new->fd = fd;\n    new->do_close = do_close;\n    /* search to end of list */\n    for (; (cf = *prev); prev = &(cf->next));\n    *prev = new;\n}\n\nstatic int\nremoveFd(struct _XtransConnFd **prev)\n{\n    struct _XtransConnFd *cf;\n    int fd;\n\n    if ((cf = *prev)) {\n        *prev = cf->next;\n        fd = cf->fd;\n        free(cf);\n    } else\n        fd = -1;\n    return fd;\n}\n\nstatic void\ndiscardFd(struct _XtransConnFd **prev, struct _XtransConnFd *upto, int do_close)\n{\n    struct _XtransConnFd *cf, *next;\n\n    for (cf = *prev; cf != upto; cf = next) {\n        next = cf->next;\n        if (do_close || cf->do_close)\n            close(cf->fd);\n        free(cf);\n    }\n    *prev = upto;\n}\n\nstatic void\ncleanupFds(XtransConnInfo ciptr)\n{\n    /* Clean up the send list but don't close the fds */\n    discardFd(&ciptr->send_fds, NULL, 0);\n    /* Clean up the recv list and *do* close the fds */\n    discardFd(&ciptr->recv_fds, NULL, 1);\n}\n\nstatic int\nnFd(struct _XtransConnFd **prev)\n{\n    struct _XtransConnFd *cf;\n    int n = 0;\n\n    for (cf = *prev; cf; cf = cf->next)\n        n++;\n    return n;\n}\n\nstatic int\nTRANS(SocketRecvFd) (XtransConnInfo ciptr)\n{\n    prmsg (2, \"SocketRecvFd(%d)\\n\", ciptr->fd);\n    return removeFd(&ciptr->recv_fds);\n}\n\nstatic int\nTRANS(SocketSendFd) (XtransConnInfo ciptr, int fd, int do_close)\n{\n    appendFd(&ciptr->send_fds, fd, do_close);\n    return 0;\n}\n\nstatic int\nTRANS(SocketRecvFdInvalid)(XtransConnInfo ciptr)\n{\n    errno = EINVAL;\n    return -1;\n}\n\nstatic int\nTRANS(SocketSendFdInvalid)(XtransConnInfo ciptr, int fd, int do_close)\n{\n    errno = EINVAL;\n    return -1;\n}\n\n#define MAX_FDS\t\t128\n\nunion fd_pass {\n\tstruct cmsghdr\tcmsghdr;\n\tchar\t\tbuf[CMSG_SPACE(MAX_FDS * sizeof(int))];\n};\n\n#endif /* XTRANS_SEND_FDS */\n\nstatic int\nTRANS(SocketRead) (XtransConnInfo ciptr, char *buf, int size)\n\n{\n    prmsg (2,\"SocketRead(%d,%p,%d)\\n\", ciptr->fd, buf, size);\n\n#if defined(WIN32)\n    {\n\tint ret = recv ((SOCKET)ciptr->fd, buf, size, 0);\n#ifdef WIN32\n\tif (ret == SOCKET_ERROR) errno = WSAGetLastError();\n#endif\n\treturn ret;\n    }\n#else\n#if XTRANS_SEND_FDS\n    {\n        struct iovec    iov = {\n            .iov_base = buf,\n            .iov_len = size\n        };\n        union fd_pass   cmsgbuf;\n        struct msghdr   msg = {\n            .msg_name = NULL,\n            .msg_namelen = 0,\n            .msg_iov = &iov,\n            .msg_iovlen = 1,\n            .msg_control = cmsgbuf.buf,\n            .msg_controllen = CMSG_LEN(MAX_FDS * sizeof(int))\n        };\n\n        size = recvmsg(ciptr->fd, &msg, 0);\n        if (size >= 0) {\n            struct cmsghdr *hdr;\n\n            for (hdr = CMSG_FIRSTHDR(&msg); hdr; hdr = CMSG_NXTHDR(&msg, hdr)) {\n                if (hdr->cmsg_level == SOL_SOCKET && hdr->cmsg_type == SCM_RIGHTS) {\n                    int nfd = (hdr->cmsg_len - CMSG_LEN(0)) / sizeof (int);\n                    int i;\n                    int *fd = (int *) CMSG_DATA(hdr);\n\n                    for (i = 0; i < nfd; i++)\n                        appendFd(&ciptr->recv_fds, fd[i], 0);\n                }\n            }\n        }\n        return size;\n    }\n#else\n    return read(ciptr->fd, buf, size);\n#endif /* XTRANS_SEND_FDS */\n#endif /* WIN32 */\n}\n\nstatic int\nTRANS(SocketReadv) (XtransConnInfo ciptr, struct iovec *buf, int size)\n\n{\n    prmsg (2,\"SocketReadv(%d,%p,%d)\\n\", ciptr->fd, buf, size);\n\n#if XTRANS_SEND_FDS\n    {\n        union fd_pass   cmsgbuf;\n        struct msghdr   msg = {\n            .msg_name = NULL,\n            .msg_namelen = 0,\n            .msg_iov = buf,\n            .msg_iovlen = size,\n            .msg_control = cmsgbuf.buf,\n            .msg_controllen = CMSG_LEN(MAX_FDS * sizeof(int))\n        };\n\n        size = recvmsg(ciptr->fd, &msg, 0);\n        if (size >= 0) {\n            struct cmsghdr *hdr;\n\n            for (hdr = CMSG_FIRSTHDR(&msg); hdr; hdr = CMSG_NXTHDR(&msg, hdr)) {\n                if (hdr->cmsg_level == SOL_SOCKET && hdr->cmsg_type == SCM_RIGHTS) {\n                    int nfd = (hdr->cmsg_len - CMSG_LEN(0)) / sizeof (int);\n                    int i;\n                    int *fd = (int *) CMSG_DATA(hdr);\n\n                    for (i = 0; i < nfd; i++)\n                        appendFd(&ciptr->recv_fds, fd[i], 0);\n                }\n            }\n        }\n        return size;\n    }\n#else\n    return READV (ciptr, buf, size);\n#endif\n}\n\n\nstatic int\nTRANS(SocketWritev) (XtransConnInfo ciptr, struct iovec *buf, int size)\n\n{\n    prmsg (2,\"SocketWritev(%d,%p,%d)\\n\", ciptr->fd, buf, size);\n\n#if XTRANS_SEND_FDS\n    if (ciptr->send_fds)\n    {\n        union fd_pass           cmsgbuf;\n        int                     nfd = nFd(&ciptr->send_fds);\n        struct _XtransConnFd    *cf = ciptr->send_fds;\n        struct msghdr           msg = {\n            .msg_name = NULL,\n            .msg_namelen = 0,\n            .msg_iov = buf,\n            .msg_iovlen = size,\n            .msg_control = cmsgbuf.buf,\n            .msg_controllen = CMSG_LEN(nfd * sizeof(int))\n        };\n        struct cmsghdr          *hdr = CMSG_FIRSTHDR(&msg);\n        int                     i;\n        int                     *fds;\n\n        hdr->cmsg_len = msg.msg_controllen;\n        hdr->cmsg_level = SOL_SOCKET;\n        hdr->cmsg_type = SCM_RIGHTS;\n\n        fds = (int *) CMSG_DATA(hdr);\n        /* Set up fds */\n        for (i = 0; i < nfd; i++) {\n            fds[i] = cf->fd;\n            cf = cf->next;\n        }\n\n        i = sendmsg(ciptr->fd, &msg, 0);\n        if (i > 0)\n            discardFd(&ciptr->send_fds, cf, 0);\n        return i;\n    }\n#endif\n    return WRITEV (ciptr, buf, size);\n}\n\n\nstatic int\nTRANS(SocketWrite) (XtransConnInfo ciptr, char *buf, int size)\n\n{\n    prmsg (2,\"SocketWrite(%d,%p,%d)\\n\", ciptr->fd, buf, size);\n\n#if defined(WIN32)\n    {\n\tint ret = send ((SOCKET)ciptr->fd, buf, size, 0);\n#ifdef WIN32\n\tif (ret == SOCKET_ERROR) errno = WSAGetLastError();\n#endif\n\treturn ret;\n    }\n#else\n#if XTRANS_SEND_FDS\n    if (ciptr->send_fds)\n    {\n        struct iovec            iov;\n\n        iov.iov_base = buf;\n        iov.iov_len = size;\n        return TRANS(SocketWritev)(ciptr, &iov, 1);\n    }\n#endif /* XTRANS_SEND_FDS */\n    return write (ciptr->fd, buf, size);\n#endif /* WIN32 */\n}\n\nstatic int\nTRANS(SocketDisconnect) (XtransConnInfo ciptr)\n\n{\n    prmsg (2,\"SocketDisconnect(%p,%d)\\n\", ciptr, ciptr->fd);\n\n#ifdef WIN32\n    {\n\tint ret = shutdown (ciptr->fd, 2);\n\tif (ret == SOCKET_ERROR) errno = WSAGetLastError();\n\treturn ret;\n    }\n#else\n    return shutdown (ciptr->fd, 2); /* disallow further sends and receives */\n#endif\n}\n\n\n#ifdef TCPCONN\nstatic int\nTRANS(SocketINETClose) (XtransConnInfo ciptr)\n\n{\n    prmsg (2,\"SocketINETClose(%p,%d)\\n\", ciptr, ciptr->fd);\n\n#ifdef WIN32\n    {\n\tint ret = close (ciptr->fd);\n\tif (ret == SOCKET_ERROR) errno = WSAGetLastError();\n\treturn ret;\n    }\n#else\n    return close (ciptr->fd);\n#endif\n}\n\n#endif /* TCPCONN */\n\n\n#ifdef UNIXCONN\nstatic int\nTRANS(SocketUNIXClose) (XtransConnInfo ciptr)\n{\n    /*\n     * If this is the server side, then once the socket is closed,\n     * it must be unlinked to completely close it\n     */\n\n    struct sockaddr_un\t*sockname = (struct sockaddr_un *) ciptr->addr;\n    int ret;\n\n    prmsg (2,\"SocketUNIXClose(%p,%d)\\n\", ciptr, ciptr->fd);\n\n#if XTRANS_SEND_FDS\n    cleanupFds(ciptr);\n#endif\n    ret = close(ciptr->fd);\n\n    if (ciptr->flags\n       && sockname\n       && sockname->sun_family == AF_UNIX\n       && sockname->sun_path[0])\n    {\n\tif (!(ciptr->flags & TRANS_NOUNLINK\n\t    || ciptr->transptr->flags & TRANS_ABSTRACT))\n\t\tunlink (sockname->sun_path);\n    }\n\n    return ret;\n}\n\nstatic int\nTRANS(SocketUNIXCloseForCloning) (XtransConnInfo ciptr)\n\n{\n    /*\n     * Don't unlink path.\n     */\n\n    int ret;\n\n    prmsg (2,\"SocketUNIXCloseForCloning(%p,%d)\\n\",\n\tciptr, ciptr->fd);\n\n#if XTRANS_SEND_FDS\n    cleanupFds(ciptr);\n#endif\n    ret = close(ciptr->fd);\n\n    return ret;\n}\n\n#endif /* UNIXCONN */\n\n\n#ifdef TCPCONN\n# ifdef TRANS_SERVER\nstatic const char* tcp_nolisten[] = {\n\t\"inet\",\n#if defined(IPv6) && defined(AF_INET6)\n\t\"inet6\",\n#endif\n\tNULL\n};\n# endif\n\nXtransport\tTRANS(SocketTCPFuncs) = {\n\t/* Socket Interface */\n\t\"tcp\",\n        TRANS_ALIAS,\n#ifdef TRANS_CLIENT\n\tTRANS(SocketOpenCOTSClient),\n#endif /* TRANS_CLIENT */\n#ifdef TRANS_SERVER\n\ttcp_nolisten,\n\tTRANS(SocketOpenCOTSServer),\n#endif /* TRANS_SERVER */\n#ifdef TRANS_CLIENT\n\tTRANS(SocketOpenCLTSClient),\n#endif /* TRANS_CLIENT */\n#ifdef TRANS_SERVER\n\tTRANS(SocketOpenCLTSServer),\n#endif /* TRANS_SERVER */\n#ifdef TRANS_REOPEN\n\tTRANS(SocketReopenCOTSServer),\n\tTRANS(SocketReopenCLTSServer),\n#endif\n\tTRANS(SocketSetOption),\n#ifdef TRANS_SERVER\n\tTRANS(SocketINETCreateListener),\n\tNULL,\t\t       \t\t\t/* ResetListener */\n\tTRANS(SocketINETAccept),\n#endif /* TRANS_SERVER */\n#ifdef TRANS_CLIENT\n\tTRANS(SocketINETConnect),\n#endif /* TRANS_CLIENT */\n\tTRANS(SocketBytesReadable),\n\tTRANS(SocketRead),\n\tTRANS(SocketWrite),\n\tTRANS(SocketReadv),\n\tTRANS(SocketWritev),\n#if XTRANS_SEND_FDS\n        TRANS(SocketSendFdInvalid),\n        TRANS(SocketRecvFdInvalid),\n#endif\n\tTRANS(SocketDisconnect),\n\tTRANS(SocketINETClose),\n\tTRANS(SocketINETClose),\n\t};\n\nXtransport\tTRANS(SocketINETFuncs) = {\n\t/* Socket Interface */\n\t\"inet\",\n\t0,\n#ifdef TRANS_CLIENT\n\tTRANS(SocketOpenCOTSClient),\n#endif /* TRANS_CLIENT */\n#ifdef TRANS_SERVER\n\tNULL,\n\tTRANS(SocketOpenCOTSServer),\n#endif /* TRANS_SERVER */\n#ifdef TRANS_CLIENT\n\tTRANS(SocketOpenCLTSClient),\n#endif /* TRANS_CLIENT */\n#ifdef TRANS_SERVER\n\tTRANS(SocketOpenCLTSServer),\n#endif /* TRANS_SERVER */\n#ifdef TRANS_REOPEN\n\tTRANS(SocketReopenCOTSServer),\n\tTRANS(SocketReopenCLTSServer),\n#endif\n\tTRANS(SocketSetOption),\n#ifdef TRANS_SERVER\n\tTRANS(SocketINETCreateListener),\n\tNULL,\t\t       \t\t\t/* ResetListener */\n\tTRANS(SocketINETAccept),\n#endif /* TRANS_SERVER */\n#ifdef TRANS_CLIENT\n\tTRANS(SocketINETConnect),\n#endif /* TRANS_CLIENT */\n\tTRANS(SocketBytesReadable),\n\tTRANS(SocketRead),\n\tTRANS(SocketWrite),\n\tTRANS(SocketReadv),\n\tTRANS(SocketWritev),\n#if XTRANS_SEND_FDS\n        TRANS(SocketSendFdInvalid),\n        TRANS(SocketRecvFdInvalid),\n#endif\n\tTRANS(SocketDisconnect),\n\tTRANS(SocketINETClose),\n\tTRANS(SocketINETClose),\n\t};\n\n#if defined(IPv6) && defined(AF_INET6)\nXtransport     TRANS(SocketINET6Funcs) = {\n\t/* Socket Interface */\n\t\"inet6\",\n\t0,\n#ifdef TRANS_CLIENT\n\tTRANS(SocketOpenCOTSClient),\n#endif /* TRANS_CLIENT */\n#ifdef TRANS_SERVER\n\tNULL,\n\tTRANS(SocketOpenCOTSServer),\n#endif /* TRANS_SERVER */\n#ifdef TRANS_CLIENT\n\tTRANS(SocketOpenCLTSClient),\n#endif /* TRANS_CLIENT */\n#ifdef TRANS_SERVER\n\tTRANS(SocketOpenCLTSServer),\n#endif /* TRANS_SERVER */\n#ifdef TRANS_REOPEN\n\tTRANS(SocketReopenCOTSServer),\n\tTRANS(SocketReopenCLTSServer),\n#endif\n\tTRANS(SocketSetOption),\n#ifdef TRANS_SERVER\n\tTRANS(SocketINETCreateListener),\n\tNULL,\t\t\t\t\t/* ResetListener */\n\tTRANS(SocketINETAccept),\n#endif /* TRANS_SERVER */\n#ifdef TRANS_CLIENT\n\tTRANS(SocketINETConnect),\n#endif /* TRANS_CLIENT */\n\tTRANS(SocketBytesReadable),\n\tTRANS(SocketRead),\n\tTRANS(SocketWrite),\n\tTRANS(SocketReadv),\n\tTRANS(SocketWritev),\n#if XTRANS_SEND_FDS\n        TRANS(SocketSendFdInvalid),\n        TRANS(SocketRecvFdInvalid),\n#endif\n\tTRANS(SocketDisconnect),\n\tTRANS(SocketINETClose),\n\tTRANS(SocketINETClose),\n\t};\n#endif /* IPv6 */\n#endif /* TCPCONN */\n\n#ifdef UNIXCONN\n#if !defined(LOCALCONN)\nXtransport\tTRANS(SocketLocalFuncs) = {\n\t/* Socket Interface */\n\t\"local\",\n#ifdef HAVE_ABSTRACT_SOCKETS\n\tTRANS_ABSTRACT,\n#else\n\t0,\n#endif\n#ifdef TRANS_CLIENT\n\tTRANS(SocketOpenCOTSClient),\n#endif /* TRANS_CLIENT */\n#ifdef TRANS_SERVER\n\tNULL,\n\tTRANS(SocketOpenCOTSServer),\n#endif /* TRANS_SERVER */\n#ifdef TRANS_CLIENT\n\tTRANS(SocketOpenCLTSClient),\n#endif /* TRANS_CLIENT */\n#ifdef TRANS_SERVER\n\tTRANS(SocketOpenCLTSServer),\n#endif /* TRANS_SERVER */\n#ifdef TRANS_REOPEN\n\tTRANS(SocketReopenCOTSServer),\n\tTRANS(SocketReopenCLTSServer),\n#endif\n\tTRANS(SocketSetOption),\n#ifdef TRANS_SERVER\n\tTRANS(SocketUNIXCreateListener),\n\tTRANS(SocketUNIXResetListener),\n\tTRANS(SocketUNIXAccept),\n#endif /* TRANS_SERVER */\n#ifdef TRANS_CLIENT\n\tTRANS(SocketUNIXConnect),\n#endif /* TRANS_CLIENT */\n\tTRANS(SocketBytesReadable),\n\tTRANS(SocketRead),\n\tTRANS(SocketWrite),\n\tTRANS(SocketReadv),\n\tTRANS(SocketWritev),\n#if XTRANS_SEND_FDS\n        TRANS(SocketSendFd),\n        TRANS(SocketRecvFd),\n#endif\n\tTRANS(SocketDisconnect),\n\tTRANS(SocketUNIXClose),\n\tTRANS(SocketUNIXCloseForCloning),\n\t};\n#endif /* !LOCALCONN */\n# ifdef TRANS_SERVER\n#  if !defined(LOCALCONN)\nstatic const char* unix_nolisten[] = { \"local\" , NULL };\n#  endif\n# endif\n\nXtransport\tTRANS(SocketUNIXFuncs) = {\n\t/* Socket Interface */\n\t\"unix\",\n#if !defined(LOCALCONN) && !defined(HAVE_ABSTRACT_SOCKETS)\n        TRANS_ALIAS,\n#else\n\t0,\n#endif\n#ifdef TRANS_CLIENT\n\tTRANS(SocketOpenCOTSClient),\n#endif /* TRANS_CLIENT */\n#ifdef TRANS_SERVER\n#if !defined(LOCALCONN)\n\tunix_nolisten,\n#else\n\tNULL,\n#endif\n\tTRANS(SocketOpenCOTSServer),\n#endif /* TRANS_SERVER */\n#ifdef TRANS_CLIENT\n\tTRANS(SocketOpenCLTSClient),\n#endif /* TRANS_CLIENT */\n#ifdef TRANS_SERVER\n\tTRANS(SocketOpenCLTSServer),\n#endif /* TRANS_SERVER */\n#ifdef TRANS_REOPEN\n\tTRANS(SocketReopenCOTSServer),\n\tTRANS(SocketReopenCLTSServer),\n#endif\n\tTRANS(SocketSetOption),\n#ifdef TRANS_SERVER\n\tTRANS(SocketUNIXCreateListener),\n\tTRANS(SocketUNIXResetListener),\n\tTRANS(SocketUNIXAccept),\n#endif /* TRANS_SERVER */\n#ifdef TRANS_CLIENT\n\tTRANS(SocketUNIXConnect),\n#endif /* TRANS_CLIENT */\n\tTRANS(SocketBytesReadable),\n\tTRANS(SocketRead),\n\tTRANS(SocketWrite),\n\tTRANS(SocketReadv),\n\tTRANS(SocketWritev),\n#if XTRANS_SEND_FDS\n        TRANS(SocketSendFd),\n        TRANS(SocketRecvFd),\n#endif\n\tTRANS(SocketDisconnect),\n\tTRANS(SocketUNIXClose),\n\tTRANS(SocketUNIXCloseForCloning),\n\t};\n\n#endif /* UNIXCONN */\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/X11/Xtrans/Xtransutil.c",
    "content": "/*\n\nCopyright 1993, 1994, 1998  The Open Group\n\nPermission to use, copy, modify, distribute, and sell this software and its\ndocumentation for any purpose is hereby granted without fee, provided that\nthe above copyright notice appear in all copies and that both that\ncopyright notice and this permission notice appear in supporting\ndocumentation.\n\nThe above copyright notice and this permission notice shall be included\nin all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\nOR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR\nOTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,\nARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\nOTHER DEALINGS IN THE SOFTWARE.\n\nExcept as contained in this notice, the name of The Open Group shall\nnot be used in advertising or otherwise to promote the sale, use or\nother dealings in this Software without prior written authorization\nfrom The Open Group.\n\n * Copyright 1993, 1994 NCR Corporation - Dayton, Ohio, USA\n *\n * All Rights Reserved\n *\n * Permission to use, copy, modify, and distribute this software and its\n * documentation for any purpose and without fee is hereby granted, provided\n * that the above copyright notice appear in all copies and that both that\n * copyright notice and this permission notice appear in supporting\n * documentation, and that the name NCR not be used in advertising\n * or publicity pertaining to distribution of the software without specific,\n * written prior permission.  NCR makes no representations about the\n * suitability of this software for any purpose.  It is provided \"as is\"\n * without express or implied warranty.\n *\n * NCRS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,\n * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN\n * NO EVENT SHALL NCR BE LIABLE FOR ANY SPECIAL, INDIRECT OR\n * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS\n * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,\n * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN\n * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n */\n\n/*\n * These are some utility functions created for convenience or to provide\n * an interface that is similar to an existing interface. These are built\n * only using the Transport Independant API, and have no knowledge of\n * the internal implementation.\n */\n\n#ifdef XTHREADS\n#include <X11/Xthreads.h>\n#endif\n#ifdef WIN32\n#include <X11/Xlibint.h>\n#include <X11/Xwinsock.h>\n#endif\n\n#ifdef X11_t\n\n/*\n * These values come from X.h and Xauth.h, and MUST match them. Some\n * of these values are also defined by the ChangeHost protocol message.\n */\n\n#define FamilyInternet\t\t0\t/* IPv4 */\n#define FamilyDECnet\t\t1\n#define FamilyChaos\t\t2\n#define FamilyInternet6\t\t6\n#define FamilyAmoeba\t\t33\n#define FamilyLocalHost\t\t252\n#define FamilyKrb5Principal\t253\n#define FamilyNetname\t\t254\n#define FamilyLocal\t\t256\n#define FamilyWild\t\t65535\n\n/*\n * TRANS(ConvertAddress) converts a sockaddr based address to an\n * X authorization based address. Some of this is defined as part of\n * the ChangeHost protocol. The rest is just done in a consistent manner.\n */\n\nint\nTRANS(ConvertAddress)(int *familyp, int *addrlenp, Xtransaddr **addrp)\n\n{\n\n    prmsg(2,\"ConvertAddress(%d,%d,%p)\\n\",*familyp,*addrlenp,*addrp);\n\n    switch( *familyp )\n    {\n#if defined(TCPCONN)\n    case AF_INET:\n    {\n\t/*\n\t * Check for the BSD hack localhost address 127.0.0.1.\n\t * In this case, we are really FamilyLocal.\n\t */\n\n\tstruct sockaddr_in saddr;\n\tint len = sizeof(saddr.sin_addr.s_addr);\n\tchar *cp = (char *) &saddr.sin_addr.s_addr;\n\n\tmemcpy (&saddr, *addrp, sizeof (struct sockaddr_in));\n\n\tif ((len == 4) && (cp[0] == 127) && (cp[1] == 0) &&\n\t    (cp[2] == 0) && (cp[3] == 1))\n\t{\n\t    *familyp=FamilyLocal;\n\t}\n\telse\n\t{\n\t    *familyp=FamilyInternet;\n\t    *addrlenp=len;\n\t    memcpy(*addrp,&saddr.sin_addr,len);\n\t}\n\tbreak;\n    }\n\n#if defined(IPv6) && defined(AF_INET6)\n    case AF_INET6:\n    {\n\tstruct sockaddr_in6 saddr6;\n\n\tmemcpy (&saddr6, *addrp, sizeof (struct sockaddr_in6));\n\n\tif (IN6_IS_ADDR_LOOPBACK(&saddr6.sin6_addr))\n\t{\n\t    *familyp=FamilyLocal;\n\t}\n\telse if (IN6_IS_ADDR_V4MAPPED(&(saddr6.sin6_addr))) {\n\t    char *cp = (char *) &saddr6.sin6_addr.s6_addr[12];\n\n\t    if ((cp[0] == 127) && (cp[1] == 0) &&\n\t      (cp[2] == 0) && (cp[3] == 1))\n\t    {\n\t\t*familyp=FamilyLocal;\n\t    }\n\t    else\n\t    {\n\t\t*familyp=FamilyInternet;\n\t\t*addrlenp = sizeof (struct in_addr);\n\t\tmemcpy(*addrp,cp,*addrlenp);\n\t    }\n\t}\n\telse\n\t{\n\t    *familyp=FamilyInternet6;\n\t    *addrlenp=sizeof(saddr6.sin6_addr);\n\t    memcpy(*addrp,&saddr6.sin6_addr,sizeof(saddr6.sin6_addr));\n\t}\n\tbreak;\n    }\n#endif /* IPv6 */\n#endif /* defined(TCPCONN) */\n\n\n#if defined(UNIXCONN) || defined(LOCALCONN)\n    case AF_UNIX:\n    {\n\t*familyp=FamilyLocal;\n\tbreak;\n    }\n#endif /* defined(UNIXCONN) || defined(LOCALCONN) */\n\n#if (defined(__SCO__) || defined(__UNIXWARE__)) && defined(LOCALCONN)\n    case 0:\n    {\n\t*familyp=FamilyLocal;\n\tbreak;\n    }\n#endif\n\n    default:\n\tprmsg(1,\"ConvertAddress: Unknown family type %d\\n\",\n\t      *familyp);\n\treturn -1;\n    }\n\n\n    if (*familyp == FamilyLocal)\n    {\n\t/*\n\t * In the case of a local connection, we need to get the\n\t * host name for authentication.\n\t */\n\n\tchar hostnamebuf[256];\n\tint len = TRANS(GetHostname) (hostnamebuf, sizeof hostnamebuf);\n\n\tif (len > 0) {\n\t    if (*addrp && *addrlenp < (len + 1))\n\t    {\n\t\tfree (*addrp);\n\t\t*addrp = NULL;\n\t    }\n\t    if (!*addrp)\n\t\t*addrp = malloc (len + 1);\n\t    if (*addrp) {\n\t\tstrcpy ((char *) *addrp, hostnamebuf);\n\t\t*addrlenp = len;\n\t    } else {\n\t\t*addrlenp = 0;\n\t    }\n\t}\n\telse\n\t{\n\t    if (*addrp)\n\t\tfree (*addrp);\n\t    *addrp = NULL;\n\t    *addrlenp = 0;\n\t}\n    }\n\n    return 0;\n}\n\n#endif /* X11_t */\n\n#ifdef ICE_t\n\n/* Needed for _XGethostbyaddr usage in TRANS(GetPeerNetworkId) */\n# if defined(TCPCONN) || defined(UNIXCONN)\n#  define X_INCLUDE_NETDB_H\n#  define XOS_USE_NO_LOCKING\n#  include <X11/Xos_r.h>\n# endif\n\n#include <signal.h>\n\nchar *\nTRANS(GetMyNetworkId) (XtransConnInfo ciptr)\n\n{\n    int\t\tfamily = ciptr->family;\n    char \t*addr = ciptr->addr;\n    char\thostnamebuf[256];\n    char \t*networkId = NULL;\n    const char\t*transName = ciptr->transptr->TransName;\n\n    if (gethostname (hostnamebuf, sizeof (hostnamebuf)) < 0)\n    {\n\treturn (NULL);\n    }\n\n    switch (family)\n    {\n#if defined(UNIXCONN) || defined(LOCALCONN)\n    case AF_UNIX:\n    {\n\tstruct sockaddr_un *saddr = (struct sockaddr_un *) addr;\n\tnetworkId = malloc (3 + strlen (transName) +\n\t    strlen (hostnamebuf) + strlen (saddr->sun_path));\n\tsprintf (networkId, \"%s/%s:%s\", transName,\n\t    hostnamebuf, saddr->sun_path);\n\tbreak;\n    }\n#endif /* defined(UNIXCONN) || defined(LOCALCONN) */\n\n#if defined(TCPCONN)\n    case AF_INET:\n#if defined(IPv6) && defined(AF_INET6)\n    case AF_INET6:\n#endif\n    {\n\tstruct sockaddr_in *saddr = (struct sockaddr_in *) addr;\n#if defined(IPv6) && defined(AF_INET6)\n\tstruct sockaddr_in6 *saddr6 = (struct sockaddr_in6 *) addr;\n#endif\n\tint portnum;\n\tchar portnumbuf[10];\n\n\n#if defined(IPv6) && defined(AF_INET6)\n\tif (family == AF_INET6)\n\t    portnum = ntohs (saddr6->sin6_port);\n\telse\n#endif\n\t    portnum = ntohs (saddr->sin_port);\n\n\tsnprintf (portnumbuf, sizeof(portnumbuf), \"%d\", portnum);\n\tnetworkId = malloc (3 + strlen (transName) +\n\t    strlen (hostnamebuf) + strlen (portnumbuf));\n\tsprintf (networkId, \"%s/%s:%s\", transName, hostnamebuf, portnumbuf);\n\tbreak;\n    }\n#endif /* defined(TCPCONN) */\n\n\n    default:\n\tbreak;\n    }\n\n    return (networkId);\n}\n\n#include <setjmp.h>\nstatic jmp_buf env;\n\n#ifdef SIGALRM\nstatic volatile int nameserver_timedout = 0;\n\nstatic void\nnameserver_lost(int sig _X_UNUSED)\n{\n  nameserver_timedout = 1;\n  longjmp (env, -1);\n  /* NOTREACHED */\n}\n#endif /* SIGALARM */\n\n\nchar *\nTRANS(GetPeerNetworkId) (XtransConnInfo ciptr)\n\n{\n    int\t\tfamily = ciptr->family;\n    char\t*peer_addr = ciptr->peeraddr;\n    char\t*hostname;\n    char\taddrbuf[256];\n    const char\t*addr = NULL;\n\n    switch (family)\n    {\n    case AF_UNSPEC:\n#if defined(UNIXCONN) || defined(LOCALCONN)\n    case AF_UNIX:\n    {\n\tif (gethostname (addrbuf, sizeof (addrbuf)) == 0)\n\t    addr = addrbuf;\n\tbreak;\n    }\n#endif /* defined(UNIXCONN) || defined(LOCALCONN) */\n\n#if defined(TCPCONN)\n    case AF_INET:\n#if defined(IPv6) && defined(AF_INET6)\n    case AF_INET6:\n#endif\n    {\n\tstruct sockaddr_in *saddr = (struct sockaddr_in *) peer_addr;\n#if defined(IPv6) && defined(AF_INET6)\n\tstruct sockaddr_in6 *saddr6 = (struct sockaddr_in6 *) peer_addr;\n#endif\n\tchar *address;\n\tint addresslen;\n#ifdef XTHREADS_NEEDS_BYNAMEPARAMS\n\t_Xgethostbynameparams hparams;\n#endif\n\tstruct hostent * volatile hostp = NULL;\n\n#if defined(IPv6) && defined(AF_INET6)\n\tif (family == AF_INET6)\n\t{\n\t    address = (char *) &saddr6->sin6_addr;\n\t    addresslen = sizeof (saddr6->sin6_addr);\n\t}\n\telse\n#endif\n\t{\n\t    address = (char *) &saddr->sin_addr;\n\t    addresslen = sizeof (saddr->sin_addr);\n\t}\n\n#ifdef SIGALRM\n\t/*\n\t * gethostbyaddr can take a LONG time if the host does not exist.\n\t * Assume that if it does not respond in NAMESERVER_TIMEOUT seconds\n\t * that something is wrong and do not make the user wait.\n\t * gethostbyaddr will continue after a signal, so we have to\n\t * jump out of it.\n\t */\n\n\tnameserver_timedout = 0;\n\tsignal (SIGALRM, nameserver_lost);\n\talarm (4);\n\tif (setjmp(env) == 0) {\n#endif\n\t    hostp = _XGethostbyaddr (address, addresslen, family, hparams);\n#ifdef SIGALRM\n\t}\n\talarm (0);\n#endif\n\tif (hostp != NULL)\n\t  addr = hostp->h_name;\n\telse\n#if defined(IPv6) && defined(AF_INET6)\n\t  addr = inet_ntop (family, address, addrbuf, sizeof (addrbuf));\n#else\n\t  addr = inet_ntoa (saddr->sin_addr);\n#endif\n\tbreak;\n    }\n\n#endif /* defined(TCPCONN) */\n\n\n    default:\n\treturn (NULL);\n    }\n\n\n    hostname = malloc (strlen (ciptr->transptr->TransName) + strlen (addr) + 2);\n    strcpy (hostname, ciptr->transptr->TransName);\n    strcat (hostname, \"/\");\n    if (addr)\n\tstrcat (hostname, addr);\n\n    return (hostname);\n}\n\n#endif /* ICE_t */\n\n\n#if defined(WIN32) && defined(TCPCONN)\nint\nTRANS(WSAStartup) (void)\n{\n    static WSADATA wsadata;\n\n    prmsg (2,\"WSAStartup()\\n\");\n\n    if (!wsadata.wVersion && WSAStartup(MAKEWORD(2,2), &wsadata))\n        return 1;\n    return 0;\n}\n#endif\n\n#include <ctype.h>\n\nstatic int\nis_numeric (const char *str)\n{\n    int i;\n\n    for (i = 0; i < (int) strlen (str); i++)\n\tif (!isdigit (str[i]))\n\t    return (0);\n\n    return (1);\n}\n\n#ifdef TRANS_SERVER\n#include <sys/types.h>\n#include <sys/stat.h>\n#include <errno.h>\n\n#if !defined(S_IFLNK) && !defined(S_ISLNK)\n#undef lstat\n#define lstat(a,b) stat(a,b)\n#endif\n\n#define FAIL_IF_NOMODE  1\n#define FAIL_IF_NOT_ROOT 2\n#define WARN_NO_ACCESS 4\n\n/*\n * We make the assumption that when the 'sticky' (t) bit is requested\n * it's not save if the directory has non-root ownership or the sticky\n * bit cannot be set and fail.\n */\nstatic int\ntrans_mkdir(const char *path, int mode)\n{\n    struct stat buf;\n\n    if (lstat(path, &buf) != 0) {\n\tif (errno != ENOENT) {\n\t    prmsg(1, \"mkdir: ERROR: (l)stat failed for %s (%d)\\n\",\n\t\t  path, errno);\n\t    return -1;\n\t}\n\t/* Dir doesn't exist. Try to create it */\n\n#if !defined(WIN32) && !defined(__CYGWIN__)\n\t/*\n\t * 'sticky' bit requested: assume application makes\n\t * certain security implications. If effective user ID\n\t * is != 0: fail as we may not be able to meet them.\n\t */\n\tif (geteuid() != 0) {\n\t    if (mode & 01000) {\n\t\tprmsg(1, \"mkdir: ERROR: euid != 0,\"\n\t\t      \"directory %s will not be created.\\n\",\n\t\t      path);\n#ifdef FAIL_HARD\n\t\treturn -1;\n#endif\n\t    } else {\n\t\tprmsg(1, \"mkdir: Cannot create %s with root ownership\\n\",\n\t\t      path);\n\t    }\n\t}\n#endif\n\n#ifndef WIN32\n\tif (mkdir(path, mode) == 0) {\n\t    if (chmod(path, mode)) {\n\t\tprmsg(1, \"mkdir: ERROR: Mode of %s should be set to %04o\\n\",\n\t\t      path, mode);\n#ifdef FAIL_HARD\n\t\treturn -1;\n#endif\n\t    }\n#else\n\tif (mkdir(path) == 0) {\n#endif\n\t} else {\n\t    prmsg(1, \"mkdir: ERROR: Cannot create %s\\n\",\n\t\t  path);\n\t    return -1;\n\t}\n\n\treturn 0;\n\n    } else {\n\tif (S_ISDIR(buf.st_mode)) {\n\t    int updateOwner = 0;\n\t    int updateMode = 0;\n\t    int updatedOwner = 0;\n\t    int updatedMode = 0;\n\t    int status = 0;\n\t    /* Check if the directory's ownership is OK. */\n\t    if (buf.st_uid != 0)\n\t\tupdateOwner = 1;\n\n\t    /*\n\t     * Check if the directory's mode is OK.  An exact match isn't\n\t     * required, just a mode that isn't more permissive than the\n\t     * one requested.\n\t     */\n\t    if ((~mode) & 0077 & buf.st_mode)\n\t\tupdateMode = 1;\n\n\t    /*\n\t     * If the directory is not writeable not everybody may\n\t     * be able to create sockets. Therefore warn if mode\n\t     * cannot be fixed.\n\t     */\n\t    if ((~buf.st_mode) & 0022 & mode) {\n\t\tupdateMode = 1;\n\t\tstatus |= WARN_NO_ACCESS;\n\t    }\n\n\t    /*\n\t     * If 'sticky' bit is requested fail if owner isn't root\n\t     * as we assume the caller makes certain security implications\n\t     */\n\t    if (mode & 01000) {\n\t\tstatus |= FAIL_IF_NOT_ROOT;\n\t\tif (!(buf.st_mode & 01000)) {\n\t\t    status |= FAIL_IF_NOMODE;\n\t\t    updateMode = 1;\n\t\t}\n\t    }\n\n#ifdef HAS_FCHOWN\n\t    /*\n\t     * If fchown(2) and fchmod(2) are available, try to correct the\n\t     * directory's owner and mode.  Otherwise it isn't safe to attempt\n\t     * to do this.\n\t     */\n\t    if (updateMode || updateOwner) {\n\t\tint fd = -1;\n\t\tstruct stat fbuf;\n\t\tif ((fd = open(path, O_RDONLY)) != -1) {\n\t\t    if (fstat(fd, &fbuf) == -1) {\n\t\t\tprmsg(1, \"mkdir: ERROR: fstat failed for %s (%d)\\n\",\n\t\t\t      path, errno);\n\t\t\tclose(fd);\n\t\t\treturn -1;\n\t\t    }\n\t\t    /*\n\t\t     * Verify that we've opened the same directory as was\n\t\t     * checked above.\n\t\t     */\n\t\t    if (!S_ISDIR(fbuf.st_mode) ||\n\t\t\tbuf.st_dev != fbuf.st_dev ||\n\t\t\tbuf.st_ino != fbuf.st_ino) {\n\t\t\tprmsg(1, \"mkdir: ERROR: inode for %s changed\\n\",\n\t\t\t      path);\n\t\t\tclose(fd);\n\t\t\treturn -1;\n\t\t    }\n\t\t    if (updateOwner && fchown(fd, 0, 0) == 0)\n\t\t\tupdatedOwner = 1;\n\t\t    if (updateMode && fchmod(fd, mode) == 0)\n\t\t\tupdatedMode = 1;\n\t\t    close(fd);\n\t\t}\n\t    }\n#endif\n\n\t    if (updateOwner && !updatedOwner) {\n#ifdef FAIL_HARD\n\t\tif (status & FAIL_IF_NOT_ROOT) {\n\t\t    prmsg(1, \"mkdir: ERROR: Owner of %s must be set to root\\n\",\n\t\t\t  path);\n\t\t    return -1;\n\t\t}\n#endif\n#if !defined(__APPLE_CC__) && !defined(__CYGWIN__)\n\t\tprmsg(1, \"mkdir: Owner of %s should be set to root\\n\",\n\t\t      path);\n#endif\n\t    }\n\n\t    if (updateMode && !updatedMode) {\n#ifdef FAIL_HARD\n\t\tif (status & FAIL_IF_NOMODE) {\n\t\t    prmsg(1, \"mkdir: ERROR: Mode of %s must be set to %04o\\n\",\n\t\t\t  path, mode);\n\t\t    return -1;\n\t\t}\n#endif\n\t\tprmsg(1, \"mkdir: Mode of %s should be set to %04o\\n\",\n\t\t      path, mode);\n\t\tif (status & WARN_NO_ACCESS) {\n\t\t    prmsg(1, \"mkdir: this may cause subsequent errors\\n\");\n\t\t}\n\t    }\n\t    return 0;\n\t}\n\treturn -1;\n    }\n\n    /* In all other cases, fail */\n    return -1;\n}\n\n#endif /* TRANS_SERVER */\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/X11/Xtrans/transport.c",
    "content": "/*\n\nCopyright 1993, 1994, 1998  The Open Group\n\nPermission to use, copy, modify, distribute, and sell this software and its\ndocumentation for any purpose is hereby granted without fee, provided that\nthe above copyright notice appear in all copies and that both that\ncopyright notice and this permission notice appear in supporting\ndocumentation.\n\nThe above copyright notice and this permission notice shall be included\nin all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\nOR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR\nOTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,\nARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\nOTHER DEALINGS IN THE SOFTWARE.\n\nExcept as contained in this notice, the name of The Open Group shall\nnot be used in advertising or otherwise to promote the sale, use or\nother dealings in this Software without prior written authorization\nfrom The Open Group.\n\n * Copyright 1993, 1994 NCR Corporation - Dayton, Ohio, USA\n *\n * All Rights Reserved\n *\n * Permission to use, copy, modify, and distribute this software and its\n * documentation for any purpose and without fee is hereby granted, provided\n * that the above copyright notice appear in all copies and that both that\n * copyright notice and this permission notice appear in supporting\n * documentation, and that the name NCR not be used in advertising\n * or publicity pertaining to distribution of the software without specific,\n * written prior permission.  NCR makes no representations about the\n * suitability of this software for any purpose.  It is provided \"as is\"\n * without express or implied warranty.\n *\n * NCR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,\n * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN\n * NO EVENT SHALL NCR BE LIABLE FOR ANY SPECIAL, INDIRECT OR\n * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS\n * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,\n * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN\n * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n */\n\n#include <stdlib.h>\n\n#define XTRANS_TRANSPORT_C  /* used to flag Xtransint.h that it's being used\n\t\t\t       here, not just #included in another file */\n\n#include \"Xtransint.h\"\n\n#ifdef __clang__\n#pragma clang diagnostic push\n#pragma clang diagnostic ignored \"-Wformat-nonliteral\"\n#pragma clang diagnostic ignored \"-Wdeprecated-declarations\"\n#endif\n\n#ifdef LOCALCONN\n#include \"Xtranslcl.c\"\n#endif\n#if defined(TCPCONN) || defined(UNIXCONN)\n#include \"Xtranssock.c\"\n#endif\n#include \"Xtrans.c\"\n#include \"Xtransutil.c\"\n\n#ifdef __clang__\n#pragma clang diagnostic pop\n#endif\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/X11/Xutil.h",
    "content": "\n/***********************************************************\n\nCopyright 1987, 1998  The Open Group\n\nPermission to use, copy, modify, distribute, and sell this software and its\ndocumentation for any purpose is hereby granted without fee, provided that\nthe above copyright notice appear in all copies and that both that\ncopyright notice and this permission notice appear in supporting\ndocumentation.\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE\nOPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN\nAN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\nCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\nExcept as contained in this notice, the name of The Open Group shall not be\nused in advertising or otherwise to promote the sale, use or other dealings\nin this Software without prior written authorization from The Open Group.\n\n\nCopyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.\n\n                        All Rights Reserved\n\nPermission to use, copy, modify, and distribute this software and its\ndocumentation for any purpose and without fee is hereby granted,\nprovided that the above copyright notice appear in all copies and that\nboth that copyright notice and this permission notice appear in\nsupporting documentation, and that the name of Digital not be\nused in advertising or publicity pertaining to distribution of the\nsoftware without specific, written prior permission.\n\nDIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING\nALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL\nDIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR\nANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,\nWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,\nARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS\nSOFTWARE.\n\n******************************************************************/\n\n#ifndef _X11_XUTIL_H_\n#define _X11_XUTIL_H_\n\n/* You must include <X11/Xlib.h> before including this file */\n#include <X11/Xlib.h>\n#include <X11/keysym.h>\n\n/* The Xlib structs are full of implicit padding to properly align members.\n   We can't clean that up without breaking ABI, so tell clang not to bother\n   complaining about it. */\n#ifdef __clang__\n#pragma clang diagnostic push\n#pragma clang diagnostic ignored \"-Wpadded\"\n#endif\n\n/*\n * Bitmask returned by XParseGeometry().  Each bit tells if the corresponding\n * value (x, y, width, height) was found in the parsed string.\n */\n#define NoValue\t\t0x0000\n#define XValue  \t0x0001\n#define YValue\t\t0x0002\n#define WidthValue  \t0x0004\n#define HeightValue  \t0x0008\n#define AllValues \t0x000F\n#define XNegative \t0x0010\n#define YNegative \t0x0020\n\n/*\n * new version containing base_width, base_height, and win_gravity fields;\n * used with WM_NORMAL_HINTS.\n */\ntypedef struct {\n    \tlong flags;\t/* marks which fields in this structure are defined */\n\tint x, y;\t\t/* obsolete for new window mgrs, but clients */\n\tint width, height;\t/* should set so old wm's don't mess up */\n\tint min_width, min_height;\n\tint max_width, max_height;\n    \tint width_inc, height_inc;\n\tstruct {\n\t\tint x;\t/* numerator */\n\t\tint y;\t/* denominator */\n\t} min_aspect, max_aspect;\n\tint base_width, base_height;\t\t/* added by ICCCM version 1 */\n\tint win_gravity;\t\t\t/* added by ICCCM version 1 */\n} XSizeHints;\n\n/*\n * The next block of definitions are for window manager properties that\n * clients and applications use for communication.\n */\n\n/* flags argument in size hints */\n#define USPosition\t(1L << 0) /* user specified x, y */\n#define USSize\t\t(1L << 1) /* user specified width, height */\n\n#define PPosition\t(1L << 2) /* program specified position */\n#define PSize\t\t(1L << 3) /* program specified size */\n#define PMinSize\t(1L << 4) /* program specified minimum size */\n#define PMaxSize\t(1L << 5) /* program specified maximum size */\n#define PResizeInc\t(1L << 6) /* program specified resize increments */\n#define PAspect\t\t(1L << 7) /* program specified min and max aspect ratios */\n#define PBaseSize\t(1L << 8) /* program specified base for incrementing */\n#define PWinGravity\t(1L << 9) /* program specified window gravity */\n\n/* obsolete */\n#define PAllHints (PPosition|PSize|PMinSize|PMaxSize|PResizeInc|PAspect)\n\n\n\ntypedef struct {\n\tlong flags;\t/* marks which fields in this structure are defined */\n\tBool input;\t/* does this application rely on the window manager to\n\t\t\tget keyboard input? */\n\tint initial_state;\t/* see below */\n\tPixmap icon_pixmap;\t/* pixmap to be used as icon */\n\tWindow icon_window; \t/* window to be used as icon */\n\tint icon_x, icon_y; \t/* initial position of icon */\n\tPixmap icon_mask;\t/* icon mask bitmap */\n\tXID window_group;\t/* id of related window group */\n\t/* this structure may be extended in the future */\n} XWMHints;\n\n/* definition for flags of XWMHints */\n\n#define InputHint \t\t(1L << 0)\n#define StateHint \t\t(1L << 1)\n#define IconPixmapHint\t\t(1L << 2)\n#define IconWindowHint\t\t(1L << 3)\n#define IconPositionHint \t(1L << 4)\n#define IconMaskHint\t\t(1L << 5)\n#define WindowGroupHint\t\t(1L << 6)\n#define AllHints (InputHint|StateHint|IconPixmapHint|IconWindowHint| \\\nIconPositionHint|IconMaskHint|WindowGroupHint)\n#define XUrgencyHint\t\t(1L << 8)\n\n/* definitions for initial window state */\n#define WithdrawnState 0\t/* for windows that are not mapped */\n#define NormalState 1\t/* most applications want to start this way */\n#define IconicState 3\t/* application wants to start as an icon */\n\n/*\n * Obsolete states no longer defined by ICCCM\n */\n#define DontCareState 0\t/* don't know or care */\n#define ZoomState 2\t/* application wants to start zoomed */\n#define InactiveState 4\t/* application believes it is seldom used; */\n\t\t\t/* some wm's may put it on inactive menu */\n\n\n/*\n * new structure for manipulating TEXT properties; used with WM_NAME,\n * WM_ICON_NAME, WM_CLIENT_MACHINE, and WM_COMMAND.\n */\ntypedef struct {\n    unsigned char *value;\t\t/* same as Property routines */\n    Atom encoding;\t\t\t/* prop type */\n    int format;\t\t\t\t/* prop data format: 8, 16, or 32 */\n    unsigned long nitems;\t\t/* number of data items in value */\n} XTextProperty;\n\n#define XNoMemory -1\n#define XLocaleNotSupported -2\n#define XConverterNotFound -3\n\ntypedef enum {\n    XStringStyle,\t\t/* STRING */\n    XCompoundTextStyle,\t\t/* COMPOUND_TEXT */\n    XTextStyle,\t\t\t/* text in owner's encoding (current locale)*/\n    XStdICCTextStyle,\t\t/* STRING, else COMPOUND_TEXT */\n    /* The following is an XFree86 extension, introduced in November 2000 */\n    XUTF8StringStyle\t\t/* UTF8_STRING */\n} XICCEncodingStyle;\n\ntypedef struct {\n\tint min_width, min_height;\n\tint max_width, max_height;\n\tint width_inc, height_inc;\n} XIconSize;\n\ntypedef struct {\n\tchar *res_name;\n\tchar *res_class;\n} XClassHint;\n\n#ifdef XUTIL_DEFINE_FUNCTIONS\nextern int XDestroyImage(\n        XImage *ximage);\nextern unsigned long XGetPixel(\n        XImage *ximage,\n        int x, int y);\nextern int XPutPixel(\n        XImage *ximage,\n        int x, int y,\n        unsigned long pixel);\nextern XImage *XSubImage(\n        XImage *ximage,\n        int x, int y,\n        unsigned int width, unsigned int height);\nextern int XAddPixel(\n        XImage *ximage,\n        long value);\n#else\n/*\n * These macros are used to give some sugar to the image routines so that\n * naive people are more comfortable with them.\n */\n#define XDestroyImage(ximage) \\\n\t((*((ximage)->f.destroy_image))((ximage)))\n#define XGetPixel(ximage, x, y) \\\n\t((*((ximage)->f.get_pixel))((ximage), (x), (y)))\n#define XPutPixel(ximage, x, y, pixel) \\\n\t((*((ximage)->f.put_pixel))((ximage), (x), (y), (pixel)))\n#define XSubImage(ximage, x, y, width, height)  \\\n\t((*((ximage)->f.sub_image))((ximage), (x), (y), (width), (height)))\n#define XAddPixel(ximage, value) \\\n\t((*((ximage)->f.add_pixel))((ximage), (value)))\n#endif\n\n/*\n * Compose sequence status structure, used in calling XLookupString.\n */\ntypedef struct _XComposeStatus {\n    XPointer compose_ptr;\t/* state table pointer */\n    int chars_matched;\t\t/* match state */\n} XComposeStatus;\n\n/*\n * Keysym macros, used on Keysyms to test for classes of symbols\n */\n#define IsKeypadKey(keysym) \\\n  (((KeySym)(keysym) >= XK_KP_Space) && ((KeySym)(keysym) <= XK_KP_Equal))\n\n#define IsPrivateKeypadKey(keysym) \\\n  (((KeySym)(keysym) >= 0x11000000) && ((KeySym)(keysym) <= 0x1100FFFF))\n\n#define IsCursorKey(keysym) \\\n  (((KeySym)(keysym) >= XK_Home)     && ((KeySym)(keysym) <  XK_Select))\n\n#define IsPFKey(keysym) \\\n  (((KeySym)(keysym) >= XK_KP_F1)     && ((KeySym)(keysym) <= XK_KP_F4))\n\n#define IsFunctionKey(keysym) \\\n  (((KeySym)(keysym) >= XK_F1)       && ((KeySym)(keysym) <= XK_F35))\n\n#define IsMiscFunctionKey(keysym) \\\n  (((KeySym)(keysym) >= XK_Select)   && ((KeySym)(keysym) <= XK_Break))\n\n#ifdef XK_XKB_KEYS\n#define IsModifierKey(keysym) \\\n  ((((KeySym)(keysym) >= XK_Shift_L) && ((KeySym)(keysym) <= XK_Hyper_R)) \\\n   || (((KeySym)(keysym) >= XK_ISO_Lock) && \\\n       ((KeySym)(keysym) <= XK_ISO_Level5_Lock)) \\\n   || ((KeySym)(keysym) == XK_Mode_switch) \\\n   || ((KeySym)(keysym) == XK_Num_Lock))\n#else\n#define IsModifierKey(keysym) \\\n  ((((KeySym)(keysym) >= XK_Shift_L) && ((KeySym)(keysym) <= XK_Hyper_R)) \\\n   || ((KeySym)(keysym) == XK_Mode_switch) \\\n   || ((KeySym)(keysym) == XK_Num_Lock))\n#endif\n/*\n * opaque reference to Region data type\n */\ntypedef struct _XRegion *Region;\n\n/* Return values from XRectInRegion() */\n\n#define RectangleOut 0\n#define RectangleIn  1\n#define RectanglePart 2\n\n\n/*\n * Information used by the visual utility routines to find desired visual\n * type from the many visuals a display may support.\n */\n\ntypedef struct {\n  Visual *visual;\n  VisualID visualid;\n  int screen;\n  int depth;\n#if defined(__cplusplus) || defined(c_plusplus)\n  int c_class;\t\t\t\t\t/* C++ */\n#else\n  int class;\n#endif\n  unsigned long red_mask;\n  unsigned long green_mask;\n  unsigned long blue_mask;\n  int colormap_size;\n  int bits_per_rgb;\n} XVisualInfo;\n\n#define VisualNoMask\t\t0x0\n#define VisualIDMask \t\t0x1\n#define VisualScreenMask\t0x2\n#define VisualDepthMask\t\t0x4\n#define VisualClassMask\t\t0x8\n#define VisualRedMaskMask\t0x10\n#define VisualGreenMaskMask\t0x20\n#define VisualBlueMaskMask\t0x40\n#define VisualColormapSizeMask\t0x80\n#define VisualBitsPerRGBMask\t0x100\n#define VisualAllMask\t\t0x1FF\n\n/*\n * This defines a window manager property that clients may use to\n * share standard color maps of type RGB_COLOR_MAP:\n */\ntypedef struct {\n\tColormap colormap;\n\tunsigned long red_max;\n\tunsigned long red_mult;\n\tunsigned long green_max;\n\tunsigned long green_mult;\n\tunsigned long blue_max;\n\tunsigned long blue_mult;\n\tunsigned long base_pixel;\n\tVisualID visualid;\t\t/* added by ICCCM version 1 */\n\tXID killid;\t\t\t/* added by ICCCM version 1 */\n} XStandardColormap;\n\n#define ReleaseByFreeingColormap ((XID) 1L)  /* for killid field above */\n\n\n/*\n * return codes for XReadBitmapFile and XWriteBitmapFile\n */\n#define BitmapSuccess\t\t0\n#define BitmapOpenFailed \t1\n#define BitmapFileInvalid \t2\n#define BitmapNoMemory\t\t3\n\n/****************************************************************\n *\n * Context Management\n *\n ****************************************************************/\n\n\n/* Associative lookup table return codes */\n\n#define XCSUCCESS 0\t/* No error. */\n#define XCNOMEM   1    /* Out of memory */\n#define XCNOENT   2    /* No entry in table */\n\ntypedef int XContext;\n\n#define XUniqueContext()       ((XContext) XrmUniqueQuark())\n#define XStringToContext(string)   ((XContext) XrmStringToQuark(string))\n\n_XFUNCPROTOBEGIN\n\n/* The following declarations are alphabetized. */\n\nextern XClassHint *XAllocClassHint (\n    void\n);\n\nextern XIconSize *XAllocIconSize (\n    void\n);\n\nextern XSizeHints *XAllocSizeHints (\n    void\n);\n\nextern XStandardColormap *XAllocStandardColormap (\n    void\n);\n\nextern XWMHints *XAllocWMHints (\n    void\n);\n\nextern int XClipBox(\n    Region\t\t/* r */,\n    XRectangle*\t\t/* rect_return */\n);\n\nextern Region XCreateRegion(\n    void\n);\n\nextern const char *XDefaultString (void);\n\nextern int XDeleteContext(\n    Display*\t\t/* display */,\n    XID\t\t\t/* rid */,\n    XContext\t\t/* context */\n);\n\nextern int XDestroyRegion(\n    Region\t\t/* r */\n);\n\nextern int XEmptyRegion(\n    Region\t\t/* r */\n);\n\nextern int XEqualRegion(\n    Region\t\t/* r1 */,\n    Region\t\t/* r2 */\n);\n\nextern int XFindContext(\n    Display*\t\t/* display */,\n    XID\t\t\t/* rid */,\n    XContext\t\t/* context */,\n    XPointer*\t\t/* data_return */\n);\n\nextern Status XGetClassHint(\n    Display*\t\t/* display */,\n    Window\t\t/* w */,\n    XClassHint*\t\t/* class_hints_return */\n);\n\nextern Status XGetIconSizes(\n    Display*\t\t/* display */,\n    Window\t\t/* w */,\n    XIconSize**\t\t/* size_list_return */,\n    int*\t\t/* count_return */\n);\n\nextern Status XGetNormalHints(\n    Display*\t\t/* display */,\n    Window\t\t/* w */,\n    XSizeHints*\t\t/* hints_return */\n);\n\nextern Status XGetRGBColormaps(\n    Display*\t\t/* display */,\n    Window\t\t/* w */,\n    XStandardColormap** /* stdcmap_return */,\n    int*\t\t/* count_return */,\n    Atom\t\t/* property */\n);\n\nextern Status XGetSizeHints(\n    Display*\t\t/* display */,\n    Window\t\t/* w */,\n    XSizeHints*\t\t/* hints_return */,\n    Atom\t\t/* property */\n);\n\nextern Status XGetStandardColormap(\n    Display*\t\t/* display */,\n    Window\t\t/* w */,\n    XStandardColormap*\t/* colormap_return */,\n    Atom\t\t/* property */\n);\n\nextern Status XGetTextProperty(\n    Display*\t\t/* display */,\n    Window\t\t/* window */,\n    XTextProperty*\t/* text_prop_return */,\n    Atom\t\t/* property */\n);\n\nextern XVisualInfo *XGetVisualInfo(\n    Display*\t\t/* display */,\n    long\t\t/* vinfo_mask */,\n    XVisualInfo*\t/* vinfo_template */,\n    int*\t\t/* nitems_return */\n);\n\nextern Status XGetWMClientMachine(\n    Display*\t\t/* display */,\n    Window\t\t/* w */,\n    XTextProperty*\t/* text_prop_return */\n);\n\nextern XWMHints *XGetWMHints(\n    Display*\t\t/* display */,\n    Window\t\t/* w */\n);\n\nextern Status XGetWMIconName(\n    Display*\t\t/* display */,\n    Window\t\t/* w */,\n    XTextProperty*\t/* text_prop_return */\n);\n\nextern Status XGetWMName(\n    Display*\t\t/* display */,\n    Window\t\t/* w */,\n    XTextProperty*\t/* text_prop_return */\n);\n\nextern Status XGetWMNormalHints(\n    Display*\t\t/* display */,\n    Window\t\t/* w */,\n    XSizeHints*\t\t/* hints_return */,\n    long*\t\t/* supplied_return */\n);\n\nextern Status XGetWMSizeHints(\n    Display*\t\t/* display */,\n    Window\t\t/* w */,\n    XSizeHints*\t\t/* hints_return */,\n    long*\t\t/* supplied_return */,\n    Atom\t\t/* property */\n);\n\nextern Status XGetZoomHints(\n    Display*\t\t/* display */,\n    Window\t\t/* w */,\n    XSizeHints*\t\t/* zhints_return */\n);\n\nextern int XIntersectRegion(\n    Region\t\t/* sra */,\n    Region\t\t/* srb */,\n    Region\t\t/* dr_return */\n);\n\nextern void XConvertCase(\n    KeySym\t\t/* sym */,\n    KeySym*\t\t/* lower */,\n    KeySym*\t\t/* upper */\n);\n\nextern int XLookupString(\n    XKeyEvent*\t\t/* event_struct */,\n    char*\t\t/* buffer_return */,\n    int\t\t\t/* bytes_buffer */,\n    KeySym*\t\t/* keysym_return */,\n    XComposeStatus*\t/* status_in_out */\n);\n\nextern Status XMatchVisualInfo(\n    Display*\t\t/* display */,\n    int\t\t\t/* screen */,\n    int\t\t\t/* depth */,\n    int\t\t\t/* class */,\n    XVisualInfo*\t/* vinfo_return */\n);\n\nextern int XOffsetRegion(\n    Region\t\t/* r */,\n    int\t\t\t/* dx */,\n    int\t\t\t/* dy */\n);\n\nextern Bool XPointInRegion(\n    Region\t\t/* r */,\n    int\t\t\t/* x */,\n    int\t\t\t/* y */\n);\n\nextern Region XPolygonRegion(\n    XPoint*\t\t/* points */,\n    int\t\t\t/* n */,\n    int\t\t\t/* fill_rule */\n);\n\nextern int XRectInRegion(\n    Region\t\t/* r */,\n    int\t\t\t/* x */,\n    int\t\t\t/* y */,\n    unsigned int\t/* width */,\n    unsigned int\t/* height */\n);\n\nextern int XSaveContext(\n    Display*\t\t/* display */,\n    XID\t\t\t/* rid */,\n    XContext\t\t/* context */,\n    _Xconst char*\t/* data */\n);\n\nextern int XSetClassHint(\n    Display*\t\t/* display */,\n    Window\t\t/* w */,\n    XClassHint*\t\t/* class_hints */\n);\n\nextern int XSetIconSizes(\n    Display*\t\t/* display */,\n    Window\t\t/* w */,\n    XIconSize*\t\t/* size_list */,\n    int\t\t\t/* count */\n);\n\nextern int XSetNormalHints(\n    Display*\t\t/* display */,\n    Window\t\t/* w */,\n    XSizeHints*\t\t/* hints */\n);\n\nextern void XSetRGBColormaps(\n    Display*\t\t/* display */,\n    Window\t\t/* w */,\n    XStandardColormap*\t/* stdcmaps */,\n    int\t\t\t/* count */,\n    Atom\t\t/* property */\n);\n\nextern int XSetSizeHints(\n    Display*\t\t/* display */,\n    Window\t\t/* w */,\n    XSizeHints*\t\t/* hints */,\n    Atom\t\t/* property */\n);\n\nextern int XSetStandardProperties(\n    Display*\t\t/* display */,\n    Window\t\t/* w */,\n    _Xconst char*\t/* window_name */,\n    _Xconst char*\t/* icon_name */,\n    Pixmap\t\t/* icon_pixmap */,\n    char**\t\t/* argv */,\n    int\t\t\t/* argc */,\n    XSizeHints*\t\t/* hints */\n);\n\nextern void XSetTextProperty(\n    Display*\t\t/* display */,\n    Window\t\t/* w */,\n    XTextProperty*\t/* text_prop */,\n    Atom\t\t/* property */\n);\n\nextern void XSetWMClientMachine(\n    Display*\t\t/* display */,\n    Window\t\t/* w */,\n    XTextProperty*\t/* text_prop */\n);\n\nextern int XSetWMHints(\n    Display*\t\t/* display */,\n    Window\t\t/* w */,\n    XWMHints*\t\t/* wm_hints */\n);\n\nextern void XSetWMIconName(\n    Display*\t\t/* display */,\n    Window\t\t/* w */,\n    XTextProperty*\t/* text_prop */\n);\n\nextern void XSetWMName(\n    Display*\t\t/* display */,\n    Window\t\t/* w */,\n    XTextProperty*\t/* text_prop */\n);\n\nextern void XSetWMNormalHints(\n    Display*\t\t/* display */,\n    Window\t\t/* w */,\n    XSizeHints*\t\t/* hints */\n);\n\nextern void XSetWMProperties(\n    Display*\t\t/* display */,\n    Window\t\t/* w */,\n    XTextProperty*\t/* window_name */,\n    XTextProperty*\t/* icon_name */,\n    char**\t\t/* argv */,\n    int\t\t\t/* argc */,\n    XSizeHints*\t\t/* normal_hints */,\n    XWMHints*\t\t/* wm_hints */,\n    XClassHint*\t\t/* class_hints */\n);\n\nextern void XmbSetWMProperties(\n    Display*\t\t/* display */,\n    Window\t\t/* w */,\n    _Xconst char*\t/* window_name */,\n    _Xconst char*\t/* icon_name */,\n    char**\t\t/* argv */,\n    int\t\t\t/* argc */,\n    XSizeHints*\t\t/* normal_hints */,\n    XWMHints*\t\t/* wm_hints */,\n    XClassHint*\t\t/* class_hints */\n);\n\nextern void Xutf8SetWMProperties(\n    Display*\t\t/* display */,\n    Window\t\t/* w */,\n    _Xconst char*\t/* window_name */,\n    _Xconst char*\t/* icon_name */,\n    char**\t\t/* argv */,\n    int\t\t\t/* argc */,\n    XSizeHints*\t\t/* normal_hints */,\n    XWMHints*\t\t/* wm_hints */,\n    XClassHint*\t\t/* class_hints */\n);\n\nextern void XSetWMSizeHints(\n    Display*\t\t/* display */,\n    Window\t\t/* w */,\n    XSizeHints*\t\t/* hints */,\n    Atom\t\t/* property */\n);\n\nextern int XSetRegion(\n    Display*\t\t/* display */,\n    GC\t\t\t/* gc */,\n    Region\t\t/* r */\n);\n\nextern void XSetStandardColormap(\n    Display*\t\t/* display */,\n    Window\t\t/* w */,\n    XStandardColormap*\t/* colormap */,\n    Atom\t\t/* property */\n);\n\nextern int XSetZoomHints(\n    Display*\t\t/* display */,\n    Window\t\t/* w */,\n    XSizeHints*\t\t/* zhints */\n);\n\nextern int XShrinkRegion(\n    Region\t\t/* r */,\n    int\t\t\t/* dx */,\n    int\t\t\t/* dy */\n);\n\nextern Status XStringListToTextProperty(\n    char**\t\t/* list */,\n    int\t\t\t/* count */,\n    XTextProperty*\t/* text_prop_return */\n);\n\nextern int XSubtractRegion(\n    Region\t\t/* sra */,\n    Region\t\t/* srb */,\n    Region\t\t/* dr_return */\n);\n\nextern int XmbTextListToTextProperty(\n    Display*\t\tdisplay,\n    char**\t\tlist,\n    int\t\t\tcount,\n    XICCEncodingStyle\tstyle,\n    XTextProperty*\ttext_prop_return\n);\n\nextern int XwcTextListToTextProperty(\n    Display*\t\tdisplay,\n    wchar_t**\t\tlist,\n    int\t\t\tcount,\n    XICCEncodingStyle\tstyle,\n    XTextProperty*\ttext_prop_return\n);\n\nextern int Xutf8TextListToTextProperty(\n    Display*\t\tdisplay,\n    char**\t\tlist,\n    int\t\t\tcount,\n    XICCEncodingStyle\tstyle,\n    XTextProperty*\ttext_prop_return\n);\n\nextern void XwcFreeStringList(\n    wchar_t**\t\tlist\n);\n\nextern Status XTextPropertyToStringList(\n    XTextProperty*\t/* text_prop */,\n    char***\t\t/* list_return */,\n    int*\t\t/* count_return */\n);\n\nextern int XmbTextPropertyToTextList(\n    Display*\t\tdisplay,\n    const XTextProperty* text_prop,\n    char***\t\tlist_return,\n    int*\t\tcount_return\n);\n\nextern int XwcTextPropertyToTextList(\n    Display*\t\tdisplay,\n    const XTextProperty* text_prop,\n    wchar_t***\t\tlist_return,\n    int*\t\tcount_return\n);\n\nextern int Xutf8TextPropertyToTextList(\n    Display*\t\tdisplay,\n    const XTextProperty* text_prop,\n    char***\t\tlist_return,\n    int*\t\tcount_return\n);\n\nextern int XUnionRectWithRegion(\n    XRectangle*\t\t/* rectangle */,\n    Region\t\t/* src_region */,\n    Region\t\t/* dest_region_return */\n);\n\nextern int XUnionRegion(\n    Region\t\t/* sra */,\n    Region\t\t/* srb */,\n    Region\t\t/* dr_return */\n);\n\nextern int XWMGeometry(\n    Display*\t\t/* display */,\n    int\t\t\t/* screen_number */,\n    _Xconst char*\t/* user_geometry */,\n    _Xconst char*\t/* default_geometry */,\n    unsigned int\t/* border_width */,\n    XSizeHints*\t\t/* hints */,\n    int*\t\t/* x_return */,\n    int*\t\t/* y_return */,\n    int*\t\t/* width_return */,\n    int*\t\t/* height_return */,\n    int*\t\t/* gravity_return */\n);\n\nextern int XXorRegion(\n    Region\t\t/* sra */,\n    Region\t\t/* srb */,\n    Region\t\t/* dr_return */\n);\n\n#ifdef __clang__\n#pragma clang diagnostic pop\n#endif\n\n_XFUNCPROTOEND\n\n#endif /* _X11_XUTIL_H_ */\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/X11/Xw32defs.h",
    "content": "#ifndef _XW32DEFS_H\n# define  _XW32DEFS_H\n\n# ifdef __GNUC__ /* mingw is more close to unix than msvc */\n#  if !defined(__daddr_t_defined) \ntypedef char *caddr_t;\n#  endif\n#  define lstat stat\n\n# else\ntypedef char *caddr_t;\n\n#  define access\t   _access\n#  define alloca\t   _alloca\n#  define chdir\t_chdir\n#  define chmod\t   _chmod\n#  define close\t   _close\n#  define creat\t   _creat\n#  define dup\t   _dup\n#  define dup2\t   _dup2\n#  define environ     _environ\n#  define execl\t _execl\n#  define execle\t _execle\n#  define execlp\t _execlp\n#  define execlpe  _execlpe\n#  define execv\t _execv\n#  define execve\t _execve\n#  define execvp\t _execvp\n#  define execvpe  _execvpe\n#  define fdopen\t  _fdopen\n#  define fileno\t  _fileno\n#  define fstat\t _fstat\n#  define getcwd\t_getcwd\n#  define getpid\t _getpid\n#  define hypot\t\t_hypot\n#  define isascii __isascii\n#  define isatty\t   _isatty\n#  define lseek\t   _lseek\n#  define mkdir\t_mkdir\n#  define mktemp\t   _mktemp\n#  define open\t   _open\n#  define putenv\t    _putenv\n#  define read\t   _read\n#  define rmdir\t_rmdir\n#  define sleep(x) Sleep((x) * 1000)\n#  define stat\t _stat\n#  define sys_errlist _sys_errlist\n#  define sys_nerr    _sys_nerr\n#  define umask\t   _umask\n#  define unlink\t   _unlink\n#  define write\t   _write\n#  define random   rand\n#  define srandom  srand\n\n#  define O_RDONLY    _O_RDONLY\n#  define O_WRONLY    _O_WRONLY\n#  define O_RDWR\t    _O_RDWR\n#  define O_APPEND    _O_APPEND\n#  define O_CREAT     _O_CREAT\n#  define O_TRUNC     _O_TRUNC\n#  define O_EXCL\t    _O_EXCL\n#  define O_TEXT\t    _O_TEXT\n#  define O_BINARY    _O_BINARY\n#  define O_RAW\t    _O_BINARY\n\n#  define S_IFMT\t _S_IFMT\n#  define S_IFDIR  _S_IFDIR\n#  define S_IFCHR  _S_IFCHR\n#  define S_IFREG  _S_IFREG\n#  define S_IREAD  _S_IREAD\n#  define S_IWRITE _S_IWRITE\n#  define S_IEXEC  _S_IEXEC\n\n#  define\tF_OK\t0\n#  define\tX_OK\t1\n#  define\tW_OK\t2\n#  define\tR_OK\t4\n# endif /* __GNUC__ */\n#endif\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/X11/Xwindows.h",
    "content": "/*\n\nCopyright 1996, 1998  The Open Group\n\nPermission to use, copy, modify, distribute, and sell this software and its\ndocumentation for any purpose is hereby granted without fee, provided that\nthe above copyright notice appear in all copies and that both that\ncopyright notice and this permission notice appear in supporting\ndocumentation.\n\nThe above copyright notice and this permission notice shall be included\nin all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\nOR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-\nITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT\nSHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABIL-\nITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\nIN THE SOFTWARE.\n\nExcept as contained in this notice, the name of The Open Group shall\nnot be used in advertising or otherwise to promote the sale, use or\nother dealings in this Software without prior written authorization from\nThe Open Group.\n\n*/\n\n/*\n * This header file has the sole purpose of allowing the inclusion of\n * windows.h without getting any name conflicts with X headers code, by\n * renaming or disabling the conflicting definitions from windows.h\n */\n\n/*\n * Mingw.org versions of the Windows API headers actually avoid\n * making the conflicting definitions if XFree86Server is defined, so we\n * need to remember if that was defined and undefine it during including\n * windows.h (so the conflicting definitions get wrapped correctly), and\n * then redefine it afterwards. (This was never the correct thing to\n * do as it's no help at all to X11 clients which also need to use the\n * Win32 API)\n */\n#undef _XFree86Server\n#ifdef XFree86Server\n# define _XFree86Server\n# undef XFree86Server\n#endif\n\n/*\n * There doesn't seem to be a good way to wrap the min/max macros from\n * windows.h, so we simply avoid defining them completely, allowing any\n * pre-existing definition to stand.\n *\n */\n#define NOMINMAX\n\n/*\n * mingw-w64 headers define BOOL as a typedef, protecting against macros\n * mingw.org headers define BOOL in terms of WINBOOL\n * ... so try to come up with something which works with both :-)\n */\n#define _NO_BOOL_TYPEDEF\n#define BOOL WINBOOL\n#define INT32 wINT32\n#ifdef __x86_64__\n#define INT64 wINT64\n#define LONG64 wLONG64\n#endif\n#undef Status\n#define Status wStatus\n#define ATOM wATOM\n#define BYTE wBYTE\n#define FreeResource wFreeResource\n#include <windows.h>\n#undef NOMINMAX\n#undef Status\n#define Status int\n#undef BYTE\n#undef BOOL\n#undef INT32\n#undef INT64\n#undef LONG64\n#undef ATOM\n#undef FreeResource\n#undef CreateWindowA\n\n/*\n * Older version of this header used to name the windows API bool type wBOOL,\n * rather than more standard name WINBOOL\n */\n#define wBOOL WINBOOL\n\n#ifdef RESOURCE_H\n# undef RT_FONT\n# undef RT_CURSOR\n# define RT_FONT         ((RESTYPE)4)\n# define RT_CURSOR       ((RESTYPE)5)\n#endif\n\n#ifndef __CYGWIN__\n#define sleep(x) Sleep((x) * 1000)\n#endif\n\n#if defined(WIN32) && (!defined(PATH_MAX) || PATH_MAX < 1024)\n# undef PATH_MAX\n# define PATH_MAX 1024\n#endif\n\n#ifdef _XFree86Server\n# define XFree86Server\n# undef _XFree86Server\n#endif\n\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/X11/Xwinsock.h",
    "content": "/*\n\nCopyright 1996, 1998  The Open Group\n\nPermission to use, copy, modify, distribute, and sell this software and its\ndocumentation for any purpose is hereby granted without fee, provided that\nthe above copyright notice appear in all copies and that both that\ncopyright notice and this permission notice appear in supporting\ndocumentation.\n\nThe above copyright notice and this permission notice shall be included\nin all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\nOR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-\nITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT\nSHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABIL-\nITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\nIN THE SOFTWARE.\n\nExcept as contained in this notice, the name of The Open Group shall\nnot be used in advertising or otherwise to promote the sale, use or\nother dealings in this Software without prior written authorization from\nThe Open Group.\n\n*/\n\n/*\n * This header file has for sole purpose to allow to include winsock.h\n * without getting any name conflicts with our code.\n * Conflicts come from the fact that including winsock.h actually pulls\n * in the whole Windows API...\n */\n\n#undef _XFree86Server\n#ifdef XFree86Server \n# define _XFree86Server\n# undef XFree86Server\n#endif\n\n/*\n * mingw-w64 headers define BOOL as a typedef, protecting against macros\n * mingw.org headers define BOOL in terms of WINBOOL\n * ... so try to come up with something which works with both :-)\n */\n#define _NO_BOOL_TYPEDEF\n#define BOOL WINBOOL\n#define INT32 wINT32\n#undef Status\n#define Status wStatus\n#define ATOM wATOM\n#define BYTE wBYTE\n#define FreeResource wFreeResource\n#include <winsock2.h>\n#undef Status\n#define Status int\n#undef BYTE\n#undef BOOL\n#undef INT32\n#undef ATOM\n#undef FreeResource\n#undef CreateWindowA\n#undef RT_FONT\n#undef RT_CURSOR\n\n/*\n * Older version of this header used to name the windows API bool type wBOOL,\n * rather than more standard name WINBOOL\n */\n#define wBOOL WINBOOL\n\n#ifdef _XFree86Server\n# define XFree86Server\n# undef _XFree86Server\n#endif\n\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/X11/ap_keysym.h",
    "content": "/******************************************************************\nCopyright 1987 by Apollo Computer Inc., Chelmsford, Massachusetts.\nCopyright 1989 by Hewlett-Packard Company.\n\n                        All Rights Reserved\n\nPermission to use, duplicate, change, and distribute this software and\nits documentation for any purpose and without fee is granted, provided\nthat the above copyright notice appear in such copy and that this\ncopyright notice appear in all supporting documentation, and that the\nnames of Apollo Computer Inc., the Hewlett-Packard Company, or the X\nConsortium not be used in advertising or publicity pertaining to\ndistribution of the software without written prior permission.\n\nHEWLETT-PACKARD MAKES NO WARRANTY OF ANY KIND WITH REGARD\nTO THIS SOFWARE, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED \nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR \nPURPOSE.  Hewlett-Packard shall not be liable for errors \ncontained herein or direct, indirect, special, incidental or \nconsequential damages in connection with the furnishing, \nperformance, or use of this material.\n\nThis software is not subject to any license of the American\nTelephone and Telegraph Company or of the Regents of the\nUniversity of California.\n******************************************************************/\n\n#define apXK_LineDel            0x1000FF00\n#define apXK_CharDel            0x1000FF01\n#define apXK_Copy               0x1000FF02\n#define apXK_Cut                0x1000FF03\n#define apXK_Paste              0x1000FF04\n#define apXK_Move               0x1000FF05\n#define apXK_Grow               0x1000FF06\n#define apXK_Cmd                0x1000FF07\n#define apXK_Shell              0x1000FF08\n#define apXK_LeftBar            0x1000FF09\n#define apXK_RightBar           0x1000FF0A\n#define apXK_LeftBox            0x1000FF0B\n#define apXK_RightBox           0x1000FF0C\n#define apXK_UpBox              0x1000FF0D\n#define apXK_DownBox            0x1000FF0E\n#define apXK_Pop                0x1000FF0F\n#define apXK_Read               0x1000FF10\n#define apXK_Edit               0x1000FF11\n#define apXK_Save               0x1000FF12\n#define apXK_Exit               0x1000FF13\n#define apXK_Repeat             0x1000FF14\n\n#define apXK_KP_parenleft       0x1000FFA8\n#define apXK_KP_parenright      0x1000FFA9\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/X11/bitmaps/xm_error",
    "content": "/* $XConsortium: xm_error /main/5 1995/07/17 10:31:41 drk $ */\n/*\n * Motif\n *\n * Copyright (c) 1987-2012, The Open Group. All rights reserved.\n *\n * These libraries and programs are free software; you can\n * redistribute them and/or modify them under the terms of the GNU\n * Lesser General Public License as published by the Free Software\n * Foundation; either version 2 of the License, or (at your option)\n * any later version.\n *\n * These libraries and programs are distributed in the hope that\n * they will be useful, but WITHOUT ANY WARRANTY; without even the\n * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR\n * PURPOSE. See the GNU Lesser General Public License for more\n * details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with these librararies and programs; if not, write\n * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth\n * Floor, Boston, MA 02110-1301 USA\n*/\n/*\n * HISTORY\n*/\n#define xm_error_width 20\n#define xm_error_height 20\nstatic char xm_error_bits[] = {\n   0x00, 0x00, 0x00, 0xc0, 0x0f, 0x00, 0xf0, 0x3a, 0x00, 0x58, 0x55, 0x00,\n   0x2c, 0xa0, 0x00, 0x56, 0x40, 0x01, 0xaa, 0x80, 0x02, 0x46, 0x81, 0x01,\n   0x8a, 0x82, 0x02, 0x06, 0x85, 0x01, 0x0a, 0x8a, 0x02, 0x06, 0x94, 0x01,\n   0x0a, 0xe8, 0x02, 0x14, 0x50, 0x01, 0x28, 0xb0, 0x00, 0xd0, 0x5f, 0x00,\n   0xa0, 0x2a, 0x00, 0x40, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/X11/bitmaps/xm_hour16",
    "content": "/* $XConsortium: xm_hour16 /main/5 1995/07/17 10:31:48 drk $ */\n/*\n * Motif\n *\n * Copyright (c) 1987-2012, The Open Group. All rights reserved.\n *\n * These libraries and programs are free software; you can\n * redistribute them and/or modify them under the terms of the GNU\n * Lesser General Public License as published by the Free Software\n * Foundation; either version 2 of the License, or (at your option)\n * any later version.\n *\n * These libraries and programs are distributed in the hope that\n * they will be useful, but WITHOUT ANY WARRANTY; without even the\n * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR\n * PURPOSE. See the GNU Lesser General Public License for more\n * details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with these librararies and programs; if not, write\n * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth\n * Floor, Boston, MA 02110-1301 USA\n*/\n/*\n * HISTORY\n*/\n#define hour16_x_hot 7\n#define hour16_y_hot 7\n#define hour16_width 16\n#define hour16_height 16\nstatic char hour16_bits[] = {\n   0x00, 0x00, 0xfe, 0x7f, 0x14, 0x28, 0x14, 0x28, 0x14, 0x28, 0x24, 0x24,\n   0x44, 0x22, 0x84, 0x21, 0x84, 0x21, 0x44, 0x22, 0x24, 0x24, 0x14, 0x28,\n   0x94, 0x29, 0xd4, 0x2b, 0xfe, 0x7f, 0x00, 0x00};\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/X11/bitmaps/xm_hour16m",
    "content": "/* $XConsortium: xm_hour16m /main/5 1995/07/17 10:31:55 drk $ */\n/*\n * Motif\n *\n * Copyright (c) 1987-2012, The Open Group. All rights reserved.\n *\n * These libraries and programs are free software; you can\n * redistribute them and/or modify them under the terms of the GNU\n * Lesser General Public License as published by the Free Software\n * Foundation; either version 2 of the License, or (at your option)\n * any later version.\n *\n * These libraries and programs are distributed in the hope that\n * they will be useful, but WITHOUT ANY WARRANTY; without even the\n * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR\n * PURPOSE. See the GNU Lesser General Public License for more\n * details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with these librararies and programs; if not, write\n * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth\n * Floor, Boston, MA 02110-1301 USA\n*/\n/*\n * HISTORY\n*/\n#define hour16m_width 16\n#define hour16m_height 16\nstatic char hour16m_bits[] = {\n   0xff, 0xff, 0xff, 0xff, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f,\n   0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f,\n   0xfe, 0x7f, 0xfe, 0x7f, 0xff, 0xff, 0xff, 0xff};\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/X11/bitmaps/xm_hour32",
    "content": "/* $XConsortium: xm_hour32 /main/5 1995/07/17 10:32:03 drk $ */\n/*\n * Motif\n *\n * Copyright (c) 1987-2012, The Open Group. All rights reserved.\n *\n * These libraries and programs are free software; you can\n * redistribute them and/or modify them under the terms of the GNU\n * Lesser General Public License as published by the Free Software\n * Foundation; either version 2 of the License, or (at your option)\n * any later version.\n *\n * These libraries and programs are distributed in the hope that\n * they will be useful, but WITHOUT ANY WARRANTY; without even the\n * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR\n * PURPOSE. See the GNU Lesser General Public License for more\n * details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with these librararies and programs; if not, write\n * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth\n * Floor, Boston, MA 02110-1301 USA\n*/\n/*\n * HISTORY\n*/\n#define hour32_width 32\n#define hour32_height 32\n#define hour32_x_hot 15\n#define hour32_y_hot 15\nstatic char hour32_bits[] = {\n   0x00, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xff, 0x7f, 0xfe, 0xff, 0xff, 0x7f,\n   0x8c, 0x00, 0x00, 0x31, 0x4c, 0x00, 0x00, 0x32, 0x4c, 0x00, 0x00, 0x32,\n   0x4c, 0x00, 0x00, 0x32, 0x4c, 0x00, 0x00, 0x32, 0x4c, 0x00, 0x00, 0x32,\n   0x8c, 0x00, 0x00, 0x31, 0x0c, 0x7f, 0xfe, 0x30, 0x0c, 0xfe, 0x7f, 0x30,\n   0x0c, 0xfc, 0x3f, 0x30, 0x0c, 0xf8, 0x1f, 0x30, 0x0c, 0xe0, 0x07, 0x30,\n   0x0c, 0x80, 0x01, 0x30, 0x0c, 0x80, 0x01, 0x30, 0x0c, 0x60, 0x06, 0x30,\n   0x0c, 0x18, 0x18, 0x30, 0x0c, 0x04, 0x20, 0x30, 0x0c, 0x02, 0x40, 0x30,\n   0x0c, 0x01, 0x80, 0x30, 0x8c, 0x00, 0x00, 0x31, 0x4c, 0x80, 0x01, 0x32,\n   0x4c, 0xc0, 0x03, 0x32, 0x4c, 0xf0, 0x1f, 0x32, 0x4c, 0xff, 0xff, 0x32,\n   0xcc, 0xff, 0xff, 0x33, 0x8c, 0xff, 0xff, 0x31, 0xfe, 0xff, 0xff, 0x7f,\n   0xfe, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00};\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/X11/bitmaps/xm_hour32m",
    "content": "/* $XConsortium: xm_hour32m /main/5 1995/07/17 10:32:11 drk $ */\n/*\n * Motif\n *\n * Copyright (c) 1987-2012, The Open Group. All rights reserved.\n *\n * These libraries and programs are free software; you can\n * redistribute them and/or modify them under the terms of the GNU\n * Lesser General Public License as published by the Free Software\n * Foundation; either version 2 of the License, or (at your option)\n * any later version.\n *\n * These libraries and programs are distributed in the hope that\n * they will be useful, but WITHOUT ANY WARRANTY; without even the\n * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR\n * PURPOSE. See the GNU Lesser General Public License for more\n * details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with these librararies and programs; if not, write\n * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth\n * Floor, Boston, MA 02110-1301 USA\n*/\n/*\n * HISTORY\n*/\n#define hour32m_width 32\n#define hour32m_height 32\nstatic char hour32m_bits[] = {\n   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,\n   0xcf, 0x00, 0x00, 0xf3, 0x6e, 0x00, 0x00, 0x76, 0x6e, 0x00, 0x00, 0x76,\n   0x6e, 0x00, 0x00, 0x76, 0x6e, 0x00, 0x00, 0x76, 0x6e, 0x00, 0x00, 0x76,\n   0xce, 0x00, 0x00, 0x73, 0x8e, 0x7f, 0xfe, 0x71, 0x0e, 0xff, 0xff, 0x70,\n   0x0e, 0xfe, 0x7f, 0x70, 0x0e, 0xfc, 0x3f, 0x70, 0x0e, 0xf8, 0x1f, 0x70,\n   0x0e, 0xe0, 0x07, 0x70, 0x0e, 0xe0, 0x07, 0x70, 0x0e, 0x78, 0x1e, 0x70,\n   0x0e, 0x1c, 0x38, 0x70, 0x0e, 0x06, 0x60, 0x70, 0x0e, 0x03, 0xc0, 0x70,\n   0x8e, 0x01, 0x80, 0x71, 0xce, 0x00, 0x00, 0x73, 0x6e, 0x80, 0x01, 0x76,\n   0x6e, 0xc0, 0x03, 0x76, 0x6e, 0xf0, 0x1f, 0x76, 0x6e, 0xff, 0xff, 0x76,\n   0xee, 0xff, 0xff, 0x77, 0xcf, 0xff, 0xff, 0xf3, 0xff, 0xff, 0xff, 0xff,\n   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/X11/bitmaps/xm_information",
    "content": "/* $XConsortium: xm_information /main/5 1995/07/17 10:32:20 drk $ */\n/*\n * Motif\n *\n * Copyright (c) 1987-2012, The Open Group. All rights reserved.\n *\n * These libraries and programs are free software; you can\n * redistribute them and/or modify them under the terms of the GNU\n * Lesser General Public License as published by the Free Software\n * Foundation; either version 2 of the License, or (at your option)\n * any later version.\n *\n * These libraries and programs are distributed in the hope that\n * they will be useful, but WITHOUT ANY WARRANTY; without even the\n * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR\n * PURPOSE. See the GNU Lesser General Public License for more\n * details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with these librararies and programs; if not, write\n * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth\n * Floor, Boston, MA 02110-1301 USA\n*/\n/*\n * HISTORY\n*/\n#define xm_information_width 11\n#define xm_information_height 24\nstatic char xm_information_bits[] = {\n   0x00, 0x00, 0x78, 0x00, 0x54, 0x00, 0x2c, 0x00, 0x54, 0x00, 0x28, 0x00,\n   0x00, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x2a, 0x00, 0x5c, 0x00, 0x28, 0x00,\n   0x58, 0x00, 0x28, 0x00, 0x58, 0x00, 0x28, 0x00, 0x58, 0x00, 0x28, 0x00,\n   0x58, 0x00, 0xae, 0x01, 0x56, 0x01, 0xaa, 0x00, 0x00, 0x00, 0x00, 0x00};\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/X11/bitmaps/xm_noenter16",
    "content": "/* $XConsortium: xm_noenter16 /main/5 1995/07/17 10:32:28 drk $ */\n/*\n * Motif\n *\n * Copyright (c) 1987-2012, The Open Group. All rights reserved.\n *\n * These libraries and programs are free software; you can\n * redistribute them and/or modify them under the terms of the GNU\n * Lesser General Public License as published by the Free Software\n * Foundation; either version 2 of the License, or (at your option)\n * any later version.\n *\n * These libraries and programs are distributed in the hope that\n * they will be useful, but WITHOUT ANY WARRANTY; without even the\n * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR\n * PURPOSE. See the GNU Lesser General Public License for more\n * details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with these librararies and programs; if not, write\n * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth\n * Floor, Boston, MA 02110-1301 USA\n*/\n/*\n * HISTORY\n*/\n#define noenter16_width 16\n#define noenter16_height 16\n#define noenter16_x_hot 7\n#define noenter16_y_hot 7\nstatic char noenter16_bits[] = {\n   0x00, 0x00, 0xc0, 0x03, 0xf0, 0x0f, 0xf8, 0x1f, 0xfc, 0x3f, 0xfc, 0x3f,\n   0xfe, 0x7f, 0x02, 0x40, 0x02, 0x40, 0xfe, 0x7f, 0xfc, 0x3f, 0xfc, 0x3f,\n   0xf8, 0x1f, 0xf0, 0x0f, 0xc0, 0x03, 0x00, 0x00};\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/X11/bitmaps/xm_noenter16m",
    "content": "/* $XConsortium: xm_noenter16m /main/5 1995/07/17 10:32:37 drk $ */\n/*\n * Motif\n *\n * Copyright (c) 1987-2012, The Open Group. All rights reserved.\n *\n * These libraries and programs are free software; you can\n * redistribute them and/or modify them under the terms of the GNU\n * Lesser General Public License as published by the Free Software\n * Foundation; either version 2 of the License, or (at your option)\n * any later version.\n *\n * These libraries and programs are distributed in the hope that\n * they will be useful, but WITHOUT ANY WARRANTY; without even the\n * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR\n * PURPOSE. See the GNU Lesser General Public License for more\n * details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with these librararies and programs; if not, write\n * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth\n * Floor, Boston, MA 02110-1301 USA\n*/\n/*\n * HISTORY\n*/\n#define noenter16m_width 16\n#define noenter16m_height 16\nstatic char noenter16m_bits[] = {\n   0xc0, 0x03, 0xf0, 0x0f, 0xf8, 0x1f, 0xfc, 0x3f, 0xfe, 0x7f, 0xfe, 0x7f,\n   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x7f, 0xfe, 0x7f,\n   0xfc, 0x3f, 0xf8, 0x1f, 0xf0, 0x0f, 0xc0, 0x03};\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/X11/bitmaps/xm_noenter32",
    "content": "/* $XConsortium: xm_noenter32 /main/5 1995/07/17 10:32:46 drk $ */\n/*\n * Motif\n *\n * Copyright (c) 1987-2012, The Open Group. All rights reserved.\n *\n * These libraries and programs are free software; you can\n * redistribute them and/or modify them under the terms of the GNU\n * Lesser General Public License as published by the Free Software\n * Foundation; either version 2 of the License, or (at your option)\n * any later version.\n *\n * These libraries and programs are distributed in the hope that\n * they will be useful, but WITHOUT ANY WARRANTY; without even the\n * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR\n * PURPOSE. See the GNU Lesser General Public License for more\n * details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with these librararies and programs; if not, write\n * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth\n * Floor, Boston, MA 02110-1301 USA\n*/\n/*\n * HISTORY\n*/\n#define noenter32_width 32\n#define noenter32_height 32\n#define noenter32_x_hot 15\n#define noenter32_y_hot 15\nstatic char noenter32_bits[] = {\n   0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xfc, 0x3f, 0x00,\n   0x00, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x01, 0xc0, 0xff, 0xff, 0x03,\n   0xe0, 0xff, 0xff, 0x07, 0xf0, 0xff, 0xff, 0x0f, 0xf8, 0xff, 0xff, 0x1f,\n   0xf8, 0xff, 0xff, 0x1f, 0xfc, 0xff, 0xff, 0x3f, 0xfc, 0xff, 0xff, 0x3f,\n   0xfc, 0xff, 0xff, 0x3f, 0x06, 0x00, 0x00, 0x60, 0x06, 0x00, 0x00, 0x60,\n   0x06, 0x00, 0x00, 0x60, 0x06, 0x00, 0x00, 0x60, 0x06, 0x00, 0x00, 0x60,\n   0x06, 0x00, 0x00, 0x60, 0xfc, 0xff, 0xff, 0x3f, 0xfc, 0xff, 0xff, 0x3f,\n   0xfc, 0xff, 0xff, 0x3f, 0xf8, 0xff, 0xff, 0x1f, 0xf8, 0xff, 0xff, 0x1f,\n   0xf0, 0xff, 0xff, 0x0f, 0xe0, 0xff, 0xff, 0x07, 0xc0, 0xff, 0xff, 0x03,\n   0x80, 0xff, 0xff, 0x01, 0x00, 0xff, 0xff, 0x00, 0x00, 0xfc, 0x3f, 0x00,\n   0x00, 0xe0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00};\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/X11/bitmaps/xm_noenter32m",
    "content": "/* $XConsortium: xm_noenter32m /main/5 1995/07/17 10:32:56 drk $ */\n/*\n * Motif\n *\n * Copyright (c) 1987-2012, The Open Group. All rights reserved.\n *\n * These libraries and programs are free software; you can\n * redistribute them and/or modify them under the terms of the GNU\n * Lesser General Public License as published by the Free Software\n * Foundation; either version 2 of the License, or (at your option)\n * any later version.\n *\n * These libraries and programs are distributed in the hope that\n * they will be useful, but WITHOUT ANY WARRANTY; without even the\n * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR\n * PURPOSE. See the GNU Lesser General Public License for more\n * details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with these librararies and programs; if not, write\n * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth\n * Floor, Boston, MA 02110-1301 USA\n*/\n/*\n * HISTORY\n*/\n#define noenter32m_width 32\n#define noenter32m_height 32\nstatic char noenter32m_bits[] = {\n   0x00, 0xe0, 0x07, 0x00, 0x00, 0xfc, 0x3f, 0x00, 0x00, 0xff, 0xff, 0x00,\n   0x80, 0xff, 0xff, 0x01, 0xc0, 0xff, 0xff, 0x03, 0xe0, 0xff, 0xff, 0x07,\n   0xf0, 0xff, 0xff, 0x0f, 0xf8, 0xff, 0xff, 0x1f, 0xfc, 0xff, 0xff, 0x3f,\n   0xfc, 0xff, 0xff, 0x3f, 0xfe, 0xff, 0xff, 0x7f, 0xfe, 0xff, 0xff, 0x7f,\n   0xfe, 0xff, 0xff, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,\n   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,\n   0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0x7f, 0xfe, 0xff, 0xff, 0x7f,\n   0xfe, 0xff, 0xff, 0x7f, 0xfc, 0xff, 0xff, 0x3f, 0xfc, 0xff, 0xff, 0x3f,\n   0xf8, 0xff, 0xff, 0x1f, 0xf0, 0xff, 0xff, 0x0f, 0xe0, 0xff, 0xff, 0x07,\n   0xc0, 0xff, 0xff, 0x03, 0x80, 0xff, 0xff, 0x01, 0x00, 0xff, 0xff, 0x00,\n   0x00, 0xfc, 0x3f, 0x00, 0x00, 0xe0, 0x07, 0x00};\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/X11/bitmaps/xm_question",
    "content": "/* $XConsortium: xm_question /main/5 1995/07/17 10:33:09 drk $ */\n/*\n * Motif\n *\n * Copyright (c) 1987-2012, The Open Group. All rights reserved.\n *\n * These libraries and programs are free software; you can\n * redistribute them and/or modify them under the terms of the GNU\n * Lesser General Public License as published by the Free Software\n * Foundation; either version 2 of the License, or (at your option)\n * any later version.\n *\n * These libraries and programs are distributed in the hope that\n * they will be useful, but WITHOUT ANY WARRANTY; without even the\n * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR\n * PURPOSE. See the GNU Lesser General Public License for more\n * details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with these librararies and programs; if not, write\n * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth\n * Floor, Boston, MA 02110-1301 USA\n*/\n/*\n * HISTORY\n*/\n#define xm_question_width 22\n#define xm_question_height 22\nstatic char xm_question_bits[] = {\n   0xf0, 0x3f, 0x00, 0x58, 0x55, 0x00, 0xac, 0xaa, 0x00, 0xd6, 0x5f, 0x01,\n   0xea, 0xbf, 0x02, 0xf6, 0x7f, 0x01, 0xea, 0xba, 0x02, 0xf6, 0x7d, 0x05,\n   0xea, 0xba, 0x0a, 0x56, 0x7d, 0x15, 0xaa, 0xbe, 0x1e, 0x56, 0x5f, 0x01,\n   0xac, 0xaf, 0x02, 0x58, 0x57, 0x01, 0xb0, 0xaf, 0x00, 0x60, 0x55, 0x01,\n   0xa0, 0xaa, 0x00, 0x60, 0x17, 0x00, 0xa0, 0x2f, 0x00, 0x60, 0x17, 0x00,\n   0xb0, 0x2a, 0x00, 0x50, 0x55, 0x00};\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/X11/bitmaps/xm_warning",
    "content": "/* $XConsortium: xm_warning /main/5 1995/07/17 10:33:17 drk $ */\n/*\n * Motif\n *\n * Copyright (c) 1987-2012, The Open Group. All rights reserved.\n *\n * These libraries and programs are free software; you can\n * redistribute them and/or modify them under the terms of the GNU\n * Lesser General Public License as published by the Free Software\n * Foundation; either version 2 of the License, or (at your option)\n * any later version.\n *\n * These libraries and programs are distributed in the hope that\n * they will be useful, but WITHOUT ANY WARRANTY; without even the\n * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR\n * PURPOSE. See the GNU Lesser General Public License for more\n * details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with these librararies and programs; if not, write\n * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth\n * Floor, Boston, MA 02110-1301 USA\n*/\n/*\n * HISTORY\n*/\n#define xm_warning_width 9\n#define xm_warning_height 22\nstatic char xm_warning_bits[] = {\n   0x00, 0x00, 0x18, 0x00, 0x2c, 0x00, 0x56, 0x00, 0x2a, 0x00, 0x56, 0x00,\n   0x2a, 0x00, 0x56, 0x00, 0x2c, 0x00, 0x14, 0x00, 0x2c, 0x00, 0x14, 0x00,\n   0x2c, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x14, 0x00,\n   0x2c, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00};\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/X11/bitmaps/xm_working",
    "content": "/* $XConsortium: xm_working /main/5 1995/07/17 10:33:26 drk $ */\n/*\n * Motif\n *\n * Copyright (c) 1987-2012, The Open Group. All rights reserved.\n *\n * These libraries and programs are free software; you can\n * redistribute them and/or modify them under the terms of the GNU\n * Lesser General Public License as published by the Free Software\n * Foundation; either version 2 of the License, or (at your option)\n * any later version.\n *\n * These libraries and programs are distributed in the hope that\n * they will be useful, but WITHOUT ANY WARRANTY; without even the\n * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR\n * PURPOSE. See the GNU Lesser General Public License for more\n * details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with these librararies and programs; if not, write\n * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth\n * Floor, Boston, MA 02110-1301 USA\n*/\n/*\n * HISTORY\n*/\n#define xm_working_width 21\n#define xm_working_height 23\nstatic char xm_working_bits[] = {\n   0x00, 0x00, 0x00, 0xfe, 0xff, 0x0f, 0xaa, 0xaa, 0x0a, 0x44, 0x55, 0x06,\n   0xcc, 0x2a, 0x02, 0x44, 0x55, 0x06, 0xcc, 0x2a, 0x02, 0x84, 0x15, 0x06,\n   0x8c, 0x2a, 0x02, 0x04, 0x15, 0x06, 0x0c, 0x0a, 0x02, 0x04, 0x06, 0x06,\n   0x0c, 0x0b, 0x02, 0x84, 0x15, 0x06, 0xcc, 0x2a, 0x02, 0x44, 0x55, 0x06,\n   0xcc, 0x2a, 0x02, 0x44, 0x55, 0x06, 0xcc, 0x2a, 0x02, 0x44, 0x55, 0x06,\n   0xfe, 0xff, 0x0f, 0x56, 0x55, 0x05, 0x00, 0x00, 0x00};\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/X11/cursorfont.h",
    "content": "/*\n\nCopyright 1987, 1998  The Open Group\n\nPermission to use, copy, modify, distribute, and sell this software and its\ndocumentation for any purpose is hereby granted without fee, provided that\nthe above copyright notice appear in all copies and that both that\ncopyright notice and this permission notice appear in supporting\ndocumentation.\n\nThe above copyright notice and this permission notice shall be included\nin all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\nOR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR\nOTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,\nARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\nOTHER DEALINGS IN THE SOFTWARE.\n\nExcept as contained in this notice, the name of The Open Group shall\nnot be used in advertising or otherwise to promote the sale, use or\nother dealings in this Software without prior written authorization\nfrom The Open Group.\n\n*/\n\n#ifndef _X11_CURSORFONT_H_\n#define _X11_CURSORFONT_H_\n\n#define XC_num_glyphs 154\n#define XC_X_cursor 0\n#define XC_arrow 2\n#define XC_based_arrow_down 4\n#define XC_based_arrow_up 6\n#define XC_boat 8\n#define XC_bogosity 10\n#define XC_bottom_left_corner 12\n#define XC_bottom_right_corner 14\n#define XC_bottom_side 16\n#define XC_bottom_tee 18\n#define XC_box_spiral 20\n#define XC_center_ptr 22\n#define XC_circle 24\n#define XC_clock 26\n#define XC_coffee_mug 28\n#define XC_cross 30\n#define XC_cross_reverse 32\n#define XC_crosshair 34\n#define XC_diamond_cross 36\n#define XC_dot 38\n#define XC_dotbox 40\n#define XC_double_arrow 42\n#define XC_draft_large 44\n#define XC_draft_small 46\n#define XC_draped_box 48\n#define XC_exchange 50\n#define XC_fleur 52\n#define XC_gobbler 54\n#define XC_gumby 56\n#define XC_hand1 58\n#define XC_hand2 60\n#define XC_heart 62\n#define XC_icon 64\n#define XC_iron_cross 66\n#define XC_left_ptr 68\n#define XC_left_side 70\n#define XC_left_tee 72\n#define XC_leftbutton 74\n#define XC_ll_angle 76\n#define XC_lr_angle 78\n#define XC_man 80\n#define XC_middlebutton 82\n#define XC_mouse 84\n#define XC_pencil 86\n#define XC_pirate 88\n#define XC_plus 90\n#define XC_question_arrow 92\n#define XC_right_ptr 94\n#define XC_right_side 96\n#define XC_right_tee 98\n#define XC_rightbutton 100\n#define XC_rtl_logo 102\n#define XC_sailboat 104\n#define XC_sb_down_arrow 106\n#define XC_sb_h_double_arrow 108\n#define XC_sb_left_arrow 110\n#define XC_sb_right_arrow 112\n#define XC_sb_up_arrow 114\n#define XC_sb_v_double_arrow 116\n#define XC_shuttle 118\n#define XC_sizing 120\n#define XC_spider 122\n#define XC_spraycan 124\n#define XC_star 126\n#define XC_target 128\n#define XC_tcross 130\n#define XC_top_left_arrow 132\n#define XC_top_left_corner 134\n#define XC_top_right_corner 136\n#define XC_top_side 138\n#define XC_top_tee 140\n#define XC_trek 142\n#define XC_ul_angle 144\n#define XC_umbrella 146\n#define XC_ur_angle 148\n#define XC_watch 150\n#define XC_xterm 152\n\n#endif /* _X11_CURSORFONT_H_ */\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/X11/extensions/XI.h",
    "content": "/************************************************************\n\nCopyright 1989, 1998  The Open Group\n\nPermission to use, copy, modify, distribute, and sell this software and its\ndocumentation for any purpose is hereby granted without fee, provided that\nthe above copyright notice appear in all copies and that both that\ncopyright notice and this permission notice appear in supporting\ndocumentation.\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE\nOPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN\nAN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\nCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\nExcept as contained in this notice, the name of The Open Group shall not be\nused in advertising or otherwise to promote the sale, use or other dealings\nin this Software without prior written authorization from The Open Group.\n\nCopyright 1989 by Hewlett-Packard Company, Palo Alto, California.\n\n\t\t\tAll Rights Reserved\n\nPermission to use, copy, modify, and distribute this software and its\ndocumentation for any purpose and without fee is hereby granted,\nprovided that the above copyright notice appear in all copies and that\nboth that copyright notice and this permission notice appear in\nsupporting documentation, and that the name of Hewlett-Packard not be\nused in advertising or publicity pertaining to distribution of the\nsoftware without specific, written prior permission.\n\nHEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING\nALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL\nHEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR\nANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,\nWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,\nARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS\nSOFTWARE.\n\n********************************************************/\n\n/* Definitions used by the server, library and client */\n\n#ifndef _XI_H_\n#define _XI_H_\n\n#define sz_xGetExtensionVersionReq             8\n#define sz_xGetExtensionVersionReply           32\n#define sz_xListInputDevicesReq\t\t\t4\n#define sz_xListInputDevicesReply\t\t32\n#define sz_xOpenDeviceReq\t\t\t8\n#define sz_xOpenDeviceReply\t\t\t32\n#define sz_xCloseDeviceReq\t\t\t8\n#define sz_xSetDeviceModeReq\t\t\t8\n#define sz_xSetDeviceModeReply\t\t\t32\n#define sz_xSelectExtensionEventReq\t\t12\n#define sz_xGetSelectedExtensionEventsReq\t8\n#define sz_xGetSelectedExtensionEventsReply\t32\n#define sz_xChangeDeviceDontPropagateListReq\t12\n#define sz_xGetDeviceDontPropagateListReq\t8\n#define sz_xGetDeviceDontPropagateListReply\t32\n#define sz_xGetDeviceMotionEventsReq\t\t16\n#define sz_xGetDeviceMotionEventsReply\t\t32\n#define sz_xChangeKeyboardDeviceReq\t\t8\n#define sz_xChangeKeyboardDeviceReply\t\t32\n#define sz_xChangePointerDeviceReq\t\t8\n#define sz_xChangePointerDeviceReply\t\t32\n#define sz_xGrabDeviceReq\t\t\t20\n#define sz_xGrabDeviceReply\t\t\t32\n#define sz_xUngrabDeviceReq\t\t\t12\n#define sz_xGrabDeviceKeyReq\t\t\t20\n#define sz_xGrabDeviceKeyReply\t\t\t32\n#define sz_xUngrabDeviceKeyReq\t\t\t16\n#define sz_xGrabDeviceButtonReq\t\t\t20\n#define sz_xGrabDeviceButtonReply\t\t32\n#define sz_xUngrabDeviceButtonReq\t\t16\n#define sz_xAllowDeviceEventsReq\t\t12\n#define sz_xGetDeviceFocusReq\t\t\t8\n#define sz_xGetDeviceFocusReply\t\t\t32\n#define sz_xSetDeviceFocusReq\t\t\t16\n#define sz_xGetFeedbackControlReq\t\t8\n#define sz_xGetFeedbackControlReply\t\t32\n#define sz_xChangeFeedbackControlReq\t\t12\n#define sz_xGetDeviceKeyMappingReq\t\t8\n#define sz_xGetDeviceKeyMappingReply\t\t32\n#define sz_xChangeDeviceKeyMappingReq\t\t8\n#define sz_xGetDeviceModifierMappingReq\t\t8\n#define sz_xSetDeviceModifierMappingReq\t\t8\n#define sz_xSetDeviceModifierMappingReply\t32\n#define sz_xGetDeviceButtonMappingReq\t\t8\n#define sz_xGetDeviceButtonMappingReply\t\t32\n#define sz_xSetDeviceButtonMappingReq\t\t8\n#define sz_xSetDeviceButtonMappingReply\t\t32\n#define sz_xQueryDeviceStateReq\t\t\t8\n#define sz_xQueryDeviceStateReply\t\t32\n#define sz_xSendExtensionEventReq\t\t16\n#define sz_xDeviceBellReq\t\t\t8\n#define sz_xSetDeviceValuatorsReq\t\t8\n#define sz_xSetDeviceValuatorsReply\t\t32\n#define sz_xGetDeviceControlReq\t\t\t8\n#define sz_xGetDeviceControlReply\t\t32\n#define sz_xChangeDeviceControlReq\t\t8\n#define sz_xChangeDeviceControlReply\t\t32\n#define sz_xListDevicePropertiesReq             8\n#define sz_xListDevicePropertiesReply           32\n#define sz_xChangeDevicePropertyReq             20\n#define sz_xDeleteDevicePropertyReq             12\n#define sz_xGetDevicePropertyReq                24\n#define sz_xGetDevicePropertyReply              32\n\n#define INAME\t\t\"XInputExtension\"\n\n#define XI_KEYBOARD\t\"KEYBOARD\"\n#define XI_MOUSE\t\"MOUSE\"\n#define XI_TABLET\t\"TABLET\"\n#define XI_TOUCHSCREEN\t\"TOUCHSCREEN\"\n#define XI_TOUCHPAD\t\"TOUCHPAD\"\n#define XI_BARCODE\t\"BARCODE\"\n#define XI_BUTTONBOX\t\"BUTTONBOX\"\n#define XI_KNOB_BOX\t\"KNOB_BOX\"\n#define XI_ONE_KNOB\t\"ONE_KNOB\"\n#define XI_NINE_KNOB\t\"NINE_KNOB\"\n#define XI_TRACKBALL\t\"TRACKBALL\"\n#define XI_QUADRATURE\t\"QUADRATURE\"\n#define XI_ID_MODULE\t\"ID_MODULE\"\n#define XI_SPACEBALL\t\"SPACEBALL\"\n#define XI_DATAGLOVE\t\"DATAGLOVE\"\n#define XI_EYETRACKER\t\"EYETRACKER\"\n#define XI_CURSORKEYS\t\"CURSORKEYS\"\n#define XI_FOOTMOUSE\t\"FOOTMOUSE\"\n#define XI_JOYSTICK\t\"JOYSTICK\"\n\n/* Indices into the versions[] array (XExtInt.c). Used as a index to\n * retrieve the minimum version of XI from _XiCheckExtInit */\n#define Dont_Check\t\t\t0\n#define XInput_Initial_Release\t\t1\n#define XInput_Add_XDeviceBell\t\t2\n#define XInput_Add_XSetDeviceValuators\t3\n#define XInput_Add_XChangeDeviceControl\t4\n#define XInput_Add_DevicePresenceNotify\t5\n#define XInput_Add_DeviceProperties\t6\n/* DO NOT ADD TO HERE -> XI2 */\n\n#define XI_Absent\t\t0\n#define XI_Present\t\t1\n\n#define XI_Initial_Release_Major\t\t1\n#define XI_Initial_Release_Minor\t\t0\n\n#define XI_Add_XDeviceBell_Major\t\t1\n#define XI_Add_XDeviceBell_Minor\t\t1\n\n#define XI_Add_XSetDeviceValuators_Major\t1\n#define XI_Add_XSetDeviceValuators_Minor\t2\n\n#define XI_Add_XChangeDeviceControl_Major\t1\n#define XI_Add_XChangeDeviceControl_Minor\t3\n\n#define XI_Add_DevicePresenceNotify_Major\t1\n#define XI_Add_DevicePresenceNotify_Minor\t4\n\n#define XI_Add_DeviceProperties_Major\t\t1\n#define XI_Add_DeviceProperties_Minor\t\t5\n\n#define DEVICE_RESOLUTION\t1\n#define DEVICE_ABS_CALIB        2\n#define DEVICE_CORE             3\n#define DEVICE_ENABLE           4\n#define DEVICE_ABS_AREA         5\n\n#define NoSuchExtension\t\t1\n\n#define COUNT\t\t\t0\n#define CREATE\t\t\t1\n\n#define NewPointer\t\t0\n#define NewKeyboard\t\t1\n\n#define XPOINTER\t\t0\n#define XKEYBOARD\t\t1\n\n#define UseXKeyboard\t\t0xFF\n\n#define IsXPointer\t\t0\n#define IsXKeyboard\t\t1\n#define IsXExtensionDevice\t2\n#define IsXExtensionKeyboard    3\n#define IsXExtensionPointer     4\n\n#define AsyncThisDevice\t\t0\n#define SyncThisDevice\t\t1\n#define ReplayThisDevice\t2\n#define AsyncOtherDevices\t3\n#define AsyncAll\t\t4\n#define SyncAll\t\t\t5\n\n#define FollowKeyboard \t\t3\n#ifndef RevertToFollowKeyboard\n#define RevertToFollowKeyboard \t3\n#endif\n\n#define DvAccelNum              (1L << 0)\n#define DvAccelDenom            (1L << 1)\n#define DvThreshold             (1L << 2)\n\n#define DvKeyClickPercent\t(1L<<0)\n#define DvPercent\t\t(1L<<1)\n#define DvPitch\t\t\t(1L<<2)\n#define DvDuration\t\t(1L<<3)\n#define DvLed\t\t\t(1L<<4)\n#define DvLedMode\t\t(1L<<5)\n#define DvKey\t\t\t(1L<<6)\n#define DvAutoRepeatMode\t(1L<<7)\n\n#define DvString                (1L << 0)\n\n#define DvInteger               (1L << 0)\n\n#define DeviceMode              (1L << 0)\n#define Relative                0\n#define Absolute                1\n\n#define ProximityState          (1L << 1)\n#define InProximity             (0L << 1)\n#define OutOfProximity          (1L << 1)\n\n#define AddToList               0\n#define DeleteFromList          1\n\n#define KeyClass  \t\t0\n#define ButtonClass  \t\t1\n#define ValuatorClass  \t\t2\n#define FeedbackClass  \t\t3\n#define ProximityClass  \t4\n#define FocusClass  \t\t5\n#define OtherClass  \t\t6\n#define AttachClass             7\n\n#define KbdFeedbackClass  \t0\n#define PtrFeedbackClass  \t1\n#define StringFeedbackClass  \t2\n#define IntegerFeedbackClass  \t3\n#define LedFeedbackClass  \t4\n#define BellFeedbackClass  \t5\n\n#define _devicePointerMotionHint 0\n#define _deviceButton1Motion\t 1\n#define _deviceButton2Motion\t 2\n#define _deviceButton3Motion\t 3\n#define _deviceButton4Motion\t 4\n#define _deviceButton5Motion\t 5\n#define _deviceButtonMotion\t 6\n#define _deviceButtonGrab\t 7\n#define _deviceOwnerGrabButton\t 8\n#define _noExtensionEvent\t 9\n\n#define _devicePresence\t\t 0\n\n#define _deviceEnter             0\n#define _deviceLeave             1\n\n/* Device presence notify states */\n#define DeviceAdded              0\n#define DeviceRemoved            1\n#define DeviceEnabled            2\n#define DeviceDisabled           3\n#define DeviceUnrecoverable      4\n#define DeviceControlChanged     5\n\n/* XI Errors */\n#define XI_BadDevice\t0\n#define XI_BadEvent\t1\n#define XI_BadMode\t2\n#define XI_DeviceBusy\t3\n#define XI_BadClass\t4\n\n/*\n * Make XEventClass be a CARD32 for 64 bit servers.  Don't affect client\n * definition of XEventClass since that would be a library interface change.\n * See the top of X.h for more _XSERVER64 magic.\n *\n * But, don't actually use the CARD32 type.  We can't get it defined here\n * without polluting the namespace.\n */\n#ifdef _XSERVER64\ntypedef\tunsigned int\tXEventClass;\n#else\ntypedef\tunsigned long\tXEventClass;\n#endif\n\n/*******************************************************************\n *\n * Extension version structure.\n *\n */\n\ntypedef struct {\n        int   \tpresent;\n        short\tmajor_version;\n        short\tminor_version;\n} XExtensionVersion;\n\n#endif /* _XI_H_ */\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/X11/extensions/XI2.h",
    "content": "/*\n * Copyright © 2009 Red Hat, Inc.\n *\n * Permission is hereby granted, free of charge, to any person obtaining a\n * copy of this software and associated documentation files (the \"Software\"),\n * to deal in the Software without restriction, including without limitation\n * the rights to use, copy, modify, merge, publish, distribute, sublicense,\n * and/or sell copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice (including the next\n * paragraph) shall be included in all copies or substantial portions of the\n * Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL\n * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n * DEALINGS IN THE SOFTWARE.\n *\n */\n\n#ifndef _XI2_H_\n#define _XI2_H_\n\n#define XInput_2_0                              7\n/* DO NOT ADD TO THIS LIST. These are libXi-specific defines.\n   See commit libXi-1.4.2-21-ge8531dd */\n\n#define XI_2_Major                              2\n#define XI_2_Minor                              3\n\n/* Property event flags */\n#define XIPropertyDeleted                       0\n#define XIPropertyCreated                       1\n#define XIPropertyModified                      2\n\n/* Property modes */\n#define XIPropModeReplace                       0\n#define XIPropModePrepend                       1\n#define XIPropModeAppend                        2\n\n/* Special property type used for XIGetProperty */\n#define XIAnyPropertyType                       0L\n\n/* Enter/Leave and Focus In/Out modes */\n#define XINotifyNormal                          0\n#define XINotifyGrab                            1\n#define XINotifyUngrab                          2\n#define XINotifyWhileGrabbed                    3\n#define XINotifyPassiveGrab                     4\n#define XINotifyPassiveUngrab                   5\n\n/* Enter/Leave and focus In/out detail */\n#define XINotifyAncestor                        0\n#define XINotifyVirtual                         1\n#define XINotifyInferior                        2\n#define XINotifyNonlinear                       3\n#define XINotifyNonlinearVirtual                4\n#define XINotifyPointer                         5\n#define XINotifyPointerRoot                     6\n#define XINotifyDetailNone                      7\n\n/* Grab modes */\n#define XIGrabModeSync                          0\n#define XIGrabModeAsync                         1\n#define XIGrabModeTouch                         2\n\n/* Grab reply status codes */\n#define XIGrabSuccess                           0\n#define XIAlreadyGrabbed                        1\n#define XIGrabInvalidTime                       2\n#define XIGrabNotViewable                       3\n#define XIGrabFrozen                            4\n\n/* Grab owner events values */\n#define XIOwnerEvents                           True\n#define XINoOwnerEvents                         False\n\n/* Passive grab types */\n#define XIGrabtypeButton                        0\n#define XIGrabtypeKeycode                       1\n#define XIGrabtypeEnter                         2\n#define XIGrabtypeFocusIn                       3\n#define XIGrabtypeTouchBegin                    4\n\n/* Passive grab modifier */\n#define XIAnyModifier                           (1U << 31)\n#define XIAnyButton                             0\n#define XIAnyKeycode                            0\n\n/* XIAllowEvents event-modes */\n#define XIAsyncDevice                           0\n#define XISyncDevice                            1\n#define XIReplayDevice                          2\n#define XIAsyncPairedDevice                     3\n#define XIAsyncPair                             4\n#define XISyncPair                              5\n#define XIAcceptTouch                           6\n#define XIRejectTouch                           7\n\n/* DeviceChangedEvent change reasons */\n#define XISlaveSwitch                           1\n#define XIDeviceChange                          2\n\n/* Hierarchy flags */\n#define XIMasterAdded                           (1 << 0)\n#define XIMasterRemoved                         (1 << 1)\n#define XISlaveAdded                            (1 << 2)\n#define XISlaveRemoved                          (1 << 3)\n#define XISlaveAttached                         (1 << 4)\n#define XISlaveDetached                         (1 << 5)\n#define XIDeviceEnabled                         (1 << 6)\n#define XIDeviceDisabled                        (1 << 7)\n\n/* ChangeHierarchy constants */\n#define XIAddMaster                             1\n#define XIRemoveMaster                          2\n#define XIAttachSlave                           3\n#define XIDetachSlave                           4\n\n#define XIAttachToMaster                        1\n#define XIFloating                              2\n\n/* Valuator modes */\n#define XIModeRelative                          0\n#define XIModeAbsolute                          1\n\n/* Device types */\n#define XIMasterPointer                         1\n#define XIMasterKeyboard                        2\n#define XISlavePointer                          3\n#define XISlaveKeyboard                         4\n#define XIFloatingSlave                         5\n\n/* Device classes: classes that are not identical to Xi 1.x classes must be\n * numbered starting from 8. */\n#define XIKeyClass                              0\n#define XIButtonClass                           1\n#define XIValuatorClass                         2\n#define XIScrollClass                           3\n#define XITouchClass                            8\n\n/* Scroll class types */\n#define XIScrollTypeVertical                    1\n#define XIScrollTypeHorizontal                  2\n\n/* Scroll class flags */\n#define XIScrollFlagNoEmulation                 (1 << 0)\n#define XIScrollFlagPreferred                   (1 << 1)\n\n/* Device event flags (common) */\n/* Device event flags (key events only) */\n#define XIKeyRepeat                             (1 << 16)\n/* Device event flags (pointer events only) */\n#define XIPointerEmulated                       (1 << 16)\n/* Device event flags (touch events only) */\n#define XITouchPendingEnd                       (1 << 16)\n#define XITouchEmulatingPointer                 (1 << 17)\n\n/* Barrier event flags */\n#define XIBarrierPointerReleased                (1 << 0)\n#define XIBarrierDeviceIsGrabbed                (1 << 1)\n\n\n/* Touch modes */\n#define XIDirectTouch                           1\n#define XIDependentTouch                        2\n\n/* XI2 event mask macros */\n#define XISetMask(ptr, event)   (((unsigned char*)(ptr))[(event)>>3] |=  (1 << ((event) & 7)))\n#define XIClearMask(ptr, event) (((unsigned char*)(ptr))[(event)>>3] &= ~(1 << ((event) & 7)))\n#define XIMaskIsSet(ptr, event) (((unsigned char*)(ptr))[(event)>>3] &   (1 << ((event) & 7)))\n#define XIMaskLen(event)        (((event) >> 3) + 1)\n\n/* Fake device ID's for event selection */\n#define XIAllDevices                            0\n#define XIAllMasterDevices                      1\n\n/* Event types */\n#define XI_DeviceChanged                 1\n#define XI_KeyPress                      2\n#define XI_KeyRelease                    3\n#define XI_ButtonPress                   4\n#define XI_ButtonRelease                 5\n#define XI_Motion                        6\n#define XI_Enter                         7\n#define XI_Leave                         8\n#define XI_FocusIn                       9\n#define XI_FocusOut                      10\n#define XI_HierarchyChanged              11\n#define XI_PropertyEvent                 12\n#define XI_RawKeyPress                   13\n#define XI_RawKeyRelease                 14\n#define XI_RawButtonPress                15\n#define XI_RawButtonRelease              16\n#define XI_RawMotion                     17\n#define XI_TouchBegin                    18 /* XI 2.2 */\n#define XI_TouchUpdate                   19\n#define XI_TouchEnd                      20\n#define XI_TouchOwnership                21\n#define XI_RawTouchBegin                 22\n#define XI_RawTouchUpdate                23\n#define XI_RawTouchEnd                   24\n#define XI_BarrierHit                    25 /* XI 2.3 */\n#define XI_BarrierLeave                  26\n#define XI_LASTEVENT                     XI_BarrierLeave\n/* NOTE: XI2LASTEVENT in xserver/include/inputstr.h must be the same value\n * as XI_LASTEVENT if the server is supposed to handle masks etc. for this\n * type of event. */\n\n/* Event masks.\n * Note: the protocol spec defines a mask to be of (1 << type). Clients are\n * free to create masks by bitshifting instead of using these defines.\n */\n#define XI_DeviceChangedMask             (1 << XI_DeviceChanged)\n#define XI_KeyPressMask                  (1 << XI_KeyPress)\n#define XI_KeyReleaseMask                (1 << XI_KeyRelease)\n#define XI_ButtonPressMask               (1 << XI_ButtonPress)\n#define XI_ButtonReleaseMask             (1 << XI_ButtonRelease)\n#define XI_MotionMask                    (1 << XI_Motion)\n#define XI_EnterMask                     (1 << XI_Enter)\n#define XI_LeaveMask                     (1 << XI_Leave)\n#define XI_FocusInMask                   (1 << XI_FocusIn)\n#define XI_FocusOutMask                  (1 << XI_FocusOut)\n#define XI_HierarchyChangedMask          (1 << XI_HierarchyChanged)\n#define XI_PropertyEventMask             (1 << XI_PropertyEvent)\n#define XI_RawKeyPressMask               (1 << XI_RawKeyPress)\n#define XI_RawKeyReleaseMask             (1 << XI_RawKeyRelease)\n#define XI_RawButtonPressMask            (1 << XI_RawButtonPress)\n#define XI_RawButtonReleaseMask          (1 << XI_RawButtonRelease)\n#define XI_RawMotionMask                 (1 << XI_RawMotion)\n#define XI_TouchBeginMask                (1 << XI_TouchBegin)\n#define XI_TouchEndMask                  (1 << XI_TouchEnd)\n#define XI_TouchOwnershipChangedMask     (1 << XI_TouchOwnership)\n#define XI_TouchUpdateMask               (1 << XI_TouchUpdate)\n#define XI_RawTouchBeginMask             (1 << XI_RawTouchBegin)\n#define XI_RawTouchEndMask               (1 << XI_RawTouchEnd)\n#define XI_RawTouchUpdateMask            (1 << XI_RawTouchUpdate)\n#define XI_BarrierHitMask                (1 << XI_BarrierHit)\n#define XI_BarrierLeaveMask              (1 << XI_BarrierLeave)\n\n#endif /* _XI2_H_ */\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/X11/extensions/XI2proto.h",
    "content": "/*\n * Copyright © 2009 Red Hat, Inc.\n *\n * Permission is hereby granted, free of charge, to any person obtaining a\n * copy of this software and associated documentation files (the \"Software\"),\n * to deal in the Software without restriction, including without limitation\n * the rights to use, copy, modify, merge, publish, distribute, sublicense,\n * and/or sell copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice (including the next\n * paragraph) shall be included in all copies or substantial portions of the\n * Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL\n * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n * DEALINGS IN THE SOFTWARE.\n *\n */\n\n/* Conventions for this file:\n * Names:\n * structs: always typedef'd, prefixed with xXI, CamelCase\n * struct members: lower_case_with_underscores\n *        Exceptions: reqType, ReqType, repType, RepType, sequenceNumber are\n *        named as such for historical reasons.\n * request opcodes: X_XIRequestName as CamelCase\n * defines: defines used in client applications must go in XI2.h\n *          defines used only in protocol handling: XISOMENAME\n *\n * Data types: unless there is a historical name for a datatype (e.g.\n * Window), use stdint types specifying the size of the datatype.\n * historical data type names must be defined and undefined at the top and\n * end of the file.\n *\n * General:\n * spaces, not tabs.\n * structs specific to a request or reply added before the request\n *      definition. structs used in more than one request, reply or event\n *      appended to the common structs section before the definition of the\n *      first request.\n * members of structs vertically aligned on column 16 if datatypes permit.\n *      otherwise alingned on next available 8n column.\n */\n\n/**\n * Protocol definitions for the XI2 protocol.\n * This file should not be included by clients that merely use XI2, but do not\n * need the wire protocol. Such clients should include XI2.h, or the matching\n * header from the library.\n *\n */\n#ifndef _XI2PROTO_H_\n#define _XI2PROTO_H_\n\n#include <X11/Xproto.h>\n#include <X11/X.h>\n#include <X11/extensions/XI2.h>\n#include <stdint.h>\n\n/* make sure types have right sizes for protocol structures. */\n#define Window  uint32_t\n#define Time    uint32_t\n#define Atom    uint32_t\n#define Cursor  uint32_t\n#define Barrier uint32_t\n\n/**\n * XI2 Request opcodes\n */\n#define X_XIQueryPointer                40\n#define X_XIWarpPointer                 41\n#define X_XIChangeCursor                42\n#define X_XIChangeHierarchy             43\n#define X_XISetClientPointer            44\n#define X_XIGetClientPointer            45\n#define X_XISelectEvents                46\n#define X_XIQueryVersion                47\n#define X_XIQueryDevice                 48\n#define X_XISetFocus                    49\n#define X_XIGetFocus                    50\n#define X_XIGrabDevice                  51\n#define X_XIUngrabDevice                52\n#define X_XIAllowEvents                 53\n#define X_XIPassiveGrabDevice           54\n#define X_XIPassiveUngrabDevice         55\n#define X_XIListProperties              56\n#define X_XIChangeProperty              57\n#define X_XIDeleteProperty              58\n#define X_XIGetProperty                 59\n#define X_XIGetSelectedEvents           60\n#define X_XIBarrierReleasePointer       61\n\n/** Number of XI requests */\n#define XI2REQUESTS (X_XIBarrierReleasePointer - X_XIQueryPointer + 1)\n/** Number of XI2 events */\n#define XI2EVENTS   (XI_LASTEVENT + 1)\n\n/*************************************************************************************\n *                                                                                   *\n *                               COMMON STRUCTS                                      *\n *                                                                                   *\n *************************************************************************************/\n/** Fixed point 16.16 */\ntypedef int32_t FP1616;\n\n/** Fixed point 32.32 */\ntypedef struct {\n    int32_t     integral;\n    uint32_t    frac;\n} FP3232;\n\n/**\n * Struct to describe a device.\n *\n * For a MasterPointer or a MasterKeyboard, 'attachment' specifies the\n * paired master device.\n * For a SlaveKeyboard or SlavePointer, 'attachment' specifies the master\n * device this device is attached to.\n * For a FloatingSlave, 'attachment' is undefined.\n */\ntypedef struct {\n    uint16_t    deviceid;\n    uint16_t    use;            /**< ::XIMasterPointer, ::XIMasterKeyboard,\n                                     ::XISlavePointer, ::XISlaveKeyboard,\n                                     ::XIFloatingSlave */\n    uint16_t    attachment;     /**< Current attachment or pairing.*/\n    uint16_t    num_classes;    /**< Number of classes following this struct. */\n    uint16_t    name_len;       /**< Length of name in bytes. */\n    uint8_t     enabled;        /**< TRUE if device is enabled. */\n    uint8_t     pad;\n} xXIDeviceInfo;\n\n/**\n * Default template for a device class.\n * A device class is equivalent to a device's capabilities. Multiple classes\n * are supported per device.\n */\ntypedef struct {\n    uint16_t    type;           /**< One of *class */\n    uint16_t    length;         /**< Length in 4 byte units */\n    uint16_t    sourceid;       /**< source device for this class */\n    uint16_t    pad;\n} xXIAnyInfo;\n\n/**\n * Denotes button capability on a device.\n * Struct is followed by num_buttons * Atom that names the buttons in the\n * device-native setup (i.e. ignoring button mappings).\n */\ntypedef struct {\n    uint16_t    type;           /**< Always ButtonClass */\n    uint16_t    length;         /**< Length in 4 byte units */\n    uint16_t    sourceid;       /**< source device for this class */\n    uint16_t    num_buttons;    /**< Number of buttons provided */\n} xXIButtonInfo;\n\n/**\n * Denotes key capability on a device.\n * Struct is followed by num_keys * CARD32 that lists the keycodes available\n * on the device.\n */\ntypedef struct {\n    uint16_t    type;           /**< Always KeyClass */\n    uint16_t    length;         /**< Length in 4 byte units */\n    uint16_t    sourceid;       /**< source device for this class */\n    uint16_t    num_keycodes;   /**< Number of keys provided */\n} xXIKeyInfo;\n\n/**\n * Denotes an valuator capability on a device.\n * One XIValuatorInfo describes exactly one valuator (axis) on the device.\n */\ntypedef struct {\n    uint16_t    type;           /**< Always ValuatorClass       */\n    uint16_t    length;         /**< Length in 4 byte units */\n    uint16_t    sourceid;       /**< source device for this class */\n    uint16_t    number;         /**< Valuator number            */\n    Atom        label;          /**< Axis label                 */\n    FP3232      min;            /**< Min value                  */\n    FP3232      max;            /**< Max value                  */\n    FP3232      value;          /**< Last published value       */\n    uint32_t    resolution;     /**< Resolutions in units/m     */\n    uint8_t     mode;           /**< ModeRelative or ModeAbsolute */\n    uint8_t     pad1;\n    uint16_t    pad2;\n} xXIValuatorInfo;\n\n/***\n * Denotes a scroll valuator on a device.\n * One XIScrollInfo describes exactly one scroll valuator that must have a\n * XIValuatorInfo struct.\n */\ntypedef struct {\n    uint16_t    type;           /**< Always ValuatorClass         */\n    uint16_t    length;         /**< Length in 4 byte units       */\n    uint16_t    sourceid;       /**< source device for this class */\n    uint16_t    number;         /**< Valuator number              */\n    uint16_t    scroll_type;    /**< ::XIScrollTypeVertical, ::XIScrollTypeHorizontal */\n    uint16_t    pad0;\n    uint32_t    flags;          /**< ::XIScrollFlagEmulate, ::XIScrollFlagPreferred   */\n    FP3232      increment;      /**< Increment for one unit of scrolling              */\n} xXIScrollInfo;\n\n/**\n * Denotes multitouch capability on a device.\n */\ntypedef struct {\n    uint16_t    type;           /**< Always TouchClass */\n    uint16_t    length;         /**< Length in 4 byte units */\n    uint16_t    sourceid;       /**< source device for this class */\n    uint8_t     mode;           /**< DirectTouch or DependentTouch */\n    uint8_t     num_touches;    /**< Maximum number of touches (0==unlimited) */\n} xXITouchInfo;\n\n/**\n * Used to select for events on a given window.\n * Struct is followed by (mask_len * CARD8), with each bit set representing\n * the event mask for the given type. A mask bit represents an event type if\n * (mask == (1 << type)).\n */\ntypedef struct {\n    uint16_t    deviceid;       /**< Device id to select for        */\n    uint16_t    mask_len;       /**< Length of mask in 4 byte units */\n} xXIEventMask;\n\n/**\n * XKB modifier information.\n * The effective modifier is a binary mask of base, latched, and locked\n * modifiers.\n */\ntypedef struct\n{\n    uint32_t    base_mods;              /**< Logically pressed modifiers */\n    uint32_t    latched_mods;           /**< Logically latched modifiers */\n    uint32_t    locked_mods;            /**< Logically locked modifiers */\n    uint32_t    effective_mods;         /**< Effective modifiers */\n} xXIModifierInfo;\n\n/**\n * XKB group information.\n * The effective group is the mathematical sum of base, latched, and locked\n * group after group wrapping is taken into account.\n */\ntypedef struct\n{\n    uint8_t     base_group;             /**< Logically \"pressed\" group */\n    uint8_t     latched_group;          /**< Logically latched group */\n    uint8_t     locked_group;           /**< Logically locked group */\n    uint8_t     effective_group;        /**< Effective group */\n} xXIGroupInfo;\n\n\n/*************************************************************************************\n *                                                                                   *\n *                                   REQUESTS                                        *\n *                                                                                   *\n *************************************************************************************/\n\n/**\n * Query the server for the supported X Input extension version.\n */\n\ntypedef struct {\n    uint8_t     reqType;                /**< Input extension major code */\n    uint8_t     ReqType;                /**< Always ::X_XIQueryVersion */\n    uint16_t    length;                 /**< Length in 4 byte units */\n    uint16_t    major_version;\n    uint16_t    minor_version;\n} xXIQueryVersionReq;\n#define sz_xXIQueryVersionReq                     8\n\ntypedef struct {\n    uint8_t     repType;                /**< ::X_Reply */\n    uint8_t     RepType;                /**< Always ::X_XIQueryVersion */\n    uint16_t    sequenceNumber;\n    uint32_t    length;\n    uint16_t    major_version;\n    uint16_t    minor_version;\n    uint32_t    pad1;\n    uint32_t    pad2;\n    uint32_t    pad3;\n    uint32_t    pad4;\n    uint32_t    pad5;\n} xXIQueryVersionReply;\n#define sz_xXIQueryVersionReply             32\n\n/**\n * Query the server for information about a specific device or all input\n * devices.\n */\ntypedef struct {\n    uint8_t     reqType;                /**< Input extension major code */\n    uint8_t     ReqType;                /**< Always ::X_XIQueryDevice */\n    uint16_t    length;                 /**< Length in 4 byte units */\n    uint16_t    deviceid;\n    uint16_t    pad;\n} xXIQueryDeviceReq;\n#define sz_xXIQueryDeviceReq                    8\n\ntypedef struct {\n    uint8_t     repType;                /**< ::X_Reply */\n    uint8_t     RepType;                /**< Always ::X_XIQueryDevice */\n    uint16_t    sequenceNumber;\n    uint32_t    length;\n    uint16_t    num_devices;\n    uint16_t    pad0;\n    uint32_t    pad1;\n    uint32_t    pad2;\n    uint32_t    pad3;\n    uint32_t    pad4;\n    uint32_t    pad5;\n} xXIQueryDeviceReply;\n#define sz_xXIQueryDeviceReply                  32\n\n/**\n * Select for events on a given window.\n */\ntypedef struct {\n    uint8_t     reqType;                /**< Input extension major code */\n    uint8_t     ReqType;                /**< Always ::X_XISelectEvents */\n    uint16_t    length;                 /**< Length in 4 byte units */\n    Window      win;\n    uint16_t    num_masks;\n    uint16_t    pad;\n} xXISelectEventsReq;\n#define sz_xXISelectEventsReq                  12\n\n/**\n * Query for selected events on a given window.\n */\ntypedef struct {\n    uint8_t     reqType;                /**< Input extension major code */\n    uint8_t     ReqType;                /**< Always ::X_XIGetSelectedEvents */\n    uint16_t    length;                 /**< Length in 4 byte units */\n    Window      win;\n} xXIGetSelectedEventsReq;\n#define sz_xXIGetSelectedEventsReq              8\n\ntypedef struct {\n    uint8_t     repType;                /**< Input extension major opcode */\n    uint8_t     RepType;                /**< Always ::X_XIGetSelectedEvents */\n    uint16_t    sequenceNumber;\n    uint32_t    length;\n    uint16_t    num_masks;              /**< Number of xXIEventMask structs\n                                             trailing the reply */\n    uint16_t    pad0;\n    uint32_t    pad1;\n    uint32_t    pad2;\n    uint32_t    pad3;\n    uint32_t    pad4;\n    uint32_t    pad5;\n} xXIGetSelectedEventsReply;\n#define sz_xXIGetSelectedEventsReply            32\n\n/**\n * Query the given device's screen/window coordinates.\n */\n\ntypedef struct {\n    uint8_t     reqType;                /**< Input extension major code */\n    uint8_t     ReqType;                /**< Always ::X_XIQueryPointer */\n    uint16_t    length;                 /**< Length in 4 byte units */\n    Window      win;\n    uint16_t    deviceid;\n    uint16_t    pad1;\n} xXIQueryPointerReq;\n#define sz_xXIQueryPointerReq                   12\n\n\ntypedef struct {\n    uint8_t     repType;                /**< Input extension major opcode */\n    uint8_t     RepType;                /**< Always ::X_XIQueryPointer */\n    uint16_t    sequenceNumber;\n    uint32_t    length;\n    Window      root;\n    Window      child;\n    FP1616      root_x;\n    FP1616      root_y;\n    FP1616      win_x;\n    FP1616      win_y;\n    uint8_t     same_screen;\n    uint8_t     pad0;\n    uint16_t    buttons_len;\n    xXIModifierInfo mods;\n    xXIGroupInfo group;\n} xXIQueryPointerReply;\n#define sz_xXIQueryPointerReply                 56\n\n/**\n * Warp the given device's pointer to the specified position.\n */\n\ntypedef struct {\n    uint8_t     reqType;                /**< Input extension major code */\n    uint8_t     ReqType;                /**< Always ::X_XIWarpPointer   */\n    uint16_t    length;                 /**< Length in 4 byte units */\n    Window      src_win;\n    Window      dst_win;\n    FP1616      src_x;\n    FP1616      src_y;\n    uint16_t    src_width;\n    uint16_t    src_height;\n    FP1616      dst_x;\n    FP1616      dst_y;\n    uint16_t    deviceid;\n    uint16_t    pad1;\n} xXIWarpPointerReq;\n#define sz_xXIWarpPointerReq                    36\n\n/**\n * Change the given device's sprite to the given cursor.\n */\n\ntypedef struct {\n    uint8_t     reqType;                /**< Input extension major code */\n    uint8_t     ReqType;                /**< Always ::X_XIChangeCursor  */\n    uint16_t    length;                 /**< Length in 4 byte units */\n    Window      win;\n    Cursor      cursor;\n    uint16_t    deviceid;\n    uint16_t    pad1;\n} xXIChangeCursorReq;\n#define sz_xXIChangeCursorReq                           16\n\n/**\n * Modify the device hierarchy.\n */\n\ntypedef struct {\n    uint8_t     reqType;                /**< Input extension major code */\n    uint8_t     ReqType;                /**< Always ::X_XIChangeHierarchy */\n    uint16_t    length;                 /**< Length in 4 byte units */\n    uint8_t     num_changes;\n    uint8_t     pad0;\n    uint16_t    pad1;\n} xXIChangeHierarchyReq;\n#define sz_xXIChangeHierarchyReq                        8\n\n/**\n * Generic header for any hierarchy change.\n */\ntypedef struct {\n    uint16_t    type;\n    uint16_t    length;                 /**< Length in 4 byte units */\n} xXIAnyHierarchyChangeInfo;\n\n/**\n * Create a new master device.\n * Name of new master follows struct (4-byte padded)\n */\ntypedef struct {\n    uint16_t    type;                   /**< Always ::XIAddMaster */\n    uint16_t    length;                 /**< 2 + (namelen + padding)/4 */\n    uint16_t    name_len;\n    uint8_t     send_core;\n    uint8_t     enable;\n} xXIAddMasterInfo;\n\n/**\n * Delete a master device. Will automatically delete the master device paired\n * with the given master device.\n */\ntypedef struct {\n    uint16_t    type;            /**< Always ::XIRemoveMaster */\n    uint16_t    length;          /**< 3 */\n    uint16_t    deviceid;\n    uint8_t     return_mode;     /**< ::XIAttachToMaster, ::XIFloating */\n    uint8_t     pad;\n    uint16_t    return_pointer;  /**< Pointer to attach slave ptr devices to */\n    uint16_t    return_keyboard; /**< keyboard to attach slave keybd devices to*/\n} xXIRemoveMasterInfo;\n\n/**\n * Attach an SD to a new device.\n * NewMaster has to be of same type (pointer->pointer, keyboard->keyboard);\n */\ntypedef struct {\n    uint16_t    type;           /**< Always ::XIAttachSlave */\n    uint16_t    length;         /**< 2 */\n    uint16_t    deviceid;\n    uint16_t    new_master;     /**< id of new master device */\n} xXIAttachSlaveInfo;\n\n/**\n * Detach an SD from its current master device.\n */\ntypedef struct {\n    uint16_t    type;           /**< Always ::XIDetachSlave */\n    uint16_t    length;         /**< 2 */\n    uint16_t    deviceid;\n    uint16_t    pad;\n} xXIDetachSlaveInfo;\n\n\n/**\n * Set the window/client's ClientPointer.\n */\ntypedef struct {\n    uint8_t     reqType;\n    uint8_t     ReqType;                /**< Always ::X_XISetClientPointer */\n    uint16_t    length;                 /**< Length in 4 byte units */\n    Window      win;\n    uint16_t    deviceid;\n    uint16_t    pad1;\n} xXISetClientPointerReq;\n#define sz_xXISetClientPointerReq                 12\n\n/**\n * Query the given window/client's ClientPointer setting.\n */\ntypedef struct {\n    uint8_t     reqType;\n    uint8_t     ReqType;                /**< Always ::X_GetClientPointer */\n    uint16_t    length;                 /**< Length in 4 byte units */\n    Window      win;\n} xXIGetClientPointerReq;\n#define sz_xXIGetClientPointerReq                 8\n\ntypedef struct {\n    uint8_t     repType;                /**< Input extension major opcode */\n    uint8_t     RepType;                /**< Always ::X_GetClientPointer */\n    uint16_t    sequenceNumber;\n    uint32_t    length;\n    BOOL        set;                    /**< client pointer is set? */\n    uint8_t     pad0;\n    uint16_t    deviceid;\n    uint32_t    pad1;\n    uint32_t    pad2;\n    uint32_t    pad3;\n    uint32_t    pad4;\n    uint32_t    pad5;\n} xXIGetClientPointerReply;\n#define sz_xXIGetClientPointerReply               32\n\n/**\n * Set the input focus to the specified window.\n */\ntypedef struct {\n    uint8_t     reqType;\n    uint8_t     ReqType;                /**< Always ::X_XISetFocus */\n    uint16_t    length;                 /**< Length in 4 byte units */\n    Window      focus;\n    Time        time;\n    uint16_t    deviceid;\n    uint16_t    pad0;\n} xXISetFocusReq;\n#define sz_xXISetFocusReq                       16\n\n/**\n * Query the current input focus.\n */\ntypedef struct {\n    uint8_t     reqType;\n    uint8_t     ReqType;                /**< Always ::X_XIGetDeviceFocus */\n    uint16_t    length;                 /**< Length in 4 byte units */\n    uint16_t    deviceid;\n    uint16_t    pad0;\n} xXIGetFocusReq;\n#define sz_xXIGetFocusReq                       8\n\ntypedef struct {\n    uint8_t     repType;                /**< Input extension major opcode */\n    uint8_t     RepType;                /**< Always ::X_XIGetFocus */\n    uint16_t    sequenceNumber;\n    uint32_t    length;\n    Window      focus;\n    uint32_t    pad1;\n    uint32_t    pad2;\n    uint32_t    pad3;\n    uint32_t    pad4;\n    uint32_t    pad5;\n} xXIGetFocusReply;\n#define sz_xXIGetFocusReply                     32\n\n\n/**\n * Grab the given device.\n */\ntypedef struct {\n    uint8_t     reqType;\n    uint8_t     ReqType;                /**< Always ::X_XIGrabDevice */\n    uint16_t    length;                 /**< Length in 4 byte units */\n    Window      grab_window;\n    Time        time;\n    Cursor      cursor;\n    uint16_t    deviceid;\n    uint8_t     grab_mode;\n    uint8_t     paired_device_mode;\n    uint8_t     owner_events;\n    uint8_t     pad;\n    uint16_t    mask_len;\n} xXIGrabDeviceReq;\n#define sz_xXIGrabDeviceReq                     24\n\n/**\n * Return codes from a XIPassiveGrabDevice request.\n */\ntypedef struct {\n    uint32_t    modifiers;              /**< Modifier state */\n    uint8_t     status;                 /**< Grab status code */\n    uint8_t     pad0;\n    uint16_t    pad1;\n} xXIGrabModifierInfo;\n\ntypedef struct {\n    uint8_t     repType;                /**< Input extension major opcode */\n    uint8_t     RepType;                /**< Always ::X_XIGrabDevice */\n    uint16_t    sequenceNumber;\n    uint32_t    length;\n    uint8_t     status;\n    uint8_t     pad0;\n    uint16_t    pad1;\n    uint32_t    pad2;\n    uint32_t    pad3;\n    uint32_t    pad4;\n    uint32_t    pad5;\n    uint32_t    pad6;\n} xXIGrabDeviceReply;\n#define sz_xXIGrabDeviceReply                  32\n\n/**\n * Ungrab the specified device.\n *\n */\ntypedef struct {\n    uint8_t     reqType;\n    uint8_t     ReqType;                /**< Always ::X_XIUngrabDevice */\n    uint16_t    length;                 /**< Length in 4 byte units */\n    Time        time;\n    uint16_t    deviceid;\n    uint16_t    pad;\n} xXIUngrabDeviceReq;\n#define sz_xXIUngrabDeviceReq                   12\n\n\n/**\n * Allow or replay events on the specified grabbed device.\n */\ntypedef struct {\n    uint8_t     reqType;\n    uint8_t     ReqType;                /**< Always ::X_XIAllowEvents */\n    uint16_t    length;                 /**< Length in 4 byte units */\n    Time        time;\n    uint16_t    deviceid;\n    uint8_t     mode;\n    uint8_t     pad;\n} xXIAllowEventsReq;\n#define sz_xXIAllowEventsReq                   12\n\n/**\n * Allow or replay events on the specified grabbed device.\n * Since XI 2.2\n */\ntypedef struct {\n    uint8_t     reqType;\n    uint8_t     ReqType;                /**< Always ::X_XIAllowEvents */\n    uint16_t    length;                 /**< Length in 4 byte units */\n    Time        time;\n    uint16_t    deviceid;\n    uint8_t     mode;\n    uint8_t     pad;\n    uint32_t    touchid;                /**< Since XI 2.2 */\n    Window      grab_window;            /**< Since XI 2.2 */\n} xXI2_2AllowEventsReq;\n#define sz_xXI2_2AllowEventsReq                20\n\n\n/**\n * Passively grab the device.\n */\ntypedef struct {\n    uint8_t     reqType;\n    uint8_t     ReqType;                /**< Always ::X_XIPassiveGrabDevice */\n    uint16_t    length;                 /**< Length in 4 byte units */\n    Time        time;\n    Window      grab_window;\n    Cursor      cursor;\n    uint32_t    detail;\n    uint16_t    deviceid;\n    uint16_t    num_modifiers;\n    uint16_t    mask_len;\n    uint8_t     grab_type;\n    uint8_t     grab_mode;\n    uint8_t     paired_device_mode;\n    uint8_t     owner_events;\n    uint16_t    pad1;\n} xXIPassiveGrabDeviceReq;\n#define sz_xXIPassiveGrabDeviceReq              32\n\ntypedef struct {\n    uint8_t     repType;                /**< Input extension major opcode */\n    uint8_t     RepType;                /**< Always ::X_XIPassiveGrabDevice */\n    uint16_t    sequenceNumber;\n    uint32_t    length;\n    uint16_t    num_modifiers;\n    uint16_t    pad1;\n    uint32_t    pad2;\n    uint32_t    pad3;\n    uint32_t    pad4;\n    uint32_t    pad5;\n    uint32_t    pad6;\n} xXIPassiveGrabDeviceReply;\n#define sz_xXIPassiveGrabDeviceReply            32\n\n/**\n * Delete a passive grab for the given device.\n */\ntypedef struct {\n    uint8_t     reqType;\n    uint8_t     ReqType;                /**< Always ::X_XIPassiveUngrabDevice */\n    uint16_t    length;                 /**< Length in 4 byte units */\n    Window      grab_window;\n    uint32_t    detail;\n    uint16_t    deviceid;\n    uint16_t    num_modifiers;\n    uint8_t     grab_type;\n    uint8_t     pad0;\n    uint16_t    pad1;\n} xXIPassiveUngrabDeviceReq;\n#define sz_xXIPassiveUngrabDeviceReq            20\n\n/**\n * List all device properties on the specified device.\n */\ntypedef struct {\n    uint8_t     reqType;\n    uint8_t     ReqType;                /**< Always ::X_XIListProperties */\n    uint16_t    length;                 /**< Length in 4 byte units */\n    uint16_t    deviceid;\n    uint16_t    pad;\n} xXIListPropertiesReq;\n#define sz_xXIListPropertiesReq                 8\n\ntypedef struct {\n    uint8_t     repType;                /**< Input extension major opcode */\n    uint8_t     RepType;                /**< Always ::X_XIListProperties */\n    uint16_t    sequenceNumber;\n    uint32_t    length;\n    uint16_t    num_properties;\n    uint16_t    pad0;\n    uint32_t    pad1;\n    uint32_t    pad2;\n    uint32_t    pad3;\n    uint32_t    pad4;\n    uint32_t    pad5;\n} xXIListPropertiesReply;\n#define sz_xXIListPropertiesReply               32\n\n/**\n * Change a property on the specified device.\n */\ntypedef struct {\n    uint8_t     reqType;\n    uint8_t     ReqType;                /**< Always ::X_XIChangeProperty */\n    uint16_t    length;                 /**< Length in 4 byte units */\n    uint16_t    deviceid;\n    uint8_t     mode;\n    uint8_t     format;\n    Atom        property;\n    Atom        type;\n    uint32_t    num_items;\n} xXIChangePropertyReq;\n#define sz_xXIChangePropertyReq                 20\n\n/**\n * Delete the specified property.\n */\ntypedef struct {\n    uint8_t     reqType;\n    uint8_t     ReqType;                /**< Always X_XIDeleteProperty */\n    uint16_t    length;                 /**< Length in 4 byte units */\n    uint16_t    deviceid;\n    uint16_t    pad0;\n    Atom        property;\n} xXIDeletePropertyReq;\n#define sz_xXIDeletePropertyReq                 12\n\n/**\n * Query the specified property's values.\n */\ntypedef struct {\n    uint8_t     reqType;\n    uint8_t     ReqType;                /**< Always X_XIGetProperty */\n    uint16_t    length;                 /**< Length in 4 byte units */\n    uint16_t    deviceid;\n#if defined(__cplusplus) || defined(c_plusplus)\n    uint8_t     c_delete;\n#else\n    uint8_t     delete;\n#endif\n    uint8_t     pad0;\n    Atom        property;\n    Atom        type;\n    uint32_t    offset;\n    uint32_t    len;\n} xXIGetPropertyReq;\n#define sz_xXIGetPropertyReq                    24\n\ntypedef struct {\n    uint8_t     repType;                /**< Input extension major opcode */\n    uint8_t     RepType;                /**< Always X_XIGetProperty */\n    uint16_t    sequenceNumber;\n    uint32_t    length;\n    Atom        type;\n    uint32_t    bytes_after;\n    uint32_t    num_items;\n    uint8_t     format;\n    uint8_t     pad0;\n    uint16_t    pad1;\n    uint32_t    pad2;\n    uint32_t    pad3;\n} xXIGetPropertyReply;\n#define sz_xXIGetPropertyReply               32\n\ntypedef struct {\n    uint16_t    deviceid;\n    uint16_t    pad;\n    Barrier     barrier;\n    uint32_t    eventid;\n} xXIBarrierReleasePointerInfo;\n\ntypedef struct {\n    uint8_t     reqType;                /**< Input extension major opcode */\n    uint8_t     ReqType;                /**< Always X_XIBarrierReleasePointer */\n    uint16_t    length;\n    uint32_t    num_barriers;\n    /* array of xXIBarrierReleasePointerInfo */\n} xXIBarrierReleasePointerReq;\n#define sz_xXIBarrierReleasePointerReq       8\n\n/*************************************************************************************\n *                                                                                   *\n *                                      EVENTS                                       *\n *                                                                                   *\n *************************************************************************************/\n\n/**\n * Generic XI2 event header. All XI2 events use the same header.\n */\ntypedef struct\n{\n    uint8_t     type;\n    uint8_t     extension;              /**< XI extension offset */\n    uint16_t    sequenceNumber;\n    uint32_t    length;\n    uint16_t    evtype;\n    uint16_t    deviceid;\n    Time        time;\n} xXIGenericDeviceEvent;\n\n/**\n * Device hierarchy information.\n */\ntypedef struct\n{\n    uint16_t    deviceid;\n    uint16_t    attachment;             /**< ID of master or paired device */\n    uint8_t     use;                    /**< ::XIMasterKeyboard,\n                                             ::XIMasterPointer,\n                                             ::XISlaveKeyboard,\n                                             ::XISlavePointer,\n                                             ::XIFloatingSlave */\n    BOOL        enabled;                /**< TRUE if the device is enabled */\n    uint16_t    pad;\n    uint32_t    flags;                  /**< ::XIMasterAdded, ::XIMasterRemoved,\n                                             ::XISlaveAttached, ::XISlaveDetached,\n                                             ::XISlaveAdded, ::XISlaveRemoved,\n                                             ::XIDeviceEnabled, ::XIDeviceDisabled */\n} xXIHierarchyInfo;\n\n/**\n * The device hierarchy has been modified. This event includes the device\n * hierarchy after the modification has been applied.\n */\ntypedef struct\n{\n    uint8_t     type;                   /**< Always GenericEvent */\n    uint8_t     extension;              /**< XI extension offset */\n    uint16_t    sequenceNumber;\n    uint32_t    length;                 /**< Length in 4 byte units */\n    uint16_t    evtype;                 /**< ::XI_Hierarchy */\n    uint16_t    deviceid;\n    Time        time;\n    uint32_t    flags;                  /**< ::XIMasterAdded, ::XIMasterDeleted,\n                                             ::XISlaveAttached, ::XISlaveDetached,\n                                             ::XISlaveAdded, ::XISlaveRemoved,\n                                             ::XIDeviceEnabled, ::XIDeviceDisabled */\n    uint16_t    num_info;\n    uint16_t    pad0;\n    uint32_t    pad1;\n    uint32_t    pad2;\n} xXIHierarchyEvent;\n\n/**\n * A device has changed capabilities.\n */\ntypedef struct\n{\n    uint8_t     type;                   /**< Always GenericEvent */\n    uint8_t     extension;              /**< XI extension offset */\n    uint16_t    sequenceNumber;\n    uint32_t    length;                 /**< Length in 4 byte units */\n    uint16_t    evtype;                 /**< XI_DeviceChanged */\n    uint16_t    deviceid;               /**< Device that has changed */\n    Time        time;\n    uint16_t    num_classes;            /**< Number of classes that have changed */\n    uint16_t    sourceid;               /**< Source of the new classes */\n    uint8_t     reason;                 /**< ::XISlaveSwitch, ::XIDeviceChange */\n    uint8_t     pad0;\n    uint16_t    pad1;\n    uint32_t    pad2;\n    uint32_t    pad3;\n} xXIDeviceChangedEvent;\n\n/**\n * The owner of a touch stream has passed on ownership to another client.\n */\ntypedef struct\n{\n    uint8_t     type;               /**< Always GenericEvent */\n    uint8_t     extension;          /**< XI extension offset */\n    uint16_t    sequenceNumber;\n    uint32_t    length;             /**< Length in 4 byte units */\n    uint16_t    evtype;             /**< XI_TouchOwnership */\n    uint16_t    deviceid;           /**< Device that has changed */\n    Time        time;\n    uint32_t    touchid;\n    Window      root;\n    Window      event;\n    Window      child;\n/* └──────── 32 byte boundary ────────┘ */\n    uint16_t    sourceid;\n    uint16_t    pad0;\n    uint32_t    flags;\n    uint32_t    pad1;\n    uint32_t    pad2;\n} xXITouchOwnershipEvent;\n\n/**\n * Default input event for pointer, keyboard or touch input.\n */\ntypedef struct\n{\n    uint8_t     type;                   /**< Always GenericEvent */\n    uint8_t     extension;              /**< XI extension offset */\n    uint16_t    sequenceNumber;\n    uint32_t    length;                 /**< Length in 4 byte uints */\n    uint16_t    evtype;\n    uint16_t    deviceid;\n    Time        time;\n    uint32_t    detail;                 /**< Keycode or button */\n    Window      root;\n    Window      event;\n    Window      child;\n/* └──────── 32 byte boundary ────────┘ */\n    FP1616      root_x;                 /**< Always screen coords, 16.16 fixed point */\n    FP1616      root_y;\n    FP1616      event_x;                /**< Always screen coords, 16.16 fixed point */\n    FP1616      event_y;\n    uint16_t    buttons_len;            /**< Len of button flags in 4 b units */\n    uint16_t    valuators_len;          /**< Len of val. flags in 4 b units */\n    uint16_t    sourceid;               /**< The source device */\n    uint16_t    pad0;\n    uint32_t    flags;                  /**< ::XIKeyRepeat */\n    xXIModifierInfo     mods;\n    xXIGroupInfo        group;\n} xXIDeviceEvent;\n\n\n/**\n * Sent when an input event is generated. RawEvents include valuator\n * information in both device-specific data (i.e. unaccelerated) and\n * processed data (i.e. accelerated, if applicable).\n */\ntypedef struct\n{\n    uint8_t     type;                   /**< Always GenericEvent */\n    uint8_t     extension;              /**< XI extension offset */\n    uint16_t    sequenceNumber;\n    uint32_t    length;                 /**< Length in 4 byte uints */\n    uint16_t    evtype;                 /**< ::XI_RawEvent */\n    uint16_t    deviceid;\n    Time        time;\n    uint32_t    detail;\n    uint16_t    sourceid;               /**< The source device (XI 2.1) */\n    uint16_t    valuators_len;          /**< Length of trailing valuator\n                                             mask in 4 byte units */\n    uint32_t    flags;                  /**< ::XIKeyRepeat */\n    uint32_t    pad2;\n} xXIRawEvent;\n\n/**\n * Note that the layout of root, event, child, root_x, root_y, event_x,\n * event_y must be identical to the xXIDeviceEvent.\n */\ntypedef struct\n{\n    uint8_t     type;                   /**< Always GenericEvent */\n    uint8_t     extension;              /**< XI extension offset */\n    uint16_t    sequenceNumber;\n    uint32_t    length;                 /**< Length in 4 byte uints */\n    uint16_t    evtype;                 /**< ::XI_Enter */\n    uint16_t    deviceid;\n    Time        time;\n    uint16_t    sourceid;\n    uint8_t     mode;\n    uint8_t     detail;\n    Window      root;\n    Window      event;\n    Window      child;\n/* └──────── 32 byte boundary ────────┘ */\n    FP1616      root_x;\n    FP1616      root_y;\n    FP1616      event_x;\n    FP1616      event_y;\n    BOOL        same_screen;\n    BOOL        focus;\n    uint16_t    buttons_len;            /**< Length of trailing button mask\n                                             in 4 byte units */\n    xXIModifierInfo     mods;\n    xXIGroupInfo        group;\n} xXIEnterEvent;\n\ntypedef xXIEnterEvent xXILeaveEvent;\ntypedef xXIEnterEvent xXIFocusInEvent;\ntypedef xXIEnterEvent xXIFocusOutEvent;\n\n/**\n * Sent when a device property is created, modified or deleted. Does not\n * include property data, the client is required to query the data.\n */\ntypedef struct\n{\n    uint8_t     type;                   /**< Always GenericEvent */\n    uint8_t     extension;              /**< XI extension offset */\n    uint16_t    sequenceNumber;\n    uint32_t    length;                 /**< Length in 4 byte units */\n    uint16_t    evtype;                 /**< ::XI_PropertyEvent */\n    uint16_t    deviceid;\n    Time        time;\n    Atom        property;\n    uint8_t     what;                   /**< ::XIPropertyDeleted,\n                                             ::XIPropertyCreated,\n                                             ::XIPropertyMotified */\n    uint8_t     pad0;\n    uint16_t    pad1;\n    uint32_t    pad2;\n    uint32_t    pad3;\n} xXIPropertyEvent;\n\ntypedef struct\n{\n    uint8_t     type;                   /**< Always GenericEvent */\n    uint8_t     extension;              /**< XI extension offset */\n    uint16_t    sequenceNumber;\n    uint32_t    length;                 /**< Length in 4 byte units */\n    uint16_t    evtype;                 /**< ::XI_BarrierHit or ::XI_BarrierLeave */\n    uint16_t    deviceid;\n    Time        time;\n    uint32_t    eventid;\n    Window      root;\n    Window      event;\n    Barrier     barrier;\n/* └──────── 32 byte boundary ────────┘ */\n    uint32_t    dtime;\n    uint32_t    flags;                  /**< ::XIBarrierPointerReleased\n                                             ::XIBarrierDeviceIsGrabbed */\n    uint16_t    sourceid;\n    int16_t     pad;\n    FP1616      root_x;\n    FP1616      root_y;\n    FP3232      dx;\n    FP3232      dy;\n} xXIBarrierEvent;\n\ntypedef xXIBarrierEvent xXIBarrierHitEvent;\ntypedef xXIBarrierEvent xXIBarrierPointerReleasedEvent;\ntypedef xXIBarrierEvent xXIBarrierLeaveEvent;\n\n#undef Window\n#undef Time\n#undef Atom\n#undef Cursor\n#undef Barrier\n\n#endif /* _XI2PROTO_H_ */\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/X11/extensions/XIproto.h",
    "content": "/************************************************************\n\nCopyright 1989, 1998  The Open Group\n\nPermission to use, copy, modify, distribute, and sell this software and its\ndocumentation for any purpose is hereby granted without fee, provided that\nthe above copyright notice appear in all copies and that both that\ncopyright notice and this permission notice appear in supporting\ndocumentation.\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE\nOPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN\nAN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\nCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\nExcept as contained in this notice, the name of The Open Group shall not be\nused in advertising or otherwise to promote the sale, use or other dealings\nin this Software without prior written authorization from The Open Group.\n\nCopyright 1989 by Hewlett-Packard Company, Palo Alto, California.\n\n\t\t\tAll Rights Reserved\n\nPermission to use, copy, modify, and distribute this software and its\ndocumentation for any purpose and without fee is hereby granted,\nprovided that the above copyright notice appear in all copies and that\nboth that copyright notice and this permission notice appear in\nsupporting documentation, and that the name of Hewlett-Packard not be\nused in advertising or publicity pertaining to distribution of the\nsoftware without specific, written prior permission.\n\nHEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING\nALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL\nHEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR\nANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,\nWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,\nARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS\nSOFTWARE.\n\n********************************************************/\n\n#ifndef _XIPROTO_H\n#define _XIPROTO_H\n\n#include <X11/Xproto.h>\n#include <X11/X.h>\n\n/* make sure types have right sizes for protocol structures. */\n#define Window CARD32\n#define Time CARD32\n#define KeyCode CARD8\n#define Mask CARD32\n#define Atom CARD32\n#define Cursor CARD32\n\n/*********************************************************\n *\n * number of events, errors, and extension name.\n *\n */\n\n#define MORE_EVENTS\t0x80\n#define DEVICE_BITS\t0x7F\n\n#define InputClassBits\t0x3F\t/* bits in mode field for input classes */\n#define ModeBitsShift\t6\t/* amount to shift the remaining bits   */\n\n#define numInputClasses 7\n\n#define IEVENTS         17       /* does NOT include generic events */\n#define IERRORS         5\n#define IREQUESTS       39\n\n#define CLIENT_REQ      1\n\ntypedef struct  _XExtEventInfo\n    {\n    Mask\tmask;\n    BYTE\ttype;\n    BYTE\tword;\n    } XExtEventInfo;\n\n#ifndef _XITYPEDEF_POINTER\ntypedef void *Pointer;\n#endif\n\nstruct tmask\n    {\n    Mask\tmask;\n    void        *dev;\n    };\n\n/*********************************************************\n *\n * Event constants used by library.\n *\n */\n\n#define XI_DeviceValuator\t\t0\n#define XI_DeviceKeyPress\t\t1\n#define XI_DeviceKeyRelease\t\t2\n#define XI_DeviceButtonPress\t\t3\n#define XI_DeviceButtonRelease\t\t4\n#define XI_DeviceMotionNotify\t\t5\n#define XI_DeviceFocusIn\t\t6\n#define XI_DeviceFocusOut\t\t7\n#define XI_ProximityIn\t\t\t8\n#define XI_ProximityOut\t\t\t9\n#define XI_DeviceStateNotify\t\t10\n#define XI_DeviceMappingNotify\t\t11\n#define XI_ChangeDeviceNotify\t\t12\n#define XI_DeviceKeystateNotify\t\t13\n#define XI_DeviceButtonstateNotify\t14\n#define XI_DevicePresenceNotify\t\t15\n#define XI_DevicePropertyNotify         16\n\n/*********************************************************\n *\n * Protocol request constants\n *\n */\n\n#define X_GetExtensionVersion\t\t1\n#define X_ListInputDevices\t\t2\n#define X_OpenDevice\t\t\t3\n#define X_CloseDevice\t\t\t4\n#define X_SetDeviceMode\t\t\t5\n#define X_SelectExtensionEvent\t\t6\n#define X_GetSelectedExtensionEvents\t7\n#define X_ChangeDeviceDontPropagateList 8\n#define X_GetDeviceDontPropagateList\t9\n#define X_GetDeviceMotionEvents\t\t10\n#define X_ChangeKeyboardDevice\t\t11\n#define X_ChangePointerDevice\t\t12\n#define X_GrabDevice\t\t\t13\n#define X_UngrabDevice\t\t\t14\n#define X_GrabDeviceKey\t\t\t15\n#define X_UngrabDeviceKey\t\t16\n#define X_GrabDeviceButton\t\t17\n#define X_UngrabDeviceButton\t\t18\n#define X_AllowDeviceEvents\t\t19\n#define X_GetDeviceFocus\t\t20\n#define X_SetDeviceFocus\t\t21\n#define X_GetFeedbackControl\t\t22\n#define X_ChangeFeedbackControl\t\t23\n#define X_GetDeviceKeyMapping\t\t24\n#define X_ChangeDeviceKeyMapping\t25\n#define X_GetDeviceModifierMapping\t26\n#define X_SetDeviceModifierMapping\t27\n#define X_GetDeviceButtonMapping\t28\n#define X_SetDeviceButtonMapping\t29\n#define X_QueryDeviceState\t\t30\n#define X_SendExtensionEvent\t\t31\n#define X_DeviceBell\t\t\t32\n#define X_SetDeviceValuators\t\t33\n#define X_GetDeviceControl\t\t34\n#define X_ChangeDeviceControl\t\t35\n/* XI 1.5 */\n#define X_ListDeviceProperties          36\n#define X_ChangeDeviceProperty          37\n#define X_DeleteDeviceProperty          38\n#define X_GetDeviceProperty             39\n\n/*********************************************************\n *\n * Protocol request and reply structures.\n *\n * GetExtensionVersion.\n *\n */\n\ntypedef struct {\n    CARD8\treqType;       /* input extension major code   */\n    CARD8\tReqType;       /* always X_GetExtensionVersion */\n    CARD16\tlength B16;\n    CARD16\tnbytes B16;\n    CARD8\tpad1, pad2;\n} xGetExtensionVersionReq;\n\ntypedef struct {\n    CARD8\trepType;\t/* X_Reply\t\t\t*/\n    CARD8\tRepType;\t/* always X_GetExtensionVersion */\n    CARD16\tsequenceNumber B16;\n    CARD32\tlength B32;\n    CARD16\tmajor_version B16;\n    CARD16\tminor_version B16;\n    BOOL\tpresent;\n    CARD8\tpad1, pad2, pad3;\n    CARD32\tpad01 B32;\n    CARD32\tpad02 B32;\n    CARD32\tpad03 B32;\n    CARD32\tpad04 B32;\n} xGetExtensionVersionReply;\n\n/*********************************************************\n *\n * ListInputDevices.\n *\n */\n\ntypedef struct {\n    CARD8\treqType;\t/* input extension major code\t*/\n    CARD8\tReqType;\t/* always X_ListInputDevices\t*/\n    CARD16\tlength B16;\n} xListInputDevicesReq;\n\ntypedef struct {\n    CARD8\trepType;\t/* X_Reply\t\t\t*/\n    CARD8\tRepType;        /* always X_ListInputDevices\t*/\n    CARD16\tsequenceNumber B16;\n    CARD32\tlength B32;\n    CARD8\tndevices;\n    CARD8\tpad1, pad2, pad3;\n    CARD32\tpad01 B32;\n    CARD32\tpad02 B32;\n    CARD32\tpad03 B32;\n    CARD32\tpad04 B32;\n    CARD32\tpad05 B32;\n} xListInputDevicesReply;\n\ntypedef struct _xDeviceInfo *xDeviceInfoPtr;\n\ntypedef struct _xAnyClassinfo *xAnyClassPtr;\n\ntypedef struct _xAnyClassinfo {\n#if defined(__cplusplus) || defined(c_plusplus)\n    CARD8\tc_class;\n#else\n    CARD8\tclass;\n#endif\n    CARD8\tlength;\n    } xAnyClassInfo;\n\ntypedef struct _xDeviceInfo {\n    CARD32\ttype B32;\n    CARD8\tid;\n    CARD8\tnum_classes;\n    CARD8\tuse;      /* IsXPointer | IsXKeyboard | IsXExtension... */\n    CARD8\tattached; /* id of master dev (if IsXExtension..) */\n    } xDeviceInfo;\n\ntypedef struct _xKeyInfo *xKeyInfoPtr;\n\ntypedef struct _xKeyInfo {\n#if defined(__cplusplus) || defined(c_plusplus)\n    CARD8\tc_class;\n#else\n    CARD8\tclass;\n#endif\n    CARD8\tlength;\n    KeyCode\tmin_keycode;\n    KeyCode\tmax_keycode;\n    CARD16\tnum_keys B16;\n    CARD8\tpad1,pad2;\n    } xKeyInfo;\n\ntypedef struct _xButtonInfo *xButtonInfoPtr;\n\ntypedef struct _xButtonInfo {\n#if defined(__cplusplus) || defined(c_plusplus)\n    CARD8\tc_class;\n#else\n    CARD8\tclass;\n#endif\n    CARD8\tlength;\n    CARD16\tnum_buttons B16;\n    } xButtonInfo;\n\ntypedef struct _xValuatorInfo *xValuatorInfoPtr;\n\ntypedef struct _xValuatorInfo {\n#if defined(__cplusplus) || defined(c_plusplus)\n    CARD8\tc_class;\n#else\n    CARD8\tclass;\n#endif\n    CARD8\tlength;\n    CARD8\tnum_axes;\n    CARD8\tmode;\n    CARD32\tmotion_buffer_size B32;\n    } xValuatorInfo;\n\ntypedef struct _xAxisInfo *xAxisInfoPtr;\n\ntypedef struct _xAxisInfo {\n    CARD32\tresolution B32;\n    CARD32\tmin_value B32;\n    CARD32\tmax_value B32;\n    } xAxisInfo;\n\n/*********************************************************\n *\n * OpenDevice.\n *\n */\n\ntypedef struct {\n    CARD8\treqType;\t/* input extension major code\t*/\n    CARD8\tReqType;        /* always X_OpenDevice\t\t*/\n    CARD16\tlength B16;\n    CARD8       deviceid;\n    BYTE\tpad1, pad2, pad3;\n} xOpenDeviceReq;\n\ntypedef struct {\n    CARD8\trepType;\t/* X_Reply\t\t\t*/\n    CARD8\tRepType;\t/* always X_OpenDevice\t\t*/\n    CARD16\tsequenceNumber B16;\n    CARD32\tlength B32;\n    CARD8\tnum_classes;\n    BYTE\tpad1, pad2, pad3;\n    CARD32\tpad00 B32;\n    CARD32\tpad01 B32;\n    CARD32\tpad02 B32;\n    CARD32\tpad03 B32;\n    CARD32\tpad04 B32;\n    } xOpenDeviceReply;\n\ntypedef struct {\n#if defined(__cplusplus) || defined(c_plusplus)\n    CARD8\tc_class;\n#else\n    CARD8\tclass;\n#endif\n    CARD8\tevent_type_base;\n    } xInputClassInfo;\n\n/*********************************************************\n *\n * CloseDevice.\n *\n */\n\ntypedef struct {\n    CARD8\treqType;\t/* input extension major code\t*/\n    CARD8\tReqType;        /* always X_CloseDevice\t*/\n    CARD16\tlength B16;\n    CARD8       deviceid;\n    BYTE\tpad1, pad2, pad3;\n} xCloseDeviceReq;\n\n/*********************************************************\n *\n * SetDeviceMode.\n *\n */\n\ntypedef struct {\n    CARD8\treqType;\t/* input extension major code\t*/\n    CARD8\tReqType;\t/* always X_SetDeviceMode\t*/\n    CARD16\tlength B16;\n    CARD8       deviceid;\n    CARD8       mode;\n    BYTE\tpad1, pad2;\n} xSetDeviceModeReq;\n\ntypedef struct {\n    CARD8\trepType;\t/* X_Reply\t\t\t*/\n    CARD8\tRepType;\t/* always X_SetDeviceMode\t*/\n    CARD16\tsequenceNumber B16;\n    CARD32\tlength B32;\n    CARD8\tstatus;\n    BYTE\tpad1, pad2, pad3;\n    CARD32\tpad01 B32;\n    CARD32\tpad02 B32;\n    CARD32\tpad03 B32;\n    CARD32\tpad04 B32;\n    CARD32\tpad05 B32;\n} xSetDeviceModeReply;\n\n/*********************************************************\n *\n * SelectExtensionEvent.\n *\n */\n\ntypedef struct {\n    CARD8\treqType;\t/* input extension major code\t*/\n    CARD8\tReqType;        /* always X_SelectExtensionEvent */\n    CARD16\tlength B16;\n    Window\twindow B32;\n    CARD16\tcount B16;\n    CARD16\tpad00 B16;\n} xSelectExtensionEventReq;\n\n/*********************************************************\n *\n * GetSelectedExtensionEvent.\n *\n */\n\ntypedef struct {\n    CARD8\treqType;\t/* input extension major code\t*/\n    CARD8\tReqType;        /* X_GetSelectedExtensionEvents */\n    CARD16\tlength B16;\n    Window\twindow B32;\n} xGetSelectedExtensionEventsReq;\n\ntypedef struct {\n    CARD8\trepType;\t/* X_Reply\t\t\t*/\n    CARD8\tRepType;\t/* GetSelectedExtensionEvents\t*/\n    CARD16\tsequenceNumber B16;\n    CARD32\tlength B32;\n    CARD16\tthis_client_count B16;\n    CARD16\tall_clients_count B16;\n    CARD32\tpad01 B32;\n    CARD32\tpad02 B32;\n    CARD32\tpad03 B32;\n    CARD32\tpad04 B32;\n    CARD32\tpad05 B32;\n} xGetSelectedExtensionEventsReply;\n\n/*********************************************************\n *\n * ChangeDeviceDontPropagateList.\n *\n */\n\ntypedef struct {\n    CARD8\treqType;\t/* input extension major code\t*/\n    CARD8\tReqType;        /* X_ChangeDeviceDontPropagateList */\n    CARD16\tlength B16;\n    Window\twindow B32;\n    CARD16\tcount B16;\n    CARD8\tmode;\n    BYTE\tpad;\n} xChangeDeviceDontPropagateListReq;\n\n/*********************************************************\n *\n * GetDeviceDontPropagateList.\n *\n */\n\ntypedef struct {\n    CARD8\treqType;\t/* input extension major code\t*/\n    CARD8\tReqType;        /* X_GetDeviceDontPropagateList */\n    CARD16\tlength B16;\n    Window\twindow B32;\n} xGetDeviceDontPropagateListReq;\n\ntypedef struct {\n    CARD8\trepType;\t/* X_Reply\t\t\t*/\n    CARD8\tRepType;        /* GetDeviceDontPropagateList   */\n    CARD16\tsequenceNumber B16;\n    CARD32\tlength B32;\n    CARD16\tcount B16;\n    CARD16\tpad00 B16;\n    CARD32\tpad01 B32;\n    CARD32\tpad02 B32;\n    CARD32\tpad03 B32;\n    CARD32\tpad04 B32;\n    CARD32\tpad05 B32;\n    } xGetDeviceDontPropagateListReply;\n\n/*********************************************************\n *\n * GetDeviceMotionEvents.\n *\n */\n\ntypedef struct {\n    CARD8\treqType;\t/* input extension major code\t*/\n    CARD8\tReqType;        /* always X_GetDeviceMotionEvents*/\n    CARD16\tlength B16;\n    Time\tstart B32;\n    Time\tstop B32;\n    CARD8\tdeviceid;\n    BYTE\tpad1, pad2, pad3;\n} xGetDeviceMotionEventsReq;\n\ntypedef struct {\n    CARD8\trepType;\t/* X_Reply */\n    CARD8\tRepType;        /* always X_GetDeviceMotionEvents  */\n    CARD16\tsequenceNumber B16;\n    CARD32\tlength B32;\n    CARD32\tnEvents B32;\n    CARD8\taxes;\n    CARD8\tmode;\n    BYTE\tpad1, pad2;\n    CARD32\tpad01 B32;\n    CARD32\tpad02 B32;\n    CARD32\tpad03 B32;\n    CARD32\tpad04 B32;\n} xGetDeviceMotionEventsReply;\n\n/*********************************************************\n *\n * ChangeKeyboardDevice.\n *\n */\n\ntypedef struct {\n    CARD8\treqType;\t/* input extension major code\t*/\n    CARD8\tReqType;        /* X_ChangeKeyboardDevice\t*/\n    CARD16\tlength B16;\n    CARD8\tdeviceid;\n    BYTE\tpad1, pad2, pad3;\n} xChangeKeyboardDeviceReq;\n\ntypedef struct {\n    CARD8\trepType;\t/* X_Reply\t\t\t*/\n    CARD8\tRepType;        /* always X_ChangeKeyboardDevice*/\n    CARD16\tsequenceNumber B16;\n    CARD32\tlength B32;  /* 0 */\n    CARD8\tstatus;\n    BYTE\tpad1, pad2, pad3;\n    CARD32\tpad01 B32;\n    CARD32\tpad02 B32;\n    CARD32\tpad03 B32;\n    CARD32\tpad04 B32;\n    CARD32\tpad05 B32;\n    } xChangeKeyboardDeviceReply;\n\n/*********************************************************\n *\n * ChangePointerDevice.\n *\n */\n\ntypedef struct {\n    CARD8\treqType;\t/* input extension major code\t*/\n    CARD8\tReqType;        /* X_ChangePointerDevice\t*/\n    CARD16\tlength B16;\n    CARD8\txaxis;\n    CARD8\tyaxis;\n    CARD8\tdeviceid;\n    BYTE\tpad1;\n} xChangePointerDeviceReq;\n\ntypedef struct {\n    CARD8\trepType;\t/* X_Reply\t\t\t*/\n    CARD8\tRepType;        /* always X_ChangePointerDevice */\n    CARD16\tsequenceNumber B16;\n    CARD32\tlength B32;  /* 0 */\n    CARD8\tstatus;\n    BYTE\tpad1, pad2, pad3;\n    CARD32\tpad01 B32;\n    CARD32\tpad02 B32;\n    CARD32\tpad03 B32;\n    CARD32\tpad04 B32;\n    CARD32\tpad05 B32;\n    } xChangePointerDeviceReply;\n\n/*********************************************************\n *\n * GrabDevice.\n *\n */\n\ntypedef struct {\n    CARD8\treqType;\t/* input extension major code\t*/\n    CARD8\tReqType;        /* always X_GrabDevice */\n    CARD16\tlength B16;\n    Window\tgrabWindow B32;\n    Time\ttime B32;\n    CARD16\tevent_count B16;\n    CARD8\tthis_device_mode;\n    CARD8\tother_devices_mode;\n    BOOL\townerEvents;\n    CARD8\tdeviceid;\n    CARD16\tpad01 B16;\n} xGrabDeviceReq;\n\ntypedef struct {\n    CARD8\trepType;\t/* X_Reply\t\t\t*/\n    CARD8\tRepType;        /* always X_GrabDevice\t*/\n    CARD16\tsequenceNumber B16;\n    CARD32\tlength B32;  /* 0 */\n    CARD8\tstatus;\n    BYTE\tpad1, pad2, pad3;\n    CARD32\tpad01 B32;\n    CARD32\tpad02 B32;\n    CARD32\tpad03 B32;\n    CARD32\tpad04 B32;\n    CARD32\tpad05 B32;\n    } xGrabDeviceReply;\n\n/*********************************************************\n *\n * UngrabDevice.\n *\n */\n\ntypedef struct {\n    CARD8\treqType;\t/* input extension major code\t*/\n    CARD8\tReqType;        /* always X_UnGrabDevice\t*/\n    CARD16\tlength B16;\n    Time\ttime B32;\n    CARD8\tdeviceid;\n    BYTE\tpad1, pad2, pad3;\n} xUngrabDeviceReq;\n\n/*********************************************************\n *\n * GrabDeviceKey.\n *\n */\n\ntypedef struct {\n    CARD8\treqType;\t/* input extension major code\t*/\n    CARD8\tReqType;        /* always X_GrabDeviceKey\t*/\n    CARD16\tlength B16;\n    Window\tgrabWindow B32;\n    CARD16\tevent_count B16;\n    CARD16\tmodifiers B16;\n    CARD8\tmodifier_device;\n    CARD8\tgrabbed_device;\n    CARD8\tkey;\n    BYTE\tthis_device_mode;\n    BYTE\tother_devices_mode;\n    BOOL\townerEvents;\n    BYTE\tpad1, pad2;\n} xGrabDeviceKeyReq;\n\n/*********************************************************\n *\n * UngrabDeviceKey.\n *\n */\n\ntypedef struct {\n    CARD8\treqType;\t/* input extension major code\t*/\n    CARD8\tReqType;        /* always X_UngrabDeviceKey\t*/\n    CARD16\tlength B16;\n    Window\tgrabWindow B32;\n    CARD16\tmodifiers B16;\n    CARD8\tmodifier_device;\n    CARD8\tkey;\n    CARD8\tgrabbed_device;\n    BYTE\tpad1, pad2, pad3;\n} xUngrabDeviceKeyReq;\n\n/*********************************************************\n *\n * GrabDeviceButton.\n *\n */\n\ntypedef struct {\n    CARD8\treqType;\t/* input extension major code\t*/\n    CARD8\tReqType;        /* always X_GrabDeviceButton\t*/\n    CARD16\tlength B16;\n    Window\tgrabWindow B32;\n    CARD8\tgrabbed_device;\n    CARD8\tmodifier_device;\n    CARD16\tevent_count B16;\n    CARD16\tmodifiers B16;\n    BYTE\tthis_device_mode;\n    BYTE\tother_devices_mode;\n    CARD8\tbutton;\n    BOOL\townerEvents;\n    BYTE\tpad1, pad2;\n} xGrabDeviceButtonReq;\n\n/*********************************************************\n *\n * UngrabDeviceButton.\n *\n */\n\ntypedef struct {\n    CARD8\treqType;\t/* input extension major code\t*/\n    CARD8\tReqType;        /* always X_UngrabDeviceButton\t*/\n    CARD16\tlength B16;\n    Window\tgrabWindow B32;\n    CARD16\tmodifiers B16;\n    CARD8\tmodifier_device;\n    CARD8\tbutton;\n    CARD8\tgrabbed_device;\n    BYTE\tpad1, pad2, pad3;\n} xUngrabDeviceButtonReq;\n\n/*********************************************************\n *\n * AllowDeviceEvents.\n *\n */\n\ntypedef struct {\n    CARD8\treqType;\t/* input extension major code\t*/\n    CARD8\tReqType;        /* always X_AllowDeviceEvents\t*/\n    CARD16\tlength B16;\n    Time\ttime B32;\n    CARD8\tmode;\n    CARD8\tdeviceid;\n    BYTE\tpad1, pad2;\n} xAllowDeviceEventsReq;\n\n/*********************************************************\n *\n * GetDeviceFocus.\n *\n */\n\ntypedef struct {\n    CARD8\treqType;        /* input extension major code   */\n    CARD8\tReqType;        /* always X_GetDeviceFocus\t*/\n    CARD16\tlength B16;\n    CARD8\tdeviceid;\n    BYTE\tpad1, pad2, pad3;\n} xGetDeviceFocusReq;\n\ntypedef struct {\n    CARD8\trepType;\t/* X_Reply\t\t\t*/\n    CARD8\tRepType;        /* always X_GetDeviceFocus\t*/\n    CARD16\tsequenceNumber B16;\n    CARD32\tlength B32;\n    CARD32\tfocus B32;\n    Time\ttime B32;\n    CARD8\trevertTo;\n    BYTE\tpad1, pad2, pad3;\n    CARD32\tpad01 B32;\n    CARD32\tpad02 B32;\n    CARD32\tpad03 B32;\n    } xGetDeviceFocusReply;\n\n/*********************************************************\n *\n * SetDeviceFocus.\n *\n */\n\ntypedef struct {\n    CARD8\treqType;        /* input extension major code   */\n    CARD8\tReqType;        /* always X_SetDeviceFocus\t*/\n    CARD16\tlength B16;\n    Window\tfocus B32;\n    Time\ttime B32;\n    CARD8\trevertTo;\n    CARD8\tdevice;\n    CARD16\tpad01 B16;\n} xSetDeviceFocusReq;\n\n/*********************************************************\n *\n * GetFeedbackControl.\n *\n */\n\ntypedef struct {\n    CARD8\treqType;\t/* input extension major code\t*/\n    CARD8\tReqType;        /* X_GetFeedbackControl\t*/\n    CARD16\tlength B16;\n    CARD8\tdeviceid;\n    BYTE\tpad1, pad2, pad3;\n} xGetFeedbackControlReq;\n\ntypedef struct {\n    CARD8\trepType;\t/* X_Reply\t\t\t*/\n    CARD8\tRepType;        /* always X_GetFeedbackControl\t*/\n    CARD16\tsequenceNumber B16;\n    CARD32\tlength B32;\n    CARD16\tnum_feedbacks B16;\n    CARD16\tpad01 B16;\n    CARD32\tpad02 B32;\n    CARD32\tpad03 B32;\n    CARD32\tpad04 B32;\n    CARD32\tpad05 B32;\n    CARD32\tpad06 B32;\n} xGetFeedbackControlReply;\n\ntypedef struct {\n#if defined(__cplusplus) || defined(c_plusplus)\n    CARD8\tc_class;\t/* feedback class\t\t*/\n#else\n    CARD8\tclass;\t\t/* feedback class\t\t*/\n#endif\n    CARD8\tid;\t\t/* feedback id\t\t*/\n    CARD16\tlength B16;\t/* feedback length\t\t*/\n} xFeedbackState;\n\ntypedef struct {\n#if defined(__cplusplus) || defined(c_plusplus)\n    CARD8   c_class;\n#else\n    CARD8   class;\n#endif\n    CARD8   id;\n    CARD16  length B16;\n    CARD16  pitch B16;\n    CARD16  duration B16;\n    CARD32  led_mask B32;\n    CARD32  led_values B32;\n    BOOL    global_auto_repeat;\n    CARD8   click;\n    CARD8   percent;\n    BYTE    pad;\n    BYTE    auto_repeats[32];\n} xKbdFeedbackState;\n\ntypedef struct {\n#if defined(__cplusplus) || defined(c_plusplus)\n    CARD8   c_class;\n#else\n    CARD8   class;\n#endif\n    CARD8   id;\n    CARD16  length B16;\n    CARD8   pad1,pad2;\n    CARD16  accelNum B16;\n    CARD16  accelDenom B16;\n    CARD16  threshold B16;\n} xPtrFeedbackState;\n\ntypedef struct {\n#if defined(__cplusplus) || defined(c_plusplus)\n    CARD8\tc_class;\t/* feedback class id\t\t*/\n#else\n    CARD8\tclass;\t\t/* feedback class id\t\t*/\n#endif\n    CARD8\tid;\n    CARD16\tlength B16;\t/* feedback length\t\t*/\n    CARD32\tresolution B32;\n    INT32\tmin_value B32;\n    INT32\tmax_value B32;\n} xIntegerFeedbackState;\n\ntypedef struct {\n#if defined(__cplusplus) || defined(c_plusplus)\n    CARD8\tc_class;\t/* feedback class id\t\t*/\n#else\n    CARD8\tclass;\t\t/* feedback class id\t\t*/\n#endif\n    CARD8\tid;\n    CARD16\tlength B16;\t/* feedback length\t\t*/\n    CARD16\tmax_symbols B16;\n    CARD16\tnum_syms_supported B16;\n} xStringFeedbackState;\n\ntypedef struct {\n#if defined(__cplusplus) || defined(c_plusplus)\n    CARD8\tc_class;\t/* feedback class id\t\t*/\n#else\n    CARD8\tclass;\t\t/* feedback class id\t\t*/\n#endif\n    CARD8\tid;\n    CARD16\tlength B16;\t/* feedback length\t\t*/\n    CARD8\tpercent;\n    BYTE\tpad1, pad2, pad3;\n    CARD16\tpitch B16;\n    CARD16\tduration B16;\n} xBellFeedbackState;\n\ntypedef struct {\n#if defined(__cplusplus) || defined(c_plusplus)\n    CARD8\tc_class;\t/* feedback class id\t\t*/\n#else\n    CARD8\tclass;\t\t/* feedback class id\t\t*/\n#endif\n    CARD8\tid;\n    CARD16\tlength B16;\t/* feedback length\t\t*/\n    CARD32\tled_mask B32;\n    CARD32\tled_values B32;\n} xLedFeedbackState;\n\n/*********************************************************\n *\n * ChangeFeedbackControl.\n *\n */\n\ntypedef struct {\n    CARD8\treqType;\t/* input extension major code\t*/\n    CARD8\tReqType;        /* X_ChangeFeedbackControl\t*/\n    CARD16\tlength B16;\n    CARD32\tmask B32;\n    CARD8\tdeviceid;\n    CARD8\tfeedbackid;\n    BYTE\tpad1, pad2;\n} xChangeFeedbackControlReq;\n\ntypedef struct {\n#if defined(__cplusplus) || defined(c_plusplus)\n    CARD8\tc_class;\t/* feedback class id\t\t*/\n#else\n    CARD8\tclass;\t\t/* feedback class id\t\t*/\n#endif\n    CARD8\tid;\t\t/* feedback id\t\t*/\n    CARD16\tlength B16;\t/* feedback length\t\t*/\n} xFeedbackCtl;\n\ntypedef struct {\n#if defined(__cplusplus) || defined(c_plusplus)\n    CARD8\tc_class;\t/* feedback class id\t\t*/\n#else\n    CARD8\tclass;\t\t/* feedback class id\t\t*/\n#endif\n    CARD8\tid;\t\t/* feedback length\t\t*/\n    CARD16\tlength B16;\t/* feedback length\t\t*/\n    KeyCode\tkey;\n    CARD8\tauto_repeat_mode;\n    INT8\tclick;\n    INT8\tpercent;\n    INT16\tpitch B16;\n    INT16\tduration B16;\n    CARD32\tled_mask B32;\n    CARD32\tled_values B32;\n} xKbdFeedbackCtl;\n\ntypedef struct {\n#if defined(__cplusplus) || defined(c_plusplus)\n    CARD8\tc_class;\t/* feedback class id\t\t*/\n#else\n    CARD8\tclass;\t\t/* feedback class id\t\t*/\n#endif\n    CARD8\tid;\t\t/* feedback id\t\t*/\n    CARD16\tlength B16;\t/* feedback length\t\t*/\n    CARD8\tpad1,pad2;\n    INT16\tnum B16;\n    INT16\tdenom B16;\n    INT16\tthresh B16;\n} xPtrFeedbackCtl;\n\ntypedef struct {\n#if defined(__cplusplus) || defined(c_plusplus)\n    CARD8\tc_class;\t/* feedback class id\t\t*/\n#else\n    CARD8\tclass;\t\t/* feedback class id\t\t*/\n#endif\n    CARD8\tid;\t\t/* feedback id\t\t*/\n    CARD16\tlength B16;\t/* feedback length\t\t*/\n    INT32\tint_to_display B32;\n} xIntegerFeedbackCtl;\n\ntypedef struct {\n#if defined(__cplusplus) || defined(c_plusplus)\n    CARD8\tc_class;\t/* feedback class id\t\t*/\n#else\n    CARD8\tclass;\t\t/* feedback class id\t\t*/\n#endif\n    CARD8\tid;\t\t/* feedback id\t\t*/\n    CARD16\tlength B16;\t/* feedback length\t\t*/\n    CARD8\tpad1,pad2;\n    CARD16\tnum_keysyms B16;\n} xStringFeedbackCtl;\n\ntypedef struct {\n#if defined(__cplusplus) || defined(c_plusplus)\n    CARD8\tc_class;\t/* feedback class id\t\t*/\n#else\n    CARD8\tclass;\t\t/* feedback class id\t\t*/\n#endif\n    CARD8\tid;\t\t/* feedback id\t\t*/\n    CARD16\tlength B16;\t/* feedback length\t\t*/\n    INT8\tpercent;\n    BYTE\tpad1, pad2, pad3;\n    INT16\tpitch B16;\n    INT16\tduration B16;\n} xBellFeedbackCtl;\n\ntypedef struct {\n#if defined(__cplusplus) || defined(c_plusplus)\n    CARD8\tc_class;\t/* feedback class id\t\t*/\n#else\n    CARD8\tclass;\t\t/* feedback class id\t\t*/\n#endif\n    CARD8\tid;\t\t/* feedback id\t\t*/\n    CARD16\tlength B16;\t/* feedback length\t\t*/\n    CARD32\tled_mask B32;\n    CARD32\tled_values B32;\n} xLedFeedbackCtl;\n\n/*********************************************************\n *\n * GetDeviceKeyMapping.\n *\n */\n\ntypedef struct {\n    CARD8\treqType;        /* input extension major code   */\n    CARD8\tReqType;\t/* always X_GetDeviceKeyMapping */\n    CARD16\tlength B16;\n    CARD8\tdeviceid;\n    KeyCode\tfirstKeyCode;\n    CARD8\tcount;\n    BYTE\tpad1;\n} xGetDeviceKeyMappingReq;\n\ntypedef struct {\n    CARD8\trepType;\t/* X_Reply\t\t\t*/\n    CARD8\tRepType;\t/* always X_GetDeviceKeyMapping */\n    CARD16\tsequenceNumber B16;\n    CARD32\tlength B32;\n    CARD8\tkeySymsPerKeyCode;\n    CARD8\tpad0;\n    CARD16\tpad1 B16;\n    CARD32\tpad2 B32;\n    CARD32\tpad3 B32;\n    CARD32\tpad4 B32;\n    CARD32\tpad5 B32;\n    CARD32\tpad6 B32;\n} xGetDeviceKeyMappingReply;\n\n/*********************************************************\n *\n * ChangeDeviceKeyMapping.\n *\n */\n\ntypedef struct {\n    CARD8\treqType;        /* input extension major code   */\n    CARD8\tReqType;        /* always X_ChangeDeviceKeyMapping */\n    CARD16\tlength B16;\n    CARD8\tdeviceid;\n    KeyCode\tfirstKeyCode;\n    CARD8\tkeySymsPerKeyCode;\n    CARD8\tkeyCodes;\n} xChangeDeviceKeyMappingReq;\n\n/*********************************************************\n *\n * GetDeviceModifierMapping.\n *\n */\n\ntypedef struct {\n    CARD8\treqType;        /* input extension major code   */\n    CARD8\tReqType;        /* always X_GetDeviceModifierMapping */\n    CARD16\tlength B16;\n    CARD8\tdeviceid;\n    BYTE\tpad1, pad2, pad3;\n} xGetDeviceModifierMappingReq;\n\ntypedef struct {\n    CARD8\trepType;\t/* X_Reply */\n    CARD8\tRepType;        /* always X_GetDeviceModifierMapping */\n    CARD16\tsequenceNumber B16;\n    CARD32\tlength B32;\n    CARD8\tnumKeyPerModifier;\n    CARD8\tpad0;\n    CARD16\tpad1 B16;\n    CARD32\tpad2 B32;\n    CARD32\tpad3 B32;\n    CARD32\tpad4 B32;\n    CARD32\tpad5 B32;\n    CARD32\tpad6 B32;\n} xGetDeviceModifierMappingReply;\n\n/*********************************************************\n *\n * SetDeviceModifierMapping.\n *\n */\n\ntypedef struct {\n    CARD8\treqType;        /* input extension major code   */\n    CARD8\tReqType;        /* always X_SetDeviceModifierMapping */\n    CARD16\tlength B16;\n    CARD8\tdeviceid;\n    CARD8\tnumKeyPerModifier;\n    CARD16\tpad1 B16;\n} xSetDeviceModifierMappingReq;\n\ntypedef struct {\n    CARD8\trepType;\t/* X_Reply */\n    CARD8\tRepType;        /* always X_SetDeviceModifierMapping */\n    CARD16\tsequenceNumber B16;\n    CARD32\tlength B32;\n    CARD8\tsuccess;\n    CARD8\tpad0;\n    CARD16\tpad1 B16;\n    CARD32\tpad2 B32;\n    CARD32\tpad3 B32;\n    CARD32\tpad4 B32;\n    CARD32\tpad5 B32;\n    CARD32\tpad6 B32;\n} xSetDeviceModifierMappingReply;\n\n/*********************************************************\n *\n * GetDeviceButtonMapping.\n *\n */\n\ntypedef struct {\n    CARD8\treqType;\t/* input extension major code\t*/\n    CARD8\tReqType;        /* X_GetDeviceButtonMapping     */\n    CARD16\tlength B16;\n    CARD8\tdeviceid;\n    BYTE\tpad1, pad2, pad3;\n} xGetDeviceButtonMappingReq;\n\ntypedef struct {\n    CARD8\trepType;\t/* X_Reply */\n    CARD8\tRepType;        /* always X_GetDeviceButtonMapping */\n    CARD16\tsequenceNumber B16;\n    CARD32\tlength B32;\n    CARD8\tnElts;\n    BYTE\tpad1, pad2, pad3;\n    CARD32\tpad01 B32;\n    CARD32\tpad02 B32;\n    CARD32\tpad03 B32;\n    CARD32\tpad04 B32;\n    CARD32\tpad05 B32;\n} xGetDeviceButtonMappingReply;\n\n/*********************************************************\n *\n * SetDeviceButtonMapping.\n *\n */\n\ntypedef struct {\n    CARD8\treqType;\t/* input extension major code\t*/\n    CARD8\tReqType;        /* X_SetDeviceButtonMapping     */\n    CARD16\tlength B16;\n    CARD8\tdeviceid;\n    CARD8\tmap_length;\n    BYTE\tpad1, pad2;\n} xSetDeviceButtonMappingReq;\n\ntypedef struct {\n    CARD8\trepType;\t\t/* X_Reply */\n    CARD8\tRepType;\t/* always X_SetDeviceButtonMapping */\n    CARD16\tsequenceNumber B16;\n    CARD32\tlength B32;\n    CARD8\tstatus;\n    BYTE\tpad0;\n    CARD16\tpad1 B16;\n    CARD32\tpad2 B32;\n    CARD32\tpad3 B32;\n    CARD32\tpad4 B32;\n    CARD32\tpad5 B32;\n    CARD32\tpad6 B32;\n} xSetDeviceButtonMappingReply;\n\n/*********************************************************\n *\n * QueryDeviceState.\n *\n */\n\ntypedef struct {\n    CARD8\treqType;\n    CARD8\tReqType;        /* always X_QueryDeviceState */\n    CARD16\tlength B16;\n    CARD8\tdeviceid;\n    BYTE\tpad1, pad2, pad3;\n} xQueryDeviceStateReq;\n\ntypedef struct {\n    CARD8\trepType;\t\t/* X_Reply */\n    CARD8\tRepType;\t/* always X_QueryDeviceState\t*/\n    CARD16\tsequenceNumber B16;\n    CARD32\tlength B32;\n    CARD8\tnum_classes;\n    BYTE\tpad0;\n    CARD16\tpad1 B16;\n    CARD32\tpad2 B32;\n    CARD32\tpad3 B32;\n    CARD32\tpad4 B32;\n    CARD32\tpad5 B32;\n    CARD32\tpad6 B32;\n} xQueryDeviceStateReply;\n\ntypedef struct {\n#if defined(__cplusplus) || defined(c_plusplus)\n    CARD8\tc_class;\n#else\n    CARD8\tclass;\n#endif\n    CARD8\tlength;\n    CARD8\tnum_keys;\n    BYTE\tpad1;\n    CARD8\tkeys[32];\n} xKeyState;\n\ntypedef struct {\n#if defined(__cplusplus) || defined(c_plusplus)\n    CARD8\tc_class;\n#else\n    CARD8\tclass;\n#endif\n    CARD8\tlength;\n    CARD8\tnum_buttons;\n    BYTE\tpad1;\n    CARD8\tbuttons[32];\n} xButtonState;\n\ntypedef struct {\n#if defined(__cplusplus) || defined(c_plusplus)\n    CARD8\tc_class;\n#else\n    CARD8\tclass;\n#endif\n    CARD8\tlength;\n    CARD8\tnum_valuators;\n    CARD8\tmode;\n} xValuatorState;\n\n/*********************************************************\n *\n * SendExtensionEvent.\n * THIS REQUEST MUST BE KEPT A MULTIPLE OF 8 BYTES IN LENGTH!\n * MORE EVENTS MAY FOLLOW AND THEY MUST BE QUAD-ALIGNED!\n *\n */\n\ntypedef struct {\n    CARD8\treqType;\n    CARD8\tReqType;        /* always X_SendExtensionEvent */\n    CARD16\tlength B16;\n    Window\tdestination B32;\n    CARD8\tdeviceid;\n    BOOL\tpropagate;\n    CARD16\tcount B16;\n    CARD8\tnum_events;\n    BYTE\tpad1,pad2,pad3;\n} xSendExtensionEventReq;\n\n/*********************************************************\n *\n * DeviceBell.\n *\n */\n\ntypedef struct {\n    CARD8\treqType;\n    CARD8\tReqType;        /* always X_DeviceBell */\n    CARD16\tlength B16;\n    CARD8\tdeviceid;\n    CARD8\tfeedbackid;\n    CARD8\tfeedbackclass;\n    INT8\tpercent;\n} xDeviceBellReq;\n\n/*********************************************************\n *\n * SetDeviceValuators.\n *\n */\n\ntypedef struct {\n    CARD8\treqType;\t/* input extension major code\t*/\n    CARD8\tReqType;\t/* always X_SetDeviceValuators\t*/\n    CARD16\tlength B16;\n    CARD8       deviceid;\n    CARD8       first_valuator;\n    CARD8       num_valuators;\n    BYTE\tpad1;\n} xSetDeviceValuatorsReq;\n\ntypedef struct {\n    CARD8\trepType;\t/* X_Reply\t\t\t*/\n    CARD8\tRepType;\t/* always X_SetDeviceValuators\t*/\n    CARD16\tsequenceNumber B16;\n    CARD32\tlength B32;\n    CARD8\tstatus;\n    BYTE\tpad1, pad2, pad3;\n    CARD32\tpad01 B32;\n    CARD32\tpad02 B32;\n    CARD32\tpad03 B32;\n    CARD32\tpad04 B32;\n    CARD32\tpad05 B32;\n} xSetDeviceValuatorsReply;\n\n/*********************************************************\n *\n * GetDeviceControl.\n *\n */\n\ntypedef struct {\n    CARD8\treqType;\t/* input extension major code\t*/\n    CARD8\tReqType;\t/* always X_GetDeviceControl\t*/\n    CARD16\tlength B16;\n    CARD16      control B16;\n    CARD8       deviceid;\n    BYTE\tpad2;\n} xGetDeviceControlReq;\n\ntypedef struct {\n    CARD8\trepType;\t/* X_Reply\t\t\t*/\n    CARD8\tRepType;\t/* always X_GetDeviceControl\t*/\n    CARD16\tsequenceNumber B16;\n    CARD32\tlength B32;\n    CARD8\tstatus;\n    BYTE\tpad1, pad2, pad3;\n    CARD32\tpad01 B32;\n    CARD32\tpad02 B32;\n    CARD32\tpad03 B32;\n    CARD32\tpad04 B32;\n    CARD32\tpad05 B32;\n} xGetDeviceControlReply;\n\ntypedef struct {\n    CARD16\tcontrol B16;\t/* control type\t\t*/\n    CARD16\tlength B16;\t/* control length\t\t*/\n} xDeviceState;\n\ntypedef struct {\n    CARD16\tcontrol B16;\t\t/* control type\t\t*/\n    CARD16\tlength B16;\t\t/* control length\t\t*/\n    CARD32\tnum_valuators B32;\t/* number of valuators\t\t*/\n} xDeviceResolutionState;\n\ntypedef struct {\n     CARD16         control B16;\n     CARD16         length B16;\n     INT32          min_x B32;\n     INT32          max_x B32;\n     INT32          min_y B32;\n     INT32          max_y B32;\n     CARD32         flip_x B32;\n     CARD32         flip_y B32;\n     CARD32         rotation B32;\n     CARD32         button_threshold B32;\n} xDeviceAbsCalibState;\n\ntypedef struct {\n     CARD16         control B16;\n     CARD16         length B16;\n     CARD32         offset_x B32;\n     CARD32         offset_y B32;\n     CARD32         width B32;\n     CARD32         height B32;\n     CARD32         screen B32;\n     CARD32         following B32;\n} xDeviceAbsAreaState;\n\ntypedef struct {\n    CARD16      control B16;            /* control type                 */\n    CARD16      length  B16;            /* control length               */\n    CARD8       status;\n    CARD8       iscore;\n    CARD16      pad1 B16;\n} xDeviceCoreState;\n\ntypedef struct {\n    CARD16      control B16;            /* control type                 */\n    CARD16      length  B16;            /* control length               */\n    CARD8       enable;\n    CARD8       pad0;\n    CARD16      pad1 B16;\n} xDeviceEnableState;\n\n/*********************************************************\n *\n * ChangeDeviceControl.\n *\n */\n\ntypedef struct {\n    CARD8\treqType;\t/* input extension major code\t*/\n    CARD8\tReqType;\t/* always X_ChangeDeviceControl */\n    CARD16\tlength B16;\n    CARD16      control B16;\n    CARD8       deviceid;\n    BYTE        pad0;\n} xChangeDeviceControlReq;\n\ntypedef struct {\n    CARD8\trepType;\t/* X_Reply\t\t\t*/\n    CARD8\tRepType;\t/* always X_ChangeDeviceControl\t*/\n    CARD16\tsequenceNumber B16;\n    CARD32\tlength B32;\n    CARD8\tstatus;\n    BYTE\tpad1, pad2, pad3;\n    CARD32\tpad01 B32;\n    CARD32\tpad02 B32;\n    CARD32\tpad03 B32;\n    CARD32\tpad04 B32;\n    CARD32\tpad05 B32;\n} xChangeDeviceControlReply;\n\ntypedef struct {\n    CARD16\tcontrol B16;\t/* control type\t\t*/\n    CARD16\tlength B16;\t/* control length\t\t*/\n} xDeviceCtl;\n\ntypedef struct {\n    CARD16\tcontrol B16;\t\t/* control type\t\t*/\n    CARD16\tlength B16;\t\t/* control length\t\t*/\n    CARD8\tfirst_valuator;\t\t/* first valuator to change     */\n    CARD8\tnum_valuators;\t\t/* number of valuators to change*/\n    CARD8\tpad1,pad2;\n} xDeviceResolutionCtl;\n\ntypedef struct {\n     CARD16         control B16;\n     CARD16         length B16;\n     INT32          min_x;\n     INT32          max_x;\n     INT32          min_y;\n     INT32          max_y;\n     CARD32         flip_x;\n     CARD32         flip_y;\n     CARD32         rotation;\n     CARD32         button_threshold;\n} xDeviceAbsCalibCtl;\n\ntypedef struct {\n     CARD16         control B16;\n     CARD16         length B16;\n     CARD32         offset_x;\n     CARD32         offset_y;\n     INT32          width;\n     INT32          height;\n     INT32          screen;\n     CARD32         following;\n} xDeviceAbsAreaCtl;\n\ntypedef struct {\n    CARD16          control B16;\n    CARD16          length  B16;\n    CARD8           status;\n    CARD8           pad0;\n    CARD16          pad1 B16;\n} xDeviceCoreCtl;\n\ntypedef struct {\n    CARD16          control B16;\n    CARD16          length  B16;\n    CARD8           enable;\n    CARD8           pad0;\n    CARD16          pad1 B16;\n} xDeviceEnableCtl;\n\n/* XI 1.5 */\n\n/*********************************************************\n *\n * ListDeviceProperties.\n *\n */\n\ntypedef struct {\n    CARD8       reqType;        /* input extension major opcode */\n    CARD8       ReqType;        /* always X_ListDeviceProperties */\n    CARD16      length B16;\n    CARD8       deviceid;\n    CARD8       pad0;\n    CARD16      pad1 B16;\n} xListDevicePropertiesReq;\n\ntypedef struct {\n    CARD8       repType;        /* X_Reply                       */\n    CARD8       RepType;        /* always X_ListDeviceProperties */\n    CARD16      sequenceNumber B16;\n    CARD32      length B32;\n    CARD16      nAtoms B16;\n    CARD16      pad1 B16;\n    CARD32      pad2 B32;\n    CARD32      pad3 B32;\n    CARD32      pad4 B32;\n    CARD32      pad5 B32;\n    CARD32      pad6 B32;\n} xListDevicePropertiesReply;\n\n/*********************************************************\n *\n * ChangeDeviceProperty.\n *\n */\n\ntypedef struct {\n    CARD8       reqType;        /* input extension major opcode */\n    CARD8       ReqType;        /* always X_ChangeDeviceProperty */\n    CARD16      length B16;\n    Atom        property B32;\n    Atom        type B32;\n    CARD8       deviceid;\n    CARD8       format;\n    CARD8       mode;\n    CARD8       pad;\n    CARD32      nUnits B32;\n} xChangeDevicePropertyReq;\n\n/*********************************************************\n *\n * DeleteDeviceProperty.\n *\n */\n\ntypedef struct {\n    CARD8       reqType;        /* input extension major opcode */\n    CARD8       ReqType;        /* always X_DeleteDeviceProperty */\n    CARD16      length B16;\n    Atom        property B32;\n    CARD8       deviceid;\n    CARD8       pad0;\n    CARD16      pad1 B16;\n} xDeleteDevicePropertyReq;\n\n/*********************************************************\n *\n * GetDeviceProperty.\n *\n */\n\ntypedef struct {\n    CARD8       reqType;        /* input extension major opcode */\n    CARD8       ReqType;        /* always X_GetDeviceProperty */\n    CARD16      length B16;\n    Atom        property B32;\n    Atom        type B32;\n    CARD32      longOffset B32;\n    CARD32      longLength B32;\n    CARD8       deviceid;\n#if defined(__cplusplus) || defined(c_plusplus)\n    BOOL        c_delete;\n#else\n    BOOL        delete;\n#endif\n    CARD16      pad;\n} xGetDevicePropertyReq;\n\ntypedef struct {\n    CARD8       repType;        /* X_Reply                        */\n    CARD8       RepType;        /* always X_GetDeviceProperty   */\n    CARD16      sequenceNumber B16;\n    CARD32      length B32;\n    Atom        propertyType B32;\n    CARD32      bytesAfter B32;\n    CARD32      nItems B32;\n    CARD8       format;\n    CARD8       deviceid;\n    CARD16      pad1 B16;\n    CARD32      pad2 B32;\n    CARD32      pad3 B32;\n} xGetDevicePropertyReply;\n\n\n/**********************************************************\n *\n * Input extension events.\n *\n * DeviceValuator\n *\n */\n\ntypedef struct\n    {\n    BYTE\ttype;\n    CARD8       deviceid;\n    CARD16\tsequenceNumber B16;\n    KeyButMask  device_state B16;\n    CARD8\tnum_valuators;\n    CARD8       first_valuator;\n    INT32\tvaluator0 B32;\n    INT32\tvaluator1 B32;\n    INT32\tvaluator2 B32;\n    INT32\tvaluator3 B32;\n    INT32\tvaluator4 B32;\n    INT32\tvaluator5 B32;\n    }  deviceValuator;\n\n/**********************************************************\n *\n * DeviceKeyButtonPointer.\n *\n * Used for: DeviceKeyPress, DeviceKeyRelease,\n *\t     DeviceButtonPress, DeviceButtonRelease,\n *\t     ProximityIn, ProximityOut\n *\t     DeviceMotionNotify,\n *\n */\n\ntypedef struct\n    {\n    BYTE\ttype;\n    BYTE        detail;\n    CARD16\tsequenceNumber B16;\n    Time        time B32;\n    Window      root B32;\n    Window      event B32;\n    Window      child B32;\n    INT16       root_x B16;\n    INT16       root_y B16;\n    INT16       event_x B16;\n    INT16       event_y B16;\n    KeyButMask  state B16;\n    BOOL        same_screen;\n    CARD8       deviceid;\n    }  deviceKeyButtonPointer;\n\n/**********************************************************\n *\n * DeviceFocus.\n *\n */\n\ntypedef struct\n    {\n    BYTE\ttype;\n    BYTE        detail;\n    CARD16\tsequenceNumber B16;\n    Time        time B32;\n    Window      window B32;\n    BYTE\tmode;\n    CARD8       deviceid;\n    BYTE\tpad1, pad2;\n    CARD32\tpad00 B32;\n    CARD32\tpad01 B32;\n    CARD32\tpad02 B32;\n    CARD32\tpad03 B32;\n    }  deviceFocus;\n\n/**********************************************************\n *\n * DeviceStateNotify.\n *\n * Note that the two high-order bits in the classes_reported\n * field are the proximity state (InProximity or OutOfProximity),\n * and the device mode (Absolute or Relative), respectively.\n *\n */\n\ntypedef struct\n    {\n    BYTE\ttype;\n    BYTE        deviceid;\n    CARD16\tsequenceNumber B16;\n    Time        time B32;\n    CARD8\tnum_keys;\n    CARD8\tnum_buttons;\n    CARD8\tnum_valuators;\n    CARD8       classes_reported;\n    CARD8       buttons[4];\n    CARD8       keys[4];\n    INT32\tvaluator0 B32;\n    INT32\tvaluator1 B32;\n    INT32\tvaluator2 B32;\n    }  deviceStateNotify;\n\n/**********************************************************\n *\n * DeviceKeyStateNotify.\n *\n */\n\ntypedef struct\n    {\n    BYTE\ttype;\n    BYTE        deviceid;\n    CARD16\tsequenceNumber B16;\n    CARD8       keys[28];\n    }  deviceKeyStateNotify;\n\n/**********************************************************\n *\n * DeviceButtonStateNotify.\n *\n */\n\ntypedef struct\n    {\n    BYTE\ttype;\n    BYTE        deviceid;\n    CARD16\tsequenceNumber B16;\n    CARD8       buttons[28];\n    }  deviceButtonStateNotify;\n\n/**********************************************************\n *\n * DeviceMappingNotify.\n * Fields must be kept in sync with core mappingnotify event.\n *\n */\n\ntypedef struct\n    {\n    BYTE\ttype;\n    BYTE        deviceid;\n    CARD16\tsequenceNumber B16;\n    CARD8       request;\n    KeyCode     firstKeyCode;\n    CARD8       count;\n    BYTE        pad1;\n    Time        time B32;\n    CARD32\tpad00 B32;\n    CARD32\tpad01 B32;\n    CARD32\tpad02 B32;\n    CARD32\tpad03 B32;\n    CARD32\tpad04 B32;\n    }  deviceMappingNotify;\n\n/**********************************************************\n *\n * ChangeDeviceNotify.\n *\n */\n\ntypedef struct\n    {\n    BYTE\ttype;\n    BYTE        deviceid;\n    CARD16\tsequenceNumber B16;\n    Time        time B32;\n    CARD8       request;\n    BYTE        pad1, pad2, pad3;\n    CARD32\tpad00 B32;\n    CARD32\tpad01 B32;\n    CARD32\tpad02 B32;\n    CARD32\tpad03 B32;\n    CARD32\tpad04 B32;\n    }  changeDeviceNotify;\n\n/**********************************************************\n *\n * devicePresenceNotify.\n *\n */\n\ntypedef struct\n    {\n    BYTE\ttype;\n    BYTE        pad00;\n    CARD16\tsequenceNumber B16;\n    Time        time B32;\n    BYTE        devchange; /* Device{Added|Removed|Enabled|Disabled|ControlChanged} */\n    BYTE        deviceid;\n    CARD16      control B16;\n    CARD32\tpad02 B32;\n    CARD32\tpad03 B32;\n    CARD32\tpad04 B32;\n    CARD32\tpad05 B32;\n    CARD32\tpad06 B32;\n    }  devicePresenceNotify;\n\n\n/*********************************************************\n * DevicePropertyNotifyEvent\n *\n * Sent whenever a device's property changes.\n *\n */\n\ntypedef struct\n    {\n    BYTE        type;\n    BYTE        state;               /* NewValue or Deleted */\n    CARD16      sequenceNumber B16;\n    CARD32      time B32;\n    Atom        atom B32;            /* affected property */\n    CARD32      pad0 B32;\n    CARD32      pad1 B32;\n    CARD32      pad2 B32;\n    CARD32      pad3 B32;\n    CARD16      pad5 B16;\n    CARD8       pad4;\n    CARD8       deviceid;            /* id of device */\n    } devicePropertyNotify;\n\n#undef Window\n#undef Time\n#undef KeyCode\n#undef Mask\n#undef Atom\n#undef Cursor\n\n#endif\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/X11/extensions/XKB.h",
    "content": "/************************************************************\nCopyright (c) 1993 by Silicon Graphics Computer Systems, Inc.\n\nPermission to use, copy, modify, and distribute this\nsoftware and its documentation for any purpose and without\nfee is hereby granted, provided that the above copyright\nnotice appear in all copies and that both that copyright\nnotice and this permission notice appear in supporting\ndocumentation, and that the name of Silicon Graphics not be \nused in advertising or publicity pertaining to distribution \nof the software without specific prior written permission.\nSilicon Graphics makes no representation about the suitability \nof this software for any purpose. It is provided \"as is\"\nwithout any express or implied warranty.\n\nSILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS \nSOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY \nAND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON\nGRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL \nDAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, \nDATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE \nOR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION  WITH\nTHE USE OR PERFORMANCE OF THIS SOFTWARE.\n\n********************************************************/\n\n#ifndef _XKB_H_\n#define\t_XKB_H_\n\n    /*\n     * XKB request codes, used in:\n     *  -  xkbReqType field of all requests\n     *  -  requestMinor field of some events\n     */\n#define\tX_kbUseExtension\t\t 0\n#define\tX_kbSelectEvents\t \t 1\n#define\tX_kbBell\t\t\t 3\n#define\tX_kbGetState\t\t\t 4\n#define\tX_kbLatchLockState\t\t 5\n#define\tX_kbGetControls\t\t\t 6\n#define\tX_kbSetControls\t\t\t 7\n#define\tX_kbGetMap\t\t\t 8\n#define\tX_kbSetMap\t\t\t 9\n#define\tX_kbGetCompatMap\t\t10\n#define\tX_kbSetCompatMap\t\t11\n#define\tX_kbGetIndicatorState\t\t12\n#define\tX_kbGetIndicatorMap\t\t13\n#define\tX_kbSetIndicatorMap\t\t14\n#define\tX_kbGetNamedIndicator\t\t15\n#define\tX_kbSetNamedIndicator\t\t16\n#define\tX_kbGetNames\t\t\t17\n#define\tX_kbSetNames\t\t\t18\n#define\tX_kbGetGeometry\t\t\t19\n#define\tX_kbSetGeometry\t\t\t20\n#define\tX_kbPerClientFlags\t\t21\n#define\tX_kbListComponents\t\t22\n#define\tX_kbGetKbdByName\t\t23\n#define\tX_kbGetDeviceInfo\t\t24\n#define\tX_kbSetDeviceInfo\t\t25\n#define\tX_kbSetDebuggingFlags\t\t101\n\n    /*\n     * In the X sense, XKB reports only one event.\n     * The type field of all XKB events is XkbEventCode\n     */\n#define\tXkbEventCode\t\t\t0\n#define\tXkbNumberEvents\t\t\t(XkbEventCode+1)\n\n    /*\n     * XKB has a minor event code so it can use one X event code for \n     * multiple purposes.  \n     *  - reported in the xkbType field of all XKB events.\n     *  - XkbSelectEventDetails: Indicates the event for which event details \n     *    are being changed\n     */\n#define\tXkbNewKeyboardNotify\t\t0\n#define XkbMapNotify\t\t\t1\n#define\tXkbStateNotify\t\t\t2\n#define XkbControlsNotify\t\t3\n#define\tXkbIndicatorStateNotify\t\t4\n#define\tXkbIndicatorMapNotify\t\t5\n#define\tXkbNamesNotify\t\t\t6\n#define XkbCompatMapNotify\t\t7\n#define\tXkbBellNotify\t\t\t8\n#define\tXkbActionMessage\t\t9\n#define\tXkbAccessXNotify\t\t10\n#define\tXkbExtensionDeviceNotify\t11\n\n    /*\n     * Event Mask:\n     *  - XkbSelectEvents:  Specifies event interest.\n     */\n#define\tXkbNewKeyboardNotifyMask\t(1L << 0)\n#define XkbMapNotifyMask\t\t(1L << 1)\n#define\tXkbStateNotifyMask\t\t(1L << 2)\n#define XkbControlsNotifyMask\t\t(1L << 3)\n#define\tXkbIndicatorStateNotifyMask\t(1L << 4)\n#define\tXkbIndicatorMapNotifyMask\t(1L << 5)\n#define\tXkbNamesNotifyMask\t\t(1L << 6)\n#define XkbCompatMapNotifyMask\t\t(1L << 7)\n#define\tXkbBellNotifyMask\t\t(1L << 8)\n#define\tXkbActionMessageMask\t\t(1L << 9)\n#define\tXkbAccessXNotifyMask\t\t(1L << 10)\n#define\tXkbExtensionDeviceNotifyMask\t(1L << 11)\n#define\tXkbAllEventsMask\t\t(0xFFF)\n\n    /*\n     * NewKeyboardNotify event details:\n     */\n#define\tXkbNKN_KeycodesMask\t\t(1L << 0)\n#define\tXkbNKN_GeometryMask\t\t(1L << 1)\n#define\tXkbNKN_DeviceIDMask\t\t(1L << 2)\n#define\tXkbAllNewKeyboardEventsMask\t(0x7)\n\n    /*\n     * AccessXNotify event types:\n     *  - The 'what' field of AccessXNotify events reports the\n     *    reason that the event was generated.\n     */\n#define\tXkbAXN_SKPress\t\t\t0\n#define\tXkbAXN_SKAccept\t\t\t1\n#define\tXkbAXN_SKReject\t\t\t2\n#define\tXkbAXN_SKRelease\t\t3\n#define\tXkbAXN_BKAccept\t\t\t4\n#define\tXkbAXN_BKReject\t\t\t5\n#define\tXkbAXN_AXKWarning\t\t6\n\n    /*\n     * AccessXNotify details:\n     * - Used as an event detail mask to limit the conditions under which\n     *   AccessXNotify events are reported\n     */\n#define\tXkbAXN_SKPressMask\t\t(1L << 0)\n#define\tXkbAXN_SKAcceptMask\t\t(1L << 1)\n#define\tXkbAXN_SKRejectMask\t\t(1L << 2)\n#define\tXkbAXN_SKReleaseMask\t\t(1L << 3)\n#define\tXkbAXN_BKAcceptMask\t\t(1L << 4)\n#define\tXkbAXN_BKRejectMask\t\t(1L << 5)\n#define\tXkbAXN_AXKWarningMask\t\t(1L << 6)\n#define\tXkbAllAccessXEventsMask\t\t(0x7f)\n\n    /*\n     * Miscellaneous event details:\n     * - event detail masks for assorted events that don't reall\n     *   have any details.\n     */\n#define\tXkbAllStateEventsMask\t\tXkbAllStateComponentsMask\n#define\tXkbAllMapEventsMask\t\tXkbAllMapComponentsMask\n#define\tXkbAllControlEventsMask\t\tXkbAllControlsMask\n#define\tXkbAllIndicatorEventsMask\tXkbAllIndicatorsMask\n#define\tXkbAllNameEventsMask\t\tXkbAllNamesMask\n#define\tXkbAllCompatMapEventsMask\tXkbAllCompatMask\n#define\tXkbAllBellEventsMask\t\t(1L << 0)\n#define\tXkbAllActionMessagesMask\t(1L << 0)\n\n    /*\n     * XKB reports one error:  BadKeyboard\n     * A further reason for the error is encoded into to most significant\n     * byte of the resourceID for the error:\n     *    XkbErr_BadDevice - the device in question was not found\n     *    XkbErr_BadClass  - the device was found but it doesn't belong to \n     *                       the appropriate class.\n     *    XkbErr_BadId     - the device was found and belongs to the right\n     *                       class, but not feedback with a matching id was\n     *                       found.\n     * The low byte of the resourceID for this error contains the device\n     * id, class specifier or feedback id that failed.\n     */\n#define\tXkbKeyboard\t\t\t0\n#define\tXkbNumberErrors\t\t\t1\n\n#define\tXkbErr_BadDevice\t0xff\n#define\tXkbErr_BadClass\t\t0xfe\n#define\tXkbErr_BadId\t\t0xfd\n\n    /*\n     * Keyboard Components Mask:\n     * - Specifies the components that follow a GetKeyboardByNameReply\n     */\n#define\tXkbClientMapMask\t\t(1L << 0)\n#define\tXkbServerMapMask\t\t(1L << 1)\n#define\tXkbCompatMapMask\t\t(1L << 2)\n#define\tXkbIndicatorMapMask\t\t(1L << 3)\n#define\tXkbNamesMask\t\t\t(1L << 4)\n#define\tXkbGeometryMask\t\t\t(1L << 5)\n#define\tXkbControlsMask\t\t\t(1L << 6)\n#define\tXkbAllComponentsMask\t\t(0x7f)\n\n    /*\n     * State detail mask:\n     *  - The 'changed' field of StateNotify events reports which of\n     *    the keyboard state components have changed.\n     *  - Used as an event detail mask to limit the conditions under\n     *    which StateNotify events are reported.\n     */\n#define\tXkbModifierStateMask\t\t(1L << 0)\n#define\tXkbModifierBaseMask\t\t(1L << 1)\n#define\tXkbModifierLatchMask\t\t(1L << 2)\n#define\tXkbModifierLockMask\t\t(1L << 3)\n#define\tXkbGroupStateMask\t\t(1L << 4)\n#define\tXkbGroupBaseMask\t\t(1L << 5)\n#define\tXkbGroupLatchMask\t\t(1L << 6)\n#define XkbGroupLockMask\t\t(1L << 7)\n#define\tXkbCompatStateMask\t\t(1L << 8)\n#define\tXkbGrabModsMask\t\t\t(1L << 9)\n#define\tXkbCompatGrabModsMask\t\t(1L << 10)\n#define\tXkbLookupModsMask\t\t(1L << 11)\n#define\tXkbCompatLookupModsMask\t\t(1L << 12)\n#define\tXkbPointerButtonMask\t\t(1L << 13)\n#define\tXkbAllStateComponentsMask\t(0x3fff)\n\n    /*\n     * Controls detail masks:\n     *  The controls specified in XkbAllControlsMask:\n     *  - The 'changed' field of ControlsNotify events reports which of \n     *    the keyboard controls have changed.\n     *  - The 'changeControls' field of the SetControls request specifies\n     *    the controls for which values are to be changed.\n     *  - Used as an event detail mask to limit the conditions under \n     *    which ControlsNotify events are reported.\n     *\n     *  The controls specified in the XkbAllBooleanCtrlsMask:\n     *  - The 'enabledControls' field of ControlsNotify events reports the\n     *    current status of the boolean controls.\n     *  - The 'enabledControlsChanges' field of ControlsNotify events reports\n     *    any boolean controls that have been turned on or off.\n     *  - The 'affectEnabledControls' and 'enabledControls' fields of the\n     *    kbSetControls request change the set of enabled controls.\n     *  - The 'accessXTimeoutMask' and 'accessXTimeoutValues' fields of\n     *    an XkbControlsRec specify the controls to be changed if the keyboard\n     *    times out and the values to which they should be changed.\n     *  - The 'autoCtrls' and 'autoCtrlsValues' fields of the PerClientFlags \n     *    request specifies the specify the controls to be reset when the\n     *    client exits and the values to which they should be reset.\n     *  - The 'ctrls' field of an indicator map specifies the controls\n     *    that drive the indicator.\n     *  - Specifies the boolean controls affected by the SetControls and\n     *    LockControls key actions.\n     */\n#define\tXkbRepeatKeysMask\t (1L << 0)\n#define\tXkbSlowKeysMask\t\t (1L << 1)\n#define\tXkbBounceKeysMask\t (1L << 2)\n#define\tXkbStickyKeysMask\t (1L << 3)\n#define\tXkbMouseKeysMask\t (1L << 4)\n#define\tXkbMouseKeysAccelMask\t (1L << 5)\n#define\tXkbAccessXKeysMask\t (1L << 6)\n#define\tXkbAccessXTimeoutMask\t (1L << 7)\n#define\tXkbAccessXFeedbackMask\t (1L << 8)\n#define\tXkbAudibleBellMask\t (1L << 9)\n#define\tXkbOverlay1Mask\t\t (1L << 10)\n#define\tXkbOverlay2Mask\t\t (1L << 11)\n#define\tXkbIgnoreGroupLockMask\t (1L << 12)\n#define\tXkbGroupsWrapMask\t (1L << 27)\n#define\tXkbInternalModsMask\t (1L << 28)\n#define\tXkbIgnoreLockModsMask\t (1L << 29)\n#define\tXkbPerKeyRepeatMask\t (1L << 30)\n#define\tXkbControlsEnabledMask\t (1L << 31)\n\n#define\tXkbAccessXOptionsMask    (XkbStickyKeysMask|XkbAccessXFeedbackMask)\n\n#define\tXkbAllBooleanCtrlsMask\t (0x00001FFF)\n#define\tXkbAllControlsMask\t (0xF8001FFF)\n#define\tXkbAllControlEventsMask\t XkbAllControlsMask\n\n    /*\n     * AccessX Options Mask\n     *  - The 'accessXOptions' field of an XkbControlsRec specifies the\n     *    AccessX options that are currently in effect.\n     *  - The 'accessXTimeoutOptionsMask' and 'accessXTimeoutOptionsValues'\n     *    fields of an XkbControlsRec specify the Access X options to be \n     *    changed if the keyboard times out and the values to which they \n     *    should be changed.\n     */\n#define\tXkbAX_SKPressFBMask\t(1L << 0)\n#define\tXkbAX_SKAcceptFBMask\t(1L << 1)\n#define\tXkbAX_FeatureFBMask\t(1L << 2)\n#define\tXkbAX_SlowWarnFBMask\t(1L << 3)\n#define\tXkbAX_IndicatorFBMask\t(1L << 4)\n#define\tXkbAX_StickyKeysFBMask\t(1L << 5)\n#define\tXkbAX_TwoKeysMask\t(1L << 6)\n#define\tXkbAX_LatchToLockMask\t(1L << 7)\n#define\tXkbAX_SKReleaseFBMask\t(1L << 8)\n#define\tXkbAX_SKRejectFBMask\t(1L << 9)\n#define\tXkbAX_BKRejectFBMask\t(1L << 10)\n#define\tXkbAX_DumbBellFBMask\t(1L << 11)\n#define\tXkbAX_FBOptionsMask\t(0xF3F)\n#define\tXkbAX_SKOptionsMask\t(0x0C0)\n#define\tXkbAX_AllOptionsMask\t(0xFFF)\n\n    /*\n     * XkbUseCoreKbd is used to specify the core keyboard without having\n     * \t\t\tto look up its X input extension identifier.\n     * XkbUseCorePtr is used to specify the core pointer without having\n     *\t\t\tto look up its X input extension identifier.\n     * XkbDfltXIClass is used to specify \"don't care\" any place that the\n     *\t\t\tXKB protocol is looking for an X Input Extension \n     *\t\t\tdevice class.\n     * XkbDfltXIId is used to specify \"don't care\" any place that the\n     *\t\t\tXKB protocol is looking for an X Input Extension\n     *\t\t\tfeedback identifier.\n     * XkbAllXIClasses is used to get information about all device indicators,\n     *\t\t\twhether they're part of the indicator feedback class\n     *\t\t\tor the keyboard feedback class.\n     * XkbAllXIIds is used to get information about all device indicator\n     *\t\t\tfeedbacks without having to list them.\n     * XkbXINone is used to indicate that no class or id has been specified.\n     * XkbLegalXILedClass(c)  True if 'c' specifies a legal class with LEDs\n     * XkbLegalXIBellClass(c) True if 'c' specifies a legal class with bells\n     * XkbExplicitXIDevice(d) True if 'd' explicitly specifies a device\n     * XkbExplicitXIClass(c)  True if 'c' explicitly specifies a device class\n     * XkbExplicitXIId(c)     True if 'i' explicitly specifies a device id\n     * XkbSingleXIClass(c)    True if 'c' specifies exactly one device class, \n     *                        including the default.\n     * XkbSingleXIId(i)       True if 'i' specifies exactly one device \n     *\t                      identifier, including the default.\n     */\n#define\tXkbUseCoreKbd\t\t0x0100\n#define\tXkbUseCorePtr\t\t0x0200\n#define\tXkbDfltXIClass\t\t0x0300\n#define\tXkbDfltXIId\t\t0x0400\n#define\tXkbAllXIClasses\t\t0x0500\n#define\tXkbAllXIIds\t\t0x0600\n#define\tXkbXINone\t\t0xff00\n\n#define\tXkbLegalXILedClass(c)\t(((c)==KbdFeedbackClass)||\\\n\t\t\t\t\t((c)==LedFeedbackClass)||\\\n\t\t\t\t\t((c)==XkbDfltXIClass)||\\\n\t\t\t\t\t((c)==XkbAllXIClasses))\n#define\tXkbLegalXIBellClass(c)\t(((c)==KbdFeedbackClass)||\\\n\t\t\t\t\t((c)==BellFeedbackClass)||\\\n\t\t\t\t\t((c)==XkbDfltXIClass)||\\\n\t\t\t\t\t((c)==XkbAllXIClasses))\n#define\tXkbExplicitXIDevice(c)\t(((c)&(~0xff))==0)\n#define\tXkbExplicitXIClass(c)\t(((c)&(~0xff))==0)\n#define\tXkbExplicitXIId(c)\t(((c)&(~0xff))==0)\n#define\tXkbSingleXIClass(c)\t((((c)&(~0xff))==0)||((c)==XkbDfltXIClass))\n#define\tXkbSingleXIId(c)\t((((c)&(~0xff))==0)||((c)==XkbDfltXIId))\n\n#define\tXkbNoModifier\t\t0xff\n#define\tXkbNoShiftLevel\t\t0xff\n#define\tXkbNoShape\t\t0xff\n#define\tXkbNoIndicator\t\t0xff\n\n#define\tXkbNoModifierMask\t0\n#define\tXkbAllModifiersMask\t0xff\n#define\tXkbAllVirtualModsMask\t0xffff\n\n#define\tXkbNumKbdGroups\t\t4\n#define\tXkbMaxKbdGroup\t\t(XkbNumKbdGroups-1)\n\n#define\tXkbMaxMouseKeysBtn\t4\n\n    /*\n     * Group Index and Mask:\n     *  - Indices into the kt_index array of a key type.\n     *  - Mask specifies types to be changed for XkbChangeTypesOfKey\n     */\n#define\tXkbGroup1Index\t\t0\n#define\tXkbGroup2Index\t\t1\n#define\tXkbGroup3Index\t\t2\n#define\tXkbGroup4Index\t\t3\n#define\tXkbAnyGroup\t\t254\n#define\tXkbAllGroups\t\t255\n\n#define\tXkbGroup1Mask\t\t(1<<0)\n#define\tXkbGroup2Mask\t\t(1<<1)\n#define\tXkbGroup3Mask\t\t(1<<2)\n#define\tXkbGroup4Mask\t\t(1<<3)\n#define\tXkbAnyGroupMask\t\t(1<<7)\n#define\tXkbAllGroupsMask\t(0xf)\n\n    /*\n     * BuildCoreState: Given a keyboard group and a modifier state,\n     *                 construct the value to be reported an event.\n     * GroupForCoreState:  Given the state reported in an event,\n     *                 determine the keyboard group.\n     * IsLegalGroup:   Returns TRUE if 'g' is a valid group index.\n     */\n#define\tXkbBuildCoreState(m,g)\t((((g)&0x3)<<13)|((m)&0xff))\n#define XkbGroupForCoreState(s)\t(((s)>>13)&0x3)\n#define\tXkbIsLegalGroup(g)\t(((g)>=0)&&((g)<XkbNumKbdGroups))\n\n    /*\n     * GroupsWrap values:\n     *  - The 'groupsWrap' field of an XkbControlsRec specifies the\n     *    treatment of out of range groups.\n     *  - Bits 6 and 7 of the group info field of a key symbol map\n     *    specify the interpretation of out of range groups for the\n     *    corresponding key.\n     */\n#define\tXkbWrapIntoRange\t(0x00)\n#define\tXkbClampIntoRange\t(0x40)\n#define\tXkbRedirectIntoRange\t(0x80)\n\n    /*\n     * Action flags:  Reported in the 'flags' field of most key actions.\n     * Interpretation depends on the type of the action; not all actions\n     * accept all flags.\n     *\n     * Option\t\t\tUsed for Actions\n     * ------\t\t\t----------------\n     * ClearLocks\t\tSetMods, LatchMods, SetGroup, LatchGroup\n     * LatchToLock\t\tSetMods, LatchMods, SetGroup, LatchGroup\n     * LockNoLock\t\tLockMods, ISOLock, LockPtrBtn, LockDeviceBtn\n     * LockNoUnlock\t\tLockMods, ISOLock, LockPtrBtn, LockDeviceBtn\n     * UseModMapMods\t\tSetMods, LatchMods, LockMods, ISOLock\n     * GroupAbsolute\t\tSetGroup, LatchGroup, LockGroup, ISOLock\n     * UseDfltButton\t\tPtrBtn, LockPtrBtn\n     * NoAcceleration\t\tMovePtr\n     * MoveAbsoluteX\t\tMovePtr\n     * MoveAbsoluteY\t\tMovePtr\n     * ISODfltIsGroup\t\tISOLock\n     * ISONoAffectMods\t\tISOLock\n     * ISONoAffectGroup\t\tISOLock\n     * ISONoAffectPtr\t\tISOLock\n     * ISONoAffectCtrls\t\tISOLock\n     * MessageOnPress\t\tActionMessage\n     * MessageOnRelease\t\tActionMessage\n     * MessageGenKeyEvent\tActionMessage\n     * AffectDfltBtn\t\tSetPtrDflt\n     * DfltBtnAbsolute\t\tSetPtrDflt\n     * SwitchApplication\tSwitchScreen\n     * SwitchAbsolute\t\tSwitchScreen\n     */\n\n#define\tXkbSA_ClearLocks\t(1L << 0)\n#define\tXkbSA_LatchToLock\t(1L << 1)\n\n#define\tXkbSA_LockNoLock\t(1L << 0)\n#define\tXkbSA_LockNoUnlock\t(1L << 1)\n\n#define\tXkbSA_UseModMapMods\t(1L << 2)\n\n#define\tXkbSA_GroupAbsolute\t(1L << 2)\n#define\tXkbSA_UseDfltButton\t0\n\n#define\tXkbSA_NoAcceleration\t(1L << 0)\n#define\tXkbSA_MoveAbsoluteX\t(1L << 1)\n#define\tXkbSA_MoveAbsoluteY\t(1L << 2)\n\n#define\tXkbSA_ISODfltIsGroup \t (1L << 7)\n#define\tXkbSA_ISONoAffectMods\t (1L << 6)\n#define\tXkbSA_ISONoAffectGroup\t (1L << 5)\n#define\tXkbSA_ISONoAffectPtr\t (1L << 4)\n#define\tXkbSA_ISONoAffectCtrls\t (1L << 3)\n#define\tXkbSA_ISOAffectMask\t (0x78)\n\n#define\tXkbSA_MessageOnPress\t (1L << 0)\n#define\tXkbSA_MessageOnRelease\t (1L << 1)\n#define\tXkbSA_MessageGenKeyEvent (1L << 2)\n\n#define\tXkbSA_AffectDfltBtn\t1\n#define\tXkbSA_DfltBtnAbsolute\t(1L << 2)\n\n#define\tXkbSA_SwitchApplication\t(1L << 0)\n#define\tXkbSA_SwitchAbsolute\t(1L << 2)\n\n    /*\n     * The following values apply to the SA_DeviceValuator \n     * action only.  Valuator operations specify the action \n     * to be taken.   Values specified in the action are \n     * multiplied by 2^scale before they are applied.\n     */\n#define\tXkbSA_IgnoreVal\t\t(0x00)\n#define\tXkbSA_SetValMin\t\t(0x10)\n#define\tXkbSA_SetValCenter\t(0x20)\n#define\tXkbSA_SetValMax\t\t(0x30)\n#define\tXkbSA_SetValRelative\t(0x40)\n#define\tXkbSA_SetValAbsolute\t(0x50)\n#define\tXkbSA_ValOpMask\t\t(0x70)\n#define\tXkbSA_ValScaleMask\t(0x07)\n#define\tXkbSA_ValOp(a)\t\t((a)&XkbSA_ValOpMask)\n#define\tXkbSA_ValScale(a)\t((a)&XkbSA_ValScaleMask)\n\n    /*\n     * Action types: specifies the type of a key action.  Reported in the\n     * type field of all key actions.\n     */\n#define\tXkbSA_NoAction\t\t0x00\n#define\tXkbSA_SetMods\t\t0x01\n#define\tXkbSA_LatchMods\t\t0x02\n#define\tXkbSA_LockMods\t\t0x03\n#define\tXkbSA_SetGroup\t\t0x04\n#define\tXkbSA_LatchGroup\t0x05\n#define\tXkbSA_LockGroup\t\t0x06\n#define\tXkbSA_MovePtr\t\t0x07\n#define\tXkbSA_PtrBtn\t\t0x08\n#define\tXkbSA_LockPtrBtn\t0x09\n#define\tXkbSA_SetPtrDflt\t0x0a\n#define\tXkbSA_ISOLock\t\t0x0b\n#define\tXkbSA_Terminate\t\t0x0c\n#define\tXkbSA_SwitchScreen\t0x0d\n#define\tXkbSA_SetControls\t0x0e\n#define\tXkbSA_LockControls\t0x0f\n#define\tXkbSA_ActionMessage\t0x10\n#define\tXkbSA_RedirectKey\t0x11\n#define\tXkbSA_DeviceBtn\t\t0x12\n#define\tXkbSA_LockDeviceBtn\t0x13\n#define\tXkbSA_DeviceValuator\t0x14\n#define\tXkbSA_LastAction\tXkbSA_DeviceValuator\n#define\tXkbSA_NumActions\t(XkbSA_LastAction+1)\n\n#define\tXkbSA_XFree86Private\t0x86\n\n    /*\n     * Specifies the key actions that clear latched groups or modifiers.\n     */\n#define\tXkbSA_BreakLatch \\\n\t((1<<XkbSA_NoAction)|(1<<XkbSA_PtrBtn)|(1<<XkbSA_LockPtrBtn)|\\\n\t(1<<XkbSA_Terminate)|(1<<XkbSA_SwitchScreen)|(1<<XkbSA_SetControls)|\\\n\t(1<<XkbSA_LockControls)|(1<<XkbSA_ActionMessage)|\\\n\t(1<<XkbSA_RedirectKey)|(1<<XkbSA_DeviceBtn)|(1<<XkbSA_LockDeviceBtn))\n\t \n    /*\n     * Macros to classify key actions\n     */\n#define\tXkbIsModAction(a)\t(((a)->type>=Xkb_SASetMods)&&((a)->type<=XkbSA_LockMods))\n#define\tXkbIsGroupAction(a)\t(((a)->type>=XkbSA_SetGroup)&&((a)->type<=XkbSA_LockGroup))\n#define\tXkbIsPtrAction(a)\t(((a)->type>=XkbSA_MovePtr)&&((a)->type<=XkbSA_SetPtrDflt))\n\n\n    /*\n     * Key Behavior Qualifier:\n     *    KB_Permanent indicates that the behavior describes an unalterable\n     *    characteristic of the keyboard, not an XKB software-simulation of\n     *    the listed behavior.\n     * Key Behavior Types:  \n     *    Specifies the behavior of the underlying key.\n     */\n#define\tXkbKB_Permanent\t\t0x80\n#define\tXkbKB_OpMask\t\t0x7f\n\n#define\tXkbKB_Default\t\t0x00\n#define\tXkbKB_Lock\t\t0x01\n#define\tXkbKB_RadioGroup\t0x02\n#define\tXkbKB_Overlay1\t\t0x03\n#define\tXkbKB_Overlay2\t\t0x04\n\n#define\tXkbKB_RGAllowNone\t0x80\n\n    /*\n     * Various macros which describe the range of legal keycodes.\n     */\n#define\tXkbMinLegalKeyCode\t8\n#define\tXkbMaxLegalKeyCode\t255\n#define\tXkbMaxKeyCount\t\t(XkbMaxLegalKeyCode-XkbMinLegalKeyCode+1)\n#define\tXkbPerKeyBitArraySize\t((XkbMaxLegalKeyCode+1)/8)\n/* Seems kinda silly to check that an unsigned char is <= 255... */\n#define\tXkbIsLegalKeycode(k)\t((k)>=XkbMinLegalKeyCode)\n\n    /*\n     * Assorted constants and limits.\n     */\n#define\tXkbNumModifiers\t\t8\n#define\tXkbNumVirtualMods\t16\n#define\tXkbNumIndicators\t32\n#define\tXkbAllIndicatorsMask\t(0xffffffff)\n#define\tXkbMaxRadioGroups\t32\n#define\tXkbAllRadioGroupsMask\t(0xffffffff)\n#define\tXkbMaxShiftLevel\t63\n#define\tXkbMaxSymsPerKey\t(XkbMaxShiftLevel*XkbNumKbdGroups)\n#define\tXkbRGMaxMembers\t\t12\n#define\tXkbActionMessageLength\t6\n#define\tXkbKeyNameLength\t4\n#define\tXkbMaxRedirectCount\t8\n\n#define\tXkbGeomPtsPerMM\t\t10\n#define\tXkbGeomMaxColors\t32\n#define\tXkbGeomMaxLabelColors\t3\n#define\tXkbGeomMaxPriority\t255\n\n    /*\n     * Key Type index and mask for the four standard key types.\n     */\n#define\tXkbOneLevelIndex\t0\n#define\tXkbTwoLevelIndex\t1\n#define\tXkbAlphabeticIndex\t2\n#define\tXkbKeypadIndex\t\t3\n#define\tXkbLastRequiredType\tXkbKeypadIndex\n#define\tXkbNumRequiredTypes\t(XkbLastRequiredType+1)\n#define\tXkbMaxKeyTypes\t\t255\n\n#define\tXkbOneLevelMask\t\t(1<<0)\n#define\tXkbTwoLevelMask\t\t(1<<1)\n#define\tXkbAlphabeticMask\t(1<<2)\n#define\tXkbKeypadMask\t\t(1<<3)\n#define\tXkbAllRequiredTypes\t(0xf)\n\n#define\tXkbShiftLevel(n)\t((n)-1)\n#define\tXkbShiftLevelMask(n)\t(1<<((n)-1))\n\n    /*\n     * Extension name and version information\n     */\n#define\tXkbName \"XKEYBOARD\"\n#define\tXkbMajorVersion\t1\n#define\tXkbMinorVersion\t0\n\n    /*\n     * Explicit map components:\n     *  - Used in the 'explicit' field of an XkbServerMap.  Specifies\n     *    the keyboard components that should _not_ be updated automatically\n     *    in response to core protocol keyboard mapping requests.\n     */\n#define\tXkbExplicitKeyTypesMask\t  (0x0f)\n#define\tXkbExplicitKeyType1Mask\t  (1<<0)\n#define\tXkbExplicitKeyType2Mask\t  (1<<1)\n#define\tXkbExplicitKeyType3Mask\t  (1<<2)\n#define\tXkbExplicitKeyType4Mask\t  (1<<3)\n#define\tXkbExplicitInterpretMask  (1<<4)\n#define\tXkbExplicitAutoRepeatMask (1<<5)\n#define\tXkbExplicitBehaviorMask\t  (1<<6)\n#define\tXkbExplicitVModMapMask\t  (1<<7)\n#define\tXkbAllExplicitMask\t  (0xff)\n\n    /*\n     * Map components masks:\n     * Those in AllMapComponentsMask:\n     *  - Specifies the individual fields to be loaded or changed for the\n     *    GetMap and SetMap requests.\n     * Those in ClientInfoMask:\n     *  - Specifies the components to be allocated by XkbAllocClientMap.\n     * Those in ServerInfoMask:\n     *  - Specifies the components to be allocated by XkbAllocServerMap.\n     */\n#define\tXkbKeyTypesMask\t\t(1<<0)\n#define\tXkbKeySymsMask\t\t(1<<1)\n#define\tXkbModifierMapMask\t(1<<2)\n#define\tXkbExplicitComponentsMask (1<<3)\n#define XkbKeyActionsMask\t(1<<4)\n#define\tXkbKeyBehaviorsMask\t(1<<5)\n#define\tXkbVirtualModsMask\t(1<<6)\n#define\tXkbVirtualModMapMask\t(1<<7)\n\n#define\tXkbAllClientInfoMask\t(XkbKeyTypesMask|XkbKeySymsMask|XkbModifierMapMask)\n#define\tXkbAllServerInfoMask\t(XkbExplicitComponentsMask|XkbKeyActionsMask|XkbKeyBehaviorsMask|XkbVirtualModsMask|XkbVirtualModMapMask)\n#define\tXkbAllMapComponentsMask\t(XkbAllClientInfoMask|XkbAllServerInfoMask)\n\n    /*\n     * Symbol interpretations flags:\n     *  - Used in the flags field of a symbol interpretation\n     */\n#define\tXkbSI_AutoRepeat\t(1<<0)\n#define\tXkbSI_LockingKey\t(1<<1)\n\n    /*\n     * Symbol interpretations match specification:\n     *  - Used in the match field of a symbol interpretation to specify \n     *    the conditions under which an interpretation is used.\n     */\n#define\tXkbSI_LevelOneOnly\t(0x80)\n#define\tXkbSI_OpMask\t\t(0x7f)\n#define\tXkbSI_NoneOf\t\t(0)\n#define\tXkbSI_AnyOfOrNone\t(1)\n#define\tXkbSI_AnyOf\t\t(2)\n#define\tXkbSI_AllOf\t\t(3)\n#define\tXkbSI_Exactly\t\t(4)\n\n    /*\n     * Indicator map flags:\n     *  - Used in the flags field of an indicator map to indicate the\n     *    conditions under which and indicator can be changed and the\n     *    effects of changing the indicator.\n     */\n#define\tXkbIM_NoExplicit\t(1L << 7)\n#define\tXkbIM_NoAutomatic\t(1L << 6)\n#define\tXkbIM_LEDDrivesKB\t(1L << 5)\n\n    /*\n     * Indicator map component specifications:\n     *  - Used by the 'which_groups' and 'which_mods' fields of an indicator\n     *    map to specify which keyboard components should be used to drive\n     *    the indicator.\n     */\n#define\tXkbIM_UseBase\t\t(1L << 0)\n#define\tXkbIM_UseLatched\t(1L << 1)\n#define\tXkbIM_UseLocked\t\t(1L << 2)\n#define\tXkbIM_UseEffective\t(1L << 3)\n#define\tXkbIM_UseCompat\t\t(1L << 4)\n\n#define\tXkbIM_UseNone\t  0\n#define\tXkbIM_UseAnyGroup (XkbIM_UseBase|XkbIM_UseLatched|XkbIM_UseLocked\\\n                           |XkbIM_UseEffective)\n#define\tXkbIM_UseAnyMods  (XkbIM_UseAnyGroup|XkbIM_UseCompat)\n\n    /*\n     * Compatibility Map Compontents:\n     *  - Specifies the components to be allocated in XkbAllocCompatMap.\n     */\n#define\tXkbSymInterpMask\t(1<<0)\n#define\tXkbGroupCompatMask\t(1<<1)\n#define\tXkbAllCompatMask\t(0x3)\n\n    /*\n     * Names component mask:\n     *  - Specifies the names to be loaded or changed for the GetNames and\n     *    SetNames requests.\n     *  - Specifies the names that have changed in a NamesNotify event.\n     *  - Specifies the names components to be allocated by XkbAllocNames.\n     */\n#define\tXkbKeycodesNameMask\t(1<<0)\n#define\tXkbGeometryNameMask\t(1<<1)\n#define\tXkbSymbolsNameMask\t(1<<2)\n#define\tXkbPhysSymbolsNameMask\t(1<<3)\n#define\tXkbTypesNameMask\t(1<<4)\n#define\tXkbCompatNameMask \t(1<<5)\n#define\tXkbKeyTypeNamesMask\t(1<<6)\n#define\tXkbKTLevelNamesMask\t(1<<7)\n#define\tXkbIndicatorNamesMask\t(1<<8)\n#define\tXkbKeyNamesMask\t\t(1<<9)\n#define\tXkbKeyAliasesMask\t(1<<10)\n#define\tXkbVirtualModNamesMask\t(1<<11)\n#define\tXkbGroupNamesMask\t(1<<12)\n#define\tXkbRGNamesMask\t\t(1<<13)\n#define\tXkbComponentNamesMask\t(0x3f)\n#define\tXkbAllNamesMask\t\t(0x3fff)\n\n    /*\n     * GetByName components:\n     *  - Specifies desired or necessary components to GetKbdByName request.\n     *  - Reports the components that were found in a GetKbdByNameReply\n     */\n#define\tXkbGBN_TypesMask\t\t(1L << 0)\n#define\tXkbGBN_CompatMapMask\t\t(1L << 1)\n#define\tXkbGBN_ClientSymbolsMask\t(1L << 2)\n#define\tXkbGBN_ServerSymbolsMask\t(1L << 3)\n#define\tXkbGBN_SymbolsMask (XkbGBN_ClientSymbolsMask|XkbGBN_ServerSymbolsMask)\n#define\tXkbGBN_IndicatorMapMask\t\t(1L << 4)\n#define\tXkbGBN_KeyNamesMask\t\t(1L << 5)\n#define\tXkbGBN_GeometryMask\t\t(1L << 6)\n#define\tXkbGBN_OtherNamesMask\t\t(1L << 7)\n#define\tXkbGBN_AllComponentsMask\t(0xff)\n\n     /*\n      * ListComponents flags\n      */\n#define\tXkbLC_Hidden\t\t\t(1L <<  0)\n#define\tXkbLC_Default\t\t\t(1L <<  1)\n#define\tXkbLC_Partial\t\t\t(1L <<  2)\n\n#define\tXkbLC_AlphanumericKeys\t\t(1L <<  8)\n#define\tXkbLC_ModifierKeys\t\t(1L <<  9)\n#define\tXkbLC_KeypadKeys\t\t(1L << 10)\n#define\tXkbLC_FunctionKeys\t\t(1L << 11)\n#define\tXkbLC_AlternateGroup\t\t(1L << 12)\n\n    /*\n     * X Input Extension Interactions\n     * - Specifies the possible interactions between XKB and the X input\n     *   extension\n     * - Used to request (XkbGetDeviceInfo) or change (XKbSetDeviceInfo)\n     *   XKB information about an extension device.\n     * - Reports the list of supported optional features in the reply to\n     *   XkbGetDeviceInfo or in an XkbExtensionDeviceNotify event.\n     * XkbXI_UnsupportedFeature is reported in XkbExtensionDeviceNotify\n     * events to indicate an attempt to use an unsupported feature.\n     */\n#define\tXkbXI_KeyboardsMask\t\t(1L << 0)\n#define\tXkbXI_ButtonActionsMask\t\t(1L << 1)\n#define\tXkbXI_IndicatorNamesMask\t(1L << 2)\n#define\tXkbXI_IndicatorMapsMask\t\t(1L << 3)\n#define\tXkbXI_IndicatorStateMask\t(1L << 4)\n#define\tXkbXI_UnsupportedFeatureMask\t(1L << 15)\n#define\tXkbXI_AllFeaturesMask\t\t(0x001f)\n#define\tXkbXI_AllDeviceFeaturesMask\t(0x001e)\n\n#define\tXkbXI_IndicatorsMask\t\t(0x001c)\n#define\tXkbAllExtensionDeviceEventsMask (0x801f)\n\n    /*\n     * Per-Client Flags:\n     *  - Specifies flags to be changed by the PerClientFlags request.\n     */\n#define\tXkbPCF_DetectableAutoRepeatMask\t(1L << 0)\n#define\tXkbPCF_GrabsUseXKBStateMask\t(1L << 1)\n#define\tXkbPCF_AutoResetControlsMask\t(1L << 2)\n#define\tXkbPCF_LookupStateWhenGrabbed\t(1L << 3)\n#define\tXkbPCF_SendEventUsesXKBState\t(1L << 4)\n#define\tXkbPCF_AllFlagsMask\t\t(0x1F)\n\n    /*\n     * Debugging flags and controls\n     */\n#define\tXkbDF_DisableLocks\t(1<<0)\n\n#endif /* _XKB_H_ */\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/X11/extensions/XKBgeom.h",
    "content": "/************************************************************\nCopyright (c) 1993 by Silicon Graphics Computer Systems, Inc.\n\nPermission to use, copy, modify, and distribute this\nsoftware and its documentation for any purpose and without\nfee is hereby granted, provided that the above copyright\nnotice appear in all copies and that both that copyright\nnotice and this permission notice appear in supporting\ndocumentation, and that the name of Silicon Graphics not be \nused in advertising or publicity pertaining to distribution \nof the software without specific prior written permission.\nSilicon Graphics makes no representation about the suitability \nof this software for any purpose. It is provided \"as is\"\nwithout any express or implied warranty.\n\nSILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS \nSOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY \nAND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON\nGRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL \nDAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, \nDATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE \nOR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION  WITH\nTHE USE OR PERFORMANCE OF THIS SOFTWARE.\n\n********************************************************/\n\n#ifndef _XKBGEOM_H_\n#define\t_XKBGEOM_H_\n\n#include <X11/extensions/XKBstr.h>\n\n#ifdef XKB_IN_SERVER\n#define XkbAddGeomKeyAlias \t\tSrvXkbAddGeomKeyAlias\n#define XkbAddGeomColor \t\tSrvXkbAddGeomColor\n#define XkbAddGeomDoodad\t\tSrvXkbAddGeomDoodad\n#define XkbAddGeomKey\t\t\tSrvXkbAddGeomKey\n#define XkbAddGeomOutline\t\tSrvXkbAddGeomOutline\n#define XkbAddGeomOverlay\t\tSrvXkbAddGeomOverlay\n#define XkbAddGeomOverlayRow\t\tSrvXkbAddGeomOverlayRow\n#define\tXkbAddGeomOverlayKey\t\tSrvXkbAddGeomOverlayKey\n#define XkbAddGeomProperty\t\tSrvXkbAddGeomProperty\n#define XkbAddGeomRow\t\t\tSrvXkbAddGeomRow\n#define XkbAddGeomSection\t\tSrvXkbAddGeomSection\n#define XkbAddGeomShape\t\t\tSrvXkbAddGeomShape\n#define XkbAllocGeomKeyAliases\t\tSrvXkbAllocGeomKeyAliases\n#define XkbAllocGeomColors\t\tSrvXkbAllocGeomColors\n#define XkbAllocGeomDoodads\t\tSrvXkbAllocGeomDoodads\n#define XkbAllocGeomKeys\t\tSrvXkbAllocGeomKeys\n#define XkbAllocGeomOutlines\t\tSrvXkbAllocGeomOutlines\n#define XkbAllocGeomPoints\t\tSrvXkbAllocGeomPoints\n#define XkbAllocGeomProps\t\tSrvXkbAllocGeomProps\n#define XkbAllocGeomRows\t\tSrvXkbAllocGeomRows\n#define XkbAllocGeomSectionDoodads\tSrvXkbAllocGeomSectionDoodads\n#define XkbAllocGeomSections\t\tSrvXkbAllocGeomSections\n#define\tXkbAllocGeomOverlays\t\tSrvXkbAllocGeomOverlays\n#define\tXkbAllocGeomOverlayRows\t\tSrvXkbAllocGeomOverlayRows\n#define\tXkbAllocGeomOverlayKeys\t\tSrvXkbAllocGeomOverlayKeys\n#define XkbAllocGeomShapes\t\tSrvXkbAllocGeomShapes\n#define XkbAllocGeometry\t\tSrvXkbAllocGeometry\n#define XkbFreeGeomKeyAliases\t\tSrvXkbFreeGeomKeyAliases\n#define XkbFreeGeomColors\t\tSrvXkbFreeGeomColors\n#define XkbFreeGeomDoodads\t\tSrvXkbFreeGeomDoodads\n#define XkbFreeGeomProperties\t\tSrvXkbFreeGeomProperties\n#define\tXkbFreeGeomOverlayKeys\t\tSrvXkbFreeGeomOverlayKeys\n#define\tXkbFreeGeomOverlayRows\t\tSrvXkbFreeGeomOverlayRows\n#define\tXkbFreeGeomOverlays\t\tSrvXkbFreeGeomOverlays\n#define\tXkbFreeGeomKeys\t\t\tSrvXkbFreeGeomKeys\n#define\tXkbFreeGeomRows\t\t\tSrvXkbFreeGeomRows\n#define XkbFreeGeomSections\t\tSrvXkbFreeGeomSections\n#define\tXkbFreeGeomPoints\t\tSrvXkbFreeGeomPoints\n#define\tXkbFreeGeomOutlines\t\tSrvXkbFreeGeomOutlines\n#define XkbFreeGeomShapes\t\tSrvXkbFreeGeomShapes\n#define XkbFreeGeometry\t\t\tSrvXkbFreeGeometry\n#endif\n\ntypedef\tstruct _XkbProperty {\n\tchar\t*name;\n\tchar\t*value;\n} XkbPropertyRec,*XkbPropertyPtr;\n\ntypedef struct _XkbColor {\n\tunsigned int \tpixel;\n\tchar *\t\tspec;\n} XkbColorRec,*XkbColorPtr;\n\ntypedef\tstruct _XkbPoint {\n\tshort\tx;\n\tshort\ty;\n} XkbPointRec, *XkbPointPtr;\n\ntypedef struct\t_XkbBounds {\n\tshort\tx1,y1;\n\tshort\tx2,y2;\n} XkbBoundsRec, *XkbBoundsPtr;\n#define\tXkbBoundsWidth(b)\t(((b)->x2)-((b)->x1))\n#define\tXkbBoundsHeight(b)\t(((b)->y2)-((b)->y1))\n\ntypedef struct _XkbOutline {\n\tunsigned short\tnum_points;\n\tunsigned short\tsz_points;\n\tunsigned short\tcorner_radius;\n\tXkbPointPtr\tpoints;\n} XkbOutlineRec, *XkbOutlinePtr;\n\ntypedef struct _XkbShape {\n\tAtom\t \t name;\n\tunsigned short\t num_outlines;\n\tunsigned short\t sz_outlines;\n\tXkbOutlinePtr\t outlines;\n\tXkbOutlinePtr\t approx;\n\tXkbOutlinePtr\t primary;\n\tXkbBoundsRec\t bounds;\n} XkbShapeRec, *XkbShapePtr;\n#define\tXkbOutlineIndex(s,o)\t((int)((o)-&(s)->outlines[0]))\n\ntypedef struct _XkbShapeDoodad {\n\tAtom\t\t name;\n\tunsigned char\t type;\n\tunsigned char\t priority;\n\tshort\t\t top;\n\tshort\t\t left;\n\tshort\t \t angle;\n\tunsigned short\t color_ndx;\n\tunsigned short\t shape_ndx;\n} XkbShapeDoodadRec, *XkbShapeDoodadPtr;\n#define\tXkbShapeDoodadColor(g,d)\t(&(g)->colors[(d)->color_ndx])\n#define\tXkbShapeDoodadShape(g,d)\t(&(g)->shapes[(d)->shape_ndx])\n#define\tXkbSetShapeDoodadColor(g,d,c)\t((d)->color_ndx= (c)-&(g)->colors[0])\n#define\tXkbSetShapeDoodadShape(g,d,s)\t((d)->shape_ndx= (s)-&(g)->shapes[0])\n\ntypedef struct _XkbTextDoodad {\n\tAtom\t\t name;\n\tunsigned char\t type;\n\tunsigned char\t priority;\n\tshort\t \t top;\n\tshort\t \t left;\n\tshort\t \t angle;\n\tshort\t \t width;\n\tshort\t\t height;\n\tunsigned short\t color_ndx;\n\tchar *\t\t text;\n\tchar *\t\t font;\n} XkbTextDoodadRec, *XkbTextDoodadPtr;\n#define\tXkbTextDoodadColor(g,d)\t(&(g)->colors[(d)->color_ndx])\n#define\tXkbSetTextDoodadColor(g,d,c)\t((d)->color_ndx= (c)-&(g)->colors[0])\n\ntypedef struct _XkbIndicatorDoodad {\n\tAtom\t\t name;\n\tunsigned char\t type;\n\tunsigned char\t priority;\n\tshort\t \t top;\n\tshort\t \t left;\n\tshort\t\t angle;\n\tunsigned short\t shape_ndx;\n\tunsigned short\t on_color_ndx;\n\tunsigned short\t off_color_ndx;\n} XkbIndicatorDoodadRec, *XkbIndicatorDoodadPtr;\n#define\tXkbIndicatorDoodadShape(g,d)\t(&(g)->shapes[(d)->shape_ndx])\n#define\tXkbIndicatorDoodadOnColor(g,d)\t(&(g)->colors[(d)->on_color_ndx])\n#define\tXkbIndicatorDoodadOffColor(g,d)\t(&(g)->colors[(d)->off_color_ndx])\n#define\tXkbSetIndicatorDoodadOnColor(g,d,c) \\\n\t\t\t\t((d)->on_color_ndx= (c)-&(g)->colors[0])\n#define\tXkbSetIndicatorDoodadOffColor(g,d,c) \\\n\t\t\t\t((d)->off_color_ndx= (c)-&(g)->colors[0])\n#define\tXkbSetIndicatorDoodadShape(g,d,s) \\\n\t\t\t\t((d)->shape_ndx= (s)-&(g)->shapes[0])\n\ntypedef struct _XkbLogoDoodad {\n\tAtom\t\t name;\n\tunsigned char\t type;\n\tunsigned char\t priority;\n\tshort\t\t top;\n\tshort\t\t left;\n\tshort\t \t angle;\n\tunsigned short\t color_ndx;\n\tunsigned short\t shape_ndx;\n\tchar *\t\t logo_name;\n} XkbLogoDoodadRec, *XkbLogoDoodadPtr;\n#define\tXkbLogoDoodadColor(g,d)\t\t(&(g)->colors[(d)->color_ndx])\n#define\tXkbLogoDoodadShape(g,d)\t\t(&(g)->shapes[(d)->shape_ndx])\n#define\tXkbSetLogoDoodadColor(g,d,c)\t((d)->color_ndx= (c)-&(g)->colors[0])\n#define\tXkbSetLogoDoodadShape(g,d,s)\t((d)->shape_ndx= (s)-&(g)->shapes[0])\n\ntypedef struct _XkbAnyDoodad {\n\tAtom\t\t name;\n\tunsigned char\t type;\n\tunsigned char\t priority;\n\tshort\t \t top;\n\tshort\t \t left;\n\tshort\t\t angle;\n} XkbAnyDoodadRec, *XkbAnyDoodadPtr;\n\ntypedef union _XkbDoodad {\n\tXkbAnyDoodadRec\t\tany;\n\tXkbShapeDoodadRec\tshape;\n\tXkbTextDoodadRec\ttext;\n\tXkbIndicatorDoodadRec\tindicator;\n\tXkbLogoDoodadRec\tlogo;\n} XkbDoodadRec, *XkbDoodadPtr;\n\n#define\tXkbUnknownDoodad\t0\n#define\tXkbOutlineDoodad\t1\n#define\tXkbSolidDoodad\t\t2\n#define\tXkbTextDoodad\t\t3\n#define\tXkbIndicatorDoodad\t4\n#define\tXkbLogoDoodad\t\t5\n\ntypedef struct _XkbKey {\n\tXkbKeyNameRec\t name;\n\tshort\t\t gap;\n\tunsigned char\t shape_ndx;\n\tunsigned char\t color_ndx;\n} XkbKeyRec, *XkbKeyPtr;\n#define\tXkbKeyShape(g,k)\t(&(g)->shapes[(k)->shape_ndx])\n#define\tXkbKeyColor(g,k)\t(&(g)->colors[(k)->color_ndx])\n#define\tXkbSetKeyShape(g,k,s)\t((k)->shape_ndx= (s)-&(g)->shapes[0])\n#define\tXkbSetKeyColor(g,k,c)\t((k)->color_ndx= (c)-&(g)->colors[0])\n\ntypedef struct _XkbRow {\n\tshort\t \ttop;\n\tshort\t \tleft;\n\tunsigned short\tnum_keys;\n\tunsigned short\tsz_keys;\n\tint\t\tvertical;\n\tXkbKeyPtr\tkeys;\n\tXkbBoundsRec\tbounds;\n} XkbRowRec, *XkbRowPtr;\n\ntypedef struct _XkbSection {\n\tAtom\t\t name;\n\tunsigned char\t priority;\n\tshort\t \t top;\n\tshort\t \t left;\n\tunsigned short\t width;\n\tunsigned short\t height;\n\tshort\t \t angle;\n\tunsigned short\t num_rows;\n\tunsigned short\t num_doodads;\n\tunsigned short\t num_overlays;\n\tunsigned short\t sz_rows;\n\tunsigned short\t sz_doodads;\n\tunsigned short\t sz_overlays;\n\tXkbRowPtr\t rows;\n\tXkbDoodadPtr\t doodads;\n\tXkbBoundsRec\t bounds;\n\tstruct _XkbOverlay *overlays;\n} XkbSectionRec, *XkbSectionPtr;\n\ntypedef\tstruct _XkbOverlayKey {\n\tXkbKeyNameRec\tover;\n\tXkbKeyNameRec\tunder;\n} XkbOverlayKeyRec,*XkbOverlayKeyPtr;\n\ntypedef struct _XkbOverlayRow {\n\tunsigned short\t\trow_under;\n\tunsigned short\t\tnum_keys;\n\tunsigned short\t\tsz_keys;\n\tXkbOverlayKeyPtr\tkeys;\n} XkbOverlayRowRec,*XkbOverlayRowPtr;\n\ntypedef struct _XkbOverlay {\n\tAtom\t\t\tname;\n\tXkbSectionPtr\t\tsection_under;\n\tunsigned short\t\tnum_rows;\n\tunsigned short\t\tsz_rows;\n\tXkbOverlayRowPtr\trows;\n\tXkbBoundsPtr\t\tbounds;\n} XkbOverlayRec,*XkbOverlayPtr;\n\ntypedef struct _XkbGeometry {\n\tAtom\t\t name;\n\tunsigned short\t width_mm;\n\tunsigned short\t height_mm;\n\tchar *\t\t label_font;\n\tXkbColorPtr\t label_color;\n\tXkbColorPtr\t base_color;\n\tunsigned short\t sz_properties;\n\tunsigned short\t sz_colors;\n\tunsigned short\t sz_shapes;\n\tunsigned short   sz_sections;\n\tunsigned short\t sz_doodads;\n\tunsigned short\t sz_key_aliases;\n\tunsigned short\t num_properties;\n\tunsigned short\t num_colors;\n\tunsigned short\t num_shapes;\n\tunsigned short\t num_sections;\n\tunsigned short\t num_doodads;\n\tunsigned short\t num_key_aliases;\n\tXkbPropertyPtr\t properties;\n\tXkbColorPtr\t colors;\n\tXkbShapePtr\t shapes;\n\tXkbSectionPtr\t sections;\n\tXkbDoodadPtr\t doodads;\n\tXkbKeyAliasPtr\t key_aliases;\n} XkbGeometryRec;\n#define\tXkbGeomColorIndex(g,c)\t((int)((c)-&(g)->colors[0]))\n\n#define\tXkbGeomPropertiesMask\t(1<<0)\n#define\tXkbGeomColorsMask\t(1<<1)\n#define\tXkbGeomShapesMask\t(1<<2)\n#define\tXkbGeomSectionsMask\t(1<<3)\n#define\tXkbGeomDoodadsMask\t(1<<4)\n#define\tXkbGeomKeyAliasesMask\t(1<<5)\n#define\tXkbGeomAllMask\t\t(0x3f)\n\ntypedef struct _XkbGeometrySizes {\n\tunsigned int\twhich;\n\tunsigned short\tnum_properties;\n\tunsigned short\tnum_colors;\n\tunsigned short\tnum_shapes;\n\tunsigned short\tnum_sections;\n\tunsigned short\tnum_doodads;\n\tunsigned short\tnum_key_aliases;\n} XkbGeometrySizesRec,*XkbGeometrySizesPtr;\n\n_XFUNCPROTOBEGIN\n\nextern\tXkbPropertyPtr\nXkbAddGeomProperty(\n    XkbGeometryPtr\t/* geom */,\n    char *\t\t/* name */,\n    char *\t\t/* value */\n);\n\nextern\tXkbKeyAliasPtr\nXkbAddGeomKeyAlias(\n    XkbGeometryPtr\t/* geom */,\n    char *\t\t/* alias */,\n    char *\t\t/* real */\n);\n\nextern\tXkbColorPtr\nXkbAddGeomColor(\n    XkbGeometryPtr\t/* geom */,\n    char *\t\t/* spec */,\n    unsigned int\t/* pixel */\n);\n\nextern\tXkbOutlinePtr\nXkbAddGeomOutline(\n    XkbShapePtr\t\t/* shape */,\n    int\t\t\t/* sz_points */\n);\n\nextern XkbShapePtr\nXkbAddGeomShape(\n    XkbGeometryPtr\t/* geom */,\n    Atom\t\t/* name */,\n    int\t\t\t/* sz_outlines */\n);\n\nextern XkbKeyPtr\nXkbAddGeomKey(\n    XkbRowPtr\t\t/* row */\n);\n\nextern XkbRowPtr\nXkbAddGeomRow(\n    XkbSectionPtr\t/* section */,\n    int\t\t\t/* sz_keys */\n);\n\nextern XkbSectionPtr\nXkbAddGeomSection(\n    XkbGeometryPtr\t/* geom */,\n    Atom\t\t/* name */,\n    int\t\t\t/* sz_rows */,\n    int\t\t\t/* sz_doodads */,\n    int\t\t\t/* sz_overlays */\n);\n\nextern XkbOverlayPtr\nXkbAddGeomOverlay(\n    XkbSectionPtr\t/* section */,\n    Atom\t\t/* name */,\n    int\t\t\t/* sz_rows */\n);\n\nextern XkbOverlayRowPtr\nXkbAddGeomOverlayRow(\n    XkbOverlayPtr\t/* overlay */,\n    int\t\t\t/* row_under */,\n    int\t\t\t/* sz_keys */\n);\n\nextern XkbOverlayKeyPtr\nXkbAddGeomOverlayKey(\n    XkbOverlayPtr\t/* overlay */,\n    XkbOverlayRowPtr\t/* row */,\n    char *\t\t/* over */,\n    char *\t\t/* under */\n);\n\nextern XkbDoodadPtr\nXkbAddGeomDoodad(\n    XkbGeometryPtr\t/* geom */,\n    XkbSectionPtr\t/* section */,\n    Atom\t\t/* name */\n);\n\n\nextern void\nXkbFreeGeomKeyAliases(\n    XkbGeometryPtr\t/* geom */,\n    int\t\t\t/* first */,\n    int\t\t\t/* count */,\n    Bool\t\t/* freeAll */\n);\n\nextern void\nXkbFreeGeomColors(\n    XkbGeometryPtr\t/* geom */,\n    int\t\t\t/* first */,\n    int\t\t\t/* count */,\n    Bool\t\t/* freeAll */\n);\n\nextern void\nXkbFreeGeomDoodads(\n    XkbDoodadPtr\t/* doodads */,\n    int\t\t\t/* nDoodads */,\n    Bool\t\t/* freeAll */\n);\n\n\nextern void\nXkbFreeGeomProperties(\n    XkbGeometryPtr\t/* geom */,\n    int\t\t\t/* first */,\n    int\t\t\t/* count */,\n    Bool\t\t/* freeAll */\n);\n\nextern void\nXkbFreeGeomOverlayKeys(\n    XkbOverlayRowPtr\t/* row */,\n    int\t\t\t/* first */,\n    int\t\t\t/* count */,\n    Bool\t\t/* freeAll */\n);\n\nextern void\nXkbFreeGeomOverlayRows(\n    XkbOverlayPtr\t/* overlay */,\n    int\t\t\t/* first */,\n    int\t\t\t/* count */,\n    Bool\t\t/* freeAll */\n);\n\nextern void\nXkbFreeGeomOverlays(\n    XkbSectionPtr\t/* section */,\n    int\t\t\t/* first */,\n    int\t\t\t/* count */,\n    Bool\t\t/* freeAll */\n);\n\nextern void\nXkbFreeGeomKeys(\n    XkbRowPtr\t\t/* row */,\n    int\t\t\t/* first */,\n    int\t\t\t/* count */,\n    Bool\t\t/* freeAll */\n);\n\nextern void\nXkbFreeGeomRows(\n    XkbSectionPtr\t/* section */,\n    int\t\t\t/* first */,\n    int\t\t\t/* count */,\n    Bool\t\t/* freeAll */\n);\n\nextern void\nXkbFreeGeomSections(\n    XkbGeometryPtr\t/* geom */,\n    int\t\t\t/* first */,\n    int\t\t\t/* count */,\n    Bool\t\t/* freeAll */\n);\n\n\nextern void\nXkbFreeGeomPoints(\n    XkbOutlinePtr\t/* outline */,\n    int\t\t\t/* first */,\n    int\t\t\t/* count */,\n    Bool\t\t/* freeAll */\n);\n\nextern void\nXkbFreeGeomOutlines(\n    XkbShapePtr\t\t/* shape */,\n    int\t\t\t/* first */,\n    int\t\t\t/* count */,\n    Bool\t\t/* freeAll */\n);\n\nextern void\nXkbFreeGeomShapes(\n    XkbGeometryPtr\t/* geom */,\n    int\t\t\t/* first */,\n    int\t\t\t/* count */,\n    Bool\t\t/* freeAll */\n);\n\nextern void\nXkbFreeGeometry(\n    XkbGeometryPtr\t/* geom */,\n    unsigned int\t/* which */,\n    Bool\t\t/* freeMap */\n);\n\nextern Status\nXkbAllocGeomProps(\n    XkbGeometryPtr\t/* geom */,\n    int\t\t\t/* nProps */\n);\n\nextern Status\nXkbAllocGeomKeyAliases(\n    XkbGeometryPtr\t/* geom */,\n    int\t\t\t/* nAliases */\n);\n\nextern Status\nXkbAllocGeomColors(\n    XkbGeometryPtr\t/* geom */,\n    int\t\t\t/* nColors */\n);\n\nextern Status\nXkbAllocGeomShapes(\n    XkbGeometryPtr\t/* geom */,\n    int\t\t\t/* nShapes */\n);\n\nextern Status\nXkbAllocGeomSections(\n    XkbGeometryPtr\t/* geom */,\n    int\t\t\t/* nSections */\n);\n\nextern Status\nXkbAllocGeomOverlays(\n    XkbSectionPtr\t/* section */,\n    int\t\t\t/* num_needed */\n);\n\nextern Status\nXkbAllocGeomOverlayRows(\n    XkbOverlayPtr\t/* overlay */,\n    int\t\t\t/* num_needed */\n);\n\nextern Status\nXkbAllocGeomOverlayKeys(\n    XkbOverlayRowPtr\t/* row */,\n    int\t\t\t/* num_needed */\n);\n\nextern Status\nXkbAllocGeomDoodads(\n    XkbGeometryPtr\t/* geom */,\n    int\t\t\t/* nDoodads */\n);\n\nextern Status\nXkbAllocGeomSectionDoodads(\n    XkbSectionPtr\t/* section */,\n    int\t\t\t/* nDoodads */\n);\n\nextern Status\nXkbAllocGeomOutlines(\n    XkbShapePtr\t\t/* shape */,\n    int\t\t\t/* nOL */\n);\n\nextern Status\nXkbAllocGeomRows(\n    XkbSectionPtr\t/* section */,\n    int\t\t\t/* nRows */\n);\n\nextern Status\nXkbAllocGeomPoints(\n    XkbOutlinePtr\t/* ol */,\n    int\t\t\t/* nPts */\n);\n\nextern Status\nXkbAllocGeomKeys(\n    XkbRowPtr\t\t/* row */,\n    int\t\t\t/* nKeys */\n);\n\nextern\tStatus\nXkbAllocGeometry(\n\tXkbDescPtr\t\t/* xkb */,\n\tXkbGeometrySizesPtr\t/* sizes */\n);\n\nextern\tStatus\nXkbSetGeometry(\n\tDisplay *\t\t/* dpy */,\n\tunsigned\t\t/* deviceSpec */,\n\tXkbGeometryPtr\t\t/* geom */\n);\n\nextern\tBool\nXkbComputeShapeTop(\n\tXkbShapePtr\t\t/* shape */,\n\tXkbBoundsPtr\t\t/* bounds */\n);\n\nextern\tBool\nXkbComputeShapeBounds(\n\tXkbShapePtr\t\t/* shape */\n);\n\nextern\tBool\nXkbComputeRowBounds(\n\tXkbGeometryPtr\t\t/* geom */,\n\tXkbSectionPtr\t\t/* section */,\n\tXkbRowPtr\t\t/* row */\n);\n\nextern\tBool\nXkbComputeSectionBounds(\n\tXkbGeometryPtr\t\t/* geom */,\n\tXkbSectionPtr\t\t/* section */\n);\n\nextern\tchar *\nXkbFindOverlayForKey(\n\tXkbGeometryPtr\t\t/* geom */,\n\tXkbSectionPtr\t\t/* wanted */,\n\tchar *\t\t\t/* under */\n);\n\nextern\tStatus\nXkbGetGeometry(\n    Display *\t\t\t/* dpy */,\n    XkbDescPtr\t\t\t/* xkb */\n);\n\nextern\tStatus\nXkbGetNamedGeometry(\n    Display *\t\t\t/* dpy */,\n    XkbDescPtr\t\t\t/* xkb */,\n    Atom\t\t\t/* name */\n);\n\n_XFUNCPROTOEND\n\n#endif /* _XKBSTR_H_ */\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/X11/extensions/XKBproto.h",
    "content": "/************************************************************\nCopyright (c) 1993 by Silicon Graphics Computer Systems, Inc.\n\nPermission to use, copy, modify, and distribute this\nsoftware and its documentation for any purpose and without\nfee is hereby granted, provided that the above copyright\nnotice appear in all copies and that both that copyright\nnotice and this permission notice appear in supporting\ndocumentation, and that the name of Silicon Graphics not be \nused in advertising or publicity pertaining to distribution \nof the software without specific prior written permission.\nSilicon Graphics makes no representation about the suitability \nof this software for any purpose. It is provided \"as is\"\nwithout any express or implied warranty.\n\nSILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS \nSOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY \nAND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON\nGRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL \nDAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, \nDATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE \nOR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION  WITH\nTHE USE OR PERFORMANCE OF THIS SOFTWARE.\n\n********************************************************/\n\n#ifndef _XKBPROTO_H_\n#define\t_XKBPROTO_H_\n\n#include <X11/Xmd.h>\n#include <X11/extensions/XKB.h>\n\n#define Window CARD32\n#define Atom CARD32\n#define Time CARD32\n#define KeyCode CARD8\n#define KeySym CARD32\n\n#define\tXkbPaddedSize(n)\t((((unsigned int)(n)+3) >> 2) << 2)\n\ntypedef struct _xkbUseExtension {\n    CARD8\treqType;\n    CARD8\txkbReqType;\t/* always X_KBUseExtension */\n    CARD16\tlength B16;\n    CARD16\twantedMajor B16;\n    CARD16\twantedMinor B16;\n} xkbUseExtensionReq;\n#define\tsz_xkbUseExtensionReq\t8\n\ntypedef struct _xkbUseExtensionReply {\n    BYTE\ttype;\t\t/* X_Reply */\n    BOOL\tsupported;\n    CARD16\tsequenceNumber B16;\n    CARD32\tlength B32;\n    CARD16\tserverMajor B16;\n    CARD16\tserverMinor B16;\n    CARD32\tpad1 B32;\n    CARD32\tpad2 B32;\n    CARD32\tpad3 B32;\n    CARD32\tpad4 B32;\n    CARD32\tpad5 B32;\n} xkbUseExtensionReply;\n#define\tsz_xkbUseExtensionReply\t32\n\ntypedef\tstruct _xkbSelectEvents {\n    CARD8\treqType;\n    CARD8\txkbReqType;\t/* X_KBSelectEvents */\n    CARD16\tlength B16;\n    CARD16\tdeviceSpec B16;\n    CARD16\taffectWhich B16;\n    CARD16\tclear B16;\n    CARD16\tselectAll B16;\n    CARD16\taffectMap B16;\n    CARD16\tmap B16;\n} xkbSelectEventsReq;\n#define\tsz_xkbSelectEventsReq\t16\n\ntypedef struct _xkbBell {\n    CARD8\treqType;\n    CARD8\txkbReqType;\t/* X_KBBell */\n    CARD16\tlength B16;\n    CARD16\tdeviceSpec B16;\n    CARD16\tbellClass B16;\n    CARD16\tbellID B16;\n    INT8\tpercent;\n    BOOL\tforceSound;\n    BOOL\teventOnly;\n    CARD8\tpad1;\n    INT16\tpitch B16;\n    INT16\tduration B16;\n    CARD16\tpad2 B16;\n    Atom\tname B32;\n    Window\twindow B32;\n} xkbBellReq;\n#define\tsz_xkbBellReq\t\t28\n\ntypedef struct _xkbGetState {\n\tCARD8\t\treqType;\n\tCARD8\t\txkbReqType;\t/* always X_KBGetState */\n\tCARD16\t\tlength B16;\n\tCARD16\t\tdeviceSpec B16;\n\tCARD16\t\tpad B16;\n} xkbGetStateReq;\n#define\tsz_xkbGetStateReq\t8\n\ntypedef\tstruct _xkbGetStateReply {\n    BYTE\ttype;\n    BYTE\tdeviceID;\n    CARD16\tsequenceNumber B16;\n    CARD32\tlength B32;\n    CARD8\tmods;\n    CARD8\tbaseMods;\n    CARD8\tlatchedMods;\n    CARD8\tlockedMods;\n    CARD8\tgroup;\n    CARD8\tlockedGroup;\n    INT16\tbaseGroup B16;\n    INT16\tlatchedGroup B16;\n    CARD8\tcompatState;\n    CARD8\tgrabMods;\n    CARD8\tcompatGrabMods;\n    CARD8\tlookupMods;\n    CARD8\tcompatLookupMods;\n    CARD8\tpad1;\n    CARD16\tptrBtnState B16;\n    CARD16\tpad2 B16;\n    CARD32\tpad3 B32;\n} xkbGetStateReply;\n#define\tsz_xkbGetStateReply\t32\n\ntypedef struct _xkbLatchLockState {\n    CARD8\treqType;\n    CARD8\txkbReqType;\t/* always X_KBLatchLockState */\n    CARD16\tlength B16;\n    CARD16\tdeviceSpec B16;\n    CARD8\taffectModLocks;\n    CARD8\tmodLocks;\n    BOOL\tlockGroup;\n    CARD8\tgroupLock;\n    CARD8\taffectModLatches;\n    CARD8\tmodLatches;\n    CARD8\tpad;\n    BOOL\tlatchGroup;\n    INT16\tgroupLatch B16;\n} xkbLatchLockStateReq;\n#define\tsz_xkbLatchLockStateReq\t\t16\n\ntypedef struct _xkbGetControls {\n    CARD8\treqType;\n    CARD8\txkbReqType;\t/* always X_KBGetControls */\n    CARD16\tlength B16;\n    CARD16\tdeviceSpec B16;\n    CARD16\tpad B16;\n} xkbGetControlsReq;\n#define\tsz_xkbGetControlsReq\t8\n\ntypedef struct _xkbGetControlsReply {\n    BYTE\ttype;\t\t/* X_Reply */\n    CARD8\tdeviceID;\n    CARD16\tsequenceNumber B16;\n    CARD32\tlength B32;\n    CARD8\tmkDfltBtn;\n    CARD8\tnumGroups;\n    CARD8\tgroupsWrap;\n    CARD8\tinternalMods;\n    CARD8\tignoreLockMods;\n    CARD8\tinternalRealMods;\n    CARD8\tignoreLockRealMods;\n    CARD8\tpad1;\n    CARD16\tinternalVMods B16;\n    CARD16\tignoreLockVMods B16;\n    CARD16\trepeatDelay B16;\n    CARD16\trepeatInterval B16;\n    CARD16\tslowKeysDelay B16;\n    CARD16\tdebounceDelay B16;\n    CARD16\tmkDelay B16;\n    CARD16\tmkInterval B16;\n    CARD16\tmkTimeToMax B16;\n    CARD16\tmkMaxSpeed B16;\n    INT16\tmkCurve B16;\n    CARD16\taxOptions B16;\n    CARD16\taxTimeout B16;\n    CARD16\taxtOptsMask B16;\n    CARD16\taxtOptsValues B16;\n    CARD16\tpad2 B16;\n    CARD32\taxtCtrlsMask B32;\n    CARD32\taxtCtrlsValues B32;\n    CARD32\tenabledCtrls B32;\n    BYTE\tperKeyRepeat[XkbPerKeyBitArraySize];\n} xkbGetControlsReply;\n#define\tsz_xkbGetControlsReply\t92\n\ntypedef struct _xkbSetControls {\n    CARD8\treqType;\n    CARD8\txkbReqType;\t/* always X_KBSetControls */\n    CARD16\tlength B16;\n    CARD16\tdeviceSpec B16;\n    CARD8\taffectInternalMods;\n    CARD8\tinternalMods;\n    CARD8\taffectIgnoreLockMods;\n    CARD8\tignoreLockMods;\n    CARD16\taffectInternalVMods B16;\n    CARD16\tinternalVMods B16;\n    CARD16\taffectIgnoreLockVMods B16;\n    CARD16\tignoreLockVMods B16;\n    CARD8\tmkDfltBtn;\n    CARD8\tgroupsWrap;\n    CARD16\taxOptions B16;\n    CARD16\tpad1 B16;\n    CARD32\taffectEnabledCtrls B32;\n    CARD32\tenabledCtrls B32;\n    CARD32\tchangeCtrls B32;\n    CARD16\trepeatDelay B16;\n    CARD16\trepeatInterval B16;\n    CARD16\tslowKeysDelay B16;\n    CARD16\tdebounceDelay B16;\n    CARD16\tmkDelay B16;\n    CARD16\tmkInterval B16;\n    CARD16\tmkTimeToMax B16;\n    CARD16\tmkMaxSpeed B16;\n    INT16\tmkCurve B16;\n    CARD16\taxTimeout B16;\n    CARD32\taxtCtrlsMask B32;\n    CARD32\taxtCtrlsValues B32;\n    CARD16\taxtOptsMask B16;\n    CARD16\taxtOptsValues B16;\n    BYTE\tperKeyRepeat[XkbPerKeyBitArraySize];\n} xkbSetControlsReq;\n#define\tsz_xkbSetControlsReq\t100\n\ntypedef\tstruct _xkbKTMapEntryWireDesc {\n    BOOL\tactive;\n    CARD8\tmask;\n    CARD8\tlevel;\n    CARD8\trealMods;\n    CARD16\tvirtualMods B16;\n    CARD16\tpad B16;\n} xkbKTMapEntryWireDesc;\n#define sz_xkbKTMapEntryWireDesc\t8\n\ntypedef struct _xkbKTSetMapEntryWireDesc {\n    CARD8\tlevel;\n    CARD8\trealMods;\n    CARD16\tvirtualMods B16;\n} xkbKTSetMapEntryWireDesc;\n#define\tsz_xkbKTSetMapEntryWireDesc\t4\n\ntypedef struct _xkbModsWireDesc {\n    CARD8\tmask;\t\t/* GetMap only */\n    CARD8\trealMods;\n    CARD16\tvirtualMods B16;\n} xkbModsWireDesc;\n#define\tsz_xkbModsWireDesc\t4\n\ntypedef struct _xkbKeyTypeWireDesc {\n    CARD8\tmask;\n    CARD8\trealMods;\n    CARD16\tvirtualMods B16;\n    CARD8\tnumLevels;\n    CARD8\tnMapEntries;\n    BOOL\tpreserve;\n    CARD8\tpad;\n} xkbKeyTypeWireDesc;\n#define\tsz_xkbKeyTypeWireDesc\t8\n\ntypedef struct _xkbSymMapWireDesc {\n    CARD8\tktIndex[XkbNumKbdGroups];\n    CARD8\tgroupInfo;\n    CARD8\twidth;\n    CARD16\tnSyms B16;\n} xkbSymMapWireDesc;\n#define\tsz_xkbSymMapWireDesc\t8\n\ntypedef struct _xkbVModMapWireDesc {\n    KeyCode\tkey;\n    CARD8\tpad;\n    CARD16\tvmods B16;\n} xkbVModMapWireDesc;\n#define\tsz_xkbVModMapWireDesc\t4\n\ntypedef struct _xkbBehaviorWireDesc {\n\tCARD8\tkey;\n\tCARD8\ttype;\n\tCARD8\tdata;\n\tCARD8\tpad;\n} xkbBehaviorWireDesc;\n#define\tsz_xkbBehaviorWireDesc\t4\n\ntypedef\tstruct _xkbActionWireDesc {\n    CARD8\ttype;\n    CARD8\tdata[7];\n} xkbActionWireDesc;\n#define\tsz_xkbActionWireDesc\t8\n\ntypedef struct _xkbGetMap {\n    CARD8\treqType;\n    CARD8\txkbReqType;\t/* always X_KBGetMap */\n    CARD16\tlength B16;\n    CARD16\tdeviceSpec B16;\n    CARD16\tfull B16;\n    CARD16\tpartial B16;\n    CARD8\tfirstType;\n    CARD8\tnTypes;\n    KeyCode\tfirstKeySym;\n    CARD8\tnKeySyms;\n    KeyCode\tfirstKeyAct;\n    CARD8\tnKeyActs;\n    KeyCode\tfirstKeyBehavior;\n    CARD8\tnKeyBehaviors;\n    CARD16\tvirtualMods B16;\n    KeyCode\tfirstKeyExplicit;\n    CARD8\tnKeyExplicit;\n    KeyCode\tfirstModMapKey;\n    CARD8\tnModMapKeys;\n    KeyCode\tfirstVModMapKey;\n    CARD8\tnVModMapKeys;\n    CARD16\tpad1 B16;\n} xkbGetMapReq;\n#define\tsz_xkbGetMapReq\t28\n\ntypedef struct _xkbGetMapReply {\n    CARD8\ttype;\t\t/* always X_Reply */\n    CARD8\tdeviceID;\n    CARD16\tsequenceNumber B16;\n    CARD32\tlength B32;\n    CARD16\tpad1 B16;\n    KeyCode\tminKeyCode;\n    KeyCode\tmaxKeyCode;\n    CARD16\tpresent B16;\n    CARD8\tfirstType;\n    CARD8\tnTypes;\n    CARD8\ttotalTypes;\n    KeyCode\tfirstKeySym;\n    CARD16\ttotalSyms B16;\n    CARD8\tnKeySyms;\n    KeyCode\tfirstKeyAct;\n    CARD16\ttotalActs B16;\n    CARD8\tnKeyActs;\n    KeyCode\tfirstKeyBehavior;\n    CARD8\tnKeyBehaviors;\n    CARD8\ttotalKeyBehaviors;\n    KeyCode\tfirstKeyExplicit;\n    CARD8\tnKeyExplicit;\n    CARD8\ttotalKeyExplicit;\n    KeyCode\tfirstModMapKey;\n    CARD8\tnModMapKeys;\n    CARD8\ttotalModMapKeys;\n    KeyCode\tfirstVModMapKey;\n    CARD8\tnVModMapKeys;\n    CARD8\ttotalVModMapKeys;\n    CARD8\tpad2;\n    CARD16\tvirtualMods B16;\n} xkbGetMapReply;\n#define\tsz_xkbGetMapReply\t\t40\n\n#define\tXkbSetMapResizeTypes\t\t(1L<<0)\n#define\tXkbSetMapRecomputeActions\t(1L<<1)\n#define\tXkbSetMapAllFlags\t\t(0x3)\n\ntypedef struct _xkbSetMap {\n    CARD8\treqType;\n    CARD8\txkbReqType;\t/* always X_KBSetMap */\n    CARD16\tlength B16;\n    CARD16\tdeviceSpec B16;\n    CARD16\tpresent B16;\n    CARD16\tflags B16;\n    KeyCode\tminKeyCode;\n    KeyCode\tmaxKeyCode;\n    CARD8\tfirstType;\n    CARD8\tnTypes;\n    KeyCode\tfirstKeySym;\n    CARD8\tnKeySyms;\n    CARD16\ttotalSyms B16;\n    KeyCode\tfirstKeyAct;\n    CARD8\tnKeyActs;\n    CARD16\ttotalActs B16;\n    KeyCode\tfirstKeyBehavior;\n    CARD8\tnKeyBehaviors;\n    CARD8\ttotalKeyBehaviors;\n    KeyCode\tfirstKeyExplicit;\n    CARD8\tnKeyExplicit;\n    CARD8\ttotalKeyExplicit;\n    KeyCode\tfirstModMapKey;\n    CARD8\tnModMapKeys;\n    CARD8\ttotalModMapKeys;\n    KeyCode\tfirstVModMapKey;\n    CARD8\tnVModMapKeys;\n    CARD8\ttotalVModMapKeys;\n    CARD16\tvirtualMods B16;\n} xkbSetMapReq;\n#define\tsz_xkbSetMapReq\t36\n\ntypedef struct _xkbSymInterpretWireDesc {\n    CARD32\t\tsym B32;\n    CARD8\t\tmods;\n    CARD8\t\tmatch;\n    CARD8\t\tvirtualMod;\n    CARD8\t\tflags;\n    xkbActionWireDesc\tact;\n} xkbSymInterpretWireDesc;\n#define\tsz_xkbSymInterpretWireDesc\t16\n\ntypedef struct _xkbGetCompatMap {\n    CARD8\treqType;\n    CARD8\txkbReqType;\t/* always X_KBGetCompatMap */\n    CARD16\tlength B16;\n    CARD16\tdeviceSpec B16;\n    CARD8\tgroups;\n    BOOL\tgetAllSI;\n    CARD16\tfirstSI B16;\n    CARD16\tnSI B16;\n} xkbGetCompatMapReq;\n#define\tsz_xkbGetCompatMapReq\t12\n\ntypedef struct _xkbGetCompatMapReply {\n    CARD8\ttype;\t\t/* always X_Reply */\n    CARD8\tdeviceID;\n    CARD16\tsequenceNumber B16;\n    CARD32\tlength B32;\n    CARD8\tgroups;\n    CARD8\tpad1;\n    CARD16\tfirstSI B16;\n    CARD16\tnSI B16;\n    CARD16\tnTotalSI B16;\n    CARD32\tpad2 B32;\n    CARD32\tpad3 B32;\n    CARD32\tpad4 B32;\n    CARD32\tpad5 B32;\n} xkbGetCompatMapReply;\n#define\tsz_xkbGetCompatMapReply\t\t32\n\ntypedef struct _xkbSetCompatMap {\n    CARD8\treqType;\n    CARD8\txkbReqType;\t/* always X_KBSetCompatMap */\n    CARD16\tlength B16;\n    CARD16\tdeviceSpec B16;\n    CARD8\tpad1;\n    BOOL\trecomputeActions;\n    BOOL\ttruncateSI;\n    CARD8\tgroups;\n    CARD16\tfirstSI B16;\n    CARD16\tnSI B16;\n    CARD16\tpad2 B16;\n} xkbSetCompatMapReq;\n#define\tsz_xkbSetCompatMapReq\t16\n\ntypedef struct _xkbGetIndicatorState {\n    CARD8\treqType;\n    CARD8\txkbReqType;\t/* always X_KBGetIndicatorState */\n    CARD16\tlength B16;\n    CARD16\tdeviceSpec B16;\n    CARD16\tpad1 B16;\n} xkbGetIndicatorStateReq;\n#define\tsz_xkbGetIndicatorStateReq\t8\n\ntypedef struct _xkbGetIndicatorStateReply {\n    CARD8\ttype;\t\t/* always X_Reply */\n    CARD8\tdeviceID;\n    CARD16\tsequenceNumber B16;\n    CARD32\tlength B32;\n    CARD32\tstate B32;\n    CARD32\tpad1 B32;\n    CARD32\tpad2 B32;\n    CARD32\tpad3 B32;\n    CARD32\tpad4 B32;\n    CARD32\tpad5 B32;\n} xkbGetIndicatorStateReply;\n#define\tsz_xkbGetIndicatorStateReply\t32\n\ntypedef struct _xkbGetIndicatorMap {\n    CARD8\treqType;\n    CARD8\txkbReqType;\t/* always X_KBGetIndicatorMap */\n    CARD16\tlength B16;\n    CARD16\tdeviceSpec B16;\n    CARD16\tpad B16;\n    CARD32\twhich B32;\n} xkbGetIndicatorMapReq;\n#define\tsz_xkbGetIndicatorMapReq\t12\n\ntypedef struct _xkbGetIndicatorMapReply {\n    CARD8\ttype;\t\t/* always X_Reply */\n    CARD8\tdeviceID;\n    CARD16\tsequenceNumber B16;\n    CARD32\tlength B32;\n    CARD32\twhich B32;\n    CARD32\trealIndicators B32;\n    CARD8\tnIndicators;\n    CARD8\tpad1;\n    CARD16\tpad2 B16;\n    CARD32\tpad3 B32;\n    CARD32\tpad4 B32;\n    CARD32\tpad5 B32;\n} xkbGetIndicatorMapReply;\n#define\tsz_xkbGetIndicatorMapReply\t32\n\ntypedef struct _xkbIndicatorMapWireDesc {\n    CARD8\tflags;\n    CARD8\twhichGroups;\n    CARD8\tgroups;\n    CARD8\twhichMods;\n    CARD8\tmods;\n    CARD8\trealMods;\n    CARD16\tvirtualMods B16;\n    CARD32\tctrls B32;\n} xkbIndicatorMapWireDesc;\n#define\tsz_xkbIndicatorMapWireDesc\t12\n\ntypedef struct _xkbSetIndicatorMap {\n    CARD8\treqType;\n    CARD8\txkbReqType;\t/* always X_KBSetIndicatorMap */\n    CARD16\tlength B16;\n    CARD16\tdeviceSpec B16;\n    CARD16\tpad1 B16;\n    CARD32\twhich B32;\n} xkbSetIndicatorMapReq;\n#define\tsz_xkbSetIndicatorMapReq\t12\n\ntypedef struct _xkbGetNamedIndicator {\n    CARD8\treqType;\n    CARD8\txkbReqType;\t/* X_KBGetNamedIndicator */\n    CARD16\tlength B16;\n    CARD16\tdeviceSpec B16;\n    CARD16\tledClass B16;\n    CARD16\tledID B16;\n    CARD16\tpad1 B16;\n    Atom\tindicator B32;\n} xkbGetNamedIndicatorReq;\n#define\tsz_xkbGetNamedIndicatorReq\t\t16\n\ntypedef\tstruct _xkbGetNamedIndicatorReply {\n    BYTE\ttype;\n    BYTE\tdeviceID;\n    CARD16\tsequenceNumber B16;\n    CARD32\tlength B32;\n    Atom\tindicator B32;\n    BOOL\tfound;\n    BOOL\ton;\n    BOOL\trealIndicator;\n    CARD8\tndx;\n    CARD8\tflags;\n    CARD8\twhichGroups;\n    CARD8\tgroups;\n    CARD8\twhichMods;\n    CARD8\tmods;\n    CARD8\trealMods;\n    CARD16\tvirtualMods B16;\n    CARD32\tctrls B32;\n    BOOL\tsupported;\n    CARD8\tpad1;\n    CARD16\tpad2 B16;\n} xkbGetNamedIndicatorReply;\n#define\tsz_xkbGetNamedIndicatorReply\t32\n\ntypedef struct _xkbSetNamedIndicator {\n    CARD8\treqType;\n    CARD8\txkbReqType;\t/* X_KBSetNamedIndicator */\n    CARD16\tlength B16;\n    CARD16\tdeviceSpec B16;\n    CARD16\tledClass B16;\n    CARD16\tledID B16;\n    CARD16\tpad1 B16;\n    Atom\tindicator B32;\n    BOOL\tsetState;\n    BOOL\ton;\n    BOOL\tsetMap;\n    BOOL\tcreateMap;\n    CARD8\tpad2;\n    CARD8\tflags;\n    CARD8\twhichGroups;\n    CARD8\tgroups;\n    CARD8\twhichMods;\n    CARD8\trealMods;\n    CARD16\tvirtualMods B16;\n    CARD32\tctrls B32;\n} xkbSetNamedIndicatorReq;\n#define\tsz_xkbSetNamedIndicatorReq\t32\n\ntypedef struct _xkbGetNames {\n    CARD8\treqType;\n    CARD8\txkbReqType;\t/* always X_KBGetNames */\n    CARD16\tlength B16;\n    CARD16\tdeviceSpec B16;\n    CARD16\tpad B16;\n    CARD32\twhich B32;\n} xkbGetNamesReq;\n#define\tsz_xkbGetNamesReq\t\t12\n\ntypedef\tstruct _xkbGetNamesReply {\n    BYTE\ttype;\n    BYTE\tdeviceID;\n    CARD16\tsequenceNumber B16;\n    CARD32\tlength B32;\n    CARD32\twhich B32;\n    KeyCode\tminKeyCode;\n    KeyCode\tmaxKeyCode;\n    CARD8\tnTypes;\n    CARD8\tgroupNames;\n    CARD16\tvirtualMods B16;\n    KeyCode\tfirstKey;\n    CARD8\tnKeys;\n    CARD32\tindicators B32;\n    CARD8\tnRadioGroups;\n    CARD8\tnKeyAliases;\n    CARD16\tnKTLevels B16;\n    CARD32\tpad3 B32;\n} xkbGetNamesReply;\n#define\tsz_xkbGetNamesReply\t32\n\ntypedef struct _xkbSetNames {\n    CARD8\treqType;\n    CARD8\txkbReqType;\t/* always X_KBSetNames */\n    CARD16\tlength B16;\n    CARD16\tdeviceSpec B16;\n    CARD16\tvirtualMods B16;\n    CARD32\twhich B32;\n    CARD8\tfirstType;\n    CARD8\tnTypes;\n    CARD8\tfirstKTLevel;\n    CARD8\tnKTLevels;\n    CARD32\tindicators B32;\n    CARD8\tgroupNames;\n    CARD8\tnRadioGroups;\n    KeyCode\tfirstKey;\n    CARD8\tnKeys;\n    CARD8\tnKeyAliases;\n    CARD8\tpad1;\n    CARD16\ttotalKTLevelNames B16;\n} xkbSetNamesReq;\n#define\tsz_xkbSetNamesReq\t28\n\ntypedef struct _xkbPointWireDesc {\n    INT16\tx B16;\n    INT16\ty B16;\n} xkbPointWireDesc;\n#define\tsz_xkbPointWireDesc\t4\n\ntypedef struct _xkbOutlineWireDesc {\n    CARD8\tnPoints;\n    CARD8\tcornerRadius;\n    CARD16\tpad B16;\n} xkbOutlineWireDesc;\n#define\tsz_xkbOutlineWireDesc\t4\n\ntypedef struct _xkbShapeWireDesc {\n    Atom\tname B32;\n    CARD8\tnOutlines;\n    CARD8\tprimaryNdx;\n    CARD8\tapproxNdx;\n    CARD8\tpad;\n} xkbShapeWireDesc;\n#define\tsz_xkbShapeWireDesc\t8\n\ntypedef struct _xkbSectionWireDesc {\n    Atom\tname B32;\n    INT16\ttop B16;\n    INT16\tleft B16;\n    CARD16\twidth B16;\n    CARD16\theight B16;\n    INT16\tangle B16;\n    CARD8\tpriority;\n    CARD8\tnRows;\n    CARD8\tnDoodads;\n    CARD8\tnOverlays;\n    CARD16\tpad B16;\n} xkbSectionWireDesc;\n#define\tsz_xkbSectionWireDesc\t20\n\ntypedef struct _xkbRowWireDesc {\n    INT16\ttop B16;\n    INT16\tleft B16;\n    CARD8\tnKeys;\n    BOOL\tvertical;\n    CARD16\tpad B16;\n} xkbRowWireDesc;\n#define\tsz_xkbRowWireDesc\t8\n\ntypedef struct _xkbKeyWireDesc {\n    CARD8\tname[XkbKeyNameLength];\n    INT16\tgap B16;\n    CARD8\tshapeNdx;\n    CARD8\tcolorNdx;\n} xkbKeyWireDesc;\n#define\tsz_xkbKeyWireDesc\t8\n\ntypedef struct _xkbOverlayWireDesc {\n    Atom\tname B32;\n    CARD8\tnRows;\n    CARD8\tpad1;\n    CARD16\tpad2 B16;\n} xkbOverlayWireDesc;\n#define\tsz_xkbOverlayWireDesc\t8\n\ntypedef struct _xkbOverlayRowWireDesc {\n   CARD8\trowUnder;\n   CARD8\tnKeys;\n   CARD16\tpad1 B16;\n} xkbOverlayRowWireDesc;\n#define\tsz_xkbOverlayRowWireDesc\t4\n\ntypedef struct _xkbOverlayKeyWireDesc {\n   CARD8\tover[XkbKeyNameLength];\n   CARD8\tunder[XkbKeyNameLength];\n} xkbOverlayKeyWireDesc;\n#define\tsz_xkbOverlayKeyWireDesc\t8\n\ntypedef struct _xkbShapeDoodadWireDesc {\n    Atom\tname B32;\n    CARD8\ttype;\n    CARD8\tpriority;\n    INT16\ttop B16;\n    INT16\tleft B16;\n    INT16\tangle B16;\n    CARD8\tcolorNdx;\n    CARD8\tshapeNdx;\n    CARD16\tpad1 B16;\n    CARD32\tpad2 B32;\n} xkbShapeDoodadWireDesc;\n#define\tsz_xkbShapeDoodadWireDesc\t20\n\ntypedef struct _xkbTextDoodadWireDesc {\n    Atom\tname B32;\n    CARD8\ttype;\n    CARD8\tpriority;\n    INT16\ttop B16;\n    INT16\tleft B16;\n    INT16\tangle B16;\n    CARD16\twidth B16;\n    CARD16\theight B16;\n    CARD8\tcolorNdx;\n    CARD8\tpad1;\n    CARD16\tpad2 B16;\n} xkbTextDoodadWireDesc;\n#define\tsz_xkbTextDoodadWireDesc\t20\n\ntypedef struct _xkbIndicatorDoodadWireDesc {\n    Atom\tname B32;\n    CARD8\ttype;\n    CARD8\tpriority;\n    INT16\ttop B16;\n    INT16\tleft B16;\n    INT16\tangle B16;\n    CARD8\tshapeNdx;\n    CARD8\tonColorNdx;\n    CARD8\toffColorNdx;\n    CARD8\tpad1;\n    CARD32\tpad2 B32;\n} xkbIndicatorDoodadWireDesc;\n#define\tsz_xkbIndicatorDoodadWireDesc\t20\n\ntypedef struct _xkbLogoDoodadWireDesc {\n    Atom\tname B32;\n    CARD8\ttype;\n    CARD8\tpriority;\n    INT16\ttop B16;\n    INT16\tleft B16;\n    INT16\tangle B16;\n    CARD8\tcolorNdx;\n    CARD8\tshapeNdx;\n    CARD16\tpad1 B16;\n    CARD32\tpad2 B32;\n} xkbLogoDoodadWireDesc;\n#define\tsz_xkbLogoDoodadWireDesc\t20\n\ntypedef struct _xkbAnyDoodadWireDesc {\n    Atom\tname B32;\n    CARD8\ttype;\n    CARD8\tpriority;\n    INT16\ttop B16;\n    INT16\tleft B16;\n    INT16\tangle B16;\n    CARD32\tpad2 B32;\n    CARD32\tpad3 B32;\n} xkbAnyDoodadWireDesc;\n#define\tsz_xkbAnyDoodadWireDesc\t20\n\ntypedef union _xkbDoodadWireDesc {\n    xkbAnyDoodadWireDesc\tany;\n    xkbShapeDoodadWireDesc\tshape;\n    xkbTextDoodadWireDesc\ttext;\n    xkbIndicatorDoodadWireDesc\tindicator;\n    xkbLogoDoodadWireDesc\tlogo;\n} xkbDoodadWireDesc;\n#define\tsz_xkbDoodadWireDesc\t20\n\ntypedef struct _xkbGetGeometry {\n    CARD8\treqType;\n    CARD8\txkbReqType;\t/* always X_KBGetGeometry */\n    CARD16\tlength B16;\n    CARD16\tdeviceSpec B16;\n    CARD16\tpad B16;\n    Atom\tname B32;\n} xkbGetGeometryReq;\n#define\tsz_xkbGetGeometryReq\t12\n\ntypedef struct _xkbGetGeometryReply {\n    CARD8\ttype;\t\t/* always X_Reply */\n    CARD8\tdeviceID;\n    CARD16\tsequenceNumber B16;\n    CARD32\tlength B32;\n    Atom\tname B32;\n    BOOL\tfound;\n    CARD8\tpad;\n    CARD16\twidthMM B16;\n    CARD16\theightMM B16;\n    CARD16\tnProperties B16;\n    CARD16\tnColors B16;\n    CARD16\tnShapes B16;\n    CARD16\tnSections B16;\n    CARD16\tnDoodads B16;\n    CARD16\tnKeyAliases B16;\n    CARD8\tbaseColorNdx;\n    CARD8\tlabelColorNdx;\n} xkbGetGeometryReply;\n#define\tsz_xkbGetGeometryReply\t32\n\ntypedef struct _xkbSetGeometry {\n    CARD8\treqType;\n    CARD8\txkbReqType;\t/* always X_KBSetGeometry */\n    CARD16\tlength B16;\n    CARD16\tdeviceSpec B16;\n    CARD8\tnShapes;\n    CARD8\tnSections;\n    Atom\tname B32;\n    CARD16\twidthMM B16;\n    CARD16\theightMM B16;\n    CARD16\tnProperties B16;\n    CARD16\tnColors B16;\n    CARD16\tnDoodads B16;\n    CARD16\tnKeyAliases B16;\n    CARD8\tbaseColorNdx;\n    CARD8\tlabelColorNdx;\n    CARD16\tpad B16;\n} xkbSetGeometryReq;\n#define\tsz_xkbSetGeometryReq\t28\n\ntypedef struct _xkbPerClientFlags {\n    CARD8\treqType;\n    CARD8\txkbReqType;/* always X_KBPerClientFlags */\n    CARD16\tlength B16;\n    CARD16\tdeviceSpec B16;\n    CARD16\tpad1 B16;\n    CARD32\tchange B32;\n    CARD32\tvalue B32;\n    CARD32\tctrlsToChange B32;\n    CARD32\tautoCtrls B32;\n    CARD32\tautoCtrlValues B32;\n} xkbPerClientFlagsReq;\n#define\tsz_xkbPerClientFlagsReq\t28\n\ntypedef struct _xkbPerClientFlagsReply {\n    CARD8\ttype;\t\t/* always X_Reply */\n    CARD8\tdeviceID;\n    CARD16\tsequenceNumber B16;\n    CARD32\tlength B32;\n    CARD32\tsupported B32;\n    CARD32\tvalue B32;\n    CARD32\tautoCtrls B32;\n    CARD32\tautoCtrlValues B32;\n    CARD32\tpad1 B32;\n    CARD32\tpad2 B32;\n} xkbPerClientFlagsReply;\n#define\tsz_xkbPerClientFlagsReply\t32\n\ntypedef struct _xkbListComponents {\n    CARD8\treqType;\n    CARD8\txkbReqType;\t/* always X_KBListComponents */\n    CARD16\tlength B16;\n    CARD16\tdeviceSpec B16;\n    CARD16\tmaxNames B16;\n} xkbListComponentsReq;\n#define\tsz_xkbListComponentsReq\t8\n\ntypedef struct _xkbListComponentsReply {\n    CARD8\ttype;\t\t/* always X_Reply */\n    CARD8\tdeviceID;\n    CARD16\tsequenceNumber B16;\n    CARD32\tlength B32;\n    CARD16\tnKeymaps B16;\n    CARD16\tnKeycodes B16;\n    CARD16\tnTypes B16;\n    CARD16\tnCompatMaps B16;\n    CARD16\tnSymbols B16;\n    CARD16\tnGeometries B16;\n    CARD16\textra B16;\n    CARD16\tpad1 B16;\n    CARD32\tpad2 B32;\n    CARD32\tpad3 B32;\n} xkbListComponentsReply;\n#define\tsz_xkbListComponentsReply\t32\n\ntypedef struct _xkbGetKbdByName {\n    CARD8\treqType;\n    CARD8\txkbReqType;\t/* always X_KBGetKbdByName */\n    CARD16\tlength B16;\n    CARD16\tdeviceSpec B16;\n    CARD16\tneed B16;\t/* combination of XkbGBN_* */\n    CARD16\twant B16;\t/* combination of XkbGBN_* */\n    BOOL\tload;\n    CARD8\tpad;\n} xkbGetKbdByNameReq;\n#define\tsz_xkbGetKbdByNameReq\t12\n\ntypedef struct _xkbGetKbdByNameReply {\n    CARD8\ttype;\t\t/* always X_Reply */\n    CARD8\tdeviceID;\n    CARD16\tsequenceNumber B16;\n    CARD32\tlength B32;\n    KeyCode\tminKeyCode;\n    KeyCode\tmaxKeyCode;\n    BOOL\tloaded;\n    BOOL\tnewKeyboard;\n    CARD16\tfound B16;\t/* combination of XkbGBN_* */\n    CARD16\treported B16;\t/* combination of XkbAllComponents */\n    CARD32\tpad1 B32;\n    CARD32\tpad2 B32;\n    CARD32\tpad3 B32;\n    CARD32\tpad4 B32;\n} xkbGetKbdByNameReply;\n#define\tsz_xkbGetKbdByNameReply\t32\n\ntypedef\tstruct _xkbDeviceLedsWireDesc {\n    CARD16\tledClass B16;\n    CARD16\tledID B16;\n    CARD32\tnamesPresent B32;\n    CARD32\tmapsPresent B32;\n    CARD32\tphysIndicators B32;\n    CARD32\tstate B32;\n} xkbDeviceLedsWireDesc;\n#define sz_xkbDeviceLedsWireDesc\t20\n\ntypedef struct _xkbGetDeviceInfo {\n    CARD8\treqType;\n    CARD8\txkbReqType;\t/* always X_KBGetDeviceInfo */\n    CARD16\tlength B16;\n    CARD16\tdeviceSpec B16;\n    CARD16\twanted B16;\n    BOOL\tallBtns;\n    CARD8\tfirstBtn;\n    CARD8\tnBtns;\n    CARD8\tpad;\n    CARD16\tledClass B16;\n    CARD16\tledID B16;\n} xkbGetDeviceInfoReq;\n#define\tsz_xkbGetDeviceInfoReq\t16\n\ntypedef struct _xkbGetDeviceInfoReply {\n    CARD8\ttype;\t\t/* always X_Reply */\n    CARD8\tdeviceID;\n    CARD16\tsequenceNumber B16;\n    CARD32\tlength B32;\n    CARD16\tpresent B16;\n    CARD16\tsupported B16;\n    CARD16\tunsupported B16;\n    CARD16\tnDeviceLedFBs B16;\n    CARD8\tfirstBtnWanted;\n    CARD8\tnBtnsWanted;\n    CARD8\tfirstBtnRtrn;\n    CARD8\tnBtnsRtrn;\n    CARD8\ttotalBtns;\n    BOOL\thasOwnState;\n    CARD16\tdfltKbdFB B16;\n    CARD16\tdfltLedFB B16;\n    CARD16\tpad B16;\n    Atom\tdevType B32;\n} xkbGetDeviceInfoReply;\n#define\tsz_xkbGetDeviceInfoReply\t32\n\ntypedef struct _xkbSetDeviceInfo {\n    CARD8\treqType;\n    CARD8\txkbReqType;\t/* always X_KBSetDeviceInfo */\n    CARD16\tlength B16;\n    CARD16\tdeviceSpec B16;\n    CARD8\tfirstBtn;\n    CARD8\tnBtns;\n    CARD16\tchange B16;\n    CARD16\tnDeviceLedFBs B16;\n} xkbSetDeviceInfoReq;\n#define\tsz_xkbSetDeviceInfoReq\t12\n\ntypedef struct _xkbSetDebuggingFlags {\n    CARD8\treqType;\n    CARD8\txkbReqType;\t/* always X_KBSetDebuggingFlags */\n    CARD16\tlength B16;\n    CARD16\tmsgLength B16;\n    CARD16\tpad B16;\n    CARD32\taffectFlags B32;\n    CARD32\tflags B32;\n    CARD32\taffectCtrls B32;\n    CARD32\tctrls B32;\n} xkbSetDebuggingFlagsReq;\n#define\tsz_xkbSetDebuggingFlagsReq\t24\n\ntypedef struct _xkbSetDebuggingFlagsReply {\n    BYTE\ttype;\t\t/* X_Reply */\n    CARD8\tpad0;\n    CARD16\tsequenceNumber B16;\n    CARD32\tlength B32;\n    CARD32\tcurrentFlags B32;\n    CARD32\tcurrentCtrls B32;\n    CARD32\tsupportedFlags B32;\n    CARD32\tsupportedCtrls B32;\n    CARD32\tpad1 B32;\n    CARD32\tpad2 B32;\n} xkbSetDebuggingFlagsReply;\n#define\tsz_xkbSetDebuggingFlagsReply\t32\n\n\t/*\n\t * X KEYBOARD EXTENSION EVENT STRUCTURES\n\t */\n\ntypedef struct _xkbAnyEvent {\n    BYTE\ttype;\n    BYTE\txkbType;\n    CARD16\tsequenceNumber B16;\n    Time\ttime B32;\n    CARD8\tdeviceID;\n    CARD8\tpad1;\n    CARD16\tpad2 B16;\n    CARD32\tpad3 B32;\n    CARD32\tpad4 B32;\n    CARD32\tpad5 B32;\n    CARD32\tpad6 B32;\n    CARD32\tpad7 B32;\n} xkbAnyEvent;\n#define\tsz_xkbAnyEvent 32\n\ntypedef\tstruct _xkbNewKeyboardNotify {\n    BYTE\ttype;\n    BYTE\txkbType;\n    CARD16\tsequenceNumber B16;\n    Time\ttime B32;\n    CARD8\tdeviceID;\n    CARD8\toldDeviceID;\n    KeyCode\tminKeyCode;\n    KeyCode\tmaxKeyCode;\n    KeyCode\toldMinKeyCode;\n    KeyCode\toldMaxKeyCode;\n    CARD8\trequestMajor;\n    CARD8\trequestMinor;\n    CARD16\tchanged B16;\n    CARD8\tdetail;\n    CARD8\tpad1;\n    CARD32\tpad2 B32;\n    CARD32\tpad3 B32;\n    CARD32\tpad4 B32;\n} xkbNewKeyboardNotify;\n#define\tsz_xkbNewKeyboardNotify\t32\n\ntypedef\tstruct _xkbMapNotify {\n    BYTE\ttype;\n    BYTE\txkbType;\n    CARD16\tsequenceNumber B16;\n    Time\ttime B32;\n    CARD8\tdeviceID;\n    CARD8\tptrBtnActions;\n    CARD16\tchanged B16;\n    KeyCode\tminKeyCode;\n    KeyCode\tmaxKeyCode;\n    CARD8\tfirstType;\n    CARD8\tnTypes;\n    KeyCode\tfirstKeySym;\n    CARD8\tnKeySyms;\n    KeyCode\tfirstKeyAct;\n    CARD8\tnKeyActs;\n    KeyCode\tfirstKeyBehavior;\n    CARD8\tnKeyBehaviors;\n    KeyCode\tfirstKeyExplicit;\n    CARD8\tnKeyExplicit;\n    KeyCode\tfirstModMapKey;\n    CARD8\tnModMapKeys;\n    KeyCode\tfirstVModMapKey;\n    CARD8\tnVModMapKeys;\n    CARD16\tvirtualMods B16;\n    CARD16\tpad1 B16;\n} xkbMapNotify;\n#define\tsz_xkbMapNotify\t32\n\ntypedef\tstruct _xkbStateNotify {\n    BYTE\ttype;\n    BYTE\txkbType;\n    CARD16\tsequenceNumber B16;\n    Time\ttime B32;\n    CARD8\tdeviceID;\n    CARD8\tmods;\n    CARD8\tbaseMods;\n    CARD8\tlatchedMods;\n    CARD8\tlockedMods;\n    CARD8\tgroup;\n    INT16\tbaseGroup B16;\n    INT16\tlatchedGroup B16;\n    CARD8\tlockedGroup;\n    CARD8\tcompatState;\n    CARD8\tgrabMods;\n    CARD8\tcompatGrabMods;\n    CARD8\tlookupMods;\n    CARD8\tcompatLookupMods;\n    CARD16\tptrBtnState B16;\n    CARD16\tchanged B16;\n    KeyCode\tkeycode;\n    CARD8\teventType;\n    CARD8\trequestMajor;\n    CARD8\trequestMinor;\n} xkbStateNotify;\n#define\tsz_xkbStateNotify\t32\n\ntypedef struct _xkbControlsNotify {\n    BYTE\ttype;\n    BYTE\txkbType;\n    CARD16\tsequenceNumber B16;\n    Time\ttime B32;\n    CARD8\tdeviceID;\n    CARD8\tnumGroups;\n    CARD16\tpad1 B16;\n    CARD32\tchangedControls B32;\n    CARD32\tenabledControls B32;\n    CARD32\tenabledControlChanges B32;\n    KeyCode\tkeycode;\n    CARD8\teventType;\n    CARD8\trequestMajor;\n    CARD8\trequestMinor;\n    CARD32\tpad2 B32;\n} xkbControlsNotify;\n#define\tsz_xkbControlsNotify\t32\n\ntypedef struct _xkbIndicatorNotify {\n    BYTE\ttype;\n    BYTE\txkbType;\n    CARD16\tsequenceNumber B16;\n    Time\ttime B32;\n    CARD8\tdeviceID;\n    CARD8\tpad1;\n    CARD16\tpad2 B16;\n    CARD32\tstate B32;\n    CARD32\tchanged B32;\n    CARD32\tpad3 B32;\n    CARD32\tpad4 B32;\n    CARD32\tpad5 B32;\n} xkbIndicatorNotify;\n#define\tsz_xkbIndicatorNotify\t32\n\ntypedef struct _xkbNamesNotify {\n    BYTE\ttype;\n    BYTE\txkbType;\n    CARD16\tsequenceNumber B16;\n    Time\ttime B32;\n    CARD8\tdeviceID;\n    CARD8\tpad1;\n    CARD16\tchanged B16;\n    CARD8\tfirstType;\n    CARD8\tnTypes;\n    CARD8\tfirstLevelName;\n    CARD8\tnLevelNames;\n    CARD8\tpad2;\n    CARD8\tnRadioGroups;\n    CARD8\tnAliases;\n    CARD8\tchangedGroupNames;\n    CARD16\tchangedVirtualMods B16;\n    CARD8\tfirstKey;\n    CARD8\tnKeys;\n    CARD32\tchangedIndicators B32;\n    CARD32\tpad3 B32;\n} xkbNamesNotify;\n#define\tsz_xkbNamesNotify\t32\n\ntypedef struct _xkbCompatMapNotify {\n    BYTE\ttype;\n    BYTE\txkbType;\n    CARD16\tsequenceNumber B16;\n    Time\ttime B32;\n    CARD8\tdeviceID;\n    CARD8\tchangedGroups;\n    CARD16\tfirstSI B16;\n    CARD16\tnSI B16;\n    CARD16\tnTotalSI B16;\n    CARD32\tpad1 B32;\n    CARD32\tpad2 B32;\n    CARD32\tpad3 B32;\n    CARD32\tpad4 B32;\n} xkbCompatMapNotify;\n#define sz_xkbCompatMapNotify\t32\n\ntypedef struct _xkbBellNotify {\n    BYTE\ttype;\n    BYTE\txkbType;\n    CARD16\tsequenceNumber B16;\n    Time\ttime B32;\n    CARD8\tdeviceID;\n    CARD8\tbellClass;\n    CARD8\tbellID;\n    CARD8\tpercent;\n    CARD16\tpitch B16;\n    CARD16\tduration B16;\n    Atom\tname B32;\n    Window\twindow B32;\n    BOOL\teventOnly;\n    CARD8\tpad1;\n    CARD16\tpad2 B16;\n    CARD32\tpad3 B32;\n} xkbBellNotify;\n#define\tsz_xkbBellNotify\t32\n\ntypedef struct _xkbActionMessage {\n    BYTE\ttype;\n    BYTE\txkbType;\n    CARD16\tsequenceNumber B16;\n    Time\ttime B32;\n    CARD8\tdeviceID;\n    KeyCode\tkeycode;\n    BOOL\tpress;\n    BOOL\tkeyEventFollows;\n    CARD8\tmods;\n    CARD8\tgroup;\n    CARD8\tmessage[8];\n    CARD16\tpad1 B16;\n    CARD32\tpad2 B32;\n    CARD32\tpad3 B32;\n} xkbActionMessage;\n#define\tsz_xkbActionMessage\t\t32\n\ntypedef struct _xkbAccessXNotify {\n    BYTE\ttype;\n    BYTE\txkbType;\n    CARD16\tsequenceNumber B16;\n    Time\ttime B32;\n    CARD8\tdeviceID;\n    KeyCode\tkeycode;\n    CARD16\tdetail B16;\n    CARD16\tslowKeysDelay B16;\n    CARD16\tdebounceDelay B16;\n    CARD32\tpad1 B32;\n    CARD32\tpad2 B32;\n    CARD32\tpad3 B32;\n    CARD32\tpad4 B32;\n} xkbAccessXNotify;\n#define\tsz_xkbAccessXNotify\t32\n\ntypedef struct _xkbExtensionDeviceNotify {\n    BYTE\ttype;\n    BYTE\txkbType;\n    CARD16\tsequenceNumber B16;\n    Time\ttime B32;\n    CARD8\tdeviceID;\n    CARD8\tpad1;\n    CARD16\treason B16;\n    CARD16\tledClass B16;\n    CARD16\tledID B16;\n    CARD32\tledsDefined B32;\n    CARD32\tledState B32;\n    CARD8\tfirstBtn;\n    CARD8\tnBtns;\n    CARD16\tsupported B16;\n    CARD16\tunsupported B16;\n    CARD16\tpad3 B16;\n} xkbExtensionDeviceNotify;\n#define\tsz_xkbExtensionDeviceNotify\t\t32\n\ntypedef struct _xkbEvent {\n    union {\n\txkbAnyEvent\t\tany;\n\txkbNewKeyboardNotify\tnew_kbd;\n\txkbMapNotify\t\tmap;\n\txkbStateNotify\t\tstate;\n\txkbControlsNotify\tctrls;\n\txkbIndicatorNotify\tindicators;\n\txkbNamesNotify\t\tnames;\n\txkbCompatMapNotify\tcompat;\n\txkbBellNotify\t\tbell;\n\txkbActionMessage\tmessage;\n\txkbAccessXNotify\taccessx;\n\txkbExtensionDeviceNotify device;\n    } u;\n} xkbEvent;\n#define sz_xkbEvent\t32\n\n#undef Window\n#undef Atom\n#undef Time\n#undef KeyCode\n#undef KeySym\n\n#endif /* _XKBPROTO_H_ */\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/X11/extensions/XKBsrv.h",
    "content": "/************************************************************\nCopyright (c) 1993 by Silicon Graphics Computer Systems, Inc.\n\nPermission to use, copy, modify, and distribute this\nsoftware and its documentation for any purpose and without\nfee is hereby granted, provided that the above copyright\nnotice appear in all copies and that both that copyright\nnotice and this permission notice appear in supporting\ndocumentation, and that the name of Silicon Graphics not be \nused in advertising or publicity pertaining to distribution \nof the software without specific prior written permission.\nSilicon Graphics makes no representation about the suitability \nof this software for any purpose. It is provided \"as is\"\nwithout any express or implied warranty.\n\nSILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS \nSOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY \nAND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON\nGRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL \nDAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, \nDATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE \nOR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION  WITH\nTHE USE OR PERFORMANCE OF THIS SOFTWARE.\n\n********************************************************/\n\n#ifndef _XKBSRV_H_\n#define\t_XKBSRV_H_\n\n#ifdef XKB_IN_SERVER\n#define XkbAllocClientMap\t\tSrvXkbAllocClientMap\n#define XkbAllocServerMap\t\tSrvXkbAllocServerMap\n#define XkbChangeTypesOfKey\t\tSrvXkbChangeTypesOfKey\n#define\tXkbAddKeyType\t\t\tSrvXkbAddKeyType\n#define XkbCopyKeyType\t\t\tSrvXkbCopyKeyType\n#define XkbCopyKeyTypes\t\t\tSrvXkbCopyKeyTypes\n#define XkbFreeClientMap\t\tSrvXkbFreeClientMap\n#define XkbFreeServerMap\t\tSrvXkbFreeServerMap\n#define XkbInitCanonicalKeyTypes\tSrvXkbInitCanonicalKeyTypes\n#define\tXkbKeyTypesForCoreSymbols\tSrvXkbKeyTypesForCoreSymbols\n#define\tXkbApplyCompatMapToKey\t\tSrvXkbApplyCompatMapToKey\n#define\tXkbUpdateMapFromCore\t\tSrvXkbUpdateMapFromCore\n#define XkbResizeKeyActions\t\tSrvXkbResizeKeyActions\n#define XkbResizeKeySyms\t\tSrvXkbResizeKeySyms\n#define XkbResizeKeyType\t\tSrvXkbResizeKeyType\n#define XkbAllocCompatMap\t\tSrvXkbAllocCompatMap\n#define XkbAllocControls\t\tSrvXkbAllocControls\n#define XkbAllocIndicatorMaps\t\tSrvXkbAllocIndicatorMaps\n#define XkbAllocKeyboard\t\tSrvXkbAllocKeyboard\n#define XkbAllocNames\t\t\tSrvXkbAllocNames\n#define XkbFreeCompatMap\t\tSrvXkbFreeCompatMap\n#define XkbFreeControls\t\t\tSrvXkbFreeControls\n#define XkbFreeIndicatorMaps\t\tSrvXkbFreeIndicatorMaps\n#define XkbFreeKeyboard\t\t\tSrvXkbFreeKeyboard\n#define XkbFreeNames\t\t\tSrvXkbFreeNames\n#define\tXkbAddDeviceLedInfo\t\tSrvXkbAddDeviceLedInfo\n#define\tXkbAllocDeviceInfo\t\tSrvXkbAllocDeviceInfo\n#define\tXkbFreeDeviceInfo\t\tSrvXkbFreeDeviceInfo\n#define\tXkbResizeDeviceButtonActions\tSrvXkbResizeDeviceButtonActions\n#define XkbLatchModifiers\t\tSrvXkbLatchModifiers\n#define XkbLatchGroup\t\t\tSrvXkbLatchGroup\n#define XkbVirtualModsToReal\t\tSrvXkbVirtualModsToReal\n#define\tXkbChangeKeycodeRange\t\tSrvXkbChangeKeycodeRange\n#define\tXkbApplyVirtualModChanges\tSrvXkbApplyVirtualModChanges\n#define\tXkbUpdateActionVirtualMods\tSrvXkbUpdateActionVirtualMods\n#define XkbUpdateKeyTypeVirtualMods\tSrvXkbUpdateKeyTypeVirtualMods\n#endif\n\n#include <X11/extensions/XKBstr.h>\n#include <X11/extensions/XKBproto.h>\n#include \"inputstr.h\"\n\ntypedef struct _XkbInterest {\n\tDeviceIntPtr\t\tdev;\n\tClientPtr\t\tclient;\n\tXID\t\t\tresource;\n\tstruct _XkbInterest *\tnext;\n\tCARD16\t\t\textDevNotifyMask;\n\tCARD16\t\t\tstateNotifyMask;\n\tCARD16\t\t\tnamesNotifyMask;\n\tCARD32 \t\t\tctrlsNotifyMask;\n\tCARD8\t\t\tcompatNotifyMask;\n\tBOOL\t\t\tbellNotifyMask;\n\tBOOL\t\t\tactionMessageMask;\n\tCARD16\t\t\taccessXNotifyMask;\n\tCARD32\t\t\tiStateNotifyMask;\n\tCARD32\t\t\tiMapNotifyMask;\n\tCARD16\t\t\taltSymsNotifyMask;\n\tCARD32\t\t\tautoCtrls;\n\tCARD32\t\t\tautoCtrlValues;\n} XkbInterestRec,*XkbInterestPtr;\n\ntypedef struct _XkbRadioGroup {\n\tCARD8\t\tflags;\n\tCARD8\t\tnMembers;\n\tCARD8\t\tdfltDown;\n\tCARD8\t\tcurrentDown;\n\tCARD8\t\tmembers[XkbRGMaxMembers];\n} XkbRadioGroupRec, *XkbRadioGroupPtr;\n\ntypedef struct\t_XkbEventCause {\n\tCARD8\t\tkc;\n\tCARD8\t\tevent;\n\tCARD8\t\tmjr;\n\tCARD8\t\tmnr;\n\tClientPtr\tclient;\n} XkbEventCauseRec,*XkbEventCausePtr;\n#define\tXkbSetCauseKey(c,k,e)\t{ (c)->kc= (k),(c)->event= (e),\\\n\t\t\t\t  (c)->mjr= (c)->mnr= 0; \\\n\t\t\t\t  (c)->client= NULL; }\n#define\tXkbSetCauseReq(c,j,n,cl) { (c)->kc= (c)->event= 0,\\\n\t\t\t\t  (c)->mjr= (j),(c)->mnr= (n);\\\n\t\t\t\t  (c)->client= (cl); }\n#define\tXkbSetCauseCoreReq(c,e,cl) XkbSetCauseReq(c,e,0,cl)\n#define\tXkbSetCauseXkbReq(c,e,cl)  XkbSetCauseReq(c,XkbReqCode,e,cl)\n#define\tXkbSetCauseUnknown(c)\t   XkbSetCauseKey(c,0,0)\n\n#define\t_OFF_TIMER\t\t0\n#define\t_KRG_WARN_TIMER\t\t1\n#define\t_KRG_TIMER\t\t2\n#define\t_SK_TIMEOUT_TIMER\t3\n#define\t_ALL_TIMEOUT_TIMER\t4\n\n#define\t_BEEP_NONE\t\t0\n#define\t_BEEP_FEATURE_ON\t1\n#define\t_BEEP_FEATURE_OFF\t2\n#define\t_BEEP_FEATURE_CHANGE\t3\n#define\t_BEEP_SLOW_WARN\t\t4\n#define\t_BEEP_SLOW_PRESS\t5\n#define\t_BEEP_SLOW_ACCEPT\t6\n#define\t_BEEP_SLOW_REJECT\t7\n#define\t_BEEP_SLOW_RELEASE\t8\n#define\t_BEEP_STICKY_LATCH\t9\n#define\t_BEEP_STICKY_LOCK\t10\n#define\t_BEEP_STICKY_UNLOCK\t11\n#define\t_BEEP_LED_ON\t\t12\n#define\t_BEEP_LED_OFF\t\t13\n#define\t_BEEP_LED_CHANGE\t14\n#define\t_BEEP_BOUNCE_REJECT\t15\n\ntypedef struct _XkbSrvInfo {\n\tXkbStateRec\t prev_state;\n\tXkbStateRec\t state;\n\tXkbDescPtr\t desc;\n\n\tDeviceIntPtr\t device;\n\tKbdCtrlProcPtr\t kbdProc;\n\n\tXkbRadioGroupPtr radioGroups;\n\tCARD8\t\t nRadioGroups;\n\tCARD8\t\t clearMods;\n\tCARD8\t\t setMods;\n\tINT16\t\t groupChange;\n\n\tCARD16\t\t dfltPtrDelta;\n\n\tdouble\t\t mouseKeysCurve;\n\tdouble\t\t mouseKeysCurveFactor;\n\tINT16\t\t mouseKeysDX;\n\tINT16\t\t mouseKeysDY;\n\tCARD8\t\t mouseKeysFlags;\n\tBool\t\t mouseKeysAccel;\n\tCARD8\t\t mouseKeysCounter;\n\n\tCARD8\t\t lockedPtrButtons;\n\tCARD8\t\t shiftKeyCount;\n\tKeyCode\t\t mouseKey;\n\tKeyCode\t\t inactiveKey;\n\tKeyCode\t\t slowKey;\n\tKeyCode\t\t repeatKey;\n\tCARD8\t\t krgTimerActive;\n\tCARD8\t\t beepType;\n\tCARD8\t\t beepCount;\n\n\tCARD32\t\t flags;\n\tCARD32\t\t lastPtrEventTime;\n\tCARD32\t\t lastShiftEventTime;\n\tOsTimerPtr\t beepTimer;\n\tOsTimerPtr\t mouseKeyTimer;\n\tOsTimerPtr\t slowKeysTimer;\n\tOsTimerPtr\t bounceKeysTimer;\n\tOsTimerPtr\t repeatKeyTimer;\n\tOsTimerPtr\t krgTimer;\n} XkbSrvInfoRec, *XkbSrvInfoPtr;\n\n#define\tXkbSLI_IsDefault\t(1L<<0)\n#define\tXkbSLI_HasOwnState\t(1L<<1)\n\ntypedef struct\t_XkbSrvLedInfo {\n\tCARD16\t\t\tflags;\n\tCARD16\t\t\tclass;\n\tCARD16\t\t\tid;\n\tunion {\n\t    KbdFeedbackPtr\tkf;\n\t    LedFeedbackPtr\tlf;\n\t} \t\t\tfb;\n\n\tCARD32\t\t\tphysIndicators;\n\tCARD32\t\t\tautoState;\n\tCARD32\t\t\texplicitState;\n\tCARD32\t\t\teffectiveState;\n\n\tCARD32\t\t\tmapsPresent;\n\tCARD32\t\t\tnamesPresent;\n\tXkbIndicatorMapPtr\tmaps;\n\tAtom *\t\t\tnames;\n\n\tCARD32\t\t\tusesBase;\n\tCARD32\t\t\tusesLatched;\n\tCARD32\t\t\tusesLocked;\n\tCARD32\t\t\tusesEffective;\n\tCARD32\t\t\tusesCompat;\n\tCARD32\t\t\tusesControls;\n\n\tCARD32\t\t\tusedComponents;\n} XkbSrvLedInfoRec, *XkbSrvLedInfoPtr;\n\n/*\n * Settings for xkbClientFlags field (used by DIX)\n * These flags _must_ not overlap with XkbPCF_*\n */\n#define\t_XkbClientInitialized\t\t(1<<15)\n\n#define\t_XkbWantsDetectableAutoRepeat(c)\\\n\t((c)->xkbClientFlags&XkbPCF_DetectableAutoRepeatMask)\n\n/*\n * Settings for flags field\n */\n#define\t_XkbStateNotifyInProgress\t(1<<0)\n\ntypedef struct\n{\n    ProcessInputProc processInputProc;\n    ProcessInputProc realInputProc;\n    DeviceUnwrapProc unwrapProc;\n} xkbDeviceInfoRec, *xkbDeviceInfoPtr;\n\n#define WRAP_PROCESS_INPUT_PROC(device, oldprocs, proc, unwrapproc) \\\n\tdevice->public.processInputProc = proc; \\\n\toldprocs->processInputProc = \\\n\toldprocs->realInputProc = device->public.realInputProc; \\\n\tdevice->public.realInputProc = proc; \\\n\toldprocs->unwrapProc = device->unwrapProc; \\\n\tdevice->unwrapProc = unwrapproc;\n\n#define COND_WRAP_PROCESS_INPUT_PROC(device, oldprocs, proc, unwrapproc) \\\n\tif (device->public.processInputProc == device->public.realInputProc)\\\n\t    device->public.processInputProc = proc; \\\n\toldprocs->processInputProc = \\\n\toldprocs->realInputProc = device->public.realInputProc; \\\n\tdevice->public.realInputProc = proc; \\\n\toldprocs->unwrapProc = device->unwrapProc; \\\n\tdevice->unwrapProc = unwrapproc;\n\n#define UNWRAP_PROCESS_INPUT_PROC(device, oldprocs) \\\n\tdevice->public.processInputProc = oldprocs->processInputProc; \\\n\tdevice->public.realInputProc = oldprocs->realInputProc; \\\n\tdevice->unwrapProc = oldprocs->unwrapProc;\n\n#define XKBDEVICEINFO(dev) ((xkbDeviceInfoPtr) (dev)->devPrivates[xkbDevicePrivateIndex].ptr)\n\n/***====================================================================***/\n\n\n/***====================================================================***/\n\n#define XkbAX_KRGMask\t (XkbSlowKeysMask|XkbBounceKeysMask)\n#define\tXkbAllFilteredEventsMask \\\n\t(XkbAccessXKeysMask|XkbRepeatKeysMask|XkbMouseKeysAccelMask|XkbAX_KRGMask)\n\n/***====================================================================***/\n\nextern int\tXkbReqCode;\nextern int\tXkbEventBase;\nextern int\tXkbKeyboardErrorCode;\nextern int\tXkbDisableLockActions;\nextern char *\tXkbBaseDirectory;\nextern char *\tXkbBinDirectory;\nextern char *\tXkbInitialMap;\nextern int\t_XkbClientMajor;\nextern int\t_XkbClientMinor;\nextern unsigned\tint XkbXIUnsupported;\n\nextern char *\tXkbModelUsed,*XkbLayoutUsed,*XkbVariantUsed,*XkbOptionsUsed;\nextern Bool\tnoXkbExtension;\nextern Bool\tXkbWantRulesProp;\n\nextern pointer\tXkbLastRepeatEvent;\n\nextern CARD32\txkbDebugFlags;\nextern CARD32\txkbDebugCtrls;\n\n#define\t_XkbAlloc(s)\t\txalloc((s))\n#define\t_XkbCalloc(n,s)\t\tXcalloc((n)*(s))\n#define\t_XkbRealloc(o,s)\tXrealloc((o),(s))\n#define\t_XkbTypedAlloc(t)\t((t *)xalloc(sizeof(t)))\n#define\t_XkbTypedCalloc(n,t)\t((t *)Xcalloc((n)*sizeof(t)))\n#define\t_XkbTypedRealloc(o,n,t) \\\n\t((o)?(t *)Xrealloc((o),(n)*sizeof(t)):_XkbTypedCalloc(n,t))\n#define\t_XkbClearElems(a,f,l,t)\tbzero(&(a)[f],((l)-(f)+1)*sizeof(t))\n#define\t_XkbFree(p)\t\tXfree(p)\n\n#define\t_XkbLibError(c,l,d) \\\n\t{ _XkbErrCode= (c); _XkbErrLocation= (l); _XkbErrData= (d); }\n#define\t_XkbErrCode2(a,b) ((XID)((((unsigned int)(a))<<24)|((b)&0xffffff)))\n#define\t_XkbErrCode3(a,b,c)\t_XkbErrCode2(a,(((unsigned int)(b))<<16)|(c))\n#define\t_XkbErrCode4(a,b,c,d) _XkbErrCode3(a,b,((((unsigned int)(c))<<8)|(d)))\n\nextern\tint\tDeviceKeyPress,DeviceKeyRelease;\nextern\tint\tDeviceButtonPress,DeviceButtonRelease;\n\n#ifdef XINPUT\n#define\t_XkbIsPressEvent(t)\t(((t)==KeyPress)||((t)==DeviceKeyPress))\n#define\t_XkbIsReleaseEvent(t)\t(((t)==KeyRelease)||((t)==DeviceKeyRelease))\n#else\n#define\t_XkbIsPressEvent(t)\t((t)==KeyPress)\n#define\t_XkbIsReleaseEvent(t)\t((t)==KeyRelease)\n#endif\n\n#define\t_XkbCoreKeycodeInRange(c,k)\t(((k)>=(c)->curKeySyms.minKeyCode)&&\\\n\t\t\t\t\t ((k)<=(c)->curKeySyms.maxKeyCode))\n#define\t_XkbCoreNumKeys(c)\t((c)->curKeySyms.maxKeyCode-\\\n\t\t\t\t (c)->curKeySyms.minKeyCode+1)\n\n#define\tXConvertCase(s,l,u)\tXkbConvertCase(s,l,u)\n#undef\tIsKeypadKey\n#define\tIsKeypadKey(s)\t\tXkbKSIsKeypad(s)\n\ntypedef int Status;\ntypedef pointer XPointer;\ntypedef struct _XDisplay Display;\n\n#ifndef True\n#define\tTrue\t1\n#define\tFalse\t0\n#endif\n\n#ifndef PATH_MAX\n#ifdef MAXPATHLEN\n#define\tPATH_MAX MAXPATHLEN\n#else\n#define\tPATH_MAX 1024\n#endif\n#endif\n\n_XFUNCPROTOBEGIN\n\nextern void XkbUseMsg(\n    void\n);\n\nextern int XkbProcessArguments(\n    int\t\t\t\t/* argc */,\n    char **\t\t\t/* argv */,\n    int\t\t\t\t/* i */\n);\n\nextern\tvoid\tXkbSetExtension(DeviceIntPtr device, ProcessInputProc proc);\n\nextern\tvoid\tXkbFreeCompatMap(\n    XkbDescPtr\t\t\t/* xkb */,\n    unsigned int\t\t/* which */,\n    Bool\t\t\t/* freeMap */\n);\n\nextern\tvoid XkbFreeNames(\n\tXkbDescPtr\t\t/* xkb */,\n\tunsigned int\t\t/* which */,\n\tBool\t\t\t/* freeMap */\n);\n\nextern DeviceIntPtr _XkbLookupAnyDevice(\n    int\t\t\t/* id */,\n    int *\t\t/* why_rtrn */\n);\n\nextern DeviceIntPtr _XkbLookupKeyboard(\n    int\t\t\t/* id */,\n    int *\t\t/* why_rtrn */\n);\n\nextern DeviceIntPtr _XkbLookupBellDevice(\n    int\t\t\t/* id */,\n    int *\t\t/* why_rtrn */\n);\n\nextern DeviceIntPtr _XkbLookupLedDevice(\n    int\t\t\t/* id */,\n    int *\t\t/* why_rtrn */\n);\n\nextern DeviceIntPtr _XkbLookupButtonDevice(\n    int\t\t\t/* id */,\n    int *\t\t/* why_rtrn */\n);\n\nextern\tXkbDescPtr XkbAllocKeyboard(\n\tvoid\n);\n\nextern\tStatus XkbAllocClientMap(\n\tXkbDescPtr\t\t/* xkb */,\n\tunsigned int\t\t/* which */,\n\tunsigned int\t\t/* nTypes */\n);\n\nextern\tStatus XkbAllocServerMap(\n\tXkbDescPtr\t\t/* xkb */,\n\tunsigned int\t\t/* which */,\n\tunsigned int\t\t/* nNewActions */\n);\n\nextern\tvoid\tXkbFreeClientMap(\n    XkbDescPtr\t\t\t/* xkb */,\n    unsigned int\t\t/* what */,\n    Bool\t\t\t/* freeMap */\n);\n\nextern\tvoid\tXkbFreeServerMap(\n    XkbDescPtr\t\t\t/* xkb */,\n    unsigned int\t\t/* what */,\n    Bool\t\t\t/* freeMap */\n);\n\nextern\tStatus XkbAllocIndicatorMaps(\n\tXkbDescPtr\t\t/* xkb */\n);\n\nextern\tStatus\tXkbAllocCompatMap(\n    XkbDescPtr\t\t\t/* xkb */,\n    unsigned int\t\t/* which */,\n    unsigned int\t\t/* nInterpret */\n);\n\nextern\tStatus XkbAllocNames(\n\tXkbDescPtr\t\t/* xkb */,\n\tunsigned int\t\t/* which */,\n\tint\t\t\t/* nTotalRG */,\n\tint\t\t\t/* nTotalAliases */\n);\n\nextern\tStatus\tXkbAllocControls(\n\tXkbDescPtr\t\t/* xkb */,\n\tunsigned int\t\t/* which*/\n);\n\nextern\tStatus\tXkbCopyKeyType(\n    XkbKeyTypePtr\t\t/* from */,\n    XkbKeyTypePtr\t\t/* into */\n);\n\nextern\tStatus\tXkbCopyKeyTypes(\n    XkbKeyTypePtr\t\t/* from */,\n    XkbKeyTypePtr\t\t/* into */,\n    int\t\t\t\t/* num_types */\n);\n\nextern\tStatus\tXkbResizeKeyType(\n    XkbDescPtr\t\t/* xkb */,\n    int\t\t\t/* type_ndx */,\n    int\t\t\t/* map_count */,\n    Bool\t\t/* want_preserve */,\n    int\t\t\t/* new_num_lvls */\n);\n\nextern\tvoid\tXkbFreeKeyboard(\n\tXkbDescPtr\t\t/* xkb */,\n\tunsigned int\t\t/* which */,\n\tBool\t\t\t/* freeDesc */\n);\n\nextern  void XkbSetActionKeyMods(\n\tXkbDescPtr\t\t/* xkb */,\n\tXkbAction *\t\t/* act */,\n\tunsigned int \t\t/* mods */\n);\n\nextern Bool XkbCheckActionVMods(\n\tXkbDescPtr\t\t/* xkb */,\n\tXkbAction *\t\t/* act */,\n\tunsigned int \t\t/* changed */\n);\n\nextern Bool XkbApplyVModChanges(\n    XkbSrvInfoPtr\t/* xkbi */,\n    unsigned int\t/* changed */,\n    XkbChangesPtr\t/* pChanges */,\n    unsigned int *\t/* needChecksRtrn */,\n    XkbEventCausePtr\t/* cause */\n);\n\nextern void XkbApplyVModChangesToAllDevices(\n    DeviceIntPtr\t/* dev */,\n    XkbDescPtr \t\t/* xkb */,\n    unsigned int \t/* changed */,\n    XkbEventCausePtr\t/* cause */\n);\n\nextern\tunsigned int XkbMaskForVMask(\n    XkbDescPtr\t\t/* xkb */,\n    unsigned int\t/* vmask */\n);\n\nextern Bool XkbVirtualModsToReal(\n\tXkbDescPtr\t/* xkb */,\n\tunsigned int\t/* virtua_mask */,\n\tunsigned int *\t/* mask_rtrn */\n);\n\nextern\tunsigned int\tXkbAdjustGroup(\n    int\t\t\t/* group */,\n    XkbControlsPtr\t/* ctrls */\n);\n\nextern KeySym *XkbResizeKeySyms(\n    XkbDescPtr\t\t/* xkb */,\n    int \t\t/* key */,\n    int \t\t/* needed */\n);\n\nextern XkbAction *XkbResizeKeyActions(\n    XkbDescPtr\t\t/* xkb */,\n    int \t\t/* key */,\n    int \t\t/* needed */\n);\n\nextern void XkbUpdateKeyTypesFromCore(\n    DeviceIntPtr\t/* pXDev */,\n    KeyCode \t\t/* first */,\n    CARD8 \t\t/* num */,\n    XkbChangesPtr\t/* pChanges */\n);\n\nextern\tvoid XkbUpdateDescActions(\t\n    XkbDescPtr\t\t/* xkb */,\n    KeyCode\t\t/* first */,\n    CARD8\t\t/* num */,\n    XkbChangesPtr\t/* changes */\n);\n\nextern void XkbUpdateActions(\n    DeviceIntPtr\t/* pXDev */,\n    KeyCode \t\t/* first */,\n    CARD8 \t\t/* num */,\n    XkbChangesPtr  \t/* pChanges */,\n    unsigned int *\t/* needChecksRtrn */,\n    XkbEventCausePtr\t/* cause */\n);\n\nextern void XkbUpdateCoreDescription(\n    DeviceIntPtr\t/* keybd */,\n    Bool\t\t/* resize */\n);\n\nextern void XkbApplyMappingChange(\n    DeviceIntPtr\t/* pXDev */,\n    CARD8 \t\t/* request */,\n    KeyCode \t\t/* firstKey */,\n    CARD8 \t\t/* num */,\n    ClientPtr\t\t/* client */\n);\n\nextern void XkbSetIndicators(\n    DeviceIntPtr\t\t/* pXDev */,\n    CARD32\t\t\t/* affect */,\n    CARD32\t\t\t/* values */,\n    XkbEventCausePtr\t\t/* cause */\n);\n\nextern void XkbUpdateIndicators(\n    DeviceIntPtr\t\t/* keybd */,\n    CARD32\t\t \t/* changed */,\n    Bool\t\t\t/* check_edevs */,\n    XkbChangesPtr\t\t/* pChanges */,\n    XkbEventCausePtr\t\t/* cause */\n);\n\nextern XkbSrvLedInfoPtr XkbAllocSrvLedInfo(\n    DeviceIntPtr\t\t/* dev */,\n    KbdFeedbackPtr\t\t/* kf */,\n    LedFeedbackPtr\t\t/* lf */,\n    unsigned int\t\t/* needed_parts */\n);\n\nextern XkbSrvLedInfoPtr XkbFindSrvLedInfo(\n    DeviceIntPtr\t\t/* dev */,\n    unsigned int\t\t/* class */,\n    unsigned int\t\t/* id */,\n    unsigned int\t\t/* needed_parts */\n);\n\nextern void XkbApplyLedNameChanges(\n    DeviceIntPtr\t\t/* dev */,\n    XkbSrvLedInfoPtr\t\t/* sli */,\n    unsigned int\t\t/* changed_names */,\n    xkbExtensionDeviceNotify *\t/* ed */,\n    XkbChangesPtr\t\t/* changes */,\n    XkbEventCausePtr\t\t/* cause */\n);\n\nextern void XkbApplyLedMapChanges(\n    DeviceIntPtr\t\t/* dev */,\n    XkbSrvLedInfoPtr\t\t/* sli */,\n    unsigned int\t\t/* changed_maps */,\n    xkbExtensionDeviceNotify *\t/* ed */,\n    XkbChangesPtr\t\t/* changes */,\n    XkbEventCausePtr\t\t/* cause */\n);\n\nextern void XkbApplyLedStateChanges(\n    DeviceIntPtr\t\t/* dev */,\n    XkbSrvLedInfoPtr\t\t/* sli */,\n    unsigned int\t\t/* changed_leds */,\n    xkbExtensionDeviceNotify *\t/* ed */,\n    XkbChangesPtr\t\t/* changes */,\n    XkbEventCausePtr\t\t/* cause */\n);\n\nextern void XkbUpdateLedAutoState(\n    DeviceIntPtr\t\t/* dev */,\n    XkbSrvLedInfoPtr\t\t/* sli */,\n    unsigned int\t\t/* maps_to_check */,\n    xkbExtensionDeviceNotify *\t/* ed */,\n    XkbChangesPtr\t\t/* changes */,\n    XkbEventCausePtr\t\t/* cause */\n);\n\nextern void XkbFlushLedEvents(\t\n    DeviceIntPtr\t\t/* dev */,\n    DeviceIntPtr\t\t/* kbd */,\n    XkbSrvLedInfoPtr\t\t/* sli */,\n    xkbExtensionDeviceNotify *\t/* ed */,\n    XkbChangesPtr\t\t/* changes */,\n    XkbEventCausePtr\t\t/* cause */\n);\n\nextern void XkbUpdateAllDeviceIndicators(\n    XkbChangesPtr\t\t/* changes */,\n    XkbEventCausePtr\t\t/* cause */\n);\n\nextern unsigned int XkbIndicatorsToUpdate(\n    DeviceIntPtr\t\t/* dev */,\n    unsigned long\t\t/* state_changes */,\n    Bool\t\t\t/* enabled_ctrl_changes */\n);\n\nextern void XkbComputeDerivedState(\n    XkbSrvInfoPtr\t\t/* xkbi */\n);\n\nextern void XkbCheckSecondaryEffects(\n    XkbSrvInfoPtr\t\t/* xkbi */,\n    unsigned int\t\t/* which */,\n    XkbChangesPtr\t\t/* changes */,\n    XkbEventCausePtr\t\t/* cause */\n);\n\nextern void XkbCheckIndicatorMaps(\n    DeviceIntPtr\t\t/* dev */,\n    XkbSrvLedInfoPtr\t\t/* sli */,\n    unsigned int\t\t/* which */\n);\n\nextern unsigned int XkbStateChangedFlags(\n    XkbStatePtr\t\t\t/* old */,\n    XkbStatePtr\t\t\t/* new */\n);\n\nextern\tvoid XkbSendStateNotify(\n       DeviceIntPtr\t/* kbd */,\n       xkbStateNotify *\t/* pSN */\n);\n\nextern\tvoid XkbSendMapNotify(\n       DeviceIntPtr\t/* kbd */,\n       xkbMapNotify *\t/* ev */\n);\n\nextern\tint  XkbComputeControlsNotify(\n\tDeviceIntPtr\t\t/* kbd */,\n\tXkbControlsPtr\t\t/* old */,\n\tXkbControlsPtr\t\t/* new */,\n\txkbControlsNotify *\t/* pCN */,\n\tBool\t\t\t/* forceCtrlProc */\n);\n\nextern\tvoid XkbSendControlsNotify(\n       DeviceIntPtr\t\t/* kbd */,\n       xkbControlsNotify *\t/* ev */\n);\n\nextern\tvoid XkbSendCompatMapNotify(\n\tDeviceIntPtr\t\t/* kbd */,\n\txkbCompatMapNotify *\t/* ev */\n);\n\nextern\tvoid XkbSendIndicatorNotify(\n       DeviceIntPtr\t\t/* kbd */,\n       int\t\t\t/* xkbType */,\n       xkbIndicatorNotify *\t/* ev */\n);\n\nextern\tvoid XkbHandleBell(\n       BOOL\t\t/* force */,\n       BOOL\t\t/* eventOnly */,\n       DeviceIntPtr\t/* kbd */,\n       CARD8\t\t/* percent */,\n       pointer \t\t/* ctrl */,\n       CARD8\t\t/* class */,\n       Atom\t\t/* name */,\n       WindowPtr\t/* pWin */,\n       ClientPtr\t/* pClient */\n);\n\nextern\tvoid XkbSendAccessXNotify(\n       DeviceIntPtr\t\t/* kbd */,\n       xkbAccessXNotify *\t/* pEv */\n);\n\nextern\tvoid XkbSendNamesNotify(\n       DeviceIntPtr\t/* kbd */,\n       xkbNamesNotify *\t/* ev */\n);\n\nextern\tvoid XkbSendCompatNotify(\n       DeviceIntPtr\t\t/* kbd */,\n       xkbCompatMapNotify *\t/* ev */\n);\n\nextern\tvoid XkbSendActionMessage(\n       DeviceIntPtr\t\t/* kbd */,\n       xkbActionMessage *\t/* ev */\n);\n\nextern\tvoid XkbSendExtensionDeviceNotify(\n       DeviceIntPtr\t\t\t/* kbd */,\n       ClientPtr\t\t\t/* client */,\n       xkbExtensionDeviceNotify *\t/* ev */\n);\n\nextern void XkbSendNotification(\n    DeviceIntPtr\t\t/* kbd */,\n    XkbChangesPtr\t\t/* pChanges */,\n    XkbEventCausePtr\t\t/* cause */\n);\n\nextern void XkbProcessKeyboardEvent(\n    struct _xEvent * \t\t/* xE */,\n    DeviceIntPtr\t\t/* keybd */,\n    int \t\t\t/* count */\n);\n\nextern void XkbProcessOtherEvent(\n    struct _xEvent * \t\t/* xE */,\n    DeviceIntPtr\t\t/* keybd */,\n    int \t\t\t/* count */\n);\n\nextern void XkbHandleActions(\n    DeviceIntPtr\t\t/* dev */,\n    DeviceIntPtr\t\t/* kbd */,\n    struct _xEvent * \t\t/* xE */,\n    int \t\t\t/* count */\n);\n\nextern Bool XkbEnableDisableControls(\n    XkbSrvInfoPtr\t/* xkbi */,\n    unsigned long\t/* change */,\n    unsigned long\t/* newValues */,\n    XkbChangesPtr\t/* changes */,\n    XkbEventCausePtr\t/* cause */\n);\n\nextern void AccessXInit(\n    DeviceIntPtr        /* dev */\n);\n\nextern Bool AccessXFilterPressEvent(\n    register struct _xEvent *\t/* xE */,\n    register DeviceIntPtr\t/* keybd */,\n    int\t\t\t\t/* count */\n);\n\nextern Bool AccessXFilterReleaseEvent(\n    register struct _xEvent *\t/* xE */,\n    register DeviceIntPtr\t/* keybd */,\n    int\t\t\t\t/* count */\n);\n\nextern void AccessXCancelRepeatKey(\n    XkbSrvInfoPtr\t/* xkbi */,\n    KeyCode\t\t/* key */\n);\n\nextern void AccessXComputeCurveFactor(\n    XkbSrvInfoPtr\t/* xkbi */,\n    XkbControlsPtr\t/* ctrls */\n);\n\nextern\tXkbDeviceLedInfoPtr\tXkbAddDeviceLedInfo(\n\tXkbDeviceInfoPtr\t/* devi */,\n\tunsigned int\t\t/* ledClass */,\n\tunsigned int\t\t/* ledId */\n);\n\nextern\tXkbDeviceInfoPtr\tXkbAllocDeviceInfo(\n\tunsigned int\t\t/* deviceSpec */,\n\tunsigned int\t\t/* nButtons */,\n\tunsigned int\t\t/* szLeds */\n);\n\nextern\tvoid XkbFreeDeviceInfo(\n\tXkbDeviceInfoPtr\t/* devi */,\n\tunsigned int\t\t/* which */,\n\tBool\t\t\t/* freeDevI */\n);\n\nextern Status XkbResizeDeviceButtonActions(\n\tXkbDeviceInfoPtr        /* devi */,\n\tunsigned int            /* newTotal */\n);\n\nextern\tXkbInterestPtr XkbFindClientResource(\n       DevicePtr\t/* inDev */,\n       ClientPtr\t/* client */\n);\n\nextern\tXkbInterestPtr XkbAddClientResource(\n       DevicePtr\t/* inDev */,\n       ClientPtr\t/* client */,\n       XID\t\t/* id */\n);\n\nextern\tint XkbRemoveClient(\n       DevicePtr\t/* inDev */,\n       ClientPtr\t/* client */\n);\n\nextern\tint XkbRemoveResourceClient(\n       DevicePtr\t/* inDev */,\n       XID\t\t/* id */\n);\n\nextern int XkbDDXInitDevice(\n    DeviceIntPtr        /* dev */\n);\n\nextern\tint XkbDDXAccessXBeep(\n    DeviceIntPtr        /* dev */,\n    unsigned int\t/* what */,\n    unsigned int\t/* which */\n);\n\nextern\tvoid XkbDDXKeyClick(\n    DeviceIntPtr\t/* dev */,\n    int\t\t\t/* keycode */,\n    int\t\t\t/* synthetic */\n);\n\nextern \tint XkbDDXUsesSoftRepeat(\n    DeviceIntPtr\t/* dev */\n);\n\nextern\tvoid XkbDDXKeybdCtrlProc(\n\tDeviceIntPtr\t/* dev */,\n\tKeybdCtrl *\t/* ctrl */\n);\n\nextern void XkbDDXChangeControls(\n\tDeviceIntPtr\t/* dev */,\n\tXkbControlsPtr \t/* old */,\n\tXkbControlsPtr \t/* new */\n);\n\nextern void XkbDDXUpdateIndicators(\n\tDeviceIntPtr\t/* keybd */,\n\tCARD32\t\t/* newState */\n);\n\nextern void XkbDDXUpdateDeviceIndicators(\n\tDeviceIntPtr\t\t/* dev */,\n\tXkbSrvLedInfoPtr\t/* sli */,\n\tCARD32\t\t\t/* newState */\n);\n\nextern void XkbDDXFakePointerButton(\n\tint \t\t/* event */,\n\tint\t\t/* button */\n);\n\nextern void XkbDDXFakePointerMotion(\n \tunsigned int\t/* flags */,\n\tint\t\t/* x */,\n\tint\t\t/* y */\n);\n\nextern void XkbDDXFakeDeviceButton(\n\tDeviceIntPtr\t/* dev */,\n\tBool\t\t/* press */,\n\tint\t\t/* button */\n);\n\nextern int XkbDDXTerminateServer(\n\tDeviceIntPtr\t/* dev */,\n\tKeyCode\t\t/* key */,\n\tXkbAction *\t/* act */\n);\n\nextern int XkbDDXSwitchScreen(\n\tDeviceIntPtr\t/* dev */,\n\tKeyCode\t\t/* key */,\n\tXkbAction *\t/* act */\n);\n\nextern int XkbDDXPrivate(\n\tDeviceIntPtr\t/* dev */,\n\tKeyCode\t\t/* key */,\n\tXkbAction *\t/* act */\n);\n\nextern void XkbDisableComputedAutoRepeats(\n\tDeviceIntPtr \t/* pXDev */,\n\tunsigned int\t/* key */\n);\n\nextern void XkbSetRepeatKeys(\n\tDeviceIntPtr \t/* pXDev */,\n\tint\t\t/* key */,\n\tint\t \t/* onoff */\n);\n\nextern\tint XkbLatchModifiers(\n\tDeviceIntPtr \t/* pXDev */,\n\tCARD8 \t\t/* mask */,\n\tCARD8 \t\t/* latches */\n);\n\nextern\tint XkbLatchGroup(\n\tDeviceIntPtr  \t/* pXDev */,\n\tint\t  \t/* group */\n);\n\nextern\tvoid XkbClearAllLatchesAndLocks(\n\tDeviceIntPtr\t\t/* dev */,\n\tXkbSrvInfoPtr\t\t/* xkbi */,\n\tBool\t\t\t/* genEv */,\n\tXkbEventCausePtr\t/* cause */\n);\n\nextern\tvoid\tXkbSetRulesDflts(\n\tchar *\t\t\t/* rulesFile */,\n\tchar *\t\t\t/* model */,\n\tchar *\t\t\t/* layout */,\n\tchar *\t\t\t/* variant */,\n\tchar *\t\t\t/* options */\n);\n\nextern\tvoid\tXkbInitDevice(\n\tDeviceIntPtr \t/* pXDev */\n);\n\nextern\tBool\tXkbInitKeyboardDeviceStruct(\n\tDeviceIntPtr \t\t/* pXDev */,\n\tXkbComponentNamesPtr\t/* pNames */,\n\tKeySymsPtr\t\t/* pSyms */,\n\tCARD8 \t\t\t/* pMods */[],\n\tBellProcPtr\t\t/* bellProc */,\n\tKbdCtrlProcPtr\t\t/* ctrlProc */\n);\n\nextern\tint SProcXkbDispatch(\n\tClientPtr\t\t/* client */\n);\n\nextern XkbGeometryPtr XkbLookupNamedGeometry(\n\tDeviceIntPtr\t\t/* dev */,\n\tAtom\t\t\t/* name */,\n\tBool *\t\t\t/* shouldFree */\n);\n\nextern char *\t_XkbDupString(\n\tchar *\t\t\t/* str */\n);\n\nextern void\tXkbConvertCase(\n\tKeySym \t\t\t/* sym */,\n\tKeySym *\t\t/* lower */,\n\tKeySym *\t\t/* upper */\n);\n\nextern\tStatus\t XkbChangeKeycodeRange(\t\n\tXkbDescPtr\t\t/* xkb */,\n\tint \t\t\t/* minKC */,\n\tint \t\t\t/* maxKC */,\n\tXkbChangesPtr\t\t/* changes */\n);\n\nextern int XkbFinishDeviceInit(\n\tDeviceIntPtr\t\t/* pXDev */\n);\n\nextern void XkbFreeSrvLedInfo(\n\tXkbSrvLedInfoPtr\t/* sli */\n);\n\nextern void XkbFreeInfo(\n\tXkbSrvInfoPtr\t\t/* xkbi */\n);\n\nextern Status XkbChangeTypesOfKey(\n\tXkbDescPtr\t\t/* xkb */,\n\tint\t\t\t/* key */,\n\tint\t\t\t/* nGroups */,\n\tunsigned int\t\t/* groups */,\n\tint *\t\t\t/* newTypesIn */,\n\tXkbMapChangesPtr\t/* changes */\n);\n\nextern XkbKeyTypePtr XkbAddKeyType(\n\tXkbDescPtr\t\t/* xkb */,\n\tAtom\t\t\t/* name */,\n\tint\t\t\t/* map_count */,\n\tBool\t\t\t/* want_preserve */,\n\tint\t\t\t/* num_lvls */\n);\n\nextern Status XkbInitCanonicalKeyTypes(\n\tXkbDescPtr\t\t/* xkb */,\n\tunsigned int\t\t/* which */,\n\tint\t\t\t/* keypadVMod */\n);\n\nextern int XkbKeyTypesForCoreSymbols(\n\tXkbDescPtr\t\t/* xkb */,\n\tint\t\t\t/* map_width */,\n\tKeySym *\t\t/* core_syms */,\n\tunsigned int\t\t/* protected */,\n\tint *\t\t\t/* types_inout */,\n\tKeySym *\t\t/* xkb_syms_rtrn */\n);\n\nextern Bool XkbApplyCompatMapToKey(\n\tXkbDescPtr\t\t/* xkb */,\n\tKeyCode\t\t\t/* key */,\n\tXkbChangesPtr\t\t/* changes */\n);\n\nextern Bool XkbUpdateMapFromCore(\n\tXkbDescPtr\t\t/* xkb */,\n\tKeyCode\t\t\t/* first_key */,\n\tint\t\t\t/* num_keys */,\n\tint\t\t\t/* map_width */,\n\tKeySym *\t\t/* core_keysyms */,\n\tXkbChangesPtr\t\t/* changes */\n);\n\nextern void XkbFreeControls(\n\tXkbDescPtr\t\t/* xkb */,\n\tunsigned int\t\t/* which */,\n\tBool\t\t\t/* freeMap */\n);\n\nextern void XkbFreeIndicatorMaps(\n\tXkbDescPtr\t\t/* xkb */\n);\n\nextern Bool XkbApplyVirtualModChanges(\n\tXkbDescPtr\t\t/* xkb */,\n\tunsigned int\t\t/* changed */,\n\tXkbChangesPtr\t\t/* changes */\n);\n\nextern Bool XkbUpdateActionVirtualMods(\n\tXkbDescPtr\t\t/* xkb */,\n\tXkbAction *\t\t/* act */,\n\tunsigned int\t\t/* changed */\n);\n\nextern void XkbUpdateKeyTypeVirtualMods(\n\tXkbDescPtr\t\t/* xkb */,\n\tXkbKeyTypePtr\t\t/* type */,\n\tunsigned int\t\t/* changed */,\n\tXkbChangesPtr\t\t/* changes */\n);\n\nextern void XkbSendNewKeyboardNotify(\n\tDeviceIntPtr\t\t/* kbd */,\n\txkbNewKeyboardNotify *\t/* pNKN */\n);\n\n#ifdef XKBSRV_NEED_FILE_FUNCS\n\n#include <X11/extensions/XKMformat.h>\n#include <X11/extensions/XKBfile.h>\n#include <X11/extensions/XKBrules.h>\n\n#define\t_XkbListKeymaps\t\t0\n#define\t_XkbListKeycodes\t1\n#define\t_XkbListTypes\t\t2\n#define\t_XkbListCompat\t\t3\n#define\t_XkbListSymbols\t\t4\n#define\t_XkbListGeometry\t5\n#define\t_XkbListNumComponents\t6\n\ntypedef struct _XkbSrvListInfo {\n\tint\t\tszPool;\n\tint\t\tnPool;\n\tchar *\t\tpool;\n\n\tint\t\tmaxRtrn;\n\tint\t\tnTotal;\n\n\tchar *\t\tpattern[_XkbListNumComponents];\n\tint\t\tnFound[_XkbListNumComponents];\n} XkbSrvListInfoRec,*XkbSrvListInfoPtr;\n\nchar *\nXkbGetRulesDflts(\n\tXkbRF_VarDefsPtr\t/* defs */\n);\n\nextern void\tXkbSetRulesUsed(\n\tXkbRF_VarDefsPtr\t/* defs */\n);\n\n\nextern\tStatus\tXkbDDXList(\n\tDeviceIntPtr\t\t/* dev */,\n\tXkbSrvListInfoPtr\t/* listing */,\n\tClientPtr\t\t/* client */\n);\n\nextern\tunsigned int XkbDDXLoadKeymapByNames(\n\tDeviceIntPtr\t\t/* keybd */,\n\tXkbComponentNamesPtr\t/* names */,\n\tunsigned int\t\t/* want */,\n\tunsigned int\t\t/* need */,\n\tXkbFileInfoPtr\t\t/* finfoRtrn */,\n\tchar *\t\t\t/* keymapNameRtrn */,\n\tint \t\t\t/* keymapNameRtrnLen */\n);\n\nextern\tBool XkbDDXNamesFromRules(\n\tDeviceIntPtr\t\t/* keybd */,\n\tchar *\t\t\t/* rules */,\n\tXkbRF_VarDefsPtr\t/* defs */,\n\tXkbComponentNamesPtr\t/* names */\n);\n\nextern\tFILE *XkbDDXOpenConfigFile(\n\tchar *\t/* mapName */,\n\tchar *\t/* fileNameRtrn */,\n\tint\t/* fileNameRtrnLen */\n);\n\nextern\tBool XkbDDXApplyConfig(\n\tXPointer\t/* cfg_in */,\n\tXkbSrvInfoPtr\t/* xkbi */\n);\n\nextern XPointer XkbDDXPreloadConfig(\n\tchar **\t\t\t/* rulesFileRtrn */,\n\tXkbRF_VarDefsPtr\t/* defs */,\n\tXkbComponentNamesPtr\t/* names */,\n\tDeviceIntPtr\t\t/* dev */\n);\n\nextern\tint _XkbStrCaseCmp(\n\tchar *\t\t\t/* str1 */,\n\tchar *\t\t\t/* str2 */\n);\n\n#endif /* XKBSRV_NEED_FILE_FUNCS */\n\n\n_XFUNCPROTOEND\n\n#define\tXkbAtomGetString(d,s)\tNameForAtom(s)\n\n#endif /* _XKBSRV_H_ */\n\n\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/X11/extensions/XKBstr.h",
    "content": "/************************************************************\nCopyright (c) 1993 by Silicon Graphics Computer Systems, Inc.\n\nPermission to use, copy, modify, and distribute this\nsoftware and its documentation for any purpose and without\nfee is hereby granted, provided that the above copyright\nnotice appear in all copies and that both that copyright\nnotice and this permission notice appear in supporting\ndocumentation, and that the name of Silicon Graphics not be \nused in advertising or publicity pertaining to distribution \nof the software without specific prior written permission.\nSilicon Graphics makes no representation about the suitability \nof this software for any purpose. It is provided \"as is\"\nwithout any express or implied warranty.\n\nSILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS \nSOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY \nAND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON\nGRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL \nDAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, \nDATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE \nOR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION  WITH\nTHE USE OR PERFORMANCE OF THIS SOFTWARE.\n\n********************************************************/\n\n#ifndef _XKBSTR_H_\n#define\t_XKBSTR_H_\n\n#include <X11/extensions/XKB.h>\n\n#define\tXkbCharToInt(v)\t\t((v)&0x80?(int)((v)|(~0xff)):(int)((v)&0x7f))\n#define\tXkbIntTo2Chars(i,h,l)\t(((h)=((i>>8)&0xff)),((l)=((i)&0xff)))\n\n#if defined(WORD64) && defined(UNSIGNEDBITFIELDS)\n#define\tXkb2CharsToInt(h,l)\t((h)&0x80?(int)(((h)<<8)|(l)|(~0xffff)):\\\n\t\t\t\t\t  (int)(((h)<<8)|(l)&0x7fff))\n#else\n#define\tXkb2CharsToInt(h,l)\t((short)(((h)<<8)|(l)))\n#endif\n\n\t/*\n\t * Common data structures and access macros\n\t */\n\ntypedef struct _XkbStateRec {\n\tunsigned char\tgroup;\n\tunsigned char   locked_group;\n\tunsigned short\tbase_group;\n\tunsigned short\tlatched_group;\n\tunsigned char\tmods;\n\tunsigned char\tbase_mods;\n\tunsigned char\tlatched_mods;\n\tunsigned char\tlocked_mods;\n\tunsigned char\tcompat_state;\n\tunsigned char\tgrab_mods;\n\tunsigned char\tcompat_grab_mods;\n\tunsigned char\tlookup_mods;\n\tunsigned char\tcompat_lookup_mods;\n\tunsigned short\tptr_buttons;\n} XkbStateRec,*XkbStatePtr;\n#define\tXkbModLocks(s)\t ((s)->locked_mods)\n#define\tXkbStateMods(s)\t ((s)->base_mods|(s)->latched_mods|XkbModLocks(s))\n#define\tXkbGroupLock(s)\t ((s)->locked_group)\n#define\tXkbStateGroup(s) ((s)->base_group+(s)->latched_group+XkbGroupLock(s))\n#define\tXkbStateFieldFromRec(s)\tXkbBuildCoreState((s)->lookup_mods,(s)->group)\n#define\tXkbGrabStateFromRec(s)\tXkbBuildCoreState((s)->grab_mods,(s)->group)\n\ntypedef struct _XkbMods {\n\tunsigned char\tmask;\t/* effective mods */\n\tunsigned char\treal_mods;\n\tunsigned short\tvmods;\n} XkbModsRec,*XkbModsPtr;\n\ntypedef struct _XkbKTMapEntry {\n\tBool\t\tactive;\n\tunsigned char\tlevel;\n\tXkbModsRec\tmods;\n} XkbKTMapEntryRec,*XkbKTMapEntryPtr;\n\ntypedef struct _XkbKeyType {\n\tXkbModsRec\t\tmods;\n\tunsigned char\t  \tnum_levels;\n\tunsigned char\t  \tmap_count;\n\tXkbKTMapEntryPtr  \tmap;\n\tXkbModsPtr  \t\tpreserve;\n\tAtom\t\t  \tname;\n\tAtom *\t\t\tlevel_names;\n} XkbKeyTypeRec, *XkbKeyTypePtr;\n\n#define\tXkbNumGroups(g)\t\t\t((g)&0x0f)\n#define\tXkbOutOfRangeGroupInfo(g)\t((g)&0xf0)\n#define\tXkbOutOfRangeGroupAction(g)\t((g)&0xc0)\n#define\tXkbOutOfRangeGroupNumber(g)\t(((g)&0x30)>>4)\n#define\tXkbSetGroupInfo(g,w,n)\t(((w)&0xc0)|(((n)&3)<<4)|((g)&0x0f))\n#define\tXkbSetNumGroups(g,n)\t(((g)&0xf0)|((n)&0x0f))\n\n\t/*\n\t * Structures and access macros used primarily by the server\n\t */\n\ntypedef struct _XkbBehavior {\n\tunsigned char\ttype;\n\tunsigned char\tdata;\n} XkbBehavior;\n\n#define\tXkbAnyActionDataSize 7\ntypedef\tstruct _XkbAnyAction {\n\tunsigned char\ttype;\n\tunsigned char\tdata[XkbAnyActionDataSize];\n} XkbAnyAction;\n\ntypedef struct _XkbModAction {\n\tunsigned char\ttype;\n\tunsigned char\tflags;\n\tunsigned char\tmask;\n\tunsigned char\treal_mods;\n\tunsigned char\tvmods1;\n\tunsigned char\tvmods2;\n} XkbModAction;\n#define\tXkbModActionVMods(a)      \\\n\t((short)(((a)->vmods1<<8)|((a)->vmods2)))\n#define\tXkbSetModActionVMods(a,v) \\\n\t(((a)->vmods1=(((v)>>8)&0xff)),(a)->vmods2=((v)&0xff))\n\ntypedef struct _XkbGroupAction {\n\tunsigned char\ttype;\n\tunsigned char\tflags;\n\tchar\t\tgroup_XXX;\n} XkbGroupAction;\n#define\tXkbSAGroup(a)\t\t(XkbCharToInt((a)->group_XXX))\n#define\tXkbSASetGroup(a,g)\t((a)->group_XXX=(g))\n\ntypedef struct _XkbISOAction {\n\tunsigned char\ttype;\n\tunsigned char\tflags;\n\tunsigned char\tmask;\n\tunsigned char\treal_mods;\n\tchar\t\tgroup_XXX;\n\tunsigned char\taffect;\n\tunsigned char\tvmods1;\n\tunsigned char\tvmods2;\n} XkbISOAction;\n\ntypedef struct _XkbPtrAction {\n\tunsigned char\ttype;\n\tunsigned char\tflags;\n\tunsigned char\thigh_XXX;\n\tunsigned char\tlow_XXX;\n\tunsigned char\thigh_YYY;\n\tunsigned char\tlow_YYY;\n} XkbPtrAction;\n#define\tXkbPtrActionX(a)      (Xkb2CharsToInt((a)->high_XXX,(a)->low_XXX))\n#define\tXkbPtrActionY(a)      (Xkb2CharsToInt((a)->high_YYY,(a)->low_YYY))\n#define\tXkbSetPtrActionX(a,x) (XkbIntTo2Chars(x,(a)->high_XXX,(a)->low_XXX))\n#define\tXkbSetPtrActionY(a,y) (XkbIntTo2Chars(y,(a)->high_YYY,(a)->low_YYY))\n\ntypedef struct _XkbPtrBtnAction {\n\tunsigned char\ttype;\n\tunsigned char\tflags;\n\tunsigned char\tcount;\n\tunsigned char\tbutton;\n} XkbPtrBtnAction;\n\ntypedef struct _XkbPtrDfltAction {\n\tunsigned char\ttype;\n\tunsigned char\tflags;\n\tunsigned char\taffect;\n\tchar\t\tvalueXXX;\n} XkbPtrDfltAction;\n#define\tXkbSAPtrDfltValue(a)\t\t(XkbCharToInt((a)->valueXXX))\n#define\tXkbSASetPtrDfltValue(a,c)\t((a)->valueXXX= ((c)&0xff))\n\ntypedef struct _XkbSwitchScreenAction {\n\tunsigned char\ttype;\n\tunsigned char\tflags;\n\tchar\t\tscreenXXX;\n} XkbSwitchScreenAction;\n#define\tXkbSAScreen(a)\t\t\t(XkbCharToInt((a)->screenXXX))\n#define\tXkbSASetScreen(a,s)\t\t((a)->screenXXX= ((s)&0xff))\n\ntypedef struct _XkbCtrlsAction {\n\tunsigned char\ttype;\n\tunsigned char\tflags;\n\tunsigned char\tctrls3;\n\tunsigned char\tctrls2;\n\tunsigned char\tctrls1;\n\tunsigned char\tctrls0;\n} XkbCtrlsAction;\n#define\tXkbActionSetCtrls(a,c)\t(((a)->ctrls3=(((c)>>24)&0xff)),\\\n\t\t\t\t\t((a)->ctrls2=(((c)>>16)&0xff)),\\\n\t\t\t\t\t((a)->ctrls1=(((c)>>8)&0xff)),\\\n\t\t\t\t\t((a)->ctrls0=((c)&0xff)))\n#define\tXkbActionCtrls(a) ((((unsigned int)(a)->ctrls3)<<24)|\\\n\t\t\t   (((unsigned int)(a)->ctrls2)<<16)|\\\n\t\t\t   (((unsigned int)(a)->ctrls1)<<8)|\\\n\t\t\t   ((unsigned int)((a)->ctrls0)))\n\ntypedef struct _XkbMessageAction {\n\tunsigned char\ttype;\n\tunsigned char\tflags;\n\tunsigned char\tmessage[6];\n} XkbMessageAction;\n\ntypedef struct\t_XkbRedirectKeyAction {\n\tunsigned char\ttype;\n\tunsigned char\tnew_key;\n\tunsigned char\tmods_mask;\n\tunsigned char\tmods;\n\tunsigned char\tvmods_mask0;\n\tunsigned char\tvmods_mask1;\n\tunsigned char\tvmods0;\n\tunsigned char\tvmods1;\n} XkbRedirectKeyAction;\n\n#define\tXkbSARedirectVMods(a)\t\t((((unsigned int)(a)->vmods1)<<8)|\\\n\t\t\t\t\t((unsigned int)(a)->vmods0))\n#define\tXkbSARedirectSetVMods(a,m)\t(((a)->vmods_mask1=(((m)>>8)&0xff)),\\\n\t\t\t\t\t ((a)->vmods_mask0=((m)&0xff)))\n#define\tXkbSARedirectVModsMask(a)\t((((unsigned int)(a)->vmods_mask1)<<8)|\\\n\t\t\t\t\t((unsigned int)(a)->vmods_mask0))\n#define\tXkbSARedirectSetVModsMask(a,m)\t(((a)->vmods_mask1=(((m)>>8)&0xff)),\\\n\t\t\t\t\t ((a)->vmods_mask0=((m)&0xff)))\n\ntypedef struct _XkbDeviceBtnAction {\n\tunsigned char\ttype;\n\tunsigned char\tflags;\n\tunsigned char\tcount;\n\tunsigned char\tbutton;\n\tunsigned char\tdevice;\n} XkbDeviceBtnAction;\n\ntypedef struct _XkbDeviceValuatorAction {\n\tunsigned char\ttype;\n\tunsigned char\tdevice;\n\tunsigned char\tv1_what;\n\tunsigned char\tv1_ndx;\n\tunsigned char\tv1_value;\n\tunsigned char\tv2_what;\n\tunsigned char\tv2_ndx;\n\tunsigned char\tv2_value;\n} XkbDeviceValuatorAction;\n\ntypedef\tunion _XkbAction {\n\tXkbAnyAction\t\tany;\n\tXkbModAction\t\tmods;\n\tXkbGroupAction\t\tgroup;\n\tXkbISOAction\t\tiso;\n\tXkbPtrAction\t\tptr;\n\tXkbPtrBtnAction\t\tbtn;\n\tXkbPtrDfltAction\tdflt;\n\tXkbSwitchScreenAction\tscreen;\n\tXkbCtrlsAction\t\tctrls;\n\tXkbMessageAction\tmsg;\n\tXkbRedirectKeyAction\tredirect;\n\tXkbDeviceBtnAction\tdevbtn;\n\tXkbDeviceValuatorAction\tdevval;\n\tunsigned char \t\ttype;\n} XkbAction;\n\ntypedef\tstruct _XkbControls {\n\tunsigned char\tmk_dflt_btn;\n\tunsigned char\tnum_groups;\n\tunsigned char\tgroups_wrap;\n\tXkbModsRec\tinternal;\n\tXkbModsRec\tignore_lock;\n\tunsigned int\tenabled_ctrls;\n\tunsigned short\trepeat_delay;\n\tunsigned short\trepeat_interval;\n\tunsigned short\tslow_keys_delay;\n\tunsigned short\tdebounce_delay;\n\tunsigned short\tmk_delay;\n\tunsigned short\tmk_interval;\n\tunsigned short\tmk_time_to_max;\n\tunsigned short\tmk_max_speed;\n\t\t short\tmk_curve;\n\tunsigned short\tax_options;\n\tunsigned short\tax_timeout;\n\tunsigned short\taxt_opts_mask;\n\tunsigned short\taxt_opts_values;\n\tunsigned int\taxt_ctrls_mask;\n\tunsigned int\taxt_ctrls_values;\n\tunsigned char\tper_key_repeat[XkbPerKeyBitArraySize];\n} XkbControlsRec, *XkbControlsPtr;\n\n#define\tXkbAX_AnyFeedback(c)\t((c)->enabled_ctrls&XkbAccessXFeedbackMask)\n#define\tXkbAX_NeedOption(c,w)\t((c)->ax_options&(w))\n#define\tXkbAX_NeedFeedback(c,w)\t(XkbAX_AnyFeedback(c)&&XkbAX_NeedOption(c,w))\n\ntypedef struct _XkbServerMapRec {\n\tunsigned short\t\t num_acts;\n\tunsigned short\t\t size_acts;\n\tXkbAction\t\t*acts;\n\n\tXkbBehavior\t\t*behaviors;\n\tunsigned short\t\t*key_acts;\n#if defined(__cplusplus) || defined(c_plusplus)\n\t/* explicit is a C++ reserved word */\n\tunsigned char\t\t*c_explicit;\n#else\n\tunsigned char\t\t*explicit;\n#endif\n\tunsigned char\t\t vmods[XkbNumVirtualMods];\n\tunsigned short\t\t*vmodmap;\n} XkbServerMapRec, *XkbServerMapPtr;\n\n#define\tXkbSMKeyActionsPtr(m,k) (&(m)->acts[(m)->key_acts[k]])\n\n\t/*\n\t * Structures and access macros used primarily by clients\n\t */\n\ntypedef\tstruct _XkbSymMapRec {\n\tunsigned char\t kt_index[XkbNumKbdGroups];\n\tunsigned char\t group_info;\n\tunsigned char\t width;\n\tunsigned short\t offset;\n} XkbSymMapRec, *XkbSymMapPtr;\n\ntypedef struct _XkbClientMapRec {\n\tunsigned char\t\t size_types;\n\tunsigned char\t\t num_types;\n\tXkbKeyTypePtr\t\t types;\n\n\tunsigned short\t\t size_syms;\n\tunsigned short\t\t num_syms;\n\tKeySym\t\t\t*syms;\n\tXkbSymMapPtr\t\t key_sym_map;\n\n\tunsigned char\t\t*modmap;\n} XkbClientMapRec, *XkbClientMapPtr;\n\n#define\tXkbCMKeyGroupInfo(m,k)  ((m)->key_sym_map[k].group_info)\n#define\tXkbCMKeyNumGroups(m,k)\t (XkbNumGroups((m)->key_sym_map[k].group_info))\n#define\tXkbCMKeyGroupWidth(m,k,g) (XkbCMKeyType(m,k,g)->num_levels)\n#define\tXkbCMKeyGroupsWidth(m,k) ((m)->key_sym_map[k].width)\n#define\tXkbCMKeyTypeIndex(m,k,g) ((m)->key_sym_map[k].kt_index[g&0x3])\n#define\tXkbCMKeyType(m,k,g)\t (&(m)->types[XkbCMKeyTypeIndex(m,k,g)])\n#define\tXkbCMKeyNumSyms(m,k) (XkbCMKeyGroupsWidth(m,k)*XkbCMKeyNumGroups(m,k))\n#define\tXkbCMKeySymsOffset(m,k)\t((m)->key_sym_map[k].offset)\n#define\tXkbCMKeySymsPtr(m,k)\t(&(m)->syms[XkbCMKeySymsOffset(m,k)])\n\n\t/*\n\t * Compatibility structures and access macros\n\t */\n\ntypedef struct _XkbSymInterpretRec {\n\tKeySym\t\tsym;\n\tunsigned char\tflags;\n\tunsigned char\tmatch;\n\tunsigned char\tmods;\n\tunsigned char\tvirtual_mod;\n\tXkbAnyAction\tact;\n} XkbSymInterpretRec,*XkbSymInterpretPtr;\n\ntypedef struct _XkbCompatMapRec {\n\tXkbSymInterpretPtr\t sym_interpret;\n\tXkbModsRec\t\t groups[XkbNumKbdGroups];\n\tunsigned short\t\t num_si;\n\tunsigned short\t\t size_si;\n} XkbCompatMapRec, *XkbCompatMapPtr;\n\ntypedef struct _XkbIndicatorMapRec {\n\tunsigned char\tflags;\n\tunsigned char\twhich_groups;\n\tunsigned char\tgroups;\n\tunsigned char\twhich_mods;\n\tXkbModsRec\tmods;\n\tunsigned int\tctrls;\n} XkbIndicatorMapRec, *XkbIndicatorMapPtr;\n\n#define\tXkbIM_IsAuto(i)\t((((i)->flags&XkbIM_NoAutomatic)==0)&&\\\n\t\t\t    (((i)->which_groups&&(i)->groups)||\\\n\t\t\t     ((i)->which_mods&&(i)->mods.mask)||\\\n\t\t\t     ((i)->ctrls)))\n#define\tXkbIM_InUse(i)\t(((i)->flags)||((i)->which_groups)||\\\n\t\t\t\t\t((i)->which_mods)||((i)->ctrls))\n\t\n\ntypedef struct _XkbIndicatorRec {\n\tunsigned long\t  \tphys_indicators;\n\tXkbIndicatorMapRec\tmaps[XkbNumIndicators];\n} XkbIndicatorRec,*XkbIndicatorPtr;\n\ntypedef\tstruct _XkbKeyNameRec {\n\tchar\tname[XkbKeyNameLength];\n} XkbKeyNameRec,*XkbKeyNamePtr;\n\ntypedef struct _XkbKeyAliasRec {\n\tchar\treal[XkbKeyNameLength];\n\tchar\talias[XkbKeyNameLength];\n} XkbKeyAliasRec,*XkbKeyAliasPtr;\n\n\t/*\n\t * Names for everything \n\t */\ntypedef struct _XkbNamesRec {\n\tAtom\t\t  keycodes;\n\tAtom\t\t  geometry;\n\tAtom\t\t  symbols;\n\tAtom              types;\n\tAtom\t\t  compat;\n\tAtom\t\t  vmods[XkbNumVirtualMods];\n\tAtom\t\t  indicators[XkbNumIndicators];\n\tAtom\t\t  groups[XkbNumKbdGroups];\n\tXkbKeyNamePtr\t  keys;\n\tXkbKeyAliasPtr\t  key_aliases;\n\tAtom\t\t *radio_groups;\n\tAtom\t\t  phys_symbols;\n\n\tunsigned char\t  num_keys;\n\tunsigned char\t  num_key_aliases;\n\tunsigned short\t  num_rg;\n} XkbNamesRec,*XkbNamesPtr;\n\ntypedef\tstruct _XkbGeometry\t*XkbGeometryPtr;\n\t/*\n\t * Tie it all together into one big keyboard description\n\t */\ntypedef\tstruct _XkbDesc {\n\tstruct _XDisplay *\tdpy;\n\tunsigned short\t \tflags;\n\tunsigned short\t\tdevice_spec;\n\tKeyCode\t\t\tmin_key_code;\n\tKeyCode\t\t\tmax_key_code;\n\n\tXkbControlsPtr\t\tctrls;\n\tXkbServerMapPtr\t\tserver;\n\tXkbClientMapPtr\t\tmap;\n\tXkbIndicatorPtr\t\tindicators;\n\tXkbNamesPtr\t\tnames;\n\tXkbCompatMapPtr\t\tcompat;\n\tXkbGeometryPtr\t\tgeom;\n} XkbDescRec, *XkbDescPtr;\n#define\tXkbKeyKeyTypeIndex(d,k,g)\t(XkbCMKeyTypeIndex((d)->map,k,g))\n#define\tXkbKeyKeyType(d,k,g)\t\t(XkbCMKeyType((d)->map,k,g))\n#define\tXkbKeyGroupWidth(d,k,g)\t\t(XkbCMKeyGroupWidth((d)->map,k,g))\n#define\tXkbKeyGroupsWidth(d,k)\t\t(XkbCMKeyGroupsWidth((d)->map,k))\n#define\tXkbKeyGroupInfo(d,k)\t\t(XkbCMKeyGroupInfo((d)->map,(k)))\n#define\tXkbKeyNumGroups(d,k)\t\t(XkbCMKeyNumGroups((d)->map,(k)))\n#define\tXkbKeyNumSyms(d,k)\t\t(XkbCMKeyNumSyms((d)->map,(k)))\n#define\tXkbKeySymsPtr(d,k)\t\t(XkbCMKeySymsPtr((d)->map,(k)))\n#define\tXkbKeySym(d,k,n)\t\t(XkbKeySymsPtr(d,k)[n])\n#define\tXkbKeySymEntry(d,k,sl,g) \\\n\t(XkbKeySym(d,k,((XkbKeyGroupsWidth(d,k)*(g))+(sl))))\n#define\tXkbKeyAction(d,k,n) \\\n\t(XkbKeyHasActions(d,k)?&XkbKeyActionsPtr(d,k)[n]:NULL)\n#define\tXkbKeyActionEntry(d,k,sl,g) \\\n\t(XkbKeyHasActions(d,k)?\\\n\t\tXkbKeyAction(d,k,((XkbKeyGroupsWidth(d,k)*(g))+(sl))):NULL)\n\n#define\tXkbKeyHasActions(d,k)\t((d)->server->key_acts[k]!=0)\n#define\tXkbKeyNumActions(d,k)\t(XkbKeyHasActions(d,k)?XkbKeyNumSyms(d,k):1)\n#define\tXkbKeyActionsPtr(d,k)\t(XkbSMKeyActionsPtr((d)->server,k))\n#define\tXkbKeycodeInRange(d,k)\t(((k)>=(d)->min_key_code)&&\\\n\t\t\t\t ((k)<=(d)->max_key_code))\n#define\tXkbNumKeys(d)\t\t((d)->max_key_code-(d)->min_key_code+1)\n\n\n\t/*\n\t * The following structures can be used to track changes\n\t * to a keyboard device\n\t */\ntypedef struct _XkbMapChanges {\n\tunsigned short\t\t changed;\n\tKeyCode\t\t\t min_key_code;\n\tKeyCode\t\t\t max_key_code;\n\tunsigned char\t\t first_type;\n\tunsigned char\t\t num_types;\n\tKeyCode\t\t\t first_key_sym;\n\tunsigned char\t\t num_key_syms;\n\tKeyCode\t\t\t first_key_act;\n\tunsigned char\t\t num_key_acts;\n\tKeyCode\t\t\t first_key_behavior;\n\tunsigned char\t\t num_key_behaviors;\n\tKeyCode \t\t first_key_explicit;\n\tunsigned char\t\t num_key_explicit;\n\tKeyCode\t\t\t first_modmap_key;\n\tunsigned char\t\t num_modmap_keys;\n\tKeyCode\t\t\t first_vmodmap_key;\n\tunsigned char\t\t num_vmodmap_keys;\n\tunsigned char\t\t pad;\n\tunsigned short\t\t vmods;\n} XkbMapChangesRec,*XkbMapChangesPtr;\n\ntypedef struct _XkbControlsChanges {\n\tunsigned int \t\t changed_ctrls;\n\tunsigned int\t\t enabled_ctrls_changes;\n\tBool\t\t\t num_groups_changed;\n} XkbControlsChangesRec,*XkbControlsChangesPtr;\n\ntypedef struct _XkbIndicatorChanges {\n\tunsigned int\t\t state_changes;\n\tunsigned int\t\t map_changes;\n} XkbIndicatorChangesRec,*XkbIndicatorChangesPtr;\n\ntypedef struct _XkbNameChanges {\n\tunsigned int \t\tchanged;\n\tunsigned char\t\tfirst_type;\n\tunsigned char\t\tnum_types;\n\tunsigned char\t\tfirst_lvl;\n\tunsigned char\t\tnum_lvls;\n\tunsigned char\t\tnum_aliases;\n\tunsigned char\t\tnum_rg;\n\tunsigned char\t\tfirst_key;\n\tunsigned char\t\tnum_keys;\n\tunsigned short\t\tchanged_vmods;\n\tunsigned long\t\tchanged_indicators;\n\tunsigned char\t\tchanged_groups;\n} XkbNameChangesRec,*XkbNameChangesPtr;\n\ntypedef struct _XkbCompatChanges {\n\tunsigned char\t\tchanged_groups;\n\tunsigned short\t\tfirst_si;\n\tunsigned short\t\tnum_si;\n} XkbCompatChangesRec,*XkbCompatChangesPtr;\n\ntypedef struct _XkbChanges {\n\tunsigned short\t\t device_spec;\n\tunsigned short\t\t state_changes;\n\tXkbMapChangesRec\t map;\n\tXkbControlsChangesRec\t ctrls;\n\tXkbIndicatorChangesRec\t indicators;\n\tXkbNameChangesRec\t names;\n\tXkbCompatChangesRec\t compat;\n} XkbChangesRec, *XkbChangesPtr;\n\n\t/*\n\t * These data structures are used to construct a keymap from \n\t * a set of components or to list components in the server\n\t * database.\n\t */\ntypedef struct _XkbComponentNames {\n\tchar *\t\t\t keymap;\n\tchar *\t\t\t keycodes;\n\tchar *\t\t\t types;\n\tchar *\t\t\t compat;\n\tchar *\t\t\t symbols;\n\tchar *\t\t\t geometry;\n} XkbComponentNamesRec, *XkbComponentNamesPtr;\n\ntypedef struct _XkbComponentName {\n\tunsigned short\t\tflags;\n\tchar *\t\t\tname;\n} XkbComponentNameRec,*XkbComponentNamePtr;\n\ntypedef struct _XkbComponentList {\n\tint\t\t\tnum_keymaps;\n\tint\t\t\tnum_keycodes;\n\tint\t\t\tnum_types;\n\tint\t\t\tnum_compat;\n\tint\t\t\tnum_symbols;\n\tint\t\t\tnum_geometry;\n\tXkbComponentNamePtr\tkeymaps;\n\tXkbComponentNamePtr \tkeycodes;\n\tXkbComponentNamePtr\ttypes;\n\tXkbComponentNamePtr\tcompat;\n\tXkbComponentNamePtr\tsymbols;\n\tXkbComponentNamePtr\tgeometry;\n} XkbComponentListRec, *XkbComponentListPtr;\n\n\t/*\n\t * The following data structures describe and track changes to a \n\t * non-keyboard extension device \n\t */\ntypedef struct _XkbDeviceLedInfo {\n\tunsigned short\t\t\tled_class;\n\tunsigned short\t\t\tled_id;\n\tunsigned int\t\t\tphys_indicators;\n\tunsigned int\t\t\tmaps_present;\n\tunsigned int\t\t\tnames_present;\n\tunsigned int\t\t\tstate;\n\tAtom \t\t\t\tnames[XkbNumIndicators];\n\tXkbIndicatorMapRec\t\tmaps[XkbNumIndicators];\n} XkbDeviceLedInfoRec,*XkbDeviceLedInfoPtr;\n\ntypedef struct _XkbDeviceInfo {\n\tchar *\t\t\tname;\n\tAtom\t\t\ttype;\n\tunsigned short\t\tdevice_spec;\n\tBool\t\t\thas_own_state;\n\tunsigned short\t\tsupported;\n\tunsigned short\t\tunsupported;\n\n\tunsigned short\t\tnum_btns;\n\tXkbAction *\t\tbtn_acts;\n\n\tunsigned short\t\tsz_leds;\n\tunsigned short\t\tnum_leds;\n\tunsigned short\t\tdflt_kbd_fb;\n\tunsigned short\t\tdflt_led_fb;\n\tXkbDeviceLedInfoPtr\tleds;\n} XkbDeviceInfoRec,*XkbDeviceInfoPtr;\n\n#define\tXkbXI_DevHasBtnActs(d)\t(((d)->num_btns>0)&&((d)->btn_acts!=NULL))\n#define\tXkbXI_LegalDevBtn(d,b)\t(XkbXI_DevHasBtnActs(d)&&((b)<(d)->num_btns))\n#define\tXkbXI_DevHasLeds(d)\t(((d)->num_leds>0)&&((d)->leds!=NULL))\n\ntypedef struct _XkbDeviceLedChanges {\n\tunsigned short\t\tled_class;\n\tunsigned short\t\tled_id;\n\tunsigned int\t\tdefined; /* names or maps changed */\n\tstruct _XkbDeviceLedChanges *next;\n} XkbDeviceLedChangesRec,*XkbDeviceLedChangesPtr;\n\ntypedef struct _XkbDeviceChanges {\n\tunsigned int\t\tchanged;\n\tunsigned short\t\tfirst_btn;\n\tunsigned short\t\tnum_btns;\n\tXkbDeviceLedChangesRec \tleds;\n} XkbDeviceChangesRec,*XkbDeviceChangesPtr;\n\n#endif /* _XKBSTR_H_ */\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/X11/keysym.h",
    "content": "/***********************************************************\n\nCopyright 1987, 1998  The Open Group\n\nPermission to use, copy, modify, distribute, and sell this software and its\ndocumentation for any purpose is hereby granted without fee, provided that\nthe above copyright notice appear in all copies and that both that\ncopyright notice and this permission notice appear in supporting\ndocumentation.\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE\nOPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN\nAN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\nCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\nExcept as contained in this notice, the name of The Open Group shall not be\nused in advertising or otherwise to promote the sale, use or other dealings\nin this Software without prior written authorization from The Open Group.\n\n\nCopyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.\n\n                        All Rights Reserved\n\nPermission to use, copy, modify, and distribute this software and its \ndocumentation for any purpose and without fee is hereby granted, \nprovided that the above copyright notice appear in all copies and that\nboth that copyright notice and this permission notice appear in \nsupporting documentation, and that the name of Digital not be\nused in advertising or publicity pertaining to distribution of the\nsoftware without specific, written prior permission.  \n\nDIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING\nALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL\nDIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR\nANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,\nWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,\nARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS\nSOFTWARE.\n\n******************************************************************/\n\n/* default keysyms */\n#define XK_MISCELLANY\n#define XK_XKB_KEYS\n#define XK_LATIN1\n#define XK_LATIN2\n#define XK_LATIN3\n#define XK_LATIN4\n#define XK_LATIN8\n#define XK_LATIN9\n#define XK_CAUCASUS\n#define XK_GREEK\n#define XK_KATAKANA\n#define XK_ARABIC\n#define XK_CYRILLIC\n#define XK_HEBREW\n#define XK_THAI\n#define XK_KOREAN\n#define XK_ARMENIAN\n#define XK_GEORGIAN\n#define XK_VIETNAMESE\n#define XK_CURRENCY\n#define XK_MATHEMATICAL\n#define XK_BRAILLE\n#define XK_SINHALA\n\n#include <X11/keysymdef.h>\n\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/X11/keysymdef.h",
    "content": "/***********************************************************\nCopyright 1987, 1994, 1998  The Open Group\n\nPermission to use, copy, modify, distribute, and sell this software and its\ndocumentation for any purpose is hereby granted without fee, provided that\nthe above copyright notice appear in all copies and that both that\ncopyright notice and this permission notice appear in supporting\ndocumentation.\n\nThe above copyright notice and this permission notice shall be included\nin all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\nOR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR\nOTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,\nARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\nOTHER DEALINGS IN THE SOFTWARE.\n\nExcept as contained in this notice, the name of The Open Group shall\nnot be used in advertising or otherwise to promote the sale, use or\nother dealings in this Software without prior written authorization\nfrom The Open Group.\n\n\nCopyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts\n\n                        All Rights Reserved\n\nPermission to use, copy, modify, and distribute this software and its\ndocumentation for any purpose and without fee is hereby granted,\nprovided that the above copyright notice appear in all copies and that\nboth that copyright notice and this permission notice appear in\nsupporting documentation, and that the name of Digital not be\nused in advertising or publicity pertaining to distribution of the\nsoftware without specific, written prior permission.\n\nDIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING\nALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL\nDIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR\nANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,\nWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,\nARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS\nSOFTWARE.\n\n******************************************************************/\n\n/*\n * The \"X11 Window System Protocol\" standard defines in Appendix A the\n * keysym codes. These 29-bit integer values identify characters or\n * functions associated with each key (e.g., via the visible\n * engraving) of a keyboard layout. This file assigns mnemonic macro\n * names for these keysyms.\n *\n * This file is also compiled (by src/util/makekeys.c in libX11) into\n * hash tables that can be accessed with X11 library functions such as\n * XStringToKeysym() and XKeysymToString().\n *\n * Where a keysym corresponds one-to-one to an ISO 10646 / Unicode\n * character, this is noted in a comment that provides both the U+xxxx\n * Unicode position, as well as the official Unicode name of the\n * character.\n *\n * Where the correspondence is either not one-to-one or semantically\n * unclear, the Unicode position and name are enclosed in\n * parentheses. Such legacy keysyms should be considered deprecated\n * and are not recommended for use in future keyboard mappings.\n *\n * For any future extension of the keysyms with characters already\n * found in ISO 10646 / Unicode, the following algorithm shall be\n * used. The new keysym code position will simply be the character's\n * Unicode number plus 0x01000000. The keysym values in the range\n * 0x01000100 to 0x0110ffff are reserved to represent Unicode\n * characters in the range U+0100 to U+10FFFF.\n * \n * While most newer Unicode-based X11 clients do already accept\n * Unicode-mapped keysyms in the range 0x01000100 to 0x0110ffff, it\n * will remain necessary for clients -- in the interest of\n * compatibility with existing servers -- to also understand the\n * existing legacy keysym values in the range 0x0100 to 0x20ff.\n *\n * Where several mnemonic names are defined for the same keysym in this\n * file, all but the first one listed should be considered deprecated.\n *\n * Mnemonic names for keysyms are defined in this file with lines\n * that match one of these Perl regular expressions:\n *\n *    /^\\#define XK_([a-zA-Z_0-9]+)\\s+0x([0-9a-f]+)\\s*\\/\\* U+([0-9A-F]{4,6}) (.*) \\*\\/\\s*$/\n *    /^\\#define XK_([a-zA-Z_0-9]+)\\s+0x([0-9a-f]+)\\s*\\/\\*\\(U+([0-9A-F]{4,6}) (.*)\\)\\*\\/\\s*$/\n *    /^\\#define XK_([a-zA-Z_0-9]+)\\s+0x([0-9a-f]+)\\s*(\\/\\*\\s*(.*)\\s*\\*\\/)?\\s*$/\n *\n * Before adding new keysyms, please do consider the following: In\n * addition to the keysym names defined in this file, the\n * XStringToKeysym() and XKeysymToString() functions will also handle\n * any keysym string of the form \"U0020\" to \"U007E\" and \"U00A0\" to\n * \"U10FFFF\" for all possible Unicode characters. In other words,\n * every possible Unicode character has already a keysym string\n * defined algorithmically, even if it is not listed here. Therefore,\n * defining an additional keysym macro is only necessary where a\n * non-hexadecimal mnemonic name is needed, or where the new keysym\n * does not represent any existing Unicode character.\n *\n * When adding new keysyms to this file, do not forget to also update the\n * following as needed:\n *\n *   - the mappings in src/KeyBind.c in the repo\n *     git://anongit.freedesktop.org/xorg/lib/libX11.git\n *\n *   - the protocol specification in specs/keysyms.xml\n *     in the repo git://anongit.freedesktop.org/xorg/proto/x11proto.git\n *\n */\n\n#define XK_VoidSymbol                  0xffffff  /* Void symbol */\n\n#ifdef XK_MISCELLANY\n/*\n * TTY function keys, cleverly chosen to map to ASCII, for convenience of\n * programming, but could have been arbitrary (at the cost of lookup\n * tables in client code).\n */\n\n#define XK_BackSpace                     0xff08  /* Back space, back char */\n#define XK_Tab                           0xff09\n#define XK_Linefeed                      0xff0a  /* Linefeed, LF */\n#define XK_Clear                         0xff0b\n#define XK_Return                        0xff0d  /* Return, enter */\n#define XK_Pause                         0xff13  /* Pause, hold */\n#define XK_Scroll_Lock                   0xff14\n#define XK_Sys_Req                       0xff15\n#define XK_Escape                        0xff1b\n#define XK_Delete                        0xffff  /* Delete, rubout */\n\n\n\n/* International & multi-key character composition */\n\n#define XK_Multi_key                     0xff20  /* Multi-key character compose */\n#define XK_Codeinput                     0xff37\n#define XK_SingleCandidate               0xff3c\n#define XK_MultipleCandidate             0xff3d\n#define XK_PreviousCandidate             0xff3e\n\n/* Japanese keyboard support */\n\n#define XK_Kanji                         0xff21  /* Kanji, Kanji convert */\n#define XK_Muhenkan                      0xff22  /* Cancel Conversion */\n#define XK_Henkan_Mode                   0xff23  /* Start/Stop Conversion */\n#define XK_Henkan                        0xff23  /* Alias for Henkan_Mode */\n#define XK_Romaji                        0xff24  /* to Romaji */\n#define XK_Hiragana                      0xff25  /* to Hiragana */\n#define XK_Katakana                      0xff26  /* to Katakana */\n#define XK_Hiragana_Katakana             0xff27  /* Hiragana/Katakana toggle */\n#define XK_Zenkaku                       0xff28  /* to Zenkaku */\n#define XK_Hankaku                       0xff29  /* to Hankaku */\n#define XK_Zenkaku_Hankaku               0xff2a  /* Zenkaku/Hankaku toggle */\n#define XK_Touroku                       0xff2b  /* Add to Dictionary */\n#define XK_Massyo                        0xff2c  /* Delete from Dictionary */\n#define XK_Kana_Lock                     0xff2d  /* Kana Lock */\n#define XK_Kana_Shift                    0xff2e  /* Kana Shift */\n#define XK_Eisu_Shift                    0xff2f  /* Alphanumeric Shift */\n#define XK_Eisu_toggle                   0xff30  /* Alphanumeric toggle */\n#define XK_Kanji_Bangou                  0xff37  /* Codeinput */\n#define XK_Zen_Koho                      0xff3d  /* Multiple/All Candidate(s) */\n#define XK_Mae_Koho                      0xff3e  /* Previous Candidate */\n\n/* 0xff31 thru 0xff3f are under XK_KOREAN */\n\n/* Cursor control & motion */\n\n#define XK_Home                          0xff50\n#define XK_Left                          0xff51  /* Move left, left arrow */\n#define XK_Up                            0xff52  /* Move up, up arrow */\n#define XK_Right                         0xff53  /* Move right, right arrow */\n#define XK_Down                          0xff54  /* Move down, down arrow */\n#define XK_Prior                         0xff55  /* Prior, previous */\n#define XK_Page_Up                       0xff55\n#define XK_Next                          0xff56  /* Next */\n#define XK_Page_Down                     0xff56\n#define XK_End                           0xff57  /* EOL */\n#define XK_Begin                         0xff58  /* BOL */\n\n\n/* Misc functions */\n\n#define XK_Select                        0xff60  /* Select, mark */\n#define XK_Print                         0xff61\n#define XK_Execute                       0xff62  /* Execute, run, do */\n#define XK_Insert                        0xff63  /* Insert, insert here */\n#define XK_Undo                          0xff65\n#define XK_Redo                          0xff66  /* Redo, again */\n#define XK_Menu                          0xff67\n#define XK_Find                          0xff68  /* Find, search */\n#define XK_Cancel                        0xff69  /* Cancel, stop, abort, exit */\n#define XK_Help                          0xff6a  /* Help */\n#define XK_Break                         0xff6b\n#define XK_Mode_switch                   0xff7e  /* Character set switch */\n#define XK_script_switch                 0xff7e  /* Alias for mode_switch */\n#define XK_Num_Lock                      0xff7f\n\n/* Keypad functions, keypad numbers cleverly chosen to map to ASCII */\n\n#define XK_KP_Space                      0xff80  /* Space */\n#define XK_KP_Tab                        0xff89\n#define XK_KP_Enter                      0xff8d  /* Enter */\n#define XK_KP_F1                         0xff91  /* PF1, KP_A, ... */\n#define XK_KP_F2                         0xff92\n#define XK_KP_F3                         0xff93\n#define XK_KP_F4                         0xff94\n#define XK_KP_Home                       0xff95\n#define XK_KP_Left                       0xff96\n#define XK_KP_Up                         0xff97\n#define XK_KP_Right                      0xff98\n#define XK_KP_Down                       0xff99\n#define XK_KP_Prior                      0xff9a\n#define XK_KP_Page_Up                    0xff9a\n#define XK_KP_Next                       0xff9b\n#define XK_KP_Page_Down                  0xff9b\n#define XK_KP_End                        0xff9c\n#define XK_KP_Begin                      0xff9d\n#define XK_KP_Insert                     0xff9e\n#define XK_KP_Delete                     0xff9f\n#define XK_KP_Equal                      0xffbd  /* Equals */\n#define XK_KP_Multiply                   0xffaa\n#define XK_KP_Add                        0xffab\n#define XK_KP_Separator                  0xffac  /* Separator, often comma */\n#define XK_KP_Subtract                   0xffad\n#define XK_KP_Decimal                    0xffae\n#define XK_KP_Divide                     0xffaf\n\n#define XK_KP_0                          0xffb0\n#define XK_KP_1                          0xffb1\n#define XK_KP_2                          0xffb2\n#define XK_KP_3                          0xffb3\n#define XK_KP_4                          0xffb4\n#define XK_KP_5                          0xffb5\n#define XK_KP_6                          0xffb6\n#define XK_KP_7                          0xffb7\n#define XK_KP_8                          0xffb8\n#define XK_KP_9                          0xffb9\n\n\n\n/*\n * Auxiliary functions; note the duplicate definitions for left and right\n * function keys;  Sun keyboards and a few other manufacturers have such\n * function key groups on the left and/or right sides of the keyboard.\n * We've not found a keyboard with more than 35 function keys total.\n */\n\n#define XK_F1                            0xffbe\n#define XK_F2                            0xffbf\n#define XK_F3                            0xffc0\n#define XK_F4                            0xffc1\n#define XK_F5                            0xffc2\n#define XK_F6                            0xffc3\n#define XK_F7                            0xffc4\n#define XK_F8                            0xffc5\n#define XK_F9                            0xffc6\n#define XK_F10                           0xffc7\n#define XK_F11                           0xffc8\n#define XK_L1                            0xffc8\n#define XK_F12                           0xffc9\n#define XK_L2                            0xffc9\n#define XK_F13                           0xffca\n#define XK_L3                            0xffca\n#define XK_F14                           0xffcb\n#define XK_L4                            0xffcb\n#define XK_F15                           0xffcc\n#define XK_L5                            0xffcc\n#define XK_F16                           0xffcd\n#define XK_L6                            0xffcd\n#define XK_F17                           0xffce\n#define XK_L7                            0xffce\n#define XK_F18                           0xffcf\n#define XK_L8                            0xffcf\n#define XK_F19                           0xffd0\n#define XK_L9                            0xffd0\n#define XK_F20                           0xffd1\n#define XK_L10                           0xffd1\n#define XK_F21                           0xffd2\n#define XK_R1                            0xffd2\n#define XK_F22                           0xffd3\n#define XK_R2                            0xffd3\n#define XK_F23                           0xffd4\n#define XK_R3                            0xffd4\n#define XK_F24                           0xffd5\n#define XK_R4                            0xffd5\n#define XK_F25                           0xffd6\n#define XK_R5                            0xffd6\n#define XK_F26                           0xffd7\n#define XK_R6                            0xffd7\n#define XK_F27                           0xffd8\n#define XK_R7                            0xffd8\n#define XK_F28                           0xffd9\n#define XK_R8                            0xffd9\n#define XK_F29                           0xffda\n#define XK_R9                            0xffda\n#define XK_F30                           0xffdb\n#define XK_R10                           0xffdb\n#define XK_F31                           0xffdc\n#define XK_R11                           0xffdc\n#define XK_F32                           0xffdd\n#define XK_R12                           0xffdd\n#define XK_F33                           0xffde\n#define XK_R13                           0xffde\n#define XK_F34                           0xffdf\n#define XK_R14                           0xffdf\n#define XK_F35                           0xffe0\n#define XK_R15                           0xffe0\n\n/* Modifiers */\n\n#define XK_Shift_L                       0xffe1  /* Left shift */\n#define XK_Shift_R                       0xffe2  /* Right shift */\n#define XK_Control_L                     0xffe3  /* Left control */\n#define XK_Control_R                     0xffe4  /* Right control */\n#define XK_Caps_Lock                     0xffe5  /* Caps lock */\n#define XK_Shift_Lock                    0xffe6  /* Shift lock */\n\n#define XK_Meta_L                        0xffe7  /* Left meta */\n#define XK_Meta_R                        0xffe8  /* Right meta */\n#define XK_Alt_L                         0xffe9  /* Left alt */\n#define XK_Alt_R                         0xffea  /* Right alt */\n#define XK_Super_L                       0xffeb  /* Left super */\n#define XK_Super_R                       0xffec  /* Right super */\n#define XK_Hyper_L                       0xffed  /* Left hyper */\n#define XK_Hyper_R                       0xffee  /* Right hyper */\n#endif /* XK_MISCELLANY */\n\n/*\n * Keyboard (XKB) Extension function and modifier keys\n * (from Appendix C of \"The X Keyboard Extension: Protocol Specification\")\n * Byte 3 = 0xfe\n */\n\n#ifdef XK_XKB_KEYS\n#define XK_ISO_Lock                      0xfe01\n#define XK_ISO_Level2_Latch              0xfe02\n#define XK_ISO_Level3_Shift              0xfe03\n#define XK_ISO_Level3_Latch              0xfe04\n#define XK_ISO_Level3_Lock               0xfe05\n#define XK_ISO_Level5_Shift              0xfe11\n#define XK_ISO_Level5_Latch              0xfe12\n#define XK_ISO_Level5_Lock               0xfe13\n#define XK_ISO_Group_Shift               0xff7e  /* Alias for mode_switch */\n#define XK_ISO_Group_Latch               0xfe06\n#define XK_ISO_Group_Lock                0xfe07\n#define XK_ISO_Next_Group                0xfe08\n#define XK_ISO_Next_Group_Lock           0xfe09\n#define XK_ISO_Prev_Group                0xfe0a\n#define XK_ISO_Prev_Group_Lock           0xfe0b\n#define XK_ISO_First_Group               0xfe0c\n#define XK_ISO_First_Group_Lock          0xfe0d\n#define XK_ISO_Last_Group                0xfe0e\n#define XK_ISO_Last_Group_Lock           0xfe0f\n\n#define XK_ISO_Left_Tab                  0xfe20\n#define XK_ISO_Move_Line_Up              0xfe21\n#define XK_ISO_Move_Line_Down            0xfe22\n#define XK_ISO_Partial_Line_Up           0xfe23\n#define XK_ISO_Partial_Line_Down         0xfe24\n#define XK_ISO_Partial_Space_Left        0xfe25\n#define XK_ISO_Partial_Space_Right       0xfe26\n#define XK_ISO_Set_Margin_Left           0xfe27\n#define XK_ISO_Set_Margin_Right          0xfe28\n#define XK_ISO_Release_Margin_Left       0xfe29\n#define XK_ISO_Release_Margin_Right      0xfe2a\n#define XK_ISO_Release_Both_Margins      0xfe2b\n#define XK_ISO_Fast_Cursor_Left          0xfe2c\n#define XK_ISO_Fast_Cursor_Right         0xfe2d\n#define XK_ISO_Fast_Cursor_Up            0xfe2e\n#define XK_ISO_Fast_Cursor_Down          0xfe2f\n#define XK_ISO_Continuous_Underline      0xfe30\n#define XK_ISO_Discontinuous_Underline   0xfe31\n#define XK_ISO_Emphasize                 0xfe32\n#define XK_ISO_Center_Object             0xfe33\n#define XK_ISO_Enter                     0xfe34\n\n#define XK_dead_grave                    0xfe50\n#define XK_dead_acute                    0xfe51\n#define XK_dead_circumflex               0xfe52\n#define XK_dead_tilde                    0xfe53\n#define XK_dead_perispomeni              0xfe53  /* alias for dead_tilde */\n#define XK_dead_macron                   0xfe54\n#define XK_dead_breve                    0xfe55\n#define XK_dead_abovedot                 0xfe56\n#define XK_dead_diaeresis                0xfe57\n#define XK_dead_abovering                0xfe58\n#define XK_dead_doubleacute              0xfe59\n#define XK_dead_caron                    0xfe5a\n#define XK_dead_cedilla                  0xfe5b\n#define XK_dead_ogonek                   0xfe5c\n#define XK_dead_iota                     0xfe5d\n#define XK_dead_voiced_sound             0xfe5e\n#define XK_dead_semivoiced_sound         0xfe5f\n#define XK_dead_belowdot                 0xfe60\n#define XK_dead_hook                     0xfe61\n#define XK_dead_horn                     0xfe62\n#define XK_dead_stroke                   0xfe63\n#define XK_dead_abovecomma               0xfe64\n#define XK_dead_psili                    0xfe64  /* alias for dead_abovecomma */\n#define XK_dead_abovereversedcomma       0xfe65\n#define XK_dead_dasia                    0xfe65  /* alias for dead_abovereversedcomma */\n#define XK_dead_doublegrave              0xfe66\n#define XK_dead_belowring                0xfe67\n#define XK_dead_belowmacron              0xfe68\n#define XK_dead_belowcircumflex          0xfe69\n#define XK_dead_belowtilde               0xfe6a\n#define XK_dead_belowbreve               0xfe6b\n#define XK_dead_belowdiaeresis           0xfe6c\n#define XK_dead_invertedbreve            0xfe6d\n#define XK_dead_belowcomma               0xfe6e\n#define XK_dead_currency                 0xfe6f\n\n/* extra dead elements for German T3 layout */\n#define XK_dead_lowline                  0xfe90\n#define XK_dead_aboveverticalline        0xfe91\n#define XK_dead_belowverticalline        0xfe92\n#define XK_dead_longsolidusoverlay       0xfe93\n\n/* dead vowels for universal syllable entry */\n#define XK_dead_a                        0xfe80\n#define XK_dead_A                        0xfe81\n#define XK_dead_e                        0xfe82\n#define XK_dead_E                        0xfe83\n#define XK_dead_i                        0xfe84\n#define XK_dead_I                        0xfe85\n#define XK_dead_o                        0xfe86\n#define XK_dead_O                        0xfe87\n#define XK_dead_u                        0xfe88\n#define XK_dead_U                        0xfe89\n#define XK_dead_small_schwa              0xfe8a\n#define XK_dead_capital_schwa            0xfe8b\n\n#define XK_dead_greek                    0xfe8c\n\n#define XK_First_Virtual_Screen          0xfed0\n#define XK_Prev_Virtual_Screen           0xfed1\n#define XK_Next_Virtual_Screen           0xfed2\n#define XK_Last_Virtual_Screen           0xfed4\n#define XK_Terminate_Server              0xfed5\n\n#define XK_AccessX_Enable                0xfe70\n#define XK_AccessX_Feedback_Enable       0xfe71\n#define XK_RepeatKeys_Enable             0xfe72\n#define XK_SlowKeys_Enable               0xfe73\n#define XK_BounceKeys_Enable             0xfe74\n#define XK_StickyKeys_Enable             0xfe75\n#define XK_MouseKeys_Enable              0xfe76\n#define XK_MouseKeys_Accel_Enable        0xfe77\n#define XK_Overlay1_Enable               0xfe78\n#define XK_Overlay2_Enable               0xfe79\n#define XK_AudibleBell_Enable            0xfe7a\n\n#define XK_Pointer_Left                  0xfee0\n#define XK_Pointer_Right                 0xfee1\n#define XK_Pointer_Up                    0xfee2\n#define XK_Pointer_Down                  0xfee3\n#define XK_Pointer_UpLeft                0xfee4\n#define XK_Pointer_UpRight               0xfee5\n#define XK_Pointer_DownLeft              0xfee6\n#define XK_Pointer_DownRight             0xfee7\n#define XK_Pointer_Button_Dflt           0xfee8\n#define XK_Pointer_Button1               0xfee9\n#define XK_Pointer_Button2               0xfeea\n#define XK_Pointer_Button3               0xfeeb\n#define XK_Pointer_Button4               0xfeec\n#define XK_Pointer_Button5               0xfeed\n#define XK_Pointer_DblClick_Dflt         0xfeee\n#define XK_Pointer_DblClick1             0xfeef\n#define XK_Pointer_DblClick2             0xfef0\n#define XK_Pointer_DblClick3             0xfef1\n#define XK_Pointer_DblClick4             0xfef2\n#define XK_Pointer_DblClick5             0xfef3\n#define XK_Pointer_Drag_Dflt             0xfef4\n#define XK_Pointer_Drag1                 0xfef5\n#define XK_Pointer_Drag2                 0xfef6\n#define XK_Pointer_Drag3                 0xfef7\n#define XK_Pointer_Drag4                 0xfef8\n#define XK_Pointer_Drag5                 0xfefd\n\n#define XK_Pointer_EnableKeys            0xfef9\n#define XK_Pointer_Accelerate            0xfefa\n#define XK_Pointer_DfltBtnNext           0xfefb\n#define XK_Pointer_DfltBtnPrev           0xfefc\n\n/* Single-Stroke Multiple-Character N-Graph Keysyms For The X Input Method */\n\n#define XK_ch                            0xfea0\n#define XK_Ch                            0xfea1\n#define XK_CH                            0xfea2\n#define XK_c_h                           0xfea3\n#define XK_C_h                           0xfea4\n#define XK_C_H                           0xfea5\n\n#endif /* XK_XKB_KEYS */\n\n/*\n * 3270 Terminal Keys\n * Byte 3 = 0xfd\n */\n\n#ifdef XK_3270\n#define XK_3270_Duplicate                0xfd01\n#define XK_3270_FieldMark                0xfd02\n#define XK_3270_Right2                   0xfd03\n#define XK_3270_Left2                    0xfd04\n#define XK_3270_BackTab                  0xfd05\n#define XK_3270_EraseEOF                 0xfd06\n#define XK_3270_EraseInput               0xfd07\n#define XK_3270_Reset                    0xfd08\n#define XK_3270_Quit                     0xfd09\n#define XK_3270_PA1                      0xfd0a\n#define XK_3270_PA2                      0xfd0b\n#define XK_3270_PA3                      0xfd0c\n#define XK_3270_Test                     0xfd0d\n#define XK_3270_Attn                     0xfd0e\n#define XK_3270_CursorBlink              0xfd0f\n#define XK_3270_AltCursor                0xfd10\n#define XK_3270_KeyClick                 0xfd11\n#define XK_3270_Jump                     0xfd12\n#define XK_3270_Ident                    0xfd13\n#define XK_3270_Rule                     0xfd14\n#define XK_3270_Copy                     0xfd15\n#define XK_3270_Play                     0xfd16\n#define XK_3270_Setup                    0xfd17\n#define XK_3270_Record                   0xfd18\n#define XK_3270_ChangeScreen             0xfd19\n#define XK_3270_DeleteWord               0xfd1a\n#define XK_3270_ExSelect                 0xfd1b\n#define XK_3270_CursorSelect             0xfd1c\n#define XK_3270_PrintScreen              0xfd1d\n#define XK_3270_Enter                    0xfd1e\n#endif /* XK_3270 */\n\n/*\n * Latin 1\n * (ISO/IEC 8859-1 = Unicode U+0020..U+00FF)\n * Byte 3 = 0\n */\n#ifdef XK_LATIN1\n#define XK_space                         0x0020  /* U+0020 SPACE */\n#define XK_exclam                        0x0021  /* U+0021 EXCLAMATION MARK */\n#define XK_quotedbl                      0x0022  /* U+0022 QUOTATION MARK */\n#define XK_numbersign                    0x0023  /* U+0023 NUMBER SIGN */\n#define XK_dollar                        0x0024  /* U+0024 DOLLAR SIGN */\n#define XK_percent                       0x0025  /* U+0025 PERCENT SIGN */\n#define XK_ampersand                     0x0026  /* U+0026 AMPERSAND */\n#define XK_apostrophe                    0x0027  /* U+0027 APOSTROPHE */\n#define XK_quoteright                    0x0027  /* deprecated */\n#define XK_parenleft                     0x0028  /* U+0028 LEFT PARENTHESIS */\n#define XK_parenright                    0x0029  /* U+0029 RIGHT PARENTHESIS */\n#define XK_asterisk                      0x002a  /* U+002A ASTERISK */\n#define XK_plus                          0x002b  /* U+002B PLUS SIGN */\n#define XK_comma                         0x002c  /* U+002C COMMA */\n#define XK_minus                         0x002d  /* U+002D HYPHEN-MINUS */\n#define XK_period                        0x002e  /* U+002E FULL STOP */\n#define XK_slash                         0x002f  /* U+002F SOLIDUS */\n#define XK_0                             0x0030  /* U+0030 DIGIT ZERO */\n#define XK_1                             0x0031  /* U+0031 DIGIT ONE */\n#define XK_2                             0x0032  /* U+0032 DIGIT TWO */\n#define XK_3                             0x0033  /* U+0033 DIGIT THREE */\n#define XK_4                             0x0034  /* U+0034 DIGIT FOUR */\n#define XK_5                             0x0035  /* U+0035 DIGIT FIVE */\n#define XK_6                             0x0036  /* U+0036 DIGIT SIX */\n#define XK_7                             0x0037  /* U+0037 DIGIT SEVEN */\n#define XK_8                             0x0038  /* U+0038 DIGIT EIGHT */\n#define XK_9                             0x0039  /* U+0039 DIGIT NINE */\n#define XK_colon                         0x003a  /* U+003A COLON */\n#define XK_semicolon                     0x003b  /* U+003B SEMICOLON */\n#define XK_less                          0x003c  /* U+003C LESS-THAN SIGN */\n#define XK_equal                         0x003d  /* U+003D EQUALS SIGN */\n#define XK_greater                       0x003e  /* U+003E GREATER-THAN SIGN */\n#define XK_question                      0x003f  /* U+003F QUESTION MARK */\n#define XK_at                            0x0040  /* U+0040 COMMERCIAL AT */\n#define XK_A                             0x0041  /* U+0041 LATIN CAPITAL LETTER A */\n#define XK_B                             0x0042  /* U+0042 LATIN CAPITAL LETTER B */\n#define XK_C                             0x0043  /* U+0043 LATIN CAPITAL LETTER C */\n#define XK_D                             0x0044  /* U+0044 LATIN CAPITAL LETTER D */\n#define XK_E                             0x0045  /* U+0045 LATIN CAPITAL LETTER E */\n#define XK_F                             0x0046  /* U+0046 LATIN CAPITAL LETTER F */\n#define XK_G                             0x0047  /* U+0047 LATIN CAPITAL LETTER G */\n#define XK_H                             0x0048  /* U+0048 LATIN CAPITAL LETTER H */\n#define XK_I                             0x0049  /* U+0049 LATIN CAPITAL LETTER I */\n#define XK_J                             0x004a  /* U+004A LATIN CAPITAL LETTER J */\n#define XK_K                             0x004b  /* U+004B LATIN CAPITAL LETTER K */\n#define XK_L                             0x004c  /* U+004C LATIN CAPITAL LETTER L */\n#define XK_M                             0x004d  /* U+004D LATIN CAPITAL LETTER M */\n#define XK_N                             0x004e  /* U+004E LATIN CAPITAL LETTER N */\n#define XK_O                             0x004f  /* U+004F LATIN CAPITAL LETTER O */\n#define XK_P                             0x0050  /* U+0050 LATIN CAPITAL LETTER P */\n#define XK_Q                             0x0051  /* U+0051 LATIN CAPITAL LETTER Q */\n#define XK_R                             0x0052  /* U+0052 LATIN CAPITAL LETTER R */\n#define XK_S                             0x0053  /* U+0053 LATIN CAPITAL LETTER S */\n#define XK_T                             0x0054  /* U+0054 LATIN CAPITAL LETTER T */\n#define XK_U                             0x0055  /* U+0055 LATIN CAPITAL LETTER U */\n#define XK_V                             0x0056  /* U+0056 LATIN CAPITAL LETTER V */\n#define XK_W                             0x0057  /* U+0057 LATIN CAPITAL LETTER W */\n#define XK_X                             0x0058  /* U+0058 LATIN CAPITAL LETTER X */\n#define XK_Y                             0x0059  /* U+0059 LATIN CAPITAL LETTER Y */\n#define XK_Z                             0x005a  /* U+005A LATIN CAPITAL LETTER Z */\n#define XK_bracketleft                   0x005b  /* U+005B LEFT SQUARE BRACKET */\n#define XK_backslash                     0x005c  /* U+005C REVERSE SOLIDUS */\n#define XK_bracketright                  0x005d  /* U+005D RIGHT SQUARE BRACKET */\n#define XK_asciicircum                   0x005e  /* U+005E CIRCUMFLEX ACCENT */\n#define XK_underscore                    0x005f  /* U+005F LOW LINE */\n#define XK_grave                         0x0060  /* U+0060 GRAVE ACCENT */\n#define XK_quoteleft                     0x0060  /* deprecated */\n#define XK_a                             0x0061  /* U+0061 LATIN SMALL LETTER A */\n#define XK_b                             0x0062  /* U+0062 LATIN SMALL LETTER B */\n#define XK_c                             0x0063  /* U+0063 LATIN SMALL LETTER C */\n#define XK_d                             0x0064  /* U+0064 LATIN SMALL LETTER D */\n#define XK_e                             0x0065  /* U+0065 LATIN SMALL LETTER E */\n#define XK_f                             0x0066  /* U+0066 LATIN SMALL LETTER F */\n#define XK_g                             0x0067  /* U+0067 LATIN SMALL LETTER G */\n#define XK_h                             0x0068  /* U+0068 LATIN SMALL LETTER H */\n#define XK_i                             0x0069  /* U+0069 LATIN SMALL LETTER I */\n#define XK_j                             0x006a  /* U+006A LATIN SMALL LETTER J */\n#define XK_k                             0x006b  /* U+006B LATIN SMALL LETTER K */\n#define XK_l                             0x006c  /* U+006C LATIN SMALL LETTER L */\n#define XK_m                             0x006d  /* U+006D LATIN SMALL LETTER M */\n#define XK_n                             0x006e  /* U+006E LATIN SMALL LETTER N */\n#define XK_o                             0x006f  /* U+006F LATIN SMALL LETTER O */\n#define XK_p                             0x0070  /* U+0070 LATIN SMALL LETTER P */\n#define XK_q                             0x0071  /* U+0071 LATIN SMALL LETTER Q */\n#define XK_r                             0x0072  /* U+0072 LATIN SMALL LETTER R */\n#define XK_s                             0x0073  /* U+0073 LATIN SMALL LETTER S */\n#define XK_t                             0x0074  /* U+0074 LATIN SMALL LETTER T */\n#define XK_u                             0x0075  /* U+0075 LATIN SMALL LETTER U */\n#define XK_v                             0x0076  /* U+0076 LATIN SMALL LETTER V */\n#define XK_w                             0x0077  /* U+0077 LATIN SMALL LETTER W */\n#define XK_x                             0x0078  /* U+0078 LATIN SMALL LETTER X */\n#define XK_y                             0x0079  /* U+0079 LATIN SMALL LETTER Y */\n#define XK_z                             0x007a  /* U+007A LATIN SMALL LETTER Z */\n#define XK_braceleft                     0x007b  /* U+007B LEFT CURLY BRACKET */\n#define XK_bar                           0x007c  /* U+007C VERTICAL LINE */\n#define XK_braceright                    0x007d  /* U+007D RIGHT CURLY BRACKET */\n#define XK_asciitilde                    0x007e  /* U+007E TILDE */\n\n#define XK_nobreakspace                  0x00a0  /* U+00A0 NO-BREAK SPACE */\n#define XK_exclamdown                    0x00a1  /* U+00A1 INVERTED EXCLAMATION MARK */\n#define XK_cent                          0x00a2  /* U+00A2 CENT SIGN */\n#define XK_sterling                      0x00a3  /* U+00A3 POUND SIGN */\n#define XK_currency                      0x00a4  /* U+00A4 CURRENCY SIGN */\n#define XK_yen                           0x00a5  /* U+00A5 YEN SIGN */\n#define XK_brokenbar                     0x00a6  /* U+00A6 BROKEN BAR */\n#define XK_section                       0x00a7  /* U+00A7 SECTION SIGN */\n#define XK_diaeresis                     0x00a8  /* U+00A8 DIAERESIS */\n#define XK_copyright                     0x00a9  /* U+00A9 COPYRIGHT SIGN */\n#define XK_ordfeminine                   0x00aa  /* U+00AA FEMININE ORDINAL INDICATOR */\n#define XK_guillemotleft                 0x00ab  /* U+00AB LEFT-POINTING DOUBLE ANGLE QUOTATION MARK */\n#define XK_notsign                       0x00ac  /* U+00AC NOT SIGN */\n#define XK_hyphen                        0x00ad  /* U+00AD SOFT HYPHEN */\n#define XK_registered                    0x00ae  /* U+00AE REGISTERED SIGN */\n#define XK_macron                        0x00af  /* U+00AF MACRON */\n#define XK_degree                        0x00b0  /* U+00B0 DEGREE SIGN */\n#define XK_plusminus                     0x00b1  /* U+00B1 PLUS-MINUS SIGN */\n#define XK_twosuperior                   0x00b2  /* U+00B2 SUPERSCRIPT TWO */\n#define XK_threesuperior                 0x00b3  /* U+00B3 SUPERSCRIPT THREE */\n#define XK_acute                         0x00b4  /* U+00B4 ACUTE ACCENT */\n#define XK_mu                            0x00b5  /* U+00B5 MICRO SIGN */\n#define XK_paragraph                     0x00b6  /* U+00B6 PILCROW SIGN */\n#define XK_periodcentered                0x00b7  /* U+00B7 MIDDLE DOT */\n#define XK_cedilla                       0x00b8  /* U+00B8 CEDILLA */\n#define XK_onesuperior                   0x00b9  /* U+00B9 SUPERSCRIPT ONE */\n#define XK_masculine                     0x00ba  /* U+00BA MASCULINE ORDINAL INDICATOR */\n#define XK_guillemotright                0x00bb  /* U+00BB RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK */\n#define XK_onequarter                    0x00bc  /* U+00BC VULGAR FRACTION ONE QUARTER */\n#define XK_onehalf                       0x00bd  /* U+00BD VULGAR FRACTION ONE HALF */\n#define XK_threequarters                 0x00be  /* U+00BE VULGAR FRACTION THREE QUARTERS */\n#define XK_questiondown                  0x00bf  /* U+00BF INVERTED QUESTION MARK */\n#define XK_Agrave                        0x00c0  /* U+00C0 LATIN CAPITAL LETTER A WITH GRAVE */\n#define XK_Aacute                        0x00c1  /* U+00C1 LATIN CAPITAL LETTER A WITH ACUTE */\n#define XK_Acircumflex                   0x00c2  /* U+00C2 LATIN CAPITAL LETTER A WITH CIRCUMFLEX */\n#define XK_Atilde                        0x00c3  /* U+00C3 LATIN CAPITAL LETTER A WITH TILDE */\n#define XK_Adiaeresis                    0x00c4  /* U+00C4 LATIN CAPITAL LETTER A WITH DIAERESIS */\n#define XK_Aring                         0x00c5  /* U+00C5 LATIN CAPITAL LETTER A WITH RING ABOVE */\n#define XK_AE                            0x00c6  /* U+00C6 LATIN CAPITAL LETTER AE */\n#define XK_Ccedilla                      0x00c7  /* U+00C7 LATIN CAPITAL LETTER C WITH CEDILLA */\n#define XK_Egrave                        0x00c8  /* U+00C8 LATIN CAPITAL LETTER E WITH GRAVE */\n#define XK_Eacute                        0x00c9  /* U+00C9 LATIN CAPITAL LETTER E WITH ACUTE */\n#define XK_Ecircumflex                   0x00ca  /* U+00CA LATIN CAPITAL LETTER E WITH CIRCUMFLEX */\n#define XK_Ediaeresis                    0x00cb  /* U+00CB LATIN CAPITAL LETTER E WITH DIAERESIS */\n#define XK_Igrave                        0x00cc  /* U+00CC LATIN CAPITAL LETTER I WITH GRAVE */\n#define XK_Iacute                        0x00cd  /* U+00CD LATIN CAPITAL LETTER I WITH ACUTE */\n#define XK_Icircumflex                   0x00ce  /* U+00CE LATIN CAPITAL LETTER I WITH CIRCUMFLEX */\n#define XK_Idiaeresis                    0x00cf  /* U+00CF LATIN CAPITAL LETTER I WITH DIAERESIS */\n#define XK_ETH                           0x00d0  /* U+00D0 LATIN CAPITAL LETTER ETH */\n#define XK_Eth                           0x00d0  /* deprecated */\n#define XK_Ntilde                        0x00d1  /* U+00D1 LATIN CAPITAL LETTER N WITH TILDE */\n#define XK_Ograve                        0x00d2  /* U+00D2 LATIN CAPITAL LETTER O WITH GRAVE */\n#define XK_Oacute                        0x00d3  /* U+00D3 LATIN CAPITAL LETTER O WITH ACUTE */\n#define XK_Ocircumflex                   0x00d4  /* U+00D4 LATIN CAPITAL LETTER O WITH CIRCUMFLEX */\n#define XK_Otilde                        0x00d5  /* U+00D5 LATIN CAPITAL LETTER O WITH TILDE */\n#define XK_Odiaeresis                    0x00d6  /* U+00D6 LATIN CAPITAL LETTER O WITH DIAERESIS */\n#define XK_multiply                      0x00d7  /* U+00D7 MULTIPLICATION SIGN */\n#define XK_Oslash                        0x00d8  /* U+00D8 LATIN CAPITAL LETTER O WITH STROKE */\n#define XK_Ooblique                      0x00d8  /* U+00D8 LATIN CAPITAL LETTER O WITH STROKE */\n#define XK_Ugrave                        0x00d9  /* U+00D9 LATIN CAPITAL LETTER U WITH GRAVE */\n#define XK_Uacute                        0x00da  /* U+00DA LATIN CAPITAL LETTER U WITH ACUTE */\n#define XK_Ucircumflex                   0x00db  /* U+00DB LATIN CAPITAL LETTER U WITH CIRCUMFLEX */\n#define XK_Udiaeresis                    0x00dc  /* U+00DC LATIN CAPITAL LETTER U WITH DIAERESIS */\n#define XK_Yacute                        0x00dd  /* U+00DD LATIN CAPITAL LETTER Y WITH ACUTE */\n#define XK_THORN                         0x00de  /* U+00DE LATIN CAPITAL LETTER THORN */\n#define XK_Thorn                         0x00de  /* deprecated */\n#define XK_ssharp                        0x00df  /* U+00DF LATIN SMALL LETTER SHARP S */\n#define XK_agrave                        0x00e0  /* U+00E0 LATIN SMALL LETTER A WITH GRAVE */\n#define XK_aacute                        0x00e1  /* U+00E1 LATIN SMALL LETTER A WITH ACUTE */\n#define XK_acircumflex                   0x00e2  /* U+00E2 LATIN SMALL LETTER A WITH CIRCUMFLEX */\n#define XK_atilde                        0x00e3  /* U+00E3 LATIN SMALL LETTER A WITH TILDE */\n#define XK_adiaeresis                    0x00e4  /* U+00E4 LATIN SMALL LETTER A WITH DIAERESIS */\n#define XK_aring                         0x00e5  /* U+00E5 LATIN SMALL LETTER A WITH RING ABOVE */\n#define XK_ae                            0x00e6  /* U+00E6 LATIN SMALL LETTER AE */\n#define XK_ccedilla                      0x00e7  /* U+00E7 LATIN SMALL LETTER C WITH CEDILLA */\n#define XK_egrave                        0x00e8  /* U+00E8 LATIN SMALL LETTER E WITH GRAVE */\n#define XK_eacute                        0x00e9  /* U+00E9 LATIN SMALL LETTER E WITH ACUTE */\n#define XK_ecircumflex                   0x00ea  /* U+00EA LATIN SMALL LETTER E WITH CIRCUMFLEX */\n#define XK_ediaeresis                    0x00eb  /* U+00EB LATIN SMALL LETTER E WITH DIAERESIS */\n#define XK_igrave                        0x00ec  /* U+00EC LATIN SMALL LETTER I WITH GRAVE */\n#define XK_iacute                        0x00ed  /* U+00ED LATIN SMALL LETTER I WITH ACUTE */\n#define XK_icircumflex                   0x00ee  /* U+00EE LATIN SMALL LETTER I WITH CIRCUMFLEX */\n#define XK_idiaeresis                    0x00ef  /* U+00EF LATIN SMALL LETTER I WITH DIAERESIS */\n#define XK_eth                           0x00f0  /* U+00F0 LATIN SMALL LETTER ETH */\n#define XK_ntilde                        0x00f1  /* U+00F1 LATIN SMALL LETTER N WITH TILDE */\n#define XK_ograve                        0x00f2  /* U+00F2 LATIN SMALL LETTER O WITH GRAVE */\n#define XK_oacute                        0x00f3  /* U+00F3 LATIN SMALL LETTER O WITH ACUTE */\n#define XK_ocircumflex                   0x00f4  /* U+00F4 LATIN SMALL LETTER O WITH CIRCUMFLEX */\n#define XK_otilde                        0x00f5  /* U+00F5 LATIN SMALL LETTER O WITH TILDE */\n#define XK_odiaeresis                    0x00f6  /* U+00F6 LATIN SMALL LETTER O WITH DIAERESIS */\n#define XK_division                      0x00f7  /* U+00F7 DIVISION SIGN */\n#define XK_oslash                        0x00f8  /* U+00F8 LATIN SMALL LETTER O WITH STROKE */\n#define XK_ooblique                      0x00f8  /* U+00F8 LATIN SMALL LETTER O WITH STROKE */\n#define XK_ugrave                        0x00f9  /* U+00F9 LATIN SMALL LETTER U WITH GRAVE */\n#define XK_uacute                        0x00fa  /* U+00FA LATIN SMALL LETTER U WITH ACUTE */\n#define XK_ucircumflex                   0x00fb  /* U+00FB LATIN SMALL LETTER U WITH CIRCUMFLEX */\n#define XK_udiaeresis                    0x00fc  /* U+00FC LATIN SMALL LETTER U WITH DIAERESIS */\n#define XK_yacute                        0x00fd  /* U+00FD LATIN SMALL LETTER Y WITH ACUTE */\n#define XK_thorn                         0x00fe  /* U+00FE LATIN SMALL LETTER THORN */\n#define XK_ydiaeresis                    0x00ff  /* U+00FF LATIN SMALL LETTER Y WITH DIAERESIS */\n#endif /* XK_LATIN1 */\n\n/*\n * Latin 2\n * Byte 3 = 1\n */\n\n#ifdef XK_LATIN2\n#define XK_Aogonek                       0x01a1  /* U+0104 LATIN CAPITAL LETTER A WITH OGONEK */\n#define XK_breve                         0x01a2  /* U+02D8 BREVE */\n#define XK_Lstroke                       0x01a3  /* U+0141 LATIN CAPITAL LETTER L WITH STROKE */\n#define XK_Lcaron                        0x01a5  /* U+013D LATIN CAPITAL LETTER L WITH CARON */\n#define XK_Sacute                        0x01a6  /* U+015A LATIN CAPITAL LETTER S WITH ACUTE */\n#define XK_Scaron                        0x01a9  /* U+0160 LATIN CAPITAL LETTER S WITH CARON */\n#define XK_Scedilla                      0x01aa  /* U+015E LATIN CAPITAL LETTER S WITH CEDILLA */\n#define XK_Tcaron                        0x01ab  /* U+0164 LATIN CAPITAL LETTER T WITH CARON */\n#define XK_Zacute                        0x01ac  /* U+0179 LATIN CAPITAL LETTER Z WITH ACUTE */\n#define XK_Zcaron                        0x01ae  /* U+017D LATIN CAPITAL LETTER Z WITH CARON */\n#define XK_Zabovedot                     0x01af  /* U+017B LATIN CAPITAL LETTER Z WITH DOT ABOVE */\n#define XK_aogonek                       0x01b1  /* U+0105 LATIN SMALL LETTER A WITH OGONEK */\n#define XK_ogonek                        0x01b2  /* U+02DB OGONEK */\n#define XK_lstroke                       0x01b3  /* U+0142 LATIN SMALL LETTER L WITH STROKE */\n#define XK_lcaron                        0x01b5  /* U+013E LATIN SMALL LETTER L WITH CARON */\n#define XK_sacute                        0x01b6  /* U+015B LATIN SMALL LETTER S WITH ACUTE */\n#define XK_caron                         0x01b7  /* U+02C7 CARON */\n#define XK_scaron                        0x01b9  /* U+0161 LATIN SMALL LETTER S WITH CARON */\n#define XK_scedilla                      0x01ba  /* U+015F LATIN SMALL LETTER S WITH CEDILLA */\n#define XK_tcaron                        0x01bb  /* U+0165 LATIN SMALL LETTER T WITH CARON */\n#define XK_zacute                        0x01bc  /* U+017A LATIN SMALL LETTER Z WITH ACUTE */\n#define XK_doubleacute                   0x01bd  /* U+02DD DOUBLE ACUTE ACCENT */\n#define XK_zcaron                        0x01be  /* U+017E LATIN SMALL LETTER Z WITH CARON */\n#define XK_zabovedot                     0x01bf  /* U+017C LATIN SMALL LETTER Z WITH DOT ABOVE */\n#define XK_Racute                        0x01c0  /* U+0154 LATIN CAPITAL LETTER R WITH ACUTE */\n#define XK_Abreve                        0x01c3  /* U+0102 LATIN CAPITAL LETTER A WITH BREVE */\n#define XK_Lacute                        0x01c5  /* U+0139 LATIN CAPITAL LETTER L WITH ACUTE */\n#define XK_Cacute                        0x01c6  /* U+0106 LATIN CAPITAL LETTER C WITH ACUTE */\n#define XK_Ccaron                        0x01c8  /* U+010C LATIN CAPITAL LETTER C WITH CARON */\n#define XK_Eogonek                       0x01ca  /* U+0118 LATIN CAPITAL LETTER E WITH OGONEK */\n#define XK_Ecaron                        0x01cc  /* U+011A LATIN CAPITAL LETTER E WITH CARON */\n#define XK_Dcaron                        0x01cf  /* U+010E LATIN CAPITAL LETTER D WITH CARON */\n#define XK_Dstroke                       0x01d0  /* U+0110 LATIN CAPITAL LETTER D WITH STROKE */\n#define XK_Nacute                        0x01d1  /* U+0143 LATIN CAPITAL LETTER N WITH ACUTE */\n#define XK_Ncaron                        0x01d2  /* U+0147 LATIN CAPITAL LETTER N WITH CARON */\n#define XK_Odoubleacute                  0x01d5  /* U+0150 LATIN CAPITAL LETTER O WITH DOUBLE ACUTE */\n#define XK_Rcaron                        0x01d8  /* U+0158 LATIN CAPITAL LETTER R WITH CARON */\n#define XK_Uring                         0x01d9  /* U+016E LATIN CAPITAL LETTER U WITH RING ABOVE */\n#define XK_Udoubleacute                  0x01db  /* U+0170 LATIN CAPITAL LETTER U WITH DOUBLE ACUTE */\n#define XK_Tcedilla                      0x01de  /* U+0162 LATIN CAPITAL LETTER T WITH CEDILLA */\n#define XK_racute                        0x01e0  /* U+0155 LATIN SMALL LETTER R WITH ACUTE */\n#define XK_abreve                        0x01e3  /* U+0103 LATIN SMALL LETTER A WITH BREVE */\n#define XK_lacute                        0x01e5  /* U+013A LATIN SMALL LETTER L WITH ACUTE */\n#define XK_cacute                        0x01e6  /* U+0107 LATIN SMALL LETTER C WITH ACUTE */\n#define XK_ccaron                        0x01e8  /* U+010D LATIN SMALL LETTER C WITH CARON */\n#define XK_eogonek                       0x01ea  /* U+0119 LATIN SMALL LETTER E WITH OGONEK */\n#define XK_ecaron                        0x01ec  /* U+011B LATIN SMALL LETTER E WITH CARON */\n#define XK_dcaron                        0x01ef  /* U+010F LATIN SMALL LETTER D WITH CARON */\n#define XK_dstroke                       0x01f0  /* U+0111 LATIN SMALL LETTER D WITH STROKE */\n#define XK_nacute                        0x01f1  /* U+0144 LATIN SMALL LETTER N WITH ACUTE */\n#define XK_ncaron                        0x01f2  /* U+0148 LATIN SMALL LETTER N WITH CARON */\n#define XK_odoubleacute                  0x01f5  /* U+0151 LATIN SMALL LETTER O WITH DOUBLE ACUTE */\n#define XK_rcaron                        0x01f8  /* U+0159 LATIN SMALL LETTER R WITH CARON */\n#define XK_uring                         0x01f9  /* U+016F LATIN SMALL LETTER U WITH RING ABOVE */\n#define XK_udoubleacute                  0x01fb  /* U+0171 LATIN SMALL LETTER U WITH DOUBLE ACUTE */\n#define XK_tcedilla                      0x01fe  /* U+0163 LATIN SMALL LETTER T WITH CEDILLA */\n#define XK_abovedot                      0x01ff  /* U+02D9 DOT ABOVE */\n#endif /* XK_LATIN2 */\n\n/*\n * Latin 3\n * Byte 3 = 2\n */\n\n#ifdef XK_LATIN3\n#define XK_Hstroke                       0x02a1  /* U+0126 LATIN CAPITAL LETTER H WITH STROKE */\n#define XK_Hcircumflex                   0x02a6  /* U+0124 LATIN CAPITAL LETTER H WITH CIRCUMFLEX */\n#define XK_Iabovedot                     0x02a9  /* U+0130 LATIN CAPITAL LETTER I WITH DOT ABOVE */\n#define XK_Gbreve                        0x02ab  /* U+011E LATIN CAPITAL LETTER G WITH BREVE */\n#define XK_Jcircumflex                   0x02ac  /* U+0134 LATIN CAPITAL LETTER J WITH CIRCUMFLEX */\n#define XK_hstroke                       0x02b1  /* U+0127 LATIN SMALL LETTER H WITH STROKE */\n#define XK_hcircumflex                   0x02b6  /* U+0125 LATIN SMALL LETTER H WITH CIRCUMFLEX */\n#define XK_idotless                      0x02b9  /* U+0131 LATIN SMALL LETTER DOTLESS I */\n#define XK_gbreve                        0x02bb  /* U+011F LATIN SMALL LETTER G WITH BREVE */\n#define XK_jcircumflex                   0x02bc  /* U+0135 LATIN SMALL LETTER J WITH CIRCUMFLEX */\n#define XK_Cabovedot                     0x02c5  /* U+010A LATIN CAPITAL LETTER C WITH DOT ABOVE */\n#define XK_Ccircumflex                   0x02c6  /* U+0108 LATIN CAPITAL LETTER C WITH CIRCUMFLEX */\n#define XK_Gabovedot                     0x02d5  /* U+0120 LATIN CAPITAL LETTER G WITH DOT ABOVE */\n#define XK_Gcircumflex                   0x02d8  /* U+011C LATIN CAPITAL LETTER G WITH CIRCUMFLEX */\n#define XK_Ubreve                        0x02dd  /* U+016C LATIN CAPITAL LETTER U WITH BREVE */\n#define XK_Scircumflex                   0x02de  /* U+015C LATIN CAPITAL LETTER S WITH CIRCUMFLEX */\n#define XK_cabovedot                     0x02e5  /* U+010B LATIN SMALL LETTER C WITH DOT ABOVE */\n#define XK_ccircumflex                   0x02e6  /* U+0109 LATIN SMALL LETTER C WITH CIRCUMFLEX */\n#define XK_gabovedot                     0x02f5  /* U+0121 LATIN SMALL LETTER G WITH DOT ABOVE */\n#define XK_gcircumflex                   0x02f8  /* U+011D LATIN SMALL LETTER G WITH CIRCUMFLEX */\n#define XK_ubreve                        0x02fd  /* U+016D LATIN SMALL LETTER U WITH BREVE */\n#define XK_scircumflex                   0x02fe  /* U+015D LATIN SMALL LETTER S WITH CIRCUMFLEX */\n#endif /* XK_LATIN3 */\n\n\n/*\n * Latin 4\n * Byte 3 = 3\n */\n\n#ifdef XK_LATIN4\n#define XK_kra                           0x03a2  /* U+0138 LATIN SMALL LETTER KRA */\n#define XK_kappa                         0x03a2  /* deprecated */\n#define XK_Rcedilla                      0x03a3  /* U+0156 LATIN CAPITAL LETTER R WITH CEDILLA */\n#define XK_Itilde                        0x03a5  /* U+0128 LATIN CAPITAL LETTER I WITH TILDE */\n#define XK_Lcedilla                      0x03a6  /* U+013B LATIN CAPITAL LETTER L WITH CEDILLA */\n#define XK_Emacron                       0x03aa  /* U+0112 LATIN CAPITAL LETTER E WITH MACRON */\n#define XK_Gcedilla                      0x03ab  /* U+0122 LATIN CAPITAL LETTER G WITH CEDILLA */\n#define XK_Tslash                        0x03ac  /* U+0166 LATIN CAPITAL LETTER T WITH STROKE */\n#define XK_rcedilla                      0x03b3  /* U+0157 LATIN SMALL LETTER R WITH CEDILLA */\n#define XK_itilde                        0x03b5  /* U+0129 LATIN SMALL LETTER I WITH TILDE */\n#define XK_lcedilla                      0x03b6  /* U+013C LATIN SMALL LETTER L WITH CEDILLA */\n#define XK_emacron                       0x03ba  /* U+0113 LATIN SMALL LETTER E WITH MACRON */\n#define XK_gcedilla                      0x03bb  /* U+0123 LATIN SMALL LETTER G WITH CEDILLA */\n#define XK_tslash                        0x03bc  /* U+0167 LATIN SMALL LETTER T WITH STROKE */\n#define XK_ENG                           0x03bd  /* U+014A LATIN CAPITAL LETTER ENG */\n#define XK_eng                           0x03bf  /* U+014B LATIN SMALL LETTER ENG */\n#define XK_Amacron                       0x03c0  /* U+0100 LATIN CAPITAL LETTER A WITH MACRON */\n#define XK_Iogonek                       0x03c7  /* U+012E LATIN CAPITAL LETTER I WITH OGONEK */\n#define XK_Eabovedot                     0x03cc  /* U+0116 LATIN CAPITAL LETTER E WITH DOT ABOVE */\n#define XK_Imacron                       0x03cf  /* U+012A LATIN CAPITAL LETTER I WITH MACRON */\n#define XK_Ncedilla                      0x03d1  /* U+0145 LATIN CAPITAL LETTER N WITH CEDILLA */\n#define XK_Omacron                       0x03d2  /* U+014C LATIN CAPITAL LETTER O WITH MACRON */\n#define XK_Kcedilla                      0x03d3  /* U+0136 LATIN CAPITAL LETTER K WITH CEDILLA */\n#define XK_Uogonek                       0x03d9  /* U+0172 LATIN CAPITAL LETTER U WITH OGONEK */\n#define XK_Utilde                        0x03dd  /* U+0168 LATIN CAPITAL LETTER U WITH TILDE */\n#define XK_Umacron                       0x03de  /* U+016A LATIN CAPITAL LETTER U WITH MACRON */\n#define XK_amacron                       0x03e0  /* U+0101 LATIN SMALL LETTER A WITH MACRON */\n#define XK_iogonek                       0x03e7  /* U+012F LATIN SMALL LETTER I WITH OGONEK */\n#define XK_eabovedot                     0x03ec  /* U+0117 LATIN SMALL LETTER E WITH DOT ABOVE */\n#define XK_imacron                       0x03ef  /* U+012B LATIN SMALL LETTER I WITH MACRON */\n#define XK_ncedilla                      0x03f1  /* U+0146 LATIN SMALL LETTER N WITH CEDILLA */\n#define XK_omacron                       0x03f2  /* U+014D LATIN SMALL LETTER O WITH MACRON */\n#define XK_kcedilla                      0x03f3  /* U+0137 LATIN SMALL LETTER K WITH CEDILLA */\n#define XK_uogonek                       0x03f9  /* U+0173 LATIN SMALL LETTER U WITH OGONEK */\n#define XK_utilde                        0x03fd  /* U+0169 LATIN SMALL LETTER U WITH TILDE */\n#define XK_umacron                       0x03fe  /* U+016B LATIN SMALL LETTER U WITH MACRON */\n#endif /* XK_LATIN4 */\n\n/*\n * Latin 8\n */\n#ifdef XK_LATIN8\n#define XK_Wcircumflex                0x1000174  /* U+0174 LATIN CAPITAL LETTER W WITH CIRCUMFLEX */\n#define XK_wcircumflex                0x1000175  /* U+0175 LATIN SMALL LETTER W WITH CIRCUMFLEX */\n#define XK_Ycircumflex                0x1000176  /* U+0176 LATIN CAPITAL LETTER Y WITH CIRCUMFLEX */\n#define XK_ycircumflex                0x1000177  /* U+0177 LATIN SMALL LETTER Y WITH CIRCUMFLEX */\n#define XK_Babovedot                  0x1001e02  /* U+1E02 LATIN CAPITAL LETTER B WITH DOT ABOVE */\n#define XK_babovedot                  0x1001e03  /* U+1E03 LATIN SMALL LETTER B WITH DOT ABOVE */\n#define XK_Dabovedot                  0x1001e0a  /* U+1E0A LATIN CAPITAL LETTER D WITH DOT ABOVE */\n#define XK_dabovedot                  0x1001e0b  /* U+1E0B LATIN SMALL LETTER D WITH DOT ABOVE */\n#define XK_Fabovedot                  0x1001e1e  /* U+1E1E LATIN CAPITAL LETTER F WITH DOT ABOVE */\n#define XK_fabovedot                  0x1001e1f  /* U+1E1F LATIN SMALL LETTER F WITH DOT ABOVE */\n#define XK_Mabovedot                  0x1001e40  /* U+1E40 LATIN CAPITAL LETTER M WITH DOT ABOVE */\n#define XK_mabovedot                  0x1001e41  /* U+1E41 LATIN SMALL LETTER M WITH DOT ABOVE */\n#define XK_Pabovedot                  0x1001e56  /* U+1E56 LATIN CAPITAL LETTER P WITH DOT ABOVE */\n#define XK_pabovedot                  0x1001e57  /* U+1E57 LATIN SMALL LETTER P WITH DOT ABOVE */\n#define XK_Sabovedot                  0x1001e60  /* U+1E60 LATIN CAPITAL LETTER S WITH DOT ABOVE */\n#define XK_sabovedot                  0x1001e61  /* U+1E61 LATIN SMALL LETTER S WITH DOT ABOVE */\n#define XK_Tabovedot                  0x1001e6a  /* U+1E6A LATIN CAPITAL LETTER T WITH DOT ABOVE */\n#define XK_tabovedot                  0x1001e6b  /* U+1E6B LATIN SMALL LETTER T WITH DOT ABOVE */\n#define XK_Wgrave                     0x1001e80  /* U+1E80 LATIN CAPITAL LETTER W WITH GRAVE */\n#define XK_wgrave                     0x1001e81  /* U+1E81 LATIN SMALL LETTER W WITH GRAVE */\n#define XK_Wacute                     0x1001e82  /* U+1E82 LATIN CAPITAL LETTER W WITH ACUTE */\n#define XK_wacute                     0x1001e83  /* U+1E83 LATIN SMALL LETTER W WITH ACUTE */\n#define XK_Wdiaeresis                 0x1001e84  /* U+1E84 LATIN CAPITAL LETTER W WITH DIAERESIS */\n#define XK_wdiaeresis                 0x1001e85  /* U+1E85 LATIN SMALL LETTER W WITH DIAERESIS */\n#define XK_Ygrave                     0x1001ef2  /* U+1EF2 LATIN CAPITAL LETTER Y WITH GRAVE */\n#define XK_ygrave                     0x1001ef3  /* U+1EF3 LATIN SMALL LETTER Y WITH GRAVE */\n#endif /* XK_LATIN8 */\n\n/*\n * Latin 9\n * Byte 3 = 0x13\n */\n\n#ifdef XK_LATIN9\n#define XK_OE                            0x13bc  /* U+0152 LATIN CAPITAL LIGATURE OE */\n#define XK_oe                            0x13bd  /* U+0153 LATIN SMALL LIGATURE OE */\n#define XK_Ydiaeresis                    0x13be  /* U+0178 LATIN CAPITAL LETTER Y WITH DIAERESIS */\n#endif /* XK_LATIN9 */\n\n/*\n * Katakana\n * Byte 3 = 4\n */\n\n#ifdef XK_KATAKANA\n#define XK_overline                      0x047e  /* U+203E OVERLINE */\n#define XK_kana_fullstop                 0x04a1  /* U+3002 IDEOGRAPHIC FULL STOP */\n#define XK_kana_openingbracket           0x04a2  /* U+300C LEFT CORNER BRACKET */\n#define XK_kana_closingbracket           0x04a3  /* U+300D RIGHT CORNER BRACKET */\n#define XK_kana_comma                    0x04a4  /* U+3001 IDEOGRAPHIC COMMA */\n#define XK_kana_conjunctive              0x04a5  /* U+30FB KATAKANA MIDDLE DOT */\n#define XK_kana_middledot                0x04a5  /* deprecated */\n#define XK_kana_WO                       0x04a6  /* U+30F2 KATAKANA LETTER WO */\n#define XK_kana_a                        0x04a7  /* U+30A1 KATAKANA LETTER SMALL A */\n#define XK_kana_i                        0x04a8  /* U+30A3 KATAKANA LETTER SMALL I */\n#define XK_kana_u                        0x04a9  /* U+30A5 KATAKANA LETTER SMALL U */\n#define XK_kana_e                        0x04aa  /* U+30A7 KATAKANA LETTER SMALL E */\n#define XK_kana_o                        0x04ab  /* U+30A9 KATAKANA LETTER SMALL O */\n#define XK_kana_ya                       0x04ac  /* U+30E3 KATAKANA LETTER SMALL YA */\n#define XK_kana_yu                       0x04ad  /* U+30E5 KATAKANA LETTER SMALL YU */\n#define XK_kana_yo                       0x04ae  /* U+30E7 KATAKANA LETTER SMALL YO */\n#define XK_kana_tsu                      0x04af  /* U+30C3 KATAKANA LETTER SMALL TU */\n#define XK_kana_tu                       0x04af  /* deprecated */\n#define XK_prolongedsound                0x04b0  /* U+30FC KATAKANA-HIRAGANA PROLONGED SOUND MARK */\n#define XK_kana_A                        0x04b1  /* U+30A2 KATAKANA LETTER A */\n#define XK_kana_I                        0x04b2  /* U+30A4 KATAKANA LETTER I */\n#define XK_kana_U                        0x04b3  /* U+30A6 KATAKANA LETTER U */\n#define XK_kana_E                        0x04b4  /* U+30A8 KATAKANA LETTER E */\n#define XK_kana_O                        0x04b5  /* U+30AA KATAKANA LETTER O */\n#define XK_kana_KA                       0x04b6  /* U+30AB KATAKANA LETTER KA */\n#define XK_kana_KI                       0x04b7  /* U+30AD KATAKANA LETTER KI */\n#define XK_kana_KU                       0x04b8  /* U+30AF KATAKANA LETTER KU */\n#define XK_kana_KE                       0x04b9  /* U+30B1 KATAKANA LETTER KE */\n#define XK_kana_KO                       0x04ba  /* U+30B3 KATAKANA LETTER KO */\n#define XK_kana_SA                       0x04bb  /* U+30B5 KATAKANA LETTER SA */\n#define XK_kana_SHI                      0x04bc  /* U+30B7 KATAKANA LETTER SI */\n#define XK_kana_SU                       0x04bd  /* U+30B9 KATAKANA LETTER SU */\n#define XK_kana_SE                       0x04be  /* U+30BB KATAKANA LETTER SE */\n#define XK_kana_SO                       0x04bf  /* U+30BD KATAKANA LETTER SO */\n#define XK_kana_TA                       0x04c0  /* U+30BF KATAKANA LETTER TA */\n#define XK_kana_CHI                      0x04c1  /* U+30C1 KATAKANA LETTER TI */\n#define XK_kana_TI                       0x04c1  /* deprecated */\n#define XK_kana_TSU                      0x04c2  /* U+30C4 KATAKANA LETTER TU */\n#define XK_kana_TU                       0x04c2  /* deprecated */\n#define XK_kana_TE                       0x04c3  /* U+30C6 KATAKANA LETTER TE */\n#define XK_kana_TO                       0x04c4  /* U+30C8 KATAKANA LETTER TO */\n#define XK_kana_NA                       0x04c5  /* U+30CA KATAKANA LETTER NA */\n#define XK_kana_NI                       0x04c6  /* U+30CB KATAKANA LETTER NI */\n#define XK_kana_NU                       0x04c7  /* U+30CC KATAKANA LETTER NU */\n#define XK_kana_NE                       0x04c8  /* U+30CD KATAKANA LETTER NE */\n#define XK_kana_NO                       0x04c9  /* U+30CE KATAKANA LETTER NO */\n#define XK_kana_HA                       0x04ca  /* U+30CF KATAKANA LETTER HA */\n#define XK_kana_HI                       0x04cb  /* U+30D2 KATAKANA LETTER HI */\n#define XK_kana_FU                       0x04cc  /* U+30D5 KATAKANA LETTER HU */\n#define XK_kana_HU                       0x04cc  /* deprecated */\n#define XK_kana_HE                       0x04cd  /* U+30D8 KATAKANA LETTER HE */\n#define XK_kana_HO                       0x04ce  /* U+30DB KATAKANA LETTER HO */\n#define XK_kana_MA                       0x04cf  /* U+30DE KATAKANA LETTER MA */\n#define XK_kana_MI                       0x04d0  /* U+30DF KATAKANA LETTER MI */\n#define XK_kana_MU                       0x04d1  /* U+30E0 KATAKANA LETTER MU */\n#define XK_kana_ME                       0x04d2  /* U+30E1 KATAKANA LETTER ME */\n#define XK_kana_MO                       0x04d3  /* U+30E2 KATAKANA LETTER MO */\n#define XK_kana_YA                       0x04d4  /* U+30E4 KATAKANA LETTER YA */\n#define XK_kana_YU                       0x04d5  /* U+30E6 KATAKANA LETTER YU */\n#define XK_kana_YO                       0x04d6  /* U+30E8 KATAKANA LETTER YO */\n#define XK_kana_RA                       0x04d7  /* U+30E9 KATAKANA LETTER RA */\n#define XK_kana_RI                       0x04d8  /* U+30EA KATAKANA LETTER RI */\n#define XK_kana_RU                       0x04d9  /* U+30EB KATAKANA LETTER RU */\n#define XK_kana_RE                       0x04da  /* U+30EC KATAKANA LETTER RE */\n#define XK_kana_RO                       0x04db  /* U+30ED KATAKANA LETTER RO */\n#define XK_kana_WA                       0x04dc  /* U+30EF KATAKANA LETTER WA */\n#define XK_kana_N                        0x04dd  /* U+30F3 KATAKANA LETTER N */\n#define XK_voicedsound                   0x04de  /* U+309B KATAKANA-HIRAGANA VOICED SOUND MARK */\n#define XK_semivoicedsound               0x04df  /* U+309C KATAKANA-HIRAGANA SEMI-VOICED SOUND MARK */\n#define XK_kana_switch                   0xff7e  /* Alias for mode_switch */\n#endif /* XK_KATAKANA */\n\n/*\n * Arabic\n * Byte 3 = 5\n */\n\n#ifdef XK_ARABIC\n#define XK_Farsi_0                    0x10006f0  /* U+06F0 EXTENDED ARABIC-INDIC DIGIT ZERO */\n#define XK_Farsi_1                    0x10006f1  /* U+06F1 EXTENDED ARABIC-INDIC DIGIT ONE */\n#define XK_Farsi_2                    0x10006f2  /* U+06F2 EXTENDED ARABIC-INDIC DIGIT TWO */\n#define XK_Farsi_3                    0x10006f3  /* U+06F3 EXTENDED ARABIC-INDIC DIGIT THREE */\n#define XK_Farsi_4                    0x10006f4  /* U+06F4 EXTENDED ARABIC-INDIC DIGIT FOUR */\n#define XK_Farsi_5                    0x10006f5  /* U+06F5 EXTENDED ARABIC-INDIC DIGIT FIVE */\n#define XK_Farsi_6                    0x10006f6  /* U+06F6 EXTENDED ARABIC-INDIC DIGIT SIX */\n#define XK_Farsi_7                    0x10006f7  /* U+06F7 EXTENDED ARABIC-INDIC DIGIT SEVEN */\n#define XK_Farsi_8                    0x10006f8  /* U+06F8 EXTENDED ARABIC-INDIC DIGIT EIGHT */\n#define XK_Farsi_9                    0x10006f9  /* U+06F9 EXTENDED ARABIC-INDIC DIGIT NINE */\n#define XK_Arabic_percent             0x100066a  /* U+066A ARABIC PERCENT SIGN */\n#define XK_Arabic_superscript_alef    0x1000670  /* U+0670 ARABIC LETTER SUPERSCRIPT ALEF */\n#define XK_Arabic_tteh                0x1000679  /* U+0679 ARABIC LETTER TTEH */\n#define XK_Arabic_peh                 0x100067e  /* U+067E ARABIC LETTER PEH */\n#define XK_Arabic_tcheh               0x1000686  /* U+0686 ARABIC LETTER TCHEH */\n#define XK_Arabic_ddal                0x1000688  /* U+0688 ARABIC LETTER DDAL */\n#define XK_Arabic_rreh                0x1000691  /* U+0691 ARABIC LETTER RREH */\n#define XK_Arabic_comma                  0x05ac  /* U+060C ARABIC COMMA */\n#define XK_Arabic_fullstop            0x10006d4  /* U+06D4 ARABIC FULL STOP */\n#define XK_Arabic_0                   0x1000660  /* U+0660 ARABIC-INDIC DIGIT ZERO */\n#define XK_Arabic_1                   0x1000661  /* U+0661 ARABIC-INDIC DIGIT ONE */\n#define XK_Arabic_2                   0x1000662  /* U+0662 ARABIC-INDIC DIGIT TWO */\n#define XK_Arabic_3                   0x1000663  /* U+0663 ARABIC-INDIC DIGIT THREE */\n#define XK_Arabic_4                   0x1000664  /* U+0664 ARABIC-INDIC DIGIT FOUR */\n#define XK_Arabic_5                   0x1000665  /* U+0665 ARABIC-INDIC DIGIT FIVE */\n#define XK_Arabic_6                   0x1000666  /* U+0666 ARABIC-INDIC DIGIT SIX */\n#define XK_Arabic_7                   0x1000667  /* U+0667 ARABIC-INDIC DIGIT SEVEN */\n#define XK_Arabic_8                   0x1000668  /* U+0668 ARABIC-INDIC DIGIT EIGHT */\n#define XK_Arabic_9                   0x1000669  /* U+0669 ARABIC-INDIC DIGIT NINE */\n#define XK_Arabic_semicolon              0x05bb  /* U+061B ARABIC SEMICOLON */\n#define XK_Arabic_question_mark          0x05bf  /* U+061F ARABIC QUESTION MARK */\n#define XK_Arabic_hamza                  0x05c1  /* U+0621 ARABIC LETTER HAMZA */\n#define XK_Arabic_maddaonalef            0x05c2  /* U+0622 ARABIC LETTER ALEF WITH MADDA ABOVE */\n#define XK_Arabic_hamzaonalef            0x05c3  /* U+0623 ARABIC LETTER ALEF WITH HAMZA ABOVE */\n#define XK_Arabic_hamzaonwaw             0x05c4  /* U+0624 ARABIC LETTER WAW WITH HAMZA ABOVE */\n#define XK_Arabic_hamzaunderalef         0x05c5  /* U+0625 ARABIC LETTER ALEF WITH HAMZA BELOW */\n#define XK_Arabic_hamzaonyeh             0x05c6  /* U+0626 ARABIC LETTER YEH WITH HAMZA ABOVE */\n#define XK_Arabic_alef                   0x05c7  /* U+0627 ARABIC LETTER ALEF */\n#define XK_Arabic_beh                    0x05c8  /* U+0628 ARABIC LETTER BEH */\n#define XK_Arabic_tehmarbuta             0x05c9  /* U+0629 ARABIC LETTER TEH MARBUTA */\n#define XK_Arabic_teh                    0x05ca  /* U+062A ARABIC LETTER TEH */\n#define XK_Arabic_theh                   0x05cb  /* U+062B ARABIC LETTER THEH */\n#define XK_Arabic_jeem                   0x05cc  /* U+062C ARABIC LETTER JEEM */\n#define XK_Arabic_hah                    0x05cd  /* U+062D ARABIC LETTER HAH */\n#define XK_Arabic_khah                   0x05ce  /* U+062E ARABIC LETTER KHAH */\n#define XK_Arabic_dal                    0x05cf  /* U+062F ARABIC LETTER DAL */\n#define XK_Arabic_thal                   0x05d0  /* U+0630 ARABIC LETTER THAL */\n#define XK_Arabic_ra                     0x05d1  /* U+0631 ARABIC LETTER REH */\n#define XK_Arabic_zain                   0x05d2  /* U+0632 ARABIC LETTER ZAIN */\n#define XK_Arabic_seen                   0x05d3  /* U+0633 ARABIC LETTER SEEN */\n#define XK_Arabic_sheen                  0x05d4  /* U+0634 ARABIC LETTER SHEEN */\n#define XK_Arabic_sad                    0x05d5  /* U+0635 ARABIC LETTER SAD */\n#define XK_Arabic_dad                    0x05d6  /* U+0636 ARABIC LETTER DAD */\n#define XK_Arabic_tah                    0x05d7  /* U+0637 ARABIC LETTER TAH */\n#define XK_Arabic_zah                    0x05d8  /* U+0638 ARABIC LETTER ZAH */\n#define XK_Arabic_ain                    0x05d9  /* U+0639 ARABIC LETTER AIN */\n#define XK_Arabic_ghain                  0x05da  /* U+063A ARABIC LETTER GHAIN */\n#define XK_Arabic_tatweel                0x05e0  /* U+0640 ARABIC TATWEEL */\n#define XK_Arabic_feh                    0x05e1  /* U+0641 ARABIC LETTER FEH */\n#define XK_Arabic_qaf                    0x05e2  /* U+0642 ARABIC LETTER QAF */\n#define XK_Arabic_kaf                    0x05e3  /* U+0643 ARABIC LETTER KAF */\n#define XK_Arabic_lam                    0x05e4  /* U+0644 ARABIC LETTER LAM */\n#define XK_Arabic_meem                   0x05e5  /* U+0645 ARABIC LETTER MEEM */\n#define XK_Arabic_noon                   0x05e6  /* U+0646 ARABIC LETTER NOON */\n#define XK_Arabic_ha                     0x05e7  /* U+0647 ARABIC LETTER HEH */\n#define XK_Arabic_heh                    0x05e7  /* deprecated */\n#define XK_Arabic_waw                    0x05e8  /* U+0648 ARABIC LETTER WAW */\n#define XK_Arabic_alefmaksura            0x05e9  /* U+0649 ARABIC LETTER ALEF MAKSURA */\n#define XK_Arabic_yeh                    0x05ea  /* U+064A ARABIC LETTER YEH */\n#define XK_Arabic_fathatan               0x05eb  /* U+064B ARABIC FATHATAN */\n#define XK_Arabic_dammatan               0x05ec  /* U+064C ARABIC DAMMATAN */\n#define XK_Arabic_kasratan               0x05ed  /* U+064D ARABIC KASRATAN */\n#define XK_Arabic_fatha                  0x05ee  /* U+064E ARABIC FATHA */\n#define XK_Arabic_damma                  0x05ef  /* U+064F ARABIC DAMMA */\n#define XK_Arabic_kasra                  0x05f0  /* U+0650 ARABIC KASRA */\n#define XK_Arabic_shadda                 0x05f1  /* U+0651 ARABIC SHADDA */\n#define XK_Arabic_sukun                  0x05f2  /* U+0652 ARABIC SUKUN */\n#define XK_Arabic_madda_above         0x1000653  /* U+0653 ARABIC MADDAH ABOVE */\n#define XK_Arabic_hamza_above         0x1000654  /* U+0654 ARABIC HAMZA ABOVE */\n#define XK_Arabic_hamza_below         0x1000655  /* U+0655 ARABIC HAMZA BELOW */\n#define XK_Arabic_jeh                 0x1000698  /* U+0698 ARABIC LETTER JEH */\n#define XK_Arabic_veh                 0x10006a4  /* U+06A4 ARABIC LETTER VEH */\n#define XK_Arabic_keheh               0x10006a9  /* U+06A9 ARABIC LETTER KEHEH */\n#define XK_Arabic_gaf                 0x10006af  /* U+06AF ARABIC LETTER GAF */\n#define XK_Arabic_noon_ghunna         0x10006ba  /* U+06BA ARABIC LETTER NOON GHUNNA */\n#define XK_Arabic_heh_doachashmee     0x10006be  /* U+06BE ARABIC LETTER HEH DOACHASHMEE */\n#define XK_Farsi_yeh                  0x10006cc  /* U+06CC ARABIC LETTER FARSI YEH */\n#define XK_Arabic_farsi_yeh           0x10006cc  /* U+06CC ARABIC LETTER FARSI YEH */\n#define XK_Arabic_yeh_baree           0x10006d2  /* U+06D2 ARABIC LETTER YEH BARREE */\n#define XK_Arabic_heh_goal            0x10006c1  /* U+06C1 ARABIC LETTER HEH GOAL */\n#define XK_Arabic_switch                 0xff7e  /* Alias for mode_switch */\n#endif /* XK_ARABIC */\n\n/*\n * Cyrillic\n * Byte 3 = 6\n */\n#ifdef XK_CYRILLIC\n#define XK_Cyrillic_GHE_bar           0x1000492  /* U+0492 CYRILLIC CAPITAL LETTER GHE WITH STROKE */\n#define XK_Cyrillic_ghe_bar           0x1000493  /* U+0493 CYRILLIC SMALL LETTER GHE WITH STROKE */\n#define XK_Cyrillic_ZHE_descender     0x1000496  /* U+0496 CYRILLIC CAPITAL LETTER ZHE WITH DESCENDER */\n#define XK_Cyrillic_zhe_descender     0x1000497  /* U+0497 CYRILLIC SMALL LETTER ZHE WITH DESCENDER */\n#define XK_Cyrillic_KA_descender      0x100049a  /* U+049A CYRILLIC CAPITAL LETTER KA WITH DESCENDER */\n#define XK_Cyrillic_ka_descender      0x100049b  /* U+049B CYRILLIC SMALL LETTER KA WITH DESCENDER */\n#define XK_Cyrillic_KA_vertstroke     0x100049c  /* U+049C CYRILLIC CAPITAL LETTER KA WITH VERTICAL STROKE */\n#define XK_Cyrillic_ka_vertstroke     0x100049d  /* U+049D CYRILLIC SMALL LETTER KA WITH VERTICAL STROKE */\n#define XK_Cyrillic_EN_descender      0x10004a2  /* U+04A2 CYRILLIC CAPITAL LETTER EN WITH DESCENDER */\n#define XK_Cyrillic_en_descender      0x10004a3  /* U+04A3 CYRILLIC SMALL LETTER EN WITH DESCENDER */\n#define XK_Cyrillic_U_straight        0x10004ae  /* U+04AE CYRILLIC CAPITAL LETTER STRAIGHT U */\n#define XK_Cyrillic_u_straight        0x10004af  /* U+04AF CYRILLIC SMALL LETTER STRAIGHT U */\n#define XK_Cyrillic_U_straight_bar    0x10004b0  /* U+04B0 CYRILLIC CAPITAL LETTER STRAIGHT U WITH STROKE */\n#define XK_Cyrillic_u_straight_bar    0x10004b1  /* U+04B1 CYRILLIC SMALL LETTER STRAIGHT U WITH STROKE */\n#define XK_Cyrillic_HA_descender      0x10004b2  /* U+04B2 CYRILLIC CAPITAL LETTER HA WITH DESCENDER */\n#define XK_Cyrillic_ha_descender      0x10004b3  /* U+04B3 CYRILLIC SMALL LETTER HA WITH DESCENDER */\n#define XK_Cyrillic_CHE_descender     0x10004b6  /* U+04B6 CYRILLIC CAPITAL LETTER CHE WITH DESCENDER */\n#define XK_Cyrillic_che_descender     0x10004b7  /* U+04B7 CYRILLIC SMALL LETTER CHE WITH DESCENDER */\n#define XK_Cyrillic_CHE_vertstroke    0x10004b8  /* U+04B8 CYRILLIC CAPITAL LETTER CHE WITH VERTICAL STROKE */\n#define XK_Cyrillic_che_vertstroke    0x10004b9  /* U+04B9 CYRILLIC SMALL LETTER CHE WITH VERTICAL STROKE */\n#define XK_Cyrillic_SHHA              0x10004ba  /* U+04BA CYRILLIC CAPITAL LETTER SHHA */\n#define XK_Cyrillic_shha              0x10004bb  /* U+04BB CYRILLIC SMALL LETTER SHHA */\n\n#define XK_Cyrillic_SCHWA             0x10004d8  /* U+04D8 CYRILLIC CAPITAL LETTER SCHWA */\n#define XK_Cyrillic_schwa             0x10004d9  /* U+04D9 CYRILLIC SMALL LETTER SCHWA */\n#define XK_Cyrillic_I_macron          0x10004e2  /* U+04E2 CYRILLIC CAPITAL LETTER I WITH MACRON */\n#define XK_Cyrillic_i_macron          0x10004e3  /* U+04E3 CYRILLIC SMALL LETTER I WITH MACRON */\n#define XK_Cyrillic_O_bar             0x10004e8  /* U+04E8 CYRILLIC CAPITAL LETTER BARRED O */\n#define XK_Cyrillic_o_bar             0x10004e9  /* U+04E9 CYRILLIC SMALL LETTER BARRED O */\n#define XK_Cyrillic_U_macron          0x10004ee  /* U+04EE CYRILLIC CAPITAL LETTER U WITH MACRON */\n#define XK_Cyrillic_u_macron          0x10004ef  /* U+04EF CYRILLIC SMALL LETTER U WITH MACRON */\n\n#define XK_Serbian_dje                   0x06a1  /* U+0452 CYRILLIC SMALL LETTER DJE */\n#define XK_Macedonia_gje                 0x06a2  /* U+0453 CYRILLIC SMALL LETTER GJE */\n#define XK_Cyrillic_io                   0x06a3  /* U+0451 CYRILLIC SMALL LETTER IO */\n#define XK_Ukrainian_ie                  0x06a4  /* U+0454 CYRILLIC SMALL LETTER UKRAINIAN IE */\n#define XK_Ukranian_je                   0x06a4  /* deprecated */\n#define XK_Macedonia_dse                 0x06a5  /* U+0455 CYRILLIC SMALL LETTER DZE */\n#define XK_Ukrainian_i                   0x06a6  /* U+0456 CYRILLIC SMALL LETTER BYELORUSSIAN-UKRAINIAN I */\n#define XK_Ukranian_i                    0x06a6  /* deprecated */\n#define XK_Ukrainian_yi                  0x06a7  /* U+0457 CYRILLIC SMALL LETTER YI */\n#define XK_Ukranian_yi                   0x06a7  /* deprecated */\n#define XK_Cyrillic_je                   0x06a8  /* U+0458 CYRILLIC SMALL LETTER JE */\n#define XK_Serbian_je                    0x06a8  /* deprecated */\n#define XK_Cyrillic_lje                  0x06a9  /* U+0459 CYRILLIC SMALL LETTER LJE */\n#define XK_Serbian_lje                   0x06a9  /* deprecated */\n#define XK_Cyrillic_nje                  0x06aa  /* U+045A CYRILLIC SMALL LETTER NJE */\n#define XK_Serbian_nje                   0x06aa  /* deprecated */\n#define XK_Serbian_tshe                  0x06ab  /* U+045B CYRILLIC SMALL LETTER TSHE */\n#define XK_Macedonia_kje                 0x06ac  /* U+045C CYRILLIC SMALL LETTER KJE */\n#define XK_Ukrainian_ghe_with_upturn     0x06ad  /* U+0491 CYRILLIC SMALL LETTER GHE WITH UPTURN */\n#define XK_Byelorussian_shortu           0x06ae  /* U+045E CYRILLIC SMALL LETTER SHORT U */\n#define XK_Cyrillic_dzhe                 0x06af  /* U+045F CYRILLIC SMALL LETTER DZHE */\n#define XK_Serbian_dze                   0x06af  /* deprecated */\n#define XK_numerosign                    0x06b0  /* U+2116 NUMERO SIGN */\n#define XK_Serbian_DJE                   0x06b1  /* U+0402 CYRILLIC CAPITAL LETTER DJE */\n#define XK_Macedonia_GJE                 0x06b2  /* U+0403 CYRILLIC CAPITAL LETTER GJE */\n#define XK_Cyrillic_IO                   0x06b3  /* U+0401 CYRILLIC CAPITAL LETTER IO */\n#define XK_Ukrainian_IE                  0x06b4  /* U+0404 CYRILLIC CAPITAL LETTER UKRAINIAN IE */\n#define XK_Ukranian_JE                   0x06b4  /* deprecated */\n#define XK_Macedonia_DSE                 0x06b5  /* U+0405 CYRILLIC CAPITAL LETTER DZE */\n#define XK_Ukrainian_I                   0x06b6  /* U+0406 CYRILLIC CAPITAL LETTER BYELORUSSIAN-UKRAINIAN I */\n#define XK_Ukranian_I                    0x06b6  /* deprecated */\n#define XK_Ukrainian_YI                  0x06b7  /* U+0407 CYRILLIC CAPITAL LETTER YI */\n#define XK_Ukranian_YI                   0x06b7  /* deprecated */\n#define XK_Cyrillic_JE                   0x06b8  /* U+0408 CYRILLIC CAPITAL LETTER JE */\n#define XK_Serbian_JE                    0x06b8  /* deprecated */\n#define XK_Cyrillic_LJE                  0x06b9  /* U+0409 CYRILLIC CAPITAL LETTER LJE */\n#define XK_Serbian_LJE                   0x06b9  /* deprecated */\n#define XK_Cyrillic_NJE                  0x06ba  /* U+040A CYRILLIC CAPITAL LETTER NJE */\n#define XK_Serbian_NJE                   0x06ba  /* deprecated */\n#define XK_Serbian_TSHE                  0x06bb  /* U+040B CYRILLIC CAPITAL LETTER TSHE */\n#define XK_Macedonia_KJE                 0x06bc  /* U+040C CYRILLIC CAPITAL LETTER KJE */\n#define XK_Ukrainian_GHE_WITH_UPTURN     0x06bd  /* U+0490 CYRILLIC CAPITAL LETTER GHE WITH UPTURN */\n#define XK_Byelorussian_SHORTU           0x06be  /* U+040E CYRILLIC CAPITAL LETTER SHORT U */\n#define XK_Cyrillic_DZHE                 0x06bf  /* U+040F CYRILLIC CAPITAL LETTER DZHE */\n#define XK_Serbian_DZE                   0x06bf  /* deprecated */\n#define XK_Cyrillic_yu                   0x06c0  /* U+044E CYRILLIC SMALL LETTER YU */\n#define XK_Cyrillic_a                    0x06c1  /* U+0430 CYRILLIC SMALL LETTER A */\n#define XK_Cyrillic_be                   0x06c2  /* U+0431 CYRILLIC SMALL LETTER BE */\n#define XK_Cyrillic_tse                  0x06c3  /* U+0446 CYRILLIC SMALL LETTER TSE */\n#define XK_Cyrillic_de                   0x06c4  /* U+0434 CYRILLIC SMALL LETTER DE */\n#define XK_Cyrillic_ie                   0x06c5  /* U+0435 CYRILLIC SMALL LETTER IE */\n#define XK_Cyrillic_ef                   0x06c6  /* U+0444 CYRILLIC SMALL LETTER EF */\n#define XK_Cyrillic_ghe                  0x06c7  /* U+0433 CYRILLIC SMALL LETTER GHE */\n#define XK_Cyrillic_ha                   0x06c8  /* U+0445 CYRILLIC SMALL LETTER HA */\n#define XK_Cyrillic_i                    0x06c9  /* U+0438 CYRILLIC SMALL LETTER I */\n#define XK_Cyrillic_shorti               0x06ca  /* U+0439 CYRILLIC SMALL LETTER SHORT I */\n#define XK_Cyrillic_ka                   0x06cb  /* U+043A CYRILLIC SMALL LETTER KA */\n#define XK_Cyrillic_el                   0x06cc  /* U+043B CYRILLIC SMALL LETTER EL */\n#define XK_Cyrillic_em                   0x06cd  /* U+043C CYRILLIC SMALL LETTER EM */\n#define XK_Cyrillic_en                   0x06ce  /* U+043D CYRILLIC SMALL LETTER EN */\n#define XK_Cyrillic_o                    0x06cf  /* U+043E CYRILLIC SMALL LETTER O */\n#define XK_Cyrillic_pe                   0x06d0  /* U+043F CYRILLIC SMALL LETTER PE */\n#define XK_Cyrillic_ya                   0x06d1  /* U+044F CYRILLIC SMALL LETTER YA */\n#define XK_Cyrillic_er                   0x06d2  /* U+0440 CYRILLIC SMALL LETTER ER */\n#define XK_Cyrillic_es                   0x06d3  /* U+0441 CYRILLIC SMALL LETTER ES */\n#define XK_Cyrillic_te                   0x06d4  /* U+0442 CYRILLIC SMALL LETTER TE */\n#define XK_Cyrillic_u                    0x06d5  /* U+0443 CYRILLIC SMALL LETTER U */\n#define XK_Cyrillic_zhe                  0x06d6  /* U+0436 CYRILLIC SMALL LETTER ZHE */\n#define XK_Cyrillic_ve                   0x06d7  /* U+0432 CYRILLIC SMALL LETTER VE */\n#define XK_Cyrillic_softsign             0x06d8  /* U+044C CYRILLIC SMALL LETTER SOFT SIGN */\n#define XK_Cyrillic_yeru                 0x06d9  /* U+044B CYRILLIC SMALL LETTER YERU */\n#define XK_Cyrillic_ze                   0x06da  /* U+0437 CYRILLIC SMALL LETTER ZE */\n#define XK_Cyrillic_sha                  0x06db  /* U+0448 CYRILLIC SMALL LETTER SHA */\n#define XK_Cyrillic_e                    0x06dc  /* U+044D CYRILLIC SMALL LETTER E */\n#define XK_Cyrillic_shcha                0x06dd  /* U+0449 CYRILLIC SMALL LETTER SHCHA */\n#define XK_Cyrillic_che                  0x06de  /* U+0447 CYRILLIC SMALL LETTER CHE */\n#define XK_Cyrillic_hardsign             0x06df  /* U+044A CYRILLIC SMALL LETTER HARD SIGN */\n#define XK_Cyrillic_YU                   0x06e0  /* U+042E CYRILLIC CAPITAL LETTER YU */\n#define XK_Cyrillic_A                    0x06e1  /* U+0410 CYRILLIC CAPITAL LETTER A */\n#define XK_Cyrillic_BE                   0x06e2  /* U+0411 CYRILLIC CAPITAL LETTER BE */\n#define XK_Cyrillic_TSE                  0x06e3  /* U+0426 CYRILLIC CAPITAL LETTER TSE */\n#define XK_Cyrillic_DE                   0x06e4  /* U+0414 CYRILLIC CAPITAL LETTER DE */\n#define XK_Cyrillic_IE                   0x06e5  /* U+0415 CYRILLIC CAPITAL LETTER IE */\n#define XK_Cyrillic_EF                   0x06e6  /* U+0424 CYRILLIC CAPITAL LETTER EF */\n#define XK_Cyrillic_GHE                  0x06e7  /* U+0413 CYRILLIC CAPITAL LETTER GHE */\n#define XK_Cyrillic_HA                   0x06e8  /* U+0425 CYRILLIC CAPITAL LETTER HA */\n#define XK_Cyrillic_I                    0x06e9  /* U+0418 CYRILLIC CAPITAL LETTER I */\n#define XK_Cyrillic_SHORTI               0x06ea  /* U+0419 CYRILLIC CAPITAL LETTER SHORT I */\n#define XK_Cyrillic_KA                   0x06eb  /* U+041A CYRILLIC CAPITAL LETTER KA */\n#define XK_Cyrillic_EL                   0x06ec  /* U+041B CYRILLIC CAPITAL LETTER EL */\n#define XK_Cyrillic_EM                   0x06ed  /* U+041C CYRILLIC CAPITAL LETTER EM */\n#define XK_Cyrillic_EN                   0x06ee  /* U+041D CYRILLIC CAPITAL LETTER EN */\n#define XK_Cyrillic_O                    0x06ef  /* U+041E CYRILLIC CAPITAL LETTER O */\n#define XK_Cyrillic_PE                   0x06f0  /* U+041F CYRILLIC CAPITAL LETTER PE */\n#define XK_Cyrillic_YA                   0x06f1  /* U+042F CYRILLIC CAPITAL LETTER YA */\n#define XK_Cyrillic_ER                   0x06f2  /* U+0420 CYRILLIC CAPITAL LETTER ER */\n#define XK_Cyrillic_ES                   0x06f3  /* U+0421 CYRILLIC CAPITAL LETTER ES */\n#define XK_Cyrillic_TE                   0x06f4  /* U+0422 CYRILLIC CAPITAL LETTER TE */\n#define XK_Cyrillic_U                    0x06f5  /* U+0423 CYRILLIC CAPITAL LETTER U */\n#define XK_Cyrillic_ZHE                  0x06f6  /* U+0416 CYRILLIC CAPITAL LETTER ZHE */\n#define XK_Cyrillic_VE                   0x06f7  /* U+0412 CYRILLIC CAPITAL LETTER VE */\n#define XK_Cyrillic_SOFTSIGN             0x06f8  /* U+042C CYRILLIC CAPITAL LETTER SOFT SIGN */\n#define XK_Cyrillic_YERU                 0x06f9  /* U+042B CYRILLIC CAPITAL LETTER YERU */\n#define XK_Cyrillic_ZE                   0x06fa  /* U+0417 CYRILLIC CAPITAL LETTER ZE */\n#define XK_Cyrillic_SHA                  0x06fb  /* U+0428 CYRILLIC CAPITAL LETTER SHA */\n#define XK_Cyrillic_E                    0x06fc  /* U+042D CYRILLIC CAPITAL LETTER E */\n#define XK_Cyrillic_SHCHA                0x06fd  /* U+0429 CYRILLIC CAPITAL LETTER SHCHA */\n#define XK_Cyrillic_CHE                  0x06fe  /* U+0427 CYRILLIC CAPITAL LETTER CHE */\n#define XK_Cyrillic_HARDSIGN             0x06ff  /* U+042A CYRILLIC CAPITAL LETTER HARD SIGN */\n#endif /* XK_CYRILLIC */\n\n/*\n * Greek\n * (based on an early draft of, and not quite identical to, ISO/IEC 8859-7)\n * Byte 3 = 7\n */\n\n#ifdef XK_GREEK\n#define XK_Greek_ALPHAaccent             0x07a1  /* U+0386 GREEK CAPITAL LETTER ALPHA WITH TONOS */\n#define XK_Greek_EPSILONaccent           0x07a2  /* U+0388 GREEK CAPITAL LETTER EPSILON WITH TONOS */\n#define XK_Greek_ETAaccent               0x07a3  /* U+0389 GREEK CAPITAL LETTER ETA WITH TONOS */\n#define XK_Greek_IOTAaccent              0x07a4  /* U+038A GREEK CAPITAL LETTER IOTA WITH TONOS */\n#define XK_Greek_IOTAdieresis            0x07a5  /* U+03AA GREEK CAPITAL LETTER IOTA WITH DIALYTIKA */\n#define XK_Greek_IOTAdiaeresis           0x07a5  /* old typo */\n#define XK_Greek_OMICRONaccent           0x07a7  /* U+038C GREEK CAPITAL LETTER OMICRON WITH TONOS */\n#define XK_Greek_UPSILONaccent           0x07a8  /* U+038E GREEK CAPITAL LETTER UPSILON WITH TONOS */\n#define XK_Greek_UPSILONdieresis         0x07a9  /* U+03AB GREEK CAPITAL LETTER UPSILON WITH DIALYTIKA */\n#define XK_Greek_OMEGAaccent             0x07ab  /* U+038F GREEK CAPITAL LETTER OMEGA WITH TONOS */\n#define XK_Greek_accentdieresis          0x07ae  /* U+0385 GREEK DIALYTIKA TONOS */\n#define XK_Greek_horizbar                0x07af  /* U+2015 HORIZONTAL BAR */\n#define XK_Greek_alphaaccent             0x07b1  /* U+03AC GREEK SMALL LETTER ALPHA WITH TONOS */\n#define XK_Greek_epsilonaccent           0x07b2  /* U+03AD GREEK SMALL LETTER EPSILON WITH TONOS */\n#define XK_Greek_etaaccent               0x07b3  /* U+03AE GREEK SMALL LETTER ETA WITH TONOS */\n#define XK_Greek_iotaaccent              0x07b4  /* U+03AF GREEK SMALL LETTER IOTA WITH TONOS */\n#define XK_Greek_iotadieresis            0x07b5  /* U+03CA GREEK SMALL LETTER IOTA WITH DIALYTIKA */\n#define XK_Greek_iotaaccentdieresis      0x07b6  /* U+0390 GREEK SMALL LETTER IOTA WITH DIALYTIKA AND TONOS */\n#define XK_Greek_omicronaccent           0x07b7  /* U+03CC GREEK SMALL LETTER OMICRON WITH TONOS */\n#define XK_Greek_upsilonaccent           0x07b8  /* U+03CD GREEK SMALL LETTER UPSILON WITH TONOS */\n#define XK_Greek_upsilondieresis         0x07b9  /* U+03CB GREEK SMALL LETTER UPSILON WITH DIALYTIKA */\n#define XK_Greek_upsilonaccentdieresis   0x07ba  /* U+03B0 GREEK SMALL LETTER UPSILON WITH DIALYTIKA AND TONOS */\n#define XK_Greek_omegaaccent             0x07bb  /* U+03CE GREEK SMALL LETTER OMEGA WITH TONOS */\n#define XK_Greek_ALPHA                   0x07c1  /* U+0391 GREEK CAPITAL LETTER ALPHA */\n#define XK_Greek_BETA                    0x07c2  /* U+0392 GREEK CAPITAL LETTER BETA */\n#define XK_Greek_GAMMA                   0x07c3  /* U+0393 GREEK CAPITAL LETTER GAMMA */\n#define XK_Greek_DELTA                   0x07c4  /* U+0394 GREEK CAPITAL LETTER DELTA */\n#define XK_Greek_EPSILON                 0x07c5  /* U+0395 GREEK CAPITAL LETTER EPSILON */\n#define XK_Greek_ZETA                    0x07c6  /* U+0396 GREEK CAPITAL LETTER ZETA */\n#define XK_Greek_ETA                     0x07c7  /* U+0397 GREEK CAPITAL LETTER ETA */\n#define XK_Greek_THETA                   0x07c8  /* U+0398 GREEK CAPITAL LETTER THETA */\n#define XK_Greek_IOTA                    0x07c9  /* U+0399 GREEK CAPITAL LETTER IOTA */\n#define XK_Greek_KAPPA                   0x07ca  /* U+039A GREEK CAPITAL LETTER KAPPA */\n#define XK_Greek_LAMDA                   0x07cb  /* U+039B GREEK CAPITAL LETTER LAMDA */\n#define XK_Greek_LAMBDA                  0x07cb  /* U+039B GREEK CAPITAL LETTER LAMDA */\n#define XK_Greek_MU                      0x07cc  /* U+039C GREEK CAPITAL LETTER MU */\n#define XK_Greek_NU                      0x07cd  /* U+039D GREEK CAPITAL LETTER NU */\n#define XK_Greek_XI                      0x07ce  /* U+039E GREEK CAPITAL LETTER XI */\n#define XK_Greek_OMICRON                 0x07cf  /* U+039F GREEK CAPITAL LETTER OMICRON */\n#define XK_Greek_PI                      0x07d0  /* U+03A0 GREEK CAPITAL LETTER PI */\n#define XK_Greek_RHO                     0x07d1  /* U+03A1 GREEK CAPITAL LETTER RHO */\n#define XK_Greek_SIGMA                   0x07d2  /* U+03A3 GREEK CAPITAL LETTER SIGMA */\n#define XK_Greek_TAU                     0x07d4  /* U+03A4 GREEK CAPITAL LETTER TAU */\n#define XK_Greek_UPSILON                 0x07d5  /* U+03A5 GREEK CAPITAL LETTER UPSILON */\n#define XK_Greek_PHI                     0x07d6  /* U+03A6 GREEK CAPITAL LETTER PHI */\n#define XK_Greek_CHI                     0x07d7  /* U+03A7 GREEK CAPITAL LETTER CHI */\n#define XK_Greek_PSI                     0x07d8  /* U+03A8 GREEK CAPITAL LETTER PSI */\n#define XK_Greek_OMEGA                   0x07d9  /* U+03A9 GREEK CAPITAL LETTER OMEGA */\n#define XK_Greek_alpha                   0x07e1  /* U+03B1 GREEK SMALL LETTER ALPHA */\n#define XK_Greek_beta                    0x07e2  /* U+03B2 GREEK SMALL LETTER BETA */\n#define XK_Greek_gamma                   0x07e3  /* U+03B3 GREEK SMALL LETTER GAMMA */\n#define XK_Greek_delta                   0x07e4  /* U+03B4 GREEK SMALL LETTER DELTA */\n#define XK_Greek_epsilon                 0x07e5  /* U+03B5 GREEK SMALL LETTER EPSILON */\n#define XK_Greek_zeta                    0x07e6  /* U+03B6 GREEK SMALL LETTER ZETA */\n#define XK_Greek_eta                     0x07e7  /* U+03B7 GREEK SMALL LETTER ETA */\n#define XK_Greek_theta                   0x07e8  /* U+03B8 GREEK SMALL LETTER THETA */\n#define XK_Greek_iota                    0x07e9  /* U+03B9 GREEK SMALL LETTER IOTA */\n#define XK_Greek_kappa                   0x07ea  /* U+03BA GREEK SMALL LETTER KAPPA */\n#define XK_Greek_lamda                   0x07eb  /* U+03BB GREEK SMALL LETTER LAMDA */\n#define XK_Greek_lambda                  0x07eb  /* U+03BB GREEK SMALL LETTER LAMDA */\n#define XK_Greek_mu                      0x07ec  /* U+03BC GREEK SMALL LETTER MU */\n#define XK_Greek_nu                      0x07ed  /* U+03BD GREEK SMALL LETTER NU */\n#define XK_Greek_xi                      0x07ee  /* U+03BE GREEK SMALL LETTER XI */\n#define XK_Greek_omicron                 0x07ef  /* U+03BF GREEK SMALL LETTER OMICRON */\n#define XK_Greek_pi                      0x07f0  /* U+03C0 GREEK SMALL LETTER PI */\n#define XK_Greek_rho                     0x07f1  /* U+03C1 GREEK SMALL LETTER RHO */\n#define XK_Greek_sigma                   0x07f2  /* U+03C3 GREEK SMALL LETTER SIGMA */\n#define XK_Greek_finalsmallsigma         0x07f3  /* U+03C2 GREEK SMALL LETTER FINAL SIGMA */\n#define XK_Greek_tau                     0x07f4  /* U+03C4 GREEK SMALL LETTER TAU */\n#define XK_Greek_upsilon                 0x07f5  /* U+03C5 GREEK SMALL LETTER UPSILON */\n#define XK_Greek_phi                     0x07f6  /* U+03C6 GREEK SMALL LETTER PHI */\n#define XK_Greek_chi                     0x07f7  /* U+03C7 GREEK SMALL LETTER CHI */\n#define XK_Greek_psi                     0x07f8  /* U+03C8 GREEK SMALL LETTER PSI */\n#define XK_Greek_omega                   0x07f9  /* U+03C9 GREEK SMALL LETTER OMEGA */\n#define XK_Greek_switch                  0xff7e  /* Alias for mode_switch */\n#endif /* XK_GREEK */\n\n/*\n * Technical\n * (from the DEC VT330/VT420 Technical Character Set, http://vt100.net/charsets/technical.html)\n * Byte 3 = 8\n */\n\n#ifdef XK_TECHNICAL\n#define XK_leftradical                   0x08a1  /* U+23B7 RADICAL SYMBOL BOTTOM */\n#define XK_topleftradical                0x08a2  /*(U+250C BOX DRAWINGS LIGHT DOWN AND RIGHT)*/\n#define XK_horizconnector                0x08a3  /*(U+2500 BOX DRAWINGS LIGHT HORIZONTAL)*/\n#define XK_topintegral                   0x08a4  /* U+2320 TOP HALF INTEGRAL */\n#define XK_botintegral                   0x08a5  /* U+2321 BOTTOM HALF INTEGRAL */\n#define XK_vertconnector                 0x08a6  /*(U+2502 BOX DRAWINGS LIGHT VERTICAL)*/\n#define XK_topleftsqbracket              0x08a7  /* U+23A1 LEFT SQUARE BRACKET UPPER CORNER */\n#define XK_botleftsqbracket              0x08a8  /* U+23A3 LEFT SQUARE BRACKET LOWER CORNER */\n#define XK_toprightsqbracket             0x08a9  /* U+23A4 RIGHT SQUARE BRACKET UPPER CORNER */\n#define XK_botrightsqbracket             0x08aa  /* U+23A6 RIGHT SQUARE BRACKET LOWER CORNER */\n#define XK_topleftparens                 0x08ab  /* U+239B LEFT PARENTHESIS UPPER HOOK */\n#define XK_botleftparens                 0x08ac  /* U+239D LEFT PARENTHESIS LOWER HOOK */\n#define XK_toprightparens                0x08ad  /* U+239E RIGHT PARENTHESIS UPPER HOOK */\n#define XK_botrightparens                0x08ae  /* U+23A0 RIGHT PARENTHESIS LOWER HOOK */\n#define XK_leftmiddlecurlybrace          0x08af  /* U+23A8 LEFT CURLY BRACKET MIDDLE PIECE */\n#define XK_rightmiddlecurlybrace         0x08b0  /* U+23AC RIGHT CURLY BRACKET MIDDLE PIECE */\n#define XK_topleftsummation              0x08b1\n#define XK_botleftsummation              0x08b2\n#define XK_topvertsummationconnector     0x08b3\n#define XK_botvertsummationconnector     0x08b4\n#define XK_toprightsummation             0x08b5\n#define XK_botrightsummation             0x08b6\n#define XK_rightmiddlesummation          0x08b7\n#define XK_lessthanequal                 0x08bc  /* U+2264 LESS-THAN OR EQUAL TO */\n#define XK_notequal                      0x08bd  /* U+2260 NOT EQUAL TO */\n#define XK_greaterthanequal              0x08be  /* U+2265 GREATER-THAN OR EQUAL TO */\n#define XK_integral                      0x08bf  /* U+222B INTEGRAL */\n#define XK_therefore                     0x08c0  /* U+2234 THEREFORE */\n#define XK_variation                     0x08c1  /* U+221D PROPORTIONAL TO */\n#define XK_infinity                      0x08c2  /* U+221E INFINITY */\n#define XK_nabla                         0x08c5  /* U+2207 NABLA */\n#define XK_approximate                   0x08c8  /* U+223C TILDE OPERATOR */\n#define XK_similarequal                  0x08c9  /* U+2243 ASYMPTOTICALLY EQUAL TO */\n#define XK_ifonlyif                      0x08cd  /* U+21D4 LEFT RIGHT DOUBLE ARROW */\n#define XK_implies                       0x08ce  /* U+21D2 RIGHTWARDS DOUBLE ARROW */\n#define XK_identical                     0x08cf  /* U+2261 IDENTICAL TO */\n#define XK_radical                       0x08d6  /* U+221A SQUARE ROOT */\n#define XK_includedin                    0x08da  /* U+2282 SUBSET OF */\n#define XK_includes                      0x08db  /* U+2283 SUPERSET OF */\n#define XK_intersection                  0x08dc  /* U+2229 INTERSECTION */\n#define XK_union                         0x08dd  /* U+222A UNION */\n#define XK_logicaland                    0x08de  /* U+2227 LOGICAL AND */\n#define XK_logicalor                     0x08df  /* U+2228 LOGICAL OR */\n#define XK_partialderivative             0x08ef  /* U+2202 PARTIAL DIFFERENTIAL */\n#define XK_function                      0x08f6  /* U+0192 LATIN SMALL LETTER F WITH HOOK */\n#define XK_leftarrow                     0x08fb  /* U+2190 LEFTWARDS ARROW */\n#define XK_uparrow                       0x08fc  /* U+2191 UPWARDS ARROW */\n#define XK_rightarrow                    0x08fd  /* U+2192 RIGHTWARDS ARROW */\n#define XK_downarrow                     0x08fe  /* U+2193 DOWNWARDS ARROW */\n#endif /* XK_TECHNICAL */\n\n/*\n * Special\n * (from the DEC VT100 Special Graphics Character Set)\n * Byte 3 = 9\n */\n\n#ifdef XK_SPECIAL\n#define XK_blank                         0x09df\n#define XK_soliddiamond                  0x09e0  /* U+25C6 BLACK DIAMOND */\n#define XK_checkerboard                  0x09e1  /* U+2592 MEDIUM SHADE */\n#define XK_ht                            0x09e2  /* U+2409 SYMBOL FOR HORIZONTAL TABULATION */\n#define XK_ff                            0x09e3  /* U+240C SYMBOL FOR FORM FEED */\n#define XK_cr                            0x09e4  /* U+240D SYMBOL FOR CARRIAGE RETURN */\n#define XK_lf                            0x09e5  /* U+240A SYMBOL FOR LINE FEED */\n#define XK_nl                            0x09e8  /* U+2424 SYMBOL FOR NEWLINE */\n#define XK_vt                            0x09e9  /* U+240B SYMBOL FOR VERTICAL TABULATION */\n#define XK_lowrightcorner                0x09ea  /* U+2518 BOX DRAWINGS LIGHT UP AND LEFT */\n#define XK_uprightcorner                 0x09eb  /* U+2510 BOX DRAWINGS LIGHT DOWN AND LEFT */\n#define XK_upleftcorner                  0x09ec  /* U+250C BOX DRAWINGS LIGHT DOWN AND RIGHT */\n#define XK_lowleftcorner                 0x09ed  /* U+2514 BOX DRAWINGS LIGHT UP AND RIGHT */\n#define XK_crossinglines                 0x09ee  /* U+253C BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL */\n#define XK_horizlinescan1                0x09ef  /* U+23BA HORIZONTAL SCAN LINE-1 */\n#define XK_horizlinescan3                0x09f0  /* U+23BB HORIZONTAL SCAN LINE-3 */\n#define XK_horizlinescan5                0x09f1  /* U+2500 BOX DRAWINGS LIGHT HORIZONTAL */\n#define XK_horizlinescan7                0x09f2  /* U+23BC HORIZONTAL SCAN LINE-7 */\n#define XK_horizlinescan9                0x09f3  /* U+23BD HORIZONTAL SCAN LINE-9 */\n#define XK_leftt                         0x09f4  /* U+251C BOX DRAWINGS LIGHT VERTICAL AND RIGHT */\n#define XK_rightt                        0x09f5  /* U+2524 BOX DRAWINGS LIGHT VERTICAL AND LEFT */\n#define XK_bott                          0x09f6  /* U+2534 BOX DRAWINGS LIGHT UP AND HORIZONTAL */\n#define XK_topt                          0x09f7  /* U+252C BOX DRAWINGS LIGHT DOWN AND HORIZONTAL */\n#define XK_vertbar                       0x09f8  /* U+2502 BOX DRAWINGS LIGHT VERTICAL */\n#endif /* XK_SPECIAL */\n\n/*\n * Publishing\n * (these are probably from a long forgotten DEC Publishing\n * font that once shipped with DECwrite)\n * Byte 3 = 0x0a\n */\n\n#ifdef XK_PUBLISHING\n#define XK_emspace                       0x0aa1  /* U+2003 EM SPACE */\n#define XK_enspace                       0x0aa2  /* U+2002 EN SPACE */\n#define XK_em3space                      0x0aa3  /* U+2004 THREE-PER-EM SPACE */\n#define XK_em4space                      0x0aa4  /* U+2005 FOUR-PER-EM SPACE */\n#define XK_digitspace                    0x0aa5  /* U+2007 FIGURE SPACE */\n#define XK_punctspace                    0x0aa6  /* U+2008 PUNCTUATION SPACE */\n#define XK_thinspace                     0x0aa7  /* U+2009 THIN SPACE */\n#define XK_hairspace                     0x0aa8  /* U+200A HAIR SPACE */\n#define XK_emdash                        0x0aa9  /* U+2014 EM DASH */\n#define XK_endash                        0x0aaa  /* U+2013 EN DASH */\n#define XK_signifblank                   0x0aac  /*(U+2423 OPEN BOX)*/\n#define XK_ellipsis                      0x0aae  /* U+2026 HORIZONTAL ELLIPSIS */\n#define XK_doubbaselinedot               0x0aaf  /* U+2025 TWO DOT LEADER */\n#define XK_onethird                      0x0ab0  /* U+2153 VULGAR FRACTION ONE THIRD */\n#define XK_twothirds                     0x0ab1  /* U+2154 VULGAR FRACTION TWO THIRDS */\n#define XK_onefifth                      0x0ab2  /* U+2155 VULGAR FRACTION ONE FIFTH */\n#define XK_twofifths                     0x0ab3  /* U+2156 VULGAR FRACTION TWO FIFTHS */\n#define XK_threefifths                   0x0ab4  /* U+2157 VULGAR FRACTION THREE FIFTHS */\n#define XK_fourfifths                    0x0ab5  /* U+2158 VULGAR FRACTION FOUR FIFTHS */\n#define XK_onesixth                      0x0ab6  /* U+2159 VULGAR FRACTION ONE SIXTH */\n#define XK_fivesixths                    0x0ab7  /* U+215A VULGAR FRACTION FIVE SIXTHS */\n#define XK_careof                        0x0ab8  /* U+2105 CARE OF */\n#define XK_figdash                       0x0abb  /* U+2012 FIGURE DASH */\n#define XK_leftanglebracket              0x0abc  /*(U+27E8 MATHEMATICAL LEFT ANGLE BRACKET)*/\n#define XK_decimalpoint                  0x0abd  /*(U+002E FULL STOP)*/\n#define XK_rightanglebracket             0x0abe  /*(U+27E9 MATHEMATICAL RIGHT ANGLE BRACKET)*/\n#define XK_marker                        0x0abf\n#define XK_oneeighth                     0x0ac3  /* U+215B VULGAR FRACTION ONE EIGHTH */\n#define XK_threeeighths                  0x0ac4  /* U+215C VULGAR FRACTION THREE EIGHTHS */\n#define XK_fiveeighths                   0x0ac5  /* U+215D VULGAR FRACTION FIVE EIGHTHS */\n#define XK_seveneighths                  0x0ac6  /* U+215E VULGAR FRACTION SEVEN EIGHTHS */\n#define XK_trademark                     0x0ac9  /* U+2122 TRADE MARK SIGN */\n#define XK_signaturemark                 0x0aca  /*(U+2613 SALTIRE)*/\n#define XK_trademarkincircle             0x0acb\n#define XK_leftopentriangle              0x0acc  /*(U+25C1 WHITE LEFT-POINTING TRIANGLE)*/\n#define XK_rightopentriangle             0x0acd  /*(U+25B7 WHITE RIGHT-POINTING TRIANGLE)*/\n#define XK_emopencircle                  0x0ace  /*(U+25CB WHITE CIRCLE)*/\n#define XK_emopenrectangle               0x0acf  /*(U+25AF WHITE VERTICAL RECTANGLE)*/\n#define XK_leftsinglequotemark           0x0ad0  /* U+2018 LEFT SINGLE QUOTATION MARK */\n#define XK_rightsinglequotemark          0x0ad1  /* U+2019 RIGHT SINGLE QUOTATION MARK */\n#define XK_leftdoublequotemark           0x0ad2  /* U+201C LEFT DOUBLE QUOTATION MARK */\n#define XK_rightdoublequotemark          0x0ad3  /* U+201D RIGHT DOUBLE QUOTATION MARK */\n#define XK_prescription                  0x0ad4  /* U+211E PRESCRIPTION TAKE */\n#define XK_permille                      0x0ad5  /* U+2030 PER MILLE SIGN */\n#define XK_minutes                       0x0ad6  /* U+2032 PRIME */\n#define XK_seconds                       0x0ad7  /* U+2033 DOUBLE PRIME */\n#define XK_latincross                    0x0ad9  /* U+271D LATIN CROSS */\n#define XK_hexagram                      0x0ada\n#define XK_filledrectbullet              0x0adb  /*(U+25AC BLACK RECTANGLE)*/\n#define XK_filledlefttribullet           0x0adc  /*(U+25C0 BLACK LEFT-POINTING TRIANGLE)*/\n#define XK_filledrighttribullet          0x0add  /*(U+25B6 BLACK RIGHT-POINTING TRIANGLE)*/\n#define XK_emfilledcircle                0x0ade  /*(U+25CF BLACK CIRCLE)*/\n#define XK_emfilledrect                  0x0adf  /*(U+25AE BLACK VERTICAL RECTANGLE)*/\n#define XK_enopencircbullet              0x0ae0  /*(U+25E6 WHITE BULLET)*/\n#define XK_enopensquarebullet            0x0ae1  /*(U+25AB WHITE SMALL SQUARE)*/\n#define XK_openrectbullet                0x0ae2  /*(U+25AD WHITE RECTANGLE)*/\n#define XK_opentribulletup               0x0ae3  /*(U+25B3 WHITE UP-POINTING TRIANGLE)*/\n#define XK_opentribulletdown             0x0ae4  /*(U+25BD WHITE DOWN-POINTING TRIANGLE)*/\n#define XK_openstar                      0x0ae5  /*(U+2606 WHITE STAR)*/\n#define XK_enfilledcircbullet            0x0ae6  /*(U+2022 BULLET)*/\n#define XK_enfilledsqbullet              0x0ae7  /*(U+25AA BLACK SMALL SQUARE)*/\n#define XK_filledtribulletup             0x0ae8  /*(U+25B2 BLACK UP-POINTING TRIANGLE)*/\n#define XK_filledtribulletdown           0x0ae9  /*(U+25BC BLACK DOWN-POINTING TRIANGLE)*/\n#define XK_leftpointer                   0x0aea  /*(U+261C WHITE LEFT POINTING INDEX)*/\n#define XK_rightpointer                  0x0aeb  /*(U+261E WHITE RIGHT POINTING INDEX)*/\n#define XK_club                          0x0aec  /* U+2663 BLACK CLUB SUIT */\n#define XK_diamond                       0x0aed  /* U+2666 BLACK DIAMOND SUIT */\n#define XK_heart                         0x0aee  /* U+2665 BLACK HEART SUIT */\n#define XK_maltesecross                  0x0af0  /* U+2720 MALTESE CROSS */\n#define XK_dagger                        0x0af1  /* U+2020 DAGGER */\n#define XK_doubledagger                  0x0af2  /* U+2021 DOUBLE DAGGER */\n#define XK_checkmark                     0x0af3  /* U+2713 CHECK MARK */\n#define XK_ballotcross                   0x0af4  /* U+2717 BALLOT X */\n#define XK_musicalsharp                  0x0af5  /* U+266F MUSIC SHARP SIGN */\n#define XK_musicalflat                   0x0af6  /* U+266D MUSIC FLAT SIGN */\n#define XK_malesymbol                    0x0af7  /* U+2642 MALE SIGN */\n#define XK_femalesymbol                  0x0af8  /* U+2640 FEMALE SIGN */\n#define XK_telephone                     0x0af9  /* U+260E BLACK TELEPHONE */\n#define XK_telephonerecorder             0x0afa  /* U+2315 TELEPHONE RECORDER */\n#define XK_phonographcopyright           0x0afb  /* U+2117 SOUND RECORDING COPYRIGHT */\n#define XK_caret                         0x0afc  /* U+2038 CARET */\n#define XK_singlelowquotemark            0x0afd  /* U+201A SINGLE LOW-9 QUOTATION MARK */\n#define XK_doublelowquotemark            0x0afe  /* U+201E DOUBLE LOW-9 QUOTATION MARK */\n#define XK_cursor                        0x0aff\n#endif /* XK_PUBLISHING */\n\n/*\n * APL\n * Byte 3 = 0x0b\n */\n\n#ifdef XK_APL\n#define XK_leftcaret                     0x0ba3  /*(U+003C LESS-THAN SIGN)*/\n#define XK_rightcaret                    0x0ba6  /*(U+003E GREATER-THAN SIGN)*/\n#define XK_downcaret                     0x0ba8  /*(U+2228 LOGICAL OR)*/\n#define XK_upcaret                       0x0ba9  /*(U+2227 LOGICAL AND)*/\n#define XK_overbar                       0x0bc0  /*(U+00AF MACRON)*/\n#define XK_downtack                      0x0bc2  /* U+22A4 DOWN TACK */\n#define XK_upshoe                        0x0bc3  /*(U+2229 INTERSECTION)*/\n#define XK_downstile                     0x0bc4  /* U+230A LEFT FLOOR */\n#define XK_underbar                      0x0bc6  /*(U+005F LOW LINE)*/\n#define XK_jot                           0x0bca  /* U+2218 RING OPERATOR */\n#define XK_quad                          0x0bcc  /* U+2395 APL FUNCTIONAL SYMBOL QUAD */\n#define XK_uptack                        0x0bce  /* U+22A5 UP TACK */\n#define XK_circle                        0x0bcf  /* U+25CB WHITE CIRCLE */\n#define XK_upstile                       0x0bd3  /* U+2308 LEFT CEILING */\n#define XK_downshoe                      0x0bd6  /*(U+222A UNION)*/\n#define XK_rightshoe                     0x0bd8  /*(U+2283 SUPERSET OF)*/\n#define XK_leftshoe                      0x0bda  /*(U+2282 SUBSET OF)*/\n#define XK_lefttack                      0x0bdc  /* U+22A3 LEFT TACK */\n#define XK_righttack                     0x0bfc  /* U+22A2 RIGHT TACK */\n#endif /* XK_APL */\n\n/*\n * Hebrew\n * Byte 3 = 0x0c\n */\n\n#ifdef XK_HEBREW\n#define XK_hebrew_doublelowline          0x0cdf  /* U+2017 DOUBLE LOW LINE */\n#define XK_hebrew_aleph                  0x0ce0  /* U+05D0 HEBREW LETTER ALEF */\n#define XK_hebrew_bet                    0x0ce1  /* U+05D1 HEBREW LETTER BET */\n#define XK_hebrew_beth                   0x0ce1  /* deprecated */\n#define XK_hebrew_gimel                  0x0ce2  /* U+05D2 HEBREW LETTER GIMEL */\n#define XK_hebrew_gimmel                 0x0ce2  /* deprecated */\n#define XK_hebrew_dalet                  0x0ce3  /* U+05D3 HEBREW LETTER DALET */\n#define XK_hebrew_daleth                 0x0ce3  /* deprecated */\n#define XK_hebrew_he                     0x0ce4  /* U+05D4 HEBREW LETTER HE */\n#define XK_hebrew_waw                    0x0ce5  /* U+05D5 HEBREW LETTER VAV */\n#define XK_hebrew_zain                   0x0ce6  /* U+05D6 HEBREW LETTER ZAYIN */\n#define XK_hebrew_zayin                  0x0ce6  /* deprecated */\n#define XK_hebrew_chet                   0x0ce7  /* U+05D7 HEBREW LETTER HET */\n#define XK_hebrew_het                    0x0ce7  /* deprecated */\n#define XK_hebrew_tet                    0x0ce8  /* U+05D8 HEBREW LETTER TET */\n#define XK_hebrew_teth                   0x0ce8  /* deprecated */\n#define XK_hebrew_yod                    0x0ce9  /* U+05D9 HEBREW LETTER YOD */\n#define XK_hebrew_finalkaph              0x0cea  /* U+05DA HEBREW LETTER FINAL KAF */\n#define XK_hebrew_kaph                   0x0ceb  /* U+05DB HEBREW LETTER KAF */\n#define XK_hebrew_lamed                  0x0cec  /* U+05DC HEBREW LETTER LAMED */\n#define XK_hebrew_finalmem               0x0ced  /* U+05DD HEBREW LETTER FINAL MEM */\n#define XK_hebrew_mem                    0x0cee  /* U+05DE HEBREW LETTER MEM */\n#define XK_hebrew_finalnun               0x0cef  /* U+05DF HEBREW LETTER FINAL NUN */\n#define XK_hebrew_nun                    0x0cf0  /* U+05E0 HEBREW LETTER NUN */\n#define XK_hebrew_samech                 0x0cf1  /* U+05E1 HEBREW LETTER SAMEKH */\n#define XK_hebrew_samekh                 0x0cf1  /* deprecated */\n#define XK_hebrew_ayin                   0x0cf2  /* U+05E2 HEBREW LETTER AYIN */\n#define XK_hebrew_finalpe                0x0cf3  /* U+05E3 HEBREW LETTER FINAL PE */\n#define XK_hebrew_pe                     0x0cf4  /* U+05E4 HEBREW LETTER PE */\n#define XK_hebrew_finalzade              0x0cf5  /* U+05E5 HEBREW LETTER FINAL TSADI */\n#define XK_hebrew_finalzadi              0x0cf5  /* deprecated */\n#define XK_hebrew_zade                   0x0cf6  /* U+05E6 HEBREW LETTER TSADI */\n#define XK_hebrew_zadi                   0x0cf6  /* deprecated */\n#define XK_hebrew_qoph                   0x0cf7  /* U+05E7 HEBREW LETTER QOF */\n#define XK_hebrew_kuf                    0x0cf7  /* deprecated */\n#define XK_hebrew_resh                   0x0cf8  /* U+05E8 HEBREW LETTER RESH */\n#define XK_hebrew_shin                   0x0cf9  /* U+05E9 HEBREW LETTER SHIN */\n#define XK_hebrew_taw                    0x0cfa  /* U+05EA HEBREW LETTER TAV */\n#define XK_hebrew_taf                    0x0cfa  /* deprecated */\n#define XK_Hebrew_switch                 0xff7e  /* Alias for mode_switch */\n#endif /* XK_HEBREW */\n\n/*\n * Thai\n * Byte 3 = 0x0d\n */\n\n#ifdef XK_THAI\n#define XK_Thai_kokai                    0x0da1  /* U+0E01 THAI CHARACTER KO KAI */\n#define XK_Thai_khokhai                  0x0da2  /* U+0E02 THAI CHARACTER KHO KHAI */\n#define XK_Thai_khokhuat                 0x0da3  /* U+0E03 THAI CHARACTER KHO KHUAT */\n#define XK_Thai_khokhwai                 0x0da4  /* U+0E04 THAI CHARACTER KHO KHWAI */\n#define XK_Thai_khokhon                  0x0da5  /* U+0E05 THAI CHARACTER KHO KHON */\n#define XK_Thai_khorakhang               0x0da6  /* U+0E06 THAI CHARACTER KHO RAKHANG */\n#define XK_Thai_ngongu                   0x0da7  /* U+0E07 THAI CHARACTER NGO NGU */\n#define XK_Thai_chochan                  0x0da8  /* U+0E08 THAI CHARACTER CHO CHAN */\n#define XK_Thai_choching                 0x0da9  /* U+0E09 THAI CHARACTER CHO CHING */\n#define XK_Thai_chochang                 0x0daa  /* U+0E0A THAI CHARACTER CHO CHANG */\n#define XK_Thai_soso                     0x0dab  /* U+0E0B THAI CHARACTER SO SO */\n#define XK_Thai_chochoe                  0x0dac  /* U+0E0C THAI CHARACTER CHO CHOE */\n#define XK_Thai_yoying                   0x0dad  /* U+0E0D THAI CHARACTER YO YING */\n#define XK_Thai_dochada                  0x0dae  /* U+0E0E THAI CHARACTER DO CHADA */\n#define XK_Thai_topatak                  0x0daf  /* U+0E0F THAI CHARACTER TO PATAK */\n#define XK_Thai_thothan                  0x0db0  /* U+0E10 THAI CHARACTER THO THAN */\n#define XK_Thai_thonangmontho            0x0db1  /* U+0E11 THAI CHARACTER THO NANGMONTHO */\n#define XK_Thai_thophuthao               0x0db2  /* U+0E12 THAI CHARACTER THO PHUTHAO */\n#define XK_Thai_nonen                    0x0db3  /* U+0E13 THAI CHARACTER NO NEN */\n#define XK_Thai_dodek                    0x0db4  /* U+0E14 THAI CHARACTER DO DEK */\n#define XK_Thai_totao                    0x0db5  /* U+0E15 THAI CHARACTER TO TAO */\n#define XK_Thai_thothung                 0x0db6  /* U+0E16 THAI CHARACTER THO THUNG */\n#define XK_Thai_thothahan                0x0db7  /* U+0E17 THAI CHARACTER THO THAHAN */\n#define XK_Thai_thothong                 0x0db8  /* U+0E18 THAI CHARACTER THO THONG */\n#define XK_Thai_nonu                     0x0db9  /* U+0E19 THAI CHARACTER NO NU */\n#define XK_Thai_bobaimai                 0x0dba  /* U+0E1A THAI CHARACTER BO BAIMAI */\n#define XK_Thai_popla                    0x0dbb  /* U+0E1B THAI CHARACTER PO PLA */\n#define XK_Thai_phophung                 0x0dbc  /* U+0E1C THAI CHARACTER PHO PHUNG */\n#define XK_Thai_fofa                     0x0dbd  /* U+0E1D THAI CHARACTER FO FA */\n#define XK_Thai_phophan                  0x0dbe  /* U+0E1E THAI CHARACTER PHO PHAN */\n#define XK_Thai_fofan                    0x0dbf  /* U+0E1F THAI CHARACTER FO FAN */\n#define XK_Thai_phosamphao               0x0dc0  /* U+0E20 THAI CHARACTER PHO SAMPHAO */\n#define XK_Thai_moma                     0x0dc1  /* U+0E21 THAI CHARACTER MO MA */\n#define XK_Thai_yoyak                    0x0dc2  /* U+0E22 THAI CHARACTER YO YAK */\n#define XK_Thai_rorua                    0x0dc3  /* U+0E23 THAI CHARACTER RO RUA */\n#define XK_Thai_ru                       0x0dc4  /* U+0E24 THAI CHARACTER RU */\n#define XK_Thai_loling                   0x0dc5  /* U+0E25 THAI CHARACTER LO LING */\n#define XK_Thai_lu                       0x0dc6  /* U+0E26 THAI CHARACTER LU */\n#define XK_Thai_wowaen                   0x0dc7  /* U+0E27 THAI CHARACTER WO WAEN */\n#define XK_Thai_sosala                   0x0dc8  /* U+0E28 THAI CHARACTER SO SALA */\n#define XK_Thai_sorusi                   0x0dc9  /* U+0E29 THAI CHARACTER SO RUSI */\n#define XK_Thai_sosua                    0x0dca  /* U+0E2A THAI CHARACTER SO SUA */\n#define XK_Thai_hohip                    0x0dcb  /* U+0E2B THAI CHARACTER HO HIP */\n#define XK_Thai_lochula                  0x0dcc  /* U+0E2C THAI CHARACTER LO CHULA */\n#define XK_Thai_oang                     0x0dcd  /* U+0E2D THAI CHARACTER O ANG */\n#define XK_Thai_honokhuk                 0x0dce  /* U+0E2E THAI CHARACTER HO NOKHUK */\n#define XK_Thai_paiyannoi                0x0dcf  /* U+0E2F THAI CHARACTER PAIYANNOI */\n#define XK_Thai_saraa                    0x0dd0  /* U+0E30 THAI CHARACTER SARA A */\n#define XK_Thai_maihanakat               0x0dd1  /* U+0E31 THAI CHARACTER MAI HAN-AKAT */\n#define XK_Thai_saraaa                   0x0dd2  /* U+0E32 THAI CHARACTER SARA AA */\n#define XK_Thai_saraam                   0x0dd3  /* U+0E33 THAI CHARACTER SARA AM */\n#define XK_Thai_sarai                    0x0dd4  /* U+0E34 THAI CHARACTER SARA I */\n#define XK_Thai_saraii                   0x0dd5  /* U+0E35 THAI CHARACTER SARA II */\n#define XK_Thai_saraue                   0x0dd6  /* U+0E36 THAI CHARACTER SARA UE */\n#define XK_Thai_sarauee                  0x0dd7  /* U+0E37 THAI CHARACTER SARA UEE */\n#define XK_Thai_sarau                    0x0dd8  /* U+0E38 THAI CHARACTER SARA U */\n#define XK_Thai_sarauu                   0x0dd9  /* U+0E39 THAI CHARACTER SARA UU */\n#define XK_Thai_phinthu                  0x0dda  /* U+0E3A THAI CHARACTER PHINTHU */\n#define XK_Thai_maihanakat_maitho        0x0dde\n#define XK_Thai_baht                     0x0ddf  /* U+0E3F THAI CURRENCY SYMBOL BAHT */\n#define XK_Thai_sarae                    0x0de0  /* U+0E40 THAI CHARACTER SARA E */\n#define XK_Thai_saraae                   0x0de1  /* U+0E41 THAI CHARACTER SARA AE */\n#define XK_Thai_sarao                    0x0de2  /* U+0E42 THAI CHARACTER SARA O */\n#define XK_Thai_saraaimaimuan            0x0de3  /* U+0E43 THAI CHARACTER SARA AI MAIMUAN */\n#define XK_Thai_saraaimaimalai           0x0de4  /* U+0E44 THAI CHARACTER SARA AI MAIMALAI */\n#define XK_Thai_lakkhangyao              0x0de5  /* U+0E45 THAI CHARACTER LAKKHANGYAO */\n#define XK_Thai_maiyamok                 0x0de6  /* U+0E46 THAI CHARACTER MAIYAMOK */\n#define XK_Thai_maitaikhu                0x0de7  /* U+0E47 THAI CHARACTER MAITAIKHU */\n#define XK_Thai_maiek                    0x0de8  /* U+0E48 THAI CHARACTER MAI EK */\n#define XK_Thai_maitho                   0x0de9  /* U+0E49 THAI CHARACTER MAI THO */\n#define XK_Thai_maitri                   0x0dea  /* U+0E4A THAI CHARACTER MAI TRI */\n#define XK_Thai_maichattawa              0x0deb  /* U+0E4B THAI CHARACTER MAI CHATTAWA */\n#define XK_Thai_thanthakhat              0x0dec  /* U+0E4C THAI CHARACTER THANTHAKHAT */\n#define XK_Thai_nikhahit                 0x0ded  /* U+0E4D THAI CHARACTER NIKHAHIT */\n#define XK_Thai_leksun                   0x0df0  /* U+0E50 THAI DIGIT ZERO */\n#define XK_Thai_leknung                  0x0df1  /* U+0E51 THAI DIGIT ONE */\n#define XK_Thai_leksong                  0x0df2  /* U+0E52 THAI DIGIT TWO */\n#define XK_Thai_leksam                   0x0df3  /* U+0E53 THAI DIGIT THREE */\n#define XK_Thai_leksi                    0x0df4  /* U+0E54 THAI DIGIT FOUR */\n#define XK_Thai_lekha                    0x0df5  /* U+0E55 THAI DIGIT FIVE */\n#define XK_Thai_lekhok                   0x0df6  /* U+0E56 THAI DIGIT SIX */\n#define XK_Thai_lekchet                  0x0df7  /* U+0E57 THAI DIGIT SEVEN */\n#define XK_Thai_lekpaet                  0x0df8  /* U+0E58 THAI DIGIT EIGHT */\n#define XK_Thai_lekkao                   0x0df9  /* U+0E59 THAI DIGIT NINE */\n#endif /* XK_THAI */\n\n/*\n * Korean\n * Byte 3 = 0x0e\n */\n\n#ifdef XK_KOREAN\n\n#define XK_Hangul                        0xff31  /* Hangul start/stop(toggle) */\n#define XK_Hangul_Start                  0xff32  /* Hangul start */\n#define XK_Hangul_End                    0xff33  /* Hangul end, English start */\n#define XK_Hangul_Hanja                  0xff34  /* Start Hangul->Hanja Conversion */\n#define XK_Hangul_Jamo                   0xff35  /* Hangul Jamo mode */\n#define XK_Hangul_Romaja                 0xff36  /* Hangul Romaja mode */\n#define XK_Hangul_Codeinput              0xff37  /* Hangul code input mode */\n#define XK_Hangul_Jeonja                 0xff38  /* Jeonja mode */\n#define XK_Hangul_Banja                  0xff39  /* Banja mode */\n#define XK_Hangul_PreHanja               0xff3a  /* Pre Hanja conversion */\n#define XK_Hangul_PostHanja              0xff3b  /* Post Hanja conversion */\n#define XK_Hangul_SingleCandidate        0xff3c  /* Single candidate */\n#define XK_Hangul_MultipleCandidate      0xff3d  /* Multiple candidate */\n#define XK_Hangul_PreviousCandidate      0xff3e  /* Previous candidate */\n#define XK_Hangul_Special                0xff3f  /* Special symbols */\n#define XK_Hangul_switch                 0xff7e  /* Alias for mode_switch */\n\n/* Hangul Consonant Characters */\n#define XK_Hangul_Kiyeog                 0x0ea1\n#define XK_Hangul_SsangKiyeog            0x0ea2\n#define XK_Hangul_KiyeogSios             0x0ea3\n#define XK_Hangul_Nieun                  0x0ea4\n#define XK_Hangul_NieunJieuj             0x0ea5\n#define XK_Hangul_NieunHieuh             0x0ea6\n#define XK_Hangul_Dikeud                 0x0ea7\n#define XK_Hangul_SsangDikeud            0x0ea8\n#define XK_Hangul_Rieul                  0x0ea9\n#define XK_Hangul_RieulKiyeog            0x0eaa\n#define XK_Hangul_RieulMieum             0x0eab\n#define XK_Hangul_RieulPieub             0x0eac\n#define XK_Hangul_RieulSios              0x0ead\n#define XK_Hangul_RieulTieut             0x0eae\n#define XK_Hangul_RieulPhieuf            0x0eaf\n#define XK_Hangul_RieulHieuh             0x0eb0\n#define XK_Hangul_Mieum                  0x0eb1\n#define XK_Hangul_Pieub                  0x0eb2\n#define XK_Hangul_SsangPieub             0x0eb3\n#define XK_Hangul_PieubSios              0x0eb4\n#define XK_Hangul_Sios                   0x0eb5\n#define XK_Hangul_SsangSios              0x0eb6\n#define XK_Hangul_Ieung                  0x0eb7\n#define XK_Hangul_Jieuj                  0x0eb8\n#define XK_Hangul_SsangJieuj             0x0eb9\n#define XK_Hangul_Cieuc                  0x0eba\n#define XK_Hangul_Khieuq                 0x0ebb\n#define XK_Hangul_Tieut                  0x0ebc\n#define XK_Hangul_Phieuf                 0x0ebd\n#define XK_Hangul_Hieuh                  0x0ebe\n\n/* Hangul Vowel Characters */\n#define XK_Hangul_A                      0x0ebf\n#define XK_Hangul_AE                     0x0ec0\n#define XK_Hangul_YA                     0x0ec1\n#define XK_Hangul_YAE                    0x0ec2\n#define XK_Hangul_EO                     0x0ec3\n#define XK_Hangul_E                      0x0ec4\n#define XK_Hangul_YEO                    0x0ec5\n#define XK_Hangul_YE                     0x0ec6\n#define XK_Hangul_O                      0x0ec7\n#define XK_Hangul_WA                     0x0ec8\n#define XK_Hangul_WAE                    0x0ec9\n#define XK_Hangul_OE                     0x0eca\n#define XK_Hangul_YO                     0x0ecb\n#define XK_Hangul_U                      0x0ecc\n#define XK_Hangul_WEO                    0x0ecd\n#define XK_Hangul_WE                     0x0ece\n#define XK_Hangul_WI                     0x0ecf\n#define XK_Hangul_YU                     0x0ed0\n#define XK_Hangul_EU                     0x0ed1\n#define XK_Hangul_YI                     0x0ed2\n#define XK_Hangul_I                      0x0ed3\n\n/* Hangul syllable-final (JongSeong) Characters */\n#define XK_Hangul_J_Kiyeog               0x0ed4\n#define XK_Hangul_J_SsangKiyeog          0x0ed5\n#define XK_Hangul_J_KiyeogSios           0x0ed6\n#define XK_Hangul_J_Nieun                0x0ed7\n#define XK_Hangul_J_NieunJieuj           0x0ed8\n#define XK_Hangul_J_NieunHieuh           0x0ed9\n#define XK_Hangul_J_Dikeud               0x0eda\n#define XK_Hangul_J_Rieul                0x0edb\n#define XK_Hangul_J_RieulKiyeog          0x0edc\n#define XK_Hangul_J_RieulMieum           0x0edd\n#define XK_Hangul_J_RieulPieub           0x0ede\n#define XK_Hangul_J_RieulSios            0x0edf\n#define XK_Hangul_J_RieulTieut           0x0ee0\n#define XK_Hangul_J_RieulPhieuf          0x0ee1\n#define XK_Hangul_J_RieulHieuh           0x0ee2\n#define XK_Hangul_J_Mieum                0x0ee3\n#define XK_Hangul_J_Pieub                0x0ee4\n#define XK_Hangul_J_PieubSios            0x0ee5\n#define XK_Hangul_J_Sios                 0x0ee6\n#define XK_Hangul_J_SsangSios            0x0ee7\n#define XK_Hangul_J_Ieung                0x0ee8\n#define XK_Hangul_J_Jieuj                0x0ee9\n#define XK_Hangul_J_Cieuc                0x0eea\n#define XK_Hangul_J_Khieuq               0x0eeb\n#define XK_Hangul_J_Tieut                0x0eec\n#define XK_Hangul_J_Phieuf               0x0eed\n#define XK_Hangul_J_Hieuh                0x0eee\n\n/* Ancient Hangul Consonant Characters */\n#define XK_Hangul_RieulYeorinHieuh       0x0eef\n#define XK_Hangul_SunkyeongeumMieum      0x0ef0\n#define XK_Hangul_SunkyeongeumPieub      0x0ef1\n#define XK_Hangul_PanSios                0x0ef2\n#define XK_Hangul_KkogjiDalrinIeung      0x0ef3\n#define XK_Hangul_SunkyeongeumPhieuf     0x0ef4\n#define XK_Hangul_YeorinHieuh            0x0ef5\n\n/* Ancient Hangul Vowel Characters */\n#define XK_Hangul_AraeA                  0x0ef6\n#define XK_Hangul_AraeAE                 0x0ef7\n\n/* Ancient Hangul syllable-final (JongSeong) Characters */\n#define XK_Hangul_J_PanSios              0x0ef8\n#define XK_Hangul_J_KkogjiDalrinIeung    0x0ef9\n#define XK_Hangul_J_YeorinHieuh          0x0efa\n\n/* Korean currency symbol */\n#define XK_Korean_Won                    0x0eff  /*(U+20A9 WON SIGN)*/\n\n#endif /* XK_KOREAN */\n\n/*\n * Armenian\n */\n\n#ifdef XK_ARMENIAN\n#define XK_Armenian_ligature_ew       0x1000587  /* U+0587 ARMENIAN SMALL LIGATURE ECH YIWN */\n#define XK_Armenian_full_stop         0x1000589  /* U+0589 ARMENIAN FULL STOP */\n#define XK_Armenian_verjaket          0x1000589  /* U+0589 ARMENIAN FULL STOP */\n#define XK_Armenian_separation_mark   0x100055d  /* U+055D ARMENIAN COMMA */\n#define XK_Armenian_but               0x100055d  /* U+055D ARMENIAN COMMA */\n#define XK_Armenian_hyphen            0x100058a  /* U+058A ARMENIAN HYPHEN */\n#define XK_Armenian_yentamna          0x100058a  /* U+058A ARMENIAN HYPHEN */\n#define XK_Armenian_exclam            0x100055c  /* U+055C ARMENIAN EXCLAMATION MARK */\n#define XK_Armenian_amanak            0x100055c  /* U+055C ARMENIAN EXCLAMATION MARK */\n#define XK_Armenian_accent            0x100055b  /* U+055B ARMENIAN EMPHASIS MARK */\n#define XK_Armenian_shesht            0x100055b  /* U+055B ARMENIAN EMPHASIS MARK */\n#define XK_Armenian_question          0x100055e  /* U+055E ARMENIAN QUESTION MARK */\n#define XK_Armenian_paruyk            0x100055e  /* U+055E ARMENIAN QUESTION MARK */\n#define XK_Armenian_AYB               0x1000531  /* U+0531 ARMENIAN CAPITAL LETTER AYB */\n#define XK_Armenian_ayb               0x1000561  /* U+0561 ARMENIAN SMALL LETTER AYB */\n#define XK_Armenian_BEN               0x1000532  /* U+0532 ARMENIAN CAPITAL LETTER BEN */\n#define XK_Armenian_ben               0x1000562  /* U+0562 ARMENIAN SMALL LETTER BEN */\n#define XK_Armenian_GIM               0x1000533  /* U+0533 ARMENIAN CAPITAL LETTER GIM */\n#define XK_Armenian_gim               0x1000563  /* U+0563 ARMENIAN SMALL LETTER GIM */\n#define XK_Armenian_DA                0x1000534  /* U+0534 ARMENIAN CAPITAL LETTER DA */\n#define XK_Armenian_da                0x1000564  /* U+0564 ARMENIAN SMALL LETTER DA */\n#define XK_Armenian_YECH              0x1000535  /* U+0535 ARMENIAN CAPITAL LETTER ECH */\n#define XK_Armenian_yech              0x1000565  /* U+0565 ARMENIAN SMALL LETTER ECH */\n#define XK_Armenian_ZA                0x1000536  /* U+0536 ARMENIAN CAPITAL LETTER ZA */\n#define XK_Armenian_za                0x1000566  /* U+0566 ARMENIAN SMALL LETTER ZA */\n#define XK_Armenian_E                 0x1000537  /* U+0537 ARMENIAN CAPITAL LETTER EH */\n#define XK_Armenian_e                 0x1000567  /* U+0567 ARMENIAN SMALL LETTER EH */\n#define XK_Armenian_AT                0x1000538  /* U+0538 ARMENIAN CAPITAL LETTER ET */\n#define XK_Armenian_at                0x1000568  /* U+0568 ARMENIAN SMALL LETTER ET */\n#define XK_Armenian_TO                0x1000539  /* U+0539 ARMENIAN CAPITAL LETTER TO */\n#define XK_Armenian_to                0x1000569  /* U+0569 ARMENIAN SMALL LETTER TO */\n#define XK_Armenian_ZHE               0x100053a  /* U+053A ARMENIAN CAPITAL LETTER ZHE */\n#define XK_Armenian_zhe               0x100056a  /* U+056A ARMENIAN SMALL LETTER ZHE */\n#define XK_Armenian_INI               0x100053b  /* U+053B ARMENIAN CAPITAL LETTER INI */\n#define XK_Armenian_ini               0x100056b  /* U+056B ARMENIAN SMALL LETTER INI */\n#define XK_Armenian_LYUN              0x100053c  /* U+053C ARMENIAN CAPITAL LETTER LIWN */\n#define XK_Armenian_lyun              0x100056c  /* U+056C ARMENIAN SMALL LETTER LIWN */\n#define XK_Armenian_KHE               0x100053d  /* U+053D ARMENIAN CAPITAL LETTER XEH */\n#define XK_Armenian_khe               0x100056d  /* U+056D ARMENIAN SMALL LETTER XEH */\n#define XK_Armenian_TSA               0x100053e  /* U+053E ARMENIAN CAPITAL LETTER CA */\n#define XK_Armenian_tsa               0x100056e  /* U+056E ARMENIAN SMALL LETTER CA */\n#define XK_Armenian_KEN               0x100053f  /* U+053F ARMENIAN CAPITAL LETTER KEN */\n#define XK_Armenian_ken               0x100056f  /* U+056F ARMENIAN SMALL LETTER KEN */\n#define XK_Armenian_HO                0x1000540  /* U+0540 ARMENIAN CAPITAL LETTER HO */\n#define XK_Armenian_ho                0x1000570  /* U+0570 ARMENIAN SMALL LETTER HO */\n#define XK_Armenian_DZA               0x1000541  /* U+0541 ARMENIAN CAPITAL LETTER JA */\n#define XK_Armenian_dza               0x1000571  /* U+0571 ARMENIAN SMALL LETTER JA */\n#define XK_Armenian_GHAT              0x1000542  /* U+0542 ARMENIAN CAPITAL LETTER GHAD */\n#define XK_Armenian_ghat              0x1000572  /* U+0572 ARMENIAN SMALL LETTER GHAD */\n#define XK_Armenian_TCHE              0x1000543  /* U+0543 ARMENIAN CAPITAL LETTER CHEH */\n#define XK_Armenian_tche              0x1000573  /* U+0573 ARMENIAN SMALL LETTER CHEH */\n#define XK_Armenian_MEN               0x1000544  /* U+0544 ARMENIAN CAPITAL LETTER MEN */\n#define XK_Armenian_men               0x1000574  /* U+0574 ARMENIAN SMALL LETTER MEN */\n#define XK_Armenian_HI                0x1000545  /* U+0545 ARMENIAN CAPITAL LETTER YI */\n#define XK_Armenian_hi                0x1000575  /* U+0575 ARMENIAN SMALL LETTER YI */\n#define XK_Armenian_NU                0x1000546  /* U+0546 ARMENIAN CAPITAL LETTER NOW */\n#define XK_Armenian_nu                0x1000576  /* U+0576 ARMENIAN SMALL LETTER NOW */\n#define XK_Armenian_SHA               0x1000547  /* U+0547 ARMENIAN CAPITAL LETTER SHA */\n#define XK_Armenian_sha               0x1000577  /* U+0577 ARMENIAN SMALL LETTER SHA */\n#define XK_Armenian_VO                0x1000548  /* U+0548 ARMENIAN CAPITAL LETTER VO */\n#define XK_Armenian_vo                0x1000578  /* U+0578 ARMENIAN SMALL LETTER VO */\n#define XK_Armenian_CHA               0x1000549  /* U+0549 ARMENIAN CAPITAL LETTER CHA */\n#define XK_Armenian_cha               0x1000579  /* U+0579 ARMENIAN SMALL LETTER CHA */\n#define XK_Armenian_PE                0x100054a  /* U+054A ARMENIAN CAPITAL LETTER PEH */\n#define XK_Armenian_pe                0x100057a  /* U+057A ARMENIAN SMALL LETTER PEH */\n#define XK_Armenian_JE                0x100054b  /* U+054B ARMENIAN CAPITAL LETTER JHEH */\n#define XK_Armenian_je                0x100057b  /* U+057B ARMENIAN SMALL LETTER JHEH */\n#define XK_Armenian_RA                0x100054c  /* U+054C ARMENIAN CAPITAL LETTER RA */\n#define XK_Armenian_ra                0x100057c  /* U+057C ARMENIAN SMALL LETTER RA */\n#define XK_Armenian_SE                0x100054d  /* U+054D ARMENIAN CAPITAL LETTER SEH */\n#define XK_Armenian_se                0x100057d  /* U+057D ARMENIAN SMALL LETTER SEH */\n#define XK_Armenian_VEV               0x100054e  /* U+054E ARMENIAN CAPITAL LETTER VEW */\n#define XK_Armenian_vev               0x100057e  /* U+057E ARMENIAN SMALL LETTER VEW */\n#define XK_Armenian_TYUN              0x100054f  /* U+054F ARMENIAN CAPITAL LETTER TIWN */\n#define XK_Armenian_tyun              0x100057f  /* U+057F ARMENIAN SMALL LETTER TIWN */\n#define XK_Armenian_RE                0x1000550  /* U+0550 ARMENIAN CAPITAL LETTER REH */\n#define XK_Armenian_re                0x1000580  /* U+0580 ARMENIAN SMALL LETTER REH */\n#define XK_Armenian_TSO               0x1000551  /* U+0551 ARMENIAN CAPITAL LETTER CO */\n#define XK_Armenian_tso               0x1000581  /* U+0581 ARMENIAN SMALL LETTER CO */\n#define XK_Armenian_VYUN              0x1000552  /* U+0552 ARMENIAN CAPITAL LETTER YIWN */\n#define XK_Armenian_vyun              0x1000582  /* U+0582 ARMENIAN SMALL LETTER YIWN */\n#define XK_Armenian_PYUR              0x1000553  /* U+0553 ARMENIAN CAPITAL LETTER PIWR */\n#define XK_Armenian_pyur              0x1000583  /* U+0583 ARMENIAN SMALL LETTER PIWR */\n#define XK_Armenian_KE                0x1000554  /* U+0554 ARMENIAN CAPITAL LETTER KEH */\n#define XK_Armenian_ke                0x1000584  /* U+0584 ARMENIAN SMALL LETTER KEH */\n#define XK_Armenian_O                 0x1000555  /* U+0555 ARMENIAN CAPITAL LETTER OH */\n#define XK_Armenian_o                 0x1000585  /* U+0585 ARMENIAN SMALL LETTER OH */\n#define XK_Armenian_FE                0x1000556  /* U+0556 ARMENIAN CAPITAL LETTER FEH */\n#define XK_Armenian_fe                0x1000586  /* U+0586 ARMENIAN SMALL LETTER FEH */\n#define XK_Armenian_apostrophe        0x100055a  /* U+055A ARMENIAN APOSTROPHE */\n#endif /* XK_ARMENIAN */\n\n/*\n * Georgian\n */\n\n#ifdef XK_GEORGIAN\n#define XK_Georgian_an                0x10010d0  /* U+10D0 GEORGIAN LETTER AN */\n#define XK_Georgian_ban               0x10010d1  /* U+10D1 GEORGIAN LETTER BAN */\n#define XK_Georgian_gan               0x10010d2  /* U+10D2 GEORGIAN LETTER GAN */\n#define XK_Georgian_don               0x10010d3  /* U+10D3 GEORGIAN LETTER DON */\n#define XK_Georgian_en                0x10010d4  /* U+10D4 GEORGIAN LETTER EN */\n#define XK_Georgian_vin               0x10010d5  /* U+10D5 GEORGIAN LETTER VIN */\n#define XK_Georgian_zen               0x10010d6  /* U+10D6 GEORGIAN LETTER ZEN */\n#define XK_Georgian_tan               0x10010d7  /* U+10D7 GEORGIAN LETTER TAN */\n#define XK_Georgian_in                0x10010d8  /* U+10D8 GEORGIAN LETTER IN */\n#define XK_Georgian_kan               0x10010d9  /* U+10D9 GEORGIAN LETTER KAN */\n#define XK_Georgian_las               0x10010da  /* U+10DA GEORGIAN LETTER LAS */\n#define XK_Georgian_man               0x10010db  /* U+10DB GEORGIAN LETTER MAN */\n#define XK_Georgian_nar               0x10010dc  /* U+10DC GEORGIAN LETTER NAR */\n#define XK_Georgian_on                0x10010dd  /* U+10DD GEORGIAN LETTER ON */\n#define XK_Georgian_par               0x10010de  /* U+10DE GEORGIAN LETTER PAR */\n#define XK_Georgian_zhar              0x10010df  /* U+10DF GEORGIAN LETTER ZHAR */\n#define XK_Georgian_rae               0x10010e0  /* U+10E0 GEORGIAN LETTER RAE */\n#define XK_Georgian_san               0x10010e1  /* U+10E1 GEORGIAN LETTER SAN */\n#define XK_Georgian_tar               0x10010e2  /* U+10E2 GEORGIAN LETTER TAR */\n#define XK_Georgian_un                0x10010e3  /* U+10E3 GEORGIAN LETTER UN */\n#define XK_Georgian_phar              0x10010e4  /* U+10E4 GEORGIAN LETTER PHAR */\n#define XK_Georgian_khar              0x10010e5  /* U+10E5 GEORGIAN LETTER KHAR */\n#define XK_Georgian_ghan              0x10010e6  /* U+10E6 GEORGIAN LETTER GHAN */\n#define XK_Georgian_qar               0x10010e7  /* U+10E7 GEORGIAN LETTER QAR */\n#define XK_Georgian_shin              0x10010e8  /* U+10E8 GEORGIAN LETTER SHIN */\n#define XK_Georgian_chin              0x10010e9  /* U+10E9 GEORGIAN LETTER CHIN */\n#define XK_Georgian_can               0x10010ea  /* U+10EA GEORGIAN LETTER CAN */\n#define XK_Georgian_jil               0x10010eb  /* U+10EB GEORGIAN LETTER JIL */\n#define XK_Georgian_cil               0x10010ec  /* U+10EC GEORGIAN LETTER CIL */\n#define XK_Georgian_char              0x10010ed  /* U+10ED GEORGIAN LETTER CHAR */\n#define XK_Georgian_xan               0x10010ee  /* U+10EE GEORGIAN LETTER XAN */\n#define XK_Georgian_jhan              0x10010ef  /* U+10EF GEORGIAN LETTER JHAN */\n#define XK_Georgian_hae               0x10010f0  /* U+10F0 GEORGIAN LETTER HAE */\n#define XK_Georgian_he                0x10010f1  /* U+10F1 GEORGIAN LETTER HE */\n#define XK_Georgian_hie               0x10010f2  /* U+10F2 GEORGIAN LETTER HIE */\n#define XK_Georgian_we                0x10010f3  /* U+10F3 GEORGIAN LETTER WE */\n#define XK_Georgian_har               0x10010f4  /* U+10F4 GEORGIAN LETTER HAR */\n#define XK_Georgian_hoe               0x10010f5  /* U+10F5 GEORGIAN LETTER HOE */\n#define XK_Georgian_fi                0x10010f6  /* U+10F6 GEORGIAN LETTER FI */\n#endif /* XK_GEORGIAN */\n\n/*\n * Azeri (and other Turkic or Caucasian languages)\n */\n\n#ifdef XK_CAUCASUS\n/* latin */\n#define XK_Xabovedot                  0x1001e8a  /* U+1E8A LATIN CAPITAL LETTER X WITH DOT ABOVE */\n#define XK_Ibreve                     0x100012c  /* U+012C LATIN CAPITAL LETTER I WITH BREVE */\n#define XK_Zstroke                    0x10001b5  /* U+01B5 LATIN CAPITAL LETTER Z WITH STROKE */\n#define XK_Gcaron                     0x10001e6  /* U+01E6 LATIN CAPITAL LETTER G WITH CARON */\n#define XK_Ocaron                     0x10001d1  /* U+01D2 LATIN CAPITAL LETTER O WITH CARON */\n#define XK_Obarred                    0x100019f  /* U+019F LATIN CAPITAL LETTER O WITH MIDDLE TILDE */\n#define XK_xabovedot                  0x1001e8b  /* U+1E8B LATIN SMALL LETTER X WITH DOT ABOVE */\n#define XK_ibreve                     0x100012d  /* U+012D LATIN SMALL LETTER I WITH BREVE */\n#define XK_zstroke                    0x10001b6  /* U+01B6 LATIN SMALL LETTER Z WITH STROKE */\n#define XK_gcaron                     0x10001e7  /* U+01E7 LATIN SMALL LETTER G WITH CARON */\n#define XK_ocaron                     0x10001d2  /* U+01D2 LATIN SMALL LETTER O WITH CARON */\n#define XK_obarred                    0x1000275  /* U+0275 LATIN SMALL LETTER BARRED O */\n#define XK_SCHWA                      0x100018f  /* U+018F LATIN CAPITAL LETTER SCHWA */\n#define XK_schwa                      0x1000259  /* U+0259 LATIN SMALL LETTER SCHWA */\n#define XK_EZH                        0x10001b7  /* U+01B7 LATIN CAPITAL LETTER EZH */\n#define XK_ezh                        0x1000292  /* U+0292 LATIN SMALL LETTER EZH */\n/* those are not really Caucasus */\n/* For Inupiak */\n#define XK_Lbelowdot                  0x1001e36  /* U+1E36 LATIN CAPITAL LETTER L WITH DOT BELOW */\n#define XK_lbelowdot                  0x1001e37  /* U+1E37 LATIN SMALL LETTER L WITH DOT BELOW */\n#endif /* XK_CAUCASUS */\n\n/*\n * Vietnamese\n */\n \n#ifdef XK_VIETNAMESE\n#define XK_Abelowdot                  0x1001ea0  /* U+1EA0 LATIN CAPITAL LETTER A WITH DOT BELOW */\n#define XK_abelowdot                  0x1001ea1  /* U+1EA1 LATIN SMALL LETTER A WITH DOT BELOW */\n#define XK_Ahook                      0x1001ea2  /* U+1EA2 LATIN CAPITAL LETTER A WITH HOOK ABOVE */\n#define XK_ahook                      0x1001ea3  /* U+1EA3 LATIN SMALL LETTER A WITH HOOK ABOVE */\n#define XK_Acircumflexacute           0x1001ea4  /* U+1EA4 LATIN CAPITAL LETTER A WITH CIRCUMFLEX AND ACUTE */\n#define XK_acircumflexacute           0x1001ea5  /* U+1EA5 LATIN SMALL LETTER A WITH CIRCUMFLEX AND ACUTE */\n#define XK_Acircumflexgrave           0x1001ea6  /* U+1EA6 LATIN CAPITAL LETTER A WITH CIRCUMFLEX AND GRAVE */\n#define XK_acircumflexgrave           0x1001ea7  /* U+1EA7 LATIN SMALL LETTER A WITH CIRCUMFLEX AND GRAVE */\n#define XK_Acircumflexhook            0x1001ea8  /* U+1EA8 LATIN CAPITAL LETTER A WITH CIRCUMFLEX AND HOOK ABOVE */\n#define XK_acircumflexhook            0x1001ea9  /* U+1EA9 LATIN SMALL LETTER A WITH CIRCUMFLEX AND HOOK ABOVE */\n#define XK_Acircumflextilde           0x1001eaa  /* U+1EAA LATIN CAPITAL LETTER A WITH CIRCUMFLEX AND TILDE */\n#define XK_acircumflextilde           0x1001eab  /* U+1EAB LATIN SMALL LETTER A WITH CIRCUMFLEX AND TILDE */\n#define XK_Acircumflexbelowdot        0x1001eac  /* U+1EAC LATIN CAPITAL LETTER A WITH CIRCUMFLEX AND DOT BELOW */\n#define XK_acircumflexbelowdot        0x1001ead  /* U+1EAD LATIN SMALL LETTER A WITH CIRCUMFLEX AND DOT BELOW */\n#define XK_Abreveacute                0x1001eae  /* U+1EAE LATIN CAPITAL LETTER A WITH BREVE AND ACUTE */\n#define XK_abreveacute                0x1001eaf  /* U+1EAF LATIN SMALL LETTER A WITH BREVE AND ACUTE */\n#define XK_Abrevegrave                0x1001eb0  /* U+1EB0 LATIN CAPITAL LETTER A WITH BREVE AND GRAVE */\n#define XK_abrevegrave                0x1001eb1  /* U+1EB1 LATIN SMALL LETTER A WITH BREVE AND GRAVE */\n#define XK_Abrevehook                 0x1001eb2  /* U+1EB2 LATIN CAPITAL LETTER A WITH BREVE AND HOOK ABOVE */\n#define XK_abrevehook                 0x1001eb3  /* U+1EB3 LATIN SMALL LETTER A WITH BREVE AND HOOK ABOVE */\n#define XK_Abrevetilde                0x1001eb4  /* U+1EB4 LATIN CAPITAL LETTER A WITH BREVE AND TILDE */\n#define XK_abrevetilde                0x1001eb5  /* U+1EB5 LATIN SMALL LETTER A WITH BREVE AND TILDE */\n#define XK_Abrevebelowdot             0x1001eb6  /* U+1EB6 LATIN CAPITAL LETTER A WITH BREVE AND DOT BELOW */\n#define XK_abrevebelowdot             0x1001eb7  /* U+1EB7 LATIN SMALL LETTER A WITH BREVE AND DOT BELOW */\n#define XK_Ebelowdot                  0x1001eb8  /* U+1EB8 LATIN CAPITAL LETTER E WITH DOT BELOW */\n#define XK_ebelowdot                  0x1001eb9  /* U+1EB9 LATIN SMALL LETTER E WITH DOT BELOW */\n#define XK_Ehook                      0x1001eba  /* U+1EBA LATIN CAPITAL LETTER E WITH HOOK ABOVE */\n#define XK_ehook                      0x1001ebb  /* U+1EBB LATIN SMALL LETTER E WITH HOOK ABOVE */\n#define XK_Etilde                     0x1001ebc  /* U+1EBC LATIN CAPITAL LETTER E WITH TILDE */\n#define XK_etilde                     0x1001ebd  /* U+1EBD LATIN SMALL LETTER E WITH TILDE */\n#define XK_Ecircumflexacute           0x1001ebe  /* U+1EBE LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND ACUTE */\n#define XK_ecircumflexacute           0x1001ebf  /* U+1EBF LATIN SMALL LETTER E WITH CIRCUMFLEX AND ACUTE */\n#define XK_Ecircumflexgrave           0x1001ec0  /* U+1EC0 LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND GRAVE */\n#define XK_ecircumflexgrave           0x1001ec1  /* U+1EC1 LATIN SMALL LETTER E WITH CIRCUMFLEX AND GRAVE */\n#define XK_Ecircumflexhook            0x1001ec2  /* U+1EC2 LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND HOOK ABOVE */\n#define XK_ecircumflexhook            0x1001ec3  /* U+1EC3 LATIN SMALL LETTER E WITH CIRCUMFLEX AND HOOK ABOVE */\n#define XK_Ecircumflextilde           0x1001ec4  /* U+1EC4 LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND TILDE */\n#define XK_ecircumflextilde           0x1001ec5  /* U+1EC5 LATIN SMALL LETTER E WITH CIRCUMFLEX AND TILDE */\n#define XK_Ecircumflexbelowdot        0x1001ec6  /* U+1EC6 LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND DOT BELOW */\n#define XK_ecircumflexbelowdot        0x1001ec7  /* U+1EC7 LATIN SMALL LETTER E WITH CIRCUMFLEX AND DOT BELOW */\n#define XK_Ihook                      0x1001ec8  /* U+1EC8 LATIN CAPITAL LETTER I WITH HOOK ABOVE */\n#define XK_ihook                      0x1001ec9  /* U+1EC9 LATIN SMALL LETTER I WITH HOOK ABOVE */\n#define XK_Ibelowdot                  0x1001eca  /* U+1ECA LATIN CAPITAL LETTER I WITH DOT BELOW */\n#define XK_ibelowdot                  0x1001ecb  /* U+1ECB LATIN SMALL LETTER I WITH DOT BELOW */\n#define XK_Obelowdot                  0x1001ecc  /* U+1ECC LATIN CAPITAL LETTER O WITH DOT BELOW */\n#define XK_obelowdot                  0x1001ecd  /* U+1ECD LATIN SMALL LETTER O WITH DOT BELOW */\n#define XK_Ohook                      0x1001ece  /* U+1ECE LATIN CAPITAL LETTER O WITH HOOK ABOVE */\n#define XK_ohook                      0x1001ecf  /* U+1ECF LATIN SMALL LETTER O WITH HOOK ABOVE */\n#define XK_Ocircumflexacute           0x1001ed0  /* U+1ED0 LATIN CAPITAL LETTER O WITH CIRCUMFLEX AND ACUTE */\n#define XK_ocircumflexacute           0x1001ed1  /* U+1ED1 LATIN SMALL LETTER O WITH CIRCUMFLEX AND ACUTE */\n#define XK_Ocircumflexgrave           0x1001ed2  /* U+1ED2 LATIN CAPITAL LETTER O WITH CIRCUMFLEX AND GRAVE */\n#define XK_ocircumflexgrave           0x1001ed3  /* U+1ED3 LATIN SMALL LETTER O WITH CIRCUMFLEX AND GRAVE */\n#define XK_Ocircumflexhook            0x1001ed4  /* U+1ED4 LATIN CAPITAL LETTER O WITH CIRCUMFLEX AND HOOK ABOVE */\n#define XK_ocircumflexhook            0x1001ed5  /* U+1ED5 LATIN SMALL LETTER O WITH CIRCUMFLEX AND HOOK ABOVE */\n#define XK_Ocircumflextilde           0x1001ed6  /* U+1ED6 LATIN CAPITAL LETTER O WITH CIRCUMFLEX AND TILDE */\n#define XK_ocircumflextilde           0x1001ed7  /* U+1ED7 LATIN SMALL LETTER O WITH CIRCUMFLEX AND TILDE */\n#define XK_Ocircumflexbelowdot        0x1001ed8  /* U+1ED8 LATIN CAPITAL LETTER O WITH CIRCUMFLEX AND DOT BELOW */\n#define XK_ocircumflexbelowdot        0x1001ed9  /* U+1ED9 LATIN SMALL LETTER O WITH CIRCUMFLEX AND DOT BELOW */\n#define XK_Ohornacute                 0x1001eda  /* U+1EDA LATIN CAPITAL LETTER O WITH HORN AND ACUTE */\n#define XK_ohornacute                 0x1001edb  /* U+1EDB LATIN SMALL LETTER O WITH HORN AND ACUTE */\n#define XK_Ohorngrave                 0x1001edc  /* U+1EDC LATIN CAPITAL LETTER O WITH HORN AND GRAVE */\n#define XK_ohorngrave                 0x1001edd  /* U+1EDD LATIN SMALL LETTER O WITH HORN AND GRAVE */\n#define XK_Ohornhook                  0x1001ede  /* U+1EDE LATIN CAPITAL LETTER O WITH HORN AND HOOK ABOVE */\n#define XK_ohornhook                  0x1001edf  /* U+1EDF LATIN SMALL LETTER O WITH HORN AND HOOK ABOVE */\n#define XK_Ohorntilde                 0x1001ee0  /* U+1EE0 LATIN CAPITAL LETTER O WITH HORN AND TILDE */\n#define XK_ohorntilde                 0x1001ee1  /* U+1EE1 LATIN SMALL LETTER O WITH HORN AND TILDE */\n#define XK_Ohornbelowdot              0x1001ee2  /* U+1EE2 LATIN CAPITAL LETTER O WITH HORN AND DOT BELOW */\n#define XK_ohornbelowdot              0x1001ee3  /* U+1EE3 LATIN SMALL LETTER O WITH HORN AND DOT BELOW */\n#define XK_Ubelowdot                  0x1001ee4  /* U+1EE4 LATIN CAPITAL LETTER U WITH DOT BELOW */\n#define XK_ubelowdot                  0x1001ee5  /* U+1EE5 LATIN SMALL LETTER U WITH DOT BELOW */\n#define XK_Uhook                      0x1001ee6  /* U+1EE6 LATIN CAPITAL LETTER U WITH HOOK ABOVE */\n#define XK_uhook                      0x1001ee7  /* U+1EE7 LATIN SMALL LETTER U WITH HOOK ABOVE */\n#define XK_Uhornacute                 0x1001ee8  /* U+1EE8 LATIN CAPITAL LETTER U WITH HORN AND ACUTE */\n#define XK_uhornacute                 0x1001ee9  /* U+1EE9 LATIN SMALL LETTER U WITH HORN AND ACUTE */\n#define XK_Uhorngrave                 0x1001eea  /* U+1EEA LATIN CAPITAL LETTER U WITH HORN AND GRAVE */\n#define XK_uhorngrave                 0x1001eeb  /* U+1EEB LATIN SMALL LETTER U WITH HORN AND GRAVE */\n#define XK_Uhornhook                  0x1001eec  /* U+1EEC LATIN CAPITAL LETTER U WITH HORN AND HOOK ABOVE */\n#define XK_uhornhook                  0x1001eed  /* U+1EED LATIN SMALL LETTER U WITH HORN AND HOOK ABOVE */\n#define XK_Uhorntilde                 0x1001eee  /* U+1EEE LATIN CAPITAL LETTER U WITH HORN AND TILDE */\n#define XK_uhorntilde                 0x1001eef  /* U+1EEF LATIN SMALL LETTER U WITH HORN AND TILDE */\n#define XK_Uhornbelowdot              0x1001ef0  /* U+1EF0 LATIN CAPITAL LETTER U WITH HORN AND DOT BELOW */\n#define XK_uhornbelowdot              0x1001ef1  /* U+1EF1 LATIN SMALL LETTER U WITH HORN AND DOT BELOW */\n#define XK_Ybelowdot                  0x1001ef4  /* U+1EF4 LATIN CAPITAL LETTER Y WITH DOT BELOW */\n#define XK_ybelowdot                  0x1001ef5  /* U+1EF5 LATIN SMALL LETTER Y WITH DOT BELOW */\n#define XK_Yhook                      0x1001ef6  /* U+1EF6 LATIN CAPITAL LETTER Y WITH HOOK ABOVE */\n#define XK_yhook                      0x1001ef7  /* U+1EF7 LATIN SMALL LETTER Y WITH HOOK ABOVE */\n#define XK_Ytilde                     0x1001ef8  /* U+1EF8 LATIN CAPITAL LETTER Y WITH TILDE */\n#define XK_ytilde                     0x1001ef9  /* U+1EF9 LATIN SMALL LETTER Y WITH TILDE */\n#define XK_Ohorn                      0x10001a0  /* U+01A0 LATIN CAPITAL LETTER O WITH HORN */\n#define XK_ohorn                      0x10001a1  /* U+01A1 LATIN SMALL LETTER O WITH HORN */\n#define XK_Uhorn                      0x10001af  /* U+01AF LATIN CAPITAL LETTER U WITH HORN */\n#define XK_uhorn                      0x10001b0  /* U+01B0 LATIN SMALL LETTER U WITH HORN */\n\n#endif /* XK_VIETNAMESE */\n\n#ifdef XK_CURRENCY\n#define XK_EcuSign                    0x10020a0  /* U+20A0 EURO-CURRENCY SIGN */\n#define XK_ColonSign                  0x10020a1  /* U+20A1 COLON SIGN */\n#define XK_CruzeiroSign               0x10020a2  /* U+20A2 CRUZEIRO SIGN */\n#define XK_FFrancSign                 0x10020a3  /* U+20A3 FRENCH FRANC SIGN */\n#define XK_LiraSign                   0x10020a4  /* U+20A4 LIRA SIGN */\n#define XK_MillSign                   0x10020a5  /* U+20A5 MILL SIGN */\n#define XK_NairaSign                  0x10020a6  /* U+20A6 NAIRA SIGN */\n#define XK_PesetaSign                 0x10020a7  /* U+20A7 PESETA SIGN */\n#define XK_RupeeSign                  0x10020a8  /* U+20A8 RUPEE SIGN */\n#define XK_WonSign                    0x10020a9  /* U+20A9 WON SIGN */\n#define XK_NewSheqelSign              0x10020aa  /* U+20AA NEW SHEQEL SIGN */\n#define XK_DongSign                   0x10020ab  /* U+20AB DONG SIGN */\n#define XK_EuroSign                      0x20ac  /* U+20AC EURO SIGN */\n#endif /* XK_CURRENCY */\n\n#ifdef XK_MATHEMATICAL\n/* one, two and three are defined above. */\n#define XK_zerosuperior               0x1002070  /* U+2070 SUPERSCRIPT ZERO */\n#define XK_foursuperior               0x1002074  /* U+2074 SUPERSCRIPT FOUR */\n#define XK_fivesuperior               0x1002075  /* U+2075 SUPERSCRIPT FIVE */\n#define XK_sixsuperior                0x1002076  /* U+2076 SUPERSCRIPT SIX */\n#define XK_sevensuperior              0x1002077  /* U+2077 SUPERSCRIPT SEVEN */\n#define XK_eightsuperior              0x1002078  /* U+2078 SUPERSCRIPT EIGHT */\n#define XK_ninesuperior               0x1002079  /* U+2079 SUPERSCRIPT NINE */\n#define XK_zerosubscript              0x1002080  /* U+2080 SUBSCRIPT ZERO */\n#define XK_onesubscript               0x1002081  /* U+2081 SUBSCRIPT ONE */\n#define XK_twosubscript               0x1002082  /* U+2082 SUBSCRIPT TWO */\n#define XK_threesubscript             0x1002083  /* U+2083 SUBSCRIPT THREE */\n#define XK_foursubscript              0x1002084  /* U+2084 SUBSCRIPT FOUR */\n#define XK_fivesubscript              0x1002085  /* U+2085 SUBSCRIPT FIVE */\n#define XK_sixsubscript               0x1002086  /* U+2086 SUBSCRIPT SIX */\n#define XK_sevensubscript             0x1002087  /* U+2087 SUBSCRIPT SEVEN */\n#define XK_eightsubscript             0x1002088  /* U+2088 SUBSCRIPT EIGHT */\n#define XK_ninesubscript              0x1002089  /* U+2089 SUBSCRIPT NINE */\n#define XK_partdifferential           0x1002202  /* U+2202 PARTIAL DIFFERENTIAL */\n#define XK_emptyset                   0x1002205  /* U+2205 NULL SET */\n#define XK_elementof                  0x1002208  /* U+2208 ELEMENT OF */\n#define XK_notelementof               0x1002209  /* U+2209 NOT AN ELEMENT OF */\n#define XK_containsas                 0x100220B  /* U+220B CONTAINS AS MEMBER */\n#define XK_squareroot                 0x100221A  /* U+221A SQUARE ROOT */\n#define XK_cuberoot                   0x100221B  /* U+221B CUBE ROOT */\n#define XK_fourthroot                 0x100221C  /* U+221C FOURTH ROOT */\n#define XK_dintegral                  0x100222C  /* U+222C DOUBLE INTEGRAL */\n#define XK_tintegral                  0x100222D  /* U+222D TRIPLE INTEGRAL */\n#define XK_because                    0x1002235  /* U+2235 BECAUSE */\n#define XK_approxeq                   0x1002248  /* U+2245 ALMOST EQUAL TO */\n#define XK_notapproxeq                0x1002247  /* U+2247 NOT ALMOST EQUAL TO */\n#define XK_notidentical               0x1002262  /* U+2262 NOT IDENTICAL TO */\n#define XK_stricteq                   0x1002263  /* U+2263 STRICTLY EQUIVALENT TO */          \n#endif /* XK_MATHEMATICAL */\n\n#ifdef XK_BRAILLE\n#define XK_braille_dot_1                 0xfff1\n#define XK_braille_dot_2                 0xfff2\n#define XK_braille_dot_3                 0xfff3\n#define XK_braille_dot_4                 0xfff4\n#define XK_braille_dot_5                 0xfff5\n#define XK_braille_dot_6                 0xfff6\n#define XK_braille_dot_7                 0xfff7\n#define XK_braille_dot_8                 0xfff8\n#define XK_braille_dot_9                 0xfff9\n#define XK_braille_dot_10                0xfffa\n#define XK_braille_blank              0x1002800  /* U+2800 BRAILLE PATTERN BLANK */\n#define XK_braille_dots_1             0x1002801  /* U+2801 BRAILLE PATTERN DOTS-1 */\n#define XK_braille_dots_2             0x1002802  /* U+2802 BRAILLE PATTERN DOTS-2 */\n#define XK_braille_dots_12            0x1002803  /* U+2803 BRAILLE PATTERN DOTS-12 */\n#define XK_braille_dots_3             0x1002804  /* U+2804 BRAILLE PATTERN DOTS-3 */\n#define XK_braille_dots_13            0x1002805  /* U+2805 BRAILLE PATTERN DOTS-13 */\n#define XK_braille_dots_23            0x1002806  /* U+2806 BRAILLE PATTERN DOTS-23 */\n#define XK_braille_dots_123           0x1002807  /* U+2807 BRAILLE PATTERN DOTS-123 */\n#define XK_braille_dots_4             0x1002808  /* U+2808 BRAILLE PATTERN DOTS-4 */\n#define XK_braille_dots_14            0x1002809  /* U+2809 BRAILLE PATTERN DOTS-14 */\n#define XK_braille_dots_24            0x100280a  /* U+280a BRAILLE PATTERN DOTS-24 */\n#define XK_braille_dots_124           0x100280b  /* U+280b BRAILLE PATTERN DOTS-124 */\n#define XK_braille_dots_34            0x100280c  /* U+280c BRAILLE PATTERN DOTS-34 */\n#define XK_braille_dots_134           0x100280d  /* U+280d BRAILLE PATTERN DOTS-134 */\n#define XK_braille_dots_234           0x100280e  /* U+280e BRAILLE PATTERN DOTS-234 */\n#define XK_braille_dots_1234          0x100280f  /* U+280f BRAILLE PATTERN DOTS-1234 */\n#define XK_braille_dots_5             0x1002810  /* U+2810 BRAILLE PATTERN DOTS-5 */\n#define XK_braille_dots_15            0x1002811  /* U+2811 BRAILLE PATTERN DOTS-15 */\n#define XK_braille_dots_25            0x1002812  /* U+2812 BRAILLE PATTERN DOTS-25 */\n#define XK_braille_dots_125           0x1002813  /* U+2813 BRAILLE PATTERN DOTS-125 */\n#define XK_braille_dots_35            0x1002814  /* U+2814 BRAILLE PATTERN DOTS-35 */\n#define XK_braille_dots_135           0x1002815  /* U+2815 BRAILLE PATTERN DOTS-135 */\n#define XK_braille_dots_235           0x1002816  /* U+2816 BRAILLE PATTERN DOTS-235 */\n#define XK_braille_dots_1235          0x1002817  /* U+2817 BRAILLE PATTERN DOTS-1235 */\n#define XK_braille_dots_45            0x1002818  /* U+2818 BRAILLE PATTERN DOTS-45 */\n#define XK_braille_dots_145           0x1002819  /* U+2819 BRAILLE PATTERN DOTS-145 */\n#define XK_braille_dots_245           0x100281a  /* U+281a BRAILLE PATTERN DOTS-245 */\n#define XK_braille_dots_1245          0x100281b  /* U+281b BRAILLE PATTERN DOTS-1245 */\n#define XK_braille_dots_345           0x100281c  /* U+281c BRAILLE PATTERN DOTS-345 */\n#define XK_braille_dots_1345          0x100281d  /* U+281d BRAILLE PATTERN DOTS-1345 */\n#define XK_braille_dots_2345          0x100281e  /* U+281e BRAILLE PATTERN DOTS-2345 */\n#define XK_braille_dots_12345         0x100281f  /* U+281f BRAILLE PATTERN DOTS-12345 */\n#define XK_braille_dots_6             0x1002820  /* U+2820 BRAILLE PATTERN DOTS-6 */\n#define XK_braille_dots_16            0x1002821  /* U+2821 BRAILLE PATTERN DOTS-16 */\n#define XK_braille_dots_26            0x1002822  /* U+2822 BRAILLE PATTERN DOTS-26 */\n#define XK_braille_dots_126           0x1002823  /* U+2823 BRAILLE PATTERN DOTS-126 */\n#define XK_braille_dots_36            0x1002824  /* U+2824 BRAILLE PATTERN DOTS-36 */\n#define XK_braille_dots_136           0x1002825  /* U+2825 BRAILLE PATTERN DOTS-136 */\n#define XK_braille_dots_236           0x1002826  /* U+2826 BRAILLE PATTERN DOTS-236 */\n#define XK_braille_dots_1236          0x1002827  /* U+2827 BRAILLE PATTERN DOTS-1236 */\n#define XK_braille_dots_46            0x1002828  /* U+2828 BRAILLE PATTERN DOTS-46 */\n#define XK_braille_dots_146           0x1002829  /* U+2829 BRAILLE PATTERN DOTS-146 */\n#define XK_braille_dots_246           0x100282a  /* U+282a BRAILLE PATTERN DOTS-246 */\n#define XK_braille_dots_1246          0x100282b  /* U+282b BRAILLE PATTERN DOTS-1246 */\n#define XK_braille_dots_346           0x100282c  /* U+282c BRAILLE PATTERN DOTS-346 */\n#define XK_braille_dots_1346          0x100282d  /* U+282d BRAILLE PATTERN DOTS-1346 */\n#define XK_braille_dots_2346          0x100282e  /* U+282e BRAILLE PATTERN DOTS-2346 */\n#define XK_braille_dots_12346         0x100282f  /* U+282f BRAILLE PATTERN DOTS-12346 */\n#define XK_braille_dots_56            0x1002830  /* U+2830 BRAILLE PATTERN DOTS-56 */\n#define XK_braille_dots_156           0x1002831  /* U+2831 BRAILLE PATTERN DOTS-156 */\n#define XK_braille_dots_256           0x1002832  /* U+2832 BRAILLE PATTERN DOTS-256 */\n#define XK_braille_dots_1256          0x1002833  /* U+2833 BRAILLE PATTERN DOTS-1256 */\n#define XK_braille_dots_356           0x1002834  /* U+2834 BRAILLE PATTERN DOTS-356 */\n#define XK_braille_dots_1356          0x1002835  /* U+2835 BRAILLE PATTERN DOTS-1356 */\n#define XK_braille_dots_2356          0x1002836  /* U+2836 BRAILLE PATTERN DOTS-2356 */\n#define XK_braille_dots_12356         0x1002837  /* U+2837 BRAILLE PATTERN DOTS-12356 */\n#define XK_braille_dots_456           0x1002838  /* U+2838 BRAILLE PATTERN DOTS-456 */\n#define XK_braille_dots_1456          0x1002839  /* U+2839 BRAILLE PATTERN DOTS-1456 */\n#define XK_braille_dots_2456          0x100283a  /* U+283a BRAILLE PATTERN DOTS-2456 */\n#define XK_braille_dots_12456         0x100283b  /* U+283b BRAILLE PATTERN DOTS-12456 */\n#define XK_braille_dots_3456          0x100283c  /* U+283c BRAILLE PATTERN DOTS-3456 */\n#define XK_braille_dots_13456         0x100283d  /* U+283d BRAILLE PATTERN DOTS-13456 */\n#define XK_braille_dots_23456         0x100283e  /* U+283e BRAILLE PATTERN DOTS-23456 */\n#define XK_braille_dots_123456        0x100283f  /* U+283f BRAILLE PATTERN DOTS-123456 */\n#define XK_braille_dots_7             0x1002840  /* U+2840 BRAILLE PATTERN DOTS-7 */\n#define XK_braille_dots_17            0x1002841  /* U+2841 BRAILLE PATTERN DOTS-17 */\n#define XK_braille_dots_27            0x1002842  /* U+2842 BRAILLE PATTERN DOTS-27 */\n#define XK_braille_dots_127           0x1002843  /* U+2843 BRAILLE PATTERN DOTS-127 */\n#define XK_braille_dots_37            0x1002844  /* U+2844 BRAILLE PATTERN DOTS-37 */\n#define XK_braille_dots_137           0x1002845  /* U+2845 BRAILLE PATTERN DOTS-137 */\n#define XK_braille_dots_237           0x1002846  /* U+2846 BRAILLE PATTERN DOTS-237 */\n#define XK_braille_dots_1237          0x1002847  /* U+2847 BRAILLE PATTERN DOTS-1237 */\n#define XK_braille_dots_47            0x1002848  /* U+2848 BRAILLE PATTERN DOTS-47 */\n#define XK_braille_dots_147           0x1002849  /* U+2849 BRAILLE PATTERN DOTS-147 */\n#define XK_braille_dots_247           0x100284a  /* U+284a BRAILLE PATTERN DOTS-247 */\n#define XK_braille_dots_1247          0x100284b  /* U+284b BRAILLE PATTERN DOTS-1247 */\n#define XK_braille_dots_347           0x100284c  /* U+284c BRAILLE PATTERN DOTS-347 */\n#define XK_braille_dots_1347          0x100284d  /* U+284d BRAILLE PATTERN DOTS-1347 */\n#define XK_braille_dots_2347          0x100284e  /* U+284e BRAILLE PATTERN DOTS-2347 */\n#define XK_braille_dots_12347         0x100284f  /* U+284f BRAILLE PATTERN DOTS-12347 */\n#define XK_braille_dots_57            0x1002850  /* U+2850 BRAILLE PATTERN DOTS-57 */\n#define XK_braille_dots_157           0x1002851  /* U+2851 BRAILLE PATTERN DOTS-157 */\n#define XK_braille_dots_257           0x1002852  /* U+2852 BRAILLE PATTERN DOTS-257 */\n#define XK_braille_dots_1257          0x1002853  /* U+2853 BRAILLE PATTERN DOTS-1257 */\n#define XK_braille_dots_357           0x1002854  /* U+2854 BRAILLE PATTERN DOTS-357 */\n#define XK_braille_dots_1357          0x1002855  /* U+2855 BRAILLE PATTERN DOTS-1357 */\n#define XK_braille_dots_2357          0x1002856  /* U+2856 BRAILLE PATTERN DOTS-2357 */\n#define XK_braille_dots_12357         0x1002857  /* U+2857 BRAILLE PATTERN DOTS-12357 */\n#define XK_braille_dots_457           0x1002858  /* U+2858 BRAILLE PATTERN DOTS-457 */\n#define XK_braille_dots_1457          0x1002859  /* U+2859 BRAILLE PATTERN DOTS-1457 */\n#define XK_braille_dots_2457          0x100285a  /* U+285a BRAILLE PATTERN DOTS-2457 */\n#define XK_braille_dots_12457         0x100285b  /* U+285b BRAILLE PATTERN DOTS-12457 */\n#define XK_braille_dots_3457          0x100285c  /* U+285c BRAILLE PATTERN DOTS-3457 */\n#define XK_braille_dots_13457         0x100285d  /* U+285d BRAILLE PATTERN DOTS-13457 */\n#define XK_braille_dots_23457         0x100285e  /* U+285e BRAILLE PATTERN DOTS-23457 */\n#define XK_braille_dots_123457        0x100285f  /* U+285f BRAILLE PATTERN DOTS-123457 */\n#define XK_braille_dots_67            0x1002860  /* U+2860 BRAILLE PATTERN DOTS-67 */\n#define XK_braille_dots_167           0x1002861  /* U+2861 BRAILLE PATTERN DOTS-167 */\n#define XK_braille_dots_267           0x1002862  /* U+2862 BRAILLE PATTERN DOTS-267 */\n#define XK_braille_dots_1267          0x1002863  /* U+2863 BRAILLE PATTERN DOTS-1267 */\n#define XK_braille_dots_367           0x1002864  /* U+2864 BRAILLE PATTERN DOTS-367 */\n#define XK_braille_dots_1367          0x1002865  /* U+2865 BRAILLE PATTERN DOTS-1367 */\n#define XK_braille_dots_2367          0x1002866  /* U+2866 BRAILLE PATTERN DOTS-2367 */\n#define XK_braille_dots_12367         0x1002867  /* U+2867 BRAILLE PATTERN DOTS-12367 */\n#define XK_braille_dots_467           0x1002868  /* U+2868 BRAILLE PATTERN DOTS-467 */\n#define XK_braille_dots_1467          0x1002869  /* U+2869 BRAILLE PATTERN DOTS-1467 */\n#define XK_braille_dots_2467          0x100286a  /* U+286a BRAILLE PATTERN DOTS-2467 */\n#define XK_braille_dots_12467         0x100286b  /* U+286b BRAILLE PATTERN DOTS-12467 */\n#define XK_braille_dots_3467          0x100286c  /* U+286c BRAILLE PATTERN DOTS-3467 */\n#define XK_braille_dots_13467         0x100286d  /* U+286d BRAILLE PATTERN DOTS-13467 */\n#define XK_braille_dots_23467         0x100286e  /* U+286e BRAILLE PATTERN DOTS-23467 */\n#define XK_braille_dots_123467        0x100286f  /* U+286f BRAILLE PATTERN DOTS-123467 */\n#define XK_braille_dots_567           0x1002870  /* U+2870 BRAILLE PATTERN DOTS-567 */\n#define XK_braille_dots_1567          0x1002871  /* U+2871 BRAILLE PATTERN DOTS-1567 */\n#define XK_braille_dots_2567          0x1002872  /* U+2872 BRAILLE PATTERN DOTS-2567 */\n#define XK_braille_dots_12567         0x1002873  /* U+2873 BRAILLE PATTERN DOTS-12567 */\n#define XK_braille_dots_3567          0x1002874  /* U+2874 BRAILLE PATTERN DOTS-3567 */\n#define XK_braille_dots_13567         0x1002875  /* U+2875 BRAILLE PATTERN DOTS-13567 */\n#define XK_braille_dots_23567         0x1002876  /* U+2876 BRAILLE PATTERN DOTS-23567 */\n#define XK_braille_dots_123567        0x1002877  /* U+2877 BRAILLE PATTERN DOTS-123567 */\n#define XK_braille_dots_4567          0x1002878  /* U+2878 BRAILLE PATTERN DOTS-4567 */\n#define XK_braille_dots_14567         0x1002879  /* U+2879 BRAILLE PATTERN DOTS-14567 */\n#define XK_braille_dots_24567         0x100287a  /* U+287a BRAILLE PATTERN DOTS-24567 */\n#define XK_braille_dots_124567        0x100287b  /* U+287b BRAILLE PATTERN DOTS-124567 */\n#define XK_braille_dots_34567         0x100287c  /* U+287c BRAILLE PATTERN DOTS-34567 */\n#define XK_braille_dots_134567        0x100287d  /* U+287d BRAILLE PATTERN DOTS-134567 */\n#define XK_braille_dots_234567        0x100287e  /* U+287e BRAILLE PATTERN DOTS-234567 */\n#define XK_braille_dots_1234567       0x100287f  /* U+287f BRAILLE PATTERN DOTS-1234567 */\n#define XK_braille_dots_8             0x1002880  /* U+2880 BRAILLE PATTERN DOTS-8 */\n#define XK_braille_dots_18            0x1002881  /* U+2881 BRAILLE PATTERN DOTS-18 */\n#define XK_braille_dots_28            0x1002882  /* U+2882 BRAILLE PATTERN DOTS-28 */\n#define XK_braille_dots_128           0x1002883  /* U+2883 BRAILLE PATTERN DOTS-128 */\n#define XK_braille_dots_38            0x1002884  /* U+2884 BRAILLE PATTERN DOTS-38 */\n#define XK_braille_dots_138           0x1002885  /* U+2885 BRAILLE PATTERN DOTS-138 */\n#define XK_braille_dots_238           0x1002886  /* U+2886 BRAILLE PATTERN DOTS-238 */\n#define XK_braille_dots_1238          0x1002887  /* U+2887 BRAILLE PATTERN DOTS-1238 */\n#define XK_braille_dots_48            0x1002888  /* U+2888 BRAILLE PATTERN DOTS-48 */\n#define XK_braille_dots_148           0x1002889  /* U+2889 BRAILLE PATTERN DOTS-148 */\n#define XK_braille_dots_248           0x100288a  /* U+288a BRAILLE PATTERN DOTS-248 */\n#define XK_braille_dots_1248          0x100288b  /* U+288b BRAILLE PATTERN DOTS-1248 */\n#define XK_braille_dots_348           0x100288c  /* U+288c BRAILLE PATTERN DOTS-348 */\n#define XK_braille_dots_1348          0x100288d  /* U+288d BRAILLE PATTERN DOTS-1348 */\n#define XK_braille_dots_2348          0x100288e  /* U+288e BRAILLE PATTERN DOTS-2348 */\n#define XK_braille_dots_12348         0x100288f  /* U+288f BRAILLE PATTERN DOTS-12348 */\n#define XK_braille_dots_58            0x1002890  /* U+2890 BRAILLE PATTERN DOTS-58 */\n#define XK_braille_dots_158           0x1002891  /* U+2891 BRAILLE PATTERN DOTS-158 */\n#define XK_braille_dots_258           0x1002892  /* U+2892 BRAILLE PATTERN DOTS-258 */\n#define XK_braille_dots_1258          0x1002893  /* U+2893 BRAILLE PATTERN DOTS-1258 */\n#define XK_braille_dots_358           0x1002894  /* U+2894 BRAILLE PATTERN DOTS-358 */\n#define XK_braille_dots_1358          0x1002895  /* U+2895 BRAILLE PATTERN DOTS-1358 */\n#define XK_braille_dots_2358          0x1002896  /* U+2896 BRAILLE PATTERN DOTS-2358 */\n#define XK_braille_dots_12358         0x1002897  /* U+2897 BRAILLE PATTERN DOTS-12358 */\n#define XK_braille_dots_458           0x1002898  /* U+2898 BRAILLE PATTERN DOTS-458 */\n#define XK_braille_dots_1458          0x1002899  /* U+2899 BRAILLE PATTERN DOTS-1458 */\n#define XK_braille_dots_2458          0x100289a  /* U+289a BRAILLE PATTERN DOTS-2458 */\n#define XK_braille_dots_12458         0x100289b  /* U+289b BRAILLE PATTERN DOTS-12458 */\n#define XK_braille_dots_3458          0x100289c  /* U+289c BRAILLE PATTERN DOTS-3458 */\n#define XK_braille_dots_13458         0x100289d  /* U+289d BRAILLE PATTERN DOTS-13458 */\n#define XK_braille_dots_23458         0x100289e  /* U+289e BRAILLE PATTERN DOTS-23458 */\n#define XK_braille_dots_123458        0x100289f  /* U+289f BRAILLE PATTERN DOTS-123458 */\n#define XK_braille_dots_68            0x10028a0  /* U+28a0 BRAILLE PATTERN DOTS-68 */\n#define XK_braille_dots_168           0x10028a1  /* U+28a1 BRAILLE PATTERN DOTS-168 */\n#define XK_braille_dots_268           0x10028a2  /* U+28a2 BRAILLE PATTERN DOTS-268 */\n#define XK_braille_dots_1268          0x10028a3  /* U+28a3 BRAILLE PATTERN DOTS-1268 */\n#define XK_braille_dots_368           0x10028a4  /* U+28a4 BRAILLE PATTERN DOTS-368 */\n#define XK_braille_dots_1368          0x10028a5  /* U+28a5 BRAILLE PATTERN DOTS-1368 */\n#define XK_braille_dots_2368          0x10028a6  /* U+28a6 BRAILLE PATTERN DOTS-2368 */\n#define XK_braille_dots_12368         0x10028a7  /* U+28a7 BRAILLE PATTERN DOTS-12368 */\n#define XK_braille_dots_468           0x10028a8  /* U+28a8 BRAILLE PATTERN DOTS-468 */\n#define XK_braille_dots_1468          0x10028a9  /* U+28a9 BRAILLE PATTERN DOTS-1468 */\n#define XK_braille_dots_2468          0x10028aa  /* U+28aa BRAILLE PATTERN DOTS-2468 */\n#define XK_braille_dots_12468         0x10028ab  /* U+28ab BRAILLE PATTERN DOTS-12468 */\n#define XK_braille_dots_3468          0x10028ac  /* U+28ac BRAILLE PATTERN DOTS-3468 */\n#define XK_braille_dots_13468         0x10028ad  /* U+28ad BRAILLE PATTERN DOTS-13468 */\n#define XK_braille_dots_23468         0x10028ae  /* U+28ae BRAILLE PATTERN DOTS-23468 */\n#define XK_braille_dots_123468        0x10028af  /* U+28af BRAILLE PATTERN DOTS-123468 */\n#define XK_braille_dots_568           0x10028b0  /* U+28b0 BRAILLE PATTERN DOTS-568 */\n#define XK_braille_dots_1568          0x10028b1  /* U+28b1 BRAILLE PATTERN DOTS-1568 */\n#define XK_braille_dots_2568          0x10028b2  /* U+28b2 BRAILLE PATTERN DOTS-2568 */\n#define XK_braille_dots_12568         0x10028b3  /* U+28b3 BRAILLE PATTERN DOTS-12568 */\n#define XK_braille_dots_3568          0x10028b4  /* U+28b4 BRAILLE PATTERN DOTS-3568 */\n#define XK_braille_dots_13568         0x10028b5  /* U+28b5 BRAILLE PATTERN DOTS-13568 */\n#define XK_braille_dots_23568         0x10028b6  /* U+28b6 BRAILLE PATTERN DOTS-23568 */\n#define XK_braille_dots_123568        0x10028b7  /* U+28b7 BRAILLE PATTERN DOTS-123568 */\n#define XK_braille_dots_4568          0x10028b8  /* U+28b8 BRAILLE PATTERN DOTS-4568 */\n#define XK_braille_dots_14568         0x10028b9  /* U+28b9 BRAILLE PATTERN DOTS-14568 */\n#define XK_braille_dots_24568         0x10028ba  /* U+28ba BRAILLE PATTERN DOTS-24568 */\n#define XK_braille_dots_124568        0x10028bb  /* U+28bb BRAILLE PATTERN DOTS-124568 */\n#define XK_braille_dots_34568         0x10028bc  /* U+28bc BRAILLE PATTERN DOTS-34568 */\n#define XK_braille_dots_134568        0x10028bd  /* U+28bd BRAILLE PATTERN DOTS-134568 */\n#define XK_braille_dots_234568        0x10028be  /* U+28be BRAILLE PATTERN DOTS-234568 */\n#define XK_braille_dots_1234568       0x10028bf  /* U+28bf BRAILLE PATTERN DOTS-1234568 */\n#define XK_braille_dots_78            0x10028c0  /* U+28c0 BRAILLE PATTERN DOTS-78 */\n#define XK_braille_dots_178           0x10028c1  /* U+28c1 BRAILLE PATTERN DOTS-178 */\n#define XK_braille_dots_278           0x10028c2  /* U+28c2 BRAILLE PATTERN DOTS-278 */\n#define XK_braille_dots_1278          0x10028c3  /* U+28c3 BRAILLE PATTERN DOTS-1278 */\n#define XK_braille_dots_378           0x10028c4  /* U+28c4 BRAILLE PATTERN DOTS-378 */\n#define XK_braille_dots_1378          0x10028c5  /* U+28c5 BRAILLE PATTERN DOTS-1378 */\n#define XK_braille_dots_2378          0x10028c6  /* U+28c6 BRAILLE PATTERN DOTS-2378 */\n#define XK_braille_dots_12378         0x10028c7  /* U+28c7 BRAILLE PATTERN DOTS-12378 */\n#define XK_braille_dots_478           0x10028c8  /* U+28c8 BRAILLE PATTERN DOTS-478 */\n#define XK_braille_dots_1478          0x10028c9  /* U+28c9 BRAILLE PATTERN DOTS-1478 */\n#define XK_braille_dots_2478          0x10028ca  /* U+28ca BRAILLE PATTERN DOTS-2478 */\n#define XK_braille_dots_12478         0x10028cb  /* U+28cb BRAILLE PATTERN DOTS-12478 */\n#define XK_braille_dots_3478          0x10028cc  /* U+28cc BRAILLE PATTERN DOTS-3478 */\n#define XK_braille_dots_13478         0x10028cd  /* U+28cd BRAILLE PATTERN DOTS-13478 */\n#define XK_braille_dots_23478         0x10028ce  /* U+28ce BRAILLE PATTERN DOTS-23478 */\n#define XK_braille_dots_123478        0x10028cf  /* U+28cf BRAILLE PATTERN DOTS-123478 */\n#define XK_braille_dots_578           0x10028d0  /* U+28d0 BRAILLE PATTERN DOTS-578 */\n#define XK_braille_dots_1578          0x10028d1  /* U+28d1 BRAILLE PATTERN DOTS-1578 */\n#define XK_braille_dots_2578          0x10028d2  /* U+28d2 BRAILLE PATTERN DOTS-2578 */\n#define XK_braille_dots_12578         0x10028d3  /* U+28d3 BRAILLE PATTERN DOTS-12578 */\n#define XK_braille_dots_3578          0x10028d4  /* U+28d4 BRAILLE PATTERN DOTS-3578 */\n#define XK_braille_dots_13578         0x10028d5  /* U+28d5 BRAILLE PATTERN DOTS-13578 */\n#define XK_braille_dots_23578         0x10028d6  /* U+28d6 BRAILLE PATTERN DOTS-23578 */\n#define XK_braille_dots_123578        0x10028d7  /* U+28d7 BRAILLE PATTERN DOTS-123578 */\n#define XK_braille_dots_4578          0x10028d8  /* U+28d8 BRAILLE PATTERN DOTS-4578 */\n#define XK_braille_dots_14578         0x10028d9  /* U+28d9 BRAILLE PATTERN DOTS-14578 */\n#define XK_braille_dots_24578         0x10028da  /* U+28da BRAILLE PATTERN DOTS-24578 */\n#define XK_braille_dots_124578        0x10028db  /* U+28db BRAILLE PATTERN DOTS-124578 */\n#define XK_braille_dots_34578         0x10028dc  /* U+28dc BRAILLE PATTERN DOTS-34578 */\n#define XK_braille_dots_134578        0x10028dd  /* U+28dd BRAILLE PATTERN DOTS-134578 */\n#define XK_braille_dots_234578        0x10028de  /* U+28de BRAILLE PATTERN DOTS-234578 */\n#define XK_braille_dots_1234578       0x10028df  /* U+28df BRAILLE PATTERN DOTS-1234578 */\n#define XK_braille_dots_678           0x10028e0  /* U+28e0 BRAILLE PATTERN DOTS-678 */\n#define XK_braille_dots_1678          0x10028e1  /* U+28e1 BRAILLE PATTERN DOTS-1678 */\n#define XK_braille_dots_2678          0x10028e2  /* U+28e2 BRAILLE PATTERN DOTS-2678 */\n#define XK_braille_dots_12678         0x10028e3  /* U+28e3 BRAILLE PATTERN DOTS-12678 */\n#define XK_braille_dots_3678          0x10028e4  /* U+28e4 BRAILLE PATTERN DOTS-3678 */\n#define XK_braille_dots_13678         0x10028e5  /* U+28e5 BRAILLE PATTERN DOTS-13678 */\n#define XK_braille_dots_23678         0x10028e6  /* U+28e6 BRAILLE PATTERN DOTS-23678 */\n#define XK_braille_dots_123678        0x10028e7  /* U+28e7 BRAILLE PATTERN DOTS-123678 */\n#define XK_braille_dots_4678          0x10028e8  /* U+28e8 BRAILLE PATTERN DOTS-4678 */\n#define XK_braille_dots_14678         0x10028e9  /* U+28e9 BRAILLE PATTERN DOTS-14678 */\n#define XK_braille_dots_24678         0x10028ea  /* U+28ea BRAILLE PATTERN DOTS-24678 */\n#define XK_braille_dots_124678        0x10028eb  /* U+28eb BRAILLE PATTERN DOTS-124678 */\n#define XK_braille_dots_34678         0x10028ec  /* U+28ec BRAILLE PATTERN DOTS-34678 */\n#define XK_braille_dots_134678        0x10028ed  /* U+28ed BRAILLE PATTERN DOTS-134678 */\n#define XK_braille_dots_234678        0x10028ee  /* U+28ee BRAILLE PATTERN DOTS-234678 */\n#define XK_braille_dots_1234678       0x10028ef  /* U+28ef BRAILLE PATTERN DOTS-1234678 */\n#define XK_braille_dots_5678          0x10028f0  /* U+28f0 BRAILLE PATTERN DOTS-5678 */\n#define XK_braille_dots_15678         0x10028f1  /* U+28f1 BRAILLE PATTERN DOTS-15678 */\n#define XK_braille_dots_25678         0x10028f2  /* U+28f2 BRAILLE PATTERN DOTS-25678 */\n#define XK_braille_dots_125678        0x10028f3  /* U+28f3 BRAILLE PATTERN DOTS-125678 */\n#define XK_braille_dots_35678         0x10028f4  /* U+28f4 BRAILLE PATTERN DOTS-35678 */\n#define XK_braille_dots_135678        0x10028f5  /* U+28f5 BRAILLE PATTERN DOTS-135678 */\n#define XK_braille_dots_235678        0x10028f6  /* U+28f6 BRAILLE PATTERN DOTS-235678 */\n#define XK_braille_dots_1235678       0x10028f7  /* U+28f7 BRAILLE PATTERN DOTS-1235678 */\n#define XK_braille_dots_45678         0x10028f8  /* U+28f8 BRAILLE PATTERN DOTS-45678 */\n#define XK_braille_dots_145678        0x10028f9  /* U+28f9 BRAILLE PATTERN DOTS-145678 */\n#define XK_braille_dots_245678        0x10028fa  /* U+28fa BRAILLE PATTERN DOTS-245678 */\n#define XK_braille_dots_1245678       0x10028fb  /* U+28fb BRAILLE PATTERN DOTS-1245678 */\n#define XK_braille_dots_345678        0x10028fc  /* U+28fc BRAILLE PATTERN DOTS-345678 */\n#define XK_braille_dots_1345678       0x10028fd  /* U+28fd BRAILLE PATTERN DOTS-1345678 */\n#define XK_braille_dots_2345678       0x10028fe  /* U+28fe BRAILLE PATTERN DOTS-2345678 */\n#define XK_braille_dots_12345678      0x10028ff  /* U+28ff BRAILLE PATTERN DOTS-12345678 */\n#endif /* XK_BRAILLE */\n\n/*\n * Sinhala (http://unicode.org/charts/PDF/U0D80.pdf)\n * http://www.nongnu.org/sinhala/doc/transliteration/sinhala-transliteration_6.html\n */\n\n#ifdef XK_SINHALA\n#define XK_Sinh_ng            0x1000d82  /* U+0D82 SINHALA ANUSVARAYA */\n#define XK_Sinh_h2            0x1000d83  /* U+0D83 SINHALA VISARGAYA */\n#define XK_Sinh_a             0x1000d85  /* U+0D85 SINHALA AYANNA */\n#define XK_Sinh_aa            0x1000d86  /* U+0D86 SINHALA AAYANNA */\n#define XK_Sinh_ae            0x1000d87  /* U+0D87 SINHALA AEYANNA */\n#define XK_Sinh_aee           0x1000d88  /* U+0D88 SINHALA AEEYANNA */\n#define XK_Sinh_i             0x1000d89  /* U+0D89 SINHALA IYANNA */\n#define XK_Sinh_ii            0x1000d8a  /* U+0D8A SINHALA IIYANNA */\n#define XK_Sinh_u             0x1000d8b  /* U+0D8B SINHALA UYANNA */\n#define XK_Sinh_uu            0x1000d8c  /* U+0D8C SINHALA UUYANNA */\n#define XK_Sinh_ri            0x1000d8d  /* U+0D8D SINHALA IRUYANNA */\n#define XK_Sinh_rii           0x1000d8e  /* U+0D8E SINHALA IRUUYANNA */\n#define XK_Sinh_lu            0x1000d8f  /* U+0D8F SINHALA ILUYANNA */\n#define XK_Sinh_luu           0x1000d90  /* U+0D90 SINHALA ILUUYANNA */\n#define XK_Sinh_e             0x1000d91  /* U+0D91 SINHALA EYANNA */\n#define XK_Sinh_ee            0x1000d92  /* U+0D92 SINHALA EEYANNA */\n#define XK_Sinh_ai            0x1000d93  /* U+0D93 SINHALA AIYANNA */\n#define XK_Sinh_o             0x1000d94  /* U+0D94 SINHALA OYANNA */\n#define XK_Sinh_oo            0x1000d95  /* U+0D95 SINHALA OOYANNA */\n#define XK_Sinh_au            0x1000d96  /* U+0D96 SINHALA AUYANNA */\n#define XK_Sinh_ka            0x1000d9a  /* U+0D9A SINHALA KAYANNA */\n#define XK_Sinh_kha           0x1000d9b  /* U+0D9B SINHALA MAHA. KAYANNA */\n#define XK_Sinh_ga            0x1000d9c  /* U+0D9C SINHALA GAYANNA */\n#define XK_Sinh_gha           0x1000d9d  /* U+0D9D SINHALA MAHA. GAYANNA */\n#define XK_Sinh_ng2           0x1000d9e  /* U+0D9E SINHALA KANTAJA NAASIKYAYA */\n#define XK_Sinh_nga           0x1000d9f  /* U+0D9F SINHALA SANYAKA GAYANNA */\n#define XK_Sinh_ca            0x1000da0  /* U+0DA0 SINHALA CAYANNA */\n#define XK_Sinh_cha           0x1000da1  /* U+0DA1 SINHALA MAHA. CAYANNA */\n#define XK_Sinh_ja            0x1000da2  /* U+0DA2 SINHALA JAYANNA */\n#define XK_Sinh_jha           0x1000da3  /* U+0DA3 SINHALA MAHA. JAYANNA */\n#define XK_Sinh_nya           0x1000da4  /* U+0DA4 SINHALA TAALUJA NAASIKYAYA */\n#define XK_Sinh_jnya          0x1000da5  /* U+0DA5 SINHALA TAALUJA SANYOOGA NAASIKYAYA */\n#define XK_Sinh_nja           0x1000da6  /* U+0DA6 SINHALA SANYAKA JAYANNA */\n#define XK_Sinh_tta           0x1000da7  /* U+0DA7 SINHALA TTAYANNA */\n#define XK_Sinh_ttha          0x1000da8  /* U+0DA8 SINHALA MAHA. TTAYANNA */\n#define XK_Sinh_dda           0x1000da9  /* U+0DA9 SINHALA DDAYANNA */\n#define XK_Sinh_ddha          0x1000daa  /* U+0DAA SINHALA MAHA. DDAYANNA */\n#define XK_Sinh_nna           0x1000dab  /* U+0DAB SINHALA MUURDHAJA NAYANNA */\n#define XK_Sinh_ndda          0x1000dac  /* U+0DAC SINHALA SANYAKA DDAYANNA */\n#define XK_Sinh_tha           0x1000dad  /* U+0DAD SINHALA TAYANNA */\n#define XK_Sinh_thha          0x1000dae  /* U+0DAE SINHALA MAHA. TAYANNA */\n#define XK_Sinh_dha           0x1000daf  /* U+0DAF SINHALA DAYANNA */\n#define XK_Sinh_dhha          0x1000db0  /* U+0DB0 SINHALA MAHA. DAYANNA */\n#define XK_Sinh_na            0x1000db1  /* U+0DB1 SINHALA DANTAJA NAYANNA */\n#define XK_Sinh_ndha          0x1000db3  /* U+0DB3 SINHALA SANYAKA DAYANNA */\n#define XK_Sinh_pa            0x1000db4  /* U+0DB4 SINHALA PAYANNA */\n#define XK_Sinh_pha           0x1000db5  /* U+0DB5 SINHALA MAHA. PAYANNA */\n#define XK_Sinh_ba            0x1000db6  /* U+0DB6 SINHALA BAYANNA */\n#define XK_Sinh_bha           0x1000db7  /* U+0DB7 SINHALA MAHA. BAYANNA */\n#define XK_Sinh_ma            0x1000db8  /* U+0DB8 SINHALA MAYANNA */\n#define XK_Sinh_mba           0x1000db9  /* U+0DB9 SINHALA AMBA BAYANNA */\n#define XK_Sinh_ya            0x1000dba  /* U+0DBA SINHALA YAYANNA */\n#define XK_Sinh_ra            0x1000dbb  /* U+0DBB SINHALA RAYANNA */\n#define XK_Sinh_la            0x1000dbd  /* U+0DBD SINHALA DANTAJA LAYANNA */\n#define XK_Sinh_va            0x1000dc0  /* U+0DC0 SINHALA VAYANNA */\n#define XK_Sinh_sha           0x1000dc1  /* U+0DC1 SINHALA TAALUJA SAYANNA */\n#define XK_Sinh_ssha          0x1000dc2  /* U+0DC2 SINHALA MUURDHAJA SAYANNA */\n#define XK_Sinh_sa            0x1000dc3  /* U+0DC3 SINHALA DANTAJA SAYANNA */\n#define XK_Sinh_ha            0x1000dc4  /* U+0DC4 SINHALA HAYANNA */\n#define XK_Sinh_lla           0x1000dc5  /* U+0DC5 SINHALA MUURDHAJA LAYANNA */\n#define XK_Sinh_fa            0x1000dc6  /* U+0DC6 SINHALA FAYANNA */\n#define XK_Sinh_al            0x1000dca  /* U+0DCA SINHALA AL-LAKUNA */\n#define XK_Sinh_aa2           0x1000dcf  /* U+0DCF SINHALA AELA-PILLA */\n#define XK_Sinh_ae2           0x1000dd0  /* U+0DD0 SINHALA AEDA-PILLA */\n#define XK_Sinh_aee2          0x1000dd1  /* U+0DD1 SINHALA DIGA AEDA-PILLA */\n#define XK_Sinh_i2            0x1000dd2  /* U+0DD2 SINHALA IS-PILLA */\n#define XK_Sinh_ii2           0x1000dd3  /* U+0DD3 SINHALA DIGA IS-PILLA */\n#define XK_Sinh_u2            0x1000dd4  /* U+0DD4 SINHALA PAA-PILLA */\n#define XK_Sinh_uu2           0x1000dd6  /* U+0DD6 SINHALA DIGA PAA-PILLA */\n#define XK_Sinh_ru2           0x1000dd8  /* U+0DD8 SINHALA GAETTA-PILLA */\n#define XK_Sinh_e2            0x1000dd9  /* U+0DD9 SINHALA KOMBUVA */\n#define XK_Sinh_ee2           0x1000dda  /* U+0DDA SINHALA DIGA KOMBUVA */\n#define XK_Sinh_ai2           0x1000ddb  /* U+0DDB SINHALA KOMBU DEKA */\n#define XK_Sinh_o2            0x1000ddc  /* U+0DDC SINHALA KOMBUVA HAA AELA-PILLA*/\n#define XK_Sinh_oo2           0x1000ddd  /* U+0DDD SINHALA KOMBUVA HAA DIGA AELA-PILLA*/\n#define XK_Sinh_au2           0x1000dde  /* U+0DDE SINHALA KOMBUVA HAA GAYANUKITTA */\n#define XK_Sinh_lu2           0x1000ddf  /* U+0DDF SINHALA GAYANUKITTA */\n#define XK_Sinh_ruu2          0x1000df2  /* U+0DF2 SINHALA DIGA GAETTA-PILLA */\n#define XK_Sinh_luu2          0x1000df3  /* U+0DF3 SINHALA DIGA GAYANUKITTA */\n#define XK_Sinh_kunddaliya    0x1000df4  /* U+0DF4 SINHALA KUNDDALIYA */\n#endif /* XK_SINHALA */\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/aes/aes.h",
    "content": "/* The MIT License\n\n   Copyright (C) 2011 Zilong Tan (labytan@gmail.com)\n\n   Permission is hereby granted, free of charge, to any person obtaining\n   a copy of this software and associated documentation files (the\n   \"Software\"), to deal in the Software without restriction, including\n   without limitation the rights to use, copy, modify, merge, publish,\n   distribute, sublicense, and/or sell copies of the Software, and to\n   permit persons to whom the Software is furnished to do so, subject to\n   the following conditions:\n\n   The above copyright notice and this permission notice shall be\n   included in all copies or substantial portions of the Software.\n\n   THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n   NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS\n   BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\n   ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\n   CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n   SOFTWARE.\n*/\n\n/*\n * aes.h\n *\n * @version 3.0 (December 2000)\n *\n * Optimised ANSI C code for the Rijndael cipher (now AES)\n *\n * @author Vincent Rijmen <vincent.rijmen@esat.kuleuven.ac.be>\n * @author Antoon Bosselaers <antoon.bosselaers@esat.kuleuven.ac.be>\n * @author Paulo Barreto <paulo.barreto@terra.com.br>\n *\n * This code is hereby placed in the public domain.\n *\n * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ''AS IS'' AND ANY EXPRESS\n * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE\n * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,\n * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\n#ifndef __ULIB_AES_H\n#define __ULIB_AES_H\n\n#include <stdint.h>\n\n#define AES_MAXNR 14\n#define AES_BLOCK_SIZE 16\n\nstruct aes_key_st {\n        uint32_t rd_key[4 *(AES_MAXNR + 1)];\n        int rounds;\n};\n\ntypedef struct aes_key_st AES_KEY;\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n        /* bits can be 128, 192 or 256 */\n        int  AES_set_encrypt_key(const unsigned char *userKey, const int bits,\n                                AES_KEY *key);\n        int  AES_set_decrypt_key(const unsigned char *userKey, const int bits,\n                                AES_KEY *key);\n\n        /* in/out can be the same for ECB encryption/decryption */\n        void AES_encrypt(const unsigned char *in, unsigned char *out,\n                         const AES_KEY *key);\n        void AES_decrypt(const unsigned char *in, unsigned char *out,\n                         const AES_KEY *key);\n\n        /* in/out can be the same */\n        void AES_cbc_encrypt(const unsigned char *in, unsigned char *out, unsigned char *ivec,\n                             unsigned long nblock, const AES_KEY *key);\n\n        /* in/out MUST be DIFFERENT */\n        void AES_cbc_decrypt(const unsigned char *in, unsigned char *out, unsigned char *ivec,\n                             unsigned long nblock, const AES_KEY *key);\n\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/base64/base64.h",
    "content": "#include <string>\n\nstd::string base64_encode(unsigned char const* , unsigned int len);\nstd::string base64_decode(std::string const& s);\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/bcm_host.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n// Header file with useful bits from other headers\n\n#ifndef BCM_HOST_H\n#define BCM_HOST_H\n\n#include <stdint.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\nvoid bcm_host_init(void);\nvoid bcm_host_deinit(void);\n\nint32_t graphics_get_display_size( const uint16_t display_number,\n                                                    uint32_t *width,\n                                                    uint32_t *height);\n\nunsigned bcm_host_get_peripheral_address(void);\nunsigned bcm_host_get_peripheral_size(void);\nunsigned bcm_host_get_sdram_address(void);\n\n#include \"interface/vmcs_host/vc_dispmanx.h\"\n#include \"interface/vmcs_host/vc_tvservice.h\"\n#include \"interface/vmcs_host/vc_cec.h\"\n#include \"interface/vmcs_host/vc_cecservice.h\"\n#include \"interface/vmcs_host/vcgencmd.h\"\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif\n\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/curl/curl.h",
    "content": "#ifndef __CURL_CURL_H\n#define __CURL_CURL_H\n/***************************************************************************\n *                                  _   _ ____  _\n *  Project                     ___| | | |  _ \\| |\n *                             / __| | | | |_) | |\n *                            | (__| |_| |  _ <| |___\n *                             \\___|\\___/|_| \\_\\_____|\n *\n * Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.\n *\n * This software is licensed as described in the file COPYING, which\n * you should have received as part of this distribution. The terms\n * are also available at http://curl.haxx.se/docs/copyright.html.\n *\n * You may opt to use, copy, modify, merge, publish, distribute and/or sell\n * copies of the Software, and permit persons to whom the Software is\n * furnished to do so, under the terms of the COPYING file.\n *\n * This software is distributed on an \"AS IS\" basis, WITHOUT WARRANTY OF ANY\n * KIND, either express or implied.\n *\n ***************************************************************************/\n\n/*\n * If you have libcurl problems, all docs and details are found here:\n *   http://curl.haxx.se/libcurl/\n *\n * curl-library mailing list subscription and unsubscription web interface:\n *   http://cool.haxx.se/mailman/listinfo/curl-library/\n */\n\n#include \"curlver.h\"         /* libcurl version defines   */\n#include \"curlbuild.h\"       /* libcurl build definitions */\n#include \"curlrules.h\"       /* libcurl rules enforcement */\n\n/*\n * Define WIN32 when build target is Win32 API\n */\n\n#if (defined(_WIN32) || defined(__WIN32__)) && \\\n     !defined(WIN32) && !defined(__SYMBIAN32__)\n#define WIN32\n#endif\n\n#include <stdio.h>\n#include <limits.h>\n\n#if defined(__FreeBSD__) && (__FreeBSD__ >= 2)\n/* Needed for __FreeBSD_version symbol definition */\n#include <osreldate.h>\n#endif\n\n/* The include stuff here below is mainly for time_t! */\n#include <sys/types.h>\n#include <time.h>\n\n#if defined(WIN32) && !defined(_WIN32_WCE) && !defined(__CYGWIN__)\n#if !(defined(_WINSOCKAPI_) || defined(_WINSOCK_H) || defined(__LWIP_OPT_H__))\n/* The check above prevents the winsock2 inclusion if winsock.h already was\n   included, since they can't co-exist without problems */\n#include <winsock2.h>\n#include <ws2tcpip.h>\n#endif\n#endif\n\n/* HP-UX systems version 9, 10 and 11 lack sys/select.h and so does oldish\n   libc5-based Linux systems. Only include it on systems that are known to\n   require it! */\n#if defined(_AIX) || defined(__NOVELL_LIBC__) || defined(__NetBSD__) || \\\n    defined(__minix) || defined(__SYMBIAN32__) || defined(__INTEGRITY) || \\\n    defined(ANDROID) || defined(__ANDROID__) || defined(__OpenBSD__) || \\\n   (defined(__FreeBSD_version) && (__FreeBSD_version < 800000))\n#include <sys/select.h>\n#endif\n\n#if !defined(WIN32) && !defined(_WIN32_WCE)\n#include <sys/socket.h>\n#endif\n\n#if !defined(WIN32) && !defined(__WATCOMC__) && !defined(__VXWORKS__)\n#include <sys/time.h>\n#endif\n\n#ifdef __BEOS__\n#include <support/SupportDefs.h>\n#endif\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\ntypedef void CURL;\n\n/*\n * libcurl external API function linkage decorations.\n */\n\n#ifdef CURL_STATICLIB\n#  define CURL_EXTERN\n#elif defined(WIN32) || defined(_WIN32) || defined(__SYMBIAN32__)\n#  if defined(BUILDING_LIBCURL)\n#    define CURL_EXTERN  __declspec(dllexport)\n#  else\n#    define CURL_EXTERN  __declspec(dllimport)\n#  endif\n#elif defined(BUILDING_LIBCURL) && defined(CURL_HIDDEN_SYMBOLS)\n#  define CURL_EXTERN CURL_EXTERN_SYMBOL\n#else\n#  define CURL_EXTERN\n#endif\n\n#ifndef curl_socket_typedef\n/* socket typedef */\n#if defined(WIN32) && !defined(__LWIP_OPT_H__)\ntypedef SOCKET curl_socket_t;\n#define CURL_SOCKET_BAD INVALID_SOCKET\n#else\ntypedef int curl_socket_t;\n#define CURL_SOCKET_BAD -1\n#endif\n#define curl_socket_typedef\n#endif /* curl_socket_typedef */\n\nstruct curl_httppost {\n  struct curl_httppost *next;       /* next entry in the list */\n  char *name;                       /* pointer to allocated name */\n  long namelength;                  /* length of name length */\n  char *contents;                   /* pointer to allocated data contents */\n  long contentslength;              /* length of contents field */\n  char *buffer;                     /* pointer to allocated buffer contents */\n  long bufferlength;                /* length of buffer field */\n  char *contenttype;                /* Content-Type */\n  struct curl_slist* contentheader; /* list of extra headers for this form */\n  struct curl_httppost *more;       /* if one field name has more than one\n                                       file, this link should link to following\n                                       files */\n  long flags;                       /* as defined below */\n#define HTTPPOST_FILENAME (1<<0)    /* specified content is a file name */\n#define HTTPPOST_READFILE (1<<1)    /* specified content is a file name */\n#define HTTPPOST_PTRNAME (1<<2)     /* name is only stored pointer\n                                       do not free in formfree */\n#define HTTPPOST_PTRCONTENTS (1<<3) /* contents is only stored pointer\n                                       do not free in formfree */\n#define HTTPPOST_BUFFER (1<<4)      /* upload file from buffer */\n#define HTTPPOST_PTRBUFFER (1<<5)   /* upload file from pointer contents */\n#define HTTPPOST_CALLBACK (1<<6)    /* upload file contents by using the\n                                       regular read callback to get the data\n                                       and pass the given pointer as custom\n                                       pointer */\n\n  char *showfilename;               /* The file name to show. If not set, the\n                                       actual file name will be used (if this\n                                       is a file part) */\n  void *userp;                      /* custom pointer used for\n                                       HTTPPOST_CALLBACK posts */\n};\n\n/* This is the CURLOPT_PROGRESSFUNCTION callback proto. It is now considered\n   deprecated but was the only choice up until 7.31.0 */\ntypedef int (*curl_progress_callback)(void *clientp,\n                                      double dltotal,\n                                      double dlnow,\n                                      double ultotal,\n                                      double ulnow);\n\n/* This is the CURLOPT_XFERINFOFUNCTION callback proto. It was introduced in\n   7.32.0, it avoids floating point and provides more detailed information. */\ntypedef int (*curl_xferinfo_callback)(void *clientp,\n                                      curl_off_t dltotal,\n                                      curl_off_t dlnow,\n                                      curl_off_t ultotal,\n                                      curl_off_t ulnow);\n\n#ifndef CURL_MAX_WRITE_SIZE\n  /* Tests have proven that 20K is a very bad buffer size for uploads on\n     Windows, while 16K for some odd reason performed a lot better.\n     We do the ifndef check to allow this value to easier be changed at build\n     time for those who feel adventurous. The practical minimum is about\n     400 bytes since libcurl uses a buffer of this size as a scratch area\n     (unrelated to network send operations). */\n#define CURL_MAX_WRITE_SIZE 16384\n#endif\n\n#ifndef CURL_MAX_HTTP_HEADER\n/* The only reason to have a max limit for this is to avoid the risk of a bad\n   server feeding libcurl with a never-ending header that will cause reallocs\n   infinitely */\n#define CURL_MAX_HTTP_HEADER (100*1024)\n#endif\n\n/* This is a magic return code for the write callback that, when returned,\n   will signal libcurl to pause receiving on the current transfer. */\n#define CURL_WRITEFUNC_PAUSE 0x10000001\n\ntypedef size_t (*curl_write_callback)(char *buffer,\n                                      size_t size,\n                                      size_t nitems,\n                                      void *outstream);\n\n\n\n/* enumeration of file types */\ntypedef enum {\n  CURLFILETYPE_FILE = 0,\n  CURLFILETYPE_DIRECTORY,\n  CURLFILETYPE_SYMLINK,\n  CURLFILETYPE_DEVICE_BLOCK,\n  CURLFILETYPE_DEVICE_CHAR,\n  CURLFILETYPE_NAMEDPIPE,\n  CURLFILETYPE_SOCKET,\n  CURLFILETYPE_DOOR, /* is possible only on Sun Solaris now */\n\n  CURLFILETYPE_UNKNOWN /* should never occur */\n} curlfiletype;\n\n#define CURLFINFOFLAG_KNOWN_FILENAME    (1<<0)\n#define CURLFINFOFLAG_KNOWN_FILETYPE    (1<<1)\n#define CURLFINFOFLAG_KNOWN_TIME        (1<<2)\n#define CURLFINFOFLAG_KNOWN_PERM        (1<<3)\n#define CURLFINFOFLAG_KNOWN_UID         (1<<4)\n#define CURLFINFOFLAG_KNOWN_GID         (1<<5)\n#define CURLFINFOFLAG_KNOWN_SIZE        (1<<6)\n#define CURLFINFOFLAG_KNOWN_HLINKCOUNT  (1<<7)\n\n/* Content of this structure depends on information which is known and is\n   achievable (e.g. by FTP LIST parsing). Please see the url_easy_setopt(3) man\n   page for callbacks returning this structure -- some fields are mandatory,\n   some others are optional. The FLAG field has special meaning. */\nstruct curl_fileinfo {\n  char *filename;\n  curlfiletype filetype;\n  time_t time;\n  unsigned int perm;\n  int uid;\n  int gid;\n  curl_off_t size;\n  long int hardlinks;\n\n  struct {\n    /* If some of these fields is not NULL, it is a pointer to b_data. */\n    char *time;\n    char *perm;\n    char *user;\n    char *group;\n    char *target; /* pointer to the target filename of a symlink */\n  } strings;\n\n  unsigned int flags;\n\n  /* used internally */\n  char * b_data;\n  size_t b_size;\n  size_t b_used;\n};\n\n/* return codes for CURLOPT_CHUNK_BGN_FUNCTION */\n#define CURL_CHUNK_BGN_FUNC_OK      0\n#define CURL_CHUNK_BGN_FUNC_FAIL    1 /* tell the lib to end the task */\n#define CURL_CHUNK_BGN_FUNC_SKIP    2 /* skip this chunk over */\n\n/* if splitting of data transfer is enabled, this callback is called before\n   download of an individual chunk started. Note that parameter \"remains\" works\n   only for FTP wildcard downloading (for now), otherwise is not used */\ntypedef long (*curl_chunk_bgn_callback)(const void *transfer_info,\n                                        void *ptr,\n                                        int remains);\n\n/* return codes for CURLOPT_CHUNK_END_FUNCTION */\n#define CURL_CHUNK_END_FUNC_OK      0\n#define CURL_CHUNK_END_FUNC_FAIL    1 /* tell the lib to end the task */\n\n/* If splitting of data transfer is enabled this callback is called after\n   download of an individual chunk finished.\n   Note! After this callback was set then it have to be called FOR ALL chunks.\n   Even if downloading of this chunk was skipped in CHUNK_BGN_FUNC.\n   This is the reason why we don't need \"transfer_info\" parameter in this\n   callback and we are not interested in \"remains\" parameter too. */\ntypedef long (*curl_chunk_end_callback)(void *ptr);\n\n/* return codes for FNMATCHFUNCTION */\n#define CURL_FNMATCHFUNC_MATCH    0 /* string corresponds to the pattern */\n#define CURL_FNMATCHFUNC_NOMATCH  1 /* pattern doesn't match the string */\n#define CURL_FNMATCHFUNC_FAIL     2 /* an error occurred */\n\n/* callback type for wildcard downloading pattern matching. If the\n   string matches the pattern, return CURL_FNMATCHFUNC_MATCH value, etc. */\ntypedef int (*curl_fnmatch_callback)(void *ptr,\n                                     const char *pattern,\n                                     const char *string);\n\n/* These are the return codes for the seek callbacks */\n#define CURL_SEEKFUNC_OK       0\n#define CURL_SEEKFUNC_FAIL     1 /* fail the entire transfer */\n#define CURL_SEEKFUNC_CANTSEEK 2 /* tell libcurl seeking can't be done, so\n                                    libcurl might try other means instead */\ntypedef int (*curl_seek_callback)(void *instream,\n                                  curl_off_t offset,\n                                  int origin); /* 'whence' */\n\n/* This is a return code for the read callback that, when returned, will\n   signal libcurl to immediately abort the current transfer. */\n#define CURL_READFUNC_ABORT 0x10000000\n/* This is a return code for the read callback that, when returned, will\n   signal libcurl to pause sending data on the current transfer. */\n#define CURL_READFUNC_PAUSE 0x10000001\n\ntypedef size_t (*curl_read_callback)(char *buffer,\n                                      size_t size,\n                                      size_t nitems,\n                                      void *instream);\n\ntypedef enum  {\n  CURLSOCKTYPE_IPCXN,  /* socket created for a specific IP connection */\n  CURLSOCKTYPE_ACCEPT, /* socket created by accept() call */\n  CURLSOCKTYPE_LAST    /* never use */\n} curlsocktype;\n\n/* The return code from the sockopt_callback can signal information back\n   to libcurl: */\n#define CURL_SOCKOPT_OK 0\n#define CURL_SOCKOPT_ERROR 1 /* causes libcurl to abort and return\n                                CURLE_ABORTED_BY_CALLBACK */\n#define CURL_SOCKOPT_ALREADY_CONNECTED 2\n\ntypedef int (*curl_sockopt_callback)(void *clientp,\n                                     curl_socket_t curlfd,\n                                     curlsocktype purpose);\n\nstruct curl_sockaddr {\n  int family;\n  int socktype;\n  int protocol;\n  unsigned int addrlen; /* addrlen was a socklen_t type before 7.18.0 but it\n                           turned really ugly and painful on the systems that\n                           lack this type */\n  struct sockaddr addr;\n};\n\ntypedef curl_socket_t\n(*curl_opensocket_callback)(void *clientp,\n                            curlsocktype purpose,\n                            struct curl_sockaddr *address);\n\ntypedef int\n(*curl_closesocket_callback)(void *clientp, curl_socket_t item);\n\ntypedef enum {\n  CURLIOE_OK,            /* I/O operation successful */\n  CURLIOE_UNKNOWNCMD,    /* command was unknown to callback */\n  CURLIOE_FAILRESTART,   /* failed to restart the read */\n  CURLIOE_LAST           /* never use */\n} curlioerr;\n\ntypedef enum  {\n  CURLIOCMD_NOP,         /* no operation */\n  CURLIOCMD_RESTARTREAD, /* restart the read stream from start */\n  CURLIOCMD_LAST         /* never use */\n} curliocmd;\n\ntypedef curlioerr (*curl_ioctl_callback)(CURL *handle,\n                                         int cmd,\n                                         void *clientp);\n\n/*\n * The following typedef's are signatures of malloc, free, realloc, strdup and\n * calloc respectively.  Function pointers of these types can be passed to the\n * curl_global_init_mem() function to set user defined memory management\n * callback routines.\n */\ntypedef void *(*curl_malloc_callback)(size_t size);\ntypedef void (*curl_free_callback)(void *ptr);\ntypedef void *(*curl_realloc_callback)(void *ptr, size_t size);\ntypedef char *(*curl_strdup_callback)(const char *str);\ntypedef void *(*curl_calloc_callback)(size_t nmemb, size_t size);\n\n/* the kind of data that is passed to information_callback*/\ntypedef enum {\n  CURLINFO_TEXT = 0,\n  CURLINFO_HEADER_IN,    /* 1 */\n  CURLINFO_HEADER_OUT,   /* 2 */\n  CURLINFO_DATA_IN,      /* 3 */\n  CURLINFO_DATA_OUT,     /* 4 */\n  CURLINFO_SSL_DATA_IN,  /* 5 */\n  CURLINFO_SSL_DATA_OUT, /* 6 */\n  CURLINFO_END\n} curl_infotype;\n\ntypedef int (*curl_debug_callback)\n       (CURL *handle,      /* the handle/transfer this concerns */\n        curl_infotype type, /* what kind of data */\n        char *data,        /* points to the data */\n        size_t size,       /* size of the data pointed to */\n        void *userptr);    /* whatever the user please */\n\n/* All possible error codes from all sorts of curl functions. Future versions\n   may return other values, stay prepared.\n\n   Always add new return codes last. Never *EVER* remove any. The return\n   codes must remain the same!\n */\n\ntypedef enum {\n  CURLE_OK = 0,\n  CURLE_UNSUPPORTED_PROTOCOL,    /* 1 */\n  CURLE_FAILED_INIT,             /* 2 */\n  CURLE_URL_MALFORMAT,           /* 3 */\n  CURLE_NOT_BUILT_IN,            /* 4 - [was obsoleted in August 2007 for\n                                    7.17.0, reused in April 2011 for 7.21.5] */\n  CURLE_COULDNT_RESOLVE_PROXY,   /* 5 */\n  CURLE_COULDNT_RESOLVE_HOST,    /* 6 */\n  CURLE_COULDNT_CONNECT,         /* 7 */\n  CURLE_FTP_WEIRD_SERVER_REPLY,  /* 8 */\n  CURLE_REMOTE_ACCESS_DENIED,    /* 9 a service was denied by the server\n                                    due to lack of access - when login fails\n                                    this is not returned. */\n  CURLE_FTP_ACCEPT_FAILED,       /* 10 - [was obsoleted in April 2006 for\n                                    7.15.4, reused in Dec 2011 for 7.24.0]*/\n  CURLE_FTP_WEIRD_PASS_REPLY,    /* 11 */\n  CURLE_FTP_ACCEPT_TIMEOUT,      /* 12 - timeout occurred accepting server\n                                    [was obsoleted in August 2007 for 7.17.0,\n                                    reused in Dec 2011 for 7.24.0]*/\n  CURLE_FTP_WEIRD_PASV_REPLY,    /* 13 */\n  CURLE_FTP_WEIRD_227_FORMAT,    /* 14 */\n  CURLE_FTP_CANT_GET_HOST,       /* 15 */\n  CURLE_HTTP2,                   /* 16 - A problem in the http2 framing layer.\n                                    [was obsoleted in August 2007 for 7.17.0,\n                                    reused in July 2014 for 7.38.0] */\n  CURLE_FTP_COULDNT_SET_TYPE,    /* 17 */\n  CURLE_PARTIAL_FILE,            /* 18 */\n  CURLE_FTP_COULDNT_RETR_FILE,   /* 19 */\n  CURLE_OBSOLETE20,              /* 20 - NOT USED */\n  CURLE_QUOTE_ERROR,             /* 21 - quote command failure */\n  CURLE_HTTP_RETURNED_ERROR,     /* 22 */\n  CURLE_WRITE_ERROR,             /* 23 */\n  CURLE_OBSOLETE24,              /* 24 - NOT USED */\n  CURLE_UPLOAD_FAILED,           /* 25 - failed upload \"command\" */\n  CURLE_READ_ERROR,              /* 26 - couldn't open/read from file */\n  CURLE_OUT_OF_MEMORY,           /* 27 */\n  /* Note: CURLE_OUT_OF_MEMORY may sometimes indicate a conversion error\n           instead of a memory allocation error if CURL_DOES_CONVERSIONS\n           is defined\n  */\n  CURLE_OPERATION_TIMEDOUT,      /* 28 - the timeout time was reached */\n  CURLE_OBSOLETE29,              /* 29 - NOT USED */\n  CURLE_FTP_PORT_FAILED,         /* 30 - FTP PORT operation failed */\n  CURLE_FTP_COULDNT_USE_REST,    /* 31 - the REST command failed */\n  CURLE_OBSOLETE32,              /* 32 - NOT USED */\n  CURLE_RANGE_ERROR,             /* 33 - RANGE \"command\" didn't work */\n  CURLE_HTTP_POST_ERROR,         /* 34 */\n  CURLE_SSL_CONNECT_ERROR,       /* 35 - wrong when connecting with SSL */\n  CURLE_BAD_DOWNLOAD_RESUME,     /* 36 - couldn't resume download */\n  CURLE_FILE_COULDNT_READ_FILE,  /* 37 */\n  CURLE_LDAP_CANNOT_BIND,        /* 38 */\n  CURLE_LDAP_SEARCH_FAILED,      /* 39 */\n  CURLE_OBSOLETE40,              /* 40 - NOT USED */\n  CURLE_FUNCTION_NOT_FOUND,      /* 41 */\n  CURLE_ABORTED_BY_CALLBACK,     /* 42 */\n  CURLE_BAD_FUNCTION_ARGUMENT,   /* 43 */\n  CURLE_OBSOLETE44,              /* 44 - NOT USED */\n  CURLE_INTERFACE_FAILED,        /* 45 - CURLOPT_INTERFACE failed */\n  CURLE_OBSOLETE46,              /* 46 - NOT USED */\n  CURLE_TOO_MANY_REDIRECTS ,     /* 47 - catch endless re-direct loops */\n  CURLE_UNKNOWN_OPTION,          /* 48 - User specified an unknown option */\n  CURLE_TELNET_OPTION_SYNTAX ,   /* 49 - Malformed telnet option */\n  CURLE_OBSOLETE50,              /* 50 - NOT USED */\n  CURLE_PEER_FAILED_VERIFICATION, /* 51 - peer's certificate or fingerprint\n                                     wasn't verified fine */\n  CURLE_GOT_NOTHING,             /* 52 - when this is a specific error */\n  CURLE_SSL_ENGINE_NOTFOUND,     /* 53 - SSL crypto engine not found */\n  CURLE_SSL_ENGINE_SETFAILED,    /* 54 - can not set SSL crypto engine as\n                                    default */\n  CURLE_SEND_ERROR,              /* 55 - failed sending network data */\n  CURLE_RECV_ERROR,              /* 56 - failure in receiving network data */\n  CURLE_OBSOLETE57,              /* 57 - NOT IN USE */\n  CURLE_SSL_CERTPROBLEM,         /* 58 - problem with the local certificate */\n  CURLE_SSL_CIPHER,              /* 59 - couldn't use specified cipher */\n  CURLE_SSL_CACERT,              /* 60 - problem with the CA cert (path?) */\n  CURLE_BAD_CONTENT_ENCODING,    /* 61 - Unrecognized/bad encoding */\n  CURLE_LDAP_INVALID_URL,        /* 62 - Invalid LDAP URL */\n  CURLE_FILESIZE_EXCEEDED,       /* 63 - Maximum file size exceeded */\n  CURLE_USE_SSL_FAILED,          /* 64 - Requested FTP SSL level failed */\n  CURLE_SEND_FAIL_REWIND,        /* 65 - Sending the data requires a rewind\n                                    that failed */\n  CURLE_SSL_ENGINE_INITFAILED,   /* 66 - failed to initialise ENGINE */\n  CURLE_LOGIN_DENIED,            /* 67 - user, password or similar was not\n                                    accepted and we failed to login */\n  CURLE_TFTP_NOTFOUND,           /* 68 - file not found on server */\n  CURLE_TFTP_PERM,               /* 69 - permission problem on server */\n  CURLE_REMOTE_DISK_FULL,        /* 70 - out of disk space on server */\n  CURLE_TFTP_ILLEGAL,            /* 71 - Illegal TFTP operation */\n  CURLE_TFTP_UNKNOWNID,          /* 72 - Unknown transfer ID */\n  CURLE_REMOTE_FILE_EXISTS,      /* 73 - File already exists */\n  CURLE_TFTP_NOSUCHUSER,         /* 74 - No such user */\n  CURLE_CONV_FAILED,             /* 75 - conversion failed */\n  CURLE_CONV_REQD,               /* 76 - caller must register conversion\n                                    callbacks using curl_easy_setopt options\n                                    CURLOPT_CONV_FROM_NETWORK_FUNCTION,\n                                    CURLOPT_CONV_TO_NETWORK_FUNCTION, and\n                                    CURLOPT_CONV_FROM_UTF8_FUNCTION */\n  CURLE_SSL_CACERT_BADFILE,      /* 77 - could not load CACERT file, missing\n                                    or wrong format */\n  CURLE_REMOTE_FILE_NOT_FOUND,   /* 78 - remote file not found */\n  CURLE_SSH,                     /* 79 - error from the SSH layer, somewhat\n                                    generic so the error message will be of\n                                    interest when this has happened */\n\n  CURLE_SSL_SHUTDOWN_FAILED,     /* 80 - Failed to shut down the SSL\n                                    connection */\n  CURLE_AGAIN,                   /* 81 - socket is not ready for send/recv,\n                                    wait till it's ready and try again (Added\n                                    in 7.18.2) */\n  CURLE_SSL_CRL_BADFILE,         /* 82 - could not load CRL file, missing or\n                                    wrong format (Added in 7.19.0) */\n  CURLE_SSL_ISSUER_ERROR,        /* 83 - Issuer check failed.  (Added in\n                                    7.19.0) */\n  CURLE_FTP_PRET_FAILED,         /* 84 - a PRET command failed */\n  CURLE_RTSP_CSEQ_ERROR,         /* 85 - mismatch of RTSP CSeq numbers */\n  CURLE_RTSP_SESSION_ERROR,      /* 86 - mismatch of RTSP Session Ids */\n  CURLE_FTP_BAD_FILE_LIST,       /* 87 - unable to parse FTP file list */\n  CURLE_CHUNK_FAILED,            /* 88 - chunk callback reported error */\n  CURLE_NO_CONNECTION_AVAILABLE, /* 89 - No connection available, the\n                                    session will be queued */\n  CURL_LAST /* never use! */\n} CURLcode;\n\n#ifndef CURL_NO_OLDIES /* define this to test if your app builds with all\n                          the obsolete stuff removed! */\n\n/* Previously obsolete error code re-used in 7.38.0 */\n#define CURLE_OBSOLETE16 CURLE_HTTP2\n\n/* Previously obsolete error codes re-used in 7.24.0 */\n#define CURLE_OBSOLETE10 CURLE_FTP_ACCEPT_FAILED\n#define CURLE_OBSOLETE12 CURLE_FTP_ACCEPT_TIMEOUT\n\n/*  compatibility with older names */\n#define CURLOPT_ENCODING CURLOPT_ACCEPT_ENCODING\n\n/* The following were added in 7.21.5, April 2011 */\n#define CURLE_UNKNOWN_TELNET_OPTION CURLE_UNKNOWN_OPTION\n\n/* The following were added in 7.17.1 */\n/* These are scheduled to disappear by 2009 */\n#define CURLE_SSL_PEER_CERTIFICATE CURLE_PEER_FAILED_VERIFICATION\n\n/* The following were added in 7.17.0 */\n/* These are scheduled to disappear by 2009 */\n#define CURLE_OBSOLETE CURLE_OBSOLETE50 /* no one should be using this! */\n#define CURLE_BAD_PASSWORD_ENTERED CURLE_OBSOLETE46\n#define CURLE_BAD_CALLING_ORDER CURLE_OBSOLETE44\n#define CURLE_FTP_USER_PASSWORD_INCORRECT CURLE_OBSOLETE10\n#define CURLE_FTP_CANT_RECONNECT CURLE_OBSOLETE16\n#define CURLE_FTP_COULDNT_GET_SIZE CURLE_OBSOLETE32\n#define CURLE_FTP_COULDNT_SET_ASCII CURLE_OBSOLETE29\n#define CURLE_FTP_WEIRD_USER_REPLY CURLE_OBSOLETE12\n#define CURLE_FTP_WRITE_ERROR CURLE_OBSOLETE20\n#define CURLE_LIBRARY_NOT_FOUND CURLE_OBSOLETE40\n#define CURLE_MALFORMAT_USER CURLE_OBSOLETE24\n#define CURLE_SHARE_IN_USE CURLE_OBSOLETE57\n#define CURLE_URL_MALFORMAT_USER CURLE_NOT_BUILT_IN\n\n#define CURLE_FTP_ACCESS_DENIED CURLE_REMOTE_ACCESS_DENIED\n#define CURLE_FTP_COULDNT_SET_BINARY CURLE_FTP_COULDNT_SET_TYPE\n#define CURLE_FTP_QUOTE_ERROR CURLE_QUOTE_ERROR\n#define CURLE_TFTP_DISKFULL CURLE_REMOTE_DISK_FULL\n#define CURLE_TFTP_EXISTS CURLE_REMOTE_FILE_EXISTS\n#define CURLE_HTTP_RANGE_ERROR CURLE_RANGE_ERROR\n#define CURLE_FTP_SSL_FAILED CURLE_USE_SSL_FAILED\n\n/* The following were added earlier */\n\n#define CURLE_OPERATION_TIMEOUTED CURLE_OPERATION_TIMEDOUT\n\n#define CURLE_HTTP_NOT_FOUND CURLE_HTTP_RETURNED_ERROR\n#define CURLE_HTTP_PORT_FAILED CURLE_INTERFACE_FAILED\n#define CURLE_FTP_COULDNT_STOR_FILE CURLE_UPLOAD_FAILED\n\n#define CURLE_FTP_PARTIAL_FILE CURLE_PARTIAL_FILE\n#define CURLE_FTP_BAD_DOWNLOAD_RESUME CURLE_BAD_DOWNLOAD_RESUME\n\n/* This was the error code 50 in 7.7.3 and a few earlier versions, this\n   is no longer used by libcurl but is instead #defined here only to not\n   make programs break */\n#define CURLE_ALREADY_COMPLETE 99999\n\n/* Provide defines for really old option names */\n#define CURLOPT_FILE CURLOPT_WRITEDATA /* name changed in 7.9.7 */\n#define CURLOPT_INFILE CURLOPT_READDATA /* name changed in 7.9.7 */\n#define CURLOPT_WRITEHEADER CURLOPT_HEADERDATA\n\n/* Since long deprecated options with no code in the lib that does anything\n   with them. */\n#define CURLOPT_WRITEINFO CURLOPT_OBSOLETE40\n#define CURLOPT_CLOSEPOLICY CURLOPT_OBSOLETE72\n\n#endif /*!CURL_NO_OLDIES*/\n\n/* This prototype applies to all conversion callbacks */\ntypedef CURLcode (*curl_conv_callback)(char *buffer, size_t length);\n\ntypedef CURLcode (*curl_ssl_ctx_callback)(CURL *curl,    /* easy handle */\n                                          void *ssl_ctx, /* actually an\n                                                            OpenSSL SSL_CTX */\n                                          void *userptr);\n\ntypedef enum {\n  CURLPROXY_HTTP = 0,   /* added in 7.10, new in 7.19.4 default is to use\n                           CONNECT HTTP/1.1 */\n  CURLPROXY_HTTP_1_0 = 1,   /* added in 7.19.4, force to use CONNECT\n                               HTTP/1.0  */\n  CURLPROXY_SOCKS4 = 4, /* support added in 7.15.2, enum existed already\n                           in 7.10 */\n  CURLPROXY_SOCKS5 = 5, /* added in 7.10 */\n  CURLPROXY_SOCKS4A = 6, /* added in 7.18.0 */\n  CURLPROXY_SOCKS5_HOSTNAME = 7 /* Use the SOCKS5 protocol but pass along the\n                                   host name rather than the IP address. added\n                                   in 7.18.0 */\n} curl_proxytype;  /* this enum was added in 7.10 */\n\n/*\n * Bitmasks for CURLOPT_HTTPAUTH and CURLOPT_PROXYAUTH options:\n *\n * CURLAUTH_NONE         - No HTTP authentication\n * CURLAUTH_BASIC        - HTTP Basic authentication (default)\n * CURLAUTH_DIGEST       - HTTP Digest authentication\n * CURLAUTH_NEGOTIATE    - HTTP Negotiate (SPNEGO) authentication\n * CURLAUTH_GSSNEGOTIATE - Alias for CURLAUTH_NEGOTIATE (deprecated)\n * CURLAUTH_NTLM         - HTTP NTLM authentication\n * CURLAUTH_DIGEST_IE    - HTTP Digest authentication with IE flavour\n * CURLAUTH_NTLM_WB      - HTTP NTLM authentication delegated to winbind helper\n * CURLAUTH_ONLY         - Use together with a single other type to force no\n *                         authentication or just that single type\n * CURLAUTH_ANY          - All fine types set\n * CURLAUTH_ANYSAFE      - All fine types except Basic\n */\n\n#define CURLAUTH_NONE         ((unsigned long)0)\n#define CURLAUTH_BASIC        (((unsigned long)1)<<0)\n#define CURLAUTH_DIGEST       (((unsigned long)1)<<1)\n#define CURLAUTH_NEGOTIATE    (((unsigned long)1)<<2)\n/* Deprecated since the advent of CURLAUTH_NEGOTIATE */\n#define CURLAUTH_GSSNEGOTIATE CURLAUTH_NEGOTIATE\n#define CURLAUTH_NTLM         (((unsigned long)1)<<3)\n#define CURLAUTH_DIGEST_IE    (((unsigned long)1)<<4)\n#define CURLAUTH_NTLM_WB      (((unsigned long)1)<<5)\n#define CURLAUTH_ONLY         (((unsigned long)1)<<31)\n#define CURLAUTH_ANY          (~CURLAUTH_DIGEST_IE)\n#define CURLAUTH_ANYSAFE      (~(CURLAUTH_BASIC|CURLAUTH_DIGEST_IE))\n\n#define CURLSSH_AUTH_ANY       ~0     /* all types supported by the server */\n#define CURLSSH_AUTH_NONE      0      /* none allowed, silly but complete */\n#define CURLSSH_AUTH_PUBLICKEY (1<<0) /* public/private key files */\n#define CURLSSH_AUTH_PASSWORD  (1<<1) /* password */\n#define CURLSSH_AUTH_HOST      (1<<2) /* host key files */\n#define CURLSSH_AUTH_KEYBOARD  (1<<3) /* keyboard interactive */\n#define CURLSSH_AUTH_AGENT     (1<<4) /* agent (ssh-agent, pageant...) */\n#define CURLSSH_AUTH_DEFAULT CURLSSH_AUTH_ANY\n\n#define CURLGSSAPI_DELEGATION_NONE        0      /* no delegation (default) */\n#define CURLGSSAPI_DELEGATION_POLICY_FLAG (1<<0) /* if permitted by policy */\n#define CURLGSSAPI_DELEGATION_FLAG        (1<<1) /* delegate always */\n\n#define CURL_ERROR_SIZE 256\n\nenum curl_khtype {\n  CURLKHTYPE_UNKNOWN,\n  CURLKHTYPE_RSA1,\n  CURLKHTYPE_RSA,\n  CURLKHTYPE_DSS\n};\n\nstruct curl_khkey {\n  const char *key; /* points to a zero-terminated string encoded with base64\n                      if len is zero, otherwise to the \"raw\" data */\n  size_t len;\n  enum curl_khtype keytype;\n};\n\n/* this is the set of return values expected from the curl_sshkeycallback\n   callback */\nenum curl_khstat {\n  CURLKHSTAT_FINE_ADD_TO_FILE,\n  CURLKHSTAT_FINE,\n  CURLKHSTAT_REJECT, /* reject the connection, return an error */\n  CURLKHSTAT_DEFER,  /* do not accept it, but we can't answer right now so\n                        this causes a CURLE_DEFER error but otherwise the\n                        connection will be left intact etc */\n  CURLKHSTAT_LAST    /* not for use, only a marker for last-in-list */\n};\n\n/* this is the set of status codes pass in to the callback */\nenum curl_khmatch {\n  CURLKHMATCH_OK,       /* match */\n  CURLKHMATCH_MISMATCH, /* host found, key mismatch! */\n  CURLKHMATCH_MISSING,  /* no matching host/key found */\n  CURLKHMATCH_LAST      /* not for use, only a marker for last-in-list */\n};\n\ntypedef int\n  (*curl_sshkeycallback) (CURL *easy,     /* easy handle */\n                          const struct curl_khkey *knownkey, /* known */\n                          const struct curl_khkey *foundkey, /* found */\n                          enum curl_khmatch, /* libcurl's view on the keys */\n                          void *clientp); /* custom pointer passed from app */\n\n/* parameter for the CURLOPT_USE_SSL option */\ntypedef enum {\n  CURLUSESSL_NONE,    /* do not attempt to use SSL */\n  CURLUSESSL_TRY,     /* try using SSL, proceed anyway otherwise */\n  CURLUSESSL_CONTROL, /* SSL for the control connection or fail */\n  CURLUSESSL_ALL,     /* SSL for all communication or fail */\n  CURLUSESSL_LAST     /* not an option, never use */\n} curl_usessl;\n\n/* Definition of bits for the CURLOPT_SSL_OPTIONS argument: */\n\n/* - ALLOW_BEAST tells libcurl to allow the BEAST SSL vulnerability in the\n   name of improving interoperability with older servers. Some SSL libraries\n   have introduced work-arounds for this flaw but those work-arounds sometimes\n   make the SSL communication fail. To regain functionality with those broken\n   servers, a user can this way allow the vulnerability back. */\n#define CURLSSLOPT_ALLOW_BEAST (1<<0)\n\n#ifndef CURL_NO_OLDIES /* define this to test if your app builds with all\n                          the obsolete stuff removed! */\n\n/* Backwards compatibility with older names */\n/* These are scheduled to disappear by 2009 */\n\n#define CURLFTPSSL_NONE CURLUSESSL_NONE\n#define CURLFTPSSL_TRY CURLUSESSL_TRY\n#define CURLFTPSSL_CONTROL CURLUSESSL_CONTROL\n#define CURLFTPSSL_ALL CURLUSESSL_ALL\n#define CURLFTPSSL_LAST CURLUSESSL_LAST\n#define curl_ftpssl curl_usessl\n#endif /*!CURL_NO_OLDIES*/\n\n/* parameter for the CURLOPT_FTP_SSL_CCC option */\ntypedef enum {\n  CURLFTPSSL_CCC_NONE,    /* do not send CCC */\n  CURLFTPSSL_CCC_PASSIVE, /* Let the server initiate the shutdown */\n  CURLFTPSSL_CCC_ACTIVE,  /* Initiate the shutdown */\n  CURLFTPSSL_CCC_LAST     /* not an option, never use */\n} curl_ftpccc;\n\n/* parameter for the CURLOPT_FTPSSLAUTH option */\ntypedef enum {\n  CURLFTPAUTH_DEFAULT, /* let libcurl decide */\n  CURLFTPAUTH_SSL,     /* use \"AUTH SSL\" */\n  CURLFTPAUTH_TLS,     /* use \"AUTH TLS\" */\n  CURLFTPAUTH_LAST /* not an option, never use */\n} curl_ftpauth;\n\n/* parameter for the CURLOPT_FTP_CREATE_MISSING_DIRS option */\ntypedef enum {\n  CURLFTP_CREATE_DIR_NONE,  /* do NOT create missing dirs! */\n  CURLFTP_CREATE_DIR,       /* (FTP/SFTP) if CWD fails, try MKD and then CWD\n                               again if MKD succeeded, for SFTP this does\n                               similar magic */\n  CURLFTP_CREATE_DIR_RETRY, /* (FTP only) if CWD fails, try MKD and then CWD\n                               again even if MKD failed! */\n  CURLFTP_CREATE_DIR_LAST   /* not an option, never use */\n} curl_ftpcreatedir;\n\n/* parameter for the CURLOPT_FTP_FILEMETHOD option */\ntypedef enum {\n  CURLFTPMETHOD_DEFAULT,   /* let libcurl pick */\n  CURLFTPMETHOD_MULTICWD,  /* single CWD operation for each path part */\n  CURLFTPMETHOD_NOCWD,     /* no CWD at all */\n  CURLFTPMETHOD_SINGLECWD, /* one CWD to full dir, then work on file */\n  CURLFTPMETHOD_LAST       /* not an option, never use */\n} curl_ftpmethod;\n\n/* bitmask defines for CURLOPT_HEADEROPT */\n#define CURLHEADER_UNIFIED  0\n#define CURLHEADER_SEPARATE (1<<0)\n\n/* CURLPROTO_ defines are for the CURLOPT_*PROTOCOLS options */\n#define CURLPROTO_HTTP   (1<<0)\n#define CURLPROTO_HTTPS  (1<<1)\n#define CURLPROTO_FTP    (1<<2)\n#define CURLPROTO_FTPS   (1<<3)\n#define CURLPROTO_SCP    (1<<4)\n#define CURLPROTO_SFTP   (1<<5)\n#define CURLPROTO_TELNET (1<<6)\n#define CURLPROTO_LDAP   (1<<7)\n#define CURLPROTO_LDAPS  (1<<8)\n#define CURLPROTO_DICT   (1<<9)\n#define CURLPROTO_FILE   (1<<10)\n#define CURLPROTO_TFTP   (1<<11)\n#define CURLPROTO_IMAP   (1<<12)\n#define CURLPROTO_IMAPS  (1<<13)\n#define CURLPROTO_POP3   (1<<14)\n#define CURLPROTO_POP3S  (1<<15)\n#define CURLPROTO_SMTP   (1<<16)\n#define CURLPROTO_SMTPS  (1<<17)\n#define CURLPROTO_RTSP   (1<<18)\n#define CURLPROTO_RTMP   (1<<19)\n#define CURLPROTO_RTMPT  (1<<20)\n#define CURLPROTO_RTMPE  (1<<21)\n#define CURLPROTO_RTMPTE (1<<22)\n#define CURLPROTO_RTMPS  (1<<23)\n#define CURLPROTO_RTMPTS (1<<24)\n#define CURLPROTO_GOPHER (1<<25)\n#define CURLPROTO_ALL    (~0) /* enable everything */\n\n/* long may be 32 or 64 bits, but we should never depend on anything else\n   but 32 */\n#define CURLOPTTYPE_LONG          0\n#define CURLOPTTYPE_OBJECTPOINT   10000\n#define CURLOPTTYPE_FUNCTIONPOINT 20000\n#define CURLOPTTYPE_OFF_T         30000\n\n/* name is uppercase CURLOPT_<name>,\n   type is one of the defined CURLOPTTYPE_<type>\n   number is unique identifier */\n#ifdef CINIT\n#undef CINIT\n#endif\n\n#ifdef CURL_ISOCPP\n#define CINIT(na,t,nu) CURLOPT_ ## na = CURLOPTTYPE_ ## t + nu\n#else\n/* The macro \"##\" is ISO C, we assume pre-ISO C doesn't support it. */\n#define LONG          CURLOPTTYPE_LONG\n#define OBJECTPOINT   CURLOPTTYPE_OBJECTPOINT\n#define FUNCTIONPOINT CURLOPTTYPE_FUNCTIONPOINT\n#define OFF_T         CURLOPTTYPE_OFF_T\n#define CINIT(name,type,number) CURLOPT_/**/name = type + number\n#endif\n\n/*\n * This macro-mania below setups the CURLOPT_[what] enum, to be used with\n * curl_easy_setopt(). The first argument in the CINIT() macro is the [what]\n * word.\n */\n\ntypedef enum {\n  /* This is the FILE * or void * the regular output should be written to. */\n  CINIT(WRITEDATA, OBJECTPOINT, 1),\n\n  /* The full URL to get/put */\n  CINIT(URL,  OBJECTPOINT, 2),\n\n  /* Port number to connect to, if other than default. */\n  CINIT(PORT, LONG, 3),\n\n  /* Name of proxy to use. */\n  CINIT(PROXY, OBJECTPOINT, 4),\n\n  /* \"user:password;options\" to use when fetching. */\n  CINIT(USERPWD, OBJECTPOINT, 5),\n\n  /* \"user:password\" to use with proxy. */\n  CINIT(PROXYUSERPWD, OBJECTPOINT, 6),\n\n  /* Range to get, specified as an ASCII string. */\n  CINIT(RANGE, OBJECTPOINT, 7),\n\n  /* not used */\n\n  /* Specified file stream to upload from (use as input): */\n  CINIT(READDATA, OBJECTPOINT, 9),\n\n  /* Buffer to receive error messages in, must be at least CURL_ERROR_SIZE\n   * bytes big. If this is not used, error messages go to stderr instead: */\n  CINIT(ERRORBUFFER, OBJECTPOINT, 10),\n\n  /* Function that will be called to store the output (instead of fwrite). The\n   * parameters will use fwrite() syntax, make sure to follow them. */\n  CINIT(WRITEFUNCTION, FUNCTIONPOINT, 11),\n\n  /* Function that will be called to read the input (instead of fread). The\n   * parameters will use fread() syntax, make sure to follow them. */\n  CINIT(READFUNCTION, FUNCTIONPOINT, 12),\n\n  /* Time-out the read operation after this amount of seconds */\n  CINIT(TIMEOUT, LONG, 13),\n\n  /* If the CURLOPT_INFILE is used, this can be used to inform libcurl about\n   * how large the file being sent really is. That allows better error\n   * checking and better verifies that the upload was successful. -1 means\n   * unknown size.\n   *\n   * For large file support, there is also a _LARGE version of the key\n   * which takes an off_t type, allowing platforms with larger off_t\n   * sizes to handle larger files.  See below for INFILESIZE_LARGE.\n   */\n  CINIT(INFILESIZE, LONG, 14),\n\n  /* POST static input fields. */\n  CINIT(POSTFIELDS, OBJECTPOINT, 15),\n\n  /* Set the referrer page (needed by some CGIs) */\n  CINIT(REFERER, OBJECTPOINT, 16),\n\n  /* Set the FTP PORT string (interface name, named or numerical IP address)\n     Use i.e '-' to use default address. */\n  CINIT(FTPPORT, OBJECTPOINT, 17),\n\n  /* Set the User-Agent string (examined by some CGIs) */\n  CINIT(USERAGENT, OBJECTPOINT, 18),\n\n  /* If the download receives less than \"low speed limit\" bytes/second\n   * during \"low speed time\" seconds, the operations is aborted.\n   * You could i.e if you have a pretty high speed connection, abort if\n   * it is less than 2000 bytes/sec during 20 seconds.\n   */\n\n  /* Set the \"low speed limit\" */\n  CINIT(LOW_SPEED_LIMIT, LONG, 19),\n\n  /* Set the \"low speed time\" */\n  CINIT(LOW_SPEED_TIME, LONG, 20),\n\n  /* Set the continuation offset.\n   *\n   * Note there is also a _LARGE version of this key which uses\n   * off_t types, allowing for large file offsets on platforms which\n   * use larger-than-32-bit off_t's.  Look below for RESUME_FROM_LARGE.\n   */\n  CINIT(RESUME_FROM, LONG, 21),\n\n  /* Set cookie in request: */\n  CINIT(COOKIE, OBJECTPOINT, 22),\n\n  /* This points to a linked list of headers, struct curl_slist kind. This\n     list is also used for RTSP (in spite of its name) */\n  CINIT(HTTPHEADER, OBJECTPOINT, 23),\n\n  /* This points to a linked list of post entries, struct curl_httppost */\n  CINIT(HTTPPOST, OBJECTPOINT, 24),\n\n  /* name of the file keeping your private SSL-certificate */\n  CINIT(SSLCERT, OBJECTPOINT, 25),\n\n  /* password for the SSL or SSH private key */\n  CINIT(KEYPASSWD, OBJECTPOINT, 26),\n\n  /* send TYPE parameter? */\n  CINIT(CRLF, LONG, 27),\n\n  /* send linked-list of QUOTE commands */\n  CINIT(QUOTE, OBJECTPOINT, 28),\n\n  /* send FILE * or void * to store headers to, if you use a callback it\n     is simply passed to the callback unmodified */\n  CINIT(HEADERDATA, OBJECTPOINT, 29),\n\n  /* point to a file to read the initial cookies from, also enables\n     \"cookie awareness\" */\n  CINIT(COOKIEFILE, OBJECTPOINT, 31),\n\n  /* What version to specifically try to use.\n     See CURL_SSLVERSION defines below. */\n  CINIT(SSLVERSION, LONG, 32),\n\n  /* What kind of HTTP time condition to use, see defines */\n  CINIT(TIMECONDITION, LONG, 33),\n\n  /* Time to use with the above condition. Specified in number of seconds\n     since 1 Jan 1970 */\n  CINIT(TIMEVALUE, LONG, 34),\n\n  /* 35 = OBSOLETE */\n\n  /* Custom request, for customizing the get command like\n     HTTP: DELETE, TRACE and others\n     FTP: to use a different list command\n     */\n  CINIT(CUSTOMREQUEST, OBJECTPOINT, 36),\n\n  /* HTTP request, for odd commands like DELETE, TRACE and others */\n  CINIT(STDERR, OBJECTPOINT, 37),\n\n  /* 38 is not used */\n\n  /* send linked-list of post-transfer QUOTE commands */\n  CINIT(POSTQUOTE, OBJECTPOINT, 39),\n\n  CINIT(OBSOLETE40, OBJECTPOINT, 40), /* OBSOLETE, do not use! */\n\n  CINIT(VERBOSE, LONG, 41),      /* talk a lot */\n  CINIT(HEADER, LONG, 42),       /* throw the header out too */\n  CINIT(NOPROGRESS, LONG, 43),   /* shut off the progress meter */\n  CINIT(NOBODY, LONG, 44),       /* use HEAD to get http document */\n  CINIT(FAILONERROR, LONG, 45),  /* no output on http error codes >= 300 */\n  CINIT(UPLOAD, LONG, 46),       /* this is an upload */\n  CINIT(POST, LONG, 47),         /* HTTP POST method */\n  CINIT(DIRLISTONLY, LONG, 48),  /* bare names when listing directories */\n\n  CINIT(APPEND, LONG, 50),       /* Append instead of overwrite on upload! */\n\n  /* Specify whether to read the user+password from the .netrc or the URL.\n   * This must be one of the CURL_NETRC_* enums below. */\n  CINIT(NETRC, LONG, 51),\n\n  CINIT(FOLLOWLOCATION, LONG, 52),  /* use Location: Luke! */\n\n  CINIT(TRANSFERTEXT, LONG, 53), /* transfer data in text/ASCII format */\n  CINIT(PUT, LONG, 54),          /* HTTP PUT */\n\n  /* 55 = OBSOLETE */\n\n  /* DEPRECATED\n   * Function that will be called instead of the internal progress display\n   * function. This function should be defined as the curl_progress_callback\n   * prototype defines. */\n  CINIT(PROGRESSFUNCTION, FUNCTIONPOINT, 56),\n\n  /* Data passed to the CURLOPT_PROGRESSFUNCTION and CURLOPT_XFERINFOFUNCTION\n     callbacks */\n  CINIT(PROGRESSDATA, OBJECTPOINT, 57),\n#define CURLOPT_XFERINFODATA CURLOPT_PROGRESSDATA\n\n  /* We want the referrer field set automatically when following locations */\n  CINIT(AUTOREFERER, LONG, 58),\n\n  /* Port of the proxy, can be set in the proxy string as well with:\n     \"[host]:[port]\" */\n  CINIT(PROXYPORT, LONG, 59),\n\n  /* size of the POST input data, if strlen() is not good to use */\n  CINIT(POSTFIELDSIZE, LONG, 60),\n\n  /* tunnel non-http operations through a HTTP proxy */\n  CINIT(HTTPPROXYTUNNEL, LONG, 61),\n\n  /* Set the interface string to use as outgoing network interface */\n  CINIT(INTERFACE, OBJECTPOINT, 62),\n\n  /* Set the krb4/5 security level, this also enables krb4/5 awareness.  This\n   * is a string, 'clear', 'safe', 'confidential' or 'private'.  If the string\n   * is set but doesn't match one of these, 'private' will be used.  */\n  CINIT(KRBLEVEL, OBJECTPOINT, 63),\n\n  /* Set if we should verify the peer in ssl handshake, set 1 to verify. */\n  CINIT(SSL_VERIFYPEER, LONG, 64),\n\n  /* The CApath or CAfile used to validate the peer certificate\n     this option is used only if SSL_VERIFYPEER is true */\n  CINIT(CAINFO, OBJECTPOINT, 65),\n\n  /* 66 = OBSOLETE */\n  /* 67 = OBSOLETE */\n\n  /* Maximum number of http redirects to follow */\n  CINIT(MAXREDIRS, LONG, 68),\n\n  /* Pass a long set to 1 to get the date of the requested document (if\n     possible)! Pass a zero to shut it off. */\n  CINIT(FILETIME, LONG, 69),\n\n  /* This points to a linked list of telnet options */\n  CINIT(TELNETOPTIONS, OBJECTPOINT, 70),\n\n  /* Max amount of cached alive connections */\n  CINIT(MAXCONNECTS, LONG, 71),\n\n  CINIT(OBSOLETE72, LONG, 72), /* OBSOLETE, do not use! */\n\n  /* 73 = OBSOLETE */\n\n  /* Set to explicitly use a new connection for the upcoming transfer.\n     Do not use this unless you're absolutely sure of this, as it makes the\n     operation slower and is less friendly for the network. */\n  CINIT(FRESH_CONNECT, LONG, 74),\n\n  /* Set to explicitly forbid the upcoming transfer's connection to be re-used\n     when done. Do not use this unless you're absolutely sure of this, as it\n     makes the operation slower and is less friendly for the network. */\n  CINIT(FORBID_REUSE, LONG, 75),\n\n  /* Set to a file name that contains random data for libcurl to use to\n     seed the random engine when doing SSL connects. */\n  CINIT(RANDOM_FILE, OBJECTPOINT, 76),\n\n  /* Set to the Entropy Gathering Daemon socket pathname */\n  CINIT(EGDSOCKET, OBJECTPOINT, 77),\n\n  /* Time-out connect operations after this amount of seconds, if connects are\n     OK within this time, then fine... This only aborts the connect phase. */\n  CINIT(CONNECTTIMEOUT, LONG, 78),\n\n  /* Function that will be called to store headers (instead of fwrite). The\n   * parameters will use fwrite() syntax, make sure to follow them. */\n  CINIT(HEADERFUNCTION, FUNCTIONPOINT, 79),\n\n  /* Set this to force the HTTP request to get back to GET. Only really usable\n     if POST, PUT or a custom request have been used first.\n   */\n  CINIT(HTTPGET, LONG, 80),\n\n  /* Set if we should verify the Common name from the peer certificate in ssl\n   * handshake, set 1 to check existence, 2 to ensure that it matches the\n   * provided hostname. */\n  CINIT(SSL_VERIFYHOST, LONG, 81),\n\n  /* Specify which file name to write all known cookies in after completed\n     operation. Set file name to \"-\" (dash) to make it go to stdout. */\n  CINIT(COOKIEJAR, OBJECTPOINT, 82),\n\n  /* Specify which SSL ciphers to use */\n  CINIT(SSL_CIPHER_LIST, OBJECTPOINT, 83),\n\n  /* Specify which HTTP version to use! This must be set to one of the\n     CURL_HTTP_VERSION* enums set below. */\n  CINIT(HTTP_VERSION, LONG, 84),\n\n  /* Specifically switch on or off the FTP engine's use of the EPSV command. By\n     default, that one will always be attempted before the more traditional\n     PASV command. */\n  CINIT(FTP_USE_EPSV, LONG, 85),\n\n  /* type of the file keeping your SSL-certificate (\"DER\", \"PEM\", \"ENG\") */\n  CINIT(SSLCERTTYPE, OBJECTPOINT, 86),\n\n  /* name of the file keeping your private SSL-key */\n  CINIT(SSLKEY, OBJECTPOINT, 87),\n\n  /* type of the file keeping your private SSL-key (\"DER\", \"PEM\", \"ENG\") */\n  CINIT(SSLKEYTYPE, OBJECTPOINT, 88),\n\n  /* crypto engine for the SSL-sub system */\n  CINIT(SSLENGINE, OBJECTPOINT, 89),\n\n  /* set the crypto engine for the SSL-sub system as default\n     the param has no meaning...\n   */\n  CINIT(SSLENGINE_DEFAULT, LONG, 90),\n\n  /* Non-zero value means to use the global dns cache */\n  CINIT(DNS_USE_GLOBAL_CACHE, LONG, 91), /* DEPRECATED, do not use! */\n\n  /* DNS cache timeout */\n  CINIT(DNS_CACHE_TIMEOUT, LONG, 92),\n\n  /* send linked-list of pre-transfer QUOTE commands */\n  CINIT(PREQUOTE, OBJECTPOINT, 93),\n\n  /* set the debug function */\n  CINIT(DEBUGFUNCTION, FUNCTIONPOINT, 94),\n\n  /* set the data for the debug function */\n  CINIT(DEBUGDATA, OBJECTPOINT, 95),\n\n  /* mark this as start of a cookie session */\n  CINIT(COOKIESESSION, LONG, 96),\n\n  /* The CApath directory used to validate the peer certificate\n     this option is used only if SSL_VERIFYPEER is true */\n  CINIT(CAPATH, OBJECTPOINT, 97),\n\n  /* Instruct libcurl to use a smaller receive buffer */\n  CINIT(BUFFERSIZE, LONG, 98),\n\n  /* Instruct libcurl to not use any signal/alarm handlers, even when using\n     timeouts. This option is useful for multi-threaded applications.\n     See libcurl-the-guide for more background information. */\n  CINIT(NOSIGNAL, LONG, 99),\n\n  /* Provide a CURLShare for mutexing non-ts data */\n  CINIT(SHARE, OBJECTPOINT, 100),\n\n  /* indicates type of proxy. accepted values are CURLPROXY_HTTP (default),\n     CURLPROXY_SOCKS4, CURLPROXY_SOCKS4A and CURLPROXY_SOCKS5. */\n  CINIT(PROXYTYPE, LONG, 101),\n\n  /* Set the Accept-Encoding string. Use this to tell a server you would like\n     the response to be compressed. Before 7.21.6, this was known as\n     CURLOPT_ENCODING */\n  CINIT(ACCEPT_ENCODING, OBJECTPOINT, 102),\n\n  /* Set pointer to private data */\n  CINIT(PRIVATE, OBJECTPOINT, 103),\n\n  /* Set aliases for HTTP 200 in the HTTP Response header */\n  CINIT(HTTP200ALIASES, OBJECTPOINT, 104),\n\n  /* Continue to send authentication (user+password) when following locations,\n     even when hostname changed. This can potentially send off the name\n     and password to whatever host the server decides. */\n  CINIT(UNRESTRICTED_AUTH, LONG, 105),\n\n  /* Specifically switch on or off the FTP engine's use of the EPRT command (\n     it also disables the LPRT attempt). By default, those ones will always be\n     attempted before the good old traditional PORT command. */\n  CINIT(FTP_USE_EPRT, LONG, 106),\n\n  /* Set this to a bitmask value to enable the particular authentications\n     methods you like. Use this in combination with CURLOPT_USERPWD.\n     Note that setting multiple bits may cause extra network round-trips. */\n  CINIT(HTTPAUTH, LONG, 107),\n\n  /* Set the ssl context callback function, currently only for OpenSSL ssl_ctx\n     in second argument. The function must be matching the\n     curl_ssl_ctx_callback proto. */\n  CINIT(SSL_CTX_FUNCTION, FUNCTIONPOINT, 108),\n\n  /* Set the userdata for the ssl context callback function's third\n     argument */\n  CINIT(SSL_CTX_DATA, OBJECTPOINT, 109),\n\n  /* FTP Option that causes missing dirs to be created on the remote server.\n     In 7.19.4 we introduced the convenience enums for this option using the\n     CURLFTP_CREATE_DIR prefix.\n  */\n  CINIT(FTP_CREATE_MISSING_DIRS, LONG, 110),\n\n  /* Set this to a bitmask value to enable the particular authentications\n     methods you like. Use this in combination with CURLOPT_PROXYUSERPWD.\n     Note that setting multiple bits may cause extra network round-trips. */\n  CINIT(PROXYAUTH, LONG, 111),\n\n  /* FTP option that changes the timeout, in seconds, associated with\n     getting a response.  This is different from transfer timeout time and\n     essentially places a demand on the FTP server to acknowledge commands\n     in a timely manner. */\n  CINIT(FTP_RESPONSE_TIMEOUT, LONG, 112),\n#define CURLOPT_SERVER_RESPONSE_TIMEOUT CURLOPT_FTP_RESPONSE_TIMEOUT\n\n  /* Set this option to one of the CURL_IPRESOLVE_* defines (see below) to\n     tell libcurl to resolve names to those IP versions only. This only has\n     affect on systems with support for more than one, i.e IPv4 _and_ IPv6. */\n  CINIT(IPRESOLVE, LONG, 113),\n\n  /* Set this option to limit the size of a file that will be downloaded from\n     an HTTP or FTP server.\n\n     Note there is also _LARGE version which adds large file support for\n     platforms which have larger off_t sizes.  See MAXFILESIZE_LARGE below. */\n  CINIT(MAXFILESIZE, LONG, 114),\n\n  /* See the comment for INFILESIZE above, but in short, specifies\n   * the size of the file being uploaded.  -1 means unknown.\n   */\n  CINIT(INFILESIZE_LARGE, OFF_T, 115),\n\n  /* Sets the continuation offset.  There is also a LONG version of this;\n   * look above for RESUME_FROM.\n   */\n  CINIT(RESUME_FROM_LARGE, OFF_T, 116),\n\n  /* Sets the maximum size of data that will be downloaded from\n   * an HTTP or FTP server.  See MAXFILESIZE above for the LONG version.\n   */\n  CINIT(MAXFILESIZE_LARGE, OFF_T, 117),\n\n  /* Set this option to the file name of your .netrc file you want libcurl\n     to parse (using the CURLOPT_NETRC option). If not set, libcurl will do\n     a poor attempt to find the user's home directory and check for a .netrc\n     file in there. */\n  CINIT(NETRC_FILE, OBJECTPOINT, 118),\n\n  /* Enable SSL/TLS for FTP, pick one of:\n     CURLUSESSL_TRY     - try using SSL, proceed anyway otherwise\n     CURLUSESSL_CONTROL - SSL for the control connection or fail\n     CURLUSESSL_ALL     - SSL for all communication or fail\n  */\n  CINIT(USE_SSL, LONG, 119),\n\n  /* The _LARGE version of the standard POSTFIELDSIZE option */\n  CINIT(POSTFIELDSIZE_LARGE, OFF_T, 120),\n\n  /* Enable/disable the TCP Nagle algorithm */\n  CINIT(TCP_NODELAY, LONG, 121),\n\n  /* 122 OBSOLETE, used in 7.12.3. Gone in 7.13.0 */\n  /* 123 OBSOLETE. Gone in 7.16.0 */\n  /* 124 OBSOLETE, used in 7.12.3. Gone in 7.13.0 */\n  /* 125 OBSOLETE, used in 7.12.3. Gone in 7.13.0 */\n  /* 126 OBSOLETE, used in 7.12.3. Gone in 7.13.0 */\n  /* 127 OBSOLETE. Gone in 7.16.0 */\n  /* 128 OBSOLETE. Gone in 7.16.0 */\n\n  /* When FTP over SSL/TLS is selected (with CURLOPT_USE_SSL), this option\n     can be used to change libcurl's default action which is to first try\n     \"AUTH SSL\" and then \"AUTH TLS\" in this order, and proceed when a OK\n     response has been received.\n\n     Available parameters are:\n     CURLFTPAUTH_DEFAULT - let libcurl decide\n     CURLFTPAUTH_SSL     - try \"AUTH SSL\" first, then TLS\n     CURLFTPAUTH_TLS     - try \"AUTH TLS\" first, then SSL\n  */\n  CINIT(FTPSSLAUTH, LONG, 129),\n\n  CINIT(IOCTLFUNCTION, FUNCTIONPOINT, 130),\n  CINIT(IOCTLDATA, OBJECTPOINT, 131),\n\n  /* 132 OBSOLETE. Gone in 7.16.0 */\n  /* 133 OBSOLETE. Gone in 7.16.0 */\n\n  /* zero terminated string for pass on to the FTP server when asked for\n     \"account\" info */\n  CINIT(FTP_ACCOUNT, OBJECTPOINT, 134),\n\n  /* feed cookies into cookie engine */\n  CINIT(COOKIELIST, OBJECTPOINT, 135),\n\n  /* ignore Content-Length */\n  CINIT(IGNORE_CONTENT_LENGTH, LONG, 136),\n\n  /* Set to non-zero to skip the IP address received in a 227 PASV FTP server\n     response. Typically used for FTP-SSL purposes but is not restricted to\n     that. libcurl will then instead use the same IP address it used for the\n     control connection. */\n  CINIT(FTP_SKIP_PASV_IP, LONG, 137),\n\n  /* Select \"file method\" to use when doing FTP, see the curl_ftpmethod\n     above. */\n  CINIT(FTP_FILEMETHOD, LONG, 138),\n\n  /* Local port number to bind the socket to */\n  CINIT(LOCALPORT, LONG, 139),\n\n  /* Number of ports to try, including the first one set with LOCALPORT.\n     Thus, setting it to 1 will make no additional attempts but the first.\n  */\n  CINIT(LOCALPORTRANGE, LONG, 140),\n\n  /* no transfer, set up connection and let application use the socket by\n     extracting it with CURLINFO_LASTSOCKET */\n  CINIT(CONNECT_ONLY, LONG, 141),\n\n  /* Function that will be called to convert from the\n     network encoding (instead of using the iconv calls in libcurl) */\n  CINIT(CONV_FROM_NETWORK_FUNCTION, FUNCTIONPOINT, 142),\n\n  /* Function that will be called to convert to the\n     network encoding (instead of using the iconv calls in libcurl) */\n  CINIT(CONV_TO_NETWORK_FUNCTION, FUNCTIONPOINT, 143),\n\n  /* Function that will be called to convert from UTF8\n     (instead of using the iconv calls in libcurl)\n     Note that this is used only for SSL certificate processing */\n  CINIT(CONV_FROM_UTF8_FUNCTION, FUNCTIONPOINT, 144),\n\n  /* if the connection proceeds too quickly then need to slow it down */\n  /* limit-rate: maximum number of bytes per second to send or receive */\n  CINIT(MAX_SEND_SPEED_LARGE, OFF_T, 145),\n  CINIT(MAX_RECV_SPEED_LARGE, OFF_T, 146),\n\n  /* Pointer to command string to send if USER/PASS fails. */\n  CINIT(FTP_ALTERNATIVE_TO_USER, OBJECTPOINT, 147),\n\n  /* callback function for setting socket options */\n  CINIT(SOCKOPTFUNCTION, FUNCTIONPOINT, 148),\n  CINIT(SOCKOPTDATA, OBJECTPOINT, 149),\n\n  /* set to 0 to disable session ID re-use for this transfer, default is\n     enabled (== 1) */\n  CINIT(SSL_SESSIONID_CACHE, LONG, 150),\n\n  /* allowed SSH authentication methods */\n  CINIT(SSH_AUTH_TYPES, LONG, 151),\n\n  /* Used by scp/sftp to do public/private key authentication */\n  CINIT(SSH_PUBLIC_KEYFILE, OBJECTPOINT, 152),\n  CINIT(SSH_PRIVATE_KEYFILE, OBJECTPOINT, 153),\n\n  /* Send CCC (Clear Command Channel) after authentication */\n  CINIT(FTP_SSL_CCC, LONG, 154),\n\n  /* Same as TIMEOUT and CONNECTTIMEOUT, but with ms resolution */\n  CINIT(TIMEOUT_MS, LONG, 155),\n  CINIT(CONNECTTIMEOUT_MS, LONG, 156),\n\n  /* set to zero to disable the libcurl's decoding and thus pass the raw body\n     data to the application even when it is encoded/compressed */\n  CINIT(HTTP_TRANSFER_DECODING, LONG, 157),\n  CINIT(HTTP_CONTENT_DECODING, LONG, 158),\n\n  /* Permission used when creating new files and directories on the remote\n     server for protocols that support it, SFTP/SCP/FILE */\n  CINIT(NEW_FILE_PERMS, LONG, 159),\n  CINIT(NEW_DIRECTORY_PERMS, LONG, 160),\n\n  /* Set the behaviour of POST when redirecting. Values must be set to one\n     of CURL_REDIR* defines below. This used to be called CURLOPT_POST301 */\n  CINIT(POSTREDIR, LONG, 161),\n\n  /* used by scp/sftp to verify the host's public key */\n  CINIT(SSH_HOST_PUBLIC_KEY_MD5, OBJECTPOINT, 162),\n\n  /* Callback function for opening socket (instead of socket(2)). Optionally,\n     callback is able change the address or refuse to connect returning\n     CURL_SOCKET_BAD.  The callback should have type\n     curl_opensocket_callback */\n  CINIT(OPENSOCKETFUNCTION, FUNCTIONPOINT, 163),\n  CINIT(OPENSOCKETDATA, OBJECTPOINT, 164),\n\n  /* POST volatile input fields. */\n  CINIT(COPYPOSTFIELDS, OBJECTPOINT, 165),\n\n  /* set transfer mode (;type=<a|i>) when doing FTP via an HTTP proxy */\n  CINIT(PROXY_TRANSFER_MODE, LONG, 166),\n\n  /* Callback function for seeking in the input stream */\n  CINIT(SEEKFUNCTION, FUNCTIONPOINT, 167),\n  CINIT(SEEKDATA, OBJECTPOINT, 168),\n\n  /* CRL file */\n  CINIT(CRLFILE, OBJECTPOINT, 169),\n\n  /* Issuer certificate */\n  CINIT(ISSUERCERT, OBJECTPOINT, 170),\n\n  /* (IPv6) Address scope */\n  CINIT(ADDRESS_SCOPE, LONG, 171),\n\n  /* Collect certificate chain info and allow it to get retrievable with\n     CURLINFO_CERTINFO after the transfer is complete. */\n  CINIT(CERTINFO, LONG, 172),\n\n  /* \"name\" and \"pwd\" to use when fetching. */\n  CINIT(USERNAME, OBJECTPOINT, 173),\n  CINIT(PASSWORD, OBJECTPOINT, 174),\n\n    /* \"name\" and \"pwd\" to use with Proxy when fetching. */\n  CINIT(PROXYUSERNAME, OBJECTPOINT, 175),\n  CINIT(PROXYPASSWORD, OBJECTPOINT, 176),\n\n  /* Comma separated list of hostnames defining no-proxy zones. These should\n     match both hostnames directly, and hostnames within a domain. For\n     example, local.com will match local.com and www.local.com, but NOT\n     notlocal.com or www.notlocal.com. For compatibility with other\n     implementations of this, .local.com will be considered to be the same as\n     local.com. A single * is the only valid wildcard, and effectively\n     disables the use of proxy. */\n  CINIT(NOPROXY, OBJECTPOINT, 177),\n\n  /* block size for TFTP transfers */\n  CINIT(TFTP_BLKSIZE, LONG, 178),\n\n  /* Socks Service */\n  CINIT(SOCKS5_GSSAPI_SERVICE, OBJECTPOINT, 179),\n\n  /* Socks Service */\n  CINIT(SOCKS5_GSSAPI_NEC, LONG, 180),\n\n  /* set the bitmask for the protocols that are allowed to be used for the\n     transfer, which thus helps the app which takes URLs from users or other\n     external inputs and want to restrict what protocol(s) to deal\n     with. Defaults to CURLPROTO_ALL. */\n  CINIT(PROTOCOLS, LONG, 181),\n\n  /* set the bitmask for the protocols that libcurl is allowed to follow to,\n     as a subset of the CURLOPT_PROTOCOLS ones. That means the protocol needs\n     to be set in both bitmasks to be allowed to get redirected to. Defaults\n     to all protocols except FILE and SCP. */\n  CINIT(REDIR_PROTOCOLS, LONG, 182),\n\n  /* set the SSH knownhost file name to use */\n  CINIT(SSH_KNOWNHOSTS, OBJECTPOINT, 183),\n\n  /* set the SSH host key callback, must point to a curl_sshkeycallback\n     function */\n  CINIT(SSH_KEYFUNCTION, FUNCTIONPOINT, 184),\n\n  /* set the SSH host key callback custom pointer */\n  CINIT(SSH_KEYDATA, OBJECTPOINT, 185),\n\n  /* set the SMTP mail originator */\n  CINIT(MAIL_FROM, OBJECTPOINT, 186),\n\n  /* set the SMTP mail receiver(s) */\n  CINIT(MAIL_RCPT, OBJECTPOINT, 187),\n\n  /* FTP: send PRET before PASV */\n  CINIT(FTP_USE_PRET, LONG, 188),\n\n  /* RTSP request method (OPTIONS, SETUP, PLAY, etc...) */\n  CINIT(RTSP_REQUEST, LONG, 189),\n\n  /* The RTSP session identifier */\n  CINIT(RTSP_SESSION_ID, OBJECTPOINT, 190),\n\n  /* The RTSP stream URI */\n  CINIT(RTSP_STREAM_URI, OBJECTPOINT, 191),\n\n  /* The Transport: header to use in RTSP requests */\n  CINIT(RTSP_TRANSPORT, OBJECTPOINT, 192),\n\n  /* Manually initialize the client RTSP CSeq for this handle */\n  CINIT(RTSP_CLIENT_CSEQ, LONG, 193),\n\n  /* Manually initialize the server RTSP CSeq for this handle */\n  CINIT(RTSP_SERVER_CSEQ, LONG, 194),\n\n  /* The stream to pass to INTERLEAVEFUNCTION. */\n  CINIT(INTERLEAVEDATA, OBJECTPOINT, 195),\n\n  /* Let the application define a custom write method for RTP data */\n  CINIT(INTERLEAVEFUNCTION, FUNCTIONPOINT, 196),\n\n  /* Turn on wildcard matching */\n  CINIT(WILDCARDMATCH, LONG, 197),\n\n  /* Directory matching callback called before downloading of an\n     individual file (chunk) started */\n  CINIT(CHUNK_BGN_FUNCTION, FUNCTIONPOINT, 198),\n\n  /* Directory matching callback called after the file (chunk)\n     was downloaded, or skipped */\n  CINIT(CHUNK_END_FUNCTION, FUNCTIONPOINT, 199),\n\n  /* Change match (fnmatch-like) callback for wildcard matching */\n  CINIT(FNMATCH_FUNCTION, FUNCTIONPOINT, 200),\n\n  /* Let the application define custom chunk data pointer */\n  CINIT(CHUNK_DATA, OBJECTPOINT, 201),\n\n  /* FNMATCH_FUNCTION user pointer */\n  CINIT(FNMATCH_DATA, OBJECTPOINT, 202),\n\n  /* send linked-list of name:port:address sets */\n  CINIT(RESOLVE, OBJECTPOINT, 203),\n\n  /* Set a username for authenticated TLS */\n  CINIT(TLSAUTH_USERNAME, OBJECTPOINT, 204),\n\n  /* Set a password for authenticated TLS */\n  CINIT(TLSAUTH_PASSWORD, OBJECTPOINT, 205),\n\n  /* Set authentication type for authenticated TLS */\n  CINIT(TLSAUTH_TYPE, OBJECTPOINT, 206),\n\n  /* Set to 1 to enable the \"TE:\" header in HTTP requests to ask for\n     compressed transfer-encoded responses. Set to 0 to disable the use of TE:\n     in outgoing requests. The current default is 0, but it might change in a\n     future libcurl release.\n\n     libcurl will ask for the compressed methods it knows of, and if that\n     isn't any, it will not ask for transfer-encoding at all even if this\n     option is set to 1.\n\n  */\n  CINIT(TRANSFER_ENCODING, LONG, 207),\n\n  /* Callback function for closing socket (instead of close(2)). The callback\n     should have type curl_closesocket_callback */\n  CINIT(CLOSESOCKETFUNCTION, FUNCTIONPOINT, 208),\n  CINIT(CLOSESOCKETDATA, OBJECTPOINT, 209),\n\n  /* allow GSSAPI credential delegation */\n  CINIT(GSSAPI_DELEGATION, LONG, 210),\n\n  /* Set the name servers to use for DNS resolution */\n  CINIT(DNS_SERVERS, OBJECTPOINT, 211),\n\n  /* Time-out accept operations (currently for FTP only) after this amount\n     of miliseconds. */\n  CINIT(ACCEPTTIMEOUT_MS, LONG, 212),\n\n  /* Set TCP keepalive */\n  CINIT(TCP_KEEPALIVE, LONG, 213),\n\n  /* non-universal keepalive knobs (Linux, AIX, HP-UX, more) */\n  CINIT(TCP_KEEPIDLE, LONG, 214),\n  CINIT(TCP_KEEPINTVL, LONG, 215),\n\n  /* Enable/disable specific SSL features with a bitmask, see CURLSSLOPT_* */\n  CINIT(SSL_OPTIONS, LONG, 216),\n\n  /* Set the SMTP auth originator */\n  CINIT(MAIL_AUTH, OBJECTPOINT, 217),\n\n  /* Enable/disable SASL initial response */\n  CINIT(SASL_IR, LONG, 218),\n\n  /* Function that will be called instead of the internal progress display\n   * function. This function should be defined as the curl_xferinfo_callback\n   * prototype defines. (Deprecates CURLOPT_PROGRESSFUNCTION) */\n  CINIT(XFERINFOFUNCTION, FUNCTIONPOINT, 219),\n\n  /* The XOAUTH2 bearer token */\n  CINIT(XOAUTH2_BEARER, OBJECTPOINT, 220),\n\n  /* Set the interface string to use as outgoing network\n   * interface for DNS requests.\n   * Only supported by the c-ares DNS backend */\n  CINIT(DNS_INTERFACE, OBJECTPOINT, 221),\n\n  /* Set the local IPv4 address to use for outgoing DNS requests.\n   * Only supported by the c-ares DNS backend */\n  CINIT(DNS_LOCAL_IP4, OBJECTPOINT, 222),\n\n  /* Set the local IPv4 address to use for outgoing DNS requests.\n   * Only supported by the c-ares DNS backend */\n  CINIT(DNS_LOCAL_IP6, OBJECTPOINT, 223),\n\n  /* Set authentication options directly */\n  CINIT(LOGIN_OPTIONS, OBJECTPOINT, 224),\n\n  /* Enable/disable TLS NPN extension (http2 over ssl might fail without) */\n  CINIT(SSL_ENABLE_NPN, LONG, 225),\n\n  /* Enable/disable TLS ALPN extension (http2 over ssl might fail without) */\n  CINIT(SSL_ENABLE_ALPN, LONG, 226),\n\n  /* Time to wait for a response to a HTTP request containing an\n   * Expect: 100-continue header before sending the data anyway. */\n  CINIT(EXPECT_100_TIMEOUT_MS, LONG, 227),\n\n  /* This points to a linked list of headers used for proxy requests only,\n     struct curl_slist kind */\n  CINIT(PROXYHEADER, OBJECTPOINT, 228),\n\n  /* Pass in a bitmask of \"header options\" */\n  CINIT(HEADEROPT, LONG, 229),\n\n  CURLOPT_LASTENTRY /* the last unused */\n} CURLoption;\n\n#ifndef CURL_NO_OLDIES /* define this to test if your app builds with all\n                          the obsolete stuff removed! */\n\n/* Backwards compatibility with older names */\n/* These are scheduled to disappear by 2011 */\n\n/* This was added in version 7.19.1 */\n#define CURLOPT_POST301 CURLOPT_POSTREDIR\n\n/* These are scheduled to disappear by 2009 */\n\n/* The following were added in 7.17.0 */\n#define CURLOPT_SSLKEYPASSWD CURLOPT_KEYPASSWD\n#define CURLOPT_FTPAPPEND CURLOPT_APPEND\n#define CURLOPT_FTPLISTONLY CURLOPT_DIRLISTONLY\n#define CURLOPT_FTP_SSL CURLOPT_USE_SSL\n\n/* The following were added earlier */\n\n#define CURLOPT_SSLCERTPASSWD CURLOPT_KEYPASSWD\n#define CURLOPT_KRB4LEVEL CURLOPT_KRBLEVEL\n\n#else\n/* This is set if CURL_NO_OLDIES is defined at compile-time */\n#undef CURLOPT_DNS_USE_GLOBAL_CACHE /* soon obsolete */\n#endif\n\n\n  /* Below here follows defines for the CURLOPT_IPRESOLVE option. If a host\n     name resolves addresses using more than one IP protocol version, this\n     option might be handy to force libcurl to use a specific IP version. */\n#define CURL_IPRESOLVE_WHATEVER 0 /* default, resolves addresses to all IP\n                                     versions that your system allows */\n#define CURL_IPRESOLVE_V4       1 /* resolve to ipv4 addresses */\n#define CURL_IPRESOLVE_V6       2 /* resolve to ipv6 addresses */\n\n  /* three convenient \"aliases\" that follow the name scheme better */\n#define CURLOPT_RTSPHEADER CURLOPT_HTTPHEADER\n\n  /* These enums are for use with the CURLOPT_HTTP_VERSION option. */\nenum {\n  CURL_HTTP_VERSION_NONE, /* setting this means we don't care, and that we'd\n                             like the library to choose the best possible\n                             for us! */\n  CURL_HTTP_VERSION_1_0,  /* please use HTTP 1.0 in the request */\n  CURL_HTTP_VERSION_1_1,  /* please use HTTP 1.1 in the request */\n  CURL_HTTP_VERSION_2_0,  /* please use HTTP 2.0 in the request */\n\n  CURL_HTTP_VERSION_LAST /* *ILLEGAL* http version */\n};\n\n/*\n * Public API enums for RTSP requests\n */\nenum {\n    CURL_RTSPREQ_NONE, /* first in list */\n    CURL_RTSPREQ_OPTIONS,\n    CURL_RTSPREQ_DESCRIBE,\n    CURL_RTSPREQ_ANNOUNCE,\n    CURL_RTSPREQ_SETUP,\n    CURL_RTSPREQ_PLAY,\n    CURL_RTSPREQ_PAUSE,\n    CURL_RTSPREQ_TEARDOWN,\n    CURL_RTSPREQ_GET_PARAMETER,\n    CURL_RTSPREQ_SET_PARAMETER,\n    CURL_RTSPREQ_RECORD,\n    CURL_RTSPREQ_RECEIVE,\n    CURL_RTSPREQ_LAST /* last in list */\n};\n\n  /* These enums are for use with the CURLOPT_NETRC option. */\nenum CURL_NETRC_OPTION {\n  CURL_NETRC_IGNORED,     /* The .netrc will never be read.\n                           * This is the default. */\n  CURL_NETRC_OPTIONAL,    /* A user:password in the URL will be preferred\n                           * to one in the .netrc. */\n  CURL_NETRC_REQUIRED,    /* A user:password in the URL will be ignored.\n                           * Unless one is set programmatically, the .netrc\n                           * will be queried. */\n  CURL_NETRC_LAST\n};\n\nenum {\n  CURL_SSLVERSION_DEFAULT,\n  CURL_SSLVERSION_TLSv1, /* TLS 1.x */\n  CURL_SSLVERSION_SSLv2,\n  CURL_SSLVERSION_SSLv3,\n  CURL_SSLVERSION_TLSv1_0,\n  CURL_SSLVERSION_TLSv1_1,\n  CURL_SSLVERSION_TLSv1_2,\n\n  CURL_SSLVERSION_LAST /* never use, keep last */\n};\n\nenum CURL_TLSAUTH {\n  CURL_TLSAUTH_NONE,\n  CURL_TLSAUTH_SRP,\n  CURL_TLSAUTH_LAST /* never use, keep last */\n};\n\n/* symbols to use with CURLOPT_POSTREDIR.\n   CURL_REDIR_POST_301, CURL_REDIR_POST_302 and CURL_REDIR_POST_303\n   can be bitwise ORed so that CURL_REDIR_POST_301 | CURL_REDIR_POST_302\n   | CURL_REDIR_POST_303 == CURL_REDIR_POST_ALL */\n\n#define CURL_REDIR_GET_ALL  0\n#define CURL_REDIR_POST_301 1\n#define CURL_REDIR_POST_302 2\n#define CURL_REDIR_POST_303 4\n#define CURL_REDIR_POST_ALL \\\n    (CURL_REDIR_POST_301|CURL_REDIR_POST_302|CURL_REDIR_POST_303)\n\ntypedef enum {\n  CURL_TIMECOND_NONE,\n\n  CURL_TIMECOND_IFMODSINCE,\n  CURL_TIMECOND_IFUNMODSINCE,\n  CURL_TIMECOND_LASTMOD,\n\n  CURL_TIMECOND_LAST\n} curl_TimeCond;\n\n\n/* curl_strequal() and curl_strnequal() are subject for removal in a future\n   libcurl, see lib/README.curlx for details */\nCURL_EXTERN int (curl_strequal)(const char *s1, const char *s2);\nCURL_EXTERN int (curl_strnequal)(const char *s1, const char *s2, size_t n);\n\n/* name is uppercase CURLFORM_<name> */\n#ifdef CFINIT\n#undef CFINIT\n#endif\n\n#ifdef CURL_ISOCPP\n#define CFINIT(name) CURLFORM_ ## name\n#else\n/* The macro \"##\" is ISO C, we assume pre-ISO C doesn't support it. */\n#define CFINIT(name) CURLFORM_/**/name\n#endif\n\ntypedef enum {\n  CFINIT(NOTHING),        /********* the first one is unused ************/\n\n  /*  */\n  CFINIT(COPYNAME),\n  CFINIT(PTRNAME),\n  CFINIT(NAMELENGTH),\n  CFINIT(COPYCONTENTS),\n  CFINIT(PTRCONTENTS),\n  CFINIT(CONTENTSLENGTH),\n  CFINIT(FILECONTENT),\n  CFINIT(ARRAY),\n  CFINIT(OBSOLETE),\n  CFINIT(FILE),\n\n  CFINIT(BUFFER),\n  CFINIT(BUFFERPTR),\n  CFINIT(BUFFERLENGTH),\n\n  CFINIT(CONTENTTYPE),\n  CFINIT(CONTENTHEADER),\n  CFINIT(FILENAME),\n  CFINIT(END),\n  CFINIT(OBSOLETE2),\n\n  CFINIT(STREAM),\n\n  CURLFORM_LASTENTRY /* the last unused */\n} CURLformoption;\n\n#undef CFINIT /* done */\n\n/* structure to be used as parameter for CURLFORM_ARRAY */\nstruct curl_forms {\n  CURLformoption option;\n  const char     *value;\n};\n\n/* use this for multipart formpost building */\n/* Returns code for curl_formadd()\n *\n * Returns:\n * CURL_FORMADD_OK             on success\n * CURL_FORMADD_MEMORY         if the FormInfo allocation fails\n * CURL_FORMADD_OPTION_TWICE   if one option is given twice for one Form\n * CURL_FORMADD_NULL           if a null pointer was given for a char\n * CURL_FORMADD_MEMORY         if the allocation of a FormInfo struct failed\n * CURL_FORMADD_UNKNOWN_OPTION if an unknown option was used\n * CURL_FORMADD_INCOMPLETE     if the some FormInfo is not complete (or error)\n * CURL_FORMADD_MEMORY         if a curl_httppost struct cannot be allocated\n * CURL_FORMADD_MEMORY         if some allocation for string copying failed.\n * CURL_FORMADD_ILLEGAL_ARRAY  if an illegal option is used in an array\n *\n ***************************************************************************/\ntypedef enum {\n  CURL_FORMADD_OK, /* first, no error */\n\n  CURL_FORMADD_MEMORY,\n  CURL_FORMADD_OPTION_TWICE,\n  CURL_FORMADD_NULL,\n  CURL_FORMADD_UNKNOWN_OPTION,\n  CURL_FORMADD_INCOMPLETE,\n  CURL_FORMADD_ILLEGAL_ARRAY,\n  CURL_FORMADD_DISABLED, /* libcurl was built with this disabled */\n\n  CURL_FORMADD_LAST /* last */\n} CURLFORMcode;\n\n/*\n * NAME curl_formadd()\n *\n * DESCRIPTION\n *\n * Pretty advanced function for building multi-part formposts. Each invoke\n * adds one part that together construct a full post. Then use\n * CURLOPT_HTTPPOST to send it off to libcurl.\n */\nCURL_EXTERN CURLFORMcode curl_formadd(struct curl_httppost **httppost,\n                                      struct curl_httppost **last_post,\n                                      ...);\n\n/*\n * callback function for curl_formget()\n * The void *arg pointer will be the one passed as second argument to\n *   curl_formget().\n * The character buffer passed to it must not be freed.\n * Should return the buffer length passed to it as the argument \"len\" on\n *   success.\n */\ntypedef size_t (*curl_formget_callback)(void *arg, const char *buf,\n                                        size_t len);\n\n/*\n * NAME curl_formget()\n *\n * DESCRIPTION\n *\n * Serialize a curl_httppost struct built with curl_formadd().\n * Accepts a void pointer as second argument which will be passed to\n * the curl_formget_callback function.\n * Returns 0 on success.\n */\nCURL_EXTERN int curl_formget(struct curl_httppost *form, void *arg,\n                             curl_formget_callback append);\n/*\n * NAME curl_formfree()\n *\n * DESCRIPTION\n *\n * Free a multipart formpost previously built with curl_formadd().\n */\nCURL_EXTERN void curl_formfree(struct curl_httppost *form);\n\n/*\n * NAME curl_getenv()\n *\n * DESCRIPTION\n *\n * Returns a malloc()'ed string that MUST be curl_free()ed after usage is\n * complete. DEPRECATED - see lib/README.curlx\n */\nCURL_EXTERN char *curl_getenv(const char *variable);\n\n/*\n * NAME curl_version()\n *\n * DESCRIPTION\n *\n * Returns a static ascii string of the libcurl version.\n */\nCURL_EXTERN char *curl_version(void);\n\n/*\n * NAME curl_easy_escape()\n *\n * DESCRIPTION\n *\n * Escapes URL strings (converts all letters consider illegal in URLs to their\n * %XX versions). This function returns a new allocated string or NULL if an\n * error occurred.\n */\nCURL_EXTERN char *curl_easy_escape(CURL *handle,\n                                   const char *string,\n                                   int length);\n\n/* the previous version: */\nCURL_EXTERN char *curl_escape(const char *string,\n                              int length);\n\n\n/*\n * NAME curl_easy_unescape()\n *\n * DESCRIPTION\n *\n * Unescapes URL encoding in strings (converts all %XX codes to their 8bit\n * versions). This function returns a new allocated string or NULL if an error\n * occurred.\n * Conversion Note: On non-ASCII platforms the ASCII %XX codes are\n * converted into the host encoding.\n */\nCURL_EXTERN char *curl_easy_unescape(CURL *handle,\n                                     const char *string,\n                                     int length,\n                                     int *outlength);\n\n/* the previous version */\nCURL_EXTERN char *curl_unescape(const char *string,\n                                int length);\n\n/*\n * NAME curl_free()\n *\n * DESCRIPTION\n *\n * Provided for de-allocation in the same translation unit that did the\n * allocation. Added in libcurl 7.10\n */\nCURL_EXTERN void curl_free(void *p);\n\n/*\n * NAME curl_global_init()\n *\n * DESCRIPTION\n *\n * curl_global_init() should be invoked exactly once for each application that\n * uses libcurl and before any call of other libcurl functions.\n *\n * This function is not thread-safe!\n */\nCURL_EXTERN CURLcode curl_global_init(long flags);\n\n/*\n * NAME curl_global_init_mem()\n *\n * DESCRIPTION\n *\n * curl_global_init() or curl_global_init_mem() should be invoked exactly once\n * for each application that uses libcurl.  This function can be used to\n * initialize libcurl and set user defined memory management callback\n * functions.  Users can implement memory management routines to check for\n * memory leaks, check for mis-use of the curl library etc.  User registered\n * callback routines with be invoked by this library instead of the system\n * memory management routines like malloc, free etc.\n */\nCURL_EXTERN CURLcode curl_global_init_mem(long flags,\n                                          curl_malloc_callback m,\n                                          curl_free_callback f,\n                                          curl_realloc_callback r,\n                                          curl_strdup_callback s,\n                                          curl_calloc_callback c);\n\n/*\n * NAME curl_global_cleanup()\n *\n * DESCRIPTION\n *\n * curl_global_cleanup() should be invoked exactly once for each application\n * that uses libcurl\n */\nCURL_EXTERN void curl_global_cleanup(void);\n\n/* linked-list structure for the CURLOPT_QUOTE option (and other) */\nstruct curl_slist {\n  char *data;\n  struct curl_slist *next;\n};\n\n/*\n * NAME curl_slist_append()\n *\n * DESCRIPTION\n *\n * Appends a string to a linked list. If no list exists, it will be created\n * first. Returns the new list, after appending.\n */\nCURL_EXTERN struct curl_slist *curl_slist_append(struct curl_slist *,\n                                                 const char *);\n\n/*\n * NAME curl_slist_free_all()\n *\n * DESCRIPTION\n *\n * free a previously built curl_slist.\n */\nCURL_EXTERN void curl_slist_free_all(struct curl_slist *);\n\n/*\n * NAME curl_getdate()\n *\n * DESCRIPTION\n *\n * Returns the time, in seconds since 1 Jan 1970 of the time string given in\n * the first argument. The time argument in the second parameter is unused\n * and should be set to NULL.\n */\nCURL_EXTERN time_t curl_getdate(const char *p, const time_t *unused);\n\n/* info about the certificate chain, only for OpenSSL builds. Asked\n   for with CURLOPT_CERTINFO / CURLINFO_CERTINFO */\nstruct curl_certinfo {\n  int num_of_certs;             /* number of certificates with information */\n  struct curl_slist **certinfo; /* for each index in this array, there's a\n                                   linked list with textual information in the\n                                   format \"name: value\" */\n};\n\n/* enum for the different supported SSL backends */\ntypedef enum {\n  CURLSSLBACKEND_NONE = 0,\n  CURLSSLBACKEND_OPENSSL = 1,\n  CURLSSLBACKEND_GNUTLS = 2,\n  CURLSSLBACKEND_NSS = 3,\n  CURLSSLBACKEND_QSOSSL = 4,\n  CURLSSLBACKEND_GSKIT = 5,\n  CURLSSLBACKEND_POLARSSL = 6,\n  CURLSSLBACKEND_CYASSL = 7,\n  CURLSSLBACKEND_SCHANNEL = 8,\n  CURLSSLBACKEND_DARWINSSL = 9,\n  CURLSSLBACKEND_AXTLS = 10\n} curl_sslbackend;\n\n/* Information about the SSL library used and the respective internal SSL\n   handle, which can be used to obtain further information regarding the\n   connection. Asked for with CURLINFO_TLS_SESSION. */\nstruct curl_tlssessioninfo {\n  curl_sslbackend backend;\n  void *internals;\n};\n\n#define CURLINFO_STRING   0x100000\n#define CURLINFO_LONG     0x200000\n#define CURLINFO_DOUBLE   0x300000\n#define CURLINFO_SLIST    0x400000\n#define CURLINFO_MASK     0x0fffff\n#define CURLINFO_TYPEMASK 0xf00000\n\ntypedef enum {\n  CURLINFO_NONE, /* first, never use this */\n  CURLINFO_EFFECTIVE_URL    = CURLINFO_STRING + 1,\n  CURLINFO_RESPONSE_CODE    = CURLINFO_LONG   + 2,\n  CURLINFO_TOTAL_TIME       = CURLINFO_DOUBLE + 3,\n  CURLINFO_NAMELOOKUP_TIME  = CURLINFO_DOUBLE + 4,\n  CURLINFO_CONNECT_TIME     = CURLINFO_DOUBLE + 5,\n  CURLINFO_PRETRANSFER_TIME = CURLINFO_DOUBLE + 6,\n  CURLINFO_SIZE_UPLOAD      = CURLINFO_DOUBLE + 7,\n  CURLINFO_SIZE_DOWNLOAD    = CURLINFO_DOUBLE + 8,\n  CURLINFO_SPEED_DOWNLOAD   = CURLINFO_DOUBLE + 9,\n  CURLINFO_SPEED_UPLOAD     = CURLINFO_DOUBLE + 10,\n  CURLINFO_HEADER_SIZE      = CURLINFO_LONG   + 11,\n  CURLINFO_REQUEST_SIZE     = CURLINFO_LONG   + 12,\n  CURLINFO_SSL_VERIFYRESULT = CURLINFO_LONG   + 13,\n  CURLINFO_FILETIME         = CURLINFO_LONG   + 14,\n  CURLINFO_CONTENT_LENGTH_DOWNLOAD   = CURLINFO_DOUBLE + 15,\n  CURLINFO_CONTENT_LENGTH_UPLOAD     = CURLINFO_DOUBLE + 16,\n  CURLINFO_STARTTRANSFER_TIME = CURLINFO_DOUBLE + 17,\n  CURLINFO_CONTENT_TYPE     = CURLINFO_STRING + 18,\n  CURLINFO_REDIRECT_TIME    = CURLINFO_DOUBLE + 19,\n  CURLINFO_REDIRECT_COUNT   = CURLINFO_LONG   + 20,\n  CURLINFO_PRIVATE          = CURLINFO_STRING + 21,\n  CURLINFO_HTTP_CONNECTCODE = CURLINFO_LONG   + 22,\n  CURLINFO_HTTPAUTH_AVAIL   = CURLINFO_LONG   + 23,\n  CURLINFO_PROXYAUTH_AVAIL  = CURLINFO_LONG   + 24,\n  CURLINFO_OS_ERRNO         = CURLINFO_LONG   + 25,\n  CURLINFO_NUM_CONNECTS     = CURLINFO_LONG   + 26,\n  CURLINFO_SSL_ENGINES      = CURLINFO_SLIST  + 27,\n  CURLINFO_COOKIELIST       = CURLINFO_SLIST  + 28,\n  CURLINFO_LASTSOCKET       = CURLINFO_LONG   + 29,\n  CURLINFO_FTP_ENTRY_PATH   = CURLINFO_STRING + 30,\n  CURLINFO_REDIRECT_URL     = CURLINFO_STRING + 31,\n  CURLINFO_PRIMARY_IP       = CURLINFO_STRING + 32,\n  CURLINFO_APPCONNECT_TIME  = CURLINFO_DOUBLE + 33,\n  CURLINFO_CERTINFO         = CURLINFO_SLIST  + 34,\n  CURLINFO_CONDITION_UNMET  = CURLINFO_LONG   + 35,\n  CURLINFO_RTSP_SESSION_ID  = CURLINFO_STRING + 36,\n  CURLINFO_RTSP_CLIENT_CSEQ = CURLINFO_LONG   + 37,\n  CURLINFO_RTSP_SERVER_CSEQ = CURLINFO_LONG   + 38,\n  CURLINFO_RTSP_CSEQ_RECV   = CURLINFO_LONG   + 39,\n  CURLINFO_PRIMARY_PORT     = CURLINFO_LONG   + 40,\n  CURLINFO_LOCAL_IP         = CURLINFO_STRING + 41,\n  CURLINFO_LOCAL_PORT       = CURLINFO_LONG   + 42,\n  CURLINFO_TLS_SESSION      = CURLINFO_SLIST  + 43,\n  /* Fill in new entries below here! */\n\n  CURLINFO_LASTONE          = 43\n} CURLINFO;\n\n/* CURLINFO_RESPONSE_CODE is the new name for the option previously known as\n   CURLINFO_HTTP_CODE */\n#define CURLINFO_HTTP_CODE CURLINFO_RESPONSE_CODE\n\ntypedef enum {\n  CURLCLOSEPOLICY_NONE, /* first, never use this */\n\n  CURLCLOSEPOLICY_OLDEST,\n  CURLCLOSEPOLICY_LEAST_RECENTLY_USED,\n  CURLCLOSEPOLICY_LEAST_TRAFFIC,\n  CURLCLOSEPOLICY_SLOWEST,\n  CURLCLOSEPOLICY_CALLBACK,\n\n  CURLCLOSEPOLICY_LAST /* last, never use this */\n} curl_closepolicy;\n\n#define CURL_GLOBAL_SSL (1<<0)\n#define CURL_GLOBAL_WIN32 (1<<1)\n#define CURL_GLOBAL_ALL (CURL_GLOBAL_SSL|CURL_GLOBAL_WIN32)\n#define CURL_GLOBAL_NOTHING 0\n#define CURL_GLOBAL_DEFAULT CURL_GLOBAL_ALL\n#define CURL_GLOBAL_ACK_EINTR (1<<2)\n\n\n/*****************************************************************************\n * Setup defines, protos etc for the sharing stuff.\n */\n\n/* Different data locks for a single share */\ntypedef enum {\n  CURL_LOCK_DATA_NONE = 0,\n  /*  CURL_LOCK_DATA_SHARE is used internally to say that\n   *  the locking is just made to change the internal state of the share\n   *  itself.\n   */\n  CURL_LOCK_DATA_SHARE,\n  CURL_LOCK_DATA_COOKIE,\n  CURL_LOCK_DATA_DNS,\n  CURL_LOCK_DATA_SSL_SESSION,\n  CURL_LOCK_DATA_CONNECT,\n  CURL_LOCK_DATA_LAST\n} curl_lock_data;\n\n/* Different lock access types */\ntypedef enum {\n  CURL_LOCK_ACCESS_NONE = 0,   /* unspecified action */\n  CURL_LOCK_ACCESS_SHARED = 1, /* for read perhaps */\n  CURL_LOCK_ACCESS_SINGLE = 2, /* for write perhaps */\n  CURL_LOCK_ACCESS_LAST        /* never use */\n} curl_lock_access;\n\ntypedef void (*curl_lock_function)(CURL *handle,\n                                   curl_lock_data data,\n                                   curl_lock_access locktype,\n                                   void *userptr);\ntypedef void (*curl_unlock_function)(CURL *handle,\n                                     curl_lock_data data,\n                                     void *userptr);\n\ntypedef void CURLSH;\n\ntypedef enum {\n  CURLSHE_OK,  /* all is fine */\n  CURLSHE_BAD_OPTION, /* 1 */\n  CURLSHE_IN_USE,     /* 2 */\n  CURLSHE_INVALID,    /* 3 */\n  CURLSHE_NOMEM,      /* 4 out of memory */\n  CURLSHE_NOT_BUILT_IN, /* 5 feature not present in lib */\n  CURLSHE_LAST        /* never use */\n} CURLSHcode;\n\ntypedef enum {\n  CURLSHOPT_NONE,  /* don't use */\n  CURLSHOPT_SHARE,   /* specify a data type to share */\n  CURLSHOPT_UNSHARE, /* specify which data type to stop sharing */\n  CURLSHOPT_LOCKFUNC,   /* pass in a 'curl_lock_function' pointer */\n  CURLSHOPT_UNLOCKFUNC, /* pass in a 'curl_unlock_function' pointer */\n  CURLSHOPT_USERDATA,   /* pass in a user data pointer used in the lock/unlock\n                           callback functions */\n  CURLSHOPT_LAST  /* never use */\n} CURLSHoption;\n\nCURL_EXTERN CURLSH *curl_share_init(void);\nCURL_EXTERN CURLSHcode curl_share_setopt(CURLSH *, CURLSHoption option, ...);\nCURL_EXTERN CURLSHcode curl_share_cleanup(CURLSH *);\n\n/****************************************************************************\n * Structures for querying information about the curl library at runtime.\n */\n\ntypedef enum {\n  CURLVERSION_FIRST,\n  CURLVERSION_SECOND,\n  CURLVERSION_THIRD,\n  CURLVERSION_FOURTH,\n  CURLVERSION_LAST /* never actually use this */\n} CURLversion;\n\n/* The 'CURLVERSION_NOW' is the symbolic name meant to be used by\n   basically all programs ever that want to get version information. It is\n   meant to be a built-in version number for what kind of struct the caller\n   expects. If the struct ever changes, we redefine the NOW to another enum\n   from above. */\n#define CURLVERSION_NOW CURLVERSION_FOURTH\n\ntypedef struct {\n  CURLversion age;          /* age of the returned struct */\n  const char *version;      /* LIBCURL_VERSION */\n  unsigned int version_num; /* LIBCURL_VERSION_NUM */\n  const char *host;         /* OS/host/cpu/machine when configured */\n  int features;             /* bitmask, see defines below */\n  const char *ssl_version;  /* human readable string */\n  long ssl_version_num;     /* not used anymore, always 0 */\n  const char *libz_version; /* human readable string */\n  /* protocols is terminated by an entry with a NULL protoname */\n  const char * const *protocols;\n\n  /* The fields below this were added in CURLVERSION_SECOND */\n  const char *ares;\n  int ares_num;\n\n  /* This field was added in CURLVERSION_THIRD */\n  const char *libidn;\n\n  /* These field were added in CURLVERSION_FOURTH */\n\n  /* Same as '_libiconv_version' if built with HAVE_ICONV */\n  int iconv_ver_num;\n\n  const char *libssh_version; /* human readable string */\n\n} curl_version_info_data;\n\n#define CURL_VERSION_IPV6      (1<<0)  /* IPv6-enabled */\n#define CURL_VERSION_KERBEROS4 (1<<1)  /* kerberos auth is supported */\n#define CURL_VERSION_SSL       (1<<2)  /* SSL options are present */\n#define CURL_VERSION_LIBZ      (1<<3)  /* libz features are present */\n#define CURL_VERSION_NTLM      (1<<4)  /* NTLM auth is supported */\n#define CURL_VERSION_GSSNEGOTIATE (1<<5) /* Negotiate auth support\n                                            (deprecated) */\n#define CURL_VERSION_DEBUG     (1<<6)  /* built with debug capabilities */\n#define CURL_VERSION_ASYNCHDNS (1<<7)  /* asynchronous dns resolves */\n#define CURL_VERSION_SPNEGO    (1<<8)  /* SPNEGO auth is supported */\n#define CURL_VERSION_LARGEFILE (1<<9)  /* supports files bigger than 2GB */\n#define CURL_VERSION_IDN       (1<<10) /* International Domain Names support */\n#define CURL_VERSION_SSPI      (1<<11) /* SSPI is supported */\n#define CURL_VERSION_CONV      (1<<12) /* character conversions supported */\n#define CURL_VERSION_CURLDEBUG (1<<13) /* debug memory tracking supported */\n#define CURL_VERSION_TLSAUTH_SRP (1<<14) /* TLS-SRP auth is supported */\n#define CURL_VERSION_NTLM_WB   (1<<15) /* NTLM delegating to winbind helper */\n#define CURL_VERSION_HTTP2     (1<<16) /* HTTP2 support built-in */\n#define CURL_VERSION_GSSAPI    (1<<17) /* GSS-API is supported */\n\n /*\n * NAME curl_version_info()\n *\n * DESCRIPTION\n *\n * This function returns a pointer to a static copy of the version info\n * struct. See above.\n */\nCURL_EXTERN curl_version_info_data *curl_version_info(CURLversion);\n\n/*\n * NAME curl_easy_strerror()\n *\n * DESCRIPTION\n *\n * The curl_easy_strerror function may be used to turn a CURLcode value\n * into the equivalent human readable error string.  This is useful\n * for printing meaningful error messages.\n */\nCURL_EXTERN const char *curl_easy_strerror(CURLcode);\n\n/*\n * NAME curl_share_strerror()\n *\n * DESCRIPTION\n *\n * The curl_share_strerror function may be used to turn a CURLSHcode value\n * into the equivalent human readable error string.  This is useful\n * for printing meaningful error messages.\n */\nCURL_EXTERN const char *curl_share_strerror(CURLSHcode);\n\n/*\n * NAME curl_easy_pause()\n *\n * DESCRIPTION\n *\n * The curl_easy_pause function pauses or unpauses transfers. Select the new\n * state by setting the bitmask, use the convenience defines below.\n *\n */\nCURL_EXTERN CURLcode curl_easy_pause(CURL *handle, int bitmask);\n\n#define CURLPAUSE_RECV      (1<<0)\n#define CURLPAUSE_RECV_CONT (0)\n\n#define CURLPAUSE_SEND      (1<<2)\n#define CURLPAUSE_SEND_CONT (0)\n\n#define CURLPAUSE_ALL       (CURLPAUSE_RECV|CURLPAUSE_SEND)\n#define CURLPAUSE_CONT      (CURLPAUSE_RECV_CONT|CURLPAUSE_SEND_CONT)\n\n#ifdef  __cplusplus\n}\n#endif\n\n/* unfortunately, the easy.h and multi.h include files need options and info\n  stuff before they can be included! */\n#include \"easy.h\" /* nothing in curl is fun without the easy stuff */\n#include \"multi.h\"\n\n/* the typechecker doesn't work in C++ (yet) */\n#if defined(__GNUC__) && defined(__GNUC_MINOR__) && \\\n    ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)) && \\\n    !defined(__cplusplus) && !defined(CURL_DISABLE_TYPECHECK)\n#include \"typecheck-gcc.h\"\n#else\n#if defined(__STDC__) && (__STDC__ >= 1)\n/* This preprocessor magic that replaces a call with the exact same call is\n   only done to make sure application authors pass exactly three arguments\n   to these functions. */\n#define curl_easy_setopt(handle,opt,param) curl_easy_setopt(handle,opt,param)\n#define curl_easy_getinfo(handle,info,arg) curl_easy_getinfo(handle,info,arg)\n#define curl_share_setopt(share,opt,param) curl_share_setopt(share,opt,param)\n#define curl_multi_setopt(handle,opt,param) curl_multi_setopt(handle,opt,param)\n#endif /* __STDC__ >= 1 */\n#endif /* gcc >= 4.3 && !__cplusplus */\n\n#endif /* __CURL_CURL_H */\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/curl/curlbuild.h",
    "content": "/* include/curl/curlbuild.h.  Generated from curlbuild.h.in by configure.  */\n#ifndef __CURL_CURLBUILD_H\n#define __CURL_CURLBUILD_H\n/***************************************************************************\n *                                  _   _ ____  _\n *  Project                     ___| | | |  _ \\| |\n *                             / __| | | | |_) | |\n *                            | (__| |_| |  _ <| |___\n *                             \\___|\\___/|_| \\_\\_____|\n *\n * Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al.\n *\n * This software is licensed as described in the file COPYING, which\n * you should have received as part of this distribution. The terms\n * are also available at http://curl.haxx.se/docs/copyright.html.\n *\n * You may opt to use, copy, modify, merge, publish, distribute and/or sell\n * copies of the Software, and permit persons to whom the Software is\n * furnished to do so, under the terms of the COPYING file.\n *\n * This software is distributed on an \"AS IS\" basis, WITHOUT WARRANTY OF ANY\n * KIND, either express or implied.\n *\n ***************************************************************************/\n\n/* ================================================================ */\n/*               NOTES FOR CONFIGURE CAPABLE SYSTEMS                */\n/* ================================================================ */\n\n/*\n * NOTE 1:\n * -------\n *\n * Nothing in this file is intended to be modified or adjusted by the\n * curl library user nor by the curl library builder.\n *\n * If you think that something actually needs to be changed, adjusted\n * or fixed in this file, then, report it on the libcurl development\n * mailing list: http://cool.haxx.se/mailman/listinfo/curl-library/\n *\n * This header file shall only export symbols which are 'curl' or 'CURL'\n * prefixed, otherwise public name space would be polluted.\n *\n * NOTE 2:\n * -------\n *\n * Right now you might be staring at file include/curl/curlbuild.h.in or\n * at file include/curl/curlbuild.h, this is due to the following reason:\n *\n * On systems capable of running the configure script, the configure process\n * will overwrite the distributed include/curl/curlbuild.h file with one that\n * is suitable and specific to the library being configured and built, which\n * is generated from the include/curl/curlbuild.h.in template file.\n *\n */\n\n/* ================================================================ */\n/*  DEFINITION OF THESE SYMBOLS SHALL NOT TAKE PLACE ANYWHERE ELSE  */\n/* ================================================================ */\n\n#ifdef CURL_SIZEOF_LONG\n#error \"CURL_SIZEOF_LONG shall not be defined except in curlbuild.h\"\n   Error Compilation_aborted_CURL_SIZEOF_LONG_already_defined\n#endif\n\n#ifdef CURL_TYPEOF_CURL_SOCKLEN_T\n#error \"CURL_TYPEOF_CURL_SOCKLEN_T shall not be defined except in curlbuild.h\"\n   Error Compilation_aborted_CURL_TYPEOF_CURL_SOCKLEN_T_already_defined\n#endif\n\n#ifdef CURL_SIZEOF_CURL_SOCKLEN_T\n#error \"CURL_SIZEOF_CURL_SOCKLEN_T shall not be defined except in curlbuild.h\"\n   Error Compilation_aborted_CURL_SIZEOF_CURL_SOCKLEN_T_already_defined\n#endif\n\n#ifdef CURL_TYPEOF_CURL_OFF_T\n#error \"CURL_TYPEOF_CURL_OFF_T shall not be defined except in curlbuild.h\"\n   Error Compilation_aborted_CURL_TYPEOF_CURL_OFF_T_already_defined\n#endif\n\n#ifdef CURL_FORMAT_CURL_OFF_T\n#error \"CURL_FORMAT_CURL_OFF_T shall not be defined except in curlbuild.h\"\n   Error Compilation_aborted_CURL_FORMAT_CURL_OFF_T_already_defined\n#endif\n\n#ifdef CURL_FORMAT_CURL_OFF_TU\n#error \"CURL_FORMAT_CURL_OFF_TU shall not be defined except in curlbuild.h\"\n   Error Compilation_aborted_CURL_FORMAT_CURL_OFF_TU_already_defined\n#endif\n\n#ifdef CURL_FORMAT_OFF_T\n#error \"CURL_FORMAT_OFF_T shall not be defined except in curlbuild.h\"\n   Error Compilation_aborted_CURL_FORMAT_OFF_T_already_defined\n#endif\n\n#ifdef CURL_SIZEOF_CURL_OFF_T\n#error \"CURL_SIZEOF_CURL_OFF_T shall not be defined except in curlbuild.h\"\n   Error Compilation_aborted_CURL_SIZEOF_CURL_OFF_T_already_defined\n#endif\n\n#ifdef CURL_SUFFIX_CURL_OFF_T\n#error \"CURL_SUFFIX_CURL_OFF_T shall not be defined except in curlbuild.h\"\n   Error Compilation_aborted_CURL_SUFFIX_CURL_OFF_T_already_defined\n#endif\n\n#ifdef CURL_SUFFIX_CURL_OFF_TU\n#error \"CURL_SUFFIX_CURL_OFF_TU shall not be defined except in curlbuild.h\"\n   Error Compilation_aborted_CURL_SUFFIX_CURL_OFF_TU_already_defined\n#endif\n\n/* ================================================================ */\n/*  EXTERNAL INTERFACE SETTINGS FOR CONFIGURE CAPABLE SYSTEMS ONLY  */\n/* ================================================================ */\n\n/* Configure process defines this to 1 when it finds out that system  */\n/* header file ws2tcpip.h must be included by the external interface. */\n/* #undef CURL_PULL_WS2TCPIP_H */\n#ifdef CURL_PULL_WS2TCPIP_H\n#  ifndef WIN32_LEAN_AND_MEAN\n#    define WIN32_LEAN_AND_MEAN\n#  endif\n#  include <windows.h>\n#  include <winsock2.h>\n#  include <ws2tcpip.h>\n#endif\n\n/* Configure process defines this to 1 when it finds out that system   */\n/* header file sys/types.h must be included by the external interface. */\n#define CURL_PULL_SYS_TYPES_H 1\n#ifdef CURL_PULL_SYS_TYPES_H\n#  include <sys/types.h>\n#endif\n\n/* Configure process defines this to 1 when it finds out that system */\n/* header file stdint.h must be included by the external interface.  */\n#define CURL_PULL_STDINT_H 1\n#ifdef CURL_PULL_STDINT_H\n#  include <stdint.h>\n#endif\n\n/* Configure process defines this to 1 when it finds out that system  */\n/* header file inttypes.h must be included by the external interface. */\n#define CURL_PULL_INTTYPES_H 1\n#ifdef CURL_PULL_INTTYPES_H\n#  include <inttypes.h>\n#endif\n\n/* Configure process defines this to 1 when it finds out that system    */\n/* header file sys/socket.h must be included by the external interface. */\n#define CURL_PULL_SYS_SOCKET_H 1\n#ifdef CURL_PULL_SYS_SOCKET_H\n#  include <sys/socket.h>\n#endif\n\n/* Configure process defines this to 1 when it finds out that system  */\n/* header file sys/poll.h must be included by the external interface. */\n/* #undef CURL_PULL_SYS_POLL_H */\n#ifdef CURL_PULL_SYS_POLL_H\n#  include <sys/poll.h>\n#endif\n\n/* The size of `long', as computed by sizeof. */\n#define CURL_SIZEOF_LONG 4\n\n/* Integral data type used for curl_socklen_t. */\n#define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t\n\n/* The size of `curl_socklen_t', as computed by sizeof. */\n#define CURL_SIZEOF_CURL_SOCKLEN_T 4\n\n/* Data type definition of curl_socklen_t. */\ntypedef CURL_TYPEOF_CURL_SOCKLEN_T curl_socklen_t;\n\n/* Signed integral data type used for curl_off_t. */\n#define CURL_TYPEOF_CURL_OFF_T int64_t\n\n/* Data type definition of curl_off_t. */\ntypedef CURL_TYPEOF_CURL_OFF_T curl_off_t;\n\n/* curl_off_t formatting string directive without \"%\" conversion specifier. */\n#define CURL_FORMAT_CURL_OFF_T \"lld\"\n\n/* unsigned curl_off_t formatting string without \"%\" conversion specifier. */\n#define CURL_FORMAT_CURL_OFF_TU \"llu\"\n\n/* curl_off_t formatting string directive with \"%\" conversion specifier. */\n#define CURL_FORMAT_OFF_T \"%lld\"\n\n/* The size of `curl_off_t', as computed by sizeof. */\n#define CURL_SIZEOF_CURL_OFF_T 8\n\n/* curl_off_t constant suffix. */\n#define CURL_SUFFIX_CURL_OFF_T LL\n\n/* unsigned curl_off_t constant suffix. */\n#define CURL_SUFFIX_CURL_OFF_TU ULL\n\n#endif /* __CURL_CURLBUILD_H */\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/curl/curlrules.h",
    "content": "#ifndef __CURL_CURLRULES_H\n#define __CURL_CURLRULES_H\n/***************************************************************************\n *                                  _   _ ____  _\n *  Project                     ___| | | |  _ \\| |\n *                             / __| | | | |_) | |\n *                            | (__| |_| |  _ <| |___\n *                             \\___|\\___/|_| \\_\\_____|\n *\n * Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al.\n *\n * This software is licensed as described in the file COPYING, which\n * you should have received as part of this distribution. The terms\n * are also available at http://curl.haxx.se/docs/copyright.html.\n *\n * You may opt to use, copy, modify, merge, publish, distribute and/or sell\n * copies of the Software, and permit persons to whom the Software is\n * furnished to do so, under the terms of the COPYING file.\n *\n * This software is distributed on an \"AS IS\" basis, WITHOUT WARRANTY OF ANY\n * KIND, either express or implied.\n *\n ***************************************************************************/\n\n/* ================================================================ */\n/*                    COMPILE TIME SANITY CHECKS                    */\n/* ================================================================ */\n\n/*\n * NOTE 1:\n * -------\n *\n * All checks done in this file are intentionally placed in a public\n * header file which is pulled by curl/curl.h when an application is\n * being built using an already built libcurl library. Additionally\n * this file is also included and used when building the library.\n *\n * If compilation fails on this file it is certainly sure that the\n * problem is elsewhere. It could be a problem in the curlbuild.h\n * header file, or simply that you are using different compilation\n * settings than those used to build the library.\n *\n * Nothing in this file is intended to be modified or adjusted by the\n * curl library user nor by the curl library builder.\n *\n * Do not deactivate any check, these are done to make sure that the\n * library is properly built and used.\n *\n * You can find further help on the libcurl development mailing list:\n * http://cool.haxx.se/mailman/listinfo/curl-library/\n *\n * NOTE 2\n * ------\n *\n * Some of the following compile time checks are based on the fact\n * that the dimension of a constant array can not be a negative one.\n * In this way if the compile time verification fails, the compilation\n * will fail issuing an error. The error description wording is compiler\n * dependent but it will be quite similar to one of the following:\n *\n *   \"negative subscript or subscript is too large\"\n *   \"array must have at least one element\"\n *   \"-1 is an illegal array size\"\n *   \"size of array is negative\"\n *\n * If you are building an application which tries to use an already\n * built libcurl library and you are getting this kind of errors on\n * this file, it is a clear indication that there is a mismatch between\n * how the library was built and how you are trying to use it for your\n * application. Your already compiled or binary library provider is the\n * only one who can give you the details you need to properly use it.\n */\n\n/*\n * Verify that some macros are actually defined.\n */\n\n#ifndef CURL_SIZEOF_LONG\n#  error \"CURL_SIZEOF_LONG definition is missing!\"\n   Error Compilation_aborted_CURL_SIZEOF_LONG_is_missing\n#endif\n\n#ifndef CURL_TYPEOF_CURL_SOCKLEN_T\n#  error \"CURL_TYPEOF_CURL_SOCKLEN_T definition is missing!\"\n   Error Compilation_aborted_CURL_TYPEOF_CURL_SOCKLEN_T_is_missing\n#endif\n\n#ifndef CURL_SIZEOF_CURL_SOCKLEN_T\n#  error \"CURL_SIZEOF_CURL_SOCKLEN_T definition is missing!\"\n   Error Compilation_aborted_CURL_SIZEOF_CURL_SOCKLEN_T_is_missing\n#endif\n\n#ifndef CURL_TYPEOF_CURL_OFF_T\n#  error \"CURL_TYPEOF_CURL_OFF_T definition is missing!\"\n   Error Compilation_aborted_CURL_TYPEOF_CURL_OFF_T_is_missing\n#endif\n\n#ifndef CURL_FORMAT_CURL_OFF_T\n#  error \"CURL_FORMAT_CURL_OFF_T definition is missing!\"\n   Error Compilation_aborted_CURL_FORMAT_CURL_OFF_T_is_missing\n#endif\n\n#ifndef CURL_FORMAT_CURL_OFF_TU\n#  error \"CURL_FORMAT_CURL_OFF_TU definition is missing!\"\n   Error Compilation_aborted_CURL_FORMAT_CURL_OFF_TU_is_missing\n#endif\n\n#ifndef CURL_FORMAT_OFF_T\n#  error \"CURL_FORMAT_OFF_T definition is missing!\"\n   Error Compilation_aborted_CURL_FORMAT_OFF_T_is_missing\n#endif\n\n#ifndef CURL_SIZEOF_CURL_OFF_T\n#  error \"CURL_SIZEOF_CURL_OFF_T definition is missing!\"\n   Error Compilation_aborted_CURL_SIZEOF_CURL_OFF_T_is_missing\n#endif\n\n#ifndef CURL_SUFFIX_CURL_OFF_T\n#  error \"CURL_SUFFIX_CURL_OFF_T definition is missing!\"\n   Error Compilation_aborted_CURL_SUFFIX_CURL_OFF_T_is_missing\n#endif\n\n#ifndef CURL_SUFFIX_CURL_OFF_TU\n#  error \"CURL_SUFFIX_CURL_OFF_TU definition is missing!\"\n   Error Compilation_aborted_CURL_SUFFIX_CURL_OFF_TU_is_missing\n#endif\n\n/*\n * Macros private to this header file.\n */\n\n#define CurlchkszEQ(t, s) sizeof(t) == s ? 1 : -1\n\n#define CurlchkszGE(t1, t2) sizeof(t1) >= sizeof(t2) ? 1 : -1\n\n/*\n * Verify that the size previously defined and expected for long\n * is the same as the one reported by sizeof() at compile time.\n */\n\ntypedef char\n  __curl_rule_01__\n    [CurlchkszEQ(long, CURL_SIZEOF_LONG)];\n\n/*\n * Verify that the size previously defined and expected for\n * curl_off_t is actually the the same as the one reported\n * by sizeof() at compile time.\n */\n\ntypedef char\n  __curl_rule_02__\n    [CurlchkszEQ(curl_off_t, CURL_SIZEOF_CURL_OFF_T)];\n\n/*\n * Verify at compile time that the size of curl_off_t as reported\n * by sizeof() is greater or equal than the one reported for long\n * for the current compilation.\n */\n\ntypedef char\n  __curl_rule_03__\n    [CurlchkszGE(curl_off_t, long)];\n\n/*\n * Verify that the size previously defined and expected for\n * curl_socklen_t is actually the the same as the one reported\n * by sizeof() at compile time.\n */\n\ntypedef char\n  __curl_rule_04__\n    [CurlchkszEQ(curl_socklen_t, CURL_SIZEOF_CURL_SOCKLEN_T)];\n\n/*\n * Verify at compile time that the size of curl_socklen_t as reported\n * by sizeof() is greater or equal than the one reported for int for\n * the current compilation.\n */\n\ntypedef char\n  __curl_rule_05__\n    [CurlchkszGE(curl_socklen_t, int)];\n\n/* ================================================================ */\n/*          EXTERNALLY AND INTERNALLY VISIBLE DEFINITIONS           */\n/* ================================================================ */\n\n/*\n * CURL_ISOCPP and CURL_OFF_T_C definitions are done here in order to allow\n * these to be visible and exported by the external libcurl interface API,\n * while also making them visible to the library internals, simply including\n * curl_setup.h, without actually needing to include curl.h internally.\n * If some day this section would grow big enough, all this should be moved\n * to its own header file.\n */\n\n/*\n * Figure out if we can use the ## preprocessor operator, which is supported\n * by ISO/ANSI C and C++. Some compilers support it without setting __STDC__\n * or  __cplusplus so we need to carefully check for them too.\n */\n\n#if defined(__STDC__) || defined(_MSC_VER) || defined(__cplusplus) || \\\n  defined(__HP_aCC) || defined(__BORLANDC__) || defined(__LCC__) || \\\n  defined(__POCC__) || defined(__SALFORDC__) || defined(__HIGHC__) || \\\n  defined(__ILEC400__)\n  /* This compiler is believed to have an ISO compatible preprocessor */\n#define CURL_ISOCPP\n#else\n  /* This compiler is believed NOT to have an ISO compatible preprocessor */\n#undef CURL_ISOCPP\n#endif\n\n/*\n * Macros for minimum-width signed and unsigned curl_off_t integer constants.\n */\n\n#if defined(__BORLANDC__) && (__BORLANDC__ == 0x0551)\n#  define __CURL_OFF_T_C_HLPR2(x) x\n#  define __CURL_OFF_T_C_HLPR1(x) __CURL_OFF_T_C_HLPR2(x)\n#  define CURL_OFF_T_C(Val)  __CURL_OFF_T_C_HLPR1(Val) ## \\\n                             __CURL_OFF_T_C_HLPR1(CURL_SUFFIX_CURL_OFF_T)\n#  define CURL_OFF_TU_C(Val) __CURL_OFF_T_C_HLPR1(Val) ## \\\n                             __CURL_OFF_T_C_HLPR1(CURL_SUFFIX_CURL_OFF_TU)\n#else\n#  ifdef CURL_ISOCPP\n#    define __CURL_OFF_T_C_HLPR2(Val,Suffix) Val ## Suffix\n#  else\n#    define __CURL_OFF_T_C_HLPR2(Val,Suffix) Val/**/Suffix\n#  endif\n#  define __CURL_OFF_T_C_HLPR1(Val,Suffix) __CURL_OFF_T_C_HLPR2(Val,Suffix)\n#  define CURL_OFF_T_C(Val)  __CURL_OFF_T_C_HLPR1(Val,CURL_SUFFIX_CURL_OFF_T)\n#  define CURL_OFF_TU_C(Val) __CURL_OFF_T_C_HLPR1(Val,CURL_SUFFIX_CURL_OFF_TU)\n#endif\n\n/*\n * Get rid of macros private to this header file.\n */\n\n#undef CurlchkszEQ\n#undef CurlchkszGE\n\n/*\n * Get rid of macros not intended to exist beyond this point.\n */\n\n#undef CURL_PULL_WS2TCPIP_H\n#undef CURL_PULL_SYS_TYPES_H\n#undef CURL_PULL_SYS_SOCKET_H\n#undef CURL_PULL_SYS_POLL_H\n#undef CURL_PULL_STDINT_H\n#undef CURL_PULL_INTTYPES_H\n\n#undef CURL_TYPEOF_CURL_SOCKLEN_T\n#undef CURL_TYPEOF_CURL_OFF_T\n\n#ifdef CURL_NO_OLDIES\n#undef CURL_FORMAT_OFF_T /* not required since 7.19.0 - obsoleted in 7.20.0 */\n#endif\n\n#endif /* __CURL_CURLRULES_H */\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/curl/curlver.h",
    "content": "#ifndef __CURL_CURLVER_H\n#define __CURL_CURLVER_H\n/***************************************************************************\n *                                  _   _ ____  _\n *  Project                     ___| | | |  _ \\| |\n *                             / __| | | | |_) | |\n *                            | (__| |_| |  _ <| |___\n *                             \\___|\\___/|_| \\_\\_____|\n *\n * Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.\n *\n * This software is licensed as described in the file COPYING, which\n * you should have received as part of this distribution. The terms\n * are also available at http://curl.haxx.se/docs/copyright.html.\n *\n * You may opt to use, copy, modify, merge, publish, distribute and/or sell\n * copies of the Software, and permit persons to whom the Software is\n * furnished to do so, under the terms of the COPYING file.\n *\n * This software is distributed on an \"AS IS\" basis, WITHOUT WARRANTY OF ANY\n * KIND, either express or implied.\n *\n ***************************************************************************/\n\n/* This header file contains nothing but libcurl version info, generated by\n   a script at release-time. This was made its own header file in 7.11.2 */\n\n/* This is the global package copyright */\n#define LIBCURL_COPYRIGHT \"1996 - 2014 Daniel Stenberg, <daniel@haxx.se>.\"\n\n/* This is the version number of the libcurl package from which this header\n   file origins: */\n#define LIBCURL_VERSION \"7.38.0\"\n\n/* The numeric version number is also available \"in parts\" by using these\n   defines: */\n#define LIBCURL_VERSION_MAJOR 7\n#define LIBCURL_VERSION_MINOR 38\n#define LIBCURL_VERSION_PATCH 0\n\n/* This is the numeric version of the libcurl version number, meant for easier\n   parsing and comparions by programs. The LIBCURL_VERSION_NUM define will\n   always follow this syntax:\n\n         0xXXYYZZ\n\n   Where XX, YY and ZZ are the main version, release and patch numbers in\n   hexadecimal (using 8 bits each). All three numbers are always represented\n   using two digits.  1.2 would appear as \"0x010200\" while version 9.11.7\n   appears as \"0x090b07\".\n\n   This 6-digit (24 bits) hexadecimal number does not show pre-release number,\n   and it is always a greater number in a more recent release. It makes\n   comparisons with greater than and less than work.\n*/\n#define LIBCURL_VERSION_NUM 0x072600\n\n/*\n * This is the date and time when the full source package was created. The\n * timestamp is not stored in git, as the timestamp is properly set in the\n * tarballs by the maketgz script.\n *\n * The format of the date should follow this template:\n *\n * \"Mon Feb 12 11:35:33 UTC 2007\"\n */\n#define LIBCURL_TIMESTAMP \"Wed Sep 10 06:19:50 UTC 2014\"\n\n#endif /* __CURL_CURLVER_H */\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/curl/easy.h",
    "content": "#ifndef __CURL_EASY_H\n#define __CURL_EASY_H\n/***************************************************************************\n *                                  _   _ ____  _\n *  Project                     ___| | | |  _ \\| |\n *                             / __| | | | |_) | |\n *                            | (__| |_| |  _ <| |___\n *                             \\___|\\___/|_| \\_\\_____|\n *\n * Copyright (C) 1998 - 2008, Daniel Stenberg, <daniel@haxx.se>, et al.\n *\n * This software is licensed as described in the file COPYING, which\n * you should have received as part of this distribution. The terms\n * are also available at http://curl.haxx.se/docs/copyright.html.\n *\n * You may opt to use, copy, modify, merge, publish, distribute and/or sell\n * copies of the Software, and permit persons to whom the Software is\n * furnished to do so, under the terms of the COPYING file.\n *\n * This software is distributed on an \"AS IS\" basis, WITHOUT WARRANTY OF ANY\n * KIND, either express or implied.\n *\n ***************************************************************************/\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\nCURL_EXTERN CURL *curl_easy_init(void);\nCURL_EXTERN CURLcode curl_easy_setopt(CURL *curl, CURLoption option, ...);\nCURL_EXTERN CURLcode curl_easy_perform(CURL *curl);\nCURL_EXTERN void curl_easy_cleanup(CURL *curl);\n\n/*\n * NAME curl_easy_getinfo()\n *\n * DESCRIPTION\n *\n * Request internal information from the curl session with this function.  The\n * third argument MUST be a pointer to a long, a pointer to a char * or a\n * pointer to a double (as the documentation describes elsewhere).  The data\n * pointed to will be filled in accordingly and can be relied upon only if the\n * function returns CURLE_OK.  This function is intended to get used *AFTER* a\n * performed transfer, all results from this function are undefined until the\n * transfer is completed.\n */\nCURL_EXTERN CURLcode curl_easy_getinfo(CURL *curl, CURLINFO info, ...);\n\n\n/*\n * NAME curl_easy_duphandle()\n *\n * DESCRIPTION\n *\n * Creates a new curl session handle with the same options set for the handle\n * passed in. Duplicating a handle could only be a matter of cloning data and\n * options, internal state info and things like persistent connections cannot\n * be transferred. It is useful in multithreaded applications when you can run\n * curl_easy_duphandle() for each new thread to avoid a series of identical\n * curl_easy_setopt() invokes in every thread.\n */\nCURL_EXTERN CURL* curl_easy_duphandle(CURL *curl);\n\n/*\n * NAME curl_easy_reset()\n *\n * DESCRIPTION\n *\n * Re-initializes a CURL handle to the default values. This puts back the\n * handle to the same state as it was in when it was just created.\n *\n * It does keep: live connections, the Session ID cache, the DNS cache and the\n * cookies.\n */\nCURL_EXTERN void curl_easy_reset(CURL *curl);\n\n/*\n * NAME curl_easy_recv()\n *\n * DESCRIPTION\n *\n * Receives data from the connected socket. Use after successful\n * curl_easy_perform() with CURLOPT_CONNECT_ONLY option.\n */\nCURL_EXTERN CURLcode curl_easy_recv(CURL *curl, void *buffer, size_t buflen,\n                                    size_t *n);\n\n/*\n * NAME curl_easy_send()\n *\n * DESCRIPTION\n *\n * Sends data over the connected socket. Use after successful\n * curl_easy_perform() with CURLOPT_CONNECT_ONLY option.\n */\nCURL_EXTERN CURLcode curl_easy_send(CURL *curl, const void *buffer,\n                                    size_t buflen, size_t *n);\n\n#ifdef  __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/curl/mprintf.h",
    "content": "#ifndef __CURL_MPRINTF_H\n#define __CURL_MPRINTF_H\n/***************************************************************************\n *                                  _   _ ____  _\n *  Project                     ___| | | |  _ \\| |\n *                             / __| | | | |_) | |\n *                            | (__| |_| |  _ <| |___\n *                             \\___|\\___/|_| \\_\\_____|\n *\n * Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al.\n *\n * This software is licensed as described in the file COPYING, which\n * you should have received as part of this distribution. The terms\n * are also available at http://curl.haxx.se/docs/copyright.html.\n *\n * You may opt to use, copy, modify, merge, publish, distribute and/or sell\n * copies of the Software, and permit persons to whom the Software is\n * furnished to do so, under the terms of the COPYING file.\n *\n * This software is distributed on an \"AS IS\" basis, WITHOUT WARRANTY OF ANY\n * KIND, either express or implied.\n *\n ***************************************************************************/\n\n#include <stdarg.h>\n#include <stdio.h> /* needed for FILE */\n\n#include \"curl.h\"\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\nCURL_EXTERN int curl_mprintf(const char *format, ...);\nCURL_EXTERN int curl_mfprintf(FILE *fd, const char *format, ...);\nCURL_EXTERN int curl_msprintf(char *buffer, const char *format, ...);\nCURL_EXTERN int curl_msnprintf(char *buffer, size_t maxlength,\n                               const char *format, ...);\nCURL_EXTERN int curl_mvprintf(const char *format, va_list args);\nCURL_EXTERN int curl_mvfprintf(FILE *fd, const char *format, va_list args);\nCURL_EXTERN int curl_mvsprintf(char *buffer, const char *format, va_list args);\nCURL_EXTERN int curl_mvsnprintf(char *buffer, size_t maxlength,\n                                const char *format, va_list args);\nCURL_EXTERN char *curl_maprintf(const char *format, ...);\nCURL_EXTERN char *curl_mvaprintf(const char *format, va_list args);\n\n#ifdef _MPRINTF_REPLACE\n# undef printf\n# undef fprintf\n# undef sprintf\n# undef vsprintf\n# undef snprintf\n# undef vprintf\n# undef vfprintf\n# undef vsnprintf\n# undef aprintf\n# undef vaprintf\n# define printf curl_mprintf\n# define fprintf curl_mfprintf\n#ifdef CURLDEBUG\n/* When built with CURLDEBUG we define away the sprintf functions since we\n   don't want internal code to be using them */\n# define sprintf sprintf_was_used\n# define vsprintf vsprintf_was_used\n#else\n# define sprintf curl_msprintf\n# define vsprintf curl_mvsprintf\n#endif\n# define snprintf curl_msnprintf\n# define vprintf curl_mvprintf\n# define vfprintf curl_mvfprintf\n# define vsnprintf curl_mvsnprintf\n# define aprintf curl_maprintf\n# define vaprintf curl_mvaprintf\n#endif\n\n#ifdef  __cplusplus\n}\n#endif\n\n#endif /* __CURL_MPRINTF_H */\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/curl/multi.h",
    "content": "#ifndef __CURL_MULTI_H\n#define __CURL_MULTI_H\n/***************************************************************************\n *                                  _   _ ____  _\n *  Project                     ___| | | |  _ \\| |\n *                             / __| | | | |_) | |\n *                            | (__| |_| |  _ <| |___\n *                             \\___|\\___/|_| \\_\\_____|\n *\n * Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al.\n *\n * This software is licensed as described in the file COPYING, which\n * you should have received as part of this distribution. The terms\n * are also available at http://curl.haxx.se/docs/copyright.html.\n *\n * You may opt to use, copy, modify, merge, publish, distribute and/or sell\n * copies of the Software, and permit persons to whom the Software is\n * furnished to do so, under the terms of the COPYING file.\n *\n * This software is distributed on an \"AS IS\" basis, WITHOUT WARRANTY OF ANY\n * KIND, either express or implied.\n *\n ***************************************************************************/\n/*\n  This is an \"external\" header file. Don't give away any internals here!\n\n  GOALS\n\n  o Enable a \"pull\" interface. The application that uses libcurl decides where\n    and when to ask libcurl to get/send data.\n\n  o Enable multiple simultaneous transfers in the same thread without making it\n    complicated for the application.\n\n  o Enable the application to select() on its own file descriptors and curl's\n    file descriptors simultaneous easily.\n\n*/\n\n/*\n * This header file should not really need to include \"curl.h\" since curl.h\n * itself includes this file and we expect user applications to do #include\n * <curl/curl.h> without the need for especially including multi.h.\n *\n * For some reason we added this include here at one point, and rather than to\n * break existing (wrongly written) libcurl applications, we leave it as-is\n * but with this warning attached.\n */\n#include \"curl.h\"\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\ntypedef void CURLM;\n\ntypedef enum {\n  CURLM_CALL_MULTI_PERFORM = -1, /* please call curl_multi_perform() or\n                                    curl_multi_socket*() soon */\n  CURLM_OK,\n  CURLM_BAD_HANDLE,      /* the passed-in handle is not a valid CURLM handle */\n  CURLM_BAD_EASY_HANDLE, /* an easy handle was not good/valid */\n  CURLM_OUT_OF_MEMORY,   /* if you ever get this, you're in deep sh*t */\n  CURLM_INTERNAL_ERROR,  /* this is a libcurl bug */\n  CURLM_BAD_SOCKET,      /* the passed in socket argument did not match */\n  CURLM_UNKNOWN_OPTION,  /* curl_multi_setopt() with unsupported option */\n  CURLM_ADDED_ALREADY,   /* an easy handle already added to a multi handle was\n                            attempted to get added - again */\n  CURLM_LAST\n} CURLMcode;\n\n/* just to make code nicer when using curl_multi_socket() you can now check\n   for CURLM_CALL_MULTI_SOCKET too in the same style it works for\n   curl_multi_perform() and CURLM_CALL_MULTI_PERFORM */\n#define CURLM_CALL_MULTI_SOCKET CURLM_CALL_MULTI_PERFORM\n\ntypedef enum {\n  CURLMSG_NONE, /* first, not used */\n  CURLMSG_DONE, /* This easy handle has completed. 'result' contains\n                   the CURLcode of the transfer */\n  CURLMSG_LAST /* last, not used */\n} CURLMSG;\n\nstruct CURLMsg {\n  CURLMSG msg;       /* what this message means */\n  CURL *easy_handle; /* the handle it concerns */\n  union {\n    void *whatever;    /* message-specific data */\n    CURLcode result;   /* return code for transfer */\n  } data;\n};\ntypedef struct CURLMsg CURLMsg;\n\n/* Based on poll(2) structure and values.\n * We don't use pollfd and POLL* constants explicitly\n * to cover platforms without poll(). */\n#define CURL_WAIT_POLLIN    0x0001\n#define CURL_WAIT_POLLPRI   0x0002\n#define CURL_WAIT_POLLOUT   0x0004\n\nstruct curl_waitfd {\n  curl_socket_t fd;\n  short events;\n  short revents; /* not supported yet */\n};\n\n/*\n * Name:    curl_multi_init()\n *\n * Desc:    inititalize multi-style curl usage\n *\n * Returns: a new CURLM handle to use in all 'curl_multi' functions.\n */\nCURL_EXTERN CURLM *curl_multi_init(void);\n\n/*\n * Name:    curl_multi_add_handle()\n *\n * Desc:    add a standard curl handle to the multi stack\n *\n * Returns: CURLMcode type, general multi error code.\n */\nCURL_EXTERN CURLMcode curl_multi_add_handle(CURLM *multi_handle,\n                                            CURL *curl_handle);\n\n /*\n  * Name:    curl_multi_remove_handle()\n  *\n  * Desc:    removes a curl handle from the multi stack again\n  *\n  * Returns: CURLMcode type, general multi error code.\n  */\nCURL_EXTERN CURLMcode curl_multi_remove_handle(CURLM *multi_handle,\n                                               CURL *curl_handle);\n\n /*\n  * Name:    curl_multi_fdset()\n  *\n  * Desc:    Ask curl for its fd_set sets. The app can use these to select() or\n  *          poll() on. We want curl_multi_perform() called as soon as one of\n  *          them are ready.\n  *\n  * Returns: CURLMcode type, general multi error code.\n  */\nCURL_EXTERN CURLMcode curl_multi_fdset(CURLM *multi_handle,\n                                       fd_set *read_fd_set,\n                                       fd_set *write_fd_set,\n                                       fd_set *exc_fd_set,\n                                       int *max_fd);\n\n/*\n * Name:     curl_multi_wait()\n *\n * Desc:     Poll on all fds within a CURLM set as well as any\n *           additional fds passed to the function.\n *\n * Returns:  CURLMcode type, general multi error code.\n */\nCURL_EXTERN CURLMcode curl_multi_wait(CURLM *multi_handle,\n                                      struct curl_waitfd extra_fds[],\n                                      unsigned int extra_nfds,\n                                      int timeout_ms,\n                                      int *ret);\n\n /*\n  * Name:    curl_multi_perform()\n  *\n  * Desc:    When the app thinks there's data available for curl it calls this\n  *          function to read/write whatever there is right now. This returns\n  *          as soon as the reads and writes are done. This function does not\n  *          require that there actually is data available for reading or that\n  *          data can be written, it can be called just in case. It returns\n  *          the number of handles that still transfer data in the second\n  *          argument's integer-pointer.\n  *\n  * Returns: CURLMcode type, general multi error code. *NOTE* that this only\n  *          returns errors etc regarding the whole multi stack. There might\n  *          still have occurred problems on invidual transfers even when this\n  *          returns OK.\n  */\nCURL_EXTERN CURLMcode curl_multi_perform(CURLM *multi_handle,\n                                         int *running_handles);\n\n /*\n  * Name:    curl_multi_cleanup()\n  *\n  * Desc:    Cleans up and removes a whole multi stack. It does not free or\n  *          touch any individual easy handles in any way. We need to define\n  *          in what state those handles will be if this function is called\n  *          in the middle of a transfer.\n  *\n  * Returns: CURLMcode type, general multi error code.\n  */\nCURL_EXTERN CURLMcode curl_multi_cleanup(CURLM *multi_handle);\n\n/*\n * Name:    curl_multi_info_read()\n *\n * Desc:    Ask the multi handle if there's any messages/informationals from\n *          the individual transfers. Messages include informationals such as\n *          error code from the transfer or just the fact that a transfer is\n *          completed. More details on these should be written down as well.\n *\n *          Repeated calls to this function will return a new struct each\n *          time, until a special \"end of msgs\" struct is returned as a signal\n *          that there is no more to get at this point.\n *\n *          The data the returned pointer points to will not survive calling\n *          curl_multi_cleanup().\n *\n *          The 'CURLMsg' struct is meant to be very simple and only contain\n *          very basic informations. If more involved information is wanted,\n *          we will provide the particular \"transfer handle\" in that struct\n *          and that should/could/would be used in subsequent\n *          curl_easy_getinfo() calls (or similar). The point being that we\n *          must never expose complex structs to applications, as then we'll\n *          undoubtably get backwards compatibility problems in the future.\n *\n * Returns: A pointer to a filled-in struct, or NULL if it failed or ran out\n *          of structs. It also writes the number of messages left in the\n *          queue (after this read) in the integer the second argument points\n *          to.\n */\nCURL_EXTERN CURLMsg *curl_multi_info_read(CURLM *multi_handle,\n                                          int *msgs_in_queue);\n\n/*\n * Name:    curl_multi_strerror()\n *\n * Desc:    The curl_multi_strerror function may be used to turn a CURLMcode\n *          value into the equivalent human readable error string.  This is\n *          useful for printing meaningful error messages.\n *\n * Returns: A pointer to a zero-terminated error message.\n */\nCURL_EXTERN const char *curl_multi_strerror(CURLMcode);\n\n/*\n * Name:    curl_multi_socket() and\n *          curl_multi_socket_all()\n *\n * Desc:    An alternative version of curl_multi_perform() that allows the\n *          application to pass in one of the file descriptors that have been\n *          detected to have \"action\" on them and let libcurl perform.\n *          See man page for details.\n */\n#define CURL_POLL_NONE   0\n#define CURL_POLL_IN     1\n#define CURL_POLL_OUT    2\n#define CURL_POLL_INOUT  3\n#define CURL_POLL_REMOVE 4\n\n#define CURL_SOCKET_TIMEOUT CURL_SOCKET_BAD\n\n#define CURL_CSELECT_IN   0x01\n#define CURL_CSELECT_OUT  0x02\n#define CURL_CSELECT_ERR  0x04\n\ntypedef int (*curl_socket_callback)(CURL *easy,      /* easy handle */\n                                    curl_socket_t s, /* socket */\n                                    int what,        /* see above */\n                                    void *userp,     /* private callback\n                                                        pointer */\n                                    void *socketp);  /* private socket\n                                                        pointer */\n/*\n * Name:    curl_multi_timer_callback\n *\n * Desc:    Called by libcurl whenever the library detects a change in the\n *          maximum number of milliseconds the app is allowed to wait before\n *          curl_multi_socket() or curl_multi_perform() must be called\n *          (to allow libcurl's timed events to take place).\n *\n * Returns: The callback should return zero.\n */\ntypedef int (*curl_multi_timer_callback)(CURLM *multi,    /* multi handle */\n                                         long timeout_ms, /* see above */\n                                         void *userp);    /* private callback\n                                                             pointer */\n\nCURL_EXTERN CURLMcode curl_multi_socket(CURLM *multi_handle, curl_socket_t s,\n                                        int *running_handles);\n\nCURL_EXTERN CURLMcode curl_multi_socket_action(CURLM *multi_handle,\n                                               curl_socket_t s,\n                                               int ev_bitmask,\n                                               int *running_handles);\n\nCURL_EXTERN CURLMcode curl_multi_socket_all(CURLM *multi_handle,\n                                            int *running_handles);\n\n#ifndef CURL_ALLOW_OLD_MULTI_SOCKET\n/* This macro below was added in 7.16.3 to push users who recompile to use\n   the new curl_multi_socket_action() instead of the old curl_multi_socket()\n*/\n#define curl_multi_socket(x,y,z) curl_multi_socket_action(x,y,0,z)\n#endif\n\n/*\n * Name:    curl_multi_timeout()\n *\n * Desc:    Returns the maximum number of milliseconds the app is allowed to\n *          wait before curl_multi_socket() or curl_multi_perform() must be\n *          called (to allow libcurl's timed events to take place).\n *\n * Returns: CURLM error code.\n */\nCURL_EXTERN CURLMcode curl_multi_timeout(CURLM *multi_handle,\n                                         long *milliseconds);\n\n#undef CINIT /* re-using the same name as in curl.h */\n\n#ifdef CURL_ISOCPP\n#define CINIT(name,type,num) CURLMOPT_ ## name = CURLOPTTYPE_ ## type + num\n#else\n/* The macro \"##\" is ISO C, we assume pre-ISO C doesn't support it. */\n#define LONG          CURLOPTTYPE_LONG\n#define OBJECTPOINT   CURLOPTTYPE_OBJECTPOINT\n#define FUNCTIONPOINT CURLOPTTYPE_FUNCTIONPOINT\n#define OFF_T         CURLOPTTYPE_OFF_T\n#define CINIT(name,type,number) CURLMOPT_/**/name = type + number\n#endif\n\ntypedef enum {\n  /* This is the socket callback function pointer */\n  CINIT(SOCKETFUNCTION, FUNCTIONPOINT, 1),\n\n  /* This is the argument passed to the socket callback */\n  CINIT(SOCKETDATA, OBJECTPOINT, 2),\n\n    /* set to 1 to enable pipelining for this multi handle */\n  CINIT(PIPELINING, LONG, 3),\n\n   /* This is the timer callback function pointer */\n  CINIT(TIMERFUNCTION, FUNCTIONPOINT, 4),\n\n  /* This is the argument passed to the timer callback */\n  CINIT(TIMERDATA, OBJECTPOINT, 5),\n\n  /* maximum number of entries in the connection cache */\n  CINIT(MAXCONNECTS, LONG, 6),\n\n  /* maximum number of (pipelining) connections to one host */\n  CINIT(MAX_HOST_CONNECTIONS, LONG, 7),\n\n  /* maximum number of requests in a pipeline */\n  CINIT(MAX_PIPELINE_LENGTH, LONG, 8),\n\n  /* a connection with a content-length longer than this\n     will not be considered for pipelining */\n  CINIT(CONTENT_LENGTH_PENALTY_SIZE, OFF_T, 9),\n\n  /* a connection with a chunk length longer than this\n     will not be considered for pipelining */\n  CINIT(CHUNK_LENGTH_PENALTY_SIZE, OFF_T, 10),\n\n  /* a list of site names(+port) that are blacklisted from\n     pipelining */\n  CINIT(PIPELINING_SITE_BL, OBJECTPOINT, 11),\n\n  /* a list of server types that are blacklisted from\n     pipelining */\n  CINIT(PIPELINING_SERVER_BL, OBJECTPOINT, 12),\n\n  /* maximum number of open connections in total */\n  CINIT(MAX_TOTAL_CONNECTIONS, LONG, 13),\n\n  CURLMOPT_LASTENTRY /* the last unused */\n} CURLMoption;\n\n\n/*\n * Name:    curl_multi_setopt()\n *\n * Desc:    Sets options for the multi handle.\n *\n * Returns: CURLM error code.\n */\nCURL_EXTERN CURLMcode curl_multi_setopt(CURLM *multi_handle,\n                                        CURLMoption option, ...);\n\n\n/*\n * Name:    curl_multi_assign()\n *\n * Desc:    This function sets an association in the multi handle between the\n *          given socket and a private pointer of the application. This is\n *          (only) useful for curl_multi_socket uses.\n *\n * Returns: CURLM error code.\n */\nCURL_EXTERN CURLMcode curl_multi_assign(CURLM *multi_handle,\n                                        curl_socket_t sockfd, void *sockp);\n\n#ifdef __cplusplus\n} /* end of extern \"C\" */\n#endif\n\n#endif\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/curl/stdcheaders.h",
    "content": "#ifndef __STDC_HEADERS_H\n#define __STDC_HEADERS_H\n/***************************************************************************\n *                                  _   _ ____  _\n *  Project                     ___| | | |  _ \\| |\n *                             / __| | | | |_) | |\n *                            | (__| |_| |  _ <| |___\n *                             \\___|\\___/|_| \\_\\_____|\n *\n * Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al.\n *\n * This software is licensed as described in the file COPYING, which\n * you should have received as part of this distribution. The terms\n * are also available at http://curl.haxx.se/docs/copyright.html.\n *\n * You may opt to use, copy, modify, merge, publish, distribute and/or sell\n * copies of the Software, and permit persons to whom the Software is\n * furnished to do so, under the terms of the COPYING file.\n *\n * This software is distributed on an \"AS IS\" basis, WITHOUT WARRANTY OF ANY\n * KIND, either express or implied.\n *\n ***************************************************************************/\n\n#include <sys/types.h>\n\nsize_t fread (void *, size_t, size_t, FILE *);\nsize_t fwrite (const void *, size_t, size_t, FILE *);\n\nint strcasecmp(const char *, const char *);\nint strncasecmp(const char *, const char *, size_t);\n\n#endif /* __STDC_HEADERS_H */\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/curl/typecheck-gcc.h",
    "content": "#ifndef __CURL_TYPECHECK_GCC_H\n#define __CURL_TYPECHECK_GCC_H\n/***************************************************************************\n *                                  _   _ ____  _\n *  Project                     ___| | | |  _ \\| |\n *                             / __| | | | |_) | |\n *                            | (__| |_| |  _ <| |___\n *                             \\___|\\___/|_| \\_\\_____|\n *\n * Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.\n *\n * This software is licensed as described in the file COPYING, which\n * you should have received as part of this distribution. The terms\n * are also available at http://curl.haxx.se/docs/copyright.html.\n *\n * You may opt to use, copy, modify, merge, publish, distribute and/or sell\n * copies of the Software, and permit persons to whom the Software is\n * furnished to do so, under the terms of the COPYING file.\n *\n * This software is distributed on an \"AS IS\" basis, WITHOUT WARRANTY OF ANY\n * KIND, either express or implied.\n *\n ***************************************************************************/\n\n/* wraps curl_easy_setopt() with typechecking */\n\n/* To add a new kind of warning, add an\n *   if(_curl_is_sometype_option(_curl_opt))\n *     if(!_curl_is_sometype(value))\n *       _curl_easy_setopt_err_sometype();\n * block and define _curl_is_sometype_option, _curl_is_sometype and\n * _curl_easy_setopt_err_sometype below\n *\n * NOTE: We use two nested 'if' statements here instead of the && operator, in\n *       order to work around gcc bug #32061.  It affects only gcc 4.3.x/4.4.x\n *       when compiling with -Wlogical-op.\n *\n * To add an option that uses the same type as an existing option, you'll just\n * need to extend the appropriate _curl_*_option macro\n */\n#define curl_easy_setopt(handle, option, value)                               \\\n__extension__ ({                                                              \\\n  __typeof__ (option) _curl_opt = option;                                     \\\n  if(__builtin_constant_p(_curl_opt)) {                                       \\\n    if(_curl_is_long_option(_curl_opt))                                       \\\n      if(!_curl_is_long(value))                                               \\\n        _curl_easy_setopt_err_long();                                         \\\n    if(_curl_is_off_t_option(_curl_opt))                                      \\\n      if(!_curl_is_off_t(value))                                              \\\n        _curl_easy_setopt_err_curl_off_t();                                   \\\n    if(_curl_is_string_option(_curl_opt))                                     \\\n      if(!_curl_is_string(value))                                             \\\n        _curl_easy_setopt_err_string();                                       \\\n    if(_curl_is_write_cb_option(_curl_opt))                                   \\\n      if(!_curl_is_write_cb(value))                                           \\\n        _curl_easy_setopt_err_write_callback();                               \\\n    if((_curl_opt) == CURLOPT_READFUNCTION)                                   \\\n      if(!_curl_is_read_cb(value))                                            \\\n        _curl_easy_setopt_err_read_cb();                                      \\\n    if((_curl_opt) == CURLOPT_IOCTLFUNCTION)                                  \\\n      if(!_curl_is_ioctl_cb(value))                                           \\\n        _curl_easy_setopt_err_ioctl_cb();                                     \\\n    if((_curl_opt) == CURLOPT_SOCKOPTFUNCTION)                                \\\n      if(!_curl_is_sockopt_cb(value))                                         \\\n        _curl_easy_setopt_err_sockopt_cb();                                   \\\n    if((_curl_opt) == CURLOPT_OPENSOCKETFUNCTION)                             \\\n      if(!_curl_is_opensocket_cb(value))                                      \\\n        _curl_easy_setopt_err_opensocket_cb();                                \\\n    if((_curl_opt) == CURLOPT_PROGRESSFUNCTION)                               \\\n      if(!_curl_is_progress_cb(value))                                        \\\n        _curl_easy_setopt_err_progress_cb();                                  \\\n    if((_curl_opt) == CURLOPT_DEBUGFUNCTION)                                  \\\n      if(!_curl_is_debug_cb(value))                                           \\\n        _curl_easy_setopt_err_debug_cb();                                     \\\n    if((_curl_opt) == CURLOPT_SSL_CTX_FUNCTION)                               \\\n      if(!_curl_is_ssl_ctx_cb(value))                                         \\\n        _curl_easy_setopt_err_ssl_ctx_cb();                                   \\\n    if(_curl_is_conv_cb_option(_curl_opt))                                    \\\n      if(!_curl_is_conv_cb(value))                                            \\\n        _curl_easy_setopt_err_conv_cb();                                      \\\n    if((_curl_opt) == CURLOPT_SEEKFUNCTION)                                   \\\n      if(!_curl_is_seek_cb(value))                                            \\\n        _curl_easy_setopt_err_seek_cb();                                      \\\n    if(_curl_is_cb_data_option(_curl_opt))                                    \\\n      if(!_curl_is_cb_data(value))                                            \\\n        _curl_easy_setopt_err_cb_data();                                      \\\n    if((_curl_opt) == CURLOPT_ERRORBUFFER)                                    \\\n      if(!_curl_is_error_buffer(value))                                       \\\n        _curl_easy_setopt_err_error_buffer();                                 \\\n    if((_curl_opt) == CURLOPT_STDERR)                                         \\\n      if(!_curl_is_FILE(value))                                               \\\n        _curl_easy_setopt_err_FILE();                                         \\\n    if(_curl_is_postfields_option(_curl_opt))                                 \\\n      if(!_curl_is_postfields(value))                                         \\\n        _curl_easy_setopt_err_postfields();                                   \\\n    if((_curl_opt) == CURLOPT_HTTPPOST)                                       \\\n      if(!_curl_is_arr((value), struct curl_httppost))                        \\\n        _curl_easy_setopt_err_curl_httpost();                                 \\\n    if(_curl_is_slist_option(_curl_opt))                                      \\\n      if(!_curl_is_arr((value), struct curl_slist))                           \\\n        _curl_easy_setopt_err_curl_slist();                                   \\\n    if((_curl_opt) == CURLOPT_SHARE)                                          \\\n      if(!_curl_is_ptr((value), CURLSH))                                      \\\n        _curl_easy_setopt_err_CURLSH();                                       \\\n  }                                                                           \\\n  curl_easy_setopt(handle, _curl_opt, value);                                 \\\n})\n\n/* wraps curl_easy_getinfo() with typechecking */\n/* FIXME: don't allow const pointers */\n#define curl_easy_getinfo(handle, info, arg)                                  \\\n__extension__ ({                                                              \\\n  __typeof__ (info) _curl_info = info;                                        \\\n  if(__builtin_constant_p(_curl_info)) {                                      \\\n    if(_curl_is_string_info(_curl_info))                                      \\\n      if(!_curl_is_arr((arg), char *))                                        \\\n        _curl_easy_getinfo_err_string();                                      \\\n    if(_curl_is_long_info(_curl_info))                                        \\\n      if(!_curl_is_arr((arg), long))                                          \\\n        _curl_easy_getinfo_err_long();                                        \\\n    if(_curl_is_double_info(_curl_info))                                      \\\n      if(!_curl_is_arr((arg), double))                                        \\\n        _curl_easy_getinfo_err_double();                                      \\\n    if(_curl_is_slist_info(_curl_info))                                       \\\n      if(!_curl_is_arr((arg), struct curl_slist *))                           \\\n        _curl_easy_getinfo_err_curl_slist();                                  \\\n  }                                                                           \\\n  curl_easy_getinfo(handle, _curl_info, arg);                                 \\\n})\n\n/* TODO: typechecking for curl_share_setopt() and curl_multi_setopt(),\n * for now just make sure that the functions are called with three\n * arguments\n */\n#define curl_share_setopt(share,opt,param) curl_share_setopt(share,opt,param)\n#define curl_multi_setopt(handle,opt,param) curl_multi_setopt(handle,opt,param)\n\n\n/* the actual warnings, triggered by calling the _curl_easy_setopt_err*\n * functions */\n\n/* To define a new warning, use _CURL_WARNING(identifier, \"message\") */\n#define _CURL_WARNING(id, message)                                            \\\n  static void __attribute__((__warning__(message)))                           \\\n  __attribute__((__unused__)) __attribute__((__noinline__))                   \\\n  id(void) { __asm__(\"\"); }\n\n_CURL_WARNING(_curl_easy_setopt_err_long,\n  \"curl_easy_setopt expects a long argument for this option\")\n_CURL_WARNING(_curl_easy_setopt_err_curl_off_t,\n  \"curl_easy_setopt expects a curl_off_t argument for this option\")\n_CURL_WARNING(_curl_easy_setopt_err_string,\n              \"curl_easy_setopt expects a \"\n              \"string (char* or char[]) argument for this option\"\n  )\n_CURL_WARNING(_curl_easy_setopt_err_write_callback,\n  \"curl_easy_setopt expects a curl_write_callback argument for this option\")\n_CURL_WARNING(_curl_easy_setopt_err_read_cb,\n  \"curl_easy_setopt expects a curl_read_callback argument for this option\")\n_CURL_WARNING(_curl_easy_setopt_err_ioctl_cb,\n  \"curl_easy_setopt expects a curl_ioctl_callback argument for this option\")\n_CURL_WARNING(_curl_easy_setopt_err_sockopt_cb,\n  \"curl_easy_setopt expects a curl_sockopt_callback argument for this option\")\n_CURL_WARNING(_curl_easy_setopt_err_opensocket_cb,\n              \"curl_easy_setopt expects a \"\n              \"curl_opensocket_callback argument for this option\"\n  )\n_CURL_WARNING(_curl_easy_setopt_err_progress_cb,\n  \"curl_easy_setopt expects a curl_progress_callback argument for this option\")\n_CURL_WARNING(_curl_easy_setopt_err_debug_cb,\n  \"curl_easy_setopt expects a curl_debug_callback argument for this option\")\n_CURL_WARNING(_curl_easy_setopt_err_ssl_ctx_cb,\n  \"curl_easy_setopt expects a curl_ssl_ctx_callback argument for this option\")\n_CURL_WARNING(_curl_easy_setopt_err_conv_cb,\n  \"curl_easy_setopt expects a curl_conv_callback argument for this option\")\n_CURL_WARNING(_curl_easy_setopt_err_seek_cb,\n  \"curl_easy_setopt expects a curl_seek_callback argument for this option\")\n_CURL_WARNING(_curl_easy_setopt_err_cb_data,\n              \"curl_easy_setopt expects a \"\n              \"private data pointer as argument for this option\")\n_CURL_WARNING(_curl_easy_setopt_err_error_buffer,\n              \"curl_easy_setopt expects a \"\n              \"char buffer of CURL_ERROR_SIZE as argument for this option\")\n_CURL_WARNING(_curl_easy_setopt_err_FILE,\n  \"curl_easy_setopt expects a FILE* argument for this option\")\n_CURL_WARNING(_curl_easy_setopt_err_postfields,\n  \"curl_easy_setopt expects a void* or char* argument for this option\")\n_CURL_WARNING(_curl_easy_setopt_err_curl_httpost,\n  \"curl_easy_setopt expects a struct curl_httppost* argument for this option\")\n_CURL_WARNING(_curl_easy_setopt_err_curl_slist,\n  \"curl_easy_setopt expects a struct curl_slist* argument for this option\")\n_CURL_WARNING(_curl_easy_setopt_err_CURLSH,\n  \"curl_easy_setopt expects a CURLSH* argument for this option\")\n\n_CURL_WARNING(_curl_easy_getinfo_err_string,\n  \"curl_easy_getinfo expects a pointer to char * for this info\")\n_CURL_WARNING(_curl_easy_getinfo_err_long,\n  \"curl_easy_getinfo expects a pointer to long for this info\")\n_CURL_WARNING(_curl_easy_getinfo_err_double,\n  \"curl_easy_getinfo expects a pointer to double for this info\")\n_CURL_WARNING(_curl_easy_getinfo_err_curl_slist,\n  \"curl_easy_getinfo expects a pointer to struct curl_slist * for this info\")\n\n/* groups of curl_easy_setops options that take the same type of argument */\n\n/* To add a new option to one of the groups, just add\n *   (option) == CURLOPT_SOMETHING\n * to the or-expression. If the option takes a long or curl_off_t, you don't\n * have to do anything\n */\n\n/* evaluates to true if option takes a long argument */\n#define _curl_is_long_option(option)                                          \\\n  (0 < (option) && (option) < CURLOPTTYPE_OBJECTPOINT)\n\n#define _curl_is_off_t_option(option)                                         \\\n  ((option) > CURLOPTTYPE_OFF_T)\n\n/* evaluates to true if option takes a char* argument */\n#define _curl_is_string_option(option)                                        \\\n  ((option) == CURLOPT_URL ||                                                 \\\n   (option) == CURLOPT_PROXY ||                                               \\\n   (option) == CURLOPT_INTERFACE ||                                           \\\n   (option) == CURLOPT_NETRC_FILE ||                                          \\\n   (option) == CURLOPT_USERPWD ||                                             \\\n   (option) == CURLOPT_USERNAME ||                                            \\\n   (option) == CURLOPT_PASSWORD ||                                            \\\n   (option) == CURLOPT_PROXYUSERPWD ||                                        \\\n   (option) == CURLOPT_PROXYUSERNAME ||                                       \\\n   (option) == CURLOPT_PROXYPASSWORD ||                                       \\\n   (option) == CURLOPT_NOPROXY ||                                             \\\n   (option) == CURLOPT_ACCEPT_ENCODING ||                                     \\\n   (option) == CURLOPT_REFERER ||                                             \\\n   (option) == CURLOPT_USERAGENT ||                                           \\\n   (option) == CURLOPT_COOKIE ||                                              \\\n   (option) == CURLOPT_COOKIEFILE ||                                          \\\n   (option) == CURLOPT_COOKIEJAR ||                                           \\\n   (option) == CURLOPT_COOKIELIST ||                                          \\\n   (option) == CURLOPT_FTPPORT ||                                             \\\n   (option) == CURLOPT_FTP_ALTERNATIVE_TO_USER ||                             \\\n   (option) == CURLOPT_FTP_ACCOUNT ||                                         \\\n   (option) == CURLOPT_RANGE ||                                               \\\n   (option) == CURLOPT_CUSTOMREQUEST ||                                       \\\n   (option) == CURLOPT_SSLCERT ||                                             \\\n   (option) == CURLOPT_SSLCERTTYPE ||                                         \\\n   (option) == CURLOPT_SSLKEY ||                                              \\\n   (option) == CURLOPT_SSLKEYTYPE ||                                          \\\n   (option) == CURLOPT_KEYPASSWD ||                                           \\\n   (option) == CURLOPT_SSLENGINE ||                                           \\\n   (option) == CURLOPT_CAINFO ||                                              \\\n   (option) == CURLOPT_CAPATH ||                                              \\\n   (option) == CURLOPT_RANDOM_FILE ||                                         \\\n   (option) == CURLOPT_EGDSOCKET ||                                           \\\n   (option) == CURLOPT_SSL_CIPHER_LIST ||                                     \\\n   (option) == CURLOPT_KRBLEVEL ||                                            \\\n   (option) == CURLOPT_SSH_HOST_PUBLIC_KEY_MD5 ||                             \\\n   (option) == CURLOPT_SSH_PUBLIC_KEYFILE ||                                  \\\n   (option) == CURLOPT_SSH_PRIVATE_KEYFILE ||                                 \\\n   (option) == CURLOPT_CRLFILE ||                                             \\\n   (option) == CURLOPT_ISSUERCERT ||                                          \\\n   (option) == CURLOPT_SOCKS5_GSSAPI_SERVICE ||                               \\\n   (option) == CURLOPT_SSH_KNOWNHOSTS ||                                      \\\n   (option) == CURLOPT_MAIL_FROM ||                                           \\\n   (option) == CURLOPT_RTSP_SESSION_ID ||                                     \\\n   (option) == CURLOPT_RTSP_STREAM_URI ||                                     \\\n   (option) == CURLOPT_RTSP_TRANSPORT ||                                      \\\n   (option) == CURLOPT_XOAUTH2_BEARER ||                                      \\\n   (option) == CURLOPT_DNS_SERVERS ||                                         \\\n   (option) == CURLOPT_DNS_INTERFACE ||                                       \\\n   (option) == CURLOPT_DNS_LOCAL_IP4 ||                                       \\\n   (option) == CURLOPT_DNS_LOCAL_IP6 ||                                       \\\n   (option) == CURLOPT_LOGIN_OPTIONS ||                                       \\\n   0)\n\n/* evaluates to true if option takes a curl_write_callback argument */\n#define _curl_is_write_cb_option(option)                                      \\\n  ((option) == CURLOPT_HEADERFUNCTION ||                                      \\\n   (option) == CURLOPT_WRITEFUNCTION)\n\n/* evaluates to true if option takes a curl_conv_callback argument */\n#define _curl_is_conv_cb_option(option)                                       \\\n  ((option) == CURLOPT_CONV_TO_NETWORK_FUNCTION ||                            \\\n   (option) == CURLOPT_CONV_FROM_NETWORK_FUNCTION ||                          \\\n   (option) == CURLOPT_CONV_FROM_UTF8_FUNCTION)\n\n/* evaluates to true if option takes a data argument to pass to a callback */\n#define _curl_is_cb_data_option(option)                                       \\\n  ((option) == CURLOPT_WRITEDATA ||                                           \\\n   (option) == CURLOPT_READDATA ||                                            \\\n   (option) == CURLOPT_IOCTLDATA ||                                           \\\n   (option) == CURLOPT_SOCKOPTDATA ||                                         \\\n   (option) == CURLOPT_OPENSOCKETDATA ||                                      \\\n   (option) == CURLOPT_PROGRESSDATA ||                                        \\\n   (option) == CURLOPT_HEADERDATA ||                                         \\\n   (option) == CURLOPT_DEBUGDATA ||                                           \\\n   (option) == CURLOPT_SSL_CTX_DATA ||                                        \\\n   (option) == CURLOPT_SEEKDATA ||                                            \\\n   (option) == CURLOPT_PRIVATE ||                                             \\\n   (option) == CURLOPT_SSH_KEYDATA ||                                         \\\n   (option) == CURLOPT_INTERLEAVEDATA ||                                      \\\n   (option) == CURLOPT_CHUNK_DATA ||                                          \\\n   (option) == CURLOPT_FNMATCH_DATA ||                                        \\\n   0)\n\n/* evaluates to true if option takes a POST data argument (void* or char*) */\n#define _curl_is_postfields_option(option)                                    \\\n  ((option) == CURLOPT_POSTFIELDS ||                                          \\\n   (option) == CURLOPT_COPYPOSTFIELDS ||                                      \\\n   0)\n\n/* evaluates to true if option takes a struct curl_slist * argument */\n#define _curl_is_slist_option(option)                                         \\\n  ((option) == CURLOPT_HTTPHEADER ||                                          \\\n   (option) == CURLOPT_HTTP200ALIASES ||                                      \\\n   (option) == CURLOPT_QUOTE ||                                               \\\n   (option) == CURLOPT_POSTQUOTE ||                                           \\\n   (option) == CURLOPT_PREQUOTE ||                                            \\\n   (option) == CURLOPT_TELNETOPTIONS ||                                       \\\n   (option) == CURLOPT_MAIL_RCPT ||                                           \\\n   0)\n\n/* groups of curl_easy_getinfo infos that take the same type of argument */\n\n/* evaluates to true if info expects a pointer to char * argument */\n#define _curl_is_string_info(info)                                            \\\n  (CURLINFO_STRING < (info) && (info) < CURLINFO_LONG)\n\n/* evaluates to true if info expects a pointer to long argument */\n#define _curl_is_long_info(info)                                              \\\n  (CURLINFO_LONG < (info) && (info) < CURLINFO_DOUBLE)\n\n/* evaluates to true if info expects a pointer to double argument */\n#define _curl_is_double_info(info)                                            \\\n  (CURLINFO_DOUBLE < (info) && (info) < CURLINFO_SLIST)\n\n/* true if info expects a pointer to struct curl_slist * argument */\n#define _curl_is_slist_info(info)                                             \\\n  (CURLINFO_SLIST < (info))\n\n\n/* typecheck helpers -- check whether given expression has requested type*/\n\n/* For pointers, you can use the _curl_is_ptr/_curl_is_arr macros,\n * otherwise define a new macro. Search for __builtin_types_compatible_p\n * in the GCC manual.\n * NOTE: these macros MUST NOT EVALUATE their arguments! The argument is\n * the actual expression passed to the curl_easy_setopt macro. This\n * means that you can only apply the sizeof and __typeof__ operators, no\n * == or whatsoever.\n */\n\n/* XXX: should evaluate to true iff expr is a pointer */\n#define _curl_is_any_ptr(expr)                                                \\\n  (sizeof(expr) == sizeof(void*))\n\n/* evaluates to true if expr is NULL */\n/* XXX: must not evaluate expr, so this check is not accurate */\n#define _curl_is_NULL(expr)                                                   \\\n  (__builtin_types_compatible_p(__typeof__(expr), __typeof__(NULL)))\n\n/* evaluates to true if expr is type*, const type* or NULL */\n#define _curl_is_ptr(expr, type)                                              \\\n  (_curl_is_NULL(expr) ||                                                     \\\n   __builtin_types_compatible_p(__typeof__(expr), type *) ||                  \\\n   __builtin_types_compatible_p(__typeof__(expr), const type *))\n\n/* evaluates to true if expr is one of type[], type*, NULL or const type* */\n#define _curl_is_arr(expr, type)                                              \\\n  (_curl_is_ptr((expr), type) ||                                              \\\n   __builtin_types_compatible_p(__typeof__(expr), type []))\n\n/* evaluates to true if expr is a string */\n#define _curl_is_string(expr)                                                 \\\n  (_curl_is_arr((expr), char) ||                                              \\\n   _curl_is_arr((expr), signed char) ||                                       \\\n   _curl_is_arr((expr), unsigned char))\n\n/* evaluates to true if expr is a long (no matter the signedness)\n * XXX: for now, int is also accepted (and therefore short and char, which\n * are promoted to int when passed to a variadic function) */\n#define _curl_is_long(expr)                                                   \\\n  (__builtin_types_compatible_p(__typeof__(expr), long) ||                    \\\n   __builtin_types_compatible_p(__typeof__(expr), signed long) ||             \\\n   __builtin_types_compatible_p(__typeof__(expr), unsigned long) ||           \\\n   __builtin_types_compatible_p(__typeof__(expr), int) ||                     \\\n   __builtin_types_compatible_p(__typeof__(expr), signed int) ||              \\\n   __builtin_types_compatible_p(__typeof__(expr), unsigned int) ||            \\\n   __builtin_types_compatible_p(__typeof__(expr), short) ||                   \\\n   __builtin_types_compatible_p(__typeof__(expr), signed short) ||            \\\n   __builtin_types_compatible_p(__typeof__(expr), unsigned short) ||          \\\n   __builtin_types_compatible_p(__typeof__(expr), char) ||                    \\\n   __builtin_types_compatible_p(__typeof__(expr), signed char) ||             \\\n   __builtin_types_compatible_p(__typeof__(expr), unsigned char))\n\n/* evaluates to true if expr is of type curl_off_t */\n#define _curl_is_off_t(expr)                                                  \\\n  (__builtin_types_compatible_p(__typeof__(expr), curl_off_t))\n\n/* evaluates to true if expr is abuffer suitable for CURLOPT_ERRORBUFFER */\n/* XXX: also check size of an char[] array? */\n#define _curl_is_error_buffer(expr)                                           \\\n  (_curl_is_NULL(expr) ||                                                     \\\n   __builtin_types_compatible_p(__typeof__(expr), char *) ||                  \\\n   __builtin_types_compatible_p(__typeof__(expr), char[]))\n\n/* evaluates to true if expr is of type (const) void* or (const) FILE* */\n#if 0\n#define _curl_is_cb_data(expr)                                                \\\n  (_curl_is_ptr((expr), void) ||                                              \\\n   _curl_is_ptr((expr), FILE))\n#else /* be less strict */\n#define _curl_is_cb_data(expr)                                                \\\n  _curl_is_any_ptr(expr)\n#endif\n\n/* evaluates to true if expr is of type FILE* */\n#define _curl_is_FILE(expr)                                                   \\\n  (__builtin_types_compatible_p(__typeof__(expr), FILE *))\n\n/* evaluates to true if expr can be passed as POST data (void* or char*) */\n#define _curl_is_postfields(expr)                                             \\\n  (_curl_is_ptr((expr), void) ||                                              \\\n   _curl_is_arr((expr), char))\n\n/* FIXME: the whole callback checking is messy...\n * The idea is to tolerate char vs. void and const vs. not const\n * pointers in arguments at least\n */\n/* helper: __builtin_types_compatible_p distinguishes between functions and\n * function pointers, hide it */\n#define _curl_callback_compatible(func, type)                                 \\\n  (__builtin_types_compatible_p(__typeof__(func), type) ||                    \\\n   __builtin_types_compatible_p(__typeof__(func), type*))\n\n/* evaluates to true if expr is of type curl_read_callback or \"similar\" */\n#define _curl_is_read_cb(expr)                                          \\\n  (_curl_is_NULL(expr) ||                                                     \\\n   __builtin_types_compatible_p(__typeof__(expr), __typeof__(fread)) ||       \\\n   __builtin_types_compatible_p(__typeof__(expr), curl_read_callback) ||      \\\n   _curl_callback_compatible((expr), _curl_read_callback1) ||                 \\\n   _curl_callback_compatible((expr), _curl_read_callback2) ||                 \\\n   _curl_callback_compatible((expr), _curl_read_callback3) ||                 \\\n   _curl_callback_compatible((expr), _curl_read_callback4) ||                 \\\n   _curl_callback_compatible((expr), _curl_read_callback5) ||                 \\\n   _curl_callback_compatible((expr), _curl_read_callback6))\ntypedef size_t (_curl_read_callback1)(char *, size_t, size_t, void*);\ntypedef size_t (_curl_read_callback2)(char *, size_t, size_t, const void*);\ntypedef size_t (_curl_read_callback3)(char *, size_t, size_t, FILE*);\ntypedef size_t (_curl_read_callback4)(void *, size_t, size_t, void*);\ntypedef size_t (_curl_read_callback5)(void *, size_t, size_t, const void*);\ntypedef size_t (_curl_read_callback6)(void *, size_t, size_t, FILE*);\n\n/* evaluates to true if expr is of type curl_write_callback or \"similar\" */\n#define _curl_is_write_cb(expr)                                               \\\n  (_curl_is_read_cb(expr) ||                                            \\\n   __builtin_types_compatible_p(__typeof__(expr), __typeof__(fwrite)) ||      \\\n   __builtin_types_compatible_p(__typeof__(expr), curl_write_callback) ||     \\\n   _curl_callback_compatible((expr), _curl_write_callback1) ||                \\\n   _curl_callback_compatible((expr), _curl_write_callback2) ||                \\\n   _curl_callback_compatible((expr), _curl_write_callback3) ||                \\\n   _curl_callback_compatible((expr), _curl_write_callback4) ||                \\\n   _curl_callback_compatible((expr), _curl_write_callback5) ||                \\\n   _curl_callback_compatible((expr), _curl_write_callback6))\ntypedef size_t (_curl_write_callback1)(const char *, size_t, size_t, void*);\ntypedef size_t (_curl_write_callback2)(const char *, size_t, size_t,\n                                       const void*);\ntypedef size_t (_curl_write_callback3)(const char *, size_t, size_t, FILE*);\ntypedef size_t (_curl_write_callback4)(const void *, size_t, size_t, void*);\ntypedef size_t (_curl_write_callback5)(const void *, size_t, size_t,\n                                       const void*);\ntypedef size_t (_curl_write_callback6)(const void *, size_t, size_t, FILE*);\n\n/* evaluates to true if expr is of type curl_ioctl_callback or \"similar\" */\n#define _curl_is_ioctl_cb(expr)                                         \\\n  (_curl_is_NULL(expr) ||                                                     \\\n   __builtin_types_compatible_p(__typeof__(expr), curl_ioctl_callback) ||     \\\n   _curl_callback_compatible((expr), _curl_ioctl_callback1) ||                \\\n   _curl_callback_compatible((expr), _curl_ioctl_callback2) ||                \\\n   _curl_callback_compatible((expr), _curl_ioctl_callback3) ||                \\\n   _curl_callback_compatible((expr), _curl_ioctl_callback4))\ntypedef curlioerr (_curl_ioctl_callback1)(CURL *, int, void*);\ntypedef curlioerr (_curl_ioctl_callback2)(CURL *, int, const void*);\ntypedef curlioerr (_curl_ioctl_callback3)(CURL *, curliocmd, void*);\ntypedef curlioerr (_curl_ioctl_callback4)(CURL *, curliocmd, const void*);\n\n/* evaluates to true if expr is of type curl_sockopt_callback or \"similar\" */\n#define _curl_is_sockopt_cb(expr)                                       \\\n  (_curl_is_NULL(expr) ||                                                     \\\n   __builtin_types_compatible_p(__typeof__(expr), curl_sockopt_callback) ||   \\\n   _curl_callback_compatible((expr), _curl_sockopt_callback1) ||              \\\n   _curl_callback_compatible((expr), _curl_sockopt_callback2))\ntypedef int (_curl_sockopt_callback1)(void *, curl_socket_t, curlsocktype);\ntypedef int (_curl_sockopt_callback2)(const void *, curl_socket_t,\n                                      curlsocktype);\n\n/* evaluates to true if expr is of type curl_opensocket_callback or\n   \"similar\" */\n#define _curl_is_opensocket_cb(expr)                                    \\\n  (_curl_is_NULL(expr) ||                                                     \\\n   __builtin_types_compatible_p(__typeof__(expr), curl_opensocket_callback) ||\\\n   _curl_callback_compatible((expr), _curl_opensocket_callback1) ||           \\\n   _curl_callback_compatible((expr), _curl_opensocket_callback2) ||           \\\n   _curl_callback_compatible((expr), _curl_opensocket_callback3) ||           \\\n   _curl_callback_compatible((expr), _curl_opensocket_callback4))\ntypedef curl_socket_t (_curl_opensocket_callback1)\n  (void *, curlsocktype, struct curl_sockaddr *);\ntypedef curl_socket_t (_curl_opensocket_callback2)\n  (void *, curlsocktype, const struct curl_sockaddr *);\ntypedef curl_socket_t (_curl_opensocket_callback3)\n  (const void *, curlsocktype, struct curl_sockaddr *);\ntypedef curl_socket_t (_curl_opensocket_callback4)\n  (const void *, curlsocktype, const struct curl_sockaddr *);\n\n/* evaluates to true if expr is of type curl_progress_callback or \"similar\" */\n#define _curl_is_progress_cb(expr)                                      \\\n  (_curl_is_NULL(expr) ||                                                     \\\n   __builtin_types_compatible_p(__typeof__(expr), curl_progress_callback) ||  \\\n   _curl_callback_compatible((expr), _curl_progress_callback1) ||             \\\n   _curl_callback_compatible((expr), _curl_progress_callback2))\ntypedef int (_curl_progress_callback1)(void *,\n    double, double, double, double);\ntypedef int (_curl_progress_callback2)(const void *,\n    double, double, double, double);\n\n/* evaluates to true if expr is of type curl_debug_callback or \"similar\" */\n#define _curl_is_debug_cb(expr)                                         \\\n  (_curl_is_NULL(expr) ||                                                     \\\n   __builtin_types_compatible_p(__typeof__(expr), curl_debug_callback) ||     \\\n   _curl_callback_compatible((expr), _curl_debug_callback1) ||                \\\n   _curl_callback_compatible((expr), _curl_debug_callback2) ||                \\\n   _curl_callback_compatible((expr), _curl_debug_callback3) ||                \\\n   _curl_callback_compatible((expr), _curl_debug_callback4) ||                \\\n   _curl_callback_compatible((expr), _curl_debug_callback5) ||                \\\n   _curl_callback_compatible((expr), _curl_debug_callback6) ||                \\\n   _curl_callback_compatible((expr), _curl_debug_callback7) ||                \\\n   _curl_callback_compatible((expr), _curl_debug_callback8))\ntypedef int (_curl_debug_callback1) (CURL *,\n    curl_infotype, char *, size_t, void *);\ntypedef int (_curl_debug_callback2) (CURL *,\n    curl_infotype, char *, size_t, const void *);\ntypedef int (_curl_debug_callback3) (CURL *,\n    curl_infotype, const char *, size_t, void *);\ntypedef int (_curl_debug_callback4) (CURL *,\n    curl_infotype, const char *, size_t, const void *);\ntypedef int (_curl_debug_callback5) (CURL *,\n    curl_infotype, unsigned char *, size_t, void *);\ntypedef int (_curl_debug_callback6) (CURL *,\n    curl_infotype, unsigned char *, size_t, const void *);\ntypedef int (_curl_debug_callback7) (CURL *,\n    curl_infotype, const unsigned char *, size_t, void *);\ntypedef int (_curl_debug_callback8) (CURL *,\n    curl_infotype, const unsigned char *, size_t, const void *);\n\n/* evaluates to true if expr is of type curl_ssl_ctx_callback or \"similar\" */\n/* this is getting even messier... */\n#define _curl_is_ssl_ctx_cb(expr)                                       \\\n  (_curl_is_NULL(expr) ||                                                     \\\n   __builtin_types_compatible_p(__typeof__(expr), curl_ssl_ctx_callback) ||   \\\n   _curl_callback_compatible((expr), _curl_ssl_ctx_callback1) ||              \\\n   _curl_callback_compatible((expr), _curl_ssl_ctx_callback2) ||              \\\n   _curl_callback_compatible((expr), _curl_ssl_ctx_callback3) ||              \\\n   _curl_callback_compatible((expr), _curl_ssl_ctx_callback4) ||              \\\n   _curl_callback_compatible((expr), _curl_ssl_ctx_callback5) ||              \\\n   _curl_callback_compatible((expr), _curl_ssl_ctx_callback6) ||              \\\n   _curl_callback_compatible((expr), _curl_ssl_ctx_callback7) ||              \\\n   _curl_callback_compatible((expr), _curl_ssl_ctx_callback8))\ntypedef CURLcode (_curl_ssl_ctx_callback1)(CURL *, void *, void *);\ntypedef CURLcode (_curl_ssl_ctx_callback2)(CURL *, void *, const void *);\ntypedef CURLcode (_curl_ssl_ctx_callback3)(CURL *, const void *, void *);\ntypedef CURLcode (_curl_ssl_ctx_callback4)(CURL *, const void *, const void *);\n#ifdef HEADER_SSL_H\n/* hack: if we included OpenSSL's ssl.h, we know about SSL_CTX\n * this will of course break if we're included before OpenSSL headers...\n */\ntypedef CURLcode (_curl_ssl_ctx_callback5)(CURL *, SSL_CTX, void *);\ntypedef CURLcode (_curl_ssl_ctx_callback6)(CURL *, SSL_CTX, const void *);\ntypedef CURLcode (_curl_ssl_ctx_callback7)(CURL *, const SSL_CTX, void *);\ntypedef CURLcode (_curl_ssl_ctx_callback8)(CURL *, const SSL_CTX,\n                                           const void *);\n#else\ntypedef _curl_ssl_ctx_callback1 _curl_ssl_ctx_callback5;\ntypedef _curl_ssl_ctx_callback1 _curl_ssl_ctx_callback6;\ntypedef _curl_ssl_ctx_callback1 _curl_ssl_ctx_callback7;\ntypedef _curl_ssl_ctx_callback1 _curl_ssl_ctx_callback8;\n#endif\n\n/* evaluates to true if expr is of type curl_conv_callback or \"similar\" */\n#define _curl_is_conv_cb(expr)                                          \\\n  (_curl_is_NULL(expr) ||                                                     \\\n   __builtin_types_compatible_p(__typeof__(expr), curl_conv_callback) ||      \\\n   _curl_callback_compatible((expr), _curl_conv_callback1) ||                 \\\n   _curl_callback_compatible((expr), _curl_conv_callback2) ||                 \\\n   _curl_callback_compatible((expr), _curl_conv_callback3) ||                 \\\n   _curl_callback_compatible((expr), _curl_conv_callback4))\ntypedef CURLcode (*_curl_conv_callback1)(char *, size_t length);\ntypedef CURLcode (*_curl_conv_callback2)(const char *, size_t length);\ntypedef CURLcode (*_curl_conv_callback3)(void *, size_t length);\ntypedef CURLcode (*_curl_conv_callback4)(const void *, size_t length);\n\n/* evaluates to true if expr is of type curl_seek_callback or \"similar\" */\n#define _curl_is_seek_cb(expr)                                          \\\n  (_curl_is_NULL(expr) ||                                                     \\\n   __builtin_types_compatible_p(__typeof__(expr), curl_seek_callback) ||      \\\n   _curl_callback_compatible((expr), _curl_seek_callback1) ||                 \\\n   _curl_callback_compatible((expr), _curl_seek_callback2))\ntypedef CURLcode (*_curl_seek_callback1)(void *, curl_off_t, int);\ntypedef CURLcode (*_curl_seek_callback2)(const void *, curl_off_t, int);\n\n\n#endif /* __CURL_TYPECHECK_GCC_H */\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vchi/common/endian.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n#ifndef _VCHI_ENDIAN_H_\n#define _VCHI_ENDIAN_H_\n\n#include \"interface/vcos/vcos.h\"\n\nint16_t  vchi_readbuf_int16 ( const void *ptr );\nuint16_t vchi_readbuf_uint16( const void *ptr );\nuint32_t vchi_readbuf_uint32( const void *ptr );\nvcos_fourcc_t vchi_readbuf_fourcc( const void *ptr );\n\nvoid vchi_writebuf_uint16( void *ptr, uint16_t value );\nvoid vchi_writebuf_uint32( void *ptr, uint32_t value );\nvoid vchi_writebuf_fourcc( void *ptr, vcos_fourcc_t value );\n\n#endif /* _VCHI_ENDIAN_H_ */\n\n/********************************** End of file ******************************************/\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vchi/connections/connection.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n/*\n * \\file\n *\n * \\brief Contains the protypes for the interface functions.\n*/\n\n#ifndef CONNECTION_H_\n#define CONNECTION_H_\n\n#include \"interface/vchi/vchi_cfg_internal.h\"\n#include \"interface/vchi/vchi_common.h\"\n#include \"interface/vchi/message_drivers/message.h\"\n\n/******************************************************************************\n Global defs\n *****************************************************************************/\n\n// Opaque handle for a connection / service pair\ntypedef struct opaque_vchi_connection_connected_service_handle_t *VCHI_CONNECTION_SERVICE_HANDLE_T;\n\n// opaque handle to the connection state information\ntypedef struct opaque_vchi_connection_info_t VCHI_CONNECTION_STATE_T;\n\ntypedef struct vchi_connection_t VCHI_CONNECTION_T;\n\n\n/******************************************************************************\n API\n *****************************************************************************/\n\n// Routine to init a connection with a particular low level driver\ntypedef VCHI_CONNECTION_STATE_T * (*VCHI_CONNECTION_INIT_T)( struct vchi_connection_t * connection,\n                                                             const VCHI_MESSAGE_DRIVER_T * driver );\n\n// Routine to control CRC enabling at a connection level\ntypedef int32_t (*VCHI_CONNECTION_CRC_CONTROL_T)( VCHI_CONNECTION_STATE_T *state_handle,\n                                                  VCHI_CRC_CONTROL_T control );\n\n// Routine to create a service\ntypedef int32_t (*VCHI_CONNECTION_SERVICE_CONNECT_T)( VCHI_CONNECTION_STATE_T *state_handle,\n                                                      vcos_fourcc_t service_id,\n                                                      uint32_t rx_fifo_size,\n                                                      uint32_t tx_fifo_size,\n                                                      int server,\n                                                      VCHI_CALLBACK_T callback,\n                                                      void *callback_param,\n                                                      vcos_bool_t want_crc,\n                                                      vcos_bool_t want_unaligned_bulk_rx,\n                                                      vcos_bool_t want_unaligned_bulk_tx,\n                                                      VCHI_CONNECTION_SERVICE_HANDLE_T *service_handle );\n\n// Routine to close a service\ntypedef int32_t (*VCHI_CONNECTION_SERVICE_DISCONNECT_T)( VCHI_CONNECTION_SERVICE_HANDLE_T service_handle );\n\n// Routine to queue a message\ntypedef int32_t (*VCHI_CONNECTION_SERVICE_QUEUE_MESSAGE_T)( VCHI_CONNECTION_SERVICE_HANDLE_T service_handle,\n                                                            const void *data,\n                                                            uint32_t data_size,\n                                                            VCHI_FLAGS_T flags,\n                                                            void *msg_handle );\n\n// scatter-gather (vector) message queueing\ntypedef int32_t (*VCHI_CONNECTION_SERVICE_QUEUE_MESSAGEV_T)( VCHI_CONNECTION_SERVICE_HANDLE_T service_handle,\n                                                             VCHI_MSG_VECTOR_T *vector,\n                                                             uint32_t count,\n                                                             VCHI_FLAGS_T flags,\n                                                             void *msg_handle );\n\n// Routine to dequeue a message\ntypedef int32_t (*VCHI_CONNECTION_SERVICE_DEQUEUE_MESSAGE_T)( VCHI_CONNECTION_SERVICE_HANDLE_T service_handle,\n                                                              void *data,\n                                                              uint32_t max_data_size_to_read,\n                                                              uint32_t *actual_msg_size,\n                                                              VCHI_FLAGS_T flags );\n\n// Routine to peek at a message\ntypedef int32_t (*VCHI_CONNECTION_SERVICE_PEEK_MESSAGE_T)( VCHI_CONNECTION_SERVICE_HANDLE_T service_handle,\n                                                           void **data,\n                                                           uint32_t *msg_size,\n                                                           VCHI_FLAGS_T flags );\n\n// Routine to hold a message\ntypedef int32_t (*VCHI_CONNECTION_SERVICE_HOLD_MESSAGE_T)( VCHI_CONNECTION_SERVICE_HANDLE_T service_handle,\n                                                           void **data,\n                                                           uint32_t *msg_size,\n                                                           VCHI_FLAGS_T flags,\n                                                           void **message_handle );\n\n// Routine to initialise a received message iterator\ntypedef int32_t (*VCHI_CONNECTION_SERVICE_LOOKAHEAD_MESSAGE_T)( VCHI_CONNECTION_SERVICE_HANDLE_T service_handle,\n                                                                VCHI_MSG_ITER_T *iter,\n                                                                VCHI_FLAGS_T flags );\n\n// Routine to release a held message\ntypedef int32_t (*VCHI_CONNECTION_HELD_MSG_RELEASE_T)( VCHI_CONNECTION_SERVICE_HANDLE_T service_handle,\n                                                       void *message_handle );\n\n// Routine to get info on a held message\ntypedef int32_t (*VCHI_CONNECTION_HELD_MSG_INFO_T)( VCHI_CONNECTION_SERVICE_HANDLE_T service_handle,\n                                                    void *message_handle,\n                                                    void **data,\n                                                    int32_t *msg_size,\n                                                    uint32_t *tx_timestamp,\n                                                    uint32_t *rx_timestamp );\n\n// Routine to check whether the iterator has a next message\ntypedef vcos_bool_t (*VCHI_CONNECTION_MSG_ITER_HAS_NEXT_T)( VCHI_CONNECTION_SERVICE_HANDLE_T service,\n                                                       const VCHI_MSG_ITER_T *iter );\n\n// Routine to advance the iterator\ntypedef int32_t (*VCHI_CONNECTION_MSG_ITER_NEXT_T)( VCHI_CONNECTION_SERVICE_HANDLE_T service,\n                                                    VCHI_MSG_ITER_T *iter,\n                                                    void **data,\n                                                    uint32_t *msg_size );\n\n// Routine to remove the last message returned by the iterator\ntypedef int32_t (*VCHI_CONNECTION_MSG_ITER_REMOVE_T)( VCHI_CONNECTION_SERVICE_HANDLE_T service,\n                                                      VCHI_MSG_ITER_T *iter );\n\n// Routine to hold the last message returned by the iterator\ntypedef int32_t (*VCHI_CONNECTION_MSG_ITER_HOLD_T)( VCHI_CONNECTION_SERVICE_HANDLE_T service,\n                                                    VCHI_MSG_ITER_T *iter,\n                                                    void **msg_handle );\n\n// Routine to transmit bulk data\ntypedef int32_t (*VCHI_CONNECTION_BULK_QUEUE_TRANSMIT_T)( VCHI_CONNECTION_SERVICE_HANDLE_T service_handle,\n                                                          const void *data_src,\n                                                          uint32_t data_size,\n                                                          VCHI_FLAGS_T flags,\n                                                          void *bulk_handle );\n\n// Routine to receive data\ntypedef int32_t (*VCHI_CONNECTION_BULK_QUEUE_RECEIVE_T)( VCHI_CONNECTION_SERVICE_HANDLE_T service_handle,\n                                                         void *data_dst,\n                                                         uint32_t data_size,\n                                                         VCHI_FLAGS_T flags,\n                                                         void *bulk_handle );\n\n// Routine to report if a server is available\ntypedef int32_t (*VCHI_CONNECTION_SERVER_PRESENT)( VCHI_CONNECTION_STATE_T *state, vcos_fourcc_t service_id, int32_t peer_flags );\n\n// Routine to report the number of RX slots available\ntypedef int (*VCHI_CONNECTION_RX_SLOTS_AVAILABLE)( const VCHI_CONNECTION_STATE_T *state );\n\n// Routine to report the RX slot size\ntypedef uint32_t (*VCHI_CONNECTION_RX_SLOT_SIZE)( const VCHI_CONNECTION_STATE_T *state );\n\n// Callback to indicate that the other side has added a buffer to the rx bulk DMA FIFO\ntypedef void (*VCHI_CONNECTION_RX_BULK_BUFFER_ADDED)(VCHI_CONNECTION_STATE_T *state,\n                                                     vcos_fourcc_t service,\n                                                     uint32_t length,\n                                                     MESSAGE_TX_CHANNEL_T channel,\n                                                     uint32_t channel_params,\n                                                     uint32_t data_length,\n                                                     uint32_t data_offset);\n\n// Callback to inform a service that a Xon or Xoff message has been received\ntypedef void (*VCHI_CONNECTION_FLOW_CONTROL)(VCHI_CONNECTION_STATE_T *state, vcos_fourcc_t service_id, int32_t xoff);\n\n// Callback to inform a service that a server available reply message has been received\ntypedef void (*VCHI_CONNECTION_SERVER_AVAILABLE_REPLY)(VCHI_CONNECTION_STATE_T *state, vcos_fourcc_t service_id, uint32_t flags);\n\n// Callback to indicate that bulk auxiliary messages have arrived\ntypedef void (*VCHI_CONNECTION_BULK_AUX_RECEIVED)(VCHI_CONNECTION_STATE_T *state);\n\n// Callback to indicate that bulk auxiliary messages have arrived\ntypedef void (*VCHI_CONNECTION_BULK_AUX_TRANSMITTED)(VCHI_CONNECTION_STATE_T *state, void *handle);\n\n// Callback with all the connection info you require\ntypedef void (*VCHI_CONNECTION_INFO)(VCHI_CONNECTION_STATE_T *state, uint32_t protocol_version, uint32_t slot_size, uint32_t num_slots, uint32_t min_bulk_size);\n\n// Callback to inform of a disconnect\ntypedef void (*VCHI_CONNECTION_DISCONNECT)(VCHI_CONNECTION_STATE_T *state, uint32_t flags);\n\n// Callback to inform of a power control request\ntypedef void (*VCHI_CONNECTION_POWER_CONTROL)(VCHI_CONNECTION_STATE_T *state, MESSAGE_TX_CHANNEL_T channel, vcos_bool_t enable);\n\n// allocate memory suitably aligned for this connection\ntypedef void * (*VCHI_BUFFER_ALLOCATE)(VCHI_CONNECTION_SERVICE_HANDLE_T service_handle, uint32_t * length);\n\n// free memory allocated by buffer_allocate\ntypedef void   (*VCHI_BUFFER_FREE)(VCHI_CONNECTION_SERVICE_HANDLE_T service_handle, void * address);\n\n\n/******************************************************************************\n System driver struct\n *****************************************************************************/\n\nstruct opaque_vchi_connection_api_t\n{\n   // Routine to init the connection\n   VCHI_CONNECTION_INIT_T                      init;\n\n   // Connection-level CRC control\n   VCHI_CONNECTION_CRC_CONTROL_T               crc_control;\n\n   // Routine to connect to or create service\n   VCHI_CONNECTION_SERVICE_CONNECT_T           service_connect;\n\n   // Routine to disconnect from a service\n   VCHI_CONNECTION_SERVICE_DISCONNECT_T        service_disconnect;\n\n   // Routine to queue a message\n   VCHI_CONNECTION_SERVICE_QUEUE_MESSAGE_T     service_queue_msg;\n\n   // scatter-gather (vector) message queue\n   VCHI_CONNECTION_SERVICE_QUEUE_MESSAGEV_T    service_queue_msgv;\n\n   // Routine to dequeue a message\n   VCHI_CONNECTION_SERVICE_DEQUEUE_MESSAGE_T   service_dequeue_msg;\n\n   // Routine to peek at a message\n   VCHI_CONNECTION_SERVICE_PEEK_MESSAGE_T      service_peek_msg;\n\n   // Routine to hold a message\n   VCHI_CONNECTION_SERVICE_HOLD_MESSAGE_T      service_hold_msg;\n\n   // Routine to initialise a received message iterator\n   VCHI_CONNECTION_SERVICE_LOOKAHEAD_MESSAGE_T service_look_ahead_msg;\n\n   // Routine to release a message\n   VCHI_CONNECTION_HELD_MSG_RELEASE_T          held_msg_release;\n\n   // Routine to get information on a held message\n   VCHI_CONNECTION_HELD_MSG_INFO_T             held_msg_info;\n\n   // Routine to check for next message on iterator\n   VCHI_CONNECTION_MSG_ITER_HAS_NEXT_T         msg_iter_has_next;\n\n   // Routine to get next message on iterator\n   VCHI_CONNECTION_MSG_ITER_NEXT_T             msg_iter_next;\n\n   // Routine to remove the last message returned by iterator\n   VCHI_CONNECTION_MSG_ITER_REMOVE_T           msg_iter_remove;\n\n   // Routine to hold the last message returned by iterator\n   VCHI_CONNECTION_MSG_ITER_HOLD_T             msg_iter_hold;\n\n   // Routine to transmit bulk data\n   VCHI_CONNECTION_BULK_QUEUE_TRANSMIT_T       bulk_queue_transmit;\n\n   // Routine to receive data\n   VCHI_CONNECTION_BULK_QUEUE_RECEIVE_T        bulk_queue_receive;\n\n   // Routine to report the available servers\n   VCHI_CONNECTION_SERVER_PRESENT              server_present;\n\n   // Routine to report the number of RX slots available\n   VCHI_CONNECTION_RX_SLOTS_AVAILABLE          connection_rx_slots_available;\n\n   // Routine to report the RX slot size\n   VCHI_CONNECTION_RX_SLOT_SIZE                connection_rx_slot_size;\n\n   // Callback to indicate that the other side has added a buffer to the rx bulk DMA FIFO\n   VCHI_CONNECTION_RX_BULK_BUFFER_ADDED        rx_bulk_buffer_added;\n\n   // Callback to inform a service that a Xon or Xoff message has been received\n   VCHI_CONNECTION_FLOW_CONTROL                flow_control;\n\n   // Callback to inform a service that a server available reply message has been received\n   VCHI_CONNECTION_SERVER_AVAILABLE_REPLY      server_available_reply;\n\n   // Callback to indicate that bulk auxiliary messages have arrived\n   VCHI_CONNECTION_BULK_AUX_RECEIVED           bulk_aux_received;\n\n   // Callback to indicate that a bulk auxiliary message has been transmitted\n   VCHI_CONNECTION_BULK_AUX_TRANSMITTED        bulk_aux_transmitted;\n\n   // Callback to provide information about the connection\n   VCHI_CONNECTION_INFO                        connection_info;\n\n   // Callback to notify that peer has requested disconnect\n   VCHI_CONNECTION_DISCONNECT                  disconnect;\n\n   // Callback to notify that peer has requested power change\n   VCHI_CONNECTION_POWER_CONTROL               power_control;\n\n   // allocate memory suitably aligned for this connection\n   VCHI_BUFFER_ALLOCATE                        buffer_allocate;\n\n   // free memory allocated by buffer_allocate\n   VCHI_BUFFER_FREE                            buffer_free;\n\n};\n\nstruct vchi_connection_t {\n   const VCHI_CONNECTION_API_T *api;\n   VCHI_CONNECTION_STATE_T     *state;\n#ifdef VCHI_COARSE_LOCKING\n   VCOS_SEMAPHORE_T             sem;\n#endif\n};\n\n\n#endif /* CONNECTION_H_ */\n\n/****************************** End of file **********************************/\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vchi/message_drivers/message.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n// MPHI videocore message driver\n\n#ifndef _VCHI_MESSAGE_H_\n#define _VCHI_MESSAGE_H_\n\n#include \"interface/vchi/vchi_cfg_internal.h\"\n#include \"interface/vcos/vcos.h\"\n#include \"interface/vchi/vchi_common.h\"\n\n\ntypedef enum message_event_type {\n   MESSAGE_EVENT_NONE,\n   MESSAGE_EVENT_NOP,\n   MESSAGE_EVENT_MESSAGE,\n   MESSAGE_EVENT_SLOT_COMPLETE,\n   MESSAGE_EVENT_RX_BULK_PAUSED,\n   MESSAGE_EVENT_RX_BULK_COMPLETE,\n   MESSAGE_EVENT_TX_COMPLETE,\n   MESSAGE_EVENT_MSG_DISCARDED\n} MESSAGE_EVENT_TYPE_T;\n\ntypedef enum vchi_msg_flags\n{\n   VCHI_MSG_FLAGS_NONE                  = 0x0,\n   VCHI_MSG_FLAGS_TERMINATE_DMA         = 0x1\n} VCHI_MSG_FLAGS_T;\n\ntypedef enum message_tx_channel\n{\n   MESSAGE_TX_CHANNEL_MESSAGE           = 0,\n   MESSAGE_TX_CHANNEL_BULK              = 1 // drivers may provide multiple bulk channels, from 1 upwards\n} MESSAGE_TX_CHANNEL_T;\n\n// Macros used for cycling through bulk channels\n#define MESSAGE_TX_CHANNEL_BULK_PREV(c) (MESSAGE_TX_CHANNEL_BULK+((c)-MESSAGE_TX_CHANNEL_BULK+VCHI_MAX_BULK_TX_CHANNELS_PER_CONNECTION-1)%VCHI_MAX_BULK_TX_CHANNELS_PER_CONNECTION)\n#define MESSAGE_TX_CHANNEL_BULK_NEXT(c) (MESSAGE_TX_CHANNEL_BULK+((c)-MESSAGE_TX_CHANNEL_BULK+1)%VCHI_MAX_BULK_TX_CHANNELS_PER_CONNECTION)\n\ntypedef enum message_rx_channel\n{\n   MESSAGE_RX_CHANNEL_MESSAGE           = 0,\n   MESSAGE_RX_CHANNEL_BULK              = 1 // drivers may provide multiple bulk channels, from 1 upwards\n} MESSAGE_RX_CHANNEL_T;\n\n// Message receive slot information\ntypedef struct rx_msg_slot_info {\n\n   struct rx_msg_slot_info *next;\n   //struct slot_info *prev;\n#if !defined VCHI_COARSE_LOCKING\n   VCOS_SEMAPHORE_T   sem;\n#endif\n\n   uint8_t           *addr;               // base address of slot\n   uint32_t           len;                // length of slot in bytes\n\n   uint32_t           write_ptr;          // hardware causes this to advance\n   uint32_t           read_ptr;           // this module does the reading\n   int                active;             // is this slot in the hardware dma fifo?\n   uint32_t           msgs_parsed;        // count how many messages are in this slot\n   uint32_t           msgs_released;      // how many messages have been released\n   void              *state;              // connection state information\n   uint8_t            ref_count[VCHI_MAX_SERVICES_PER_CONNECTION];          // reference count for slots held by services\n} RX_MSG_SLOTINFO_T;\n\n// The message driver no longer needs to know about the fields of RX_BULK_SLOTINFO_T - sort this out.\n// In particular, it mustn't use addr and len - they're the client buffer, but the message\n// driver will be tasked with sending the aligned core section.\ntypedef struct rx_bulk_slotinfo_t {\n   struct rx_bulk_slotinfo_t *next;\n\n   VCOS_SEMAPHORE_T *blocking;\n\n   // needed by DMA\n   void        *addr;\n   uint32_t     len;\n\n   // needed for the callback\n   void        *service;\n   void        *handle;\n   VCHI_FLAGS_T flags;\n} RX_BULK_SLOTINFO_T;\n\n\n/* ----------------------------------------------------------------------\n * each connection driver will have a pool of the following struct.\n *\n * the pool will be managed by vchi_qman_*\n * this means there will be multiple queues (single linked lists)\n * a given struct message_info will be on exactly one of these queues\n * at any one time\n * -------------------------------------------------------------------- */\ntypedef struct rx_message_info {\n\n   struct message_info *next;\n   //struct message_info *prev;\n\n   uint8_t    *addr;\n   uint32_t   len;\n   RX_MSG_SLOTINFO_T *slot; // points to whichever slot contains this message\n   uint32_t   tx_timestamp;\n   uint32_t   rx_timestamp;\n\n} RX_MESSAGE_INFO_T;\n\ntypedef struct {\n   MESSAGE_EVENT_TYPE_T type;\n\n   struct {\n      // for messages\n      void    *addr;           // address of message\n      uint16_t slot_delta;     // whether this message indicated slot delta\n      uint32_t len;            // length of message\n      RX_MSG_SLOTINFO_T *slot; // slot this message is in\n      vcos_fourcc_t service;   // service id this message is destined for\n      uint32_t tx_timestamp;   // timestamp from the header\n      uint32_t rx_timestamp;   // timestamp when we parsed it\n   } message;\n\n   // FIXME: cleanup slot reporting...\n   RX_MSG_SLOTINFO_T *rx_msg;\n   RX_BULK_SLOTINFO_T *rx_bulk;\n   void *tx_handle;\n   MESSAGE_TX_CHANNEL_T tx_channel;\n\n} MESSAGE_EVENT_T;\n\n\n// callbacks\ntypedef void VCHI_MESSAGE_DRIVER_EVENT_CALLBACK_T( void *state );\n\ntypedef struct {\n   VCHI_MESSAGE_DRIVER_EVENT_CALLBACK_T *event_callback;\n} VCHI_MESSAGE_DRIVER_OPEN_T;\n\n\n// handle to this instance of message driver (as returned by ->open)\ntypedef struct opaque_mhandle_t *VCHI_MDRIVER_HANDLE_T;\n\nstruct opaque_vchi_message_driver_t {\n   VCHI_MDRIVER_HANDLE_T *(*open)( VCHI_MESSAGE_DRIVER_OPEN_T *params, void *state );\n   int32_t (*suspending)( VCHI_MDRIVER_HANDLE_T *handle );\n   int32_t (*resumed)( VCHI_MDRIVER_HANDLE_T *handle );\n   int32_t (*power_control)( VCHI_MDRIVER_HANDLE_T *handle, MESSAGE_TX_CHANNEL_T, vcos_bool_t enable );\n   int32_t (*add_msg_rx_slot)( VCHI_MDRIVER_HANDLE_T *handle, RX_MSG_SLOTINFO_T *slot );      // rx message\n   int32_t (*add_bulk_rx)( VCHI_MDRIVER_HANDLE_T *handle, void *data, uint32_t len, RX_BULK_SLOTINFO_T *slot );  // rx data (bulk)\n   int32_t (*send)( VCHI_MDRIVER_HANDLE_T *handle, MESSAGE_TX_CHANNEL_T channel, const void *data, uint32_t len, VCHI_MSG_FLAGS_T flags, void *send_handle );      // tx (message & bulk)\n   void    (*next_event)( VCHI_MDRIVER_HANDLE_T *handle, MESSAGE_EVENT_T *event );     // get the next event from message_driver\n   int32_t (*enable)( VCHI_MDRIVER_HANDLE_T *handle );\n   int32_t (*form_message)( VCHI_MDRIVER_HANDLE_T *handle, vcos_fourcc_t service_id, VCHI_MSG_VECTOR_T *vector, uint32_t count, void\n                            *address, uint32_t length_avail, uint32_t max_total_length, vcos_bool_t pad_to_fill, vcos_bool_t allow_partial );\n\n   int32_t (*update_message)( VCHI_MDRIVER_HANDLE_T *handle, void *dest, int16_t *slot_count );\n   int32_t (*buffer_aligned)( VCHI_MDRIVER_HANDLE_T *handle, int tx, int uncached, const void *address, const uint32_t length );\n   void *  (*allocate_buffer)( VCHI_MDRIVER_HANDLE_T *handle, uint32_t *length );\n   void    (*free_buffer)( VCHI_MDRIVER_HANDLE_T *handle, void *address );\n   int     (*rx_slot_size)( VCHI_MDRIVER_HANDLE_T *handle, int msg_size );\n   int     (*tx_slot_size)( VCHI_MDRIVER_HANDLE_T *handle, int msg_size );\n\n   vcos_bool_t  (*tx_supports_terminate)( const VCHI_MDRIVER_HANDLE_T *handle, MESSAGE_TX_CHANNEL_T channel );\n   uint32_t (*tx_bulk_chunk_size)( const VCHI_MDRIVER_HANDLE_T *handle, MESSAGE_TX_CHANNEL_T channel );\n   int     (*tx_alignment)( const VCHI_MDRIVER_HANDLE_T *handle, MESSAGE_TX_CHANNEL_T channel );\n   int     (*rx_alignment)( const VCHI_MDRIVER_HANDLE_T *handle, MESSAGE_RX_CHANNEL_T channel );\n   void    (*form_bulk_aux)( VCHI_MDRIVER_HANDLE_T *handle, MESSAGE_TX_CHANNEL_T channel, const void *data, uint32_t len, uint32_t chunk_size, const void **aux_data, int32_t *aux_len );\n   void    (*debug)( VCHI_MDRIVER_HANDLE_T *handle );\n};\n\n\n#endif // _VCHI_MESSAGE_H_\n\n/****************************** End of file ***********************************/\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vchi/vchi.h",
    "content": "/*\nCopyright (c) 2012-2014, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n// Contains the protypes for the vchi functions.\n\n#ifndef VCHI_H_\n#define VCHI_H_\n\n#include \"interface/vcos/vcos.h\"\n#include \"interface/vchi/vchi_cfg.h\"\n#include \"interface/vchi/vchi_common.h\"\n#include \"interface/vchi/connections/connection.h\"\n#include \"vchi_mh.h\"\n\n\n/******************************************************************************\n Global defs\n *****************************************************************************/\n\n#define VCHI_SERVICE_HANDLE_INVALID 0\n\n#define VCHI_BULK_ROUND_UP(x)     ((((unsigned long)(x))+VCHI_BULK_ALIGN-1) & ~(VCHI_BULK_ALIGN-1))\n#define VCHI_BULK_ROUND_DOWN(x)   (((unsigned long)(x)) & ~(VCHI_BULK_ALIGN-1))\n#define VCHI_BULK_ALIGN_NBYTES(x) (VCHI_BULK_ALIGNED(x) ? 0 : (VCHI_BULK_ALIGN - ((unsigned long)(x) & (VCHI_BULK_ALIGN-1))))\n\n#ifdef USE_VCHIQ_ARM\n#define VCHI_BULK_ALIGNED(x)      1\n#else\n#define VCHI_BULK_ALIGNED(x)      (((unsigned long)(x) & (VCHI_BULK_ALIGN-1)) == 0)\n#endif\n\ntypedef struct \n{\n   uint32_t version;\n   uint32_t version_min;\n} VCHI_VERSION_T;\n#define VCHI_VERSION(v_) { v_, v_ }\n#define VCHI_VERSION_EX(v_,m_) { v_, m_ }\n\ntypedef enum\n{\n   VCHI_VEC_POINTER,\n   VCHI_VEC_HANDLE,\n   VCHI_VEC_LIST\n} VCHI_MSG_VECTOR_TYPE_T;\n\ntypedef struct vchi_msg_vector_ex {\n\n   VCHI_MSG_VECTOR_TYPE_T type;\n   union\n   {\n      // a memory handle\n      struct\n      {\n         VCHI_MEM_HANDLE_T handle;\n         uint32_t offset;\n         int32_t vec_len;\n      } handle;\n\n      // an ordinary data pointer\n      struct\n      {\n         const void *vec_base;\n         int32_t vec_len;\n      } ptr;\n\n      // a nested vector list\n      struct\n      {\n         struct vchi_msg_vector_ex *vec;\n         uint32_t vec_len;\n      } list;\n   } u;\n} VCHI_MSG_VECTOR_EX_T;\n\n\n// Construct an entry in a msg vector for a pointer (p) of length (l)\n#define VCHI_VEC_POINTER(p,l)  VCHI_VEC_POINTER, { { (VCHI_MEM_HANDLE_T)(p), (l) } }\n\n// Construct an entry in a msg vector for a message handle (h), starting at offset (o) of length (l)\n#define VCHI_VEC_HANDLE(h,o,l) VCHI_VEC_HANDLE,  { { (h), (o), (l) } }\n\n// Macros to manipulate fourcc_t values\n#define MAKE_FOURCC(x) ((fourcc_t)( (x[0] << 24) | (x[1] << 16) | (x[2] << 8) | x[3] ))\n#define FOURCC_TO_CHAR(x) (x >> 24) & 0xFF,(x >> 16) & 0xFF,(x >> 8) & 0xFF, x & 0xFF\n\n\n// Opaque service information\nstruct opaque_vchi_service_t;\n\n// Descriptor for a held message. Allocated by client, initialised by vchi_msg_hold,\n// vchi_msg_iter_hold or vchi_msg_iter_hold_next. Fields are for internal VCHI use only.\ntypedef struct\n{\n   struct opaque_vchi_service_t *service;\n   void *message;\n} VCHI_HELD_MSG_T;\n\n\n\n// structure used to provide the information needed to open a server or a client\ntypedef struct {\n   VCHI_VERSION_T version;\n   vcos_fourcc_t service_id;\n   VCHI_CONNECTION_T *connection;\n   uint32_t rx_fifo_size;\n   uint32_t tx_fifo_size;\n   VCHI_CALLBACK_T callback;\n   void *callback_param;\n   vcos_bool_t want_unaligned_bulk_rx;    // client intends to receive bulk transfers of odd lengths or into unaligned buffers\n   vcos_bool_t want_unaligned_bulk_tx;    // client intends to transmit bulk transfers of odd lengths or out of unaligned buffers\n   vcos_bool_t want_crc;                  // client wants to check CRCs on (bulk) transfers. Only needs to be set at 1 end - will do both directions.\n} SERVICE_CREATION_T;\n\n// Opaque handle for a VCHI instance\ntypedef struct opaque_vchi_instance_handle_t *VCHI_INSTANCE_T;\n\n// Opaque handle for a server or client\ntypedef unsigned int VCHI_SERVICE_HANDLE_T;\n\n// Service registration & startup\ntypedef void (*VCHI_SERVICE_INIT)(VCHI_INSTANCE_T initialise_instance, VCHI_CONNECTION_T **connections, uint32_t num_connections);\n\ntypedef struct service_info_tag {\n   const char * const vll_filename; /* VLL to load to start this service. This is an empty string if VLL is \"static\" */\n   VCHI_SERVICE_INIT init;          /* Service initialisation function */\n   void *vll_handle;                /* VLL handle; NULL when unloaded or a \"static VLL\" in build */\n} SERVICE_INFO_T;\n\n/******************************************************************************\n Global funcs - implementation is specific to which side you are on (local / remote)\n *****************************************************************************/\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\nextern /*@observer@*/ VCHI_CONNECTION_T * vchi_create_connection( const VCHI_CONNECTION_API_T * function_table,\n                                                   const VCHI_MESSAGE_DRIVER_T * low_level);\n\n\n// Routine used to initialise the vchi on both local + remote connections\nextern int32_t vchi_initialise( VCHI_INSTANCE_T *instance_handle );\n\nextern int32_t vchi_connect( VCHI_CONNECTION_T **connections,\n                             const uint32_t num_connections,\n                             VCHI_INSTANCE_T instance_handle );\n\n//When this is called, ensure that all services have no data pending.\n//Bulk transfers can remain 'queued'\nextern int32_t vchi_disconnect( VCHI_INSTANCE_T instance_handle );\n\n// Global control over bulk CRC checking\nextern int32_t vchi_crc_control( VCHI_CONNECTION_T *connection,\n                                 VCHI_CRC_CONTROL_T control );\n\n// helper functions\nextern void * vchi_allocate_buffer(VCHI_SERVICE_HANDLE_T handle, uint32_t *length);\nextern void vchi_free_buffer(VCHI_SERVICE_HANDLE_T handle, void *address);\nextern uint32_t vchi_current_time(VCHI_INSTANCE_T instance_handle);\n\n\n/******************************************************************************\n Global service API\n *****************************************************************************/\n// Routine to create a named service\nextern int32_t vchi_service_create( VCHI_INSTANCE_T instance_handle,\n                                    SERVICE_CREATION_T *setup,\n                                    VCHI_SERVICE_HANDLE_T *handle );\n\n// Routine to destroy a service\nextern int32_t vchi_service_destroy( const VCHI_SERVICE_HANDLE_T handle );\n\n// Routine to open a named service\nextern int32_t vchi_service_open( VCHI_INSTANCE_T instance_handle,\n                                  SERVICE_CREATION_T *setup,\n                                  VCHI_SERVICE_HANDLE_T *handle);\n\nextern int32_t vchi_get_peer_version( const VCHI_SERVICE_HANDLE_T handle,\n                                      short *peer_version );\n\n// Routine to close a named service\nextern int32_t vchi_service_close( const VCHI_SERVICE_HANDLE_T handle );\n\n// Routine to increment ref count on a named service\nextern int32_t vchi_service_use( const VCHI_SERVICE_HANDLE_T handle );\n\n// Routine to decrement ref count on a named service\nextern int32_t vchi_service_release( const VCHI_SERVICE_HANDLE_T handle );\n\n// Routine to set a control option for a named service\nextern int32_t vchi_service_set_option( const VCHI_SERVICE_HANDLE_T handle,\n                                        VCHI_SERVICE_OPTION_T option,\n                                        int value);\n\n// Routine to send a message across a service\nextern int32_t vchi_msg_queue( VCHI_SERVICE_HANDLE_T handle,\n                               const void *data,\n                               uint32_t data_size,\n                               VCHI_FLAGS_T flags,\n                               void *msg_handle );\n\n// scatter-gather (vector) and send message\nint32_t vchi_msg_queuev_ex( VCHI_SERVICE_HANDLE_T handle,\n                            VCHI_MSG_VECTOR_EX_T *vector,\n                            uint32_t count,\n                            VCHI_FLAGS_T flags,\n                            void *msg_handle );\n\n// legacy scatter-gather (vector) and send message, only handles pointers\nint32_t vchi_msg_queuev( VCHI_SERVICE_HANDLE_T handle,\n                         VCHI_MSG_VECTOR_T *vector,\n                         uint32_t count,\n                         VCHI_FLAGS_T flags,\n                         void *msg_handle );\n\n// Routine to receive a msg from a service\n// Dequeue is equivalent to hold, copy into client buffer, release\nextern int32_t vchi_msg_dequeue( VCHI_SERVICE_HANDLE_T handle,\n                                 void *data,\n                                 uint32_t max_data_size_to_read,\n                                 uint32_t *actual_msg_size,\n                                 VCHI_FLAGS_T flags );\n\n// Routine to look at a message in place.\n// The message is not dequeued, so a subsequent call to peek or dequeue\n// will return the same message.\nextern int32_t vchi_msg_peek( VCHI_SERVICE_HANDLE_T handle,\n                              void **data,\n                              uint32_t *msg_size,\n                              VCHI_FLAGS_T flags );\n\n// Routine to remove a message after it has been read in place with peek\n// The first message on the queue is dequeued.\nextern int32_t vchi_msg_remove( VCHI_SERVICE_HANDLE_T handle );\n\n// Routine to look at a message in place.\n// The message is dequeued, so the caller is left holding it; the descriptor is\n// filled in and must be released when the user has finished with the message.\nextern int32_t vchi_msg_hold( VCHI_SERVICE_HANDLE_T handle,\n                              void **data,        // } may be NULL, as info can be\n                              uint32_t *msg_size, // } obtained from HELD_MSG_T\n                              VCHI_FLAGS_T flags,\n                              VCHI_HELD_MSG_T *message_descriptor );\n\n// Initialise an iterator to look through messages in place\nextern int32_t vchi_msg_look_ahead( VCHI_SERVICE_HANDLE_T handle,\n                                    VCHI_MSG_ITER_T *iter,\n                                    VCHI_FLAGS_T flags );\n\n/******************************************************************************\n Global service support API - operations on held messages and message iterators\n *****************************************************************************/\n\n// Routine to get the address of a held message\nextern void *vchi_held_msg_ptr( const VCHI_HELD_MSG_T *message );\n\n// Routine to get the size of a held message\nextern int32_t vchi_held_msg_size( const VCHI_HELD_MSG_T *message );\n\n// Routine to get the transmit timestamp as written into the header by the peer\nextern uint32_t vchi_held_msg_tx_timestamp( const VCHI_HELD_MSG_T *message );\n\n// Routine to get the reception timestamp, written as we parsed the header\nextern uint32_t vchi_held_msg_rx_timestamp( const VCHI_HELD_MSG_T *message );\n\n// Routine to release a held message after it has been processed\nextern int32_t vchi_held_msg_release( VCHI_HELD_MSG_T *message );\n\n// Indicates whether the iterator has a next message.\nextern vcos_bool_t vchi_msg_iter_has_next( const VCHI_MSG_ITER_T *iter );\n\n// Return the pointer and length for the next message and advance the iterator.\nextern int32_t vchi_msg_iter_next( VCHI_MSG_ITER_T *iter,\n                                   void **data,\n                                   uint32_t *msg_size );\n\n// Remove the last message returned by vchi_msg_iter_next.\n// Can only be called once after each call to vchi_msg_iter_next.\nextern int32_t vchi_msg_iter_remove( VCHI_MSG_ITER_T *iter );\n\n// Hold the last message returned by vchi_msg_iter_next.\n// Can only be called once after each call to vchi_msg_iter_next.\nextern int32_t vchi_msg_iter_hold( VCHI_MSG_ITER_T *iter,\n                                   VCHI_HELD_MSG_T *message );\n\n// Return information for the next message, and hold it, advancing the iterator.\nextern int32_t vchi_msg_iter_hold_next( VCHI_MSG_ITER_T *iter,\n                                        void **data,        // } may be NULL\n                                        uint32_t *msg_size, // }\n                                        VCHI_HELD_MSG_T *message );\n\n\n/******************************************************************************\n Global bulk API\n *****************************************************************************/\n\n// Routine to prepare interface for a transfer from the other side\nextern int32_t vchi_bulk_queue_receive( VCHI_SERVICE_HANDLE_T handle,\n                                        void *data_dst,\n                                        uint32_t data_size,\n                                        VCHI_FLAGS_T flags,\n                                        void *transfer_handle );\n\n\n// Prepare interface for a transfer from the other side into relocatable memory.\nint32_t vchi_bulk_queue_receive_reloc( const VCHI_SERVICE_HANDLE_T handle,\n                                       VCHI_MEM_HANDLE_T h_dst,\n                                       uint32_t offset,\n                                       uint32_t data_size,\n                                       const VCHI_FLAGS_T flags,\n                                       void * const bulk_handle );\n\n// Prepare interface for a transfer from the other side into relocatable memory.\nint32_t vchi_bulk_queue_receive_reloc_func( const VCHI_SERVICE_HANDLE_T handle,\n                                       VCHI_MEM_HANDLE_T h_dst,\n                                       uint32_t offset,\n                                       uint32_t data_size,\n                                       const VCHI_FLAGS_T flags,\n                                       void * const bulk_handle,\n                                       int (*copy_pagelist)() );\n\n// Routine to queue up data ready for transfer to the other (once they have signalled they are ready)\nextern int32_t vchi_bulk_queue_transmit( VCHI_SERVICE_HANDLE_T handle,\n                                         const void *data_src,\n                                         uint32_t data_size,\n                                         VCHI_FLAGS_T flags,\n                                         void *transfer_handle );\n\n\n/******************************************************************************\n Configuration plumbing\n *****************************************************************************/\n\n// function prototypes for the different mid layers (the state info gives the different physical connections)\nextern const VCHI_CONNECTION_API_T *single_get_func_table( void );\n//extern const VCHI_CONNECTION_API_T *local_server_get_func_table( void );\n//extern const VCHI_CONNECTION_API_T *local_client_get_func_table( void );\n\n// declare all message drivers here\nconst VCHI_MESSAGE_DRIVER_T *vchi_mphi_message_driver_func_table( void );\n\n#ifdef __cplusplus\n}\n#endif\n\nextern int32_t vchi_bulk_queue_transmit_reloc( VCHI_SERVICE_HANDLE_T handle,\n                                               VCHI_MEM_HANDLE_T h_src,\n                                               uint32_t offset,\n                                               uint32_t data_size,\n                                               VCHI_FLAGS_T flags,\n                                               void *transfer_handle );\n#endif /* VCHI_H_ */\n\n/****************************** End of file **********************************/\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vchi/vchi_cfg.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n// Contains the #defines for the number of servers / clients etc, these can be\n// over-ridden from the platform makefile if needed\n\n\n#ifndef VCHI_CFG_H_\n#define VCHI_CFG_H_\n\n/****************************************************************************************\n * Defines in this first section are part of the VCHI API and may be examined by VCHI\n * services.\n ***************************************************************************************/\n\n/* Required alignment of base addresses for bulk transfer, if unaligned transfers are not enabled */\n/* Really determined by the message driver, and should be available from a run-time call. */\n#ifndef VCHI_BULK_ALIGN\n#   if __VCCOREVER__ >= 0x04000000\n#       define VCHI_BULK_ALIGN 32 // Allows for the need to do cache cleans\n#   else\n#       define VCHI_BULK_ALIGN 16\n#   endif\n#endif\n\n/* Required length multiple for bulk transfers, if unaligned transfers are not enabled */\n/* May be less than or greater than VCHI_BULK_ALIGN */\n/* Really determined by the message driver, and should be available from a run-time call. */\n#ifndef VCHI_BULK_GRANULARITY\n#   if __VCCOREVER__ >= 0x04000000\n#       define VCHI_BULK_GRANULARITY 32 // Allows for the need to do cache cleans\n#   else\n#       define VCHI_BULK_GRANULARITY 16\n#   endif\n#endif\n\n/* The largest possible message to be queued with vchi_msg_queue. */\n#ifndef VCHI_MAX_MSG_SIZE\n#   if defined VCHI_LOCAL_HOST_PORT\n#       define VCHI_MAX_MSG_SIZE     16384         // makes file transfers fast, but should they be using bulk?\n#   else\n#       define VCHI_MAX_MSG_SIZE      4096 // NOTE: THIS MUST BE LARGER THAN OR EQUAL TO THE SIZE OF THE KHRONOS MERGE BUFFER!!\n#   endif\n#endif\n\n/******************************************************************************************\n * Defines below are system configuration options, and should not be used by VCHI services.\n *****************************************************************************************/\n\n/* How many connections can we support? A localhost implementation uses 2 connections,\n * 1 for host-app, 1 for VMCS, and these are hooked together by a loopback MPHI VCFW\n * driver. */\n#ifndef VCHI_MAX_NUM_CONNECTIONS\n#   define VCHI_MAX_NUM_CONNECTIONS 3\n#endif\n\n/* How many services can we open per connection? Extending this doesn't cost processing time, just a small\n * amount of static memory. */\n#ifndef VCHI_MAX_SERVICES_PER_CONNECTION\n#  define VCHI_MAX_SERVICES_PER_CONNECTION 36\n#endif\n\n/* Adjust if using a message driver that supports more logical TX channels */\n#ifndef VCHI_MAX_BULK_TX_CHANNELS_PER_CONNECTION\n#   define VCHI_MAX_BULK_TX_CHANNELS_PER_CONNECTION 9 // 1 MPHI + 8 CCP2 logical channels\n#endif\n\n/* Adjust if using a message driver that supports more logical RX channels */\n#ifndef VCHI_MAX_BULK_RX_CHANNELS_PER_CONNECTION\n#   define VCHI_MAX_BULK_RX_CHANNELS_PER_CONNECTION 1 // 1 MPHI\n#endif\n\n/* How many receive slots do we use. This times VCHI_MAX_MSG_SIZE gives the effective\n * receive queue space, less message headers. */\n#ifndef VCHI_NUM_READ_SLOTS\n#  if defined(VCHI_LOCAL_HOST_PORT)\n#     define VCHI_NUM_READ_SLOTS 4\n#  else\n#     define VCHI_NUM_READ_SLOTS 48\n#  endif\n#endif\n\n/* Do we utilise overrun facility for receive message slots? Can aid peer transmit\n * performance. Only define on VideoCore end, talking to host.\n */\n//#define VCHI_MSG_RX_OVERRUN\n\n/* How many transmit slots do we use. Generally don't need many, as the hardware driver\n * underneath VCHI will usually have its own buffering. */\n#ifndef VCHI_NUM_WRITE_SLOTS\n#  define VCHI_NUM_WRITE_SLOTS 4\n#endif\n\n/* If a service has held or queued received messages in VCHI_XOFF_THRESHOLD or more slots,\n * then it's taking up too much buffer space, and the peer service will be told to stop\n * transmitting with an XOFF message. For this to be effective, the VCHI_NUM_READ_SLOTS\n * needs to be considerably bigger than VCHI_NUM_WRITE_SLOTS, or the transmit latency\n * is too high. */\n#ifndef VCHI_XOFF_THRESHOLD\n#  define VCHI_XOFF_THRESHOLD (VCHI_NUM_READ_SLOTS / 2)\n#endif\n\n/* After we've sent an XOFF, the peer will be told to resume transmission once the local\n * service has dequeued/released enough messages that it's now occupying\n * VCHI_XON_THRESHOLD slots or fewer. */\n#ifndef VCHI_XON_THRESHOLD\n#  define VCHI_XON_THRESHOLD (VCHI_NUM_READ_SLOTS / 4)\n#endif\n\n/* A size below which a bulk transfer omits the handshake completely and always goes\n * via the message channel, if bulk auxiliary is being sent on that service. (The user\n * can guarantee this by enabling unaligned transmits).\n * Not API. */\n#ifndef VCHI_MIN_BULK_SIZE\n#  define VCHI_MIN_BULK_SIZE    ( VCHI_MAX_MSG_SIZE / 2 < 4096 ? VCHI_MAX_MSG_SIZE / 2 : 4096 )\n#endif\n\n/* Maximum size of bulk transmission chunks, for each interface type. A trade-off between\n * speed and latency; the smaller the chunk size the better change of messages and other\n * bulk transmissions getting in when big bulk transfers are happening. Set to 0 to not\n * break transmissions into chunks.\n */\n#ifndef VCHI_MAX_BULK_CHUNK_SIZE_MPHI\n#  define VCHI_MAX_BULK_CHUNK_SIZE_MPHI (16 * 1024)\n#endif\n\n/* NB Chunked CCP2 transmissions violate the letter of the CCP2 spec by using \"JPEG8\" mode\n * with multiple-line frames. Only use if the receiver can cope. */\n#ifndef VCHI_MAX_BULK_CHUNK_SIZE_CCP2\n#  define VCHI_MAX_BULK_CHUNK_SIZE_CCP2 0\n#endif\n\n/* How many TX messages can we have pending in our transmit slots. Once exhausted,\n * vchi_msg_queue will be blocked. */\n#ifndef VCHI_TX_MSG_QUEUE_SIZE\n#  define VCHI_TX_MSG_QUEUE_SIZE           256\n#endif\n\n/* How many RX messages can we have parsed in the receive slots. Once exhausted, parsing\n * will be suspended until older messages are dequeued/released. */\n#ifndef VCHI_RX_MSG_QUEUE_SIZE\n#  define VCHI_RX_MSG_QUEUE_SIZE           256\n#endif\n\n/* Really should be able to cope if we run out of received message descriptors, by\n * suspending parsing as the comment above says, but we don't. This sweeps the issue\n * under the carpet. */\n#if VCHI_RX_MSG_QUEUE_SIZE < (VCHI_MAX_MSG_SIZE/16 + 1) * VCHI_NUM_READ_SLOTS\n#  undef VCHI_RX_MSG_QUEUE_SIZE\n#  define VCHI_RX_MSG_QUEUE_SIZE (VCHI_MAX_MSG_SIZE/16 + 1) * VCHI_NUM_READ_SLOTS\n#endif\n\n/* How many bulk transmits can we have pending. Once exhausted, vchi_bulk_queue_transmit\n * will be blocked. */\n#ifndef VCHI_TX_BULK_QUEUE_SIZE\n#  define VCHI_TX_BULK_QUEUE_SIZE           64\n#endif\n\n/* How many bulk receives can we have pending. Once exhausted, vchi_bulk_queue_receive\n * will be blocked. */\n#ifndef VCHI_RX_BULK_QUEUE_SIZE\n#  define VCHI_RX_BULK_QUEUE_SIZE           64\n#endif\n\n/* A limit on how many outstanding bulk requests we expect the peer to give us. If\n * the peer asks for more than this, VCHI will fail and assert. The number is determined\n * by the peer's hardware - it's the number of outstanding requests that can be queued\n * on all bulk channels. VC3's MPHI peripheral allows 16. */\n#ifndef VCHI_MAX_PEER_BULK_REQUESTS\n#  define VCHI_MAX_PEER_BULK_REQUESTS       32\n#endif\n\n/* Define VCHI_CCP2TX_MANUAL_POWER if the host tells us when to turn the CCP2\n * transmitter on and off.\n */\n/*#define VCHI_CCP2TX_MANUAL_POWER*/\n\n#ifndef VCHI_CCP2TX_MANUAL_POWER\n\n/* Timeout (in milliseconds) for putting the CCP2TX interface into IDLE state. Set\n * negative for no IDLE.\n */\n#  ifndef VCHI_CCP2TX_IDLE_TIMEOUT\n#    define VCHI_CCP2TX_IDLE_TIMEOUT        5\n#  endif\n\n/* Timeout (in milliseconds) for putting the CCP2TX interface into OFF state. Set\n * negative for no OFF.\n */\n#  ifndef VCHI_CCP2TX_OFF_TIMEOUT\n#    define VCHI_CCP2TX_OFF_TIMEOUT         1000\n#  endif\n\n#endif /* VCHI_CCP2TX_MANUAL_POWER */\n\n#endif /* VCHI_CFG_H_ */\n\n/****************************** End of file **********************************/\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vchi/vchi_cfg_internal.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n#ifndef VCHI_CFG_INTERNAL_H_\n#define VCHI_CFG_INTERNAL_H_\n\n/****************************************************************************************\n * Control optimisation attempts.\n ***************************************************************************************/\n\n// Don't use lots of short-term locks - use great long ones, reducing the overall locks-per-second\n#define VCHI_COARSE_LOCKING\n\n// Avoid lock then unlock on exit from blocking queue operations (msg tx, bulk rx/tx)\n// (only relevant if VCHI_COARSE_LOCKING)\n#define VCHI_ELIDE_BLOCK_EXIT_LOCK\n\n// Avoid lock on non-blocking peek\n// (only relevant if VCHI_COARSE_LOCKING)\n#define VCHI_AVOID_PEEK_LOCK\n\n// Use one slot-handler thread per connection, rather than 1 thread dealing with all connections in rotation.\n#define VCHI_MULTIPLE_HANDLER_THREADS\n\n// Put free descriptors onto the head of the free queue, rather than the tail, so that we don't thrash\n// our way through the pool of descriptors.\n#define VCHI_PUSH_FREE_DESCRIPTORS_ONTO_HEAD\n\n// Don't issue a MSG_AVAILABLE callback for every single message. Possibly only safe if VCHI_COARSE_LOCKING.\n#define VCHI_FEWER_MSG_AVAILABLE_CALLBACKS\n\n// Don't use message descriptors for TX messages that don't need them\n#define VCHI_MINIMISE_TX_MSG_DESCRIPTORS\n\n// Nano-locks for multiqueue\n//#define VCHI_MQUEUE_NANOLOCKS\n\n// Lock-free(er) dequeuing\n//#define VCHI_RX_NANOLOCKS\n\n#endif /*VCHI_CFG_INTERNAL_H_*/\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vchi/vchi_common.h",
    "content": "/*\nCopyright (c) 2012-2014, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n// Contains global defs used by submodules within vchi\n\n#ifndef VCHI_COMMON_H_\n#define VCHI_COMMON_H_\n\n\n//flags used when sending messages (must be bitmapped)\ntypedef enum\n{\n   VCHI_FLAGS_NONE                      = 0x0,\n   VCHI_FLAGS_BLOCK_UNTIL_OP_COMPLETE   = 0x1,   // waits for message to be received, or sent (NB. not the same as being seen on other side)\n   VCHI_FLAGS_CALLBACK_WHEN_OP_COMPLETE = 0x2,   // run a callback when message sent\n   VCHI_FLAGS_BLOCK_UNTIL_QUEUED        = 0x4,   // return once the transfer is in a queue ready to go\n   VCHI_FLAGS_ALLOW_PARTIAL             = 0x8,\n   VCHI_FLAGS_BLOCK_UNTIL_DATA_READ     = 0x10,\n   VCHI_FLAGS_CALLBACK_WHEN_DATA_READ   = 0x20,\n\n   VCHI_FLAGS_ALIGN_SLOT            = 0x000080,  // internal use only\n   VCHI_FLAGS_BULK_AUX_QUEUED       = 0x010000,  // internal use only\n   VCHI_FLAGS_BULK_AUX_COMPLETE     = 0x020000,  // internal use only\n   VCHI_FLAGS_BULK_DATA_QUEUED      = 0x040000,  // internal use only\n   VCHI_FLAGS_BULK_DATA_COMPLETE    = 0x080000,  // internal use only\n   VCHI_FLAGS_INTERNAL              = 0xFF0000\n} VCHI_FLAGS_T;\n\n// constants for vchi_crc_control()\ntypedef enum {\n   VCHI_CRC_NOTHING = -1,\n   VCHI_CRC_PER_SERVICE = 0,\n   VCHI_CRC_EVERYTHING = 1,\n} VCHI_CRC_CONTROL_T;\n\n//callback reasons when an event occurs on a service\ntypedef enum\n{\n   VCHI_CALLBACK_REASON_MIN,\n\n   //This indicates that there is data available\n   //handle is the msg id that was transmitted with the data\n   //    When a message is received and there was no FULL message available previously, send callback\n   //    Tasks get kicked by the callback, reset their event and try and read from the fifo until it fails\n   VCHI_CALLBACK_MSG_AVAILABLE,\n   VCHI_CALLBACK_MSG_SENT,\n   VCHI_CALLBACK_MSG_SPACE_AVAILABLE, // XXX not yet implemented\n\n   // This indicates that a transfer from the other side has completed\n   VCHI_CALLBACK_BULK_RECEIVED,\n   //This indicates that data queued up to be sent has now gone\n   //handle is the msg id that was used when sending the data\n   VCHI_CALLBACK_BULK_SENT,\n   VCHI_CALLBACK_BULK_RX_SPACE_AVAILABLE, // XXX not yet implemented\n   VCHI_CALLBACK_BULK_TX_SPACE_AVAILABLE, // XXX not yet implemented\n\n   VCHI_CALLBACK_SERVICE_CLOSED,\n\n   // this side has sent XOFF to peer due to lack of data consumption by service\n   // (suggests the service may need to take some recovery action if it has\n   // been deliberately holding off consuming data)\n   VCHI_CALLBACK_SENT_XOFF,\n   VCHI_CALLBACK_SENT_XON,\n\n   // indicates that a bulk transfer has finished reading the source buffer\n   VCHI_CALLBACK_BULK_DATA_READ,\n\n   // power notification events (currently host side only)\n   VCHI_CALLBACK_PEER_OFF,\n   VCHI_CALLBACK_PEER_SUSPENDED,\n   VCHI_CALLBACK_PEER_ON,\n   VCHI_CALLBACK_PEER_RESUMED,\n   VCHI_CALLBACK_FORCED_POWER_OFF,\n\n#ifdef USE_VCHIQ_ARM\n   // some extra notifications provided by vchiq_arm\n   VCHI_CALLBACK_SERVICE_OPENED,\n   VCHI_CALLBACK_BULK_RECEIVE_ABORTED,\n   VCHI_CALLBACK_BULK_TRANSMIT_ABORTED,\n#endif\n\n   VCHI_CALLBACK_REASON_MAX\n} VCHI_CALLBACK_REASON_T;\n\n// service control options\ntypedef enum\n{\n   VCHI_SERVICE_OPTION_MIN,\n\n   VCHI_SERVICE_OPTION_TRACE,\n   VCHI_SERVICE_OPTION_SYNCHRONOUS,\n\n   VCHI_SERVICE_OPTION_MAX\n} VCHI_SERVICE_OPTION_T;\n\n//Callback used by all services / bulk transfers\ntypedef void (*VCHI_CALLBACK_T)( void *callback_param, //my service local param\n                                 VCHI_CALLBACK_REASON_T reason,\n                                 void *handle ); //for transmitting msg's only\n\n\n\n/*\n * Define vector struct for scatter-gather (vector) operations\n * Vectors can be nested - if a vector element has negative length, then\n * the data pointer is treated as pointing to another vector array, with\n * '-vec_len' elements. Thus to append a header onto an existing vector,\n * you can do this:\n *\n * void foo(const VCHI_MSG_VECTOR_T *v, int n)\n * {\n *    VCHI_MSG_VECTOR_T nv[2];\n *    nv[0].vec_base = my_header;\n *    nv[0].vec_len = sizeof my_header;\n *    nv[1].vec_base = v;\n *    nv[1].vec_len = -n;\n *    ...\n *\n */\ntypedef struct vchi_msg_vector {\n   const void *vec_base;\n   int32_t vec_len;\n} VCHI_MSG_VECTOR_T;\n\n// Opaque type for a connection API\ntypedef struct opaque_vchi_connection_api_t VCHI_CONNECTION_API_T;\n\n// Opaque type for a message driver\ntypedef struct opaque_vchi_message_driver_t VCHI_MESSAGE_DRIVER_T;\n\n\n// Iterator structure for reading ahead through received message queue. Allocated by client,\n// initialised by vchi_msg_look_ahead. Fields are for internal VCHI use only.\n// Iterates over messages in queue at the instant of the call to vchi_msg_lookahead -\n// will not proceed to messages received since. Behaviour is undefined if an iterator\n// is used again after messages for that service are removed/dequeued by any\n// means other than vchi_msg_iter_... calls on the iterator itself.\ntypedef struct {\n   struct opaque_vchi_service_t *service;\n   void *last;\n   void *next;\n   void *remove;\n} VCHI_MSG_ITER_T;\n\n\n#endif // VCHI_COMMON_H_\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vchi/vchi_mh.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n#ifndef VCHI_MH_H_\n#define VCHI_MH_H_\n\n#include <interface/vcos/vcos.h>\n\ntypedef int32_t VCHI_MEM_HANDLE_T;\n#define VCHI_MEM_HANDLE_INVALID 0\n\n#endif\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vchiq_arm/vchiq.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n#ifndef VCHIQ_VCHIQ_H\n#define VCHIQ_VCHIQ_H\n\n#include \"vchiq_if.h\"\n#include \"vchiq_util.h\"\n#include \"interface/vcos/vcos.h\"\n\n#endif\n\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vchiq_arm/vchiq_cfg.h",
    "content": "/*\nCopyright (c) 2014, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\n#ifndef VCHIQ_CFG_H\n#define VCHIQ_CFG_H\n\n#define VCHIQ_MAGIC              VCHIQ_MAKE_FOURCC('V', 'C', 'H', 'I')\n/* The version of VCHIQ - change with any non-trivial change */\n#define VCHIQ_VERSION            8\n/* The minimum compatible version - update to match VCHIQ_VERSION with any\n** incompatible change */\n#define VCHIQ_VERSION_MIN        3\n\n/* The version that introduced the VCHIQ_IOC_LIB_VERSION ioctl */\n#define VCHIQ_VERSION_LIB_VERSION 7\n\n/* The version that introduced the VCHIQ_IOC_CLOSE_DELIVERED ioctl */\n#define VCHIQ_VERSION_CLOSE_DELIVERED 7\n\n/* The version that made it safe to use SYNCHRONOUS mode */\n#define VCHIQ_VERSION_SYNCHRONOUS_MODE 8\n\n#define VCHIQ_MAX_STATES         2\n#define VCHIQ_MAX_SERVICES       4096\n#define VCHIQ_MAX_SLOTS          128\n#define VCHIQ_MAX_SLOTS_PER_SIDE 64\n\n#define VCHIQ_NUM_CURRENT_BULKS        32\n#define VCHIQ_NUM_SERVICE_BULKS        4\n\n#ifndef VCHIQ_ENABLE_DEBUG\n#define VCHIQ_ENABLE_DEBUG             1\n#endif\n\n#ifndef VCHIQ_ENABLE_STATS\n#define VCHIQ_ENABLE_STATS             1\n#endif\n\n#endif /* VCHIQ_CFG_H */\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vchiq_arm/vchiq_if.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\n#ifndef VCHIQ_IF_H\n#define VCHIQ_IF_H\n\n#include \"interface/vchi/vchi_mh.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#define VCHIQ_SERVICE_HANDLE_INVALID 0\n\n#define VCHIQ_SLOT_SIZE          4096\n#define VCHIQ_MAX_MSG_SIZE       (VCHIQ_SLOT_SIZE - sizeof(VCHIQ_HEADER_T))\n#define VCHIQ_CHANNEL_SIZE       VCHIQ_MAX_MSG_SIZE /* For backwards compatibility */\n\n#define VCHIQ_MAKE_FOURCC(x0, x1, x2, x3)     (((x0) << 24) | ((x1) << 16) | ((x2) << 8) | (x3))\n#define VCHIQ_GET_SERVICE_USERDATA(service) vchiq_get_service_userdata(service)\n#define VCHIQ_GET_SERVICE_FOURCC(service)   vchiq_get_service_fourcc(service)\n\ntypedef enum {\n   VCHIQ_SERVICE_OPENED,         // service, -, -\n   VCHIQ_SERVICE_CLOSED,         // service, -, -\n   VCHIQ_MESSAGE_AVAILABLE,      // service, header, -\n   VCHIQ_BULK_TRANSMIT_DONE,     // service, -, bulk_userdata\n   VCHIQ_BULK_RECEIVE_DONE,      // service, -, bulk_userdata\n   VCHIQ_BULK_TRANSMIT_ABORTED,  // service, -, bulk_userdata\n   VCHIQ_BULK_RECEIVE_ABORTED    // service, -, bulk_userdata\n} VCHIQ_REASON_T;\n\ntypedef enum\n{\n   VCHIQ_ERROR   = -1,\n   VCHIQ_SUCCESS = 0,\n   VCHIQ_RETRY   = 1\n} VCHIQ_STATUS_T;\n\ntypedef enum\n{\n   VCHIQ_BULK_MODE_CALLBACK,\n   VCHIQ_BULK_MODE_BLOCKING,\n   VCHIQ_BULK_MODE_NOCALLBACK\n} VCHIQ_BULK_MODE_T;\n\ntypedef enum\n{\n   VCHIQ_SERVICE_OPTION_AUTOCLOSE,\n   VCHIQ_SERVICE_OPTION_SLOT_QUOTA,\n   VCHIQ_SERVICE_OPTION_MESSAGE_QUOTA,\n   VCHIQ_SERVICE_OPTION_SYNCHRONOUS,\n   VCHIQ_SERVICE_OPTION_TRACE\n} VCHIQ_SERVICE_OPTION_T;\n\n#ifdef __HIGHC__\n/* Allow zero-sized arrays without warnings */\n#pragma warning (push)\n#pragma warning (disable : 4200)\n#endif\n\ntypedef struct vchiq_header_struct {\n   /* The message identifier - opaque to applications. */\n   int msgid;\n\n   /* Size of message data. */\n   unsigned int size;      \n\n   char data[0];           /* message */\n} VCHIQ_HEADER_T;\n\n#ifdef __HIGHC__\n#pragma warning (pop)\n#endif\n\ntypedef struct {\n   const void *data;\n   int size;\n} VCHIQ_ELEMENT_T;\n\ntypedef unsigned int VCHIQ_SERVICE_HANDLE_T;\n\ntypedef VCHIQ_STATUS_T (*VCHIQ_CALLBACK_T)(VCHIQ_REASON_T, VCHIQ_HEADER_T *,\n   VCHIQ_SERVICE_HANDLE_T, void *);\n\ntypedef struct vchiq_service_base_struct {\n   int fourcc;\n   VCHIQ_CALLBACK_T callback;\n   void *userdata;\n} VCHIQ_SERVICE_BASE_T;\n\ntypedef struct vchiq_service_params_struct {\n   int fourcc;\n   VCHIQ_CALLBACK_T callback;\n   void *userdata;\n   short version;       /* Increment for non-trivial changes */\n   short version_min;   /* Update for incompatible changes */\n} VCHIQ_SERVICE_PARAMS_T;\n\ntypedef struct vchiq_config_struct {\n   int max_msg_size;\n   int bulk_threshold; /* The message size aboce which it is better to use\n                          a bulk transfer (<= max_msg_size) */\n   int max_outstanding_bulks;\n   int max_services;\n   short version;      /* The version of VCHIQ */\n   short version_min;  /* The minimum compatible version of VCHIQ */\n} VCHIQ_CONFIG_T;\n\ntypedef struct vchiq_instance_struct *VCHIQ_INSTANCE_T;\ntypedef void (*VCHIQ_REMOTE_USE_CALLBACK_T)(void* cb_arg);\n\n\nextern VCHIQ_STATUS_T vchiq_initialise(VCHIQ_INSTANCE_T *pinstance);\nextern VCHIQ_STATUS_T vchiq_initialise_fd(VCHIQ_INSTANCE_T *pinstance, int dev_vchiq_fd);\nextern VCHIQ_STATUS_T vchiq_shutdown(VCHIQ_INSTANCE_T instance);\nextern VCHIQ_STATUS_T vchiq_connect(VCHIQ_INSTANCE_T instance);\nextern VCHIQ_STATUS_T vchiq_add_service(VCHIQ_INSTANCE_T instance,\n   const VCHIQ_SERVICE_PARAMS_T *params,\n   VCHIQ_SERVICE_HANDLE_T *pservice);\nextern VCHIQ_STATUS_T vchiq_open_service(VCHIQ_INSTANCE_T instance,\n   const VCHIQ_SERVICE_PARAMS_T *params,\n   VCHIQ_SERVICE_HANDLE_T *pservice);\nextern VCHIQ_STATUS_T vchiq_close_service(VCHIQ_SERVICE_HANDLE_T service);\nextern VCHIQ_STATUS_T vchiq_remove_service(VCHIQ_SERVICE_HANDLE_T service);\nextern VCHIQ_STATUS_T vchiq_use_service(VCHIQ_SERVICE_HANDLE_T service);\nextern VCHIQ_STATUS_T vchiq_release_service(VCHIQ_SERVICE_HANDLE_T service);\n\nextern VCHIQ_STATUS_T vchiq_queue_message(VCHIQ_SERVICE_HANDLE_T service,\n   const VCHIQ_ELEMENT_T *elements, int count);\nextern void           vchiq_release_message(VCHIQ_SERVICE_HANDLE_T service,\n   VCHIQ_HEADER_T *header);\nextern VCHIQ_STATUS_T vchiq_queue_bulk_transmit(VCHIQ_SERVICE_HANDLE_T service,\n   const void *data, int size, void *userdata);\nextern VCHIQ_STATUS_T vchiq_queue_bulk_receive(VCHIQ_SERVICE_HANDLE_T service,\n   void *data, int size, void *userdata);\nextern VCHIQ_STATUS_T vchiq_queue_bulk_transmit_handle(\n   VCHIQ_SERVICE_HANDLE_T service, VCHI_MEM_HANDLE_T handle,\n   const void *offset, int size, void *userdata);\nextern VCHIQ_STATUS_T vchiq_queue_bulk_receive_handle(\n   VCHIQ_SERVICE_HANDLE_T service, VCHI_MEM_HANDLE_T handle,\n   void *offset, int size, void *userdata);\nextern VCHIQ_STATUS_T vchiq_bulk_transmit(VCHIQ_SERVICE_HANDLE_T service,\n   const void *data, int size, void *userdata, VCHIQ_BULK_MODE_T mode);\nextern VCHIQ_STATUS_T vchiq_bulk_receive(VCHIQ_SERVICE_HANDLE_T service,\n   void *data, int size, void *userdata, VCHIQ_BULK_MODE_T mode);\nextern VCHIQ_STATUS_T vchiq_bulk_transmit_handle(VCHIQ_SERVICE_HANDLE_T service,\n   VCHI_MEM_HANDLE_T handle, const void *offset, int size, void *userdata,\n   VCHIQ_BULK_MODE_T mode);\nextern VCHIQ_STATUS_T vchiq_bulk_receive_handle(VCHIQ_SERVICE_HANDLE_T service,\n   VCHI_MEM_HANDLE_T handle, void *offset, int size, void *userdata,\n   VCHIQ_BULK_MODE_T mode, int (*copy_pagelist)());\nextern int   vchiq_get_client_id(VCHIQ_SERVICE_HANDLE_T service);\nextern void *vchiq_get_service_userdata(VCHIQ_SERVICE_HANDLE_T service);\nextern int   vchiq_get_service_fourcc(VCHIQ_SERVICE_HANDLE_T service);\nextern VCHIQ_STATUS_T vchiq_get_config(VCHIQ_INSTANCE_T instance,\n   int config_size, VCHIQ_CONFIG_T *pconfig);\nextern VCHIQ_STATUS_T vchiq_set_service_option(VCHIQ_SERVICE_HANDLE_T service,\n   VCHIQ_SERVICE_OPTION_T option, int value);\n\nextern VCHIQ_STATUS_T vchiq_remote_use(VCHIQ_INSTANCE_T instance,\n   VCHIQ_REMOTE_USE_CALLBACK_T callback, void *cb_arg);\nextern VCHIQ_STATUS_T vchiq_remote_release(VCHIQ_INSTANCE_T instance);\n\nextern VCHIQ_STATUS_T vchiq_dump_phys_mem(VCHIQ_SERVICE_HANDLE_T service,\n   void *ptr, size_t num_bytes);\n\nextern VCHIQ_STATUS_T vchiq_get_peer_version(VCHIQ_SERVICE_HANDLE_T handle,\n      short *peer_version);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* VCHIQ_IF_H */\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vchiq_arm/vchiq_ioctl.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\n#ifndef VCHIQ_IOCTLS_H\n#define VCHIQ_IOCTLS_H\n\n#include <linux/ioctl.h>\n#include \"vchiq_if.h\"\n\n#define VCHIQ_IOC_MAGIC 0xc4\n#define VCHIQ_INVALID_HANDLE (~0)\n\ntypedef struct {\n   VCHIQ_SERVICE_PARAMS_T params;\n   int is_open;\n   int is_vchi;\n   unsigned int handle;       /* OUT */\n} VCHIQ_CREATE_SERVICE_T;\n\ntypedef struct {\n   unsigned int handle;\n   unsigned int count;\n   const VCHIQ_ELEMENT_T *elements;\n} VCHIQ_QUEUE_MESSAGE_T;\n\ntypedef struct {\n   unsigned int handle;\n   void *data;\n   unsigned int size;\n   void *userdata;\n   VCHIQ_BULK_MODE_T mode;\n} VCHIQ_QUEUE_BULK_TRANSFER_T;\n\ntypedef struct {\n   VCHIQ_REASON_T reason;\n   VCHIQ_HEADER_T *header;\n   void *service_userdata;\n   void *bulk_userdata;\n} VCHIQ_COMPLETION_DATA_T;\n\ntypedef struct {\n   unsigned int count;\n   VCHIQ_COMPLETION_DATA_T *buf;\n   unsigned int msgbufsize;\n   unsigned int msgbufcount; /* IN/OUT */\n   void **msgbufs;\n} VCHIQ_AWAIT_COMPLETION_T;\n\ntypedef struct {\n   unsigned int handle;\n   int blocking;\n   unsigned int bufsize;\n   void *buf;\n} VCHIQ_DEQUEUE_MESSAGE_T;\n\ntypedef struct {\n   unsigned int config_size;\n   VCHIQ_CONFIG_T *pconfig;\n} VCHIQ_GET_CONFIG_T;\n\ntypedef struct {\n   unsigned int handle;\n   VCHIQ_SERVICE_OPTION_T option;\n   int value;\n} VCHIQ_SET_SERVICE_OPTION_T;\n\ntypedef struct {\n   void     *virt_addr;\n   size_t    num_bytes;\n} VCHIQ_DUMP_MEM_T;\n\n#define VCHIQ_IOC_CONNECT              _IO(VCHIQ_IOC_MAGIC,   0)\n#define VCHIQ_IOC_SHUTDOWN             _IO(VCHIQ_IOC_MAGIC,   1)\n#define VCHIQ_IOC_CREATE_SERVICE       _IOWR(VCHIQ_IOC_MAGIC, 2, VCHIQ_CREATE_SERVICE_T)\n#define VCHIQ_IOC_REMOVE_SERVICE       _IO(VCHIQ_IOC_MAGIC,   3)\n#define VCHIQ_IOC_QUEUE_MESSAGE        _IOW(VCHIQ_IOC_MAGIC,  4, VCHIQ_QUEUE_MESSAGE_T)\n#define VCHIQ_IOC_QUEUE_BULK_TRANSMIT  _IOWR(VCHIQ_IOC_MAGIC, 5, VCHIQ_QUEUE_BULK_TRANSFER_T)\n#define VCHIQ_IOC_QUEUE_BULK_RECEIVE   _IOWR(VCHIQ_IOC_MAGIC, 6, VCHIQ_QUEUE_BULK_TRANSFER_T)\n#define VCHIQ_IOC_AWAIT_COMPLETION     _IOWR(VCHIQ_IOC_MAGIC, 7, VCHIQ_AWAIT_COMPLETION_T)\n#define VCHIQ_IOC_DEQUEUE_MESSAGE      _IOWR(VCHIQ_IOC_MAGIC, 8, VCHIQ_DEQUEUE_MESSAGE_T)\n#define VCHIQ_IOC_GET_CLIENT_ID        _IO(VCHIQ_IOC_MAGIC,   9)\n#define VCHIQ_IOC_GET_CONFIG           _IOWR(VCHIQ_IOC_MAGIC, 10, VCHIQ_GET_CONFIG_T)\n#define VCHIQ_IOC_CLOSE_SERVICE        _IO(VCHIQ_IOC_MAGIC,   11)\n#define VCHIQ_IOC_USE_SERVICE          _IO(VCHIQ_IOC_MAGIC,   12)\n#define VCHIQ_IOC_RELEASE_SERVICE      _IO(VCHIQ_IOC_MAGIC,   13)\n#define VCHIQ_IOC_SET_SERVICE_OPTION   _IOW(VCHIQ_IOC_MAGIC,  14, VCHIQ_SET_SERVICE_OPTION_T)\n#define VCHIQ_IOC_DUMP_PHYS_MEM        _IOW(VCHIQ_IOC_MAGIC,  15, VCHIQ_DUMP_MEM_T)\n#define VCHIQ_IOC_LIB_VERSION          _IO(VCHIQ_IOC_MAGIC,   16)\n#define VCHIQ_IOC_CLOSE_DELIVERED      _IO(VCHIQ_IOC_MAGIC,   17)\n#define VCHIQ_IOC_MAX                  17\n\n#endif\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vchiq_arm/vchiq_test.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\n#ifndef VCHIQ_TEST_H\n#define VCHIQ_TEST_H\n\n#include \"vchiq_test_if.h\"\n\n#define VCOS_LOG_CATEGORY (&vchiq_test_log_category)\n\n#define VERBOSE_TRACE 1\n\n#define FUNC_FOURCC VCHIQ_MAKE_FOURCC('f','u','n','c')\n#define FUN2_FOURCC VCHIQ_MAKE_FOURCC('f','u','n','2')\n\n#define SERVICE1_DATA_SIZE 1024\n#define SERVICE2_DATA_SIZE 2048\n#define FUN2_MAX_DATA_SIZE 16384\n#define FUN2_MAX_ALIGN     4096\n#define BULK_ALIGN_SIZE    4096\n\n#define VCHIQ_TEST_VER     3\n\nenum {\n   MSG_ERROR,\n   MSG_ONEWAY,\n   MSG_ASYNC,\n   MSG_SYNC,\n   MSG_CONFIG,\n   MSG_ECHO\n};\n\nstruct test_params\n{\n   int magic; /* = MSG_CONFIG */\n   int blocksize;\n   int iters;\n   int verify;\n   int echo;\n   int align_size;\n   int client_align;\n   int server_align;\n   int client_message_quota;\n   int server_message_quota;\n};\n\n#if VERBOSE_TRACE\n\n#define EXPECT(_e, _v) if (_e != _v) { vcos_log_error(\"%d: \" #_e \" != \" #_v, __LINE__); VCOS_BKPT; goto error_exit; } else { vcos_log_trace(\"%d: \" #_e \" == \" #_v, __LINE__); }\n\n#define START_CALLBACK(_r, _u) \\\n   if (++callback_index == callback_count) { \\\n      if (reason != _r) { \\\n         vcos_log_error(\"%d: expected callback reason \" #_r \", got %d\", __LINE__, reason); VCOS_BKPT; goto error_exit; \\\n      } \\\n      else if ((int)VCHIQ_GET_SERVICE_USERDATA(service) != _u) { \\\n         vcos_log_error(\"%d: expected userdata %d, got %d\", __LINE__, _u, (int)VCHIQ_GET_SERVICE_USERDATA(service)); VCOS_BKPT; goto error_exit; \\\n      } \\\n      else \\\n      { \\\n         vcos_log_trace(\"%d: \" #_r \", \" #_u, __LINE__); \\\n      }\n\n#define START_BULK_CALLBACK(_r, _u, _bu)   \\\n   if (++bulk_index == bulk_count) {  \\\n      if (reason != _r) { \\\n         vcos_log_error(\"%d: expected callback reason \" #_r \", got %d\", __LINE__, reason); VCOS_BKPT; goto error_exit; \\\n      } \\\n      else if ((int)VCHIQ_GET_SERVICE_USERDATA(service) != _u) { \\\n         vcos_log_error(\"%d: expected userdata %d, got %d\", __LINE__, _u, (int)VCHIQ_GET_SERVICE_USERDATA(service)); VCOS_BKPT; goto error_exit; \\\n      } \\\n      else if ((int)bulk_userdata != _bu) { \\\n         vcos_log_error(\"%d: expected bulk_userdata %d, got %d\", __LINE__, _bu, (int)bulk_userdata); VCOS_BKPT; goto error_exit; \\\n      } \\\n      else \\\n      { \\\n         vcos_log_trace(\"%d: \" #_r \", \" #_u \", \" #_bu, __LINE__); \\\n      }\n\n#else\n\n#define EXPECT(_e, _v) if (_e != _v) { vcos_log_trace(\"%d: \" #_e \" != \" #_v, __LINE__); VCOS_BKPT; goto error_exit; }\n\n#define START_CALLBACK(_r, _u) \\\n   if (++callback_index == callback_count) { \\\n      if (reason != _r) { \\\n         vcos_log_error(\"%d: expected callback reason \" #_r \", got %d\", __LINE__, reason); VCOS_BKPT; goto error_exit; \\\n      } \\\n      else if ((int)VCHIQ_GET_SERVICE_USERDATA(service) != _u) { \\\n         vcos_log_error(\"%d: expected userdata %d, got %d\", __LINE__, _u, (int)VCHIQ_GET_SERVICE_USERDATA(service)); VCOS_BKPT; goto error_exit; \\\n      }\n\n#define START_BULK_CALLBACK(_r, _u, _bu)   \\\n   if (++bulk_index == bulk_count) {  \\\n      if (reason != _r) { \\\n         vcos_log_error(\"%d: expected callback reason \" #_r \", got %d\", __LINE__, reason); VCOS_BKPT; goto error_exit; \\\n      } \\\n      else if ((int)VCHIQ_GET_SERVICE_USERDATA(service) != _u) { \\\n         vcos_log_error(\"%d: expected userdata %d, got %d\", __LINE__, _u, (int)VCHIQ_GET_SERVICE_USERDATA(service)); VCOS_BKPT; goto error_exit; \\\n      } \\\n      else if ((int)bulk_userdata != _bu) { \\\n         vcos_log_error(\"%d: expected bulkuserdata %d, got %d\", __LINE__, _bu, (int)bulk_userdata); VCOS_BKPT; goto error_exit; \\\n      }\n\n#endif\n\n#define END_CALLBACK(_s) \\\n      return _s; \\\n   }\n\n#endif\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vchiq_arm/vchiq_test_if.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n#ifndef VCHIQ_TEST_IF_H\n#define VCHIQ_TEST_IF_H\n\n#include \"vchiq.h\"\n\nextern void vchiq_test_start_services(VCHIQ_INSTANCE_T instance);\n\n#endif\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vchiq_arm/vchiq_util.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\n#ifndef VCHIQ_UTIL_H\n#define VCHIQ_UTIL_H\n\n#include \"vchiq_if.h\"\n#include \"interface/vcos/vcos.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\ntypedef struct {\n   int size;\n   int read;\n   int write;\n\n   VCOS_EVENT_T pop;\n   VCOS_EVENT_T push;\n\n   VCHIQ_HEADER_T **storage;\n} VCHIU_QUEUE_T;\n\nextern int  vchiu_queue_init(VCHIU_QUEUE_T *queue, int size);\nextern void vchiu_queue_delete(VCHIU_QUEUE_T *queue);\n\nextern int vchiu_queue_is_empty(VCHIU_QUEUE_T *queue);\nextern int vchiu_queue_is_full(VCHIU_QUEUE_T *queue);\n\nextern void vchiu_queue_push(VCHIU_QUEUE_T *queue, VCHIQ_HEADER_T *header);\n\nextern VCHIQ_HEADER_T *vchiu_queue_peek(VCHIU_QUEUE_T *queue);\nextern VCHIQ_HEADER_T *vchiu_queue_pop(VCHIU_QUEUE_T *queue);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif\n\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vcos/generic/vcos_common.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n/*=============================================================================\nVideoCore OS Abstraction Layer - common postamble code\n=============================================================================*/\n\n/** \\file\n  *\n  * Postamble code included by the platform-specific header files\n  */\n\n#define VCOS_THREAD_PRI_DEFAULT VCOS_THREAD_PRI_NORMAL\n\n#if !defined(VCOS_THREAD_PRI_INCREASE)\n#error Which way to thread priorities go?\n#endif\n\n#if VCOS_THREAD_PRI_INCREASE < 0\n/* smaller numbers are higher priority */\n#define VCOS_THREAD_PRI_LESS(x) ((x)<VCOS_THREAD_PRI_MAX?(x)+1:VCOS_THREAD_PRI_MAX)\n#define VCOS_THREAD_PRI_MORE(x) ((x)>VCOS_THREAD_PRI_MIN?(x)-1:VCOS_THREAD_PRI_MIN)\n#else\n/* bigger numbers are lower priority */\n#define VCOS_THREAD_PRI_MORE(x) ((x)<VCOS_THREAD_PRI_MAX?(x)+1:VCOS_THREAD_PRI_MAX)\n#define VCOS_THREAD_PRI_LESS(x) ((x)>VCOS_THREAD_PRI_MIN?(x)-1:VCOS_THREAD_PRI_MIN)\n#endif\n\n/* Convenience for Brits: */\n#define VCOS_APPLICATION_INITIALISE VCOS_APPLICATION_INITIALIZE\n\n/*\n * Check for constant definitions\n */\n#ifndef VCOS_TICKS_PER_SECOND\n#error VCOS_TICKS_PER_SECOND not defined\n#endif\n\n#if !defined(VCOS_THREAD_PRI_MIN) || !defined(VCOS_THREAD_PRI_MAX)\n#error Priority range not defined\n#endif\n\n#if !defined(VCOS_THREAD_PRI_HIGHEST) || !defined(VCOS_THREAD_PRI_LOWEST) || !defined(VCOS_THREAD_PRI_NORMAL)\n#error Priority ordering not defined\n#endif\n\n#if !defined(VCOS_CAN_SET_STACK_ADDR)\n#error Can stack addresses be set on this platform? Please set this macro to either 0 or 1.\n#endif\n\n#if (_VCOS_AFFINITY_CPU0|_VCOS_AFFINITY_CPU1) & (~_VCOS_AFFINITY_MASK) \n#error _VCOS_AFFINITY_CPUxxx values are not consistent with _VCOS_AFFINITY_MASK\n#endif\n\n/** Append to the end of a singly-linked queue, O(1). Works with\n  * any structure where list has members 'head' and 'tail' and\n  * item has a 'next' pointer.\n  */\n#define VCOS_QUEUE_APPEND_TAIL(list, item) {\\\n   (item)->next = NULL;\\\n   if (!(list)->head) {\\\n      (list)->head = (list)->tail = (item); \\\n   } else {\\\n      (list)->tail->next = (item); \\\n      (list)->tail = (item); \\\n   } \\\n}\n\n#ifndef VCOS_HAVE_TIMER\nVCOSPRE_ void VCOSPOST_ vcos_timer_init(void);\n#endif\n\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vcos/generic/vcos_deprecated.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n/*\nThe symbol vcos_deprecated_code may be defined at most once, by the inclusion of \"vcos_deprecated.h\" in vcos_init.c.\nAny other inclusions of this header will cause the linker to warn about multiple definitions of vcos_deprecated_code, for example:\n   [ldvc] (Warning) \"vcos_deprecated_code\" is multiply defined in libs/vcos_threadx/vcos_init.c.o and libs/xxxxx/xxxxx.c.o\nIf you see a build message like this then the configuration you are building is using deprecated code.\nContact the person named in the accompanying comment for advice - do not remove the inclusion.\n*/\n\nint vcos_deprecated_code;\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vcos/generic/vcos_generic_blockpool.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n/*=============================================================================\nVideoCore OS Abstraction Layer - event flags implemented via a semaphore\n=============================================================================*/\n\n#ifndef VCOS_GENERIC_BLOCKPOOL_H\n#define VCOS_GENERIC_BLOCKPOOL_H\n\n/**\n  * \\file\n  *\n  * This provides a generic, thread safe implementation of a VCOS block pool\n  * fixed size memory allocator.\n  */\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#include \"interface/vcos/vcos_types.h\"\n\n/** Bits 0 to (VCOS_BLOCKPOOL_SUBPOOL_BITS - 1) are used to store the\n * subpool id. */\n#define VCOS_BLOCKPOOL_SUBPOOL_BITS 3\n#define VCOS_BLOCKPOOL_MAX_SUBPOOLS (1 << VCOS_BLOCKPOOL_SUBPOOL_BITS)\n\n/* Make zero an invalid handle at the cost of decreasing the maximum\n * number of blocks (2^28) by 1. Alternatively, a spare bit could be\n * used to indicated valid blocks but there are likely to be better\n * uses for spare bits. e.g. allowing more subpools\n */\n#define INDEX_OFFSET 1\n\n#define VCOS_BLOCKPOOL_HANDLE_GET_INDEX(h) \\\n   (((h) >> VCOS_BLOCKPOOL_SUBPOOL_BITS) - INDEX_OFFSET)\n\n#define VCOS_BLOCKPOOL_HANDLE_GET_SUBPOOL(h) \\\n   ((h) & ((1 << VCOS_BLOCKPOOL_SUBPOOL_BITS) - 1))\n\n#define VCOS_BLOCKPOOL_HANDLE_CREATE(i,s) \\\n   ((((i) + INDEX_OFFSET) << VCOS_BLOCKPOOL_SUBPOOL_BITS) | (s))\n\n#define VCOS_BLOCKPOOL_INVALID_HANDLE 0\n#define VCOS_BLOCKPOOL_ALIGN_DEFAULT sizeof(unsigned long)\n#define VCOS_BLOCKPOOL_FLAG_NONE 0\n\ntypedef struct VCOS_BLOCKPOOL_HEADER_TAG\n{\n   /* Blocks either refer to to the pool if they are allocated\n    * or the free list if they are available.\n    */\n   union {\n   struct VCOS_BLOCKPOOL_HEADER_TAG *next;\n   struct VCOS_BLOCKPOOL_SUBPOOL_TAG* subpool;\n   } owner;\n} VCOS_BLOCKPOOL_HEADER_T;\n\ntypedef struct VCOS_BLOCKPOOL_SUBPOOL_TAG\n{\n   /** VCOS_BLOCKPOOL_SUBPOOL_MAGIC */\n   uint32_t magic;\n   VCOS_BLOCKPOOL_HEADER_T* free_list;\n   /* The start of the pool memory */\n   void *mem;\n   /* Address of the first block header */\n   void *start;\n   /* The end of the subpool */\n   void *end;\n   /** The number of blocks in this sub-pool */\n   VCOS_UNSIGNED num_blocks;\n   /** Current number of available blocks in this sub-pool */\n   VCOS_UNSIGNED available_blocks;\n   /** Pointers to the pool that owns this sub-pool */\n   struct VCOS_BLOCKPOOL_TAG* owner;\n   /** Define properties such as memory ownership */\n   uint32_t flags;\n} VCOS_BLOCKPOOL_SUBPOOL_T;\n\ntypedef struct VCOS_BLOCKPOOL_TAG\n{\n   /** VCOS_BLOCKPOOL_MAGIC */\n   uint32_t magic;\n   /** Thread safety for Alloc, Free, Delete, Stats */\n   VCOS_MUTEX_T mutex;\n   /** Alignment of block data pointers */\n   VCOS_UNSIGNED align;\n   /** Flags for future use e.g. cache options */\n   VCOS_UNSIGNED flags;\n   /** The size of the block data */\n   size_t block_data_size;\n   /** Block size inc overheads */\n   size_t block_size;\n   /** Name for debugging */\n   const char *name;\n   /* The number of subpools that may be used */\n   VCOS_UNSIGNED num_subpools;\n   /** Number of blocks in each dynamically allocated subpool */\n   VCOS_UNSIGNED num_extension_blocks;\n   /** Array of subpools. Subpool zero is is not deleted until the pool is\n    * destroed. If the index of the pool is < num_subpools and\n    * subpool[index.mem] is null then the subpool entry is valid but\n    * \"not currently allocated\" */\n   VCOS_BLOCKPOOL_SUBPOOL_T subpools[VCOS_BLOCKPOOL_MAX_SUBPOOLS];\n} VCOS_BLOCKPOOL_T;\n\n#define VCOS_BLOCKPOOL_ROUND_UP(x,s)   (((x) + ((s) - 1)) & ~((s) - 1))\n/**\n * Calculates the size in bytes required for a block pool containing\n * num_blocks of size block_size plus any overheads.\n *\n * The block pool header (VCOS_BLOCKPOOL_T) is allocated separately\n *\n * Overheads:\n * block_size + header must be rounded up to meet the required alignment\n * The start of the first block may need to be up to align bytes\n * into the given buffer because statically allocated buffers within structures\n * are not guaranteed to be aligned as required.\n */\n#define VCOS_BLOCKPOOL_SIZE(num_blocks, block_size, align) \\\n   ((VCOS_BLOCKPOOL_ROUND_UP((block_size) + (align >= 4096 ? 32 : 0) + sizeof(VCOS_BLOCKPOOL_HEADER_T), \\\n                             (align)) * (num_blocks)) + (align))\n\n/**\n * Sanity check to verify whether a handle is potentially a blockpool handle\n * when the pool pointer is not available.\n *\n * If the pool pointer is available use vcos_blockpool_elem_to_handle instead.\n *\n * @param handle       the handle to verify\n * @param max_blocks   the expected maximum number of block in the pool\n *                     that the handle belongs to.\n */\n#define VCOS_BLOCKPOOL_IS_VALID_HANDLE_FORMAT(handle, max_blocks) \\\n    ((handle) != VCOS_BLOCKPOOL_INVALID_HANDLE \\\n     && VCOS_BLOCKPOOL_HANDLE_GET_INDEX((handle)) < (max_blocks))\n\nVCOSPRE_\n   VCOS_STATUS_T VCOSPOST_ vcos_generic_blockpool_init(VCOS_BLOCKPOOL_T *pool,\n      VCOS_UNSIGNED num_blocks, VCOS_UNSIGNED block_size,\n      void *start, VCOS_UNSIGNED pool_size,\n      VCOS_UNSIGNED align, VCOS_UNSIGNED flags,\n      const char *name);\n\nVCOSPRE_\n   VCOS_STATUS_T VCOSPOST_ vcos_generic_blockpool_create_on_heap(\n         VCOS_BLOCKPOOL_T *pool, VCOS_UNSIGNED num_blocks,\n         VCOS_UNSIGNED block_size,\n         VCOS_UNSIGNED align, VCOS_UNSIGNED flags,\n         const char *name);\n\nVCOSPRE_\n   VCOS_STATUS_T VCOSPOST_ vcos_generic_blockpool_extend(VCOS_BLOCKPOOL_T *pool,\n         VCOS_UNSIGNED num_extensions, VCOS_UNSIGNED num_blocks);\n\nVCOSPRE_ void VCOSPOST_ *vcos_generic_blockpool_alloc(VCOS_BLOCKPOOL_T *pool);\n\nVCOSPRE_ void VCOSPOST_ *vcos_generic_blockpool_calloc(VCOS_BLOCKPOOL_T *pool);\n\nVCOSPRE_ void VCOSPOST_ vcos_generic_blockpool_free(void *block);\n\nVCOSPRE_\n   VCOS_UNSIGNED VCOSPOST_ vcos_generic_blockpool_available_count(\n         VCOS_BLOCKPOOL_T *pool);\n\nVCOSPRE_\n   VCOS_UNSIGNED VCOSPOST_ vcos_generic_blockpool_used_count(\n         VCOS_BLOCKPOOL_T *pool);\n\nVCOSPRE_ void VCOSPOST_ vcos_generic_blockpool_delete(VCOS_BLOCKPOOL_T *pool);\n\nVCOSPRE_ uint32_t VCOSPOST_ vcos_generic_blockpool_elem_to_handle(void *block);\n\nVCOSPRE_ void VCOSPOST_\n   *vcos_generic_blockpool_elem_from_handle(\n         VCOS_BLOCKPOOL_T *pool, uint32_t handle);\n\nVCOSPRE_ uint32_t VCOSPOST_\n   vcos_generic_blockpool_is_valid_elem(\n         VCOS_BLOCKPOOL_T *pool, const void *block);\n#if defined(VCOS_INLINE_BODIES)\n\nVCOS_INLINE_IMPL\nVCOS_STATUS_T vcos_blockpool_init(VCOS_BLOCKPOOL_T *pool,\n      VCOS_UNSIGNED num_blocks, VCOS_UNSIGNED block_size,\n      void *start, VCOS_UNSIGNED pool_size,\n      VCOS_UNSIGNED align, VCOS_UNSIGNED flags, const char *name)\n{\n   return vcos_generic_blockpool_init(pool, num_blocks, block_size,\n         start, pool_size, align, flags, name);\n}\n\nVCOS_INLINE_IMPL\nVCOS_STATUS_T vcos_blockpool_create_on_heap(VCOS_BLOCKPOOL_T *pool,\n      VCOS_UNSIGNED num_blocks, VCOS_UNSIGNED block_size,\n      VCOS_UNSIGNED align, VCOS_UNSIGNED flags, const char *name)\n{\n   return vcos_generic_blockpool_create_on_heap(\n         pool, num_blocks, block_size, align, flags, name);\n}\n\nVCOS_INLINE_IMPL\n   VCOS_STATUS_T VCOSPOST_ vcos_blockpool_extend(VCOS_BLOCKPOOL_T *pool,\n         VCOS_UNSIGNED num_extensions, VCOS_UNSIGNED num_blocks)\n{\n    return vcos_generic_blockpool_extend(pool, num_extensions, num_blocks);\n}\n\nVCOS_INLINE_IMPL\nvoid *vcos_blockpool_alloc(VCOS_BLOCKPOOL_T *pool)\n{\n   return vcos_generic_blockpool_alloc(pool);\n}\n\nVCOS_INLINE_IMPL\nvoid *vcos_blockpool_calloc(VCOS_BLOCKPOOL_T *pool)\n{\n   return vcos_generic_blockpool_calloc(pool);\n}\n\nVCOS_INLINE_IMPL\nvoid vcos_blockpool_free(void *block)\n{\n   vcos_generic_blockpool_free(block);\n}\n\nVCOS_INLINE_IMPL\nVCOS_UNSIGNED vcos_blockpool_available_count(VCOS_BLOCKPOOL_T *pool)\n{\n   return vcos_generic_blockpool_available_count(pool);\n}\n\nVCOS_INLINE_IMPL\nVCOS_UNSIGNED vcos_blockpool_used_count(VCOS_BLOCKPOOL_T *pool)\n{\n   return vcos_generic_blockpool_used_count(pool);\n}\n\nVCOS_INLINE_IMPL\nvoid vcos_blockpool_delete(VCOS_BLOCKPOOL_T *pool)\n{\n   vcos_generic_blockpool_delete(pool);\n}\n\nVCOS_INLINE_IMPL\nuint32_t vcos_blockpool_elem_to_handle(void *block)\n{\n   return vcos_generic_blockpool_elem_to_handle(block);\n}\n\nVCOS_INLINE_IMPL\nvoid *vcos_blockpool_elem_from_handle(VCOS_BLOCKPOOL_T *pool, uint32_t handle)\n{\n   return vcos_generic_blockpool_elem_from_handle(pool, handle);\n}\n\nVCOS_INLINE_IMPL\nuint32_t vcos_blockpool_is_valid_elem(VCOS_BLOCKPOOL_T *pool, const void *block)\n{\n   return vcos_generic_blockpool_is_valid_elem(pool, block);\n}\n#endif /* VCOS_INLINE_BODIES */\n\n\n#ifdef __cplusplus\n}\n#endif\n#endif /* VCOS_GENERIC_BLOCKPOOL_H */\n\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vcos/generic/vcos_generic_event_flags.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n/*=============================================================================\nVideoCore OS Abstraction Layer - event flags implemented via a semaphore\n=============================================================================*/\n\n#ifndef VCOS_GENERIC_EVENT_FLAGS_H\n#define VCOS_GENERIC_EVENT_FLAGS_H\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#include \"interface/vcos/vcos_types.h\"\n\n/**\n  * \\file\n  *\n  * This provides event flags (as per Nucleus Event Groups) based on a\n  * mutex, a semaphore (per waiting thread) and a timer (per waiting\n  * thread).\n  * \n  * The data structure is a 32 bit unsigned int (the current set of\n  * flags) and a linked list of clients waiting to be 'satisfied'.\n  *\n  * The mutex merely locks access to the data structure. If a client\n  * calls vcos_event_flags_get() and the requested bits are not already\n  * present, it then sleeps on its per-thread semaphore after adding\n  * this semaphore to the queue waiting. It also sets up a timer.\n  *\n  * The per-thread semaphore and timer are actually stored in the\n  * thread context (joinable thread). In future it may become necessary\n  * to support non-VCOS threads by using thread local storage to\n  * create these objects and associate them with the thread.\n  */\n\nstruct VCOS_EVENT_WAITER_T;\n\ntypedef struct VCOS_EVENT_FLAGS_T\n{\n   VCOS_UNSIGNED events;      /**< Events currently set */\n   VCOS_MUTEX_T lock;         /**< Serialize access */\n   struct\n   {\n      struct VCOS_EVENT_WAITER_T *head;   /**< List of threads waiting */\n      struct VCOS_EVENT_WAITER_T *tail;   /**< List of threads waiting */\n   } waiters;\n} VCOS_EVENT_FLAGS_T;\n\n#define VCOS_OR      1\n#define VCOS_AND     2\n#define VCOS_CONSUME 4\n#define VCOS_OR_CONSUME (VCOS_OR | VCOS_CONSUME)\n#define VCOS_AND_CONSUME (VCOS_AND | VCOS_CONSUME)\n#define VCOS_EVENT_FLAG_OP_MASK (VCOS_OR|VCOS_AND)\n\nVCOSPRE_  VCOS_STATUS_T VCOSPOST_ vcos_generic_event_flags_create(VCOS_EVENT_FLAGS_T *flags, const char *name);\nVCOSPRE_  void VCOSPOST_ vcos_generic_event_flags_set(VCOS_EVENT_FLAGS_T *flags,\n                                                      VCOS_UNSIGNED events,\n                                                      VCOS_OPTION op);\nVCOSPRE_  void VCOSPOST_ vcos_generic_event_flags_delete(VCOS_EVENT_FLAGS_T *);\nVCOSPRE_  VCOS_STATUS_T VCOSPOST_ vcos_generic_event_flags_get(VCOS_EVENT_FLAGS_T *flags,\n                                                               VCOS_UNSIGNED requested_events,\n                                                               VCOS_OPTION op,\n                                                               VCOS_UNSIGNED suspend,\n                                                               VCOS_UNSIGNED *retrieved_events);\n\n#ifdef VCOS_INLINE_BODIES\n\nVCOS_INLINE_IMPL\nVCOS_STATUS_T vcos_event_flags_create(VCOS_EVENT_FLAGS_T *flags, const char *name) {\n   return vcos_generic_event_flags_create(flags, name);\n}\n\nVCOS_INLINE_IMPL\nvoid vcos_event_flags_set(VCOS_EVENT_FLAGS_T *flags,\n                          VCOS_UNSIGNED events,\n                          VCOS_OPTION op) {\n   vcos_generic_event_flags_set(flags, events, op);\n}\n\nVCOS_INLINE_IMPL\nvoid vcos_event_flags_delete(VCOS_EVENT_FLAGS_T *f) {\n   vcos_generic_event_flags_delete(f);\n}\n\nVCOS_INLINE_IMPL\nVCOS_STATUS_T vcos_event_flags_get(VCOS_EVENT_FLAGS_T *flags,\n                                   VCOS_UNSIGNED requested_events,\n                                   VCOS_OPTION op,\n                                   VCOS_UNSIGNED suspend,\n                                   VCOS_UNSIGNED *retrieved_events) {\n   return vcos_generic_event_flags_get(flags, requested_events, op, suspend, retrieved_events);\n}\n\n#endif /* VCOS_INLINE_BODIES */\n\n#ifdef __cplusplus\n}\n#endif\n#endif\n\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vcos/generic/vcos_generic_named_sem.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n/*=============================================================================\nVideoCore OS Abstraction Layer - named semaphores\n=============================================================================*/\n\n#ifndef VCOS_GENERIC_NAMED_SEM_H\n#define VCOS_GENERIC_NAMED_SEM_H\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#include \"interface/vcos/vcos_types.h\"\n\n/**\n * \\file\n *\n * Generic support for named semaphores, using regular ones. This is only\n * suitable for emulating them on an embedded MMUless system, since there is\n * no support for opening semaphores across process boundaries.\n *\n */\n\n#define VCOS_NAMED_SEMAPHORE_NAMELEN   64\n\n/* In theory we could use the name facility provided within Nucleus. However, this\n * is hard to do as semaphores are constantly being created and destroyed; we\n * would need to stop everything while allocating the memory for the semaphore\n * list and then walking it. So keep our own list.\n */\ntypedef struct VCOS_NAMED_SEMAPHORE_T\n{\n   struct VCOS_NAMED_SEMAPHORE_IMPL_T *actual; /**< There are 'n' named semaphores per 1 actual semaphore  */\n   VCOS_SEMAPHORE_T *sem;                      /**< Pointer to actual underlying semaphore */\n} VCOS_NAMED_SEMAPHORE_T;\n\nVCOSPRE_ VCOS_STATUS_T VCOSPOST_\nvcos_generic_named_semaphore_create(VCOS_NAMED_SEMAPHORE_T *sem, const char *name, VCOS_UNSIGNED count);\n\nVCOSPRE_ void VCOSPOST_ vcos_named_semaphore_delete(VCOS_NAMED_SEMAPHORE_T *sem);\n\nVCOSPRE_ VCOS_STATUS_T VCOSPOST_ _vcos_named_semaphore_init(void);\nVCOSPRE_ void VCOSPOST_ _vcos_named_semaphore_deinit(void);\n\n#if defined(VCOS_INLINE_BODIES)\n\nVCOS_INLINE_IMPL\nVCOS_STATUS_T vcos_named_semaphore_create(VCOS_NAMED_SEMAPHORE_T *sem, const char *name, VCOS_UNSIGNED count) {\n   return vcos_generic_named_semaphore_create(sem, name, count);\n}\n\nVCOS_INLINE_IMPL\nvoid vcos_named_semaphore_wait(VCOS_NAMED_SEMAPHORE_T *sem) {\n   vcos_semaphore_wait(sem->sem);\n}\n\nVCOS_INLINE_IMPL\nVCOS_STATUS_T vcos_named_semaphore_trywait(VCOS_NAMED_SEMAPHORE_T *sem) {\n   return vcos_semaphore_trywait(sem->sem);\n}\n\nVCOS_INLINE_IMPL\nvoid vcos_named_semaphore_post(VCOS_NAMED_SEMAPHORE_T *sem) {\n   vcos_semaphore_post(sem->sem);\n}\n\n\n#endif\n\n#ifdef __cplusplus\n}\n#endif\n#endif\n\n\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vcos/generic/vcos_generic_quickslow_mutex.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n/*=============================================================================\nVideoCore OS Abstraction Layer - reentrant mutexes created from regular ones.\n=============================================================================*/\n\n#ifndef VCOS_GENERIC_QUICKSLOW_MUTEX_H\n#define VCOS_GENERIC_QUICKSLOW_MUTEX_H\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#include \"interface/vcos/vcos_types.h\"\n\n/**\n * \\file\n *\n * Quickslow Mutexes implemented as regular ones (i.e. quick and slow modes are the same).\n *\n */\n\ntypedef VCOS_MUTEX_T VCOS_QUICKSLOW_MUTEX_T;\n\n#if defined(VCOS_INLINE_BODIES)\nVCOS_INLINE_IMPL\nVCOS_STATUS_T vcos_quickslow_mutex_create(VCOS_QUICKSLOW_MUTEX_T *m, const char *name)\n{\n   return vcos_mutex_create(m, name);\n}\n\nVCOS_INLINE_IMPL\nvoid vcos_quickslow_mutex_delete(VCOS_QUICKSLOW_MUTEX_T *m)\n{\n   vcos_mutex_delete(m);\n}\n\nVCOS_INLINE_IMPL\nvoid vcos_quickslow_mutex_lock(VCOS_QUICKSLOW_MUTEX_T *m)\n{\n   while (vcos_mutex_lock(m) == VCOS_EAGAIN);\n}\n\nVCOS_INLINE_IMPL\nvoid vcos_quickslow_mutex_unlock(VCOS_QUICKSLOW_MUTEX_T *m)\n{\n   vcos_mutex_unlock(m);\n}\n\nVCOS_INLINE_IMPL\nvoid vcos_quickslow_mutex_lock_quick(VCOS_QUICKSLOW_MUTEX_T *m)\n{\n   while (vcos_mutex_lock(m) == VCOS_EAGAIN);\n}\n\nVCOS_INLINE_IMPL\nvoid vcos_quickslow_mutex_unlock_quick(VCOS_QUICKSLOW_MUTEX_T *m)\n{\n   vcos_mutex_unlock(m);\n}\n\n#endif\n\n\n#ifdef __cplusplus\n}\n#endif\n#endif\n\n\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vcos/generic/vcos_generic_reentrant_mtx.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n/*=============================================================================\nVideoCore OS Abstraction Layer - reentrant mutexes created from regular ones.\n=============================================================================*/\n\n#ifndef VCOS_GENERIC_REENTRANT_MUTEX_H\n#define VCOS_GENERIC_REENTRANT_MUTEX_H\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#include \"interface/vcos/vcos_types.h\"\n\n/**\n * \\file\n *\n * Reentrant Mutexes from regular ones.\n *\n */\n\ntypedef struct VCOS_REENTRANT_MUTEX_T\n{\n   VCOS_MUTEX_T mutex;\n   VCOS_THREAD_T *owner;\n   unsigned count;\n} VCOS_REENTRANT_MUTEX_T;\n\n/* Extern definitions of functions that do the actual work */\n\nVCOSPRE_ VCOS_STATUS_T VCOSPOST_ vcos_generic_reentrant_mutex_create(VCOS_REENTRANT_MUTEX_T *m, const char *name);\n\nVCOSPRE_ void VCOSPOST_ vcos_generic_reentrant_mutex_delete(VCOS_REENTRANT_MUTEX_T *m);\n\nVCOSPRE_ void VCOSPOST_ vcos_generic_reentrant_mutex_lock(VCOS_REENTRANT_MUTEX_T *m);\n\nVCOSPRE_ void VCOSPOST_ vcos_generic_reentrant_mutex_unlock(VCOS_REENTRANT_MUTEX_T *m);\n\n/* Inline forwarding functions */\n\n#if defined(VCOS_INLINE_BODIES)\n\nVCOS_INLINE_IMPL\nVCOS_STATUS_T vcos_reentrant_mutex_create(VCOS_REENTRANT_MUTEX_T *m, const char *name) {\n   return vcos_generic_reentrant_mutex_create(m,name);\n}\n\nVCOS_INLINE_IMPL\nvoid vcos_reentrant_mutex_delete(VCOS_REENTRANT_MUTEX_T *m) {\n   vcos_generic_reentrant_mutex_delete(m);\n}\n\nVCOS_INLINE_IMPL\nvoid vcos_reentrant_mutex_lock(VCOS_REENTRANT_MUTEX_T *m) {\n   vcos_generic_reentrant_mutex_lock(m);\n}\n\nVCOS_INLINE_IMPL\nvoid vcos_reentrant_mutex_unlock(VCOS_REENTRANT_MUTEX_T *m) {\n   vcos_generic_reentrant_mutex_unlock(m);\n}\n#endif\n\n#ifdef __cplusplus\n}\n#endif\n#endif\n\n\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vcos/generic/vcos_generic_tls.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n/*=============================================================================\nVideoCore OS Abstraction Layer - generic thread local storage\n=============================================================================*/\n\n#ifndef VCOS_GENERIC_TLS_H\n#define VCOS_GENERIC_TLS_H\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#include \"interface/vcos/vcos_types.h\"\n\n/**\n  * \\file\n  *\n  * Do an emulation of Thread Local Storage. The platform needs to\n  * provide a way to set and get a per-thread pointer which is\n  * where the TLS data itself is stored.\n  *\n  *\n  * Each thread that wants to join in this scheme needs to call\n  * vcos_tls_thread_register().\n  *\n  * The platform needs to support the macros/functions\n  * _vcos_tls_thread_ptr_set() and _vcos_tls_thread_ptr_get().\n  */\n\n#ifndef VCOS_WANT_TLS_EMULATION\n#error Should not be included unless TLS emulation is defined\n#endif\n\n/** Number of slots to reserve per thread. This results in an overhead\n  * of this many words per thread.\n  */\n#define VCOS_TLS_MAX_SLOTS 4\n\n/** TLS key. Allocating one of these reserves the client one of the \n  * available slots.\n  */\ntypedef VCOS_UNSIGNED VCOS_TLS_KEY_T;\n\n/** TLS per-thread structure. Each thread gets one of these\n  * if TLS emulation (rather than native TLS support) is\n  * being used.\n  */\ntypedef struct VCOS_TLS_THREAD_T\n{\n   void *slots[VCOS_TLS_MAX_SLOTS];\n} VCOS_TLS_THREAD_T;\n\n/*\n * Internal APIs \n */\n\n/** Register this thread's TLS storage area. */\nVCOSPRE_ void VCOSPOST_ vcos_tls_thread_register(VCOS_TLS_THREAD_T *);\n\n/** Create a new TLS key */\nVCOSPRE_ VCOS_STATUS_T VCOSPOST_ vcos_generic_tls_create(VCOS_TLS_KEY_T *key);\n\n/** Delete a TLS key */\nVCOSPRE_ void VCOSPOST_ vcos_generic_tls_delete(VCOS_TLS_KEY_T tls);\n\n/** Initialise the TLS library */\nVCOSPRE_ VCOS_STATUS_T VCOSPOST_ vcos_tls_init(void);\n\n/** Deinitialise the TLS library */\nVCOSPRE_ void VCOSPOST_ vcos_tls_deinit(void);\n\n#if defined(VCOS_INLINE_BODIES)\n\n#undef VCOS_ASSERT_LOGGING_DISABLE\n#define VCOS_ASSERT_LOGGING_DISABLE 1\n\n/*\n * Implementations of public API functions\n */\n\n/** Set the given value. Since everything is per-thread, there is no need\n  * for any locking.\n  */\nVCOS_INLINE_IMPL\nVCOS_STATUS_T vcos_tls_set(VCOS_TLS_KEY_T tls, void *v) {\n   VCOS_TLS_THREAD_T *tlsdata = _vcos_tls_thread_ptr_get();\n   vcos_assert(tlsdata); /* Fires if this thread has not been registered */\n   if (tls<VCOS_TLS_MAX_SLOTS)\n   {\n      tlsdata->slots[tls] = v;\n      return VCOS_SUCCESS;\n   }\n   else\n   {\n      vcos_assert(0);\n      return VCOS_EINVAL;\n   }\n}\n\n/** Get the given value. No locking required.\n  */\nVCOS_INLINE_IMPL\nvoid *vcos_tls_get(VCOS_TLS_KEY_T tls) {\n   VCOS_TLS_THREAD_T *tlsdata = _vcos_tls_thread_ptr_get();\n   vcos_assert(tlsdata); /* Fires if this thread has not been registered */\n   if (tls<VCOS_TLS_MAX_SLOTS)\n   {\n      return tlsdata->slots[tls];\n   }\n   else\n   {\n      vcos_assert(0);\n      return NULL;\n   }\n}\n\nVCOS_INLINE_IMPL\nVCOS_STATUS_T vcos_tls_create(VCOS_TLS_KEY_T *key) {\n   return vcos_generic_tls_create(key);\n}\n\nVCOS_INLINE_IMPL\nvoid vcos_tls_delete(VCOS_TLS_KEY_T tls) {\n   vcos_generic_tls_delete(tls);\n}\n\n#undef VCOS_ASSERT_LOGGING_DISABLE\n#define VCOS_ASSERT_LOGGING_DISABLE 0\n\n#endif /* VCOS_INLINE_BODIES */\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif\n\n\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vcos/generic/vcos_joinable_thread_from_plain.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n/*=============================================================================\nVideoCore OS Abstraction Layer - implementation: joinable thread from plain\n=============================================================================*/\n\n/** \\file\n  *\n  * Header file for platforms creating the joinable thread from a lowlevel\n  * thread.\n  *\n  * In addition to the actual thread, the following are also created:\n  *\n  * - a semaphore to wait on when joining the thread\n  * - a semaphore to support counted suspend/resume (used by event group)\n  * - a per-thread timer (used by event group, but could be removed)\n  */\n\n#ifndef VCOS_JOINABLE_THREAD_FROM_PLAIN_H\n#define VCOS_JOINABLE_THREAD_FROM_PLAIN_H\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#ifndef VCOS_SEMAPHORE_H\n#include \"interface/vcos/vcos_semaphore.h\"\n#endif\n#ifndef VCOS_LOWLEVEL_THREAD_H\n#include \"interface/vcos/vcos_lowlevel_thread.h\"\n#endif\n#ifndef VCOS_TIMER_H\n#include \"interface/vcos/vcos_timer.h\"\n#endif\n\n#ifdef VCOS_WANT_TLS_EMULATION\n#include \"interface/vcos/generic/vcos_generic_tls.h\"\n#endif\n\n#define VCOS_THREAD_MAGIC 0x56436a74\n\n#define VCOS_THREAD_VALID(t) (t->magic == VCOS_THREAD_MAGIC)\n#define VCOS_HAVE_THREAD_AT_EXIT        1\n\n/** Thread attribute structure. Clients should not manipulate this directly, but\n  * should instead use the provided functions.\n  */\ntypedef struct VCOS_THREAD_ATTR_T\n{\n   void *ta_stackaddr;\n   VCOS_UNSIGNED ta_stacksz;\n   VCOS_UNSIGNED ta_priority;\n   VCOS_UNSIGNED ta_affinity;\n   VCOS_UNSIGNED ta_timeslice;\n   VCOS_UNSIGNED legacy;\n   VCOS_UNSIGNED ta_autostart;\n} VCOS_THREAD_ATTR_T;\n\n/** Each thread gets a timer, which is for internal VCOS use.\n  */\ntypedef struct _VCOS_THREAD_TIMER_T\n{\n   VCOS_TIMER_T timer;\n   void (*pfn)(void *);\n   void *cxt;\n} _VCOS_THREAD_TIMER_T;\n\ntypedef void (*VCOS_THREAD_EXIT_HANDLER_T)(void *);\n/** Called at thread exit.\n  */\ntypedef struct VCOS_THREAD_EXIT_T\n{\n   VCOS_THREAD_EXIT_HANDLER_T pfn;\n   void *cxt;\n} VCOS_THREAD_EXIT_T;\n#define VCOS_MAX_EXIT_HANDLERS  8\n\n/* The name field isn't used for anything, so we can just copy the\n * the pointer. Nucleus makes its own copy.\n */\ntypedef const char *          VCOS_LLTHREAD_T_NAME;\n#define _VCOS_LLTHREAD_NAME(dst,src) (dst)=(src)\n\n/*\n * Simulated TLS support\n */\n\n\n/** Thread structure.\n  *\n  * \\warning Do not access the members of this structure directly!\n  */\ntypedef struct VCOS_THREAD_T\n{\n   VCOS_LLTHREAD_T  thread;      /**< The underlying thread */\n   char name[16];                /**< The name */\n   unsigned int     magic;       /**< For debug */\n   void            *exit_data;   /**< Exit data passed out in vcos_joinable_thread_exit() */\n   void            *stack;       /**< Stack, if not supplied by caller */\n   VCOS_SEMAPHORE_T wait;        /**< Semaphore to wait on at join */\n   VCOS_SEMAPHORE_T suspend;     /**< Semaphore to wait on for counted suspend */\n   int16_t          joined;      /**< Joined yet? For debug. */\n   VCOS_UNSIGNED    legacy;      /**< Use (argc,argv) for entry point arguments */\n   void *(*entry)(void*);        /**< Entry point */\n   void             *arg;        /**< Argument passed to entry point */\n   void *(*term)(void*);         /**< Termination function, used by reaper */\n   void             *term_arg;   /**< Argument passed to termination function */\n   _VCOS_THREAD_TIMER_T _timer;  /**< Internal timer, mainly for event groups */\n#ifdef VCOS_WANT_TLS_EMULATION\n   VCOS_TLS_THREAD_T   _tls;     /**< TLS data when native TLS not available, or NULL */\n#endif\n   /** Array of functions to call at thread exit */\n   VCOS_THREAD_EXIT_T at_exit[VCOS_MAX_EXIT_HANDLERS];\n\n   struct VCOS_THREAD_T *next;   /**< For linked lists of threads */\n} VCOS_THREAD_T;\n\n#if defined(VCOS_INLINE_BODIES)\n\nVCOS_INLINE_IMPL\nvoid vcos_thread_attr_setstack(VCOS_THREAD_ATTR_T *attrs, void *addr, VCOS_UNSIGNED stacksz) {\n   attrs->ta_stackaddr = addr;\n   attrs->ta_stacksz = stacksz;\n}\n\nVCOS_INLINE_IMPL\nvoid vcos_thread_attr_setstacksize(VCOS_THREAD_ATTR_T *attrs, VCOS_UNSIGNED stacksz) {\n   attrs->ta_stacksz = stacksz;\n}\n\nVCOS_INLINE_IMPL\nvoid vcos_thread_attr_setpriority(VCOS_THREAD_ATTR_T *attrs, VCOS_UNSIGNED pri) {\n   attrs->ta_priority = pri;\n}\n\nVCOS_INLINE_IMPL\nvoid vcos_thread_attr_setaffinity(VCOS_THREAD_ATTR_T *attrs, VCOS_UNSIGNED affinity) {\n   attrs->ta_affinity = affinity;\n}\n\nVCOS_INLINE_IMPL\nvoid vcos_thread_attr_settimeslice(VCOS_THREAD_ATTR_T *attrs, VCOS_UNSIGNED ts) {\n   attrs->ta_timeslice = ts;\n}\n\nVCOS_INLINE_IMPL\nvoid _vcos_thread_attr_setlegacyapi(VCOS_THREAD_ATTR_T *attrs, VCOS_UNSIGNED legacy) {\n   attrs->legacy = legacy;\n}\n\nVCOS_INLINE_IMPL\nvoid vcos_thread_attr_setautostart(VCOS_THREAD_ATTR_T *attrs, VCOS_UNSIGNED autostart) {\n   attrs->ta_autostart = autostart;\n}\n\nVCOS_INLINE_IMPL\nVCOS_THREAD_T *vcos_thread_current(void) {\n   VCOS_THREAD_T *ret =  (VCOS_THREAD_T*)vcos_llthread_current();\n   /*If we're called from a non-vcos thread, this assert will fail.\n    *XXX FIXME why is this commented out?\n    *vcos_assert(ret->magic == VCOS_THREAD_MAGIC);\n    */\n   return ret;\n}\n\nVCOS_INLINE_IMPL\nint vcos_thread_running(VCOS_THREAD_T *thread) {\n   return vcos_llthread_running(&thread->thread);\n}\n\nVCOS_INLINE_IMPL\nvoid vcos_thread_resume(VCOS_THREAD_T *thread) {\n   vcos_llthread_resume(&thread->thread);\n}\n\n#endif /* VCOS_INLINE_BODIES */\n\n/**\n  * \\brief Create a VCOS_THREAD_T for the current thread. This is so we can have\n  * VCOS_THREAD_Ts even for threads not originally created by VCOS (eg the\n  * thread that calls vcos_init)\n  */\nextern VCOS_STATUS_T _vcos_thread_create_attach(VCOS_THREAD_T *thread,\n                                                const char *name);\n\n/**\n  * \\brief Deletes the VCOS_THREAD_T, but does not wait for the underlying\n  * thread to exit. This will cleanup everything created by\n  * _vcos_thread_create_attach\n  */\nextern void _vcos_thread_delete(VCOS_THREAD_T *thread);\n\n/** Register a function to be called when the current thread exits.\n  */\nextern VCOS_STATUS_T vcos_thread_at_exit(void (*pfn)(void*), void *cxt);\n\n/** Deregister a previously registered at-exit function.\n  */\nextern void vcos_thread_deregister_at_exit(void (*pfn)(void*), void *cxt);\n\n#ifdef __cplusplus\n}\n#endif\n#endif /* VCOS_JOINABLE_THREAD_FROM_PLAIN_H */\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vcos/generic/vcos_latch_from_sem.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n/*=============================================================================\nVideoCore OS Abstraction Layer - Construct a latch from a semaphore\n=============================================================================*/\n\n/** FIXME: rename to vcos_mutex_from_sem.c\n  */\n\ntypedef struct VCOS_MUTEX_T {\n   VCOS_SEMAPHORE_T sem;\n   struct VCOS_THREAD_T *owner;\n} VCOS_MUTEX_T;\n\nextern VCOS_STATUS_T vcos_generic_mutex_create(VCOS_MUTEX_T *latch, const char *name);\nextern void vcos_generic_mutex_delete(VCOS_MUTEX_T *latch);\nextern VCOS_STATUS_T vcos_generic_mutex_lock(VCOS_MUTEX_T *latch);\nextern void vcos_generic_mutex_unlock(VCOS_MUTEX_T *latch);\n\n#if defined(VCOS_INLINE_BODIES)\n\nVCOS_INLINE_IMPL\nVCOS_STATUS_T vcos_mutex_create(VCOS_MUTEX_T *latch, const char *name) {\n   return vcos_generic_mutex_create(latch,name);\n}\n\nVCOS_INLINE_IMPL\nvoid vcos_mutex_delete(VCOS_MUTEX_T *latch) {\n   vcos_generic_mutex_delete(latch);\n}\n\nVCOS_INLINE_IMPL\nVCOS_STATUS_T vcos_mutex_lock(VCOS_MUTEX_T *latch) {\n   return vcos_generic_mutex_lock(latch);\n}\n\nVCOS_INLINE_IMPL\nvoid vcos_mutex_unlock(VCOS_MUTEX_T *latch) {\n   vcos_generic_mutex_unlock(latch);\n}\n\n#endif /* VCOS_INLINE_BODIES */\n\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vcos/generic/vcos_mem_from_malloc.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n/*=============================================================================\nCreate the vcos_malloc API from the regular system malloc/free\n=============================================================================*/\n\n/**\n  * \\file\n  *\n  * Create the vcos malloc API from a regular system malloc/free library.\n  *\n  * The API lets callers specify an alignment.\n  *\n  * Under VideoCore this is not needed, as we can simply use the rtos_malloc routines.\n  * But on host platforms that won't be the case.\n  *\n  */\n\nVCOSPRE_ void * VCOSPOST_  vcos_generic_mem_alloc(VCOS_UNSIGNED sz, const char *desc);\nVCOSPRE_  void * VCOSPOST_ vcos_generic_mem_calloc(VCOS_UNSIGNED count, VCOS_UNSIGNED sz, const char *descr);\nVCOSPRE_  void VCOSPOST_   vcos_generic_mem_free(void *ptr);\nVCOSPRE_  void * VCOSPOST_ vcos_generic_mem_alloc_aligned(VCOS_UNSIGNED sz, VCOS_UNSIGNED align, const char *desc);\n\n#ifdef VCOS_INLINE_BODIES\n\nVCOS_INLINE_IMPL\nvoid *vcos_malloc(VCOS_UNSIGNED size, const char *description) {\n   return vcos_generic_mem_alloc(size, description);\n}\n\nVCOS_INLINE_IMPL\nvoid *vcos_calloc(VCOS_UNSIGNED num, VCOS_UNSIGNED size, const char *description) {\n   return vcos_generic_mem_calloc(num, size, description);\n}\n\nVCOS_INLINE_IMPL\nvoid vcos_free(void *ptr) {\n   vcos_generic_mem_free(ptr);\n}\n\nVCOS_INLINE_IMPL\nvoid * vcos_malloc_aligned(VCOS_UNSIGNED size, VCOS_UNSIGNED align, const char *description) {\n   return vcos_generic_mem_alloc_aligned(size, align, description);\n}\n\n\n#endif /* VCOS_INLINE_BODIES */\n\n\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vcos/generic/vcos_mutexes_are_reentrant.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n/*=============================================================================\nVideoCore OS Abstraction Layer - reentrant mutexes mapped directly to regular ones\n=============================================================================*/\n\n#ifndef VCOS_GENERIC_REENTRANT_MUTEX_H\n#define VCOS_GENERIC_REENTRANT_MUTEX_H\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#include \"interface/vcos/vcos_types.h\"\n#include \"interface/vcos/vcos_mutex.h\"\n\n/**\n * \\file\n *\n * Reentrant Mutexes directly using the native re-entrant mutex.\n *\n */\n\ntypedef VCOS_MUTEX_T VCOS_REENTRANT_MUTEX_T;\n\n/* Inline forwarding functions */\n\n#if defined(VCOS_INLINE_BODIES)\n\nVCOS_INLINE_IMPL\nVCOS_STATUS_T vcos_reentrant_mutex_create(VCOS_REENTRANT_MUTEX_T *m, const char *name) {\n   return vcos_mutex_create(m,name);\n}\n\nVCOS_INLINE_IMPL\nvoid vcos_reentrant_mutex_delete(VCOS_REENTRANT_MUTEX_T *m) {\n   vcos_mutex_delete(m);\n}\n\nVCOS_INLINE_IMPL\nvoid vcos_reentrant_mutex_lock(VCOS_REENTRANT_MUTEX_T *m) {\n   vcos_mutex_lock(m);\n}\n\nVCOS_INLINE_IMPL\nvoid vcos_reentrant_mutex_unlock(VCOS_REENTRANT_MUTEX_T *m) {\n   vcos_mutex_unlock(m);\n}\n\nVCOS_INLINE_IMPL\nint vcos_reentrant_mutex_is_locked(VCOS_REENTRANT_MUTEX_T *m) {\n   return vcos_mutex_is_locked(m);\n}\n\n#endif\n\n#ifdef __cplusplus\n}\n#endif\n#endif\n\n\n\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vcos/generic/vcos_thread_reaper.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n/*=============================================================================\nVideoCore OS Abstraction Layer - thread reaping\n=============================================================================*/\n\n#ifndef VCOS_THREAD_REAPER_H\n#define VCOS_THREAD_REAPER_H\n\n#define VCOS_HAVE_THREAD_REAPER\n\n/** Initialise the thread reaper.\n  */\nVCOS_STATUS_T vcos_thread_reaper_init(void);\n\n/** Reap a thread. Arranges for the thread to be automatically\n  * joined.\n  *\n  * @sa vcos_thread_join().\n  *\n  * @param thread           the thread to terminate\n  * @param on_terminated    called after the thread has exited\n  * @param cxt              pass back to the callback\n  *\n  */\nvoid vcos_thread_reap(VCOS_THREAD_T *thread, void (*on_terminated)(void*), void *cxt);\n\n#endif\n\n\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vcos/pthreads/vcos_futex_mutex.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n/*=============================================================================\nFIXME: This code should be moved to 'linux', it is linux-specific and not generic\non 'pthreads'.\n============================================================================*/\n\n#ifndef VCOS_MUTEX_FROM_FUTEX_H\n#define VCOS_MUTEX_FROM_FUTEX_H\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#include \"interface/vcos/vcos_types.h\"\n#include \"vcos_platform.h\"\n\ntypedef struct VCOS_FUTEX_T\n{\n   volatile int value;\n} VCOS_FUTEX_T;\n\ntypedef VCOS_FUTEX_T VCOS_MUTEX_T;\n\nVCOSPRE_ VCOS_STATUS_T VCOSPOST_ vcos_futex_init(VCOS_FUTEX_T *futex);\nVCOSPRE_ void VCOSPOST_ vcos_futex_delete(VCOS_FUTEX_T *futex);\nVCOSPRE_ VCOS_STATUS_T VCOSPOST_ vcos_futex_lock(VCOS_FUTEX_T *futex);\nVCOSPRE_ void VCOSPOST_ vcos_futex_unlock(VCOS_FUTEX_T *futex);\nVCOSPRE_ VCOS_STATUS_T VCOSPOST_ vcos_futex_trylock(VCOS_FUTEX_T *futex);\n\n#if defined(VCOS_INLINE_BODIES)\n\nVCOS_INLINE_IMPL\nVCOS_STATUS_T vcos_mutex_create(VCOS_MUTEX_T *latch, const char *name) {\n   vcos_unused(name);\n   return vcos_futex_init(latch);\n}\n\nVCOS_INLINE_IMPL\nvoid vcos_mutex_delete(VCOS_MUTEX_T *latch) {\n   vcos_futex_delete(latch);\n}\n\nVCOS_INLINE_IMPL\nVCOS_STATUS_T vcos_mutex_lock(VCOS_MUTEX_T *latch) {\n   return vcos_futex_lock(latch);\n}\n\nVCOS_INLINE_IMPL\nvoid vcos_mutex_unlock(VCOS_MUTEX_T *latch) {\n   vcos_futex_unlock(latch);\n}\n\nVCOS_INLINE_IMPL\nint vcos_mutex_is_locked(VCOS_MUTEX_T *latch) {\n   int rc = latch->value;\n   if (!rc) {\n      /* it wasn't locked */\n      return 0;\n   }\n   else {\n      return 1; /* it was locked */\n   }\n}\n\nVCOS_INLINE_IMPL\nVCOS_STATUS_T vcos_mutex_trylock(VCOS_MUTEX_T *m) {\n   return vcos_futex_trylock(m);\n}\n\n#endif /* VCOS_INLINE_BODIES */\n\n#ifdef __cplusplus\n}\n#endif\n#endif /* VCOS_MUTEX_FROM_FUTEX_H */\n\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vcos/pthreads/vcos_platform.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n/*=============================================================================\nVideoCore OS Abstraction Layer - pthreads types\n=============================================================================*/\n\n/* DO NOT include this file directly - instead include it via vcos.h */\n\n/** @file\n  *\n  * Pthreads implementation of VCOS.\n  *\n  */\n\n#ifndef VCOS_PLATFORM_H\n#define VCOS_PLATFORM_H\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#include <pthread.h>\n#include <semaphore.h>\n#include <unistd.h>\n#include <sys/types.h>\n#include <sched.h>\n#include <errno.h>\n#include <unistd.h>\n#include <string.h>\n#include <strings.h>\n#include <time.h>\n#include <signal.h>\n#include <stddef.h>\n#include <stdlib.h>\n#include <dlfcn.h>\n\n\n#define VCOS_HAVE_RTOS         1\n#define VCOS_HAVE_SEMAPHORE    1\n#define VCOS_HAVE_EVENT        1\n#define VCOS_HAVE_QUEUE        0\n#define VCOS_HAVE_LEGACY_ISR   0\n#define VCOS_HAVE_TIMER        1\n#define VCOS_HAVE_CANCELLATION_SAFE_TIMER 1\n#define VCOS_HAVE_MEMPOOL      0\n#define VCOS_HAVE_ISR          0\n#define VCOS_HAVE_ATOMIC_FLAGS 1\n#define VCOS_HAVE_THREAD_AT_EXIT        1\n#define VCOS_HAVE_ONCE         1\n#define VCOS_HAVE_BLOCK_POOL   1\n#define VCOS_HAVE_FILE         0\n#define VCOS_HAVE_PROC         0\n#define VCOS_HAVE_CFG          0\n#define VCOS_HAVE_ALIEN_THREADS  1\n#define VCOS_HAVE_CMD          1\n#define VCOS_HAVE_EVENT_FLAGS  1\n#define VCOS_WANT_LOG_CMD      0    /* User apps should do their own thing */\n\n#define VCOS_ALWAYS_WANT_LOGGING\n\n#ifdef __linux__\n#define VCOS_HAVE_BACKTRACE    1\n#endif\n\n#define VCOS_SO_EXT  \".so\"\n\n/* Linux/pthreads seems to have different timer characteristics */\n#define VCOS_TIMER_MARGIN_EARLY 0\n#define VCOS_TIMER_MARGIN_LATE 15\n\ntypedef sem_t                 VCOS_SEMAPHORE_T;\ntypedef uint32_t              VCOS_UNSIGNED;\ntypedef uint32_t              VCOS_OPTION;\ntypedef pthread_key_t         VCOS_TLS_KEY_T;\ntypedef pthread_once_t        VCOS_ONCE_T;\n\ntypedef struct VCOS_LLTHREAD_T\n{\n   pthread_t thread; // Must be first field.\n} VCOS_LLTHREAD_T;\n\n/* VCOS_CASSERT(offsetof(VCOS_LLTHREAD_T, thread) == 0); */\n\n#ifndef VCOS_USE_VCOS_FUTEX\ntypedef pthread_mutex_t       VCOS_MUTEX_T;\n#else\n#include \"vcos_futex_mutex.h\"\n#endif /* VCOS_USE_VCOS_FUTEX */\n\ntypedef struct\n{\n   VCOS_MUTEX_T   mutex;\n   sem_t          sem;\n} VCOS_EVENT_T;\n\n#define VCOS_ONCE_INIT        PTHREAD_ONCE_INIT\n\ntypedef struct VCOS_TIMER_T\n{\n   pthread_t thread;                      /**< id of the timer thread */\n\n   pthread_mutex_t lock;                  /**< lock protecting all other members of the struct */\n   pthread_cond_t settings_changed;       /**< cond. var. for informing the timer thread about changes*/\n   int quit;                              /**< non-zero if the timer thread is requested to quit*/\n\n   struct timespec expires;               /**< absolute time of next expiration, or 0 if disarmed*/\n\n   void (*orig_expiration_routine)(void*);/**< the expiration routine provided by the user of the timer*/\n   void *orig_context;                    /**< the context for exp. routine provided by the user*/\n\n} VCOS_TIMER_T;\n\n/** Thread attribute structure. Don't use pthread_attr directly, as\n  * the calls can fail, and inits must match deletes.\n  */\ntypedef struct VCOS_THREAD_ATTR_T\n{\n   void *ta_stackaddr;\n   VCOS_UNSIGNED ta_stacksz;\n   VCOS_UNSIGNED ta_priority;\n   VCOS_UNSIGNED ta_affinity;\n   VCOS_UNSIGNED ta_timeslice;\n   VCOS_UNSIGNED legacy;\n} VCOS_THREAD_ATTR_T;\n\n/** Called at thread exit.\n  */\ntypedef struct VCOS_THREAD_EXIT_T\n{\n   void (*pfn)(void *);\n   void *cxt;\n} VCOS_THREAD_EXIT_T;\n#define VCOS_MAX_EXIT_HANDLERS  4\n\ntypedef struct VCOS_THREAD_T\n{\n   pthread_t thread;             /**< The thread itself */\n   VCOS_THREAD_ENTRY_FN_T entry; /**< The thread entry point */\n   void *arg;                    /**< The argument to be passed to entry */\n   VCOS_SEMAPHORE_T suspend;     /**< For support event groups and similar - a per thread semaphore */\n\n   VCOS_TIMER_T task_timer;\n   int task_timer_created;       /**< non-zero if the task timer has already been created*/\n   void (*orig_task_timer_expiration_routine)(void*);\n   void *orig_task_timer_context;\n\n   VCOS_UNSIGNED legacy;\n   char name[16];                /**< Record the name of this thread, for diagnostics */\n   VCOS_UNSIGNED dummy;          /**< Dummy thread created for non-vcos created threads */\n\n   /** Callback invoked at thread exit time */\n   VCOS_THREAD_EXIT_T at_exit[VCOS_MAX_EXIT_HANDLERS];\n} VCOS_THREAD_T;\n\n#ifdef VCOS_PTHREADS_WANT_HISR_EMULATION\n\ntypedef struct\n{\n   VCOS_THREAD_T thread;\n   char stack[1024];\n   VCOS_SEMAPHORE_T waitsem;\n} VCOS_HISR_T;\n\n#endif\n\n#define VCOS_SUSPEND          -1\n#define VCOS_NO_SUSPEND       0\n\n#define VCOS_START 1\n#define VCOS_NO_START 0\n\n#define VCOS_THREAD_PRI_MIN   (sched_get_priority_min(SCHED_OTHER))\n#define VCOS_THREAD_PRI_MAX   (sched_get_priority_max(SCHED_OTHER))\n\n#define VCOS_THREAD_PRI_INCREASE (1)\n#define VCOS_THREAD_PRI_HIGHEST  VCOS_THREAD_PRI_MAX\n#define VCOS_THREAD_PRI_LOWEST   VCOS_THREAD_PRI_MIN\n#define VCOS_THREAD_PRI_NORMAL ((VCOS_THREAD_PRI_MAX+VCOS_THREAD_PRI_MIN)/2)\n#define VCOS_THREAD_PRI_BELOW_NORMAL (VCOS_THREAD_PRI_NORMAL-VCOS_THREAD_PRI_INCREASE)\n#define VCOS_THREAD_PRI_ABOVE_NORMAL (VCOS_THREAD_PRI_NORMAL+VCOS_THREAD_PRI_INCREASE)\n#define VCOS_THREAD_PRI_REALTIME VCOS_THREAD_PRI_MAX\n\n#define _VCOS_AFFINITY_DEFAULT 0\n#define _VCOS_AFFINITY_CPU0    0x100\n#define _VCOS_AFFINITY_CPU1    0x200\n#define _VCOS_AFFINITY_MASK    0x300\n#define VCOS_CAN_SET_STACK_ADDR  0\n\n#define VCOS_TICKS_PER_SECOND _vcos_get_ticks_per_second()\n\n#include \"interface/vcos/generic/vcos_generic_event_flags.h\"\n#include \"interface/vcos/generic/vcos_generic_blockpool.h\"\n#include \"interface/vcos/generic/vcos_mem_from_malloc.h\"\n\n/** Convert errno values into the values recognized by vcos */\nVCOSPRE_ VCOS_STATUS_T vcos_pthreads_map_error(int error);\nVCOSPRE_ VCOS_STATUS_T VCOSPOST_ vcos_pthreads_map_errno(void);\n\n/** Register a function to be called when the current thread exits.\n  */\nextern VCOS_STATUS_T vcos_thread_at_exit(void (*pfn)(void*), void *cxt);\n\nextern uint32_t _vcos_get_ticks_per_second(void);\n\n/**\n * Set to 1 by default when ANDROID is defined. Allows runtime\n * switching for console apps.\n */\nextern int vcos_use_android_log;\n\ntypedef struct {\n   VCOS_MUTEX_T mutex;\n   uint32_t flags;\n} VCOS_ATOMIC_FLAGS_T;\n\n#if defined(VCOS_INLINE_BODIES)\n\n#undef VCOS_ASSERT_LOGGING_DISABLE\n#define VCOS_ASSERT_LOGGING_DISABLE 1\n\n\n/*\n * Counted Semaphores\n */\nVCOS_INLINE_IMPL\nVCOS_STATUS_T vcos_semaphore_wait(VCOS_SEMAPHORE_T *sem) {\n   int ret;\n   /* gdb causes sem_wait() to EINTR when a breakpoint is hit, retry here */\n   while ((ret = sem_wait(sem)) == -1 && errno == EINTR)\n      continue;\n   vcos_assert(ret==0);\n   return VCOS_SUCCESS;\n}\n\nVCOS_INLINE_IMPL\nVCOS_STATUS_T vcos_semaphore_trywait(VCOS_SEMAPHORE_T *sem) {\n   int ret;\n   while ((ret = sem_trywait(sem)) == -1 && errno == EINTR)\n      continue;\n   if (ret == 0)\n      return VCOS_SUCCESS;\n   else if (errno == EAGAIN)\n      return VCOS_EAGAIN;\n   else {\n      vcos_assert(0);\n      return VCOS_EINVAL;\n   }\n}\n\n/**\n  * \\brief Wait on a semaphore with a timeout.\n  *\n  * Note that this function may not be implemented on all\n  * platforms, and may not be efficient on all platforms\n  * (see comment in vcos_semaphore_wait)\n  *\n  * Try to obtain the semaphore. If it is already taken, return\n  * VCOS_EAGAIN.\n  * @param sem Semaphore to wait on\n  * @param timeout Number of milliseconds to wait before\n  *                returning if the semaphore can't be acquired.\n  * @return VCOS_SUCCESS - semaphore was taken.\n  *         VCOS_EAGAIN - could not take semaphore (i.e. timeout\n  *         expired)\n  *         VCOS_EINVAL - Some other error (most likely bad\n  *         parameters).\n  */\nVCOS_INLINE_IMPL\nVCOS_STATUS_T vcos_semaphore_wait_timeout(VCOS_SEMAPHORE_T *sem, VCOS_UNSIGNED timeout) {\n   struct timespec ts;\n   int ret;\n   if (clock_gettime(CLOCK_REALTIME, &ts) == -1)\n      return VCOS_EINVAL;\n   ts.tv_sec  += timeout/1000;\n   ts.tv_nsec += (timeout%1000)*1000*1000;\n   if (ts.tv_nsec > 1000000000) {\n      ts.tv_sec++;\n      ts.tv_nsec -= 1000000000;\n   }\n\n   while (1) {\n      ret = sem_timedwait( sem, &ts );\n      if (ret == 0) {\n         return VCOS_SUCCESS;\n      } else {\n         if (errno == EINTR) {\n            continue;\n         } else if (errno == ETIMEDOUT) {\n            return VCOS_EAGAIN;\n         } else {\n            vcos_assert(0);\n            return VCOS_EINVAL;\n         }\n      }\n   }\n}\n\nVCOS_INLINE_IMPL\nVCOS_STATUS_T vcos_semaphore_create(VCOS_SEMAPHORE_T *sem,\n                                    const char *name,\n                                    VCOS_UNSIGNED initial_count) {\n   int rc = sem_init(sem, 0, initial_count);\n   (void)name;\n   if (rc != -1) return VCOS_SUCCESS;\n   else return vcos_pthreads_map_errno();\n}\n\nVCOS_INLINE_IMPL\nvoid vcos_semaphore_delete(VCOS_SEMAPHORE_T *sem) {\n   int rc = sem_destroy(sem);\n   vcos_assert(rc != -1);\n   (void)rc;\n}\n\nVCOS_INLINE_IMPL\nVCOS_STATUS_T vcos_semaphore_post(VCOS_SEMAPHORE_T *sem) {\n   int rc = sem_post(sem);\n   vcos_assert(rc == 0);\n   (void)rc;\n   return VCOS_SUCCESS;\n}\n\n/***********************************************************\n *\n * Threads\n *\n ***********************************************************/\n\n\nextern VCOS_THREAD_T *vcos_dummy_thread_create(void);\nextern pthread_key_t _vcos_thread_current_key;\nextern uint64_t vcos_getmicrosecs64_internal(void);\n\nVCOS_INLINE_IMPL\nuint32_t vcos_getmicrosecs(void) { return (uint32_t)vcos_getmicrosecs64_internal(); }\n\nVCOS_INLINE_IMPL\nuint64_t vcos_getmicrosecs64(void) { return vcos_getmicrosecs64_internal(); }\n\nVCOS_INLINE_IMPL\nVCOS_THREAD_T *vcos_thread_current(void) {\n   void *ret = pthread_getspecific(_vcos_thread_current_key);\n   if (ret == NULL)\n   {\n      ret = vcos_dummy_thread_create();\n   }\n\n#ifdef __cplusplus\n   return static_cast<VCOS_THREAD_T*>(ret);\n#else\n   return (VCOS_THREAD_T *)ret;\n#endif\n}\n\nVCOS_INLINE_IMPL\nvoid vcos_sleep(uint32_t ms) {\n   struct timespec ts;\n   ts.tv_sec = ms/1000;\n   ts.tv_nsec = ms % 1000 * (1000000);\n   nanosleep(&ts, NULL);\n}\n\nVCOS_INLINE_IMPL\nvoid vcos_thread_attr_setstack(VCOS_THREAD_ATTR_T *attr, void *addr, VCOS_UNSIGNED sz) {\n   attr->ta_stackaddr = addr;\n   attr->ta_stacksz = sz;\n}\n\nVCOS_INLINE_IMPL\nvoid vcos_thread_attr_setstacksize(VCOS_THREAD_ATTR_T *attr, VCOS_UNSIGNED sz) {\n   attr->ta_stacksz = sz;\n}\n\nVCOS_INLINE_IMPL\nvoid vcos_thread_attr_setpriority(VCOS_THREAD_ATTR_T *attr, VCOS_UNSIGNED pri) {\n   (void)attr;\n   (void)pri;\n}\n\nVCOS_INLINE_IMPL\nvoid vcos_thread_set_priority(VCOS_THREAD_T *thread, VCOS_UNSIGNED p) {\n   /* not implemented */\n   (void)thread;\n   (void)p;\n}\n\nVCOS_INLINE_IMPL\nVCOS_UNSIGNED vcos_thread_get_priority(VCOS_THREAD_T *thread) {\n   /* not implemented */\n   (void)thread;\n   return 0;\n}\n\nVCOS_INLINE_IMPL\nvoid vcos_thread_set_affinity(VCOS_THREAD_T *thread, VCOS_UNSIGNED affinity) {\n   /* not implemented */\n   vcos_unused(thread);\n   vcos_unused(affinity);\n}\n\n\nVCOS_INLINE_IMPL\nvoid vcos_thread_attr_setaffinity(VCOS_THREAD_ATTR_T *attrs, VCOS_UNSIGNED affinity) {\n   attrs->ta_affinity = affinity;\n}\n\nVCOS_INLINE_IMPL\nvoid vcos_thread_attr_settimeslice(VCOS_THREAD_ATTR_T *attrs, VCOS_UNSIGNED ts) {\n   attrs->ta_timeslice = ts;\n}\n\nVCOS_INLINE_IMPL\nvoid _vcos_thread_attr_setlegacyapi(VCOS_THREAD_ATTR_T *attrs, VCOS_UNSIGNED legacy) {\n   attrs->legacy = legacy;\n}\n\nVCOS_INLINE_IMPL\nvoid vcos_thread_attr_setautostart(VCOS_THREAD_ATTR_T *attrs, VCOS_UNSIGNED autostart) {\n   (void)attrs;\n   (void)autostart;\n}\n\nVCOS_INLINE_IMPL\nVCOS_LLTHREAD_T *vcos_llthread_current(void) {\n   return (VCOS_LLTHREAD_T *)pthread_self();\n}\n\nVCOS_INLINE_IMPL\nVCOS_UNSIGNED vcos_thread_get_affinity(VCOS_THREAD_T *thread) {\n   vcos_unused(thread);\n   return _VCOS_AFFINITY_CPU0;\n}\n\nVCOS_INLINE_IMPL\nint vcos_thread_running(VCOS_THREAD_T *thread) {\n   vcos_unused(thread);\n   /* Not applicable to pthreads */\n   return 0;\n}\n\nVCOS_INLINE_IMPL\nVCOS_UNSIGNED vcos_change_preemption(VCOS_UNSIGNED pe) {\n   vcos_unused(pe);\n   /* Nothing to do */\n   return 0;\n}\n\nVCOS_INLINE_IMPL\nvoid vcos_thread_relinquish(void) {\n   /* Nothing to do */\n}\n\nVCOS_INLINE_IMPL\nvoid vcos_thread_resume(VCOS_THREAD_T *thread) {\n   vcos_unused(thread);\n   /* Nothing to do */\n}\n\n\n/*\n * Mutexes\n */\n\n#ifndef VCOS_USE_VCOS_FUTEX\n\nVCOS_INLINE_IMPL\nVCOS_STATUS_T vcos_mutex_create(VCOS_MUTEX_T *latch, const char *name) {\n   int rc = pthread_mutex_init(latch, NULL);\n   (void)name;\n   if (rc == 0) return VCOS_SUCCESS;\n   else return vcos_pthreads_map_errno();\n}\n\nVCOS_INLINE_IMPL\nvoid vcos_mutex_delete(VCOS_MUTEX_T *latch) {\n   int rc = pthread_mutex_destroy(latch);\n   (void)rc;\n   vcos_assert(rc==0);\n}\n\nVCOS_INLINE_IMPL\nVCOS_STATUS_T vcos_mutex_lock(VCOS_MUTEX_T *latch) {\n   int rc = pthread_mutex_lock(latch);\n   vcos_assert(rc==0);\n   (void)rc;\n   return VCOS_SUCCESS;\n}\n\nVCOS_INLINE_IMPL\nvoid vcos_mutex_unlock(VCOS_MUTEX_T *latch) {\n   int rc = pthread_mutex_unlock(latch);\n   (void)rc;\n   vcos_assert(rc==0);\n}\n\nVCOS_INLINE_IMPL\nint vcos_mutex_is_locked(VCOS_MUTEX_T *m) {\n   int rc = pthread_mutex_trylock(m);\n   if (rc == 0) {\n      pthread_mutex_unlock(m);\n      /* it wasn't locked */\n      return 0;\n   }\n   else {\n      return 1; /* it was locked */\n   }\n}\n\nVCOS_INLINE_IMPL\nVCOS_STATUS_T vcos_mutex_trylock(VCOS_MUTEX_T *m) {\n   int rc = pthread_mutex_trylock(m);\n   (void)rc;\n   return (rc == 0) ? VCOS_SUCCESS : VCOS_EAGAIN;\n}\n\n#endif /* VCOS_USE_VCOS_FUTEX */\n\n/*\n * Events\n */\n\nVCOS_INLINE_IMPL\nVCOS_STATUS_T vcos_event_create(VCOS_EVENT_T *event, const char *debug_name)\n{\n   VCOS_STATUS_T status;\n\n   int rc = sem_init(&event->sem, 0, 0);\n   if (rc != 0) return vcos_pthreads_map_errno();\n\n   status = vcos_mutex_create(&event->mutex, debug_name);\n   if (status != VCOS_SUCCESS) {\n      sem_destroy(&event->sem);\n      return status;\n   }\n\n   return VCOS_SUCCESS;\n}\n\nVCOS_INLINE_IMPL\nvoid vcos_event_signal(VCOS_EVENT_T *event)\n{\n   int ok = 0;\n   int value;\n\n   if (vcos_mutex_lock(&event->mutex) != VCOS_SUCCESS)\n      goto fail_mtx;\n\n   if (sem_getvalue(&event->sem, &value) != 0)\n      goto fail_sem;\n\n   if (value == 0)\n      if (sem_post(&event->sem) != 0)\n         goto fail_sem;\n\n   ok = 1;\nfail_sem:\n   vcos_mutex_unlock(&event->mutex);\nfail_mtx:\n   if (!ok)\n      vcos_assert(ok);\n}\n\nVCOS_INLINE_IMPL\nVCOS_STATUS_T vcos_event_wait(VCOS_EVENT_T *event)\n{\n   int ret;\n   /* gdb causes sem_wait() to EINTR when a breakpoint is hit, retry here */\n   while ((ret = sem_wait(&event->sem)) == -1 && errno == EINTR)\n      continue;\n   vcos_assert(ret==0);\n   return ret == 0 ? VCOS_SUCCESS : (VCOS_STATUS_T)errno;\n}\n\nVCOS_INLINE_IMPL\nVCOS_STATUS_T vcos_event_try(VCOS_EVENT_T *event)\n{\n   int ret;\n   while ((ret = sem_trywait(&event->sem)) == -1 && errno == EINTR)\n      continue;\n\n   if (ret == -1 && errno == EAGAIN)\n      return VCOS_EAGAIN;\n   else\n      return VCOS_SUCCESS;\n}\n\nVCOS_INLINE_IMPL\nvoid vcos_event_delete(VCOS_EVENT_T *event)\n{\n   int rc = sem_destroy(&event->sem);\n   vcos_assert(rc != -1);\n   (void)rc;\n\n   vcos_mutex_delete(&event->mutex);\n}\n\nVCOS_INLINE_IMPL\nVCOS_UNSIGNED vcos_process_id_current(void) {\n   return (VCOS_UNSIGNED) getpid();\n}\n\nVCOS_INLINE_IMPL\nint vcos_strcasecmp(const char *s1, const char *s2) {\n   return strcasecmp(s1,s2);\n}\n\nVCOS_INLINE_IMPL\nint vcos_strncasecmp(const char *s1, const char *s2, size_t n) {\n   return strncasecmp(s1,s2,n);\n}\n\nVCOS_INLINE_IMPL\nint vcos_in_interrupt(void) {\n   return 0;\n}\n\n/* For support event groups - per thread semaphore */\nVCOS_INLINE_IMPL\nvoid _vcos_thread_sem_wait(void) {\n   VCOS_THREAD_T *t = vcos_thread_current();\n   vcos_semaphore_wait(&t->suspend);\n}\n\nVCOS_INLINE_IMPL\nvoid _vcos_thread_sem_post(VCOS_THREAD_T *target) {\n   vcos_semaphore_post(&target->suspend);\n}\n\nVCOS_INLINE_IMPL\nVCOS_STATUS_T vcos_tls_create(VCOS_TLS_KEY_T *key) {\n   int st = pthread_key_create(key, NULL);\n   return st == 0 ? VCOS_SUCCESS: VCOS_ENOMEM;\n}\n\nVCOS_INLINE_IMPL\nvoid vcos_tls_delete(VCOS_TLS_KEY_T tls) {\n   pthread_key_delete(tls);\n}\n\nVCOS_INLINE_IMPL\nVCOS_STATUS_T vcos_tls_set(VCOS_TLS_KEY_T tls, void *v) {\n   pthread_setspecific(tls, v);\n   return VCOS_SUCCESS;\n}\n\nVCOS_INLINE_IMPL\nvoid *vcos_tls_get(VCOS_TLS_KEY_T tls) {\n   return pthread_getspecific(tls);\n}\n\n/***********************************************************\n *\n * Timers\n *\n ***********************************************************/\n\n//Other platforms can call compatible OS implementations directly\n//from inline functions with minimal overhead.\n//Pthreads needs a little bit more, so call functions\n//in vcos_pthreads.c from the inline functions.\nVCOS_STATUS_T vcos_pthreads_timer_create(VCOS_TIMER_T *timer,\n                                const char *name,\n                                void (*expiration_routine)(void *context),\n                                void *context);\nvoid vcos_pthreads_timer_set(VCOS_TIMER_T *timer, VCOS_UNSIGNED delay_ms);\nvoid vcos_pthreads_timer_cancel(VCOS_TIMER_T *timer);\nvoid vcos_pthreads_timer_reset(VCOS_TIMER_T *timer, VCOS_UNSIGNED delay_ms);\nvoid vcos_pthreads_timer_delete(VCOS_TIMER_T *timer);\n\n/** Create a timer.\n  *\n  * Note that we just cast the expiry function - this assumes that UNSIGNED\n  * and VOID* are the same size.\n  */\n\n\nVCOS_INLINE_IMPL\nVCOS_STATUS_T vcos_timer_create(VCOS_TIMER_T *timer,\n                                const char *name,\n                                void (*expiration_routine)(void *context),\n                                void *context) {\n   return vcos_pthreads_timer_create(timer, name, expiration_routine, context);\n}\n\nVCOS_INLINE_IMPL\nvoid vcos_timer_set(VCOS_TIMER_T *timer, VCOS_UNSIGNED delay_ms) {\n   return vcos_pthreads_timer_set(timer, delay_ms);\n}\n\nVCOS_INLINE_IMPL\nvoid vcos_timer_cancel(VCOS_TIMER_T *timer) {\n   return vcos_pthreads_timer_cancel(timer);\n}\n\nVCOS_INLINE_IMPL\nvoid vcos_timer_reset(VCOS_TIMER_T *timer, VCOS_UNSIGNED delay) {\n   vcos_timer_set(timer, delay);\n}\n\nVCOS_INLINE_IMPL\nvoid vcos_timer_delete(VCOS_TIMER_T *timer) {\n   vcos_pthreads_timer_delete(timer);\n}\n\n#if VCOS_HAVE_ATOMIC_FLAGS\n\n/*\n * Atomic flags\n */\n\n/* TODO implement properly... */\n\nVCOS_INLINE_IMPL\nVCOS_STATUS_T vcos_atomic_flags_create(VCOS_ATOMIC_FLAGS_T *atomic_flags)\n{\n   atomic_flags->flags = 0;\n   return vcos_mutex_create(&atomic_flags->mutex, \"VCOS_ATOMIC_FLAGS_T\");\n}\n\nVCOS_INLINE_IMPL\nvoid vcos_atomic_flags_or(VCOS_ATOMIC_FLAGS_T *atomic_flags, uint32_t flags)\n{\n   vcos_mutex_lock(&atomic_flags->mutex);\n   atomic_flags->flags |= flags;\n   vcos_mutex_unlock(&atomic_flags->mutex);\n}\n\nVCOS_INLINE_IMPL\nuint32_t vcos_atomic_flags_get_and_clear(VCOS_ATOMIC_FLAGS_T *atomic_flags)\n{\n   uint32_t flags;\n   vcos_mutex_lock(&atomic_flags->mutex);\n   flags = atomic_flags->flags;\n   atomic_flags->flags = 0;\n   vcos_mutex_unlock(&atomic_flags->mutex);\n   return flags;\n}\n\nVCOS_INLINE_IMPL\nvoid vcos_atomic_flags_delete(VCOS_ATOMIC_FLAGS_T *atomic_flags)\n{\n   vcos_mutex_delete(&atomic_flags->mutex);\n}\n\n#endif\n\n#if defined(linux) || defined(_HAVE_SBRK)\n\n/* Returns invalid result, do not use */\n\nVCOS_INLINE_IMPL\nunsigned long VCOS_DEPRECATED(\"returns invalid result\") vcos_get_free_mem(void) {\n   return 0;\n}\n\n#endif\n\n#ifdef VCOS_PTHREADS_WANT_HISR_EMULATION\nVCOS_STATUS_T vcos_legacy_hisr_create(VCOS_HISR_T *hisr, const char *name,\n                                      void (*entry)(void),\n                                      VCOS_UNSIGNED pri,\n                                      void *stack, VCOS_UNSIGNED stack_size);\n\nvoid vcos_legacy_hisr_activate(VCOS_HISR_T *hisr);\n\nvoid vcos_legacy_hisr_delete(VCOS_HISR_T *hisr);\n\n#endif\n\n#undef VCOS_ASSERT_LOGGING_DISABLE\n#define VCOS_ASSERT_LOGGING_DISABLE 0\n\n#endif /* VCOS_INLINE_BODIES */\n\n#define  vcos_log_platform_init()               _vcos_log_platform_init()\nVCOSPRE_ void VCOSPOST_             _vcos_log_platform_init(void);\n\nVCOS_INLINE_DECL void _vcos_thread_sem_wait(void);\nVCOS_INLINE_DECL void _vcos_thread_sem_post(VCOS_THREAD_T *);\n\n#define VCOS_APPLICATION_ARGC          vcos_get_argc()\n#define VCOS_APPLICATION_ARGV          vcos_get_argv()\n\n#include \"interface/vcos/generic/vcos_generic_reentrant_mtx.h\"\n#include \"interface/vcos/generic/vcos_generic_named_sem.h\"\n#include \"interface/vcos/generic/vcos_generic_quickslow_mutex.h\"\n#include \"interface/vcos/generic/vcos_common.h\"\n\n#define _VCOS_LOG_LEVEL() getenv(\"VC_LOGLEVEL\")\n\nVCOS_STATIC_INLINE\nchar *vcos_strdup(const char *str)\n{\n   size_t len = strlen(str) + 1;\n   void *p = malloc(len);\n\n   if (p == NULL)\n      return NULL;\n\n   return (char *)memcpy(p, str, len);\n}\n\ntypedef void (*VCOS_ISR_HANDLER_T)(VCOS_UNSIGNED vecnum);\n\n#define VCOS_DL_LAZY RTLD_LAZY\n#define VCOS_DL_NOW  RTLD_NOW\n#define VCOS_DL_LOCAL  RTLD_LOCAL\n#define VCOS_DL_GLOBAL  RTLD_GLOBAL\n\n#ifdef __cplusplus\n}\n#endif\n#endif /* VCOS_PLATFORM_H */\n\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vcos/pthreads/vcos_platform_types.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n/*=============================================================================\nVideoCore OS Abstraction Layer - platform-specific types and defines\n=============================================================================*/\n\n#ifndef VCOS_PLATFORM_TYPES_H\n#define VCOS_PLATFORM_TYPES_H\n\n#include \"interface/vcos/vcos_inttypes.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#define VCOSPRE_ extern\n#define VCOSPOST_\n\n#if defined(__GNUC__) && (( __GNUC__ > 2 ) || (( __GNUC__ == 2 ) && ( __GNUC_MINOR__ >= 3 )))\n#define VCOS_FORMAT_ATTR_(ARCHETYPE, STRING_INDEX, FIRST_TO_CHECK)  __attribute__ ((format (ARCHETYPE, STRING_INDEX, FIRST_TO_CHECK)))\n#else\n#define VCOS_FORMAT_ATTR_(ARCHETYPE, STRING_INDEX, FIRST_TO_CHECK)\n#endif\n\n#if defined(__linux__) && !defined(NDEBUG) && defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))\n   #define VCOS_BKPT ({ __asm volatile (\"int3\":::\"memory\"); })\n#endif\n/*#define VCOS_BKPT vcos_abort() */\n\n#define VCOS_ASSERT_LOGGING         1\n#define VCOS_ASSERT_LOGGING_DISABLE 0\n\nextern void\nvcos_pthreads_logging_assert(const char *file, const char *func, unsigned int line, const char *fmt, ...);\n\n#define VCOS_ASSERT_MSG(...) ((VCOS_ASSERT_LOGGING && !VCOS_ASSERT_LOGGING_DISABLE) ? vcos_pthreads_logging_assert(__FILE__, __func__, __LINE__, __VA_ARGS__) : (void)0)\n\n#define VCOS_INLINE_BODIES\n#define VCOS_INLINE_DECL extern __inline__\n#define VCOS_INLINE_IMPL static __inline__\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vcos/user_nodefs.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n#ifndef USER_NODEFS_H\n#define USER_NODEFS_H\n\n/*\n * This tells coverity not to expand the assert macro, so it still sees the\n * asserts in the code, even in release builds (we currently run coverity on\n * our release builds). Unfortunately MetaWare won't compile it, even though\n * __COVERITY__ isn't defined, so we put this in its own header.\n *\n * FIXME: This belongs in the Coverity config (in a file called\n * config/user_nodefs.h)\n */\n#nodef assert\n\n/*\n * So we need to declare the function now that it isn't a macro any more. It's\n * already built into coverity that assert is a \"killpath\".\n */\nextern void assert(int cond);\n\n#endif /* USER_NODEFS_H */\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vcos/vcos.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n/*=============================================================================\nVideoCore OS Abstraction Layer - public header file\n=============================================================================*/\n\n/**\n  * \\mainpage OS Abstraction Layer\n  *\n  * \\section intro Introduction\n  *\n  * This abstraction layer is here to allow the underlying OS to be easily changed (e.g. from\n  * Nucleus to ThreadX) and to aid in porting host applications to new targets.\n  *\n  * \\subsection error Error handling\n  *\n  * Wherever possible, VCOS functions assert internally and return void. The only exceptions\n  * are creation functions (which might fail due to lack of resources) and functions that\n  * might timeout or fail due to lack of space. Errors that might be reported by the underlying\n  * OS API (e.g. invalid mutex) are treated as a programming error, and are merely asserted on.\n  *\n  * \\section thread_synch Threads and synchronisation\n  *\n  * \\subsection thread Threads\n  *\n  * The thread API is somewhat different to that found in Nucleus. In particular, threads\n  * cannot just be destroyed at arbitrary times and nor can they merely exit. This is so\n  * that the same API can be implemented across all interesting platforms without too much\n  * difficulty. See vcos_thread.h for details. Thread attributes are configured via\n  * the VCOS_THREAD_ATTR_T structure, found in vcos_thread_attr.h.\n  *\n  * \\subsection sema Semaphores\n  *\n  * Counted semaphores (c.f. Nucleus NU_SEMAPHORE) are created with VCOS_SEMAPHORE_T.\n  * Under ThreadX on VideoCore, semaphores are implemented using VideoCore spinlocks, and\n  * so are quite a lot faster than ordinary ThreadX semaphores. See vcos_semaphore.h.\n  *\n  * \\subsection mtx Mutexes\n  *\n  * Mutexes are used for locking. Attempts to take a mutex twice, or to unlock it\n  * in a different thread to the one in which it was locked should be expected to fail.\n  * Mutexes are not re-entrant (see vcos_reentrant_mutex.h for a slightly slower\n  * re-entrant mutex).\n  *\n  * \\subsection evflags Event flags\n  *\n  * Event flags (the ThreadX name - also known as event groups under Nucleus) provide\n  * 32 flags which can be waited on by multiple clients, and signalled by multiple clients.\n  * A timeout can be specified. See vcos_event_flags.h. An alternative to this is the\n  * VCOS_EVENT_T (see vcos_event.h) which is akin to the Win32 auto-reset event, or a\n  * saturating counted semaphore.\n  *\n  * \\subsection event Events\n  *\n  * A VCOS_EVENT_T is a bit like a saturating semaphore. No matter how many times it\n  * is signalled, the waiter will only wake up once. See vcos_event.h. You might think this\n  * is useful if you suspect that the cost of reading the semaphore count (perhaps via a\n  * system call) is expensive on your platform.\n  *\n  * \\subsection tls Thread local storage\n  *\n  * Thread local storage is supported using vcos_tls.h. This is emulated on Nucleus\n  * and ThreadX.\n  *\n  * \\section int Interrupts\n  *\n  * The legacy LISR/HISR scheme found in Nucleus is supported via the legacy ISR API,\n  * which is also supported on ThreadX. New code should avoid this, and old code should\n  * be migrated away from it, since it is slow. See vcos_legacy_isr.h.\n  *\n  * Registering an interrupt handler, and disabling/restoring interrupts, is handled\n  * using the functions in vcos_isr.h.\n  *\n  */\n\n/**\n  * \\file vcos.h\n  *\n  * This is the top level header file. Clients include this. It pulls in the platform-specific\n  * header file (vcos_platform.h) together with header files defining the expected APIs, such\n  * as vcos_mutex.h, vcos_semaphore.h, etc. It is also possible to include these header files\n  * directly.\n  *\n  */\n\n#ifndef VCOS_H\n#define VCOS_H\n\n#include \"interface/vcos/vcos_assert.h\"\n#include \"vcos_types.h\"\n\n#if defined(__unix__) && !defined(__ANDROID__)\n#include \"interface/vcos/pthreads/vcos_platform.h\"\n#else\n#include \"vcos_platform.h\"\n#endif\n\n#ifndef VCOS_INIT_H\n#include \"interface/vcos/vcos_init.h\"\n#endif\n\n#ifndef VCOS_SEMAPHORE_H\n#include \"interface/vcos/vcos_semaphore.h\"\n#endif\n\n#ifndef VCOS_THREAD_H\n#include \"interface/vcos/vcos_thread.h\"\n#endif\n\n#ifndef VCOS_MUTEX_H\n#include \"interface/vcos/vcos_mutex.h\"\n#endif\n\n#ifndef VCOS_MEM_H\n#include \"interface/vcos/vcos_mem.h\"\n#endif\n\n#ifndef VCOS_LOGGING_H\n#include \"interface/vcos/vcos_logging.h\"\n#endif\n\n#ifndef VCOS_STRING_H\n#include \"interface/vcos/vcos_string.h\"\n#endif\n\n#ifndef VCOS_EVENT_H\n#include \"interface/vcos/vcos_event.h\"\n#endif\n\n#ifndef VCOS_THREAD_ATTR_H\n#include \"interface/vcos/vcos_thread_attr.h\"\n#endif\n\n#ifndef VCOS_TLS_H\n#include \"interface/vcos/vcos_tls.h\"\n#endif\n\n#ifndef VCOS_REENTRANT_MUTEX_H\n#include \"interface/vcos/vcos_reentrant_mutex.h\"\n#endif\n\n#ifndef VCOS_NAMED_SEMAPHORE_H\n#include \"interface/vcos/vcos_named_semaphore.h\"\n#endif\n\n#ifndef VCOS_QUICKSLOW_MUTEX_H\n#include \"interface/vcos/vcos_quickslow_mutex.h\"\n#endif\n\n/* Headers with predicates */\n\n#if VCOS_HAVE_EVENT_FLAGS\n#include \"interface/vcos/vcos_event_flags.h\"\n#endif\n\n#if VCOS_HAVE_QUEUE\n#include \"interface/vcos/vcos_queue.h\"\n#endif\n\n#if VCOS_HAVE_LEGACY_ISR\n#include \"interface/vcos/vcos_legacy_isr.h\"\n#endif\n\n#if VCOS_HAVE_TIMER\n#include \"interface/vcos/vcos_timer.h\"\n#endif\n\n#if VCOS_HAVE_MEMPOOL\n#include \"interface/vcos/vcos_mempool.h\"\n#endif\n\n#if VCOS_HAVE_ISR\n#include \"interface/vcos/vcos_isr.h\"\n#endif\n\n#if VCOS_HAVE_ATOMIC_FLAGS\n#include \"interface/vcos/vcos_atomic_flags.h\"\n#endif\n\n#if VCOS_HAVE_ONCE\n#include \"interface/vcos/vcos_once.h\"\n#endif\n\n#if VCOS_HAVE_BLOCK_POOL\n#include \"interface/vcos/vcos_blockpool.h\"\n#endif\n\n#if VCOS_HAVE_FILE\n#include \"interface/vcos/vcos_file.h\"\n#endif\n\n#if VCOS_HAVE_CFG\n#include \"interface/vcos/vcos_cfg.h\"\n#endif\n\n#if VCOS_HAVE_CMD\n#include \"interface/vcos/vcos_cmd.h\"\n#endif\n\n#endif /* VCOS_H */\n\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vcos/vcos_assert.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n/*=============================================================================\nVideoCore OS Abstraction Layer - Assertion and error-handling macros.\n=============================================================================*/\n\n\n#ifndef VCOS_ASSERT_H\n#define VCOS_ASSERT_H\n\n/*\n * Macro:\n *    vcos_assert(cond)\n *    vcos_assert_msg(cond, fmt, ...)\n * Use:\n *    Detecting programming errors by ensuring that assumptions are correct.\n * On failure:\n *    Performs a platform-dependent \"breakpoint\", usually with an assert-style\n *    message. The '_msg' variant expects a printf-style format string and\n *    parameters.\n *    If a failure is detected, the code should be fixed and rebuilt.\n * In release builds:\n *    Generates no code, i.e. does not evaluate 'cond'.\n * Returns:\n *    Nothing.\n *\n * Macro:\n *    vcos_demand(cond)\n *    vcos_demand_msg(cond, fmt, ...)\n * Use:\n *    Detecting fatal system errors that require a reboot.\n * On failure:\n *    Performs a platform-dependent \"breakpoint\", usually with an assert-style\n *    message, then calls vcos_abort (see below).\n * In release builds:\n *    Calls vcos_abort() if 'cond' is false.\n * Returns:\n *    Nothing (never, on failure).\n *\n * Macro:\n *    vcos_verify(cond)\n *    vcos_verify_msg(cond, fmt, ...)\n * Use:\n *    Detecting run-time errors and interesting conditions, normally within an\n *    'if' statement to catch the failures, i.e.\n *       if (!vcos_verify(cond)) handle_error();\n * On failure:\n *    Generates a message and optionally stops at a platform-dependent\n *    \"breakpoint\" (usually disabled). See vcos_verify_bkpts_enable below.\n * In release builds:\n *    Just evaluates and returns 'cond'.\n * Returns:\n *    Non-zero if 'cond' is true, otherwise zero.\n *\n * Macro:\n *    vcos_static_assert(cond)\n * Use:\n *    Detecting compile-time errors.\n * On failure:\n *    Generates a compiler error.\n * In release builds:\n *    Generates a compiler error.\n *\n * Function:\n *    void vcos_abort(void)\n * Use:\n *    Invokes the fatal error handling mechanism, alerting the host where\n *    applicable.\n * Returns:\n *    Never.\n *\n * Macro:\n *    VCOS_VERIFY_BKPTS\n * Use:\n *    Define in a module (before including vcos.h) to specify an alternative\n *    flag to control breakpoints on vcos_verify() failures.\n * Returns:\n *    Non-zero values enable breakpoints.\n *\n * Function:\n *    int vcos_verify_bkpts_enable(int enable);\n * Use:\n *    Sets the global flag controlling breakpoints on vcos_verify failures,\n *    enabling the breakpoints iff 'enable' is non-zero.\n * Returns:\n *    The previous state of the flag.\n *\n * Function:\n *    int vcos_verify_bkpts_enabled(void);\n * Use:\n *    Queries the state of the global flag enabling breakpoints on vcos_verify\n *    failures.\n * Returns:\n *    The current state of the flag.\n *\n * Examples:\n *\n * int my_breakpoint_enable_flag = 1;\n *\n * #define VCOS_VERIFY_BKPTS my_breakpoint_enable_flag\n *\n * #include \"interface/vcos/vcos.h\"\n *\n * vcos_static_assert((sizeof(object) % 32) == 0);\n *\n * // ...\n *\n *    vcos_assert_msg(postcondition_is_true, \"Coding error\");\n *\n *    if (!vcos_verify_msg(buf, \"Buffer allocation failed (%d bytes)\", size))\n *    {\n *       // Tidy up\n *       // ...\n *       return OUT_OF_MEMORY;\n *    }\n *\n *    vcos_demand(*p++==GUARDWORDHEAP);\n */\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#include \"interface/vcos/vcos_types.h\"\n\n#ifdef __COVERITY__\n#include \"interface/vcos/user_nodefs.h\"\n\nextern void __coverity_panic__(void);\n#undef VCOS_ASSERT_BKPT\n#define VCOS_ASSERT_BKPT __coverity_panic__()\n#endif\n\n/*\n * ANDROID should NOT be defined for files built for Videocore, but currently it\n * is. FIXME When that's fixed, remove the __VIDEOCORE__ band-aid.\n */\n#if (defined(ANDROID) && !defined(__VIDEOCORE__))\n#  include \"assert.h\"\n#  define vcos_assert assert\n#endif\n\n#ifndef VCOS_VERIFY_BKPTS\n#define VCOS_VERIFY_BKPTS vcos_verify_bkpts_enabled()\n#endif\n\n#ifndef VCOS_BKPT\n#if defined(__VIDEOCORE__) && !defined(VCOS_ASSERT_NO_BKPTS)\n#define VCOS_BKPT _bkpt()\n#else\n#define VCOS_BKPT (void )0\n#endif\n#endif\n\n#ifndef VCOS_ASSERT_BKPT\n#define VCOS_ASSERT_BKPT VCOS_BKPT\n#endif\n\n#ifndef VCOS_VERIFY_BKPT\n#define VCOS_VERIFY_BKPT (VCOS_VERIFY_BKPTS ? VCOS_BKPT : (void)0)\n#endif\n\nVCOSPRE_ int VCOSPOST_ vcos_verify_bkpts_enabled(void);\nVCOSPRE_ int VCOSPOST_ vcos_verify_bkpts_enable(int enable);\nVCOSPRE_ void VCOSPOST_ vcos_abort(void);\n\n#ifndef VCOS_ASSERT_MSG\n#ifdef LOGGING\nextern void logging_assert(const char *file, const char *func, int line, const char *format, ...);\nextern void logging_assert_dump(void);\n#define VCOS_ASSERT_MSG(...) ((VCOS_ASSERT_LOGGING && !VCOS_ASSERT_LOGGING_DISABLE) ? logging_assert_dump(), logging_assert(__FILE__, __func__, __LINE__, __VA_ARGS__) : (void)0)\n#else\n#define VCOS_ASSERT_MSG(...) ((void)0)\n#endif\n#endif\n\n#ifndef VCOS_VERIFY_MSG\n#define VCOS_VERIFY_MSG(...) VCOS_ASSERT_MSG(__VA_ARGS__)\n#endif\n\n#ifndef VCOS_ASSERT_LOGGING\n#define VCOS_ASSERT_LOGGING 0\n#endif\n\n#ifndef VCOS_ASSERT_LOGGING_DISABLE\n#define VCOS_ASSERT_LOGGING_DISABLE 0\n#endif\n\n#if !defined(NDEBUG) || defined(VCOS_RELEASE_ASSERTS)\n#define VCOS_ASSERT_ENABLED 1\n#define VCOS_VERIFY_ENABLED 1\n#else\n#define VCOS_ASSERT_ENABLED 0\n#define VCOS_VERIFY_ENABLED 0\n#endif\n\n#define VCOS_DEMAND_ENABLED 1\n\n#if VCOS_ASSERT_ENABLED\n\n#ifndef vcos_assert\n#define vcos_assert(cond) \\\n   ( (cond) ? (void)0 : (VCOS_ASSERT_BKPT, VCOS_ASSERT_MSG(\"%s\", #cond)) )\n#endif\n\n#ifndef vcos_assert_msg\n#define vcos_assert_msg(cond, ...) \\\n   ( (cond) ? (void)0 : (VCOS_ASSERT_BKPT, VCOS_ASSERT_MSG(__VA_ARGS__)) )\n#endif\n\n#else  /* VCOS_ASSERT_ENABLED */\n\n#ifndef vcos_assert\n#define vcos_assert(cond) (void)0\n#endif\n\n#ifndef vcos_assert_msg\n#define vcos_assert_msg(cond, ...) (void)0\n#endif\n\n#endif /* VCOS_ASSERT_ENABLED */\n\n\n#if VCOS_DEMAND_ENABLED\n\n#ifndef vcos_demand\n#define vcos_demand(cond) \\\n   ( (cond) ? (void)0 : (VCOS_ASSERT_BKPT, VCOS_ASSERT_MSG(\"%s\", #cond), vcos_abort()) )\n#endif\n\n#ifndef vcos_demand_msg\n#define vcos_demand_msg(cond, ...) \\\n   ( (cond) ? (void)0 : (VCOS_ASSERT_BKPT, VCOS_ASSERT_MSG(__VA_ARGS__), vcos_abort()) )\n#endif\n\n#else  /* VCOS_DEMAND_ENABLED */\n\n#ifndef vcos_demand\n#define vcos_demand(cond) \\\n   ( (cond) ? (void)0 : vcos_abort() )\n#endif\n\n#ifndef vcos_demand_msg\n#define vcos_demand_msg(cond, ...) \\\n   ( (cond) ? (void)0 : vcos_abort() )\n#endif\n\n#endif /* VCOS_DEMAND_ENABLED */\n\n\n#if VCOS_VERIFY_ENABLED\n\n#ifndef vcos_verify\n#define vcos_verify(cond) \\\n   ( (cond) ? 1 : (VCOS_VERIFY_MSG(\"%s\", #cond), VCOS_VERIFY_BKPT, 0) )\n#endif\n\n#ifndef vcos_verify_msg\n#define vcos_verify_msg(cond, ...) \\\n   ( (cond) ? 1 : (VCOS_VERIFY_MSG(__VA_ARGS__), VCOS_VERIFY_BKPT, 0) )\n#endif\n\n#else /* VCOS_VERIFY_ENABLED */\n\n#ifndef vcos_verify\n#define vcos_verify(cond) (cond)\n#endif\n\n#ifndef vcos_verify_msg\n#define vcos_verify_msg(cond, ...) (cond)\n#endif\n\n#endif /* VCOS_VERIFY_ENABLED */\n\n\n#ifndef vcos_static_assert\n#if defined(__GNUC__)\n#define vcos_static_assert(cond) __attribute__((unused)) extern int vcos_static_assert[(cond)?1:-1]\n#else\n#define vcos_static_assert(cond) extern int vcos_static_assert[(cond)?1:-1]\n#endif\n#endif\n\n#ifndef vc_assert\n#define vc_assert(cond) vcos_assert(cond)\n#endif\n\n#define vcos_unreachable() vcos_assert(0)\n#define vcos_not_impl() vcos_assert(0)\n\n/** Print out a backtrace, on supported platforms.\n  */\nextern void vcos_backtrace_self(void);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* VCOS_ASSERT_H */\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vcos/vcos_atomic_flags.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n/*=============================================================================\nVideoCore OS Abstraction Layer - public header file\n=============================================================================*/\n\n#ifndef VCOS_ATOMIC_FLAGS_H\n#define VCOS_ATOMIC_FLAGS_H\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#include \"interface/vcos/vcos_types.h\"\n#include \"vcos.h\"\n\n/**\n * \\file vcos_atomic_flags.h\n *\n * Defines atomic flags API.\n *\n * 32 flags. Atomic \"or\" and \"get and clear\" operations\n */\n\n/**\n * Create an atomic flags instance.\n *\n * @param atomic_flags Pointer to atomic flags instance, filled in on return\n *\n * @return VCOS_SUCCESS if succeeded.\n */\nVCOS_INLINE_DECL\nVCOS_STATUS_T vcos_atomic_flags_create(VCOS_ATOMIC_FLAGS_T *atomic_flags);\n\n/**\n * Atomically set the specified flags.\n *\n * @param atomic_flags Instance to set flags on\n * @param flags        Mask of flags to set\n */\nVCOS_INLINE_DECL\nvoid vcos_atomic_flags_or(VCOS_ATOMIC_FLAGS_T *atomic_flags, uint32_t flags);\n\n/**\n * Retrieve the current flags and then clear them. The entire operation is\n * atomic.\n *\n * @param atomic_flags Instance to get/clear flags from/on\n *\n * @return Mask of flags which were set (and we cleared)\n */\nVCOS_INLINE_DECL\nuint32_t vcos_atomic_flags_get_and_clear(VCOS_ATOMIC_FLAGS_T *atomic_flags);\n\n/**\n * Delete an atomic flags instance.\n *\n * @param atomic_flags Instance to delete\n */\nVCOS_INLINE_DECL\nvoid vcos_atomic_flags_delete(VCOS_ATOMIC_FLAGS_T *atomic_flags);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vcos/vcos_attr.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n/*=============================================================================\nVideoCore OS Abstraction Layer - compiler-specific attributes\n=============================================================================*/\n\n#ifndef VCOS_ATTR_H\n#define VCOS_ATTR_H\n\n/**\n * Type attribute indicating the enum should be stored in as few bytes as\n * possible. MetaWare does this by default, so the attribute is useful when\n * structs need to be portable to GCC too.\n *\n * MSVC doesn't support VCOS_ENUM_PACKED, so code that needs to be portable\n * across all platforms but wants the type-safety and debug-info benefits\n * of enum types when possible, should do:\n *\n *    typedef enum VCOS_ENUM_PACKED { a = 0, b = 0xffff } EXAMPLE_T;\n *    struct foo {\n *       int bar;\n *       #if VCOS_HAS_ENUM_PACKED\n *       EXAMPLE_T baz;\n *       #else\n *       uint16_t baz;\n *       #endif\n *    };\n */\n\n#if defined(__VECTORC__)\n# define VCOS_ENUM_PACKED\n# define VCOS_HAS_ENUM_PACKED 0\n#elif defined(__GNUC__)\n# define VCOS_ENUM_PACKED  __attribute__ ((packed))\n# define VCOS_HAS_ENUM_PACKED 1\n#elif defined(__HIGHC__)\n# define VCOS_ENUM_PACKED /* packed enums are default on Metaware */\n# define VCOS_HAS_ENUM_PACKED 1\n#else\n# define VCOS_ENUM_PACKED\n# define VCOS_HAS_ENUM_PACKED 0\n#endif\n\n/** Variable attribute indicating the variable must be emitted even if it appears unused. */\n#if defined(__GNUC__) || defined(__HIGHC__)\n# define VCOS_ATTR_USED  __attribute__ ((used))\n#else\n# define VCOS_ATTR_USED\n#endif\n\n/** Variable attribute indicating the compiler should not warn if the variable is unused. */\n#if defined(__GNUC__) || defined(__HIGHC__)\n# define VCOS_ATTR_POSSIBLY_UNUSED  __attribute__ ((unused))\n#else\n# define VCOS_ATTR_POSSIBLY_UNUSED\n#endif\n\n/** Variable attribute requiring specific alignment.\n *\n * Use as:\n *   int VCOS_ATTR_ALIGNED(256) n;\n * or:\n *   VCOS_ATTR_ALIGNED(256) int n;\n * or if you don't want to support MSVC:\n *   int n VCOS_ATTR_ALIGNED(256);\n */\n#if defined(__GNUC__) || defined(__HIGHC__)\n# define VCOS_ATTR_ALIGNED(n)  __attribute__ ((aligned(n)))\n#elif defined(_MSC_VER)\n# define VCOS_ATTR_ALIGNED(n)  __declspec(align(n))\n#else\n/* Force a syntax error if this is used when the compiler doesn't support it,\n * instead of silently misaligning */\n# define VCOS_ATTR_ALIGNED(n) VCOS_ATTR_ALIGNED_NOT_SUPPORTED_ON_THIS_COMPILER\n#endif\n\n/** Variable attribute requiring specific ELF section.\n *\n * Use as:\n *   int n VCOS_ATTR_SECTION(\".foo\") = 1;\n *\n * A pointer like &n will have type \"VCOS_ATTR_SECTION_QUALIFIER int *\".\n */\n#if defined(__HIGHC__) || defined(__VECTORC__)\n/* hcvc requires 'far' else it'll put small objects in .sdata/.rsdata/.sbss */\n# define VCOS_ATTR_SECTION(s)  __attribute__ ((far, section(s)))\n# define VCOS_ATTR_SECTION_QUALIFIER _Far\n#elif defined(__GNUC__)\n# define VCOS_ATTR_SECTION(s)  __attribute__ ((section(s)))\n# define VCOS_ATTR_SECTION_QUALIFIER\n#else\n/* Force a syntax error if this is used when the compiler doesn't support it */\n# define VCOS_ATTR_SECTION(s) VCOS_ATTR_SECTION_NOT_SUPPORTED_ON_THIS_COMPILER\n# define VCOS_ATTR_SECTION_QUALIFIER\n#endif\n\n/** Define a function as a weak alias to another function.\n * @param ret_type     Function return type.\n * @param alias_name   Name of the alias.\n * @param param_list   Function parameter list, including the parentheses.\n * @param target_name  Target function (bare function name, not a string).\n */\n#if defined(__GNUC__) || defined(__HIGHC__)\n  /* N.B. gcc allows __attribute__ after parameter list, but hcvc seems to silently ignore it. */\n# define VCOS_WEAK_ALIAS(ret_type, alias_name, param_list, target_name) \\\n   __attribute__ ((weak, alias(#target_name))) ret_type alias_name param_list\n#else\n# define VCOS_WEAK_ALIAS(ret_type, alias, params, target)  VCOS_CASSERT(0)\n#endif\n\n/** Define a function as a weak alias to another function, specified as a string.\n * @param ret_type     Function return type.\n * @param alias_name   Name of the alias.\n * @param param_list   Function parameter list, including the parentheses.\n * @param target_name  Target function name as a string.\n * @note Prefer the use of VCOS_WEAK_ALIAS - it is likely to be more portable.\n *       Only use VCOS_WEAK_ALIAS_STR if you need to do pre-processor mangling of the target\n *       symbol.\n */\n#if defined(__GNUC__) || defined(__HIGHC__)\n  /* N.B. gcc allows __attribute__ after parameter list, but hcvc seems to silently ignore it. */\n# define VCOS_WEAK_ALIAS_STR(ret_type, alias_name, param_list, target_name) \\\n   __attribute__ ((weak, alias(target_name))) ret_type alias_name param_list\n#else\n# define VCOS_WEAK_ALIAS_STR(ret_type, alias, params, target)  VCOS_CASSERT(0)\n#endif\n\n#endif /* VCOS_ATTR_H */\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vcos/vcos_blockpool.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n/*=============================================================================\nVideoCore OS Abstraction Layer - fixed size allocator support\n=============================================================================*/\n\n#ifndef VCOS_BLOCKPOOL_H\n#define VCOS_BLOCKPOOL_H\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#include \"interface/vcos/vcos_types.h\"\n#include \"vcos.h\"\n\n/** \\file\n  *\n  * Thread safe, fixed size allocator API.\n  *\n  */\n\n/** Initialises a block pool to use already allocated (e.g. statically)\n * allocated memory.\n *\n * Different implementations will incur different overheads. Use\n * VCOS_BLOCKPOOL_SIZE(num_blocks, block_size) to calculate the number\n * of bytes required including overheads for the desired pools.\n *\n * @param pool        Pointer to pool object\n * @param num_blocks  The number of blocks required.\n * @param block_size  The size of an individual block.\n * @param start       The address of the start of the pool.\n * @param pool_size   The size of the pool in bytes.\n * @param align       Alignment for block data. Use VCOS_BLOCKPOOL_ALIGN_DEFAULT\n *                    for default word alignment.\n * @param flags       Reserved for future use.\n * @param name        Name of the pool. Used for diagnostics.\n *\n * @return VCOS_SUCCESS if the pool was created.\n */\n\nVCOS_INLINE_DECL\nVCOS_STATUS_T vcos_blockpool_init(VCOS_BLOCKPOOL_T *pool,\n      VCOS_UNSIGNED num_blocks, VCOS_UNSIGNED block_size,\n      void *start, VCOS_UNSIGNED pool_size, VCOS_UNSIGNED align,\n      VCOS_UNSIGNED flags, const char *name);\n\n/** Creates a pool of blocks of a given size within a buffer allocated on\n * the heap.\n *\n * The heap memory is freed when the block pool is destroyed by\n * calling vcos_blockpool_delete.\n *\n * @param pool        Pointer to pool object\n * @param num_blocks  The number of blocks required.\n * @param block_size  The size of an individual block.\n * @param align       Alignment for block data. Use VCOS_BLOCKPOOL_ALIGN_DEFAULT\n *                    for default word alignment.\n * @param flags       Reserved for future use.\n * @param name        Name of the pool. Used for diagnostics.\n *\n * @return VCOS_SUCCESS if the pool was created.\n */\nVCOS_INLINE_DECL\nVCOS_STATUS_T vcos_blockpool_create_on_heap(VCOS_BLOCKPOOL_T *pool,\n      VCOS_UNSIGNED num_blocks, VCOS_UNSIGNED block_size,\n      VCOS_UNSIGNED align, VCOS_UNSIGNED flags,\n      const char *name);\n\n/** Allocate a block from the pool\n *\n * @param pool Pointer to the pool to allocate from.\n * @return a pointer to the newly allocated block or NULL if no blocks were\n * available.\n */\nVCOS_INLINE_DECL\nvoid *vcos_blockpool_alloc(VCOS_BLOCKPOOL_T *pool);\n\n/** Allocate a block from the pool and zero it.\n *\n * @param pool Pointer to the pool to allocate from.\n * @return a pointer to the newly allocated block or NULL if no blocks were\n * available.\n */\nVCOS_INLINE_DECL\nvoid *vcos_blockpool_calloc(VCOS_BLOCKPOOL_T *pool);\n\n/** Returns a block to the pool.\n *\n * @param block The block to free.\n */\nVCOS_INLINE_DECL\nvoid vcos_blockpool_free(void *block);\n\n/** Queries the number of available blocks in the pool.\n * @param pool The pool to query.\n */\nVCOS_INLINE_IMPL\n   VCOS_UNSIGNED vcos_blockpool_available_count(VCOS_BLOCKPOOL_T *pool);\n\n/** Queries the number of used blocks in the pool.\n * @param pool The pool to query.\n */\nVCOS_INLINE_IMPL\n   VCOS_UNSIGNED vcos_blockpool_used_count(VCOS_BLOCKPOOL_T *pool);\n\n/** Deinitialize a memory pool.\n *\n * @param pool The pool to de-initialize.\n */\nVCOS_INLINE_DECL\nvoid vcos_blockpool_delete(VCOS_BLOCKPOOL_T *pool);\n\n/** Return an integer handle for a given allocated block. */\nVCOS_INLINE_DECL\nuint32_t vcos_blockpool_elem_to_handle(void *block);\n\n/** Convert an integer handle back into a pointer.\n  * Returns NULL if invalid. */\nVCOS_INLINE_DECL\nvoid *vcos_blockpool_elem_from_handle(VCOS_BLOCKPOOL_T *pool, uint32_t handle);\n\n/** Checks whether a pointer is an allocated block within the specified pool.\n  * Returns true if the block is valid, otherwise, false is returned. */\nVCOS_INLINE_DECL\nuint32_t vcos_blockpool_is_valid_elem(\n      VCOS_BLOCKPOOL_T *pool, const void *block);\n\n/** May be called once to allow the block pool to be extended by dynamically\n * adding subpools. The block size cannot be altered.\n *\n * @param num_extensions The number of extensions that may be created.\n *                       The maximum is (VCOS_BLOCKPOOL_MAX_SUBPOOLS - 1)\n * @param num_blocks     The number of blocks to allocate in each in each\n *                       dynamically allocated subpool.\n * @return VCOS_SUCCESS if successful.\n */\nVCOS_INLINE_DECL\n   VCOS_STATUS_T vcos_blockpool_extend(VCOS_BLOCKPOOL_T *pool,\n         VCOS_UNSIGNED num_extensions, VCOS_UNSIGNED num_blocks);\n\n#ifdef __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vcos/vcos_build_info.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\nconst char *vcos_get_build_hostname( void );\nconst char *vcos_get_build_version( void );\nconst char *vcos_get_build_time( void );\nconst char *vcos_get_build_date( void );\n\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vcos/vcos_cfg.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n#if !defined( VCOS_CFG_H )\n#define VCOS_CFG_H\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#include \"interface/vcos/vcos_types.h\"\n#include \"vcos.h\"\n\ntypedef struct opaque_vcos_cfg_buf_t    *VCOS_CFG_BUF_T;\ntypedef struct opaque_vcos_cfg_entry_t  *VCOS_CFG_ENTRY_T;\n\n/** \\file vcos_file.h\n  *\n  * API for accessing configuration/statistics information. This\n  * is loosely modelled on the linux proc entries.\n  */\n\ntypedef void (*VCOS_CFG_SHOW_FPTR)( VCOS_CFG_BUF_T buf, void *data );\ntypedef void (*VCOS_CFG_PARSE_FPTR)( VCOS_CFG_BUF_T buf, void *data );\n\n/** Create a configuration directory.\n  *\n  * @param entry        Place to store the created config entry.\n  * @param parent       Parent entry (for directory like config \n  *                     options).\n  * @param entryName    Name of the directory.\n  */\n\nVCOS_STATUS_T vcos_cfg_mkdir( VCOS_CFG_ENTRY_T *entry,\n                              VCOS_CFG_ENTRY_T *parent,\n                              const char *dirName );           \n\n/** Create a configuration entry.\n  *\n  * @param entry        Place to store the created config entry.\n  * @param parent       Parent entry (for directory like config \n  *                     options).\n  * @param entryName    Name of the configuration entry.\n  * @param showFunc     Function pointer to show configuration \n  *                     data.\n  * @param parseFunc    Function pointer to parse new data. \n  */\n\nVCOS_STATUS_T vcos_cfg_create_entry( VCOS_CFG_ENTRY_T *entry,\n                                     VCOS_CFG_ENTRY_T *parent,\n                                     const char *entryName,\n                                     VCOS_CFG_SHOW_FPTR showFunc,\n                                     VCOS_CFG_PARSE_FPTR parseFunc,\n                                     void *data );\n\n/** Determines if a configuration entry has been created or not.\n  *\n  * @param entry        Configuration entry to query.\n  */\n\nint vcos_cfg_is_entry_created( VCOS_CFG_ENTRY_T entry );\n\n/** Returns the name of a configuration entry.\n  *\n  * @param entry        Configuration entry to query.\n  */\n\nconst char *vcos_cfg_get_entry_name( VCOS_CFG_ENTRY_T entry );\n\n/** Removes a configuration entry.\n  *\n  * @param entry        Configuration entry to remove.\n  */\n\nVCOS_STATUS_T vcos_cfg_remove_entry( VCOS_CFG_ENTRY_T *entry );\n\n\n/** Writes data into a configuration buffer. Only valid inside\n  * the show function. \n  *\n  * @param buf      Buffer to write data into.\n  * @param fmt      printf style format string. \n  */\n\nvoid vcos_cfg_buf_printf( VCOS_CFG_BUF_T buf, const char *fmt, ... );\n\n/** Retrieves a null terminated string of the data associated\n  * with the buffer. Only valid inside the parse function.\n  *\n  * @param buf      Buffer to get data from.\n  * @param fmt      printf style format string. \n  */\n\nchar *vcos_cfg_buf_get_str( VCOS_CFG_BUF_T buf );\n\nvoid *vcos_cfg_get_proc_entry( VCOS_CFG_ENTRY_T entry );\n\n#ifdef __cplusplus\n}\n#endif\n#endif\n\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vcos/vcos_cmd.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n#if !defined( VCOS_CMD_H )\n#define VCOS_CMD_H\n\n/* ---- Include Files ----------------------------------------------------- */\n\n#ifndef VCOS_H\n#include \"interface/vcos/vcos.h\"\n#endif\n#include \"interface/vcos/vcos_stdint.h\"\n\n\n/* ---- Constants and Types ---------------------------------------------- */\n\nstruct VCOS_CMD_S;\ntypedef struct VCOS_CMD_S VCOS_CMD_T;\n\ntypedef struct\n{\n    int         argc;           /* Number of arguments (includes the command/sub-command) */\n    char      **argv;           /* Array of arguments */\n    char      **argv_orig;      /* Original array of arguments */\n\n    VCOS_CMD_T *cmd_entry;\n    VCOS_CMD_T *cmd_parent_entry;\n\n    int         use_log;        /* Output being logged? */\n    size_t      result_size;    /* Size of result buffer. */\n    char       *result_ptr;     /* Next place to put output. */\n    char       *result_buf;     /* Start of the buffer. */\n\n} VCOS_CMD_PARAM_T;\n\ntypedef VCOS_STATUS_T (*VCOS_CMD_FUNC_T)( VCOS_CMD_PARAM_T *param );\n\nstruct VCOS_CMD_S\n{\n    const char         *name;\n    const char         *args;\n    VCOS_CMD_FUNC_T     cmd_fn;\n    VCOS_CMD_T         *sub_cmd_entry;\n    const char         *descr;\n\n};\n\n/* ---- Variable Externs ------------------------------------------------- */\n\n/* ---- Function Prototypes ---------------------------------------------- */\n\n/*\n * Common printing routine for generating command output.\n */\nVCOSPRE_ void VCOSPOST_ vcos_cmd_error( VCOS_CMD_PARAM_T *param, const char *fmt, ... ) VCOS_FORMAT_ATTR_(printf, 2, 3);\nVCOSPRE_ void VCOSPOST_ vcos_cmd_printf( VCOS_CMD_PARAM_T *param, const char *fmt, ... ) VCOS_FORMAT_ATTR_(printf, 2, 3);\nVCOSPRE_ void VCOSPOST_ vcos_cmd_vprintf( VCOS_CMD_PARAM_T *param, const char *fmt, va_list args ) VCOS_FORMAT_ATTR_(printf, 2, 0);\n\n/*\n * Cause vcos_cmd_error, printf and vprintf to always log to the provided\n * category. When this call is made, the results buffer passed into\n * vcos_cmd_execute is used as a line buffer and does not need to be\n * output by the caller.\n */\nstruct VCOS_LOG_CAT_T;\nVCOSPRE_ void VCOSPOST_ vcos_cmd_always_log_output( struct VCOS_LOG_CAT_T *log_category );\n\n/*\n * Prints command usage for the current command.\n */\nVCOSPRE_ void VCOSPOST_ vcos_cmd_usage( VCOS_CMD_PARAM_T *param );\n\n/*\n * Register commands to be processed\n */\nVCOSPRE_ VCOS_STATUS_T VCOSPOST_ vcos_cmd_register( VCOS_CMD_T *cmd_entry );\n\n/*\n * Registers multiple commands to be processed. The array should\n * be terminated by an entry with all zeros.\n */\nVCOSPRE_ VCOS_STATUS_T VCOSPOST_ vcos_cmd_register_multiple( VCOS_CMD_T *cmd_entry );\n\n/*\n * Executes a command based on a command line.\n */\nVCOSPRE_ VCOS_STATUS_T VCOSPOST_ vcos_cmd_execute( int argc, char **argv, size_t result_size, char *result_buf );\n\n/*\n * Shut down the command system and free all allocated data.\n * Do not call any other command functions after this.\n */\nVCOSPRE_ void VCOSPOST_ vcos_cmd_shutdown( void );\n\n#endif /* VCOS_CMD_H */\n\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vcos/vcos_ctype.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n/*=============================================================================\nVideoCore OS Abstraction Layer - public header file\n=============================================================================*/\n\n#ifndef VCOS_CTYPE_H\n#define VCOS_CTYPE_H\n\n/**\n  * \\file\n  *\n  * ctype functions.\n  *\n  */\n\n#ifdef __KERNEL__\n#include <linux/ctype.h>\n#else\n#include <ctype.h>\n#endif\n\n#endif\n\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vcos/vcos_dlfcn.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n/*=============================================================================\nVCOS - abstraction over dynamic library opening\n=============================================================================*/\n\n#ifndef VCOS_DLFCN_H\n#define VCOS_DLFCN_H\n\n#include \"interface/vcos/vcos_types.h\"\n#include \"vcos.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/**\n * \\file\n *\n * Loading dynamic libraries. See also dlfcn.h.\n */\n\n/** Open a dynamic library.\n  *\n  * @param name  name of the library\n  * @param mode  Load lazily or immediately (VCOS_DL_LAZY, VCOS_DL_NOW, VCOS_DL_LOCAL, VCOS_DL_GLOBAL).\n  *\n  * @return A handle for use in subsequent calls.\n  */\nVCOSPRE_ void * VCOSPOST_ vcos_dlopen(const char *name, int mode);\n\n/** Look up a symbol.\n  *\n  * @param handle Handle to open\n  * @param name   Name of function\n  *\n  * @return Function pointer, or NULL.\n  */\nVCOSPRE_ void VCOSPOST_ (*vcos_dlsym(void *handle, const char *name))(void);\n\n/** Close a library\n  *\n  * @param handle Handle to close\n  */\nVCOSPRE_ int VCOSPOST_ vcos_dlclose (void *handle);\n\n/** Return error message from library.\n  *\n  * @param err  On return, set to non-zero if an error has occurred\n  * @param buf  Buffer to write error to\n  * @param len  Size of buffer (including terminating NUL).\n  */\nVCOSPRE_ int VCOSPOST_ vcos_dlerror(int *err, char *buf, size_t buflen);\n\n\n#ifdef __cplusplus\n}\n#endif\n#endif\n\n\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vcos/vcos_event.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n/*=============================================================================\nVideoCore OS Abstraction Layer - public header file for events\n=============================================================================*/\n\n#ifndef VCOS_EVENT_H\n#define VCOS_EVENT_H\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#include \"interface/vcos/vcos_types.h\"\n#include \"vcos.h\"\n\n/** \n  * \\file\n  *\n  * An event is akin to the Win32 auto-reset event.\n  *\n  *\n  * Signalling an event will wake up one waiting thread only. Once one\n  * thread has been woken the event atomically returns to the unsignalled\n  * state.\n  * \n  * If no threads are waiting on the event when it is signalled it remains\n  * signalled.\n  *\n  * This is almost, but not quite, completely unlike the \"event flags\"\n  * object based on Nucleus event groups and ThreadX event flags.\n  *\n  * In particular, it should be similar in speed to a semaphore, unlike\n  * the event flags.\n  */\n\n/**\n  * Create an event instance.\n  *\n  * @param event  Filled in with constructed event.\n  * @param name   Name of the event (for debugging)\n  *\n  * @return VCOS_SUCCESS on success, or error code.\n  */\nVCOS_INLINE_DECL\nVCOS_STATUS_T vcos_event_create(VCOS_EVENT_T *event, const char *name);\n\n#ifndef vcos_event_signal\n\n/**\n  * Signal the event. The event will return to being unsignalled\n  * after exactly one waiting thread has been woken up. If no\n  * threads are waiting it remains signalled.\n  *\n  * @param event The event to signal\n  */\nVCOS_INLINE_DECL\nvoid vcos_event_signal(VCOS_EVENT_T *event);\n\n/**\n  * Wait for the event.\n  *\n  * @param event The event to wait for\n  * @return VCOS_SUCCESS on success, VCOS_EAGAIN if the wait was interrupted.\n  */\nVCOS_INLINE_DECL\nVCOS_STATUS_T vcos_event_wait(VCOS_EVENT_T *event);\n\n/**\n  * Try event, but don't block.\n  *\n  * @param event The event to try\n  * @return VCOS_SUCCESS on success, VCOS_EAGAIN if the event is not currently signalled\n  */\nVCOS_INLINE_DECL\nVCOS_STATUS_T vcos_event_try(VCOS_EVENT_T *event);\n\n#endif\n\n/*\n * Destroy an event.\n */\nVCOS_INLINE_DECL\nvoid vcos_event_delete(VCOS_EVENT_T *event);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif\n\n\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vcos/vcos_event_flags.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n/*=============================================================================\nVideoCore OS Abstraction Layer - public header file\n=============================================================================*/\n\n#ifndef VCOS_EVENT_FLAGS_H\n#define VCOS_EVENT_FLAGS_H\n\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#include \"interface/vcos/vcos_types.h\"\n#include \"vcos.h\"\n\n#define VCOS_EVENT_FLAGS_SUSPEND    VCOS_SUSPEND\n#define VCOS_EVENT_FLAGS_NO_SUSPEND VCOS_NO_SUSPEND\ntypedef VCOS_OPTION VCOS_EVENTGROUP_OPERATION_T;\n\n/**\n * \\file vcos_event_flags.h\n *\n * Defines event flags API.\n *\n * Similar to Nucleus event groups.\n *\n * These have the same semantics as Nucleus event groups and ThreadX event\n * flags. As such, they are quite complex internally; if speed is important\n * they might not be your best choice.\n *\n */\n\n/**\n * Create an event flags instance.\n *\n * @param flags   Pointer to event flags instance, filled in on return.\n * @param name    Name for the event flags, used for debug.\n *\n * @return VCOS_SUCCESS if succeeded.\n */\n\nVCOS_INLINE_DECL\nVCOS_STATUS_T vcos_event_flags_create(VCOS_EVENT_FLAGS_T *flags, const char *name);\n\n/**\n  * Set some events.\n  *\n  * @param flags   Instance to set flags on\n  * @param events  Bitmask of the flags to actually set\n  * @param op      How the flags should be set. VCOS_OR will OR in the flags; VCOS_AND\n  *                will AND them in, possibly clearing existing flags.\n  */\nVCOS_INLINE_DECL\nvoid vcos_event_flags_set(VCOS_EVENT_FLAGS_T *flags,\n                          VCOS_UNSIGNED events,\n                          VCOS_OPTION op);\n\n/**\n * Retrieve some events.\n *\n * Waits until the specified events have been set.\n *\n * @param flags            Instance to wait on\n * @param requested_events The bitmask to wait for\n * @param op               VCOS_OR - get any; VCOS_AND - get all.\n * @param ms_suspend       How long to wait, in milliseconds\n * @param retrieved_events the events actually retrieved.\n *\n * @return VCOS_SUCCESS if events were retrieved. VCOS_EAGAIN if the\n * timeout expired.\n */\nVCOS_INLINE_DECL\nVCOS_STATUS_T vcos_event_flags_get(VCOS_EVENT_FLAGS_T *flags,\n                                                     VCOS_UNSIGNED requested_events,\n                                                     VCOS_OPTION op,\n                                                     VCOS_UNSIGNED ms_suspend,\n                                                     VCOS_UNSIGNED *retrieved_events);\n\n\n/**\n * Delete an event flags instance.\n */\nVCOS_INLINE_DECL\nvoid vcos_event_flags_delete(VCOS_EVENT_FLAGS_T *);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif\n\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vcos/vcos_init.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n/*=============================================================================\nVideoCore OS Abstraction Layer - initialization routines\n=============================================================================*/\n\n\n#include \"interface/vcos/vcos_types.h\"\n#include \"vcos.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/** \\file\n  *\n  * Some OS support libraries need some initialization. To support this, call\n  * vcos_init() function at the start of day; vcos_deinit() at the end.\n  */\n\n/**\n * vcos initialization. Call this function before using other vcos functions.\n * Calls can be nested within the same process; they are reference counted so\n * that only a call from uninitialized state has any effect.\n * @note On platforms/toolchains that support it, gcc's constructor attribute or\n *       similar is used to invoke this function before main() or equivalent.\n * @return Status of initialisation.\n */\nVCOSPRE_ VCOS_STATUS_T VCOSPOST_ vcos_init(void);\n\n/**\n * vcos deinitialization. Call this function when vcos is no longer required,\n * in order to free resources.\n * Calls can be nested within the same process; they are reference counted so\n * that only a call that decrements the reference count to 0 has any effect.\n * @note On platforms/toolchains that support it, gcc's destructor attribute or\n *       similar is used to invoke this function after exit() or equivalent.\n * @return Status of initialisation.\n */\nVCOSPRE_ void VCOSPOST_ vcos_deinit(void);\n\n/**\n * Acquire global lock. This must be available independent of vcos_init()/vcos_deinit().\n */\nVCOSPRE_ void VCOSPOST_ vcos_global_lock(void);\n\n/**\n * Release global lock. This must be available independent of vcos_init()/vcos_deinit().\n */\nVCOSPRE_ void VCOSPOST_ vcos_global_unlock(void);\n\n/** Pass in the argv/argc arguments passed to main() */\nVCOSPRE_ void VCOSPOST_ vcos_set_args(int argc, const char **argv);\n\n/** Return argc. */\nVCOSPRE_ int VCOSPOST_ vcos_get_argc(void);\n\n/** Return argv. */\nVCOSPRE_ const char ** VCOSPOST_ vcos_get_argv(void);\n\n/**\n * Platform-specific initialisation.\n * VCOS internal function, not part of public API, do not call from outside\n * vcos. vcos_init()/vcos_deinit() reference count calls, so this function is\n * only called from an uninitialized state, i.e. there will not be two\n * consecutive calls to vcos_platform_init() without an intervening call to\n * vcos_platform_deinit().\n * This function is called with vcos_global_lock held.\n * @return Status of initialisation.\n */\nVCOSPRE_ VCOS_STATUS_T VCOSPOST_ vcos_platform_init(void);\n\n/**\n * Platform-specific de-initialisation.\n * VCOS internal function, not part of public API, do not call from outside\n * vcos.\n * See vcos_platform_init() re reference counting.\n * This function is called with vcos_global_lock held.\n */\nVCOSPRE_ void VCOSPOST_ vcos_platform_deinit(void);\n\n#ifdef __cplusplus\n}\n#endif\n\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vcos/vcos_inttypes.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n#ifndef VCOS_INTTYPES_H\n#define VCOS_INTTYPES_H\n\n/** \\file\n * Attempt to provide the support for fixed width integer types as per\n * inttypes.h. This simply includes inttypes.h, which should find the\n * system/toolchain version if present, otherwise falling back to the version\n * in interface/vcos/<platform>. The vcos versions initially only provide the\n * most common printf() macros.\n */\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#include <inttypes.h>\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* VCOS_INTTYPES_H */\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vcos/vcos_isr.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n/*=============================================================================\nVideoCore OS Abstraction Layer - IRQ support\n=============================================================================*/\n\n#ifndef VCOS_ISR_H\n#define VCOS_ISR_H\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#include \"interface/vcos/vcos_types.h\"\n#include \"vcos.h\"\n\n/**\n  * \\file vcos_isr.h\n  *\n  * \\section isr ISR support\n  *\n  * API for dispatching interrupts.\n  */\n\n/**\n  *\n  * Register an interrupt handler. The old handler (if any) is returned in\n  * old_handler. The old handler should be called if the interrupt was not\n  * for you.\n  *\n  * The handler function will be called in a context with interrupts disabled,\n  * so should be written to be as short as possible. If significant processing\n  * is needed, the handler should delegate to a thread.\n  *\n  * The handler function can call any OS primitive that does not block (e.g.\n  * post a semaphore or set an event flag). Blocking operations (including memory\n  * allocation from the system heap) are not permitted.\n  *\n  * To deregister an ISR, pass in NULL.\n  *\n  * @param vec  Vector to register for\n  * @param handler Handler to be called\n  * @param old_handler Updated with the old handler, or NULL.\n  */\n\nVCOS_INLINE_DECL\nvoid vcos_register_isr(VCOS_UNSIGNED vec,\n                       VCOS_ISR_HANDLER_T handler,\n                       VCOS_ISR_HANDLER_T *old_handler);\n\n/** Disable interrupts, returning the old value (enabled/disabled) to the caller.\n  */\nVCOS_INLINE_DECL\nVCOS_UNSIGNED vcos_int_disable(void);\n\n/** Restore the previous interrupt enable/disable state.\n  */\nVCOS_INLINE_DECL\nvoid vcos_int_restore(VCOS_UNSIGNED previous);\n\n#ifdef __cplusplus\n}\n#endif\n#endif\n\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vcos/vcos_legacy_isr.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n/*=============================================================================\nVideoCore OS Abstraction Layer - legacy (Nucleus) IRQ support\n=============================================================================*/\n\n#ifndef VCOS_LEGACY_ISR_H\n#define VCOS_LEGACY_ISR_H\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#include \"interface/vcos/vcos_types.h\"\n#include \"vcos.h\"\n\n/** \\file vcos_legacy_isr.h\n  *\n  * API for dispatching interrupts the Nucleus way, via a LISR and HISR.\n  * New code should use the single-dispatch scheme - the LISR/HISR\n  * distinction is not necessary.\n  *\n  * Under ThreadX, a HISR is implemented as a high-priority thread which \n  * waits on a counting semaphore to call the HISR function. Although this\n  * provides a good approximation to the Nucleus semantics, it is potentially\n  * slow if all you are trying to do is to wake a thread from LISR context.\n  */\n\n/** Register a LISR. This is identical to the NU_Register_LISR API.\n  */\nVCOS_INLINE_DECL\nVCOS_STATUS_T vcos_register_legacy_lisr(VCOS_UNSIGNED vecnum,\n                                        void (*lisr)(VCOS_INT),\n                                        void (**old_lisr)(VCOS_INT));\n\nVCOS_INLINE_DECL\nVCOS_STATUS_T vcos_legacy_hisr_create(VCOS_HISR_T *hisr, const char *name,\n                                      void (*entry)(void),\n                                      VCOS_UNSIGNED pri,\n                                      void *stack, VCOS_UNSIGNED stack_size);\n\n/** Activate a HISR. On an OS which has no distinction between a HISR and LISR,\n  * this may use some kind of emulation, which could well be less efficient than\n  * a normal ISR.`\n  *\n  * @param hisr HISR to activate.\n  */\nVCOS_INLINE_DECL\nvoid vcos_legacy_hisr_activate(VCOS_HISR_T *hisr);\n\n/** Delete a HISR. \n  *\n  * @param hisr HISR to delete.\n  */\nVCOS_INLINE_DECL\nvoid vcos_legacy_hisr_delete(VCOS_HISR_T *hisr);\n\n/** Are we in a legacy LISR?\n  *\n  * @return On Nucleus, non-zero if in a LISR. On other platforms, non-zero if\n  * in an interrupt.\n  */\nVCOS_INLINE_DECL\nint vcos_in_legacy_lisr(void);\n\n/** Is the current thread actually a fake HISR thread? Only implemented\n  * on platforms that fake up HISRs.\n  */\n\n#ifndef VCOS_LISRS_NEED_HISRS\nVCOSPRE_ int VCOSPOST_ vcos_current_thread_is_fake_hisr_thread(VCOS_HISR_T *);\n#endif\n\n#ifdef __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vcos/vcos_logging.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n/*=============================================================================\nVideoCore OS Abstraction Layer - logging support\n=============================================================================*/\n\n#ifndef VCOS_LOGGING_H\n#define VCOS_LOGGING_H\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#include <stdarg.h>\n\n#include \"interface/vcos/vcos_types.h\"\n#include \"vcos.h\"\n#include \"vcos_logging_control.h\"\n\n/**\n * \\file\n *\n * Logging support\n *\n * This provides categorised logging. Clients register\n * a category, and then get a number of logging levels for\n * that category.\n *\n * The logging level flag is tested using a flag *before* the\n * function call, which makes logging very fast when disabled - there\n * is no function call overhead just to find out that this log\n * message is disabled.\n *\n * \\section VCOS_LOG_CATEGORY\n *\n * As a convenience, clients define VCOS_LOG_CATEGORY to point to\n * their category; the various vcos_log_xxx() macros then expand to\n * use this.\n *\n * e.g.\n *\n *     #define VCOS_LOG_CATEGORY (&my_category)\n *\n *     #include <interface/vcos/vcos.h>\n *\n *     VCOS_LOG_CAT_T my_category;\n *\n *     ....\n *\n *     vcos_log_trace(\"Stuff happened: %d\", n_stuff);\n *\n */\n\n/** Logging levels */\ntypedef enum VCOS_LOG_LEVEL_T\n{\n   VCOS_LOG_UNINITIALIZED   = 0,\n   VCOS_LOG_NEVER,\n   VCOS_LOG_ERROR,\n   VCOS_LOG_WARN,\n   VCOS_LOG_INFO,\n   VCOS_LOG_TRACE,\n} VCOS_LOG_LEVEL_T;\n\n\n/** Initialize a logging category without going through vcos_log_register().\n *\n * This is useful for the case where there is no obvious point to do the\n * registration (no initialization function for the module). However, it\n * means that your logging category is not registered, so cannot be easily\n * changed at run-time.\n */\n#define VCOS_LOG_INIT(n,l) { l, n, 0, {0}, 0, 0 }\n\n/** A registered logging category.\n  */\ntypedef struct VCOS_LOG_CAT_T\n{\n   VCOS_LOG_LEVEL_T level;      /**< Which levels are enabled for this category */\n   const char *name;            /**< Name for this category. */\n   struct VCOS_LOG_CAT_T *next;\n   struct {\n      unsigned int want_prefix:1;\n   } flags;\n   unsigned int refcount;\n   void *platform_data;         /**< platform specific data */\n} VCOS_LOG_CAT_T;\n\ntypedef void (*VCOS_VLOG_IMPL_FUNC_T)(const VCOS_LOG_CAT_T *cat, VCOS_LOG_LEVEL_T _level, const char *fmt, va_list args);\n\n/** Convert a VCOS_LOG_LEVEL_T into a printable string.\n  * The platform needs to implement this function.\n  */\nVCOSPRE_ const char * VCOSPOST_ vcos_log_level_to_string( VCOS_LOG_LEVEL_T level );\n\n/** Convert a string into a VCOS_LOG_LEVEL_T\n  * The platform needs to implement this function.\n  */\nVCOSPRE_ VCOS_STATUS_T VCOSPOST_ vcos_string_to_log_level( const char *str, VCOS_LOG_LEVEL_T *level );\n\n/** Log a message. Basic API. Normal code should not use this.\n  * The platform needs to implement this function.\n  */\nVCOSPRE_ void VCOSPOST_ vcos_log_impl(const VCOS_LOG_CAT_T *cat, VCOS_LOG_LEVEL_T _level, const char *fmt, ...) VCOS_FORMAT_ATTR_(printf, 3, 4);\n\n/** Log a message using a varargs parameter list. Normal code should\n  * not use this.\n  */\nVCOSPRE_ void VCOSPOST_ vcos_vlog_impl(const VCOS_LOG_CAT_T *cat, VCOS_LOG_LEVEL_T _level, const char *fmt, va_list args) VCOS_FORMAT_ATTR_(printf, 3, 0);\n\n/** Set the function which does the actual logging output.\n *  Passing in NULL causes the default logging function to be\n *  used.\n  */\nVCOSPRE_ void VCOSPOST_ vcos_set_vlog_impl( VCOS_VLOG_IMPL_FUNC_T vlog_impl_func );\n\n/** The default logging function, which is provided by each\n  * platform.\n  */\n\nVCOSPRE_ void VCOSPOST_ vcos_vlog_default_impl(const VCOS_LOG_CAT_T *cat, VCOS_LOG_LEVEL_T _level, const char *fmt, va_list args) VCOS_FORMAT_ATTR_(printf, 3, 0);\n\n/*\n * Initialise the logging subsystem. This is called from\n * vcos_init() so you don't normally need to call it.\n */\nVCOSPRE_ void VCOSPOST_ vcos_logging_init(void);\n\n/** Register a logging category.\n  *\n  * @param name the name of this category.\n  * @param category the category to register.\n  */\nVCOSPRE_ void VCOSPOST_ vcos_log_register(const char *name, VCOS_LOG_CAT_T *category);\n\n/** Unregister a logging category.\n  */\nVCOSPRE_ void VCOSPOST_ vcos_log_unregister(VCOS_LOG_CAT_T *category);\n\n/** Return a default logging category, for people too lazy to create their own.\n  *\n  * Using the default category will be slow (there's an extra function\n  * call overhead). Don't do this in normal code.\n  */\nVCOSPRE_ const VCOS_LOG_CAT_T * VCOSPOST_ vcos_log_get_default_category(void);\n\nVCOSPRE_ void VCOSPOST_ vcos_set_log_options(const char *opt);\n\n/** Set the logging level for a category at run time. Without this, the level\n  * will be that set by vcos_log_register from a platform-specific source.\n  *\n  * @param category the category to modify.\n  * @param level the new logging level for this category.\n  */\nVCOS_STATIC_INLINE void vcos_log_set_level(VCOS_LOG_CAT_T *category, VCOS_LOG_LEVEL_T level)\n{\n   category->level = level;\n}\n\n#define vcos_log_dump_mem(cat,label,addr,voidMem,numBytes)  do { if (vcos_is_log_enabled(cat,VCOS_LOG_TRACE)) vcos_log_dump_mem_impl(cat,label,addr,voidMem,numBytes); } while (0)\n\nvoid vcos_log_dump_mem_impl( const VCOS_LOG_CAT_T *cat,\n                             const char           *label,\n                             uint32_t              addr,\n                             const void           *voidMem,\n                             size_t                numBytes );\n\n/*\n * Platform specific hooks (optional).\n */\n#ifndef vcos_log_platform_init\n#define vcos_log_platform_init()                (void)0\n#endif\n\n#ifndef vcos_log_platform_register\n#define vcos_log_platform_register(category)    (void)0\n#endif\n\n#ifndef vcos_log_platform_unregister\n#define vcos_log_platform_unregister(category)  (void)0\n#endif\n\n/* VCOS_TRACE() - deprecated macro which just outputs in a debug build and\n * is a no-op in a release build.\n *\n * _VCOS_LOG_X() - internal macro which outputs if the current level for the\n * particular category is higher than the supplied message level.\n */\n\n#define VCOS_LOG_DFLT_CATEGORY vcos_log_get_default_category()\n\n#define _VCOS_LEVEL(x) (x)\n\n#define vcos_is_log_enabled(cat,_level)  (_VCOS_LEVEL((cat)->level) >= _VCOS_LEVEL(_level))\n\n#if defined(_VCOS_METAWARE) || defined(__GNUC__)\n\n# if !defined(AMPUTATE_ALL_VCOS_LOGGING) && (!defined(NDEBUG) || defined(VCOS_ALWAYS_WANT_LOGGING))\n#  define VCOS_LOGGING_ENABLED\n#  define _VCOS_LOG_X(cat, _level, fmt...)   do { if (vcos_is_log_enabled(cat,_level)) vcos_log_impl(cat,_level,fmt); } while (0)\n#  define _VCOS_VLOG_X(cat, _level, fmt, ap) do { if (vcos_is_log_enabled(cat,_level)) vcos_vlog_impl(cat,_level,fmt,ap); } while (0)\n# else\n#  define _VCOS_LOG_X(cat, _level, fmt...) (void)0\n#  define _VCOS_VLOG_X(cat, _level, fmt, ap) (void)0\n# endif\n\n\n\n# define vcos_log_error(...)   _VCOS_LOG_X(VCOS_LOG_CATEGORY, VCOS_LOG_ERROR, __VA_ARGS__)\n# define vcos_log_warn(...)    _VCOS_LOG_X(VCOS_LOG_CATEGORY, VCOS_LOG_WARN, __VA_ARGS__)\n# define vcos_log_info(...)    _VCOS_LOG_X(VCOS_LOG_CATEGORY, VCOS_LOG_INFO, __VA_ARGS__)\n# define vcos_log_trace(...)   _VCOS_LOG_X(VCOS_LOG_CATEGORY, VCOS_LOG_TRACE, __VA_ARGS__)\n\n# define vcos_vlog_error(fmt,ap)  _VCOS_VLOG_X(VCOS_LOG_CATEGORY, VCOS_LOG_ERROR, fmt, ap)\n# define vcos_vlog_warn(fmt,ap)   _VCOS_VLOG_X(VCOS_LOG_CATEGORY, VCOS_LOG_WARN, fmt, ap)\n# define vcos_vlog_info(fmt,ap)   _VCOS_VLOG_X(VCOS_LOG_CATEGORY, VCOS_LOG_INFO, fmt, ap)\n# define vcos_vlog_trace(fmt,ap)  _VCOS_VLOG_X(VCOS_LOG_CATEGORY, VCOS_LOG_TRACE, fmt, ap)\n\n# define vcos_logc_error(cat,...)   _VCOS_LOG_X(cat, VCOS_LOG_ERROR, __VA_ARGS__)\n# define vcos_logc_warn(cat,...)    _VCOS_LOG_X(cat, VCOS_LOG_WARN, __VA_ARGS__)\n# define vcos_logc_info(cat,...)    _VCOS_LOG_X(cat, VCOS_LOG_INFO, __VA_ARGS__)\n# define vcos_logc_trace(cat,...)   _VCOS_LOG_X(cat, VCOS_LOG_TRACE, __VA_ARGS__)\n\n# define vcos_vlogc_error(cat,fmt,ap)  _VCOS_VLOG_X(cat, VCOS_LOG_ERROR, fmt, ap)\n# define vcos_vlogc_warn(cat,fmt,ap)   _VCOS_VLOG_X(cat, VCOS_LOG_WARN, fmt, ap)\n# define vcos_vlogc_info(cat,fmt,ap)   _VCOS_VLOG_X(cat, VCOS_LOG_INFO, fmt, ap)\n# define vcos_vlogc_trace(cat,fmt,ap)  _VCOS_VLOG_X(cat, VCOS_LOG_TRACE, fmt, ap)\n\n# define vcos_log(...)   _VCOS_LOG_X(VCOS_LOG_DFLT_CATEGORY, VCOS_LOG_INFO, __VA_ARGS__)\n# define vcos_vlog(fmt,ap)  _VCOS_VLOG_X(VCOS_LOG_DFLT_CATEGORY, VCOS_LOG_INFO, fmt, ap)\n# define VCOS_ALERT(...) _VCOS_LOG_X(VCOS_LOG_DFLT_CATEGORY, VCOS_LOG_ERROR, __VA_ARGS__)\n# define VCOS_TRACE(...) _VCOS_LOG_X(VCOS_LOG_DFLT_CATEGORY, VCOS_LOG_INFO, __VA_ARGS__)\n\n/*\n * MS Visual Studio - pre 2005 does not grok variadic macros\n */\n#elif defined(_MSC_VER)\n\n# if _MSC_VER >= 1400\n\n#  if !defined(AMPUTATE_ALL_VCOS_LOGGING) && (!defined(NDEBUG) || defined(VCOS_ALWAYS_WANT_LOGGING))\n#   define VCOS_LOGGING_ENABLED\n#   define _VCOS_LOG_X(cat, _level, fmt,...) do { if (vcos_is_log_enabled(cat,_level)) vcos_log_impl(cat, _level, fmt, __VA_ARGS__); } while (0)\n#  else\n#   define _VCOS_LOG_X(cat, _level, fmt,...) (void)0\n#  endif\n\n# define vcos_log_error(fmt,...)   _VCOS_LOG_X(VCOS_LOG_CATEGORY, VCOS_LOG_ERROR, fmt, __VA_ARGS__)\n# define vcos_log_warn(fmt,...)    _VCOS_LOG_X(VCOS_LOG_CATEGORY, VCOS_LOG_WARN, fmt, __VA_ARGS__)\n# define vcos_log_info(fmt,...)    _VCOS_LOG_X(VCOS_LOG_CATEGORY, VCOS_LOG_INFO, fmt, __VA_ARGS__)\n# define vcos_log_trace(fmt,...)   _VCOS_LOG_X(VCOS_LOG_CATEGORY, VCOS_LOG_TRACE, fmt, __VA_ARGS__)\n\n# define vcos_logc_error(cat,fmt,...)   _VCOS_LOG_X(cat, VCOS_LOG_ERROR, fmt, __VA_ARGS__)\n# define vcos_logc_warn(cat,fmt,...)    _VCOS_LOG_X(cat, VCOS_LOG_WARN, fmt, __VA_ARGS__)\n# define vcos_logc_info(cat,fmt,...)    _VCOS_LOG_X(cat, VCOS_LOG_INFO, fmt, __VA_ARGS__)\n# define vcos_logc_trace(cat,fmt,...)   _VCOS_LOG_X(cat, VCOS_LOG_TRACE, fmt, __VA_ARGS__)\n\n# define vcos_log(fmt,...)   _VCOS_LOG_X(VCOS_LOG_DFLT_CATEGORY, VCOS_LOG_INFO, fmt, __VA_ARGS__)\n# define VCOS_ALERT(fmt,...) _VCOS_LOG_X(VCOS_LOG_DFLT_CATEGORY, VCOS_LOG_ERROR, fmt, __VA_ARGS__)\n# define VCOS_TRACE(fmt,...) _VCOS_LOG_X(VCOS_LOG_DFLT_CATEGORY, VCOS_LOG_INFO, fmt, __VA_ARGS__)\n\n# else /* _MSC_VER >= 1400 */\n\n/* do not define these */\n\n# endif /* _MSC_VER >= 1400 */\n\n#endif\n\n#if VCOS_HAVE_CMD\n\n#include \"interface/vcos/vcos_cmd.h\"\n\n/*\n * These are the log sub-commands. They're exported here for user-mode apps which \n * may want to call these, since the \"log\" command isn't registered for user-mode \n * apps (vcdbg for example, has its own log command). \n */\nVCOSPRE_ VCOS_STATUS_T VCOSPOST_ vcos_log_assert_cmd( VCOS_CMD_PARAM_T *param );\nVCOSPRE_ VCOS_STATUS_T VCOSPOST_ vcos_log_set_cmd( VCOS_CMD_PARAM_T *param );\nVCOSPRE_ VCOS_STATUS_T VCOSPOST_ vcos_log_status_cmd( VCOS_CMD_PARAM_T *param );\nVCOSPRE_ VCOS_STATUS_T VCOSPOST_ vcos_log_test_cmd( VCOS_CMD_PARAM_T *param );\n#endif\n\n#ifdef __cplusplus\n}\n#endif\n#endif /* VCOS_LOGGING_H */\n\n\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vcos/vcos_logging_control.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vcos/vcos_lowlevel_thread.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n/*=============================================================================\nVideoCore OS Abstraction Layer - low level thread support\n=============================================================================*/\n\n#ifndef VCOS_LOWLEVEL_THREAD_H\n#define VCOS_LOWLEVEL_THREAD_H\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#include \"interface/vcos/vcos_types.h\"\n#ifndef VCOS_PLATFORM_H\n#include \"vcos.h\"\n#endif\n\n/**\n * \\file\n *\n * This defines a low level thread API that is supported by *some* operating systems\n * and can be used to construct the regular \"joinable thread\" API on those operating\n * systems.\n *\n * Most clients will not need to use this code.\n *\n * \\sa vcos_joinable_thread.h\n */\n\n/**\n  * \\brief Create a thread.\n  *\n  * This creates a thread which can be stopped either by returning from the\n  * entry point function or by calling vcos_llthread_exit from within the entry\n  * point function. The thread must be cleaned up by calling\n  * vcos_llthread_delete. vcos_llthread_delete may or may not terminate the\n  * thread.\n  *\n  * The preemptible parameter familiar from Nucleus is removed, as it is unused in\n  *  VideoCore code. Affinity is added, since we do use this.\n  *\n  * @param thread       Filled in with thread instance\n  * @param name         An optional name for the thread. \"\" may be used (but\n  *                     a name will aid in debugging).\n  * @param entry        Entry point\n  * @param arg          A single argument passed to the entry point function\n  * @param stack        Pointer to stack address\n  * @param stacksz      Size of stack in bytes\n  * @param priority     Priority of task, between VCOS_PRI_LOW and VCOS_PRI_HIGH\n  * @param affinity     CPU affinity\n  *\n  * @sa vcos_llthread_terminate vcos_llthread_delete\n  */\nVCOSPRE_ VCOS_STATUS_T VCOSPOST_ vcos_llthread_create(VCOS_LLTHREAD_T *thread,\n                                                      const char *name,\n                                                      VCOS_LLTHREAD_ENTRY_FN_T entry,\n                                                      void *arg,\n                                                      void *stack,\n                                                      VCOS_UNSIGNED stacksz,\n                                                      VCOS_UNSIGNED priority,\n                                                      VCOS_UNSIGNED affinity,\n                                                      VCOS_UNSIGNED timeslice,\n                                                      VCOS_UNSIGNED autostart);\n\n/**\n  * \\brief Exits the current thread.\n  */\nVCOSPRE_ void VCOSPOST_ vcos_llthread_exit(void);\n\n/**\n  * \\brief Delete a thread. This must be called to cleanup after\n  * vcos_llthread_create. This may or may not terminate the thread.\n  * It does not clean up any resources that may have been\n  * allocated by the thread.\n  */\nVCOSPRE_ void VCOSPOST_ vcos_llthread_delete(VCOS_LLTHREAD_T *thread);\n\n/**\n  * \\brief Return current lowlevel thread pointer.\n  */\nVCOS_INLINE_DECL\nVCOS_LLTHREAD_T *vcos_llthread_current(void);\n\n/**\n  * Resume a thread.\n  */\nVCOS_INLINE_DECL\nvoid vcos_llthread_resume(VCOS_LLTHREAD_T *thread);\n\nVCOSPRE_ int VCOSPOST_ vcos_llthread_running(VCOS_LLTHREAD_T *thread);\n\n/**\n  * \\brief Create a VCOS_LLTHREAD_T for the current thread. This is so we can\n  * have VCOS_LLTHREAD_Ts even for threads not originally created by VCOS (eg\n  * the thread that calls vcos_init).\n  */\nextern VCOS_STATUS_T _vcos_llthread_create_attach(VCOS_LLTHREAD_T *thread);\n\n#ifdef __cplusplus\n}\n#endif\n#endif\n\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vcos/vcos_mem.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n/*=============================================================================\nVideoCore OS Abstraction Layer - memory support\n=============================================================================*/\n\n#ifndef VCOS_MEM_H\n#define VCOS_MEM_H\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#include \"interface/vcos/vcos_types.h\"\n#include \"vcos.h\"\n\n/** \\file\n  *\n  * Memory allocation api (malloc/free equivalents) is for benefit of host\n  * applications. VideoCore code should use rtos_XXX functions.\n  *\n  */\n\n\n/** Allocate memory\n  *\n  * @param size Size of memory to allocate\n  * @param description Description, to aid in debugging. May be ignored internally on some platforms.\n  */\nVCOS_INLINE_DECL\nvoid *vcos_malloc(VCOS_UNSIGNED size, const char *description);\n\nvoid *vcos_kmalloc(VCOS_UNSIGNED size, const char *description);\nvoid *vcos_kcalloc(VCOS_UNSIGNED num, VCOS_UNSIGNED size, const char *description);\n\n/** Allocate cleared memory\n  *\n  * @param num Number of items to allocate.\n  * @param size Size of each item in bytes.\n  * @param description Description, to aid in debugging. May be ignored internally on some platforms.\n  */\nVCOS_INLINE_DECL\nvoid *vcos_calloc(VCOS_UNSIGNED num, VCOS_UNSIGNED size, const char *description);\n\n/** Free memory\n  *\n  * Free memory that has been allocated.\n  */\nVCOS_INLINE_DECL\nvoid vcos_free(void *ptr);\n\nvoid vcos_kfree(void *ptr);\n\n/** Allocate aligned memory\n  *\n  * Allocate memory aligned on the specified boundary.\n  *\n  * @param size Size of memory to allocate\n  * @param description Description, to aid in debugging. May be ignored internally on some platforms.\n  */\nVCOS_INLINE_DECL\nvoid *vcos_malloc_aligned(VCOS_UNSIGNED size, VCOS_UNSIGNED align, const char *description);\n\n/** Return the amount of free heap memory\n  *\n  */\nVCOS_INLINE_DECL\nunsigned long vcos_get_free_mem(void);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif\n\n\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vcos/vcos_mempool.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n/*=============================================================================\nVideoCore OS Abstraction Layer - memory pool support\n=============================================================================*/\n\n#ifndef VCOS_MEMPOOL_H\n#define VCOS_MEMPOOL_H\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#include \"interface/vcos/vcos_types.h\"\n#include \"vcos.h\"\n\n/** \\file\n  *\n  * Memory pools - variable sized allocator.\n  *\n  * A very basic memory pool API.\n  *\n  * This interface is deliberately not thread safe - clients should add\n  * their own locking, if required.\n  *\n  *\n  * \\fixme: Add fixed-size allocator.\n  *\n  */\n\n\n/** Initialize a memory pool. The control data is taken from the memory\n  * supplied itself.\n  *\n  * Note: the dmalloc pool uses the memory supplied for its control\n  * area. This is probably a bit broken, as it stops you creating\n  * a pool in some \"special\" area of memory, while leaving the control\n  * information in normal memory.\n  *\n  * @param pool  Pointer to pool object.\n  *\n  * @param name  Name for the pool. Used for diagnostics.\n  *\n  * @param start Starting address. Must be at least 8byte aligned.\n  *\n  * @param size  Size of pool in bytes.\n  *\n  * @return VCOS_SUCCESS if pool was created.\n  */\nVCOS_INLINE_DECL\nVCOS_STATUS_T vcos_mempool_create(VCOS_MEMPOOL_T *pool, const char *name, void *start, VCOS_UNSIGNED size);\n\n/** Allocate some memory from a pool. If no memory is available, it\n  * returns NULL.\n  *\n  * @param pool Pool to allocate from\n  * @param len  Length of memory to allocate\n  *\n  */\nVCOS_INLINE_DECL\nvoid *vcos_mempool_alloc(VCOS_MEMPOOL_T *pool, VCOS_UNSIGNED len);\n\n/** Free some memory back to a pool.\n  *\n  * @param pool Pool to return to\n  * @param mem Memory to return\n  */\nVCOS_INLINE_DECL\nvoid vcos_mempool_free(VCOS_MEMPOOL_T *pool, void *mem);\n\n/** Deinitialize a memory pool.\n  *\n  * @param pool Pool to return to\n  */\nVCOS_INLINE_DECL\nvoid vcos_mempool_delete(VCOS_MEMPOOL_T *pool);\n\n#ifdef __cplusplus\n}\n#endif\n#endif\n\n\n\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vcos/vcos_msgqueue.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n/*=============================================================================\nVCOS - packet-like messages, based loosely on those found in TRIPOS.\n\nIn the simple case, only the server thread creates a message queue, and\nclients wait for replies on a semaphore. In more complex cases, clients can\nalso create message queues (not yet implemented).\n\nAlthough it's possible for a thread to create multiple queues and listen\non them in turn, if you find yourself doing this it's probably a bug.\n=============================================================================*/\n\n#ifndef VCOS_MSGQUEUE_H\n#define VCOS_MSGQUEUE_H\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#include \"vcos_types.h\"\n#include \"vcos.h\"\n#include \"vcos_blockpool.h\"\n\n/**\n * \\file\n *\n * Packet-like messages, based loosely on those found in TRIPOS and\n * derivatives thereof.\n *\n * A task can send a message *pointer* to another task, where it is\n * queued on a linked list and the task woken up. The receiving task\n * consumes all of the messages on its input queue, and optionally\n * sends back replies using the original message memory.\n *\n * A caller can wait for the reply to a specific message - any other\n * messages that arrive in the meantime are queued separately.\n *\n *\n * All messages have a standard common layout, but the payload area can\n * be used freely to extend this.\n */\n\n#define VCOS_MSGQ_MAGIC 0x5147534d\n\n/** Map the payload portion of a message to a structure pointer.\n  */\n#define VCOS_MSG_DATA(_msg) (void*)((_msg)->data)\n\n/** Standard message ids - FIXME - these need to be done properly! */\n#define VCOS_MSG_N_QUIT            1\n#define VCOS_MSG_N_OPEN            2\n#define VCOS_MSG_N_CLOSE           3\n#define VCOS_MSG_N_PRIVATE         (1<<20)\n\n#define VCOS_MSG_REPLY_BIT         (1<<31)\n\n/** Make gnuc compiler be happy about pointer punning */\n#ifdef __GNUC__\n#define __VCOS_MAY_ALIAS __attribute__((__may_alias__))\n#else\n#define __VCOS_MAY_ALIAS\n#endif\n\nstruct VCOS_MSG_T;\n\n/* Replies go to one of these objects.\n */\ntypedef struct VCOS_MSG_WAITER_T\n{\n   /* When the reply is sent, this function gets called with the\n    * address of the waiter.\n    */\n   void (*on_reply)(struct VCOS_MSG_WAITER_T *waiter,\n                    struct VCOS_MSG_T *msg);\n} VCOS_MSG_WAITER_T;\n\n/** A single message queue.\n  */\ntypedef struct VCOS_MSGQUEUE_T\n{\n   VCOS_MSG_WAITER_T waiter;           /**< So we can wait on a queue */\n   struct VCOS_MSG_T *head;            /**< head of linked list of messages waiting on this queue */\n   struct VCOS_MSG_T *tail;            /**< tail of message queue */\n   VCOS_SEMAPHORE_T sem;               /**< thread waits on this for new messages */\n   VCOS_MUTEX_T lock;                  /**< locks the messages list */\n   int attached;                       /**< Is this attached to a thread? */\n} VCOS_MSGQUEUE_T;\n\n/** A single message\n  */\ntypedef struct VCOS_MSG_T\n{\n   uint32_t magic;                     /**< Sanity checking */\n   uint32_t code;                      /**< message code */\n   struct VCOS_MSG_T *next;            /**< next in queue */\n   VCOS_THREAD_T *src_thread;          /**< for debug */\n   struct VCOS_MSG_WAITER_T *waiter;   /**< client waiter structure */\n   struct VCOS_MSGQ_POOL_T *pool;      /**< Pool allocated from, or NULL */\n} VCOS_MSG_T;\n\n#define MSG_REPLY_BIT (1<<31)\n\n/** Initialize a VCOS_MSG_T. Can also use vcos_msg_init().\n */\n#define VCOS_MSG_INITIALIZER {VCOS_MSGQ_MAGIC, 0, NULL, NULL, NULL, 0}\n\n/** A pool of messages. This contains its own waiter and\n * semaphore, as well as a blockpool for the actual memory\n * management.\n *\n * When messages are returned to the waiter, it posts the\n * semaphore.\n *\n * When waiting for a message, we just wait on the semaphore.\n * When allocating without waiting, we just try-wait on the\n * semaphore.\n *\n * If we managed to claim the semaphore, then by definition\n * there must be at least that many free messages in the\n * blockpool.\n */\ntypedef struct VCOS_MSGQ_POOL_T\n{\n   VCOS_MSG_WAITER_T waiter;\n   VCOS_BLOCKPOOL_T blockpool;\n   VCOS_SEMAPHORE_T sem;\n   uint32_t magic;\n} VCOS_MSGQ_POOL_T;\n\n/** Initialise the library. Normally called from vcos_init().\n  */\nVCOSPRE_ VCOS_STATUS_T VCOSPOST_ vcos_msgq_init(void);\n\n/** De-initialise the library. Normally called from vcos_deinit().\n */\nVCOSPRE_ void VCOSPOST_ vcos_msgq_deinit(void);\n\n/** Send a message.\n *\n * @param dest    Destination message queue\n * @param code    Message code.\n * @param msg     Pointer to message to send. Must not go out of scope before\n *                message is received (do not declare on the stack).\n */\nVCOSPRE_ void VCOSPOST_ vcos_msg_send(VCOS_MSGQUEUE_T *dest, uint32_t code, VCOS_MSG_T *msg);\n\n/** Send a message and wait for a reply.\n *\n * @param dest    Destination message queue\n * @param code    Message code.\n * @param msg     Pointer to message to send. May be declared on the stack.\n */\nVCOSPRE_ VCOS_STATUS_T VCOSPOST_ vcos_msg_sendwait(VCOS_MSGQUEUE_T *queue, uint32_t code, VCOS_MSG_T *msg);\n\n/** Wait for a message on a queue.\n  */\nVCOSPRE_ VCOS_MSG_T * VCOSPOST_ vcos_msg_wait(VCOS_MSGQUEUE_T *queue);\n\n/** Peek for a message on this thread's endpoint. If a message is not\n * available, NULL is returned. If a message is available it will be\n * removed from the endpoint and returned.\n */\nVCOSPRE_ VCOS_MSG_T * VCOSPOST_ vcos_msg_peek(VCOS_MSGQUEUE_T *queue);\n\n/** Send a reply to a message\n  */\nVCOSPRE_ void VCOSPOST_ vcos_msg_reply(VCOS_MSG_T *msg);\n\n/** Set the reply queue for a message. When the message is replied-to, it\n * will return to the given queue.\n *\n * @param msg      Message\n * @param queue    Message queue the message should return to\n */\nVCOSPRE_ void VCOSPOST_ vcos_msg_set_source(VCOS_MSG_T *msg, VCOS_MSGQUEUE_T *queue);\n\n/** Initialise a newly allocated message. This only needs to be called\n * for messages allocated on the stack, heap or statically. It is not\n * needed for messages allocated from a pool.\n */\nVCOSPRE_ void VCOSPOST_ vcos_msg_init(VCOS_MSG_T *msg);\n\n/** Create a message queue to wait on.\n  */\nVCOSPRE_ VCOS_STATUS_T VCOSPOST_ vcos_msgq_create(VCOS_MSGQUEUE_T *queue, const char *name);\n\n/** Destroy a queue\n  */\nVCOSPRE_ void  VCOSPOST_ vcos_msgq_delete(VCOS_MSGQUEUE_T *queue);\n\n/*\n * Message pools\n */\n\n/** Create a pool of messages. Messages can be allocated from the pool and\n * sent to a message queue. Replying to the message will automatically\n * free it back to the pool.\n *\n * The pool is threadsafe.\n *\n * @param count          number of messages in the pool\n * @param payload_size   maximum message payload size, not including MSG_T.\n */\nVCOSPRE_ VCOS_STATUS_T VCOSPOST_ vcos_msgq_pool_create(\n   VCOS_MSGQ_POOL_T *pool,\n   size_t count,\n   size_t payload_size,\n   const char *name);\n\n/** Destroy a message pool.\n */\nVCOSPRE_ void VCOSPOST_ vcos_msgq_pool_delete(VCOS_MSGQ_POOL_T *pool);\n\n/** Allocate a message from a message pool.\n *\n * Note:\n *\n * If the alloc fails (returns NULL) then your worker thread has stopped\n * servicing requests or your pool is too small for the latency in\n * the system. Your best bet to handle this is to fail the call that\n * needs to send the message.\n *\n * The returned message payload area is initialised to zero.\n *\n * @param  pool  Pool to allocate from.\n * @return Message or NULL if pool exhausted.\n */\nVCOSPRE_ VCOS_MSG_T *VCOSPOST_ vcos_msgq_pool_alloc(VCOS_MSGQ_POOL_T *pool);\n\n/** Wait for a message from a message pool. Waits until a\n * message is available in the pool and then allocates it. If\n * one is already available, returns immediately.\n *\n * This call can never fail.\n *\n * The returned message payload area is initialised to zero.\n *\n * @param  pool  Pool to allocate from.\n * @return Message\n */\nVCOSPRE_ VCOS_MSG_T *VCOSPOST_ vcos_msgq_pool_wait(VCOS_MSGQ_POOL_T *pool);\n\n/** Explicitly free a message and return it to its pool.\n *\n * @param  msg  Message to free. No-op if NULL.\n */\nVCOSPRE_ void VCOSPOST_ vcos_msgq_pool_free(VCOS_MSG_T *msg);\n\n#ifdef __cplusplus\n}\n#endif\n#endif\n\n\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vcos/vcos_mutex.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n/*=============================================================================\nVideoCore OS Abstraction Layer - mutex public header file\n=============================================================================*/\n\n#ifndef VCOS_MUTEX_H\n#define VCOS_MUTEX_H\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#include \"interface/vcos/vcos_types.h\"\n#include \"vcos.h\"\n\n/**\n * \\file vcos_mutex.h\n *\n * Mutex API. Mutexes are not re-entrant, as supporting this adds extra code\n * that slows down clients which have been written sensibly.\n *\n * \\sa vcos_reentrant_mutex.h\n *\n */\n\n/** Create a mutex.\n  *\n  * @param m      Filled in with mutex on return\n  * @param name   A non-null name for the mutex, used for diagnostics.\n  *\n  * @return VCOS_SUCCESS if mutex was created, or error code.\n  */\nVCOS_INLINE_DECL\nVCOS_STATUS_T vcos_mutex_create(VCOS_MUTEX_T *m, const char *name);\n\n/** Delete the mutex.\n  */\nVCOS_INLINE_DECL\nvoid vcos_mutex_delete(VCOS_MUTEX_T *m);\n\n/**\n  * \\brief Wait to claim the mutex.\n  *\n  * On most platforms this always returns VCOS_SUCCESS, and so would ideally be\n  * a void function, however some platforms allow a wait to be interrupted so\n  * it remains non-void.\n  *\n  * Try to obtain the mutex.\n  * @param m   Mutex to wait on\n  * @return VCOS_SUCCESS - mutex was taken.\n  *         VCOS_EAGAIN  - could not take mutex.\n  */\n#ifndef vcos_mutex_lock\nVCOS_INLINE_DECL\nVCOS_STATUS_T vcos_mutex_lock(VCOS_MUTEX_T *m);\n\n/** Release the mutex.\n  */\nVCOS_INLINE_DECL\nvoid vcos_mutex_unlock(VCOS_MUTEX_T *m);\n#endif\n\n/** Test if the mutex is already locked.\n  *\n  * @return 1 if mutex is locked, 0 if it is unlocked.\n  */\nVCOS_INLINE_DECL\nint vcos_mutex_is_locked(VCOS_MUTEX_T *m);\n\n/** Obtain the mutex if possible.\n  *\n  * @param m  the mutex to try to obtain\n  *\n  * @return VCOS_SUCCESS if mutex is successfully obtained, or VCOS_EAGAIN\n  * if it is already in use by another thread.\n  */\n#ifndef vcos_mutex_trylock\nVCOS_INLINE_DECL\nVCOS_STATUS_T vcos_mutex_trylock(VCOS_MUTEX_T *m);\n#endif\n\n\n#ifdef __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vcos/vcos_named_semaphore.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n/*=============================================================================\nVideoCore OS Abstraction Layer - named semaphores\n=============================================================================*/\n\n#ifndef VCOS_NAMED_SEMAPHORE_H\n#define VCOS_NAMED_SEMAPHORE_H\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#include \"interface/vcos/vcos_types.h\"\n#include \"vcos.h\"\n\n/**\n * \\file\n *\n * Create a named semaphore, or open an existing one by name.\n *\n */\n\n/** \n  * \\brief Create a named semaphore.\n  *\n  * Semaphores are not re-entrant.\n  *\n  * @param sem   Pointer to memory to be initialized\n  * @param name  A name for this semaphore.\n  * @param count The initial count for the semaphore.\n  *\n  * @return VCOS_SUCCESS if the semaphore was created.\n  * \n  */\nVCOS_INLINE_DECL\nVCOS_STATUS_T vcos_named_semaphore_create(VCOS_NAMED_SEMAPHORE_T *sem, const char *name, VCOS_UNSIGNED count);\n\n/**\n  * \\brief Wait on a named semaphore.\n  *\n  * There is no timeout option on a semaphore, as adding this will slow down\n  * implementations on some platforms. If you need that kind of behaviour, use\n  * an event group.\n  *\n  * This always returns VCOS_SUCCESS and so should really be a void function. However\n  * too many lines of code would need to be changed in non-trivial ways, so for now\n  * it is non-void.\n  *\n  * @param sem Semaphore to wait on\n  * @return VCOS_SUCCESS - semaphore was taken.\n  *\n  */\nVCOS_INLINE_DECL\nvoid vcos_named_semaphore_wait(VCOS_NAMED_SEMAPHORE_T *sem);\n\n/**\n  * \\brief Try to wait for a semaphore.\n  *\n  * Try to obtain the semaphore. If it is already taken, return VCOS_TIMEOUT.\n  * @param sem Semaphore to wait on\n  * @return VCOS_SUCCESS - semaphore was taken.\n  *         VCOS_EAGAIN - could not take semaphore\n  */\nVCOS_INLINE_DECL\nVCOS_STATUS_T vcos_named_semaphore_trywait(VCOS_NAMED_SEMAPHORE_T *sem);\n\n/**\n  * \\brief Post a semaphore.\n  *\n  * @param sem Semaphore to wait on\n  */\nVCOS_INLINE_DECL\nvoid vcos_named_semaphore_post(VCOS_NAMED_SEMAPHORE_T *sem);\n\n/**\n  * \\brief Delete a semaphore, releasing any resources consumed by it.\n  *\n  * @param sem Semaphore to wait on\n  */\nvoid vcos_named_semaphore_delete(VCOS_NAMED_SEMAPHORE_T *sem);\n\n\n#ifdef __cplusplus\n}\n#endif\n#endif\n\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vcos/vcos_once.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n/*=============================================================================\nVideoCore OS Abstraction Layer - 'once'\n=============================================================================*/\n\n#ifndef VCOS_ONCE_H\n#define VCOS_ONCE_H\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#include \"interface/vcos/vcos_types.h\"\n#include \"vcos.h\"\n\n/**\n * \\file vcos_once.h\n *\n * Ensure something is called only once.\n *\n * Initialize once_control to VCOS_ONCE_INIT. The first\n * time this is called, the init_routine will be called. Thereafter\n * it won't.\n *\n * \\sa pthread_once()\n *\n */\n\nVCOS_STATUS_T vcos_once(VCOS_ONCE_T *once_control,\n                        void (*init_routine)(void));\n\n#ifdef __cplusplus\n}\n#endif\n#endif\n\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vcos/vcos_queue.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n/*=============================================================================\nVideoCore OS Abstraction Layer - Queue public header file\n=============================================================================*/\n\n#ifndef VCOS_QUEUE_H\n#define VCOS_QUEUE_H\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#include \"interface/vcos/vcos_types.h\"\n#include \"vcos.h\"\n\n/** \\file vcos_queue.h\n  *\n  * API for accessing a fixed length queue.\n  *\n  * Nucleus offers variable length items, but this feature is not used\n  * in the current code base, so is withdrawn to simplify the API.\n  */\n\n/** Create a fixed length queue.\n  *\n  * @param queue        Pointer to queue control block\n  * @param name         Name of queue\n  * @param message_size Size of each queue message item in words (words are sizeof VCOS_UNSIGNED).\n  * @param queue_start  Start address of queue area\n  * @param queue_size   Size in words (words are sizeof VCOS_UNSIGNED) of queue\n  *\n  */\n\nVCOS_INLINE_DECL\nVCOS_STATUS_T vcos_queue_create(VCOS_QUEUE_T *queue,\n                                const char *name,\n                                VCOS_UNSIGNED message_size,\n                                void *queue_start,\n                                VCOS_UNSIGNED queue_size);\n\n/** Delete a queue.\n  * @param queue The queue to delete\n  */\nVCOS_INLINE_DECL\nvoid vcos_queue_delete(VCOS_QUEUE_T *queue);\n\n/** Send an item to a queue. If there is no space, the call with\n  * either block waiting for space, or return an error, depending\n  * on the value of the wait parameter.\n  *\n  * @param queue The queue to send to\n  * @param src   The data to send (length set when queue was created)\n  * @param wait  Whether to wait for space (VCOS_SUSPEND) or fail if\n  *              no space (VCOS_NO_SUSPEND).\n  *\n  * @return If space available, returns VCOS_SUCCESS. Otherwise returns\n  * VCOS_EAGAIN if no space available before timeout expires.\n  *\n  */\nVCOS_INLINE_DECL\nVCOS_STATUS_T vcos_queue_send(VCOS_QUEUE_T *queue, const void *src, VCOS_UNSIGNED wait);\n\n/** Receive an item from a queue.\n  * @param queue The queue to receive from\n  * @param dst   Where to write the data to\n  * @param wait  Whether to wait (VCOS_SUSPEND) or fail if\n  *              empty (VCOS_NO_SUSPEND).\n  *\n  * @return If an item is available, returns VCOS_SUCCESS. Otherwise returns\n  * VCOS_EAGAIN if no item available before timeout expires.\n  */\nVCOS_INLINE_DECL\nVCOS_STATUS_T vcos_queue_receive(VCOS_QUEUE_T *queue, void *dst, VCOS_UNSIGNED wait);\n\n#ifdef __cplusplus\n}\n#endif\n#endif\n\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vcos/vcos_quickslow_mutex.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n/*=============================================================================\nVideoCore OS Abstraction Layer - mutex public header file\n=============================================================================*/\n\n#ifndef VCOS_QUICKSLOW_MUTEX_H\n#define VCOS_QUICKSLOW_MUTEX_H\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#include \"interface/vcos/vcos_types.h\"\n#include \"vcos.h\"\n\n/**\n * \\file vcos_quickslow_mutex.h\n *\n * \"Quick/Slow\" Mutex API. This is a mutex which supports an additional \"quick\"\n * (spinlock-based) locking mechanism. While in this quick locked state, other\n * operating system commands will be unavailable and the caller should complete\n * whatever it has to do in a short, bounded length of time (as the spinlock\n * completely locks out other system activity).\n *\n * \\sa vcos_mutex.h\n *\n */\n\n/** Create a mutex.\n  *\n  * @param m      Filled in with mutex on return\n  * @param name   A non-null name for the mutex, used for diagnostics.\n  *\n  * @return VCOS_SUCCESS if mutex was created, or error code.\n  */\nVCOS_INLINE_DECL\nVCOS_STATUS_T vcos_quickslow_mutex_create(VCOS_QUICKSLOW_MUTEX_T *m, const char *name);\n\n/** Delete the mutex.\n  */\nVCOS_INLINE_DECL\nvoid vcos_quickslow_mutex_delete(VCOS_QUICKSLOW_MUTEX_T *m);\n\n/**\n  * \\brief Wait to claim the mutex (\"slow\" mode).\n  *\n  * Obtain the mutex.\n  */\nVCOS_INLINE_DECL\nvoid vcos_quickslow_mutex_lock(VCOS_QUICKSLOW_MUTEX_T *m);\n\n/** Release the mutex (\"slow\" mode).\n  */\nVCOS_INLINE_DECL\nvoid vcos_quickslow_mutex_unlock(VCOS_QUICKSLOW_MUTEX_T *m);\n\n/**\n  * \\brief Wait to claim the mutex (\"quick\" mode).\n  *\n  * Obtain the mutex. The caller must not call any OS functions or do anything\n  * \"slow\" before the corresponding call to vcos_mutex_quickslow_unlock_quick.\n  */\nVCOS_INLINE_DECL\nvoid vcos_quickslow_mutex_lock_quick(VCOS_QUICKSLOW_MUTEX_T *m);\n\n/** Release the mutex (\"quick\" mode).\n  */\nVCOS_INLINE_DECL\nvoid vcos_quickslow_mutex_unlock_quick(VCOS_QUICKSLOW_MUTEX_T *m);\n\n\n#ifdef __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vcos/vcos_reentrant_mutex.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n/*=============================================================================\nVideoCore OS Abstraction Layer - reentrant mutex public header file\n=============================================================================*/\n\n#ifndef VCOS_REENTRANT_MUTEX_H\n#define VCOS_REENTRANT_MUTEX_H\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#include \"interface/vcos/vcos_types.h\"\n#include \"vcos.h\"\n\n/**\n * \\file\n *\n * Reentrant Mutex API. You can take one of these mutexes even if you've already\n * taken it. Just to make sure.\n *\n * A re-entrant mutex may be slower on some platforms than a regular one.\n *\n * \\sa vcos_mutex.h\n *\n */\n\n/** Create a mutex.\n  *\n  * @param m      Filled in with mutex on return\n  * @param name   A non-null name for the mutex, used for diagnostics.\n  *\n  * @return VCOS_SUCCESS if mutex was created, or error code.\n  */\nVCOS_INLINE_DECL\nVCOS_STATUS_T vcos_reentrant_mutex_create(VCOS_REENTRANT_MUTEX_T *m, const char *name);\n\n/** Delete the mutex.\n  */\nVCOS_INLINE_DECL\nvoid vcos_reentrant_mutex_delete(VCOS_REENTRANT_MUTEX_T *m);\n\n/** Wait to claim the mutex. Must not have already been claimed by the current thread.\n  */\n#ifndef vcos_reentrant_mutexlock\nVCOS_INLINE_DECL\nvoid vcos_reentrant_mutex_lock(VCOS_REENTRANT_MUTEX_T *m);\n\n/** Release the mutex.\n  */\nVCOS_INLINE_DECL\nvoid vcos_reentrant_mutex_unlock(VCOS_REENTRANT_MUTEX_T *m);\n#endif\n\n\n#ifdef __cplusplus\n}\n#endif\n#endif\n\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vcos/vcos_semaphore.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n/*=============================================================================\nVideoCore OS Abstraction Layer - public header file\n=============================================================================*/\n\n#ifndef VCOS_SEMAPHORE_H\n#define VCOS_SEMAPHORE_H\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#include \"interface/vcos/vcos_types.h\"\n#ifndef VCOS_PLATFORM_H\n#include \"vcos.h\"\n#endif\n\n/**\n * \\file vcos_semaphore.h\n *\n * \\section sem Semaphores\n *\n * This provides counting semaphores. Semaphores are not re-entrant. On sensible\n * operating systems a semaphore can always be posted but can only be taken in \n * thread (not interrupt) context. Under Nucleus, a LISR cannot post a semaphore,\n * although it would not be hard to lift this restriction.\n *\n * \\subsection timeout Timeout\n *\n * On both Nucleus and ThreadX a semaphore can be taken with a timeout. This is\n * not supported by VCOS because it makes the non-timeout code considerably more\n * complicated (and hence slower). In the unlikely event that you need a timeout\n * with a semaphore, and you cannot simply redesign your code to avoid it, use\n * an event flag (vcos_event_flags.h).\n *\n * \\subsection sem_nucleus Changes from Nucleus:\n *\n *  Semaphores are always \"FIFO\" - i.e. sleeping threads are woken in FIFO order. That's\n *  because:\n *  \\arg there's no support for NU_PRIORITY in threadx (though it can be emulated, slowly)\n *  \\arg we don't appear to actually consciously use it - for example, Dispmanx uses\n *  it, but all threads waiting are the same priority.\n *         \n */\n\n/** \n  * \\brief Create a semaphore.\n  *\n  * Create a semaphore.\n  *\n  * @param sem   Pointer to memory to be initialized\n  * @param name  A name for this semaphore. The name may be truncated internally.\n  * @param count The initial count for the semaphore.\n  *\n  * @return VCOS_SUCCESS if the semaphore was created.\n  * \n  */\nVCOS_INLINE_DECL\nVCOS_STATUS_T vcos_semaphore_create(VCOS_SEMAPHORE_T *sem, const char *name, VCOS_UNSIGNED count);\n\n/**\n  * \\brief Wait on a semaphore.\n  *\n  * There is no timeout option on a semaphore, as adding this will slow down\n  * implementations on some platforms. If you need that kind of behaviour, use\n  * an event group.\n  *\n  * On most platforms this always returns VCOS_SUCCESS, and so would ideally be\n  * a void function, however some platforms allow a wait to be interrupted so\n  * it remains non-void.\n  *\n  * @param sem Semaphore to wait on\n  * @return VCOS_SUCCESS - semaphore was taken.\n  *         VCOS_EAGAIN  - could not take semaphore\n  *\n  */\nVCOS_INLINE_DECL\nVCOS_STATUS_T vcos_semaphore_wait(VCOS_SEMAPHORE_T *sem);\n\n/**\n  * \\brief Wait on a semaphore with a timeout.\n  *\n  * Note that this function may not be implemented on all\n  * platforms, and may not be efficient on all platforms\n  * (see comment in vcos_semaphore_wait)\n  *\n  * Try to obtain the semaphore. If it is already taken, return\n  * VCOS_EAGAIN.\n  * @param sem Semaphore to wait on\n  * @param timeout Number of milliseconds to wait before\n  *                returning if the semaphore can't be acquired.\n  * @return VCOS_SUCCESS - semaphore was taken.\n  *         VCOS_EAGAIN - could not take semaphore (i.e. timeout\n  *         expired)\n  *         VCOS_EINVAL - Some other error (most likely bad\n  *         parameters).\n  */\nVCOS_INLINE_DECL\nVCOS_STATUS_T vcos_semaphore_wait_timeout(VCOS_SEMAPHORE_T *sem, VCOS_UNSIGNED timeout);\n\n/**\n  * \\brief Try to wait for a semaphore.\n  *\n  * Try to obtain the semaphore. If it is already taken, return VCOS_TIMEOUT.\n  * @param sem Semaphore to wait on\n  * @return VCOS_SUCCESS - semaphore was taken.\n  *         VCOS_EAGAIN - could not take semaphore\n  */\nVCOS_INLINE_DECL\nVCOS_STATUS_T vcos_semaphore_trywait(VCOS_SEMAPHORE_T *sem);\n\n/**\n  * \\brief Post a semaphore.\n  *\n  * @param sem Semaphore to wait on\n  */\nVCOS_INLINE_DECL\nVCOS_STATUS_T vcos_semaphore_post(VCOS_SEMAPHORE_T *sem);\n\n/**\n  * \\brief Delete a semaphore, releasing any resources consumed by it.\n  *\n  * @param sem Semaphore to wait on\n  */\nVCOS_INLINE_DECL\nvoid vcos_semaphore_delete(VCOS_SEMAPHORE_T *sem);\n\n#ifdef __cplusplus\n}\n#endif\n#endif\n\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vcos/vcos_stdbool.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n#ifndef VCOS_STDBOOL_H\n#define VCOS_STDBOOL_H\n\n#ifndef __cplusplus\n\n#if defined(__STDC__) && (__STDC_VERSION__ >= 199901L)\n#include <stdbool.h>\n#else\n/* sizeof(bool) == 1. hopefully this matches up with c++ (so structures and\n * such containing bool are binary compatible), but the c++ standard doesn't\n * require sizeof(bool) == 1, so there's no guarantee */\ntypedef unsigned char bool;\nenum {\n   false,\n   true\n};\n#endif\n\n#endif /* __cplusplus */\n\n#endif\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vcos/vcos_stdint.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n#ifndef VCOS_STDINT_H\n#define VCOS_STDINT_H\n\n/** \\file\n * Attempt to provide the types defined in stdint.h.\n *\n * Except for use with lcc, this simply includes stdint.h, which should find\n * the system/toolchain version if present, otherwise falling back to the\n * version in interface/vcos/<platform>.\n */\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#if defined (VCMODS_LCC)\n\n#include <limits.h>\n\ntypedef signed   char      int8_t;\ntypedef unsigned char      uint8_t;\n\ntypedef signed   short     int16_t;\ntypedef unsigned short     uint16_t;\n\ntypedef signed   long      int32_t;\ntypedef unsigned long      uint32_t;\n\ntypedef int32_t            intptr_t;\ntypedef uint32_t           uintptr_t;\n\ntypedef int32_t            intmax_t;\ntypedef uint32_t           uintmax_t;\n\ntypedef int8_t             int_least8_t;\ntypedef int16_t            int_least16_t;\ntypedef int32_t            int_least32_t;\ntypedef uint8_t            uint_least8_t;\ntypedef uint16_t           uint_least16_t;\ntypedef uint32_t           uint_least32_t;\n\n#define INT8_MIN SCHAR_MIN\n#define INT8_MAX SCHAR_MAX\n#define UINT8_MAX UCHAR_MAX\n\n#define INT16_MIN SHRT_MIN\n#define INT16_MAX SHRT_MAX\n#define UINT16_MAX USHRT_MAX\n\n#define INT32_MIN LONG_MIN\n#define INT32_MAX LONG_MAX\n#define UINT32_MAX ULONG_MAX\n\n#define INTPTR_MIN INT32_MIN\n#define INTPTR_MAX INT32_MAX\n#define UINTPTR_MAX UINT32_MAX\n\n#define INTMAX_MIN INT32_MIN\n#define INTMAX_MAX INT32_MAX\n#define UINTMAX_MAX UINT32_MAX\n\n/* N.B. 64-bit integer types are not currently supported by lcc.\n * However, these symbols are referenced in header files included by files\n * compiled by lcc for VCE, so removing them would break the build.\n * The solution here then is to define them, as the correct size, but in a\n * way that should make them unusable in normal arithmetic operations.\n */\ntypedef struct { uint32_t a; uint32_t b; }  int64_t;\ntypedef struct { uint32_t a; uint32_t b; } uint64_t;\n\n#else\n\n#include <stdint.h>\n\n#endif\n\n#ifdef __cplusplus\n}\n#endif\n#endif /* VCOS_STDINT_H */\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vcos/vcos_string.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n/*=============================================================================\nVideoCore OS Abstraction Layer - public header file\n=============================================================================*/\n\n#ifndef VCOS_STRING_H\n#define VCOS_STRING_H\n\n/**\n  * \\file\n  *\n  * String functions.\n  *\n  */\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#include \"interface/vcos/vcos_types.h\"\n#include \"vcos.h\"\n\n#ifdef __KERNEL__\n#include <linux/string.h>\n#else\n#include <string.h>\n#endif\n\n/** Case insensitive string comparison.\n  *\n  */\n\nVCOS_INLINE_DECL\nint vcos_strcasecmp(const char *s1, const char *s2);\n\nVCOS_INLINE_DECL\nint vcos_strncasecmp(const char *s1, const char *s2, size_t n);\n\nVCOSPRE_ int VCOSPOST_ vcos_vsnprintf(char *buf, size_t buflen, const char *fmt, va_list ap);\n\nVCOSPRE_ int VCOSPOST_ vcos_snprintf(char *buf, size_t buflen, const char *fmt, ...);\n\n/** Like vsnprintf, except it places the output at the specified offset.\n  * Output is truncated to fit in buflen bytes, and is guaranteed to be NUL-terminated.\n  * Returns the string length before/without truncation.\n  */\nVCOSPRE_ size_t VCOSPOST_ vcos_safe_vsprintf(char *buf, size_t buflen, size_t offset, const char *fmt, va_list ap);\n\n#define VCOS_SAFE_VSPRINTF(buf, offset, fmt, ap) \\\n   vcos_safe_vsprintf(buf, sizeof(buf) + ((char (*)[sizeof(buf)])buf - &(buf)), offset, fmt, ap)\n\n/** Like snprintf, except it places the output at the specified offset.\n  * Output is truncated to fit in buflen bytes, and is guaranteed to be NUL-terminated.\n  * Returns the string length before/without truncation.\n  */\nVCOSPRE_ size_t VCOSPOST_ vcos_safe_sprintf(char *buf, size_t buflen, size_t offset, const char *fmt, ...);\n\n/* The Metaware compiler currently has a bug in its variadic macro handling which\n   causes it to append a spurious command to the end of its __VA_ARGS__ data.\n   Do not use until this has been fixed (and this comment has been deleted). */\n\n#define VCOS_SAFE_SPRINTF(buf, offset, ...) \\\n   vcos_safe_sprintf(buf, sizeof(buf) + ((char (*)[sizeof(buf)])buf - &(buf)), offset, __VA_ARGS__)\n\n/** Copies string src to dst at the specified offset.\n  * Output is truncated to fit in dstlen bytes, i.e. the string is at most\n  * (buflen - 1) characters long. Unlike strncpy, exactly one NUL is written\n  * to dst, which is always NUL-terminated.\n  * Returns the string length before/without truncation.\n  */\nVCOSPRE_ size_t VCOSPOST_ vcos_safe_strcpy(char *dst, const char *src, size_t dstlen, size_t offset);\n\n#define VCOS_SAFE_STRCPY(dst, src, offset) \\\n   vcos_safe_strcpy(dst, src, sizeof(dst) + ((char (*)[sizeof(dst)])dst - &(dst)), offset)\n\nVCOS_STATIC_INLINE\nint vcos_strlen(const char *s) { return (int)strlen(s); }\n\nVCOS_STATIC_INLINE\nint vcos_strcmp(const char *s1, const char *s2) { return strcmp(s1,s2); }\n\nVCOS_STATIC_INLINE\nint vcos_strncmp(const char *cs, const char *ct, size_t count) { return strncmp(cs, ct, count); }\n\nVCOS_STATIC_INLINE\nchar *vcos_strcpy(char *dst, const char *src) { return strcpy(dst, src); }\n\nVCOS_STATIC_INLINE\nchar *vcos_strncpy(char *dst, const char *src, size_t count) { return strncpy(dst, src, count); }\n\nVCOS_STATIC_INLINE\nvoid *vcos_memcpy(void *dst, const void *src, size_t n) {  memcpy(dst, src, n);  return dst;  }\n\nVCOS_STATIC_INLINE\nvoid *vcos_memset(void *p, int c, size_t n) { return memset(p, c, n); }\n\nVCOS_STATIC_INLINE\nint vcos_memcmp(const void *ptr1, const void *ptr2, size_t count) { return memcmp(ptr1, ptr2, count); }\n\n#ifdef __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vcos/vcos_thread.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n/*=============================================================================\nVideoCore OS Abstraction Layer - public header file\n=============================================================================*/\n\n#ifndef VCOS_THREAD_H\n#define VCOS_THREAD_H\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#include \"interface/vcos/vcos_types.h\"\n#include \"vcos.h\"\n\n/**\n * \\file vcos_thread.h\n *\n * \\section thread Threads\n *\n * Under Nucleus, a thread is created by NU_Create_Task, passing in the stack\n * and various other parameters. To stop the thread, NU_Terminate_Thread() and\n * NU_Delete_Thread() are called.\n *\n * Unfortunately it's not possible to emulate this API under some fairly common\n * operating systems. Under Windows you can't pass in the stack, and you can't\n * safely terminate a thread.\n *\n * Therefore, an API which is similar to the pthreads API is used instead. This\n * API can (mostly) be emulated under all interesting operating systems.\n *\n * Obviously this makes the code somewhat more complicated on VideoCore than it\n * would otherwise be - we end up with an extra mutex per thread, and some code\n * that waits for it. The benefit is that we have a single way of creating\n * threads that works consistently on all platforms (apart from stack supplying).\n *\n * \\subsection stack Stack\n *\n * It's still not possible to pass in the stack address, but this can be made\n * much more obvious in the API: the relevant function is missing and the\n * CPP symbol VCOS_CAN_SET_STACK_ADDR is zero rather than one.\n *\n * \\subsection thr_create Creating a thread\n *\n * The simplest way to create a thread is with vcos_thread_create() passing in a\n * NULL thread parameter argument. To wait for the thread to exit, call\n * vcos_thread_join().\n *\n * \\subsection back Backward compatibility\n *\n * To ease migration, a \"classic\" thread creation API is provided for code\n * that used to make use of Nucleus, vcos_thread_create_classic(). The\n * arguments are not exactly the same, as the PREEMPT parameter is dropped.\n *\n */\n\n#define VCOS_AFFINITY_CPU0    _VCOS_AFFINITY_CPU0\n#define VCOS_AFFINITY_CPU1    _VCOS_AFFINITY_CPU1\n#define VCOS_AFFINITY_MASK    _VCOS_AFFINITY_MASK\n#define VCOS_AFFINITY_DEFAULT _VCOS_AFFINITY_DEFAULT\n#define VCOS_AFFINITY_THISCPU _VCOS_AFFINITY_THISCPU\n\n/** Report whether or not we have an RTOS at all, and hence the ability to\n  * create threads.\n  */\nVCOSPRE_ int VCOSPOST_ vcos_have_rtos(void);\n\n/** Create a thread. It must be cleaned up by calling vcos_thread_join().\n  *\n  * @param thread   Filled in on return with thread\n  * @param name     A name for the thread. May be the empty string.\n  * @param attrs    Attributes; default attributes will be used if this is NULL.\n  * @param entry    Entry point.\n  * @param arg      Argument passed to the entry point.\n  */\nVCOSPRE_ VCOS_STATUS_T VCOSPOST_ vcos_thread_create(VCOS_THREAD_T *thread,\n                                                    const char *name,\n                                                    VCOS_THREAD_ATTR_T *attrs,\n                                                    VCOS_THREAD_ENTRY_FN_T entry,\n                                                    void *arg);\n\n/** Exit the thread from within the thread function itself.\n  * Resources must still be cleaned up via a call to thread_join().\n  *\n  * The thread can also be terminated by simply exiting the thread function.\n  *\n  * @param data Data passed to thread_join. May be NULL.\n  */\nVCOSPRE_ void VCOSPOST_ vcos_thread_exit(void *data);\n\n/** Wait for a thread to terminate and then clean up its resources.\n  *\n  * @param thread Thread to wait for\n  * @param pData  Updated to point at data provided in vcos_thread_exit or exit\n  * code of thread function.\n  */\nVCOSPRE_ void VCOSPOST_ vcos_thread_join(VCOS_THREAD_T *thread,\n                             void **pData);\n\n\n/**\n  * \\brief Create a thread using an API similar to the one \"traditionally\"\n  * used under Nucleus.\n  *\n  * This creates a thread which must be cleaned up by calling vcos_thread_join().\n  * The thread cannot be simply terminated (as in Nucleus and ThreadX) as thread\n  * termination is not universally supported.\n  *\n  * @param thread       Filled in with thread instance\n  * @param name         An optional name for the thread. NULL or \"\" may be used (but\n  *                     a name will aid in debugging).\n  * @param entry        Entry point\n  * @param arg          A single argument passed to the entry point function\n  * @param stack        Pointer to stack address\n  * @param stacksz      Size of stack in bytes\n  * @param priaff       Priority of task, between VCOS_PRI_LOW and VCOS_PRI_HIGH, ORed with the CPU affinity\n  * @param autostart    If non-zero the thread will start immediately.\n  * @param timeslice    Timeslice (system ticks) for this thread.\n  *\n  * @sa vcos_thread_terminate vcos_thread_delete\n  */\nVCOSPRE_ VCOS_STATUS_T VCOSPOST_ vcos_thread_create_classic(VCOS_THREAD_T *thread,\n                                                            const char *name,\n                                                            void *(*entry)(void *arg),\n                                                            void *arg,\n                                                            void *stack,\n                                                            VCOS_UNSIGNED stacksz,\n                                                            VCOS_UNSIGNED priaff,\n                                                            VCOS_UNSIGNED timeslice,\n                                                            VCOS_UNSIGNED autostart);\n\n/**\n  * \\brief Set a thread's priority\n  *\n  * Set the priority for a thread.\n  *\n  * @param thread  The thread\n  * @param pri     Thread priority in VCOS_PRI_MASK bits; affinity in VCOS_AFFINITY_MASK bits.\n  */\nVCOS_INLINE_DECL\nvoid vcos_thread_set_priority(VCOS_THREAD_T *thread, VCOS_UNSIGNED pri);\n\n/**\n  * \\brief Return the currently executing thread.\n  *\n  */\nVCOS_INLINE_DECL\nVCOS_THREAD_T *vcos_thread_current(void);\n\n/**\n  * \\brief Return the thread's priority.\n  */\nVCOS_INLINE_DECL\nVCOS_UNSIGNED vcos_thread_get_priority(VCOS_THREAD_T *thread);\n\n/**\n  * \\brief Return the thread's cpu affinity.\n  */\nVCOS_INLINE_DECL\nVCOS_UNSIGNED vcos_thread_get_affinity(VCOS_THREAD_T *thread);\n\n/**\n  * \\brief Set the thread's cpu affinity.\n  */\n\nVCOS_INLINE_DECL\nvoid vcos_thread_set_affinity(VCOS_THREAD_T *thread, VCOS_UNSIGNED affinity);\n\n/**\n  * \\brief Query whether we are in an interrupt.\n  *\n  * @return 1 if in interrupt context.\n  */\nVCOS_INLINE_DECL\nint vcos_in_interrupt(void);\n\n/**\n  * \\brief Sleep a while.\n  *\n  * @param ms Number of milliseconds to sleep for\n  *\n  * This may actually sleep a whole number of ticks.\n  */\nVCOS_INLINE_DECL\nvoid vcos_sleep(uint32_t ms);\n\n/**\n  * \\brief Return the value of the hardware microsecond counter.\n  *\n  */\nVCOS_INLINE_DECL\nuint32_t vcos_getmicrosecs(void);\n\nVCOS_INLINE_DECL\nuint64_t vcos_getmicrosecs64(void);\n\n#define vcos_get_ms() (vcos_getmicrosecs()/1000)\n\n/**\n  * \\brief Return a unique identifier for the current process\n  *\n  */\nVCOS_INLINE_DECL\nVCOS_UNSIGNED vcos_process_id_current(void);\n\n/** Relinquish this time slice. */\nVCOS_INLINE_DECL\nvoid vcos_thread_relinquish(void);\n\n/** Return the name of the given thread.\n  */\nVCOSPRE_ const char * VCOSPOST_ vcos_thread_get_name(const VCOS_THREAD_T *thread);\n\n/** Change preemption. This is almost certainly not what you want, as it won't\n  * work reliably in a multicore system: although you can affect the preemption\n  * on *this* core, you won't affect what's happening on the other core(s).\n  *\n  * It's mainly here to ease migration. If you're using it in new code, you\n  * probably need to think again.\n  *\n  * @param pe New preemption, VCOS_PREEMPT or VCOS_NO_PREEMPT\n  * @return Old value of preemption.\n  */\nVCOS_INLINE_DECL\nVCOS_UNSIGNED vcos_change_preemption(VCOS_UNSIGNED pe);\n\n/** Is a thread still running, or has it exited?\n  *\n  * Note: this exists for some fairly scary code in the video codec tests. Don't\n  * try to use it for anything else, as it may well not do what you expect.\n  *\n  * @param thread   thread to query\n  * @return non-zero if thread is running, or zero if it has exited.\n  */\nVCOS_INLINE_DECL\nint vcos_thread_running(VCOS_THREAD_T *thread);\n\n/** Resume a thread.\n  *\n  * @param thread thread to resume\n  */\nVCOS_INLINE_DECL\nvoid vcos_thread_resume(VCOS_THREAD_T *thread);\n\n/*\n * Internal APIs - may not always be present and should not be used in\n * client code.\n */\n\nextern void _vcos_task_timer_set(void (*pfn)(void*), void *, VCOS_UNSIGNED ms);\nextern void _vcos_task_timer_cancel(void);\n\n#ifdef __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vcos/vcos_thread_attr.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n/*=============================================================================\nVideoCore OS Abstraction Layer - thread attributes\n=============================================================================*/\n\n#ifndef VCOS_THREAD_ATTR_H\n#define VCOS_THREAD_ATTR_H\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/**\n * \\file\n *\n * Attributes for thread creation.\n *\n */\n\n/** Initialize thread attribute struct. This call does not allocate memory,\n  * and so cannot fail.\n  *\n  */\nVCOSPRE_ void VCOSPOST_ vcos_thread_attr_init(VCOS_THREAD_ATTR_T *attrs);\n\n/** Set the stack address and size. If not set, a stack will be allocated automatically.\n  *\n  * This can only be set on some platforms. It will always be possible to set the stack\n  * address on VideoCore, but on host platforms, support may well not be available.\n  */\n#if VCOS_CAN_SET_STACK_ADDR\nVCOS_INLINE_DECL\nvoid vcos_thread_attr_setstack(VCOS_THREAD_ATTR_T *attrs, void *addr, VCOS_UNSIGNED sz);\n#endif\n\n/** Set the stack size. If not set, a default size will be used. Attempting to call this after having\n  * set the stack location with vcos_thread_attr_setstack() will result in undefined behaviour.\n  */\nVCOS_INLINE_DECL\nvoid vcos_thread_attr_setstacksize(VCOS_THREAD_ATTR_T *attrs, VCOS_UNSIGNED sz);\n\n/** Set the task priority. If not set, a default value will be used.\n  */\nVCOS_INLINE_DECL\nvoid vcos_thread_attr_setpriority(VCOS_THREAD_ATTR_T *attrs, VCOS_UNSIGNED pri);\n\n/** Set the task cpu affinity. If not set, the default will be used.\n  */\nVCOS_INLINE_DECL\nvoid vcos_thread_attr_setaffinity(VCOS_THREAD_ATTR_T *attrs, VCOS_UNSIGNED aff);\n\n/** Set the timeslice. If not set the default will be used.\n  */\nVCOS_INLINE_DECL\nvoid vcos_thread_attr_settimeslice(VCOS_THREAD_ATTR_T *attrs, VCOS_UNSIGNED ts);\n\n/** The thread entry function takes (argc,argv), as per Nucleus, with\n  * argc being 0. This may be withdrawn in a future release and should not\n  * be used in new code.\n  */\nVCOS_INLINE_DECL\nvoid _vcos_thread_attr_setlegacyapi(VCOS_THREAD_ATTR_T *attrs, VCOS_UNSIGNED legacy);\n\nVCOS_INLINE_DECL\nvoid vcos_thread_attr_setautostart(VCOS_THREAD_ATTR_T *attrs, VCOS_UNSIGNED autostart);\n\n#ifdef __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vcos/vcos_timer.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n/*=============================================================================\nVideoCore OS Abstraction Layer - timer support\n=============================================================================*/\n\n#ifndef VCOS_TIMER_H\n#define VCOS_TIMER_H\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#include \"interface/vcos/vcos_types.h\"\n#ifndef VCOS_PLATFORM_H\n#include \"vcos.h\"\n#endif\n\n/** \\file vcos_timer.h\n  *\n  * Timers are single shot.\n  *\n  * Timer times are in milliseconds.\n  *\n  * \\note that timer callback functions are called from an arbitrary thread\n  * context. The expiration function should do its work as quickly as possible;\n  * blocking should be avoided.\n  *\n  * \\note On Windows, the separate function vcos_timer_init() must be called\n  * as timer initialization from DllMain is not possible.\n  */\n\n/** Perform timer subsystem initialization. This function is not needed\n  * on non-Windows platforms but is still present so that it can be\n  * called. On Windows it is needed because vcos_init() gets called\n  * from DLL initialization where it is not possible to create a\n  * time queue (deadlock occurs if you try).\n  *\n  * @return VCOS_SUCCESS on success. VCOS_EEXIST if this has already been called\n  * once. VCOS_ENOMEM if resource allocation failed.\n  */\nVCOSPRE_ VCOS_STATUS_T VCOSPOST_ vcos_timer_init(void);\n\n/** Create a timer in a disabled state.\n  *\n  * The timer is initially disabled.\n  *\n  * @param timer     timer handle\n  * @param name      name for timer\n  * @param expiration_routine function to call when timer expires\n  * @param context   context passed to expiration routine\n  *\n  */\nVCOS_INLINE_DECL\nVCOS_STATUS_T vcos_timer_create(VCOS_TIMER_T *timer,\n                                const char *name,\n                                void (*expiration_routine)(void *context),\n                                void *context);\n\n\n\n/** Start a timer running.\n  *\n  * Timer must be stopped.\n  *\n  * @param timer     timer handle\n  * @param delay     Delay to wait for, in ms\n  */\nVCOS_INLINE_DECL\nvoid vcos_timer_set(VCOS_TIMER_T *timer, VCOS_UNSIGNED delay);\n\n/** Stop an already running timer.\n  *\n  * @param timer     timer handle\n  */\nVCOS_INLINE_DECL\nvoid vcos_timer_cancel(VCOS_TIMER_T *timer);\n\n/** Stop a timer and restart it.\n  * @param timer     timer handle\n  * @param delay     delay in ms\n  */\nVCOS_INLINE_DECL\nvoid vcos_timer_reset(VCOS_TIMER_T *timer, VCOS_UNSIGNED delay);\n\nVCOS_INLINE_DECL\nvoid vcos_timer_delete(VCOS_TIMER_T *timer);\n\n#ifdef __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vcos/vcos_tls.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n/*=============================================================================\nVideoCore OS Abstraction Layer - thread local storage\n=============================================================================*/\n\n#ifndef VCOS_TLS_H\n#define VCOS_TLS_H\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#include \"interface/vcos/vcos_types.h\"\n#include \"vcos.h\"\n\n\n/** Create a new thread local storage data key visible to all threads in\n  * the current process.\n  *\n  * @param key    The key to create\n  */\nVCOS_INLINE_DECL\nVCOS_STATUS_T vcos_tls_create(VCOS_TLS_KEY_T *key);\n\n/** Delete an existing TLS data key.\n  */\nVCOS_INLINE_DECL\nvoid vcos_tls_delete(VCOS_TLS_KEY_T tls);\n\n/** Set the value seen by the current thread.\n  *\n  * @param key    The key to update\n  * @param v      The value to set for the current thread.\n  *\n  * @return VCOS_SUCCESS, or VCOS_ENOMEM if memory for this slot\n  * could not be allocated.\n  *\n  * If TLS is being emulated via VCOS then the memory required\n  * can be preallocated at thread creation time\n  */\nVCOS_INLINE_DECL\nVCOS_STATUS_T vcos_tls_set(VCOS_TLS_KEY_T tls, void *v);\n\n/** Get the value for the current thread.\n  *\n  * @param key    The key to update\n  *\n  * @return The current value for this thread.\n  */\nVCOS_INLINE_DECL\nvoid *vcos_tls_get(VCOS_TLS_KEY_T tls);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif\n\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vcos/vcos_types.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n/*=============================================================================\nVideoCore OS Abstraction Layer - basic types\n=============================================================================*/\n\n#ifndef VCOS_TYPES_H\n#define VCOS_TYPES_H\n\n#define VCOS_VERSION   1\n\n#include <stddef.h>\n#if defined(__unix__) && !defined(__ANDROID__)\n#include \"interface/vcos/pthreads/vcos_platform_types.h\"\n#else\n#include \"vcos_platform_types.h\"\n#endif\n#include \"interface/vcos/vcos_attr.h\"\n\n#if !defined(VCOSPRE_) || !defined(VCOSPOST_)\n#error VCOSPRE_ or VCOSPOST_ not defined!\n#endif\n\n/* Redefine these here; this means that existing header files can carry on\n * using the VCHPOST/VCHPRE macros rather than having huge changes, which\n * could cause nasty merge problems.\n */\n#ifndef VCHPOST_\n#define VCHPOST_ VCOSPOST_\n#endif\n#ifndef VCHPRE_\n#define VCHPRE_  VCOSPRE_\n#endif\n\n/** Entry function for a lowlevel thread.\n  *\n  * Returns void for consistency with Nucleus/ThreadX.\n  */\ntypedef void (*VCOS_LLTHREAD_ENTRY_FN_T)(void *);\n\n/** Thread entry point. Returns a void* for consistency\n  * with pthreads.\n  */\ntypedef void *(*VCOS_THREAD_ENTRY_FN_T)(void*);\n\n\n/* Error return codes - chosen to be similar to errno values */\ntypedef enum\n{\n   VCOS_SUCCESS,\n   VCOS_EAGAIN,\n   VCOS_ENOENT,\n   VCOS_ENOSPC,\n   VCOS_EINVAL,\n   VCOS_EACCESS,\n   VCOS_ENOMEM,\n   VCOS_ENOSYS,\n   VCOS_EEXIST,\n   VCOS_ENXIO,\n   VCOS_EINTR\n} VCOS_STATUS_T;\n\n/* Some compilers (MetaWare) won't inline with -g turned on, which then results\n * in a lot of code bloat. To overcome this, inline functions are forward declared\n * with the prefix VCOS_INLINE_DECL, and implemented with the prefix VCOS_INLINE_IMPL.\n *\n * That then means that in a release build, \"static inline\" can be used in the obvious\n * way, but in a debug build the implementations can be skipped in all but one file,\n * by using VCOS_INLINE_BODIES.\n *\n * VCOS_INLINE_DECL - put this at the start of an inline forward declaration of a VCOS\n * function.\n *\n * VCOS_INLINE_IMPL - put this at the start of an inlined implementation of a VCOS\n * function.\n *\n */\n\n/* VCOS_EXPORT - it turns out that in some circumstances we need the implementation of\n * a function even if it is usually inlined.\n *\n * In particular, if we have a codec that is usually provided in object form, if it\n * was built for a debug build it will be full of calls to vcos_XXX(). If this is used\n * in a *release* build, then there won't be any of these calls around in the main image\n * as they will all have been inlined. The problem also exists for vcos functions called\n * from assembler.\n *\n * VCOS_EXPORT ensures that the named function will be emitted as a regular (not static-inline)\n * function inside vcos_<platform>.c so that it can be linked against. Doing this for every\n * VCOS function would be a bit code-bloat-tastic, so it is only done for those that need it.\n *\n */\n\n#ifdef __cplusplus\n#define _VCOS_INLINE inline\n#else\n#define _VCOS_INLINE __inline\n#endif\n\n#if defined(NDEBUG)\n\n#ifdef __GNUC__\n# define VCOS_INLINE_DECL extern __inline__\n# define VCOS_INLINE_IMPL static __inline__\n#else\n# define VCOS_INLINE_DECL static _VCOS_INLINE   /* declare a func */\n# define VCOS_INLINE_IMPL static _VCOS_INLINE   /* implement a func inline */\n#endif\n\n# if defined(VCOS_WANT_IMPL)\n#  define VCOS_EXPORT\n# else\n#  define VCOS_EXPORT VCOS_INLINE_IMPL\n# endif /* VCOS_WANT_IMPL */\n\n#define VCOS_INLINE_BODIES\n\n#else /* NDEBUG */\n\n#if !defined(VCOS_INLINE_DECL)\n   #define VCOS_INLINE_DECL extern\n#endif\n#if !defined(VCOS_INLINE_IMPL)\n   #define VCOS_INLINE_IMPL\n#endif\n#define VCOS_EXPORT VCOS_INLINE_IMPL\n#endif\n\n#define VCOS_STATIC_INLINE static _VCOS_INLINE\n\n#if defined(__HIGHC__) || defined(__HIGHC_ANSI__)\n#define _VCOS_METAWARE\n#endif\n\n/** It seems that __FUNCTION__ isn't standard!\n  */\n#if __STDC_VERSION__ < 199901L\n# if __GNUC__ >= 2 || defined(__VIDEOCORE__)\n#  define VCOS_FUNCTION __FUNCTION__\n# else\n#  define VCOS_FUNCTION \"<unknown>\"\n# endif\n#else\n# define VCOS_FUNCTION __func__\n#endif\n\n#define _VCOS_MS_PER_TICK (1000/VCOS_TICKS_PER_SECOND)\n\n/* Convert a number of milliseconds to a tick count. Internal use only - fails to\n * convert VCOS_SUSPEND correctly.\n */\n#define _VCOS_MS_TO_TICKS(ms) (((ms)+_VCOS_MS_PER_TICK-1)/_VCOS_MS_PER_TICK)\n\n#define VCOS_TICKS_TO_MS(ticks) ((ticks) * _VCOS_MS_PER_TICK)\n\n/** VCOS version of DATESTR, from pcdisk.h. Used by the hostreq service.\n */\ntypedef struct vcos_datestr\n{\n   uint8_t       cmsec;              /**< Centesimal mili second */\n   uint16_t      date;               /**< Date */\n   uint16_t      time;               /**< Time */\n\n} VCOS_DATESTR;\n\n/* Compile-time assert - declares invalid array length if condition\n * not met, or array of length one if OK.\n */\n#define VCOS_CASSERT(e) extern char vcos_compile_time_check[1/(e)]\n\n#define vcos_min(x,y) ((x) < (y) ? (x) : (y))\n#define vcos_max(x,y) ((x) > (y) ? (x) : (y))\n\n/** Return the count of an array. FIXME: under gcc we could make\n * this report an error for pointers using __builtin_types_compatible().\n */\n#define vcos_countof(x) (sizeof((x)) / sizeof((x)[0]))\n\n/* for backward compatibility */\n#define countof(x) (sizeof((x)) / sizeof((x)[0]))\n\n#define VCOS_ALIGN_DOWN(p,n) (((ptrdiff_t)(p)) & ~((n)-1))\n#define VCOS_ALIGN_UP(p,n) VCOS_ALIGN_DOWN((ptrdiff_t)(p)+(n)-1,(n))\n\n#ifdef _MSC_VER\n   #define vcos_alignof(T) __alignof(T)\n#elif defined(__GNUC__)\n   #define vcos_alignof(T) __alignof__(T)\n#else\n   #define vcos_alignof(T) (sizeof(struct { T t; char ch; }) - sizeof(T))\n#endif\n\n/** bool_t is not a POSIX type so cannot rely on it. Define it here.\n  * It's not even defined in stdbool.h.\n  */\ntypedef int32_t vcos_bool_t;\ntypedef int32_t vcos_fourcc_t;\n\n#define VCOS_FALSE   0\n#define VCOS_TRUE    (!VCOS_FALSE)\n\n/** Mark unused arguments to keep compilers quiet */\n#define vcos_unused(x) (void)(x)\n\n/** For backward compatibility */\ntypedef vcos_fourcc_t fourcc_t;\ntypedef vcos_fourcc_t FOURCC_T;\n\n#ifdef __cplusplus\n#define VCOS_EXTERN_C_BEGIN extern \"C\" {\n#define VCOS_EXTERN_C_END }\n#else\n#define VCOS_EXTERN_C_BEGIN\n#define VCOS_EXTERN_C_END\n#endif\n\n/** Variable attribute indicating the variable must be emitted even if it appears unused. */\n#if defined(__GNUC__) || defined(_VCOS_METAWARE)\n# define VCOS_ATTR_USED  __attribute__ ((used))\n#else\n# define VCOS_ATTR_USED\n#endif\n\n/** Variable attribute requiring specific alignment. */\n#if defined(__GNUC__) || defined(_VCOS_METAWARE)\n# define VCOS_ATTR_ALIGNED(n)  __attribute__ ((aligned(n)))\n#else\n# define VCOS_ATTR_ALIGNED(n)\n#endif\n\n/** Define a function as a weak alias to another function.\n * @param ret_type     Function return type.\n * @param alias_name   Name of the alias.\n * @param param_list   Function parameter list, including the parentheses.\n * @param target_name  Target function (bare function name, not a string).\n */\n#if defined(__GNUC__) || defined(_VCOS_METAWARE)\n  /* N.B. gcc allows __attribute__ after parameter list, but hcvc seems to silently ignore it. */\n# define VCOS_WEAK_ALIAS(ret_type, alias_name, param_list, target_name) \\\n   __attribute__ ((weak, alias(#target_name))) ret_type alias_name param_list\n#else\n# define VCOS_WEAK_ALIAS(ret_type, alias, params, target)  VCOS_CASSERT(0)\n#endif\n\n/** Define a function as a weak alias to another function, specified as a string.\n * @param ret_type     Function return type.\n * @param alias_name   Name of the alias.\n * @param param_list   Function parameter list, including the parentheses.\n * @param target_name  Target function name as a string.\n * @note Prefer the use of VCOS_WEAK_ALIAS - it is likely to be more portable.\n *       Only use VCOS_WEAK_ALIAS_STR if you need to do pre-processor mangling of the target\n *       symbol.\n */\n#if defined(__GNUC__) || defined(_VCOS_METAWARE)\n  /* N.B. gcc allows __attribute__ after parameter list, but hcvc seems to silently ignore it. */\n# define VCOS_WEAK_ALIAS_STR(ret_type, alias_name, param_list, target_name) \\\n   __attribute__ ((weak, alias(target_name))) ret_type alias_name param_list\n#else\n# define VCOS_WEAK_ALIAS_STR(ret_type, alias, params, target)  VCOS_CASSERT(0)\n#endif\n\n#if defined(__GNUC__)\n#define VCOS_DEPRECATED(msg) __attribute__((deprecated(msg)))\n#else\n#define VCOS_DEPRECATED(msg)\n#endif\n\n#endif\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vctypes/vc_display_types.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n/*=============================================================================\nCommon image types used by the vc_image library.\n=============================================================================*/\n\n#ifndef INTERFACE_VC_DISPLAY_TYPES_H\n#define INTERFACE_VC_DISPLAY_TYPES_H\n\n//enums of display input format\ntypedef enum\n{\n   VCOS_DISPLAY_INPUT_FORMAT_INVALID = 0,\n   VCOS_DISPLAY_INPUT_FORMAT_RGB888,\n   VCOS_DISPLAY_INPUT_FORMAT_RGB565\n}\nVCOS_DISPLAY_INPUT_FORMAT_T;\n\n/** For backward compatibility */\n#define DISPLAY_INPUT_FORMAT_INVALID VCOS_DISPLAY_INPUT_FORMAT_INVALID\n#define DISPLAY_INPUT_FORMAT_RGB888  VCOS_DISPLAY_INPUT_FORMAT_RGB888\n#define DISPLAY_INPUT_FORMAT_RGB565  VCOS_DISPLAY_INPUT_FORMAT_RGB565\ntypedef VCOS_DISPLAY_INPUT_FORMAT_T DISPLAY_INPUT_FORMAT_T;\n\n// Enum determining how image data for 3D displays has to be supplied\ntypedef enum\n{\n   DISPLAY_3D_UNSUPPORTED = 0,   // default\n   DISPLAY_3D_INTERLEAVED,       // For autosteroscopic displays\n   DISPLAY_3D_SBS_FULL_AUTO,     // Side-By-Side, Full Width (also used by some autostereoscopic displays)\n   DISPLAY_3D_SBS_HALF_HORIZ,    // Side-By-Side, Half Width, Horizontal Subsampling (see HDMI spec)\n   DISPLAY_3D_TB_HALF,           // Top-bottom 3D\n   DISPLAY_3D_FRAME_PACKING,     // Frame Packed 3D\n   DISPLAY_3D_FRAME_SEQUENTIAL,  // Output left on even frames and right on odd frames (typically 120Hz)\n   DISPLAY_3D_FORMAT_MAX\n} DISPLAY_3D_FORMAT_T;\n\n//enums of display types\ntypedef enum\n{\n   DISPLAY_INTERFACE_MIN,\n   DISPLAY_INTERFACE_SMI,\n   DISPLAY_INTERFACE_DPI,\n   DISPLAY_INTERFACE_DSI,\n   DISPLAY_INTERFACE_LVDS,\n   DISPLAY_INTERFACE_MAX\n\n} DISPLAY_INTERFACE_T;\n\n/* display dither setting, used on B0 */\ntypedef enum {\n   DISPLAY_DITHER_NONE   = 0,   /* default if not set */\n   DISPLAY_DITHER_RGB666 = 1,\n   DISPLAY_DITHER_RGB565 = 2,\n   DISPLAY_DITHER_RGB555 = 3,\n   DISPLAY_DITHER_MAX\n} DISPLAY_DITHER_T;\n\n//info struct\ntypedef struct\n{\n   //type\n   DISPLAY_INTERFACE_T type;\n   //width / height\n   uint32_t width;\n   uint32_t height;\n   //output format\n   DISPLAY_INPUT_FORMAT_T input_format;\n   //interlaced?\n   uint32_t interlaced;\n   /* output dither setting (if required) */\n   DISPLAY_DITHER_T output_dither;\n   /* Pixel frequency */\n   uint32_t pixel_freq;\n   /* Line rate in lines per second */\n   uint32_t line_rate;\n   // Format required for image data for 3D displays\n   DISPLAY_3D_FORMAT_T format_3d;\n   // If display requires PV1 (e.g. DSI1), special config is required in HVS\n   uint32_t use_pixelvalve_1;\n   // Set for DSI displays which use video mode.\n   uint32_t dsi_video_mode;\n   // Select HVS channel (usually 0).\n   uint32_t hvs_channel;\n} DISPLAY_INFO_T;\n\n#endif /* __VC_INCLUDE_IMAGE_TYPES_H__ */\n\n\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vctypes/vc_image_types.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n// Common image types used by the vc_image library\n\n#ifndef INTERFACE_VC_IMAGE_TYPES_H\n#define INTERFACE_VC_IMAGE_TYPES_H\n\n/* This file gets included by the VCE compiler, which gets confused\n * easily by the VCOS headers. So cannot include vcos.h here.\n */\n#include \"interface/vcos/vcos_stdint.h\"\n\n/* We have so many rectangle types; let's try to introduce a common one. */\ntypedef struct tag_VC_RECT_T {\n   int32_t x;\n   int32_t y;\n   int32_t width;\n   int32_t height;\n} VC_RECT_T;\n\nstruct VC_IMAGE_T;\ntypedef struct VC_IMAGE_T VC_IMAGE_T;\n\n/* Types of image supported. */\n/* Please add any new types to the *end* of this list.  Also update\n * case_VC_IMAGE_ANY_xxx macros (below), and the vc_image_type_info table in\n * vc_image/vc_image_helper.c.\n */\ntypedef enum\n{\n   VC_IMAGE_MIN = 0, //bounds for error checking\n\n   VC_IMAGE_RGB565 = 1,\n   VC_IMAGE_1BPP,\n   VC_IMAGE_YUV420,\n   VC_IMAGE_48BPP,\n   VC_IMAGE_RGB888,\n   VC_IMAGE_8BPP,\n   VC_IMAGE_4BPP,    // 4bpp palettised image\n   VC_IMAGE_3D32,    /* A separated format of 16 colour/light shorts followed by 16 z values */\n   VC_IMAGE_3D32B,   /* 16 colours followed by 16 z values */\n   VC_IMAGE_3D32MAT, /* A separated format of 16 material/colour/light shorts followed by 16 z values */\n   VC_IMAGE_RGB2X9,   /* 32 bit format containing 18 bits of 6.6.6 RGB, 9 bits per short */\n   VC_IMAGE_RGB666,   /* 32-bit format holding 18 bits of 6.6.6 RGB */\n   VC_IMAGE_PAL4_OBSOLETE,     // 4bpp palettised image with embedded palette\n   VC_IMAGE_PAL8_OBSOLETE,     // 8bpp palettised image with embedded palette\n   VC_IMAGE_RGBA32,   /* RGB888 with an alpha byte after each pixel */ /* xxx: isn't it BEFORE each pixel? */\n   VC_IMAGE_YUV422,   /* a line of Y (32-byte padded), a line of U (16-byte padded), and a line of V (16-byte padded) */\n   VC_IMAGE_RGBA565,  /* RGB565 with a transparent patch */\n   VC_IMAGE_RGBA16,   /* Compressed (4444) version of RGBA32 */\n   VC_IMAGE_YUV_UV,   /* VCIII codec format */\n   VC_IMAGE_TF_RGBA32, /* VCIII T-format RGBA8888 */\n   VC_IMAGE_TF_RGBX32,  /* VCIII T-format RGBx8888 */\n   VC_IMAGE_TF_FLOAT, /* VCIII T-format float */\n   VC_IMAGE_TF_RGBA16, /* VCIII T-format RGBA4444 */\n   VC_IMAGE_TF_RGBA5551, /* VCIII T-format RGB5551 */\n   VC_IMAGE_TF_RGB565, /* VCIII T-format RGB565 */\n   VC_IMAGE_TF_YA88, /* VCIII T-format 8-bit luma and 8-bit alpha */\n   VC_IMAGE_TF_BYTE, /* VCIII T-format 8 bit generic sample */\n   VC_IMAGE_TF_PAL8, /* VCIII T-format 8-bit palette */\n   VC_IMAGE_TF_PAL4, /* VCIII T-format 4-bit palette */\n   VC_IMAGE_TF_ETC1, /* VCIII T-format Ericsson Texture Compressed */\n   VC_IMAGE_BGR888,  /* RGB888 with R & B swapped */\n   VC_IMAGE_BGR888_NP,  /* RGB888 with R & B swapped, but with no pitch, i.e. no padding after each row of pixels */\n   VC_IMAGE_BAYER,  /* Bayer image, extra defines which variant is being used */\n   VC_IMAGE_CODEC,  /* General wrapper for codec images e.g. JPEG from camera */\n   VC_IMAGE_YUV_UV32,   /* VCIII codec format */\n   VC_IMAGE_TF_Y8,   /* VCIII T-format 8-bit luma */\n   VC_IMAGE_TF_A8,   /* VCIII T-format 8-bit alpha */\n   VC_IMAGE_TF_SHORT,/* VCIII T-format 16-bit generic sample */\n   VC_IMAGE_TF_1BPP, /* VCIII T-format 1bpp black/white */\n   VC_IMAGE_OPENGL,\n   VC_IMAGE_YUV444I, /* VCIII-B0 HVS YUV 4:4:4 interleaved samples */\n   VC_IMAGE_YUV422PLANAR,  /* Y, U, & V planes separately (VC_IMAGE_YUV422 has them interleaved on a per line basis) */\n   VC_IMAGE_ARGB8888,   /* 32bpp with 8bit alpha at MS byte, with R, G, B (LS byte) */\n   VC_IMAGE_XRGB8888,   /* 32bpp with 8bit unused at MS byte, with R, G, B (LS byte) */\n\n   VC_IMAGE_YUV422YUYV,  /* interleaved 8 bit samples of Y, U, Y, V */\n   VC_IMAGE_YUV422YVYU,  /* interleaved 8 bit samples of Y, V, Y, U */\n   VC_IMAGE_YUV422UYVY,  /* interleaved 8 bit samples of U, Y, V, Y */\n   VC_IMAGE_YUV422VYUY,  /* interleaved 8 bit samples of V, Y, U, Y */\n\n   VC_IMAGE_RGBX32,      /* 32bpp like RGBA32 but with unused alpha */\n   VC_IMAGE_RGBX8888,    /* 32bpp, corresponding to RGBA with unused alpha */\n   VC_IMAGE_BGRX8888,    /* 32bpp, corresponding to BGRA with unused alpha */\n\n   VC_IMAGE_YUV420SP,    /* Y as a plane, then UV byte interleaved in plane with with same pitch, half height */\n   \n   VC_IMAGE_YUV444PLANAR,  /* Y, U, & V planes separately 4:4:4 */\n\n   VC_IMAGE_TF_U8,   /* T-format 8-bit U - same as TF_Y8 buf from U plane */\n   VC_IMAGE_TF_V8,   /* T-format 8-bit U - same as TF_Y8 buf from V plane */\n   \n   VC_IMAGE_MAX,     //bounds for error checking\n   VC_IMAGE_FORCE_ENUM_16BIT = 0xffff,\n} VC_IMAGE_TYPE_T;\n\n/* Image transformations (flips and 90 degree rotations).\n   These are made out of 3 primitives (transpose is done first).\n   These must match the DISPMAN and Media Player definitions. */\n\n#define TRANSFORM_HFLIP     (1<<0)\n#define TRANSFORM_VFLIP     (1<<1)\n#define TRANSFORM_TRANSPOSE (1<<2)\n\ntypedef enum {\n   VC_IMAGE_ROT0           = 0,\n   VC_IMAGE_MIRROR_ROT0    = TRANSFORM_HFLIP,\n   VC_IMAGE_MIRROR_ROT180  = TRANSFORM_VFLIP,\n   VC_IMAGE_ROT180         = TRANSFORM_HFLIP|TRANSFORM_VFLIP,\n   VC_IMAGE_MIRROR_ROT90   = TRANSFORM_TRANSPOSE,\n   VC_IMAGE_ROT270         = TRANSFORM_TRANSPOSE|TRANSFORM_HFLIP,\n   VC_IMAGE_ROT90          = TRANSFORM_TRANSPOSE|TRANSFORM_VFLIP,\n   VC_IMAGE_MIRROR_ROT270  = TRANSFORM_TRANSPOSE|TRANSFORM_HFLIP|TRANSFORM_VFLIP,\n} VC_IMAGE_TRANSFORM_T;\n\ntypedef enum\n{ //defined to be identical to register bits\n   VC_IMAGE_BAYER_RGGB     = 0,\n   VC_IMAGE_BAYER_GBRG     = 1,\n   VC_IMAGE_BAYER_BGGR     = 2,\n   VC_IMAGE_BAYER_GRBG     = 3\n} VC_IMAGE_BAYER_ORDER_T;\n\ntypedef enum\n{ //defined to be identical to register bits\n   VC_IMAGE_BAYER_RAW6     = 0,\n   VC_IMAGE_BAYER_RAW7     = 1,\n   VC_IMAGE_BAYER_RAW8     = 2,\n   VC_IMAGE_BAYER_RAW10    = 3,\n   VC_IMAGE_BAYER_RAW12    = 4,\n   VC_IMAGE_BAYER_RAW14    = 5,\n   VC_IMAGE_BAYER_RAW16    = 6,\n   VC_IMAGE_BAYER_RAW10_8  = 7,\n   VC_IMAGE_BAYER_RAW12_8  = 8,\n   VC_IMAGE_BAYER_RAW14_8  = 9,\n   VC_IMAGE_BAYER_RAW10L   = 11,\n   VC_IMAGE_BAYER_RAW12L   = 12,\n   VC_IMAGE_BAYER_RAW14L   = 13,\n   VC_IMAGE_BAYER_RAW16_BIG_ENDIAN = 14, \n   VC_IMAGE_BAYER_RAW4    = 15,\n} VC_IMAGE_BAYER_FORMAT_T;\n\n#endif /* __VC_INCLUDE_IMAGE_TYPES_H__ */\n\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vmcs_host/khronos/IL/OMX_Audio.h",
    "content": "/*\n * Copyright (c) 2008 The Khronos Group Inc. \n * \n * Permission is hereby granted, free of charge, to any person obtaining\n * a copy of this software and associated documentation files (the\n * \"Software\"), to deal in the Software without restriction, including\n * without limitation the rights to use, copy, modify, merge, publish,\n * distribute, sublicense, and/or sell copies of the Software, and to\n * permit persons to whom the Software is furnished to do so, subject\n * to the following conditions: \n * The above copyright notice and this permission notice shall be included\n * in all copies or substantial portions of the Software. \n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\n * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\n * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\n * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \n *\n */\n\n/** @file OMX_Audio.h - OpenMax IL version 1.1.2\n *  The structures needed by Audio components to exchange\n *  parameters and configuration data with the componenmilts.\n */\n\n#ifndef OMX_Audio_h\n#define OMX_Audio_h\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif /* __cplusplus */\n\n\n/* Each OMX header must include all required header files to allow the\n *  header to compile without errors.  The includes below are required\n *  for this header file to compile successfully \n */\n\n#include \"OMX_Core.h\"\n\n/** @defgroup midi MIDI\n * @ingroup audio\n */\n \n/** @defgroup effects Audio effects\n * @ingroup audio\n */\n\n/** @defgroup audio OpenMAX IL Audio Domain\n * Structures for OpenMAX IL Audio domain\n * @{\n */\n\n/** Enumeration used to define the possible audio codings.  \n *  If \"OMX_AUDIO_CodingUnused\" is selected, the coding selection must \n *  be done in a vendor specific way.  Since this is for an audio \n *  processing element this enum is relevant.  However, for another \n *  type of component other enums would be in this area.\n */\ntypedef enum OMX_AUDIO_CODINGTYPE {\n    OMX_AUDIO_CodingUnused = 0,  /**< Placeholder value when coding is N/A  */\n    OMX_AUDIO_CodingAutoDetect,  /**< auto detection of audio format */\n    OMX_AUDIO_CodingPCM,         /**< Any variant of PCM coding */\n    OMX_AUDIO_CodingADPCM,       /**< Any variant of ADPCM encoded data */\n    OMX_AUDIO_CodingAMR,         /**< Any variant of AMR encoded data */\n    OMX_AUDIO_CodingGSMFR,       /**< Any variant of GSM fullrate (i.e. GSM610) */\n    OMX_AUDIO_CodingGSMEFR,      /**< Any variant of GSM Enhanced Fullrate encoded data*/\n    OMX_AUDIO_CodingGSMHR,       /**< Any variant of GSM Halfrate encoded data */\n    OMX_AUDIO_CodingPDCFR,       /**< Any variant of PDC Fullrate encoded data */\n    OMX_AUDIO_CodingPDCEFR,      /**< Any variant of PDC Enhanced Fullrate encoded data */\n    OMX_AUDIO_CodingPDCHR,       /**< Any variant of PDC Halfrate encoded data */\n    OMX_AUDIO_CodingTDMAFR,      /**< Any variant of TDMA Fullrate encoded data (TIA/EIA-136-420) */\n    OMX_AUDIO_CodingTDMAEFR,     /**< Any variant of TDMA Enhanced Fullrate encoded data (TIA/EIA-136-410) */\n    OMX_AUDIO_CodingQCELP8,      /**< Any variant of QCELP 8kbps encoded data */\n    OMX_AUDIO_CodingQCELP13,     /**< Any variant of QCELP 13kbps encoded data */\n    OMX_AUDIO_CodingEVRC,        /**< Any variant of EVRC encoded data */\n    OMX_AUDIO_CodingSMV,         /**< Any variant of SMV encoded data */\n    OMX_AUDIO_CodingG711,        /**< Any variant of G.711 encoded data */\n    OMX_AUDIO_CodingG723,        /**< Any variant of G.723 dot 1 encoded data */\n    OMX_AUDIO_CodingG726,        /**< Any variant of G.726 encoded data */\n    OMX_AUDIO_CodingG729,        /**< Any variant of G.729 encoded data */\n    OMX_AUDIO_CodingAAC,         /**< Any variant of AAC encoded data */\n    OMX_AUDIO_CodingMP3,         /**< Any variant of MP3 encoded data */\n    OMX_AUDIO_CodingSBC,         /**< Any variant of SBC encoded data */\n    OMX_AUDIO_CodingVORBIS,      /**< Any variant of VORBIS encoded data */\n    OMX_AUDIO_CodingWMA,         /**< Any variant of WMA encoded data */\n    OMX_AUDIO_CodingRA,          /**< Any variant of RA encoded data */\n    OMX_AUDIO_CodingMIDI,        /**< Any variant of MIDI encoded data */\n    OMX_AUDIO_CodingKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_AUDIO_CodingVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n\n#define OMX_AUDIO_CodingFLAC_Supported 1\n    OMX_AUDIO_CodingFLAC,        /**< Any variant of FLAC */\n#define OMX_AUDIO_CodingDDP_Supported 1\n    OMX_AUDIO_CodingDDP,         /**< Any variant of Dolby Digital Plus */\n#define OMX_AUDIO_CodingDTS_Supported 1\n    OMX_AUDIO_CodingDTS,         /**< Any variant of DTS */\n#define OMX_AUDIO_CodingWMAPRO_Supported 1\n    OMX_AUDIO_CodingWMAPRO,      /**< Any variant of WMA Professional */\n#define OMX_AUDIO_CodingATRAC3_Supported 1\n    OMX_AUDIO_CodingATRAC3,      /**< Sony ATRAC-3 variants */\n#define OMX_AUDIO_CodingATRACX_Supported 1\n    OMX_AUDIO_CodingATRACX,      /**< Sony ATRAC-X variants */\n#define OMX_AUDIO_CodingATRACAAL_Supported 1\n    OMX_AUDIO_CodingATRACAAL,    /**< Sony ATRAC advanced-lossless variants  */\n\n    OMX_AUDIO_CodingMax = 0x7FFFFFFF\n} OMX_AUDIO_CODINGTYPE;\n\n\n/** The PortDefinition structure is used to define all of the parameters \n *  necessary for the compliant component to setup an input or an output audio \n *  path.  If additional information is needed to define the parameters of the\n *  port (such as frequency), additional structures must be sent such as the\n *  OMX_AUDIO_PARAM_PCMMODETYPE structure to supply the extra parameters for the port.\n */\ntypedef struct OMX_AUDIO_PORTDEFINITIONTYPE {\n    OMX_STRING cMIMEType;            /**< MIME type of data for the port */\n    OMX_NATIVE_DEVICETYPE pNativeRender; /** < platform specific reference\n                                               for an output device, \n                                               otherwise this field is 0 */\n    OMX_BOOL bFlagErrorConcealment;  /**< Turns on error concealment if it is \n                                          supported by the OMX component */\n    OMX_AUDIO_CODINGTYPE eEncoding;  /**< Type of data expected for this \n                                          port (e.g. PCM, AMR, MP3, etc) */\n} OMX_AUDIO_PORTDEFINITIONTYPE;\n\n\n/**  Port format parameter.  This structure is used to enumerate\n  *  the various data input/output format supported by the port.\n  */\ntypedef struct OMX_AUDIO_PARAM_PORTFORMATTYPE {\n    OMX_U32 nSize;                  /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion;       /**< OMX specification version information */\n    OMX_U32 nPortIndex;             /**< Indicates which port to set */\n    OMX_U32 nIndex;                 /**< Indicates the enumeration index for the format from 0x0 to N-1 */\n    OMX_AUDIO_CODINGTYPE eEncoding; /**< Type of data expected for this port (e.g. PCM, AMR, MP3, etc) */\n} OMX_AUDIO_PARAM_PORTFORMATTYPE;\n\n\n/** PCM mode type  */ \ntypedef enum OMX_AUDIO_PCMMODETYPE { \n    OMX_AUDIO_PCMModeLinear = 0,  /**< Linear PCM encoded data */ \n    OMX_AUDIO_PCMModeALaw,        /**< A law PCM encoded data (G.711) */ \n    OMX_AUDIO_PCMModeMULaw,       /**< Mu law PCM encoded data (G.711)  */ \n    OMX_AUDIO_PCMModeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_AUDIO_PCMModeVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_AUDIO_PCMModeMax = 0x7FFFFFFF \n} OMX_AUDIO_PCMMODETYPE; \n\n\ntypedef enum OMX_AUDIO_CHANNELTYPE {\n    OMX_AUDIO_ChannelNone = 0x0,    /**< Unused or empty */\n    OMX_AUDIO_ChannelLF   = 0x1,    /**< Left front */\n    OMX_AUDIO_ChannelRF   = 0x2,    /**< Right front */\n    OMX_AUDIO_ChannelCF   = 0x3,    /**< Center front */\n    OMX_AUDIO_ChannelLS   = 0x4,    /**< Left surround */\n    OMX_AUDIO_ChannelRS   = 0x5,    /**< Right surround */\n    OMX_AUDIO_ChannelLFE  = 0x6,    /**< Low frequency effects */\n    OMX_AUDIO_ChannelCS   = 0x7,    /**< Back surround */\n    OMX_AUDIO_ChannelLR   = 0x8,    /**< Left rear. */\n    OMX_AUDIO_ChannelRR   = 0x9,    /**< Right rear. */\n    OMX_AUDIO_ChannelKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_AUDIO_ChannelVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_AUDIO_ChannelMax  = 0x7FFFFFFF \n} OMX_AUDIO_CHANNELTYPE;\n\n#define OMX_AUDIO_MAXCHANNELS 16  /**< maximum number distinct audio channels that a buffer may contain */\n#define OMX_MIN_PCMPAYLOAD_MSEC 5 /**< Minimum audio buffer payload size for uncompressed (PCM) audio */\n\n/** PCM format description */ \ntypedef struct OMX_AUDIO_PARAM_PCMMODETYPE { \n    OMX_U32 nSize;                    /**< Size of this structure, in Bytes */ \n    OMX_VERSIONTYPE nVersion;         /**< OMX specification version information */ \n    OMX_U32 nPortIndex;               /**< port that this structure applies to */ \n    OMX_U32 nChannels;                /**< Number of channels (e.g. 2 for stereo) */ \n    OMX_NUMERICALDATATYPE eNumData;   /**< indicates PCM data as signed or unsigned */ \n    OMX_ENDIANTYPE eEndian;           /**< indicates PCM data as little or big endian */ \n    OMX_BOOL bInterleaved;            /**< True for normal interleaved data; false for \n                                           non-interleaved data (e.g. block data) */ \n    OMX_U32 nBitPerSample;            /**< Bit per sample */ \n    OMX_U32 nSamplingRate;            /**< Sampling rate of the source data.  Use 0 for \n                                           variable or unknown sampling rate. */ \n    OMX_AUDIO_PCMMODETYPE ePCMMode;   /**< PCM mode enumeration */ \n    OMX_AUDIO_CHANNELTYPE eChannelMapping[OMX_AUDIO_MAXCHANNELS]; /**< Slot i contains channel defined by eChannelMap[i] */\n\n} OMX_AUDIO_PARAM_PCMMODETYPE; \n\n\n/** Audio channel mode.  This is used by both AAC and MP3, although the names are more appropriate\n * for the MP3.  For example, JointStereo for MP3 is CouplingChannels for AAC. \n */\ntypedef enum OMX_AUDIO_CHANNELMODETYPE {\n    OMX_AUDIO_ChannelModeStereo = 0,  /**< 2 channels, the bitrate allocation between those \n                                          two channels changes accordingly to each channel information */\n    OMX_AUDIO_ChannelModeJointStereo, /**< mode that takes advantage of what is common between \n                                           2 channels for higher compression gain */\n    OMX_AUDIO_ChannelModeDual,        /**< 2 mono-channels, each channel is encoded with half \n                                           the bitrate of the overall bitrate */\n    OMX_AUDIO_ChannelModeMono,        /**< Mono channel mode */\n    OMX_AUDIO_ChannelModeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_AUDIO_ChannelModeVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_AUDIO_ChannelModeMax = 0x7FFFFFFF\n} OMX_AUDIO_CHANNELMODETYPE;\n\n\ntypedef enum OMX_AUDIO_MP3STREAMFORMATTYPE {\n    OMX_AUDIO_MP3StreamFormatMP1Layer3 = 0, /**< MP3 Audio MPEG 1 Layer 3 Stream format */\n    OMX_AUDIO_MP3StreamFormatMP2Layer3,     /**< MP3 Audio MPEG 2 Layer 3 Stream format */\n    OMX_AUDIO_MP3StreamFormatMP2_5Layer3,   /**< MP3 Audio MPEG2.5 Layer 3 Stream format */\n    OMX_AUDIO_MP3StreamFormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_AUDIO_MP3StreamFormatVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_AUDIO_MP3StreamFormatMax = 0x7FFFFFFF\n} OMX_AUDIO_MP3STREAMFORMATTYPE;\n\n/** MP3 params */\ntypedef struct OMX_AUDIO_PARAM_MP3TYPE {\n    OMX_U32 nSize;                 /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion;      /**< OMX specification version information */\n    OMX_U32 nPortIndex;            /**< port that this structure applies to */\n    OMX_U32 nChannels;             /**< Number of channels */\n    OMX_U32 nBitRate;              /**< Bit rate of the input data.  Use 0 for variable\n                                        rate or unknown bit rates */\n    OMX_U32 nSampleRate;           /**< Sampling rate of the source data.  Use 0 for\n                                        variable or unknown sampling rate. */\n    OMX_U32 nAudioBandWidth;       /**< Audio band width (in Hz) to which an encoder should\n                                        limit the audio signal. Use 0 to let encoder decide */\n    OMX_AUDIO_CHANNELMODETYPE eChannelMode;   /**< Channel mode enumeration */\n    OMX_AUDIO_MP3STREAMFORMATTYPE eFormat;  /**< MP3 stream format */\n} OMX_AUDIO_PARAM_MP3TYPE;\n\ntypedef enum OMX_AUDIO_DDPBITSTREAMID {\n   OMX_AUDIO_DDPBitStreamIdAC3 = 8,\n   OMX_AUDIO_DDPBitStreamIdEAC3 = 16,\n   OMX_AUDIO_DDPBitStreamIdKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n   OMX_AUDIO_DDPBitStreamIdVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n   OMX_AUDIO_DDPBitStreamIdMax = 0x7FFFFFFF\n} OMX_AUDIO_DDPBITSTREAMID;\n\ntypedef enum OMX_AUDIO_DDPBITSTREAMMODE {\n   OMX_AUDIO_DDPBitStreamModeCM = 0,   /**< DDP any main audio service: complete main (CM) */\n   OMX_AUDIO_DDPBitStreamModeME,       /**< DDP any main audio service: music and effects (ME) */\n   OMX_AUDIO_DDPBitStreamModeVI,       /**< DDP any associated service: visually impaired (VI) */\n   OMX_AUDIO_DDPBitStreamModeHI,       /**< DDP any associated service: hearing impaired (HI)  */\n   OMX_AUDIO_DDPBitStreamModeD,        /**< DDP any associated service: dialogue (D)           */\n   OMX_AUDIO_DDPBitStreamModeC,        /**< DDP any associated service: commentary (C)         */\n   OMX_AUDIO_DDPBitStreamModeE,        /**< DDP any associated service: emergency (E)          */\n   OMX_AUDIO_DDPBitStreamModeVO,       /**< DDP associated service: voice over (VO)            */\n   OMX_AUDIO_DDPBitStreamModeK,        /**< DDP main audio service: karaoke                    */\n   OMX_AUDIO_DDPBitStreamModeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n   OMX_AUDIO_DDPBitStreamModeVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n   OMX_AUDIO_DDPBitStreamModeMax = 0x7FFFFFFF\n} OMX_AUDIO_DDPBITSTREAMMODE;\n\ntypedef enum OMX_AUDIO_DDPDOLBYSURROUNDMODE {\n   OMX_AUDIO_DDPDolbySurroundModeNotIndicated = 0,               /**< Not indicated */\n   OMX_AUDIO_DDPDolbySurroundModeNotDolbySurround,               /**< Not Dolby Surround */\n   OMX_AUDIO_DDPDolbySurroundModeDolbySurroundEncoded,           /**< Dolby Surround encoded */\n   OMX_AUDIO_DDPDolbySurroundModeReserverd,                      /**< Reserved */\n   OMX_AUDIO_DDPDolbySurroundModeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n   OMX_AUDIO_DDPDolbySurroundModeVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n   OMX_AUDIO_DDPDolbySurroundModeMax = 0x7FFFFFFF\n} OMX_AUDIO_DDPDOLBYSURROUNDMODE;\n\n/** DDP params */\ntypedef struct OMX_AUDIO_PARAM_DDPTYPE {\n    OMX_U32 nSize;                 /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion;      /**< OMX specification version information */\n    OMX_U32 nPortIndex;            /**< port that this structure applies to */\n    OMX_U32 nChannels;             /**< Number of channels */\n    OMX_U32 nBitRate;              /**< Bit rate of the input data.  Use 0 for variable\n                                        rate or unknown bit rates */\n    OMX_U32 nSampleRate;           /**< Sampling rate of the source data. Use 0 for\n                                        variable or unknown sampling rate. */\n    OMX_AUDIO_DDPBITSTREAMID eBitStreamId;\n    OMX_AUDIO_DDPBITSTREAMMODE eBitStreamMode;\n    OMX_AUDIO_DDPDOLBYSURROUNDMODE eDolbySurroundMode;\n    OMX_AUDIO_CHANNELTYPE eChannelMapping[OMX_AUDIO_MAXCHANNELS]; /**< Slot i contains channel defined by eChannelMapping[i] */    \n} OMX_AUDIO_PARAM_DDPTYPE;\n\n/** DTS params */\ntypedef struct OMX_AUDIO_PARAM_DTSTYPE {\n    OMX_U32 nSize;                 /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion;      /**< OMX specification version information */\n    OMX_U32 nPortIndex;            /**< port that this structure applies to */\n    OMX_U32 nChannels;             /**< Number of channels */\n    OMX_U32 nBitRate;              /**< Bit rate of the input data.  Use 0 for variable\n                                        rate or unknown bit rates */\n    OMX_U32 nSampleRate;           /**< Sampling rate of the source data. Use 0 for\n                                        variable or unknown sampling rate. */\n    OMX_U32 nDtsType;              /** DTS type 1, 2, or 3. */\n    OMX_U32 nFormat;               /** DTS stream is either big/little endian and 16/14 bit packing */\n    OMX_U32 nDtsFrameSizeBytes;    /** DTS frame size in bytes */\n    OMX_AUDIO_CHANNELTYPE eChannelMapping[OMX_AUDIO_MAXCHANNELS]; /**< Slot i contains channel defined by eChannelMapping[i] */\n} OMX_AUDIO_PARAM_DTSTYPE;\n\ntypedef enum OMX_AUDIO_AACSTREAMFORMATTYPE {\n    OMX_AUDIO_AACStreamFormatMP2ADTS = 0, /**< AAC Audio Data Transport Stream 2 format */\n    OMX_AUDIO_AACStreamFormatMP4ADTS,     /**< AAC Audio Data Transport Stream 4 format */\n    OMX_AUDIO_AACStreamFormatMP4LOAS,     /**< AAC Low Overhead Audio Stream format */\n    OMX_AUDIO_AACStreamFormatMP4LATM,     /**< AAC Low overhead Audio Transport Multiplex */\n    OMX_AUDIO_AACStreamFormatADIF,        /**< AAC Audio Data Interchange Format */\n    OMX_AUDIO_AACStreamFormatMP4FF,       /**< AAC inside MPEG-4/ISO File Format */\n    OMX_AUDIO_AACStreamFormatRAW,         /**< AAC Raw Format */\n    OMX_AUDIO_AACStreamFormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_AUDIO_AACStreamFormatVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_AUDIO_AACStreamFormatMax = 0x7FFFFFFF\n} OMX_AUDIO_AACSTREAMFORMATTYPE;\n\n\n/** AAC mode type.  Note that the term profile is used with the MPEG-2\n * standard and the term object type and profile is used with MPEG-4 */\ntypedef enum OMX_AUDIO_AACPROFILETYPE{\n  OMX_AUDIO_AACObjectNull = 0,      /**< Null, not used */\n  OMX_AUDIO_AACObjectMain = 1,      /**< AAC Main object */\n  OMX_AUDIO_AACObjectLC,            /**< AAC Low Complexity object (AAC profile) */\n  OMX_AUDIO_AACObjectSSR,           /**< AAC Scalable Sample Rate object */\n  OMX_AUDIO_AACObjectLTP,           /**< AAC Long Term Prediction object */\n  OMX_AUDIO_AACObjectHE,            /**< AAC High Efficiency (object type SBR, HE-AAC profile) */\n  OMX_AUDIO_AACObjectScalable,      /**< AAC Scalable object */\n  OMX_AUDIO_AACObjectERLC = 17,     /**< ER AAC Low Complexity object (Error Resilient AAC-LC) */\n  OMX_AUDIO_AACObjectLD = 23,       /**< AAC Low Delay object (Error Resilient) */\n  OMX_AUDIO_AACObjectHE_PS = 29,    /**< AAC High Efficiency with Parametric Stereo coding (HE-AAC v2, object type PS) */\n  OMX_AUDIO_AACObjectKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n  OMX_AUDIO_AACObjectVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n  OMX_AUDIO_AACObjectMax = 0x7FFFFFFF\n} OMX_AUDIO_AACPROFILETYPE;\n\n\n/** AAC tool usage (for nAACtools in OMX_AUDIO_PARAM_AACPROFILETYPE).\n * Required for encoder configuration and optional as decoder info output.\n * For MP3, OMX_AUDIO_CHANNELMODETYPE is sufficient. */\n#define OMX_AUDIO_AACToolNone 0x00000000 /**< no AAC tools allowed (encoder config) or active (decoder info output) */\n#define OMX_AUDIO_AACToolMS   0x00000001 /**< MS: Mid/side joint coding tool allowed or active */\n#define OMX_AUDIO_AACToolIS   0x00000002 /**< IS: Intensity stereo tool allowed or active */\n#define OMX_AUDIO_AACToolTNS  0x00000004 /**< TNS: Temporal Noise Shaping tool allowed or active */\n#define OMX_AUDIO_AACToolPNS  0x00000008 /**< PNS: MPEG-4 Perceptual Noise substitution tool allowed or active */\n#define OMX_AUDIO_AACToolLTP  0x00000010 /**< LTP: MPEG-4 Long Term Prediction tool allowed or active */\n#define OMX_AUDIO_AACToolAll  0x7FFFFFFF /**< all AAC tools allowed or active (*/\n\n/** MPEG-4 AAC error resilience (ER) tool usage (for nAACERtools in OMX_AUDIO_PARAM_AACPROFILETYPE).\n * Required for ER encoder configuration and optional as decoder info output */\n#define OMX_AUDIO_AACERNone  0x00000000  /**< no AAC ER tools allowed/used */\n#define OMX_AUDIO_AACERVCB11 0x00000001  /**< VCB11: Virtual Code Books for AAC section data */\n#define OMX_AUDIO_AACERRVLC  0x00000002  /**< RVLC: Reversible Variable Length Coding */\n#define OMX_AUDIO_AACERHCR   0x00000004  /**< HCR: Huffman Codeword Reordering */\n#define OMX_AUDIO_AACERAll   0x7FFFFFFF  /**< all AAC ER tools allowed/used */\n\n\n/** AAC params */\ntypedef struct OMX_AUDIO_PARAM_AACPROFILETYPE {\n    OMX_U32 nSize;                 /**< Size of this structure, in Bytes */\n    OMX_VERSIONTYPE nVersion;      /**< OMX specification version information */\n    OMX_U32 nPortIndex;            /**< Port that this structure applies to */\n    OMX_U32 nChannels;             /**< Number of channels */\n    OMX_U32 nSampleRate;           /**< Sampling rate of the source data.  Use 0 for\n                                        variable or unknown sampling rate. */\n    OMX_U32 nBitRate;              /**< Bit rate of the input data.  Use 0 for variable\n                                        rate or unknown bit rates */\n    OMX_U32 nAudioBandWidth;       /**< Audio band width (in Hz) to which an encoder should\n                                        limit the audio signal. Use 0 to let encoder decide */\n    OMX_U32 nFrameLength;          /**< Frame length (in audio samples per channel) of the codec.\n                                        Can be 1024 or 960 (AAC-LC), 2048 (HE-AAC), 480 or 512 (AAC-LD).\n                                        Use 0 to let encoder decide */\n    OMX_U32 nAACtools;             /**< AAC tool usage */\n    OMX_U32 nAACERtools;           /**< MPEG-4 AAC error resilience tool usage */\n    OMX_AUDIO_AACPROFILETYPE eAACProfile;   /**< AAC profile enumeration */\n    OMX_AUDIO_AACSTREAMFORMATTYPE eAACStreamFormat; /**< AAC stream format enumeration */\n    OMX_AUDIO_CHANNELMODETYPE eChannelMode;   /**< Channel mode enumeration */\n} OMX_AUDIO_PARAM_AACPROFILETYPE;\n\n\n/** VORBIS params */\ntypedef struct OMX_AUDIO_PARAM_VORBISTYPE {\n    OMX_U32 nSize;            /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion; /**< OMX specification version information */\n    OMX_U32 nPortIndex;       /**< port that this structure applies to */\n    OMX_U32 nChannels;        /**< Number of channels */\n    OMX_U32 nBitRate;         /**< Bit rate of the encoded data data.  Use 0 for variable\n                                   rate or unknown bit rates. Encoding is set to the\n                                   bitrate closest to specified  value (in bps) */\n    OMX_U32 nMinBitRate;      /**< Sets minimum bitrate (in bps). */\n    OMX_U32 nMaxBitRate;      /**< Sets maximum bitrate (in bps). */\n\n    OMX_U32 nSampleRate;      /**< Sampling rate of the source data.  Use 0 for\n                                   variable or unknown sampling rate. */\n    OMX_U32 nAudioBandWidth;  /**< Audio band width (in Hz) to which an encoder should\n                                   limit the audio signal. Use 0 to let encoder decide */\n    OMX_S32 nQuality;\t\t  /**< Sets encoding quality to n, between -1 (low) and 10 (high).\n                                   In the default mode of operation, the quality level is 3.\n                                   Normal quality range is 0 - 10. */\n    OMX_BOOL bManaged;\t\t  /**< Set  bitrate  management  mode. This turns off the\n                                   normal VBR encoding, but allows hard or soft bitrate\n                                   constraints to be enforced by the encoder. This mode can\n                                   be slower, and may also be lower quality. It is\n                                   primarily useful for streaming. */\n    OMX_BOOL bDownmix;\t\t  /**< Downmix input from stereo to mono (has no effect on \n                                   non-stereo streams). Useful for lower-bitrate encoding. */     \n} OMX_AUDIO_PARAM_VORBISTYPE;\n\n\n/** WMA Version */\ntypedef enum OMX_AUDIO_WMAFORMATTYPE {\n  OMX_AUDIO_WMAFormatUnused = 0, /**< format unused or unknown */\n  OMX_AUDIO_WMAFormat7,          /**< Windows Media Audio format 7 */\n  OMX_AUDIO_WMAFormat8,          /**< Windows Media Audio format 8 */\n  OMX_AUDIO_WMAFormat9,          /**< Windows Media Audio format 9 */\n  OMX_AUDIO_WMAFormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n  OMX_AUDIO_WMAFormatVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n  OMX_AUDIO_WMAFormatMax = 0x7FFFFFFF\n} OMX_AUDIO_WMAFORMATTYPE;\n\n\n/** WMA Profile */\ntypedef enum OMX_AUDIO_WMAPROFILETYPE {\n  OMX_AUDIO_WMAProfileUnused = 0,  /**< profile unused or unknown */\n  OMX_AUDIO_WMAProfileL1,          /**< Windows Media audio version 9 profile L1 */\n  OMX_AUDIO_WMAProfileL2,          /**< Windows Media audio version 9 profile L2 */\n  OMX_AUDIO_WMAProfileL3,          /**< Windows Media audio version 9 profile L3 */\n  OMX_AUDIO_WMAProfileKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n  OMX_AUDIO_WMAProfileVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n  OMX_AUDIO_WMAProfileMax = 0x7FFFFFFF\n} OMX_AUDIO_WMAPROFILETYPE;\n\n\n/** WMA params */\ntypedef struct OMX_AUDIO_PARAM_WMATYPE {\n    OMX_U32 nSize;            /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion; /**< OMX specification version information */\n    OMX_U32 nPortIndex;       /**< port that this structure applies to */\n    OMX_U16 nChannels;        /**< Number of channels */\n    OMX_U32 nBitRate;         /**< Bit rate of the input data.  Use 0 for variable\n                                   rate or unknown bit rates */\n    OMX_AUDIO_WMAFORMATTYPE eFormat; /**< Version of WMA stream / data */\n\tOMX_AUDIO_WMAPROFILETYPE eProfile;  /**< Profile of WMA stream / data */\n    OMX_U32 nSamplingRate;    /**< Sampling rate of the source data */\n    OMX_U16 nBlockAlign;      /**< is the block alignment, or block size, in bytes of the audio codec */\n    OMX_U16 nEncodeOptions;   /**< WMA Type-specific data */\n    OMX_U32 nSuperBlockAlign; /**< WMA Type-specific data */\n} OMX_AUDIO_PARAM_WMATYPE;\n\n/** \n * RealAudio format\n */\ntypedef enum OMX_AUDIO_RAFORMATTYPE {\n    OMX_AUDIO_RAFormatUnused = 0, /**< Format unused or unknown */\n    OMX_AUDIO_RA8,                /**< RealAudio 8 codec */\n    OMX_AUDIO_RA9,                /**< RealAudio 9 codec */\n    OMX_AUDIO_RA10_AAC,           /**< MPEG-4 AAC codec for bitrates of more than 128kbps */\n    OMX_AUDIO_RA10_CODEC,         /**< RealAudio codec for bitrates less than 128 kbps */\n    OMX_AUDIO_RA10_LOSSLESS,      /**< RealAudio Lossless */\n    OMX_AUDIO_RA10_MULTICHANNEL,  /**< RealAudio Multichannel */\n    OMX_AUDIO_RA10_VOICE,         /**< RealAudio Voice for bitrates below 15 kbps */\n    OMX_AUDIO_RAFormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_AUDIO_RAFormatVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_VIDEO_RAFormatMax = 0x7FFFFFFF\n} OMX_AUDIO_RAFORMATTYPE;\n\n/** RA (Real Audio) params */ \ntypedef struct OMX_AUDIO_PARAM_RATYPE { \n    OMX_U32 nSize;              /**< Size of this structure, in Bytes */ \n    OMX_VERSIONTYPE nVersion;   /**< OMX specification version information */ \n    OMX_U32 nPortIndex;         /**< Port that this structure applies to */ \n    OMX_U32 nChannels;          /**< Number of channels */ \n    OMX_U32 nSamplingRate;      /**< is the sampling rate of the source data */ \n    OMX_U32 nBitsPerFrame;      /**< is the value for bits per frame  */ \n    OMX_U32 nSamplePerFrame;    /**< is the value for samples per frame */ \n    OMX_U32 nCouplingQuantBits; /**< is the number of coupling quantization bits in the stream */ \n    OMX_U32 nCouplingStartRegion;   /**< is the coupling start region in the stream  */ \n    OMX_U32 nNumRegions;        /**< is the number of regions value */ \n    OMX_AUDIO_RAFORMATTYPE eFormat; /**< is the RealAudio audio format */\n} OMX_AUDIO_PARAM_RATYPE; \n\n\n/** SBC Allocation Method Type */\ntypedef enum OMX_AUDIO_SBCALLOCMETHODTYPE {\n  OMX_AUDIO_SBCAllocMethodLoudness, /**< Loudness allocation method */\n  OMX_AUDIO_SBCAllocMethodSNR,      /**< SNR allocation method */\n  OMX_AUDIO_SBCAllocMethodKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n  OMX_AUDIO_SBCAllocMethodVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n  OMX_AUDIO_SBCAllocMethodMax = 0x7FFFFFFF\n} OMX_AUDIO_SBCALLOCMETHODTYPE;\n\n\n/** SBC params */\ntypedef struct OMX_AUDIO_PARAM_SBCTYPE {\n    OMX_U32 nSize;             /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion;  /**< OMX specification version information */\n    OMX_U32 nPortIndex;        /**< port that this structure applies to */\n    OMX_U32 nChannels;         /**< Number of channels */\n    OMX_U32 nBitRate;          /**< Bit rate of the input data.  Use 0 for variable\n                                    rate or unknown bit rates */\n    OMX_U32 nSampleRate;       /**< Sampling rate of the source data.  Use 0 for\n                                    variable or unknown sampling rate. */\n    OMX_U32 nBlocks;           /**< Number of blocks */\n    OMX_U32 nSubbands;         /**< Number of subbands */\n    OMX_U32 nBitPool;          /**< Bitpool value */\n    OMX_BOOL bEnableBitrate;   /**< Use bitrate value instead of bitpool */\n    OMX_AUDIO_CHANNELMODETYPE eChannelMode; /**< Channel mode enumeration */\n    OMX_AUDIO_SBCALLOCMETHODTYPE eSBCAllocType;   /**< SBC Allocation method type */\n} OMX_AUDIO_PARAM_SBCTYPE;\n\n\n/** ADPCM stream format parameters */ \ntypedef struct OMX_AUDIO_PARAM_ADPCMTYPE { \n    OMX_U32 nSize;              /**< size of the structure in bytes */ \n    OMX_VERSIONTYPE nVersion;   /**< OMX specification version information */ \n    OMX_U32 nPortIndex;         /**< port that this structure applies to */ \n    OMX_U32 nChannels;          /**< Number of channels in the data stream (not \n                                     necessarily the same as the number of channels \n                                     to be rendered. */ \n    OMX_U32 nBitsPerSample;     /**< Number of bits in each sample */ \n    OMX_U32 nSampleRate;        /**< Sampling rate of the source data.  Use 0 for \n                                    variable or unknown sampling rate. */ \n} OMX_AUDIO_PARAM_ADPCMTYPE; \n\n\n/** G723 rate */\ntypedef enum OMX_AUDIO_G723RATE {\n    OMX_AUDIO_G723ModeUnused = 0,  /**< AMRNB Mode unused / unknown */\n    OMX_AUDIO_G723ModeLow,         /**< 5300 bps */\n    OMX_AUDIO_G723ModeHigh,        /**< 6300 bps */\n    OMX_AUDIO_G723ModeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_AUDIO_G723ModeVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_AUDIO_G723ModeMax = 0x7FFFFFFF\n} OMX_AUDIO_G723RATE;\n\n\n/** G723 - Sample rate must be 8 KHz */\ntypedef struct OMX_AUDIO_PARAM_G723TYPE { \n    OMX_U32 nSize;                /**< size of the structure in bytes */ \n    OMX_VERSIONTYPE nVersion;     /**< OMX specification version information */ \n    OMX_U32 nPortIndex;           /**< port that this structure applies to */ \n    OMX_U32 nChannels;            /**< Number of channels in the data stream (not \n                                       necessarily the same as the number of channels \n                                       to be rendered. */ \n    OMX_BOOL bDTX;                /**< Enable Discontinuous Transmisssion */ \n    OMX_AUDIO_G723RATE eBitRate;  /**< todo: Should this be moved to a config? */\n    OMX_BOOL bHiPassFilter;       /**< Enable High Pass Filter */ \n    OMX_BOOL bPostFilter;         /**< Enable Post Filter */ \n} OMX_AUDIO_PARAM_G723TYPE; \n\n\n/** ITU G726 (ADPCM) rate */\ntypedef enum OMX_AUDIO_G726MODE {\n    OMX_AUDIO_G726ModeUnused = 0,  /**< G726 Mode unused / unknown */\n    OMX_AUDIO_G726Mode16,          /**< 16 kbps */\n    OMX_AUDIO_G726Mode24,          /**< 24 kbps */\n    OMX_AUDIO_G726Mode32,          /**< 32 kbps, most common rate, also G721 */\n    OMX_AUDIO_G726Mode40,          /**< 40 kbps */\n    OMX_AUDIO_G726ModeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_AUDIO_G726ModeVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_AUDIO_G726ModeMax = 0x7FFFFFFF\n} OMX_AUDIO_G726MODE;\n\n\n/** G.726 stream format parameters - must be at 8KHz */ \ntypedef struct OMX_AUDIO_PARAM_G726TYPE { \n    OMX_U32 nSize;              /**< size of the structure in bytes */ \n    OMX_VERSIONTYPE nVersion;   /**< OMX specification version information */ \n    OMX_U32 nPortIndex;         /**< port that this structure applies to */ \n    OMX_U32 nChannels;          /**< Number of channels in the data stream (not \n                                     necessarily the same as the number of channels \n                                     to be rendered. */ \n     OMX_AUDIO_G726MODE eG726Mode;\n} OMX_AUDIO_PARAM_G726TYPE; \n\n\n/** G729 coder type */\ntypedef enum OMX_AUDIO_G729TYPE {\n    OMX_AUDIO_G729 = 0,           /**< ITU G.729  encoded data */\n    OMX_AUDIO_G729A,              /**< ITU G.729 annex A  encoded data */\n    OMX_AUDIO_G729B,              /**< ITU G.729 with annex B encoded data */\n    OMX_AUDIO_G729AB,             /**< ITU G.729 annexes A and B encoded data */\n    OMX_AUDIO_G729KhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_AUDIO_G729VendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_AUDIO_G729Max = 0x7FFFFFFF\n} OMX_AUDIO_G729TYPE;\n\n\n/** G729 stream format parameters - fixed 6KHz sample rate */\ntypedef struct OMX_AUDIO_PARAM_G729TYPE {\n    OMX_U32 nSize;            /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion; /**< OMX specification version information */\n    OMX_U32 nPortIndex;       /**< port that this structure applies to */\n    OMX_U32 nChannels;        /**< Number of channels in the data stream (not\n                                   necessarily the same as the number of channels\n                                   to be rendered. */\n    OMX_BOOL bDTX;            /**< Enable Discontinuous Transmisssion */\n    OMX_AUDIO_G729TYPE eBitType;\n} OMX_AUDIO_PARAM_G729TYPE;\n\n\n/** AMR Frame format */ \ntypedef enum OMX_AUDIO_AMRFRAMEFORMATTYPE { \n    OMX_AUDIO_AMRFrameFormatConformance = 0,  /**< Frame Format is AMR Conformance \n                                                   (Standard) Format */ \n    OMX_AUDIO_AMRFrameFormatIF1,              /**< Frame Format is AMR Interface \n                                                   Format 1 */ \n    OMX_AUDIO_AMRFrameFormatIF2,              /**< Frame Format is AMR Interface \n                                                   Format 2*/ \n    OMX_AUDIO_AMRFrameFormatFSF,              /**< Frame Format is AMR File Storage \n                                                   Format */ \n    OMX_AUDIO_AMRFrameFormatRTPPayload,       /**< Frame Format is AMR Real-Time \n                                                   Transport Protocol Payload Format */ \n    OMX_AUDIO_AMRFrameFormatITU,              /**< Frame Format is ITU Format (added at Motorola request) */ \n    OMX_AUDIO_AMRFrameFormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_AUDIO_AMRFrameFormatVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_AUDIO_AMRFrameFormatMax = 0x7FFFFFFF \n} OMX_AUDIO_AMRFRAMEFORMATTYPE; \n\n\n/** AMR band mode */\ntypedef enum OMX_AUDIO_AMRBANDMODETYPE {\n    OMX_AUDIO_AMRBandModeUnused = 0,          /**< AMRNB Mode unused / unknown */\n    OMX_AUDIO_AMRBandModeNB0,                 /**< AMRNB Mode 0 =  4750 bps */\n    OMX_AUDIO_AMRBandModeNB1,                 /**< AMRNB Mode 1 =  5150 bps */\n    OMX_AUDIO_AMRBandModeNB2,                 /**< AMRNB Mode 2 =  5900 bps */ \n    OMX_AUDIO_AMRBandModeNB3,                 /**< AMRNB Mode 3 =  6700 bps */\n    OMX_AUDIO_AMRBandModeNB4,                 /**< AMRNB Mode 4 =  7400 bps */\n    OMX_AUDIO_AMRBandModeNB5,                 /**< AMRNB Mode 5 =  7950 bps */\n    OMX_AUDIO_AMRBandModeNB6,                 /**< AMRNB Mode 6 = 10200 bps */\n    OMX_AUDIO_AMRBandModeNB7,                 /**< AMRNB Mode 7 = 12200 bps */\n    OMX_AUDIO_AMRBandModeWB0,                 /**< AMRWB Mode 0 =  6600 bps */\n    OMX_AUDIO_AMRBandModeWB1,                 /**< AMRWB Mode 1 =  8850 bps */\n    OMX_AUDIO_AMRBandModeWB2,                 /**< AMRWB Mode 2 = 12650 bps */ \n    OMX_AUDIO_AMRBandModeWB3,                 /**< AMRWB Mode 3 = 14250 bps */ \n    OMX_AUDIO_AMRBandModeWB4,                 /**< AMRWB Mode 4 = 15850 bps */\n    OMX_AUDIO_AMRBandModeWB5,                 /**< AMRWB Mode 5 = 18250 bps */\n    OMX_AUDIO_AMRBandModeWB6,                 /**< AMRWB Mode 6 = 19850 bps */\n    OMX_AUDIO_AMRBandModeWB7,                 /**< AMRWB Mode 7 = 23050 bps */\n    OMX_AUDIO_AMRBandModeWB8,                 /**< AMRWB Mode 8 = 23850 bps */      \n    OMX_AUDIO_AMRBandModeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_AUDIO_AMRBandModeVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_AUDIO_AMRBandModeMax = 0x7FFFFFFF\n} OMX_AUDIO_AMRBANDMODETYPE;\n     \n\n/** AMR Discontinuous Transmission mode */ \ntypedef enum OMX_AUDIO_AMRDTXMODETYPE { \n    OMX_AUDIO_AMRDTXModeOff = 0,        /**< AMR Discontinuous Transmission Mode is disabled */ \n    OMX_AUDIO_AMRDTXModeOnVAD1,         /**< AMR Discontinuous Transmission Mode using \n                                             Voice Activity Detector 1 (VAD1) is enabled */ \n    OMX_AUDIO_AMRDTXModeOnVAD2,         /**< AMR Discontinuous Transmission Mode using \n                                             Voice Activity Detector 2 (VAD2) is enabled */       \n    OMX_AUDIO_AMRDTXModeOnAuto,         /**< The codec will automatically select between \n                                             Off, VAD1 or VAD2 modes */ \n\n    OMX_AUDIO_AMRDTXasEFR,             /**< DTX as EFR instead of AMR standard (3GPP 26.101, frame type =8,9,10) */\n\n    OMX_AUDIO_AMRDTXModeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_AUDIO_AMRDTXModeVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_AUDIO_AMRDTXModeMax = 0x7FFFFFFF \n} OMX_AUDIO_AMRDTXMODETYPE; \n \n\n/** AMR params */\ntypedef struct OMX_AUDIO_PARAM_AMRTYPE {\n    OMX_U32 nSize;                          /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion;               /**< OMX specification version information */\n    OMX_U32 nPortIndex;                     /**< port that this structure applies to */\n    OMX_U32 nChannels;                      /**< Number of channels */\n    OMX_U32 nBitRate;                       /**< Bit rate read only field */\n    OMX_AUDIO_AMRBANDMODETYPE eAMRBandMode; /**< AMR Band Mode enumeration */ \n    OMX_AUDIO_AMRDTXMODETYPE  eAMRDTXMode;  /**< AMR DTX Mode enumeration */\n    OMX_AUDIO_AMRFRAMEFORMATTYPE eAMRFrameFormat; /**< AMR frame format enumeration */\n} OMX_AUDIO_PARAM_AMRTYPE;\n\n\n/** GSM_FR (ETSI 06.10, 3GPP 46.010) stream format parameters */\ntypedef struct OMX_AUDIO_PARAM_GSMFRTYPE {\n    OMX_U32 nSize;            /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion; /**< OMX specification version information */\n    OMX_U32 nPortIndex;       /**< port that this structure applies to */\n    OMX_BOOL bDTX;            /**< Enable Discontinuous Transmisssion */\n    OMX_BOOL bHiPassFilter;   /**< Enable High Pass Filter */\n} OMX_AUDIO_PARAM_GSMFRTYPE;\n\n\n/** GSM-HR (ETSI 06.20, 3GPP 46.020) stream format parameters */\ntypedef struct OMX_AUDIO_PARAM_GSMHRTYPE {\n    OMX_U32 nSize;            /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion; /**< OMX specification version information */\n    OMX_U32 nPortIndex;       /**< port that this structure applies to */\n    OMX_BOOL bDTX;            /**< Enable Discontinuous Transmisssion */\n    OMX_BOOL bHiPassFilter;   /**< Enable High Pass Filter */\n} OMX_AUDIO_PARAM_GSMHRTYPE;\n\n\n/** GSM-EFR (ETSI 06.60, 3GPP 46.060) stream format parameters */\ntypedef struct OMX_AUDIO_PARAM_GSMEFRTYPE {\n    OMX_U32 nSize;            /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion; /**< OMX specification version information */\n    OMX_U32 nPortIndex;       /**< port that this structure applies to */\n    OMX_BOOL bDTX;            /**< Enable Discontinuous Transmisssion */\n    OMX_BOOL bHiPassFilter;   /**< Enable High Pass Filter */\n} OMX_AUDIO_PARAM_GSMEFRTYPE;\n\n\n/** TDMA FR (TIA/EIA-136-420, VSELP 7.95kbps coder) stream format parameters */\ntypedef struct OMX_AUDIO_PARAM_TDMAFRTYPE {\n    OMX_U32 nSize;                /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion;     /**< OMX specification version information */\n    OMX_U32 nPortIndex;           /**< port that this structure applies to */\n    OMX_U32 nChannels;            /**< Number of channels in the data stream (not\n                                       necessarily the same as the number of channels\n                                       to be rendered. */\n    OMX_BOOL bDTX;                /**< Enable Discontinuous Transmisssion */\n    OMX_BOOL bHiPassFilter;       /**< Enable High Pass Filter */\n} OMX_AUDIO_PARAM_TDMAFRTYPE;\n\n\n/** TDMA EFR (TIA/EIA-136-410, ACELP 7.4kbps coder) stream format parameters */\ntypedef struct OMX_AUDIO_PARAM_TDMAEFRTYPE {\n    OMX_U32 nSize;                /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion;     /**< OMX specification version information */\n    OMX_U32 nPortIndex;           /**< port that this structure applies to */\n    OMX_U32 nChannels;            /**< Number of channels in the data stream (not\n                                       necessarily the same as the number of channels\n                                       to be rendered. */\n    OMX_BOOL bDTX;                /**< Enable Discontinuous Transmisssion */\n    OMX_BOOL bHiPassFilter;       /**< Enable High Pass Filter */\n} OMX_AUDIO_PARAM_TDMAEFRTYPE;\n\n\n/** PDC FR ( RCR-27, VSELP 6.7kbps coder) stream format parameters */\ntypedef struct OMX_AUDIO_PARAM_PDCFRTYPE {\n    OMX_U32 nSize;                /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion;     /**< OMX specification version information */\n    OMX_U32 nPortIndex;           /**< port that this structure applies to */\n    OMX_U32 nChannels;            /**< Number of channels in the data stream (not\n                                       necessarily the same as the number of channels\n                                       to be rendered. */\n    OMX_BOOL bDTX;                /**< Enable Discontinuous Transmisssion */\n    OMX_BOOL bHiPassFilter;       /**< Enable High Pass Filter */\n} OMX_AUDIO_PARAM_PDCFRTYPE;\n\n\n/** PDC EFR ( RCR-27, ACELP 6.7kbps coder) stream format parameters */\ntypedef struct OMX_AUDIO_PARAM_PDCEFRTYPE {\n    OMX_U32 nSize;                /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion;     /**< OMX specification version information */\n    OMX_U32 nPortIndex;           /**< port that this structure applies to */\n    OMX_U32 nChannels;            /**< Number of channels in the data stream (not\n                                       necessarily the same as the number of channels\n                                       to be rendered. */\n    OMX_BOOL bDTX;                /**< Enable Discontinuous Transmisssion */\n    OMX_BOOL bHiPassFilter;       /**< Enable High Pass Filter */\n} OMX_AUDIO_PARAM_PDCEFRTYPE;\n\n/** PDC HR ( RCR-27, PSI-CELP 3.45kbps coder) stream format parameters */\ntypedef struct OMX_AUDIO_PARAM_PDCHRTYPE {\n    OMX_U32 nSize;                /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion;     /**< OMX specification version information */\n    OMX_U32 nPortIndex;           /**< port that this structure applies to */\n    OMX_U32 nChannels;            /**< Number of channels in the data stream (not\n                                       necessarily the same as the number of channels\n                                       to be rendered. */\n    OMX_BOOL bDTX;                /**< Enable Discontinuous Transmisssion */\n    OMX_BOOL bHiPassFilter;       /**< Enable High Pass Filter */\n} OMX_AUDIO_PARAM_PDCHRTYPE;\n\n\n/** CDMA Rate types */\ntypedef enum OMX_AUDIO_CDMARATETYPE {\n    OMX_AUDIO_CDMARateBlank = 0,          /**< CDMA encoded frame is blank */\n    OMX_AUDIO_CDMARateFull,               /**< CDMA encoded frame in full rate */\n    OMX_AUDIO_CDMARateHalf,               /**< CDMA encoded frame in half rate */\n    OMX_AUDIO_CDMARateQuarter,            /**< CDMA encoded frame in quarter rate */\n    OMX_AUDIO_CDMARateEighth,             /**< CDMA encoded frame in eighth rate (DTX)*/\n    OMX_AUDIO_CDMARateErasure,            /**< CDMA erasure frame */\n    OMX_AUDIO_CDMARateKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_AUDIO_CDMARateVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_AUDIO_CDMARateMax = 0x7FFFFFFF\n} OMX_AUDIO_CDMARATETYPE;\n\n\n/** QCELP8 (TIA/EIA-96, up to 8kbps coder) stream format parameters */\ntypedef struct OMX_AUDIO_PARAM_QCELP8TYPE {\n    OMX_U32 nSize;                /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion;     /**< OMX specification version information */\n    OMX_U32 nPortIndex;           /**< port that this structure applies to */\n    OMX_U32 nChannels;            /**< Number of channels in the data stream (not\n                                       necessarily the same as the number of channels\n                                       to be rendered. */\n    OMX_U32 nBitRate;             /**< Bit rate of the input data.  Use 0 for variable\n                                       rate or unknown bit rates */\n    OMX_AUDIO_CDMARATETYPE eCDMARate; /**< Frame rate */\n    OMX_U32 nMinBitRate;          /**< minmal rate for the encoder = 1,2,3,4, default = 1 */\n    OMX_U32 nMaxBitRate;          /**< maximal rate for the encoder = 1,2,3,4, default = 4 */\n} OMX_AUDIO_PARAM_QCELP8TYPE;\n\n\n/** QCELP13 ( CDMA, EIA/TIA-733, 13.3kbps coder) stream format parameters */\ntypedef struct OMX_AUDIO_PARAM_QCELP13TYPE {\n    OMX_U32 nSize;                /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion;     /**< OMX specification version information */\n    OMX_U32 nPortIndex;           /**< port that this structure applies to */\n    OMX_U32 nChannels;            /**< Number of channels in the data stream (not\n                                       necessarily the same as the number of channels\n                                       to be rendered. */\n    OMX_AUDIO_CDMARATETYPE eCDMARate; /**< Frame rate */\n    OMX_U32 nMinBitRate;          /**< minmal rate for the encoder = 1,2,3,4, default = 1 */\n    OMX_U32 nMaxBitRate;          /**< maximal rate for the encoder = 1,2,3,4, default = 4 */\n} OMX_AUDIO_PARAM_QCELP13TYPE;\n\n\n/** EVRC ( CDMA, EIA/TIA-127, RCELP up to 8.55kbps coder) stream format parameters */\ntypedef struct OMX_AUDIO_PARAM_EVRCTYPE {\n    OMX_U32 nSize;                /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion;     /**< OMX specification version information */\n    OMX_U32 nPortIndex;           /**< port that this structure applies to */\n    OMX_U32 nChannels;            /**< Number of channels in the data stream (not\n                                       necessarily the same as the number of channels\n                                       to be rendered. */\n    OMX_AUDIO_CDMARATETYPE eCDMARate; /**< actual Frame rate */\n    OMX_BOOL bRATE_REDUCon;       /**< RATE_REDUCtion is requested for this frame */\n    OMX_U32 nMinBitRate;          /**< minmal rate for the encoder = 1,2,3,4, default = 1 */\n    OMX_U32 nMaxBitRate;          /**< maximal rate for the encoder = 1,2,3,4, default = 4 */\n    OMX_BOOL bHiPassFilter;       /**< Enable encoder's High Pass Filter */\n    OMX_BOOL bNoiseSuppressor;    /**< Enable encoder's noise suppressor pre-processing */\n    OMX_BOOL bPostFilter;         /**< Enable decoder's post Filter */\n} OMX_AUDIO_PARAM_EVRCTYPE;\n\n\n/** SMV ( up to 8.55kbps coder) stream format parameters */\ntypedef struct OMX_AUDIO_PARAM_SMVTYPE {\n    OMX_U32 nSize;                /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion;     /**< OMX specification version information */\n    OMX_U32 nPortIndex;           /**< port that this structure applies to */\n    OMX_U32 nChannels;            /**< Number of channels in the data stream (not\n                                       necessarily the same as the number of channels\n                                       to be rendered. */\n    OMX_AUDIO_CDMARATETYPE eCDMARate; /**< Frame rate */\n    OMX_BOOL bRATE_REDUCon;           /**< RATE_REDUCtion is requested for this frame */\n    OMX_U32 nMinBitRate;          /**< minmal rate for the encoder = 1,2,3,4, default = 1 ??*/\n    OMX_U32 nMaxBitRate;          /**< maximal rate for the encoder = 1,2,3,4, default = 4 ??*/\n    OMX_BOOL bHiPassFilter;       /**< Enable encoder's High Pass Filter ??*/\n    OMX_BOOL bNoiseSuppressor;    /**< Enable encoder's noise suppressor pre-processing */\n    OMX_BOOL bPostFilter;         /**< Enable decoder's post Filter ??*/\n} OMX_AUDIO_PARAM_SMVTYPE;\n\n\n/** MIDI Format \n * @ingroup midi\n */\ntypedef enum OMX_AUDIO_MIDIFORMATTYPE\n{\n    OMX_AUDIO_MIDIFormatUnknown = 0, /**< MIDI Format unknown or don't care */\n    OMX_AUDIO_MIDIFormatSMF0,        /**< Standard MIDI File Type 0 */\n    OMX_AUDIO_MIDIFormatSMF1,        /**< Standard MIDI File Type 1 */\n    OMX_AUDIO_MIDIFormatSMF2,        /**< Standard MIDI File Type 2 */\n    OMX_AUDIO_MIDIFormatSPMIDI,      /**< SP-MIDI */\n    OMX_AUDIO_MIDIFormatXMF0,        /**< eXtensible Music Format type 0 */\n    OMX_AUDIO_MIDIFormatXMF1,        /**< eXtensible Music Format type 1 */\n    OMX_AUDIO_MIDIFormatMobileXMF,   /**< Mobile XMF (eXtensible Music Format type 2) */\n    OMX_AUDIO_MIDIFormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_AUDIO_MIDIFormatVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_AUDIO_MIDIFormatMax = 0x7FFFFFFF\n} OMX_AUDIO_MIDIFORMATTYPE;\n\n\n/** MIDI params \n * @ingroup midi\n */\ntypedef struct OMX_AUDIO_PARAM_MIDITYPE {\n    OMX_U32 nSize;                 /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion;      /**< OMX specification version information */\n    OMX_U32 nPortIndex;            /**< port that this structure applies to */\n    OMX_U32 nFileSize;             /**< size of the MIDI file in bytes, where the entire \n                                        MIDI file passed in, otherwise if 0x0, the MIDI data \n                                        is merged and streamed (instead of passed as an \n                                        entire MIDI file) */\n    OMX_BU32 sMaxPolyphony;        /**< Specifies the maximum simultaneous polyphonic \n                                        voices. A value of zero indicates that the default \n                                        polyphony of the device is used  */                                    \n    OMX_BOOL bLoadDefaultSound;    /**< Whether to load default sound \n                                        bank at initialization */\n    OMX_AUDIO_MIDIFORMATTYPE eMidiFormat; /**< Version of the MIDI file */                                                                           \n} OMX_AUDIO_PARAM_MIDITYPE;\n\n\n/** Type of the MIDI sound bank \n * @ingroup midi\n */\ntypedef enum OMX_AUDIO_MIDISOUNDBANKTYPE {\n    OMX_AUDIO_MIDISoundBankUnused = 0,           /**< unused/unknown soundbank type */\n    OMX_AUDIO_MIDISoundBankDLS1,                 /**< DLS version 1 */\n    OMX_AUDIO_MIDISoundBankDLS2,                 /**< DLS version 2 */\n    OMX_AUDIO_MIDISoundBankMobileDLSBase,        /**< Mobile DLS, using the base functionality */\n    OMX_AUDIO_MIDISoundBankMobileDLSPlusOptions, /**< Mobile DLS, using the specification-defined optional feature set */\n    OMX_AUDIO_MIDISoundBankKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_AUDIO_MIDISoundBankVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_AUDIO_MIDISoundBankMax = 0x7FFFFFFF\n} OMX_AUDIO_MIDISOUNDBANKTYPE;\n\n\n/** Bank Layout describes how bank MSB & LSB are used in the DLS instrument definitions sound bank \n * @ingroup midi\n */\ntypedef enum OMX_AUDIO_MIDISOUNDBANKLAYOUTTYPE {\n   OMX_AUDIO_MIDISoundBankLayoutUnused = 0,   /**< unused/unknown soundbank type */\n   OMX_AUDIO_MIDISoundBankLayoutGM,           /**< GS layout (based on bank MSB 0x00) */\n   OMX_AUDIO_MIDISoundBankLayoutGM2,          /**< General MIDI 2 layout (using MSB 0x78/0x79, LSB 0x00) */\n   OMX_AUDIO_MIDISoundBankLayoutUser,         /**< Does not conform to any bank numbering standards */\n   OMX_AUDIO_MIDISoundBankLayoutKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n   OMX_AUDIO_MIDISoundBankLayoutVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n   OMX_AUDIO_MIDISoundBankLayoutMax = 0x7FFFFFFF\n} OMX_AUDIO_MIDISOUNDBANKLAYOUTTYPE;\n\n\n/** MIDI params to load/unload user soundbank \n * @ingroup midi\n */\ntypedef struct OMX_AUDIO_PARAM_MIDILOADUSERSOUNDTYPE {\n    OMX_U32 nSize;            /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion; /**< OMX specification version information */\n    OMX_U32 nPortIndex;       /**< port that this structure applies to */\n    OMX_U32 nDLSIndex;        /**< DLS file index to be loaded */\n    OMX_U32 nDLSSize;         /**< Size in bytes */\n    OMX_PTR pDLSData;         /**< Pointer to DLS file data */\n    OMX_AUDIO_MIDISOUNDBANKTYPE eMidiSoundBank;   /**< Midi sound bank type enumeration */\n    OMX_AUDIO_MIDISOUNDBANKLAYOUTTYPE eMidiSoundBankLayout; /**< Midi sound bank layout enumeration */\n} OMX_AUDIO_PARAM_MIDILOADUSERSOUNDTYPE;\n\n\n/** Structure for Live MIDI events and MIP messages. \n * (MIP = Maximum Instantaneous Polyphony; part of the SP-MIDI standard.) \n * @ingroup midi\n */\ntypedef struct OMX_AUDIO_CONFIG_MIDIIMMEDIATEEVENTTYPE {\n    OMX_U32 nSize;            /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion; /**< OMX specification version information */\n    OMX_U32 nPortIndex;       /**< Port that this structure applies to */\n    OMX_U32 nMidiEventSize;   /**< Size of immediate MIDI events or MIP message in bytes  */\n    OMX_U8 nMidiEvents[1];    /**< MIDI event array to be rendered immediately, or an\n                                   array for the MIP message buffer, where the size is \n                                   indicated by nMidiEventSize */\n} OMX_AUDIO_CONFIG_MIDIIMMEDIATEEVENTTYPE;\n\n\n/** MIDI sound bank/ program pair in a given channel \n * @ingroup midi\n */\ntypedef struct OMX_AUDIO_CONFIG_MIDISOUNDBANKPROGRAMTYPE {\n    OMX_U32 nSize;              /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion;   /**< OMX specification version information */\n    OMX_U32 nPortIndex;         /**< Port that this structure applies to */\n    OMX_U32 nChannel;           /**< Valid channel values range from 1 to 16 */\n    OMX_U16 nIDProgram;         /**< Valid program ID range is 1 to 128 */\n    OMX_U16 nIDSoundBank;       /**< Sound bank ID */\n    OMX_U32 nUserSoundBankIndex;/**< User soundbank index, easier to access soundbanks \n                                     by index if multiple banks are present */\n} OMX_AUDIO_CONFIG_MIDISOUNDBANKPROGRAMTYPE;\n\n\n/** MIDI control \n * @ingroup midi\n */\ntypedef struct OMX_AUDIO_CONFIG_MIDICONTROLTYPE {\n    OMX_U32 nSize;                /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion;     /**< OMX specification version information */\n    OMX_U32 nPortIndex;           /**< port that this structure applies to */\n    OMX_BS32 sPitchTransposition; /**< Pitch transposition in semitones, stored as Q22.10 \n                                       format based on JAVA MMAPI (JSR-135) requirement */\n    OMX_BU32 sPlayBackRate;       /**< Relative playback rate, stored as Q14.17 fixed-point\n                                       number based on JSR-135 requirement */\n    OMX_BU32 sTempo ;             /**< Tempo in beats per minute (BPM), stored as Q22.10 \n                                       fixed-point number based on JSR-135 requirement */\n    OMX_U32 nMaxPolyphony;        /**< Specifies the maximum simultaneous polyphonic \n                                       voices. A value of zero indicates that the default \n                                       polyphony of the device is used  */\n    OMX_U32 nNumRepeat;           /**< Number of times to repeat playback */\n    OMX_U32 nStopTime;            /**< Time in milliseconds to indicate when playback \n                                       will stop automatically.  Set to zero if not used */\n    OMX_U16 nChannelMuteMask;     /**< 16 bit mask for channel mute status */\n    OMX_U16 nChannelSoloMask;     /**< 16 bit mask for channel solo status */\n    OMX_U32 nTrack0031MuteMask;   /**< 32 bit mask for track mute status. Note: This is for tracks 0-31 */\n    OMX_U32 nTrack3263MuteMask;   /**< 32 bit mask for track mute status. Note: This is for tracks 32-63 */\n    OMX_U32 nTrack0031SoloMask;   /**< 32 bit mask for track solo status. Note: This is for tracks 0-31 */\n    OMX_U32 nTrack3263SoloMask;   /**< 32 bit mask for track solo status. Note: This is for tracks 32-63 */\n\n} OMX_AUDIO_CONFIG_MIDICONTROLTYPE;\n\n\n/** MIDI Playback States \n * @ingroup midi\n */\ntypedef enum OMX_AUDIO_MIDIPLAYBACKSTATETYPE {\n  OMX_AUDIO_MIDIPlayBackStateUnknown = 0,      /**< Unknown state or state does not map to \n  \t\t\t\t\t\t\t\t\t\t\t\t\tother defined states */\n  OMX_AUDIO_MIDIPlayBackStateClosedEngaged,    /**< No MIDI resource is currently open. \n                                                    The MIDI engine is currently processing \n                                                    MIDI events. */\n  OMX_AUDIO_MIDIPlayBackStateParsing,          /**< A MIDI resource is open and is being \n                                                    primed. The MIDI engine is currently \n                                                    processing MIDI events. */\n  OMX_AUDIO_MIDIPlayBackStateOpenEngaged,      /**< A MIDI resource is open and primed but \n                                                    not playing. The MIDI engine is currently\n                                                    processing MIDI events. The transition to\n                                                    this state is only possible from the \n                                                    OMX_AUDIO_MIDIPlayBackStatePlaying state,\n                                                    when the 'playback head' reaches the end\n                                                    of media data or the playback stops due\n                                                    to stop time set.*/\n  OMX_AUDIO_MIDIPlayBackStatePlaying,          /**< A MIDI resource is open and currently\n                                                    playing. The MIDI engine is currently\n                                                    processing MIDI events.*/\n  OMX_AUDIO_MIDIPlayBackStatePlayingPartially, /**< Best-effort playback due to SP-MIDI/DLS\n                                                    resource constraints */\n  OMX_AUDIO_MIDIPlayBackStatePlayingSilently,  /**< Due to system resource constraints and\n                                                    SP-MIDI content constraints, there is\n                                                    no audible MIDI content during playback\n                                                    currently. The situation may change if\n                                                    resources are freed later.*/\n  OMX_AUDIO_MIDIPlayBackStateKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n  OMX_AUDIO_MIDIPlayBackStateVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n  OMX_AUDIO_MIDIPlayBackStateMax = 0x7FFFFFFF\n} OMX_AUDIO_MIDIPLAYBACKSTATETYPE;\n\n\n/** MIDI status \n * @ingroup midi\n */\ntypedef struct OMX_AUDIO_CONFIG_MIDISTATUSTYPE {\n    OMX_U32 nSize;              /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion;   /**< OMX specification version information */\n    OMX_U32 nPortIndex;         /**< port that this structure applies to */\n    OMX_U16 nNumTracks;         /**< Number of MIDI tracks in the file, read only field. \n                                     NOTE: May not return a meaningful value until the entire \n                                     file is parsed and buffered.  */\n    OMX_U32 nDuration;          /**< The length of the currently open MIDI resource \n                                     in milliseconds. NOTE: May not return a meaningful value \n                                     until the entire file is parsed and buffered.  */  \n    OMX_U32 nPosition;          /**< Current Position of the MIDI resource being played \n                                     in milliseconds */\n    OMX_BOOL bVibra;            /**< Does Vibra track exist? NOTE: May not return a meaningful \n                                     value until the entire file is parsed and buffered. */\n    OMX_U32 nNumMetaEvents;     /**< Total number of MIDI Meta Events in the currently \n                                     open MIDI resource. NOTE: May not return a meaningful value \n                                     until the entire file is parsed and buffered.  */\n    OMX_U32 nNumActiveVoices;   /**< Number of active voices in the currently playing \n                                     MIDI resource. NOTE: May not return a meaningful value until \n                                     the entire file is parsed and buffered. */\n    OMX_AUDIO_MIDIPLAYBACKSTATETYPE eMIDIPlayBackState;  /**< MIDI playback state enumeration, read only field */\n} OMX_AUDIO_CONFIG_MIDISTATUSTYPE;\n\n\n/** MIDI Meta Event structure one per Meta Event.\n *  MIDI Meta Events are like audio metadata, except that they are interspersed \n *  with the MIDI content throughout the file and are not localized in the header. \n *  As such, it is necessary to retrieve information about these Meta Events from \n *  the engine, as it encounters these Meta Events within the MIDI content. \n *  For example, SMF files can have up to 14 types of MIDI Meta Events (copyright, \n *  author, default tempo, etc.) scattered throughout the file. \n *  @ingroup midi\n */\ntypedef struct OMX_AUDIO_CONFIG_MIDIMETAEVENTTYPE{ \n    OMX_U32 nSize;            /**< size of the structure in bytes */ \n    OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ \n    OMX_U32 nPortIndex;       /**< port that this structure applies to */ \n    OMX_U32 nIndex;           /**< Index of Meta Event */ \n    OMX_U8 nMetaEventType;    /**< Meta Event Type, 7bits (i.e. 0 - 127) */ \n    OMX_U32 nMetaEventSize;   /**< size of the Meta Event in bytes */ \n    OMX_U32 nTrack;           /**< track number for the meta event */\n    OMX_U32 nPosition;        /**< Position of the meta-event in milliseconds */\n} OMX_AUDIO_CONFIG_MIDIMETAEVENTTYPE; \n\n\n/** MIDI Meta Event Data structure - one per Meta Event. \n * @ingroup midi\n */ \ntypedef struct OMX_AUDIO_CONFIG_MIDIMETAEVENTDATATYPE{ \n    OMX_U32 nSize;            /**< size of the structure in bytes */ \n    OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ \n    OMX_U32 nPortIndex;       /**< port that this structure applies to */ \n    OMX_U32 nIndex;           /**< Index of Meta Event */ \n    OMX_U32 nMetaEventSize;   /**< size of the Meta Event in bytes */ \n    OMX_U8 nData[1];          /**< array of one or more bytes of meta data \n                                   as indicated by the nMetaEventSize field */ \n} OMX_AUDIO_CONFIG__MIDIMETAEVENTDATATYPE; \n\n\n/** Audio Volume adjustment for a port */\ntypedef struct OMX_AUDIO_CONFIG_VOLUMETYPE {\n    OMX_U32 nSize;              /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion;   /**< OMX specification version information */\n    OMX_U32 nPortIndex;         /**< Port index indicating which port to \n                                     set.  Select the input port to set \n                                     just that port's volume.  Select the \n                                     output port to adjust the master \n                                     volume. */\n    OMX_BOOL bLinear;           /**< Is the volume to be set in linear (0.100) \n                                     or logarithmic scale (mB) */\n    OMX_BS32 sVolume;           /**< Volume linear setting in the 0..100 range, OR\n                                     Volume logarithmic setting for this port.  The values\n                                     for volume are in mB (millibels = 1/100 dB) relative\n                                     to a gain of 1 (e.g. the output is the same as the \n                                     input level).  Values are in mB from nMax \n                                     (maximum volume) to nMin mB (typically negative).\n                                     Since the volume is \"voltage\"\n                                     and not a \"power\", it takes a setting of\n                                     -600 mB to decrease the volume by 1/2.  If\n                                     a component cannot accurately set the \n                                     volume to the requested value, it must\n                                     set the volume to the closest value BELOW\n                                     the requested value.  When getting the\n                                     volume setting, the current actual volume\n                                     must be returned. */\n} OMX_AUDIO_CONFIG_VOLUMETYPE;\n\n\n/** Audio Volume adjustment for a channel */\ntypedef struct OMX_AUDIO_CONFIG_CHANNELVOLUMETYPE {\n    OMX_U32 nSize;              /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion;   /**< OMX specification version information */\n    OMX_U32 nPortIndex;         /**< Port index indicating which port to \n                                     set.  Select the input port to set \n                                     just that port's volume.  Select the \n                                     output port to adjust the master \n                                     volume. */\n    OMX_U32 nChannel;           /**< channel to select from 0 to N-1, \n                                     using OMX_ALL to apply volume settings\n                                     to all channels */\n    OMX_BOOL bLinear;           /**< Is the volume to be set in linear (0.100) or \n                                     logarithmic scale (mB) */\n    OMX_BS32 sVolume;           /**< Volume linear setting in the 0..100 range, OR\n                                     Volume logarithmic setting for this port.  \n                                     The values for volume are in mB \n                                     (millibels = 1/100 dB) relative to a gain\n                                     of 1 (e.g. the output is the same as the \n                                     input level).  Values are in mB from nMax \n                                     (maximum volume) to nMin mB (typically negative).  \n                                     Since the volume is \"voltage\"\n                                     and not a \"power\", it takes a setting of\n                                     -600 mB to decrease the volume by 1/2.  If\n                                     a component cannot accurately set the \n                                     volume to the requested value, it must\n                                     set the volume to the closest value BELOW\n                                     the requested value.  When getting the\n                                     volume setting, the current actual volume\n                                     must be returned. */\n    OMX_BOOL bIsMIDI;           /**< TRUE if nChannel refers to a MIDI channel,\n                                     FALSE otherwise */\n} OMX_AUDIO_CONFIG_CHANNELVOLUMETYPE;\n\n\n/** Audio balance setting */\ntypedef struct OMX_AUDIO_CONFIG_BALANCETYPE {\n    OMX_U32 nSize;              /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion;   /**< OMX specification version information */\n    OMX_U32 nPortIndex;         /**< Port index indicating which port to \n                                     set.  Select the input port to set \n                                     just that port's balance.  Select the \n                                     output port to adjust the master \n                                     balance. */\n    OMX_S32 nBalance;           /**< balance setting for this port \n                                     (-100 to 100, where -100 indicates\n                                     all left, and no right */\n} OMX_AUDIO_CONFIG_BALANCETYPE;\n\n\n/** Audio Port mute */\ntypedef struct OMX_AUDIO_CONFIG_MUTETYPE {\n    OMX_U32 nSize;              /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion;   /**< OMX specification version information */\n    OMX_U32 nPortIndex;         /**< Port index indicating which port to \n                                     set.  Select the input port to set \n                                     just that port's mute.  Select the \n                                     output port to adjust the master \n                                     mute. */\n    OMX_BOOL bMute;             /**< Mute setting for this port */\n} OMX_AUDIO_CONFIG_MUTETYPE;\n\n\n/** Audio Channel mute */\ntypedef struct OMX_AUDIO_CONFIG_CHANNELMUTETYPE {\n    OMX_U32 nSize;              /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion;   /**< OMX specification version information */\n    OMX_U32 nPortIndex;         /**< port that this structure applies to */\n    OMX_U32 nChannel;           /**< channel to select from 0 to N-1, \n                                     using OMX_ALL to apply mute settings\n                                     to all channels */\n    OMX_BOOL bMute;             /**< Mute setting for this channel */\n    OMX_BOOL bIsMIDI;           /**< TRUE if nChannel refers to a MIDI channel,\n                                     FALSE otherwise */ \n} OMX_AUDIO_CONFIG_CHANNELMUTETYPE;\n\n\n\n/** Enable / Disable for loudness control, which boosts bass and to a \n *  smaller extent high end frequencies to compensate for hearing\n *  ability at the extreme ends of the audio spectrum\n */ \ntypedef struct OMX_AUDIO_CONFIG_LOUDNESSTYPE {\n    OMX_U32 nSize;             /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion;  /**< OMX specification version information */\n    OMX_U32 nPortIndex;        /**< port that this structure applies to */\n    OMX_BOOL bLoudness;        /**< Enable/disable for loudness */\n} OMX_AUDIO_CONFIG_LOUDNESSTYPE;\n\n\n/** Enable / Disable for bass, which controls low frequencies\n */ \ntypedef struct OMX_AUDIO_CONFIG_BASSTYPE {\n    OMX_U32 nSize;             /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion;  /**< OMX specification version information */\n    OMX_U32 nPortIndex;        /**< port that this structure applies to */\n    OMX_BOOL bEnable;          /**< Enable/disable for bass control */\n    OMX_S32 nBass;             /**< bass setting for the port, as a \n                                    continuous value from -100 to 100  \n                                    (0 means no change in bass level)*/\n} OMX_AUDIO_CONFIG_BASSTYPE;\n\n\n/** Enable / Disable for treble, which controls high frequencies tones\n */ \ntypedef struct OMX_AUDIO_CONFIG_TREBLETYPE {\n    OMX_U32 nSize;             /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion;  /**< OMX specification version information */\n    OMX_U32 nPortIndex;        /**< port that this structure applies to */\n    OMX_BOOL bEnable;          /**< Enable/disable for treble control */\n    OMX_S32  nTreble;          /**< treble setting for the port, as a\n                                    continuous value from -100 to 100  \n                                    (0 means no change in treble level) */\n} OMX_AUDIO_CONFIG_TREBLETYPE;\n\n\n/** An equalizer is typically used for two reasons: to compensate for an \n *  sub-optimal frequency response of a system to make it sound more natural \n *  or to create intentionally some unnatural coloring to the sound to create\n *  an effect.\n *  @ingroup effects\n */\ntypedef struct OMX_AUDIO_CONFIG_EQUALIZERTYPE {\n    OMX_U32 nSize;             /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion;  /**< OMX specification version information */\n    OMX_U32 nPortIndex;        /**< port that this structure applies to */\n    OMX_BOOL bEnable;          /**< Enable/disable for equalizer */\n    OMX_BU32 sBandIndex;       /**< Band number to be set.  Upper Limit is \n                                    N-1, where N is the number of bands, lower limit is 0 */\n    OMX_BU32 sCenterFreq;      /**< Center frequecies in Hz.  This is a\n                                    read only element and is used to determine \n                                    the lower, center and upper frequency of \n                                    this band.  */\n    OMX_BS32 sBandLevel;       /**< band level in millibels */\n} OMX_AUDIO_CONFIG_EQUALIZERTYPE;\n\n\n/** Stereo widening mode type \n * @ingroup effects\n */ \ntypedef enum OMX_AUDIO_STEREOWIDENINGTYPE {\n    OMX_AUDIO_StereoWideningHeadphones,    /**< Stereo widening for loudspeakers */\n    OMX_AUDIO_StereoWideningLoudspeakers,  /**< Stereo widening for closely spaced loudspeakers */\n    OMX_AUDIO_StereoWideningKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_AUDIO_StereoWideningVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_AUDIO_StereoWideningMax = 0x7FFFFFFF\n} OMX_AUDIO_STEREOWIDENINGTYPE;\n\n\n/** Control for stereo widening, which is a special 2-channel\n *  case of the audio virtualizer effect. For example, for 5.1-channel \n *  output, it translates to virtual surround sound. \n * @ingroup effects\n */ \ntypedef struct OMX_AUDIO_CONFIG_STEREOWIDENINGTYPE {\n    OMX_U32 nSize;             /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion;  /**< OMX specification version information */\n    OMX_U32 nPortIndex;        /**< port that this structure applies to */\n    OMX_BOOL bEnable;          /**< Enable/disable for stereo widening control */\n    OMX_AUDIO_STEREOWIDENINGTYPE eWideningType; /**< Stereo widening algorithm type */\n    OMX_U32  nStereoWidening;  /**< stereo widening setting for the port,\n                                    as a continuous value from 0 to 100  */\n} OMX_AUDIO_CONFIG_STEREOWIDENINGTYPE;\n\n\n/** The chorus effect (or ``choralizer'') is any signal processor which makes\n *  one sound source (such as a voice) sound like many such sources singing \n *  (or playing) in unison. Since performance in unison is never exact, chorus \n *  effects simulate this by making independently modified copies of the input \n *  signal. Modifications may include (1) delay, (2) frequency shift, and \n *  (3) amplitude modulation.\n * @ingroup effects\n */\ntypedef struct OMX_AUDIO_CONFIG_CHORUSTYPE {\n    OMX_U32 nSize;             /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion;  /**< OMX specification version information */\n    OMX_U32 nPortIndex;        /**< port that this structure applies to */\n    OMX_BOOL bEnable;          /**< Enable/disable for chorus */\n    OMX_BU32 sDelay;           /**< average delay in milliseconds */\n    OMX_BU32 sModulationRate;  /**< rate of modulation in millihertz */\n    OMX_U32 nModulationDepth;  /**< depth of modulation as a percentage of \n                                    delay (i.e. 0 to 100) */\n    OMX_BU32 nFeedback;        /**< Feedback from chorus output to input in percentage */\n} OMX_AUDIO_CONFIG_CHORUSTYPE;\n\n\n/** Reverberation is part of the reflected sound that follows the early \n *  reflections. In a typical room, this consists of a dense succession of \n *  echoes whose energy decays exponentially. The reverberation effect structure \n *  as defined here includes both (early) reflections as well as (late) reverberations. \n * @ingroup effects\n */\ntypedef struct OMX_AUDIO_CONFIG_REVERBERATIONTYPE {\n    OMX_U32 nSize;                /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion;     /**< OMX specification version information */\n    OMX_U32 nPortIndex;           /**< port that this structure applies to */\n    OMX_BOOL bEnable;             /**< Enable/disable for reverberation control */\n    OMX_BS32 sRoomLevel;          /**< Intensity level for the whole room effect \n                                       (i.e. both early reflections and late \n                                       reverberation) in millibels */\n    OMX_BS32 sRoomHighFreqLevel;  /**< Attenuation at high frequencies\n                                       relative to the intensity at low\n                                       frequencies in millibels */\n    OMX_BS32 sReflectionsLevel;   /**< Intensity level of early reflections\n                                       (relative to room value), in millibels */\n    OMX_BU32 sReflectionsDelay;   /**< Delay time of the first reflection relative \n                                       to the direct path, in milliseconds */\n    OMX_BS32 sReverbLevel;        /**< Intensity level of late reverberation\n                                       relative to room level, in millibels */\n    OMX_BU32 sReverbDelay;        /**< Time delay from the first early reflection \n                                       to the beginning of the late reverberation \n                                       section, in milliseconds */\n    OMX_BU32 sDecayTime;          /**< Late reverberation decay time at low\n                                       frequencies, in milliseconds */\n    OMX_BU32 nDecayHighFreqRatio; /**< Ratio of high frequency decay time relative \n                                       to low frequency decay time in percent  */\n    OMX_U32 nDensity;             /**< Modal density in the late reverberation decay,\n                                       in percent (i.e. 0 - 100) */\n    OMX_U32 nDiffusion;           /**< Echo density in the late reverberation decay,\n                                       in percent (i.e. 0 - 100) */\n    OMX_BU32 sReferenceHighFreq;  /**< Reference high frequency in Hertz. This is \n                                       the frequency used as the reference for all \n                                       the high-frequency settings above */\n\n} OMX_AUDIO_CONFIG_REVERBERATIONTYPE;\n\n\n/** Possible settings for the Echo Cancelation structure to use \n * @ingroup effects\n */\ntypedef enum OMX_AUDIO_ECHOCANTYPE {\n   OMX_AUDIO_EchoCanOff = 0,    /**< Echo Cancellation is disabled */\n   OMX_AUDIO_EchoCanNormal,     /**< Echo Cancellation normal operation - \n                                     echo from plastics and face */\n   OMX_AUDIO_EchoCanHFree,      /**< Echo Cancellation optimized for \n                                     Hands Free operation */\n   OMX_AUDIO_EchoCanCarKit,    /**< Echo Cancellation optimized for \n                                     Car Kit (longer echo) */\n   OMX_AUDIO_EchoCanKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n   OMX_AUDIO_EchoCanVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n   OMX_AUDIO_EchoCanMax = 0x7FFFFFFF\n} OMX_AUDIO_ECHOCANTYPE;\n\n\n/** Enable / Disable for echo cancelation, which removes undesired echo's\n *  from the audio\n * @ingroup effects\n */ \ntypedef struct OMX_AUDIO_CONFIG_ECHOCANCELATIONTYPE {\n    OMX_U32 nSize;             /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion;  /**< OMX specification version information */\n    OMX_U32 nPortIndex;        /**< port that this structure applies to */\n    OMX_AUDIO_ECHOCANTYPE eEchoCancelation; /**< Echo cancelation settings */\n} OMX_AUDIO_CONFIG_ECHOCANCELATIONTYPE;\n\n\n/** Enable / Disable for noise reduction, which undesired noise from\n * the audio\n * @ingroup effects\n */ \ntypedef struct OMX_AUDIO_CONFIG_NOISEREDUCTIONTYPE {\n    OMX_U32 nSize;             /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion;  /**< OMX specification version information */\n    OMX_U32 nPortIndex;        /**< port that this structure applies to */\n    OMX_BOOL bNoiseReduction;  /**< Enable/disable for noise reduction */\n} OMX_AUDIO_CONFIG_NOISEREDUCTIONTYPE;\n\n/** @} */\n\n#ifdef __cplusplus\n}\n#endif /* __cplusplus */\n\n#endif\n/* File EOF */\n\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vmcs_host/khronos/IL/OMX_Broadcom.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n// OpenMAX IL - Broadcom specific types\n\n#ifndef OMX_Broadcom_h\n#define OMX_Broadcom_h\n\n#include \"OMX_Component.h\"\n\n// for use in buffer headers - marks the contained data\n// as being a codec header\n#define OMX_BUFFERFLAG_TIME_UNKNOWN 0x00000100\n\n//for use in buffer headers - marks the buffer as being the\n//snapshot preview image from a still capture.\n//Mainly to be used with the DisplayFunction callback from camera.\n#define OMX_BUFFERFLAG_CAPTURE_PREVIEW 0x00000200\n\n/* Mark the end of a NAL unit produced by a video encoder.\n */\n#define OMX_BUFFERFLAG_ENDOFNAL    0x00000400\n\n/* Marks pBuffer in OMX_BUFFERHEADERTYPE as containing a fragment list instead of the actual buffer\n */\n#define OMX_BUFFERFLAG_FRAGMENTLIST 0x00000800\n\n/* Marks the start of a new sequence of data following any kind of seek operation.\n */\n#define OMX_BUFFERFLAG_DISCONTINUITY 0x00001000\n\n/** Codec side information Flag:\n* OMX_BUFFERFLAG_CODECSIDEINFO is an optional flag that is set by an\n* output port when all bytes in the buffer form part or all of a set of\n* codec specific side information. For example, distortion information\n* estimated by H.264 encoder can be sent using this flag to signal\n* the decoder quality\n*/\n#define OMX_BUFFERFLAG_CODECSIDEINFO 0x00002000\n\n// for use in buffer headers - indicated the timestamp is a DTS rather than PTS\n#define OMX_BUFFERFLAG_TIME_IS_DTS 0x000004000\n\n// for use in buffer headers - signals that a video picture is interlaced\n#define OMX_BUFFERFLAG_INTERLACED 0x000010000\n\n// Signals that the top field of the current interlaced frame should be displayed first\n#define OMX_BUFFERFLAG_TOP_FIELD_FIRST 0x000020000\n\n/**\n * Macros to convert to <code>OMX_TICKS</code> from a signed 64 bit value and\n * vice-versa. These macros don't actually do anything unless <code>OMX_TICKS</code>\n * is defined as a two-part structure (instead of a native signed 64-bit type).\n **/\n#ifndef OMX_SKIP64BIT\n   #define omx_ticks_from_s64(s) (s)\n   #define omx_ticks_to_s64(t) (t)\n#else\n   static inline OMX_TICKS omx_ticks_from_s64(signed long long s) { OMX_TICKS t; t.nLowPart = (OMX_U32)s; t.nHighPart = (OMX_U32)(s>>32); return t; }\n   #define omx_ticks_to_s64(t) ((t).nLowPart | ((uint64_t)((t).nHighPart) << 32))\n#endif /* OMX_SKIP64BIT */\n\n/* Buffer fragment descriptor */\ntypedef struct OMX_BUFFERFRAGMENTTYPE {\n   OMX_PTR pBuffer; /**< Pointer to actual block of memory that is acting as the fragment buffer */\n   OMX_U32 nLen;    /**< number of bytes in the buffer */\n} OMX_BUFFERFRAGMENTTYPE;\n\n/* OMX_IndexParamBrcmEnableIJGTableScaling: JPEG Quality Table Setting. */\ntypedef struct OMX_PARAM_IJGSCALINGTYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nPortIndex;\n   OMX_BOOL bEnabled;\n} OMX_PARAM_IJGSCALINGTYPE;\n/*\nThe boolean \\code{bEnabled} value determines whether the component uses\nthe standard IJG quality tables when encoding images.\n*/\n\n\n/* OMX_IndexConfigTimeInvalidStartTime: Invalid Start Times */\n/*\nThis allows clock clients to supply a start time notification to the\nclock whilst indicating that this time is invalid.\n*/\n\n/* OMX_IndexParamBrcmMaxFrameSkips: Frame timestamp jumps */\n/*\nThis number represents the number of times a jump in frame timestamps\nhas been observed that is greater than expected.\n*/\n\n/* OMX_IndexConfigAsynchronousFailureURI: Asynchronous Failure Filename */\n/*\nThis allows the client to query for the filename that cause an asynchronous\noutput error.\n*/\n\n/* OMX_IndexParamAsynchronousOutput: Asynchronous Output */\n/*\nThe allows the client to specify to a component that is writing files\nthat this writing may happen asynchronously, including opening and closing\nof files.\n*/\n\n/* OMX_IndexConfigClockAdjustment: Clock Adjustment */\n/*\nThis allows the client to read from the clock the total time\nadjustment made to the clock whilst running by the reference clock.\nIf the reference clock sends a time that causes the media time to jump\nthis difference is added to the total, which can be reported via this\nindex.  When the stream restarts by setting the clock state to\n\\code{OMX_TIME_ClockStateRunning} or\n\\code{OMX_TIME_ClockStateWaitingForStartTime} this adjustment total is\nset to zero.\n*/\n\n/* OMX_IndexParamBrcmDataUnit: Data Unit */\n/*\nThe data unit is an indication to components connected to this\ncomponent of the type of data delivery available.\n\\code{OMX_DataUnitCodedPicture} indicates that we are able to give\nframing information, using the \\code{OMX_BUFFERFLAG_ENDOFFRAME} flag to\nindicate that the data contained finishes a complete\nframe. \\code{OMX_DataUnitArbitraryStreamSection} indicates that no\nend-of-frame markers will be present, and the decoder should perform\nthe steps necessary to decode the stream. The other enum values are\nnot used.\n*/\n\n/* OMX_IndexConfigPresentationOffset: Presentation Offset */\n/*\nThe value of \\code{nTimestamp} is added to the offset requested for\neach new input frame. Takes effect for all new input frames, and has\nno effect on the offset used for currently-queued frames. A positive\nvalue will make the requested port earlier relative to other streams,\na negative value will make the requested port later relative to other\nstreams.\n*/\n\n/* OMX_IndexConfigSingleStep: Single Step */\n/*\nWhen setting this config on a paused clock, where the \\code{nU32}\nvalue is non-zero and \\code{nPortIndex} is OMX_ALL, the media clock\nwill advance through the next \\code{nU32} next requested media\ntimes. A paused clock is in running state but has a time scale of\n0. This will trigger the display of some video frames, so allowing\nsingle-stepping functionality. This config can be set multiple times,\nand will buffer up stepping requests until we have media requests to\nfulfil, or the clock is stopped or un-paused.\n\nThis config can also be used on some video output ports and, if\n\\code{nU32} is non-zero, requests that the output port forwards the\nnext \\code{nU32} frames appending an EOS marker on the last frame, and\nthen ceases to forward data on this port.  If \\code{nU32} is zero, any\nprevious request to forward a limited number of frames is cancelled\nand the default behaviour of this port will resume.\n*/\n\n/* OMX_IndexParamCameraCamplusId: Camera Subsystem Identification */\n/*\nThis parameter allows the configuration of the identifier to be used\nto initialise the Broadcom Camplus subsystem that sits beneath the\ncamera component. If only one instance of the camera component is\nused, the default value can be used. If more than one instance is\nrequired, they must each have their own unique values for this\nparameter. It is also used to tie the component to the image pool\ncreated with \\code{OMX_Set upCamPools}.\n*/\n\n/* OMX_IndexConfigAudioRenderingLatency: Audio Rendering Latency */\n/*\nThis config allows the client to query the current latency of audio\nrendering.  The latency is returned as the number of samples that\nan audio rendering component has received but have not been played.\n*/\n\n/* OMX_IndexConfigBrcmPoolMemAllocSize: Pool memory usage values */\n/*\nThis config allows the client to query how much memory is being used by\nthe component for any image pools. \n*/\n\n/* OMX_IndexConfigDisplayRegion: Display Region */\ntypedef enum OMX_DISPLAYTRANSFORMTYPE{\n   OMX_DISPLAY_ROT0 = 0,\n   OMX_DISPLAY_MIRROR_ROT0 = 1,\n   OMX_DISPLAY_MIRROR_ROT180 = 2,\n   OMX_DISPLAY_ROT180 = 3,\n   OMX_DISPLAY_MIRROR_ROT90 = 4,\n   OMX_DISPLAY_ROT270 = 5,\n   OMX_DISPLAY_ROT90 = 6,\n   OMX_DISPLAY_MIRROR_ROT270 = 7,\n   OMX_DISPLAY_DUMMY = 0x7FFFFFFF\n} OMX_DISPLAYTRANSFORMTYPE;\n\ntypedef struct OMX_DISPLAYRECTTYPE {\n   OMX_S16 x_offset;\n   OMX_S16 y_offset;\n   OMX_S16 width;\n   OMX_S16 height;\n} OMX_DISPLAYRECTTYPE;\n\ntypedef enum OMX_DISPLAYMODETYPE {\n   OMX_DISPLAY_MODE_FILL = 0,\n   OMX_DISPLAY_MODE_LETTERBOX = 1,\n   // these allow a left eye source->dest to be specified and the right eye mapping will be inferred by symmetry\n   OMX_DISPLAY_MODE_STEREO_LEFT_TO_LEFT = 2,\n   OMX_DISPLAY_MODE_STEREO_TOP_TO_TOP = 3,\n   OMX_DISPLAY_MODE_STEREO_LEFT_TO_TOP = 4,\n   OMX_DISPLAY_MODE_STEREO_TOP_TO_LEFT = 5,\n   OMX_DISPLAY_MODE_DUMMY = 0x7FFFFFFF\n} OMX_DISPLAYMODETYPE;\n\ntypedef enum OMX_DISPLAYSETTYPE {\n   OMX_DISPLAY_SET_NONE = 0,\n   OMX_DISPLAY_SET_NUM = 1,\n   OMX_DISPLAY_SET_FULLSCREEN = 2,\n   OMX_DISPLAY_SET_TRANSFORM = 4,\n   OMX_DISPLAY_SET_DEST_RECT = 8,\n   OMX_DISPLAY_SET_SRC_RECT = 0x10,\n   OMX_DISPLAY_SET_MODE = 0x20,\n   OMX_DISPLAY_SET_PIXEL = 0x40,\n   OMX_DISPLAY_SET_NOASPECT = 0x80,\n   OMX_DISPLAY_SET_LAYER = 0x100,\n   OMX_DISPLAY_SET_COPYPROTECT = 0x200,\n   OMX_DISPLAY_SET_ALPHA = 0x400,\n   OMX_DISPLAY_SET_DUMMY = 0x7FFFFFFF\n} OMX_DISPLAYSETTYPE;\n\ntypedef struct OMX_CONFIG_DISPLAYREGIONTYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nPortIndex;\n   OMX_DISPLAYSETTYPE set;\n   OMX_U32 num;\n   OMX_BOOL fullscreen;\n   OMX_DISPLAYTRANSFORMTYPE transform;\n   OMX_DISPLAYRECTTYPE dest_rect;\n   OMX_DISPLAYRECTTYPE src_rect;\n   OMX_BOOL noaspect;\n   OMX_DISPLAYMODETYPE mode;\n   OMX_U32 pixel_x;\n   OMX_U32 pixel_y;\n   OMX_S32 layer;\n   OMX_BOOL copyprotect_required;\n   OMX_U32 alpha;\n   OMX_U32 wfc_context_width;\n   OMX_U32 wfc_context_height;\n} OMX_CONFIG_DISPLAYREGIONTYPE;\n/*\nThis config sets the output display device, as well as the region used\non the output display, any display transformation, and some flags to\nindicate how to scale the image.\n\nThe structure uses a bitfield, \\code{set}, to indicate which fields are set\nand should be used. All other fields will maintain their current\nvalue.\n\n\\code{num} describes the display output device, with 0 typically being\na directly connected LCD display.\n\n\\code{fullscreen} indicates that we are using the full device screen\narea, rather than a window of the display.  If fullscreen is false,\nthen dest_rect is used to specify a region of the display to use.\n\n\\code{transform} indicates any rotation or flipping used to map frames\nonto the natural display orientation.\n\nThe \\code{src_rect} indicates which area of the frame to display. If\nall values are zero, the whole frame will be used.\n\nThe \\code{noaspect} flag, if set, indicates that any display scaling\nshould disregard the aspect ratio of the frame region being displayed.\n\n\\code{mode} indicates how the image should be scaled to fit the\ndisplay. \\code{OMX_DISPLAY_MODE_FILL} indicates that the image should\nfill the screen by potentially cropping the frames.  Setting\n\\code{mode} to \\code{OMX_DISPLAY_MODE_LETTERBOX} indicates that all\nthe source region should be displayed and black bars added if\nnecessary.\n\nThe \\code{pixel_x} and \\code{pixel_y} values, if non-zero, are used to\ndescribe the size of a source pixel. If values are zero, then pixels\ndefault to being square.\n\nSet the \\code{layer} that the image will appear on with the\n\\code{layer} field.\n*/\n\n\n\n/* OMX_IndexParamSource: Source Image Configuration */\ntypedef enum OMX_SOURCETYPE {\n   OMX_SOURCE_WHITE = 0,    // all white images\n   OMX_SOURCE_BLACK = 1,    // all black images\n   OMX_SOURCE_DIAGONAL = 2, // greyscale diagonal stripes\n   OMX_SOURCE_NOISE = 3,    // random pixel values\n   OMX_SOURCE_RANDOM = 4,   // a shaded random pattern of colours\n   OMX_SOURCE_COLOUR = 5,   // a solid colour determined by nParam\n   OMX_SOURCE_BLOCKS = 6,   // random coloured blocks of 16x16 size\n   OMX_SOURCE_SWIRLY,       // a swirly pattern used for encode testing\n   OMX_SOURCE_DUMMY = 0x7FFFFFFF\n} OMX_SOURCETYPE;\n\ntypedef struct OMX_PARAM_SOURCETYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nPortIndex;\n   OMX_SOURCETYPE eType;\n   OMX_U32 nParam;\n   OMX_U32 nFrameCount;\n   OMX_U32 xFrameRate;\n} OMX_PARAM_SOURCETYPE;\n/*\nThe source type determines the kind of image that is produced. Not all\ncombinations of source type and image type are supported.  The\n\\code{OMX_SOURCE_SWIRLY} setting can only be used with YUV420 packed\nplanar image formats.  When producing RGB565 image format, the\n\\code{OMX_SOURCE_DIAGONAL} and \\code{OMX_SOURCE_RANDOM} modes are\ntreated as \\code{OMX_SOURCE_NOISE}.\n\nThe \\code{nParam} field is used to specify the colour for the source\ncolour mode, and the offset of the diagonal pattern for diagonal mode.\nFor the blocks mode, \\code{nParam} is used as the seed for the random\ncolour generator.\n\nThe \\code{nFrameCount} parameter determines how many frames to send.\nIf it is zero, then frames are sent continuously. For any other value,\nit counts down until it has sent that many frames, and then stops,\nsending out an EOS. The \\code{xFrameRate} setting is used to determine\nthe timestamp for each frame produced, or can be set to zero if\ntimestamps should all remain at zero.\n*/\n\n/* OMX_IndexParamSourceSeed: Source Random Seed */\ntypedef struct OMX_PARAM_SOURCESEEDTYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nPortIndex;\n   OMX_U16 nData[16];\n} OMX_PARAM_SOURCESEEDTYPE;\n/*\nThis structure sets the current state of the random number generator\nused for \\code{OMX_SOURCE_RANDOM} source type, allowing repeatable\nrandom image creation.\n*/\n\n/* OMX_IndexParamResize: Resize Control */\ntypedef enum OMX_RESIZEMODETYPE {\n   OMX_RESIZE_NONE,\n   OMX_RESIZE_CROP,\n   OMX_RESIZE_BOX,\n   OMX_RESIZE_BYTES,\n   OMX_RESIZE_DUMMY = 0x7FFFFFFF\n} OMX_RESIZEMODETYPE;\n\ntypedef struct OMX_PARAM_RESIZETYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nPortIndex;\n   OMX_RESIZEMODETYPE eMode;\n   OMX_U32 nMaxWidth;\n   OMX_U32 nMaxHeight;\n   OMX_U32 nMaxBytes;\n   OMX_BOOL bPreserveAspectRatio;\n   OMX_BOOL bAllowUpscaling;\n} OMX_PARAM_RESIZETYPE;\n/*\nThe mode determines the kind of resize. \\code{OMX_RESIZE_BOX} allow\nthe \\code{nMaxWidth} and \\code{nMaxHeight} to set a bounding box into\nwhich the output must fit. \\code{OMX_RESIZE_BYTES} allows\n\\code{nMaxBytes} to set the maximum number of bytes into which the\nfull output frame must fit.  Two flags aid the setting of the output\nsize. \\code{bPreseveAspectRatio} sets whether the resize should\npreserve the aspect ratio of the incoming\nimage. \\code{bAllowUpscaling} sets whether the resize is allowed to\nincrease the size of the output image compared to the size of the\ninput image.\n*/\n\ntypedef struct OMX_PARAM_TESTINTERFACETYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_BOOL bTest;\n   OMX_BOOL bSetExtra;\n   OMX_U32 nExtra;\n   OMX_BOOL bSetError;\n   OMX_BOOL stateError[2];\n} OMX_PARAM_TESTINTERFACETYPE;\n\n/* OMX_IndexConfigVisualisation: Visualisation Mode */\ntypedef struct OMX_CONFIG_VISUALISATIONTYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nPortIndex;\n   OMX_U8 name[16];\n   OMX_U8 property[64];\n} OMX_CONFIG_VISUALISATIONTYPE;\n\n/*\n\\code{name} is a string of characters specifying the type of\nvisualization. The component appends \\code{\"_vis.vll\"} to the name\nprovided, and attempts to load a visualisation library contained in\nthis VLL.  \\code{property} contains configuration parameters and\nvalues, which is interpreted by the visualisation library. Typically\nall visualisations will accept a property string containing\n\\code{'mode=<number>'}, where \\code{<number>} may be a random 32 bit\ninteger in decimal format. If provided, this may select a random mode\nfrom that visualisation library.\n*/\n\n/*\nThis parameter is used when creating proprietary communication with\nthe display component, and provides the display function for passing\nimages to be displayed, together with a function used to flush all\npending image updates and release all images.\n*/\n\n/* OMX_IndexConfigBrcmAudioDestination: Audio Destination */\ntypedef struct OMX_CONFIG_BRCMAUDIODESTINATIONTYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U8 sName[16];\n} OMX_CONFIG_BRCMAUDIODESTINATIONTYPE;\n/*\nThis config sets the platform-specific audio destination or output\ndevice for audio sink components (e.g. audio_render).\n\n\\code{sName} describes the audio destination, with \\code{\"local\"}\ntypically being directly connected to headphones.\n*/\n\n/* OMX_IndexConfigBrcmAudioSource: Audio Source */\ntypedef struct OMX_CONFIG_BRCMAUDIOSOURCETYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U8 sName[16];\n} OMX_CONFIG_BRCMAUDIOSOURCETYPE;\n/*\nThis config sets the platform-specific audio source or input device\nfor audio source components (e.g. audio_capture).\n\n\\code{sName} describes the audio source, with \\code{\"local\"}\ntypically being directly connected to microphone.\n*/\n\n/* OMX_IndexConfigBrcmAudioDownmixCoefficients: Audio Downmix Coefficients */\ntypedef struct OMX_CONFIG_BRCMAUDIODOWNMIXCOEFFICIENTS {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nPortIndex;\n   OMX_U32 coeff[16];\n} OMX_CONFIG_BRCMAUDIODOWNMIXCOEFFICIENTS;\n/*\nThis config sets the platform-specific audio downmixing coefficients for the \naudio mixer component. The coefficients are 16.16 fixed point.\nThe even coefficients contribute to the left channel. \nThe odd coefficients contribute to the right channel. \nL' = coeff[0] * sample[N] + coeff[2] * sample[N+1] + coeff[4] * sample[N+2] + coeff[6] * sample[N+3] \n   + coeff[8] * sample[N+4] + coeff[10] * sample[N+5] + coeff[12] * sample[N+6] + coeff[14] * sample[N+7]\nR' = coeff[1] * sample[N] + coeff[3] * sample[N+1] + coeff[5] * sample[N+2] + coeff[7] * sample[N+3] \n   + coeff[9] * sample[N+4] + coeff[11] * sample[N+5] + coeff[13] * sample[N+6] + coeff[15] * sample[N+7]\n\n\\code{coeff} describes the downmixing coefficients\n*/\n\n/* OMX_IndexConfigBrcmAudioDownmixCoefficients8x8: Audio Downmix Coefficient matrix */\ntypedef struct OMX_CONFIG_BRCMAUDIODOWNMIXCOEFFICIENTS8x8 {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nPortIndex;\n   OMX_U32 coeff[64];\n} OMX_CONFIG_BRCMAUDIODOWNMIXCOEFFICIENTS8x8;\n/*\nThis config sets the platform-specific audio downmixing coefficients for the \naudio mixer component. The coefficients are 16.16 fixed point.\nThe coefficients are a 8*8 mixing matrix from 8 input channels to 8 outputs channels\n\n\\code{coeff} describes the downmixing coefficients\n*/\n\n/* OMX_IndexConfigBrcmAudioMaxSample: Maximum sample seen */\ntypedef struct OMX_CONFIG_BRCMAUDIOMAXSAMPLE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nPortIndex;\n   OMX_U32 nMaxSample;\n   OMX_TICKS nTimeStamp;\n} OMX_CONFIG_BRCMAUDIOMAXSAMPLE;\n/*\nThis gets the largest sample produced (after downmixing with OMX_CONFIG_BRCMAUDIODOWNMIXCOEFFICIENTS8x8) \nsince this config was last read. The nTimestamp is the earliest timestamp processed. \nThis can be used for DRC schemes \n\n\\code{coeff} maximum sample seen in current block\n*/\n\n/* OMX_IndexConfigPlayMode: Play Mode */\ntypedef enum OMX_PLAYMODETYPE {\n   OMX_PLAYMODE_NORMAL,\n   OMX_PLAYMODE_FF,\n   OMX_PLAYMODE_REW,\n   OMX_PLAYMODE_DUMMY = 0x7FFFFFFF\n} OMX_PLAYMODETYPE;\n\ntypedef struct OMX_CONFIG_PLAYMODETYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_PLAYMODETYPE eMode;\n} OMX_CONFIG_PLAYMODETYPE;\n/*\nThe playmode affects which frames are extracted from the media file\nand passed on the output ports. \\code{OMX_PLAYMODE_NORMAL} will\nextract all frames, \\code{OMX_PLAYMODE_FF} extracts only IDR frames\nwhen video is present, or only occasional packets of audio if no video\nis present. \\code{OMX_PLAYMODE_REW} is similar to\n\\code{OMX_PLAYMODE_FF} but extracts packets in reverse time\norder.\n*/\n\ntypedef enum OMX_DELIVERYFORMATTYPE {\n   OMX_DELIVERYFORMAT_STREAM,         // no framing information is known\n   OMX_DELIVERYFORMAT_SINGLE_PACKET,  // packetised, at most one frame per buffer\n   OMX_DELIVERYFORMAT_DUMMY = 0x7FFFFFFF\n} OMX_DELIVERYFORMATTYPE;\n\ntypedef struct OMX_PARAM_DELIVERYFORMATTYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nPortIndex;\n   OMX_DELIVERYFORMATTYPE eFormat;\n} OMX_PARAM_DELIVERYFORMATTYPE;\n\n/* OMX_IndexParamCodecConfig: Codec Configuration */\n\ntypedef struct OMX_PARAM_CODECCONFIGTYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nPortIndex;\n   OMX_U32 bCodecConfigIsComplete;\n   OMX_U8 nData[1];\n} OMX_PARAM_CODECCONFIGTYPE;\n\n/*\nThis parameter contains opaque data in a format specified by Broadcom\nand allows out-of-band information such as cropping rectangles, aspect\nratio information, codec-specific header bytes, and other essential\ninformation to be passed between connected components.\n\n\\code{bCodecConfigIsCompete} specifies if the codec config is fully\ncontained in here and there is no need to wait for OMX_BUFFERFLAG_CODECCONFIG\nbuffers\n*/\n\ntypedef struct OMX_PARAM_STILLSFUNCTIONTYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_BOOL bBuffer;\n   OMX_PTR (*pOpenFunc)(void);\n   OMX_PTR (*pCloseFunc)(void);\n   OMX_PTR (*pReadFunc)(void);\n   OMX_PTR (*pSeekFunc)(void);\n   OMX_PTR (*pWriteFunc)(void);\n} OMX_PARAM_STILLSFUNCTIONTYPE;\n\ntypedef void* OMX_BUFFERADDRESSHANDLETYPE;\n\ntypedef struct OMX_PARAM_BUFFERADDRESSTYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nPortIndex;\n   OMX_U32 nAllocLen;\n   OMX_BUFFERADDRESSHANDLETYPE handle;\n} OMX_PARAM_BUFFERADDRESSTYPE;\n\ntypedef struct OMX_PARAM_TUNNELSETUPTYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nPortIndex;\n   OMX_TUNNELSETUPTYPE sSetup;\n} OMX_PARAM_TUNNELSETUPTYPE;\n\n/* OMX_IndexParamBrcmPortEGL: Used for querying whether a port is an EGL port or not. */\ntypedef struct OMX_PARAM_BRCMPORTEGLTYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nPortIndex;\n   OMX_BOOL bPortIsEGL;\n} OMX_PARAM_BRCMPORTEGLTYPE;\n/*\n*/\n\n#define OMX_CONFIG_IMAGEFILTERPARAMS_MAXPARAMS 6\n/* OMX_IndexConfigCommonImageFilterParameters: Parameterized Image Filter */\ntypedef struct OMX_CONFIG_IMAGEFILTERPARAMSTYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nPortIndex;\n   OMX_IMAGEFILTERTYPE eImageFilter;\n   OMX_U32 nNumParams;\n   OMX_U32 nParams[OMX_CONFIG_IMAGEFILTERPARAMS_MAXPARAMS];\n} OMX_CONFIG_IMAGEFILTERPARAMSTYPE;\n/*\nThis structure contains optional parameters for some image\nfilters. The following table lists all image filters that support\nparameters.\n\n<table border=\"1\" cellspacing=\"0\" cellpadding=\"2\">\n<tr><td>Filter<td>Parameters<td>Notes\n\n<tr><td>\\code{OMX_ImageFilterSolarize}\n<td>\\code{[x0 y0 y1 y2]}\n<td>Linear mapping of \\code{[0,x0]} to \\code{[0,y0>]}\nand \\code{[x0,255]} to \\code{[y1,y2]}.\nDefault is \\code{\"128 128 128 0\"}.\n\n<tr><td>\\code{OMX_ImageFilterSharpen}\n<td>\\code{[sz [str [th]]}\n<td>\\code{sz} size of filter, either 1 or 2.\n\\code{str} strength of filter.\n\\code{th} threshold of filter.\nDefault is \\code{\"1 40 20\"}.\n\n<tr><td>\\code{OMX_ImageFilterFilm}\n<td>\\code{[[str] [u v]]}\n<td>\\code{str} strength of effect.\n\\code{u} sets u to constant value.\n\\code{v} sets v to constant value.\nDefault is \\code{\"24\"}.\n\n<tr><td>\\code{OMX_ImageFilterBlur}\n<td>\\code{[sz]}\n<td>\\code{sz} size of filter, either 1 or 2.\nDefault is \\code{\"2\"}.\n\n<tr><td>\\code{OMX_ImageFilterSaturation}\n<td>\\code{[str]}\n<td>\\code{str} strength of effect, in 8.8 fixed point format. u/v value\ndifferences from 128 are multiplied by \\code{str}.\nDefault is \\code{\"272\"}.\n</table>\n*/\n\n\n/* OMX_IndexConfigTransitionControl: Transition Control */\ntypedef struct OMX_CONFIG_TRANSITIONCONTROLTYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nPortIndex;\n   OMX_U32 nPosStart;\n   OMX_U32 nPosEnd;\n   OMX_S32 nPosIncrement;\n   OMX_TICKS nFrameIncrement;\n   OMX_BOOL bSwapInputs;\n   OMX_U8 name[16];\n   OMX_U8 property[64];\n} OMX_CONFIG_TRANSITIONCONTROLTYPE;\n/*\nThis structure represents the internal configuration of the\ntransition. Transitions are generated by a loadable plug-in described\nby the \\code{name} field. The component appends \\code{\"_tran.vll\"} to\nthe name provided, and attempts to load a transition library contained\nin this VLL.  The exact type of transition is configured in a\nplug-in-dependent manner with the \\code{property} field. All plug-ins\nshould accept a \\code{property} field equal to\n\\code{\"flags=<number>\"}, where \\code{<number>} can be a random 32 bit\nnumber.  If \\code{bSwapInputs} is false, then the start image is on\nport 210, the stop image on port 211. These are reversed if\n\\code{bSwapInputs} is true.\n\nTransition frames are generated from the plug-in by referencing a\nframe position in [0,65536], where position 0 is the start image,\nposition 65536 is the stop image. The first frame position generated\nis \\code{nPosStart}. The last frame position generated is\n\\code{nPosEnd}. Each frame will increment the position by\n\\code{nPosIncrement}. The timestamp attached to each frame will\nincrement by \\code{nFrameIncrement}.\n*/\n\n\n/*\nThis parameter is used to provide a callback function pointer for\nrelease events. It is used for internal clients on VideoCore.\n*/\n\n\n/* OMX_IndexConfigAudioMonoTrackControl: Dual Mono Control */\ntypedef enum OMX_AUDIOMONOTRACKOPERATIONSTYPE {\n   OMX_AUDIOMONOTRACKOPERATIONS_NOP,\n   OMX_AUDIOMONOTRACKOPERATIONS_L_TO_R,\n   OMX_AUDIOMONOTRACKOPERATIONS_R_TO_L,\n   OMX_AUDIOMONOTRACKOPERATIONS_DUMMY = 0x7FFFFFFF\n} OMX_AUDIOMONOTRACKOPERATIONSTYPE ;\n\ntypedef struct OMX_CONFIG_AUDIOMONOTRACKCONTROLTYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nPortIndex;\n   OMX_AUDIOMONOTRACKOPERATIONSTYPE eMode;\n} OMX_CONFIG_AUDIOMONOTRACKCONTROLTYPE;\n/*\nThis config controls the options to support dual mono audio\nstreams. The output can be unchanged, or the left channel copied over\nthe right channel, or the right channel copied over the left\nchannel. This config can be applied at any time with stereo\n16-bit-per-sample data. Since audio output is typically buffered, any\nchange will not be audible until that buffering has been played out.\n*/\n\n/* OMX_IndexParamCameraImagePool: Camera Image Pools */\ntypedef enum OMX_CAMERAIMAGEPOOLINPUTMODETYPE {\n   OMX_CAMERAIMAGEPOOLINPUTMODE_ONEPOOL,     /*All input images are allocated from one pool\n                                               Works for simple stills capture use cases\n                                               Can not be used with parallel stills capture\n                                               and video encode, as the pool will be sized for\n                                               capture or viewfinder, not both simultaneously.\n                                               The pool wouldn't divide sensibly in this mode\n                                               anyway.\n                                             */\n   OMX_CAMERAIMAGEPOOLINPUTMODE_TWOPOOLS,    /*All stills & video input images are allocated\n                                               from two separate pools.\n                                               This ensures that parallel capture can work, but\n                                               would consume more memory if used on a simple\n                                               stills capture use case.\n                                             */\n} OMX_CAMERAIMAGEPOOLINPUTMODETYPE;\n\ntypedef struct OMX_PARAM_CAMERAIMAGEPOOLTYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nNumHiResVideoFrames;\n   OMX_U32 nHiResVideoWidth;\n   OMX_U32 nHiResVideoHeight;\n   OMX_COLOR_FORMATTYPE eHiResVideoType;\n   OMX_U32 nNumHiResStillsFrames;\n   OMX_U32 nHiResStillsWidth;\n   OMX_U32 nHiResStillsHeight;\n   OMX_COLOR_FORMATTYPE eHiResStillsType;\n   OMX_U32 nNumLoResFrames;\n   OMX_U32 nLoResWidth;\n   OMX_U32 nLoResHeight;\n   OMX_COLOR_FORMATTYPE eLoResType;\n   OMX_U32 nNumSnapshotFrames;\n   OMX_COLOR_FORMATTYPE eSnapshotType;\n   OMX_CAMERAIMAGEPOOLINPUTMODETYPE eInputPoolMode;\n   OMX_U32 nNumInputVideoFrames;\n   OMX_U32 nInputVideoWidth;\n   OMX_U32 nInputVideoHeight;\n   OMX_COLOR_FORMATTYPE eInputVideoType;\n   OMX_U32 nNumInputStillsFrames;\n   OMX_U32 nInputStillsWidth;\n   OMX_U32 nInputStillsHeight;\n   OMX_COLOR_FORMATTYPE eInputStillsType;\n} OMX_PARAM_CAMERAIMAGEPOOLTYPE;\n/*\n\\sloppy This parameter specifies the size, type, and number, of images to\nallow in the images pools required by Camplus. Supported types are\n\\code{OMX_COLOR_FormatYUV420PackedPlanar},\n\\code{OMX_COLOR_FormatYUV422PackedPlanar},\n\\code{OMX_COLOR_FormatRawBayer8bit},\n\\code{OMX_COLOR_FormatRawBayer10bit},\n\\code{OMX_COLOR_FormatRawBayer8bitcompressed}, and 0 (reserved for the\nBroadcom-specific format required by the video encoder). The input\npool width, height, and type can be set as 0 to make the component\nquery Camplus for the sensor mode that would correspond to the largest\nof the viewfinder port definition, the capture port definition, or the\nhigh resolution image pool.\n*/\n\n/* OMX_IndexParamImagePoolSize: Specifying Image Pool Properties */\ntypedef struct OMX_PARAM_IMAGEPOOLSIZETYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 width;\n   OMX_U32 height;\n   OMX_U32 num_pages;\n} OMX_PARAM_IMAGEPOOLSIZETYPE;\n/*\nThis parameter is used to control the size of pool that the component\nwill allocate in the absence of setting an external pool.  The default\ncan be reset by setting this parameter with all three fields set to\nzero.\n*/\n\n\n/* OMX_IndexParamImagePoolExternal: Client Allocated Image Pools */\nstruct opaque_vc_pool_s;\ntypedef struct opaque_vc_pool_s OMX_BRCM_POOL_T;\n\ntypedef struct OMX_PARAM_IMAGEPOOLEXTERNALTYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_BRCM_POOL_T *image_pool;\n   OMX_BRCM_POOL_T *image_pool2;\n   OMX_BRCM_POOL_T *image_pool3;\n   OMX_BRCM_POOL_T *image_pool4;\n   OMX_BRCM_POOL_T *image_pool5;\n} OMX_PARAM_IMAGEPOOLEXTERNALTYPE;\n/*\nThis config allows the client to pass in handles to pre-allocated\nimage pools for use within the component.\n*/\n\n\nstruct _IL_FIFO_T;\ntypedef struct OMX_PARAM_RUTILFIFOINFOTYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nPortIndex;\n   struct _IL_FIFO_T *pILFifo;\n} OMX_PARAM_RUTILFIFOINFOTYPE;\n\n/* OMX_IndexParamILFifoConfig: Allows configuration of the FIFO settings. */\ntypedef struct OMX_PARAM_ILFIFOCONFIG {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nPortIndex;\n   OMX_U32 nDataSize;         /**< The size of the FIFO's data area */\n   OMX_U32 nHeaderCount;      /**< The number of headers allocated */\n} OMX_PARAM_ILFIFOCONFIG;\n/**\n * Allows configuring the size of the ILFIFO used in a component.\n */\n\n/* OMX_IndexConfigCameraSensorModes: Camera Sensor Mode */\ntypedef struct OMX_CONFIG_CAMERASENSORMODETYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nPortIndex;\n   OMX_U32 nModeIndex;\n   OMX_U32 nNumModes;\n   OMX_U32 nWidth;\n   OMX_U32 nHeight;\n   OMX_U32 nPaddingRight;\n   OMX_U32 nPaddingDown;\n   OMX_COLOR_FORMATTYPE eColorFormat;\n   OMX_U32 nFrameRateMax;\n   OMX_U32 nFrameRateMin;\n} OMX_CONFIG_CAMERASENSORMODETYPE;\n/*\nThis parameter is used by clients to determine the sensor mode, and\nhence the memory usage, of the camera module. This is primarily used\nfor determining the size of the input image pool.\n\nIt can be used in two ways dependent on \\code{nPortIndex}. If\n\\code{nPortIndex} is \\code{OMX_ALL}, it returns the sensor mode\ncorresponding to \\code{nModeIndex}, and the number of modes in\n\\code{nNumModes}. If \\code{nModeIndex} is greater than or equal to\n\\code{nNumModes} only \\code{nNumModes} is returned. If\n\\code{nPortIndex} is equal to a camera video output port index, it\nreturns the sensor mode that would be selected for the values\ncurrently in \\code{OMX_IndexParamPortDefinition} for that port.\n\nThe \\code{nPaddingRight} and \\code{nPaddingDown} values determine the\nextra padding the sensor adds to the image. These values must be added\nto \\code{nWidth} and \\code{nHeight} respectively if the client is\nspecifying the input image pool size.\n*/\n\ntypedef struct OMX_BRCMBUFFERSTATSTYPE {\n   OMX_U32 nOrdinal;\n   OMX_TICKS nTimeStamp;\n   OMX_U32 nFilledLen;\n   OMX_U32 nFlags;\n   union\n   {\n      OMX_U32 nU32;\n      struct\n      {\n         OMX_U32 nYpart;\n         OMX_U32 nUVpart;\n      } image;\n   } crc;\n} OMX_BRCMBUFFERSTATSTYPE;\n\n/*\nPorts that gather statistics for debugging and diagnostics\nmight also collect information about buffer header fields\nand data.\n\nNote that:\n\nThe \\code{nOrdinal} field increases monotonically whenever\na new buffer is received or emitted and shall not be reset\nupon a port flush.\n\nThe \\code{nFilledLen} might indicate the size of a data area\nlarger than the data area that actually contributed to the\nchecksums (e.g. when image data is provided with cropping\ninformation).\n*/\n\n/* OMX_IndexConfigBrcmPortBufferStats: Query port buffer stats history */\ntypedef struct OMX_CONFIG_BRCMPORTBUFFERSTATSTYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nPortIndex;\n   OMX_U32 nCount;\n   OMX_BRCMBUFFERSTATSTYPE sData[1];\n} OMX_CONFIG_BRCMPORTBUFFERSTATSTYPE;\n/*\nPorts that gather statistics for debugging and diagnostics\nmight also collect information about buffer header fields\nand data.\n\nThe \\code{sStatsData} field is a variable length array and\nthe number of items is denoted by \\code{nStatsCount}.\n*/\n\n/* OMX_IndexConfigBrcmPortStats: Query port statistics */\ntypedef struct OMX_CONFIG_BRCMPORTSTATSTYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nPortIndex;\n   OMX_U32 nImageCount;\n   OMX_U32 nBufferCount;\n   OMX_U32 nFrameCount;\n   OMX_U32 nFrameSkips;\n   OMX_U32 nDiscards;\n   OMX_U32 nEOS;\n   OMX_U32 nMaxFrameSize;\n\n   OMX_TICKS nByteCount;\n   OMX_TICKS nMaxTimeDelta;\n   OMX_U32 nCorruptMBs;   /**< Number of corrupt macroblocks in the stream */\n} OMX_CONFIG_BRCMPORTSTATSTYPE;\n/*\nSome ports gather various statistics that can be used by clients for\ndebugging purposes.  This structure is the set of all statistics that\nare gathered.\n\nThe \\code{nFrameSkips} field indicates the number of frames that did\nnot have an expected PTS value based on the port frame rate.\n\nThe \\code{nByteCount} field is a 64 bit value, that will either use a\n64 bit type or two 32 bit types, similarly to \\code{OMX_TICKS}.\n*/\n\n/* OMX_IndexConfigBrcmClockMissCount: Missed clock request accounting */\n/*\nFor each port on the clock component, requests for media times may be\nmade.  These are typically done one per video frame to allow for\nscheduling the display of that frame at the correct time.  If a\nrequest is made after the time has occurred, then that frame will be\ndisplayed late, and the clock component keeps a per-port record of the\nnumber of times this occurs.  This record can be read using this\nindex.\n*/\n\ntypedef struct OMX_CONFIG_BRCMCAMERASTATSTYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nOutFrameCount;\n   OMX_U32 nDroppedFrameCount;\n} OMX_CONFIG_BRCMCAMERASTATSTYPE;\n\n// for backward compatibility\ntypedef struct OMX_CONFIG_BRCMCAMERASTATSTYPE OMX_CONFIG_BRCMCAMERASTATS;\n\n\n#define OMX_BRCM_MAXIOPERFBANDS 10\ntypedef struct {\n   OMX_U32 count[OMX_BRCM_MAXIOPERFBANDS];\n   OMX_U32 num[OMX_BRCM_MAXIOPERFBANDS];\n} OMX_BRCM_PERFSTATS;\n\n/* OMX_IndexConfigBrcmIOPerfStats: Query I/O performance statistics */\ntypedef struct OMX_CONFIG_BRCMIOPERFSTATSTYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_BOOL bEnabled;                              /**< Enable/disable I/O performance statistics */\n   OMX_BRCM_PERFSTATS write; /**< count:bytes     num:microseconds */\n   OMX_BRCM_PERFSTATS flush; /**< count:frequency num:microseconds waiting to flush data */\n   OMX_BRCM_PERFSTATS wait;  /**< count:frequency num:microseconds waiting in calling function */\n} OMX_CONFIG_BRCMIOPERFSTATSTYPE;\n/*\nA sink component can gather various statistics about I/O (eg. file media) performance that can be used by\nclients for debugging purposes.  The \\code{bEnabled} field is used to turn the gathering of statistics\non/off.\n*/\n\ntypedef struct OMX_CONFIG_SHARPNESSTYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nPortIndex;\n   OMX_S32 nSharpness;\n} OMX_CONFIG_SHARPNESSTYPE;\n\n/* OMX_IndexConfigCommonFlickerCancellation: Flicker cancellation */\ntypedef enum OMX_COMMONFLICKERCANCELTYPE {\n   OMX_COMMONFLICKERCANCEL_OFF,\n   OMX_COMMONFLICKERCANCEL_AUTO,\n   OMX_COMMONFLICKERCANCEL_50,\n   OMX_COMMONFLICKERCANCEL_60,\n   OMX_COMMONFLICKERCANCEL_DUMMY = 0x7FFFFFFF\n} OMX_COMMONFLICKERCANCELTYPE;\n\ntypedef struct OMX_CONFIG_FLICKERCANCELTYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nPortIndex;\n   OMX_COMMONFLICKERCANCELTYPE eFlickerCancel;\n} OMX_CONFIG_FLICKERCANCELTYPE;\n/*\nQuery / set the flicker cancellation frequency. Values are defined for Off,\n50Hz, 60Hz, or auto. The method for auto detecting the flicker frequency is\nnot defined, and currently results in the feature being turned off.\n*/\n\n/* OMX_IndexConfigCommonRedEyeRemoval: Red eye removal/reduction */\ntypedef enum OMX_REDEYEREMOVALTYPE {\n   OMX_RedEyeRemovalNone,                           /**< No red eye removal */\n   OMX_RedEyeRemovalOn,                             /**< Red eye removal on */\n   OMX_RedEyeRemovalAuto,                           /**< Red eye removal will be done automatically when detected */\n   OMX_RedEyeRemovalKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */\n   OMX_RedEyeRemovalVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n   OMX_RedEyeRemovalSimple,                         /**< Use simple red eye reduction mechanism if supported by algorithm */\n   OMX_RedEyeRemovalMax = 0x7FFFFFFF\n} OMX_REDEYEREMOVALTYPE;\n\ntypedef struct OMX_CONFIG_REDEYEREMOVALTYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nPortIndex;\n   OMX_REDEYEREMOVALTYPE eMode;\n} OMX_CONFIG_REDEYEREMOVALTYPE;\n/*\n   Configures the red eye reduction algorithm in the camera processing\n   pipeline. The stage is only enabled if the flash mode is not FlashOff.\n   The OMX_RedEyeRemovalSimple mode requests that the algorithm uses a\n   reduced complexity algorithm to reduce the processing time.\n*/\n\n\ntypedef enum OMX_FACEDETECTIONCONTROLTYPE {\n   OMX_FaceDetectionControlNone,                           /**< Disables face detection */\n   OMX_FaceDetectionControlOn,                             /**< Enables face detection */\n   OMX_FaceDetectionControlKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */\n   OMX_FaceDetectionControlVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n   OMX_FaceDetectionControlMax = 0x7FFFFFFF\n} OMX_FACEDETECTIONCONTROLTYPE;\n\ntypedef struct OMX_CONFIG_FACEDETECTIONCONTROLTYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nPortIndex;\n   OMX_FACEDETECTIONCONTROLTYPE eMode;\n   OMX_U32 nFrames;      /**< number of frames to apply this setting for,\n                              0 for unlimited */\n   OMX_U32 nMaxRegions;  /**< maximum number of regions to detect, 0 for unlimited */\n   OMX_U32 nQuality;     /**< hint for algorithmic complexity, range is 0-100.\n                              0 for simplest algorithm, 100 for best quality */\n} OMX_CONFIG_FACEDETECTIONCONTROLTYPE;\n\ntypedef enum OMX_FACEREGIONFLAGSTYPE {\n   OMX_FaceRegionFlagsNone    = 0,\n   OMX_FaceRegionFlagsBlink   = 1,\n   OMX_FaceRegionFlagsSmile   = 2,\n   OMX_FaceRegionFlagsKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */\n   OMX_FaceRegionFlagsVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n   OMX_FaceRegionFlagsMax = 0x7FFFFFFF\n} OMX_FACEREGIONFLAGSTYPE;\n\ntypedef struct OMX_FACEREGIONTYPE {\n   OMX_S16 nLeft;              /**< X Coordinate of the top left corner of the rectangle */\n   OMX_S16 nTop;               /**< Y Coordinate of the top left corner of the rectangle */\n   OMX_U16 nWidth;             /**< Width of the rectangle */\n   OMX_U16 nHeight;            /**< Height of the rectangle */\n   OMX_FACEREGIONFLAGSTYPE nFlags;  /**< Flags for the region */\n#ifndef OMX_SKIP64BIT\n   OMX_U64 nFaceRecognitionId; /**< ID returned by face recognition for this face */\n#else\n   struct\n   {\n      OMX_U32 nLowPart;   /**< low bits of the signed 64 bit value */\n      OMX_U32 nHighPart;  /**< high bits of the signed 64 bit value */\n   } nFaceRecognitionId;\n#endif\n} OMX_FACEREGIONTYPE;\n\ntypedef struct OMX_CONFIG_FACEDETECTIONREGIONTYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nPortIndex;            /**< index of port with face detection enabled */\n   OMX_U32 nIndex;                /**< first requested region number, allowing retrieval of many regions\n                                       over several requests */\n   OMX_U32 nDetectedRegions;      /**< total number of detected regions */\n   OMX_S32 nValidRegions;         /**< number of valid regions in sRegion array\n                                       When getting, the client sets this to the number of regions available.\n                                       The component writes region data and updates this field with how many\n                                       regions have been written to. */\n   OMX_U32 nImageWidth;           /**< Width of the image, hence reference for the face coordinates */\n   OMX_U32 nImageHeight;          /**< Height of the image, hence reference for the face coordinates */\n   OMX_FACEREGIONTYPE sRegion[1]; /**< variable length array of face regions */\n} OMX_CONFIG_FACEDETECTIONREGIONTYPE;\n\ntypedef enum OMX_INTERLACETYPE {\n   OMX_InterlaceProgressive,                    /**< The data is not interlaced, it is progressive scan */\n   OMX_InterlaceFieldSingleUpperFirst,          /**< The data is interlaced, fields sent\n                                                     separately in temporal order, with upper field first */\n   OMX_InterlaceFieldSingleLowerFirst,          /**< The data is interlaced, fields sent\n                                                     separately in temporal order, with lower field first */\n   OMX_InterlaceFieldsInterleavedUpperFirst,    /**< The data is interlaced, two fields sent together line\n                                                     interleaved, with the upper field temporally earlier */\n   OMX_InterlaceFieldsInterleavedLowerFirst,    /**< The data is interlaced, two fields sent together line\n                                                     interleaved, with the lower field temporally earlier */\n   OMX_InterlaceMixed,                          /**< The stream may contain a mixture of progressive\n                                                     and interlaced frames */\n   OMX_InterlaceKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */\n   OMX_InterlaceVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n   OMX_InterlaceMax = 0x7FFFFFFF\n} OMX_INTERLACETYPE;\n\ntypedef struct OMX_CONFIG_INTERLACETYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nPortIndex;            /**< index of port emitting or accepting the content */\n   OMX_INTERLACETYPE eMode;       /**< The interlace type of the content */\n   OMX_BOOL bRepeatFirstField;    /**< Whether to repeat the first field */\n} OMX_CONFIG_INTERLACETYPE;\n\n/* OMX_IndexParamIspTuner: Custom ISP tuner */\ntypedef struct OMX_PARAM_CAMERAISPTUNERTYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U8 tuner_name[64];\n} OMX_PARAM_CAMERAISPTUNERTYPE;\n/*\nThis parameter allows a custom ISP tuner to be loaded instead of\nthe default one specified for the camera module. Setting an empty\nstring uses the default value.\n*/\n\n/* OMX_IndexConfigCameraInputFrame: Pointer to the raw input image */\ntypedef struct OMX_CONFIG_IMAGEPTRTYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_PTR pImage;\n} OMX_CONFIG_IMAGEPTRTYPE;\n/*\nThis parameter parameter allows the return of a pointer to a\nVideoCore image resource.\n*/\n\n/* OMX_IndexConfigAFAssistLight: Autofocus assist light mode selection */\ntypedef enum OMX_AFASSISTTYPE {\n   OMX_AFAssistAuto,\n   OMX_AFAssistOn,\n   OMX_AFAssistOff,\n   OMX_AFAssistTorch,\n   OMX_AFAssistKhronosExtensions = 0x6F000000,\n   OMX_AFAssistVendorStartUnused = 0x7F000000,\n   OMX_AFAssistMax = 0x7FFFFFFF\n} OMX_AFASSISTTYPE;\n\ntypedef struct OMX_CONFIG_AFASSISTTYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nPortIndex;\n   OMX_AFASSISTTYPE eMode;\n} OMX_CONFIG_AFASSISTTYPE;\n/*\nSet the mode to adopt for the autofocus assist light.\n\\code{OMX_AFAssistTorch} will turn the AF assist light on permanently, allowing\nit to be used as a torch.\n*/\n\n/* OMX_IndexConfigInputCropPercentage: Specify input crop as a percentage */\ntypedef struct OMX_CONFIG_INPUTCROPTYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nPortIndex;\n   OMX_U32 xLeft;     /**< Fraction of the width for the top left corner of the rectangle */\n   OMX_U32 xTop;      /**< Fraction of the height for the top left corner of the rectangle */\n   OMX_U32 xWidth;    /**< Fraction of the image width desired */\n   OMX_U32 xHeight;   /**< Fraction of the image height desired */\n} OMX_CONFIG_INPUTCROPTYPE;\n/*\nThis parameter allows the input cropping to be specified as a\npercentage of the current width/height.  Required for the camera\ncomponent where the output resolution varies dependent on the port.\nAll percentage values are as 16p16 fixed point numbers (0x10000 =\n100\\%)\n*/\n\n/* OMX_IndexParamCodecRequirements: Advanced codec requirements */\ntypedef struct OMX_PARAM_CODECREQUIREMENTSTYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nCallbackID;\n   OMX_BOOL bTryHWCodec;\n} OMX_PARAM_CODECREQUIREMENTSTYPE;\n/*\nThis parameter allows internal users of RIL components controlling\nvideo codecs to request that the component loads the component and\nqueries for requirements.  The component will perform a callback with\nthe given nCallbackID value passing a pointer to the requirements\nstructure as the data field.\n*/\n\n/* OMX_IndexConfigBrcmEGLImageMemHandle: Mapping from an EGLImage to a VideoCore mem handle */\ntypedef struct OMX_CONFIG_BRCMEGLIMAGEMEMHANDLETYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nPortIndex;\n   OMX_PTR eglImage;\n   OMX_PTR memHandle;\n} OMX_CONFIG_BRCMEGLIMAGEMEMHANDLETYPE;\n/*\nThis config allows the EGL server to notify a RIL component that an\nEGLImage is available for rendering into and to provide a mapping from\nan EGLImage to a mem handle.\n*/\n\n/* OMX_IndexConfigPrivacyIndicator: Privacy indicator control */\ntypedef enum OMX_PRIVACYINDICATORTYPE {\n   OMX_PrivacyIndicatorOff,\n   OMX_PrivacyIndicatorOn,\n   OMX_PrivacyIndicatorForceOn,\n   OMX_PrivacyIndicatorKhronosExtensions = 0x6F000000,\n   OMX_PrivacyIndicatorVendorStartUnused = 0x7F000000,\n   OMX_PrivacyIndicatorMax = 0x7FFFFFFF\n} OMX_PRIVACYINDICATORTYPE;\n\ntypedef struct OMX_CONFIG_PRIVACYINDICATORTYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_PRIVACYINDICATORTYPE ePrivacyIndicatorMode;\n} OMX_CONFIG_PRIVACYINDICATORTYPE;\n/*\nThis config allows control over the privacy indicator light.  This\nlight indicates when a capture is in progress.\n\n\\code{OMX_PrivacyIndicatorOff} indicator is disabled.\n\n\\code{OMX_PrivacyIndicatorOn} indicator will be\nturned on whenever an image is being captured as determined by the\ncapturing bit. Minimum on duration of approx 200ms.\n\n\\code{OMX_PrivacyIndicatorForceOn} results in turning the indicator on\nimmediately, whether an image is being captured or not. The mode will\nautomatically revert to \\code{OMX_PrivacyIndicatorOff} once the\nindicator has been turned on, so \\code{OMX_PrivacyIndicatorForceOn}\nmust be requested at least every 200ms if the indicator is to remain\non.\n*/\n\n\n/* OMX_IndexParamCameraFlashType: Select flash type */\ntypedef enum OMX_CAMERAFLASHTYPE {\n   OMX_CameraFlashDefault,\n   OMX_CameraFlashXenon,\n   OMX_CameraFlashLED,\n   OMX_CameraFlashNone,\n   OMX_CameraFlashKhronosExtensions = 0x6F000000,\n   OMX_CameraFlashVendorStartUnused = 0x7F000000,\n   OMX_CameraFlashMax = 0x7FFFFFFF\n} OMX_CAMERAFLASHTYPE;\n\ntypedef struct OMX_PARAM_CAMERAFLASHTYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nPortIndex;\n   OMX_CAMERAFLASHTYPE eFlashType;\n   OMX_BOOL bRedEyeUsesTorchMode;\n} OMX_PARAM_CAMERAFLASHTYPE;\n/*\nThis parameter allows the selection of xenon or LED flash devices\nto be used with the currently selected camera. If that device is not\navailable, then the component will revert back to whatever flash\ndevice is available for that camera.\n\\code{bRedEyeUsesTorchMode} allows the blinking for red eye reduction to\nbe switched between using the indicator mode, and the torch mode for the\nflash driver.\n*/\n\n/* OMX_IndexConfigCameraFlashConfig: Flash cycle configuration */\ntypedef enum OMX_CAMERAFLASHCONFIGSYNCTYPE {\n   OMX_CameraFlashConfigSyncFrontSlow,\n   OMX_CameraFlashConfigSyncRearSlow,\n   OMX_CameraFlashConfigSyncFrontFast,\n   OMX_CameraFlashConfigSyncKhronosExtensions = 0x6F000000,\n   OMX_CameraFlashConfigSyncVendorStartUnused = 0x7F000000,\n   OMX_CameraFlashConfigSyncMax = 0x7FFFFFFF\n} OMX_CAMERAFLASHCONFIGSYNCTYPE;\n\ntypedef struct OMX_CONFIG_CAMERAFLASHCONFIGTYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nPortIndex;\n   OMX_BOOL bUsePreFlash;\n   OMX_BOOL bUseFocusDistanceInfo;\n   OMX_CAMERAFLASHCONFIGSYNCTYPE eFlashSync;\n   OMX_BOOL bIgnoreChargeState;\n} OMX_CONFIG_CAMERAFLASHCONFIGTYPE;\n/*\nThis parameter allows the configuration of various parameters relating to\nthe flash cycle. Some of the options are only applicable to xenon flash.\n\n\\code{bUsePreFlash} uses a low intensity pre-flash to determine flash intensity. This setting\nis recommended for almost all flash situations.\n\n\\code{bUseFocusDistanceInfo} uses the distance of the subject, as measured by the AF algorithm\nto set the intensity of the flash.\n\n\\code{eFlashSync} configures which edge of the shutter is used to synchronise the flash, and\nthe duration of the exposure.\n\n\\code{eIgnoreChargeState} will make the flash fire, even if it is not fully charged.\n*/\n\n/* OMX_IndexConfigBrcmAudioTrackGaplessPlayback: Encoder/decoder delay and padding information for gapless playback. */\ntypedef struct OMX_CONFIG_BRCMAUDIOTRACKGAPLESSPLAYBACKTYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nPortIndex;\n   OMX_U32 nDelay;   /**< number of samples delay added by the codec */\n   OMX_U32 nPadding; /**< number of silent samples added to the end */\n} OMX_CONFIG_BRCMAUDIOTRACKGAPLESSPLAYBACKTYPE;\n/*\nThis config allows communication between components to facilitate gapless playback.\n*/\n\n\n/* OMX_IndexConfigBrcmAudioTrackChangeControl: Configure gapless/crossfaded audio track change. */\ntypedef struct OMX_CONFIG_BRCMAUDIOTRACKCHANGECONTROLTYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nSrcPortIndex;\n   OMX_U32 nDstPortIndex;\n   OMX_U32 nXFade;\n} OMX_CONFIG_BRCMAUDIOTRACKCHANGECONTROLTYPE;\n/*\nThis config allows the client to specify the gapless or crossfade\nparameters to be used on a track change.  If \\code{nXFade} is 0, then\na normal or gapless track change will result, otherwise a crossfade of\n\\code{nXFade} ms is used.\n*/\n\n/* OMX_IndexParamBrcmPixelValueRange: Describing the pixel value range */\ntypedef enum OMX_BRCMPIXELVALUERANGETYPE\n{\n   OMX_PixelValueRangeUnspecified = 0,\n   OMX_PixelValueRangeITU_R_BT601,\n   OMX_PixelValueRangeFull8Bit,\n   OMX_PixelValueRangeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */\n   OMX_PixelValueRangeVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n   OMX_PixelValueRangeMax = 0x7FFFFFFF\n} OMX_BRCMPIXELVALUERANGETYPE;\n\ntypedef struct OMX_PARAM_BRCMPIXELVALUERANGETYPE\n{\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nPortIndex;\n   OMX_BRCMPIXELVALUERANGETYPE ePixelValueRange;\n} OMX_PARAM_BRCMPIXELVALUERANGETYPE;\n/*\nThis structure allows a description of the range that pixel values may\nhave.  This is typically useful since some standards use the full 8\nbit range, whereas others introduce pedastals which reduce the range\nat the top and bottom end.\n*/\n\n/* OMX_IndexParamCameraDisableAlgorithm: Disabling camera processing stages. */\ntypedef enum OMX_CAMERADISABLEALGORITHMTYPE {\n      OMX_CameraDisableAlgorithmFacetracking,\n      OMX_CameraDisableAlgorithmRedEyeReduction,\n      OMX_CameraDisableAlgorithmVideoStabilisation,\n      OMX_CameraDisableAlgorithmWriteRaw,\n      OMX_CameraDisableAlgorithmVideoDenoise,\n      OMX_CameraDisableAlgorithmStillsDenoise,\n      OMX_CameraDisableAlgorithmAntiShake,\n      OMX_CameraDisableAlgorithmImageEffects,\n      OMX_CameraDisableAlgorithmDarkSubtract,\n      OMX_CameraDisableAlgorithmDynamicRangeExpansion,\n      OMX_CameraDisableAlgorithmFaceRecognition,\n      OMX_CameraDisableAlgorithmFaceBeautification,\n      OMX_CameraDisableAlgorithmSceneDetection,\n      OMX_CameraDisableAlgorithmHighDynamicRange,\n   OMX_CameraDisableAlgorithmKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */\n   OMX_CameraDisableAlgorithmVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n   OMX_CameraDisableAlgorithmMax = 0x7FFFFFFF\n} OMX_CAMERADISABLEALGORITHMTYPE;\n\ntypedef struct OMX_PARAM_CAMERADISABLEALGORITHMTYPE\n{\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_CAMERADISABLEALGORITHMTYPE eAlgorithm;\n   OMX_BOOL bDisabled;\n} OMX_PARAM_CAMERADISABLEALGORITHMTYPE;\n/*\nAllows plugin algorithms to be disabled to save memory\nwithin the camera component\n*/\n\n/* OMX_IndexConfigBrcmAudioEffectControl: Audio Effect Control */\ntypedef struct OMX_CONFIG_BRCMAUDIOEFFECTCONTROLTYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nPortIndex;\n   OMX_BOOL bEnable;\n   OMX_U8 name[16];\n   OMX_U8 property[256];\n} OMX_CONFIG_BRCMAUDIOEFFECTCONTROLTYPE;\n/*\nThis structure represents the internal configuration of an audio effect.\nThe audio effect is provided by a loadable plug-in described\nin the \\code{name} field and is configured in a plug-in-dependent\nmanner with the \\code{property} field. The \\code{bEnable} field is used to\nturn the effect on/off.\n*/\n\n/* OMX_IndexConfigBrcmMinimumProcessingLatency: Processing Latency Bound */\ntypedef struct OMX_CONFIG_BRCMMINIMUMPROCESSINGLATENCY {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_TICKS nOffset;\n} OMX_CONFIG_BRCMMINIMUMPROCESSINGLATENCY;\n/*\nQuery/set the difference between the actual media time and when the\ncomponent receives request fulfillments for media time requests. This\ncan be used with e.g. splitter/mixer components to control when the\ncomponent stops waiting for input or output packets from active\nstreams and continues with processing (to maintain a constant\nprocessing rate).\n*/\n\n/** Enable or disable Supplemental Enhancment Information (SEI) messages to be inserted in\n  * the H.264 bitstream.\n  */\ntypedef struct OMX_PARAM_BRCMVIDEOAVCSEIENABLETYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nPortIndex;\n   OMX_BOOL bEnable;\n} OMX_PARAM_BRCMVIDEOAVCSEIENABLETYPE;\n\n/* OMX_IndexParamBrcmAllowMemChange: Allowing changing memory allocation on state transition */\ntypedef struct OMX_PARAM_BRCMALLOWMEMCHANGETYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_BOOL bEnable;\n} OMX_PARAM_BRCMALLOWMEMCHANGETYPE;\n/*\nLet the component change the amount of memory it has allocated when\ngoing from LOADED to IDLE. By default this is enabled, but if it is\ndisabled the component will fail to transition to IDLE if the\ncomponent requires more memory than has already been allocated.  This\nmight occur if (for example) the component was configured, taken to\nIDLE, then taken back to LOADED, the profile increased and the\ncomponent taken back to IDLE.\n*/\n\ntypedef enum OMX_CONFIG_CAMERAUSECASE {\n   OMX_CameraUseCaseAuto,\n   OMX_CameraUseCaseVideo,\n   OMX_CameraUseCaseStills,\n   OMX_CameraUseCaseKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */\n   OMX_CameraUseCaseVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n   OMX_CameraUseCaseMax = 0x7FFFFFFF\n} OMX_CONFIG_CAMERAUSECASE;\n\ntypedef struct OMX_CONFIG_CAMERAUSECASETYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_CONFIG_CAMERAUSECASE eUseCase;\n} OMX_CONFIG_CAMERAUSECASETYPE;\n\n/* OMX_IndexParamBrcmDisableProprietaryTunnels: Disabling proprietary tunnelling */\ntypedef struct OMX_PARAM_BRCMDISABLEPROPRIETARYTUNNELSTYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nPortIndex;\n   OMX_BOOL bUseBuffers;\n}  OMX_PARAM_BRCMDISABLEPROPRIETARYTUNNELSTYPE;\n/*\nTell a source component to refuse to support proprietary tunnelling. Buffers will be used instead.\n*/\n\n\n//\n// Control for memory allocation and component-internal buffering\n//\n\n/* OMX_IndexParamBrcmRetainMemory: Controlling memory use on state transition */\ntypedef struct OMX_PARAM_BRCMRETAINMEMORYTYPE\n{\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_BOOL bEnable;\n} OMX_PARAM_BRCMRETAINMEMORYTYPE;\n/*\nAsk a component to retain its memory when going from IDLE to LOADED, if possible.\nThis has the benefit that you are then guaranteed that the transition to IDLE cannot\nfail due to lack of memory, but has the disadvantage that you cannot leave the component\nlying around in LOADED, unused, since it is using significant amounts of memory.\n*/\n\n/** Tell write media how large the output buffer should be. This is a hint, and\n  * may be ignored. A good size is bandwidth*<SDcard-delay>, which works out at\n  * around 1Mbyte for up to 16Mbit/s. Sizes may (and probably will) be rounded down\n  * to the nearest power of 2.\n  */\ntypedef struct OMX_PARAM_BRCMOUTPUTBUFFERSIZETYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nBufferSize;\n} OMX_PARAM_BRCMOUTPUTBUFFERSIZETYPE;\n\n/* OMX_IndexConfigCameraInfo: Camera device driver information */\n#define OMX_CONFIG_CAMERAINFOTYPE_NAME_LEN 16\ntypedef struct OMX_CONFIG_LENSCALIBRATIONVALUETYPE\n{\n   OMX_U16  nShutterDelayTime;\n   OMX_U16  nNdTransparency;\n   OMX_U16  nPwmPulseNearEnd;  /**< Num pulses to move lens 1um at near end */\n   OMX_U16  nPwmPulseFarEnd;   /**< Num pulses to move lens 1um at far end */\n   OMX_U16  nVoltagePIOutNearEnd[3];\n   OMX_U16  nVoltagePIOut10cm[3];\n   OMX_U16  nVoltagePIOutInfinity[3];\n   OMX_U16  nVoltagePIOutFarEnd[3];\n   OMX_U32  nAdcConversionNearEnd;\n   OMX_U32  nAdcConversionFarEnd;\n} OMX_CONFIG_LENSCALIBRATIONVALUETYPE;\n/*\nAsk the camera component for the driver info on the current camera device\n*/\n\n#define OMX_CONFIG_CAMERAINFOTYPE_NAME_LEN 16\n#define OMX_CONFIG_CAMERAINFOTYPE_SERIALNUM_LEN 20\n#define OMX_CONFIG_CAMERAINFOTYPE_EPROMVER_LEN 8\ntypedef struct OMX_CONFIG_CAMERAINFOTYPE\n{\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U8 cameraname[OMX_CONFIG_CAMERAINFOTYPE_NAME_LEN];\n   OMX_U8 lensname[OMX_CONFIG_CAMERAINFOTYPE_NAME_LEN];\n   OMX_U16 nModelId;\n   OMX_U8 nManufacturerId;\n   OMX_U8 nRevNum;\n   OMX_U8 sSerialNumber[OMX_CONFIG_CAMERAINFOTYPE_SERIALNUM_LEN];\n   OMX_U8 sEpromVersion[OMX_CONFIG_CAMERAINFOTYPE_EPROMVER_LEN];\n   OMX_CONFIG_LENSCALIBRATIONVALUETYPE sLensCalibration;\n   OMX_U32 xFNumber;\n   OMX_U32 xFocalLength;\n} OMX_CONFIG_CAMERAINFOTYPE;\n\n\ntypedef enum OMX_CONFIG_CAMERAFEATURESSHUTTER {\n   OMX_CameraFeaturesShutterUnknown,\n   OMX_CameraFeaturesShutterNotPresent,\n   OMX_CameraFeaturesShutterPresent,\n   OMX_CameraFeaturesShutterKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */\n   OMX_CameraFeaturesShutterVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n   OMX_CameraFeaturesShutterMax = 0x7FFFFFFF\n} OMX_CONFIG_CAMERAFEATURESSHUTTER;\n\ntypedef struct OMX_CONFIG_CAMERAFEATURESTYPE\n{\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_CONFIG_CAMERAFEATURESSHUTTER eHasMechanicalShutter;\n   OMX_BOOL bHasLens;\n} OMX_CONFIG_CAMERAFEATURESTYPE;\n\n\n//Should be added to the spec as part of IL416c\n/* OMX_IndexConfigRequestCallback: Enable config change notifications. */\ntypedef struct OMX_CONFIG_REQUESTCALLBACKTYPE\n{\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nPortIndex;\n   OMX_INDEXTYPE nIndex;\n   OMX_BOOL bEnable;\n} OMX_CONFIG_REQUESTCALLBACKTYPE;\n/*\nThis config implements IL416c to allow clients to request notification\nof when a config or parameter is changed. When the parameter specified\nin \\code{nIndex} for port \\code{nPortIndex} changes, an\n\\code{OMX_EventParamOrConfigChanged} event is generated for the client.\n*/\n\n/* OMX_IndexConfigCommonFocusRegionXY: Define focus regions */\ntypedef enum OMX_FOCUSREGIONTYPE {\n   OMX_FocusRegionNormal,\n   OMX_FocusRegionFace,\n   OMX_FocusRegionMax\n} OMX_FOCUSREGIONTYPE;\n\ntypedef struct OMX_FOCUSREGIONXY {\n   OMX_U32 xLeft;\n   OMX_U32 xTop;\n   OMX_U32 xWidth;\n   OMX_U32 xHeight;\n   OMX_U32 nWeight;\n   OMX_U32 nMask;\n   OMX_FOCUSREGIONTYPE eType;\n} OMX_FOCUSREGIONXY;\n\ntypedef struct OMX_CONFIG_FOCUSREGIONXYTYPE\n{\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nPortIndex;\n   OMX_U32 nIndex;\n   OMX_U32 nTotalRegions;\n   OMX_S32 nValidRegions;\n   OMX_BOOL bLockToFaces;\n   OMX_U32 xFaceTolerance;\n   OMX_FOCUSREGIONXY sRegion[1];\n} OMX_CONFIG_FOCUSREGIONXYTYPE;\n/*\nQuery / set the focus regions to use as a set of x/y/width/height boxes relative\nto the overall image.\n\n\\code{nIndex} - first region number being set/read, allowing retrieval/setting\nof many regions over several requests.\n\n\\code{nTotalRegions} - total number of regions currently defined.\n\n\\code{nValidRegions} - number of valid regions in the \\code{sRegion} array.\nWhen getting, the client sets this to the number of regions available.\nThe component writes region data and updates this field with how many\nregions have been written to.\nWhen setting, this is the number of regions defined with this structure\n\n\\code{bLockToFaces} - compare the region(s) given to the latest face tracking results.\nIf a face is found within xFaceTolerance of the defined region, then amend the\nregion to correspond to the face.\n\n\\code{xFaceTolerance} - 0p16 value to define the max difference between the region centre\nand face tracking result centre to take the FT results\n\n\\code{sRegions} - variable length array of focus regions.\n*/\n\ntypedef struct OMX_CONFIG_U8TYPE {\n    OMX_U32 nSize;                    /**< Size of this structure, in Bytes */\n    OMX_VERSIONTYPE nVersion;         /**< OMX specification version information */\n    OMX_U32 nPortIndex;               /**< port that this structure applies to */\n    OMX_U8  nU8;                     /**< U8 value */\n} OMX_PARAM_U8TYPE;\n\ntypedef struct OMX_CONFIG_CAMERASETTINGSTYPE {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;               /**< port that this structure applies to */\n    OMX_U32 nExposure;\n    OMX_U32 nAnalogGain;\n    OMX_U32 nDigitalGain;\n    OMX_U32 nLux;\n    OMX_U32 nRedGain;\n    OMX_U32 nBlueGain;\n    OMX_U32 nFocusPosition;\n} OMX_CONFIG_CAMERASETTINGSTYPE;\n\n/* OMX_IndexConfigDrawBoxLineParams: Face box style parameters. */\ntypedef struct OMX_YUVCOLOUR {\n   OMX_U8 nY;\n   OMX_U8 nU;\n   OMX_U8 nV;\n} OMX_YUVCOLOUR;\n\ntypedef struct OMX_CONFIG_DRAWBOXLINEPARAMS {\n    OMX_U32 nSize;                           /**< Size of this structure, in Bytes */\n    OMX_VERSIONTYPE nVersion;                /**< OMX specification version information */\n    OMX_U32 nPortIndex;                      /**< Port to which this config applies */\n    OMX_U32 xCornerSize;                     /**< Size of the corners as a fraction of the complete side */\n    OMX_U32 nPrimaryFaceLineWidth;           /**< Width of the box line for the primary face in pixels */\n    OMX_U32 nOtherFaceLineWidth;             /**< Width of the box line for other faces in pixels */\n    OMX_U32 nFocusRegionLineWidth;           /**< Width of the box line for focus regions in pixels */\n    OMX_YUVCOLOUR sPrimaryFaceColour;        /**< YUV colour for the primary face */\n    OMX_YUVCOLOUR sPrimaryFaceSmileColour;   /**< YUV colour for the primary face if smiling */\n    OMX_YUVCOLOUR sPrimaryFaceBlinkColour;   /**< YUV colour for the primary face if blinking */\n    OMX_YUVCOLOUR sOtherFaceColour;          /**< YUV colour for the all other faces */\n    OMX_YUVCOLOUR sOtherFaceSmileColour;     /**< YUV colour for the all other faces if smiling */\n    OMX_YUVCOLOUR sOtherFaceBlinkColour;     /**< YUV colour for the all other faces if blinking */\n    OMX_BOOL bShowFocusRegionsWhenIdle;      /**< Are focus regions displayed when just in viewfinder/AF idle */\n    OMX_YUVCOLOUR sFocusRegionColour;        /**< YUV colour for focus regions */\n    OMX_BOOL bShowAfState;                   /**< Change to the colours specified below if AF cycle has run */\n    OMX_BOOL bShowOnlyPrimaryAfState;        /**< Only show the primary face when displaying the AF status */\n    OMX_BOOL bCombineNonFaceRegions;         /**< Combine all regions not defined as faces into one single box covering them all */\n    OMX_YUVCOLOUR sAfLockPrimaryFaceColour;  /**< YUV colour for the primary face */\n    OMX_YUVCOLOUR sAfLockOtherFaceColour;    /**< YUV colour for the all other faces */\n    OMX_YUVCOLOUR sAfLockFocusRegionColour;  /**< YUV colour for focus regions */\n    OMX_YUVCOLOUR sAfFailPrimaryFaceColour;  /**< YUV colour for the primary face */\n    OMX_YUVCOLOUR sAfFailOtherFaceColour;    /**< YUV colour for the all other faces */\n    OMX_YUVCOLOUR sAfFailFocusRegionColour;  /**< YUV colour for focus regions */\n } OMX_CONFIG_DRAWBOXLINEPARAMS;\n/*\nQuery / set the parameters for the box to be drawn around faces/focus regions.\n*/\n\n #define OMX_PARAM_CAMERARMITYPE_RMINAME_LEN 16\n //OMX_IndexParamCameraRmiControl\n typedef struct OMX_PARAM_CAMERARMITYPE {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_BOOL bEnabled;\n    OMX_U8 sRmiName[OMX_PARAM_CAMERARMITYPE_RMINAME_LEN];\n    OMX_U32 nInputBufferHeight;\n    OMX_U32 nRmiBufferSize;\n    OMX_BRCM_POOL_T *pImagePool;\n } OMX_PARAM_CAMERARMITYPE;\n\n/* OMX_IndexConfigBrcmSyncOutput: Forcing a write sync */\ntypedef struct OMX_CONFIG_BRCMSYNCOUTPUTTYPE {\n    OMX_U32 nSize;                           /**< Size of this structure, in Bytes */\n    OMX_VERSIONTYPE nVersion;                /**< OMX specification version information */\n}  OMX_CONFIG_BRCMSYNCOUTPUTTYPE;\n/*\nSetting this config forces a sync of data to the filesystem.\n*/\n\n/* OMX_IndexConfigDrmView: View information for DRM rental files */\ntypedef struct OMX_CONFIG_DRMVIEWTYPE {\n   OMX_U32 nSize;             /**< Size of this structure, in Bytes */\n   OMX_VERSIONTYPE nVersion;  /**< OMX specification version information */\n   OMX_U32 nCurrentView;      /**< Current view count */\n   OMX_U32 nMaxView;          /**< Max. no. of view allowed */\n} OMX_CONFIG_DRMVIEWTYPE;\n/*\nThis structure contains information about the number of available\nviews in the selected DRM rental file, which typically have a given\nmaximum view count.  It allows the user to explicitly agree to playing\nthe file, which will increment the number of current views the file\nhas had.\n*/\n\ntypedef struct OMX_PARAM_BRCMU64TYPE {\n    OMX_U32 nSize;                    /**< Size of this structure, in Bytes */\n    OMX_VERSIONTYPE nVersion;         /**< OMX specification version information */\n    OMX_U32 nPortIndex;               /**< port that this structure applies to */\n    OMX_U32 nLowPart;                 /**< low bits of the unsigned 64 bit value */\n    OMX_U32 nHighPart;                /**< high bits of the unsigned 64 bit value */\n} OMX_PARAM_BRCMU64TYPE;\n\n/* OMX_IndexParamBrcmDisableEXIF: Disable generation of EXIF data */\n/*\nThis parameter is used by clients to control the generation of exif\ndata in JPEG images.\n*/\n\n/* OMX_IndexParamBrcmThumbnail: Control generation of thumbnail */\ntypedef struct OMX_PARAM_BRCMTHUMBNAILTYPE {\n    OMX_U32 nSize;                    /**< Size of this structure, in Bytes */\n    OMX_VERSIONTYPE nVersion;         /**< OMX specification version information */\n    OMX_BOOL bEnable;                 /**< Enable generation of thumbnails during still capture */\n    OMX_BOOL bUsePreview;             /**< Use the preview image (as is) as thumbnail */\n    OMX_U32 nWidth;                   /**< Desired width of the thumbnail */\n    OMX_U32 nHeight;                  /**< Desired height of the thumbnail */\n} OMX_PARAM_BRCMTHUMBNAILTYPE;\n/*\nThis parameter is used by clients to control how thumbnails are\ngenerated when creating still images.\n\nThumbnail generation will be turned on or off depending on the\n\\code{bEnable} field.\n\nThe \\code{bUsePreview} field will let the component know whether it\nshould use the low resolution preview image (if the component has one\navailable) as is for the thumbnail. When this is set to true, it should\nmake the generation of thumbnails faster (if a preview image is available)\nand should use less memory as well.\n\nThe \\code{nWidth} and \\code{nHeight} fields allow the client to\nspecify the dimensions of the thumbnail.  If both \\code{nWidth} and\n\\code{nHeight} are 0, we will calculate a sensible size for the\nthumbnail.\n*/\n\ntypedef struct OMX_PARAM_BRCMASPECTRATIOTYPE {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n    OMX_U32 nWidth;\n    OMX_U32 nHeight;\n} OMX_PARAM_BRCMASPECTRATIOTYPE;\n\n/* OMX_IndexParamBrcmVideoDecodeErrorConcealment: Control error concealment for video decode */\ntypedef struct OMX_PARAM_BRCMVIDEODECODEERRORCONCEALMENTTYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_BOOL bStartWithValidFrame; /**< Decoder will only start emitting frames from a non-corrupted frame */\n} OMX_PARAM_BRCMVIDEODECODEERRORCONCEALMENTTYPE;\n/*\n This parameter is used by clients to control the type of error concealment\n that will be done by the video decoder.\n */\n\n#define OMX_CONFIG_FLASHINFOTYPE_NAME_LEN 16\ntypedef struct OMX_CONFIG_FLASHINFOTYPE\n{\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U8 sFlashName[OMX_CONFIG_FLASHINFOTYPE_NAME_LEN];\n   OMX_CAMERAFLASHTYPE eFlashType;\n   OMX_U8 nDeviceId;\n   OMX_U8 nDeviceVersion;\n} OMX_CONFIG_FLASHINFOTYPE;\n\n/* OMX_IndexParamBrcmInterpolateMissingTimestamps: Configure component to interpolate missing timestamps */\n/*\nConfigures a component so that it tries to timestamp all the buffers it outputs.\nIf the timestamp information is missing from the original buffer, the\ncomponent will try its best to interpolate a value for the missing timestamp.\n */\n\n/* OMX_IndexParamBrcmSetCodecPerformanceMonitoring: Configure component to output performance statistics */\n/*\nConfigures a codec component so that it outputs performance statistics to\nthe given DECODE_PROGRESS_REPORT_T structure (passed as a pointer).\nThis structure can then be read by the client to find out where the codec is\nat in its processing.\n */\n\n/* OMX_IndexConfigDynamicRangeExpansion: Configure image dynamic range expansion processing */\ntypedef enum OMX_DYNAMICRANGEEXPANSIONMODETYPE {\n   OMX_DynRangeExpOff,\n   OMX_DynRangeExpLow,\n   OMX_DynRangeExpMedium,\n   OMX_DynRangeExpHigh,\n   OMX_DynRangeExpKhronosExtensions = 0x6F000000,\n   OMX_DynRangeExpVendorStartUnused = 0x7F000000,\n   OMX_DynRangeExpMax = 0x7FFFFFFF\n} OMX_DYNAMICRANGEEXPANSIONMODETYPE;\n\ntypedef struct OMX_CONFIG_DYNAMICRANGEEXPANSIONTYPE\n{\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_DYNAMICRANGEEXPANSIONMODETYPE eMode;\n} OMX_CONFIG_DYNAMICRANGEEXPANSIONTYPE;\n/*\nConfigures the intensity of an image dynamic range expansion processing stage\n*/\n\n/* OMX_IndexParamBrcmTransposeBufferCount: Configure the number of pre-allocated transpose buffers  */\n/*\nThis config allows the client to explicitly set the number of destination buffers pre-allocated for\nports that support 90/270 degree rotation (e.g. in video_render). The buffers will be pre-allocated during\na state transition from LOADED to IDLE (the transition will fail if there is not enough memory available\nfor the buffers).\n.\n*/\n\n\n/* OMX_IndexParamBrcmThreadAffinity: Control the CPU affinity of component thread(s) */\ntypedef enum OMX_BRCMTHREADAFFINITYTYPE {\n   OMX_BrcmThreadAffinityCPU0,\n   OMX_BrcmThreadAffinityCPU1,\n   OMX_BrcmThreadAffinityMax = 0x7FFFFFFF\n} OMX_BRCMTHREADAFFINITYTYPE;\n\ntypedef struct OMX_PARAM_BRCMTHREADAFFINITYTYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_BRCMTHREADAFFINITYTYPE eAffinity;  /**< Thread CPU affinity */\n} OMX_PARAM_BRCMTHREADAFFINITYTYPE;\n/*\n This parameter is used by clients to hint the CPU that a component thread should run on.\n */\n\n /* OMX_IndexConfigCommonSceneDetected: Reports the scene type detected by a scene detection algorithm. */\ntypedef enum OMX_SCENEDETECTTYPE {\n   OMX_SceneDetectUnknown,\n   OMX_SceneDetectLandscape,\n   OMX_SceneDetectPortrait,\n   OMX_SceneDetectMacro,\n   OMX_SceneDetectNight,\n   OMX_SceneDetectPortraitNight,\n   OMX_SceneDetectBacklit,\n   OMX_SceneDetectPortraitBacklit,\n   OMX_SceneDetectSunset,\n   OMX_SceneDetectBeach,\n   OMX_SceneDetectSnow,\n   OMX_SceneDetectFireworks,\n   OMX_SceneDetectMax = 0x7FFFFFFF\n} OMX_SCENEDETECTTYPE;\n\n/* OMX_IndexConfigCommonSceneDetected: Reports the scene type detected by a scene detection algorithm. */\ntypedef struct OMX_CONFIG_SCENEDETECTTYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_SCENEDETECTTYPE eScene;  /**< Scene type detected */\n} OMX_CONFIG_SCENEDETECTTYPE;\n/*\n This config is used to report to clients the scene type that has been detected.\n */\n\n/* OMX_IndexParamNalStreamFormat: Control the NAL unit packaging. This is a Khronos extension. */\ntypedef enum OMX_INDEXEXTTYPE {\n    /* Video parameters and configurations */\n    OMX_IndexExtVideoStartUnused = OMX_IndexKhronosExtensions + 0x00600000,\n    OMX_IndexParamNalStreamFormatSupported,         /**< reference: OMX_NALSTREAMFORMATTYPE */\n    OMX_IndexParamNalStreamFormat,                  /**< reference: OMX_NALSTREAMFORMATTYPE */\n    OMX_IndexParamNalStreamFormatSelect,            /**< reference: OMX_NALSTREAMFORMATTYPE */\n\n    OMX_IndexExtMax = 0x7FFFFFFF\n} OMX_INDEXEXTTYPE;\n\n/* OMX_IndexParamNalStreamFormat: Control the NAL unit packaging. This is a Khronos extension. */\ntypedef enum OMX_NALUFORMATSTYPE {\n    OMX_NaluFormatStartCodes = 1,\n    OMX_NaluFormatOneNaluPerBuffer = 2,\n    OMX_NaluFormatOneByteInterleaveLength = 4,\n    OMX_NaluFormatTwoByteInterleaveLength = 8,\n    OMX_NaluFormatFourByteInterleaveLength = 16,\n    OMX_NaluFormatCodingMax = 0x7FFFFFFF\n} OMX_NALUFORMATSTYPE;\n\n/* OMX_IndexParamNalStreamFormat: Control the NAL unit packaging. This is a Khronos extension. */\ntypedef struct OMX_NALSTREAMFORMATTYPE{\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n    OMX_NALUFORMATSTYPE eNaluFormat;\n} OMX_NALSTREAMFORMATTYPE;\n/*\n This parameter is used to control the NAL unit packaging of an H264 video port.\n */\n\n/* OMX_IndexParamVideoMvc: MVC codec parameters */\ntypedef  struct OMX_VIDEO_PARAM_AVCTYPE  OMX_VIDEO_PARAM_MVCTYPE;\n/*\nThis parameter is currently identical to the AVC parameter type.\n*/\n\n /* OMX_IndexConfigBrcmDrawStaticBox: Define static box to be drawn */\ntypedef enum OMX_STATICBOXTYPE {\n   OMX_StaticBoxNormal,\n   OMX_StaticBoxPrimaryFaceAfIdle,\n   OMX_StaticBoxNonPrimaryFaceAfIdle,\n   OMX_StaticBoxFocusRegionAfIdle,\n   OMX_StaticBoxPrimaryFaceAfSuccess,\n   OMX_StaticBoxNonPrimaryFaceAfSuccess,\n   OMX_StaticBoxFocusRegionAfSuccess,\n   OMX_StaticBoxPrimaryFaceAfFail,\n   OMX_StaticBoxNonPrimaryFaceAfFail,\n   OMX_StaticBoxFocusRegionAfFail,\n   OMX_StaticBoxMax\n} OMX_STATICBOXTYPE;\n\ntypedef struct OMX_STATICBOX {\n   OMX_U32 xLeft;\n   OMX_U32 xTop;\n   OMX_U32 xWidth;\n   OMX_U32 xHeight;\n   OMX_STATICBOXTYPE eType;\n} OMX_STATICBOX;\n\ntypedef struct OMX_CONFIG_STATICBOXTYPE\n{\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nPortIndex;\n   OMX_U32 nIndex;\n   OMX_U32 nTotalBoxes;\n   OMX_S32 nValidBoxes;\n   OMX_BOOL bDrawOtherBoxes;\n   OMX_STATICBOX sBoxes[1];\n} OMX_CONFIG_STATICBOXTYPE;\n/*\nQuery / set the parameters for a box to always be drawn on viewfinder images\nThe x/y/width/height values for the boxes are relative to the overall image.\n\n\\code{nIndex} - first box number being set/read, allowing retrieval/setting\nof many boxes over several requests.\n\n\\code{nValidBoxes} - total number of boxes currently defined.\n\n\\code{nValidBoxes} - number of valid boxes in the \\code{sBoxes} array.\nWhen getting, the client sets this to the number of boxes available.\nThe component writes box data and updates this field with how many\nboxes have been written to.\nWhen setting, this is the number of boxes defined with this structure\n\n\\code{sBoxes} - variable length array of static boxes.\n*/\n\n/* OMX_IndexConfigPortCapturing: Per-port capturing state */\ntypedef struct OMX_CONFIG_PORTBOOLEANTYPE{\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n    OMX_BOOL bEnabled;\n} OMX_CONFIG_PORTBOOLEANTYPE;\n/*\nThis is proposed in IL533f for controlling\nwhich ports of a multi-port camera component are capturing frames.\n*/\n\n/* OMX_IndexConfigCaptureMode: Capturing mode type */\ntypedef enum OMX_CAMERACAPTUREMODETYPE {\n   OMX_CameraCaptureModeWaitForCaptureEnd,\n   OMX_CameraCaptureModeWaitForCaptureEndAndUsePreviousInputImage,\n   OMX_CameraCaptureModeResumeViewfinderImmediately,\n   OMX_CameraCaptureModeMax,\n} OMX_CAMERACAPTUREMODETYPE;\n\ntypedef struct OMX_PARAM_CAMERACAPTUREMODETYPE{\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n    OMX_CAMERACAPTUREMODETYPE eMode;\n} OMX_PARAM_CAMERACAPTUREMODETYPE;\n/*\nThis controls the mode of operation for\nstill image capture in the camera component.\n*/\n\n/* OMX_IndexParamBrcmDrmEncryption: Set DRM encryption scheme */\ntypedef enum OMX_BRCMDRMENCRYPTIONTYPE\n{\n   OMX_DrmEncryptionNone = 0,\n   OMX_DrmEncryptionHdcp2,\n   OMX_DrmEncryptionKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */\n   OMX_DrmEncryptionVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n   OMX_DrmEncryptionRangeMax = 0x7FFFFFFF\n} OMX_BRCMDRMENCRYPTIONTYPE;\n\ntypedef struct OMX_PARAM_BRCMDRMENCRYPTIONTYPE\n{\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nPortIndex;\n   OMX_BRCMDRMENCRYPTIONTYPE eEncryption;\n   OMX_U32 nConfigDataLen;\n   OMX_U8 configData[1];\n} OMX_PARAM_BRCMDRMENCRYPTIONTYPE;\n/*\nQuery/set the DRM encryption scheme used by a port writing out data.\n*/\n\n\n/* OMX_IndexConfigBufferStall: Advertise buffer stall state */\ntypedef struct OMX_CONFIG_BUFFERSTALLTYPE\n{\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nPortIndex;\n   OMX_BOOL bStalled;      /**< Whether we are stalled */\n   OMX_U32 nDelay;         /**< Delay in real time (us) from last buffer to current time */\n} OMX_CONFIG_BUFFERSTALLTYPE;\n/*\nQuery/set the buffer stall threashold.  When set the \\code{nDelay}\nparameter specifies a time to class whether buffer output is stalled.\nWhen get, the \\code{nDelay} parameter indicates the current buffer\ndelay, and the {bStalled} parameter indicates whether this time is\nover a previously set threashold.  When\n\\code{OMX_IndexConfigRequestCallback} is used with this index, a\nnotification is given when \\code{bStalled} changes.\n*/\n\n/* OMX_IndexConfigLatencyTarget: Maintain target latency by adjusting clock speed */\ntypedef struct OMX_CONFIG_LATENCYTARGETTYPE\n{\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nPortIndex;\n   OMX_BOOL bEnabled; /**< whether this mode is enabled */\n   OMX_U32 nFilter; /**< number of latency samples to filter on, good value: 1 */\n   OMX_U32 nTarget; /**< target latency, us */\n   OMX_U32 nShift;  /**< shift for storing latency values, good value: 7 */\n   OMX_S32 nSpeedFactor; /**< multiplier for speed changes, in 24.8 format, good value: 256-512 */\n   OMX_S32 nInterFactor; /**< divider for comparing latency versus gradiant, good value: 300 */\n   OMX_S32 nAdjCap; /**< limit for speed change before nSpeedFactor is applied, good value: 100 */\n} OMX_CONFIG_LATENCYTARGETTYPE;\n/*\nQuery/set parameters used when adjusting clock speed to match the\nmeasured latency to a specified value.\n*/\n\n/* OMX_IndexConfigBrcmUseProprietaryCallback: Force use of proprietary callback */\ntypedef struct OMX_CONFIG_BRCMUSEPROPRIETARYCALLBACKTYPE\n{\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nPortIndex;\n   OMX_BOOL bEnable;\n} OMX_CONFIG_BRCMUSEPROPRIETARYCALLBACKTYPE;\n/*\nDisable/enable the use of proprietary callbacks rather than OpenMAX IL buffer handling.\n*/\n\n/* OMX_IndexParamCommonUseStcTimestamps: Select timestamp mode */\ntypedef enum OMX_TIMESTAMPMODETYPE\n{\n   OMX_TimestampModeZero = 0,       /**< Use a timestamp of 0 */\n   OMX_TimestampModeRawStc,         /**< Use the raw STC as the timestamp */\n   OMX_TimestampModeResetStc,       /**< Store the STC when video capture port goes active, and subtract that from STC for the timestamp */\n   OMX_TimestampModeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */\n   OMX_TimestampModeVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n   OMX_TimestampModeMax = 0x7FFFFFFF\n} OMX_TIMESTAMPMODETYPE;\n\ntypedef struct OMX_PARAM_TIMESTAMPMODETYPE\n{\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_TIMESTAMPMODETYPE eTimestampMode;\n} OMX_PARAM_TIMESTAMPMODETYPE;\n/*\n Specifies what to use as timestamps in the absence of a clock component.\n*/\n\n/* EGL image buffer for passing to video port.\n * Used when port color format is OMX_COLOR_FormatBRCMEGL.\n */\ntypedef struct OMX_BRCMVEGLIMAGETYPE\n{\n   /* Passed between ARM + VC; use fixed width types. */\n   OMX_U32 nWidth;\n   OMX_U32 nHeight;\n   OMX_U32 nStride;\n   OMX_U32 nUmemHandle;\n   OMX_U32 nUmemOffset;\n   OMX_U32 nFlipped;    /* Non-zero -> vertically flipped image */\n} OMX_BRCMVEGLIMAGETYPE;\n\n/* Provides field of view \n */\ntypedef struct OMX_CONFIG_BRCMFOVTYPE\n{\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nPortIndex;\n   OMX_U32 xFieldOfViewHorizontal;  /**< Horizontal field of view in degrees. 16p16 value */\n   OMX_U32 xFieldOfViewVertical;    /**< Vertical field of view in degrees. 16p16 value */\n} OMX_CONFIG_BRCMFOVTYPE;\n\n/* OMX_IndexConfigBrcmDecoderPassThrough: Enabling Audio Passthrough */\n/*\nThis allows an audio decoder to disable decoding the stream and pass through correctly framed\ndata to enable playback of compressed audio to supported output devices.\n*/\n\n/* OMX_IndexConfigBrcmClockReferenceSource: Select Clock Reference Source */\n/*\nThis control allows communicating directly to an audio renderer component whether it should\nact as a clock reference source or act as a slave.\n*/\n\n/* OMX_IndexConfigEncLevelExtension: AVC Override encode capabilities */\ntypedef struct OMX_VIDEO_CONFIG_LEVEL_EXTEND {\n   OMX_U32 nSize; \n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nPortIndex;\n   OMX_U32 nCustomMaxMBPS;     /**< Specifies maximum macro-blocks per second */\n   OMX_U32 nCustomMaxFS;       /**< Specifies maximum frame size (macro-blocks per frame) */\n   OMX_U32 nCustomMaxBRandCPB; /**< Specifies maximum bitrate in units of 1000 bits/s and Codec Picture Buffer (CPB derived from bitrate) */\n} OMX_VIDEO_CONFIG_LEVEL_EXTEND;\n/*\nThis allows finer control of the H264 encode internal parameters.\n*/\n\n/* OMX_IndexParamBrcmEEDEEnable: Enable/Disable end to end distortion estimator */\ntypedef struct OMX_VIDEO_EEDE_ENABLE {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n    OMX_U32 enable;\n} OMX_VIDEO_EEDE_ENABLE;\n/*\nThis enables or disables the use of end to end distortion estimation.\n*/\n\n/* OMX_IndexParamBrcmEEDELossRate: Loss rate configuration for end to end distortion */\ntypedef struct OMX_VIDEO_EEDE_LOSSRATE {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n   OMX_U32 loss_rate; /**< loss rate, 5 means 5% */\n} OMX_VIDEO_EEDE_LOSSRATE;\n/*\nSet the packet loss rate used by the end to end distortion estimator.\n*/\n\n/* OMX_IndexParamColorSpace: Colour space information */\ntypedef enum OMX_COLORSPACETYPE\n{\n   OMX_COLORSPACE_UNKNOWN,\n   OMX_COLORSPACE_JPEG_JFIF,\n   OMX_COLORSPACE_ITU_R_BT601,\n   OMX_COLORSPACE_ITU_R_BT709,\n   OMX_COLORSPACE_FCC,\n   OMX_COLORSPACE_SMPTE240M,\n   OMX_COLORSPACE_BT470_2_M,\n   OMX_COLORSPACE_BT470_2_BG,\n   OMX_COLORSPACE_JFIF_Y16_255,\n   OMX_COLORSPACE_MAX = 0x7FFFFFFF\n} OMX_COLORSPACETYPE;\n\ntypedef struct OMX_PARAM_COLORSPACETYPE\n{\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nPortIndex;\n   OMX_COLORSPACETYPE eColorSpace;\n} OMX_PARAM_COLORSPACETYPE;\n/*\nSets the colourspace with which pixel buffers should be generated / interpreted.\n*/\n\ntypedef enum OMX_CAPTURESTATETYPE\n{\n   OMX_NotCapturing,\n   OMX_CaptureStarted,\n   OMX_CaptureComplete,\n   OMX_CaptureMax = 0x7FFFFFFF\n} OMX_CAPTURESTATETYPE;\n\ntypedef struct OMX_PARAM_CAPTURESTATETYPE\n{\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nPortIndex;\n   OMX_CAPTURESTATETYPE eCaptureState;\n} OMX_PARAM_CAPTURESTATETYPE;\n\n/*\nProvides information on the colour space that's in use during image/video processing.\n*/\n\n/* OMX_IndexConfigMinimiseFragmentation: Minimising Fragmentation */\n/*\nThis control can be supported to enable the client to request that the component works\nto minimise fragmentation of output buffers.\n*/\n\n/* OMX_IndexConfigBrcmBufferFlagFilter: Filter buffers based on flags */\n/*\nThis control can be set to request that buffers are conditionally forwarded on \noutput ports based on matching flags set on that buffer.\n*/\n\n/* OMX_IndexParamPortMaxFrameSize: Specifying maximum frame size */\n/*\nThis control can be used to control the maximum frame size allowed on an output port.\n*/\n\n/* OMX_IndexConfigBrcmCameraRnDPreprocess: Enable use of development ISP software stage */\n/*\nThis control can be used to enable a developmental software stage to be inserted into\nthe preprocessor stage of the ISP.\n*/\n\n/* OMX_IndexConfigBrcmCameraRnDPostprocess: Enable use of development ISP software stage */\n/*\nThis control can be used to enable a developmental software stage to be inserted into\nthe postprocessor stage of the ISP.\n*/\n\n/* OMX_IndexParamDisableVllPool: Controlling use of memory for loadable modules */\n/*\nThis control can be used to control whether loadable modules used a dedicated memory\npool or use heap allocated memory.\n*/\n\n/* OMX_IndexParamBrcmVideoPrecodeForQP: Pre-code 1st frame for QP.*/\n/*\nThis control selects a pre-encode of the first frame to set up a better initial QP value.\n*/\n\n/* OMX_IndexParamBrcmVideoTimestampFifo: Video timestamp FIFO mode. */\n/*\nWhen enabled, the timestamp fifo mode will change the way\nincoming timestamps are associated with output images so the incoming timestamps\nget used without re-ordering on output images.\n*/\n\n/* OMX_IndexParamCameraCustomSensorConfig: Custom camera sensor configuration. */\n/*\nThis parameter is passed down to the camera sensor driver to be interpreted as a\nrequest for a different configuration to normal. How the configuration varies is\nsensor specific.\n*/\n\n/* OMX_IndexParamCameraDeviceNumber: Camera device selection .*/\n/*\nControls which camera driver, or camera peripheral, to use.\n*/\n\n/* OMX_IndexParamBrcmMaxNumCallbacks: Codec callback limit. */\n/*\nThe codec can queue up a significant number of frames internally if the sink is\nnot consuming the output fast enough. This control limits the number of frames\nthat can be queued up.\n*/\n\ntypedef struct OMX_PARAM_BRCMCONFIGFILETYPE {\n   OMX_U32 nSize;                      /**< size of the structure in bytes, including\n                                            actual URI name */\n   OMX_VERSIONTYPE nVersion;           /**< OMX specification version information */\n   OMX_U32 fileSize;                   /**< Size of complete file data */\n} OMX_PARAM_BRCMCONFIGFILETYPE;\n\ntypedef struct OMX_PARAM_BRCMCONFIGFILECHUNKTYPE {\n   OMX_U32 nSize;                      /**< size of the structure in bytes, including\n                                            actual chunk data */\n   OMX_VERSIONTYPE nVersion;           /**< OMX specification version information */\n   OMX_U32 size;                       /**< Number of bytes being transferred in this chunk */\n   OMX_U32 offset;                     /**< Offset of this chunk in the file */\n   OMX_U8 data[1];                     /**< Chunk data */\n} OMX_PARAM_BRCMCONFIGFILECHUNKTYPE;\n\ntypedef struct OMX_PARAM_BRCMFRAMERATERANGETYPE {\n   OMX_U32 nSize;                      /**< size of the structure in bytes, including\n                                            actual chunk data */\n   OMX_VERSIONTYPE nVersion;           /**< OMX specification version information */\n   OMX_U32 nPortIndex;\n   OMX_U32 xFramerateLow;              /**< Low end of framerate range. Q16 format */\n   OMX_U32 xFramerateHigh;             /**< High end of framerate range. Q16 format */\n} OMX_PARAM_BRCMFRAMERATERANGETYPE;\n\ntypedef struct OMX_PARAM_S32TYPE {\n    OMX_U32 nSize;                    /**< Size of this structure, in Bytes */\n    OMX_VERSIONTYPE nVersion;         /**< OMX specification version information */\n    OMX_U32 nPortIndex;               /**< port that this structure applies to */\n    OMX_S32 nS32;                     /**< S32 value */\n} OMX_PARAM_S32TYPE;\n\ntypedef struct OMX_PARAM_BRCMVIDEODRMPROTECTBUFFERTYPE\n{\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n\n   OMX_U32 size_wanted;     /**< Input. Zero size means internal video decoder buffer,\n                                 mem_handle and phys_addr not returned in this case */\n   OMX_U32 protect;         /**< Input. 1 = protect, 0 = unprotect */\n\n   OMX_U32 mem_handle;      /**< Output. Handle for protected buffer */\n   OMX_PTR phys_addr;       /**< Output. Physical memory address of protected buffer */\n} OMX_PARAM_BRCMVIDEODRMPROTECTBUFFERTYPE;\n\ntypedef struct OMX_CONFIG_ZEROSHUTTERLAGTYPE\n{\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n\n   OMX_U32 bZeroShutterMode;        /**< Select ZSL mode from the camera. */\n   OMX_U32 bConcurrentCapture;      /**< Perform concurrent captures for full ZSL. */\n\n} OMX_CONFIG_ZEROSHUTTERLAGTYPE;\n\n/* OMX_IndexParamBrcmVideoDecodeConfigVD3: VDec3 configuration. */\ntypedef struct OMX_PARAM_BRCMVIDEODECODECONFIGVD3TYPE {\n   OMX_U32 nSize;                      /**< size of the structure in bytes, including\n                                            configuration data */\n   OMX_VERSIONTYPE nVersion;           /**< OMX specification version information */\n   OMX_U8 config[1];                   /**< Configuration data (a VD3_CONFIGURE_T) */\n} OMX_PARAM_BRCMVIDEODECODECONFIGVD3TYPE;\n/*\nCodec specific configuration block to set up internal state in a non-standard manner.\n*/\n\ntypedef struct OMX_CONFIG_CUSTOMAWBGAINSTYPE {\n   OMX_U32 nSize;                      /**< size of the structure in bytes, including\n                                            configuration data */\n   OMX_VERSIONTYPE nVersion;           /**< OMX specification version information */\n   OMX_U32 xGainR;                     /**< Red gain - 16p16 */\n   OMX_U32 xGainB;                     /**< Blue gain - 16p16 */\n} OMX_CONFIG_CUSTOMAWBGAINSTYPE;\n\n/* OMX_IndexConfigBrcmRenderStats: Render port statistics */\ntypedef struct OMX_CONFIG_BRCMRENDERSTATSTYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_U32 nPortIndex;\n   OMX_BOOL nValid;\n   OMX_U32 nMatch;\n   OMX_U32 nPeriod;\n   OMX_U32 nPhase;\n   OMX_U32 nPixelClockNominal;\n   OMX_U32 nPixelClock;\n   OMX_U32 nHvsStatus;\n   OMX_U32 dummy0[2];\n} OMX_CONFIG_BRCMRENDERSTATSTYPE;\n/*\nThis provides statistics from the renderer to allow more accurate synchronisation\nbetween the scheduler and display VSYNC.\n*/\n\n#define OMX_BRCM_MAXANNOTATETEXTLEN 256\ntypedef struct OMX_CONFIG_BRCMANNOTATETYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_BOOL bEnable;\n   OMX_BOOL bShowShutter;\n   OMX_BOOL bShowAnalogGain;\n   OMX_BOOL bShowLens;\n   OMX_BOOL bShowCaf;\n   OMX_BOOL bShowMotion;\n   OMX_BOOL bShowFrameNum;\n   OMX_BOOL bEnableBackground;\n   OMX_BOOL bCustomBackgroundColour;\n   OMX_U8 nBackgroundY;\n   OMX_U8 nBackgroundU;\n   OMX_U8 nBackgroundV;\n   OMX_U8 dummy1;\n   OMX_BOOL bCustomTextColour;\n   OMX_U8 nTextY;\n   OMX_U8 nTextU;\n   OMX_U8 nTextV;\n   OMX_U8 nTextSize;   /**< Text size: 6-150 pixels */\n   OMX_U8 sText[OMX_BRCM_MAXANNOTATETEXTLEN];\n} OMX_CONFIG_BRCMANNOTATETYPE;\n\n/* OMX_IndexParamBrcmStereoscopicMode: Stereoscopic camera support */\ntypedef enum OMX_BRCMSTEREOSCOPICMODETYPE {\n   OMX_STEREOSCOPIC_NONE = 0,\n   OMX_STEREOSCOPIC_SIDEBYSIDE = 1,\n   OMX_STEREOSCOPIC_TOPBOTTOM = 2,\n   OMX_STEREOSCOPIC_MAX = 0x7FFFFFFF,\n} OMX_BRCMSTEREOSCOPICMODETYPE;\n\ntypedef struct OMX_CONFIG_BRCMSTEREOSCOPICMODETYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n\n   OMX_U32 nPortIndex;                    /**< port that this structure applies to */\n   OMX_BRCMSTEREOSCOPICMODETYPE eMode;    /**< Packing mode */\n   OMX_BOOL bDecimate;                    /**< Half/half mode\n                                          (pixel aspect ratio = 1:2 or 2:1 if set. 1:1 if not set) */\n   OMX_BOOL bSwapEyes;                    /**< False = left eye first. True = right eye first. */\n} OMX_CONFIG_BRCMSTEREOSCOPICMODETYPE;\n/*\nThis control sets up how stereoscopic images should be generated.\n*/\n\n/* OMX_IndexParamCameraInterface: Camera interface type. */\ntypedef enum OMX_CAMERAINTERFACETYPE {\n   OMX_CAMERAINTERFACE_CSI = 0,\n   OMX_CAMERAINTERFACE_CCP2 = 1,\n   OMX_CAMERAINTERFACE_CPI = 2,\n   OMX_CAMERAINTERFACE_MAX = 0x7FFFFFFF,\n} OMX_CAMERAINTERFACETYPE;\n\ntypedef struct OMX_PARAM_CAMERAINTERFACETYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n\n   OMX_U32 nPortIndex;                    /**< port that this structure applies to */\n   OMX_CAMERAINTERFACETYPE eMode;         /**< Interface mode */\n} OMX_PARAM_CAMERAINTERFACETYPE;\n/*\nThis configures the physical camera interface type.\n*/\n\ntypedef enum OMX_CAMERACLOCKINGMODETYPE {\n   OMX_CAMERACLOCKINGMODE_STROBE = 0,\n   OMX_CAMERACLOCKINGMODE_CLOCK = 1,\n   OMX_CAMERACLOCKINGMODE_MAX = 0x7FFFFFFF,\n} OMX_CAMERACLOCKINGMODETYPE;\n\ntypedef struct OMX_PARAM_CAMERACLOCKINGMODETYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n\n   OMX_U32 nPortIndex;                    /**< port that this structure applies to */\n   OMX_CAMERACLOCKINGMODETYPE eMode;      /**< Clocking mode */\n} OMX_PARAM_CAMERACLOCKINGMODETYPE;\n\n/* OMX_IndexParamCameraRxConfig: Camera receiver configuration */\ntypedef enum OMX_CAMERARXDECODETYPE {\n   OMX_CAMERARXDECODE_NONE = 0,\n   OMX_CAMERARXDECODE_DPCM8TO10 = 1,\n   OMX_CAMERARXDECODE_DPCM7TO10 = 2,\n   OMX_CAMERARXDECODE_DPCM6TO10 = 3,\n   OMX_CAMERARXDECODE_DPCM8TO12 = 4,\n   OMX_CAMERARXDECODE_DPCM7TO12 = 5,\n   OMX_CAMERARXDECODE_DPCM6TO12 = 6,\n   OMX_CAMERARXDECODE_DPCM10TO14 = 7,\n   OMX_CAMERARXDECODE_DPCM8TO14 = 8,\n   OMX_CAMERARXDECODE_DPCM12TO16 = 9,\n   OMX_CAMERARXDECODE_DPCM10TO16 = 10,\n   OMX_CAMERARXDECODE_DPCM8TO16 = 11,\n   OMX_CAMERARXDECODE_MAX = 0x7FFFFFFF\n} OMX_CAMERARXDECODETYPE;\n\ntypedef enum OMX_CAMERARXENCODETYPE {\n   OMX_CAMERARXENCODE_NONE = 0,\n   OMX_CAMERARXENCODE_DPCM10TO8 = 1,\n   OMX_CAMERARXENCODE_DPCM12TO8 = 2,\n   OMX_CAMERARXENCODE_DPCM14TO8 = 3,\n   OMX_CAMERARXENCODE_MAX = 0x7FFFFFFF\n} OMX_CAMERARXENCODETYPE;\n\ntypedef enum OMX_CAMERARXUNPACKTYPE {\n   OMX_CAMERARXUNPACK_NONE = 0,\n   OMX_CAMERARXUNPACK_6 = 1,\n   OMX_CAMERARXUNPACK_7 = 2,\n   OMX_CAMERARXUNPACK_8 = 3,\n   OMX_CAMERARXUNPACK_10 = 4,\n   OMX_CAMERARXUNPACK_12 = 5,\n   OMX_CAMERARXUNPACK_14 = 6,\n   OMX_CAMERARXUNPACK_16 = 7,\n   OMX_CAMERARXUNPACK_MAX = 0x7FFFFFFF\n} OMX_CAMERARXUNPACKYPE;\n\ntypedef enum OMX_CAMERARXPACKTYPE {\n   OMX_CAMERARXPACK_NONE = 0,\n   OMX_CAMERARXPACK_8 = 1,\n   OMX_CAMERARXPACK_10 = 2,\n   OMX_CAMERARXPACK_12 = 3,\n   OMX_CAMERARXPACK_14 = 4,\n   OMX_CAMERARXPACK_16 = 5,\n   OMX_CAMERARXPACK_RAW10 = 6,\n   OMX_CAMERARXPACK_RAW12 = 7,\n   OMX_CAMERARXPACK_MAX = 0x7FFFFFFF\n} OMX_CAMERARXPACKTYPE;\n\ntypedef struct OMX_PARAM_CAMERARXCONFIG_TYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n\n   OMX_U32 nPortIndex;                    /**< port that this structure applies to */\n   OMX_CAMERARXDECODETYPE eDecode;\n   OMX_CAMERARXENCODETYPE eEncode;\n   OMX_CAMERARXUNPACKYPE eUnpack;\n   OMX_CAMERARXPACKTYPE ePack;\n   OMX_U32 nDataLanes;\n   OMX_U32 nEncodeBlockLength;\n   OMX_U32 nEmbeddedDataLines;\n   OMX_U32 nImageId;\n} OMX_PARAM_CAMERARXCONFIG_TYPE;\n/*\nConfigures the setup and processing options of the camera receiver peripheral.\n*/\n\ntypedef struct OMX_PARAM_CAMERARXTIMING_TYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n\n   OMX_U32 nPortIndex;                    /**< port that this structure applies to */\n   OMX_U32 nTiming1;\n   OMX_U32 nTiming2;\n   OMX_U32 nTiming3;\n   OMX_U32 nTiming4;\n   OMX_U32 nTiming5;\n   OMX_U32 nTerm1;\n   OMX_U32 nTerm2;\n   OMX_U32 nCpiTiming1;\n   OMX_U32 nCpiTiming2;\n} OMX_PARAM_CAMERARXTIMING_TYPE;\n\n\n/* OMX_IndexParamBrcmBayerOrder: Bayer order */\ntypedef enum OMX_BAYERORDERTYPE {\n   OMX_BayerOrderRGGB = 0,\n   OMX_BayerOrderGBRG = 1,\n   OMX_BayerOrderBGGR = 2,\n   OMX_BayerOrderGRBG = 3,\n\n   OMX_BayerOrderMax = 0x7FFFFFFF\n} OMX_BAYERORDERTYPE;\n\ntypedef struct OMX_PARAM_BAYERORDERTYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n\n   OMX_U32 nPortIndex;                    /**< port that this structure applies to */\n   OMX_BAYERORDERTYPE eBayerOrder;\n} OMX_PARAM_BAYERORDERTYPE;\n/*\nThe IL standard does not support a way to specify the Bayer order of Bayer images.\nThis control adds that missing functionality.\n*/\n\n/* OMX_IndexConfigBrcmPowerMonitor: Deprecated.*/\n/*\nDeprecated. Do not use.\n*/\n\n/* OMX_IndexParamBrcmZeroCopy: Deprecated */\n/*\nDeprecated. Do not use.\n*/\n\n#endif\n/* File EOF */\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vmcs_host/khronos/IL/OMX_Component.h",
    "content": "/*\n * Copyright (c) 2008 The Khronos Group Inc. \n * \n * Permission is hereby granted, free of charge, to any person obtaining\n * a copy of this software and associated documentation files (the\n * \"Software\"), to deal in the Software without restriction, including\n * without limitation the rights to use, copy, modify, merge, publish,\n * distribute, sublicense, and/or sell copies of the Software, and to\n * permit persons to whom the Software is furnished to do so, subject\n * to the following conditions: \n * The above copyright notice and this permission notice shall be included\n * in all copies or substantial portions of the Software. \n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\n * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\n * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\n * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \n *\n */\n\n/** OMX_Component.h - OpenMax IL version 1.1.2\n *  The OMX_Component header file contains the definitions used to define\n *  the public interface of a component.  This header file is intended to\n *  be used by both the application and the component.\n */\n\n#ifndef OMX_Component_h\n#define OMX_Component_h\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif /* __cplusplus */\n\n\n\n/* Each OMX header must include all required header files to allow the\n *  header to compile without errors.  The includes below are required\n *  for this header file to compile successfully \n */\n\n#include \"OMX_Audio.h\"\n#include \"OMX_Video.h\"\n#include \"OMX_Image.h\"\n#include \"OMX_Other.h\"\n\n/** @ingroup comp */\ntypedef enum OMX_PORTDOMAINTYPE { \n    OMX_PortDomainAudio, \n    OMX_PortDomainVideo, \n    OMX_PortDomainImage, \n    OMX_PortDomainOther,\n    OMX_PortDomainKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_PortDomainVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_PortDomainMax = 0x7ffffff\n} OMX_PORTDOMAINTYPE;\n\n/** @ingroup comp */\ntypedef struct OMX_PARAM_PORTDEFINITIONTYPE {\n    OMX_U32 nSize;                 /**< Size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion;      /**< OMX specification version information */\n    OMX_U32 nPortIndex;            /**< Port number the structure applies to */\n    OMX_DIRTYPE eDir;              /**< Direction (input or output) of this port */\n    OMX_U32 nBufferCountActual;    /**< The actual number of buffers allocated on this port */\n    OMX_U32 nBufferCountMin;       /**< The minimum number of buffers this port requires */\n    OMX_U32 nBufferSize;           /**< Size, in bytes, for buffers to be used for this channel */\n    OMX_BOOL bEnabled;             /**< Ports default to enabled and are enabled/disabled by\n                                        OMX_CommandPortEnable/OMX_CommandPortDisable.\n                                        When disabled a port is unpopulated. A disabled port\n                                        is not populated with buffers on a transition to IDLE. */\n    OMX_BOOL bPopulated;           /**< Port is populated with all of its buffers as indicated by\n                                        nBufferCountActual. A disabled port is always unpopulated. \n                                        An enabled port is populated on a transition to OMX_StateIdle\n                                        and unpopulated on a transition to loaded. */\n    OMX_PORTDOMAINTYPE eDomain;    /**< Domain of the port. Determines the contents of metadata below. */\n    union {\n        OMX_AUDIO_PORTDEFINITIONTYPE audio;\n        OMX_VIDEO_PORTDEFINITIONTYPE video;\n        OMX_IMAGE_PORTDEFINITIONTYPE image;\n        OMX_OTHER_PORTDEFINITIONTYPE other;\n    } format;\n    OMX_BOOL bBuffersContiguous;\n    OMX_U32 nBufferAlignment;\n} OMX_PARAM_PORTDEFINITIONTYPE;\n\n/** @ingroup comp */\ntypedef struct OMX_PARAM_U32TYPE { \n    OMX_U32 nSize;                    /**< Size of this structure, in Bytes */ \n    OMX_VERSIONTYPE nVersion;         /**< OMX specification version information */ \n    OMX_U32 nPortIndex;               /**< port that this structure applies to */ \n    OMX_U32 nU32;                     /**< U32 value */\n} OMX_PARAM_U32TYPE;\n\n/** @ingroup rpm */\ntypedef enum OMX_SUSPENSIONPOLICYTYPE {\n    OMX_SuspensionDisabled, /**< No suspension; v1.0 behavior */\n    OMX_SuspensionEnabled,  /**< Suspension allowed */   \n    OMX_SuspensionPolicyKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_SuspensionPolicyStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_SuspensionPolicyMax = 0x7fffffff\n} OMX_SUSPENSIONPOLICYTYPE;\n\n/** @ingroup rpm */\ntypedef struct OMX_PARAM_SUSPENSIONPOLICYTYPE {\n    OMX_U32 nSize;                  \n    OMX_VERSIONTYPE nVersion;        \n    OMX_SUSPENSIONPOLICYTYPE ePolicy;\n} OMX_PARAM_SUSPENSIONPOLICYTYPE;\n\n/** @ingroup rpm */\ntypedef enum OMX_SUSPENSIONTYPE {\n    OMX_NotSuspended, /**< component is not suspended */\n    OMX_Suspended,    /**< component is suspended */\n    OMX_SuspensionKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_SuspensionVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_SuspendMax = 0x7FFFFFFF\n} OMX_SUSPENSIONTYPE;\n\n/** @ingroup rpm */\ntypedef struct OMX_PARAM_SUSPENSIONTYPE {\n    OMX_U32 nSize;                  \n    OMX_VERSIONTYPE nVersion;       \n    OMX_SUSPENSIONTYPE eType;             \n} OMX_PARAM_SUSPENSIONTYPE ;\n\ntypedef struct OMX_CONFIG_BOOLEANTYPE {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_BOOL bEnabled;    \n} OMX_CONFIG_BOOLEANTYPE;\n\n/* Parameter specifying the content uri to use. */\n/** @ingroup cp */\ntypedef struct OMX_PARAM_CONTENTURITYPE\n{\n    OMX_U32 nSize;                      /**< size of the structure in bytes, including\n                                             actual URI name */\n    OMX_VERSIONTYPE nVersion;           /**< OMX specification version information */\n    OMX_U8 contentURI[1];               /**< The URI name */\n} OMX_PARAM_CONTENTURITYPE;\n\n/* Parameter specifying the pipe to use. */\n/** @ingroup cp */\ntypedef struct OMX_PARAM_CONTENTPIPETYPE\n{\n    OMX_U32 nSize;              /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion;   /**< OMX specification version information */\n    OMX_HANDLETYPE hPipe;       /**< The pipe handle*/\n} OMX_PARAM_CONTENTPIPETYPE;\n\n/** @ingroup rpm */\ntypedef struct OMX_RESOURCECONCEALMENTTYPE {\n    OMX_U32 nSize;             /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion;  /**< OMX specification version information */\n    OMX_BOOL bResourceConcealmentForbidden; /**< disallow the use of resource concealment \n                                            methods (like degrading algorithm quality to \n                                            lower resource consumption or functional bypass) \n                                            on a component as a resolution to resource conflicts. */\n} OMX_RESOURCECONCEALMENTTYPE;\n\n\n/** @ingroup metadata */\ntypedef enum OMX_METADATACHARSETTYPE {\n    OMX_MetadataCharsetUnknown = 0,\n    OMX_MetadataCharsetASCII,\n    OMX_MetadataCharsetBinary,\n    OMX_MetadataCharsetCodePage1252,\n    OMX_MetadataCharsetUTF8,\n    OMX_MetadataCharsetJavaConformantUTF8,\n    OMX_MetadataCharsetUTF7,\n    OMX_MetadataCharsetImapUTF7,\n    OMX_MetadataCharsetUTF16LE, \n    OMX_MetadataCharsetUTF16BE,\n    OMX_MetadataCharsetGB12345,\n    OMX_MetadataCharsetHZGB2312,\n    OMX_MetadataCharsetGB2312,\n    OMX_MetadataCharsetGB18030,\n    OMX_MetadataCharsetGBK,\n    OMX_MetadataCharsetBig5,\n    OMX_MetadataCharsetISO88591,\n    OMX_MetadataCharsetISO88592,\n    OMX_MetadataCharsetISO88593,\n    OMX_MetadataCharsetISO88594,\n    OMX_MetadataCharsetISO88595,\n    OMX_MetadataCharsetISO88596,\n    OMX_MetadataCharsetISO88597,\n    OMX_MetadataCharsetISO88598,\n    OMX_MetadataCharsetISO88599,\n    OMX_MetadataCharsetISO885910,\n    OMX_MetadataCharsetISO885913,\n    OMX_MetadataCharsetISO885914,\n    OMX_MetadataCharsetISO885915,\n    OMX_MetadataCharsetShiftJIS,\n    OMX_MetadataCharsetISO2022JP,\n    OMX_MetadataCharsetISO2022JP1,\n    OMX_MetadataCharsetISOEUCJP,\n    OMX_MetadataCharsetSMS7Bit,\n    OMX_MetadataCharsetKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_MetadataCharsetVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_MetadataCharsetTypeMax= 0x7FFFFFFF\n} OMX_METADATACHARSETTYPE;\n\n/** @ingroup metadata */\ntypedef enum OMX_METADATASCOPETYPE\n{\n    OMX_MetadataScopeAllLevels,\n    OMX_MetadataScopeTopLevel,\n    OMX_MetadataScopePortLevel,\n    OMX_MetadataScopeNodeLevel,\n    OMX_MetadataScopeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_MetadataScopeVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_MetadataScopeTypeMax = 0x7fffffff\n} OMX_METADATASCOPETYPE;\n\n/** @ingroup metadata */\ntypedef enum OMX_METADATASEARCHMODETYPE\n{\n    OMX_MetadataSearchValueSizeByIndex,\n    OMX_MetadataSearchItemByIndex,\n    OMX_MetadataSearchNextItemByKey,\n    OMX_MetadataSearchKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_MetadataSearchVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_MetadataSearchTypeMax = 0x7fffffff\n} OMX_METADATASEARCHMODETYPE;\n/** @ingroup metadata */\ntypedef struct OMX_CONFIG_METADATAITEMCOUNTTYPE\n{\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_METADATASCOPETYPE eScopeMode;\n    OMX_U32 nScopeSpecifier;\n    OMX_U32 nMetadataItemCount;\n} OMX_CONFIG_METADATAITEMCOUNTTYPE;\n\n/** @ingroup metadata */\ntypedef struct OMX_CONFIG_METADATAITEMTYPE\n{\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_METADATASCOPETYPE eScopeMode;\n    OMX_U32 nScopeSpecifier;\n    OMX_U32 nMetadataItemIndex;  \n    OMX_METADATASEARCHMODETYPE eSearchMode;\n    OMX_METADATACHARSETTYPE eKeyCharset;\n    OMX_U8 nKeySizeUsed;\n    OMX_U8 nKey[128];\n    OMX_METADATACHARSETTYPE eValueCharset;\n    OMX_STRING sLanguageCountry;\n    OMX_U32 nValueMaxSize;\n    OMX_U32 nValueSizeUsed;\n    OMX_U8 nValue[1];\n} OMX_CONFIG_METADATAITEMTYPE;\n\n/* @ingroup metadata */\ntypedef struct OMX_CONFIG_CONTAINERNODECOUNTTYPE\n{\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_BOOL bAllKeys;\n    OMX_U32 nParentNodeID;\n    OMX_U32 nNumNodes;\n} OMX_CONFIG_CONTAINERNODECOUNTTYPE;\n\n/** @ingroup metadata */\ntypedef struct OMX_CONFIG_CONTAINERNODEIDTYPE\n{\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_BOOL bAllKeys;\n    OMX_U32 nParentNodeID;\n    OMX_U32 nNodeIndex; \n    OMX_U32 nNodeID; \n    OMX_STRING cNodeName;\n    OMX_BOOL bIsLeafType;\n} OMX_CONFIG_CONTAINERNODEIDTYPE;\n\n/** @ingroup metadata */\ntypedef struct OMX_PARAM_METADATAFILTERTYPE \n{ \n    OMX_U32 nSize; \n    OMX_VERSIONTYPE nVersion; \n    OMX_BOOL bAllKeys;\t/* if true then this structure refers to all keys and \n                         * the three key fields below are ignored */\n    OMX_METADATACHARSETTYPE eKeyCharset;\n    OMX_U32 nKeySizeUsed; \n    OMX_U8   nKey [128]; \n    OMX_U32 nLanguageCountrySizeUsed;\n    OMX_U8 nLanguageCountry[128];\n    OMX_BOOL bEnabled;\t/* if true then key is part of filter (e.g. \n                         * retained for query later). If false then\n                         * key is not part of filter */\n} OMX_PARAM_METADATAFILTERTYPE; \n\n/** The OMX_HANDLETYPE structure defines the component handle.  The component \n *  handle is used to access all of the component's public methods and also\n *  contains pointers to the component's private data area.  The component\n *  handle is initialized by the OMX core (with help from the component)\n *  during the process of loading the component.  After the component is\n *  successfully loaded, the application can safely access any of the\n *  component's public functions (although some may return an error because\n *  the state is inappropriate for the access).\n * \n *  @ingroup comp\n */\ntypedef struct OMX_COMPONENTTYPE\n{\n    /** The size of this structure, in bytes.  It is the responsibility\n        of the allocator of this structure to fill in this value.  Since\n        this structure is allocated by the GetHandle function, this\n        function will fill in this value. */\n    OMX_U32 nSize;\n\n    /** nVersion is the version of the OMX specification that the structure \n        is built against.  It is the responsibility of the creator of this \n        structure to initialize this value and every user of this structure \n        should verify that it knows how to use the exact version of \n        this structure found herein. */\n    OMX_VERSIONTYPE nVersion;\n\n    /** pComponentPrivate is a pointer to the component private data area.  \n        This member is allocated and initialized by the component when the \n        component is first loaded.  The application should not access this \n        data area. */\n    OMX_PTR pComponentPrivate;\n\n    /** pApplicationPrivate is a pointer that is a parameter to the \n        OMX_GetHandle method, and contains an application private value \n        provided by the IL client.  This application private data is \n        returned to the IL Client by OMX in all callbacks */\n    OMX_PTR pApplicationPrivate;\n\n    /** refer to OMX_GetComponentVersion in OMX_core.h or the OMX IL \n        specification for details on the GetComponentVersion method.\n     */\n    OMX_ERRORTYPE (*GetComponentVersion)(\n            OMX_IN  OMX_HANDLETYPE hComponent,\n            OMX_OUT OMX_STRING pComponentName,\n            OMX_OUT OMX_VERSIONTYPE* pComponentVersion,\n            OMX_OUT OMX_VERSIONTYPE* pSpecVersion,\n            OMX_OUT OMX_UUIDTYPE* pComponentUUID);\n\n    /** refer to OMX_SendCommand in OMX_core.h or the OMX IL \n        specification for details on the SendCommand method.\n     */\n    OMX_ERRORTYPE (*SendCommand)(\n            OMX_IN  OMX_HANDLETYPE hComponent,\n            OMX_IN  OMX_COMMANDTYPE Cmd,\n            OMX_IN  OMX_U32 nParam1,\n            OMX_IN  OMX_PTR pCmdData);\n\n    /** refer to OMX_GetParameter in OMX_core.h or the OMX IL \n        specification for details on the GetParameter method.\n     */\n    OMX_ERRORTYPE (*GetParameter)(\n            OMX_IN  OMX_HANDLETYPE hComponent, \n            OMX_IN  OMX_INDEXTYPE nParamIndex,  \n            OMX_INOUT OMX_PTR pComponentParameterStructure);\n\n\n    /** refer to OMX_SetParameter in OMX_core.h or the OMX IL \n        specification for details on the SetParameter method.\n     */\n    OMX_ERRORTYPE (*SetParameter)(\n            OMX_IN  OMX_HANDLETYPE hComponent, \n            OMX_IN  OMX_INDEXTYPE nIndex,\n            OMX_IN  OMX_PTR pComponentParameterStructure);\n\n\n    /** refer to OMX_GetConfig in OMX_core.h or the OMX IL \n        specification for details on the GetConfig method.\n     */\n    OMX_ERRORTYPE (*GetConfig)(\n            OMX_IN  OMX_HANDLETYPE hComponent,\n            OMX_IN  OMX_INDEXTYPE nIndex, \n            OMX_INOUT OMX_PTR pComponentConfigStructure);\n\n\n    /** refer to OMX_SetConfig in OMX_core.h or the OMX IL \n        specification for details on the SetConfig method.\n     */\n    OMX_ERRORTYPE (*SetConfig)(\n            OMX_IN  OMX_HANDLETYPE hComponent,\n            OMX_IN  OMX_INDEXTYPE nIndex, \n            OMX_IN  OMX_PTR pComponentConfigStructure);\n\n\n    /** refer to OMX_GetExtensionIndex in OMX_core.h or the OMX IL \n        specification for details on the GetExtensionIndex method.\n     */\n    OMX_ERRORTYPE (*GetExtensionIndex)(\n            OMX_IN  OMX_HANDLETYPE hComponent,\n            OMX_IN  OMX_STRING cParameterName,\n            OMX_OUT OMX_INDEXTYPE* pIndexType);\n\n\n    /** refer to OMX_GetState in OMX_core.h or the OMX IL \n        specification for details on the GetState method.\n     */\n    OMX_ERRORTYPE (*GetState)(\n            OMX_IN  OMX_HANDLETYPE hComponent,\n            OMX_OUT OMX_STATETYPE* pState);\n\n    \n    /** The ComponentTunnelRequest method will interact with another OMX\n        component to determine if tunneling is possible and to setup the\n        tunneling.  The return codes for this method can be used to \n        determine if tunneling is not possible, or if tunneling is not\n        supported.  \n        \n        Base profile components (i.e. non-interop) do not support this\n        method and should return OMX_ErrorNotImplemented \n\n        The interop profile component MUST support tunneling to another \n        interop profile component with a compatible port parameters.  \n        A component may also support proprietary communication.\n        \n        If proprietary communication is supported the negotiation of \n        proprietary communication is done outside of OMX in a vendor \n        specific way. It is only required that the proper result be \n        returned and the details of how the setup is done is left \n        to the component implementation.  \n    \n        When this method is invoked when nPort in an output port, the\n        component will:\n        1.  Populate the pTunnelSetup structure with the output port's \n            requirements and constraints for the tunnel.\n\n        When this method is invoked when nPort in an input port, the\n        component will:\n        1.  Query the necessary parameters from the output port to \n            determine if the ports are compatible for tunneling\n        2.  If the ports are compatible, the component should store\n            the tunnel step provided by the output port\n        3.  Determine which port (either input or output) is the buffer\n            supplier, and call OMX_SetParameter on the output port to\n            indicate this selection.\n        \n        The component will return from this call within 5 msec.\n    \n        @param [in] hComp\n            Handle of the component to be accessed.  This is the component\n            handle returned by the call to the OMX_GetHandle method.\n        @param [in] nPort\n            nPort is used to select the port on the component to be used\n            for tunneling.\n        @param [in] hTunneledComp\n            Handle of the component to tunnel with.  This is the component \n            handle returned by the call to the OMX_GetHandle method.  When\n            this parameter is 0x0 the component should setup the port for\n            communication with the application / IL Client.\n        @param [in] nPortOutput\n            nPortOutput is used indicate the port the component should\n            tunnel with.\n        @param [in] pTunnelSetup\n            Pointer to the tunnel setup structure.  When nPort is an output port\n            the component should populate the fields of this structure.  When\n            When nPort is an input port the component should review the setup\n            provided by the component with the output port.\n        @return OMX_ERRORTYPE\n            If the command successfully executes, the return code will be\n            OMX_ErrorNone.  Otherwise the appropriate OMX error will be returned.\n        @ingroup tun\n    */\n\n    OMX_ERRORTYPE (*ComponentTunnelRequest)(\n        OMX_IN  OMX_HANDLETYPE hComp,\n        OMX_IN  OMX_U32 nPort,\n        OMX_IN  OMX_HANDLETYPE hTunneledComp,\n        OMX_IN  OMX_U32 nTunneledPort,\n        OMX_INOUT  OMX_TUNNELSETUPTYPE* pTunnelSetup); \n\n    /** refer to OMX_UseBuffer in OMX_core.h or the OMX IL \n        specification for details on the UseBuffer method.\n        @ingroup buf\n     */\n    OMX_ERRORTYPE (*UseBuffer)(\n            OMX_IN OMX_HANDLETYPE hComponent,\n            OMX_INOUT OMX_BUFFERHEADERTYPE** ppBufferHdr,\n            OMX_IN OMX_U32 nPortIndex,\n            OMX_IN OMX_PTR pAppPrivate,\n            OMX_IN OMX_U32 nSizeBytes,\n            OMX_IN OMX_U8* pBuffer);\n\n    /** refer to OMX_AllocateBuffer in OMX_core.h or the OMX IL \n        specification for details on the AllocateBuffer method.\n        @ingroup buf\n     */\n    OMX_ERRORTYPE (*AllocateBuffer)(\n            OMX_IN OMX_HANDLETYPE hComponent,\n            OMX_INOUT OMX_BUFFERHEADERTYPE** ppBuffer,\n            OMX_IN OMX_U32 nPortIndex,\n            OMX_IN OMX_PTR pAppPrivate,\n            OMX_IN OMX_U32 nSizeBytes);\n\n    /** refer to OMX_FreeBuffer in OMX_core.h or the OMX IL \n        specification for details on the FreeBuffer method.\n        @ingroup buf\n     */\n    OMX_ERRORTYPE (*FreeBuffer)(\n            OMX_IN  OMX_HANDLETYPE hComponent,\n            OMX_IN  OMX_U32 nPortIndex,\n            OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer);\n\n    /** refer to OMX_EmptyThisBuffer in OMX_core.h or the OMX IL \n        specification for details on the EmptyThisBuffer method.\n        @ingroup buf\n     */\n    OMX_ERRORTYPE (*EmptyThisBuffer)(\n            OMX_IN  OMX_HANDLETYPE hComponent,\n            OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer);\n\n    /** refer to OMX_FillThisBuffer in OMX_core.h or the OMX IL \n        specification for details on the FillThisBuffer method.\n        @ingroup buf\n     */\n    OMX_ERRORTYPE (*FillThisBuffer)(\n            OMX_IN  OMX_HANDLETYPE hComponent,\n            OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer);\n\n    /** The SetCallbacks method is used by the core to specify the callback\n        structure from the application to the component.  This is a blocking\n        call.  The component will return from this call within 5 msec.\n        @param [in] hComponent\n            Handle of the component to be accessed.  This is the component\n            handle returned by the call to the GetHandle function.\n        @param [in] pCallbacks\n            pointer to an OMX_CALLBACKTYPE structure used to provide the \n            callback information to the component\n        @param [in] pAppData\n            pointer to an application defined value.  It is anticipated that \n            the application will pass a pointer to a data structure or a \"this\n            pointer\" in this area to allow the callback (in the application)\n            to determine the context of the call\n        @return OMX_ERRORTYPE\n            If the command successfully executes, the return code will be\n            OMX_ErrorNone.  Otherwise the appropriate OMX error will be returned.\n     */\n    OMX_ERRORTYPE (*SetCallbacks)(\n            OMX_IN  OMX_HANDLETYPE hComponent,\n            OMX_IN  OMX_CALLBACKTYPE* pCallbacks, \n            OMX_IN  OMX_PTR pAppData);\n\n    /** ComponentDeInit method is used to deinitialize the component\n        providing a means to free any resources allocated at component\n        initialization.  NOTE:  After this call the component handle is\n        not valid for further use.\n        @param [in] hComponent\n            Handle of the component to be accessed.  This is the component\n            handle returned by the call to the GetHandle function.\n        @return OMX_ERRORTYPE\n            If the command successfully executes, the return code will be\n            OMX_ErrorNone.  Otherwise the appropriate OMX error will be returned.\n     */\n    OMX_ERRORTYPE (*ComponentDeInit)(\n            OMX_IN  OMX_HANDLETYPE hComponent);\n\n    /** @ingroup buf */\n    OMX_ERRORTYPE (*UseEGLImage)(\n            OMX_IN OMX_HANDLETYPE hComponent,\n            OMX_INOUT OMX_BUFFERHEADERTYPE** ppBufferHdr,\n            OMX_IN OMX_U32 nPortIndex,\n            OMX_IN OMX_PTR pAppPrivate,\n            OMX_IN void* eglImage);\n\n    OMX_ERRORTYPE (*ComponentRoleEnum)(\n        OMX_IN OMX_HANDLETYPE hComponent,\n\t\tOMX_OUT OMX_U8 *cRole,\n\t\tOMX_IN OMX_U32 nIndex);\n\n} OMX_COMPONENTTYPE;\n\n#ifdef __cplusplus\n}\n#endif /* __cplusplus */\n\n#endif\n/* File EOF */\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vmcs_host/khronos/IL/OMX_Core.h",
    "content": "/*\n * Copyright (c) 2008 The Khronos Group Inc. \n * \n * Permission is hereby granted, free of charge, to any person obtaining\n * a copy of this software and associated documentation files (the\n * \"Software\"), to deal in the Software without restriction, including\n * without limitation the rights to use, copy, modify, merge, publish,\n * distribute, sublicense, and/or sell copies of the Software, and to\n * permit persons to whom the Software is furnished to do so, subject\n * to the following conditions: \n * The above copyright notice and this permission notice shall be included\n * in all copies or substantial portions of the Software. \n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\n * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\n * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\n * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \n *\n */\n\n/** OMX_Core.h - OpenMax IL version 1.1.2\n *  The OMX_Core header file contains the definitions used by both the\n *  application and the component to access common items.\n */\n\n#ifndef OMX_Core_h\n#define OMX_Core_h\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif /* __cplusplus */\n\n#if !defined(OMX_SKIP64BIT) && !defined(_VIDEOCORE)\n  /* The Videocore compiler doesn't enforce 64 bit alignment on 64 bit variables,\n   * which is almost equivalent to OMX_SKIP64BIT.\n   * Annoyingly struct OMX_BUFFERHEADERTYPE doesn't do the sensible thing\n   * and add padding fields or similar to make it the same for all compilers,\n   * so all clients need to define this.\n   * Warn if this isn't set, as the GPU will not interpret your buffers correctly,\n   * or vice versa.\n   */\n  #warning OMX_SKIP64BIT is not defined - this will be incompatible with the VC GPU code.\n#endif\n\n/* Each OMX header shall include all required header files to allow the\n *  header to compile without errors.  The includes below are required\n *  for this header file to compile successfully \n */\n\n#include \"OMX_Index.h\"\n\n\n/** The OMX_COMMANDTYPE enumeration is used to specify the action in the\n *  OMX_SendCommand macro.  \n *  @ingroup core\n */\ntypedef enum OMX_COMMANDTYPE\n{\n    OMX_CommandStateSet,    /**< Change the component state */\n    OMX_CommandFlush,       /**< Flush the data queue(s) of a component */\n    OMX_CommandPortDisable, /**< Disable a port on a component. */\n    OMX_CommandPortEnable,  /**< Enable a port on a component. */\n    OMX_CommandMarkBuffer,  /**< Mark a component/buffer for observation */\n    OMX_CommandKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_CommandVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_CommandMax = 0X7FFFFFFF\n} OMX_COMMANDTYPE;\n\n\n\n/** The OMX_STATETYPE enumeration is used to indicate or change the component\n *  state.  This enumeration reflects the current state of the component when\n *  used with the OMX_GetState macro or becomes the parameter in a state change\n *  command when used with the OMX_SendCommand macro.\n *\n *  The component will be in the Loaded state after the component is initially\n *  loaded into memory.  In the Loaded state, the component is not allowed to\n *  allocate or hold resources other than to build it's internal parameter\n *  and configuration tables.  The application will send one or more\n *  SetParameters/GetParameters and SetConfig/GetConfig commands to the\n *  component and the component will record each of these parameter and\n *  configuration changes for use later.  When the application sends the\n *  Idle command, the component will acquire the resources needed for the\n *  specified configuration and will transition to the idle state if the\n *  allocation is successful.  If the component cannot successfully\n *  transition to the idle state for any reason, the state of the component\n *  shall be fully rolled back to the Loaded state (e.g. all allocated \n *  resources shall be released).  When the component receives the command\n *  to go to the Executing state, it shall begin processing buffers by\n *  sending all input buffers it holds to the application.  While\n *  the component is in the Idle state, the application may also send the\n *  Pause command.  If the component receives the pause command while in the\n *  Idle state, the component shall send all input buffers it holds to the \n *  application, but shall not begin processing buffers.  This will allow the\n *  application to prefill buffers.\n * \n *  @ingroup comp\n */\n\ntypedef enum OMX_STATETYPE\n{\n    OMX_StateInvalid,      /**< component has detected that it's internal data \n                                structures are corrupted to the point that\n                                it cannot determine it's state properly */\n    OMX_StateLoaded,      /**< component has been loaded but has not completed\n                                initialization.  The OMX_SetParameter macro\n                                and the OMX_GetParameter macro are the only \n                                valid macros allowed to be sent to the \n                                component in this state. */\n    OMX_StateIdle,        /**< component initialization has been completed\n                                successfully and the component is ready to\n                                to start. */\n    OMX_StateExecuting,   /**< component has accepted the start command and\n                                is processing data (if data is available) */\n    OMX_StatePause,       /**< component has received pause command */\n    OMX_StateWaitForResources, /**< component is waiting for resources, either after \n                                preemption or before it gets the resources requested.\n                                See specification for complete details. */\n    OMX_StateKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_StateVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_StateMax = 0X7FFFFFFF\n} OMX_STATETYPE;\n\n/** The OMX_ERRORTYPE enumeration defines the standard OMX Errors.  These \n *  errors should cover most of the common failure cases.  However, \n *  vendors are free to add additional error messages of their own as \n *  long as they follow these rules:\n *  1.  Vendor error messages shall be in the range of 0x90000000 to\n *      0x9000FFFF.\n *  2.  Vendor error messages shall be defined in a header file provided\n *      with the component.  No error messages are allowed that are\n *      not defined.\n */\ntypedef enum OMX_ERRORTYPE\n{\n  OMX_ErrorNone = 0,\n\n  /** There were insufficient resources to perform the requested operation */\n  OMX_ErrorInsufficientResources = (OMX_S32) 0x80001000,\n\n  /** There was an error, but the cause of the error could not be determined */\n  OMX_ErrorUndefined = (OMX_S32) 0x80001001,\n\n  /** The component name string was not valid */\n  OMX_ErrorInvalidComponentName = (OMX_S32) 0x80001002,\n\n  /** No component with the specified name string was found */\n  OMX_ErrorComponentNotFound = (OMX_S32) 0x80001003,\n\n  /** The component specified did not have a \"OMX_ComponentInit\" or\n      \"OMX_ComponentDeInit entry point */\n  OMX_ErrorInvalidComponent = (OMX_S32) 0x80001004,\n\n  /** One or more parameters were not valid */\n  OMX_ErrorBadParameter = (OMX_S32) 0x80001005,\n\n  /** The requested function is not implemented */\n  OMX_ErrorNotImplemented = (OMX_S32) 0x80001006,\n\n  /** The buffer was emptied before the next buffer was ready */\n  OMX_ErrorUnderflow = (OMX_S32) 0x80001007,\n\n  /** The buffer was not available when it was needed */\n  OMX_ErrorOverflow = (OMX_S32) 0x80001008,\n\n  /** The hardware failed to respond as expected */\n  OMX_ErrorHardware = (OMX_S32) 0x80001009,\n\n  /** The component is in the state OMX_StateInvalid */\n  OMX_ErrorInvalidState = (OMX_S32) 0x8000100A,\n\n  /** Stream is found to be corrupt */\n  OMX_ErrorStreamCorrupt = (OMX_S32) 0x8000100B,\n\n  /** Ports being connected are not compatible */\n  OMX_ErrorPortsNotCompatible = (OMX_S32) 0x8000100C,\n\n  /** Resources allocated to an idle component have been\n      lost resulting in the component returning to the loaded state */\n  OMX_ErrorResourcesLost = (OMX_S32) 0x8000100D,\n\n  /** No more indicies can be enumerated */\n  OMX_ErrorNoMore = (OMX_S32) 0x8000100E,\n\n  /** The component detected a version mismatch */\n  OMX_ErrorVersionMismatch = (OMX_S32) 0x8000100F,\n\n  /** The component is not ready to return data at this time */\n  OMX_ErrorNotReady = (OMX_S32) 0x80001010,\n\n  /** There was a timeout that occurred */\n  OMX_ErrorTimeout = (OMX_S32) 0x80001011,\n\n  /** This error occurs when trying to transition into the state you are already in */\n  OMX_ErrorSameState = (OMX_S32) 0x80001012,\n\n  /** Resources allocated to an executing or paused component have been \n      preempted, causing the component to return to the idle state */\n  OMX_ErrorResourcesPreempted = (OMX_S32) 0x80001013, \n\n  /** A non-supplier port sends this error to the IL client (via the EventHandler callback) \n      during the allocation of buffers (on a transition from the LOADED to the IDLE state or\n      on a port restart) when it deems that it has waited an unusually long time for the supplier \n      to send it an allocated buffer via a UseBuffer call. */\n  OMX_ErrorPortUnresponsiveDuringAllocation = (OMX_S32) 0x80001014,\n\n  /** A non-supplier port sends this error to the IL client (via the EventHandler callback) \n      during the deallocation of buffers (on a transition from the IDLE to LOADED state or \n      on a port stop) when it deems that it has waited an unusually long time for the supplier \n      to request the deallocation of a buffer header via a FreeBuffer call. */\n  OMX_ErrorPortUnresponsiveDuringDeallocation = (OMX_S32) 0x80001015,\n\n  /** A supplier port sends this error to the IL client (via the EventHandler callback) \n      during the stopping of a port (either on a transition from the IDLE to LOADED \n      state or a port stop) when it deems that it has waited an unusually long time for \n      the non-supplier to return a buffer via an EmptyThisBuffer or FillThisBuffer call. */\n  OMX_ErrorPortUnresponsiveDuringStop = (OMX_S32) 0x80001016,\n\n  /** Attempting a state transtion that is not allowed */\n  OMX_ErrorIncorrectStateTransition = (OMX_S32) 0x80001017,\n\n  /* Attempting a command that is not allowed during the present state. */\n  OMX_ErrorIncorrectStateOperation = (OMX_S32) 0x80001018, \n\n  /** The values encapsulated in the parameter or config structure are not supported. */\n  OMX_ErrorUnsupportedSetting = (OMX_S32) 0x80001019,\n\n  /** The parameter or config indicated by the given index is not supported. */\n  OMX_ErrorUnsupportedIndex = (OMX_S32) 0x8000101A,\n\n  /** The port index supplied is incorrect. */\n  OMX_ErrorBadPortIndex = (OMX_S32) 0x8000101B,\n\n  /** The port has lost one or more of its buffers and it thus unpopulated. */\n  OMX_ErrorPortUnpopulated = (OMX_S32) 0x8000101C,\n\n  /** Component suspended due to temporary loss of resources */\n  OMX_ErrorComponentSuspended = (OMX_S32) 0x8000101D,\n\n  /** Component suspended due to an inability to acquire dynamic resources */\n  OMX_ErrorDynamicResourcesUnavailable = (OMX_S32) 0x8000101E,\n\n  /** When the macroblock error reporting is enabled the component returns new error \n  for every frame that has errors */\n  OMX_ErrorMbErrorsInFrame = (OMX_S32) 0x8000101F,\n\n  /** A component reports this error when it cannot parse or determine the format of an input stream. */\n  OMX_ErrorFormatNotDetected = (OMX_S32) 0x80001020, \n\n  /** The content open operation failed. */\n  OMX_ErrorContentPipeOpenFailed = (OMX_S32) 0x80001021,\n\n  /** The content creation operation failed. */\n  OMX_ErrorContentPipeCreationFailed = (OMX_S32) 0x80001022,\n\n  /** Separate table information is being used */\n  OMX_ErrorSeperateTablesUsed = (OMX_S32) 0x80001023,\n\n  /** Tunneling is unsupported by the component*/\n  OMX_ErrorTunnelingUnsupported = (OMX_S32) 0x80001024,\n\n  OMX_ErrorKhronosExtensions = (OMX_S32)0x8F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n  OMX_ErrorVendorStartUnused = (OMX_S32)0x90000000, /**< Reserved region for introducing Vendor Extensions */\n\n  /** Disk Full error */\n  OMX_ErrorDiskFull = (OMX_S32) 0x90000001,\n \n  /** Max file size is reached */\n  OMX_ErrorMaxFileSize = (OMX_S32) 0x90000002,\n\n  /** Unauthorised to play a DRM protected file */\n  OMX_ErrorDrmUnauthorised = (OMX_S32) 0x90000003,\n\n  /** The DRM protected file has expired */\n  OMX_ErrorDrmExpired = (OMX_S32) 0x90000004,\n\n  /** Some other DRM library error */\n  OMX_ErrorDrmGeneral = (OMX_S32) 0x90000005,\n\n  OMX_ErrorMax = 0x7FFFFFFF\n} OMX_ERRORTYPE;\n\n/** @ingroup core */\ntypedef OMX_ERRORTYPE (* OMX_COMPONENTINITTYPE)(OMX_IN  OMX_HANDLETYPE hComponent);\n\n/** @ingroup core */\ntypedef struct OMX_COMPONENTREGISTERTYPE\n{\n  const char          * pName;       /* Component name, 128 byte limit (including '\\0') applies */\n  OMX_COMPONENTINITTYPE pInitialize; /* Component instance initialization function */\n} OMX_COMPONENTREGISTERTYPE;\n\n/** @ingroup core */\nextern OMX_COMPONENTREGISTERTYPE OMX_ComponentRegistered[];\n\n/** @ingroup rpm */\ntypedef struct OMX_PRIORITYMGMTTYPE {\n OMX_U32 nSize;             /**< size of the structure in bytes */\n OMX_VERSIONTYPE nVersion;  /**< OMX specification version information */\n OMX_U32 nGroupPriority;            /**< Priority of the component group */\n OMX_U32 nGroupID;                  /**< ID of the component group */\n} OMX_PRIORITYMGMTTYPE;\n\n/* Component name and Role names are limited to 128 characters including the terminating '\\0'. */\n#define OMX_MAX_STRINGNAME_SIZE 128\n\n/** @ingroup comp */\ntypedef struct OMX_PARAM_COMPONENTROLETYPE {\n    OMX_U32 nSize;              /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion;   /**< OMX specification version information */\n    OMX_U8 cRole[OMX_MAX_STRINGNAME_SIZE];  /**< name of standard component which defines component role */\n} OMX_PARAM_COMPONENTROLETYPE;\n\n/** End of Stream Buffer Flag: \n  *\n  * A component sets EOS when it has no more data to emit on a particular \n  * output port. Thus an output port shall set EOS on the last buffer it \n  * emits. A component's determination of when an output port should \n  * cease sending data is implemenation specific.\n  * @ingroup buf\n  */\n\n#define OMX_BUFFERFLAG_EOS 0x00000001 \n\n/** Start Time Buffer Flag: \n *\n * The source of a stream (e.g. a demux component) sets the STARTTIME\n * flag on the buffer that contains the starting timestamp for the\n * stream. The starting timestamp corresponds to the first data that\n * should be displayed at startup or after a seek.\n * The first timestamp of the stream is not necessarily the start time.\n * For instance, in the case of a seek to a particular video frame, \n * the target frame may be an interframe. Thus the first buffer of \n * the stream will be the intra-frame preceding the target frame and\n * the starttime will occur with the target frame (with any other\n * required frames required to reconstruct the target intervening).\n *\n * The STARTTIME flag is directly associated with the buffer's \n * timestamp ' thus its association to buffer data and its \n * propagation is identical to the timestamp's.\n *\n * When a Sync Component client receives a buffer with the \n * STARTTIME flag it shall perform a SetConfig on its sync port \n * using OMX_ConfigTimeClientStartTime and passing the buffer's\n * timestamp.\n * \n * @ingroup buf\n */\n\n#define OMX_BUFFERFLAG_STARTTIME 0x00000002\n\n \n\n/** Decode Only Buffer Flag: \n *\n * The source of a stream (e.g. a demux component) sets the DECODEONLY\n * flag on any buffer that should shall be decoded but should not be\n * displayed. This flag is used, for instance, when a source seeks to \n * a target interframe that requires the decode of frames preceding the \n * target to facilitate the target's reconstruction. In this case the \n * source would emit the frames preceding the target downstream \n * but mark them as decode only.\n *\n * The DECODEONLY is associated with buffer data and propagated in a \n * manner identical to the buffer timestamp.\n *\n * A component that renders data should ignore all buffers with \n * the DECODEONLY flag set.\n * \n * @ingroup buf\n */\n\n#define OMX_BUFFERFLAG_DECODEONLY 0x00000004\n\n\n/* Data Corrupt Flag: This flag is set when the IL client believes the data in the associated buffer is corrupt \n * @ingroup buf\n */\n\n#define OMX_BUFFERFLAG_DATACORRUPT 0x00000008\n\n/* End of Frame: The buffer contains exactly one end of frame and no data\n *  occurs after the end of frame. This flag is an optional hint. The absence\n *  of this flag does not imply the absence of an end of frame within the buffer. \n * @ingroup buf\n*/\n#define OMX_BUFFERFLAG_ENDOFFRAME 0x00000010\n\n/* Sync Frame Flag: This flag is set when the buffer content contains a coded sync frame ' \n *  a frame that has no dependency on any other frame information \n *  @ingroup buf\n */\n#define OMX_BUFFERFLAG_SYNCFRAME 0x00000020\n\n/* Extra data present flag: there is extra data appended to the data stream\n * residing in the buffer \n * @ingroup buf  \n */\n#define OMX_BUFFERFLAG_EXTRADATA 0x00000040\n\n/** Codec Config Buffer Flag: \n* OMX_BUFFERFLAG_CODECCONFIG is an optional flag that is set by an\n* output port when all bytes in the buffer form part or all of a set of\n* codec specific configuration data.  Examples include SPS/PPS nal units\n* for OMX_VIDEO_CodingAVC or AudioSpecificConfig data for\n* OMX_AUDIO_CodingAAC.  Any component that for a given stream sets \n* OMX_BUFFERFLAG_CODECCONFIG shall not mix codec configuration bytes\n* with frame data in the same buffer, and shall send all buffers\n* containing codec configuration bytes before any buffers containing\n* frame data that those configurations bytes describe.\n* If the stream format for a particular codec has a frame specific\n* header at the start of each frame, for example OMX_AUDIO_CodingMP3 or\n* OMX_AUDIO_CodingAAC in ADTS mode, then these shall be presented as\n* normal without setting OMX_BUFFERFLAG_CODECCONFIG.\n * @ingroup buf\n */\n#define OMX_BUFFERFLAG_CODECCONFIG 0x00000080\n\n\n\n/** @ingroup buf */\ntypedef struct OMX_BUFFERHEADERTYPE\n{\n    OMX_U32 nSize;              /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion;   /**< OMX specification version information */\n    OMX_U8* pBuffer;            /**< Pointer to actual block of memory \n                                     that is acting as the buffer */\n    OMX_U32 nAllocLen;          /**< size of the buffer allocated, in bytes */\n    OMX_U32 nFilledLen;         /**< number of bytes currently in the \n                                     buffer */\n    OMX_U32 nOffset;            /**< start offset of valid data in bytes from\n                                     the start of the buffer */\n    OMX_PTR pAppPrivate;        /**< pointer to any data the application\n                                     wants to associate with this buffer */\n    OMX_PTR pPlatformPrivate;   /**< pointer to any data the platform\n                                     wants to associate with this buffer */ \n    OMX_PTR pInputPortPrivate;  /**< pointer to any data the input port\n                                     wants to associate with this buffer */\n    OMX_PTR pOutputPortPrivate; /**< pointer to any data the output port\n                                     wants to associate with this buffer */\n    OMX_HANDLETYPE hMarkTargetComponent; /**< The component that will generate a \n                                              mark event upon processing this buffer. */\n    OMX_PTR pMarkData;          /**< Application specific data associated with \n                                     the mark sent on a mark event to disambiguate \n                                     this mark from others. */\n    OMX_U32 nTickCount;         /**< Optional entry that the component and\n                                     application can update with a tick count\n                                     when they access the component.  This\n                                     value should be in microseconds.  Since\n                                     this is a value relative to an arbitrary\n                                     starting point, this value cannot be used \n                                     to determine absolute time.  This is an\n                                     optional entry and not all components\n                                     will update it.*/\n OMX_TICKS nTimeStamp;          /**< Timestamp corresponding to the sample \n                                     starting at the first logical sample \n                                     boundary in the buffer. Timestamps of \n                                     successive samples within the buffer may\n                                     be inferred by adding the duration of the \n                                     of the preceding buffer to the timestamp\n                                     of the preceding buffer.*/\n  OMX_U32     nFlags;           /**< buffer specific flags */\n  OMX_U32 nOutputPortIndex;     /**< The index of the output port (if any) using \n                                     this buffer */\n  OMX_U32 nInputPortIndex;      /**< The index of the input port (if any) using\n                                     this buffer */\n} OMX_BUFFERHEADERTYPE;\n\n/** The OMX_EXTRADATATYPE enumeration is used to define the \n * possible extra data payload types.\n * NB: this enum is binary backwards compatible with the previous\n * OMX_EXTRADATA_QUANT define.  This should be replaced with\n * OMX_ExtraDataQuantization.\n */\ntypedef enum OMX_EXTRADATATYPE\n{\n   OMX_ExtraDataNone = 0,                       /**< Indicates that no more extra data sections follow */        \n   OMX_ExtraDataQuantization,                   /**< The data payload contains quantization data */\n   OMX_ExtraDataKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n   OMX_ExtraDataVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n\n   OMX_ExtraDataSequenceGap,                    /**< Indicates a gap in sequence numbers, data is uint32_t \n                                                     saying how many frames were lost */\n   OMX_ExtraDataDecodeOnlyUntil,                /**< Indicates a timestamp until which all data should be\n                                                     decoded only, and the first packets after should generate\n                                                     a client start time flag.  data is int32_t of seek time\n                                                     in milliseconds */\n\n   OMX_ExtraDataMax = 0x7FFFFFFF\n} OMX_EXTRADATATYPE;\n\n\ntypedef struct OMX_OTHER_EXTRADATATYPE  {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;               \n    OMX_U32 nPortIndex;\n    OMX_EXTRADATATYPE eType;       /* Extra Data type */\n    OMX_U32 nDataSize;   /* Size of the supporting data to follow */\n    OMX_U8  data[1];     /* Supporting data hint  */\n} OMX_OTHER_EXTRADATATYPE;\n\n/** @ingroup comp */\ntypedef struct OMX_PORT_PARAM_TYPE {\n    OMX_U32 nSize;              /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion;   /**< OMX specification version information */\n    OMX_U32 nPorts;             /**< The number of ports for this component */\n    OMX_U32 nStartPortNumber;   /** first port number for this type of port */\n} OMX_PORT_PARAM_TYPE; \n\n/** @ingroup comp */\ntypedef enum OMX_EVENTTYPE\n{\n    OMX_EventCmdComplete,         /**< component has sucessfully completed a command */\n    OMX_EventError,               /**< component has detected an error condition */\n    OMX_EventMark,                /**< component has detected a buffer mark */\n    OMX_EventPortSettingsChanged, /**< component is reported a port settings change */\n    OMX_EventBufferFlag,          /**< component has detected an EOS */ \n    OMX_EventResourcesAcquired,   /**< component has been granted resources and is\n                                       automatically starting the state change from\n                                       OMX_StateWaitForResources to OMX_StateIdle. */\n   OMX_EventComponentResumed,     /**< Component resumed due to reacquisition of resources */\n   OMX_EventDynamicResourcesAvailable, /**< Component has acquired previously unavailable dynamic resources */\n   OMX_EventPortFormatDetected,      /**< Component has detected a supported format. */\n   OMX_EventKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n   OMX_EventVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n   OMX_EventParamOrConfigChanged,   /* Should be added to the main spec as part of IL416c */\n   OMX_EventMax = 0x7FFFFFFF\n} OMX_EVENTTYPE;\n\ntypedef struct OMX_CALLBACKTYPE\n{\n    /** The EventHandler method is used to notify the application when an\n        event of interest occurs.  Events are defined in the OMX_EVENTTYPE\n        enumeration.  Please see that enumeration for details of what will\n        be returned for each type of event. Callbacks should not return\n        an error to the component, so if an error occurs, the application \n        shall handle it internally.  This is a blocking call.\n\n        The application should return from this call within 5 msec to avoid\n        blocking the component for an excessively long period of time.\n\n        @param hComponent\n            handle of the component to access.  This is the component\n            handle returned by the call to the GetHandle function.\n        @param pAppData\n            pointer to an application defined value that was provided in the \n            pAppData parameter to the OMX_GetHandle method for the component.\n            This application defined value is provided so that the application \n            can have a component specific context when receiving the callback.\n        @param eEvent\n            Event that the component wants to notify the application about.\n        @param nData1\n            nData will be the OMX_ERRORTYPE for an error event and will be \n            an OMX_COMMANDTYPE for a command complete event and OMX_INDEXTYPE for a OMX_PortSettingsChanged event.\n         @param nData2\n            nData2 will hold further information related to the event. Can be OMX_STATETYPE for\n            a OMX_CommandStateSet command or port index for a OMX_PortSettingsChanged event.\n            Default value is 0 if not used. )\n        @param pEventData\n            Pointer to additional event-specific data (see spec for meaning).\n      */\n\n   OMX_ERRORTYPE (*EventHandler)(\n        OMX_IN OMX_HANDLETYPE hComponent,\n        OMX_IN OMX_PTR pAppData,\n        OMX_IN OMX_EVENTTYPE eEvent,\n        OMX_IN OMX_U32 nData1,\n        OMX_IN OMX_U32 nData2,\n        OMX_IN OMX_PTR pEventData);\n\n    /** The EmptyBufferDone method is used to return emptied buffers from an\n        input port back to the application for reuse.  This is a blocking call \n        so the application should not attempt to refill the buffers during this\n        call, but should queue them and refill them in another thread.  There\n        is no error return, so the application shall handle any errors generated\n        internally.  \n        \n        The application should return from this call within 5 msec.\n        \n        @param hComponent\n            handle of the component to access.  This is the component\n            handle returned by the call to the GetHandle function.\n        @param pAppData\n            pointer to an application defined value that was provided in the \n            pAppData parameter to the OMX_GetHandle method for the component.\n            This application defined value is provided so that the application \n            can have a component specific context when receiving the callback.\n        @param pBuffer\n            pointer to an OMX_BUFFERHEADERTYPE structure allocated with UseBuffer\n            or AllocateBuffer indicating the buffer that was emptied.\n        @ingroup buf\n     */\n    OMX_ERRORTYPE (*EmptyBufferDone)(\n        OMX_IN OMX_HANDLETYPE hComponent,\n        OMX_IN OMX_PTR pAppData,\n        OMX_IN OMX_BUFFERHEADERTYPE* pBuffer);\n\n    /** The FillBufferDone method is used to return filled buffers from an\n        output port back to the application for emptying and then reuse.  \n        This is a blocking call so the application should not attempt to \n        empty the buffers during this call, but should queue the buffers \n        and empty them in another thread.  There is no error return, so \n        the application shall handle any errors generated internally.  The \n        application shall also update the buffer header to indicate the\n        number of bytes placed into the buffer.  \n\n        The application should return from this call within 5 msec.\n        \n        @param hComponent\n            handle of the component to access.  This is the component\n            handle returned by the call to the GetHandle function.\n        @param pAppData\n            pointer to an application defined value that was provided in the \n            pAppData parameter to the OMX_GetHandle method for the component.\n            This application defined value is provided so that the application \n            can have a component specific context when receiving the callback.\n        @param pBuffer\n            pointer to an OMX_BUFFERHEADERTYPE structure allocated with UseBuffer\n            or AllocateBuffer indicating the buffer that was filled.\n        @ingroup buf\n     */\n    OMX_ERRORTYPE (*FillBufferDone)(\n        OMX_OUT OMX_HANDLETYPE hComponent,\n        OMX_OUT OMX_PTR pAppData,\n        OMX_OUT OMX_BUFFERHEADERTYPE* pBuffer);\n\n} OMX_CALLBACKTYPE;\n\n/** The OMX_BUFFERSUPPLIERTYPE enumeration is used to dictate port supplier\n    preference when tunneling between two ports.\n    @ingroup tun buf\n*/\ntypedef enum OMX_BUFFERSUPPLIERTYPE\n{\n    OMX_BufferSupplyUnspecified = 0x0, /**< port supplying the buffers is unspecified,\n                                              or don't care */\n    OMX_BufferSupplyInput,             /**< input port supplies the buffers */\n    OMX_BufferSupplyOutput,            /**< output port supplies the buffers */\n    OMX_BufferSupplyKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_BufferSupplyVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_BufferSupplyMax = 0x7FFFFFFF\n} OMX_BUFFERSUPPLIERTYPE;\n\n\n/** buffer supplier parameter \n * @ingroup tun\n */\ntypedef struct OMX_PARAM_BUFFERSUPPLIERTYPE {\n    OMX_U32 nSize; /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion; /**< OMX specification version information */\n    OMX_U32 nPortIndex; /**< port that this structure applies to */\n    OMX_BUFFERSUPPLIERTYPE eBufferSupplier; /**< buffer supplier */\n} OMX_PARAM_BUFFERSUPPLIERTYPE;\n\n\n/**< indicates that buffers received by an input port of a tunnel \n     may not modify the data in the buffers \n     @ingroup tun\n */\n#define OMX_PORTTUNNELFLAG_READONLY 0x00000001 \n\n\n/** The OMX_TUNNELSETUPTYPE structure is used to pass data from an output\n    port to an input port as part the two ComponentTunnelRequest calls\n    resulting from a OMX_SetupTunnel call from the IL Client. \n    @ingroup tun\n */   \ntypedef struct OMX_TUNNELSETUPTYPE\n{\n    OMX_U32 nTunnelFlags;             /**< bit flags for tunneling */\n    OMX_BUFFERSUPPLIERTYPE eSupplier; /**< supplier preference */\n} OMX_TUNNELSETUPTYPE; \n\n/* OMX Component headers is included to enable the core to use\n   macros for functions into the component for OMX release 1.0.  \n   Developers should not access any structures or data from within\n   the component header directly */\n/* TO BE REMOVED - #include <OMX_Component.h> */\n\n/** GetComponentVersion will return information about the component.  \n    This is a blocking call.  This macro will go directly from the\n    application to the component (via a core macro).  The\n    component will return from this call within 5 msec.\n    @param [in] hComponent\n        handle of component to execute the command\n    @param [out] pComponentName\n        pointer to an empty string of length 128 bytes.  The component \n        will write its name into this string.  The name will be \n        terminated by a single zero byte.  The name of a component will \n        be 127 bytes or less to leave room for the trailing zero byte.  \n        An example of a valid component name is \"OMX.ABC.ChannelMixer\\0\".\n    @param [out] pComponentVersion\n        pointer to an OMX Version structure that the component will fill \n        in.  The component will fill in a value that indicates the \n        component version.  NOTE: the component version is NOT the same \n        as the OMX Specification version (found in all structures).  The \n        component version is defined by the vendor of the component and \n        its value is entirely up to the component vendor.\n    @param [out] pSpecVersion\n        pointer to an OMX Version structure that the component will fill \n        in.  The SpecVersion is the version of the specification that the \n        component was built against.  Please note that this value may or \n        may not match the structure's version.  For example, if the \n        component was built against the 2.0 specification, but the \n        application (which creates the structure is built against the \n        1.0 specification the versions would be different.\n    @param [out] pComponentUUID\n        pointer to the UUID of the component which will be filled in by \n        the component.  The UUID is a unique identifier that is set at \n        RUN time for the component and is unique to each instantion of \n        the component.\n    @return OMX_ERRORTYPE\n        If the command successfully executes, the return code will be\n        OMX_ErrorNone.  Otherwise the appropriate OMX error will be returned.\n    @ingroup comp\n */\n#define OMX_GetComponentVersion(                            \\\n        hComponent,                                         \\\n        pComponentName,                                     \\\n        pComponentVersion,                                  \\\n        pSpecVersion,                                       \\\n        pComponentUUID)                                     \\\n    ((OMX_COMPONENTTYPE*)hComponent)->GetComponentVersion(  \\\n        hComponent,                                         \\\n        pComponentName,                                     \\\n        pComponentVersion,                                  \\\n        pSpecVersion,                                       \\\n        pComponentUUID)                 /* Macro End */\n\n\n/** Send a command to the component.  This call is a non-blocking call.\n    The component should check the parameters and then queue the command\n    to the component thread to be executed.  The component thread shall \n    send the EventHandler() callback at the conclusion of the command. \n    This macro will go directly from the application to the component (via\n    a core macro).  The component will return from this call within 5 msec.\n    \n    When the command is \"OMX_CommandStateSet\" the component will queue a\n    state transition to the new state idenfied in nParam.\n    \n    When the command is \"OMX_CommandFlush\", to flush a port's buffer queues,\n    the command will force the component to return all buffers NOT CURRENTLY \n    BEING PROCESSED to the application, in the order in which the buffers \n    were received.\n    \n    When the command is \"OMX_CommandPortDisable\" or \n    \"OMX_CommandPortEnable\", the component's port (given by the value of\n    nParam) will be stopped or restarted. \n    \n    When the command \"OMX_CommandMarkBuffer\" is used to mark a buffer, the\n    pCmdData will point to a OMX_MARKTYPE structure containing the component\n    handle of the component to examine the buffer chain for the mark.  nParam1\n    contains the index of the port on which the buffer mark is applied.\n\n    Specification text for more details. \n    \n    @param [in] hComponent\n        handle of component to execute the command\n    @param [in] Cmd\n        Command for the component to execute\n    @param [in] nParam\n        Parameter for the command to be executed.  When Cmd has the value \n        OMX_CommandStateSet, value is a member of OMX_STATETYPE.  When Cmd has \n        the value OMX_CommandFlush, value of nParam indicates which port(s) \n        to flush. -1 is used to flush all ports a single port index will \n        only flush that port.  When Cmd has the value \"OMX_CommandPortDisable\"\n        or \"OMX_CommandPortEnable\", the component's port is given by \n        the value of nParam.  When Cmd has the value \"OMX_CommandMarkBuffer\"\n        the components pot is given by the value of nParam.\n    @param [in] pCmdData\n        Parameter pointing to the OMX_MARKTYPE structure when Cmd has the value\n        \"OMX_CommandMarkBuffer\".     \n    @return OMX_ERRORTYPE\n        If the command successfully executes, the return code will be\n        OMX_ErrorNone.  Otherwise the appropriate OMX error will be returned.\n    @ingroup comp\n */\n#define OMX_SendCommand(                                    \\\n         hComponent,                                        \\\n         Cmd,                                               \\\n         nParam,                                            \\\n         pCmdData)                                          \\\n     ((OMX_COMPONENTTYPE*)hComponent)->SendCommand(         \\\n         hComponent,                                        \\\n         Cmd,                                               \\\n         nParam,                                            \\\n         pCmdData)                          /* Macro End */\n\n\n/** The OMX_GetParameter macro will get one of the current parameter \n    settings from the component.  This macro cannot only be invoked when \n    the component is in the OMX_StateInvalid state.  The nParamIndex\n    parameter is used to indicate which structure is being requested from\n    the component.  The application shall allocate the correct structure \n    and shall fill in the structure size and version information before \n    invoking this macro.  When the parameter applies to a port, the\n    caller shall fill in the appropriate nPortIndex value indicating the\n    port on which the parameter applies. If the component has not had \n    any settings changed, then the component should return a set of \n    valid DEFAULT  parameters for the component.  This is a blocking \n    call.  \n    \n    The component should return from this call within 20 msec.\n    \n    @param [in] hComponent\n        Handle of the component to be accessed.  This is the component\n        handle returned by the call to the OMX_GetHandle function.\n    @param [in] nParamIndex\n        Index of the structure to be filled.  This value is from the\n        OMX_INDEXTYPE enumeration.\n    @param [in,out] pComponentParameterStructure\n        Pointer to application allocated structure to be filled by the \n        component.\n    @return OMX_ERRORTYPE\n        If the command successfully executes, the return code will be\n        OMX_ErrorNone.  Otherwise the appropriate OMX error will be returned.\n    @ingroup comp\n */\n#define OMX_GetParameter(                                   \\\n        hComponent,                                         \\\n        nParamIndex,                                        \\\n        pComponentParameterStructure)                        \\\n    ((OMX_COMPONENTTYPE*)hComponent)->GetParameter(         \\\n        hComponent,                                         \\\n        nParamIndex,                                        \\\n        pComponentParameterStructure)    /* Macro End */\n\n\n/** The OMX_SetParameter macro will send an initialization parameter\n    structure to a component.  Each structure shall be sent one at a time,\n    in a separate invocation of the macro.  This macro can only be\n    invoked when the component is in the OMX_StateLoaded state, or the\n    port is disabled (when the parameter applies to a port). The \n    nParamIndex parameter is used to indicate which structure is being\n    passed to the component.  The application shall allocate the \n    correct structure and shall fill in the structure size and version \n    information (as well as the actual data) before invoking this macro.\n    The application is free to dispose of this structure after the call\n    as the component is required to copy any data it shall retain.  This \n    is a blocking call.  \n    \n    The component should return from this call within 20 msec.\n    \n    @param [in] hComponent\n        Handle of the component to be accessed.  This is the component\n        handle returned by the call to the OMX_GetHandle function.\n    @param [in] nIndex\n        Index of the structure to be sent.  This value is from the\n        OMX_INDEXTYPE enumeration.\n    @param [in] pComponentParameterStructure\n        pointer to application allocated structure to be used for\n        initialization by the component.\n    @return OMX_ERRORTYPE\n        If the command successfully executes, the return code will be\n        OMX_ErrorNone.  Otherwise the appropriate OMX error will be returned.\n    @ingroup comp\n */\n#define OMX_SetParameter(                                   \\\n        hComponent,                                         \\\n        nParamIndex,                                        \\\n        pComponentParameterStructure)                        \\\n    ((OMX_COMPONENTTYPE*)hComponent)->SetParameter(         \\\n        hComponent,                                         \\\n        nParamIndex,                                        \\\n        pComponentParameterStructure)    /* Macro End */\n\n\n/** The OMX_GetConfig macro will get one of the configuration structures \n    from a component.  This macro can be invoked anytime after the \n    component has been loaded.  The nParamIndex call parameter is used to \n    indicate which structure is being requested from the component.  The \n    application shall allocate the correct structure and shall fill in the \n    structure size and version information before invoking this macro.  \n    If the component has not had this configuration parameter sent before, \n    then the component should return a set of valid DEFAULT values for the \n    component.  This is a blocking call.  \n    \n    The component should return from this call within 5 msec.\n    \n    @param [in] hComponent\n        Handle of the component to be accessed.  This is the component\n        handle returned by the call to the OMX_GetHandle function.\n    @param [in] nIndex\n        Index of the structure to be filled.  This value is from the\n        OMX_INDEXTYPE enumeration.\n    @param [in,out] pComponentConfigStructure\n        pointer to application allocated structure to be filled by the \n        component.\n    @return OMX_ERRORTYPE\n        If the command successfully executes, the return code will be\n        OMX_ErrorNone.  Otherwise the appropriate OMX error will be returned.\n    @ingroup comp\n*/        \n#define OMX_GetConfig(                                      \\\n        hComponent,                                         \\\n        nConfigIndex,                                       \\\n        pComponentConfigStructure)                           \\\n    ((OMX_COMPONENTTYPE*)hComponent)->GetConfig(            \\\n        hComponent,                                         \\\n        nConfigIndex,                                       \\\n        pComponentConfigStructure)       /* Macro End */\n\n\n/** The OMX_SetConfig macro will send one of the configuration \n    structures to a component.  Each structure shall be sent one at a time,\n    each in a separate invocation of the macro.  This macro can be invoked \n    anytime after the component has been loaded.  The application shall \n    allocate the correct structure and shall fill in the structure size \n    and version information (as well as the actual data) before invoking \n    this macro.  The application is free to dispose of this structure after \n    the call as the component is required to copy any data it shall retain.  \n    This is a blocking call.  \n    \n    The component should return from this call within 5 msec.\n    \n    @param [in] hComponent\n        Handle of the component to be accessed.  This is the component\n        handle returned by the call to the OMX_GetHandle function.\n    @param [in] nConfigIndex\n        Index of the structure to be sent.  This value is from the\n        OMX_INDEXTYPE enumeration above.\n    @param [in] pComponentConfigStructure\n        pointer to application allocated structure to be used for\n        initialization by the component.\n    @return OMX_ERRORTYPE\n        If the command successfully executes, the return code will be\n        OMX_ErrorNone.  Otherwise the appropriate OMX error will be returned.\n    @ingroup comp\n */\n#define OMX_SetConfig(                                      \\\n        hComponent,                                         \\\n        nConfigIndex,                                       \\\n        pComponentConfigStructure)                           \\\n    ((OMX_COMPONENTTYPE*)hComponent)->SetConfig(            \\\n        hComponent,                                         \\\n        nConfigIndex,                                       \\\n        pComponentConfigStructure)       /* Macro End */\n\n\n/** The OMX_GetExtensionIndex macro will invoke a component to translate \n    a vendor specific configuration or parameter string into an OMX \n    structure index.  There is no requirement for the vendor to support \n    this command for the indexes already found in the OMX_INDEXTYPE \n    enumeration (this is done to save space in small components).  The \n    component shall support all vendor supplied extension indexes not found\n    in the master OMX_INDEXTYPE enumeration.  This is a blocking call.  \n    \n    The component should return from this call within 5 msec.\n    \n    @param [in] hComponent\n        Handle of the component to be accessed.  This is the component\n        handle returned by the call to the GetHandle function.\n    @param [in] cParameterName\n        OMX_STRING that shall be less than 128 characters long including\n        the trailing null byte.  This is the string that will get \n        translated by the component into a configuration index.\n    @param [out] pIndexType\n        a pointer to a OMX_INDEXTYPE to receive the index value.\n    @return OMX_ERRORTYPE\n        If the command successfully executes, the return code will be\n        OMX_ErrorNone.  Otherwise the appropriate OMX error will be returned.\n    @ingroup comp\n */\n#define OMX_GetExtensionIndex(                              \\\n        hComponent,                                         \\\n        cParameterName,                                     \\\n        pIndexType)                                         \\\n    ((OMX_COMPONENTTYPE*)hComponent)->GetExtensionIndex(    \\\n        hComponent,                                         \\\n        cParameterName,                                     \\\n        pIndexType)                     /* Macro End */\n\n\n/** The OMX_GetState macro will invoke the component to get the current \n    state of the component and place the state value into the location\n    pointed to by pState.  \n    \n    The component should return from this call within 5 msec.\n    \n    @param [in] hComponent\n        Handle of the component to be accessed.  This is the component\n        handle returned by the call to the OMX_GetHandle function.\n    @param [out] pState\n        pointer to the location to receive the state.  The value returned\n        is one of the OMX_STATETYPE members \n    @return OMX_ERRORTYPE\n        If the command successfully executes, the return code will be\n        OMX_ErrorNone.  Otherwise the appropriate OMX error will be returned.\n    @ingroup comp\n */\n#define OMX_GetState(                                       \\\n        hComponent,                                         \\\n        pState)                                             \\\n    ((OMX_COMPONENTTYPE*)hComponent)->GetState(             \\\n        hComponent,                                         \\\n        pState)                         /* Macro End */\n\n\n/** The OMX_UseBuffer macro will request that the component use\n    a buffer (and allocate its own buffer header) already allocated \n    by another component, or by the IL Client. This is a blocking \n    call.\n    \n    The component should return from this call within 20 msec.\n    \n    @param [in] hComponent\n        Handle of the component to be accessed.  This is the component\n        handle returned by the call to the OMX_GetHandle function.\n    @param [out] ppBuffer\n        pointer to an OMX_BUFFERHEADERTYPE structure used to receive the \n        pointer to the buffer header\n    @return OMX_ERRORTYPE\n        If the command successfully executes, the return code will be\n        OMX_ErrorNone.  Otherwise the appropriate OMX error will be returned.\n    @ingroup comp buf\n */\n\n#define OMX_UseBuffer(                                      \\\n           hComponent,                                      \\\n           ppBufferHdr,                                     \\\n           nPortIndex,                                      \\\n           pAppPrivate,                                     \\\n           nSizeBytes,                                      \\\n           pBuffer)                                         \\\n    ((OMX_COMPONENTTYPE*)hComponent)->UseBuffer(            \\\n           hComponent,                                      \\\n           ppBufferHdr,                                     \\\n           nPortIndex,                                      \\\n           pAppPrivate,                                     \\\n           nSizeBytes,                                      \\\n           pBuffer)\n\n\n/** The OMX_AllocateBuffer macro will request that the component allocate \n    a new buffer and buffer header.  The component will allocate the \n    buffer and the buffer header and return a pointer to the buffer \n    header.  This is a blocking call.\n    \n    The component should return from this call within 5 msec.\n    \n    @param [in] hComponent\n        Handle of the component to be accessed.  This is the component\n        handle returned by the call to the OMX_GetHandle function.\n    @param [out] ppBuffer\n        pointer to an OMX_BUFFERHEADERTYPE structure used to receive \n        the pointer to the buffer header\n    @param [in] nPortIndex\n        nPortIndex is used to select the port on the component the buffer will\n        be used with.  The port can be found by using the nPortIndex\n        value as an index into the Port Definition array of the component.\n    @param [in] pAppPrivate\n        pAppPrivate is used to initialize the pAppPrivate member of the \n        buffer header structure.\n    @param [in] nSizeBytes\n        size of the buffer to allocate.  Used when bAllocateNew is true.\n    @return OMX_ERRORTYPE\n        If the command successfully executes, the return code will be\n        OMX_ErrorNone.  Otherwise the appropriate OMX error will be returned.\n    @ingroup comp buf\n */    \n#define OMX_AllocateBuffer(                                 \\\n        hComponent,                                         \\\n        ppBuffer,                                           \\\n        nPortIndex,                                         \\\n        pAppPrivate,                                        \\\n        nSizeBytes)                                         \\\n    ((OMX_COMPONENTTYPE*)hComponent)->AllocateBuffer(       \\\n        hComponent,                                         \\\n        ppBuffer,                                           \\\n        nPortIndex,                                         \\\n        pAppPrivate,                                        \\\n        nSizeBytes)                     /* Macro End */\n\n\n/** The OMX_FreeBuffer macro will release a buffer header from the component\n    which was allocated using either OMX_AllocateBuffer or OMX_UseBuffer. If  \n    the component allocated the buffer (see the OMX_UseBuffer macro) then \n    the component shall free the buffer and buffer header. This is a \n    blocking call. \n    \n    The component should return from this call within 20 msec.\n    \n    @param [in] hComponent\n        Handle of the component to be accessed.  This is the component\n        handle returned by the call to the OMX_GetHandle function.\n    @param [in] nPortIndex\n        nPortIndex is used to select the port on the component the buffer will\n        be used with.\n    @param [in] pBuffer\n        pointer to an OMX_BUFFERHEADERTYPE structure allocated with UseBuffer\n        or AllocateBuffer.\n    @return OMX_ERRORTYPE\n        If the command successfully executes, the return code will be\n        OMX_ErrorNone.  Otherwise the appropriate OMX error will be returned.\n    @ingroup comp buf\n */\n#define OMX_FreeBuffer(                                     \\\n        hComponent,                                         \\\n        nPortIndex,                                         \\\n        pBuffer)                                            \\\n    ((OMX_COMPONENTTYPE*)hComponent)->FreeBuffer(           \\\n        hComponent,                                         \\\n        nPortIndex,                                         \\\n        pBuffer)                        /* Macro End */\n\n\n/** The OMX_EmptyThisBuffer macro will send a buffer full of data to an \n    input port of a component.  The buffer will be emptied by the component\n    and returned to the application via the EmptyBufferDone call back.\n    This is a non-blocking call in that the component will record the buffer\n    and return immediately and then empty the buffer, later, at the proper \n    time.  As expected, this macro may be invoked only while the component \n    is in the OMX_StateExecuting.  If nPortIndex does not specify an input\n    port, the component shall return an error.  \n    \n    The component should return from this call within 5 msec.\n    \n    @param [in] hComponent\n        Handle of the component to be accessed.  This is the component\n        handle returned by the call to the OMX_GetHandle function.\n    @param [in] pBuffer\n        pointer to an OMX_BUFFERHEADERTYPE structure allocated with UseBuffer\n        or AllocateBuffer.\n    @return OMX_ERRORTYPE\n        If the command successfully executes, the return code will be\n        OMX_ErrorNone.  Otherwise the appropriate OMX error will be returned.\n    @ingroup comp buf\n */\n#define OMX_EmptyThisBuffer(                                \\\n        hComponent,                                         \\\n        pBuffer)                                            \\\n    ((OMX_COMPONENTTYPE*)hComponent)->EmptyThisBuffer(      \\\n        hComponent,                                         \\\n        pBuffer)                        /* Macro End */\n\n\n/** The OMX_FillThisBuffer macro will send an empty buffer to an \n    output port of a component.  The buffer will be filled by the component\n    and returned to the application via the FillBufferDone call back.\n    This is a non-blocking call in that the component will record the buffer\n    and return immediately and then fill the buffer, later, at the proper \n    time.  As expected, this macro may be invoked only while the component \n    is in the OMX_ExecutingState.  If nPortIndex does not specify an output\n    port, the component shall return an error.  \n    \n    The component should return from this call within 5 msec.\n    \n    @param [in] hComponent\n        Handle of the component to be accessed.  This is the component\n        handle returned by the call to the OMX_GetHandle function.\n    @param [in] pBuffer\n        pointer to an OMX_BUFFERHEADERTYPE structure allocated with UseBuffer\n        or AllocateBuffer.\n    @return OMX_ERRORTYPE\n        If the command successfully executes, the return code will be\n        OMX_ErrorNone.  Otherwise the appropriate OMX error will be returned.\n    @ingroup comp buf\n */\n#define OMX_FillThisBuffer(                                 \\\n        hComponent,                                         \\\n        pBuffer)                                            \\\n    ((OMX_COMPONENTTYPE*)hComponent)->FillThisBuffer(       \\\n        hComponent,                                         \\\n        pBuffer)                        /* Macro End */\n\n\n\n/** The OMX_UseEGLImage macro will request that the component use\n    a EGLImage provided by EGL (and allocate its own buffer header)\n    This is a blocking call.\n    \n    The component should return from this call within 20 msec.\n    \n    @param [in] hComponent\n        Handle of the component to be accessed.  This is the component\n        handle returned by the call to the OMX_GetHandle function.\n    @param [out] ppBuffer\n        pointer to an OMX_BUFFERHEADERTYPE structure used to receive the \n        pointer to the buffer header.  Note that the memory location used\n        for this buffer is NOT visible to the IL Client.\n    @param [in] nPortIndex\n        nPortIndex is used to select the port on the component the buffer will\n        be used with.  The port can be found by using the nPortIndex\n        value as an index into the Port Definition array of the component.\n    @param [in] pAppPrivate\n        pAppPrivate is used to initialize the pAppPrivate member of the \n        buffer header structure.\n    @param [in] eglImage\n        eglImage contains the handle of the EGLImage to use as a buffer on the\n        specified port.  The component is expected to validate properties of \n        the EGLImage against the configuration of the port to ensure the component\n        can use the EGLImage as a buffer.          \n    @return OMX_ERRORTYPE\n        If the command successfully executes, the return code will be\n        OMX_ErrorNone.  Otherwise the appropriate OMX error will be returned.\n    @ingroup comp buf\n */\n#define OMX_UseEGLImage(                                    \\\n           hComponent,                                      \\\n           ppBufferHdr,                                     \\\n           nPortIndex,                                      \\\n           pAppPrivate,                                     \\\n           eglImage)                                        \\\n    ((OMX_COMPONENTTYPE*)hComponent)->UseEGLImage(          \\\n           hComponent,                                      \\\n           ppBufferHdr,                                     \\\n           nPortIndex,                                      \\\n           pAppPrivate,                                     \\\n           eglImage)\n\n/** The OMX_Init method is used to initialize the OMX core.  It shall be the\n    first call made into OMX and it should only be executed one time without\n    an interviening OMX_Deinit call.  \n    \n    The core should return from this call within 20 msec.\n\n    @return OMX_ERRORTYPE\n        If the command successfully executes, the return code will be\n        OMX_ErrorNone.  Otherwise the appropriate OMX error will be returned.\n    @ingroup core\n */\nOMX_API OMX_ERRORTYPE OMX_APIENTRY OMX_Init(void);\n\n\n/** The OMX_Deinit method is used to deinitialize the OMX core.  It shall be \n    the last call made into OMX. In the event that the core determines that \n    thare are components loaded when this call is made, the core may return \n    with an error rather than try to unload the components.\n        \n    The core should return from this call within 20 msec.\n    \n    @return OMX_ERRORTYPE\n        If the command successfully executes, the return code will be\n        OMX_ErrorNone.  Otherwise the appropriate OMX error will be returned.\n    @ingroup core\n */\nOMX_API OMX_ERRORTYPE OMX_APIENTRY OMX_Deinit(void);\n\n\n/** The OMX_ComponentNameEnum method will enumerate through all the names of\n    recognised valid components in the system. This function is provided\n    as a means to detect all the components in the system run-time. There is\n    no strict ordering to the enumeration order of component names, although\n    each name will only be enumerated once.  If the OMX core supports run-time\n    installation of new components, it is only requried to detect newly\n    installed components when the first call to enumerate component names\n    is made (i.e. when nIndex is 0x0).\n    \n    The core should return from this call in 20 msec.\n    \n    @param [out] cComponentName\n        pointer to a null terminated string with the component name.  The\n        names of the components are strings less than 127 bytes in length\n        plus the trailing null for a maximum size of 128 bytes.  An example \n        of a valid component name is \"OMX.TI.AUDIO.DSP.MIXER\\0\".  Names are \n        assigned by the vendor, but shall start with \"OMX.\" and then have \n        the Vendor designation next.\n    @param [in] nNameLength\n        number of characters in the cComponentName string.  With all \n        component name strings restricted to less than 128 characters \n        (including the trailing null) it is recomended that the caller\n        provide a input string for the cComponentName of 128 characters.\n    @param [in] nIndex\n        number containing the enumeration index for the component. \n        Multiple calls to OMX_ComponentNameEnum with increasing values\n        of nIndex will enumerate through the component names in the\n        system until OMX_ErrorNoMore is returned.  The value of nIndex\n        is 0 to (N-1), where N is the number of valid installed components\n        in the system.\n    @return OMX_ERRORTYPE\n        If the command successfully executes, the return code will be\n        OMX_ErrorNone.  When the value of nIndex exceeds the number of \n        components in the system minus 1, OMX_ErrorNoMore will be\n        returned. Otherwise the appropriate OMX error will be returned.\n    @ingroup core\n */\nOMX_API OMX_ERRORTYPE OMX_APIENTRY OMX_ComponentNameEnum(\n    OMX_OUT OMX_STRING cComponentName,\n    OMX_IN  OMX_U32 nNameLength,\n    OMX_IN  OMX_U32 nIndex);\n\n\n/** The OMX_GetHandle method will locate the component specified by the\n    component name given, load that component into memory and then invoke\n    the component's methods to create an instance of the component.  \n    \n    The core should return from this call within 20 msec.\n    \n    @param [out] pHandle\n        pointer to an OMX_HANDLETYPE pointer to be filled in by this method.\n    @param [in] cComponentName\n        pointer to a null terminated string with the component name.  The\n        names of the components are strings less than 127 bytes in length\n        plus the trailing null for a maximum size of 128 bytes.  An example \n        of a valid component name is \"OMX.TI.AUDIO.DSP.MIXER\\0\".  Names are \n        assigned by the vendor, but shall start with \"OMX.\" and then have \n        the Vendor designation next.\n    @param [in] pAppData\n        pointer to an application defined value that will be returned\n        during callbacks so that the application can identify the source\n        of the callback.\n    @param [in] pCallBacks\n        pointer to a OMX_CALLBACKTYPE structure that will be passed to the\n        component to initialize it with.  \n    @return OMX_ERRORTYPE\n        If the command successfully executes, the return code will be\n        OMX_ErrorNone.  Otherwise the appropriate OMX error will be returned.\n    @ingroup core\n */\nOMX_API OMX_ERRORTYPE OMX_APIENTRY OMX_GetHandle(\n    OMX_OUT OMX_HANDLETYPE* pHandle, \n    OMX_IN  OMX_STRING cComponentName,\n    OMX_IN  OMX_PTR pAppData,\n    OMX_IN  OMX_CALLBACKTYPE* pCallBacks);\n\n\n/** The OMX_FreeHandle method will free a handle allocated by the OMX_GetHandle \n    method.  If the component reference count goes to zero, the component will\n    be unloaded from memory.  \n    \n    The core should return from this call within 20 msec when the component is \n    in the OMX_StateLoaded state.\n\n    @param [in] hComponent\n        Handle of the component to be accessed.  This is the component\n        handle returned by the call to the GetHandle function.\n    @return OMX_ERRORTYPE\n        If the command successfully executes, the return code will be\n        OMX_ErrorNone.  Otherwise the appropriate OMX error will be returned.\n    @ingroup core\n */\nOMX_API OMX_ERRORTYPE OMX_APIENTRY OMX_FreeHandle(\n    OMX_IN  OMX_HANDLETYPE hComponent);\n\n\n\n/** The OMX_SetupTunnel method will handle the necessary calls to the components\n    to setup the specified tunnel the two components.  NOTE: This is\n    an actual method (not a #define macro).  This method will make calls into\n    the component ComponentTunnelRequest method to do the actual tunnel \n    connection.  \n\n    The ComponentTunnelRequest method on both components will be called. \n    This method shall not be called unless the component is in the \n    OMX_StateLoaded state except when the ports used for the tunnel are\n    disabled. In this case, the component may be in the OMX_StateExecuting,\n    OMX_StatePause, or OMX_StateIdle states. \n\n    The core should return from this call within 20 msec.\n    \n    @param [in] hOutput\n        Handle of the component to be accessed.  Also this is the handle\n        of the component whose port, specified in the nPortOutput parameter\n        will be used the source for the tunnel. This is the component handle\n        returned by the call to the OMX_GetHandle function.  There is a \n        requirement that hOutput be the source for the data when\n        tunelling (i.e. nPortOutput is an output port).  If 0x0, the component\n        specified in hInput will have it's port specified in nPortInput\n        setup for communication with the application / IL client.\n    @param [in] nPortOutput\n        nPortOutput is used to select the source port on component to be\n        used in the tunnel. \n    @param [in] hInput\n        This is the component to setup the tunnel with. This is the handle\n        of the component whose port, specified in the nPortInput parameter\n        will be used the destination for the tunnel. This is the component handle\n        returned by the call to the OMX_GetHandle function.  There is a \n        requirement that hInput be the destination for the data when\n        tunelling (i.e. nPortInut is an input port).   If 0x0, the component\n        specified in hOutput will have it's port specified in nPortPOutput\n        setup for communication with the application / IL client.\n    @param [in] nPortInput\n        nPortInput is used to select the destination port on component to be\n        used in the tunnel.\n    @return OMX_ERRORTYPE\n        If the command successfully executes, the return code will be\n        OMX_ErrorNone.  Otherwise the appropriate OMX error will be returned.\n        When OMX_ErrorNotImplemented is returned, one or both components is \n        a non-interop component and does not support tunneling.\n        \n        On failure, the ports of both components are setup for communication\n        with the application / IL Client.\n    @ingroup core tun\n */\nOMX_API OMX_ERRORTYPE OMX_APIENTRY OMX_SetupTunnel(\n    OMX_IN  OMX_HANDLETYPE hOutput,\n    OMX_IN  OMX_U32 nPortOutput,\n    OMX_IN  OMX_HANDLETYPE hInput,\n    OMX_IN  OMX_U32 nPortInput);\n    \n/** @ingroup cp */\nOMX_API OMX_ERRORTYPE   OMX_GetContentPipe(\n    OMX_OUT OMX_HANDLETYPE *hPipe,\n    OMX_IN OMX_STRING szURI);\n\n/** The OMX_GetComponentsOfRole method will return the number of components that support the given\n    role and (if the compNames field is non-NULL) the names of those components. The call will fail if \n    an insufficiently sized array of names is supplied. To ensure the array is sufficiently sized the\n    client should:\n        * first call this function with the compNames field NULL to determine the number of component names\n        * second call this function with the compNames field pointing to an array of names allocated \n          according to the number returned by the first call.\n\n    The core should return from this call within 5 msec.\n    \n    @param [in] role\n        This is generic standard component name consisting only of component class \n        name and the type within that class (e.g. 'audio_decoder.aac').\n    @param [inout] pNumComps\n        This is used both as input and output. \n \n        If compNames is NULL, the input is ignored and the output specifies how many components support\n        the given role.\n     \n        If compNames is not NULL, on input it bounds the size of the input structure and \n        on output, it specifies the number of components string names listed within the compNames parameter.\n    @param [inout] compNames\n        If NULL this field is ignored. If non-NULL this points to an array of 128-byte strings which accepts \n        a list of the names of all physical components that implement the specified standard component name. \n        Each name is NULL terminated. numComps indicates the number of names.\n    @ingroup core\n */\nOMX_API OMX_ERRORTYPE OMX_GetComponentsOfRole ( \n\tOMX_IN      OMX_STRING role,\n    OMX_INOUT   OMX_U32 *pNumComps,\n    OMX_INOUT   OMX_U8  **compNames);\n\n/** The OMX_GetRolesOfComponent method will return the number of roles supported by the given\n    component and (if the roles field is non-NULL) the names of those roles. The call will fail if \n    an insufficiently sized array of names is supplied. To ensure the array is sufficiently sized the\n    client should:\n        * first call this function with the roles field NULL to determine the number of role names\n        * second call this function with the roles field pointing to an array of names allocated \n          according to the number returned by the first call.\n\n    The core should return from this call within 5 msec.\n\n    @param [in] compName\n        This is the name of the component being queried about.\n    @param [inout] pNumRoles\n        This is used both as input and output. \n \n        If roles is NULL, the input is ignored and the output specifies how many roles the component supports.\n     \n        If compNames is not NULL, on input it bounds the size of the input structure and \n        on output, it specifies the number of roles string names listed within the roles parameter.\n    @param [out] roles\n        If NULL this field is ignored. If non-NULL this points to an array of 128-byte strings \n        which accepts a list of the names of all standard components roles implemented on the \n        specified component name. numComps indicates the number of names.\n    @ingroup core\n */\nOMX_API OMX_ERRORTYPE OMX_GetRolesOfComponent ( \n\tOMX_IN      OMX_STRING compName, \n    OMX_INOUT   OMX_U32 *pNumRoles,\n    OMX_OUT     OMX_U8 **roles);\n\n#ifdef __cplusplus\n}\n#endif /* __cplusplus */\n\n#endif\n/* File EOF */\n\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vmcs_host/khronos/IL/OMX_ILCS.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n// OpenMAX IL - ILCS specific types\n\n#ifndef OMX_ILCS_h\n#define OMX_ILCS_h\n\ntypedef struct OMX_PARAM_PORTSUMMARYTYPE {\n   OMX_U32 nSize;            /**< Size of the structure in bytes */\n   OMX_VERSIONTYPE nVersion; /**< OMX specification version information */\n   OMX_U32 nNumPorts;        /**< Total number of ports */\n   OMX_U32 reqSet;           /**< Which set of ports is details below, portIndex[0] is port reqSet*32 */\n   OMX_U32 portDir;          /**< Bitfield, 1 if output port, 0 if input port, max 256 ports */\n   OMX_U32 portIndex[32];    /**< Port Indexes */\n} OMX_PARAM_PORTSUMMARYTYPE;\n\ntypedef struct OMX_PARAM_MARKCOMPARISONTYPE {\n   OMX_U32 nSize;            /**< Size of the structure in bytes */\n   OMX_VERSIONTYPE nVersion; /**< OMX specification version information */\n   OMX_PTR mark;             /**< Pointer to be used for mark comparisons */\n} OMX_PARAM_MARKCOMPARISONTYPE;\n\ntypedef struct OMX_PARAM_BRCMRECURSIONUNSAFETYPE {\n   OMX_U32 nSize;\n   OMX_VERSIONTYPE nVersion;\n   OMX_S32 (*pRecursionUnsafe)(OMX_PTR param);\n   OMX_PTR param;\n} OMX_PARAM_BRCMRECURSIONUNSAFETYPE;\n\ntypedef struct OMX_PARAM_TUNNELSTATUSTYPE {\n   OMX_U32 nSize;            /**< Size of the structure in bytes */\n   OMX_VERSIONTYPE nVersion; /**< OMX specification version information */\n   OMX_U32 nPortIndex;       /**< Port being queried */\n   OMX_U32 nIndex;           /**< Query the nIndex'th port and fill in nPortIndex */\n   OMX_BOOL bUseIndex;       /**< If OMX_TRUE read nIndex, otherwise read nPortIndex */\n   OMX_PTR hTunneledComponent; /**< Component currently tunnelling with */\n   OMX_U32 nTunneledPort;    /**< Port on tunnelled component */\n} OMX_PARAM_TUNNELSTATUSTYPE;\n\n#endif\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vmcs_host/khronos/IL/OMX_IVCommon.h",
    "content": "/**\n * Copyright (c) 2008 The Khronos Group Inc. \n * \n * Permission is hereby granted, free of charge, to any person obtaining\n * a copy of this software and associated documentation files (the\n * \"Software\"), to deal in the Software without restriction, including\n * without limitation the rights to use, copy, modify, merge, publish,\n * distribute, sublicense, and/or sell copies of the Software, and to\n * permit persons to whom the Software is furnished to do so, subject\n * to the following conditions: \n * The above copyright notice and this permission notice shall be included\n * in all copies or substantial portions of the Software. \n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\n * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\n * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\n * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \n *\n */\n\n/** \n * @file OMX_IVCommon.h - OpenMax IL version 1.1.2\n *  The structures needed by Video and Image components to exchange\n *  parameters and configuration data with the components.\n */\n#ifndef OMX_IVCommon_h\n#define OMX_IVCommon_h\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif /* __cplusplus */\n\n/**\n * Each OMX header must include all required header files to allow the header\n * to compile without errors.  The includes below are required for this header\n * file to compile successfully \n */\n\n#include \"OMX_Core.h\"\n\n/** @defgroup iv OpenMAX IL Imaging and Video Domain\n * Common structures for OpenMAX IL Imaging and Video domains\n * @{\n */\n\n\n/** \n * Enumeration defining possible uncompressed image/video formats. \n *\n * ENUMS:\n *  Unused                 : Placeholder value when format is N/A\n *  Monochrome             : black and white\n *  8bitRGB332             : Red 7:5, Green 4:2, Blue 1:0\n *  12bitRGB444            : Red 11:8, Green 7:4, Blue 3:0\n *  16bitARGB4444          : Alpha 15:12, Red 11:8, Green 7:4, Blue 3:0\n *  16bitARGB1555          : Alpha 15, Red 14:10, Green 9:5, Blue 4:0\n *  16bitRGB565            : Red 15:11, Green 10:5, Blue 4:0\n *  16bitBGR565            : Blue 15:11, Green 10:5, Red 4:0\n *  18bitRGB666            : Red 17:12, Green 11:6, Blue 5:0\n *  18bitARGB1665          : Alpha 17, Red 16:11, Green 10:5, Blue 4:0\n *  19bitARGB1666          : Alpha 18, Red 17:12, Green 11:6, Blue 5:0\n *  24bitRGB888            : Red 24:16, Green 15:8, Blue 7:0\n *  24bitBGR888            : Blue 24:16, Green 15:8, Red 7:0\n *  24bitARGB1887          : Alpha 23, Red 22:15, Green 14:7, Blue 6:0\n *  25bitARGB1888          : Alpha 24, Red 23:16, Green 15:8, Blue 7:0\n *  32bitBGRA8888          : Blue 31:24, Green 23:16, Red 15:8, Alpha 7:0\n *  32bitARGB8888          : Alpha 31:24, Red 23:16, Green 15:8, Blue 7:0\n *  YUV411Planar           : U,Y are subsampled by a factor of 4 horizontally\n *  YUV411PackedPlanar     : packed per payload in planar slices\n *  YUV420Planar           : Three arrays Y,U,V.\n *  YUV420PackedPlanar     : packed per payload in planar slices\n *  YUV420SemiPlanar       : Two arrays, one is all Y, the other is U and V\n *  YUV422Planar           : Three arrays Y,U,V.\n *  YUV422PackedPlanar     : packed per payload in planar slices\n *  YUV422SemiPlanar       : Two arrays, one is all Y, the other is U and V\n *  YCbYCr                 : Organized as 16bit YUYV (i.e. YCbYCr)\n *  YCrYCb                 : Organized as 16bit YVYU (i.e. YCrYCb)\n *  CbYCrY                 : Organized as 16bit UYVY (i.e. CbYCrY)\n *  CrYCbY                 : Organized as 16bit VYUY (i.e. CrYCbY)\n *  YUV444Interleaved      : Each pixel contains equal parts YUV\n *  RawBayer8bit           : SMIA camera output format\n *  RawBayer10bit          : SMIA camera output format\n *  RawBayer8bitcompressed : SMIA camera output format\n Vendor extensions\n *  32bitABGR888           : Alpha 31:24, Blue 23:16, Green 15:8, Red 7:0\n */\ntypedef enum OMX_COLOR_FORMATTYPE {\n    OMX_COLOR_FormatUnused,\n    OMX_COLOR_FormatMonochrome,\n    OMX_COLOR_Format8bitRGB332,\n    OMX_COLOR_Format12bitRGB444,\n    OMX_COLOR_Format16bitARGB4444,\n    OMX_COLOR_Format16bitARGB1555,\n    OMX_COLOR_Format16bitRGB565,\n    OMX_COLOR_Format16bitBGR565,\n    OMX_COLOR_Format18bitRGB666,\n    OMX_COLOR_Format18bitARGB1665,\n    OMX_COLOR_Format19bitARGB1666, \n    OMX_COLOR_Format24bitRGB888,\n    OMX_COLOR_Format24bitBGR888,\n    OMX_COLOR_Format24bitARGB1887,\n    OMX_COLOR_Format25bitARGB1888,\n    OMX_COLOR_Format32bitBGRA8888,\n    OMX_COLOR_Format32bitARGB8888,\n    OMX_COLOR_FormatYUV411Planar,\n    OMX_COLOR_FormatYUV411PackedPlanar,\n    OMX_COLOR_FormatYUV420Planar,\n    OMX_COLOR_FormatYUV420PackedPlanar,\n    OMX_COLOR_FormatYUV420SemiPlanar,\n    OMX_COLOR_FormatYUV422Planar,\n    OMX_COLOR_FormatYUV422PackedPlanar,\n    OMX_COLOR_FormatYUV422SemiPlanar,\n    OMX_COLOR_FormatYCbYCr,\n    OMX_COLOR_FormatYCrYCb,\n    OMX_COLOR_FormatCbYCrY,\n    OMX_COLOR_FormatCrYCbY,\n    OMX_COLOR_FormatYUV444Interleaved,\n    OMX_COLOR_FormatRawBayer8bit,\n    OMX_COLOR_FormatRawBayer10bit,\n    OMX_COLOR_FormatRawBayer8bitcompressed,\n    OMX_COLOR_FormatL2, \n    OMX_COLOR_FormatL4, \n    OMX_COLOR_FormatL8, \n    OMX_COLOR_FormatL16, \n    OMX_COLOR_FormatL24, \n    OMX_COLOR_FormatL32,\n    OMX_COLOR_FormatYUV420PackedSemiPlanar,\n    OMX_COLOR_FormatYUV422PackedSemiPlanar,\n    OMX_COLOR_Format18BitBGR666,\n    OMX_COLOR_Format24BitARGB6666,\n    OMX_COLOR_Format24BitABGR6666,\n    OMX_COLOR_FormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_COLOR_FormatVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_COLOR_Format32bitABGR8888,\n    OMX_COLOR_Format8bitPalette,\n    OMX_COLOR_FormatYUVUV128,\n    OMX_COLOR_FormatRawBayer12bit,\n    OMX_COLOR_FormatBRCMEGL,\n    OMX_COLOR_FormatBRCMOpaque,\n    OMX_COLOR_FormatYVU420PackedPlanar,\n    OMX_COLOR_FormatYVU420PackedSemiPlanar,\n    OMX_COLOR_FormatRawBayer16bit,\n    OMX_COLOR_FormatMax = 0x7FFFFFFF\n} OMX_COLOR_FORMATTYPE;\n\n\n/** \n * Defines the matrix for conversion from RGB to YUV or vice versa.\n * iColorMatrix should be initialized with the fixed point values \n * used in converting between formats.\n */\ntypedef struct OMX_CONFIG_COLORCONVERSIONTYPE {\n    OMX_U32 nSize;              /**< Size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion;   /**< OMX specification version info */ \n    OMX_U32 nPortIndex;         /**< Port that this struct applies to */\n    OMX_S32 xColorMatrix[3][3]; /**< Stored in signed Q16 format */\n    OMX_S32 xColorOffset[4];    /**< Stored in signed Q16 format */\n}OMX_CONFIG_COLORCONVERSIONTYPE;\n\n\n/** \n * Structure defining percent to scale each frame dimension.  For example:  \n * To make the width 50% larger, use fWidth = 1.5 and to make the width\n * 1/2 the original size, use fWidth = 0.5\n */\ntypedef struct OMX_CONFIG_SCALEFACTORTYPE {\n    OMX_U32 nSize;            /**< Size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion; /**< OMX specification version info */ \n    OMX_U32 nPortIndex;       /**< Port that this struct applies to */\n    OMX_S32 xWidth;           /**< Fixed point value stored as Q16 */\n    OMX_S32 xHeight;          /**< Fixed point value stored as Q16 */\n}OMX_CONFIG_SCALEFACTORTYPE;\n\n\n/** \n * Enumeration of possible image filter types \n */\ntypedef enum OMX_IMAGEFILTERTYPE {\n    OMX_ImageFilterNone,\n    OMX_ImageFilterNoise,\n    OMX_ImageFilterEmboss,\n    OMX_ImageFilterNegative,\n    OMX_ImageFilterSketch,\n    OMX_ImageFilterOilPaint,\n    OMX_ImageFilterHatch,\n    OMX_ImageFilterGpen,\n    OMX_ImageFilterAntialias, \n    OMX_ImageFilterDeRing,       \n    OMX_ImageFilterSolarize,\n    OMX_ImageFilterKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_ImageFilterVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n      \n    /* Broadcom specific image filters */\n    OMX_ImageFilterWatercolor,\n    OMX_ImageFilterPastel,\n    OMX_ImageFilterSharpen,\n    OMX_ImageFilterFilm,\n    OMX_ImageFilterBlur,\n    OMX_ImageFilterSaturation,\n\n    OMX_ImageFilterDeInterlaceLineDouble,\n    OMX_ImageFilterDeInterlaceAdvanced,\n    \n    OMX_ImageFilterColourSwap,\n    OMX_ImageFilterWashedOut,\n    OMX_ImageFilterColourPoint,\n    OMX_ImageFilterPosterise,\n    OMX_ImageFilterColourBalance,\n    OMX_ImageFilterCartoon,\n\n    OMX_ImageFilterAnaglyph,\n    OMX_ImageFilterDeInterlaceFast,\n    OMX_ImageFilterMax = 0x7FFFFFFF\n} OMX_IMAGEFILTERTYPE;\n\ntypedef enum OMX_IMAGEFILTERANAGLYPHTYPE {\n    OMX_ImageFilterAnaglyphNone,\n    OMX_ImageFilterAnaglyphSBStoRedCyan,\n    OMX_ImageFilterAnaglyphSBStoCyanRed,\n    OMX_ImageFilterAnaglyphSBStoGreenMagenta,\n    OMX_ImageFilterAnaglyphSBStoMagentaGreen,\n    OMX_ImageFilterAnaglyphTABtoRedCyan,\n    OMX_ImageFilterAnaglyphTABtoCyanRed,\n    OMX_ImageFilterAnaglyphTABtoGreenMagenta,\n    OMX_ImageFilterAnaglyphTABtoMagentaGreen,\n} OMX_IMAGEFILTERANAGLYPHTYPE;\n\n/** \n * Image filter configuration \n *\n * STRUCT MEMBERS:\n *  nSize        : Size of the structure in bytes       \n *  nVersion     : OMX specification version information\n *  nPortIndex   : Port that this structure applies to \n *  eImageFilter : Image filter type enumeration      \n */\ntypedef struct OMX_CONFIG_IMAGEFILTERTYPE {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n    OMX_IMAGEFILTERTYPE eImageFilter;\n} OMX_CONFIG_IMAGEFILTERTYPE;\n\n\n/** \n * Customized U and V for color enhancement \n *\n * STRUCT MEMBERS:\n *  nSize             : Size of the structure in bytes\n *  nVersion          : OMX specification version information \n *  nPortIndex        : Port that this structure applies to\n *  bColorEnhancement : Enable/disable color enhancement\n *  nCustomizedU      : Practical values: 16-240, range: 0-255, value set for \n *                      U component\n *  nCustomizedV      : Practical values: 16-240, range: 0-255, value set for \n *                      V component\n */\ntypedef struct OMX_CONFIG_COLORENHANCEMENTTYPE {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion; \n    OMX_U32 nPortIndex;\n    OMX_BOOL bColorEnhancement;\n    OMX_U8 nCustomizedU;\n    OMX_U8 nCustomizedV;\n} OMX_CONFIG_COLORENHANCEMENTTYPE;\n\n\n/** \n * Define color key and color key mask \n *\n * STRUCT MEMBERS:\n *  nSize      : Size of the structure in bytes\n *  nVersion   : OMX specification version information \n *  nPortIndex : Port that this structure applies to\n *  nARGBColor : 32bit Alpha, Red, Green, Blue Color\n *  nARGBMask  : 32bit Mask for Alpha, Red, Green, Blue channels\n */\ntypedef struct OMX_CONFIG_COLORKEYTYPE {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n    OMX_U32 nARGBColor;\n    OMX_U32 nARGBMask;\n} OMX_CONFIG_COLORKEYTYPE;\n\n\n/** \n * List of color blend types for pre/post processing \n *\n * ENUMS:\n *  None          : No color blending present\n *  AlphaConstant : Function is (alpha_constant * src) + \n *                  (1 - alpha_constant) * dst)\n *  AlphaPerPixel : Function is (alpha * src) + (1 - alpha) * dst)\n *  Alternate     : Function is alternating pixels from src and dst\n *  And           : Function is (src & dst)\n *  Or            : Function is (src | dst)\n *  Invert        : Function is ~src\n */\ntypedef enum OMX_COLORBLENDTYPE {\n    OMX_ColorBlendNone,\n    OMX_ColorBlendAlphaConstant,\n    OMX_ColorBlendAlphaPerPixel,\n    OMX_ColorBlendAlternate,\n    OMX_ColorBlendAnd,\n    OMX_ColorBlendOr,\n    OMX_ColorBlendInvert,\n    OMX_ColorBlendKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_ColorBlendVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_ColorBlendMax = 0x7FFFFFFF\n} OMX_COLORBLENDTYPE;\n\n\n/** \n * Color blend configuration \n *\n * STRUCT MEMBERS:\n *  nSize             : Size of the structure in bytes                        \n *  nVersion          : OMX specification version information                \n *  nPortIndex        : Port that this structure applies to                   \n *  nRGBAlphaConstant : Constant global alpha values when global alpha is used\n *  eColorBlend       : Color blend type enumeration                         \n */\ntypedef struct OMX_CONFIG_COLORBLENDTYPE {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n    OMX_U32 nRGBAlphaConstant;\n    OMX_COLORBLENDTYPE  eColorBlend;\n} OMX_CONFIG_COLORBLENDTYPE;\n\n\n/** \n * Hold frame dimension\n *\n * STRUCT MEMBERS:\n *  nSize      : Size of the structure in bytes      \n *  nVersion   : OMX specification version information\n *  nPortIndex : Port that this structure applies to     \n *  nWidth     : Frame width in pixels                 \n *  nHeight    : Frame height in pixels                \n */\ntypedef struct OMX_FRAMESIZETYPE {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n    OMX_U32 nWidth;\n    OMX_U32 nHeight;\n} OMX_FRAMESIZETYPE;\n\n\n/**\n * Rotation configuration \n *\n * STRUCT MEMBERS:\n *  nSize      : Size of the structure in bytes             \n *  nVersion   : OMX specification version information\n *  nPortIndex : Port that this structure applies to\n *  nRotation  : +/- integer rotation value               \n */\ntypedef struct OMX_CONFIG_ROTATIONTYPE {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n    OMX_S32 nRotation; \n} OMX_CONFIG_ROTATIONTYPE;\n\n\n/** \n * Possible mirroring directions for pre/post processing \n *\n * ENUMS:\n *  None       : No mirroring                         \n *  Vertical   : Vertical mirroring, flip on X axis   \n *  Horizontal : Horizontal mirroring, flip on Y axis  \n *  Both       : Both vertical and horizontal mirroring\n */\ntypedef enum OMX_MIRRORTYPE {\n    OMX_MirrorNone = 0,\n    OMX_MirrorVertical,\n    OMX_MirrorHorizontal,\n    OMX_MirrorBoth, \n    OMX_MirrorKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_MirrorVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_MirrorMax = 0x7FFFFFFF   \n} OMX_MIRRORTYPE;\n\n\n/** \n * Mirroring configuration \n *\n * STRUCT MEMBERS:\n *  nSize      : Size of the structure in bytes      \n *  nVersion   : OMX specification version information\n *  nPortIndex : Port that this structure applies to  \n *  eMirror    : Mirror type enumeration              \n */\ntypedef struct OMX_CONFIG_MIRRORTYPE {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion; \n    OMX_U32 nPortIndex;\n    OMX_MIRRORTYPE  eMirror;\n} OMX_CONFIG_MIRRORTYPE;\n\n\n/** \n * Position information only \n *\n * STRUCT MEMBERS:\n *  nSize      : Size of the structure in bytes               \n *  nVersion   : OMX specification version information\n *  nPortIndex : Port that this structure applies to\n *  nX         : X coordinate for the point                     \n *  nY         : Y coordinate for the point \n */                      \ntypedef struct OMX_CONFIG_POINTTYPE {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n    OMX_S32 nX;\n    OMX_S32 nY;\n} OMX_CONFIG_POINTTYPE;\n\n\n/** \n * Frame size plus position \n *\n * STRUCT MEMBERS:\n *  nSize      : Size of the structure in bytes                    \n *  nVersion   : OMX specification version information      \n *  nPortIndex : Port that this structure applies to    \n *  nLeft      : X Coordinate of the top left corner of the rectangle\n *  nTop       : Y Coordinate of the top left corner of the rectangle\n *  nWidth     : Width of the rectangle                              \n *  nHeight    : Height of the rectangle                             \n */\ntypedef struct OMX_CONFIG_RECTTYPE {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;  \n    OMX_U32 nPortIndex; \n    OMX_S32 nLeft; \n    OMX_S32 nTop;\n    OMX_U32 nWidth;\n    OMX_U32 nHeight;\n} OMX_CONFIG_RECTTYPE;\n\n\n/** \n * Deblocking state; it is required to be set up before starting the codec \n *\n * STRUCT MEMBERS:\n *  nSize       : Size of the structure in bytes      \n *  nVersion    : OMX specification version information \n *  nPortIndex  : Port that this structure applies to\n *  bDeblocking : Enable/disable deblocking mode    \n */\ntypedef struct OMX_PARAM_DEBLOCKINGTYPE {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n    OMX_BOOL bDeblocking;\n} OMX_PARAM_DEBLOCKINGTYPE;\n\n\n/** \n * Stabilization state \n *\n * STRUCT MEMBERS:\n *  nSize      : Size of the structure in bytes          \n *  nVersion   : OMX specification version information    \n *  nPortIndex : Port that this structure applies to   \n *  bStab      : Enable/disable frame stabilization state\n */\ntypedef struct OMX_CONFIG_FRAMESTABTYPE {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n    OMX_BOOL bStab;\n} OMX_CONFIG_FRAMESTABTYPE;\n\n\n/** \n * White Balance control type \n *\n * STRUCT MEMBERS:\n *  SunLight : Referenced in JSR-234\n *  Flash    : Optimal for device's integrated flash\n */\ntypedef enum OMX_WHITEBALCONTROLTYPE {\n    OMX_WhiteBalControlOff = 0,\n    OMX_WhiteBalControlAuto,\n    OMX_WhiteBalControlSunLight,\n    OMX_WhiteBalControlCloudy,\n    OMX_WhiteBalControlShade,\n    OMX_WhiteBalControlTungsten,\n    OMX_WhiteBalControlFluorescent,\n    OMX_WhiteBalControlIncandescent,\n    OMX_WhiteBalControlFlash,\n    OMX_WhiteBalControlHorizon,\n    OMX_WhiteBalControlKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_WhiteBalControlVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_WhiteBalControlMax = 0x7FFFFFFF\n} OMX_WHITEBALCONTROLTYPE;\n\n\n/** \n * White Balance control configuration \n *\n * STRUCT MEMBERS:\n *  nSize            : Size of the structure in bytes       \n *  nVersion         : OMX specification version information\n *  nPortIndex       : Port that this structure applies to                 \n *  eWhiteBalControl : White balance enumeration            \n */\ntypedef struct OMX_CONFIG_WHITEBALCONTROLTYPE {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n    OMX_WHITEBALCONTROLTYPE eWhiteBalControl;\n} OMX_CONFIG_WHITEBALCONTROLTYPE;\n\n\n/** \n * Exposure control type \n */\ntypedef enum OMX_EXPOSURECONTROLTYPE {\n    OMX_ExposureControlOff = 0,\n    OMX_ExposureControlAuto,\n    OMX_ExposureControlNight,\n    OMX_ExposureControlBackLight,\n    OMX_ExposureControlSpotLight,\n    OMX_ExposureControlSports,\n    OMX_ExposureControlSnow,\n    OMX_ExposureControlBeach,\n    OMX_ExposureControlLargeAperture,\n    OMX_ExposureControlSmallAperture,\n    OMX_ExposureControlKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_ExposureControlVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_ExposureControlVeryLong,\n    OMX_ExposureControlFixedFps,\n    OMX_ExposureControlNightWithPreview,\n    OMX_ExposureControlAntishake,\n    OMX_ExposureControlFireworks,\n    OMX_ExposureControlMax = 0x7FFFFFFF\n} OMX_EXPOSURECONTROLTYPE;\n\n\n/** \n * White Balance control configuration \n *\n * STRUCT MEMBERS:\n *  nSize            : Size of the structure in bytes      \n *  nVersion         : OMX specification version information\n *  nPortIndex       : Port that this structure applies to                \n *  eExposureControl : Exposure control enumeration         \n */\ntypedef struct OMX_CONFIG_EXPOSURECONTROLTYPE {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n    OMX_EXPOSURECONTROLTYPE eExposureControl;\n} OMX_CONFIG_EXPOSURECONTROLTYPE;\n\n\n/** \n * Defines sensor supported mode. \n *\n * STRUCT MEMBERS:\n *  nSize      : Size of the structure in bytes           \n *  nVersion   : OMX specification version information\n *  nPortIndex : Port that this structure applies to \n *  nFrameRate : Single shot mode is indicated by a 0     \n *  bOneShot   : Enable for single shot, disable for streaming\n *  sFrameSize : Framesize                                          \n */\ntypedef struct OMX_PARAM_SENSORMODETYPE {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n    OMX_U32 nFrameRate;\n    OMX_BOOL bOneShot;\n    OMX_FRAMESIZETYPE sFrameSize;\n} OMX_PARAM_SENSORMODETYPE;\n\n\n/** \n * Defines contrast level \n *\n * STRUCT MEMBERS:\n *  nSize      : Size of the structure in bytes                              \n *  nVersion   : OMX specification version information                \n *  nPortIndex : Port that this structure applies to                 \n *  nContrast  : Values allowed for contrast -100 to 100, zero means no change\n */\ntypedef struct OMX_CONFIG_CONTRASTTYPE {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n    OMX_S32 nContrast;\n} OMX_CONFIG_CONTRASTTYPE;\n\n\n/** \n * Defines brightness level \n *\n * STRUCT MEMBERS:\n *  nSize       : Size of the structure in bytes          \n *  nVersion    : OMX specification version information \n *  nPortIndex  : Port that this structure applies to \n *  nBrightness : 0-100%        \n */\ntypedef struct OMX_CONFIG_BRIGHTNESSTYPE {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n    OMX_U32 nBrightness;\n} OMX_CONFIG_BRIGHTNESSTYPE;\n\n\n/** \n * Defines backlight level configuration for a video sink, e.g. LCD panel \n *\n * STRUCT MEMBERS:\n *  nSize      : Size of the structure in bytes\n *  nVersion   : OMX specification version information \n *  nPortIndex : Port that this structure applies to\n *  nBacklight : Values allowed for backlight 0-100%\n *  nTimeout   : Number of milliseconds before backlight automatically turns \n *               off.  A value of 0x0 disables backight timeout \n */\ntypedef struct OMX_CONFIG_BACKLIGHTTYPE {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n    OMX_U32 nBacklight;\n    OMX_U32 nTimeout;\n} OMX_CONFIG_BACKLIGHTTYPE;\n\n\n/** \n * Defines setting for Gamma \n *\n * STRUCT MEMBERS:\n *  nSize      : Size of the structure in bytes\n *  nVersion   : OMX specification version information \n *  nPortIndex : Port that this structure applies to\n *  nGamma     : Values allowed for gamma -100 to 100, zero means no change\n */\ntypedef struct OMX_CONFIG_GAMMATYPE {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n    OMX_S32 nGamma;\n} OMX_CONFIG_GAMMATYPE;\n\n\n/** \n * Define for setting saturation \n * \n * STRUCT MEMBERS:\n *  nSize       : Size of the structure in bytes\n *  nVersion    : OMX specification version information\n *  nPortIndex  : Port that this structure applies to\n *  nSaturation : Values allowed for saturation -100 to 100, zero means \n *                no change\n */\ntypedef struct OMX_CONFIG_SATURATIONTYPE {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n    OMX_S32 nSaturation;\n} OMX_CONFIG_SATURATIONTYPE;\n\n\n/** \n * Define for setting Lightness \n *\n * STRUCT MEMBERS:\n *  nSize      : Size of the structure in bytes\n *  nVersion   : OMX specification version information\n *  nPortIndex : Port that this structure applies to\n *  nLightness : Values allowed for lightness -100 to 100, zero means no \n *               change\n */\ntypedef struct OMX_CONFIG_LIGHTNESSTYPE {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n    OMX_S32 nLightness;\n} OMX_CONFIG_LIGHTNESSTYPE;\n\n\n/** \n * Plane blend configuration \n *\n * STRUCT MEMBERS:\n *  nSize      : Size of the structure in bytes \n *  nVersion   : OMX specification version information\n *  nPortIndex : Index of input port associated with the plane.\n *  nDepth     : Depth of the plane in relation to the screen. Higher \n *               numbered depths are \"behind\" lower number depths.  \n *               This number defaults to the Port Index number.\n *  nAlpha     : Transparency blending component for the entire plane.  \n *               See blending modes for more detail.\n */\ntypedef struct OMX_CONFIG_PLANEBLENDTYPE {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n    OMX_U32 nDepth;\n    OMX_U32 nAlpha;\n} OMX_CONFIG_PLANEBLENDTYPE;\n\n\n/** \n * Define interlace type\n *\n * STRUCT MEMBERS:\n *  nSize                 : Size of the structure in bytes \n *  nVersion              : OMX specification version information \n *  nPortIndex            : Port that this structure applies to\n *  bEnable               : Enable control variable for this functionality \n *                          (see below)\n *  nInterleavePortIndex  : Index of input or output port associated with  \n *                          the interleaved plane. \n *  pPlanarPortIndexes[4] : Index of input or output planar ports.\n */\ntypedef struct OMX_PARAM_INTERLEAVETYPE {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n    OMX_BOOL bEnable;\n    OMX_U32 nInterleavePortIndex;\n} OMX_PARAM_INTERLEAVETYPE;\n\n\n/** \n * Defines the picture effect used for an input picture \n */\ntypedef enum OMX_TRANSITIONEFFECTTYPE {\n    OMX_EffectNone,\n    OMX_EffectFadeFromBlack,\n    OMX_EffectFadeToBlack,\n    OMX_EffectUnspecifiedThroughConstantColor,\n    OMX_EffectDissolve,\n    OMX_EffectWipe,\n    OMX_EffectUnspecifiedMixOfTwoScenes,\n    OMX_EffectKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_EffectVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n\n    OMX_EffectReverseUnspecifiedMixOfTwoScenes,\n    \n#ifndef __VIDEOCORE4__\n    OMX_EffectDiagonalWipe,\n    OMX_EffectDiagonalWipeRotate,\n    OMX_EffectEllipticalWipe,\n    OMX_EffectEllipticalWipeRotate,\n    OMX_EffectInverseEllipticalWipe,\n    OMX_EffectInverseEllipticalWipeRotate,\n    OMX_EffectGlassWipe,\n    OMX_EffectGlassWipeRotate,\n    OMX_EffectWavyWipe,\n    OMX_EffectWavyWipeRotate,\n    OMX_EffectMunchingSquares,\n    OMX_EffectStripeWipe,\n    OMX_EffectStripeWipeRotate,\n    \n    OMX_EffectRotozoomUnmatched,\n    OMX_EffectRotozoomMatched,\n    OMX_EffectRotozoomGentle,\n#endif\n\n    OMX_EffectMunchRandom,\n    OMX_EffectMunchVRandom,\n    OMX_EffectMunchHRandom,\n    OMX_EffectMunchWipe,\n    OMX_EffectMunchMunch,\n    OMX_EffectMunchStripe,\n    OMX_EffectFadeRandom,\n    OMX_EffectFadeVRandom,\n    OMX_EffectFadeHRandom,\n    OMX_EffectFadeWipe,\n    OMX_EffectFadeMunch,\n    OMX_EffectFadeStripe,\n    OMX_EffectColourBlockRandom,\n    OMX_EffectColourBlockVRandom,\n    OMX_EffectColourBlockHRandom,\n    OMX_EffectColourBlockWipe,\n    OMX_EffectColourBlockMunch,\n    OMX_EffectColourBlockStripe,\n    OMX_EffectColourBlock2Random,\n    OMX_EffectColourBlock2VRandom,\n    OMX_EffectColourBlock2HRandom,\n    OMX_EffectColourBlock2Wipe,\n    OMX_EffectColourBlock2Munch,\n    OMX_EffectColourBlock2Stripe,\n    OMX_EffectShadeRandom,\n    OMX_EffectShadeVRandom,\n    OMX_EffectShadeHRandom,\n    OMX_EffectShadeWipe,\n    OMX_EffectShadeMunch,\n    OMX_EffectShadeStripe,\n    OMX_EffectBitmaskRandom,\n    OMX_EffectBitmaskVRandom,\n    OMX_EffectBitmaskHRandom,\n    OMX_EffectBitmaskWipe,\n    OMX_EffectBitmaskMunch,\n    OMX_EffectBitmaskStripe,\n    OMX_EffectBitmask2Random,\n    OMX_EffectBitmask2VRandom,\n    OMX_EffectBitmask2HRandom,\n    OMX_EffectBitmask2Wipe,\n    OMX_EffectBitmask2Munch,\n    OMX_EffectBitmask2Stripe,\n    OMX_EffectBitmask2ColourRandom,\n    OMX_EffectBitmask2ColourVRandom,\n    OMX_EffectBitmask2ColourHRandom,\n    OMX_EffectBitmask2ColourWipe,\n    OMX_EffectBitmask2ColourMunch,\n    OMX_EffectBitmask2ColourStripe,\n\n    OMX_EffectPushRight,\n    OMX_EffectPushLeft,\n    OMX_EffectPushDown,\n    OMX_EffectPushUp,\n    OMX_EffectCoverRight,\n    OMX_EffectCoverLeft,\n    OMX_EffectCoverDown,\n    OMX_EffectCoverUp,\n    OMX_EffectRevealRight,\n    OMX_EffectRevealLeft,\n    OMX_EffectRevealDown,\n    OMX_EffectRevealUp,\n    OMX_EffectWipeRight,\n    OMX_EffectWipeLeft,\n    OMX_EffectWipeDown,\n    OMX_EffectWipeUp,\n    OMX_EffectSpeckle,\n    OMX_EffectCircle,\n    OMX_EffectSpiral,\n    OMX_EffectDiamond,\n    OMX_EffectVert,\n    OMX_EffectPlus,\n    OMX_EffectClock,\n    OMX_EffectPlasma,\n    OMX_EffectDisplace,\n    OMX_EffectGenie,\n    OMX_EffectSide,\n    OMX_EffectMaze,\n    OMX_EffectRipple,\n    OMX_EffectStar,\n    OMX_EffectAlpha,\n    OMX_EffectIntense,\n    OMX_EffectIntenseU,\n    OMX_EffectIntenseV,\n    OMX_EffectInverseIntense,\n    OMX_EffectInverseIntenseU,\n    OMX_EffectInverseIntenseV,\n\n    OMX_EffectPageTurn,\n\n    OMX_EffectFlipPlaneDown,\n    OMX_EffectFlipPlaneDownMid,\n    OMX_EffectFlipPlaneDownHigh,\n    OMX_EffectFlipPlaneLeft,\n    OMX_EffectFlipPlaneLeftMid,\n    OMX_EffectFlipPlaneLeftHigh,\n    OMX_EffectFlipCubeDown,\n    OMX_EffectFlipCubeDownMid,\n    OMX_EffectFlipCubeDownHigh,\n    OMX_EffectFlipCubeLeft,\n    OMX_EffectFlipCubeLeftMid,\n    OMX_EffectFlipCubeLeftHigh,\n\n    OMX_EffectMax = 0x7FFFFFFF\n} OMX_TRANSITIONEFFECTTYPE;\n\n\n/** \n * Structure used to configure current transition effect \n *\n * STRUCT MEMBERS:\n * nSize      : Size of the structure in bytes\n * nVersion   : OMX specification version information \n * nPortIndex : Port that this structure applies to\n * eEffect    : Effect to enable\n */\ntypedef struct OMX_CONFIG_TRANSITIONEFFECTTYPE {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n    OMX_TRANSITIONEFFECTTYPE eEffect;\n} OMX_CONFIG_TRANSITIONEFFECTTYPE;\n\n\n/** \n * Defines possible data unit types for encoded video data. The data unit \n * types are used both for encoded video input for playback as well as\n * encoded video output from recording. \n */\ntypedef enum OMX_DATAUNITTYPE {\n    OMX_DataUnitCodedPicture,\n    OMX_DataUnitVideoSegment,\n    OMX_DataUnitSeveralSegments,\n    OMX_DataUnitArbitraryStreamSection,\n    OMX_DataUnitKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_DataUnitVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_DataUnitMax = 0x7FFFFFFF\n} OMX_DATAUNITTYPE;\n\n\n/** \n * Defines possible encapsulation types for coded video data unit. The \n * encapsulation information is used both for encoded video input for \n * playback as well as encoded video output from recording. \n */\ntypedef enum OMX_DATAUNITENCAPSULATIONTYPE {\n    OMX_DataEncapsulationElementaryStream,\n    OMX_DataEncapsulationGenericPayload,\n    OMX_DataEncapsulationRtpPayload,\n    OMX_DataEncapsulationKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_DataEncapsulationVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_DataEncapsulationMax = 0x7FFFFFFF\n} OMX_DATAUNITENCAPSULATIONTYPE;\n\n\n/** \n * Structure used to configure the type of being decoded/encoded \n */\ntypedef struct OMX_PARAM_DATAUNITTYPE {\n    OMX_U32 nSize;            /**< Size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ \n    OMX_U32 nPortIndex;       /**< Port that this structure applies to */\n    OMX_DATAUNITTYPE eUnitType;\n    OMX_DATAUNITENCAPSULATIONTYPE eEncapsulationType;\n} OMX_PARAM_DATAUNITTYPE;\n\n\n/**\n * Defines dither types \n */\ntypedef enum OMX_DITHERTYPE {\n    OMX_DitherNone,\n    OMX_DitherOrdered,\n    OMX_DitherErrorDiffusion,\n    OMX_DitherOther,\n    OMX_DitherKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_DitherVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_DitherMax = 0x7FFFFFFF\n} OMX_DITHERTYPE;\n\n\n/** \n * Structure used to configure current type of dithering \n */\ntypedef struct OMX_CONFIG_DITHERTYPE {\n    OMX_U32 nSize;            /**< Size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ \n    OMX_U32 nPortIndex;       /**< Port that this structure applies to */\n    OMX_DITHERTYPE eDither;   /**< Type of dithering to use */\n} OMX_CONFIG_DITHERTYPE;\n\ntypedef struct OMX_CONFIG_CAPTUREMODETYPE {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;     /**< Port that this structure applies to */\n    OMX_BOOL bContinuous;   /**< If true then ignore frame rate and emit capture \n                             *   data as fast as possible (otherwise obey port's frame rate). */\n    OMX_BOOL bFrameLimited; /**< If true then terminate capture after the port emits the \n                             *   specified number of frames (otherwise the port does not \n                             *   terminate the capture until instructed to do so by the client). \n                             *   Even if set, the client may manually terminate the capture prior \n                             *   to reaching the limit. */\n    OMX_U32 nFrameLimit;      /**< Limit on number of frames emitted during a capture (only\n                               *   valid if bFrameLimited is set). */\n} OMX_CONFIG_CAPTUREMODETYPE;\n\ntypedef enum OMX_METERINGTYPE {\n \n    OMX_MeteringModeAverage,     /**< Center-weighted average metering. */\n    OMX_MeteringModeSpot,  \t      /**< Spot (partial) metering. */\n    OMX_MeteringModeMatrix,      /**< Matrix or evaluative metering. */\n \n    OMX_MeteringKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_MeteringVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_MeteringModeBacklit,\n    OMX_EVModeMax = 0x7fffffff\n} OMX_METERINGTYPE;\n \ntypedef struct OMX_CONFIG_EXPOSUREVALUETYPE {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n    OMX_METERINGTYPE eMetering;\n    OMX_S32 xEVCompensation;      /**< Fixed point value stored as Q16 */\n    OMX_U32 nApertureFNumber;     /**< e.g. nApertureFNumber = 2 implies \"f/2\" - Q16 format */\n    OMX_BOOL bAutoAperture;\t\t/**< Whether aperture number is defined automatically */\n    OMX_U32 nShutterSpeedMsec;    /**< Shutterspeed in milliseconds */ \n    OMX_BOOL bAutoShutterSpeed;\t/**< Whether shutter speed is defined automatically */ \n    OMX_U32 nSensitivity;         /**< e.g. nSensitivity = 100 implies \"ISO 100\" */\n    OMX_BOOL bAutoSensitivity;\t/**< Whether sensitivity is defined automatically */\n} OMX_CONFIG_EXPOSUREVALUETYPE;\n\n/** \n * Focus region configuration \n *\n * STRUCT MEMBERS:\n *  nSize           : Size of the structure in bytes\n *  nVersion        : OMX specification version information\n *  nPortIndex      : Port that this structure applies to\n *  bCenter         : Use center region as focus region of interest\n *  bLeft           : Use left region as focus region of interest\n *  bRight          : Use right region as focus region of interest\n *  bTop            : Use top region as focus region of interest\n *  bBottom         : Use bottom region as focus region of interest\n *  bTopLeft        : Use top left region as focus region of interest\n *  bTopRight       : Use top right region as focus region of interest\n *  bBottomLeft     : Use bottom left region as focus region of interest\n *  bBottomRight    : Use bottom right region as focus region of interest\n */\ntypedef struct OMX_CONFIG_FOCUSREGIONTYPE {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n    OMX_BOOL bCenter;\n    OMX_BOOL bLeft;\n    OMX_BOOL bRight;\n    OMX_BOOL bTop;\n    OMX_BOOL bBottom;\n    OMX_BOOL bTopLeft;\n    OMX_BOOL bTopRight;\n    OMX_BOOL bBottomLeft;\n    OMX_BOOL bBottomRight;\n} OMX_CONFIG_FOCUSREGIONTYPE;\n\n/** \n * Focus Status type \n */\ntypedef enum OMX_FOCUSSTATUSTYPE {\n    OMX_FocusStatusOff = 0,\n    OMX_FocusStatusRequest,\n    OMX_FocusStatusReached,\n    OMX_FocusStatusUnableToReach,\n    OMX_FocusStatusLost,\n    OMX_FocusStatusKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_FocusStatusVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_FocusStatusCafWatching,\n    OMX_FocusStatusCafSceneChanged,\n    OMX_FocusStatusMax = 0x7FFFFFFF\n} OMX_FOCUSSTATUSTYPE;\n\n/** \n * Focus status configuration \n *\n * STRUCT MEMBERS:\n *  nSize               : Size of the structure in bytes\n *  nVersion            : OMX specification version information\n *  nPortIndex          : Port that this structure applies to\n *  eFocusStatus        : Specifies the focus status\n *  bCenterStatus       : Use center region as focus region of interest\n *  bLeftStatus         : Use left region as focus region of interest\n *  bRightStatus        : Use right region as focus region of interest\n *  bTopStatus          : Use top region as focus region of interest\n *  bBottomStatus       : Use bottom region as focus region of interest\n *  bTopLeftStatus      : Use top left region as focus region of interest\n *  bTopRightStatus     : Use top right region as focus region of interest\n *  bBottomLeftStatus   : Use bottom left region as focus region of interest\n *  bBottomRightStatus  : Use bottom right region as focus region of interest\n */\ntypedef struct OMX_PARAM_FOCUSSTATUSTYPE {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n    OMX_FOCUSSTATUSTYPE eFocusStatus;\n    OMX_BOOL bCenterStatus;\n    OMX_BOOL bLeftStatus;\n    OMX_BOOL bRightStatus;\n    OMX_BOOL bTopStatus;\n    OMX_BOOL bBottomStatus;\n    OMX_BOOL bTopLeftStatus;\n    OMX_BOOL bTopRightStatus;\n    OMX_BOOL bBottomLeftStatus;\n    OMX_BOOL bBottomRightStatus;\n} OMX_PARAM_FOCUSSTATUSTYPE;\n\n/** @} */\n\n#ifdef __cplusplus\n}\n#endif /* __cplusplus */\n\n#endif\n/* File EOF */\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vmcs_host/khronos/IL/OMX_Image.h",
    "content": "/**\n * Copyright (c) 2008 The Khronos Group Inc. \n * \n * Permission is hereby granted, free of charge, to any person obtaining\n * a copy of this software and associated documentation files (the\n * \"Software\"), to deal in the Software without restriction, including\n * without limitation the rights to use, copy, modify, merge, publish,\n * distribute, sublicense, and/or sell copies of the Software, and to\n * permit persons to whom the Software is furnished to do so, subject\n * to the following conditions: \n * The above copyright notice and this permission notice shall be included\n * in all copies or substantial portions of the Software. \n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\n * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\n * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\n * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \n */\n\n/** \n * @file OMX_Image.h - OpenMax IL version 1.1.2\n * The structures needed by Image components to exchange parameters and \n * configuration data with the components.\n */\n#ifndef OMX_Image_h\n#define OMX_Image_h\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif /* __cplusplus */\n\n\n/**\n * Each OMX header must include all required header files to allow the \n * header to compile without errors.  The includes below are required  \n * for this header file to compile successfully \n */\n\n#include \"OMX_IVCommon.h\"\n\n/** @defgroup imaging OpenMAX IL Imaging Domain\n * @ingroup iv\n * Structures for OpenMAX IL Imaging domain\n * @{\n */\n\n/** \n * Enumeration used to define the possible image compression coding. \n */\ntypedef enum OMX_IMAGE_CODINGTYPE {\n    OMX_IMAGE_CodingUnused,      /**< Value when format is N/A */\n    OMX_IMAGE_CodingAutoDetect,  /**< Auto detection of image format */\n    OMX_IMAGE_CodingJPEG,        /**< JPEG/JFIF image format */\n    OMX_IMAGE_CodingJPEG2K,      /**< JPEG 2000 image format */\n    OMX_IMAGE_CodingEXIF,        /**< EXIF image format */\n    OMX_IMAGE_CodingTIFF,        /**< TIFF image format */\n    OMX_IMAGE_CodingGIF,         /**< Graphics image format */\n    OMX_IMAGE_CodingPNG,         /**< PNG image format */\n    OMX_IMAGE_CodingLZW,         /**< LZW image format */\n    OMX_IMAGE_CodingBMP,         /**< Windows Bitmap format */\n    OMX_IMAGE_CodingKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_IMAGE_CodingVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n\n    OMX_IMAGE_CodingTGA,\n    OMX_IMAGE_CodingPPM,\n\n    OMX_IMAGE_CodingMax = 0x7FFFFFFF\n} OMX_IMAGE_CODINGTYPE;\n\n\n/**\n * Data structure used to define an image path. The number of image paths \n * for input and output will vary by type of the image component.  \n * \n *  Input (aka Source) : Zero Inputs, one Output,\n *  Splitter           : One Input, 2 or more Outputs,\n *  Processing Element : One Input, one output,\n *  Mixer              : 2 or more inputs, one output,\n *  Output (aka Sink)  : One Input, zero outputs.\n * \n * The PortDefinition structure is used to define all of the parameters \n * necessary for the compliant component to setup an input or an output  \n * image path.  If additional vendor specific data is required, it should  \n * be transmitted to the component using the CustomCommand function.   \n * Compliant components will prepopulate this structure with optimal  \n * values during the OMX_GetParameter() command.\n *\n * STRUCT MEMBERS:\n *  cMIMEType             : MIME type of data for the port\n *  pNativeRender         : Platform specific reference for a display if a \n *                          sync, otherwise this field is 0\n *  nFrameWidth           : Width of frame to be used on port if \n *                          uncompressed format is used.  Use 0 for \n *                          unknown, don't care or variable\n *  nFrameHeight          : Height of frame to be used on port if \n *                          uncompressed format is used. Use 0 for \n *                          unknown, don't care or variable\n *  nStride               : Number of bytes per span of an image (i.e. \n *                          indicates the number of bytes to get from\n *                          span N to span N+1, where negative stride \n *                          indicates the image is bottom up\n *  nSliceHeight          : Height used when encoding in slices\n *  bFlagErrorConcealment : Turns on error concealment if it is supported by \n *                          the OMX component\n *  eCompressionFormat    : Compression format used in this instance of  \n *                          the component. When OMX_IMAGE_CodingUnused is \n *                          specified, eColorFormat is valid\n *  eColorFormat          : Decompressed format used by this component\n *  pNativeWindow         : Platform specific reference for a window object if a \n *                          display sink , otherwise this field is 0x0. \n */\ntypedef struct OMX_IMAGE_PORTDEFINITIONTYPE {\n    OMX_STRING cMIMEType;\n    OMX_NATIVE_DEVICETYPE pNativeRender;\n    OMX_U32 nFrameWidth; \n    OMX_U32 nFrameHeight;\n    OMX_S32 nStride;     \n    OMX_U32 nSliceHeight;\n    OMX_BOOL bFlagErrorConcealment;\n    OMX_IMAGE_CODINGTYPE eCompressionFormat;\n    OMX_COLOR_FORMATTYPE eColorFormat;\n    OMX_NATIVE_WINDOWTYPE pNativeWindow;\n} OMX_IMAGE_PORTDEFINITIONTYPE;\n\n\n/**  \n * Port format parameter.  This structure is used to enumerate the various \n * data input/output format supported by the port.\n * \n * STRUCT MEMBERS:\n *  nSize              : Size of the structure in bytes\n *  nVersion           : OMX specification version information\n *  nPortIndex         : Indicates which port to set\n *  nIndex             : Indicates the enumeration index for the format from \n *                       0x0 to N-1\n *  eCompressionFormat : Compression format used in this instance of the \n *                       component. When OMX_IMAGE_CodingUnused is specified, \n *                       eColorFormat is valid\n *  eColorFormat       : Decompressed format used by this component\n */\ntypedef struct OMX_IMAGE_PARAM_PORTFORMATTYPE {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n    OMX_U32 nIndex;\n    OMX_IMAGE_CODINGTYPE eCompressionFormat;\n    OMX_COLOR_FORMATTYPE eColorFormat;\n} OMX_IMAGE_PARAM_PORTFORMATTYPE;\n\n\n/** \n * Flash control type \n *\n * ENUMS\n *  Torch : Flash forced constantly on\n */\ntypedef enum OMX_IMAGE_FLASHCONTROLTYPE {\n    OMX_IMAGE_FlashControlOn = 0,\n    OMX_IMAGE_FlashControlOff,\n    OMX_IMAGE_FlashControlAuto,\n    OMX_IMAGE_FlashControlRedEyeReduction,\n    OMX_IMAGE_FlashControlFillin,\n    OMX_IMAGE_FlashControlTorch,\n    OMX_IMAGE_FlashControlKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_IMAGE_FlashControlVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_IMAGE_FlashControlMax = 0x7FFFFFFF\n} OMX_IMAGE_FLASHCONTROLTYPE;\n\n\n/** \n * Flash control configuration \n *\n * STRUCT MEMBERS:\n *  nSize         : Size of the structure in bytes\n *  nVersion      : OMX specification version information\n *  nPortIndex    : Port that this structure applies to\n *  eFlashControl : Flash control type\n */\ntypedef struct OMX_IMAGE_PARAM_FLASHCONTROLTYPE {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n    OMX_IMAGE_FLASHCONTROLTYPE eFlashControl;\n} OMX_IMAGE_PARAM_FLASHCONTROLTYPE;\n\n\n/** \n * Focus control type \n */\ntypedef enum OMX_IMAGE_FOCUSCONTROLTYPE {\n    OMX_IMAGE_FocusControlOn = 0,\n    OMX_IMAGE_FocusControlOff,\n    OMX_IMAGE_FocusControlAuto,\n    OMX_IMAGE_FocusControlAutoLock,\n    OMX_IMAGE_FocusControlKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_IMAGE_FocusControlVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_IMAGE_FocusControlHyperfocal,         /* Focus at the hyperfocal point of the lens. */\n    OMX_IMAGE_FocusControlAutoMacro,          /* CF over a macro range (eg 0-50cm) */\n    OMX_IMAGE_FocusControlAutoInfinity,       /* CF over distant range (eg 50cm to infinity) */\n    OMX_IMAGE_FocusControlAutoLockMacro,      /* AF over a macro range (eg 0-50cm) */\n    OMX_IMAGE_FocusControlAutoLockInfinity,   /* AF over distant range (eg 50cm to infinity) */\n    OMX_IMAGE_FocusControlNearFixed,          /* Focus at a fixed near focus point - (50cm-1m) */\n    OMX_IMAGE_FocusControlAutoNear,           /* CF over a near range (eg 0-200cm) */\n    OMX_IMAGE_FocusControlAutoLockNear,       /* AF over a near range (eg 0-200cm) */\n    OMX_IMAGE_FocusControlInfinityFixed,      /* Focus at infinity */\n    OMX_IMAGE_FocusControlMacroFixed,         /* Focus at a macro distance */\n    OMX_IMAGE_FocusControlAutoFast,           /* CF over a full range with fast response */\n    OMX_IMAGE_FocusControlAutoMacroFast,      /* CF over a macro range (eg 0-50cm) with fast response */\n    OMX_IMAGE_FocusControlAutoNearFast,       /* CF over a near range (eg 0-200cm) */\n    OMX_IMAGE_FocusControlAutoInfinityFast,   /* CF over distant range (eg 50cm to infinity) with fast response */\n    OMX_IMAGE_FocusControlCurrentFixed,       /* Stop the lens at the current position */\n    OMX_IMAGE_FocusControlMax = 0x7FFFFFFF\n} OMX_IMAGE_FOCUSCONTROLTYPE;\n\n \n/** \n * Focus control configuration \n *\n * STRUCT MEMBERS:\n *  nSize           : Size of the structure in bytes\n *  nVersion        : OMX specification version information\n *  nPortIndex      : Port that this structure applies to\n *  eFocusControl   : Focus control\n *  nFocusSteps     : Focus can take on values from 0 mm to infinity. \n *                    Interest is only in number of steps over this range.\n *  nFocusStepIndex : Current focus step index\n */\ntypedef struct OMX_IMAGE_CONFIG_FOCUSCONTROLTYPE {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n    OMX_IMAGE_FOCUSCONTROLTYPE eFocusControl;\n    OMX_U32 nFocusSteps;\n    OMX_U32 nFocusStepIndex;\n} OMX_IMAGE_CONFIG_FOCUSCONTROLTYPE;\n\n\n/** \n * Q Factor for JPEG compression, which controls the tradeoff between image\n * quality and size.  Q Factor provides a more simple means of controlling\n * JPEG compression quality, without directly programming Quantization\n * tables for chroma and luma \n *\n * STRUCT MEMBERS:\n *  nSize      : Size of the structure in bytes         \n *  nVersion   : OMX specification version information \n *  nPortIndex : Port that this structure applies to \n *  nQFactor   : JPEG Q factor value in the range of 1-100. A factor of 1 \n *               produces the smallest, worst quality images, and a factor \n *               of 100 produces the largest, best quality images.  A \n *               typical default is 75 for small good quality images               \n */\ntypedef struct OMX_IMAGE_PARAM_QFACTORTYPE {\n    OMX_U32 nSize;            \n    OMX_VERSIONTYPE nVersion; \n    OMX_U32 nPortIndex;       \n    OMX_U32 nQFactor;                                        \n} OMX_IMAGE_PARAM_QFACTORTYPE;\n\n/** \n * Quantization table type \n */\n\ntypedef enum OMX_IMAGE_QUANTIZATIONTABLETYPE {\n    OMX_IMAGE_QuantizationTableLuma = 0,\n    OMX_IMAGE_QuantizationTableChroma,\n    OMX_IMAGE_QuantizationTableChromaCb,\n    OMX_IMAGE_QuantizationTableChromaCr,\n    OMX_IMAGE_QuantizationTableKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_IMAGE_QuantizationTableVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_IMAGE_QuantizationTableMax = 0x7FFFFFFF\n} OMX_IMAGE_QUANTIZATIONTABLETYPE;\n\n/** \n * JPEG quantization tables are used to determine DCT compression for\n * YUV data, as an alternative to specifying Q factor, providing exact \n * control of compression \n *\n * STRUCT MEMBERS:\n *  nSize                   : Size of the structure in bytes\n *  nVersion                : OMX specification version information \n *  nPortIndex              : Port that this structure applies to\n *  eQuantizationTable      : Quantization table type\n *  nQuantizationMatrix[64] : JPEG quantization table of coefficients stored \n *                            in increasing columns then by rows of data (i.e. \n *                            row 1, ... row 8). Quantization values are in \n *                            the range 0-255 and stored in linear order\n *                            (i.e. the component will zig-zag the \n *                            quantization table data if required internally) \n */\ntypedef struct OMX_IMAGE_PARAM_QUANTIZATIONTABLETYPE {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n    OMX_IMAGE_QUANTIZATIONTABLETYPE eQuantizationTable;\n    OMX_U8 nQuantizationMatrix[64];\n} OMX_IMAGE_PARAM_QUANTIZATIONTABLETYPE;\n\n\n/** \n * Huffman table type, the same Huffman table is applied for chroma and \n * luma component \n */\ntypedef enum OMX_IMAGE_HUFFMANTABLETYPE {\n    OMX_IMAGE_HuffmanTableAC = 0,\n    OMX_IMAGE_HuffmanTableDC,\n    OMX_IMAGE_HuffmanTableACLuma,\n    OMX_IMAGE_HuffmanTableACChroma,\n    OMX_IMAGE_HuffmanTableDCLuma,\n    OMX_IMAGE_HuffmanTableDCChroma,\n    OMX_IMAGE_HuffmanTableKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_IMAGE_HuffmanTableVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_IMAGE_HuffmanTableMax = 0x7FFFFFFF\n} OMX_IMAGE_HUFFMANTABLETYPE;\n\n/** \n * JPEG Huffman table \n *\n * STRUCT MEMBERS:\n *  nSize                            : Size of the structure in bytes\n *  nVersion                         : OMX specification version information\n *  nPortIndex                       : Port that this structure applies to\n *  eHuffmanTable                    : Huffman table type\n *  nNumberOfHuffmanCodeOfLength[16] : 0-16, number of Huffman codes of each \n *                                     possible length\n *  nHuffmanTable[256]               : 0-255, the size used for AC and DC \n *                                     HuffmanTable are 16 and 162 \n */\ntypedef struct OMX_IMAGE_PARAM_HUFFMANTTABLETYPE {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n    OMX_IMAGE_HUFFMANTABLETYPE eHuffmanTable;\n    OMX_U8 nNumberOfHuffmanCodeOfLength[16];\n    OMX_U8 nHuffmanTable[256];\n}OMX_IMAGE_PARAM_HUFFMANTTABLETYPE;\n\n/** @} */\n#ifdef __cplusplus\n}\n#endif /* __cplusplus */\n\n#endif\n/* File EOF */\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vmcs_host/khronos/IL/OMX_Index.h",
    "content": "/*\n * Copyright (c) 2008 The Khronos Group Inc.\n *\n * Permission is hereby granted, free of charge, to any person obtaining\n * a copy of this software and associated documentation files (the\n * \"Software\"), to deal in the Software without restriction, including\n * without limitation the rights to use, copy, modify, merge, publish,\n * distribute, sublicense, and/or sell copies of the Software, and to\n * permit persons to whom the Software is furnished to do so, subject\n * to the following conditions:\n * The above copyright notice and this permission notice shall be included\n * in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\n * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\n * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\n * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n *\n */\n\n/** @file OMX_Index.h - OpenMax IL version 1.1.2\n *  The OMX_Index header file contains the definitions for both applications\n *  and components .\n */\n\n\n#ifndef OMX_Index_h\n#define OMX_Index_h\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif /* __cplusplus */\n\n\n/* Each OMX header must include all required header files to allow the\n *  header to compile without errors.  The includes below are required\n *  for this header file to compile successfully\n */\n#include \"OMX_Types.h\"\n\n\n/** The OMX_INDEXTYPE enumeration is used to select a structure when either\n *  getting or setting parameters and/or configuration data.  Each entry in\n *  this enumeration maps to an OMX specified structure.  When the\n *  OMX_GetParameter, OMX_SetParameter, OMX_GetConfig or OMX_SetConfig methods\n *  are used, the second parameter will always be an entry from this enumeration\n *  and the third entry will be the structure shown in the comments for the entry.\n *  For example, if the application is initializing a cropping function, the\n *  OMX_SetConfig command would have OMX_IndexConfigCommonInputCrop as the second parameter\n *  and would send a pointer to an initialized OMX_RECTTYPE structure as the\n *  third parameter.\n *\n *  The enumeration entries named with the OMX_Config prefix are sent using\n *  the OMX_SetConfig command and the enumeration entries named with the\n *  OMX_PARAM_ prefix are sent using the OMX_SetParameter command.\n */\ntypedef enum OMX_INDEXTYPE {\n\n    OMX_IndexComponentStartUnused = 0x01000000,\n    OMX_IndexParamPriorityMgmt,             /**< reference: OMX_PRIORITYMGMTTYPE */\n    OMX_IndexParamAudioInit,                /**< reference: OMX_PORT_PARAM_TYPE */\n    OMX_IndexParamImageInit,                /**< reference: OMX_PORT_PARAM_TYPE */\n    OMX_IndexParamVideoInit,                /**< reference: OMX_PORT_PARAM_TYPE */\n    OMX_IndexParamOtherInit,                /**< reference: OMX_PORT_PARAM_TYPE */\n    OMX_IndexParamNumAvailableStreams,      /**< reference: OMX_PARAM_U32TYPE */\n    OMX_IndexParamActiveStream,             /**< reference: OMX_PARAM_U32TYPE */\n    OMX_IndexParamSuspensionPolicy,         /**< reference: OMX_PARAM_SUSPENSIONPOLICYTYPE */\n    OMX_IndexParamComponentSuspended,       /**< reference: OMX_PARAM_SUSPENSIONTYPE */\n    OMX_IndexConfigCapturing,               /**< reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexConfigCaptureMode,             /**< reference: OMX_CONFIG_CAPTUREMODETYPE */\n    OMX_IndexAutoPauseAfterCapture,         /**< reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexParamContentURI,               /**< reference: OMX_PARAM_CONTENTURITYPE */\n    OMX_IndexParamCustomContentPipe,        /**< reference: OMX_PARAM_CONTENTPIPETYPE */\n    OMX_IndexParamDisableResourceConcealment, /**< reference: OMX_RESOURCECONCEALMENTTYPE */\n    OMX_IndexConfigMetadataItemCount,       /**< reference: OMX_CONFIG_METADATAITEMCOUNTTYPE */\n    OMX_IndexConfigContainerNodeCount,      /**< reference: OMX_CONFIG_CONTAINERNODECOUNTTYPE */\n    OMX_IndexConfigMetadataItem,            /**< reference: OMX_CONFIG_METADATAITEMTYPE */\n    OMX_IndexConfigCounterNodeID,           /**< reference: OMX_CONFIG_CONTAINERNODEIDTYPE */\n    OMX_IndexParamMetadataFilterType,       /**< reference: OMX_PARAM_METADATAFILTERTYPE */\n    OMX_IndexParamMetadataKeyFilter,        /**< reference: OMX_PARAM_METADATAFILTERTYPE */\n    OMX_IndexConfigPriorityMgmt,            /**< reference: OMX_PRIORITYMGMTTYPE */\n    OMX_IndexParamStandardComponentRole,    /**< reference: OMX_PARAM_COMPONENTROLETYPE */\n\n    OMX_IndexPortStartUnused = 0x02000000,\n    OMX_IndexParamPortDefinition,           /**< reference: OMX_PARAM_PORTDEFINITIONTYPE */\n    OMX_IndexParamCompBufferSupplier,       /**< reference: OMX_PARAM_BUFFERSUPPLIERTYPE */\n    OMX_IndexReservedStartUnused = 0x03000000,\n\n    /* Audio parameters and configurations */\n    OMX_IndexAudioStartUnused = 0x04000000,\n    OMX_IndexParamAudioPortFormat,          /**< reference: OMX_AUDIO_PARAM_PORTFORMATTYPE */\n    OMX_IndexParamAudioPcm,                 /**< reference: OMX_AUDIO_PARAM_PCMMODETYPE */\n    OMX_IndexParamAudioAac,                 /**< reference: OMX_AUDIO_PARAM_AACPROFILETYPE */\n    OMX_IndexParamAudioRa,                  /**< reference: OMX_AUDIO_PARAM_RATYPE */\n    OMX_IndexParamAudioMp3,                 /**< reference: OMX_AUDIO_PARAM_MP3TYPE */\n    OMX_IndexParamAudioAdpcm,               /**< reference: OMX_AUDIO_PARAM_ADPCMTYPE */\n    OMX_IndexParamAudioG723,                /**< reference: OMX_AUDIO_PARAM_G723TYPE */\n    OMX_IndexParamAudioG729,                /**< reference: OMX_AUDIO_PARAM_G729TYPE */\n    OMX_IndexParamAudioAmr,                 /**< reference: OMX_AUDIO_PARAM_AMRTYPE */\n    OMX_IndexParamAudioWma,                 /**< reference: OMX_AUDIO_PARAM_WMATYPE */\n    OMX_IndexParamAudioSbc,                 /**< reference: OMX_AUDIO_PARAM_SBCTYPE */\n    OMX_IndexParamAudioMidi,                /**< reference: OMX_AUDIO_PARAM_MIDITYPE */\n    OMX_IndexParamAudioGsm_FR,              /**< reference: OMX_AUDIO_PARAM_GSMFRTYPE */\n    OMX_IndexParamAudioMidiLoadUserSound,   /**< reference: OMX_AUDIO_PARAM_MIDILOADUSERSOUNDTYPE */\n    OMX_IndexParamAudioG726,                /**< reference: OMX_AUDIO_PARAM_G726TYPE */\n    OMX_IndexParamAudioGsm_EFR,             /**< reference: OMX_AUDIO_PARAM_GSMEFRTYPE */\n    OMX_IndexParamAudioGsm_HR,              /**< reference: OMX_AUDIO_PARAM_GSMHRTYPE */\n    OMX_IndexParamAudioPdc_FR,              /**< reference: OMX_AUDIO_PARAM_PDCFRTYPE */\n    OMX_IndexParamAudioPdc_EFR,             /**< reference: OMX_AUDIO_PARAM_PDCEFRTYPE */\n    OMX_IndexParamAudioPdc_HR,              /**< reference: OMX_AUDIO_PARAM_PDCHRTYPE */\n    OMX_IndexParamAudioTdma_FR,             /**< reference: OMX_AUDIO_PARAM_TDMAFRTYPE */\n    OMX_IndexParamAudioTdma_EFR,            /**< reference: OMX_AUDIO_PARAM_TDMAEFRTYPE */\n    OMX_IndexParamAudioQcelp8,              /**< reference: OMX_AUDIO_PARAM_QCELP8TYPE */\n    OMX_IndexParamAudioQcelp13,             /**< reference: OMX_AUDIO_PARAM_QCELP13TYPE */\n    OMX_IndexParamAudioEvrc,                /**< reference: OMX_AUDIO_PARAM_EVRCTYPE */\n    OMX_IndexParamAudioSmv,                 /**< reference: OMX_AUDIO_PARAM_SMVTYPE */\n    OMX_IndexParamAudioVorbis,              /**< reference: OMX_AUDIO_PARAM_VORBISTYPE */\n\n    OMX_IndexConfigAudioMidiImmediateEvent, /**< reference: OMX_AUDIO_CONFIG_MIDIIMMEDIATEEVENTTYPE */\n    OMX_IndexConfigAudioMidiControl,        /**< reference: OMX_AUDIO_CONFIG_MIDICONTROLTYPE */\n    OMX_IndexConfigAudioMidiSoundBankProgram, /**< reference: OMX_AUDIO_CONFIG_MIDISOUNDBANKPROGRAMTYPE */\n    OMX_IndexConfigAudioMidiStatus,         /**< reference: OMX_AUDIO_CONFIG_MIDISTATUSTYPE */\n    OMX_IndexConfigAudioMidiMetaEvent,      /**< reference: OMX_AUDIO_CONFIG_MIDIMETAEVENTTYPE */\n    OMX_IndexConfigAudioMidiMetaEventData,  /**< reference: OMX_AUDIO_CONFIG_MIDIMETAEVENTDATATYPE */\n    OMX_IndexConfigAudioVolume,             /**< reference: OMX_AUDIO_CONFIG_VOLUMETYPE */\n    OMX_IndexConfigAudioBalance,            /**< reference: OMX_AUDIO_CONFIG_BALANCETYPE */\n    OMX_IndexConfigAudioChannelMute,        /**< reference: OMX_AUDIO_CONFIG_CHANNELMUTETYPE */\n    OMX_IndexConfigAudioMute,               /**< reference: OMX_AUDIO_CONFIG_MUTETYPE */\n    OMX_IndexConfigAudioLoudness,           /**< reference: OMX_AUDIO_CONFIG_LOUDNESSTYPE */\n    OMX_IndexConfigAudioEchoCancelation,    /**< reference: OMX_AUDIO_CONFIG_ECHOCANCELATIONTYPE */\n    OMX_IndexConfigAudioNoiseReduction,     /**< reference: OMX_AUDIO_CONFIG_NOISEREDUCTIONTYPE */\n    OMX_IndexConfigAudioBass,               /**< reference: OMX_AUDIO_CONFIG_BASSTYPE */\n    OMX_IndexConfigAudioTreble,             /**< reference: OMX_AUDIO_CONFIG_TREBLETYPE */\n    OMX_IndexConfigAudioStereoWidening,     /**< reference: OMX_AUDIO_CONFIG_STEREOWIDENINGTYPE */\n    OMX_IndexConfigAudioChorus,             /**< reference: OMX_AUDIO_CONFIG_CHORUSTYPE */\n    OMX_IndexConfigAudioEqualizer,          /**< reference: OMX_AUDIO_CONFIG_EQUALIZERTYPE */\n    OMX_IndexConfigAudioReverberation,      /**< reference: OMX_AUDIO_CONFIG_REVERBERATIONTYPE */\n    OMX_IndexConfigAudioChannelVolume,      /**< reference: OMX_AUDIO_CONFIG_CHANNELVOLUMETYPE */\n\n    /* Image specific parameters and configurations */\n    OMX_IndexImageStartUnused = 0x05000000,\n    OMX_IndexParamImagePortFormat,          /**< reference: OMX_IMAGE_PARAM_PORTFORMATTYPE */\n    OMX_IndexParamFlashControl,             /**< reference: OMX_IMAGE_PARAM_FLASHCONTROLTYPE */\n    OMX_IndexConfigFocusControl,            /**< reference: OMX_IMAGE_CONFIG_FOCUSCONTROLTYPE */\n    OMX_IndexParamQFactor,                  /**< reference: OMX_IMAGE_PARAM_QFACTORTYPE */\n    OMX_IndexParamQuantizationTable,        /**< reference: OMX_IMAGE_PARAM_QUANTIZATIONTABLETYPE */\n    OMX_IndexParamHuffmanTable,             /**< reference: OMX_IMAGE_PARAM_HUFFMANTTABLETYPE */\n    OMX_IndexConfigFlashControl,            /**< reference: OMX_IMAGE_PARAM_FLASHCONTROLTYPE */\n\n    /* Video specific parameters and configurations */\n    OMX_IndexVideoStartUnused = 0x06000000,\n    OMX_IndexParamVideoPortFormat,          /**< reference: OMX_VIDEO_PARAM_PORTFORMATTYPE */\n    OMX_IndexParamVideoQuantization,        /**< reference: OMX_VIDEO_PARAM_QUANTIZATIONTYPE */\n    OMX_IndexParamVideoFastUpdate,          /**< reference: OMX_VIDEO_PARAM_VIDEOFASTUPDATETYPE */\n    OMX_IndexParamVideoBitrate,             /**< reference: OMX_VIDEO_PARAM_BITRATETYPE */\n    OMX_IndexParamVideoMotionVector,        /**< reference: OMX_VIDEO_PARAM_MOTIONVECTORTYPE */\n    OMX_IndexParamVideoIntraRefresh,        /**< reference: OMX_VIDEO_PARAM_INTRAREFRESHTYPE */\n    OMX_IndexParamVideoErrorCorrection,     /**< reference: OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE */\n    OMX_IndexParamVideoVBSMC,               /**< reference: OMX_VIDEO_PARAM_VBSMCTYPE */\n    OMX_IndexParamVideoMpeg2,               /**< reference: OMX_VIDEO_PARAM_MPEG2TYPE */\n    OMX_IndexParamVideoMpeg4,               /**< reference: OMX_VIDEO_PARAM_MPEG4TYPE */\n    OMX_IndexParamVideoWmv,                 /**< reference: OMX_VIDEO_PARAM_WMVTYPE */\n    OMX_IndexParamVideoRv,                  /**< reference: OMX_VIDEO_PARAM_RVTYPE */\n    OMX_IndexParamVideoAvc,                 /**< reference: OMX_VIDEO_PARAM_AVCTYPE */\n    OMX_IndexParamVideoH263,                /**< reference: OMX_VIDEO_PARAM_H263TYPE */\n    OMX_IndexParamVideoProfileLevelQuerySupported, /**< reference: OMX_VIDEO_PARAM_PROFILELEVELTYPE */\n    OMX_IndexParamVideoProfileLevelCurrent, /**< reference: OMX_VIDEO_PARAM_PROFILELEVELTYPE */\n    OMX_IndexConfigVideoBitrate,            /**< reference: OMX_VIDEO_CONFIG_BITRATETYPE */\n    OMX_IndexConfigVideoFramerate,          /**< reference: OMX_CONFIG_FRAMERATETYPE */\n    OMX_IndexConfigVideoIntraVOPRefresh,    /**< reference: OMX_CONFIG_INTRAREFRESHVOPTYPE */\n    OMX_IndexConfigVideoIntraMBRefresh,     /**< reference: OMX_CONFIG_MACROBLOCKERRORMAPTYPE */\n    OMX_IndexConfigVideoMBErrorReporting,   /**< reference: OMX_CONFIG_MBERRORREPORTINGTYPE */\n    OMX_IndexParamVideoMacroblocksPerFrame, /**< reference: OMX_PARAM_MACROBLOCKSTYPE */\n    OMX_IndexConfigVideoMacroBlockErrorMap, /**< reference: OMX_CONFIG_MACROBLOCKERRORMAPTYPE */\n    OMX_IndexParamVideoSliceFMO,            /**< reference: OMX_VIDEO_PARAM_AVCSLICEFMO */\n    OMX_IndexConfigVideoAVCIntraPeriod,     /**< reference: OMX_VIDEO_CONFIG_AVCINTRAPERIOD */\n    OMX_IndexConfigVideoNalSize,            /**< reference: OMX_VIDEO_CONFIG_NALSIZE */\n\n    /* Image & Video common Configurations */\n    OMX_IndexCommonStartUnused = 0x07000000,\n    OMX_IndexParamCommonDeblocking,         /**< reference: OMX_PARAM_DEBLOCKINGTYPE */\n    OMX_IndexParamCommonSensorMode,         /**< reference: OMX_PARAM_SENSORMODETYPE */\n    OMX_IndexParamCommonInterleave,         /**< reference: OMX_PARAM_INTERLEAVETYPE */\n    OMX_IndexConfigCommonColorFormatConversion, /**< reference: OMX_CONFIG_COLORCONVERSIONTYPE */\n    OMX_IndexConfigCommonScale,             /**< reference: OMX_CONFIG_SCALEFACTORTYPE */\n    OMX_IndexConfigCommonImageFilter,       /**< reference: OMX_CONFIG_IMAGEFILTERTYPE */\n    OMX_IndexConfigCommonColorEnhancement,  /**< reference: OMX_CONFIG_COLORENHANCEMENTTYPE */\n    OMX_IndexConfigCommonColorKey,          /**< reference: OMX_CONFIG_COLORKEYTYPE */\n    OMX_IndexConfigCommonColorBlend,        /**< reference: OMX_CONFIG_COLORBLENDTYPE */\n    OMX_IndexConfigCommonFrameStabilisation,/**< reference: OMX_CONFIG_FRAMESTABTYPE */\n    OMX_IndexConfigCommonRotate,            /**< reference: OMX_CONFIG_ROTATIONTYPE */\n    OMX_IndexConfigCommonMirror,            /**< reference: OMX_CONFIG_MIRRORTYPE */\n    OMX_IndexConfigCommonOutputPosition,    /**< reference: OMX_CONFIG_POINTTYPE */\n    OMX_IndexConfigCommonInputCrop,         /**< reference: OMX_CONFIG_RECTTYPE */\n    OMX_IndexConfigCommonOutputCrop,        /**< reference: OMX_CONFIG_RECTTYPE */\n    OMX_IndexConfigCommonDigitalZoom,       /**< reference: OMX_CONFIG_SCALEFACTORTYPE */\n    OMX_IndexConfigCommonOpticalZoom,       /**< reference: OMX_CONFIG_SCALEFACTORTYPE*/\n    OMX_IndexConfigCommonWhiteBalance,      /**< reference: OMX_CONFIG_WHITEBALCONTROLTYPE */\n    OMX_IndexConfigCommonExposure,          /**< reference: OMX_CONFIG_EXPOSURECONTROLTYPE */\n    OMX_IndexConfigCommonContrast,          /**< reference: OMX_CONFIG_CONTRASTTYPE */\n    OMX_IndexConfigCommonBrightness,        /**< reference: OMX_CONFIG_BRIGHTNESSTYPE */\n    OMX_IndexConfigCommonBacklight,         /**< reference: OMX_CONFIG_BACKLIGHTTYPE */\n    OMX_IndexConfigCommonGamma,             /**< reference: OMX_CONFIG_GAMMATYPE */\n    OMX_IndexConfigCommonSaturation,        /**< reference: OMX_CONFIG_SATURATIONTYPE */\n    OMX_IndexConfigCommonLightness,         /**< reference: OMX_CONFIG_LIGHTNESSTYPE */\n    OMX_IndexConfigCommonExclusionRect,     /**< reference: OMX_CONFIG_RECTTYPE */\n    OMX_IndexConfigCommonDithering,         /**< reference: OMX_CONFIG_DITHERTYPE */\n    OMX_IndexConfigCommonPlaneBlend,        /**< reference: OMX_CONFIG_PLANEBLENDTYPE */\n    OMX_IndexConfigCommonExposureValue,     /**< reference: OMX_CONFIG_EXPOSUREVALUETYPE */\n    OMX_IndexConfigCommonOutputSize,        /**< reference: OMX_FRAMESIZETYPE */\n    OMX_IndexParamCommonExtraQuantData,     /**< reference: OMX_OTHER_EXTRADATATYPE */\n    OMX_IndexConfigCommonFocusRegion,       /**< reference: OMX_CONFIG_FOCUSREGIONTYPE */\n    OMX_IndexConfigCommonFocusStatus,       /**< reference: OMX_PARAM_FOCUSSTATUSTYPE */\n    OMX_IndexConfigCommonTransitionEffect,  /**< reference: OMX_CONFIG_TRANSITIONEFFECTTYPE */\n\n    /* Reserved Configuration range */\n    OMX_IndexOtherStartUnused = 0x08000000,\n    OMX_IndexParamOtherPortFormat,          /**< reference: OMX_OTHER_PARAM_PORTFORMATTYPE */\n    OMX_IndexConfigOtherPower,              /**< reference: OMX_OTHER_CONFIG_POWERTYPE */\n    OMX_IndexConfigOtherStats,              /**< reference: OMX_OTHER_CONFIG_STATSTYPE */\n\n\n    /* Reserved Time range */\n    OMX_IndexTimeStartUnused = 0x09000000,\n    OMX_IndexConfigTimeScale,               /**< reference: OMX_TIME_CONFIG_SCALETYPE */\n    OMX_IndexConfigTimeClockState,          /**< reference: OMX_TIME_CONFIG_CLOCKSTATETYPE */\n    OMX_IndexConfigTimeActiveRefClock,      /**< reference: OMX_TIME_CONFIG_ACTIVEREFCLOCKTYPE */\n    OMX_IndexConfigTimeCurrentMediaTime,    /**< reference: OMX_TIME_CONFIG_TIMESTAMPTYPE (read only) */\n    OMX_IndexConfigTimeCurrentWallTime,     /**< reference: OMX_TIME_CONFIG_TIMESTAMPTYPE (read only) */\n    OMX_IndexConfigTimeCurrentAudioReference, /**< reference: OMX_TIME_CONFIG_TIMESTAMPTYPE (write only) */\n    OMX_IndexConfigTimeCurrentVideoReference, /**< reference: OMX_TIME_CONFIG_TIMESTAMPTYPE (write only) */\n    OMX_IndexConfigTimeMediaTimeRequest,    /**< reference: OMX_TIME_CONFIG_MEDIATIMEREQUESTTYPE (write only) */\n    OMX_IndexConfigTimeClientStartTime,     /**<reference:  OMX_TIME_CONFIG_TIMESTAMPTYPE (write only) */\n    OMX_IndexConfigTimePosition,            /**< reference: OMX_TIME_CONFIG_TIMESTAMPTYPE */\n    OMX_IndexConfigTimeSeekMode,            /**< reference: OMX_TIME_CONFIG_SEEKMODETYPE */\n\n\n    OMX_IndexKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */\n    /* Vendor specific area */\n    OMX_IndexVendorStartUnused = 0x7F000000,\n    /* Vendor specific structures should be in the range of 0x7F000000\n       to 0x7FFFFFFE.  This range is not broken out by vendor, so\n       private indexes are not guaranteed unique and therefore should\n       only be sent to the appropriate component. */\n\n    /* used for ilcs-top communication */\n    OMX_IndexParamMarkComparison,           /**< reference: OMX_PARAM_MARKCOMPARISONTYPE */\n    OMX_IndexParamPortSummary,              /**< reference: OMX_PARAM_PORTSUMMARYTYPE */\n    OMX_IndexParamTunnelStatus,             /**< reference : OMX_PARAM_TUNNELSTATUSTYPE */\n    OMX_IndexParamBrcmRecursionUnsafe,      /**< reference: OMX_PARAM_BRCMRECURSIONUNSAFETYPE */\n\n    /* used for top-ril communication */\n    OMX_IndexParamBufferAddress,            /**< reference : OMX_PARAM_BUFFERADDRESSTYPE */\n    OMX_IndexParamTunnelSetup,              /**< reference : OMX_PARAM_TUNNELSETUPTYPE */\n    OMX_IndexParamBrcmPortEGL,              /**< reference : OMX_PARAM_BRCMPORTEGLTYPE */\n    OMX_IndexParamIdleResourceCount,        /**< reference : OMX_PARAM_U32TYPE */\n\n    /* used for ril-ril communication */\n    OMX_IndexParamImagePoolDisplayFunction, /**<reference : OMX_PARAM_IMAGEDISPLAYFUNCTIONTYPE */\n    OMX_IndexParamBrcmDataUnit,             /**<reference: OMX_PARAM_DATAUNITTYPE */\n    OMX_IndexParamCodecConfig,              /**<reference: OMX_PARAM_CODECCONFIGTYPE */\n    OMX_IndexParamCameraPoolToEncoderFunction, /**<reference : OMX_PARAM_CAMERAPOOLTOENCODERFUNCTIONTYPE */\n    OMX_IndexParamCameraStripeFunction,     /**<reference : OMX_PARAM_CAMERASTRIPEFUNCTIONTYPE */\n    OMX_IndexParamCameraCaptureEventFunction, /**<reference : OMX_PARAM_CAMERACAPTUREEVENTFUNCTIONTYPE */\n\n    /* used for client-ril communication */\n    OMX_IndexParamTestInterface,            /**< reference : OMX_PARAM_TESTINTERFACETYPE */\n\n    // 0x7f000010\n    OMX_IndexConfigDisplayRegion,           /**< reference : OMX_CONFIG_DISPLAYREGIONTYPE */\n    OMX_IndexParamSource,                   /**< reference : OMX_PARAM_SOURCETYPE */\n    OMX_IndexParamSourceSeed,               /**< reference : OMX_PARAM_SOURCESEEDTYPE */\n    OMX_IndexParamResize,                   /**< reference : OMX_PARAM_RESIZETYPE */\n    OMX_IndexConfigVisualisation,           /**< reference : OMX_CONFIG_VISUALISATIONTYPE */\n    OMX_IndexConfigSingleStep,              /**<reference : OMX_PARAM_U32TYPE */\n    OMX_IndexConfigPlayMode,                /**<reference: OMX_CONFIG_PLAYMODETYPE */\n    OMX_IndexParamCameraCamplusId,          /**<reference : OMX_PARAM_U32TYPE */\n    OMX_IndexConfigCommonImageFilterParameters,  /**<reference : OMX_CONFIG_IMAGEFILTERPARAMSTYPE */\n    OMX_IndexConfigTransitionControl,       /**<reference : OMX_CONFIG_TRANSITIONCONTROLTYPE */\n    OMX_IndexConfigPresentationOffset,      /**<reference: OMX_TIME_CONFIG_TIMESTAMPTYPE */\n    OMX_IndexParamSourceFunctions,          /**<reference: OMX_PARAM_STILLSFUNCTIONTYPE */\n    OMX_IndexConfigAudioMonoTrackControl,   /**<reference : OMX_CONFIG_AUDIOMONOTRACKCONTROLTYPE */\n    OMX_IndexParamCameraImagePool,          /**<reference : OMX_PARAM_CAMERAIMAGEPOOLTYPE */\n    OMX_IndexConfigCameraISPOutputPoolHeight,/**<reference : OMX_PARAM_U32TYPE */\n    OMX_IndexParamImagePoolSize,            /**<reference: OMX_PARAM_IMAGEPOOLSIZETYPE */\n\n    // 0x7f000020\n    OMX_IndexParamImagePoolExternal,        /**<reference: OMX_PARAM_IMAGEPOOLEXTERNALTYPE */\n    OMX_IndexParamRUTILFifoInfo,            /**<reference: OMX_PARAM_RUTILFIFOINFOTYPE*/\n    OMX_IndexParamILFifoConfig,             /**<reference: OMX_PARAM_ILFIFOCONFIG */\n    OMX_IndexConfigCameraSensorModes,       /**<reference : OMX_CONFIG_CAMERASENSORMODETYPE */\n    OMX_IndexConfigBrcmPortStats,           /**<reference : OMX_CONFIG_BRCMPORTSTATSTYPE */\n    OMX_IndexConfigBrcmPortBufferStats,     /**<reference : OMX_CONFIG_BRCMPORTBUFFERSTATSTYPE */\n    OMX_IndexConfigBrcmCameraStats,         /**<reference : OMX_CONFIG_BRCMCAMERASTATSTYPE */\n    OMX_IndexConfigBrcmIOPerfStats,         /**<reference : OMX_CONFIG_BRCMIOPERFSTATSTYPE */\n    OMX_IndexConfigCommonSharpness,         /**<reference : OMX_CONFIG_SHARPNESSTYPE */\n    OMX_IndexConfigCommonFlickerCancellation,   /**reference : OMX_CONFIG_FLICKERCANCELTYPE */\n    OMX_IndexParamCameraSwapImagePools,     /**<reference : OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexParamCameraSingleBufferCaptureInput,  /**<reference : OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexConfigCommonRedEyeRemoval,   /**<reference : OMX_CONFIG_REDEYEREMOVALTYPE  */\n    OMX_IndexConfigCommonFaceDetectionControl,  /**<reference : OMX_CONFIG_FACEDETECTIONCONTROLTYPE */\n    OMX_IndexConfigCommonFaceDetectionRegion,   /**<reference : OMX_CONFIG_FACEDETECTIONREGIONTYPE */\n    OMX_IndexConfigCommonInterlace,         /**<reference: OMX_CONFIG_INTERLACETYPE */\n\n    // 0x7f000030\n    OMX_IndexParamISPTunerName,             /**<reference: OMX_PARAM_CAMERAISPTUNERTYPE */\n    OMX_IndexParamCameraDeviceNumber,       /**<reference: OMX_PARAM_U32TYPE */\n    OMX_IndexParamCameraDevicesPresent,     /**<reference: OMX_PARAM_U32TYPE */\n    OMX_IndexConfigCameraInputFrame,        /**<reference: OMX_CONFIG_IMAGEPTRTYPE */\n    OMX_IndexConfigStillColourDenoiseEnable,    /**<reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexConfigVideoColourDenoiseEnable,    /**<reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexConfigAFAssistLight,           /**<reference: OMX_CONFIG_AFASSISTTYPE */\n    OMX_IndexConfigSmartShakeReductionEnable, /**<reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexConfigInputCropPercentages,    /**<reference: OMX_CONFIG_INPUTCROPTYPE */\n    OMX_IndexConfigStillsAntiShakeEnable,   /**<reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexConfigWaitForFocusBeforeCapture,/**<reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexConfigAudioRenderingLatency,   /**<reference: OMX_PARAM_U32TYPE */\n    OMX_IndexConfigDrawBoxAroundFaces,      /**<reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexParamCodecRequirements,        /**<reference: OMX_PARAM_CODECREQUIREMENTSTYPE */\n    OMX_IndexConfigBrcmEGLImageMemHandle,   /**<reference: OMX_CONFIG_BRCMEGLIMAGEMEMHANDLETYPE */\n    OMX_IndexConfigPrivacyIndicator,        /**<reference: OMX_CONFIG_PRIVACYINDICATORTYPE */\n\n    // 0x7f000040\n    OMX_IndexParamCameraFlashType,          /**<reference: OMX_PARAM_CAMERAFLASHTYPE */\n    OMX_IndexConfigCameraEnableStatsPass,   /**<reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexConfigCameraFlashConfig,       /**<reference: OMX_CONFIG_CAMERAFLASHCONFIGTYPE */\n    OMX_IndexConfigCaptureRawImageURI,      /**<reference: OMX_PARAM_CONTENTURITYPE */\n    OMX_IndexConfigCameraStripeFuncMinLines, /**<reference: OMX_PARAM_U32TYPE */\n    OMX_IndexConfigCameraAlgorithmVersionDeprecated,   /**<reference: OMX_PARAM_U32TYPE */\n    OMX_IndexConfigCameraIsoReferenceValue,  /**<reference: OMX_PARAM_U32TYPE */\n    OMX_IndexConfigCameraCaptureAbortsAutoFocus, /**<reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexConfigBrcmClockMissCount,      /**<reference: OMX_PARAM_U32TYPE */\n    OMX_IndexConfigFlashChargeLevel,         /**<reference: OMX_PARAM_U32TYPE */\n    OMX_IndexConfigBrcmVideoEncodedSliceSize, /**<reference: OMX_PARAM_U32TYPE */\n    OMX_IndexConfigBrcmAudioTrackGaplessPlayback,  /**< reference: OMX_CONFIG_BRCMAUDIOTRACKGAPLESSPLAYBACKTYPE */\n    OMX_IndexConfigBrcmAudioTrackChangeControl,    /**< reference: OMX_CONFIG_BRCMAUDIOTRACKCHANGECONTROLTYPE */\n    OMX_IndexParamBrcmPixelAspectRatio,     /**< reference: OMX_CONFIG_POINTTYPE */\n    OMX_IndexParamBrcmPixelValueRange,      /**< reference: OMX_PARAM_BRCMPIXELVALUERANGETYPE */\n    OMX_IndexParamCameraDisableAlgorithm,   /**< reference: OMX_PARAM_CAMERADISABLEALGORITHMTYPE */\n\n    // 0x7f000050\n    OMX_IndexConfigBrcmVideoIntraPeriodTime, /**< reference: OMX_PARAM_U32TYPE */\n    OMX_IndexConfigBrcmVideoIntraPeriod,     /**< reference: OMX_PARAM_U32TYPE */\n    OMX_IndexConfigBrcmAudioEffectControl, /**< reference: OMX_CONFIG_BRCMAUDIOEFFECTCONTROLTYPE */\n    OMX_IndexConfigBrcmMinimumProcessingLatency, /**< reference: OMX_CONFIG_BRCMMINIMUMPROCESSINGLATENCY */\n    OMX_IndexParamBrcmVideoAVCSEIEnable,    /**< reference: OMX_PARAM_BRCMVIDEOAVCSEIENABLETYPE */\n    OMX_IndexParamBrcmAllowMemChange,   /**< reference: OMX_PARAM_BRCMALLOWMEMCHANGETYPE */\n    OMX_IndexConfigBrcmVideoEncoderMBRowsPerSlice, /**< reference: OMX_PARAM_U32TYPE */\n    OMX_IndexParamCameraAFAssistDeviceNumber_Deprecated,   /**< reference: OMX_PARAM_U32TYPE */\n    OMX_IndexParamCameraPrivacyIndicatorDeviceNumber_Deprecated,   /**< reference: OMX_PARAM_U32TYPE */\n    OMX_IndexConfigCameraUseCase,               /**< reference: OMX_CONFIG_CAMERAUSECASETYPE */\n    OMX_IndexParamBrcmDisableProprietaryTunnels,   /**< reference: OMX_PARAM_BRCMDISABLEPROPRIETARYTUNNELSTYPE */\n    OMX_IndexParamBrcmOutputBufferSize,         /**<  reference: OMX_PARAM_BRCMOUTPUTBUFFERSIZETYPE */\n    OMX_IndexParamBrcmRetainMemory,             /**< reference: OMX_PARAM_BRCMRETAINMEMORYTYPE */\n    OMX_IndexConfigCanFocus_Deprecated,                    /**< reference: OMX_PARAM_U32TYPE */\n    OMX_IndexParamBrcmImmutableInput,           /**< reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexParamDynamicParameterFile,        /**< reference: OMX_PARAM_CONTENTURITYPE */\n\n    // 0x7f000060\n    OMX_IndexParamUseDynamicParameterFile,     /**< reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexConfigCameraInfo,                 /**< reference: OMX_CONFIG_CAMERAINFOTYPE */\n    OMX_IndexConfigCameraFeatures,             /**< reference: OMX_CONFIG_CAMERAFEATURESTYPE */\n    OMX_IndexConfigRequestCallback,            /**< reference: OMX_CONFIG_REQUESTCALLBACKTYPE */ //Should be added to the spec as part of IL416c\n    OMX_IndexConfigBrcmOutputBufferFullCount,  /**< reference: OMX_PARAM_U32TYPE */\n    OMX_IndexConfigCommonFocusRegionXY,        /**< reference: OMX_CONFIG_FOCUSREGIONXYTYPE */\n    OMX_IndexParamBrcmDisableEXIF,             /**< reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexConfigUserSettingsId,             /**< reference: OMX_CONFIG_U8TYPE */\n    OMX_IndexConfigCameraSettings,             /**< reference: OMX_CONFIG_CAMERASETTINGSTYPE */\n    OMX_IndexConfigDrawBoxLineParams,          /**< reference: OMX_CONFIG_DRAWBOXLINEPARAMS */\n    OMX_IndexParamCameraRmiControl_Deprecated,            /**< reference: OMX_PARAM_CAMERARMITYPE */\n    OMX_IndexConfigBurstCapture,               /**< reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexParamBrcmEnableIJGTableScaling,   /**< reference: OMX_PARAM_IJGSCALINGTYPE */\n    OMX_IndexConfigPowerDown,                  /**< reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexConfigBrcmSyncOutput,             /**< reference: OMX_CONFIG_BRCMSYNCOUTPUTTYPE */\n    OMX_IndexParamBrcmFlushCallback,           /**< reference: OMX_PARAM_BRCMFLUSHCALLBACK */\n\n    // 0x7f000070\n    OMX_IndexConfigBrcmVideoRequestIFrame,     /**< reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexParamBrcmNALSSeparate,            /**< reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexConfigConfirmView,                /**< reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexConfigDrmView,                    /**< reference: OMX_CONFIG_DRMVIEWTYPE */\n    OMX_IndexConfigBrcmVideoIntraRefresh,      /**< reference: OMX_VIDEO_PARAM_INTRAREFRESHTYPE */\n    OMX_IndexParamBrcmMaxFileSize,             /**< reference: OMX_PARAM_BRCMU64TYPE */\n    OMX_IndexParamBrcmCRCEnable,               /**< reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexParamBrcmCRC,                     /**< reference: OMX_PARAM_U32TYPE */\n    OMX_IndexConfigCameraRmiInUse_Deprecated,             /**< reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexConfigBrcmAudioSource,            /**<reference: OMX_CONFIG_BRCMAUDIOSOURCETYPE */\n    OMX_IndexConfigBrcmAudioDestination,       /**< reference: OMX_CONFIG_BRCMAUDIODESTINATIONTYPE */\n    OMX_IndexParamAudioDdp,                    /**< reference: OMX_AUDIO_PARAM_DDPTYPE */\n    OMX_IndexParamBrcmThumbnail,               /**< reference: OMX_PARAM_BRCMTHUMBNAILTYPE */\n    OMX_IndexParamBrcmDisableLegacyBlocks_Deprecated,     /**< reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexParamBrcmCameraInputAspectRatio,  /**< reference: OMX_PARAM_BRCMASPECTRATIOTYPE */\n    OMX_IndexParamDynamicParameterFileFailFatal,/**< reference: OMX_CONFIG_BOOLEANTYPE */\n\n    // 0x7f000080\n    OMX_IndexParamBrcmVideoDecodeErrorConcealment, /**< reference: OMX_PARAM_BRCMVIDEODECODEERRORCONCEALMENTTYPE */\n    OMX_IndexParamBrcmInterpolateMissingTimestamps, /**< reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexParamBrcmSetCodecPerformanceMonitoring, /**< reference: OMX_PARAM_U32TYPE */\n    OMX_IndexConfigFlashInfo,                  /**< reference: OMX_CONFIG_FLASHINFOTYPE */\n    OMX_IndexParamBrcmMaxFrameSkips,           /**< reference: OMX_PARAM_U32TYPE */\n    OMX_IndexConfigDynamicRangeExpansion,      /**< reference: OMX_CONFIG_DYNAMICRANGEEXPANSIONTYPE */\n    OMX_IndexParamBrcmFlushCallbackId,         /**< reference: OMX_PARAM_U32TYPE */\n    OMX_IndexParamBrcmTransposeBufferCount,    /**< reference: OMX_PARAM_U32TYPE */\n    OMX_IndexConfigFaceRecognitionControl,     /**< reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexConfigFaceRecognitionSaveFace,    /**< reference: OMX_PARAM_BRCMU64TYPE */\n    OMX_IndexConfigFaceRecognitionDatabaseUri, /**< reference: OMX_PARAM_CONTENTURITYPE */\n    OMX_IndexConfigClockAdjustment,            /**< reference: OMX_TIME_CONFIG_TIMESTAMPTYPE */\n    OMX_IndexParamBrcmThreadAffinity,          /**< reference: OMX_PARAM_BRCMTHREADAFFINITYTYPE */\n    OMX_IndexParamAsynchronousOutput,          /**< reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexConfigAsynchronousFailureURI,     /**< reference: OMX_PARAM_CONTENTURITYPE */\n    OMX_IndexConfigCommonFaceBeautification,   /**< reference: OMX_CONFIG_BOOLEANTYPE */\n\n    // 0x7f000090\n    OMX_IndexConfigCommonSceneDetectionControl,/**< reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexConfigCommonSceneDetected,        /**< reference: OMX_CONFIG_SCENEDETECTTYPE */\n    OMX_IndexParamDisableVllPool,              /**< reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexParamVideoMvc,                    /**< reference: OMX_VIDEO_PARAM_MVCTYPE */\n    OMX_IndexConfigBrcmDrawStaticBox,          /**< reference: OMX_CONFIG_STATICBOXTYPE */\n    OMX_IndexConfigBrcmClockReferenceSource,   /**< reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexParamPassBufferMarks,             /**< reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexConfigPortCapturing,              /**< reference: OMX_CONFIG_PORTBOOLEANTYPE */\n    OMX_IndexConfigBrcmDecoderPassThrough,     /**< reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexParamBrcmDecoderPassThrough=OMX_IndexConfigBrcmDecoderPassThrough,  /* deprecated */\n    OMX_IndexParamBrcmMaxCorruptMBs,           /**< reference: OMX_PARAM_U32TYPE */\n    OMX_IndexConfigBrcmGlobalAudioMute,        /**< reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexParamCameraCaptureMode,           /**< reference: OMX_PARAM_CAMERACAPTUREMODETYPE */\n    OMX_IndexParamBrcmDrmEncryption,           /**< reference: OMX_PARAM_BRCMDRMENCRYPTIONTYPE */\n    OMX_IndexConfigBrcmCameraRnDPreprocess,    /**< reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexConfigBrcmCameraRnDPostprocess,   /**< reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexConfigBrcmAudioTrackChangeCount,  /**< reference: OMX_PARAM_U32TYPE */\n\n    // 0x7f0000a0\n    OMX_IndexParamCommonUseStcTimestamps,      /**< reference: OMX_PARAM_TIMESTAMPMODETYPE */\n    OMX_IndexConfigBufferStall,                /**< reference: OMX_CONFIG_BUFFERSTALLTYPE */\n    OMX_IndexConfigRefreshCodec,               /**< reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexParamCaptureStatus,               /**< reference: OMX_PARAM_CAPTURESTATETYPE */\n    OMX_IndexConfigTimeInvalidStartTime,       /**< reference: OMX_TIME_CONFIG_TIMESTAMPTYPE */\n    OMX_IndexConfigLatencyTarget,              /**< reference: OMX_CONFIG_LATENCYTARGETTYPE */\n    OMX_IndexConfigMinimiseFragmentation,      /**< reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexConfigBrcmUseProprietaryCallback, /**< reference: OMX_CONFIG_BRCMUSEPROPRIETARYTUNNELTYPE */\n    OMX_IndexParamPortMaxFrameSize,            /**< reference: OMX_FRAMESIZETYPE */\n    OMX_IndexParamComponentName,               /**< reference: OMX_PARAM_COMPONENTROLETYPE */\n    OMX_IndexConfigEncLevelExtension,          /**< reference: OMX_VIDEO_CONFIG_LEVEL_EXTEND */\n    OMX_IndexConfigTemporalDenoiseEnable,      /**< reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexParamBrcmLazyImagePoolDestroy,    /**< reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexParamBrcmEEDEEnable,              /**< reference: OMX_VIDEO_EEDE_ENABLE */\n    OMX_IndexParamBrcmEEDELossRate,            /**< reference: OMX_VIDEO_EEDE_LOSSRATE */\n    OMX_IndexParamAudioDts,                    /**< reference: OMX_AUDIO_PARAM_DTSTYPE */\n\n    // 0x7f0000b0\n    OMX_IndexParamNumOutputChannels,           /**< reference: OMX_PARAM_U32TYPE */\n    OMX_IndexConfigBrcmHighDynamicRange,       /**< reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexConfigBrcmPoolMemAllocSize,       /**< reference: OMX_PARAM_U32TYPE */\n    OMX_IndexConfigBrcmBufferFlagFilter,       /**< reference: OMX_PARAM_U32TYPE */\n    OMX_IndexParamBrcmVideoEncodeMinQuant,     /**< reference: OMX_PARAM_U32TYPE */\n    OMX_IndexParamBrcmVideoEncodeMaxQuant,     /**< reference: OMX_PARAM_U32TYPE */\n    OMX_IndexParamRateControlModel,            /**< reference: OMX_PARAM_U32TYPE */\n    OMX_IndexParamBrcmExtraBuffers,            /**< reference: OMX_PARAM_U32TYPE */\n    OMX_IndexConfigFieldOfView,                /**< reference: OMX_CONFIG_BRCMFOVTYPE */\n    OMX_IndexParamBrcmAlignHoriz,              /**< reference: OMX_PARAM_U32TYPE */\n    OMX_IndexParamBrcmAlignVert,               /**< reference: OMX_PARAM_U32TYPE */\n    OMX_IndexParamColorSpace,                  /**< reference: OMX_PARAM_COLORSPACETYPE */\n    OMX_IndexParamBrcmDroppablePFrames,        /**< reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexParamBrcmVideoInitialQuant,       /**< reference: OMX_PARAM_U32TYPE */\n    OMX_IndexParamBrcmVideoEncodeQpP,          /**< reference: OMX_PARAM_U32TYPE */\n    OMX_IndexParamBrcmVideoRCSliceDQuant,      /**< reference: OMX_PARAM_U32TYPE */\n\n    // 0x7f0000c0\n    OMX_IndexParamBrcmVideoFrameLimitBits,     /**< reference: OMX_PARAM_U32TYPE */\n    OMX_IndexParamBrcmVideoPeakRate,           /**< reference: OMX_PARAM_U32TYPE */\n    OMX_IndexConfigBrcmVideoH264DisableCABAC,  /**< reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexConfigBrcmVideoH264LowLatency,    /**< reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexConfigBrcmVideoH264AUDelimiters,  /**< reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexConfigBrcmVideoH264DeblockIDC,    /**< reference: OMX_PARAM_U32TYPE */\n    OMX_IndexConfigBrcmVideoH264IntraMBMode,   /**< reference: OMX_PARAM_U32TYPE */\n    OMX_IndexConfigContrastEnhance,            /**< reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexParamCameraCustomSensorConfig,    /**< reference: OMX_PARAM_U32TYPE */\n    OMX_IndexParamBrcmHeaderOnOpen,            /**< reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexConfigBrcmUseRegisterFile,        /**< reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexConfigBrcmRegisterFileFailFatal,  /**< reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexParamBrcmConfigFileRegisters,     /**< reference: OMX_PARAM_BRCMCONFIGFILETYPE */\n    OMX_IndexParamBrcmConfigFileChunkRegisters,/**< reference: OMX_PARAM_BRCMCONFIGFILECHUNKTYPE */\n    OMX_IndexParamBrcmAttachLog,               /**< reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexParamCameraZeroShutterLag,        /**< reference: OMX_CONFIG_ZEROSHUTTERLAGTYPE */\n\n    // 0x7f0000d0\n    OMX_IndexParamBrcmFpsRange,                /**< reference: OMX_PARAM_BRCMFRAMERATERANGETYPE */\n    OMX_IndexParamCaptureExposureCompensation, /**< reference: OMX_PARAM_S32TYPE */\n    OMX_IndexParamBrcmVideoPrecodeForQP,       /**< reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexParamBrcmVideoTimestampFifo,      /**< reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexParamSWSharpenDisable,            /**< reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexConfigBrcmFlashRequired,          /**< reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexParamBrcmVideoDrmProtectBuffer,   /**< reference: OMX_PARAM_BRCMVIDEODRMPROTECTBUFFERTYPE */\n    OMX_IndexParamSWSaturationDisable,         /**< reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexParamBrcmVideoDecodeConfigVD3,    /**< reference: OMX_PARAM_BRCMVIDEODECODECONFIGVD3TYPE */\n    OMX_IndexConfigBrcmPowerMonitor,           /**< reference: OMX_CONFIG_BOOLEANTYPE */\n    OMX_IndexParamBrcmZeroCopy,                /**< reference: OMX_CONFIG_PORTBOOLEANTYPE */\n    OMX_IndexParamBrcmVideoEGLRenderDiscardMode,   /**< reference: OMX_CONFIG_PORTBOOLEANTYPE */\n    OMX_IndexParamBrcmVideoAVC_VCLHRDEnable,    /**< reference: OMX_CONFIG_PORTBOOLEANTYPE*/\n    OMX_IndexParamBrcmVideoAVC_LowDelayHRDEnable, /**< reference: OMX_CONFIG_PORTBOOLEANTYPE*/\n    OMX_IndexParamBrcmVideoCroppingDisable,    /**< reference: OMX_CONFIG_PORTBOOLEANTYPE*/\n    OMX_IndexParamBrcmVideoAVCInlineHeaderEnable, /**< reference: OMX_CONFIG_PORTBOOLEANTYPE*/\n\n    // 0x7f0000f0\n    OMX_IndexConfigBrcmAudioDownmixCoefficients = 0x7f0000f0, /**< reference: OMX_CONFIG_BRCMAUDIODOWNMIXCOEFFICIENTS */\n    OMX_IndexConfigBrcmAudioDownmixCoefficients8x8,           /**< reference: OMX_CONFIG_BRCMAUDIODOWNMIXCOEFFICIENTS8x8 */\n    OMX_IndexConfigBrcmAudioMaxSample,                        /**< reference: OMX_CONFIG_BRCMAUDIOMAXSAMPLE */\n    OMX_IndexConfigCustomAwbGains,                            /**< reference: OMX_CONFIG_CUSTOMAWBGAINSTYPE */\n    OMX_IndexParamRemoveImagePadding,                         /**< reference: OMX_CONFIG_PORTBOOLEANTYPE*/\n    OMX_IndexParamBrcmVideoAVCInlineVectorsEnable,            /**< reference: OMX_CONFIG_PORTBOOLEANTYPE */\n    OMX_IndexConfigBrcmRenderStats,                           /**< reference: OMX_CONFIG_BRCMRENDERSTATSTYPE */\n    OMX_IndexConfigBrcmCameraAnnotate,                        /**< reference: OMX_CONFIG_BRCMANNOTATETYPE */\n    OMX_IndexParamBrcmStereoscopicMode,                       /**< reference :OMX_CONFIG_BRCMSTEREOSCOPICMODETYPE */\n    OMX_IndexParamBrcmLockStepEnable,                         /**< reference: OMX_CONFIG_PORTBOOLEANTYPE */\n    OMX_IndexParamBrcmTimeScale,                              /**< reference: OMX_PARAM_U32TYPE */\n    OMX_IndexParamCameraInterface,                            /**< reference: OMX_PARAM_CAMERAINTERFACETYPE */\n    OMX_IndexParamCameraClockingMode,                         /**< reference: OMX_PARAM_CAMERACLOCKINGMODETYPE */\n    OMX_IndexParamCameraRxConfig,                             /**< reference: OMX_PARAM_CAMERARXCONFIG_TYPE */\n    OMX_IndexParamCameraRxTiming,                             /**< reference: OMX_PARAM_CAMERARXTIMING_TYPE */\n    OMX_IndexParamDynamicParameterConfig,                     /**< reference: OMX_PARAM_U32TYPE */\n    OMX_IndexParamBrcmVideoAVCSPSTimingEnable,                /** reference: OMX_CONFIG_PORTBOOLEANTYPE */\n    OMX_IndexParamBrcmBayerOrder,                             /** reference: OMX_PARAM_BAYERORDERTYPE */\n    OMX_IndexParamBrcmMaxNumCallbacks,                        /**< reference: OMX_PARAM_U32TYPE */\n    OMX_IndexParamBrcmJpegRestartInterval,                    /**< reference: OMX_PARAM_U32TYPE */\n    OMX_IndexParamBrcmSupportsSlices,                         /**< reference: OMX_CONFIG_PORT_BOOLEANTYPE */\n    OMX_IndexMax = 0x7FFFFFFF\n} OMX_INDEXTYPE;\n\n#ifdef __cplusplus\n}\n#endif /* __cplusplus */\n\n#endif\n/* File EOF */\n\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vmcs_host/khronos/IL/OMX_Other.h",
    "content": "/*\n * Copyright (c) 2008 The Khronos Group Inc. \n * \n * Permission is hereby granted, free of charge, to any person obtaining\n * a copy of this software and associated documentation files (the\n * \"Software\"), to deal in the Software without restriction, including\n * without limitation the rights to use, copy, modify, merge, publish,\n * distribute, sublicense, and/or sell copies of the Software, and to\n * permit persons to whom the Software is furnished to do so, subject\n * to the following conditions: \n * The above copyright notice and this permission notice shall be included\n * in all copies or substantial portions of the Software. \n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\n * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\n * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\n * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \n *\n */\n\n/** @file OMX_Other.h - OpenMax IL version 1.1.2\n *  The structures needed by Other components to exchange\n *  parameters and configuration data with the components.\n */\n\n#ifndef OMX_Other_h\n#define OMX_Other_h\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif /* __cplusplus */\n\n\n/* Each OMX header must include all required header files to allow the\n *  header to compile without errors.  The includes below are required\n *  for this header file to compile successfully \n */\n\n#include \"OMX_Core.h\"\n\n\n/** \n * Enumeration of possible data types which match to multiple domains or no\n * domain at all.  For types which are vendor specific, a value above\n * OMX_OTHER_VENDORTSTART should be used.\n */\ntypedef enum OMX_OTHER_FORMATTYPE {\n    OMX_OTHER_FormatTime = 0, /**< Transmission of various timestamps, elapsed time, \n                                   time deltas, etc */\n    OMX_OTHER_FormatPower,    /**< Perhaps used for enabling/disabling power \n                                   management, setting clocks? */\n    OMX_OTHER_FormatStats,    /**< Could be things such as frame rate, frames \n                                   dropped, etc */\n    OMX_OTHER_FormatBinary,   /**< Arbitrary binary data */\n    OMX_OTHER_FormatVendorReserved = 1000, /**< Starting value for vendor specific \n                                                formats */\n\n    OMX_OTHER_FormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_OTHER_FormatVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n\n    OMX_OTHER_FormatText,\n    OMX_OTHER_FormatTextSKM2,\n    OMX_OTHER_FormatText3GP5,\n\n    OMX_OTHER_FormatMax = 0x7FFFFFFF\n} OMX_OTHER_FORMATTYPE;\n\n/** \n * Enumeration of seek modes.\n */\ntypedef enum OMX_TIME_SEEKMODETYPE {\n    OMX_TIME_SeekModeFast = 0, /**< Prefer seeking to an approximation\n                                * of the requested seek position over   \n                                * the actual seek position if it\n                                * results in a faster seek. */\n    OMX_TIME_SeekModeAccurate, /**< Prefer seeking to the actual seek \n                                * position over an approximation\n                                * of the requested seek position even\n                                * if it results in a slower seek. */\n    OMX_TIME_SeekModeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_TIME_SeekModeVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n\n    OMX_TIME_SeekModeDirectional, /**< Similar to Fast, but if seeking backwards will\n                                   * try and seek to a previous sync position from the\n                                   * current media time. */\n\n    OMX_TIME_SeekModeMax = 0x7FFFFFFF\n} OMX_TIME_SEEKMODETYPE;\n\n/* Structure representing the seekmode of the component */\ntypedef struct OMX_TIME_CONFIG_SEEKMODETYPE {\n    OMX_U32 nSize;                  /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion;       /**< OMX specification version information */\n    OMX_TIME_SEEKMODETYPE eType;    /**< The seek mode */\n} OMX_TIME_CONFIG_SEEKMODETYPE;\n\n/** Structure representing a time stamp used with the following configs \n * on the Clock Component (CC):\n * \n * OMX_IndexConfigTimeCurrentWallTime: query of the CCs current wall  \n *     time\n * OMX_IndexConfigTimeCurrentMediaTime: query of the CCs current media\n *     time\n * OMX_IndexConfigTimeCurrentAudioReference and  \n * OMX_IndexConfigTimeCurrentVideoReference: audio/video reference \n *     clock sending SC its reference time\n * OMX_IndexConfigTimeClientStartTime: a Clock Component client sends \n *     this structure to the Clock Component via a SetConfig on its \n *     client port when it receives a buffer with\n *     OMX_BUFFERFLAG_STARTTIME set. It must use the timestamp\n *     specified by that buffer for nStartTimestamp. \n *\n * Its also used with the following config on components in general:\n *\n * OMX_IndexConfigTimePosition: IL client querying component position \n * (GetConfig) or commanding a component to seek to the given location\n * (SetConfig)\n */\t\ntypedef struct OMX_TIME_CONFIG_TIMESTAMPTYPE {\n    OMX_U32 nSize;               /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion;    /**< OMX specification version\n                                  *   information */\n    OMX_U32 nPortIndex;     /**< port that this structure applies to */\n    OMX_TICKS nTimestamp;  \t     /**< timestamp .*/ \n} OMX_TIME_CONFIG_TIMESTAMPTYPE;  \n\n/** Enumeration of possible reference clocks to the media time. */\ntypedef enum OMX_TIME_UPDATETYPE {\n      OMX_TIME_UpdateRequestFulfillment,    /**< Update is the fulfillment of a media time request. */\n      OMX_TIME_UpdateScaleChanged,\t        /**< Update was generated because the scale chagned. */\n      OMX_TIME_UpdateClockStateChanged,     /**< Update was generated because the clock state changed. */\n      OMX_TIME_UpdateKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n      OMX_TIME_UpdateVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n      OMX_TIME_UpdateMax = 0x7FFFFFFF\n} OMX_TIME_UPDATETYPE;\n\n/** Enumeration of possible reference clocks to the media time. */\ntypedef enum OMX_TIME_REFCLOCKTYPE {\n      OMX_TIME_RefClockNone,    /**< Use no references. */\n      OMX_TIME_RefClockAudio,\t/**< Use references sent through OMX_IndexConfigTimeCurrentAudioReference */\n      OMX_TIME_RefClockVideo,   /**< Use references sent through OMX_IndexConfigTimeCurrentVideoReference */\n      OMX_TIME_RefClockKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n      OMX_TIME_RefClockVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n      OMX_TIME_RefClockMax = 0x7FFFFFFF\n} OMX_TIME_REFCLOCKTYPE;\n\n/** Enumeration of clock states. */\ntypedef enum OMX_TIME_CLOCKSTATE {\n      OMX_TIME_ClockStateRunning,             /**< Clock running. */\n      OMX_TIME_ClockStateWaitingForStartTime, /**< Clock waiting until the \n                                               *   prescribed clients emit their\n                                               *   start time. */\n      OMX_TIME_ClockStateStopped,             /**< Clock stopped. */\n      OMX_TIME_ClockStateKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n      OMX_TIME_ClockStateVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n      OMX_TIME_ClockStateMax = 0x7FFFFFFF\n} OMX_TIME_CLOCKSTATE;\n\n/** Structure representing a media time request to the clock component.\n *\n *  A client component sends this structure to the Clock Component via a SetConfig\n *  on its client port to specify a media timestamp the Clock Component\n *  should emit.  The Clock Component should fulfill the request by sending a\n *  OMX_TIME_MEDIATIMETYPE when its media clock matches the requested \n *  timestamp.\n *\n *  The client may require a media time request be fulfilled slightly\n *  earlier than the media time specified. In this case the client specifies \n *  an offset which is equal to the difference between wall time corresponding \n *  to the requested media time and the wall time when it will be \n *  fulfilled. \n *\n *  A client component may uses these requests and the OMX_TIME_MEDIATIMETYPE to\n *  time events according to timestamps. If a client must perform an operation O at\n *  a time T (e.g. deliver a video frame at its corresponding timestamp), it makes a \n *  media time request at T (perhaps specifying an offset to ensure the request fulfillment\n *  is a little early). When the clock component passes the resulting OMX_TIME_MEDIATIMETYPE\n *  structure back to the client component, the client may perform operation O (perhaps having\n *  to wait a slight amount more time itself as specified by the return values).\n */\n\ntypedef struct OMX_TIME_CONFIG_MEDIATIMEREQUESTTYPE {\n    OMX_U32 nSize;              /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion;   /**< OMX specification version information */\n    OMX_U32 nPortIndex;         /**< port that this structure applies to */\n    OMX_PTR pClientPrivate;     /**< Client private data to disabiguate this media time \n                                 *   from others (e.g. the number of the frame to deliver). \n                                 *   Duplicated in the media time structure that fulfills \n                                 *   this request. A value of zero is reserved for time scale \n                                 *   updates. */\n    OMX_TICKS nMediaTimestamp;  /**< Media timestamp requested.*/ \n    OMX_TICKS nOffset;          /**< Amount of wall clock time by which this\n                                 *   request should be fulfilled early */\n} OMX_TIME_CONFIG_MEDIATIMEREQUESTTYPE;\n\n/**< Structure sent from the clock component client either when fulfilling \n *   a media time request or when the time scale has changed. \n *\n *   In the former case the Clock Component fills this structure and times its emission \n *   to a client component (via the client port) according to the corresponding media \n *   time request sent by the client. The Clock Component should time the emission to occur\n *   when the requested timestamp matches the Clock Component's media time but also the \n *   prescribed offset early. \n *\n *   Upon scale changes the clock component clears the nClientPrivate data, sends the current\n *   media time and sets the nScale to the new scale via the client port. It emits a \n *   OMX_TIME_MEDIATIMETYPE to all clients independent of any requests. This allows clients to \n *   alter processing to accomodate scaling. For instance a video component might skip inter-frames \n *   in the case of extreme fastforward. Likewise an audio component might add or remove samples \n *   from an audio frame to scale audio data. \n *\n *   It is expected that some clock components may not be able to fulfill requests\n *   at exactly the prescribed time. This is acceptable so long as the request is \n *   fulfilled at least as early as described and not later. This structure provides \n *   fields the client may use to wait for the remaining time.\n *\n *   The client may use either the nOffset or nWallTimeAtMedia fields to determine the \n *   wall time until the nMediaTimestamp actually occurs. In the latter case the\n *   client can get a more accurate value for offset by getting the current wall\n *   from the cloc component and subtracting it from nWallTimeAtMedia. \n */\n\ntypedef struct OMX_TIME_MEDIATIMETYPE {\n    OMX_U32 nSize;                  /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion;       /**< OMX specification version information */\n    OMX_U32 nClientPrivate;         /**< Client private data to disabiguate this media time \n                                     *   from others. Copied from the media time request. \n                                     *   A value of zero is reserved for time scale updates. */\n    OMX_TIME_UPDATETYPE eUpdateType; /**< Reason for the update */\n    OMX_TICKS nMediaTimestamp;      /**< Media time requested. If no media time was \n                                     *   requested then this is the current media time. */ \n    OMX_TICKS nOffset;              /**< Amount of wall clock time by which this\n                                     *   request was actually fulfilled early */\n\n    OMX_TICKS nWallTimeAtMediaTime; /**< Wall time corresponding to nMediaTimeStamp.\n                                     *   A client may compare this value to current\n                                     *   media time obtained from the Clock Component to determine\n                                     *   the wall time until the media timestamp is really\n                                     *   current. */\n    OMX_S32 xScale;                 /**< Current media time scale in Q16 format. */\n    OMX_TIME_CLOCKSTATE eState;     /* Seeking Change. Added 7/12.*/\n                                    /**< State of the media time. */\n} OMX_TIME_MEDIATIMETYPE;  \n\n/** Structure representing the current media time scale factor. Applicable only to clock \n *  component, other components see scale changes via OMX_TIME_MEDIATIMETYPE buffers sent via\n *  the clock component client ports. Upon recieving this config the clock component changes \n *  the rate by which the media time increases or decreases effectively implementing trick modes. \n */ \ntypedef struct OMX_TIME_CONFIG_SCALETYPE {\n    OMX_U32 nSize;                  /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion;       /**< OMX specification version information */\n    OMX_S32 xScale;                 /**< This is a value in Q16 format which is used for\n                                     * scaling the media time */\n} OMX_TIME_CONFIG_SCALETYPE;\n \n/** Bits used to identify a clock port. Used in OMX_TIME_CONFIG_CLOCKSTATETYPEs nWaitMask field */\n#define OMX_CLOCKPORT0 0x00000001\n#define OMX_CLOCKPORT1 0x00000002\n#define OMX_CLOCKPORT2 0x00000004\n#define OMX_CLOCKPORT3 0x00000008\n#define OMX_CLOCKPORT4 0x00000010\n#define OMX_CLOCKPORT5 0x00000020\n#define OMX_CLOCKPORT6 0x00000040\n#define OMX_CLOCKPORT7 0x00000080\n\n/** Structure representing the current mode of the media clock. \n *  IL Client uses this config to change or query the mode of the \n *  media clock of the clock component. Applicable only to clock\n *  component. \n *  \n *  On a SetConfig if eState is OMX_TIME_ClockStateRunning media time\n *  starts immediately at the prescribed start time. If\n *  OMX_TIME_ClockStateWaitingForStartTime the Clock Component ignores\n *  the given nStartTime and waits for all clients specified in the \n *  nWaitMask to send starttimes (via \n *  OMX_IndexConfigTimeClientStartTime). The Clock Component then starts \n *  the media clock using the earliest start time supplied. */    \ntypedef struct OMX_TIME_CONFIG_CLOCKSTATETYPE {\n    OMX_U32 nSize;              /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion;   /**< OMX specification version \n                                 *   information */\n    OMX_TIME_CLOCKSTATE eState; /**< State of the media time. */\n    OMX_TICKS nStartTime;       /**< Start time of the media time. */\n    OMX_TICKS nOffset;          /**< Time to offset the media time by \n                                 * (e.g. preroll). Media time will be\n                                 * reported to be nOffset ticks earlier.     \n                                 */\n    OMX_U32 nWaitMask;          /**< Mask of OMX_CLOCKPORT values. */\n} OMX_TIME_CONFIG_CLOCKSTATETYPE;\n\n/** Structure representing the reference clock currently being used to\n *  compute media time. IL client uses this config to change or query the \n *  clock component's active reference clock */\ntypedef struct OMX_TIME_CONFIG_ACTIVEREFCLOCKTYPE {\n    OMX_U32 nSize;                  /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion;       /**< OMX specification version information */\n    OMX_TIME_REFCLOCKTYPE eClock;   /**< Reference clock used to compute media time */                        \n} OMX_TIME_CONFIG_ACTIVEREFCLOCKTYPE;\n\n/** Descriptor for setting specifics of power type.\n *  Note: this structure is listed for backwards compatibility. */\ntypedef struct OMX_OTHER_CONFIG_POWERTYPE {\n    OMX_U32 nSize;            /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion; /**< OMX specification version information */\n    OMX_BOOL bEnablePM;       /**< Flag to enable Power Management */\n} OMX_OTHER_CONFIG_POWERTYPE;\n\n\n/** Descriptor for setting specifics of stats type.\n *  Note: this structure is listed for backwards compatibility. */\ntypedef struct OMX_OTHER_CONFIG_STATSTYPE {\n    OMX_U32 nSize;            /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion; /**< OMX specification version information */\n    /* what goes here */\n} OMX_OTHER_CONFIG_STATSTYPE;\n\n\n/**\n * The PortDefinition structure is used to define all of the parameters \n * necessary for the compliant component to setup an input or an output other \n * path.\n */\ntypedef struct OMX_OTHER_PORTDEFINITIONTYPE {\n    OMX_OTHER_FORMATTYPE eFormat;  /**< Type of data expected for this channel */\n} OMX_OTHER_PORTDEFINITIONTYPE;\n\n/**  Port format parameter.  This structure is used to enumerate\n  *  the various data input/output format supported by the port.\n  */\ntypedef struct OMX_OTHER_PARAM_PORTFORMATTYPE {\n    OMX_U32 nSize; /**< size of the structure in bytes */\n    OMX_VERSIONTYPE nVersion; /**< OMX specification version information */\n    OMX_U32 nPortIndex; /**< Indicates which port to set */\n    OMX_U32 nIndex; /**< Indicates the enumeration index for the format from 0x0 to N-1 */\n    OMX_OTHER_FORMATTYPE eFormat; /**< Type of data expected for this channel */\n} OMX_OTHER_PARAM_PORTFORMATTYPE; \n\n#ifdef __cplusplus\n}\n#endif /* __cplusplus */\n\n#endif\n/* File EOF */\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vmcs_host/khronos/IL/OMX_Types.h",
    "content": "/*\n * Copyright (c) 2008 The Khronos Group Inc. \n * \n * Permission is hereby granted, free of charge, to any person obtaining\n * a copy of this software and associated documentation files (the\n * \"Software\"), to deal in the Software without restriction, including\n * without limitation the rights to use, copy, modify, merge, publish,\n * distribute, sublicense, and/or sell copies of the Software, and to\n * permit persons to whom the Software is furnished to do so, subject\n * to the following conditions: \n * The above copyright notice and this permission notice shall be included\n * in all copies or substantial portions of the Software. \n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\n * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\n * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\n * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \n *\n */\n\n/** OMX_Types.h - OpenMax IL version 1.1.2\n *  The OMX_Types header file contains the primitive type definitions used by \n *  the core, the application and the component.  This file may need to be\n *  modified to be used on systems that do not have \"char\" set to 8 bits, \n *  \"short\" set to 16 bits and \"long\" set to 32 bits.\n */\n\n#ifndef OMX_Types_h\n#define OMX_Types_h\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif /* __cplusplus */\n\n/** The OMX_API and OMX_APIENTRY are platform specific definitions used\n *  to declare OMX function prototypes.  They are modified to meet the\n *  requirements for a particular platform */\n#ifdef __SYMBIAN32__   \n#   ifdef __OMX_EXPORTS\n#       define OMX_API __declspec(dllexport)\n#   else\n#       ifdef _WIN32\n#           define OMX_API __declspec(dllexport) \n#       else\n#           define OMX_API __declspec(dllimport)\n#       endif\n#   endif\n#else\n#   if defined(_WIN32) && !defined(__MINGW32__)\n#      ifdef __OMX_EXPORTS\n#          define OMX_API __declspec(dllexport)\n#      else\n#          define OMX_API __declspec(dllimport)\n#      endif\n#   else\n#      ifdef __OMX_EXPORTS\n#          define OMX_API\n#      else\n#          define OMX_API extern\n#      endif\n#   endif\n#endif\n\n#ifndef OMX_APIENTRY\n#define OMX_APIENTRY \n#endif \n\n/** OMX_IN is used to identify inputs to an OMX function.  This designation \n    will also be used in the case of a pointer that points to a parameter \n    that is used as an output. */\n#ifndef OMX_IN\n#define OMX_IN\n#endif\n\n/** OMX_OUT is used to identify outputs from an OMX function.  This \n    designation will also be used in the case of a pointer that points \n    to a parameter that is used as an input. */\n#ifndef OMX_OUT\n#define OMX_OUT\n#endif\n\n\n/** OMX_INOUT is used to identify parameters that may be either inputs or\n    outputs from an OMX function at the same time.  This designation will \n    also be used in the case of a pointer that  points to a parameter that \n    is used both as an input and an output. */\n#ifndef OMX_INOUT\n#define OMX_INOUT\n#endif\n\n/** OMX_ALL is used to as a wildcard to select all entities of the same type\n *  when specifying the index, or referring to a object by an index.  (i.e.\n *  use OMX_ALL to indicate all N channels). When used as a port index\n *  for a config or parameter this OMX_ALL denotes that the config or\n *  parameter applies to the entire component not just one port. */\n#define OMX_ALL 0xFFFFFFFF\n\n/** In the following we define groups that help building doxygen documentation */\n\n/** @defgroup core OpenMAX IL core\n * Functions and structure related to the OMX IL core\n */\n \n /** @defgroup comp OpenMAX IL component\n * Functions and structure related to the OMX IL component\n */\n \n/** @defgroup rpm Resource and Policy Management \n * Structures for resource and policy management of components\n */\n\n/** @defgroup buf Buffer Management\n * Buffer handling functions and structures\n */\n  \n/** @defgroup tun Tunneling\n * @ingroup core comp\n * Structures and functions to manage tunnels among component ports\n */\n \n/** @defgroup cp Content Pipes\n *  @ingroup core\n */\n \n /** @defgroup metadata Metadata handling\n  * \n  */ \n\n#if defined(__GNUC__)\n#include <stdint.h>\n#define STDINT_H_AVAILABLE\n#endif\n\n/** OMX_U8 is an 8 bit unsigned quantity that is byte aligned */\ntypedef unsigned char OMX_U8;\n\n/** OMX_S8 is an 8 bit signed quantity that is byte aligned */\ntypedef signed char OMX_S8;\n\n/** OMX_U16 is a 16 bit unsigned quantity that is 16 bit word aligned */\ntypedef unsigned short OMX_U16;\n\n/** OMX_S16 is a 16 bit signed quantity that is 16 bit word aligned */\ntypedef signed short OMX_S16;\n\n/** OMX_U32 is a 32 bit unsigned quantity that is 32 bit word aligned */\n#ifdef STDINT_H_AVAILABLE\ntypedef uint32_t OMX_U32;\n#else\ntypedef unsigned long OMX_U32;\n#endif\n\n/** OMX_S32 is a 32 bit signed quantity that is 32 bit word aligned */\n#ifdef STDINT_H_AVAILABLE\ntypedef int32_t OMX_S32;\n#else\ntypedef signed long OMX_S32;\n#endif\n\n\n/* Users with compilers that cannot accept the \"long long\" designation should\n   define the OMX_SKIP64BIT macro.  It should be noted that this may cause \n   some components to fail to compile if the component was written to require\n   64 bit integral types.  However, these components would NOT compile anyway\n   since the compiler does not support the way the component was written.\n*/\n#ifndef OMX_SKIP64BIT\n#ifdef __SYMBIAN32__\n/** OMX_U64 is a 64 bit unsigned quantity that is 64 bit word aligned */\ntypedef unsigned long long OMX_U64;\n\n/** OMX_S64 is a 64 bit signed quantity that is 64 bit word aligned */\ntypedef signed long long OMX_S64;\n\n#elif defined(WIN32)\n\n/** OMX_U64 is a 64 bit unsigned quantity that is 64 bit word aligned */   \ntypedef unsigned __int64  OMX_U64;\n\n/** OMX_S64 is a 64 bit signed quantity that is 64 bit word aligned */\ntypedef signed   __int64  OMX_S64;\n\n#else /* WIN32 */\n\n/** OMX_U64 is a 64 bit unsigned quantity that is 64 bit word aligned */\ntypedef unsigned long long OMX_U64;\n\n/** OMX_S64 is a 64 bit signed quantity that is 64 bit word aligned */\ntypedef signed long long OMX_S64;\n\n#endif /* WIN32 */\n#endif\n\n\n/** The OMX_BOOL type is intended to be used to represent a true or a false \n    value when passing parameters to and from the OMX core and components.  The\n    OMX_BOOL is a 32 bit quantity and is aligned on a 32 bit word boundary.\n */\ntypedef enum OMX_BOOL {\n    OMX_FALSE = 0,\n    OMX_TRUE = !OMX_FALSE,\n    OMX_BOOL_MAX = 0x7FFFFFFF\n} OMX_BOOL; \n \n/** The OMX_PTR type is intended to be used to pass pointers between the OMX\n    applications and the OMX Core and components.  This is a 32 bit pointer and\n    is aligned on a 32 bit boundary.\n */\ntypedef void* OMX_PTR;\n\n/** The OMX_STRING type is intended to be used to pass \"C\" type strings between\n    the application and the core and component.  The OMX_STRING type is a 32 \n    bit pointer to a zero terminated string.  The  pointer is word aligned and \n    the string is byte aligned.  \n */\ntypedef char* OMX_STRING;\n\n/** The OMX_BYTE type is intended to be used to pass arrays of bytes such as\n    buffers between the application and the component and core.  The OMX_BYTE \n    type is a 32 bit pointer to a zero terminated string.  The  pointer is word\n    aligned and the string is byte aligned.\n */\ntypedef unsigned char* OMX_BYTE;\n\n/** OMX_UUIDTYPE is a very long unique identifier to uniquely identify\n    at runtime.  This identifier should be generated by a component in a way\n    that guarantees that every instance of the identifier running on the system\n    is unique. */\ntypedef unsigned char OMX_UUIDTYPE[128];\n\n/** The OMX_DIRTYPE enumeration is used to indicate if a port is an input or\n    an output port.  This enumeration is common across all component types.    \n */\ntypedef enum OMX_DIRTYPE\n{\n    OMX_DirInput,              /**< Port is an input port */\n    OMX_DirOutput,             /**< Port is an output port */\n    OMX_DirMax = 0x7FFFFFFF\n} OMX_DIRTYPE;\n\n/** The OMX_ENDIANTYPE enumeration is used to indicate the bit ordering \n    for numerical data (i.e. big endian, or little endian).    \n */\ntypedef enum OMX_ENDIANTYPE\n{\n    OMX_EndianBig, /**< big endian */\n    OMX_EndianLittle, /**< little endian */\n    OMX_EndianMax = 0x7FFFFFFF\n} OMX_ENDIANTYPE;\n\n\n/** The OMX_NUMERICALDATATYPE enumeration is used to indicate if data \n    is signed or unsigned\n */\ntypedef enum OMX_NUMERICALDATATYPE\n{\n    OMX_NumericalDataSigned, /**< signed data */\n    OMX_NumericalDataUnsigned, /**< unsigned data */\n    OMX_NumercialDataMax = 0x7FFFFFFF\n} OMX_NUMERICALDATATYPE;\n\n\n/** Unsigned bounded value type */\ntypedef struct OMX_BU32 {\n    OMX_U32 nValue; /**< actual value */\n    OMX_U32 nMin;   /**< minimum for value (i.e. nValue >= nMin) */\n    OMX_U32 nMax;   /**< maximum for value (i.e. nValue <= nMax) */\n} OMX_BU32;\n\n\n/** Signed bounded value type */\ntypedef struct OMX_BS32 {\n    OMX_S32 nValue; /**< actual value */\n    OMX_S32 nMin;   /**< minimum for value (i.e. nValue >= nMin) */\n    OMX_S32 nMax;   /**< maximum for value (i.e. nValue <= nMax) */\n} OMX_BS32;\n\n\n/** Structure representing some time or duration in microseconds. This structure\n  *  must be interpreted as a signed 64 bit value. The quantity is signed to accommodate \n  *  negative deltas and preroll scenarios. The quantity is represented in microseconds \n  *  to accomodate high resolution timestamps (e.g. DVD presentation timestamps based\n  *  on a 90kHz clock) and to allow more accurate and synchronized delivery (e.g. \n  *  individual audio samples delivered at 192 kHz). The quantity is 64 bit to \n  *  accommodate a large dynamic range (signed 32 bit values would allow only for plus\n  *  or minus 35 minutes).\n  *\n  *  Implementations with limited precision may convert the signed 64 bit value to \n  *  a signed 32 bit value internally but risk loss of precision.  \n  */\n#ifndef OMX_SKIP64BIT\ntypedef OMX_S64 OMX_TICKS;\n#else\ntypedef struct OMX_TICKS\n{\n    OMX_U32 nLowPart;    /** low bits of the signed 64 bit tick value */\n    OMX_U32 nHighPart;   /** high bits of the signed 64 bit tick value */\n} OMX_TICKS;\n#endif\n#define OMX_TICKS_PER_SECOND 1000000\n\n/** Define the public interface for the OMX Handle.  The core will not use\n    this value internally, but the application should only use this value.\n */\ntypedef void* OMX_HANDLETYPE;\n\ntypedef struct OMX_MARKTYPE\n{\n    OMX_HANDLETYPE hMarkTargetComponent;   /**< The component that will \n                                                generate a mark event upon \n                                                processing the mark. */\n    OMX_PTR pMarkData;   /**< Application specific data associated with \n                              the mark sent on a mark event to disambiguate \n                              this mark from others. */\n} OMX_MARKTYPE;\n\n\n/** OMX_NATIVE_DEVICETYPE is used to map a OMX video port to the\n *  platform & operating specific object used to reference the display \n *  or can be used by a audio port for native audio rendering */\ntypedef void* OMX_NATIVE_DEVICETYPE;\n\n/** OMX_NATIVE_WINDOWTYPE is used to map a OMX video port to the\n *  platform & operating specific object used to reference the window */\ntypedef void* OMX_NATIVE_WINDOWTYPE;\n\n\n/** Define the OMX IL version that corresponds to this set of header files.\n *  We also define a combined version that can be used to write or compare\n *  values of the 32bit nVersion field, assuming a little endian architecture */\n#define OMX_VERSION_MAJOR 1\n#define OMX_VERSION_MINOR 1\n#define OMX_VERSION_REVISION 2\n#define OMX_VERSION_STEP 0\n\n#define OMX_VERSION ((OMX_VERSION_STEP<<24) | (OMX_VERSION_REVISION<<16) | (OMX_VERSION_MINOR<<8) | OMX_VERSION_MAJOR)\n\n\n/** The OMX_VERSIONTYPE union is used to specify the version for\n    a structure or component.  For a component, the version is entirely\n    specified by the component vendor.  Components doing the same function\n    from different vendors may or may not have the same version.  For \n    structures, the version shall be set by the entity that allocates the\n    structure.  For structures specified in the OMX 1.1 specification, the\n    value of the version shall be set to 1.1.0.0 in all cases.  Access to the\n    OMX_VERSIONTYPE can be by a single 32 bit access (e.g. by nVersion) or\n    by accessing one of the structure elements to, for example, check only\n    the Major revision.\n */\ntypedef union OMX_VERSIONTYPE\n{\n    struct\n    {\n        OMX_U8 nVersionMajor;   /**< Major version accessor element */\n        OMX_U8 nVersionMinor;   /**< Minor version accessor element */\n        OMX_U8 nRevision;       /**< Revision version accessor element */\n        OMX_U8 nStep;           /**< Step version accessor element */\n    } s;\n    OMX_U32 nVersion;           /**< 32 bit value to make accessing the\n                                    version easily done in a single word\n                                    size copy/compare operation */\n} OMX_VERSIONTYPE;\n\n#ifdef __cplusplus\n}\n#endif /* __cplusplus */\n\n#endif\n/* File EOF */\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vmcs_host/khronos/IL/OMX_Video.h",
    "content": "/**\n * Copyright (c) 2008 The Khronos Group Inc. \n * \n * Permission is hereby granted, free of charge, to any person obtaining\n * a copy of this software and associated documentation files (the\n * \"Software\"), to deal in the Software without restriction, including\n * without limitation the rights to use, copy, modify, merge, publish,\n * distribute, sublicense, and/or sell copies of the Software, and to\n * permit persons to whom the Software is furnished to do so, subject\n * to the following conditions: \n * The above copyright notice and this permission notice shall be included\n * in all copies or substantial portions of the Software. \n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\n * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\n * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\n * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \n *\n */\n\n/** \n *  @file OMX_Video.h - OpenMax IL version 1.1.2\n *  The structures is needed by Video components to exchange parameters \n *  and configuration data with OMX components.\n */\n#ifndef OMX_Video_h\n#define OMX_Video_h\n\n/** @defgroup video OpenMAX IL Video Domain\n * @ingroup iv\n * Structures for OpenMAX IL Video domain\n * @{\n */\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif /* __cplusplus */\n\n\n/**\n * Each OMX header must include all required header files to allow the\n * header to compile without errors.  The includes below are required\n * for this header file to compile successfully \n */\n\n#include \"OMX_IVCommon.h\"\n\n\n/**\n * Enumeration used to define the possible video compression codings.  \n * NOTE:  This essentially refers to file extensions. If the coding is \n *        being used to specify the ENCODE type, then additional work \n *        must be done to configure the exact flavor of the compression \n *        to be used.  For decode cases where the user application can \n *        not differentiate between MPEG-4 and H.264 bit streams, it is \n *        up to the codec to handle this.\n */\ntypedef enum OMX_VIDEO_CODINGTYPE {\n    OMX_VIDEO_CodingUnused,     /**< Value when coding is N/A */\n    OMX_VIDEO_CodingAutoDetect, /**< Autodetection of coding type */\n    OMX_VIDEO_CodingMPEG2,      /**< AKA: H.262 */\n    OMX_VIDEO_CodingH263,       /**< H.263 */\n    OMX_VIDEO_CodingMPEG4,      /**< MPEG-4 */\n    OMX_VIDEO_CodingWMV,        /**< all versions of Windows Media Video */\n    OMX_VIDEO_CodingRV,         /**< all versions of Real Video */\n    OMX_VIDEO_CodingAVC,        /**< H.264/AVC */\n    OMX_VIDEO_CodingMJPEG,      /**< Motion JPEG */\n    OMX_VIDEO_CodingKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_VIDEO_CodingVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n\n#define OMX_AUDIO_CodingVP6_Supported 1\n    OMX_VIDEO_CodingVP6,        /**< On2 VP6 */\n#define OMX_AUDIO_CodingVP7_Supported 1\n    OMX_VIDEO_CodingVP7,        /**< On2 VP7 */\n#define OMX_AUDIO_CodingVP8_Supported 1\n    OMX_VIDEO_CodingVP8,        /**< On2 VP8 */\n#define OMX_AUDIO_CodingYUV_Supported 1\n    OMX_VIDEO_CodingYUV,        /* raw YUV video */\n#define OMX_AUDIO_CodingSorenson_Supported 1\n    OMX_VIDEO_CodingSorenson,   /**< Sorenson */\n#define OMX_AUDIO_CodingTheora_Supported 1\n    OMX_VIDEO_CodingTheora,     /**< Theora */\n#define OMX_AUDIO_CodingMVC_Supported 1\n    OMX_VIDEO_CodingMVC,        /**< H.264/MVC */ \t\n    \n    OMX_VIDEO_CodingMax = 0x7FFFFFFF\n} OMX_VIDEO_CODINGTYPE;\n\n\n/**\n * Data structure used to define a video path.  The number of Video paths for \n * input and output will vary by type of the Video component.  \n * \n *    Input (aka Source) : zero Inputs, one Output,\n *    Splitter           : one Input, 2 or more Outputs,\n *    Processing Element : one Input, one output,\n *    Mixer              : 2 or more inputs, one output,\n *    Output (aka Sink)  : one Input, zero outputs.\n * \n * The PortDefinition structure is used to define all of the parameters \n * necessary for the compliant component to setup an input or an output video \n * path.  If additional vendor specific data is required, it should be \n * transmitted to the component using the CustomCommand function.  Compliant \n * components will prepopulate this structure with optimal values during the \n * GetDefaultInitParams command.\n *\n * STRUCT MEMBERS:\n *  cMIMEType             : MIME type of data for the port\n *  pNativeRender         : Platform specific reference for a display if a \n *                          sync, otherwise this field is 0\n *  nFrameWidth           : Width of frame to be used on channel if \n *                          uncompressed format is used.  Use 0 for unknown,\n *                          don't care or variable\n *  nFrameHeight          : Height of frame to be used on channel if \n *                          uncompressed format is used. Use 0 for unknown,\n *                          don't care or variable\n *  nStride               : Number of bytes per span of an image \n *                          (i.e. indicates the number of bytes to get\n *                          from span N to span N+1, where negative stride\n *                          indicates the image is bottom up\n *  nSliceHeight          : Height used when encoding in slices\n *  nBitrate              : Bit rate of frame to be used on channel if \n *                          compressed format is used. Use 0 for unknown, \n *                          don't care or variable\n *  xFramerate            : Frame rate to be used on channel if uncompressed \n *                          format is used. Use 0 for unknown, don't care or \n *                          variable.  Units are Q16 frames per second.\n *  bFlagErrorConcealment : Turns on error concealment if it is supported by \n *                          the OMX component\n *  eCompressionFormat    : Compression format used in this instance of the \n *                          component. When OMX_VIDEO_CodingUnused is \n *                          specified, eColorFormat is used\n *  eColorFormat : Decompressed format used by this component\n *  pNativeWindow : Platform specific reference for a window object if a \n *                          display sink , otherwise this field is 0x0. \n */\ntypedef struct OMX_VIDEO_PORTDEFINITIONTYPE {\n    OMX_STRING cMIMEType;\n    OMX_NATIVE_DEVICETYPE pNativeRender;\n    OMX_U32 nFrameWidth;\n    OMX_U32 nFrameHeight;\n    OMX_S32 nStride;\n    OMX_U32 nSliceHeight;\n    OMX_U32 nBitrate;\n    OMX_U32 xFramerate;\n    OMX_BOOL bFlagErrorConcealment;\n    OMX_VIDEO_CODINGTYPE eCompressionFormat;\n    OMX_COLOR_FORMATTYPE eColorFormat;\n    OMX_NATIVE_WINDOWTYPE pNativeWindow;\n} OMX_VIDEO_PORTDEFINITIONTYPE;\n\n/**  \n * Port format parameter.  This structure is used to enumerate the various \n * data input/output format supported by the port.\n * \n * STRUCT MEMBERS:\n *  nSize              : Size of the structure in bytes\n *  nVersion           : OMX specification version information\n *  nPortIndex         : Indicates which port to set\n *  nIndex             : Indicates the enumeration index for the format from \n *                       0x0 to N-1\n *  eCompressionFormat : Compression format used in this instance of the \n *                       component. When OMX_VIDEO_CodingUnused is specified, \n *                       eColorFormat is used \n *  eColorFormat       : Decompressed format used by this component\n *  xFrameRate         : Indicates the video frame rate in Q16 format\n */\ntypedef struct OMX_VIDEO_PARAM_PORTFORMATTYPE {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n    OMX_U32 nIndex;\n    OMX_VIDEO_CODINGTYPE eCompressionFormat; \n    OMX_COLOR_FORMATTYPE eColorFormat;\n    OMX_U32 xFramerate;\n} OMX_VIDEO_PARAM_PORTFORMATTYPE;\n\n\n/**\n * This is a structure for configuring video compression quantization \n * parameter values.  Codecs may support different QP values for different\n * frame types.\n *\n * STRUCT MEMBERS:\n *  nSize      : Size of the structure in bytes\n *  nVersion   : OMX specification version info\n *  nPortIndex : Port that this structure applies to\n *  nQpI       : QP value to use for index frames\n *  nQpP       : QP value to use for P frames\n *  nQpB       : QP values to use for bidirectional frames \n */\ntypedef struct OMX_VIDEO_PARAM_QUANTIZATIONTYPE {\n    OMX_U32 nSize;            \n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n    OMX_U32 nQpI;\n    OMX_U32 nQpP;\n    OMX_U32 nQpB;\n} OMX_VIDEO_PARAM_QUANTIZATIONTYPE;\n\n\n/** \n * Structure for configuration of video fast update parameters. \n *  \n * STRUCT MEMBERS:\n *  nSize      : Size of the structure in bytes\n *  nVersion   : OMX specification version info \n *  nPortIndex : Port that this structure applies to\n *  bEnableVFU : Enable/Disable video fast update\n *  nFirstGOB  : Specifies the number of the first macroblock row\n *  nFirstMB   : specifies the first MB relative to the specified first GOB\n *  nNumMBs    : Specifies the number of MBs to be refreshed from nFirstGOB \n *               and nFirstMB\n */\ntypedef struct OMX_VIDEO_PARAM_VIDEOFASTUPDATETYPE {\n    OMX_U32 nSize;            \n    OMX_VERSIONTYPE nVersion; \n    OMX_U32 nPortIndex;       \n    OMX_BOOL bEnableVFU;      \n    OMX_U32 nFirstGOB;                            \n    OMX_U32 nFirstMB;                            \n    OMX_U32 nNumMBs;                                  \n} OMX_VIDEO_PARAM_VIDEOFASTUPDATETYPE;\n\n\n/** \n * Enumeration of possible bitrate control types \n */\ntypedef enum OMX_VIDEO_CONTROLRATETYPE {\n    OMX_Video_ControlRateDisable,\n    OMX_Video_ControlRateVariable,\n    OMX_Video_ControlRateConstant,\n    OMX_Video_ControlRateVariableSkipFrames,\n    OMX_Video_ControlRateConstantSkipFrames,\n    OMX_Video_ControlRateKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_Video_ControlRateVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_Video_ControlRateMax = 0x7FFFFFFF\n} OMX_VIDEO_CONTROLRATETYPE;\n\n\n/** \n * Structure for configuring bitrate mode of a codec. \n *\n * STRUCT MEMBERS:\n *  nSize          : Size of the struct in bytes\n *  nVersion       : OMX spec version info\n *  nPortIndex     : Port that this struct applies to\n *  eControlRate   : Control rate type enum\n *  nTargetBitrate : Target bitrate to encode with\n */\ntypedef struct OMX_VIDEO_PARAM_BITRATETYPE {\n    OMX_U32 nSize;                          \n    OMX_VERSIONTYPE nVersion;               \n    OMX_U32 nPortIndex;                     \n    OMX_VIDEO_CONTROLRATETYPE eControlRate; \n    OMX_U32 nTargetBitrate;                 \n} OMX_VIDEO_PARAM_BITRATETYPE;\n\n\n/** \n * Enumeration of possible motion vector (MV) types \n */\ntypedef enum OMX_VIDEO_MOTIONVECTORTYPE {\n    OMX_Video_MotionVectorPixel,\n    OMX_Video_MotionVectorHalfPel,\n    OMX_Video_MotionVectorQuarterPel,\n    OMX_Video_MotionVectorEighthPel,\n    OMX_Video_MotionVectorKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_Video_MotionVectorVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_Video_MotionVectorMax = 0x7FFFFFFF\n} OMX_VIDEO_MOTIONVECTORTYPE;\n\n\n/**\n * Structure for configuring the number of motion vectors used as well\n * as their accuracy.\n * \n * STRUCT MEMBERS:\n *  nSize            : Size of the struct in bytes\n *  nVersion         : OMX spec version info\n *  nPortIndex       : port that this structure applies to\n *  eAccuracy        : Enumerated MV accuracy\n *  bUnrestrictedMVs : Allow unrestricted MVs\n *  bFourMV          : Allow use of 4 MVs\n *  sXSearchRange    : Search range in horizontal direction for MVs\n *  sYSearchRange    : Search range in vertical direction for MVs\n */\ntypedef struct OMX_VIDEO_PARAM_MOTIONVECTORTYPE {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n    OMX_VIDEO_MOTIONVECTORTYPE eAccuracy;\n    OMX_BOOL bUnrestrictedMVs;\n    OMX_BOOL bFourMV;\n    OMX_S32 sXSearchRange;\n    OMX_S32 sYSearchRange;\n} OMX_VIDEO_PARAM_MOTIONVECTORTYPE;\n\n\n/** \n * Enumeration of possible methods to use for Intra Refresh \n */\ntypedef enum OMX_VIDEO_INTRAREFRESHTYPE {\n    OMX_VIDEO_IntraRefreshCyclic,                         /**< Cyclic intra refresh, bit 0 is set*/\n    OMX_VIDEO_IntraRefreshAdaptive,                       /**< Adaptive intra refresh, bit 1 is set*/\n    OMX_VIDEO_IntraRefreshBoth,                           /**< Cyclic + Adaptive intra refresh (no mrows since bit 2 is off)*/\n    OMX_VIDEO_IntraRefreshKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_VIDEO_IntraRefreshVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_VIDEO_IntraRefreshCyclicMrows,                    /**< Cyclic intra refresh, multiple rows at a time bits 0 and 2 are set*/\n    OMX_VIDEO_IntraRefreshPseudoRand,                     /**< Pseudo random intra refresh, uses bit 3*/\n    OMX_VIDEO_IntraRefreshMax = 0x7FFFFFFF\n} OMX_VIDEO_INTRAREFRESHTYPE;\n\n\n/**\n * Structure for configuring intra refresh mode \n * \n * STRUCT MEMBERS:\n *  nSize        : Size of the structure in bytes\n *  nVersion     : OMX specification version information\n *  nPortIndex   : Port that this structure applies to\n *  eRefreshMode : Cyclic, Adaptive, or Both\n *  nAirMBs      : Number of intra macroblocks to refresh in a frame when \n *                 AIR is enabled\n *  nAirRef      : Number of times a motion marked macroblock has to be  \n *                 intra coded\n *  nCirMBs      : Number of consecutive macroblocks to be coded as \"intra\"  \n *                 when CIR is enabled\n */\ntypedef struct OMX_VIDEO_PARAM_INTRAREFRESHTYPE {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n    OMX_VIDEO_INTRAREFRESHTYPE eRefreshMode;\n    OMX_U32 nAirMBs;\n    OMX_U32 nAirRef;\n    OMX_U32 nCirMBs;\n    OMX_U32 nPirMBs;\n} OMX_VIDEO_PARAM_INTRAREFRESHTYPE;\n\n\n/**\n * Structure for enabling various error correction methods for video \n * compression.\n *\n * STRUCT MEMBERS:\n *  nSize                   : Size of the structure in bytes\n *  nVersion                : OMX specification version information \n *  nPortIndex              : Port that this structure applies to \n *  bEnableHEC              : Enable/disable header extension codes (HEC)\n *  bEnableResync           : Enable/disable resynchronization markers\n *  nResynchMarkerSpacing   : Resynch markers interval (in bits) to be \n *                            applied in the stream \n *  bEnableDataPartitioning : Enable/disable data partitioning \n *  bEnableRVLC             : Enable/disable reversible variable length \n *                            coding\n */\ntypedef struct OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n    OMX_BOOL bEnableHEC;\n    OMX_BOOL bEnableResync;\n    OMX_U32  nResynchMarkerSpacing;\n    OMX_BOOL bEnableDataPartitioning;\n    OMX_BOOL bEnableRVLC;\n} OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE;\n\n\n/** \n * Configuration of variable block-size motion compensation (VBSMC) \n * \n * STRUCT MEMBERS:\n *  nSize      : Size of the structure in bytes\n *  nVersion   : OMX specification version information \n *  nPortIndex : Port that this structure applies to\n *  b16x16     : Enable inter block search 16x16\n *  b16x8      : Enable inter block search 16x8\n *  b8x16      : Enable inter block search 8x16\n *  b8x8       : Enable inter block search 8x8\n *  b8x4       : Enable inter block search 8x4\n *  b4x8       : Enable inter block search 4x8\n *  b4x4       : Enable inter block search 4x4\n */\ntypedef struct OMX_VIDEO_PARAM_VBSMCTYPE {\n    OMX_U32 nSize; \n    OMX_VERSIONTYPE nVersion; \n    OMX_U32 nPortIndex;       \n    OMX_BOOL b16x16; \n    OMX_BOOL b16x8; \n    OMX_BOOL b8x16;\n    OMX_BOOL b8x8;\n    OMX_BOOL b8x4;\n    OMX_BOOL b4x8;\n    OMX_BOOL b4x4;\n} OMX_VIDEO_PARAM_VBSMCTYPE;\n\n\n/** \n * H.263 profile types, each profile indicates support for various \n * performance bounds and different annexes.\n *\n * ENUMS:\n *  Baseline           : Baseline Profile: H.263 (V1), no optional modes                                                    \n *  H320 Coding        : H.320 Coding Efficiency Backward Compatibility \n *                       Profile: H.263+ (V2), includes annexes I, J, L.4\n *                       and T\n *  BackwardCompatible : Backward Compatibility Profile: H.263 (V1), \n *                       includes annex F                                    \n *  ISWV2              : Interactive Streaming Wireless Profile: H.263+ \n *                       (V2), includes annexes I, J, K and T                 \n *  ISWV3              : Interactive Streaming Wireless Profile: H.263++  \n *                       (V3), includes profile 3 and annexes V and W.6.3.8   \n *  HighCompression    : Conversational High Compression Profile: H.263++  \n *                       (V3), includes profiles 1 & 2 and annexes D and U   \n *  Internet           : Conversational Internet Profile: H.263++ (V3),  \n *                       includes profile 5 and annex K                       \n *  Interlace          : Conversational Interlace Profile: H.263++ (V3),  \n *                       includes profile 5 and annex W.6.3.11               \n *  HighLatency        : High Latency Profile: H.263++ (V3), includes  \n *                       profile 6 and annexes O.1 and P.5                       \n */\ntypedef enum OMX_VIDEO_H263PROFILETYPE {\n    OMX_VIDEO_H263ProfileBaseline            = 0x01,        \n    OMX_VIDEO_H263ProfileH320Coding          = 0x02,          \n    OMX_VIDEO_H263ProfileBackwardCompatible  = 0x04,  \n    OMX_VIDEO_H263ProfileISWV2               = 0x08,               \n    OMX_VIDEO_H263ProfileISWV3               = 0x10,               \n    OMX_VIDEO_H263ProfileHighCompression     = 0x20,     \n    OMX_VIDEO_H263ProfileInternet            = 0x40,            \n    OMX_VIDEO_H263ProfileInterlace           = 0x80,           \n    OMX_VIDEO_H263ProfileHighLatency         = 0x100,         \n    OMX_VIDEO_H263ProfileKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_VIDEO_H263ProfileVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_VIDEO_H263ProfileMax                 = 0x7FFFFFFF  \n} OMX_VIDEO_H263PROFILETYPE;\n\n\n/** \n * H.263 level types, each level indicates support for various frame sizes, \n * bit rates, decoder frame rates.\n */\ntypedef enum OMX_VIDEO_H263LEVELTYPE {\n    OMX_VIDEO_H263Level10  = 0x01,  \n    OMX_VIDEO_H263Level20  = 0x02,      \n    OMX_VIDEO_H263Level30  = 0x04,      \n    OMX_VIDEO_H263Level40  = 0x08,      \n    OMX_VIDEO_H263Level45  = 0x10,      \n    OMX_VIDEO_H263Level50  = 0x20,      \n    OMX_VIDEO_H263Level60  = 0x40,      \n    OMX_VIDEO_H263Level70  = 0x80, \n    OMX_VIDEO_H263LevelKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_VIDEO_H263LevelVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_VIDEO_H263LevelMax = 0x7FFFFFFF  \n} OMX_VIDEO_H263LEVELTYPE;\n\n\n/** \n * Specifies the picture type. These values should be OR'd to signal all \n * pictures types which are allowed.\n *\n * ENUMS:\n *  Generic Picture Types:          I, P and B\n *  H.263 Specific Picture Types:   SI and SP\n *  H.264 Specific Picture Types:   EI and EP\n *  MPEG-4 Specific Picture Types:  S\n */\ntypedef enum OMX_VIDEO_PICTURETYPE {\n    OMX_VIDEO_PictureTypeI   = 0x01,\n    OMX_VIDEO_PictureTypeP   = 0x02,\n    OMX_VIDEO_PictureTypeB   = 0x04,\n    OMX_VIDEO_PictureTypeSI  = 0x08,\n    OMX_VIDEO_PictureTypeSP  = 0x10,\n    OMX_VIDEO_PictureTypeEI  = 0x11,\n    OMX_VIDEO_PictureTypeEP  = 0x12,\n    OMX_VIDEO_PictureTypeS   = 0x14,\n    OMX_VIDEO_PictureTypeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_VIDEO_PictureTypeVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_VIDEO_PictureTypeMax = 0x7FFFFFFF\n} OMX_VIDEO_PICTURETYPE;\n\n\n/** \n * H.263 Params \n *\n * STRUCT MEMBERS:\n *  nSize                    : Size of the structure in bytes\n *  nVersion                 : OMX specification version information \n *  nPortIndex               : Port that this structure applies to\n *  nPFrames                 : Number of P frames between each I frame\n *  nBFrames                 : Number of B frames between each I frame\n *  eProfile                 : H.263 profile(s) to use\n *  eLevel                   : H.263 level(s) to use\n *  bPLUSPTYPEAllowed        : Indicating that it is allowed to use PLUSPTYPE \n *                             (specified in the 1998 version of H.263) to \n *                             indicate custom picture sizes or clock \n *                             frequencies \n *  nAllowedPictureTypes     : Specifies the picture types allowed in the \n *                             bitstream\n *  bForceRoundingTypeToZero : value of the RTYPE bit (bit 6 of MPPTYPE) is \n *                             not constrained. It is recommended to change \n *                             the value of the RTYPE bit for each reference \n *                             picture in error-free communication\n *  nPictureHeaderRepetition : Specifies the frequency of picture header \n *                             repetition\n *  nGOBHeaderInterval       : Specifies the interval of non-empty GOB  \n *                             headers in units of GOBs\n */\ntypedef struct OMX_VIDEO_PARAM_H263TYPE {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n    OMX_U32 nPFrames;\n    OMX_U32 nBFrames;\n    OMX_VIDEO_H263PROFILETYPE eProfile;\n\tOMX_VIDEO_H263LEVELTYPE eLevel;\n    OMX_BOOL bPLUSPTYPEAllowed;\n    OMX_U32 nAllowedPictureTypes;\n    OMX_BOOL bForceRoundingTypeToZero;\n    OMX_U32 nPictureHeaderRepetition;\n    OMX_U32 nGOBHeaderInterval;\n} OMX_VIDEO_PARAM_H263TYPE;\n\n\n/** \n * MPEG-2 profile types, each profile indicates support for various \n * performance bounds and different annexes.\n */\ntypedef enum OMX_VIDEO_MPEG2PROFILETYPE {\n    OMX_VIDEO_MPEG2ProfileSimple = 0,  /**< Simple Profile */\n    OMX_VIDEO_MPEG2ProfileMain,        /**< Main Profile */\n    OMX_VIDEO_MPEG2Profile422,         /**< 4:2:2 Profile */\n    OMX_VIDEO_MPEG2ProfileSNR,         /**< SNR Profile */\n    OMX_VIDEO_MPEG2ProfileSpatial,     /**< Spatial Profile */\n    OMX_VIDEO_MPEG2ProfileHigh,        /**< High Profile */\n    OMX_VIDEO_MPEG2ProfileKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_VIDEO_MPEG2ProfileVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_VIDEO_MPEG2ProfileMax = 0x7FFFFFFF  \n} OMX_VIDEO_MPEG2PROFILETYPE;\n\n\n/** \n * MPEG-2 level types, each level indicates support for various frame \n * sizes, bit rates, decoder frame rates.  No need \n */\ntypedef enum OMX_VIDEO_MPEG2LEVELTYPE {\n    OMX_VIDEO_MPEG2LevelLL = 0,  /**< Low Level */ \n    OMX_VIDEO_MPEG2LevelML,      /**< Main Level */ \n    OMX_VIDEO_MPEG2LevelH14,     /**< High 1440 */ \n    OMX_VIDEO_MPEG2LevelHL,      /**< High Level */   \n    OMX_VIDEO_MPEG2LevelKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_VIDEO_MPEG2LevelVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_VIDEO_MPEG2LevelMax = 0x7FFFFFFF  \n} OMX_VIDEO_MPEG2LEVELTYPE;\n\n\n/** \n * MPEG-2 params \n *\n * STRUCT MEMBERS:\n *  nSize      : Size of the structure in bytes\n *  nVersion   : OMX specification version information\n *  nPortIndex : Port that this structure applies to\n *  nPFrames   : Number of P frames between each I frame\n *  nBFrames   : Number of B frames between each I frame\n *  eProfile   : MPEG-2 profile(s) to use\n *  eLevel     : MPEG-2 levels(s) to use\n */\ntypedef struct OMX_VIDEO_PARAM_MPEG2TYPE {\n    OMX_U32 nSize;           \n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;      \n    OMX_U32 nPFrames;        \n    OMX_U32 nBFrames;        \n    OMX_VIDEO_MPEG2PROFILETYPE eProfile;\n\tOMX_VIDEO_MPEG2LEVELTYPE eLevel;   \n} OMX_VIDEO_PARAM_MPEG2TYPE;\n\n\n/** \n * MPEG-4 profile types, each profile indicates support for various \n * performance bounds and different annexes.\n * \n * ENUMS:\n *  - Simple Profile, Levels 1-3\n *  - Simple Scalable Profile, Levels 1-2\n *  - Core Profile, Levels 1-2\n *  - Main Profile, Levels 2-4\n *  - N-bit Profile, Level 2\n *  - Scalable Texture Profile, Level 1\n *  - Simple Face Animation Profile, Levels 1-2\n *  - Simple Face and Body Animation (FBA) Profile, Levels 1-2\n *  - Basic Animated Texture Profile, Levels 1-2\n *  - Hybrid Profile, Levels 1-2\n *  - Advanced Real Time Simple Profiles, Levels 1-4\n *  - Core Scalable Profile, Levels 1-3\n *  - Advanced Coding Efficiency Profile, Levels 1-4\n *  - Advanced Core Profile, Levels 1-2\n *  - Advanced Scalable Texture, Levels 2-3\n */\ntypedef enum OMX_VIDEO_MPEG4PROFILETYPE {\n    OMX_VIDEO_MPEG4ProfileSimple           = 0x01,        \n    OMX_VIDEO_MPEG4ProfileSimpleScalable   = 0x02,    \n    OMX_VIDEO_MPEG4ProfileCore             = 0x04,              \n    OMX_VIDEO_MPEG4ProfileMain             = 0x08,             \n    OMX_VIDEO_MPEG4ProfileNbit             = 0x10,              \n    OMX_VIDEO_MPEG4ProfileScalableTexture  = 0x20,   \n    OMX_VIDEO_MPEG4ProfileSimpleFace       = 0x40,        \n    OMX_VIDEO_MPEG4ProfileSimpleFBA        = 0x80,         \n    OMX_VIDEO_MPEG4ProfileBasicAnimated    = 0x100,     \n    OMX_VIDEO_MPEG4ProfileHybrid           = 0x200,            \n    OMX_VIDEO_MPEG4ProfileAdvancedRealTime = 0x400,  \n    OMX_VIDEO_MPEG4ProfileCoreScalable     = 0x800,      \n    OMX_VIDEO_MPEG4ProfileAdvancedCoding   = 0x1000,    \n    OMX_VIDEO_MPEG4ProfileAdvancedCore     = 0x2000,      \n    OMX_VIDEO_MPEG4ProfileAdvancedScalable = 0x4000,\n    OMX_VIDEO_MPEG4ProfileAdvancedSimple   = 0x8000,\n    OMX_VIDEO_MPEG4ProfileKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_VIDEO_MPEG4ProfileVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_VIDEO_MPEG4ProfileMax              = 0x7FFFFFFF  \n} OMX_VIDEO_MPEG4PROFILETYPE;\n\n\n/** \n * MPEG-4 level types, each level indicates support for various frame \n * sizes, bit rates, decoder frame rates.  No need \n */\ntypedef enum OMX_VIDEO_MPEG4LEVELTYPE {\n    OMX_VIDEO_MPEG4Level0  = 0x01,   /**< Level 0 */   \n    OMX_VIDEO_MPEG4Level0b = 0x02,   /**< Level 0b */   \n    OMX_VIDEO_MPEG4Level1  = 0x04,   /**< Level 1 */ \n    OMX_VIDEO_MPEG4Level2  = 0x08,   /**< Level 2 */ \n    OMX_VIDEO_MPEG4Level3  = 0x10,   /**< Level 3 */ \n    OMX_VIDEO_MPEG4Level4  = 0x20,   /**< Level 4 */  \n    OMX_VIDEO_MPEG4Level4a = 0x40,   /**< Level 4a */  \n    OMX_VIDEO_MPEG4Level5  = 0x80,   /**< Level 5 */  \n    OMX_VIDEO_MPEG4Level6  = 0x100,  /**< Level 5 */  \n    OMX_VIDEO_MPEG4LevelKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_VIDEO_MPEG4LevelVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_VIDEO_MPEG4LevelMax = 0x7FFFFFFF  \n} OMX_VIDEO_MPEG4LEVELTYPE;\n\n\n/** \n * MPEG-4 configuration.  This structure handles configuration options\n * which are specific to MPEG4 algorithms\n *\n * STRUCT MEMBERS:\n *  nSize                : Size of the structure in bytes\n *  nVersion             : OMX specification version information\n *  nPortIndex           : Port that this structure applies to\n *  nSliceHeaderSpacing  : Number of macroblocks between slice header (H263+ \n *                         Annex K). Put zero if not used\n *  bSVH                 : Enable Short Video Header mode\n *  bGov                 : Flag to enable GOV\n *  nPFrames             : Number of P frames between each I frame (also called \n *                         GOV period)\n *  nBFrames             : Number of B frames between each I frame\n *  nIDCVLCThreshold     : Value of intra DC VLC threshold\n *  bACPred              : Flag to use ac prediction\n *  nMaxPacketSize       : Maximum size of packet in bytes.\n *  nTimeIncRes          : Used to pass VOP time increment resolution for MPEG4. \n *                         Interpreted as described in MPEG4 standard.\n *  eProfile             : MPEG-4 profile(s) to use.\n *  eLevel               : MPEG-4 level(s) to use.\n *  nAllowedPictureTypes : Specifies the picture types allowed in the bitstream\n *  nHeaderExtension     : Specifies the number of consecutive video packet\n *                         headers within a VOP\n *  bReversibleVLC       : Specifies whether reversible variable length coding \n *                         is in use\n */\ntypedef struct OMX_VIDEO_PARAM_MPEG4TYPE {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n    OMX_U32 nSliceHeaderSpacing;\n    OMX_BOOL bSVH;\n    OMX_BOOL bGov;\n    OMX_U32 nPFrames;\n    OMX_U32 nBFrames;\n    OMX_U32 nIDCVLCThreshold;\n    OMX_BOOL bACPred;\n    OMX_U32 nMaxPacketSize;\n    OMX_U32 nTimeIncRes;\n    OMX_VIDEO_MPEG4PROFILETYPE eProfile;\n    OMX_VIDEO_MPEG4LEVELTYPE eLevel;\n    OMX_U32 nAllowedPictureTypes;\n    OMX_U32 nHeaderExtension;\n    OMX_BOOL bReversibleVLC;\n} OMX_VIDEO_PARAM_MPEG4TYPE;\n\n\n/** \n * WMV Versions \n */\ntypedef enum OMX_VIDEO_WMVFORMATTYPE {\n    OMX_VIDEO_WMVFormatUnused = 0x01,   /**< Format unused or unknown */\n    OMX_VIDEO_WMVFormat7      = 0x02,   /**< Windows Media Video format 7 */\n    OMX_VIDEO_WMVFormat8      = 0x04,   /**< Windows Media Video format 8 */\n    OMX_VIDEO_WMVFormat9      = 0x08,   /**< Windows Media Video format 9 */\n    OMX_VIDEO_WMFFormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_VIDEO_WMFFormatVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_VIDEO_WMVFormatMax    = 0x7FFFFFFF\n} OMX_VIDEO_WMVFORMATTYPE;\n\n\n/** \n * WMV Params \n *\n * STRUCT MEMBERS:\n *  nSize      : Size of the structure in bytes\n *  nVersion   : OMX specification version information\n *  nPortIndex : Port that this structure applies to\n *  eFormat    : Version of WMV stream / data\n */\ntypedef struct OMX_VIDEO_PARAM_WMVTYPE {\n    OMX_U32 nSize; \n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n    OMX_VIDEO_WMVFORMATTYPE eFormat;\n} OMX_VIDEO_PARAM_WMVTYPE;\n\n\n/** \n * Real Video Version \n */\ntypedef enum OMX_VIDEO_RVFORMATTYPE {\n    OMX_VIDEO_RVFormatUnused = 0, /**< Format unused or unknown */\n    OMX_VIDEO_RVFormat8,          /**< Real Video format 8 */\n    OMX_VIDEO_RVFormat9,          /**< Real Video format 9 */\n    OMX_VIDEO_RVFormatG2,         /**< Real Video Format G2 */\n    OMX_VIDEO_RVFormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_VIDEO_RVFormatVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_VIDEO_RVFormatMax = 0x7FFFFFFF\n} OMX_VIDEO_RVFORMATTYPE;\n\n\n/** \n * Real Video Params \n *\n * STUCT MEMBERS:\n *  nSize              : Size of the structure in bytes\n *  nVersion           : OMX specification version information \n *  nPortIndex         : Port that this structure applies to\n *  eFormat            : Version of RV stream / data\n *  nBitsPerPixel      : Bits per pixel coded in the frame\n *  nPaddedWidth       : Padded width in pixel of a video frame\n *  nPaddedHeight      : Padded Height in pixels of a video frame\n *  nFrameRate         : Rate of video in frames per second\n *  nBitstreamFlags    : Flags which internal information about the bitstream\n *  nBitstreamVersion  : Bitstream version\n *  nMaxEncodeFrameSize: Max encoded frame size\n *  bEnablePostFilter  : Turn on/off post filter\n *  bEnableTemporalInterpolation : Turn on/off temporal interpolation\n *  bEnableLatencyMode : When enabled, the decoder does not display a decoded \n *                       frame until it has detected that no enhancement layer \n *  \t\t\t\t\t frames or dependent B frames will be coming. This \n *  \t\t\t\t\t detection usually occurs when a subsequent non-B \n *  \t\t\t\t\t frame is encountered \n */\ntypedef struct OMX_VIDEO_PARAM_RVTYPE {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n    OMX_VIDEO_RVFORMATTYPE eFormat;\n    OMX_U16 nBitsPerPixel;\n    OMX_U16 nPaddedWidth;\n    OMX_U16 nPaddedHeight;\n    OMX_U32 nFrameRate;\n    OMX_U32 nBitstreamFlags;\n    OMX_U32 nBitstreamVersion;\n    OMX_U32 nMaxEncodeFrameSize;\n    OMX_BOOL bEnablePostFilter;\n    OMX_BOOL bEnableTemporalInterpolation;\n    OMX_BOOL bEnableLatencyMode;\n} OMX_VIDEO_PARAM_RVTYPE;\n\n\n/** \n * AVC profile types, each profile indicates support for various \n * performance bounds and different annexes.\n */\ntypedef enum OMX_VIDEO_AVCPROFILETYPE {\n    OMX_VIDEO_AVCProfileBaseline = 0x01,   /**< Baseline profile */\n    OMX_VIDEO_AVCProfileMain     = 0x02,   /**< Main profile */\n    OMX_VIDEO_AVCProfileExtended = 0x04,   /**< Extended profile */\n    OMX_VIDEO_AVCProfileHigh     = 0x08,   /**< High profile */\n    OMX_VIDEO_AVCProfileHigh10   = 0x10,   /**< High 10 profile */\n    OMX_VIDEO_AVCProfileHigh422  = 0x20,   /**< High 4:2:2 profile */\n    OMX_VIDEO_AVCProfileHigh444  = 0x40,   /**< High 4:4:4 profile */\n    OMX_VIDEO_AVCProfileConstrainedBaseline = 0x80, /**< Constrained Baseline Profile   */\n    OMX_VIDEO_AVCProfileKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_VIDEO_AVCProfileVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_VIDEO_AVCProfileMax      = 0x7FFFFFFF  \n} OMX_VIDEO_AVCPROFILETYPE;\n\n\n/** \n * AVC level types, each level indicates support for various frame sizes, \n * bit rates, decoder frame rates.  No need \n */\ntypedef enum OMX_VIDEO_AVCLEVELTYPE {\n    OMX_VIDEO_AVCLevel1   = 0x01,     /**< Level 1 */\n    OMX_VIDEO_AVCLevel1b  = 0x02,     /**< Level 1b */\n    OMX_VIDEO_AVCLevel11  = 0x04,     /**< Level 1.1 */\n    OMX_VIDEO_AVCLevel12  = 0x08,     /**< Level 1.2 */\n    OMX_VIDEO_AVCLevel13  = 0x10,     /**< Level 1.3 */\n    OMX_VIDEO_AVCLevel2   = 0x20,     /**< Level 2 */\n    OMX_VIDEO_AVCLevel21  = 0x40,     /**< Level 2.1 */\n    OMX_VIDEO_AVCLevel22  = 0x80,     /**< Level 2.2 */\n    OMX_VIDEO_AVCLevel3   = 0x100,    /**< Level 3 */\n    OMX_VIDEO_AVCLevel31  = 0x200,    /**< Level 3.1 */\n    OMX_VIDEO_AVCLevel32  = 0x400,    /**< Level 3.2 */\n    OMX_VIDEO_AVCLevel4   = 0x800,    /**< Level 4 */\n    OMX_VIDEO_AVCLevel41  = 0x1000,   /**< Level 4.1 */\n    OMX_VIDEO_AVCLevel42  = 0x2000,   /**< Level 4.2 */\n    OMX_VIDEO_AVCLevel5   = 0x4000,   /**< Level 5 */\n    OMX_VIDEO_AVCLevel51  = 0x8000,   /**< Level 5.1 */\n    OMX_VIDEO_AVCLevelKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_VIDEO_AVCLevelVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_VIDEO_AVCLevelMax = 0x7FFFFFFF  \n} OMX_VIDEO_AVCLEVELTYPE;\n\n\n/** \n * AVC loop filter modes \n *\n * OMX_VIDEO_AVCLoopFilterEnable               : Enable\n * OMX_VIDEO_AVCLoopFilterDisable              : Disable\n * OMX_VIDEO_AVCLoopFilterDisableSliceBoundary : Disabled on slice boundaries\n */\ntypedef enum OMX_VIDEO_AVCLOOPFILTERTYPE {\n    OMX_VIDEO_AVCLoopFilterEnable = 0,\n    OMX_VIDEO_AVCLoopFilterDisable,\n    OMX_VIDEO_AVCLoopFilterDisableSliceBoundary,\n    OMX_VIDEO_AVCLoopFilterKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_VIDEO_AVCLoopFilterVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_VIDEO_AVCLoopFilterMax = 0x7FFFFFFF\n} OMX_VIDEO_AVCLOOPFILTERTYPE;\n\n\n/** \n * AVC params \n *\n * STRUCT MEMBERS:\n *  nSize                     : Size of the structure in bytes\n *  nVersion                  : OMX specification version information\n *  nPortIndex                : Port that this structure applies to\n *  nSliceHeaderSpacing       : Number of macroblocks between slice header, put  \n *                              zero if not used\n *  nPFrames                  : Number of P frames between each I frame\n *  nBFrames                  : Number of B frames between each I frame\n *  bUseHadamard              : Enable/disable Hadamard transform\n *  nRefFrames                : Max number of reference frames to use for inter\n *                              motion search (1-16)\n *  nRefIdxTrailing           : Pic param set ref frame index (index into ref\n *                              frame buffer of trailing frames list), B frame\n *                              support\n *  nRefIdxForward            : Pic param set ref frame index (index into ref\n *                              frame buffer of forward frames list), B frame\n *                              support\n *  bEnableUEP                : Enable/disable unequal error protection. This \n *                              is only valid of data partitioning is enabled.\n *  bEnableFMO                : Enable/disable flexible macroblock ordering\n *  bEnableASO                : Enable/disable arbitrary slice ordering\n *  bEnableRS                 : Enable/disable sending of redundant slices\n *  eProfile                  : AVC profile(s) to use\n *  eLevel                    : AVC level(s) to use\n *  nAllowedPictureTypes      : Specifies the picture types allowed in the \n *                              bitstream\n *  bFrameMBsOnly             : specifies that every coded picture of the \n *                              coded video sequence is a coded frame \n *                              containing only frame macroblocks\n *  bMBAFF                    : Enable/disable switching between frame and \n *                              field macroblocks within a picture\n *  bEntropyCodingCABAC       : Entropy decoding method to be applied for the \n *                              syntax elements for which two descriptors appear \n *                              in the syntax tables\n *  bWeightedPPrediction      : Enable/disable weighted prediction shall not \n *                              be applied to P and SP slices\n *  nWeightedBipredicitonMode : Default weighted prediction is applied to B \n *                              slices \n *  bconstIpred               : Enable/disable intra prediction\n *  bDirect8x8Inference       : Specifies the method used in the derivation \n *                              process for luma motion vectors for B_Skip, \n *                              B_Direct_16x16 and B_Direct_8x8 as specified \n *                              in subclause 8.4.1.2 of the AVC spec \n *  bDirectSpatialTemporal    : Flag indicating spatial or temporal direct\n *                              mode used in B slice coding (related to \n *                              bDirect8x8Inference) . Spatial direct mode is \n *                              more common and should be the default.\n *  nCabacInitIdx             : Index used to init CABAC contexts\n *  eLoopFilterMode           : Enable/disable loop filter\n */\ntypedef struct OMX_VIDEO_PARAM_AVCTYPE {\n    OMX_U32 nSize;                 \n    OMX_VERSIONTYPE nVersion;      \n    OMX_U32 nPortIndex;            \n    OMX_U32 nSliceHeaderSpacing;  \n    OMX_U32 nPFrames;     \n    OMX_U32 nBFrames;     \n    OMX_BOOL bUseHadamard;\n    OMX_U32 nRefFrames;  \n\tOMX_U32 nRefIdx10ActiveMinus1;\n\tOMX_U32 nRefIdx11ActiveMinus1;\n    OMX_BOOL bEnableUEP;  \n    OMX_BOOL bEnableFMO;  \n    OMX_BOOL bEnableASO;  \n    OMX_BOOL bEnableRS;   \n    OMX_VIDEO_AVCPROFILETYPE eProfile;\n\tOMX_VIDEO_AVCLEVELTYPE eLevel; \n    OMX_U32 nAllowedPictureTypes;  \n\tOMX_BOOL bFrameMBsOnly;        \t\t\t\t\t\t\t\t\t\n    OMX_BOOL bMBAFF;               \n    OMX_BOOL bEntropyCodingCABAC;  \n    OMX_BOOL bWeightedPPrediction; \n    OMX_U32 nWeightedBipredicitonMode; \n    OMX_BOOL bconstIpred ;\n    OMX_BOOL bDirect8x8Inference;  \n\tOMX_BOOL bDirectSpatialTemporal;\n\tOMX_U32 nCabacInitIdc;\n\tOMX_VIDEO_AVCLOOPFILTERTYPE eLoopFilterMode;\n} OMX_VIDEO_PARAM_AVCTYPE;\n\ntypedef struct OMX_VIDEO_PARAM_PROFILELEVELTYPE {\n   OMX_U32 nSize;                 \n   OMX_VERSIONTYPE nVersion;      \n   OMX_U32 nPortIndex;            \n   OMX_U32 eProfile;      /**< type is OMX_VIDEO_AVCPROFILETYPE, OMX_VIDEO_H263PROFILETYPE, \n                                 or OMX_VIDEO_MPEG4PROFILETYPE depending on context */\n   OMX_U32 eLevel;        /**< type is OMX_VIDEO_AVCLEVELTYPE, OMX_VIDEO_H263LEVELTYPE, \n                                 or OMX_VIDEO_MPEG4PROFILETYPE depending on context */\n   OMX_U32 nProfileIndex; /**< Used to query for individual profile support information,\n                               This parameter is valid only for \n                               OMX_IndexParamVideoProfileLevelQuerySupported index,\n                               For all other indices this parameter is to be ignored. */\n} OMX_VIDEO_PARAM_PROFILELEVELTYPE;\n\n/** \n * Structure for dynamically configuring bitrate mode of a codec. \n *\n * STRUCT MEMBERS:\n *  nSize          : Size of the struct in bytes\n *  nVersion       : OMX spec version info\n *  nPortIndex     : Port that this struct applies to\n *  nEncodeBitrate : Target average bitrate to be generated in bps\n */\ntypedef struct OMX_VIDEO_CONFIG_BITRATETYPE {\n    OMX_U32 nSize;                          \n    OMX_VERSIONTYPE nVersion;               \n    OMX_U32 nPortIndex;                     \n    OMX_U32 nEncodeBitrate;                 \n} OMX_VIDEO_CONFIG_BITRATETYPE;\n\n/** \n * Defines Encoder Frame Rate setting\n *\n * STRUCT MEMBERS:\n *  nSize            : Size of the structure in bytes\n *  nVersion         : OMX specification version information \n *  nPortIndex       : Port that this structure applies to\n *  xEncodeFramerate : Encoding framerate represented in Q16 format\n */\ntypedef struct OMX_CONFIG_FRAMERATETYPE {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n    OMX_U32 xEncodeFramerate; /* Q16 format */\n} OMX_CONFIG_FRAMERATETYPE;\n\ntypedef struct OMX_CONFIG_INTRAREFRESHVOPTYPE {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n    OMX_BOOL IntraRefreshVOP;\n} OMX_CONFIG_INTRAREFRESHVOPTYPE;\n\ntypedef struct OMX_CONFIG_MACROBLOCKERRORMAPTYPE {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n    OMX_U32 nErrMapSize;           /* Size of the Error Map in bytes */\n    OMX_U8  ErrMap[1];             /* Error map hint */\n} OMX_CONFIG_MACROBLOCKERRORMAPTYPE;\n\ntypedef struct OMX_CONFIG_MBERRORREPORTINGTYPE {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n    OMX_BOOL bEnabled;\n} OMX_CONFIG_MBERRORREPORTINGTYPE;\n\ntypedef struct OMX_PARAM_MACROBLOCKSTYPE {\n    OMX_U32 nSize;\n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n    OMX_U32 nMacroblocks;\n} OMX_PARAM_MACROBLOCKSTYPE;\n\n/** \n * AVC Slice Mode modes \n *\n * OMX_VIDEO_SLICEMODE_AVCDefault   : Normal frame encoding, one slice per frame\n * OMX_VIDEO_SLICEMODE_AVCMBSlice   : NAL mode, number of MBs per frame\n * OMX_VIDEO_SLICEMODE_AVCByteSlice : NAL mode, number of bytes per frame\n */\ntypedef enum OMX_VIDEO_AVCSLICEMODETYPE {\n    OMX_VIDEO_SLICEMODE_AVCDefault = 0,\n    OMX_VIDEO_SLICEMODE_AVCMBSlice,\n    OMX_VIDEO_SLICEMODE_AVCByteSlice,\n    OMX_VIDEO_SLICEMODE_AVCKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ \n    OMX_VIDEO_SLICEMODE_AVCVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */\n    OMX_VIDEO_SLICEMODE_AVCLevelMax = 0x7FFFFFFF\n} OMX_VIDEO_AVCSLICEMODETYPE;\n\n/** \n * AVC FMO Slice Mode Params \n *\n * STRUCT MEMBERS:\n *  nSize      : Size of the structure in bytes\n *  nVersion   : OMX specification version information\n *  nPortIndex : Port that this structure applies to\n *  nNumSliceGroups : Specifies the number of slice groups\n *  nSliceGroupMapType : Specifies the type of slice groups\n *  eSliceMode : Specifies the type of slice\n */\ntypedef struct OMX_VIDEO_PARAM_AVCSLICEFMO {\n    OMX_U32 nSize; \n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n    OMX_U8 nNumSliceGroups;\n    OMX_U8 nSliceGroupMapType;\n    OMX_VIDEO_AVCSLICEMODETYPE eSliceMode;\n} OMX_VIDEO_PARAM_AVCSLICEFMO;\n\n/** \n * AVC IDR Period Configs\n *\n * STRUCT MEMBERS:\n *  nSize      : Size of the structure in bytes\n *  nVersion   : OMX specification version information\n *  nPortIndex : Port that this structure applies to\n *  nIDRPeriod : Specifies periodicity of IDR frames\n *  nPFrames : Specifies internal of coding Intra frames\n */\ntypedef struct OMX_VIDEO_CONFIG_AVCINTRAPERIOD {\n    OMX_U32 nSize; \n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n    OMX_U32 nIDRPeriod;\n    OMX_U32 nPFrames;\n} OMX_VIDEO_CONFIG_AVCINTRAPERIOD;\n\n/** \n * AVC NAL Size Configs\n *\n * STRUCT MEMBERS:\n *  nSize      : Size of the structure in bytes\n *  nVersion   : OMX specification version information\n *  nPortIndex : Port that this structure applies to\n *  nNaluBytes : Specifies the NAL unit size\n */\ntypedef struct OMX_VIDEO_CONFIG_NALSIZE {\n    OMX_U32 nSize; \n    OMX_VERSIONTYPE nVersion;\n    OMX_U32 nPortIndex;\n    OMX_U32 nNaluBytes;\n} OMX_VIDEO_CONFIG_NALSIZE;\n\n\n/** @} */\n\n#ifdef __cplusplus\n}\n#endif /* __cplusplus */\n\n#endif\n/* File EOF */\n\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vmcs_host/linux/vcfiled/vcfiled_check.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n#ifndef VCFILED_CHECK_H\n#define VCFILED_CHECK_H\n\n#ifdef ANDROID\n#define VCFILED_LOCKDIR \"/tmp/vcfiled/vcfiled.pid\"\n#define VCFILED_LOCKFILE \"/tmp/vcfiled\"\n#endif\n\n#ifndef VCFILED_LOCKFILE\n#define VCFILED_LOCKDIR \"/var/run/vcfiled\"\n#define VCFILED_LOCKFILE VCFILED_LOCKDIR \"/vcfiled\"\n#endif\n\ntypedef void (*VCFILED_LOGMSG_T)(int level, const char *fmt, ...);\nint vcfiled_lock(const char *filename, VCFILED_LOGMSG_T logmsg);\nextern int vcfiled_is_running(const char *lockfile);\n\n\n#endif\n\n\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vmcs_host/linux/vchost_config.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n#ifndef VCHOST_CONFIG_H\n#define VCHOST_CONFIG_H\n\n#include \"interface/vcos/vcos.h\"\n\n#if 0\n/* Types that map onto VideoCore's types of the same name. */\ntypedef unsigned char uint8_t;\ntypedef unsigned short uint16_t;\ntypedef short int16_t;\ntypedef long int32_t;\ntypedef unsigned long uint32_t;\ntypedef long long int64_t;\ntypedef unsigned long long uint64_t;\n\n#ifndef vc_assert\n#define vc_assert(cond) vcos_assert(cond)\n#endif\n#endif\n\n/* On this platform we need to be able to release the host-side software resources. */\nextern void vc_os_close(void);\n\n#ifndef VCHPRE_\n#define VCHPRE_     extern\n#endif\n#ifndef VCHPOST_\n#define VCHPOST_\n#endif\n#ifndef VCCPRE_\n#define VCCPRE_     \n#endif\n\n#endif\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vmcs_host/vc_cec.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n/*\n * CEC related constants - shared by both host and vc.\n */\n\n#ifndef _VC_CEC_H_\n#define _VC_CEC_H_\n\n#ifndef STRINGIFY\n#define STRINGIFY(x) #x\n#define TOSTRING(x)  STRINGIFY(x)\n#endif\n\n//Broadcast address and TV logical address\n#define CEC_BROADCAST_ADDR       0x0F\n#define CEC_TV_ADDRESS           0x00\n\n//Maximum transmit length excluding the header byte */\n#define CEC_MAX_XMIT_LENGTH      15  /* +1 for CEC Header Length */\n//Invalid physical address\n#define CEC_CLEAR_ADDR           0xFFFF  /* packed 16 bits of F.F.F.F */\n\n/* ----------------------------------------------------------------------\n * general CEC defines\n * -------------------------------------------------------------------- */\n//Maximum transmission length and invalid physical address are now in vc_cec.h\n#define CEC_VERSION              0x04    /* HDMI 1.3a */\n//This OUI ID is registered at the current HQ address in Irvine\n#define CEC_VENDOR_ID_BROADCOM   (0x18C086L) // 24 bit OUI company id from IEEE. = Broadcom\n//These three OUI IDs are registered with the old address of Irvine office in case you need them\n//#define CEC_VENDOR_ID_BROADCOM   (0x000AF7L)\n//#define CEC_VENDOR_ID_BROADCOM   (0x001018L)\n//#define CEC_VENDOR_ID_BROADCOM   (0x001BE9L)\n#define CEC_VENDOR_ID_ONKYO            (0x0009B0L)\n#define CEC_VENDOR_ID_PANASONIC_EUROPE (0x000F12L)\n\n//If we want to \"pretend\" to be somebody else use a different company id\n#define CEC_VENDOR_ID  (0x000000L) //We should set the vendor id\n\n#define CEC_BLOCKING             1\n#define CEC_NONBLOCKING          0\n\n/**\n * These are the logical addresses for all possible attached devices\n */\ntypedef enum CEC_AllDevices {\n   CEC_AllDevices_eTV = 0,            /**<TV only */\n   CEC_AllDevices_eRec1,              /**<Address for 1st Recording Device */\n   CEC_AllDevices_eRec2,              /**<Address for 2nd Recording Device */\n   CEC_AllDevices_eSTB1,              /**<Address for 1st SetTop Box Device */\n   CEC_AllDevices_eDVD1,              /**<Address for 1st DVD Device */\n   CEC_AllDevices_eAudioSystem,       /**<Address for Audio Device */\n   CEC_AllDevices_eSTB2,              /**<Address for 2nd SetTop Box Device */\n   CEC_AllDevices_eSTB3,              /**<Address for 3rd SetTop Box Device */\n   CEC_AllDevices_eDVD2,              /**<Address for 2nd DVD Device */\n   CEC_AllDevices_eRec3,              /**<Address for 3rd Recording Device */\n   CEC_AllDevices_eSTB4,              /**<10 Address for 4th Tuner Device */\n   CEC_AllDevices_eDVD3,              /**<11 Address for 3rd DVD Device */\n   CEC_AllDevices_eRsvd3,             /**<Reserved and cannot be used */\n   CEC_AllDevices_eRsvd4,             /**<Reserved and cannot be used */\n   CEC_AllDevices_eFreeUse,           /**<Free Address, use for any device */\n   CEC_AllDevices_eUnRegistered = 15  /**<UnRegistered Devices */\n} CEC_AllDevices_T;\n\n/**\n * define device types for <Report Physical Address>\n */\ntypedef enum CEC_DeviceTypes{\n   CEC_DeviceType_TV           = 0, /**<TV only */\n   CEC_DeviceType_Rec          = 1, /**<Recoding device */\n   CEC_DeviceType_Reserved     = 2, /**<Reserved */\n   CEC_DeviceType_Tuner        = 3, /**<STB */\n   CEC_DeviceType_Playback     = 4, /**<DVD player */\n   CEC_DeviceType_Audio        = 5, /**<AV receiver */\n   CEC_DeviceType_Switch       = 6, /**<CEC switch */\n   CEC_DeviceType_VidProc      = 7, /**<Video processor */\n\n   CEC_DeviceType_Invalid      = 0xF, //RESERVED - DO NOT USE\n} CEC_DEVICE_TYPE_T;\n\n/**\n * Generic CEC opcode\n */\ntypedef enum {\n   CEC_Opcode_FeatureAbort \t            = 0x00,\n   CEC_Opcode_ImageViewOn \t            = 0x04,\n   CEC_Opcode_TunerStepIncrement    \t    = 0x05,\n   CEC_Opcode_TunerStepDecrement    \t    = 0x06,\n   CEC_Opcode_TunerDeviceStatus \t    = 0x07,\n   CEC_Opcode_GiveTunerDeviceStatus \t    = 0x08,\n   CEC_Opcode_RecordOn \t                    = 0x09,\n   CEC_Opcode_RecordStatus \t            = 0x0A,\n   CEC_Opcode_RecordOff \t            = 0x0B,\n   CEC_Opcode_TextViewOn \t            = 0x0D,\n   CEC_Opcode_RecordTVScreen                = 0x0F,\n   CEC_Opcode_GiveDeckStatus        \t    = 0x1A,\n   CEC_Opcode_DeckStatus \t            = 0x1B,\n   CEC_Opcode_SetMenuLanguage               = 0x32,\n   CEC_Opcode_ClearAnalogTimer              = 0x33,\n   CEC_Opcode_SetAnalogTimer                = 0x34,\n   CEC_Opcode_TimerStatus                   = 0x35,\n   CEC_Opcode_Standby \t                    = 0x36,\n   CEC_Opcode_Play                  \t    = 0x41,\n   CEC_Opcode_DeckControl \t            = 0x42,\n   CEC_Opcode_TimerClearedStatus            = 0x43,\n   CEC_Opcode_UserControlPressed \t    = 0x44,\n   CEC_Opcode_UserControlReleased \t    = 0x45,\n   CEC_Opcode_GiveOSDName           \t    = 0x46,\n   CEC_Opcode_SetOSDName \t            = 0x47,\n   CEC_Opcode_SetOSDString \t            = 0x64,\n   CEC_Opcode_SetTimerProgramTitle          = 0x67,\n   CEC_Opcode_SystemAudioModeRequest        = 0x70,\n   CEC_Opcode_GiveAudioStatus               = 0x71,\n   CEC_Opcode_SetSystemAudioMode            = 0x72,\n   CEC_Opcode_ReportAudioStatus             = 0x7A,\n   CEC_Opcode_GiveSystemAudioModeStatus     = 0x7D,\n   CEC_Opcode_SystemAudioModeStatus         = 0x7E,\n   CEC_Opcode_RoutingChange \t            = 0x80,\n   CEC_Opcode_RoutingInformation \t    = 0x81,\n   CEC_Opcode_ActiveSource \t            = 0x82,\n   CEC_Opcode_GivePhysicalAddress           = 0x83,\n   CEC_Opcode_ReportPhysicalAddress         = 0x84,\n   CEC_Opcode_RequestActiveSource \t    = 0x85,\n   CEC_Opcode_SetStreamPath \t            = 0x86,\n   CEC_Opcode_DeviceVendorID \t            = 0x87,\n   CEC_Opcode_VendorCommand         \t    = 0x89,\n   CEC_Opcode_VendorRemoteButtonDown \t    = 0x8A,\n   CEC_Opcode_VendorRemoteButtonUp    \t    = 0x8B,\n   CEC_Opcode_GiveDeviceVendorID    \t    = 0x8C,\n   CEC_Opcode_MenuRequest \t            = 0x8D,\n   CEC_Opcode_MenuStatus \t            = 0x8E,\n   CEC_Opcode_GiveDevicePowerStatus \t    = 0x8F,\n   CEC_Opcode_ReportPowerStatus \t    = 0x90,\n   CEC_Opcode_GetMenuLanguage               = 0x91,\n   CEC_Opcode_SelectAnalogService           = 0x92,\n   CEC_Opcode_SelectDigitalService   \t    = 0x93,\n   CEC_Opcode_SetDigitalTimer               = 0x97,\n   CEC_Opcode_ClearDigitalTimer             = 0x99,\n   CEC_Opcode_SetAudioRate                  = 0x9A,\n   CEC_Opcode_InactiveSource        \t    = 0x9D,\n   CEC_Opcode_CECVersion                    = 0x9E,\n   CEC_Opcode_GetCECVersion                 = 0x9F,\n   CEC_Opcode_VendorCommandWithID           = 0xA0,\n   CEC_Opcode_ClearExternalTimer            = 0xA1,\n   CEC_Opcode_SetExternalTimer              = 0xA2,\n   CEC_Opcode_ReportShortAudioDescriptor    = 0xA3,\n   CEC_Opcode_RequestShortAudioDescriptor   = 0xA4,\n   CEC_Opcode_InitARC                       = 0xC0,\n   CEC_Opcode_ReportARCInited               = 0xC1,\n   CEC_Opcode_ReportARCTerminated           = 0xC2,\n   CEC_Opcode_RequestARCInit                = 0xC3,\n   CEC_Opcode_RequestARCTermination         = 0xC4,\n   CEC_Opcode_TerminateARC                  = 0xC5,\n   CEC_Opcode_CDC                           = 0xF8,\n   CEC_Opcode_Abort        \t            = 0xFF\n} CEC_OPCODE_T;\n\n/**\n * Reason parameter for <Feature Abort>\n */\ntypedef enum {\n   CEC_Abort_Reason_Unrecognised_Opcode   = 0,\n   CEC_Abort_Reason_Wrong_Mode            = 1,\n   CEC_Abort_Reason_Cannot_Provide_Source = 2,\n   CEC_Abort_Reason_Invalid_Operand       = 3,\n   CEC_Abort_Reason_Refused               = 4,\n   CEC_Abort_Reason_Undetermined          = 5\n} CEC_ABORT_REASON_T;\n\n/**\n * Display control parameter for <Set OSD string>\n */\ntypedef enum {\n   CEC_DISPLAY_CONTROL_DEFAULT_TIME       = 0,\n   CEC_DISPLAY_CONTROL_UNTIL_CLEARED      = (1<<6),\n   CEC_DISPLAY_CONTROL_CLEAR_PREV_MSG     = (1<<7)\n} CEC_DISPLAY_CONTROL_T;\n\n/**\n * Power status parameter for <Report Power Status>\n */\ntypedef enum {\n   CEC_POWER_STATUS_ON                    = 0,\n   CEC_POWER_STATUS_STANDBY               = 1,\n   CEC_POWER_STATUS_ON_PENDING            = 2,\n   CEC_POWER_STATUS_STANDBY_PENDING       = 3\n} CEC_POWER_STATUS_T;\n\n/**\n * Menu state parameter for <Menu Status>\n */\ntypedef enum {\n   CEC_MENU_STATE_ACTIVATED               = 0,\n   CEC_MENU_STATE_DEACTIVATED             = 1,\n   CEC_MENU_STATE_QUERY                   = 2\n} CEC_MENU_STATE_T;\n\n/**\n * Deck status parameter for <Deck Status>\n */\ntypedef enum {\n   CEC_DECK_INFO_PLAY                     = 0x11,\n   CEC_DECK_INFO_RECORD                   = 0x12,\n   CEC_DECK_INFO_PLAY_REVERSE             = 0x13,\n   CEC_DECK_INFO_STILL                    = 0x14,\n   CEC_DECK_INFO_SLOW                     = 0x15,\n   CEC_DECK_INFO_SLOW_REVERSE             = 0x16,\n   CEC_DECK_INFO_SEARCH_FORWARD           = 0x17,\n   CEC_DECK_INFO_SEARCH_REVERSE           = 0x18,\n   CEC_DECK_INFO_NO_MEDIA                 = 0x19,\n   CEC_DECK_INFO_STOP                     = 0x1A,\n   CEC_DECK_INFO_WIND                     = 0x1B,\n   CEC_DECK_INFO_REWIND                   = 0x1C,\n   CEC_DECK_IDX_SEARCH_FORWARD            = 0x1D,\n   CEC_DECK_IDX_SEARCH_REVERSE            = 0x1E,\n   CEC_DECK_OTHER_STATUS                  = 0x1F\n} CEC_DECK_INFO_T;\n\n/**\n * Deck control mode for <Deck Control>\n */\ntypedef enum {\n   CEC_DECK_CTRL_FORWARD                  = 1,\n   CEC_DECK_CTRL_BACKWARD                 = 2,\n   CEC_DECK_CTRL_STOP                     = 3,\n   CEC_DECK_CTRL_EJECT                    = 4\n} CEC_DECK_CTRL_MODE_T;\n\n/**\n * Play mode for <Play>\n */\ntypedef enum {\n   CEC_PLAY_FORWARD                       = 0x24,\n   CEC_PLAY_REVERSE                       = 0x20,\n   CEC_PLAY_STILL                         = 0x25,\n   CEC_PLAY_SCAN_FORWARD_MIN_SPEED        = 0x05,\n   CEC_PLAY_SCAN_FORWARD_MED_SPEED        = 0x06,\n   CEC_PLAY_SCAN_FORWARD_MAX_SPEED        = 0x07,\n   CEC_PLAY_SCAN_REVERSE_MIN_SPEED        = 0x09,\n   CEC_PLAY_SCAN_REVERSE_MED_SPEED        = 0x0A,\n   CEC_PLAY_SCAN_REVERSE_MAX_SPEED        = 0x0B,\n   CEC_PLAY_SLOW_FORWARD_MIN_SPEED        = 0x15,\n   CEC_PLAY_SLOW_FORWARD_MED_SPEED        = 0x16,\n   CEC_PLAY_SLOW_FORWARD_MAX_SPEED        = 0x17,\n   CEC_PLAY_SLOW_REVERSE_MIN_SPEED        = 0x19,\n   CEC_PLAY_SLOW_REVERSE_MED_SPEED        = 0x1A,\n   CEC_PLAY_SLOW_REVERSE_MAX_SPEED        = 0x1B\n} CEC_PLAY_MODE_T;\n\n/**\n * Status request for <Give Deck Status>\n */\ntypedef enum {\n   CEC_DECK_STATUS_ON                     = 1,\n   CEC_DECK_STATUS_OFF                    = 2,\n   CEC_DECK_STATUS_ONCE                   = 3\n} CEC_DECK_STATUS_REQUEST_T;\n\n/**\n * Button code for <User Control Pressed>\n */\ntypedef enum {\n   CEC_User_Control_Select                      = 0x00,\n   CEC_User_Control_Up                          = 0x01,\n   CEC_User_Control_Down                        = 0x02,\n   CEC_User_Control_Left                        = 0x03,\n   CEC_User_Control_Right                       = 0x04,\n   CEC_User_Control_RightUp                     = 0x05,\n   CEC_User_Control_RightDown                   = 0x06,\n   CEC_User_Control_LeftUp                      = 0x07,\n   CEC_User_Control_LeftDown                    = 0x08,\n   CEC_User_Control_RootMenu                    = 0x09,\n   CEC_User_Control_SetupMenu                   = 0x0A,\n   CEC_User_Control_ContentsMenu                = 0x0B,\n   CEC_User_Control_FavoriteMenu                = 0x0C,\n   CEC_User_Control_Exit                        = 0x0D,\n   CEC_User_Control_Number0                     = 0x20,\n   CEC_User_Control_Number1                     = 0x21,\n   CEC_User_Control_Number2                     = 0x22,\n   CEC_User_Control_Number3                     = 0x23,\n   CEC_User_Control_Number4                     = 0x24,\n   CEC_User_Control_Number5                     = 0x25,\n   CEC_User_Control_Number6                     = 0x26,\n   CEC_User_Control_Number7                     = 0x27,\n   CEC_User_Control_Number8                     = 0x28,\n   CEC_User_Control_Number9                     = 0x29,\n   CEC_User_Control_Dot                         = 0x2A,\n   CEC_User_Control_Enter                       = 0x2B,\n   CEC_User_Control_Clear                       = 0x2C,\n   CEC_User_Control_ChannelUp                   = 0x30,\n   CEC_User_Control_ChannelDown                 = 0x31,\n   CEC_User_Control_PreviousChannel             = 0x32,\n   CEC_User_Control_SoundSelect                 = 0x33,\n   CEC_User_Control_InputSelect                 = 0x34,\n   CEC_User_Control_DisplayInformation          = 0x35,\n   CEC_User_Control_Help                        = 0x36,\n   CEC_User_Control_PageUp                      = 0x37,\n   CEC_User_Control_PageDown                    = 0x38,\n   CEC_User_Control_Power                       = 0x40,\n   CEC_User_Control_VolumeUp                    = 0x41,\n   CEC_User_Control_VolumeDown                  = 0x42,\n   CEC_User_Control_Mute                        = 0x43,\n   CEC_User_Control_Play                        = 0x44,\n   CEC_User_Control_Stop                        = 0x45,\n   CEC_User_Control_Pause                       = 0x46,\n   CEC_User_Control_Record                      = 0x47,\n   CEC_User_Control_Rewind                      = 0x48,\n   CEC_User_Control_FastForward                 = 0x49,\n   CEC_User_Control_Eject                       = 0x4A,\n   CEC_User_Control_Forward                     = 0x4B,\n   CEC_User_Control_Backward                    = 0x4C,\n   CEC_User_Control_Angle                       = 0x50,\n   CEC_User_Control_Subpicture                  = 0x51,\n   CEC_User_Control_VideoOnDemand               = 0x52,\n   CEC_User_Control_EPG                         = 0x53,\n   CEC_User_Control_TimerProgramming            = 0x54,\n   CEC_User_Control_InitialConfig               = 0x55,\n   CEC_User_Control_PlayFunction                = 0x60,\n   CEC_User_Control_PausePlayFunction           = 0x61,\n   CEC_User_Control_RecordFunction              = 0x62,\n   CEC_User_Control_PauseRecordFunction         = 0x63,\n   CEC_User_Control_StopFunction                = 0x64,\n   CEC_User_Control_MuteFunction                = 0x65,\n   CEC_User_Control_RestoreVolumeFunction       = 0x66,\n   CEC_User_Control_TuneFunction                = 0x67,\n   CEC_User_Control_SelectDiskFunction          = 0x68,\n   CEC_User_Control_SelectAVInputFunction       = 0x69,\n   CEC_User_Control_SelectAudioInputFunction    = 0x6A,\n   CEC_User_Control_F1Blue                      = 0x71,\n   CEC_User_Control_F2Red                       = 0x72,\n   CEC_User_Control_F3Green                     = 0x73,\n   CEC_User_Control_F4Yellow                    = 0x74,\n   CEC_User_Control_F5                          = 0x75\n} CEC_USER_CONTROL_T;\n\n/**\n *CEC topology struct (now deprecated)\n *\n * Meaning of device_attr is as follows (one per active logical device)\n * bit 3-0 logical address (see CEC_AllDevices_T above)\n * bit 7-4 device type (see CEC_DEVICE_TYPE_T above)\n * bit 11-8 index to upstream device\n * bit 15-12 number of downstream device\n * bit 31-16 index of first 4 downstream devices\n * \n * To keep life simple we only show the first 4 connected downstream devices\n *\n */\ntypedef struct {\n   uint16_t active_mask;       /**<bit n is set if logical device n is active */\n   uint16_t num_devices;       /**<no. of bits set above, save us from counting */\n   uint32_t device_attr[16];   /**<Device attribute, see above for explanation */\n} VC_CEC_TOPOLOGY_T;\n\n/**\n * CEC message format (provided for host application's convenience\n * for encapsulating a CEC message\n */\ntypedef struct {\n   uint32_t length; //Length of CEC message without the header, so zero indicates a poll message\n   CEC_AllDevices_T initiator;\n   CEC_AllDevices_T follower;\n   uint8_t payload[CEC_MAX_XMIT_LENGTH+1]; //We actually only need 15 bytes, this payload does not include header\n} VC_CEC_MESSAGE_T;\n\n/**\n * CEC related notification\n */\ntypedef enum {\n   VC_CEC_NOTIFY_NONE     = 0,        //Reserved - NOT TO BE USED\n   VC_CEC_TX              = (1 << 0), /**<A message has been transmitted */\n   VC_CEC_RX              = (1 << 1), /**<A message has arrived (only for registered commands) */\n   VC_CEC_BUTTON_PRESSED  = (1 << 2), /**<<User Control Pressed> */\n   VC_CEC_BUTTON_RELEASE  = (1 << 3), /**<<User Control Release> */\n   VC_CEC_REMOTE_PRESSED  = (1 << 4), /**<<Vendor Remote Button Down> */\n   VC_CEC_REMOTE_RELEASE  = (1 << 5), /**<<Vendor Remote Button Up> */\n   VC_CEC_LOGICAL_ADDR    = (1 << 6), /**<New logical address allocated or released */\n   VC_CEC_TOPOLOGY        = (1 << 7), /**<Topology is available (deprecated) */\n   VC_CEC_LOGICAL_ADDR_LOST = (1 << 15) /**<Only for passive mode, if the logical address is lost for whatever reason, this will be triggered */\n} VC_CEC_NOTIFY_T;\n\n\n/**\n * Callback reason and arguments (for sending back to host) All parameters are uint32_t\n * For the reason parameter\n * Bit 15-0 of reason is the reason code, \n * Bit 23-16 is length of valid bytes which follows in the 4 32-bit parameters (0 < length <= 16)\n * Bit 31-24 is any return code (if required for this callback)\n *\n * Length of valid bytes for TX/RX/button press/release callbacks will be the length\n * of the actual CEC message\n *\n * Length of valid bytes for logical address will always be 6 (first parameter + 16-bit physical address)\n *\n * Length of valid bytes for topology callback will always be 2 (16-bit mask)\n * \n * Many CEC callback messages are of variable length so not all bytes 0-15 are available \n *\n * Reason                  param1          param2       param3      param4           remark\n * VC_CEC_TX               bytes 0-3       bytes 4-7    bytes 8-11  bytes 12-15      A message has been transmitted \n *                                                                                   Only a message sent from the host will \n                                                                                     generate this callback\n                                                                                     (non-zero return code means failure)\n                                                     \n * VC_CEC_RX               bytes 0-3       bytes 4-7    bytes 8-11  bytes 12-15      By definition only successful message will be forwarded\n *\n * VC_CEC_BUTTON_PRESSED   bytes 0-3       bytes 4-7     -           -               User Control pressed (byte 2 will be actual user control code)\n * VC_CEC_BUTTON_RELEASE   bytes 0-3          -          -           -               User Control release (byte 2 will be actual user control code)\n\n * VC_CEC_REMOTE_PRESSED   bytes 0-3       bytes 4-7    bytes 8-11  bytes 12-15      Vendor remote button down\n * VC_CEC_REMOTE_RELEASE   bytes 0-3       bytes 4-7    bytes 8-11  bytes 12-15      Vendor remote button up\n\n * VC_CEC_LOGICAL_ADDR     Log addr        Phy addr      -           -               Logical address allocated or failure\n * VC_CEC_TOPOLOGY         topology bit \n *                         mask                                                      New topology is avaiable\n *\n *VC_CEC_LOGICAL_ADDR_LOST Last log addr   Phy addr                                  \"Last log addr\" is no longer available\n *\n * Notes: \n * VC_CEC_BUTTON_RELEASE and VC_CEC_REMOTE_RELEASE (<User Control Release> and <Vendor Remote Button Up> messages respectively)\n * returns the code from the most recent <User Control pressed> <Vendor Remote button up> respectively.\n * The host application will need to find out the vendor ID of the initiator\n * separately in the case if <Vendor Remote Button Up>/<Vendor Remote Button Down> commands were received.\n * <User Control Pressed> will not be longer than 6 bytes (including header)\n *\n * VC_CEC_LOGICAL_ADDR returns 0xF in param1 whenever no logical address is in used. If physical address is 0xFFFF, \n * this means CEC is being disabled. Otherwise physical address is the one read from EDID (and no suitable logical address \n * is avaiable to be allocated). Host application should only attempt to send message if both param1 is not 0xF AND param2\n * is not 0xFFFF.\n *\n * VC_CEC_TOPOLOGY returns a 16-bit mask in param1 where bit n is set if logical address n is present. Host application\n * must explicitly retrieve the entire topology if it wants to know how devices are connected. The bit mask includes our\n * own logical address.\n *\n * If CEC is running in passive mode, the host will get a VC_CEC_LOGICAL_ADDR_LOST callback if the logical address is\n * lost (e.g. HDMI mode change). In this case the host should try a new logical address. The physical address returned may \n * also change, so the host should check this.\n */\n\n/**\n * General callback function for notifications from CEC middleware (and CEC service)\n *\n * @param client_p is the callback context passed in by user\n *\n * @param reason is the notification nature (plus message lengths, return code, etc.)\n *\n * @param param1 is the first parameter of notification (see above)\n *\n * @param param2 is the second parameter of notification (see above)\n *\n * @param param3 is the third parameter of notification (see above)\n *\n * @param param4 is the fourth parameter of notification (see above)\n *\n * @return void\n */\ntypedef void (*CEC_CALLBACK_T)(void *client_p, uint32_t reason, uint32_t param1, uint32_t param2, uint32_t param3, uint32_t param4);\n\n/**\n * Some macros to get some fields from the callback parameters in CEC callback \n */\n//Marcos operating on reason\n#define CEC_CB_REASON(x) ((x) & 0xFFFF) /** Get callback reason */\n#define CEC_CB_MSG_LENGTH(x) (((x) >> 16) & 0xFF) /** Get callback parameter length (this includes the header byte) */\n#define CEC_CB_RC(x) (((x) >> 24) & 0xFF) /** Get return value (only for TX callbacks for the moment) */\n\n//Macros operating on param1\n#define CEC_CB_INITIATOR(x) (((x) >> 4) & 0xF) /** Get the initiator from first parameter */\n#define CEC_CB_FOLLOWER(x) ((x) & 0xF) /** Get the follower from first parameter */\n#define CEC_CB_OPCODE(x) (((x) >> 8) & 0xFF) /** Get the opcode from first parameter */\n#define CEC_CB_OPERAND1(x) (((x) >> 16) & 0xFF) /** Get the button code from <User Control Pressed> or the first operand of the opcode */\n#define CEC_CB_OPERAND2(x) (((x) >> 24) & 0xFF) /** Get the second operand of opcode */\n\n//CEC service return code\ntypedef enum {\n   VC_CEC_SUCCESS                = 0, /** OK */\n   VC_CEC_ERROR_NO_ACK           = 1, /** No acknowledgement */\n   VC_CEC_ERROR_SHUTDOWN         = 2, /** In the process of shutting down */\n   VC_CEC_ERROR_BUSY             = 3, /** block is busy */\n   VC_CEC_ERROR_NO_LA            = 4, /** No logical address */\n   VC_CEC_ERROR_NO_PA            = 5, /** No physical address */\n   VC_CEC_ERROR_NO_TOPO          = 6, /** No topology */\n   VC_CEC_ERROR_INVALID_FOLLOWER = 7, /** Invalid follower */\n   VC_CEC_ERROR_INVALID_ARGUMENT = 8  /** Invalid arguments */\n} VC_CEC_ERROR_T;\n\n#endif\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vmcs_host/vc_cecservice.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n/*\n * CEC service host API, \n * See vc_cec.h and vc_cecservice_defs.h for related constants\n */\n\n#ifndef _VC_CECSERVICE_H_\n#define _VC_CECSERVICE_H_\n\n#include \"vcinclude/common.h\"\n#include \"interface/vcos/vcos.h\"\n#include \"interface/vchi/vchi.h\"\n#include \"interface/vmcs_host/vc_cecservice_defs.h\"\n#include \"interface/vmcs_host/vc_cec.h\"\n\n/**\n * \\file\n * This API defines the controls for CEC. HDMI must be powered on before\n * CEC is available (subject to CEC support in TV). \n *\n * In general, a zero return value indicates success; a negative return\n * value indicates error in VCHI layer; a positive return value indicates\n * alternative return value from the server\n */\n\n/**\n * Callback function for host side notification \n * This is the SAME as the callback function type defined in vc_cec.h\n * Host applications register a single callback for all CEC related notifications.\n * See vc_cec.h for meanings of all parameters\n *\n * @param callback_data is the context passed in by user in <DFN>vc_cec_register_callback</DFN>\n *\n * @param reason bits 15-0 is VC_CEC_NOTIFY_T in vc_cec.h;\n *               bits 23-16 is the valid length of message in param1 to param4 (LSB of param1 is the byte0, MSB of param4 is byte15), little endian\n *               bits 31-24 is the return code (if any)\n *\n * @param param1 is the first parameter\n * \n * @param param2 is the second parameter\n *\n * @param param3 is the third parameter\n *\n * @param param4 is the fourth parameter\n * \n * @return void\n */\ntypedef void (*CECSERVICE_CALLBACK_T)(void *callback_data, uint32_t reason, uint32_t param1, uint32_t param2, uint32_t param3, uint32_t param4);\n\n//API at application start time\n/**\n * Call <DFN>vc_vchi_cec_init</DFN> to initialise the CEC service for use.\n *\n * @param initialise_instance is the VCHI instance\n * @param connections are array of pointers to VCHI connections\n * @param num_connections is the number of connections in array\n * @return void\n **********************************************************/\nVCHPRE_ void vc_vchi_cec_init(VCHI_INSTANCE_T initialise_instance, VCHI_CONNECTION_T **connections, uint32_t num_connections );\n\n/**\n * Call <DFN>vc_vchi_cec_stop</DFN> to stop host side CEC service.\n *\n * @param none\n * @return void\n **********************************************************/\nVCHPRE_ void vc_vchi_cec_stop( void );\n\n/**\n * Host applications use <DFN>vc_cec_register_callaback</DFN> to register\n * callback to handle all CEC notifications. If more than one applications \n * need to use CEC, there should be ONE central application which acts on\n * behalf of all clients and handles all communications with CEC services.\n *\n * @param callback function \n * @param context to be passed when function is called\n * @return void\n ***********************************************************/\nVCHPRE_ void vc_cec_register_callback(CECSERVICE_CALLBACK_T callback, void *callback_data);\n\n//Service API\n/**\n * This function is now deprecated. Commands are always forwarded.\n *\n * <DFN>vc_cec_register_command</DFN>\n *\n * @param opcode to be registered.\n *\n * @return zero if the command is successful, non-zero otherwise\n ***********************************************************/\nVCHPRE_ int VCOS_DEPRECATED(\"has no effect\") VCHPOST_ vc_cec_register_command(CEC_OPCODE_T opcode);\n\n/**\n * This function is now deprecated. Commands are always forwarded.\n *\n * <DFN>vc_cec_register_all</DFN>\n *\n * @param None\n *\n * @return zero if the command is successful, non-zero otherwise\n ***********************************************************/\nVCHPRE_ int VCOS_DEPRECATED(\"has no effect\") VCHPOST_ vc_cec_register_all( void );\n\n\n/**\n * Use <DFN>vc_cec_deregister_command</DFN> to remove an opcode from\n * the filter for forwarding. By default <Feature Abort> is always forwarded.\n * The following opcode cannot be deregistered:\n * <User Control Pressed>, <User Control Released>, \n * <Vendor Remote Button Down>, <Vendor Remote Button Up>,\n * and <Abort>.\n *\n * @param opcode to be deregistered\n *\n * @return zero if the command is successful, non-zero otherwise\n ***********************************************************/\nVCHPRE_ int VCOS_DEPRECATED(\"has no effect\") VCHPOST_ vc_cec_deregister_command(CEC_OPCODE_T opcode);\n\n/**\n * This function is now deprecated. Commands are always forwarded.\n *\n * <DFN>vc_cec_deregister_all</DFN>\n *\n * @param None\n *\n * @return zero if the command is successful, non-zero otherwise\n ***********************************************************/\nVCHPRE_ int VCOS_DEPRECATED(\"has no effect\") VCHPOST_ vc_cec_deregister_all(void);\n\n/**\n * <DFN>vc_cec_send_message</DFN> allows a host application to \n * send a CEC message to another device. There are several \n * built-in functions for sending command messages. The host\n * application MUST have a valid logical address (between 1 and\n * 14 inclusive) before it can send a message.\n * (For poll message set payload to NULL and length to zero).\n *\n * @param Follower's logical address\n *\n * @param Message payload WITHOUT the header byte (can be NULL)\n *\n * @param Payload length WITHOUT the header byte (can be zero)\n *\n * @param VC_TRUE if the message is a reply to an incoming message\n *\n * @return zero if the command is successful, non-zero otherwise\n *         If the command is successful, there will be a Tx callback\n *         in due course to indicate whether the message has been\n *         acknowledged by the recipient or not\n ***********************************************************/\nVCHPRE_ int VCHPOST_ vc_cec_send_message(const uint32_t follower,\n                                         const uint8_t *payload,\n                                         uint32_t length,\n                                         vcos_bool_t is_reply);\n/**\n * <DFN>vc_cec_get_logical_address</DFN> gets the logical address, \n * If one is being allocated 0xF (unregistered) will be set.\n * A address value of 0xF also means CEC system is not yet ready\n * to send or receive any messages.\n *\n * @param pointer to logical address (set to allocated address)\n *\n * @return zero if the command is successful, non-zero otherwise\n *         logical_address is not modified if command failed\n ***********************************************************/\nVCHPRE_ int VCHPOST_ vc_cec_get_logical_address(CEC_AllDevices_T *logical_address);\n\n/**\n * <DFN>vc_cec_alloc_logical_address</DFN> starts the allocation \n * of a logical address. Logical address is automatically allocated\n * after HDMI power on is complete and AV mute is deassert.\n * The host only needs to call this if the \n * initial allocation failed (logical address being 0xF and \n * physical address is NOT 0xFFFF from <DFN>VC_CEC_LOGICAL_ADDR</DFN>\n * notification), or if the host explicitly released its logical \n * address.\n *\n * @param none\n *\n * @return zero if the command is successful, non-zero otherwise\n *         If successful, there will be a callback notification\n *         <DFN>VC_CEC_LOGICAL_ADDR</DFN>. \n *         The host should wait for this before calling this \n *         function again.\n ***********************************************************/\nVCHPRE_ int VCHPOST_ vc_cec_alloc_logical_address( void );\n\n/**\n * Use <DFN>vc_cec_release_logical_address</DFN> to clear\n * the set logical address. Logical address will be reset\n * back to 15 (unregistered) internally. No direct inbound\n * messages will be acknowledged. Host must call\n * vc_cec_set_logical_address with a valid logical address\n * again before attempting to send any more messages.\n *\n * @param none\n *\n * @return zero if the command is successful, non-zero otherwise\n *         The host should get a callback reason\n *         <DFN>VC_CEC_LOGICAL_ADDR</DFN> with 0xF being the\n *         logical address and the current physical address.\n ***********************************************************/\nVCHPRE_ int VCHPOST_ vc_cec_release_logical_address( void );\n\n/**\n * This function is now deprecated. Topology is always\n * returned as a zeroed block of data.\n *\n * Use <DFN>vc_cec_get_topology</DFN> to get the topology.\n *\n * @param pointer to <DFN>VC_CEC_TOPOLOGY_T</DFN>\n *\n * @return zero if the command is successful, non-zero otherwise\n *\n ***********************************************************/\nVCHPRE_ int VCOS_DEPRECATED(\"returns invalid result\") VCHPOST_ vc_cec_get_topology( VC_CEC_TOPOLOGY_T* topology);\n\n/**\n * Use <DFN>vc_cec_set_vendor_id</DFN> to \n * set the response to <Give Device Vendor ID>\n *\n * @param 24-bit IEEE vendor id\n *\n * @return zero if the command is successful, non-zero otherwise\n ***********************************************************/\nVCHPRE_ int VCHPOST_ vc_cec_set_vendor_id( const uint32_t id );\n\n/**\n * Use <DFN>vc_cec_set_osd_name</DFN> to\n * set the response to <Give OSD Name>\n * \n * @param OSD name (14 byte char array)\n *\n * @return zero if the command is successful, non-zero otherwise\n ***********************************************************/\nVCHPRE_ int VCHPOST_ vc_cec_set_osd_name( const char* name );\n\n/**\n * <DFN>vc_cec_get_physical_address</DFN> gets our physical address\n *\n * @param pointer to physical address (returned as 16-bit packed value)\n *\n * @return zero if the command is successful, non-zero otherwise\n *          If failed, physical address argument will not be changed\n *          A physical address of 0xFFFF means CEC is not supported\n ***********************************************************/\nVCHPRE_ int VCHPOST_ vc_cec_get_physical_address(uint16_t *physical_address);\n\n/**\n * <DFN>vc_cec_get_vendor_id(</DFN> gets the vendor id of a particular logical address\n *\n * @param logical_address is the logical address of the device [in]\n *\n * @param vendorid is the pointer to vendor ID (24-bit IEEE OUI value) [out]\n *\n * @return zero if the command is successful, non-zero otherwise\n *         If failed, vendor id argument will not be changed\n *         A vendor ID of 0xFFFFFF means the device does not exist\n *         A vendor ID of 0x0 means vendor ID is not known and\n *         the application can send <Give Device Vendor ID> to that device\n ***********************************************************/\nVCHPRE_ int VCHPOST_ vc_cec_get_vendor_id(const CEC_AllDevices_T logical_address, uint32_t *vendor_id);\n\n/**\n * <DFN>vc_cec_device_type(</DFN> returns the default device type of a particular\n * logical address, which can be used as the argument to vc_cec_send_ReportPhysicalAddress.\n *\n * @param logical address\n *\n * @return the default device type, if there is any error, the return device\n *         type will be CEC_DeviceType_Invalid\n *\n ************************************************************/\nVCHPRE_ CEC_DEVICE_TYPE_T VCHPOST_ vc_cec_device_type(const CEC_AllDevices_T logical_address);\n\n/**\n * These couple of functions are provided for host application's convenience:\n * If the xmit message is encapsulate in a VC_CEC_MESSAGE_T\n * then it can be sent as a normal message (not as a reply)\n * and the initiator field is ignored with vc_cec_send_message2\n * and return zero for success\n * \n * Applications can call vc_cec_param2message to turn the callback parameters\n * into a VC_CEC_MESSAGE_T (not for LOGICAL_ADDR callbacks).\n * It also returns zero for success.\n */\nVCHPRE_ int VCHPOST_ vc_cec_send_message2(const VC_CEC_MESSAGE_T *message);\n\nVCHPRE_ int VCHPOST_ vc_cec_param2message( const uint32_t reason, const uint32_t param1, \n                                           const uint32_t param2, const uint32_t param3,\n                                           const uint32_t param4, VC_CEC_MESSAGE_T *message);\n\n//Extra API if CEC is running in passive mode\n//If CEC is not in passive mode the following 3 functions always\n//return failure\n/**\n * <DFN> vc_cec_poll_address </DFN> sets and polls a particular address to find out\n * its availability in the CEC network. Only available when CEC is running in passive\n * mode. The host can only call this function during logical address allocation stage.\n *\n * @param logical address to try\n *\n * @return 0 if poll is successful (address is occupied)\n *        >0 if poll is unsuccessful (Error code is in VC_CEC_ERROR_T in vc_cec.h)\n *        <0 VCHI errors\n */\nVCHPRE_ int VCHPOST_ vc_cec_poll_address(const CEC_AllDevices_T logical_address);\n\n/**\n * <DFN> vc_cec_set_logical_address </DFN> sets the logical address, device type\n * and vendor ID to be in use. Only available when CEC is running in passive\n * mode. It is the responsibility of the host to make sure the logical address\n * is actually free to be used. Physical address will be what is read from EDID.\n *\n * @param logical address\n *\n * @param device type\n *\n * @param vendor ID\n *\n * @return 0 if successful, non-zero otherwise\n */\nVCHPRE_ int VCHPOST_ vc_cec_set_logical_address(const CEC_AllDevices_T logical_address,\n                                                const CEC_DEVICE_TYPE_T device_type,\n                                                const uint32_t vendor_id);\n\n/**\n * This function is now deprecated and has no effect.\n *\n * <DFN> vc_cec_add_device </DFN>\n *\n * @return 0 if successful, non-zero otherwise\n */\nVCHPRE_ int VCOS_DEPRECATED(\"has no effect\") VCHPOST_\n    vc_cec_add_device(const CEC_AllDevices_T logical_address,\n                      const uint16_t physical_address,\n                      const CEC_DEVICE_TYPE_T device_type,\n                      vcos_bool_t last_device);\n\n/**\n * <DFN> vc_cec_set_passive </DFN> enables and disables passive mode.\n * Call this function first (with VC_TRUE as the argument) to enable\n * passive mode before calling any of the above passive API functions\n *\n * @param TRUE to enable passive mode, FALSE to disable\n * \n * @return 0 if successful, non-zero otherwise\n */\nVCHPRE_ int VCHPOST_ vc_cec_set_passive(vcos_bool_t enabled);\n\n\n//API for some common CEC messages\n/** \n * Functions beginning with vc_cec_send_xxx make it easier for the \n * host application to send CEC message xxx to other devices\n */\n/**\n * <DFN>vc_cec_send_FeatureAbort</DFN> sends <Feature Abort> \n * for a received command.\n *\n * @param follower (cannot be 0xF)\n *\n * @param rejected opcode\n *\n * @param reject reason <DFN>CEC_ABORT_REASON_T</DFN>\n *\n * @return zero if the command is successful, non-zero otherwise\n *         Tx callback if successful\n ***********************************************************/\nVCHPRE_ int VCHPOST_ vc_cec_send_FeatureAbort(uint32_t follower, \n                                              CEC_OPCODE_T opcode, \n                                              CEC_ABORT_REASON_T reason);\n\n/**\n * <DFN>vc_cec_send_ActiveSource</DFN> broadcasts\n * <Active Source> to all devices\n *\n * @param physical address (16-bit packed)\n *\n * @param reply or not (normally not)\n *\n * @return zero if the command is successful, non-zero otherwise\n *         Tx callback if successful\n ***********************************************************/\nVCHPRE_ int VCHPOST_ vc_cec_send_ActiveSource(uint16_t physical_address, vcos_bool_t is_reply);\n\n/**\n * <DFN>vc_cec_send_ImageViewOn</DFN> sends <Image View On>\n * \n * @param follower\n *\n * @param reply or not (normally not)\n *\n * @return zero if the command is successful, non-zero otherwise\n *         Tx callback if successful\n ***********************************************************/\nVCHPRE_ int VCHPOST_ vc_cec_send_ImageViewOn(uint32_t follower, vcos_bool_t is_reply);\n\n/**\n * <DFN>vc_cec_send_SetOSDString</DFN> sends <Set OSD String>\n *\n * @param follower \n *\n * @param string (char[13]) \n *\n * @param display control <DFN>CEC_DISPLAY_CONTROL_T</DFN>\n *\n * @param reply or not (normally not)\n *\n * @return zero if the command is successful, non-zero otherwise\n *         Tx callback if successful\n ***********************************************************/\nVCHPRE_ int VCHPOST_ vc_cec_send_SetOSDString(uint32_t follower, \n                                              CEC_DISPLAY_CONTROL_T disp_ctrl, \n                                              const char* string,\n                                              vcos_bool_t is_reply);\n\n/**\n * <DFN>vc_cec_send_Standby</DFN> sends <Standby>.\n * This will put any/all devices to standby if they support\n * this CEC message.\n *\n * @param follower (can be 0xF)\n *\n * @param reply or not (normally not)\n *\n * @return zero if the command is successful, non-zero otherwise\n *         Tx callback if successful\n ***********************************************************/\nVCHPRE_ int VCHPOST_ vc_cec_send_Standby(uint32_t follower, vcos_bool_t is_reply);\n\n/**\n * <DFN>vc_cec_send_MenuStatus</DFN> sends <Menu Status> \n * (response to <Menu Request>)\n *\n * @param follower\n * \n * @param menu state <DFN>CEC_MENU_STATE_T</DFN> but NOT CEC_MENU_STATE_QUERY\n *\n * @param reply or not (should always be yes)\n *\n * @return zero if the command is successful, non-zero otherwise\n *         Tx callback if successful\n ***********************************************************/\nVCHPRE_ int VCHPOST_ vc_cec_send_MenuStatus(uint32_t follower, \n                                            CEC_MENU_STATE_T menu_state, \n                                            vcos_bool_t is_reply);\n\n/**\n * <DFN>vc_cec_send_ReportPhysicalAddress</DFN> broadcasts\n * <Report Physical Address> to all devices. Note although\n * the passed in device type can be override the default one \n * associated the allocated logical address, it is not \n * recommended to do so. One can use <DFN>vc_cec_device_type</DFN>\n * to get the default device type associated with the logical \n * address returned via VC_CEC_LOGICAL_ADDR callback.\n *\n * @param physical address (16-bit packed)\n *\n * @param device type to be broadcasted\n *\n * @param reply or not (normally not)\n *\n * @return zero if the command is successful, non-zero otherwise\n *         Tx callback if successful\n ***********************************************************/\nVCHPRE_ int VCHPOST_ vc_cec_send_ReportPhysicalAddress(uint16_t physical_address, \n                                                       CEC_DEVICE_TYPE_T device_type,\n                                                       vcos_bool_t is_reply);\n\n#endif //_VC_CECSERVICE_H_\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vmcs_host/vc_cecservice_defs.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n/*\n * CEC service command enumeration and parameter types.\n */\n\n/**\n * \\file\n * This file contains definition shared by host side and\n * Videocore side CEC service:\n *\n * In general, a zero return value indicates success of the function\n * A non-zero value indicates VCHI error\n * A positive value indicates alternative return value (for some functions).\n *\n */\n\n\n#ifndef _VC_CECSERVICE_DEFS_H_\n#define _VC_CECSERVICE_DEFS_H_\n#include \"vcinclude/common.h\"\n#include \"interface/vcos/vcos.h\"\n#include \"interface/vcos/vcos_logging.h\"\n#include \"interface/vchi/message_drivers/message.h\"\n\n//CEC VCOS logging stuff\n#define CECHOST_LOG_CATEGORY (&cechost_log_category)\n#define vc_cec_log_trace(...) _VCOS_LOG_X(CECHOST_LOG_CATEGORY, VCOS_LOG_TRACE, __VA_ARGS__)\n#define vc_cec_log_warn(...)  _VCOS_LOG_X(CECHOST_LOG_CATEGORY, VCOS_LOG_WARN, __VA_ARGS__)\n#define vc_cec_log_error(...) _VCOS_LOG_X(CECHOST_LOG_CATEGORY, VCOS_LOG_ERROR, __VA_ARGS__)\n#define vc_cec_log_info(...)  _VCOS_LOG_X(CECHOST_LOG_CATEGORY, VCOS_LOG_INFO, __VA_ARGS__)\nextern VCOS_LOG_CAT_T cechost_log_category; //The actual object lives in CEC host side service code\n\n#define VC_CECSERVICE_VER 1\n#define CECSERVICE_MSGFIFO_SIZE 1024\n#define CECSERVICE_CLIENT_NAME MAKE_FOURCC(\"CECS\")\n#define CECSERVICE_NOTIFY_NAME MAKE_FOURCC(\"CECN\")\n\n//CEC service commands\ntypedef enum {\n   VC_CEC_REGISTER_CMD = 0,\n   VC_CEC_REGISTER_ALL,\n   VC_CEC_DEREGISTER_CMD,\n   VC_CEC_DEREGISTER_ALL,\n   VC_CEC_SEND_MSG,\n   VC_CEC_GET_LOGICAL_ADDR,\n   VC_CEC_ALLOC_LOGICAL_ADDR,\n   VC_CEC_RELEASE_LOGICAL_ADDR,\n   VC_CEC_GET_TOPOLOGY,\n   VC_CEC_SET_VENDOR_ID,\n   VC_CEC_SET_OSD_NAME,\n   VC_CEC_GET_PHYSICAL_ADDR,\n   VC_CEC_GET_VENDOR_ID,\n\n   //The following 3 commands are used when CEC middleware is \n   //running in passive mode (i.e. it does not allocate \n   //logical address automatically)\n   VC_CEC_POLL_ADDR,\n   VC_CEC_SET_LOGICAL_ADDR,\n   VC_CEC_ADD_DEVICE,\n   VC_CEC_SET_PASSIVE,\n   //Add more commands here\n   VC_CEC_END_OF_LIST\n} VC_CEC_CMD_CODE_T;\n\n//See vc_cec.h for details\n//REGISTER_CMD\n//Parameters: opcode to register (CEC_OPCODE_T sent as uint32)\n//Reply: none\n\n//REGISTER_ALL\n//Parameters: none\n//Reply: none\n\n//DEREGISTER_CMD\n//Parameters: opcode to deregister (CEC_OPCODE_T sent as uint32)\n//Reply: none\n\n//DEREGISTER_ALL\n//Parameters: none\n//Reply: none\n\n//SEND_MSG\n//Parameters: destination, length, 16 bytes buffer (message can only be at most 15 bytes however)\n//Reply: none (callback)\ntypedef struct {\n   uint32_t follower;\n   uint32_t length;\n   uint8_t payload[16]; //max. 15 bytes padded to 16\n   uint32_t is_reply;   //non-zero if this is a reply, zero otherwise\n} CEC_SEND_MSG_PARAM_T;\n\n//GET_LOGICAL_ADDR\n//Parameters: none\n//Reply: logical address (uint8 returned as uint32)\n\n//ALLOC_LOGICAL_ADDR\n//Parameters: none\n//Reply: none (callback)\n\n//GET_TOPOLOGY\n//Parameters: none\n//Reply: topology (see VC_TOPOLOGY_T)\n\n//SET_VENDOR_ID\n//Parameters: vendor id (uint32)\n//Reply: none\n\n//Set OSD name\n//Parameters: 14 byte char\n//Reply: none\n#define OSD_NAME_LENGTH 14\n\n//GET_PHYSICAL_ADDR\n//Parameter: none\n//Reply: packed physical address returned as uint16\n\n//GET_VENDOR_ID\n//Parameter: logical address (CEC_AllDevices_T sent as uint32_t)\n//Reply: (uint32_t vendor id)\n\n//POLL_LOGICAL_ADDR (only for passive mode)\n//Used by host to test a logical address to see if it is available for use\n//Only available if CEC is compiled in passive mode and while the host\n//is testing the availability of a logical address\n//Parameter: logical address\n//Reply: \n\n//SET_LOGICAL_ADDR [(only for passive mode) This will be changed when we support multiple logical addresses]\n//Set the logical address used \n//Only available if CEC is compiled in passive mode\n//Parameter: logical address, device type, vendor ID\n//Reply: (int32_t - zero means success, non-zero otherwise)\n//This function will result in a VC_CEC_LOGICAL_ADDR callback\ntypedef struct {\n   uint32_t logical_address;\n   uint32_t device_type;\n   uint32_t vendor_id;\n} CEC_SET_LOGICAL_ADDR_PARAM_T;\n   \n//ADD_DEVICE (only for passive mode)\n//Only available if CEC is compiled in passive mode\n//Parameter: logical address, physical address, device type, last device?\n//Reply: (int32_t - zero means success, non-zero otherwise)\ntypedef struct {\n   uint32_t logical_address;  /**<logical address */\n   uint32_t physical_address; /**<16-bit packed physical address in big endian */\n   uint32_t device_type;      /**<CEC_DEVICE_TYPE_T */\n   uint32_t last_device;      /**<True (non-zero) or false (zero) */\n} CEC_ADD_DEVICE_PARAM_T;\n\n//SET PASSIVE (only for passive mode)\n//Enable/disable passive mode\n//Parameter: non-zero to enable passive mode, zero to disable\n//Reply: (int32_t - zero means success, non-zero otherwise, non zero will be VCHI errors)\n\n#endif //#ifndef _VC_CECSERVICE_DEFS_H_\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vmcs_host/vc_cma.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n#ifndef _VC_CMA_H_\n#define _VC_CMA_H_\n\n#include \"interface/vcos/vcos.h\"\n#include \"interface/vchiq_arm/vchiq.h\"\n\n#ifdef __linux__\n\n#include <linux/ioctl.h>\n\n#define VC_CMA_IOC_MAGIC 0xc5\n\n#define VC_CMA_IOC_RESERVE _IO(VC_CMA_IOC_MAGIC, 0)\n\n#endif\n\n#define VC_CMA_FOURCC VCHIQ_MAKE_FOURCC('C','M','A',' ')\n#define VC_CMA_VERSION 2\n\n#define VC_CMA_CHUNK_ORDER 6  /* 256K */\n#define VC_CMA_CHUNK_SIZE (4096 << VC_CMA_CHUNK_ORDER)\n#define VC_CMA_MAX_PARAMS_PER_MSG ((VCHIQ_MAX_MSG_SIZE - sizeof(unsigned short)) / sizeof(unsigned short))\n\nenum\n{\n   VC_CMA_MSG_QUIT,\n   VC_CMA_MSG_OPEN,\n   VC_CMA_MSG_TICK,\n   VC_CMA_MSG_ALLOC,     /* chunk count */\n   VC_CMA_MSG_FREE,      /* chunk, chunk, ... */\n   VC_CMA_MSG_ALLOCATED, /* chunk, chunk, ... */\n   VC_CMA_MSG_REQUEST_ALLOC, /* chunk count */\n   VC_CMA_MSG_REQUEST_FREE,  /* chunk count */\n   VC_CMA_MSG_RESERVE,   /* bytes lo, bytes hi */\n   VC_CMA_MSG_MAX\n};\n\ntypedef struct vc_cma_msg_struct\n{\n    unsigned short type;\n    unsigned short params[VC_CMA_MAX_PARAMS_PER_MSG];\n} VC_CMA_MSG_T;\n\n#endif\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vmcs_host/vc_dispmanx.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n// Display manager service API\n\n#ifndef _VC_DISPMANX_H_\n#define _VC_DISPMANX_H_\n\n#include \"interface/vcos/vcos.h\"\n#include \"interface/vctypes/vc_image_types.h\"\n#include \"vc_dispservice_x_defs.h\"\n#include \"interface/vmcs_host/vc_dispmanx_types.h\"\n#include \"interface/vchi/vchi.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n// Same function as above, to aid migration of code.\nVCHPRE_ int VCHPOST_ vc_dispman_init( void );\n// Stop the service from being used\nVCHPRE_ void VCHPOST_ vc_dispmanx_stop( void );\n// Set the entries in the rect structure\nVCHPRE_ int VCHPOST_ vc_dispmanx_rect_set( VC_RECT_T *rect, uint32_t x_offset, uint32_t y_offset, uint32_t width, uint32_t height );\n// Resources\n// Create a new resource\nVCHPRE_ DISPMANX_RESOURCE_HANDLE_T VCHPOST_ vc_dispmanx_resource_create( VC_IMAGE_TYPE_T type, uint32_t width, uint32_t height, uint32_t *native_image_handle );\n// Write the bitmap data to VideoCore memory\nVCHPRE_ int VCHPOST_ vc_dispmanx_resource_write_data( DISPMANX_RESOURCE_HANDLE_T res, VC_IMAGE_TYPE_T src_type, int src_pitch, void * src_address, const VC_RECT_T * rect );\nVCHPRE_ int VCHPOST_ vc_dispmanx_resource_write_data_handle( DISPMANX_RESOURCE_HANDLE_T res, VC_IMAGE_TYPE_T src_type, int src_pitch, VCHI_MEM_HANDLE_T handle, uint32_t offset, const VC_RECT_T * rect );\nVCHPRE_ int VCHPOST_ vc_dispmanx_resource_read_data(\n                              DISPMANX_RESOURCE_HANDLE_T handle,\n                              const VC_RECT_T* p_rect,\n                              void *   dst_address,\n                              uint32_t dst_pitch );\n// Delete a resource\nVCHPRE_ int VCHPOST_ vc_dispmanx_resource_delete( DISPMANX_RESOURCE_HANDLE_T res );\n\n// Displays\n// Opens a display on the given device\nVCHPRE_ DISPMANX_DISPLAY_HANDLE_T VCHPOST_ vc_dispmanx_display_open( uint32_t device );\n// Opens a display on the given device in the request mode\nVCHPRE_ DISPMANX_DISPLAY_HANDLE_T VCHPOST_ vc_dispmanx_display_open_mode( uint32_t device, uint32_t mode );\n// Open an offscreen display\nVCHPRE_ DISPMANX_DISPLAY_HANDLE_T VCHPOST_ vc_dispmanx_display_open_offscreen( DISPMANX_RESOURCE_HANDLE_T dest, DISPMANX_TRANSFORM_T orientation );\n// Change the mode of a display\nVCHPRE_ int VCHPOST_ vc_dispmanx_display_reconfigure( DISPMANX_DISPLAY_HANDLE_T display, uint32_t mode );\n// Sets the desstination of the display to be the given resource\nVCHPRE_ int VCHPOST_ vc_dispmanx_display_set_destination( DISPMANX_DISPLAY_HANDLE_T display, DISPMANX_RESOURCE_HANDLE_T dest );\n// Set the background colour of the display\nVCHPRE_ int VCHPOST_ vc_dispmanx_display_set_background( DISPMANX_UPDATE_HANDLE_T update, DISPMANX_DISPLAY_HANDLE_T display,\n                                                                       uint8_t red, uint8_t green, uint8_t blue );\n// get the width, height, frame rate and aspect ratio of the display\nVCHPRE_ int VCHPOST_ vc_dispmanx_display_get_info( DISPMANX_DISPLAY_HANDLE_T display, DISPMANX_MODEINFO_T * pinfo );\n// Closes a display\nVCHPRE_ int VCHPOST_ vc_dispmanx_display_close( DISPMANX_DISPLAY_HANDLE_T display );\n\n// Updates\n// Start a new update, DISPMANX_NO_HANDLE on error\nVCHPRE_ DISPMANX_UPDATE_HANDLE_T VCHPOST_ vc_dispmanx_update_start( int32_t priority );\n// Add an elment to a display as part of an update\nVCHPRE_ DISPMANX_ELEMENT_HANDLE_T VCHPOST_ vc_dispmanx_element_add ( DISPMANX_UPDATE_HANDLE_T update, DISPMANX_DISPLAY_HANDLE_T display,\n                                                                     int32_t layer, const VC_RECT_T *dest_rect, DISPMANX_RESOURCE_HANDLE_T src,\n                                                                     const VC_RECT_T *src_rect, DISPMANX_PROTECTION_T protection, \n                                                                     VC_DISPMANX_ALPHA_T *alpha,\n                                                                     DISPMANX_CLAMP_T *clamp, DISPMANX_TRANSFORM_T transform );\n// Change the source image of a display element\nVCHPRE_ int VCHPOST_ vc_dispmanx_element_change_source( DISPMANX_UPDATE_HANDLE_T update, DISPMANX_ELEMENT_HANDLE_T element,\n                                                        DISPMANX_RESOURCE_HANDLE_T src );\n// Change the layer number of a display element\nVCHPRE_ int VCHPOST_ vc_dispmanx_element_change_layer ( DISPMANX_UPDATE_HANDLE_T update, DISPMANX_ELEMENT_HANDLE_T element,\n                                                        int32_t layer );\n// Signal that a region of the bitmap has been modified\nVCHPRE_ int VCHPOST_ vc_dispmanx_element_modified( DISPMANX_UPDATE_HANDLE_T update, DISPMANX_ELEMENT_HANDLE_T element, const VC_RECT_T * rect );\n// Remove a display element from its display\nVCHPRE_ int VCHPOST_ vc_dispmanx_element_remove( DISPMANX_UPDATE_HANDLE_T update, DISPMANX_ELEMENT_HANDLE_T element );\n// Ends an update\nVCHPRE_ int VCHPOST_ vc_dispmanx_update_submit( DISPMANX_UPDATE_HANDLE_T update, DISPMANX_CALLBACK_FUNC_T cb_func, void *cb_arg );\n// End an update and wait for it to complete\nVCHPRE_ int VCHPOST_ vc_dispmanx_update_submit_sync( DISPMANX_UPDATE_HANDLE_T update );\n// Query the image formats supported in the VMCS build\nVCHPRE_ int VCHPOST_ vc_dispmanx_query_image_formats( uint32_t *supported_formats );\n\n//New function added to VCHI to change attributes, set_opacity does not work there.\nVCHPRE_ int VCHPOST_ vc_dispmanx_element_change_attributes( DISPMANX_UPDATE_HANDLE_T update, \n                                                            DISPMANX_ELEMENT_HANDLE_T element,\n                                                            uint32_t change_flags,\n                                                            int32_t layer,\n                                                            uint8_t opacity,\n                                                            const VC_RECT_T *dest_rect,\n                                                            const VC_RECT_T *src_rect,\n                                                            DISPMANX_RESOURCE_HANDLE_T mask,\n                                                            DISPMANX_TRANSFORM_T transform );\n\n//xxx hack to get the image pointer from a resource handle, will be obsolete real soon\nVCHPRE_ uint32_t VCHPOST_ vc_dispmanx_resource_get_image_handle( DISPMANX_RESOURCE_HANDLE_T res);\n\n//Call this instead of vc_dispman_init\nVCHPRE_ void VCHPOST_ vc_vchi_dispmanx_init (VCHI_INSTANCE_T initialise_instance, VCHI_CONNECTION_T **connections, uint32_t num_connections );\n\n// Take a snapshot of a display in its current state.\n// This call may block for a time; when it completes, the snapshot is ready.\n// only transform=0 is supported\nVCHPRE_ int VCHPOST_ vc_dispmanx_snapshot( DISPMANX_DISPLAY_HANDLE_T display, \n                                           DISPMANX_RESOURCE_HANDLE_T snapshot_resource, \n                                           DISPMANX_TRANSFORM_T transform );\n\n// Set the resource palette (for VC_IMAGE_4BPP and VC_IMAGE_8BPP)\nVCHPRE_ int VCHPOST_ vc_dispmanx_resource_set_palette( DISPMANX_RESOURCE_HANDLE_T handle, \n                                                      void * src_address, int offset, int size);\n\n// Start triggering callbacks synced to vsync\nVCHPRE_ int VCHPOST_ vc_dispmanx_vsync_callback( DISPMANX_DISPLAY_HANDLE_T display, DISPMANX_CALLBACK_FUNC_T cb_func, void *cb_arg );\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif // _VC_DISPMANX_H_\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vmcs_host/vc_dispmanx_types.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n// Typedefs and enums for the VideoCore III Display Manager\n\n#ifndef _DISPMANX_TYPES_H\n#define _DISPMANX_TYPES_H\n\n#include \"interface/vctypes/vc_image_types.h\"\n#include \"interface/vctypes/vc_display_types.h\"\n\n#define VC_DISPMANX_VERSION   1\n\n/* Opaque handles */\ntypedef uint32_t DISPMANX_DISPLAY_HANDLE_T;\ntypedef uint32_t DISPMANX_UPDATE_HANDLE_T;\ntypedef uint32_t DISPMANX_ELEMENT_HANDLE_T;\ntypedef uint32_t DISPMANX_RESOURCE_HANDLE_T;\n\ntypedef uint32_t DISPMANX_PROTECTION_T;\n\n#define DISPMANX_NO_HANDLE 0\n\n#define DISPMANX_PROTECTION_MAX   0x0f\n#define DISPMANX_PROTECTION_NONE  0\n#define DISPMANX_PROTECTION_HDCP  11   // Derived from the WM DRM levels, 101-300\n\n\n\n/* Default display IDs.\n   Note: if you overwrite with your own dispmanx_platform_init function, you\n   should use IDs you provided during dispmanx_display_attach.\n*/\n#define DISPMANX_ID_MAIN_LCD  0\n#define DISPMANX_ID_AUX_LCD   1\n#define DISPMANX_ID_HDMI      2\n#define DISPMANX_ID_SDTV      3\n#define DISPMANX_ID_FORCE_LCD 4\n#define DISPMANX_ID_FORCE_TV  5\n#define DISPMANX_ID_FORCE_OTHER 6 /* non-default display */\n\n/* Return codes. Nonzero ones indicate failure. */\ntypedef enum {\n  DISPMANX_SUCCESS      = 0,\n  DISPMANX_INVALID      = -1\n  /* XXX others TBA */\n} DISPMANX_STATUS_T;\n\ntypedef enum {\n  /* Bottom 2 bits sets the orientation */\n  DISPMANX_NO_ROTATE = 0,\n  DISPMANX_ROTATE_90 = 1,\n  DISPMANX_ROTATE_180 = 2,\n  DISPMANX_ROTATE_270 = 3,\n\n  DISPMANX_FLIP_HRIZ = 1 << 16,\n  DISPMANX_FLIP_VERT = 1 << 17,\n\n  /* invert left/right images */\n  DISPMANX_STEREOSCOPIC_INVERT =  1 << 19,\n  /* extra flags for controlling 3d duplication behaviour */\n  DISPMANX_STEREOSCOPIC_NONE   =  0 << 20,\n  DISPMANX_STEREOSCOPIC_MONO   =  1 << 20,\n  DISPMANX_STEREOSCOPIC_SBS    =  2 << 20,\n  DISPMANX_STEREOSCOPIC_TB     =  3 << 20,\n  DISPMANX_STEREOSCOPIC_MASK   = 15 << 20,\n\n  /* extra flags for controlling snapshot behaviour */\n  DISPMANX_SNAPSHOT_NO_YUV = 1 << 24,\n  DISPMANX_SNAPSHOT_NO_RGB = 1 << 25,\n  DISPMANX_SNAPSHOT_FILL = 1 << 26,\n  DISPMANX_SNAPSHOT_SWAP_RED_BLUE = 1 << 27,\n  DISPMANX_SNAPSHOT_PACK = 1 << 28\n} DISPMANX_TRANSFORM_T;\n\ntypedef enum {\n  /* Bottom 2 bits sets the alpha mode */\n  DISPMANX_FLAGS_ALPHA_FROM_SOURCE = 0,\n  DISPMANX_FLAGS_ALPHA_FIXED_ALL_PIXELS = 1,\n  DISPMANX_FLAGS_ALPHA_FIXED_NON_ZERO = 2,\n  DISPMANX_FLAGS_ALPHA_FIXED_EXCEED_0X07 = 3,\n\n  DISPMANX_FLAGS_ALPHA_PREMULT = 1 << 16,\n  DISPMANX_FLAGS_ALPHA_MIX = 1 << 17\n} DISPMANX_FLAGS_ALPHA_T;\n\ntypedef struct {\n  DISPMANX_FLAGS_ALPHA_T flags;\n  uint32_t opacity;\n  VC_IMAGE_T *mask;\n} DISPMANX_ALPHA_T;\n\ntypedef struct {\n  DISPMANX_FLAGS_ALPHA_T flags;\n  uint32_t opacity;\n  DISPMANX_RESOURCE_HANDLE_T mask;\n} VC_DISPMANX_ALPHA_T;  /* for use with vmcs_host */\n\ntypedef enum {\n  DISPMANX_FLAGS_CLAMP_NONE = 0,\n  DISPMANX_FLAGS_CLAMP_LUMA_TRANSPARENT = 1,\n#if __VCCOREVER__ >= 0x04000000\n  DISPMANX_FLAGS_CLAMP_TRANSPARENT = 2,\n  DISPMANX_FLAGS_CLAMP_REPLACE = 3\n#else\n  DISPMANX_FLAGS_CLAMP_CHROMA_TRANSPARENT = 2,\n  DISPMANX_FLAGS_CLAMP_TRANSPARENT = 3\n#endif\n} DISPMANX_FLAGS_CLAMP_T;\n\ntypedef enum {\n  DISPMANX_FLAGS_KEYMASK_OVERRIDE = 1,\n  DISPMANX_FLAGS_KEYMASK_SMOOTH = 1 << 1,\n  DISPMANX_FLAGS_KEYMASK_CR_INV = 1 << 2,\n  DISPMANX_FLAGS_KEYMASK_CB_INV = 1 << 3,\n  DISPMANX_FLAGS_KEYMASK_YY_INV = 1 << 4\n} DISPMANX_FLAGS_KEYMASK_T;\n\ntypedef union {\n  struct {\n    uint8_t yy_upper;\n    uint8_t yy_lower;\n    uint8_t cr_upper;\n    uint8_t cr_lower;\n    uint8_t cb_upper;\n    uint8_t cb_lower;\n  } yuv;\n  struct {\n    uint8_t red_upper;\n    uint8_t red_lower;\n    uint8_t blue_upper;\n    uint8_t blue_lower;\n    uint8_t green_upper;\n    uint8_t green_lower;\n  } rgb;\n} DISPMANX_CLAMP_KEYS_T;\n\ntypedef struct {\n  DISPMANX_FLAGS_CLAMP_T mode;\n  DISPMANX_FLAGS_KEYMASK_T key_mask;\n  DISPMANX_CLAMP_KEYS_T key_value;\n  uint32_t replace_value;\n} DISPMANX_CLAMP_T;\n\ntypedef struct {\n  int32_t width;\n  int32_t height;\n  DISPMANX_TRANSFORM_T transform;\n  DISPLAY_INPUT_FORMAT_T input_format;\n  uint32_t display_num;\n} DISPMANX_MODEINFO_T;\n\n/* Update callback. */\ntypedef void (*DISPMANX_CALLBACK_FUNC_T)(DISPMANX_UPDATE_HANDLE_T u, void * arg);\n\n/* Progress callback */\ntypedef void (*DISPMANX_PROGRESS_CALLBACK_FUNC_T)(DISPMANX_UPDATE_HANDLE_T u,\n                                                  uint32_t line,\n                                                  void * arg);\n\n/* Pluggable display interface */\n\ntypedef struct tag_DISPMANX_DISPLAY_FUNCS_T {\n   // Get essential HVS configuration to be passed to the HVS driver. Options\n   // is any combination of the following flags: HVS_ONESHOT, HVS_FIFOREG,\n   // HVS_FIFO32, HVS_AUTOHSTART, HVS_INTLACE; and if HVS_FIFOREG, one of;\n   // { HVS_FMT_RGB888, HVS_FMT_RGB565, HVS_FMT_RGB666, HVS_FMT_YUV }.\n   int32_t (*get_hvs_config)(void *instance, uint32_t *pchan,\n                             uint32_t *poptions, DISPLAY_INFO_T *info,\n                             uint32_t *bg_colour, uint32_t *test_mode);\n   \n   // Get optional HVS configuration for gamma tables, OLED matrix and dither controls.\n   // Set these function pointers to NULL if the relevant features are not required.\n   int32_t (*get_gamma_params)(void * instance,\n                               int32_t gain[3], int32_t offset[3], int32_t gamma[3]);\n   int32_t (*get_oled_params)(void * instance, uint32_t * poffsets,\n                              uint32_t coeffs[3]);\n   int32_t (*get_dither)(void * instance, uint32_t * dither_depth, uint32_t * dither_type);\n   \n   // Get mode information, which may be returned to the applications as a courtesy.\n   // Transform should be set to 0, and {width,height} should be final dimensions.\n   int32_t (*get_info)(void * instance, DISPMANX_MODEINFO_T * info);\n   \n   // Inform driver that the application refcount has become nonzero / zero\n   // These callbacks might perhaps be used for backlight and power management.\n   int32_t (*open)(void * instance);\n   int32_t (*close)(void * instance);\n   \n   // Display list updated callback. Primarily of use to a \"one-shot\" display.\n   // For convenience of the driver, we pass the register address of the HVS FIFO.\n   void (*dlist_updated)(void * instance, volatile uint32_t * fifo_reg);\n   \n   // End-of-field callback. This may occur in an interrupt context.\n   void (*eof_callback)(void * instance);\n\n   // Return screen resolution format\n   DISPLAY_INPUT_FORMAT_T (*get_input_format)(void * instance);\n\n   int32_t (*suspend_resume)(void *instance, int up);\n\n   DISPLAY_3D_FORMAT_T (*get_3d_format)(void * instance);\n} DISPMANX_DISPLAY_FUNCS_T;\n\n#endif /* ifndef _DISPMANX_TYPES_H */\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vmcs_host/vc_dispservice_defs.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n#ifndef VC_DISPSERVICE_DEFS_H\n#define VC_DISPSERVICE_DEFS_H\n\n#define  HOST_PITCH_ALIGNMENT    4\n\n//Round up to the nearest multiple of 16\n#define  PAD16(x) (((x) + (VC_INTERFACE_BLOCK_SIZE-1)) & ~(VC_INTERFACE_BLOCK_SIZE-1))\n\n//The max length for an effect name\n#define DISPMAN_MAX_EFFECT_NAME  (28)\n\ntypedef enum {\n   // Values initially chosen to match VC_IMAGE_TYPE_T to aid debugging\n   // This is now a mandatory constraint\n   VC_FORMAT_RGB565    = 1,\n   VC_FORMAT_YUV420    = 3,\n   VC_FORMAT_RGB888    = 5,\n   VC_FORMAT_RGBA32    = 15,\n   VC_FORMAT_RGBA565   = 17,\n   VC_FORMAT_RGBA16    = 18,\n   VC_FORMAT_TF_RGBA32 = 20,\n   VC_FORMAT_TF_RGBA16 = 23,\n   VC_FORMAT_TF_RGB565 = 25,\n   VC_FORMAT_BGR888    = 31,\n   VC_FORMAT_BGR888_NP = 32,\n   \n   VC_FORMAT_ARGB8888  = 43,\n   VC_FORMAT_XRGB8888  = 44,\n\n   /* To force 32-bit storage, enabling use in structures over-the-wire */\n   VC_FORMAT_RANGE_MAX = 0x7FFFFFFF\n} VC_IMAGE_FORMAT_T;\n\n// Transforms.\n/* Image transformations. These must match the DISPMAN and Media Player versions */\n#define TRANSFORM_HFLIP     (1<<0)\n#define TRANSFORM_VFLIP     (1<<1)\n#define TRANSFORM_TRANSPOSE (1<<2)\n\ntypedef enum {\n   VC_DISPMAN_ROT0           = 0,\n   VC_DISPMAN_MIRROR_ROT0    = TRANSFORM_HFLIP,\n   VC_DISPMAN_MIRROR_ROT180  = TRANSFORM_VFLIP,\n   VC_DISPMAN_ROT180         = TRANSFORM_HFLIP|TRANSFORM_VFLIP,\n   VC_DISPMAN_MIRROR_ROT90   = TRANSFORM_TRANSPOSE,\n   VC_DISPMAN_ROT270         = TRANSFORM_TRANSPOSE|TRANSFORM_HFLIP,\n   VC_DISPMAN_ROT90          = TRANSFORM_TRANSPOSE|TRANSFORM_VFLIP,\n   VC_DISPMAN_MIRROR_ROT270  = TRANSFORM_TRANSPOSE|TRANSFORM_HFLIP|TRANSFORM_VFLIP,\n} VC_DISPMAN_TRANSFORM_T;\n\ntypedef enum {\n   VC_RESOURCE_TYPE_HOST,\n   VC_RESOURCE_TYPE_VIDEOCORE,\n   VC_RESOURCE_TYPE_VIDEOCORE_UNCACHED,\n} VC_RESOURCE_TYPE_T;\n\ntypedef struct {\n   uint8_t  type;            // VC_IMAGE_FORMAT_T\n   uint32_t width;           // width in pixels\n   uint32_t height;          // height in pixels\n   uint32_t pitch;           // pitch of image_data array in *bytes*\n   uint32_t size;            // number of *bytes* available in the image_data arry\n   uint32_t pointer;         // pointer for image_data - this allows the object to be cast to a VC_IMAGE_T on the VIDEOCORE side\n} VC_IMAGE_PARAM_T;\n\ntypedef enum {\n   VC_DISPMAN_DISPLAY_SET_DESTINATION = 0,\n   VC_DISPMAN_DISPLAY_UPDATE_START,\n   VC_DISPMAN_DISPLAY_UPDATE_END,\n   VC_DISPMAN_DISPLAY_OBJECT_ADD,\n   VC_DISPMAN_DISPLAY_OBJECT_REMOVE,\n   VC_DISPMAN_DISPLAY_OBJECT_MODIFY,\n   VC_DISPMAN_DISPLAY_LOCK,\n   VC_DISPMAN_DISPLAY_UNLOCK,\n   VC_DISPMAN_DISPLAY_RESOURCE_CREATE,\n   VC_DISPMAN_DISPLAY_RESOURCE_DELETE,\n   VC_DISPMAN_DISPLAY_GET_COMPOSITE,\n   VC_DISPMAN_DISPLAY_APPLY_EFFECT_INSTANCE,\n   VC_DISPMAN_DISPLAY_RECONFIGURE,\n   VC_DISPMAN_DISPLAY_CREATE_EFFECTS_INSTANCE,\n   VC_DISPMAN_DISPLAY_DELETE_EFFECTS_INSTANCE,\n   VC_DISPMAN_DISPLAY_SET_EFFECT,\n   VC_DISPMAN_DISPLAY_RESOURCE_SET_ALPHA,\n   VC_DISPMAN_DISPLAY_SNAPSHOT,\n   VC_DISPMAN_DISPLAY_QUERY_IMAGE_FORMATS,\n   VC_DISPMAN_DISPLAY_GET_DISPLAY_DETAILS,\n   // new features - add to end of list\n   VC_DISPMAN_DISPLAY_RESOURCE_CREATE_FROM_IMAGE,\n   VC_CMD_END_OF_LIST\n} VC_CMD_CODE_T;\n\n/* The table of functions executed for each command. */\n\ntypedef void (*INTERFACE_EXECUTE_FN_T)(int, int);\n\nextern INTERFACE_EXECUTE_FN_T interface_execute_fn[];\n\n//Parameter sets for dispservice commands\ntypedef struct {\n   uint32_t state;\n   uint32_t dummy[3];   //Pad to multiple of 16 bytes\n} DISPMAN_LOCK_PARAM_T;\n\ntypedef struct {\n   uint32_t display;\n   uint32_t dummy[3];   //Pad to multiple of 16 bytes\n} DISPMAN_GET_DISPLAY_DETAILS_PARAM_T;\n\ntypedef struct {\n   uint32_t display;\n   uint32_t resource;\n   uint32_t dummy[2];   //Pad to multiple of 16 bytes\n} DISPMAN_SET_DEST_PARAM_T;\n\ntypedef struct {\n   uint32_t display;\n   uint32_t dummy[3];   //Pad to multiple of 16 bytes\n} DISPMAN_GET_COMPOSITE_PARAM_T;\n\ntypedef struct\n{\n   uint32_t display;\n   uint32_t effects_instance;\n\n   uint32_t dummy[2];   //Pad to multiple of 16 bytes\n} DISPMAN_APPLY_EFFECTS_INSTANCE_PARAM_T;\n\ntypedef struct\n{\n   uint32_t read_response;\n   uint32_t effects_instance;\n} DISPMAN_CREATE_EFFECTS_INSTANCE_RESPONSE_T;\n\ntypedef struct\n{\n   uint32_t effects_instance;\n   uint32_t dummy[3];   //Pad to multiple of 16 bytes\n} DISPMAN_DELETE_EFFECTS_INSTANCE_PARAM_T;\n\ntypedef struct\n{\n   uint32_t effects_instance;\n   char effect_name[ DISPMAN_MAX_EFFECT_NAME ];\n   //no need to pad as long as DISPMAN_MAX_EFFECT_NAME +sizeof(uint32) = 32\n} DISPMAN_SET_EFFECT_PARAM_T;\n\ntypedef struct {\n   uint32_t display;\n   uint16_t width;\n   uint16_t height;\n   uint32_t dummy[2];   //Pad to multiple of 16 bytes\n} DISPMAN_RECONFIGURE_PARAM_T;\n\ntypedef struct {\n   uint32_t display;\n   uint32_t transparent_colour;\n   uint32_t dummy[2];   //Pad to multiple of 16 bytes\n} DISPMAN_SET_TRANSPARENT_COLOUR_PARAM_T;\n\ntypedef struct {\n   //uint32_t object;\n   uint32_t display;\n   int32_t layer;\n   uint32_t transform;\n   uint32_t resource;\n   uint16_t dest_x;\n   uint16_t dest_y;\n   uint16_t dest_width;\n   uint16_t dest_height;\n   uint16_t src_x;\n   uint16_t src_y;\n   uint16_t src_width;\n   uint16_t src_height;\n} DISPMAN_OBJECT_ADD_PARAM_T;\n\ntypedef struct {\n   uint32_t object;\n   uint32_t dummy[3];   //Pad to multiple of 16 bytes\n} DISPMAN_OBJECT_REMOVE_PARAM_T;\n\ntypedef struct {\n   uint32_t object;\n   uint16_t src_x;\n   uint16_t src_y;\n   uint16_t width;\n   uint16_t height;\n   uint32_t dummy[1];   // Pad to multiple of 16 bytes\n} DISPMAN_OBJECT_MODIFY_PARAM_T;\n\ntypedef struct\n{\n   uint32_t *resource;\n   VC_IMAGE_PARAM_T image;\n   uint8_t  type;   // VC_RESOURCE_TYPE_T\n   //Removed padding.  VC_IMAGE_T may change in size, so handle the size in the code that sends and receives the commands\n   //uint32_t dummy[3];   //Pad to multiple of 16 bytes\n} DISPMAN_RESOURCE_CREATE_PARAM_T;\n\ntypedef struct\n{\n   uint32_t native_image_ptr;\n   uint32_t type;   // VC_RESOURCE_TYPE_T\n   uint32_t dummy[2];  // Pad to multiple of 16 bytes\n} DISPMAN_RESOURCE_CREATE_FROM_IMAGE_PARAM_T;\n\ntypedef struct {\n   uint32_t resource;\n   uint32_t dummy[3];   //Pad to multiple of 16 bytes\n} DISPMAN_RESOURCE_DELETE_PARAM_T;\n\ntypedef struct {\n   uint32_t resource;\n   uint32_t alpha;\n   uint32_t dummy[2];   //Pad to multiple of 16 bytes\n} DISPMAN_RESOURCE_SET_ALPHA_PARAM_T;\n\ntypedef struct {\n   uint32_t display;\n   uint32_t resource;\n   uint32_t dummy[2];   //Pad to multiple of 16 bytes\n} DISPMAN_DISPLAY_SNAPSHOT_PARAM_T;\n\n#endif   //VC_DISPSERVICE_DEFS_H\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vmcs_host/vc_dispservice_x_defs.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n// Display service command enumeration.\n\n#ifndef VC_DISPSERVICEX_DEFS_H\n#define VC_DISPSERVICEX_DEFS_H\n\n#include \"interface/vctypes/vc_image_types.h\"\n\n#define  HOST_PITCH_ALIGNMENT    4\n\n//Round up to the nearest multiple of 16\n#define  PAD16(x) (((x) + (VC_INTERFACE_BLOCK_SIZE-1)) & ~(VC_INTERFACE_BLOCK_SIZE-1))\n\n//The max length for an effect name\n#define DISPMANX_MAX_EFFECT_NAME  (28)\n\n// Should really use the VC_IMAGE_TYPE_T, but this one has been extended\n// to force it up to 32-bits...\ntypedef enum {\n   // Values initially chosen to match VC_IMAGE_TYPE_T to aid debugging\n   // This is now a mandatory constraint\n   VC_FORMAT_RGB565    = VC_IMAGE_RGB565,\n   VC_FORMAT_YUV420    = VC_IMAGE_YUV420,\n   VC_FORMAT_RGB888    = VC_IMAGE_RGB888,\n   VC_FORMAT_RGBA32    = VC_IMAGE_RGBA32,\n   VC_FORMAT_RGBA565   = VC_IMAGE_RGBA565,\n   VC_FORMAT_RGBA16    = VC_IMAGE_RGBA16,\n   VC_FORMAT_TF_RGBA32 = VC_IMAGE_TF_RGBA32,\n   VC_FORMAT_TF_RGBA16 = VC_IMAGE_TF_RGBA16,\n   VC_FORMAT_TF_RGB565 = VC_IMAGE_TF_RGB565,\n   VC_FORMAT_BGR888    = VC_IMAGE_BGR888,\n   VC_FORMAT_BGR888_NP = VC_IMAGE_BGR888_NP,\n\n   VC_FORMAT_ARGB8888  = VC_IMAGE_ARGB8888,\n   VC_FORMAT_XRGB8888  = VC_IMAGE_XRGB8888,\n\n   /* To force 32-bit storage, enabling use in structures over-the-wire */\n   VC_FORMAT_RANGE_MAX = 0x7FFFFFFF\n} VC_IMAGE_FORMAT_T;\n\n// Transforms.\n/* Image transformations. These must match the DISPMAN and Media Player versions */\n#define TRANSFORM_HFLIP     (1<<0)\n#define TRANSFORM_VFLIP     (1<<1)\n#define TRANSFORM_TRANSPOSE (1<<2)\n\n#define VC_DISPMAN_ROT0 VC_IMAGE_ROT0\n#define VC_DISPMAN_ROT90 VC_IMAGE_ROT90\n#define VC_DISPMAN_ROT180 VC_IMAGE_ROT180\n#define VC_DISPMAN_ROT270 VC_IMAGE_ROT270\n#define VC_DISPMAN_MIRROR_ROT0 VC_IMAGE_MIRROR_ROT0\n#define VC_DISPMAN_MIRROR_ROT90 VC_IMAGE_MIRROR_ROT90\n#define VC_DISPMAN_MIRROR_ROT180 VC_IMAGE_MIRROR_ROT180\n#define VC_DISPMAN_MIRROR_ROT270 VC_IMAGE_MIRROR_ROT270\n#define VC_DISPMAN_TRANSFORM_T VC_IMAGE_TRANSFORM_T\n\ntypedef enum {\n   VC_RESOURCE_TYPE_HOST,\n   VC_RESOURCE_TYPE_VIDEOCORE,\n   VC_RESOURCE_TYPE_VIDEOCORE_UNCACHED,\n} VC_RESOURCE_TYPE_T;\n\ntypedef struct {\n   uint8_t  type;            // VC_IMAGE_FORMAT_T\n   uint32_t width;           // width in pixels\n   uint32_t height;          // height in pixels\n   uint32_t pitch;           // pitch of image_data array in *bytes*\n   uint32_t size;            // number of *bytes* available in the image_data arry\n   uint32_t pointer;         // pointer for image_data - this allows the object to be cast to a VC_IMAGE_T on the VIDEOCORE side\n} VC_IMAGE_PARAM_T;\n\ntypedef enum {\n   VC_DISPMANX_GET_DEVICES = 0,\n   VC_DISPMANX_GET_DEVICE_NAME,\n   VC_DISPMANX_GET_MODES,\n   VC_DISPMANX_GET_MODE_INFO,\n   VC_DISPMANX_DISPLAY_QUERY_IMAGE_FORMATS,\n   // Resources\n   VC_DISPMANX_RESOURCE_CREATE,\n   VC_DISPMANX_RESOURCE_WRITE_DATA,\n   VC_DISPMANX_RESOURCE_DELETE,\n   // Displays\n   VC_DISPMANX_DISPLAY_OPEN,\n   VC_DISPMANX_DISPLAY_OPEN_MODE,\n   VC_DISPMANX_DISPLAY_OPEN_OFFSCREEN,\n   VC_DISPMANX_DISPLAY_RECONFIGURE,\n   VC_DISPMANX_DISPLAY_SET_DESTINATION,\n   VC_DISPMANX_DISPLAY_SET_BACKGROUND,\n   VC_DISPMANX_DISPLAY_GET_INFO,\n   VC_DISPMANX_DISPLAY_CLOSE,\n   // Updates\n   VC_DISPMANX_UPDATE_START,\n   VC_DISPMANX_ELEMENT_ADD,\n   VC_DISPMANX_ELEMENT_CHANGE_SOURCE,\n   VC_DISPMANX_ELEMENT_MODIFIED,\n   VC_DISPMANX_ELEMENT_REMOVE,\n   VC_DISPMANX_UPDATE_SUBMIT,\n   VC_DISPMANX_UPDATE_SUBMIT_SYNC,\n   // Miscellaneous\n   VC_DISPMANX_SNAPSHOT,\n   // new features - add to end of list\n   VC_CMD_END_OF_LIST\n} VC_CMD_CODE_T;\n\n/* The table of functions executed for each command. */\n\ntypedef void (*INTERFACE_EXECUTE_FN_T)(int, int);\n\nextern INTERFACE_EXECUTE_FN_T interface_execute_fn[];\n\n#define DISPMANX_MAX_HOST_DEVICES 8\n#define DISPMANX_MAX_DEVICE_NAME_LEN 16\n\n//Parameter sets for dispservice commands\n\ntypedef struct {\n   int32_t response;\n   uint32_t ndevices;\n   uint32_t dummy[2];\n   uint8_t names[DISPMANX_MAX_HOST_DEVICES][DISPMANX_MAX_DEVICE_NAME_LEN];\n} DISPMANX_GET_DEVICES_RESP_T;\ntypedef struct {\n   uint32_t device;\n   uint32_t dummy[3];   //Pad to multiple of 16 bytes\n} DISPMANX_GET_MODES_PARAM_T;\ntypedef struct {\n   uint32_t display;\n   uint32_t mode;\n   uint32_t dummy[2];   //Pad to multiple of 16 bytes\n} DISPMANX_GET_MODE_INFO_PARAM_T;\ntypedef struct {\n   uint32_t type;\n   uint32_t width;\n   uint32_t height;\n   uint32_t dummy[1];   // Pad to multiple of 16 bytes\n} DISPMANX_RESOURCE_CREATE_PARAM_T;\ntypedef struct {\n   // This will be needed when we change to vchi.\n   int junk; // empty structure not allowed\n} DISPMANX_RESOURCE_WRITE_DATA_PARAM_T;\ntypedef struct {\n   uint32_t handle;\n   uint32_t dummy[3];   //Pad to multiple of 16 bytes\n} DISPMANX_RESOURCE_DELETE_PARAM_T;\ntypedef struct {\n   uint32_t device;\n   uint32_t dummy[3];\n} DISPMANX_DISPLAY_OPEN_PARAM_T;\ntypedef struct {\n   uint32_t device;\n   uint32_t mode;\n   uint32_t dummy[2];\n} DISPMANX_DISPLAY_OPEN_MODE_PARAM_T;\ntypedef struct {\n   uint32_t dest;\n   uint32_t orientation;\n   uint32_t dummy[2];\n} DISPMANX_DISPLAY_OPEN_OFFSCREEN_PARAM_T;\ntypedef struct {\n   uint32_t display;\n   uint32_t dest;\n   uint32_t dummy[2];\n} DISPMANX_DISPLAY_SET_DESTINATION_PARAM_T;\ntypedef struct {\n   uint32_t display;\n   uint32_t update;\n   uint32_t colour;\n   uint32_t dummy;\n} DISPMANX_DISPLAY_SET_BACKGROUND_PARAM_T;\ntypedef struct {\n   uint32_t display;\n   uint32_t dummy[3];\n} DISPMANX_DISPLAY_GET_INFO_PARAM_T;\ntypedef struct {\n   uint32_t read_response;\n   int32_t      width;\n   int32_t      height;\n   int32_t      aspect_pixwidth;\n   int32_t      aspect_pixheight;\n   int32_t      fieldrate_num;\n   int32_t      fieldrate_denom;\n   int32_t      fields_per_frame;\n   uint32_t transform;\n   uint32_t dummy[3];\n} DISPMANX_DISPLAY_GET_INFO_RESP_T;\ntypedef struct {\n   int32_t priority;\n   uint32_t dummy[3];\n} DISPMANX_UPDATE_START_PARAM_T;\ntypedef struct {\n   uint32_t update;\n   uint32_t display;\n   int32_t layer;\n   uint32_t transform;\n   uint32_t src_resource;\n   uint16_t dest_x;\n   uint16_t dest_y;\n   uint16_t dest_width;\n   uint16_t dest_height;\n   uint16_t src_x;\n   uint16_t src_y;\n   uint16_t src_width;\n   uint16_t src_height;\n   uint32_t flags;\n   uint32_t opacity;\n   uint32_t mask_resource;\n   // already 16 byte aligned\n} DISPMANX_ELEMENT_ADD_PARAM_T;\ntypedef struct {\n   uint32_t update;\n   uint32_t element;\n   uint32_t src_resource;\n   uint32_t dummy; // pad to 16 bytes\n} DISPMANX_ELEMENT_CHANGE_SOURCE_PARAM_T;\ntypedef struct {\n   uint32_t update;\n   uint32_t element;\n   uint16_t x;\n   uint16_t y;\n   uint16_t width;\n   uint16_t height;\n} DISPMANX_ELEMENT_MODIFIED_PARAM_T;\ntypedef struct {\n   uint32_t update;\n   uint32_t element;\n   uint32_t dummy[2];\n} DISPMANX_ELEMENT_REMOVE_PARAM_T;\ntypedef struct {\n   uint32_t update;\n   uint32_t dummy[3];\n} DISPMANX_UPDATE_SUBMIT_PARAM_T;\ntypedef struct {\n   uint32_t update;\n   uint32_t dummy[3];\n} DISPMANX_UPDATE_SUBMIT_SYNC_PARAM_T;\ntypedef struct {\n   uint32_t display;\n   uint32_t snapshot_resource;\n   uint32_t transform;\n   uint32_t dummy[1];\n} DISPMANX_DISPLAY_SNAPSHOT_PARAM_T;\n\n// for dispmanx\n\n#define TRANSFORM_HFLIP     (1<<0)\n#define TRANSFORM_VFLIP     (1<<1)\n#define TRANSFORM_TRANSPOSE (1<<2)\n\n\n#endif   //VC_DISPSERVICEX_DEFS_H\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vmcs_host/vc_fileservice_defs.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n// File service command enumeration.\n\n#ifndef VC_FILESERVICE_DEFS_H\n#define VC_FILESERVICE_DEFS_H\n\n#define VC_FILESERV_VER   1\n/* Definitions (not used by API) */\n#define FS_MAX_DATA 8192 //4096\n\n/* Protocol (not used by API) version 1.2 */\n\nenum {\n   /* Over-the-wire file open flags */\n   VC_O_RDONLY     = 0x01,\n   VC_O_WRONLY     = 0x02,\n   VC_O_RDWR            = 0x04,\n   VC_O_APPEND     = 0x08,\n   VC_O_CREAT           = 0x10,\n   VC_O_TRUNC           = 0x20,\n   VC_O_EXCL            = 0x40,\n\n   /* Request Commands (VC->Host->VC) */\n\n   /* These commands don't require a pathname */\n   VC_FILESYS_RESET      = 64,\n   VC_FILESYS_CLOSE      = 65,\n   VC_FILESYS_CLOSEDIR   = 66,\n   VC_FILESYS_LSEEK      = 67,\n   VC_FILESYS_READ       = 68,\n   VC_FILESYS_READDIR    = 69,\n   VC_FILESYS_SETEND     = 70,\n   VC_FILESYS_WRITE      = 71,\n\n   /* These commands require a pathname */\n   VC_FILESYS_FORMAT     = 72,\n   VC_FILESYS_FREESPACE  = 73,\n   VC_FILESYS_GET_ATTR   = 74,\n   VC_FILESYS_MKDIR      = 75,\n   VC_FILESYS_OPEN       = 76,\n   VC_FILESYS_OPENDIR    = 77,\n   VC_FILESYS_REMOVE     = 78,\n   VC_FILESYS_RENAME     = 79,\n   VC_FILESYS_SET_ATTR   = 80,\n   VC_FILESYS_SCANDISK   = 81,\n   VC_FILESYS_TOTALSPACE = 82,\n   VC_FILESYS_DISKWRITABLE=83,\n   VC_FILESYS_OPEN_DISK_RAW  = 84,\n   VC_FILESYS_CLOSE_DISK_RAW = 85,\n   VC_FILESYS_NUMSECTORS     = 86,\n   VC_FILESYS_READ_SECTORS   = 87,\n   VC_FILESYS_WRITE_SECTORS  = 88,\n\n   VC_FILESYS_MOUNT      = 89,\n   VC_FILESYS_UMOUNT     = 90,\n   VC_FILESYS_FSTYPE     = 91,\n\n   VC_FILESYS_READ_DIRECT = 92,\n\n   VC_FILESYS_LSEEK64     = 93,\n   VC_FILESYS_FREESPACE64 = 94,\n   VC_FILESYS_TOTALSPACE64= 95,\n   VC_FILESYS_OPEN_DISK   = 96,\n   VC_FILESYS_CLOSE_DISK  = 97,\n   \n   /* extra simple functions for mass storage testing */\n   VC_FILESYS_READ_SECTOR = 98, //1sect\n   VC_FILESYS_STREAM_SECTOR_BEGIN = 99,\n   VC_FILESYS_STREAM_SECTOR_END = 100,\n   VC_FILESYS_WRITE_SECTOR = 101,\n   VC_FILESYS_FSTAT      = 102,\n   VC_FILESYS_DIRSIZE     = 103,\n   VC_FILESYS_LIST_DIRS   = 104,\n   VC_FILESYS_LIST_FILES  = 105,\n   VC_FILESYS_NUM_DIRS    = 106,\n   VC_FILESYS_NUM_FILES   = 107,\n   VC_FILESYS_MAX_FILESIZE = 108,\n   VC_FILESYS_CHKDSK       = 109,\n};\n\n/* Parameters for lseek */\n\n#define  VC_FILESYS_SEEK_SET  0    /* Set file pointer to \"offset\" */\n#define  VC_FILESYS_SEEK_CUR  1    /* Set file pointer to current plus \"offset\" */\n#define  VC_FILESYS_SEEK_END  2    /* Set file pointer to EOF plus \"offset\" */\n\n/* Return values of vc_filesys_type */\n#define VC_FILESYS_FS_UNKNOWN 0\n#define VC_FILESYS_FS_FAT12 1\n#define VC_FILESYS_FS_FAT16 2\n#define VC_FILESYS_FS_FAT32 3\n\n#endif\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vmcs_host/vc_gencmd_defs.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n#ifndef VC_GENCMD_DEFS_H\n#define VC_GENCMD_DEFS_H\n\n//Format of reply message is error code followed by a string\n#define GENCMDSERVICE_MSGFIFO_SIZE 1024\n\n#define VC_GENCMD_VER   1\n\n#endif\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vmcs_host/vc_hdmi.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n/*\n * HDMI common host header for TV service, defines resolution code which host applications should\n * use for power up command for HDMI\n */\n\n#ifndef _VC_HDMI_H_\n#define _VC_HDMI_H_\n\n#include \"vc_hdmi_property.h\" /**< All HDMI related properties have been moved to here */\n\ntypedef int VC_HDMI_BOOL_T;\n\n/**\n * HDMI resolution groups. There are two main groups: \n * CEA - the conventional HDMI ones like 720p\n * DMT - computer monitor resolutions like XGA\n */\ntypedef enum {\n   HDMI_RES_GROUP_INVALID = 0, /**< Initialised value */\n   HDMI_RES_GROUP_CEA     = 1, /**< CEA - HDMI device */\n   HDMI_RES_GROUP_DMT     = 2, /**< DMT - computer monitors */\n   HDMI_RES_GROUP_CEA_3D  = 3, /* deprecated */\n\n} HDMI_RES_GROUP_T;\n\n#define HDMI_RES_GROUP_NAME(g) \\\n   (((g) == HDMI_RES_GROUP_INVALID) ? \"Invalid\" : \\\n   (((g) == HDMI_RES_GROUP_CEA) ? \"CEA\" : \\\n   (((g) == HDMI_RES_GROUP_DMT) ? \"DMT\" : \\\n    \"Unknown\")))\n\n/**\n *  CEA 861 defined video code and aspect ratios for various HDMI modes\n *  Not all values are valid for AVI infoframe\n */\ntypedef enum {\n   HDMI_ASPECT_UNKNOWN  = 0, /**< Unknown aspect ratio, or not one of the values below */\n   HDMI_ASPECT_4_3      = 1, /**< 4:3  */\n   HDMI_ASPECT_14_9     = 2, /**< 14:9 */\n   HDMI_ASPECT_16_9     = 3, /**< 16:9 */\n   HDMI_ASPECT_5_4      = 4, /**< 5:4  */\n   HDMI_ASPECT_16_10    = 5, /**< 16:10*/\n   HDMI_ASPECT_15_9     = 6, /**< 15:9 */\n   HDMI_ASPECT_64_27    = 7, /**< 64:27 */\n   HDMI_ASPECT_21_9     = HDMI_ASPECT_64_27 /**< 21:9 is jargon, 64:27 is the actual aspect ratio */\n   /* More aspect ratio values may be added here if defined by CEA in future */\n} HDMI_ASPECT_T;\n\n/**\n * Display options set the bounding box (only used in CEA mode)\n */\ntypedef struct {\n   uint16_t aspect; /**<HDMI_ASPECT_T */\n   /** Active area information - meanings as in CEA-861. */\n   uint16_t vertical_bar_present; /**<VC_HDMI_BOOL_T */\n   uint16_t left_bar_width;\n   uint16_t right_bar_width;\n   uint16_t horizontal_bar_present; /**<VC_HDMI_BOOL_T */\n   uint16_t top_bar_height;\n   uint16_t bottom_bar_height;\n   /** S0/S1 flags as defined in CEA-861. */\n   uint8_t         overscan_flags;\n} HDMI_DISPLAY_OPTIONS_T;\n\n/**\n * HDMI internal state (with some of the properties related to current display signal)\n * Also see SDTV_DISPLAY_STATE_T in vc_sdtv.h, members up to scan_mode will be in the\n * same position as the equivalent state in SDTV_DISPLAY_STATE_T;\n */\ntypedef struct {\n   uint32_t state;\n   uint32_t width;\n   uint32_t height;\n   uint16_t frame_rate;\n   uint16_t scan_mode;\n   uint32_t group; /**<HDMI_RES_GROUP_T */\n   uint32_t mode; /* This is the mode number of the format */\n   uint16_t pixel_rep;   /* Pixel repetition factor, only relevant for CEA formats */\n   uint16_t aspect_ratio; /* This is the format's native aspect ratio */\n   HDMI_DISPLAY_OPTIONS_T display_options; /* This has the aspect ratio sent in AVI infoframe */\n   uint16_t pixel_encoding;\n   uint16_t format_3d; /* 3D format, only relevant for CEA formats */\n} HDMI_DISPLAY_STATE_T;\n\n/**\n * Copy protection for HDMI, only HDCP is available\n * This enum is to make it consistent with the enums\n * SDTV_CP_MODE_T in vc_sdtv.h\n */\ntypedef enum {\n   HDMI_CP_NONE         = 0, /**< No copyprotection */\n   HDMI_CP_HDCP         = 1  /**< HDCP 1.x */\n} HDMI_CP_MODE_T;\n\n/**\n *  HDMI operation modes\n */\ntypedef enum {\n   HDMI_MODE_OFF,  /**< Off! */\n   HDMI_MODE_DVI,  /**< DVI */\n   HDMI_MODE_HDMI, /**< HDMI */\n   HDMI_MODE_3D    /**< HDMI 1.4a 3D */\n} HDMI_MODE_T;\n\n/**\n * Possible values for the Source Product Description type code (in SPD infoframe).\n * Taken from the CEA-861 spec.\n */\ntypedef enum {\n   HDMI_SPD_TYPE_UNKNOWN,\n   HDMI_SPD_TYPE_STB,           /**<Digital STB */\n   HDMI_SPD_TYPE_DVD,           /**<DVD player */\n   HDMI_SPD_TYPE_DVHS,          /**<D-VHS */\n   HDMI_SPD_TYPE_HDD_RECORDER,  /**<HDD video recoder */\n   HDMI_SPD_TYPE_DVC,           /**<DVC */\n   HDMI_SPD_TYPE_DSC,           /**<DSC */\n   HDMI_SPD_TYPE_VCD,           /**<Video CD */\n   HDMI_SPD_TYPE_GAME,          /**<Game */\n   HDMI_SPD_TYPE_PC,            /**<PC general */\n   HDMI_SPD_TYPE_BD,            /**<Blu-Ray Disc */\n   HDMI_SPD_TYPE_SACD,          /**<Super Audio CD */\n   HDMI_SPD_TYPE_HDDVD,         /**<HD DVD */\n   HDMI_SPD_TYPE_PMP            /**<Personal media player */\n} HDMI_SPD_TYPE_CODE_T;\n\n/**\n * Structure for SPD infoframe\n */\ntypedef struct {\n   char  *manufacturer;        /**< Manufacture name (up to 8 characters) */\n   char  *description;         /**< Product name (up to 16 characters) */\n   HDMI_SPD_TYPE_CODE_T type;  /**< Product type */\n} HDMI_SPD_DATA_T;\n\n/**\n * These are CEA mode numbers (sent in AVI infoframe) for different resolutions as define in CEA-861\n * 1080i at 100/120Hz (40,46) are supported by HDMI H/W but note we cannot\n * display the debug overlay under these modes.\n * Some modes have two codes, the first one has aspect ratio 4:3 and\n * the second one (with \"H\" suffix\") 16:9.\n * The modes with \"4x\", etc. are the same the corresponding \"non-multiplied\" modes\n * but clocked at a higher pixel clock.\n */\ntypedef enum {\n   HDMI_CEA_VGA             =  1,\n   HDMI_CEA_480p60          =  2,\n   HDMI_CEA_480p60H         =  3,\n   HDMI_CEA_720p60          =  4,\n   HDMI_CEA_1080i60         =  5,\n   HDMI_CEA_480i60          =  6,\n   HDMI_CEA_480i60H         =  7,\n   HDMI_CEA_240p60          =  8,\n   HDMI_CEA_240p60H         =  9,\n   HDMI_CEA_480i60_4x       = 10,\n   HDMI_CEA_480i60_4xH      = 11,\n   HDMI_CEA_240p60_4x       = 12,\n   HDMI_CEA_240p60_4xH      = 13,\n   HDMI_CEA_480p60_2x       = 14,\n   HDMI_CEA_480p60_2xH      = 15,\n   HDMI_CEA_1080p60         = 16,\n   HDMI_CEA_576p50          = 17,\n   HDMI_CEA_576p50H         = 18,\n   HDMI_CEA_720p50          = 19,\n   HDMI_CEA_1080i50         = 20,\n   HDMI_CEA_576i50          = 21,\n   HDMI_CEA_576i50H         = 22,\n   HDMI_CEA_288p50          = 23,\n   HDMI_CEA_288p50H         = 24,\n   HDMI_CEA_576i50_4x       = 25,\n   HDMI_CEA_576i50_4xH      = 26,\n   HDMI_CEA_288p50_4x       = 27,\n   HDMI_CEA_288p50_4xH      = 28,\n   HDMI_CEA_576p50_2x       = 29,\n   HDMI_CEA_576p50_2xH      = 30,\n   HDMI_CEA_1080p50         = 31,\n   HDMI_CEA_1080p24         = 32,\n   HDMI_CEA_1080p25         = 33,\n   HDMI_CEA_1080p30         = 34,\n   HDMI_CEA_480p60_4x       = 35,\n   HDMI_CEA_480p60_4xH      = 36,\n   HDMI_CEA_576p50_4x       = 37,\n   HDMI_CEA_576p50_4xH      = 38,\n   HDMI_CEA_1080i50_rb      = 39,\n   HDMI_CEA_1080i100        = 40,\n   HDMI_CEA_720p100         = 41,\n   HDMI_CEA_576p100         = 42,\n   HDMI_CEA_576p100H        = 43,\n   HDMI_CEA_576i100         = 44,\n   HDMI_CEA_576i100H        = 45,\n   HDMI_CEA_1080i120        = 46,\n   HDMI_CEA_720p120         = 47,\n   HDMI_CEA_480p120         = 48,\n   HDMI_CEA_480p120H        = 49,\n   HDMI_CEA_480i120         = 50,\n   HDMI_CEA_480i120H        = 51,\n   HDMI_CEA_576p200         = 52,\n   HDMI_CEA_576p200H        = 53,\n   HDMI_CEA_576i200         = 54,\n   HDMI_CEA_576i200H        = 55,\n   HDMI_CEA_480p240         = 56,\n   HDMI_CEA_480p240H        = 57,\n   HDMI_CEA_480i240         = 58,\n   HDMI_CEA_480i240H        = 59,\n   HDMI_CEA_720p24          = 60,\n   HDMI_CEA_720p25          = 61,\n   HDMI_CEA_720p30          = 62,\n   HDMI_CEA_1080p120        = 63,\n   HDMI_CEA_1080p100        = 64,\n\n   /* Up-to-date as of CEA 861-E */\n\n   HDMI_CEA_OFF = 0xff /**<Special code to shutdown HDMI */\n\n} HDMI_CEA_RES_CODE_T;\n\n/**\n * These are the DMT modes from VESA. They are used for powering up\n * HDMI in DMT resolutions and are not sent in AVI infoframes.\n * Enum is ordered as ascending order of DMT id.\n * All reduced blanking formats are 60Hz unless stated otherwise.\n */\ntypedef enum {\n   HDMI_DMT_640x350_85      = 0x1,  /**<640x350 */\n   HDMI_DMT_640x400_85      = 0x2,  /**<640x400 */\n   HDMI_DMT_IBM_VGA_85      = 0x3,  /**<720x400 */\n   HDMI_DMT_VGA_60          = 0x4,  /**<640x480 (60Hz is same as VGA above) */\n   HDMI_DMT_VGA_72          = 0x5,\n   HDMI_DMT_VGA_75          = 0x6,\n   HDMI_DMT_VGA_85          = 0x7,\n   HDMI_DMT_SVGA_56         = 0x8,  /**<800x600 */\n   HDMI_DMT_SVGA_60         = 0x9,\n   HDMI_DMT_SVGA_72         = 0xA,\n   HDMI_DMT_SVGA_75         = 0xB,\n   HDMI_DMT_SVGA_85         = 0xC,\n   HDMI_DMT_SVGA_120        = 0xD,\n   HDMI_DMT_848x480_60      = 0xE,  /**<848x480 */\n   HDMI_DMT_XGA_43          = 0xF,  /**<1024x768 - interlaced, DO NOT USE */\n   HDMI_DMT_XGA_60          = 0x10, /**<1024x768 */\n   HDMI_DMT_XGA_70          = 0x11,\n   HDMI_DMT_XGA_75          = 0x12,\n   HDMI_DMT_XGA_85          = 0x13,\n   HDMI_DMT_XGA_120         = 0x14,\n   HDMI_DMT_XGAP_75         = 0x15, /**<1152x864 */\n   HDMI_DMT_WXGA_RB         = 0x16, /**<1280x768 reduced blanking */\n   HDMI_DMT_WXGA_60         = 0x17,\n   HDMI_DMT_WXGA_75         = 0x18,\n   HDMI_DMT_WXGA_85         = 0x19,\n   HDMI_DMT_WXGA_120        = 0x1A, /**<120Hz with reduced blanking */\n   HDMI_DMT_1280x800_RB     = 0x1B, /**<1280x800 reduced blanking */\n   HDMI_DMT_1280x800_60     = 0x1C,\n   HDMI_DMT_1280x800_75     = 0x1D,\n   HDMI_DMT_1280x800_85     = 0x1E,\n   HDMI_DMT_1280x800_120    = 0x1F, /** reduced blanking */\n   HDMI_DMT_1280x960_60     = 0x20, /**<1280x960 */\n   HDMI_DMT_1280x960_85     = 0x21,\n   HDMI_DMT_1280x960_120    = 0x22, /** reduced blanking */\n   HDMI_DMT_SXGA_60         = 0x23, /**<1280x1024 */\n   HDMI_DMT_SXGA_75         = 0x24,\n   HDMI_DMT_SXGA_85         = 0x25,\n   HDMI_DMT_SXGA_120        = 0x26, /** reduced blanking */\n   HDMI_DMT_1360x768_60     = 0x27, /**<1360x768 */\n   HDMI_DMT_1360x768_120    = 0x28, /**<120 Hz with reduced blanking */\n   HDMI_DMT_SXGAP_RB        = 0x29, /**<1400x1050 reduced blanking */\n   HDMI_DMT_SXGAP_60        = 0x2A,\n   HDMI_DMT_SXGAP_75        = 0x2B,\n   HDMI_DMT_SXGAP_85        = 0x2C,\n   HDMI_DMT_SXGAP_120       = 0x2D, /** reduced blanking */\n   HDMI_DMT_1440x900_RB     = 0x2E, /**<1440x900 reduced blanking */\n   HDMI_DMT_1440x900_60     = 0x2F,\n   HDMI_DMT_1440x900_75     = 0x30,\n   HDMI_DMT_1440x900_85     = 0x31,\n   HDMI_DMT_1440x900_120    = 0x32, /** reduced blanking */\n   HDMI_DMT_UXGA_60         = 0x33, /**<1600x1200 60Hz */\n   HDMI_DMT_UXGA_65         = 0x34, \n   HDMI_DMT_UXGA_70         = 0x35, \n   HDMI_DMT_UXGA_75         = 0x36, \n   HDMI_DMT_UXGA_85         = 0x37, \n   HDMI_DMT_UXGA_120        = 0x38, /** reduced blanking */\n   HDMI_DMT_SWXGAP_RB       = 0x39, /**<1680x1050 reduced blanking */\n   HDMI_DMT_SWXGAP_60       = 0x3A, /**<1680x1050 60Hz */\n   HDMI_DMT_SWXGAP_75       = 0x3B, \n   HDMI_DMT_SWXGAP_85       = 0x3C, \n   HDMI_DMT_SWXGAP_120      = 0x3D, /** reduced blanking */ \n   HDMI_DMT_1792x1344_60    = 0x3E, /**<1792x1344 60Hz */\n   HDMI_DMT_1792x1344_75    = 0x3F, /**<1792x1344 75Hz */\n   HDMI_DMT_1792x1344_120   = 0x40, /** reduced blanking */\n   HDMI_DMT_1856x1392_60    = 0x41, /**<1856x1392 60Hz */\n   HDMI_DMT_1856x1392_75    = 0x42, /**<1856x1392 75Hz */\n   HDMI_DMT_1856x1392_120   = 0x43, /** reduced blanking */\n   HDMI_DMT_WUXGA_RB        = 0x44, /**<1920x1200 reduced blanking */\n   HDMI_DMT_WUXGA_60        = 0x45, /**<1920x1200 60Hz */\n   HDMI_DMT_WUXGA_75        = 0x46, /**<1920x1200 75Hz */\n   HDMI_DMT_WUXGA_85        = 0x47, /**<1920x1200 85Hz */\n   HDMI_DMT_WUXGA_120       = 0x48, /** reduced blanking */\n   HDMI_DMT_1920x1440_60    = 0x49, /**<1920x1440 60Hz */\n   HDMI_DMT_1920x1440_75    = 0x4A, /**<1920x1440 75Hz */\n   HDMI_DMT_1920x1440_120   = 0x4B, /** reduced blanking */\n   HDMI_DMT_2560x1600_RB    = 0x4C, /**<2560x1600 reduced blanking */\n   HDMI_DMT_2560x1600_60    = 0x4D, /**<2560x1600 60 Hz */\n   HDMI_DMT_2560x1600_75    = 0x4E, /**<2560x1600 75 Hz */\n   HDMI_DMT_2560x1600_85    = 0x4E, /**<2560x1600 85 Hz */\n   HDMI_DMT_2560x1600_120   = 0x50, /** reduced blanking */\n   HDMI_DMT_1366x768_60     = 0x51, /**<1366x768 60Hz */\n   HDMI_DMT_1080p_60        = 0x52, /**<Same as 1080p60 above */\n   HDMI_DMT_1600x900_RB     = 0x53, /**<1600x900 reduced blanking */\n   HDMI_DMT_2048x1152_RB    = 0x54, /**<2048x1152 reduced blanking */\n   HDMI_DMT_720p_60         = 0x55, /**<Same as 720p60 above */\n   HDMI_DMT_1366x768_RB     = 0x56, /**<1366x768 reduced blanking */\n   /* Up-to-date as of VESA DMT v1 r12 */\n\n   HDMI_DMT_OFF = 0xff\n} HDMI_DMT_RES_CODE_T;\n\n/**\n * HDMI scanmode\n */\ntypedef enum {\n   HDMI_NONINTERLACED,\n   HDMI_INTERLACED\n} HDMI_INTERLACED_T;\n\n/**\n * Preference for powering up HDMI using best mode\n * Note we will only use CEA modes for matching\n */\ntypedef enum {\n   HDMI_MODE_MATCH_NONE          = 0x0, /**<No mode*/\n   HDMI_MODE_MATCH_FRAMERATE     = 0x1, /**<Match based on frame rate */\n   HDMI_MODE_MATCH_RESOLUTION    = 0x2, /**<Match based on resolution */\n   HDMI_MODE_MATCH_SCANMODE      = 0x4  /**<Match based on scan mode */\n} EDID_MODE_MATCH_FLAG_T;\n\n/**\n * Audio support flags\n */\ntypedef enum {\n   EDID_AUDIO_NO_SUPPORT         = (1 << 0), /**<No support for that format */\n   EDID_AUDIO_CHAN_UNSUPPORTED   = (1 << 1), /**<max. no. of channels exceeded */\n   EDID_AUDIO_FS_UNSUPPORTED     = (1 << 2), /**<no support for that sampling frequency */\n   EDID_AUDIO_BR_UNSUPPORTED     = (1 << 3), /**<max. bitrate exceeded */\n   EDID_AUDIO_SAMP_UNSUPPORTED   = (1 << 4), /**sample size unsupported (pcm only) */\n} EDID_AUDIO_SUPPORT_FLAG_T;\n\n/**\n * Enums for audio support in audio descriptor block (CEA only)\n * audio formats as specified in CEA Short Audio Descriptors\n */\ntypedef enum {\n   EDID_AudioFormat_eReserved,      /**<Refer to header when set in audio info frame */\n   EDID_AudioFormat_ePCM,           /**<Plain old PCM, mandatory for any audio support */\n   EDID_AudioFormat_eAC3,           /**<AC3 */\n   EDID_AudioFormat_eMPEG1,         /**<Mpeg layer 1 and 2 */\n   EDID_AudioFormat_eMP3,           /**<Mpeg layer 3 */\n   EDID_AudioFormat_eMPEG2,         /**<Mpeg 2 audio */\n   EDID_AudioFormat_eAAC,           /**<AAC */\n   EDID_AudioFormat_eDTS,           /**<DTS */\n   EDID_AudioFormat_eATRAC,         /**<Sony proprietary */\n   EDID_AudioFormat_eDSD,           /**<Super Audio CD 1-bit audio */\n   EDID_AudioFormat_eEAC3,          /**<Dolby Digital + */\n   EDID_AudioFormat_eDTS_HD,        /**<DTS-HD */\n   EDID_AudioFormat_eMLP,           /**<Meridian Lossless Packing - for DVD audio */\n   EDID_AudioFormat_eDST,           /**<Direct stream transfer - compressed super audio CD */\n   EDID_AudioFormat_eWMAPRO,        /**<WMA Pro */\n   EDID_AudioFormat_eExtended,      /**<Refer to byte 3 of audio db for coding extension type */\n\n   EDID_AudioFormat_eMaxCount\n} EDID_AudioFormat;\n\n/**\n * If audio format is set to EDID_AudioFormat_eExtended,\n * this gives the extended audio type (see CEA-861E section 6.6.1)\n */\ntypedef enum {\n   EDID_AudioCodingExtension_NONE    = 0x0, /** no extension, for audio format != Extended */\n   EDID_AudioCodingExtension_HEAAC   = 0x1, /**<HE-AAC */\n   EDID_AudioCodingExtension_HEAAC2  = 0x2, /**<HE-AAC v2 */\n   EDID_AudioCodingExtension_MPEGSUR = 0x3, /**<MPEG Surround */\n\n   EDID_AudioCodingExtension_max\n} EDID_AudioCodingExtension;\n\n/**\n * Audio sample rates as specified in CEA Short Audio Descriptors\n */\ntypedef enum {\n   EDID_AudioSampleRate_eReferToHeader = 0x0,      /**<Only used in audio infoframe */\n   EDID_AudioSampleRate_e32KHz         = (1 << 0), /**<32 kHz (mandatory) */\n   EDID_AudioSampleRate_e44KHz         = (1 << 1), /**<44.1 kHz (mandatory) */\n   EDID_AudioSampleRate_e48KHz         = (1 << 2), /**<48kHz (mandatory) */\n   EDID_AudioSampleRate_e88KHz         = (1 << 3), /**<88.2 kHz */\n   EDID_AudioSampleRate_e96KHz         = (1 << 4), /**<96kHz */\n   EDID_AudioSampleRate_e176KHz        = (1 << 5), /**<176.4 kHz */\n   EDID_AudioSampleRate_e192KHz        = (1 << 6)  /**<192 kHz */\n} EDID_AudioSampleRate;\n\n/**\n * Audio sample sizes (L-PCM) as specified in CEA Short Audio Descriptors\n */\ntypedef enum {\n   EDID_AudioSampleSize_refertoheader = 0x0, /**<Only used in audio infoframe */\n   EDID_AudioSampleSize_16bit         = 0x1, /**<16-bit samples (mandatory) */\n   EDID_AudioSampleSize_20bit         = 0x2, /**<20-bit samples */\n   EDID_AudioSampleSize_24bit         = 0x4  /**<24-bit samples */\n} EDID_AudioSampleSize;\n\n/**\n *  LFE feedback level as described in audio db\n */\ntypedef enum {\n   EDID_AudioLFEFB_UNKNOWN = 0x0, /**<Refer to other information */\n   EDID_AudioLFEFB_0dB     = 0x1, /**<0dB - same level as other channels */\n   EDID_AudioLFEFB_10dB    = 0x2  /**<+10dB relative to other channels */\n} EDID_AudioLFEFB;\n\n/**\n * All possible 3D structures\n * to be used in decoded 3D modes (e.g. HDMI_3D_SUPPORTED_MODE)\n */\ntypedef enum {\n   HDMI_3D_STRUCT_NONE                                   = 0,\n   HDMI_3D_STRUCT_FRAME_PACKING                          = (1<<0),\n   HDMI_3D_STRUCT_FIELD_ALTERNATIVE                      = (1<<1),\n   HDMI_3D_STRUCT_LINE_ALTERNATIVE                       = (1<<2),\n   HDMI_3D_STRUCT_SIDE_BY_SIDE_FULL                      = (1<<3),\n   HDMI_3D_STRUCT_L_DEPTH                                = (1<<4),\n   HDMI_3D_STRUCT_L_DEPTH_GRAPHICS_GRAPHICS_DEPTH        = (1<<5),\n   HDMI_3D_STRUCT_TOP_AND_BOTTOM                         = (1<<6),\n   HDMI_3D_STRUCT_SIDE_BY_SIDE_HALF_HORIZONTAL           = (1<<7),\n   HDMI_3D_STRUCT_SIDE_BY_SIDE_HALF_ODD_LEFT_ODD_RIGHT   = (1<<8),\n   HDMI_3D_STRUCT_SIDE_BY_SIDE_HALF_ODD_LEFT_EVEN_RIGHT  = (1<<9),\n   HDMI_3D_STRUCT_SIDE_BY_SIDE_HALF_EVEN_LEFT_ODD_RIGHT  = (1<<10),\n   HDMI_3D_STRUCT_SIDE_BY_SIDE_HALF_EVEN_LEFT_EVEN_RIGHT = (1<<11),\n   HDMI_3D_STRUCT_FRAME_SEQUENTIAL                       = (1<<12),\n} HDMI_3D_STRUCT_T;\n\n/**\n * HDMI notifications (defined as a bit mask to be conveniently returned as a state),\n * make sure this does not clash with the values in vc_sdtv.h\n * SDTV notifications start at bit 16.\n * These values are returned by the TV service in a callback.\n */\ntypedef enum {\n   VC_HDMI_UNPLUGGED          = (1 << 0),  /**<HDMI cable is detached */\n   VC_HDMI_ATTACHED           = (1 << 1),  /**<HDMI cable is attached but not powered on */\n   VC_HDMI_DVI                = (1 << 2),  /**<HDMI is on but in DVI mode (no audio) */\n   VC_HDMI_HDMI               = (1 << 3),  /**<HDMI is on and HDMI mode is active */\n   VC_HDMI_HDCP_UNAUTH        = (1 << 4),  /**<HDCP authentication is broken (e.g. Ri mismatched) or not active */\n   VC_HDMI_HDCP_AUTH          = (1 << 5),  /**<HDCP is active */\n   VC_HDMI_HDCP_KEY_DOWNLOAD  = (1 << 6),  /**<HDCP key download successful/fail */\n   VC_HDMI_HDCP_SRM_DOWNLOAD  = (1 << 7),  /**<HDCP revocation list download successful/fail */\n   VC_HDMI_CHANGING_MODE      = (1 << 8),  /**<HDMI is starting to change mode, clock has not yet been set */\n\n} VC_HDMI_NOTIFY_T;\n#define VC_HDMI_STANDBY (VC_HDMI_ATTACHED) /* For backward code compatibility */\n\n/**\n * Callback reason and arguments from HDMI middleware\n * Each callback comes with two optional uint32_t parameters.\n * Reason                     param1       param2      remark\n * VC_HDMI_UNPLUGGED            -            -         cable is unplugged\n * VC_HDMI_STANDBY            CEA/DMT      mode code   cable is plugged in and peripheral powered off (preferred mode sent back if available)\n * VC_HDMI_DVI                CEA/DMT      mode code   DVI mode is active at said resolution\n * VC_HDMI_HDMI               CEA(3D)/DMT  mode code   HDMI mode is active at said resolution (in 3D mode if CEA3D)\n * VC_HDMI_HDCP_UNAUTH        HDCP_ERROR_T  retry?     HDCP is inactive, the error can be none if we actively disable HDCP, if retry is non-zero, HDCP will attempt to reauthenticate\n * VC_HDMI_HDCP_AUTH            -            -         HDCP is active\n * VC_HDMI_HDCP_KEY_DOWNLOAD  success?       -         HDCP key download success (zero) or not (non zero)\n * VC_HDMI_HDCP_SRM_DOWNLOAD  no. of keys    -         HDCP revocation list download set no. of keys (zero means failure)\n * VC_HDMI_CHANGING_MODE        0            0         No information is supplied in this callback\n */\n\n/* Some constants which are required on host side */\n#define HDCP_KEY_BLOCK_SIZE 328 /* KSV, padding, device keys and hash. */\n#define HDCP_KSV_LENGTH   5\n#define HDCP_MAX_DEVICE 127 /* Max. number of HDCP downstream device supported */\n#define HDCP_MAX_DEPTH 7 /* Max. number of levels HDCP 1.x can have */\n#define EDID_BLOCKSIZE 128\n#define HDMI_NUM_PACKET_BYTES 28 /* Size of HDMI infoframes minus the header */\n#define HDMI_MAX_EXPLICIT_3D_MODES 31 /* The number of explicit 3D modes is stored in 5 bits */\n#define EDID_MONITOR_DESC_SIZE  18 /* Size of detailed timing descriptor in EDID */\n#define EDID_DESC_HEADER_LEN     5 /* Size of detailed timing descriptor header in EDID */\n#define EDID_DESC_ASCII_STRING_LEN (EDID_MONITOR_DESC_SIZE - EDID_DESC_HEADER_LEN)\n#define EDID_DEVICE_VENDOR_ID_LENGTH 3 /* Expanded Device Vendor ID length in EDID */\n\n/* All CEC related constants now reside in vc_cec.h */\n\n/**\n * General callback function for both HDMI and HDCP middleware\n * reason is the notification nature\n * param1 and param2 have different meanings depending on the notification (see above)\n *\n * @param client_p is the callback context\n *\n * @param reason is the callback reason\n *\n * @param param1 is the first callback argument (meaning as above)\n *\n * @param param2 is the second callback argument (meaning as above)\n *\n * @return void\n */\ntypedef void (*HDMI_CALLBACK_T)(void *client_p, VC_HDMI_NOTIFY_T reason, uint32_t param1, uint32_t param2);\n\n/* TV service error return code */\ntypedef enum {\n   VC_HDMI_SUCCESS                  = 0, /** OK */\n   VC_HDMI_ERROR_FORMAT_UNSUPPORTED = 1, /** format not supported */\n   VC_HDMI_ERROR_INVALID_FORMAT     = 2, /** invalid format */\n   VC_HDMI_ERROR_INVALID_PROPERTY   = 3, /** invalid property */\n   VC_HDMI_ERROR_OUT_OF_RANGE       = 4, /** invalid values passed to set property */\n   VC_HDMI_ERROR_INVALID_INFOFRAME  = 5, /** invalid infoframe */\n} VC_HDMI_ERROR_T;\n\n/* Defines for backward code compatibility (these were originally in hdmi.h) */\ntypedef VC_HDMI_ERROR_T HDMI_RESULT_T;\n#define HDMI_RESULT_SUCCESS (VC_HDMI_SUCCESS)\n#define HDMI_RESULT_FAILED  (VC_HDMI_ERROR_FORMAT_UNSUPPORTED)\n\n#endif\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vmcs_host/vc_hdmi_property.h",
    "content": "/*\nCopyright (c) 2012 Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\n      THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n      ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n      WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n      DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\n      DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n      (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n      LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n      ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n      (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n      SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n/*\n * This file contains all the properties one can set in HDMI\n * Each property has up to two parameters corresponding to list of enums one can set via\n * the set/get property function from TV service (HOST) or HDMI middleware API (Videocore)\n * Each property also has a default value for these parameters. Please refer to \n * individual properties for details.\n */\n\n#ifndef _VC_HDMI_PROPERTY_H_\n#define _VC_HDMI_PROPERTY_H_\n#include \"vcinclude/common.h\"\n\n/**\n * Property type\n */\ntypedef enum {\n   HDMI_PROPERTY_PIXEL_ENCODING   = 0, /**< Set pixel encoding, value of property is HDMI_PIXEL_ENCODING_T, default is RGB full range (unless it is not supported) */\n   HDMI_PROPERTY_PIXEL_CLOCK_TYPE = 1, /**< See HDMI_PIXEL_CLOCK_TYPE_T, default is HDMI_PIXEL_CLOCK_TYPE_PAL */\n   HDMI_PROPERTY_CONTENT_TYPE     = 2, /**< Set content type flag EDID_ContentType_T */\n   HDMI_PROPERTY_FUZZY_MATCH      = 3, /**< disable (0 - default) or enable (1) fuzzy format match */\n   HDMI_PROPERTY_3D_STRUCTURE     = 4, /**< Set the 3D structure of the next HDMI power on (only for CEA mode) */\n\n   //More properties to be added here\n   HDMI_PROPERTY_MAX                   /**< place holder */\n} HDMI_PROPERTY_T;\n\n/**\n * Setting/getting a property\n */\ntypedef struct {\n   HDMI_PROPERTY_T property;\n   uint32_t param1;\n   uint32_t param2;\n   //More fields may be added here if required in future\n} HDMI_PROPERTY_PARAM_T;\n\n/**\n * PIXEL_ENCODING: param1: encoding type, param2: n/a\n * Setting encoding type is subjected to support in EDID\n */\ntypedef enum {\n   HDMI_PIXEL_ENCODING_DEFAULT = 0,  /**<Default, note that CEA modes (except VGA) default to RGB limited but DMT modes default to RGB full */\n   HDMI_PIXEL_ENCODING_RGB_LIMITED,\n   HDMI_PIXEL_ENCODING_RGB_FULL,\n   HDMI_PIXEL_ENCODING_YCbCr444_LIMITED,\n   HDMI_PIXEL_ENCODING_YCbCr444_FULL,\n   /** YCbCr 422 are not used at the moment */\n   HDMI_PIXEL_ENCODING_YCbCr422_LIMITED,\n   HDMI_PIXEL_ENCODING_YCbCr422_FULL,\n   HDMI_PIXEL_ENCODING_MAX /**<place holder */\n} HDMI_PIXEL_ENCODING_T;\n\n/**\n * PIXEL_CLOCK_TYPE: param1: pixel clock type, param2: n/a\n * Pixel clock nudge factor (set pixel clock type)\n */\ntypedef enum {\n   HDMI_PIXEL_CLOCK_TYPE_PAL  = 0, /**< Use norminal pixel clock (default) */\n   HDMI_PIXEL_CLOCK_TYPE_NTSC = 1, /**< Multiply norminal pixel clock by 1000/1001 to get the alternative frame rate e.g. 59.94Hz rather than 60, not applicable to all formats */\n   HDMI_PIXEL_CLOCK_TYPE_MAX       /**< place holder */\n} HDMI_PIXEL_CLOCK_TYPE_T;\n\n/**\n * Content type: param1: EDID content type, param2: n/a\n */\n/**\n * Content type: the enum is the actual value in AVI infoframe + 1\n * because NODATA and Graphics both have value zero\n */\ntypedef enum {\n   EDID_ContentType_NODATA   = 0x0, /**<Content type none */\n   EDID_ContentType_Graphics = 0x1, /**<Graphics, ITC must be set to 1 */\n   EDID_ContentType_Photo    = 0x2, /**<Photo */\n   EDID_ContentType_Cinema   = 0x3, /**<Cinema */\n   EDID_ContentType_Game     = 0x4, /**<Game */\n   EDID_ContentType_MAX             /**<place holder */\n} EDID_ContentType_T;\n\n/**\n * Fuzzy match: param1 zero (disabled) or non-zero (enabled), param2: n/a\n * If enabled, match format in EDID based on resolutions and formats only\n * Default is zero (disabled, so match on blanking periods and pixel clock)\n * Set to non-zero to enable fuzzy match\n */\ntypedef enum {\n   EDID_FUZZY_MATCH_DISABLED = 0x0,\n   EDID_FUZZY_MATCH_ENABLED  = 0x1,\n   EDID_FUZZY_MATCH_MAX\n} EDID_FuzzyMatch_T;\n\n/**\n * 3D structure: param1 - 3D structure (e.g. top/bottom side by side) (default value is none, i.e. 2D)\n *               param2 - n/a at the moment, may be used in the future\n *\n * 3D structure is auto reset to \"2D\" every time HDMI is power on. Only affect CEA formats.\n */\n/*\n * Matched to the 3d struct bit fields stored internally to represent 3D support in EDID\n */\ntypedef enum {\n   HDMI_3D_FORMAT_NONE = 0,           /**<plain and simple 2D! */\n   HDMI_3D_FORMAT_SBS_HALF = (1<<7),  /**<side by side half horizontal */\n   HDMI_3D_FORMAT_TB_HALF  = (1<<6),  /**<top and bottom half vertical */\n   HDMI_3D_FORMAT_FRAME_PACKING = (1<<8),  /**<frame packed */\n   HDMI_3D_FORMAT_FRAME_SEQUENTIAL = (1<<9),  /**<Output left on even frames and right on odd frames (typically 120Hz)*/\n   /* More 3D structs, e.g. full frame packing, may be added here */\n   HDMI_3D_FORMAT_INVALID = 0xFFFF\n} HDMI_3D_FORMAT_T;\n\n#endif //_VC_HDMI_PROPERTY_H_\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vmcs_host/vc_ilcs_defs.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n// OpenMAX IL Component Service definitions\n\n#ifndef VC_ILCS_DEFS_H\n#define VC_ILCS_DEFS_H\n\n#define VC_ILCS_VERSION 1\n\n#ifdef USE_VCHIQ_ARM\n#include \"interface/vchiq_arm/vchiq.h\"\n#else\n#include \"interface/vchiq/vchiq.h\"\n#endif\n\ntypedef enum {\n   IL_RESPONSE,\n   IL_CREATE_COMPONENT,\n\n   IL_GET_COMPONENT_VERSION,\n   IL_SEND_COMMAND,\n   IL_GET_PARAMETER,\n   IL_SET_PARAMETER,\n   IL_GET_CONFIG,\n   IL_SET_CONFIG,\n   IL_GET_EXTENSION_INDEX,\n   IL_GET_STATE,\n   IL_COMPONENT_TUNNEL_REQUEST,\n   IL_USE_BUFFER,\n   IL_USE_EGL_IMAGE,\n   IL_ALLOCATE_BUFFER,\n   IL_FREE_BUFFER,\n   IL_EMPTY_THIS_BUFFER,\n   IL_FILL_THIS_BUFFER,\n   IL_SET_CALLBACKS,\n   IL_COMPONENT_ROLE_ENUM,\n\n   IL_COMPONENT_DEINIT,\n\n   IL_EVENT_HANDLER,\n   IL_EMPTY_BUFFER_DONE,\n   IL_FILL_BUFFER_DONE,\n\n   IL_COMPONENT_NAME_ENUM,\n   IL_GET_DEBUG_INFORMATION,\n\n   IL_SERVICE_QUIT,\n   IL_FUNCTION_MAX_NUM,\n   IL_FUNCTION_MAX = 0x7fffffff\n} IL_FUNCTION_T;\n\n\n// size of the largest structure passed by get/set\n// parameter/config\n// this should be calculated at compile time from IL headers\n// must be a multiple of VC_INTERFACE_BLOCK_SIZE\n#define VC_ILCS_MAX_PARAM_SIZE 288\n\n// size of the largest structure below\n#define VC_ILCS_MAX_CMD_LENGTH (sizeof(IL_GET_EXECUTE_T))\n\n#define VC_ILCS_MAX_INLINE (VCHIQ_SLOT_SIZE-8-16)\n\n// all structures should be padded to be multiples of\n// VC_INTERFACE_BLOCK_SIZE in length (currently 16)\ntypedef struct {\n   void *reference;\n} IL_EXECUTE_HEADER_T;\n\ntypedef struct {\n   IL_FUNCTION_T func;\n   OMX_ERRORTYPE err;\n} IL_RESPONSE_HEADER_T;\n\n// create instance\ntypedef struct {\n   OMX_PTR mark;\n   char name[256];\n} IL_CREATE_COMPONENT_EXECUTE_T;\n\ntypedef struct {\n   IL_FUNCTION_T func;\n   OMX_ERRORTYPE err;\n   void *reference;\n   OMX_U32 numPorts;\n   OMX_U32 portDir;\n   OMX_U32 portIndex[32];\n} IL_CREATE_COMPONENT_RESPONSE_T;\n\n// set callbacks\ntypedef struct {\n   void *reference;\n   void *pAppData;\n} IL_SET_CALLBACKS_EXECUTE_T;\n\n// get state\ntypedef struct {\n   IL_FUNCTION_T func;\n   OMX_ERRORTYPE err;\n   OMX_STATETYPE state;\n} IL_GET_STATE_RESPONSE_T;\n\n// get parameter & get config\n#define IL_GET_EXECUTE_HEADER_SIZE 8\ntypedef struct {\n   void *reference;\n   OMX_INDEXTYPE index;\n   unsigned char param[VC_ILCS_MAX_PARAM_SIZE];\n} IL_GET_EXECUTE_T;\n\n#define IL_GET_RESPONSE_HEADER_SIZE 8\ntypedef struct {\n   IL_FUNCTION_T func;\n   OMX_ERRORTYPE err;\n   unsigned char param[VC_ILCS_MAX_PARAM_SIZE];\n} IL_GET_RESPONSE_T;\n\n// set parameter & set config\n#define IL_SET_EXECUTE_HEADER_SIZE 8\ntypedef struct {\n   void *reference;\n   OMX_INDEXTYPE index;\n   unsigned char param[VC_ILCS_MAX_PARAM_SIZE];\n} IL_SET_EXECUTE_T;\n\n// send command\ntypedef struct {\n   void *reference;\n   OMX_COMMANDTYPE cmd;\n   OMX_U32 param;\n   OMX_MARKTYPE mark;\n} IL_SEND_COMMAND_EXECUTE_T;\n\n// event handler callback\ntypedef struct {\n   void *reference;\n   OMX_EVENTTYPE event;\n   OMX_U32 data1;\n   OMX_U32 data2;\n   OMX_PTR eventdata;\n} IL_EVENT_HANDLER_EXECUTE_T;\n\n// use/allocate buffer\ntypedef struct {\n   void *reference;\n   OMX_PTR bufferReference;\n   OMX_U32 port;\n   OMX_U32 size;\n   void *eglImage;\n} IL_ADD_BUFFER_EXECUTE_T;\n\ntypedef struct {\n   IL_FUNCTION_T func;\n   OMX_ERRORTYPE err;\n   OMX_PTR reference;\n   OMX_BUFFERHEADERTYPE bufferHeader;\n} IL_ADD_BUFFER_RESPONSE_T;\n\n// free buffer\ntypedef struct {\n   void *reference;\n   OMX_U32 port;\n   OMX_PTR bufferReference;\n   IL_FUNCTION_T func;\n   OMX_PTR inputPrivate;\n   OMX_PTR outputPrivate;\n} IL_FREE_BUFFER_EXECUTE_T;\n\n// empty/fill this buffer\ntypedef enum {\n   IL_BUFFER_NONE,\n   IL_BUFFER_BULK,\n   IL_BUFFER_INLINE,\n   IL_BUFFER_MAX = 0x7fffffff\n} IL_BUFFER_METHOD_T;\n\n#define IL_BUFFER_BULK_UNALIGNED_MAX (32) // This value needs to be the same on voth VC and HOST.\n                                          // Here, we just manually set it to the max of VCHI_BULK_ALIGN on VC and HOST. \n#if ( VCHI_BULK_ALIGN > IL_BUFFER_BULK_UNALIGNED_MAX )\n   #error \"VCHI_BULK_ALIGN > IL_BUFFER_BULK_UNALIGNED_MAX. Just set max higher on both VC and HOST so there's space to put the unaligned bytes.\"\n#endif\ntypedef struct {\n   OMX_U8 header[IL_BUFFER_BULK_UNALIGNED_MAX-1];\n   OMX_U8 headerlen;\n   OMX_U8 trailer[IL_BUFFER_BULK_UNALIGNED_MAX-1];\n   OMX_U8 trailerlen;\n} IL_BUFFER_BULK_T;\n\ntypedef struct {\n   OMX_U8 buffer[1];\n} IL_BUFFER_INLINE_T;\n\ntypedef struct {\n   void *reference;\n   OMX_BUFFERHEADERTYPE bufferHeader;\n   IL_BUFFER_METHOD_T method;\n   OMX_U32 bufferLen;\n} IL_PASS_BUFFER_EXECUTE_T;\n\n// get component version\ntypedef struct {\n   IL_FUNCTION_T func;\n   OMX_ERRORTYPE err;\n   char name[128];\n   OMX_VERSIONTYPE component_version;\n   OMX_VERSIONTYPE spec_version;\n   OMX_UUIDTYPE uuid;\n} IL_GET_VERSION_RESPONSE_T;\n\n// get extension index\ntypedef struct {\n   void *reference;\n   char name[128];\n} IL_GET_EXTENSION_EXECUTE_T;\n\ntypedef struct {\n   IL_FUNCTION_T func;\n   OMX_ERRORTYPE err;\n   OMX_INDEXTYPE index;\n} IL_GET_EXTENSION_RESPONSE_T;\n\n// component role enum\ntypedef struct {\n   void *reference;\n   OMX_U32 index;\n} IL_COMPONENT_ROLE_ENUM_EXECUTE_T;\n\ntypedef struct {\n   IL_FUNCTION_T func;\n   OMX_ERRORTYPE err;\n   OMX_U8 role[128];\n} IL_COMPONENT_ROLE_ENUM_RESPONSE_T;\n\ntypedef struct {\n   void *reference;\n   OMX_U32 port;\n   OMX_PTR tunnel_ref;       // reference to use in requests - address of host/vc component\n   OMX_BOOL tunnel_host;     // whether tunnel_ref is a host component\n   OMX_U32 tunnel_port;\n   OMX_TUNNELSETUPTYPE setup;\n} IL_TUNNEL_REQUEST_EXECUTE_T;\n\ntypedef struct {\n   IL_FUNCTION_T func;\n   OMX_ERRORTYPE err;\n   OMX_TUNNELSETUPTYPE setup;\n} IL_TUNNEL_REQUEST_RESPONSE_T;\n\ntypedef struct {\n   int index;\n} IL_COMPONENT_NAME_ENUM_EXECUTE_T;\n\ntypedef struct {\n   IL_FUNCTION_T func;\n   OMX_ERRORTYPE err;\n   OMX_U8 name[128];\n} IL_COMPONENT_NAME_ENUM_RESPONSE_T;\n\ntypedef struct {\n   OMX_S32 len;\n} IL_GET_DEBUG_INFORMATION_EXECUTE_T;\n\n#endif // VC_ILCS_DEFS_H\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vmcs_host/vc_imageconv_defs.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n#ifndef IMAGECONV_DEFS_H\n#define IMAGECONV_DEFS_H\n\n/** Statistics for image conversion to foreign image types\n */\ntypedef struct\n{\n   uint32_t magic;\n   uint32_t size;                   /**< Size of this structure, in bytes */\n   uint32_t conversions;            /**< Total conversions so far */\n   uint32_t duplicate_conversions;  /**< Duplicate conversions (same image twice) */\n   uint32_t size_requests;          /**< Num calls to get_converted_size */\n   uint32_t consumed_count;         /**< How many converted images were consumed */\n   uint32_t failures;               /**< Failed conversions */\n   uint32_t time_spent;             /**< Time spent converting, us */\n   uint32_t max_vrf_delay;          /**< The max time waiting for the VRF */\n   uint32_t vrf_wait_time;          /**< Total time waiting for the VRF */\n   uint32_t last_mem_handle;        /**< Last mem handle converted */\n   uint32_t first_image_ts;         /**< Timestamp of first image */\n   uint32_t last_image_ts;          /**< Timestamp of first image */\n   uint32_t max_delay;              /**< Jitter */\n} IMAGECONV_STATS_T;\n\n#define IMAGECONV_STATS_MAGIC 0x494D454C\n#endif\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vmcs_host/vc_sdtv.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n/*\n * SDTV common host header for TV service\n */\n \n#ifndef _VC_SDTV_H_\n#define _VC_SDTV_H_\n\n/** Different SDTV modes */\n/** colour */\ntypedef enum SDTV_COLOUR_\n{\n   SDTV_COLOUR_UNKNOWN = 0x0,\n   SDTV_COLOUR_RGB     = 0x4,\n   SDTV_COLOUR_YPRPB   = 0x8,\n   SDTV_COLOUR_FORCE_32BIT    = 0x80000000\n} SDTV_COLOUR_T;\n/** operation mode */\ntypedef enum SDTV_MODE_T_\n{\n   SDTV_MODE_NTSC       = 0, /**<Normal NTSC */\n   SDTV_MODE_NTSC_J     = 1, /**<Japanese version of NTSC - no pedestal.*/\n   SDTV_MODE_PAL        = 2, /**<Normal PAL */\n   SDTV_MODE_PAL_M      = 3, /**<Brazilian version of PAL - 525/60 rather than 625/50, different subcarrier */\n   SDTV_MODE_FORMAT_MASK = 0x3,\n   \n   SDTV_MODE_OUTPUT_MASK = 0xc,\n\n   SDTV_MODE_YPRPB_480i = (SDTV_MODE_NTSC | SDTV_COLOUR_YPRPB),\n   SDTV_MODE_RGB_480i   = (SDTV_MODE_NTSC | SDTV_COLOUR_RGB),\n   SDTV_MODE_YPRPB_576i = (SDTV_MODE_PAL  | SDTV_COLOUR_YPRPB),\n   SDTV_MODE_RGB_576i   = (SDTV_MODE_PAL  | SDTV_COLOUR_RGB),\n\n   SDTV_MODE_OFF        = 0xf0,\n   SDTV_MODE_FORCE_32BIT = 0x80000000\n} SDTV_MODE_T;\n\n/** Different aspect ratios */\ntypedef enum SDTV_ASPECT_T_\n{\n   // TODO: extend this to allow picture placement/size to be communicated.\n   SDTV_ASPECT_UNKNOWN  = 0, /**<Unknown */\n   SDTV_ASPECT_4_3      = 1, /**<4:3 */\n   SDTV_ASPECT_14_9     = 2, /**<14:9 */\n   SDTV_ASPECT_16_9     = 3, /**<16:9 */\n   SDTV_ASPECTFORCE_32BIT = 0x80000000\n} SDTV_ASPECT_T;\n\n/** SDTV power on option */\ntypedef struct SDTV_OPTIONS_T_\n{\n   SDTV_ASPECT_T   aspect;\n} SDTV_OPTIONS_T;\n\n/**\n * Different copy protection modes\n * At the moment we have only implemented Macrovision\n */\ntypedef enum\n{\n   SDTV_CP_NONE              = 0, /**<No copy protection */\n   SDTV_CP_MACROVISION_TYPE1 = 1, /**<Macrovision Type 1 */\n   SDTV_CP_MACROVISION_TYPE2 = 2, /**<Macrovision Type 2 */\n   SDTV_CP_MACROVISION_TYPE3 = 3, /**<Macrovision Type 3 */\n   SDTV_CP_MACROVISION_TEST1 = 4, /**<Macrovision Test 1 */\n   SDTV_CP_MACROVISION_TEST2 = 5, /**<Macrovision Test 2 */\n   SDTV_CP_CGMS_COPYFREE     = 6, /**<CGMS copy freely */\n   SDTV_CP_CGMS_COPYNOMORE   = 7, /**<CGMS copy no more */\n   SDTV_CP_CGMS_COPYONCE     = 8, /**<CGMS copy once */\n   SDTV_CP_CGMS_COPYNEVER    = 9, /**<CGMS copy never */\n   SDTV_CP_WSS_COPYFREE      = 10, /**<WSS no restriction */\n   SDTV_CP_WSS_COPYRIGHT_COPYFREE = 11, /**<WSS copyright asserted */\n   SDTV_CP_WSS_NOCOPY        = 12, /**<WSS copying restricted */\n   SDTV_CP_WSS_COPYRIGHT_NOCOPY = 13, /**<WSS copying restriced, copyright asserted */\n   SDTV_CP_FORCE_32BIT = 0x80000000\n} SDTV_CP_MODE_T;\n\n/**\n * SDTV internal state\n */\ntypedef struct {\n   uint32_t state;\n   uint32_t width;\n   uint32_t height;\n   uint16_t frame_rate;\n   uint16_t scan_mode;\n   SDTV_MODE_T mode;\n   SDTV_OPTIONS_T display_options;\n   SDTV_COLOUR_T colour;\n   SDTV_CP_MODE_T cp_mode;\n} SDTV_DISPLAY_STATE_T;\n\n/**\n * SDTV notifications\n */\ntypedef enum \n{\n   VC_SDTV_UNPLUGGED          = 1 << 16, /**<SDTV cable unplugged, subject to platform support */\n   VC_SDTV_ATTACHED           = 1 << 17, /**<SDTV cable is plugged in */\n   VC_SDTV_NTSC               = 1 << 18, /**<SDTV is in NTSC mode */\n   VC_SDTV_PAL                = 1 << 19, /**<SDTV is in PAL mode */\n   VC_SDTV_CP_INACTIVE        = 1 << 20, /**<Copy protection disabled */\n   VC_SDTV_CP_ACTIVE          = 1 << 21  /**<Copy protection enabled */\n} VC_SDTV_NOTIFY_T;\n#define VC_SDTV_STANDBY (VC_SDTV_ATTACHED) /* For backward code compatibility, to be consistent with HDMI */\n\n/**\n * Callback reason and arguments from vec middleware\n * Each callback comes with two optional uint32_t parameters.\n * Reason                     param1       param2      remark\n * VC_SDTV_UNPLUGGED            -            -         cable is unplugged\n * VC_SDTV_STANDBY              -            -         cable is plugged in\n * VC_SDTV_NTSC              SDTV_MODE_T SDTV_ASPECT_T NTSC mode active with said aspect ratio\n * VC_SDTV_PAL               SDTV_MODE_T SDTV_ASPECT_T PAL  mode active with said aspect ratio\n * VC_SDTV_CP_INACTIVE          -            -         copy protection is inactive\n * VC_SDTV_CP_ACTIVE         SDTV_CP_MODE_T  -         copy protection is active\n */\n\n#endif\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vmcs_host/vc_service_common.h",
    "content": "/*\n* Copyright (c) 2012 Broadcom Europe Ltd\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n/*\n * Common definitions for services\n */\n\n#ifndef _VC_SERVICE_COMMON_DEFS_H_\n#define _VC_SERVICE_COMMON_DEFS_H_\n#include \"vcinclude/common.h\"\n//Map VCHI return value to internal error code\n//VCHI return +1 for retry so we will map it to -2 to allow\n//servers to use positive values to indicate alternative return values\ntypedef enum {\n   VC_SERVICE_VCHI_SUCCESS = 0,\n   VC_SERVICE_VCHI_VCHIQ_ERROR = -1,\n   VC_SERVUCE_VCHI_RETRY = -2,\n   VC_SERVICE_VCHI_UNKNOWN_ERROR = -3\n} VC_SERVICE_VCHI_STATUS_T;\n\nextern VC_SERVICE_VCHI_STATUS_T vchi2service_status(int32_t x);\nextern const char* vchi2service_status_string(VC_SERVICE_VCHI_STATUS_T status);\n\n#endif //#ifndef _VC_SERVICE_COMMON_DEFS_H_\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vmcs_host/vc_tvservice.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n/*\n * TV service host API,\n * See vc_hdmi.h for HDMI related constants\n * See vc_sdtv.h for SDTV related constants\n */\n\n#ifndef _VC_TVSERVICE_H_\n#define _VC_TVSERVICE_H_\n\n#include \"vcinclude/common.h\"\n#include \"interface/vcos/vcos.h\"\n#include \"interface/vchi/vchi.h\"\n#include \"interface/vmcs_host/vc_tvservice_defs.h\"\n#include \"interface/vmcs_host/vc_hdmi.h\"\n#include \"interface/vmcs_host/vc_sdtv.h\"\n\n/**\n * \\file\n *\n * This API defines the controls for both HDMI and analogue TVs. It allows\n * the user to dynamically switch between HDMI and SDTV without having\n * to worry about switch one off before turning the other on. It also\n * allows the user to query the supported HDMI resolutions and audio\n * formats and turn on/off copy protection.\n *\n * There are three ways to turn on HDMI: preferred mode; best matched mode\n * and explicit mode. See the three power on functions for details.\n */\n\n/**\n * TVSERVICE_CALLBACK_T is the callback function for host side notification.\n * Host applications register a single callback for all TV related notifications.\n * See <DFN>VC_HDMI_NOTIFY_T</DFN> and <DFN>VC_SDTV_NOTIFY_T</DFN> in vc_hdmi.h and vc_sdtv.h\n * respectively for list of reasons and respective param1 and param2\n *\n * @param callback_data is the context passed in during the call to vc_tv_register_callback\n *\n * @param reason is the notification reason\n *\n * @param param1 is the first optional parameter\n *\n * @param param2 is the second optional parameter\n *\n * @return void\n */\ntypedef void (*TVSERVICE_CALLBACK_T)(void *callback_data, uint32_t reason, uint32_t param1, uint32_t param2);\n\n/* API at application start time */\n/**\n * <DFN>vc_vchi_tv_init</DFN> is called at the beginning of the application\n * to initialise the client to TV service\n *\n * @param initialise_instance is the VCHI instance\n *\n * @param array of pointers of connections\n *\n * @param number of connections (currently this is always <DFN>1</DFN>\n *\n * @return Zero is successful A negative return value indicates failure (which may mean it has not been started on VideoCore).\n */\nVCHPRE_ int vc_vchi_tv_init(VCHI_INSTANCE_T initialise_instance, VCHI_CONNECTION_T **connections, uint32_t num_connections );\n\n/**\n * <DFN>vc_vchi_tv_stop</DFN> is called to stop the host side of TV service.\n *\n * @param none\n *\n * @return void\n */\nVCHPRE_ void vc_vchi_tv_stop( void );\n\n/**\n * Host applications should call <DFN>vc_tv_register_callback</DFN> at\n * the beginning to register a callback function to handle all notifications.\n * See <DFN>TVSERVICE_CALLBACK_T </DFN>\n *\n * @param callback function\n *\n * @param callback_data is the context to be passed when function is called\n *\n * @return void\n */\nVCHPRE_ void vc_tv_register_callback(TVSERVICE_CALLBACK_T callback, void *callback_data);\n\n/**\n * <DFN>vc_tv_unregister_callback</DFN> removes a function registered with\n * <DFN>vc_tv_register_callback</DFN> from the list of callbacks.\n *\n * @param callback function\n *\n * @return void\n */\nVCHPRE_ void vc_tv_unregister_callback(TVSERVICE_CALLBACK_T callback);\n\n/**\n * <DFN>vc_tv_unregister_callback</DFN> removes a function registered with\n * <DFN>vc_tv_register_callback</DFN> from the list of callbacks.\n * In contrast to vc_tv_unregister_callback this one matches not only the\n * function pointer but also the data pointer before removal.\n *\n * @param callback function\n *\n * @return void\n */\nVCHPRE_ void vc_tv_unregister_callback_full(TVSERVICE_CALLBACK_T callback, void *callback_data);\n\n/**\n * In the following API any functions applying to HDMI only will have hdmi_\n * in the name, ditto for SDTV only will have sdtv_ in the name,\n * Otherwise the function applies to both SDTV and HDMI (e.g. power off)\n */\n\n/**\n * <DFN>vc_tv_get_state</DFN> is used to obtain the current TV state.\n * Host applications should call this function right after registering\n * a callback in case any notifications are missed.\n *\n * Now deprecated - use vc_tv_get_display_state instead\n *\n * @param pointer to TV_GET_STATE_RESP_T\n *\n * @return zero if the command is sent successfully, non zero otherwise\n * If the command fails to be sent, passed in state is unchanged\n *\n */\nVCHPRE_ int VCHPOST_ vc_tv_get_state(TV_GET_STATE_RESP_T *tvstate);\n\n/**\n * <DFN>vc_tv_get_display_state</DFN> is used to obtain the current TV display\n * state. This function supersedes vc_tv_get_state (which is only kept for\n * backward compatibility.\n * Host applications should call this function right after registering\n * a callback in case any notifications are missed.\n *\n * @param pointer to TV_DISPLAY_STATE_T\n *\n * @return zero if the command is sent successfully, non zero otherwise\n * If the command fails to be sent, passed in state is unchanged\n *\n */\nVCHPRE_ int VCHPOST_ vc_tv_get_display_state(TV_DISPLAY_STATE_T *tvstate);\n\n/**\n * Use <DFN>vc_tv_hdmi_power_on_preferred</DFN> if you don't care what resolutions\n * a TV supports and just want to turn on its native resolution. Analogue TV will\n * be powered down if on (same for the following two HDMI power on functions.)\n * If power on is successful, a host application must wait for the power on complete\n * callback before attempting to open the display.\n *\n * @param none\n *\n * @return single value interpreted as HDMI_RESULT_T (zero means success)\n *         if successful, there will be a callback when the power on is complete\n *\n **/\nVCHPRE_ int VCHPOST_ vc_tv_hdmi_power_on_preferred( void );\n\n/**\n * Same as above, but tell the TV to enter 3D mode. The TV will go to 2D mode\n * if the preferred mode doesn't support 3D.\n **/\nVCHPRE_ int VCHPOST_ vc_tv_hdmi_power_on_preferred_3d( void );\n\n/**\n * Use <DFN>vc_tv_hdmi_power_on_best</DFN> to power on HDMI at best matched resolution\n * based on passed in parameters. Use HDMI_MODE_MATCH_FRAMERATE if you want to\n * match the frame rate; use HDMI_MODE_MATCH_RESOLUTION if you want to match on\n * screen size; add HDMI_MODE_MATCH_SCANMODE if you want to force\n * interlaced/progressive mode. If no matching mode is found, the native resolution\n * will be used instead.\n *\n * @param width is the desired minimum screen width\n *\n * @param height is the desired minimum screen height\n *\n * @param rate is the desired frame rate\n *\n * @param scan_mode (HDMI_NONINTERLACED / HDMI_INTERLACED) is the desired scan mode\n *\n * @param match flags is the matching flag <DFN>EDID_MODE_MATCH_FLAG_T</DFN>\n *\n * @return same as <DFN>vc_tv_hdmi_power_on_preferred</DFN>\n */\nVCHPRE_ int VCHPOST_ vc_tv_hdmi_power_on_best(uint32_t width, uint32_t height, uint32_t frame_rate,\n                                              HDMI_INTERLACED_T scan_mode, EDID_MODE_MATCH_FLAG_T match_flags);\n\n/**\n * Same as above, but tell the TV to enter 3D mode. The TV will go to 2D mode\n * if no suitable 3D mode can be found.\n **/\nVCHPRE_ int VCHPOST_ vc_tv_hdmi_power_on_best_3d(uint32_t width, uint32_t height, uint32_t frame_rate,\n                                              HDMI_INTERLACED_T scan_mode, EDID_MODE_MATCH_FLAG_T match_flags);\n\n/**\n * Use <DFN>vc_tv_hdmi_power_on_explicit</DFN> if you want full control over what mode\n * the TV is driven. This function is used, for example, when the host has the EDID\n * and HDMI middleware does not know. If HDMI middleware has knowledge of EDID, the\n * passed in mode is still subject to TV's supported modes\n *\n * @param mode (HDMI_MODE_HDMI/HDMI_MODE_DVI/HDMI_MODE_3D)\n *\n * @param group (HDMI_RES_GROUP_CEA/HDMI_RES_GROUP_DMT)\n *\n * @param code either <DFN>HDMI_CEA_RES_CODE_T</DFN> or <DFN>HDMI_DMT_RES_CODE_T</DFN>\n *\n * @return same as <DFN>vc_tv_hdmi_power_on_preferred</DFN>\n */\nVCHPRE_ int VCHPOST_ vc_tv_hdmi_power_on_explicit_new(HDMI_MODE_T mode, HDMI_RES_GROUP_T group, uint32_t code);\n\n/**\n * <DFN>vc_tv_sdtv_power_on</DFN> is used to turn on analogue TV. HDMI will\n * automatically be powered off if on.\n *\n * @param SDTV mode <DFN>SDTV_MODE_T</DFN>\n *\n * @param options <DFN>SDTV_OPTIONS_T</DFN>\n *\n * @return single value (zero means success) if successful, there will be a callback when the power on is complete\n *\n */\nVCHPRE_ int VCHPOST_ vc_tv_sdtv_power_on(SDTV_MODE_T mode, SDTV_OPTIONS_T *options);\n\n/**\n * <DFN>vc_tv_power_off</DFN> is used to turn off either analogue or HDMI output.\n * If HDMI is powered down, there will be a callback with reason UNPLUGGED (if no\n * cable is attached) or STANDBY (if a cable is attached)\n *\n * @param none\n *\n * @return whether command is succcessfully sent\n *\n */\nVCHPRE_ int VCHPOST_ vc_tv_power_off( void );\n\n/**\n * <DFN>vc_tv_hdmi_get_supported_modes</DFN> is used to get a list of supported\n * modes for a particular standard (CEA/DMT/CEA3D). Prefer resolution (group and mode)\n * is also returned, if needed. If there are more modes supported than the size of the array\n * supply, only the array will be filled.\n *\n * @param group(HDMI_RES_GROUP_CEA/HDMI_RES_GROUP_DMT)\n *\n * @param array of <DFN>TV_SUPPORT_MODE_T</DFN> struct\n *\n * @param length of array above (in elements, not bytes)\n *\n * @pointer to preferred group (can be NULL)\n *\n * @pointer to prefer mode code (can be NULL)\n *\n * @return the number of modes actually written in the array,\n *         zero means no modes (no EDID or cable unplugged)\n *\n */\nVCHPRE_ int VCHPOST_ vc_tv_hdmi_get_supported_modes_new(HDMI_RES_GROUP_T group,\n                                                    TV_SUPPORTED_MODE_NEW_T *supported_modes,\n                                                    uint32_t max_supported_modes,\n                                                    HDMI_RES_GROUP_T *preferred_group,\n                                                    uint32_t *preferred_mode);\n/**\n * <DFN>vc_tv_hdmi_mode_supported</DFN> is used to query whether a particular mode\n * is supported or not.\n *\n * @param resolution standard (HDMI_RES_GROUP_CEA/HDMI_RES_GROUP_DMT)\n *\n * @param mode code\n *\n * @return > 0 means supported, 0 means unsupported, < 0 means error\n *\n */\nVCHPRE_ int VCHPOST_ vc_tv_hdmi_mode_supported(HDMI_RES_GROUP_T group,\n                                               uint32_t mode);\n\n/**\n * <DFN>vc_tv_hdmi_audio_supported</DFN> is used to query whether a\n * particular audio format is supported. By default a device has to support\n * 16-bit stereo PCM at 32/44.1/48 kHz if audio is supported at all.\n * Support of other audio formats allow SPDIF to be used.\n * A return value of zero means the audio format is completely supported.\n * Any non-zero values are interpreted as bit mask (EDID_AUDIO_SUPPORT_FLAG_T).\n * For example, if EDID_AUDIO_NO_SUPPORT is set, the audio format is not supported.\n * If EDID_AUDIO_CHAN_UNSUPPORTED is set, the max no. of channels has exceeded.\n *\n * @param audio format supplied as (<DFN>EDID_AudioFormat</DFN> + <DFN>EDID_AudioCodingExtension</DFN>)\n *\n * @param no. of channels (1-8)\n *\n * @param sample rate <DFN>EDID_AudioSampleRate</DFN> but NOT \"refer to header\"\n *\n * @param bit rate (or sample size if pcm) use <DFN>EDID_AudioSampleSize</DFN> as sample size argument\n *\n * @return: single value return interpreted as flags in <DFN>EDID_AUDIO_SUPPORT_FLAG_T</DFN>\n *\n */\nVCHPRE_ int VCHPOST_ vc_tv_hdmi_audio_supported(uint32_t audio_format, uint32_t num_channels,\n                                                EDID_AudioSampleRate fs, uint32_t bitrate);\n\n/**\n * Use <DFN>vc_tv_enable_copyprotect</DFN> to turn on copy protection.\n * For HDMI, only HDMI_CP_HDCP is recognised.\n * For SDTV, use one of the values in SDTV_CP_MODE_T\n *\n * @param copy protect mode\n *\n * @param time out in milliseconds (only applicable to HDMI)\n *\n * @return 0 means success, additional result via callback\n *\n */\nVCHPRE_ int VCHPOST_ vc_tv_enable_copyprotect(uint32_t cp_mode, uint32_t timeout);\n\n/**\n * Use <DFN>vc_tv_disable_copyprotect</DFN> to turn off copy protection\n *\n * @param none\n *\n * @rturn 0 means success, additional result via callback\n *\n */\nVCHPRE_ int VCHPOST_ vc_tv_disable_copyprotect( void );\n\n/**\n * Use <DFN>vc_tv_show_info</DFN> to show or hide info screen.\n * Only usable in HDMI at the moment.\n *\n * @param show (1) or hide (0) info screen\n *\n * @return zero if command is successfully sent\n *\n */\nVCHPRE_ int VCHPOST_ vc_tv_show_info(uint32_t show);\n\n/**\n * <DFN>vc_tv_hdmi_get_av_latency</DFN> is used to get the AV latency\n * (in ms) for HDMI (lipsync), only valid if HDMI is currently powered on,\n * otherwise you get zero. The latency is defined as the relative delay\n * of the video stream to the audio stream\n *\n * @param none\n *\n * @return latency (zero if error or latency is not defined),\n *         < 0 if failed to send command)\n *\n */\nVCHPRE_ int VCHPOST_ vc_tv_hdmi_get_av_latency( void );\n\n/**\n * Use <DFN>vc_tv_hdmi_set_hdcp_key</DFN> to download HDCP key to HDCP middleware\n *\n * @param AES encrypted key block (328 bytes)\n *\n * @return single value return indicating queued status\n *         Callback indicates the validity of key\n */\nVCHPRE_ int VCHPOST_ vc_tv_hdmi_set_hdcp_key(const uint8_t *key);\n\n/**\n * Use <DFN>vc_tv_hdmi_set_hdcp_revoked_list</DFN> to download SRM\n * revoked list\n *\n * @param list\n *\n * @param size of list (no. of keys)\n *\n * @return single value return indicating queued status\n *         Callback indicates the number of keys set (zero if failed, unless you are clearing the list)\n *\n */\nVCHPRE_ int VCHPOST_ vc_tv_hdmi_set_hdcp_revoked_list(const uint8_t *list, uint32_t num_keys);\n\n/**\n * <DFN>vc_tv_hdmi_set_spd</DFN> is used to set the SPD infoframe.\n *\n * @param manufacturer (max. 8 characters)\n *\n * @param description (max. 16 characters)\n *\n * @param product type <DFN>HDMI_SPD_TYPE_CODE_T</DFN>\n *\n * @return whether command was sent successfully (zero means success)\n *\n */\nVCHPRE_ int VCHPOST_ vc_tv_hdmi_set_spd(const char *manufacturer, const char *description, HDMI_SPD_TYPE_CODE_T type);\n\n/**\n * <DFN>vc_tv_hdmi_set_display_options</DFN> is used to set the\n * active area for HDMI (bar width/height should be set to zero if absent)\n * This information is conveyed in AVI infoframe.\n *\n * @param aspect ratio <DFN>HDMI_ASPECT_T</DFN>\n *\n * @param left bar width\n *\n * @param right bar width\n *\n * @param top bar height\n *\n * @param bottom bar height\n *\n * @return whether command was sent successfully (zero means success)\n *\n */\nVCHPRE_ int VCHPOST_ vc_tv_hdmi_set_display_options(HDMI_ASPECT_T aspect, uint32_t left_bar_width, uint32_t right_bar_width, uint32_t top_bar_height, uint32_t bottom_bar_height, uint32_t overscan_flags);\n\n/**\n * Use <DFN>vc_tv_test_mode_start</DFN> to generate test signal.\n * At the moment only DVI test signal is supported.\n * HDMI must be powered off before this function is called.\n *\n * @param 24-bit background colour (if applicable)\n *\n * @param test mode <DFN>TV_TEST_MODE_T</DFN>\n *\n * @return whether command was sent successfully (zero means success)\n *\n */\nVCHPRE_ int VCHPOST_ vc_tv_test_mode_start(uint32_t colour, TV_TEST_MODE_T test_mode);\n\n/**\n * Use <DFN>vc_tv_test_mode_stop</DFN> to stop the test signal and power down\n * HDMI.\n *\n * @param none\n *\n * @return whether command was sent successfully (zero means success)\n *\n */\nVCHPRE_ int VCHPOST_ vc_tv_test_mode_stop( void );\n\n/**\n * <DFN>vc_tv_hdmi_ddc_read</DFN> allows an host application to read EDID\n * with DDC protocol.\n *\n * @param offset\n *\n * @param length to read (this is typically 128 bytes to coincide with EDID block size)\n *\n * @param pointer to buffer, must be 16 byte aligned\n *\n * @returns length of data read (so zero means error) and the buffer will be filled\n *          only if there is no error\n *\n */\nVCHPRE_ int VCHPOST_ vc_tv_hdmi_ddc_read(uint32_t offset, uint32_t length, uint8_t *buffer);\n\n/**\n * Sets the TV state to attached.\n * Required when hotplug interrupt is not handled by VideoCore.\n *\n * @param attached  non-zero if the TV is attached or zero for unplugged.\n */\nVCHPRE_ int VCHPOST_ vc_tv_hdmi_set_attached(uint32_t attached);\n\n/**\n * Sets one of the HDMI properties. HDMI properties persist\n * between HDMI power on/off\n *\n * @param property [in]\n *\n * @return zero if successful, non-zero otherwise\n */\nVCHPRE_ int VCHPOST_ vc_tv_hdmi_set_property(const HDMI_PROPERTY_PARAM_T *property);\n\n/**\n * Gets the current value of an HDMI property.\n *\n * @param property [in/out]\n *\n * @return zero if success (param1/param2 will be set), non-zero otherwise (param1/param2 will not be set)\n */\nVCHPRE_ int VCHPOST_ vc_tv_hdmi_get_property(HDMI_PROPERTY_PARAM_T *property);\n\n/**\n * Converts the notification reason to a string.\n *\n * @param reason is the notification reason\n * @return  The notification reason as a string.\n */\nVCHPRE_ const char* vc_tv_notification_name(VC_HDMI_NOTIFY_T reason);\n\n/**\n * Get the unique device ID from the EDID\n * @param pointer to device ID struct\n * @return zero if successful, non-zero if failed.\n */\nVCHPRE_ int VCHPOST_  vc_tv_get_device_id(TV_DEVICE_ID_T *id);\n\n// temporary: maintain backwards compatibility\nVCHPRE_ int VCHPOST_ vc_tv_hdmi_get_supported_modes(HDMI_RES_GROUP_T group,\n                                                    TV_SUPPORTED_MODE_T *supported_modes,\n                                                    uint32_t max_supported_modes,\n                                                    HDMI_RES_GROUP_T *preferred_group,\n                                                    uint32_t *preferred_mode);\n// temporary: maintain backwards compatibility\nVCHPRE_ int VCHPOST_ vc_tv_hdmi_power_on_explicit(HDMI_MODE_T mode, HDMI_RES_GROUP_T group, uint32_t code);\n\n#endif\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vmcs_host/vc_tvservice_defs.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n/*\n * TV service command enumeration and parameter types.\n */\n\n#ifndef _VC_TVSERVICE_DEFS_H_\n#define _VC_TVSERVICE_DEFS_H_\n#include \"vcinclude/common.h\"\n#include \"interface/vchi/message_drivers/message.h\"\n#include \"vc_hdmi.h\"\n#include \"vc_sdtv.h\"\n\n#define VC_TVSERVICE_VER   1\n\n#define TVSERVICE_MSGFIFO_SIZE 1024\n#define TVSERVICE_CLIENT_NAME MAKE_FOURCC(\"TVSV\")\n#define TVSERVICE_NOTIFY_NAME MAKE_FOURCC(\"TVNT\")\n\n#define TVSERVICE_MAX_CALLBACKS  5\n\n//TV service commands\ntypedef enum {\n   VC_TV_GET_STATE = 0,\n   VC_TV_HDMI_ON_PREFERRED,\n   VC_TV_HDMI_ON_BEST,\n   VC_TV_HDMI_ON_EXPLICIT,\n   VC_TV_SDTV_ON,\n   VC_TV_OFF,\n   VC_TV_QUERY_SUPPORTED_MODES,\n   VC_TV_QUERY_MODE_SUPPORT,\n   VC_TV_QUERY_AUDIO_SUPPORT,\n   VC_TV_ENABLE_COPY_PROTECT,\n   VC_TV_DISABLE_COPY_PROTECT,\n   VC_TV_SHOW_INFO,\n   VC_TV_GET_AV_LATENCY,\n   VC_TV_HDCP_SET_KEY,\n   VC_TV_HDCP_SET_SRM,\n   VC_TV_SET_SPD,\n   VC_TV_SET_DISPLAY_OPTIONS,\n   VC_TV_TEST_MODE_START,\n   VC_TV_TEST_MODE_STOP,\n   VC_TV_DDC_READ,\n   VC_TV_SET_ATTACHED,\n   VC_TV_SET_PROP,\n   VC_TV_GET_PROP,\n   VC_TV_GET_DISPLAY_STATE,\n   VC_TV_QUERY_SUPPORTED_MODES_ACTUAL,\n   VC_TV_GET_DEVICE_ID,\n   //Add more commands here\n   VC_TV_END_OF_LIST\n} VC_TV_CMD_CODE_T;\n\n//Parameters for each command (padded to multiple of 16 bytes)\n//See vc_hdmi.h and vc_sdtv.h for details\n\n//GET_STATE\n//Parameters: none\n//Reply: state (flags of VC_HDMI_NOTIFY_T and VC_SDTV_NOTIFY_T)\n//       current width\n//       current height\n//       current refresh rate\n//       current scan mode\n\ntypedef struct {\n   uint32_t state;     /**<TV state is a union of bitmask of VC_HDMI_NOTIFY_T and VC_SDTV_NOTIFY_T */\n   uint32_t width;     /**<Current display width if TV is on */\n   uint32_t height;    /**<Current display height if TV is on */\n   uint16_t frame_rate;/**<Current refresh rate is TV is on */\n   uint16_t scan_mode; /**<Current scanmode 0 for progressive, 1 for interlaced */\n} TV_GET_STATE_RESP_T;\n\n//Generic single returned interpreted based on the command\ntypedef struct {\n   int32_t ret; //Single return value\n} TV_GENERAL_RESP_T;\n\n//HDMI_ON_PREFERRED\n//Parameters: 3d mode (on/off)\n//Reply: single return value interpreted as HDMI_RESULT_T or SDTV equivalent (all single reply value will be of this form)\ntypedef struct {\n   uint32_t in_3d;\n} TV_HDMI_ON_PREFERRED_PARAM_T;\n\n//HDMI_ON_BEST\n//Parameters: width, height, frame rate, scan mode, matching flag (EDID_MODE_MATCH_FLAG_T), 3d mode (on/off)\n//Reply: single return value interpreted as HDMI_RESULT_T or SDTV equivalent\ntypedef struct {\n   uint32_t width;\n   uint32_t height;\n   uint32_t frame_rate;\n   uint32_t scan_mode;\n   uint32_t match_flags;\n   uint32_t in_3d;\n} TV_HDMI_ON_BEST_PARAM_T;\n\n//HDMI_ON_EXPLICIT\n//Parameters: hdmi_mode, standard, mode\n//Reply: same as above\ntypedef struct {\n   uint32_t hdmi_mode; //DVI or HDMI\n   uint32_t group;\n   uint32_t mode;\n} TV_HDMI_ON_EXPLICIT_PARAM_T;\n\n//SDTV_ON\n//Parameters: SDTV mode, aspect ratio\n//Reply: Same as above\ntypedef struct {\n   uint32_t mode;\n   uint32_t aspect;\n} TV_SDTV_ON_PARAM_T;\n\n//TV_OFF\n//Parameters: none\n//Reply: none\n\n//TV_QUERY_SUPPORTED_MODES\n//Parameters: standard (CEA/DMT) sent as uint32_t\n//Reply: how many modes there are in this group,\n//       preferred resolution\n\n//TV_QUERY_SUPPORTED_MODES_ACTUAL (This  downloads the array of supported modes)\n//Parameters: standard (CEA/DMT) sent as uint32_t,\n//            table size supplied\n//Reply: how many modes which will be returned,\n//       prefer resolution,\n//       the actual array of modes (via bulk transfer)\n\ntypedef struct {\n   uint32_t scan_mode    : 1; /**<1 is interlaced, 0 for progressive */\n   uint32_t native       : 1; /**<1 means native mode, 0 otherwise */\n   uint32_t group        : 3; /**<group */\n   uint32_t code         : 7; /**<mode code */\n   uint32_t pixel_rep    : 3; /**<pixel repetition (zero means no repetition)*/\n   uint32_t aspect_ratio : 5; /**<aspect ratio of the format */\n   uint16_t frame_rate;    /**<frame rate */\n   uint16_t width;         /**<frame width */\n   uint16_t height;        /**<frame height */\n   uint32_t pixel_freq;    /**<pixel clock in Hz */\n   uint32_t struct_3d_mask;/**<3D structure supported for this mode, only valid if group == CEA. This is a bitmask of HDMI_3D_STRUCT_T */\n} TV_SUPPORTED_MODE_NEW_T;\n\ntypedef struct {\n   uint16_t scan_mode : 1; /**<1 is interlaced, 0 for progressive */\n   uint16_t native    : 1; /**<1 means native mode, 0 otherwise */\n   uint16_t code      : 7; /**<mode code */\n   uint16_t frame_rate;    /**<frame rate */\n   uint16_t width;         /**<frame width */\n   uint16_t height;        /**<frame height */\n} TV_SUPPORTED_MODE_T;\n\ntypedef struct {\n   uint32_t num_supported_modes;\n   uint32_t preferred_group;\n   uint32_t preferred_mode;\n} TV_QUERY_SUPPORTED_MODES_RESP_T;\n\n//num_supported_modes is the no. of modes available in that group for TV_QUERY_SUPPORTED_MODES\n//and no. of modes which will be bulk sent across in TV_QUERY_SUPPORTED_MODES_ACTUAL\n\n//For TV_QUERY_SUPPORTED_MODES_ACTUAL, there will be a separate bulk receive\n//containing the supported modes array\n\n//TV_QUERY_MODE_SUPPORT\n//Parameters: stardard, mode\n//Reply: yes/no\n//but the return value meaning is reversed (zero is unsupported, non-zero is supported)\ntypedef struct {\n   uint32_t group;\n   uint32_t mode;\n} TV_QUERY_MODE_SUPPORT_PARAM_T;\n\n//TV_QUERY_AUDIO_SUPPORT\n//Parameters: audio format, no. of channels, sampling frequency, bitrate/sample size\n//Reply: single value interpreted as flags EDID_AUDIO_SUPPORT_FLAG_T\ntypedef struct {\n   uint32_t audio_format; //EDID_AudioFormat (if format is eExtended, add EDID_AudioCodingExtension to the audio format)\n   uint32_t num_channels; // 1-8\n   uint32_t fs;           // EDID_AudioSampleRate\n   uint32_t bitrate;      // EDID_AudioSampleSize if format == PCM, bitrate otherwise\n} TV_QUERY_AUDIO_SUPPORT_PARAM_T;\n\n//TV_ENABLE_COPY_PROTECT\n//Parameters: copy protect mode (for HDMI it will always be HDCP), timeout\n//Reply: single return value - cp result arrive via callback\ntypedef struct {\n   uint32_t cp_mode;\n   uint32_t timeout;\n} TV_ENABLE_COPY_PROTECT_PARAM_T;\n\n//TV_DISABLE_COPY_PROTECT\n//Parameters: none\n//Reply: single value return - results arrive via callback\n\n//TV_SHOW_INFO\n//Parameters: visible\n//Reply: none\ntypedef struct {\n   uint32_t visible; //0 to hide the screen\n} TV_SHOW_INFO_PARAM_T;\n\n//TV_GET_AV_LATENCY\n//Parameters: none\n//Reply: single value interpreted as latency in ms\n\n\n//TV_HDCP_SET_KEY\n//Parameters: key block buffer (fixed size HDCP_KEY_BLOCK_SIZE)\n//Reply: none, key validity result arrives via callback\ntypedef struct {\n   uint8_t key[HDCP_KEY_BLOCK_SIZE];\n} TV_HDCP_SET_KEY_PARAM_T;\n\n//TV_HDCP_SET_SRM\n//Parameters: num of keys, pointer to revocation list (transferred as buffer)\n//Reply: none, callback indicates no. of keys set\ntypedef struct {\n   uint32_t num_keys;\n} TV_HDCP_SET_SRM_PARAM_T;\n\n//TV_SET_SPD\n//Parameters: name [8], description [16], type\n//Reply: none\n#define TV_SPD_NAME_LEN 8\n#define TV_SPD_DESC_LEN 16\ntypedef struct {\n   char manufacturer[TV_SPD_NAME_LEN];\n   char description[TV_SPD_DESC_LEN];\n   uint32_t type;\n} TV_SET_SPD_PARAM_T;\n\n//TV_SET_DISPLAY_OPTIONS\n//Parameters: aspect ratio (HDMI_ASPECT_T), vert bar present (bool),\n//            left bar width, right bar width, horiz bar present (bool)\n//            top bar height, bottom bar height\n//Reply: none\ntypedef struct {\n   uint32_t aspect;\n   uint32_t vertical_bar_present;\n   uint32_t left_bar_width;\n   uint32_t right_bar_width;\n   uint32_t horizontal_bar_present;\n   uint32_t top_bar_height;\n   uint32_t bottom_bar_height;\n   uint32_t overscan_flags;\n} TV_SET_DISPLAY_OPTIONS_PARAM_T;\n\n//TV_TEST_MODE_START\n//Parameters: rgb colour, test mode\n//Reply: none\n\n//Actual enums used for test mode\ntypedef enum {\n   TV_TEST_MODE_DISABLED        = 0, //Test mode disabled\n   TV_TEST_MODE_SOLID_BACKGND   = 1, //Solid background colur\n   TV_TEST_MODE_SOLID_VERTICAL  = 2, //Vertical bars\n   TV_TEST_MODE_SHADED_VERTICAL = 3, //Shaded vertical bars\n   TV_TEST_MODE_SHADED_WHITE_V  = 4, //White vertical bars\n   TV_TEST_MODE_SHADED_WHITE_H  = 5, //White horizontal bars\n   TV_TEST_MODE_SHADED_RGB      = 6, //Shaded RGB + white bars\n   TV_TEST_MODE_WALKING         = 7, //Walking one across 24-bit RGB\n   TV_TEST_MODE_DELAYED         = 8, //Delayed shaded RGB bars\n   TV_TEST_MODE_HVD             = 9, //Horizontal G, Vert. B, Diag. R bars\n   TV_TEST_MODE_ODD_CH          =10, //Odd field crosshairs\n   TV_TEST_MODE_EVEN_CH         =11, //Even field crosshairs\n   TV_TEST_MODE_32x32           =12, //32x32 white grid\n   TV_TEST_MODE_WYCGMRBK_SOLID  =13, //Solid blah blah\n   TV_TEST_MODE_WYCGMRBK_SHADED =14, //Shaded blah blah\n   TV_TEST_MODE_32x32_DIAGONAL  =15  //32x32 white diagonal grid\n} TV_TEST_MODE_T;\n\ntypedef struct {\n   uint32_t colour; //RGB colour\n   uint32_t test_mode; //one of the TV_TEST_MODE_T enums above\n} TV_TEST_MODE_START_PARAM_T;\n\n//TV_TEST_MODE_STOP\n//Parameters: none\n//Reply: none\n\n//TV_DDC_READ\n//Parameters: offset, length\n//Reply: length of data actually read (so zero means error),\n//and fills in the passed in buffer if no error\ntypedef struct {\n   uint32_t offset;\n   uint32_t length;\n} TV_DDC_READ_PARAM_T;\n\n//TV_SET_ATTACHED\n//Parameters: uint32_t attached or not (0 = hotplug low, 1 = hotplug high)\n\n//TV_SET_PROP\n//Parameters: HDMI_PROPERTY_PARAM_T\n//Reply: 0 = set successful, non-zero if error (int32_t) \n#define HDMI_PROPERTY_SIZE_IN_WORDS (sizeof(HDMI_PROPERTY_T)/sizeof(uint32_t))\n\n//TV_GET_PROP\n//Parameters: parameter type (sent as uint32_t)\n//Reply param1/param2 of the passed in property and return code\ntypedef struct {\n   int32_t  ret; /**<Return code */\n   HDMI_PROPERTY_PARAM_T property; /**<HDMI_PROPERTY_PARAM_T */\n} TV_GET_PROP_PARAM_T;\n\n//TV_GET_DISPLAY_STATE\n//Parameters: none\n//Return TV display state\ntypedef struct {\n   uint32_t state;               /** This will be the state of HDMI | SDTV */\n   union {\n      SDTV_DISPLAY_STATE_T sdtv; /** If SDTV is active, this is the state of SDTV */\n      HDMI_DISPLAY_STATE_T hdmi; /** If HDMI is active, this is the state of HDMI */\n   } display;\n} TV_DISPLAY_STATE_T;\n\n//TV_GET_DEVICE_ID\n//Parameter: none\n//Return device ID information from EDID\ntypedef struct {\n   char vendor[EDID_DEVICE_VENDOR_ID_LENGTH+1];\n   char monitor_name[EDID_DESC_ASCII_STRING_LEN+1];\n   uint32_t serial_num;\n} TV_DEVICE_ID_T;\n\n// state flag for LCD attached\nenum {\n   VC_LCD_ATTACHED_DEFAULT    = (1 <<22),  /**<LCD display is attached and default */\n};\n\n#endif\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vmcs_host/vc_vchi_audioserv_defs.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n#ifndef _VC_AUDIO_DEFS_H_\n#define _VC_AUDIO_DEFS_H_\n\n#define VC_AUDIOSERV_MIN_VER 1\n#define VC_AUDIOSERV_VER 3\n\n// FourCC code used for VCHI connection\n#define VC_AUDIO_SERVER_NAME  MAKE_FOURCC(\"AUDS\")\n\n// Maximum message length\n#define VC_AUDIO_MAX_MSG_LEN  (sizeof( VC_AUDIO_MSG_T ))\n\n// List of screens that are currently supported\n// All message types supported for HOST->VC direction\ntypedef enum\n{\n   VC_AUDIO_MSG_TYPE_RESULT,              // Generic result\n   VC_AUDIO_MSG_TYPE_COMPLETE,              // playback of samples complete\n   VC_AUDIO_MSG_TYPE_CONFIG,                 // Configure\n   VC_AUDIO_MSG_TYPE_CONTROL,                 // control \n   VC_AUDIO_MSG_TYPE_OPEN,                 //  open\n   VC_AUDIO_MSG_TYPE_CLOSE,                 // close/shutdown\n   VC_AUDIO_MSG_TYPE_START,                 // start output (i.e. resume)\n   VC_AUDIO_MSG_TYPE_STOP,                 // stop output (i.e. pause)\n   VC_AUDIO_MSG_TYPE_WRITE,                 // write samples\n   VC_AUDIO_MSG_TYPE_LATENCY,               // request latency in cycles\n   VC_AUDIO_MSG_TYPE_MAX\n\n} VC_AUDIO_MSG_TYPE;\n\nstatic const char *vc_audio_msg_type_names[] = {\n   \"VC_AUDIO_MSG_TYPE_RESULT\",\n   \"VC_AUDIO_MSG_TYPE_COMPLETE\",\n   \"VC_AUDIO_MSG_TYPE_CONFIG\",\n   \"VC_AUDIO_MSG_TYPE_CONTROL\",\n   \"VC_AUDIO_MSG_TYPE_OPEN\",\n   \"VC_AUDIO_MSG_TYPE_CLOSE\",\n   \"VC_AUDIO_MSG_TYPE_START\",\n   \"VC_AUDIO_MSG_TYPE_STOP\",\n   \"VC_AUDIO_MSG_TYPE_WRITE\",\n   \"VC_AUDIO_MSG_TYPE_MAX\"\n};\n\n// configure the audio\ntypedef struct\n{\n   uint32_t channels;\n   uint32_t samplerate;\n   uint32_t bps;\n   uint32_t channelmap;\n\n} VC_AUDIO_CONFIG_T;\n\ntypedef struct\n{\n   uint32_t volume;\n   uint32_t dest;\n\n} VC_AUDIO_CONTROL_T;\n\n// audio\ntypedef struct\n{\n   uint32_t dummy;\n\n} VC_AUDIO_OPEN_T;\n\n// audio\ntypedef struct\n{\n   uint32_t dummy;\n\n} VC_AUDIO_CLOSE_T;\n// audio\ntypedef struct\n{\n   uint32_t dummy;\n\n} VC_AUDIO_START_T;\n// audio\ntypedef struct\n{\n   uint32_t draining;\n\n} VC_AUDIO_STOP_T;\n// audio\ntypedef struct\n{\n   uint32_t dummy;\n\n} VC_AUDIO_LATENCY_T;\n\n// configure the write audio samples\ntypedef struct\n{\n   uint32_t count; // in bytes\n   void *callback;\n   void *cookie;\n   uint16_t silence;\n   uint16_t max_packet;\n} VC_AUDIO_WRITE_T;\n\n// Generic result for a request (VC->HOST)\ntypedef struct\n{\n   int32_t success;  // Success value\n\n} VC_AUDIO_RESULT_T;\n\n// Generic result for a request (VC->HOST)\ntypedef struct\n{\n   int32_t count;  // Success value\n   void *callback;\n   void *cookie;\n} VC_AUDIO_COMPLETE_T;\n\n// Message header for all messages in HOST->VC direction\ntypedef struct\n{\n   int32_t type;     // Message type (VC_AUDIO_MSG_TYPE)\n   union\n   {\n\tVC_AUDIO_CONFIG_T    config;\n   VC_AUDIO_CONTROL_T   control;\n\tVC_AUDIO_OPEN_T  open;\n\tVC_AUDIO_CLOSE_T  close;\n\tVC_AUDIO_START_T  start;\n\tVC_AUDIO_STOP_T  stop;\n\tVC_AUDIO_WRITE_T  write;\n\tVC_AUDIO_LATENCY_T  latency;\n\tVC_AUDIO_RESULT_T result;\n\tVC_AUDIO_COMPLETE_T complete;\n   } u;\n} VC_AUDIO_MSG_T;\n\n\n#endif // _VC_AUDIO_DEFS_H_\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vmcs_host/vc_vchi_bufman.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n#ifndef VC_VCHI_BUFMAN_H\n#define VC_VCHI_BUFMAN_H\n\n#include \"interface/vctypes/vc_image_types.h\"\n#include \"interface/vchi/vchi.h\"\n#ifdef __SYMBIAN32__\n#include \"interface/vmcs_host/vc_vchi_bufman_defs.h\"\ntypedef uint32_t DISPMANX_RESOURCE_HANDLE_T;\nnamespace BufManX {\n#else\n#include \"interface/vmcs_host/vc_dispmanx.h\"\n#include \"interface/vmcs_host/vc_vchi_bufman_defs.h\"\n#endif\n\ntypedef void (*vc_bufman_callback_t) (void *next_cookie, void *next_cookie2, int32_t success);\n\nVCHPRE_ void VCHPOST_ vc_vchi_bufman_init(VCHI_INSTANCE_T initialise_instance, VCHI_CONNECTION_T **connections, uint32_t num_connections);\n\ntypedef struct\n{\n   buf_frame_type_t type;\n   int width, height, pitch;\n   int bpp; // bits per pixel\n   int size;\n   void *pixels;\n} BUFMANX_IMAGE_T;\n\n#define BUFMAN_TRANSFORM_HFLIP     (1<<0)\n#define BUFMAN_TRANSFORM_VFLIP     (1<<1)\n#define BUFMAN_TRANSFORM_TRANSPOSE (1<<2)\n\ntypedef enum {\n   BUFMAN_TRANSFORM_ROT0           = 0,\n   BUFMAN_TRANSFORM_MIRROR_ROT0    = BUFMAN_TRANSFORM_HFLIP,\n   BUFMAN_TRANSFORM_MIRROR_ROT180  = BUFMAN_TRANSFORM_VFLIP,\n   BUFMAN_TRANSFORM_ROT180         = BUFMAN_TRANSFORM_HFLIP|BUFMAN_TRANSFORM_VFLIP,\n   BUFMAN_TRANSFORM_MIRROR_ROT90   = BUFMAN_TRANSFORM_TRANSPOSE,\n   BUFMAN_TRANSFORM_ROT270         = BUFMAN_TRANSFORM_TRANSPOSE|BUFMAN_TRANSFORM_HFLIP,\n   BUFMAN_TRANSFORM_ROT90          = BUFMAN_TRANSFORM_TRANSPOSE|BUFMAN_TRANSFORM_VFLIP,\n   BUFMAN_TRANSFORM_MIRROR_ROT270  = BUFMAN_TRANSFORM_TRANSPOSE|BUFMAN_TRANSFORM_HFLIP|BUFMAN_TRANSFORM_VFLIP,\n} BUFMAN_TRANSFORM_T;\n\n\n// we use an opaque type here as the internals shouldn't be used externally, but allocation of the size of the block is required by the caller.\n#define BUFMANX_HANDLE_T_SIZE 1024\ntypedef struct {\n   char opaque[BUFMANX_HANDLE_T_SIZE];\n} BUFMANX_HANDLE_T;\n\nVCHPRE_ int32_t VCHPOST_ vc_bufmanx_convert_init(void);\nVCHPRE_ int32_t VCHPOST_ vc_bufmanx_set_transform_buffer(void *pixels, int size);\nVCHPRE_ int32_t VCHPOST_ vc_bufmanx_allocate_image(BUFMANX_IMAGE_T *image);\nVCHPRE_ int32_t VCHPOST_ vc_bufmanx_release_image(BUFMANX_IMAGE_T *image);\nVCHPRE_ int32_t VCHPOST_ vc_bufmanx_get_default_pitch( BUFMANX_IMAGE_T *src );\nVCHPRE_ int32_t VCHPOST_ vc_bufmanx_get_default_size(BUFMANX_IMAGE_T *src);\nVCHPRE_ int32_t VCHPOST_ vc_bufmanx_push ( BUFMANX_HANDLE_T *h, const BUFMANX_IMAGE_T *src, DISPMANX_RESOURCE_HANDLE_T dst, const VC_RECT_T *src_rect, const VC_RECT_T *dest_rect, BUFMAN_TRANSFORM_T transform, vc_bufman_callback_t callback, void *cookie, void *cookie2 );\nVCHPRE_ int32_t VCHPOST_ vc_bufmanx_pull ( BUFMANX_HANDLE_T *h, BUFMANX_IMAGE_T *dst, const DISPMANX_RESOURCE_HANDLE_T src, const VC_RECT_T *src_rect, const VC_RECT_T *dest_rect, BUFMAN_TRANSFORM_T transform, vc_bufman_callback_t callback, void *cookie, void *cookie2 );\nVCHPRE_ int32_t VCHPOST_ vc_bufmanx_pull_blocking ( BUFMANX_HANDLE_T *h, BUFMANX_IMAGE_T *dst, const DISPMANX_RESOURCE_HANDLE_T src, const VC_RECT_T *src_rect, const VC_RECT_T *dest_rect, BUFMAN_TRANSFORM_T transform );\nVCHPRE_ int32_t VCHPOST_ vc_bufmanx_push_blocking ( BUFMANX_HANDLE_T *h, const BUFMANX_IMAGE_T *src, DISPMANX_RESOURCE_HANDLE_T dst, const VC_RECT_T *src_rect, const VC_RECT_T *dest_rect, BUFMAN_TRANSFORM_T transform );\nVCHPRE_ int32_t VCHPOST_ vc_bufmanx_pull_striped ( BUFMANX_HANDLE_T *xh, BUFMANX_IMAGE_T *dst, const DISPMANX_RESOURCE_HANDLE_T src, const VC_RECT_T *src_rect, const VC_RECT_T *dest_rect, BUFMAN_TRANSFORM_T transform, vc_bufman_callback_t callback, void *cookie, void *cookie2 );\nVCHPRE_ int32_t VCHPOST_ vc_bufmanx_pull_striped_blocking ( BUFMANX_HANDLE_T *xh, BUFMANX_IMAGE_T *dst, const DISPMANX_RESOURCE_HANDLE_T src, const VC_RECT_T *src_rect, const VC_RECT_T *dest_rect, BUFMAN_TRANSFORM_T transform );\nVCHPRE_ int32_t VCHPOST_ vc_bufmanx_push_striped ( BUFMANX_HANDLE_T *xh, const BUFMANX_IMAGE_T *src, DISPMANX_RESOURCE_HANDLE_T dst, const VC_RECT_T *src_rect, const VC_RECT_T *dest_rect, BUFMAN_TRANSFORM_T transform, vc_bufman_callback_t callback, void *cookie, void *cookie2 );\nVCHPRE_ int32_t VCHPOST_ vc_bufmanx_push_striped_blocking ( BUFMANX_HANDLE_T *xh, const BUFMANX_IMAGE_T *src, DISPMANX_RESOURCE_HANDLE_T dst, const VC_RECT_T *src_rect, const VC_RECT_T *dest_rect, BUFMAN_TRANSFORM_T transform );\n\nVCHPRE_ void VCHPOST_ vc_bufmanx_push_multi ( BUFMANX_HANDLE_T *h, const BUFMANX_IMAGE_T *src, DISPMANX_RESOURCE_HANDLE_T dst, BUFMAN_TRANSFORM_T transform, vc_bufman_callback_t callback, void *cookie, void *cookie2 );\nVCHPRE_ void VCHPOST_ vc_bufmanx_pull_multi ( BUFMANX_HANDLE_T *h, BUFMANX_IMAGE_T *dst, const DISPMANX_RESOURCE_HANDLE_T src, BUFMAN_TRANSFORM_T transform, vc_bufman_callback_t callback, void *cookie, void *cookie2 );\nVCHPRE_ int32_t VCHPOST_ vc_bufmanx_push_multi_blocking ( BUFMANX_HANDLE_T *h, const BUFMANX_IMAGE_T *src, DISPMANX_RESOURCE_HANDLE_T dst, BUFMAN_TRANSFORM_T transform );\nVCHPRE_ int32_t VCHPOST_ vc_bufmanx_pull_multi_blocking ( BUFMANX_HANDLE_T *h, BUFMANX_IMAGE_T *dst, const DISPMANX_RESOURCE_HANDLE_T src, BUFMAN_TRANSFORM_T transform );\n\n// Allocate the specified number and type of buffers on the server side, for use with streams\nVCHPRE_ int32_t VCHPOST_ vc_bufmanx_allocate_buffers\n   (uint32_t stream, uint32_t num_of_buffers,\n      buf_frame_type_t type, uint32_t width, uint32_t height);\n\n// Free buffers on the server which are associated with the specified stream\n#define VC_BUFMANX_FREE_BUFFERS_ALL    0\nVCHPRE_ int32_t VCHPOST_ vc_bufmanx_free_buffers(uint32_t stream, uint32_t num_of_buffers);\n\n// Like vc_bufmanx_push_multi(), but specifies a stream, rather than a dispmanx resource handle,\n// to push the data to.\nVCHPRE_ void VCHPOST_ vc_bufmanx_push_multi_stream ( BUFMANX_HANDLE_T *xh, const BUFMANX_IMAGE_T *src, uint32_t stream, BUFMAN_TRANSFORM_T transform, vc_bufman_callback_t callback, void *cookie, void *cookie2 );\n\nVCHPRE_ VC_IMAGE_TYPE_T VCHPOST_ vc_bufmanx_get_vc_image_type(buf_frame_type_t bm_type);\n\n#ifdef __SYMBIAN32__\n} // namespace BufManX\n#endif\n\n#endif /* VC_VCHI_BUFMAN_H */\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vmcs_host/vc_vchi_bufman_defs.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n#ifndef VC_VCHI_BUFMAN_DEFS_H\n#define VC_VCHI_BUFMAN_DEFS_H\n\n#ifdef __SYMBIAN32__\ntypedef uint32_t DISPMANX_RESOURCE_HANDLE_T;\nnamespace BufManX {\n#else\n#include \"interface/vmcs_host/vc_dispmanx.h\"\n#endif\n\ntypedef enum {\n   // Insert extra frame types here\n   FRAME_HOST_IMAGE_BASE = 0x20000, // Base for host format images\n   FRAME_HOST_IMAGE_EFormatYuv420P,\n   FRAME_HOST_IMAGE_EFormatYuv422P,\n   FRAME_HOST_IMAGE_EFormatYuv422LE,\n   FRAME_HOST_IMAGE_EFormatRgb565,\n   FRAME_HOST_IMAGE_EFormatRgb888,\n   FRAME_HOST_IMAGE_EFormatRgbU32,\n   FRAME_HOST_IMAGE_EFormatRgbA32,\n   FRAME_HOST_IMAGE_EFormatRgbA32LE,\n   FRAME_HOST_IMAGE_EFormatRgbU32LE,\n\n   FRAME_FORCE_FIELD_WIDTH = 0xFFFFFFFF\n} buf_frame_type_t;\n\ntypedef enum {\n    //host to videocore\n    VC_BUFMAN_CONVERT_UNUSED = 0,\n    VC_BUFMAN_PULL_FRAME,\n    VC_BUFMAN_PUSH_FRAME,\n    VC_BUFMAN_MESSAGE_RESPONSE,\n    VC_BUFMAN_SYNC,\n    VC_BUFMAN_ALLOC_BUF,\n    VC_BUFMAN_FREE_BUF,\n    VC_BUFMAN_PULL_MULTI,\n    VC_BUFMAN_PUSH_MULTI,\n    VC_BUFMAN_PUSH_MULTI_STREAM,\n    //vc to host\n    VC_BUFMAN_FRAME_SENT_CALLBACK,\n    VC_BUFMAN_FORCE_WIDTH = 0x7fffffff,\n} buf_command_t;\n\n/* A header used for all messages sent and received by bufman.\n */\ntypedef struct {\n   buf_command_t command;\n} BUF_MSG_HDR_T;\n\n/* General remotely call this bufman operation commands */\ntypedef struct {\n   uint32_t resource_handle;\n   buf_frame_type_t type;\n   int32_t size, width, height, pitch;\n   VC_RECT_T src_rect;  // in 16.16 units\n   VC_RECT_T dest_rect; // in 32.0 units\n} BUF_MSG_REMOTE_FUNCTION_FRAME_T;\n\ntypedef struct {\n   int32_t status;\n   int32_t total_stripes;\n   // normal stipe height and size\n   int32_t stripe_height, stripe_size;\n   // last stripe size (if height not a mulitple of stripe height, last stripe nay be smaller)\n   int32_t last_stripe_height, last_stripe_size;\n} BUF_MSG_RESPONSE_T;\n\ntypedef struct\n{\n   uint32_t stream;\n   uint32_t num_of_buffers;\n   buf_frame_type_t type;\n   uint32_t width;\n   uint32_t height;\n} BUF_MSG_ALLOC_BUF_FRAME_T;\n\ntypedef struct\n{\n   uint32_t stream;\n   uint32_t num_of_buffers;\n} BUF_MSG_FREE_BUF_FRAME_T;\n\ntypedef struct {\n   BUF_MSG_HDR_T hdr;\n   union {\n      BUF_MSG_REMOTE_FUNCTION_FRAME_T frame;\n      BUF_MSG_RESPONSE_T message_response;\n      BUF_MSG_ALLOC_BUF_FRAME_T alloc_buf_frame;\n      BUF_MSG_FREE_BUF_FRAME_T free_buf_frame;\n   } u;\n} BUF_MSG_T;\n\nenum {\n   //host to videocore\n   VC_BUFMAN_ERROR_NONE = 0,\n   VC_BUFMAN_ERROR_BAD_GENERALLY = -1,\n   VC_BUFMAN_ERROR_BAD_RESOURCE = -2,\n   VC_BUFMAN_ERROR_BAD_TRANSFORM = -3,\n   VC_BUFMAN_ERROR_BAD_RESIZE = -4,\n   VC_BUFMAN_ERROR_BAD_HOST_FORMAT = -5,\n   VC_BUFMAN_ERROR_BAD_VC_FORMAT = -6,\n   VC_BUFMAN_ERROR_BAD_SIZE = -7,\n};\n\n#ifdef __SYMBIAN32__\n} // namespace BufManX\n#endif\n\n#endif /* VC_VCHI_BUFMAN_DEFS_H */\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vmcs_host/vc_vchi_dispmanx.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n#ifndef VC_VCHI_DISPMANX_H\n#define VC_VCHI_DISPMANX_H\n\n#include \"interface/peer/vc_vchi_dispmanx_common.h\"\n\n#define VC_NUM_HOST_RESOURCES 64\n#define DISPMANX_MSGFIFO_SIZE 1024\n#define DISPMANX_CLIENT_NAME MAKE_FOURCC(\"DISP\")\n#define DISPMANX_NOTIFY_NAME MAKE_FOURCC(\"UPDH\")\n\n//Or with command to indicate we don't need a response\n#define DISPMANX_NO_REPLY_MASK (1<<31)\n\ntypedef struct {\n   char     description[32];\n   uint32_t width;\n   uint32_t height;\n   uint32_t aspect_pixwidth;\n   uint32_t aspect_pixheight;\n   uint32_t fieldrate_num;\n   uint32_t fieldrate_denom;\n   uint32_t fields_per_frame;\n   uint32_t transform;        \n} GET_MODES_DATA_T;\n\ntypedef struct {\n   int32_t  response;\n   uint32_t width;\n   uint32_t height;\n   uint32_t transform;\n   uint32_t input_format;\n} GET_INFO_DATA_T;\n\n//Attributes changes flag mask\n#define ELEMENT_CHANGE_LAYER          (1<<0)\n#define ELEMENT_CHANGE_OPACITY        (1<<1)\n#define ELEMENT_CHANGE_DEST_RECT      (1<<2)\n#define ELEMENT_CHANGE_SRC_RECT       (1<<3)\n#define ELEMENT_CHANGE_MASK_RESOURCE  (1<<4)\n#define ELEMENT_CHANGE_TRANSFORM      (1<<5)\n\n#endif\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vmcs_host/vc_vchi_fileservice_defs.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n#ifndef VC_VCHI_FILESERVICE_DEFS_H\n#define VC_VCHI_FILESERVICE_DEFS_H\n\n#include \"interface/vchi/vchi.h\"\n\n/* Definitions (not used by API) */\n\n/* structure used by both side to communicate */\n#define FILESERV_MAX_BULK_SECTOR  128   //must be power of two\n\n#define FILESERV_SECTOR_LENGTH  512\n\n#define FILESERV_MAX_BULK (FILESERV_MAX_BULK_SECTOR*FILESERV_SECTOR_LENGTH)\n\n#define FILESERV_4CC  MAKE_FOURCC(\"FSRV\")\n\ntypedef enum FILESERV_EVENT_T\n{\n   FILESERV_BULK_RX = 0,\n   FILESERV_BULK_TX,\n   FILESERV_BULK_RX_0,\n   FILESERV_BULK_RX_1\n}FILESERV_EVENT_T;\n//this following structure has to equal VCHI_MAX_MSG_SIZE\n#define FILESERV_MAX_DATA\t(VCHI_MAX_MSG_SIZE - 40) //(VCHI_MAX_MSG_SIZE - 24)\n\ntypedef struct{\n\tuint32_t xid;\t\t    //4 // transaction's ID, used to match cmds with response\n   uint32_t cmd_code;    //4\n   uint32_t params[4];   //16\n   char  data[FILESERV_MAX_DATA];\n}FILESERV_MSG_T;\n\ntypedef enum\n{\n   FILESERV_RESP_OK,\n   FILESERV_RESP_ERROR,\n   FILESERV_BULK_READ,\n   FILESERV_BULK_WRITE,\n\n} FILESERV_RESP_CODE_T;\n\n\n/* Protocol (not used by API) version 1.2 */\n\n\n\n#endif\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vmcs_host/vc_vchi_filesys.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n#ifndef VC_VCHI_VCFILESYS_H_\n#define VC_VCHI_VCFILESYS_H_\n\n#include \"vchost_platform_config.h\"\n#include \"vcfilesys_defs.h\"\n#include \"vc_fileservice_defs.h\"\n#include \"interface/vchi/vchi.h\"\n\n#ifndef _DIRENT_H  // This should really be in a dirent.h header to avoid conflicts\ntypedef struct DIR_tag DIR;\n#endif // ifndef _DIRENT_H\n\ntypedef struct {   \n   int64_t  st_size;    /* total size, in bytes  (off_t)*/      \n   uint32_t st_modtime;   /* time of last modification (time_t)*/   \n} FSTAT_T;\n\n\nVCHPRE_ int VCHPOST_  vc_vchi_filesys_init (VCHI_INSTANCE_T initialise_instance, VCHI_CONNECTION_T **connections, uint32_t num_connections );\n\n// Stop it to prevent the functions from trying to use it.\nVCHPRE_ void VCHPOST_ vc_filesys_stop(void);\n\n// Return the service number (-1 if not running).\nVCHPRE_ int VCHPOST_ vc_filesys_inum(void);\n\n// Low level file system functions equivalent to close(), lseek(), open(), read() and write()\nVCHPRE_ int VCHPOST_ vc_filesys_close(int fildes);\n\nVCHPRE_ long VCHPOST_ vc_filesys_lseek(int fildes, long offset, int whence);\n\nVCHPRE_ int64_t VCHPOST_ vc_filesys_lseek64(int fildes, int64_t offset, int whence);\n\nVCHPRE_ int VCHPOST_ vc_filesys_open(const char *path, int vc_oflag);\n\nVCHPRE_ int VCHPOST_ vc_filesys_read(int fildes, void *buf, unsigned int nbyte);\n\nVCHPRE_ int VCHPOST_ vc_filesys_write(int fildes, const void *buf, unsigned int nbyte);\n\nVCHPRE_ int VCHPOST_ vc_filesys_mount(const char *device, const char *mountpoint, const char *options);\nVCHPRE_ int VCHPOST_ vc_filesys_umount(const char *mountpoint);\n\n\n// Ends a directory listing iteration\nVCHPRE_ int VCHPOST_ vc_filesys_closedir(void *dhandle);\n\n// Formats the drive that contains the given path\nVCHPRE_ int VCHPOST_ vc_filesys_format(const char *path);\n\n// Returns the amount of free space on the drive that contains the given path\nVCHPRE_ int VCHPOST_ vc_filesys_freespace(const char *path);\nVCHPRE_ int64_t VCHPOST_ vc_filesys_freespace64(const char *path);\n\n// Gets the attributes of the named file\nVCHPRE_ int VCHPOST_ vc_filesys_get_attr(const char *path, fattributes_t *attr);\n\n// Get the file stat info struct for the specified file.\nVCHPRE_ int VCHPOST_ vc_filesys_fstat(int filedes, FSTAT_T *buf);\n\n// Creates a new directory\nVCHPRE_ int VCHPOST_ vc_filesys_mkdir(const char *path);\n\n// Starts a directory listing iteration\nVCHPRE_ void * VCHPOST_ vc_filesys_opendir(const char *dirname);\n\n// Directory listing iterator\nVCHPRE_ struct dirent * VCHPOST_ vc_filesys_readdir_r(void *dhandle, struct dirent *result);\n\n// Get the sum of the filesizes, and the number of files under the specified directory path.\nVCHPRE_ int64_t VCHPOST_ vc_filesys_dirsize(const char *path, uint32_t *num_files, uint32_t *num_dirs);\n\n// Deletes a file or (empty) directory\nVCHPRE_ int VCHPOST_ vc_filesys_remove(const char *path);\n\n// Renames a file, provided the new name is on the same file system as the old\nVCHPRE_ int VCHPOST_ vc_filesys_rename(const char *oldfile, const char *newfile);\n\n// Resets the co-processor side file system\nVCHPRE_ int VCHPOST_ vc_filesys_reset(void);\n\n// Sets the attributes of the named file\nVCHPRE_ int VCHPOST_ vc_filesys_set_attr(const char *path, fattributes_t attr);\n\n// Truncates a file at its current position\nVCHPRE_ int VCHPOST_ vc_filesys_setend(int fildes);\n\n// Returns the size of a file in bytes.\nVCHPRE_ int VCHPOST_ vc_filesys_size(const char *path);\n\n// Checks whether there are any messages in the incoming message fifo and responds to any such messages\nVCHPRE_ int VCHPOST_ vc_filesys_poll_message_fifo(void);\n\n// Return the event used to wait for reads.\nVCHPRE_ void * VCHPOST_ vc_filesys_read_event(void);\n\n// Sends a command for VC01 to reset the file system\nVCHPRE_ void VCHPOST_ vc_filesys_sendreset(void);\n\n// Return the error code of the last file system error\nVCHPRE_ int VCHPOST_ vc_filesys_errno(void);\n\n// Invalidates any cluster chains in the FAT that are not referenced in any directory structures\nVCHPRE_ void VCHPOST_ vc_filesys_scandisk(const char *path);\n\n// Checks whether or not a FAT filesystem is corrupt or not. If fix_errors is TRUE behaves exactly as vc_filesys_scandisk.\nVCHPRE_ int VCHPOST_ vc_filesys_chkdsk(const char *path, int fix_errors);\n\n// Return whether a disk is writeable or not.\nVCHPRE_ int VCHPOST_ vc_filesys_diskwritable(const char *path);\n\n// Return file system type of a disk.\nVCHPRE_ int VCHPOST_ vc_filesys_fstype(const char *path);\n\n// Returns the toatl amount of space on the drive that contains the given path\nVCHPRE_ int VCHPOST_ vc_filesys_totalspace(const char *path);\nVCHPRE_ int64_t VCHPOST_ vc_filesys_totalspace64(const char *path);\n\n// Open disk for block level access\nVCHPRE_ int VCHPOST_ vc_filesys_open_disk_raw(const char *path);\n\n// Close disk from block level access mode\nVCHPRE_ int VCHPOST_ vc_filesys_close_disk_raw(const char *path);\n\n// Open disk for normal access\nVCHPRE_ int VCHPOST_ vc_filesys_open_disk(const char *path);\n\n// Close disk for normal access\nVCHPRE_ int VCHPOST_ vc_filesys_close_disk(const char *path);\n\n// Return number of sectors.\nVCHPRE_ int VCHPOST_ vc_filesys_numsectors(const char *path);\nVCHPRE_ int64_t VCHPOST_ vc_filesys_numsectors64(const char *path);\n\n// Read/Write sectors\nVCHPRE_ int VCHPOST_ vc_filesys_read_sectors(const char *path, uint32_t sector_num, char *sectors, uint32_t num_sectors, uint32_t *sectors_read);\nVCHPRE_ int VCHPOST_ vc_filesys_write_sectors(const char *path, uint32_t sector_num, char *sectors, uint32_t num_sectors, uint32_t *sectors_written);\n\n// Begin reading sectors from VideoCore.\nVCHPRE_ int VCHPOST_ vc_filesys_read_sectors_begin(const char *path, uint32_t sector, uint32_t count);\n\n// Read the next sector.\nVCHPRE_ int VCHPOST_ vc_filesys_read_sector(char *buf);\n\n// End streaming sectors.\nVCHPRE_ int VCHPOST_ vc_filesys_read_sectors_end(uint32_t *sectors_read);\n\n// Begin writing sectors from VideoCore.\nVCHPRE_ int VCHPOST_ vc_filesys_write_sectors_begin(const char *path, uint32_t sector, uint32_t count);\n\n// Write the next sector.\nVCHPRE_ int VCHPOST_ vc_filesys_write_sector(const char *buf);\n\n// End streaming sectors.\nVCHPRE_ int VCHPOST_ vc_filesys_write_sectors_end(uint32_t *sectors_written);\n\n#endif //VCFILESYS_H_\n\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vmcs_host/vc_vchi_gencmd.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n#ifndef VC_VCHI_GENCMD_H\n#define VC_VCHI_GENCMD_H\n#include \"vchost_platform_config.h\"\n#include \"interface/vchi/vchi.h\"\n#include \"interface/vcos/vcos.h\" //for VCHPRE_ abd VCHPOST_ macro's for func declaration\n\n/* Initialise general command service. Returns it's interface number. This initialises\n   the host side of the interface, it does not send anything to VideoCore. */\n\nVCHPRE_ int VCHPOST_ vc_gencmd_init(void);\n\nVCHPRE_ void VCHPOST_ vc_vchi_gencmd_init(VCHI_INSTANCE_T initialise_instance, VCHI_CONNECTION_T **connections, uint32_t num_connections );\n\n\n/* Stop the service from being used. */\n\nVCHPRE_ void VCHPOST_ vc_gencmd_stop(void);\n\n/* Functions to support videocore suspend/resume for cases where vc_gencmd_send expects a response to\n * ensure videocore is not shut down (done internally in vc_gencmd / vc_gencmd_until) */\n\nVCHPRE_ int VCHPOST_ use_gencmd_service(void);\nVCHPRE_ int VCHPOST_ release_gencmd_service(void);\n\n/******************************************************************************\nSend commands to VideoCore.\nThese all return 0 for success. They return VC_MSGFIFO_FIFO_FULL if there is\ninsufficient space for the whole message in the fifo, and none of the message is\nsent.\n******************************************************************************/\n\n/*  send command to general command serivce */\nVCHPRE_ int VCHPOST_ vc_gencmd_send( const char *format, ... );\n\n/*  get resonse from general command serivce */\nVCHPRE_ int VCHPOST_ vc_gencmd_read_response(char *response, int maxlen);\n\n/* convenience function to send command and receive the response */\nVCHPRE_ int VCHPOST_ vc_gencmd(char *response, int maxlen, const char *format, ...);\n\n/******************************************************************************\nUtilities to help interpret the responses.\n******************************************************************************/\n\n/* Read the value of a property=value type pair from a string (typically VideoCore's\n   response to a general command). Return non-zero if found. */\nVCHPRE_ int VCHPOST_ vc_gencmd_string_property(char *text, const char *property, char **value, int *length);\n\n/* Read the numeric value of a property=number field from a response string. Return\n   non-zero if found. */\nVCHPRE_ int VCHPOST_ vc_gencmd_number_property(char *text, const char *property, int *number);\n\n/* Send a command until the desired response is received, the error message is detected, or the timeout */\nVCHPRE_ int VCHPOST_ vc_gencmd_until( char        *cmd,\n                                      const char  *property,\n                                      char        *value,\n                                      const char  *error_string,\n                                      int         timeout);\n\n\n#endif\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vmcs_host/vc_vchi_gpuserv.h",
    "content": "/*\nCopyright (c) 2016, Raspberry Pi (Trading) Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n#ifndef VC_VCHI_GPUSERV_H\n#define VC_VCHI_GPUSERV_H\n#include \"interface/vchiq_arm/vchiq.h\"\n\n// these go in command word of gpu_job_s\n// EXECUTE_VPU and EXECUTE_QPU are valid from host\nenum { EXECUTE_NONE, EXECUTE_VPU, EXECUTE_QPU, EXECUTE_SYNC };\n\nstruct vpu_job_s {\n   // these are function address and parameters for vpu job\n   uint32_t q[7];\n   uint32_t dummy[21];\n};\n\nstruct qpu_job_s {\n   // parameters for qpu job\n   uint32_t jobs;\n   uint32_t noflush;\n   uint32_t timeout;\n   uint32_t dummy;\n   uint32_t control[12][2];\n};\n\nstruct sync_job_s {\n   // parameters for syncjob\n   // bit 0 set means wait for preceding vpu jobs to complete\n   // bit 1 set means wait for preceding qpu jobs to complete\n   uint32_t mask;\n   uint32_t dummy[27];\n};\n\nstruct gpu_callback_s {\n  // callback to call when complete (can be NULL)\n  void (*func)();\n  void *cookie;\n};\n\nstruct gpu_internal_s {\n   void *message;\n   int refcount;\n};\n\nstruct gpu_job_s {\n  // from enum above\n  uint32_t command;\n  // qpu or vpu jobs\n  union {\n    struct vpu_job_s v;\n    struct qpu_job_s q;\n    struct sync_job_s s;\n  } u;\n  // callback function to call when complete\n  struct gpu_callback_s callback;\n  // for internal use - leave as zero\n  struct gpu_internal_s internal;\n};\n\n/* Initialise gpu service. Returns its interface number. This initialises\n   the host side of the interface, it does not send anything to VideoCore. */\n\nVCHPRE_ int32_t VCHPOST_ vc_gpuserv_init(void);\n\nVCHPRE_ int32_t VCHPOST_ vc_gpuserv_execute_code(int num_jobs, struct gpu_job_s jobs[]);\n\n#endif\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vmcs_host/vcfilesys.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n#include \"vchost_platform_config.h\"\n#include \"vcfilesys_defs.h\"\n#include \"vc_fileservice_defs.h\"\n\n#ifndef VCFILESYS_H_\n#define VCFILESYS_H_\n\n#ifndef FILESYS_DIR_DEFINED\n#define  FILESYS_DIR_DEFINED\ntypedef struct DIR_tag DIR;\n#endif\n\n// Initialises the file system for use\nVCHPRE_ int VCHPOST_ vc_filesys_init (void);\n\n// Stop it to prevent the functions from trying to use it.\nVCHPRE_ void VCHPOST_ vc_filesys_stop(void);\n\n// Return the service number (-1 if not running).\nVCHPRE_ int VCHPOST_ vc_filesys_inum(void);\n\n// Low level file system functions equivalent to close(), lseek(), open(), read() and write()\nVCHPRE_ int VCHPOST_ vc_filesys_close(int fildes);\n\nVCHPRE_ long VCHPOST_ vc_filesys_lseek(int fildes, long offset, int whence);\n\nVCHPRE_ int64_t VCHPOST_ vc_filesys_lseek64(int fildes, int64_t offset, int whence);\n\nVCHPRE_ int VCHPOST_ vc_filesys_open(const char *path, int vc_oflag);\n\nVCHPRE_ int VCHPOST_ vc_filesys_read(int fildes, void *buf, unsigned int nbyte);\n\nVCHPRE_ int VCHPOST_ vc_filesys_write(int fildes, const void *buf, unsigned int nbyte);\n\nVCHPRE_ int VCHPOST_ vc_filesys_mount(const char *device, const char *mountpoint, const char *options);\nVCHPRE_ int VCHPOST_ vc_filesys_umount(const char *mountpoint);\n\n\n// Ends a directory listing iteration\nVCHPRE_ int VCHPOST_ vc_filesys_closedir(void *dhandle);\n\n// Formats the drive that contains the given path\nVCHPRE_ int VCHPOST_ vc_filesys_format(const char *path);\n\n// Returns the amount of free space on the drive that contains the given path\nVCHPRE_ int VCHPOST_ vc_filesys_freespace(const char *path);\nVCHPRE_ int64_t VCHPOST_ vc_filesys_freespace64(const char *path);\n\n// Gets the attributes of the named file\nVCHPRE_ int VCHPOST_ vc_filesys_get_attr(const char *path, fattributes_t *attr);\n\n// Creates a new directory\nVCHPRE_ int VCHPOST_ vc_filesys_mkdir(const char *path);\n\n// Starts a directory listing iteration\nVCHPRE_ void * VCHPOST_ vc_filesys_opendir(const char *dirname);\n\n// Directory listing iterator\nVCHPRE_ struct dirent * VCHPOST_ vc_filesys_readdir_r(void *dhandle, struct dirent *result);\n\n// Deletes a file or (empty) directory\nVCHPRE_ int VCHPOST_ vc_filesys_remove(const char *path);\n\n// Renames a file, provided the new name is on the same file system as the old\nVCHPRE_ int VCHPOST_ vc_filesys_rename(const char *oldfile, const char *newfile);\n\n// Resets the co-processor side file system\nVCHPRE_ int VCHPOST_ vc_filesys_reset(void);\n\n// Sets the attributes of the named file\nVCHPRE_ int VCHPOST_ vc_filesys_set_attr(const char *path, fattributes_t attr);\n\n// Truncates a file at its current position\nVCHPRE_ int VCHPOST_ vc_filesys_setend(int fildes);\n\n// Checks whether there are any messages in the incoming message fifo and responds to any such messages\nVCHPRE_ int VCHPOST_ vc_filesys_poll_message_fifo(void);\n\n// Return the event used to wait for reads.\nVCHPRE_ void * VCHPOST_ vc_filesys_read_event(void);\n\n// Sends a command for VC01 to reset the file system\nVCHPRE_ void VCHPOST_ vc_filesys_sendreset(void);\n\n// Return the error code of the last file system error\nVCHPRE_ int VCHPOST_ vc_filesys_errno(void);\n\n// Invalidates any cluster chains in the FAT that are not referenced in any directory structures\nVCHPRE_ void VCHPOST_ vc_filesys_scandisk(const char *path);\n\n// Checks whether or not a FAT filesystem is corrupt or not. If fix_errors is TRUE behaves exactly as vc_filesys_scandisk.\nVCHPRE_ int VCHPOST_ vc_filesys_chkdsk(const char *path, int fix_errors);\n\n// Return whether a disk is writeable or not.\nVCHPRE_ int VCHPOST_ vc_filesys_diskwritable(const char *path);\n\n// Return file system type of a disk.\nVCHPRE_ int VCHPOST_ vc_filesys_fstype(const char *path);\n\n// Returns the toatl amount of space on the drive that contains the given path\nVCHPRE_ int VCHPOST_ vc_filesys_totalspace(const char *path);\nVCHPRE_ int64_t VCHPOST_ vc_filesys_totalspace64(const char *path);\n\n// Open disk for block level access\nVCHPRE_ int VCHPOST_ vc_filesys_open_disk_raw(const char *path);\n\n// Close disk from block level access mode\nVCHPRE_ int VCHPOST_ vc_filesys_close_disk_raw(const char *path);\n\n// Open disk for normal access\nVCHPRE_ int VCHPOST_ vc_filesys_open_disk(const char *path);\n\n// Close disk for normal access\nVCHPRE_ int VCHPOST_ vc_filesys_close_disk(const char *path);\n\n// Return number of sectors.\nVCHPRE_ int VCHPOST_ vc_filesys_numsectors(const char *path);\nVCHPRE_ int64_t VCHPOST_ vc_filesys_numsectors64(const char *path);\n\n// Begin reading sectors from VideoCore.\nVCHPRE_ int VCHPOST_ vc_filesys_read_sectors_begin(const char *path, uint32_t sector, uint32_t count);\n\n// Read the next sector.\nVCHPRE_ int VCHPOST_ vc_filesys_read_sector(char *buf);\n\n// End streaming sectors.\nVCHPRE_ int VCHPOST_ vc_filesys_read_sectors_end(uint32_t *sectors_read);\n\n// Begin writing sectors from VideoCore.\nVCHPRE_ int VCHPOST_ vc_filesys_write_sectors_begin(const char *path, uint32_t sector, uint32_t count);\n\n// Write the next sector.\nVCHPRE_ int VCHPOST_ vc_filesys_write_sector(const char *buf);\n\n// End streaming sectors.\nVCHPRE_ int VCHPOST_ vc_filesys_write_sectors_end(uint32_t *sectors_written);\n\n#endif //VCFILESYS_H_\n\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vmcs_host/vcfilesys_defs.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n// File service required types\n\n#ifndef VCFILESYS_DEFS_H\n#define VCFILESYS_DEFS_H\n\n#include <time.h>  // for time_t\n\n/* Define type fattributes_t and struct dirent for use in file system functions */\n\ntypedef int fattributes_t;\n//enum {ATTR_RDONLY=1, ATTR_DIRENT=2};\n#define ATTR_RDONLY     0x01        /* Read only file attributes */\n#define ATTR_HIDDEN     0x02        /* Hidden file attributes */\n#define ATTR_SYSTEM     0x04        /* System file attributes */\n#define ATTR_VOLUME     0x08        /* Volume Label file attributes */\n#define ATTR_DIRENT     0x10        /* Dirrectory file attributes */\n#define ATTR_ARCHIVE     0x20        /* Archives file attributes */\n#define ATTR_NORMAL     0x00        /* Normal file attributes */\n\n#define D_NAME_MAX_SIZE 256\n\n#ifndef _DIRENT_H  // This should really be in a dirent.h header to avoid conflicts\nstruct dirent\n{\n   char d_name[D_NAME_MAX_SIZE];\n   unsigned int d_size;\n   fattributes_t d_attrib;\n   time_t d_creatime;\n   time_t d_modtime;\n};\n#endif // ifndef _DIRENT_H\n\n#define FS_MAX_PATH 256   // The maximum length of a pathname\n/* Although not used in the API, this value is required on the host and\nVC01 sides of the file system, even if there is no host side. Putting it in\nvc_fileservice_defs.h is not appropriate as it would only be included if there\nwas a host side. */\n\n/* File system error codes */\n#define FS_BAD_USER  -7000     // The task isn't registered as a file system user\n\n#define FS_BAD_FILE  -7001     // The path or filename or file descriptor is invalid\n#define FS_BAD_PARM  -7002     // Invalid parameter given\n#define FS_ACCESS    -7003     // File access conflict\n#define FS_MAX_FILES -7004     // Maximum number of files already open\n#define FS_NOEMPTY   -7005     // Directory isn't empty\n#define FS_MAX_SIZE  -7006     // File is over the maximum file size\n\n#define FS_NO_DISK   -7007     // No disk is present, or the disk has not been opened\n#define FS_DISK_ERR  -7008     // There is a problem with the disk\n\n#define FS_IO_ERROR  -7009     // Driver level error\n\n#define FS_FMT_ERR   -7010     // Format error\n\n#define FS_NO_BUFFER -7011     // Internal Nucleus File buffer not available\n#define FS_NUF_INT   -7012     // Internal Nucleus File error\n\n#define FS_UNSPEC_ERR -7013    // Unspecified error\n\n#endif\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vmcs_host/vcgencmd.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n// General command service API\n\n#ifndef GENCMD_H\n#define GENCMD_H\n\n#include \"vchost_platform_config.h\"\n#include \"interface/vchi/vchi.h\"\n\nVCHPRE_ void VCHPOST_ vc_vchi_gencmd_init(VCHI_INSTANCE_T initialise_instance, VCHI_CONNECTION_T **connections, uint32_t num_connections );\n\n\n/* Initialise general command service. Returns it's interface number. This initialises\n   the host side of the interface, it does not send anything to VideoCore. */\n\nVCHPRE_ int VCHPOST_ vc_gencmd_init(void);\n\n/* Stop the service from being used. */\n\nVCHPRE_ void VCHPOST_ vc_gencmd_stop(void);\n\n/* Return the service number (-1 if not running). */\nVCHPRE_ int VCHPOST_ vc_gencmd_inum(void);\n\n/******************************************************************************\nSend commands to VideoCore.\nThese all return 0 for success. They return VC_MSGFIFO_FIFO_FULL if there is\ninsufficient space for the whole message in the fifo, and none of the message is\nsent.\n******************************************************************************/\n\n/*  send command to general command serivce */\nVCHPRE_ int VCHPOST_ vc_gencmd_send( const char *format, ... );\n\n/*  get resonse from general command serivce */\nVCHPRE_ int VCHPOST_ vc_gencmd_read_response(char *response, int maxlen);\n\n/* convenience function to send command and receive the response */\nVCHPRE_ int VCHPOST_ vc_gencmd(char *response, int maxlen, const char *format, ...);\n\n/* read part of a response from the general command service */\nVCHPRE_ int VCHPOST_ vc_gencmd_read_response_partial(char *response, int nbytes);\n\n/* if reading with vc_gencmd_read_response_partial end response reads with this */\nVCHPRE_ int VCHPOST_ vc_gencmd_close_response_partial(void);\n\n/* get state of reading of response */\nVCHPRE_ int VCHPOST_ vc_gencmd_read_partial_state(void);\n\n/******************************************************************************\nUtilities to help interpret the responses.\n******************************************************************************/\n\n/* Read the value of a property=value type pair from a string (typically VideoCore's\n   response to a general command). Return non-zero if found. */\nVCHPRE_ int VCHPOST_ vc_gencmd_string_property(char *text, const char *property, char **value, int *length);\n\n/* Read the numeric value of a property=number field from a response string. Return\n   non-zero if found. */\nVCHPRE_ int VCHPOST_ vc_gencmd_number_property(char *text, const char *property, int *number);\n\n/* Send a command until the desired response is received, the error message is detected, or the timeout */\nVCHPRE_ int VCHPOST_ vc_gencmd_until( char        *cmd,\n                                      const char  *property,\n                                      char        *value,\n                                      const char  *error_string,\n                                      int         timeout);\n\n#endif\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vmcs_host/vchost.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n#ifndef VCHOST_H\n#define VCHOST_H\n\n#include \"vchost_platform_config.h\"\n#include \"vcfilesys_defs.h\"\n#include \"interface/vcos/vcos.h\" //for VCHPRE_ abd VCHPOST_ macro's for func declaration\n#include \"interface/vmcs_host/vc_fileservice_defs.h\" // for VC_O_XXX file definitions\n#include \"interface/vchi/vchi.h\"\n\n#define UNUSED_PARAMETER(x) ((void)(x))/* macro to suppress not use warning */\n\n/*---------------------------------------------------------------------------*/\n/* Byte-swapping, dependent on host's orientation */\n/*---------------------------------------------------------------------------*/\n\n#ifndef VC_HOST_IS_BIG_ENDIAN\n#define VC_HTOV32(val) (val)\n#define VC_HTOV16(val) (val)\n#define VC_VTOH32(val) (val)\n#define VC_VTOH16(val) (val)\n#else\nstatic unsigned long  VC_HTOV32(unsigned long val)  {\n   return ((val<<24) | ((val&0xff00)<<8) | ((val>>8)&0xff00) | ((val>>24)&0xff)); }\nstatic unsigned short VC_HTOV16(unsigned short val) {\n   return ((val<<8)|(val>>8)); }\nstatic unsigned long  VC_VTOH32(unsigned long val)  {\n   return ((val<<24) | ((val&0xff00)<<8) | ((val>>8)&0xff00) | ((val>>24)&0xff)); }\nstatic unsigned short VC_VTOH16(unsigned short val) {\n   return ((val<<8)|(val>>8)); }\n#endif\n\n/*---------------------------------------------------------------------------*/\n/* Host port related functions */\n/*---------------------------------------------------------------------------*/\n\n/* Boot a bin file from flash into RAM. Returns the id of the application running */\n\nVCHPRE_ int VCHPOST_ vc_host_boot(char *cmd_line, void *binimg, int nbytes, int bootloader);\n\n/* Perform any platform specific initialisations. */\n\nVCHPRE_ int VCHPOST_ vc_host_init(void);\n\n/* Read a multiple of 16 bytes from VideoCore. host_addr has no particular alignment,\n   but it is important that it transfers the data in 16-bit chunks if this is possible. */\n\nVCHPRE_ int VCHPOST_ vc_host_read_consecutive(void *host_addr, uint32_t vc_addr, int nbytes, int channel);\n\n#ifdef VC_HOST_IS_BIG_ENDIAN\n// Reads from VideoCore with an implicit swap of each pair of bytes.\nVCHPRE_ int VCHPOST_ vc_host_read_byteswapped(void *host_addr, uint32_t vc_addr, int nbytes, int channel);\n#endif\n\n/* Write a multiple of 16 bytes to VideoCore. host_addr has no particular alignment,\n   but it is important that it transfers the data in 16-bit chunks if this is possible. */\n\nVCHPRE_ int VCHPOST_ vc_host_write_consecutive(uint32_t vc_addr, void *host_addr, int nbytes, int channel);\n\n#ifdef VC_HOST_IS_BIG_ENDIAN\n// Write to VideoCore with an implicit swap of each pair of bytes.\nVCHPRE_ int VCHPOST_ vc_host_write_byteswapped(uint32_t vc_addr, void *host_addr, int nbytes, int channel);\n#endif\n\n/* Send an interrupt to VideoCore. */\n\nVCHPRE_ int VCHPOST_ vc_host_send_interrupt(int channel);\n\n/* Wait for an interrupt from VideoCore. This can return immediately if applications\n   are happy to busy-wait. */\n\nVCHPRE_ int VCHPOST_ vc_host_wait_interrupt(void);\n\n/* Tell the host to act on or ignore interrupts. */\n\nVCHPRE_ void VCHPOST_ vc_host_interrupts(int on);\n\n/* Function called when there is some kind of internal error. Breakpoints can be set on\n   this for debugging. */\n\nVCHPRE_ void VCHPOST_ vc_error(void);\n\n\n/*---------------------------------------------------------------------------*/\n/* Event (interrupt) related functions */\n/*---------------------------------------------------------------------------*/\n\n// Minimum number of event objects an implementation should support.\n// Sufficient for 2 per 8 interfaces/services + 4 others\n#define VC_EVENT_MAX_NUM  20\n\n/* Create (and clear) an event.  Returns a pointer to the event object. */\nVCHPRE_ void * VCHPOST_ vc_event_create(void);\n\n/* Wait for an event to be set, blocking until it is set.\n   Only one thread may be waiting at any one time.\n   The event is automatically cleared on leaving this function. */\nVCHPRE_ void VCHPOST_ vc_event_wait(void *sig);\n\n/* Reads the state of an event (for polling systems) */\nVCHPRE_ int VCHPOST_ vc_event_status(void *sig);\n\n/* Forcibly clears any pending event */\nVCHPRE_ void VCHPOST_ vc_event_clear(void *sig);\n\n/* Sets an event - can be called from any thread */\nVCHPRE_ void VCHPOST_ vc_event_set(void *sig);\n\n/* Register the calling task to be notified of an event. */\nVCHPRE_ void VCHPOST_ vc_event_register(void *ievent);\n\n/* Set events to block, stopping polling mode. */\nVCHPRE_ void VCHPOST_ vc_event_blocking(void);\n\n/*---------------------------------------------------------------------------*/\n/* Semaphore related functions */\n/*---------------------------------------------------------------------------*/\n\n// Minimum number of locks an implementation should support.\n\n#define VC_LOCK_MAX_NUM 32\n\n// Create a lock. Returns a pointer to the lock object. A lock is initially available\n// just once.\n\nVCHPRE_ void * VCHPOST_ vc_lock_create(void);\n\n// Obtain a lock. Block until we have it. Locks are not re-entrant for the same thread.\n\nVCHPRE_ void VCHPOST_ vc_lock_obtain(void *lock);\n\n// Release a lock. Anyone can call this, even if they didn't obtain the lock first.\n\nVCHPRE_ void VCHPOST_ vc_lock_release(void *lock);\n\n/*---------------------------------------------------------------------------*/\n/* File system related functions */\n/*---------------------------------------------------------------------------*/\n\n// Initialises the host dependent file system functions for use\nVCHPRE_ void VCHPOST_ vc_hostfs_init(void);\nVCHPRE_ void VCHPOST_ vc_hostfs_exit(void);\n\n// Low level file system functions equivalent to close(), lseek(), open(), read() and write()\nVCHPRE_ int VCHPOST_ vc_hostfs_close(int fildes);\n\nVCHPRE_ long VCHPOST_ vc_hostfs_lseek(int fildes, long offset, int whence);\n\nVCHPRE_ int64_t VCHPOST_ vc_hostfs_lseek64(int fildes, int64_t offset, int whence);\n\nVCHPRE_ int VCHPOST_ vc_hostfs_open(const char *path, int vc_oflag);\n\nVCHPRE_ int VCHPOST_ vc_hostfs_read(int fildes, void *buf, unsigned int nbyte);\n\nVCHPRE_ int VCHPOST_ vc_hostfs_write(int fildes, const void *buf, unsigned int nbyte);\n\n// Ends a directory listing iteration\nVCHPRE_ int VCHPOST_ vc_hostfs_closedir(void *dhandle);\n\n// Formats the drive that contains the given path\nVCHPRE_ int VCHPOST_ vc_hostfs_format(const char *path);\n\n// Returns the amount of free space on the drive that contains the given path\nVCHPRE_ int VCHPOST_ vc_hostfs_freespace(const char *path);\nVCHPRE_ int64_t VCHPOST_ vc_hostfs_freespace64(const char *path);\n\n// Gets the attributes of the named file\nVCHPRE_ int VCHPOST_ vc_hostfs_get_attr(const char *path, fattributes_t *attr);\n\n// Creates a new directory\nVCHPRE_ int VCHPOST_ vc_hostfs_mkdir(const char *path);\n\n// Starts a directory listing iteration\nVCHPRE_ void * VCHPOST_ vc_hostfs_opendir(const char *dirname);\n\n// Directory listing iterator\nVCHPRE_ struct dirent * VCHPOST_ vc_hostfs_readdir_r(void *dhandle, struct dirent *result);\n\n// Deletes a file or (empty) directory\nVCHPRE_ int VCHPOST_ vc_hostfs_remove(const char *path);\n\n// Renames a file, provided the new name is on the same file system as the old\nVCHPRE_ int VCHPOST_ vc_hostfs_rename(const char *oldfile, const char *newfile);\n\n// Sets the attributes of the named file\nVCHPRE_ int VCHPOST_ vc_hostfs_set_attr(const char *path, fattributes_t attr);\n\n// Truncates a file at its current position\nVCHPRE_ int VCHPOST_ vc_hostfs_setend(int fildes);\n\n// Returns the total amount of space on the drive that contains the given path\nVCHPRE_ int VCHPOST_ vc_hostfs_totalspace(const char *path);\nVCHPRE_ int64_t VCHPOST_ vc_hostfs_totalspace64(const char *path);\n\n// Return millisecond resolution system time, only used for differences\nVCHPRE_ int VCHPOST_ vc_millitime(void);\n\n// Invalidates any cluster chains in the FAT that are not referenced in any directory structures\nVCHPRE_ void VCHPOST_ vc_hostfs_scandisk(const char *path);\n\n// Checks whether or not a FAT filesystem is corrupt or not. If fix_errors is TRUE behaves exactly as vc_filesys_scandisk.\nVCHPRE_ int VCHPOST_ vc_hostfs_chkdsk(const char *path, int fix_errors);\n\n/*---------------------------------------------------------------------------*/\n/* These functions only need to be implemented for the test system. */\n/*---------------------------------------------------------------------------*/\n\n// Open a log file.\nVCHPRE_ void VCHPOST_ vc_log_open(const char *fname);\n\n// Flush any pending data to the log file.\nVCHPRE_ void VCHPOST_ vc_log_flush(void);\n\n// Close the log file.\nVCHPRE_ void VCHPOST_ vc_log_close(void);\n\n// Log an error.\nVCHPRE_ void VCHPOST_ vc_log_error(const char *format, ...);\n\n// Log a warning.\nVCHPRE_ void VCHPOST_ vc_log_warning(const char *format, ...);\n\n// Write a message to the log.\nVCHPRE_ void VCHPOST_ vc_log_msg(const char *format, ...);\n\n// Flush the log.\nVCHPRE_ void VCHPOST_ vc_log_flush(void);\n\n// Return the total number of warnings and errors logged.\nVCHPRE_ void VCHPOST_ vc_log_counts(int *warnings, int *errors);\n\n// Wait for the specified number of microseconds. Used in test system only.\nVCHPRE_ void VCHPOST_ vc_sleep(int ms);\n\n// Get a time value in milliseconds. Used for measuring time differences\nVCHPRE_ uint32_t VCHPOST_ vc_time(void);\n\n// Check timing functions are available. Use in calibrating tests.\nVCHPRE_ int VCHPOST_ calibrate_sleep (const char *data_dir);\n\n/*---------------------------------------------------------------------------*/\n/* Functions to allow dynamic service creation */\n/*---------------------------------------------------------------------------*/\n\nVCHPRE_ void VCHPOST_ vc_host_get_vchi_state(VCHI_INSTANCE_T *initialise_instance, VCHI_CONNECTION_T **connection);\n\n#endif\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vmcs_host/vchost_platform_config.h",
    "content": "/*\nCopyright (c) 2016, Raspberry Pi (Trading) Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n#if defined(__unix__) && !defined(__ANDROID__)\n#include \"linux/vchost_config.h\"\n#else\n#include \"vchost_config.h\"\n#endif\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vmcs_host/vcilcs.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n// OpenMAX IL Component Service definitions\n\n#ifndef ILCS_H\n#define ILCS_H\n\n#include \"interface/vmcs_host/khronos/IL/OMX_Component.h\"\n#include \"interface/vmcs_host/vc_ilcs_defs.h\"\n\nstruct ILCS_SERVICE_T;\ntypedef struct ILCS_SERVICE_T ILCS_SERVICE_T;\n\nstruct ILCS_COMMON_T;\ntypedef struct ILCS_COMMON_T ILCS_COMMON_T;\n\ntypedef void (*IL_FN_T)(ILCS_COMMON_T *st, void *call, int clen, void *resp, int *rlen);\n\ntypedef struct {\n   IL_FN_T *fns;\n   ILCS_COMMON_T *(*ilcs_common_init)(ILCS_SERVICE_T *);\n   void (*ilcs_common_deinit)(ILCS_COMMON_T *st);\n   void (*ilcs_thread_init)(ILCS_COMMON_T *st);\n   unsigned char *(*ilcs_mem_lock)(OMX_BUFFERHEADERTYPE *buffer);\n   void (*ilcs_mem_unlock)(OMX_BUFFERHEADERTYPE *buffer);\n} ILCS_CONFIG_T;\n\n// initialise the VideoCore IL Component service\n// returns pointer to state on success, NULL on failure\n#ifdef USE_VCHIQ_ARM\nVCHPRE_ ILCS_SERVICE_T VCHPOST_ *ilcs_init(VCHIQ_INSTANCE_T state, void **connection, ILCS_CONFIG_T *config, int use_memmgr);\n#else\nVCHPRE_ ILCS_SERVICE_T VCHPOST_ *ilcs_init(VCHIQ_STATE_T *state, void **connection, ILCS_CONFIG_T *config, int use_memmgr);\n#endif\n\n// deinitialises the IL Component service\nVCHPRE_ void VCHPOST_ ilcs_deinit(ILCS_SERVICE_T *ilcs);\n\n// returns 1 if the current thread is the ilcs thread, 0 otherwise\nVCHPRE_ int VCHPOST_ ilcs_thread_current(void *param);\n\n// returns pointer to shared state\nVCHPRE_ ILCS_COMMON_T *ilcs_get_common(ILCS_SERVICE_T *ilcs);\n\nVCHPRE_ int VCHPOST_ ilcs_execute_function(ILCS_SERVICE_T *ilcs, IL_FUNCTION_T func, void *data, int len, void *resp, int *rlen);\nVCHPRE_ OMX_ERRORTYPE VCHPOST_ ilcs_pass_buffer(ILCS_SERVICE_T *ilcs, IL_FUNCTION_T func, void *reference, OMX_BUFFERHEADERTYPE *pBuffer);\nVCHPRE_ OMX_BUFFERHEADERTYPE * VCHPOST_ ilcs_receive_buffer(ILCS_SERVICE_T *ilcs, void *call, int clen, OMX_COMPONENTTYPE **pComp);\n\n// bulks are 16 bytes aligned, implicit in use of vchiq\n#define ILCS_ALIGN   16\n\n#define ILCS_ROUND_UP(x) ((((unsigned long)(x))+ILCS_ALIGN-1) & ~(ILCS_ALIGN-1))\n#define ILCS_ROUND_DOWN(x) (((unsigned long)(x)) & ~(ILCS_ALIGN-1))\n#define ILCS_ALIGNED(x) (((unsigned long)(x) & (ILCS_ALIGN-1)) == 0)\n\n\n#ifdef _VIDEOCORE\n#include \"vcfw/logging/logging.h\"\n\n#ifdef ILCS_LOGGING\n\n#define LOG_MSG ILCS_LOGGING\nextern void ilcs_log_event_handler(OMX_HANDLETYPE hComponent, OMX_PTR pAppData, OMX_EVENTTYPE eEvent,\n                                   OMX_U32 nData1,OMX_U32 nData2,OMX_PTR pEventData);\n\n#else\n\n#define LOG_MSG LOGGING_GENERAL\n#define ilcs_log_event_handler(...)\nextern void dummy_logging_message(int level, const char *format, ...);\n#undef logging_message\n#define logging_message if (1) {} else dummy_logging_message\n\n#endif // ILCS_LOGGING\n#endif // _VIDEOCORE\n\n#endif // ILCS_H\n\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/interface/vmcs_host/vcilcs_common.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n// OpenMAX IL Component Service common - Host side header\n\ntypedef struct {\n   OMX_U32 port;\n   IL_FUNCTION_T func;\n   OMX_BOOL bEGL;\n   OMX_U32 numBuffers;\n   OMX_DIRTYPE dir;\n} VC_PRIVATE_PORT_T;\n\nstruct _VC_PRIVATE_COMPONENT_T {\n   OMX_COMPONENTTYPE *comp;\n   void *reference;\n   OMX_U32 numPorts;\n   OMX_CALLBACKTYPE callbacks;\n   OMX_PTR callback_state;\n   VC_PRIVATE_PORT_T *port;\n   struct _VC_PRIVATE_COMPONENT_T *next;\n};\ntypedef struct _VC_PRIVATE_COMPONENT_T  VC_PRIVATE_COMPONENT_T;\n\nstruct ILCS_COMMON_T {\n   VCOS_SEMAPHORE_T component_lock;\n   VC_PRIVATE_COMPONENT_T *component_list;\n   ILCS_SERVICE_T *ilcs;\n};\n   \nVCHPRE_ void VCHPOST_ vcilcs_config(ILCS_CONFIG_T *config);\n\n// functions that implement incoming functions calls\n// from VideoCore components to host based components\nVCHPRE_ void VCHPOST_ vcil_in_get_state(ILCS_COMMON_T *st, void *call, int clen, void *resp, int *rlen);\nVCHPRE_ void VCHPOST_ vcil_in_get_parameter(ILCS_COMMON_T *st, void *call, int clen, void *resp, int *rlen);\nVCHPRE_ void VCHPOST_ vcil_in_set_parameter(ILCS_COMMON_T *st, void *call, int clen, void *resp, int *rlen);\nVCHPRE_ void VCHPOST_ vcil_in_get_config(ILCS_COMMON_T *st, void *call, int clen, void *resp, int *rlen);\nVCHPRE_ void VCHPOST_ vcil_in_set_config(ILCS_COMMON_T *st, void *call, int clen, void *resp, int *rlen);\nVCHPRE_ void VCHPOST_ vcil_in_use_buffer(ILCS_COMMON_T *st, void *call, int clen, void *resp, int *rlen);\nVCHPRE_ void VCHPOST_ vcil_in_free_buffer(ILCS_COMMON_T *st, void *call, int clen, void *resp, int *rlen);\nVCHPRE_ void VCHPOST_ vcil_in_empty_this_buffer(ILCS_COMMON_T *st, void *call, int clen, void *resp, int *rlen);\nVCHPRE_ void VCHPOST_ vcil_in_fill_this_buffer(ILCS_COMMON_T *st, void *call, int clen, void *resp, int *rlen);\nVCHPRE_ void VCHPOST_ vcil_in_get_component_version(ILCS_COMMON_T *st, void *call, int clen, void *resp, int *rlen);\nVCHPRE_ void VCHPOST_ vcil_in_get_extension_index(ILCS_COMMON_T *st, void *call, int clen, void *resp, int *rlen);\nVCHPRE_ void VCHPOST_ vcil_in_component_role_enum(ILCS_COMMON_T *st, void *call, int clen, void *resp, int *rlen);\n\n// functions that implement callbacks from VideoCore\n// components to the host core.\n// The prefix is vcil_out since they implement part\n// of the API that the host uses out to VideoCore\nVCHPRE_ void VCHPOST_ vcil_out_event_handler(ILCS_COMMON_T *st, void *call, int clen, void *resp, int *rlen);\nVCHPRE_ void VCHPOST_ vcil_out_empty_buffer_done(ILCS_COMMON_T *st, void *call, int clen, void *resp, int *rlen);\nVCHPRE_ void VCHPOST_ vcil_out_fill_buffer_done(ILCS_COMMON_T *st, void *call, int clen, void *resp, int *rlen);\n\n// functions used by the host IL core\nVCHPRE_ OMX_ERRORTYPE VCHPOST_ vcil_out_get_debug_information(ILCS_COMMON_T *st, OMX_STRING debugInfo, OMX_S32 *pLen);\nVCHPRE_ OMX_ERRORTYPE VCHPOST_ vcil_out_create_component(ILCS_COMMON_T *st, OMX_HANDLETYPE hComponent, OMX_STRING component_name);\nVCHPRE_ OMX_ERRORTYPE VCHPOST_ vcil_out_component_name_enum(ILCS_COMMON_T *st, OMX_STRING cComponentName, OMX_U32 nNameLength, OMX_U32 nIndex);\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/json/assertions.h",
    "content": "// Copyright 2007-2010 Baptiste Lepilleur\n// Distributed under MIT license, or public domain if desired and\n// recognized in your jurisdiction.\n// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE\n\n#ifndef CPPTL_JSON_ASSERTIONS_H_INCLUDED\n#define CPPTL_JSON_ASSERTIONS_H_INCLUDED\n\n#include <stdlib.h>\n\n#if !defined(JSON_IS_AMALGAMATION)\n#include \"config.h\"\n#endif // if !defined(JSON_IS_AMALGAMATION)\n\n#if JSON_USE_EXCEPTION\n#include <stdexcept>\n#define JSON_ASSERT(condition)                                                 \\\n  assert(condition); // @todo <= change this into an exception throw\n#define JSON_FAIL_MESSAGE(message) throw std::runtime_error(message);\n#else // JSON_USE_EXCEPTION\n#define JSON_ASSERT(condition) assert(condition);\n\n// The call to assert() will show the failure message in debug builds. In\n// release bugs we write to invalid memory in order to crash hard, so that a\n// debugger or crash reporter gets the chance to take over. We still call exit()\n// afterward in order to tell the compiler that this macro doesn't return.\n#define JSON_FAIL_MESSAGE(message)                                             \\\n  {                                                                            \\\n    assert(false &&message);                                                   \\\n    strcpy(reinterpret_cast<char *>(666), message);                            \\\n    exit(123);                                                                 \\\n  }\n\n#endif\n\n#define JSON_ASSERT_MESSAGE(condition, message)                                \\\n  if (!(condition)) {                                                          \\\n    JSON_FAIL_MESSAGE(message)                                                 \\\n  }\n\n#endif // CPPTL_JSON_ASSERTIONS_H_INCLUDED\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/json/autolink.h",
    "content": "// Copyright 2007-2010 Baptiste Lepilleur\n// Distributed under MIT license, or public domain if desired and\n// recognized in your jurisdiction.\n// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE\n\n#ifndef JSON_AUTOLINK_H_INCLUDED\n#define JSON_AUTOLINK_H_INCLUDED\n\n#include \"config.h\"\n\n#ifdef JSON_IN_CPPTL\n#include <cpptl/cpptl_autolink.h>\n#endif\n\n#if !defined(JSON_NO_AUTOLINK) && !defined(JSON_DLL_BUILD) &&                  \\\n    !defined(JSON_IN_CPPTL)\n#define CPPTL_AUTOLINK_NAME \"json\"\n#undef CPPTL_AUTOLINK_DLL\n#ifdef JSON_DLL\n#define CPPTL_AUTOLINK_DLL\n#endif\n#include \"autolink.h\"\n#endif\n\n#endif // JSON_AUTOLINK_H_INCLUDED\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/json/config.h",
    "content": "// Copyright 2007-2010 Baptiste Lepilleur\n// Distributed under MIT license, or public domain if desired and\n// recognized in your jurisdiction.\n// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE\n\n#ifndef JSON_CONFIG_H_INCLUDED\n#define JSON_CONFIG_H_INCLUDED\n\n/// If defined, indicates that json library is embedded in CppTL library.\n//# define JSON_IN_CPPTL 1\n\n/// If defined, indicates that json may leverage CppTL library\n//#  define JSON_USE_CPPTL 1\n/// If defined, indicates that cpptl vector based map should be used instead of\n/// std::map\n/// as Value container.\n//#  define JSON_USE_CPPTL_SMALLMAP 1\n/// If defined, indicates that Json specific container should be used\n/// (hash table & simple deque container with customizable allocator).\n/// THIS FEATURE IS STILL EXPERIMENTAL! There is know bugs: See #3177332\n//#  define JSON_VALUE_USE_INTERNAL_MAP 1\n/// Force usage of standard new/malloc based allocator instead of memory pool\n/// based allocator.\n/// The memory pools allocator used optimization (initializing Value and\n/// ValueInternalLink\n/// as if it was a POD) that may cause some validation tool to report errors.\n/// Only has effects if JSON_VALUE_USE_INTERNAL_MAP is defined.\n//#  define JSON_USE_SIMPLE_INTERNAL_ALLOCATOR 1\n\n// If non-zero, the library uses exceptions to report bad input instead of C\n// assertion macros. The default is to use exceptions.\n#ifndef JSON_USE_EXCEPTION\n#define JSON_USE_EXCEPTION 1\n#endif\n\n/// If defined, indicates that the source file is amalgated\n/// to prevent private header inclusion.\n/// Remarks: it is automatically defined in the generated amalgated header.\n// #define JSON_IS_AMALGAMATION\n\n#ifdef JSON_IN_CPPTL\n#include <cpptl/config.h>\n#ifndef JSON_USE_CPPTL\n#define JSON_USE_CPPTL 1\n#endif\n#endif\n\n#ifdef JSON_IN_CPPTL\n#define JSON_API CPPTL_API\n#elif defined(JSON_DLL_BUILD)\n#if defined(_MSC_VER)\n#define JSON_API __declspec(dllexport)\n#define JSONCPP_DISABLE_DLL_INTERFACE_WARNING\n#endif // if defined(_MSC_VER)\n#elif defined(JSON_DLL)\n#if defined(_MSC_VER)\n#define JSON_API __declspec(dllimport)\n#define JSONCPP_DISABLE_DLL_INTERFACE_WARNING\n#endif // if defined(_MSC_VER)\n#endif // ifdef JSON_IN_CPPTL\n#if !defined(JSON_API)\n#define JSON_API\n#endif\n\n// If JSON_NO_INT64 is defined, then Json only support C++ \"int\" type for\n// integer\n// Storages, and 64 bits integer support is disabled.\n// #define JSON_NO_INT64 1\n\n#if defined(_MSC_VER) && _MSC_VER <= 1200 // MSVC 6\n// Microsoft Visual Studio 6 only support conversion from __int64 to double\n// (no conversion from unsigned __int64).\n#define JSON_USE_INT64_DOUBLE_CONVERSION 1\n// Disable warning 4786 for VS6 caused by STL (identifier was truncated to '255'\n// characters in the debug information)\n// All projects I've ever seen with VS6 were using this globally (not bothering\n// with pragma push/pop).\n#pragma warning(disable : 4786)\n#endif // if defined(_MSC_VER)  &&  _MSC_VER < 1200 // MSVC 6\n\n#if defined(_MSC_VER) && _MSC_VER >= 1500 // MSVC 2008\n/// Indicates that the following function is deprecated.\n#define JSONCPP_DEPRECATED(message) __declspec(deprecated(message))\n#endif\n\n#if !defined(JSONCPP_DEPRECATED)\n#define JSONCPP_DEPRECATED(message)\n#endif // if !defined(JSONCPP_DEPRECATED)\n\nnamespace Json {\ntypedef int Int;\ntypedef unsigned int UInt;\n#if defined(JSON_NO_INT64)\ntypedef int LargestInt;\ntypedef unsigned int LargestUInt;\n#undef JSON_HAS_INT64\n#else                 // if defined(JSON_NO_INT64)\n// For Microsoft Visual use specific types as long long is not supported\n#if defined(_MSC_VER) // Microsoft Visual Studio\ntypedef __int64 Int64;\ntypedef unsigned __int64 UInt64;\n#else                 // if defined(_MSC_VER) // Other platforms, use long long\ntypedef long long int Int64;\ntypedef unsigned long long int UInt64;\n#endif // if defined(_MSC_VER)\ntypedef Int64 LargestInt;\ntypedef UInt64 LargestUInt;\n#define JSON_HAS_INT64\n#endif // if defined(JSON_NO_INT64)\n} // end namespace Json\n\n#endif // JSON_CONFIG_H_INCLUDED\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/json/features.h",
    "content": "// Copyright 2007-2010 Baptiste Lepilleur\n// Distributed under MIT license, or public domain if desired and\n// recognized in your jurisdiction.\n// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE\n\n#ifndef CPPTL_JSON_FEATURES_H_INCLUDED\n#define CPPTL_JSON_FEATURES_H_INCLUDED\n\n#if !defined(JSON_IS_AMALGAMATION)\n#include \"forwards.h\"\n#endif // if !defined(JSON_IS_AMALGAMATION)\n\nnamespace Json {\n\n/** \\brief Configuration passed to reader and writer.\n * This configuration object can be used to force the Reader or Writer\n * to behave in a standard conforming way.\n */\nclass JSON_API Features {\npublic:\n  /** \\brief A configuration that allows all features and assumes all strings\n   * are UTF-8.\n   * - C & C++ comments are allowed\n   * - Root object can be any JSON value\n   * - Assumes Value strings are encoded in UTF-8\n   */\n  static Features all();\n\n  /** \\brief A configuration that is strictly compatible with the JSON\n   * specification.\n   * - Comments are forbidden.\n   * - Root object must be either an array or an object value.\n   * - Assumes Value strings are encoded in UTF-8\n   */\n  static Features strictMode();\n\n  /** \\brief Initialize the configuration like JsonConfig::allFeatures;\n   */\n  Features();\n\n  /// \\c true if comments are allowed. Default: \\c true.\n  bool allowComments_;\n\n  /// \\c true if root must be either an array or an object value. Default: \\c\n  /// false.\n  bool strictRoot_;\n\n  /// \\c true if dropped null placeholders are allowed. Default: \\c false.\n  bool allowDroppedNullPlaceholders_;\n\n  /// \\c true if numeric object key are allowed. Default: \\c false.\n  bool allowNumericKeys_;\n};\n\n} // namespace Json\n\n#endif // CPPTL_JSON_FEATURES_H_INCLUDED\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/json/forwards.h",
    "content": "// Copyright 2007-2010 Baptiste Lepilleur\n// Distributed under MIT license, or public domain if desired and\n// recognized in your jurisdiction.\n// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE\n\n#ifndef JSON_FORWARDS_H_INCLUDED\n#define JSON_FORWARDS_H_INCLUDED\n\n#if !defined(JSON_IS_AMALGAMATION)\n#include \"config.h\"\n#endif // if !defined(JSON_IS_AMALGAMATION)\n\nnamespace Json {\n\n// writer.h\nclass FastWriter;\nclass StyledWriter;\n\n// reader.h\nclass Reader;\n\n// features.h\nclass Features;\n\n// value.h\ntypedef unsigned int ArrayIndex;\nclass StaticString;\nclass Path;\nclass PathArgument;\nclass Value;\nclass ValueIteratorBase;\nclass ValueIterator;\nclass ValueConstIterator;\n#ifdef JSON_VALUE_USE_INTERNAL_MAP\nclass ValueMapAllocator;\nclass ValueInternalLink;\nclass ValueInternalArray;\nclass ValueInternalMap;\n#endif // #ifdef JSON_VALUE_USE_INTERNAL_MAP\n\n} // namespace Json\n\n#endif // JSON_FORWARDS_H_INCLUDED\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/json/json.h",
    "content": "// Copyright 2007-2010 Baptiste Lepilleur\n// Distributed under MIT license, or public domain if desired and\n// recognized in your jurisdiction.\n// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE\n\n#ifndef JSON_JSON_H_INCLUDED\n#define JSON_JSON_H_INCLUDED\n\n#include \"autolink.h\"\n#include \"value.h\"\n#include \"reader.h\"\n#include \"writer.h\"\n#include \"features.h\"\n\n#endif // JSON_JSON_H_INCLUDED\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/json/json_batchallocator.h",
    "content": "// Copyright 2007-2010 Baptiste Lepilleur\n// Distributed under MIT license, or public domain if desired and\n// recognized in your jurisdiction.\n// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE\n\n#ifndef JSONCPP_BATCHALLOCATOR_H_INCLUDED\n#define JSONCPP_BATCHALLOCATOR_H_INCLUDED\n\n#include <stdlib.h>\n#include <assert.h>\n\n#ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION\n\nnamespace Json {\n\n/* Fast memory allocator.\n *\n * This memory allocator allocates memory for a batch of object (specified by\n * the page size, the number of object in each page).\n *\n * It does not allow the destruction of a single object. All the allocated\n * objects can be destroyed at once. The memory can be either released or reused\n * for future allocation.\n *\n * The in-place new operator must be used to construct the object using the\n * pointer returned by allocate.\n */\ntemplate <typename AllocatedType, const unsigned int objectPerAllocation>\nclass BatchAllocator {\npublic:\n  BatchAllocator(unsigned int objectsPerPage = 255)\n      : freeHead_(0), objectsPerPage_(objectsPerPage) {\n    //      printf( \"Size: %d => %s\\n\", sizeof(AllocatedType),\n    // typeid(AllocatedType).name() );\n    assert(sizeof(AllocatedType) * objectPerAllocation >=\n           sizeof(AllocatedType *)); // We must be able to store a slist in the\n                                     // object free space.\n    assert(objectsPerPage >= 16);\n    batches_ = allocateBatch(0); // allocated a dummy page\n    currentBatch_ = batches_;\n  }\n\n  ~BatchAllocator() {\n    for (BatchInfo *batch = batches_; batch;) {\n      BatchInfo *nextBatch = batch->next_;\n      free(batch);\n      batch = nextBatch;\n    }\n  }\n\n  /// allocate space for an array of objectPerAllocation object.\n  /// @warning it is the responsability of the caller to call objects\n  /// constructors.\n  AllocatedType *allocate() {\n    if (freeHead_) // returns node from free list.\n    {\n      AllocatedType *object = freeHead_;\n      freeHead_ = *(AllocatedType **)object;\n      return object;\n    }\n    if (currentBatch_->used_ == currentBatch_->end_) {\n      currentBatch_ = currentBatch_->next_;\n      while (currentBatch_ && currentBatch_->used_ == currentBatch_->end_)\n        currentBatch_ = currentBatch_->next_;\n\n      if (!currentBatch_) // no free batch found, allocate a new one\n      {\n        currentBatch_ = allocateBatch(objectsPerPage_);\n        currentBatch_->next_ = batches_; // insert at the head of the list\n        batches_ = currentBatch_;\n      }\n    }\n    AllocatedType *allocated = currentBatch_->used_;\n    currentBatch_->used_ += objectPerAllocation;\n    return allocated;\n  }\n\n  /// Release the object.\n  /// @warning it is the responsability of the caller to actually destruct the\n  /// object.\n  void release(AllocatedType *object) {\n    assert(object != 0);\n    *(AllocatedType **)object = freeHead_;\n    freeHead_ = object;\n  }\n\nprivate:\n  struct BatchInfo {\n    BatchInfo *next_;\n    AllocatedType *used_;\n    AllocatedType *end_;\n    AllocatedType buffer_[objectPerAllocation];\n  };\n\n  // disabled copy constructor and assignement operator.\n  BatchAllocator(const BatchAllocator &);\n  void operator=(const BatchAllocator &);\n\n  static BatchInfo *allocateBatch(unsigned int objectsPerPage) {\n    const unsigned int mallocSize =\n        sizeof(BatchInfo) - sizeof(AllocatedType) * objectPerAllocation +\n        sizeof(AllocatedType) * objectPerAllocation * objectsPerPage;\n    BatchInfo *batch = static_cast<BatchInfo *>(malloc(mallocSize));\n    batch->next_ = 0;\n    batch->used_ = batch->buffer_;\n    batch->end_ = batch->buffer_ + objectsPerPage;\n    return batch;\n  }\n\n  BatchInfo *batches_;\n  BatchInfo *currentBatch_;\n  /// Head of a single linked list within the allocated space of freeed object\n  AllocatedType *freeHead_;\n  unsigned int objectsPerPage_;\n};\n\n} // namespace Json\n\n#endif // ifndef JSONCPP_DOC_INCLUDE_IMPLEMENTATION\n\n#endif // JSONCPP_BATCHALLOCATOR_H_INCLUDED\n// vim: et ts=2 sts=2 sw=2 tw=0\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/json/json_internalarray.inl",
    "content": "// Copyright 2007-2010 Baptiste Lepilleur\n// Distributed under MIT license, or public domain if desired and\n// recognized in your jurisdiction.\n// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE\n\n// included by json_value.cpp\n\nnamespace Json {\n\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// class ValueInternalArray\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n\nValueArrayAllocator::~ValueArrayAllocator()\n{\n}\n\n// //////////////////////////////////////////////////////////////////\n// class DefaultValueArrayAllocator\n// //////////////////////////////////////////////////////////////////\n#ifdef JSON_USE_SIMPLE_INTERNAL_ALLOCATOR\nclass DefaultValueArrayAllocator : public ValueArrayAllocator\n{\npublic: // overridden from ValueArrayAllocator\n   virtual ~DefaultValueArrayAllocator()\n   {\n   }\n\n   virtual ValueInternalArray *newArray()\n   {\n      return new ValueInternalArray();\n   }\n\n   virtual ValueInternalArray *newArrayCopy( const ValueInternalArray &other )\n   {\n      return new ValueInternalArray( other );\n   }\n\n   virtual void destructArray( ValueInternalArray *array )\n   {\n      delete array;\n   }\n\n   virtual void reallocateArrayPageIndex( Value **&indexes, \n                                          ValueInternalArray::PageIndex &indexCount,\n                                          ValueInternalArray::PageIndex minNewIndexCount )\n   {\n      ValueInternalArray::PageIndex newIndexCount = (indexCount*3)/2 + 1;\n      if ( minNewIndexCount > newIndexCount )\n         newIndexCount = minNewIndexCount;\n      void *newIndexes = realloc( indexes, sizeof(Value*) * newIndexCount );\n      JSON_ASSERT_MESSAGE(newIndexes, \"Couldn't realloc.\");\n      indexCount = newIndexCount;\n      indexes = static_cast<Value **>( newIndexes );\n   }\n   virtual void releaseArrayPageIndex( Value **indexes, \n                                       ValueInternalArray::PageIndex indexCount )\n   {\n      if ( indexes )\n         free( indexes );\n   }\n\n   virtual Value *allocateArrayPage()\n   {\n      return static_cast<Value *>( malloc( sizeof(Value) * ValueInternalArray::itemsPerPage ) );\n   }\n\n   virtual void releaseArrayPage( Value *value )\n   {\n      if ( value )\n         free( value );\n   }\n};\n\n#else // #ifdef JSON_USE_SIMPLE_INTERNAL_ALLOCATOR\n/// @todo make this thread-safe (lock when accessign batch allocator)\nclass DefaultValueArrayAllocator : public ValueArrayAllocator\n{\npublic: // overridden from ValueArrayAllocator\n   virtual ~DefaultValueArrayAllocator()\n   {\n   }\n\n   virtual ValueInternalArray *newArray()\n   {\n      ValueInternalArray *array = arraysAllocator_.allocate();\n      new (array) ValueInternalArray(); // placement new\n      return array;\n   }\n\n   virtual ValueInternalArray *newArrayCopy( const ValueInternalArray &other )\n   {\n      ValueInternalArray *array = arraysAllocator_.allocate();\n      new (array) ValueInternalArray( other ); // placement new\n      return array;\n   }\n\n   virtual void destructArray( ValueInternalArray *array )\n   {\n      if ( array )\n      {\n         array->~ValueInternalArray();\n         arraysAllocator_.release( array );\n      }\n   }\n\n   virtual void reallocateArrayPageIndex( Value **&indexes, \n                                          ValueInternalArray::PageIndex &indexCount,\n                                          ValueInternalArray::PageIndex minNewIndexCount )\n   {\n      ValueInternalArray::PageIndex newIndexCount = (indexCount*3)/2 + 1;\n      if ( minNewIndexCount > newIndexCount )\n         newIndexCount = minNewIndexCount;\n      void *newIndexes = realloc( indexes, sizeof(Value*) * newIndexCount );\n      JSON_ASSERT_MESSAGE(newIndexes, \"Couldn't realloc.\");\n      indexCount = newIndexCount;\n      indexes = static_cast<Value **>( newIndexes );\n   }\n   virtual void releaseArrayPageIndex( Value **indexes, \n                                       ValueInternalArray::PageIndex indexCount )\n   {\n      if ( indexes )\n         free( indexes );\n   }\n\n   virtual Value *allocateArrayPage()\n   {\n      return static_cast<Value *>( pagesAllocator_.allocate() );\n   }\n\n   virtual void releaseArrayPage( Value *value )\n   {\n      if ( value )\n         pagesAllocator_.release( value );\n   }\nprivate:\n   BatchAllocator<ValueInternalArray,1> arraysAllocator_;\n   BatchAllocator<Value,ValueInternalArray::itemsPerPage> pagesAllocator_;\n};\n#endif // #ifdef JSON_USE_SIMPLE_INTERNAL_ALLOCATOR\n\nstatic ValueArrayAllocator *&arrayAllocator()\n{\n   static DefaultValueArrayAllocator defaultAllocator;\n   static ValueArrayAllocator *arrayAllocator = &defaultAllocator;\n   return arrayAllocator;\n}\n\nstatic struct DummyArrayAllocatorInitializer {\n   DummyArrayAllocatorInitializer() \n   {\n      arrayAllocator();      // ensure arrayAllocator() statics are initialized before main().\n   }\n} dummyArrayAllocatorInitializer;\n\n// //////////////////////////////////////////////////////////////////\n// class ValueInternalArray\n// //////////////////////////////////////////////////////////////////\nbool \nValueInternalArray::equals( const IteratorState &x, \n                            const IteratorState &other )\n{\n   return x.array_ == other.array_  \n          &&  x.currentItemIndex_ == other.currentItemIndex_  \n          &&  x.currentPageIndex_ == other.currentPageIndex_;\n}\n\n\nvoid \nValueInternalArray::increment( IteratorState &it )\n{\n   JSON_ASSERT_MESSAGE( it.array_  &&\n      (it.currentPageIndex_ - it.array_->pages_)*itemsPerPage + it.currentItemIndex_\n      != it.array_->size_,\n      \"ValueInternalArray::increment(): moving iterator beyond end\" );\n   ++(it.currentItemIndex_);\n   if ( it.currentItemIndex_ == itemsPerPage )\n   {\n      it.currentItemIndex_ = 0;\n      ++(it.currentPageIndex_);\n   }\n}\n\n\nvoid \nValueInternalArray::decrement( IteratorState &it )\n{\n   JSON_ASSERT_MESSAGE( it.array_  &&  it.currentPageIndex_ == it.array_->pages_ \n                        &&  it.currentItemIndex_ == 0,\n      \"ValueInternalArray::decrement(): moving iterator beyond end\" );\n   if ( it.currentItemIndex_ == 0 )\n   {\n      it.currentItemIndex_ = itemsPerPage-1;\n      --(it.currentPageIndex_);\n   }\n   else\n   {\n      --(it.currentItemIndex_);\n   }\n}\n\n\nValue &\nValueInternalArray::unsafeDereference( const IteratorState &it )\n{\n   return (*(it.currentPageIndex_))[it.currentItemIndex_];\n}\n\n\nValue &\nValueInternalArray::dereference( const IteratorState &it )\n{\n   JSON_ASSERT_MESSAGE( it.array_  &&\n      (it.currentPageIndex_ - it.array_->pages_)*itemsPerPage + it.currentItemIndex_\n      < it.array_->size_,\n      \"ValueInternalArray::dereference(): dereferencing invalid iterator\" );\n   return unsafeDereference( it );\n}\n\nvoid \nValueInternalArray::makeBeginIterator( IteratorState &it ) const\n{\n   it.array_ = const_cast<ValueInternalArray *>( this );\n   it.currentItemIndex_ = 0;\n   it.currentPageIndex_ = pages_;\n}\n\n\nvoid \nValueInternalArray::makeIterator( IteratorState &it, ArrayIndex index ) const\n{\n   it.array_ = const_cast<ValueInternalArray *>( this );\n   it.currentItemIndex_ = index % itemsPerPage;\n   it.currentPageIndex_ = pages_ + index / itemsPerPage;\n}\n\n\nvoid \nValueInternalArray::makeEndIterator( IteratorState &it ) const\n{\n   makeIterator( it, size_ );\n}\n\n\nValueInternalArray::ValueInternalArray()\n   : pages_( 0 )\n   , size_( 0 )\n   , pageCount_( 0 )\n{\n}\n\n\nValueInternalArray::ValueInternalArray( const ValueInternalArray &other )\n   : pages_( 0 )\n   , size_( other.size_ )\n   , pageCount_( 0 )\n{\n   PageIndex minNewPages = other.size_ / itemsPerPage;\n   arrayAllocator()->reallocateArrayPageIndex( pages_, pageCount_, minNewPages );\n   JSON_ASSERT_MESSAGE( pageCount_ >= minNewPages, \n                        \"ValueInternalArray::reserve(): bad reallocation\" );\n   IteratorState itOther;\n   other.makeBeginIterator( itOther );\n   Value *value;\n   for ( ArrayIndex index = 0; index < size_; ++index, increment(itOther) )\n   {\n      if ( index % itemsPerPage == 0 )\n      {\n         PageIndex pageIndex = index / itemsPerPage;\n         value = arrayAllocator()->allocateArrayPage();\n         pages_[pageIndex] = value;\n      }\n      new (value) Value( dereference( itOther ) );\n   }\n}\n\n\nValueInternalArray &\nValueInternalArray::operator=(ValueInternalArray other)\n{\n   swap(other);\n   return *this;\n}\n\n\nValueInternalArray::~ValueInternalArray()\n{\n   // destroy all constructed items\n   IteratorState it;\n   IteratorState itEnd;\n   makeBeginIterator( it);\n   makeEndIterator( itEnd );\n   for ( ; !equals(it,itEnd); increment(it) )\n   {\n      Value *value = &dereference(it);\n      value->~Value();\n   }\n   // release all pages\n   PageIndex lastPageIndex = size_ / itemsPerPage;\n   for ( PageIndex pageIndex = 0; pageIndex < lastPageIndex; ++pageIndex )\n      arrayAllocator()->releaseArrayPage( pages_[pageIndex] );\n   // release pages index\n   arrayAllocator()->releaseArrayPageIndex( pages_, pageCount_ );\n}\n\n\nvoid \nValueInternalArray::swap( ValueInternalArray &other )\n{\n   Value **tempPages = pages_;\n   pages_ = other.pages_;\n   other.pages_ = tempPages;\n   ArrayIndex tempSize = size_;\n   size_ = other.size_;\n   other.size_ = tempSize;\n   PageIndex tempPageCount = pageCount_;\n   pageCount_ = other.pageCount_;\n   other.pageCount_ = tempPageCount;\n}\n\nvoid \nValueInternalArray::clear()\n{\n   ValueInternalArray dummy;\n   swap( dummy );\n}\n\n\nvoid \nValueInternalArray::resize( ArrayIndex newSize )\n{\n   if ( newSize == 0 )\n      clear();\n   else if ( newSize < size_ )\n   {\n      IteratorState it;\n      IteratorState itEnd;\n      makeIterator( it, newSize );\n      makeIterator( itEnd, size_ );\n      for ( ; !equals(it,itEnd); increment(it) )\n      {\n         Value *value = &dereference(it);\n         value->~Value();\n      }\n      PageIndex pageIndex = (newSize + itemsPerPage - 1) / itemsPerPage;\n      PageIndex lastPageIndex = size_ / itemsPerPage;\n      for ( ; pageIndex < lastPageIndex; ++pageIndex )\n         arrayAllocator()->releaseArrayPage( pages_[pageIndex] );\n      size_ = newSize;\n   }\n   else if ( newSize > size_ )\n      resolveReference( newSize );\n}\n\n\nvoid \nValueInternalArray::makeIndexValid( ArrayIndex index )\n{\n   // Need to enlarge page index ?\n   if ( index >= pageCount_ * itemsPerPage )\n   {\n      PageIndex minNewPages = (index + 1) / itemsPerPage;\n      arrayAllocator()->reallocateArrayPageIndex( pages_, pageCount_, minNewPages );\n      JSON_ASSERT_MESSAGE( pageCount_ >= minNewPages, \"ValueInternalArray::reserve(): bad reallocation\" );\n   }\n\n   // Need to allocate new pages ?\n   ArrayIndex nextPageIndex = \n      (size_ % itemsPerPage) != 0 ? size_ - (size_%itemsPerPage) + itemsPerPage\n                                  : size_;\n   if ( nextPageIndex <= index )\n   {\n      PageIndex pageIndex = nextPageIndex / itemsPerPage;\n      PageIndex pageToAllocate = (index - nextPageIndex) / itemsPerPage + 1;\n      for ( ; pageToAllocate-- > 0; ++pageIndex )\n         pages_[pageIndex] = arrayAllocator()->allocateArrayPage();\n   }\n\n   // Initialize all new entries\n   IteratorState it;\n   IteratorState itEnd;\n   makeIterator( it, size_ );\n   size_ = index + 1;\n   makeIterator( itEnd, size_ );\n   for ( ; !equals(it,itEnd); increment(it) )\n   {\n      Value *value = &dereference(it);\n      new (value) Value(); // Construct a default value using placement new\n   }\n}\n\nValue &\nValueInternalArray::resolveReference( ArrayIndex index )\n{\n   if ( index >= size_ )\n      makeIndexValid( index );\n   return pages_[index/itemsPerPage][index%itemsPerPage];\n}\n\nValue *\nValueInternalArray::find( ArrayIndex index ) const\n{\n   if ( index >= size_ )\n      return 0;\n   return &(pages_[index/itemsPerPage][index%itemsPerPage]);\n}\n\nValueInternalArray::ArrayIndex \nValueInternalArray::size() const\n{\n   return size_;\n}\n\nint \nValueInternalArray::distance( const IteratorState &x, const IteratorState &y )\n{\n   return indexOf(y) - indexOf(x);\n}\n\n\nValueInternalArray::ArrayIndex \nValueInternalArray::indexOf( const IteratorState &iterator )\n{\n   if ( !iterator.array_ )\n      return ArrayIndex(-1);\n   return ArrayIndex(\n      (iterator.currentPageIndex_ - iterator.array_->pages_) * itemsPerPage \n      + iterator.currentItemIndex_ );\n}\n\n\nint \nValueInternalArray::compare( const ValueInternalArray &other ) const\n{\n   int sizeDiff( size_ - other.size_ );\n   if ( sizeDiff != 0 )\n      return sizeDiff;\n   \n   for ( ArrayIndex index =0; index < size_; ++index )\n   {\n      int diff = pages_[index/itemsPerPage][index%itemsPerPage].compare( \n         other.pages_[index/itemsPerPage][index%itemsPerPage] );\n      if ( diff != 0 )\n         return diff;\n   }\n   return 0;\n}\n\n} // namespace Json\n// vim: et ts=3 sts=3 sw=3 tw=0\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/json/json_internalmap.inl",
    "content": "// Copyright 2007-2010 Baptiste Lepilleur\n// Distributed under MIT license, or public domain if desired and\n// recognized in your jurisdiction.\n// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE\n\n// included by json_value.cpp\n\nnamespace Json {\n\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// class ValueInternalMap\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n\n/** \\internal MUST be safely initialized using memset( this, 0, sizeof(ValueInternalLink) );\n   * This optimization is used by the fast allocator.\n   */\nValueInternalLink::ValueInternalLink()\n   : previous_( 0 )\n   , next_( 0 )\n{\n}\n\nValueInternalLink::~ValueInternalLink()\n{ \n   for ( int index =0; index < itemPerLink; ++index )\n   {\n      if ( !items_[index].isItemAvailable() )\n      {\n         if ( !items_[index].isMemberNameStatic() )\n            free( keys_[index] );\n      }\n      else\n         break;\n   }\n}\n\n\n\nValueMapAllocator::~ValueMapAllocator()\n{\n}\n\n#ifdef JSON_USE_SIMPLE_INTERNAL_ALLOCATOR\nclass DefaultValueMapAllocator : public ValueMapAllocator\n{\npublic: // overridden from ValueMapAllocator\n   virtual ValueInternalMap *newMap()\n   {\n      return new ValueInternalMap();\n   }\n\n   virtual ValueInternalMap *newMapCopy( const ValueInternalMap &other )\n   {\n      return new ValueInternalMap( other );\n   }\n\n   virtual void destructMap( ValueInternalMap *map )\n   {\n      delete map;\n   }\n\n   virtual ValueInternalLink *allocateMapBuckets( unsigned int size )\n   {\n      return new ValueInternalLink[size];\n   }\n\n   virtual void releaseMapBuckets( ValueInternalLink *links )\n   {\n      delete [] links;\n   }\n\n   virtual ValueInternalLink *allocateMapLink()\n   {\n      return new ValueInternalLink();\n   }\n\n   virtual void releaseMapLink( ValueInternalLink *link )\n   {\n      delete link;\n   }\n};\n#else\n/// @todo make this thread-safe (lock when accessign batch allocator)\nclass DefaultValueMapAllocator : public ValueMapAllocator\n{\npublic: // overridden from ValueMapAllocator\n   virtual ValueInternalMap *newMap()\n   {\n      ValueInternalMap *map = mapsAllocator_.allocate();\n      new (map) ValueInternalMap(); // placement new\n      return map;\n   }\n\n   virtual ValueInternalMap *newMapCopy( const ValueInternalMap &other )\n   {\n      ValueInternalMap *map = mapsAllocator_.allocate();\n      new (map) ValueInternalMap( other ); // placement new\n      return map;\n   }\n\n   virtual void destructMap( ValueInternalMap *map )\n   {\n      if ( map )\n      {\n         map->~ValueInternalMap();\n         mapsAllocator_.release( map );\n      }\n   }\n\n   virtual ValueInternalLink *allocateMapBuckets( unsigned int size )\n   {\n      return new ValueInternalLink[size];\n   }\n\n   virtual void releaseMapBuckets( ValueInternalLink *links )\n   {\n      delete [] links;\n   }\n\n   virtual ValueInternalLink *allocateMapLink()\n   {\n      ValueInternalLink *link = linksAllocator_.allocate();\n      memset( link, 0, sizeof(ValueInternalLink) );\n      return link;\n   }\n\n   virtual void releaseMapLink( ValueInternalLink *link )\n   {\n      link->~ValueInternalLink();\n      linksAllocator_.release( link );\n   }\nprivate:\n   BatchAllocator<ValueInternalMap,1> mapsAllocator_;\n   BatchAllocator<ValueInternalLink,1> linksAllocator_;\n};\n#endif\n\nstatic ValueMapAllocator *&mapAllocator()\n{\n   static DefaultValueMapAllocator defaultAllocator;\n   static ValueMapAllocator *mapAllocator = &defaultAllocator;\n   return mapAllocator;\n}\n\nstatic struct DummyMapAllocatorInitializer {\n   DummyMapAllocatorInitializer() \n   {\n      mapAllocator();      // ensure mapAllocator() statics are initialized before main().\n   }\n} dummyMapAllocatorInitializer;\n\n\n\n// h(K) = value * K >> w ; with w = 32 & K prime w.r.t. 2^32.\n\n/*\nuse linked list hash map. \nbuckets array is a container.\nlinked list element contains 6 key/values. (memory = (16+4) * 6 + 4 = 124)\nvalue have extra state: valid, available, deleted\n*/\n\n\nValueInternalMap::ValueInternalMap()\n   : buckets_( 0 )\n   , tailLink_( 0 )\n   , bucketsSize_( 0 )\n   , itemCount_( 0 )\n{\n}\n\n\nValueInternalMap::ValueInternalMap( const ValueInternalMap &other )\n   : buckets_( 0 )\n   , tailLink_( 0 )\n   , bucketsSize_( 0 )\n   , itemCount_( 0 )\n{\n   reserve( other.itemCount_ );\n   IteratorState it;\n   IteratorState itEnd;\n   other.makeBeginIterator( it );\n   other.makeEndIterator( itEnd );\n   for ( ; !equals(it,itEnd); increment(it) )\n   {\n      bool isStatic;\n      const char *memberName = key( it, isStatic );\n      const Value &aValue = value( it );\n      resolveReference(memberName, isStatic) = aValue;\n   }\n}\n\n\nValueInternalMap &\nValueInternalMap::operator=(ValueInternalMap other)\n{\n   swap(other);\n   return *this;\n}\n\n\nValueInternalMap::~ValueInternalMap()\n{\n   if ( buckets_ )\n   {\n      for ( BucketIndex bucketIndex =0; bucketIndex < bucketsSize_; ++bucketIndex )\n      {\n         ValueInternalLink *link = buckets_[bucketIndex].next_;\n         while ( link )\n         {\n            ValueInternalLink *linkToRelease = link;\n            link = link->next_;\n            mapAllocator()->releaseMapLink( linkToRelease );\n         }\n      }\n      mapAllocator()->releaseMapBuckets( buckets_ );\n   }\n}\n\n\nvoid \nValueInternalMap::swap( ValueInternalMap &other )\n{\n   ValueInternalLink *tempBuckets = buckets_;\n   buckets_ = other.buckets_;\n   other.buckets_ = tempBuckets;\n   ValueInternalLink *tempTailLink = tailLink_;\n   tailLink_ = other.tailLink_;\n   other.tailLink_ = tempTailLink;\n   BucketIndex tempBucketsSize = bucketsSize_;\n   bucketsSize_ = other.bucketsSize_;\n   other.bucketsSize_ = tempBucketsSize;\n   BucketIndex tempItemCount = itemCount_;\n   itemCount_ = other.itemCount_;\n   other.itemCount_ = tempItemCount;\n}\n\n\nvoid \nValueInternalMap::clear()\n{\n   ValueInternalMap dummy;\n   swap( dummy );\n}\n\n\nValueInternalMap::BucketIndex \nValueInternalMap::size() const\n{\n   return itemCount_;\n}\n\nbool \nValueInternalMap::reserveDelta( BucketIndex growth )\n{\n   return reserve( itemCount_ + growth );\n}\n\nbool \nValueInternalMap::reserve( BucketIndex newItemCount )\n{\n   if ( !buckets_  &&  newItemCount > 0 )\n   {\n      buckets_ = mapAllocator()->allocateMapBuckets( 1 );\n      bucketsSize_ = 1;\n      tailLink_ = &buckets_[0];\n   }\n//   BucketIndex idealBucketCount = (newItemCount + ValueInternalLink::itemPerLink) / ValueInternalLink::itemPerLink;\n   return true;\n}\n\n\nconst Value *\nValueInternalMap::find( const char *key ) const\n{\n   if ( !bucketsSize_ )\n      return 0;\n   HashKey hashedKey = hash( key );\n   BucketIndex bucketIndex = hashedKey % bucketsSize_;\n   for ( const ValueInternalLink *current = &buckets_[bucketIndex]; \n         current != 0; \n         current = current->next_ )\n   {\n      for ( BucketIndex index=0; index < ValueInternalLink::itemPerLink; ++index )\n      {\n         if ( current->items_[index].isItemAvailable() )\n            return 0;\n         if ( strcmp( key, current->keys_[index] ) == 0 )\n            return &current->items_[index];\n      }\n   }\n   return 0;\n}\n\n\nValue *\nValueInternalMap::find( const char *key )\n{\n   const ValueInternalMap *constThis = this;\n   return const_cast<Value *>( constThis->find( key ) );\n}\n\n\nValue &\nValueInternalMap::resolveReference( const char *key,\n                                    bool isStatic )\n{\n   HashKey hashedKey = hash( key );\n   if ( bucketsSize_ )\n   {\n      BucketIndex bucketIndex = hashedKey % bucketsSize_;\n      ValueInternalLink **previous = 0;\n      BucketIndex index;\n      for ( ValueInternalLink *current = &buckets_[bucketIndex]; \n            current != 0; \n            previous = &current->next_, current = current->next_ )\n      {\n         for ( index=0; index < ValueInternalLink::itemPerLink; ++index )\n         {\n            if ( current->items_[index].isItemAvailable() )\n               return setNewItem( key, isStatic, current, index );\n            if ( strcmp( key, current->keys_[index] ) == 0 )\n               return current->items_[index];\n         }\n      }\n   }\n\n   reserveDelta( 1 );\n   return unsafeAdd( key, isStatic, hashedKey );\n}\n\n\nvoid \nValueInternalMap::remove( const char *key )\n{\n   HashKey hashedKey = hash( key );\n   if ( !bucketsSize_ )\n      return;\n   BucketIndex bucketIndex = hashedKey % bucketsSize_;\n   for ( ValueInternalLink *link = &buckets_[bucketIndex]; \n         link != 0; \n         link = link->next_ )\n   {\n      BucketIndex index;\n      for ( index =0; index < ValueInternalLink::itemPerLink; ++index )\n      {\n         if ( link->items_[index].isItemAvailable() )\n            return;\n         if ( strcmp( key, link->keys_[index] ) == 0 )\n         {\n            doActualRemove( link, index, bucketIndex );\n            return;\n         }\n      }\n   }\n}\n\nvoid \nValueInternalMap::doActualRemove( ValueInternalLink *link, \n                                  BucketIndex index,\n                                  BucketIndex bucketIndex )\n{\n   // find last item of the bucket and swap it with the 'removed' one.\n   // set removed items flags to 'available'.\n   // if last page only contains 'available' items, then desallocate it (it's empty)\n   ValueInternalLink *&lastLink = getLastLinkInBucket( index );\n   BucketIndex lastItemIndex = 1; // a link can never be empty, so start at 1\n   for ( ;   \n         lastItemIndex < ValueInternalLink::itemPerLink; \n         ++lastItemIndex ) // may be optimized with dicotomic search\n   {\n      if ( lastLink->items_[lastItemIndex].isItemAvailable() )\n         break;\n   }\n   \n   BucketIndex lastUsedIndex = lastItemIndex - 1;\n   Value *valueToDelete = &link->items_[index];\n   Value *valueToPreserve = &lastLink->items_[lastUsedIndex];\n   if ( valueToDelete != valueToPreserve )\n      valueToDelete->swap( *valueToPreserve );\n   if ( lastUsedIndex == 0 )  // page is now empty\n   {  // remove it from bucket linked list and delete it.\n      ValueInternalLink *linkPreviousToLast = lastLink->previous_;\n      if ( linkPreviousToLast != 0 )   // can not deleted bucket link.\n      {\n         mapAllocator()->releaseMapLink( lastLink );\n         linkPreviousToLast->next_ = 0;\n         lastLink = linkPreviousToLast;\n      }\n   }\n   else\n   {\n      Value dummy;\n      valueToPreserve->swap( dummy ); // restore deleted to default Value.\n      valueToPreserve->setItemUsed( false );\n   }\n   --itemCount_;\n}\n\n\nValueInternalLink *&\nValueInternalMap::getLastLinkInBucket( BucketIndex bucketIndex )\n{\n   if ( bucketIndex == bucketsSize_ - 1 )\n      return tailLink_;\n   ValueInternalLink *&previous = buckets_[bucketIndex+1].previous_;\n   if ( !previous )\n      previous = &buckets_[bucketIndex];\n   return previous;\n}\n\n\nValue &\nValueInternalMap::setNewItem( const char *key, \n                              bool isStatic,\n                              ValueInternalLink *link, \n                              BucketIndex index )\n{\n   char *duplicatedKey = makeMemberName( key );\n   ++itemCount_;\n   link->keys_[index] = duplicatedKey;\n   link->items_[index].setItemUsed();\n   link->items_[index].setMemberNameIsStatic( isStatic );\n   return link->items_[index]; // items already default constructed.\n}\n\n\nValue &\nValueInternalMap::unsafeAdd( const char *key, \n                             bool isStatic, \n                             HashKey hashedKey )\n{\n   JSON_ASSERT_MESSAGE( bucketsSize_ > 0, \"ValueInternalMap::unsafeAdd(): internal logic error.\" );\n   BucketIndex bucketIndex = hashedKey % bucketsSize_;\n   ValueInternalLink *&previousLink = getLastLinkInBucket( bucketIndex );\n   ValueInternalLink *link = previousLink;\n   BucketIndex index;\n   for ( index =0; index < ValueInternalLink::itemPerLink; ++index )\n   {\n      if ( link->items_[index].isItemAvailable() )\n         break;\n   }\n   if ( index == ValueInternalLink::itemPerLink ) // need to add a new page\n   {\n      ValueInternalLink *newLink = mapAllocator()->allocateMapLink();\n      index = 0;\n      link->next_ = newLink;\n      previousLink = newLink;\n      link = newLink;\n   }\n   return setNewItem( key, isStatic, link, index );\n}\n\n\nValueInternalMap::HashKey \nValueInternalMap::hash( const char *key ) const\n{\n   HashKey hash = 0;\n   while ( *key )\n      hash += *key++ * 37;\n   return hash;\n}\n\n\nint \nValueInternalMap::compare( const ValueInternalMap &other ) const\n{\n   int sizeDiff( itemCount_ - other.itemCount_ );\n   if ( sizeDiff != 0 )\n      return sizeDiff;\n   // Strict order guaranty is required. Compare all keys FIRST, then compare values.\n   IteratorState it;\n   IteratorState itEnd;\n   makeBeginIterator( it );\n   makeEndIterator( itEnd );\n   for ( ; !equals(it,itEnd); increment(it) )\n   {\n      if ( !other.find( key( it ) ) )\n         return 1;\n   }\n\n   // All keys are equals, let's compare values\n   makeBeginIterator( it );\n   for ( ; !equals(it,itEnd); increment(it) )\n   {\n      const Value *otherValue = other.find( key( it ) );\n      int valueDiff = value(it).compare( *otherValue );\n      if ( valueDiff != 0 )\n         return valueDiff;\n   }\n   return 0;\n}\n\n\nvoid \nValueInternalMap::makeBeginIterator( IteratorState &it ) const\n{\n   it.map_ = const_cast<ValueInternalMap *>( this );\n   it.bucketIndex_ = 0;\n   it.itemIndex_ = 0;\n   it.link_ = buckets_;\n}\n\n\nvoid \nValueInternalMap::makeEndIterator( IteratorState &it ) const\n{\n   it.map_ = const_cast<ValueInternalMap *>( this );\n   it.bucketIndex_ = bucketsSize_;\n   it.itemIndex_ = 0;\n   it.link_ = 0;\n}\n\n\nbool \nValueInternalMap::equals( const IteratorState &x, const IteratorState &other )\n{\n   return x.map_ == other.map_  \n          &&  x.bucketIndex_ == other.bucketIndex_  \n          &&  x.link_ == other.link_\n          &&  x.itemIndex_ == other.itemIndex_;\n}\n\n\nvoid \nValueInternalMap::incrementBucket( IteratorState &iterator )\n{\n   ++iterator.bucketIndex_;\n   JSON_ASSERT_MESSAGE( iterator.bucketIndex_ <= iterator.map_->bucketsSize_,\n      \"ValueInternalMap::increment(): attempting to iterate beyond end.\" );\n   if ( iterator.bucketIndex_ == iterator.map_->bucketsSize_ )\n      iterator.link_ = 0;\n   else\n      iterator.link_ = &(iterator.map_->buckets_[iterator.bucketIndex_]);\n   iterator.itemIndex_ = 0;\n}\n\n\nvoid \nValueInternalMap::increment( IteratorState &iterator )\n{\n   JSON_ASSERT_MESSAGE( iterator.map_, \"Attempting to iterator using invalid iterator.\" );\n   ++iterator.itemIndex_;\n   if ( iterator.itemIndex_ == ValueInternalLink::itemPerLink )\n   {\n      JSON_ASSERT_MESSAGE( iterator.link_ != 0,\n         \"ValueInternalMap::increment(): attempting to iterate beyond end.\" );\n      iterator.link_ = iterator.link_->next_;\n      if ( iterator.link_ == 0 )\n         incrementBucket( iterator );\n   }\n   else if ( iterator.link_->items_[iterator.itemIndex_].isItemAvailable() )\n   {\n      incrementBucket( iterator );\n   }\n}\n\n\nvoid \nValueInternalMap::decrement( IteratorState &iterator )\n{\n   if ( iterator.itemIndex_ == 0 )\n   {\n      JSON_ASSERT_MESSAGE( iterator.map_, \"Attempting to iterate using invalid iterator.\" );\n      if ( iterator.link_ == &iterator.map_->buckets_[iterator.bucketIndex_] )\n      {\n         JSON_ASSERT_MESSAGE( iterator.bucketIndex_ > 0, \"Attempting to iterate beyond beginning.\" );\n         --(iterator.bucketIndex_);\n      }\n      iterator.link_ = iterator.link_->previous_;\n      iterator.itemIndex_ = ValueInternalLink::itemPerLink - 1;\n   }\n}\n\n\nconst char *\nValueInternalMap::key( const IteratorState &iterator )\n{\n   JSON_ASSERT_MESSAGE( iterator.link_, \"Attempting to iterate using invalid iterator.\" );\n   return iterator.link_->keys_[iterator.itemIndex_];\n}\n\nconst char *\nValueInternalMap::key( const IteratorState &iterator, bool &isStatic )\n{\n   JSON_ASSERT_MESSAGE( iterator.link_, \"Attempting to iterate using invalid iterator.\" );\n   isStatic = iterator.link_->items_[iterator.itemIndex_].isMemberNameStatic();\n   return iterator.link_->keys_[iterator.itemIndex_];\n}\n\n\nValue &\nValueInternalMap::value( const IteratorState &iterator )\n{\n   JSON_ASSERT_MESSAGE( iterator.link_, \"Attempting to iterate using invalid iterator.\" );\n   return iterator.link_->items_[iterator.itemIndex_];\n}\n\n\nint \nValueInternalMap::distance( const IteratorState &x, const IteratorState &y )\n{\n   int offset = 0;\n   IteratorState it = x;\n   while ( !equals( it, y ) )\n      increment( it );\n   return offset;\n}\n\n} // namespace Json\n// vim: et ts=3 sts=3 sw=3 tw=0\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/json/json_tool.h",
    "content": "// Copyright 2007-2010 Baptiste Lepilleur\n// Distributed under MIT license, or public domain if desired and\n// recognized in your jurisdiction.\n// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE\n\n#ifndef LIB_JSONCPP_JSON_TOOL_H_INCLUDED\n#define LIB_JSONCPP_JSON_TOOL_H_INCLUDED\n\n/* This header provides common string manipulation support, such as UTF-8,\n * portable conversion from/to string...\n *\n * It is an internal header that must not be exposed.\n */\n\nnamespace Json {\n\n/// Converts a unicode code-point to UTF-8.\nstatic inline std::string codePointToUTF8(unsigned int cp) {\n  std::string result;\n\n  // based on description from http://en.wikipedia.org/wiki/UTF-8\n\n  if (cp <= 0x7f) {\n    result.resize(1);\n    result[0] = static_cast<char>(cp);\n  } else if (cp <= 0x7FF) {\n    result.resize(2);\n    result[1] = static_cast<char>(0x80 | (0x3f & cp));\n    result[0] = static_cast<char>(0xC0 | (0x1f & (cp >> 6)));\n  } else if (cp <= 0xFFFF) {\n    result.resize(3);\n    result[2] = static_cast<char>(0x80 | (0x3f & cp));\n    result[1] = 0x80 | static_cast<char>((0x3f & (cp >> 6)));\n    result[0] = 0xE0 | static_cast<char>((0xf & (cp >> 12)));\n  } else if (cp <= 0x10FFFF) {\n    result.resize(4);\n    result[3] = static_cast<char>(0x80 | (0x3f & cp));\n    result[2] = static_cast<char>(0x80 | (0x3f & (cp >> 6)));\n    result[1] = static_cast<char>(0x80 | (0x3f & (cp >> 12)));\n    result[0] = static_cast<char>(0xF0 | (0x7 & (cp >> 18)));\n  }\n\n  return result;\n}\n\n/// Returns true if ch is a control character (in range [0,32[).\nstatic inline bool isControlCharacter(char ch) { return ch > 0 && ch <= 0x1F; }\n\nenum {\n  /// Constant that specify the size of the buffer that must be passed to\n  /// uintToString.\n  uintToStringBufferSize = 3 * sizeof(LargestUInt) + 1\n};\n\n// Defines a char buffer for use with uintToString().\ntypedef char UIntToStringBuffer[uintToStringBufferSize];\n\n/** Converts an unsigned integer to string.\n * @param value Unsigned interger to convert to string\n * @param current Input/Output string buffer.\n *        Must have at least uintToStringBufferSize chars free.\n */\nstatic inline void uintToString(LargestUInt value, char *&current) {\n  *--current = 0;\n  do {\n    *--current = char(value % 10) + '0';\n    value /= 10;\n  } while (value != 0);\n}\n\n/** Change ',' to '.' everywhere in buffer.\n *\n * We had a sophisticated way, but it did not work in WinCE.\n * @see https://github.com/open-source-parsers/jsoncpp/pull/9\n */\nstatic inline void fixNumericLocale(char* begin, char* end) {\n  while (begin < end) {\n    if (*begin == ',') {\n      *begin = '.';\n    }\n    ++begin;\n  }\n}\n\n} // namespace Json {\n\n#endif // LIB_JSONCPP_JSON_TOOL_H_INCLUDED\n// vim: et ts=2 sts=2 sw=2 tw=0\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/json/json_valueiterator.inl",
    "content": "// Copyright 2007-2010 Baptiste Lepilleur\n// Distributed under MIT license, or public domain if desired and\n// recognized in your jurisdiction.\n// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE\n\n// included by json_value.cpp\n\nnamespace Json {\n\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// class ValueIteratorBase\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n\nValueIteratorBase::ValueIteratorBase()\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\n   : current_()\n   , isNull_( true )\n{\n}\n#else\n   : isArray_( true )\n   , isNull_( true )\n{\n   iterator_.array_ = ValueInternalArray::IteratorState();\n}\n#endif\n\n\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\nValueIteratorBase::ValueIteratorBase( const Value::ObjectValues::iterator &current )\n   : current_( current )\n   , isNull_( false )\n{\n}\n#else\nValueIteratorBase::ValueIteratorBase( const ValueInternalArray::IteratorState &state )\n   : isArray_( true )\n{\n   iterator_.array_ = state;\n}\n\n\nValueIteratorBase::ValueIteratorBase( const ValueInternalMap::IteratorState &state )\n   : isArray_( false )\n{\n   iterator_.map_ = state;\n}\n#endif\n\nValue &\nValueIteratorBase::deref() const\n{\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\n   return current_->second;\n#else\n   if ( isArray_ )\n      return ValueInternalArray::dereference( iterator_.array_ );\n   return ValueInternalMap::value( iterator_.map_ );\n#endif\n}\n\n\nvoid \nValueIteratorBase::increment()\n{\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\n   ++current_;\n#else\n   if ( isArray_ )\n      ValueInternalArray::increment( iterator_.array_ );\n   ValueInternalMap::increment( iterator_.map_ );\n#endif\n}\n\n\nvoid \nValueIteratorBase::decrement()\n{\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\n   --current_;\n#else\n   if ( isArray_ )\n      ValueInternalArray::decrement( iterator_.array_ );\n   ValueInternalMap::decrement( iterator_.map_ );\n#endif\n}\n\n\nValueIteratorBase::difference_type \nValueIteratorBase::computeDistance( const SelfType &other ) const\n{\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\n# ifdef JSON_USE_CPPTL_SMALLMAP\n   return current_ - other.current_;\n# else\n   // Iterator for null value are initialized using the default\n   // constructor, which initialize current_ to the default\n   // std::map::iterator. As begin() and end() are two instance \n   // of the default std::map::iterator, they can not be compared.\n   // To allow this, we handle this comparison specifically.\n   if ( isNull_  &&  other.isNull_ )\n   {\n      return 0;\n   }\n\n\n   // Usage of std::distance is not portable (does not compile with Sun Studio 12 RogueWave STL,\n   // which is the one used by default).\n   // Using a portable hand-made version for non random iterator instead:\n   //   return difference_type( std::distance( current_, other.current_ ) );\n   difference_type myDistance = 0;\n   for ( Value::ObjectValues::iterator it = current_; it != other.current_; ++it )\n   {\n      ++myDistance;\n   }\n   return myDistance;\n# endif\n#else\n   if ( isArray_ )\n      return ValueInternalArray::distance( iterator_.array_, other.iterator_.array_ );\n   return ValueInternalMap::distance( iterator_.map_, other.iterator_.map_ );\n#endif\n}\n\n\nbool \nValueIteratorBase::isEqual( const SelfType &other ) const\n{\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\n   if ( isNull_ )\n   {\n      return other.isNull_;\n   }\n   return current_ == other.current_;\n#else\n   if ( isArray_ )\n      return ValueInternalArray::equals( iterator_.array_, other.iterator_.array_ );\n   return ValueInternalMap::equals( iterator_.map_, other.iterator_.map_ );\n#endif\n}\n\n\nvoid \nValueIteratorBase::copy( const SelfType &other )\n{\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\n   current_ = other.current_;\n   isNull_ = other.isNull_;\n#else\n   if ( isArray_ )\n      iterator_.array_ = other.iterator_.array_;\n   iterator_.map_ = other.iterator_.map_;\n#endif\n}\n\n\nValue \nValueIteratorBase::key() const\n{\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\n   const Value::CZString czstring = (*current_).first;\n   if ( czstring.c_str() )\n   {\n      if ( czstring.isStaticString() )\n         return Value( StaticString( czstring.c_str() ) );\n      return Value( czstring.c_str() );\n   }\n   return Value( czstring.index() );\n#else\n   if ( isArray_ )\n      return Value( ValueInternalArray::indexOf( iterator_.array_ ) );\n   bool isStatic;\n   const char *memberName = ValueInternalMap::key( iterator_.map_, isStatic );\n   if ( isStatic )\n      return Value( StaticString( memberName ) );\n   return Value( memberName );\n#endif\n}\n\n\nUInt \nValueIteratorBase::index() const\n{\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\n   const Value::CZString czstring = (*current_).first;\n   if ( !czstring.c_str() )\n      return czstring.index();\n   return Value::UInt( -1 );\n#else\n   if ( isArray_ )\n      return Value::UInt( ValueInternalArray::indexOf( iterator_.array_ ) );\n   return Value::UInt( -1 );\n#endif\n}\n\n\nconst char *\nValueIteratorBase::memberName() const\n{\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\n   const char *name = (*current_).first.c_str();\n   return name ? name : \"\";\n#else\n   if ( !isArray_ )\n      return ValueInternalMap::key( iterator_.map_ );\n   return \"\";\n#endif\n}\n\n\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// class ValueConstIterator\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n\nValueConstIterator::ValueConstIterator()\n{\n}\n\n\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\nValueConstIterator::ValueConstIterator( const Value::ObjectValues::iterator &current )\n   : ValueIteratorBase( current )\n{\n}\n#else\nValueConstIterator::ValueConstIterator( const ValueInternalArray::IteratorState &state )\n   : ValueIteratorBase( state )\n{\n}\n\nValueConstIterator::ValueConstIterator( const ValueInternalMap::IteratorState &state )\n   : ValueIteratorBase( state )\n{\n}\n#endif\n\nValueConstIterator &\nValueConstIterator::operator =( const ValueIteratorBase &other )\n{\n   copy( other );\n   return *this;\n}\n\n\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// class ValueIterator\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n\nValueIterator::ValueIterator()\n{\n}\n\n\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\nValueIterator::ValueIterator( const Value::ObjectValues::iterator &current )\n   : ValueIteratorBase( current )\n{\n}\n#else\nValueIterator::ValueIterator( const ValueInternalArray::IteratorState &state )\n   : ValueIteratorBase( state )\n{\n}\n\nValueIterator::ValueIterator( const ValueInternalMap::IteratorState &state )\n   : ValueIteratorBase( state )\n{\n}\n#endif\n\nValueIterator::ValueIterator( const ValueConstIterator &other )\n   : ValueIteratorBase( other )\n{\n}\n\nValueIterator::ValueIterator( const ValueIterator &other )\n   : ValueIteratorBase( other )\n{\n}\n\nValueIterator &\nValueIterator::operator =( const SelfType &other )\n{\n   copy( other );\n   return *this;\n}\n\n} // namespace Json\n// vim: et ts=3 sts=3 sw=3 tw=0\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/json/reader.h",
    "content": "// Copyright 2007-2010 Baptiste Lepilleur\n// Distributed under MIT license, or public domain if desired and\n// recognized in your jurisdiction.\n// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE\n\n#ifndef CPPTL_JSON_READER_H_INCLUDED\n#define CPPTL_JSON_READER_H_INCLUDED\n\n#if !defined(JSON_IS_AMALGAMATION)\n#include \"features.h\"\n#include \"value.h\"\n#endif // if !defined(JSON_IS_AMALGAMATION)\n#include <deque>\n#include <iosfwd>\n#include <stack>\n#include <string>\n\n// Disable warning C4251: <data member>: <type> needs to have dll-interface to\n// be used by...\n#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)\n#pragma warning(push)\n#pragma warning(disable : 4251)\n#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)\n\nnamespace Json {\n\n/** \\brief Unserialize a <a HREF=\"http://www.json.org\">JSON</a> document into a\n *Value.\n *\n */\nclass JSON_API Reader {\npublic:\n  typedef char Char;\n  typedef const Char *Location;\n\n  /** \\brief An error tagged with where in the JSON text it was encountered.\n   *\n   * The offsets give the [start, limit) range of bytes within the text. Note\n   * that this is bytes, not codepoints.\n   *\n   */\n  struct StructuredError {\n    size_t offset_start;\n    size_t offset_limit;\n    std::string message;\n  };\n\n  /** \\brief Constructs a Reader allowing all features\n   * for parsing.\n   */\n  Reader();\n\n  /** \\brief Constructs a Reader allowing the specified feature set\n   * for parsing.\n   */\n  Reader(const Features &features);\n\n  /** \\brief Read a Value from a <a HREF=\"http://www.json.org\">JSON</a>\n   * document.\n   * \\param document UTF-8 encoded string containing the document to read.\n   * \\param root [out] Contains the root value of the document if it was\n   *             successfully parsed.\n   * \\param collectComments \\c true to collect comment and allow writing them\n   * back during\n   *                        serialization, \\c false to discard comments.\n   *                        This parameter is ignored if\n   * Features::allowComments_\n   *                        is \\c false.\n   * \\return \\c true if the document was successfully parsed, \\c false if an\n   * error occurred.\n   */\n  bool\n  parse(const std::string &document, Value &root, bool collectComments = true);\n\n  /** \\brief Read a Value from a <a HREF=\"http://www.json.org\">JSON</a>\n   document.\n   * \\param beginDoc Pointer on the beginning of the UTF-8 encoded string of the\n   document to read.\n   * \\param endDoc Pointer on the end of the UTF-8 encoded string of the\n   document to read.\n   \\               Must be >= beginDoc.\n   * \\param root [out] Contains the root value of the document if it was\n   *             successfully parsed.\n   * \\param collectComments \\c true to collect comment and allow writing them\n   back during\n   *                        serialization, \\c false to discard comments.\n   *                        This parameter is ignored if\n   Features::allowComments_\n   *                        is \\c false.\n   * \\return \\c true if the document was successfully parsed, \\c false if an\n   error occurred.\n   */\n  bool parse(const char *beginDoc,\n             const char *endDoc,\n             Value &root,\n             bool collectComments = true);\n\n  /// \\brief Parse from input stream.\n  /// \\see Json::operator>>(std::istream&, Json::Value&).\n  bool parse(std::istream &is, Value &root, bool collectComments = true);\n\n  /** \\brief Returns a user friendly string that list errors in the parsed\n   * document.\n   * \\return Formatted error message with the list of errors with their location\n   * in\n   *         the parsed document. An empty string is returned if no error\n   * occurred\n   *         during parsing.\n   * \\deprecated Use getFormattedErrorMessages() instead (typo fix).\n   */\n  JSONCPP_DEPRECATED(\"Use getFormattedErrorMessages instead\")\n  std::string getFormatedErrorMessages() const;\n\n  /** \\brief Returns a user friendly string that list errors in the parsed\n   * document.\n   * \\return Formatted error message with the list of errors with their location\n   * in\n   *         the parsed document. An empty string is returned if no error\n   * occurred\n   *         during parsing.\n   */\n  std::string getFormattedErrorMessages() const;\n\n  /** \\brief Returns a vector of structured erros encounted while parsing.\n   * \\return A (possibly empty) vector of StructuredError objects. Currently\n   *         only one error can be returned, but the caller should tolerate\n   * multiple\n   *         errors.  This can occur if the parser recovers from a non-fatal\n   *         parse error and then encounters additional errors.\n   */\n  std::vector<StructuredError> getStructuredErrors() const;\n\nprivate:\n  enum TokenType {\n    tokenEndOfStream = 0,\n    tokenObjectBegin,\n    tokenObjectEnd,\n    tokenArrayBegin,\n    tokenArrayEnd,\n    tokenString,\n    tokenNumber,\n    tokenTrue,\n    tokenFalse,\n    tokenNull,\n    tokenArraySeparator,\n    tokenMemberSeparator,\n    tokenComment,\n    tokenError\n  };\n\n  class Token {\n  public:\n    TokenType type_;\n    Location start_;\n    Location end_;\n  };\n\n  class ErrorInfo {\n  public:\n    Token token_;\n    std::string message_;\n    Location extra_;\n  };\n\n  typedef std::deque<ErrorInfo> Errors;\n\n  bool expectToken(TokenType type, Token &token, const char *message);\n  bool readToken(Token &token);\n  void skipSpaces();\n  bool match(Location pattern, int patternLength);\n  bool readComment();\n  bool readCStyleComment();\n  bool readCppStyleComment();\n  bool readString();\n  void readNumber();\n  bool readValue();\n  bool readObject(Token &token);\n  bool readArray(Token &token);\n  bool decodeNumber(Token &token);\n  bool decodeNumber(Token &token, Value &decoded);\n  bool decodeString(Token &token);\n  bool decodeString(Token &token, std::string &decoded);\n  bool decodeDouble(Token &token);\n  bool decodeDouble(Token &token, Value &decoded);\n  bool decodeUnicodeCodePoint(Token &token,\n                              Location &current,\n                              Location end,\n                              unsigned int &unicode);\n  bool decodeUnicodeEscapeSequence(Token &token,\n                                   Location &current,\n                                   Location end,\n                                   unsigned int &unicode);\n  bool addError(const std::string &message, Token &token, Location extra = 0);\n  bool recoverFromError(TokenType skipUntilToken);\n  bool addErrorAndRecover(const std::string &message,\n                          Token &token,\n                          TokenType skipUntilToken);\n  void skipUntilSpace();\n  Value &currentValue();\n  Char getNextChar();\n  void\n  getLocationLineAndColumn(Location location, int &line, int &column) const;\n  std::string getLocationLineAndColumn(Location location) const;\n  void addComment(Location begin, Location end, CommentPlacement placement);\n  void skipCommentTokens(Token &token);\n\n  typedef std::stack<Value *> Nodes;\n  Nodes nodes_;\n  Errors errors_;\n  std::string document_;\n  Location begin_;\n  Location end_;\n  Location current_;\n  Location lastValueEnd_;\n  Value *lastValue_;\n  std::string commentsBefore_;\n  Features features_;\n  bool collectComments_;\n};\n\n/** \\brief Read from 'sin' into 'root'.\n\n Always keep comments from the input JSON.\n\n This can be used to read a file into a particular sub-object.\n For example:\n \\code\n Json::Value root;\n cin >> root[\"dir\"][\"file\"];\n cout << root;\n \\endcode\n Result:\n \\verbatim\n {\n \"dir\": {\n     \"file\": {\n     // The input stream JSON would be nested here.\n     }\n }\n }\n \\endverbatim\n \\throw std::exception on parse error.\n \\see Json::operator<<()\n*/\nJSON_API std::istream &operator>>(std::istream &, Value &);\n\n} // namespace Json\n\n#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)\n#pragma warning(pop)\n#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)\n\n#endif // CPPTL_JSON_READER_H_INCLUDED\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/json/value.h",
    "content": "// Copyright 2007-2010 Baptiste Lepilleur\n// Distributed under MIT license, or public domain if desired and\n// recognized in your jurisdiction.\n// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE\n\n#ifndef CPPTL_JSON_H_INCLUDED\n#define CPPTL_JSON_H_INCLUDED\n\n#if !defined(JSON_IS_AMALGAMATION)\n#include \"forwards.h\"\n#endif // if !defined(JSON_IS_AMALGAMATION)\n#include <string>\n#include <vector>\n\n#ifndef JSON_USE_CPPTL_SMALLMAP\n#include <map>\n#else\n#include <cpptl/smallmap.h>\n#endif\n#ifdef JSON_USE_CPPTL\n#include <cpptl/forwards.h>\n#endif\n\n// Disable warning C4251: <data member>: <type> needs to have dll-interface to\n// be used by...\n#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)\n#pragma warning(push)\n#pragma warning(disable : 4251)\n#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)\n\n/** \\brief JSON (JavaScript Object Notation).\n */\nnamespace Json {\n\n/** \\brief Type of the value held by a Value object.\n */\nenum ValueType {\n  nullValue = 0, ///< 'null' value\n  intValue,      ///< signed integer value\n  uintValue,     ///< unsigned integer value\n  realValue,     ///< double value\n  stringValue,   ///< UTF-8 string value\n  booleanValue,  ///< bool value\n  arrayValue,    ///< array value (ordered list)\n  objectValue    ///< object value (collection of name/value pairs).\n};\n\nenum CommentPlacement {\n  commentBefore = 0,      ///< a comment placed on the line before a value\n  commentAfterOnSameLine, ///< a comment just after a value on the same line\n  commentAfter, ///< a comment on the line after a value (only make sense for\n  /// root value)\n  numberOfCommentPlacement\n};\n\n//# ifdef JSON_USE_CPPTL\n//   typedef CppTL::AnyEnumerator<const char *> EnumMemberNames;\n//   typedef CppTL::AnyEnumerator<const Value &> EnumValues;\n//# endif\n\n/** \\brief Lightweight wrapper to tag static string.\n *\n * Value constructor and objectValue member assignement takes advantage of the\n * StaticString and avoid the cost of string duplication when storing the\n * string or the member name.\n *\n * Example of usage:\n * \\code\n * Json::Value aValue( StaticString(\"some text\") );\n * Json::Value object;\n * static const StaticString code(\"code\");\n * object[code] = 1234;\n * \\endcode\n */\nclass JSON_API StaticString {\npublic:\n  explicit StaticString(const char *czstring) : str_(czstring) {}\n\n  operator const char *() const { return str_; }\n\n  const char *c_str() const { return str_; }\n\nprivate:\n  const char *str_;\n};\n\n/** \\brief Represents a <a HREF=\"http://www.json.org\">JSON</a> value.\n *\n * This class is a discriminated union wrapper that can represents a:\n * - signed integer [range: Value::minInt - Value::maxInt]\n * - unsigned integer (range: 0 - Value::maxUInt)\n * - double\n * - UTF-8 string\n * - boolean\n * - 'null'\n * - an ordered list of Value\n * - collection of name/value pairs (javascript object)\n *\n * The type of the held value is represented by a #ValueType and\n * can be obtained using type().\n *\n * values of an #objectValue or #arrayValue can be accessed using operator[]()\n *methods.\n * Non const methods will automatically create the a #nullValue element\n * if it does not exist.\n * The sequence of an #arrayValue will be automatically resize and initialized\n * with #nullValue. resize() can be used to enlarge or truncate an #arrayValue.\n *\n * The get() methods can be used to obtanis default value in the case the\n *required element\n * does not exist.\n *\n * It is possible to iterate over the list of a #objectValue values using\n * the getMemberNames() method.\n */\nclass JSON_API Value {\n  friend class ValueIteratorBase;\n#ifdef JSON_VALUE_USE_INTERNAL_MAP\n  friend class ValueInternalLink;\n  friend class ValueInternalMap;\n#endif\npublic:\n  typedef std::vector<std::string> Members;\n  typedef ValueIterator iterator;\n  typedef ValueConstIterator const_iterator;\n  typedef Json::UInt UInt;\n  typedef Json::Int Int;\n#if defined(JSON_HAS_INT64)\n  typedef Json::UInt64 UInt64;\n  typedef Json::Int64 Int64;\n#endif // defined(JSON_HAS_INT64)\n  typedef Json::LargestInt LargestInt;\n  typedef Json::LargestUInt LargestUInt;\n  typedef Json::ArrayIndex ArrayIndex;\n\n  static const Value& null;\n  /// Minimum signed integer value that can be stored in a Json::Value.\n  static const LargestInt minLargestInt;\n  /// Maximum signed integer value that can be stored in a Json::Value.\n  static const LargestInt maxLargestInt;\n  /// Maximum unsigned integer value that can be stored in a Json::Value.\n  static const LargestUInt maxLargestUInt;\n\n  /// Minimum signed int value that can be stored in a Json::Value.\n  static const Int minInt;\n  /// Maximum signed int value that can be stored in a Json::Value.\n  static const Int maxInt;\n  /// Maximum unsigned int value that can be stored in a Json::Value.\n  static const UInt maxUInt;\n\n#if defined(JSON_HAS_INT64)\n  /// Minimum signed 64 bits int value that can be stored in a Json::Value.\n  static const Int64 minInt64;\n  /// Maximum signed 64 bits int value that can be stored in a Json::Value.\n  static const Int64 maxInt64;\n  /// Maximum unsigned 64 bits int value that can be stored in a Json::Value.\n  static const UInt64 maxUInt64;\n#endif // defined(JSON_HAS_INT64)\n\nprivate:\n#ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\n  class CZString {\n  public:\n    enum DuplicationPolicy {\n      noDuplication = 0,\n      duplicate,\n      duplicateOnCopy\n    };\n    CZString(ArrayIndex index);\n    CZString(const char *cstr, DuplicationPolicy allocate);\n    CZString(const CZString &other);\n    ~CZString();\n    CZString &operator=(CZString other);\n    bool operator<(const CZString &other) const;\n    bool operator==(const CZString &other) const;\n    ArrayIndex index() const;\n    const char *c_str() const;\n    bool isStaticString() const;\n\n  private:\n    void swap(CZString &other);\n    const char *cstr_;\n    ArrayIndex index_;\n  };\n\npublic:\n#ifndef JSON_USE_CPPTL_SMALLMAP\n  typedef std::map<CZString, Value> ObjectValues;\n#else\n  typedef CppTL::SmallMap<CZString, Value> ObjectValues;\n#endif // ifndef JSON_USE_CPPTL_SMALLMAP\n#endif // ifndef JSON_VALUE_USE_INTERNAL_MAP\n#endif // ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION\n\npublic:\n  /** \\brief Create a default Value of the given type.\n\n    This is a very useful constructor.\n    To create an empty array, pass arrayValue.\n    To create an empty object, pass objectValue.\n    Another Value can then be set to this one by assignment.\nThis is useful since clear() and resize() will not alter types.\n\n    Examples:\n\\code\nJson::Value null_value; // null\nJson::Value arr_value(Json::arrayValue); // []\nJson::Value obj_value(Json::objectValue); // {}\n\\endcode\n  */\n  Value(ValueType type = nullValue);\n  Value(Int value);\n  Value(UInt value);\n#if defined(JSON_HAS_INT64)\n  Value(Int64 value);\n  Value(UInt64 value);\n#endif // if defined(JSON_HAS_INT64)\n  Value(double value);\n  Value(const char *value);\n  Value(const char *beginValue, const char *endValue);\n  /** \\brief Constructs a value from a static string.\n\n   * Like other value string constructor but do not duplicate the string for\n   * internal storage. The given string must remain alive after the call to this\n   * constructor.\n   * Example of usage:\n   * \\code\n   * Json::Value aValue( StaticString(\"some text\") );\n   * \\endcode\n   */\n  Value(const StaticString &value);\n  Value(const std::string &value);\n#ifdef JSON_USE_CPPTL\n  Value(const CppTL::ConstString &value);\n#endif\n  Value(bool value);\n  Value(const Value &other);\n  ~Value();\n\n  Value &operator=(Value other);\n  /// Swap values.\n  /// \\note Currently, comments are intentionally not swapped, for\n  /// both logic and efficiency.\n  void swap(Value &other);\n\n  ValueType type() const;\n\n  bool operator<(const Value &other) const;\n  bool operator<=(const Value &other) const;\n  bool operator>=(const Value &other) const;\n  bool operator>(const Value &other) const;\n\n  bool operator==(const Value &other) const;\n  bool operator!=(const Value &other) const;\n\n  int compare(const Value &other) const;\n\n  const char *asCString() const;\n  std::string asString() const;\n#ifdef JSON_USE_CPPTL\n  CppTL::ConstString asConstString() const;\n#endif\n  Int asInt() const;\n  UInt asUInt() const;\n#if defined(JSON_HAS_INT64)\n  Int64 asInt64() const;\n  UInt64 asUInt64() const;\n#endif // if defined(JSON_HAS_INT64)\n  LargestInt asLargestInt() const;\n  LargestUInt asLargestUInt() const;\n  float asFloat() const;\n  double asDouble() const;\n  bool asBool() const;\n\n  bool isNull() const;\n  bool isBool() const;\n  bool isInt() const;\n  bool isInt64() const;\n  bool isUInt() const;\n  bool isUInt64() const;\n  bool isIntegral() const;\n  bool isDouble() const;\n  bool isNumeric() const;\n  bool isString() const;\n  bool isArray() const;\n  bool isObject() const;\n\n  bool isConvertibleTo(ValueType other) const;\n\n  /// Number of values in array or object\n  ArrayIndex size() const;\n\n  /// \\brief Return true if empty array, empty object, or null;\n  /// otherwise, false.\n  bool empty() const;\n\n  /// Return isNull()\n  bool operator!() const;\n\n  /// Remove all object members and array elements.\n  /// \\pre type() is arrayValue, objectValue, or nullValue\n  /// \\post type() is unchanged\n  void clear();\n\n  /// Resize the array to size elements.\n  /// New elements are initialized to null.\n  /// May only be called on nullValue or arrayValue.\n  /// \\pre type() is arrayValue or nullValue\n  /// \\post type() is arrayValue\n  void resize(ArrayIndex size);\n\n  /// Access an array element (zero based index ).\n  /// If the array contains less than index element, then null value are\n  /// inserted\n  /// in the array so that its size is index+1.\n  /// (You may need to say 'value[0u]' to get your compiler to distinguish\n  ///  this from the operator[] which takes a string.)\n  Value &operator[](ArrayIndex index);\n\n  /// Access an array element (zero based index ).\n  /// If the array contains less than index element, then null value are\n  /// inserted\n  /// in the array so that its size is index+1.\n  /// (You may need to say 'value[0u]' to get your compiler to distinguish\n  ///  this from the operator[] which takes a string.)\n  Value &operator[](int index);\n\n  /// Access an array element (zero based index )\n  /// (You may need to say 'value[0u]' to get your compiler to distinguish\n  ///  this from the operator[] which takes a string.)\n  const Value &operator[](ArrayIndex index) const;\n\n  /// Access an array element (zero based index )\n  /// (You may need to say 'value[0u]' to get your compiler to distinguish\n  ///  this from the operator[] which takes a string.)\n  const Value &operator[](int index) const;\n\n  /// If the array contains at least index+1 elements, returns the element\n  /// value,\n  /// otherwise returns defaultValue.\n  Value get(ArrayIndex index, const Value &defaultValue) const;\n  /// Return true if index < size().\n  bool isValidIndex(ArrayIndex index) const;\n  /// \\brief Append value to array at the end.\n  ///\n  /// Equivalent to jsonvalue[jsonvalue.size()] = value;\n  Value &append(const Value &value);\n\n  /// Access an object value by name, create a null member if it does not exist.\n  Value &operator[](const char *key);\n  /// Access an object value by name, returns null if there is no member with\n  /// that name.\n  const Value &operator[](const char *key) const;\n  /// Access an object value by name, create a null member if it does not exist.\n  Value &operator[](const std::string &key);\n  /// Access an object value by name, returns null if there is no member with\n  /// that name.\n  const Value &operator[](const std::string &key) const;\n  /** \\brief Access an object value by name, create a null member if it does not\n   exist.\n\n   * If the object as no entry for that name, then the member name used to store\n   * the new entry is not duplicated.\n   * Example of use:\n   * \\code\n   * Json::Value object;\n   * static const StaticString code(\"code\");\n   * object[code] = 1234;\n   * \\endcode\n   */\n  Value &operator[](const StaticString &key);\n#ifdef JSON_USE_CPPTL\n  /// Access an object value by name, create a null member if it does not exist.\n  Value &operator[](const CppTL::ConstString &key);\n  /// Access an object value by name, returns null if there is no member with\n  /// that name.\n  const Value &operator[](const CppTL::ConstString &key) const;\n#endif\n  /// Return the member named key if it exist, defaultValue otherwise.\n  Value get(const char *key, const Value &defaultValue) const;\n  /// Return the member named key if it exist, defaultValue otherwise.\n  Value get(const std::string &key, const Value &defaultValue) const;\n#ifdef JSON_USE_CPPTL\n  /// Return the member named key if it exist, defaultValue otherwise.\n  Value get(const CppTL::ConstString &key, const Value &defaultValue) const;\n#endif\n  /// \\brief Remove and return the named member.\n  ///\n  /// Do nothing if it did not exist.\n  /// \\return the removed Value, or null.\n  /// \\pre type() is objectValue or nullValue\n  /// \\post type() is unchanged\n  Value removeMember(const char *key);\n  /// Same as removeMember(const char*)\n  Value removeMember(const std::string &key);\n\n  /// Return true if the object has a member named key.\n  bool isMember(const char *key) const;\n  /// Return true if the object has a member named key.\n  bool isMember(const std::string &key) const;\n#ifdef JSON_USE_CPPTL\n  /// Return true if the object has a member named key.\n  bool isMember(const CppTL::ConstString &key) const;\n#endif\n\n  /// \\brief Return a list of the member names.\n  ///\n  /// If null, return an empty list.\n  /// \\pre type() is objectValue or nullValue\n  /// \\post if type() was nullValue, it remains nullValue\n  Members getMemberNames() const;\n\n  //# ifdef JSON_USE_CPPTL\n  //      EnumMemberNames enumMemberNames() const;\n  //      EnumValues enumValues() const;\n  //# endif\n\n  /// Comments must be //... or /* ... */\n  void setComment(const char *comment, CommentPlacement placement);\n  /// Comments must be //... or /* ... */\n  void setComment(const std::string &comment, CommentPlacement placement);\n  bool hasComment(CommentPlacement placement) const;\n  /// Include delimiters and embedded newlines.\n  std::string getComment(CommentPlacement placement) const;\n\n  std::string toStyledString() const;\n\n  const_iterator begin() const;\n  const_iterator end() const;\n\n  iterator begin();\n  iterator end();\n\n  // Accessors for the [start, limit) range of bytes within the JSON text from\n  // which this value was parsed, if any.\n  void setOffsetStart(size_t start);\n  void setOffsetLimit(size_t limit);\n  size_t getOffsetStart() const;\n  size_t getOffsetLimit() const;\n\nprivate:\n  Value &resolveReference(const char *key, bool isStatic);\n\n#ifdef JSON_VALUE_USE_INTERNAL_MAP\n  inline bool isItemAvailable() const { return itemIsUsed_ == 0; }\n\n  inline void setItemUsed(bool isUsed = true) { itemIsUsed_ = isUsed ? 1 : 0; }\n\n  inline bool isMemberNameStatic() const { return memberNameIsStatic_ == 0; }\n\n  inline void setMemberNameIsStatic(bool isStatic) {\n    memberNameIsStatic_ = isStatic ? 1 : 0;\n  }\n#endif // # ifdef JSON_VALUE_USE_INTERNAL_MAP\n\nprivate:\n  struct CommentInfo {\n    CommentInfo();\n    ~CommentInfo();\n\n    void setComment(const char *text);\n\n    char *comment_;\n  };\n\n  // struct MemberNamesTransform\n  //{\n  //   typedef const char *result_type;\n  //   const char *operator()( const CZString &name ) const\n  //   {\n  //      return name.c_str();\n  //   }\n  //};\n\n  union ValueHolder {\n    LargestInt int_;\n    LargestUInt uint_;\n    double real_;\n    bool bool_;\n    char *string_;\n#ifdef JSON_VALUE_USE_INTERNAL_MAP\n    ValueInternalArray *array_;\n    ValueInternalMap *map_;\n#else\n    ObjectValues *map_;\n#endif\n  } value_;\n  ValueType type_ : 8;\n  int allocated_ : 1; // Notes: if declared as bool, bitfield is useless.\n#ifdef JSON_VALUE_USE_INTERNAL_MAP\n  unsigned int itemIsUsed_ : 1; // used by the ValueInternalMap container.\n  int memberNameIsStatic_ : 1;  // used by the ValueInternalMap container.\n#endif\n  CommentInfo *comments_;\n\n  // [start, limit) byte offsets in the source JSON text from which this Value\n  // was extracted.\n  size_t start_;\n  size_t limit_;\n};\n\n/** \\brief Experimental and untested: represents an element of the \"path\" to\n * access a node.\n */\nclass JSON_API PathArgument {\npublic:\n  friend class Path;\n\n  PathArgument();\n  PathArgument(ArrayIndex index);\n  PathArgument(const char *key);\n  PathArgument(const std::string &key);\n\nprivate:\n  enum Kind {\n    kindNone = 0,\n    kindIndex,\n    kindKey\n  };\n  std::string key_;\n  ArrayIndex index_;\n  Kind kind_;\n};\n\n/** \\brief Experimental and untested: represents a \"path\" to access a node.\n *\n * Syntax:\n * - \".\" => root node\n * - \".[n]\" => elements at index 'n' of root node (an array value)\n * - \".name\" => member named 'name' of root node (an object value)\n * - \".name1.name2.name3\"\n * - \".[0][1][2].name1[3]\"\n * - \".%\" => member name is provided as parameter\n * - \".[%]\" => index is provied as parameter\n */\nclass JSON_API Path {\npublic:\n  Path(const std::string &path,\n       const PathArgument &a1 = PathArgument(),\n       const PathArgument &a2 = PathArgument(),\n       const PathArgument &a3 = PathArgument(),\n       const PathArgument &a4 = PathArgument(),\n       const PathArgument &a5 = PathArgument());\n\n  const Value &resolve(const Value &root) const;\n  Value resolve(const Value &root, const Value &defaultValue) const;\n  /// Creates the \"path\" to access the specified node and returns a reference on\n  /// the node.\n  Value &make(Value &root) const;\n\nprivate:\n  typedef std::vector<const PathArgument *> InArgs;\n  typedef std::vector<PathArgument> Args;\n\n  void makePath(const std::string &path, const InArgs &in);\n  void addPathInArg(const std::string &path,\n                    const InArgs &in,\n                    InArgs::const_iterator &itInArg,\n                    PathArgument::Kind kind);\n  void invalidPath(const std::string &path, int location);\n\n  Args args_;\n};\n\n#ifdef JSON_VALUE_USE_INTERNAL_MAP\n/** \\brief Allocator to customize Value internal map.\n * Below is an example of a simple implementation (default implementation\n actually\n * use memory pool for speed).\n * \\code\n   class DefaultValueMapAllocator : public ValueMapAllocator\n   {\n   public: // overridden from ValueMapAllocator\n      virtual ValueInternalMap *newMap()\n      {\n         return new ValueInternalMap();\n      }\n\n      virtual ValueInternalMap *newMapCopy( const ValueInternalMap &other )\n      {\n         return new ValueInternalMap( other );\n      }\n\n      virtual void destructMap( ValueInternalMap *map )\n      {\n         delete map;\n      }\n\n      virtual ValueInternalLink *allocateMapBuckets( unsigned int size )\n      {\n         return new ValueInternalLink[size];\n      }\n\n      virtual void releaseMapBuckets( ValueInternalLink *links )\n      {\n         delete [] links;\n      }\n\n      virtual ValueInternalLink *allocateMapLink()\n      {\n         return new ValueInternalLink();\n      }\n\n      virtual void releaseMapLink( ValueInternalLink *link )\n      {\n         delete link;\n      }\n   };\n * \\endcode\n */\nclass JSON_API ValueMapAllocator {\npublic:\n  virtual ~ValueMapAllocator();\n  virtual ValueInternalMap *newMap() = 0;\n  virtual ValueInternalMap *newMapCopy(const ValueInternalMap &other) = 0;\n  virtual void destructMap(ValueInternalMap *map) = 0;\n  virtual ValueInternalLink *allocateMapBuckets(unsigned int size) = 0;\n  virtual void releaseMapBuckets(ValueInternalLink *links) = 0;\n  virtual ValueInternalLink *allocateMapLink() = 0;\n  virtual void releaseMapLink(ValueInternalLink *link) = 0;\n};\n\n/** \\brief ValueInternalMap hash-map bucket chain link (for internal use only).\n * \\internal previous_ & next_ allows for bidirectional traversal.\n */\nclass JSON_API ValueInternalLink {\npublic:\n  enum {\n    itemPerLink = 6\n  }; // sizeof(ValueInternalLink) = 128 on 32 bits architecture.\n  enum InternalFlags {\n    flagAvailable = 0,\n    flagUsed = 1\n  };\n\n  ValueInternalLink();\n\n  ~ValueInternalLink();\n\n  Value items_[itemPerLink];\n  char *keys_[itemPerLink];\n  ValueInternalLink *previous_;\n  ValueInternalLink *next_;\n};\n\n/** \\brief A linked page based hash-table implementation used internally by\n *Value.\n * \\internal ValueInternalMap is a tradional bucket based hash-table, with a\n *linked\n * list in each bucket to handle collision. There is an addional twist in that\n * each node of the collision linked list is a page containing a fixed amount of\n * value. This provides a better compromise between memory usage and speed.\n *\n * Each bucket is made up of a chained list of ValueInternalLink. The last\n * link of a given bucket can be found in the 'previous_' field of the following\n *bucket.\n * The last link of the last bucket is stored in tailLink_ as it has no\n *following bucket.\n * Only the last link of a bucket may contains 'available' item. The last link\n *always\n * contains at least one element unless is it the bucket one very first link.\n */\nclass JSON_API ValueInternalMap {\n  friend class ValueIteratorBase;\n  friend class Value;\n\npublic:\n  typedef unsigned int HashKey;\n  typedef unsigned int BucketIndex;\n\n#ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION\n  struct IteratorState {\n    IteratorState() : map_(0), link_(0), itemIndex_(0), bucketIndex_(0) {}\n    ValueInternalMap *map_;\n    ValueInternalLink *link_;\n    BucketIndex itemIndex_;\n    BucketIndex bucketIndex_;\n  };\n#endif // ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION\n\n  ValueInternalMap();\n  ValueInternalMap(const ValueInternalMap &other);\n  ValueInternalMap &operator=(ValueInternalMap other);\n  ~ValueInternalMap();\n\n  void swap(ValueInternalMap &other);\n\n  BucketIndex size() const;\n\n  void clear();\n\n  bool reserveDelta(BucketIndex growth);\n\n  bool reserve(BucketIndex newItemCount);\n\n  const Value *find(const char *key) const;\n\n  Value *find(const char *key);\n\n  Value &resolveReference(const char *key, bool isStatic);\n\n  void remove(const char *key);\n\n  void doActualRemove(ValueInternalLink *link,\n                      BucketIndex index,\n                      BucketIndex bucketIndex);\n\n  ValueInternalLink *&getLastLinkInBucket(BucketIndex bucketIndex);\n\n  Value &setNewItem(const char *key,\n                    bool isStatic,\n                    ValueInternalLink *link,\n                    BucketIndex index);\n\n  Value &unsafeAdd(const char *key, bool isStatic, HashKey hashedKey);\n\n  HashKey hash(const char *key) const;\n\n  int compare(const ValueInternalMap &other) const;\n\nprivate:\n  void makeBeginIterator(IteratorState &it) const;\n  void makeEndIterator(IteratorState &it) const;\n  static bool equals(const IteratorState &x, const IteratorState &other);\n  static void increment(IteratorState &iterator);\n  static void incrementBucket(IteratorState &iterator);\n  static void decrement(IteratorState &iterator);\n  static const char *key(const IteratorState &iterator);\n  static const char *key(const IteratorState &iterator, bool &isStatic);\n  static Value &value(const IteratorState &iterator);\n  static int distance(const IteratorState &x, const IteratorState &y);\n\nprivate:\n  ValueInternalLink *buckets_;\n  ValueInternalLink *tailLink_;\n  BucketIndex bucketsSize_;\n  BucketIndex itemCount_;\n};\n\n/** \\brief A simplified deque implementation used internally by Value.\n* \\internal\n* It is based on a list of fixed \"page\", each page contains a fixed number of\n*items.\n* Instead of using a linked-list, a array of pointer is used for fast item\n*look-up.\n* Look-up for an element is as follow:\n* - compute page index: pageIndex = itemIndex / itemsPerPage\n* - look-up item in page: pages_[pageIndex][itemIndex % itemsPerPage]\n*\n* Insertion is amortized constant time (only the array containing the index of\n*pointers\n* need to be reallocated when items are appended).\n*/\nclass JSON_API ValueInternalArray {\n  friend class Value;\n  friend class ValueIteratorBase;\n\npublic:\n  enum {\n    itemsPerPage = 8\n  }; // should be a power of 2 for fast divide and modulo.\n  typedef Value::ArrayIndex ArrayIndex;\n  typedef unsigned int PageIndex;\n\n#ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION\n  struct IteratorState // Must be a POD\n      {\n    IteratorState() : array_(0), currentPageIndex_(0), currentItemIndex_(0) {}\n    ValueInternalArray *array_;\n    Value **currentPageIndex_;\n    unsigned int currentItemIndex_;\n  };\n#endif // ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION\n\n  ValueInternalArray();\n  ValueInternalArray(const ValueInternalArray &other);\n  ValueInternalArray &operator=(ValueInternalArray other);\n  ~ValueInternalArray();\n  void swap(ValueInternalArray &other);\n\n  void clear();\n  void resize(ArrayIndex newSize);\n\n  Value &resolveReference(ArrayIndex index);\n\n  Value *find(ArrayIndex index) const;\n\n  ArrayIndex size() const;\n\n  int compare(const ValueInternalArray &other) const;\n\nprivate:\n  static bool equals(const IteratorState &x, const IteratorState &other);\n  static void increment(IteratorState &iterator);\n  static void decrement(IteratorState &iterator);\n  static Value &dereference(const IteratorState &iterator);\n  static Value &unsafeDereference(const IteratorState &iterator);\n  static int distance(const IteratorState &x, const IteratorState &y);\n  static ArrayIndex indexOf(const IteratorState &iterator);\n  void makeBeginIterator(IteratorState &it) const;\n  void makeEndIterator(IteratorState &it) const;\n  void makeIterator(IteratorState &it, ArrayIndex index) const;\n\n  void makeIndexValid(ArrayIndex index);\n\n  Value **pages_;\n  ArrayIndex size_;\n  PageIndex pageCount_;\n};\n\n/** \\brief Experimental: do not use. Allocator to customize Value internal\narray.\n * Below is an example of a simple implementation (actual implementation use\n * memory pool).\n   \\code\nclass DefaultValueArrayAllocator : public ValueArrayAllocator\n{\npublic: // overridden from ValueArrayAllocator\nvirtual ~DefaultValueArrayAllocator()\n{\n}\n\nvirtual ValueInternalArray *newArray()\n{\n   return new ValueInternalArray();\n}\n\nvirtual ValueInternalArray *newArrayCopy( const ValueInternalArray &other )\n{\n   return new ValueInternalArray( other );\n}\n\nvirtual void destruct( ValueInternalArray *array )\n{\n   delete array;\n}\n\nvirtual void reallocateArrayPageIndex( Value **&indexes,\n                                       ValueInternalArray::PageIndex\n&indexCount,\n                                       ValueInternalArray::PageIndex\nminNewIndexCount )\n{\n   ValueInternalArray::PageIndex newIndexCount = (indexCount*3)/2 + 1;\n   if ( minNewIndexCount > newIndexCount )\n      newIndexCount = minNewIndexCount;\n   void *newIndexes = realloc( indexes, sizeof(Value*) * newIndexCount );\n   if ( !newIndexes )\n      throw std::bad_alloc();\n   indexCount = newIndexCount;\n   indexes = static_cast<Value **>( newIndexes );\n}\nvirtual void releaseArrayPageIndex( Value **indexes,\n                                    ValueInternalArray::PageIndex indexCount )\n{\n   if ( indexes )\n      free( indexes );\n}\n\nvirtual Value *allocateArrayPage()\n{\n   return static_cast<Value *>( malloc( sizeof(Value) *\nValueInternalArray::itemsPerPage ) );\n}\n\nvirtual void releaseArrayPage( Value *value )\n{\n   if ( value )\n      free( value );\n}\n};\n   \\endcode\n */\nclass JSON_API ValueArrayAllocator {\npublic:\n  virtual ~ValueArrayAllocator();\n  virtual ValueInternalArray *newArray() = 0;\n  virtual ValueInternalArray *newArrayCopy(const ValueInternalArray &other) = 0;\n  virtual void destructArray(ValueInternalArray *array) = 0;\n  /** \\brief Reallocate array page index.\n   * Reallocates an array of pointer on each page.\n   * \\param indexes [input] pointer on the current index. May be \\c NULL.\n   *                [output] pointer on the new index of at least\n   *                         \\a minNewIndexCount pages.\n   * \\param indexCount [input] current number of pages in the index.\n   *                   [output] number of page the reallocated index can handle.\n   *                            \\b MUST be >= \\a minNewIndexCount.\n   * \\param minNewIndexCount Minimum number of page the new index must be able\n   * to\n   *                         handle.\n   */\n  virtual void\n  reallocateArrayPageIndex(Value **&indexes,\n                           ValueInternalArray::PageIndex &indexCount,\n                           ValueInternalArray::PageIndex minNewIndexCount) = 0;\n  virtual void\n  releaseArrayPageIndex(Value **indexes,\n                        ValueInternalArray::PageIndex indexCount) = 0;\n  virtual Value *allocateArrayPage() = 0;\n  virtual void releaseArrayPage(Value *value) = 0;\n};\n#endif // #ifdef JSON_VALUE_USE_INTERNAL_MAP\n\n/** \\brief base class for Value iterators.\n *\n */\nclass JSON_API ValueIteratorBase {\npublic:\n  typedef std::bidirectional_iterator_tag iterator_category;\n  typedef unsigned int size_t;\n  typedef int difference_type;\n  typedef ValueIteratorBase SelfType;\n\n  ValueIteratorBase();\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\n  explicit ValueIteratorBase(const Value::ObjectValues::iterator &current);\n#else\n  ValueIteratorBase(const ValueInternalArray::IteratorState &state);\n  ValueIteratorBase(const ValueInternalMap::IteratorState &state);\n#endif\n\n  bool operator==(const SelfType &other) const { return isEqual(other); }\n\n  bool operator!=(const SelfType &other) const { return !isEqual(other); }\n\n  difference_type operator-(const SelfType &other) const {\n    return computeDistance(other);\n  }\n\n  /// Return either the index or the member name of the referenced value as a\n  /// Value.\n  Value key() const;\n\n  /// Return the index of the referenced Value. -1 if it is not an arrayValue.\n  UInt index() const;\n\n  /// Return the member name of the referenced Value. \"\" if it is not an\n  /// objectValue.\n  const char *memberName() const;\n\nprotected:\n  Value &deref() const;\n\n  void increment();\n\n  void decrement();\n\n  difference_type computeDistance(const SelfType &other) const;\n\n  bool isEqual(const SelfType &other) const;\n\n  void copy(const SelfType &other);\n\nprivate:\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\n  Value::ObjectValues::iterator current_;\n  // Indicates that iterator is for a null value.\n  bool isNull_;\n#else\n  union {\n    ValueInternalArray::IteratorState array_;\n    ValueInternalMap::IteratorState map_;\n  } iterator_;\n  bool isArray_;\n#endif\n};\n\n/** \\brief const iterator for object and array value.\n *\n */\nclass JSON_API ValueConstIterator : public ValueIteratorBase {\n  friend class Value;\n\npublic:\n  typedef const Value value_type;\n  typedef unsigned int size_t;\n  typedef int difference_type;\n  typedef const Value &reference;\n  typedef const Value *pointer;\n  typedef ValueConstIterator SelfType;\n\n  ValueConstIterator();\n\nprivate:\n/*! \\internal Use by Value to create an iterator.\n */\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\n  explicit ValueConstIterator(const Value::ObjectValues::iterator &current);\n#else\n  ValueConstIterator(const ValueInternalArray::IteratorState &state);\n  ValueConstIterator(const ValueInternalMap::IteratorState &state);\n#endif\npublic:\n  SelfType &operator=(const ValueIteratorBase &other);\n\n  SelfType operator++(int) {\n    SelfType temp(*this);\n    ++*this;\n    return temp;\n  }\n\n  SelfType operator--(int) {\n    SelfType temp(*this);\n    --*this;\n    return temp;\n  }\n\n  SelfType &operator--() {\n    decrement();\n    return *this;\n  }\n\n  SelfType &operator++() {\n    increment();\n    return *this;\n  }\n\n  reference operator*() const { return deref(); }\n};\n\n/** \\brief Iterator for object and array value.\n */\nclass JSON_API ValueIterator : public ValueIteratorBase {\n  friend class Value;\n\npublic:\n  typedef Value value_type;\n  typedef unsigned int size_t;\n  typedef int difference_type;\n  typedef Value &reference;\n  typedef Value *pointer;\n  typedef ValueIterator SelfType;\n\n  ValueIterator();\n  ValueIterator(const ValueConstIterator &other);\n  ValueIterator(const ValueIterator &other);\n\nprivate:\n/*! \\internal Use by Value to create an iterator.\n */\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\n  explicit ValueIterator(const Value::ObjectValues::iterator &current);\n#else\n  ValueIterator(const ValueInternalArray::IteratorState &state);\n  ValueIterator(const ValueInternalMap::IteratorState &state);\n#endif\npublic:\n  SelfType &operator=(const SelfType &other);\n\n  SelfType operator++(int) {\n    SelfType temp(*this);\n    ++*this;\n    return temp;\n  }\n\n  SelfType operator--(int) {\n    SelfType temp(*this);\n    --*this;\n    return temp;\n  }\n\n  SelfType &operator--() {\n    decrement();\n    return *this;\n  }\n\n  SelfType &operator++() {\n    increment();\n    return *this;\n  }\n\n  reference operator*() const { return deref(); }\n};\n\n} // namespace Json\n\n#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)\n#pragma warning(pop)\n#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)\n\n#endif // CPPTL_JSON_H_INCLUDED\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/json/writer.h",
    "content": "// Copyright 2007-2010 Baptiste Lepilleur\n// Distributed under MIT license, or public domain if desired and\n// recognized in your jurisdiction.\n// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE\n\n#ifndef JSON_WRITER_H_INCLUDED\n#define JSON_WRITER_H_INCLUDED\n\n#if !defined(JSON_IS_AMALGAMATION)\n#include \"value.h\"\n#endif // if !defined(JSON_IS_AMALGAMATION)\n#include <vector>\n#include <string>\n\n// Disable warning C4251: <data member>: <type> needs to have dll-interface to\n// be used by...\n#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)\n#pragma warning(push)\n#pragma warning(disable : 4251)\n#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)\n\nnamespace Json {\n\nclass Value;\n\n/** \\brief Abstract class for writers.\n */\nclass JSON_API Writer {\npublic:\n  virtual ~Writer();\n\n  virtual std::string write(const Value &root) = 0;\n};\n\n/** \\brief Outputs a Value in <a HREF=\"http://www.json.org\">JSON</a> format\n *without formatting (not human friendly).\n *\n * The JSON document is written in a single line. It is not intended for 'human'\n *consumption,\n * but may be usefull to support feature such as RPC where bandwith is limited.\n * \\sa Reader, Value\n */\nclass JSON_API FastWriter : public Writer {\npublic:\n  FastWriter();\n  virtual ~FastWriter() {}\n\n  void enableYAMLCompatibility();\n\n  /** \\brief Drop the \"null\" string from the writer's output for nullValues.\n   * Strictly speaking, this is not valid JSON. But when the output is being\n   * fed to a browser's Javascript, it makes for smaller output and the\n   * browser can handle the output just fine.\n   */\n  void dropNullPlaceholders();\n\n  void omitEndingLineFeed();\n\npublic: // overridden from Writer\n  virtual std::string write(const Value &root);\n\nprivate:\n  void writeValue(const Value &value);\n\n  std::string document_;\n  bool yamlCompatiblityEnabled_;\n  bool dropNullPlaceholders_;\n  bool omitEndingLineFeed_;\n};\n\n/** \\brief Writes a Value in <a HREF=\"http://www.json.org\">JSON</a> format in a\n *human friendly way.\n *\n * The rules for line break and indent are as follow:\n * - Object value:\n *     - if empty then print {} without indent and line break\n *     - if not empty the print '{', line break & indent, print one value per\n *line\n *       and then unindent and line break and print '}'.\n * - Array value:\n *     - if empty then print [] without indent and line break\n *     - if the array contains no object value, empty array or some other value\n *types,\n *       and all the values fit on one lines, then print the array on a single\n *line.\n *     - otherwise, it the values do not fit on one line, or the array contains\n *       object or non empty array, then print one value per line.\n *\n * If the Value have comments then they are outputed according to their\n *#CommentPlacement.\n *\n * \\sa Reader, Value, Value::setComment()\n */\nclass JSON_API StyledWriter : public Writer {\npublic:\n  StyledWriter();\n  virtual ~StyledWriter() {}\n\npublic: // overridden from Writer\n  /** \\brief Serialize a Value in <a HREF=\"http://www.json.org\">JSON</a> format.\n   * \\param root Value to serialize.\n   * \\return String containing the JSON document that represents the root value.\n   */\n  virtual std::string write(const Value &root);\n\nprivate:\n  void writeValue(const Value &value);\n  void writeArrayValue(const Value &value);\n  bool isMultineArray(const Value &value);\n  void pushValue(const std::string &value);\n  void writeIndent();\n  void writeWithIndent(const std::string &value);\n  void indent();\n  void unindent();\n  void writeCommentBeforeValue(const Value &root);\n  void writeCommentAfterValueOnSameLine(const Value &root);\n  bool hasCommentForValue(const Value &value);\n  static std::string normalizeEOL(const std::string &text);\n\n  typedef std::vector<std::string> ChildValues;\n\n  ChildValues childValues_;\n  std::string document_;\n  std::string indentString_;\n  int rightMargin_;\n  int indentSize_;\n  bool addChildValues_;\n};\n\n/** \\brief Writes a Value in <a HREF=\"http://www.json.org\">JSON</a> format in a\n human friendly way,\n     to a stream rather than to a string.\n *\n * The rules for line break and indent are as follow:\n * - Object value:\n *     - if empty then print {} without indent and line break\n *     - if not empty the print '{', line break & indent, print one value per\n line\n *       and then unindent and line break and print '}'.\n * - Array value:\n *     - if empty then print [] without indent and line break\n *     - if the array contains no object value, empty array or some other value\n types,\n *       and all the values fit on one lines, then print the array on a single\n line.\n *     - otherwise, it the values do not fit on one line, or the array contains\n *       object or non empty array, then print one value per line.\n *\n * If the Value have comments then they are outputed according to their\n #CommentPlacement.\n *\n * \\param indentation Each level will be indented by this amount extra.\n * \\sa Reader, Value, Value::setComment()\n */\nclass JSON_API StyledStreamWriter {\npublic:\n  StyledStreamWriter(std::string indentation = \"\\t\");\n  ~StyledStreamWriter() {}\n\npublic:\n  /** \\brief Serialize a Value in <a HREF=\"http://www.json.org\">JSON</a> format.\n   * \\param out Stream to write to. (Can be ostringstream, e.g.)\n   * \\param root Value to serialize.\n   * \\note There is no point in deriving from Writer, since write() should not\n   * return a value.\n   */\n  void write(std::ostream &out, const Value &root);\n\nprivate:\n  void writeValue(const Value &value);\n  void writeArrayValue(const Value &value);\n  bool isMultineArray(const Value &value);\n  void pushValue(const std::string &value);\n  void writeIndent();\n  void writeWithIndent(const std::string &value);\n  void indent();\n  void unindent();\n  void writeCommentBeforeValue(const Value &root);\n  void writeCommentAfterValueOnSameLine(const Value &root);\n  bool hasCommentForValue(const Value &value);\n  static std::string normalizeEOL(const std::string &text);\n\n  typedef std::vector<std::string> ChildValues;\n\n  ChildValues childValues_;\n  std::ostream *document_;\n  std::string indentString_;\n  int rightMargin_;\n  std::string indentation_;\n  bool addChildValues_;\n};\n\n#if defined(JSON_HAS_INT64)\nstd::string JSON_API valueToString(Int value);\nstd::string JSON_API valueToString(UInt value);\n#endif // if defined(JSON_HAS_INT64)\nstd::string JSON_API valueToString(LargestInt value);\nstd::string JSON_API valueToString(LargestUInt value);\nstd::string JSON_API valueToString(double value);\nstd::string JSON_API valueToString(bool value);\nstd::string JSON_API valueToQuotedString(const char *value);\n\n/// \\brief Output using the StyledStreamWriter.\n/// \\see Json::operator>>()\nJSON_API std::ostream &operator<<(std::ostream &, const Value &root);\n\n} // namespace Json\n\n#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)\n#pragma warning(pop)\n#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)\n\n#endif // JSON_WRITER_H_INCLUDED\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/libevdev/libevdev-uinput.h",
    "content": "/*\n * Copyright © 2013 Red Hat, Inc.\n *\n * Permission to use, copy, modify, distribute, and sell this software and its\n * documentation for any purpose is hereby granted without fee, provided that\n * the above copyright notice appear in all copies and that both that copyright\n * notice and this permission notice appear in supporting documentation, and\n * that the name of the copyright holders not be used in advertising or\n * publicity pertaining to distribution of the software without specific,\n * written prior permission.  The copyright holders make no representations\n * about the suitability of this software for any purpose.  It is provided \"as\n * is\" without express or implied warranty.\n *\n * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,\n * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO\n * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR\n * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,\n * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER\n * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE\n * OF THIS SOFTWARE.\n */\n\n#ifndef LIBEVDEV_UINPUT_H\n#define LIBEVDEV_UINPUT_H\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#include <libevdev/libevdev.h>\n\nstruct libevdev_uinput;\n\n/**\n * @defgroup uinput uinput device creation\n *\n * Creation of uinput devices based on existing libevdev devices. These functions\n * help to create uinput devices that emulate libevdev devices. In the simplest\n * form it serves to duplicate an existing device:\n *\n @code\n int err;\n int new_fd;\n struct libevdev *dev;\n struct libevdev_uinput *uidev;\n struct input_event ev[2];\n\n err = libevdev_new_from_fd(&dev, fd);\n if (err != 0)\n     return err;\n\n uifd = open(\"/dev/uinput\", O_RDWR);\n if (uidev < 0)\n     return -errno;\n\n err = libevdev_uinput_create_from_device(dev, uifd, &uidev);\n if (err != 0)\n     return err;\n\n // post a REL_X event\n err = libevdev_uinput_write_event(uidev, EV_REL, REL_X, -1);\n if (err != 0)\n     return err;\n libevdev_uinput_write_event(uidev, EV_SYN, SYN_REPORT, 0);\n if (err != 0)\n     return err;\n\n libevdev_uinput_destroy(uidev);\n close(uifd);\n\n @endcode\n *\n * Alternatively, a device can be constructed from scratch:\n *\n @code\n int err;\n struct libevdev *dev;\n struct libevdev_uinput *uidev;\n\n dev = libevdev_new();\n libevdev_set_name(dev, \"test device\");\n libevdev_enable_event_type(dev, EV_REL);\n libevdev_enable_event_code(dev, EV_REL, REL_X);\n libevdev_enable_event_code(dev, EV_REL, REL_Y);\n libevdev_enable_event_type(dev, EV_KEY);\n libevdev_enable_event_code(dev, EV_KEY, BTN_LEFT);\n libevdev_enable_event_code(dev, EV_KEY, BTN_MIDDLE);\n libevdev_enable_event_code(dev, EV_KEY, BTN_RIGHT);\n\n err = libevdev_uinput_create_from_device(dev,\n                                          LIBEVDEV_UINPUT_OPEN_MANAGED,\n                                          &uidev);\n if (err != 0)\n     return err;\n\n // ... do something ...\n\n libevdev_uinput_destroy(uidev);\n\n @endcode\n */\n\nenum libevdev_uinput_open_mode {\n\t/* intentionally -2 to avoid to avoid code like the below from accidentally working:\n\t\tfd = open(\"/dev/uinput\", O_RDWR); // fails, fd is -1\n\t\tlibevdev_uinput_create_from_device(dev, fd, &uidev); // may hide the error */\n\tLIBEVDEV_UINPUT_OPEN_MANAGED = -2  /**< let libevdev open and close @c /dev/uinput */\n};\n\n/**\n * @ingroup uinput\n *\n * Create a uinput device based on the given libevdev device. The uinput device\n * will be an exact copy of the libevdev device, minus the bits that uinput doesn't\n * allow to be set.\n *\n * If uinput_fd is @ref LIBEVDEV_UINPUT_OPEN_MANAGED, libevdev_uinput_create_from_device()\n * will open @c /dev/uinput in read/write mode and manage the file descriptor.\n * Otherwise, uinput_fd must be opened by the caller and opened with the\n * appropriate permissions.\n *\n * The device's lifetime is tied to the uinput file descriptor, closing it will\n * destroy the uinput device. You should call libevdev_uinput_destroy() before\n * closing the file descriptor to free allocated resources.\n * A file descriptor can only create one uinput device at a time; the second device\n * will fail with -EINVAL.\n *\n * You don't need to keep the file descriptor variable around,\n * libevdev_uinput_get_fd() will return it when needed.\n *\n * @note Due to limitations in the uinput kernel module, REP_DELAY and\n * REP_PERIOD will default to the kernel defaults, not to the ones set in the\n * source device.\n *\n * @param dev The device to duplicate\n * @param uinput_fd @ref LIBEVDEV_UINPUT_OPEN_MANAGED or a file descriptor to @c /dev/uinput,\n * @param[out] uinput_dev The newly created libevdev device.\n *\n * @return 0 on success or a negative errno on failure. On failure, the value of\n * uinput_dev is unmodified.\n *\n * @see libevdev_uinput_destroy\n */\nint libevdev_uinput_create_from_device(const struct libevdev *dev,\n\t\t\t\t       int uinput_fd,\n\t\t\t\t       struct libevdev_uinput **uinput_dev);\n\n/**\n * @ingroup uinput\n *\n * Destroy a previously created uinput device and free associated memory.\n *\n * If the device was opened with @ref LIBEVDEV_UINPUT_OPEN_MANAGED,\n * libevdev_uinput_destroy() also closes the file descriptor. Otherwise, the\n * fd is left as-is and must be closed by the caller.\n *\n * @param uinput_dev A previously created uinput device.\n */\nvoid libevdev_uinput_destroy(struct libevdev_uinput *uinput_dev);\n\n/**\n * @ingroup uinput\n *\n * Return the file descriptor used to create this uinput device. This is the\n * fd pointing to <strong>/dev/uinput</strong>. This file descriptor may be used to write\n * events that are emitted by the uinput device.\n * Closing this file descriptor will destroy the uinput device, you should\n * call libevdev_uinput_destroy() first to free allocated resources.\n *\n * @param uinput_dev A previously created uinput device.\n *\n * @return The file descriptor used to create this device\n */\nint libevdev_uinput_get_fd(const struct libevdev_uinput *uinput_dev);\n\n/**\n * @ingroup uinput\n *\n * Return the syspath representing this uinput device. If the UI_GET_SYSNAME\n * ioctl not available, libevdev makes an educated guess.\n * The UI_GET_SYSNAME ioctl is available since Linux 3.15.\n *\n * @note This function may return NULL if UI_GET_SYSNAME is not available.\n * In that case, libevdev uses ctime and the device name to guess devices.\n * To avoid false positives, wait at least wait at least 1.5s between\n * creating devices that have the same name.\n * @param uinput_dev A previously created uinput device.\n * @return The syspath for this device, including the preceding /sys\n *\n * @see libevdev_uinput_get_devnode\n */\nconst char* libevdev_uinput_get_syspath(struct libevdev_uinput *uinput_dev);\n\n/**\n * @ingroup uinput\n *\n * Return the device node representing this uinput device.\n *\n * This relies on libevdev_uinput_get_syspath() to provide a valid syspath.\n * See libevdev_uinput_get_syspath() for more details.\n *\n * @note This function may return NULL. libevdev may have to guess the\n * syspath and the device node. See libevdev_uinput_get_syspath() for details.\n * @param uinput_dev A previously created uinput device.\n * @return The device node for this device, in the form of /dev/input/eventN\n *\n * @see libevdev_uinput_get_syspath\n */\nconst char* libevdev_uinput_get_devnode(struct libevdev_uinput *uinput_dev);\n\n/**\n * @ingroup uinput\n *\n * Post an event through the uinput device. It is the caller's responsibility\n * that any event sequence is terminated with an EV_SYN/SYN_REPORT/0 event.\n * Otherwise, listeners on the device node will not see the events until the\n * next EV_SYN event is posted.\n *\n * @param uinput_dev A previously created uinput device.\n * @param type Event type (EV_ABS, EV_REL, etc.)\n * @param code Event code (ABS_X, REL_Y, etc.)\n * @param value The event value\n * @return 0 on success or a negative errno on error\n */\nint libevdev_uinput_write_event(const struct libevdev_uinput *uinput_dev,\n\t\t\t\tunsigned int type,\n\t\t\t\tunsigned int code,\n\t\t\t\tint value);\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* LIBEVDEV_UINPUT_H */\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/libevdev/libevdev.h",
    "content": "/*\n * Copyright © 2013 Red Hat, Inc.\n *\n * Permission to use, copy, modify, distribute, and sell this software and its\n * documentation for any purpose is hereby granted without fee, provided that\n * the above copyright notice appear in all copies and that both that copyright\n * notice and this permission notice appear in supporting documentation, and\n * that the name of the copyright holders not be used in advertising or\n * publicity pertaining to distribution of the software without specific,\n * written prior permission.  The copyright holders make no representations\n * about the suitability of this software for any purpose.  It is provided \"as\n * is\" without express or implied warranty.\n *\n * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,\n * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO\n * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR\n * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,\n * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER\n * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE\n * OF THIS SOFTWARE.\n */\n\n#ifndef LIBEVDEV_H\n#define LIBEVDEV_H\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#include <linux/input.h>\n#include <stdarg.h>\n\n#define LIBEVDEV_ATTRIBUTE_PRINTF(_format, _args) __attribute__ ((format (printf, _format, _args)))\n\n/**\n * @mainpage\n *\n * **libevdev** is a library for handling evdev kernel devices. It abstracts\n * the \\ref ioctls through type-safe interfaces and provides functions to change\n * the appearance of the device.\n *\n * Development of libevdev is discussed on\n * [input-tools@lists.freedesktop.org](http://lists.freedesktop.org/mailman/listinfo/input-tools)\n * Please submit patches, questions or general comments there.\n *\n * Handling events and SYN_DROPPED\n * ===============================\n *\n * libevdev provides an interface for handling events, including most notably\n * SYN_DROPPED events. SYN_DROPPED events are sent by the kernel when the\n * process does not read events fast enough and the kernel is forced to drop\n * some events. This causes the device to get out of sync with the process'\n * view of it. libevdev handles this by telling the caller that a SYN_DROPPED\n * has been received and that the state of the device is different to what is\n * to be expected. It then provides the delta between the previous state and\n * the actual state of the device as a set of events. See\n * libevdev_next_event() and @ref syn_dropped for more information on how\n * SYN_DROPPED is handled.\n *\n * Signal safety\n * =============\n *\n * libevdev is signal-safe for the majority of its operations, i.e. many of\n * its functions are safe to be called from within a signal handler.\n * Check the API documentation to make sure, unless explicitly stated a call\n * is <b>not</b> signal safe.\n *\n * Device handling\n * ===============\n *\n * A libevdev context is valid for a given file descriptor and its\n * duration. Closing the file descriptor will not destroy the libevdev device\n * but libevdev will not be able to read further events.\n *\n * libevdev does not attempt duplicate detection. Initializing two libevdev\n * devices for the same fd is valid and behaves the same as for two different\n * devices.\n *\n * libevdev does not handle the file descriptors directly, it merely uses\n * them. The caller is responsible for opening the file descriptors, setting\n * them to O_NONBLOCK and handling permissions.\n *\n * Where does libevdev sit?\n * ========================\n *\n * libevdev is essentially a `read(2)` on steroids for `/dev/input/eventX`\n * devices. It sits below the process that handles input events, in between\n * the kernel and that process. In the simplest case, e.g. an evtest-like tool\n * the stack would look like this:\n *\n *      kernel → libevdev → evtest\n *\n * For X.Org input modules, the stack would look like this:\n *\n *      kernel → libevdev → xf86-input-evdev → X server → X client\n *\n * For Weston/Wayland, the stack would look like this:\n *\n *      kernel → libevdev → Weston → Wayland client\n *\n * libevdev does **not** have knowledge of X clients or Wayland clients, it is\n * too low in the stack.\n *\n * Example\n * =======\n * Below is a simple example that shows how libevdev could be used. This example\n * opens a device, checks for relative axes and a left mouse button and if it\n * finds them monitors the device to print the event.\n *\n * @code\n       struct libevdev *dev = NULL;\n       int fd;\n       int rc = 1;\n\n       fd = open(\"/dev/input/event0\", O_RDONLY|O_NONBLOCK);\n       rc = libevdev_new_from_fd(fd, &dev);\n       if (rc < 0) {\n               fprintf(stderr, \"Failed to init libevdev (%s)\\n\", strerror(-rc));\n               exit(1);\n       }\n       printf(\"Input device name: \\\"%s\\\"\\n\", libevdev_get_name(dev));\n       printf(\"Input device ID: bus %#x vendor %#x product %#x\\n\",\n              libevdev_get_id_bustype(dev),\n              libevdev_get_id_vendor(dev),\n              libevdev_get_id_product(dev));\n       if (!libevdev_has_event_type(dev, EV_REL) ||\n           !libevdev_has_event_code(dev, EV_KEY, BTN_LEFT)) {\n               printf(\"This device does not look like a mouse\\n\");\n               exit(1);\n       }\n\n       do {\n               struct input_event ev;\n               rc = libevdev_next_event(dev, LIBEVDEV_READ_FLAG_NORMAL, &ev);\n               if (rc == 0)\n                       printf(\"Event: %s %s %d\\n\",\n                              libevdev_get_event_type_name(ev.type),\n                              libevdev_get_event_code_name(ev.type, ev.code),\n                              ev.value);\n       } while (rc == 1 || rc == 0 || rc == -EAGAIN);\n  @endcode\n *\n * A more complete example is available with the libevdev-events tool here:\n * http://cgit.freedesktop.org/libevdev/tree/tools/libevdev-events.c\n *\n * Backwards compatibility with older kernel\n * =========================================\n * libevdev attempts to build and run correctly on a number of kernel versions.\n * If features required are not available, libevdev attempts to work around them\n * in the most reasonable way. For more details see \\ref backwardscompatibility.\n *\n * License information\n * ===================\n * libevdev is licensed under the\n * [X11 license](http://cgit.freedesktop.org/libevdev/tree/COPYING).\n *\n * Reporting bugs\n * ==============\n * Please report bugs in the freedesktop.org bugzilla under the libevdev product:\n * https://bugs.freedesktop.org/enter_bug.cgi?product=libevdev\n */\n\n/**\n * @page syn_dropped SYN_DROPPED handling\n *\n * This page describes how libevdev handles SYN_DROPPED events.\n *\n * Receiving SYN_DROPPED events\n * ============================\n *\n * The kernel sends evdev events separated by an event of type EV_SYN and\n * code SYN_REPORT. Such an event marks the end of a frame of hardware\n * events. The number of events between SYN_REPORT events is arbitrary and\n * depends on the hardware. An example event sequence may look like this:\n * @code\n   EV_ABS   ABS_X        9\n   EV_ABS   ABS_Y        8\n   EV_SYN   SYN_REPORT   0\n   ------------------------\n   EV_ABS   ABS_X        10\n   EV_ABS   ABS_Y        10\n   EV_KEY   BTN_TOUCH    1\n   EV_SYN   SYN_REPORT   0\n   ------------------------\n   EV_ABS   ABS_X        11\n   EV_SYN   SYN_REPORT   0\n * @endcode\n *\n * Events are handed to the client buffer as they appear, the kernel adjusts\n * the buffer size to handle at least one full event. In the normal case,\n * the client reads the event and the kernel can place the next event in the\n * buffer. If the client is not fast enough, the kernel places an event of\n * type EV_SYN and code SYN_DROPPED into the buffer, effectively notifying\n * the client that some events were lost. The above example event sequence\n * may look like this (note the missing/repeated events):\n * @code\n   EV_ABS   ABS_X        9\n   EV_ABS   ABS_Y        8\n   EV_SYN   SYN_REPORT   0\n   ------------------------\n   EV_ABS   ABS_X        10\n   EV_ABS   ABS_Y        10\n   EV_SYN   SYN_DROPPED  0\n   EV_ABS   ABS_Y        15\n   EV_SYN   SYN_REPORT   0\n   ------------------------\n   EV_ABS   ABS_X        11\n   EV_KEY   BTN_TOUCH    0\n   EV_SYN   SYN_REPORT   0\n * @endcode\n *\n * A SYN_DROPPED event may be recieved at any time in the event sequence.\n * When a SYN_DROPPED event is received, the client must:\n * * discard all events since the last SYN_REPORT\n * * discard all events until including the next SYN_REPORT\n * These event are part of incomplete event frames.\n *\n * Synchronizing the state of the device\n * =====================================\n *\n * The handling of the device after a SYN_DROPPED depends on the available\n * event codes. For all event codes of type EV_REL, no handling is\n * necessary, there is no state attached. For all event codes of type\n * EV_KEY, EV_SW, EV_LED and EV_SND, the matching @ref ioctls retrieve the\n * current state. The caller must then compare the last-known state to the\n * retrieved state and handle the deltas accordingly.\n * libevdev simplifies this approach: if the state of the device has\n * changed, libevdev generates an event for each code with the new value and\n * passes it to the caller during libevdev_next_event() if\n * @ref LIBEVDEV_READ_FLAG_SYNC is set.\n *\n * For events of type EV_ABS and an event code less than ABS_MT_SLOT, the\n * handling of state changes is as described above. For events between\n * ABS_MT_SLOT and ABS_MAX, the event handling differs.\n * Slots are the vehicles to transport information for multiple simultaneous\n * touchpoints on a device. Slots are re-used once a touchpoint has ended.\n * The kernel sends an ABS_MT_SLOT event whenever the current slot\n * changes; any event in the above axis range applies only to the currently\n * active slot.\n * Thus, an event sequence from a slot-capable device may look like this:\n * @code\n   EV_ABS   ABS_MT_POSITION_Y   10\n   EV_ABS   ABS_MT_SLOT         1\n   EV_ABS   ABS_MT_POSITION_X   100\n   EV_ABS   ABS_MT_POSITION_Y   80\n   EV_SYN   SYN_REPORT          0\n * @endcode\n * Note the lack of ABS_MT_SLOT: the first ABS_MT_POSITION_Y applies to\n * a slot opened previously, and is the only axis that changed for that\n * slot. The touchpoint in slot 1 now has position 100/80.\n * The kernel does not provide events if a value does not change, and does\n * not send ABS_MT_SLOT events if the slot does not change, or none of the\n * values within a slot changes. A client must thus keep the state for each\n * slot.\n *\n * If a SYN_DROPPED is received,  the client must sync all slots\n * individually and update its internal state. libevdev simplifies this by\n * generating multiple events:\n * * for each slot on the device, libevdev generates an\n *   ABS_MT_SLOT event with the value set to the slot number\n * * for each event code between ABS_MT_SLOT + 1 and ABS_MAX that changed\n *   state for this slot, libevdev generates an event for the new state\n * * libevdev sends a final ABS_MT_SLOT event for the current slot as\n *   seen by the kernel\n * * libevdev terminates this sequence with an EV_SYN SYN_REPORT event\n *\n * An example event sequence for such a sync may look like this:\n * @code\n   EV_ABS   ABS_MT_SLOT         0\n   EV_ABS   ABS_MT_POSITION_Y   10\n   EV_ABS   ABS_MT_SLOT         1\n   EV_ABS   ABS_MT_POSITION_X   100\n   EV_ABS   ABS_MT_POSITION_Y   80\n   EV_ABS   ABS_MT_SLOT         2\n   EV_ABS   ABS_MT_POSITION_Y   8\n   EV_ABS   ABS_MT_PRESSURE     12\n   EV_ABS   ABS_MT_SLOT         1\n   EV_SYN   SYN_REPORT          0\n * @endcode\n * Note the terminating ABS_MT_SLOT event, this indicates that the kernel\n * currently has slot 1 active.\n *\n * Synchronizing ABS_MT_TRACKING_ID\n * ================================\n *\n * The event code ABS_MT_TRACKING_ID is used to denote the start and end of\n * a touch point within a slot. An ABS_MT_TRACKING_ID of zero or greater\n * denotes the start of a touchpoint, an ABS_MT_TRACKING_ID of -1 denotes\n * the end of a touchpoint within this slot. During SYN_DROPPED, a touch\n * point may have ended and re-started within a slot - a client must check\n * the ABS_MT_TRACKING_ID. libevdev simplifies this by emulating extra\n * events if the ABS_MT_TRACKING_ID has changed:\n * * if the ABS_MT_TRACKING_ID was valid and is -1, libevdev enqueues an\n *   ABS_MT_TRACKING_ID event with value -1.\n * * if the ABS_MT_TRACKING_ID was -1 and is now a valid ID, libevdev\n *   enqueues an ABS_MT_TRACKING_ID event with the current value.\n * * if the ABS_MT_TRACKING_ID was a valid ID and is now a different valid\n *   ID, libevev enqueues an ABS_MT_TRACKING_ID event with value -1 and\n *   another ABS_MT_TRACKING_ID event with the new value.\n *\n * An example event sequence for such a sync may look like this:\n * @code\n   EV_ABS   ABS_MT_SLOT         0\n   EV_ABS   ABS_MT_TRACKING_ID  -1\n   EV_ABS   ABS_MT_SLOT         2\n   EV_ABS   ABS_MT_TRACKING_ID  -1\n   EV_SYN   SYN_REPORT          0\n   ------------------------\n   EV_ABS   ABS_MT_SLOT         1\n   EV_ABS   ABS_MT_POSITION_X   100\n   EV_ABS   ABS_MT_POSITION_Y   80\n   EV_ABS   ABS_MT_SLOT         2\n   EV_ABS   ABS_MT_TRACKING_ID  45\n   EV_ABS   ABS_MT_POSITION_Y   8\n   EV_ABS   ABS_MT_PRESSURE     12\n   EV_ABS   ABS_MT_SLOT         1\n   EV_SYN   SYN_REPORT          0\n * @endcode\n * Note how the touchpoint in slot 0 was terminated, the touchpoint in slot\n * 2 was terminated and then started with a new ABS_MT_TRACKING_ID. The touchpoint\n * in slot 1 maintained the same ABS_MT_TRACKING_ID and only updated the\n * coordinates. Slot 1 is the currently active slot.\n *\n * In the case of a SYN_DROPPED event, a touch point may be invisible to a\n * client if it started after SYN_DROPPED and finished before the client\n * handles events again. The below example shows an example event sequence\n * and what libevdev sees in the case of a SYN_DROPPED event:\n * @code\n\n             kernel                  |              userspace\n                                     |\n   EV_ABS   ABS_MT_SLOT         0    |    EV_ABS   ABS_MT_SLOT         0\n   EV_ABS   ABS_MT_TRACKING_ID  -1   |    EV_ABS   ABS_MT_TRACKING_ID  -1\n   EV_SYN   SYN_REPORT          0    |    EV_SYN   SYN_REPORT          0\n   ------------------------          |    ------------------------\n   EV_ABS   ABS_MT_TRACKING_ID  30   |\n   EV_ABS   ABS_MT_POSITION_X   100  |\n   EV_ABS   ABS_MT_POSITION_Y   80   |\n   EV_SYN   SYN_REPORT          0    |           SYN_DROPPED\n   ------------------------          |\n   EV_ABS   ABS_MT_TRACKING_ID  -1   |\n   EV_SYN   SYN_REPORT          0    |\n   ------------------------          |    ------------------------\n   EV_ABS   ABS_MT_SLOT         1    |    EV_ABS   ABS_MT_SLOT         1\n   EV_ABS   ABS_MT_POSITION_X   90   |    EV_ABS   ABS_MT_POSITION_X   90\n   EV_ABS   ABS_MT_POSITION_Y   10   |    EV_ABS   ABS_MT_POSITION_Y   10\n   EV_SYN   SYN_REPORT          0    |    EV_SYN   SYN_REPORT          0\n * @endcode\n * If such an event sequence occurs, libevdev will send all updated axes\n * during the sync process. Axis events may thus be generated for devices\n * without a currently valid ABS_MT_TRACKING_ID. Specifically for the above\n * example, the client would receive the following event sequence:\n * @code\n   EV_ABS   ABS_MT_SLOT         0       ← LIBEVDEV_READ_FLAG_NORMAL\n   EV_ABS   ABS_MT_TRACKING_ID  -1\n   EV_SYN   SYN_REPORT          0\n   ------------------------\n   EV_SYN   SYN_DROPPED         0       → LIBEVDEV_READ_STATUS_SYNC\n   ------------------------\n   EV_ABS   ABS_MT_POSITION_X   100     ← LIBEVDEV_READ_FLAG_SYNC\n   EV_ABS   ABS_MT_POSITION_Y   80\n   EV_SYN   SYN_REPORT          0\n   -----------------------------        → -EGAIN\n   EV_ABS   ABS_MT_SLOT         1       ← LIBEVDEV_READ_FLAG_NORMAL\n   EV_ABS   ABS_MT_POSITION_X   90\n   EV_ABS   ABS_MT_POSITION_Y   10\n   EV_SYN   SYN_REPORT          0\n   -------------------\n * @endcode\n * The axis events do not reflect the position of a current touch point, a\n * client must take care not to generate a new touch point based on those\n * updates.\n *\n * Discarding events before synchronizing\n * =====================================\n *\n * The kernel implements the client buffer as a ring buffer. SYN_DROPPED\n * events are handled when the buffer is full and a new event is received\n * from a device. All existing events are discarded, a SYN_DROPPED is added\n * to the buffer followed by the actual device event. Further events will be\n * appended to the buffer until it is either read by the client, or filled\n * again, at which point the sequence repeats.\n *\n * When the client reads the buffer, the buffer will thus always consist of\n * exactly one SYN_DROPPED event followed by an unspecified number of real\n * events. The data the ioctls return is the current state of the device,\n * i.e. the state after all these events have been processed. For example,\n * assume the buffer contains the following sequence:\n *\n * @code\n   EV_SYN   SYN_DROPPED\n   EV_ABS   ABS_X               1\n   EV_SYN   SYN_REPORT          0\n   EV_ABS   ABS_X               2\n   EV_SYN   SYN_REPORT          0\n   EV_ABS   ABS_X               3\n   EV_SYN   SYN_REPORT          0\n   EV_ABS   ABS_X               4\n   EV_SYN   SYN_REPORT          0\n   EV_ABS   ABS_X               5\n   EV_SYN   SYN_REPORT          0\n   EV_ABS   ABS_X               6\n   EV_SYN   SYN_REPORT          0\n * @endcode\n * An ioctl at any time in this sequence will return a value of 6 for ABS_X.\n *\n * libevdev discards all events after a SYN_DROPPED to ensure the events\n * during @ref LIBEVDEV_READ_FLAG_SYNC represent the last known state of the\n * device. This loses some granularity of the events especially as the time\n * between the SYN_DROPPED and the sync process increases. It does however\n * avoid spurious cursor movements. In the above example, the event sequence\n * by libevdev is:\n * @code\n   EV_SYN   SYN_DROPPED\n   EV_ABS   ABS_X               6\n   EV_SYN   SYN_REPORT          0\n   @endcode\n */\n\n/**\n * @page backwardscompatibility Compatibility and Behavior across kernel versions\n *\n * This page describes libevdev's behavior when the build-time kernel and the\n * run-time kernel differ in their feature set.\n *\n * With the exception of event names, libevdev defines features that may be\n * missing on older kernels and building on such kernels will not disable\n * features. Running libevdev on a kernel that is missing some feature will\n * change libevdev's behavior. In most cases, the new behavior should be\n * obvious, but it is spelled out below in detail.\n *\n * Minimum requirements\n * ====================\n * libevdev requires a 2.6.36 kernel as minimum. Specifically, it requires\n * kernel-support for ABS_MT_SLOT.\n *\n * Event and input property names\n * ==============================\n * Event names and input property names are defined at build-time by the\n * linux/input.h shipped with libevdev.\n * The list of event names is compiled at build-time, any events not defined\n * at build time will not resolve. Specifically,\n * libevdev_event_code_get_name() for an undefined type or code will\n * always return NULL. Likewise, libevdev_property_get_name() will return NULL\n * for properties undefined at build-time.\n *\n * Input properties\n * ================\n * If the kernel does not support input properties, specifically the\n * EVIOCGPROPS ioctl, libevdev does not expose input properties to the caller.\n * Specifically, libevdev_has_property() will always return 0 unless the\n * property has been manually set with libevdev_enable_property().\n *\n * This also applies to the libevdev-uinput code. If uinput does not honor\n * UI_SET_PROPBIT, libevdev will continue without setting the properties on\n * the device.\n *\n * MT slot behavior\n * =================\n * If the kernel does not support the EVIOCGMTSLOTS ioctl, libevdev\n * assumes all values in all slots are 0 and continues without an error.\n *\n * SYN_DROPPED behavior\n * ====================\n * A kernel without SYN_DROPPED won't send such an event. libevdev_next_event()\n * will never require the switch to sync mode.\n */\n\n/**\n * @page ioctls evdev ioctls\n *\n * This page lists the status of the evdev-specific ioctls in libevdev.\n *\n * <dl>\n * <dt>EVIOCGVERSION:</dt>\n * <dd>supported, see libevdev_get_driver_version()</dd>\n * <dt>EVIOCGID:</dt>\n * <dd>supported, see libevdev_get_id_product(), libevdev_get_id_vendor(),\n * libevdev_get_id_bustype(), libevdev_get_id_version()</dd>\n * <dt>EVIOCGREP:</dt>\n * <dd>supported, see libevdev_get_event_value())</dd>\n * <dt>EVIOCSREP:</dt>\n * <dd>supported, see libevdev_enable_event_code()</dd>\n * <dt>EVIOCGKEYCODE:</dt>\n * <dd>currently not supported</dd>\n * <dt>EVIOCGKEYCODE:</dt>\n * <dd>currently not supported</dd>\n * <dt>EVIOCSKEYCODE:</dt>\n * <dd>currently not supported</dd>\n * <dt>EVIOCSKEYCODE:</dt>\n * <dd>currently not supported</dd>\n * <dt>EVIOCGNAME:</dt>\n * <dd>supported, see libevdev_get_name()</dd>\n * <dt>EVIOCGPHYS:</dt>\n * <dd>supported, see libevdev_get_phys()</dd>\n * <dt>EVIOCGUNIQ:</dt>\n * <dd>supported, see libevdev_get_uniq()</dd>\n * <dt>EVIOCGPROP:</dt>\n * <dd>supported, see libevdev_has_property()</dd>\n * <dt>EVIOCGMTSLOTS:</dt>\n * <dd>supported, see libevdev_get_num_slots(), libevdev_get_slot_value()</dd>\n * <dt>EVIOCGKEY:</dt>\n * <dd>supported, see libevdev_has_event_code(), libevdev_get_event_value()</dd>\n * <dt>EVIOCGLED:</dt>\n * <dd>supported, see libevdev_has_event_code(), libevdev_get_event_value()</dd>\n * <dt>EVIOCGSND:</dt>\n * <dd>currently not supported</dd>\n * <dt>EVIOCGSW:</dt>\n * <dd>supported, see libevdev_has_event_code(), libevdev_get_event_value()</dd>\n * <dt>EVIOCGBIT:</dt>\n * <dd>supported, see libevdev_has_event_code(), libevdev_get_event_value()</dd>\n * <dt>EVIOCGABS:</dt>\n * <dd>supported, see libevdev_has_event_code(), libevdev_get_event_value(),\n * libevdev_get_abs_info()</dd>\n * <dt>EVIOCSABS:</dt>\n * <dd>supported, see libevdev_kernel_set_abs_info()</dd>\n * <dt>EVIOCSFF:</dt>\n * <dd>currently not supported</dd>\n * <dt>EVIOCRMFF:</dt>\n * <dd>currently not supported</dd>\n * <dt>EVIOCGEFFECTS:</dt>\n * <dd>currently not supported</dd>\n * <dt>EVIOCGRAB:</dt>\n * <dd>supported, see libevdev_grab()</dd>\n * <dt>EVIOCSCLOCKID:</dt>\n * <dd>supported, see libevdev_set_clock_id()</dd>\n * <dt>EVIOCREVOKE:</dt>\n * <dd>currently not supported, see\n * http://lists.freedesktop.org/archives/input-tools/2014-January/000688.html</dd>\n * </dl>\n *\n */\n\n/**\n * @page kernel_header Kernel header\n *\n * libevdev provides its own copy of the Linux kernel header file and\n * compiles against the definitions define here. Event type and event code\n * names, etc. are taken from the file below:\n * @include linux/input.h\n */\n\n/**\n * @page static_linking Statically linking libevdev\n *\n * Statically linking libevdev.a is not recommended. Symbol visibility is\n * difficult to control in a static library, so extra care must be taken to\n * only use symbols that are explicitly exported. libevdev's API stability\n * guarantee only applies to those symbols.\n *\n * If you do link libevdev statically, note that in addition to the exported\n * symbols, libevdev reserves the <b>_libevdev_*</b> namespace. Do not use\n * or create symbols with that prefix, they are subject to change at any\n * time.\n */\n\n/**\n * @page testing libevdev-internal test suite\n *\n * libevdev's internal test suite uses the\n * [Check unit testing framework](http://check.sourceforge.net/). Tests are\n * divided into test suites and test cases. Most tests create a uinput device,\n * so you'll need to run as root, and your kernel must have\n * CONFIG_INPUT_UINPUT enabled.\n *\n * To run a specific suite only:\n *\n *     export CK_RUN_SUITE=\"suite name\"\n *\n * To run a specific test case only:\n *\n *     export CK_RUN_TEST=\"test case name\"\n *\n * To get a list of all suites or tests:\n *\n *     git grep \"suite_create\"\n *     git grep \"tcase_create\"\n *\n * By default, Check forks, making debugging harder. The test suite tries to detect\n * if it is running inside gdb and disable forking. If that doesn't work for\n * some reason, run gdb as below to avoid forking.\n *\n *     sudo CK_FORK=no CK_RUN_TEST=\"test case name\" gdb ./test/test-libevdev\n *\n * A special target `make gcov-report.txt` exists that runs gcov and leaves a\n * `libevdev.c.gcov` file. Check that for test coverage.\n *\n * `make check` is hooked up to run the test and gcov (again, needs root).\n *\n * The test suite creates a lot of devices, very quickly. Add the following\n * xorg.conf.d snippet to avoid the devices being added as X devices (at the\n * time of writing, mutter can't handle these devices and exits after getting\n * a BadDevice error).\n *\n *     $ cat /etc/X11/xorg.conf.d/99-ignore-libevdev-devices.conf\n *     Section \"InputClass\"\n *             Identifier \"Ignore libevdev test devices\"\n *             MatchProduct \"libevdev test device\"\n *             Option \"Ignore\" \"on\"\n *     EndSection\n *\n */\n\n/**\n * @defgroup init Initialization and setup\n *\n * Initialization, initial setup and file descriptor handling.\n * These functions are the main entry points for users of libevdev, usually a\n * caller will use this series of calls:\n *\n * @code\n * struct libevdev *dev;\n * int err;\n *\n * dev = libevdev_new();\n * if (!dev)\n *         return ENOMEM;\n *\n * err = libevdev_set_fd(dev, fd);\n * if (err < 0) {\n *         printf(\"Failed (errno %d): %s\\n\", -err, strerror(-err));\n *\n * libevdev_free(dev);\n * @endcode\n *\n * libevdev_set_fd() is the central call and initializes the internal structs\n * for the device at the given fd. libevdev functions will fail if called\n * before libevdev_set_fd() unless documented otherwise.\n */\n\n/**\n * @defgroup logging Library logging facilities\n *\n * libevdev provides two methods of logging library-internal messages. The\n * old method is to provide a global log handler in\n * libevdev_set_log_function(). The new method is to provide a per-context\n * log handler in libevdev_set_device_log_function(). Developers are encouraged\n * to use the per-context logging facilities over the global log handler as\n * it provides access to the libevdev instance that caused a message, and is\n * more flexible when libevdev is used from within a shared library.\n *\n * If a caller sets both the global log handler and a per-context log\n * handler, each device with a per-context log handler will only invoke that\n * log handler.\n *\n * @note To set a context-specific log handler, a context is needed.\n * Thus developers are discouraged from using libevdev_new_from_fd() as\n * important messages from the device initialization process may get lost.\n *\n * @note A context-specific handler cannot be used for libevdev's uinput\n * devices. @ref uinput must use the global log handler.\n */\n\n/**\n * @defgroup bits Querying device capabilities\n *\n * Abstraction functions to handle device capabilities, specificially\n * device properties such as the name of the device and the bits\n * representing the events suppported by this device.\n *\n * The logical state returned may lag behind the physical state of the device.\n * libevdev queries the device state on libevdev_set_fd() and then relies on\n * the caller to parse events through libevdev_next_event(). If a caller does not\n * use libevdev_next_event(), libevdev will not update the internal state of the\n * device and thus returns outdated values.\n */\n\n/**\n * @defgroup mt Multi-touch related functions\n * Functions for querying multi-touch-related capabilities. MT devices\n * following the kernel protocol B (using ABS_MT_SLOT) provide multiple touch\n * points through so-called slots on the same axis. The slots are enumerated,\n * a client reading from the device will first get an ABS_MT_SLOT event, then\n * the values of axes changed in this slot. Multiple slots may be provided in\n * before an EV_SYN event.\n *\n * As with @ref bits, the logical state of the device as seen by the library\n * depends on the caller using libevdev_next_event().\n *\n * The Linux kernel requires all axes on a device to have a semantic\n * meaning, matching the axis names in linux/input.h. Some devices merely\n * export a number of axes beyond the available axis list. For those\n * devices, the multitouch information is invalid. Specfically, if a device\n * provides the ABS_MT_SLOT axis AND also the (ABS_MT_SLOT - 1) axis, the\n * device is not treated as multitouch device. No slot information is\n * available and the ABS_MT axis range for these devices is treated as all\n * other EV_ABS axes.\n *\n * Note that because of limitations in the kernel API, such fake multitouch\n * devices can not be reliably synched after a SYN_DROPPED event. libevdev\n * ignores all ABS_MT axis values during the sync process and instead\n * relies on the device to send the current axis value with the first event\n * after SYN_DROPPED.\n */\n\n/**\n * @defgroup kernel Modifying the appearance or capabilities of the device\n *\n * Modifying the set of events reported by this device. By default, the\n * libevdev device mirrors the kernel device, enabling only those bits\n * exported by the kernel. This set of functions enable or disable bits as\n * seen from the caller.\n *\n * Enabling an event type or code does not affect event reporting - a\n * software-enabled event will not be generated by the physical hardware.\n * Disabling an event will prevent libevdev from routing such events to the\n * caller. Enabling and disabling event types and codes is at the library\n * level and thus only affects the caller.\n *\n * If an event type or code is enabled at kernel-level, future users of this\n * device will see this event enabled. Currently there is no option of\n * disabling an event type or code at kernel-level.\n */\n\n/**\n * @defgroup misc Miscellaneous helper functions\n *\n * Functions for printing or querying event ranges. The list of names is\n * compiled into libevdev and is independent of the run-time kernel.\n * Likewise, the max for each event type is compiled in and does not check\n * the kernel at run-time.\n */\n\n/**\n * @defgroup events Event handling\n *\n * Functions to handle events and fetch the current state of the event.\n * libevdev updates its internal state as the event is processed and forwarded\n * to the caller. Thus, the libevdev state of the device should always be identical\n * to the caller's state. It may however lag behind the actual state of the device.\n */\n\n/**\n * @ingroup init\n *\n * Opaque struct representing an evdev device.\n */\nstruct libevdev;\n\n/**\n * @ingroup events\n */\nenum libevdev_read_flag {\n\tLIBEVDEV_READ_FLAG_SYNC\t\t= 1, /**< Process data in sync mode */\n\tLIBEVDEV_READ_FLAG_NORMAL\t= 2, /**< Process data in normal mode */\n\tLIBEVDEV_READ_FLAG_FORCE_SYNC\t= 4, /**< Pretend the next event is a SYN_DROPPED and\n\t\t\t\t\t          require the caller to sync */\n\tLIBEVDEV_READ_FLAG_BLOCKING\t= 8  /**< The fd is not in O_NONBLOCK and a read may block */\n};\n\n/**\n * @ingroup init\n *\n * Initialize a new libevdev device. This function only allocates the\n * required memory and initializes the struct to sane default values.\n * To actually hook up the device to a kernel device, use\n * libevdev_set_fd().\n *\n * Memory allocated through libevdev_new() must be released by the\n * caller with libevdev_free().\n *\n * @see libevdev_set_fd\n * @see libevdev_free\n */\nstruct libevdev* libevdev_new(void);\n\n/**\n * @ingroup init\n *\n * Initialize a new libevdev device from the given fd.\n *\n * This is a shortcut for\n *\n @code\n int err;\n struct libevdev *dev = libevdev_new();\n err = libevdev_set_fd(dev, fd);\n @endcode\n *\n * @param fd A file descriptor to the device in O_RDWR or O_RDONLY mode.\n * @param[out] dev The newly initialized evdev device.\n *\n * @return On success, 0 is returned and dev is set to the newly\n * allocated struct. On failure, a negative errno is returned and the value\n * of dev is undefined.\n *\n * @see libevdev_free\n */\nint libevdev_new_from_fd(int fd, struct libevdev **dev);\n\n/**\n * @ingroup init\n *\n * Clean up and free the libevdev struct. After completion, the <code>struct\n * libevdev</code> is invalid and must not be used.\n *\n * @param dev The evdev device\n *\n * @note This function may be called before libevdev_set_fd().\n */\nvoid libevdev_free(struct libevdev *dev);\n\n/**\n * @ingroup logging\n */\nenum libevdev_log_priority {\n\tLIBEVDEV_LOG_ERROR = 10,\t/**< critical errors and application bugs */\n\tLIBEVDEV_LOG_INFO  = 20,\t/**< informational messages */\n\tLIBEVDEV_LOG_DEBUG = 30\t\t/**< debug information */\n};\n\n/**\n * @ingroup logging\n *\n * Logging function called by library-internal logging.\n * This function is expected to treat its input like printf would.\n *\n * @param priority Log priority of this message\n * @param data User-supplied data pointer (see libevdev_set_log_function())\n * @param file libevdev source code file generating this message\n * @param line libevdev source code line generating this message\n * @param func libevdev source code function generating this message\n * @param format printf-style format string\n * @param args List of arguments\n *\n * @see libevdev_set_log_function\n */\ntypedef void (*libevdev_log_func_t)(enum libevdev_log_priority priority,\n\t\t\t\t    void *data,\n\t\t\t\t    const char *file, int line,\n\t\t\t\t    const char *func,\n\t\t\t\t    const char *format, va_list args)\n\tLIBEVDEV_ATTRIBUTE_PRINTF(6, 0);\n\n/**\n * @ingroup logging\n *\n * Set a printf-style logging handler for library-internal logging. The default\n * logging function is to stdout.\n *\n * @note The global log handler is only called if no context-specific log\n * handler has been set with libevdev_set_device_log_function().\n *\n * @param logfunc The logging function for this device. If NULL, the current\n * logging function is unset and no logging is performed.\n * @param data User-specific data passed to the log handler.\n *\n * @note This function may be called before libevdev_set_fd().\n *\n * @deprecated Use per-context logging instead, see\n * libevdev_set_device_log_function().\n */\nvoid libevdev_set_log_function(libevdev_log_func_t logfunc, void *data);\n\n/**\n * @ingroup logging\n *\n * Define the minimum level to be printed to the log handler.\n * Messages higher than this level are printed, others are discarded. This\n * is a global setting and applies to any future logging messages.\n *\n * @param priority Minimum priority to be printed to the log.\n *\n * @deprecated Use per-context logging instead, see\n * libevdev_set_device_log_function().\n */\nvoid libevdev_set_log_priority(enum libevdev_log_priority priority);\n\n/**\n * @ingroup logging\n *\n * Return the current log priority level. Messages higher than this level\n * are printed, others are discarded. This is a global setting.\n *\n * @return the current log level\n *\n * @deprecated Use per-context logging instead, see\n * libevdev_set_device_log_function().\n */\nenum libevdev_log_priority libevdev_get_log_priority(void);\n\n/**\n * @ingroup logging\n *\n * Logging function called by library-internal logging for a specific\n * libevdev context. This function is expected to treat its input like\n * printf would.\n *\n * @param dev The evdev device\n * @param priority Log priority of this message\n * @param data User-supplied data pointer (see libevdev_set_log_function())\n * @param file libevdev source code file generating this message\n * @param line libevdev source code line generating this message\n * @param func libevdev source code function generating this message\n * @param format printf-style format string\n * @param args List of arguments\n *\n * @see libevdev_set_log_function\n * @since 1.3\n */\ntypedef void (*libevdev_device_log_func_t)(const struct libevdev *dev,\n\t\t\t\t\t   enum libevdev_log_priority priority,\n\t\t\t\t\t   void *data,\n\t\t\t\t\t   const char *file, int line,\n\t\t\t\t\t   const char *func,\n\t\t\t\t\t   const char *format, va_list args)\n\tLIBEVDEV_ATTRIBUTE_PRINTF(7, 0);\n\n/**\n * @ingroup logging\n *\n * Set a printf-style logging handler for library-internal logging for this\n * device context. The default logging function is NULL, i.e. the global log\n * handler is invoked. If a context-specific log handler is set, the global\n * log handler is not invoked for this device.\n *\n * @note This log function applies for this device context only, even if\n * another context exists for the same fd.\n *\n * @param dev The evdev device\n * @param logfunc The logging function for this device. If NULL, the current\n * logging function is unset and logging falls back to the global log\n * handler, if any.\n * @param priority Minimum priority to be printed to the log.\n * @param data User-specific data passed to the log handler.\n *\n * @note This function may be called before libevdev_set_fd().\n * @since 1.3\n */\nvoid libevdev_set_device_log_function(struct libevdev *dev,\n\t\t\t\t      libevdev_device_log_func_t logfunc,\n\t\t\t\t      enum libevdev_log_priority priority,\n\t\t\t\t      void *data);\n\n/**\n * @ingroup init\n */\nenum libevdev_grab_mode {\n\tLIBEVDEV_GRAB = 3,\t/**< Grab the device if not currently grabbed */\n\tLIBEVDEV_UNGRAB = 4\t/**< Ungrab the device if currently grabbed */\n};\n\n/**\n * @ingroup init\n *\n * Grab or ungrab the device through a kernel EVIOCGRAB. This prevents other\n * clients (including kernel-internal ones such as rfkill) from receiving\n * events from this device.\n *\n * This is generally a bad idea. Don't do this.\n *\n * Grabbing an already grabbed device, or ungrabbing an ungrabbed device is\n * a noop and always succeeds.\n *\n * @param dev The evdev device, already initialized with libevdev_set_fd()\n * @param grab If true, grab the device. Otherwise ungrab the device.\n *\n * @return 0 if the device was successfull grabbed or ungrabbed, or a\n * negative errno in case of failure.\n */\nint libevdev_grab(struct libevdev *dev, enum libevdev_grab_mode grab);\n\n/**\n * @ingroup init\n *\n * Set the fd for this struct and initialize internal data.\n * The fd must be in O_RDONLY or O_RDWR mode.\n *\n * This function may only be called once per device. If the device changed and\n * you need to re-read a device, use libevdev_free() and libevdev_new(). If\n * you need to change the fd after closing and re-opening the same device, use\n * libevdev_change_fd().\n *\n * Unless otherwise specified, libevdev function behavior is undefined until\n * a successfull call to libevdev_set_fd().\n *\n * @param dev The evdev device\n * @param fd The file descriptor for the device\n *\n * @return 0 on success, or a negative errno on failure\n *\n * @see libevdev_change_fd\n * @see libevdev_new\n * @see libevdev_free\n */\nint libevdev_set_fd(struct libevdev* dev, int fd);\n\n/**\n * @ingroup init\n *\n * Change the fd for this device, without re-reading the actual device. If the fd\n * changes after initializing the device, for example after a VT-switch in the\n * X.org X server, this function updates the internal fd to the newly opened.\n * No check is made that new fd points to the same device. If the device has\n * changed, libevdev's behavior is undefined.\n *\n * libevdev does not sync itself after changing the fd and keeps the current\n * device state. Use libevdev_next_event with the\n * @ref LIBEVDEV_READ_FLAG_FORCE_SYNC flag to force a re-sync.\n *\n * The example code below illustrates how to force a re-sync of the\n * library-internal state. Note that this code doesn't handle the events in\n * the caller, it merely forces an update of the internal library state.\n @code\n     struct input_event ev;\n     libevdev_change_fd(dev, new_fd);\n     libevdev_next_event(dev, LIBEVDEV_READ_FLAG_FORCE_SYNC, &ev);\n     while (libevdev_next_event(dev, LIBEVDEV_READ_FLAG_SYNC, &ev) == LIBEVDEV_READ_STATUS_SYNC)\n\t                     ; // noop\n @endcode\n *\n * The fd may be open in O_RDONLY or O_RDWR.\n *\n * It is an error to call this function before calling libevdev_set_fd().\n *\n * @param dev The evdev device, already initialized with libevdev_set_fd()\n * @param fd The new fd\n *\n * @return 0 on success, or -1 on failure.\n *\n * @see libevdev_set_fd\n */\nint libevdev_change_fd(struct libevdev* dev, int fd);\n\n/**\n * @ingroup init\n *\n * @param dev The evdev device\n *\n * @return The previously set fd, or -1 if none had been set previously.\n * @note This function may be called before libevdev_set_fd().\n */\nint libevdev_get_fd(const struct libevdev* dev);\n\n\n/**\n * @ingroup events\n */\nenum libevdev_read_status {\n\t/**\n\t * libevdev_next_event() has finished without an error\n\t * and an event is available for processing.\n\t *\n\t * @see libevdev_next_event\n\t */\n\tLIBEVDEV_READ_STATUS_SUCCESS = 0,\n\t/**\n\t * Depending on the libevdev_next_event() read flag:\n\t * * libevdev received a SYN_DROPPED from the device, and the caller should\n\t * now resync the device, or,\n\t * * an event has been read in sync mode.\n\t *\n\t * @see libevdev_next_event\n\t */\n\tLIBEVDEV_READ_STATUS_SYNC = 1\n};\n/**\n * @ingroup events\n *\n * Get the next event from the device. This function operates in two different\n * modes: normal mode or sync mode.\n *\n * In normal mode (when flags has @ref LIBEVDEV_READ_FLAG_NORMAL set), this\n * function returns @ref LIBEVDEV_READ_STATUS_SUCCESS and returns the event\n * in the argument @p ev. If no events are available at this\n * time, it returns -EAGAIN and ev is undefined.\n *\n * If the current event is an EV_SYN SYN_DROPPED event, this function returns\n * @ref LIBEVDEV_READ_STATUS_SYNC and ev is set to the EV_SYN event.\n * The caller should now call this function with the\n * @ref LIBEVDEV_READ_FLAG_SYNC flag set, to get the set of events that make up the\n * device state delta. This function returns @ref LIBEVDEV_READ_STATUS_SYNC for\n * each event part of that delta, until it returns -EAGAIN once all events\n * have been synced. For more details on what libevdev does to sync after a\n * SYN_DROPPED event, see @ref syn_dropped.\n *\n * If a device needs to be synced by the caller but the caller does not call\n * with the @ref LIBEVDEV_READ_FLAG_SYNC flag set, all events from the diff are\n * dropped after libevdev updates its internal state and event processing\n * continues as normal. Note that the current slot and the state of touch\n * points may have updated during the SYN_DROPPED event, it is strongly\n * recommended that a caller ignoring all sync events calls\n * libevdev_get_current_slot() and checks the ABS_MT_TRACKING_ID values for\n * all slots.\n *\n * If a device has changed state without events being enqueued in libevdev,\n * e.g. after changing the file descriptor, use the @ref\n * LIBEVDEV_READ_FLAG_FORCE_SYNC flag. This triggers an internal sync of the\n * device and libevdev_next_event() returns @ref LIBEVDEV_READ_STATUS_SYNC.\n * Any state changes are available as events as described above. If\n * @ref LIBEVDEV_READ_FLAG_FORCE_SYNC is set, the value of ev is undefined.\n *\n * @param dev The evdev device, already initialized with libevdev_set_fd()\n * @param flags Set of flags to determine behaviour. If @ref LIBEVDEV_READ_FLAG_NORMAL\n * is set, the next event is read in normal mode. If @ref LIBEVDEV_READ_FLAG_SYNC is\n * set, the next event is read in sync mode.\n * @param ev On success, set to the current event.\n * @return On failure, a negative errno is returned.\n * @retval LIBEVDEV_READ_STATUS_SUCCESS One or more events were read of the\n * device and ev points to the next event in the queue\n * @retval -EAGAIN No events are currently available on the device\n * @retval LIBEVDEV_READ_STATUS_SYNC A SYN_DROPPED event was received, or a\n * synced event was returned and ev points to the SYN_DROPPED event\n *\n * @note This function is signal-safe.\n */\nint libevdev_next_event(struct libevdev *dev, unsigned int flags, struct input_event *ev);\n\n/**\n * @ingroup events\n *\n * Check if there are events waiting for us. This function does not read an\n * event off the fd and may not access the fd at all. If there are events\n * queued internally this function will return non-zero. If the internal\n * queue is empty, this function will poll the file descriptor for data.\n *\n * This is a convenience function for simple processes, most complex programs\n * are expected to use select(2) or poll(2) on the file descriptor. The kernel\n * guarantees that if data is available, it is a multiple of sizeof(struct\n * input_event), and thus calling libevdev_next_event() when select(2) or\n * poll(2) return is safe. You do not need libevdev_has_event_pending() if\n * you're using select(2) or poll(2).\n *\n * @param dev The evdev device, already initialized with libevdev_set_fd()\n * @return On failure, a negative errno is returned.\n * @retval 0 No event is currently available\n * @retval 1 One or more events are available on the fd\n *\n * @note This function is signal-safe.\n */\nint libevdev_has_event_pending(struct libevdev *dev);\n\n/**\n * @ingroup bits\n *\n * Retrieve the device's name, either as set by the caller or as read from\n * the kernel. The string returned is valid until libevdev_free() or until\n * libevdev_set_name(), whichever comes earlier.\n *\n * @param dev The evdev device, already initialized with libevdev_set_fd()\n *\n * @return The device name as read off the kernel device. The name is never\n * NULL but it may be the empty string.\n *\n * @note This function is signal-safe.\n */\nconst char* libevdev_get_name(const struct libevdev *dev);\n\n/**\n * @ingroup kernel\n *\n * Change the device's name as returned by libevdev_get_name(). This\n * function destroys the string previously returned by libevdev_get_name(),\n * a caller must take care that no references are kept.\n *\n * @param dev The evdev device\n * @param name The new, non-NULL, name to assign to this device.\n *\n * @note This function may be called before libevdev_set_fd(). A call to\n * libevdev_set_fd() will overwrite any previously set value.\n */\nvoid libevdev_set_name(struct libevdev *dev, const char *name);\n\n/**\n * @ingroup bits\n *\n * Retrieve the device's physical location, either as set by the caller or\n * as read from the kernel. The string returned is valid until\n * libevdev_free() or until libevdev_set_phys(), whichever comes earlier.\n *\n * Virtual devices such as uinput devices have no phys location.\n *\n * @param dev The evdev device, already initialized with libevdev_set_fd()\n *\n * @return The physical location of this device, or NULL if there is none\n *\n * @note This function is signal safe.\n */\nconst char * libevdev_get_phys(const struct libevdev *dev);\n\n/**\n * @ingroup kernel\n *\n * Change the device's physical location as returned by libevdev_get_phys().\n * This function destroys the string previously returned by\n * libevdev_get_phys(), a caller must take care that no references are kept.\n *\n * @param dev The evdev device\n * @param phys The new phys to assign to this device.\n *\n * @note This function may be called before libevdev_set_fd(). A call to\n * libevdev_set_fd() will overwrite any previously set value.\n */\nvoid libevdev_set_phys(struct libevdev *dev, const char *phys);\n\n/**\n * @ingroup bits\n *\n * Retrieve the device's unique identifier, either as set by the caller or\n * as read from the kernel. The string returned is valid until\n * libevdev_free() or until libevdev_set_uniq(), whichever comes earlier.\n *\n * @param dev The evdev device, already initialized with libevdev_set_fd()\n *\n * @return The unique identifier for this device, or NULL if there is none\n *\n * @note This function is signal safe.\n */\nconst char * libevdev_get_uniq(const struct libevdev *dev);\n\n/**\n * @ingroup kernel\n *\n * Change the device's unique identifier as returned by libevdev_get_uniq().\n * This function destroys the string previously returned by\n * libevdev_get_uniq(), a caller must take care that no references are kept.\n *\n * @param dev The evdev device\n * @param uniq The new uniq to assign to this device.\n *\n * @note This function may be called before libevdev_set_fd(). A call to\n * libevdev_set_fd() will overwrite any previously set value.\n */\nvoid libevdev_set_uniq(struct libevdev *dev, const char *uniq);\n\n/**\n * @ingroup bits\n *\n * @param dev The evdev device, already initialized with libevdev_set_fd()\n *\n * @return The device's product ID\n *\n * @note This function is signal-safe.\n */\nint libevdev_get_id_product(const struct libevdev *dev);\n\n/**\n * @ingroup kernel\n *\n * @param dev The evdev device\n * @param product_id The product ID to assign to this device\n *\n * @note This function may be called before libevdev_set_fd(). A call to\n * libevdev_set_fd() will overwrite any previously set value.\n */\nvoid libevdev_set_id_product(struct libevdev *dev, int product_id);\n\n/**\n * @ingroup bits\n *\n * @param dev The evdev device, already initialized with libevdev_set_fd()\n *\n * @return The device's vendor ID\n *\n * @note This function is signal-safe.\n */\nint libevdev_get_id_vendor(const struct libevdev *dev);\n\n/**\n * @ingroup kernel\n *\n * @param dev The evdev device\n * @param vendor_id The vendor ID to assign to this device\n *\n * @note This function may be called before libevdev_set_fd(). A call to\n * libevdev_set_fd() will overwrite any previously set value.\n */\nvoid libevdev_set_id_vendor(struct libevdev *dev, int vendor_id);\n\n/**\n * @ingroup bits\n *\n * @param dev The evdev device, already initialized with libevdev_set_fd()\n *\n * @return The device's bus type\n *\n * @note This function is signal-safe.\n */\nint libevdev_get_id_bustype(const struct libevdev *dev);\n\n/**\n * @ingroup kernel\n *\n * @param dev The evdev device\n * @param bustype The bustype to assign to this device\n *\n * @note This function may be called before libevdev_set_fd(). A call to\n * libevdev_set_fd() will overwrite any previously set value.\n */\nvoid libevdev_set_id_bustype(struct libevdev *dev, int bustype);\n\n/**\n * @ingroup bits\n *\n * @param dev The evdev device, already initialized with libevdev_set_fd()\n *\n * @return The device's firmware version\n *\n * @note This function is signal-safe.\n */\nint libevdev_get_id_version(const struct libevdev *dev);\n\n/**\n * @ingroup kernel\n *\n * @param dev The evdev device\n * @param version The version to assign to this device\n *\n * @note This function may be called before libevdev_set_fd(). A call to\n * libevdev_set_fd() will overwrite any previously set value.\n */\nvoid libevdev_set_id_version(struct libevdev *dev, int version);\n\n/**\n * @ingroup bits\n *\n * @param dev The evdev device, already initialized with libevdev_set_fd()\n *\n * @return The driver version for this device\n *\n * @note This function is signal-safe.\n */\nint libevdev_get_driver_version(const struct libevdev *dev);\n\n/**\n * @ingroup bits\n *\n * @param dev The evdev device, already initialized with libevdev_set_fd()\n * @param prop The input property to query for, one of INPUT_PROP_...\n *\n * @return 1 if the device provides this input property, or 0 otherwise.\n *\n * @note This function is signal-safe\n */\nint libevdev_has_property(const struct libevdev *dev, unsigned int prop);\n\n/**\n * @ingroup kernel\n *\n * @param dev The evdev device\n * @param prop The input property to enable, one of INPUT_PROP_...\n *\n * @return 0 on success or -1 on failure\n *\n * @note This function may be called before libevdev_set_fd(). A call to\n * libevdev_set_fd() will overwrite any previously set value.\n */\nint libevdev_enable_property(struct libevdev *dev, unsigned int prop);\n\n/**\n * @ingroup bits\n *\n * @param dev The evdev device, already initialized with libevdev_set_fd()\n * @param type The event type to query for, one of EV_SYN, EV_REL, etc.\n *\n * @return 1 if the device supports this event type, or 0 otherwise.\n *\n * @note This function is signal-safe.\n */\nint libevdev_has_event_type(const struct libevdev *dev, unsigned int type);\n\n/**\n * @ingroup bits\n *\n * @param dev The evdev device, already initialized with libevdev_set_fd()\n * @param type The event type for the code to query (EV_SYN, EV_REL, etc.)\n * @param code The event code to query for, one of ABS_X, REL_X, etc.\n *\n * @return 1 if the device supports this event type and code, or 0 otherwise.\n *\n * @note This function is signal-safe.\n */\nint libevdev_has_event_code(const struct libevdev *dev, unsigned int type, unsigned int code);\n\n/**\n * @ingroup bits\n *\n * Get the minimum axis value for the given axis, as advertised by the kernel.\n *\n * @param dev The evdev device, already initialized with libevdev_set_fd()\n * @param code The EV_ABS event code to query for, one of ABS_X, ABS_Y, etc.\n *\n * @return axis minimum for the given axis or 0 if the axis is invalid\n *\n * @note This function is signal-safe.\n */\nint libevdev_get_abs_minimum(const struct libevdev *dev, unsigned int code);\n/**\n * @ingroup bits\n *\n * Get the maximum axis value for the given axis, as advertised by the kernel.\n *\n * @param dev The evdev device, already initialized with libevdev_set_fd()\n * @param code The EV_ABS event code to query for, one of ABS_X, ABS_Y, etc.\n *\n * @return axis maximum for the given axis or 0 if the axis is invalid\n *\n * @note This function is signal-safe.\n */\nint libevdev_get_abs_maximum(const struct libevdev *dev, unsigned int code);\n/**\n * @ingroup bits\n *\n * Get the axis fuzz for the given axis, as advertised by the kernel.\n *\n * @param dev The evdev device, already initialized with libevdev_set_fd()\n * @param code The EV_ABS event code to query for, one of ABS_X, ABS_Y, etc.\n *\n * @return axis fuzz for the given axis or 0 if the axis is invalid\n *\n * @note This function is signal-safe.\n */\nint libevdev_get_abs_fuzz(const struct libevdev *dev, unsigned int code);\n/**\n * @ingroup bits\n *\n * Get the axis flat for the given axis, as advertised by the kernel.\n *\n * @param dev The evdev device, already initialized with libevdev_set_fd()\n * @param code The EV_ABS event code to query for, one of ABS_X, ABS_Y, etc.\n *\n * @return axis flat for the given axis or 0 if the axis is invalid\n *\n * @note This function is signal-safe.\n */\nint libevdev_get_abs_flat(const struct libevdev *dev, unsigned int code);\n/**\n * @ingroup bits\n *\n * Get the axis resolution for the given axis, as advertised by the kernel.\n *\n * @param dev The evdev device, already initialized with libevdev_set_fd()\n * @param code The EV_ABS event code to query for, one of ABS_X, ABS_Y, etc.\n *\n * @return axis resolution for the given axis or 0 if the axis is invalid\n *\n * @note This function is signal-safe.\n */\nint libevdev_get_abs_resolution(const struct libevdev *dev, unsigned int code);\n\n/**\n * @ingroup bits\n *\n * Get the axis info for the given axis, as advertised by the kernel.\n *\n * @param dev The evdev device, already initialized with libevdev_set_fd()\n * @param code The EV_ABS event code to query for, one of ABS_X, ABS_Y, etc.\n *\n * @return The input_absinfo for the given code, or NULL if the device does\n * not support this event code.\n *\n * @note This function is signal-safe.\n */\nconst struct input_absinfo* libevdev_get_abs_info(const struct libevdev *dev, unsigned int code);\n\n/**\n * @ingroup bits\n *\n * Behaviour of this function is undefined if the device does not provide\n * the event.\n *\n * If the device supports ABS_MT_SLOT, the value returned for any ABS_MT_*\n * event code is the value of the currently active slot. You should use\n * libevdev_get_slot_value() instead.\n *\n * @param dev The evdev device, already initialized with libevdev_set_fd()\n * @param type The event type for the code to query (EV_SYN, EV_REL, etc.)\n * @param code The event code to query for, one of ABS_X, REL_X, etc.\n *\n * @return The current value of the event.\n *\n * @note This function is signal-safe.\n * @note The value for ABS_MT_ events is undefined, use\n * libevdev_get_slot_value() instead\n *\n * @see libevdev_get_slot_value\n */\nint libevdev_get_event_value(const struct libevdev *dev, unsigned int type, unsigned int code);\n\n/**\n * @ingroup kernel\n *\n * Set the value for a given event type and code. This only makes sense for\n * some event types, e.g. setting the value for EV_REL is pointless.\n *\n * This is a local modification only affecting only this representation of\n * this device. A future call to libevdev_get_event_value() will return this\n * value, unless the value was overwritten by an event.\n *\n * If the device supports ABS_MT_SLOT, the value set for any ABS_MT_*\n * event code is the value of the currently active slot. You should use\n * libevdev_set_slot_value() instead.\n *\n * If the device supports ABS_MT_SLOT and the type is EV_ABS and the code is\n * ABS_MT_SLOT, the value must be a positive number less then the number of\n * slots on the device. Otherwise, libevdev_set_event_value() returns -1.\n *\n * @param dev The evdev device, already initialized with libevdev_set_fd()\n * @param type The event type for the code to query (EV_SYN, EV_REL, etc.)\n * @param code The event code to set the value for, one of ABS_X, LED_NUML, etc.\n * @param value The new value to set\n *\n * @return 0 on success, or -1 on failure.\n * @retval -1 the device does not have the event type or code enabled, or the code is outside the\n * allowed limits for the given type, or the type cannot be set, or the\n * value is not permitted for the given code.\n *\n * @see libevdev_set_slot_value\n * @see libevdev_get_event_value\n */\nint libevdev_set_event_value(struct libevdev *dev, unsigned int type, unsigned int code, int value);\n\n/**\n * @ingroup bits\n *\n * Fetch the current value of the event type. This is a shortcut for\n *\n @code\n   if (libevdev_has_event_type(dev, t) && libevdev_has_event_code(dev, t, c))\n        val = libevdev_get_event_value(dev, t, c);\n @endcode\n *\n * @param dev The evdev device, already initialized with libevdev_set_fd()\n * @param type The event type for the code to query (EV_SYN, EV_REL, etc.)\n * @param code The event code to query for, one of ABS_X, REL_X, etc.\n * @param[out] value The current value of this axis returned.\n *\n * @return If the device supports this event type and code, the return value is\n * non-zero and value is set to the current value of this axis. Otherwise,\n * 0 is returned and value is unmodified.\n *\n * @note This function is signal-safe.\n * @note The value for ABS_MT_ events is undefined, use\n * libevdev_fetch_slot_value() instead\n *\n * @see libevdev_fetch_slot_value\n */\nint libevdev_fetch_event_value(const struct libevdev *dev, unsigned int type, unsigned int code, int *value);\n\n/**\n * @ingroup mt\n *\n * Return the current value of the code for the given slot.\n *\n * The return value is undefined for a slot exceeding the available slots on\n * the device, for a code that is not in the permitted ABS_MT range or for a\n * device that does not have slots.\n *\n * @param dev The evdev device, already initialized with libevdev_set_fd()\n * @param slot The numerical slot number, must be smaller than the total number\n * of slots on this device\n * @param code The event code to query for, one of ABS_MT_POSITION_X, etc.\n *\n * @note This function is signal-safe.\n * @note The value for events other than ABS_MT_ is undefined, use\n * libevdev_fetch_value() instead\n *\n * @see libevdev_get_event_value\n */\nint libevdev_get_slot_value(const struct libevdev *dev, unsigned int slot, unsigned int code);\n\n/**\n * @ingroup kernel\n *\n * Set the value for a given code for the given slot.\n *\n * This is a local modification only affecting only this representation of\n * this device. A future call to libevdev_get_slot_value() will return this\n * value, unless the value was overwritten by an event.\n *\n * This function does not set event values for axes outside the ABS_MT range,\n * use libevdev_set_event_value() instead.\n *\n * @param dev The evdev device, already initialized with libevdev_set_fd()\n * @param slot The numerical slot number, must be smaller than the total number\n * of slots on this device\n * @param code The event code to set the value for, one of ABS_MT_POSITION_X, etc.\n * @param value The new value to set\n *\n * @return 0 on success, or -1 on failure.\n * @retval -1 the device does not have the event code enabled, or the code is\n * outside the allowed limits for multitouch events, or the slot number is outside\n * the limits for this device, or the device does not support multitouch events.\n *\n * @see libevdev_set_event_value\n * @see libevdev_get_slot_value\n */\nint libevdev_set_slot_value(struct libevdev *dev, unsigned int slot, unsigned int code, int value);\n\n/**\n * @ingroup mt\n *\n * Fetch the current value of the code for the given slot. This is a shortcut for\n *\n @code\n   if (libevdev_has_event_type(dev, EV_ABS) &&\n       libevdev_has_event_code(dev, EV_ABS, c) &&\n       slot < device->number_of_slots)\n       val = libevdev_get_slot_value(dev, slot, c);\n @endcode\n *\n * @param dev The evdev device, already initialized with libevdev_set_fd()\n * @param slot The numerical slot number, must be smaller than the total number\n * of slots on this * device\n * @param[out] value The current value of this axis returned.\n *\n * @param code The event code to query for, one of ABS_MT_POSITION_X, etc.\n * @return If the device supports this event code, the return value is\n * non-zero and value is set to the current value of this axis. Otherwise, or\n * if the event code is not an ABS_MT_* event code, 0 is returned and value\n * is unmodified.\n *\n * @note This function is signal-safe.\n */\nint libevdev_fetch_slot_value(const struct libevdev *dev, unsigned int slot, unsigned int code, int *value);\n\n/**\n * @ingroup mt\n *\n * Get the number of slots supported by this device.\n *\n * @param dev The evdev device, already initialized with libevdev_set_fd()\n *\n * @return The number of slots supported, or -1 if the device does not provide\n * any slots\n *\n * @note A device may provide ABS_MT_SLOT but a total number of 0 slots. Hence\n * the return value of -1 for \"device does not provide slots at all\"\n */\nint libevdev_get_num_slots(const struct libevdev *dev);\n\n/**\n * @ingroup mt\n *\n * Get the currently active slot. This may differ from the value\n * an ioctl may return at this time as events may have been read off the fd\n * since changing the slot value but those events are still in the buffer\n * waiting to be processed. The returned value is the value a caller would\n * see if it were to process events manually one-by-one.\n *\n * @param dev The evdev device, already initialized with libevdev_set_fd()\n *\n * @return the currently active slot (logically)\n *\n * @note This function is signal-safe.\n */\nint libevdev_get_current_slot(const struct libevdev *dev);\n\n/**\n * @ingroup kernel\n *\n * Change the minimum for the given EV_ABS event code, if the code exists.\n * This function has no effect if libevdev_has_event_code() returns false for\n * this code.\n *\n * @param dev The evdev device, already initialized with libevdev_set_fd()\n * @param code One of ABS_X, ABS_Y, ...\n * @param min The new minimum for this axis\n */\nvoid libevdev_set_abs_minimum(struct libevdev *dev, unsigned int code, int min);\n\n/**\n * @ingroup kernel\n *\n * Change the maximum for the given EV_ABS event code, if the code exists.\n * This function has no effect if libevdev_has_event_code() returns false for\n * this code.\n *\n * @param dev The evdev device, already initialized with libevdev_set_fd()\n * @param code One of ABS_X, ABS_Y, ...\n * @param max The new maxium for this axis\n */\nvoid libevdev_set_abs_maximum(struct libevdev *dev, unsigned int code, int max);\n\n/**\n * @ingroup kernel\n *\n * Change the fuzz for the given EV_ABS event code, if the code exists.\n * This function has no effect if libevdev_has_event_code() returns false for\n * this code.\n *\n * @param dev The evdev device, already initialized with libevdev_set_fd()\n * @param code One of ABS_X, ABS_Y, ...\n * @param fuzz The new fuzz for this axis\n */\nvoid libevdev_set_abs_fuzz(struct libevdev *dev, unsigned int code, int fuzz);\n\n/**\n * @ingroup kernel\n *\n * Change the flat for the given EV_ABS event code, if the code exists.\n * This function has no effect if libevdev_has_event_code() returns false for\n * this code.\n *\n * @param dev The evdev device, already initialized with libevdev_set_fd()\n * @param code One of ABS_X, ABS_Y, ...\n * @param flat The new flat for this axis\n */\nvoid libevdev_set_abs_flat(struct libevdev *dev, unsigned int code, int flat);\n\n/**\n * @ingroup kernel\n *\n * Change the resolution for the given EV_ABS event code, if the code exists.\n * This function has no effect if libevdev_has_event_code() returns false for\n * this code.\n *\n * @param dev The evdev device, already initialized with libevdev_set_fd()\n * @param code One of ABS_X, ABS_Y, ...\n * @param resolution The new axis resolution\n */\nvoid libevdev_set_abs_resolution(struct libevdev *dev, unsigned int code, int resolution);\n\n/**\n * @ingroup kernel\n *\n * Change the abs info for the given EV_ABS event code, if the code exists.\n * This function has no effect if libevdev_has_event_code() returns false for\n * this code.\n *\n * @param dev The evdev device, already initialized with libevdev_set_fd()\n * @param code One of ABS_X, ABS_Y, ...\n * @param abs The new absolute axis data (min, max, fuzz, flat, resolution)\n */\nvoid libevdev_set_abs_info(struct libevdev *dev, unsigned int code, const struct input_absinfo *abs);\n\n/**\n * @ingroup kernel\n *\n * Forcibly enable an event type on this device, even if the underlying\n * device does not support it. While this cannot make the device actually\n * report such events, it will now return true for libevdev_has_event_type().\n *\n * This is a local modification only affecting only this representation of\n * this device.\n *\n * @param dev The evdev device, already initialized with libevdev_set_fd()\n * @param type The event type to enable (EV_ABS, EV_KEY, ...)\n *\n * @return 0 on success or -1 otherwise\n *\n * @see libevdev_has_event_type\n */\nint libevdev_enable_event_type(struct libevdev *dev, unsigned int type);\n\n/**\n * @ingroup kernel\n *\n * Forcibly disable an event type on this device, even if the underlying\n * device provides it. This effectively mutes the respective set of\n * events. libevdev will filter any events matching this type and none will\n * reach the caller. libevdev_has_event_type() will return false for this\n * type.\n *\n * In most cases, a caller likely only wants to disable a single code, not\n * the whole type. Use libevdev_disable_event_code() for that.\n *\n * Disabling EV_SYN will not work. Don't shoot yourself in the foot.\n * It hurts.\n *\n * This is a local modification only affecting only this representation of\n * this device.\n *\n * @param dev The evdev device, already initialized with libevdev_set_fd()\n * @param type The event type to disable (EV_ABS, EV_KEY, ...)\n *\n * @return 0 on success or -1 otherwise\n *\n * @see libevdev_has_event_type\n * @see libevdev_disable_event_type\n */\nint libevdev_disable_event_type(struct libevdev *dev, unsigned int type);\n\n/**\n * @ingroup kernel\n *\n * Forcibly enable an event code on this device, even if the underlying\n * device does not support it. While this cannot make the device actually\n * report such events, it will now return true for libevdev_has_event_code().\n *\n * The last argument depends on the type and code:\n * - If type is EV_ABS, data must be a pointer to a struct input_absinfo\n *   containing the data for this axis.\n * - If type is EV_REP, daat must be a pointer to a int containing the data\n *   for this axis\n * - For all other types, the argument must be NULL.\n *\n * This function calls libevdev_enable_event_type() if necessary.\n *\n * This is a local modification only affecting only this representation of\n * this device.\n *\n * If this function is called with a type of EV_ABS and EV_REP on a device\n * that already has the given event code enabled, the values in data\n * overwrite the previous values.\n *\n * @param dev The evdev device, already initialized with libevdev_set_fd()\n * @param type The event type to enable (EV_ABS, EV_KEY, ...)\n * @param code The event code to enable (ABS_X, REL_X, etc.)\n * @param data If type is EV_ABS, data points to a struct input_absinfo. If type is EV_REP, data\n * points to an integer. Otherwise, data must be NULL.\n *\n * @return 0 on success or -1 otherwise\n *\n * @see libevdev_enable_event_type\n */\nint libevdev_enable_event_code(struct libevdev *dev, unsigned int type, unsigned int code, const void *data);\n\n/**\n * @ingroup kernel\n *\n * Forcibly disable an event code on this device, even if the underlying\n * device provides it. This effectively mutes the respective set of\n * events. libevdev will filter any events matching this type and code and\n * none will reach the caller. libevdev_has_event_code() will return false for\n * this code.\n *\n * Disabling all event codes for a given type will not disable the event\n * type. Use libevdev_disable_event_type() for that.\n *\n * This is a local modification only affecting only this representation of\n * this device.\n *\n * Disabling codes of type EV_SYN will not work. Don't shoot yourself in the\n * foot. It hurts.\n *\n * @param dev The evdev device, already initialized with libevdev_set_fd()\n * @param type The event type to disable (EV_ABS, EV_KEY, ...)\n * @param code The event code to disable (ABS_X, REL_X, etc.)\n *\n * @return 0 on success or -1 otherwise\n *\n * @see libevdev_has_event_code\n * @see libevdev_disable_event_type\n */\nint libevdev_disable_event_code(struct libevdev *dev, unsigned int type, unsigned int code);\n\n/**\n * @ingroup kernel\n *\n * Set the device's EV_ABS axis to the value defined in the abs\n * parameter. This will be written to the kernel.\n *\n * @param dev The evdev device, already initialized with libevdev_set_fd()\n * @param code The EV_ABS event code to modify, one of ABS_X, ABS_Y, etc.\n * @param abs Axis info to set the kernel axis to\n *\n * @return 0 on success, or a negative errno on failure\n *\n * @see libevdev_enable_event_code\n */\nint libevdev_kernel_set_abs_info(struct libevdev *dev, unsigned int code, const struct input_absinfo *abs);\n\n\n/**\n * @ingroup kernel\n */\nenum libevdev_led_value {\n\tLIBEVDEV_LED_ON = 3, /**< Turn the LED on */\n\tLIBEVDEV_LED_OFF = 4 /**< Turn the LED off */\n};\n\n/**\n * @ingroup kernel\n *\n * Turn an LED on or off. Convenience function, if you need to modify multiple\n * LEDs simultaneously, use libevdev_kernel_set_led_values() instead.\n *\n * @note enabling an LED requires write permissions on the device's file descriptor.\n *\n * @param dev The evdev device, already initialized with libevdev_set_fd()\n * @param code The EV_LED event code to modify, one of LED_NUML, LED_CAPSL, ...\n * @param value Specifies whether to turn the LED on or off\n * @return 0 on success, or a negative errno on failure\n */\nint libevdev_kernel_set_led_value(struct libevdev *dev, unsigned int code, enum libevdev_led_value value);\n\n/**\n * @ingroup kernel\n *\n * Turn multiple LEDs on or off simultaneously. This function expects a pair\n * of LED codes and values to set them to, terminated by a -1. For example, to\n * switch the NumLock LED on but the CapsLock LED off, use:\n *\n @code\n     libevdev_kernel_set_led_values(dev, LED_NUML, LIBEVDEV_LED_ON,\n                                         LED_CAPSL, LIBEVDEV_LED_OFF,\n                                         -1);\n @endcode\n *\n * If any LED code or value is invalid, this function returns -EINVAL and no\n * LEDs are modified.\n *\n * @note enabling an LED requires write permissions on the device's file descriptor.\n *\n * @param dev The evdev device, already initialized with libevdev_set_fd()\n * @param ... A pair of LED_* event codes and libevdev_led_value_t, followed by\n * -1 to terminate the list.\n * @return 0 on success, or a negative errno on failure\n */\nint libevdev_kernel_set_led_values(struct libevdev *dev, ...);\n\n/**\n * @ingroup kernel\n *\n * Set the clock ID to be used for timestamps. Further events from this device\n * will report an event time based on the given clock.\n *\n * This is a modification only affecting this representation of\n * this device.\n *\n * @param dev The evdev device, already initialized with libevdev_set_fd()\n * @param clockid The clock to use for future events. Permitted values\n * are CLOCK_MONOTONIC and CLOCK_REALTIME (the default).\n * @return 0 on success, or a negative errno on failure\n */\nint libevdev_set_clock_id(struct libevdev *dev, int clockid);\n\n/**\n * @ingroup misc\n *\n * Helper function to check if an event is of a specific type. This is\n * virtually the same as:\n *\n *      ev->type == type\n *\n * with the exception that some sanity checks are performed to ensure type\n * is valid.\n *\n * @note The ranges for types are compiled into libevdev. If the kernel\n * changes the max value, libevdev will not automatically pick these up.\n *\n * @param ev The input event to check\n * @param type Input event type to compare the event against (EV_REL, EV_ABS,\n * etc.)\n *\n * @return 1 if the event type matches the given type, 0 otherwise (or if\n * type is invalid)\n */\nint libevdev_event_is_type(const struct input_event *ev, unsigned int type);\n\n/**\n * @ingroup misc\n *\n * Helper function to check if an event is of a specific type and code. This\n * is virtually the same as:\n *\n *      ev->type == type && ev->code == code\n *\n * with the exception that some sanity checks are performed to ensure type and\n * code are valid.\n *\n * @note The ranges for types and codes are compiled into libevdev. If the kernel\n * changes the max value, libevdev will not automatically pick these up.\n *\n * @param ev The input event to check\n * @param type Input event type to compare the event against (EV_REL, EV_ABS,\n * etc.)\n * @param code Input event code to compare the event against (ABS_X, REL_X,\n * etc.)\n *\n * @return 1 if the event type matches the given type and code, 0 otherwise\n * (or if type/code are invalid)\n */\nint libevdev_event_is_code(const struct input_event *ev, unsigned int type, unsigned int code);\n\n/**\n * @ingroup misc\n *\n * @param type The event type to return the name for.\n *\n * @return The name of the given event type (e.g. EV_ABS) or NULL for an\n * invalid type\n *\n * @note The list of names is compiled into libevdev. If the kernel adds new\n * defines for new event types, libevdev will not automatically pick these up.\n */\nconst char * libevdev_event_type_get_name(unsigned int type);\n/**\n * @ingroup misc\n *\n * @param type The event type for the code to query (EV_SYN, EV_REL, etc.)\n * @param code The event code to return the name for (e.g. ABS_X)\n *\n * @return The name of the given event code (e.g. ABS_X) or NULL for an\n * invalid type or code\n *\n * @note The list of names is compiled into libevdev. If the kernel adds new\n * defines for new event codes, libevdev will not automatically pick these up.\n */\nconst char * libevdev_event_code_get_name(unsigned int type, unsigned int code);\n\n/**\n * @ingroup misc\n *\n * @param prop The input prop to return the name for (e.g. INPUT_PROP_BUTTONPAD)\n *\n * @return The name of the given input prop (e.g. INPUT_PROP_BUTTONPAD) or NULL for an\n * invalid property\n *\n * @note The list of names is compiled into libevdev. If the kernel adds new\n * defines for new properties libevdev will not automatically pick these up.\n * @note On older kernels input properties may not be defined and\n * libevdev_property_get_name() will always return NULL\n */\nconst char* libevdev_property_get_name(unsigned int prop);\n\n/**\n * @ingroup misc\n *\n * @param type The event type to return the maximum for (EV_ABS, EV_REL, etc.). No max is defined for\n * EV_SYN.\n *\n * @return The max value defined for the given event type, e.g. ABS_MAX for a type of EV_ABS, or -1\n * for an invalid type.\n *\n * @note The max value is compiled into libevdev. If the kernel changes the\n * max value, libevdev will not automatically pick these up.\n */\nint libevdev_event_type_get_max(unsigned int type);\n\n/**\n * @ingroup misc\n *\n * Look up an event-type by its name. Event-types start with \"EV_\" followed by\n * the name (eg., \"EV_ABS\"). The \"EV_\" prefix must be included in the name. It\n * returns the constant assigned to the event-type or -1 if not found.\n *\n * @param name A non-NULL string describing an input-event type (\"EV_KEY\",\n * \"EV_ABS\", ...), zero-terminated.\n *\n * @return The given type constant for the passed name or -1 if not found.\n *\n * @note EV_MAX is also recognized.\n */\nint libevdev_event_type_from_name(const char *name);\n\n/**\n * @ingroup misc\n *\n * Look up an event-type by its name. Event-types start with \"EV_\" followed by\n * the name (eg., \"EV_ABS\"). The \"EV_\" prefix must be included in the name. It\n * returns the constant assigned to the event-type or -1 if not found.\n *\n * @param name A non-NULL string describing an input-event type (\"EV_KEY\",\n * \"EV_ABS\", ...).\n * @param len The length of the passed string excluding any terminating 0\n * character.\n *\n * @return The given type constant for the passed name or -1 if not found.\n *\n * @note EV_MAX is also recognized.\n */\nint libevdev_event_type_from_name_n(const char *name, size_t len);\n\n/**\n * @ingroup misc\n *\n * Look up an event code by its type and name. Event codes start with a fixed\n * prefix followed by their name (eg., \"ABS_X\"). The prefix must be included in\n * the name. It returns the constant assigned to the event code or -1 if not\n * found.\n *\n * You have to pass the event type where to look for the name. For instance, to\n * resolve \"ABS_X\" you need to pass EV_ABS as type and \"ABS_X\" as string.\n * Supported event codes are codes starting with SYN_, KEY_, BTN_, REL_, ABS_,\n * MSC_, SND_, SW_, LED_, REP_, FF_.\n *\n * @param type The event type (EV_* constant) where to look for the name.\n * @param name A non-NULL string describing an input-event code (\"KEY_A\",\n * \"ABS_X\", \"BTN_Y\", ...), zero-terminated.\n *\n * @return The given code constant for the passed name or -1 if not found.\n */\nint libevdev_event_code_from_name(unsigned int type, const char *name);\n\n/**\n * @ingroup misc\n *\n * Look up an event code by its type and name. Event codes start with a fixed\n * prefix followed by their name (eg., \"ABS_X\"). The prefix must be included in\n * the name. It returns the constant assigned to the event code or -1 if not\n * found.\n *\n * You have to pass the event type where to look for the name. For instance, to\n * resolve \"ABS_X\" you need to pass EV_ABS as type and \"ABS_X\" as string.\n * Supported event codes are codes starting with SYN_, KEY_, BTN_, REL_, ABS_,\n * MSC_, SND_, SW_, LED_, REP_, FF_.\n *\n * @param type The event type (EV_* constant) where to look for the name.\n * @param name A non-NULL string describing an input-event code (\"KEY_A\",\n * \"ABS_X\", \"BTN_Y\", ...).\n * @param len The length of the string in @p name excluding any terminating 0\n * character.\n *\n * @return The given code constant for the name or -1 if not found.\n */\nint libevdev_event_code_from_name_n(unsigned int type, const char *name,\n\t\t\t\t    size_t len);\n\n/**\n * @ingroup misc\n *\n * Look up an input property by its name. Properties start with the fixed\n * prefix \"INPUT_PROP_\" followed by their name (eg., \"INPUT_PROP_POINTER\").\n * The prefix must be included in the name. It returns the constant assigned\n * to the property or -1 if not found.\n *\n * @param name A non-NULL string describing an input property\n *\n * @return The given code constant for the name or -1 if not found.\n */\nint libevdev_property_from_name(const char *name);\n\n/**\n * @ingroup misc\n *\n * Look up an input property by its name. Properties start with the fixed\n * prefix \"INPUT_PROP_\" followed by their name (eg., \"INPUT_PROP_POINTER\").\n * The prefix must be included in the name. It returns the constant assigned\n * to the property or -1 if not found.\n *\n * @param name A non-NULL string describing an input property\n * @param len The length of the string in @p name excluding any terminating 0\n * character.\n *\n * @return The given code constant for the name or -1 if not found.\n */\nint libevdev_property_from_name_n(const char *name, size_t len);\n\n/**\n * @ingroup bits\n *\n * Get the repeat delay and repeat period values for this device. This\n * function is a convenience function only, EV_REP is supported by\n * libevdev_get_event_value().\n *\n * @param dev The evdev device, already initialized with libevdev_set_fd()\n * @param delay If not null, set to the repeat delay value\n * @param period If not null, set to the repeat period value\n *\n * @return 0 on success, -1 if this device does not have repeat settings.\n *\n * @note This function is signal-safe\n *\n * @see libevdev_get_event_value\n */\nint libevdev_get_repeat(const struct libevdev *dev, int *delay, int *period);\n\n\n/********* DEPRECATED SECTION *********/\n#if defined(__GNUC__) && __GNUC__ >= 4\n#define LIBEVDEV_DEPRECATED __attribute__ ((deprecated))\n#else\n#define LIBEVDEV_DEPRECATED\n#endif\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* LIBEVDEV_H */\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/libudev.h",
    "content": "/***\n  This file is part of systemd.\n\n  Copyright 2008-2012 Kay Sievers <kay@vrfy.org>\n\n  systemd is free software; you can redistribute it and/or modify it\n  under the terms of the GNU Lesser General Public License as published by\n  the Free Software Foundation; either version 2.1 of the License, or\n  (at your option) any later version.\n\n  systemd is distributed in the hope that it will be useful, but\n  WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n  Lesser General Public License for more details.\n\n  You should have received a copy of the GNU Lesser General Public License\n  along with systemd; If not, see <http://www.gnu.org/licenses/>.\n***/\n\n#ifndef _LIBUDEV_H_\n#define _LIBUDEV_H_\n\n#include <stdarg.h>\n#include <sys/types.h>\n#include <sys/stat.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/*\n * udev - library context\n *\n * reads the udev config and system environment\n * allows custom logging\n */\nstruct udev;\nstruct udev *udev_ref(struct udev *udev);\nstruct udev *udev_unref(struct udev *udev);\nstruct udev *udev_new(void);\nvoid udev_set_log_fn(struct udev *udev,\n                            void (*log_fn)(struct udev *udev,\n                                           int priority, const char *file, int line, const char *fn,\n                                           const char *format, va_list args));\nint udev_get_log_priority(struct udev *udev);\nvoid udev_set_log_priority(struct udev *udev, int priority);\nvoid *udev_get_userdata(struct udev *udev);\nvoid udev_set_userdata(struct udev *udev, void *userdata);\n\n/*\n * udev_list\n *\n * access to libudev generated lists\n */\nstruct udev_list_entry;\nstruct udev_list_entry *udev_list_entry_get_next(struct udev_list_entry *list_entry);\nstruct udev_list_entry *udev_list_entry_get_by_name(struct udev_list_entry *list_entry, const char *name);\nconst char *udev_list_entry_get_name(struct udev_list_entry *list_entry);\nconst char *udev_list_entry_get_value(struct udev_list_entry *list_entry);\n/**\n * udev_list_entry_foreach:\n * @list_entry: entry to store the current position\n * @first_entry: first entry to start with\n *\n * Helper to iterate over all entries of a list.\n */\n#define udev_list_entry_foreach(list_entry, first_entry) \\\n        for (list_entry = first_entry; \\\n             list_entry != NULL; \\\n             list_entry = udev_list_entry_get_next(list_entry))\n\n/*\n * udev_device\n *\n * access to sysfs/kernel devices\n */\nstruct udev_device;\nstruct udev_device *udev_device_ref(struct udev_device *udev_device);\nstruct udev_device *udev_device_unref(struct udev_device *udev_device);\nstruct udev *udev_device_get_udev(struct udev_device *udev_device);\nstruct udev_device *udev_device_new_from_syspath(struct udev *udev, const char *syspath);\nstruct udev_device *udev_device_new_from_devnum(struct udev *udev, char type, dev_t devnum);\nstruct udev_device *udev_device_new_from_subsystem_sysname(struct udev *udev, const char *subsystem, const char *sysname);\nstruct udev_device *udev_device_new_from_device_id(struct udev *udev, const char *id);\nstruct udev_device *udev_device_new_from_environment(struct udev *udev);\n/* udev_device_get_parent_*() does not take a reference on the returned device, it is automatically unref'd with the parent */\nstruct udev_device *udev_device_get_parent(struct udev_device *udev_device);\nstruct udev_device *udev_device_get_parent_with_subsystem_devtype(struct udev_device *udev_device,\n                                                                  const char *subsystem, const char *devtype);\n/* retrieve device properties */\nconst char *udev_device_get_devpath(struct udev_device *udev_device);\nconst char *udev_device_get_subsystem(struct udev_device *udev_device);\nconst char *udev_device_get_devtype(struct udev_device *udev_device);\nconst char *udev_device_get_syspath(struct udev_device *udev_device);\nconst char *udev_device_get_sysname(struct udev_device *udev_device);\nconst char *udev_device_get_sysnum(struct udev_device *udev_device);\nconst char *udev_device_get_devnode(struct udev_device *udev_device);\nint udev_device_get_is_initialized(struct udev_device *udev_device);\nstruct udev_list_entry *udev_device_get_devlinks_list_entry(struct udev_device *udev_device);\nstruct udev_list_entry *udev_device_get_properties_list_entry(struct udev_device *udev_device);\nstruct udev_list_entry *udev_device_get_tags_list_entry(struct udev_device *udev_device);\nstruct udev_list_entry *udev_device_get_sysattr_list_entry(struct udev_device *udev_device);\nconst char *udev_device_get_property_value(struct udev_device *udev_device, const char *key);\nconst char *udev_device_get_driver(struct udev_device *udev_device);\ndev_t udev_device_get_devnum(struct udev_device *udev_device);\nconst char *udev_device_get_action(struct udev_device *udev_device);\nunsigned long long int udev_device_get_seqnum(struct udev_device *udev_device);\nunsigned long long int udev_device_get_usec_since_initialized(struct udev_device *udev_device);\nconst char *udev_device_get_sysattr_value(struct udev_device *udev_device, const char *sysattr);\nint udev_device_set_sysattr_value(struct udev_device *udev_device, const char *sysattr, char *value);\nint udev_device_has_tag(struct udev_device *udev_device, const char *tag);\n\n/*\n * udev_monitor\n *\n * access to kernel uevents and udev events\n */\nstruct udev_monitor;\nstruct udev_monitor *udev_monitor_ref(struct udev_monitor *udev_monitor);\nstruct udev_monitor *udev_monitor_unref(struct udev_monitor *udev_monitor);\nstruct udev *udev_monitor_get_udev(struct udev_monitor *udev_monitor);\n/* kernel and udev generated events over netlink */\nstruct udev_monitor *udev_monitor_new_from_netlink(struct udev *udev, const char *name);\n/* bind socket */\nint udev_monitor_enable_receiving(struct udev_monitor *udev_monitor);\nint udev_monitor_set_receive_buffer_size(struct udev_monitor *udev_monitor, int size);\nint udev_monitor_get_fd(struct udev_monitor *udev_monitor);\nstruct udev_device *udev_monitor_receive_device(struct udev_monitor *udev_monitor);\n/* in-kernel socket filters to select messages that get delivered to a listener */\nint udev_monitor_filter_add_match_subsystem_devtype(struct udev_monitor *udev_monitor,\n                                                    const char *subsystem, const char *devtype);\nint udev_monitor_filter_add_match_tag(struct udev_monitor *udev_monitor, const char *tag);\nint udev_monitor_filter_update(struct udev_monitor *udev_monitor);\nint udev_monitor_filter_remove(struct udev_monitor *udev_monitor);\n\n/*\n * udev_enumerate\n *\n * search sysfs for specific devices and provide a sorted list\n */\nstruct udev_enumerate;\nstruct udev_enumerate *udev_enumerate_ref(struct udev_enumerate *udev_enumerate);\nstruct udev_enumerate *udev_enumerate_unref(struct udev_enumerate *udev_enumerate);\nstruct udev *udev_enumerate_get_udev(struct udev_enumerate *udev_enumerate);\nstruct udev_enumerate *udev_enumerate_new(struct udev *udev);\n/* device properties filter */\nint udev_enumerate_add_match_subsystem(struct udev_enumerate *udev_enumerate, const char *subsystem);\nint udev_enumerate_add_nomatch_subsystem(struct udev_enumerate *udev_enumerate, const char *subsystem);\nint udev_enumerate_add_match_sysattr(struct udev_enumerate *udev_enumerate, const char *sysattr, const char *value);\nint udev_enumerate_add_nomatch_sysattr(struct udev_enumerate *udev_enumerate, const char *sysattr, const char *value);\nint udev_enumerate_add_match_property(struct udev_enumerate *udev_enumerate, const char *property, const char *value);\nint udev_enumerate_add_match_sysname(struct udev_enumerate *udev_enumerate, const char *sysname);\nint udev_enumerate_add_match_tag(struct udev_enumerate *udev_enumerate, const char *tag);\nint udev_enumerate_add_match_parent(struct udev_enumerate *udev_enumerate, struct udev_device *parent);\nint udev_enumerate_add_match_is_initialized(struct udev_enumerate *udev_enumerate);\nint udev_enumerate_add_syspath(struct udev_enumerate *udev_enumerate, const char *syspath);\n/* run enumeration with active filters */\nint udev_enumerate_scan_devices(struct udev_enumerate *udev_enumerate);\nint udev_enumerate_scan_subsystems(struct udev_enumerate *udev_enumerate);\n/* return device list */\nstruct udev_list_entry *udev_enumerate_get_list_entry(struct udev_enumerate *udev_enumerate);\n\n/*\n * udev_queue\n *\n * access to the currently running udev events\n */\nstruct udev_queue;\nstruct udev_queue *udev_queue_ref(struct udev_queue *udev_queue);\nstruct udev_queue *udev_queue_unref(struct udev_queue *udev_queue);\nstruct udev *udev_queue_get_udev(struct udev_queue *udev_queue);\nstruct udev_queue *udev_queue_new(struct udev *udev);\nunsigned long long int udev_queue_get_kernel_seqnum(struct udev_queue *udev_queue) __attribute__ ((deprecated));\nunsigned long long int udev_queue_get_udev_seqnum(struct udev_queue *udev_queue) __attribute__ ((deprecated));\nint udev_queue_get_udev_is_active(struct udev_queue *udev_queue);\nint udev_queue_get_queue_is_empty(struct udev_queue *udev_queue);\nint udev_queue_get_seqnum_is_finished(struct udev_queue *udev_queue, unsigned long long int seqnum) __attribute__ ((deprecated));\nint udev_queue_get_seqnum_sequence_is_finished(struct udev_queue *udev_queue,\n                                               unsigned long long int start, unsigned long long int end) __attribute__ ((deprecated));\nint udev_queue_get_fd(struct udev_queue *udev_queue);\nint udev_queue_flush(struct udev_queue *udev_queue);\nstruct udev_list_entry *udev_queue_get_queued_list_entry(struct udev_queue *udev_queue) __attribute__ ((deprecated));\n\n/*\n *  udev_hwdb\n *\n *  access to the static hardware properties database\n */\nstruct udev_hwdb;\nstruct udev_hwdb *udev_hwdb_new(struct udev *udev);\nstruct udev_hwdb *udev_hwdb_ref(struct udev_hwdb *hwdb);\nstruct udev_hwdb *udev_hwdb_unref(struct udev_hwdb *hwdb);\nstruct udev_list_entry *udev_hwdb_get_properties_list_entry(struct udev_hwdb *hwdb, const char *modalias, unsigned int flags);\n\n/*\n * udev_util\n *\n * udev specific utilities\n */\nint udev_util_encode_string(const char *str, char *str_enc, size_t len);\n\n\n#ifdef __cplusplus\n} /* extern \"C\" */\n#endif\n\n#endif\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/md5/md5.h",
    "content": "/* MD5\n converted to C++ class by Frank Thilo (thilo@unix-ag.org)\n for bzflag (http://www.bzflag.org)\n\n   based on:\n\n   md5.h and md5.c\n   reference implementation of RFC 1321\n\n   Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All\nrights reserved.\n\nLicense to copy and use this software is granted provided that it\nis identified as the \"RSA Data Security, Inc. MD5 Message-Digest\nAlgorithm\" in all material mentioning or referencing this software\nor this function.\n\nLicense is also granted to make and use derivative works provided\nthat such works are identified as \"derived from the RSA Data\nSecurity, Inc. MD5 Message-Digest Algorithm\" in all material\nmentioning or referencing the derived work.\n\nRSA Data Security, Inc. makes no representations concerning either\nthe merchantability of this software or the suitability of this\nsoftware for any particular purpose. It is provided \"as is\"\nwithout express or implied warranty of any kind.\n\nThese notices must be retained in any copies of any part of this\ndocumentation and/or software.\n\n*/\n\n#ifndef BZF_MD5_H\n#define BZF_MD5_H\n\n#include <cstring>\n#include <iostream>\n\n\n// a small class for calculating MD5 hashes of strings or byte arrays\n// it is not meant to be fast or secure\n//\n// usage: 1) feed it blocks of uchars with update()\n//      2) finalize()\n//      3) get hexdigest() string\n//      or\n//      MD5(std::string).hexdigest()\n//\n// assumes that char is 8 bit and int is 32 bit\nclass MD5\n{\npublic:\n  typedef unsigned int size_type; // must be 32bit\n\n  MD5();\n  MD5(const std::string& text);\n  void update(const unsigned char *buf, size_type length);\n  void update(const char *buf, size_type length);\n  MD5& finalize();\n  std::string hexdigest() const;\n  friend std::ostream& operator<<(std::ostream&, MD5 md5);\n  std::string binarydigest() const {return std::string(reinterpret_cast<const char*>(digest), 16);} //Ian Copland, 09/06/2014: added accessor for the raw digest.\n    \nprivate:\n  void init();\n  typedef unsigned char uint1; //  8bit\n  typedef unsigned int uint4;  // 32bit\n  enum {blocksize = 64}; // VC6 won't eat a const static int here\n\n  void transform(const uint1 block[blocksize]);\n  static void decode(uint4 output[], const uint1 input[], size_type len);\n  static void encode(uint1 output[], const uint4 input[], size_type len);\n\n  bool finalized;\n  uint1 buffer[blocksize]; // bytes that didn't fit in last 64 byte chunk\n  uint4 count[2];   // 64bit counter for number of bits (lo, hi)\n  uint4 state[4];   // digest so far\n  uint1 digest[16]; // the result\n\n  // low level logic operations\n  static inline uint4 F(uint4 x, uint4 y, uint4 z);\n  static inline uint4 G(uint4 x, uint4 y, uint4 z);\n  static inline uint4 H(uint4 x, uint4 y, uint4 z);\n  static inline uint4 I(uint4 x, uint4 y, uint4 z);\n  static inline uint4 rotate_left(uint4 x, int n);\n  static inline void FF(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac);\n  static inline void GG(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac);\n  static inline void HH(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac);\n  static inline void II(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac);\n};\n\nstd::string md5(const std::string str);\n\n#endif\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/minizip/crypt.h",
    "content": "/* crypt.h -- base code for crypt/uncrypt ZIPfile\n\n\n   Version 1.01e, February 12th, 2005\n\n   Copyright (C) 1998-2005 Gilles Vollant\n\n   This code is a modified version of crypting code in Infozip distribution\n\n   The encryption/decryption parts of this source code (as opposed to the\n   non-echoing password parts) were originally written in Europe.  The\n   whole source package can be freely distributed, including from the USA.\n   (Prior to January 2000, re-export from the US was a violation of US law.)\n\n   This encryption code is a direct transcription of the algorithm from\n   Roger Schlafly, described by Phil Katz in the file appnote.txt.  This\n   file (appnote.txt) is distributed with the PKZIP program (even in the\n   version without encryption capabilities).\n\n   If you don't need crypting in your application, just define symbols\n   NOCRYPT and NOUNCRYPT.\n\n   This code support the \"Traditional PKWARE Encryption\".\n\n   The new AES encryption added on Zip format by Winzip (see the page\n   http://www.winzip.com/aes_info.htm ) and PKWare PKZip 5.x Strong\n   Encryption is not supported.\n*/\n\n#define CRC32(c, b) ((*(pcrc_32_tab+(((int)(c) ^ (b)) & 0xff))) ^ ((c) >> 8))\n\n/***********************************************************************\n * Return the next byte in the pseudo-random sequence\n */\nstatic int decrypt_byte(unsigned long* pkeys, const unsigned long* pcrc_32_tab)\n{\n    unsigned temp;  /* POTENTIAL BUG:  temp*(temp^1) may overflow in an\n                     * unpredictable manner on 16-bit systems; not a problem\n                     * with any known compiler so far, though */\n\n    temp = ((unsigned)(*(pkeys+2)) & 0xffff) | 2;\n    return (int)(((temp * (temp ^ 1)) >> 8) & 0xff);\n}\n\n/***********************************************************************\n * Update the encryption keys with the next byte of plain text\n */\nstatic int update_keys(unsigned long* pkeys,const unsigned long* pcrc_32_tab,int c)\n{\n    (*(pkeys+0)) = CRC32((*(pkeys+0)), c);\n    (*(pkeys+1)) += (*(pkeys+0)) & 0xff;\n    (*(pkeys+1)) = (*(pkeys+1)) * 134775813L + 1;\n    {\n      register int keyshift = (int)((*(pkeys+1)) >> 24);\n      (*(pkeys+2)) = CRC32((*(pkeys+2)), keyshift);\n    }\n    return c;\n}\n\n\n/***********************************************************************\n * Initialize the encryption keys and the random header according to\n * the given password.\n */\nstatic void init_keys(const char* passwd,unsigned long* pkeys,const unsigned long* pcrc_32_tab)\n{\n    *(pkeys+0) = 305419896L;\n    *(pkeys+1) = 591751049L;\n    *(pkeys+2) = 878082192L;\n    while (*passwd != '\\0') {\n        update_keys(pkeys,pcrc_32_tab,(int)*passwd);\n        passwd++;\n    }\n}\n\n#define zdecode(pkeys,pcrc_32_tab,c) \\\n    (update_keys(pkeys,pcrc_32_tab,c ^= decrypt_byte(pkeys,pcrc_32_tab)))\n\n#define zencode(pkeys,pcrc_32_tab,c,t) \\\n    (t=decrypt_byte(pkeys,pcrc_32_tab), update_keys(pkeys,pcrc_32_tab,c), t^(c))\n\n#ifdef INCLUDECRYPTINGCODE_IFCRYPTALLOWED\n\n#define RAND_HEAD_LEN  12\n   /* \"last resort\" source for second part of crypt seed pattern */\n#  ifndef ZCR_SEED2\n#    define ZCR_SEED2 3141592654UL     /* use PI as default pattern */\n#  endif\n\nstatic int crypthead(const char* passwd,      /* password string */\n                     unsigned char* buf,      /* where to write header */\n                     int bufSize,\n                     unsigned long* pkeys,\n                     const unsigned long* pcrc_32_tab,\n                     unsigned long crcForCrypting)\n{\n    int n;                       /* index in random header */\n    int t;                       /* temporary */\n    int c;                       /* random byte */\n    unsigned char header[RAND_HEAD_LEN-2]; /* random header */\n    static unsigned calls = 0;   /* ensure different random header each time */\n\n    if (bufSize<RAND_HEAD_LEN)\n      return 0;\n\n    /* First generate RAND_HEAD_LEN-2 random bytes. We encrypt the\n     * output of rand() to get less predictability, since rand() is\n     * often poorly implemented.\n     */\n    if (++calls == 1)\n    {\n        srand((unsigned)(time(NULL) ^ ZCR_SEED2));\n    }\n    init_keys(passwd, pkeys, pcrc_32_tab);\n    for (n = 0; n < RAND_HEAD_LEN-2; n++)\n    {\n        c = (rand() >> 7) & 0xff;\n        header[n] = (unsigned char)zencode(pkeys, pcrc_32_tab, c, t);\n    }\n    /* Encrypt random header (last two bytes is high word of crc) */\n    init_keys(passwd, pkeys, pcrc_32_tab);\n    for (n = 0; n < RAND_HEAD_LEN-2; n++)\n    {\n        buf[n] = (unsigned char)zencode(pkeys, pcrc_32_tab, header[n], t);\n    }\n    buf[n++] = (unsigned char)zencode(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 16) & 0xff, t);\n    buf[n++] = (unsigned char)zencode(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 24) & 0xff, t);\n    return n;\n}\n\n#endif\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/minizip/ioapi.h",
    "content": "/* ioapi.h -- IO base function header for compress/uncompress .zip\n   part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )\n\n         Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html )\n\n         Modifications for Zip64 support\n         Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )\n\n         For more info read MiniZip_info.txt\n\n         Changes\n\n    Oct-2009 - Defined ZPOS64_T to fpos_t on windows and u_int64_t on linux. (might need to find a better why for this)\n    Oct-2009 - Change to fseeko64, ftello64 and fopen64 so large files would work on linux.\n               More if/def section may be needed to support other platforms\n    Oct-2009 - Defined fxxxx64 calls to normal fopen/ftell/fseek so they would compile on windows.\n                          (but you should use iowin32.c for windows instead)\n\n*/\n\n#ifndef _ZLIBIOAPI64_H\n#define _ZLIBIOAPI64_H\n\n#if (!defined(_WIN32)) && (!defined(WIN32))\n\n  // Linux needs this to support file operation on files larger then 4+GB\n  // But might need better if/def to select just the platforms that needs them.\n\n        #ifndef __USE_FILE_OFFSET64\n                #define __USE_FILE_OFFSET64\n        #endif\n        #ifndef __USE_LARGEFILE64\n                #define __USE_LARGEFILE64\n        #endif\n        #ifndef _LARGEFILE64_SOURCE\n                #define _LARGEFILE64_SOURCE\n        #endif\n        #ifndef _FILE_OFFSET_BIT\n                #define _FILE_OFFSET_BIT 64\n        #endif\n#endif\n\n#include <stdio.h>\n#include <stdlib.h>\n#include \"zlib.h\"\n\n#if defined(USE_FILE32API)\n#define fopen64 fopen\n#define ftello64 ftell\n#define fseeko64 fseek\n#else\n#ifdef _MSC_VER\n #define fopen64 fopen\n #if (_MSC_VER >= 1400) && (!(defined(NO_MSCVER_FILE64_FUNC)))\n  #define ftello64 _ftelli64\n  #define fseeko64 _fseeki64\n #else // old MSC\n  #define ftello64 ftell\n  #define fseeko64 fseek\n #endif\n#endif\n#endif\n\n/*\n#ifndef ZPOS64_T\n  #ifdef _WIN32\n                #define ZPOS64_T fpos_t\n  #else\n    #include <stdint.h>\n    #define ZPOS64_T uint64_t\n  #endif\n#endif\n*/\n\n#ifdef HAVE_MINIZIP64_CONF_H\n#include \"mz64conf.h\"\n#endif\n\n/* a type choosen by DEFINE */\n#ifdef HAVE_64BIT_INT_CUSTOM\ntypedef  64BIT_INT_CUSTOM_TYPE ZPOS64_T;\n#else\n#ifdef HAS_STDINT_H\n#include \"stdint.h\"\ntypedef uint64_t ZPOS64_T;\n#else\n\n\n#if defined(_MSC_VER) || defined(__BORLANDC__)\ntypedef unsigned __int64 ZPOS64_T;\n#else\ntypedef unsigned long long int ZPOS64_T;\n#endif\n#endif\n#endif\n\n\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n\n#define ZLIB_FILEFUNC_SEEK_CUR (1)\n#define ZLIB_FILEFUNC_SEEK_END (2)\n#define ZLIB_FILEFUNC_SEEK_SET (0)\n\n#define ZLIB_FILEFUNC_MODE_READ      (1)\n#define ZLIB_FILEFUNC_MODE_WRITE     (2)\n#define ZLIB_FILEFUNC_MODE_READWRITEFILTER (3)\n\n#define ZLIB_FILEFUNC_MODE_EXISTING (4)\n#define ZLIB_FILEFUNC_MODE_CREATE   (8)\n\n\n#ifndef ZCALLBACK\n #if (defined(WIN32) || defined(_WIN32) || defined (WINDOWS) || defined (_WINDOWS)) && defined(CALLBACK) && defined (USEWINDOWS_CALLBACK)\n   #define ZCALLBACK CALLBACK\n #else\n   #define ZCALLBACK\n #endif\n#endif\n\n\n\n\ntypedef voidpf   (ZCALLBACK *open_file_func)      OF((voidpf opaque, const char* filename, int mode));\ntypedef uLong    (ZCALLBACK *read_file_func)      OF((voidpf opaque, voidpf stream, void* buf, uLong size));\ntypedef uLong    (ZCALLBACK *write_file_func)     OF((voidpf opaque, voidpf stream, const void* buf, uLong size));\ntypedef int      (ZCALLBACK *close_file_func)     OF((voidpf opaque, voidpf stream));\ntypedef int      (ZCALLBACK *testerror_file_func) OF((voidpf opaque, voidpf stream));\n\ntypedef long     (ZCALLBACK *tell_file_func)      OF((voidpf opaque, voidpf stream));\ntypedef long     (ZCALLBACK *seek_file_func)      OF((voidpf opaque, voidpf stream, uLong offset, int origin));\n\n\n/* here is the \"old\" 32 bits structure structure */\ntypedef struct zlib_filefunc_def_s\n{\n    open_file_func      zopen_file;\n    read_file_func      zread_file;\n    write_file_func     zwrite_file;\n    tell_file_func      ztell_file;\n    seek_file_func      zseek_file;\n    close_file_func     zclose_file;\n    testerror_file_func zerror_file;\n    voidpf              opaque;\n} zlib_filefunc_def;\n\ntypedef ZPOS64_T (ZCALLBACK *tell64_file_func)    OF((voidpf opaque, voidpf stream));\ntypedef long     (ZCALLBACK *seek64_file_func)    OF((voidpf opaque, voidpf stream, ZPOS64_T offset, int origin));\ntypedef voidpf   (ZCALLBACK *open64_file_func)    OF((voidpf opaque, const void* filename, int mode));\n\ntypedef struct zlib_filefunc64_def_s\n{\n    open64_file_func    zopen64_file;\n    read_file_func      zread_file;\n    write_file_func     zwrite_file;\n    tell64_file_func    ztell64_file;\n    seek64_file_func    zseek64_file;\n    close_file_func     zclose_file;\n    testerror_file_func zerror_file;\n    voidpf              opaque;\n} zlib_filefunc64_def;\n\nvoid fill_fopen64_filefunc OF((zlib_filefunc64_def* pzlib_filefunc_def));\nvoid fill_fopen_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def));\n\n/* now internal definition, only for zip.c and unzip.h */\ntypedef struct zlib_filefunc64_32_def_s\n{\n    zlib_filefunc64_def zfile_func64;\n    open_file_func      zopen32_file;\n    tell_file_func      ztell32_file;\n    seek_file_func      zseek32_file;\n} zlib_filefunc64_32_def;\n\n\n#define ZREAD64(filefunc,filestream,buf,size)     ((*((filefunc).zfile_func64.zread_file))   ((filefunc).zfile_func64.opaque,filestream,buf,size))\n#define ZWRITE64(filefunc,filestream,buf,size)    ((*((filefunc).zfile_func64.zwrite_file))  ((filefunc).zfile_func64.opaque,filestream,buf,size))\n//#define ZTELL64(filefunc,filestream)            ((*((filefunc).ztell64_file)) ((filefunc).opaque,filestream))\n//#define ZSEEK64(filefunc,filestream,pos,mode)   ((*((filefunc).zseek64_file)) ((filefunc).opaque,filestream,pos,mode))\n#define ZCLOSE64(filefunc,filestream)             ((*((filefunc).zfile_func64.zclose_file))  ((filefunc).zfile_func64.opaque,filestream))\n#define ZERROR64(filefunc,filestream)             ((*((filefunc).zfile_func64.zerror_file))  ((filefunc).zfile_func64.opaque,filestream))\n\nvoidpf call_zopen64 OF((const zlib_filefunc64_32_def* pfilefunc,const void*filename,int mode));\nlong    call_zseek64 OF((const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZPOS64_T offset, int origin));\nZPOS64_T call_ztell64 OF((const zlib_filefunc64_32_def* pfilefunc,voidpf filestream));\n\nvoid    fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filefunc64_32,const zlib_filefunc_def* p_filefunc32);\n\n#define ZOPEN64(filefunc,filename,mode)         (call_zopen64((&(filefunc)),(filename),(mode)))\n#define ZTELL64(filefunc,filestream)            (call_ztell64((&(filefunc)),(filestream)))\n#define ZSEEK64(filefunc,filestream,pos,mode)   (call_zseek64((&(filefunc)),(filestream),(pos),(mode)))\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/minizip/mztools.h",
    "content": "/*\n  Additional tools for Minizip\n  Code: Xavier Roche '2004\n  License: Same as ZLIB (www.gzip.org)\n*/\n\n#ifndef _zip_tools_H\n#define _zip_tools_H\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#ifndef _ZLIB_H\n#include \"zlib.h\"\n#endif\n\n#include \"unzip.h\"\n\n/* Repair a ZIP file (missing central directory)\n   file: file to recover\n   fileOut: output file after recovery\n   fileOutTmp: temporary file name used for recovery\n*/\nextern int ZEXPORT unzRepair(const char* file,\n                             const char* fileOut,\n                             const char* fileOutTmp,\n                             uLong* nRecovered,\n                             uLong* bytesRecovered);\n\n#endif\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/minizip/unzip.h",
    "content": "/* unzip.h -- IO for uncompress .zip files using zlib\n   Version 1.1, February 14h, 2010\n   part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )\n\n         Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html )\n\n         Modifications of Unzip for Zip64\n         Copyright (C) 2007-2008 Even Rouault\n\n         Modifications for Zip64 support on both zip and unzip\n         Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )\n\n         For more info read MiniZip_info.txt\n\n         ---------------------------------------------------------------------------------\n\n        Condition of use and distribution are the same than zlib :\n\n  This software is provided 'as-is', without any express or implied\n  warranty.  In no event will the authors be held liable for any damages\n  arising from the use of this software.\n\n  Permission is granted to anyone to use this software for any purpose,\n  including commercial applications, and to alter it and redistribute it\n  freely, subject to the following restrictions:\n\n  1. The origin of this software must not be misrepresented; you must not\n     claim that you wrote the original software. If you use this software\n     in a product, an acknowledgment in the product documentation would be\n     appreciated but is not required.\n  2. Altered source versions must be plainly marked as such, and must not be\n     misrepresented as being the original software.\n  3. This notice may not be removed or altered from any source distribution.\n\n  ---------------------------------------------------------------------------------\n\n        Changes\n\n        See header of unzip64.c\n\n*/\n\n#ifndef _unz64_H\n#define _unz64_H\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#ifndef _ZLIB_H\n#include \"zlib.h\"\n#endif\n\n#ifndef  _ZLIBIOAPI_H\n#include \"ioapi.h\"\n#endif\n\n#ifdef HAVE_BZIP2\n#include \"bzlib.h\"\n#endif\n\n#define Z_BZIP2ED 12\n\n#if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP)\n/* like the STRICT of WIN32, we define a pointer that cannot be converted\n    from (void*) without cast */\ntypedef struct TagunzFile__ { int unused; } unzFile__;\ntypedef unzFile__ *unzFile;\n#else\ntypedef voidp unzFile;\n#endif\n\n\n#define UNZ_OK                          (0)\n#define UNZ_END_OF_LIST_OF_FILE         (-100)\n#define UNZ_ERRNO                       (Z_ERRNO)\n#define UNZ_EOF                         (0)\n#define UNZ_PARAMERROR                  (-102)\n#define UNZ_BADZIPFILE                  (-103)\n#define UNZ_INTERNALERROR               (-104)\n#define UNZ_CRCERROR                    (-105)\n\n/* tm_unz contain date/time info */\ntypedef struct tm_unz_s\n{\n    uInt tm_sec;            /* seconds after the minute - [0,59] */\n    uInt tm_min;            /* minutes after the hour - [0,59] */\n    uInt tm_hour;           /* hours since midnight - [0,23] */\n    uInt tm_mday;           /* day of the month - [1,31] */\n    uInt tm_mon;            /* months since January - [0,11] */\n    uInt tm_year;           /* years - [1980..2044] */\n} tm_unz;\n\n/* unz_global_info structure contain global data about the ZIPfile\n   These data comes from the end of central dir */\ntypedef struct unz_global_info64_s\n{\n    ZPOS64_T number_entry;         /* total number of entries in\n                                     the central dir on this disk */\n    uLong size_comment;         /* size of the global comment of the zipfile */\n} unz_global_info64;\n\ntypedef struct unz_global_info_s\n{\n    uLong number_entry;         /* total number of entries in\n                                     the central dir on this disk */\n    uLong size_comment;         /* size of the global comment of the zipfile */\n} unz_global_info;\n\n/* unz_file_info contain information about a file in the zipfile */\ntypedef struct unz_file_info64_s\n{\n    uLong version;              /* version made by                 2 bytes */\n    uLong version_needed;       /* version needed to extract       2 bytes */\n    uLong flag;                 /* general purpose bit flag        2 bytes */\n    uLong compression_method;   /* compression method              2 bytes */\n    uLong dosDate;              /* last mod file date in Dos fmt   4 bytes */\n    uLong crc;                  /* crc-32                          4 bytes */\n    ZPOS64_T compressed_size;   /* compressed size                 8 bytes */\n    ZPOS64_T uncompressed_size; /* uncompressed size               8 bytes */\n    uLong size_filename;        /* filename length                 2 bytes */\n    uLong size_file_extra;      /* extra field length              2 bytes */\n    uLong size_file_comment;    /* file comment length             2 bytes */\n\n    uLong disk_num_start;       /* disk number start               2 bytes */\n    uLong internal_fa;          /* internal file attributes        2 bytes */\n    uLong external_fa;          /* external file attributes        4 bytes */\n\n    tm_unz tmu_date;\n} unz_file_info64;\n\ntypedef struct unz_file_info_s\n{\n    uLong version;              /* version made by                 2 bytes */\n    uLong version_needed;       /* version needed to extract       2 bytes */\n    uLong flag;                 /* general purpose bit flag        2 bytes */\n    uLong compression_method;   /* compression method              2 bytes */\n    uLong dosDate;              /* last mod file date in Dos fmt   4 bytes */\n    uLong crc;                  /* crc-32                          4 bytes */\n    uLong compressed_size;      /* compressed size                 4 bytes */\n    uLong uncompressed_size;    /* uncompressed size               4 bytes */\n    uLong size_filename;        /* filename length                 2 bytes */\n    uLong size_file_extra;      /* extra field length              2 bytes */\n    uLong size_file_comment;    /* file comment length             2 bytes */\n\n    uLong disk_num_start;       /* disk number start               2 bytes */\n    uLong internal_fa;          /* internal file attributes        2 bytes */\n    uLong external_fa;          /* external file attributes        4 bytes */\n\n    tm_unz tmu_date;\n} unz_file_info;\n\nextern int ZEXPORT unzStringFileNameCompare OF ((const char* fileName1,\n                                                 const char* fileName2,\n                                                 int iCaseSensitivity));\n/*\n   Compare two filename (fileName1,fileName2).\n   If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp)\n   If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi\n                                or strcasecmp)\n   If iCaseSenisivity = 0, case sensitivity is defaut of your operating system\n    (like 1 on Unix, 2 on Windows)\n*/\n\n\nextern unzFile ZEXPORT unzOpen OF((const char *path));\nextern unzFile ZEXPORT unzOpen64 OF((const void *path));\n/*\n  Open a Zip file. path contain the full pathname (by example,\n     on a Windows XP computer \"c:\\\\zlib\\\\zlib113.zip\" or on an Unix computer\n     \"zlib/zlib113.zip\".\n     If the zipfile cannot be opened (file don't exist or in not valid), the\n       return value is NULL.\n     Else, the return value is a unzFile Handle, usable with other function\n       of this unzip package.\n     the \"64\" function take a const void* pointer, because the path is just the\n       value passed to the open64_file_func callback.\n     Under Windows, if UNICODE is defined, using fill_fopen64_filefunc, the path\n       is a pointer to a wide unicode string (LPCTSTR is LPCWSTR), so const char*\n       does not describe the reality\n*/\n\n\nextern unzFile ZEXPORT unzOpen2 OF((const char *path,\n                                    zlib_filefunc_def* pzlib_filefunc_def));\n/*\n   Open a Zip file, like unzOpen, but provide a set of file low level API\n      for read/write the zip file (see ioapi.h)\n*/\n\nextern unzFile ZEXPORT unzOpen2_64 OF((const void *path,\n                                    zlib_filefunc64_def* pzlib_filefunc_def));\n/*\n   Open a Zip file, like unz64Open, but provide a set of file low level API\n      for read/write the zip file (see ioapi.h)\n*/\n\nextern int ZEXPORT unzClose OF((unzFile file));\n/*\n  Close a ZipFile opened with unzipOpen.\n  If there is files inside the .Zip opened with unzOpenCurrentFile (see later),\n    these files MUST be closed with unzipCloseCurrentFile before call unzipClose.\n  return UNZ_OK if there is no problem. */\n\nextern int ZEXPORT unzGetGlobalInfo OF((unzFile file,\n                                        unz_global_info *pglobal_info));\n\nextern int ZEXPORT unzGetGlobalInfo64 OF((unzFile file,\n                                        unz_global_info64 *pglobal_info));\n/*\n  Write info about the ZipFile in the *pglobal_info structure.\n  No preparation of the structure is needed\n  return UNZ_OK if there is no problem. */\n\n\nextern int ZEXPORT unzGetGlobalComment OF((unzFile file,\n                                           char *szComment,\n                                           uLong uSizeBuf));\n/*\n  Get the global comment string of the ZipFile, in the szComment buffer.\n  uSizeBuf is the size of the szComment buffer.\n  return the number of byte copied or an error code <0\n*/\n\n\n/***************************************************************************/\n/* Unzip package allow you browse the directory of the zipfile */\n\nextern int ZEXPORT unzGoToFirstFile OF((unzFile file));\n/*\n  Set the current file of the zipfile to the first file.\n  return UNZ_OK if there is no problem\n*/\n\nextern int ZEXPORT unzGoToNextFile OF((unzFile file));\n/*\n  Set the current file of the zipfile to the next file.\n  return UNZ_OK if there is no problem\n  return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest.\n*/\n\nextern int ZEXPORT unzLocateFile OF((unzFile file,\n                     const char *szFileName,\n                     int iCaseSensitivity));\n/*\n  Try locate the file szFileName in the zipfile.\n  For the iCaseSensitivity signification, see unzStringFileNameCompare\n\n  return value :\n  UNZ_OK if the file is found. It becomes the current file.\n  UNZ_END_OF_LIST_OF_FILE if the file is not found\n*/\n\n\n/* ****************************************** */\n/* Ryan supplied functions */\n/* unz_file_info contain information about a file in the zipfile */\ntypedef struct unz_file_pos_s\n{\n    uLong pos_in_zip_directory;   /* offset in zip file directory */\n    uLong num_of_file;            /* # of file */\n} unz_file_pos;\n\nextern int ZEXPORT unzGetFilePos(\n    unzFile file,\n    unz_file_pos* file_pos);\n\nextern int ZEXPORT unzGoToFilePos(\n    unzFile file,\n    unz_file_pos* file_pos);\n\ntypedef struct unz64_file_pos_s\n{\n    ZPOS64_T pos_in_zip_directory;   /* offset in zip file directory */\n    ZPOS64_T num_of_file;            /* # of file */\n} unz64_file_pos;\n\nextern int ZEXPORT unzGetFilePos64(\n    unzFile file,\n    unz64_file_pos* file_pos);\n\nextern int ZEXPORT unzGoToFilePos64(\n    unzFile file,\n    const unz64_file_pos* file_pos);\n\n/* ****************************************** */\n\nextern int ZEXPORT unzGetCurrentFileInfo64 OF((unzFile file,\n                         unz_file_info64 *pfile_info,\n                         char *szFileName,\n                         uLong fileNameBufferSize,\n                         void *extraField,\n                         uLong extraFieldBufferSize,\n                         char *szComment,\n                         uLong commentBufferSize));\n\nextern int ZEXPORT unzGetCurrentFileInfo OF((unzFile file,\n                         unz_file_info *pfile_info,\n                         char *szFileName,\n                         uLong fileNameBufferSize,\n                         void *extraField,\n                         uLong extraFieldBufferSize,\n                         char *szComment,\n                         uLong commentBufferSize));\n/*\n  Get Info about the current file\n  if pfile_info!=NULL, the *pfile_info structure will contain somes info about\n        the current file\n  if szFileName!=NULL, the filemane string will be copied in szFileName\n            (fileNameBufferSize is the size of the buffer)\n  if extraField!=NULL, the extra field information will be copied in extraField\n            (extraFieldBufferSize is the size of the buffer).\n            This is the Central-header version of the extra field\n  if szComment!=NULL, the comment string of the file will be copied in szComment\n            (commentBufferSize is the size of the buffer)\n*/\n\n\n/** Addition for GDAL : START */\n\nextern ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64 OF((unzFile file));\n\n/** Addition for GDAL : END */\n\n\n/***************************************************************************/\n/* for reading the content of the current zipfile, you can open it, read data\n   from it, and close it (you can close it before reading all the file)\n   */\n\nextern int ZEXPORT unzOpenCurrentFile OF((unzFile file));\n/*\n  Open for reading data the current file in the zipfile.\n  If there is no error, the return value is UNZ_OK.\n*/\n\nextern int ZEXPORT unzOpenCurrentFilePassword OF((unzFile file,\n                                                  const char* password));\n/*\n  Open for reading data the current file in the zipfile.\n  password is a crypting password\n  If there is no error, the return value is UNZ_OK.\n*/\n\nextern int ZEXPORT unzOpenCurrentFile2 OF((unzFile file,\n                                           int* method,\n                                           int* level,\n                                           int raw));\n/*\n  Same than unzOpenCurrentFile, but open for read raw the file (not uncompress)\n    if raw==1\n  *method will receive method of compression, *level will receive level of\n     compression\n  note : you can set level parameter as NULL (if you did not want known level,\n         but you CANNOT set method parameter as NULL\n*/\n\nextern int ZEXPORT unzOpenCurrentFile3 OF((unzFile file,\n                                           int* method,\n                                           int* level,\n                                           int raw,\n                                           const char* password));\n/*\n  Same than unzOpenCurrentFile, but open for read raw the file (not uncompress)\n    if raw==1\n  *method will receive method of compression, *level will receive level of\n     compression\n  note : you can set level parameter as NULL (if you did not want known level,\n         but you CANNOT set method parameter as NULL\n*/\n\n\nextern int ZEXPORT unzCloseCurrentFile OF((unzFile file));\n/*\n  Close the file in zip opened with unzOpenCurrentFile\n  Return UNZ_CRCERROR if all the file was read but the CRC is not good\n*/\n\nextern int ZEXPORT unzReadCurrentFile OF((unzFile file,\n                      voidp buf,\n                      unsigned len));\n/*\n  Read bytes from the current file (opened by unzOpenCurrentFile)\n  buf contain buffer where data must be copied\n  len the size of buf.\n\n  return the number of byte copied if somes bytes are copied\n  return 0 if the end of file was reached\n  return <0 with error code if there is an error\n    (UNZ_ERRNO for IO error, or zLib error for uncompress error)\n*/\n\nextern z_off_t ZEXPORT unztell OF((unzFile file));\n\nextern ZPOS64_T ZEXPORT unztell64 OF((unzFile file));\n/*\n  Give the current position in uncompressed data\n*/\n\nextern int ZEXPORT unzeof OF((unzFile file));\n/*\n  return 1 if the end of file was reached, 0 elsewhere\n*/\n\nextern int ZEXPORT unzGetLocalExtrafield OF((unzFile file,\n                                             voidp buf,\n                                             unsigned len));\n/*\n  Read extra field from the current file (opened by unzOpenCurrentFile)\n  This is the local-header version of the extra field (sometimes, there is\n    more info in the local-header version than in the central-header)\n\n  if buf==NULL, it return the size of the local extra field\n\n  if buf!=NULL, len is the size of the buffer, the extra header is copied in\n    buf.\n  the return value is the number of bytes copied in buf, or (if <0)\n    the error code\n*/\n\n/***************************************************************************/\n\n/* Get the current file offset */\nextern ZPOS64_T ZEXPORT unzGetOffset64 (unzFile file);\nextern uLong ZEXPORT unzGetOffset (unzFile file);\n\n/* Set the current file offset */\nextern int ZEXPORT unzSetOffset64 (unzFile file, ZPOS64_T pos);\nextern int ZEXPORT unzSetOffset (unzFile file, uLong pos);\n\n\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* _unz64_H */\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/minizip/zip.h",
    "content": "/* zip.h -- IO on .zip files using zlib\n   Version 1.1, February 14h, 2010\n   part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )\n\n         Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html )\n\n         Modifications for Zip64 support\n         Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )\n\n         For more info read MiniZip_info.txt\n\n         ---------------------------------------------------------------------------\n\n   Condition of use and distribution are the same than zlib :\n\n  This software is provided 'as-is', without any express or implied\n  warranty.  In no event will the authors be held liable for any damages\n  arising from the use of this software.\n\n  Permission is granted to anyone to use this software for any purpose,\n  including commercial applications, and to alter it and redistribute it\n  freely, subject to the following restrictions:\n\n  1. The origin of this software must not be misrepresented; you must not\n     claim that you wrote the original software. If you use this software\n     in a product, an acknowledgment in the product documentation would be\n     appreciated but is not required.\n  2. Altered source versions must be plainly marked as such, and must not be\n     misrepresented as being the original software.\n  3. This notice may not be removed or altered from any source distribution.\n\n        ---------------------------------------------------------------------------\n\n        Changes\n\n        See header of zip.h\n\n*/\n\n#ifndef _zip12_H\n#define _zip12_H\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n//#define HAVE_BZIP2\n\n#ifndef _ZLIB_H\n#include \"zlib.h\"\n#endif\n\n#ifndef _ZLIBIOAPI_H\n#include \"ioapi.h\"\n#endif\n\n#ifdef HAVE_BZIP2\n#include \"bzlib.h\"\n#endif\n\n#define Z_BZIP2ED 12\n\n#if defined(STRICTZIP) || defined(STRICTZIPUNZIP)\n/* like the STRICT of WIN32, we define a pointer that cannot be converted\n    from (void*) without cast */\ntypedef struct TagzipFile__ { int unused; } zipFile__;\ntypedef zipFile__ *zipFile;\n#else\ntypedef voidp zipFile;\n#endif\n\n#define ZIP_OK                          (0)\n#define ZIP_EOF                         (0)\n#define ZIP_ERRNO                       (Z_ERRNO)\n#define ZIP_PARAMERROR                  (-102)\n#define ZIP_BADZIPFILE                  (-103)\n#define ZIP_INTERNALERROR               (-104)\n\n#ifndef DEF_MEM_LEVEL\n#  if MAX_MEM_LEVEL >= 8\n#    define DEF_MEM_LEVEL 8\n#  else\n#    define DEF_MEM_LEVEL  MAX_MEM_LEVEL\n#  endif\n#endif\n/* default memLevel */\n\n/* tm_zip contain date/time info */\ntypedef struct tm_zip_s\n{\n    uInt tm_sec;            /* seconds after the minute - [0,59] */\n    uInt tm_min;            /* minutes after the hour - [0,59] */\n    uInt tm_hour;           /* hours since midnight - [0,23] */\n    uInt tm_mday;           /* day of the month - [1,31] */\n    uInt tm_mon;            /* months since January - [0,11] */\n    uInt tm_year;           /* years - [1980..2044] */\n} tm_zip;\n\ntypedef struct\n{\n    tm_zip      tmz_date;       /* date in understandable format           */\n    uLong       dosDate;       /* if dos_date == 0, tmu_date is used      */\n/*    uLong       flag;        */   /* general purpose bit flag        2 bytes */\n\n    uLong       internal_fa;    /* internal file attributes        2 bytes */\n    uLong       external_fa;    /* external file attributes        4 bytes */\n} zip_fileinfo;\n\ntypedef const char* zipcharpc;\n\n\n#define APPEND_STATUS_CREATE        (0)\n#define APPEND_STATUS_CREATEAFTER   (1)\n#define APPEND_STATUS_ADDINZIP      (2)\n\nextern zipFile ZEXPORT zipOpen OF((const char *pathname, int append));\nextern zipFile ZEXPORT zipOpen64 OF((const void *pathname, int append));\n/*\n  Create a zipfile.\n     pathname contain on Windows XP a filename like \"c:\\\\zlib\\\\zlib113.zip\" or on\n       an Unix computer \"zlib/zlib113.zip\".\n     if the file pathname exist and append==APPEND_STATUS_CREATEAFTER, the zip\n       will be created at the end of the file.\n         (useful if the file contain a self extractor code)\n     if the file pathname exist and append==APPEND_STATUS_ADDINZIP, we will\n       add files in existing zip (be sure you don't add file that doesn't exist)\n     If the zipfile cannot be opened, the return value is NULL.\n     Else, the return value is a zipFile Handle, usable with other function\n       of this zip package.\n*/\n\n/* Note : there is no delete function into a zipfile.\n   If you want delete file into a zipfile, you must open a zipfile, and create another\n   Of couse, you can use RAW reading and writing to copy the file you did not want delte\n*/\n\nextern zipFile ZEXPORT zipOpen2 OF((const char *pathname,\n                                   int append,\n                                   zipcharpc* globalcomment,\n                                   zlib_filefunc_def* pzlib_filefunc_def));\n\nextern zipFile ZEXPORT zipOpen2_64 OF((const void *pathname,\n                                   int append,\n                                   zipcharpc* globalcomment,\n                                   zlib_filefunc64_def* pzlib_filefunc_def));\n\nextern int ZEXPORT zipOpenNewFileInZip OF((zipFile file,\n                       const char* filename,\n                       const zip_fileinfo* zipfi,\n                       const void* extrafield_local,\n                       uInt size_extrafield_local,\n                       const void* extrafield_global,\n                       uInt size_extrafield_global,\n                       const char* comment,\n                       int method,\n                       int level));\n\nextern int ZEXPORT zipOpenNewFileInZip64 OF((zipFile file,\n                       const char* filename,\n                       const zip_fileinfo* zipfi,\n                       const void* extrafield_local,\n                       uInt size_extrafield_local,\n                       const void* extrafield_global,\n                       uInt size_extrafield_global,\n                       const char* comment,\n                       int method,\n                       int level,\n                       int zip64));\n\n/*\n  Open a file in the ZIP for writing.\n  filename : the filename in zip (if NULL, '-' without quote will be used\n  *zipfi contain supplemental information\n  if extrafield_local!=NULL and size_extrafield_local>0, extrafield_local\n    contains the extrafield data the the local header\n  if extrafield_global!=NULL and size_extrafield_global>0, extrafield_global\n    contains the extrafield data the the local header\n  if comment != NULL, comment contain the comment string\n  method contain the compression method (0 for store, Z_DEFLATED for deflate)\n  level contain the level of compression (can be Z_DEFAULT_COMPRESSION)\n  zip64 is set to 1 if a zip64 extended information block should be added to the local file header.\n                    this MUST be '1' if the uncompressed size is >= 0xffffffff.\n\n*/\n\n\nextern int ZEXPORT zipOpenNewFileInZip2 OF((zipFile file,\n                                            const char* filename,\n                                            const zip_fileinfo* zipfi,\n                                            const void* extrafield_local,\n                                            uInt size_extrafield_local,\n                                            const void* extrafield_global,\n                                            uInt size_extrafield_global,\n                                            const char* comment,\n                                            int method,\n                                            int level,\n                                            int raw));\n\n\nextern int ZEXPORT zipOpenNewFileInZip2_64 OF((zipFile file,\n                                            const char* filename,\n                                            const zip_fileinfo* zipfi,\n                                            const void* extrafield_local,\n                                            uInt size_extrafield_local,\n                                            const void* extrafield_global,\n                                            uInt size_extrafield_global,\n                                            const char* comment,\n                                            int method,\n                                            int level,\n                                            int raw,\n                                            int zip64));\n/*\n  Same than zipOpenNewFileInZip, except if raw=1, we write raw file\n */\n\nextern int ZEXPORT zipOpenNewFileInZip3 OF((zipFile file,\n                                            const char* filename,\n                                            const zip_fileinfo* zipfi,\n                                            const void* extrafield_local,\n                                            uInt size_extrafield_local,\n                                            const void* extrafield_global,\n                                            uInt size_extrafield_global,\n                                            const char* comment,\n                                            int method,\n                                            int level,\n                                            int raw,\n                                            int windowBits,\n                                            int memLevel,\n                                            int strategy,\n                                            const char* password,\n                                            uLong crcForCrypting));\n\nextern int ZEXPORT zipOpenNewFileInZip3_64 OF((zipFile file,\n                                            const char* filename,\n                                            const zip_fileinfo* zipfi,\n                                            const void* extrafield_local,\n                                            uInt size_extrafield_local,\n                                            const void* extrafield_global,\n                                            uInt size_extrafield_global,\n                                            const char* comment,\n                                            int method,\n                                            int level,\n                                            int raw,\n                                            int windowBits,\n                                            int memLevel,\n                                            int strategy,\n                                            const char* password,\n                                            uLong crcForCrypting,\n                                            int zip64\n                                            ));\n\n/*\n  Same than zipOpenNewFileInZip2, except\n    windowBits,memLevel,,strategy : see parameter strategy in deflateInit2\n    password : crypting password (NULL for no crypting)\n    crcForCrypting : crc of file to compress (needed for crypting)\n */\n\nextern int ZEXPORT zipOpenNewFileInZip4 OF((zipFile file,\n                                            const char* filename,\n                                            const zip_fileinfo* zipfi,\n                                            const void* extrafield_local,\n                                            uInt size_extrafield_local,\n                                            const void* extrafield_global,\n                                            uInt size_extrafield_global,\n                                            const char* comment,\n                                            int method,\n                                            int level,\n                                            int raw,\n                                            int windowBits,\n                                            int memLevel,\n                                            int strategy,\n                                            const char* password,\n                                            uLong crcForCrypting,\n                                            uLong versionMadeBy,\n                                            uLong flagBase\n                                            ));\n\n\nextern int ZEXPORT zipOpenNewFileInZip4_64 OF((zipFile file,\n                                            const char* filename,\n                                            const zip_fileinfo* zipfi,\n                                            const void* extrafield_local,\n                                            uInt size_extrafield_local,\n                                            const void* extrafield_global,\n                                            uInt size_extrafield_global,\n                                            const char* comment,\n                                            int method,\n                                            int level,\n                                            int raw,\n                                            int windowBits,\n                                            int memLevel,\n                                            int strategy,\n                                            const char* password,\n                                            uLong crcForCrypting,\n                                            uLong versionMadeBy,\n                                            uLong flagBase,\n                                            int zip64\n                                            ));\n/*\n  Same than zipOpenNewFileInZip4, except\n    versionMadeBy : value for Version made by field\n    flag : value for flag field (compression level info will be added)\n */\n\n\nextern int ZEXPORT zipWriteInFileInZip OF((zipFile file,\n                       const void* buf,\n                       unsigned len));\n/*\n  Write data in the zipfile\n*/\n\nextern int ZEXPORT zipCloseFileInZip OF((zipFile file));\n/*\n  Close the current file in the zipfile\n*/\n\nextern int ZEXPORT zipCloseFileInZipRaw OF((zipFile file,\n                                            uLong uncompressed_size,\n                                            uLong crc32));\n\nextern int ZEXPORT zipCloseFileInZipRaw64 OF((zipFile file,\n                                            ZPOS64_T uncompressed_size,\n                                            uLong crc32));\n\n/*\n  Close the current file in the zipfile, for file opened with\n    parameter raw=1 in zipOpenNewFileInZip2\n  uncompressed_size and crc32 are value for the uncompressed size\n*/\n\nextern int ZEXPORT zipClose OF((zipFile file,\n                const char* global_comment));\n/*\n  Close the zipfile\n*/\n\n\nextern int ZEXPORT zipRemoveExtraInfoBlock OF((char* pData, int* dataLen, short sHeader));\n/*\n  zipRemoveExtraInfoBlock -  Added by Mathias Svensson\n\n  Remove extra information block from a extra information data for the local file header or central directory header\n\n  It is needed to remove ZIP64 extra information blocks when before data is written if using RAW mode.\n\n  0x0001 is the signature header for the ZIP64 extra information blocks\n\n  usage.\n                        Remove ZIP64 Extra information from a central director extra field data\n              zipRemoveExtraInfoBlock(pCenDirExtraFieldData, &nCenDirExtraFieldDataLen, 0x0001);\n\n                        Remove ZIP64 Extra information from a Local File Header extra field data\n        zipRemoveExtraInfoBlock(pLocalHeaderExtraFieldData, &nLocalHeaderExtraFieldDataLen, 0x0001);\n*/\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* _zip64_H */\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/png/png.h",
    "content": "\n/* png.h - header file for PNG reference library\n *\n * libpng version 1.6.10 - March 6, 2014\n * Copyright (c) 1998-2014 Glenn Randers-Pehrson\n * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)\n * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)\n *\n * This code is released under the libpng license (See LICENSE, below)\n *\n * Authors and maintainers:\n *   libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat\n *   libpng versions 0.89c, June 1996, through 0.96, May 1997: Andreas Dilger\n *   libpng versions 0.97, January 1998, through 1.6.10 - March 6, 2014: Glenn\n *   See also \"Contributing Authors\", below.\n *\n * Note about libpng version numbers:\n *\n *   Due to various miscommunications, unforeseen code incompatibilities\n *   and occasional factors outside the authors' control, version numbering\n *   on the library has not always been consistent and straightforward.\n *   The following table summarizes matters since version 0.89c, which was\n *   the first widely used release:\n *\n *    source                 png.h  png.h  shared-lib\n *    version                string   int  version\n *    -------                ------ -----  ----------\n *    0.89c \"1.0 beta 3\"     0.89      89  1.0.89\n *    0.90  \"1.0 beta 4\"     0.90      90  0.90  [should have been 2.0.90]\n *    0.95  \"1.0 beta 5\"     0.95      95  0.95  [should have been 2.0.95]\n *    0.96  \"1.0 beta 6\"     0.96      96  0.96  [should have been 2.0.96]\n *    0.97b \"1.00.97 beta 7\" 1.00.97   97  1.0.1 [should have been 2.0.97]\n *    0.97c                  0.97      97  2.0.97\n *    0.98                   0.98      98  2.0.98\n *    0.99                   0.99      98  2.0.99\n *    0.99a-m                0.99      99  2.0.99\n *    1.00                   1.00     100  2.1.0 [100 should be 10000]\n *    1.0.0      (from here on, the   100  2.1.0 [100 should be 10000]\n *    1.0.1       png.h string is   10001  2.1.0\n *    1.0.1a-e    identical to the  10002  from here on, the shared library\n *    1.0.2       source version)   10002  is 2.V where V is the source code\n *    1.0.2a-b                      10003  version, except as noted.\n *    1.0.3                         10003\n *    1.0.3a-d                      10004\n *    1.0.4                         10004\n *    1.0.4a-f                      10005\n *    1.0.5 (+ 2 patches)           10005\n *    1.0.5a-d                      10006\n *    1.0.5e-r                      10100 (not source compatible)\n *    1.0.5s-v                      10006 (not binary compatible)\n *    1.0.6 (+ 3 patches)           10006 (still binary incompatible)\n *    1.0.6d-f                      10007 (still binary incompatible)\n *    1.0.6g                        10007\n *    1.0.6h                        10007  10.6h (testing xy.z so-numbering)\n *    1.0.6i                        10007  10.6i\n *    1.0.6j                        10007  2.1.0.6j (incompatible with 1.0.0)\n *    1.0.7beta11-14        DLLNUM  10007  2.1.0.7beta11-14 (binary compatible)\n *    1.0.7beta15-18           1    10007  2.1.0.7beta15-18 (binary compatible)\n *    1.0.7rc1-2               1    10007  2.1.0.7rc1-2 (binary compatible)\n *    1.0.7                    1    10007  (still compatible)\n *    1.0.8beta1-4             1    10008  2.1.0.8beta1-4\n *    1.0.8rc1                 1    10008  2.1.0.8rc1\n *    1.0.8                    1    10008  2.1.0.8\n *    1.0.9beta1-6             1    10009  2.1.0.9beta1-6\n *    1.0.9rc1                 1    10009  2.1.0.9rc1\n *    1.0.9beta7-10            1    10009  2.1.0.9beta7-10\n *    1.0.9rc2                 1    10009  2.1.0.9rc2\n *    1.0.9                    1    10009  2.1.0.9\n *    1.0.10beta1              1    10010  2.1.0.10beta1\n *    1.0.10rc1                1    10010  2.1.0.10rc1\n *    1.0.10                   1    10010  2.1.0.10\n *    1.0.11beta1-3            1    10011  2.1.0.11beta1-3\n *    1.0.11rc1                1    10011  2.1.0.11rc1\n *    1.0.11                   1    10011  2.1.0.11\n *    1.0.12beta1-2            2    10012  2.1.0.12beta1-2\n *    1.0.12rc1                2    10012  2.1.0.12rc1\n *    1.0.12                   2    10012  2.1.0.12\n *    1.1.0a-f                 -    10100  2.1.1.0a-f (branch abandoned)\n *    1.2.0beta1-2             2    10200  2.1.2.0beta1-2\n *    1.2.0beta3-5             3    10200  3.1.2.0beta3-5\n *    1.2.0rc1                 3    10200  3.1.2.0rc1\n *    1.2.0                    3    10200  3.1.2.0\n *    1.2.1beta1-4             3    10201  3.1.2.1beta1-4\n *    1.2.1rc1-2               3    10201  3.1.2.1rc1-2\n *    1.2.1                    3    10201  3.1.2.1\n *    1.2.2beta1-6            12    10202  12.so.0.1.2.2beta1-6\n *    1.0.13beta1             10    10013  10.so.0.1.0.13beta1\n *    1.0.13rc1               10    10013  10.so.0.1.0.13rc1\n *    1.2.2rc1                12    10202  12.so.0.1.2.2rc1\n *    1.0.13                  10    10013  10.so.0.1.0.13\n *    1.2.2                   12    10202  12.so.0.1.2.2\n *    1.2.3rc1-6              12    10203  12.so.0.1.2.3rc1-6\n *    1.2.3                   12    10203  12.so.0.1.2.3\n *    1.2.4beta1-3            13    10204  12.so.0.1.2.4beta1-3\n *    1.0.14rc1               13    10014  10.so.0.1.0.14rc1\n *    1.2.4rc1                13    10204  12.so.0.1.2.4rc1\n *    1.0.14                  10    10014  10.so.0.1.0.14\n *    1.2.4                   13    10204  12.so.0.1.2.4\n *    1.2.5beta1-2            13    10205  12.so.0.1.2.5beta1-2\n *    1.0.15rc1-3             10    10015  10.so.0.1.0.15rc1-3\n *    1.2.5rc1-3              13    10205  12.so.0.1.2.5rc1-3\n *    1.0.15                  10    10015  10.so.0.1.0.15\n *    1.2.5                   13    10205  12.so.0.1.2.5\n *    1.2.6beta1-4            13    10206  12.so.0.1.2.6beta1-4\n *    1.0.16                  10    10016  10.so.0.1.0.16\n *    1.2.6                   13    10206  12.so.0.1.2.6\n *    1.2.7beta1-2            13    10207  12.so.0.1.2.7beta1-2\n *    1.0.17rc1               10    10017  12.so.0.1.0.17rc1\n *    1.2.7rc1                13    10207  12.so.0.1.2.7rc1\n *    1.0.17                  10    10017  12.so.0.1.0.17\n *    1.2.7                   13    10207  12.so.0.1.2.7\n *    1.2.8beta1-5            13    10208  12.so.0.1.2.8beta1-5\n *    1.0.18rc1-5             10    10018  12.so.0.1.0.18rc1-5\n *    1.2.8rc1-5              13    10208  12.so.0.1.2.8rc1-5\n *    1.0.18                  10    10018  12.so.0.1.0.18\n *    1.2.8                   13    10208  12.so.0.1.2.8\n *    1.2.9beta1-3            13    10209  12.so.0.1.2.9beta1-3\n *    1.2.9beta4-11           13    10209  12.so.0.9[.0]\n *    1.2.9rc1                13    10209  12.so.0.9[.0]\n *    1.2.9                   13    10209  12.so.0.9[.0]\n *    1.2.10beta1-7           13    10210  12.so.0.10[.0]\n *    1.2.10rc1-2             13    10210  12.so.0.10[.0]\n *    1.2.10                  13    10210  12.so.0.10[.0]\n *    1.4.0beta1-5            14    10400  14.so.0.0[.0]\n *    1.2.11beta1-4           13    10211  12.so.0.11[.0]\n *    1.4.0beta7-8            14    10400  14.so.0.0[.0]\n *    1.2.11                  13    10211  12.so.0.11[.0]\n *    1.2.12                  13    10212  12.so.0.12[.0]\n *    1.4.0beta9-14           14    10400  14.so.0.0[.0]\n *    1.2.13                  13    10213  12.so.0.13[.0]\n *    1.4.0beta15-36          14    10400  14.so.0.0[.0]\n *    1.4.0beta37-87          14    10400  14.so.14.0[.0]\n *    1.4.0rc01               14    10400  14.so.14.0[.0]\n *    1.4.0beta88-109         14    10400  14.so.14.0[.0]\n *    1.4.0rc02-08            14    10400  14.so.14.0[.0]\n *    1.4.0                   14    10400  14.so.14.0[.0]\n *    1.4.1beta01-03          14    10401  14.so.14.1[.0]\n *    1.4.1rc01               14    10401  14.so.14.1[.0]\n *    1.4.1beta04-12          14    10401  14.so.14.1[.0]\n *    1.4.1                   14    10401  14.so.14.1[.0]\n *    1.4.2                   14    10402  14.so.14.2[.0]\n *    1.4.3                   14    10403  14.so.14.3[.0]\n *    1.4.4                   14    10404  14.so.14.4[.0]\n *    1.5.0beta01-58          15    10500  15.so.15.0[.0]\n *    1.5.0rc01-07            15    10500  15.so.15.0[.0]\n *    1.5.0                   15    10500  15.so.15.0[.0]\n *    1.5.1beta01-11          15    10501  15.so.15.1[.0]\n *    1.5.1rc01-02            15    10501  15.so.15.1[.0]\n *    1.5.1                   15    10501  15.so.15.1[.0]\n *    1.5.2beta01-03          15    10502  15.so.15.2[.0]\n *    1.5.2rc01-03            15    10502  15.so.15.2[.0]\n *    1.5.2                   15    10502  15.so.15.2[.0]\n *    1.5.3beta01-10          15    10503  15.so.15.3[.0]\n *    1.5.3rc01-02            15    10503  15.so.15.3[.0]\n *    1.5.3beta11             15    10503  15.so.15.3[.0]\n *    1.5.3 [omitted]\n *    1.5.4beta01-08          15    10504  15.so.15.4[.0]\n *    1.5.4rc01               15    10504  15.so.15.4[.0]\n *    1.5.4                   15    10504  15.so.15.4[.0]\n *    1.5.5beta01-08          15    10505  15.so.15.5[.0]\n *    1.5.5rc01               15    10505  15.so.15.5[.0]\n *    1.5.5                   15    10505  15.so.15.5[.0]\n *    1.5.6beta01-07          15    10506  15.so.15.6[.0]\n *    1.5.6rc01-03            15    10506  15.so.15.6[.0]\n *    1.5.6                   15    10506  15.so.15.6[.0]\n *    1.5.7beta01-05          15    10507  15.so.15.7[.0]\n *    1.5.7rc01-03            15    10507  15.so.15.7[.0]\n *    1.5.7                   15    10507  15.so.15.7[.0]\n *    1.6.0beta01-40          16    10600  16.so.16.0[.0]\n *    1.6.0rc01-08            16    10600  16.so.16.0[.0]\n *    1.6.0                   16    10600  16.so.16.0[.0]\n *    1.6.1beta01-09          16    10601  16.so.16.1[.0]\n *    1.6.1rc01               16    10601  16.so.16.1[.0]\n *    1.6.1                   16    10601  16.so.16.1[.0]\n *    1.6.2beta01             16    10602  16.so.16.2[.0]\n *    1.6.2rc01-06            16    10602  16.so.16.2[.0]\n *    1.6.2                   16    10602  16.so.16.2[.0]\n *    1.6.3beta01-11          16    10603  16.so.16.3[.0]\n *    1.6.3rc01               16    10603  16.so.16.3[.0]\n *    1.6.3                   16    10603  16.so.16.3[.0]\n *    1.6.4beta01-02          16    10604  16.so.16.4[.0]\n *    1.6.4rc01               16    10604  16.so.16.4[.0]\n *    1.6.4                   16    10604  16.so.16.4[.0]\n *    1.6.5                   16    10605  16.so.16.5[.0]\n *    1.6.6                   16    10606  16.so.16.6[.0]\n *    1.6.7beta01-04          16    10607  16.so.16.7[.0]\n *    1.6.7rc01-03            16    10607  16.so.16.7[.0]\n *    1.6.7                   16    10607  16.so.16.7[.0]\n *    1.6.8beta01-02          16    10608  16.so.16.8[.0]\n *    1.6.8rc01-02            16    10608  16.so.16.8[.0]\n *    1.6.8                   16    10608  16.so.16.8[.0]\n *    1.6.9beta01-04          16    10609  16.so.16.9[.0]\n *    1.6.9rc01-02            16    10609  16.so.16.9[.0]\n *    1.6.9                   16    10609  16.so.16.9[.0]\n *    1.6.10beta01-03         16    10610  16.so.16.10[.0]\n *    1.6.10betarc01-04       16    10610  16.so.16.10[.0]\n *    1.6.10beta              16    10610  16.so.16.10[.0]\n *\n *   Henceforth the source version will match the shared-library major\n *   and minor numbers; the shared-library major version number will be\n *   used for changes in backward compatibility, as it is intended.  The\n *   PNG_LIBPNG_VER macro, which is not used within libpng but is available\n *   for applications, is an unsigned integer of the form xyyzz corresponding\n *   to the source version x.y.z (leading zeros in y and z).  Beta versions\n *   were given the previous public release number plus a letter, until\n *   version 1.0.6j; from then on they were given the upcoming public\n *   release number plus \"betaNN\" or \"rcNN\".\n *\n *   Binary incompatibility exists only when applications make direct access\n *   to the info_ptr or png_ptr members through png.h, and the compiled\n *   application is loaded with a different version of the library.\n *\n *   DLLNUM will change each time there are forward or backward changes\n *   in binary compatibility (e.g., when a new feature is added).\n *\n * See libpng-manual.txt or libpng.3 for more information.  The PNG\n * specification is available as a W3C Recommendation and as an ISO\n * Specification, <http://www.w3.org/TR/2003/REC-PNG-20031110/\n */\n\n/*\n * COPYRIGHT NOTICE, DISCLAIMER, and LICENSE:\n *\n * If you modify libpng you may insert additional notices immediately following\n * this sentence.\n *\n * This code is released under the libpng license.\n *\n * libpng versions 1.2.6, August 15, 2004, through 1.6.10, March 6, 2014, are\n * Copyright (c) 2004, 2006-2013 Glenn Randers-Pehrson, and are\n * distributed according to the same disclaimer and license as libpng-1.2.5\n * with the following individual added to the list of Contributing Authors:\n *\n *    Cosmin Truta\n *\n * libpng versions 1.0.7, July 1, 2000, through 1.2.5, October 3, 2002, are\n * Copyright (c) 2000-2002 Glenn Randers-Pehrson, and are\n * distributed according to the same disclaimer and license as libpng-1.0.6\n * with the following individuals added to the list of Contributing Authors:\n *\n *    Simon-Pierre Cadieux\n *    Eric S. Raymond\n *    Gilles Vollant\n *\n * and with the following additions to the disclaimer:\n *\n *    There is no warranty against interference with your enjoyment of the\n *    library or against infringement.  There is no warranty that our\n *    efforts or the library will fulfill any of your particular purposes\n *    or needs.  This library is provided with all faults, and the entire\n *    risk of satisfactory quality, performance, accuracy, and effort is with\n *    the user.\n *\n * libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are\n * Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson, and are\n * distributed according to the same disclaimer and license as libpng-0.96,\n * with the following individuals added to the list of Contributing Authors:\n *\n *    Tom Lane\n *    Glenn Randers-Pehrson\n *    Willem van Schaik\n *\n * libpng versions 0.89, June 1996, through 0.96, May 1997, are\n * Copyright (c) 1996, 1997 Andreas Dilger\n * Distributed according to the same disclaimer and license as libpng-0.88,\n * with the following individuals added to the list of Contributing Authors:\n *\n *    John Bowler\n *    Kevin Bracey\n *    Sam Bushell\n *    Magnus Holmgren\n *    Greg Roelofs\n *    Tom Tanner\n *\n * libpng versions 0.5, May 1995, through 0.88, January 1996, are\n * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.\n *\n * For the purposes of this copyright and license, \"Contributing Authors\"\n * is defined as the following set of individuals:\n *\n *    Andreas Dilger\n *    Dave Martindale\n *    Guy Eric Schalnat\n *    Paul Schmidt\n *    Tim Wegner\n *\n * The PNG Reference Library is supplied \"AS IS\".  The Contributing Authors\n * and Group 42, Inc. disclaim all warranties, expressed or implied,\n * including, without limitation, the warranties of merchantability and of\n * fitness for any purpose.  The Contributing Authors and Group 42, Inc.\n * assume no liability for direct, indirect, incidental, special, exemplary,\n * or consequential damages, which may result from the use of the PNG\n * Reference Library, even if advised of the possibility of such damage.\n *\n * Permission is hereby granted to use, copy, modify, and distribute this\n * source code, or portions hereof, for any purpose, without fee, subject\n * to the following restrictions:\n *\n *   1. The origin of this source code must not be misrepresented.\n *\n *   2. Altered versions must be plainly marked as such and must not\n *      be misrepresented as being the original source.\n *\n *   3. This Copyright notice may not be removed or altered from\n *      any source or altered source distribution.\n *\n * The Contributing Authors and Group 42, Inc. specifically permit, without\n * fee, and encourage the use of this source code as a component to\n * supporting the PNG file format in commercial products.  If you use this\n * source code in a product, acknowledgment is not required but would be\n * appreciated.\n */\n\n/*\n * A \"png_get_copyright\" function is available, for convenient use in \"about\"\n * boxes and the like:\n *\n *     printf(\"%s\", png_get_copyright(NULL));\n *\n * Also, the PNG logo (in PNG format, of course) is supplied in the\n * files \"pngbar.png\" and \"pngbar.jpg (88x31) and \"pngnow.png\" (98x31).\n */\n\n/*\n * Libpng is OSI Certified Open Source Software.  OSI Certified is a\n * certification mark of the Open Source Initiative.\n */\n\n/*\n * The contributing authors would like to thank all those who helped\n * with testing, bug fixes, and patience.  This wouldn't have been\n * possible without all of you.\n *\n * Thanks to Frank J. T. Wojcik for helping with the documentation.\n */\n\n/*\n * Y2K compliance in libpng:\n * =========================\n *\n *    March 6, 2014\n *\n *    Since the PNG Development group is an ad-hoc body, we can't make\n *    an official declaration.\n *\n *    This is your unofficial assurance that libpng from version 0.71 and\n *    upward through 1.6.10 are Y2K compliant.  It is my belief that\n *    earlier versions were also Y2K compliant.\n *\n *    Libpng only has two year fields.  One is a 2-byte unsigned integer\n *    that will hold years up to 65535.  The other, which is deprecated,\n *    holds the date in text format, and will hold years up to 9999.\n *\n *    The integer is\n *        \"png_uint_16 year\" in png_time_struct.\n *\n *    The string is\n *        \"char time_buffer[29]\" in png_struct.  This is no longer used\n *    in libpng-1.6.x and will be removed from libpng-1.7.0.\n *\n *    There are seven time-related functions:\n *        png.c: png_convert_to_rfc_1123_buffer() in png.c\n *          (formerly png_convert_to_rfc_1123() prior to libpng-1.5.x and\n *          png_convert_to_rfc_1152() in error prior to libpng-0.98)\n *        png_convert_from_struct_tm() in pngwrite.c, called in pngwrite.c\n *        png_convert_from_time_t() in pngwrite.c\n *        png_get_tIME() in pngget.c\n *        png_handle_tIME() in pngrutil.c, called in pngread.c\n *        png_set_tIME() in pngset.c\n *        png_write_tIME() in pngwutil.c, called in pngwrite.c\n *\n *    All handle dates properly in a Y2K environment.  The\n *    png_convert_from_time_t() function calls gmtime() to convert from system\n *    clock time, which returns (year - 1900), which we properly convert to\n *    the full 4-digit year.  There is a possibility that libpng applications\n *    are not passing 4-digit years into the png_convert_to_rfc_1123_buffer()\n *    function, or that they are incorrectly passing only a 2-digit year\n *    instead of \"year - 1900\" into the png_convert_from_struct_tm() function,\n *    but this is not under our control.  The libpng documentation has always\n *    stated that it works with 4-digit years, and the APIs have been\n *    documented as such.\n *\n *    The tIME chunk itself is also Y2K compliant.  It uses a 2-byte unsigned\n *    integer to hold the year, and can hold years as large as 65535.\n *\n *    zlib, upon which libpng depends, is also Y2K compliant.  It contains\n *    no date-related code.\n *\n *       Glenn Randers-Pehrson\n *       libpng maintainer\n *       PNG Development Group\n */\n\n#ifndef PNG_H\n#define PNG_H\n\n/* This is not the place to learn how to use libpng. The file libpng-manual.txt\n * describes how to use libpng, and the file example.c summarizes it\n * with some code on which to build.  This file is useful for looking\n * at the actual function definitions and structure components.\n *\n * If you just need to read a PNG file and don't want to read the documentation\n * skip to the end of this file and read the section entitled 'simplified API'.\n */\n\n/* Version information for png.h - this should match the version in png.c */\n#define PNG_LIBPNG_VER_STRING \"1.6.10\"\n#define PNG_HEADER_VERSION_STRING \\\n     \" libpng version 1.6.10 - March 6, 2014\\n\"\n\n#define PNG_LIBPNG_VER_SONUM   16\n#define PNG_LIBPNG_VER_DLLNUM  16\n\n/* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */\n#define PNG_LIBPNG_VER_MAJOR   1\n#define PNG_LIBPNG_VER_MINOR   6\n#define PNG_LIBPNG_VER_RELEASE 10\n\n/* This should match the numeric part of the final component of\n * PNG_LIBPNG_VER_STRING, omitting any leading zero:\n */\n\n#define PNG_LIBPNG_VER_BUILD  0\n\n/* Release Status */\n#define PNG_LIBPNG_BUILD_ALPHA    1\n#define PNG_LIBPNG_BUILD_BETA     2\n#define PNG_LIBPNG_BUILD_RC       3\n#define PNG_LIBPNG_BUILD_STABLE   4\n#define PNG_LIBPNG_BUILD_RELEASE_STATUS_MASK 7\n\n/* Release-Specific Flags */\n#define PNG_LIBPNG_BUILD_PATCH    8 /* Can be OR'ed with\n                                       PNG_LIBPNG_BUILD_STABLE only */\n#define PNG_LIBPNG_BUILD_PRIVATE 16 /* Cannot be OR'ed with\n                                       PNG_LIBPNG_BUILD_SPECIAL */\n#define PNG_LIBPNG_BUILD_SPECIAL 32 /* Cannot be OR'ed with\n                                       PNG_LIBPNG_BUILD_PRIVATE */\n\n#define PNG_LIBPNG_BUILD_BASE_TYPE PNG_LIBPNG_BUILD_STABLE\n\n/* Careful here.  At one time, Guy wanted to use 082, but that would be octal.\n * We must not include leading zeros.\n * Versions 0.7 through 1.0.0 were in the range 0 to 100 here (only\n * version 1.0.0 was mis-numbered 100 instead of 10000).  From\n * version 1.0.1 it's    xxyyzz, where x=major, y=minor, z=release\n */\n#define PNG_LIBPNG_VER 10610 /* 1.6.10 */\n\n/* Library configuration: these options cannot be changed after\n * the library has been built.\n */\n#ifndef PNGLCONF_H\n    /* If pnglibconf.h is missing, you can\n     * copy scripts/pnglibconf.h.prebuilt to pnglibconf.h\n     */\n#   include \"pnglibconf.h\"\n#endif\n\n#ifndef PNG_VERSION_INFO_ONLY\n   /* Machine specific configuration. */\n#  include \"pngconf.h\"\n#endif\n\n/*\n * Added at libpng-1.2.8\n *\n * Ref MSDN: Private as priority over Special\n * VS_FF_PRIVATEBUILD File *was not* built using standard release\n * procedures. If this value is given, the StringFileInfo block must\n * contain a PrivateBuild string.\n *\n * VS_FF_SPECIALBUILD File *was* built by the original company using\n * standard release procedures but is a variation of the standard\n * file of the same version number. If this value is given, the\n * StringFileInfo block must contain a SpecialBuild string.\n */\n\n#ifdef PNG_USER_PRIVATEBUILD /* From pnglibconf.h */\n#  define PNG_LIBPNG_BUILD_TYPE \\\n       (PNG_LIBPNG_BUILD_BASE_TYPE | PNG_LIBPNG_BUILD_PRIVATE)\n#else\n#  ifdef PNG_LIBPNG_SPECIALBUILD\n#    define PNG_LIBPNG_BUILD_TYPE \\\n         (PNG_LIBPNG_BUILD_BASE_TYPE | PNG_LIBPNG_BUILD_SPECIAL)\n#  else\n#    define PNG_LIBPNG_BUILD_TYPE (PNG_LIBPNG_BUILD_BASE_TYPE)\n#  endif\n#endif\n\n#ifndef PNG_VERSION_INFO_ONLY\n\n/* Inhibit C++ name-mangling for libpng functions but not for system calls. */\n#ifdef __cplusplus\nextern \"C\" {\n#endif /* __cplusplus */\n\n/* Version information for C files, stored in png.c.  This had better match\n * the version above.\n */\n#define png_libpng_ver png_get_header_ver(NULL)\n\n/* This file is arranged in several sections:\n *\n * 1. Any configuration options that can be specified by for the application\n *    code when it is built.  (Build time configuration is in pnglibconf.h)\n * 2. Type definitions (base types are defined in pngconf.h), structure\n *    definitions.\n * 3. Exported library functions.\n * 4. Simplified API.\n *\n * The library source code has additional files (principally pngpriv.h) that\n * allow configuration of the library.\n */\n/* Section 1: run time configuration\n * See pnglibconf.h for build time configuration\n *\n * Run time configuration allows the application to choose between\n * implementations of certain arithmetic APIs.  The default is set\n * at build time and recorded in pnglibconf.h, but it is safe to\n * override these (and only these) settings.  Note that this won't\n * change what the library does, only application code, and the\n * settings can (and probably should) be made on a per-file basis\n * by setting the #defines before including png.h\n *\n * Use macros to read integers from PNG data or use the exported\n * functions?\n *   PNG_USE_READ_MACROS: use the macros (see below)  Note that\n *     the macros evaluate their argument multiple times.\n *   PNG_NO_USE_READ_MACROS: call the relevant library function.\n *\n * Use the alternative algorithm for compositing alpha samples that\n * does not use division?\n *   PNG_READ_COMPOSITE_NODIV_SUPPORTED: use the 'no division'\n *      algorithm.\n *   PNG_NO_READ_COMPOSITE_NODIV: use the 'division' algorithm.\n *\n * How to handle benign errors if PNG_ALLOW_BENIGN_ERRORS is\n * false?\n *   PNG_ALLOW_BENIGN_ERRORS: map calls to the benign error\n *      APIs to png_warning.\n * Otherwise the calls are mapped to png_error.\n */\n\n/* Section 2: type definitions, including structures and compile time\n * constants.\n * See pngconf.h for base types that vary by machine/system\n */\n\n/* This triggers a compiler error in png.c, if png.c and png.h\n * do not agree upon the version number.\n */\ntypedef char* png_libpng_version_1_6_10;\n\n/* Basic control structions.  Read libpng-manual.txt or libpng.3 for more info.\n *\n * png_struct is the cache of information used while reading or writing a single\n * PNG file.  One of these is always required, although the simplified API\n * (below) hides the creation and destruction of it.\n */\ntypedef struct png_struct_def png_struct;\ntypedef const png_struct * png_const_structp;\ntypedef png_struct * png_structp;\ntypedef png_struct * * png_structpp;\n\n/* png_info contains information read from or to be written to a PNG file.  One\n * or more of these must exist while reading or creating a PNG file.  The\n * information is not used by libpng during read but is used to control what\n * gets written when a PNG file is created.  \"png_get_\" function calls read\n * information during read and \"png_set_\" functions calls write information\n * when creating a PNG.\n * been moved into a separate header file that is not accessible to\n * applications.  Read libpng-manual.txt or libpng.3 for more info.\n */\ntypedef struct png_info_def png_info;\ntypedef png_info * png_infop;\ntypedef const png_info * png_const_infop;\ntypedef png_info * * png_infopp;\n\n/* Types with names ending 'p' are pointer types.  The corresponding types with\n * names ending 'rp' are identical pointer types except that the pointer is\n * marked 'restrict', which means that it is the only pointer to the object\n * passed to the function.  Applications should not use the 'restrict' types;\n * it is always valid to pass 'p' to a pointer with a function argument of the\n * corresponding 'rp' type.  Different compilers have different rules with\n * regard to type matching in the presence of 'restrict'.  For backward\n * compatibility libpng callbacks never have 'restrict' in their parameters and,\n * consequentially, writing portable application code is extremely difficult if\n * an attempt is made to use 'restrict'.\n */\ntypedef png_struct * PNG_RESTRICT png_structrp;\ntypedef const png_struct * PNG_RESTRICT png_const_structrp;\ntypedef png_info * PNG_RESTRICT png_inforp;\ntypedef const png_info * PNG_RESTRICT png_const_inforp;\n\n/* Three color definitions.  The order of the red, green, and blue, (and the\n * exact size) is not important, although the size of the fields need to\n * be png_byte or png_uint_16 (as defined below).\n */\ntypedef struct png_color_struct\n{\n   png_byte red;\n   png_byte green;\n   png_byte blue;\n} png_color;\ntypedef png_color * png_colorp;\ntypedef const png_color * png_const_colorp;\ntypedef png_color * * png_colorpp;\n\ntypedef struct png_color_16_struct\n{\n   png_byte index;    /* used for palette files */\n   png_uint_16 red;   /* for use in red green blue files */\n   png_uint_16 green;\n   png_uint_16 blue;\n   png_uint_16 gray;  /* for use in grayscale files */\n} png_color_16;\ntypedef png_color_16 * png_color_16p;\ntypedef const png_color_16 * png_const_color_16p;\ntypedef png_color_16 * * png_color_16pp;\n\ntypedef struct png_color_8_struct\n{\n   png_byte red;   /* for use in red green blue files */\n   png_byte green;\n   png_byte blue;\n   png_byte gray;  /* for use in grayscale files */\n   png_byte alpha; /* for alpha channel files */\n} png_color_8;\ntypedef png_color_8 * png_color_8p;\ntypedef const png_color_8 * png_const_color_8p;\ntypedef png_color_8 * * png_color_8pp;\n\n/*\n * The following two structures are used for the in-core representation\n * of sPLT chunks.\n */\ntypedef struct png_sPLT_entry_struct\n{\n   png_uint_16 red;\n   png_uint_16 green;\n   png_uint_16 blue;\n   png_uint_16 alpha;\n   png_uint_16 frequency;\n} png_sPLT_entry;\ntypedef png_sPLT_entry * png_sPLT_entryp;\ntypedef const png_sPLT_entry * png_const_sPLT_entryp;\ntypedef png_sPLT_entry * * png_sPLT_entrypp;\n\n/*  When the depth of the sPLT palette is 8 bits, the color and alpha samples\n *  occupy the LSB of their respective members, and the MSB of each member\n *  is zero-filled.  The frequency member always occupies the full 16 bits.\n */\n\ntypedef struct png_sPLT_struct\n{\n   png_charp name;           /* palette name */\n   png_byte depth;           /* depth of palette samples */\n   png_sPLT_entryp entries;  /* palette entries */\n   png_int_32 nentries;      /* number of palette entries */\n} png_sPLT_t;\ntypedef png_sPLT_t * png_sPLT_tp;\ntypedef const png_sPLT_t * png_const_sPLT_tp;\ntypedef png_sPLT_t * * png_sPLT_tpp;\n\n#ifdef PNG_TEXT_SUPPORTED\n/* png_text holds the contents of a text/ztxt/itxt chunk in a PNG file,\n * and whether that contents is compressed or not.  The \"key\" field\n * points to a regular zero-terminated C string.  The \"text\" fields can be a\n * regular C string, an empty string, or a NULL pointer.\n * However, the structure returned by png_get_text() will always contain\n * the \"text\" field as a regular zero-terminated C string (possibly\n * empty), never a NULL pointer, so it can be safely used in printf() and\n * other string-handling functions.  Note that the \"itxt_length\", \"lang\", and\n * \"lang_key\" members of the structure only exist when the library is built\n * with iTXt chunk support.  Prior to libpng-1.4.0 the library was built by\n * default without iTXt support. Also note that when iTXt *is* supported,\n * the \"lang\" and \"lang_key\" fields contain NULL pointers when the\n * \"compression\" field contains * PNG_TEXT_COMPRESSION_NONE or\n * PNG_TEXT_COMPRESSION_zTXt. Note that the \"compression value\" is not the\n * same as what appears in the PNG tEXt/zTXt/iTXt chunk's \"compression flag\"\n * which is always 0 or 1, or its \"compression method\" which is always 0.\n */\ntypedef struct png_text_struct\n{\n   int  compression;       /* compression value:\n                             -1: tEXt, none\n                              0: zTXt, deflate\n                              1: iTXt, none\n                              2: iTXt, deflate  */\n   png_charp key;          /* keyword, 1-79 character description of \"text\" */\n   png_charp text;         /* comment, may be an empty string (ie \"\")\n                              or a NULL pointer */\n   png_size_t text_length; /* length of the text string */\n   png_size_t itxt_length; /* length of the itxt string */\n   png_charp lang;         /* language code, 0-79 characters\n                              or a NULL pointer */\n   png_charp lang_key;     /* keyword translated UTF-8 string, 0 or more\n                              chars or a NULL pointer */\n} png_text;\ntypedef png_text * png_textp;\ntypedef const png_text * png_const_textp;\ntypedef png_text * * png_textpp;\n#endif\n\n/* Supported compression types for text in PNG files (tEXt, and zTXt).\n * The values of the PNG_TEXT_COMPRESSION_ defines should NOT be changed. */\n#define PNG_TEXT_COMPRESSION_NONE_WR -3\n#define PNG_TEXT_COMPRESSION_zTXt_WR -2\n#define PNG_TEXT_COMPRESSION_NONE    -1\n#define PNG_TEXT_COMPRESSION_zTXt     0\n#define PNG_ITXT_COMPRESSION_NONE     1\n#define PNG_ITXT_COMPRESSION_zTXt     2\n#define PNG_TEXT_COMPRESSION_LAST     3  /* Not a valid value */\n\n/* png_time is a way to hold the time in an machine independent way.\n * Two conversions are provided, both from time_t and struct tm.  There\n * is no portable way to convert to either of these structures, as far\n * as I know.  If you know of a portable way, send it to me.  As a side\n * note - PNG has always been Year 2000 compliant!\n */\ntypedef struct png_time_struct\n{\n   png_uint_16 year; /* full year, as in, 1995 */\n   png_byte month;   /* month of year, 1 - 12 */\n   png_byte day;     /* day of month, 1 - 31 */\n   png_byte hour;    /* hour of day, 0 - 23 */\n   png_byte minute;  /* minute of hour, 0 - 59 */\n   png_byte second;  /* second of minute, 0 - 60 (for leap seconds) */\n} png_time;\ntypedef png_time * png_timep;\ntypedef const png_time * png_const_timep;\ntypedef png_time * * png_timepp;\n\n#if defined(PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED) ||\\\n   defined(PNG_USER_CHUNKS_SUPPORTED)\n/* png_unknown_chunk is a structure to hold queued chunks for which there is\n * no specific support.  The idea is that we can use this to queue\n * up private chunks for output even though the library doesn't actually\n * know about their semantics.\n *\n * The data in the structure is set by libpng on read and used on write.\n */\ntypedef struct png_unknown_chunk_t\n{\n    png_byte name[5]; /* Textual chunk name with '\\0' terminator */\n    png_byte *data;   /* Data, should not be modified on read! */\n    png_size_t size;\n\n    /* On write 'location' must be set using the flag values listed below.\n     * Notice that on read it is set by libpng however the values stored have\n     * more bits set than are listed below.  Always treat the value as a\n     * bitmask.  On write set only one bit - setting multiple bits may cause the\n     * chunk to be written in multiple places.\n     */\n    png_byte location; /* mode of operation at read time */\n}\npng_unknown_chunk;\n\ntypedef png_unknown_chunk * png_unknown_chunkp;\ntypedef const png_unknown_chunk * png_const_unknown_chunkp;\ntypedef png_unknown_chunk * * png_unknown_chunkpp;\n#endif\n\n/* Flag values for the unknown chunk location byte. */\n#define PNG_HAVE_IHDR  0x01\n#define PNG_HAVE_PLTE  0x02\n#define PNG_AFTER_IDAT 0x08\n\n/* Maximum positive integer used in PNG is (2^31)-1 */\n#define PNG_UINT_31_MAX ((png_uint_32)0x7fffffffL)\n#define PNG_UINT_32_MAX ((png_uint_32)(-1))\n#define PNG_SIZE_MAX ((png_size_t)(-1))\n\n/* These are constants for fixed point values encoded in the\n * PNG specification manner (x100000)\n */\n#define PNG_FP_1    100000\n#define PNG_FP_HALF  50000\n#define PNG_FP_MAX  ((png_fixed_point)0x7fffffffL)\n#define PNG_FP_MIN  (-PNG_FP_MAX)\n\n/* These describe the color_type field in png_info. */\n/* color type masks */\n#define PNG_COLOR_MASK_PALETTE    1\n#define PNG_COLOR_MASK_COLOR      2\n#define PNG_COLOR_MASK_ALPHA      4\n\n/* color types.  Note that not all combinations are legal */\n#define PNG_COLOR_TYPE_GRAY 0\n#define PNG_COLOR_TYPE_PALETTE  (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_PALETTE)\n#define PNG_COLOR_TYPE_RGB        (PNG_COLOR_MASK_COLOR)\n#define PNG_COLOR_TYPE_RGB_ALPHA  (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_ALPHA)\n#define PNG_COLOR_TYPE_GRAY_ALPHA (PNG_COLOR_MASK_ALPHA)\n/* aliases */\n#define PNG_COLOR_TYPE_RGBA  PNG_COLOR_TYPE_RGB_ALPHA\n#define PNG_COLOR_TYPE_GA  PNG_COLOR_TYPE_GRAY_ALPHA\n\n/* This is for compression type. PNG 1.0-1.2 only define the single type. */\n#define PNG_COMPRESSION_TYPE_BASE 0 /* Deflate method 8, 32K window */\n#define PNG_COMPRESSION_TYPE_DEFAULT PNG_COMPRESSION_TYPE_BASE\n\n/* This is for filter type. PNG 1.0-1.2 only define the single type. */\n#define PNG_FILTER_TYPE_BASE      0 /* Single row per-byte filtering */\n#define PNG_INTRAPIXEL_DIFFERENCING 64 /* Used only in MNG datastreams */\n#define PNG_FILTER_TYPE_DEFAULT   PNG_FILTER_TYPE_BASE\n\n/* These are for the interlacing type.  These values should NOT be changed. */\n#define PNG_INTERLACE_NONE        0 /* Non-interlaced image */\n#define PNG_INTERLACE_ADAM7       1 /* Adam7 interlacing */\n#define PNG_INTERLACE_LAST        2 /* Not a valid value */\n\n/* These are for the oFFs chunk.  These values should NOT be changed. */\n#define PNG_OFFSET_PIXEL          0 /* Offset in pixels */\n#define PNG_OFFSET_MICROMETER     1 /* Offset in micrometers (1/10^6 meter) */\n#define PNG_OFFSET_LAST           2 /* Not a valid value */\n\n/* These are for the pCAL chunk.  These values should NOT be changed. */\n#define PNG_EQUATION_LINEAR       0 /* Linear transformation */\n#define PNG_EQUATION_BASE_E       1 /* Exponential base e transform */\n#define PNG_EQUATION_ARBITRARY    2 /* Arbitrary base exponential transform */\n#define PNG_EQUATION_HYPERBOLIC   3 /* Hyperbolic sine transformation */\n#define PNG_EQUATION_LAST         4 /* Not a valid value */\n\n/* These are for the sCAL chunk.  These values should NOT be changed. */\n#define PNG_SCALE_UNKNOWN         0 /* unknown unit (image scale) */\n#define PNG_SCALE_METER           1 /* meters per pixel */\n#define PNG_SCALE_RADIAN          2 /* radians per pixel */\n#define PNG_SCALE_LAST            3 /* Not a valid value */\n\n/* These are for the pHYs chunk.  These values should NOT be changed. */\n#define PNG_RESOLUTION_UNKNOWN    0 /* pixels/unknown unit (aspect ratio) */\n#define PNG_RESOLUTION_METER      1 /* pixels/meter */\n#define PNG_RESOLUTION_LAST       2 /* Not a valid value */\n\n/* These are for the sRGB chunk.  These values should NOT be changed. */\n#define PNG_sRGB_INTENT_PERCEPTUAL 0\n#define PNG_sRGB_INTENT_RELATIVE   1\n#define PNG_sRGB_INTENT_SATURATION 2\n#define PNG_sRGB_INTENT_ABSOLUTE   3\n#define PNG_sRGB_INTENT_LAST       4 /* Not a valid value */\n\n/* This is for text chunks */\n#define PNG_KEYWORD_MAX_LENGTH     79\n\n/* Maximum number of entries in PLTE/sPLT/tRNS arrays */\n#define PNG_MAX_PALETTE_LENGTH    256\n\n/* These determine if an ancillary chunk's data has been successfully read\n * from the PNG header, or if the application has filled in the corresponding\n * data in the info_struct to be written into the output file.  The values\n * of the PNG_INFO_<chunk> defines should NOT be changed.\n */\n#define PNG_INFO_gAMA 0x0001\n#define PNG_INFO_sBIT 0x0002\n#define PNG_INFO_cHRM 0x0004\n#define PNG_INFO_PLTE 0x0008\n#define PNG_INFO_tRNS 0x0010\n#define PNG_INFO_bKGD 0x0020\n#define PNG_INFO_hIST 0x0040\n#define PNG_INFO_pHYs 0x0080\n#define PNG_INFO_oFFs 0x0100\n#define PNG_INFO_tIME 0x0200\n#define PNG_INFO_pCAL 0x0400\n#define PNG_INFO_sRGB 0x0800   /* GR-P, 0.96a */\n#define PNG_INFO_iCCP 0x1000   /* ESR, 1.0.6 */\n#define PNG_INFO_sPLT 0x2000   /* ESR, 1.0.6 */\n#define PNG_INFO_sCAL 0x4000   /* ESR, 1.0.6 */\n#define PNG_INFO_IDAT 0x8000   /* ESR, 1.0.6 */\n\n/* This is used for the transformation routines, as some of them\n * change these values for the row.  It also should enable using\n * the routines for other purposes.\n */\ntypedef struct png_row_info_struct\n{\n   png_uint_32 width;    /* width of row */\n   png_size_t rowbytes;  /* number of bytes in row */\n   png_byte color_type;  /* color type of row */\n   png_byte bit_depth;   /* bit depth of row */\n   png_byte channels;    /* number of channels (1, 2, 3, or 4) */\n   png_byte pixel_depth; /* bits per pixel (depth * channels) */\n} png_row_info;\n\ntypedef png_row_info * png_row_infop;\ntypedef png_row_info * * png_row_infopp;\n\n/* These are the function types for the I/O functions and for the functions\n * that allow the user to override the default I/O functions with his or her\n * own.  The png_error_ptr type should match that of user-supplied warning\n * and error functions, while the png_rw_ptr type should match that of the\n * user read/write data functions.  Note that the 'write' function must not\n * modify the buffer it is passed. The 'read' function, on the other hand, is\n * expected to return the read data in the buffer.\n */\ntypedef PNG_CALLBACK(void, *png_error_ptr, (png_structp, png_const_charp));\ntypedef PNG_CALLBACK(void, *png_rw_ptr, (png_structp, png_bytep, png_size_t));\ntypedef PNG_CALLBACK(void, *png_flush_ptr, (png_structp));\ntypedef PNG_CALLBACK(void, *png_read_status_ptr, (png_structp, png_uint_32,\n    int));\ntypedef PNG_CALLBACK(void, *png_write_status_ptr, (png_structp, png_uint_32,\n    int));\n\n#ifdef PNG_PROGRESSIVE_READ_SUPPORTED\ntypedef PNG_CALLBACK(void, *png_progressive_info_ptr, (png_structp, png_infop));\ntypedef PNG_CALLBACK(void, *png_progressive_end_ptr, (png_structp, png_infop));\n\n/* The following callback receives png_uint_32 row_number, int pass for the\n * png_bytep data of the row.  When transforming an interlaced image the\n * row number is the row number within the sub-image of the interlace pass, so\n * the value will increase to the height of the sub-image (not the full image)\n * then reset to 0 for the next pass.\n *\n * Use PNG_ROW_FROM_PASS_ROW(row, pass) and PNG_COL_FROM_PASS_COL(col, pass) to\n * find the output pixel (x,y) given an interlaced sub-image pixel\n * (row,col,pass).  (See below for these macros.)\n */\ntypedef PNG_CALLBACK(void, *png_progressive_row_ptr, (png_structp, png_bytep,\n    png_uint_32, int));\n#endif\n\n#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \\\n    defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)\ntypedef PNG_CALLBACK(void, *png_user_transform_ptr, (png_structp, png_row_infop,\n    png_bytep));\n#endif\n\n#ifdef PNG_USER_CHUNKS_SUPPORTED\ntypedef PNG_CALLBACK(int, *png_user_chunk_ptr, (png_structp,\n    png_unknown_chunkp));\n#endif\n#ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED\n/* not used anywhere */\n/* typedef PNG_CALLBACK(void, *png_unknown_chunk_ptr, (png_structp)); */\n#endif\n\n#ifdef PNG_SETJMP_SUPPORTED\n/* This must match the function definition in <setjmp.h>, and the application\n * must include this before png.h to obtain the definition of jmp_buf.  The\n * function is required to be PNG_NORETURN, but this is not checked.  If the\n * function does return the application will crash via an abort() or similar\n * system level call.\n *\n * If you get a warning here while building the library you may need to make\n * changes to ensure that pnglibconf.h records the calling convention used by\n * your compiler.  This may be very difficult - try using a different compiler\n * to build the library!\n */\nPNG_FUNCTION(void, (PNGCAPI *png_longjmp_ptr), PNGARG((jmp_buf, int)), typedef);\n#endif\n\n/* Transform masks for the high-level interface */\n#define PNG_TRANSFORM_IDENTITY       0x0000    /* read and write */\n#define PNG_TRANSFORM_STRIP_16       0x0001    /* read only */\n#define PNG_TRANSFORM_STRIP_ALPHA    0x0002    /* read only */\n#define PNG_TRANSFORM_PACKING        0x0004    /* read and write */\n#define PNG_TRANSFORM_PACKSWAP       0x0008    /* read and write */\n#define PNG_TRANSFORM_EXPAND         0x0010    /* read only */\n#define PNG_TRANSFORM_INVERT_MONO    0x0020    /* read and write */\n#define PNG_TRANSFORM_SHIFT          0x0040    /* read and write */\n#define PNG_TRANSFORM_BGR            0x0080    /* read and write */\n#define PNG_TRANSFORM_SWAP_ALPHA     0x0100    /* read and write */\n#define PNG_TRANSFORM_SWAP_ENDIAN    0x0200    /* read and write */\n#define PNG_TRANSFORM_INVERT_ALPHA   0x0400    /* read and write */\n#define PNG_TRANSFORM_STRIP_FILLER   0x0800    /* write only */\n/* Added to libpng-1.2.34 */\n#define PNG_TRANSFORM_STRIP_FILLER_BEFORE PNG_TRANSFORM_STRIP_FILLER\n#define PNG_TRANSFORM_STRIP_FILLER_AFTER 0x1000 /* write only */\n/* Added to libpng-1.4.0 */\n#define PNG_TRANSFORM_GRAY_TO_RGB   0x2000      /* read only */\n/* Added to libpng-1.5.4 */\n#define PNG_TRANSFORM_EXPAND_16     0x4000      /* read only */\n#define PNG_TRANSFORM_SCALE_16      0x8000      /* read only */\n\n/* Flags for MNG supported features */\n#define PNG_FLAG_MNG_EMPTY_PLTE     0x01\n#define PNG_FLAG_MNG_FILTER_64      0x04\n#define PNG_ALL_MNG_FEATURES        0x05\n\n/* NOTE: prior to 1.5 these functions had no 'API' style declaration,\n * this allowed the zlib default functions to be used on Windows\n * platforms.  In 1.5 the zlib default malloc (which just calls malloc and\n * ignores the first argument) should be completely compatible with the\n * following.\n */\ntypedef PNG_CALLBACK(png_voidp, *png_malloc_ptr, (png_structp,\n    png_alloc_size_t));\ntypedef PNG_CALLBACK(void, *png_free_ptr, (png_structp, png_voidp));\n\n/* Section 3: exported functions\n * Here are the function definitions most commonly used.  This is not\n * the place to find out how to use libpng.  See libpng-manual.txt for the\n * full explanation, see example.c for the summary.  This just provides\n * a simple one line description of the use of each function.\n *\n * The PNG_EXPORT() and PNG_EXPORTA() macros used below are defined in\n * pngconf.h and in the *.dfn files in the scripts directory.\n *\n *   PNG_EXPORT(ordinal, type, name, (args));\n *\n *       ordinal:    ordinal that is used while building\n *                   *.def files. The ordinal value is only\n *                   relevant when preprocessing png.h with\n *                   the *.dfn files for building symbol table\n *                   entries, and are removed by pngconf.h.\n *       type:       return type of the function\n *       name:       function name\n *       args:       function arguments, with types\n *\n * When we wish to append attributes to a function prototype we use\n * the PNG_EXPORTA() macro instead.\n *\n *   PNG_EXPORTA(ordinal, type, name, (args), attributes);\n *\n *       ordinal, type, name, and args: same as in PNG_EXPORT().\n *       attributes: function attributes\n */\n\n/* Returns the version number of the library */\nPNG_EXPORT(1, png_uint_32, png_access_version_number, (void));\n\n/* Tell lib we have already handled the first <num_bytes> magic bytes.\n * Handling more than 8 bytes from the beginning of the file is an error.\n */\nPNG_EXPORT(2, void, png_set_sig_bytes, (png_structrp png_ptr, int num_bytes));\n\n/* Check sig[start] through sig[start + num_to_check - 1] to see if it's a\n * PNG file.  Returns zero if the supplied bytes match the 8-byte PNG\n * signature, and non-zero otherwise.  Having num_to_check == 0 or\n * start > 7 will always fail (ie return non-zero).\n */\nPNG_EXPORT(3, int, png_sig_cmp, (png_const_bytep sig, png_size_t start,\n    png_size_t num_to_check));\n\n/* Simple signature checking function.  This is the same as calling\n * png_check_sig(sig, n) := !png_sig_cmp(sig, 0, n).\n */\n#define png_check_sig(sig, n) !png_sig_cmp((sig), 0, (n))\n\n/* Allocate and initialize png_ptr struct for reading, and any other memory. */\nPNG_EXPORTA(4, png_structp, png_create_read_struct,\n    (png_const_charp user_png_ver, png_voidp error_ptr,\n    png_error_ptr error_fn, png_error_ptr warn_fn),\n    PNG_ALLOCATED);\n\n/* Allocate and initialize png_ptr struct for writing, and any other memory */\nPNG_EXPORTA(5, png_structp, png_create_write_struct,\n    (png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn,\n    png_error_ptr warn_fn),\n    PNG_ALLOCATED);\n\nPNG_EXPORT(6, png_size_t, png_get_compression_buffer_size,\n    (png_const_structrp png_ptr));\n\nPNG_EXPORT(7, void, png_set_compression_buffer_size, (png_structrp png_ptr,\n    png_size_t size));\n\n/* Moved from pngconf.h in 1.4.0 and modified to ensure setjmp/longjmp\n * match up.\n */\n#ifdef PNG_SETJMP_SUPPORTED\n/* This function returns the jmp_buf built in to *png_ptr.  It must be\n * supplied with an appropriate 'longjmp' function to use on that jmp_buf\n * unless the default error function is overridden in which case NULL is\n * acceptable.  The size of the jmp_buf is checked against the actual size\n * allocated by the library - the call will return NULL on a mismatch\n * indicating an ABI mismatch.\n */\nPNG_EXPORT(8, jmp_buf*, png_set_longjmp_fn, (png_structrp png_ptr,\n    png_longjmp_ptr longjmp_fn, size_t jmp_buf_size));\n#  define png_jmpbuf(png_ptr) \\\n      (*png_set_longjmp_fn((png_ptr), longjmp, (sizeof (jmp_buf))))\n#else\n#  define png_jmpbuf(png_ptr) \\\n      (LIBPNG_WAS_COMPILED_WITH__PNG_NO_SETJMP)\n#endif\n/* This function should be used by libpng applications in place of\n * longjmp(png_ptr->jmpbuf, val).  If longjmp_fn() has been set, it\n * will use it; otherwise it will call PNG_ABORT().  This function was\n * added in libpng-1.5.0.\n */\nPNG_EXPORTA(9, void, png_longjmp, (png_const_structrp png_ptr, int val),\n    PNG_NORETURN);\n\n#ifdef PNG_READ_SUPPORTED\n/* Reset the compression stream */\nPNG_EXPORTA(10, int, png_reset_zstream, (png_structrp png_ptr), PNG_DEPRECATED);\n#endif\n\n/* New functions added in libpng-1.0.2 (not enabled by default until 1.2.0) */\n#ifdef PNG_USER_MEM_SUPPORTED\nPNG_EXPORTA(11, png_structp, png_create_read_struct_2,\n    (png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn,\n    png_error_ptr warn_fn,\n    png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn),\n    PNG_ALLOCATED);\nPNG_EXPORTA(12, png_structp, png_create_write_struct_2,\n    (png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn,\n    png_error_ptr warn_fn,\n    png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn),\n    PNG_ALLOCATED);\n#endif\n\n/* Write the PNG file signature. */\nPNG_EXPORT(13, void, png_write_sig, (png_structrp png_ptr));\n\n/* Write a PNG chunk - size, type, (optional) data, CRC. */\nPNG_EXPORT(14, void, png_write_chunk, (png_structrp png_ptr, png_const_bytep\n    chunk_name, png_const_bytep data, png_size_t length));\n\n/* Write the start of a PNG chunk - length and chunk name. */\nPNG_EXPORT(15, void, png_write_chunk_start, (png_structrp png_ptr,\n    png_const_bytep chunk_name, png_uint_32 length));\n\n/* Write the data of a PNG chunk started with png_write_chunk_start(). */\nPNG_EXPORT(16, void, png_write_chunk_data, (png_structrp png_ptr,\n    png_const_bytep data, png_size_t length));\n\n/* Finish a chunk started with png_write_chunk_start() (includes CRC). */\nPNG_EXPORT(17, void, png_write_chunk_end, (png_structrp png_ptr));\n\n/* Allocate and initialize the info structure */\nPNG_EXPORTA(18, png_infop, png_create_info_struct, (png_const_structrp png_ptr),\n    PNG_ALLOCATED);\n\n/* DEPRECATED: this function allowed init structures to be created using the\n * default allocation method (typically malloc).  Use is deprecated in 1.6.0 and\n * the API will be removed in the future.\n */\nPNG_EXPORTA(19, void, png_info_init_3, (png_infopp info_ptr,\n    png_size_t png_info_struct_size), PNG_DEPRECATED);\n\n/* Writes all the PNG information before the image. */\nPNG_EXPORT(20, void, png_write_info_before_PLTE,\n    (png_structrp png_ptr, png_const_inforp info_ptr));\nPNG_EXPORT(21, void, png_write_info,\n    (png_structrp png_ptr, png_const_inforp info_ptr));\n\n#ifdef PNG_SEQUENTIAL_READ_SUPPORTED\n/* Read the information before the actual image data. */\nPNG_EXPORT(22, void, png_read_info,\n    (png_structrp png_ptr, png_inforp info_ptr));\n#endif\n\n#ifdef PNG_TIME_RFC1123_SUPPORTED\n   /* Convert to a US string format: there is no localization support in this\n    * routine.  The original implementation used a 29 character buffer in\n    * png_struct, this will be removed in future versions.\n    */\n#if PNG_LIBPNG_VER < 10700\n/* To do: remove this from libpng17 (and from libpng17/png.c and pngstruct.h) */\nPNG_EXPORTA(23, png_const_charp, png_convert_to_rfc1123, (png_structrp png_ptr,\n    png_const_timep ptime),PNG_DEPRECATED);\n#endif\nPNG_EXPORT(241, int, png_convert_to_rfc1123_buffer, (char out[29],\n    png_const_timep ptime));\n#endif\n\n#ifdef PNG_CONVERT_tIME_SUPPORTED\n/* Convert from a struct tm to png_time */\nPNG_EXPORT(24, void, png_convert_from_struct_tm, (png_timep ptime,\n    const struct tm * ttime));\n\n/* Convert from time_t to png_time.  Uses gmtime() */\nPNG_EXPORT(25, void, png_convert_from_time_t, (png_timep ptime, time_t ttime));\n#endif /* PNG_CONVERT_tIME_SUPPORTED */\n\n#ifdef PNG_READ_EXPAND_SUPPORTED\n/* Expand data to 24-bit RGB, or 8-bit grayscale, with alpha if available. */\nPNG_EXPORT(26, void, png_set_expand, (png_structrp png_ptr));\nPNG_EXPORT(27, void, png_set_expand_gray_1_2_4_to_8, (png_structrp png_ptr));\nPNG_EXPORT(28, void, png_set_palette_to_rgb, (png_structrp png_ptr));\nPNG_EXPORT(29, void, png_set_tRNS_to_alpha, (png_structrp png_ptr));\n#endif\n\n#ifdef PNG_READ_EXPAND_16_SUPPORTED\n/* Expand to 16-bit channels, forces conversion of palette to RGB and expansion\n * of a tRNS chunk if present.\n */\nPNG_EXPORT(221, void, png_set_expand_16, (png_structrp png_ptr));\n#endif\n\n#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED)\n/* Use blue, green, red order for pixels. */\nPNG_EXPORT(30, void, png_set_bgr, (png_structrp png_ptr));\n#endif\n\n#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED\n/* Expand the grayscale to 24-bit RGB if necessary. */\nPNG_EXPORT(31, void, png_set_gray_to_rgb, (png_structrp png_ptr));\n#endif\n\n#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED\n/* Reduce RGB to grayscale. */\n#define PNG_ERROR_ACTION_NONE  1\n#define PNG_ERROR_ACTION_WARN  2\n#define PNG_ERROR_ACTION_ERROR 3\n#define PNG_RGB_TO_GRAY_DEFAULT (-1)/*for red/green coefficients*/\n\nPNG_FP_EXPORT(32, void, png_set_rgb_to_gray, (png_structrp png_ptr,\n    int error_action, double red, double green))\nPNG_FIXED_EXPORT(33, void, png_set_rgb_to_gray_fixed, (png_structrp png_ptr,\n    int error_action, png_fixed_point red, png_fixed_point green))\n\nPNG_EXPORT(34, png_byte, png_get_rgb_to_gray_status, (png_const_structrp\n    png_ptr));\n#endif\n\n#ifdef PNG_BUILD_GRAYSCALE_PALETTE_SUPPORTED\nPNG_EXPORT(35, void, png_build_grayscale_palette, (int bit_depth,\n    png_colorp palette));\n#endif\n\n#ifdef PNG_READ_ALPHA_MODE_SUPPORTED\n/* How the alpha channel is interpreted - this affects how the color channels\n * of a PNG file are returned to the calling application when an alpha channel,\n * or a tRNS chunk in a palette file, is present.\n *\n * This has no effect on the way pixels are written into a PNG output\n * datastream. The color samples in a PNG datastream are never premultiplied\n * with the alpha samples.\n *\n * The default is to return data according to the PNG specification: the alpha\n * channel is a linear measure of the contribution of the pixel to the\n * corresponding composited pixel, and the color channels are unassociated\n * (not premultiplied).  The gamma encoded color channels must be scaled\n * according to the contribution and to do this it is necessary to undo\n * the encoding, scale the color values, perform the composition and reencode\n * the values.  This is the 'PNG' mode.\n *\n * The alternative is to 'associate' the alpha with the color information by\n * storing color channel values that have been scaled by the alpha.\n * image.  These are the 'STANDARD', 'ASSOCIATED' or 'PREMULTIPLIED' modes\n * (the latter being the two common names for associated alpha color channels).\n *\n * For the 'OPTIMIZED' mode, a pixel is treated as opaque only if the alpha\n * value is equal to the maximum value.\n *\n * The final choice is to gamma encode the alpha channel as well.  This is\n * broken because, in practice, no implementation that uses this choice\n * correctly undoes the encoding before handling alpha composition.  Use this\n * choice only if other serious errors in the software or hardware you use\n * mandate it; the typical serious error is for dark halos to appear around\n * opaque areas of the composited PNG image because of arithmetic overflow.\n *\n * The API function png_set_alpha_mode specifies which of these choices to use\n * with an enumerated 'mode' value and the gamma of the required output:\n */\n#define PNG_ALPHA_PNG           0 /* according to the PNG standard */\n#define PNG_ALPHA_STANDARD      1 /* according to Porter/Duff */\n#define PNG_ALPHA_ASSOCIATED    1 /* as above; this is the normal practice */\n#define PNG_ALPHA_PREMULTIPLIED 1 /* as above */\n#define PNG_ALPHA_OPTIMIZED     2 /* 'PNG' for opaque pixels, else 'STANDARD' */\n#define PNG_ALPHA_BROKEN        3 /* the alpha channel is gamma encoded */\n\nPNG_FP_EXPORT(227, void, png_set_alpha_mode, (png_structrp png_ptr, int mode,\n    double output_gamma))\nPNG_FIXED_EXPORT(228, void, png_set_alpha_mode_fixed, (png_structrp png_ptr,\n    int mode, png_fixed_point output_gamma))\n#endif\n\n#if defined(PNG_GAMMA_SUPPORTED) || defined(PNG_READ_ALPHA_MODE_SUPPORTED)\n/* The output_gamma value is a screen gamma in libpng terminology: it expresses\n * how to decode the output values, not how they are encoded.\n */\n#define PNG_DEFAULT_sRGB -1       /* sRGB gamma and color space */\n#define PNG_GAMMA_MAC_18 -2       /* Old Mac '1.8' gamma and color space */\n#define PNG_GAMMA_sRGB   220000   /* Television standards--matches sRGB gamma */\n#define PNG_GAMMA_LINEAR PNG_FP_1 /* Linear */\n#endif\n\n/* The following are examples of calls to png_set_alpha_mode to achieve the\n * required overall gamma correction and, where necessary, alpha\n * premultiplication.\n *\n * png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_DEFAULT_sRGB);\n *    This is the default libpng handling of the alpha channel - it is not\n *    pre-multiplied into the color components.  In addition the call states\n *    that the output is for a sRGB system and causes all PNG files without gAMA\n *    chunks to be assumed to be encoded using sRGB.\n *\n * png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_GAMMA_MAC);\n *    In this case the output is assumed to be something like an sRGB conformant\n *    display preceeded by a power-law lookup table of power 1.45.  This is how\n *    early Mac systems behaved.\n *\n * png_set_alpha_mode(pp, PNG_ALPHA_STANDARD, PNG_GAMMA_LINEAR);\n *    This is the classic Jim Blinn approach and will work in academic\n *    environments where everything is done by the book.  It has the shortcoming\n *    of assuming that input PNG data with no gamma information is linear - this\n *    is unlikely to be correct unless the PNG files where generated locally.\n *    Most of the time the output precision will be so low as to show\n *    significant banding in dark areas of the image.\n *\n * png_set_expand_16(pp);\n * png_set_alpha_mode(pp, PNG_ALPHA_STANDARD, PNG_DEFAULT_sRGB);\n *    This is a somewhat more realistic Jim Blinn inspired approach.  PNG files\n *    are assumed to have the sRGB encoding if not marked with a gamma value and\n *    the output is always 16 bits per component.  This permits accurate scaling\n *    and processing of the data.  If you know that your input PNG files were\n *    generated locally you might need to replace PNG_DEFAULT_sRGB with the\n *    correct value for your system.\n *\n * png_set_alpha_mode(pp, PNG_ALPHA_OPTIMIZED, PNG_DEFAULT_sRGB);\n *    If you just need to composite the PNG image onto an existing background\n *    and if you control the code that does this you can use the optimization\n *    setting.  In this case you just copy completely opaque pixels to the\n *    output.  For pixels that are not completely transparent (you just skip\n *    those) you do the composition math using png_composite or png_composite_16\n *    below then encode the resultant 8-bit or 16-bit values to match the output\n *    encoding.\n *\n * Other cases\n *    If neither the PNG nor the standard linear encoding work for you because\n *    of the software or hardware you use then you have a big problem.  The PNG\n *    case will probably result in halos around the image.  The linear encoding\n *    will probably result in a washed out, too bright, image (it's actually too\n *    contrasty.)  Try the ALPHA_OPTIMIZED mode above - this will probably\n *    substantially reduce the halos.  Alternatively try:\n *\n * png_set_alpha_mode(pp, PNG_ALPHA_BROKEN, PNG_DEFAULT_sRGB);\n *    This option will also reduce the halos, but there will be slight dark\n *    halos round the opaque parts of the image where the background is light.\n *    In the OPTIMIZED mode the halos will be light halos where the background\n *    is dark.  Take your pick - the halos are unavoidable unless you can get\n *    your hardware/software fixed!  (The OPTIMIZED approach is slightly\n *    faster.)\n *\n * When the default gamma of PNG files doesn't match the output gamma.\n *    If you have PNG files with no gamma information png_set_alpha_mode allows\n *    you to provide a default gamma, but it also sets the ouput gamma to the\n *    matching value.  If you know your PNG files have a gamma that doesn't\n *    match the output you can take advantage of the fact that\n *    png_set_alpha_mode always sets the output gamma but only sets the PNG\n *    default if it is not already set:\n *\n * png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_DEFAULT_sRGB);\n * png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_GAMMA_MAC);\n *    The first call sets both the default and the output gamma values, the\n *    second call overrides the output gamma without changing the default.  This\n *    is easier than achieving the same effect with png_set_gamma.  You must use\n *    PNG_ALPHA_PNG for the first call - internal checking in png_set_alpha will\n *    fire if more than one call to png_set_alpha_mode and png_set_background is\n *    made in the same read operation, however multiple calls with PNG_ALPHA_PNG\n *    are ignored.\n */\n\n#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED\nPNG_EXPORT(36, void, png_set_strip_alpha, (png_structrp png_ptr));\n#endif\n\n#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) || \\\n    defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED)\nPNG_EXPORT(37, void, png_set_swap_alpha, (png_structrp png_ptr));\n#endif\n\n#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) || \\\n    defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED)\nPNG_EXPORT(38, void, png_set_invert_alpha, (png_structrp png_ptr));\n#endif\n\n#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED)\n/* Add a filler byte to 8-bit Gray or 24-bit RGB images. */\nPNG_EXPORT(39, void, png_set_filler, (png_structrp png_ptr, png_uint_32 filler,\n    int flags));\n/* The values of the PNG_FILLER_ defines should NOT be changed */\n#  define PNG_FILLER_BEFORE 0\n#  define PNG_FILLER_AFTER 1\n/* Add an alpha byte to 8-bit Gray or 24-bit RGB images. */\nPNG_EXPORT(40, void, png_set_add_alpha, (png_structrp png_ptr,\n    png_uint_32 filler, int flags));\n#endif /* PNG_READ_FILLER_SUPPORTED || PNG_WRITE_FILLER_SUPPORTED */\n\n#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED)\n/* Swap bytes in 16-bit depth files. */\nPNG_EXPORT(41, void, png_set_swap, (png_structrp png_ptr));\n#endif\n\n#if defined(PNG_READ_PACK_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED)\n/* Use 1 byte per pixel in 1, 2, or 4-bit depth files. */\nPNG_EXPORT(42, void, png_set_packing, (png_structrp png_ptr));\n#endif\n\n#if defined(PNG_READ_PACKSWAP_SUPPORTED) || \\\n    defined(PNG_WRITE_PACKSWAP_SUPPORTED)\n/* Swap packing order of pixels in bytes. */\nPNG_EXPORT(43, void, png_set_packswap, (png_structrp png_ptr));\n#endif\n\n#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED)\n/* Converts files to legal bit depths. */\nPNG_EXPORT(44, void, png_set_shift, (png_structrp png_ptr, png_const_color_8p\n    true_bits));\n#endif\n\n#if defined(PNG_READ_INTERLACING_SUPPORTED) || \\\n    defined(PNG_WRITE_INTERLACING_SUPPORTED)\n/* Have the code handle the interlacing.  Returns the number of passes.\n * MUST be called before png_read_update_info or png_start_read_image,\n * otherwise it will not have the desired effect.  Note that it is still\n * necessary to call png_read_row or png_read_rows png_get_image_height\n * times for each pass.\n*/\nPNG_EXPORT(45, int, png_set_interlace_handling, (png_structrp png_ptr));\n#endif\n\n#if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED)\n/* Invert monochrome files */\nPNG_EXPORT(46, void, png_set_invert_mono, (png_structrp png_ptr));\n#endif\n\n#ifdef PNG_READ_BACKGROUND_SUPPORTED\n/* Handle alpha and tRNS by replacing with a background color.  Prior to\n * libpng-1.5.4 this API must not be called before the PNG file header has been\n * read.  Doing so will result in unexpected behavior and possible warnings or\n * errors if the PNG file contains a bKGD chunk.\n */\nPNG_FP_EXPORT(47, void, png_set_background, (png_structrp png_ptr,\n    png_const_color_16p background_color, int background_gamma_code,\n    int need_expand, double background_gamma))\nPNG_FIXED_EXPORT(215, void, png_set_background_fixed, (png_structrp png_ptr,\n    png_const_color_16p background_color, int background_gamma_code,\n    int need_expand, png_fixed_point background_gamma))\n#endif\n#ifdef PNG_READ_BACKGROUND_SUPPORTED\n#  define PNG_BACKGROUND_GAMMA_UNKNOWN 0\n#  define PNG_BACKGROUND_GAMMA_SCREEN  1\n#  define PNG_BACKGROUND_GAMMA_FILE    2\n#  define PNG_BACKGROUND_GAMMA_UNIQUE  3\n#endif\n\n#ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED\n/* Scale a 16-bit depth file down to 8-bit, accurately. */\nPNG_EXPORT(229, void, png_set_scale_16, (png_structrp png_ptr));\n#endif\n\n#ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED\n#define PNG_READ_16_TO_8 SUPPORTED /* Name prior to 1.5.4 */\n/* Strip the second byte of information from a 16-bit depth file. */\nPNG_EXPORT(48, void, png_set_strip_16, (png_structrp png_ptr));\n#endif\n\n#ifdef PNG_READ_QUANTIZE_SUPPORTED\n/* Turn on quantizing, and reduce the palette to the number of colors\n * available.\n */\nPNG_EXPORT(49, void, png_set_quantize, (png_structrp png_ptr,\n    png_colorp palette, int num_palette, int maximum_colors,\n    png_const_uint_16p histogram, int full_quantize));\n#endif\n\n#ifdef PNG_READ_GAMMA_SUPPORTED\n/* The threshold on gamma processing is configurable but hard-wired into the\n * library.  The following is the floating point variant.\n */\n#define PNG_GAMMA_THRESHOLD (PNG_GAMMA_THRESHOLD_FIXED*.00001)\n\n/* Handle gamma correction. Screen_gamma=(display_exponent).\n * NOTE: this API simply sets the screen and file gamma values. It will\n * therefore override the value for gamma in a PNG file if it is called after\n * the file header has been read - use with care  - call before reading the PNG\n * file for best results!\n *\n * These routines accept the same gamma values as png_set_alpha_mode (described\n * above).  The PNG_GAMMA_ defines and PNG_DEFAULT_sRGB can be passed to either\n * API (floating point or fixed.)  Notice, however, that the 'file_gamma' value\n * is the inverse of a 'screen gamma' value.\n */\nPNG_FP_EXPORT(50, void, png_set_gamma, (png_structrp png_ptr,\n    double screen_gamma, double override_file_gamma))\nPNG_FIXED_EXPORT(208, void, png_set_gamma_fixed, (png_structrp png_ptr,\n    png_fixed_point screen_gamma, png_fixed_point override_file_gamma))\n#endif\n\n#ifdef PNG_WRITE_FLUSH_SUPPORTED\n/* Set how many lines between output flushes - 0 for no flushing */\nPNG_EXPORT(51, void, png_set_flush, (png_structrp png_ptr, int nrows));\n/* Flush the current PNG output buffer */\nPNG_EXPORT(52, void, png_write_flush, (png_structrp png_ptr));\n#endif\n\n/* Optional update palette with requested transformations */\nPNG_EXPORT(53, void, png_start_read_image, (png_structrp png_ptr));\n\n/* Optional call to update the users info structure */\nPNG_EXPORT(54, void, png_read_update_info, (png_structrp png_ptr,\n    png_inforp info_ptr));\n\n#ifdef PNG_SEQUENTIAL_READ_SUPPORTED\n/* Read one or more rows of image data. */\nPNG_EXPORT(55, void, png_read_rows, (png_structrp png_ptr, png_bytepp row,\n    png_bytepp display_row, png_uint_32 num_rows));\n#endif\n\n#ifdef PNG_SEQUENTIAL_READ_SUPPORTED\n/* Read a row of data. */\nPNG_EXPORT(56, void, png_read_row, (png_structrp png_ptr, png_bytep row,\n    png_bytep display_row));\n#endif\n\n#ifdef PNG_SEQUENTIAL_READ_SUPPORTED\n/* Read the whole image into memory at once. */\nPNG_EXPORT(57, void, png_read_image, (png_structrp png_ptr, png_bytepp image));\n#endif\n\n/* Write a row of image data */\nPNG_EXPORT(58, void, png_write_row, (png_structrp png_ptr,\n    png_const_bytep row));\n\n/* Write a few rows of image data: (*row) is not written; however, the type\n * is declared as writeable to maintain compatibility with previous versions\n * of libpng and to allow the 'display_row' array from read_rows to be passed\n * unchanged to write_rows.\n */\nPNG_EXPORT(59, void, png_write_rows, (png_structrp png_ptr, png_bytepp row,\n    png_uint_32 num_rows));\n\n/* Write the image data */\nPNG_EXPORT(60, void, png_write_image, (png_structrp png_ptr, png_bytepp image));\n\n/* Write the end of the PNG file. */\nPNG_EXPORT(61, void, png_write_end, (png_structrp png_ptr,\n    png_inforp info_ptr));\n\n#ifdef PNG_SEQUENTIAL_READ_SUPPORTED\n/* Read the end of the PNG file. */\nPNG_EXPORT(62, void, png_read_end, (png_structrp png_ptr, png_inforp info_ptr));\n#endif\n\n/* Free any memory associated with the png_info_struct */\nPNG_EXPORT(63, void, png_destroy_info_struct, (png_const_structrp png_ptr,\n    png_infopp info_ptr_ptr));\n\n/* Free any memory associated with the png_struct and the png_info_structs */\nPNG_EXPORT(64, void, png_destroy_read_struct, (png_structpp png_ptr_ptr,\n    png_infopp info_ptr_ptr, png_infopp end_info_ptr_ptr));\n\n/* Free any memory associated with the png_struct and the png_info_structs */\nPNG_EXPORT(65, void, png_destroy_write_struct, (png_structpp png_ptr_ptr,\n    png_infopp info_ptr_ptr));\n\n/* Set the libpng method of handling chunk CRC errors */\nPNG_EXPORT(66, void, png_set_crc_action, (png_structrp png_ptr, int crit_action,\n    int ancil_action));\n\n/* Values for png_set_crc_action() say how to handle CRC errors in\n * ancillary and critical chunks, and whether to use the data contained\n * therein.  Note that it is impossible to \"discard\" data in a critical\n * chunk.  For versions prior to 0.90, the action was always error/quit,\n * whereas in version 0.90 and later, the action for CRC errors in ancillary\n * chunks is warn/discard.  These values should NOT be changed.\n *\n *      value                       action:critical     action:ancillary\n */\n#define PNG_CRC_DEFAULT       0  /* error/quit          warn/discard data */\n#define PNG_CRC_ERROR_QUIT    1  /* error/quit          error/quit        */\n#define PNG_CRC_WARN_DISCARD  2  /* (INVALID)           warn/discard data */\n#define PNG_CRC_WARN_USE      3  /* warn/use data       warn/use data     */\n#define PNG_CRC_QUIET_USE     4  /* quiet/use data      quiet/use data    */\n#define PNG_CRC_NO_CHANGE     5  /* use current value   use current value */\n\n/* These functions give the user control over the scan-line filtering in\n * libpng and the compression methods used by zlib.  These functions are\n * mainly useful for testing, as the defaults should work with most users.\n * Those users who are tight on memory or want faster performance at the\n * expense of compression can modify them.  See the compression library\n * header file (zlib.h) for an explination of the compression functions.\n */\n\n/* Set the filtering method(s) used by libpng.  Currently, the only valid\n * value for \"method\" is 0.\n */\nPNG_EXPORT(67, void, png_set_filter, (png_structrp png_ptr, int method,\n    int filters));\n\n/* Flags for png_set_filter() to say which filters to use.  The flags\n * are chosen so that they don't conflict with real filter types\n * below, in case they are supplied instead of the #defined constants.\n * These values should NOT be changed.\n */\n#define PNG_NO_FILTERS     0x00\n#define PNG_FILTER_NONE    0x08\n#define PNG_FILTER_SUB     0x10\n#define PNG_FILTER_UP      0x20\n#define PNG_FILTER_AVG     0x40\n#define PNG_FILTER_PAETH   0x80\n#define PNG_ALL_FILTERS (PNG_FILTER_NONE | PNG_FILTER_SUB | PNG_FILTER_UP | \\\n                         PNG_FILTER_AVG | PNG_FILTER_PAETH)\n\n/* Filter values (not flags) - used in pngwrite.c, pngwutil.c for now.\n * These defines should NOT be changed.\n */\n#define PNG_FILTER_VALUE_NONE  0\n#define PNG_FILTER_VALUE_SUB   1\n#define PNG_FILTER_VALUE_UP    2\n#define PNG_FILTER_VALUE_AVG   3\n#define PNG_FILTER_VALUE_PAETH 4\n#define PNG_FILTER_VALUE_LAST  5\n\n#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED /* EXPERIMENTAL */\n/* The \"heuristic_method\" is given by one of the PNG_FILTER_HEURISTIC_\n * defines, either the default (minimum-sum-of-absolute-differences), or\n * the experimental method (weighted-minimum-sum-of-absolute-differences).\n *\n * Weights are factors >= 1.0, indicating how important it is to keep the\n * filter type consistent between rows.  Larger numbers mean the current\n * filter is that many times as likely to be the same as the \"num_weights\"\n * previous filters.  This is cumulative for each previous row with a weight.\n * There needs to be \"num_weights\" values in \"filter_weights\", or it can be\n * NULL if the weights aren't being specified.  Weights have no influence on\n * the selection of the first row filter.  Well chosen weights can (in theory)\n * improve the compression for a given image.\n *\n * Costs are factors >= 1.0 indicating the relative decoding costs of a\n * filter type.  Higher costs indicate more decoding expense, and are\n * therefore less likely to be selected over a filter with lower computational\n * costs.  There needs to be a value in \"filter_costs\" for each valid filter\n * type (given by PNG_FILTER_VALUE_LAST), or it can be NULL if you aren't\n * setting the costs.  Costs try to improve the speed of decompression without\n * unduly increasing the compressed image size.\n *\n * A negative weight or cost indicates the default value is to be used, and\n * values in the range [0.0, 1.0) indicate the value is to remain unchanged.\n * The default values for both weights and costs are currently 1.0, but may\n * change if good general weighting/cost heuristics can be found.  If both\n * the weights and costs are set to 1.0, this degenerates the WEIGHTED method\n * to the UNWEIGHTED method, but with added encoding time/computation.\n */\nPNG_FP_EXPORT(68, void, png_set_filter_heuristics, (png_structrp png_ptr,\n    int heuristic_method, int num_weights, png_const_doublep filter_weights,\n    png_const_doublep filter_costs))\nPNG_FIXED_EXPORT(209, void, png_set_filter_heuristics_fixed,\n    (png_structrp png_ptr, int heuristic_method, int num_weights,\n    png_const_fixed_point_p filter_weights,\n    png_const_fixed_point_p filter_costs))\n#endif /*  PNG_WRITE_WEIGHTED_FILTER_SUPPORTED */\n\n/* Heuristic used for row filter selection.  These defines should NOT be\n * changed.\n */\n#define PNG_FILTER_HEURISTIC_DEFAULT    0  /* Currently \"UNWEIGHTED\" */\n#define PNG_FILTER_HEURISTIC_UNWEIGHTED 1  /* Used by libpng < 0.95 */\n#define PNG_FILTER_HEURISTIC_WEIGHTED   2  /* Experimental feature */\n#define PNG_FILTER_HEURISTIC_LAST       3  /* Not a valid value */\n\n#ifdef PNG_WRITE_SUPPORTED\n/* Set the library compression level.  Currently, valid values range from\n * 0 - 9, corresponding directly to the zlib compression levels 0 - 9\n * (0 - no compression, 9 - \"maximal\" compression).  Note that tests have\n * shown that zlib compression levels 3-6 usually perform as well as level 9\n * for PNG images, and do considerably fewer caclulations.  In the future,\n * these values may not correspond directly to the zlib compression levels.\n */\nPNG_EXPORT(69, void, png_set_compression_level, (png_structrp png_ptr,\n    int level));\n\nPNG_EXPORT(70, void, png_set_compression_mem_level, (png_structrp png_ptr,\n    int mem_level));\n\nPNG_EXPORT(71, void, png_set_compression_strategy, (png_structrp png_ptr,\n    int strategy));\n\n/* If PNG_WRITE_OPTIMIZE_CMF_SUPPORTED is defined, libpng will use a\n * smaller value of window_bits if it can do so safely.\n */\nPNG_EXPORT(72, void, png_set_compression_window_bits, (png_structrp png_ptr,\n    int window_bits));\n\nPNG_EXPORT(73, void, png_set_compression_method, (png_structrp png_ptr,\n    int method));\n#endif\n\n#ifdef PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED\n/* Also set zlib parameters for compressing non-IDAT chunks */\nPNG_EXPORT(222, void, png_set_text_compression_level, (png_structrp png_ptr,\n    int level));\n\nPNG_EXPORT(223, void, png_set_text_compression_mem_level, (png_structrp png_ptr,\n    int mem_level));\n\nPNG_EXPORT(224, void, png_set_text_compression_strategy, (png_structrp png_ptr,\n    int strategy));\n\n/* If PNG_WRITE_OPTIMIZE_CMF_SUPPORTED is defined, libpng will use a\n * smaller value of window_bits if it can do so safely.\n */\nPNG_EXPORT(225, void, png_set_text_compression_window_bits,\n    (png_structrp png_ptr, int window_bits));\n\nPNG_EXPORT(226, void, png_set_text_compression_method, (png_structrp png_ptr,\n    int method));\n#endif /* PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED */\n\n/* These next functions are called for input/output, memory, and error\n * handling.  They are in the file pngrio.c, pngwio.c, and pngerror.c,\n * and call standard C I/O routines such as fread(), fwrite(), and\n * fprintf().  These functions can be made to use other I/O routines\n * at run time for those applications that need to handle I/O in a\n * different manner by calling png_set_???_fn().  See libpng-manual.txt for\n * more information.\n */\n\n#ifdef PNG_STDIO_SUPPORTED\n/* Initialize the input/output for the PNG file to the default functions. */\nPNG_EXPORT(74, void, png_init_io, (png_structrp png_ptr, png_FILE_p fp));\n#endif\n\n/* Replace the (error and abort), and warning functions with user\n * supplied functions.  If no messages are to be printed you must still\n * write and use replacement functions. The replacement error_fn should\n * still do a longjmp to the last setjmp location if you are using this\n * method of error handling.  If error_fn or warning_fn is NULL, the\n * default function will be used.\n */\n\nPNG_EXPORT(75, void, png_set_error_fn, (png_structrp png_ptr,\n    png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warning_fn));\n\n/* Return the user pointer associated with the error functions */\nPNG_EXPORT(76, png_voidp, png_get_error_ptr, (png_const_structrp png_ptr));\n\n/* Replace the default data output functions with a user supplied one(s).\n * If buffered output is not used, then output_flush_fn can be set to NULL.\n * If PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng compile time\n * output_flush_fn will be ignored (and thus can be NULL).\n * It is probably a mistake to use NULL for output_flush_fn if\n * write_data_fn is not also NULL unless you have built libpng with\n * PNG_WRITE_FLUSH_SUPPORTED undefined, because in this case libpng's\n * default flush function, which uses the standard *FILE structure, will\n * be used.\n */\nPNG_EXPORT(77, void, png_set_write_fn, (png_structrp png_ptr, png_voidp io_ptr,\n    png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn));\n\n/* Replace the default data input function with a user supplied one. */\nPNG_EXPORT(78, void, png_set_read_fn, (png_structrp png_ptr, png_voidp io_ptr,\n    png_rw_ptr read_data_fn));\n\n/* Return the user pointer associated with the I/O functions */\nPNG_EXPORT(79, png_voidp, png_get_io_ptr, (png_const_structrp png_ptr));\n\nPNG_EXPORT(80, void, png_set_read_status_fn, (png_structrp png_ptr,\n    png_read_status_ptr read_row_fn));\n\nPNG_EXPORT(81, void, png_set_write_status_fn, (png_structrp png_ptr,\n    png_write_status_ptr write_row_fn));\n\n#ifdef PNG_USER_MEM_SUPPORTED\n/* Replace the default memory allocation functions with user supplied one(s). */\nPNG_EXPORT(82, void, png_set_mem_fn, (png_structrp png_ptr, png_voidp mem_ptr,\n    png_malloc_ptr malloc_fn, png_free_ptr free_fn));\n/* Return the user pointer associated with the memory functions */\nPNG_EXPORT(83, png_voidp, png_get_mem_ptr, (png_const_structrp png_ptr));\n#endif\n\n#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED\nPNG_EXPORT(84, void, png_set_read_user_transform_fn, (png_structrp png_ptr,\n    png_user_transform_ptr read_user_transform_fn));\n#endif\n\n#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED\nPNG_EXPORT(85, void, png_set_write_user_transform_fn, (png_structrp png_ptr,\n    png_user_transform_ptr write_user_transform_fn));\n#endif\n\n#ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED\nPNG_EXPORT(86, void, png_set_user_transform_info, (png_structrp png_ptr,\n    png_voidp user_transform_ptr, int user_transform_depth,\n    int user_transform_channels));\n/* Return the user pointer associated with the user transform functions */\nPNG_EXPORT(87, png_voidp, png_get_user_transform_ptr,\n    (png_const_structrp png_ptr));\n#endif\n\n#ifdef PNG_USER_TRANSFORM_INFO_SUPPORTED\n/* Return information about the row currently being processed.  Note that these\n * APIs do not fail but will return unexpected results if called outside a user\n * transform callback.  Also note that when transforming an interlaced image the\n * row number is the row number within the sub-image of the interlace pass, so\n * the value will increase to the height of the sub-image (not the full image)\n * then reset to 0 for the next pass.\n *\n * Use PNG_ROW_FROM_PASS_ROW(row, pass) and PNG_COL_FROM_PASS_COL(col, pass) to\n * find the output pixel (x,y) given an interlaced sub-image pixel\n * (row,col,pass).  (See below for these macros.)\n */\nPNG_EXPORT(217, png_uint_32, png_get_current_row_number, (png_const_structrp));\nPNG_EXPORT(218, png_byte, png_get_current_pass_number, (png_const_structrp));\n#endif\n\n#ifdef PNG_READ_USER_CHUNKS_SUPPORTED\n/* This callback is called only for *unknown* chunks.  If\n * PNG_HANDLE_AS_UNKNOWN_SUPPORTED is set then it is possible to set known\n * chunks to be treated as unknown, however in this case the callback must do\n * any processing required by the chunk (e.g. by calling the appropriate\n * png_set_ APIs.)\n *\n * There is no write support - on write, by default, all the chunks in the\n * 'unknown' list are written in the specified position.\n *\n * The integer return from the callback function is interpreted thus:\n *\n * negative: An error occured, png_chunk_error will be called.\n *     zero: The chunk was not handled, the chunk will be saved. A critical\n *           chunk will cause an error at this point unless it is to be saved.\n * positive: The chunk was handled, libpng will ignore/discard it.\n *\n * See \"INTERACTION WTIH USER CHUNK CALLBACKS\" below for important notes about\n * how this behavior will change in libpng 1.7\n */\nPNG_EXPORT(88, void, png_set_read_user_chunk_fn, (png_structrp png_ptr,\n    png_voidp user_chunk_ptr, png_user_chunk_ptr read_user_chunk_fn));\n#endif\n\n#ifdef PNG_USER_CHUNKS_SUPPORTED\nPNG_EXPORT(89, png_voidp, png_get_user_chunk_ptr, (png_const_structrp png_ptr));\n#endif\n\n#ifdef PNG_PROGRESSIVE_READ_SUPPORTED\n/* Sets the function callbacks for the push reader, and a pointer to a\n * user-defined structure available to the callback functions.\n */\nPNG_EXPORT(90, void, png_set_progressive_read_fn, (png_structrp png_ptr,\n    png_voidp progressive_ptr, png_progressive_info_ptr info_fn,\n    png_progressive_row_ptr row_fn, png_progressive_end_ptr end_fn));\n\n/* Returns the user pointer associated with the push read functions */\nPNG_EXPORT(91, png_voidp, png_get_progressive_ptr,\n    (png_const_structrp png_ptr));\n\n/* Function to be called when data becomes available */\nPNG_EXPORT(92, void, png_process_data, (png_structrp png_ptr,\n    png_inforp info_ptr, png_bytep buffer, png_size_t buffer_size));\n\n/* A function which may be called *only* within png_process_data to stop the\n * processing of any more data.  The function returns the number of bytes\n * remaining, excluding any that libpng has cached internally.  A subsequent\n * call to png_process_data must supply these bytes again.  If the argument\n * 'save' is set to true the routine will first save all the pending data and\n * will always return 0.\n */\nPNG_EXPORT(219, png_size_t, png_process_data_pause, (png_structrp, int save));\n\n/* A function which may be called *only* outside (after) a call to\n * png_process_data.  It returns the number of bytes of data to skip in the\n * input.  Normally it will return 0, but if it returns a non-zero value the\n * application must skip than number of bytes of input data and pass the\n * following data to the next call to png_process_data.\n */\nPNG_EXPORT(220, png_uint_32, png_process_data_skip, (png_structrp));\n\n#ifdef PNG_READ_INTERLACING_SUPPORTED\n/* Function that combines rows.  'new_row' is a flag that should come from\n * the callback and be non-NULL if anything needs to be done; the library\n * stores its own version of the new data internally and ignores the passed\n * in value.\n */\nPNG_EXPORT(93, void, png_progressive_combine_row, (png_const_structrp png_ptr,\n    png_bytep old_row, png_const_bytep new_row));\n#endif /* PNG_READ_INTERLACING_SUPPORTED */\n#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */\n\nPNG_EXPORTA(94, png_voidp, png_malloc, (png_const_structrp png_ptr,\n    png_alloc_size_t size), PNG_ALLOCATED);\n/* Added at libpng version 1.4.0 */\nPNG_EXPORTA(95, png_voidp, png_calloc, (png_const_structrp png_ptr,\n    png_alloc_size_t size), PNG_ALLOCATED);\n\n/* Added at libpng version 1.2.4 */\nPNG_EXPORTA(96, png_voidp, png_malloc_warn, (png_const_structrp png_ptr,\n    png_alloc_size_t size), PNG_ALLOCATED);\n\n/* Frees a pointer allocated by png_malloc() */\nPNG_EXPORT(97, void, png_free, (png_const_structrp png_ptr, png_voidp ptr));\n\n/* Free data that was allocated internally */\nPNG_EXPORT(98, void, png_free_data, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 free_me, int num));\n\n/* Reassign responsibility for freeing existing data, whether allocated\n * by libpng or by the application; this works on the png_info structure passed\n * in, it does not change the state for other png_info structures.\n *\n * It is unlikely that this function works correctly as of 1.6.0 and using it\n * may result either in memory leaks or double free of allocated data.\n */\nPNG_EXPORT(99, void, png_data_freer, (png_const_structrp png_ptr,\n    png_inforp info_ptr, int freer, png_uint_32 mask));\n\n/* Assignments for png_data_freer */\n#define PNG_DESTROY_WILL_FREE_DATA 1\n#define PNG_SET_WILL_FREE_DATA 1\n#define PNG_USER_WILL_FREE_DATA 2\n/* Flags for png_ptr->free_me and info_ptr->free_me */\n#define PNG_FREE_HIST 0x0008\n#define PNG_FREE_ICCP 0x0010\n#define PNG_FREE_SPLT 0x0020\n#define PNG_FREE_ROWS 0x0040\n#define PNG_FREE_PCAL 0x0080\n#define PNG_FREE_SCAL 0x0100\n#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED\n#  define PNG_FREE_UNKN 0x0200\n#endif\n/*      PNG_FREE_LIST 0x0400    removed in 1.6.0 because it is ignored */\n#define PNG_FREE_PLTE 0x1000\n#define PNG_FREE_TRNS 0x2000\n#define PNG_FREE_TEXT 0x4000\n#define PNG_FREE_ALL  0x7fff\n#define PNG_FREE_MUL  0x4220 /* PNG_FREE_SPLT|PNG_FREE_TEXT|PNG_FREE_UNKN */\n\n#ifdef PNG_USER_MEM_SUPPORTED\nPNG_EXPORTA(100, png_voidp, png_malloc_default, (png_const_structrp png_ptr,\n    png_alloc_size_t size), PNG_ALLOCATED PNG_DEPRECATED);\nPNG_EXPORTA(101, void, png_free_default, (png_const_structrp png_ptr,\n    png_voidp ptr), PNG_DEPRECATED);\n#endif\n\n#ifdef PNG_ERROR_TEXT_SUPPORTED\n/* Fatal error in PNG image of libpng - can't continue */\nPNG_EXPORTA(102, void, png_error, (png_const_structrp png_ptr,\n    png_const_charp error_message), PNG_NORETURN);\n\n/* The same, but the chunk name is prepended to the error string. */\nPNG_EXPORTA(103, void, png_chunk_error, (png_const_structrp png_ptr,\n    png_const_charp error_message), PNG_NORETURN);\n\n#else\n/* Fatal error in PNG image of libpng - can't continue */\nPNG_EXPORTA(104, void, png_err, (png_const_structrp png_ptr), PNG_NORETURN);\n#  define png_error(s1,s2) png_err(s1)\n#  define png_chunk_error(s1,s2) png_err(s1)\n#endif\n\n#ifdef PNG_WARNINGS_SUPPORTED\n/* Non-fatal error in libpng.  Can continue, but may have a problem. */\nPNG_EXPORT(105, void, png_warning, (png_const_structrp png_ptr,\n    png_const_charp warning_message));\n\n/* Non-fatal error in libpng, chunk name is prepended to message. */\nPNG_EXPORT(106, void, png_chunk_warning, (png_const_structrp png_ptr,\n    png_const_charp warning_message));\n#else\n#  define png_warning(s1,s2) ((void)(s1))\n#  define png_chunk_warning(s1,s2) ((void)(s1))\n#endif\n\n#ifdef PNG_BENIGN_ERRORS_SUPPORTED\n/* Benign error in libpng.  Can continue, but may have a problem.\n * User can choose whether to handle as a fatal error or as a warning. */\nPNG_EXPORT(107, void, png_benign_error, (png_const_structrp png_ptr,\n    png_const_charp warning_message));\n\n#ifdef PNG_READ_SUPPORTED\n/* Same, chunk name is prepended to message (only during read) */\nPNG_EXPORT(108, void, png_chunk_benign_error, (png_const_structrp png_ptr,\n    png_const_charp warning_message));\n#endif\n\nPNG_EXPORT(109, void, png_set_benign_errors,\n    (png_structrp png_ptr, int allowed));\n#else\n#  ifdef PNG_ALLOW_BENIGN_ERRORS\n#    define png_benign_error png_warning\n#    define png_chunk_benign_error png_chunk_warning\n#  else\n#    define png_benign_error png_error\n#    define png_chunk_benign_error png_chunk_error\n#  endif\n#endif\n\n/* The png_set_<chunk> functions are for storing values in the png_info_struct.\n * Similarly, the png_get_<chunk> calls are used to read values from the\n * png_info_struct, either storing the parameters in the passed variables, or\n * setting pointers into the png_info_struct where the data is stored.  The\n * png_get_<chunk> functions return a non-zero value if the data was available\n * in info_ptr, or return zero and do not change any of the parameters if the\n * data was not available.\n *\n * These functions should be used instead of directly accessing png_info\n * to avoid problems with future changes in the size and internal layout of\n * png_info_struct.\n */\n/* Returns \"flag\" if chunk data is valid in info_ptr. */\nPNG_EXPORT(110, png_uint_32, png_get_valid, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr, png_uint_32 flag));\n\n/* Returns number of bytes needed to hold a transformed row. */\nPNG_EXPORT(111, png_size_t, png_get_rowbytes, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr));\n\n#ifdef PNG_INFO_IMAGE_SUPPORTED\n/* Returns row_pointers, which is an array of pointers to scanlines that was\n * returned from png_read_png().\n */\nPNG_EXPORT(112, png_bytepp, png_get_rows, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr));\n\n/* Set row_pointers, which is an array of pointers to scanlines for use\n * by png_write_png().\n */\nPNG_EXPORT(113, void, png_set_rows, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_bytepp row_pointers));\n#endif\n\n/* Returns number of color channels in image. */\nPNG_EXPORT(114, png_byte, png_get_channels, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr));\n\n#ifdef PNG_EASY_ACCESS_SUPPORTED\n/* Returns image width in pixels. */\nPNG_EXPORT(115, png_uint_32, png_get_image_width, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr));\n\n/* Returns image height in pixels. */\nPNG_EXPORT(116, png_uint_32, png_get_image_height, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr));\n\n/* Returns image bit_depth. */\nPNG_EXPORT(117, png_byte, png_get_bit_depth, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr));\n\n/* Returns image color_type. */\nPNG_EXPORT(118, png_byte, png_get_color_type, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr));\n\n/* Returns image filter_type. */\nPNG_EXPORT(119, png_byte, png_get_filter_type, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr));\n\n/* Returns image interlace_type. */\nPNG_EXPORT(120, png_byte, png_get_interlace_type, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr));\n\n/* Returns image compression_type. */\nPNG_EXPORT(121, png_byte, png_get_compression_type, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr));\n\n/* Returns image resolution in pixels per meter, from pHYs chunk data. */\nPNG_EXPORT(122, png_uint_32, png_get_pixels_per_meter,\n    (png_const_structrp png_ptr, png_const_inforp info_ptr));\nPNG_EXPORT(123, png_uint_32, png_get_x_pixels_per_meter,\n    (png_const_structrp png_ptr, png_const_inforp info_ptr));\nPNG_EXPORT(124, png_uint_32, png_get_y_pixels_per_meter,\n    (png_const_structrp png_ptr, png_const_inforp info_ptr));\n\n/* Returns pixel aspect ratio, computed from pHYs chunk data.  */\nPNG_FP_EXPORT(125, float, png_get_pixel_aspect_ratio,\n    (png_const_structrp png_ptr, png_const_inforp info_ptr))\nPNG_FIXED_EXPORT(210, png_fixed_point, png_get_pixel_aspect_ratio_fixed,\n    (png_const_structrp png_ptr, png_const_inforp info_ptr))\n\n/* Returns image x, y offset in pixels or microns, from oFFs chunk data. */\nPNG_EXPORT(126, png_int_32, png_get_x_offset_pixels,\n    (png_const_structrp png_ptr, png_const_inforp info_ptr));\nPNG_EXPORT(127, png_int_32, png_get_y_offset_pixels,\n    (png_const_structrp png_ptr, png_const_inforp info_ptr));\nPNG_EXPORT(128, png_int_32, png_get_x_offset_microns,\n    (png_const_structrp png_ptr, png_const_inforp info_ptr));\nPNG_EXPORT(129, png_int_32, png_get_y_offset_microns,\n    (png_const_structrp png_ptr, png_const_inforp info_ptr));\n\n#endif /* PNG_EASY_ACCESS_SUPPORTED */\n\n#ifdef PNG_READ_SUPPORTED\n/* Returns pointer to signature string read from PNG header */\nPNG_EXPORT(130, png_const_bytep, png_get_signature, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr));\n#endif\n\n#ifdef PNG_bKGD_SUPPORTED\nPNG_EXPORT(131, png_uint_32, png_get_bKGD, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_color_16p *background));\n#endif\n\n#ifdef PNG_bKGD_SUPPORTED\nPNG_EXPORT(132, void, png_set_bKGD, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_const_color_16p background));\n#endif\n\n#ifdef PNG_cHRM_SUPPORTED\nPNG_FP_EXPORT(133, png_uint_32, png_get_cHRM, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr, double *white_x, double *white_y, double *red_x,\n    double *red_y, double *green_x, double *green_y, double *blue_x,\n    double *blue_y))\nPNG_FP_EXPORT(230, png_uint_32, png_get_cHRM_XYZ, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr, double *red_X, double *red_Y, double *red_Z,\n    double *green_X, double *green_Y, double *green_Z, double *blue_X,\n    double *blue_Y, double *blue_Z))\nPNG_FIXED_EXPORT(134, png_uint_32, png_get_cHRM_fixed,\n    (png_const_structrp png_ptr, png_const_inforp info_ptr,\n    png_fixed_point *int_white_x, png_fixed_point *int_white_y,\n    png_fixed_point *int_red_x, png_fixed_point *int_red_y,\n    png_fixed_point *int_green_x, png_fixed_point *int_green_y,\n    png_fixed_point *int_blue_x, png_fixed_point *int_blue_y))\nPNG_FIXED_EXPORT(231, png_uint_32, png_get_cHRM_XYZ_fixed,\n    (png_const_structrp png_ptr, png_const_inforp info_ptr,\n    png_fixed_point *int_red_X, png_fixed_point *int_red_Y,\n    png_fixed_point *int_red_Z, png_fixed_point *int_green_X,\n    png_fixed_point *int_green_Y, png_fixed_point *int_green_Z,\n    png_fixed_point *int_blue_X, png_fixed_point *int_blue_Y,\n    png_fixed_point *int_blue_Z))\n#endif\n\n#ifdef PNG_cHRM_SUPPORTED\nPNG_FP_EXPORT(135, void, png_set_cHRM, (png_const_structrp png_ptr,\n    png_inforp info_ptr,\n    double white_x, double white_y, double red_x, double red_y, double green_x,\n    double green_y, double blue_x, double blue_y))\nPNG_FP_EXPORT(232, void, png_set_cHRM_XYZ, (png_const_structrp png_ptr,\n    png_inforp info_ptr, double red_X, double red_Y, double red_Z,\n    double green_X, double green_Y, double green_Z, double blue_X,\n    double blue_Y, double blue_Z))\nPNG_FIXED_EXPORT(136, void, png_set_cHRM_fixed, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_fixed_point int_white_x,\n    png_fixed_point int_white_y, png_fixed_point int_red_x,\n    png_fixed_point int_red_y, png_fixed_point int_green_x,\n    png_fixed_point int_green_y, png_fixed_point int_blue_x,\n    png_fixed_point int_blue_y))\nPNG_FIXED_EXPORT(233, void, png_set_cHRM_XYZ_fixed, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_fixed_point int_red_X, png_fixed_point int_red_Y,\n    png_fixed_point int_red_Z, png_fixed_point int_green_X,\n    png_fixed_point int_green_Y, png_fixed_point int_green_Z,\n    png_fixed_point int_blue_X, png_fixed_point int_blue_Y,\n    png_fixed_point int_blue_Z))\n#endif\n\n#ifdef PNG_gAMA_SUPPORTED\nPNG_FP_EXPORT(137, png_uint_32, png_get_gAMA, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr, double *file_gamma))\nPNG_FIXED_EXPORT(138, png_uint_32, png_get_gAMA_fixed,\n    (png_const_structrp png_ptr, png_const_inforp info_ptr,\n    png_fixed_point *int_file_gamma))\n#endif\n\n#ifdef PNG_gAMA_SUPPORTED\nPNG_FP_EXPORT(139, void, png_set_gAMA, (png_const_structrp png_ptr,\n    png_inforp info_ptr, double file_gamma))\nPNG_FIXED_EXPORT(140, void, png_set_gAMA_fixed, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_fixed_point int_file_gamma))\n#endif\n\n#ifdef PNG_hIST_SUPPORTED\nPNG_EXPORT(141, png_uint_32, png_get_hIST, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_uint_16p *hist));\n#endif\n\n#ifdef PNG_hIST_SUPPORTED\nPNG_EXPORT(142, void, png_set_hIST, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_const_uint_16p hist));\n#endif\n\nPNG_EXPORT(143, png_uint_32, png_get_IHDR, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr, png_uint_32 *width, png_uint_32 *height,\n    int *bit_depth, int *color_type, int *interlace_method,\n    int *compression_method, int *filter_method));\n\nPNG_EXPORT(144, void, png_set_IHDR, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 width, png_uint_32 height, int bit_depth,\n    int color_type, int interlace_method, int compression_method,\n    int filter_method));\n\n#ifdef PNG_oFFs_SUPPORTED\nPNG_EXPORT(145, png_uint_32, png_get_oFFs, (png_const_structrp png_ptr,\n   png_const_inforp info_ptr, png_int_32 *offset_x, png_int_32 *offset_y,\n   int *unit_type));\n#endif\n\n#ifdef PNG_oFFs_SUPPORTED\nPNG_EXPORT(146, void, png_set_oFFs, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_int_32 offset_x, png_int_32 offset_y,\n    int unit_type));\n#endif\n\n#ifdef PNG_pCAL_SUPPORTED\nPNG_EXPORT(147, png_uint_32, png_get_pCAL, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_charp *purpose, png_int_32 *X0,\n    png_int_32 *X1, int *type, int *nparams, png_charp *units,\n    png_charpp *params));\n#endif\n\n#ifdef PNG_pCAL_SUPPORTED\nPNG_EXPORT(148, void, png_set_pCAL, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_const_charp purpose, png_int_32 X0, png_int_32 X1,\n    int type, int nparams, png_const_charp units, png_charpp params));\n#endif\n\n#ifdef PNG_pHYs_SUPPORTED\nPNG_EXPORT(149, png_uint_32, png_get_pHYs, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr, png_uint_32 *res_x, png_uint_32 *res_y,\n    int *unit_type));\n#endif\n\n#ifdef PNG_pHYs_SUPPORTED\nPNG_EXPORT(150, void, png_set_pHYs, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 res_x, png_uint_32 res_y, int unit_type));\n#endif\n\nPNG_EXPORT(151, png_uint_32, png_get_PLTE, (png_const_structrp png_ptr,\n   png_inforp info_ptr, png_colorp *palette, int *num_palette));\n\nPNG_EXPORT(152, void, png_set_PLTE, (png_structrp png_ptr,\n    png_inforp info_ptr, png_const_colorp palette, int num_palette));\n\n#ifdef PNG_sBIT_SUPPORTED\nPNG_EXPORT(153, png_uint_32, png_get_sBIT, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_color_8p *sig_bit));\n#endif\n\n#ifdef PNG_sBIT_SUPPORTED\nPNG_EXPORT(154, void, png_set_sBIT, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_const_color_8p sig_bit));\n#endif\n\n#ifdef PNG_sRGB_SUPPORTED\nPNG_EXPORT(155, png_uint_32, png_get_sRGB, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr, int *file_srgb_intent));\n#endif\n\n#ifdef PNG_sRGB_SUPPORTED\nPNG_EXPORT(156, void, png_set_sRGB, (png_const_structrp png_ptr,\n    png_inforp info_ptr, int srgb_intent));\nPNG_EXPORT(157, void, png_set_sRGB_gAMA_and_cHRM, (png_const_structrp png_ptr,\n    png_inforp info_ptr, int srgb_intent));\n#endif\n\n#ifdef PNG_iCCP_SUPPORTED\nPNG_EXPORT(158, png_uint_32, png_get_iCCP, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_charpp name, int *compression_type,\n    png_bytepp profile, png_uint_32 *proflen));\n#endif\n\n#ifdef PNG_iCCP_SUPPORTED\nPNG_EXPORT(159, void, png_set_iCCP, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_const_charp name, int compression_type,\n    png_const_bytep profile, png_uint_32 proflen));\n#endif\n\n#ifdef PNG_sPLT_SUPPORTED\nPNG_EXPORT(160, int, png_get_sPLT, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_sPLT_tpp entries));\n#endif\n\n#ifdef PNG_sPLT_SUPPORTED\nPNG_EXPORT(161, void, png_set_sPLT, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_const_sPLT_tp entries, int nentries));\n#endif\n\n#ifdef PNG_TEXT_SUPPORTED\n/* png_get_text also returns the number of text chunks in *num_text */\nPNG_EXPORT(162, int, png_get_text, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_textp *text_ptr, int *num_text));\n#endif\n\n/* Note while png_set_text() will accept a structure whose text,\n * language, and  translated keywords are NULL pointers, the structure\n * returned by png_get_text will always contain regular\n * zero-terminated C strings.  They might be empty strings but\n * they will never be NULL pointers.\n */\n\n#ifdef PNG_TEXT_SUPPORTED\nPNG_EXPORT(163, void, png_set_text, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_const_textp text_ptr, int num_text));\n#endif\n\n#ifdef PNG_tIME_SUPPORTED\nPNG_EXPORT(164, png_uint_32, png_get_tIME, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_timep *mod_time));\n#endif\n\n#ifdef PNG_tIME_SUPPORTED\nPNG_EXPORT(165, void, png_set_tIME, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_const_timep mod_time));\n#endif\n\n#ifdef PNG_tRNS_SUPPORTED\nPNG_EXPORT(166, png_uint_32, png_get_tRNS, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_bytep *trans_alpha, int *num_trans,\n    png_color_16p *trans_color));\n#endif\n\n#ifdef PNG_tRNS_SUPPORTED\nPNG_EXPORT(167, void, png_set_tRNS, (png_structrp png_ptr,\n    png_inforp info_ptr, png_const_bytep trans_alpha, int num_trans,\n    png_const_color_16p trans_color));\n#endif\n\n#ifdef PNG_sCAL_SUPPORTED\nPNG_FP_EXPORT(168, png_uint_32, png_get_sCAL, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr, int *unit, double *width, double *height))\n#if defined(PNG_FLOATING_ARITHMETIC_SUPPORTED) || \\\n   defined(PNG_FLOATING_POINT_SUPPORTED)\n/* NOTE: this API is currently implemented using floating point arithmetic,\n * consequently it can only be used on systems with floating point support.\n * In any case the range of values supported by png_fixed_point is small and it\n * is highly recommended that png_get_sCAL_s be used instead.\n */\nPNG_FIXED_EXPORT(214, png_uint_32, png_get_sCAL_fixed,\n    (png_const_structrp png_ptr, png_const_inforp info_ptr, int *unit,\n    png_fixed_point *width, png_fixed_point *height))\n#endif\nPNG_EXPORT(169, png_uint_32, png_get_sCAL_s,\n    (png_const_structrp png_ptr, png_const_inforp info_ptr, int *unit,\n    png_charpp swidth, png_charpp sheight));\n\nPNG_FP_EXPORT(170, void, png_set_sCAL, (png_const_structrp png_ptr,\n    png_inforp info_ptr, int unit, double width, double height))\nPNG_FIXED_EXPORT(213, void, png_set_sCAL_fixed, (png_const_structrp png_ptr,\n   png_inforp info_ptr, int unit, png_fixed_point width,\n   png_fixed_point height))\nPNG_EXPORT(171, void, png_set_sCAL_s, (png_const_structrp png_ptr,\n    png_inforp info_ptr, int unit,\n    png_const_charp swidth, png_const_charp sheight));\n#endif /* PNG_sCAL_SUPPORTED */\n\n#ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED\n/* Provide the default handling for all unknown chunks or, optionally, for\n * specific unknown chunks.\n *\n * NOTE: prior to 1.6.0 the handling specified for particular chunks on read was\n * ignored and the default was used, the per-chunk setting only had an effect on\n * write.  If you wish to have chunk-specific handling on read in code that must\n * work on earlier versions you must use a user chunk callback to specify the\n * desired handling (keep or discard.)\n *\n * The 'keep' parameter is a PNG_HANDLE_CHUNK_ value as listed below.  The\n * parameter is interpreted as follows:\n *\n * READ:\n *    PNG_HANDLE_CHUNK_AS_DEFAULT:\n *       Known chunks: do normal libpng processing, do not keep the chunk (but\n *          see the comments below about PNG_HANDLE_AS_UNKNOWN_SUPPORTED)\n *       Unknown chunks: for a specific chunk use the global default, when used\n *          as the default discard the chunk data.\n *    PNG_HANDLE_CHUNK_NEVER:\n *       Discard the chunk data.\n *    PNG_HANDLE_CHUNK_IF_SAFE:\n *       Keep the chunk data if the chunk is not critical else raise a chunk\n *       error.\n *    PNG_HANDLE_CHUNK_ALWAYS:\n *       Keep the chunk data.\n *\n * If the chunk data is saved it can be retrieved using png_get_unknown_chunks,\n * below.  Notice that specifying \"AS_DEFAULT\" as a global default is equivalent\n * to specifying \"NEVER\", however when \"AS_DEFAULT\" is used for specific chunks\n * it simply resets the behavior to the libpng default.\n *\n * INTERACTION WTIH USER CHUNK CALLBACKS:\n * The per-chunk handling is always used when there is a png_user_chunk_ptr\n * callback and the callback returns 0; the chunk is then always stored *unless*\n * it is critical and the per-chunk setting is other than ALWAYS.  Notice that\n * the global default is *not* used in this case.  (In effect the per-chunk\n * value is incremented to at least IF_SAFE.)\n *\n * IMPORTANT NOTE: this behavior will change in libpng 1.7 - the global and\n * per-chunk defaults will be honored.  If you want to preserve the current\n * behavior when your callback returns 0 you must set PNG_HANDLE_CHUNK_IF_SAFE\n * as the default - if you don't do this libpng 1.6 will issue a warning.\n *\n * If you want unhandled unknown chunks to be discarded in libpng 1.6 and\n * earlier simply return '1' (handled).\n *\n * PNG_HANDLE_AS_UNKNOWN_SUPPORTED:\n *    If this is *not* set known chunks will always be handled by libpng and\n *    will never be stored in the unknown chunk list.  Known chunks listed to\n *    png_set_keep_unknown_chunks will have no effect.  If it is set then known\n *    chunks listed with a keep other than AS_DEFAULT will *never* be processed\n *    by libpng, in addition critical chunks must either be processed by the\n *    callback or saved.\n *\n *    The IHDR and IEND chunks must not be listed.  Because this turns off the\n *    default handling for chunks that would otherwise be recognized the\n *    behavior of libpng transformations may well become incorrect!\n *\n * WRITE:\n *    When writing chunks the options only apply to the chunks specified by\n *    png_set_unknown_chunks (below), libpng will *always* write known chunks\n *    required by png_set_ calls and will always write the core critical chunks\n *    (as required for PLTE).\n *\n *    Each chunk in the png_set_unknown_chunks list is looked up in the\n *    png_set_keep_unknown_chunks list to find the keep setting, this is then\n *    interpreted as follows:\n *\n *    PNG_HANDLE_CHUNK_AS_DEFAULT:\n *       Write safe-to-copy chunks and write other chunks if the global\n *       default is set to _ALWAYS, otherwise don't write this chunk.\n *    PNG_HANDLE_CHUNK_NEVER:\n *       Do not write the chunk.\n *    PNG_HANDLE_CHUNK_IF_SAFE:\n *       Write the chunk if it is safe-to-copy, otherwise do not write it.\n *    PNG_HANDLE_CHUNK_ALWAYS:\n *       Write the chunk.\n *\n * Note that the default behavior is effectively the opposite of the read case -\n * in read unknown chunks are not stored by default, in write they are written\n * by default.  Also the behavior of PNG_HANDLE_CHUNK_IF_SAFE is very different\n * - on write the safe-to-copy bit is checked, on read the critical bit is\n * checked and on read if the chunk is critical an error will be raised.\n *\n * num_chunks:\n * ===========\n *    If num_chunks is positive, then the \"keep\" parameter specifies the manner\n *    for handling only those chunks appearing in the chunk_list array,\n *    otherwise the chunk list array is ignored.\n *\n *    If num_chunks is 0 the \"keep\" parameter specifies the default behavior for\n *    unknown chunks, as described above.\n *\n *    If num_chunks is negative, then the \"keep\" parameter specifies the manner\n *    for handling all unknown chunks plus all chunks recognized by libpng\n *    except for the IHDR, PLTE, tRNS, IDAT, and IEND chunks (which continue to\n *    be processed by libpng.\n */\nPNG_EXPORT(172, void, png_set_keep_unknown_chunks, (png_structrp png_ptr,\n    int keep, png_const_bytep chunk_list, int num_chunks));\n\n/* The \"keep\" PNG_HANDLE_CHUNK_ parameter for the specified chunk is returned;\n * the result is therefore true (non-zero) if special handling is required,\n * false for the default handling.\n */\nPNG_EXPORT(173, int, png_handle_as_unknown, (png_const_structrp png_ptr,\n    png_const_bytep chunk_name));\n#endif\n\n#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED\nPNG_EXPORT(174, void, png_set_unknown_chunks, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_const_unknown_chunkp unknowns,\n    int num_unknowns));\n   /* NOTE: prior to 1.6.0 this routine set the 'location' field of the added\n    * unknowns to the location currently stored in the png_struct.  This is\n    * invariably the wrong value on write.  To fix this call the following API\n    * for each chunk in the list with the correct location.  If you know your\n    * code won't be compiled on earlier versions you can rely on\n    * png_set_unknown_chunks(write-ptr, png_get_unknown_chunks(read-ptr)) doing\n    * the correct thing.\n    */\n\nPNG_EXPORT(175, void, png_set_unknown_chunk_location,\n    (png_const_structrp png_ptr, png_inforp info_ptr, int chunk, int location));\n\nPNG_EXPORT(176, int, png_get_unknown_chunks, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_unknown_chunkpp entries));\n#endif\n\n/* Png_free_data() will turn off the \"valid\" flag for anything it frees.\n * If you need to turn it off for a chunk that your application has freed,\n * you can use png_set_invalid(png_ptr, info_ptr, PNG_INFO_CHNK);\n */\nPNG_EXPORT(177, void, png_set_invalid, (png_const_structrp png_ptr,\n    png_inforp info_ptr, int mask));\n\n#ifdef PNG_INFO_IMAGE_SUPPORTED\n/* The \"params\" pointer is currently not used and is for future expansion. */\n#ifdef PNG_SEQUENTIAL_READ_SUPPORTED\nPNG_EXPORT(178, void, png_read_png, (png_structrp png_ptr, png_inforp info_ptr,\n    int transforms, png_voidp params));\n#endif\n#ifdef PNG_WRITE_SUPPORTED\nPNG_EXPORT(179, void, png_write_png, (png_structrp png_ptr, png_inforp info_ptr,\n    int transforms, png_voidp params));\n#endif\n#endif\n\nPNG_EXPORT(180, png_const_charp, png_get_copyright,\n    (png_const_structrp png_ptr));\nPNG_EXPORT(181, png_const_charp, png_get_header_ver,\n    (png_const_structrp png_ptr));\nPNG_EXPORT(182, png_const_charp, png_get_header_version,\n    (png_const_structrp png_ptr));\nPNG_EXPORT(183, png_const_charp, png_get_libpng_ver,\n    (png_const_structrp png_ptr));\n\n#ifdef PNG_MNG_FEATURES_SUPPORTED\nPNG_EXPORT(184, png_uint_32, png_permit_mng_features, (png_structrp png_ptr,\n    png_uint_32 mng_features_permitted));\n#endif\n\n/* For use in png_set_keep_unknown, added to version 1.2.6 */\n#define PNG_HANDLE_CHUNK_AS_DEFAULT   0\n#define PNG_HANDLE_CHUNK_NEVER        1\n#define PNG_HANDLE_CHUNK_IF_SAFE      2\n#define PNG_HANDLE_CHUNK_ALWAYS       3\n#define PNG_HANDLE_CHUNK_LAST         4\n\n/* Strip the prepended error numbers (\"#nnn \") from error and warning\n * messages before passing them to the error or warning handler.\n */\n#ifdef PNG_ERROR_NUMBERS_SUPPORTED\nPNG_EXPORT(185, void, png_set_strip_error_numbers, (png_structrp png_ptr,\n    png_uint_32 strip_mode));\n#endif\n\n/* Added in libpng-1.2.6 */\n#ifdef PNG_SET_USER_LIMITS_SUPPORTED\nPNG_EXPORT(186, void, png_set_user_limits, (png_structrp png_ptr,\n    png_uint_32 user_width_max, png_uint_32 user_height_max));\nPNG_EXPORT(187, png_uint_32, png_get_user_width_max,\n    (png_const_structrp png_ptr));\nPNG_EXPORT(188, png_uint_32, png_get_user_height_max,\n    (png_const_structrp png_ptr));\n/* Added in libpng-1.4.0 */\nPNG_EXPORT(189, void, png_set_chunk_cache_max, (png_structrp png_ptr,\n    png_uint_32 user_chunk_cache_max));\nPNG_EXPORT(190, png_uint_32, png_get_chunk_cache_max,\n    (png_const_structrp png_ptr));\n/* Added in libpng-1.4.1 */\nPNG_EXPORT(191, void, png_set_chunk_malloc_max, (png_structrp png_ptr,\n    png_alloc_size_t user_chunk_cache_max));\nPNG_EXPORT(192, png_alloc_size_t, png_get_chunk_malloc_max,\n    (png_const_structrp png_ptr));\n#endif\n\n#if defined(PNG_INCH_CONVERSIONS_SUPPORTED)\nPNG_EXPORT(193, png_uint_32, png_get_pixels_per_inch,\n    (png_const_structrp png_ptr, png_const_inforp info_ptr));\n\nPNG_EXPORT(194, png_uint_32, png_get_x_pixels_per_inch,\n    (png_const_structrp png_ptr, png_const_inforp info_ptr));\n\nPNG_EXPORT(195, png_uint_32, png_get_y_pixels_per_inch,\n    (png_const_structrp png_ptr, png_const_inforp info_ptr));\n\nPNG_FP_EXPORT(196, float, png_get_x_offset_inches,\n    (png_const_structrp png_ptr, png_const_inforp info_ptr))\n#ifdef PNG_FIXED_POINT_SUPPORTED /* otherwise not implemented. */\nPNG_FIXED_EXPORT(211, png_fixed_point, png_get_x_offset_inches_fixed,\n    (png_const_structrp png_ptr, png_const_inforp info_ptr))\n#endif\n\nPNG_FP_EXPORT(197, float, png_get_y_offset_inches, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr))\n#ifdef PNG_FIXED_POINT_SUPPORTED /* otherwise not implemented. */\nPNG_FIXED_EXPORT(212, png_fixed_point, png_get_y_offset_inches_fixed,\n    (png_const_structrp png_ptr, png_const_inforp info_ptr))\n#endif\n\n#  ifdef PNG_pHYs_SUPPORTED\nPNG_EXPORT(198, png_uint_32, png_get_pHYs_dpi, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr, png_uint_32 *res_x, png_uint_32 *res_y,\n    int *unit_type));\n#  endif /* PNG_pHYs_SUPPORTED */\n#endif  /* PNG_INCH_CONVERSIONS_SUPPORTED */\n\n/* Added in libpng-1.4.0 */\n#ifdef PNG_IO_STATE_SUPPORTED\nPNG_EXPORT(199, png_uint_32, png_get_io_state, (png_const_structrp png_ptr));\n\n/* Removed from libpng 1.6; use png_get_io_chunk_type. */\nPNG_REMOVED(200, png_const_bytep, png_get_io_chunk_name, (png_structrp png_ptr),\n    PNG_DEPRECATED)\n\nPNG_EXPORT(216, png_uint_32, png_get_io_chunk_type,\n    (png_const_structrp png_ptr));\n\n/* The flags returned by png_get_io_state() are the following: */\n#  define PNG_IO_NONE        0x0000   /* no I/O at this moment */\n#  define PNG_IO_READING     0x0001   /* currently reading */\n#  define PNG_IO_WRITING     0x0002   /* currently writing */\n#  define PNG_IO_SIGNATURE   0x0010   /* currently at the file signature */\n#  define PNG_IO_CHUNK_HDR   0x0020   /* currently at the chunk header */\n#  define PNG_IO_CHUNK_DATA  0x0040   /* currently at the chunk data */\n#  define PNG_IO_CHUNK_CRC   0x0080   /* currently at the chunk crc */\n#  define PNG_IO_MASK_OP     0x000f   /* current operation: reading/writing */\n#  define PNG_IO_MASK_LOC    0x00f0   /* current location: sig/hdr/data/crc */\n#endif /* ?PNG_IO_STATE_SUPPORTED */\n\n/* Interlace support.  The following macros are always defined so that if\n * libpng interlace handling is turned off the macros may be used to handle\n * interlaced images within the application.\n */\n#define PNG_INTERLACE_ADAM7_PASSES 7\n\n/* Two macros to return the first row and first column of the original,\n * full, image which appears in a given pass.  'pass' is in the range 0\n * to 6 and the result is in the range 0 to 7.\n */\n#define PNG_PASS_START_ROW(pass) (((1&~(pass))<<(3-((pass)>>1)))&7)\n#define PNG_PASS_START_COL(pass) (((1& (pass))<<(3-(((pass)+1)>>1)))&7)\n\n/* A macro to return the offset between pixels in the output row for a pair of\n * pixels in the input - effectively the inverse of the 'COL_SHIFT' macro that\n * follows.  Note that ROW_OFFSET is the offset from one row to the next whereas\n * COL_OFFSET is from one column to the next, within a row.\n */\n#define PNG_PASS_ROW_OFFSET(pass) ((pass)>2?(8>>(((pass)-1)>>1)):8)\n#define PNG_PASS_COL_OFFSET(pass) (1<<((7-(pass))>>1))\n\n/* Two macros to help evaluate the number of rows or columns in each\n * pass.  This is expressed as a shift - effectively log2 of the number or\n * rows or columns in each 8x8 tile of the original image.\n */\n#define PNG_PASS_ROW_SHIFT(pass) ((pass)>2?(8-(pass))>>1:3)\n#define PNG_PASS_COL_SHIFT(pass) ((pass)>1?(7-(pass))>>1:3)\n\n/* Hence two macros to determine the number of rows or columns in a given\n * pass of an image given its height or width.  In fact these macros may\n * return non-zero even though the sub-image is empty, because the other\n * dimension may be empty for a small image.\n */\n#define PNG_PASS_ROWS(height, pass) (((height)+(((1<<PNG_PASS_ROW_SHIFT(pass))\\\n   -1)-PNG_PASS_START_ROW(pass)))>>PNG_PASS_ROW_SHIFT(pass))\n#define PNG_PASS_COLS(width, pass) (((width)+(((1<<PNG_PASS_COL_SHIFT(pass))\\\n   -1)-PNG_PASS_START_COL(pass)))>>PNG_PASS_COL_SHIFT(pass))\n\n/* For the reader row callbacks (both progressive and sequential) it is\n * necessary to find the row in the output image given a row in an interlaced\n * image, so two more macros:\n */\n#define PNG_ROW_FROM_PASS_ROW(y_in, pass) \\\n   (((y_in)<<PNG_PASS_ROW_SHIFT(pass))+PNG_PASS_START_ROW(pass))\n#define PNG_COL_FROM_PASS_COL(x_in, pass) \\\n   (((x_in)<<PNG_PASS_COL_SHIFT(pass))+PNG_PASS_START_COL(pass))\n\n/* Two macros which return a boolean (0 or 1) saying whether the given row\n * or column is in a particular pass.  These use a common utility macro that\n * returns a mask for a given pass - the offset 'off' selects the row or\n * column version.  The mask has the appropriate bit set for each column in\n * the tile.\n */\n#define PNG_PASS_MASK(pass,off) ( \\\n   ((0x110145AF>>(((7-(off))-(pass))<<2)) & 0xF) | \\\n   ((0x01145AF0>>(((7-(off))-(pass))<<2)) & 0xF0))\n\n#define PNG_ROW_IN_INTERLACE_PASS(y, pass) \\\n   ((PNG_PASS_MASK(pass,0) >> ((y)&7)) & 1)\n#define PNG_COL_IN_INTERLACE_PASS(x, pass) \\\n   ((PNG_PASS_MASK(pass,1) >> ((x)&7)) & 1)\n\n#ifdef PNG_READ_COMPOSITE_NODIV_SUPPORTED\n/* With these routines we avoid an integer divide, which will be slower on\n * most machines.  However, it does take more operations than the corresponding\n * divide method, so it may be slower on a few RISC systems.  There are two\n * shifts (by 8 or 16 bits) and an addition, versus a single integer divide.\n *\n * Note that the rounding factors are NOT supposed to be the same!  128 and\n * 32768 are correct for the NODIV code; 127 and 32767 are correct for the\n * standard method.\n *\n * [Optimized code by Greg Roelofs and Mark Adler...blame us for bugs. :-) ]\n */\n\n /* fg and bg should be in `gamma 1.0' space; alpha is the opacity */\n\n#  define png_composite(composite, fg, alpha, bg)         \\\n     { png_uint_16 temp = (png_uint_16)((png_uint_16)(fg) \\\n           * (png_uint_16)(alpha)                         \\\n           + (png_uint_16)(bg)*(png_uint_16)(255          \\\n           - (png_uint_16)(alpha)) + 128);                \\\n       (composite) = (png_byte)((temp + (temp >> 8)) >> 8); }\n\n#  define png_composite_16(composite, fg, alpha, bg)       \\\n     { png_uint_32 temp = (png_uint_32)((png_uint_32)(fg)  \\\n           * (png_uint_32)(alpha)                          \\\n           + (png_uint_32)(bg)*(65535                      \\\n           - (png_uint_32)(alpha)) + 32768);               \\\n       (composite) = (png_uint_16)((temp + (temp >> 16)) >> 16); }\n\n#else  /* Standard method using integer division */\n\n#  define png_composite(composite, fg, alpha, bg)                          \\\n     (composite) = (png_byte)(((png_uint_16)(fg) * (png_uint_16)(alpha) +  \\\n     (png_uint_16)(bg) * (png_uint_16)(255 - (png_uint_16)(alpha)) +       \\\n     127) / 255)\n\n#  define png_composite_16(composite, fg, alpha, bg)                         \\\n     (composite) = (png_uint_16)(((png_uint_32)(fg) * (png_uint_32)(alpha) + \\\n     (png_uint_32)(bg)*(png_uint_32)(65535 - (png_uint_32)(alpha)) +         \\\n     32767) / 65535)\n#endif /* PNG_READ_COMPOSITE_NODIV_SUPPORTED */\n\n#ifdef PNG_READ_INT_FUNCTIONS_SUPPORTED\nPNG_EXPORT(201, png_uint_32, png_get_uint_32, (png_const_bytep buf));\nPNG_EXPORT(202, png_uint_16, png_get_uint_16, (png_const_bytep buf));\nPNG_EXPORT(203, png_int_32, png_get_int_32, (png_const_bytep buf));\n#endif\n\nPNG_EXPORT(204, png_uint_32, png_get_uint_31, (png_const_structrp png_ptr,\n    png_const_bytep buf));\n/* No png_get_int_16 -- may be added if there's a real need for it. */\n\n/* Place a 32-bit number into a buffer in PNG byte order (big-endian). */\n#ifdef PNG_WRITE_INT_FUNCTIONS_SUPPORTED\nPNG_EXPORT(205, void, png_save_uint_32, (png_bytep buf, png_uint_32 i));\n#endif\n#ifdef PNG_SAVE_INT_32_SUPPORTED\nPNG_EXPORT(206, void, png_save_int_32, (png_bytep buf, png_int_32 i));\n#endif\n\n/* Place a 16-bit number into a buffer in PNG byte order.\n * The parameter is declared unsigned int, not png_uint_16,\n * just to avoid potential problems on pre-ANSI C compilers.\n */\n#ifdef PNG_WRITE_INT_FUNCTIONS_SUPPORTED\nPNG_EXPORT(207, void, png_save_uint_16, (png_bytep buf, unsigned int i));\n/* No png_save_int_16 -- may be added if there's a real need for it. */\n#endif\n\n#ifdef PNG_USE_READ_MACROS\n/* Inline macros to do direct reads of bytes from the input buffer.\n * The png_get_int_32() routine assumes we are using two's complement\n * format for negative values, which is almost certainly true.\n */\n#  define PNG_get_uint_32(buf) \\\n     (((png_uint_32)(*(buf)) << 24) + \\\n      ((png_uint_32)(*((buf) + 1)) << 16) + \\\n      ((png_uint_32)(*((buf) + 2)) << 8) + \\\n      ((png_uint_32)(*((buf) + 3))))\n\n   /* From libpng-1.4.0 until 1.4.4, the png_get_uint_16 macro (but not the\n    * function) incorrectly returned a value of type png_uint_32.\n    */\n#  define PNG_get_uint_16(buf) \\\n     ((png_uint_16) \\\n      (((unsigned int)(*(buf)) << 8) + \\\n       ((unsigned int)(*((buf) + 1)))))\n\n#  define PNG_get_int_32(buf) \\\n     ((png_int_32)((*(buf) & 0x80) \\\n      ? -((png_int_32)((png_get_uint_32(buf) ^ 0xffffffffL) + 1)) \\\n      : (png_int_32)png_get_uint_32(buf)))\n\n   /* If PNG_PREFIX is defined the same thing as below happens in pnglibconf.h,\n    * but defining a macro name prefixed with PNG_PREFIX.\n    */\n#  ifndef PNG_PREFIX\n#     define png_get_uint_32(buf) PNG_get_uint_32(buf)\n#     define png_get_uint_16(buf) PNG_get_uint_16(buf)\n#     define png_get_int_32(buf)  PNG_get_int_32(buf)\n#  endif\n#else\n#  ifdef PNG_PREFIX\n      /* No macros; revert to the (redefined) function */\n#     define PNG_get_uint_32 (png_get_uint_32)\n#     define PNG_get_uint_16 (png_get_uint_16)\n#     define PNG_get_int_32  (png_get_int_32)\n#  endif\n#endif\n\n/*******************************************************************************\n *  SIMPLIFIED API\n *******************************************************************************\n *\n * Please read the documentation in libpng-manual.txt (TODO: write said\n * documentation) if you don't understand what follows.\n *\n * The simplified API hides the details of both libpng and the PNG file format\n * itself.  It allows PNG files to be read into a very limited number of\n * in-memory bitmap formats or to be written from the same formats.  If these\n * formats do not accomodate your needs then you can, and should, use the more\n * sophisticated APIs above - these support a wide variety of in-memory formats\n * and a wide variety of sophisticated transformations to those formats as well\n * as a wide variety of APIs to manipulate ancillary information.\n *\n * To read a PNG file using the simplified API:\n *\n * 1) Declare a 'png_image' structure (see below) on the stack and set the\n *    version field to PNG_IMAGE_VERSION.\n * 2) Call the appropriate png_image_begin_read... function.\n * 3) Set the png_image 'format' member to the required sample format.\n * 4) Allocate a buffer for the image and, if required, the color-map.\n * 5) Call png_image_finish_read to read the image and, if required, the\n *    color-map into your buffers.\n *\n * There are no restrictions on the format of the PNG input itself; all valid\n * color types, bit depths, and interlace methods are acceptable, and the\n * input image is transformed as necessary to the requested in-memory format\n * during the png_image_finish_read() step.  The only caveat is that if you\n * request a color-mapped image from a PNG that is full-color or makes\n * complex use of an alpha channel the transformation is extremely lossy and the\n * result may look terrible.\n *\n * To write a PNG file using the simplified API:\n *\n * 1) Declare a 'png_image' structure on the stack and memset() it to all zero.\n * 2) Initialize the members of the structure that describe the image, setting\n *    the 'format' member to the format of the image samples.\n * 3) Call the appropriate png_image_write... function with a pointer to the\n *    image and, if necessary, the color-map to write the PNG data.\n *\n * png_image is a structure that describes the in-memory format of an image\n * when it is being read or defines the in-memory format of an image that you\n * need to write:\n */\n#define PNG_IMAGE_VERSION 1\n\ntypedef struct png_control *png_controlp;\ntypedef struct\n{\n   png_controlp opaque;    /* Initialize to NULL, free with png_image_free */\n   png_uint_32  version;   /* Set to PNG_IMAGE_VERSION */\n   png_uint_32  width;     /* Image width in pixels (columns) */\n   png_uint_32  height;    /* Image height in pixels (rows) */\n   png_uint_32  format;    /* Image format as defined below */\n   png_uint_32  flags;     /* A bit mask containing informational flags */\n   png_uint_32  colormap_entries;\n                           /* Number of entries in the color-map */\n\n   /* In the event of an error or warning the following field will be set to a\n    * non-zero value and the 'message' field will contain a '\\0' terminated\n    * string with the libpng error or warning message.  If both warnings and\n    * an error were encountered, only the error is recorded.  If there\n    * are multiple warnings, only the first one is recorded.\n    *\n    * The upper 30 bits of this value are reserved, the low two bits contain\n    * a value as follows:\n    */\n#  define PNG_IMAGE_WARNING 1\n#  define PNG_IMAGE_ERROR 2\n   /*\n    * The result is a two bit code such that a value more than 1 indicates\n    * a failure in the API just called:\n    *\n    *    0 - no warning or error\n    *    1 - warning\n    *    2 - error\n    *    3 - error preceded by warning\n    */\n#  define PNG_IMAGE_FAILED(png_cntrl) ((((png_cntrl).warning_or_error)&0x03)>1)\n\n   png_uint_32  warning_or_error;\n\n   char         message[64];\n} png_image, *png_imagep;\n\n/* The samples of the image have one to four channels whose components have\n * original values in the range 0 to 1.0:\n *\n * 1: A single gray or luminance channel (G).\n * 2: A gray/luminance channel and an alpha channel (GA).\n * 3: Three red, green, blue color channels (RGB).\n * 4: Three color channels and an alpha channel (RGBA).\n *\n * The components are encoded in one of two ways:\n *\n * a) As a small integer, value 0..255, contained in a single byte.  For the\n * alpha channel the original value is simply value/255.  For the color or\n * luminance channels the value is encoded according to the sRGB specification\n * and matches the 8-bit format expected by typical display devices.\n *\n * The color/gray channels are not scaled (pre-multiplied) by the alpha\n * channel and are suitable for passing to color management software.\n *\n * b) As a value in the range 0..65535, contained in a 2-byte integer.  All\n * channels can be converted to the original value by dividing by 65535; all\n * channels are linear.  Color channels use the RGB encoding (RGB end-points) of\n * the sRGB specification.  This encoding is identified by the\n * PNG_FORMAT_FLAG_LINEAR flag below.\n *\n * When the simplified API needs to convert between sRGB and linear colorspaces,\n * the actual sRGB transfer curve defined in the sRGB specification (see the\n * article at http://en.wikipedia.org/wiki/SRGB) is used, not the gamma=1/2.2\n * approximation used elsewhere in libpng.\n *\n * When an alpha channel is present it is expected to denote pixel coverage\n * of the color or luminance channels and is returned as an associated alpha\n * channel: the color/gray channels are scaled (pre-multiplied) by the alpha\n * value.\n *\n * The samples are either contained directly in the image data, between 1 and 8\n * bytes per pixel according to the encoding, or are held in a color-map indexed\n * by bytes in the image data.  In the case of a color-map the color-map entries\n * are individual samples, encoded as above, and the image data has one byte per\n * pixel to select the relevant sample from the color-map.\n */\n\n/* PNG_FORMAT_*\n *\n * #defines to be used in png_image::format.  Each #define identifies a\n * particular layout of sample data and, if present, alpha values.  There are\n * separate defines for each of the two component encodings.\n *\n * A format is built up using single bit flag values.  All combinations are\n * valid.  Formats can be built up from the flag values or you can use one of\n * the predefined values below.  When testing formats always use the FORMAT_FLAG\n * macros to test for individual features - future versions of the library may\n * add new flags.\n *\n * When reading or writing color-mapped images the format should be set to the\n * format of the entries in the color-map then png_image_{read,write}_colormap\n * called to read or write the color-map and set the format correctly for the\n * image data.  Do not set the PNG_FORMAT_FLAG_COLORMAP bit directly!\n *\n * NOTE: libpng can be built with particular features disabled, if you see\n * compiler errors because the definition of one of the following flags has been\n * compiled out it is because libpng does not have the required support.  It is\n * possible, however, for the libpng configuration to enable the format on just\n * read or just write; in that case you may see an error at run time.  You can\n * guard against this by checking for the definition of the appropriate\n * \"_SUPPORTED\" macro, one of:\n *\n *    PNG_SIMPLIFIED_{READ,WRITE}_{BGR,AFIRST}_SUPPORTED\n */\n#define PNG_FORMAT_FLAG_ALPHA    0x01U /* format with an alpha channel */\n#define PNG_FORMAT_FLAG_COLOR    0x02U /* color format: otherwise grayscale */\n#define PNG_FORMAT_FLAG_LINEAR   0x04U /* 2 byte channels else 1 byte */\n#define PNG_FORMAT_FLAG_COLORMAP 0x08U /* image data is color-mapped */\n\n#ifdef PNG_FORMAT_BGR_SUPPORTED\n#  define PNG_FORMAT_FLAG_BGR    0x10U /* BGR colors, else order is RGB */\n#endif\n\n#ifdef PNG_FORMAT_AFIRST_SUPPORTED\n#  define PNG_FORMAT_FLAG_AFIRST 0x20U /* alpha channel comes first */\n#endif\n\n/* Commonly used formats have predefined macros.\n *\n * First the single byte (sRGB) formats:\n */\n#define PNG_FORMAT_GRAY 0\n#define PNG_FORMAT_GA   PNG_FORMAT_FLAG_ALPHA\n#define PNG_FORMAT_AG   (PNG_FORMAT_GA|PNG_FORMAT_FLAG_AFIRST)\n#define PNG_FORMAT_RGB  PNG_FORMAT_FLAG_COLOR\n#define PNG_FORMAT_BGR  (PNG_FORMAT_FLAG_COLOR|PNG_FORMAT_FLAG_BGR)\n#define PNG_FORMAT_RGBA (PNG_FORMAT_RGB|PNG_FORMAT_FLAG_ALPHA)\n#define PNG_FORMAT_ARGB (PNG_FORMAT_RGBA|PNG_FORMAT_FLAG_AFIRST)\n#define PNG_FORMAT_BGRA (PNG_FORMAT_BGR|PNG_FORMAT_FLAG_ALPHA)\n#define PNG_FORMAT_ABGR (PNG_FORMAT_BGRA|PNG_FORMAT_FLAG_AFIRST)\n\n/* Then the linear 2-byte formats.  When naming these \"Y\" is used to\n * indicate a luminance (gray) channel.\n */\n#define PNG_FORMAT_LINEAR_Y PNG_FORMAT_FLAG_LINEAR\n#define PNG_FORMAT_LINEAR_Y_ALPHA (PNG_FORMAT_FLAG_LINEAR|PNG_FORMAT_FLAG_ALPHA)\n#define PNG_FORMAT_LINEAR_RGB (PNG_FORMAT_FLAG_LINEAR|PNG_FORMAT_FLAG_COLOR)\n#define PNG_FORMAT_LINEAR_RGB_ALPHA \\\n   (PNG_FORMAT_FLAG_LINEAR|PNG_FORMAT_FLAG_COLOR|PNG_FORMAT_FLAG_ALPHA)\n\n/* With color-mapped formats the image data is one byte for each pixel, the byte\n * is an index into the color-map which is formatted as above.  To obtain a\n * color-mapped format it is sufficient just to add the PNG_FOMAT_FLAG_COLORMAP\n * to one of the above definitions, or you can use one of the definitions below.\n */\n#define PNG_FORMAT_RGB_COLORMAP  (PNG_FORMAT_RGB|PNG_FORMAT_FLAG_COLORMAP)\n#define PNG_FORMAT_BGR_COLORMAP  (PNG_FORMAT_BGR|PNG_FORMAT_FLAG_COLORMAP)\n#define PNG_FORMAT_RGBA_COLORMAP (PNG_FORMAT_RGBA|PNG_FORMAT_FLAG_COLORMAP)\n#define PNG_FORMAT_ARGB_COLORMAP (PNG_FORMAT_ARGB|PNG_FORMAT_FLAG_COLORMAP)\n#define PNG_FORMAT_BGRA_COLORMAP (PNG_FORMAT_BGRA|PNG_FORMAT_FLAG_COLORMAP)\n#define PNG_FORMAT_ABGR_COLORMAP (PNG_FORMAT_ABGR|PNG_FORMAT_FLAG_COLORMAP)\n\n/* PNG_IMAGE macros\n *\n * These are convenience macros to derive information from a png_image\n * structure.  The PNG_IMAGE_SAMPLE_ macros return values appropriate to the\n * actual image sample values - either the entries in the color-map or the\n * pixels in the image.  The PNG_IMAGE_PIXEL_ macros return corresponding values\n * for the pixels and will always return 1 for color-mapped formats.  The\n * remaining macros return information about the rows in the image and the\n * complete image.\n *\n * NOTE: All the macros that take a png_image::format parameter are compile time\n * constants if the format parameter is, itself, a constant.  Therefore these\n * macros can be used in array declarations and case labels where required.\n * Similarly the macros are also pre-processor constants (sizeof is not used) so\n * they can be used in #if tests.\n *\n * First the information about the samples.\n */\n#define PNG_IMAGE_SAMPLE_CHANNELS(fmt)\\\n   (((fmt)&(PNG_FORMAT_FLAG_COLOR|PNG_FORMAT_FLAG_ALPHA))+1)\n   /* Return the total number of channels in a given format: 1..4 */\n\n#define PNG_IMAGE_SAMPLE_COMPONENT_SIZE(fmt)\\\n   ((((fmt) & PNG_FORMAT_FLAG_LINEAR) >> 2)+1)\n   /* Return the size in bytes of a single component of a pixel or color-map\n    * entry (as appropriate) in the image: 1 or 2.\n    */\n\n#define PNG_IMAGE_SAMPLE_SIZE(fmt)\\\n   (PNG_IMAGE_SAMPLE_CHANNELS(fmt) * PNG_IMAGE_SAMPLE_COMPONENT_SIZE(fmt))\n   /* This is the size of the sample data for one sample.  If the image is\n    * color-mapped it is the size of one color-map entry (and image pixels are\n    * one byte in size), otherwise it is the size of one image pixel.\n    */\n\n#define PNG_IMAGE_MAXIMUM_COLORMAP_COMPONENTS(fmt)\\\n   (PNG_IMAGE_SAMPLE_CHANNELS(fmt) * 256)\n   /* The maximum size of the color-map required by the format expressed in a\n    * count of components.  This can be used to compile-time allocate a\n    * color-map:\n    *\n    * png_uint_16 colormap[PNG_IMAGE_MAXIMUM_COLORMAP_COMPONENTS(linear_fmt)];\n    *\n    * png_byte colormap[PNG_IMAGE_MAXIMUM_COLORMAP_COMPONENTS(sRGB_fmt)];\n    *\n    * Alternatively use the PNG_IMAGE_COLORMAP_SIZE macro below to use the\n    * information from one of the png_image_begin_read_ APIs and dynamically\n    * allocate the required memory.\n    */\n\n/* Corresponding information about the pixels */\n#define PNG_IMAGE_PIXEL_(test,fmt)\\\n   (((fmt)&PNG_FORMAT_FLAG_COLORMAP)?1:test(fmt))\n\n#define PNG_IMAGE_PIXEL_CHANNELS(fmt)\\\n   PNG_IMAGE_PIXEL_(PNG_IMAGE_SAMPLE_CHANNELS,fmt)\n   /* The number of separate channels (components) in a pixel; 1 for a\n    * color-mapped image.\n    */\n\n#define PNG_IMAGE_PIXEL_COMPONENT_SIZE(fmt)\\\n   PNG_IMAGE_PIXEL_(PNG_IMAGE_SAMPLE_COMPONENT_SIZE,fmt)\n   /* The size, in bytes, of each component in a pixel; 1 for a color-mapped\n    * image.\n    */\n\n#define PNG_IMAGE_PIXEL_SIZE(fmt) PNG_IMAGE_PIXEL_(PNG_IMAGE_SAMPLE_SIZE,fmt)\n   /* The size, in bytes, of a complete pixel; 1 for a color-mapped image. */\n\n/* Information about the whole row, or whole image */\n#define PNG_IMAGE_ROW_STRIDE(image)\\\n   (PNG_IMAGE_PIXEL_CHANNELS((image).format) * (image).width)\n   /* Return the total number of components in a single row of the image; this\n    * is the minimum 'row stride', the minimum count of components between each\n    * row.  For a color-mapped image this is the minimum number of bytes in a\n    * row.\n    */\n\n#define PNG_IMAGE_BUFFER_SIZE(image, row_stride)\\\n   (PNG_IMAGE_PIXEL_COMPONENT_SIZE((image).format)*(image).height*(row_stride))\n   /* Return the size, in bytes, of an image buffer given a png_image and a row\n    * stride - the number of components to leave space for in each row.\n    */\n\n#define PNG_IMAGE_SIZE(image)\\\n   PNG_IMAGE_BUFFER_SIZE(image, PNG_IMAGE_ROW_STRIDE(image))\n   /* Return the size, in bytes, of the image in memory given just a png_image;\n    * the row stride is the minimum stride required for the image.\n    */\n\n#define PNG_IMAGE_COLORMAP_SIZE(image)\\\n   (PNG_IMAGE_SAMPLE_SIZE((image).format) * (image).colormap_entries)\n   /* Return the size, in bytes, of the color-map of this image.  If the image\n    * format is not a color-map format this will return a size sufficient for\n    * 256 entries in the given format; check PNG_FORMAT_FLAG_COLORMAP if\n    * you don't want to allocate a color-map in this case.\n    */\n\n/* PNG_IMAGE_FLAG_*\n *\n * Flags containing additional information about the image are held in the\n * 'flags' field of png_image.\n */\n#define PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB 0x01\n   /* This indicates the the RGB values of the in-memory bitmap do not\n    * correspond to the red, green and blue end-points defined by sRGB.\n    */\n\n#define PNG_IMAGE_FLAG_FAST 0x02\n   /* On write emphasise speed over compression; the resultant PNG file will be\n    * larger but will be produced significantly faster, particular for large\n    * images.  Do not use this option for images which will be distributed, only\n    * used it when producing intermediate files that will be read back in\n    * repeatedly.  For a typical 24-bit image the option will double the read\n    * speed at the cost of increasing the image size by 25%, however for many\n    * more compressible images the PNG file can be 10 times larger with only a\n    * slight speed gain.\n    */\n\n#define PNG_IMAGE_FLAG_16BIT_sRGB 0x04\n   /* On read if the image is a 16-bit per component image and there is no gAMA\n    * or sRGB chunk assume that the components are sRGB encoded.  Notice that\n    * images output by the simplified API always have gamma information; setting\n    * this flag only affects the interpretation of 16-bit images from an\n    * external source.  It is recommended that the application expose this flag\n    * to the user; the user can normally easily recognize the difference between\n    * linear and sRGB encoding.  This flag has no effect on write - the data\n    * passed to the write APIs must have the correct encoding (as defined\n    * above.)\n    *\n    * If the flag is not set (the default) input 16-bit per component data is\n    * assumed to be linear.\n    *\n    * NOTE: the flag can only be set after the png_image_begin_read_ call,\n    * because that call initializes the 'flags' field.\n    */\n\n#ifdef PNG_SIMPLIFIED_READ_SUPPORTED\n/* READ APIs\n * ---------\n *\n * The png_image passed to the read APIs must have been initialized by setting\n * the png_controlp field 'opaque' to NULL (or, safer, memset the whole thing.)\n */\n#ifdef PNG_STDIO_SUPPORTED\nPNG_EXPORT(234, int, png_image_begin_read_from_file, (png_imagep image,\n   const char *file_name));\n   /* The named file is opened for read and the image header is filled in\n    * from the PNG header in the file.\n    */\n\nPNG_EXPORT(235, int, png_image_begin_read_from_stdio, (png_imagep image,\n   FILE* file));\n   /* The PNG header is read from the stdio FILE object. */\n#endif /* PNG_STDIO_SUPPORTED */\n\nPNG_EXPORT(236, int, png_image_begin_read_from_memory, (png_imagep image,\n   png_const_voidp memory, png_size_t size));\n   /* The PNG header is read from the given memory buffer. */\n\nPNG_EXPORT(237, int, png_image_finish_read, (png_imagep image,\n   png_const_colorp background, void *buffer, png_int_32 row_stride,\n   void *colormap));\n   /* Finish reading the image into the supplied buffer and clean up the\n    * png_image structure.\n    *\n    * row_stride is the step, in byte or 2-byte units as appropriate,\n    * between adjacent rows.  A positive stride indicates that the top-most row\n    * is first in the buffer - the normal top-down arrangement.  A negative\n    * stride indicates that the bottom-most row is first in the buffer.\n    *\n    * background need only be supplied if an alpha channel must be removed from\n    * a png_byte format and the removal is to be done by compositing on a solid\n    * color; otherwise it may be NULL and any composition will be done directly\n    * onto the buffer.  The value is an sRGB color to use for the background,\n    * for grayscale output the green channel is used.\n    *\n    * background must be supplied when an alpha channel must be removed from a\n    * single byte color-mapped output format, in other words if:\n    *\n    * 1) The original format from png_image_begin_read_from_* had\n    *    PNG_FORMAT_FLAG_ALPHA set.\n    * 2) The format set by the application does not.\n    * 3) The format set by the application has PNG_FORMAT_FLAG_COLORMAP set and\n    *    PNG_FORMAT_FLAG_LINEAR *not* set.\n    *\n    * For linear output removing the alpha channel is always done by compositing\n    * on black and background is ignored.\n    *\n    * colormap must be supplied when PNG_FORMAT_FLAG_COLORMAP is set.  It must\n    * be at least the size (in bytes) returned by PNG_IMAGE_COLORMAP_SIZE.\n    * image->colormap_entries will be updated to the actual number of entries\n    * written to the colormap; this may be less than the original value.\n    */\n\nPNG_EXPORT(238, void, png_image_free, (png_imagep image));\n   /* Free any data allocated by libpng in image->opaque, setting the pointer to\n    * NULL.  May be called at any time after the structure is initialized.\n    */\n#endif /* PNG_SIMPLIFIED_READ_SUPPORTED */\n\n#ifdef PNG_SIMPLIFIED_WRITE_SUPPORTED\n#ifdef PNG_STDIO_SUPPORTED\n/* WRITE APIS\n * ----------\n * For write you must initialize a png_image structure to describe the image to\n * be written.  To do this use memset to set the whole structure to 0 then\n * initialize fields describing your image.\n *\n * version: must be set to PNG_IMAGE_VERSION\n * opaque: must be initialized to NULL\n * width: image width in pixels\n * height: image height in rows\n * format: the format of the data (image and color-map) you wish to write\n * flags: set to 0 unless one of the defined flags applies; set\n *    PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB for color format images where the RGB\n *    values do not correspond to the colors in sRGB.\n * colormap_entries: set to the number of entries in the color-map (0 to 256)\n */\nPNG_EXPORT(239, int, png_image_write_to_file, (png_imagep image,\n   const char *file, int convert_to_8bit, const void *buffer,\n   png_int_32 row_stride, const void *colormap));\n   /* Write the image to the named file. */\n\nPNG_EXPORT(240, int, png_image_write_to_stdio, (png_imagep image, FILE *file,\n   int convert_to_8_bit, const void *buffer, png_int_32 row_stride,\n   const void *colormap));\n   /* Write the image to the given (FILE*). */\n\n/* With both write APIs if image is in one of the linear formats with 16-bit\n * data then setting convert_to_8_bit will cause the output to be an 8-bit PNG\n * gamma encoded according to the sRGB specification, otherwise a 16-bit linear\n * encoded PNG file is written.\n *\n * With color-mapped data formats the colormap parameter point to a color-map\n * with at least image->colormap_entries encoded in the specified format.  If\n * the format is linear the written PNG color-map will be converted to sRGB\n * regardless of the convert_to_8_bit flag.\n *\n * With all APIs row_stride is handled as in the read APIs - it is the spacing\n * from one row to the next in component sized units (1 or 2 bytes) and if\n * negative indicates a bottom-up row layout in the buffer.\n *\n * Note that the write API does not support interlacing or sub-8-bit pixels.\n */\n#endif /* PNG_STDIO_SUPPORTED */\n#endif /* PNG_SIMPLIFIED_WRITE_SUPPORTED */\n/*******************************************************************************\n *  END OF SIMPLIFIED API\n ******************************************************************************/\n\n#ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED\nPNG_EXPORT(242, void, png_set_check_for_invalid_index,\n    (png_structrp png_ptr, int allowed));\n#  ifdef PNG_GET_PALETTE_MAX_SUPPORTED\nPNG_EXPORT(243, int, png_get_palette_max, (png_const_structp png_ptr,\n    png_const_infop info_ptr));\n#  endif\n#endif /* CHECK_FOR_INVALID_INDEX */\n\n/*******************************************************************************\n *  IMPLEMENTATION OPTIONS\n *******************************************************************************\n *\n * Support for arbitrary implementation-specific optimizations.  The API allows\n * particular options to be turned on or off.  'Option' is the number of the\n * option and 'onoff' is 0 (off) or non-0 (on).  The value returned is given\n * by the PNG_OPTION_ defines below.\n *\n * HARDWARE: normally hardware capabilites, such as the Intel SSE instructions,\n *           are detected at run time, however sometimes it may be impossible\n *           to do this in user mode, in which case it is necessary to discover\n *           the capabilities in an OS specific way.  Such capabilities are\n *           listed here when libpng has support for them and must be turned\n *           ON by the application if present.\n *\n * SOFTWARE: sometimes software optimizations actually result in performance\n *           decrease on some architectures or systems, or with some sets of\n *           PNG images.  'Software' options allow such optimizations to be\n *           selected at run time.\n */\n#ifdef PNG_SET_OPTION_SUPPORTED\n#ifdef PNG_ARM_NEON_API_SUPPORTED\n#  define PNG_ARM_NEON   0 /* HARDWARE: ARM Neon SIMD instructions supported */\n#endif\n#define PNG_MAXIMUM_INFLATE_WINDOW 2 /* SOFTWARE: force maximum window */\n#define PNG_OPTION_NEXT  4 /* Next option - numbers must be even */\n\n/* Return values: NOTE: there are four values and 'off' is *not* zero */\n#define PNG_OPTION_UNSET   0 /* Unset - defaults to off */\n#define PNG_OPTION_INVALID 1 /* Option number out of range */\n#define PNG_OPTION_OFF     2\n#define PNG_OPTION_ON      3\n\nPNG_EXPORT(244, int, png_set_option, (png_structrp png_ptr, int option,\n   int onoff));\n#endif\n\n/*******************************************************************************\n *  END OF HARDWARE OPTIONS\n ******************************************************************************/\n\n/* Maintainer: Put new public prototypes here ^, in libpng.3, and project\n * defs, scripts/pnglibconf.h, and scripts/pnglibconf.h.prebuilt\n */\n\n/* The last ordinal number (this is the *last* one already used; the next\n * one to use is one more than this.)  Maintainer, remember to add an entry to\n * scripts/symbols.def as well.\n */\n#ifdef PNG_EXPORT_LAST_ORDINAL\n  PNG_EXPORT_LAST_ORDINAL(244);\n#endif\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* PNG_VERSION_INFO_ONLY */\n/* Do not put anything past this line */\n#endif /* PNG_H */\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/png/pngconf.h",
    "content": "\n/* pngconf.h - machine configurable file for libpng\n *\n * libpng version 1.6.10 - March 6, 2014\n *\n * Copyright (c) 1998-2013 Glenn Randers-Pehrson\n * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)\n * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)\n *\n * This code is released under the libpng license.\n * For conditions of distribution and use, see the disclaimer\n * and license in png.h\n *\n */\n\n/* Any machine specific code is near the front of this file, so if you\n * are configuring libpng for a machine, you may want to read the section\n * starting here down to where it starts to typedef png_color, png_text,\n * and png_info.\n */\n\n#ifndef PNGCONF_H\n#define PNGCONF_H\n\n/* To do: Do all of this in scripts/pnglibconf.dfa */\n#ifdef PNG_SAFE_LIMITS_SUPPORTED\n#  ifdef PNG_USER_WIDTH_MAX\n#    undef PNG_USER_WIDTH_MAX\n#    define PNG_USER_WIDTH_MAX 1000000L\n#  endif\n#  ifdef PNG_USER_HEIGHT_MAX\n#    undef PNG_USER_HEIGHT_MAX\n#    define PNG_USER_HEIGHT_MAX 1000000L\n#  endif\n#  ifdef PNG_USER_CHUNK_MALLOC_MAX\n#    undef PNG_USER_CHUNK_MALLOC_MAX\n#    define PNG_USER_CHUNK_MALLOC_MAX 4000000L\n#  endif\n#  ifdef PNG_USER_CHUNK_CACHE_MAX\n#    undef PNG_USER_CHUNK_CACHE_MAX\n#    define PNG_USER_CHUNK_CACHE_MAX 128\n#  endif\n#endif\n\n#ifndef PNG_BUILDING_SYMBOL_TABLE /* else includes may cause problems */\n\n/* From libpng 1.6.0 libpng requires an ANSI X3.159-1989 (\"ISOC90\") compliant C\n * compiler for correct compilation.  The following header files are required by\n * the standard.  If your compiler doesn't provide these header files, or they\n * do not match the standard, you will need to provide/improve them.\n */\n#include <limits.h>\n#include <stddef.h>\n\n/* Library header files.  These header files are all defined by ISOC90; libpng\n * expects conformant implementations, however, an ISOC90 conformant system need\n * not provide these header files if the functionality cannot be implemented.\n * In this case it will be necessary to disable the relevant parts of libpng in\n * the build of pnglibconf.h.\n *\n * Prior to 1.6.0 string.h was included here; the API changes in 1.6.0 to not\n * include this unnecessary header file.\n */\n\n#ifdef PNG_STDIO_SUPPORTED\n   /* Required for the definition of FILE: */\n#  include <stdio.h>\n#endif\n\n#ifdef PNG_SETJMP_SUPPORTED\n   /* Required for the definition of jmp_buf and the declaration of longjmp: */\n#  include <setjmp.h>\n#endif\n\n#ifdef PNG_CONVERT_tIME_SUPPORTED\n   /* Required for struct tm: */\n#  include <time.h>\n#endif\n\n#endif /* PNG_BUILDING_SYMBOL_TABLE */\n\n/* Prior to 1.6.0 it was possible to turn off 'const' in declarations using\n * PNG_NO_CONST; this is no longer supported except for data declarations which\n * apparently still cause problems in 2011 on some compilers.\n */\n#define PNG_CONST const /* backward compatibility only */\n\n/* This controls optimization of the reading of 16 and 32 bit values\n * from PNG files.  It can be set on a per-app-file basis - it\n * just changes whether a macro is used when the function is called.\n * The library builder sets the default; if read functions are not\n * built into the library the macro implementation is forced on.\n */\n#ifndef PNG_READ_INT_FUNCTIONS_SUPPORTED\n#  define PNG_USE_READ_MACROS\n#endif\n#if !defined(PNG_NO_USE_READ_MACROS) && !defined(PNG_USE_READ_MACROS)\n#  if PNG_DEFAULT_READ_MACROS\n#    define PNG_USE_READ_MACROS\n#  endif\n#endif\n\n/* COMPILER SPECIFIC OPTIONS.\n *\n * These options are provided so that a variety of difficult compilers\n * can be used.  Some are fixed at build time (e.g. PNG_API_RULE\n * below) but still have compiler specific implementations, others\n * may be changed on a per-file basis when compiling against libpng.\n */\n\n/* The PNGARG macro was used in versions of libpng prior to 1.6.0 to protect\n * against legacy (pre ISOC90) compilers that did not understand function\n * prototypes.  It is not required for modern C compilers.\n */\n#ifndef PNGARG\n#  define PNGARG(arglist) arglist\n#endif\n\n/* Function calling conventions.\n * =============================\n * Normally it is not necessary to specify to the compiler how to call\n * a function - it just does it - however on x86 systems derived from\n * Microsoft and Borland C compilers ('IBM PC', 'DOS', 'Windows' systems\n * and some others) there are multiple ways to call a function and the\n * default can be changed on the compiler command line.  For this reason\n * libpng specifies the calling convention of every exported function and\n * every function called via a user supplied function pointer.  This is\n * done in this file by defining the following macros:\n *\n * PNGAPI    Calling convention for exported functions.\n * PNGCBAPI  Calling convention for user provided (callback) functions.\n * PNGCAPI   Calling convention used by the ANSI-C library (required\n *           for longjmp callbacks and sometimes used internally to\n *           specify the calling convention for zlib).\n *\n * These macros should never be overridden.  If it is necessary to\n * change calling convention in a private build this can be done\n * by setting PNG_API_RULE (which defaults to 0) to one of the values\n * below to select the correct 'API' variants.\n *\n * PNG_API_RULE=0 Use PNGCAPI - the 'C' calling convention - throughout.\n *                This is correct in every known environment.\n * PNG_API_RULE=1 Use the operating system convention for PNGAPI and\n *                the 'C' calling convention (from PNGCAPI) for\n *                callbacks (PNGCBAPI).  This is no longer required\n *                in any known environment - if it has to be used\n *                please post an explanation of the problem to the\n *                libpng mailing list.\n *\n * These cases only differ if the operating system does not use the C\n * calling convention, at present this just means the above cases\n * (x86 DOS/Windows sytems) and, even then, this does not apply to\n * Cygwin running on those systems.\n *\n * Note that the value must be defined in pnglibconf.h so that what\n * the application uses to call the library matches the conventions\n * set when building the library.\n */\n\n/* Symbol export\n * =============\n * When building a shared library it is almost always necessary to tell\n * the compiler which symbols to export.  The png.h macro 'PNG_EXPORT'\n * is used to mark the symbols.  On some systems these symbols can be\n * extracted at link time and need no special processing by the compiler,\n * on other systems the symbols are flagged by the compiler and just\n * the declaration requires a special tag applied (unfortunately) in a\n * compiler dependent way.  Some systems can do either.\n *\n * A small number of older systems also require a symbol from a DLL to\n * be flagged to the program that calls it.  This is a problem because\n * we do not know in the header file included by application code that\n * the symbol will come from a shared library, as opposed to a statically\n * linked one.  For this reason the application must tell us by setting\n * the magic flag PNG_USE_DLL to turn on the special processing before\n * it includes png.h.\n *\n * Four additional macros are used to make this happen:\n *\n * PNG_IMPEXP The magic (if any) to cause a symbol to be exported from\n *            the build or imported if PNG_USE_DLL is set - compiler\n *            and system specific.\n *\n * PNG_EXPORT_TYPE(type) A macro that pre or appends PNG_IMPEXP to\n *                       'type', compiler specific.\n *\n * PNG_DLL_EXPORT Set to the magic to use during a libpng build to\n *                make a symbol exported from the DLL.  Not used in the\n *                public header files; see pngpriv.h for how it is used\n *                in the libpng build.\n *\n * PNG_DLL_IMPORT Set to the magic to force the libpng symbols to come\n *                from a DLL - used to define PNG_IMPEXP when\n *                PNG_USE_DLL is set.\n */\n\n/* System specific discovery.\n * ==========================\n * This code is used at build time to find PNG_IMPEXP, the API settings\n * and PNG_EXPORT_TYPE(), it may also set a macro to indicate the DLL\n * import processing is possible.  On Windows systems it also sets\n * compiler-specific macros to the values required to change the calling\n * conventions of the various functions.\n */\n#if defined(_Windows) || defined(_WINDOWS) || defined(WIN32) ||\\\n    defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)\n  /* Windows system (DOS doesn't support DLLs).  Includes builds under Cygwin or\n   * MinGW on any architecture currently supported by Windows.  Also includes\n   * Watcom builds but these need special treatment because they are not\n   * compatible with GCC or Visual C because of different calling conventions.\n   */\n#  if PNG_API_RULE == 2\n    /* If this line results in an error, either because __watcall is not\n     * understood or because of a redefine just below you cannot use *this*\n     * build of the library with the compiler you are using.  *This* build was\n     * build using Watcom and applications must also be built using Watcom!\n     */\n#    define PNGCAPI __watcall\n#  endif\n\n#  if defined(__GNUC__) || (defined(_MSC_VER) && (_MSC_VER >= 800))\n#    define PNGCAPI __cdecl\n#    if PNG_API_RULE == 1\n       /* If this line results in an error __stdcall is not understood and\n        * PNG_API_RULE should not have been set to '1'.\n        */\n#      define PNGAPI __stdcall\n#    endif\n#  else\n    /* An older compiler, or one not detected (erroneously) above,\n     * if necessary override on the command line to get the correct\n     * variants for the compiler.\n     */\n#    ifndef PNGCAPI\n#      define PNGCAPI _cdecl\n#    endif\n#    if PNG_API_RULE == 1 && !defined(PNGAPI)\n#      define PNGAPI _stdcall\n#    endif\n#  endif /* compiler/api */\n\n  /* NOTE: PNGCBAPI always defaults to PNGCAPI. */\n\n#  if defined(PNGAPI) && !defined(PNG_USER_PRIVATEBUILD)\n#     error \"PNG_USER_PRIVATEBUILD must be defined if PNGAPI is changed\"\n#  endif\n\n#  if (defined(_MSC_VER) && _MSC_VER < 800) ||\\\n      (defined(__BORLANDC__) && __BORLANDC__ < 0x500)\n    /* older Borland and MSC\n     * compilers used '__export' and required this to be after\n     * the type.\n     */\n#    ifndef PNG_EXPORT_TYPE\n#      define PNG_EXPORT_TYPE(type) type PNG_IMPEXP\n#    endif\n#    define PNG_DLL_EXPORT __export\n#  else /* newer compiler */\n#    define PNG_DLL_EXPORT __declspec(dllexport)\n#    ifndef PNG_DLL_IMPORT\n#      define PNG_DLL_IMPORT __declspec(dllimport)\n#    endif\n#  endif /* compiler */\n\n#else /* !Windows */\n#  if (defined(__IBMC__) || defined(__IBMCPP__)) && defined(__OS2__)\n#    define PNGAPI _System\n#  else /* !Windows/x86 && !OS/2 */\n    /* Use the defaults, or define PNG*API on the command line (but\n     * this will have to be done for every compile!)\n     */\n#  endif /* other system, !OS/2 */\n#endif /* !Windows/x86 */\n\n/* Now do all the defaulting . */\n#ifndef PNGCAPI\n#  define PNGCAPI\n#endif\n#ifndef PNGCBAPI\n#  define PNGCBAPI PNGCAPI\n#endif\n#ifndef PNGAPI\n#  define PNGAPI PNGCAPI\n#endif\n\n/* PNG_IMPEXP may be set on the compilation system command line or (if not set)\n * then in an internal header file when building the library, otherwise (when\n * using the library) it is set here.\n */\n#ifndef PNG_IMPEXP\n#  if defined(PNG_USE_DLL) && defined(PNG_DLL_IMPORT)\n     /* This forces use of a DLL, disallowing static linking */\n#    define PNG_IMPEXP PNG_DLL_IMPORT\n#  endif\n\n#  ifndef PNG_IMPEXP\n#    define PNG_IMPEXP\n#  endif\n#endif\n\n/* In 1.5.2 the definition of PNG_FUNCTION has been changed to always treat\n * 'attributes' as a storage class - the attributes go at the start of the\n * function definition, and attributes are always appended regardless of the\n * compiler.  This considerably simplifies these macros but may cause problems\n * if any compilers both need function attributes and fail to handle them as\n * a storage class (this is unlikely.)\n */\n#ifndef PNG_FUNCTION\n#  define PNG_FUNCTION(type, name, args, attributes) attributes type name args\n#endif\n\n#ifndef PNG_EXPORT_TYPE\n#  define PNG_EXPORT_TYPE(type) PNG_IMPEXP type\n#endif\n\n   /* The ordinal value is only relevant when preprocessing png.h for symbol\n    * table entries, so we discard it here.  See the .dfn files in the\n    * scripts directory.\n    */\n#ifndef PNG_EXPORTA\n\n#  define PNG_EXPORTA(ordinal, type, name, args, attributes)\\\n      PNG_FUNCTION(PNG_EXPORT_TYPE(type),(PNGAPI name),PNGARG(args), \\\n        extern attributes)\n#endif\n\n/* ANSI-C (C90) does not permit a macro to be invoked with an empty argument,\n * so make something non-empty to satisfy the requirement:\n */\n#define PNG_EMPTY /*empty list*/\n\n#define PNG_EXPORT(ordinal, type, name, args)\\\n   PNG_EXPORTA(ordinal, type, name, args, PNG_EMPTY)\n\n/* Use PNG_REMOVED to comment out a removed interface. */\n#ifndef PNG_REMOVED\n#  define PNG_REMOVED(ordinal, type, name, args, attributes)\n#endif\n\n#ifndef PNG_CALLBACK\n#  define PNG_CALLBACK(type, name, args) type (PNGCBAPI name) PNGARG(args)\n#endif\n\n/* Support for compiler specific function attributes.  These are used\n * so that where compiler support is available incorrect use of API\n * functions in png.h will generate compiler warnings.\n *\n * Added at libpng-1.2.41.\n */\n\n#ifndef PNG_NO_PEDANTIC_WARNINGS\n#  ifndef PNG_PEDANTIC_WARNINGS_SUPPORTED\n#    define PNG_PEDANTIC_WARNINGS_SUPPORTED\n#  endif\n#endif\n\n#ifdef PNG_PEDANTIC_WARNINGS_SUPPORTED\n  /* Support for compiler specific function attributes.  These are used\n   * so that where compiler support is available, incorrect use of API\n   * functions in png.h will generate compiler warnings.  Added at libpng\n   * version 1.2.41.  Disabling these removes the warnings but may also produce\n   * less efficient code.\n   */\n#  if defined(__clang__)\n     /* Clang defines both __clang__ and __GNUC__. Check __clang__ first. */\n#    if !defined(PNG_USE_RESULT) && __has_attribute(__warn_unused_result__)\n#      define PNG_USE_RESULT __attribute__((__warn_unused_result__))\n#    endif\n#    if !defined(PNG_NORETURN) && __has_attribute(__noreturn__)\n#      define PNG_NORETURN __attribute__((__noreturn__))\n#    endif\n#    if !defined(PNG_ALLOCATED) && __has_attribute(__malloc__)\n#      define PNG_ALLOCATED __attribute__((__malloc__))\n#    endif\n#    if !defined(PNG_DEPRECATED) && __has_attribute(__deprecated__)\n#      define PNG_DEPRECATED __attribute__((__deprecated__))\n#    endif\n#    if !defined(PNG_PRIVATE)\n#      ifdef __has_extension\n#        if __has_extension(attribute_unavailable_with_message)\n#          define PNG_PRIVATE __attribute__((__unavailable__(\\\n             \"This function is not exported by libpng.\")))\n#        endif\n#      endif\n#    endif\n#    ifndef PNG_RESTRICT\n#      define PNG_RESTRICT __restrict\n#    endif\n\n#  elif defined(__GNUC__)\n#    ifndef PNG_USE_RESULT\n#      define PNG_USE_RESULT __attribute__((__warn_unused_result__))\n#    endif\n#    ifndef PNG_NORETURN\n#      define PNG_NORETURN   __attribute__((__noreturn__))\n#    endif\n#    if __GNUC__ >= 3\n#      ifndef PNG_ALLOCATED\n#        define PNG_ALLOCATED  __attribute__((__malloc__))\n#      endif\n#      ifndef PNG_DEPRECATED\n#        define PNG_DEPRECATED __attribute__((__deprecated__))\n#      endif\n#      ifndef PNG_PRIVATE\n#        if 0 /* Doesn't work so we use deprecated instead*/\n#          define PNG_PRIVATE \\\n            __attribute__((warning(\"This function is not exported by libpng.\")))\n#        else\n#          define PNG_PRIVATE \\\n            __attribute__((__deprecated__))\n#        endif\n#      endif\n#      if ((__GNUC__ > 3) || !defined(__GNUC_MINOR__) || (__GNUC_MINOR__ >= 1))\n#        ifndef PNG_RESTRICT\n#          define PNG_RESTRICT __restrict\n#        endif\n#      endif /* __GNUC__.__GNUC_MINOR__ > 3.0 */\n#    endif /* __GNUC__ >= 3 */\n\n#  elif defined(_MSC_VER)  && (_MSC_VER >= 1300)\n#    ifndef PNG_USE_RESULT\n#      define PNG_USE_RESULT /* not supported */\n#    endif\n#    ifndef PNG_NORETURN\n#      define PNG_NORETURN   __declspec(noreturn)\n#    endif\n#    ifndef PNG_ALLOCATED\n#      if (_MSC_VER >= 1400)\n#        define PNG_ALLOCATED __declspec(restrict)\n#      endif\n#    endif\n#    ifndef PNG_DEPRECATED\n#      define PNG_DEPRECATED __declspec(deprecated)\n#    endif\n#    ifndef PNG_PRIVATE\n#      define PNG_PRIVATE __declspec(deprecated)\n#    endif\n#    ifndef PNG_RESTRICT\n#      if (_MSC_VER >= 1400)\n#        define PNG_RESTRICT __restrict\n#      endif\n#    endif\n\n#  elif defined(__WATCOMC__)\n#    ifndef PNG_RESTRICT\n#      define PNG_RESTRICT __restrict\n#    endif\n#  endif\n#endif /* PNG_PEDANTIC_WARNINGS */\n\n#ifndef PNG_DEPRECATED\n#  define PNG_DEPRECATED  /* Use of this function is deprecated */\n#endif\n#ifndef PNG_USE_RESULT\n#  define PNG_USE_RESULT  /* The result of this function must be checked */\n#endif\n#ifndef PNG_NORETURN\n#  define PNG_NORETURN    /* This function does not return */\n#endif\n#ifndef PNG_ALLOCATED\n#  define PNG_ALLOCATED   /* The result of the function is new memory */\n#endif\n#ifndef PNG_PRIVATE\n#  define PNG_PRIVATE     /* This is a private libpng function */\n#endif\n#ifndef PNG_RESTRICT\n#  define PNG_RESTRICT    /* The C99 \"restrict\" feature */\n#endif\n\n#ifndef PNG_FP_EXPORT     /* A floating point API. */\n#  ifdef PNG_FLOATING_POINT_SUPPORTED\n#     define PNG_FP_EXPORT(ordinal, type, name, args)\\\n         PNG_EXPORT(ordinal, type, name, args);\n#  else                   /* No floating point APIs */\n#     define PNG_FP_EXPORT(ordinal, type, name, args)\n#  endif\n#endif\n#ifndef PNG_FIXED_EXPORT  /* A fixed point API. */\n#  ifdef PNG_FIXED_POINT_SUPPORTED\n#     define PNG_FIXED_EXPORT(ordinal, type, name, args)\\\n         PNG_EXPORT(ordinal, type, name, args);\n#  else                   /* No fixed point APIs */\n#     define PNG_FIXED_EXPORT(ordinal, type, name, args)\n#  endif\n#endif\n\n#ifndef PNG_BUILDING_SYMBOL_TABLE\n/* Some typedefs to get us started.  These should be safe on most of the common\n * platforms.\n *\n * png_uint_32 and png_int_32 may, currently, be larger than required to hold a\n * 32-bit value however this is not normally advisable.\n *\n * png_uint_16 and png_int_16 should always be two bytes in size - this is\n * verified at library build time.\n *\n * png_byte must always be one byte in size.\n *\n * The checks below use constants from limits.h, as defined by the ISOC90\n * standard.\n */\n#if CHAR_BIT == 8 && UCHAR_MAX == 255\n   typedef unsigned char png_byte;\n#else\n#  error \"libpng requires 8 bit bytes\"\n#endif\n\n#if INT_MIN == -32768 && INT_MAX == 32767\n   typedef int png_int_16;\n#elif SHRT_MIN == -32768 && SHRT_MAX == 32767\n   typedef short png_int_16;\n#else\n#  error \"libpng requires a signed 16 bit type\"\n#endif\n\n#if UINT_MAX == 65535\n   typedef unsigned int png_uint_16;\n#elif USHRT_MAX == 65535\n   typedef unsigned short png_uint_16;\n#else\n#  error \"libpng requires an unsigned 16 bit type\"\n#endif\n\n#if INT_MIN < -2147483646 && INT_MAX > 2147483646\n   typedef int png_int_32;\n#elif LONG_MIN < -2147483646 && LONG_MAX > 2147483646\n   typedef long int png_int_32;\n#else\n#  error \"libpng requires a signed 32 bit (or more) type\"\n#endif\n\n#if UINT_MAX > 4294967294\n   typedef unsigned int png_uint_32;\n#elif ULONG_MAX > 4294967294\n   typedef unsigned long int png_uint_32;\n#else\n#  error \"libpng requires an unsigned 32 bit (or more) type\"\n#endif\n\n/* Prior to 1.6.0 it was possible to disable the use of size_t, 1.6.0, however,\n * requires an ISOC90 compiler and relies on consistent behavior of sizeof.\n */\ntypedef size_t png_size_t;\ntypedef ptrdiff_t png_ptrdiff_t;\n\n/* libpng needs to know the maximum value of 'size_t' and this controls the\n * definition of png_alloc_size_t, below.  This maximum value of size_t limits\n * but does not control the maximum allocations the library makes - there is\n * direct application control of this through png_set_user_limits().\n */\n#ifndef PNG_SMALL_SIZE_T\n   /* Compiler specific tests for systems where size_t is known to be less than\n    * 32 bits (some of these systems may no longer work because of the lack of\n    * 'far' support; see above.)\n    */\n#  if (defined(__TURBOC__) && !defined(__FLAT__)) ||\\\n   (defined(_MSC_VER) && defined(MAXSEG_64K))\n#     define PNG_SMALL_SIZE_T\n#  endif\n#endif\n\n/* png_alloc_size_t is guaranteed to be no smaller than png_size_t, and no\n * smaller than png_uint_32.  Casts from png_size_t or png_uint_32 to\n * png_alloc_size_t are not necessary; in fact, it is recommended not to use\n * them at all so that the compiler can complain when something turns out to be\n * problematic.\n *\n * Casts in the other direction (from png_alloc_size_t to png_size_t or\n * png_uint_32) should be explicitly applied; however, we do not expect to\n * encounter practical situations that require such conversions.\n *\n * PNG_SMALL_SIZE_T must be defined if the maximum value of size_t is less than\n * 4294967295 - i.e. less than the maximum value of png_uint_32.\n */\n#ifdef PNG_SMALL_SIZE_T\n   typedef png_uint_32 png_alloc_size_t;\n#else\n   typedef png_size_t png_alloc_size_t;\n#endif\n\n/* Prior to 1.6.0 libpng offered limited support for Microsoft C compiler\n * implementations of Intel CPU specific support of user-mode segmented address\n * spaces, where 16-bit pointers address more than 65536 bytes of memory using\n * separate 'segment' registers.  The implementation requires two different\n * types of pointer (only one of which includes the segment value.)\n *\n * If required this support is available in version 1.2 of libpng and may be\n * available in versions through 1.5, although the correctness of the code has\n * not been verified recently.\n */\n\n/* Typedef for floating-point numbers that are converted to fixed-point with a\n * multiple of 100,000, e.g., gamma\n */\ntypedef png_int_32 png_fixed_point;\n\n/* Add typedefs for pointers */\ntypedef void                  * png_voidp;\ntypedef const void            * png_const_voidp;\ntypedef png_byte              * png_bytep;\ntypedef const png_byte        * png_const_bytep;\ntypedef png_uint_32           * png_uint_32p;\ntypedef const png_uint_32     * png_const_uint_32p;\ntypedef png_int_32            * png_int_32p;\ntypedef const png_int_32      * png_const_int_32p;\ntypedef png_uint_16           * png_uint_16p;\ntypedef const png_uint_16     * png_const_uint_16p;\ntypedef png_int_16            * png_int_16p;\ntypedef const png_int_16      * png_const_int_16p;\ntypedef char                  * png_charp;\ntypedef const char            * png_const_charp;\ntypedef png_fixed_point       * png_fixed_point_p;\ntypedef const png_fixed_point * png_const_fixed_point_p;\ntypedef png_size_t            * png_size_tp;\ntypedef const png_size_t      * png_const_size_tp;\n\n#ifdef PNG_STDIO_SUPPORTED\ntypedef FILE            * png_FILE_p;\n#endif\n\n#ifdef PNG_FLOATING_POINT_SUPPORTED\ntypedef double       * png_doublep;\ntypedef const double * png_const_doublep;\n#endif\n\n/* Pointers to pointers; i.e. arrays */\ntypedef png_byte        * * png_bytepp;\ntypedef png_uint_32     * * png_uint_32pp;\ntypedef png_int_32      * * png_int_32pp;\ntypedef png_uint_16     * * png_uint_16pp;\ntypedef png_int_16      * * png_int_16pp;\ntypedef const char      * * png_const_charpp;\ntypedef char            * * png_charpp;\ntypedef png_fixed_point * * png_fixed_point_pp;\n#ifdef PNG_FLOATING_POINT_SUPPORTED\ntypedef double          * * png_doublepp;\n#endif\n\n/* Pointers to pointers to pointers; i.e., pointer to array */\ntypedef char            * * * png_charppp;\n\n#endif /* PNG_BUILDING_SYMBOL_TABLE */\n\n#endif /* PNGCONF_H */\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/png/pngdebug.h",
    "content": "\n/* pngdebug.h - Debugging macros for libpng, also used in pngtest.c\n *\n * Copyright (c) 1998-2013 Glenn Randers-Pehrson\n * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)\n * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)\n *\n * Last changed in libpng 1.6.8 [December 19, 2013]\n *\n * This code is released under the libpng license.\n * For conditions of distribution and use, see the disclaimer\n * and license in png.h\n */\n\n/* Define PNG_DEBUG at compile time for debugging information.  Higher\n * numbers for PNG_DEBUG mean more debugging information.  This has\n * only been added since version 0.95 so it is not implemented throughout\n * libpng yet, but more support will be added as needed.\n *\n * png_debug[1-2]?(level, message ,arg{0-2})\n *   Expands to a statement (either a simple expression or a compound\n *   do..while(0) statement) that outputs a message with parameter\n *   substitution if PNG_DEBUG is defined to 2 or more.  If PNG_DEBUG\n *   is undefined, 0 or 1 every png_debug expands to a simple expression\n *   (actually ((void)0)).\n *\n *   level: level of detail of message, starting at 0.  A level 'n'\n *          message is preceded by 'n' 3-space indentations (not implemented\n *          on Microsoft compilers unless PNG_DEBUG_FILE is also\n *          defined, to allow debug DLL compilation with no standard IO).\n *   message: a printf(3) style text string.  A trailing '\\n' is added\n *            to the message.\n *   arg: 0 to 2 arguments for printf(3) style substitution in message.\n */\n#ifndef PNGDEBUG_H\n#define PNGDEBUG_H\n/* These settings control the formatting of messages in png.c and pngerror.c */\n/* Moved to pngdebug.h at 1.5.0 */\n#  ifndef PNG_LITERAL_SHARP\n#    define PNG_LITERAL_SHARP 0x23\n#  endif\n#  ifndef PNG_LITERAL_LEFT_SQUARE_BRACKET\n#    define PNG_LITERAL_LEFT_SQUARE_BRACKET 0x5b\n#  endif\n#  ifndef PNG_LITERAL_RIGHT_SQUARE_BRACKET\n#    define PNG_LITERAL_RIGHT_SQUARE_BRACKET 0x5d\n#  endif\n#  ifndef PNG_STRING_NEWLINE\n#    define PNG_STRING_NEWLINE \"\\n\"\n#  endif\n\n#ifdef PNG_DEBUG\n#  if (PNG_DEBUG > 0)\n#    if !defined(PNG_DEBUG_FILE) && defined(_MSC_VER)\n#      include <crtdbg.h>\n#      if (PNG_DEBUG > 1)\n#        ifndef _DEBUG\n#          define _DEBUG\n#        endif\n#        ifndef png_debug\n#          define png_debug(l,m)  _RPT0(_CRT_WARN,m PNG_STRING_NEWLINE)\n#        endif\n#        ifndef png_debug1\n#          define png_debug1(l,m,p1)  _RPT1(_CRT_WARN,m PNG_STRING_NEWLINE,p1)\n#        endif\n#        ifndef png_debug2\n#          define png_debug2(l,m,p1,p2) \\\n             _RPT2(_CRT_WARN,m PNG_STRING_NEWLINE,p1,p2)\n#        endif\n#      endif\n#    else /* PNG_DEBUG_FILE || !_MSC_VER */\n#      ifndef PNG_STDIO_SUPPORTED\n#        include <stdio.h> /* not included yet */\n#      endif\n#      ifndef PNG_DEBUG_FILE\n#        define PNG_DEBUG_FILE stderr\n#      endif /* PNG_DEBUG_FILE */\n\n#      if (PNG_DEBUG > 1)\n#        ifdef __STDC__\n#          ifndef png_debug\n#            define png_debug(l,m) \\\n       do { \\\n       int num_tabs=l; \\\n       fprintf(PNG_DEBUG_FILE,\"%s\" m PNG_STRING_NEWLINE,(num_tabs==1 ? \"   \" : \\\n         (num_tabs==2 ? \"      \" : (num_tabs>2 ? \"         \" : \"\")))); \\\n       } while (0)\n#          endif\n#          ifndef png_debug1\n#            define png_debug1(l,m,p1) \\\n       do { \\\n       int num_tabs=l; \\\n       fprintf(PNG_DEBUG_FILE,\"%s\" m PNG_STRING_NEWLINE,(num_tabs==1 ? \"   \" : \\\n         (num_tabs==2 ? \"      \" : (num_tabs>2 ? \"         \" : \"\"))),p1); \\\n       } while (0)\n#          endif\n#          ifndef png_debug2\n#            define png_debug2(l,m,p1,p2) \\\n       do { \\\n       int num_tabs=l; \\\n       fprintf(PNG_DEBUG_FILE,\"%s\" m PNG_STRING_NEWLINE,(num_tabs==1 ? \"   \" : \\\n         (num_tabs==2 ? \"      \" : (num_tabs>2 ? \"         \" : \"\"))),p1,p2);\\\n       } while (0)\n#          endif\n#        else /* __STDC __ */\n#          ifndef png_debug\n#            define png_debug(l,m) \\\n       do { \\\n       int num_tabs=l; \\\n       char format[256]; \\\n       snprintf(format,256,\"%s%s%s\",(num_tabs==1 ? \"\\t\" : \\\n         (num_tabs==2 ? \"\\t\\t\":(num_tabs>2 ? \"\\t\\t\\t\":\"\"))), \\\n         m,PNG_STRING_NEWLINE); \\\n       fprintf(PNG_DEBUG_FILE,format); \\\n       } while (0)\n#          endif\n#          ifndef png_debug1\n#            define png_debug1(l,m,p1) \\\n       do { \\\n       int num_tabs=l; \\\n       char format[256]; \\\n       snprintf(format,256,\"%s%s%s\",(num_tabs==1 ? \"\\t\" : \\\n         (num_tabs==2 ? \"\\t\\t\":(num_tabs>2 ? \"\\t\\t\\t\":\"\"))), \\\n         m,PNG_STRING_NEWLINE); \\\n       fprintf(PNG_DEBUG_FILE,format,p1); \\\n       } while (0)\n#          endif\n#          ifndef png_debug2\n#            define png_debug2(l,m,p1,p2) \\\n       do { \\\n       int num_tabs=l; \\\n       char format[256]; \\\n       snprintf(format,256,\"%s%s%s\",(num_tabs==1 ? \"\\t\" : \\\n         (num_tabs==2 ? \"\\t\\t\":(num_tabs>2 ? \"\\t\\t\\t\":\"\"))), \\\n         m,PNG_STRING_NEWLINE); \\\n       fprintf(PNG_DEBUG_FILE,format,p1,p2); \\\n       } while (0)\n#          endif\n#        endif /* __STDC __ */\n#      endif /* (PNG_DEBUG > 1) */\n\n#    endif /* _MSC_VER */\n#  endif /* (PNG_DEBUG > 0) */\n#endif /* PNG_DEBUG */\n#ifndef png_debug\n#  define png_debug(l, m) ((void)0)\n#endif\n#ifndef png_debug1\n#  define png_debug1(l, m, p1) ((void)0)\n#endif\n#ifndef png_debug2\n#  define png_debug2(l, m, p1, p2) ((void)0)\n#endif\n#endif /* PNGDEBUG_H */\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/png/pnginfo.h",
    "content": "\n/* pnginfo.h - header file for PNG reference library\n *\n * Copyright (c) 1998-2013 Glenn Randers-Pehrson\n * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)\n * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)\n *\n * Last changed in libpng 1.6.1 [March 28, 2013]\n *\n * This code is released under the libpng license.\n * For conditions of distribution and use, see the disclaimer\n * and license in png.h\n */\n\n /* png_info is a structure that holds the information in a PNG file so\n * that the application can find out the characteristics of the image.\n * If you are reading the file, this structure will tell you what is\n * in the PNG file.  If you are writing the file, fill in the information\n * you want to put into the PNG file, using png_set_*() functions, then\n * call png_write_info().\n *\n * The names chosen should be very close to the PNG specification, so\n * consult that document for information about the meaning of each field.\n *\n * With libpng < 0.95, it was only possible to directly set and read the\n * the values in the png_info_struct, which meant that the contents and\n * order of the values had to remain fixed.  With libpng 0.95 and later,\n * however, there are now functions that abstract the contents of\n * png_info_struct from the application, so this makes it easier to use\n * libpng with dynamic libraries, and even makes it possible to use\n * libraries that don't have all of the libpng ancillary chunk-handing\n * functionality.  In libpng-1.5.0 this was moved into a separate private\n * file that is not visible to applications.\n *\n * The following members may have allocated storage attached that should be\n * cleaned up before the structure is discarded: palette, trans, text,\n * pcal_purpose, pcal_units, pcal_params, hist, iccp_name, iccp_profile,\n * splt_palettes, scal_unit, row_pointers, and unknowns.   By default, these\n * are automatically freed when the info structure is deallocated, if they were\n * allocated internally by libpng.  This behavior can be changed by means\n * of the png_data_freer() function.\n *\n * More allocation details: all the chunk-reading functions that\n * change these members go through the corresponding png_set_*\n * functions.  A function to clear these members is available: see\n * png_free_data().  The png_set_* functions do not depend on being\n * able to point info structure members to any of the storage they are\n * passed (they make their own copies), EXCEPT that the png_set_text\n * functions use the same storage passed to them in the text_ptr or\n * itxt_ptr structure argument, and the png_set_rows and png_set_unknowns\n * functions do not make their own copies.\n */\n#ifndef PNGINFO_H\n#define PNGINFO_H\n\nstruct png_info_def\n{\n   /* The following are necessary for every PNG file */\n   png_uint_32 width;  /* width of image in pixels (from IHDR) */\n   png_uint_32 height; /* height of image in pixels (from IHDR) */\n   png_uint_32 valid;  /* valid chunk data (see PNG_INFO_ below) */\n   png_size_t rowbytes; /* bytes needed to hold an untransformed row */\n   png_colorp palette;      /* array of color values (valid & PNG_INFO_PLTE) */\n   png_uint_16 num_palette; /* number of color entries in \"palette\" (PLTE) */\n   png_uint_16 num_trans;   /* number of transparent palette color (tRNS) */\n   png_byte bit_depth;      /* 1, 2, 4, 8, or 16 bits/channel (from IHDR) */\n   png_byte color_type;     /* see PNG_COLOR_TYPE_ below (from IHDR) */\n   /* The following three should have been named *_method not *_type */\n   png_byte compression_type; /* must be PNG_COMPRESSION_TYPE_BASE (IHDR) */\n   png_byte filter_type;    /* must be PNG_FILTER_TYPE_BASE (from IHDR) */\n   png_byte interlace_type; /* One of PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */\n\n   /* The following are set by png_set_IHDR, called from the application on\n    * write, but the are never actually used by the write code.\n    */\n   png_byte channels;       /* number of data channels per pixel (1, 2, 3, 4) */\n   png_byte pixel_depth;    /* number of bits per pixel */\n   png_byte spare_byte;     /* to align the data, and for future use */\n\n#ifdef PNG_READ_SUPPORTED\n   /* This is never set during write */\n   png_byte signature[8];   /* magic bytes read by libpng from start of file */\n#endif\n\n   /* The rest of the data is optional.  If you are reading, check the\n    * valid field to see if the information in these are valid.  If you\n    * are writing, set the valid field to those chunks you want written,\n    * and initialize the appropriate fields below.\n    */\n\n#if defined(PNG_COLORSPACE_SUPPORTED) || defined(PNG_GAMMA_SUPPORTED)\n   /* png_colorspace only contains 'flags' if neither GAMMA or COLORSPACE are\n    * defined.  When COLORSPACE is switched on all the colorspace-defining\n    * chunks should be enabled, when GAMMA is switched on all the gamma-defining\n    * chunks should be enabled.  If this is not done it becomes possible to read\n    * inconsistent PNG files and assign a probably incorrect interpretation to\n    * the information.  (In other words, by carefully choosing which chunks to\n    * recognize the system configuration can select an interpretation for PNG\n    * files containing ambiguous data and this will result in inconsistent\n    * behavior between different libpng builds!)\n    */\n   png_colorspace colorspace;\n#endif\n\n#ifdef PNG_iCCP_SUPPORTED\n   /* iCCP chunk data. */\n   png_charp iccp_name;     /* profile name */\n   png_bytep iccp_profile;  /* International Color Consortium profile data */\n   png_uint_32 iccp_proflen;  /* ICC profile data length */\n#endif\n\n#ifdef PNG_TEXT_SUPPORTED\n   /* The tEXt, and zTXt chunks contain human-readable textual data in\n    * uncompressed, compressed, and optionally compressed forms, respectively.\n    * The data in \"text\" is an array of pointers to uncompressed,\n    * null-terminated C strings. Each chunk has a keyword that describes the\n    * textual data contained in that chunk.  Keywords are not required to be\n    * unique, and the text string may be empty.  Any number of text chunks may\n    * be in an image.\n    */\n   int num_text; /* number of comments read or comments to write */\n   int max_text; /* current size of text array */\n   png_textp text; /* array of comments read or comments to write */\n#endif /* PNG_TEXT_SUPPORTED */\n\n#ifdef PNG_tIME_SUPPORTED\n   /* The tIME chunk holds the last time the displayed image data was\n    * modified.  See the png_time struct for the contents of this struct.\n    */\n   png_time mod_time;\n#endif\n\n#ifdef PNG_sBIT_SUPPORTED\n   /* The sBIT chunk specifies the number of significant high-order bits\n    * in the pixel data.  Values are in the range [1, bit_depth], and are\n    * only specified for the channels in the pixel data.  The contents of\n    * the low-order bits is not specified.  Data is valid if\n    * (valid & PNG_INFO_sBIT) is non-zero.\n    */\n   png_color_8 sig_bit; /* significant bits in color channels */\n#endif\n\n#if defined(PNG_tRNS_SUPPORTED) || defined(PNG_READ_EXPAND_SUPPORTED) || \\\ndefined(PNG_READ_BACKGROUND_SUPPORTED)\n   /* The tRNS chunk supplies transparency data for paletted images and\n    * other image types that don't need a full alpha channel.  There are\n    * \"num_trans\" transparency values for a paletted image, stored in the\n    * same order as the palette colors, starting from index 0.  Values\n    * for the data are in the range [0, 255], ranging from fully transparent\n    * to fully opaque, respectively.  For non-paletted images, there is a\n    * single color specified that should be treated as fully transparent.\n    * Data is valid if (valid & PNG_INFO_tRNS) is non-zero.\n    */\n   png_bytep trans_alpha;    /* alpha values for paletted image */\n   png_color_16 trans_color; /* transparent color for non-palette image */\n#endif\n\n#if defined(PNG_bKGD_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)\n   /* The bKGD chunk gives the suggested image background color if the\n    * display program does not have its own background color and the image\n    * is needs to composited onto a background before display.  The colors\n    * in \"background\" are normally in the same color space/depth as the\n    * pixel data.  Data is valid if (valid & PNG_INFO_bKGD) is non-zero.\n    */\n   png_color_16 background;\n#endif\n\n#ifdef PNG_oFFs_SUPPORTED\n   /* The oFFs chunk gives the offset in \"offset_unit_type\" units rightwards\n    * and downwards from the top-left corner of the display, page, or other\n    * application-specific co-ordinate space.  See the PNG_OFFSET_ defines\n    * below for the unit types.  Valid if (valid & PNG_INFO_oFFs) non-zero.\n    */\n   png_int_32 x_offset; /* x offset on page */\n   png_int_32 y_offset; /* y offset on page */\n   png_byte offset_unit_type; /* offset units type */\n#endif\n\n#ifdef PNG_pHYs_SUPPORTED\n   /* The pHYs chunk gives the physical pixel density of the image for\n    * display or printing in \"phys_unit_type\" units (see PNG_RESOLUTION_\n    * defines below).  Data is valid if (valid & PNG_INFO_pHYs) is non-zero.\n    */\n   png_uint_32 x_pixels_per_unit; /* horizontal pixel density */\n   png_uint_32 y_pixels_per_unit; /* vertical pixel density */\n   png_byte phys_unit_type; /* resolution type (see PNG_RESOLUTION_ below) */\n#endif\n\n#ifdef PNG_hIST_SUPPORTED\n   /* The hIST chunk contains the relative frequency or importance of the\n    * various palette entries, so that a viewer can intelligently select a\n    * reduced-color palette, if required.  Data is an array of \"num_palette\"\n    * values in the range [0,65535]. Data valid if (valid & PNG_INFO_hIST)\n    * is non-zero.\n    */\n   png_uint_16p hist;\n#endif\n\n#ifdef PNG_pCAL_SUPPORTED\n   /* The pCAL chunk describes a transformation between the stored pixel\n    * values and original physical data values used to create the image.\n    * The integer range [0, 2^bit_depth - 1] maps to the floating-point\n    * range given by [pcal_X0, pcal_X1], and are further transformed by a\n    * (possibly non-linear) transformation function given by \"pcal_type\"\n    * and \"pcal_params\" into \"pcal_units\".  Please see the PNG_EQUATION_\n    * defines below, and the PNG-Group's PNG extensions document for a\n    * complete description of the transformations and how they should be\n    * implemented, and for a description of the ASCII parameter strings.\n    * Data values are valid if (valid & PNG_INFO_pCAL) non-zero.\n    */\n   png_charp pcal_purpose;  /* pCAL chunk description string */\n   png_int_32 pcal_X0;      /* minimum value */\n   png_int_32 pcal_X1;      /* maximum value */\n   png_charp pcal_units;    /* Latin-1 string giving physical units */\n   png_charpp pcal_params;  /* ASCII strings containing parameter values */\n   png_byte pcal_type;      /* equation type (see PNG_EQUATION_ below) */\n   png_byte pcal_nparams;   /* number of parameters given in pcal_params */\n#endif\n\n/* New members added in libpng-1.0.6 */\n   png_uint_32 free_me;     /* flags items libpng is responsible for freeing */\n\n#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED\n   /* Storage for unknown chunks that the library doesn't recognize. */\n   png_unknown_chunkp unknown_chunks;\n\n   /* The type of this field is limited by the type of \n    * png_struct::user_chunk_cache_max, else overflow can occur.\n    */\n   int                unknown_chunks_num;\n#endif\n\n#ifdef PNG_sPLT_SUPPORTED\n   /* Data on sPLT chunks (there may be more than one). */\n   png_sPLT_tp splt_palettes;\n   int         splt_palettes_num; /* Match type returned by png_get API */\n#endif\n\n#ifdef PNG_sCAL_SUPPORTED\n   /* The sCAL chunk describes the actual physical dimensions of the\n    * subject matter of the graphic.  The chunk contains a unit specification\n    * a byte value, and two ASCII strings representing floating-point\n    * values.  The values are width and height corresponsing to one pixel\n    * in the image.  Data values are valid if (valid & PNG_INFO_sCAL) is\n    * non-zero.\n    */\n   png_byte scal_unit;         /* unit of physical scale */\n   png_charp scal_s_width;     /* string containing height */\n   png_charp scal_s_height;    /* string containing width */\n#endif\n\n#ifdef PNG_INFO_IMAGE_SUPPORTED\n   /* Memory has been allocated if (valid & PNG_ALLOCATED_INFO_ROWS)\n      non-zero */\n   /* Data valid if (valid & PNG_INFO_IDAT) non-zero */\n   png_bytepp row_pointers;        /* the image bits */\n#endif\n\n};\n#endif /* PNGINFO_H */\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/png/pnglibconf.h",
    "content": "/* libpng 1.6.10 STANDARD API DEFINITION */\n\n/* pnglibconf.h - library build configuration */\n\n/* Libpng version 1.6.10 - March 6, 2014 */\n\n/* Copyright (c) 1998-2013 Glenn Randers-Pehrson */\n\n/* This code is released under the libpng license. */\n/* For conditions of distribution and use, see the disclaimer */\n/* and license in png.h */\n\n/* pnglibconf.h */\n/* Machine generated file: DO NOT EDIT */\n/* Derived from: scripts/pnglibconf.dfa */\n#ifndef PNGLCONF_H\n#define PNGLCONF_H\n/* options */\n#define PNG_16BIT_SUPPORTED\n#define PNG_ALIGNED_MEMORY_SUPPORTED\n/*#undef PNG_ARM_NEON_API_SUPPORTED*/\n/*#undef PNG_ARM_NEON_CHECK_SUPPORTED*/\n#define PNG_BENIGN_ERRORS_SUPPORTED\n#define PNG_BENIGN_READ_ERRORS_SUPPORTED\n/*#undef PNG_BENIGN_WRITE_ERRORS_SUPPORTED*/\n#define PNG_BUILD_GRAYSCALE_PALETTE_SUPPORTED\n#define PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED\n#define PNG_COLORSPACE_SUPPORTED\n#define PNG_CONSOLE_IO_SUPPORTED\n#define PNG_CONVERT_tIME_SUPPORTED\n#define PNG_EASY_ACCESS_SUPPORTED\n/*#undef PNG_ERROR_NUMBERS_SUPPORTED*/\n#define PNG_ERROR_TEXT_SUPPORTED\n#define PNG_FIXED_POINT_SUPPORTED\n#define PNG_FLOATING_ARITHMETIC_SUPPORTED\n#define PNG_FLOATING_POINT_SUPPORTED\n#define PNG_FORMAT_AFIRST_SUPPORTED\n#define PNG_FORMAT_BGR_SUPPORTED\n#define PNG_GAMMA_SUPPORTED\n#define PNG_GET_PALETTE_MAX_SUPPORTED\n#define PNG_HANDLE_AS_UNKNOWN_SUPPORTED\n#define PNG_INCH_CONVERSIONS_SUPPORTED\n#define PNG_INFO_IMAGE_SUPPORTED\n#define PNG_IO_STATE_SUPPORTED\n#define PNG_MNG_FEATURES_SUPPORTED\n#define PNG_POINTER_INDEXING_SUPPORTED\n#define PNG_PROGRESSIVE_READ_SUPPORTED\n#define PNG_READ_16BIT_SUPPORTED\n#define PNG_READ_ALPHA_MODE_SUPPORTED\n#define PNG_READ_ANCILLARY_CHUNKS_SUPPORTED\n#define PNG_READ_BACKGROUND_SUPPORTED\n#define PNG_READ_BGR_SUPPORTED\n#define PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED\n#define PNG_READ_COMPOSITE_NODIV_SUPPORTED\n#define PNG_READ_COMPRESSED_TEXT_SUPPORTED\n#define PNG_READ_EXPAND_16_SUPPORTED\n#define PNG_READ_EXPAND_SUPPORTED\n#define PNG_READ_FILLER_SUPPORTED\n#define PNG_READ_GAMMA_SUPPORTED\n#define PNG_READ_GET_PALETTE_MAX_SUPPORTED\n#define PNG_READ_GRAY_TO_RGB_SUPPORTED\n#define PNG_READ_INTERLACING_SUPPORTED\n#define PNG_READ_INT_FUNCTIONS_SUPPORTED\n#define PNG_READ_INVERT_ALPHA_SUPPORTED\n#define PNG_READ_INVERT_SUPPORTED\n#define PNG_READ_OPT_PLTE_SUPPORTED\n#define PNG_READ_PACKSWAP_SUPPORTED\n#define PNG_READ_PACK_SUPPORTED\n#define PNG_READ_QUANTIZE_SUPPORTED\n#define PNG_READ_RGB_TO_GRAY_SUPPORTED\n#define PNG_READ_SCALE_16_TO_8_SUPPORTED\n#define PNG_READ_SHIFT_SUPPORTED\n#define PNG_READ_STRIP_16_TO_8_SUPPORTED\n#define PNG_READ_STRIP_ALPHA_SUPPORTED\n#define PNG_READ_SUPPORTED\n#define PNG_READ_SWAP_ALPHA_SUPPORTED\n#define PNG_READ_SWAP_SUPPORTED\n#define PNG_READ_TEXT_SUPPORTED\n#define PNG_READ_TRANSFORMS_SUPPORTED\n#define PNG_READ_UNKNOWN_CHUNKS_SUPPORTED\n#define PNG_READ_USER_CHUNKS_SUPPORTED\n#define PNG_READ_USER_TRANSFORM_SUPPORTED\n#define PNG_READ_bKGD_SUPPORTED\n#define PNG_READ_cHRM_SUPPORTED\n#define PNG_READ_gAMA_SUPPORTED\n#define PNG_READ_hIST_SUPPORTED\n#define PNG_READ_iCCP_SUPPORTED\n#define PNG_READ_iTXt_SUPPORTED\n#define PNG_READ_oFFs_SUPPORTED\n#define PNG_READ_pCAL_SUPPORTED\n#define PNG_READ_pHYs_SUPPORTED\n#define PNG_READ_sBIT_SUPPORTED\n#define PNG_READ_sCAL_SUPPORTED\n#define PNG_READ_sPLT_SUPPORTED\n#define PNG_READ_sRGB_SUPPORTED\n#define PNG_READ_tEXt_SUPPORTED\n#define PNG_READ_tIME_SUPPORTED\n#define PNG_READ_tRNS_SUPPORTED\n#define PNG_READ_zTXt_SUPPORTED\n/*#undef PNG_SAFE_LIMITS_SUPPORTED*/\n#define PNG_SAVE_INT_32_SUPPORTED\n#define PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED\n#define PNG_SEQUENTIAL_READ_SUPPORTED\n#define PNG_SETJMP_SUPPORTED\n#define PNG_SET_CHUNK_CACHE_LIMIT_SUPPORTED\n#define PNG_SET_CHUNK_MALLOC_LIMIT_SUPPORTED\n#define PNG_SET_OPTION_SUPPORTED\n#define PNG_SET_UNKNOWN_CHUNKS_SUPPORTED\n#define PNG_SET_USER_LIMITS_SUPPORTED\n#define PNG_SIMPLIFIED_READ_AFIRST_SUPPORTED\n#define PNG_SIMPLIFIED_READ_BGR_SUPPORTED\n#define PNG_SIMPLIFIED_READ_SUPPORTED\n#define PNG_SIMPLIFIED_WRITE_AFIRST_SUPPORTED\n#define PNG_SIMPLIFIED_WRITE_BGR_SUPPORTED\n#define PNG_SIMPLIFIED_WRITE_SUPPORTED\n#define PNG_STDIO_SUPPORTED\n#define PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED\n#define PNG_TEXT_SUPPORTED\n#define PNG_TIME_RFC1123_SUPPORTED\n#define PNG_UNKNOWN_CHUNKS_SUPPORTED\n#define PNG_USER_CHUNKS_SUPPORTED\n#define PNG_USER_LIMITS_SUPPORTED\n#define PNG_USER_MEM_SUPPORTED\n#define PNG_USER_TRANSFORM_INFO_SUPPORTED\n#define PNG_USER_TRANSFORM_PTR_SUPPORTED\n#define PNG_WARNINGS_SUPPORTED\n#define PNG_WRITE_16BIT_SUPPORTED\n#define PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED\n#define PNG_WRITE_BGR_SUPPORTED\n#define PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED\n#define PNG_WRITE_COMPRESSED_TEXT_SUPPORTED\n#define PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED\n#define PNG_WRITE_FILLER_SUPPORTED\n#define PNG_WRITE_FILTER_SUPPORTED\n#define PNG_WRITE_FLUSH_SUPPORTED\n#define PNG_WRITE_GET_PALETTE_MAX_SUPPORTED\n#define PNG_WRITE_INTERLACING_SUPPORTED\n#define PNG_WRITE_INT_FUNCTIONS_SUPPORTED\n#define PNG_WRITE_INVERT_ALPHA_SUPPORTED\n#define PNG_WRITE_INVERT_SUPPORTED\n#define PNG_WRITE_OPTIMIZE_CMF_SUPPORTED\n#define PNG_WRITE_PACKSWAP_SUPPORTED\n#define PNG_WRITE_PACK_SUPPORTED\n#define PNG_WRITE_SHIFT_SUPPORTED\n#define PNG_WRITE_SUPPORTED\n#define PNG_WRITE_SWAP_ALPHA_SUPPORTED\n#define PNG_WRITE_SWAP_SUPPORTED\n#define PNG_WRITE_TEXT_SUPPORTED\n#define PNG_WRITE_TRANSFORMS_SUPPORTED\n#define PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED\n#define PNG_WRITE_USER_TRANSFORM_SUPPORTED\n#define PNG_WRITE_WEIGHTED_FILTER_SUPPORTED\n#define PNG_WRITE_bKGD_SUPPORTED\n#define PNG_WRITE_cHRM_SUPPORTED\n#define PNG_WRITE_gAMA_SUPPORTED\n#define PNG_WRITE_hIST_SUPPORTED\n#define PNG_WRITE_iCCP_SUPPORTED\n#define PNG_WRITE_iTXt_SUPPORTED\n#define PNG_WRITE_oFFs_SUPPORTED\n#define PNG_WRITE_pCAL_SUPPORTED\n#define PNG_WRITE_pHYs_SUPPORTED\n#define PNG_WRITE_sBIT_SUPPORTED\n#define PNG_WRITE_sCAL_SUPPORTED\n#define PNG_WRITE_sPLT_SUPPORTED\n#define PNG_WRITE_sRGB_SUPPORTED\n#define PNG_WRITE_tEXt_SUPPORTED\n#define PNG_WRITE_tIME_SUPPORTED\n#define PNG_WRITE_tRNS_SUPPORTED\n#define PNG_WRITE_zTXt_SUPPORTED\n#define PNG_bKGD_SUPPORTED\n#define PNG_cHRM_SUPPORTED\n#define PNG_gAMA_SUPPORTED\n#define PNG_hIST_SUPPORTED\n#define PNG_iCCP_SUPPORTED\n#define PNG_iTXt_SUPPORTED\n#define PNG_oFFs_SUPPORTED\n#define PNG_pCAL_SUPPORTED\n#define PNG_pHYs_SUPPORTED\n#define PNG_sBIT_SUPPORTED\n#define PNG_sCAL_SUPPORTED\n#define PNG_sPLT_SUPPORTED\n#define PNG_sRGB_SUPPORTED\n#define PNG_tEXt_SUPPORTED\n#define PNG_tIME_SUPPORTED\n#define PNG_tRNS_SUPPORTED\n#define PNG_zTXt_SUPPORTED\n/* end of options */\n/* settings */\n#define PNG_API_RULE 0\n#define PNG_CALLOC_SUPPORTED\n#define PNG_COST_SHIFT 3\n#define PNG_DEFAULT_READ_MACROS 1\n#define PNG_GAMMA_THRESHOLD_FIXED 5000\n#define PNG_IDAT_READ_SIZE PNG_ZBUF_SIZE\n#define PNG_INFLATE_BUF_SIZE 1024\n#define PNG_MAX_GAMMA_8 11\n#define PNG_QUANTIZE_BLUE_BITS 5\n#define PNG_QUANTIZE_GREEN_BITS 5\n#define PNG_QUANTIZE_RED_BITS 5\n#define PNG_TEXT_Z_DEFAULT_COMPRESSION (-1)\n#define PNG_TEXT_Z_DEFAULT_STRATEGY 0\n#define PNG_WEIGHT_SHIFT 8\n#define PNG_ZBUF_SIZE 8192\n#define PNG_ZLIB_VERNUM 0 /* unknown */\n#define PNG_Z_DEFAULT_COMPRESSION (-1)\n#define PNG_Z_DEFAULT_NOFILTER_STRATEGY 0\n#define PNG_Z_DEFAULT_STRATEGY 1\n#define PNG_sCAL_PRECISION 5\n#define PNG_sRGB_PROFILE_CHECKS 2\n/* end of settings */\n#endif /* PNGLCONF_H */\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/png/pngpriv.h",
    "content": "\n/* pngpriv.h - private declarations for use inside libpng\n *\n * For conditions of distribution and use, see copyright notice in png.h\n * Copyright (c) 1998-2014 Glenn Randers-Pehrson\n * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)\n * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)\n *\n * Last changed in libpng 1.6.10 [March 6, 2014]\n *\n * This code is released under the libpng license.\n * For conditions of distribution and use, see the disclaimer\n * and license in png.h\n */\n\n/* The symbols declared in this file (including the functions declared\n * as extern) are PRIVATE.  They are not part of the libpng public\n * interface, and are not recommended for use by regular applications.\n * Some of them may become public in the future; others may stay private,\n * change in an incompatible way, or even disappear.\n * Although the libpng users are not forbidden to include this header,\n * they should be well aware of the issues that may arise from doing so.\n */\n\n#ifndef PNGPRIV_H\n#define PNGPRIV_H\n\n/* Feature Test Macros.  The following are defined here to ensure that correctly\n * implemented libraries reveal the APIs libpng needs to build and hide those\n * that are not needed and potentially damaging to the compilation.\n *\n * Feature Test Macros must be defined before any system header is included (see\n * POSIX 1003.1 2.8.2 \"POSIX Symbols.\"\n *\n * These macros only have an effect if the operating system supports either\n * POSIX 1003.1 or C99, or both.  On other operating systems (particularly\n * Windows/Visual Studio) there is no effect; the OS specific tests below are\n * still required (as of 2011-05-02.)\n */\n#define _POSIX_SOURCE 1 /* Just the POSIX 1003.1 and C89 APIs */\n\n#ifndef PNG_VERSION_INFO_ONLY\n/* Standard library headers not required by png.h: */\n#  include <stdlib.h>\n#  include <string.h>\n#endif\n\n#define PNGLIB_BUILD /*libpng is being built, not used*/\n\n/* If HAVE_CONFIG_H is defined during the build then the build system must\n * provide an appropriate \"config.h\" file on the include path.  The header file\n * must provide definitions as required below (search for \"HAVE_CONFIG_H\");\n * see configure.ac for more details of the requirements.  The macro\n * \"PNG_NO_CONFIG_H\" is provided for maintainers to test for dependencies on\n * 'configure'; define this macro to prevent the configure build including the\n * configure generated config.h.  Libpng is expected to compile without *any*\n * special build system support on a reasonably ANSI-C compliant system.\n */\n#if defined(HAVE_CONFIG_H) && !defined(PNG_NO_CONFIG_H)\n#  include <config.h>\n\n   /* Pick up the definition of 'restrict' from config.h if it was read: */\n#  define PNG_RESTRICT restrict\n#endif\n\n/* To support symbol prefixing it is necessary to know *before* including png.h\n * whether the fixed point (and maybe other) APIs are exported, because if they\n * are not internal definitions may be required.  This is handled below just\n * before png.h is included, but load the configuration now if it is available.\n */\n#ifndef PNGLCONF_H\n#  include \"pnglibconf.h\"\n#endif\n\n/* Local renames may change non-exported API functions from png.h */\n#if defined(PNG_PREFIX) && !defined(PNGPREFIX_H)\n#  include \"pngprefix.h\"\n#endif\n\n#ifdef PNG_USER_CONFIG\n#  include \"pngusr.h\"\n   /* These should have been defined in pngusr.h */\n#  ifndef PNG_USER_PRIVATEBUILD\n#    define PNG_USER_PRIVATEBUILD \"Custom libpng build\"\n#  endif\n#  ifndef PNG_USER_DLLFNAME_POSTFIX\n#    define PNG_USER_DLLFNAME_POSTFIX \"Cb\"\n#  endif\n#endif\n\n/* Compile time options.\n * =====================\n * In a multi-arch build the compiler may compile the code several times for the\n * same object module, producing different binaries for different architectures.\n * When this happens configure-time setting of the target host options cannot be\n * done and this interferes with the handling of the ARM NEON optimizations, and\n * possibly other similar optimizations.  Put additional tests here; in general\n * this is needed when the same option can be changed at both compile time and\n * run time depending on the target OS (i.e. iOS vs Android.)\n *\n * NOTE: symbol prefixing does not pass $(CFLAGS) to the preprocessor, because\n * this is not possible with certain compilers (Oracle SUN OS CC), as a result\n * it is necessary to ensure that all extern functions that *might* be used\n * regardless of $(CFLAGS) get declared in this file.  The test on __ARM_NEON__\n * below is one example of this behavior because it is controlled by the\n * presence or not of -mfpu=neon on the GCC command line, it is possible to do\n * this in $(CC), e.g. \"CC=gcc -mfpu=neon\", but people who build libpng rarely\n * do this.\n */\n#ifndef PNG_ARM_NEON_OPT\n   /* ARM NEON optimizations are being controlled by the compiler settings,\n    * typically the target FPU.  If the FPU has been set to NEON (-mfpu=neon\n    * with GCC) then the compiler will define __ARM_NEON__ and we can rely\n    * unconditionally on NEON instructions not crashing, otherwise we must\n    * disable use of NEON instructions.\n    *\n    * NOTE: at present these optimizations depend on 'ALIGNED_MEMORY', so they\n    * can only be turned on automatically if that is supported too.  If\n    * PNG_ARM_NEON_OPT is set in CPPFLAGS (to >0) then arm/arm_init.c will fail\n    * to compile with an appropriate #error if ALIGNED_MEMORY has been turned\n    * off.\n    */\n#  if defined(__ARM_NEON__) && defined(PNG_ALIGNED_MEMORY_SUPPORTED)\n#     define PNG_ARM_NEON_OPT 2\n#  else\n#     define PNG_ARM_NEON_OPT 0\n#  endif\n#endif\n\n#if PNG_ARM_NEON_OPT > 0\n   /* NEON optimizations are to be at least considered by libpng, so enable the\n    * callbacks to do this.\n    */\n#  define PNG_FILTER_OPTIMIZATIONS png_init_filter_functions_neon\n\n   /* By default the 'intrinsics' code in arm/filter_neon_intrinsics.c is used\n    * if possible - if __ARM_NEON__ is set and the compiler version is not known\n    * to be broken.  This is controlled by PNG_ARM_NEON_IMPLEMENTATION which can\n    * be:\n    *\n    *    1  The intrinsics code (the default with __ARM_NEON__)\n    *    2  The hand coded assembler (the default without __ARM_NEON__)\n    *\n    * It is possible to set PNG_ARM_NEON_IMPLEMENTATION in CPPFLAGS, however\n    * this is *NOT* supported and may cease to work even after a minor revision\n    * to libpng.  It *is* valid to do this for testing purposes, e.g. speed\n    * testing or a new compiler, but the results should be communicated to the\n    * libpng implementation list for incorporation in the next minor release.\n    */\n#  ifndef PNG_ARM_NEON_IMPLEMENTATION\n#     ifdef __ARM_NEON__\n#        if defined(__clang__)\n            /* At present it is unknown by the libpng developers which versions\n             * of clang support the intrinsics, however some or perhaps all\n             * versions do not work with the assembler so this may be\n             * irrelevant, so just use the default (do nothing here.)\n             */\n#        elif defined(__GNUC__)\n            /* GCC 4.5.4 NEON support is known to be broken.  4.6.3 is known to\n             * work, so if this *is* GCC, or G++, look for a version >4.5\n             */\n#           if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 6)\n#              define PNG_ARM_NEON_IMPLEMENTATION 2\n#           endif /* no GNUC support */\n#        endif /* __GNUC__ */\n#     else /* !defined __ARM_NEON__ */\n         /* The 'intrinsics' code simply won't compile without this -mfpu=neon:\n          */\n#        define PNG_ARM_NEON_IMPLEMENTATION 2\n#     endif /* __ARM_NEON__ */\n#  endif /* !defined PNG_ARM_NEON_IMPLEMENTATION */\n\n#  ifndef PNG_ARM_NEON_IMPLEMENTATION\n      /* Use the intrinsics code by default. */\n#     define PNG_ARM_NEON_IMPLEMENTATION 1\n#  endif\n#endif /* PNG_ARM_NEON_OPT > 0 */\n\n/* Is this a build of a DLL where compilation of the object modules requires\n * different preprocessor settings to those required for a simple library?  If\n * so PNG_BUILD_DLL must be set.\n *\n * If libpng is used inside a DLL but that DLL does not export the libpng APIs\n * PNG_BUILD_DLL must not be set.  To avoid the code below kicking in build a\n * static library of libpng then link the DLL against that.\n */\n#ifndef PNG_BUILD_DLL\n#  ifdef DLL_EXPORT\n      /* This is set by libtool when files are compiled for a DLL; libtool\n       * always compiles twice, even on systems where it isn't necessary.  Set\n       * PNG_BUILD_DLL in case it is necessary:\n       */\n#     define PNG_BUILD_DLL\n#  else\n#     ifdef _WINDLL\n         /* This is set by the Microsoft Visual Studio IDE in projects that\n          * build a DLL.  It can't easily be removed from those projects (it\n          * isn't visible in the Visual Studio UI) so it is a fairly reliable\n          * indication that PNG_IMPEXP needs to be set to the DLL export\n          * attributes.\n          */\n#        define PNG_BUILD_DLL\n#     else\n#        ifdef __DLL__\n            /* This is set by the Borland C system when compiling for a DLL\n             * (as above.)\n             */\n#           define PNG_BUILD_DLL\n#        else\n            /* Add additional compiler cases here. */\n#        endif\n#     endif\n#  endif\n#endif /* Setting PNG_BUILD_DLL if required */\n\n/* See pngconf.h for more details: the builder of the library may set this on\n * the command line to the right thing for the specific compilation system or it\n * may be automagically set above (at present we know of no system where it does\n * need to be set on the command line.)\n *\n * PNG_IMPEXP must be set here when building the library to prevent pngconf.h\n * setting it to the \"import\" setting for a DLL build.\n */\n#ifndef PNG_IMPEXP\n#  ifdef PNG_BUILD_DLL\n#     define PNG_IMPEXP PNG_DLL_EXPORT\n#  else\n      /* Not building a DLL, or the DLL doesn't require specific export\n       * definitions.\n       */\n#     define PNG_IMPEXP\n#  endif\n#endif\n\n/* No warnings for private or deprecated functions in the build: */\n#ifndef PNG_DEPRECATED\n#  define PNG_DEPRECATED\n#endif\n#ifndef PNG_PRIVATE\n#  define PNG_PRIVATE\n#endif\n\n/* Symbol preprocessing support.\n *\n * To enable listing global, but internal, symbols the following macros should\n * always be used to declare an extern data or function object in this file.\n */\n#ifndef PNG_INTERNAL_DATA\n#  define PNG_INTERNAL_DATA(type, name, array) extern type name array\n#endif\n\n#ifndef PNG_INTERNAL_FUNCTION\n#  define PNG_INTERNAL_FUNCTION(type, name, args, attributes)\\\n      extern PNG_FUNCTION(type, name, args, PNG_EMPTY attributes)\n#endif\n\n#ifndef PNG_INTERNAL_CALLBACK\n#  define PNG_INTERNAL_CALLBACK(type, name, args, attributes)\\\n      extern PNG_FUNCTION(type, (PNGCBAPI name), args, PNG_EMPTY attributes)\n#endif\n\n/* If floating or fixed point APIs are disabled they may still be compiled\n * internally.  To handle this make sure they are declared as the appropriate\n * internal extern function (otherwise the symbol prefixing stuff won't work and\n * the functions will be used without definitions.)\n *\n * NOTE: although all the API functions are declared here they are not all\n * actually built!  Because the declarations are still made it is necessary to\n * fake out types that they depend on.\n */\n#ifndef PNG_FP_EXPORT\n#  ifndef PNG_FLOATING_POINT_SUPPORTED\n#     define PNG_FP_EXPORT(ordinal, type, name, args)\\\n         PNG_INTERNAL_FUNCTION(type, name, args, PNG_EMPTY);\n#     ifndef PNG_VERSION_INFO_ONLY\n         typedef struct png_incomplete png_double;\n         typedef png_double*           png_doublep;\n         typedef const png_double*     png_const_doublep;\n         typedef png_double**          png_doublepp;\n#     endif\n#  endif\n#endif\n#ifndef PNG_FIXED_EXPORT\n#  ifndef PNG_FIXED_POINT_SUPPORTED\n#     define PNG_FIXED_EXPORT(ordinal, type, name, args)\\\n         PNG_INTERNAL_FUNCTION(type, name, args, PNG_EMPTY);\n#  endif\n#endif\n\n#include \"png.h\"\n\n/* pngconf.h does not set PNG_DLL_EXPORT unless it is required, so: */\n#ifndef PNG_DLL_EXPORT\n#  define PNG_DLL_EXPORT\n#endif\n\n/* SECURITY and SAFETY:\n *\n * By default libpng is built without any internal limits on image size,\n * individual heap (png_malloc) allocations or the total amount of memory used.\n * If PNG_SAFE_LIMITS_SUPPORTED is defined, however, the limits below are used\n * (unless individually overridden).  These limits are believed to be fairly\n * safe, but builders of secure systems should verify the values against the\n * real system capabilities.\n */\n#ifdef PNG_SAFE_LIMITS_SUPPORTED\n   /* 'safe' limits */\n#  ifndef PNG_USER_WIDTH_MAX\n#     define PNG_USER_WIDTH_MAX 1000000\n#  endif\n#  ifndef PNG_USER_HEIGHT_MAX\n#     define PNG_USER_HEIGHT_MAX 1000000\n#  endif\n#  ifndef PNG_USER_CHUNK_CACHE_MAX\n#     define PNG_USER_CHUNK_CACHE_MAX 128\n#  endif\n#  ifndef PNG_USER_CHUNK_MALLOC_MAX\n#     define PNG_USER_CHUNK_MALLOC_MAX 8000000\n#  endif\n#else\n   /* values for no limits */\n#  ifndef PNG_USER_WIDTH_MAX\n#     define PNG_USER_WIDTH_MAX 0x7fffffff\n#  endif\n#  ifndef PNG_USER_HEIGHT_MAX\n#     define PNG_USER_HEIGHT_MAX 0x7fffffff\n#  endif\n#  ifndef PNG_USER_CHUNK_CACHE_MAX\n#     define PNG_USER_CHUNK_CACHE_MAX 0\n#  endif\n#  ifndef PNG_USER_CHUNK_MALLOC_MAX\n#     define PNG_USER_CHUNK_MALLOC_MAX 0\n#  endif\n#endif\n\n/* Moved to pngpriv.h at libpng-1.5.0 */\n/* NOTE: some of these may have been used in external applications as\n * these definitions were exposed in pngconf.h prior to 1.5.\n */\n\n/* If you are running on a machine where you cannot allocate more\n * than 64K of memory at once, uncomment this.  While libpng will not\n * normally need that much memory in a chunk (unless you load up a very\n * large file), zlib needs to know how big of a chunk it can use, and\n * libpng thus makes sure to check any memory allocation to verify it\n * will fit into memory.\n *\n * zlib provides 'MAXSEG_64K' which, if defined, indicates the\n * same limit and pngconf.h (already included) sets the limit\n * if certain operating systems are detected.\n */\n#if defined(MAXSEG_64K) && !defined(PNG_MAX_MALLOC_64K)\n#  define PNG_MAX_MALLOC_64K\n#endif\n\n#ifndef PNG_UNUSED\n/* Unused formal parameter warnings are silenced using the following macro\n * which is expected to have no bad effects on performance (optimizing\n * compilers will probably remove it entirely).  Note that if you replace\n * it with something other than whitespace, you must include the terminating\n * semicolon.\n */\n#  define PNG_UNUSED(param) (void)param;\n#endif\n\n/* Just a little check that someone hasn't tried to define something\n * contradictory.\n */\n#if (PNG_ZBUF_SIZE > 65536L) && defined(PNG_MAX_MALLOC_64K)\n#  undef PNG_ZBUF_SIZE\n#  define PNG_ZBUF_SIZE 65536L\n#endif\n\n/* If warnings or errors are turned off the code is disabled or redirected here.\n * From 1.5.4 functions have been added to allow very limited formatting of\n * error and warning messages - this code will also be disabled here.\n */\n#ifdef PNG_WARNINGS_SUPPORTED\n#  define PNG_WARNING_PARAMETERS(p) png_warning_parameters p;\n#else\n#  define png_warning_parameter(p,number,string) ((void)0)\n#  define png_warning_parameter_unsigned(p,number,format,value) ((void)0)\n#  define png_warning_parameter_signed(p,number,format,value) ((void)0)\n#  define png_formatted_warning(pp,p,message) ((void)(pp))\n#  define PNG_WARNING_PARAMETERS(p)\n#endif\n#ifndef PNG_ERROR_TEXT_SUPPORTED\n#  define png_fixed_error(s1,s2) png_err(s1)\n#endif\n\n/* C allows up-casts from (void*) to any pointer and (const void*) to any\n * pointer to a const object.  C++ regards this as a type error and requires an\n * explicit, static, cast and provides the static_cast<> rune to ensure that\n * const is not cast away.\n */\n#ifdef __cplusplus\n#  define png_voidcast(type, value) static_cast<type>(value)\n#  define png_constcast(type, value) const_cast<type>(value)\n#  define png_aligncast(type, value) \\\n   static_cast<type>(static_cast<void*>(value))\n#  define png_aligncastconst(type, value) \\\n   static_cast<type>(static_cast<const void*>(value))\n#else\n#  define png_voidcast(type, value) (value)\n#  define png_constcast(type, value) ((type)(value))\n#  define png_aligncast(type, value) ((void*)(value))\n#  define png_aligncastconst(type, value) ((const void*)(value))\n#endif /* __cplusplus */\n\n/* Some fixed point APIs are still required even if not exported because\n * they get used by the corresponding floating point APIs.  This magic\n * deals with this:\n */\n#ifdef PNG_FIXED_POINT_SUPPORTED\n#  define PNGFAPI PNGAPI\n#else\n#  define PNGFAPI /* PRIVATE */\n#endif\n\n#ifndef PNG_VERSION_INFO_ONLY\n/* Other defines specific to compilers can go here.  Try to keep\n * them inside an appropriate ifdef/endif pair for portability.\n */\n#if defined(PNG_FLOATING_POINT_SUPPORTED) ||\\\n    defined(PNG_FLOATING_ARITHMETIC_SUPPORTED)\n   /* png.c requires the following ANSI-C constants if the conversion of\n    * floating point to ASCII is implemented therein:\n    *\n    *  DBL_DIG  Maximum number of decimal digits (can be set to any constant)\n    *  DBL_MIN  Smallest normalized fp number (can be set to an arbitrary value)\n    *  DBL_MAX  Maximum floating point number (can be set to an arbitrary value)\n    */\n#  include <float.h>\n\n#  if (defined(__MWERKS__) && defined(macintosh)) || defined(applec) || \\\n    defined(THINK_C) || defined(__SC__) || defined(TARGET_OS_MAC)\n     /* We need to check that <math.h> hasn't already been included earlier\n      * as it seems it doesn't agree with <fp.h>, yet we should really use\n      * <fp.h> if possible.\n      */\n#    if !defined(__MATH_H__) && !defined(__MATH_H) && !defined(__cmath__)\n#      include <fp.h>\n#    endif\n#  else\n#    include <math.h>\n#  endif\n#  if defined(_AMIGA) && defined(__SASC) && defined(_M68881)\n     /* Amiga SAS/C: We must include builtin FPU functions when compiling using\n      * MATH=68881\n      */\n#    include <m68881.h>\n#  endif\n#endif\n\n/* This provides the non-ANSI (far) memory allocation routines. */\n#if defined(__TURBOC__) && defined(__MSDOS__)\n#  include <mem.h>\n#  include <alloc.h>\n#endif\n\n#if defined(WIN32) || defined(_Windows) || defined(_WINDOWS) || \\\n    defined(_WIN32) || defined(__WIN32__)\n#  include <windows.h>  /* defines _WINDOWS_ macro */\n#endif\n#endif /* PNG_VERSION_INFO_ONLY */\n\n/* Moved here around 1.5.0beta36 from pngconf.h */\n/* Users may want to use these so they are not private.  Any library\n * functions that are passed far data must be model-independent.\n */\n\n/* Memory model/platform independent fns */\n#ifndef PNG_ABORT\n#  ifdef _WINDOWS_\n#    define PNG_ABORT() ExitProcess(0)\n#  else\n#    define PNG_ABORT() abort()\n#  endif\n#endif\n\n/* These macros may need to be architecture dependent. */\n#define PNG_ALIGN_NONE   0 /* do not use data alignment */\n#define PNG_ALIGN_ALWAYS 1 /* assume unaligned accesses are OK */\n#ifdef offsetof\n#  define PNG_ALIGN_OFFSET 2 /* use offsetof to determine alignment */\n#else\n#  define PNG_ALIGN_OFFSET -1 /* prevent the use of this */\n#endif\n#define PNG_ALIGN_SIZE   3 /* use sizeof to determine alignment */\n\n#ifndef PNG_ALIGN_TYPE\n   /* Default to using aligned access optimizations and requiring alignment to a\n    * multiple of the data type size.  Override in a compiler specific fashion\n    * if necessary by inserting tests here:\n    */\n#  define PNG_ALIGN_TYPE PNG_ALIGN_SIZE\n#endif\n\n#if PNG_ALIGN_TYPE == PNG_ALIGN_SIZE\n   /* This is used because in some compiler implementations non-aligned\n    * structure members are supported, so the offsetof approach below fails.\n    * Set PNG_ALIGN_SIZE=0 for compiler combinations where unaligned access\n    * is good for performance.  Do not do this unless you have tested the result\n    * and understand it.\n    */\n#  define png_alignof(type) (sizeof (type))\n#else\n#  if PNG_ALIGN_TYPE == PNG_ALIGN_OFFSET\n#     define png_alignof(type) offsetof(struct{char c; type t;}, t)\n#  else\n#     if PNG_ALIGN_TYPE == PNG_ALIGN_ALWAYS\n#        define png_alignof(type) (1)\n#     endif\n      /* Else leave png_alignof undefined to prevent use thereof */\n#  endif\n#endif\n\n/* This implicitly assumes alignment is always to a power of 2. */\n#ifdef png_alignof\n#  define png_isaligned(ptr, type)\\\n   ((((const char*)ptr-(const char*)0) & (png_alignof(type)-1)) == 0)\n#else\n#  define png_isaligned(ptr, type) 0\n#endif\n\n/* End of memory model/platform independent support */\n/* End of 1.5.0beta36 move from pngconf.h */\n\n/* CONSTANTS and UTILITY MACROS\n * These are used internally by libpng and not exposed in the API\n */\n\n/* Various modes of operation.  Note that after an init, mode is set to\n * zero automatically when the structure is created.  Three of these\n * are defined in png.h because they need to be visible to applications\n * that call png_set_unknown_chunk().\n */\n/* #define PNG_HAVE_IHDR            0x01 (defined in png.h) */\n/* #define PNG_HAVE_PLTE            0x02 (defined in png.h) */\n#define PNG_HAVE_IDAT               0x04\n/* #define PNG_AFTER_IDAT           0x08 (defined in png.h) */\n#define PNG_HAVE_IEND               0x10\n                   /*               0x20 (unused) */\n                   /*               0x40 (unused) */\n                   /*               0x80 (unused) */\n#define PNG_HAVE_CHUNK_HEADER      0x100\n#define PNG_WROTE_tIME             0x200\n#define PNG_WROTE_INFO_BEFORE_PLTE 0x400\n#define PNG_BACKGROUND_IS_GRAY     0x800\n#define PNG_HAVE_PNG_SIGNATURE    0x1000\n#define PNG_HAVE_CHUNK_AFTER_IDAT 0x2000 /* Have another chunk after IDAT */\n                   /*             0x4000 (unused) */\n#define PNG_IS_READ_STRUCT        0x8000 /* Else is a write struct */\n\n/* Flags for the transformations the PNG library does on the image data */\n#define PNG_BGR                 0x0001\n#define PNG_INTERLACE           0x0002\n#define PNG_PACK                0x0004\n#define PNG_SHIFT               0x0008\n#define PNG_SWAP_BYTES          0x0010\n#define PNG_INVERT_MONO         0x0020\n#define PNG_QUANTIZE            0x0040\n#define PNG_COMPOSE             0x0080     /* Was PNG_BACKGROUND */\n#define PNG_BACKGROUND_EXPAND   0x0100\n#define PNG_EXPAND_16           0x0200     /* Added to libpng 1.5.2 */\n#define PNG_16_TO_8             0x0400     /* Becomes 'chop' in 1.5.4 */\n#define PNG_RGBA                0x0800\n#define PNG_EXPAND              0x1000\n#define PNG_GAMMA               0x2000\n#define PNG_GRAY_TO_RGB         0x4000\n#define PNG_FILLER              0x8000\n#define PNG_PACKSWAP           0x10000\n#define PNG_SWAP_ALPHA         0x20000\n#define PNG_STRIP_ALPHA        0x40000\n#define PNG_INVERT_ALPHA       0x80000\n#define PNG_USER_TRANSFORM    0x100000\n#define PNG_RGB_TO_GRAY_ERR   0x200000\n#define PNG_RGB_TO_GRAY_WARN  0x400000\n#define PNG_RGB_TO_GRAY       0x600000 /* two bits, RGB_TO_GRAY_ERR|WARN */\n#define PNG_ENCODE_ALPHA      0x800000 /* Added to libpng-1.5.4 */\n#define PNG_ADD_ALPHA         0x1000000 /* Added to libpng-1.2.7 */\n#define PNG_EXPAND_tRNS       0x2000000 /* Added to libpng-1.2.9 */\n#define PNG_SCALE_16_TO_8     0x4000000 /* Added to libpng-1.5.4 */\n                       /*   0x8000000 unused */\n                       /*  0x10000000 unused */\n                       /*  0x20000000 unused */\n                       /*  0x40000000 unused */\n/* Flags for png_create_struct */\n#define PNG_STRUCT_PNG   0x0001\n#define PNG_STRUCT_INFO  0x0002\n\n/* Scaling factor for filter heuristic weighting calculations */\n#define PNG_WEIGHT_FACTOR (1<<(PNG_WEIGHT_SHIFT))\n#define PNG_COST_FACTOR (1<<(PNG_COST_SHIFT))\n\n/* Flags for the png_ptr->flags rather than declaring a byte for each one */\n#define PNG_FLAG_ZLIB_CUSTOM_STRATEGY     0x0001\n#define PNG_FLAG_ZSTREAM_INITIALIZED      0x0002 /* Added to libpng-1.6.0 */\n                                  /*      0x0004    unused */\n#define PNG_FLAG_ZSTREAM_ENDED            0x0008 /* Added to libpng-1.6.0 */\n                                  /*      0x0010    unused */\n                                  /*      0x0020    unused */\n#define PNG_FLAG_ROW_INIT                 0x0040\n#define PNG_FLAG_FILLER_AFTER             0x0080\n#define PNG_FLAG_CRC_ANCILLARY_USE        0x0100\n#define PNG_FLAG_CRC_ANCILLARY_NOWARN     0x0200\n#define PNG_FLAG_CRC_CRITICAL_USE         0x0400\n#define PNG_FLAG_CRC_CRITICAL_IGNORE      0x0800\n#define PNG_FLAG_ASSUME_sRGB              0x1000 /* Added to libpng-1.5.4 */\n#define PNG_FLAG_OPTIMIZE_ALPHA           0x2000 /* Added to libpng-1.5.4 */\n#define PNG_FLAG_DETECT_UNINITIALIZED     0x4000 /* Added to libpng-1.5.4 */\n/* #define PNG_FLAG_KEEP_UNKNOWN_CHUNKS      0x8000 */\n/* #define PNG_FLAG_KEEP_UNSAFE_CHUNKS      0x10000 */\n#define PNG_FLAG_LIBRARY_MISMATCH        0x20000\n#define PNG_FLAG_STRIP_ERROR_NUMBERS     0x40000\n#define PNG_FLAG_STRIP_ERROR_TEXT        0x80000\n#define PNG_FLAG_BENIGN_ERRORS_WARN     0x100000 /* Added to libpng-1.4.0 */\n#define PNG_FLAG_APP_WARNINGS_WARN      0x200000 /* Added to libpng-1.6.0 */\n#define PNG_FLAG_APP_ERRORS_WARN        0x400000 /* Added to libpng-1.6.0 */\n                                  /*    0x800000    unused */\n                                  /*   0x1000000    unused */\n                                  /*   0x2000000    unused */\n                                  /*   0x4000000    unused */\n                                  /*   0x8000000    unused */\n                                  /*  0x10000000    unused */\n                                  /*  0x20000000    unused */\n                                  /*  0x40000000    unused */\n\n#define PNG_FLAG_CRC_ANCILLARY_MASK (PNG_FLAG_CRC_ANCILLARY_USE | \\\n                                     PNG_FLAG_CRC_ANCILLARY_NOWARN)\n\n#define PNG_FLAG_CRC_CRITICAL_MASK  (PNG_FLAG_CRC_CRITICAL_USE | \\\n                                     PNG_FLAG_CRC_CRITICAL_IGNORE)\n\n#define PNG_FLAG_CRC_MASK           (PNG_FLAG_CRC_ANCILLARY_MASK | \\\n                                     PNG_FLAG_CRC_CRITICAL_MASK)\n\n/* Save typing and make code easier to understand */\n\n#define PNG_COLOR_DIST(c1, c2) (abs((int)((c1).red) - (int)((c2).red)) + \\\n   abs((int)((c1).green) - (int)((c2).green)) + \\\n   abs((int)((c1).blue) - (int)((c2).blue)))\n\n/* Added to libpng-1.6.0: scale a 16-bit value in the range 0..65535 to 0..255\n * by dividing by 257 *with rounding*.  This macro is exact for the given range.\n * See the discourse in pngrtran.c png_do_scale_16_to_8.  The values in the\n * macro were established by experiment (modifying the added value).  The macro\n * has a second variant that takes a value already scaled by 255 and divides by\n * 65535 - this has a maximum error of .502.  Over the range 0..65535*65535 it\n * only gives off-by-one errors and only for 0.5% (1 in 200) of the values.\n */\n#define PNG_DIV65535(v24) (((v24) + 32895) >> 16)\n#define PNG_DIV257(v16) PNG_DIV65535((png_uint_32)(v16) * 255)\n\n/* Added to libpng-1.2.6 JB */\n#define PNG_ROWBYTES(pixel_bits, width) \\\n    ((pixel_bits) >= 8 ? \\\n    ((png_size_t)(width) * (((png_size_t)(pixel_bits)) >> 3)) : \\\n    (( ((png_size_t)(width) * ((png_size_t)(pixel_bits))) + 7) >> 3) )\n\n/* PNG_OUT_OF_RANGE returns true if value is outside the range\n * ideal-delta..ideal+delta.  Each argument is evaluated twice.\n * \"ideal\" and \"delta\" should be constants, normally simple\n * integers, \"value\" a variable. Added to libpng-1.2.6 JB\n */\n#define PNG_OUT_OF_RANGE(value, ideal, delta) \\\n   ( (value) < (ideal)-(delta) || (value) > (ideal)+(delta) )\n\n/* Conversions between fixed and floating point, only defined if\n * required (to make sure the code doesn't accidentally use float\n * when it is supposedly disabled.)\n */\n#ifdef PNG_FLOATING_POINT_SUPPORTED\n/* The floating point conversion can't overflow, though it can and\n * does lose accuracy relative to the original fixed point value.\n * In practice this doesn't matter because png_fixed_point only\n * stores numbers with very low precision.  The png_ptr and s\n * arguments are unused by default but are there in case error\n * checking becomes a requirement.\n */\n#define png_float(png_ptr, fixed, s) (.00001 * (fixed))\n\n/* The fixed point conversion performs range checking and evaluates\n * its argument multiple times, so must be used with care.  The\n * range checking uses the PNG specification values for a signed\n * 32 bit fixed point value except that the values are deliberately\n * rounded-to-zero to an integral value - 21474 (21474.83 is roughly\n * (2^31-1) * 100000). 's' is a string that describes the value being\n * converted.\n *\n * NOTE: this macro will raise a png_error if the range check fails,\n * therefore it is normally only appropriate to use this on values\n * that come from API calls or other sources where an out of range\n * error indicates a programming error, not a data error!\n *\n * NOTE: by default this is off - the macro is not used - because the\n * function call saves a lot of code.\n */\n#ifdef PNG_FIXED_POINT_MACRO_SUPPORTED\n#define png_fixed(png_ptr, fp, s) ((fp) <= 21474 && (fp) >= -21474 ?\\\n    ((png_fixed_point)(100000 * (fp))) : (png_fixed_error(png_ptr, s),0))\n#endif\n/* else the corresponding function is defined below, inside the scope of the\n * cplusplus test.\n */\n#endif\n\n/* Constants for known chunk types.  If you need to add a chunk, define the name\n * here.  For historical reasons these constants have the form png_<name>; i.e.\n * the prefix is lower case.  Please use decimal values as the parameters to\n * match the ISO PNG specification and to avoid relying on the C locale\n * interpretation of character values.\n *\n * Prior to 1.5.6 these constants were strings, as of 1.5.6 png_uint_32 values\n * are computed and a new macro (PNG_STRING_FROM_CHUNK) added to allow a string\n * to be generated if required.\n *\n * PNG_32b correctly produces a value shifted by up to 24 bits, even on\n * architectures where (int) is only 16 bits.\n */\n#define PNG_32b(b,s) ((png_uint_32)(b) << (s))\n#define PNG_U32(b1,b2,b3,b4) \\\n   (PNG_32b(b1,24) | PNG_32b(b2,16) | PNG_32b(b3,8) | PNG_32b(b4,0))\n\n/* Constants for known chunk types.\n *\n * MAINTAINERS: If you need to add a chunk, define the name here.\n * For historical reasons these constants have the form png_<name>; i.e.\n * the prefix is lower case.  Please use decimal values as the parameters to\n * match the ISO PNG specification and to avoid relying on the C locale\n * interpretation of character values.  Please keep the list sorted.\n *\n * Notice that PNG_U32 is used to define a 32-bit value for the 4 byte chunk\n * type.  In fact the specification does not express chunk types this way,\n * however using a 32-bit value means that the chunk type can be read from the\n * stream using exactly the same code as used for a 32-bit unsigned value and\n * can be examined far more efficiently (using one arithmetic compare).\n *\n * Prior to 1.5.6 the chunk type constants were expressed as C strings.  The\n * libpng API still uses strings for 'unknown' chunks and a macro,\n * PNG_STRING_FROM_CHUNK, allows a string to be generated if required.  Notice\n * that for portable code numeric values must still be used; the string \"IHDR\"\n * is not portable and neither is PNG_U32('I', 'H', 'D', 'R').\n *\n * In 1.7.0 the definitions will be made public in png.h to avoid having to\n * duplicate the same definitions in application code.\n */\n#define png_IDAT PNG_U32( 73,  68,  65,  84)\n#define png_IEND PNG_U32( 73,  69,  78,  68)\n#define png_IHDR PNG_U32( 73,  72,  68,  82)\n#define png_PLTE PNG_U32( 80,  76,  84,  69)\n#define png_bKGD PNG_U32( 98,  75,  71,  68)\n#define png_cHRM PNG_U32( 99,  72,  82,  77)\n#define png_fRAc PNG_U32(102,  82,  65,  99) /* registered, not defined */\n#define png_gAMA PNG_U32(103,  65,  77,  65)\n#define png_gIFg PNG_U32(103,  73,  70, 103)\n#define png_gIFt PNG_U32(103,  73,  70, 116) /* deprecated */\n#define png_gIFx PNG_U32(103,  73,  70, 120)\n#define png_hIST PNG_U32(104,  73,  83,  84)\n#define png_iCCP PNG_U32(105,  67,  67,  80)\n#define png_iTXt PNG_U32(105,  84,  88, 116)\n#define png_oFFs PNG_U32(111,  70,  70, 115)\n#define png_pCAL PNG_U32(112,  67,  65,  76)\n#define png_pHYs PNG_U32(112,  72,  89, 115)\n#define png_sBIT PNG_U32(115,  66,  73,  84)\n#define png_sCAL PNG_U32(115,  67,  65,  76)\n#define png_sPLT PNG_U32(115,  80,  76,  84)\n#define png_sRGB PNG_U32(115,  82,  71,  66)\n#define png_sTER PNG_U32(115,  84,  69,  82)\n#define png_tEXt PNG_U32(116,  69,  88, 116)\n#define png_tIME PNG_U32(116,  73,  77,  69)\n#define png_tRNS PNG_U32(116,  82,  78,  83)\n#define png_zTXt PNG_U32(122,  84,  88, 116)\n\n/* The following will work on (signed char*) strings, whereas the get_uint_32\n * macro will fail on top-bit-set values because of the sign extension.\n */\n#define PNG_CHUNK_FROM_STRING(s)\\\n   PNG_U32(0xff&(s)[0], 0xff&(s)[1], 0xff&(s)[2], 0xff&(s)[3])\n\n/* This uses (char), not (png_byte) to avoid warnings on systems where (char) is\n * signed and the argument is a (char[])  This macro will fail miserably on\n * systems where (char) is more than 8 bits.\n */\n#define PNG_STRING_FROM_CHUNK(s,c)\\\n   (void)(((char*)(s))[0]=(char)((c)>>24), ((char*)(s))[1]=(char)((c)>>16),\\\n   ((char*)(s))[2]=(char)((c)>>8), ((char*)(s))[3]=(char)((c)))\n\n/* Do the same but terminate with a null character. */\n#define PNG_CSTRING_FROM_CHUNK(s,c)\\\n   (void)(PNG_STRING_FROM_CHUNK(s,c), ((char*)(s))[4] = 0)\n\n/* Test on flag values as defined in the spec (section 5.4): */\n#define PNG_CHUNK_ANCILLARY(c)   (1 & ((c) >> 29))\n#define PNG_CHUNK_CRITICAL(c)     (!PNG_CHUNK_ANCILLARY(c))\n#define PNG_CHUNK_PRIVATE(c)      (1 & ((c) >> 21))\n#define PNG_CHUNK_RESERVED(c)     (1 & ((c) >> 13))\n#define PNG_CHUNK_SAFE_TO_COPY(c) (1 & ((c) >>  5))\n\n/* Gamma values (new at libpng-1.5.4): */\n#define PNG_GAMMA_MAC_OLD 151724  /* Assume '1.8' is really 2.2/1.45! */\n#define PNG_GAMMA_MAC_INVERSE 65909\n#define PNG_GAMMA_sRGB_INVERSE 45455\n\n/* Almost everything below is C specific; the #defines above can be used in\n * non-C code (so long as it is C-preprocessed) the rest of this stuff cannot.\n */\n#ifndef PNG_VERSION_INFO_ONLY\n\n#include \"pngstruct.h\"\n#include \"pnginfo.h\"\n\n/* Validate the include paths - the include path used to generate pnglibconf.h\n * must match that used in the build, or we must be using pnglibconf.h.prebuilt:\n */\n#if PNG_ZLIB_VERNUM != 0 && PNG_ZLIB_VERNUM != ZLIB_VERNUM\n#  error ZLIB_VERNUM != PNG_ZLIB_VERNUM \\\n      \"-I (include path) error: see the notes in pngpriv.h\"\n   /* This means that when pnglibconf.h was built the copy of zlib.h that it\n    * used is not the same as the one being used here.  Because the build of\n    * libpng makes decisions to use inflateInit2 and inflateReset2 based on the\n    * zlib version number and because this affects handling of certain broken\n    * PNG files the -I directives must match.\n    *\n    * The most likely explanation is that you passed a -I in CFLAGS, this will\n    * not work; all the preprocessor directories and in particular all the -I\n    * directives must be in CPPFLAGS.\n    */\n#endif\n\n/* This is used for 16 bit gamma tables -- only the top level pointers are\n * const; this could be changed:\n */\ntypedef const png_uint_16p * png_const_uint_16pp;\n\n/* Added to libpng-1.5.7: sRGB conversion tables */\n#if defined(PNG_SIMPLIFIED_READ_SUPPORTED) ||\\\n   defined(PNG_SIMPLIFIED_WRITE_SUPPORTED)\n#ifdef PNG_SIMPLIFIED_READ_SUPPORTED\nPNG_INTERNAL_DATA(const png_uint_16, png_sRGB_table, [256]);\n   /* Convert from an sRGB encoded value 0..255 to a 16-bit linear value,\n    * 0..65535.  This table gives the closest 16-bit answers (no errors).\n    */\n#endif\n\nPNG_INTERNAL_DATA(const png_uint_16, png_sRGB_base, [512]);\nPNG_INTERNAL_DATA(const png_byte, png_sRGB_delta, [512]);\n\n#define PNG_sRGB_FROM_LINEAR(linear) ((png_byte)((png_sRGB_base[(linear)>>15] +\\\n   ((((linear)&0x7fff)*png_sRGB_delta[(linear)>>15])>>12)) >> 8))\n   /* Given a value 'linear' in the range 0..255*65535 calculate the 8-bit sRGB\n    * encoded value with maximum error 0.646365.  Note that the input is not a\n    * 16-bit value; it has been multiplied by 255! */\n#endif /* PNG_SIMPLIFIED_READ/WRITE */\n\n\n/* Inhibit C++ name-mangling for libpng functions but not for system calls. */\n#ifdef __cplusplus\nextern \"C\" {\n#endif /* __cplusplus */\n\n/* Internal functions; these are not exported from a DLL however because they\n * are used within several of the C source files they have to be C extern.\n *\n * All of these functions must be declared with PNG_INTERNAL_FUNCTION.\n */\n\n/* Zlib support */\n#define PNG_UNEXPECTED_ZLIB_RETURN (-7)\nPNG_INTERNAL_FUNCTION(void, png_zstream_error,(png_structrp png_ptr, int ret),\n   PNG_EMPTY);\n   /* Used by the zlib handling functions to ensure that z_stream::msg is always\n    * set before they return.\n    */\n\n#ifdef PNG_WRITE_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_free_buffer_list,(png_structrp png_ptr,\n   png_compression_bufferp *list),PNG_EMPTY);\n   /* Free the buffer list used by the compressed write code. */\n#endif\n\n#if defined(PNG_FLOATING_POINT_SUPPORTED) && \\\n   !defined(PNG_FIXED_POINT_MACRO_SUPPORTED) && \\\n   (defined(PNG_gAMA_SUPPORTED) || defined(PNG_cHRM_SUPPORTED) || \\\n   defined(PNG_sCAL_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) || \\\n   defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)) || \\\n   (defined(PNG_sCAL_SUPPORTED) && \\\n   defined(PNG_FLOATING_ARITHMETIC_SUPPORTED))\nPNG_INTERNAL_FUNCTION(png_fixed_point,png_fixed,(png_const_structrp png_ptr,\n   double fp, png_const_charp text),PNG_EMPTY);\n#endif\n\n/* Check the user version string for compatibility, returns false if the version\n * numbers aren't compatible.\n */\nPNG_INTERNAL_FUNCTION(int,png_user_version_check,(png_structrp png_ptr,\n   png_const_charp user_png_ver),PNG_EMPTY);\n\n/* Internal base allocator - no messages, NULL on failure to allocate.  This\n * does, however, call the application provided allocator and that could call\n * png_error (although that would be a bug in the application implementation.)\n */\nPNG_INTERNAL_FUNCTION(png_voidp,png_malloc_base,(png_const_structrp png_ptr,\n   png_alloc_size_t size),PNG_ALLOCATED);\n\n#if defined(PNG_TEXT_SUPPORTED) || defined(PNG_sPLT_SUPPORTED) ||\\\n   defined(PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED)\n/* Internal array allocator, outputs no error or warning messages on failure,\n * just returns NULL.  \n */\nPNG_INTERNAL_FUNCTION(png_voidp,png_malloc_array,(png_const_structrp png_ptr,\n   int nelements, size_t element_size),PNG_ALLOCATED);\n\n/* The same but an existing array is extended by add_elements.  This function\n * also memsets the new elements to 0 and copies the old elements.  The old\n * array is not freed or altered.\n */\nPNG_INTERNAL_FUNCTION(png_voidp,png_realloc_array,(png_const_structrp png_ptr,\n   png_const_voidp array, int old_elements, int add_elements,\n   size_t element_size),PNG_ALLOCATED);\n#endif /* text, sPLT or unknown chunks */\n\n/* Magic to create a struct when there is no struct to call the user supplied\n * memory allocators.  Because error handling has not been set up the memory\n * handlers can't safely call png_error, but this is an obscure and undocumented\n * restriction so libpng has to assume that the 'free' handler, at least, might\n * call png_error.\n */\nPNG_INTERNAL_FUNCTION(png_structp,png_create_png_struct,\n   (png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn,\n    png_error_ptr warn_fn, png_voidp mem_ptr, png_malloc_ptr malloc_fn,\n    png_free_ptr free_fn),PNG_ALLOCATED);\n\n/* Free memory from internal libpng struct */\nPNG_INTERNAL_FUNCTION(void,png_destroy_png_struct,(png_structrp png_ptr),\n   PNG_EMPTY);\n\n/* Free an allocated jmp_buf (always succeeds) */\nPNG_INTERNAL_FUNCTION(void,png_free_jmpbuf,(png_structrp png_ptr),PNG_EMPTY);\n\n/* Function to allocate memory for zlib.  PNGAPI is disallowed. */\nPNG_INTERNAL_FUNCTION(voidpf,png_zalloc,(voidpf png_ptr, uInt items, uInt size),\n   PNG_ALLOCATED);\n\n/* Function to free memory for zlib.  PNGAPI is disallowed. */\nPNG_INTERNAL_FUNCTION(void,png_zfree,(voidpf png_ptr, voidpf ptr),PNG_EMPTY);\n\n/* Next four functions are used internally as callbacks.  PNGCBAPI is required\n * but not PNG_EXPORT.  PNGAPI added at libpng version 1.2.3, changed to\n * PNGCBAPI at 1.5.0\n */\n\nPNG_INTERNAL_FUNCTION(void PNGCBAPI,png_default_read_data,(png_structp png_ptr,\n    png_bytep data, png_size_t length),PNG_EMPTY);\n\n#ifdef PNG_PROGRESSIVE_READ_SUPPORTED\nPNG_INTERNAL_FUNCTION(void PNGCBAPI,png_push_fill_buffer,(png_structp png_ptr,\n    png_bytep buffer, png_size_t length),PNG_EMPTY);\n#endif\n\nPNG_INTERNAL_FUNCTION(void PNGCBAPI,png_default_write_data,(png_structp png_ptr,\n    png_bytep data, png_size_t length),PNG_EMPTY);\n\n#ifdef PNG_WRITE_FLUSH_SUPPORTED\n#  ifdef PNG_STDIO_SUPPORTED\nPNG_INTERNAL_FUNCTION(void PNGCBAPI,png_default_flush,(png_structp png_ptr),\n   PNG_EMPTY);\n#  endif\n#endif\n\n/* Reset the CRC variable */\nPNG_INTERNAL_FUNCTION(void,png_reset_crc,(png_structrp png_ptr),PNG_EMPTY);\n\n/* Write the \"data\" buffer to whatever output you are using */\nPNG_INTERNAL_FUNCTION(void,png_write_data,(png_structrp png_ptr,\n    png_const_bytep data, png_size_t length),PNG_EMPTY);\n\n/* Read and check the PNG file signature */\nPNG_INTERNAL_FUNCTION(void,png_read_sig,(png_structrp png_ptr,\n   png_inforp info_ptr),PNG_EMPTY);\n\n/* Read the chunk header (length + type name) */\nPNG_INTERNAL_FUNCTION(png_uint_32,png_read_chunk_header,(png_structrp png_ptr),\n   PNG_EMPTY);\n\n/* Read data from whatever input you are using into the \"data\" buffer */\nPNG_INTERNAL_FUNCTION(void,png_read_data,(png_structrp png_ptr, png_bytep data,\n    png_size_t length),PNG_EMPTY);\n\n/* Read bytes into buf, and update png_ptr->crc */\nPNG_INTERNAL_FUNCTION(void,png_crc_read,(png_structrp png_ptr, png_bytep buf,\n    png_uint_32 length),PNG_EMPTY);\n\n/* Read \"skip\" bytes, read the file crc, and (optionally) verify png_ptr->crc */\nPNG_INTERNAL_FUNCTION(int,png_crc_finish,(png_structrp png_ptr,\n   png_uint_32 skip),PNG_EMPTY);\n\n/* Read the CRC from the file and compare it to the libpng calculated CRC */\nPNG_INTERNAL_FUNCTION(int,png_crc_error,(png_structrp png_ptr),PNG_EMPTY);\n\n/* Calculate the CRC over a section of data.  Note that we are only\n * passing a maximum of 64K on systems that have this as a memory limit,\n * since this is the maximum buffer size we can specify.\n */\nPNG_INTERNAL_FUNCTION(void,png_calculate_crc,(png_structrp png_ptr,\n   png_const_bytep ptr, png_size_t length),PNG_EMPTY);\n\n#ifdef PNG_WRITE_FLUSH_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_flush,(png_structrp png_ptr),PNG_EMPTY);\n#endif\n\n/* Write various chunks */\n\n/* Write the IHDR chunk, and update the png_struct with the necessary\n * information.\n */\nPNG_INTERNAL_FUNCTION(void,png_write_IHDR,(png_structrp png_ptr,\n   png_uint_32 width, png_uint_32 height, int bit_depth, int color_type,\n   int compression_method, int filter_method, int interlace_method),PNG_EMPTY);\n\nPNG_INTERNAL_FUNCTION(void,png_write_PLTE,(png_structrp png_ptr,\n   png_const_colorp palette, png_uint_32 num_pal),PNG_EMPTY);\n\nPNG_INTERNAL_FUNCTION(void,png_compress_IDAT,(png_structrp png_ptr,\n   png_const_bytep row_data, png_alloc_size_t row_data_length, int flush),\n   PNG_EMPTY);\n\nPNG_INTERNAL_FUNCTION(void,png_write_IEND,(png_structrp png_ptr),PNG_EMPTY);\n\n#ifdef PNG_WRITE_gAMA_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_write_gAMA_fixed,(png_structrp png_ptr,\n    png_fixed_point file_gamma),PNG_EMPTY);\n#endif\n\n#ifdef PNG_WRITE_sBIT_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_write_sBIT,(png_structrp png_ptr,\n    png_const_color_8p sbit, int color_type),PNG_EMPTY);\n#endif\n\n#ifdef PNG_WRITE_cHRM_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_write_cHRM_fixed,(png_structrp png_ptr,\n    const png_xy *xy), PNG_EMPTY);\n    /* The xy value must have been previously validated */\n#endif\n\n#ifdef PNG_WRITE_sRGB_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_write_sRGB,(png_structrp png_ptr,\n    int intent),PNG_EMPTY);\n#endif\n\n#ifdef PNG_WRITE_iCCP_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_write_iCCP,(png_structrp png_ptr,\n   png_const_charp name, png_const_bytep profile), PNG_EMPTY);\n   /* The profile must have been previously validated for correctness, the\n    * length comes from the first four bytes.  Only the base, deflate,\n    * compression is supported.\n    */\n#endif\n\n#ifdef PNG_WRITE_sPLT_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_write_sPLT,(png_structrp png_ptr,\n    png_const_sPLT_tp palette),PNG_EMPTY);\n#endif\n\n#ifdef PNG_WRITE_tRNS_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_write_tRNS,(png_structrp png_ptr,\n    png_const_bytep trans, png_const_color_16p values, int number,\n    int color_type),PNG_EMPTY);\n#endif\n\n#ifdef PNG_WRITE_bKGD_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_write_bKGD,(png_structrp png_ptr,\n    png_const_color_16p values, int color_type),PNG_EMPTY);\n#endif\n\n#ifdef PNG_WRITE_hIST_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_write_hIST,(png_structrp png_ptr,\n    png_const_uint_16p hist, int num_hist),PNG_EMPTY);\n#endif\n\n/* Chunks that have keywords */\n#ifdef PNG_WRITE_tEXt_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_write_tEXt,(png_structrp png_ptr,\n   png_const_charp key, png_const_charp text, png_size_t text_len),PNG_EMPTY);\n#endif\n\n#ifdef PNG_WRITE_zTXt_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_write_zTXt,(png_structrp png_ptr, png_const_charp\n    key, png_const_charp text, png_size_t text_len, int compression),PNG_EMPTY);\n#endif\n\n#ifdef PNG_WRITE_iTXt_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_write_iTXt,(png_structrp png_ptr,\n    int compression, png_const_charp key, png_const_charp lang,\n    png_const_charp lang_key, png_const_charp text),PNG_EMPTY);\n#endif\n\n#ifdef PNG_TEXT_SUPPORTED  /* Added at version 1.0.14 and 1.2.4 */\nPNG_INTERNAL_FUNCTION(int,png_set_text_2,(png_const_structrp png_ptr,\n    png_inforp info_ptr, png_const_textp text_ptr, int num_text),PNG_EMPTY);\n#endif\n\n#ifdef PNG_WRITE_oFFs_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_write_oFFs,(png_structrp png_ptr,\n    png_int_32 x_offset, png_int_32 y_offset, int unit_type),PNG_EMPTY);\n#endif\n\n#ifdef PNG_WRITE_pCAL_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_write_pCAL,(png_structrp png_ptr,\n    png_charp purpose, png_int_32 X0, png_int_32 X1, int type, int nparams,\n    png_const_charp units, png_charpp params),PNG_EMPTY);\n#endif\n\n#ifdef PNG_WRITE_pHYs_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_write_pHYs,(png_structrp png_ptr,\n    png_uint_32 x_pixels_per_unit, png_uint_32 y_pixels_per_unit,\n    int unit_type),PNG_EMPTY);\n#endif\n\n#ifdef PNG_WRITE_tIME_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_write_tIME,(png_structrp png_ptr,\n    png_const_timep mod_time),PNG_EMPTY);\n#endif\n\n#ifdef PNG_WRITE_sCAL_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_write_sCAL_s,(png_structrp png_ptr,\n    int unit, png_const_charp width, png_const_charp height),PNG_EMPTY);\n#endif\n\n/* Called when finished processing a row of data */\nPNG_INTERNAL_FUNCTION(void,png_write_finish_row,(png_structrp png_ptr),\n    PNG_EMPTY);\n\n/* Internal use only.   Called before first row of data */\nPNG_INTERNAL_FUNCTION(void,png_write_start_row,(png_structrp png_ptr),\n    PNG_EMPTY);\n\n/* Combine a row of data, dealing with alpha, etc. if requested.  'row' is an\n * array of png_ptr->width pixels.  If the image is not interlaced or this\n * is the final pass this just does a memcpy, otherwise the \"display\" flag\n * is used to determine whether to copy pixels that are not in the current pass.\n *\n * Because 'png_do_read_interlace' (below) replicates pixels this allows this\n * function to achieve the documented 'blocky' appearance during interlaced read\n * if display is 1 and the 'sparkle' appearance, where existing pixels in 'row'\n * are not changed if they are not in the current pass, when display is 0.\n *\n * 'display' must be 0 or 1, otherwise the memcpy will be done regardless.\n *\n * The API always reads from the png_struct row buffer and always assumes that\n * it is full width (png_do_read_interlace has already been called.)\n *\n * This function is only ever used to write to row buffers provided by the\n * caller of the relevant libpng API and the row must have already been\n * transformed by the read transformations.\n *\n * The PNG_USE_COMPILE_TIME_MASKS option causes generation of pre-computed\n * bitmasks for use within the code, otherwise runtime generated masks are used.\n * The default is compile time masks.\n */\n#ifndef PNG_USE_COMPILE_TIME_MASKS\n#  define PNG_USE_COMPILE_TIME_MASKS 1\n#endif\nPNG_INTERNAL_FUNCTION(void,png_combine_row,(png_const_structrp png_ptr,\n    png_bytep row, int display),PNG_EMPTY);\n\n#ifdef PNG_READ_INTERLACING_SUPPORTED\n/* Expand an interlaced row: the 'row_info' describes the pass data that has\n * been read in and must correspond to the pixels in 'row', the pixels are\n * expanded (moved apart) in 'row' to match the final layout, when doing this\n * the pixels are *replicated* to the intervening space.  This is essential for\n * the correct operation of png_combine_row, above.\n */\nPNG_INTERNAL_FUNCTION(void,png_do_read_interlace,(png_row_infop row_info,\n    png_bytep row, int pass, png_uint_32 transformations),PNG_EMPTY);\n#endif\n\n/* GRR TO DO (2.0 or whenever):  simplify other internal calling interfaces */\n\n#ifdef PNG_WRITE_INTERLACING_SUPPORTED\n/* Grab pixels out of a row for an interlaced pass */\nPNG_INTERNAL_FUNCTION(void,png_do_write_interlace,(png_row_infop row_info,\n    png_bytep row, int pass),PNG_EMPTY);\n#endif\n\n/* Unfilter a row: check the filter value before calling this, there is no point\n * calling it for PNG_FILTER_VALUE_NONE.\n */\nPNG_INTERNAL_FUNCTION(void,png_read_filter_row,(png_structrp pp, png_row_infop\n    row_info, png_bytep row, png_const_bytep prev_row, int filter),PNG_EMPTY);\n\nPNG_INTERNAL_FUNCTION(void,png_read_filter_row_up_neon,(png_row_infop row_info,\n    png_bytep row, png_const_bytep prev_row),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub3_neon,(png_row_infop\n    row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub4_neon,(png_row_infop\n    row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_read_filter_row_avg3_neon,(png_row_infop\n    row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_read_filter_row_avg4_neon,(png_row_infop\n    row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth3_neon,(png_row_infop\n    row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth4_neon,(png_row_infop\n    row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);\n\n/* Choose the best filter to use and filter the row data */\nPNG_INTERNAL_FUNCTION(void,png_write_find_filter,(png_structrp png_ptr,\n    png_row_infop row_info),PNG_EMPTY);\n\n#ifdef PNG_SEQUENTIAL_READ_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_read_IDAT_data,(png_structrp png_ptr,\n   png_bytep output, png_alloc_size_t avail_out),PNG_EMPTY);\n   /* Read 'avail_out' bytes of data from the IDAT stream.  If the output buffer\n    * is NULL the function checks, instead, for the end of the stream.  In this\n    * case a benign error will be issued if the stream end is not found or if\n    * extra data has to be consumed.\n    */\nPNG_INTERNAL_FUNCTION(void,png_read_finish_IDAT,(png_structrp png_ptr),\n   PNG_EMPTY);\n   /* This cleans up when the IDAT LZ stream does not end when the last image\n    * byte is read; there is still some pending input.\n    */\n\nPNG_INTERNAL_FUNCTION(void,png_read_finish_row,(png_structrp png_ptr),\n   PNG_EMPTY);\n   /* Finish a row while reading, dealing with interlacing passes, etc. */\n#endif /* PNG_SEQUENTIAL_READ_SUPPORTED */\n\n/* Initialize the row buffers, etc. */\nPNG_INTERNAL_FUNCTION(void,png_read_start_row,(png_structrp png_ptr),PNG_EMPTY);\n\n#ifdef PNG_READ_TRANSFORMS_SUPPORTED\n/* Optional call to update the users info structure */\nPNG_INTERNAL_FUNCTION(void,png_read_transform_info,(png_structrp png_ptr,\n    png_inforp info_ptr),PNG_EMPTY);\n#endif\n\n/* Shared transform functions, defined in pngtran.c */\n#if defined(PNG_WRITE_FILLER_SUPPORTED) || \\\n    defined(PNG_READ_STRIP_ALPHA_SUPPORTED)\nPNG_INTERNAL_FUNCTION(void,png_do_strip_channel,(png_row_infop row_info,\n    png_bytep row, int at_start),PNG_EMPTY);\n#endif\n\n#ifdef PNG_16BIT_SUPPORTED\n#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED)\nPNG_INTERNAL_FUNCTION(void,png_do_swap,(png_row_infop row_info,\n    png_bytep row),PNG_EMPTY);\n#endif\n#endif\n\n#if defined(PNG_READ_PACKSWAP_SUPPORTED) || \\\n    defined(PNG_WRITE_PACKSWAP_SUPPORTED)\nPNG_INTERNAL_FUNCTION(void,png_do_packswap,(png_row_infop row_info,\n    png_bytep row),PNG_EMPTY);\n#endif\n\n#if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED)\nPNG_INTERNAL_FUNCTION(void,png_do_invert,(png_row_infop row_info,\n    png_bytep row),PNG_EMPTY);\n#endif\n\n#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED)\nPNG_INTERNAL_FUNCTION(void,png_do_bgr,(png_row_infop row_info,\n    png_bytep row),PNG_EMPTY);\n#endif\n\n/* The following decodes the appropriate chunks, and does error correction,\n * then calls the appropriate callback for the chunk if it is valid.\n */\n\n/* Decode the IHDR chunk */\nPNG_INTERNAL_FUNCTION(void,png_handle_IHDR,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_handle_PLTE,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_handle_IEND,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\n\n#ifdef PNG_READ_bKGD_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_handle_bKGD,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\n#endif\n\n#ifdef PNG_READ_cHRM_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_handle_cHRM,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\n#endif\n\n#ifdef PNG_READ_gAMA_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_handle_gAMA,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\n#endif\n\n#ifdef PNG_READ_hIST_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_handle_hIST,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\n#endif\n\n#ifdef PNG_READ_iCCP_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_handle_iCCP,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\n#endif /* PNG_READ_iCCP_SUPPORTED */\n\n#ifdef PNG_READ_iTXt_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_handle_iTXt,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\n#endif\n\n#ifdef PNG_READ_oFFs_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_handle_oFFs,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\n#endif\n\n#ifdef PNG_READ_pCAL_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_handle_pCAL,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\n#endif\n\n#ifdef PNG_READ_pHYs_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_handle_pHYs,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\n#endif\n\n#ifdef PNG_READ_sBIT_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_handle_sBIT,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\n#endif\n\n#ifdef PNG_READ_sCAL_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_handle_sCAL,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\n#endif\n\n#ifdef PNG_READ_sPLT_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_handle_sPLT,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\n#endif /* PNG_READ_sPLT_SUPPORTED */\n\n#ifdef PNG_READ_sRGB_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_handle_sRGB,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\n#endif\n\n#ifdef PNG_READ_tEXt_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_handle_tEXt,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\n#endif\n\n#ifdef PNG_READ_tIME_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_handle_tIME,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\n#endif\n\n#ifdef PNG_READ_tRNS_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_handle_tRNS,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\n#endif\n\n#ifdef PNG_READ_zTXt_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_handle_zTXt,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\n#endif\n\nPNG_INTERNAL_FUNCTION(void,png_check_chunk_name,(png_structrp png_ptr,\n    png_uint_32 chunk_name),PNG_EMPTY);\n\nPNG_INTERNAL_FUNCTION(void,png_handle_unknown,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length, int keep),PNG_EMPTY);\n   /* This is the function that gets called for unknown chunks.  The 'keep'\n    * argument is either non-zero for a known chunk that has been set to be\n    * handled as unknown or zero for an unknown chunk.  By default the function\n    * just skips the chunk or errors out if it is critical.\n    */\n\n#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) ||\\\n    defined(PNG_HANDLE_AS_UNKNOWN_SUPPORTED)\nPNG_INTERNAL_FUNCTION(int,png_chunk_unknown_handling,\n    (png_const_structrp png_ptr, png_uint_32 chunk_name),PNG_EMPTY);\n   /* Exactly as the API png_handle_as_unknown() except that the argument is a\n    * 32-bit chunk name, not a string.\n    */\n#endif /* READ_UNKNOWN_CHUNKS || HANDLE_AS_UNKNOWN */\n\n/* Handle the transformations for reading and writing */\n#ifdef PNG_READ_TRANSFORMS_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_do_read_transformations,(png_structrp png_ptr,\n   png_row_infop row_info),PNG_EMPTY);\n#endif\n#ifdef PNG_WRITE_TRANSFORMS_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_do_write_transformations,(png_structrp png_ptr,\n   png_row_infop row_info),PNG_EMPTY);\n#endif\n\n#ifdef PNG_READ_TRANSFORMS_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_init_read_transformations,(png_structrp png_ptr),\n    PNG_EMPTY);\n#endif\n\n#ifdef PNG_PROGRESSIVE_READ_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_push_read_chunk,(png_structrp png_ptr,\n    png_inforp info_ptr),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_push_read_sig,(png_structrp png_ptr,\n    png_inforp info_ptr),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_push_check_crc,(png_structrp png_ptr),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_push_crc_skip,(png_structrp png_ptr,\n    png_uint_32 length),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_push_crc_finish,(png_structrp png_ptr),\n    PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_push_save_buffer,(png_structrp png_ptr),\n    PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_push_restore_buffer,(png_structrp png_ptr,\n    png_bytep buffer, png_size_t buffer_length),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_push_read_IDAT,(png_structrp png_ptr),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_process_IDAT_data,(png_structrp png_ptr,\n    png_bytep buffer, png_size_t buffer_length),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_push_process_row,(png_structrp png_ptr),\n    PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_push_handle_unknown,(png_structrp png_ptr,\n   png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_push_have_info,(png_structrp png_ptr,\n   png_inforp info_ptr),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_push_have_end,(png_structrp png_ptr,\n   png_inforp info_ptr),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_push_have_row,(png_structrp png_ptr,\n     png_bytep row),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_push_read_end,(png_structrp png_ptr,\n    png_inforp info_ptr),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_process_some_data,(png_structrp png_ptr,\n    png_inforp info_ptr),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_read_push_finish_row,(png_structrp png_ptr),\n    PNG_EMPTY);\n#  ifdef PNG_READ_tEXt_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_push_handle_tEXt,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_push_read_tEXt,(png_structrp png_ptr,\n    png_inforp info_ptr),PNG_EMPTY);\n#  endif\n#  ifdef PNG_READ_zTXt_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_push_handle_zTXt,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_push_read_zTXt,(png_structrp png_ptr,\n    png_inforp info_ptr),PNG_EMPTY);\n#  endif\n#  ifdef PNG_READ_iTXt_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_push_handle_iTXt,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_push_read_iTXt,(png_structrp png_ptr,\n    png_inforp info_ptr),PNG_EMPTY);\n#  endif\n\n#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */\n\n/* Added at libpng version 1.6.0 */\n#ifdef PNG_GAMMA_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_colorspace_set_gamma,(png_const_structrp png_ptr,\n    png_colorspacerp colorspace, png_fixed_point gAMA), PNG_EMPTY);\n   /* Set the colorspace gamma with a value provided by the application or by\n    * the gAMA chunk on read.  The value will override anything set by an ICC\n    * profile.\n    */\n\nPNG_INTERNAL_FUNCTION(void,png_colorspace_sync_info,(png_const_structrp png_ptr,\n    png_inforp info_ptr), PNG_EMPTY);\n    /* Synchronize the info 'valid' flags with the colorspace */\n\nPNG_INTERNAL_FUNCTION(void,png_colorspace_sync,(png_const_structrp png_ptr,\n    png_inforp info_ptr), PNG_EMPTY);\n    /* Copy the png_struct colorspace to the info_struct and call the above to\n     * synchronize the flags.  Checks for NULL info_ptr and does nothing.\n     */\n#endif\n\n/* Added at libpng version 1.4.0 */\n#ifdef PNG_COLORSPACE_SUPPORTED\n/* These internal functions are for maintaining the colorspace structure within\n * a png_info or png_struct (or, indeed, both).\n */\nPNG_INTERNAL_FUNCTION(int,png_colorspace_set_chromaticities,\n   (png_const_structrp png_ptr, png_colorspacerp colorspace, const png_xy *xy,\n    int preferred), PNG_EMPTY);\n\nPNG_INTERNAL_FUNCTION(int,png_colorspace_set_endpoints,\n   (png_const_structrp png_ptr, png_colorspacerp colorspace, const png_XYZ *XYZ,\n    int preferred), PNG_EMPTY);\n\n#ifdef PNG_sRGB_SUPPORTED\nPNG_INTERNAL_FUNCTION(int,png_colorspace_set_sRGB,(png_const_structrp png_ptr,\n   png_colorspacerp colorspace, int intent), PNG_EMPTY);\n   /* This does set the colorspace gAMA and cHRM values too, but doesn't set the\n    * flags to write them, if it returns false there was a problem and an error\n    * message has already been output (but the colorspace may still need to be\n    * synced to record the invalid flag).\n    */\n#endif /* sRGB */\n\n#ifdef PNG_iCCP_SUPPORTED\nPNG_INTERNAL_FUNCTION(int,png_colorspace_set_ICC,(png_const_structrp png_ptr,\n   png_colorspacerp colorspace, png_const_charp name,\n   png_uint_32 profile_length, png_const_bytep profile, int color_type),\n   PNG_EMPTY);\n   /* The 'name' is used for information only */\n\n/* Routines for checking parts of an ICC profile. */\nPNG_INTERNAL_FUNCTION(int,png_icc_check_length,(png_const_structrp png_ptr,\n   png_colorspacerp colorspace, png_const_charp name,\n   png_uint_32 profile_length), PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(int,png_icc_check_header,(png_const_structrp png_ptr,\n   png_colorspacerp colorspace, png_const_charp name,\n   png_uint_32 profile_length,\n   png_const_bytep profile /* first 132 bytes only */, int color_type),\n   PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(int,png_icc_check_tag_table,(png_const_structrp png_ptr,\n   png_colorspacerp colorspace, png_const_charp name,\n   png_uint_32 profile_length,\n   png_const_bytep profile /* header plus whole tag table */), PNG_EMPTY);\n#ifdef PNG_sRGB_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_icc_set_sRGB,(\n   png_const_structrp png_ptr, png_colorspacerp colorspace,\n   png_const_bytep profile, uLong adler), PNG_EMPTY);\n   /* 'adler' is the Adler32 checksum of the uncompressed profile data. It may\n    * be zero to indicate that it is not available.  It is used, if provided,\n    * as a fast check on the profile when checking to see if it is sRGB.\n    */\n#endif\n#endif /* iCCP */\n\n#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_colorspace_set_rgb_coefficients,\n   (png_structrp png_ptr), PNG_EMPTY);\n   /* Set the rgb_to_gray coefficients from the colorspace Y values */\n#endif /* READ_RGB_TO_GRAY */\n#endif /* COLORSPACE */\n\n/* Added at libpng version 1.4.0 */\nPNG_INTERNAL_FUNCTION(void,png_check_IHDR,(png_const_structrp png_ptr,\n    png_uint_32 width, png_uint_32 height, int bit_depth,\n    int color_type, int interlace_type, int compression_type,\n    int filter_type),PNG_EMPTY);\n\n/* Added at libpng version 1.5.10 */\n#if defined(PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED) || \\\n    defined(PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED)\nPNG_INTERNAL_FUNCTION(void,png_do_check_palette_indexes,\n   (png_structrp png_ptr, png_row_infop row_info),PNG_EMPTY);\n#endif\n\n#if defined(PNG_FLOATING_POINT_SUPPORTED) && defined(PNG_ERROR_TEXT_SUPPORTED)\nPNG_INTERNAL_FUNCTION(void,png_fixed_error,(png_const_structrp png_ptr,\n   png_const_charp name),PNG_NORETURN);\n#endif\n\n/* Puts 'string' into 'buffer' at buffer[pos], taking care never to overwrite\n * the end.  Always leaves the buffer nul terminated.  Never errors out (and\n * there is no error code.)\n */\nPNG_INTERNAL_FUNCTION(size_t,png_safecat,(png_charp buffer, size_t bufsize,\n   size_t pos, png_const_charp string),PNG_EMPTY);\n\n/* Various internal functions to handle formatted warning messages, currently\n * only implemented for warnings.\n */\n#if defined(PNG_WARNINGS_SUPPORTED) || defined(PNG_TIME_RFC1123_SUPPORTED)\n/* Utility to dump an unsigned value into a buffer, given a start pointer and\n * and end pointer (which should point just *beyond* the end of the buffer!)\n * Returns the pointer to the start of the formatted string.  This utility only\n * does unsigned values.\n */\nPNG_INTERNAL_FUNCTION(png_charp,png_format_number,(png_const_charp start,\n   png_charp end, int format, png_alloc_size_t number),PNG_EMPTY);\n\n/* Convenience macro that takes an array: */\n#define PNG_FORMAT_NUMBER(buffer,format,number) \\\n   png_format_number(buffer, buffer + (sizeof buffer), format, number)\n\n/* Suggested size for a number buffer (enough for 64 bits and a sign!) */\n#define PNG_NUMBER_BUFFER_SIZE 24\n\n/* These are the integer formats currently supported, the name is formed from\n * the standard printf(3) format string.\n */\n#define PNG_NUMBER_FORMAT_u     1 /* chose unsigned API! */\n#define PNG_NUMBER_FORMAT_02u   2\n#define PNG_NUMBER_FORMAT_d     1 /* chose signed API! */\n#define PNG_NUMBER_FORMAT_02d   2\n#define PNG_NUMBER_FORMAT_x     3\n#define PNG_NUMBER_FORMAT_02x   4\n#define PNG_NUMBER_FORMAT_fixed 5 /* choose the signed API */\n#endif\n\n#ifdef PNG_WARNINGS_SUPPORTED\n/* New defines and members adding in libpng-1.5.4 */\n#  define PNG_WARNING_PARAMETER_SIZE 32\n#  define PNG_WARNING_PARAMETER_COUNT 8 /* Maximum 9; see pngerror.c */\n\n/* An l-value of this type has to be passed to the APIs below to cache the\n * values of the parameters to a formatted warning message.\n */\ntypedef char png_warning_parameters[PNG_WARNING_PARAMETER_COUNT][\n   PNG_WARNING_PARAMETER_SIZE];\n\nPNG_INTERNAL_FUNCTION(void,png_warning_parameter,(png_warning_parameters p,\n   int number, png_const_charp string),PNG_EMPTY);\n   /* Parameters are limited in size to PNG_WARNING_PARAMETER_SIZE characters,\n    * including the trailing '\\0'.\n    */\nPNG_INTERNAL_FUNCTION(void,png_warning_parameter_unsigned,\n   (png_warning_parameters p, int number, int format, png_alloc_size_t value),\n   PNG_EMPTY);\n   /* Use png_alloc_size_t because it is an unsigned type as big as any we\n    * need to output.  Use the following for a signed value.\n    */\nPNG_INTERNAL_FUNCTION(void,png_warning_parameter_signed,\n   (png_warning_parameters p, int number, int format, png_int_32 value),\n   PNG_EMPTY);\n\nPNG_INTERNAL_FUNCTION(void,png_formatted_warning,(png_const_structrp png_ptr,\n   png_warning_parameters p, png_const_charp message),PNG_EMPTY);\n   /* 'message' follows the X/Open approach of using @1, @2 to insert\n    * parameters previously supplied using the above functions.  Errors in\n    * specifying the parameters will simply result in garbage substitutions.\n    */\n#endif\n\n#ifdef PNG_BENIGN_ERRORS_SUPPORTED\n/* Application errors (new in 1.6); use these functions (declared below) for\n * errors in the parameters or order of API function calls on read.  The\n * 'warning' should be used for an error that can be handled completely; the\n * 'error' for one which can be handled safely but which may lose application\n * information or settings.\n *\n * By default these both result in a png_error call prior to release, while in a\n * released version the 'warning' is just a warning.  However if the application\n * explicitly disables benign errors (explicitly permitting the code to lose\n * information) they both turn into warnings.\n *\n * If benign errors aren't supported they end up as the corresponding base call\n * (png_warning or png_error.)\n */\nPNG_INTERNAL_FUNCTION(void,png_app_warning,(png_const_structrp png_ptr,\n   png_const_charp message),PNG_EMPTY);\n   /* The application provided invalid parameters to an API function or called\n    * an API function at the wrong time, libpng can completely recover.\n    */\n\nPNG_INTERNAL_FUNCTION(void,png_app_error,(png_const_structrp png_ptr,\n   png_const_charp message),PNG_EMPTY);\n   /* As above but libpng will ignore the call, or attempt some other partial\n    * recovery from the error.\n    */\n#else\n#  define png_app_warning(pp,s) png_warning(pp,s)\n#  define png_app_error(pp,s) png_error(pp,s)\n#endif\n\nPNG_INTERNAL_FUNCTION(void,png_chunk_report,(png_const_structrp png_ptr,\n   png_const_charp message, int error),PNG_EMPTY);\n   /* Report a recoverable issue in chunk data.  On read this is used to report\n    * a problem found while reading a particular chunk and the\n    * png_chunk_benign_error or png_chunk_warning function is used as\n    * appropriate.  On write this is used to report an error that comes from\n    * data set via an application call to a png_set_ API and png_app_error or\n    * png_app_warning is used as appropriate.\n    *\n    * The 'error' parameter must have one of the following values:\n    */\n#define PNG_CHUNK_WARNING     0 /* never an error */\n#define PNG_CHUNK_WRITE_ERROR 1 /* an error only on write */\n#define PNG_CHUNK_ERROR       2 /* always an error */\n\n/* ASCII to FP interfaces, currently only implemented if sCAL\n * support is required.\n */\n#if defined(PNG_sCAL_SUPPORTED)\n/* MAX_DIGITS is actually the maximum number of characters in an sCAL\n * width or height, derived from the precision (number of significant\n * digits - a build time settable option) and assumptions about the\n * maximum ridiculous exponent.\n */\n#define PNG_sCAL_MAX_DIGITS (PNG_sCAL_PRECISION+1/*.*/+1/*E*/+10/*exponent*/)\n\n#ifdef PNG_FLOATING_POINT_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_ascii_from_fp,(png_const_structrp png_ptr,\n   png_charp ascii, png_size_t size, double fp, unsigned int precision),\n   PNG_EMPTY);\n#endif /* FLOATING_POINT */\n\n#ifdef PNG_FIXED_POINT_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_ascii_from_fixed,(png_const_structrp png_ptr,\n   png_charp ascii, png_size_t size, png_fixed_point fp),PNG_EMPTY);\n#endif /* FIXED_POINT */\n#endif /* sCAL */\n\n#if defined(PNG_sCAL_SUPPORTED) || defined(PNG_pCAL_SUPPORTED)\n/* An internal API to validate the format of a floating point number.\n * The result is the index of the next character.  If the number is\n * not valid it will be the index of a character in the supposed number.\n *\n * The format of a number is defined in the PNG extensions specification\n * and this API is strictly conformant to that spec, not anyone elses!\n *\n * The format as a regular expression is:\n *\n * [+-]?[0-9]+.?([Ee][+-]?[0-9]+)?\n *\n * or:\n *\n * [+-]?.[0-9]+(.[0-9]+)?([Ee][+-]?[0-9]+)?\n *\n * The complexity is that either integer or fraction must be present and the\n * fraction is permitted to have no digits only if the integer is present.\n *\n * NOTE: The dangling E problem.\n *   There is a PNG valid floating point number in the following:\n *\n *       PNG floating point numbers are not greedy.\n *\n *   Working this out requires *TWO* character lookahead (because of the\n *   sign), the parser does not do this - it will fail at the 'r' - this\n *   doesn't matter for PNG sCAL chunk values, but it requires more care\n *   if the value were ever to be embedded in something more complex.  Use\n *   ANSI-C strtod if you need the lookahead.\n */\n/* State table for the parser. */\n#define PNG_FP_INTEGER    0  /* before or in integer */\n#define PNG_FP_FRACTION   1  /* before or in fraction */\n#define PNG_FP_EXPONENT   2  /* before or in exponent */\n#define PNG_FP_STATE      3  /* mask for the above */\n#define PNG_FP_SAW_SIGN   4  /* Saw +/- in current state */\n#define PNG_FP_SAW_DIGIT  8  /* Saw a digit in current state */\n#define PNG_FP_SAW_DOT   16  /* Saw a dot in current state */\n#define PNG_FP_SAW_E     32  /* Saw an E (or e) in current state */\n#define PNG_FP_SAW_ANY   60  /* Saw any of the above 4 */\n\n/* These three values don't affect the parser.  They are set but not used.\n */\n#define PNG_FP_WAS_VALID 64  /* Preceding substring is a valid fp number */\n#define PNG_FP_NEGATIVE 128  /* A negative number, including \"-0\" */\n#define PNG_FP_NONZERO  256  /* A non-zero value */\n#define PNG_FP_STICKY   448  /* The above three flags */\n\n/* This is available for the caller to store in 'state' if required.  Do not\n * call the parser after setting it (the parser sometimes clears it.)\n */\n#define PNG_FP_INVALID  512  /* Available for callers as a distinct value */\n\n/* Result codes for the parser (boolean - true meants ok, false means\n * not ok yet.)\n */\n#define PNG_FP_MAYBE      0  /* The number may be valid in the future */\n#define PNG_FP_OK         1  /* The number is valid */\n\n/* Tests on the sticky non-zero and negative flags.  To pass these checks\n * the state must also indicate that the whole number is valid - this is\n * achieved by testing PNG_FP_SAW_DIGIT (see the implementation for why this\n * is equivalent to PNG_FP_OK above.)\n */\n#define PNG_FP_NZ_MASK (PNG_FP_SAW_DIGIT | PNG_FP_NEGATIVE | PNG_FP_NONZERO)\n   /* NZ_MASK: the string is valid and a non-zero negative value */\n#define PNG_FP_Z_MASK (PNG_FP_SAW_DIGIT | PNG_FP_NONZERO)\n   /* Z MASK: the string is valid and a non-zero value. */\n   /* PNG_FP_SAW_DIGIT: the string is valid. */\n#define PNG_FP_IS_ZERO(state) (((state) & PNG_FP_Z_MASK) == PNG_FP_SAW_DIGIT)\n#define PNG_FP_IS_POSITIVE(state) (((state) & PNG_FP_NZ_MASK) == PNG_FP_Z_MASK)\n#define PNG_FP_IS_NEGATIVE(state) (((state) & PNG_FP_NZ_MASK) == PNG_FP_NZ_MASK)\n\n/* The actual parser.  This can be called repeatedly. It updates\n * the index into the string and the state variable (which must\n * be initialized to 0).  It returns a result code, as above.  There\n * is no point calling the parser any more if it fails to advance to\n * the end of the string - it is stuck on an invalid character (or\n * terminated by '\\0').\n *\n * Note that the pointer will consume an E or even an E+ and then leave\n * a 'maybe' state even though a preceding integer.fraction is valid.\n * The PNG_FP_WAS_VALID flag indicates that a preceding substring was\n * a valid number.  It's possible to recover from this by calling\n * the parser again (from the start, with state 0) but with a string\n * that omits the last character (i.e. set the size to the index of\n * the problem character.)  This has not been tested within libpng.\n */\nPNG_INTERNAL_FUNCTION(int,png_check_fp_number,(png_const_charp string,\n   png_size_t size, int *statep, png_size_tp whereami),PNG_EMPTY);\n\n/* This is the same but it checks a complete string and returns true\n * only if it just contains a floating point number.  As of 1.5.4 this\n * function also returns the state at the end of parsing the number if\n * it was valid (otherwise it returns 0.)  This can be used for testing\n * for negative or zero values using the sticky flag.\n */\nPNG_INTERNAL_FUNCTION(int,png_check_fp_string,(png_const_charp string,\n   png_size_t size),PNG_EMPTY);\n#endif /* pCAL || sCAL */\n\n#if defined(PNG_GAMMA_SUPPORTED) ||\\\n    defined(PNG_INCH_CONVERSIONS_SUPPORTED) || defined(PNG_READ_pHYs_SUPPORTED)\n/* Added at libpng version 1.5.0 */\n/* This is a utility to provide a*times/div (rounded) and indicate\n * if there is an overflow.  The result is a boolean - false (0)\n * for overflow, true (1) if no overflow, in which case *res\n * holds the result.\n */\nPNG_INTERNAL_FUNCTION(int,png_muldiv,(png_fixed_point_p res, png_fixed_point a,\n   png_int_32 multiplied_by, png_int_32 divided_by),PNG_EMPTY);\n#endif\n\n#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_INCH_CONVERSIONS_SUPPORTED)\n/* Same deal, but issue a warning on overflow and return 0. */\nPNG_INTERNAL_FUNCTION(png_fixed_point,png_muldiv_warn,\n   (png_const_structrp png_ptr, png_fixed_point a, png_int_32 multiplied_by,\n   png_int_32 divided_by),PNG_EMPTY);\n#endif\n\n#ifdef PNG_GAMMA_SUPPORTED\n/* Calculate a reciprocal - used for gamma values.  This returns\n * 0 if the argument is 0 in order to maintain an undefined value;\n * there are no warnings.\n */\nPNG_INTERNAL_FUNCTION(png_fixed_point,png_reciprocal,(png_fixed_point a),\n   PNG_EMPTY);\n\n#ifdef PNG_READ_GAMMA_SUPPORTED\n/* The same but gives a reciprocal of the product of two fixed point\n * values.  Accuracy is suitable for gamma calculations but this is\n * not exact - use png_muldiv for that.  Only required at present on read.\n */\nPNG_INTERNAL_FUNCTION(png_fixed_point,png_reciprocal2,(png_fixed_point a,\n   png_fixed_point b),PNG_EMPTY);\n#endif\n\n/* Return true if the gamma value is significantly different from 1.0 */\nPNG_INTERNAL_FUNCTION(int,png_gamma_significant,(png_fixed_point gamma_value),\n   PNG_EMPTY);\n#endif\n\n#ifdef PNG_READ_GAMMA_SUPPORTED\n/* Internal fixed point gamma correction.  These APIs are called as\n * required to convert single values - they don't need to be fast,\n * they are not used when processing image pixel values.\n *\n * While the input is an 'unsigned' value it must actually be the\n * correct bit value - 0..255 or 0..65535 as required.\n */\nPNG_INTERNAL_FUNCTION(png_uint_16,png_gamma_correct,(png_structrp png_ptr,\n   unsigned int value, png_fixed_point gamma_value),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(png_uint_16,png_gamma_16bit_correct,(unsigned int value,\n   png_fixed_point gamma_value),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(png_byte,png_gamma_8bit_correct,(unsigned int value,\n   png_fixed_point gamma_value),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_destroy_gamma_table,(png_structrp png_ptr),\n   PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_build_gamma_table,(png_structrp png_ptr,\n   int bit_depth),PNG_EMPTY);\n#endif\n\n/* SIMPLIFIED READ/WRITE SUPPORT */\n#if defined(PNG_SIMPLIFIED_READ_SUPPORTED) ||\\\n   defined(PNG_SIMPLIFIED_WRITE_SUPPORTED)\n/* The internal structure that png_image::opaque points to. */\ntypedef struct png_control\n{\n   png_structp png_ptr;\n   png_infop   info_ptr;\n   png_voidp   error_buf;           /* Always a jmp_buf at present. */\n\n   png_const_bytep memory;          /* Memory buffer. */\n   png_size_t      size;            /* Size of the memory buffer. */\n\n   unsigned int for_write       :1; /* Otherwise it is a read structure */\n   unsigned int owned_file      :1; /* We own the file in io_ptr */\n} png_control;\n\n/* Return the pointer to the jmp_buf from a png_control: necessary because C\n * does not reveal the type of the elements of jmp_buf.\n */\n#ifdef __cplusplus\n#  define png_control_jmp_buf(pc) (((jmp_buf*)((pc)->error_buf))[0])\n#else\n#  define png_control_jmp_buf(pc) ((pc)->error_buf)\n#endif\n\n/* Utility to safely execute a piece of libpng code catching and logging any\n * errors that might occur.  Returns true on success, false on failure (either\n * of the function or as a result of a png_error.)\n */\nPNG_INTERNAL_CALLBACK(void,png_safe_error,(png_structp png_ptr,\n   png_const_charp error_message),PNG_NORETURN);\n\n#ifdef PNG_WARNINGS_SUPPORTED\nPNG_INTERNAL_CALLBACK(void,png_safe_warning,(png_structp png_ptr,\n   png_const_charp warning_message),PNG_EMPTY);\n#else\n#  define png_safe_warning 0/*dummy argument*/\n#endif\n\nPNG_INTERNAL_FUNCTION(int,png_safe_execute,(png_imagep image,\n   int (*function)(png_voidp), png_voidp arg),PNG_EMPTY);\n\n/* Utility to log an error; this also cleans up the png_image; the function\n * always returns 0 (false).\n */\nPNG_INTERNAL_FUNCTION(int,png_image_error,(png_imagep image,\n   png_const_charp error_message),PNG_EMPTY);\n\n#ifndef PNG_SIMPLIFIED_READ_SUPPORTED\n/* png_image_free is used by the write code but not exported */\nPNG_INTERNAL_FUNCTION(void, png_image_free, (png_imagep image), PNG_EMPTY);\n#endif /* !SIMPLIFIED_READ */\n\n#endif /* SIMPLIFIED READ/WRITE */\n\n/* These are initialization functions for hardware specific PNG filter\n * optimizations; list these here then select the appropriate one at compile\n * time using the macro PNG_FILTER_OPTIMIZATIONS.  If the macro is not defined\n * the generic code is used.\n */\n#ifdef PNG_FILTER_OPTIMIZATIONS\nPNG_INTERNAL_FUNCTION(void, PNG_FILTER_OPTIMIZATIONS, (png_structp png_ptr,\n   unsigned int bpp), PNG_EMPTY);\n   /* Just declare the optimization that will be used */\n#else\n   /* List *all* the possible optimizations here - this branch is required if\n    * the builder of libpng passes the definition of PNG_FILTER_OPTIMIZATIONS in\n    * CFLAGS in place of CPPFLAGS *and* uses symbol prefixing.\n    */\nPNG_INTERNAL_FUNCTION(void, png_init_filter_functions_neon,\n   (png_structp png_ptr, unsigned int bpp), PNG_EMPTY);\n#endif\n\n/* Maintainer: Put new private prototypes here ^ */\n\n#include \"pngdebug.h\"\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* PNG_VERSION_INFO_ONLY */\n#endif /* PNGPRIV_H */\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/png/pngstruct.h",
    "content": "\n/* pngstruct.h - header file for PNG reference library\n *\n * Copyright (c) 1998-2013 Glenn Randers-Pehrson\n * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)\n * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)\n *\n * Last changed in libpng 1.6.1 [March 28, 2013]\n *\n * This code is released under the libpng license.\n * For conditions of distribution and use, see the disclaimer\n * and license in png.h\n */\n\n/* The structure that holds the information to read and write PNG files.\n * The only people who need to care about what is inside of this are the\n * people who will be modifying the library for their own special needs.\n * It should NOT be accessed directly by an application.\n */\n\n#ifndef PNGSTRUCT_H\n#define PNGSTRUCT_H\n/* zlib.h defines the structure z_stream, an instance of which is included\n * in this structure and is required for decompressing the LZ compressed\n * data in PNG files.\n */\n#ifndef ZLIB_CONST\n   /* We must ensure that zlib uses 'const' in declarations. */\n#  define ZLIB_CONST\n#endif\n#include \"zlib.h\"\n#ifdef const\n   /* zlib.h sometimes #defines const to nothing, undo this. */\n#  undef const\n#endif\n\n/* zlib.h has mediocre z_const use before 1.2.6, this stuff is for compatibility\n * with older builds.\n */\n#if ZLIB_VERNUM < 0x1260\n#  define PNGZ_MSG_CAST(s) png_constcast(char*,s)\n#  define PNGZ_INPUT_CAST(b) png_constcast(png_bytep,b)\n#else\n#  define PNGZ_MSG_CAST(s) (s)\n#  define PNGZ_INPUT_CAST(b) (b)\n#endif\n\n/* zlib.h declares a magic type 'uInt' that limits the amount of data that zlib\n * can handle at once.  This type need be no larger than 16 bits (so maximum of\n * 65535), this define allows us to discover how big it is, but limited by the\n * maximuum for png_size_t.  The value can be overriden in a library build\n * (pngusr.h, or set it in CPPFLAGS) and it works to set it to a considerably\n * lower value (e.g. 255 works).  A lower value may help memory usage (slightly)\n * and may even improve performance on some systems (and degrade it on others.)\n */\n#ifndef ZLIB_IO_MAX\n#  define ZLIB_IO_MAX ((uInt)-1)\n#endif\n\n#ifdef PNG_WRITE_SUPPORTED\n/* The type of a compression buffer list used by the write code. */\ntypedef struct png_compression_buffer\n{\n   struct png_compression_buffer *next;\n   png_byte                       output[1]; /* actually zbuf_size */\n} png_compression_buffer, *png_compression_bufferp;\n\n#define PNG_COMPRESSION_BUFFER_SIZE(pp)\\\n   (offsetof(png_compression_buffer, output) + (pp)->zbuffer_size)\n#endif\n\n/* Colorspace support; structures used in png_struct, png_info and in internal\n * functions to hold and communicate information about the color space.\n *\n * PNG_COLORSPACE_SUPPORTED is only required if the application will perform\n * colorspace corrections, otherwise all the colorspace information can be\n * skipped and the size of libpng can be reduced (significantly) by compiling\n * out the colorspace support.\n */\n#ifdef PNG_COLORSPACE_SUPPORTED\n/* The chromaticities of the red, green and blue colorants and the chromaticity\n * of the corresponding white point (i.e. of rgb(1.0,1.0,1.0)).\n */\ntypedef struct png_xy\n{\n   png_fixed_point redx, redy;\n   png_fixed_point greenx, greeny;\n   png_fixed_point bluex, bluey;\n   png_fixed_point whitex, whitey;\n} png_xy;\n\n/* The same data as above but encoded as CIE XYZ values.  When this data comes\n * from chromaticities the sum of the Y values is assumed to be 1.0\n */\ntypedef struct png_XYZ\n{\n   png_fixed_point red_X, red_Y, red_Z;\n   png_fixed_point green_X, green_Y, green_Z;\n   png_fixed_point blue_X, blue_Y, blue_Z;\n} png_XYZ;\n#endif /* COLORSPACE */\n\n#if defined(PNG_COLORSPACE_SUPPORTED) || defined(PNG_GAMMA_SUPPORTED)\n/* A colorspace is all the above plus, potentially, profile information,\n * however at present libpng does not use the profile internally so it is only\n * stored in the png_info struct (if iCCP is supported.)  The rendering intent\n * is retained here and is checked.\n *\n * The file gamma encoding information is also stored here and gamma correction\n * is done by libpng, whereas color correction must currently be done by the\n * application.\n */\ntypedef struct png_colorspace\n{\n#ifdef PNG_GAMMA_SUPPORTED\n   png_fixed_point gamma;        /* File gamma */\n#endif\n\n#ifdef PNG_COLORSPACE_SUPPORTED\n   png_xy      end_points_xy;    /* End points as chromaticities */\n   png_XYZ     end_points_XYZ;   /* End points as CIE XYZ colorant values */\n   png_uint_16 rendering_intent; /* Rendering intent of a profile */\n#endif\n\n   /* Flags are always defined to simplify the code. */\n   png_uint_16 flags;            /* As defined below */\n} png_colorspace, * PNG_RESTRICT png_colorspacerp;\n\ntypedef const png_colorspace * PNG_RESTRICT png_const_colorspacerp;\n\n/* General flags for the 'flags' field */\n#define PNG_COLORSPACE_HAVE_GAMMA           0x0001\n#define PNG_COLORSPACE_HAVE_ENDPOINTS       0x0002\n#define PNG_COLORSPACE_HAVE_INTENT          0x0004\n#define PNG_COLORSPACE_FROM_gAMA            0x0008\n#define PNG_COLORSPACE_FROM_cHRM            0x0010\n#define PNG_COLORSPACE_FROM_sRGB            0x0020\n#define PNG_COLORSPACE_ENDPOINTS_MATCH_sRGB 0x0040\n#define PNG_COLORSPACE_MATCHES_sRGB         0x0080 /* exact match on profile */\n#define PNG_COLORSPACE_INVALID              0x8000\n#define PNG_COLORSPACE_CANCEL(flags)        (0xffff ^ (flags))\n#endif /* COLORSPACE || GAMMA */\n\nstruct png_struct_def\n{\n#ifdef PNG_SETJMP_SUPPORTED\n   jmp_buf jmp_buf_local;     /* New name in 1.6.0 for jmp_buf in png_struct */\n   png_longjmp_ptr longjmp_fn;/* setjmp non-local goto function. */\n   jmp_buf *jmp_buf_ptr;      /* passed to longjmp_fn */\n   size_t jmp_buf_size;       /* size of the above, if allocated */\n#endif\n   png_error_ptr error_fn;    /* function for printing errors and aborting */\n#ifdef PNG_WARNINGS_SUPPORTED\n   png_error_ptr warning_fn;  /* function for printing warnings */\n#endif\n   png_voidp error_ptr;       /* user supplied struct for error functions */\n   png_rw_ptr write_data_fn;  /* function for writing output data */\n   png_rw_ptr read_data_fn;   /* function for reading input data */\n   png_voidp io_ptr;          /* ptr to application struct for I/O functions */\n\n#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED\n   png_user_transform_ptr read_user_transform_fn; /* user read transform */\n#endif\n\n#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED\n   png_user_transform_ptr write_user_transform_fn; /* user write transform */\n#endif\n\n/* These were added in libpng-1.0.2 */\n#ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED\n#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \\\n    defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)\n   png_voidp user_transform_ptr; /* user supplied struct for user transform */\n   png_byte user_transform_depth;    /* bit depth of user transformed pixels */\n   png_byte user_transform_channels; /* channels in user transformed pixels */\n#endif\n#endif\n\n   png_uint_32 mode;          /* tells us where we are in the PNG file */\n   png_uint_32 flags;         /* flags indicating various things to libpng */\n   png_uint_32 transformations; /* which transformations to perform */\n\n   png_uint_32 zowner;        /* ID (chunk type) of zstream owner, 0 if none */\n   z_stream    zstream;       /* decompression structure */\n\n#ifdef PNG_WRITE_SUPPORTED\n   png_compression_bufferp zbuffer_list; /* Created on demand during write */\n   uInt                    zbuffer_size; /* size of the actual buffer */\n\n   int zlib_level;            /* holds zlib compression level */\n   int zlib_method;           /* holds zlib compression method */\n   int zlib_window_bits;      /* holds zlib compression window bits */\n   int zlib_mem_level;        /* holds zlib compression memory level */\n   int zlib_strategy;         /* holds zlib compression strategy */\n#endif\n/* Added at libpng 1.5.4 */\n#ifdef PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED\n   int zlib_text_level;            /* holds zlib compression level */\n   int zlib_text_method;           /* holds zlib compression method */\n   int zlib_text_window_bits;      /* holds zlib compression window bits */\n   int zlib_text_mem_level;        /* holds zlib compression memory level */\n   int zlib_text_strategy;         /* holds zlib compression strategy */\n#endif\n/* End of material added at libpng 1.5.4 */\n/* Added at libpng 1.6.0 */\n#ifdef PNG_WRITE_SUPPORTED\n   int zlib_set_level;        /* Actual values set into the zstream on write */\n   int zlib_set_method;\n   int zlib_set_window_bits;\n   int zlib_set_mem_level;\n   int zlib_set_strategy;\n#endif\n\n   png_uint_32 width;         /* width of image in pixels */\n   png_uint_32 height;        /* height of image in pixels */\n   png_uint_32 num_rows;      /* number of rows in current pass */\n   png_uint_32 usr_width;     /* width of row at start of write */\n   png_size_t rowbytes;       /* size of row in bytes */\n   png_uint_32 iwidth;        /* width of current interlaced row in pixels */\n   png_uint_32 row_number;    /* current row in interlace pass */\n   png_uint_32 chunk_name;    /* PNG_CHUNK() id of current chunk */\n   png_bytep prev_row;        /* buffer to save previous (unfiltered) row.\n                               * This is a pointer into big_prev_row\n                               */\n   png_bytep row_buf;         /* buffer to save current (unfiltered) row.\n                               * This is a pointer into big_row_buf\n                               */\n#ifdef PNG_WRITE_SUPPORTED\n   png_bytep sub_row;         /* buffer to save \"sub\" row when filtering */\n   png_bytep up_row;          /* buffer to save \"up\" row when filtering */\n   png_bytep avg_row;         /* buffer to save \"avg\" row when filtering */\n   png_bytep paeth_row;       /* buffer to save \"Paeth\" row when filtering */\n#endif\n   png_size_t info_rowbytes;  /* Added in 1.5.4: cache of updated row bytes */\n\n   png_uint_32 idat_size;     /* current IDAT size for read */\n   png_uint_32 crc;           /* current chunk CRC value */\n   png_colorp palette;        /* palette from the input file */\n   png_uint_16 num_palette;   /* number of color entries in palette */\n\n/* Added at libpng-1.5.10 */\n#ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED\n   int num_palette_max;       /* maximum palette index found in IDAT */\n#endif\n\n   png_uint_16 num_trans;     /* number of transparency values */\n   png_byte compression;      /* file compression type (always 0) */\n   png_byte filter;           /* file filter type (always 0) */\n   png_byte interlaced;       /* PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */\n   png_byte pass;             /* current interlace pass (0 - 6) */\n   png_byte do_filter;        /* row filter flags (see PNG_FILTER_ below ) */\n   png_byte color_type;       /* color type of file */\n   png_byte bit_depth;        /* bit depth of file */\n   png_byte usr_bit_depth;    /* bit depth of users row: write only */\n   png_byte pixel_depth;      /* number of bits per pixel */\n   png_byte channels;         /* number of channels in file */\n#ifdef PNG_WRITE_SUPPORTED\n   png_byte usr_channels;     /* channels at start of write: write only */\n#endif\n   png_byte sig_bytes;        /* magic bytes read/written from start of file */\n   png_byte maximum_pixel_depth;\n                              /* pixel depth used for the row buffers */\n   png_byte transformed_pixel_depth;\n                              /* pixel depth after read/write transforms */\n#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED)\n   png_uint_16 filler;           /* filler bytes for pixel expansion */\n#endif\n\n#if defined(PNG_bKGD_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) ||\\\n   defined(PNG_READ_ALPHA_MODE_SUPPORTED)\n   png_byte background_gamma_type;\n   png_fixed_point background_gamma;\n   png_color_16 background;   /* background color in screen gamma space */\n#ifdef PNG_READ_GAMMA_SUPPORTED\n   png_color_16 background_1; /* background normalized to gamma 1.0 */\n#endif\n#endif /* PNG_bKGD_SUPPORTED */\n\n#ifdef PNG_WRITE_FLUSH_SUPPORTED\n   png_flush_ptr output_flush_fn; /* Function for flushing output */\n   png_uint_32 flush_dist;    /* how many rows apart to flush, 0 - no flush */\n   png_uint_32 flush_rows;    /* number of rows written since last flush */\n#endif\n\n#ifdef PNG_READ_GAMMA_SUPPORTED\n   int gamma_shift;      /* number of \"insignificant\" bits in 16-bit gamma */\n   png_fixed_point screen_gamma; /* screen gamma value (display_exponent) */\n\n   png_bytep gamma_table;     /* gamma table for 8-bit depth files */\n   png_uint_16pp gamma_16_table; /* gamma table for 16-bit depth files */\n#if defined(PNG_READ_BACKGROUND_SUPPORTED) || \\\n   defined(PNG_READ_ALPHA_MODE_SUPPORTED) || \\\n   defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)\n   png_bytep gamma_from_1;    /* converts from 1.0 to screen */\n   png_bytep gamma_to_1;      /* converts from file to 1.0 */\n   png_uint_16pp gamma_16_from_1; /* converts from 1.0 to screen */\n   png_uint_16pp gamma_16_to_1; /* converts from file to 1.0 */\n#endif /* READ_BACKGROUND || READ_ALPHA_MODE || RGB_TO_GRAY */\n#endif\n\n#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_sBIT_SUPPORTED)\n   png_color_8 sig_bit;       /* significant bits in each available channel */\n#endif\n\n#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED)\n   png_color_8 shift;         /* shift for significant bit tranformation */\n#endif\n\n#if defined(PNG_tRNS_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) \\\n || defined(PNG_READ_EXPAND_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)\n   png_bytep trans_alpha;           /* alpha values for paletted files */\n   png_color_16 trans_color;  /* transparent color for non-paletted files */\n#endif\n\n   png_read_status_ptr read_row_fn;   /* called after each row is decoded */\n   png_write_status_ptr write_row_fn; /* called after each row is encoded */\n#ifdef PNG_PROGRESSIVE_READ_SUPPORTED\n   png_progressive_info_ptr info_fn; /* called after header data fully read */\n   png_progressive_row_ptr row_fn;   /* called after a prog. row is decoded */\n   png_progressive_end_ptr end_fn;   /* called after image is complete */\n   png_bytep save_buffer_ptr;        /* current location in save_buffer */\n   png_bytep save_buffer;            /* buffer for previously read data */\n   png_bytep current_buffer_ptr;     /* current location in current_buffer */\n   png_bytep current_buffer;         /* buffer for recently used data */\n   png_uint_32 push_length;          /* size of current input chunk */\n   png_uint_32 skip_length;          /* bytes to skip in input data */\n   png_size_t save_buffer_size;      /* amount of data now in save_buffer */\n   png_size_t save_buffer_max;       /* total size of save_buffer */\n   png_size_t buffer_size;           /* total amount of available input data */\n   png_size_t current_buffer_size;   /* amount of data now in current_buffer */\n   int process_mode;                 /* what push library is currently doing */\n   int cur_palette;                  /* current push library palette index */\n\n#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */\n\n#if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__)\n/* For the Borland special 64K segment handler */\n   png_bytepp offset_table_ptr;\n   png_bytep offset_table;\n   png_uint_16 offset_table_number;\n   png_uint_16 offset_table_count;\n   png_uint_16 offset_table_count_free;\n#endif\n\n#ifdef PNG_READ_QUANTIZE_SUPPORTED\n   png_bytep palette_lookup; /* lookup table for quantizing */\n   png_bytep quantize_index; /* index translation for palette files */\n#endif\n\n#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED\n   png_byte heuristic_method;        /* heuristic for row filter selection */\n   png_byte num_prev_filters;        /* number of weights for previous rows */\n   png_bytep prev_filters;           /* filter type(s) of previous row(s) */\n   png_uint_16p filter_weights;      /* weight(s) for previous line(s) */\n   png_uint_16p inv_filter_weights;  /* 1/weight(s) for previous line(s) */\n   png_uint_16p filter_costs;        /* relative filter calculation cost */\n   png_uint_16p inv_filter_costs;    /* 1/relative filter calculation cost */\n#endif\n\n   /* Options */\n#ifdef PNG_SET_OPTION_SUPPORTED\n   png_byte options;           /* On/off state (up to 4 options) */\n#endif\n\n#if PNG_LIBPNG_VER < 10700\n/* To do: remove this from libpng-1.7 */\n#ifdef PNG_TIME_RFC1123_SUPPORTED\n   char time_buffer[29]; /* String to hold RFC 1123 time text */\n#endif\n#endif\n\n/* New members added in libpng-1.0.6 */\n\n   png_uint_32 free_me;    /* flags items libpng is responsible for freeing */\n\n#ifdef PNG_USER_CHUNKS_SUPPORTED\n   png_voidp user_chunk_ptr;\n#ifdef PNG_READ_USER_CHUNKS_SUPPORTED\n   png_user_chunk_ptr read_user_chunk_fn; /* user read chunk handler */\n#endif\n#endif\n\n#ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED\n   int          unknown_default; /* As PNG_HANDLE_* */\n   unsigned int num_chunk_list;  /* Number of entries in the list */\n   png_bytep    chunk_list;      /* List of png_byte[5]; the textual chunk name\n                                  * followed by a PNG_HANDLE_* byte */\n#endif\n\n/* New members added in libpng-1.0.3 */\n#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED\n   png_byte rgb_to_gray_status;\n   /* Added in libpng 1.5.5 to record setting of coefficients: */\n   png_byte rgb_to_gray_coefficients_set;\n   /* These were changed from png_byte in libpng-1.0.6 */\n   png_uint_16 rgb_to_gray_red_coeff;\n   png_uint_16 rgb_to_gray_green_coeff;\n   /* deleted in 1.5.5: rgb_to_gray_blue_coeff; */\n#endif\n\n/* New member added in libpng-1.0.4 (renamed in 1.0.9) */\n#if defined(PNG_MNG_FEATURES_SUPPORTED)\n/* Changed from png_byte to png_uint_32 at version 1.2.0 */\n   png_uint_32 mng_features_permitted;\n#endif\n\n/* New member added in libpng-1.0.9, ifdef'ed out in 1.0.12, enabled in 1.2.0 */\n#ifdef PNG_MNG_FEATURES_SUPPORTED\n   png_byte filter_type;\n#endif\n\n/* New members added in libpng-1.2.0 */\n\n/* New members added in libpng-1.0.2 but first enabled by default in 1.2.0 */\n#ifdef PNG_USER_MEM_SUPPORTED\n   png_voidp mem_ptr;             /* user supplied struct for mem functions */\n   png_malloc_ptr malloc_fn;      /* function for allocating memory */\n   png_free_ptr free_fn;          /* function for freeing memory */\n#endif\n\n/* New member added in libpng-1.0.13 and 1.2.0 */\n   png_bytep big_row_buf;         /* buffer to save current (unfiltered) row */\n\n#ifdef PNG_READ_QUANTIZE_SUPPORTED\n/* The following three members were added at version 1.0.14 and 1.2.4 */\n   png_bytep quantize_sort;          /* working sort array */\n   png_bytep index_to_palette;       /* where the original index currently is\n                                        in the palette */\n   png_bytep palette_to_index;       /* which original index points to this\n                                         palette color */\n#endif\n\n/* New members added in libpng-1.0.16 and 1.2.6 */\n   png_byte compression_type;\n\n#ifdef PNG_USER_LIMITS_SUPPORTED\n   png_uint_32 user_width_max;\n   png_uint_32 user_height_max;\n\n   /* Added in libpng-1.4.0: Total number of sPLT, text, and unknown\n    * chunks that can be stored (0 means unlimited).\n    */\n   png_uint_32 user_chunk_cache_max;\n\n   /* Total memory that a zTXt, sPLT, iTXt, iCCP, or unknown chunk\n    * can occupy when decompressed.  0 means unlimited.\n    */\n   png_alloc_size_t user_chunk_malloc_max;\n#endif\n\n/* New member added in libpng-1.0.25 and 1.2.17 */\n#ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED\n   /* Temporary storage for unknown chunk that the library doesn't recognize,\n    * used while reading the chunk.\n    */\n   png_unknown_chunk unknown_chunk;\n#endif\n\n/* New member added in libpng-1.2.26 */\n  png_size_t old_big_row_buf_size;\n\n#ifdef PNG_READ_SUPPORTED\n/* New member added in libpng-1.2.30 */\n  png_bytep        read_buffer;      /* buffer for reading chunk data */\n  png_alloc_size_t read_buffer_size; /* current size of the buffer */\n#endif\n#ifdef PNG_SEQUENTIAL_READ_SUPPORTED\n  uInt             IDAT_read_size;   /* limit on read buffer size for IDAT */\n#endif\n\n#ifdef PNG_IO_STATE_SUPPORTED\n/* New member added in libpng-1.4.0 */\n   png_uint_32 io_state;\n#endif\n\n/* New member added in libpng-1.5.6 */\n   png_bytep big_prev_row;\n\n/* New member added in libpng-1.5.7 */\n   void (*read_filter[PNG_FILTER_VALUE_LAST-1])(png_row_infop row_info,\n      png_bytep row, png_const_bytep prev_row);\n\n#ifdef PNG_READ_SUPPORTED\n#if defined(PNG_COLORSPACE_SUPPORTED) || defined(PNG_GAMMA_SUPPORTED)\n   png_colorspace   colorspace;\n#endif\n#endif\n};\n#endif /* PNGSTRUCT_H */\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/rapidxml/rapidxml.hpp",
    "content": "#ifndef RAPIDXML_HPP_INCLUDED\r\n#define RAPIDXML_HPP_INCLUDED\r\n\r\n// Copyright (C) 2006, 2009 Marcin Kalicinski\r\n// Version 1.13\r\n// Revision $DateTime: 2009/05/13 01:46:17 $\r\n//! \\file rapidxml.hpp This file contains rapidxml parser and DOM implementation\r\n\r\n// If standard library is disabled, user must provide implementations of required functions and typedefs\r\n#if !defined(RAPIDXML_NO_STDLIB)\r\n    #include <cstdlib>      // For std::size_t\r\n    #include <cassert>      // For assert\r\n    #include <new>          // For placement new\r\n#endif\r\n\r\n// On MSVC, disable \"conditional expression is constant\" warning (level 4). \r\n// This warning is almost impossible to avoid with certain types of templated code\r\n#ifdef _MSC_VER\r\n    #pragma warning(push)\r\n    #pragma warning(disable:4127)   // Conditional expression is constant\r\n#endif\r\n\r\n///////////////////////////////////////////////////////////////////////////\r\n// RAPIDXML_PARSE_ERROR\r\n    \r\n#if defined(RAPIDXML_NO_EXCEPTIONS)\r\n\r\n#define RAPIDXML_PARSE_ERROR(what, where) { parse_error_handler(what, where); assert(0); }\r\n\r\nnamespace rapidxml\r\n{\r\n    //! When exceptions are disabled by defining RAPIDXML_NO_EXCEPTIONS, \r\n    //! this function is called to notify user about the error.\r\n    //! It must be defined by the user.\r\n    //! <br><br>\r\n    //! This function cannot return. If it does, the results are undefined.\r\n    //! <br><br>\r\n    //! A very simple definition might look like that:\r\n    //! <pre>\r\n    //! void %rapidxml::%parse_error_handler(const char *what, void *where)\r\n    //! {\r\n    //!     std::cout << \"Parse error: \" << what << \"\\n\";\r\n    //!     std::abort();\r\n    //! }\r\n    //! </pre>\r\n    //! \\param what Human readable description of the error.\r\n    //! \\param where Pointer to character data where error was detected.\r\n    void parse_error_handler(const char *what, void *where);\r\n}\r\n\r\n#else\r\n    \r\n#include <exception>    // For std::exception\r\n\r\n#define RAPIDXML_PARSE_ERROR(what, where) throw parse_error(what, where)\r\n\r\nnamespace rapidxml\r\n{\r\n\r\n    //! Parse error exception. \r\n    //! This exception is thrown by the parser when an error occurs. \r\n    //! Use what() function to get human-readable error message. \r\n    //! Use where() function to get a pointer to position within source text where error was detected.\r\n    //! <br><br>\r\n    //! If throwing exceptions by the parser is undesirable, \r\n    //! it can be disabled by defining RAPIDXML_NO_EXCEPTIONS macro before rapidxml.hpp is included.\r\n    //! This will cause the parser to call rapidxml::parse_error_handler() function instead of throwing an exception.\r\n    //! This function must be defined by the user.\r\n    //! <br><br>\r\n    //! This class derives from <code>std::exception</code> class.\r\n    class parse_error: public std::exception\r\n    {\r\n    \r\n    public:\r\n    \r\n        //! Constructs parse error\r\n        parse_error(const char *what, void *where)\r\n            : m_what(what)\r\n            , m_where(where)\r\n        {\r\n        }\r\n\r\n        //! Gets human readable description of error.\r\n        //! \\return Pointer to null terminated description of the error.\r\n        virtual const char *what() const throw()\r\n        {\r\n            return m_what;\r\n        }\r\n\r\n        //! Gets pointer to character data where error happened.\r\n        //! Ch should be the same as char type of xml_document that produced the error.\r\n        //! \\return Pointer to location within the parsed string where error occured.\r\n        template<class Ch>\r\n        Ch *where() const\r\n        {\r\n            return reinterpret_cast<Ch *>(m_where);\r\n        }\r\n\r\n    private:  \r\n\r\n        const char *m_what;\r\n        void *m_where;\r\n\r\n    };\r\n}\r\n\r\n#endif\r\n\r\n///////////////////////////////////////////////////////////////////////////\r\n// Pool sizes\r\n\r\n#ifndef RAPIDXML_STATIC_POOL_SIZE\r\n    // Size of static memory block of memory_pool.\r\n    // Define RAPIDXML_STATIC_POOL_SIZE before including rapidxml.hpp if you want to override the default value.\r\n    // No dynamic memory allocations are performed by memory_pool until static memory is exhausted.\r\n    #define RAPIDXML_STATIC_POOL_SIZE (64 * 1024)\r\n#endif\r\n\r\n#ifndef RAPIDXML_DYNAMIC_POOL_SIZE\r\n    // Size of dynamic memory block of memory_pool.\r\n    // Define RAPIDXML_DYNAMIC_POOL_SIZE before including rapidxml.hpp if you want to override the default value.\r\n    // After the static block is exhausted, dynamic blocks with approximately this size are allocated by memory_pool.\r\n    #define RAPIDXML_DYNAMIC_POOL_SIZE (64 * 1024)\r\n#endif\r\n\r\n#ifndef RAPIDXML_ALIGNMENT\r\n    // Memory allocation alignment.\r\n    // Define RAPIDXML_ALIGNMENT before including rapidxml.hpp if you want to override the default value, which is the size of pointer.\r\n    // All memory allocations for nodes, attributes and strings will be aligned to this value.\r\n    // This must be a power of 2 and at least 1, otherwise memory_pool will not work.\r\n    #define RAPIDXML_ALIGNMENT sizeof(void *)\r\n#endif\r\n\r\nnamespace rapidxml\r\n{\r\n    // Forward declarations\r\n    template<class Ch> class xml_node;\r\n    template<class Ch> class xml_attribute;\r\n    template<class Ch> class xml_document;\r\n    \r\n    //! Enumeration listing all node types produced by the parser.\r\n    //! Use xml_node::type() function to query node type.\r\n    enum node_type\r\n    {\r\n        node_document,      //!< A document node. Name and value are empty.\r\n        node_element,       //!< An element node. Name contains element name. Value contains text of first data node.\r\n        node_data,          //!< A data node. Name is empty. Value contains data text.\r\n        node_cdata,         //!< A CDATA node. Name is empty. Value contains data text.\r\n        node_comment,       //!< A comment node. Name is empty. Value contains comment text.\r\n        node_declaration,   //!< A declaration node. Name and value are empty. Declaration parameters (version, encoding and standalone) are in node attributes.\r\n        node_doctype,       //!< A DOCTYPE node. Name is empty. Value contains DOCTYPE text.\r\n        node_pi             //!< A PI node. Name contains target. Value contains instructions.\r\n    };\r\n\r\n    ///////////////////////////////////////////////////////////////////////\r\n    // Parsing flags\r\n\r\n    //! Parse flag instructing the parser to not create data nodes. \r\n    //! Text of first data node will still be placed in value of parent element, unless rapidxml::parse_no_element_values flag is also specified.\r\n    //! Can be combined with other flags by use of | operator.\r\n    //! <br><br>\r\n    //! See xml_document::parse() function.\r\n    const int parse_no_data_nodes = 0x1;            \r\n\r\n    //! Parse flag instructing the parser to not use text of first data node as a value of parent element.\r\n    //! Can be combined with other flags by use of | operator.\r\n    //! Note that child data nodes of element node take precendence over its value when printing. \r\n    //! That is, if element has one or more child data nodes <em>and</em> a value, the value will be ignored.\r\n    //! Use rapidxml::parse_no_data_nodes flag to prevent creation of data nodes if you want to manipulate data using values of elements.\r\n    //! <br><br>\r\n    //! See xml_document::parse() function.\r\n    const int parse_no_element_values = 0x2;\r\n    \r\n    //! Parse flag instructing the parser to not place zero terminators after strings in the source text.\r\n    //! By default zero terminators are placed, modifying source text.\r\n    //! Can be combined with other flags by use of | operator.\r\n    //! <br><br>\r\n    //! See xml_document::parse() function.\r\n    const int parse_no_string_terminators = 0x4;\r\n    \r\n    //! Parse flag instructing the parser to not translate entities in the source text.\r\n    //! By default entities are translated, modifying source text.\r\n    //! Can be combined with other flags by use of | operator.\r\n    //! <br><br>\r\n    //! See xml_document::parse() function.\r\n    const int parse_no_entity_translation = 0x8;\r\n    \r\n    //! Parse flag instructing the parser to disable UTF-8 handling and assume plain 8 bit characters.\r\n    //! By default, UTF-8 handling is enabled.\r\n    //! Can be combined with other flags by use of | operator.\r\n    //! <br><br>\r\n    //! See xml_document::parse() function.\r\n    const int parse_no_utf8 = 0x10;\r\n    \r\n    //! Parse flag instructing the parser to create XML declaration node.\r\n    //! By default, declaration node is not created.\r\n    //! Can be combined with other flags by use of | operator.\r\n    //! <br><br>\r\n    //! See xml_document::parse() function.\r\n    const int parse_declaration_node = 0x20;\r\n    \r\n    //! Parse flag instructing the parser to create comments nodes.\r\n    //! By default, comment nodes are not created.\r\n    //! Can be combined with other flags by use of | operator.\r\n    //! <br><br>\r\n    //! See xml_document::parse() function.\r\n    const int parse_comment_nodes = 0x40;\r\n    \r\n    //! Parse flag instructing the parser to create DOCTYPE node.\r\n    //! By default, doctype node is not created.\r\n    //! Although W3C specification allows at most one DOCTYPE node, RapidXml will silently accept documents with more than one.\r\n    //! Can be combined with other flags by use of | operator.\r\n    //! <br><br>\r\n    //! See xml_document::parse() function.\r\n    const int parse_doctype_node = 0x80;\r\n    \r\n    //! Parse flag instructing the parser to create PI nodes.\r\n    //! By default, PI nodes are not created.\r\n    //! Can be combined with other flags by use of | operator.\r\n    //! <br><br>\r\n    //! See xml_document::parse() function.\r\n    const int parse_pi_nodes = 0x100;\r\n    \r\n    //! Parse flag instructing the parser to validate closing tag names. \r\n    //! If not set, name inside closing tag is irrelevant to the parser.\r\n    //! By default, closing tags are not validated.\r\n    //! Can be combined with other flags by use of | operator.\r\n    //! <br><br>\r\n    //! See xml_document::parse() function.\r\n    const int parse_validate_closing_tags = 0x200;\r\n    \r\n    //! Parse flag instructing the parser to trim all leading and trailing whitespace of data nodes.\r\n    //! By default, whitespace is not trimmed. \r\n    //! This flag does not cause the parser to modify source text.\r\n    //! Can be combined with other flags by use of | operator.\r\n    //! <br><br>\r\n    //! See xml_document::parse() function.\r\n    const int parse_trim_whitespace = 0x400;\r\n\r\n    //! Parse flag instructing the parser to condense all whitespace runs of data nodes to a single space character.\r\n    //! Trimming of leading and trailing whitespace of data is controlled by rapidxml::parse_trim_whitespace flag.\r\n    //! By default, whitespace is not normalized. \r\n    //! If this flag is specified, source text will be modified.\r\n    //! Can be combined with other flags by use of | operator.\r\n    //! <br><br>\r\n    //! See xml_document::parse() function.\r\n    const int parse_normalize_whitespace = 0x800;\r\n\r\n    // Compound flags\r\n    \r\n    //! Parse flags which represent default behaviour of the parser. \r\n    //! This is always equal to 0, so that all other flags can be simply ored together.\r\n    //! Normally there is no need to inconveniently disable flags by anding with their negated (~) values.\r\n    //! This also means that meaning of each flag is a <i>negation</i> of the default setting. \r\n    //! For example, if flag name is rapidxml::parse_no_utf8, it means that utf-8 is <i>enabled</i> by default,\r\n    //! and using the flag will disable it.\r\n    //! <br><br>\r\n    //! See xml_document::parse() function.\r\n    const int parse_default = 0;\r\n    \r\n    //! A combination of parse flags that forbids any modifications of the source text. \r\n    //! This also results in faster parsing. However, note that the following will occur:\r\n    //! <ul>\r\n    //! <li>names and values of nodes will not be zero terminated, you have to use xml_base::name_size() and xml_base::value_size() functions to determine where name and value ends</li>\r\n    //! <li>entities will not be translated</li>\r\n    //! <li>whitespace will not be normalized</li>\r\n    //! </ul>\r\n    //! See xml_document::parse() function.\r\n    const int parse_non_destructive = parse_no_string_terminators | parse_no_entity_translation;\r\n    \r\n    //! A combination of parse flags resulting in fastest possible parsing, without sacrificing important data.\r\n    //! <br><br>\r\n    //! See xml_document::parse() function.\r\n    const int parse_fastest = parse_non_destructive | parse_no_data_nodes;\r\n    \r\n    //! A combination of parse flags resulting in largest amount of data being extracted. \r\n    //! This usually results in slowest parsing.\r\n    //! <br><br>\r\n    //! See xml_document::parse() function.\r\n    const int parse_full = parse_declaration_node | parse_comment_nodes | parse_doctype_node | parse_pi_nodes | parse_validate_closing_tags;\r\n\r\n    ///////////////////////////////////////////////////////////////////////\r\n    // Internals\r\n\r\n    //! \\cond internal\r\n    namespace internal\r\n    {\r\n\r\n        // Struct that contains lookup tables for the parser\r\n        // It must be a template to allow correct linking (because it has static data members, which are defined in a header file).\r\n        template<int Dummy>\r\n        struct lookup_tables\r\n        {\r\n            static const unsigned char lookup_whitespace[256];              // Whitespace table\r\n            static const unsigned char lookup_node_name[256];               // Node name table\r\n            static const unsigned char lookup_text[256];                    // Text table\r\n            static const unsigned char lookup_text_pure_no_ws[256];         // Text table\r\n            static const unsigned char lookup_text_pure_with_ws[256];       // Text table\r\n            static const unsigned char lookup_attribute_name[256];          // Attribute name table\r\n            static const unsigned char lookup_attribute_data_1[256];        // Attribute data table with single quote\r\n            static const unsigned char lookup_attribute_data_1_pure[256];   // Attribute data table with single quote\r\n            static const unsigned char lookup_attribute_data_2[256];        // Attribute data table with double quotes\r\n            static const unsigned char lookup_attribute_data_2_pure[256];   // Attribute data table with double quotes\r\n            static const unsigned char lookup_digits[256];                  // Digits\r\n            static const unsigned char lookup_upcase[256];                  // To uppercase conversion table for ASCII characters\r\n        };\r\n\r\n        // Find length of the string\r\n        template<class Ch>\r\n        inline std::size_t measure(const Ch *p)\r\n        {\r\n            const Ch *tmp = p;\r\n            while (*tmp) \r\n                ++tmp;\r\n            return tmp - p;\r\n        }\r\n\r\n        // Compare strings for equality\r\n        template<class Ch>\r\n        inline bool compare(const Ch *p1, std::size_t size1, const Ch *p2, std::size_t size2, bool case_sensitive)\r\n        {\r\n            if (size1 != size2)\r\n                return false;\r\n            if (case_sensitive)\r\n            {\r\n                for (const Ch *end = p1 + size1; p1 < end; ++p1, ++p2)\r\n                    if (*p1 != *p2)\r\n                        return false;\r\n            }\r\n            else\r\n            {\r\n                for (const Ch *end = p1 + size1; p1 < end; ++p1, ++p2)\r\n                    if (lookup_tables<0>::lookup_upcase[static_cast<unsigned char>(*p1)] != lookup_tables<0>::lookup_upcase[static_cast<unsigned char>(*p2)])\r\n                        return false;\r\n            }\r\n            return true;\r\n        }\r\n    }\r\n    //! \\endcond\r\n\r\n    ///////////////////////////////////////////////////////////////////////\r\n    // Memory pool\r\n    \r\n    //! This class is used by the parser to create new nodes and attributes, without overheads of dynamic memory allocation.\r\n    //! In most cases, you will not need to use this class directly. \r\n    //! However, if you need to create nodes manually or modify names/values of nodes, \r\n    //! you are encouraged to use memory_pool of relevant xml_document to allocate the memory. \r\n    //! Not only is this faster than allocating them by using <code>new</code> operator, \r\n    //! but also their lifetime will be tied to the lifetime of document, \r\n    //! possibly simplyfing memory management. \r\n    //! <br><br>\r\n    //! Call allocate_node() or allocate_attribute() functions to obtain new nodes or attributes from the pool. \r\n    //! You can also call allocate_string() function to allocate strings.\r\n    //! Such strings can then be used as names or values of nodes without worrying about their lifetime.\r\n    //! Note that there is no <code>free()</code> function -- all allocations are freed at once when clear() function is called, \r\n    //! or when the pool is destroyed.\r\n    //! <br><br>\r\n    //! It is also possible to create a standalone memory_pool, and use it \r\n    //! to allocate nodes, whose lifetime will not be tied to any document.\r\n    //! <br><br>\r\n    //! Pool maintains <code>RAPIDXML_STATIC_POOL_SIZE</code> bytes of statically allocated memory. \r\n    //! Until static memory is exhausted, no dynamic memory allocations are done.\r\n    //! When static memory is exhausted, pool allocates additional blocks of memory of size <code>RAPIDXML_DYNAMIC_POOL_SIZE</code> each,\r\n    //! by using global <code>new[]</code> and <code>delete[]</code> operators. \r\n    //! This behaviour can be changed by setting custom allocation routines. \r\n    //! Use set_allocator() function to set them.\r\n    //! <br><br>\r\n    //! Allocations for nodes, attributes and strings are aligned at <code>RAPIDXML_ALIGNMENT</code> bytes.\r\n    //! This value defaults to the size of pointer on target architecture.\r\n    //! <br><br>\r\n    //! To obtain absolutely top performance from the parser,\r\n    //! it is important that all nodes are allocated from a single, contiguous block of memory.\r\n    //! Otherwise, cache misses when jumping between two (or more) disjoint blocks of memory can slow down parsing quite considerably.\r\n    //! If required, you can tweak <code>RAPIDXML_STATIC_POOL_SIZE</code>, <code>RAPIDXML_DYNAMIC_POOL_SIZE</code> and <code>RAPIDXML_ALIGNMENT</code> \r\n    //! to obtain best wasted memory to performance compromise.\r\n    //! To do it, define their values before rapidxml.hpp file is included.\r\n    //! \\param Ch Character type of created nodes. \r\n    template<class Ch = char>\r\n    class memory_pool\r\n    {\r\n        \r\n    public:\r\n\r\n        //! \\cond internal\r\n        typedef void *(rapidxml_alloc_func)(std::size_t);       // Type of user-defined function used to allocate memory\r\n        typedef void (free_func)(void *);              // Type of user-defined function used to free memory\r\n        //! \\endcond\r\n        \r\n        //! Constructs empty pool with default allocator functions.\r\n        memory_pool()\r\n            : m_rapidxml_alloc_func(0)\r\n            , m_free_func(0)\r\n        {\r\n            init();\r\n        }\r\n\r\n        //! Destroys pool and frees all the memory. \r\n        //! This causes memory occupied by nodes allocated by the pool to be freed.\r\n        //! Nodes allocated from the pool are no longer valid.\r\n        ~memory_pool()\r\n        {\r\n            clear();\r\n        }\r\n\r\n        //! Allocates a new node from the pool, and optionally assigns name and value to it. \r\n        //! If the allocation request cannot be accomodated, this function will throw <code>std::bad_alloc</code>.\r\n        //! If exceptions are disabled by defining RAPIDXML_NO_EXCEPTIONS, this function\r\n        //! will call rapidxml::parse_error_handler() function.\r\n        //! \\param type Type of node to create.\r\n        //! \\param name Name to assign to the node, or 0 to assign no name.\r\n        //! \\param value Value to assign to the node, or 0 to assign no value.\r\n        //! \\param name_size Size of name to assign, or 0 to automatically calculate size from name string.\r\n        //! \\param value_size Size of value to assign, or 0 to automatically calculate size from value string.\r\n        //! \\return Pointer to allocated node. This pointer will never be NULL.\r\n        xml_node<Ch> *allocate_node(node_type type, \r\n                                    const Ch *name = 0, const Ch *value = 0, \r\n                                    std::size_t name_size = 0, std::size_t value_size = 0)\r\n        {\r\n            void *memory = allocate_aligned(sizeof(xml_node<Ch>));\r\n            xml_node<Ch> *node = new(memory) xml_node<Ch>(type);\r\n            if (name)\r\n            {\r\n                if (name_size > 0)\r\n                    node->name(name, name_size);\r\n                else\r\n                    node->name(name);\r\n            }\r\n            if (value)\r\n            {\r\n                if (value_size > 0)\r\n                    node->value(value, value_size);\r\n                else\r\n                    node->value(value);\r\n            }\r\n            return node;\r\n        }\r\n\r\n        //! Allocates a new attribute from the pool, and optionally assigns name and value to it.\r\n        //! If the allocation request cannot be accomodated, this function will throw <code>std::bad_alloc</code>.\r\n        //! If exceptions are disabled by defining RAPIDXML_NO_EXCEPTIONS, this function\r\n        //! will call rapidxml::parse_error_handler() function.\r\n        //! \\param name Name to assign to the attribute, or 0 to assign no name.\r\n        //! \\param value Value to assign to the attribute, or 0 to assign no value.\r\n        //! \\param name_size Size of name to assign, or 0 to automatically calculate size from name string.\r\n        //! \\param value_size Size of value to assign, or 0 to automatically calculate size from value string.\r\n        //! \\return Pointer to allocated attribute. This pointer will never be NULL.\r\n        xml_attribute<Ch> *allocate_attribute(const Ch *name = 0, const Ch *value = 0, \r\n                                              std::size_t name_size = 0, std::size_t value_size = 0)\r\n        {\r\n            void *memory = allocate_aligned(sizeof(xml_attribute<Ch>));\r\n            xml_attribute<Ch> *attribute = new(memory) xml_attribute<Ch>;\r\n            if (name)\r\n            {\r\n                if (name_size > 0)\r\n                    attribute->name(name, name_size);\r\n                else\r\n                    attribute->name(name);\r\n            }\r\n            if (value)\r\n            {\r\n                if (value_size > 0)\r\n                    attribute->value(value, value_size);\r\n                else\r\n                    attribute->value(value);\r\n            }\r\n            return attribute;\r\n        }\r\n\r\n        //! Allocates a char array of given size from the pool, and optionally copies a given string to it.\r\n        //! If the allocation request cannot be accomodated, this function will throw <code>std::bad_alloc</code>.\r\n        //! If exceptions are disabled by defining RAPIDXML_NO_EXCEPTIONS, this function\r\n        //! will call rapidxml::parse_error_handler() function.\r\n        //! \\param source String to initialize the allocated memory with, or 0 to not initialize it.\r\n        //! \\param size Number of characters to allocate, or zero to calculate it automatically from source string length; if size is 0, source string must be specified and null terminated.\r\n        //! \\return Pointer to allocated char array. This pointer will never be NULL.\r\n        Ch *allocate_string(const Ch *source = 0, std::size_t size = 0)\r\n        {\r\n            assert(source || size);     // Either source or size (or both) must be specified\r\n            if (size == 0)\r\n                size = internal::measure(source) + 1;\r\n            Ch *result = static_cast<Ch *>(allocate_aligned(size * sizeof(Ch)));\r\n            if (source)\r\n                for (std::size_t i = 0; i < size; ++i)\r\n                    result[i] = source[i];\r\n            return result;\r\n        }\r\n\r\n        //! Clones an xml_node and its hierarchy of child nodes and attributes.\r\n        //! Nodes and attributes are allocated from this memory pool.\r\n        //! Names and values are not cloned, they are shared between the clone and the source.\r\n        //! Result node can be optionally specified as a second parameter, \r\n        //! in which case its contents will be replaced with cloned source node.\r\n        //! This is useful when you want to clone entire document.\r\n        //! \\param source Node to clone.\r\n        //! \\param result Node to put results in, or 0 to automatically allocate result node\r\n        //! \\return Pointer to cloned node. This pointer will never be NULL.\r\n        xml_node<Ch> *clone_node(const xml_node<Ch> *source, xml_node<Ch> *result = 0)\r\n        {\r\n            // Prepare result node\r\n            if (result)\r\n            {\r\n                result->remove_all_attributes();\r\n                result->remove_all_nodes();\r\n                result->type(source->type());\r\n            }\r\n            else\r\n                result = allocate_node(source->type());\r\n\r\n            // Clone name and value\r\n            result->name(source->name(), source->name_size());\r\n            result->value(source->value(), source->value_size());\r\n\r\n            // Clone child nodes and attributes\r\n            for (xml_node<Ch> *child = source->first_node(); child; child = child->next_sibling())\r\n                result->append_node(clone_node(child));\r\n            for (xml_attribute<Ch> *attr = source->first_attribute(); attr; attr = attr->next_attribute())\r\n                result->append_attribute(allocate_attribute(attr->name(), attr->value(), attr->name_size(), attr->value_size()));\r\n\r\n            return result;\r\n        }\r\n\r\n        //! Clears the pool. \r\n        //! This causes memory occupied by nodes allocated by the pool to be freed.\r\n        //! Any nodes or strings allocated from the pool will no longer be valid.\r\n        void clear()\r\n        {\r\n            while (m_begin != m_static_memory)\r\n            {\r\n                char *previous_begin = reinterpret_cast<header *>(align(m_begin))->previous_begin;\r\n                if (m_free_func)\r\n                    m_free_func(m_begin);\r\n                else\r\n                    delete[] m_begin;\r\n                m_begin = previous_begin;\r\n            }\r\n            init();\r\n        }\r\n\r\n        //! Sets or resets the user-defined memory allocation functions for the pool.\r\n        //! This can only be called when no memory is allocated from the pool yet, otherwise results are undefined.\r\n        //! Allocation function must not return invalid pointer on failure. It should either throw,\r\n        //! stop the program, or use <code>longjmp()</code> function to pass control to other place of program. \r\n        //! If it returns invalid pointer, results are undefined.\r\n        //! <br><br>\r\n        //! User defined allocation functions must have the following forms:\r\n        //! <br><code>\r\n        //! <br>void *allocate(std::size_t size);\r\n        //! <br>void free(void *pointer);\r\n        //! </code><br>\r\n        //! \\param af Allocation function, or 0 to restore default function\r\n        //! \\param ff Free function, or 0 to restore default function\r\n        void set_allocator(rapidxml_alloc_func *af, free_func *ff)\r\n        {\r\n            assert(m_begin == m_static_memory && m_ptr == align(m_begin));    // Verify that no memory is allocated yet\r\n            m_rapidxml_alloc_func = af;\r\n            m_free_func = ff;\r\n        }\r\n\r\n    private:\r\n\r\n        struct header\r\n        {\r\n            char *previous_begin;\r\n        };\r\n\r\n        void init()\r\n        {\r\n            m_begin = m_static_memory;\r\n            m_ptr = align(m_begin);\r\n            m_end = m_static_memory + sizeof(m_static_memory);\r\n        }\r\n        \r\n        char *align(char *ptr)\r\n        {\r\n            std::size_t alignment = ((RAPIDXML_ALIGNMENT - (std::size_t(ptr) & (RAPIDXML_ALIGNMENT - 1))) & (RAPIDXML_ALIGNMENT - 1));\r\n            return ptr + alignment;\r\n        }\r\n        \r\n        char *allocate_raw(std::size_t size)\r\n        {\r\n            // Allocate\r\n            void *memory;   \r\n            if (m_rapidxml_alloc_func)   // Allocate memory using either user-specified allocation function or global operator new[]\r\n            {\r\n                memory = m_rapidxml_alloc_func(size);\r\n                assert(memory); // Allocator is not allowed to return 0, on failure it must either throw, stop the program or use longjmp\r\n            }\r\n            else\r\n            {\r\n                memory = new char[size];\r\n#ifdef RAPIDXML_NO_EXCEPTIONS\r\n                if (!memory)            // If exceptions are disabled, verify memory allocation, because new will not be able to throw bad_alloc\r\n                    RAPIDXML_PARSE_ERROR(\"out of memory\", 0);\r\n#endif\r\n            }\r\n            return static_cast<char *>(memory);\r\n        }\r\n        \r\n        void *allocate_aligned(std::size_t size)\r\n        {\r\n            // Calculate aligned pointer\r\n            char *result = align(m_ptr);\r\n\r\n            // If not enough memory left in current pool, allocate a new pool\r\n            if (result + size > m_end)\r\n            {\r\n                // Calculate required pool size (may be bigger than RAPIDXML_DYNAMIC_POOL_SIZE)\r\n                std::size_t pool_size = RAPIDXML_DYNAMIC_POOL_SIZE;\r\n                if (pool_size < size)\r\n                    pool_size = size;\r\n                \r\n                // Allocate\r\n                std::size_t alloc_size = sizeof(header) + (2 * RAPIDXML_ALIGNMENT - 2) + pool_size;     // 2 alignments required in worst case: one for header, one for actual allocation\r\n                char *raw_memory = allocate_raw(alloc_size);\r\n                    \r\n                // Setup new pool in allocated memory\r\n                char *pool = align(raw_memory);\r\n                header *new_header = reinterpret_cast<header *>(pool);\r\n                new_header->previous_begin = m_begin;\r\n                m_begin = raw_memory;\r\n                m_ptr = pool + sizeof(header);\r\n                m_end = raw_memory + alloc_size;\r\n\r\n                // Calculate aligned pointer again using new pool\r\n                result = align(m_ptr);\r\n            }\r\n\r\n            // Update pool and return aligned pointer\r\n            m_ptr = result + size;\r\n            return result;\r\n        }\r\n\r\n        char *m_begin;                                      // Start of raw memory making up current pool\r\n        char *m_ptr;                                        // First free byte in current pool\r\n        char *m_end;                                        // One past last available byte in current pool\r\n        char m_static_memory[RAPIDXML_STATIC_POOL_SIZE];    // Static raw memory\r\n        rapidxml_alloc_func *m_rapidxml_alloc_func;                           // Allocator function, or 0 if default is to be used\r\n        free_func *m_free_func;                             // Free function, or 0 if default is to be used\r\n    };\r\n\r\n    ///////////////////////////////////////////////////////////////////////////\r\n    // XML base\r\n\r\n    //! Base class for xml_node and xml_attribute implementing common functions: \r\n    //! name(), name_size(), value(), value_size() and parent().\r\n    //! \\param Ch Character type to use\r\n    template<class Ch = char>\r\n    class xml_base\r\n    {\r\n\r\n    public:\r\n        \r\n        ///////////////////////////////////////////////////////////////////////////\r\n        // Construction & destruction\r\n    \r\n        // Construct a base with empty name, value and parent\r\n        xml_base()\r\n            : m_name(0)\r\n            , m_value(0)\r\n            , m_parent(0)\r\n        {\r\n        }\r\n\r\n        ///////////////////////////////////////////////////////////////////////////\r\n        // Node data access\r\n    \r\n        //! Gets name of the node. \r\n        //! Interpretation of name depends on type of node.\r\n        //! Note that name will not be zero-terminated if rapidxml::parse_no_string_terminators option was selected during parse.\r\n        //! <br><br>\r\n        //! Use name_size() function to determine length of the name.\r\n        //! \\return Name of node, or empty string if node has no name.\r\n        Ch *name() const\r\n        {\r\n            return m_name ? m_name : nullstr();\r\n        }\r\n\r\n        //! Gets size of node name, not including terminator character.\r\n        //! This function works correctly irrespective of whether name is or is not zero terminated.\r\n        //! \\return Size of node name, in characters.\r\n        std::size_t name_size() const\r\n        {\r\n            return m_name ? m_name_size : 0;\r\n        }\r\n\r\n        //! Gets value of node. \r\n        //! Interpretation of value depends on type of node.\r\n        //! Note that value will not be zero-terminated if rapidxml::parse_no_string_terminators option was selected during parse.\r\n        //! <br><br>\r\n        //! Use value_size() function to determine length of the value.\r\n        //! \\return Value of node, or empty string if node has no value.\r\n        Ch *value() const\r\n        {\r\n            return m_value ? m_value : nullstr();\r\n        }\r\n\r\n        //! Gets size of node value, not including terminator character.\r\n        //! This function works correctly irrespective of whether value is or is not zero terminated.\r\n        //! \\return Size of node value, in characters.\r\n        std::size_t value_size() const\r\n        {\r\n            return m_value ? m_value_size : 0;\r\n        }\r\n\r\n        ///////////////////////////////////////////////////////////////////////////\r\n        // Node modification\r\n    \r\n        //! Sets name of node to a non zero-terminated string.\r\n        //! See \\ref ownership_of_strings.\r\n        //! <br><br>\r\n        //! Note that node does not own its name or value, it only stores a pointer to it. \r\n        //! It will not delete or otherwise free the pointer on destruction.\r\n        //! It is reponsibility of the user to properly manage lifetime of the string.\r\n        //! The easiest way to achieve it is to use memory_pool of the document to allocate the string -\r\n        //! on destruction of the document the string will be automatically freed.\r\n        //! <br><br>\r\n        //! Size of name must be specified separately, because name does not have to be zero terminated.\r\n        //! Use name(const Ch *) function to have the length automatically calculated (string must be zero terminated).\r\n        //! \\param name Name of node to set. Does not have to be zero terminated.\r\n        //! \\param size Size of name, in characters. This does not include zero terminator, if one is present.\r\n        void name(const Ch *name, std::size_t size)\r\n        {\r\n            m_name = const_cast<Ch *>(name);\r\n            m_name_size = size;\r\n        }\r\n\r\n        //! Sets name of node to a zero-terminated string.\r\n        //! See also \\ref ownership_of_strings and xml_node::name(const Ch *, std::size_t).\r\n        //! \\param name Name of node to set. Must be zero terminated.\r\n        void name(const Ch *name)\r\n        {\r\n            this->name(name, internal::measure(name));\r\n        }\r\n\r\n        //! Sets value of node to a non zero-terminated string.\r\n        //! See \\ref ownership_of_strings.\r\n        //! <br><br>\r\n        //! Note that node does not own its name or value, it only stores a pointer to it. \r\n        //! It will not delete or otherwise free the pointer on destruction.\r\n        //! It is reponsibility of the user to properly manage lifetime of the string.\r\n        //! The easiest way to achieve it is to use memory_pool of the document to allocate the string -\r\n        //! on destruction of the document the string will be automatically freed.\r\n        //! <br><br>\r\n        //! Size of value must be specified separately, because it does not have to be zero terminated.\r\n        //! Use value(const Ch *) function to have the length automatically calculated (string must be zero terminated).\r\n        //! <br><br>\r\n        //! If an element has a child node of type node_data, it will take precedence over element value when printing.\r\n        //! If you want to manipulate data of elements using values, use parser flag rapidxml::parse_no_data_nodes to prevent creation of data nodes by the parser.\r\n        //! \\param value value of node to set. Does not have to be zero terminated.\r\n        //! \\param size Size of value, in characters. This does not include zero terminator, if one is present.\r\n        void value(const Ch *value, std::size_t size)\r\n        {\r\n            m_value = const_cast<Ch *>(value);\r\n            m_value_size = size;\r\n        }\r\n\r\n        //! Sets value of node to a zero-terminated string.\r\n        //! See also \\ref ownership_of_strings and xml_node::value(const Ch *, std::size_t).\r\n        //! \\param value Vame of node to set. Must be zero terminated.\r\n        void value(const Ch *value)\r\n        {\r\n            this->value(value, internal::measure(value));\r\n        }\r\n\r\n        ///////////////////////////////////////////////////////////////////////////\r\n        // Related nodes access\r\n    \r\n        //! Gets node parent.\r\n        //! \\return Pointer to parent node, or 0 if there is no parent.\r\n        xml_node<Ch> *parent() const\r\n        {\r\n            return m_parent;\r\n        }\r\n\r\n    protected:\r\n\r\n        // Return empty string\r\n        static Ch *nullstr()\r\n        {\r\n            static Ch zero = Ch('\\0');\r\n            return &zero;\r\n        }\r\n\r\n        Ch *m_name;                         // Name of node, or 0 if no name\r\n        Ch *m_value;                        // Value of node, or 0 if no value\r\n        std::size_t m_name_size;            // Length of node name, or undefined of no name\r\n        std::size_t m_value_size;           // Length of node value, or undefined if no value\r\n        xml_node<Ch> *m_parent;             // Pointer to parent node, or 0 if none\r\n\r\n    };\r\n\r\n    //! Class representing attribute node of XML document. \r\n    //! Each attribute has name and value strings, which are available through name() and value() functions (inherited from xml_base).\r\n    //! Note that after parse, both name and value of attribute will point to interior of source text used for parsing. \r\n    //! Thus, this text must persist in memory for the lifetime of attribute.\r\n    //! \\param Ch Character type to use.\r\n    template<class Ch = char>\r\n    class xml_attribute: public xml_base<Ch>\r\n    {\r\n\r\n        friend class xml_node<Ch>;\r\n    \r\n    public:\r\n\r\n        ///////////////////////////////////////////////////////////////////////////\r\n        // Construction & destruction\r\n    \r\n        //! Constructs an empty attribute with the specified type. \r\n        //! Consider using memory_pool of appropriate xml_document if allocating attributes manually.\r\n        xml_attribute()\r\n        {\r\n        }\r\n\r\n        ///////////////////////////////////////////////////////////////////////////\r\n        // Related nodes access\r\n    \r\n        //! Gets document of which attribute is a child.\r\n        //! \\return Pointer to document that contains this attribute, or 0 if there is no parent document.\r\n        xml_document<Ch> *document() const\r\n        {\r\n            if (xml_node<Ch> *node = this->parent())\r\n            {\r\n                while (node->parent())\r\n                    node = node->parent();\r\n                return node->type() == node_document ? static_cast<xml_document<Ch> *>(node) : 0;\r\n            }\r\n            else\r\n                return 0;\r\n        }\r\n\r\n        //! Gets previous attribute, optionally matching attribute name. \r\n        //! \\param name Name of attribute to find, or 0 to return previous attribute regardless of its name; this string doesn't have to be zero-terminated if name_size is non-zero\r\n        //! \\param name_size Size of name, in characters, or 0 to have size calculated automatically from string\r\n        //! \\param case_sensitive Should name comparison be case-sensitive; non case-sensitive comparison works properly only for ASCII characters\r\n        //! \\return Pointer to found attribute, or 0 if not found.\r\n        xml_attribute<Ch> *previous_attribute(const Ch *name = 0, std::size_t name_size = 0, bool case_sensitive = true) const\r\n        {\r\n            if (name)\r\n            {\r\n                if (name_size == 0)\r\n                    name_size = internal::measure(name);\r\n                for (xml_attribute<Ch> *attribute = m_prev_attribute; attribute; attribute = attribute->m_prev_attribute)\r\n                    if (internal::compare(attribute->name(), attribute->name_size(), name, name_size, case_sensitive))\r\n                        return attribute;\r\n                return 0;\r\n            }\r\n            else\r\n                return this->m_parent ? m_prev_attribute : 0;\r\n        }\r\n\r\n        //! Gets next attribute, optionally matching attribute name. \r\n        //! \\param name Name of attribute to find, or 0 to return next attribute regardless of its name; this string doesn't have to be zero-terminated if name_size is non-zero\r\n        //! \\param name_size Size of name, in characters, or 0 to have size calculated automatically from string\r\n        //! \\param case_sensitive Should name comparison be case-sensitive; non case-sensitive comparison works properly only for ASCII characters\r\n        //! \\return Pointer to found attribute, or 0 if not found.\r\n        xml_attribute<Ch> *next_attribute(const Ch *name = 0, std::size_t name_size = 0, bool case_sensitive = true) const\r\n        {\r\n            if (name)\r\n            {\r\n                if (name_size == 0)\r\n                    name_size = internal::measure(name);\r\n                for (xml_attribute<Ch> *attribute = m_next_attribute; attribute; attribute = attribute->m_next_attribute)\r\n                    if (internal::compare(attribute->name(), attribute->name_size(), name, name_size, case_sensitive))\r\n                        return attribute;\r\n                return 0;\r\n            }\r\n            else\r\n                return this->m_parent ? m_next_attribute : 0;\r\n        }\r\n\r\n    private:\r\n\r\n        xml_attribute<Ch> *m_prev_attribute;        // Pointer to previous sibling of attribute, or 0 if none; only valid if parent is non-zero\r\n        xml_attribute<Ch> *m_next_attribute;        // Pointer to next sibling of attribute, or 0 if none; only valid if parent is non-zero\r\n    \r\n    };\r\n\r\n    ///////////////////////////////////////////////////////////////////////////\r\n    // XML node\r\n\r\n    //! Class representing a node of XML document. \r\n    //! Each node may have associated name and value strings, which are available through name() and value() functions. \r\n    //! Interpretation of name and value depends on type of the node.\r\n    //! Type of node can be determined by using type() function.\r\n    //! <br><br>\r\n    //! Note that after parse, both name and value of node, if any, will point interior of source text used for parsing. \r\n    //! Thus, this text must persist in the memory for the lifetime of node.\r\n    //! \\param Ch Character type to use.\r\n    template<class Ch = char>\r\n    class xml_node: public xml_base<Ch>\r\n    {\r\n\r\n    public:\r\n\r\n        ///////////////////////////////////////////////////////////////////////////\r\n        // Construction & destruction\r\n    \r\n        //! Constructs an empty node with the specified type. \r\n        //! Consider using memory_pool of appropriate document to allocate nodes manually.\r\n        //! \\param type Type of node to construct.\r\n        xml_node(node_type type)\r\n            : m_type(type)\r\n            , m_first_node(0)\r\n            , m_first_attribute(0)\r\n        {\r\n        }\r\n\r\n        ///////////////////////////////////////////////////////////////////////////\r\n        // Node data access\r\n    \r\n        //! Gets type of node.\r\n        //! \\return Type of node.\r\n        node_type type() const\r\n        {\r\n            return m_type;\r\n        }\r\n\r\n        ///////////////////////////////////////////////////////////////////////////\r\n        // Related nodes access\r\n    \r\n        //! Gets document of which node is a child.\r\n        //! \\return Pointer to document that contains this node, or 0 if there is no parent document.\r\n        xml_document<Ch> *document() const\r\n        {\r\n            xml_node<Ch> *node = const_cast<xml_node<Ch> *>(this);\r\n            while (node->parent())\r\n                node = node->parent();\r\n            return node->type() == node_document ? static_cast<xml_document<Ch> *>(node) : 0;\r\n        }\r\n\r\n        //! Gets first child node, optionally matching node name.\r\n        //! \\param name Name of child to find, or 0 to return first child regardless of its name; this string doesn't have to be zero-terminated if name_size is non-zero\r\n        //! \\param name_size Size of name, in characters, or 0 to have size calculated automatically from string\r\n        //! \\param case_sensitive Should name comparison be case-sensitive; non case-sensitive comparison works properly only for ASCII characters\r\n        //! \\return Pointer to found child, or 0 if not found.\r\n        xml_node<Ch> *first_node(const Ch *name = 0, std::size_t name_size = 0, bool case_sensitive = true) const\r\n        {\r\n            if (name)\r\n            {\r\n                if (name_size == 0)\r\n                    name_size = internal::measure(name);\r\n                for (xml_node<Ch> *child = m_first_node; child; child = child->next_sibling())\r\n                    if (internal::compare(child->name(), child->name_size(), name, name_size, case_sensitive))\r\n                        return child;\r\n                return 0;\r\n            }\r\n            else\r\n                return m_first_node;\r\n        }\r\n\r\n        //! Gets last child node, optionally matching node name. \r\n        //! Behaviour is undefined if node has no children.\r\n        //! Use first_node() to test if node has children.\r\n        //! \\param name Name of child to find, or 0 to return last child regardless of its name; this string doesn't have to be zero-terminated if name_size is non-zero\r\n        //! \\param name_size Size of name, in characters, or 0 to have size calculated automatically from string\r\n        //! \\param case_sensitive Should name comparison be case-sensitive; non case-sensitive comparison works properly only for ASCII characters\r\n        //! \\return Pointer to found child, or 0 if not found.\r\n        xml_node<Ch> *last_node(const Ch *name = 0, std::size_t name_size = 0, bool case_sensitive = true) const\r\n        {\r\n            assert(m_first_node);  // Cannot query for last child if node has no children\r\n            if (name)\r\n            {\r\n                if (name_size == 0)\r\n                    name_size = internal::measure(name);\r\n                for (xml_node<Ch> *child = m_last_node; child; child = child->previous_sibling())\r\n                    if (internal::compare(child->name(), child->name_size(), name, name_size, case_sensitive))\r\n                        return child;\r\n                return 0;\r\n            }\r\n            else\r\n                return m_last_node;\r\n        }\r\n\r\n        //! Gets previous sibling node, optionally matching node name. \r\n        //! Behaviour is undefined if node has no parent.\r\n        //! Use parent() to test if node has a parent.\r\n        //! \\param name Name of sibling to find, or 0 to return previous sibling regardless of its name; this string doesn't have to be zero-terminated if name_size is non-zero\r\n        //! \\param name_size Size of name, in characters, or 0 to have size calculated automatically from string\r\n        //! \\param case_sensitive Should name comparison be case-sensitive; non case-sensitive comparison works properly only for ASCII characters\r\n        //! \\return Pointer to found sibling, or 0 if not found.\r\n        xml_node<Ch> *previous_sibling(const Ch *name = 0, std::size_t name_size = 0, bool case_sensitive = true) const\r\n        {\r\n            assert(this->m_parent);     // Cannot query for siblings if node has no parent\r\n            if (name)\r\n            {\r\n                if (name_size == 0)\r\n                    name_size = internal::measure(name);\r\n                for (xml_node<Ch> *sibling = m_prev_sibling; sibling; sibling = sibling->m_prev_sibling)\r\n                    if (internal::compare(sibling->name(), sibling->name_size(), name, name_size, case_sensitive))\r\n                        return sibling;\r\n                return 0;\r\n            }\r\n            else\r\n                return m_prev_sibling;\r\n        }\r\n\r\n        //! Gets next sibling node, optionally matching node name. \r\n        //! Behaviour is undefined if node has no parent.\r\n        //! Use parent() to test if node has a parent.\r\n        //! \\param name Name of sibling to find, or 0 to return next sibling regardless of its name; this string doesn't have to be zero-terminated if name_size is non-zero\r\n        //! \\param name_size Size of name, in characters, or 0 to have size calculated automatically from string\r\n        //! \\param case_sensitive Should name comparison be case-sensitive; non case-sensitive comparison works properly only for ASCII characters\r\n        //! \\return Pointer to found sibling, or 0 if not found.\r\n        xml_node<Ch> *next_sibling(const Ch *name = 0, std::size_t name_size = 0, bool case_sensitive = true) const\r\n        {\r\n            assert(this->m_parent);     // Cannot query for siblings if node has no parent\r\n            if (name)\r\n            {\r\n                if (name_size == 0)\r\n                    name_size = internal::measure(name);\r\n                for (xml_node<Ch> *sibling = m_next_sibling; sibling; sibling = sibling->m_next_sibling)\r\n                    if (internal::compare(sibling->name(), sibling->name_size(), name, name_size, case_sensitive))\r\n                        return sibling;\r\n                return 0;\r\n            }\r\n            else\r\n                return m_next_sibling;\r\n        }\r\n\r\n        //! Gets first attribute of node, optionally matching attribute name.\r\n        //! \\param name Name of attribute to find, or 0 to return first attribute regardless of its name; this string doesn't have to be zero-terminated if name_size is non-zero\r\n        //! \\param name_size Size of name, in characters, or 0 to have size calculated automatically from string\r\n        //! \\param case_sensitive Should name comparison be case-sensitive; non case-sensitive comparison works properly only for ASCII characters\r\n        //! \\return Pointer to found attribute, or 0 if not found.\r\n        xml_attribute<Ch> *first_attribute(const Ch *name = 0, std::size_t name_size = 0, bool case_sensitive = true) const\r\n        {\r\n            if (name)\r\n            {\r\n                if (name_size == 0)\r\n                    name_size = internal::measure(name);\r\n                for (xml_attribute<Ch> *attribute = m_first_attribute; attribute; attribute = attribute->m_next_attribute)\r\n                    if (internal::compare(attribute->name(), attribute->name_size(), name, name_size, case_sensitive))\r\n                        return attribute;\r\n                return 0;\r\n            }\r\n            else\r\n                return m_first_attribute;\r\n        }\r\n\r\n        //! Gets last attribute of node, optionally matching attribute name.\r\n        //! \\param name Name of attribute to find, or 0 to return last attribute regardless of its name; this string doesn't have to be zero-terminated if name_size is non-zero\r\n        //! \\param name_size Size of name, in characters, or 0 to have size calculated automatically from string\r\n        //! \\param case_sensitive Should name comparison be case-sensitive; non case-sensitive comparison works properly only for ASCII characters\r\n        //! \\return Pointer to found attribute, or 0 if not found.\r\n        xml_attribute<Ch> *last_attribute(const Ch *name = 0, std::size_t name_size = 0, bool case_sensitive = true) const\r\n        {\r\n            if (name)\r\n            {\r\n                if (name_size == 0)\r\n                    name_size = internal::measure(name);\r\n                for (xml_attribute<Ch> *attribute = m_last_attribute; attribute; attribute = attribute->m_prev_attribute)\r\n                    if (internal::compare(attribute->name(), attribute->name_size(), name, name_size, case_sensitive))\r\n                        return attribute;\r\n                return 0;\r\n            }\r\n            else\r\n                return m_first_attribute ? m_last_attribute : 0;\r\n        }\r\n\r\n        ///////////////////////////////////////////////////////////////////////////\r\n        // Node modification\r\n    \r\n        //! Sets type of node.\r\n        //! \\param type Type of node to set.\r\n        void type(node_type type)\r\n        {\r\n            m_type = type;\r\n        }\r\n\r\n        ///////////////////////////////////////////////////////////////////////////\r\n        // Node manipulation\r\n\r\n        //! Prepends a new child node.\r\n        //! The prepended child becomes the first child, and all existing children are moved one position back.\r\n        //! \\param child Node to prepend.\r\n        void prepend_node(xml_node<Ch> *child)\r\n        {\r\n            assert(child && !child->parent() && child->type() != node_document);\r\n            if (first_node())\r\n            {\r\n                child->m_next_sibling = m_first_node;\r\n                m_first_node->m_prev_sibling = child;\r\n            }\r\n            else\r\n            {\r\n                child->m_next_sibling = 0;\r\n                m_last_node = child;\r\n            }\r\n            m_first_node = child;\r\n            child->m_parent = this;\r\n            child->m_prev_sibling = 0;\r\n        }\r\n\r\n        //! Appends a new child node. \r\n        //! The appended child becomes the last child.\r\n        //! \\param child Node to append.\r\n        void append_node(xml_node<Ch> *child)\r\n        {\r\n            assert(child && !child->parent() && child->type() != node_document);\r\n            if (first_node())\r\n            {\r\n                child->m_prev_sibling = m_last_node;\r\n                m_last_node->m_next_sibling = child;\r\n            }\r\n            else\r\n            {\r\n                child->m_prev_sibling = 0;\r\n                m_first_node = child;\r\n            }\r\n            m_last_node = child;\r\n            child->m_parent = this;\r\n            child->m_next_sibling = 0;\r\n        }\r\n\r\n        //! Inserts a new child node at specified place inside the node. \r\n        //! All children after and including the specified node are moved one position back.\r\n        //! \\param where Place where to insert the child, or 0 to insert at the back.\r\n        //! \\param child Node to insert.\r\n        void insert_node(xml_node<Ch> *where, xml_node<Ch> *child)\r\n        {\r\n            assert(!where || where->parent() == this);\r\n            assert(child && !child->parent() && child->type() != node_document);\r\n            if (where == m_first_node)\r\n                prepend_node(child);\r\n            else if (where == 0)\r\n                append_node(child);\r\n            else\r\n            {\r\n                child->m_prev_sibling = where->m_prev_sibling;\r\n                child->m_next_sibling = where;\r\n                where->m_prev_sibling->m_next_sibling = child;\r\n                where->m_prev_sibling = child;\r\n                child->m_parent = this;\r\n            }\r\n        }\r\n\r\n        //! Removes first child node. \r\n        //! If node has no children, behaviour is undefined.\r\n        //! Use first_node() to test if node has children.\r\n        void remove_first_node()\r\n        {\r\n            assert(first_node());\r\n            xml_node<Ch> *child = m_first_node;\r\n            m_first_node = child->m_next_sibling;\r\n            if (child->m_next_sibling)\r\n                child->m_next_sibling->m_prev_sibling = 0;\r\n            else\r\n                m_last_node = 0;\r\n            child->m_parent = 0;\r\n        }\r\n\r\n        //! Removes last child of the node. \r\n        //! If node has no children, behaviour is undefined.\r\n        //! Use first_node() to test if node has children.\r\n        void remove_last_node()\r\n        {\r\n            assert(first_node());\r\n            xml_node<Ch> *child = m_last_node;\r\n            if (child->m_prev_sibling)\r\n            {\r\n                m_last_node = child->m_prev_sibling;\r\n                child->m_prev_sibling->m_next_sibling = 0;\r\n            }\r\n            else\r\n                m_first_node = 0;\r\n            child->m_parent = 0;\r\n        }\r\n\r\n        //! Removes specified child from the node\r\n        // \\param where Pointer to child to be removed.\r\n        void remove_node(xml_node<Ch> *where)\r\n        {\r\n            assert(where && where->parent() == this);\r\n            assert(first_node());\r\n            if (where == m_first_node)\r\n                remove_first_node();\r\n            else if (where == m_last_node)\r\n                remove_last_node();\r\n            else\r\n            {\r\n                where->m_prev_sibling->m_next_sibling = where->m_next_sibling;\r\n                where->m_next_sibling->m_prev_sibling = where->m_prev_sibling;\r\n                where->m_parent = 0;\r\n            }\r\n        }\r\n\r\n        //! Removes all child nodes (but not attributes).\r\n        void remove_all_nodes()\r\n        {\r\n            for (xml_node<Ch> *node = first_node(); node; node = node->m_next_sibling)\r\n                node->m_parent = 0;\r\n            m_first_node = 0;\r\n        }\r\n\r\n        //! Prepends a new attribute to the node.\r\n        //! \\param attribute Attribute to prepend.\r\n        void prepend_attribute(xml_attribute<Ch> *attribute)\r\n        {\r\n            assert(attribute && !attribute->parent());\r\n            if (first_attribute())\r\n            {\r\n                attribute->m_next_attribute = m_first_attribute;\r\n                m_first_attribute->m_prev_attribute = attribute;\r\n            }\r\n            else\r\n            {\r\n                attribute->m_next_attribute = 0;\r\n                m_last_attribute = attribute;\r\n            }\r\n            m_first_attribute = attribute;\r\n            attribute->m_parent = this;\r\n            attribute->m_prev_attribute = 0;\r\n        }\r\n\r\n        //! Appends a new attribute to the node.\r\n        //! \\param attribute Attribute to append.\r\n        void append_attribute(xml_attribute<Ch> *attribute)\r\n        {\r\n            assert(attribute && !attribute->parent());\r\n            if (first_attribute())\r\n            {\r\n                attribute->m_prev_attribute = m_last_attribute;\r\n                m_last_attribute->m_next_attribute = attribute;\r\n            }\r\n            else\r\n            {\r\n                attribute->m_prev_attribute = 0;\r\n                m_first_attribute = attribute;\r\n            }\r\n            m_last_attribute = attribute;\r\n            attribute->m_parent = this;\r\n            attribute->m_next_attribute = 0;\r\n        }\r\n\r\n        //! Inserts a new attribute at specified place inside the node. \r\n        //! All attributes after and including the specified attribute are moved one position back.\r\n        //! \\param where Place where to insert the attribute, or 0 to insert at the back.\r\n        //! \\param attribute Attribute to insert.\r\n        void insert_attribute(xml_attribute<Ch> *where, xml_attribute<Ch> *attribute)\r\n        {\r\n            assert(!where || where->parent() == this);\r\n            assert(attribute && !attribute->parent());\r\n            if (where == m_first_attribute)\r\n                prepend_attribute(attribute);\r\n            else if (where == 0)\r\n                append_attribute(attribute);\r\n            else\r\n            {\r\n                attribute->m_prev_attribute = where->m_prev_attribute;\r\n                attribute->m_next_attribute = where;\r\n                where->m_prev_attribute->m_next_attribute = attribute;\r\n                where->m_prev_attribute = attribute;\r\n                attribute->m_parent = this;\r\n            }\r\n        }\r\n\r\n        //! Removes first attribute of the node. \r\n        //! If node has no attributes, behaviour is undefined.\r\n        //! Use first_attribute() to test if node has attributes.\r\n        void remove_first_attribute()\r\n        {\r\n            assert(first_attribute());\r\n            xml_attribute<Ch> *attribute = m_first_attribute;\r\n            if (attribute->m_next_attribute)\r\n            {\r\n                attribute->m_next_attribute->m_prev_attribute = 0;\r\n            }\r\n            else\r\n                m_last_attribute = 0;\r\n            attribute->m_parent = 0;\r\n            m_first_attribute = attribute->m_next_attribute;\r\n        }\r\n\r\n        //! Removes last attribute of the node. \r\n        //! If node has no attributes, behaviour is undefined.\r\n        //! Use first_attribute() to test if node has attributes.\r\n        void remove_last_attribute()\r\n        {\r\n            assert(first_attribute());\r\n            xml_attribute<Ch> *attribute = m_last_attribute;\r\n            if (attribute->m_prev_attribute)\r\n            {\r\n                attribute->m_prev_attribute->m_next_attribute = 0;\r\n                m_last_attribute = attribute->m_prev_attribute;\r\n            }\r\n            else\r\n                m_first_attribute = 0;\r\n            attribute->m_parent = 0;\r\n        }\r\n\r\n        //! Removes specified attribute from node.\r\n        //! \\param where Pointer to attribute to be removed.\r\n        void remove_attribute(xml_attribute<Ch> *where)\r\n        {\r\n            assert(first_attribute() && where->parent() == this);\r\n            if (where == m_first_attribute)\r\n                remove_first_attribute();\r\n            else if (where == m_last_attribute)\r\n                remove_last_attribute();\r\n            else\r\n            {\r\n                where->m_prev_attribute->m_next_attribute = where->m_next_attribute;\r\n                where->m_next_attribute->m_prev_attribute = where->m_prev_attribute;\r\n                where->m_parent = 0;\r\n            }\r\n        }\r\n\r\n        //! Removes all attributes of node.\r\n        void remove_all_attributes()\r\n        {\r\n            for (xml_attribute<Ch> *attribute = first_attribute(); attribute; attribute = attribute->m_next_attribute)\r\n                attribute->m_parent = 0;\r\n            m_first_attribute = 0;\r\n        }\r\n        \r\n    private:\r\n\r\n        ///////////////////////////////////////////////////////////////////////////\r\n        // Restrictions\r\n\r\n        // No copying\r\n        xml_node(const xml_node &);\r\n        void operator =(const xml_node &);\r\n    \r\n        ///////////////////////////////////////////////////////////////////////////\r\n        // Data members\r\n    \r\n        // Note that some of the pointers below have UNDEFINED values if certain other pointers are 0.\r\n        // This is required for maximum performance, as it allows the parser to omit initialization of \r\n        // unneded/redundant values.\r\n        //\r\n        // The rules are as follows:\r\n        // 1. first_node and first_attribute contain valid pointers, or 0 if node has no children/attributes respectively\r\n        // 2. last_node and last_attribute are valid only if node has at least one child/attribute respectively, otherwise they contain garbage\r\n        // 3. prev_sibling and next_sibling are valid only if node has a parent, otherwise they contain garbage\r\n\r\n        node_type m_type;                       // Type of node; always valid\r\n        xml_node<Ch> *m_first_node;             // Pointer to first child node, or 0 if none; always valid\r\n        xml_node<Ch> *m_last_node;              // Pointer to last child node, or 0 if none; this value is only valid if m_first_node is non-zero\r\n        xml_attribute<Ch> *m_first_attribute;   // Pointer to first attribute of node, or 0 if none; always valid\r\n        xml_attribute<Ch> *m_last_attribute;    // Pointer to last attribute of node, or 0 if none; this value is only valid if m_first_attribute is non-zero\r\n        xml_node<Ch> *m_prev_sibling;           // Pointer to previous sibling of node, or 0 if none; this value is only valid if m_parent is non-zero\r\n        xml_node<Ch> *m_next_sibling;           // Pointer to next sibling of node, or 0 if none; this value is only valid if m_parent is non-zero\r\n\r\n    };\r\n\r\n    ///////////////////////////////////////////////////////////////////////////\r\n    // XML document\r\n    \r\n    //! This class represents root of the DOM hierarchy. \r\n    //! It is also an xml_node and a memory_pool through public inheritance.\r\n    //! Use parse() function to build a DOM tree from a zero-terminated XML text string.\r\n    //! parse() function allocates memory for nodes and attributes by using functions of xml_document, \r\n    //! which are inherited from memory_pool.\r\n    //! To access root node of the document, use the document itself, as if it was an xml_node.\r\n    //! \\param Ch Character type to use.\r\n    template<class Ch = char>\r\n    class xml_document: public xml_node<Ch>, public memory_pool<Ch>\r\n    {\r\n    \r\n    public:\r\n\r\n        //! Constructs empty XML document\r\n        xml_document()\r\n            : xml_node<Ch>(node_document)\r\n        {\r\n        }\r\n\r\n        //! Parses zero-terminated XML string according to given flags.\r\n        //! Passed string will be modified by the parser, unless rapidxml::parse_non_destructive flag is used.\r\n        //! The string must persist for the lifetime of the document.\r\n        //! In case of error, rapidxml::parse_error exception will be thrown.\r\n        //! <br><br>\r\n        //! If you want to parse contents of a file, you must first load the file into the memory, and pass pointer to its beginning.\r\n        //! Make sure that data is zero-terminated.\r\n        //! <br><br>\r\n        //! Document can be parsed into multiple times. \r\n        //! Each new call to parse removes previous nodes and attributes (if any), but does not clear memory pool.\r\n        //! \\param text XML data to parse; pointer is non-const to denote fact that this data may be modified by the parser.\r\n        template<int Flags>\r\n        void parse(Ch *text)\r\n        {\r\n            assert(text);\r\n            \r\n            // Remove current contents\r\n            this->remove_all_nodes();\r\n            this->remove_all_attributes();\r\n            \r\n            // Parse BOM, if any\r\n            parse_bom<Flags>(text);\r\n            \r\n            // Parse children\r\n            while (1)\r\n            {\r\n                // Skip whitespace before node\r\n                skip<whitespace_pred, Flags>(text);\r\n                if (*text == 0)\r\n                    break;\r\n\r\n                // Parse and append new child\r\n                if (*text == Ch('<'))\r\n                {\r\n                    ++text;     // Skip '<'\r\n                    if (xml_node<Ch> *node = parse_node<Flags>(text))\r\n                        this->append_node(node);\r\n                }\r\n                else\r\n                    RAPIDXML_PARSE_ERROR(\"expected <\", text);\r\n            }\r\n\r\n        }\r\n\r\n        //! Clears the document by deleting all nodes and clearing the memory pool.\r\n        //! All nodes owned by document pool are destroyed.\r\n        void clear()\r\n        {\r\n            this->remove_all_nodes();\r\n            this->remove_all_attributes();\r\n            memory_pool<Ch>::clear();\r\n        }\r\n        \r\n    private:\r\n\r\n        ///////////////////////////////////////////////////////////////////////\r\n        // Internal character utility functions\r\n        \r\n        // Detect whitespace character\r\n        struct whitespace_pred\r\n        {\r\n            static unsigned char test(Ch ch)\r\n            {\r\n                return internal::lookup_tables<0>::lookup_whitespace[static_cast<unsigned char>(ch)];\r\n            }\r\n        };\r\n\r\n        // Detect node name character\r\n        struct node_name_pred\r\n        {\r\n            static unsigned char test(Ch ch)\r\n            {\r\n                return internal::lookup_tables<0>::lookup_node_name[static_cast<unsigned char>(ch)];\r\n            }\r\n        };\r\n\r\n        // Detect attribute name character\r\n        struct attribute_name_pred\r\n        {\r\n            static unsigned char test(Ch ch)\r\n            {\r\n                return internal::lookup_tables<0>::lookup_attribute_name[static_cast<unsigned char>(ch)];\r\n            }\r\n        };\r\n\r\n        // Detect text character (PCDATA)\r\n        struct text_pred\r\n        {\r\n            static unsigned char test(Ch ch)\r\n            {\r\n                return internal::lookup_tables<0>::lookup_text[static_cast<unsigned char>(ch)];\r\n            }\r\n        };\r\n\r\n        // Detect text character (PCDATA) that does not require processing\r\n        struct text_pure_no_ws_pred\r\n        {\r\n            static unsigned char test(Ch ch)\r\n            {\r\n                return internal::lookup_tables<0>::lookup_text_pure_no_ws[static_cast<unsigned char>(ch)];\r\n            }\r\n        };\r\n\r\n        // Detect text character (PCDATA) that does not require processing\r\n        struct text_pure_with_ws_pred\r\n        {\r\n            static unsigned char test(Ch ch)\r\n            {\r\n                return internal::lookup_tables<0>::lookup_text_pure_with_ws[static_cast<unsigned char>(ch)];\r\n            }\r\n        };\r\n\r\n        // Detect attribute value character\r\n        template<Ch Quote>\r\n        struct attribute_value_pred\r\n        {\r\n            static unsigned char test(Ch ch)\r\n            {\r\n                if (Quote == Ch('\\''))\r\n                    return internal::lookup_tables<0>::lookup_attribute_data_1[static_cast<unsigned char>(ch)];\r\n                if (Quote == Ch('\\\"'))\r\n                    return internal::lookup_tables<0>::lookup_attribute_data_2[static_cast<unsigned char>(ch)];\r\n                return 0;       // Should never be executed, to avoid warnings on Comeau\r\n            }\r\n        };\r\n\r\n        // Detect attribute value character\r\n        template<Ch Quote>\r\n        struct attribute_value_pure_pred\r\n        {\r\n            static unsigned char test(Ch ch)\r\n            {\r\n                if (Quote == Ch('\\''))\r\n                    return internal::lookup_tables<0>::lookup_attribute_data_1_pure[static_cast<unsigned char>(ch)];\r\n                if (Quote == Ch('\\\"'))\r\n                    return internal::lookup_tables<0>::lookup_attribute_data_2_pure[static_cast<unsigned char>(ch)];\r\n                return 0;       // Should never be executed, to avoid warnings on Comeau\r\n            }\r\n        };\r\n\r\n        // Insert coded character, using UTF8 or 8-bit ASCII\r\n        template<int Flags>\r\n        static void insert_coded_character(Ch *&text, unsigned long code)\r\n        {\r\n            if (Flags & parse_no_utf8)\r\n            {\r\n                // Insert 8-bit ASCII character\r\n                // Todo: possibly verify that code is less than 256 and use replacement char otherwise?\r\n                text[0] = static_cast<unsigned char>(code);\r\n                text += 1;\r\n            }\r\n            else\r\n            {\r\n                // Insert UTF8 sequence\r\n                if (code < 0x80)    // 1 byte sequence\r\n                {\r\n\t                text[0] = static_cast<unsigned char>(code);\r\n                    text += 1;\r\n                }\r\n                else if (code < 0x800)  // 2 byte sequence\r\n                {\r\n\t                text[1] = static_cast<unsigned char>((code | 0x80) & 0xBF); code >>= 6;\r\n\t                text[0] = static_cast<unsigned char>(code | 0xC0);\r\n                    text += 2;\r\n                }\r\n\t            else if (code < 0x10000)    // 3 byte sequence\r\n                {\r\n\t                text[2] = static_cast<unsigned char>((code | 0x80) & 0xBF); code >>= 6;\r\n\t                text[1] = static_cast<unsigned char>((code | 0x80) & 0xBF); code >>= 6;\r\n\t                text[0] = static_cast<unsigned char>(code | 0xE0);\r\n                    text += 3;\r\n                }\r\n\t            else if (code < 0x110000)   // 4 byte sequence\r\n                {\r\n\t                text[3] = static_cast<unsigned char>((code | 0x80) & 0xBF); code >>= 6;\r\n\t                text[2] = static_cast<unsigned char>((code | 0x80) & 0xBF); code >>= 6;\r\n\t                text[1] = static_cast<unsigned char>((code | 0x80) & 0xBF); code >>= 6;\r\n\t                text[0] = static_cast<unsigned char>(code | 0xF0);\r\n                    text += 4;\r\n                }\r\n                else    // Invalid, only codes up to 0x10FFFF are allowed in Unicode\r\n                {\r\n                    RAPIDXML_PARSE_ERROR(\"invalid numeric character entity\", text);\r\n                }\r\n            }\r\n        }\r\n\r\n        // Skip characters until predicate evaluates to true\r\n        template<class StopPred, int Flags>\r\n        static void skip(Ch *&text)\r\n        {\r\n            Ch *tmp = text;\r\n            while (StopPred::test(*tmp))\r\n                ++tmp;\r\n            text = tmp;\r\n        }\r\n\r\n        // Skip characters until predicate evaluates to true while doing the following:\r\n        // - replacing XML character entity references with proper characters (&apos; &amp; &quot; &lt; &gt; &#...;)\r\n        // - condensing whitespace sequences to single space character\r\n        template<class StopPred, class StopPredPure, int Flags>\r\n        static Ch *skip_and_expand_character_refs(Ch *&text)\r\n        {\r\n            // If entity translation, whitespace condense and whitespace trimming is disabled, use plain skip\r\n            if (Flags & parse_no_entity_translation && \r\n                !(Flags & parse_normalize_whitespace) &&\r\n                !(Flags & parse_trim_whitespace))\r\n            {\r\n                skip<StopPred, Flags>(text);\r\n                return text;\r\n            }\r\n            \r\n            // Use simple skip until first modification is detected\r\n            skip<StopPredPure, Flags>(text);\r\n\r\n            // Use translation skip\r\n            Ch *src = text;\r\n            Ch *dest = src;\r\n            while (StopPred::test(*src))\r\n            {\r\n                // If entity translation is enabled    \r\n                if (!(Flags & parse_no_entity_translation))\r\n                {\r\n                    // Test if replacement is needed\r\n                    if (src[0] == Ch('&'))\r\n                    {\r\n                        switch (src[1])\r\n                        {\r\n\r\n                        // &amp; &apos;\r\n                        case Ch('a'): \r\n                            if (src[2] == Ch('m') && src[3] == Ch('p') && src[4] == Ch(';'))\r\n                            {\r\n                                *dest = Ch('&');\r\n                                ++dest;\r\n                                src += 5;\r\n                                continue;\r\n                            }\r\n                            if (src[2] == Ch('p') && src[3] == Ch('o') && src[4] == Ch('s') && src[5] == Ch(';'))\r\n                            {\r\n                                *dest = Ch('\\'');\r\n                                ++dest;\r\n                                src += 6;\r\n                                continue;\r\n                            }\r\n                            break;\r\n\r\n                        // &quot;\r\n                        case Ch('q'): \r\n                            if (src[2] == Ch('u') && src[3] == Ch('o') && src[4] == Ch('t') && src[5] == Ch(';'))\r\n                            {\r\n                                *dest = Ch('\"');\r\n                                ++dest;\r\n                                src += 6;\r\n                                continue;\r\n                            }\r\n                            break;\r\n\r\n                        // &gt;\r\n                        case Ch('g'): \r\n                            if (src[2] == Ch('t') && src[3] == Ch(';'))\r\n                            {\r\n                                *dest = Ch('>');\r\n                                ++dest;\r\n                                src += 4;\r\n                                continue;\r\n                            }\r\n                            break;\r\n\r\n                        // &lt;\r\n                        case Ch('l'): \r\n                            if (src[2] == Ch('t') && src[3] == Ch(';'))\r\n                            {\r\n                                *dest = Ch('<');\r\n                                ++dest;\r\n                                src += 4;\r\n                                continue;\r\n                            }\r\n                            break;\r\n\r\n                        // &#...; - assumes ASCII\r\n                        case Ch('#'): \r\n                            if (src[2] == Ch('x'))\r\n                            {\r\n                                unsigned long code = 0;\r\n                                src += 3;   // Skip &#x\r\n                                while (1)\r\n                                {\r\n                                    unsigned char digit = internal::lookup_tables<0>::lookup_digits[static_cast<unsigned char>(*src)];\r\n                                    if (digit == 0xFF)\r\n                                        break;\r\n                                    code = code * 16 + digit;\r\n                                    ++src;\r\n                                }\r\n                                insert_coded_character<Flags>(dest, code);    // Put character in output\r\n                            }\r\n                            else\r\n                            {\r\n                                unsigned long code = 0;\r\n                                src += 2;   // Skip &#\r\n                                while (1)\r\n                                {\r\n                                    unsigned char digit = internal::lookup_tables<0>::lookup_digits[static_cast<unsigned char>(*src)];\r\n                                    if (digit == 0xFF)\r\n                                        break;\r\n                                    code = code * 10 + digit;\r\n                                    ++src;\r\n                                }\r\n                                insert_coded_character<Flags>(dest, code);    // Put character in output\r\n                            }\r\n                            if (*src == Ch(';'))\r\n                                ++src;\r\n                            else\r\n                                RAPIDXML_PARSE_ERROR(\"expected ;\", src);\r\n                            continue;\r\n\r\n                        // Something else\r\n                        default:\r\n                            // Ignore, just copy '&' verbatim\r\n                            break;\r\n\r\n                        }\r\n                    }\r\n                }\r\n                \r\n                // If whitespace condensing is enabled\r\n                if (Flags & parse_normalize_whitespace)\r\n                {\r\n                    // Test if condensing is needed                 \r\n                    if (whitespace_pred::test(*src))\r\n                    {\r\n                        *dest = Ch(' '); ++dest;    // Put single space in dest\r\n                        ++src;                      // Skip first whitespace char\r\n                        // Skip remaining whitespace chars\r\n                        while (whitespace_pred::test(*src))\r\n                            ++src;\r\n                        continue;\r\n                    }\r\n                }\r\n\r\n                // No replacement, only copy character\r\n                *dest++ = *src++;\r\n\r\n            }\r\n\r\n            // Return new end\r\n            text = src;\r\n            return dest;\r\n\r\n        }\r\n\r\n        ///////////////////////////////////////////////////////////////////////\r\n        // Internal parsing functions\r\n        \r\n        // Parse BOM, if any\r\n        template<int Flags>\r\n        void parse_bom(Ch *&text)\r\n        {\r\n            // UTF-8?\r\n            if (static_cast<unsigned char>(text[0]) == 0xEF && \r\n                static_cast<unsigned char>(text[1]) == 0xBB && \r\n                static_cast<unsigned char>(text[2]) == 0xBF)\r\n            {\r\n                text += 3;      // Skup utf-8 bom\r\n            }\r\n        }\r\n\r\n        // Parse XML declaration (<?xml...)\r\n        template<int Flags>\r\n        xml_node<Ch> *parse_xml_declaration(Ch *&text)\r\n        {\r\n            // If parsing of declaration is disabled\r\n            if (!(Flags & parse_declaration_node))\r\n            {\r\n                // Skip until end of declaration\r\n                while (text[0] != Ch('?') || text[1] != Ch('>'))\r\n                {\r\n                    if (!text[0])\r\n                        RAPIDXML_PARSE_ERROR(\"unexpected end of data\", text);\r\n                    ++text;\r\n                }\r\n                text += 2;    // Skip '?>'\r\n                return 0;\r\n            }\r\n\r\n            // Create declaration\r\n            xml_node<Ch> *declaration = this->allocate_node(node_declaration);\r\n\r\n            // Skip whitespace before attributes or ?>\r\n            skip<whitespace_pred, Flags>(text);\r\n\r\n            // Parse declaration attributes\r\n            parse_node_attributes<Flags>(text, declaration);\r\n            \r\n            // Skip ?>\r\n            if (text[0] != Ch('?') || text[1] != Ch('>'))\r\n                RAPIDXML_PARSE_ERROR(\"expected ?>\", text);\r\n            text += 2;\r\n            \r\n            return declaration;\r\n        }\r\n\r\n        // Parse XML comment (<!--...)\r\n        template<int Flags>\r\n        xml_node<Ch> *parse_comment(Ch *&text)\r\n        {\r\n            // If parsing of comments is disabled\r\n            if (!(Flags & parse_comment_nodes))\r\n            {\r\n                // Skip until end of comment\r\n                while (text[0] != Ch('-') || text[1] != Ch('-') || text[2] != Ch('>'))\r\n                {\r\n                    if (!text[0])\r\n                        RAPIDXML_PARSE_ERROR(\"unexpected end of data\", text);\r\n                    ++text;\r\n                }\r\n                text += 3;     // Skip '-->'\r\n                return 0;      // Do not produce comment node\r\n            }\r\n\r\n            // Remember value start\r\n            Ch *value = text;\r\n\r\n            // Skip until end of comment\r\n            while (text[0] != Ch('-') || text[1] != Ch('-') || text[2] != Ch('>'))\r\n            {\r\n                if (!text[0])\r\n                    RAPIDXML_PARSE_ERROR(\"unexpected end of data\", text);\r\n                ++text;\r\n            }\r\n\r\n            // Create comment node\r\n            xml_node<Ch> *comment = this->allocate_node(node_comment);\r\n            comment->value(value, text - value);\r\n            \r\n            // Place zero terminator after comment value\r\n            if (!(Flags & parse_no_string_terminators))\r\n                *text = Ch('\\0');\r\n            \r\n            text += 3;     // Skip '-->'\r\n            return comment;\r\n        }\r\n\r\n        // Parse DOCTYPE\r\n        template<int Flags>\r\n        xml_node<Ch> *parse_doctype(Ch *&text)\r\n        {\r\n            // Remember value start\r\n            Ch *value = text;\r\n\r\n            // Skip to >\r\n            while (*text != Ch('>'))\r\n            {\r\n                // Determine character type\r\n                switch (*text)\r\n                {\r\n                \r\n                // If '[' encountered, scan for matching ending ']' using naive algorithm with depth\r\n                // This works for all W3C test files except for 2 most wicked\r\n                case Ch('['):\r\n                {\r\n                    ++text;     // Skip '['\r\n                    int depth = 1;\r\n                    while (depth > 0)\r\n                    {\r\n                        switch (*text)\r\n                        {\r\n                            case Ch('['): ++depth; break;\r\n                            case Ch(']'): --depth; break;\r\n                            case 0: RAPIDXML_PARSE_ERROR(\"unexpected end of data\", text);\r\n                        }\r\n                        ++text;\r\n                    }\r\n                    break;\r\n                }\r\n                \r\n                // Error on end of text\r\n                case Ch('\\0'):\r\n                    RAPIDXML_PARSE_ERROR(\"unexpected end of data\", text);\r\n                \r\n                // Other character, skip it\r\n                default:\r\n                    ++text;\r\n\r\n                }\r\n            }\r\n            \r\n            // If DOCTYPE nodes enabled\r\n            if (Flags & parse_doctype_node)\r\n            {\r\n                // Create a new doctype node\r\n                xml_node<Ch> *doctype = this->allocate_node(node_doctype);\r\n                doctype->value(value, text - value);\r\n                \r\n                // Place zero terminator after value\r\n                if (!(Flags & parse_no_string_terminators))\r\n                    *text = Ch('\\0');\r\n\r\n                text += 1;      // skip '>'\r\n                return doctype;\r\n            }\r\n            else\r\n            {\r\n                text += 1;      // skip '>'\r\n                return 0;\r\n            }\r\n\r\n        }\r\n\r\n        // Parse PI\r\n        template<int Flags>\r\n        xml_node<Ch> *parse_pi(Ch *&text)\r\n        {\r\n            // If creation of PI nodes is enabled\r\n            if (Flags & parse_pi_nodes)\r\n            {\r\n                // Create pi node\r\n                xml_node<Ch> *pi = this->allocate_node(node_pi);\r\n\r\n                // Extract PI target name\r\n                Ch *name = text;\r\n                skip<node_name_pred, Flags>(text);\r\n                if (text == name)\r\n                    RAPIDXML_PARSE_ERROR(\"expected PI target\", text);\r\n                pi->name(name, text - name);\r\n                \r\n                // Skip whitespace between pi target and pi\r\n                skip<whitespace_pred, Flags>(text);\r\n\r\n                // Remember start of pi\r\n                Ch *value = text;\r\n                \r\n                // Skip to '?>'\r\n                while (text[0] != Ch('?') || text[1] != Ch('>'))\r\n                {\r\n                    if (*text == Ch('\\0'))\r\n                        RAPIDXML_PARSE_ERROR(\"unexpected end of data\", text);\r\n                    ++text;\r\n                }\r\n\r\n                // Set pi value (verbatim, no entity expansion or whitespace normalization)\r\n                pi->value(value, text - value);     \r\n                \r\n                // Place zero terminator after name and value\r\n                if (!(Flags & parse_no_string_terminators))\r\n                {\r\n                    pi->name()[pi->name_size()] = Ch('\\0');\r\n                    pi->value()[pi->value_size()] = Ch('\\0');\r\n                }\r\n                \r\n                text += 2;                          // Skip '?>'\r\n                return pi;\r\n            }\r\n            else\r\n            {\r\n                // Skip to '?>'\r\n                while (text[0] != Ch('?') || text[1] != Ch('>'))\r\n                {\r\n                    if (*text == Ch('\\0'))\r\n                        RAPIDXML_PARSE_ERROR(\"unexpected end of data\", text);\r\n                    ++text;\r\n                }\r\n                text += 2;    // Skip '?>'\r\n                return 0;\r\n            }\r\n        }\r\n\r\n        // Parse and append data\r\n        // Return character that ends data.\r\n        // This is necessary because this character might have been overwritten by a terminating 0\r\n        template<int Flags>\r\n        Ch parse_and_append_data(xml_node<Ch> *node, Ch *&text, Ch *contents_start)\r\n        {\r\n            // Backup to contents start if whitespace trimming is disabled\r\n            if (!(Flags & parse_trim_whitespace))\r\n                text = contents_start;     \r\n            \r\n            // Skip until end of data\r\n            Ch *value = text, *end;\r\n            if (Flags & parse_normalize_whitespace)\r\n                end = skip_and_expand_character_refs<text_pred, text_pure_with_ws_pred, Flags>(text);   \r\n            else\r\n                end = skip_and_expand_character_refs<text_pred, text_pure_no_ws_pred, Flags>(text);\r\n\r\n            // Trim trailing whitespace if flag is set; leading was already trimmed by whitespace skip after >\r\n            if (Flags & parse_trim_whitespace)\r\n            {\r\n                if (Flags & parse_normalize_whitespace)\r\n                {\r\n                    // Whitespace is already condensed to single space characters by skipping function, so just trim 1 char off the end\r\n                    if (*(end - 1) == Ch(' '))\r\n                        --end;\r\n                }\r\n                else\r\n                {\r\n                    // Backup until non-whitespace character is found\r\n                    while (whitespace_pred::test(*(end - 1)))\r\n                        --end;\r\n                }\r\n            }\r\n            \r\n            // If characters are still left between end and value (this test is only necessary if normalization is enabled)\r\n            // Create new data node\r\n            if (!(Flags & parse_no_data_nodes))\r\n            {\r\n                xml_node<Ch> *data = this->allocate_node(node_data);\r\n                data->value(value, end - value);\r\n                node->append_node(data);\r\n            }\r\n\r\n            // Add data to parent node if no data exists yet\r\n            if (!(Flags & parse_no_element_values)) \r\n                if (*node->value() == Ch('\\0'))\r\n                    node->value(value, end - value);\r\n\r\n            // Place zero terminator after value\r\n            if (!(Flags & parse_no_string_terminators))\r\n            {\r\n                Ch ch = *text;\r\n                *end = Ch('\\0');\r\n                return ch;      // Return character that ends data; this is required because zero terminator overwritten it\r\n            }\r\n\r\n            // Return character that ends data\r\n            return *text;\r\n        }\r\n\r\n        // Parse CDATA\r\n        template<int Flags>\r\n        xml_node<Ch> *parse_cdata(Ch *&text)\r\n        {\r\n            // If CDATA is disabled\r\n            if (Flags & parse_no_data_nodes)\r\n            {\r\n                // Skip until end of cdata\r\n                while (text[0] != Ch(']') || text[1] != Ch(']') || text[2] != Ch('>'))\r\n                {\r\n                    if (!text[0])\r\n                        RAPIDXML_PARSE_ERROR(\"unexpected end of data\", text);\r\n                    ++text;\r\n                }\r\n                text += 3;      // Skip ]]>\r\n                return 0;       // Do not produce CDATA node\r\n            }\r\n\r\n            // Skip until end of cdata\r\n            Ch *value = text;\r\n            while (text[0] != Ch(']') || text[1] != Ch(']') || text[2] != Ch('>'))\r\n            {\r\n                if (!text[0])\r\n                    RAPIDXML_PARSE_ERROR(\"unexpected end of data\", text);\r\n                ++text;\r\n            }\r\n\r\n            // Create new cdata node\r\n            xml_node<Ch> *cdata = this->allocate_node(node_cdata);\r\n            cdata->value(value, text - value);\r\n\r\n            // Place zero terminator after value\r\n            if (!(Flags & parse_no_string_terminators))\r\n                *text = Ch('\\0');\r\n\r\n            text += 3;      // Skip ]]>\r\n            return cdata;\r\n        }\r\n        \r\n        // Parse element node\r\n        template<int Flags>\r\n        xml_node<Ch> *parse_element(Ch *&text)\r\n        {\r\n            // Create element node\r\n            xml_node<Ch> *element = this->allocate_node(node_element);\r\n\r\n            // Extract element name\r\n            Ch *name = text;\r\n            skip<node_name_pred, Flags>(text);\r\n            if (text == name)\r\n                RAPIDXML_PARSE_ERROR(\"expected element name\", text);\r\n            element->name(name, text - name);\r\n            \r\n            // Skip whitespace between element name and attributes or >\r\n            skip<whitespace_pred, Flags>(text);\r\n\r\n            // Parse attributes, if any\r\n            parse_node_attributes<Flags>(text, element);\r\n\r\n            // Determine ending type\r\n            if (*text == Ch('>'))\r\n            {\r\n                ++text;\r\n                parse_node_contents<Flags>(text, element);\r\n            }\r\n            else if (*text == Ch('/'))\r\n            {\r\n                ++text;\r\n                if (*text != Ch('>'))\r\n                    RAPIDXML_PARSE_ERROR(\"expected >\", text);\r\n                ++text;\r\n            }\r\n            else\r\n                RAPIDXML_PARSE_ERROR(\"expected >\", text);\r\n\r\n            // Place zero terminator after name\r\n            if (!(Flags & parse_no_string_terminators))\r\n                element->name()[element->name_size()] = Ch('\\0');\r\n\r\n            // Return parsed element\r\n            return element;\r\n        }\r\n\r\n        // Determine node type, and parse it\r\n        template<int Flags>\r\n        xml_node<Ch> *parse_node(Ch *&text)\r\n        {\r\n            // Parse proper node type\r\n            switch (text[0])\r\n            {\r\n\r\n            // <...\r\n            default: \r\n                // Parse and append element node\r\n                return parse_element<Flags>(text);\r\n\r\n            // <?...\r\n            case Ch('?'): \r\n                ++text;     // Skip ?\r\n                if ((text[0] == Ch('x') || text[0] == Ch('X')) &&\r\n                    (text[1] == Ch('m') || text[1] == Ch('M')) && \r\n                    (text[2] == Ch('l') || text[2] == Ch('L')) &&\r\n                    whitespace_pred::test(text[3]))\r\n                {\r\n                    // '<?xml ' - xml declaration\r\n                    text += 4;      // Skip 'xml '\r\n                    return parse_xml_declaration<Flags>(text);\r\n                }\r\n                else\r\n                {\r\n                    // Parse PI\r\n                    return parse_pi<Flags>(text);\r\n                }\r\n            \r\n            // <!...\r\n            case Ch('!'): \r\n\r\n                // Parse proper subset of <! node\r\n                switch (text[1])    \r\n                {\r\n                \r\n                // <!-\r\n                case Ch('-'):\r\n                    if (text[2] == Ch('-'))\r\n                    {\r\n                        // '<!--' - xml comment\r\n                        text += 3;     // Skip '!--'\r\n                        return parse_comment<Flags>(text);\r\n                    }\r\n                    break;\r\n\r\n                // <![\r\n                case Ch('['):\r\n                    if (text[2] == Ch('C') && text[3] == Ch('D') && text[4] == Ch('A') && \r\n                        text[5] == Ch('T') && text[6] == Ch('A') && text[7] == Ch('['))\r\n                    {\r\n                        // '<![CDATA[' - cdata\r\n                        text += 8;     // Skip '![CDATA['\r\n                        return parse_cdata<Flags>(text);\r\n                    }\r\n                    break;\r\n\r\n                // <!D\r\n                case Ch('D'):\r\n                    if (text[2] == Ch('O') && text[3] == Ch('C') && text[4] == Ch('T') && \r\n                        text[5] == Ch('Y') && text[6] == Ch('P') && text[7] == Ch('E') && \r\n                        whitespace_pred::test(text[8]))\r\n                    {\r\n                        // '<!DOCTYPE ' - doctype\r\n                        text += 9;      // skip '!DOCTYPE '\r\n                        return parse_doctype<Flags>(text);\r\n                    }\r\n\r\n                }   // switch\r\n\r\n                // Attempt to skip other, unrecognized node types starting with <!\r\n                ++text;     // Skip !\r\n                while (*text != Ch('>'))\r\n                {\r\n                    if (*text == 0)\r\n                        RAPIDXML_PARSE_ERROR(\"unexpected end of data\", text);\r\n                    ++text;\r\n                }\r\n                ++text;     // Skip '>'\r\n                return 0;   // No node recognized\r\n\r\n            }\r\n        }\r\n\r\n        // Parse contents of the node - children, data etc.\r\n        template<int Flags>\r\n        void parse_node_contents(Ch *&text, xml_node<Ch> *node)\r\n        {\r\n            // For all children and text\r\n            while (1)\r\n            {\r\n                // Skip whitespace between > and node contents\r\n                Ch *contents_start = text;      // Store start of node contents before whitespace is skipped\r\n                skip<whitespace_pred, Flags>(text);\r\n                Ch next_char = *text;\r\n\r\n            // After data nodes, instead of continuing the loop, control jumps here.\r\n            // This is because zero termination inside parse_and_append_data() function\r\n            // would wreak havoc with the above code.\r\n            // Also, skipping whitespace after data nodes is unnecessary.\r\n            after_data_node:    \r\n                \r\n                // Determine what comes next: node closing, child node, data node, or 0?\r\n                switch (next_char)\r\n                {\r\n                \r\n                // Node closing or child node\r\n                case Ch('<'):\r\n                    if (text[1] == Ch('/'))\r\n                    {\r\n                        // Node closing\r\n                        text += 2;      // Skip '</'\r\n                        if (Flags & parse_validate_closing_tags)\r\n                        {\r\n                            // Skip and validate closing tag name\r\n                            Ch *closing_name = text;\r\n                            skip<node_name_pred, Flags>(text);\r\n                            if (!internal::compare(node->name(), node->name_size(), closing_name, text - closing_name, true))\r\n                                RAPIDXML_PARSE_ERROR(\"invalid closing tag name\", text);\r\n                        }\r\n                        else\r\n                        {\r\n                            // No validation, just skip name\r\n                            skip<node_name_pred, Flags>(text);\r\n                        }\r\n                        // Skip remaining whitespace after node name\r\n                        skip<whitespace_pred, Flags>(text);\r\n                        if (*text != Ch('>'))\r\n                            RAPIDXML_PARSE_ERROR(\"expected >\", text);\r\n                        ++text;     // Skip '>'\r\n                        return;     // Node closed, finished parsing contents\r\n                    }\r\n                    else\r\n                    {\r\n                        // Child node\r\n                        ++text;     // Skip '<'\r\n                        if (xml_node<Ch> *child = parse_node<Flags>(text))\r\n                            node->append_node(child);\r\n                    }\r\n                    break;\r\n\r\n                // End of data - error\r\n                case Ch('\\0'):\r\n                    RAPIDXML_PARSE_ERROR(\"unexpected end of data\", text);\r\n\r\n                // Data node\r\n                default:\r\n                    next_char = parse_and_append_data<Flags>(node, text, contents_start);\r\n                    goto after_data_node;   // Bypass regular processing after data nodes\r\n\r\n                }\r\n            }\r\n        }\r\n        \r\n        // Parse XML attributes of the node\r\n        template<int Flags>\r\n        void parse_node_attributes(Ch *&text, xml_node<Ch> *node)\r\n        {\r\n            // For all attributes \r\n            while (attribute_name_pred::test(*text))\r\n            {\r\n                // Extract attribute name\r\n                Ch *name = text;\r\n                ++text;     // Skip first character of attribute name\r\n                skip<attribute_name_pred, Flags>(text);\r\n                if (text == name)\r\n                    RAPIDXML_PARSE_ERROR(\"expected attribute name\", name);\r\n\r\n                // Create new attribute\r\n                xml_attribute<Ch> *attribute = this->allocate_attribute();\r\n                attribute->name(name, text - name);\r\n                node->append_attribute(attribute);\r\n\r\n                // Skip whitespace after attribute name\r\n                skip<whitespace_pred, Flags>(text);\r\n\r\n                // Skip =\r\n                if (*text != Ch('='))\r\n                    RAPIDXML_PARSE_ERROR(\"expected =\", text);\r\n                ++text;\r\n\r\n                // Add terminating zero after name\r\n                if (!(Flags & parse_no_string_terminators))\r\n                    attribute->name()[attribute->name_size()] = 0;\r\n\r\n                // Skip whitespace after =\r\n                skip<whitespace_pred, Flags>(text);\r\n\r\n                // Skip quote and remember if it was ' or \"\r\n                Ch quote = *text;\r\n                if (quote != Ch('\\'') && quote != Ch('\"'))\r\n                    RAPIDXML_PARSE_ERROR(\"expected ' or \\\"\", text);\r\n                ++text;\r\n\r\n                // Extract attribute value and expand char refs in it\r\n                Ch *value = text, *end;\r\n                const int AttFlags = Flags & ~parse_normalize_whitespace;   // No whitespace normalization in attributes\r\n                if (quote == Ch('\\''))\r\n                    end = skip_and_expand_character_refs<attribute_value_pred<Ch('\\'')>, attribute_value_pure_pred<Ch('\\'')>, AttFlags>(text);\r\n                else\r\n                    end = skip_and_expand_character_refs<attribute_value_pred<Ch('\"')>, attribute_value_pure_pred<Ch('\"')>, AttFlags>(text);\r\n                \r\n                // Set attribute value\r\n                attribute->value(value, end - value);\r\n                \r\n                // Make sure that end quote is present\r\n                if (*text != quote)\r\n                    RAPIDXML_PARSE_ERROR(\"expected ' or \\\"\", text);\r\n                ++text;     // Skip quote\r\n\r\n                // Add terminating zero after value\r\n                if (!(Flags & parse_no_string_terminators))\r\n                    attribute->value()[attribute->value_size()] = 0;\r\n\r\n                // Skip whitespace after attribute value\r\n                skip<whitespace_pred, Flags>(text);\r\n            }\r\n        }\r\n\r\n    };\r\n\r\n    //! \\cond internal\r\n    namespace internal\r\n    {\r\n\r\n        // Whitespace (space \\n \\r \\t)\r\n        template<int Dummy>\r\n        const unsigned char lookup_tables<Dummy>::lookup_whitespace[256] = \r\n        {\r\n          // 0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F\r\n             0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  1,  0,  0,  1,  0,  0,  // 0\r\n             0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  // 1\r\n             1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  // 2\r\n             0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  // 3\r\n             0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  // 4\r\n             0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  // 5\r\n             0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  // 6\r\n             0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  // 7\r\n             0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  // 8\r\n             0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  // 9\r\n             0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  // A\r\n             0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  // B\r\n             0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  // C\r\n             0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  // D\r\n             0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  // E\r\n             0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0   // F\r\n        };\r\n\r\n        // Node name (anything but space \\n \\r \\t / > ? \\0)\r\n        template<int Dummy>\r\n        const unsigned char lookup_tables<Dummy>::lookup_node_name[256] = \r\n        {\r\n          // 0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F\r\n             0,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  1,  1,  0,  1,  1,  // 0\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 1\r\n             0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  // 2\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  // 3\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 4\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 5\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 6\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 7\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 8\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 9\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // A\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // B\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // C\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // D\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // E\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1   // F\r\n        };\r\n\r\n        // Text (i.e. PCDATA) (anything but < \\0)\r\n        template<int Dummy>\r\n        const unsigned char lookup_tables<Dummy>::lookup_text[256] = \r\n        {\r\n          // 0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F\r\n             0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 0\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 1\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 2\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  1,  1,  1,  // 3\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 4\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 5\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 6\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 7\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 8\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 9\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // A\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // B\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // C\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // D\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // E\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1   // F\r\n        };\r\n\r\n        // Text (i.e. PCDATA) that does not require processing when ws normalization is disabled \r\n        // (anything but < \\0 &)\r\n        template<int Dummy>\r\n        const unsigned char lookup_tables<Dummy>::lookup_text_pure_no_ws[256] = \r\n        {\r\n          // 0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F\r\n             0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 0\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 1\r\n             1,  1,  1,  1,  1,  1,  0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 2\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  1,  1,  1,  // 3\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 4\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 5\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 6\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 7\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 8\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 9\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // A\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // B\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // C\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // D\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // E\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1   // F\r\n        };\r\n\r\n        // Text (i.e. PCDATA) that does not require processing when ws normalizationis is enabled\r\n        // (anything but < \\0 & space \\n \\r \\t)\r\n        template<int Dummy>\r\n        const unsigned char lookup_tables<Dummy>::lookup_text_pure_with_ws[256] = \r\n        {\r\n          // 0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F\r\n             0,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  1,  1,  0,  1,  1,  // 0\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 1\r\n             0,  1,  1,  1,  1,  1,  0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 2\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  1,  1,  1,  // 3\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 4\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 5\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 6\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 7\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 8\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 9\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // A\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // B\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // C\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // D\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // E\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1   // F\r\n        };\r\n\r\n        // Attribute name (anything but space \\n \\r \\t / < > = ? ! \\0)\r\n        template<int Dummy>\r\n        const unsigned char lookup_tables<Dummy>::lookup_attribute_name[256] = \r\n        {\r\n          // 0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F\r\n             0,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  1,  1,  0,  1,  1,  // 0\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 1\r\n             0,  0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  // 2\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  // 3\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 4\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 5\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 6\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 7\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 8\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 9\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // A\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // B\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // C\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // D\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // E\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1   // F\r\n        };\r\n\r\n        // Attribute data with single quote (anything but ' \\0)\r\n        template<int Dummy>\r\n        const unsigned char lookup_tables<Dummy>::lookup_attribute_data_1[256] = \r\n        {\r\n          // 0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F\r\n             0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 0\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 1\r\n             1,  1,  1,  1,  1,  1,  1,  0,  1,  1,  1,  1,  1,  1,  1,  1,  // 2\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 3\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 4\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 5\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 6\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 7\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 8\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 9\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // A\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // B\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // C\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // D\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // E\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1   // F\r\n        };\r\n\r\n        // Attribute data with single quote that does not require processing (anything but ' \\0 &)\r\n        template<int Dummy>\r\n        const unsigned char lookup_tables<Dummy>::lookup_attribute_data_1_pure[256] = \r\n        {\r\n          // 0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F\r\n             0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 0\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 1\r\n             1,  1,  1,  1,  1,  1,  0,  0,  1,  1,  1,  1,  1,  1,  1,  1,  // 2\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 3\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 4\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 5\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 6\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 7\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 8\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 9\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // A\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // B\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // C\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // D\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // E\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1   // F\r\n        };\r\n\r\n        // Attribute data with double quote (anything but \" \\0)\r\n        template<int Dummy>\r\n        const unsigned char lookup_tables<Dummy>::lookup_attribute_data_2[256] = \r\n        {\r\n          // 0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F\r\n             0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 0\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 1\r\n             1,  1,  0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 2\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 3\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 4\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 5\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 6\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 7\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 8\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 9\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // A\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // B\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // C\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // D\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // E\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1   // F\r\n        };\r\n\r\n        // Attribute data with double quote that does not require processing (anything but \" \\0 &)\r\n        template<int Dummy>\r\n        const unsigned char lookup_tables<Dummy>::lookup_attribute_data_2_pure[256] = \r\n        {\r\n          // 0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F\r\n             0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 0\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 1\r\n             1,  1,  0,  1,  1,  1,  0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 2\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 3\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 4\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 5\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 6\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 7\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 8\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 9\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // A\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // B\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // C\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // D\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // E\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1   // F\r\n        };\r\n\r\n        // Digits (dec and hex, 255 denotes end of numeric character reference)\r\n        template<int Dummy>\r\n        const unsigned char lookup_tables<Dummy>::lookup_digits[256] = \r\n        {\r\n          // 0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F\r\n           255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  // 0\r\n           255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  // 1\r\n           255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  // 2\r\n             0,  1,  2,  3,  4,  5,  6,  7,  8,  9,255,255,255,255,255,255,  // 3\r\n           255, 10, 11, 12, 13, 14, 15,255,255,255,255,255,255,255,255,255,  // 4\r\n           255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  // 5\r\n           255, 10, 11, 12, 13, 14, 15,255,255,255,255,255,255,255,255,255,  // 6\r\n           255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  // 7\r\n           255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  // 8\r\n           255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  // 9\r\n           255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  // A\r\n           255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  // B\r\n           255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  // C\r\n           255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  // D\r\n           255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  // E\r\n           255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255   // F\r\n        };\r\n    \r\n        // Upper case conversion\r\n        template<int Dummy>\r\n        const unsigned char lookup_tables<Dummy>::lookup_upcase[256] = \r\n        {\r\n          // 0,  1,  2,  3,  4,  5,  6,  7,  8,  9,  A   B   C   D   E   F\r\n           0,  1,  2,  3,  4,  5,  6,  7,  8,  9,  10, 11, 12, 13, 14, 15,   // 0\r\n           16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,   // 1\r\n           32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,   // 2\r\n           48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,   // 3\r\n           64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,   // 4\r\n           80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,   // 5\r\n           96, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,   // 6\r\n           80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 123,124,125,126,127,  // 7\r\n           128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,  // 8\r\n           144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,  // 9\r\n           160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,  // A\r\n           176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,  // B\r\n           192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,  // C\r\n           208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,  // D\r\n           224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,  // E\r\n           240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255   // F\r\n        };\r\n    }\r\n    //! \\endcond\r\n\r\n}\r\n\r\n// Undefine internal macros\r\n#undef RAPIDXML_PARSE_ERROR\r\n\r\n// On MSVC, restore warnings state\r\n#ifdef _MSC_VER\r\n    #pragma warning(pop)\r\n#endif\r\n\r\n#endif\r\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/rapidxml/rapidxml_iterators.hpp",
    "content": "#ifndef RAPIDXML_ITERATORS_HPP_INCLUDED\r\n#define RAPIDXML_ITERATORS_HPP_INCLUDED\r\n\r\n// Copyright (C) 2006, 2009 Marcin Kalicinski\r\n// Version 1.13\r\n// Revision $DateTime: 2009/05/13 01:46:17 $\r\n//! \\file rapidxml_iterators.hpp This file contains rapidxml iterators\r\n\r\n#include \"rapidxml.hpp\"\r\n\r\nnamespace rapidxml\r\n{\r\n\r\n    //! Iterator of child nodes of xml_node\r\n    template<class Ch>\r\n    class node_iterator\r\n    {\r\n    \r\n    public:\r\n\r\n        typedef typename xml_node<Ch> value_type;\r\n        typedef typename xml_node<Ch> &reference;\r\n        typedef typename xml_node<Ch> *pointer;\r\n        typedef std::ptrdiff_t difference_type;\r\n        typedef std::bidirectional_iterator_tag iterator_category;\r\n        \r\n        node_iterator()\r\n            : m_node(0)\r\n        {\r\n        }\r\n\r\n        node_iterator(xml_node<Ch> *node)\r\n            : m_node(node->first_node())\r\n        {\r\n        }\r\n        \r\n        reference operator *() const\r\n        {\r\n            assert(m_node);\r\n            return *m_node;\r\n        }\r\n\r\n        pointer operator->() const\r\n        {\r\n            assert(m_node);\r\n            return m_node;\r\n        }\r\n\r\n        node_iterator& operator++()\r\n        {\r\n            assert(m_node);\r\n            m_node = m_node->next_sibling();\r\n            return *this;\r\n        }\r\n\r\n        node_iterator operator++(int)\r\n        {\r\n            node_iterator tmp = *this;\r\n            ++this;\r\n            return tmp;\r\n        }\r\n\r\n        node_iterator& operator--()\r\n        {\r\n            assert(m_node && m_node->previous_sibling());\r\n            m_node = m_node->previous_sibling();\r\n            return *this;\r\n        }\r\n\r\n        node_iterator operator--(int)\r\n        {\r\n            node_iterator tmp = *this;\r\n            ++this;\r\n            return tmp;\r\n        }\r\n\r\n        bool operator ==(const node_iterator<Ch> &rhs)\r\n        {\r\n            return m_node == rhs.m_node;\r\n        }\r\n\r\n        bool operator !=(const node_iterator<Ch> &rhs)\r\n        {\r\n            return m_node != rhs.m_node;\r\n        }\r\n\r\n    private:\r\n\r\n        xml_node<Ch> *m_node;\r\n\r\n    };\r\n\r\n    //! Iterator of child attributes of xml_node\r\n    template<class Ch>\r\n    class attribute_iterator\r\n    {\r\n    \r\n    public:\r\n\r\n        typedef typename xml_attribute<Ch> value_type;\r\n        typedef typename xml_attribute<Ch> &reference;\r\n        typedef typename xml_attribute<Ch> *pointer;\r\n        typedef std::ptrdiff_t difference_type;\r\n        typedef std::bidirectional_iterator_tag iterator_category;\r\n        \r\n        attribute_iterator()\r\n            : m_attribute(0)\r\n        {\r\n        }\r\n\r\n        attribute_iterator(xml_node<Ch> *node)\r\n            : m_attribute(node->first_attribute())\r\n        {\r\n        }\r\n        \r\n        reference operator *() const\r\n        {\r\n            assert(m_attribute);\r\n            return *m_attribute;\r\n        }\r\n\r\n        pointer operator->() const\r\n        {\r\n            assert(m_attribute);\r\n            return m_attribute;\r\n        }\r\n\r\n        attribute_iterator& operator++()\r\n        {\r\n            assert(m_attribute);\r\n            m_attribute = m_attribute->next_attribute();\r\n            return *this;\r\n        }\r\n\r\n        attribute_iterator operator++(int)\r\n        {\r\n            attribute_iterator tmp = *this;\r\n            ++this;\r\n            return tmp;\r\n        }\r\n\r\n        attribute_iterator& operator--()\r\n        {\r\n            assert(m_attribute && m_attribute->previous_attribute());\r\n            m_attribute = m_attribute->previous_attribute();\r\n            return *this;\r\n        }\r\n\r\n        attribute_iterator operator--(int)\r\n        {\r\n            attribute_iterator tmp = *this;\r\n            ++this;\r\n            return tmp;\r\n        }\r\n\r\n        bool operator ==(const attribute_iterator<Ch> &rhs)\r\n        {\r\n            return m_attribute == rhs.m_attribute;\r\n        }\r\n\r\n        bool operator !=(const attribute_iterator<Ch> &rhs)\r\n        {\r\n            return m_attribute != rhs.m_attribute;\r\n        }\r\n\r\n    private:\r\n\r\n        xml_attribute<Ch> *m_attribute;\r\n\r\n    };\r\n\r\n}\r\n\r\n#endif\r\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/rapidxml/rapidxml_print.hpp",
    "content": "#ifndef RAPIDXML_PRINT_HPP_INCLUDED\r\n#define RAPIDXML_PRINT_HPP_INCLUDED\r\n\r\n// Copyright (C) 2006, 2009 Marcin Kalicinski\r\n// Version 1.13\r\n// Revision $DateTime: 2009/05/13 01:46:17 $\r\n//! \\file rapidxml_print.hpp This file contains rapidxml printer implementation\r\n\r\n#include \"rapidxml.hpp\"\r\n\r\n// Only include streams if not disabled\r\n#ifndef RAPIDXML_NO_STREAMS\r\n    #include <ostream>\r\n    #include <iterator>\r\n#endif\r\n\r\nnamespace rapidxml\r\n{\r\n\r\n    ///////////////////////////////////////////////////////////////////////\r\n    // Printing flags\r\n\r\n    const int print_no_indenting = 0x1;   //!< Printer flag instructing the printer to suppress indenting of XML. See print() function.\r\n\r\n    ///////////////////////////////////////////////////////////////////////\r\n    // Internal\r\n\r\n    //! \\cond internal\r\n    namespace internal\r\n    {\r\n        ///////////////////////////////////////////////////////////////////////////\r\n        // Function declarations\r\n        \r\n        template<class OutIt, class Ch>\r\n        inline OutIt copy_chars(const Ch *begin, const Ch *end, OutIt out);\r\n        \r\n        template<class OutIt, class Ch>\r\n        inline OutIt copy_and_expand_chars(const Ch *begin, const Ch *end, Ch noexpand, OutIt out);\r\n        \r\n        template<class OutIt, class Ch>\r\n        inline OutIt fill_chars(OutIt out, int n, Ch ch);\r\n        \r\n        template<class Ch, Ch ch>\r\n        inline bool find_char(const Ch *begin, const Ch *end);\r\n        \r\n        template<class OutIt, class Ch>\r\n        inline OutIt print_node(OutIt out, const xml_node<Ch> *node, int flags, int indent);\r\n        \r\n        template<class OutIt, class Ch>\r\n        inline OutIt print_children(OutIt out, const xml_node<Ch> *node, int flags, int indent);\r\n        \r\n        template<class OutIt, class Ch>\r\n        inline OutIt print_attributes(OutIt out, const xml_node<Ch> *node, int flags);\r\n        \r\n        template<class OutIt, class Ch>\r\n        inline OutIt print_data_node(OutIt out, const xml_node<Ch> *node, int flags, int indent);\r\n        \r\n        template<class OutIt, class Ch>\r\n        inline OutIt print_cdata_node(OutIt out, const xml_node<Ch> *node, int flags, int indent);\r\n        \r\n        template<class OutIt, class Ch>\r\n        inline OutIt print_element_node(OutIt out, const xml_node<Ch> *node, int flags, int indent);\r\n        \r\n        template<class OutIt, class Ch>\r\n        inline OutIt print_declaration_node(OutIt out, const xml_node<Ch> *node, int flags, int indent);\r\n        \r\n        template<class OutIt, class Ch>\r\n        inline OutIt print_comment_node(OutIt out, const xml_node<Ch> *node, int flags, int indent);\r\n        \r\n        template<class OutIt, class Ch>\r\n        inline OutIt print_doctype_node(OutIt out, const xml_node<Ch> *node, int flags, int indent);\r\n        \r\n        template<class OutIt, class Ch>\r\n        inline OutIt print_pi_node(OutIt out, const xml_node<Ch> *node, int flags, int indent);\r\n        \r\n        ///////////////////////////////////////////////////////////////////////////\r\n        // Internal character operations\r\n    \r\n        // Copy characters from given range to given output iterator\r\n        template<class OutIt, class Ch>\r\n        inline OutIt copy_chars(const Ch *begin, const Ch *end, OutIt out)\r\n        {\r\n            while (begin != end)\r\n                *out++ = *begin++;\r\n            return out;\r\n        }\r\n        \r\n        // Copy characters from given range to given output iterator and expand\r\n        // characters into references (&lt; &gt; &apos; &quot; &amp;)\r\n        template<class OutIt, class Ch>\r\n        inline OutIt copy_and_expand_chars(const Ch *begin, const Ch *end, Ch noexpand, OutIt out)\r\n        {\r\n            while (begin != end)\r\n            {\r\n                if (*begin == noexpand)\r\n                {\r\n                    *out++ = *begin;    // No expansion, copy character\r\n                }\r\n                else\r\n                {\r\n                    switch (*begin)\r\n                    {\r\n                    case Ch('<'):\r\n                        *out++ = Ch('&'); *out++ = Ch('l'); *out++ = Ch('t'); *out++ = Ch(';');\r\n                        break;\r\n                    case Ch('>'): \r\n                        *out++ = Ch('&'); *out++ = Ch('g'); *out++ = Ch('t'); *out++ = Ch(';');\r\n                        break;\r\n                    case Ch('\\''): \r\n                        *out++ = Ch('&'); *out++ = Ch('a'); *out++ = Ch('p'); *out++ = Ch('o'); *out++ = Ch('s'); *out++ = Ch(';');\r\n                        break;\r\n                    case Ch('\"'): \r\n                        *out++ = Ch('&'); *out++ = Ch('q'); *out++ = Ch('u'); *out++ = Ch('o'); *out++ = Ch('t'); *out++ = Ch(';');\r\n                        break;\r\n                    case Ch('&'): \r\n                        *out++ = Ch('&'); *out++ = Ch('a'); *out++ = Ch('m'); *out++ = Ch('p'); *out++ = Ch(';'); \r\n                        break;\r\n                    default:\r\n                        *out++ = *begin;    // No expansion, copy character\r\n                    }\r\n                }\r\n                ++begin;    // Step to next character\r\n            }\r\n            return out;\r\n        }\r\n\r\n        // Fill given output iterator with repetitions of the same character\r\n        template<class OutIt, class Ch>\r\n        inline OutIt fill_chars(OutIt out, int n, Ch ch)\r\n        {\r\n            for (int i = 0; i < n; ++i)\r\n                *out++ = ch;\r\n            return out;\r\n        }\r\n\r\n        // Find character\r\n        template<class Ch, Ch ch>\r\n        inline bool find_char(const Ch *begin, const Ch *end)\r\n        {\r\n            while (begin != end)\r\n                if (*begin++ == ch)\r\n                    return true;\r\n            return false;\r\n        }\r\n\r\n        ///////////////////////////////////////////////////////////////////////////\r\n        // Internal printing operations\r\n    \r\n        // Print node\r\n        template<class OutIt, class Ch>\r\n        inline OutIt print_node(OutIt out, const xml_node<Ch> *node, int flags, int indent)\r\n        {\r\n            // Print proper node type\r\n            switch (node->type())\r\n            {\r\n\r\n            // Document\r\n            case node_document:\r\n                out = print_children(out, node, flags, indent);\r\n                break;\r\n\r\n            // Element\r\n            case node_element:\r\n                out = print_element_node(out, node, flags, indent);\r\n                break;\r\n            \r\n            // Data\r\n            case node_data:\r\n                out = print_data_node(out, node, flags, indent);\r\n                break;\r\n            \r\n            // CDATA\r\n            case node_cdata:\r\n                out = print_cdata_node(out, node, flags, indent);\r\n                break;\r\n\r\n            // Declaration\r\n            case node_declaration:\r\n                out = print_declaration_node(out, node, flags, indent);\r\n                break;\r\n\r\n            // Comment\r\n            case node_comment:\r\n                out = print_comment_node(out, node, flags, indent);\r\n                break;\r\n            \r\n            // Doctype\r\n            case node_doctype:\r\n                out = print_doctype_node(out, node, flags, indent);\r\n                break;\r\n\r\n            // Pi\r\n            case node_pi:\r\n                out = print_pi_node(out, node, flags, indent);\r\n                break;\r\n\r\n                // Unknown\r\n            default:\r\n                assert(0);\r\n                break;\r\n            }\r\n            \r\n            // If indenting not disabled, add line break after node\r\n            if (!(flags & print_no_indenting))\r\n                *out = Ch('\\n'), ++out;\r\n\r\n            // Return modified iterator\r\n            return out;\r\n        }\r\n        \r\n        // Print children of the node                               \r\n        template<class OutIt, class Ch>\r\n        inline OutIt print_children(OutIt out, const xml_node<Ch> *node, int flags, int indent)\r\n        {\r\n            for (xml_node<Ch> *child = node->first_node(); child; child = child->next_sibling())\r\n                out = print_node(out, child, flags, indent);\r\n            return out;\r\n        }\r\n\r\n        // Print attributes of the node\r\n        template<class OutIt, class Ch>\r\n        inline OutIt print_attributes(OutIt out, const xml_node<Ch> *node, int flags)\r\n        {\r\n            for (xml_attribute<Ch> *attribute = node->first_attribute(); attribute; attribute = attribute->next_attribute())\r\n            {\r\n                if (attribute->name() && attribute->value())\r\n                {\r\n                    // Print attribute name\r\n                    *out = Ch(' '), ++out;\r\n                    out = copy_chars(attribute->name(), attribute->name() + attribute->name_size(), out);\r\n                    *out = Ch('='), ++out;\r\n                    // Print attribute value using appropriate quote type\r\n                    if (find_char<Ch, Ch('\"')>(attribute->value(), attribute->value() + attribute->value_size()))\r\n                    {\r\n                        *out = Ch('\\''), ++out;\r\n                        out = copy_and_expand_chars(attribute->value(), attribute->value() + attribute->value_size(), Ch('\"'), out);\r\n                        *out = Ch('\\''), ++out;\r\n                    }\r\n                    else\r\n                    {\r\n                        *out = Ch('\"'), ++out;\r\n                        out = copy_and_expand_chars(attribute->value(), attribute->value() + attribute->value_size(), Ch('\\''), out);\r\n                        *out = Ch('\"'), ++out;\r\n                    }\r\n                }\r\n            }\r\n            return out;\r\n        }\r\n\r\n        // Print data node\r\n        template<class OutIt, class Ch>\r\n        inline OutIt print_data_node(OutIt out, const xml_node<Ch> *node, int flags, int indent)\r\n        {\r\n            assert(node->type() == node_data);\r\n            if (!(flags & print_no_indenting))\r\n                out = fill_chars(out, indent, Ch('\\t'));\r\n            out = copy_and_expand_chars(node->value(), node->value() + node->value_size(), Ch(0), out);\r\n            return out;\r\n        }\r\n\r\n        // Print data node\r\n        template<class OutIt, class Ch>\r\n        inline OutIt print_cdata_node(OutIt out, const xml_node<Ch> *node, int flags, int indent)\r\n        {\r\n            assert(node->type() == node_cdata);\r\n            if (!(flags & print_no_indenting))\r\n                out = fill_chars(out, indent, Ch('\\t'));\r\n            *out = Ch('<'); ++out;\r\n            *out = Ch('!'); ++out;\r\n            *out = Ch('['); ++out;\r\n            *out = Ch('C'); ++out;\r\n            *out = Ch('D'); ++out;\r\n            *out = Ch('A'); ++out;\r\n            *out = Ch('T'); ++out;\r\n            *out = Ch('A'); ++out;\r\n            *out = Ch('['); ++out;\r\n            out = copy_chars(node->value(), node->value() + node->value_size(), out);\r\n            *out = Ch(']'); ++out;\r\n            *out = Ch(']'); ++out;\r\n            *out = Ch('>'); ++out;\r\n            return out;\r\n        }\r\n\r\n        // Print element node\r\n        template<class OutIt, class Ch>\r\n        inline OutIt print_element_node(OutIt out, const xml_node<Ch> *node, int flags, int indent)\r\n        {\r\n            assert(node->type() == node_element);\r\n\r\n            // Print element name and attributes, if any\r\n            if (!(flags & print_no_indenting))\r\n                out = fill_chars(out, indent, Ch('\\t'));\r\n            *out = Ch('<'), ++out;\r\n            out = copy_chars(node->name(), node->name() + node->name_size(), out);\r\n            out = print_attributes(out, node, flags);\r\n            \r\n            // If node is childless\r\n            if (node->value_size() == 0 && !node->first_node())\r\n            {\r\n                // Print childless node tag ending\r\n                *out = Ch('/'), ++out;\r\n                *out = Ch('>'), ++out;\r\n            }\r\n            else\r\n            {\r\n                // Print normal node tag ending\r\n                *out = Ch('>'), ++out;\r\n\r\n                // Test if node contains a single data node only (and no other nodes)\r\n                xml_node<Ch> *child = node->first_node();\r\n                if (!child)\r\n                {\r\n                    // If node has no children, only print its value without indenting\r\n                    out = copy_and_expand_chars(node->value(), node->value() + node->value_size(), Ch(0), out);\r\n                }\r\n                else if (child->next_sibling() == 0 && child->type() == node_data)\r\n                {\r\n                    // If node has a sole data child, only print its value without indenting\r\n                    out = copy_and_expand_chars(child->value(), child->value() + child->value_size(), Ch(0), out);\r\n                }\r\n                else\r\n                {\r\n                    // Print all children with full indenting\r\n                    if (!(flags & print_no_indenting))\r\n                        *out = Ch('\\n'), ++out;\r\n                    out = print_children(out, node, flags, indent + 1);\r\n                    if (!(flags & print_no_indenting))\r\n                        out = fill_chars(out, indent, Ch('\\t'));\r\n                }\r\n\r\n                // Print node end\r\n                *out = Ch('<'), ++out;\r\n                *out = Ch('/'), ++out;\r\n                out = copy_chars(node->name(), node->name() + node->name_size(), out);\r\n                *out = Ch('>'), ++out;\r\n            }\r\n            return out;\r\n        }\r\n\r\n        // Print declaration node\r\n        template<class OutIt, class Ch>\r\n        inline OutIt print_declaration_node(OutIt out, const xml_node<Ch> *node, int flags, int indent)\r\n        {\r\n            // Print declaration start\r\n            if (!(flags & print_no_indenting))\r\n                out = fill_chars(out, indent, Ch('\\t'));\r\n            *out = Ch('<'), ++out;\r\n            *out = Ch('?'), ++out;\r\n            *out = Ch('x'), ++out;\r\n            *out = Ch('m'), ++out;\r\n            *out = Ch('l'), ++out;\r\n\r\n            // Print attributes\r\n            out = print_attributes(out, node, flags);\r\n            \r\n            // Print declaration end\r\n            *out = Ch('?'), ++out;\r\n            *out = Ch('>'), ++out;\r\n            \r\n            return out;\r\n        }\r\n\r\n        // Print comment node\r\n        template<class OutIt, class Ch>\r\n        inline OutIt print_comment_node(OutIt out, const xml_node<Ch> *node, int flags, int indent)\r\n        {\r\n            assert(node->type() == node_comment);\r\n            if (!(flags & print_no_indenting))\r\n                out = fill_chars(out, indent, Ch('\\t'));\r\n            *out = Ch('<'), ++out;\r\n            *out = Ch('!'), ++out;\r\n            *out = Ch('-'), ++out;\r\n            *out = Ch('-'), ++out;\r\n            out = copy_chars(node->value(), node->value() + node->value_size(), out);\r\n            *out = Ch('-'), ++out;\r\n            *out = Ch('-'), ++out;\r\n            *out = Ch('>'), ++out;\r\n            return out;\r\n        }\r\n\r\n        // Print doctype node\r\n        template<class OutIt, class Ch>\r\n        inline OutIt print_doctype_node(OutIt out, const xml_node<Ch> *node, int flags, int indent)\r\n        {\r\n            assert(node->type() == node_doctype);\r\n            if (!(flags & print_no_indenting))\r\n                out = fill_chars(out, indent, Ch('\\t'));\r\n            *out = Ch('<'), ++out;\r\n            *out = Ch('!'), ++out;\r\n            *out = Ch('D'), ++out;\r\n            *out = Ch('O'), ++out;\r\n            *out = Ch('C'), ++out;\r\n            *out = Ch('T'), ++out;\r\n            *out = Ch('Y'), ++out;\r\n            *out = Ch('P'), ++out;\r\n            *out = Ch('E'), ++out;\r\n            *out = Ch(' '), ++out;\r\n            out = copy_chars(node->value(), node->value() + node->value_size(), out);\r\n            *out = Ch('>'), ++out;\r\n            return out;\r\n        }\r\n\r\n        // Print pi node\r\n        template<class OutIt, class Ch>\r\n        inline OutIt print_pi_node(OutIt out, const xml_node<Ch> *node, int flags, int indent)\r\n        {\r\n            assert(node->type() == node_pi);\r\n            if (!(flags & print_no_indenting))\r\n                out = fill_chars(out, indent, Ch('\\t'));\r\n            *out = Ch('<'), ++out;\r\n            *out = Ch('?'), ++out;\r\n            out = copy_chars(node->name(), node->name() + node->name_size(), out);\r\n            *out = Ch(' '), ++out;\r\n            out = copy_chars(node->value(), node->value() + node->value_size(), out);\r\n            *out = Ch('?'), ++out;\r\n            *out = Ch('>'), ++out;\r\n            return out;\r\n        }\r\n\r\n    }\r\n    //! \\endcond\r\n\r\n    ///////////////////////////////////////////////////////////////////////////\r\n    // Printing\r\n\r\n    //! Prints XML to given output iterator.\r\n    //! \\param out Output iterator to print to.\r\n    //! \\param node Node to be printed. Pass xml_document to print entire document.\r\n    //! \\param flags Flags controlling how XML is printed.\r\n    //! \\return Output iterator pointing to position immediately after last character of printed text.\r\n    template<class OutIt, class Ch> \r\n    inline OutIt print(OutIt out, const xml_node<Ch> &node, int flags = 0)\r\n    {\r\n        return internal::print_node(out, &node, flags, 0);\r\n    }\r\n\r\n#ifndef RAPIDXML_NO_STREAMS\r\n\r\n    //! Prints XML to given output stream.\r\n    //! \\param out Output stream to print to.\r\n    //! \\param node Node to be printed. Pass xml_document to print entire document.\r\n    //! \\param flags Flags controlling how XML is printed.\r\n    //! \\return Output stream.\r\n    template<class Ch> \r\n    inline std::basic_ostream<Ch> &print(std::basic_ostream<Ch> &out, const xml_node<Ch> &node, int flags = 0)\r\n    {\r\n        print(std::ostream_iterator<Ch>(out), node, flags);\r\n        return out;\r\n    }\r\n\r\n    //! Prints formatted XML to given output stream. Uses default printing flags. Use print() function to customize printing process.\r\n    //! \\param out Output stream to print to.\r\n    //! \\param node Node to be printed.\r\n    //! \\return Output stream.\r\n    template<class Ch> \r\n    inline std::basic_ostream<Ch> &operator <<(std::basic_ostream<Ch> &out, const xml_node<Ch> &node)\r\n    {\r\n        return print(out, node);\r\n    }\r\n\r\n#endif\r\n\r\n}\r\n\r\n#endif\r\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/rapidxml/rapidxml_utils.hpp",
    "content": "#ifndef RAPIDXML_UTILS_HPP_INCLUDED\r\n#define RAPIDXML_UTILS_HPP_INCLUDED\r\n\r\n// Copyright (C) 2006, 2009 Marcin Kalicinski\r\n// Version 1.13\r\n// Revision $DateTime: 2009/05/13 01:46:17 $\r\n//! \\file rapidxml_utils.hpp This file contains high-level rapidxml utilities that can be useful\r\n//! in certain simple scenarios. They should probably not be used if maximizing performance is the main objective.\r\n\r\n#include \"rapidxml.hpp\"\r\n#include <vector>\r\n#include <string>\r\n#include <fstream>\r\n#include <stdexcept>\r\n\r\nnamespace rapidxml\r\n{\r\n\r\n    //! Represents data loaded from a file\r\n    template<class Ch = char>\r\n    class file\r\n    {\r\n        \r\n    public:\r\n        \r\n        //! Loads file into the memory. Data will be automatically destroyed by the destructor.\r\n        //! \\param filename Filename to load.\r\n        file(const char *filename)\r\n        {\r\n            using namespace std;\r\n\r\n            // Open stream\r\n            basic_ifstream<Ch> stream(filename, ios::binary);\r\n            if (!stream)\r\n                throw runtime_error(string(\"cannot open file \") + filename);\r\n            stream.unsetf(ios::skipws);\r\n            \r\n            // Determine stream size\r\n            stream.seekg(0, ios::end);\r\n            size_t size = stream.tellg();\r\n            stream.seekg(0);   \r\n            \r\n            // Load data and add terminating 0\r\n            m_data.resize(size + 1);\r\n            stream.read(&m_data.front(), static_cast<streamsize>(size));\r\n            m_data[size] = 0;\r\n        }\r\n\r\n        //! Loads file into the memory. Data will be automatically destroyed by the destructor\r\n        //! \\param stream Stream to load from\r\n        file(std::basic_istream<Ch> &stream)\r\n        {\r\n            using namespace std;\r\n\r\n            // Load data and add terminating 0\r\n            stream.unsetf(ios::skipws);\r\n            m_data.assign(istreambuf_iterator<Ch>(stream), istreambuf_iterator<Ch>());\r\n            if (stream.fail() || stream.bad())\r\n                throw runtime_error(\"error reading stream\");\r\n            m_data.push_back(0);\r\n        }\r\n        \r\n        //! Gets file data.\r\n        //! \\return Pointer to data of file.\r\n        Ch *data()\r\n        {\r\n            return &m_data.front();\r\n        }\r\n\r\n        //! Gets file data.\r\n        //! \\return Pointer to data of file.\r\n        const Ch *data() const\r\n        {\r\n            return &m_data.front();\r\n        }\r\n\r\n        //! Gets file data size.\r\n        //! \\return Size of file data, in characters.\r\n        std::size_t size() const\r\n        {\r\n            return m_data.size();\r\n        }\r\n\r\n    private:\r\n\r\n        std::vector<Ch> m_data;   // File data\r\n\r\n    };\r\n\r\n    //! Counts children of node. Time complexity is O(n).\r\n    //! \\return Number of children of node\r\n    template<class Ch>\r\n    inline std::size_t count_children(xml_node<Ch> *node)\r\n    {\r\n        xml_node<Ch> *child = node->first_node();\r\n        std::size_t count = 0;\r\n        while (child)\r\n        {\r\n            ++count;\r\n            child = child->next_sibling();\r\n        }\r\n        return count;\r\n    }\r\n\r\n    //! Counts attributes of node. Time complexity is O(n).\r\n    //! \\return Number of attributes of node\r\n    template<class Ch>\r\n    inline std::size_t count_attributes(xml_node<Ch> *node)\r\n    {\r\n        xml_attribute<Ch> *attr = node->first_attribute();\r\n        std::size_t count = 0;\r\n        while (attr)\r\n        {\r\n            ++count;\r\n            attr = attr->next_attribute();\r\n        }\r\n        return count;\r\n    }\r\n\r\n}\r\n\r\n#endif\r\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/vcinclude/common.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n#ifndef __VC_INCLUDE_COMMON_H__\n#define __VC_INCLUDE_COMMON_H__\n\n#include \"interface/vcos/vcos_stdint.h\"\n#include \"interface/vctypes/vc_image_types.h\"\n\n#if defined(__HIGHC__) && defined(_VIDEOCORE) && !defined(_I386)\n// __HIGHC__ is only available with MW\n// The scvc plugins are compiled (bizarrely) on an x86 with _VIDEOCORE set!\n#include <vc/intrinsics.h>\n#endif\n\n#ifdef __COVERITY__\n#ifndef _Rarely\n#define _Rarely(x) (x)\n#endif\n#ifndef _Usually\n#define _Usually(x) (x)\n#endif\n#endif\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#ifdef __SYMBIAN32__\n# ifndef INLINE\n#  define INLINE __inline\n# endif\n\n/* Align a pointer/integer by rounding up/down */\n#define ALIGN_DOWN(p, n)   ((uint32_t)(p) - ( (uint32_t)(p) % (uint32_t)(n) ))\n#define ALIGN_UP(p, n)     ALIGN_DOWN((uint32_t)(p) + (uint32_t)(n) - 1, (n))\n\n#elif defined (VCMODS_LCC)\n#include <limits.h>\n\n\n#elif !defined(__KERNEL__)\n#include <limits.h>\n\n#endif\n\n\n/*}}}*/\n\n/* Fixed-point types */\ntypedef unsigned short uint8p8_t;\ntypedef signed short sint8p8_t;\ntypedef unsigned short uint4p12_t;\ntypedef signed short sint4p12_t;\ntypedef signed short sint0p16_t;\ntypedef signed char sint8p0_t;\ntypedef unsigned char uint0p8_t;\ntypedef signed long int24p8_t;\n\n/*{{{ Common typedefs */\n\ntypedef enum bool_e\n{\n   VC_FALSE = 0,\n   VC_TRUE = 1,\n} VC_BOOL_T;\n\n#ifndef bool_t\n#define bool_t VC_BOOL_T\n#endif\n\n/*}}}*/\n\n/*{{{ Common macros */\n\n\n/* Align a pointer/integer by rounding up/down */\n#define ALIGN_DOWN(p, n)   ((uintptr_t)(p) - ( (uintptr_t)(p) % (uintptr_t)(n) ))\n#define ALIGN_UP(p, n)     ALIGN_DOWN((uintptr_t)(p) + (uintptr_t)(n) - 1, (n))\n\n#define CLIP(lower, n, upper) _min((upper), _max((lower), (n)))\n\n/*}}}*/\n\n/*{{{ Debugging and profiling macros */\n\n#if 0\n/* There's already an assert_once in <logging/logging.h> */\n#ifdef DEBUG\n#define assert_once(x) \\\n   { \\\n      static uint8_t ignore = 0; \\\n      if(!ignore) \\\n      { \\\n         assert(x); \\\n         ignore++; \\\n      } \\\n   }\n#else\n#define assert_once(x) (void)0\n#endif\n#endif /* 0 */\n\n#if defined(__HIGHC__) && !defined(NDEBUG)\n/* HighC lacks a __FUNCTION__ preproc symbol... :( */\n#define profile_rename(name) _ASM(\".global \" name \"\\n\" name \":\\n\")\n#else\n#define profile_rename(name) (void)0\n#endif\n\n/*}}}*/\n#ifdef __cplusplus\n }\n#endif\n#endif /* __VCINCLUDE_COMMON_H__ */\n\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/vcinclude/vc_image_types.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n#ifndef __VC_INCLUDE_IMAGE_TYPES_H__\n#define __VC_INCLUDE_IMAGE_TYPES_H__\n\n#include \"interface/vctypes/vc_image_types.h\"\n\n#endif /* __VC_INCLUDE_IMAGE_TYPES_H__ */\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/vcinclude/vcore.h",
    "content": "/*\nCopyright (c) 2012, Broadcom Europe Ltd\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the copyright holder nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n#ifndef VCORE_H\n#define VCORE_H\n\n#ifdef __VIDEOCORE__\n#include \"vc/intrinsics.h\"\n#undef asm\n#define asm(x) _ASM(x)\n\n#undef min\n#define min(x,y) _min(x,y)\n\n#undef max\n#define max(x,y) _max(x,y)\n\n#ifndef abs\n#define abs(x) _abs(x)\n#endif\n#else\n#define _vasm asm\n#define _bkpt() do {asm(\" bkpt\");}while(0)\n#define _di() do{asm(\" di\");}while(0)\n#define _ei() do{asm(\" ei\");}while(0)\n#define _nop() do{asm(\" nop\");}while(0)\n#define _sleep() do{asm(\" sleep\");}while(0)\n\n#undef min\n#define min(x,y) ((x)<(y) ? (x):(y))\n\n#undef max\n#define max(x,y) ((x)>(y) ? (x):(y))\n\n#ifndef abs\n#define abs(x) ((x)>=0 ? (x):-(x))\n#endif\n#endif\n\n#endif\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/zconf.h",
    "content": "/* zconf.h -- configuration of the zlib compression library\n * Copyright (C) 1995-2010 Jean-loup Gailly.\n * For conditions of distribution and use, see copyright notice in zlib.h\n */\n\n/* @(#) $Id$ */\n\n#ifndef ZCONF_H\n#define ZCONF_H\n\n/*\n * If you *really* need a unique prefix for all types and library functions,\n * compile with -DZ_PREFIX. The \"standard\" zlib should be compiled without it.\n * Even better than compiling with -DZ_PREFIX would be to use configure to set\n * this permanently in zconf.h using \"./configure --zprefix\".\n */\n#ifdef Z_PREFIX     /* may be set to #if 1 by ./configure */\n\n/* all linked symbols */\n#  define _dist_code            z__dist_code\n#  define _length_code          z__length_code\n#  define _tr_align             z__tr_align\n#  define _tr_flush_block       z__tr_flush_block\n#  define _tr_init              z__tr_init\n#  define _tr_stored_block      z__tr_stored_block\n#  define _tr_tally             z__tr_tally\n#  define adler32               z_adler32\n#  define adler32_combine       z_adler32_combine\n#  define adler32_combine64     z_adler32_combine64\n#  define compress              z_compress\n#  define compress2             z_compress2\n#  define compressBound         z_compressBound\n#  define crc32                 z_crc32\n#  define crc32_combine         z_crc32_combine\n#  define crc32_combine64       z_crc32_combine64\n#  define deflate               z_deflate\n#  define deflateBound          z_deflateBound\n#  define deflateCopy           z_deflateCopy\n#  define deflateEnd            z_deflateEnd\n#  define deflateInit2_         z_deflateInit2_\n#  define deflateInit_          z_deflateInit_\n#  define deflateParams         z_deflateParams\n#  define deflatePrime          z_deflatePrime\n#  define deflateReset          z_deflateReset\n#  define deflateSetDictionary  z_deflateSetDictionary\n#  define deflateSetHeader      z_deflateSetHeader\n#  define deflateTune           z_deflateTune\n#  define deflate_copyright     z_deflate_copyright\n#  define get_crc_table         z_get_crc_table\n#  define gz_error              z_gz_error\n#  define gz_intmax             z_gz_intmax\n#  define gz_strwinerror        z_gz_strwinerror\n#  define gzbuffer              z_gzbuffer\n#  define gzclearerr            z_gzclearerr\n#  define gzclose               z_gzclose\n#  define gzclose_r             z_gzclose_r\n#  define gzclose_w             z_gzclose_w\n#  define gzdirect              z_gzdirect\n#  define gzdopen               z_gzdopen\n#  define gzeof                 z_gzeof\n#  define gzerror               z_gzerror\n#  define gzflush               z_gzflush\n#  define gzgetc                z_gzgetc\n#  define gzgets                z_gzgets\n#  define gzoffset              z_gzoffset\n#  define gzoffset64            z_gzoffset64\n#  define gzopen                z_gzopen\n#  define gzopen64              z_gzopen64\n#  define gzprintf              z_gzprintf\n#  define gzputc                z_gzputc\n#  define gzputs                z_gzputs\n#  define gzread                z_gzread\n#  define gzrewind              z_gzrewind\n#  define gzseek                z_gzseek\n#  define gzseek64              z_gzseek64\n#  define gzsetparams           z_gzsetparams\n#  define gztell                z_gztell\n#  define gztell64              z_gztell64\n#  define gzungetc              z_gzungetc\n#  define gzwrite               z_gzwrite\n#  define inflate               z_inflate\n#  define inflateBack           z_inflateBack\n#  define inflateBackEnd        z_inflateBackEnd\n#  define inflateBackInit_      z_inflateBackInit_\n#  define inflateCopy           z_inflateCopy\n#  define inflateEnd            z_inflateEnd\n#  define inflateGetHeader      z_inflateGetHeader\n#  define inflateInit2_         z_inflateInit2_\n#  define inflateInit_          z_inflateInit_\n#  define inflateMark           z_inflateMark\n#  define inflatePrime          z_inflatePrime\n#  define inflateReset          z_inflateReset\n#  define inflateReset2         z_inflateReset2\n#  define inflateSetDictionary  z_inflateSetDictionary\n#  define inflateSync           z_inflateSync\n#  define inflateSyncPoint      z_inflateSyncPoint\n#  define inflateUndermine      z_inflateUndermine\n#  define inflate_copyright     z_inflate_copyright\n#  define inflate_fast          z_inflate_fast\n#  define inflate_table         z_inflate_table\n#  define uncompress            z_uncompress\n#  define zError                z_zError\n#  define zcalloc               z_zcalloc\n#  define zcfree                z_zcfree\n#  define zlibCompileFlags      z_zlibCompileFlags\n#  define zlibVersion           z_zlibVersion\n\n/* all zlib typedefs in zlib.h and zconf.h */\n#  define Byte                  z_Byte\n#  define Bytef                 z_Bytef\n#  define alloc_func            z_alloc_func\n#  define charf                 z_charf\n#  define free_func             z_free_func\n#  define gzFile                z_gzFile\n#  define gz_header             z_gz_header\n#  define gz_headerp            z_gz_headerp\n#  define in_func               z_in_func\n#  define intf                  z_intf\n#  define out_func              z_out_func\n#  define uInt                  z_uInt\n#  define uIntf                 z_uIntf\n#  define uLong                 z_uLong\n#  define uLongf                z_uLongf\n#  define voidp                 z_voidp\n#  define voidpc                z_voidpc\n#  define voidpf                z_voidpf\n\n/* all zlib structs in zlib.h and zconf.h */\n#  define gz_header_s           z_gz_header_s\n#  define internal_state        z_internal_state\n\n#endif\n\n#if defined(__MSDOS__) && !defined(MSDOS)\n#  define MSDOS\n#endif\n#if (defined(OS_2) || defined(__OS2__)) && !defined(OS2)\n#  define OS2\n#endif\n#if defined(_WINDOWS) && !defined(WINDOWS)\n#  define WINDOWS\n#endif\n#if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__)\n#  ifndef WIN32\n#    define WIN32\n#  endif\n#endif\n#if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32)\n#  if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__)\n#    ifndef SYS16BIT\n#      define SYS16BIT\n#    endif\n#  endif\n#endif\n\n/*\n * Compile with -DMAXSEG_64K if the alloc function cannot allocate more\n * than 64k bytes at a time (needed on systems with 16-bit int).\n */\n#ifdef SYS16BIT\n#  define MAXSEG_64K\n#endif\n#ifdef MSDOS\n#  define UNALIGNED_OK\n#endif\n\n#ifdef __STDC_VERSION__\n#  ifndef STDC\n#    define STDC\n#  endif\n#  if __STDC_VERSION__ >= 199901L\n#    ifndef STDC99\n#      define STDC99\n#    endif\n#  endif\n#endif\n#if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus))\n#  define STDC\n#endif\n#if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__))\n#  define STDC\n#endif\n#if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32))\n#  define STDC\n#endif\n#if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__))\n#  define STDC\n#endif\n\n#if defined(__OS400__) && !defined(STDC)    /* iSeries (formerly AS/400). */\n#  define STDC\n#endif\n\n#ifndef STDC\n#  ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */\n#    define const       /* note: need a more gentle solution here */\n#  endif\n#endif\n\n/* Some Mac compilers merge all .h files incorrectly: */\n#if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__)\n#  define NO_DUMMY_DECL\n#endif\n\n/* Maximum value for memLevel in deflateInit2 */\n#ifndef MAX_MEM_LEVEL\n#  ifdef MAXSEG_64K\n#    define MAX_MEM_LEVEL 8\n#  else\n#    define MAX_MEM_LEVEL 9\n#  endif\n#endif\n\n/* Maximum value for windowBits in deflateInit2 and inflateInit2.\n * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files\n * created by gzip. (Files created by minigzip can still be extracted by\n * gzip.)\n */\n#ifndef MAX_WBITS\n#  define MAX_WBITS   15 /* 32K LZ77 window */\n#endif\n\n/* The memory requirements for deflate are (in bytes):\n            (1 << (windowBits+2)) +  (1 << (memLevel+9))\n that is: 128K for windowBits=15  +  128K for memLevel = 8  (default values)\n plus a few kilobytes for small objects. For example, if you want to reduce\n the default memory requirements from 256K to 128K, compile with\n     make CFLAGS=\"-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7\"\n Of course this will generally degrade compression (there's no free lunch).\n\n   The memory requirements for inflate are (in bytes) 1 << windowBits\n that is, 32K for windowBits=15 (default value) plus a few kilobytes\n for small objects.\n*/\n\n                        /* Type declarations */\n\n#ifndef OF /* function prototypes */\n#  ifdef STDC\n#    define OF(args)  args\n#  else\n#    define OF(args)  ()\n#  endif\n#endif\n\n/* The following definitions for FAR are needed only for MSDOS mixed\n * model programming (small or medium model with some far allocations).\n * This was tested only with MSC; for other MSDOS compilers you may have\n * to define NO_MEMCPY in zutil.h.  If you don't need the mixed model,\n * just define FAR to be empty.\n */\n#ifdef SYS16BIT\n#  if defined(M_I86SM) || defined(M_I86MM)\n     /* MSC small or medium model */\n#    define SMALL_MEDIUM\n#    ifdef _MSC_VER\n#      define FAR _far\n#    else\n#      define FAR far\n#    endif\n#  endif\n#  if (defined(__SMALL__) || defined(__MEDIUM__))\n     /* Turbo C small or medium model */\n#    define SMALL_MEDIUM\n#    ifdef __BORLANDC__\n#      define FAR _far\n#    else\n#      define FAR far\n#    endif\n#  endif\n#endif\n\n#if defined(WINDOWS) || defined(WIN32)\n   /* If building or using zlib as a DLL, define ZLIB_DLL.\n    * This is not mandatory, but it offers a little performance increase.\n    */\n#  ifdef ZLIB_DLL\n#    if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500))\n#      ifdef ZLIB_INTERNAL\n#        define ZEXTERN extern __declspec(dllexport)\n#      else\n#        define ZEXTERN extern __declspec(dllimport)\n#      endif\n#    endif\n#  endif  /* ZLIB_DLL */\n   /* If building or using zlib with the WINAPI/WINAPIV calling convention,\n    * define ZLIB_WINAPI.\n    * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI.\n    */\n#  ifdef ZLIB_WINAPI\n#    ifdef FAR\n#      undef FAR\n#    endif\n#    include <windows.h>\n     /* No need for _export, use ZLIB.DEF instead. */\n     /* For complete Windows compatibility, use WINAPI, not __stdcall. */\n#    define ZEXPORT WINAPI\n#    ifdef WIN32\n#      define ZEXPORTVA WINAPIV\n#    else\n#      define ZEXPORTVA FAR CDECL\n#    endif\n#  endif\n#endif\n\n#if defined (__BEOS__)\n#  ifdef ZLIB_DLL\n#    ifdef ZLIB_INTERNAL\n#      define ZEXPORT   __declspec(dllexport)\n#      define ZEXPORTVA __declspec(dllexport)\n#    else\n#      define ZEXPORT   __declspec(dllimport)\n#      define ZEXPORTVA __declspec(dllimport)\n#    endif\n#  endif\n#endif\n\n#ifndef ZEXTERN\n#  define ZEXTERN extern\n#endif\n#ifndef ZEXPORT\n#  define ZEXPORT\n#endif\n#ifndef ZEXPORTVA\n#  define ZEXPORTVA\n#endif\n\n#ifndef FAR\n#  define FAR\n#endif\n\n#if !defined(__MACTYPES__)\ntypedef unsigned char  Byte;  /* 8 bits */\n#endif\ntypedef unsigned int   uInt;  /* 16 bits or more */\ntypedef unsigned long  uLong; /* 32 bits or more */\n\n#ifdef SMALL_MEDIUM\n   /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */\n#  define Bytef Byte FAR\n#else\n   typedef Byte  FAR Bytef;\n#endif\ntypedef char  FAR charf;\ntypedef int   FAR intf;\ntypedef uInt  FAR uIntf;\ntypedef uLong FAR uLongf;\n\n#ifdef STDC\n   typedef void const *voidpc;\n   typedef void FAR   *voidpf;\n   typedef void       *voidp;\n#else\n   typedef Byte const *voidpc;\n   typedef Byte FAR   *voidpf;\n   typedef Byte       *voidp;\n#endif\n\n#ifdef HAVE_UNISTD_H    /* may be set to #if 1 by ./configure */\n#  define Z_HAVE_UNISTD_H\n#endif\n\n#ifdef STDC\n#  include <sys/types.h>    /* for off_t */\n#endif\n\n/* a little trick to accommodate both \"#define _LARGEFILE64_SOURCE\" and\n * \"#define _LARGEFILE64_SOURCE 1\" as requesting 64-bit operations, (even\n * though the former does not conform to the LFS document), but considering\n * both \"#undef _LARGEFILE64_SOURCE\" and \"#define _LARGEFILE64_SOURCE 0\" as\n * equivalently requesting no 64-bit operations\n */\n#if -_LARGEFILE64_SOURCE - -1 == 1\n#  undef _LARGEFILE64_SOURCE\n#endif\n\n#if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE)\n#  include <unistd.h>       /* for SEEK_* and off_t */\n#  ifdef VMS\n#    include <unixio.h>     /* for off_t */\n#  endif\n#  ifndef z_off_t\n#    define z_off_t off_t\n#  endif\n#endif\n\n#ifndef SEEK_SET\n#  define SEEK_SET        0       /* Seek from beginning of file.  */\n#  define SEEK_CUR        1       /* Seek from current position.  */\n#  define SEEK_END        2       /* Set file pointer to EOF plus \"offset\" */\n#endif\n\n#ifndef z_off_t\n#  define z_off_t long\n#endif\n\n#if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0\n#  define z_off64_t off64_t\n#else\n#  define z_off64_t z_off_t\n#endif\n\n#if defined(__OS400__)\n#  define NO_vsnprintf\n#endif\n\n#if defined(__MVS__)\n#  define NO_vsnprintf\n#endif\n\n/* MVS linker does not support external names larger than 8 bytes */\n#if defined(__MVS__)\n  #pragma map(deflateInit_,\"DEIN\")\n  #pragma map(deflateInit2_,\"DEIN2\")\n  #pragma map(deflateEnd,\"DEEND\")\n  #pragma map(deflateBound,\"DEBND\")\n  #pragma map(inflateInit_,\"ININ\")\n  #pragma map(inflateInit2_,\"ININ2\")\n  #pragma map(inflateEnd,\"INEND\")\n  #pragma map(inflateSync,\"INSY\")\n  #pragma map(inflateSetDictionary,\"INSEDI\")\n  #pragma map(compressBound,\"CMBND\")\n  #pragma map(inflate_table,\"INTABL\")\n  #pragma map(inflate_fast,\"INFA\")\n  #pragma map(inflate_copyright,\"INCOPY\")\n#endif\n\n#endif /* ZCONF_H */\n"
  },
  {
    "path": "Libraries/Core/RPi/Headers/zlib.h",
    "content": "/* zlib.h -- interface of the 'zlib' general purpose compression library\n  version 1.2.5, April 19th, 2010\n\n  Copyright (C) 1995-2010 Jean-loup Gailly and Mark Adler\n\n  This software is provided 'as-is', without any express or implied\n  warranty.  In no event will the authors be held liable for any damages\n  arising from the use of this software.\n\n  Permission is granted to anyone to use this software for any purpose,\n  including commercial applications, and to alter it and redistribute it\n  freely, subject to the following restrictions:\n\n  1. The origin of this software must not be misrepresented; you must not\n     claim that you wrote the original software. If you use this software\n     in a product, an acknowledgment in the product documentation would be\n     appreciated but is not required.\n  2. Altered source versions must be plainly marked as such, and must not be\n     misrepresented as being the original software.\n  3. This notice may not be removed or altered from any source distribution.\n\n  Jean-loup Gailly        Mark Adler\n  jloup@gzip.org          madler@alumni.caltech.edu\n\n\n  The data format used by the zlib library is described by RFCs (Request for\n  Comments) 1950 to 1952 in the files http://www.ietf.org/rfc/rfc1950.txt\n  (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format).\n*/\n\n#ifndef ZLIB_H\n#define ZLIB_H\n\n#include \"zconf.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#define ZLIB_VERSION \"1.2.5\"\n#define ZLIB_VERNUM 0x1250\n#define ZLIB_VER_MAJOR 1\n#define ZLIB_VER_MINOR 2\n#define ZLIB_VER_REVISION 5\n#define ZLIB_VER_SUBREVISION 0\n\n/*\n    The 'zlib' compression library provides in-memory compression and\n  decompression functions, including integrity checks of the uncompressed data.\n  This version of the library supports only one compression method (deflation)\n  but other algorithms will be added later and will have the same stream\n  interface.\n\n    Compression can be done in a single step if the buffers are large enough,\n  or can be done by repeated calls of the compression function.  In the latter\n  case, the application must provide more input and/or consume the output\n  (providing more output space) before each call.\n\n    The compressed data format used by default by the in-memory functions is\n  the zlib format, which is a zlib wrapper documented in RFC 1950, wrapped\n  around a deflate stream, which is itself documented in RFC 1951.\n\n    The library also supports reading and writing files in gzip (.gz) format\n  with an interface similar to that of stdio using the functions that start\n  with \"gz\".  The gzip format is different from the zlib format.  gzip is a\n  gzip wrapper, documented in RFC 1952, wrapped around a deflate stream.\n\n    This library can optionally read and write gzip streams in memory as well.\n\n    The zlib format was designed to be compact and fast for use in memory\n  and on communications channels.  The gzip format was designed for single-\n  file compression on file systems, has a larger header than zlib to maintain\n  directory information, and uses a different, slower check method than zlib.\n\n    The library does not install any signal handler.  The decoder checks\n  the consistency of the compressed data, so the library should never crash\n  even in case of corrupted input.\n*/\n\ntypedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size));\ntypedef void   (*free_func)  OF((voidpf opaque, voidpf address));\n\nstruct internal_state;\n\ntypedef struct z_stream_s {\n    Bytef    *next_in;  /* next input byte */\n    uInt     avail_in;  /* number of bytes available at next_in */\n    uLong    total_in;  /* total nb of input bytes read so far */\n\n    Bytef    *next_out; /* next output byte should be put there */\n    uInt     avail_out; /* remaining free space at next_out */\n    uLong    total_out; /* total nb of bytes output so far */\n\n    char     *msg;      /* last error message, NULL if no error */\n    struct internal_state FAR *state; /* not visible by applications */\n\n    alloc_func zalloc;  /* used to allocate the internal state */\n    free_func  zfree;   /* used to free the internal state */\n    voidpf     opaque;  /* private data object passed to zalloc and zfree */\n\n    int     data_type;  /* best guess about the data type: binary or text */\n    uLong   adler;      /* adler32 value of the uncompressed data */\n    uLong   reserved;   /* reserved for future use */\n} z_stream;\n\ntypedef z_stream FAR *z_streamp;\n\n/*\n     gzip header information passed to and from zlib routines.  See RFC 1952\n  for more details on the meanings of these fields.\n*/\ntypedef struct gz_header_s {\n    int     text;       /* true if compressed data believed to be text */\n    uLong   time;       /* modification time */\n    int     xflags;     /* extra flags (not used when writing a gzip file) */\n    int     os;         /* operating system */\n    Bytef   *extra;     /* pointer to extra field or Z_NULL if none */\n    uInt    extra_len;  /* extra field length (valid if extra != Z_NULL) */\n    uInt    extra_max;  /* space at extra (only when reading header) */\n    Bytef   *name;      /* pointer to zero-terminated file name or Z_NULL */\n    uInt    name_max;   /* space at name (only when reading header) */\n    Bytef   *comment;   /* pointer to zero-terminated comment or Z_NULL */\n    uInt    comm_max;   /* space at comment (only when reading header) */\n    int     hcrc;       /* true if there was or will be a header crc */\n    int     done;       /* true when done reading gzip header (not used\n                           when writing a gzip file) */\n} gz_header;\n\ntypedef gz_header FAR *gz_headerp;\n\n/*\n     The application must update next_in and avail_in when avail_in has dropped\n   to zero.  It must update next_out and avail_out when avail_out has dropped\n   to zero.  The application must initialize zalloc, zfree and opaque before\n   calling the init function.  All other fields are set by the compression\n   library and must not be updated by the application.\n\n     The opaque value provided by the application will be passed as the first\n   parameter for calls of zalloc and zfree.  This can be useful for custom\n   memory management.  The compression library attaches no meaning to the\n   opaque value.\n\n     zalloc must return Z_NULL if there is not enough memory for the object.\n   If zlib is used in a multi-threaded application, zalloc and zfree must be\n   thread safe.\n\n     On 16-bit systems, the functions zalloc and zfree must be able to allocate\n   exactly 65536 bytes, but will not be required to allocate more than this if\n   the symbol MAXSEG_64K is defined (see zconf.h).  WARNING: On MSDOS, pointers\n   returned by zalloc for objects of exactly 65536 bytes *must* have their\n   offset normalized to zero.  The default allocation function provided by this\n   library ensures this (see zutil.c).  To reduce memory requirements and avoid\n   any allocation of 64K objects, at the expense of compression ratio, compile\n   the library with -DMAX_WBITS=14 (see zconf.h).\n\n     The fields total_in and total_out can be used for statistics or progress\n   reports.  After compression, total_in holds the total size of the\n   uncompressed data and may be saved for use in the decompressor (particularly\n   if the decompressor wants to decompress everything in a single step).\n*/\n\n                        /* constants */\n\n#define Z_NO_FLUSH      0\n#define Z_PARTIAL_FLUSH 1\n#define Z_SYNC_FLUSH    2\n#define Z_FULL_FLUSH    3\n#define Z_FINISH        4\n#define Z_BLOCK         5\n#define Z_TREES         6\n/* Allowed flush values; see deflate() and inflate() below for details */\n\n#define Z_OK            0\n#define Z_STREAM_END    1\n#define Z_NEED_DICT     2\n#define Z_ERRNO        (-1)\n#define Z_STREAM_ERROR (-2)\n#define Z_DATA_ERROR   (-3)\n#define Z_MEM_ERROR    (-4)\n#define Z_BUF_ERROR    (-5)\n#define Z_VERSION_ERROR (-6)\n/* Return codes for the compression/decompression functions. Negative values\n * are errors, positive values are used for special but normal events.\n */\n\n#define Z_NO_COMPRESSION         0\n#define Z_BEST_SPEED             1\n#define Z_BEST_COMPRESSION       9\n#define Z_DEFAULT_COMPRESSION  (-1)\n/* compression levels */\n\n#define Z_FILTERED            1\n#define Z_HUFFMAN_ONLY        2\n#define Z_RLE                 3\n#define Z_FIXED               4\n#define Z_DEFAULT_STRATEGY    0\n/* compression strategy; see deflateInit2() below for details */\n\n#define Z_BINARY   0\n#define Z_TEXT     1\n#define Z_ASCII    Z_TEXT   /* for compatibility with 1.2.2 and earlier */\n#define Z_UNKNOWN  2\n/* Possible values of the data_type field (though see inflate()) */\n\n#define Z_DEFLATED   8\n/* The deflate compression method (the only one supported in this version) */\n\n#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */\n\n#define zlib_version zlibVersion()\n/* for compatibility with versions < 1.0.2 */\n\n\n                        /* basic functions */\n\nZEXTERN const char * ZEXPORT zlibVersion OF((void));\n/* The application can compare zlibVersion and ZLIB_VERSION for consistency.\n   If the first character differs, the library code actually used is not\n   compatible with the zlib.h header file used by the application.  This check\n   is automatically made by deflateInit and inflateInit.\n */\n\n/*\nZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level));\n\n     Initializes the internal stream state for compression.  The fields\n   zalloc, zfree and opaque must be initialized before by the caller.  If\n   zalloc and zfree are set to Z_NULL, deflateInit updates them to use default\n   allocation functions.\n\n     The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9:\n   1 gives best speed, 9 gives best compression, 0 gives no compression at all\n   (the input data is simply copied a block at a time).  Z_DEFAULT_COMPRESSION\n   requests a default compromise between speed and compression (currently\n   equivalent to level 6).\n\n     deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough\n   memory, Z_STREAM_ERROR if level is not a valid compression level, or\n   Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible\n   with the version assumed by the caller (ZLIB_VERSION).  msg is set to null\n   if there is no error message.  deflateInit does not perform any compression:\n   this will be done by deflate().\n*/\n\n\nZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush));\n/*\n    deflate compresses as much data as possible, and stops when the input\n  buffer becomes empty or the output buffer becomes full.  It may introduce\n  some output latency (reading input without producing any output) except when\n  forced to flush.\n\n    The detailed semantics are as follows.  deflate performs one or both of the\n  following actions:\n\n  - Compress more input starting at next_in and update next_in and avail_in\n    accordingly.  If not all input can be processed (because there is not\n    enough room in the output buffer), next_in and avail_in are updated and\n    processing will resume at this point for the next call of deflate().\n\n  - Provide more output starting at next_out and update next_out and avail_out\n    accordingly.  This action is forced if the parameter flush is non zero.\n    Forcing flush frequently degrades the compression ratio, so this parameter\n    should be set only when necessary (in interactive applications).  Some\n    output may be provided even if flush is not set.\n\n    Before the call of deflate(), the application should ensure that at least\n  one of the actions is possible, by providing more input and/or consuming more\n  output, and updating avail_in or avail_out accordingly; avail_out should\n  never be zero before the call.  The application can consume the compressed\n  output when it wants, for example when the output buffer is full (avail_out\n  == 0), or after each call of deflate().  If deflate returns Z_OK and with\n  zero avail_out, it must be called again after making room in the output\n  buffer because there might be more output pending.\n\n    Normally the parameter flush is set to Z_NO_FLUSH, which allows deflate to\n  decide how much data to accumulate before producing output, in order to\n  maximize compression.\n\n    If the parameter flush is set to Z_SYNC_FLUSH, all pending output is\n  flushed to the output buffer and the output is aligned on a byte boundary, so\n  that the decompressor can get all input data available so far.  (In\n  particular avail_in is zero after the call if enough output space has been\n  provided before the call.) Flushing may degrade compression for some\n  compression algorithms and so it should be used only when necessary.  This\n  completes the current deflate block and follows it with an empty stored block\n  that is three bits plus filler bits to the next byte, followed by four bytes\n  (00 00 ff ff).\n\n    If flush is set to Z_PARTIAL_FLUSH, all pending output is flushed to the\n  output buffer, but the output is not aligned to a byte boundary.  All of the\n  input data so far will be available to the decompressor, as for Z_SYNC_FLUSH.\n  This completes the current deflate block and follows it with an empty fixed\n  codes block that is 10 bits long.  This assures that enough bytes are output\n  in order for the decompressor to finish the block before the empty fixed code\n  block.\n\n    If flush is set to Z_BLOCK, a deflate block is completed and emitted, as\n  for Z_SYNC_FLUSH, but the output is not aligned on a byte boundary, and up to\n  seven bits of the current block are held to be written as the next byte after\n  the next deflate block is completed.  In this case, the decompressor may not\n  be provided enough bits at this point in order to complete decompression of\n  the data provided so far to the compressor.  It may need to wait for the next\n  block to be emitted.  This is for advanced applications that need to control\n  the emission of deflate blocks.\n\n    If flush is set to Z_FULL_FLUSH, all output is flushed as with\n  Z_SYNC_FLUSH, and the compression state is reset so that decompression can\n  restart from this point if previous compressed data has been damaged or if\n  random access is desired.  Using Z_FULL_FLUSH too often can seriously degrade\n  compression.\n\n    If deflate returns with avail_out == 0, this function must be called again\n  with the same value of the flush parameter and more output space (updated\n  avail_out), until the flush is complete (deflate returns with non-zero\n  avail_out).  In the case of a Z_FULL_FLUSH or Z_SYNC_FLUSH, make sure that\n  avail_out is greater than six to avoid repeated flush markers due to\n  avail_out == 0 on return.\n\n    If the parameter flush is set to Z_FINISH, pending input is processed,\n  pending output is flushed and deflate returns with Z_STREAM_END if there was\n  enough output space; if deflate returns with Z_OK, this function must be\n  called again with Z_FINISH and more output space (updated avail_out) but no\n  more input data, until it returns with Z_STREAM_END or an error.  After\n  deflate has returned Z_STREAM_END, the only possible operations on the stream\n  are deflateReset or deflateEnd.\n\n    Z_FINISH can be used immediately after deflateInit if all the compression\n  is to be done in a single step.  In this case, avail_out must be at least the\n  value returned by deflateBound (see below).  If deflate does not return\n  Z_STREAM_END, then it must be called again as described above.\n\n    deflate() sets strm->adler to the adler32 checksum of all input read\n  so far (that is, total_in bytes).\n\n    deflate() may update strm->data_type if it can make a good guess about\n  the input data type (Z_BINARY or Z_TEXT).  In doubt, the data is considered\n  binary.  This field is only for information purposes and does not affect the\n  compression algorithm in any manner.\n\n    deflate() returns Z_OK if some progress has been made (more input\n  processed or more output produced), Z_STREAM_END if all input has been\n  consumed and all output has been produced (only when flush is set to\n  Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example\n  if next_in or next_out was Z_NULL), Z_BUF_ERROR if no progress is possible\n  (for example avail_in or avail_out was zero).  Note that Z_BUF_ERROR is not\n  fatal, and deflate() can be called again with more input and more output\n  space to continue compressing.\n*/\n\n\nZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm));\n/*\n     All dynamically allocated data structures for this stream are freed.\n   This function discards any unprocessed input and does not flush any pending\n   output.\n\n     deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the\n   stream state was inconsistent, Z_DATA_ERROR if the stream was freed\n   prematurely (some input or output was discarded).  In the error case, msg\n   may be set but then points to a static string (which must not be\n   deallocated).\n*/\n\n\n/*\nZEXTERN int ZEXPORT inflateInit OF((z_streamp strm));\n\n     Initializes the internal stream state for decompression.  The fields\n   next_in, avail_in, zalloc, zfree and opaque must be initialized before by\n   the caller.  If next_in is not Z_NULL and avail_in is large enough (the\n   exact value depends on the compression method), inflateInit determines the\n   compression method from the zlib header and allocates all data structures\n   accordingly; otherwise the allocation will be deferred to the first call of\n   inflate.  If zalloc and zfree are set to Z_NULL, inflateInit updates them to\n   use default allocation functions.\n\n     inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough\n   memory, Z_VERSION_ERROR if the zlib library version is incompatible with the\n   version assumed by the caller, or Z_STREAM_ERROR if the parameters are\n   invalid, such as a null pointer to the structure.  msg is set to null if\n   there is no error message.  inflateInit does not perform any decompression\n   apart from possibly reading the zlib header if present: actual decompression\n   will be done by inflate().  (So next_in and avail_in may be modified, but\n   next_out and avail_out are unused and unchanged.) The current implementation\n   of inflateInit() does not process any header information -- that is deferred\n   until inflate() is called.\n*/\n\n\nZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush));\n/*\n    inflate decompresses as much data as possible, and stops when the input\n  buffer becomes empty or the output buffer becomes full.  It may introduce\n  some output latency (reading input without producing any output) except when\n  forced to flush.\n\n  The detailed semantics are as follows.  inflate performs one or both of the\n  following actions:\n\n  - Decompress more input starting at next_in and update next_in and avail_in\n    accordingly.  If not all input can be processed (because there is not\n    enough room in the output buffer), next_in is updated and processing will\n    resume at this point for the next call of inflate().\n\n  - Provide more output starting at next_out and update next_out and avail_out\n    accordingly.  inflate() provides as much output as possible, until there is\n    no more input data or no more space in the output buffer (see below about\n    the flush parameter).\n\n    Before the call of inflate(), the application should ensure that at least\n  one of the actions is possible, by providing more input and/or consuming more\n  output, and updating the next_* and avail_* values accordingly.  The\n  application can consume the uncompressed output when it wants, for example\n  when the output buffer is full (avail_out == 0), or after each call of\n  inflate().  If inflate returns Z_OK and with zero avail_out, it must be\n  called again after making room in the output buffer because there might be\n  more output pending.\n\n    The flush parameter of inflate() can be Z_NO_FLUSH, Z_SYNC_FLUSH, Z_FINISH,\n  Z_BLOCK, or Z_TREES.  Z_SYNC_FLUSH requests that inflate() flush as much\n  output as possible to the output buffer.  Z_BLOCK requests that inflate()\n  stop if and when it gets to the next deflate block boundary.  When decoding\n  the zlib or gzip format, this will cause inflate() to return immediately\n  after the header and before the first block.  When doing a raw inflate,\n  inflate() will go ahead and process the first block, and will return when it\n  gets to the end of that block, or when it runs out of data.\n\n    The Z_BLOCK option assists in appending to or combining deflate streams.\n  Also to assist in this, on return inflate() will set strm->data_type to the\n  number of unused bits in the last byte taken from strm->next_in, plus 64 if\n  inflate() is currently decoding the last block in the deflate stream, plus\n  128 if inflate() returned immediately after decoding an end-of-block code or\n  decoding the complete header up to just before the first byte of the deflate\n  stream.  The end-of-block will not be indicated until all of the uncompressed\n  data from that block has been written to strm->next_out.  The number of\n  unused bits may in general be greater than seven, except when bit 7 of\n  data_type is set, in which case the number of unused bits will be less than\n  eight.  data_type is set as noted here every time inflate() returns for all\n  flush options, and so can be used to determine the amount of currently\n  consumed input in bits.\n\n    The Z_TREES option behaves as Z_BLOCK does, but it also returns when the\n  end of each deflate block header is reached, before any actual data in that\n  block is decoded.  This allows the caller to determine the length of the\n  deflate block header for later use in random access within a deflate block.\n  256 is added to the value of strm->data_type when inflate() returns\n  immediately after reaching the end of the deflate block header.\n\n    inflate() should normally be called until it returns Z_STREAM_END or an\n  error.  However if all decompression is to be performed in a single step (a\n  single call of inflate), the parameter flush should be set to Z_FINISH.  In\n  this case all pending input is processed and all pending output is flushed;\n  avail_out must be large enough to hold all the uncompressed data.  (The size\n  of the uncompressed data may have been saved by the compressor for this\n  purpose.) The next operation on this stream must be inflateEnd to deallocate\n  the decompression state.  The use of Z_FINISH is never required, but can be\n  used to inform inflate that a faster approach may be used for the single\n  inflate() call.\n\n     In this implementation, inflate() always flushes as much output as\n  possible to the output buffer, and always uses the faster approach on the\n  first call.  So the only effect of the flush parameter in this implementation\n  is on the return value of inflate(), as noted below, or when it returns early\n  because Z_BLOCK or Z_TREES is used.\n\n     If a preset dictionary is needed after this call (see inflateSetDictionary\n  below), inflate sets strm->adler to the adler32 checksum of the dictionary\n  chosen by the compressor and returns Z_NEED_DICT; otherwise it sets\n  strm->adler to the adler32 checksum of all output produced so far (that is,\n  total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as described\n  below.  At the end of the stream, inflate() checks that its computed adler32\n  checksum is equal to that saved by the compressor and returns Z_STREAM_END\n  only if the checksum is correct.\n\n    inflate() can decompress and check either zlib-wrapped or gzip-wrapped\n  deflate data.  The header type is detected automatically, if requested when\n  initializing with inflateInit2().  Any information contained in the gzip\n  header is not retained, so applications that need that information should\n  instead use raw inflate, see inflateInit2() below, or inflateBack() and\n  perform their own processing of the gzip header and trailer.\n\n    inflate() returns Z_OK if some progress has been made (more input processed\n  or more output produced), Z_STREAM_END if the end of the compressed data has\n  been reached and all uncompressed output has been produced, Z_NEED_DICT if a\n  preset dictionary is needed at this point, Z_DATA_ERROR if the input data was\n  corrupted (input stream not conforming to the zlib format or incorrect check\n  value), Z_STREAM_ERROR if the stream structure was inconsistent (for example\n  next_in or next_out was Z_NULL), Z_MEM_ERROR if there was not enough memory,\n  Z_BUF_ERROR if no progress is possible or if there was not enough room in the\n  output buffer when Z_FINISH is used.  Note that Z_BUF_ERROR is not fatal, and\n  inflate() can be called again with more input and more output space to\n  continue decompressing.  If Z_DATA_ERROR is returned, the application may\n  then call inflateSync() to look for a good compression block if a partial\n  recovery of the data is desired.\n*/\n\n\nZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm));\n/*\n     All dynamically allocated data structures for this stream are freed.\n   This function discards any unprocessed input and does not flush any pending\n   output.\n\n     inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state\n   was inconsistent.  In the error case, msg may be set but then points to a\n   static string (which must not be deallocated).\n*/\n\n\n                        /* Advanced functions */\n\n/*\n    The following functions are needed only in some special applications.\n*/\n\n/*\nZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm,\n                                     int  level,\n                                     int  method,\n                                     int  windowBits,\n                                     int  memLevel,\n                                     int  strategy));\n\n     This is another version of deflateInit with more compression options.  The\n   fields next_in, zalloc, zfree and opaque must be initialized before by the\n   caller.\n\n     The method parameter is the compression method.  It must be Z_DEFLATED in\n   this version of the library.\n\n     The windowBits parameter is the base two logarithm of the window size\n   (the size of the history buffer).  It should be in the range 8..15 for this\n   version of the library.  Larger values of this parameter result in better\n   compression at the expense of memory usage.  The default value is 15 if\n   deflateInit is used instead.\n\n     windowBits can also be -8..-15 for raw deflate.  In this case, -windowBits\n   determines the window size.  deflate() will then generate raw deflate data\n   with no zlib header or trailer, and will not compute an adler32 check value.\n\n     windowBits can also be greater than 15 for optional gzip encoding.  Add\n   16 to windowBits to write a simple gzip header and trailer around the\n   compressed data instead of a zlib wrapper.  The gzip header will have no\n   file name, no extra data, no comment, no modification time (set to zero), no\n   header crc, and the operating system will be set to 255 (unknown).  If a\n   gzip stream is being written, strm->adler is a crc32 instead of an adler32.\n\n     The memLevel parameter specifies how much memory should be allocated\n   for the internal compression state.  memLevel=1 uses minimum memory but is\n   slow and reduces compression ratio; memLevel=9 uses maximum memory for\n   optimal speed.  The default value is 8.  See zconf.h for total memory usage\n   as a function of windowBits and memLevel.\n\n     The strategy parameter is used to tune the compression algorithm.  Use the\n   value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a\n   filter (or predictor), Z_HUFFMAN_ONLY to force Huffman encoding only (no\n   string match), or Z_RLE to limit match distances to one (run-length\n   encoding).  Filtered data consists mostly of small values with a somewhat\n   random distribution.  In this case, the compression algorithm is tuned to\n   compress them better.  The effect of Z_FILTERED is to force more Huffman\n   coding and less string matching; it is somewhat intermediate between\n   Z_DEFAULT_STRATEGY and Z_HUFFMAN_ONLY.  Z_RLE is designed to be almost as\n   fast as Z_HUFFMAN_ONLY, but give better compression for PNG image data.  The\n   strategy parameter only affects the compression ratio but not the\n   correctness of the compressed output even if it is not set appropriately.\n   Z_FIXED prevents the use of dynamic Huffman codes, allowing for a simpler\n   decoder for special applications.\n\n     deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough\n   memory, Z_STREAM_ERROR if any parameter is invalid (such as an invalid\n   method), or Z_VERSION_ERROR if the zlib library version (zlib_version) is\n   incompatible with the version assumed by the caller (ZLIB_VERSION).  msg is\n   set to null if there is no error message.  deflateInit2 does not perform any\n   compression: this will be done by deflate().\n*/\n\nZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm,\n                                             const Bytef *dictionary,\n                                             uInt  dictLength));\n/*\n     Initializes the compression dictionary from the given byte sequence\n   without producing any compressed output.  This function must be called\n   immediately after deflateInit, deflateInit2 or deflateReset, before any call\n   of deflate.  The compressor and decompressor must use exactly the same\n   dictionary (see inflateSetDictionary).\n\n     The dictionary should consist of strings (byte sequences) that are likely\n   to be encountered later in the data to be compressed, with the most commonly\n   used strings preferably put towards the end of the dictionary.  Using a\n   dictionary is most useful when the data to be compressed is short and can be\n   predicted with good accuracy; the data can then be compressed better than\n   with the default empty dictionary.\n\n     Depending on the size of the compression data structures selected by\n   deflateInit or deflateInit2, a part of the dictionary may in effect be\n   discarded, for example if the dictionary is larger than the window size\n   provided in deflateInit or deflateInit2.  Thus the strings most likely to be\n   useful should be put at the end of the dictionary, not at the front.  In\n   addition, the current implementation of deflate will use at most the window\n   size minus 262 bytes of the provided dictionary.\n\n     Upon return of this function, strm->adler is set to the adler32 value\n   of the dictionary; the decompressor may later use this value to determine\n   which dictionary has been used by the compressor.  (The adler32 value\n   applies to the whole dictionary even if only a subset of the dictionary is\n   actually used by the compressor.) If a raw deflate was requested, then the\n   adler32 value is not computed and strm->adler is not set.\n\n     deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a\n   parameter is invalid (e.g.  dictionary being Z_NULL) or the stream state is\n   inconsistent (for example if deflate has already been called for this stream\n   or if the compression method is bsort).  deflateSetDictionary does not\n   perform any compression: this will be done by deflate().\n*/\n\nZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest,\n                                    z_streamp source));\n/*\n     Sets the destination stream as a complete copy of the source stream.\n\n     This function can be useful when several compression strategies will be\n   tried, for example when there are several ways of pre-processing the input\n   data with a filter.  The streams that will be discarded should then be freed\n   by calling deflateEnd.  Note that deflateCopy duplicates the internal\n   compression state which can be quite large, so this strategy is slow and can\n   consume lots of memory.\n\n     deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not\n   enough memory, Z_STREAM_ERROR if the source stream state was inconsistent\n   (such as zalloc being Z_NULL).  msg is left unchanged in both source and\n   destination.\n*/\n\nZEXTERN int ZEXPORT deflateReset OF((z_streamp strm));\n/*\n     This function is equivalent to deflateEnd followed by deflateInit,\n   but does not free and reallocate all the internal compression state.  The\n   stream will keep the same compression level and any other attributes that\n   may have been set by deflateInit2.\n\n     deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source\n   stream state was inconsistent (such as zalloc or state being Z_NULL).\n*/\n\nZEXTERN int ZEXPORT deflateParams OF((z_streamp strm,\n                                      int level,\n                                      int strategy));\n/*\n     Dynamically update the compression level and compression strategy.  The\n   interpretation of level and strategy is as in deflateInit2.  This can be\n   used to switch between compression and straight copy of the input data, or\n   to switch to a different kind of input data requiring a different strategy.\n   If the compression level is changed, the input available so far is\n   compressed with the old level (and may be flushed); the new level will take\n   effect only at the next call of deflate().\n\n     Before the call of deflateParams, the stream state must be set as for\n   a call of deflate(), since the currently available input may have to be\n   compressed and flushed.  In particular, strm->avail_out must be non-zero.\n\n     deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source\n   stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR if\n   strm->avail_out was zero.\n*/\n\nZEXTERN int ZEXPORT deflateTune OF((z_streamp strm,\n                                    int good_length,\n                                    int max_lazy,\n                                    int nice_length,\n                                    int max_chain));\n/*\n     Fine tune deflate's internal compression parameters.  This should only be\n   used by someone who understands the algorithm used by zlib's deflate for\n   searching for the best matching string, and even then only by the most\n   fanatic optimizer trying to squeeze out the last compressed bit for their\n   specific input data.  Read the deflate.c source code for the meaning of the\n   max_lazy, good_length, nice_length, and max_chain parameters.\n\n     deflateTune() can be called after deflateInit() or deflateInit2(), and\n   returns Z_OK on success, or Z_STREAM_ERROR for an invalid deflate stream.\n */\n\nZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm,\n                                       uLong sourceLen));\n/*\n     deflateBound() returns an upper bound on the compressed size after\n   deflation of sourceLen bytes.  It must be called after deflateInit() or\n   deflateInit2(), and after deflateSetHeader(), if used.  This would be used\n   to allocate an output buffer for deflation in a single pass, and so would be\n   called before deflate().\n*/\n\nZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm,\n                                     int bits,\n                                     int value));\n/*\n     deflatePrime() inserts bits in the deflate output stream.  The intent\n   is that this function is used to start off the deflate output with the bits\n   leftover from a previous deflate stream when appending to it.  As such, this\n   function can only be used for raw deflate, and must be used before the first\n   deflate() call after a deflateInit2() or deflateReset().  bits must be less\n   than or equal to 16, and that many of the least significant bits of value\n   will be inserted in the output.\n\n     deflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source\n   stream state was inconsistent.\n*/\n\nZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm,\n                                         gz_headerp head));\n/*\n     deflateSetHeader() provides gzip header information for when a gzip\n   stream is requested by deflateInit2().  deflateSetHeader() may be called\n   after deflateInit2() or deflateReset() and before the first call of\n   deflate().  The text, time, os, extra field, name, and comment information\n   in the provided gz_header structure are written to the gzip header (xflag is\n   ignored -- the extra flags are set according to the compression level).  The\n   caller must assure that, if not Z_NULL, name and comment are terminated with\n   a zero byte, and that if extra is not Z_NULL, that extra_len bytes are\n   available there.  If hcrc is true, a gzip header crc is included.  Note that\n   the current versions of the command-line version of gzip (up through version\n   1.3.x) do not support header crc's, and will report that it is a \"multi-part\n   gzip file\" and give up.\n\n     If deflateSetHeader is not used, the default gzip header has text false,\n   the time set to zero, and os set to 255, with no extra, name, or comment\n   fields.  The gzip header is returned to the default state by deflateReset().\n\n     deflateSetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source\n   stream state was inconsistent.\n*/\n\n/*\nZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm,\n                                     int  windowBits));\n\n     This is another version of inflateInit with an extra parameter.  The\n   fields next_in, avail_in, zalloc, zfree and opaque must be initialized\n   before by the caller.\n\n     The windowBits parameter is the base two logarithm of the maximum window\n   size (the size of the history buffer).  It should be in the range 8..15 for\n   this version of the library.  The default value is 15 if inflateInit is used\n   instead.  windowBits must be greater than or equal to the windowBits value\n   provided to deflateInit2() while compressing, or it must be equal to 15 if\n   deflateInit2() was not used.  If a compressed stream with a larger window\n   size is given as input, inflate() will return with the error code\n   Z_DATA_ERROR instead of trying to allocate a larger window.\n\n     windowBits can also be zero to request that inflate use the window size in\n   the zlib header of the compressed stream.\n\n     windowBits can also be -8..-15 for raw inflate.  In this case, -windowBits\n   determines the window size.  inflate() will then process raw deflate data,\n   not looking for a zlib or gzip header, not generating a check value, and not\n   looking for any check values for comparison at the end of the stream.  This\n   is for use with other formats that use the deflate compressed data format\n   such as zip.  Those formats provide their own check values.  If a custom\n   format is developed using the raw deflate format for compressed data, it is\n   recommended that a check value such as an adler32 or a crc32 be applied to\n   the uncompressed data as is done in the zlib, gzip, and zip formats.  For\n   most applications, the zlib format should be used as is.  Note that comments\n   above on the use in deflateInit2() applies to the magnitude of windowBits.\n\n     windowBits can also be greater than 15 for optional gzip decoding.  Add\n   32 to windowBits to enable zlib and gzip decoding with automatic header\n   detection, or add 16 to decode only the gzip format (the zlib format will\n   return a Z_DATA_ERROR).  If a gzip stream is being decoded, strm->adler is a\n   crc32 instead of an adler32.\n\n     inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough\n   memory, Z_VERSION_ERROR if the zlib library version is incompatible with the\n   version assumed by the caller, or Z_STREAM_ERROR if the parameters are\n   invalid, such as a null pointer to the structure.  msg is set to null if\n   there is no error message.  inflateInit2 does not perform any decompression\n   apart from possibly reading the zlib header if present: actual decompression\n   will be done by inflate().  (So next_in and avail_in may be modified, but\n   next_out and avail_out are unused and unchanged.) The current implementation\n   of inflateInit2() does not process any header information -- that is\n   deferred until inflate() is called.\n*/\n\nZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm,\n                                             const Bytef *dictionary,\n                                             uInt  dictLength));\n/*\n     Initializes the decompression dictionary from the given uncompressed byte\n   sequence.  This function must be called immediately after a call of inflate,\n   if that call returned Z_NEED_DICT.  The dictionary chosen by the compressor\n   can be determined from the adler32 value returned by that call of inflate.\n   The compressor and decompressor must use exactly the same dictionary (see\n   deflateSetDictionary).  For raw inflate, this function can be called\n   immediately after inflateInit2() or inflateReset() and before any call of\n   inflate() to set the dictionary.  The application must insure that the\n   dictionary that was used for compression is provided.\n\n     inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a\n   parameter is invalid (e.g.  dictionary being Z_NULL) or the stream state is\n   inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the\n   expected one (incorrect adler32 value).  inflateSetDictionary does not\n   perform any decompression: this will be done by subsequent calls of\n   inflate().\n*/\n\nZEXTERN int ZEXPORT inflateSync OF((z_streamp strm));\n/*\n     Skips invalid compressed data until a full flush point (see above the\n   description of deflate with Z_FULL_FLUSH) can be found, or until all\n   available input is skipped.  No output is provided.\n\n     inflateSync returns Z_OK if a full flush point has been found, Z_BUF_ERROR\n   if no more input was provided, Z_DATA_ERROR if no flush point has been\n   found, or Z_STREAM_ERROR if the stream structure was inconsistent.  In the\n   success case, the application may save the current current value of total_in\n   which indicates where valid compressed data was found.  In the error case,\n   the application may repeatedly call inflateSync, providing more input each\n   time, until success or end of the input data.\n*/\n\nZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest,\n                                    z_streamp source));\n/*\n     Sets the destination stream as a complete copy of the source stream.\n\n     This function can be useful when randomly accessing a large stream.  The\n   first pass through the stream can periodically record the inflate state,\n   allowing restarting inflate at those points when randomly accessing the\n   stream.\n\n     inflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not\n   enough memory, Z_STREAM_ERROR if the source stream state was inconsistent\n   (such as zalloc being Z_NULL).  msg is left unchanged in both source and\n   destination.\n*/\n\nZEXTERN int ZEXPORT inflateReset OF((z_streamp strm));\n/*\n     This function is equivalent to inflateEnd followed by inflateInit,\n   but does not free and reallocate all the internal decompression state.  The\n   stream will keep attributes that may have been set by inflateInit2.\n\n     inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source\n   stream state was inconsistent (such as zalloc or state being Z_NULL).\n*/\n\nZEXTERN int ZEXPORT inflateReset2 OF((z_streamp strm,\n                                      int windowBits));\n/*\n     This function is the same as inflateReset, but it also permits changing\n   the wrap and window size requests.  The windowBits parameter is interpreted\n   the same as it is for inflateInit2.\n\n     inflateReset2 returns Z_OK if success, or Z_STREAM_ERROR if the source\n   stream state was inconsistent (such as zalloc or state being Z_NULL), or if\n   the windowBits parameter is invalid.\n*/\n\nZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm,\n                                     int bits,\n                                     int value));\n/*\n     This function inserts bits in the inflate input stream.  The intent is\n   that this function is used to start inflating at a bit position in the\n   middle of a byte.  The provided bits will be used before any bytes are used\n   from next_in.  This function should only be used with raw inflate, and\n   should be used before the first inflate() call after inflateInit2() or\n   inflateReset().  bits must be less than or equal to 16, and that many of the\n   least significant bits of value will be inserted in the input.\n\n     If bits is negative, then the input stream bit buffer is emptied.  Then\n   inflatePrime() can be called again to put bits in the buffer.  This is used\n   to clear out bits leftover after feeding inflate a block description prior\n   to feeding inflate codes.\n\n     inflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source\n   stream state was inconsistent.\n*/\n\nZEXTERN long ZEXPORT inflateMark OF((z_streamp strm));\n/*\n     This function returns two values, one in the lower 16 bits of the return\n   value, and the other in the remaining upper bits, obtained by shifting the\n   return value down 16 bits.  If the upper value is -1 and the lower value is\n   zero, then inflate() is currently decoding information outside of a block.\n   If the upper value is -1 and the lower value is non-zero, then inflate is in\n   the middle of a stored block, with the lower value equaling the number of\n   bytes from the input remaining to copy.  If the upper value is not -1, then\n   it is the number of bits back from the current bit position in the input of\n   the code (literal or length/distance pair) currently being processed.  In\n   that case the lower value is the number of bytes already emitted for that\n   code.\n\n     A code is being processed if inflate is waiting for more input to complete\n   decoding of the code, or if it has completed decoding but is waiting for\n   more output space to write the literal or match data.\n\n     inflateMark() is used to mark locations in the input data for random\n   access, which may be at bit positions, and to note those cases where the\n   output of a code may span boundaries of random access blocks.  The current\n   location in the input stream can be determined from avail_in and data_type\n   as noted in the description for the Z_BLOCK flush parameter for inflate.\n\n     inflateMark returns the value noted above or -1 << 16 if the provided\n   source stream state was inconsistent.\n*/\n\nZEXTERN int ZEXPORT inflateGetHeader OF((z_streamp strm,\n                                         gz_headerp head));\n/*\n     inflateGetHeader() requests that gzip header information be stored in the\n   provided gz_header structure.  inflateGetHeader() may be called after\n   inflateInit2() or inflateReset(), and before the first call of inflate().\n   As inflate() processes the gzip stream, head->done is zero until the header\n   is completed, at which time head->done is set to one.  If a zlib stream is\n   being decoded, then head->done is set to -1 to indicate that there will be\n   no gzip header information forthcoming.  Note that Z_BLOCK or Z_TREES can be\n   used to force inflate() to return immediately after header processing is\n   complete and before any actual data is decompressed.\n\n     The text, time, xflags, and os fields are filled in with the gzip header\n   contents.  hcrc is set to true if there is a header CRC.  (The header CRC\n   was valid if done is set to one.) If extra is not Z_NULL, then extra_max\n   contains the maximum number of bytes to write to extra.  Once done is true,\n   extra_len contains the actual extra field length, and extra contains the\n   extra field, or that field truncated if extra_max is less than extra_len.\n   If name is not Z_NULL, then up to name_max characters are written there,\n   terminated with a zero unless the length is greater than name_max.  If\n   comment is not Z_NULL, then up to comm_max characters are written there,\n   terminated with a zero unless the length is greater than comm_max.  When any\n   of extra, name, or comment are not Z_NULL and the respective field is not\n   present in the header, then that field is set to Z_NULL to signal its\n   absence.  This allows the use of deflateSetHeader() with the returned\n   structure to duplicate the header.  However if those fields are set to\n   allocated memory, then the application will need to save those pointers\n   elsewhere so that they can be eventually freed.\n\n     If inflateGetHeader is not used, then the header information is simply\n   discarded.  The header is always checked for validity, including the header\n   CRC if present.  inflateReset() will reset the process to discard the header\n   information.  The application would need to call inflateGetHeader() again to\n   retrieve the header from the next gzip stream.\n\n     inflateGetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source\n   stream state was inconsistent.\n*/\n\n/*\nZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits,\n                                        unsigned char FAR *window));\n\n     Initialize the internal stream state for decompression using inflateBack()\n   calls.  The fields zalloc, zfree and opaque in strm must be initialized\n   before the call.  If zalloc and zfree are Z_NULL, then the default library-\n   derived memory allocation routines are used.  windowBits is the base two\n   logarithm of the window size, in the range 8..15.  window is a caller\n   supplied buffer of that size.  Except for special applications where it is\n   assured that deflate was used with small window sizes, windowBits must be 15\n   and a 32K byte window must be supplied to be able to decompress general\n   deflate streams.\n\n     See inflateBack() for the usage of these routines.\n\n     inflateBackInit will return Z_OK on success, Z_STREAM_ERROR if any of\n   the paramaters are invalid, Z_MEM_ERROR if the internal state could not be\n   allocated, or Z_VERSION_ERROR if the version of the library does not match\n   the version of the header file.\n*/\n\ntypedef unsigned (*in_func) OF((void FAR *, unsigned char FAR * FAR *));\ntypedef int (*out_func) OF((void FAR *, unsigned char FAR *, unsigned));\n\nZEXTERN int ZEXPORT inflateBack OF((z_streamp strm,\n                                    in_func in, void FAR *in_desc,\n                                    out_func out, void FAR *out_desc));\n/*\n     inflateBack() does a raw inflate with a single call using a call-back\n   interface for input and output.  This is more efficient than inflate() for\n   file i/o applications in that it avoids copying between the output and the\n   sliding window by simply making the window itself the output buffer.  This\n   function trusts the application to not change the output buffer passed by\n   the output function, at least until inflateBack() returns.\n\n     inflateBackInit() must be called first to allocate the internal state\n   and to initialize the state with the user-provided window buffer.\n   inflateBack() may then be used multiple times to inflate a complete, raw\n   deflate stream with each call.  inflateBackEnd() is then called to free the\n   allocated state.\n\n     A raw deflate stream is one with no zlib or gzip header or trailer.\n   This routine would normally be used in a utility that reads zip or gzip\n   files and writes out uncompressed files.  The utility would decode the\n   header and process the trailer on its own, hence this routine expects only\n   the raw deflate stream to decompress.  This is different from the normal\n   behavior of inflate(), which expects either a zlib or gzip header and\n   trailer around the deflate stream.\n\n     inflateBack() uses two subroutines supplied by the caller that are then\n   called by inflateBack() for input and output.  inflateBack() calls those\n   routines until it reads a complete deflate stream and writes out all of the\n   uncompressed data, or until it encounters an error.  The function's\n   parameters and return types are defined above in the in_func and out_func\n   typedefs.  inflateBack() will call in(in_desc, &buf) which should return the\n   number of bytes of provided input, and a pointer to that input in buf.  If\n   there is no input available, in() must return zero--buf is ignored in that\n   case--and inflateBack() will return a buffer error.  inflateBack() will call\n   out(out_desc, buf, len) to write the uncompressed data buf[0..len-1].  out()\n   should return zero on success, or non-zero on failure.  If out() returns\n   non-zero, inflateBack() will return with an error.  Neither in() nor out()\n   are permitted to change the contents of the window provided to\n   inflateBackInit(), which is also the buffer that out() uses to write from.\n   The length written by out() will be at most the window size.  Any non-zero\n   amount of input may be provided by in().\n\n     For convenience, inflateBack() can be provided input on the first call by\n   setting strm->next_in and strm->avail_in.  If that input is exhausted, then\n   in() will be called.  Therefore strm->next_in must be initialized before\n   calling inflateBack().  If strm->next_in is Z_NULL, then in() will be called\n   immediately for input.  If strm->next_in is not Z_NULL, then strm->avail_in\n   must also be initialized, and then if strm->avail_in is not zero, input will\n   initially be taken from strm->next_in[0 ..  strm->avail_in - 1].\n\n     The in_desc and out_desc parameters of inflateBack() is passed as the\n   first parameter of in() and out() respectively when they are called.  These\n   descriptors can be optionally used to pass any information that the caller-\n   supplied in() and out() functions need to do their job.\n\n     On return, inflateBack() will set strm->next_in and strm->avail_in to\n   pass back any unused input that was provided by the last in() call.  The\n   return values of inflateBack() can be Z_STREAM_END on success, Z_BUF_ERROR\n   if in() or out() returned an error, Z_DATA_ERROR if there was a format error\n   in the deflate stream (in which case strm->msg is set to indicate the nature\n   of the error), or Z_STREAM_ERROR if the stream was not properly initialized.\n   In the case of Z_BUF_ERROR, an input or output error can be distinguished\n   using strm->next_in which will be Z_NULL only if in() returned an error.  If\n   strm->next_in is not Z_NULL, then the Z_BUF_ERROR was due to out() returning\n   non-zero.  (in() will always be called before out(), so strm->next_in is\n   assured to be defined if out() returns non-zero.) Note that inflateBack()\n   cannot return Z_OK.\n*/\n\nZEXTERN int ZEXPORT inflateBackEnd OF((z_streamp strm));\n/*\n     All memory allocated by inflateBackInit() is freed.\n\n     inflateBackEnd() returns Z_OK on success, or Z_STREAM_ERROR if the stream\n   state was inconsistent.\n*/\n\nZEXTERN uLong ZEXPORT zlibCompileFlags OF((void));\n/* Return flags indicating compile-time options.\n\n    Type sizes, two bits each, 00 = 16 bits, 01 = 32, 10 = 64, 11 = other:\n     1.0: size of uInt\n     3.2: size of uLong\n     5.4: size of voidpf (pointer)\n     7.6: size of z_off_t\n\n    Compiler, assembler, and debug options:\n     8: DEBUG\n     9: ASMV or ASMINF -- use ASM code\n     10: ZLIB_WINAPI -- exported functions use the WINAPI calling convention\n     11: 0 (reserved)\n\n    One-time table building (smaller code, but not thread-safe if true):\n     12: BUILDFIXED -- build static block decoding tables when needed\n     13: DYNAMIC_CRC_TABLE -- build CRC calculation tables when needed\n     14,15: 0 (reserved)\n\n    Library content (indicates missing functionality):\n     16: NO_GZCOMPRESS -- gz* functions cannot compress (to avoid linking\n                          deflate code when not needed)\n     17: NO_GZIP -- deflate can't write gzip streams, and inflate can't detect\n                    and decode gzip streams (to avoid linking crc code)\n     18-19: 0 (reserved)\n\n    Operation variations (changes in library functionality):\n     20: PKZIP_BUG_WORKAROUND -- slightly more permissive inflate\n     21: FASTEST -- deflate algorithm with only one, lowest compression level\n     22,23: 0 (reserved)\n\n    The sprintf variant used by gzprintf (zero is best):\n     24: 0 = vs*, 1 = s* -- 1 means limited to 20 arguments after the format\n     25: 0 = *nprintf, 1 = *printf -- 1 means gzprintf() not secure!\n     26: 0 = returns value, 1 = void -- 1 means inferred string length returned\n\n    Remainder:\n     27-31: 0 (reserved)\n */\n\n\n                        /* utility functions */\n\n/*\n     The following utility functions are implemented on top of the basic\n   stream-oriented functions.  To simplify the interface, some default options\n   are assumed (compression level and memory usage, standard memory allocation\n   functions).  The source code of these utility functions can be modified if\n   you need special options.\n*/\n\nZEXTERN int ZEXPORT compress OF((Bytef *dest,   uLongf *destLen,\n                                 const Bytef *source, uLong sourceLen));\n/*\n     Compresses the source buffer into the destination buffer.  sourceLen is\n   the byte length of the source buffer.  Upon entry, destLen is the total size\n   of the destination buffer, which must be at least the value returned by\n   compressBound(sourceLen).  Upon exit, destLen is the actual size of the\n   compressed buffer.\n\n     compress returns Z_OK if success, Z_MEM_ERROR if there was not\n   enough memory, Z_BUF_ERROR if there was not enough room in the output\n   buffer.\n*/\n\nZEXTERN int ZEXPORT compress2 OF((Bytef *dest,   uLongf *destLen,\n                                  const Bytef *source, uLong sourceLen,\n                                  int level));\n/*\n     Compresses the source buffer into the destination buffer.  The level\n   parameter has the same meaning as in deflateInit.  sourceLen is the byte\n   length of the source buffer.  Upon entry, destLen is the total size of the\n   destination buffer, which must be at least the value returned by\n   compressBound(sourceLen).  Upon exit, destLen is the actual size of the\n   compressed buffer.\n\n     compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough\n   memory, Z_BUF_ERROR if there was not enough room in the output buffer,\n   Z_STREAM_ERROR if the level parameter is invalid.\n*/\n\nZEXTERN uLong ZEXPORT compressBound OF((uLong sourceLen));\n/*\n     compressBound() returns an upper bound on the compressed size after\n   compress() or compress2() on sourceLen bytes.  It would be used before a\n   compress() or compress2() call to allocate the destination buffer.\n*/\n\nZEXTERN int ZEXPORT uncompress OF((Bytef *dest,   uLongf *destLen,\n                                   const Bytef *source, uLong sourceLen));\n/*\n     Decompresses the source buffer into the destination buffer.  sourceLen is\n   the byte length of the source buffer.  Upon entry, destLen is the total size\n   of the destination buffer, which must be large enough to hold the entire\n   uncompressed data.  (The size of the uncompressed data must have been saved\n   previously by the compressor and transmitted to the decompressor by some\n   mechanism outside the scope of this compression library.) Upon exit, destLen\n   is the actual size of the uncompressed buffer.\n\n     uncompress returns Z_OK if success, Z_MEM_ERROR if there was not\n   enough memory, Z_BUF_ERROR if there was not enough room in the output\n   buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete.\n*/\n\n\n                        /* gzip file access functions */\n\n/*\n     This library supports reading and writing files in gzip (.gz) format with\n   an interface similar to that of stdio, using the functions that start with\n   \"gz\".  The gzip format is different from the zlib format.  gzip is a gzip\n   wrapper, documented in RFC 1952, wrapped around a deflate stream.\n*/\n\ntypedef voidp gzFile;       /* opaque gzip file descriptor */\n\n/*\nZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode));\n\n     Opens a gzip (.gz) file for reading or writing.  The mode parameter is as\n   in fopen (\"rb\" or \"wb\") but can also include a compression level (\"wb9\") or\n   a strategy: 'f' for filtered data as in \"wb6f\", 'h' for Huffman-only\n   compression as in \"wb1h\", 'R' for run-length encoding as in \"wb1R\", or 'F'\n   for fixed code compression as in \"wb9F\".  (See the description of\n   deflateInit2 for more information about the strategy parameter.) Also \"a\"\n   can be used instead of \"w\" to request that the gzip stream that will be\n   written be appended to the file.  \"+\" will result in an error, since reading\n   and writing to the same gzip file is not supported.\n\n     gzopen can be used to read a file which is not in gzip format; in this\n   case gzread will directly read from the file without decompression.\n\n     gzopen returns NULL if the file could not be opened, if there was\n   insufficient memory to allocate the gzFile state, or if an invalid mode was\n   specified (an 'r', 'w', or 'a' was not provided, or '+' was provided).\n   errno can be checked to determine if the reason gzopen failed was that the\n   file could not be opened.\n*/\n\nZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode));\n/*\n     gzdopen associates a gzFile with the file descriptor fd.  File descriptors\n   are obtained from calls like open, dup, creat, pipe or fileno (if the file\n   has been previously opened with fopen).  The mode parameter is as in gzopen.\n\n     The next call of gzclose on the returned gzFile will also close the file\n   descriptor fd, just like fclose(fdopen(fd, mode)) closes the file descriptor\n   fd.  If you want to keep fd open, use fd = dup(fd_keep); gz = gzdopen(fd,\n   mode);.  The duplicated descriptor should be saved to avoid a leak, since\n   gzdopen does not close fd if it fails.\n\n     gzdopen returns NULL if there was insufficient memory to allocate the\n   gzFile state, if an invalid mode was specified (an 'r', 'w', or 'a' was not\n   provided, or '+' was provided), or if fd is -1.  The file descriptor is not\n   used until the next gz* read, write, seek, or close operation, so gzdopen\n   will not detect if fd is invalid (unless fd is -1).\n*/\n\nZEXTERN int ZEXPORT gzbuffer OF((gzFile file, unsigned size));\n/*\n     Set the internal buffer size used by this library's functions.  The\n   default buffer size is 8192 bytes.  This function must be called after\n   gzopen() or gzdopen(), and before any other calls that read or write the\n   file.  The buffer memory allocation is always deferred to the first read or\n   write.  Two buffers are allocated, either both of the specified size when\n   writing, or one of the specified size and the other twice that size when\n   reading.  A larger buffer size of, for example, 64K or 128K bytes will\n   noticeably increase the speed of decompression (reading).\n\n     The new buffer size also affects the maximum length for gzprintf().\n\n     gzbuffer() returns 0 on success, or -1 on failure, such as being called\n   too late.\n*/\n\nZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy));\n/*\n     Dynamically update the compression level or strategy.  See the description\n   of deflateInit2 for the meaning of these parameters.\n\n     gzsetparams returns Z_OK if success, or Z_STREAM_ERROR if the file was not\n   opened for writing.\n*/\n\nZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len));\n/*\n     Reads the given number of uncompressed bytes from the compressed file.  If\n   the input file was not in gzip format, gzread copies the given number of\n   bytes into the buffer.\n\n     After reaching the end of a gzip stream in the input, gzread will continue\n   to read, looking for another gzip stream, or failing that, reading the rest\n   of the input file directly without decompression.  The entire input file\n   will be read if gzread is called until it returns less than the requested\n   len.\n\n     gzread returns the number of uncompressed bytes actually read, less than\n   len for end of file, or -1 for error.\n*/\n\nZEXTERN int ZEXPORT gzwrite OF((gzFile file,\n                                voidpc buf, unsigned len));\n/*\n     Writes the given number of uncompressed bytes into the compressed file.\n   gzwrite returns the number of uncompressed bytes written or 0 in case of\n   error.\n*/\n\nZEXTERN int ZEXPORTVA gzprintf OF((gzFile file, const char *format, ...));\n/*\n     Converts, formats, and writes the arguments to the compressed file under\n   control of the format string, as in fprintf.  gzprintf returns the number of\n   uncompressed bytes actually written, or 0 in case of error.  The number of\n   uncompressed bytes written is limited to 8191, or one less than the buffer\n   size given to gzbuffer().  The caller should assure that this limit is not\n   exceeded.  If it is exceeded, then gzprintf() will return an error (0) with\n   nothing written.  In this case, there may also be a buffer overflow with\n   unpredictable consequences, which is possible only if zlib was compiled with\n   the insecure functions sprintf() or vsprintf() because the secure snprintf()\n   or vsnprintf() functions were not available.  This can be determined using\n   zlibCompileFlags().\n*/\n\nZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s));\n/*\n     Writes the given null-terminated string to the compressed file, excluding\n   the terminating null character.\n\n     gzputs returns the number of characters written, or -1 in case of error.\n*/\n\nZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len));\n/*\n     Reads bytes from the compressed file until len-1 characters are read, or a\n   newline character is read and transferred to buf, or an end-of-file\n   condition is encountered.  If any characters are read or if len == 1, the\n   string is terminated with a null character.  If no characters are read due\n   to an end-of-file or len < 1, then the buffer is left untouched.\n\n     gzgets returns buf which is a null-terminated string, or it returns NULL\n   for end-of-file or in case of error.  If there was an error, the contents at\n   buf are indeterminate.\n*/\n\nZEXTERN int ZEXPORT gzputc OF((gzFile file, int c));\n/*\n     Writes c, converted to an unsigned char, into the compressed file.  gzputc\n   returns the value that was written, or -1 in case of error.\n*/\n\nZEXTERN int ZEXPORT gzgetc OF((gzFile file));\n/*\n     Reads one byte from the compressed file.  gzgetc returns this byte or -1\n   in case of end of file or error.\n*/\n\nZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file));\n/*\n     Push one character back onto the stream to be read as the first character\n   on the next read.  At least one character of push-back is allowed.\n   gzungetc() returns the character pushed, or -1 on failure.  gzungetc() will\n   fail if c is -1, and may fail if a character has been pushed but not read\n   yet.  If gzungetc is used immediately after gzopen or gzdopen, at least the\n   output buffer size of pushed characters is allowed.  (See gzbuffer above.)\n   The pushed character will be discarded if the stream is repositioned with\n   gzseek() or gzrewind().\n*/\n\nZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush));\n/*\n     Flushes all pending output into the compressed file.  The parameter flush\n   is as in the deflate() function.  The return value is the zlib error number\n   (see function gzerror below).  gzflush is only permitted when writing.\n\n     If the flush parameter is Z_FINISH, the remaining data is written and the\n   gzip stream is completed in the output.  If gzwrite() is called again, a new\n   gzip stream will be started in the output.  gzread() is able to read such\n   concatented gzip streams.\n\n     gzflush should be called only when strictly necessary because it will\n   degrade compression if called too often.\n*/\n\n/*\nZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file,\n                                   z_off_t offset, int whence));\n\n     Sets the starting position for the next gzread or gzwrite on the given\n   compressed file.  The offset represents a number of bytes in the\n   uncompressed data stream.  The whence parameter is defined as in lseek(2);\n   the value SEEK_END is not supported.\n\n     If the file is opened for reading, this function is emulated but can be\n   extremely slow.  If the file is opened for writing, only forward seeks are\n   supported; gzseek then compresses a sequence of zeroes up to the new\n   starting position.\n\n     gzseek returns the resulting offset location as measured in bytes from\n   the beginning of the uncompressed stream, or -1 in case of error, in\n   particular if the file is opened for writing and the new starting position\n   would be before the current position.\n*/\n\nZEXTERN int ZEXPORT    gzrewind OF((gzFile file));\n/*\n     Rewinds the given file. This function is supported only for reading.\n\n     gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET)\n*/\n\n/*\nZEXTERN z_off_t ZEXPORT    gztell OF((gzFile file));\n\n     Returns the starting position for the next gzread or gzwrite on the given\n   compressed file.  This position represents a number of bytes in the\n   uncompressed data stream, and is zero when starting, even if appending or\n   reading a gzip stream from the middle of a file using gzdopen().\n\n     gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR)\n*/\n\n/*\nZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile file));\n\n     Returns the current offset in the file being read or written.  This offset\n   includes the count of bytes that precede the gzip stream, for example when\n   appending or when using gzdopen() for reading.  When reading, the offset\n   does not include as yet unused buffered input.  This information can be used\n   for a progress indicator.  On error, gzoffset() returns -1.\n*/\n\nZEXTERN int ZEXPORT gzeof OF((gzFile file));\n/*\n     Returns true (1) if the end-of-file indicator has been set while reading,\n   false (0) otherwise.  Note that the end-of-file indicator is set only if the\n   read tried to go past the end of the input, but came up short.  Therefore,\n   just like feof(), gzeof() may return false even if there is no more data to\n   read, in the event that the last read request was for the exact number of\n   bytes remaining in the input file.  This will happen if the input file size\n   is an exact multiple of the buffer size.\n\n     If gzeof() returns true, then the read functions will return no more data,\n   unless the end-of-file indicator is reset by gzclearerr() and the input file\n   has grown since the previous end of file was detected.\n*/\n\nZEXTERN int ZEXPORT gzdirect OF((gzFile file));\n/*\n     Returns true (1) if file is being copied directly while reading, or false\n   (0) if file is a gzip stream being decompressed.  This state can change from\n   false to true while reading the input file if the end of a gzip stream is\n   reached, but is followed by data that is not another gzip stream.\n\n     If the input file is empty, gzdirect() will return true, since the input\n   does not contain a gzip stream.\n\n     If gzdirect() is used immediately after gzopen() or gzdopen() it will\n   cause buffers to be allocated to allow reading the file to determine if it\n   is a gzip file.  Therefore if gzbuffer() is used, it should be called before\n   gzdirect().\n*/\n\nZEXTERN int ZEXPORT    gzclose OF((gzFile file));\n/*\n     Flushes all pending output if necessary, closes the compressed file and\n   deallocates the (de)compression state.  Note that once file is closed, you\n   cannot call gzerror with file, since its structures have been deallocated.\n   gzclose must not be called more than once on the same file, just as free\n   must not be called more than once on the same allocation.\n\n     gzclose will return Z_STREAM_ERROR if file is not valid, Z_ERRNO on a\n   file operation error, or Z_OK on success.\n*/\n\nZEXTERN int ZEXPORT gzclose_r OF((gzFile file));\nZEXTERN int ZEXPORT gzclose_w OF((gzFile file));\n/*\n     Same as gzclose(), but gzclose_r() is only for use when reading, and\n   gzclose_w() is only for use when writing or appending.  The advantage to\n   using these instead of gzclose() is that they avoid linking in zlib\n   compression or decompression code that is not used when only reading or only\n   writing respectively.  If gzclose() is used, then both compression and\n   decompression code will be included the application when linking to a static\n   zlib library.\n*/\n\nZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum));\n/*\n     Returns the error message for the last error which occurred on the given\n   compressed file.  errnum is set to zlib error number.  If an error occurred\n   in the file system and not in the compression library, errnum is set to\n   Z_ERRNO and the application may consult errno to get the exact error code.\n\n     The application must not modify the returned string.  Future calls to\n   this function may invalidate the previously returned string.  If file is\n   closed, then the string previously returned by gzerror will no longer be\n   available.\n\n     gzerror() should be used to distinguish errors from end-of-file for those\n   functions above that do not distinguish those cases in their return values.\n*/\n\nZEXTERN void ZEXPORT gzclearerr OF((gzFile file));\n/*\n     Clears the error and end-of-file flags for file.  This is analogous to the\n   clearerr() function in stdio.  This is useful for continuing to read a gzip\n   file that is being written concurrently.\n*/\n\n\n                        /* checksum functions */\n\n/*\n     These functions are not related to compression but are exported\n   anyway because they might be useful in applications using the compression\n   library.\n*/\n\nZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len));\n/*\n     Update a running Adler-32 checksum with the bytes buf[0..len-1] and\n   return the updated checksum.  If buf is Z_NULL, this function returns the\n   required initial value for the checksum.\n\n     An Adler-32 checksum is almost as reliable as a CRC32 but can be computed\n   much faster.\n\n   Usage example:\n\n     uLong adler = adler32(0L, Z_NULL, 0);\n\n     while (read_buffer(buffer, length) != EOF) {\n       adler = adler32(adler, buffer, length);\n     }\n     if (adler != original_adler) error();\n*/\n\n/*\nZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2,\n                                          z_off_t len2));\n\n     Combine two Adler-32 checksums into one.  For two sequences of bytes, seq1\n   and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for\n   each, adler1 and adler2.  adler32_combine() returns the Adler-32 checksum of\n   seq1 and seq2 concatenated, requiring only adler1, adler2, and len2.\n*/\n\nZEXTERN uLong ZEXPORT crc32   OF((uLong crc, const Bytef *buf, uInt len));\n/*\n     Update a running CRC-32 with the bytes buf[0..len-1] and return the\n   updated CRC-32.  If buf is Z_NULL, this function returns the required\n   initial value for the for the crc.  Pre- and post-conditioning (one's\n   complement) is performed within this function so it shouldn't be done by the\n   application.\n\n   Usage example:\n\n     uLong crc = crc32(0L, Z_NULL, 0);\n\n     while (read_buffer(buffer, length) != EOF) {\n       crc = crc32(crc, buffer, length);\n     }\n     if (crc != original_crc) error();\n*/\n\n/*\nZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2));\n\n     Combine two CRC-32 check values into one.  For two sequences of bytes,\n   seq1 and seq2 with lengths len1 and len2, CRC-32 check values were\n   calculated for each, crc1 and crc2.  crc32_combine() returns the CRC-32\n   check value of seq1 and seq2 concatenated, requiring only crc1, crc2, and\n   len2.\n*/\n\n\n                        /* various hacks, don't look :) */\n\n/* deflateInit and inflateInit are macros to allow checking the zlib version\n * and the compiler's view of z_stream:\n */\nZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level,\n                                     const char *version, int stream_size));\nZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm,\n                                     const char *version, int stream_size));\nZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int  level, int  method,\n                                      int windowBits, int memLevel,\n                                      int strategy, const char *version,\n                                      int stream_size));\nZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int  windowBits,\n                                      const char *version, int stream_size));\nZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits,\n                                         unsigned char FAR *window,\n                                         const char *version,\n                                         int stream_size));\n#define deflateInit(strm, level) \\\n        deflateInit_((strm), (level),       ZLIB_VERSION, sizeof(z_stream))\n#define inflateInit(strm) \\\n        inflateInit_((strm),                ZLIB_VERSION, sizeof(z_stream))\n#define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \\\n        deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\\\n                      (strategy),           ZLIB_VERSION, sizeof(z_stream))\n#define inflateInit2(strm, windowBits) \\\n        inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream))\n#define inflateBackInit(strm, windowBits, window) \\\n        inflateBackInit_((strm), (windowBits), (window), \\\n                                            ZLIB_VERSION, sizeof(z_stream))\n\n/* provide 64-bit offset functions if _LARGEFILE64_SOURCE defined, and/or\n * change the regular functions to 64 bits if _FILE_OFFSET_BITS is 64 (if\n * both are true, the application gets the *64 functions, and the regular\n * functions are changed to 64 bits) -- in case these are set on systems\n * without large file support, _LFS64_LARGEFILE must also be true\n */\n#if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0\n   ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *));\n   ZEXTERN z_off64_t ZEXPORT gzseek64 OF((gzFile, z_off64_t, int));\n   ZEXTERN z_off64_t ZEXPORT gztell64 OF((gzFile));\n   ZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile));\n   ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off64_t));\n   ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off64_t));\n#endif\n\n#if !defined(ZLIB_INTERNAL) && _FILE_OFFSET_BITS-0 == 64 && _LFS64_LARGEFILE-0\n#  define gzopen gzopen64\n#  define gzseek gzseek64\n#  define gztell gztell64\n#  define gzoffset gzoffset64\n#  define adler32_combine adler32_combine64\n#  define crc32_combine crc32_combine64\n#  ifdef _LARGEFILE64_SOURCE\n     ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *));\n     ZEXTERN z_off_t ZEXPORT gzseek64 OF((gzFile, z_off_t, int));\n     ZEXTERN z_off_t ZEXPORT gztell64 OF((gzFile));\n     ZEXTERN z_off_t ZEXPORT gzoffset64 OF((gzFile));\n     ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t));\n     ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t));\n#  endif\n#else\n   ZEXTERN gzFile ZEXPORT gzopen OF((const char *, const char *));\n   ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile, z_off_t, int));\n   ZEXTERN z_off_t ZEXPORT gztell OF((gzFile));\n   ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile));\n   ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t));\n   ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t));\n#endif\n\n/* hack for buggy compilers */\n#if !defined(ZUTIL_H) && !defined(NO_DUMMY_DECL)\n    struct internal_state {int dummy;};\n#endif\n\n/* undocumented functions */\nZEXTERN const char   * ZEXPORT zError           OF((int));\nZEXTERN int            ZEXPORT inflateSyncPoint OF((z_streamp));\nZEXTERN const uLongf * ZEXPORT get_crc_table    OF((void));\nZEXTERN int            ZEXPORT inflateUndermine OF((z_streamp, int));\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* ZLIB_H */\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/GL/glew.h",
    "content": "/*\r\n** The OpenGL Extension Wrangler Library\r\n** Copyright (C) 2008-2015, Nigel Stewart <nigels[]users sourceforge net>\r\n** Copyright (C) 2002-2008, Milan Ikits <milan ikits[]ieee org>\r\n** Copyright (C) 2002-2008, Marcelo E. Magallon <mmagallo[]debian org>\r\n** Copyright (C) 2002, Lev Povalahev\r\n** All rights reserved.\r\n** \r\n** Redistribution and use in source and binary forms, with or without \r\n** modification, are permitted provided that the following conditions are met:\r\n** \r\n** * Redistributions of source code must retain the above copyright notice, \r\n**   this list of conditions and the following disclaimer.\r\n** * Redistributions in binary form must reproduce the above copyright notice, \r\n**   this list of conditions and the following disclaimer in the documentation \r\n**   and/or other materials provided with the distribution.\r\n** * The name of the author may be used to endorse or promote products \r\n**   derived from this software without specific prior written permission.\r\n**\r\n** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" \r\n** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE \r\n** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r\n** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE \r\n** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR \r\n** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF \r\n** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\r\n** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\r\n** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\r\n** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF\r\n** THE POSSIBILITY OF SUCH DAMAGE.\r\n*/\r\n\r\n/*\r\n * Mesa 3-D graphics library\r\n * Version:  7.0\r\n *\r\n * Copyright (C) 1999-2007  Brian Paul   All Rights Reserved.\r\n *\r\n * Permission is hereby granted, free of charge, to any person obtaining a\r\n * copy of this software and associated documentation files (the \"Software\"),\r\n * to deal in the Software without restriction, including without limitation\r\n * the rights to use, copy, modify, merge, publish, distribute, sublicense,\r\n * and/or sell copies of the Software, and to permit persons to whom the\r\n * Software is furnished to do so, subject to the following conditions:\r\n *\r\n * The above copyright notice and this permission notice shall be included\r\n * in all copies or substantial portions of the Software.\r\n *\r\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\r\n * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL\r\n * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN\r\n * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r\n * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r\n */\r\n\r\n/*\r\n** Copyright (c) 2007 The Khronos Group Inc.\r\n** \r\n** Permission is hereby granted, free of charge, to any person obtaining a\r\n** copy of this software and/or associated documentation files (the\r\n** \"Materials\"), to deal in the Materials without restriction, including\r\n** without limitation the rights to use, copy, modify, merge, publish,\r\n** distribute, sublicense, and/or sell copies of the Materials, and to\r\n** permit persons to whom the Materials are furnished to do so, subject to\r\n** the following conditions:\r\n** \r\n** The above copyright notice and this permission notice shall be included\r\n** in all copies or substantial portions of the Materials.\r\n** \r\n** THE MATERIALS ARE PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\r\n** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r\n** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\r\n** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\r\n** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\r\n** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\r\n** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.\r\n*/\r\n\r\n#ifndef __glew_h__\r\n#define __glew_h__\r\n#define __GLEW_H__\r\n\r\n#if defined(__gl_h_) || defined(__GL_H__) || defined(_GL_H) || defined(__X_GL_H)\r\n#error gl.h included before glew.h\r\n#endif\r\n#if defined(__gl2_h_)\r\n#error gl2.h included before glew.h\r\n#endif\r\n#if defined(__gltypes_h_)\r\n#error gltypes.h included before glew.h\r\n#endif\r\n#if defined(__REGAL_H__)\r\n#error Regal.h included before glew.h\r\n#endif\r\n#if defined(__glext_h_) || defined(__GLEXT_H_)\r\n#error glext.h included before glew.h\r\n#endif\r\n#if defined(__gl_ATI_h_)\r\n#error glATI.h included before glew.h\r\n#endif\r\n\r\n#define __gl_h_\r\n#define __gl2_h_\r\n#define __GL_H__\r\n#define _GL_H\r\n#define __gltypes_h_\r\n#define __REGAL_H__\r\n#define __X_GL_H\r\n#define __glext_h_\r\n#define __GLEXT_H_\r\n#define __gl_ATI_h_\r\n\r\n#if defined(_WIN32)\r\n\r\n/*\r\n * GLEW does not include <windows.h> to avoid name space pollution.\r\n * GL needs GLAPI and GLAPIENTRY, GLU needs APIENTRY, CALLBACK, and wchar_t\r\n * defined properly.\r\n */\r\n/* <windef.h> and <gl.h>*/\r\n#ifdef APIENTRY\r\n#  ifndef GLAPIENTRY\r\n#    define GLAPIENTRY APIENTRY\r\n#  endif\r\n#  ifndef GLEWAPIENTRY\r\n#    define GLEWAPIENTRY APIENTRY\r\n#  endif\r\n#else\r\n#define GLEW_APIENTRY_DEFINED\r\n#  if defined(__MINGW32__) || defined(__CYGWIN__) || (_MSC_VER >= 800) || defined(_STDCALL_SUPPORTED) || defined(__BORLANDC__)\r\n#    define APIENTRY __stdcall\r\n#    ifndef GLAPIENTRY\r\n#      define GLAPIENTRY __stdcall\r\n#    endif\r\n#    ifndef GLEWAPIENTRY\r\n#      define GLEWAPIENTRY __stdcall\r\n#    endif\r\n#  else\r\n#    define APIENTRY\r\n#  endif\r\n#endif\r\n#ifndef GLAPI\r\n#  if defined(__MINGW32__) || defined(__CYGWIN__)\r\n#    define GLAPI extern\r\n#  endif\r\n#endif\r\n/* <winnt.h> */\r\n#ifndef CALLBACK\r\n#define GLEW_CALLBACK_DEFINED\r\n#  if defined(__MINGW32__) || defined(__CYGWIN__)\r\n#    define CALLBACK __attribute__ ((__stdcall__))\r\n#  elif (defined(_M_MRX000) || defined(_M_IX86) || defined(_M_ALPHA) || defined(_M_PPC)) && !defined(MIDL_PASS)\r\n#    define CALLBACK __stdcall\r\n#  else\r\n#    define CALLBACK\r\n#  endif\r\n#endif\r\n/* <wingdi.h> and <winnt.h> */\r\n#ifndef WINGDIAPI\r\n#define GLEW_WINGDIAPI_DEFINED\r\n#define WINGDIAPI __declspec(dllimport)\r\n#endif\r\n/* <ctype.h> */\r\n#if (defined(_MSC_VER) || defined(__BORLANDC__)) && !defined(_WCHAR_T_DEFINED)\r\ntypedef unsigned short wchar_t;\r\n#  define _WCHAR_T_DEFINED\r\n#endif\r\n/* <stddef.h> */\r\n#if !defined(_W64)\r\n#  if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && defined(_MSC_VER) && _MSC_VER >= 1300\r\n#    define _W64 __w64\r\n#  else\r\n#    define _W64\r\n#  endif\r\n#endif\r\n#if !defined(_PTRDIFF_T_DEFINED) && !defined(_PTRDIFF_T_) && !defined(__MINGW64__)\r\n#  ifdef _WIN64\r\ntypedef __int64 ptrdiff_t;\r\n#  else\r\ntypedef _W64 int ptrdiff_t;\r\n#  endif\r\n#  define _PTRDIFF_T_DEFINED\r\n#  define _PTRDIFF_T_\r\n#endif\r\n\r\n#ifndef GLAPI\r\n#  if defined(__MINGW32__) || defined(__CYGWIN__)\r\n#    define GLAPI extern\r\n#  else\r\n#    define GLAPI WINGDIAPI\r\n#  endif\r\n#endif\r\n\r\n/*\r\n * GLEW_STATIC is defined for static library.\r\n * GLEW_BUILD  is defined for building the DLL library.\r\n */\r\n\r\n#ifdef GLEW_STATIC\r\n#  define GLEWAPI extern\r\n#else\r\n#  ifdef GLEW_BUILD\r\n#    define GLEWAPI extern __declspec(dllexport)\r\n#  else\r\n#    define GLEWAPI extern __declspec(dllimport)\r\n#  endif\r\n#endif\r\n\r\n#else /* _UNIX */\r\n\r\n/*\r\n * Needed for ptrdiff_t in turn needed by VBO.  This is defined by ISO\r\n * C.  On my system, this amounts to _3 lines_ of included code, all of\r\n * them pretty much harmless.  If you know of a way of detecting 32 vs\r\n * 64 _targets_ at compile time you are free to replace this with\r\n * something that's portable.  For now, _this_ is the portable solution.\r\n * (mem, 2004-01-04)\r\n */\r\n\r\n#include <stddef.h>\r\n\r\n/* SGI MIPSPro doesn't like stdint.h in C++ mode          */\r\n/* ID: 3376260 Solaris 9 has inttypes.h, but not stdint.h */\r\n\r\n#if (defined(__sgi) || defined(__sun)) && !defined(__GNUC__)\r\n#include <inttypes.h>\r\n#else\r\n#include <stdint.h>\r\n#endif\r\n\r\n#define GLEW_APIENTRY_DEFINED\r\n#define APIENTRY\r\n\r\n/*\r\n * GLEW_STATIC is defined for static library.\r\n */\r\n\r\n#ifdef GLEW_STATIC\r\n#  define GLEWAPI extern\r\n#else\r\n#  if defined(__GNUC__) && __GNUC__>=4\r\n#   define GLEWAPI extern __attribute__ ((visibility(\"default\")))\r\n#  elif defined(__SUNPRO_C) || defined(__SUNPRO_CC)\r\n#   define GLEWAPI extern __global\r\n#  else\r\n#   define GLEWAPI extern\r\n#  endif\r\n#endif\r\n\r\n/* <glu.h> */\r\n#ifndef GLAPI\r\n#define GLAPI extern\r\n#endif\r\n\r\n#endif /* _WIN32 */\r\n\r\n#ifndef GLAPIENTRY\r\n#define GLAPIENTRY\r\n#endif\r\n\r\n#ifndef GLEWAPIENTRY\r\n#define GLEWAPIENTRY\r\n#endif\r\n\r\n#ifdef __cplusplus\r\nextern \"C\" {\r\n#endif\r\n\r\n/* ----------------------------- GL_VERSION_1_1 ---------------------------- */\r\n\r\n#ifndef GL_VERSION_1_1\r\n#define GL_VERSION_1_1 1\r\n\r\ntypedef unsigned int GLenum;\r\ntypedef unsigned int GLbitfield;\r\ntypedef unsigned int GLuint;\r\ntypedef int GLint;\r\ntypedef int GLsizei;\r\ntypedef unsigned char GLboolean;\r\ntypedef signed char GLbyte;\r\ntypedef short GLshort;\r\ntypedef unsigned char GLubyte;\r\ntypedef unsigned short GLushort;\r\ntypedef unsigned long GLulong;\r\ntypedef float GLfloat;\r\ntypedef float GLclampf;\r\ntypedef double GLdouble;\r\ntypedef double GLclampd;\r\ntypedef void GLvoid;\r\n#if defined(_MSC_VER) && _MSC_VER < 1400\r\ntypedef __int64 GLint64EXT;\r\ntypedef unsigned __int64 GLuint64EXT;\r\n#elif defined(_MSC_VER) || defined(__BORLANDC__)\r\ntypedef signed long long GLint64EXT;\r\ntypedef unsigned long long GLuint64EXT;\r\n#else\r\n#  if defined(__MINGW32__) || defined(__CYGWIN__)\r\n#include <inttypes.h>\r\n#  endif\r\ntypedef int64_t GLint64EXT;\r\ntypedef uint64_t GLuint64EXT;\r\n#endif\r\ntypedef GLint64EXT  GLint64;\r\ntypedef GLuint64EXT GLuint64;\r\ntypedef struct __GLsync *GLsync;\r\n\r\ntypedef char GLchar;\r\n\r\n#define GL_ZERO 0\r\n#define GL_FALSE 0\r\n#define GL_LOGIC_OP 0x0BF1\r\n#define GL_NONE 0\r\n#define GL_TEXTURE_COMPONENTS 0x1003\r\n#define GL_NO_ERROR 0\r\n#define GL_POINTS 0x0000\r\n#define GL_CURRENT_BIT 0x00000001\r\n#define GL_TRUE 1\r\n#define GL_ONE 1\r\n#define GL_CLIENT_PIXEL_STORE_BIT 0x00000001\r\n#define GL_LINES 0x0001\r\n#define GL_LINE_LOOP 0x0002\r\n#define GL_POINT_BIT 0x00000002\r\n#define GL_CLIENT_VERTEX_ARRAY_BIT 0x00000002\r\n#define GL_LINE_STRIP 0x0003\r\n#define GL_LINE_BIT 0x00000004\r\n#define GL_TRIANGLES 0x0004\r\n#define GL_TRIANGLE_STRIP 0x0005\r\n#define GL_TRIANGLE_FAN 0x0006\r\n#define GL_QUADS 0x0007\r\n#define GL_QUAD_STRIP 0x0008\r\n#define GL_POLYGON_BIT 0x00000008\r\n#define GL_POLYGON 0x0009\r\n#define GL_POLYGON_STIPPLE_BIT 0x00000010\r\n#define GL_PIXEL_MODE_BIT 0x00000020\r\n#define GL_LIGHTING_BIT 0x00000040\r\n#define GL_FOG_BIT 0x00000080\r\n#define GL_DEPTH_BUFFER_BIT 0x00000100\r\n#define GL_ACCUM 0x0100\r\n#define GL_LOAD 0x0101\r\n#define GL_RETURN 0x0102\r\n#define GL_MULT 0x0103\r\n#define GL_ADD 0x0104\r\n#define GL_NEVER 0x0200\r\n#define GL_ACCUM_BUFFER_BIT 0x00000200\r\n#define GL_LESS 0x0201\r\n#define GL_EQUAL 0x0202\r\n#define GL_LEQUAL 0x0203\r\n#define GL_GREATER 0x0204\r\n#define GL_NOTEQUAL 0x0205\r\n#define GL_GEQUAL 0x0206\r\n#define GL_ALWAYS 0x0207\r\n#define GL_SRC_COLOR 0x0300\r\n#define GL_ONE_MINUS_SRC_COLOR 0x0301\r\n#define GL_SRC_ALPHA 0x0302\r\n#define GL_ONE_MINUS_SRC_ALPHA 0x0303\r\n#define GL_DST_ALPHA 0x0304\r\n#define GL_ONE_MINUS_DST_ALPHA 0x0305\r\n#define GL_DST_COLOR 0x0306\r\n#define GL_ONE_MINUS_DST_COLOR 0x0307\r\n#define GL_SRC_ALPHA_SATURATE 0x0308\r\n#define GL_STENCIL_BUFFER_BIT 0x00000400\r\n#define GL_FRONT_LEFT 0x0400\r\n#define GL_FRONT_RIGHT 0x0401\r\n#define GL_BACK_LEFT 0x0402\r\n#define GL_BACK_RIGHT 0x0403\r\n#define GL_FRONT 0x0404\r\n#define GL_BACK 0x0405\r\n#define GL_LEFT 0x0406\r\n#define GL_RIGHT 0x0407\r\n#define GL_FRONT_AND_BACK 0x0408\r\n#define GL_AUX0 0x0409\r\n#define GL_AUX1 0x040A\r\n#define GL_AUX2 0x040B\r\n#define GL_AUX3 0x040C\r\n#define GL_INVALID_ENUM 0x0500\r\n#define GL_INVALID_VALUE 0x0501\r\n#define GL_INVALID_OPERATION 0x0502\r\n#define GL_STACK_OVERFLOW 0x0503\r\n#define GL_STACK_UNDERFLOW 0x0504\r\n#define GL_OUT_OF_MEMORY 0x0505\r\n#define GL_2D 0x0600\r\n#define GL_3D 0x0601\r\n#define GL_3D_COLOR 0x0602\r\n#define GL_3D_COLOR_TEXTURE 0x0603\r\n#define GL_4D_COLOR_TEXTURE 0x0604\r\n#define GL_PASS_THROUGH_TOKEN 0x0700\r\n#define GL_POINT_TOKEN 0x0701\r\n#define GL_LINE_TOKEN 0x0702\r\n#define GL_POLYGON_TOKEN 0x0703\r\n#define GL_BITMAP_TOKEN 0x0704\r\n#define GL_DRAW_PIXEL_TOKEN 0x0705\r\n#define GL_COPY_PIXEL_TOKEN 0x0706\r\n#define GL_LINE_RESET_TOKEN 0x0707\r\n#define GL_EXP 0x0800\r\n#define GL_VIEWPORT_BIT 0x00000800\r\n#define GL_EXP2 0x0801\r\n#define GL_CW 0x0900\r\n#define GL_CCW 0x0901\r\n#define GL_COEFF 0x0A00\r\n#define GL_ORDER 0x0A01\r\n#define GL_DOMAIN 0x0A02\r\n#define GL_CURRENT_COLOR 0x0B00\r\n#define GL_CURRENT_INDEX 0x0B01\r\n#define GL_CURRENT_NORMAL 0x0B02\r\n#define GL_CURRENT_TEXTURE_COORDS 0x0B03\r\n#define GL_CURRENT_RASTER_COLOR 0x0B04\r\n#define GL_CURRENT_RASTER_INDEX 0x0B05\r\n#define GL_CURRENT_RASTER_TEXTURE_COORDS 0x0B06\r\n#define GL_CURRENT_RASTER_POSITION 0x0B07\r\n#define GL_CURRENT_RASTER_POSITION_VALID 0x0B08\r\n#define GL_CURRENT_RASTER_DISTANCE 0x0B09\r\n#define GL_POINT_SMOOTH 0x0B10\r\n#define GL_POINT_SIZE 0x0B11\r\n#define GL_POINT_SIZE_RANGE 0x0B12\r\n#define GL_POINT_SIZE_GRANULARITY 0x0B13\r\n#define GL_LINE_SMOOTH 0x0B20\r\n#define GL_LINE_WIDTH 0x0B21\r\n#define GL_LINE_WIDTH_RANGE 0x0B22\r\n#define GL_LINE_WIDTH_GRANULARITY 0x0B23\r\n#define GL_LINE_STIPPLE 0x0B24\r\n#define GL_LINE_STIPPLE_PATTERN 0x0B25\r\n#define GL_LINE_STIPPLE_REPEAT 0x0B26\r\n#define GL_LIST_MODE 0x0B30\r\n#define GL_MAX_LIST_NESTING 0x0B31\r\n#define GL_LIST_BASE 0x0B32\r\n#define GL_LIST_INDEX 0x0B33\r\n#define GL_POLYGON_MODE 0x0B40\r\n#define GL_POLYGON_SMOOTH 0x0B41\r\n#define GL_POLYGON_STIPPLE 0x0B42\r\n#define GL_EDGE_FLAG 0x0B43\r\n#define GL_CULL_FACE 0x0B44\r\n#define GL_CULL_FACE_MODE 0x0B45\r\n#define GL_FRONT_FACE 0x0B46\r\n#define GL_LIGHTING 0x0B50\r\n#define GL_LIGHT_MODEL_LOCAL_VIEWER 0x0B51\r\n#define GL_LIGHT_MODEL_TWO_SIDE 0x0B52\r\n#define GL_LIGHT_MODEL_AMBIENT 0x0B53\r\n#define GL_SHADE_MODEL 0x0B54\r\n#define GL_COLOR_MATERIAL_FACE 0x0B55\r\n#define GL_COLOR_MATERIAL_PARAMETER 0x0B56\r\n#define GL_COLOR_MATERIAL 0x0B57\r\n#define GL_FOG 0x0B60\r\n#define GL_FOG_INDEX 0x0B61\r\n#define GL_FOG_DENSITY 0x0B62\r\n#define GL_FOG_START 0x0B63\r\n#define GL_FOG_END 0x0B64\r\n#define GL_FOG_MODE 0x0B65\r\n#define GL_FOG_COLOR 0x0B66\r\n#define GL_DEPTH_RANGE 0x0B70\r\n#define GL_DEPTH_TEST 0x0B71\r\n#define GL_DEPTH_WRITEMASK 0x0B72\r\n#define GL_DEPTH_CLEAR_VALUE 0x0B73\r\n#define GL_DEPTH_FUNC 0x0B74\r\n#define GL_ACCUM_CLEAR_VALUE 0x0B80\r\n#define GL_STENCIL_TEST 0x0B90\r\n#define GL_STENCIL_CLEAR_VALUE 0x0B91\r\n#define GL_STENCIL_FUNC 0x0B92\r\n#define GL_STENCIL_VALUE_MASK 0x0B93\r\n#define GL_STENCIL_FAIL 0x0B94\r\n#define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95\r\n#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96\r\n#define GL_STENCIL_REF 0x0B97\r\n#define GL_STENCIL_WRITEMASK 0x0B98\r\n#define GL_MATRIX_MODE 0x0BA0\r\n#define GL_NORMALIZE 0x0BA1\r\n#define GL_VIEWPORT 0x0BA2\r\n#define GL_MODELVIEW_STACK_DEPTH 0x0BA3\r\n#define GL_PROJECTION_STACK_DEPTH 0x0BA4\r\n#define GL_TEXTURE_STACK_DEPTH 0x0BA5\r\n#define GL_MODELVIEW_MATRIX 0x0BA6\r\n#define GL_PROJECTION_MATRIX 0x0BA7\r\n#define GL_TEXTURE_MATRIX 0x0BA8\r\n#define GL_ATTRIB_STACK_DEPTH 0x0BB0\r\n#define GL_CLIENT_ATTRIB_STACK_DEPTH 0x0BB1\r\n#define GL_ALPHA_TEST 0x0BC0\r\n#define GL_ALPHA_TEST_FUNC 0x0BC1\r\n#define GL_ALPHA_TEST_REF 0x0BC2\r\n#define GL_DITHER 0x0BD0\r\n#define GL_BLEND_DST 0x0BE0\r\n#define GL_BLEND_SRC 0x0BE1\r\n#define GL_BLEND 0x0BE2\r\n#define GL_LOGIC_OP_MODE 0x0BF0\r\n#define GL_INDEX_LOGIC_OP 0x0BF1\r\n#define GL_COLOR_LOGIC_OP 0x0BF2\r\n#define GL_AUX_BUFFERS 0x0C00\r\n#define GL_DRAW_BUFFER 0x0C01\r\n#define GL_READ_BUFFER 0x0C02\r\n#define GL_SCISSOR_BOX 0x0C10\r\n#define GL_SCISSOR_TEST 0x0C11\r\n#define GL_INDEX_CLEAR_VALUE 0x0C20\r\n#define GL_INDEX_WRITEMASK 0x0C21\r\n#define GL_COLOR_CLEAR_VALUE 0x0C22\r\n#define GL_COLOR_WRITEMASK 0x0C23\r\n#define GL_INDEX_MODE 0x0C30\r\n#define GL_RGBA_MODE 0x0C31\r\n#define GL_DOUBLEBUFFER 0x0C32\r\n#define GL_STEREO 0x0C33\r\n#define GL_RENDER_MODE 0x0C40\r\n#define GL_PERSPECTIVE_CORRECTION_HINT 0x0C50\r\n#define GL_POINT_SMOOTH_HINT 0x0C51\r\n#define GL_LINE_SMOOTH_HINT 0x0C52\r\n#define GL_POLYGON_SMOOTH_HINT 0x0C53\r\n#define GL_FOG_HINT 0x0C54\r\n#define GL_TEXTURE_GEN_S 0x0C60\r\n#define GL_TEXTURE_GEN_T 0x0C61\r\n#define GL_TEXTURE_GEN_R 0x0C62\r\n#define GL_TEXTURE_GEN_Q 0x0C63\r\n#define GL_PIXEL_MAP_I_TO_I 0x0C70\r\n#define GL_PIXEL_MAP_S_TO_S 0x0C71\r\n#define GL_PIXEL_MAP_I_TO_R 0x0C72\r\n#define GL_PIXEL_MAP_I_TO_G 0x0C73\r\n#define GL_PIXEL_MAP_I_TO_B 0x0C74\r\n#define GL_PIXEL_MAP_I_TO_A 0x0C75\r\n#define GL_PIXEL_MAP_R_TO_R 0x0C76\r\n#define GL_PIXEL_MAP_G_TO_G 0x0C77\r\n#define GL_PIXEL_MAP_B_TO_B 0x0C78\r\n#define GL_PIXEL_MAP_A_TO_A 0x0C79\r\n#define GL_PIXEL_MAP_I_TO_I_SIZE 0x0CB0\r\n#define GL_PIXEL_MAP_S_TO_S_SIZE 0x0CB1\r\n#define GL_PIXEL_MAP_I_TO_R_SIZE 0x0CB2\r\n#define GL_PIXEL_MAP_I_TO_G_SIZE 0x0CB3\r\n#define GL_PIXEL_MAP_I_TO_B_SIZE 0x0CB4\r\n#define GL_PIXEL_MAP_I_TO_A_SIZE 0x0CB5\r\n#define GL_PIXEL_MAP_R_TO_R_SIZE 0x0CB6\r\n#define GL_PIXEL_MAP_G_TO_G_SIZE 0x0CB7\r\n#define GL_PIXEL_MAP_B_TO_B_SIZE 0x0CB8\r\n#define GL_PIXEL_MAP_A_TO_A_SIZE 0x0CB9\r\n#define GL_UNPACK_SWAP_BYTES 0x0CF0\r\n#define GL_UNPACK_LSB_FIRST 0x0CF1\r\n#define GL_UNPACK_ROW_LENGTH 0x0CF2\r\n#define GL_UNPACK_SKIP_ROWS 0x0CF3\r\n#define GL_UNPACK_SKIP_PIXELS 0x0CF4\r\n#define GL_UNPACK_ALIGNMENT 0x0CF5\r\n#define GL_PACK_SWAP_BYTES 0x0D00\r\n#define GL_PACK_LSB_FIRST 0x0D01\r\n#define GL_PACK_ROW_LENGTH 0x0D02\r\n#define GL_PACK_SKIP_ROWS 0x0D03\r\n#define GL_PACK_SKIP_PIXELS 0x0D04\r\n#define GL_PACK_ALIGNMENT 0x0D05\r\n#define GL_MAP_COLOR 0x0D10\r\n#define GL_MAP_STENCIL 0x0D11\r\n#define GL_INDEX_SHIFT 0x0D12\r\n#define GL_INDEX_OFFSET 0x0D13\r\n#define GL_RED_SCALE 0x0D14\r\n#define GL_RED_BIAS 0x0D15\r\n#define GL_ZOOM_X 0x0D16\r\n#define GL_ZOOM_Y 0x0D17\r\n#define GL_GREEN_SCALE 0x0D18\r\n#define GL_GREEN_BIAS 0x0D19\r\n#define GL_BLUE_SCALE 0x0D1A\r\n#define GL_BLUE_BIAS 0x0D1B\r\n#define GL_ALPHA_SCALE 0x0D1C\r\n#define GL_ALPHA_BIAS 0x0D1D\r\n#define GL_DEPTH_SCALE 0x0D1E\r\n#define GL_DEPTH_BIAS 0x0D1F\r\n#define GL_MAX_EVAL_ORDER 0x0D30\r\n#define GL_MAX_LIGHTS 0x0D31\r\n#define GL_MAX_CLIP_PLANES 0x0D32\r\n#define GL_MAX_TEXTURE_SIZE 0x0D33\r\n#define GL_MAX_PIXEL_MAP_TABLE 0x0D34\r\n#define GL_MAX_ATTRIB_STACK_DEPTH 0x0D35\r\n#define GL_MAX_MODELVIEW_STACK_DEPTH 0x0D36\r\n#define GL_MAX_NAME_STACK_DEPTH 0x0D37\r\n#define GL_MAX_PROJECTION_STACK_DEPTH 0x0D38\r\n#define GL_MAX_TEXTURE_STACK_DEPTH 0x0D39\r\n#define GL_MAX_VIEWPORT_DIMS 0x0D3A\r\n#define GL_MAX_CLIENT_ATTRIB_STACK_DEPTH 0x0D3B\r\n#define GL_SUBPIXEL_BITS 0x0D50\r\n#define GL_INDEX_BITS 0x0D51\r\n#define GL_RED_BITS 0x0D52\r\n#define GL_GREEN_BITS 0x0D53\r\n#define GL_BLUE_BITS 0x0D54\r\n#define GL_ALPHA_BITS 0x0D55\r\n#define GL_DEPTH_BITS 0x0D56\r\n#define GL_STENCIL_BITS 0x0D57\r\n#define GL_ACCUM_RED_BITS 0x0D58\r\n#define GL_ACCUM_GREEN_BITS 0x0D59\r\n#define GL_ACCUM_BLUE_BITS 0x0D5A\r\n#define GL_ACCUM_ALPHA_BITS 0x0D5B\r\n#define GL_NAME_STACK_DEPTH 0x0D70\r\n#define GL_AUTO_NORMAL 0x0D80\r\n#define GL_MAP1_COLOR_4 0x0D90\r\n#define GL_MAP1_INDEX 0x0D91\r\n#define GL_MAP1_NORMAL 0x0D92\r\n#define GL_MAP1_TEXTURE_COORD_1 0x0D93\r\n#define GL_MAP1_TEXTURE_COORD_2 0x0D94\r\n#define GL_MAP1_TEXTURE_COORD_3 0x0D95\r\n#define GL_MAP1_TEXTURE_COORD_4 0x0D96\r\n#define GL_MAP1_VERTEX_3 0x0D97\r\n#define GL_MAP1_VERTEX_4 0x0D98\r\n#define GL_MAP2_COLOR_4 0x0DB0\r\n#define GL_MAP2_INDEX 0x0DB1\r\n#define GL_MAP2_NORMAL 0x0DB2\r\n#define GL_MAP2_TEXTURE_COORD_1 0x0DB3\r\n#define GL_MAP2_TEXTURE_COORD_2 0x0DB4\r\n#define GL_MAP2_TEXTURE_COORD_3 0x0DB5\r\n#define GL_MAP2_TEXTURE_COORD_4 0x0DB6\r\n#define GL_MAP2_VERTEX_3 0x0DB7\r\n#define GL_MAP2_VERTEX_4 0x0DB8\r\n#define GL_MAP1_GRID_DOMAIN 0x0DD0\r\n#define GL_MAP1_GRID_SEGMENTS 0x0DD1\r\n#define GL_MAP2_GRID_DOMAIN 0x0DD2\r\n#define GL_MAP2_GRID_SEGMENTS 0x0DD3\r\n#define GL_TEXTURE_1D 0x0DE0\r\n#define GL_TEXTURE_2D 0x0DE1\r\n#define GL_FEEDBACK_BUFFER_POINTER 0x0DF0\r\n#define GL_FEEDBACK_BUFFER_SIZE 0x0DF1\r\n#define GL_FEEDBACK_BUFFER_TYPE 0x0DF2\r\n#define GL_SELECTION_BUFFER_POINTER 0x0DF3\r\n#define GL_SELECTION_BUFFER_SIZE 0x0DF4\r\n#define GL_TEXTURE_WIDTH 0x1000\r\n#define GL_TRANSFORM_BIT 0x00001000\r\n#define GL_TEXTURE_HEIGHT 0x1001\r\n#define GL_TEXTURE_INTERNAL_FORMAT 0x1003\r\n#define GL_TEXTURE_BORDER_COLOR 0x1004\r\n#define GL_TEXTURE_BORDER 0x1005\r\n#define GL_DONT_CARE 0x1100\r\n#define GL_FASTEST 0x1101\r\n#define GL_NICEST 0x1102\r\n#define GL_AMBIENT 0x1200\r\n#define GL_DIFFUSE 0x1201\r\n#define GL_SPECULAR 0x1202\r\n#define GL_POSITION 0x1203\r\n#define GL_SPOT_DIRECTION 0x1204\r\n#define GL_SPOT_EXPONENT 0x1205\r\n#define GL_SPOT_CUTOFF 0x1206\r\n#define GL_CONSTANT_ATTENUATION 0x1207\r\n#define GL_LINEAR_ATTENUATION 0x1208\r\n#define GL_QUADRATIC_ATTENUATION 0x1209\r\n#define GL_COMPILE 0x1300\r\n#define GL_COMPILE_AND_EXECUTE 0x1301\r\n#define GL_BYTE 0x1400\r\n#define GL_UNSIGNED_BYTE 0x1401\r\n#define GL_SHORT 0x1402\r\n#define GL_UNSIGNED_SHORT 0x1403\r\n#define GL_INT 0x1404\r\n#define GL_UNSIGNED_INT 0x1405\r\n#define GL_FLOAT 0x1406\r\n#define GL_2_BYTES 0x1407\r\n#define GL_3_BYTES 0x1408\r\n#define GL_4_BYTES 0x1409\r\n#define GL_DOUBLE 0x140A\r\n#define GL_CLEAR 0x1500\r\n#define GL_AND 0x1501\r\n#define GL_AND_REVERSE 0x1502\r\n#define GL_COPY 0x1503\r\n#define GL_AND_INVERTED 0x1504\r\n#define GL_NOOP 0x1505\r\n#define GL_XOR 0x1506\r\n#define GL_OR 0x1507\r\n#define GL_NOR 0x1508\r\n#define GL_EQUIV 0x1509\r\n#define GL_INVERT 0x150A\r\n#define GL_OR_REVERSE 0x150B\r\n#define GL_COPY_INVERTED 0x150C\r\n#define GL_OR_INVERTED 0x150D\r\n#define GL_NAND 0x150E\r\n#define GL_SET 0x150F\r\n#define GL_EMISSION 0x1600\r\n#define GL_SHININESS 0x1601\r\n#define GL_AMBIENT_AND_DIFFUSE 0x1602\r\n#define GL_COLOR_INDEXES 0x1603\r\n#define GL_MODELVIEW 0x1700\r\n#define GL_PROJECTION 0x1701\r\n#define GL_TEXTURE 0x1702\r\n#define GL_COLOR 0x1800\r\n#define GL_DEPTH 0x1801\r\n#define GL_STENCIL 0x1802\r\n#define GL_COLOR_INDEX 0x1900\r\n#define GL_STENCIL_INDEX 0x1901\r\n#define GL_DEPTH_COMPONENT 0x1902\r\n#define GL_RED 0x1903\r\n#define GL_GREEN 0x1904\r\n#define GL_BLUE 0x1905\r\n#define GL_ALPHA 0x1906\r\n#define GL_RGB 0x1907\r\n#define GL_RGBA 0x1908\r\n#define GL_LUMINANCE 0x1909\r\n#define GL_LUMINANCE_ALPHA 0x190A\r\n#define GL_BITMAP 0x1A00\r\n#define GL_POINT 0x1B00\r\n#define GL_LINE 0x1B01\r\n#define GL_FILL 0x1B02\r\n#define GL_RENDER 0x1C00\r\n#define GL_FEEDBACK 0x1C01\r\n#define GL_SELECT 0x1C02\r\n#define GL_FLAT 0x1D00\r\n#define GL_SMOOTH 0x1D01\r\n#define GL_KEEP 0x1E00\r\n#define GL_REPLACE 0x1E01\r\n#define GL_INCR 0x1E02\r\n#define GL_DECR 0x1E03\r\n#define GL_VENDOR 0x1F00\r\n#define GL_RENDERER 0x1F01\r\n#define GL_VERSION 0x1F02\r\n#define GL_EXTENSIONS 0x1F03\r\n#define GL_S 0x2000\r\n#define GL_ENABLE_BIT 0x00002000\r\n#define GL_T 0x2001\r\n#define GL_R 0x2002\r\n#define GL_Q 0x2003\r\n#define GL_MODULATE 0x2100\r\n#define GL_DECAL 0x2101\r\n#define GL_TEXTURE_ENV_MODE 0x2200\r\n#define GL_TEXTURE_ENV_COLOR 0x2201\r\n#define GL_TEXTURE_ENV 0x2300\r\n#define GL_EYE_LINEAR 0x2400\r\n#define GL_OBJECT_LINEAR 0x2401\r\n#define GL_SPHERE_MAP 0x2402\r\n#define GL_TEXTURE_GEN_MODE 0x2500\r\n#define GL_OBJECT_PLANE 0x2501\r\n#define GL_EYE_PLANE 0x2502\r\n#define GL_NEAREST 0x2600\r\n#define GL_LINEAR 0x2601\r\n#define GL_NEAREST_MIPMAP_NEAREST 0x2700\r\n#define GL_LINEAR_MIPMAP_NEAREST 0x2701\r\n#define GL_NEAREST_MIPMAP_LINEAR 0x2702\r\n#define GL_LINEAR_MIPMAP_LINEAR 0x2703\r\n#define GL_TEXTURE_MAG_FILTER 0x2800\r\n#define GL_TEXTURE_MIN_FILTER 0x2801\r\n#define GL_TEXTURE_WRAP_S 0x2802\r\n#define GL_TEXTURE_WRAP_T 0x2803\r\n#define GL_CLAMP 0x2900\r\n#define GL_REPEAT 0x2901\r\n#define GL_POLYGON_OFFSET_UNITS 0x2A00\r\n#define GL_POLYGON_OFFSET_POINT 0x2A01\r\n#define GL_POLYGON_OFFSET_LINE 0x2A02\r\n#define GL_R3_G3_B2 0x2A10\r\n#define GL_V2F 0x2A20\r\n#define GL_V3F 0x2A21\r\n#define GL_C4UB_V2F 0x2A22\r\n#define GL_C4UB_V3F 0x2A23\r\n#define GL_C3F_V3F 0x2A24\r\n#define GL_N3F_V3F 0x2A25\r\n#define GL_C4F_N3F_V3F 0x2A26\r\n#define GL_T2F_V3F 0x2A27\r\n#define GL_T4F_V4F 0x2A28\r\n#define GL_T2F_C4UB_V3F 0x2A29\r\n#define GL_T2F_C3F_V3F 0x2A2A\r\n#define GL_T2F_N3F_V3F 0x2A2B\r\n#define GL_T2F_C4F_N3F_V3F 0x2A2C\r\n#define GL_T4F_C4F_N3F_V4F 0x2A2D\r\n#define GL_CLIP_PLANE0 0x3000\r\n#define GL_CLIP_PLANE1 0x3001\r\n#define GL_CLIP_PLANE2 0x3002\r\n#define GL_CLIP_PLANE3 0x3003\r\n#define GL_CLIP_PLANE4 0x3004\r\n#define GL_CLIP_PLANE5 0x3005\r\n#define GL_LIGHT0 0x4000\r\n#define GL_COLOR_BUFFER_BIT 0x00004000\r\n#define GL_LIGHT1 0x4001\r\n#define GL_LIGHT2 0x4002\r\n#define GL_LIGHT3 0x4003\r\n#define GL_LIGHT4 0x4004\r\n#define GL_LIGHT5 0x4005\r\n#define GL_LIGHT6 0x4006\r\n#define GL_LIGHT7 0x4007\r\n#define GL_HINT_BIT 0x00008000\r\n#define GL_POLYGON_OFFSET_FILL 0x8037\r\n#define GL_POLYGON_OFFSET_FACTOR 0x8038\r\n#define GL_ALPHA4 0x803B\r\n#define GL_ALPHA8 0x803C\r\n#define GL_ALPHA12 0x803D\r\n#define GL_ALPHA16 0x803E\r\n#define GL_LUMINANCE4 0x803F\r\n#define GL_LUMINANCE8 0x8040\r\n#define GL_LUMINANCE12 0x8041\r\n#define GL_LUMINANCE16 0x8042\r\n#define GL_LUMINANCE4_ALPHA4 0x8043\r\n#define GL_LUMINANCE6_ALPHA2 0x8044\r\n#define GL_LUMINANCE8_ALPHA8 0x8045\r\n#define GL_LUMINANCE12_ALPHA4 0x8046\r\n#define GL_LUMINANCE12_ALPHA12 0x8047\r\n#define GL_LUMINANCE16_ALPHA16 0x8048\r\n#define GL_INTENSITY 0x8049\r\n#define GL_INTENSITY4 0x804A\r\n#define GL_INTENSITY8 0x804B\r\n#define GL_INTENSITY12 0x804C\r\n#define GL_INTENSITY16 0x804D\r\n#define GL_RGB4 0x804F\r\n#define GL_RGB5 0x8050\r\n#define GL_RGB8 0x8051\r\n#define GL_RGB10 0x8052\r\n#define GL_RGB12 0x8053\r\n#define GL_RGB16 0x8054\r\n#define GL_RGBA2 0x8055\r\n#define GL_RGBA4 0x8056\r\n#define GL_RGB5_A1 0x8057\r\n#define GL_RGBA8 0x8058\r\n#define GL_RGB10_A2 0x8059\r\n#define GL_RGBA12 0x805A\r\n#define GL_RGBA16 0x805B\r\n#define GL_TEXTURE_RED_SIZE 0x805C\r\n#define GL_TEXTURE_GREEN_SIZE 0x805D\r\n#define GL_TEXTURE_BLUE_SIZE 0x805E\r\n#define GL_TEXTURE_ALPHA_SIZE 0x805F\r\n#define GL_TEXTURE_LUMINANCE_SIZE 0x8060\r\n#define GL_TEXTURE_INTENSITY_SIZE 0x8061\r\n#define GL_PROXY_TEXTURE_1D 0x8063\r\n#define GL_PROXY_TEXTURE_2D 0x8064\r\n#define GL_TEXTURE_PRIORITY 0x8066\r\n#define GL_TEXTURE_RESIDENT 0x8067\r\n#define GL_TEXTURE_BINDING_1D 0x8068\r\n#define GL_TEXTURE_BINDING_2D 0x8069\r\n#define GL_VERTEX_ARRAY 0x8074\r\n#define GL_NORMAL_ARRAY 0x8075\r\n#define GL_COLOR_ARRAY 0x8076\r\n#define GL_INDEX_ARRAY 0x8077\r\n#define GL_TEXTURE_COORD_ARRAY 0x8078\r\n#define GL_EDGE_FLAG_ARRAY 0x8079\r\n#define GL_VERTEX_ARRAY_SIZE 0x807A\r\n#define GL_VERTEX_ARRAY_TYPE 0x807B\r\n#define GL_VERTEX_ARRAY_STRIDE 0x807C\r\n#define GL_NORMAL_ARRAY_TYPE 0x807E\r\n#define GL_NORMAL_ARRAY_STRIDE 0x807F\r\n#define GL_COLOR_ARRAY_SIZE 0x8081\r\n#define GL_COLOR_ARRAY_TYPE 0x8082\r\n#define GL_COLOR_ARRAY_STRIDE 0x8083\r\n#define GL_INDEX_ARRAY_TYPE 0x8085\r\n#define GL_INDEX_ARRAY_STRIDE 0x8086\r\n#define GL_TEXTURE_COORD_ARRAY_SIZE 0x8088\r\n#define GL_TEXTURE_COORD_ARRAY_TYPE 0x8089\r\n#define GL_TEXTURE_COORD_ARRAY_STRIDE 0x808A\r\n#define GL_EDGE_FLAG_ARRAY_STRIDE 0x808C\r\n#define GL_VERTEX_ARRAY_POINTER 0x808E\r\n#define GL_NORMAL_ARRAY_POINTER 0x808F\r\n#define GL_COLOR_ARRAY_POINTER 0x8090\r\n#define GL_INDEX_ARRAY_POINTER 0x8091\r\n#define GL_TEXTURE_COORD_ARRAY_POINTER 0x8092\r\n#define GL_EDGE_FLAG_ARRAY_POINTER 0x8093\r\n#define GL_COLOR_INDEX1_EXT 0x80E2\r\n#define GL_COLOR_INDEX2_EXT 0x80E3\r\n#define GL_COLOR_INDEX4_EXT 0x80E4\r\n#define GL_COLOR_INDEX8_EXT 0x80E5\r\n#define GL_COLOR_INDEX12_EXT 0x80E6\r\n#define GL_COLOR_INDEX16_EXT 0x80E7\r\n#define GL_EVAL_BIT 0x00010000\r\n#define GL_LIST_BIT 0x00020000\r\n#define GL_TEXTURE_BIT 0x00040000\r\n#define GL_SCISSOR_BIT 0x00080000\r\n#define GL_ALL_ATTRIB_BITS 0x000fffff\r\n#define GL_CLIENT_ALL_ATTRIB_BITS 0xffffffff\r\n\r\nGLAPI void GLAPIENTRY glAccum (GLenum op, GLfloat value);\r\nGLAPI void GLAPIENTRY glAlphaFunc (GLenum func, GLclampf ref);\r\nGLAPI GLboolean GLAPIENTRY glAreTexturesResident (GLsizei n, const GLuint *textures, GLboolean *residences);\r\nGLAPI void GLAPIENTRY glArrayElement (GLint i);\r\nGLAPI void GLAPIENTRY glBegin (GLenum mode);\r\nGLAPI void GLAPIENTRY glBindTexture (GLenum target, GLuint texture);\r\nGLAPI void GLAPIENTRY glBitmap (GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, const GLubyte *bitmap);\r\nGLAPI void GLAPIENTRY glBlendFunc (GLenum sfactor, GLenum dfactor);\r\nGLAPI void GLAPIENTRY glCallList (GLuint list);\r\nGLAPI void GLAPIENTRY glCallLists (GLsizei n, GLenum type, const void *lists);\r\nGLAPI void GLAPIENTRY glClear (GLbitfield mask);\r\nGLAPI void GLAPIENTRY glClearAccum (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);\r\nGLAPI void GLAPIENTRY glClearColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);\r\nGLAPI void GLAPIENTRY glClearDepth (GLclampd depth);\r\nGLAPI void GLAPIENTRY glClearIndex (GLfloat c);\r\nGLAPI void GLAPIENTRY glClearStencil (GLint s);\r\nGLAPI void GLAPIENTRY glClipPlane (GLenum plane, const GLdouble *equation);\r\nGLAPI void GLAPIENTRY glColor3b (GLbyte red, GLbyte green, GLbyte blue);\r\nGLAPI void GLAPIENTRY glColor3bv (const GLbyte *v);\r\nGLAPI void GLAPIENTRY glColor3d (GLdouble red, GLdouble green, GLdouble blue);\r\nGLAPI void GLAPIENTRY glColor3dv (const GLdouble *v);\r\nGLAPI void GLAPIENTRY glColor3f (GLfloat red, GLfloat green, GLfloat blue);\r\nGLAPI void GLAPIENTRY glColor3fv (const GLfloat *v);\r\nGLAPI void GLAPIENTRY glColor3i (GLint red, GLint green, GLint blue);\r\nGLAPI void GLAPIENTRY glColor3iv (const GLint *v);\r\nGLAPI void GLAPIENTRY glColor3s (GLshort red, GLshort green, GLshort blue);\r\nGLAPI void GLAPIENTRY glColor3sv (const GLshort *v);\r\nGLAPI void GLAPIENTRY glColor3ub (GLubyte red, GLubyte green, GLubyte blue);\r\nGLAPI void GLAPIENTRY glColor3ubv (const GLubyte *v);\r\nGLAPI void GLAPIENTRY glColor3ui (GLuint red, GLuint green, GLuint blue);\r\nGLAPI void GLAPIENTRY glColor3uiv (const GLuint *v);\r\nGLAPI void GLAPIENTRY glColor3us (GLushort red, GLushort green, GLushort blue);\r\nGLAPI void GLAPIENTRY glColor3usv (const GLushort *v);\r\nGLAPI void GLAPIENTRY glColor4b (GLbyte red, GLbyte green, GLbyte blue, GLbyte alpha);\r\nGLAPI void GLAPIENTRY glColor4bv (const GLbyte *v);\r\nGLAPI void GLAPIENTRY glColor4d (GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha);\r\nGLAPI void GLAPIENTRY glColor4dv (const GLdouble *v);\r\nGLAPI void GLAPIENTRY glColor4f (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);\r\nGLAPI void GLAPIENTRY glColor4fv (const GLfloat *v);\r\nGLAPI void GLAPIENTRY glColor4i (GLint red, GLint green, GLint blue, GLint alpha);\r\nGLAPI void GLAPIENTRY glColor4iv (const GLint *v);\r\nGLAPI void GLAPIENTRY glColor4s (GLshort red, GLshort green, GLshort blue, GLshort alpha);\r\nGLAPI void GLAPIENTRY glColor4sv (const GLshort *v);\r\nGLAPI void GLAPIENTRY glColor4ub (GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha);\r\nGLAPI void GLAPIENTRY glColor4ubv (const GLubyte *v);\r\nGLAPI void GLAPIENTRY glColor4ui (GLuint red, GLuint green, GLuint blue, GLuint alpha);\r\nGLAPI void GLAPIENTRY glColor4uiv (const GLuint *v);\r\nGLAPI void GLAPIENTRY glColor4us (GLushort red, GLushort green, GLushort blue, GLushort alpha);\r\nGLAPI void GLAPIENTRY glColor4usv (const GLushort *v);\r\nGLAPI void GLAPIENTRY glColorMask (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);\r\nGLAPI void GLAPIENTRY glColorMaterial (GLenum face, GLenum mode);\r\nGLAPI void GLAPIENTRY glColorPointer (GLint size, GLenum type, GLsizei stride, const void *pointer);\r\nGLAPI void GLAPIENTRY glCopyPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum type);\r\nGLAPI void GLAPIENTRY glCopyTexImage1D (GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLint border);\r\nGLAPI void GLAPIENTRY glCopyTexImage2D (GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);\r\nGLAPI void GLAPIENTRY glCopyTexSubImage1D (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width);\r\nGLAPI void GLAPIENTRY glCopyTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);\r\nGLAPI void GLAPIENTRY glCullFace (GLenum mode);\r\nGLAPI void GLAPIENTRY glDeleteLists (GLuint list, GLsizei range);\r\nGLAPI void GLAPIENTRY glDeleteTextures (GLsizei n, const GLuint *textures);\r\nGLAPI void GLAPIENTRY glDepthFunc (GLenum func);\r\nGLAPI void GLAPIENTRY glDepthMask (GLboolean flag);\r\nGLAPI void GLAPIENTRY glDepthRange (GLclampd zNear, GLclampd zFar);\r\nGLAPI void GLAPIENTRY glDisable (GLenum cap);\r\nGLAPI void GLAPIENTRY glDisableClientState (GLenum array);\r\nGLAPI void GLAPIENTRY glDrawArrays (GLenum mode, GLint first, GLsizei count);\r\nGLAPI void GLAPIENTRY glDrawBuffer (GLenum mode);\r\nGLAPI void GLAPIENTRY glDrawElements (GLenum mode, GLsizei count, GLenum type, const void *indices);\r\nGLAPI void GLAPIENTRY glDrawPixels (GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels);\r\nGLAPI void GLAPIENTRY glEdgeFlag (GLboolean flag);\r\nGLAPI void GLAPIENTRY glEdgeFlagPointer (GLsizei stride, const void *pointer);\r\nGLAPI void GLAPIENTRY glEdgeFlagv (const GLboolean *flag);\r\nGLAPI void GLAPIENTRY glEnable (GLenum cap);\r\nGLAPI void GLAPIENTRY glEnableClientState (GLenum array);\r\nGLAPI void GLAPIENTRY glEnd (void);\r\nGLAPI void GLAPIENTRY glEndList (void);\r\nGLAPI void GLAPIENTRY glEvalCoord1d (GLdouble u);\r\nGLAPI void GLAPIENTRY glEvalCoord1dv (const GLdouble *u);\r\nGLAPI void GLAPIENTRY glEvalCoord1f (GLfloat u);\r\nGLAPI void GLAPIENTRY glEvalCoord1fv (const GLfloat *u);\r\nGLAPI void GLAPIENTRY glEvalCoord2d (GLdouble u, GLdouble v);\r\nGLAPI void GLAPIENTRY glEvalCoord2dv (const GLdouble *u);\r\nGLAPI void GLAPIENTRY glEvalCoord2f (GLfloat u, GLfloat v);\r\nGLAPI void GLAPIENTRY glEvalCoord2fv (const GLfloat *u);\r\nGLAPI void GLAPIENTRY glEvalMesh1 (GLenum mode, GLint i1, GLint i2);\r\nGLAPI void GLAPIENTRY glEvalMesh2 (GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2);\r\nGLAPI void GLAPIENTRY glEvalPoint1 (GLint i);\r\nGLAPI void GLAPIENTRY glEvalPoint2 (GLint i, GLint j);\r\nGLAPI void GLAPIENTRY glFeedbackBuffer (GLsizei size, GLenum type, GLfloat *buffer);\r\nGLAPI void GLAPIENTRY glFinish (void);\r\nGLAPI void GLAPIENTRY glFlush (void);\r\nGLAPI void GLAPIENTRY glFogf (GLenum pname, GLfloat param);\r\nGLAPI void GLAPIENTRY glFogfv (GLenum pname, const GLfloat *params);\r\nGLAPI void GLAPIENTRY glFogi (GLenum pname, GLint param);\r\nGLAPI void GLAPIENTRY glFogiv (GLenum pname, const GLint *params);\r\nGLAPI void GLAPIENTRY glFrontFace (GLenum mode);\r\nGLAPI void GLAPIENTRY glFrustum (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar);\r\nGLAPI GLuint GLAPIENTRY glGenLists (GLsizei range);\r\nGLAPI void GLAPIENTRY glGenTextures (GLsizei n, GLuint *textures);\r\nGLAPI void GLAPIENTRY glGetBooleanv (GLenum pname, GLboolean *params);\r\nGLAPI void GLAPIENTRY glGetClipPlane (GLenum plane, GLdouble *equation);\r\nGLAPI void GLAPIENTRY glGetDoublev (GLenum pname, GLdouble *params);\r\nGLAPI GLenum GLAPIENTRY glGetError (void);\r\nGLAPI void GLAPIENTRY glGetFloatv (GLenum pname, GLfloat *params);\r\nGLAPI void GLAPIENTRY glGetIntegerv (GLenum pname, GLint *params);\r\nGLAPI void GLAPIENTRY glGetLightfv (GLenum light, GLenum pname, GLfloat *params);\r\nGLAPI void GLAPIENTRY glGetLightiv (GLenum light, GLenum pname, GLint *params);\r\nGLAPI void GLAPIENTRY glGetMapdv (GLenum target, GLenum query, GLdouble *v);\r\nGLAPI void GLAPIENTRY glGetMapfv (GLenum target, GLenum query, GLfloat *v);\r\nGLAPI void GLAPIENTRY glGetMapiv (GLenum target, GLenum query, GLint *v);\r\nGLAPI void GLAPIENTRY glGetMaterialfv (GLenum face, GLenum pname, GLfloat *params);\r\nGLAPI void GLAPIENTRY glGetMaterialiv (GLenum face, GLenum pname, GLint *params);\r\nGLAPI void GLAPIENTRY glGetPixelMapfv (GLenum map, GLfloat *values);\r\nGLAPI void GLAPIENTRY glGetPixelMapuiv (GLenum map, GLuint *values);\r\nGLAPI void GLAPIENTRY glGetPixelMapusv (GLenum map, GLushort *values);\r\nGLAPI void GLAPIENTRY glGetPointerv (GLenum pname, void* *params);\r\nGLAPI void GLAPIENTRY glGetPolygonStipple (GLubyte *mask);\r\nGLAPI const GLubyte * GLAPIENTRY glGetString (GLenum name);\r\nGLAPI void GLAPIENTRY glGetTexEnvfv (GLenum target, GLenum pname, GLfloat *params);\r\nGLAPI void GLAPIENTRY glGetTexEnviv (GLenum target, GLenum pname, GLint *params);\r\nGLAPI void GLAPIENTRY glGetTexGendv (GLenum coord, GLenum pname, GLdouble *params);\r\nGLAPI void GLAPIENTRY glGetTexGenfv (GLenum coord, GLenum pname, GLfloat *params);\r\nGLAPI void GLAPIENTRY glGetTexGeniv (GLenum coord, GLenum pname, GLint *params);\r\nGLAPI void GLAPIENTRY glGetTexImage (GLenum target, GLint level, GLenum format, GLenum type, void *pixels);\r\nGLAPI void GLAPIENTRY glGetTexLevelParameterfv (GLenum target, GLint level, GLenum pname, GLfloat *params);\r\nGLAPI void GLAPIENTRY glGetTexLevelParameteriv (GLenum target, GLint level, GLenum pname, GLint *params);\r\nGLAPI void GLAPIENTRY glGetTexParameterfv (GLenum target, GLenum pname, GLfloat *params);\r\nGLAPI void GLAPIENTRY glGetTexParameteriv (GLenum target, GLenum pname, GLint *params);\r\nGLAPI void GLAPIENTRY glHint (GLenum target, GLenum mode);\r\nGLAPI void GLAPIENTRY glIndexMask (GLuint mask);\r\nGLAPI void GLAPIENTRY glIndexPointer (GLenum type, GLsizei stride, const void *pointer);\r\nGLAPI void GLAPIENTRY glIndexd (GLdouble c);\r\nGLAPI void GLAPIENTRY glIndexdv (const GLdouble *c);\r\nGLAPI void GLAPIENTRY glIndexf (GLfloat c);\r\nGLAPI void GLAPIENTRY glIndexfv (const GLfloat *c);\r\nGLAPI void GLAPIENTRY glIndexi (GLint c);\r\nGLAPI void GLAPIENTRY glIndexiv (const GLint *c);\r\nGLAPI void GLAPIENTRY glIndexs (GLshort c);\r\nGLAPI void GLAPIENTRY glIndexsv (const GLshort *c);\r\nGLAPI void GLAPIENTRY glIndexub (GLubyte c);\r\nGLAPI void GLAPIENTRY glIndexubv (const GLubyte *c);\r\nGLAPI void GLAPIENTRY glInitNames (void);\r\nGLAPI void GLAPIENTRY glInterleavedArrays (GLenum format, GLsizei stride, const void *pointer);\r\nGLAPI GLboolean GLAPIENTRY glIsEnabled (GLenum cap);\r\nGLAPI GLboolean GLAPIENTRY glIsList (GLuint list);\r\nGLAPI GLboolean GLAPIENTRY glIsTexture (GLuint texture);\r\nGLAPI void GLAPIENTRY glLightModelf (GLenum pname, GLfloat param);\r\nGLAPI void GLAPIENTRY glLightModelfv (GLenum pname, const GLfloat *params);\r\nGLAPI void GLAPIENTRY glLightModeli (GLenum pname, GLint param);\r\nGLAPI void GLAPIENTRY glLightModeliv (GLenum pname, const GLint *params);\r\nGLAPI void GLAPIENTRY glLightf (GLenum light, GLenum pname, GLfloat param);\r\nGLAPI void GLAPIENTRY glLightfv (GLenum light, GLenum pname, const GLfloat *params);\r\nGLAPI void GLAPIENTRY glLighti (GLenum light, GLenum pname, GLint param);\r\nGLAPI void GLAPIENTRY glLightiv (GLenum light, GLenum pname, const GLint *params);\r\nGLAPI void GLAPIENTRY glLineStipple (GLint factor, GLushort pattern);\r\nGLAPI void GLAPIENTRY glLineWidth (GLfloat width);\r\nGLAPI void GLAPIENTRY glListBase (GLuint base);\r\nGLAPI void GLAPIENTRY glLoadIdentity (void);\r\nGLAPI void GLAPIENTRY glLoadMatrixd (const GLdouble *m);\r\nGLAPI void GLAPIENTRY glLoadMatrixf (const GLfloat *m);\r\nGLAPI void GLAPIENTRY glLoadName (GLuint name);\r\nGLAPI void GLAPIENTRY glLogicOp (GLenum opcode);\r\nGLAPI void GLAPIENTRY glMap1d (GLenum target, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points);\r\nGLAPI void GLAPIENTRY glMap1f (GLenum target, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points);\r\nGLAPI void GLAPIENTRY glMap2d (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points);\r\nGLAPI void GLAPIENTRY glMap2f (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points);\r\nGLAPI void GLAPIENTRY glMapGrid1d (GLint un, GLdouble u1, GLdouble u2);\r\nGLAPI void GLAPIENTRY glMapGrid1f (GLint un, GLfloat u1, GLfloat u2);\r\nGLAPI void GLAPIENTRY glMapGrid2d (GLint un, GLdouble u1, GLdouble u2, GLint vn, GLdouble v1, GLdouble v2);\r\nGLAPI void GLAPIENTRY glMapGrid2f (GLint un, GLfloat u1, GLfloat u2, GLint vn, GLfloat v1, GLfloat v2);\r\nGLAPI void GLAPIENTRY glMaterialf (GLenum face, GLenum pname, GLfloat param);\r\nGLAPI void GLAPIENTRY glMaterialfv (GLenum face, GLenum pname, const GLfloat *params);\r\nGLAPI void GLAPIENTRY glMateriali (GLenum face, GLenum pname, GLint param);\r\nGLAPI void GLAPIENTRY glMaterialiv (GLenum face, GLenum pname, const GLint *params);\r\nGLAPI void GLAPIENTRY glMatrixMode (GLenum mode);\r\nGLAPI void GLAPIENTRY glMultMatrixd (const GLdouble *m);\r\nGLAPI void GLAPIENTRY glMultMatrixf (const GLfloat *m);\r\nGLAPI void GLAPIENTRY glNewList (GLuint list, GLenum mode);\r\nGLAPI void GLAPIENTRY glNormal3b (GLbyte nx, GLbyte ny, GLbyte nz);\r\nGLAPI void GLAPIENTRY glNormal3bv (const GLbyte *v);\r\nGLAPI void GLAPIENTRY glNormal3d (GLdouble nx, GLdouble ny, GLdouble nz);\r\nGLAPI void GLAPIENTRY glNormal3dv (const GLdouble *v);\r\nGLAPI void GLAPIENTRY glNormal3f (GLfloat nx, GLfloat ny, GLfloat nz);\r\nGLAPI void GLAPIENTRY glNormal3fv (const GLfloat *v);\r\nGLAPI void GLAPIENTRY glNormal3i (GLint nx, GLint ny, GLint nz);\r\nGLAPI void GLAPIENTRY glNormal3iv (const GLint *v);\r\nGLAPI void GLAPIENTRY glNormal3s (GLshort nx, GLshort ny, GLshort nz);\r\nGLAPI void GLAPIENTRY glNormal3sv (const GLshort *v);\r\nGLAPI void GLAPIENTRY glNormalPointer (GLenum type, GLsizei stride, const void *pointer);\r\nGLAPI void GLAPIENTRY glOrtho (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar);\r\nGLAPI void GLAPIENTRY glPassThrough (GLfloat token);\r\nGLAPI void GLAPIENTRY glPixelMapfv (GLenum map, GLsizei mapsize, const GLfloat *values);\r\nGLAPI void GLAPIENTRY glPixelMapuiv (GLenum map, GLsizei mapsize, const GLuint *values);\r\nGLAPI void GLAPIENTRY glPixelMapusv (GLenum map, GLsizei mapsize, const GLushort *values);\r\nGLAPI void GLAPIENTRY glPixelStoref (GLenum pname, GLfloat param);\r\nGLAPI void GLAPIENTRY glPixelStorei (GLenum pname, GLint param);\r\nGLAPI void GLAPIENTRY glPixelTransferf (GLenum pname, GLfloat param);\r\nGLAPI void GLAPIENTRY glPixelTransferi (GLenum pname, GLint param);\r\nGLAPI void GLAPIENTRY glPixelZoom (GLfloat xfactor, GLfloat yfactor);\r\nGLAPI void GLAPIENTRY glPointSize (GLfloat size);\r\nGLAPI void GLAPIENTRY glPolygonMode (GLenum face, GLenum mode);\r\nGLAPI void GLAPIENTRY glPolygonOffset (GLfloat factor, GLfloat units);\r\nGLAPI void GLAPIENTRY glPolygonStipple (const GLubyte *mask);\r\nGLAPI void GLAPIENTRY glPopAttrib (void);\r\nGLAPI void GLAPIENTRY glPopClientAttrib (void);\r\nGLAPI void GLAPIENTRY glPopMatrix (void);\r\nGLAPI void GLAPIENTRY glPopName (void);\r\nGLAPI void GLAPIENTRY glPrioritizeTextures (GLsizei n, const GLuint *textures, const GLclampf *priorities);\r\nGLAPI void GLAPIENTRY glPushAttrib (GLbitfield mask);\r\nGLAPI void GLAPIENTRY glPushClientAttrib (GLbitfield mask);\r\nGLAPI void GLAPIENTRY glPushMatrix (void);\r\nGLAPI void GLAPIENTRY glPushName (GLuint name);\r\nGLAPI void GLAPIENTRY glRasterPos2d (GLdouble x, GLdouble y);\r\nGLAPI void GLAPIENTRY glRasterPos2dv (const GLdouble *v);\r\nGLAPI void GLAPIENTRY glRasterPos2f (GLfloat x, GLfloat y);\r\nGLAPI void GLAPIENTRY glRasterPos2fv (const GLfloat *v);\r\nGLAPI void GLAPIENTRY glRasterPos2i (GLint x, GLint y);\r\nGLAPI void GLAPIENTRY glRasterPos2iv (const GLint *v);\r\nGLAPI void GLAPIENTRY glRasterPos2s (GLshort x, GLshort y);\r\nGLAPI void GLAPIENTRY glRasterPos2sv (const GLshort *v);\r\nGLAPI void GLAPIENTRY glRasterPos3d (GLdouble x, GLdouble y, GLdouble z);\r\nGLAPI void GLAPIENTRY glRasterPos3dv (const GLdouble *v);\r\nGLAPI void GLAPIENTRY glRasterPos3f (GLfloat x, GLfloat y, GLfloat z);\r\nGLAPI void GLAPIENTRY glRasterPos3fv (const GLfloat *v);\r\nGLAPI void GLAPIENTRY glRasterPos3i (GLint x, GLint y, GLint z);\r\nGLAPI void GLAPIENTRY glRasterPos3iv (const GLint *v);\r\nGLAPI void GLAPIENTRY glRasterPos3s (GLshort x, GLshort y, GLshort z);\r\nGLAPI void GLAPIENTRY glRasterPos3sv (const GLshort *v);\r\nGLAPI void GLAPIENTRY glRasterPos4d (GLdouble x, GLdouble y, GLdouble z, GLdouble w);\r\nGLAPI void GLAPIENTRY glRasterPos4dv (const GLdouble *v);\r\nGLAPI void GLAPIENTRY glRasterPos4f (GLfloat x, GLfloat y, GLfloat z, GLfloat w);\r\nGLAPI void GLAPIENTRY glRasterPos4fv (const GLfloat *v);\r\nGLAPI void GLAPIENTRY glRasterPos4i (GLint x, GLint y, GLint z, GLint w);\r\nGLAPI void GLAPIENTRY glRasterPos4iv (const GLint *v);\r\nGLAPI void GLAPIENTRY glRasterPos4s (GLshort x, GLshort y, GLshort z, GLshort w);\r\nGLAPI void GLAPIENTRY glRasterPos4sv (const GLshort *v);\r\nGLAPI void GLAPIENTRY glReadBuffer (GLenum mode);\r\nGLAPI void GLAPIENTRY glReadPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void *pixels);\r\nGLAPI void GLAPIENTRY glRectd (GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2);\r\nGLAPI void GLAPIENTRY glRectdv (const GLdouble *v1, const GLdouble *v2);\r\nGLAPI void GLAPIENTRY glRectf (GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2);\r\nGLAPI void GLAPIENTRY glRectfv (const GLfloat *v1, const GLfloat *v2);\r\nGLAPI void GLAPIENTRY glRecti (GLint x1, GLint y1, GLint x2, GLint y2);\r\nGLAPI void GLAPIENTRY glRectiv (const GLint *v1, const GLint *v2);\r\nGLAPI void GLAPIENTRY glRects (GLshort x1, GLshort y1, GLshort x2, GLshort y2);\r\nGLAPI void GLAPIENTRY glRectsv (const GLshort *v1, const GLshort *v2);\r\nGLAPI GLint GLAPIENTRY glRenderMode (GLenum mode);\r\nGLAPI void GLAPIENTRY glRotated (GLdouble angle, GLdouble x, GLdouble y, GLdouble z);\r\nGLAPI void GLAPIENTRY glRotatef (GLfloat angle, GLfloat x, GLfloat y, GLfloat z);\r\nGLAPI void GLAPIENTRY glScaled (GLdouble x, GLdouble y, GLdouble z);\r\nGLAPI void GLAPIENTRY glScalef (GLfloat x, GLfloat y, GLfloat z);\r\nGLAPI void GLAPIENTRY glScissor (GLint x, GLint y, GLsizei width, GLsizei height);\r\nGLAPI void GLAPIENTRY glSelectBuffer (GLsizei size, GLuint *buffer);\r\nGLAPI void GLAPIENTRY glShadeModel (GLenum mode);\r\nGLAPI void GLAPIENTRY glStencilFunc (GLenum func, GLint ref, GLuint mask);\r\nGLAPI void GLAPIENTRY glStencilMask (GLuint mask);\r\nGLAPI void GLAPIENTRY glStencilOp (GLenum fail, GLenum zfail, GLenum zpass);\r\nGLAPI void GLAPIENTRY glTexCoord1d (GLdouble s);\r\nGLAPI void GLAPIENTRY glTexCoord1dv (const GLdouble *v);\r\nGLAPI void GLAPIENTRY glTexCoord1f (GLfloat s);\r\nGLAPI void GLAPIENTRY glTexCoord1fv (const GLfloat *v);\r\nGLAPI void GLAPIENTRY glTexCoord1i (GLint s);\r\nGLAPI void GLAPIENTRY glTexCoord1iv (const GLint *v);\r\nGLAPI void GLAPIENTRY glTexCoord1s (GLshort s);\r\nGLAPI void GLAPIENTRY glTexCoord1sv (const GLshort *v);\r\nGLAPI void GLAPIENTRY glTexCoord2d (GLdouble s, GLdouble t);\r\nGLAPI void GLAPIENTRY glTexCoord2dv (const GLdouble *v);\r\nGLAPI void GLAPIENTRY glTexCoord2f (GLfloat s, GLfloat t);\r\nGLAPI void GLAPIENTRY glTexCoord2fv (const GLfloat *v);\r\nGLAPI void GLAPIENTRY glTexCoord2i (GLint s, GLint t);\r\nGLAPI void GLAPIENTRY glTexCoord2iv (const GLint *v);\r\nGLAPI void GLAPIENTRY glTexCoord2s (GLshort s, GLshort t);\r\nGLAPI void GLAPIENTRY glTexCoord2sv (const GLshort *v);\r\nGLAPI void GLAPIENTRY glTexCoord3d (GLdouble s, GLdouble t, GLdouble r);\r\nGLAPI void GLAPIENTRY glTexCoord3dv (const GLdouble *v);\r\nGLAPI void GLAPIENTRY glTexCoord3f (GLfloat s, GLfloat t, GLfloat r);\r\nGLAPI void GLAPIENTRY glTexCoord3fv (const GLfloat *v);\r\nGLAPI void GLAPIENTRY glTexCoord3i (GLint s, GLint t, GLint r);\r\nGLAPI void GLAPIENTRY glTexCoord3iv (const GLint *v);\r\nGLAPI void GLAPIENTRY glTexCoord3s (GLshort s, GLshort t, GLshort r);\r\nGLAPI void GLAPIENTRY glTexCoord3sv (const GLshort *v);\r\nGLAPI void GLAPIENTRY glTexCoord4d (GLdouble s, GLdouble t, GLdouble r, GLdouble q);\r\nGLAPI void GLAPIENTRY glTexCoord4dv (const GLdouble *v);\r\nGLAPI void GLAPIENTRY glTexCoord4f (GLfloat s, GLfloat t, GLfloat r, GLfloat q);\r\nGLAPI void GLAPIENTRY glTexCoord4fv (const GLfloat *v);\r\nGLAPI void GLAPIENTRY glTexCoord4i (GLint s, GLint t, GLint r, GLint q);\r\nGLAPI void GLAPIENTRY glTexCoord4iv (const GLint *v);\r\nGLAPI void GLAPIENTRY glTexCoord4s (GLshort s, GLshort t, GLshort r, GLshort q);\r\nGLAPI void GLAPIENTRY glTexCoord4sv (const GLshort *v);\r\nGLAPI void GLAPIENTRY glTexCoordPointer (GLint size, GLenum type, GLsizei stride, const void *pointer);\r\nGLAPI void GLAPIENTRY glTexEnvf (GLenum target, GLenum pname, GLfloat param);\r\nGLAPI void GLAPIENTRY glTexEnvfv (GLenum target, GLenum pname, const GLfloat *params);\r\nGLAPI void GLAPIENTRY glTexEnvi (GLenum target, GLenum pname, GLint param);\r\nGLAPI void GLAPIENTRY glTexEnviv (GLenum target, GLenum pname, const GLint *params);\r\nGLAPI void GLAPIENTRY glTexGend (GLenum coord, GLenum pname, GLdouble param);\r\nGLAPI void GLAPIENTRY glTexGendv (GLenum coord, GLenum pname, const GLdouble *params);\r\nGLAPI void GLAPIENTRY glTexGenf (GLenum coord, GLenum pname, GLfloat param);\r\nGLAPI void GLAPIENTRY glTexGenfv (GLenum coord, GLenum pname, const GLfloat *params);\r\nGLAPI void GLAPIENTRY glTexGeni (GLenum coord, GLenum pname, GLint param);\r\nGLAPI void GLAPIENTRY glTexGeniv (GLenum coord, GLenum pname, const GLint *params);\r\nGLAPI void GLAPIENTRY glTexImage1D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void *pixels);\r\nGLAPI void GLAPIENTRY glTexImage2D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels);\r\nGLAPI void GLAPIENTRY glTexParameterf (GLenum target, GLenum pname, GLfloat param);\r\nGLAPI void GLAPIENTRY glTexParameterfv (GLenum target, GLenum pname, const GLfloat *params);\r\nGLAPI void GLAPIENTRY glTexParameteri (GLenum target, GLenum pname, GLint param);\r\nGLAPI void GLAPIENTRY glTexParameteriv (GLenum target, GLenum pname, const GLint *params);\r\nGLAPI void GLAPIENTRY glTexSubImage1D (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels);\r\nGLAPI void GLAPIENTRY glTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels);\r\nGLAPI void GLAPIENTRY glTranslated (GLdouble x, GLdouble y, GLdouble z);\r\nGLAPI void GLAPIENTRY glTranslatef (GLfloat x, GLfloat y, GLfloat z);\r\nGLAPI void GLAPIENTRY glVertex2d (GLdouble x, GLdouble y);\r\nGLAPI void GLAPIENTRY glVertex2dv (const GLdouble *v);\r\nGLAPI void GLAPIENTRY glVertex2f (GLfloat x, GLfloat y);\r\nGLAPI void GLAPIENTRY glVertex2fv (const GLfloat *v);\r\nGLAPI void GLAPIENTRY glVertex2i (GLint x, GLint y);\r\nGLAPI void GLAPIENTRY glVertex2iv (const GLint *v);\r\nGLAPI void GLAPIENTRY glVertex2s (GLshort x, GLshort y);\r\nGLAPI void GLAPIENTRY glVertex2sv (const GLshort *v);\r\nGLAPI void GLAPIENTRY glVertex3d (GLdouble x, GLdouble y, GLdouble z);\r\nGLAPI void GLAPIENTRY glVertex3dv (const GLdouble *v);\r\nGLAPI void GLAPIENTRY glVertex3f (GLfloat x, GLfloat y, GLfloat z);\r\nGLAPI void GLAPIENTRY glVertex3fv (const GLfloat *v);\r\nGLAPI void GLAPIENTRY glVertex3i (GLint x, GLint y, GLint z);\r\nGLAPI void GLAPIENTRY glVertex3iv (const GLint *v);\r\nGLAPI void GLAPIENTRY glVertex3s (GLshort x, GLshort y, GLshort z);\r\nGLAPI void GLAPIENTRY glVertex3sv (const GLshort *v);\r\nGLAPI void GLAPIENTRY glVertex4d (GLdouble x, GLdouble y, GLdouble z, GLdouble w);\r\nGLAPI void GLAPIENTRY glVertex4dv (const GLdouble *v);\r\nGLAPI void GLAPIENTRY glVertex4f (GLfloat x, GLfloat y, GLfloat z, GLfloat w);\r\nGLAPI void GLAPIENTRY glVertex4fv (const GLfloat *v);\r\nGLAPI void GLAPIENTRY glVertex4i (GLint x, GLint y, GLint z, GLint w);\r\nGLAPI void GLAPIENTRY glVertex4iv (const GLint *v);\r\nGLAPI void GLAPIENTRY glVertex4s (GLshort x, GLshort y, GLshort z, GLshort w);\r\nGLAPI void GLAPIENTRY glVertex4sv (const GLshort *v);\r\nGLAPI void GLAPIENTRY glVertexPointer (GLint size, GLenum type, GLsizei stride, const void *pointer);\r\nGLAPI void GLAPIENTRY glViewport (GLint x, GLint y, GLsizei width, GLsizei height);\r\n\r\n#define GLEW_VERSION_1_1 GLEW_GET_VAR(__GLEW_VERSION_1_1)\r\n\r\n#endif /* GL_VERSION_1_1 */\r\n\r\n/* ---------------------------------- GLU ---------------------------------- */\r\n\r\n#ifndef GLEW_NO_GLU\r\n#  ifdef __APPLE__\r\n#    include <Availability.h>\r\n#    if defined(__IPHONE_OS_VERSION_MIN_REQUIRED)\r\n#      define GLEW_NO_GLU\r\n#    endif\r\n#  endif\r\n#endif\r\n\r\n#ifndef GLEW_NO_GLU\r\n/* this is where we can safely include GLU */\r\n#  if defined(__APPLE__) && defined(__MACH__)\r\n#    include <OpenGL/glu.h>\r\n#  else\r\n#    include <GL/glu.h>\r\n#  endif\r\n#endif\r\n\r\n/* ----------------------------- GL_VERSION_1_2 ---------------------------- */\r\n\r\n#ifndef GL_VERSION_1_2\r\n#define GL_VERSION_1_2 1\r\n\r\n#define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12\r\n#define GL_SMOOTH_POINT_SIZE_GRANULARITY 0x0B13\r\n#define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22\r\n#define GL_SMOOTH_LINE_WIDTH_GRANULARITY 0x0B23\r\n#define GL_UNSIGNED_BYTE_3_3_2 0x8032\r\n#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033\r\n#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034\r\n#define GL_UNSIGNED_INT_8_8_8_8 0x8035\r\n#define GL_UNSIGNED_INT_10_10_10_2 0x8036\r\n#define GL_RESCALE_NORMAL 0x803A\r\n#define GL_TEXTURE_BINDING_3D 0x806A\r\n#define GL_PACK_SKIP_IMAGES 0x806B\r\n#define GL_PACK_IMAGE_HEIGHT 0x806C\r\n#define GL_UNPACK_SKIP_IMAGES 0x806D\r\n#define GL_UNPACK_IMAGE_HEIGHT 0x806E\r\n#define GL_TEXTURE_3D 0x806F\r\n#define GL_PROXY_TEXTURE_3D 0x8070\r\n#define GL_TEXTURE_DEPTH 0x8071\r\n#define GL_TEXTURE_WRAP_R 0x8072\r\n#define GL_MAX_3D_TEXTURE_SIZE 0x8073\r\n#define GL_BGR 0x80E0\r\n#define GL_BGRA 0x80E1\r\n#define GL_MAX_ELEMENTS_VERTICES 0x80E8\r\n#define GL_MAX_ELEMENTS_INDICES 0x80E9\r\n#define GL_CLAMP_TO_EDGE 0x812F\r\n#define GL_TEXTURE_MIN_LOD 0x813A\r\n#define GL_TEXTURE_MAX_LOD 0x813B\r\n#define GL_TEXTURE_BASE_LEVEL 0x813C\r\n#define GL_TEXTURE_MAX_LEVEL 0x813D\r\n#define GL_LIGHT_MODEL_COLOR_CONTROL 0x81F8\r\n#define GL_SINGLE_COLOR 0x81F9\r\n#define GL_SEPARATE_SPECULAR_COLOR 0x81FA\r\n#define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362\r\n#define GL_UNSIGNED_SHORT_5_6_5 0x8363\r\n#define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364\r\n#define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365\r\n#define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366\r\n#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367\r\n#define GL_ALIASED_POINT_SIZE_RANGE 0x846D\r\n#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E\r\n\r\ntypedef void (GLAPIENTRY * PFNGLCOPYTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);\r\ntypedef void (GLAPIENTRY * PFNGLDRAWRANGEELEMENTSPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices);\r\ntypedef void (GLAPIENTRY * PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels);\r\ntypedef void (GLAPIENTRY * PFNGLTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels);\r\n\r\n#define glCopyTexSubImage3D GLEW_GET_FUN(__glewCopyTexSubImage3D)\r\n#define glDrawRangeElements GLEW_GET_FUN(__glewDrawRangeElements)\r\n#define glTexImage3D GLEW_GET_FUN(__glewTexImage3D)\r\n#define glTexSubImage3D GLEW_GET_FUN(__glewTexSubImage3D)\r\n\r\n#define GLEW_VERSION_1_2 GLEW_GET_VAR(__GLEW_VERSION_1_2)\r\n\r\n#endif /* GL_VERSION_1_2 */\r\n\r\n/* ---------------------------- GL_VERSION_1_2_1 --------------------------- */\r\n\r\n#ifndef GL_VERSION_1_2_1\r\n#define GL_VERSION_1_2_1 1\r\n\r\n#define GLEW_VERSION_1_2_1 GLEW_GET_VAR(__GLEW_VERSION_1_2_1)\r\n\r\n#endif /* GL_VERSION_1_2_1 */\r\n\r\n/* ----------------------------- GL_VERSION_1_3 ---------------------------- */\r\n\r\n#ifndef GL_VERSION_1_3\r\n#define GL_VERSION_1_3 1\r\n\r\n#define GL_MULTISAMPLE 0x809D\r\n#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E\r\n#define GL_SAMPLE_ALPHA_TO_ONE 0x809F\r\n#define GL_SAMPLE_COVERAGE 0x80A0\r\n#define GL_SAMPLE_BUFFERS 0x80A8\r\n#define GL_SAMPLES 0x80A9\r\n#define GL_SAMPLE_COVERAGE_VALUE 0x80AA\r\n#define GL_SAMPLE_COVERAGE_INVERT 0x80AB\r\n#define GL_CLAMP_TO_BORDER 0x812D\r\n#define GL_TEXTURE0 0x84C0\r\n#define GL_TEXTURE1 0x84C1\r\n#define GL_TEXTURE2 0x84C2\r\n#define GL_TEXTURE3 0x84C3\r\n#define GL_TEXTURE4 0x84C4\r\n#define GL_TEXTURE5 0x84C5\r\n#define GL_TEXTURE6 0x84C6\r\n#define GL_TEXTURE7 0x84C7\r\n#define GL_TEXTURE8 0x84C8\r\n#define GL_TEXTURE9 0x84C9\r\n#define GL_TEXTURE10 0x84CA\r\n#define GL_TEXTURE11 0x84CB\r\n#define GL_TEXTURE12 0x84CC\r\n#define GL_TEXTURE13 0x84CD\r\n#define GL_TEXTURE14 0x84CE\r\n#define GL_TEXTURE15 0x84CF\r\n#define GL_TEXTURE16 0x84D0\r\n#define GL_TEXTURE17 0x84D1\r\n#define GL_TEXTURE18 0x84D2\r\n#define GL_TEXTURE19 0x84D3\r\n#define GL_TEXTURE20 0x84D4\r\n#define GL_TEXTURE21 0x84D5\r\n#define GL_TEXTURE22 0x84D6\r\n#define GL_TEXTURE23 0x84D7\r\n#define GL_TEXTURE24 0x84D8\r\n#define GL_TEXTURE25 0x84D9\r\n#define GL_TEXTURE26 0x84DA\r\n#define GL_TEXTURE27 0x84DB\r\n#define GL_TEXTURE28 0x84DC\r\n#define GL_TEXTURE29 0x84DD\r\n#define GL_TEXTURE30 0x84DE\r\n#define GL_TEXTURE31 0x84DF\r\n#define GL_ACTIVE_TEXTURE 0x84E0\r\n#define GL_CLIENT_ACTIVE_TEXTURE 0x84E1\r\n#define GL_MAX_TEXTURE_UNITS 0x84E2\r\n#define GL_TRANSPOSE_MODELVIEW_MATRIX 0x84E3\r\n#define GL_TRANSPOSE_PROJECTION_MATRIX 0x84E4\r\n#define GL_TRANSPOSE_TEXTURE_MATRIX 0x84E5\r\n#define GL_TRANSPOSE_COLOR_MATRIX 0x84E6\r\n#define GL_SUBTRACT 0x84E7\r\n#define GL_COMPRESSED_ALPHA 0x84E9\r\n#define GL_COMPRESSED_LUMINANCE 0x84EA\r\n#define GL_COMPRESSED_LUMINANCE_ALPHA 0x84EB\r\n#define GL_COMPRESSED_INTENSITY 0x84EC\r\n#define GL_COMPRESSED_RGB 0x84ED\r\n#define GL_COMPRESSED_RGBA 0x84EE\r\n#define GL_TEXTURE_COMPRESSION_HINT 0x84EF\r\n#define GL_NORMAL_MAP 0x8511\r\n#define GL_REFLECTION_MAP 0x8512\r\n#define GL_TEXTURE_CUBE_MAP 0x8513\r\n#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514\r\n#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515\r\n#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516\r\n#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517\r\n#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518\r\n#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519\r\n#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A\r\n#define GL_PROXY_TEXTURE_CUBE_MAP 0x851B\r\n#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C\r\n#define GL_COMBINE 0x8570\r\n#define GL_COMBINE_RGB 0x8571\r\n#define GL_COMBINE_ALPHA 0x8572\r\n#define GL_RGB_SCALE 0x8573\r\n#define GL_ADD_SIGNED 0x8574\r\n#define GL_INTERPOLATE 0x8575\r\n#define GL_CONSTANT 0x8576\r\n#define GL_PRIMARY_COLOR 0x8577\r\n#define GL_PREVIOUS 0x8578\r\n#define GL_SOURCE0_RGB 0x8580\r\n#define GL_SOURCE1_RGB 0x8581\r\n#define GL_SOURCE2_RGB 0x8582\r\n#define GL_SOURCE0_ALPHA 0x8588\r\n#define GL_SOURCE1_ALPHA 0x8589\r\n#define GL_SOURCE2_ALPHA 0x858A\r\n#define GL_OPERAND0_RGB 0x8590\r\n#define GL_OPERAND1_RGB 0x8591\r\n#define GL_OPERAND2_RGB 0x8592\r\n#define GL_OPERAND0_ALPHA 0x8598\r\n#define GL_OPERAND1_ALPHA 0x8599\r\n#define GL_OPERAND2_ALPHA 0x859A\r\n#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE 0x86A0\r\n#define GL_TEXTURE_COMPRESSED 0x86A1\r\n#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2\r\n#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3\r\n#define GL_DOT3_RGB 0x86AE\r\n#define GL_DOT3_RGBA 0x86AF\r\n#define GL_MULTISAMPLE_BIT 0x20000000\r\n\r\ntypedef void (GLAPIENTRY * PFNGLACTIVETEXTUREPROC) (GLenum texture);\r\ntypedef void (GLAPIENTRY * PFNGLCLIENTACTIVETEXTUREPROC) (GLenum texture);\r\ntypedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *data);\r\ntypedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data);\r\ntypedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data);\r\ntypedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data);\r\ntypedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data);\r\ntypedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data);\r\ntypedef void (GLAPIENTRY * PFNGLGETCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint lod, void *img);\r\ntypedef void (GLAPIENTRY * PFNGLLOADTRANSPOSEMATRIXDPROC) (const GLdouble m[16]);\r\ntypedef void (GLAPIENTRY * PFNGLLOADTRANSPOSEMATRIXFPROC) (const GLfloat m[16]);\r\ntypedef void (GLAPIENTRY * PFNGLMULTTRANSPOSEMATRIXDPROC) (const GLdouble m[16]);\r\ntypedef void (GLAPIENTRY * PFNGLMULTTRANSPOSEMATRIXFPROC) (const GLfloat m[16]);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1DPROC) (GLenum target, GLdouble s);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1DVPROC) (GLenum target, const GLdouble *v);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1FPROC) (GLenum target, GLfloat s);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1FVPROC) (GLenum target, const GLfloat *v);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1IPROC) (GLenum target, GLint s);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1IVPROC) (GLenum target, const GLint *v);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1SPROC) (GLenum target, GLshort s);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1SVPROC) (GLenum target, const GLshort *v);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2DPROC) (GLenum target, GLdouble s, GLdouble t);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2DVPROC) (GLenum target, const GLdouble *v);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2FPROC) (GLenum target, GLfloat s, GLfloat t);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2FVPROC) (GLenum target, const GLfloat *v);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2IPROC) (GLenum target, GLint s, GLint t);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2IVPROC) (GLenum target, const GLint *v);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2SPROC) (GLenum target, GLshort s, GLshort t);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2SVPROC) (GLenum target, const GLshort *v);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3DVPROC) (GLenum target, const GLdouble *v);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3FVPROC) (GLenum target, const GLfloat *v);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3IPROC) (GLenum target, GLint s, GLint t, GLint r);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3IVPROC) (GLenum target, const GLint *v);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3SPROC) (GLenum target, GLshort s, GLshort t, GLshort r);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3SVPROC) (GLenum target, const GLshort *v);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4DVPROC) (GLenum target, const GLdouble *v);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4FVPROC) (GLenum target, const GLfloat *v);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4IPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4IVPROC) (GLenum target, const GLint *v);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4SPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4SVPROC) (GLenum target, const GLshort *v);\r\ntypedef void (GLAPIENTRY * PFNGLSAMPLECOVERAGEPROC) (GLclampf value, GLboolean invert);\r\n\r\n#define glActiveTexture GLEW_GET_FUN(__glewActiveTexture)\r\n#define glClientActiveTexture GLEW_GET_FUN(__glewClientActiveTexture)\r\n#define glCompressedTexImage1D GLEW_GET_FUN(__glewCompressedTexImage1D)\r\n#define glCompressedTexImage2D GLEW_GET_FUN(__glewCompressedTexImage2D)\r\n#define glCompressedTexImage3D GLEW_GET_FUN(__glewCompressedTexImage3D)\r\n#define glCompressedTexSubImage1D GLEW_GET_FUN(__glewCompressedTexSubImage1D)\r\n#define glCompressedTexSubImage2D GLEW_GET_FUN(__glewCompressedTexSubImage2D)\r\n#define glCompressedTexSubImage3D GLEW_GET_FUN(__glewCompressedTexSubImage3D)\r\n#define glGetCompressedTexImage GLEW_GET_FUN(__glewGetCompressedTexImage)\r\n#define glLoadTransposeMatrixd GLEW_GET_FUN(__glewLoadTransposeMatrixd)\r\n#define glLoadTransposeMatrixf GLEW_GET_FUN(__glewLoadTransposeMatrixf)\r\n#define glMultTransposeMatrixd GLEW_GET_FUN(__glewMultTransposeMatrixd)\r\n#define glMultTransposeMatrixf GLEW_GET_FUN(__glewMultTransposeMatrixf)\r\n#define glMultiTexCoord1d GLEW_GET_FUN(__glewMultiTexCoord1d)\r\n#define glMultiTexCoord1dv GLEW_GET_FUN(__glewMultiTexCoord1dv)\r\n#define glMultiTexCoord1f GLEW_GET_FUN(__glewMultiTexCoord1f)\r\n#define glMultiTexCoord1fv GLEW_GET_FUN(__glewMultiTexCoord1fv)\r\n#define glMultiTexCoord1i GLEW_GET_FUN(__glewMultiTexCoord1i)\r\n#define glMultiTexCoord1iv GLEW_GET_FUN(__glewMultiTexCoord1iv)\r\n#define glMultiTexCoord1s GLEW_GET_FUN(__glewMultiTexCoord1s)\r\n#define glMultiTexCoord1sv GLEW_GET_FUN(__glewMultiTexCoord1sv)\r\n#define glMultiTexCoord2d GLEW_GET_FUN(__glewMultiTexCoord2d)\r\n#define glMultiTexCoord2dv GLEW_GET_FUN(__glewMultiTexCoord2dv)\r\n#define glMultiTexCoord2f GLEW_GET_FUN(__glewMultiTexCoord2f)\r\n#define glMultiTexCoord2fv GLEW_GET_FUN(__glewMultiTexCoord2fv)\r\n#define glMultiTexCoord2i GLEW_GET_FUN(__glewMultiTexCoord2i)\r\n#define glMultiTexCoord2iv GLEW_GET_FUN(__glewMultiTexCoord2iv)\r\n#define glMultiTexCoord2s GLEW_GET_FUN(__glewMultiTexCoord2s)\r\n#define glMultiTexCoord2sv GLEW_GET_FUN(__glewMultiTexCoord2sv)\r\n#define glMultiTexCoord3d GLEW_GET_FUN(__glewMultiTexCoord3d)\r\n#define glMultiTexCoord3dv GLEW_GET_FUN(__glewMultiTexCoord3dv)\r\n#define glMultiTexCoord3f GLEW_GET_FUN(__glewMultiTexCoord3f)\r\n#define glMultiTexCoord3fv GLEW_GET_FUN(__glewMultiTexCoord3fv)\r\n#define glMultiTexCoord3i GLEW_GET_FUN(__glewMultiTexCoord3i)\r\n#define glMultiTexCoord3iv GLEW_GET_FUN(__glewMultiTexCoord3iv)\r\n#define glMultiTexCoord3s GLEW_GET_FUN(__glewMultiTexCoord3s)\r\n#define glMultiTexCoord3sv GLEW_GET_FUN(__glewMultiTexCoord3sv)\r\n#define glMultiTexCoord4d GLEW_GET_FUN(__glewMultiTexCoord4d)\r\n#define glMultiTexCoord4dv GLEW_GET_FUN(__glewMultiTexCoord4dv)\r\n#define glMultiTexCoord4f GLEW_GET_FUN(__glewMultiTexCoord4f)\r\n#define glMultiTexCoord4fv GLEW_GET_FUN(__glewMultiTexCoord4fv)\r\n#define glMultiTexCoord4i GLEW_GET_FUN(__glewMultiTexCoord4i)\r\n#define glMultiTexCoord4iv GLEW_GET_FUN(__glewMultiTexCoord4iv)\r\n#define glMultiTexCoord4s GLEW_GET_FUN(__glewMultiTexCoord4s)\r\n#define glMultiTexCoord4sv GLEW_GET_FUN(__glewMultiTexCoord4sv)\r\n#define glSampleCoverage GLEW_GET_FUN(__glewSampleCoverage)\r\n\r\n#define GLEW_VERSION_1_3 GLEW_GET_VAR(__GLEW_VERSION_1_3)\r\n\r\n#endif /* GL_VERSION_1_3 */\r\n\r\n/* ----------------------------- GL_VERSION_1_4 ---------------------------- */\r\n\r\n#ifndef GL_VERSION_1_4\r\n#define GL_VERSION_1_4 1\r\n\r\n#define GL_BLEND_DST_RGB 0x80C8\r\n#define GL_BLEND_SRC_RGB 0x80C9\r\n#define GL_BLEND_DST_ALPHA 0x80CA\r\n#define GL_BLEND_SRC_ALPHA 0x80CB\r\n#define GL_POINT_SIZE_MIN 0x8126\r\n#define GL_POINT_SIZE_MAX 0x8127\r\n#define GL_POINT_FADE_THRESHOLD_SIZE 0x8128\r\n#define GL_POINT_DISTANCE_ATTENUATION 0x8129\r\n#define GL_GENERATE_MIPMAP 0x8191\r\n#define GL_GENERATE_MIPMAP_HINT 0x8192\r\n#define GL_DEPTH_COMPONENT16 0x81A5\r\n#define GL_DEPTH_COMPONENT24 0x81A6\r\n#define GL_DEPTH_COMPONENT32 0x81A7\r\n#define GL_MIRRORED_REPEAT 0x8370\r\n#define GL_FOG_COORDINATE_SOURCE 0x8450\r\n#define GL_FOG_COORDINATE 0x8451\r\n#define GL_FRAGMENT_DEPTH 0x8452\r\n#define GL_CURRENT_FOG_COORDINATE 0x8453\r\n#define GL_FOG_COORDINATE_ARRAY_TYPE 0x8454\r\n#define GL_FOG_COORDINATE_ARRAY_STRIDE 0x8455\r\n#define GL_FOG_COORDINATE_ARRAY_POINTER 0x8456\r\n#define GL_FOG_COORDINATE_ARRAY 0x8457\r\n#define GL_COLOR_SUM 0x8458\r\n#define GL_CURRENT_SECONDARY_COLOR 0x8459\r\n#define GL_SECONDARY_COLOR_ARRAY_SIZE 0x845A\r\n#define GL_SECONDARY_COLOR_ARRAY_TYPE 0x845B\r\n#define GL_SECONDARY_COLOR_ARRAY_STRIDE 0x845C\r\n#define GL_SECONDARY_COLOR_ARRAY_POINTER 0x845D\r\n#define GL_SECONDARY_COLOR_ARRAY 0x845E\r\n#define GL_MAX_TEXTURE_LOD_BIAS 0x84FD\r\n#define GL_TEXTURE_FILTER_CONTROL 0x8500\r\n#define GL_TEXTURE_LOD_BIAS 0x8501\r\n#define GL_INCR_WRAP 0x8507\r\n#define GL_DECR_WRAP 0x8508\r\n#define GL_TEXTURE_DEPTH_SIZE 0x884A\r\n#define GL_DEPTH_TEXTURE_MODE 0x884B\r\n#define GL_TEXTURE_COMPARE_MODE 0x884C\r\n#define GL_TEXTURE_COMPARE_FUNC 0x884D\r\n#define GL_COMPARE_R_TO_TEXTURE 0x884E\r\n\r\ntypedef void (GLAPIENTRY * PFNGLBLENDCOLORPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);\r\ntypedef void (GLAPIENTRY * PFNGLBLENDEQUATIONPROC) (GLenum mode);\r\ntypedef void (GLAPIENTRY * PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha);\r\ntypedef void (GLAPIENTRY * PFNGLFOGCOORDPOINTERPROC) (GLenum type, GLsizei stride, const void *pointer);\r\ntypedef void (GLAPIENTRY * PFNGLFOGCOORDDPROC) (GLdouble coord);\r\ntypedef void (GLAPIENTRY * PFNGLFOGCOORDDVPROC) (const GLdouble *coord);\r\ntypedef void (GLAPIENTRY * PFNGLFOGCOORDFPROC) (GLfloat coord);\r\ntypedef void (GLAPIENTRY * PFNGLFOGCOORDFVPROC) (const GLfloat *coord);\r\ntypedef void (GLAPIENTRY * PFNGLMULTIDRAWARRAYSPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei drawcount);\r\ntypedef void (GLAPIENTRY * PFNGLMULTIDRAWELEMENTSPROC) (GLenum mode, const GLsizei *count, GLenum type, const void *const* indices, GLsizei drawcount);\r\ntypedef void (GLAPIENTRY * PFNGLPOINTPARAMETERFPROC) (GLenum pname, GLfloat param);\r\ntypedef void (GLAPIENTRY * PFNGLPOINTPARAMETERFVPROC) (GLenum pname, const GLfloat *params);\r\ntypedef void (GLAPIENTRY * PFNGLPOINTPARAMETERIPROC) (GLenum pname, GLint param);\r\ntypedef void (GLAPIENTRY * PFNGLPOINTPARAMETERIVPROC) (GLenum pname, const GLint *params);\r\ntypedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3BPROC) (GLbyte red, GLbyte green, GLbyte blue);\r\ntypedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3BVPROC) (const GLbyte *v);\r\ntypedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3DPROC) (GLdouble red, GLdouble green, GLdouble blue);\r\ntypedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3DVPROC) (const GLdouble *v);\r\ntypedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3FPROC) (GLfloat red, GLfloat green, GLfloat blue);\r\ntypedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3FVPROC) (const GLfloat *v);\r\ntypedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3IPROC) (GLint red, GLint green, GLint blue);\r\ntypedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3IVPROC) (const GLint *v);\r\ntypedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3SPROC) (GLshort red, GLshort green, GLshort blue);\r\ntypedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3SVPROC) (const GLshort *v);\r\ntypedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3UBPROC) (GLubyte red, GLubyte green, GLubyte blue);\r\ntypedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3UBVPROC) (const GLubyte *v);\r\ntypedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3UIPROC) (GLuint red, GLuint green, GLuint blue);\r\ntypedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3UIVPROC) (const GLuint *v);\r\ntypedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3USPROC) (GLushort red, GLushort green, GLushort blue);\r\ntypedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3USVPROC) (const GLushort *v);\r\ntypedef void (GLAPIENTRY * PFNGLSECONDARYCOLORPOINTERPROC) (GLint size, GLenum type, GLsizei stride, const void *pointer);\r\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS2DPROC) (GLdouble x, GLdouble y);\r\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS2DVPROC) (const GLdouble *p);\r\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS2FPROC) (GLfloat x, GLfloat y);\r\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS2FVPROC) (const GLfloat *p);\r\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS2IPROC) (GLint x, GLint y);\r\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS2IVPROC) (const GLint *p);\r\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS2SPROC) (GLshort x, GLshort y);\r\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS2SVPROC) (const GLshort *p);\r\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS3DPROC) (GLdouble x, GLdouble y, GLdouble z);\r\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS3DVPROC) (const GLdouble *p);\r\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS3FPROC) (GLfloat x, GLfloat y, GLfloat z);\r\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS3FVPROC) (const GLfloat *p);\r\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS3IPROC) (GLint x, GLint y, GLint z);\r\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS3IVPROC) (const GLint *p);\r\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS3SPROC) (GLshort x, GLshort y, GLshort z);\r\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS3SVPROC) (const GLshort *p);\r\n\r\n#define glBlendColor GLEW_GET_FUN(__glewBlendColor)\r\n#define glBlendEquation GLEW_GET_FUN(__glewBlendEquation)\r\n#define glBlendFuncSeparate GLEW_GET_FUN(__glewBlendFuncSeparate)\r\n#define glFogCoordPointer GLEW_GET_FUN(__glewFogCoordPointer)\r\n#define glFogCoordd GLEW_GET_FUN(__glewFogCoordd)\r\n#define glFogCoorddv GLEW_GET_FUN(__glewFogCoorddv)\r\n#define glFogCoordf GLEW_GET_FUN(__glewFogCoordf)\r\n#define glFogCoordfv GLEW_GET_FUN(__glewFogCoordfv)\r\n#define glMultiDrawArrays GLEW_GET_FUN(__glewMultiDrawArrays)\r\n#define glMultiDrawElements GLEW_GET_FUN(__glewMultiDrawElements)\r\n#define glPointParameterf GLEW_GET_FUN(__glewPointParameterf)\r\n#define glPointParameterfv GLEW_GET_FUN(__glewPointParameterfv)\r\n#define glPointParameteri GLEW_GET_FUN(__glewPointParameteri)\r\n#define glPointParameteriv GLEW_GET_FUN(__glewPointParameteriv)\r\n#define glSecondaryColor3b GLEW_GET_FUN(__glewSecondaryColor3b)\r\n#define glSecondaryColor3bv GLEW_GET_FUN(__glewSecondaryColor3bv)\r\n#define glSecondaryColor3d GLEW_GET_FUN(__glewSecondaryColor3d)\r\n#define glSecondaryColor3dv GLEW_GET_FUN(__glewSecondaryColor3dv)\r\n#define glSecondaryColor3f GLEW_GET_FUN(__glewSecondaryColor3f)\r\n#define glSecondaryColor3fv GLEW_GET_FUN(__glewSecondaryColor3fv)\r\n#define glSecondaryColor3i GLEW_GET_FUN(__glewSecondaryColor3i)\r\n#define glSecondaryColor3iv GLEW_GET_FUN(__glewSecondaryColor3iv)\r\n#define glSecondaryColor3s GLEW_GET_FUN(__glewSecondaryColor3s)\r\n#define glSecondaryColor3sv GLEW_GET_FUN(__glewSecondaryColor3sv)\r\n#define glSecondaryColor3ub GLEW_GET_FUN(__glewSecondaryColor3ub)\r\n#define glSecondaryColor3ubv GLEW_GET_FUN(__glewSecondaryColor3ubv)\r\n#define glSecondaryColor3ui GLEW_GET_FUN(__glewSecondaryColor3ui)\r\n#define glSecondaryColor3uiv GLEW_GET_FUN(__glewSecondaryColor3uiv)\r\n#define glSecondaryColor3us GLEW_GET_FUN(__glewSecondaryColor3us)\r\n#define glSecondaryColor3usv GLEW_GET_FUN(__glewSecondaryColor3usv)\r\n#define glSecondaryColorPointer GLEW_GET_FUN(__glewSecondaryColorPointer)\r\n#define glWindowPos2d GLEW_GET_FUN(__glewWindowPos2d)\r\n#define glWindowPos2dv GLEW_GET_FUN(__glewWindowPos2dv)\r\n#define glWindowPos2f GLEW_GET_FUN(__glewWindowPos2f)\r\n#define glWindowPos2fv GLEW_GET_FUN(__glewWindowPos2fv)\r\n#define glWindowPos2i GLEW_GET_FUN(__glewWindowPos2i)\r\n#define glWindowPos2iv GLEW_GET_FUN(__glewWindowPos2iv)\r\n#define glWindowPos2s GLEW_GET_FUN(__glewWindowPos2s)\r\n#define glWindowPos2sv GLEW_GET_FUN(__glewWindowPos2sv)\r\n#define glWindowPos3d GLEW_GET_FUN(__glewWindowPos3d)\r\n#define glWindowPos3dv GLEW_GET_FUN(__glewWindowPos3dv)\r\n#define glWindowPos3f GLEW_GET_FUN(__glewWindowPos3f)\r\n#define glWindowPos3fv GLEW_GET_FUN(__glewWindowPos3fv)\r\n#define glWindowPos3i GLEW_GET_FUN(__glewWindowPos3i)\r\n#define glWindowPos3iv GLEW_GET_FUN(__glewWindowPos3iv)\r\n#define glWindowPos3s GLEW_GET_FUN(__glewWindowPos3s)\r\n#define glWindowPos3sv GLEW_GET_FUN(__glewWindowPos3sv)\r\n\r\n#define GLEW_VERSION_1_4 GLEW_GET_VAR(__GLEW_VERSION_1_4)\r\n\r\n#endif /* GL_VERSION_1_4 */\r\n\r\n/* ----------------------------- GL_VERSION_1_5 ---------------------------- */\r\n\r\n#ifndef GL_VERSION_1_5\r\n#define GL_VERSION_1_5 1\r\n\r\n#define GL_CURRENT_FOG_COORD GL_CURRENT_FOG_COORDINATE\r\n#define GL_FOG_COORD GL_FOG_COORDINATE\r\n#define GL_FOG_COORD_ARRAY GL_FOG_COORDINATE_ARRAY\r\n#define GL_FOG_COORD_ARRAY_BUFFER_BINDING GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING\r\n#define GL_FOG_COORD_ARRAY_POINTER GL_FOG_COORDINATE_ARRAY_POINTER\r\n#define GL_FOG_COORD_ARRAY_STRIDE GL_FOG_COORDINATE_ARRAY_STRIDE\r\n#define GL_FOG_COORD_ARRAY_TYPE GL_FOG_COORDINATE_ARRAY_TYPE\r\n#define GL_FOG_COORD_SRC GL_FOG_COORDINATE_SOURCE\r\n#define GL_SRC0_ALPHA GL_SOURCE0_ALPHA\r\n#define GL_SRC0_RGB GL_SOURCE0_RGB\r\n#define GL_SRC1_ALPHA GL_SOURCE1_ALPHA\r\n#define GL_SRC1_RGB GL_SOURCE1_RGB\r\n#define GL_SRC2_ALPHA GL_SOURCE2_ALPHA\r\n#define GL_SRC2_RGB GL_SOURCE2_RGB\r\n#define GL_BUFFER_SIZE 0x8764\r\n#define GL_BUFFER_USAGE 0x8765\r\n#define GL_QUERY_COUNTER_BITS 0x8864\r\n#define GL_CURRENT_QUERY 0x8865\r\n#define GL_QUERY_RESULT 0x8866\r\n#define GL_QUERY_RESULT_AVAILABLE 0x8867\r\n#define GL_ARRAY_BUFFER 0x8892\r\n#define GL_ELEMENT_ARRAY_BUFFER 0x8893\r\n#define GL_ARRAY_BUFFER_BINDING 0x8894\r\n#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895\r\n#define GL_VERTEX_ARRAY_BUFFER_BINDING 0x8896\r\n#define GL_NORMAL_ARRAY_BUFFER_BINDING 0x8897\r\n#define GL_COLOR_ARRAY_BUFFER_BINDING 0x8898\r\n#define GL_INDEX_ARRAY_BUFFER_BINDING 0x8899\r\n#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING 0x889A\r\n#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING 0x889B\r\n#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING 0x889C\r\n#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING 0x889D\r\n#define GL_WEIGHT_ARRAY_BUFFER_BINDING 0x889E\r\n#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F\r\n#define GL_READ_ONLY 0x88B8\r\n#define GL_WRITE_ONLY 0x88B9\r\n#define GL_READ_WRITE 0x88BA\r\n#define GL_BUFFER_ACCESS 0x88BB\r\n#define GL_BUFFER_MAPPED 0x88BC\r\n#define GL_BUFFER_MAP_POINTER 0x88BD\r\n#define GL_STREAM_DRAW 0x88E0\r\n#define GL_STREAM_READ 0x88E1\r\n#define GL_STREAM_COPY 0x88E2\r\n#define GL_STATIC_DRAW 0x88E4\r\n#define GL_STATIC_READ 0x88E5\r\n#define GL_STATIC_COPY 0x88E6\r\n#define GL_DYNAMIC_DRAW 0x88E8\r\n#define GL_DYNAMIC_READ 0x88E9\r\n#define GL_DYNAMIC_COPY 0x88EA\r\n#define GL_SAMPLES_PASSED 0x8914\r\n\r\ntypedef ptrdiff_t GLintptr;\r\ntypedef ptrdiff_t GLsizeiptr;\r\n\r\ntypedef void (GLAPIENTRY * PFNGLBEGINQUERYPROC) (GLenum target, GLuint id);\r\ntypedef void (GLAPIENTRY * PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer);\r\ntypedef void (GLAPIENTRY * PFNGLBUFFERDATAPROC) (GLenum target, GLsizeiptr size, const void* data, GLenum usage);\r\ntypedef void (GLAPIENTRY * PFNGLBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, const void* data);\r\ntypedef void (GLAPIENTRY * PFNGLDELETEBUFFERSPROC) (GLsizei n, const GLuint* buffers);\r\ntypedef void (GLAPIENTRY * PFNGLDELETEQUERIESPROC) (GLsizei n, const GLuint* ids);\r\ntypedef void (GLAPIENTRY * PFNGLENDQUERYPROC) (GLenum target);\r\ntypedef void (GLAPIENTRY * PFNGLGENBUFFERSPROC) (GLsizei n, GLuint* buffers);\r\ntypedef void (GLAPIENTRY * PFNGLGENQUERIESPROC) (GLsizei n, GLuint* ids);\r\ntypedef void (GLAPIENTRY * PFNGLGETBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETBUFFERPOINTERVPROC) (GLenum target, GLenum pname, void** params);\r\ntypedef void (GLAPIENTRY * PFNGLGETBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, void* data);\r\ntypedef void (GLAPIENTRY * PFNGLGETQUERYOBJECTIVPROC) (GLuint id, GLenum pname, GLint* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETQUERYOBJECTUIVPROC) (GLuint id, GLenum pname, GLuint* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETQUERYIVPROC) (GLenum target, GLenum pname, GLint* params);\r\ntypedef GLboolean (GLAPIENTRY * PFNGLISBUFFERPROC) (GLuint buffer);\r\ntypedef GLboolean (GLAPIENTRY * PFNGLISQUERYPROC) (GLuint id);\r\ntypedef void* (GLAPIENTRY * PFNGLMAPBUFFERPROC) (GLenum target, GLenum access);\r\ntypedef GLboolean (GLAPIENTRY * PFNGLUNMAPBUFFERPROC) (GLenum target);\r\n\r\n#define glBeginQuery GLEW_GET_FUN(__glewBeginQuery)\r\n#define glBindBuffer GLEW_GET_FUN(__glewBindBuffer)\r\n#define glBufferData GLEW_GET_FUN(__glewBufferData)\r\n#define glBufferSubData GLEW_GET_FUN(__glewBufferSubData)\r\n#define glDeleteBuffers GLEW_GET_FUN(__glewDeleteBuffers)\r\n#define glDeleteQueries GLEW_GET_FUN(__glewDeleteQueries)\r\n#define glEndQuery GLEW_GET_FUN(__glewEndQuery)\r\n#define glGenBuffers GLEW_GET_FUN(__glewGenBuffers)\r\n#define glGenQueries GLEW_GET_FUN(__glewGenQueries)\r\n#define glGetBufferParameteriv GLEW_GET_FUN(__glewGetBufferParameteriv)\r\n#define glGetBufferPointerv GLEW_GET_FUN(__glewGetBufferPointerv)\r\n#define glGetBufferSubData GLEW_GET_FUN(__glewGetBufferSubData)\r\n#define glGetQueryObjectiv GLEW_GET_FUN(__glewGetQueryObjectiv)\r\n#define glGetQueryObjectuiv GLEW_GET_FUN(__glewGetQueryObjectuiv)\r\n#define glGetQueryiv GLEW_GET_FUN(__glewGetQueryiv)\r\n#define glIsBuffer GLEW_GET_FUN(__glewIsBuffer)\r\n#define glIsQuery GLEW_GET_FUN(__glewIsQuery)\r\n#define glMapBuffer GLEW_GET_FUN(__glewMapBuffer)\r\n#define glUnmapBuffer GLEW_GET_FUN(__glewUnmapBuffer)\r\n\r\n#define GLEW_VERSION_1_5 GLEW_GET_VAR(__GLEW_VERSION_1_5)\r\n\r\n#endif /* GL_VERSION_1_5 */\r\n\r\n/* ----------------------------- GL_VERSION_2_0 ---------------------------- */\r\n\r\n#ifndef GL_VERSION_2_0\r\n#define GL_VERSION_2_0 1\r\n\r\n#define GL_BLEND_EQUATION_RGB GL_BLEND_EQUATION\r\n#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622\r\n#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623\r\n#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624\r\n#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625\r\n#define GL_CURRENT_VERTEX_ATTRIB 0x8626\r\n#define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642\r\n#define GL_VERTEX_PROGRAM_TWO_SIDE 0x8643\r\n#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645\r\n#define GL_STENCIL_BACK_FUNC 0x8800\r\n#define GL_STENCIL_BACK_FAIL 0x8801\r\n#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802\r\n#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803\r\n#define GL_MAX_DRAW_BUFFERS 0x8824\r\n#define GL_DRAW_BUFFER0 0x8825\r\n#define GL_DRAW_BUFFER1 0x8826\r\n#define GL_DRAW_BUFFER2 0x8827\r\n#define GL_DRAW_BUFFER3 0x8828\r\n#define GL_DRAW_BUFFER4 0x8829\r\n#define GL_DRAW_BUFFER5 0x882A\r\n#define GL_DRAW_BUFFER6 0x882B\r\n#define GL_DRAW_BUFFER7 0x882C\r\n#define GL_DRAW_BUFFER8 0x882D\r\n#define GL_DRAW_BUFFER9 0x882E\r\n#define GL_DRAW_BUFFER10 0x882F\r\n#define GL_DRAW_BUFFER11 0x8830\r\n#define GL_DRAW_BUFFER12 0x8831\r\n#define GL_DRAW_BUFFER13 0x8832\r\n#define GL_DRAW_BUFFER14 0x8833\r\n#define GL_DRAW_BUFFER15 0x8834\r\n#define GL_BLEND_EQUATION_ALPHA 0x883D\r\n#define GL_POINT_SPRITE 0x8861\r\n#define GL_COORD_REPLACE 0x8862\r\n#define GL_MAX_VERTEX_ATTRIBS 0x8869\r\n#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A\r\n#define GL_MAX_TEXTURE_COORDS 0x8871\r\n#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872\r\n#define GL_FRAGMENT_SHADER 0x8B30\r\n#define GL_VERTEX_SHADER 0x8B31\r\n#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49\r\n#define GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8B4A\r\n#define GL_MAX_VARYING_FLOATS 0x8B4B\r\n#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C\r\n#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D\r\n#define GL_SHADER_TYPE 0x8B4F\r\n#define GL_FLOAT_VEC2 0x8B50\r\n#define GL_FLOAT_VEC3 0x8B51\r\n#define GL_FLOAT_VEC4 0x8B52\r\n#define GL_INT_VEC2 0x8B53\r\n#define GL_INT_VEC3 0x8B54\r\n#define GL_INT_VEC4 0x8B55\r\n#define GL_BOOL 0x8B56\r\n#define GL_BOOL_VEC2 0x8B57\r\n#define GL_BOOL_VEC3 0x8B58\r\n#define GL_BOOL_VEC4 0x8B59\r\n#define GL_FLOAT_MAT2 0x8B5A\r\n#define GL_FLOAT_MAT3 0x8B5B\r\n#define GL_FLOAT_MAT4 0x8B5C\r\n#define GL_SAMPLER_1D 0x8B5D\r\n#define GL_SAMPLER_2D 0x8B5E\r\n#define GL_SAMPLER_3D 0x8B5F\r\n#define GL_SAMPLER_CUBE 0x8B60\r\n#define GL_SAMPLER_1D_SHADOW 0x8B61\r\n#define GL_SAMPLER_2D_SHADOW 0x8B62\r\n#define GL_DELETE_STATUS 0x8B80\r\n#define GL_COMPILE_STATUS 0x8B81\r\n#define GL_LINK_STATUS 0x8B82\r\n#define GL_VALIDATE_STATUS 0x8B83\r\n#define GL_INFO_LOG_LENGTH 0x8B84\r\n#define GL_ATTACHED_SHADERS 0x8B85\r\n#define GL_ACTIVE_UNIFORMS 0x8B86\r\n#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87\r\n#define GL_SHADER_SOURCE_LENGTH 0x8B88\r\n#define GL_ACTIVE_ATTRIBUTES 0x8B89\r\n#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A\r\n#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT 0x8B8B\r\n#define GL_SHADING_LANGUAGE_VERSION 0x8B8C\r\n#define GL_CURRENT_PROGRAM 0x8B8D\r\n#define GL_POINT_SPRITE_COORD_ORIGIN 0x8CA0\r\n#define GL_LOWER_LEFT 0x8CA1\r\n#define GL_UPPER_LEFT 0x8CA2\r\n#define GL_STENCIL_BACK_REF 0x8CA3\r\n#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4\r\n#define GL_STENCIL_BACK_WRITEMASK 0x8CA5\r\n\r\ntypedef void (GLAPIENTRY * PFNGLATTACHSHADERPROC) (GLuint program, GLuint shader);\r\ntypedef void (GLAPIENTRY * PFNGLBINDATTRIBLOCATIONPROC) (GLuint program, GLuint index, const GLchar* name);\r\ntypedef void (GLAPIENTRY * PFNGLBLENDEQUATIONSEPARATEPROC) (GLenum modeRGB, GLenum modeAlpha);\r\ntypedef void (GLAPIENTRY * PFNGLCOMPILESHADERPROC) (GLuint shader);\r\ntypedef GLuint (GLAPIENTRY * PFNGLCREATEPROGRAMPROC) (void);\r\ntypedef GLuint (GLAPIENTRY * PFNGLCREATESHADERPROC) (GLenum type);\r\ntypedef void (GLAPIENTRY * PFNGLDELETEPROGRAMPROC) (GLuint program);\r\ntypedef void (GLAPIENTRY * PFNGLDELETESHADERPROC) (GLuint shader);\r\ntypedef void (GLAPIENTRY * PFNGLDETACHSHADERPROC) (GLuint program, GLuint shader);\r\ntypedef void (GLAPIENTRY * PFNGLDISABLEVERTEXATTRIBARRAYPROC) (GLuint index);\r\ntypedef void (GLAPIENTRY * PFNGLDRAWBUFFERSPROC) (GLsizei n, const GLenum* bufs);\r\ntypedef void (GLAPIENTRY * PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint index);\r\ntypedef void (GLAPIENTRY * PFNGLGETACTIVEATTRIBPROC) (GLuint program, GLuint index, GLsizei maxLength, GLsizei* length, GLint* size, GLenum* type, GLchar* name);\r\ntypedef void (GLAPIENTRY * PFNGLGETACTIVEUNIFORMPROC) (GLuint program, GLuint index, GLsizei maxLength, GLsizei* length, GLint* size, GLenum* type, GLchar* name);\r\ntypedef void (GLAPIENTRY * PFNGLGETATTACHEDSHADERSPROC) (GLuint program, GLsizei maxCount, GLsizei* count, GLuint* shaders);\r\ntypedef GLint (GLAPIENTRY * PFNGLGETATTRIBLOCATIONPROC) (GLuint program, const GLchar* name);\r\ntypedef void (GLAPIENTRY * PFNGLGETPROGRAMINFOLOGPROC) (GLuint program, GLsizei bufSize, GLsizei* length, GLchar* infoLog);\r\ntypedef void (GLAPIENTRY * PFNGLGETPROGRAMIVPROC) (GLuint program, GLenum pname, GLint* param);\r\ntypedef void (GLAPIENTRY * PFNGLGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei* length, GLchar* infoLog);\r\ntypedef void (GLAPIENTRY * PFNGLGETSHADERSOURCEPROC) (GLuint obj, GLsizei maxLength, GLsizei* length, GLchar* source);\r\ntypedef void (GLAPIENTRY * PFNGLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint* param);\r\ntypedef GLint (GLAPIENTRY * PFNGLGETUNIFORMLOCATIONPROC) (GLuint program, const GLchar* name);\r\ntypedef void (GLAPIENTRY * PFNGLGETUNIFORMFVPROC) (GLuint program, GLint location, GLfloat* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETUNIFORMIVPROC) (GLuint program, GLint location, GLint* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBPOINTERVPROC) (GLuint index, GLenum pname, void** pointer);\r\ntypedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBDVPROC) (GLuint index, GLenum pname, GLdouble* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBFVPROC) (GLuint index, GLenum pname, GLfloat* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBIVPROC) (GLuint index, GLenum pname, GLint* params);\r\ntypedef GLboolean (GLAPIENTRY * PFNGLISPROGRAMPROC) (GLuint program);\r\ntypedef GLboolean (GLAPIENTRY * PFNGLISSHADERPROC) (GLuint shader);\r\ntypedef void (GLAPIENTRY * PFNGLLINKPROGRAMPROC) (GLuint program);\r\ntypedef void (GLAPIENTRY * PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count, const GLchar *const* string, const GLint* length);\r\ntypedef void (GLAPIENTRY * PFNGLSTENCILFUNCSEPARATEPROC) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask);\r\ntypedef void (GLAPIENTRY * PFNGLSTENCILMASKSEPARATEPROC) (GLenum face, GLuint mask);\r\ntypedef void (GLAPIENTRY * PFNGLSTENCILOPSEPARATEPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORM1FPROC) (GLint location, GLfloat v0);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORM1FVPROC) (GLint location, GLsizei count, const GLfloat* value);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORM1IPROC) (GLint location, GLint v0);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORM1IVPROC) (GLint location, GLsizei count, const GLint* value);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORM2FPROC) (GLint location, GLfloat v0, GLfloat v1);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORM2FVPROC) (GLint location, GLsizei count, const GLfloat* value);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORM2IPROC) (GLint location, GLint v0, GLint v1);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORM2IVPROC) (GLint location, GLsizei count, const GLint* value);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORM3FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORM3FVPROC) (GLint location, GLsizei count, const GLfloat* value);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORM3IPROC) (GLint location, GLint v0, GLint v1, GLint v2);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORM3IVPROC) (GLint location, GLsizei count, const GLint* value);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORM4FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORM4FVPROC) (GLint location, GLsizei count, const GLfloat* value);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORM4IPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORM4IVPROC) (GLint location, GLsizei count, const GLint* value);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);\r\ntypedef void (GLAPIENTRY * PFNGLUSEPROGRAMPROC) (GLuint program);\r\ntypedef void (GLAPIENTRY * PFNGLVALIDATEPROGRAMPROC) (GLuint program);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1DPROC) (GLuint index, GLdouble x);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1DVPROC) (GLuint index, const GLdouble* v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1FPROC) (GLuint index, GLfloat x);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1FVPROC) (GLuint index, const GLfloat* v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1SPROC) (GLuint index, GLshort x);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1SVPROC) (GLuint index, const GLshort* v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2DPROC) (GLuint index, GLdouble x, GLdouble y);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2DVPROC) (GLuint index, const GLdouble* v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2FPROC) (GLuint index, GLfloat x, GLfloat y);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2FVPROC) (GLuint index, const GLfloat* v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2SPROC) (GLuint index, GLshort x, GLshort y);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2SVPROC) (GLuint index, const GLshort* v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3DVPROC) (GLuint index, const GLdouble* v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3FVPROC) (GLuint index, const GLfloat* v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3SPROC) (GLuint index, GLshort x, GLshort y, GLshort z);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3SVPROC) (GLuint index, const GLshort* v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NBVPROC) (GLuint index, const GLbyte* v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NIVPROC) (GLuint index, const GLint* v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NSVPROC) (GLuint index, const GLshort* v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NUBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NUBVPROC) (GLuint index, const GLubyte* v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NUIVPROC) (GLuint index, const GLuint* v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NUSVPROC) (GLuint index, const GLushort* v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4BVPROC) (GLuint index, const GLbyte* v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4DVPROC) (GLuint index, const GLdouble* v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4FVPROC) (GLuint index, const GLfloat* v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4IVPROC) (GLuint index, const GLint* v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4SPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4SVPROC) (GLuint index, const GLshort* v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4UBVPROC) (GLuint index, const GLubyte* v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4UIVPROC) (GLuint index, const GLuint* v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4USVPROC) (GLuint index, const GLushort* v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* pointer);\r\n\r\n#define glAttachShader GLEW_GET_FUN(__glewAttachShader)\r\n#define glBindAttribLocation GLEW_GET_FUN(__glewBindAttribLocation)\r\n#define glBlendEquationSeparate GLEW_GET_FUN(__glewBlendEquationSeparate)\r\n#define glCompileShader GLEW_GET_FUN(__glewCompileShader)\r\n#define glCreateProgram GLEW_GET_FUN(__glewCreateProgram)\r\n#define glCreateShader GLEW_GET_FUN(__glewCreateShader)\r\n#define glDeleteProgram GLEW_GET_FUN(__glewDeleteProgram)\r\n#define glDeleteShader GLEW_GET_FUN(__glewDeleteShader)\r\n#define glDetachShader GLEW_GET_FUN(__glewDetachShader)\r\n#define glDisableVertexAttribArray GLEW_GET_FUN(__glewDisableVertexAttribArray)\r\n#define glDrawBuffers GLEW_GET_FUN(__glewDrawBuffers)\r\n#define glEnableVertexAttribArray GLEW_GET_FUN(__glewEnableVertexAttribArray)\r\n#define glGetActiveAttrib GLEW_GET_FUN(__glewGetActiveAttrib)\r\n#define glGetActiveUniform GLEW_GET_FUN(__glewGetActiveUniform)\r\n#define glGetAttachedShaders GLEW_GET_FUN(__glewGetAttachedShaders)\r\n#define glGetAttribLocation GLEW_GET_FUN(__glewGetAttribLocation)\r\n#define glGetProgramInfoLog GLEW_GET_FUN(__glewGetProgramInfoLog)\r\n#define glGetProgramiv GLEW_GET_FUN(__glewGetProgramiv)\r\n#define glGetShaderInfoLog GLEW_GET_FUN(__glewGetShaderInfoLog)\r\n#define glGetShaderSource GLEW_GET_FUN(__glewGetShaderSource)\r\n#define glGetShaderiv GLEW_GET_FUN(__glewGetShaderiv)\r\n#define glGetUniformLocation GLEW_GET_FUN(__glewGetUniformLocation)\r\n#define glGetUniformfv GLEW_GET_FUN(__glewGetUniformfv)\r\n#define glGetUniformiv GLEW_GET_FUN(__glewGetUniformiv)\r\n#define glGetVertexAttribPointerv GLEW_GET_FUN(__glewGetVertexAttribPointerv)\r\n#define glGetVertexAttribdv GLEW_GET_FUN(__glewGetVertexAttribdv)\r\n#define glGetVertexAttribfv GLEW_GET_FUN(__glewGetVertexAttribfv)\r\n#define glGetVertexAttribiv GLEW_GET_FUN(__glewGetVertexAttribiv)\r\n#define glIsProgram GLEW_GET_FUN(__glewIsProgram)\r\n#define glIsShader GLEW_GET_FUN(__glewIsShader)\r\n#define glLinkProgram GLEW_GET_FUN(__glewLinkProgram)\r\n#define glShaderSource GLEW_GET_FUN(__glewShaderSource)\r\n#define glStencilFuncSeparate GLEW_GET_FUN(__glewStencilFuncSeparate)\r\n#define glStencilMaskSeparate GLEW_GET_FUN(__glewStencilMaskSeparate)\r\n#define glStencilOpSeparate GLEW_GET_FUN(__glewStencilOpSeparate)\r\n#define glUniform1f GLEW_GET_FUN(__glewUniform1f)\r\n#define glUniform1fv GLEW_GET_FUN(__glewUniform1fv)\r\n#define glUniform1i GLEW_GET_FUN(__glewUniform1i)\r\n#define glUniform1iv GLEW_GET_FUN(__glewUniform1iv)\r\n#define glUniform2f GLEW_GET_FUN(__glewUniform2f)\r\n#define glUniform2fv GLEW_GET_FUN(__glewUniform2fv)\r\n#define glUniform2i GLEW_GET_FUN(__glewUniform2i)\r\n#define glUniform2iv GLEW_GET_FUN(__glewUniform2iv)\r\n#define glUniform3f GLEW_GET_FUN(__glewUniform3f)\r\n#define glUniform3fv GLEW_GET_FUN(__glewUniform3fv)\r\n#define glUniform3i GLEW_GET_FUN(__glewUniform3i)\r\n#define glUniform3iv GLEW_GET_FUN(__glewUniform3iv)\r\n#define glUniform4f GLEW_GET_FUN(__glewUniform4f)\r\n#define glUniform4fv GLEW_GET_FUN(__glewUniform4fv)\r\n#define glUniform4i GLEW_GET_FUN(__glewUniform4i)\r\n#define glUniform4iv GLEW_GET_FUN(__glewUniform4iv)\r\n#define glUniformMatrix2fv GLEW_GET_FUN(__glewUniformMatrix2fv)\r\n#define glUniformMatrix3fv GLEW_GET_FUN(__glewUniformMatrix3fv)\r\n#define glUniformMatrix4fv GLEW_GET_FUN(__glewUniformMatrix4fv)\r\n#define glUseProgram GLEW_GET_FUN(__glewUseProgram)\r\n#define glValidateProgram GLEW_GET_FUN(__glewValidateProgram)\r\n#define glVertexAttrib1d GLEW_GET_FUN(__glewVertexAttrib1d)\r\n#define glVertexAttrib1dv GLEW_GET_FUN(__glewVertexAttrib1dv)\r\n#define glVertexAttrib1f GLEW_GET_FUN(__glewVertexAttrib1f)\r\n#define glVertexAttrib1fv GLEW_GET_FUN(__glewVertexAttrib1fv)\r\n#define glVertexAttrib1s GLEW_GET_FUN(__glewVertexAttrib1s)\r\n#define glVertexAttrib1sv GLEW_GET_FUN(__glewVertexAttrib1sv)\r\n#define glVertexAttrib2d GLEW_GET_FUN(__glewVertexAttrib2d)\r\n#define glVertexAttrib2dv GLEW_GET_FUN(__glewVertexAttrib2dv)\r\n#define glVertexAttrib2f GLEW_GET_FUN(__glewVertexAttrib2f)\r\n#define glVertexAttrib2fv GLEW_GET_FUN(__glewVertexAttrib2fv)\r\n#define glVertexAttrib2s GLEW_GET_FUN(__glewVertexAttrib2s)\r\n#define glVertexAttrib2sv GLEW_GET_FUN(__glewVertexAttrib2sv)\r\n#define glVertexAttrib3d GLEW_GET_FUN(__glewVertexAttrib3d)\r\n#define glVertexAttrib3dv GLEW_GET_FUN(__glewVertexAttrib3dv)\r\n#define glVertexAttrib3f GLEW_GET_FUN(__glewVertexAttrib3f)\r\n#define glVertexAttrib3fv GLEW_GET_FUN(__glewVertexAttrib3fv)\r\n#define glVertexAttrib3s GLEW_GET_FUN(__glewVertexAttrib3s)\r\n#define glVertexAttrib3sv GLEW_GET_FUN(__glewVertexAttrib3sv)\r\n#define glVertexAttrib4Nbv GLEW_GET_FUN(__glewVertexAttrib4Nbv)\r\n#define glVertexAttrib4Niv GLEW_GET_FUN(__glewVertexAttrib4Niv)\r\n#define glVertexAttrib4Nsv GLEW_GET_FUN(__glewVertexAttrib4Nsv)\r\n#define glVertexAttrib4Nub GLEW_GET_FUN(__glewVertexAttrib4Nub)\r\n#define glVertexAttrib4Nubv GLEW_GET_FUN(__glewVertexAttrib4Nubv)\r\n#define glVertexAttrib4Nuiv GLEW_GET_FUN(__glewVertexAttrib4Nuiv)\r\n#define glVertexAttrib4Nusv GLEW_GET_FUN(__glewVertexAttrib4Nusv)\r\n#define glVertexAttrib4bv GLEW_GET_FUN(__glewVertexAttrib4bv)\r\n#define glVertexAttrib4d GLEW_GET_FUN(__glewVertexAttrib4d)\r\n#define glVertexAttrib4dv GLEW_GET_FUN(__glewVertexAttrib4dv)\r\n#define glVertexAttrib4f GLEW_GET_FUN(__glewVertexAttrib4f)\r\n#define glVertexAttrib4fv GLEW_GET_FUN(__glewVertexAttrib4fv)\r\n#define glVertexAttrib4iv GLEW_GET_FUN(__glewVertexAttrib4iv)\r\n#define glVertexAttrib4s GLEW_GET_FUN(__glewVertexAttrib4s)\r\n#define glVertexAttrib4sv GLEW_GET_FUN(__glewVertexAttrib4sv)\r\n#define glVertexAttrib4ubv GLEW_GET_FUN(__glewVertexAttrib4ubv)\r\n#define glVertexAttrib4uiv GLEW_GET_FUN(__glewVertexAttrib4uiv)\r\n#define glVertexAttrib4usv GLEW_GET_FUN(__glewVertexAttrib4usv)\r\n#define glVertexAttribPointer GLEW_GET_FUN(__glewVertexAttribPointer)\r\n\r\n#define GLEW_VERSION_2_0 GLEW_GET_VAR(__GLEW_VERSION_2_0)\r\n\r\n#endif /* GL_VERSION_2_0 */\r\n\r\n/* ----------------------------- GL_VERSION_2_1 ---------------------------- */\r\n\r\n#ifndef GL_VERSION_2_1\r\n#define GL_VERSION_2_1 1\r\n\r\n#define GL_CURRENT_RASTER_SECONDARY_COLOR 0x845F\r\n#define GL_PIXEL_PACK_BUFFER 0x88EB\r\n#define GL_PIXEL_UNPACK_BUFFER 0x88EC\r\n#define GL_PIXEL_PACK_BUFFER_BINDING 0x88ED\r\n#define GL_PIXEL_UNPACK_BUFFER_BINDING 0x88EF\r\n#define GL_FLOAT_MAT2x3 0x8B65\r\n#define GL_FLOAT_MAT2x4 0x8B66\r\n#define GL_FLOAT_MAT3x2 0x8B67\r\n#define GL_FLOAT_MAT3x4 0x8B68\r\n#define GL_FLOAT_MAT4x2 0x8B69\r\n#define GL_FLOAT_MAT4x3 0x8B6A\r\n#define GL_SRGB 0x8C40\r\n#define GL_SRGB8 0x8C41\r\n#define GL_SRGB_ALPHA 0x8C42\r\n#define GL_SRGB8_ALPHA8 0x8C43\r\n#define GL_SLUMINANCE_ALPHA 0x8C44\r\n#define GL_SLUMINANCE8_ALPHA8 0x8C45\r\n#define GL_SLUMINANCE 0x8C46\r\n#define GL_SLUMINANCE8 0x8C47\r\n#define GL_COMPRESSED_SRGB 0x8C48\r\n#define GL_COMPRESSED_SRGB_ALPHA 0x8C49\r\n#define GL_COMPRESSED_SLUMINANCE 0x8C4A\r\n#define GL_COMPRESSED_SLUMINANCE_ALPHA 0x8C4B\r\n\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX2X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX2X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX3X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX3X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX4X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX4X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);\r\n\r\n#define glUniformMatrix2x3fv GLEW_GET_FUN(__glewUniformMatrix2x3fv)\r\n#define glUniformMatrix2x4fv GLEW_GET_FUN(__glewUniformMatrix2x4fv)\r\n#define glUniformMatrix3x2fv GLEW_GET_FUN(__glewUniformMatrix3x2fv)\r\n#define glUniformMatrix3x4fv GLEW_GET_FUN(__glewUniformMatrix3x4fv)\r\n#define glUniformMatrix4x2fv GLEW_GET_FUN(__glewUniformMatrix4x2fv)\r\n#define glUniformMatrix4x3fv GLEW_GET_FUN(__glewUniformMatrix4x3fv)\r\n\r\n#define GLEW_VERSION_2_1 GLEW_GET_VAR(__GLEW_VERSION_2_1)\r\n\r\n#endif /* GL_VERSION_2_1 */\r\n\r\n/* ----------------------------- GL_VERSION_3_0 ---------------------------- */\r\n\r\n#ifndef GL_VERSION_3_0\r\n#define GL_VERSION_3_0 1\r\n\r\n#define GL_CLIP_DISTANCE0 GL_CLIP_PLANE0\r\n#define GL_CLIP_DISTANCE1 GL_CLIP_PLANE1\r\n#define GL_CLIP_DISTANCE2 GL_CLIP_PLANE2\r\n#define GL_CLIP_DISTANCE3 GL_CLIP_PLANE3\r\n#define GL_CLIP_DISTANCE4 GL_CLIP_PLANE4\r\n#define GL_CLIP_DISTANCE5 GL_CLIP_PLANE5\r\n#define GL_COMPARE_REF_TO_TEXTURE GL_COMPARE_R_TO_TEXTURE_ARB\r\n#define GL_MAX_CLIP_DISTANCES GL_MAX_CLIP_PLANES\r\n#define GL_MAX_VARYING_COMPONENTS GL_MAX_VARYING_FLOATS\r\n#define GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT 0x0001\r\n#define GL_MAJOR_VERSION 0x821B\r\n#define GL_MINOR_VERSION 0x821C\r\n#define GL_NUM_EXTENSIONS 0x821D\r\n#define GL_CONTEXT_FLAGS 0x821E\r\n#define GL_DEPTH_BUFFER 0x8223\r\n#define GL_STENCIL_BUFFER 0x8224\r\n#define GL_RGBA32F 0x8814\r\n#define GL_RGB32F 0x8815\r\n#define GL_RGBA16F 0x881A\r\n#define GL_RGB16F 0x881B\r\n#define GL_VERTEX_ATTRIB_ARRAY_INTEGER 0x88FD\r\n#define GL_MAX_ARRAY_TEXTURE_LAYERS 0x88FF\r\n#define GL_MIN_PROGRAM_TEXEL_OFFSET 0x8904\r\n#define GL_MAX_PROGRAM_TEXEL_OFFSET 0x8905\r\n#define GL_CLAMP_VERTEX_COLOR 0x891A\r\n#define GL_CLAMP_FRAGMENT_COLOR 0x891B\r\n#define GL_CLAMP_READ_COLOR 0x891C\r\n#define GL_FIXED_ONLY 0x891D\r\n#define GL_TEXTURE_RED_TYPE 0x8C10\r\n#define GL_TEXTURE_GREEN_TYPE 0x8C11\r\n#define GL_TEXTURE_BLUE_TYPE 0x8C12\r\n#define GL_TEXTURE_ALPHA_TYPE 0x8C13\r\n#define GL_TEXTURE_LUMINANCE_TYPE 0x8C14\r\n#define GL_TEXTURE_INTENSITY_TYPE 0x8C15\r\n#define GL_TEXTURE_DEPTH_TYPE 0x8C16\r\n#define GL_TEXTURE_1D_ARRAY 0x8C18\r\n#define GL_PROXY_TEXTURE_1D_ARRAY 0x8C19\r\n#define GL_TEXTURE_2D_ARRAY 0x8C1A\r\n#define GL_PROXY_TEXTURE_2D_ARRAY 0x8C1B\r\n#define GL_TEXTURE_BINDING_1D_ARRAY 0x8C1C\r\n#define GL_TEXTURE_BINDING_2D_ARRAY 0x8C1D\r\n#define GL_R11F_G11F_B10F 0x8C3A\r\n#define GL_UNSIGNED_INT_10F_11F_11F_REV 0x8C3B\r\n#define GL_RGB9_E5 0x8C3D\r\n#define GL_UNSIGNED_INT_5_9_9_9_REV 0x8C3E\r\n#define GL_TEXTURE_SHARED_SIZE 0x8C3F\r\n#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH 0x8C76\r\n#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE 0x8C7F\r\n#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS 0x8C80\r\n#define GL_TRANSFORM_FEEDBACK_VARYINGS 0x8C83\r\n#define GL_TRANSFORM_FEEDBACK_BUFFER_START 0x8C84\r\n#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE 0x8C85\r\n#define GL_PRIMITIVES_GENERATED 0x8C87\r\n#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN 0x8C88\r\n#define GL_RASTERIZER_DISCARD 0x8C89\r\n#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS 0x8C8A\r\n#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS 0x8C8B\r\n#define GL_INTERLEAVED_ATTRIBS 0x8C8C\r\n#define GL_SEPARATE_ATTRIBS 0x8C8D\r\n#define GL_TRANSFORM_FEEDBACK_BUFFER 0x8C8E\r\n#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING 0x8C8F\r\n#define GL_RGBA32UI 0x8D70\r\n#define GL_RGB32UI 0x8D71\r\n#define GL_RGBA16UI 0x8D76\r\n#define GL_RGB16UI 0x8D77\r\n#define GL_RGBA8UI 0x8D7C\r\n#define GL_RGB8UI 0x8D7D\r\n#define GL_RGBA32I 0x8D82\r\n#define GL_RGB32I 0x8D83\r\n#define GL_RGBA16I 0x8D88\r\n#define GL_RGB16I 0x8D89\r\n#define GL_RGBA8I 0x8D8E\r\n#define GL_RGB8I 0x8D8F\r\n#define GL_RED_INTEGER 0x8D94\r\n#define GL_GREEN_INTEGER 0x8D95\r\n#define GL_BLUE_INTEGER 0x8D96\r\n#define GL_ALPHA_INTEGER 0x8D97\r\n#define GL_RGB_INTEGER 0x8D98\r\n#define GL_RGBA_INTEGER 0x8D99\r\n#define GL_BGR_INTEGER 0x8D9A\r\n#define GL_BGRA_INTEGER 0x8D9B\r\n#define GL_SAMPLER_1D_ARRAY 0x8DC0\r\n#define GL_SAMPLER_2D_ARRAY 0x8DC1\r\n#define GL_SAMPLER_1D_ARRAY_SHADOW 0x8DC3\r\n#define GL_SAMPLER_2D_ARRAY_SHADOW 0x8DC4\r\n#define GL_SAMPLER_CUBE_SHADOW 0x8DC5\r\n#define GL_UNSIGNED_INT_VEC2 0x8DC6\r\n#define GL_UNSIGNED_INT_VEC3 0x8DC7\r\n#define GL_UNSIGNED_INT_VEC4 0x8DC8\r\n#define GL_INT_SAMPLER_1D 0x8DC9\r\n#define GL_INT_SAMPLER_2D 0x8DCA\r\n#define GL_INT_SAMPLER_3D 0x8DCB\r\n#define GL_INT_SAMPLER_CUBE 0x8DCC\r\n#define GL_INT_SAMPLER_1D_ARRAY 0x8DCE\r\n#define GL_INT_SAMPLER_2D_ARRAY 0x8DCF\r\n#define GL_UNSIGNED_INT_SAMPLER_1D 0x8DD1\r\n#define GL_UNSIGNED_INT_SAMPLER_2D 0x8DD2\r\n#define GL_UNSIGNED_INT_SAMPLER_3D 0x8DD3\r\n#define GL_UNSIGNED_INT_SAMPLER_CUBE 0x8DD4\r\n#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY 0x8DD6\r\n#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY 0x8DD7\r\n#define GL_QUERY_WAIT 0x8E13\r\n#define GL_QUERY_NO_WAIT 0x8E14\r\n#define GL_QUERY_BY_REGION_WAIT 0x8E15\r\n#define GL_QUERY_BY_REGION_NO_WAIT 0x8E16\r\n\r\ntypedef void (GLAPIENTRY * PFNGLBEGINCONDITIONALRENDERPROC) (GLuint id, GLenum mode);\r\ntypedef void (GLAPIENTRY * PFNGLBEGINTRANSFORMFEEDBACKPROC) (GLenum primitiveMode);\r\ntypedef void (GLAPIENTRY * PFNGLBINDFRAGDATALOCATIONPROC) (GLuint program, GLuint colorNumber, const GLchar* name);\r\ntypedef void (GLAPIENTRY * PFNGLCLAMPCOLORPROC) (GLenum target, GLenum clamp);\r\ntypedef void (GLAPIENTRY * PFNGLCLEARBUFFERFIPROC) (GLenum buffer, GLint drawBuffer, GLfloat depth, GLint stencil);\r\ntypedef void (GLAPIENTRY * PFNGLCLEARBUFFERFVPROC) (GLenum buffer, GLint drawBuffer, const GLfloat* value);\r\ntypedef void (GLAPIENTRY * PFNGLCLEARBUFFERIVPROC) (GLenum buffer, GLint drawBuffer, const GLint* value);\r\ntypedef void (GLAPIENTRY * PFNGLCLEARBUFFERUIVPROC) (GLenum buffer, GLint drawBuffer, const GLuint* value);\r\ntypedef void (GLAPIENTRY * PFNGLCOLORMASKIPROC) (GLuint buf, GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);\r\ntypedef void (GLAPIENTRY * PFNGLDISABLEIPROC) (GLenum cap, GLuint index);\r\ntypedef void (GLAPIENTRY * PFNGLENABLEIPROC) (GLenum cap, GLuint index);\r\ntypedef void (GLAPIENTRY * PFNGLENDCONDITIONALRENDERPROC) (void);\r\ntypedef void (GLAPIENTRY * PFNGLENDTRANSFORMFEEDBACKPROC) (void);\r\ntypedef void (GLAPIENTRY * PFNGLGETBOOLEANI_VPROC) (GLenum pname, GLuint index, GLboolean* data);\r\ntypedef GLint (GLAPIENTRY * PFNGLGETFRAGDATALOCATIONPROC) (GLuint program, const GLchar* name);\r\ntypedef const GLubyte* (GLAPIENTRY * PFNGLGETSTRINGIPROC) (GLenum name, GLuint index);\r\ntypedef void (GLAPIENTRY * PFNGLGETTEXPARAMETERIIVPROC) (GLenum target, GLenum pname, GLint* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETTEXPARAMETERIUIVPROC) (GLenum target, GLenum pname, GLuint* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETTRANSFORMFEEDBACKVARYINGPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei * length, GLsizei * size, GLenum * type, GLchar * name);\r\ntypedef void (GLAPIENTRY * PFNGLGETUNIFORMUIVPROC) (GLuint program, GLint location, GLuint* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBIIVPROC) (GLuint index, GLenum pname, GLint* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBIUIVPROC) (GLuint index, GLenum pname, GLuint* params);\r\ntypedef GLboolean (GLAPIENTRY * PFNGLISENABLEDIPROC) (GLenum cap, GLuint index);\r\ntypedef void (GLAPIENTRY * PFNGLTEXPARAMETERIIVPROC) (GLenum target, GLenum pname, const GLint* params);\r\ntypedef void (GLAPIENTRY * PFNGLTEXPARAMETERIUIVPROC) (GLenum target, GLenum pname, const GLuint* params);\r\ntypedef void (GLAPIENTRY * PFNGLTRANSFORMFEEDBACKVARYINGSPROC) (GLuint program, GLsizei count, const GLchar *const* varyings, GLenum bufferMode);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORM1UIPROC) (GLint location, GLuint v0);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORM1UIVPROC) (GLint location, GLsizei count, const GLuint* value);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORM2UIPROC) (GLint location, GLuint v0, GLuint v1);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORM2UIVPROC) (GLint location, GLsizei count, const GLuint* value);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORM3UIPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORM3UIVPROC) (GLint location, GLsizei count, const GLuint* value);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORM4UIPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORM4UIVPROC) (GLint location, GLsizei count, const GLuint* value);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI1IPROC) (GLuint index, GLint v0);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI1IVPROC) (GLuint index, const GLint* v0);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI1UIPROC) (GLuint index, GLuint v0);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI1UIVPROC) (GLuint index, const GLuint* v0);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI2IPROC) (GLuint index, GLint v0, GLint v1);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI2IVPROC) (GLuint index, const GLint* v0);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI2UIPROC) (GLuint index, GLuint v0, GLuint v1);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI2UIVPROC) (GLuint index, const GLuint* v0);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI3IPROC) (GLuint index, GLint v0, GLint v1, GLint v2);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI3IVPROC) (GLuint index, const GLint* v0);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI3UIPROC) (GLuint index, GLuint v0, GLuint v1, GLuint v2);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI3UIVPROC) (GLuint index, const GLuint* v0);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4BVPROC) (GLuint index, const GLbyte* v0);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4IPROC) (GLuint index, GLint v0, GLint v1, GLint v2, GLint v3);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4IVPROC) (GLuint index, const GLint* v0);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4SVPROC) (GLuint index, const GLshort* v0);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4UBVPROC) (GLuint index, const GLubyte* v0);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4UIPROC) (GLuint index, GLuint v0, GLuint v1, GLuint v2, GLuint v3);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4UIVPROC) (GLuint index, const GLuint* v0);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4USVPROC) (GLuint index, const GLushort* v0);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBIPOINTERPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const void*pointer);\r\n\r\n#define glBeginConditionalRender GLEW_GET_FUN(__glewBeginConditionalRender)\r\n#define glBeginTransformFeedback GLEW_GET_FUN(__glewBeginTransformFeedback)\r\n#define glBindFragDataLocation GLEW_GET_FUN(__glewBindFragDataLocation)\r\n#define glClampColor GLEW_GET_FUN(__glewClampColor)\r\n#define glClearBufferfi GLEW_GET_FUN(__glewClearBufferfi)\r\n#define glClearBufferfv GLEW_GET_FUN(__glewClearBufferfv)\r\n#define glClearBufferiv GLEW_GET_FUN(__glewClearBufferiv)\r\n#define glClearBufferuiv GLEW_GET_FUN(__glewClearBufferuiv)\r\n#define glColorMaski GLEW_GET_FUN(__glewColorMaski)\r\n#define glDisablei GLEW_GET_FUN(__glewDisablei)\r\n#define glEnablei GLEW_GET_FUN(__glewEnablei)\r\n#define glEndConditionalRender GLEW_GET_FUN(__glewEndConditionalRender)\r\n#define glEndTransformFeedback GLEW_GET_FUN(__glewEndTransformFeedback)\r\n#define glGetBooleani_v GLEW_GET_FUN(__glewGetBooleani_v)\r\n#define glGetFragDataLocation GLEW_GET_FUN(__glewGetFragDataLocation)\r\n#define glGetStringi GLEW_GET_FUN(__glewGetStringi)\r\n#define glGetTexParameterIiv GLEW_GET_FUN(__glewGetTexParameterIiv)\r\n#define glGetTexParameterIuiv GLEW_GET_FUN(__glewGetTexParameterIuiv)\r\n#define glGetTransformFeedbackVarying GLEW_GET_FUN(__glewGetTransformFeedbackVarying)\r\n#define glGetUniformuiv GLEW_GET_FUN(__glewGetUniformuiv)\r\n#define glGetVertexAttribIiv GLEW_GET_FUN(__glewGetVertexAttribIiv)\r\n#define glGetVertexAttribIuiv GLEW_GET_FUN(__glewGetVertexAttribIuiv)\r\n#define glIsEnabledi GLEW_GET_FUN(__glewIsEnabledi)\r\n#define glTexParameterIiv GLEW_GET_FUN(__glewTexParameterIiv)\r\n#define glTexParameterIuiv GLEW_GET_FUN(__glewTexParameterIuiv)\r\n#define glTransformFeedbackVaryings GLEW_GET_FUN(__glewTransformFeedbackVaryings)\r\n#define glUniform1ui GLEW_GET_FUN(__glewUniform1ui)\r\n#define glUniform1uiv GLEW_GET_FUN(__glewUniform1uiv)\r\n#define glUniform2ui GLEW_GET_FUN(__glewUniform2ui)\r\n#define glUniform2uiv GLEW_GET_FUN(__glewUniform2uiv)\r\n#define glUniform3ui GLEW_GET_FUN(__glewUniform3ui)\r\n#define glUniform3uiv GLEW_GET_FUN(__glewUniform3uiv)\r\n#define glUniform4ui GLEW_GET_FUN(__glewUniform4ui)\r\n#define glUniform4uiv GLEW_GET_FUN(__glewUniform4uiv)\r\n#define glVertexAttribI1i GLEW_GET_FUN(__glewVertexAttribI1i)\r\n#define glVertexAttribI1iv GLEW_GET_FUN(__glewVertexAttribI1iv)\r\n#define glVertexAttribI1ui GLEW_GET_FUN(__glewVertexAttribI1ui)\r\n#define glVertexAttribI1uiv GLEW_GET_FUN(__glewVertexAttribI1uiv)\r\n#define glVertexAttribI2i GLEW_GET_FUN(__glewVertexAttribI2i)\r\n#define glVertexAttribI2iv GLEW_GET_FUN(__glewVertexAttribI2iv)\r\n#define glVertexAttribI2ui GLEW_GET_FUN(__glewVertexAttribI2ui)\r\n#define glVertexAttribI2uiv GLEW_GET_FUN(__glewVertexAttribI2uiv)\r\n#define glVertexAttribI3i GLEW_GET_FUN(__glewVertexAttribI3i)\r\n#define glVertexAttribI3iv GLEW_GET_FUN(__glewVertexAttribI3iv)\r\n#define glVertexAttribI3ui GLEW_GET_FUN(__glewVertexAttribI3ui)\r\n#define glVertexAttribI3uiv GLEW_GET_FUN(__glewVertexAttribI3uiv)\r\n#define glVertexAttribI4bv GLEW_GET_FUN(__glewVertexAttribI4bv)\r\n#define glVertexAttribI4i GLEW_GET_FUN(__glewVertexAttribI4i)\r\n#define glVertexAttribI4iv GLEW_GET_FUN(__glewVertexAttribI4iv)\r\n#define glVertexAttribI4sv GLEW_GET_FUN(__glewVertexAttribI4sv)\r\n#define glVertexAttribI4ubv GLEW_GET_FUN(__glewVertexAttribI4ubv)\r\n#define glVertexAttribI4ui GLEW_GET_FUN(__glewVertexAttribI4ui)\r\n#define glVertexAttribI4uiv GLEW_GET_FUN(__glewVertexAttribI4uiv)\r\n#define glVertexAttribI4usv GLEW_GET_FUN(__glewVertexAttribI4usv)\r\n#define glVertexAttribIPointer GLEW_GET_FUN(__glewVertexAttribIPointer)\r\n\r\n#define GLEW_VERSION_3_0 GLEW_GET_VAR(__GLEW_VERSION_3_0)\r\n\r\n#endif /* GL_VERSION_3_0 */\r\n\r\n/* ----------------------------- GL_VERSION_3_1 ---------------------------- */\r\n\r\n#ifndef GL_VERSION_3_1\r\n#define GL_VERSION_3_1 1\r\n\r\n#define GL_TEXTURE_RECTANGLE 0x84F5\r\n#define GL_TEXTURE_BINDING_RECTANGLE 0x84F6\r\n#define GL_PROXY_TEXTURE_RECTANGLE 0x84F7\r\n#define GL_MAX_RECTANGLE_TEXTURE_SIZE 0x84F8\r\n#define GL_SAMPLER_2D_RECT 0x8B63\r\n#define GL_SAMPLER_2D_RECT_SHADOW 0x8B64\r\n#define GL_TEXTURE_BUFFER 0x8C2A\r\n#define GL_MAX_TEXTURE_BUFFER_SIZE 0x8C2B\r\n#define GL_TEXTURE_BINDING_BUFFER 0x8C2C\r\n#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING 0x8C2D\r\n#define GL_TEXTURE_BUFFER_FORMAT 0x8C2E\r\n#define GL_SAMPLER_BUFFER 0x8DC2\r\n#define GL_INT_SAMPLER_2D_RECT 0x8DCD\r\n#define GL_INT_SAMPLER_BUFFER 0x8DD0\r\n#define GL_UNSIGNED_INT_SAMPLER_2D_RECT 0x8DD5\r\n#define GL_UNSIGNED_INT_SAMPLER_BUFFER 0x8DD8\r\n#define GL_RED_SNORM 0x8F90\r\n#define GL_RG_SNORM 0x8F91\r\n#define GL_RGB_SNORM 0x8F92\r\n#define GL_RGBA_SNORM 0x8F93\r\n#define GL_R8_SNORM 0x8F94\r\n#define GL_RG8_SNORM 0x8F95\r\n#define GL_RGB8_SNORM 0x8F96\r\n#define GL_RGBA8_SNORM 0x8F97\r\n#define GL_R16_SNORM 0x8F98\r\n#define GL_RG16_SNORM 0x8F99\r\n#define GL_RGB16_SNORM 0x8F9A\r\n#define GL_RGBA16_SNORM 0x8F9B\r\n#define GL_SIGNED_NORMALIZED 0x8F9C\r\n#define GL_PRIMITIVE_RESTART 0x8F9D\r\n#define GL_PRIMITIVE_RESTART_INDEX 0x8F9E\r\n#define GL_BUFFER_ACCESS_FLAGS 0x911F\r\n#define GL_BUFFER_MAP_LENGTH 0x9120\r\n#define GL_BUFFER_MAP_OFFSET 0x9121\r\n\r\ntypedef void (GLAPIENTRY * PFNGLDRAWARRAYSINSTANCEDPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount);\r\ntypedef void (GLAPIENTRY * PFNGLDRAWELEMENTSINSTANCEDPROC) (GLenum mode, GLsizei count, GLenum type, const void* indices, GLsizei primcount);\r\ntypedef void (GLAPIENTRY * PFNGLPRIMITIVERESTARTINDEXPROC) (GLuint buffer);\r\ntypedef void (GLAPIENTRY * PFNGLTEXBUFFERPROC) (GLenum target, GLenum internalFormat, GLuint buffer);\r\n\r\n#define glDrawArraysInstanced GLEW_GET_FUN(__glewDrawArraysInstanced)\r\n#define glDrawElementsInstanced GLEW_GET_FUN(__glewDrawElementsInstanced)\r\n#define glPrimitiveRestartIndex GLEW_GET_FUN(__glewPrimitiveRestartIndex)\r\n#define glTexBuffer GLEW_GET_FUN(__glewTexBuffer)\r\n\r\n#define GLEW_VERSION_3_1 GLEW_GET_VAR(__GLEW_VERSION_3_1)\r\n\r\n#endif /* GL_VERSION_3_1 */\r\n\r\n/* ----------------------------- GL_VERSION_3_2 ---------------------------- */\r\n\r\n#ifndef GL_VERSION_3_2\r\n#define GL_VERSION_3_2 1\r\n\r\n#define GL_CONTEXT_CORE_PROFILE_BIT 0x00000001\r\n#define GL_CONTEXT_COMPATIBILITY_PROFILE_BIT 0x00000002\r\n#define GL_LINES_ADJACENCY 0x000A\r\n#define GL_LINE_STRIP_ADJACENCY 0x000B\r\n#define GL_TRIANGLES_ADJACENCY 0x000C\r\n#define GL_TRIANGLE_STRIP_ADJACENCY 0x000D\r\n#define GL_PROGRAM_POINT_SIZE 0x8642\r\n#define GL_GEOMETRY_VERTICES_OUT 0x8916\r\n#define GL_GEOMETRY_INPUT_TYPE 0x8917\r\n#define GL_GEOMETRY_OUTPUT_TYPE 0x8918\r\n#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS 0x8C29\r\n#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED 0x8DA7\r\n#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS 0x8DA8\r\n#define GL_GEOMETRY_SHADER 0x8DD9\r\n#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS 0x8DDF\r\n#define GL_MAX_GEOMETRY_OUTPUT_VERTICES 0x8DE0\r\n#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS 0x8DE1\r\n#define GL_MAX_VERTEX_OUTPUT_COMPONENTS 0x9122\r\n#define GL_MAX_GEOMETRY_INPUT_COMPONENTS 0x9123\r\n#define GL_MAX_GEOMETRY_OUTPUT_COMPONENTS 0x9124\r\n#define GL_MAX_FRAGMENT_INPUT_COMPONENTS 0x9125\r\n#define GL_CONTEXT_PROFILE_MASK 0x9126\r\n\r\ntypedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTUREPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level);\r\ntypedef void (GLAPIENTRY * PFNGLGETBUFFERPARAMETERI64VPROC) (GLenum target, GLenum value, GLint64 * data);\r\ntypedef void (GLAPIENTRY * PFNGLGETINTEGER64I_VPROC) (GLenum pname, GLuint index, GLint64 * data);\r\n\r\n#define glFramebufferTexture GLEW_GET_FUN(__glewFramebufferTexture)\r\n#define glGetBufferParameteri64v GLEW_GET_FUN(__glewGetBufferParameteri64v)\r\n#define glGetInteger64i_v GLEW_GET_FUN(__glewGetInteger64i_v)\r\n\r\n#define GLEW_VERSION_3_2 GLEW_GET_VAR(__GLEW_VERSION_3_2)\r\n\r\n#endif /* GL_VERSION_3_2 */\r\n\r\n/* ----------------------------- GL_VERSION_3_3 ---------------------------- */\r\n\r\n#ifndef GL_VERSION_3_3\r\n#define GL_VERSION_3_3 1\r\n\r\n#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR 0x88FE\r\n#define GL_RGB10_A2UI 0x906F\r\n\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBDIVISORPROC) (GLuint index, GLuint divisor);\r\n\r\n#define glVertexAttribDivisor GLEW_GET_FUN(__glewVertexAttribDivisor)\r\n\r\n#define GLEW_VERSION_3_3 GLEW_GET_VAR(__GLEW_VERSION_3_3)\r\n\r\n#endif /* GL_VERSION_3_3 */\r\n\r\n/* ----------------------------- GL_VERSION_4_0 ---------------------------- */\r\n\r\n#ifndef GL_VERSION_4_0\r\n#define GL_VERSION_4_0 1\r\n\r\n#define GL_SAMPLE_SHADING 0x8C36\r\n#define GL_MIN_SAMPLE_SHADING_VALUE 0x8C37\r\n#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5E\r\n#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5F\r\n#define GL_MAX_PROGRAM_TEXTURE_GATHER_COMPONENTS 0x8F9F\r\n#define GL_TEXTURE_CUBE_MAP_ARRAY 0x9009\r\n#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY 0x900A\r\n#define GL_PROXY_TEXTURE_CUBE_MAP_ARRAY 0x900B\r\n#define GL_SAMPLER_CUBE_MAP_ARRAY 0x900C\r\n#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW 0x900D\r\n#define GL_INT_SAMPLER_CUBE_MAP_ARRAY 0x900E\r\n#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY 0x900F\r\n\r\ntypedef void (GLAPIENTRY * PFNGLBLENDEQUATIONSEPARATEIPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha);\r\ntypedef void (GLAPIENTRY * PFNGLBLENDEQUATIONIPROC) (GLuint buf, GLenum mode);\r\ntypedef void (GLAPIENTRY * PFNGLBLENDFUNCSEPARATEIPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);\r\ntypedef void (GLAPIENTRY * PFNGLBLENDFUNCIPROC) (GLuint buf, GLenum src, GLenum dst);\r\ntypedef void (GLAPIENTRY * PFNGLMINSAMPLESHADINGPROC) (GLclampf value);\r\n\r\n#define glBlendEquationSeparatei GLEW_GET_FUN(__glewBlendEquationSeparatei)\r\n#define glBlendEquationi GLEW_GET_FUN(__glewBlendEquationi)\r\n#define glBlendFuncSeparatei GLEW_GET_FUN(__glewBlendFuncSeparatei)\r\n#define glBlendFunci GLEW_GET_FUN(__glewBlendFunci)\r\n#define glMinSampleShading GLEW_GET_FUN(__glewMinSampleShading)\r\n\r\n#define GLEW_VERSION_4_0 GLEW_GET_VAR(__GLEW_VERSION_4_0)\r\n\r\n#endif /* GL_VERSION_4_0 */\r\n\r\n/* ----------------------------- GL_VERSION_4_1 ---------------------------- */\r\n\r\n#ifndef GL_VERSION_4_1\r\n#define GL_VERSION_4_1 1\r\n\r\n#define GLEW_VERSION_4_1 GLEW_GET_VAR(__GLEW_VERSION_4_1)\r\n\r\n#endif /* GL_VERSION_4_1 */\r\n\r\n/* ----------------------------- GL_VERSION_4_2 ---------------------------- */\r\n\r\n#ifndef GL_VERSION_4_2\r\n#define GL_VERSION_4_2 1\r\n\r\n#define GL_TRANSFORM_FEEDBACK_PAUSED 0x8E23\r\n#define GL_TRANSFORM_FEEDBACK_ACTIVE 0x8E24\r\n#define GL_COMPRESSED_RGBA_BPTC_UNORM 0x8E8C\r\n#define GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM 0x8E8D\r\n#define GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT 0x8E8E\r\n#define GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT 0x8E8F\r\n#define GL_COPY_READ_BUFFER_BINDING 0x8F36\r\n#define GL_COPY_WRITE_BUFFER_BINDING 0x8F37\r\n\r\n#define GLEW_VERSION_4_2 GLEW_GET_VAR(__GLEW_VERSION_4_2)\r\n\r\n#endif /* GL_VERSION_4_2 */\r\n\r\n/* ----------------------------- GL_VERSION_4_3 ---------------------------- */\r\n\r\n#ifndef GL_VERSION_4_3\r\n#define GL_VERSION_4_3 1\r\n\r\n#define GL_NUM_SHADING_LANGUAGE_VERSIONS 0x82E9\r\n#define GL_VERTEX_ATTRIB_ARRAY_LONG 0x874E\r\n\r\n#define GLEW_VERSION_4_3 GLEW_GET_VAR(__GLEW_VERSION_4_3)\r\n\r\n#endif /* GL_VERSION_4_3 */\r\n\r\n/* ----------------------------- GL_VERSION_4_4 ---------------------------- */\r\n\r\n#ifndef GL_VERSION_4_4\r\n#define GL_VERSION_4_4 1\r\n\r\n#define GL_PRIMITIVE_RESTART_FOR_PATCHES_SUPPORTED 0x8221\r\n#define GL_MAX_VERTEX_ATTRIB_STRIDE 0x82E5\r\n#define GL_TEXTURE_BUFFER_BINDING 0x8C2A\r\n\r\n#define GLEW_VERSION_4_4 GLEW_GET_VAR(__GLEW_VERSION_4_4)\r\n\r\n#endif /* GL_VERSION_4_4 */\r\n\r\n/* ----------------------------- GL_VERSION_4_5 ---------------------------- */\r\n\r\n#ifndef GL_VERSION_4_5\r\n#define GL_VERSION_4_5 1\r\n\r\n#define GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT 0x00000004\r\n\r\ntypedef GLenum (GLAPIENTRY * PFNGLGETGRAPHICSRESETSTATUSPROC) (void);\r\ntypedef void (GLAPIENTRY * PFNGLGETNCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint lod, GLsizei bufSize, GLvoid *pixels);\r\ntypedef void (GLAPIENTRY * PFNGLGETNTEXIMAGEPROC) (GLenum tex, GLint level, GLenum format, GLenum type, GLsizei bufSize, GLvoid *pixels);\r\ntypedef void (GLAPIENTRY * PFNGLGETNUNIFORMDVPROC) (GLuint program, GLint location, GLsizei bufSize, GLdouble *params);\r\n\r\n#define glGetGraphicsResetStatus GLEW_GET_FUN(__glewGetGraphicsResetStatus)\r\n#define glGetnCompressedTexImage GLEW_GET_FUN(__glewGetnCompressedTexImage)\r\n#define glGetnTexImage GLEW_GET_FUN(__glewGetnTexImage)\r\n#define glGetnUniformdv GLEW_GET_FUN(__glewGetnUniformdv)\r\n\r\n#define GLEW_VERSION_4_5 GLEW_GET_VAR(__GLEW_VERSION_4_5)\r\n\r\n#endif /* GL_VERSION_4_5 */\r\n\r\n/* -------------------------- GL_3DFX_multisample -------------------------- */\r\n\r\n#ifndef GL_3DFX_multisample\r\n#define GL_3DFX_multisample 1\r\n\r\n#define GL_MULTISAMPLE_3DFX 0x86B2\r\n#define GL_SAMPLE_BUFFERS_3DFX 0x86B3\r\n#define GL_SAMPLES_3DFX 0x86B4\r\n#define GL_MULTISAMPLE_BIT_3DFX 0x20000000\r\n\r\n#define GLEW_3DFX_multisample GLEW_GET_VAR(__GLEW_3DFX_multisample)\r\n\r\n#endif /* GL_3DFX_multisample */\r\n\r\n/* ---------------------------- GL_3DFX_tbuffer ---------------------------- */\r\n\r\n#ifndef GL_3DFX_tbuffer\r\n#define GL_3DFX_tbuffer 1\r\n\r\ntypedef void (GLAPIENTRY * PFNGLTBUFFERMASK3DFXPROC) (GLuint mask);\r\n\r\n#define glTbufferMask3DFX GLEW_GET_FUN(__glewTbufferMask3DFX)\r\n\r\n#define GLEW_3DFX_tbuffer GLEW_GET_VAR(__GLEW_3DFX_tbuffer)\r\n\r\n#endif /* GL_3DFX_tbuffer */\r\n\r\n/* -------------------- GL_3DFX_texture_compression_FXT1 ------------------- */\r\n\r\n#ifndef GL_3DFX_texture_compression_FXT1\r\n#define GL_3DFX_texture_compression_FXT1 1\r\n\r\n#define GL_COMPRESSED_RGB_FXT1_3DFX 0x86B0\r\n#define GL_COMPRESSED_RGBA_FXT1_3DFX 0x86B1\r\n\r\n#define GLEW_3DFX_texture_compression_FXT1 GLEW_GET_VAR(__GLEW_3DFX_texture_compression_FXT1)\r\n\r\n#endif /* GL_3DFX_texture_compression_FXT1 */\r\n\r\n/* ----------------------- GL_AMD_blend_minmax_factor ---------------------- */\r\n\r\n#ifndef GL_AMD_blend_minmax_factor\r\n#define GL_AMD_blend_minmax_factor 1\r\n\r\n#define GL_FACTOR_MIN_AMD 0x901C\r\n#define GL_FACTOR_MAX_AMD 0x901D\r\n\r\n#define GLEW_AMD_blend_minmax_factor GLEW_GET_VAR(__GLEW_AMD_blend_minmax_factor)\r\n\r\n#endif /* GL_AMD_blend_minmax_factor */\r\n\r\n/* ----------------------- GL_AMD_conservative_depth ----------------------- */\r\n\r\n#ifndef GL_AMD_conservative_depth\r\n#define GL_AMD_conservative_depth 1\r\n\r\n#define GLEW_AMD_conservative_depth GLEW_GET_VAR(__GLEW_AMD_conservative_depth)\r\n\r\n#endif /* GL_AMD_conservative_depth */\r\n\r\n/* -------------------------- GL_AMD_debug_output -------------------------- */\r\n\r\n#ifndef GL_AMD_debug_output\r\n#define GL_AMD_debug_output 1\r\n\r\n#define GL_MAX_DEBUG_MESSAGE_LENGTH_AMD 0x9143\r\n#define GL_MAX_DEBUG_LOGGED_MESSAGES_AMD 0x9144\r\n#define GL_DEBUG_LOGGED_MESSAGES_AMD 0x9145\r\n#define GL_DEBUG_SEVERITY_HIGH_AMD 0x9146\r\n#define GL_DEBUG_SEVERITY_MEDIUM_AMD 0x9147\r\n#define GL_DEBUG_SEVERITY_LOW_AMD 0x9148\r\n#define GL_DEBUG_CATEGORY_API_ERROR_AMD 0x9149\r\n#define GL_DEBUG_CATEGORY_WINDOW_SYSTEM_AMD 0x914A\r\n#define GL_DEBUG_CATEGORY_DEPRECATION_AMD 0x914B\r\n#define GL_DEBUG_CATEGORY_UNDEFINED_BEHAVIOR_AMD 0x914C\r\n#define GL_DEBUG_CATEGORY_PERFORMANCE_AMD 0x914D\r\n#define GL_DEBUG_CATEGORY_SHADER_COMPILER_AMD 0x914E\r\n#define GL_DEBUG_CATEGORY_APPLICATION_AMD 0x914F\r\n#define GL_DEBUG_CATEGORY_OTHER_AMD 0x9150\r\n\r\ntypedef void (GLAPIENTRY *GLDEBUGPROCAMD)(GLuint id, GLenum category, GLenum severity, GLsizei length, const GLchar* message, void* userParam);\r\n\r\ntypedef void (GLAPIENTRY * PFNGLDEBUGMESSAGECALLBACKAMDPROC) (GLDEBUGPROCAMD callback, void *userParam);\r\ntypedef void (GLAPIENTRY * PFNGLDEBUGMESSAGEENABLEAMDPROC) (GLenum category, GLenum severity, GLsizei count, const GLuint* ids, GLboolean enabled);\r\ntypedef void (GLAPIENTRY * PFNGLDEBUGMESSAGEINSERTAMDPROC) (GLenum category, GLenum severity, GLuint id, GLsizei length, const GLchar* buf);\r\ntypedef GLuint (GLAPIENTRY * PFNGLGETDEBUGMESSAGELOGAMDPROC) (GLuint count, GLsizei bufsize, GLenum* categories, GLuint* severities, GLuint* ids, GLsizei* lengths, GLchar* message);\r\n\r\n#define glDebugMessageCallbackAMD GLEW_GET_FUN(__glewDebugMessageCallbackAMD)\r\n#define glDebugMessageEnableAMD GLEW_GET_FUN(__glewDebugMessageEnableAMD)\r\n#define glDebugMessageInsertAMD GLEW_GET_FUN(__glewDebugMessageInsertAMD)\r\n#define glGetDebugMessageLogAMD GLEW_GET_FUN(__glewGetDebugMessageLogAMD)\r\n\r\n#define GLEW_AMD_debug_output GLEW_GET_VAR(__GLEW_AMD_debug_output)\r\n\r\n#endif /* GL_AMD_debug_output */\r\n\r\n/* ---------------------- GL_AMD_depth_clamp_separate ---------------------- */\r\n\r\n#ifndef GL_AMD_depth_clamp_separate\r\n#define GL_AMD_depth_clamp_separate 1\r\n\r\n#define GL_DEPTH_CLAMP_NEAR_AMD 0x901E\r\n#define GL_DEPTH_CLAMP_FAR_AMD 0x901F\r\n\r\n#define GLEW_AMD_depth_clamp_separate GLEW_GET_VAR(__GLEW_AMD_depth_clamp_separate)\r\n\r\n#endif /* GL_AMD_depth_clamp_separate */\r\n\r\n/* ----------------------- GL_AMD_draw_buffers_blend ----------------------- */\r\n\r\n#ifndef GL_AMD_draw_buffers_blend\r\n#define GL_AMD_draw_buffers_blend 1\r\n\r\ntypedef void (GLAPIENTRY * PFNGLBLENDEQUATIONINDEXEDAMDPROC) (GLuint buf, GLenum mode);\r\ntypedef void (GLAPIENTRY * PFNGLBLENDEQUATIONSEPARATEINDEXEDAMDPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha);\r\ntypedef void (GLAPIENTRY * PFNGLBLENDFUNCINDEXEDAMDPROC) (GLuint buf, GLenum src, GLenum dst);\r\ntypedef void (GLAPIENTRY * PFNGLBLENDFUNCSEPARATEINDEXEDAMDPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);\r\n\r\n#define glBlendEquationIndexedAMD GLEW_GET_FUN(__glewBlendEquationIndexedAMD)\r\n#define glBlendEquationSeparateIndexedAMD GLEW_GET_FUN(__glewBlendEquationSeparateIndexedAMD)\r\n#define glBlendFuncIndexedAMD GLEW_GET_FUN(__glewBlendFuncIndexedAMD)\r\n#define glBlendFuncSeparateIndexedAMD GLEW_GET_FUN(__glewBlendFuncSeparateIndexedAMD)\r\n\r\n#define GLEW_AMD_draw_buffers_blend GLEW_GET_VAR(__GLEW_AMD_draw_buffers_blend)\r\n\r\n#endif /* GL_AMD_draw_buffers_blend */\r\n\r\n/* --------------------------- GL_AMD_gcn_shader --------------------------- */\r\n\r\n#ifndef GL_AMD_gcn_shader\r\n#define GL_AMD_gcn_shader 1\r\n\r\n#define GLEW_AMD_gcn_shader GLEW_GET_VAR(__GLEW_AMD_gcn_shader)\r\n\r\n#endif /* GL_AMD_gcn_shader */\r\n\r\n/* ------------------------ GL_AMD_gpu_shader_int64 ------------------------ */\r\n\r\n#ifndef GL_AMD_gpu_shader_int64\r\n#define GL_AMD_gpu_shader_int64 1\r\n\r\n#define GLEW_AMD_gpu_shader_int64 GLEW_GET_VAR(__GLEW_AMD_gpu_shader_int64)\r\n\r\n#endif /* GL_AMD_gpu_shader_int64 */\r\n\r\n/* ---------------------- GL_AMD_interleaved_elements ---------------------- */\r\n\r\n#ifndef GL_AMD_interleaved_elements\r\n#define GL_AMD_interleaved_elements 1\r\n\r\n#define GL_RED 0x1903\r\n#define GL_GREEN 0x1904\r\n#define GL_BLUE 0x1905\r\n#define GL_ALPHA 0x1906\r\n#define GL_RG8UI 0x8238\r\n#define GL_RG16UI 0x823A\r\n#define GL_RGBA8UI 0x8D7C\r\n#define GL_VERTEX_ELEMENT_SWIZZLE_AMD 0x91A4\r\n#define GL_VERTEX_ID_SWIZZLE_AMD 0x91A5\r\n\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBPARAMETERIAMDPROC) (GLuint index, GLenum pname, GLint param);\r\n\r\n#define glVertexAttribParameteriAMD GLEW_GET_FUN(__glewVertexAttribParameteriAMD)\r\n\r\n#define GLEW_AMD_interleaved_elements GLEW_GET_VAR(__GLEW_AMD_interleaved_elements)\r\n\r\n#endif /* GL_AMD_interleaved_elements */\r\n\r\n/* ----------------------- GL_AMD_multi_draw_indirect ---------------------- */\r\n\r\n#ifndef GL_AMD_multi_draw_indirect\r\n#define GL_AMD_multi_draw_indirect 1\r\n\r\ntypedef void (GLAPIENTRY * PFNGLMULTIDRAWARRAYSINDIRECTAMDPROC) (GLenum mode, const void *indirect, GLsizei primcount, GLsizei stride);\r\ntypedef void (GLAPIENTRY * PFNGLMULTIDRAWELEMENTSINDIRECTAMDPROC) (GLenum mode, GLenum type, const void *indirect, GLsizei primcount, GLsizei stride);\r\n\r\n#define glMultiDrawArraysIndirectAMD GLEW_GET_FUN(__glewMultiDrawArraysIndirectAMD)\r\n#define glMultiDrawElementsIndirectAMD GLEW_GET_FUN(__glewMultiDrawElementsIndirectAMD)\r\n\r\n#define GLEW_AMD_multi_draw_indirect GLEW_GET_VAR(__GLEW_AMD_multi_draw_indirect)\r\n\r\n#endif /* GL_AMD_multi_draw_indirect */\r\n\r\n/* ------------------------- GL_AMD_name_gen_delete ------------------------ */\r\n\r\n#ifndef GL_AMD_name_gen_delete\r\n#define GL_AMD_name_gen_delete 1\r\n\r\n#define GL_DATA_BUFFER_AMD 0x9151\r\n#define GL_PERFORMANCE_MONITOR_AMD 0x9152\r\n#define GL_QUERY_OBJECT_AMD 0x9153\r\n#define GL_VERTEX_ARRAY_OBJECT_AMD 0x9154\r\n#define GL_SAMPLER_OBJECT_AMD 0x9155\r\n\r\ntypedef void (GLAPIENTRY * PFNGLDELETENAMESAMDPROC) (GLenum identifier, GLuint num, const GLuint* names);\r\ntypedef void (GLAPIENTRY * PFNGLGENNAMESAMDPROC) (GLenum identifier, GLuint num, GLuint* names);\r\ntypedef GLboolean (GLAPIENTRY * PFNGLISNAMEAMDPROC) (GLenum identifier, GLuint name);\r\n\r\n#define glDeleteNamesAMD GLEW_GET_FUN(__glewDeleteNamesAMD)\r\n#define glGenNamesAMD GLEW_GET_FUN(__glewGenNamesAMD)\r\n#define glIsNameAMD GLEW_GET_FUN(__glewIsNameAMD)\r\n\r\n#define GLEW_AMD_name_gen_delete GLEW_GET_VAR(__GLEW_AMD_name_gen_delete)\r\n\r\n#endif /* GL_AMD_name_gen_delete */\r\n\r\n/* ---------------------- GL_AMD_occlusion_query_event --------------------- */\r\n\r\n#ifndef GL_AMD_occlusion_query_event\r\n#define GL_AMD_occlusion_query_event 1\r\n\r\n#define GL_QUERY_DEPTH_PASS_EVENT_BIT_AMD 0x00000001\r\n#define GL_QUERY_DEPTH_FAIL_EVENT_BIT_AMD 0x00000002\r\n#define GL_QUERY_STENCIL_FAIL_EVENT_BIT_AMD 0x00000004\r\n#define GL_QUERY_DEPTH_BOUNDS_FAIL_EVENT_BIT_AMD 0x00000008\r\n#define GL_OCCLUSION_QUERY_EVENT_MASK_AMD 0x874F\r\n#define GL_QUERY_ALL_EVENT_BITS_AMD 0xFFFFFFFF\r\n\r\ntypedef void (GLAPIENTRY * PFNGLQUERYOBJECTPARAMETERUIAMDPROC) (GLenum target, GLuint id, GLenum pname, GLuint param);\r\n\r\n#define glQueryObjectParameteruiAMD GLEW_GET_FUN(__glewQueryObjectParameteruiAMD)\r\n\r\n#define GLEW_AMD_occlusion_query_event GLEW_GET_VAR(__GLEW_AMD_occlusion_query_event)\r\n\r\n#endif /* GL_AMD_occlusion_query_event */\r\n\r\n/* ----------------------- GL_AMD_performance_monitor ---------------------- */\r\n\r\n#ifndef GL_AMD_performance_monitor\r\n#define GL_AMD_performance_monitor 1\r\n\r\n#define GL_COUNTER_TYPE_AMD 0x8BC0\r\n#define GL_COUNTER_RANGE_AMD 0x8BC1\r\n#define GL_UNSIGNED_INT64_AMD 0x8BC2\r\n#define GL_PERCENTAGE_AMD 0x8BC3\r\n#define GL_PERFMON_RESULT_AVAILABLE_AMD 0x8BC4\r\n#define GL_PERFMON_RESULT_SIZE_AMD 0x8BC5\r\n#define GL_PERFMON_RESULT_AMD 0x8BC6\r\n\r\ntypedef void (GLAPIENTRY * PFNGLBEGINPERFMONITORAMDPROC) (GLuint monitor);\r\ntypedef void (GLAPIENTRY * PFNGLDELETEPERFMONITORSAMDPROC) (GLsizei n, GLuint* monitors);\r\ntypedef void (GLAPIENTRY * PFNGLENDPERFMONITORAMDPROC) (GLuint monitor);\r\ntypedef void (GLAPIENTRY * PFNGLGENPERFMONITORSAMDPROC) (GLsizei n, GLuint* monitors);\r\ntypedef void (GLAPIENTRY * PFNGLGETPERFMONITORCOUNTERDATAAMDPROC) (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint* data, GLint *bytesWritten);\r\ntypedef void (GLAPIENTRY * PFNGLGETPERFMONITORCOUNTERINFOAMDPROC) (GLuint group, GLuint counter, GLenum pname, void *data);\r\ntypedef void (GLAPIENTRY * PFNGLGETPERFMONITORCOUNTERSTRINGAMDPROC) (GLuint group, GLuint counter, GLsizei bufSize, GLsizei* length, GLchar *counterString);\r\ntypedef void (GLAPIENTRY * PFNGLGETPERFMONITORCOUNTERSAMDPROC) (GLuint group, GLint* numCounters, GLint *maxActiveCounters, GLsizei countersSize, GLuint *counters);\r\ntypedef void (GLAPIENTRY * PFNGLGETPERFMONITORGROUPSTRINGAMDPROC) (GLuint group, GLsizei bufSize, GLsizei* length, GLchar *groupString);\r\ntypedef void (GLAPIENTRY * PFNGLGETPERFMONITORGROUPSAMDPROC) (GLint* numGroups, GLsizei groupsSize, GLuint *groups);\r\ntypedef void (GLAPIENTRY * PFNGLSELECTPERFMONITORCOUNTERSAMDPROC) (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint* counterList);\r\n\r\n#define glBeginPerfMonitorAMD GLEW_GET_FUN(__glewBeginPerfMonitorAMD)\r\n#define glDeletePerfMonitorsAMD GLEW_GET_FUN(__glewDeletePerfMonitorsAMD)\r\n#define glEndPerfMonitorAMD GLEW_GET_FUN(__glewEndPerfMonitorAMD)\r\n#define glGenPerfMonitorsAMD GLEW_GET_FUN(__glewGenPerfMonitorsAMD)\r\n#define glGetPerfMonitorCounterDataAMD GLEW_GET_FUN(__glewGetPerfMonitorCounterDataAMD)\r\n#define glGetPerfMonitorCounterInfoAMD GLEW_GET_FUN(__glewGetPerfMonitorCounterInfoAMD)\r\n#define glGetPerfMonitorCounterStringAMD GLEW_GET_FUN(__glewGetPerfMonitorCounterStringAMD)\r\n#define glGetPerfMonitorCountersAMD GLEW_GET_FUN(__glewGetPerfMonitorCountersAMD)\r\n#define glGetPerfMonitorGroupStringAMD GLEW_GET_FUN(__glewGetPerfMonitorGroupStringAMD)\r\n#define glGetPerfMonitorGroupsAMD GLEW_GET_FUN(__glewGetPerfMonitorGroupsAMD)\r\n#define glSelectPerfMonitorCountersAMD GLEW_GET_FUN(__glewSelectPerfMonitorCountersAMD)\r\n\r\n#define GLEW_AMD_performance_monitor GLEW_GET_VAR(__GLEW_AMD_performance_monitor)\r\n\r\n#endif /* GL_AMD_performance_monitor */\r\n\r\n/* -------------------------- GL_AMD_pinned_memory ------------------------- */\r\n\r\n#ifndef GL_AMD_pinned_memory\r\n#define GL_AMD_pinned_memory 1\r\n\r\n#define GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD 0x9160\r\n\r\n#define GLEW_AMD_pinned_memory GLEW_GET_VAR(__GLEW_AMD_pinned_memory)\r\n\r\n#endif /* GL_AMD_pinned_memory */\r\n\r\n/* ----------------------- GL_AMD_query_buffer_object ---------------------- */\r\n\r\n#ifndef GL_AMD_query_buffer_object\r\n#define GL_AMD_query_buffer_object 1\r\n\r\n#define GL_QUERY_BUFFER_AMD 0x9192\r\n#define GL_QUERY_BUFFER_BINDING_AMD 0x9193\r\n#define GL_QUERY_RESULT_NO_WAIT_AMD 0x9194\r\n\r\n#define GLEW_AMD_query_buffer_object GLEW_GET_VAR(__GLEW_AMD_query_buffer_object)\r\n\r\n#endif /* GL_AMD_query_buffer_object */\r\n\r\n/* ------------------------ GL_AMD_sample_positions ------------------------ */\r\n\r\n#ifndef GL_AMD_sample_positions\r\n#define GL_AMD_sample_positions 1\r\n\r\n#define GL_SUBSAMPLE_DISTANCE_AMD 0x883F\r\n\r\ntypedef void (GLAPIENTRY * PFNGLSETMULTISAMPLEFVAMDPROC) (GLenum pname, GLuint index, const GLfloat* val);\r\n\r\n#define glSetMultisamplefvAMD GLEW_GET_FUN(__glewSetMultisamplefvAMD)\r\n\r\n#define GLEW_AMD_sample_positions GLEW_GET_VAR(__GLEW_AMD_sample_positions)\r\n\r\n#endif /* GL_AMD_sample_positions */\r\n\r\n/* ------------------ GL_AMD_seamless_cubemap_per_texture ------------------ */\r\n\r\n#ifndef GL_AMD_seamless_cubemap_per_texture\r\n#define GL_AMD_seamless_cubemap_per_texture 1\r\n\r\n#define GL_TEXTURE_CUBE_MAP_SEAMLESS_ARB 0x884F\r\n\r\n#define GLEW_AMD_seamless_cubemap_per_texture GLEW_GET_VAR(__GLEW_AMD_seamless_cubemap_per_texture)\r\n\r\n#endif /* GL_AMD_seamless_cubemap_per_texture */\r\n\r\n/* -------------------- GL_AMD_shader_atomic_counter_ops ------------------- */\r\n\r\n#ifndef GL_AMD_shader_atomic_counter_ops\r\n#define GL_AMD_shader_atomic_counter_ops 1\r\n\r\n#define GLEW_AMD_shader_atomic_counter_ops GLEW_GET_VAR(__GLEW_AMD_shader_atomic_counter_ops)\r\n\r\n#endif /* GL_AMD_shader_atomic_counter_ops */\r\n\r\n/* ---------------------- GL_AMD_shader_stencil_export --------------------- */\r\n\r\n#ifndef GL_AMD_shader_stencil_export\r\n#define GL_AMD_shader_stencil_export 1\r\n\r\n#define GLEW_AMD_shader_stencil_export GLEW_GET_VAR(__GLEW_AMD_shader_stencil_export)\r\n\r\n#endif /* GL_AMD_shader_stencil_export */\r\n\r\n/* ------------------- GL_AMD_shader_stencil_value_export ------------------ */\r\n\r\n#ifndef GL_AMD_shader_stencil_value_export\r\n#define GL_AMD_shader_stencil_value_export 1\r\n\r\n#define GLEW_AMD_shader_stencil_value_export GLEW_GET_VAR(__GLEW_AMD_shader_stencil_value_export)\r\n\r\n#endif /* GL_AMD_shader_stencil_value_export */\r\n\r\n/* ---------------------- GL_AMD_shader_trinary_minmax --------------------- */\r\n\r\n#ifndef GL_AMD_shader_trinary_minmax\r\n#define GL_AMD_shader_trinary_minmax 1\r\n\r\n#define GLEW_AMD_shader_trinary_minmax GLEW_GET_VAR(__GLEW_AMD_shader_trinary_minmax)\r\n\r\n#endif /* GL_AMD_shader_trinary_minmax */\r\n\r\n/* ------------------------- GL_AMD_sparse_texture ------------------------- */\r\n\r\n#ifndef GL_AMD_sparse_texture\r\n#define GL_AMD_sparse_texture 1\r\n\r\n#define GL_TEXTURE_STORAGE_SPARSE_BIT_AMD 0x00000001\r\n#define GL_VIRTUAL_PAGE_SIZE_X_AMD 0x9195\r\n#define GL_VIRTUAL_PAGE_SIZE_Y_AMD 0x9196\r\n#define GL_VIRTUAL_PAGE_SIZE_Z_AMD 0x9197\r\n#define GL_MAX_SPARSE_TEXTURE_SIZE_AMD 0x9198\r\n#define GL_MAX_SPARSE_3D_TEXTURE_SIZE_AMD 0x9199\r\n#define GL_MAX_SPARSE_ARRAY_TEXTURE_LAYERS 0x919A\r\n#define GL_MIN_SPARSE_LEVEL_AMD 0x919B\r\n#define GL_MIN_LOD_WARNING_AMD 0x919C\r\n\r\ntypedef void (GLAPIENTRY * PFNGLTEXSTORAGESPARSEAMDPROC) (GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei layers, GLbitfield flags);\r\ntypedef void (GLAPIENTRY * PFNGLTEXTURESTORAGESPARSEAMDPROC) (GLuint texture, GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei layers, GLbitfield flags);\r\n\r\n#define glTexStorageSparseAMD GLEW_GET_FUN(__glewTexStorageSparseAMD)\r\n#define glTextureStorageSparseAMD GLEW_GET_FUN(__glewTextureStorageSparseAMD)\r\n\r\n#define GLEW_AMD_sparse_texture GLEW_GET_VAR(__GLEW_AMD_sparse_texture)\r\n\r\n#endif /* GL_AMD_sparse_texture */\r\n\r\n/* ------------------- GL_AMD_stencil_operation_extended ------------------- */\r\n\r\n#ifndef GL_AMD_stencil_operation_extended\r\n#define GL_AMD_stencil_operation_extended 1\r\n\r\n#define GL_SET_AMD 0x874A\r\n#define GL_REPLACE_VALUE_AMD 0x874B\r\n#define GL_STENCIL_OP_VALUE_AMD 0x874C\r\n#define GL_STENCIL_BACK_OP_VALUE_AMD 0x874D\r\n\r\ntypedef void (GLAPIENTRY * PFNGLSTENCILOPVALUEAMDPROC) (GLenum face, GLuint value);\r\n\r\n#define glStencilOpValueAMD GLEW_GET_FUN(__glewStencilOpValueAMD)\r\n\r\n#define GLEW_AMD_stencil_operation_extended GLEW_GET_VAR(__GLEW_AMD_stencil_operation_extended)\r\n\r\n#endif /* GL_AMD_stencil_operation_extended */\r\n\r\n/* ------------------------ GL_AMD_texture_texture4 ------------------------ */\r\n\r\n#ifndef GL_AMD_texture_texture4\r\n#define GL_AMD_texture_texture4 1\r\n\r\n#define GLEW_AMD_texture_texture4 GLEW_GET_VAR(__GLEW_AMD_texture_texture4)\r\n\r\n#endif /* GL_AMD_texture_texture4 */\r\n\r\n/* --------------- GL_AMD_transform_feedback3_lines_triangles -------------- */\r\n\r\n#ifndef GL_AMD_transform_feedback3_lines_triangles\r\n#define GL_AMD_transform_feedback3_lines_triangles 1\r\n\r\n#define GLEW_AMD_transform_feedback3_lines_triangles GLEW_GET_VAR(__GLEW_AMD_transform_feedback3_lines_triangles)\r\n\r\n#endif /* GL_AMD_transform_feedback3_lines_triangles */\r\n\r\n/* ----------------------- GL_AMD_transform_feedback4 ---------------------- */\r\n\r\n#ifndef GL_AMD_transform_feedback4\r\n#define GL_AMD_transform_feedback4 1\r\n\r\n#define GL_STREAM_RASTERIZATION_AMD 0x91A0\r\n\r\n#define GLEW_AMD_transform_feedback4 GLEW_GET_VAR(__GLEW_AMD_transform_feedback4)\r\n\r\n#endif /* GL_AMD_transform_feedback4 */\r\n\r\n/* ----------------------- GL_AMD_vertex_shader_layer ---------------------- */\r\n\r\n#ifndef GL_AMD_vertex_shader_layer\r\n#define GL_AMD_vertex_shader_layer 1\r\n\r\n#define GLEW_AMD_vertex_shader_layer GLEW_GET_VAR(__GLEW_AMD_vertex_shader_layer)\r\n\r\n#endif /* GL_AMD_vertex_shader_layer */\r\n\r\n/* -------------------- GL_AMD_vertex_shader_tessellator ------------------- */\r\n\r\n#ifndef GL_AMD_vertex_shader_tessellator\r\n#define GL_AMD_vertex_shader_tessellator 1\r\n\r\n#define GL_SAMPLER_BUFFER_AMD 0x9001\r\n#define GL_INT_SAMPLER_BUFFER_AMD 0x9002\r\n#define GL_UNSIGNED_INT_SAMPLER_BUFFER_AMD 0x9003\r\n#define GL_TESSELLATION_MODE_AMD 0x9004\r\n#define GL_TESSELLATION_FACTOR_AMD 0x9005\r\n#define GL_DISCRETE_AMD 0x9006\r\n#define GL_CONTINUOUS_AMD 0x9007\r\n\r\ntypedef void (GLAPIENTRY * PFNGLTESSELLATIONFACTORAMDPROC) (GLfloat factor);\r\ntypedef void (GLAPIENTRY * PFNGLTESSELLATIONMODEAMDPROC) (GLenum mode);\r\n\r\n#define glTessellationFactorAMD GLEW_GET_FUN(__glewTessellationFactorAMD)\r\n#define glTessellationModeAMD GLEW_GET_FUN(__glewTessellationModeAMD)\r\n\r\n#define GLEW_AMD_vertex_shader_tessellator GLEW_GET_VAR(__GLEW_AMD_vertex_shader_tessellator)\r\n\r\n#endif /* GL_AMD_vertex_shader_tessellator */\r\n\r\n/* ------------------ GL_AMD_vertex_shader_viewport_index ------------------ */\r\n\r\n#ifndef GL_AMD_vertex_shader_viewport_index\r\n#define GL_AMD_vertex_shader_viewport_index 1\r\n\r\n#define GLEW_AMD_vertex_shader_viewport_index GLEW_GET_VAR(__GLEW_AMD_vertex_shader_viewport_index)\r\n\r\n#endif /* GL_AMD_vertex_shader_viewport_index */\r\n\r\n/* ------------------------- GL_ANGLE_depth_texture ------------------------ */\r\n\r\n#ifndef GL_ANGLE_depth_texture\r\n#define GL_ANGLE_depth_texture 1\r\n\r\n#define GLEW_ANGLE_depth_texture GLEW_GET_VAR(__GLEW_ANGLE_depth_texture)\r\n\r\n#endif /* GL_ANGLE_depth_texture */\r\n\r\n/* ----------------------- GL_ANGLE_framebuffer_blit ----------------------- */\r\n\r\n#ifndef GL_ANGLE_framebuffer_blit\r\n#define GL_ANGLE_framebuffer_blit 1\r\n\r\n#define GL_DRAW_FRAMEBUFFER_BINDING_ANGLE 0x8CA6\r\n#define GL_READ_FRAMEBUFFER_ANGLE 0x8CA8\r\n#define GL_DRAW_FRAMEBUFFER_ANGLE 0x8CA9\r\n#define GL_READ_FRAMEBUFFER_BINDING_ANGLE 0x8CAA\r\n\r\ntypedef void (GLAPIENTRY * PFNGLBLITFRAMEBUFFERANGLEPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);\r\n\r\n#define glBlitFramebufferANGLE GLEW_GET_FUN(__glewBlitFramebufferANGLE)\r\n\r\n#define GLEW_ANGLE_framebuffer_blit GLEW_GET_VAR(__GLEW_ANGLE_framebuffer_blit)\r\n\r\n#endif /* GL_ANGLE_framebuffer_blit */\r\n\r\n/* -------------------- GL_ANGLE_framebuffer_multisample ------------------- */\r\n\r\n#ifndef GL_ANGLE_framebuffer_multisample\r\n#define GL_ANGLE_framebuffer_multisample 1\r\n\r\n#define GL_RENDERBUFFER_SAMPLES_ANGLE 0x8CAB\r\n#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_ANGLE 0x8D56\r\n#define GL_MAX_SAMPLES_ANGLE 0x8D57\r\n\r\ntypedef void (GLAPIENTRY * PFNGLRENDERBUFFERSTORAGEMULTISAMPLEANGLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);\r\n\r\n#define glRenderbufferStorageMultisampleANGLE GLEW_GET_FUN(__glewRenderbufferStorageMultisampleANGLE)\r\n\r\n#define GLEW_ANGLE_framebuffer_multisample GLEW_GET_VAR(__GLEW_ANGLE_framebuffer_multisample)\r\n\r\n#endif /* GL_ANGLE_framebuffer_multisample */\r\n\r\n/* ----------------------- GL_ANGLE_instanced_arrays ----------------------- */\r\n\r\n#ifndef GL_ANGLE_instanced_arrays\r\n#define GL_ANGLE_instanced_arrays 1\r\n\r\n#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE 0x88FE\r\n\r\ntypedef void (GLAPIENTRY * PFNGLDRAWARRAYSINSTANCEDANGLEPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount);\r\ntypedef void (GLAPIENTRY * PFNGLDRAWELEMENTSINSTANCEDANGLEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBDIVISORANGLEPROC) (GLuint index, GLuint divisor);\r\n\r\n#define glDrawArraysInstancedANGLE GLEW_GET_FUN(__glewDrawArraysInstancedANGLE)\r\n#define glDrawElementsInstancedANGLE GLEW_GET_FUN(__glewDrawElementsInstancedANGLE)\r\n#define glVertexAttribDivisorANGLE GLEW_GET_FUN(__glewVertexAttribDivisorANGLE)\r\n\r\n#define GLEW_ANGLE_instanced_arrays GLEW_GET_VAR(__GLEW_ANGLE_instanced_arrays)\r\n\r\n#endif /* GL_ANGLE_instanced_arrays */\r\n\r\n/* -------------------- GL_ANGLE_pack_reverse_row_order -------------------- */\r\n\r\n#ifndef GL_ANGLE_pack_reverse_row_order\r\n#define GL_ANGLE_pack_reverse_row_order 1\r\n\r\n#define GL_PACK_REVERSE_ROW_ORDER_ANGLE 0x93A4\r\n\r\n#define GLEW_ANGLE_pack_reverse_row_order GLEW_GET_VAR(__GLEW_ANGLE_pack_reverse_row_order)\r\n\r\n#endif /* GL_ANGLE_pack_reverse_row_order */\r\n\r\n/* ------------------------ GL_ANGLE_program_binary ------------------------ */\r\n\r\n#ifndef GL_ANGLE_program_binary\r\n#define GL_ANGLE_program_binary 1\r\n\r\n#define GL_PROGRAM_BINARY_ANGLE 0x93A6\r\n\r\n#define GLEW_ANGLE_program_binary GLEW_GET_VAR(__GLEW_ANGLE_program_binary)\r\n\r\n#endif /* GL_ANGLE_program_binary */\r\n\r\n/* ------------------- GL_ANGLE_texture_compression_dxt1 ------------------- */\r\n\r\n#ifndef GL_ANGLE_texture_compression_dxt1\r\n#define GL_ANGLE_texture_compression_dxt1 1\r\n\r\n#define GL_COMPRESSED_RGB_S3TC_DXT1_ANGLE 0x83F0\r\n#define GL_COMPRESSED_RGBA_S3TC_DXT1_ANGLE 0x83F1\r\n#define GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE 0x83F2\r\n#define GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE 0x83F3\r\n\r\n#define GLEW_ANGLE_texture_compression_dxt1 GLEW_GET_VAR(__GLEW_ANGLE_texture_compression_dxt1)\r\n\r\n#endif /* GL_ANGLE_texture_compression_dxt1 */\r\n\r\n/* ------------------- GL_ANGLE_texture_compression_dxt3 ------------------- */\r\n\r\n#ifndef GL_ANGLE_texture_compression_dxt3\r\n#define GL_ANGLE_texture_compression_dxt3 1\r\n\r\n#define GL_COMPRESSED_RGB_S3TC_DXT1_ANGLE 0x83F0\r\n#define GL_COMPRESSED_RGBA_S3TC_DXT1_ANGLE 0x83F1\r\n#define GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE 0x83F2\r\n#define GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE 0x83F3\r\n\r\n#define GLEW_ANGLE_texture_compression_dxt3 GLEW_GET_VAR(__GLEW_ANGLE_texture_compression_dxt3)\r\n\r\n#endif /* GL_ANGLE_texture_compression_dxt3 */\r\n\r\n/* ------------------- GL_ANGLE_texture_compression_dxt5 ------------------- */\r\n\r\n#ifndef GL_ANGLE_texture_compression_dxt5\r\n#define GL_ANGLE_texture_compression_dxt5 1\r\n\r\n#define GL_COMPRESSED_RGB_S3TC_DXT1_ANGLE 0x83F0\r\n#define GL_COMPRESSED_RGBA_S3TC_DXT1_ANGLE 0x83F1\r\n#define GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE 0x83F2\r\n#define GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE 0x83F3\r\n\r\n#define GLEW_ANGLE_texture_compression_dxt5 GLEW_GET_VAR(__GLEW_ANGLE_texture_compression_dxt5)\r\n\r\n#endif /* GL_ANGLE_texture_compression_dxt5 */\r\n\r\n/* ------------------------- GL_ANGLE_texture_usage ------------------------ */\r\n\r\n#ifndef GL_ANGLE_texture_usage\r\n#define GL_ANGLE_texture_usage 1\r\n\r\n#define GL_TEXTURE_USAGE_ANGLE 0x93A2\r\n#define GL_FRAMEBUFFER_ATTACHMENT_ANGLE 0x93A3\r\n\r\n#define GLEW_ANGLE_texture_usage GLEW_GET_VAR(__GLEW_ANGLE_texture_usage)\r\n\r\n#endif /* GL_ANGLE_texture_usage */\r\n\r\n/* -------------------------- GL_ANGLE_timer_query ------------------------- */\r\n\r\n#ifndef GL_ANGLE_timer_query\r\n#define GL_ANGLE_timer_query 1\r\n\r\n#define GL_QUERY_COUNTER_BITS_ANGLE 0x8864\r\n#define GL_CURRENT_QUERY_ANGLE 0x8865\r\n#define GL_QUERY_RESULT_ANGLE 0x8866\r\n#define GL_QUERY_RESULT_AVAILABLE_ANGLE 0x8867\r\n#define GL_TIME_ELAPSED_ANGLE 0x88BF\r\n#define GL_TIMESTAMP_ANGLE 0x8E28\r\n\r\ntypedef void (GLAPIENTRY * PFNGLBEGINQUERYANGLEPROC) (GLenum target, GLuint id);\r\ntypedef void (GLAPIENTRY * PFNGLDELETEQUERIESANGLEPROC) (GLsizei n, const GLuint* ids);\r\ntypedef void (GLAPIENTRY * PFNGLENDQUERYANGLEPROC) (GLenum target);\r\ntypedef void (GLAPIENTRY * PFNGLGENQUERIESANGLEPROC) (GLsizei n, GLuint* ids);\r\ntypedef void (GLAPIENTRY * PFNGLGETQUERYOBJECTI64VANGLEPROC) (GLuint id, GLenum pname, GLint64* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETQUERYOBJECTIVANGLEPROC) (GLuint id, GLenum pname, GLint* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETQUERYOBJECTUI64VANGLEPROC) (GLuint id, GLenum pname, GLuint64* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETQUERYOBJECTUIVANGLEPROC) (GLuint id, GLenum pname, GLuint* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETQUERYIVANGLEPROC) (GLenum target, GLenum pname, GLint* params);\r\ntypedef GLboolean (GLAPIENTRY * PFNGLISQUERYANGLEPROC) (GLuint id);\r\ntypedef void (GLAPIENTRY * PFNGLQUERYCOUNTERANGLEPROC) (GLuint id, GLenum target);\r\n\r\n#define glBeginQueryANGLE GLEW_GET_FUN(__glewBeginQueryANGLE)\r\n#define glDeleteQueriesANGLE GLEW_GET_FUN(__glewDeleteQueriesANGLE)\r\n#define glEndQueryANGLE GLEW_GET_FUN(__glewEndQueryANGLE)\r\n#define glGenQueriesANGLE GLEW_GET_FUN(__glewGenQueriesANGLE)\r\n#define glGetQueryObjecti64vANGLE GLEW_GET_FUN(__glewGetQueryObjecti64vANGLE)\r\n#define glGetQueryObjectivANGLE GLEW_GET_FUN(__glewGetQueryObjectivANGLE)\r\n#define glGetQueryObjectui64vANGLE GLEW_GET_FUN(__glewGetQueryObjectui64vANGLE)\r\n#define glGetQueryObjectuivANGLE GLEW_GET_FUN(__glewGetQueryObjectuivANGLE)\r\n#define glGetQueryivANGLE GLEW_GET_FUN(__glewGetQueryivANGLE)\r\n#define glIsQueryANGLE GLEW_GET_FUN(__glewIsQueryANGLE)\r\n#define glQueryCounterANGLE GLEW_GET_FUN(__glewQueryCounterANGLE)\r\n\r\n#define GLEW_ANGLE_timer_query GLEW_GET_VAR(__GLEW_ANGLE_timer_query)\r\n\r\n#endif /* GL_ANGLE_timer_query */\r\n\r\n/* ------------------- GL_ANGLE_translated_shader_source ------------------- */\r\n\r\n#ifndef GL_ANGLE_translated_shader_source\r\n#define GL_ANGLE_translated_shader_source 1\r\n\r\n#define GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE 0x93A0\r\n\r\ntypedef void (GLAPIENTRY * PFNGLGETTRANSLATEDSHADERSOURCEANGLEPROC) (GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source);\r\n\r\n#define glGetTranslatedShaderSourceANGLE GLEW_GET_FUN(__glewGetTranslatedShaderSourceANGLE)\r\n\r\n#define GLEW_ANGLE_translated_shader_source GLEW_GET_VAR(__GLEW_ANGLE_translated_shader_source)\r\n\r\n#endif /* GL_ANGLE_translated_shader_source */\r\n\r\n/* ----------------------- GL_APPLE_aux_depth_stencil ---------------------- */\r\n\r\n#ifndef GL_APPLE_aux_depth_stencil\r\n#define GL_APPLE_aux_depth_stencil 1\r\n\r\n#define GL_AUX_DEPTH_STENCIL_APPLE 0x8A14\r\n\r\n#define GLEW_APPLE_aux_depth_stencil GLEW_GET_VAR(__GLEW_APPLE_aux_depth_stencil)\r\n\r\n#endif /* GL_APPLE_aux_depth_stencil */\r\n\r\n/* ------------------------ GL_APPLE_client_storage ------------------------ */\r\n\r\n#ifndef GL_APPLE_client_storage\r\n#define GL_APPLE_client_storage 1\r\n\r\n#define GL_UNPACK_CLIENT_STORAGE_APPLE 0x85B2\r\n\r\n#define GLEW_APPLE_client_storage GLEW_GET_VAR(__GLEW_APPLE_client_storage)\r\n\r\n#endif /* GL_APPLE_client_storage */\r\n\r\n/* ------------------------- GL_APPLE_element_array ------------------------ */\r\n\r\n#ifndef GL_APPLE_element_array\r\n#define GL_APPLE_element_array 1\r\n\r\n#define GL_ELEMENT_ARRAY_APPLE 0x8A0C\r\n#define GL_ELEMENT_ARRAY_TYPE_APPLE 0x8A0D\r\n#define GL_ELEMENT_ARRAY_POINTER_APPLE 0x8A0E\r\n\r\ntypedef void (GLAPIENTRY * PFNGLDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, GLint first, GLsizei count);\r\ntypedef void (GLAPIENTRY * PFNGLDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, GLint first, GLsizei count);\r\ntypedef void (GLAPIENTRY * PFNGLELEMENTPOINTERAPPLEPROC) (GLenum type, const void *pointer);\r\ntypedef void (GLAPIENTRY * PFNGLMULTIDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, const GLint* first, const GLsizei *count, GLsizei primcount);\r\ntypedef void (GLAPIENTRY * PFNGLMULTIDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, const GLint* first, const GLsizei *count, GLsizei primcount);\r\n\r\n#define glDrawElementArrayAPPLE GLEW_GET_FUN(__glewDrawElementArrayAPPLE)\r\n#define glDrawRangeElementArrayAPPLE GLEW_GET_FUN(__glewDrawRangeElementArrayAPPLE)\r\n#define glElementPointerAPPLE GLEW_GET_FUN(__glewElementPointerAPPLE)\r\n#define glMultiDrawElementArrayAPPLE GLEW_GET_FUN(__glewMultiDrawElementArrayAPPLE)\r\n#define glMultiDrawRangeElementArrayAPPLE GLEW_GET_FUN(__glewMultiDrawRangeElementArrayAPPLE)\r\n\r\n#define GLEW_APPLE_element_array GLEW_GET_VAR(__GLEW_APPLE_element_array)\r\n\r\n#endif /* GL_APPLE_element_array */\r\n\r\n/* ----------------------------- GL_APPLE_fence ---------------------------- */\r\n\r\n#ifndef GL_APPLE_fence\r\n#define GL_APPLE_fence 1\r\n\r\n#define GL_DRAW_PIXELS_APPLE 0x8A0A\r\n#define GL_FENCE_APPLE 0x8A0B\r\n\r\ntypedef void (GLAPIENTRY * PFNGLDELETEFENCESAPPLEPROC) (GLsizei n, const GLuint* fences);\r\ntypedef void (GLAPIENTRY * PFNGLFINISHFENCEAPPLEPROC) (GLuint fence);\r\ntypedef void (GLAPIENTRY * PFNGLFINISHOBJECTAPPLEPROC) (GLenum object, GLint name);\r\ntypedef void (GLAPIENTRY * PFNGLGENFENCESAPPLEPROC) (GLsizei n, GLuint* fences);\r\ntypedef GLboolean (GLAPIENTRY * PFNGLISFENCEAPPLEPROC) (GLuint fence);\r\ntypedef void (GLAPIENTRY * PFNGLSETFENCEAPPLEPROC) (GLuint fence);\r\ntypedef GLboolean (GLAPIENTRY * PFNGLTESTFENCEAPPLEPROC) (GLuint fence);\r\ntypedef GLboolean (GLAPIENTRY * PFNGLTESTOBJECTAPPLEPROC) (GLenum object, GLuint name);\r\n\r\n#define glDeleteFencesAPPLE GLEW_GET_FUN(__glewDeleteFencesAPPLE)\r\n#define glFinishFenceAPPLE GLEW_GET_FUN(__glewFinishFenceAPPLE)\r\n#define glFinishObjectAPPLE GLEW_GET_FUN(__glewFinishObjectAPPLE)\r\n#define glGenFencesAPPLE GLEW_GET_FUN(__glewGenFencesAPPLE)\r\n#define glIsFenceAPPLE GLEW_GET_FUN(__glewIsFenceAPPLE)\r\n#define glSetFenceAPPLE GLEW_GET_FUN(__glewSetFenceAPPLE)\r\n#define glTestFenceAPPLE GLEW_GET_FUN(__glewTestFenceAPPLE)\r\n#define glTestObjectAPPLE GLEW_GET_FUN(__glewTestObjectAPPLE)\r\n\r\n#define GLEW_APPLE_fence GLEW_GET_VAR(__GLEW_APPLE_fence)\r\n\r\n#endif /* GL_APPLE_fence */\r\n\r\n/* ------------------------- GL_APPLE_float_pixels ------------------------- */\r\n\r\n#ifndef GL_APPLE_float_pixels\r\n#define GL_APPLE_float_pixels 1\r\n\r\n#define GL_HALF_APPLE 0x140B\r\n#define GL_RGBA_FLOAT32_APPLE 0x8814\r\n#define GL_RGB_FLOAT32_APPLE 0x8815\r\n#define GL_ALPHA_FLOAT32_APPLE 0x8816\r\n#define GL_INTENSITY_FLOAT32_APPLE 0x8817\r\n#define GL_LUMINANCE_FLOAT32_APPLE 0x8818\r\n#define GL_LUMINANCE_ALPHA_FLOAT32_APPLE 0x8819\r\n#define GL_RGBA_FLOAT16_APPLE 0x881A\r\n#define GL_RGB_FLOAT16_APPLE 0x881B\r\n#define GL_ALPHA_FLOAT16_APPLE 0x881C\r\n#define GL_INTENSITY_FLOAT16_APPLE 0x881D\r\n#define GL_LUMINANCE_FLOAT16_APPLE 0x881E\r\n#define GL_LUMINANCE_ALPHA_FLOAT16_APPLE 0x881F\r\n#define GL_COLOR_FLOAT_APPLE 0x8A0F\r\n\r\n#define GLEW_APPLE_float_pixels GLEW_GET_VAR(__GLEW_APPLE_float_pixels)\r\n\r\n#endif /* GL_APPLE_float_pixels */\r\n\r\n/* ---------------------- GL_APPLE_flush_buffer_range ---------------------- */\r\n\r\n#ifndef GL_APPLE_flush_buffer_range\r\n#define GL_APPLE_flush_buffer_range 1\r\n\r\n#define GL_BUFFER_SERIALIZED_MODIFY_APPLE 0x8A12\r\n#define GL_BUFFER_FLUSHING_UNMAP_APPLE 0x8A13\r\n\r\ntypedef void (GLAPIENTRY * PFNGLBUFFERPARAMETERIAPPLEPROC) (GLenum target, GLenum pname, GLint param);\r\ntypedef void (GLAPIENTRY * PFNGLFLUSHMAPPEDBUFFERRANGEAPPLEPROC) (GLenum target, GLintptr offset, GLsizeiptr size);\r\n\r\n#define glBufferParameteriAPPLE GLEW_GET_FUN(__glewBufferParameteriAPPLE)\r\n#define glFlushMappedBufferRangeAPPLE GLEW_GET_FUN(__glewFlushMappedBufferRangeAPPLE)\r\n\r\n#define GLEW_APPLE_flush_buffer_range GLEW_GET_VAR(__GLEW_APPLE_flush_buffer_range)\r\n\r\n#endif /* GL_APPLE_flush_buffer_range */\r\n\r\n/* ----------------------- GL_APPLE_object_purgeable ----------------------- */\r\n\r\n#ifndef GL_APPLE_object_purgeable\r\n#define GL_APPLE_object_purgeable 1\r\n\r\n#define GL_BUFFER_OBJECT_APPLE 0x85B3\r\n#define GL_RELEASED_APPLE 0x8A19\r\n#define GL_VOLATILE_APPLE 0x8A1A\r\n#define GL_RETAINED_APPLE 0x8A1B\r\n#define GL_UNDEFINED_APPLE 0x8A1C\r\n#define GL_PURGEABLE_APPLE 0x8A1D\r\n\r\ntypedef void (GLAPIENTRY * PFNGLGETOBJECTPARAMETERIVAPPLEPROC) (GLenum objectType, GLuint name, GLenum pname, GLint* params);\r\ntypedef GLenum (GLAPIENTRY * PFNGLOBJECTPURGEABLEAPPLEPROC) (GLenum objectType, GLuint name, GLenum option);\r\ntypedef GLenum (GLAPIENTRY * PFNGLOBJECTUNPURGEABLEAPPLEPROC) (GLenum objectType, GLuint name, GLenum option);\r\n\r\n#define glGetObjectParameterivAPPLE GLEW_GET_FUN(__glewGetObjectParameterivAPPLE)\r\n#define glObjectPurgeableAPPLE GLEW_GET_FUN(__glewObjectPurgeableAPPLE)\r\n#define glObjectUnpurgeableAPPLE GLEW_GET_FUN(__glewObjectUnpurgeableAPPLE)\r\n\r\n#define GLEW_APPLE_object_purgeable GLEW_GET_VAR(__GLEW_APPLE_object_purgeable)\r\n\r\n#endif /* GL_APPLE_object_purgeable */\r\n\r\n/* ------------------------- GL_APPLE_pixel_buffer ------------------------- */\r\n\r\n#ifndef GL_APPLE_pixel_buffer\r\n#define GL_APPLE_pixel_buffer 1\r\n\r\n#define GL_MIN_PBUFFER_VIEWPORT_DIMS_APPLE 0x8A10\r\n\r\n#define GLEW_APPLE_pixel_buffer GLEW_GET_VAR(__GLEW_APPLE_pixel_buffer)\r\n\r\n#endif /* GL_APPLE_pixel_buffer */\r\n\r\n/* ---------------------------- GL_APPLE_rgb_422 --------------------------- */\r\n\r\n#ifndef GL_APPLE_rgb_422\r\n#define GL_APPLE_rgb_422 1\r\n\r\n#define GL_UNSIGNED_SHORT_8_8_APPLE 0x85BA\r\n#define GL_UNSIGNED_SHORT_8_8_REV_APPLE 0x85BB\r\n#define GL_RGB_422_APPLE 0x8A1F\r\n#define GL_RGB_RAW_422_APPLE 0x8A51\r\n\r\n#define GLEW_APPLE_rgb_422 GLEW_GET_VAR(__GLEW_APPLE_rgb_422)\r\n\r\n#endif /* GL_APPLE_rgb_422 */\r\n\r\n/* --------------------------- GL_APPLE_row_bytes -------------------------- */\r\n\r\n#ifndef GL_APPLE_row_bytes\r\n#define GL_APPLE_row_bytes 1\r\n\r\n#define GL_PACK_ROW_BYTES_APPLE 0x8A15\r\n#define GL_UNPACK_ROW_BYTES_APPLE 0x8A16\r\n\r\n#define GLEW_APPLE_row_bytes GLEW_GET_VAR(__GLEW_APPLE_row_bytes)\r\n\r\n#endif /* GL_APPLE_row_bytes */\r\n\r\n/* ------------------------ GL_APPLE_specular_vector ----------------------- */\r\n\r\n#ifndef GL_APPLE_specular_vector\r\n#define GL_APPLE_specular_vector 1\r\n\r\n#define GL_LIGHT_MODEL_SPECULAR_VECTOR_APPLE 0x85B0\r\n\r\n#define GLEW_APPLE_specular_vector GLEW_GET_VAR(__GLEW_APPLE_specular_vector)\r\n\r\n#endif /* GL_APPLE_specular_vector */\r\n\r\n/* ------------------------- GL_APPLE_texture_range ------------------------ */\r\n\r\n#ifndef GL_APPLE_texture_range\r\n#define GL_APPLE_texture_range 1\r\n\r\n#define GL_TEXTURE_RANGE_LENGTH_APPLE 0x85B7\r\n#define GL_TEXTURE_RANGE_POINTER_APPLE 0x85B8\r\n#define GL_TEXTURE_STORAGE_HINT_APPLE 0x85BC\r\n#define GL_STORAGE_PRIVATE_APPLE 0x85BD\r\n#define GL_STORAGE_CACHED_APPLE 0x85BE\r\n#define GL_STORAGE_SHARED_APPLE 0x85BF\r\n\r\ntypedef void (GLAPIENTRY * PFNGLGETTEXPARAMETERPOINTERVAPPLEPROC) (GLenum target, GLenum pname, void **params);\r\ntypedef void (GLAPIENTRY * PFNGLTEXTURERANGEAPPLEPROC) (GLenum target, GLsizei length, void *pointer);\r\n\r\n#define glGetTexParameterPointervAPPLE GLEW_GET_FUN(__glewGetTexParameterPointervAPPLE)\r\n#define glTextureRangeAPPLE GLEW_GET_FUN(__glewTextureRangeAPPLE)\r\n\r\n#define GLEW_APPLE_texture_range GLEW_GET_VAR(__GLEW_APPLE_texture_range)\r\n\r\n#endif /* GL_APPLE_texture_range */\r\n\r\n/* ------------------------ GL_APPLE_transform_hint ------------------------ */\r\n\r\n#ifndef GL_APPLE_transform_hint\r\n#define GL_APPLE_transform_hint 1\r\n\r\n#define GL_TRANSFORM_HINT_APPLE 0x85B1\r\n\r\n#define GLEW_APPLE_transform_hint GLEW_GET_VAR(__GLEW_APPLE_transform_hint)\r\n\r\n#endif /* GL_APPLE_transform_hint */\r\n\r\n/* ---------------------- GL_APPLE_vertex_array_object --------------------- */\r\n\r\n#ifndef GL_APPLE_vertex_array_object\r\n#define GL_APPLE_vertex_array_object 1\r\n\r\n#define GL_VERTEX_ARRAY_BINDING_APPLE 0x85B5\r\n\r\ntypedef void (GLAPIENTRY * PFNGLBINDVERTEXARRAYAPPLEPROC) (GLuint array);\r\ntypedef void (GLAPIENTRY * PFNGLDELETEVERTEXARRAYSAPPLEPROC) (GLsizei n, const GLuint* arrays);\r\ntypedef void (GLAPIENTRY * PFNGLGENVERTEXARRAYSAPPLEPROC) (GLsizei n, const GLuint* arrays);\r\ntypedef GLboolean (GLAPIENTRY * PFNGLISVERTEXARRAYAPPLEPROC) (GLuint array);\r\n\r\n#define glBindVertexArrayAPPLE GLEW_GET_FUN(__glewBindVertexArrayAPPLE)\r\n#define glDeleteVertexArraysAPPLE GLEW_GET_FUN(__glewDeleteVertexArraysAPPLE)\r\n#define glGenVertexArraysAPPLE GLEW_GET_FUN(__glewGenVertexArraysAPPLE)\r\n#define glIsVertexArrayAPPLE GLEW_GET_FUN(__glewIsVertexArrayAPPLE)\r\n\r\n#define GLEW_APPLE_vertex_array_object GLEW_GET_VAR(__GLEW_APPLE_vertex_array_object)\r\n\r\n#endif /* GL_APPLE_vertex_array_object */\r\n\r\n/* ---------------------- GL_APPLE_vertex_array_range ---------------------- */\r\n\r\n#ifndef GL_APPLE_vertex_array_range\r\n#define GL_APPLE_vertex_array_range 1\r\n\r\n#define GL_VERTEX_ARRAY_RANGE_APPLE 0x851D\r\n#define GL_VERTEX_ARRAY_RANGE_LENGTH_APPLE 0x851E\r\n#define GL_VERTEX_ARRAY_STORAGE_HINT_APPLE 0x851F\r\n#define GL_MAX_VERTEX_ARRAY_RANGE_ELEMENT_APPLE 0x8520\r\n#define GL_VERTEX_ARRAY_RANGE_POINTER_APPLE 0x8521\r\n#define GL_STORAGE_CLIENT_APPLE 0x85B4\r\n#define GL_STORAGE_CACHED_APPLE 0x85BE\r\n#define GL_STORAGE_SHARED_APPLE 0x85BF\r\n\r\ntypedef void (GLAPIENTRY * PFNGLFLUSHVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, void *pointer);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXARRAYPARAMETERIAPPLEPROC) (GLenum pname, GLint param);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, void *pointer);\r\n\r\n#define glFlushVertexArrayRangeAPPLE GLEW_GET_FUN(__glewFlushVertexArrayRangeAPPLE)\r\n#define glVertexArrayParameteriAPPLE GLEW_GET_FUN(__glewVertexArrayParameteriAPPLE)\r\n#define glVertexArrayRangeAPPLE GLEW_GET_FUN(__glewVertexArrayRangeAPPLE)\r\n\r\n#define GLEW_APPLE_vertex_array_range GLEW_GET_VAR(__GLEW_APPLE_vertex_array_range)\r\n\r\n#endif /* GL_APPLE_vertex_array_range */\r\n\r\n/* ------------------- GL_APPLE_vertex_program_evaluators ------------------ */\r\n\r\n#ifndef GL_APPLE_vertex_program_evaluators\r\n#define GL_APPLE_vertex_program_evaluators 1\r\n\r\n#define GL_VERTEX_ATTRIB_MAP1_APPLE 0x8A00\r\n#define GL_VERTEX_ATTRIB_MAP2_APPLE 0x8A01\r\n#define GL_VERTEX_ATTRIB_MAP1_SIZE_APPLE 0x8A02\r\n#define GL_VERTEX_ATTRIB_MAP1_COEFF_APPLE 0x8A03\r\n#define GL_VERTEX_ATTRIB_MAP1_ORDER_APPLE 0x8A04\r\n#define GL_VERTEX_ATTRIB_MAP1_DOMAIN_APPLE 0x8A05\r\n#define GL_VERTEX_ATTRIB_MAP2_SIZE_APPLE 0x8A06\r\n#define GL_VERTEX_ATTRIB_MAP2_COEFF_APPLE 0x8A07\r\n#define GL_VERTEX_ATTRIB_MAP2_ORDER_APPLE 0x8A08\r\n#define GL_VERTEX_ATTRIB_MAP2_DOMAIN_APPLE 0x8A09\r\n\r\ntypedef void (GLAPIENTRY * PFNGLDISABLEVERTEXATTRIBAPPLEPROC) (GLuint index, GLenum pname);\r\ntypedef void (GLAPIENTRY * PFNGLENABLEVERTEXATTRIBAPPLEPROC) (GLuint index, GLenum pname);\r\ntypedef GLboolean (GLAPIENTRY * PFNGLISVERTEXATTRIBENABLEDAPPLEPROC) (GLuint index, GLenum pname);\r\ntypedef void (GLAPIENTRY * PFNGLMAPVERTEXATTRIB1DAPPLEPROC) (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble* points);\r\ntypedef void (GLAPIENTRY * PFNGLMAPVERTEXATTRIB1FAPPLEPROC) (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat* points);\r\ntypedef void (GLAPIENTRY * PFNGLMAPVERTEXATTRIB2DAPPLEPROC) (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble* points);\r\ntypedef void (GLAPIENTRY * PFNGLMAPVERTEXATTRIB2FAPPLEPROC) (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat* points);\r\n\r\n#define glDisableVertexAttribAPPLE GLEW_GET_FUN(__glewDisableVertexAttribAPPLE)\r\n#define glEnableVertexAttribAPPLE GLEW_GET_FUN(__glewEnableVertexAttribAPPLE)\r\n#define glIsVertexAttribEnabledAPPLE GLEW_GET_FUN(__glewIsVertexAttribEnabledAPPLE)\r\n#define glMapVertexAttrib1dAPPLE GLEW_GET_FUN(__glewMapVertexAttrib1dAPPLE)\r\n#define glMapVertexAttrib1fAPPLE GLEW_GET_FUN(__glewMapVertexAttrib1fAPPLE)\r\n#define glMapVertexAttrib2dAPPLE GLEW_GET_FUN(__glewMapVertexAttrib2dAPPLE)\r\n#define glMapVertexAttrib2fAPPLE GLEW_GET_FUN(__glewMapVertexAttrib2fAPPLE)\r\n\r\n#define GLEW_APPLE_vertex_program_evaluators GLEW_GET_VAR(__GLEW_APPLE_vertex_program_evaluators)\r\n\r\n#endif /* GL_APPLE_vertex_program_evaluators */\r\n\r\n/* --------------------------- GL_APPLE_ycbcr_422 -------------------------- */\r\n\r\n#ifndef GL_APPLE_ycbcr_422\r\n#define GL_APPLE_ycbcr_422 1\r\n\r\n#define GL_YCBCR_422_APPLE 0x85B9\r\n\r\n#define GLEW_APPLE_ycbcr_422 GLEW_GET_VAR(__GLEW_APPLE_ycbcr_422)\r\n\r\n#endif /* GL_APPLE_ycbcr_422 */\r\n\r\n/* ------------------------ GL_ARB_ES2_compatibility ----------------------- */\r\n\r\n#ifndef GL_ARB_ES2_compatibility\r\n#define GL_ARB_ES2_compatibility 1\r\n\r\n#define GL_FIXED 0x140C\r\n#define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A\r\n#define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B\r\n#define GL_RGB565 0x8D62\r\n#define GL_LOW_FLOAT 0x8DF0\r\n#define GL_MEDIUM_FLOAT 0x8DF1\r\n#define GL_HIGH_FLOAT 0x8DF2\r\n#define GL_LOW_INT 0x8DF3\r\n#define GL_MEDIUM_INT 0x8DF4\r\n#define GL_HIGH_INT 0x8DF5\r\n#define GL_SHADER_BINARY_FORMATS 0x8DF8\r\n#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9\r\n#define GL_SHADER_COMPILER 0x8DFA\r\n#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB\r\n#define GL_MAX_VARYING_VECTORS 0x8DFC\r\n#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD\r\n\r\ntypedef int GLfixed;\r\n\r\ntypedef void (GLAPIENTRY * PFNGLCLEARDEPTHFPROC) (GLclampf d);\r\ntypedef void (GLAPIENTRY * PFNGLDEPTHRANGEFPROC) (GLclampf n, GLclampf f);\r\ntypedef void (GLAPIENTRY * PFNGLGETSHADERPRECISIONFORMATPROC) (GLenum shadertype, GLenum precisiontype, GLint* range, GLint *precision);\r\ntypedef void (GLAPIENTRY * PFNGLRELEASESHADERCOMPILERPROC) (void);\r\ntypedef void (GLAPIENTRY * PFNGLSHADERBINARYPROC) (GLsizei count, const GLuint* shaders, GLenum binaryformat, const void*binary, GLsizei length);\r\n\r\n#define glClearDepthf GLEW_GET_FUN(__glewClearDepthf)\r\n#define glDepthRangef GLEW_GET_FUN(__glewDepthRangef)\r\n#define glGetShaderPrecisionFormat GLEW_GET_FUN(__glewGetShaderPrecisionFormat)\r\n#define glReleaseShaderCompiler GLEW_GET_FUN(__glewReleaseShaderCompiler)\r\n#define glShaderBinary GLEW_GET_FUN(__glewShaderBinary)\r\n\r\n#define GLEW_ARB_ES2_compatibility GLEW_GET_VAR(__GLEW_ARB_ES2_compatibility)\r\n\r\n#endif /* GL_ARB_ES2_compatibility */\r\n\r\n/* ----------------------- GL_ARB_ES3_1_compatibility ---------------------- */\r\n\r\n#ifndef GL_ARB_ES3_1_compatibility\r\n#define GL_ARB_ES3_1_compatibility 1\r\n\r\ntypedef void (GLAPIENTRY * PFNGLMEMORYBARRIERBYREGIONPROC) (GLbitfield barriers);\r\n\r\n#define glMemoryBarrierByRegion GLEW_GET_FUN(__glewMemoryBarrierByRegion)\r\n\r\n#define GLEW_ARB_ES3_1_compatibility GLEW_GET_VAR(__GLEW_ARB_ES3_1_compatibility)\r\n\r\n#endif /* GL_ARB_ES3_1_compatibility */\r\n\r\n/* ----------------------- GL_ARB_ES3_2_compatibility ---------------------- */\r\n\r\n#ifndef GL_ARB_ES3_2_compatibility\r\n#define GL_ARB_ES3_2_compatibility 1\r\n\r\n#define GL_PRIMITIVE_BOUNDING_BOX_ARB 0x92BE\r\n#define GL_MULTISAMPLE_LINE_WIDTH_RANGE_ARB 0x9381\r\n#define GL_MULTISAMPLE_LINE_WIDTH_GRANULARITY_ARB 0x9382\r\n\r\ntypedef void (GLAPIENTRY * PFNGLPRIMITIVEBOUNDINGBOXARBPROC) (GLfloat minX, GLfloat minY, GLfloat minZ, GLfloat minW, GLfloat maxX, GLfloat maxY, GLfloat maxZ, GLfloat maxW);\r\n\r\n#define glPrimitiveBoundingBoxARB GLEW_GET_FUN(__glewPrimitiveBoundingBoxARB)\r\n\r\n#define GLEW_ARB_ES3_2_compatibility GLEW_GET_VAR(__GLEW_ARB_ES3_2_compatibility)\r\n\r\n#endif /* GL_ARB_ES3_2_compatibility */\r\n\r\n/* ------------------------ GL_ARB_ES3_compatibility ----------------------- */\r\n\r\n#ifndef GL_ARB_ES3_compatibility\r\n#define GL_ARB_ES3_compatibility 1\r\n\r\n#define GL_TEXTURE_IMMUTABLE_LEVELS 0x82DF\r\n#define GL_PRIMITIVE_RESTART_FIXED_INDEX 0x8D69\r\n#define GL_ANY_SAMPLES_PASSED_CONSERVATIVE 0x8D6A\r\n#define GL_MAX_ELEMENT_INDEX 0x8D6B\r\n#define GL_COMPRESSED_R11_EAC 0x9270\r\n#define GL_COMPRESSED_SIGNED_R11_EAC 0x9271\r\n#define GL_COMPRESSED_RG11_EAC 0x9272\r\n#define GL_COMPRESSED_SIGNED_RG11_EAC 0x9273\r\n#define GL_COMPRESSED_RGB8_ETC2 0x9274\r\n#define GL_COMPRESSED_SRGB8_ETC2 0x9275\r\n#define GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9276\r\n#define GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9277\r\n#define GL_COMPRESSED_RGBA8_ETC2_EAC 0x9278\r\n#define GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC 0x9279\r\n\r\n#define GLEW_ARB_ES3_compatibility GLEW_GET_VAR(__GLEW_ARB_ES3_compatibility)\r\n\r\n#endif /* GL_ARB_ES3_compatibility */\r\n\r\n/* ------------------------ GL_ARB_arrays_of_arrays ------------------------ */\r\n\r\n#ifndef GL_ARB_arrays_of_arrays\r\n#define GL_ARB_arrays_of_arrays 1\r\n\r\n#define GLEW_ARB_arrays_of_arrays GLEW_GET_VAR(__GLEW_ARB_arrays_of_arrays)\r\n\r\n#endif /* GL_ARB_arrays_of_arrays */\r\n\r\n/* -------------------------- GL_ARB_base_instance ------------------------- */\r\n\r\n#ifndef GL_ARB_base_instance\r\n#define GL_ARB_base_instance 1\r\n\r\ntypedef void (GLAPIENTRY * PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount, GLuint baseinstance);\r\ntypedef void (GLAPIENTRY * PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount, GLuint baseinstance);\r\ntypedef void (GLAPIENTRY * PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount, GLint basevertex, GLuint baseinstance);\r\n\r\n#define glDrawArraysInstancedBaseInstance GLEW_GET_FUN(__glewDrawArraysInstancedBaseInstance)\r\n#define glDrawElementsInstancedBaseInstance GLEW_GET_FUN(__glewDrawElementsInstancedBaseInstance)\r\n#define glDrawElementsInstancedBaseVertexBaseInstance GLEW_GET_FUN(__glewDrawElementsInstancedBaseVertexBaseInstance)\r\n\r\n#define GLEW_ARB_base_instance GLEW_GET_VAR(__GLEW_ARB_base_instance)\r\n\r\n#endif /* GL_ARB_base_instance */\r\n\r\n/* ------------------------ GL_ARB_bindless_texture ------------------------ */\r\n\r\n#ifndef GL_ARB_bindless_texture\r\n#define GL_ARB_bindless_texture 1\r\n\r\n#define GL_UNSIGNED_INT64_ARB 0x140F\r\n\r\ntypedef GLuint64 (GLAPIENTRY * PFNGLGETIMAGEHANDLEARBPROC) (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format);\r\ntypedef GLuint64 (GLAPIENTRY * PFNGLGETTEXTUREHANDLEARBPROC) (GLuint texture);\r\ntypedef GLuint64 (GLAPIENTRY * PFNGLGETTEXTURESAMPLERHANDLEARBPROC) (GLuint texture, GLuint sampler);\r\ntypedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBLUI64VARBPROC) (GLuint index, GLenum pname, GLuint64EXT* params);\r\ntypedef GLboolean (GLAPIENTRY * PFNGLISIMAGEHANDLERESIDENTARBPROC) (GLuint64 handle);\r\ntypedef GLboolean (GLAPIENTRY * PFNGLISTEXTUREHANDLERESIDENTARBPROC) (GLuint64 handle);\r\ntypedef void (GLAPIENTRY * PFNGLMAKEIMAGEHANDLENONRESIDENTARBPROC) (GLuint64 handle);\r\ntypedef void (GLAPIENTRY * PFNGLMAKEIMAGEHANDLERESIDENTARBPROC) (GLuint64 handle, GLenum access);\r\ntypedef void (GLAPIENTRY * PFNGLMAKETEXTUREHANDLENONRESIDENTARBPROC) (GLuint64 handle);\r\ntypedef void (GLAPIENTRY * PFNGLMAKETEXTUREHANDLERESIDENTARBPROC) (GLuint64 handle);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMHANDLEUI64ARBPROC) (GLuint program, GLint location, GLuint64 value);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMHANDLEUI64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLuint64* values);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORMHANDLEUI64ARBPROC) (GLint location, GLuint64 value);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORMHANDLEUI64VARBPROC) (GLint location, GLsizei count, const GLuint64* value);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL1UI64ARBPROC) (GLuint index, GLuint64EXT x);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL1UI64VARBPROC) (GLuint index, const GLuint64EXT* v);\r\n\r\n#define glGetImageHandleARB GLEW_GET_FUN(__glewGetImageHandleARB)\r\n#define glGetTextureHandleARB GLEW_GET_FUN(__glewGetTextureHandleARB)\r\n#define glGetTextureSamplerHandleARB GLEW_GET_FUN(__glewGetTextureSamplerHandleARB)\r\n#define glGetVertexAttribLui64vARB GLEW_GET_FUN(__glewGetVertexAttribLui64vARB)\r\n#define glIsImageHandleResidentARB GLEW_GET_FUN(__glewIsImageHandleResidentARB)\r\n#define glIsTextureHandleResidentARB GLEW_GET_FUN(__glewIsTextureHandleResidentARB)\r\n#define glMakeImageHandleNonResidentARB GLEW_GET_FUN(__glewMakeImageHandleNonResidentARB)\r\n#define glMakeImageHandleResidentARB GLEW_GET_FUN(__glewMakeImageHandleResidentARB)\r\n#define glMakeTextureHandleNonResidentARB GLEW_GET_FUN(__glewMakeTextureHandleNonResidentARB)\r\n#define glMakeTextureHandleResidentARB GLEW_GET_FUN(__glewMakeTextureHandleResidentARB)\r\n#define glProgramUniformHandleui64ARB GLEW_GET_FUN(__glewProgramUniformHandleui64ARB)\r\n#define glProgramUniformHandleui64vARB GLEW_GET_FUN(__glewProgramUniformHandleui64vARB)\r\n#define glUniformHandleui64ARB GLEW_GET_FUN(__glewUniformHandleui64ARB)\r\n#define glUniformHandleui64vARB GLEW_GET_FUN(__glewUniformHandleui64vARB)\r\n#define glVertexAttribL1ui64ARB GLEW_GET_FUN(__glewVertexAttribL1ui64ARB)\r\n#define glVertexAttribL1ui64vARB GLEW_GET_FUN(__glewVertexAttribL1ui64vARB)\r\n\r\n#define GLEW_ARB_bindless_texture GLEW_GET_VAR(__GLEW_ARB_bindless_texture)\r\n\r\n#endif /* GL_ARB_bindless_texture */\r\n\r\n/* ----------------------- GL_ARB_blend_func_extended ---------------------- */\r\n\r\n#ifndef GL_ARB_blend_func_extended\r\n#define GL_ARB_blend_func_extended 1\r\n\r\n#define GL_SRC1_COLOR 0x88F9\r\n#define GL_ONE_MINUS_SRC1_COLOR 0x88FA\r\n#define GL_ONE_MINUS_SRC1_ALPHA 0x88FB\r\n#define GL_MAX_DUAL_SOURCE_DRAW_BUFFERS 0x88FC\r\n\r\ntypedef void (GLAPIENTRY * PFNGLBINDFRAGDATALOCATIONINDEXEDPROC) (GLuint program, GLuint colorNumber, GLuint index, const GLchar * name);\r\ntypedef GLint (GLAPIENTRY * PFNGLGETFRAGDATAINDEXPROC) (GLuint program, const GLchar * name);\r\n\r\n#define glBindFragDataLocationIndexed GLEW_GET_FUN(__glewBindFragDataLocationIndexed)\r\n#define glGetFragDataIndex GLEW_GET_FUN(__glewGetFragDataIndex)\r\n\r\n#define GLEW_ARB_blend_func_extended GLEW_GET_VAR(__GLEW_ARB_blend_func_extended)\r\n\r\n#endif /* GL_ARB_blend_func_extended */\r\n\r\n/* ------------------------- GL_ARB_buffer_storage ------------------------- */\r\n\r\n#ifndef GL_ARB_buffer_storage\r\n#define GL_ARB_buffer_storage 1\r\n\r\n#define GL_MAP_READ_BIT 0x0001\r\n#define GL_MAP_WRITE_BIT 0x0002\r\n#define GL_MAP_PERSISTENT_BIT 0x00000040\r\n#define GL_MAP_COHERENT_BIT 0x00000080\r\n#define GL_DYNAMIC_STORAGE_BIT 0x0100\r\n#define GL_CLIENT_STORAGE_BIT 0x0200\r\n#define GL_CLIENT_MAPPED_BUFFER_BARRIER_BIT 0x00004000\r\n#define GL_BUFFER_IMMUTABLE_STORAGE 0x821F\r\n#define GL_BUFFER_STORAGE_FLAGS 0x8220\r\n\r\ntypedef void (GLAPIENTRY * PFNGLBUFFERSTORAGEPROC) (GLenum target, GLsizeiptr size, const void *data, GLbitfield flags);\r\ntypedef void (GLAPIENTRY * PFNGLNAMEDBUFFERSTORAGEEXTPROC) (GLuint buffer, GLsizeiptr size, const void *data, GLbitfield flags);\r\n\r\n#define glBufferStorage GLEW_GET_FUN(__glewBufferStorage)\r\n#define glNamedBufferStorageEXT GLEW_GET_FUN(__glewNamedBufferStorageEXT)\r\n\r\n#define GLEW_ARB_buffer_storage GLEW_GET_VAR(__GLEW_ARB_buffer_storage)\r\n\r\n#endif /* GL_ARB_buffer_storage */\r\n\r\n/* ---------------------------- GL_ARB_cl_event ---------------------------- */\r\n\r\n#ifndef GL_ARB_cl_event\r\n#define GL_ARB_cl_event 1\r\n\r\n#define GL_SYNC_CL_EVENT_ARB 0x8240\r\n#define GL_SYNC_CL_EVENT_COMPLETE_ARB 0x8241\r\n\r\ntypedef struct _cl_context *cl_context;\r\ntypedef struct _cl_event *cl_event;\r\n\r\ntypedef GLsync (GLAPIENTRY * PFNGLCREATESYNCFROMCLEVENTARBPROC) (cl_context context, cl_event event, GLbitfield flags);\r\n\r\n#define glCreateSyncFromCLeventARB GLEW_GET_FUN(__glewCreateSyncFromCLeventARB)\r\n\r\n#define GLEW_ARB_cl_event GLEW_GET_VAR(__GLEW_ARB_cl_event)\r\n\r\n#endif /* GL_ARB_cl_event */\r\n\r\n/* ----------------------- GL_ARB_clear_buffer_object ---------------------- */\r\n\r\n#ifndef GL_ARB_clear_buffer_object\r\n#define GL_ARB_clear_buffer_object 1\r\n\r\ntypedef void (GLAPIENTRY * PFNGLCLEARBUFFERDATAPROC) (GLenum target, GLenum internalformat, GLenum format, GLenum type, const void *data);\r\ntypedef void (GLAPIENTRY * PFNGLCLEARBUFFERSUBDATAPROC) (GLenum target, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data);\r\ntypedef void (GLAPIENTRY * PFNGLCLEARNAMEDBUFFERDATAEXTPROC) (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, const void *data);\r\ntypedef void (GLAPIENTRY * PFNGLCLEARNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data);\r\n\r\n#define glClearBufferData GLEW_GET_FUN(__glewClearBufferData)\r\n#define glClearBufferSubData GLEW_GET_FUN(__glewClearBufferSubData)\r\n#define glClearNamedBufferDataEXT GLEW_GET_FUN(__glewClearNamedBufferDataEXT)\r\n#define glClearNamedBufferSubDataEXT GLEW_GET_FUN(__glewClearNamedBufferSubDataEXT)\r\n\r\n#define GLEW_ARB_clear_buffer_object GLEW_GET_VAR(__GLEW_ARB_clear_buffer_object)\r\n\r\n#endif /* GL_ARB_clear_buffer_object */\r\n\r\n/* -------------------------- GL_ARB_clear_texture ------------------------- */\r\n\r\n#ifndef GL_ARB_clear_texture\r\n#define GL_ARB_clear_texture 1\r\n\r\n#define GL_CLEAR_TEXTURE 0x9365\r\n\r\ntypedef void (GLAPIENTRY * PFNGLCLEARTEXIMAGEPROC) (GLuint texture, GLint level, GLenum format, GLenum type, const void *data);\r\ntypedef void (GLAPIENTRY * PFNGLCLEARTEXSUBIMAGEPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *data);\r\n\r\n#define glClearTexImage GLEW_GET_FUN(__glewClearTexImage)\r\n#define glClearTexSubImage GLEW_GET_FUN(__glewClearTexSubImage)\r\n\r\n#define GLEW_ARB_clear_texture GLEW_GET_VAR(__GLEW_ARB_clear_texture)\r\n\r\n#endif /* GL_ARB_clear_texture */\r\n\r\n/* -------------------------- GL_ARB_clip_control -------------------------- */\r\n\r\n#ifndef GL_ARB_clip_control\r\n#define GL_ARB_clip_control 1\r\n\r\n#define GL_LOWER_LEFT 0x8CA1\r\n#define GL_UPPER_LEFT 0x8CA2\r\n#define GL_CLIP_ORIGIN 0x935C\r\n#define GL_CLIP_DEPTH_MODE 0x935D\r\n#define GL_NEGATIVE_ONE_TO_ONE 0x935E\r\n#define GL_ZERO_TO_ONE 0x935F\r\n\r\ntypedef void (GLAPIENTRY * PFNGLCLIPCONTROLPROC) (GLenum origin, GLenum depth);\r\n\r\n#define glClipControl GLEW_GET_FUN(__glewClipControl)\r\n\r\n#define GLEW_ARB_clip_control GLEW_GET_VAR(__GLEW_ARB_clip_control)\r\n\r\n#endif /* GL_ARB_clip_control */\r\n\r\n/* ----------------------- GL_ARB_color_buffer_float ----------------------- */\r\n\r\n#ifndef GL_ARB_color_buffer_float\r\n#define GL_ARB_color_buffer_float 1\r\n\r\n#define GL_RGBA_FLOAT_MODE_ARB 0x8820\r\n#define GL_CLAMP_VERTEX_COLOR_ARB 0x891A\r\n#define GL_CLAMP_FRAGMENT_COLOR_ARB 0x891B\r\n#define GL_CLAMP_READ_COLOR_ARB 0x891C\r\n#define GL_FIXED_ONLY_ARB 0x891D\r\n\r\ntypedef void (GLAPIENTRY * PFNGLCLAMPCOLORARBPROC) (GLenum target, GLenum clamp);\r\n\r\n#define glClampColorARB GLEW_GET_FUN(__glewClampColorARB)\r\n\r\n#define GLEW_ARB_color_buffer_float GLEW_GET_VAR(__GLEW_ARB_color_buffer_float)\r\n\r\n#endif /* GL_ARB_color_buffer_float */\r\n\r\n/* -------------------------- GL_ARB_compatibility ------------------------- */\r\n\r\n#ifndef GL_ARB_compatibility\r\n#define GL_ARB_compatibility 1\r\n\r\n#define GLEW_ARB_compatibility GLEW_GET_VAR(__GLEW_ARB_compatibility)\r\n\r\n#endif /* GL_ARB_compatibility */\r\n\r\n/* ---------------- GL_ARB_compressed_texture_pixel_storage ---------------- */\r\n\r\n#ifndef GL_ARB_compressed_texture_pixel_storage\r\n#define GL_ARB_compressed_texture_pixel_storage 1\r\n\r\n#define GL_UNPACK_COMPRESSED_BLOCK_WIDTH 0x9127\r\n#define GL_UNPACK_COMPRESSED_BLOCK_HEIGHT 0x9128\r\n#define GL_UNPACK_COMPRESSED_BLOCK_DEPTH 0x9129\r\n#define GL_UNPACK_COMPRESSED_BLOCK_SIZE 0x912A\r\n#define GL_PACK_COMPRESSED_BLOCK_WIDTH 0x912B\r\n#define GL_PACK_COMPRESSED_BLOCK_HEIGHT 0x912C\r\n#define GL_PACK_COMPRESSED_BLOCK_DEPTH 0x912D\r\n#define GL_PACK_COMPRESSED_BLOCK_SIZE 0x912E\r\n\r\n#define GLEW_ARB_compressed_texture_pixel_storage GLEW_GET_VAR(__GLEW_ARB_compressed_texture_pixel_storage)\r\n\r\n#endif /* GL_ARB_compressed_texture_pixel_storage */\r\n\r\n/* ------------------------- GL_ARB_compute_shader ------------------------- */\r\n\r\n#ifndef GL_ARB_compute_shader\r\n#define GL_ARB_compute_shader 1\r\n\r\n#define GL_COMPUTE_SHADER_BIT 0x00000020\r\n#define GL_MAX_COMPUTE_SHARED_MEMORY_SIZE 0x8262\r\n#define GL_MAX_COMPUTE_UNIFORM_COMPONENTS 0x8263\r\n#define GL_MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS 0x8264\r\n#define GL_MAX_COMPUTE_ATOMIC_COUNTERS 0x8265\r\n#define GL_MAX_COMBINED_COMPUTE_UNIFORM_COMPONENTS 0x8266\r\n#define GL_COMPUTE_WORK_GROUP_SIZE 0x8267\r\n#define GL_MAX_COMPUTE_WORK_GROUP_INVOCATIONS 0x90EB\r\n#define GL_UNIFORM_BLOCK_REFERENCED_BY_COMPUTE_SHADER 0x90EC\r\n#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_COMPUTE_SHADER 0x90ED\r\n#define GL_DISPATCH_INDIRECT_BUFFER 0x90EE\r\n#define GL_DISPATCH_INDIRECT_BUFFER_BINDING 0x90EF\r\n#define GL_COMPUTE_SHADER 0x91B9\r\n#define GL_MAX_COMPUTE_UNIFORM_BLOCKS 0x91BB\r\n#define GL_MAX_COMPUTE_TEXTURE_IMAGE_UNITS 0x91BC\r\n#define GL_MAX_COMPUTE_IMAGE_UNIFORMS 0x91BD\r\n#define GL_MAX_COMPUTE_WORK_GROUP_COUNT 0x91BE\r\n#define GL_MAX_COMPUTE_WORK_GROUP_SIZE 0x91BF\r\n\r\ntypedef void (GLAPIENTRY * PFNGLDISPATCHCOMPUTEPROC) (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z);\r\ntypedef void (GLAPIENTRY * PFNGLDISPATCHCOMPUTEINDIRECTPROC) (GLintptr indirect);\r\n\r\n#define glDispatchCompute GLEW_GET_FUN(__glewDispatchCompute)\r\n#define glDispatchComputeIndirect GLEW_GET_FUN(__glewDispatchComputeIndirect)\r\n\r\n#define GLEW_ARB_compute_shader GLEW_GET_VAR(__GLEW_ARB_compute_shader)\r\n\r\n#endif /* GL_ARB_compute_shader */\r\n\r\n/* ------------------- GL_ARB_compute_variable_group_size ------------------ */\r\n\r\n#ifndef GL_ARB_compute_variable_group_size\r\n#define GL_ARB_compute_variable_group_size 1\r\n\r\n#define GL_MAX_COMPUTE_FIXED_GROUP_INVOCATIONS_ARB 0x90EB\r\n#define GL_MAX_COMPUTE_FIXED_GROUP_SIZE_ARB 0x91BF\r\n#define GL_MAX_COMPUTE_VARIABLE_GROUP_INVOCATIONS_ARB 0x9344\r\n#define GL_MAX_COMPUTE_VARIABLE_GROUP_SIZE_ARB 0x9345\r\n\r\ntypedef void (GLAPIENTRY * PFNGLDISPATCHCOMPUTEGROUPSIZEARBPROC) (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z, GLuint group_size_x, GLuint group_size_y, GLuint group_size_z);\r\n\r\n#define glDispatchComputeGroupSizeARB GLEW_GET_FUN(__glewDispatchComputeGroupSizeARB)\r\n\r\n#define GLEW_ARB_compute_variable_group_size GLEW_GET_VAR(__GLEW_ARB_compute_variable_group_size)\r\n\r\n#endif /* GL_ARB_compute_variable_group_size */\r\n\r\n/* ------------------- GL_ARB_conditional_render_inverted ------------------ */\r\n\r\n#ifndef GL_ARB_conditional_render_inverted\r\n#define GL_ARB_conditional_render_inverted 1\r\n\r\n#define GL_QUERY_WAIT_INVERTED 0x8E17\r\n#define GL_QUERY_NO_WAIT_INVERTED 0x8E18\r\n#define GL_QUERY_BY_REGION_WAIT_INVERTED 0x8E19\r\n#define GL_QUERY_BY_REGION_NO_WAIT_INVERTED 0x8E1A\r\n\r\n#define GLEW_ARB_conditional_render_inverted GLEW_GET_VAR(__GLEW_ARB_conditional_render_inverted)\r\n\r\n#endif /* GL_ARB_conditional_render_inverted */\r\n\r\n/* ----------------------- GL_ARB_conservative_depth ----------------------- */\r\n\r\n#ifndef GL_ARB_conservative_depth\r\n#define GL_ARB_conservative_depth 1\r\n\r\n#define GLEW_ARB_conservative_depth GLEW_GET_VAR(__GLEW_ARB_conservative_depth)\r\n\r\n#endif /* GL_ARB_conservative_depth */\r\n\r\n/* --------------------------- GL_ARB_copy_buffer -------------------------- */\r\n\r\n#ifndef GL_ARB_copy_buffer\r\n#define GL_ARB_copy_buffer 1\r\n\r\n#define GL_COPY_READ_BUFFER 0x8F36\r\n#define GL_COPY_WRITE_BUFFER 0x8F37\r\n\r\ntypedef void (GLAPIENTRY * PFNGLCOPYBUFFERSUBDATAPROC) (GLenum readtarget, GLenum writetarget, GLintptr readoffset, GLintptr writeoffset, GLsizeiptr size);\r\n\r\n#define glCopyBufferSubData GLEW_GET_FUN(__glewCopyBufferSubData)\r\n\r\n#define GLEW_ARB_copy_buffer GLEW_GET_VAR(__GLEW_ARB_copy_buffer)\r\n\r\n#endif /* GL_ARB_copy_buffer */\r\n\r\n/* --------------------------- GL_ARB_copy_image --------------------------- */\r\n\r\n#ifndef GL_ARB_copy_image\r\n#define GL_ARB_copy_image 1\r\n\r\ntypedef void (GLAPIENTRY * PFNGLCOPYIMAGESUBDATAPROC) (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth);\r\n\r\n#define glCopyImageSubData GLEW_GET_FUN(__glewCopyImageSubData)\r\n\r\n#define GLEW_ARB_copy_image GLEW_GET_VAR(__GLEW_ARB_copy_image)\r\n\r\n#endif /* GL_ARB_copy_image */\r\n\r\n/* -------------------------- GL_ARB_cull_distance ------------------------- */\r\n\r\n#ifndef GL_ARB_cull_distance\r\n#define GL_ARB_cull_distance 1\r\n\r\n#define GL_MAX_CULL_DISTANCES 0x82F9\r\n#define GL_MAX_COMBINED_CLIP_AND_CULL_DISTANCES 0x82FA\r\n\r\n#define GLEW_ARB_cull_distance GLEW_GET_VAR(__GLEW_ARB_cull_distance)\r\n\r\n#endif /* GL_ARB_cull_distance */\r\n\r\n/* -------------------------- GL_ARB_debug_output -------------------------- */\r\n\r\n#ifndef GL_ARB_debug_output\r\n#define GL_ARB_debug_output 1\r\n\r\n#define GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB 0x8242\r\n#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH_ARB 0x8243\r\n#define GL_DEBUG_CALLBACK_FUNCTION_ARB 0x8244\r\n#define GL_DEBUG_CALLBACK_USER_PARAM_ARB 0x8245\r\n#define GL_DEBUG_SOURCE_API_ARB 0x8246\r\n#define GL_DEBUG_SOURCE_WINDOW_SYSTEM_ARB 0x8247\r\n#define GL_DEBUG_SOURCE_SHADER_COMPILER_ARB 0x8248\r\n#define GL_DEBUG_SOURCE_THIRD_PARTY_ARB 0x8249\r\n#define GL_DEBUG_SOURCE_APPLICATION_ARB 0x824A\r\n#define GL_DEBUG_SOURCE_OTHER_ARB 0x824B\r\n#define GL_DEBUG_TYPE_ERROR_ARB 0x824C\r\n#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB 0x824D\r\n#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB 0x824E\r\n#define GL_DEBUG_TYPE_PORTABILITY_ARB 0x824F\r\n#define GL_DEBUG_TYPE_PERFORMANCE_ARB 0x8250\r\n#define GL_DEBUG_TYPE_OTHER_ARB 0x8251\r\n#define GL_MAX_DEBUG_MESSAGE_LENGTH_ARB 0x9143\r\n#define GL_MAX_DEBUG_LOGGED_MESSAGES_ARB 0x9144\r\n#define GL_DEBUG_LOGGED_MESSAGES_ARB 0x9145\r\n#define GL_DEBUG_SEVERITY_HIGH_ARB 0x9146\r\n#define GL_DEBUG_SEVERITY_MEDIUM_ARB 0x9147\r\n#define GL_DEBUG_SEVERITY_LOW_ARB 0x9148\r\n\r\ntypedef void (GLAPIENTRY *GLDEBUGPROCARB)(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* message, const void* userParam);\r\n\r\ntypedef void (GLAPIENTRY * PFNGLDEBUGMESSAGECALLBACKARBPROC) (GLDEBUGPROCARB callback, const void *userParam);\r\ntypedef void (GLAPIENTRY * PFNGLDEBUGMESSAGECONTROLARBPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint* ids, GLboolean enabled);\r\ntypedef void (GLAPIENTRY * PFNGLDEBUGMESSAGEINSERTARBPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* buf);\r\ntypedef GLuint (GLAPIENTRY * PFNGLGETDEBUGMESSAGELOGARBPROC) (GLuint count, GLsizei bufSize, GLenum* sources, GLenum* types, GLuint* ids, GLenum* severities, GLsizei* lengths, GLchar* messageLog);\r\n\r\n#define glDebugMessageCallbackARB GLEW_GET_FUN(__glewDebugMessageCallbackARB)\r\n#define glDebugMessageControlARB GLEW_GET_FUN(__glewDebugMessageControlARB)\r\n#define glDebugMessageInsertARB GLEW_GET_FUN(__glewDebugMessageInsertARB)\r\n#define glGetDebugMessageLogARB GLEW_GET_FUN(__glewGetDebugMessageLogARB)\r\n\r\n#define GLEW_ARB_debug_output GLEW_GET_VAR(__GLEW_ARB_debug_output)\r\n\r\n#endif /* GL_ARB_debug_output */\r\n\r\n/* ----------------------- GL_ARB_depth_buffer_float ----------------------- */\r\n\r\n#ifndef GL_ARB_depth_buffer_float\r\n#define GL_ARB_depth_buffer_float 1\r\n\r\n#define GL_DEPTH_COMPONENT32F 0x8CAC\r\n#define GL_DEPTH32F_STENCIL8 0x8CAD\r\n#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV 0x8DAD\r\n\r\n#define GLEW_ARB_depth_buffer_float GLEW_GET_VAR(__GLEW_ARB_depth_buffer_float)\r\n\r\n#endif /* GL_ARB_depth_buffer_float */\r\n\r\n/* --------------------------- GL_ARB_depth_clamp -------------------------- */\r\n\r\n#ifndef GL_ARB_depth_clamp\r\n#define GL_ARB_depth_clamp 1\r\n\r\n#define GL_DEPTH_CLAMP 0x864F\r\n\r\n#define GLEW_ARB_depth_clamp GLEW_GET_VAR(__GLEW_ARB_depth_clamp)\r\n\r\n#endif /* GL_ARB_depth_clamp */\r\n\r\n/* -------------------------- GL_ARB_depth_texture ------------------------- */\r\n\r\n#ifndef GL_ARB_depth_texture\r\n#define GL_ARB_depth_texture 1\r\n\r\n#define GL_DEPTH_COMPONENT16_ARB 0x81A5\r\n#define GL_DEPTH_COMPONENT24_ARB 0x81A6\r\n#define GL_DEPTH_COMPONENT32_ARB 0x81A7\r\n#define GL_TEXTURE_DEPTH_SIZE_ARB 0x884A\r\n#define GL_DEPTH_TEXTURE_MODE_ARB 0x884B\r\n\r\n#define GLEW_ARB_depth_texture GLEW_GET_VAR(__GLEW_ARB_depth_texture)\r\n\r\n#endif /* GL_ARB_depth_texture */\r\n\r\n/* ----------------------- GL_ARB_derivative_control ----------------------- */\r\n\r\n#ifndef GL_ARB_derivative_control\r\n#define GL_ARB_derivative_control 1\r\n\r\n#define GLEW_ARB_derivative_control GLEW_GET_VAR(__GLEW_ARB_derivative_control)\r\n\r\n#endif /* GL_ARB_derivative_control */\r\n\r\n/* ----------------------- GL_ARB_direct_state_access ---------------------- */\r\n\r\n#ifndef GL_ARB_direct_state_access\r\n#define GL_ARB_direct_state_access 1\r\n\r\n#define GL_TEXTURE_TARGET 0x1006\r\n#define GL_QUERY_TARGET 0x82EA\r\n\r\ntypedef void (GLAPIENTRY * PFNGLBINDTEXTUREUNITPROC) (GLuint unit, GLuint texture);\r\ntypedef void (GLAPIENTRY * PFNGLBLITNAMEDFRAMEBUFFERPROC) (GLuint readFramebuffer, GLuint drawFramebuffer, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);\r\ntypedef GLenum (GLAPIENTRY * PFNGLCHECKNAMEDFRAMEBUFFERSTATUSPROC) (GLuint framebuffer, GLenum target);\r\ntypedef void (GLAPIENTRY * PFNGLCLEARNAMEDBUFFERDATAPROC) (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, const void *data);\r\ntypedef void (GLAPIENTRY * PFNGLCLEARNAMEDBUFFERSUBDATAPROC) (GLuint buffer, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data);\r\ntypedef void (GLAPIENTRY * PFNGLCLEARNAMEDFRAMEBUFFERFIPROC) (GLuint framebuffer, GLenum buffer, GLfloat depth, GLint stencil);\r\ntypedef void (GLAPIENTRY * PFNGLCLEARNAMEDFRAMEBUFFERFVPROC) (GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLfloat* value);\r\ntypedef void (GLAPIENTRY * PFNGLCLEARNAMEDFRAMEBUFFERIVPROC) (GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLint* value);\r\ntypedef void (GLAPIENTRY * PFNGLCLEARNAMEDFRAMEBUFFERUIVPROC) (GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLuint* value);\r\ntypedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXTURESUBIMAGE1DPROC) (GLuint texture, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data);\r\ntypedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXTURESUBIMAGE2DPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data);\r\ntypedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXTURESUBIMAGE3DPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data);\r\ntypedef void (GLAPIENTRY * PFNGLCOPYNAMEDBUFFERSUBDATAPROC) (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size);\r\ntypedef void (GLAPIENTRY * PFNGLCOPYTEXTURESUBIMAGE1DPROC) (GLuint texture, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width);\r\ntypedef void (GLAPIENTRY * PFNGLCOPYTEXTURESUBIMAGE2DPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);\r\ntypedef void (GLAPIENTRY * PFNGLCOPYTEXTURESUBIMAGE3DPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);\r\ntypedef void (GLAPIENTRY * PFNGLCREATEBUFFERSPROC) (GLsizei n, GLuint* buffers);\r\ntypedef void (GLAPIENTRY * PFNGLCREATEFRAMEBUFFERSPROC) (GLsizei n, GLuint* framebuffers);\r\ntypedef void (GLAPIENTRY * PFNGLCREATEPROGRAMPIPELINESPROC) (GLsizei n, GLuint* pipelines);\r\ntypedef void (GLAPIENTRY * PFNGLCREATEQUERIESPROC) (GLenum target, GLsizei n, GLuint* ids);\r\ntypedef void (GLAPIENTRY * PFNGLCREATERENDERBUFFERSPROC) (GLsizei n, GLuint* renderbuffers);\r\ntypedef void (GLAPIENTRY * PFNGLCREATESAMPLERSPROC) (GLsizei n, GLuint* samplers);\r\ntypedef void (GLAPIENTRY * PFNGLCREATETEXTURESPROC) (GLenum target, GLsizei n, GLuint* textures);\r\ntypedef void (GLAPIENTRY * PFNGLCREATETRANSFORMFEEDBACKSPROC) (GLsizei n, GLuint* ids);\r\ntypedef void (GLAPIENTRY * PFNGLCREATEVERTEXARRAYSPROC) (GLsizei n, GLuint* arrays);\r\ntypedef void (GLAPIENTRY * PFNGLDISABLEVERTEXARRAYATTRIBPROC) (GLuint vaobj, GLuint index);\r\ntypedef void (GLAPIENTRY * PFNGLENABLEVERTEXARRAYATTRIBPROC) (GLuint vaobj, GLuint index);\r\ntypedef void (GLAPIENTRY * PFNGLFLUSHMAPPEDNAMEDBUFFERRANGEPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length);\r\ntypedef void (GLAPIENTRY * PFNGLGENERATETEXTUREMIPMAPPROC) (GLuint texture);\r\ntypedef void (GLAPIENTRY * PFNGLGETCOMPRESSEDTEXTUREIMAGEPROC) (GLuint texture, GLint level, GLsizei bufSize, void *pixels);\r\ntypedef void (GLAPIENTRY * PFNGLGETNAMEDBUFFERPARAMETERI64VPROC) (GLuint buffer, GLenum pname, GLint64* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETNAMEDBUFFERPARAMETERIVPROC) (GLuint buffer, GLenum pname, GLint* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETNAMEDBUFFERPOINTERVPROC) (GLuint buffer, GLenum pname, void** params);\r\ntypedef void (GLAPIENTRY * PFNGLGETNAMEDBUFFERSUBDATAPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, void *data);\r\ntypedef void (GLAPIENTRY * PFNGLGETNAMEDFRAMEBUFFERATTACHMENTPARAMETERIVPROC) (GLuint framebuffer, GLenum attachment, GLenum pname, GLint* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETNAMEDFRAMEBUFFERPARAMETERIVPROC) (GLuint framebuffer, GLenum pname, GLint* param);\r\ntypedef void (GLAPIENTRY * PFNGLGETNAMEDRENDERBUFFERPARAMETERIVPROC) (GLuint renderbuffer, GLenum pname, GLint* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETQUERYBUFFEROBJECTI64VPROC) (GLuint id,GLuint buffer,GLenum pname,GLintptr offset);\r\ntypedef void (GLAPIENTRY * PFNGLGETQUERYBUFFEROBJECTIVPROC) (GLuint id,GLuint buffer,GLenum pname,GLintptr offset);\r\ntypedef void (GLAPIENTRY * PFNGLGETQUERYBUFFEROBJECTUI64VPROC) (GLuint id,GLuint buffer,GLenum pname,GLintptr offset);\r\ntypedef void (GLAPIENTRY * PFNGLGETQUERYBUFFEROBJECTUIVPROC) (GLuint id,GLuint buffer,GLenum pname,GLintptr offset);\r\ntypedef void (GLAPIENTRY * PFNGLGETTEXTUREIMAGEPROC) (GLuint texture, GLint level, GLenum format, GLenum type, GLsizei bufSize, void *pixels);\r\ntypedef void (GLAPIENTRY * PFNGLGETTEXTURELEVELPARAMETERFVPROC) (GLuint texture, GLint level, GLenum pname, GLfloat* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETTEXTURELEVELPARAMETERIVPROC) (GLuint texture, GLint level, GLenum pname, GLint* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETTEXTUREPARAMETERIIVPROC) (GLuint texture, GLenum pname, GLint* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETTEXTUREPARAMETERIUIVPROC) (GLuint texture, GLenum pname, GLuint* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETTEXTUREPARAMETERFVPROC) (GLuint texture, GLenum pname, GLfloat* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETTEXTUREPARAMETERIVPROC) (GLuint texture, GLenum pname, GLint* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETTRANSFORMFEEDBACKI64_VPROC) (GLuint xfb, GLenum pname, GLuint index, GLint64* param);\r\ntypedef void (GLAPIENTRY * PFNGLGETTRANSFORMFEEDBACKI_VPROC) (GLuint xfb, GLenum pname, GLuint index, GLint* param);\r\ntypedef void (GLAPIENTRY * PFNGLGETTRANSFORMFEEDBACKIVPROC) (GLuint xfb, GLenum pname, GLint* param);\r\ntypedef void (GLAPIENTRY * PFNGLGETVERTEXARRAYINDEXED64IVPROC) (GLuint vaobj, GLuint index, GLenum pname, GLint64* param);\r\ntypedef void (GLAPIENTRY * PFNGLGETVERTEXARRAYINDEXEDIVPROC) (GLuint vaobj, GLuint index, GLenum pname, GLint* param);\r\ntypedef void (GLAPIENTRY * PFNGLGETVERTEXARRAYIVPROC) (GLuint vaobj, GLenum pname, GLint* param);\r\ntypedef void (GLAPIENTRY * PFNGLINVALIDATENAMEDFRAMEBUFFERDATAPROC) (GLuint framebuffer, GLsizei numAttachments, const GLenum* attachments);\r\ntypedef void (GLAPIENTRY * PFNGLINVALIDATENAMEDFRAMEBUFFERSUBDATAPROC) (GLuint framebuffer, GLsizei numAttachments, const GLenum* attachments, GLint x, GLint y, GLsizei width, GLsizei height);\r\ntypedef void * (GLAPIENTRY * PFNGLMAPNAMEDBUFFERPROC) (GLuint buffer, GLenum access);\r\ntypedef void * (GLAPIENTRY * PFNGLMAPNAMEDBUFFERRANGEPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access);\r\ntypedef void (GLAPIENTRY * PFNGLNAMEDBUFFERDATAPROC) (GLuint buffer, GLsizeiptr size, const void *data, GLenum usage);\r\ntypedef void (GLAPIENTRY * PFNGLNAMEDBUFFERSTORAGEPROC) (GLuint buffer, GLsizeiptr size, const void *data, GLbitfield flags);\r\ntypedef void (GLAPIENTRY * PFNGLNAMEDBUFFERSUBDATAPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data);\r\ntypedef void (GLAPIENTRY * PFNGLNAMEDFRAMEBUFFERDRAWBUFFERPROC) (GLuint framebuffer, GLenum mode);\r\ntypedef void (GLAPIENTRY * PFNGLNAMEDFRAMEBUFFERDRAWBUFFERSPROC) (GLuint framebuffer, GLsizei n, const GLenum* bufs);\r\ntypedef void (GLAPIENTRY * PFNGLNAMEDFRAMEBUFFERPARAMETERIPROC) (GLuint framebuffer, GLenum pname, GLint param);\r\ntypedef void (GLAPIENTRY * PFNGLNAMEDFRAMEBUFFERREADBUFFERPROC) (GLuint framebuffer, GLenum mode);\r\ntypedef void (GLAPIENTRY * PFNGLNAMEDFRAMEBUFFERRENDERBUFFERPROC) (GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);\r\ntypedef void (GLAPIENTRY * PFNGLNAMEDFRAMEBUFFERTEXTUREPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level);\r\ntypedef void (GLAPIENTRY * PFNGLNAMEDFRAMEBUFFERTEXTURELAYERPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer);\r\ntypedef void (GLAPIENTRY * PFNGLNAMEDRENDERBUFFERSTORAGEPROC) (GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height);\r\ntypedef void (GLAPIENTRY * PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEPROC) (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);\r\ntypedef void (GLAPIENTRY * PFNGLTEXTUREBUFFERPROC) (GLuint texture, GLenum internalformat, GLuint buffer);\r\ntypedef void (GLAPIENTRY * PFNGLTEXTUREBUFFERRANGEPROC) (GLuint texture, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size);\r\ntypedef void (GLAPIENTRY * PFNGLTEXTUREPARAMETERIIVPROC) (GLuint texture, GLenum pname, const GLint* params);\r\ntypedef void (GLAPIENTRY * PFNGLTEXTUREPARAMETERIUIVPROC) (GLuint texture, GLenum pname, const GLuint* params);\r\ntypedef void (GLAPIENTRY * PFNGLTEXTUREPARAMETERFPROC) (GLuint texture, GLenum pname, GLfloat param);\r\ntypedef void (GLAPIENTRY * PFNGLTEXTUREPARAMETERFVPROC) (GLuint texture, GLenum pname, const GLfloat* param);\r\ntypedef void (GLAPIENTRY * PFNGLTEXTUREPARAMETERIPROC) (GLuint texture, GLenum pname, GLint param);\r\ntypedef void (GLAPIENTRY * PFNGLTEXTUREPARAMETERIVPROC) (GLuint texture, GLenum pname, const GLint* param);\r\ntypedef void (GLAPIENTRY * PFNGLTEXTURESTORAGE1DPROC) (GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width);\r\ntypedef void (GLAPIENTRY * PFNGLTEXTURESTORAGE2DPROC) (GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);\r\ntypedef void (GLAPIENTRY * PFNGLTEXTURESTORAGE2DMULTISAMPLEPROC) (GLuint texture, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations);\r\ntypedef void (GLAPIENTRY * PFNGLTEXTURESTORAGE3DPROC) (GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);\r\ntypedef void (GLAPIENTRY * PFNGLTEXTURESTORAGE3DMULTISAMPLEPROC) (GLuint texture, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations);\r\ntypedef void (GLAPIENTRY * PFNGLTEXTURESUBIMAGE1DPROC) (GLuint texture, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels);\r\ntypedef void (GLAPIENTRY * PFNGLTEXTURESUBIMAGE2DPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels);\r\ntypedef void (GLAPIENTRY * PFNGLTEXTURESUBIMAGE3DPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels);\r\ntypedef void (GLAPIENTRY * PFNGLTRANSFORMFEEDBACKBUFFERBASEPROC) (GLuint xfb, GLuint index, GLuint buffer);\r\ntypedef void (GLAPIENTRY * PFNGLTRANSFORMFEEDBACKBUFFERRANGEPROC) (GLuint xfb, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size);\r\ntypedef GLboolean (GLAPIENTRY * PFNGLUNMAPNAMEDBUFFERPROC) (GLuint buffer);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXARRAYATTRIBBINDINGPROC) (GLuint vaobj, GLuint attribindex, GLuint bindingindex);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXARRAYATTRIBFORMATPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXARRAYATTRIBIFORMATPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXARRAYATTRIBLFORMATPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXARRAYBINDINGDIVISORPROC) (GLuint vaobj, GLuint bindingindex, GLuint divisor);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXARRAYELEMENTBUFFERPROC) (GLuint vaobj, GLuint buffer);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXARRAYVERTEXBUFFERPROC) (GLuint vaobj, GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXARRAYVERTEXBUFFERSPROC) (GLuint vaobj, GLuint first, GLsizei count, const GLuint* buffers, const GLintptr *offsets, const GLsizei *strides);\r\n\r\n#define glBindTextureUnit GLEW_GET_FUN(__glewBindTextureUnit)\r\n#define glBlitNamedFramebuffer GLEW_GET_FUN(__glewBlitNamedFramebuffer)\r\n#define glCheckNamedFramebufferStatus GLEW_GET_FUN(__glewCheckNamedFramebufferStatus)\r\n#define glClearNamedBufferData GLEW_GET_FUN(__glewClearNamedBufferData)\r\n#define glClearNamedBufferSubData GLEW_GET_FUN(__glewClearNamedBufferSubData)\r\n#define glClearNamedFramebufferfi GLEW_GET_FUN(__glewClearNamedFramebufferfi)\r\n#define glClearNamedFramebufferfv GLEW_GET_FUN(__glewClearNamedFramebufferfv)\r\n#define glClearNamedFramebufferiv GLEW_GET_FUN(__glewClearNamedFramebufferiv)\r\n#define glClearNamedFramebufferuiv GLEW_GET_FUN(__glewClearNamedFramebufferuiv)\r\n#define glCompressedTextureSubImage1D GLEW_GET_FUN(__glewCompressedTextureSubImage1D)\r\n#define glCompressedTextureSubImage2D GLEW_GET_FUN(__glewCompressedTextureSubImage2D)\r\n#define glCompressedTextureSubImage3D GLEW_GET_FUN(__glewCompressedTextureSubImage3D)\r\n#define glCopyNamedBufferSubData GLEW_GET_FUN(__glewCopyNamedBufferSubData)\r\n#define glCopyTextureSubImage1D GLEW_GET_FUN(__glewCopyTextureSubImage1D)\r\n#define glCopyTextureSubImage2D GLEW_GET_FUN(__glewCopyTextureSubImage2D)\r\n#define glCopyTextureSubImage3D GLEW_GET_FUN(__glewCopyTextureSubImage3D)\r\n#define glCreateBuffers GLEW_GET_FUN(__glewCreateBuffers)\r\n#define glCreateFramebuffers GLEW_GET_FUN(__glewCreateFramebuffers)\r\n#define glCreateProgramPipelines GLEW_GET_FUN(__glewCreateProgramPipelines)\r\n#define glCreateQueries GLEW_GET_FUN(__glewCreateQueries)\r\n#define glCreateRenderbuffers GLEW_GET_FUN(__glewCreateRenderbuffers)\r\n#define glCreateSamplers GLEW_GET_FUN(__glewCreateSamplers)\r\n#define glCreateTextures GLEW_GET_FUN(__glewCreateTextures)\r\n#define glCreateTransformFeedbacks GLEW_GET_FUN(__glewCreateTransformFeedbacks)\r\n#define glCreateVertexArrays GLEW_GET_FUN(__glewCreateVertexArrays)\r\n#define glDisableVertexArrayAttrib GLEW_GET_FUN(__glewDisableVertexArrayAttrib)\r\n#define glEnableVertexArrayAttrib GLEW_GET_FUN(__glewEnableVertexArrayAttrib)\r\n#define glFlushMappedNamedBufferRange GLEW_GET_FUN(__glewFlushMappedNamedBufferRange)\r\n#define glGenerateTextureMipmap GLEW_GET_FUN(__glewGenerateTextureMipmap)\r\n#define glGetCompressedTextureImage GLEW_GET_FUN(__glewGetCompressedTextureImage)\r\n#define glGetNamedBufferParameteri64v GLEW_GET_FUN(__glewGetNamedBufferParameteri64v)\r\n#define glGetNamedBufferParameteriv GLEW_GET_FUN(__glewGetNamedBufferParameteriv)\r\n#define glGetNamedBufferPointerv GLEW_GET_FUN(__glewGetNamedBufferPointerv)\r\n#define glGetNamedBufferSubData GLEW_GET_FUN(__glewGetNamedBufferSubData)\r\n#define glGetNamedFramebufferAttachmentParameteriv GLEW_GET_FUN(__glewGetNamedFramebufferAttachmentParameteriv)\r\n#define glGetNamedFramebufferParameteriv GLEW_GET_FUN(__glewGetNamedFramebufferParameteriv)\r\n#define glGetNamedRenderbufferParameteriv GLEW_GET_FUN(__glewGetNamedRenderbufferParameteriv)\r\n#define glGetQueryBufferObjecti64v GLEW_GET_FUN(__glewGetQueryBufferObjecti64v)\r\n#define glGetQueryBufferObjectiv GLEW_GET_FUN(__glewGetQueryBufferObjectiv)\r\n#define glGetQueryBufferObjectui64v GLEW_GET_FUN(__glewGetQueryBufferObjectui64v)\r\n#define glGetQueryBufferObjectuiv GLEW_GET_FUN(__glewGetQueryBufferObjectuiv)\r\n#define glGetTextureImage GLEW_GET_FUN(__glewGetTextureImage)\r\n#define glGetTextureLevelParameterfv GLEW_GET_FUN(__glewGetTextureLevelParameterfv)\r\n#define glGetTextureLevelParameteriv GLEW_GET_FUN(__glewGetTextureLevelParameteriv)\r\n#define glGetTextureParameterIiv GLEW_GET_FUN(__glewGetTextureParameterIiv)\r\n#define glGetTextureParameterIuiv GLEW_GET_FUN(__glewGetTextureParameterIuiv)\r\n#define glGetTextureParameterfv GLEW_GET_FUN(__glewGetTextureParameterfv)\r\n#define glGetTextureParameteriv GLEW_GET_FUN(__glewGetTextureParameteriv)\r\n#define glGetTransformFeedbacki64_v GLEW_GET_FUN(__glewGetTransformFeedbacki64_v)\r\n#define glGetTransformFeedbacki_v GLEW_GET_FUN(__glewGetTransformFeedbacki_v)\r\n#define glGetTransformFeedbackiv GLEW_GET_FUN(__glewGetTransformFeedbackiv)\r\n#define glGetVertexArrayIndexed64iv GLEW_GET_FUN(__glewGetVertexArrayIndexed64iv)\r\n#define glGetVertexArrayIndexediv GLEW_GET_FUN(__glewGetVertexArrayIndexediv)\r\n#define glGetVertexArrayiv GLEW_GET_FUN(__glewGetVertexArrayiv)\r\n#define glInvalidateNamedFramebufferData GLEW_GET_FUN(__glewInvalidateNamedFramebufferData)\r\n#define glInvalidateNamedFramebufferSubData GLEW_GET_FUN(__glewInvalidateNamedFramebufferSubData)\r\n#define glMapNamedBuffer GLEW_GET_FUN(__glewMapNamedBuffer)\r\n#define glMapNamedBufferRange GLEW_GET_FUN(__glewMapNamedBufferRange)\r\n#define glNamedBufferData GLEW_GET_FUN(__glewNamedBufferData)\r\n#define glNamedBufferStorage GLEW_GET_FUN(__glewNamedBufferStorage)\r\n#define glNamedBufferSubData GLEW_GET_FUN(__glewNamedBufferSubData)\r\n#define glNamedFramebufferDrawBuffer GLEW_GET_FUN(__glewNamedFramebufferDrawBuffer)\r\n#define glNamedFramebufferDrawBuffers GLEW_GET_FUN(__glewNamedFramebufferDrawBuffers)\r\n#define glNamedFramebufferParameteri GLEW_GET_FUN(__glewNamedFramebufferParameteri)\r\n#define glNamedFramebufferReadBuffer GLEW_GET_FUN(__glewNamedFramebufferReadBuffer)\r\n#define glNamedFramebufferRenderbuffer GLEW_GET_FUN(__glewNamedFramebufferRenderbuffer)\r\n#define glNamedFramebufferTexture GLEW_GET_FUN(__glewNamedFramebufferTexture)\r\n#define glNamedFramebufferTextureLayer GLEW_GET_FUN(__glewNamedFramebufferTextureLayer)\r\n#define glNamedRenderbufferStorage GLEW_GET_FUN(__glewNamedRenderbufferStorage)\r\n#define glNamedRenderbufferStorageMultisample GLEW_GET_FUN(__glewNamedRenderbufferStorageMultisample)\r\n#define glTextureBuffer GLEW_GET_FUN(__glewTextureBuffer)\r\n#define glTextureBufferRange GLEW_GET_FUN(__glewTextureBufferRange)\r\n#define glTextureParameterIiv GLEW_GET_FUN(__glewTextureParameterIiv)\r\n#define glTextureParameterIuiv GLEW_GET_FUN(__glewTextureParameterIuiv)\r\n#define glTextureParameterf GLEW_GET_FUN(__glewTextureParameterf)\r\n#define glTextureParameterfv GLEW_GET_FUN(__glewTextureParameterfv)\r\n#define glTextureParameteri GLEW_GET_FUN(__glewTextureParameteri)\r\n#define glTextureParameteriv GLEW_GET_FUN(__glewTextureParameteriv)\r\n#define glTextureStorage1D GLEW_GET_FUN(__glewTextureStorage1D)\r\n#define glTextureStorage2D GLEW_GET_FUN(__glewTextureStorage2D)\r\n#define glTextureStorage2DMultisample GLEW_GET_FUN(__glewTextureStorage2DMultisample)\r\n#define glTextureStorage3D GLEW_GET_FUN(__glewTextureStorage3D)\r\n#define glTextureStorage3DMultisample GLEW_GET_FUN(__glewTextureStorage3DMultisample)\r\n#define glTextureSubImage1D GLEW_GET_FUN(__glewTextureSubImage1D)\r\n#define glTextureSubImage2D GLEW_GET_FUN(__glewTextureSubImage2D)\r\n#define glTextureSubImage3D GLEW_GET_FUN(__glewTextureSubImage3D)\r\n#define glTransformFeedbackBufferBase GLEW_GET_FUN(__glewTransformFeedbackBufferBase)\r\n#define glTransformFeedbackBufferRange GLEW_GET_FUN(__glewTransformFeedbackBufferRange)\r\n#define glUnmapNamedBuffer GLEW_GET_FUN(__glewUnmapNamedBuffer)\r\n#define glVertexArrayAttribBinding GLEW_GET_FUN(__glewVertexArrayAttribBinding)\r\n#define glVertexArrayAttribFormat GLEW_GET_FUN(__glewVertexArrayAttribFormat)\r\n#define glVertexArrayAttribIFormat GLEW_GET_FUN(__glewVertexArrayAttribIFormat)\r\n#define glVertexArrayAttribLFormat GLEW_GET_FUN(__glewVertexArrayAttribLFormat)\r\n#define glVertexArrayBindingDivisor GLEW_GET_FUN(__glewVertexArrayBindingDivisor)\r\n#define glVertexArrayElementBuffer GLEW_GET_FUN(__glewVertexArrayElementBuffer)\r\n#define glVertexArrayVertexBuffer GLEW_GET_FUN(__glewVertexArrayVertexBuffer)\r\n#define glVertexArrayVertexBuffers GLEW_GET_FUN(__glewVertexArrayVertexBuffers)\r\n\r\n#define GLEW_ARB_direct_state_access GLEW_GET_VAR(__GLEW_ARB_direct_state_access)\r\n\r\n#endif /* GL_ARB_direct_state_access */\r\n\r\n/* -------------------------- GL_ARB_draw_buffers -------------------------- */\r\n\r\n#ifndef GL_ARB_draw_buffers\r\n#define GL_ARB_draw_buffers 1\r\n\r\n#define GL_MAX_DRAW_BUFFERS_ARB 0x8824\r\n#define GL_DRAW_BUFFER0_ARB 0x8825\r\n#define GL_DRAW_BUFFER1_ARB 0x8826\r\n#define GL_DRAW_BUFFER2_ARB 0x8827\r\n#define GL_DRAW_BUFFER3_ARB 0x8828\r\n#define GL_DRAW_BUFFER4_ARB 0x8829\r\n#define GL_DRAW_BUFFER5_ARB 0x882A\r\n#define GL_DRAW_BUFFER6_ARB 0x882B\r\n#define GL_DRAW_BUFFER7_ARB 0x882C\r\n#define GL_DRAW_BUFFER8_ARB 0x882D\r\n#define GL_DRAW_BUFFER9_ARB 0x882E\r\n#define GL_DRAW_BUFFER10_ARB 0x882F\r\n#define GL_DRAW_BUFFER11_ARB 0x8830\r\n#define GL_DRAW_BUFFER12_ARB 0x8831\r\n#define GL_DRAW_BUFFER13_ARB 0x8832\r\n#define GL_DRAW_BUFFER14_ARB 0x8833\r\n#define GL_DRAW_BUFFER15_ARB 0x8834\r\n\r\ntypedef void (GLAPIENTRY * PFNGLDRAWBUFFERSARBPROC) (GLsizei n, const GLenum* bufs);\r\n\r\n#define glDrawBuffersARB GLEW_GET_FUN(__glewDrawBuffersARB)\r\n\r\n#define GLEW_ARB_draw_buffers GLEW_GET_VAR(__GLEW_ARB_draw_buffers)\r\n\r\n#endif /* GL_ARB_draw_buffers */\r\n\r\n/* ----------------------- GL_ARB_draw_buffers_blend ----------------------- */\r\n\r\n#ifndef GL_ARB_draw_buffers_blend\r\n#define GL_ARB_draw_buffers_blend 1\r\n\r\ntypedef void (GLAPIENTRY * PFNGLBLENDEQUATIONSEPARATEIARBPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha);\r\ntypedef void (GLAPIENTRY * PFNGLBLENDEQUATIONIARBPROC) (GLuint buf, GLenum mode);\r\ntypedef void (GLAPIENTRY * PFNGLBLENDFUNCSEPARATEIARBPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);\r\ntypedef void (GLAPIENTRY * PFNGLBLENDFUNCIARBPROC) (GLuint buf, GLenum src, GLenum dst);\r\n\r\n#define glBlendEquationSeparateiARB GLEW_GET_FUN(__glewBlendEquationSeparateiARB)\r\n#define glBlendEquationiARB GLEW_GET_FUN(__glewBlendEquationiARB)\r\n#define glBlendFuncSeparateiARB GLEW_GET_FUN(__glewBlendFuncSeparateiARB)\r\n#define glBlendFunciARB GLEW_GET_FUN(__glewBlendFunciARB)\r\n\r\n#define GLEW_ARB_draw_buffers_blend GLEW_GET_VAR(__GLEW_ARB_draw_buffers_blend)\r\n\r\n#endif /* GL_ARB_draw_buffers_blend */\r\n\r\n/* -------------------- GL_ARB_draw_elements_base_vertex ------------------- */\r\n\r\n#ifndef GL_ARB_draw_elements_base_vertex\r\n#define GL_ARB_draw_elements_base_vertex 1\r\n\r\ntypedef void (GLAPIENTRY * PFNGLDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLint basevertex);\r\ntypedef void (GLAPIENTRY * PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount, GLint basevertex);\r\ntypedef void (GLAPIENTRY * PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices, GLint basevertex);\r\ntypedef void (GLAPIENTRY * PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, const GLsizei* count, GLenum type, const void *const *indices, GLsizei primcount, const GLint *basevertex);\r\n\r\n#define glDrawElementsBaseVertex GLEW_GET_FUN(__glewDrawElementsBaseVertex)\r\n#define glDrawElementsInstancedBaseVertex GLEW_GET_FUN(__glewDrawElementsInstancedBaseVertex)\r\n#define glDrawRangeElementsBaseVertex GLEW_GET_FUN(__glewDrawRangeElementsBaseVertex)\r\n#define glMultiDrawElementsBaseVertex GLEW_GET_FUN(__glewMultiDrawElementsBaseVertex)\r\n\r\n#define GLEW_ARB_draw_elements_base_vertex GLEW_GET_VAR(__GLEW_ARB_draw_elements_base_vertex)\r\n\r\n#endif /* GL_ARB_draw_elements_base_vertex */\r\n\r\n/* -------------------------- GL_ARB_draw_indirect ------------------------- */\r\n\r\n#ifndef GL_ARB_draw_indirect\r\n#define GL_ARB_draw_indirect 1\r\n\r\n#define GL_DRAW_INDIRECT_BUFFER 0x8F3F\r\n#define GL_DRAW_INDIRECT_BUFFER_BINDING 0x8F43\r\n\r\ntypedef void (GLAPIENTRY * PFNGLDRAWARRAYSINDIRECTPROC) (GLenum mode, const void *indirect);\r\ntypedef void (GLAPIENTRY * PFNGLDRAWELEMENTSINDIRECTPROC) (GLenum mode, GLenum type, const void *indirect);\r\n\r\n#define glDrawArraysIndirect GLEW_GET_FUN(__glewDrawArraysIndirect)\r\n#define glDrawElementsIndirect GLEW_GET_FUN(__glewDrawElementsIndirect)\r\n\r\n#define GLEW_ARB_draw_indirect GLEW_GET_VAR(__GLEW_ARB_draw_indirect)\r\n\r\n#endif /* GL_ARB_draw_indirect */\r\n\r\n/* ------------------------- GL_ARB_draw_instanced ------------------------- */\r\n\r\n#ifndef GL_ARB_draw_instanced\r\n#define GL_ARB_draw_instanced 1\r\n\r\n#define GLEW_ARB_draw_instanced GLEW_GET_VAR(__GLEW_ARB_draw_instanced)\r\n\r\n#endif /* GL_ARB_draw_instanced */\r\n\r\n/* ------------------------ GL_ARB_enhanced_layouts ------------------------ */\r\n\r\n#ifndef GL_ARB_enhanced_layouts\r\n#define GL_ARB_enhanced_layouts 1\r\n\r\n#define GL_LOCATION_COMPONENT 0x934A\r\n#define GL_TRANSFORM_FEEDBACK_BUFFER_INDEX 0x934B\r\n#define GL_TRANSFORM_FEEDBACK_BUFFER_STRIDE 0x934C\r\n\r\n#define GLEW_ARB_enhanced_layouts GLEW_GET_VAR(__GLEW_ARB_enhanced_layouts)\r\n\r\n#endif /* GL_ARB_enhanced_layouts */\r\n\r\n/* -------------------- GL_ARB_explicit_attrib_location -------------------- */\r\n\r\n#ifndef GL_ARB_explicit_attrib_location\r\n#define GL_ARB_explicit_attrib_location 1\r\n\r\n#define GLEW_ARB_explicit_attrib_location GLEW_GET_VAR(__GLEW_ARB_explicit_attrib_location)\r\n\r\n#endif /* GL_ARB_explicit_attrib_location */\r\n\r\n/* -------------------- GL_ARB_explicit_uniform_location ------------------- */\r\n\r\n#ifndef GL_ARB_explicit_uniform_location\r\n#define GL_ARB_explicit_uniform_location 1\r\n\r\n#define GL_MAX_UNIFORM_LOCATIONS 0x826E\r\n\r\n#define GLEW_ARB_explicit_uniform_location GLEW_GET_VAR(__GLEW_ARB_explicit_uniform_location)\r\n\r\n#endif /* GL_ARB_explicit_uniform_location */\r\n\r\n/* ------------------- GL_ARB_fragment_coord_conventions ------------------- */\r\n\r\n#ifndef GL_ARB_fragment_coord_conventions\r\n#define GL_ARB_fragment_coord_conventions 1\r\n\r\n#define GLEW_ARB_fragment_coord_conventions GLEW_GET_VAR(__GLEW_ARB_fragment_coord_conventions)\r\n\r\n#endif /* GL_ARB_fragment_coord_conventions */\r\n\r\n/* --------------------- GL_ARB_fragment_layer_viewport -------------------- */\r\n\r\n#ifndef GL_ARB_fragment_layer_viewport\r\n#define GL_ARB_fragment_layer_viewport 1\r\n\r\n#define GLEW_ARB_fragment_layer_viewport GLEW_GET_VAR(__GLEW_ARB_fragment_layer_viewport)\r\n\r\n#endif /* GL_ARB_fragment_layer_viewport */\r\n\r\n/* ------------------------ GL_ARB_fragment_program ------------------------ */\r\n\r\n#ifndef GL_ARB_fragment_program\r\n#define GL_ARB_fragment_program 1\r\n\r\n#define GL_FRAGMENT_PROGRAM_ARB 0x8804\r\n#define GL_PROGRAM_ALU_INSTRUCTIONS_ARB 0x8805\r\n#define GL_PROGRAM_TEX_INSTRUCTIONS_ARB 0x8806\r\n#define GL_PROGRAM_TEX_INDIRECTIONS_ARB 0x8807\r\n#define GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x8808\r\n#define GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x8809\r\n#define GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x880A\r\n#define GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB 0x880B\r\n#define GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB 0x880C\r\n#define GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB 0x880D\r\n#define GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x880E\r\n#define GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x880F\r\n#define GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x8810\r\n#define GL_MAX_TEXTURE_COORDS_ARB 0x8871\r\n#define GL_MAX_TEXTURE_IMAGE_UNITS_ARB 0x8872\r\n\r\n#define GLEW_ARB_fragment_program GLEW_GET_VAR(__GLEW_ARB_fragment_program)\r\n\r\n#endif /* GL_ARB_fragment_program */\r\n\r\n/* --------------------- GL_ARB_fragment_program_shadow -------------------- */\r\n\r\n#ifndef GL_ARB_fragment_program_shadow\r\n#define GL_ARB_fragment_program_shadow 1\r\n\r\n#define GLEW_ARB_fragment_program_shadow GLEW_GET_VAR(__GLEW_ARB_fragment_program_shadow)\r\n\r\n#endif /* GL_ARB_fragment_program_shadow */\r\n\r\n/* ------------------------- GL_ARB_fragment_shader ------------------------ */\r\n\r\n#ifndef GL_ARB_fragment_shader\r\n#define GL_ARB_fragment_shader 1\r\n\r\n#define GL_FRAGMENT_SHADER_ARB 0x8B30\r\n#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB 0x8B49\r\n#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB 0x8B8B\r\n\r\n#define GLEW_ARB_fragment_shader GLEW_GET_VAR(__GLEW_ARB_fragment_shader)\r\n\r\n#endif /* GL_ARB_fragment_shader */\r\n\r\n/* -------------------- GL_ARB_fragment_shader_interlock ------------------- */\r\n\r\n#ifndef GL_ARB_fragment_shader_interlock\r\n#define GL_ARB_fragment_shader_interlock 1\r\n\r\n#define GLEW_ARB_fragment_shader_interlock GLEW_GET_VAR(__GLEW_ARB_fragment_shader_interlock)\r\n\r\n#endif /* GL_ARB_fragment_shader_interlock */\r\n\r\n/* ------------------- GL_ARB_framebuffer_no_attachments ------------------- */\r\n\r\n#ifndef GL_ARB_framebuffer_no_attachments\r\n#define GL_ARB_framebuffer_no_attachments 1\r\n\r\n#define GL_FRAMEBUFFER_DEFAULT_WIDTH 0x9310\r\n#define GL_FRAMEBUFFER_DEFAULT_HEIGHT 0x9311\r\n#define GL_FRAMEBUFFER_DEFAULT_LAYERS 0x9312\r\n#define GL_FRAMEBUFFER_DEFAULT_SAMPLES 0x9313\r\n#define GL_FRAMEBUFFER_DEFAULT_FIXED_SAMPLE_LOCATIONS 0x9314\r\n#define GL_MAX_FRAMEBUFFER_WIDTH 0x9315\r\n#define GL_MAX_FRAMEBUFFER_HEIGHT 0x9316\r\n#define GL_MAX_FRAMEBUFFER_LAYERS 0x9317\r\n#define GL_MAX_FRAMEBUFFER_SAMPLES 0x9318\r\n\r\ntypedef void (GLAPIENTRY * PFNGLFRAMEBUFFERPARAMETERIPROC) (GLenum target, GLenum pname, GLint param);\r\ntypedef void (GLAPIENTRY * PFNGLGETFRAMEBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETNAMEDFRAMEBUFFERPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum pname, GLint* params);\r\ntypedef void (GLAPIENTRY * PFNGLNAMEDFRAMEBUFFERPARAMETERIEXTPROC) (GLuint framebuffer, GLenum pname, GLint param);\r\n\r\n#define glFramebufferParameteri GLEW_GET_FUN(__glewFramebufferParameteri)\r\n#define glGetFramebufferParameteriv GLEW_GET_FUN(__glewGetFramebufferParameteriv)\r\n#define glGetNamedFramebufferParameterivEXT GLEW_GET_FUN(__glewGetNamedFramebufferParameterivEXT)\r\n#define glNamedFramebufferParameteriEXT GLEW_GET_FUN(__glewNamedFramebufferParameteriEXT)\r\n\r\n#define GLEW_ARB_framebuffer_no_attachments GLEW_GET_VAR(__GLEW_ARB_framebuffer_no_attachments)\r\n\r\n#endif /* GL_ARB_framebuffer_no_attachments */\r\n\r\n/* ----------------------- GL_ARB_framebuffer_object ----------------------- */\r\n\r\n#ifndef GL_ARB_framebuffer_object\r\n#define GL_ARB_framebuffer_object 1\r\n\r\n#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506\r\n#define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING 0x8210\r\n#define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE 0x8211\r\n#define GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE 0x8212\r\n#define GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE 0x8213\r\n#define GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE 0x8214\r\n#define GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE 0x8215\r\n#define GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE 0x8216\r\n#define GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE 0x8217\r\n#define GL_FRAMEBUFFER_DEFAULT 0x8218\r\n#define GL_FRAMEBUFFER_UNDEFINED 0x8219\r\n#define GL_DEPTH_STENCIL_ATTACHMENT 0x821A\r\n#define GL_INDEX 0x8222\r\n#define GL_MAX_RENDERBUFFER_SIZE 0x84E8\r\n#define GL_DEPTH_STENCIL 0x84F9\r\n#define GL_UNSIGNED_INT_24_8 0x84FA\r\n#define GL_DEPTH24_STENCIL8 0x88F0\r\n#define GL_TEXTURE_STENCIL_SIZE 0x88F1\r\n#define GL_UNSIGNED_NORMALIZED 0x8C17\r\n#define GL_SRGB 0x8C40\r\n#define GL_DRAW_FRAMEBUFFER_BINDING 0x8CA6\r\n#define GL_FRAMEBUFFER_BINDING 0x8CA6\r\n#define GL_RENDERBUFFER_BINDING 0x8CA7\r\n#define GL_READ_FRAMEBUFFER 0x8CA8\r\n#define GL_DRAW_FRAMEBUFFER 0x8CA9\r\n#define GL_READ_FRAMEBUFFER_BINDING 0x8CAA\r\n#define GL_RENDERBUFFER_SAMPLES 0x8CAB\r\n#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0\r\n#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1\r\n#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2\r\n#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3\r\n#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER 0x8CD4\r\n#define GL_FRAMEBUFFER_COMPLETE 0x8CD5\r\n#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6\r\n#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7\r\n#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER 0x8CDB\r\n#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER 0x8CDC\r\n#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD\r\n#define GL_MAX_COLOR_ATTACHMENTS 0x8CDF\r\n#define GL_COLOR_ATTACHMENT0 0x8CE0\r\n#define GL_COLOR_ATTACHMENT1 0x8CE1\r\n#define GL_COLOR_ATTACHMENT2 0x8CE2\r\n#define GL_COLOR_ATTACHMENT3 0x8CE3\r\n#define GL_COLOR_ATTACHMENT4 0x8CE4\r\n#define GL_COLOR_ATTACHMENT5 0x8CE5\r\n#define GL_COLOR_ATTACHMENT6 0x8CE6\r\n#define GL_COLOR_ATTACHMENT7 0x8CE7\r\n#define GL_COLOR_ATTACHMENT8 0x8CE8\r\n#define GL_COLOR_ATTACHMENT9 0x8CE9\r\n#define GL_COLOR_ATTACHMENT10 0x8CEA\r\n#define GL_COLOR_ATTACHMENT11 0x8CEB\r\n#define GL_COLOR_ATTACHMENT12 0x8CEC\r\n#define GL_COLOR_ATTACHMENT13 0x8CED\r\n#define GL_COLOR_ATTACHMENT14 0x8CEE\r\n#define GL_COLOR_ATTACHMENT15 0x8CEF\r\n#define GL_DEPTH_ATTACHMENT 0x8D00\r\n#define GL_STENCIL_ATTACHMENT 0x8D20\r\n#define GL_FRAMEBUFFER 0x8D40\r\n#define GL_RENDERBUFFER 0x8D41\r\n#define GL_RENDERBUFFER_WIDTH 0x8D42\r\n#define GL_RENDERBUFFER_HEIGHT 0x8D43\r\n#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44\r\n#define GL_STENCIL_INDEX1 0x8D46\r\n#define GL_STENCIL_INDEX4 0x8D47\r\n#define GL_STENCIL_INDEX8 0x8D48\r\n#define GL_STENCIL_INDEX16 0x8D49\r\n#define GL_RENDERBUFFER_RED_SIZE 0x8D50\r\n#define GL_RENDERBUFFER_GREEN_SIZE 0x8D51\r\n#define GL_RENDERBUFFER_BLUE_SIZE 0x8D52\r\n#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53\r\n#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54\r\n#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55\r\n#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE 0x8D56\r\n#define GL_MAX_SAMPLES 0x8D57\r\n\r\ntypedef void (GLAPIENTRY * PFNGLBINDFRAMEBUFFERPROC) (GLenum target, GLuint framebuffer);\r\ntypedef void (GLAPIENTRY * PFNGLBINDRENDERBUFFERPROC) (GLenum target, GLuint renderbuffer);\r\ntypedef void (GLAPIENTRY * PFNGLBLITFRAMEBUFFERPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);\r\ntypedef GLenum (GLAPIENTRY * PFNGLCHECKFRAMEBUFFERSTATUSPROC) (GLenum target);\r\ntypedef void (GLAPIENTRY * PFNGLDELETEFRAMEBUFFERSPROC) (GLsizei n, const GLuint* framebuffers);\r\ntypedef void (GLAPIENTRY * PFNGLDELETERENDERBUFFERSPROC) (GLsizei n, const GLuint* renderbuffers);\r\ntypedef void (GLAPIENTRY * PFNGLFRAMEBUFFERRENDERBUFFERPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);\r\ntypedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURE1DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);\r\ntypedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURE2DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);\r\ntypedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURE3DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint layer);\r\ntypedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURELAYERPROC) (GLenum target,GLenum attachment, GLuint texture,GLint level,GLint layer);\r\ntypedef void (GLAPIENTRY * PFNGLGENFRAMEBUFFERSPROC) (GLsizei n, GLuint* framebuffers);\r\ntypedef void (GLAPIENTRY * PFNGLGENRENDERBUFFERSPROC) (GLsizei n, GLuint* renderbuffers);\r\ntypedef void (GLAPIENTRY * PFNGLGENERATEMIPMAPPROC) (GLenum target);\r\ntypedef void (GLAPIENTRY * PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC) (GLenum target, GLenum attachment, GLenum pname, GLint* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETRENDERBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint* params);\r\ntypedef GLboolean (GLAPIENTRY * PFNGLISFRAMEBUFFERPROC) (GLuint framebuffer);\r\ntypedef GLboolean (GLAPIENTRY * PFNGLISRENDERBUFFERPROC) (GLuint renderbuffer);\r\ntypedef void (GLAPIENTRY * PFNGLRENDERBUFFERSTORAGEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height);\r\ntypedef void (GLAPIENTRY * PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);\r\n\r\n#define glBindFramebuffer GLEW_GET_FUN(__glewBindFramebuffer)\r\n#define glBindRenderbuffer GLEW_GET_FUN(__glewBindRenderbuffer)\r\n#define glBlitFramebuffer GLEW_GET_FUN(__glewBlitFramebuffer)\r\n#define glCheckFramebufferStatus GLEW_GET_FUN(__glewCheckFramebufferStatus)\r\n#define glDeleteFramebuffers GLEW_GET_FUN(__glewDeleteFramebuffers)\r\n#define glDeleteRenderbuffers GLEW_GET_FUN(__glewDeleteRenderbuffers)\r\n#define glFramebufferRenderbuffer GLEW_GET_FUN(__glewFramebufferRenderbuffer)\r\n#define glFramebufferTexture1D GLEW_GET_FUN(__glewFramebufferTexture1D)\r\n#define glFramebufferTexture2D GLEW_GET_FUN(__glewFramebufferTexture2D)\r\n#define glFramebufferTexture3D GLEW_GET_FUN(__glewFramebufferTexture3D)\r\n#define glFramebufferTextureLayer GLEW_GET_FUN(__glewFramebufferTextureLayer)\r\n#define glGenFramebuffers GLEW_GET_FUN(__glewGenFramebuffers)\r\n#define glGenRenderbuffers GLEW_GET_FUN(__glewGenRenderbuffers)\r\n#define glGenerateMipmap GLEW_GET_FUN(__glewGenerateMipmap)\r\n#define glGetFramebufferAttachmentParameteriv GLEW_GET_FUN(__glewGetFramebufferAttachmentParameteriv)\r\n#define glGetRenderbufferParameteriv GLEW_GET_FUN(__glewGetRenderbufferParameteriv)\r\n#define glIsFramebuffer GLEW_GET_FUN(__glewIsFramebuffer)\r\n#define glIsRenderbuffer GLEW_GET_FUN(__glewIsRenderbuffer)\r\n#define glRenderbufferStorage GLEW_GET_FUN(__glewRenderbufferStorage)\r\n#define glRenderbufferStorageMultisample GLEW_GET_FUN(__glewRenderbufferStorageMultisample)\r\n\r\n#define GLEW_ARB_framebuffer_object GLEW_GET_VAR(__GLEW_ARB_framebuffer_object)\r\n\r\n#endif /* GL_ARB_framebuffer_object */\r\n\r\n/* ------------------------ GL_ARB_framebuffer_sRGB ------------------------ */\r\n\r\n#ifndef GL_ARB_framebuffer_sRGB\r\n#define GL_ARB_framebuffer_sRGB 1\r\n\r\n#define GL_FRAMEBUFFER_SRGB 0x8DB9\r\n\r\n#define GLEW_ARB_framebuffer_sRGB GLEW_GET_VAR(__GLEW_ARB_framebuffer_sRGB)\r\n\r\n#endif /* GL_ARB_framebuffer_sRGB */\r\n\r\n/* ------------------------ GL_ARB_geometry_shader4 ------------------------ */\r\n\r\n#ifndef GL_ARB_geometry_shader4\r\n#define GL_ARB_geometry_shader4 1\r\n\r\n#define GL_LINES_ADJACENCY_ARB 0xA\r\n#define GL_LINE_STRIP_ADJACENCY_ARB 0xB\r\n#define GL_TRIANGLES_ADJACENCY_ARB 0xC\r\n#define GL_TRIANGLE_STRIP_ADJACENCY_ARB 0xD\r\n#define GL_PROGRAM_POINT_SIZE_ARB 0x8642\r\n#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_ARB 0x8C29\r\n#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER 0x8CD4\r\n#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_ARB 0x8DA7\r\n#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_ARB 0x8DA8\r\n#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_ARB 0x8DA9\r\n#define GL_GEOMETRY_SHADER_ARB 0x8DD9\r\n#define GL_GEOMETRY_VERTICES_OUT_ARB 0x8DDA\r\n#define GL_GEOMETRY_INPUT_TYPE_ARB 0x8DDB\r\n#define GL_GEOMETRY_OUTPUT_TYPE_ARB 0x8DDC\r\n#define GL_MAX_GEOMETRY_VARYING_COMPONENTS_ARB 0x8DDD\r\n#define GL_MAX_VERTEX_VARYING_COMPONENTS_ARB 0x8DDE\r\n#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_ARB 0x8DDF\r\n#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_ARB 0x8DE0\r\n#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_ARB 0x8DE1\r\n\r\ntypedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTUREARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level);\r\ntypedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTUREFACEARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face);\r\ntypedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURELAYERARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMPARAMETERIARBPROC) (GLuint program, GLenum pname, GLint value);\r\n\r\n#define glFramebufferTextureARB GLEW_GET_FUN(__glewFramebufferTextureARB)\r\n#define glFramebufferTextureFaceARB GLEW_GET_FUN(__glewFramebufferTextureFaceARB)\r\n#define glFramebufferTextureLayerARB GLEW_GET_FUN(__glewFramebufferTextureLayerARB)\r\n#define glProgramParameteriARB GLEW_GET_FUN(__glewProgramParameteriARB)\r\n\r\n#define GLEW_ARB_geometry_shader4 GLEW_GET_VAR(__GLEW_ARB_geometry_shader4)\r\n\r\n#endif /* GL_ARB_geometry_shader4 */\r\n\r\n/* ----------------------- GL_ARB_get_program_binary ----------------------- */\r\n\r\n#ifndef GL_ARB_get_program_binary\r\n#define GL_ARB_get_program_binary 1\r\n\r\n#define GL_PROGRAM_BINARY_RETRIEVABLE_HINT 0x8257\r\n#define GL_PROGRAM_BINARY_LENGTH 0x8741\r\n#define GL_NUM_PROGRAM_BINARY_FORMATS 0x87FE\r\n#define GL_PROGRAM_BINARY_FORMATS 0x87FF\r\n\r\ntypedef void (GLAPIENTRY * PFNGLGETPROGRAMBINARYPROC) (GLuint program, GLsizei bufSize, GLsizei* length, GLenum *binaryFormat, void*binary);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMBINARYPROC) (GLuint program, GLenum binaryFormat, const void *binary, GLsizei length);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMPARAMETERIPROC) (GLuint program, GLenum pname, GLint value);\r\n\r\n#define glGetProgramBinary GLEW_GET_FUN(__glewGetProgramBinary)\r\n#define glProgramBinary GLEW_GET_FUN(__glewProgramBinary)\r\n#define glProgramParameteri GLEW_GET_FUN(__glewProgramParameteri)\r\n\r\n#define GLEW_ARB_get_program_binary GLEW_GET_VAR(__GLEW_ARB_get_program_binary)\r\n\r\n#endif /* GL_ARB_get_program_binary */\r\n\r\n/* ---------------------- GL_ARB_get_texture_sub_image --------------------- */\r\n\r\n#ifndef GL_ARB_get_texture_sub_image\r\n#define GL_ARB_get_texture_sub_image 1\r\n\r\ntypedef void (GLAPIENTRY * PFNGLGETCOMPRESSEDTEXTURESUBIMAGEPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei bufSize, void *pixels);\r\ntypedef void (GLAPIENTRY * PFNGLGETTEXTURESUBIMAGEPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLsizei bufSize, void *pixels);\r\n\r\n#define glGetCompressedTextureSubImage GLEW_GET_FUN(__glewGetCompressedTextureSubImage)\r\n#define glGetTextureSubImage GLEW_GET_FUN(__glewGetTextureSubImage)\r\n\r\n#define GLEW_ARB_get_texture_sub_image GLEW_GET_VAR(__GLEW_ARB_get_texture_sub_image)\r\n\r\n#endif /* GL_ARB_get_texture_sub_image */\r\n\r\n/* --------------------------- GL_ARB_gpu_shader5 -------------------------- */\r\n\r\n#ifndef GL_ARB_gpu_shader5\r\n#define GL_ARB_gpu_shader5 1\r\n\r\n#define GL_GEOMETRY_SHADER_INVOCATIONS 0x887F\r\n#define GL_MAX_GEOMETRY_SHADER_INVOCATIONS 0x8E5A\r\n#define GL_MIN_FRAGMENT_INTERPOLATION_OFFSET 0x8E5B\r\n#define GL_MAX_FRAGMENT_INTERPOLATION_OFFSET 0x8E5C\r\n#define GL_FRAGMENT_INTERPOLATION_OFFSET_BITS 0x8E5D\r\n#define GL_MAX_VERTEX_STREAMS 0x8E71\r\n\r\n#define GLEW_ARB_gpu_shader5 GLEW_GET_VAR(__GLEW_ARB_gpu_shader5)\r\n\r\n#endif /* GL_ARB_gpu_shader5 */\r\n\r\n/* ------------------------- GL_ARB_gpu_shader_fp64 ------------------------ */\r\n\r\n#ifndef GL_ARB_gpu_shader_fp64\r\n#define GL_ARB_gpu_shader_fp64 1\r\n\r\n#define GL_DOUBLE_MAT2 0x8F46\r\n#define GL_DOUBLE_MAT3 0x8F47\r\n#define GL_DOUBLE_MAT4 0x8F48\r\n#define GL_DOUBLE_MAT2x3 0x8F49\r\n#define GL_DOUBLE_MAT2x4 0x8F4A\r\n#define GL_DOUBLE_MAT3x2 0x8F4B\r\n#define GL_DOUBLE_MAT3x4 0x8F4C\r\n#define GL_DOUBLE_MAT4x2 0x8F4D\r\n#define GL_DOUBLE_MAT4x3 0x8F4E\r\n#define GL_DOUBLE_VEC2 0x8FFC\r\n#define GL_DOUBLE_VEC3 0x8FFD\r\n#define GL_DOUBLE_VEC4 0x8FFE\r\n\r\ntypedef void (GLAPIENTRY * PFNGLGETUNIFORMDVPROC) (GLuint program, GLint location, GLdouble* params);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORM1DPROC) (GLint location, GLdouble x);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORM1DVPROC) (GLint location, GLsizei count, const GLdouble* value);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORM2DPROC) (GLint location, GLdouble x, GLdouble y);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORM2DVPROC) (GLint location, GLsizei count, const GLdouble* value);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORM3DPROC) (GLint location, GLdouble x, GLdouble y, GLdouble z);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORM3DVPROC) (GLint location, GLsizei count, const GLdouble* value);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORM4DPROC) (GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORM4DVPROC) (GLint location, GLsizei count, const GLdouble* value);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble* value);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX2X3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble* value);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX2X4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble* value);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble* value);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX3X2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble* value);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX3X4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble* value);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble* value);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX4X2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble* value);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX4X3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble* value);\r\n\r\n#define glGetUniformdv GLEW_GET_FUN(__glewGetUniformdv)\r\n#define glUniform1d GLEW_GET_FUN(__glewUniform1d)\r\n#define glUniform1dv GLEW_GET_FUN(__glewUniform1dv)\r\n#define glUniform2d GLEW_GET_FUN(__glewUniform2d)\r\n#define glUniform2dv GLEW_GET_FUN(__glewUniform2dv)\r\n#define glUniform3d GLEW_GET_FUN(__glewUniform3d)\r\n#define glUniform3dv GLEW_GET_FUN(__glewUniform3dv)\r\n#define glUniform4d GLEW_GET_FUN(__glewUniform4d)\r\n#define glUniform4dv GLEW_GET_FUN(__glewUniform4dv)\r\n#define glUniformMatrix2dv GLEW_GET_FUN(__glewUniformMatrix2dv)\r\n#define glUniformMatrix2x3dv GLEW_GET_FUN(__glewUniformMatrix2x3dv)\r\n#define glUniformMatrix2x4dv GLEW_GET_FUN(__glewUniformMatrix2x4dv)\r\n#define glUniformMatrix3dv GLEW_GET_FUN(__glewUniformMatrix3dv)\r\n#define glUniformMatrix3x2dv GLEW_GET_FUN(__glewUniformMatrix3x2dv)\r\n#define glUniformMatrix3x4dv GLEW_GET_FUN(__glewUniformMatrix3x4dv)\r\n#define glUniformMatrix4dv GLEW_GET_FUN(__glewUniformMatrix4dv)\r\n#define glUniformMatrix4x2dv GLEW_GET_FUN(__glewUniformMatrix4x2dv)\r\n#define glUniformMatrix4x3dv GLEW_GET_FUN(__glewUniformMatrix4x3dv)\r\n\r\n#define GLEW_ARB_gpu_shader_fp64 GLEW_GET_VAR(__GLEW_ARB_gpu_shader_fp64)\r\n\r\n#endif /* GL_ARB_gpu_shader_fp64 */\r\n\r\n/* ------------------------ GL_ARB_gpu_shader_int64 ------------------------ */\r\n\r\n#ifndef GL_ARB_gpu_shader_int64\r\n#define GL_ARB_gpu_shader_int64 1\r\n\r\n#define GL_INT64_ARB 0x140E\r\n#define GL_UNSIGNED_INT64_ARB 0x140F\r\n#define GL_INT64_VEC2_ARB 0x8FE9\r\n#define GL_INT64_VEC3_ARB 0x8FEA\r\n#define GL_INT64_VEC4_ARB 0x8FEB\r\n#define GL_UNSIGNED_INT64_VEC2_ARB 0x8FF5\r\n#define GL_UNSIGNED_INT64_VEC3_ARB 0x8FF6\r\n#define GL_UNSIGNED_INT64_VEC4_ARB 0x8FF7\r\n\r\ntypedef void (GLAPIENTRY * PFNGLGETUNIFORMI64VARBPROC) (GLuint program, GLint location, GLint64* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETUNIFORMUI64VARBPROC) (GLuint program, GLint location, GLuint64* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETNUNIFORMI64VARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLint64* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETNUNIFORMUI64VARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLuint64* params);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1I64ARBPROC) (GLuint program, GLint location, GLint64 x);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1I64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLint64* value);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1UI64ARBPROC) (GLuint program, GLint location, GLuint64 x);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1UI64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLuint64* value);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2I64ARBPROC) (GLuint program, GLint location, GLint64 x, GLint64 y);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2I64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLint64* value);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2UI64ARBPROC) (GLuint program, GLint location, GLuint64 x, GLuint64 y);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2UI64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLuint64* value);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3I64ARBPROC) (GLuint program, GLint location, GLint64 x, GLint64 y, GLint64 z);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3I64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLint64* value);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3UI64ARBPROC) (GLuint program, GLint location, GLuint64 x, GLuint64 y, GLuint64 z);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3UI64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLuint64* value);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4I64ARBPROC) (GLuint program, GLint location, GLint64 x, GLint64 y, GLint64 z, GLint64 w);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4I64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLint64* value);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4UI64ARBPROC) (GLuint program, GLint location, GLuint64 x, GLuint64 y, GLuint64 z, GLuint64 w);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4UI64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLuint64* value);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORM1I64ARBPROC) (GLint location, GLint64 x);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORM1I64VARBPROC) (GLint location, GLsizei count, const GLint64* value);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORM1UI64ARBPROC) (GLint location, GLuint64 x);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORM1UI64VARBPROC) (GLint location, GLsizei count, const GLuint64* value);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORM2I64ARBPROC) (GLint location, GLint64 x, GLint64 y);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORM2I64VARBPROC) (GLint location, GLsizei count, const GLint64* value);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORM2UI64ARBPROC) (GLint location, GLuint64 x, GLuint64 y);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORM2UI64VARBPROC) (GLint location, GLsizei count, const GLuint64* value);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORM3I64ARBPROC) (GLint location, GLint64 x, GLint64 y, GLint64 z);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORM3I64VARBPROC) (GLint location, GLsizei count, const GLint64* value);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORM3UI64ARBPROC) (GLint location, GLuint64 x, GLuint64 y, GLuint64 z);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORM3UI64VARBPROC) (GLint location, GLsizei count, const GLuint64* value);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORM4I64ARBPROC) (GLint location, GLint64 x, GLint64 y, GLint64 z, GLint64 w);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORM4I64VARBPROC) (GLint location, GLsizei count, const GLint64* value);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORM4UI64ARBPROC) (GLint location, GLuint64 x, GLuint64 y, GLuint64 z, GLuint64 w);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORM4UI64VARBPROC) (GLint location, GLsizei count, const GLuint64* value);\r\n\r\n#define glGetUniformi64vARB GLEW_GET_FUN(__glewGetUniformi64vARB)\r\n#define glGetUniformui64vARB GLEW_GET_FUN(__glewGetUniformui64vARB)\r\n#define glGetnUniformi64vARB GLEW_GET_FUN(__glewGetnUniformi64vARB)\r\n#define glGetnUniformui64vARB GLEW_GET_FUN(__glewGetnUniformui64vARB)\r\n#define glProgramUniform1i64ARB GLEW_GET_FUN(__glewProgramUniform1i64ARB)\r\n#define glProgramUniform1i64vARB GLEW_GET_FUN(__glewProgramUniform1i64vARB)\r\n#define glProgramUniform1ui64ARB GLEW_GET_FUN(__glewProgramUniform1ui64ARB)\r\n#define glProgramUniform1ui64vARB GLEW_GET_FUN(__glewProgramUniform1ui64vARB)\r\n#define glProgramUniform2i64ARB GLEW_GET_FUN(__glewProgramUniform2i64ARB)\r\n#define glProgramUniform2i64vARB GLEW_GET_FUN(__glewProgramUniform2i64vARB)\r\n#define glProgramUniform2ui64ARB GLEW_GET_FUN(__glewProgramUniform2ui64ARB)\r\n#define glProgramUniform2ui64vARB GLEW_GET_FUN(__glewProgramUniform2ui64vARB)\r\n#define glProgramUniform3i64ARB GLEW_GET_FUN(__glewProgramUniform3i64ARB)\r\n#define glProgramUniform3i64vARB GLEW_GET_FUN(__glewProgramUniform3i64vARB)\r\n#define glProgramUniform3ui64ARB GLEW_GET_FUN(__glewProgramUniform3ui64ARB)\r\n#define glProgramUniform3ui64vARB GLEW_GET_FUN(__glewProgramUniform3ui64vARB)\r\n#define glProgramUniform4i64ARB GLEW_GET_FUN(__glewProgramUniform4i64ARB)\r\n#define glProgramUniform4i64vARB GLEW_GET_FUN(__glewProgramUniform4i64vARB)\r\n#define glProgramUniform4ui64ARB GLEW_GET_FUN(__glewProgramUniform4ui64ARB)\r\n#define glProgramUniform4ui64vARB GLEW_GET_FUN(__glewProgramUniform4ui64vARB)\r\n#define glUniform1i64ARB GLEW_GET_FUN(__glewUniform1i64ARB)\r\n#define glUniform1i64vARB GLEW_GET_FUN(__glewUniform1i64vARB)\r\n#define glUniform1ui64ARB GLEW_GET_FUN(__glewUniform1ui64ARB)\r\n#define glUniform1ui64vARB GLEW_GET_FUN(__glewUniform1ui64vARB)\r\n#define glUniform2i64ARB GLEW_GET_FUN(__glewUniform2i64ARB)\r\n#define glUniform2i64vARB GLEW_GET_FUN(__glewUniform2i64vARB)\r\n#define glUniform2ui64ARB GLEW_GET_FUN(__glewUniform2ui64ARB)\r\n#define glUniform2ui64vARB GLEW_GET_FUN(__glewUniform2ui64vARB)\r\n#define glUniform3i64ARB GLEW_GET_FUN(__glewUniform3i64ARB)\r\n#define glUniform3i64vARB GLEW_GET_FUN(__glewUniform3i64vARB)\r\n#define glUniform3ui64ARB GLEW_GET_FUN(__glewUniform3ui64ARB)\r\n#define glUniform3ui64vARB GLEW_GET_FUN(__glewUniform3ui64vARB)\r\n#define glUniform4i64ARB GLEW_GET_FUN(__glewUniform4i64ARB)\r\n#define glUniform4i64vARB GLEW_GET_FUN(__glewUniform4i64vARB)\r\n#define glUniform4ui64ARB GLEW_GET_FUN(__glewUniform4ui64ARB)\r\n#define glUniform4ui64vARB GLEW_GET_FUN(__glewUniform4ui64vARB)\r\n\r\n#define GLEW_ARB_gpu_shader_int64 GLEW_GET_VAR(__GLEW_ARB_gpu_shader_int64)\r\n\r\n#endif /* GL_ARB_gpu_shader_int64 */\r\n\r\n/* ------------------------ GL_ARB_half_float_pixel ------------------------ */\r\n\r\n#ifndef GL_ARB_half_float_pixel\r\n#define GL_ARB_half_float_pixel 1\r\n\r\n#define GL_HALF_FLOAT_ARB 0x140B\r\n\r\n#define GLEW_ARB_half_float_pixel GLEW_GET_VAR(__GLEW_ARB_half_float_pixel)\r\n\r\n#endif /* GL_ARB_half_float_pixel */\r\n\r\n/* ------------------------ GL_ARB_half_float_vertex ----------------------- */\r\n\r\n#ifndef GL_ARB_half_float_vertex\r\n#define GL_ARB_half_float_vertex 1\r\n\r\n#define GL_HALF_FLOAT 0x140B\r\n\r\n#define GLEW_ARB_half_float_vertex GLEW_GET_VAR(__GLEW_ARB_half_float_vertex)\r\n\r\n#endif /* GL_ARB_half_float_vertex */\r\n\r\n/* ----------------------------- GL_ARB_imaging ---------------------------- */\r\n\r\n#ifndef GL_ARB_imaging\r\n#define GL_ARB_imaging 1\r\n\r\n#define GL_CONSTANT_COLOR 0x8001\r\n#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002\r\n#define GL_CONSTANT_ALPHA 0x8003\r\n#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004\r\n#define GL_BLEND_COLOR 0x8005\r\n#define GL_FUNC_ADD 0x8006\r\n#define GL_MIN 0x8007\r\n#define GL_MAX 0x8008\r\n#define GL_BLEND_EQUATION 0x8009\r\n#define GL_FUNC_SUBTRACT 0x800A\r\n#define GL_FUNC_REVERSE_SUBTRACT 0x800B\r\n#define GL_CONVOLUTION_1D 0x8010\r\n#define GL_CONVOLUTION_2D 0x8011\r\n#define GL_SEPARABLE_2D 0x8012\r\n#define GL_CONVOLUTION_BORDER_MODE 0x8013\r\n#define GL_CONVOLUTION_FILTER_SCALE 0x8014\r\n#define GL_CONVOLUTION_FILTER_BIAS 0x8015\r\n#define GL_REDUCE 0x8016\r\n#define GL_CONVOLUTION_FORMAT 0x8017\r\n#define GL_CONVOLUTION_WIDTH 0x8018\r\n#define GL_CONVOLUTION_HEIGHT 0x8019\r\n#define GL_MAX_CONVOLUTION_WIDTH 0x801A\r\n#define GL_MAX_CONVOLUTION_HEIGHT 0x801B\r\n#define GL_POST_CONVOLUTION_RED_SCALE 0x801C\r\n#define GL_POST_CONVOLUTION_GREEN_SCALE 0x801D\r\n#define GL_POST_CONVOLUTION_BLUE_SCALE 0x801E\r\n#define GL_POST_CONVOLUTION_ALPHA_SCALE 0x801F\r\n#define GL_POST_CONVOLUTION_RED_BIAS 0x8020\r\n#define GL_POST_CONVOLUTION_GREEN_BIAS 0x8021\r\n#define GL_POST_CONVOLUTION_BLUE_BIAS 0x8022\r\n#define GL_POST_CONVOLUTION_ALPHA_BIAS 0x8023\r\n#define GL_HISTOGRAM 0x8024\r\n#define GL_PROXY_HISTOGRAM 0x8025\r\n#define GL_HISTOGRAM_WIDTH 0x8026\r\n#define GL_HISTOGRAM_FORMAT 0x8027\r\n#define GL_HISTOGRAM_RED_SIZE 0x8028\r\n#define GL_HISTOGRAM_GREEN_SIZE 0x8029\r\n#define GL_HISTOGRAM_BLUE_SIZE 0x802A\r\n#define GL_HISTOGRAM_ALPHA_SIZE 0x802B\r\n#define GL_HISTOGRAM_LUMINANCE_SIZE 0x802C\r\n#define GL_HISTOGRAM_SINK 0x802D\r\n#define GL_MINMAX 0x802E\r\n#define GL_MINMAX_FORMAT 0x802F\r\n#define GL_MINMAX_SINK 0x8030\r\n#define GL_TABLE_TOO_LARGE 0x8031\r\n#define GL_COLOR_MATRIX 0x80B1\r\n#define GL_COLOR_MATRIX_STACK_DEPTH 0x80B2\r\n#define GL_MAX_COLOR_MATRIX_STACK_DEPTH 0x80B3\r\n#define GL_POST_COLOR_MATRIX_RED_SCALE 0x80B4\r\n#define GL_POST_COLOR_MATRIX_GREEN_SCALE 0x80B5\r\n#define GL_POST_COLOR_MATRIX_BLUE_SCALE 0x80B6\r\n#define GL_POST_COLOR_MATRIX_ALPHA_SCALE 0x80B7\r\n#define GL_POST_COLOR_MATRIX_RED_BIAS 0x80B8\r\n#define GL_POST_COLOR_MATRIX_GREEN_BIAS 0x80B9\r\n#define GL_POST_COLOR_MATRIX_BLUE_BIAS 0x80BA\r\n#define GL_POST_COLOR_MATRIX_ALPHA_BIAS 0x80BB\r\n#define GL_COLOR_TABLE 0x80D0\r\n#define GL_POST_CONVOLUTION_COLOR_TABLE 0x80D1\r\n#define GL_POST_COLOR_MATRIX_COLOR_TABLE 0x80D2\r\n#define GL_PROXY_COLOR_TABLE 0x80D3\r\n#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE 0x80D4\r\n#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE 0x80D5\r\n#define GL_COLOR_TABLE_SCALE 0x80D6\r\n#define GL_COLOR_TABLE_BIAS 0x80D7\r\n#define GL_COLOR_TABLE_FORMAT 0x80D8\r\n#define GL_COLOR_TABLE_WIDTH 0x80D9\r\n#define GL_COLOR_TABLE_RED_SIZE 0x80DA\r\n#define GL_COLOR_TABLE_GREEN_SIZE 0x80DB\r\n#define GL_COLOR_TABLE_BLUE_SIZE 0x80DC\r\n#define GL_COLOR_TABLE_ALPHA_SIZE 0x80DD\r\n#define GL_COLOR_TABLE_LUMINANCE_SIZE 0x80DE\r\n#define GL_COLOR_TABLE_INTENSITY_SIZE 0x80DF\r\n#define GL_IGNORE_BORDER 0x8150\r\n#define GL_CONSTANT_BORDER 0x8151\r\n#define GL_WRAP_BORDER 0x8152\r\n#define GL_REPLICATE_BORDER 0x8153\r\n#define GL_CONVOLUTION_BORDER_COLOR 0x8154\r\n\r\ntypedef void (GLAPIENTRY * PFNGLCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const void *data);\r\ntypedef void (GLAPIENTRY * PFNGLCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *table);\r\ntypedef void (GLAPIENTRY * PFNGLCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params);\r\ntypedef void (GLAPIENTRY * PFNGLCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params);\r\ntypedef void (GLAPIENTRY * PFNGLCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *image);\r\ntypedef void (GLAPIENTRY * PFNGLCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *image);\r\ntypedef void (GLAPIENTRY * PFNGLCONVOLUTIONPARAMETERFPROC) (GLenum target, GLenum pname, GLfloat params);\r\ntypedef void (GLAPIENTRY * PFNGLCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params);\r\ntypedef void (GLAPIENTRY * PFNGLCONVOLUTIONPARAMETERIPROC) (GLenum target, GLenum pname, GLint params);\r\ntypedef void (GLAPIENTRY * PFNGLCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params);\r\ntypedef void (GLAPIENTRY * PFNGLCOPYCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width);\r\ntypedef void (GLAPIENTRY * PFNGLCOPYCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width);\r\ntypedef void (GLAPIENTRY * PFNGLCOPYCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width);\r\ntypedef void (GLAPIENTRY * PFNGLCOPYCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height);\r\ntypedef void (GLAPIENTRY * PFNGLGETCOLORTABLEPROC) (GLenum target, GLenum format, GLenum type, void *table);\r\ntypedef void (GLAPIENTRY * PFNGLGETCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params);\r\ntypedef void (GLAPIENTRY * PFNGLGETCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params);\r\ntypedef void (GLAPIENTRY * PFNGLGETCONVOLUTIONFILTERPROC) (GLenum target, GLenum format, GLenum type, void *image);\r\ntypedef void (GLAPIENTRY * PFNGLGETCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params);\r\ntypedef void (GLAPIENTRY * PFNGLGETCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params);\r\ntypedef void (GLAPIENTRY * PFNGLGETHISTOGRAMPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values);\r\ntypedef void (GLAPIENTRY * PFNGLGETHISTOGRAMPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params);\r\ntypedef void (GLAPIENTRY * PFNGLGETHISTOGRAMPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params);\r\ntypedef void (GLAPIENTRY * PFNGLGETMINMAXPROC) (GLenum target, GLboolean reset, GLenum format, GLenum types, void *values);\r\ntypedef void (GLAPIENTRY * PFNGLGETMINMAXPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params);\r\ntypedef void (GLAPIENTRY * PFNGLGETMINMAXPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params);\r\ntypedef void (GLAPIENTRY * PFNGLGETSEPARABLEFILTERPROC) (GLenum target, GLenum format, GLenum type, void *row, void *column, void *span);\r\ntypedef void (GLAPIENTRY * PFNGLHISTOGRAMPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink);\r\ntypedef void (GLAPIENTRY * PFNGLMINMAXPROC) (GLenum target, GLenum internalformat, GLboolean sink);\r\ntypedef void (GLAPIENTRY * PFNGLRESETHISTOGRAMPROC) (GLenum target);\r\ntypedef void (GLAPIENTRY * PFNGLRESETMINMAXPROC) (GLenum target);\r\ntypedef void (GLAPIENTRY * PFNGLSEPARABLEFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *row, const void *column);\r\n\r\n#define glColorSubTable GLEW_GET_FUN(__glewColorSubTable)\r\n#define glColorTable GLEW_GET_FUN(__glewColorTable)\r\n#define glColorTableParameterfv GLEW_GET_FUN(__glewColorTableParameterfv)\r\n#define glColorTableParameteriv GLEW_GET_FUN(__glewColorTableParameteriv)\r\n#define glConvolutionFilter1D GLEW_GET_FUN(__glewConvolutionFilter1D)\r\n#define glConvolutionFilter2D GLEW_GET_FUN(__glewConvolutionFilter2D)\r\n#define glConvolutionParameterf GLEW_GET_FUN(__glewConvolutionParameterf)\r\n#define glConvolutionParameterfv GLEW_GET_FUN(__glewConvolutionParameterfv)\r\n#define glConvolutionParameteri GLEW_GET_FUN(__glewConvolutionParameteri)\r\n#define glConvolutionParameteriv GLEW_GET_FUN(__glewConvolutionParameteriv)\r\n#define glCopyColorSubTable GLEW_GET_FUN(__glewCopyColorSubTable)\r\n#define glCopyColorTable GLEW_GET_FUN(__glewCopyColorTable)\r\n#define glCopyConvolutionFilter1D GLEW_GET_FUN(__glewCopyConvolutionFilter1D)\r\n#define glCopyConvolutionFilter2D GLEW_GET_FUN(__glewCopyConvolutionFilter2D)\r\n#define glGetColorTable GLEW_GET_FUN(__glewGetColorTable)\r\n#define glGetColorTableParameterfv GLEW_GET_FUN(__glewGetColorTableParameterfv)\r\n#define glGetColorTableParameteriv GLEW_GET_FUN(__glewGetColorTableParameteriv)\r\n#define glGetConvolutionFilter GLEW_GET_FUN(__glewGetConvolutionFilter)\r\n#define glGetConvolutionParameterfv GLEW_GET_FUN(__glewGetConvolutionParameterfv)\r\n#define glGetConvolutionParameteriv GLEW_GET_FUN(__glewGetConvolutionParameteriv)\r\n#define glGetHistogram GLEW_GET_FUN(__glewGetHistogram)\r\n#define glGetHistogramParameterfv GLEW_GET_FUN(__glewGetHistogramParameterfv)\r\n#define glGetHistogramParameteriv GLEW_GET_FUN(__glewGetHistogramParameteriv)\r\n#define glGetMinmax GLEW_GET_FUN(__glewGetMinmax)\r\n#define glGetMinmaxParameterfv GLEW_GET_FUN(__glewGetMinmaxParameterfv)\r\n#define glGetMinmaxParameteriv GLEW_GET_FUN(__glewGetMinmaxParameteriv)\r\n#define glGetSeparableFilter GLEW_GET_FUN(__glewGetSeparableFilter)\r\n#define glHistogram GLEW_GET_FUN(__glewHistogram)\r\n#define glMinmax GLEW_GET_FUN(__glewMinmax)\r\n#define glResetHistogram GLEW_GET_FUN(__glewResetHistogram)\r\n#define glResetMinmax GLEW_GET_FUN(__glewResetMinmax)\r\n#define glSeparableFilter2D GLEW_GET_FUN(__glewSeparableFilter2D)\r\n\r\n#define GLEW_ARB_imaging GLEW_GET_VAR(__GLEW_ARB_imaging)\r\n\r\n#endif /* GL_ARB_imaging */\r\n\r\n/* ----------------------- GL_ARB_indirect_parameters ---------------------- */\r\n\r\n#ifndef GL_ARB_indirect_parameters\r\n#define GL_ARB_indirect_parameters 1\r\n\r\n#define GL_PARAMETER_BUFFER_ARB 0x80EE\r\n#define GL_PARAMETER_BUFFER_BINDING_ARB 0x80EF\r\n\r\ntypedef void (GLAPIENTRY * PFNGLMULTIDRAWARRAYSINDIRECTCOUNTARBPROC) (GLenum mode, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride);\r\ntypedef void (GLAPIENTRY * PFNGLMULTIDRAWELEMENTSINDIRECTCOUNTARBPROC) (GLenum mode, GLenum type, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride);\r\n\r\n#define glMultiDrawArraysIndirectCountARB GLEW_GET_FUN(__glewMultiDrawArraysIndirectCountARB)\r\n#define glMultiDrawElementsIndirectCountARB GLEW_GET_FUN(__glewMultiDrawElementsIndirectCountARB)\r\n\r\n#define GLEW_ARB_indirect_parameters GLEW_GET_VAR(__GLEW_ARB_indirect_parameters)\r\n\r\n#endif /* GL_ARB_indirect_parameters */\r\n\r\n/* ------------------------ GL_ARB_instanced_arrays ------------------------ */\r\n\r\n#ifndef GL_ARB_instanced_arrays\r\n#define GL_ARB_instanced_arrays 1\r\n\r\n#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ARB 0x88FE\r\n\r\ntypedef void (GLAPIENTRY * PFNGLDRAWARRAYSINSTANCEDARBPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount);\r\ntypedef void (GLAPIENTRY * PFNGLDRAWELEMENTSINSTANCEDARBPROC) (GLenum mode, GLsizei count, GLenum type, const void* indices, GLsizei primcount);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBDIVISORARBPROC) (GLuint index, GLuint divisor);\r\n\r\n#define glDrawArraysInstancedARB GLEW_GET_FUN(__glewDrawArraysInstancedARB)\r\n#define glDrawElementsInstancedARB GLEW_GET_FUN(__glewDrawElementsInstancedARB)\r\n#define glVertexAttribDivisorARB GLEW_GET_FUN(__glewVertexAttribDivisorARB)\r\n\r\n#define GLEW_ARB_instanced_arrays GLEW_GET_VAR(__GLEW_ARB_instanced_arrays)\r\n\r\n#endif /* GL_ARB_instanced_arrays */\r\n\r\n/* ---------------------- GL_ARB_internalformat_query ---------------------- */\r\n\r\n#ifndef GL_ARB_internalformat_query\r\n#define GL_ARB_internalformat_query 1\r\n\r\n#define GL_NUM_SAMPLE_COUNTS 0x9380\r\n\r\ntypedef void (GLAPIENTRY * PFNGLGETINTERNALFORMATIVPROC) (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint* params);\r\n\r\n#define glGetInternalformativ GLEW_GET_FUN(__glewGetInternalformativ)\r\n\r\n#define GLEW_ARB_internalformat_query GLEW_GET_VAR(__GLEW_ARB_internalformat_query)\r\n\r\n#endif /* GL_ARB_internalformat_query */\r\n\r\n/* ---------------------- GL_ARB_internalformat_query2 --------------------- */\r\n\r\n#ifndef GL_ARB_internalformat_query2\r\n#define GL_ARB_internalformat_query2 1\r\n\r\n#define GL_INTERNALFORMAT_SUPPORTED 0x826F\r\n#define GL_INTERNALFORMAT_PREFERRED 0x8270\r\n#define GL_INTERNALFORMAT_RED_SIZE 0x8271\r\n#define GL_INTERNALFORMAT_GREEN_SIZE 0x8272\r\n#define GL_INTERNALFORMAT_BLUE_SIZE 0x8273\r\n#define GL_INTERNALFORMAT_ALPHA_SIZE 0x8274\r\n#define GL_INTERNALFORMAT_DEPTH_SIZE 0x8275\r\n#define GL_INTERNALFORMAT_STENCIL_SIZE 0x8276\r\n#define GL_INTERNALFORMAT_SHARED_SIZE 0x8277\r\n#define GL_INTERNALFORMAT_RED_TYPE 0x8278\r\n#define GL_INTERNALFORMAT_GREEN_TYPE 0x8279\r\n#define GL_INTERNALFORMAT_BLUE_TYPE 0x827A\r\n#define GL_INTERNALFORMAT_ALPHA_TYPE 0x827B\r\n#define GL_INTERNALFORMAT_DEPTH_TYPE 0x827C\r\n#define GL_INTERNALFORMAT_STENCIL_TYPE 0x827D\r\n#define GL_MAX_WIDTH 0x827E\r\n#define GL_MAX_HEIGHT 0x827F\r\n#define GL_MAX_DEPTH 0x8280\r\n#define GL_MAX_LAYERS 0x8281\r\n#define GL_MAX_COMBINED_DIMENSIONS 0x8282\r\n#define GL_COLOR_COMPONENTS 0x8283\r\n#define GL_DEPTH_COMPONENTS 0x8284\r\n#define GL_STENCIL_COMPONENTS 0x8285\r\n#define GL_COLOR_RENDERABLE 0x8286\r\n#define GL_DEPTH_RENDERABLE 0x8287\r\n#define GL_STENCIL_RENDERABLE 0x8288\r\n#define GL_FRAMEBUFFER_RENDERABLE 0x8289\r\n#define GL_FRAMEBUFFER_RENDERABLE_LAYERED 0x828A\r\n#define GL_FRAMEBUFFER_BLEND 0x828B\r\n#define GL_READ_PIXELS 0x828C\r\n#define GL_READ_PIXELS_FORMAT 0x828D\r\n#define GL_READ_PIXELS_TYPE 0x828E\r\n#define GL_TEXTURE_IMAGE_FORMAT 0x828F\r\n#define GL_TEXTURE_IMAGE_TYPE 0x8290\r\n#define GL_GET_TEXTURE_IMAGE_FORMAT 0x8291\r\n#define GL_GET_TEXTURE_IMAGE_TYPE 0x8292\r\n#define GL_MIPMAP 0x8293\r\n#define GL_MANUAL_GENERATE_MIPMAP 0x8294\r\n#define GL_AUTO_GENERATE_MIPMAP 0x8295\r\n#define GL_COLOR_ENCODING 0x8296\r\n#define GL_SRGB_READ 0x8297\r\n#define GL_SRGB_WRITE 0x8298\r\n#define GL_SRGB_DECODE_ARB 0x8299\r\n#define GL_FILTER 0x829A\r\n#define GL_VERTEX_TEXTURE 0x829B\r\n#define GL_TESS_CONTROL_TEXTURE 0x829C\r\n#define GL_TESS_EVALUATION_TEXTURE 0x829D\r\n#define GL_GEOMETRY_TEXTURE 0x829E\r\n#define GL_FRAGMENT_TEXTURE 0x829F\r\n#define GL_COMPUTE_TEXTURE 0x82A0\r\n#define GL_TEXTURE_SHADOW 0x82A1\r\n#define GL_TEXTURE_GATHER 0x82A2\r\n#define GL_TEXTURE_GATHER_SHADOW 0x82A3\r\n#define GL_SHADER_IMAGE_LOAD 0x82A4\r\n#define GL_SHADER_IMAGE_STORE 0x82A5\r\n#define GL_SHADER_IMAGE_ATOMIC 0x82A6\r\n#define GL_IMAGE_TEXEL_SIZE 0x82A7\r\n#define GL_IMAGE_COMPATIBILITY_CLASS 0x82A8\r\n#define GL_IMAGE_PIXEL_FORMAT 0x82A9\r\n#define GL_IMAGE_PIXEL_TYPE 0x82AA\r\n#define GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_TEST 0x82AC\r\n#define GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_TEST 0x82AD\r\n#define GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_WRITE 0x82AE\r\n#define GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_WRITE 0x82AF\r\n#define GL_TEXTURE_COMPRESSED_BLOCK_WIDTH 0x82B1\r\n#define GL_TEXTURE_COMPRESSED_BLOCK_HEIGHT 0x82B2\r\n#define GL_TEXTURE_COMPRESSED_BLOCK_SIZE 0x82B3\r\n#define GL_CLEAR_BUFFER 0x82B4\r\n#define GL_TEXTURE_VIEW 0x82B5\r\n#define GL_VIEW_COMPATIBILITY_CLASS 0x82B6\r\n#define GL_FULL_SUPPORT 0x82B7\r\n#define GL_CAVEAT_SUPPORT 0x82B8\r\n#define GL_IMAGE_CLASS_4_X_32 0x82B9\r\n#define GL_IMAGE_CLASS_2_X_32 0x82BA\r\n#define GL_IMAGE_CLASS_1_X_32 0x82BB\r\n#define GL_IMAGE_CLASS_4_X_16 0x82BC\r\n#define GL_IMAGE_CLASS_2_X_16 0x82BD\r\n#define GL_IMAGE_CLASS_1_X_16 0x82BE\r\n#define GL_IMAGE_CLASS_4_X_8 0x82BF\r\n#define GL_IMAGE_CLASS_2_X_8 0x82C0\r\n#define GL_IMAGE_CLASS_1_X_8 0x82C1\r\n#define GL_IMAGE_CLASS_11_11_10 0x82C2\r\n#define GL_IMAGE_CLASS_10_10_10_2 0x82C3\r\n#define GL_VIEW_CLASS_128_BITS 0x82C4\r\n#define GL_VIEW_CLASS_96_BITS 0x82C5\r\n#define GL_VIEW_CLASS_64_BITS 0x82C6\r\n#define GL_VIEW_CLASS_48_BITS 0x82C7\r\n#define GL_VIEW_CLASS_32_BITS 0x82C8\r\n#define GL_VIEW_CLASS_24_BITS 0x82C9\r\n#define GL_VIEW_CLASS_16_BITS 0x82CA\r\n#define GL_VIEW_CLASS_8_BITS 0x82CB\r\n#define GL_VIEW_CLASS_S3TC_DXT1_RGB 0x82CC\r\n#define GL_VIEW_CLASS_S3TC_DXT1_RGBA 0x82CD\r\n#define GL_VIEW_CLASS_S3TC_DXT3_RGBA 0x82CE\r\n#define GL_VIEW_CLASS_S3TC_DXT5_RGBA 0x82CF\r\n#define GL_VIEW_CLASS_RGTC1_RED 0x82D0\r\n#define GL_VIEW_CLASS_RGTC2_RG 0x82D1\r\n#define GL_VIEW_CLASS_BPTC_UNORM 0x82D2\r\n#define GL_VIEW_CLASS_BPTC_FLOAT 0x82D3\r\n\r\ntypedef void (GLAPIENTRY * PFNGLGETINTERNALFORMATI64VPROC) (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint64* params);\r\n\r\n#define glGetInternalformati64v GLEW_GET_FUN(__glewGetInternalformati64v)\r\n\r\n#define GLEW_ARB_internalformat_query2 GLEW_GET_VAR(__GLEW_ARB_internalformat_query2)\r\n\r\n#endif /* GL_ARB_internalformat_query2 */\r\n\r\n/* ----------------------- GL_ARB_invalidate_subdata ----------------------- */\r\n\r\n#ifndef GL_ARB_invalidate_subdata\r\n#define GL_ARB_invalidate_subdata 1\r\n\r\ntypedef void (GLAPIENTRY * PFNGLINVALIDATEBUFFERDATAPROC) (GLuint buffer);\r\ntypedef void (GLAPIENTRY * PFNGLINVALIDATEBUFFERSUBDATAPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length);\r\ntypedef void (GLAPIENTRY * PFNGLINVALIDATEFRAMEBUFFERPROC) (GLenum target, GLsizei numAttachments, const GLenum* attachments);\r\ntypedef void (GLAPIENTRY * PFNGLINVALIDATESUBFRAMEBUFFERPROC) (GLenum target, GLsizei numAttachments, const GLenum* attachments, GLint x, GLint y, GLsizei width, GLsizei height);\r\ntypedef void (GLAPIENTRY * PFNGLINVALIDATETEXIMAGEPROC) (GLuint texture, GLint level);\r\ntypedef void (GLAPIENTRY * PFNGLINVALIDATETEXSUBIMAGEPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth);\r\n\r\n#define glInvalidateBufferData GLEW_GET_FUN(__glewInvalidateBufferData)\r\n#define glInvalidateBufferSubData GLEW_GET_FUN(__glewInvalidateBufferSubData)\r\n#define glInvalidateFramebuffer GLEW_GET_FUN(__glewInvalidateFramebuffer)\r\n#define glInvalidateSubFramebuffer GLEW_GET_FUN(__glewInvalidateSubFramebuffer)\r\n#define glInvalidateTexImage GLEW_GET_FUN(__glewInvalidateTexImage)\r\n#define glInvalidateTexSubImage GLEW_GET_FUN(__glewInvalidateTexSubImage)\r\n\r\n#define GLEW_ARB_invalidate_subdata GLEW_GET_VAR(__GLEW_ARB_invalidate_subdata)\r\n\r\n#endif /* GL_ARB_invalidate_subdata */\r\n\r\n/* ---------------------- GL_ARB_map_buffer_alignment ---------------------- */\r\n\r\n#ifndef GL_ARB_map_buffer_alignment\r\n#define GL_ARB_map_buffer_alignment 1\r\n\r\n#define GL_MIN_MAP_BUFFER_ALIGNMENT 0x90BC\r\n\r\n#define GLEW_ARB_map_buffer_alignment GLEW_GET_VAR(__GLEW_ARB_map_buffer_alignment)\r\n\r\n#endif /* GL_ARB_map_buffer_alignment */\r\n\r\n/* ------------------------ GL_ARB_map_buffer_range ------------------------ */\r\n\r\n#ifndef GL_ARB_map_buffer_range\r\n#define GL_ARB_map_buffer_range 1\r\n\r\n#define GL_MAP_READ_BIT 0x0001\r\n#define GL_MAP_WRITE_BIT 0x0002\r\n#define GL_MAP_INVALIDATE_RANGE_BIT 0x0004\r\n#define GL_MAP_INVALIDATE_BUFFER_BIT 0x0008\r\n#define GL_MAP_FLUSH_EXPLICIT_BIT 0x0010\r\n#define GL_MAP_UNSYNCHRONIZED_BIT 0x0020\r\n\r\ntypedef void (GLAPIENTRY * PFNGLFLUSHMAPPEDBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length);\r\ntypedef void * (GLAPIENTRY * PFNGLMAPBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access);\r\n\r\n#define glFlushMappedBufferRange GLEW_GET_FUN(__glewFlushMappedBufferRange)\r\n#define glMapBufferRange GLEW_GET_FUN(__glewMapBufferRange)\r\n\r\n#define GLEW_ARB_map_buffer_range GLEW_GET_VAR(__GLEW_ARB_map_buffer_range)\r\n\r\n#endif /* GL_ARB_map_buffer_range */\r\n\r\n/* ------------------------- GL_ARB_matrix_palette ------------------------- */\r\n\r\n#ifndef GL_ARB_matrix_palette\r\n#define GL_ARB_matrix_palette 1\r\n\r\n#define GL_MATRIX_PALETTE_ARB 0x8840\r\n#define GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB 0x8841\r\n#define GL_MAX_PALETTE_MATRICES_ARB 0x8842\r\n#define GL_CURRENT_PALETTE_MATRIX_ARB 0x8843\r\n#define GL_MATRIX_INDEX_ARRAY_ARB 0x8844\r\n#define GL_CURRENT_MATRIX_INDEX_ARB 0x8845\r\n#define GL_MATRIX_INDEX_ARRAY_SIZE_ARB 0x8846\r\n#define GL_MATRIX_INDEX_ARRAY_TYPE_ARB 0x8847\r\n#define GL_MATRIX_INDEX_ARRAY_STRIDE_ARB 0x8848\r\n#define GL_MATRIX_INDEX_ARRAY_POINTER_ARB 0x8849\r\n\r\ntypedef void (GLAPIENTRY * PFNGLCURRENTPALETTEMATRIXARBPROC) (GLint index);\r\ntypedef void (GLAPIENTRY * PFNGLMATRIXINDEXPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, void *pointer);\r\ntypedef void (GLAPIENTRY * PFNGLMATRIXINDEXUBVARBPROC) (GLint size, GLubyte *indices);\r\ntypedef void (GLAPIENTRY * PFNGLMATRIXINDEXUIVARBPROC) (GLint size, GLuint *indices);\r\ntypedef void (GLAPIENTRY * PFNGLMATRIXINDEXUSVARBPROC) (GLint size, GLushort *indices);\r\n\r\n#define glCurrentPaletteMatrixARB GLEW_GET_FUN(__glewCurrentPaletteMatrixARB)\r\n#define glMatrixIndexPointerARB GLEW_GET_FUN(__glewMatrixIndexPointerARB)\r\n#define glMatrixIndexubvARB GLEW_GET_FUN(__glewMatrixIndexubvARB)\r\n#define glMatrixIndexuivARB GLEW_GET_FUN(__glewMatrixIndexuivARB)\r\n#define glMatrixIndexusvARB GLEW_GET_FUN(__glewMatrixIndexusvARB)\r\n\r\n#define GLEW_ARB_matrix_palette GLEW_GET_VAR(__GLEW_ARB_matrix_palette)\r\n\r\n#endif /* GL_ARB_matrix_palette */\r\n\r\n/* --------------------------- GL_ARB_multi_bind --------------------------- */\r\n\r\n#ifndef GL_ARB_multi_bind\r\n#define GL_ARB_multi_bind 1\r\n\r\ntypedef void (GLAPIENTRY * PFNGLBINDBUFFERSBASEPROC) (GLenum target, GLuint first, GLsizei count, const GLuint* buffers);\r\ntypedef void (GLAPIENTRY * PFNGLBINDBUFFERSRANGEPROC) (GLenum target, GLuint first, GLsizei count, const GLuint* buffers, const GLintptr *offsets, const GLsizeiptr *sizes);\r\ntypedef void (GLAPIENTRY * PFNGLBINDIMAGETEXTURESPROC) (GLuint first, GLsizei count, const GLuint* textures);\r\ntypedef void (GLAPIENTRY * PFNGLBINDSAMPLERSPROC) (GLuint first, GLsizei count, const GLuint* samplers);\r\ntypedef void (GLAPIENTRY * PFNGLBINDTEXTURESPROC) (GLuint first, GLsizei count, const GLuint* textures);\r\ntypedef void (GLAPIENTRY * PFNGLBINDVERTEXBUFFERSPROC) (GLuint first, GLsizei count, const GLuint* buffers, const GLintptr *offsets, const GLsizei *strides);\r\n\r\n#define glBindBuffersBase GLEW_GET_FUN(__glewBindBuffersBase)\r\n#define glBindBuffersRange GLEW_GET_FUN(__glewBindBuffersRange)\r\n#define glBindImageTextures GLEW_GET_FUN(__glewBindImageTextures)\r\n#define glBindSamplers GLEW_GET_FUN(__glewBindSamplers)\r\n#define glBindTextures GLEW_GET_FUN(__glewBindTextures)\r\n#define glBindVertexBuffers GLEW_GET_FUN(__glewBindVertexBuffers)\r\n\r\n#define GLEW_ARB_multi_bind GLEW_GET_VAR(__GLEW_ARB_multi_bind)\r\n\r\n#endif /* GL_ARB_multi_bind */\r\n\r\n/* ----------------------- GL_ARB_multi_draw_indirect ---------------------- */\r\n\r\n#ifndef GL_ARB_multi_draw_indirect\r\n#define GL_ARB_multi_draw_indirect 1\r\n\r\ntypedef void (GLAPIENTRY * PFNGLMULTIDRAWARRAYSINDIRECTPROC) (GLenum mode, const void *indirect, GLsizei primcount, GLsizei stride);\r\ntypedef void (GLAPIENTRY * PFNGLMULTIDRAWELEMENTSINDIRECTPROC) (GLenum mode, GLenum type, const void *indirect, GLsizei primcount, GLsizei stride);\r\n\r\n#define glMultiDrawArraysIndirect GLEW_GET_FUN(__glewMultiDrawArraysIndirect)\r\n#define glMultiDrawElementsIndirect GLEW_GET_FUN(__glewMultiDrawElementsIndirect)\r\n\r\n#define GLEW_ARB_multi_draw_indirect GLEW_GET_VAR(__GLEW_ARB_multi_draw_indirect)\r\n\r\n#endif /* GL_ARB_multi_draw_indirect */\r\n\r\n/* --------------------------- GL_ARB_multisample -------------------------- */\r\n\r\n#ifndef GL_ARB_multisample\r\n#define GL_ARB_multisample 1\r\n\r\n#define GL_MULTISAMPLE_ARB 0x809D\r\n#define GL_SAMPLE_ALPHA_TO_COVERAGE_ARB 0x809E\r\n#define GL_SAMPLE_ALPHA_TO_ONE_ARB 0x809F\r\n#define GL_SAMPLE_COVERAGE_ARB 0x80A0\r\n#define GL_SAMPLE_BUFFERS_ARB 0x80A8\r\n#define GL_SAMPLES_ARB 0x80A9\r\n#define GL_SAMPLE_COVERAGE_VALUE_ARB 0x80AA\r\n#define GL_SAMPLE_COVERAGE_INVERT_ARB 0x80AB\r\n#define GL_MULTISAMPLE_BIT_ARB 0x20000000\r\n\r\ntypedef void (GLAPIENTRY * PFNGLSAMPLECOVERAGEARBPROC) (GLclampf value, GLboolean invert);\r\n\r\n#define glSampleCoverageARB GLEW_GET_FUN(__glewSampleCoverageARB)\r\n\r\n#define GLEW_ARB_multisample GLEW_GET_VAR(__GLEW_ARB_multisample)\r\n\r\n#endif /* GL_ARB_multisample */\r\n\r\n/* -------------------------- GL_ARB_multitexture -------------------------- */\r\n\r\n#ifndef GL_ARB_multitexture\r\n#define GL_ARB_multitexture 1\r\n\r\n#define GL_TEXTURE0_ARB 0x84C0\r\n#define GL_TEXTURE1_ARB 0x84C1\r\n#define GL_TEXTURE2_ARB 0x84C2\r\n#define GL_TEXTURE3_ARB 0x84C3\r\n#define GL_TEXTURE4_ARB 0x84C4\r\n#define GL_TEXTURE5_ARB 0x84C5\r\n#define GL_TEXTURE6_ARB 0x84C6\r\n#define GL_TEXTURE7_ARB 0x84C7\r\n#define GL_TEXTURE8_ARB 0x84C8\r\n#define GL_TEXTURE9_ARB 0x84C9\r\n#define GL_TEXTURE10_ARB 0x84CA\r\n#define GL_TEXTURE11_ARB 0x84CB\r\n#define GL_TEXTURE12_ARB 0x84CC\r\n#define GL_TEXTURE13_ARB 0x84CD\r\n#define GL_TEXTURE14_ARB 0x84CE\r\n#define GL_TEXTURE15_ARB 0x84CF\r\n#define GL_TEXTURE16_ARB 0x84D0\r\n#define GL_TEXTURE17_ARB 0x84D1\r\n#define GL_TEXTURE18_ARB 0x84D2\r\n#define GL_TEXTURE19_ARB 0x84D3\r\n#define GL_TEXTURE20_ARB 0x84D4\r\n#define GL_TEXTURE21_ARB 0x84D5\r\n#define GL_TEXTURE22_ARB 0x84D6\r\n#define GL_TEXTURE23_ARB 0x84D7\r\n#define GL_TEXTURE24_ARB 0x84D8\r\n#define GL_TEXTURE25_ARB 0x84D9\r\n#define GL_TEXTURE26_ARB 0x84DA\r\n#define GL_TEXTURE27_ARB 0x84DB\r\n#define GL_TEXTURE28_ARB 0x84DC\r\n#define GL_TEXTURE29_ARB 0x84DD\r\n#define GL_TEXTURE30_ARB 0x84DE\r\n#define GL_TEXTURE31_ARB 0x84DF\r\n#define GL_ACTIVE_TEXTURE_ARB 0x84E0\r\n#define GL_CLIENT_ACTIVE_TEXTURE_ARB 0x84E1\r\n#define GL_MAX_TEXTURE_UNITS_ARB 0x84E2\r\n\r\ntypedef void (GLAPIENTRY * PFNGLACTIVETEXTUREARBPROC) (GLenum texture);\r\ntypedef void (GLAPIENTRY * PFNGLCLIENTACTIVETEXTUREARBPROC) (GLenum texture);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1DARBPROC) (GLenum target, GLdouble s);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1DVARBPROC) (GLenum target, const GLdouble *v);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1FARBPROC) (GLenum target, GLfloat s);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1FVARBPROC) (GLenum target, const GLfloat *v);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1IARBPROC) (GLenum target, GLint s);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1IVARBPROC) (GLenum target, const GLint *v);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1SARBPROC) (GLenum target, GLshort s);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1SVARBPROC) (GLenum target, const GLshort *v);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2DARBPROC) (GLenum target, GLdouble s, GLdouble t);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2DVARBPROC) (GLenum target, const GLdouble *v);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2FARBPROC) (GLenum target, GLfloat s, GLfloat t);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2FVARBPROC) (GLenum target, const GLfloat *v);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2IARBPROC) (GLenum target, GLint s, GLint t);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2IVARBPROC) (GLenum target, const GLint *v);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2SARBPROC) (GLenum target, GLshort s, GLshort t);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2SVARBPROC) (GLenum target, const GLshort *v);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3DVARBPROC) (GLenum target, const GLdouble *v);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3FVARBPROC) (GLenum target, const GLfloat *v);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3IARBPROC) (GLenum target, GLint s, GLint t, GLint r);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3IVARBPROC) (GLenum target, const GLint *v);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3SVARBPROC) (GLenum target, const GLshort *v);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4DVARBPROC) (GLenum target, const GLdouble *v);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4FVARBPROC) (GLenum target, const GLfloat *v);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4IARBPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4IVARBPROC) (GLenum target, const GLint *v);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4SVARBPROC) (GLenum target, const GLshort *v);\r\n\r\n#define glActiveTextureARB GLEW_GET_FUN(__glewActiveTextureARB)\r\n#define glClientActiveTextureARB GLEW_GET_FUN(__glewClientActiveTextureARB)\r\n#define glMultiTexCoord1dARB GLEW_GET_FUN(__glewMultiTexCoord1dARB)\r\n#define glMultiTexCoord1dvARB GLEW_GET_FUN(__glewMultiTexCoord1dvARB)\r\n#define glMultiTexCoord1fARB GLEW_GET_FUN(__glewMultiTexCoord1fARB)\r\n#define glMultiTexCoord1fvARB GLEW_GET_FUN(__glewMultiTexCoord1fvARB)\r\n#define glMultiTexCoord1iARB GLEW_GET_FUN(__glewMultiTexCoord1iARB)\r\n#define glMultiTexCoord1ivARB GLEW_GET_FUN(__glewMultiTexCoord1ivARB)\r\n#define glMultiTexCoord1sARB GLEW_GET_FUN(__glewMultiTexCoord1sARB)\r\n#define glMultiTexCoord1svARB GLEW_GET_FUN(__glewMultiTexCoord1svARB)\r\n#define glMultiTexCoord2dARB GLEW_GET_FUN(__glewMultiTexCoord2dARB)\r\n#define glMultiTexCoord2dvARB GLEW_GET_FUN(__glewMultiTexCoord2dvARB)\r\n#define glMultiTexCoord2fARB GLEW_GET_FUN(__glewMultiTexCoord2fARB)\r\n#define glMultiTexCoord2fvARB GLEW_GET_FUN(__glewMultiTexCoord2fvARB)\r\n#define glMultiTexCoord2iARB GLEW_GET_FUN(__glewMultiTexCoord2iARB)\r\n#define glMultiTexCoord2ivARB GLEW_GET_FUN(__glewMultiTexCoord2ivARB)\r\n#define glMultiTexCoord2sARB GLEW_GET_FUN(__glewMultiTexCoord2sARB)\r\n#define glMultiTexCoord2svARB GLEW_GET_FUN(__glewMultiTexCoord2svARB)\r\n#define glMultiTexCoord3dARB GLEW_GET_FUN(__glewMultiTexCoord3dARB)\r\n#define glMultiTexCoord3dvARB GLEW_GET_FUN(__glewMultiTexCoord3dvARB)\r\n#define glMultiTexCoord3fARB GLEW_GET_FUN(__glewMultiTexCoord3fARB)\r\n#define glMultiTexCoord3fvARB GLEW_GET_FUN(__glewMultiTexCoord3fvARB)\r\n#define glMultiTexCoord3iARB GLEW_GET_FUN(__glewMultiTexCoord3iARB)\r\n#define glMultiTexCoord3ivARB GLEW_GET_FUN(__glewMultiTexCoord3ivARB)\r\n#define glMultiTexCoord3sARB GLEW_GET_FUN(__glewMultiTexCoord3sARB)\r\n#define glMultiTexCoord3svARB GLEW_GET_FUN(__glewMultiTexCoord3svARB)\r\n#define glMultiTexCoord4dARB GLEW_GET_FUN(__glewMultiTexCoord4dARB)\r\n#define glMultiTexCoord4dvARB GLEW_GET_FUN(__glewMultiTexCoord4dvARB)\r\n#define glMultiTexCoord4fARB GLEW_GET_FUN(__glewMultiTexCoord4fARB)\r\n#define glMultiTexCoord4fvARB GLEW_GET_FUN(__glewMultiTexCoord4fvARB)\r\n#define glMultiTexCoord4iARB GLEW_GET_FUN(__glewMultiTexCoord4iARB)\r\n#define glMultiTexCoord4ivARB GLEW_GET_FUN(__glewMultiTexCoord4ivARB)\r\n#define glMultiTexCoord4sARB GLEW_GET_FUN(__glewMultiTexCoord4sARB)\r\n#define glMultiTexCoord4svARB GLEW_GET_FUN(__glewMultiTexCoord4svARB)\r\n\r\n#define GLEW_ARB_multitexture GLEW_GET_VAR(__GLEW_ARB_multitexture)\r\n\r\n#endif /* GL_ARB_multitexture */\r\n\r\n/* ------------------------- GL_ARB_occlusion_query ------------------------ */\r\n\r\n#ifndef GL_ARB_occlusion_query\r\n#define GL_ARB_occlusion_query 1\r\n\r\n#define GL_QUERY_COUNTER_BITS_ARB 0x8864\r\n#define GL_CURRENT_QUERY_ARB 0x8865\r\n#define GL_QUERY_RESULT_ARB 0x8866\r\n#define GL_QUERY_RESULT_AVAILABLE_ARB 0x8867\r\n#define GL_SAMPLES_PASSED_ARB 0x8914\r\n\r\ntypedef void (GLAPIENTRY * PFNGLBEGINQUERYARBPROC) (GLenum target, GLuint id);\r\ntypedef void (GLAPIENTRY * PFNGLDELETEQUERIESARBPROC) (GLsizei n, const GLuint* ids);\r\ntypedef void (GLAPIENTRY * PFNGLENDQUERYARBPROC) (GLenum target);\r\ntypedef void (GLAPIENTRY * PFNGLGENQUERIESARBPROC) (GLsizei n, GLuint* ids);\r\ntypedef void (GLAPIENTRY * PFNGLGETQUERYOBJECTIVARBPROC) (GLuint id, GLenum pname, GLint* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETQUERYOBJECTUIVARBPROC) (GLuint id, GLenum pname, GLuint* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETQUERYIVARBPROC) (GLenum target, GLenum pname, GLint* params);\r\ntypedef GLboolean (GLAPIENTRY * PFNGLISQUERYARBPROC) (GLuint id);\r\n\r\n#define glBeginQueryARB GLEW_GET_FUN(__glewBeginQueryARB)\r\n#define glDeleteQueriesARB GLEW_GET_FUN(__glewDeleteQueriesARB)\r\n#define glEndQueryARB GLEW_GET_FUN(__glewEndQueryARB)\r\n#define glGenQueriesARB GLEW_GET_FUN(__glewGenQueriesARB)\r\n#define glGetQueryObjectivARB GLEW_GET_FUN(__glewGetQueryObjectivARB)\r\n#define glGetQueryObjectuivARB GLEW_GET_FUN(__glewGetQueryObjectuivARB)\r\n#define glGetQueryivARB GLEW_GET_FUN(__glewGetQueryivARB)\r\n#define glIsQueryARB GLEW_GET_FUN(__glewIsQueryARB)\r\n\r\n#define GLEW_ARB_occlusion_query GLEW_GET_VAR(__GLEW_ARB_occlusion_query)\r\n\r\n#endif /* GL_ARB_occlusion_query */\r\n\r\n/* ------------------------ GL_ARB_occlusion_query2 ------------------------ */\r\n\r\n#ifndef GL_ARB_occlusion_query2\r\n#define GL_ARB_occlusion_query2 1\r\n\r\n#define GL_ANY_SAMPLES_PASSED 0x8C2F\r\n\r\n#define GLEW_ARB_occlusion_query2 GLEW_GET_VAR(__GLEW_ARB_occlusion_query2)\r\n\r\n#endif /* GL_ARB_occlusion_query2 */\r\n\r\n/* --------------------- GL_ARB_parallel_shader_compile -------------------- */\r\n\r\n#ifndef GL_ARB_parallel_shader_compile\r\n#define GL_ARB_parallel_shader_compile 1\r\n\r\n#define GL_MAX_SHADER_COMPILER_THREADS_ARB 0x91B0\r\n#define GL_COMPLETION_STATUS_ARB 0x91B1\r\n\r\ntypedef void (GLAPIENTRY * PFNGLMAXSHADERCOMPILERTHREADSARBPROC) (GLuint count);\r\n\r\n#define glMaxShaderCompilerThreadsARB GLEW_GET_FUN(__glewMaxShaderCompilerThreadsARB)\r\n\r\n#define GLEW_ARB_parallel_shader_compile GLEW_GET_VAR(__GLEW_ARB_parallel_shader_compile)\r\n\r\n#endif /* GL_ARB_parallel_shader_compile */\r\n\r\n/* -------------------- GL_ARB_pipeline_statistics_query ------------------- */\r\n\r\n#ifndef GL_ARB_pipeline_statistics_query\r\n#define GL_ARB_pipeline_statistics_query 1\r\n\r\n#define GL_VERTICES_SUBMITTED_ARB 0x82EE\r\n#define GL_PRIMITIVES_SUBMITTED_ARB 0x82EF\r\n#define GL_VERTEX_SHADER_INVOCATIONS_ARB 0x82F0\r\n#define GL_TESS_CONTROL_SHADER_PATCHES_ARB 0x82F1\r\n#define GL_TESS_EVALUATION_SHADER_INVOCATIONS_ARB 0x82F2\r\n#define GL_GEOMETRY_SHADER_PRIMITIVES_EMITTED_ARB 0x82F3\r\n#define GL_FRAGMENT_SHADER_INVOCATIONS_ARB 0x82F4\r\n#define GL_COMPUTE_SHADER_INVOCATIONS_ARB 0x82F5\r\n#define GL_CLIPPING_INPUT_PRIMITIVES_ARB 0x82F6\r\n#define GL_CLIPPING_OUTPUT_PRIMITIVES_ARB 0x82F7\r\n#define GL_GEOMETRY_SHADER_INVOCATIONS 0x887F\r\n\r\n#define GLEW_ARB_pipeline_statistics_query GLEW_GET_VAR(__GLEW_ARB_pipeline_statistics_query)\r\n\r\n#endif /* GL_ARB_pipeline_statistics_query */\r\n\r\n/* ----------------------- GL_ARB_pixel_buffer_object ---------------------- */\r\n\r\n#ifndef GL_ARB_pixel_buffer_object\r\n#define GL_ARB_pixel_buffer_object 1\r\n\r\n#define GL_PIXEL_PACK_BUFFER_ARB 0x88EB\r\n#define GL_PIXEL_UNPACK_BUFFER_ARB 0x88EC\r\n#define GL_PIXEL_PACK_BUFFER_BINDING_ARB 0x88ED\r\n#define GL_PIXEL_UNPACK_BUFFER_BINDING_ARB 0x88EF\r\n\r\n#define GLEW_ARB_pixel_buffer_object GLEW_GET_VAR(__GLEW_ARB_pixel_buffer_object)\r\n\r\n#endif /* GL_ARB_pixel_buffer_object */\r\n\r\n/* ------------------------ GL_ARB_point_parameters ------------------------ */\r\n\r\n#ifndef GL_ARB_point_parameters\r\n#define GL_ARB_point_parameters 1\r\n\r\n#define GL_POINT_SIZE_MIN_ARB 0x8126\r\n#define GL_POINT_SIZE_MAX_ARB 0x8127\r\n#define GL_POINT_FADE_THRESHOLD_SIZE_ARB 0x8128\r\n#define GL_POINT_DISTANCE_ATTENUATION_ARB 0x8129\r\n\r\ntypedef void (GLAPIENTRY * PFNGLPOINTPARAMETERFARBPROC) (GLenum pname, GLfloat param);\r\ntypedef void (GLAPIENTRY * PFNGLPOINTPARAMETERFVARBPROC) (GLenum pname, const GLfloat* params);\r\n\r\n#define glPointParameterfARB GLEW_GET_FUN(__glewPointParameterfARB)\r\n#define glPointParameterfvARB GLEW_GET_FUN(__glewPointParameterfvARB)\r\n\r\n#define GLEW_ARB_point_parameters GLEW_GET_VAR(__GLEW_ARB_point_parameters)\r\n\r\n#endif /* GL_ARB_point_parameters */\r\n\r\n/* -------------------------- GL_ARB_point_sprite -------------------------- */\r\n\r\n#ifndef GL_ARB_point_sprite\r\n#define GL_ARB_point_sprite 1\r\n\r\n#define GL_POINT_SPRITE_ARB 0x8861\r\n#define GL_COORD_REPLACE_ARB 0x8862\r\n\r\n#define GLEW_ARB_point_sprite GLEW_GET_VAR(__GLEW_ARB_point_sprite)\r\n\r\n#endif /* GL_ARB_point_sprite */\r\n\r\n/* ----------------------- GL_ARB_post_depth_coverage ---------------------- */\r\n\r\n#ifndef GL_ARB_post_depth_coverage\r\n#define GL_ARB_post_depth_coverage 1\r\n\r\n#define GLEW_ARB_post_depth_coverage GLEW_GET_VAR(__GLEW_ARB_post_depth_coverage)\r\n\r\n#endif /* GL_ARB_post_depth_coverage */\r\n\r\n/* --------------------- GL_ARB_program_interface_query -------------------- */\r\n\r\n#ifndef GL_ARB_program_interface_query\r\n#define GL_ARB_program_interface_query 1\r\n\r\n#define GL_UNIFORM 0x92E1\r\n#define GL_UNIFORM_BLOCK 0x92E2\r\n#define GL_PROGRAM_INPUT 0x92E3\r\n#define GL_PROGRAM_OUTPUT 0x92E4\r\n#define GL_BUFFER_VARIABLE 0x92E5\r\n#define GL_SHADER_STORAGE_BLOCK 0x92E6\r\n#define GL_IS_PER_PATCH 0x92E7\r\n#define GL_VERTEX_SUBROUTINE 0x92E8\r\n#define GL_TESS_CONTROL_SUBROUTINE 0x92E9\r\n#define GL_TESS_EVALUATION_SUBROUTINE 0x92EA\r\n#define GL_GEOMETRY_SUBROUTINE 0x92EB\r\n#define GL_FRAGMENT_SUBROUTINE 0x92EC\r\n#define GL_COMPUTE_SUBROUTINE 0x92ED\r\n#define GL_VERTEX_SUBROUTINE_UNIFORM 0x92EE\r\n#define GL_TESS_CONTROL_SUBROUTINE_UNIFORM 0x92EF\r\n#define GL_TESS_EVALUATION_SUBROUTINE_UNIFORM 0x92F0\r\n#define GL_GEOMETRY_SUBROUTINE_UNIFORM 0x92F1\r\n#define GL_FRAGMENT_SUBROUTINE_UNIFORM 0x92F2\r\n#define GL_COMPUTE_SUBROUTINE_UNIFORM 0x92F3\r\n#define GL_TRANSFORM_FEEDBACK_VARYING 0x92F4\r\n#define GL_ACTIVE_RESOURCES 0x92F5\r\n#define GL_MAX_NAME_LENGTH 0x92F6\r\n#define GL_MAX_NUM_ACTIVE_VARIABLES 0x92F7\r\n#define GL_MAX_NUM_COMPATIBLE_SUBROUTINES 0x92F8\r\n#define GL_NAME_LENGTH 0x92F9\r\n#define GL_TYPE 0x92FA\r\n#define GL_ARRAY_SIZE 0x92FB\r\n#define GL_OFFSET 0x92FC\r\n#define GL_BLOCK_INDEX 0x92FD\r\n#define GL_ARRAY_STRIDE 0x92FE\r\n#define GL_MATRIX_STRIDE 0x92FF\r\n#define GL_IS_ROW_MAJOR 0x9300\r\n#define GL_ATOMIC_COUNTER_BUFFER_INDEX 0x9301\r\n#define GL_BUFFER_BINDING 0x9302\r\n#define GL_BUFFER_DATA_SIZE 0x9303\r\n#define GL_NUM_ACTIVE_VARIABLES 0x9304\r\n#define GL_ACTIVE_VARIABLES 0x9305\r\n#define GL_REFERENCED_BY_VERTEX_SHADER 0x9306\r\n#define GL_REFERENCED_BY_TESS_CONTROL_SHADER 0x9307\r\n#define GL_REFERENCED_BY_TESS_EVALUATION_SHADER 0x9308\r\n#define GL_REFERENCED_BY_GEOMETRY_SHADER 0x9309\r\n#define GL_REFERENCED_BY_FRAGMENT_SHADER 0x930A\r\n#define GL_REFERENCED_BY_COMPUTE_SHADER 0x930B\r\n#define GL_TOP_LEVEL_ARRAY_SIZE 0x930C\r\n#define GL_TOP_LEVEL_ARRAY_STRIDE 0x930D\r\n#define GL_LOCATION 0x930E\r\n#define GL_LOCATION_INDEX 0x930F\r\n\r\ntypedef void (GLAPIENTRY * PFNGLGETPROGRAMINTERFACEIVPROC) (GLuint program, GLenum programInterface, GLenum pname, GLint* params);\r\ntypedef GLuint (GLAPIENTRY * PFNGLGETPROGRAMRESOURCEINDEXPROC) (GLuint program, GLenum programInterface, const GLchar* name);\r\ntypedef GLint (GLAPIENTRY * PFNGLGETPROGRAMRESOURCELOCATIONPROC) (GLuint program, GLenum programInterface, const GLchar* name);\r\ntypedef GLint (GLAPIENTRY * PFNGLGETPROGRAMRESOURCELOCATIONINDEXPROC) (GLuint program, GLenum programInterface, const GLchar* name);\r\ntypedef void (GLAPIENTRY * PFNGLGETPROGRAMRESOURCENAMEPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei* length, GLchar *name);\r\ntypedef void (GLAPIENTRY * PFNGLGETPROGRAMRESOURCEIVPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum* props, GLsizei bufSize, GLsizei *length, GLint *params);\r\n\r\n#define glGetProgramInterfaceiv GLEW_GET_FUN(__glewGetProgramInterfaceiv)\r\n#define glGetProgramResourceIndex GLEW_GET_FUN(__glewGetProgramResourceIndex)\r\n#define glGetProgramResourceLocation GLEW_GET_FUN(__glewGetProgramResourceLocation)\r\n#define glGetProgramResourceLocationIndex GLEW_GET_FUN(__glewGetProgramResourceLocationIndex)\r\n#define glGetProgramResourceName GLEW_GET_FUN(__glewGetProgramResourceName)\r\n#define glGetProgramResourceiv GLEW_GET_FUN(__glewGetProgramResourceiv)\r\n\r\n#define GLEW_ARB_program_interface_query GLEW_GET_VAR(__GLEW_ARB_program_interface_query)\r\n\r\n#endif /* GL_ARB_program_interface_query */\r\n\r\n/* ------------------------ GL_ARB_provoking_vertex ------------------------ */\r\n\r\n#ifndef GL_ARB_provoking_vertex\r\n#define GL_ARB_provoking_vertex 1\r\n\r\n#define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION 0x8E4C\r\n#define GL_FIRST_VERTEX_CONVENTION 0x8E4D\r\n#define GL_LAST_VERTEX_CONVENTION 0x8E4E\r\n#define GL_PROVOKING_VERTEX 0x8E4F\r\n\r\ntypedef void (GLAPIENTRY * PFNGLPROVOKINGVERTEXPROC) (GLenum mode);\r\n\r\n#define glProvokingVertex GLEW_GET_FUN(__glewProvokingVertex)\r\n\r\n#define GLEW_ARB_provoking_vertex GLEW_GET_VAR(__GLEW_ARB_provoking_vertex)\r\n\r\n#endif /* GL_ARB_provoking_vertex */\r\n\r\n/* ----------------------- GL_ARB_query_buffer_object ---------------------- */\r\n\r\n#ifndef GL_ARB_query_buffer_object\r\n#define GL_ARB_query_buffer_object 1\r\n\r\n#define GL_QUERY_BUFFER_BARRIER_BIT 0x00008000\r\n#define GL_QUERY_BUFFER 0x9192\r\n#define GL_QUERY_BUFFER_BINDING 0x9193\r\n#define GL_QUERY_RESULT_NO_WAIT 0x9194\r\n\r\n#define GLEW_ARB_query_buffer_object GLEW_GET_VAR(__GLEW_ARB_query_buffer_object)\r\n\r\n#endif /* GL_ARB_query_buffer_object */\r\n\r\n/* ------------------ GL_ARB_robust_buffer_access_behavior ----------------- */\r\n\r\n#ifndef GL_ARB_robust_buffer_access_behavior\r\n#define GL_ARB_robust_buffer_access_behavior 1\r\n\r\n#define GLEW_ARB_robust_buffer_access_behavior GLEW_GET_VAR(__GLEW_ARB_robust_buffer_access_behavior)\r\n\r\n#endif /* GL_ARB_robust_buffer_access_behavior */\r\n\r\n/* --------------------------- GL_ARB_robustness --------------------------- */\r\n\r\n#ifndef GL_ARB_robustness\r\n#define GL_ARB_robustness 1\r\n\r\n#define GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT_ARB 0x00000004\r\n#define GL_LOSE_CONTEXT_ON_RESET_ARB 0x8252\r\n#define GL_GUILTY_CONTEXT_RESET_ARB 0x8253\r\n#define GL_INNOCENT_CONTEXT_RESET_ARB 0x8254\r\n#define GL_UNKNOWN_CONTEXT_RESET_ARB 0x8255\r\n#define GL_RESET_NOTIFICATION_STRATEGY_ARB 0x8256\r\n#define GL_NO_RESET_NOTIFICATION_ARB 0x8261\r\n\r\ntypedef GLenum (GLAPIENTRY * PFNGLGETGRAPHICSRESETSTATUSARBPROC) (void);\r\ntypedef void (GLAPIENTRY * PFNGLGETNCOLORTABLEARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void* table);\r\ntypedef void (GLAPIENTRY * PFNGLGETNCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint lod, GLsizei bufSize, void* img);\r\ntypedef void (GLAPIENTRY * PFNGLGETNCONVOLUTIONFILTERARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void* image);\r\ntypedef void (GLAPIENTRY * PFNGLGETNHISTOGRAMARBPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void* values);\r\ntypedef void (GLAPIENTRY * PFNGLGETNMAPDVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLdouble* v);\r\ntypedef void (GLAPIENTRY * PFNGLGETNMAPFVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLfloat* v);\r\ntypedef void (GLAPIENTRY * PFNGLGETNMAPIVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLint* v);\r\ntypedef void (GLAPIENTRY * PFNGLGETNMINMAXARBPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void* values);\r\ntypedef void (GLAPIENTRY * PFNGLGETNPIXELMAPFVARBPROC) (GLenum map, GLsizei bufSize, GLfloat* values);\r\ntypedef void (GLAPIENTRY * PFNGLGETNPIXELMAPUIVARBPROC) (GLenum map, GLsizei bufSize, GLuint* values);\r\ntypedef void (GLAPIENTRY * PFNGLGETNPIXELMAPUSVARBPROC) (GLenum map, GLsizei bufSize, GLushort* values);\r\ntypedef void (GLAPIENTRY * PFNGLGETNPOLYGONSTIPPLEARBPROC) (GLsizei bufSize, GLubyte* pattern);\r\ntypedef void (GLAPIENTRY * PFNGLGETNSEPARABLEFILTERARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei rowBufSize, void* row, GLsizei columnBufSize, void*column, void*span);\r\ntypedef void (GLAPIENTRY * PFNGLGETNTEXIMAGEARBPROC) (GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, void* img);\r\ntypedef void (GLAPIENTRY * PFNGLGETNUNIFORMDVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLdouble* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETNUNIFORMFVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLfloat* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETNUNIFORMIVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLint* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETNUNIFORMUIVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLuint* params);\r\ntypedef void (GLAPIENTRY * PFNGLREADNPIXELSARBPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void* data);\r\n\r\n#define glGetGraphicsResetStatusARB GLEW_GET_FUN(__glewGetGraphicsResetStatusARB)\r\n#define glGetnColorTableARB GLEW_GET_FUN(__glewGetnColorTableARB)\r\n#define glGetnCompressedTexImageARB GLEW_GET_FUN(__glewGetnCompressedTexImageARB)\r\n#define glGetnConvolutionFilterARB GLEW_GET_FUN(__glewGetnConvolutionFilterARB)\r\n#define glGetnHistogramARB GLEW_GET_FUN(__glewGetnHistogramARB)\r\n#define glGetnMapdvARB GLEW_GET_FUN(__glewGetnMapdvARB)\r\n#define glGetnMapfvARB GLEW_GET_FUN(__glewGetnMapfvARB)\r\n#define glGetnMapivARB GLEW_GET_FUN(__glewGetnMapivARB)\r\n#define glGetnMinmaxARB GLEW_GET_FUN(__glewGetnMinmaxARB)\r\n#define glGetnPixelMapfvARB GLEW_GET_FUN(__glewGetnPixelMapfvARB)\r\n#define glGetnPixelMapuivARB GLEW_GET_FUN(__glewGetnPixelMapuivARB)\r\n#define glGetnPixelMapusvARB GLEW_GET_FUN(__glewGetnPixelMapusvARB)\r\n#define glGetnPolygonStippleARB GLEW_GET_FUN(__glewGetnPolygonStippleARB)\r\n#define glGetnSeparableFilterARB GLEW_GET_FUN(__glewGetnSeparableFilterARB)\r\n#define glGetnTexImageARB GLEW_GET_FUN(__glewGetnTexImageARB)\r\n#define glGetnUniformdvARB GLEW_GET_FUN(__glewGetnUniformdvARB)\r\n#define glGetnUniformfvARB GLEW_GET_FUN(__glewGetnUniformfvARB)\r\n#define glGetnUniformivARB GLEW_GET_FUN(__glewGetnUniformivARB)\r\n#define glGetnUniformuivARB GLEW_GET_FUN(__glewGetnUniformuivARB)\r\n#define glReadnPixelsARB GLEW_GET_FUN(__glewReadnPixelsARB)\r\n\r\n#define GLEW_ARB_robustness GLEW_GET_VAR(__GLEW_ARB_robustness)\r\n\r\n#endif /* GL_ARB_robustness */\r\n\r\n/* ---------------- GL_ARB_robustness_application_isolation ---------------- */\r\n\r\n#ifndef GL_ARB_robustness_application_isolation\r\n#define GL_ARB_robustness_application_isolation 1\r\n\r\n#define GLEW_ARB_robustness_application_isolation GLEW_GET_VAR(__GLEW_ARB_robustness_application_isolation)\r\n\r\n#endif /* GL_ARB_robustness_application_isolation */\r\n\r\n/* ---------------- GL_ARB_robustness_share_group_isolation ---------------- */\r\n\r\n#ifndef GL_ARB_robustness_share_group_isolation\r\n#define GL_ARB_robustness_share_group_isolation 1\r\n\r\n#define GLEW_ARB_robustness_share_group_isolation GLEW_GET_VAR(__GLEW_ARB_robustness_share_group_isolation)\r\n\r\n#endif /* GL_ARB_robustness_share_group_isolation */\r\n\r\n/* ------------------------ GL_ARB_sample_locations ------------------------ */\r\n\r\n#ifndef GL_ARB_sample_locations\r\n#define GL_ARB_sample_locations 1\r\n\r\n#define GL_SAMPLE_LOCATION_ARB 0x8E50\r\n#define GL_SAMPLE_LOCATION_SUBPIXEL_BITS_ARB 0x933D\r\n#define GL_SAMPLE_LOCATION_PIXEL_GRID_WIDTH_ARB 0x933E\r\n#define GL_SAMPLE_LOCATION_PIXEL_GRID_HEIGHT_ARB 0x933F\r\n#define GL_PROGRAMMABLE_SAMPLE_LOCATION_TABLE_SIZE_ARB 0x9340\r\n#define GL_PROGRAMMABLE_SAMPLE_LOCATION_ARB 0x9341\r\n#define GL_FRAMEBUFFER_PROGRAMMABLE_SAMPLE_LOCATIONS_ARB 0x9342\r\n#define GL_FRAMEBUFFER_SAMPLE_LOCATION_PIXEL_GRID_ARB 0x9343\r\n\r\ntypedef void (GLAPIENTRY * PFNGLFRAMEBUFFERSAMPLELOCATIONSFVARBPROC) (GLenum target, GLuint start, GLsizei count, const GLfloat* v);\r\ntypedef void (GLAPIENTRY * PFNGLNAMEDFRAMEBUFFERSAMPLELOCATIONSFVARBPROC) (GLuint framebuffer, GLuint start, GLsizei count, const GLfloat* v);\r\n\r\n#define glFramebufferSampleLocationsfvARB GLEW_GET_FUN(__glewFramebufferSampleLocationsfvARB)\r\n#define glNamedFramebufferSampleLocationsfvARB GLEW_GET_FUN(__glewNamedFramebufferSampleLocationsfvARB)\r\n\r\n#define GLEW_ARB_sample_locations GLEW_GET_VAR(__GLEW_ARB_sample_locations)\r\n\r\n#endif /* GL_ARB_sample_locations */\r\n\r\n/* ------------------------- GL_ARB_sample_shading ------------------------- */\r\n\r\n#ifndef GL_ARB_sample_shading\r\n#define GL_ARB_sample_shading 1\r\n\r\n#define GL_SAMPLE_SHADING_ARB 0x8C36\r\n#define GL_MIN_SAMPLE_SHADING_VALUE_ARB 0x8C37\r\n\r\ntypedef void (GLAPIENTRY * PFNGLMINSAMPLESHADINGARBPROC) (GLclampf value);\r\n\r\n#define glMinSampleShadingARB GLEW_GET_FUN(__glewMinSampleShadingARB)\r\n\r\n#define GLEW_ARB_sample_shading GLEW_GET_VAR(__GLEW_ARB_sample_shading)\r\n\r\n#endif /* GL_ARB_sample_shading */\r\n\r\n/* ------------------------- GL_ARB_sampler_objects ------------------------ */\r\n\r\n#ifndef GL_ARB_sampler_objects\r\n#define GL_ARB_sampler_objects 1\r\n\r\n#define GL_SAMPLER_BINDING 0x8919\r\n\r\ntypedef void (GLAPIENTRY * PFNGLBINDSAMPLERPROC) (GLuint unit, GLuint sampler);\r\ntypedef void (GLAPIENTRY * PFNGLDELETESAMPLERSPROC) (GLsizei count, const GLuint * samplers);\r\ntypedef void (GLAPIENTRY * PFNGLGENSAMPLERSPROC) (GLsizei count, GLuint* samplers);\r\ntypedef void (GLAPIENTRY * PFNGLGETSAMPLERPARAMETERIIVPROC) (GLuint sampler, GLenum pname, GLint* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETSAMPLERPARAMETERIUIVPROC) (GLuint sampler, GLenum pname, GLuint* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, GLfloat* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, GLint* params);\r\ntypedef GLboolean (GLAPIENTRY * PFNGLISSAMPLERPROC) (GLuint sampler);\r\ntypedef void (GLAPIENTRY * PFNGLSAMPLERPARAMETERIIVPROC) (GLuint sampler, GLenum pname, const GLint* params);\r\ntypedef void (GLAPIENTRY * PFNGLSAMPLERPARAMETERIUIVPROC) (GLuint sampler, GLenum pname, const GLuint* params);\r\ntypedef void (GLAPIENTRY * PFNGLSAMPLERPARAMETERFPROC) (GLuint sampler, GLenum pname, GLfloat param);\r\ntypedef void (GLAPIENTRY * PFNGLSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, const GLfloat* params);\r\ntypedef void (GLAPIENTRY * PFNGLSAMPLERPARAMETERIPROC) (GLuint sampler, GLenum pname, GLint param);\r\ntypedef void (GLAPIENTRY * PFNGLSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, const GLint* params);\r\n\r\n#define glBindSampler GLEW_GET_FUN(__glewBindSampler)\r\n#define glDeleteSamplers GLEW_GET_FUN(__glewDeleteSamplers)\r\n#define glGenSamplers GLEW_GET_FUN(__glewGenSamplers)\r\n#define glGetSamplerParameterIiv GLEW_GET_FUN(__glewGetSamplerParameterIiv)\r\n#define glGetSamplerParameterIuiv GLEW_GET_FUN(__glewGetSamplerParameterIuiv)\r\n#define glGetSamplerParameterfv GLEW_GET_FUN(__glewGetSamplerParameterfv)\r\n#define glGetSamplerParameteriv GLEW_GET_FUN(__glewGetSamplerParameteriv)\r\n#define glIsSampler GLEW_GET_FUN(__glewIsSampler)\r\n#define glSamplerParameterIiv GLEW_GET_FUN(__glewSamplerParameterIiv)\r\n#define glSamplerParameterIuiv GLEW_GET_FUN(__glewSamplerParameterIuiv)\r\n#define glSamplerParameterf GLEW_GET_FUN(__glewSamplerParameterf)\r\n#define glSamplerParameterfv GLEW_GET_FUN(__glewSamplerParameterfv)\r\n#define glSamplerParameteri GLEW_GET_FUN(__glewSamplerParameteri)\r\n#define glSamplerParameteriv GLEW_GET_FUN(__glewSamplerParameteriv)\r\n\r\n#define GLEW_ARB_sampler_objects GLEW_GET_VAR(__GLEW_ARB_sampler_objects)\r\n\r\n#endif /* GL_ARB_sampler_objects */\r\n\r\n/* ------------------------ GL_ARB_seamless_cube_map ----------------------- */\r\n\r\n#ifndef GL_ARB_seamless_cube_map\r\n#define GL_ARB_seamless_cube_map 1\r\n\r\n#define GL_TEXTURE_CUBE_MAP_SEAMLESS 0x884F\r\n\r\n#define GLEW_ARB_seamless_cube_map GLEW_GET_VAR(__GLEW_ARB_seamless_cube_map)\r\n\r\n#endif /* GL_ARB_seamless_cube_map */\r\n\r\n/* ------------------ GL_ARB_seamless_cubemap_per_texture ------------------ */\r\n\r\n#ifndef GL_ARB_seamless_cubemap_per_texture\r\n#define GL_ARB_seamless_cubemap_per_texture 1\r\n\r\n#define GL_TEXTURE_CUBE_MAP_SEAMLESS 0x884F\r\n\r\n#define GLEW_ARB_seamless_cubemap_per_texture GLEW_GET_VAR(__GLEW_ARB_seamless_cubemap_per_texture)\r\n\r\n#endif /* GL_ARB_seamless_cubemap_per_texture */\r\n\r\n/* --------------------- GL_ARB_separate_shader_objects -------------------- */\r\n\r\n#ifndef GL_ARB_separate_shader_objects\r\n#define GL_ARB_separate_shader_objects 1\r\n\r\n#define GL_VERTEX_SHADER_BIT 0x00000001\r\n#define GL_FRAGMENT_SHADER_BIT 0x00000002\r\n#define GL_GEOMETRY_SHADER_BIT 0x00000004\r\n#define GL_TESS_CONTROL_SHADER_BIT 0x00000008\r\n#define GL_TESS_EVALUATION_SHADER_BIT 0x00000010\r\n#define GL_PROGRAM_SEPARABLE 0x8258\r\n#define GL_ACTIVE_PROGRAM 0x8259\r\n#define GL_PROGRAM_PIPELINE_BINDING 0x825A\r\n#define GL_ALL_SHADER_BITS 0xFFFFFFFF\r\n\r\ntypedef void (GLAPIENTRY * PFNGLACTIVESHADERPROGRAMPROC) (GLuint pipeline, GLuint program);\r\ntypedef void (GLAPIENTRY * PFNGLBINDPROGRAMPIPELINEPROC) (GLuint pipeline);\r\ntypedef GLuint (GLAPIENTRY * PFNGLCREATESHADERPROGRAMVPROC) (GLenum type, GLsizei count, const GLchar * const * strings);\r\ntypedef void (GLAPIENTRY * PFNGLDELETEPROGRAMPIPELINESPROC) (GLsizei n, const GLuint* pipelines);\r\ntypedef void (GLAPIENTRY * PFNGLGENPROGRAMPIPELINESPROC) (GLsizei n, GLuint* pipelines);\r\ntypedef void (GLAPIENTRY * PFNGLGETPROGRAMPIPELINEINFOLOGPROC) (GLuint pipeline, GLsizei bufSize, GLsizei* length, GLchar *infoLog);\r\ntypedef void (GLAPIENTRY * PFNGLGETPROGRAMPIPELINEIVPROC) (GLuint pipeline, GLenum pname, GLint* params);\r\ntypedef GLboolean (GLAPIENTRY * PFNGLISPROGRAMPIPELINEPROC) (GLuint pipeline);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1DPROC) (GLuint program, GLint location, GLdouble x);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble* value);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1FPROC) (GLuint program, GLint location, GLfloat x);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat* value);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1IPROC) (GLuint program, GLint location, GLint x);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1IVPROC) (GLuint program, GLint location, GLsizei count, const GLint* value);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1UIPROC) (GLuint program, GLint location, GLuint x);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint* value);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2DPROC) (GLuint program, GLint location, GLdouble x, GLdouble y);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble* value);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2FPROC) (GLuint program, GLint location, GLfloat x, GLfloat y);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat* value);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2IPROC) (GLuint program, GLint location, GLint x, GLint y);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2IVPROC) (GLuint program, GLint location, GLsizei count, const GLint* value);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2UIPROC) (GLuint program, GLint location, GLuint x, GLuint y);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint* value);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3DPROC) (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble* value);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3FPROC) (GLuint program, GLint location, GLfloat x, GLfloat y, GLfloat z);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat* value);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3IPROC) (GLuint program, GLint location, GLint x, GLint y, GLint z);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3IVPROC) (GLuint program, GLint location, GLsizei count, const GLint* value);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3UIPROC) (GLuint program, GLint location, GLuint x, GLuint y, GLuint z);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint* value);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4DPROC) (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble* value);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4FPROC) (GLuint program, GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat* value);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4IPROC) (GLuint program, GLint location, GLint x, GLint y, GLint z, GLint w);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4IVPROC) (GLuint program, GLint location, GLsizei count, const GLint* value);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4UIPROC) (GLuint program, GLint location, GLuint x, GLuint y, GLuint z, GLuint w);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint* value);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble* value);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX2X3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble* value);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX2X3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX2X4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble* value);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX2X4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble* value);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX3X2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble* value);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX3X2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX3X4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble* value);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX3X4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble* value);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX4X2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble* value);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX4X2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX4X3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble* value);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX4X3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);\r\ntypedef void (GLAPIENTRY * PFNGLUSEPROGRAMSTAGESPROC) (GLuint pipeline, GLbitfield stages, GLuint program);\r\ntypedef void (GLAPIENTRY * PFNGLVALIDATEPROGRAMPIPELINEPROC) (GLuint pipeline);\r\n\r\n#define glActiveShaderProgram GLEW_GET_FUN(__glewActiveShaderProgram)\r\n#define glBindProgramPipeline GLEW_GET_FUN(__glewBindProgramPipeline)\r\n#define glCreateShaderProgramv GLEW_GET_FUN(__glewCreateShaderProgramv)\r\n#define glDeleteProgramPipelines GLEW_GET_FUN(__glewDeleteProgramPipelines)\r\n#define glGenProgramPipelines GLEW_GET_FUN(__glewGenProgramPipelines)\r\n#define glGetProgramPipelineInfoLog GLEW_GET_FUN(__glewGetProgramPipelineInfoLog)\r\n#define glGetProgramPipelineiv GLEW_GET_FUN(__glewGetProgramPipelineiv)\r\n#define glIsProgramPipeline GLEW_GET_FUN(__glewIsProgramPipeline)\r\n#define glProgramUniform1d GLEW_GET_FUN(__glewProgramUniform1d)\r\n#define glProgramUniform1dv GLEW_GET_FUN(__glewProgramUniform1dv)\r\n#define glProgramUniform1f GLEW_GET_FUN(__glewProgramUniform1f)\r\n#define glProgramUniform1fv GLEW_GET_FUN(__glewProgramUniform1fv)\r\n#define glProgramUniform1i GLEW_GET_FUN(__glewProgramUniform1i)\r\n#define glProgramUniform1iv GLEW_GET_FUN(__glewProgramUniform1iv)\r\n#define glProgramUniform1ui GLEW_GET_FUN(__glewProgramUniform1ui)\r\n#define glProgramUniform1uiv GLEW_GET_FUN(__glewProgramUniform1uiv)\r\n#define glProgramUniform2d GLEW_GET_FUN(__glewProgramUniform2d)\r\n#define glProgramUniform2dv GLEW_GET_FUN(__glewProgramUniform2dv)\r\n#define glProgramUniform2f GLEW_GET_FUN(__glewProgramUniform2f)\r\n#define glProgramUniform2fv GLEW_GET_FUN(__glewProgramUniform2fv)\r\n#define glProgramUniform2i GLEW_GET_FUN(__glewProgramUniform2i)\r\n#define glProgramUniform2iv GLEW_GET_FUN(__glewProgramUniform2iv)\r\n#define glProgramUniform2ui GLEW_GET_FUN(__glewProgramUniform2ui)\r\n#define glProgramUniform2uiv GLEW_GET_FUN(__glewProgramUniform2uiv)\r\n#define glProgramUniform3d GLEW_GET_FUN(__glewProgramUniform3d)\r\n#define glProgramUniform3dv GLEW_GET_FUN(__glewProgramUniform3dv)\r\n#define glProgramUniform3f GLEW_GET_FUN(__glewProgramUniform3f)\r\n#define glProgramUniform3fv GLEW_GET_FUN(__glewProgramUniform3fv)\r\n#define glProgramUniform3i GLEW_GET_FUN(__glewProgramUniform3i)\r\n#define glProgramUniform3iv GLEW_GET_FUN(__glewProgramUniform3iv)\r\n#define glProgramUniform3ui GLEW_GET_FUN(__glewProgramUniform3ui)\r\n#define glProgramUniform3uiv GLEW_GET_FUN(__glewProgramUniform3uiv)\r\n#define glProgramUniform4d GLEW_GET_FUN(__glewProgramUniform4d)\r\n#define glProgramUniform4dv GLEW_GET_FUN(__glewProgramUniform4dv)\r\n#define glProgramUniform4f GLEW_GET_FUN(__glewProgramUniform4f)\r\n#define glProgramUniform4fv GLEW_GET_FUN(__glewProgramUniform4fv)\r\n#define glProgramUniform4i GLEW_GET_FUN(__glewProgramUniform4i)\r\n#define glProgramUniform4iv GLEW_GET_FUN(__glewProgramUniform4iv)\r\n#define glProgramUniform4ui GLEW_GET_FUN(__glewProgramUniform4ui)\r\n#define glProgramUniform4uiv GLEW_GET_FUN(__glewProgramUniform4uiv)\r\n#define glProgramUniformMatrix2dv GLEW_GET_FUN(__glewProgramUniformMatrix2dv)\r\n#define glProgramUniformMatrix2fv GLEW_GET_FUN(__glewProgramUniformMatrix2fv)\r\n#define glProgramUniformMatrix2x3dv GLEW_GET_FUN(__glewProgramUniformMatrix2x3dv)\r\n#define glProgramUniformMatrix2x3fv GLEW_GET_FUN(__glewProgramUniformMatrix2x3fv)\r\n#define glProgramUniformMatrix2x4dv GLEW_GET_FUN(__glewProgramUniformMatrix2x4dv)\r\n#define glProgramUniformMatrix2x4fv GLEW_GET_FUN(__glewProgramUniformMatrix2x4fv)\r\n#define glProgramUniformMatrix3dv GLEW_GET_FUN(__glewProgramUniformMatrix3dv)\r\n#define glProgramUniformMatrix3fv GLEW_GET_FUN(__glewProgramUniformMatrix3fv)\r\n#define glProgramUniformMatrix3x2dv GLEW_GET_FUN(__glewProgramUniformMatrix3x2dv)\r\n#define glProgramUniformMatrix3x2fv GLEW_GET_FUN(__glewProgramUniformMatrix3x2fv)\r\n#define glProgramUniformMatrix3x4dv GLEW_GET_FUN(__glewProgramUniformMatrix3x4dv)\r\n#define glProgramUniformMatrix3x4fv GLEW_GET_FUN(__glewProgramUniformMatrix3x4fv)\r\n#define glProgramUniformMatrix4dv GLEW_GET_FUN(__glewProgramUniformMatrix4dv)\r\n#define glProgramUniformMatrix4fv GLEW_GET_FUN(__glewProgramUniformMatrix4fv)\r\n#define glProgramUniformMatrix4x2dv GLEW_GET_FUN(__glewProgramUniformMatrix4x2dv)\r\n#define glProgramUniformMatrix4x2fv GLEW_GET_FUN(__glewProgramUniformMatrix4x2fv)\r\n#define glProgramUniformMatrix4x3dv GLEW_GET_FUN(__glewProgramUniformMatrix4x3dv)\r\n#define glProgramUniformMatrix4x3fv GLEW_GET_FUN(__glewProgramUniformMatrix4x3fv)\r\n#define glUseProgramStages GLEW_GET_FUN(__glewUseProgramStages)\r\n#define glValidateProgramPipeline GLEW_GET_FUN(__glewValidateProgramPipeline)\r\n\r\n#define GLEW_ARB_separate_shader_objects GLEW_GET_VAR(__GLEW_ARB_separate_shader_objects)\r\n\r\n#endif /* GL_ARB_separate_shader_objects */\r\n\r\n/* -------------------- GL_ARB_shader_atomic_counter_ops ------------------- */\r\n\r\n#ifndef GL_ARB_shader_atomic_counter_ops\r\n#define GL_ARB_shader_atomic_counter_ops 1\r\n\r\n#define GLEW_ARB_shader_atomic_counter_ops GLEW_GET_VAR(__GLEW_ARB_shader_atomic_counter_ops)\r\n\r\n#endif /* GL_ARB_shader_atomic_counter_ops */\r\n\r\n/* --------------------- GL_ARB_shader_atomic_counters --------------------- */\r\n\r\n#ifndef GL_ARB_shader_atomic_counters\r\n#define GL_ARB_shader_atomic_counters 1\r\n\r\n#define GL_ATOMIC_COUNTER_BUFFER 0x92C0\r\n#define GL_ATOMIC_COUNTER_BUFFER_BINDING 0x92C1\r\n#define GL_ATOMIC_COUNTER_BUFFER_START 0x92C2\r\n#define GL_ATOMIC_COUNTER_BUFFER_SIZE 0x92C3\r\n#define GL_ATOMIC_COUNTER_BUFFER_DATA_SIZE 0x92C4\r\n#define GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTERS 0x92C5\r\n#define GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTER_INDICES 0x92C6\r\n#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_VERTEX_SHADER 0x92C7\r\n#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_CONTROL_SHADER 0x92C8\r\n#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_EVALUATION_SHADER 0x92C9\r\n#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_GEOMETRY_SHADER 0x92CA\r\n#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_FRAGMENT_SHADER 0x92CB\r\n#define GL_MAX_VERTEX_ATOMIC_COUNTER_BUFFERS 0x92CC\r\n#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS 0x92CD\r\n#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS 0x92CE\r\n#define GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS 0x92CF\r\n#define GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS 0x92D0\r\n#define GL_MAX_COMBINED_ATOMIC_COUNTER_BUFFERS 0x92D1\r\n#define GL_MAX_VERTEX_ATOMIC_COUNTERS 0x92D2\r\n#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS 0x92D3\r\n#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS 0x92D4\r\n#define GL_MAX_GEOMETRY_ATOMIC_COUNTERS 0x92D5\r\n#define GL_MAX_FRAGMENT_ATOMIC_COUNTERS 0x92D6\r\n#define GL_MAX_COMBINED_ATOMIC_COUNTERS 0x92D7\r\n#define GL_MAX_ATOMIC_COUNTER_BUFFER_SIZE 0x92D8\r\n#define GL_ACTIVE_ATOMIC_COUNTER_BUFFERS 0x92D9\r\n#define GL_UNIFORM_ATOMIC_COUNTER_BUFFER_INDEX 0x92DA\r\n#define GL_UNSIGNED_INT_ATOMIC_COUNTER 0x92DB\r\n#define GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS 0x92DC\r\n\r\ntypedef void (GLAPIENTRY * PFNGLGETACTIVEATOMICCOUNTERBUFFERIVPROC) (GLuint program, GLuint bufferIndex, GLenum pname, GLint* params);\r\n\r\n#define glGetActiveAtomicCounterBufferiv GLEW_GET_FUN(__glewGetActiveAtomicCounterBufferiv)\r\n\r\n#define GLEW_ARB_shader_atomic_counters GLEW_GET_VAR(__GLEW_ARB_shader_atomic_counters)\r\n\r\n#endif /* GL_ARB_shader_atomic_counters */\r\n\r\n/* -------------------------- GL_ARB_shader_ballot ------------------------- */\r\n\r\n#ifndef GL_ARB_shader_ballot\r\n#define GL_ARB_shader_ballot 1\r\n\r\n#define GLEW_ARB_shader_ballot GLEW_GET_VAR(__GLEW_ARB_shader_ballot)\r\n\r\n#endif /* GL_ARB_shader_ballot */\r\n\r\n/* ----------------------- GL_ARB_shader_bit_encoding ---------------------- */\r\n\r\n#ifndef GL_ARB_shader_bit_encoding\r\n#define GL_ARB_shader_bit_encoding 1\r\n\r\n#define GLEW_ARB_shader_bit_encoding GLEW_GET_VAR(__GLEW_ARB_shader_bit_encoding)\r\n\r\n#endif /* GL_ARB_shader_bit_encoding */\r\n\r\n/* -------------------------- GL_ARB_shader_clock -------------------------- */\r\n\r\n#ifndef GL_ARB_shader_clock\r\n#define GL_ARB_shader_clock 1\r\n\r\n#define GLEW_ARB_shader_clock GLEW_GET_VAR(__GLEW_ARB_shader_clock)\r\n\r\n#endif /* GL_ARB_shader_clock */\r\n\r\n/* --------------------- GL_ARB_shader_draw_parameters --------------------- */\r\n\r\n#ifndef GL_ARB_shader_draw_parameters\r\n#define GL_ARB_shader_draw_parameters 1\r\n\r\n#define GLEW_ARB_shader_draw_parameters GLEW_GET_VAR(__GLEW_ARB_shader_draw_parameters)\r\n\r\n#endif /* GL_ARB_shader_draw_parameters */\r\n\r\n/* ------------------------ GL_ARB_shader_group_vote ----------------------- */\r\n\r\n#ifndef GL_ARB_shader_group_vote\r\n#define GL_ARB_shader_group_vote 1\r\n\r\n#define GLEW_ARB_shader_group_vote GLEW_GET_VAR(__GLEW_ARB_shader_group_vote)\r\n\r\n#endif /* GL_ARB_shader_group_vote */\r\n\r\n/* --------------------- GL_ARB_shader_image_load_store -------------------- */\r\n\r\n#ifndef GL_ARB_shader_image_load_store\r\n#define GL_ARB_shader_image_load_store 1\r\n\r\n#define GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT 0x00000001\r\n#define GL_ELEMENT_ARRAY_BARRIER_BIT 0x00000002\r\n#define GL_UNIFORM_BARRIER_BIT 0x00000004\r\n#define GL_TEXTURE_FETCH_BARRIER_BIT 0x00000008\r\n#define GL_SHADER_IMAGE_ACCESS_BARRIER_BIT 0x00000020\r\n#define GL_COMMAND_BARRIER_BIT 0x00000040\r\n#define GL_PIXEL_BUFFER_BARRIER_BIT 0x00000080\r\n#define GL_TEXTURE_UPDATE_BARRIER_BIT 0x00000100\r\n#define GL_BUFFER_UPDATE_BARRIER_BIT 0x00000200\r\n#define GL_FRAMEBUFFER_BARRIER_BIT 0x00000400\r\n#define GL_TRANSFORM_FEEDBACK_BARRIER_BIT 0x00000800\r\n#define GL_ATOMIC_COUNTER_BARRIER_BIT 0x00001000\r\n#define GL_MAX_IMAGE_UNITS 0x8F38\r\n#define GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS 0x8F39\r\n#define GL_IMAGE_BINDING_NAME 0x8F3A\r\n#define GL_IMAGE_BINDING_LEVEL 0x8F3B\r\n#define GL_IMAGE_BINDING_LAYERED 0x8F3C\r\n#define GL_IMAGE_BINDING_LAYER 0x8F3D\r\n#define GL_IMAGE_BINDING_ACCESS 0x8F3E\r\n#define GL_IMAGE_1D 0x904C\r\n#define GL_IMAGE_2D 0x904D\r\n#define GL_IMAGE_3D 0x904E\r\n#define GL_IMAGE_2D_RECT 0x904F\r\n#define GL_IMAGE_CUBE 0x9050\r\n#define GL_IMAGE_BUFFER 0x9051\r\n#define GL_IMAGE_1D_ARRAY 0x9052\r\n#define GL_IMAGE_2D_ARRAY 0x9053\r\n#define GL_IMAGE_CUBE_MAP_ARRAY 0x9054\r\n#define GL_IMAGE_2D_MULTISAMPLE 0x9055\r\n#define GL_IMAGE_2D_MULTISAMPLE_ARRAY 0x9056\r\n#define GL_INT_IMAGE_1D 0x9057\r\n#define GL_INT_IMAGE_2D 0x9058\r\n#define GL_INT_IMAGE_3D 0x9059\r\n#define GL_INT_IMAGE_2D_RECT 0x905A\r\n#define GL_INT_IMAGE_CUBE 0x905B\r\n#define GL_INT_IMAGE_BUFFER 0x905C\r\n#define GL_INT_IMAGE_1D_ARRAY 0x905D\r\n#define GL_INT_IMAGE_2D_ARRAY 0x905E\r\n#define GL_INT_IMAGE_CUBE_MAP_ARRAY 0x905F\r\n#define GL_INT_IMAGE_2D_MULTISAMPLE 0x9060\r\n#define GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY 0x9061\r\n#define GL_UNSIGNED_INT_IMAGE_1D 0x9062\r\n#define GL_UNSIGNED_INT_IMAGE_2D 0x9063\r\n#define GL_UNSIGNED_INT_IMAGE_3D 0x9064\r\n#define GL_UNSIGNED_INT_IMAGE_2D_RECT 0x9065\r\n#define GL_UNSIGNED_INT_IMAGE_CUBE 0x9066\r\n#define GL_UNSIGNED_INT_IMAGE_BUFFER 0x9067\r\n#define GL_UNSIGNED_INT_IMAGE_1D_ARRAY 0x9068\r\n#define GL_UNSIGNED_INT_IMAGE_2D_ARRAY 0x9069\r\n#define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY 0x906A\r\n#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE 0x906B\r\n#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY 0x906C\r\n#define GL_MAX_IMAGE_SAMPLES 0x906D\r\n#define GL_IMAGE_BINDING_FORMAT 0x906E\r\n#define GL_IMAGE_FORMAT_COMPATIBILITY_TYPE 0x90C7\r\n#define GL_IMAGE_FORMAT_COMPATIBILITY_BY_SIZE 0x90C8\r\n#define GL_IMAGE_FORMAT_COMPATIBILITY_BY_CLASS 0x90C9\r\n#define GL_MAX_VERTEX_IMAGE_UNIFORMS 0x90CA\r\n#define GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS 0x90CB\r\n#define GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS 0x90CC\r\n#define GL_MAX_GEOMETRY_IMAGE_UNIFORMS 0x90CD\r\n#define GL_MAX_FRAGMENT_IMAGE_UNIFORMS 0x90CE\r\n#define GL_MAX_COMBINED_IMAGE_UNIFORMS 0x90CF\r\n#define GL_ALL_BARRIER_BITS 0xFFFFFFFF\r\n\r\ntypedef void (GLAPIENTRY * PFNGLBINDIMAGETEXTUREPROC) (GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format);\r\ntypedef void (GLAPIENTRY * PFNGLMEMORYBARRIERPROC) (GLbitfield barriers);\r\n\r\n#define glBindImageTexture GLEW_GET_FUN(__glewBindImageTexture)\r\n#define glMemoryBarrier GLEW_GET_FUN(__glewMemoryBarrier)\r\n\r\n#define GLEW_ARB_shader_image_load_store GLEW_GET_VAR(__GLEW_ARB_shader_image_load_store)\r\n\r\n#endif /* GL_ARB_shader_image_load_store */\r\n\r\n/* ------------------------ GL_ARB_shader_image_size ----------------------- */\r\n\r\n#ifndef GL_ARB_shader_image_size\r\n#define GL_ARB_shader_image_size 1\r\n\r\n#define GLEW_ARB_shader_image_size GLEW_GET_VAR(__GLEW_ARB_shader_image_size)\r\n\r\n#endif /* GL_ARB_shader_image_size */\r\n\r\n/* ------------------------- GL_ARB_shader_objects ------------------------- */\r\n\r\n#ifndef GL_ARB_shader_objects\r\n#define GL_ARB_shader_objects 1\r\n\r\n#define GL_PROGRAM_OBJECT_ARB 0x8B40\r\n#define GL_SHADER_OBJECT_ARB 0x8B48\r\n#define GL_OBJECT_TYPE_ARB 0x8B4E\r\n#define GL_OBJECT_SUBTYPE_ARB 0x8B4F\r\n#define GL_FLOAT_VEC2_ARB 0x8B50\r\n#define GL_FLOAT_VEC3_ARB 0x8B51\r\n#define GL_FLOAT_VEC4_ARB 0x8B52\r\n#define GL_INT_VEC2_ARB 0x8B53\r\n#define GL_INT_VEC3_ARB 0x8B54\r\n#define GL_INT_VEC4_ARB 0x8B55\r\n#define GL_BOOL_ARB 0x8B56\r\n#define GL_BOOL_VEC2_ARB 0x8B57\r\n#define GL_BOOL_VEC3_ARB 0x8B58\r\n#define GL_BOOL_VEC4_ARB 0x8B59\r\n#define GL_FLOAT_MAT2_ARB 0x8B5A\r\n#define GL_FLOAT_MAT3_ARB 0x8B5B\r\n#define GL_FLOAT_MAT4_ARB 0x8B5C\r\n#define GL_SAMPLER_1D_ARB 0x8B5D\r\n#define GL_SAMPLER_2D_ARB 0x8B5E\r\n#define GL_SAMPLER_3D_ARB 0x8B5F\r\n#define GL_SAMPLER_CUBE_ARB 0x8B60\r\n#define GL_SAMPLER_1D_SHADOW_ARB 0x8B61\r\n#define GL_SAMPLER_2D_SHADOW_ARB 0x8B62\r\n#define GL_SAMPLER_2D_RECT_ARB 0x8B63\r\n#define GL_SAMPLER_2D_RECT_SHADOW_ARB 0x8B64\r\n#define GL_OBJECT_DELETE_STATUS_ARB 0x8B80\r\n#define GL_OBJECT_COMPILE_STATUS_ARB 0x8B81\r\n#define GL_OBJECT_LINK_STATUS_ARB 0x8B82\r\n#define GL_OBJECT_VALIDATE_STATUS_ARB 0x8B83\r\n#define GL_OBJECT_INFO_LOG_LENGTH_ARB 0x8B84\r\n#define GL_OBJECT_ATTACHED_OBJECTS_ARB 0x8B85\r\n#define GL_OBJECT_ACTIVE_UNIFORMS_ARB 0x8B86\r\n#define GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB 0x8B87\r\n#define GL_OBJECT_SHADER_SOURCE_LENGTH_ARB 0x8B88\r\n\r\ntypedef char GLcharARB;\r\ntypedef unsigned int GLhandleARB;\r\n\r\ntypedef void (GLAPIENTRY * PFNGLATTACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB obj);\r\ntypedef void (GLAPIENTRY * PFNGLCOMPILESHADERARBPROC) (GLhandleARB shaderObj);\r\ntypedef GLhandleARB (GLAPIENTRY * PFNGLCREATEPROGRAMOBJECTARBPROC) (void);\r\ntypedef GLhandleARB (GLAPIENTRY * PFNGLCREATESHADEROBJECTARBPROC) (GLenum shaderType);\r\ntypedef void (GLAPIENTRY * PFNGLDELETEOBJECTARBPROC) (GLhandleARB obj);\r\ntypedef void (GLAPIENTRY * PFNGLDETACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB attachedObj);\r\ntypedef void (GLAPIENTRY * PFNGLGETACTIVEUNIFORMARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei* length, GLint *size, GLenum *type, GLcharARB *name);\r\ntypedef void (GLAPIENTRY * PFNGLGETATTACHEDOBJECTSARBPROC) (GLhandleARB containerObj, GLsizei maxCount, GLsizei* count, GLhandleARB *obj);\r\ntypedef GLhandleARB (GLAPIENTRY * PFNGLGETHANDLEARBPROC) (GLenum pname);\r\ntypedef void (GLAPIENTRY * PFNGLGETINFOLOGARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei* length, GLcharARB *infoLog);\r\ntypedef void (GLAPIENTRY * PFNGLGETOBJECTPARAMETERFVARBPROC) (GLhandleARB obj, GLenum pname, GLfloat* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETOBJECTPARAMETERIVARBPROC) (GLhandleARB obj, GLenum pname, GLint* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETSHADERSOURCEARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei* length, GLcharARB *source);\r\ntypedef GLint (GLAPIENTRY * PFNGLGETUNIFORMLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB* name);\r\ntypedef void (GLAPIENTRY * PFNGLGETUNIFORMFVARBPROC) (GLhandleARB programObj, GLint location, GLfloat* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETUNIFORMIVARBPROC) (GLhandleARB programObj, GLint location, GLint* params);\r\ntypedef void (GLAPIENTRY * PFNGLLINKPROGRAMARBPROC) (GLhandleARB programObj);\r\ntypedef void (GLAPIENTRY * PFNGLSHADERSOURCEARBPROC) (GLhandleARB shaderObj, GLsizei count, const GLcharARB ** string, const GLint *length);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORM1FARBPROC) (GLint location, GLfloat v0);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORM1FVARBPROC) (GLint location, GLsizei count, const GLfloat* value);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORM1IARBPROC) (GLint location, GLint v0);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORM1IVARBPROC) (GLint location, GLsizei count, const GLint* value);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORM2FARBPROC) (GLint location, GLfloat v0, GLfloat v1);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORM2FVARBPROC) (GLint location, GLsizei count, const GLfloat* value);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORM2IARBPROC) (GLint location, GLint v0, GLint v1);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORM2IVARBPROC) (GLint location, GLsizei count, const GLint* value);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORM3FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORM3FVARBPROC) (GLint location, GLsizei count, const GLfloat* value);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORM3IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORM3IVARBPROC) (GLint location, GLsizei count, const GLint* value);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORM4FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORM4FVARBPROC) (GLint location, GLsizei count, const GLfloat* value);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORM4IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORM4IVARBPROC) (GLint location, GLsizei count, const GLint* value);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX2FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX3FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX4FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);\r\ntypedef void (GLAPIENTRY * PFNGLUSEPROGRAMOBJECTARBPROC) (GLhandleARB programObj);\r\ntypedef void (GLAPIENTRY * PFNGLVALIDATEPROGRAMARBPROC) (GLhandleARB programObj);\r\n\r\n#define glAttachObjectARB GLEW_GET_FUN(__glewAttachObjectARB)\r\n#define glCompileShaderARB GLEW_GET_FUN(__glewCompileShaderARB)\r\n#define glCreateProgramObjectARB GLEW_GET_FUN(__glewCreateProgramObjectARB)\r\n#define glCreateShaderObjectARB GLEW_GET_FUN(__glewCreateShaderObjectARB)\r\n#define glDeleteObjectARB GLEW_GET_FUN(__glewDeleteObjectARB)\r\n#define glDetachObjectARB GLEW_GET_FUN(__glewDetachObjectARB)\r\n#define glGetActiveUniformARB GLEW_GET_FUN(__glewGetActiveUniformARB)\r\n#define glGetAttachedObjectsARB GLEW_GET_FUN(__glewGetAttachedObjectsARB)\r\n#define glGetHandleARB GLEW_GET_FUN(__glewGetHandleARB)\r\n#define glGetInfoLogARB GLEW_GET_FUN(__glewGetInfoLogARB)\r\n#define glGetObjectParameterfvARB GLEW_GET_FUN(__glewGetObjectParameterfvARB)\r\n#define glGetObjectParameterivARB GLEW_GET_FUN(__glewGetObjectParameterivARB)\r\n#define glGetShaderSourceARB GLEW_GET_FUN(__glewGetShaderSourceARB)\r\n#define glGetUniformLocationARB GLEW_GET_FUN(__glewGetUniformLocationARB)\r\n#define glGetUniformfvARB GLEW_GET_FUN(__glewGetUniformfvARB)\r\n#define glGetUniformivARB GLEW_GET_FUN(__glewGetUniformivARB)\r\n#define glLinkProgramARB GLEW_GET_FUN(__glewLinkProgramARB)\r\n#define glShaderSourceARB GLEW_GET_FUN(__glewShaderSourceARB)\r\n#define glUniform1fARB GLEW_GET_FUN(__glewUniform1fARB)\r\n#define glUniform1fvARB GLEW_GET_FUN(__glewUniform1fvARB)\r\n#define glUniform1iARB GLEW_GET_FUN(__glewUniform1iARB)\r\n#define glUniform1ivARB GLEW_GET_FUN(__glewUniform1ivARB)\r\n#define glUniform2fARB GLEW_GET_FUN(__glewUniform2fARB)\r\n#define glUniform2fvARB GLEW_GET_FUN(__glewUniform2fvARB)\r\n#define glUniform2iARB GLEW_GET_FUN(__glewUniform2iARB)\r\n#define glUniform2ivARB GLEW_GET_FUN(__glewUniform2ivARB)\r\n#define glUniform3fARB GLEW_GET_FUN(__glewUniform3fARB)\r\n#define glUniform3fvARB GLEW_GET_FUN(__glewUniform3fvARB)\r\n#define glUniform3iARB GLEW_GET_FUN(__glewUniform3iARB)\r\n#define glUniform3ivARB GLEW_GET_FUN(__glewUniform3ivARB)\r\n#define glUniform4fARB GLEW_GET_FUN(__glewUniform4fARB)\r\n#define glUniform4fvARB GLEW_GET_FUN(__glewUniform4fvARB)\r\n#define glUniform4iARB GLEW_GET_FUN(__glewUniform4iARB)\r\n#define glUniform4ivARB GLEW_GET_FUN(__glewUniform4ivARB)\r\n#define glUniformMatrix2fvARB GLEW_GET_FUN(__glewUniformMatrix2fvARB)\r\n#define glUniformMatrix3fvARB GLEW_GET_FUN(__glewUniformMatrix3fvARB)\r\n#define glUniformMatrix4fvARB GLEW_GET_FUN(__glewUniformMatrix4fvARB)\r\n#define glUseProgramObjectARB GLEW_GET_FUN(__glewUseProgramObjectARB)\r\n#define glValidateProgramARB GLEW_GET_FUN(__glewValidateProgramARB)\r\n\r\n#define GLEW_ARB_shader_objects GLEW_GET_VAR(__GLEW_ARB_shader_objects)\r\n\r\n#endif /* GL_ARB_shader_objects */\r\n\r\n/* ------------------------ GL_ARB_shader_precision ------------------------ */\r\n\r\n#ifndef GL_ARB_shader_precision\r\n#define GL_ARB_shader_precision 1\r\n\r\n#define GLEW_ARB_shader_precision GLEW_GET_VAR(__GLEW_ARB_shader_precision)\r\n\r\n#endif /* GL_ARB_shader_precision */\r\n\r\n/* ---------------------- GL_ARB_shader_stencil_export --------------------- */\r\n\r\n#ifndef GL_ARB_shader_stencil_export\r\n#define GL_ARB_shader_stencil_export 1\r\n\r\n#define GLEW_ARB_shader_stencil_export GLEW_GET_VAR(__GLEW_ARB_shader_stencil_export)\r\n\r\n#endif /* GL_ARB_shader_stencil_export */\r\n\r\n/* ------------------ GL_ARB_shader_storage_buffer_object ------------------ */\r\n\r\n#ifndef GL_ARB_shader_storage_buffer_object\r\n#define GL_ARB_shader_storage_buffer_object 1\r\n\r\n#define GL_SHADER_STORAGE_BARRIER_BIT 0x2000\r\n#define GL_MAX_COMBINED_SHADER_OUTPUT_RESOURCES 0x8F39\r\n#define GL_SHADER_STORAGE_BUFFER 0x90D2\r\n#define GL_SHADER_STORAGE_BUFFER_BINDING 0x90D3\r\n#define GL_SHADER_STORAGE_BUFFER_START 0x90D4\r\n#define GL_SHADER_STORAGE_BUFFER_SIZE 0x90D5\r\n#define GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS 0x90D6\r\n#define GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS 0x90D7\r\n#define GL_MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS 0x90D8\r\n#define GL_MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS 0x90D9\r\n#define GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS 0x90DA\r\n#define GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS 0x90DB\r\n#define GL_MAX_COMBINED_SHADER_STORAGE_BLOCKS 0x90DC\r\n#define GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS 0x90DD\r\n#define GL_MAX_SHADER_STORAGE_BLOCK_SIZE 0x90DE\r\n#define GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT 0x90DF\r\n\r\ntypedef void (GLAPIENTRY * PFNGLSHADERSTORAGEBLOCKBINDINGPROC) (GLuint program, GLuint storageBlockIndex, GLuint storageBlockBinding);\r\n\r\n#define glShaderStorageBlockBinding GLEW_GET_FUN(__glewShaderStorageBlockBinding)\r\n\r\n#define GLEW_ARB_shader_storage_buffer_object GLEW_GET_VAR(__GLEW_ARB_shader_storage_buffer_object)\r\n\r\n#endif /* GL_ARB_shader_storage_buffer_object */\r\n\r\n/* ------------------------ GL_ARB_shader_subroutine ----------------------- */\r\n\r\n#ifndef GL_ARB_shader_subroutine\r\n#define GL_ARB_shader_subroutine 1\r\n\r\n#define GL_ACTIVE_SUBROUTINES 0x8DE5\r\n#define GL_ACTIVE_SUBROUTINE_UNIFORMS 0x8DE6\r\n#define GL_MAX_SUBROUTINES 0x8DE7\r\n#define GL_MAX_SUBROUTINE_UNIFORM_LOCATIONS 0x8DE8\r\n#define GL_ACTIVE_SUBROUTINE_UNIFORM_LOCATIONS 0x8E47\r\n#define GL_ACTIVE_SUBROUTINE_MAX_LENGTH 0x8E48\r\n#define GL_ACTIVE_SUBROUTINE_UNIFORM_MAX_LENGTH 0x8E49\r\n#define GL_NUM_COMPATIBLE_SUBROUTINES 0x8E4A\r\n#define GL_COMPATIBLE_SUBROUTINES 0x8E4B\r\n\r\ntypedef void (GLAPIENTRY * PFNGLGETACTIVESUBROUTINENAMEPROC) (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei* length, GLchar *name);\r\ntypedef void (GLAPIENTRY * PFNGLGETACTIVESUBROUTINEUNIFORMNAMEPROC) (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei* length, GLchar *name);\r\ntypedef void (GLAPIENTRY * PFNGLGETACTIVESUBROUTINEUNIFORMIVPROC) (GLuint program, GLenum shadertype, GLuint index, GLenum pname, GLint* values);\r\ntypedef void (GLAPIENTRY * PFNGLGETPROGRAMSTAGEIVPROC) (GLuint program, GLenum shadertype, GLenum pname, GLint* values);\r\ntypedef GLuint (GLAPIENTRY * PFNGLGETSUBROUTINEINDEXPROC) (GLuint program, GLenum shadertype, const GLchar* name);\r\ntypedef GLint (GLAPIENTRY * PFNGLGETSUBROUTINEUNIFORMLOCATIONPROC) (GLuint program, GLenum shadertype, const GLchar* name);\r\ntypedef void (GLAPIENTRY * PFNGLGETUNIFORMSUBROUTINEUIVPROC) (GLenum shadertype, GLint location, GLuint* params);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORMSUBROUTINESUIVPROC) (GLenum shadertype, GLsizei count, const GLuint* indices);\r\n\r\n#define glGetActiveSubroutineName GLEW_GET_FUN(__glewGetActiveSubroutineName)\r\n#define glGetActiveSubroutineUniformName GLEW_GET_FUN(__glewGetActiveSubroutineUniformName)\r\n#define glGetActiveSubroutineUniformiv GLEW_GET_FUN(__glewGetActiveSubroutineUniformiv)\r\n#define glGetProgramStageiv GLEW_GET_FUN(__glewGetProgramStageiv)\r\n#define glGetSubroutineIndex GLEW_GET_FUN(__glewGetSubroutineIndex)\r\n#define glGetSubroutineUniformLocation GLEW_GET_FUN(__glewGetSubroutineUniformLocation)\r\n#define glGetUniformSubroutineuiv GLEW_GET_FUN(__glewGetUniformSubroutineuiv)\r\n#define glUniformSubroutinesuiv GLEW_GET_FUN(__glewUniformSubroutinesuiv)\r\n\r\n#define GLEW_ARB_shader_subroutine GLEW_GET_VAR(__GLEW_ARB_shader_subroutine)\r\n\r\n#endif /* GL_ARB_shader_subroutine */\r\n\r\n/* ------------------ GL_ARB_shader_texture_image_samples ------------------ */\r\n\r\n#ifndef GL_ARB_shader_texture_image_samples\r\n#define GL_ARB_shader_texture_image_samples 1\r\n\r\n#define GLEW_ARB_shader_texture_image_samples GLEW_GET_VAR(__GLEW_ARB_shader_texture_image_samples)\r\n\r\n#endif /* GL_ARB_shader_texture_image_samples */\r\n\r\n/* ----------------------- GL_ARB_shader_texture_lod ----------------------- */\r\n\r\n#ifndef GL_ARB_shader_texture_lod\r\n#define GL_ARB_shader_texture_lod 1\r\n\r\n#define GLEW_ARB_shader_texture_lod GLEW_GET_VAR(__GLEW_ARB_shader_texture_lod)\r\n\r\n#endif /* GL_ARB_shader_texture_lod */\r\n\r\n/* ------------------- GL_ARB_shader_viewport_layer_array ------------------ */\r\n\r\n#ifndef GL_ARB_shader_viewport_layer_array\r\n#define GL_ARB_shader_viewport_layer_array 1\r\n\r\n#define GLEW_ARB_shader_viewport_layer_array GLEW_GET_VAR(__GLEW_ARB_shader_viewport_layer_array)\r\n\r\n#endif /* GL_ARB_shader_viewport_layer_array */\r\n\r\n/* ---------------------- GL_ARB_shading_language_100 ---------------------- */\r\n\r\n#ifndef GL_ARB_shading_language_100\r\n#define GL_ARB_shading_language_100 1\r\n\r\n#define GL_SHADING_LANGUAGE_VERSION_ARB 0x8B8C\r\n\r\n#define GLEW_ARB_shading_language_100 GLEW_GET_VAR(__GLEW_ARB_shading_language_100)\r\n\r\n#endif /* GL_ARB_shading_language_100 */\r\n\r\n/* -------------------- GL_ARB_shading_language_420pack -------------------- */\r\n\r\n#ifndef GL_ARB_shading_language_420pack\r\n#define GL_ARB_shading_language_420pack 1\r\n\r\n#define GLEW_ARB_shading_language_420pack GLEW_GET_VAR(__GLEW_ARB_shading_language_420pack)\r\n\r\n#endif /* GL_ARB_shading_language_420pack */\r\n\r\n/* -------------------- GL_ARB_shading_language_include -------------------- */\r\n\r\n#ifndef GL_ARB_shading_language_include\r\n#define GL_ARB_shading_language_include 1\r\n\r\n#define GL_SHADER_INCLUDE_ARB 0x8DAE\r\n#define GL_NAMED_STRING_LENGTH_ARB 0x8DE9\r\n#define GL_NAMED_STRING_TYPE_ARB 0x8DEA\r\n\r\ntypedef void (GLAPIENTRY * PFNGLCOMPILESHADERINCLUDEARBPROC) (GLuint shader, GLsizei count, const GLchar* const *path, const GLint *length);\r\ntypedef void (GLAPIENTRY * PFNGLDELETENAMEDSTRINGARBPROC) (GLint namelen, const GLchar* name);\r\ntypedef void (GLAPIENTRY * PFNGLGETNAMEDSTRINGARBPROC) (GLint namelen, const GLchar* name, GLsizei bufSize, GLint *stringlen, GLchar *string);\r\ntypedef void (GLAPIENTRY * PFNGLGETNAMEDSTRINGIVARBPROC) (GLint namelen, const GLchar* name, GLenum pname, GLint *params);\r\ntypedef GLboolean (GLAPIENTRY * PFNGLISNAMEDSTRINGARBPROC) (GLint namelen, const GLchar* name);\r\ntypedef void (GLAPIENTRY * PFNGLNAMEDSTRINGARBPROC) (GLenum type, GLint namelen, const GLchar* name, GLint stringlen, const GLchar *string);\r\n\r\n#define glCompileShaderIncludeARB GLEW_GET_FUN(__glewCompileShaderIncludeARB)\r\n#define glDeleteNamedStringARB GLEW_GET_FUN(__glewDeleteNamedStringARB)\r\n#define glGetNamedStringARB GLEW_GET_FUN(__glewGetNamedStringARB)\r\n#define glGetNamedStringivARB GLEW_GET_FUN(__glewGetNamedStringivARB)\r\n#define glIsNamedStringARB GLEW_GET_FUN(__glewIsNamedStringARB)\r\n#define glNamedStringARB GLEW_GET_FUN(__glewNamedStringARB)\r\n\r\n#define GLEW_ARB_shading_language_include GLEW_GET_VAR(__GLEW_ARB_shading_language_include)\r\n\r\n#endif /* GL_ARB_shading_language_include */\r\n\r\n/* -------------------- GL_ARB_shading_language_packing -------------------- */\r\n\r\n#ifndef GL_ARB_shading_language_packing\r\n#define GL_ARB_shading_language_packing 1\r\n\r\n#define GLEW_ARB_shading_language_packing GLEW_GET_VAR(__GLEW_ARB_shading_language_packing)\r\n\r\n#endif /* GL_ARB_shading_language_packing */\r\n\r\n/* ----------------------------- GL_ARB_shadow ----------------------------- */\r\n\r\n#ifndef GL_ARB_shadow\r\n#define GL_ARB_shadow 1\r\n\r\n#define GL_TEXTURE_COMPARE_MODE_ARB 0x884C\r\n#define GL_TEXTURE_COMPARE_FUNC_ARB 0x884D\r\n#define GL_COMPARE_R_TO_TEXTURE_ARB 0x884E\r\n\r\n#define GLEW_ARB_shadow GLEW_GET_VAR(__GLEW_ARB_shadow)\r\n\r\n#endif /* GL_ARB_shadow */\r\n\r\n/* ------------------------- GL_ARB_shadow_ambient ------------------------- */\r\n\r\n#ifndef GL_ARB_shadow_ambient\r\n#define GL_ARB_shadow_ambient 1\r\n\r\n#define GL_TEXTURE_COMPARE_FAIL_VALUE_ARB 0x80BF\r\n\r\n#define GLEW_ARB_shadow_ambient GLEW_GET_VAR(__GLEW_ARB_shadow_ambient)\r\n\r\n#endif /* GL_ARB_shadow_ambient */\r\n\r\n/* -------------------------- GL_ARB_sparse_buffer ------------------------- */\r\n\r\n#ifndef GL_ARB_sparse_buffer\r\n#define GL_ARB_sparse_buffer 1\r\n\r\n#define GL_SPARSE_STORAGE_BIT_ARB 0x0400\r\n#define GL_SPARSE_BUFFER_PAGE_SIZE_ARB 0x82F8\r\n\r\ntypedef void (GLAPIENTRY * PFNGLBUFFERPAGECOMMITMENTARBPROC) (GLenum target, GLintptr offset, GLsizeiptr size, GLboolean commit);\r\n\r\n#define glBufferPageCommitmentARB GLEW_GET_FUN(__glewBufferPageCommitmentARB)\r\n\r\n#define GLEW_ARB_sparse_buffer GLEW_GET_VAR(__GLEW_ARB_sparse_buffer)\r\n\r\n#endif /* GL_ARB_sparse_buffer */\r\n\r\n/* ------------------------- GL_ARB_sparse_texture ------------------------- */\r\n\r\n#ifndef GL_ARB_sparse_texture\r\n#define GL_ARB_sparse_texture 1\r\n\r\n#define GL_VIRTUAL_PAGE_SIZE_X_ARB 0x9195\r\n#define GL_VIRTUAL_PAGE_SIZE_Y_ARB 0x9196\r\n#define GL_VIRTUAL_PAGE_SIZE_Z_ARB 0x9197\r\n#define GL_MAX_SPARSE_TEXTURE_SIZE_ARB 0x9198\r\n#define GL_MAX_SPARSE_3D_TEXTURE_SIZE_ARB 0x9199\r\n#define GL_MAX_SPARSE_ARRAY_TEXTURE_LAYERS_ARB 0x919A\r\n#define GL_TEXTURE_SPARSE_ARB 0x91A6\r\n#define GL_VIRTUAL_PAGE_SIZE_INDEX_ARB 0x91A7\r\n#define GL_NUM_VIRTUAL_PAGE_SIZES_ARB 0x91A8\r\n#define GL_SPARSE_TEXTURE_FULL_ARRAY_CUBE_MIPMAPS_ARB 0x91A9\r\n#define GL_NUM_SPARSE_LEVELS_ARB 0x91AA\r\n\r\ntypedef void (GLAPIENTRY * PFNGLTEXPAGECOMMITMENTARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLboolean commit);\r\ntypedef void (GLAPIENTRY * PFNGLTEXTUREPAGECOMMITMENTEXTPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLboolean commit);\r\n\r\n#define glTexPageCommitmentARB GLEW_GET_FUN(__glewTexPageCommitmentARB)\r\n#define glTexturePageCommitmentEXT GLEW_GET_FUN(__glewTexturePageCommitmentEXT)\r\n\r\n#define GLEW_ARB_sparse_texture GLEW_GET_VAR(__GLEW_ARB_sparse_texture)\r\n\r\n#endif /* GL_ARB_sparse_texture */\r\n\r\n/* ------------------------- GL_ARB_sparse_texture2 ------------------------ */\r\n\r\n#ifndef GL_ARB_sparse_texture2\r\n#define GL_ARB_sparse_texture2 1\r\n\r\n#define GLEW_ARB_sparse_texture2 GLEW_GET_VAR(__GLEW_ARB_sparse_texture2)\r\n\r\n#endif /* GL_ARB_sparse_texture2 */\r\n\r\n/* ---------------------- GL_ARB_sparse_texture_clamp ---------------------- */\r\n\r\n#ifndef GL_ARB_sparse_texture_clamp\r\n#define GL_ARB_sparse_texture_clamp 1\r\n\r\n#define GLEW_ARB_sparse_texture_clamp GLEW_GET_VAR(__GLEW_ARB_sparse_texture_clamp)\r\n\r\n#endif /* GL_ARB_sparse_texture_clamp */\r\n\r\n/* ------------------------ GL_ARB_stencil_texturing ----------------------- */\r\n\r\n#ifndef GL_ARB_stencil_texturing\r\n#define GL_ARB_stencil_texturing 1\r\n\r\n#define GL_DEPTH_STENCIL_TEXTURE_MODE 0x90EA\r\n\r\n#define GLEW_ARB_stencil_texturing GLEW_GET_VAR(__GLEW_ARB_stencil_texturing)\r\n\r\n#endif /* GL_ARB_stencil_texturing */\r\n\r\n/* ------------------------------ GL_ARB_sync ------------------------------ */\r\n\r\n#ifndef GL_ARB_sync\r\n#define GL_ARB_sync 1\r\n\r\n#define GL_SYNC_FLUSH_COMMANDS_BIT 0x00000001\r\n#define GL_MAX_SERVER_WAIT_TIMEOUT 0x9111\r\n#define GL_OBJECT_TYPE 0x9112\r\n#define GL_SYNC_CONDITION 0x9113\r\n#define GL_SYNC_STATUS 0x9114\r\n#define GL_SYNC_FLAGS 0x9115\r\n#define GL_SYNC_FENCE 0x9116\r\n#define GL_SYNC_GPU_COMMANDS_COMPLETE 0x9117\r\n#define GL_UNSIGNALED 0x9118\r\n#define GL_SIGNALED 0x9119\r\n#define GL_ALREADY_SIGNALED 0x911A\r\n#define GL_TIMEOUT_EXPIRED 0x911B\r\n#define GL_CONDITION_SATISFIED 0x911C\r\n#define GL_WAIT_FAILED 0x911D\r\n#define GL_TIMEOUT_IGNORED 0xFFFFFFFFFFFFFFFF\r\n\r\ntypedef GLenum (GLAPIENTRY * PFNGLCLIENTWAITSYNCPROC) (GLsync GLsync,GLbitfield flags,GLuint64 timeout);\r\ntypedef void (GLAPIENTRY * PFNGLDELETESYNCPROC) (GLsync GLsync);\r\ntypedef GLsync (GLAPIENTRY * PFNGLFENCESYNCPROC) (GLenum condition,GLbitfield flags);\r\ntypedef void (GLAPIENTRY * PFNGLGETINTEGER64VPROC) (GLenum pname, GLint64* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETSYNCIVPROC) (GLsync GLsync,GLenum pname,GLsizei bufSize,GLsizei* length, GLint *values);\r\ntypedef GLboolean (GLAPIENTRY * PFNGLISSYNCPROC) (GLsync GLsync);\r\ntypedef void (GLAPIENTRY * PFNGLWAITSYNCPROC) (GLsync GLsync,GLbitfield flags,GLuint64 timeout);\r\n\r\n#define glClientWaitSync GLEW_GET_FUN(__glewClientWaitSync)\r\n#define glDeleteSync GLEW_GET_FUN(__glewDeleteSync)\r\n#define glFenceSync GLEW_GET_FUN(__glewFenceSync)\r\n#define glGetInteger64v GLEW_GET_FUN(__glewGetInteger64v)\r\n#define glGetSynciv GLEW_GET_FUN(__glewGetSynciv)\r\n#define glIsSync GLEW_GET_FUN(__glewIsSync)\r\n#define glWaitSync GLEW_GET_FUN(__glewWaitSync)\r\n\r\n#define GLEW_ARB_sync GLEW_GET_VAR(__GLEW_ARB_sync)\r\n\r\n#endif /* GL_ARB_sync */\r\n\r\n/* ----------------------- GL_ARB_tessellation_shader ---------------------- */\r\n\r\n#ifndef GL_ARB_tessellation_shader\r\n#define GL_ARB_tessellation_shader 1\r\n\r\n#define GL_PATCHES 0xE\r\n#define GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_CONTROL_SHADER 0x84F0\r\n#define GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_EVALUATION_SHADER 0x84F1\r\n#define GL_MAX_TESS_CONTROL_INPUT_COMPONENTS 0x886C\r\n#define GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS 0x886D\r\n#define GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS 0x8E1E\r\n#define GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS 0x8E1F\r\n#define GL_PATCH_VERTICES 0x8E72\r\n#define GL_PATCH_DEFAULT_INNER_LEVEL 0x8E73\r\n#define GL_PATCH_DEFAULT_OUTER_LEVEL 0x8E74\r\n#define GL_TESS_CONTROL_OUTPUT_VERTICES 0x8E75\r\n#define GL_TESS_GEN_MODE 0x8E76\r\n#define GL_TESS_GEN_SPACING 0x8E77\r\n#define GL_TESS_GEN_VERTEX_ORDER 0x8E78\r\n#define GL_TESS_GEN_POINT_MODE 0x8E79\r\n#define GL_ISOLINES 0x8E7A\r\n#define GL_FRACTIONAL_ODD 0x8E7B\r\n#define GL_FRACTIONAL_EVEN 0x8E7C\r\n#define GL_MAX_PATCH_VERTICES 0x8E7D\r\n#define GL_MAX_TESS_GEN_LEVEL 0x8E7E\r\n#define GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS 0x8E7F\r\n#define GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS 0x8E80\r\n#define GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS 0x8E81\r\n#define GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS 0x8E82\r\n#define GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS 0x8E83\r\n#define GL_MAX_TESS_PATCH_COMPONENTS 0x8E84\r\n#define GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS 0x8E85\r\n#define GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS 0x8E86\r\n#define GL_TESS_EVALUATION_SHADER 0x8E87\r\n#define GL_TESS_CONTROL_SHADER 0x8E88\r\n#define GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS 0x8E89\r\n#define GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS 0x8E8A\r\n\r\ntypedef void (GLAPIENTRY * PFNGLPATCHPARAMETERFVPROC) (GLenum pname, const GLfloat* values);\r\ntypedef void (GLAPIENTRY * PFNGLPATCHPARAMETERIPROC) (GLenum pname, GLint value);\r\n\r\n#define glPatchParameterfv GLEW_GET_FUN(__glewPatchParameterfv)\r\n#define glPatchParameteri GLEW_GET_FUN(__glewPatchParameteri)\r\n\r\n#define GLEW_ARB_tessellation_shader GLEW_GET_VAR(__GLEW_ARB_tessellation_shader)\r\n\r\n#endif /* GL_ARB_tessellation_shader */\r\n\r\n/* ------------------------- GL_ARB_texture_barrier ------------------------ */\r\n\r\n#ifndef GL_ARB_texture_barrier\r\n#define GL_ARB_texture_barrier 1\r\n\r\ntypedef void (GLAPIENTRY * PFNGLTEXTUREBARRIERPROC) (void);\r\n\r\n#define glTextureBarrier GLEW_GET_FUN(__glewTextureBarrier)\r\n\r\n#define GLEW_ARB_texture_barrier GLEW_GET_VAR(__GLEW_ARB_texture_barrier)\r\n\r\n#endif /* GL_ARB_texture_barrier */\r\n\r\n/* ---------------------- GL_ARB_texture_border_clamp ---------------------- */\r\n\r\n#ifndef GL_ARB_texture_border_clamp\r\n#define GL_ARB_texture_border_clamp 1\r\n\r\n#define GL_CLAMP_TO_BORDER_ARB 0x812D\r\n\r\n#define GLEW_ARB_texture_border_clamp GLEW_GET_VAR(__GLEW_ARB_texture_border_clamp)\r\n\r\n#endif /* GL_ARB_texture_border_clamp */\r\n\r\n/* ---------------------- GL_ARB_texture_buffer_object --------------------- */\r\n\r\n#ifndef GL_ARB_texture_buffer_object\r\n#define GL_ARB_texture_buffer_object 1\r\n\r\n#define GL_TEXTURE_BUFFER_ARB 0x8C2A\r\n#define GL_MAX_TEXTURE_BUFFER_SIZE_ARB 0x8C2B\r\n#define GL_TEXTURE_BINDING_BUFFER_ARB 0x8C2C\r\n#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_ARB 0x8C2D\r\n#define GL_TEXTURE_BUFFER_FORMAT_ARB 0x8C2E\r\n\r\ntypedef void (GLAPIENTRY * PFNGLTEXBUFFERARBPROC) (GLenum target, GLenum internalformat, GLuint buffer);\r\n\r\n#define glTexBufferARB GLEW_GET_FUN(__glewTexBufferARB)\r\n\r\n#define GLEW_ARB_texture_buffer_object GLEW_GET_VAR(__GLEW_ARB_texture_buffer_object)\r\n\r\n#endif /* GL_ARB_texture_buffer_object */\r\n\r\n/* ------------------- GL_ARB_texture_buffer_object_rgb32 ------------------ */\r\n\r\n#ifndef GL_ARB_texture_buffer_object_rgb32\r\n#define GL_ARB_texture_buffer_object_rgb32 1\r\n\r\n#define GLEW_ARB_texture_buffer_object_rgb32 GLEW_GET_VAR(__GLEW_ARB_texture_buffer_object_rgb32)\r\n\r\n#endif /* GL_ARB_texture_buffer_object_rgb32 */\r\n\r\n/* ---------------------- GL_ARB_texture_buffer_range ---------------------- */\r\n\r\n#ifndef GL_ARB_texture_buffer_range\r\n#define GL_ARB_texture_buffer_range 1\r\n\r\n#define GL_TEXTURE_BUFFER_OFFSET 0x919D\r\n#define GL_TEXTURE_BUFFER_SIZE 0x919E\r\n#define GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT 0x919F\r\n\r\ntypedef void (GLAPIENTRY * PFNGLTEXBUFFERRANGEPROC) (GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size);\r\ntypedef void (GLAPIENTRY * PFNGLTEXTUREBUFFERRANGEEXTPROC) (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size);\r\n\r\n#define glTexBufferRange GLEW_GET_FUN(__glewTexBufferRange)\r\n#define glTextureBufferRangeEXT GLEW_GET_FUN(__glewTextureBufferRangeEXT)\r\n\r\n#define GLEW_ARB_texture_buffer_range GLEW_GET_VAR(__GLEW_ARB_texture_buffer_range)\r\n\r\n#endif /* GL_ARB_texture_buffer_range */\r\n\r\n/* ----------------------- GL_ARB_texture_compression ---------------------- */\r\n\r\n#ifndef GL_ARB_texture_compression\r\n#define GL_ARB_texture_compression 1\r\n\r\n#define GL_COMPRESSED_ALPHA_ARB 0x84E9\r\n#define GL_COMPRESSED_LUMINANCE_ARB 0x84EA\r\n#define GL_COMPRESSED_LUMINANCE_ALPHA_ARB 0x84EB\r\n#define GL_COMPRESSED_INTENSITY_ARB 0x84EC\r\n#define GL_COMPRESSED_RGB_ARB 0x84ED\r\n#define GL_COMPRESSED_RGBA_ARB 0x84EE\r\n#define GL_TEXTURE_COMPRESSION_HINT_ARB 0x84EF\r\n#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB 0x86A0\r\n#define GL_TEXTURE_COMPRESSED_ARB 0x86A1\r\n#define GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A2\r\n#define GL_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A3\r\n\r\ntypedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXIMAGE1DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *data);\r\ntypedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXIMAGE2DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data);\r\ntypedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXIMAGE3DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data);\r\ntypedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data);\r\ntypedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data);\r\ntypedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data);\r\ntypedef void (GLAPIENTRY * PFNGLGETCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint lod, void *img);\r\n\r\n#define glCompressedTexImage1DARB GLEW_GET_FUN(__glewCompressedTexImage1DARB)\r\n#define glCompressedTexImage2DARB GLEW_GET_FUN(__glewCompressedTexImage2DARB)\r\n#define glCompressedTexImage3DARB GLEW_GET_FUN(__glewCompressedTexImage3DARB)\r\n#define glCompressedTexSubImage1DARB GLEW_GET_FUN(__glewCompressedTexSubImage1DARB)\r\n#define glCompressedTexSubImage2DARB GLEW_GET_FUN(__glewCompressedTexSubImage2DARB)\r\n#define glCompressedTexSubImage3DARB GLEW_GET_FUN(__glewCompressedTexSubImage3DARB)\r\n#define glGetCompressedTexImageARB GLEW_GET_FUN(__glewGetCompressedTexImageARB)\r\n\r\n#define GLEW_ARB_texture_compression GLEW_GET_VAR(__GLEW_ARB_texture_compression)\r\n\r\n#endif /* GL_ARB_texture_compression */\r\n\r\n/* -------------------- GL_ARB_texture_compression_bptc -------------------- */\r\n\r\n#ifndef GL_ARB_texture_compression_bptc\r\n#define GL_ARB_texture_compression_bptc 1\r\n\r\n#define GL_COMPRESSED_RGBA_BPTC_UNORM_ARB 0x8E8C\r\n#define GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB 0x8E8D\r\n#define GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB 0x8E8E\r\n#define GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB 0x8E8F\r\n\r\n#define GLEW_ARB_texture_compression_bptc GLEW_GET_VAR(__GLEW_ARB_texture_compression_bptc)\r\n\r\n#endif /* GL_ARB_texture_compression_bptc */\r\n\r\n/* -------------------- GL_ARB_texture_compression_rgtc -------------------- */\r\n\r\n#ifndef GL_ARB_texture_compression_rgtc\r\n#define GL_ARB_texture_compression_rgtc 1\r\n\r\n#define GL_COMPRESSED_RED_RGTC1 0x8DBB\r\n#define GL_COMPRESSED_SIGNED_RED_RGTC1 0x8DBC\r\n#define GL_COMPRESSED_RG_RGTC2 0x8DBD\r\n#define GL_COMPRESSED_SIGNED_RG_RGTC2 0x8DBE\r\n\r\n#define GLEW_ARB_texture_compression_rgtc GLEW_GET_VAR(__GLEW_ARB_texture_compression_rgtc)\r\n\r\n#endif /* GL_ARB_texture_compression_rgtc */\r\n\r\n/* ------------------------ GL_ARB_texture_cube_map ------------------------ */\r\n\r\n#ifndef GL_ARB_texture_cube_map\r\n#define GL_ARB_texture_cube_map 1\r\n\r\n#define GL_NORMAL_MAP_ARB 0x8511\r\n#define GL_REFLECTION_MAP_ARB 0x8512\r\n#define GL_TEXTURE_CUBE_MAP_ARB 0x8513\r\n#define GL_TEXTURE_BINDING_CUBE_MAP_ARB 0x8514\r\n#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x8515\r\n#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x8516\r\n#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x8517\r\n#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x8518\r\n#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x8519\r\n#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x851A\r\n#define GL_PROXY_TEXTURE_CUBE_MAP_ARB 0x851B\r\n#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB 0x851C\r\n\r\n#define GLEW_ARB_texture_cube_map GLEW_GET_VAR(__GLEW_ARB_texture_cube_map)\r\n\r\n#endif /* GL_ARB_texture_cube_map */\r\n\r\n/* --------------------- GL_ARB_texture_cube_map_array --------------------- */\r\n\r\n#ifndef GL_ARB_texture_cube_map_array\r\n#define GL_ARB_texture_cube_map_array 1\r\n\r\n#define GL_TEXTURE_CUBE_MAP_ARRAY_ARB 0x9009\r\n#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY_ARB 0x900A\r\n#define GL_PROXY_TEXTURE_CUBE_MAP_ARRAY_ARB 0x900B\r\n#define GL_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900C\r\n#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW_ARB 0x900D\r\n#define GL_INT_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900E\r\n#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900F\r\n\r\n#define GLEW_ARB_texture_cube_map_array GLEW_GET_VAR(__GLEW_ARB_texture_cube_map_array)\r\n\r\n#endif /* GL_ARB_texture_cube_map_array */\r\n\r\n/* ------------------------- GL_ARB_texture_env_add ------------------------ */\r\n\r\n#ifndef GL_ARB_texture_env_add\r\n#define GL_ARB_texture_env_add 1\r\n\r\n#define GLEW_ARB_texture_env_add GLEW_GET_VAR(__GLEW_ARB_texture_env_add)\r\n\r\n#endif /* GL_ARB_texture_env_add */\r\n\r\n/* ----------------------- GL_ARB_texture_env_combine ---------------------- */\r\n\r\n#ifndef GL_ARB_texture_env_combine\r\n#define GL_ARB_texture_env_combine 1\r\n\r\n#define GL_SUBTRACT_ARB 0x84E7\r\n#define GL_COMBINE_ARB 0x8570\r\n#define GL_COMBINE_RGB_ARB 0x8571\r\n#define GL_COMBINE_ALPHA_ARB 0x8572\r\n#define GL_RGB_SCALE_ARB 0x8573\r\n#define GL_ADD_SIGNED_ARB 0x8574\r\n#define GL_INTERPOLATE_ARB 0x8575\r\n#define GL_CONSTANT_ARB 0x8576\r\n#define GL_PRIMARY_COLOR_ARB 0x8577\r\n#define GL_PREVIOUS_ARB 0x8578\r\n#define GL_SOURCE0_RGB_ARB 0x8580\r\n#define GL_SOURCE1_RGB_ARB 0x8581\r\n#define GL_SOURCE2_RGB_ARB 0x8582\r\n#define GL_SOURCE0_ALPHA_ARB 0x8588\r\n#define GL_SOURCE1_ALPHA_ARB 0x8589\r\n#define GL_SOURCE2_ALPHA_ARB 0x858A\r\n#define GL_OPERAND0_RGB_ARB 0x8590\r\n#define GL_OPERAND1_RGB_ARB 0x8591\r\n#define GL_OPERAND2_RGB_ARB 0x8592\r\n#define GL_OPERAND0_ALPHA_ARB 0x8598\r\n#define GL_OPERAND1_ALPHA_ARB 0x8599\r\n#define GL_OPERAND2_ALPHA_ARB 0x859A\r\n\r\n#define GLEW_ARB_texture_env_combine GLEW_GET_VAR(__GLEW_ARB_texture_env_combine)\r\n\r\n#endif /* GL_ARB_texture_env_combine */\r\n\r\n/* ---------------------- GL_ARB_texture_env_crossbar ---------------------- */\r\n\r\n#ifndef GL_ARB_texture_env_crossbar\r\n#define GL_ARB_texture_env_crossbar 1\r\n\r\n#define GLEW_ARB_texture_env_crossbar GLEW_GET_VAR(__GLEW_ARB_texture_env_crossbar)\r\n\r\n#endif /* GL_ARB_texture_env_crossbar */\r\n\r\n/* ------------------------ GL_ARB_texture_env_dot3 ------------------------ */\r\n\r\n#ifndef GL_ARB_texture_env_dot3\r\n#define GL_ARB_texture_env_dot3 1\r\n\r\n#define GL_DOT3_RGB_ARB 0x86AE\r\n#define GL_DOT3_RGBA_ARB 0x86AF\r\n\r\n#define GLEW_ARB_texture_env_dot3 GLEW_GET_VAR(__GLEW_ARB_texture_env_dot3)\r\n\r\n#endif /* GL_ARB_texture_env_dot3 */\r\n\r\n/* ---------------------- GL_ARB_texture_filter_minmax --------------------- */\r\n\r\n#ifndef GL_ARB_texture_filter_minmax\r\n#define GL_ARB_texture_filter_minmax 1\r\n\r\n#define GL_TEXTURE_REDUCTION_MODE_ARB 0x9366\r\n#define GL_WEIGHTED_AVERAGE_ARB 0x9367\r\n\r\n#define GLEW_ARB_texture_filter_minmax GLEW_GET_VAR(__GLEW_ARB_texture_filter_minmax)\r\n\r\n#endif /* GL_ARB_texture_filter_minmax */\r\n\r\n/* -------------------------- GL_ARB_texture_float ------------------------- */\r\n\r\n#ifndef GL_ARB_texture_float\r\n#define GL_ARB_texture_float 1\r\n\r\n#define GL_RGBA32F_ARB 0x8814\r\n#define GL_RGB32F_ARB 0x8815\r\n#define GL_ALPHA32F_ARB 0x8816\r\n#define GL_INTENSITY32F_ARB 0x8817\r\n#define GL_LUMINANCE32F_ARB 0x8818\r\n#define GL_LUMINANCE_ALPHA32F_ARB 0x8819\r\n#define GL_RGBA16F_ARB 0x881A\r\n#define GL_RGB16F_ARB 0x881B\r\n#define GL_ALPHA16F_ARB 0x881C\r\n#define GL_INTENSITY16F_ARB 0x881D\r\n#define GL_LUMINANCE16F_ARB 0x881E\r\n#define GL_LUMINANCE_ALPHA16F_ARB 0x881F\r\n#define GL_TEXTURE_RED_TYPE_ARB 0x8C10\r\n#define GL_TEXTURE_GREEN_TYPE_ARB 0x8C11\r\n#define GL_TEXTURE_BLUE_TYPE_ARB 0x8C12\r\n#define GL_TEXTURE_ALPHA_TYPE_ARB 0x8C13\r\n#define GL_TEXTURE_LUMINANCE_TYPE_ARB 0x8C14\r\n#define GL_TEXTURE_INTENSITY_TYPE_ARB 0x8C15\r\n#define GL_TEXTURE_DEPTH_TYPE_ARB 0x8C16\r\n#define GL_UNSIGNED_NORMALIZED_ARB 0x8C17\r\n\r\n#define GLEW_ARB_texture_float GLEW_GET_VAR(__GLEW_ARB_texture_float)\r\n\r\n#endif /* GL_ARB_texture_float */\r\n\r\n/* ------------------------- GL_ARB_texture_gather ------------------------- */\r\n\r\n#ifndef GL_ARB_texture_gather\r\n#define GL_ARB_texture_gather 1\r\n\r\n#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET_ARB 0x8E5E\r\n#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET_ARB 0x8E5F\r\n#define GL_MAX_PROGRAM_TEXTURE_GATHER_COMPONENTS_ARB 0x8F9F\r\n\r\n#define GLEW_ARB_texture_gather GLEW_GET_VAR(__GLEW_ARB_texture_gather)\r\n\r\n#endif /* GL_ARB_texture_gather */\r\n\r\n/* ------------------ GL_ARB_texture_mirror_clamp_to_edge ------------------ */\r\n\r\n#ifndef GL_ARB_texture_mirror_clamp_to_edge\r\n#define GL_ARB_texture_mirror_clamp_to_edge 1\r\n\r\n#define GL_MIRROR_CLAMP_TO_EDGE 0x8743\r\n\r\n#define GLEW_ARB_texture_mirror_clamp_to_edge GLEW_GET_VAR(__GLEW_ARB_texture_mirror_clamp_to_edge)\r\n\r\n#endif /* GL_ARB_texture_mirror_clamp_to_edge */\r\n\r\n/* --------------------- GL_ARB_texture_mirrored_repeat -------------------- */\r\n\r\n#ifndef GL_ARB_texture_mirrored_repeat\r\n#define GL_ARB_texture_mirrored_repeat 1\r\n\r\n#define GL_MIRRORED_REPEAT_ARB 0x8370\r\n\r\n#define GLEW_ARB_texture_mirrored_repeat GLEW_GET_VAR(__GLEW_ARB_texture_mirrored_repeat)\r\n\r\n#endif /* GL_ARB_texture_mirrored_repeat */\r\n\r\n/* ----------------------- GL_ARB_texture_multisample ---------------------- */\r\n\r\n#ifndef GL_ARB_texture_multisample\r\n#define GL_ARB_texture_multisample 1\r\n\r\n#define GL_SAMPLE_POSITION 0x8E50\r\n#define GL_SAMPLE_MASK 0x8E51\r\n#define GL_SAMPLE_MASK_VALUE 0x8E52\r\n#define GL_MAX_SAMPLE_MASK_WORDS 0x8E59\r\n#define GL_TEXTURE_2D_MULTISAMPLE 0x9100\r\n#define GL_PROXY_TEXTURE_2D_MULTISAMPLE 0x9101\r\n#define GL_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9102\r\n#define GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9103\r\n#define GL_TEXTURE_BINDING_2D_MULTISAMPLE 0x9104\r\n#define GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY 0x9105\r\n#define GL_TEXTURE_SAMPLES 0x9106\r\n#define GL_TEXTURE_FIXED_SAMPLE_LOCATIONS 0x9107\r\n#define GL_SAMPLER_2D_MULTISAMPLE 0x9108\r\n#define GL_INT_SAMPLER_2D_MULTISAMPLE 0x9109\r\n#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE 0x910A\r\n#define GL_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910B\r\n#define GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910C\r\n#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910D\r\n#define GL_MAX_COLOR_TEXTURE_SAMPLES 0x910E\r\n#define GL_MAX_DEPTH_TEXTURE_SAMPLES 0x910F\r\n#define GL_MAX_INTEGER_SAMPLES 0x9110\r\n\r\ntypedef void (GLAPIENTRY * PFNGLGETMULTISAMPLEFVPROC) (GLenum pname, GLuint index, GLfloat* val);\r\ntypedef void (GLAPIENTRY * PFNGLSAMPLEMASKIPROC) (GLuint index, GLbitfield mask);\r\ntypedef void (GLAPIENTRY * PFNGLTEXIMAGE2DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations);\r\ntypedef void (GLAPIENTRY * PFNGLTEXIMAGE3DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations);\r\n\r\n#define glGetMultisamplefv GLEW_GET_FUN(__glewGetMultisamplefv)\r\n#define glSampleMaski GLEW_GET_FUN(__glewSampleMaski)\r\n#define glTexImage2DMultisample GLEW_GET_FUN(__glewTexImage2DMultisample)\r\n#define glTexImage3DMultisample GLEW_GET_FUN(__glewTexImage3DMultisample)\r\n\r\n#define GLEW_ARB_texture_multisample GLEW_GET_VAR(__GLEW_ARB_texture_multisample)\r\n\r\n#endif /* GL_ARB_texture_multisample */\r\n\r\n/* -------------------- GL_ARB_texture_non_power_of_two -------------------- */\r\n\r\n#ifndef GL_ARB_texture_non_power_of_two\r\n#define GL_ARB_texture_non_power_of_two 1\r\n\r\n#define GLEW_ARB_texture_non_power_of_two GLEW_GET_VAR(__GLEW_ARB_texture_non_power_of_two)\r\n\r\n#endif /* GL_ARB_texture_non_power_of_two */\r\n\r\n/* ---------------------- GL_ARB_texture_query_levels ---------------------- */\r\n\r\n#ifndef GL_ARB_texture_query_levels\r\n#define GL_ARB_texture_query_levels 1\r\n\r\n#define GLEW_ARB_texture_query_levels GLEW_GET_VAR(__GLEW_ARB_texture_query_levels)\r\n\r\n#endif /* GL_ARB_texture_query_levels */\r\n\r\n/* ------------------------ GL_ARB_texture_query_lod ----------------------- */\r\n\r\n#ifndef GL_ARB_texture_query_lod\r\n#define GL_ARB_texture_query_lod 1\r\n\r\n#define GLEW_ARB_texture_query_lod GLEW_GET_VAR(__GLEW_ARB_texture_query_lod)\r\n\r\n#endif /* GL_ARB_texture_query_lod */\r\n\r\n/* ------------------------ GL_ARB_texture_rectangle ----------------------- */\r\n\r\n#ifndef GL_ARB_texture_rectangle\r\n#define GL_ARB_texture_rectangle 1\r\n\r\n#define GL_TEXTURE_RECTANGLE_ARB 0x84F5\r\n#define GL_TEXTURE_BINDING_RECTANGLE_ARB 0x84F6\r\n#define GL_PROXY_TEXTURE_RECTANGLE_ARB 0x84F7\r\n#define GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB 0x84F8\r\n#define GL_SAMPLER_2D_RECT_ARB 0x8B63\r\n#define GL_SAMPLER_2D_RECT_SHADOW_ARB 0x8B64\r\n\r\n#define GLEW_ARB_texture_rectangle GLEW_GET_VAR(__GLEW_ARB_texture_rectangle)\r\n\r\n#endif /* GL_ARB_texture_rectangle */\r\n\r\n/* --------------------------- GL_ARB_texture_rg --------------------------- */\r\n\r\n#ifndef GL_ARB_texture_rg\r\n#define GL_ARB_texture_rg 1\r\n\r\n#define GL_COMPRESSED_RED 0x8225\r\n#define GL_COMPRESSED_RG 0x8226\r\n#define GL_RG 0x8227\r\n#define GL_RG_INTEGER 0x8228\r\n#define GL_R8 0x8229\r\n#define GL_R16 0x822A\r\n#define GL_RG8 0x822B\r\n#define GL_RG16 0x822C\r\n#define GL_R16F 0x822D\r\n#define GL_R32F 0x822E\r\n#define GL_RG16F 0x822F\r\n#define GL_RG32F 0x8230\r\n#define GL_R8I 0x8231\r\n#define GL_R8UI 0x8232\r\n#define GL_R16I 0x8233\r\n#define GL_R16UI 0x8234\r\n#define GL_R32I 0x8235\r\n#define GL_R32UI 0x8236\r\n#define GL_RG8I 0x8237\r\n#define GL_RG8UI 0x8238\r\n#define GL_RG16I 0x8239\r\n#define GL_RG16UI 0x823A\r\n#define GL_RG32I 0x823B\r\n#define GL_RG32UI 0x823C\r\n\r\n#define GLEW_ARB_texture_rg GLEW_GET_VAR(__GLEW_ARB_texture_rg)\r\n\r\n#endif /* GL_ARB_texture_rg */\r\n\r\n/* ----------------------- GL_ARB_texture_rgb10_a2ui ----------------------- */\r\n\r\n#ifndef GL_ARB_texture_rgb10_a2ui\r\n#define GL_ARB_texture_rgb10_a2ui 1\r\n\r\n#define GL_RGB10_A2UI 0x906F\r\n\r\n#define GLEW_ARB_texture_rgb10_a2ui GLEW_GET_VAR(__GLEW_ARB_texture_rgb10_a2ui)\r\n\r\n#endif /* GL_ARB_texture_rgb10_a2ui */\r\n\r\n/* ------------------------ GL_ARB_texture_stencil8 ------------------------ */\r\n\r\n#ifndef GL_ARB_texture_stencil8\r\n#define GL_ARB_texture_stencil8 1\r\n\r\n#define GL_STENCIL_INDEX 0x1901\r\n#define GL_STENCIL_INDEX8 0x8D48\r\n\r\n#define GLEW_ARB_texture_stencil8 GLEW_GET_VAR(__GLEW_ARB_texture_stencil8)\r\n\r\n#endif /* GL_ARB_texture_stencil8 */\r\n\r\n/* ------------------------- GL_ARB_texture_storage ------------------------ */\r\n\r\n#ifndef GL_ARB_texture_storage\r\n#define GL_ARB_texture_storage 1\r\n\r\n#define GL_TEXTURE_IMMUTABLE_FORMAT 0x912F\r\n\r\ntypedef void (GLAPIENTRY * PFNGLTEXSTORAGE1DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width);\r\ntypedef void (GLAPIENTRY * PFNGLTEXSTORAGE2DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);\r\ntypedef void (GLAPIENTRY * PFNGLTEXSTORAGE3DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);\r\ntypedef void (GLAPIENTRY * PFNGLTEXTURESTORAGE1DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width);\r\ntypedef void (GLAPIENTRY * PFNGLTEXTURESTORAGE2DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);\r\ntypedef void (GLAPIENTRY * PFNGLTEXTURESTORAGE3DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);\r\n\r\n#define glTexStorage1D GLEW_GET_FUN(__glewTexStorage1D)\r\n#define glTexStorage2D GLEW_GET_FUN(__glewTexStorage2D)\r\n#define glTexStorage3D GLEW_GET_FUN(__glewTexStorage3D)\r\n#define glTextureStorage1DEXT GLEW_GET_FUN(__glewTextureStorage1DEXT)\r\n#define glTextureStorage2DEXT GLEW_GET_FUN(__glewTextureStorage2DEXT)\r\n#define glTextureStorage3DEXT GLEW_GET_FUN(__glewTextureStorage3DEXT)\r\n\r\n#define GLEW_ARB_texture_storage GLEW_GET_VAR(__GLEW_ARB_texture_storage)\r\n\r\n#endif /* GL_ARB_texture_storage */\r\n\r\n/* ------------------- GL_ARB_texture_storage_multisample ------------------ */\r\n\r\n#ifndef GL_ARB_texture_storage_multisample\r\n#define GL_ARB_texture_storage_multisample 1\r\n\r\ntypedef void (GLAPIENTRY * PFNGLTEXSTORAGE2DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations);\r\ntypedef void (GLAPIENTRY * PFNGLTEXSTORAGE3DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations);\r\ntypedef void (GLAPIENTRY * PFNGLTEXTURESTORAGE2DMULTISAMPLEEXTPROC) (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations);\r\ntypedef void (GLAPIENTRY * PFNGLTEXTURESTORAGE3DMULTISAMPLEEXTPROC) (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations);\r\n\r\n#define glTexStorage2DMultisample GLEW_GET_FUN(__glewTexStorage2DMultisample)\r\n#define glTexStorage3DMultisample GLEW_GET_FUN(__glewTexStorage3DMultisample)\r\n#define glTextureStorage2DMultisampleEXT GLEW_GET_FUN(__glewTextureStorage2DMultisampleEXT)\r\n#define glTextureStorage3DMultisampleEXT GLEW_GET_FUN(__glewTextureStorage3DMultisampleEXT)\r\n\r\n#define GLEW_ARB_texture_storage_multisample GLEW_GET_VAR(__GLEW_ARB_texture_storage_multisample)\r\n\r\n#endif /* GL_ARB_texture_storage_multisample */\r\n\r\n/* ------------------------- GL_ARB_texture_swizzle ------------------------ */\r\n\r\n#ifndef GL_ARB_texture_swizzle\r\n#define GL_ARB_texture_swizzle 1\r\n\r\n#define GL_TEXTURE_SWIZZLE_R 0x8E42\r\n#define GL_TEXTURE_SWIZZLE_G 0x8E43\r\n#define GL_TEXTURE_SWIZZLE_B 0x8E44\r\n#define GL_TEXTURE_SWIZZLE_A 0x8E45\r\n#define GL_TEXTURE_SWIZZLE_RGBA 0x8E46\r\n\r\n#define GLEW_ARB_texture_swizzle GLEW_GET_VAR(__GLEW_ARB_texture_swizzle)\r\n\r\n#endif /* GL_ARB_texture_swizzle */\r\n\r\n/* -------------------------- GL_ARB_texture_view -------------------------- */\r\n\r\n#ifndef GL_ARB_texture_view\r\n#define GL_ARB_texture_view 1\r\n\r\n#define GL_TEXTURE_VIEW_MIN_LEVEL 0x82DB\r\n#define GL_TEXTURE_VIEW_NUM_LEVELS 0x82DC\r\n#define GL_TEXTURE_VIEW_MIN_LAYER 0x82DD\r\n#define GL_TEXTURE_VIEW_NUM_LAYERS 0x82DE\r\n#define GL_TEXTURE_IMMUTABLE_LEVELS 0x82DF\r\n\r\ntypedef void (GLAPIENTRY * PFNGLTEXTUREVIEWPROC) (GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers);\r\n\r\n#define glTextureView GLEW_GET_FUN(__glewTextureView)\r\n\r\n#define GLEW_ARB_texture_view GLEW_GET_VAR(__GLEW_ARB_texture_view)\r\n\r\n#endif /* GL_ARB_texture_view */\r\n\r\n/* --------------------------- GL_ARB_timer_query -------------------------- */\r\n\r\n#ifndef GL_ARB_timer_query\r\n#define GL_ARB_timer_query 1\r\n\r\n#define GL_TIME_ELAPSED 0x88BF\r\n#define GL_TIMESTAMP 0x8E28\r\n\r\ntypedef void (GLAPIENTRY * PFNGLGETQUERYOBJECTI64VPROC) (GLuint id, GLenum pname, GLint64* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETQUERYOBJECTUI64VPROC) (GLuint id, GLenum pname, GLuint64* params);\r\ntypedef void (GLAPIENTRY * PFNGLQUERYCOUNTERPROC) (GLuint id, GLenum target);\r\n\r\n#define glGetQueryObjecti64v GLEW_GET_FUN(__glewGetQueryObjecti64v)\r\n#define glGetQueryObjectui64v GLEW_GET_FUN(__glewGetQueryObjectui64v)\r\n#define glQueryCounter GLEW_GET_FUN(__glewQueryCounter)\r\n\r\n#define GLEW_ARB_timer_query GLEW_GET_VAR(__GLEW_ARB_timer_query)\r\n\r\n#endif /* GL_ARB_timer_query */\r\n\r\n/* ----------------------- GL_ARB_transform_feedback2 ---------------------- */\r\n\r\n#ifndef GL_ARB_transform_feedback2\r\n#define GL_ARB_transform_feedback2 1\r\n\r\n#define GL_TRANSFORM_FEEDBACK 0x8E22\r\n#define GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED 0x8E23\r\n#define GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE 0x8E24\r\n#define GL_TRANSFORM_FEEDBACK_BINDING 0x8E25\r\n\r\ntypedef void (GLAPIENTRY * PFNGLBINDTRANSFORMFEEDBACKPROC) (GLenum target, GLuint id);\r\ntypedef void (GLAPIENTRY * PFNGLDELETETRANSFORMFEEDBACKSPROC) (GLsizei n, const GLuint* ids);\r\ntypedef void (GLAPIENTRY * PFNGLDRAWTRANSFORMFEEDBACKPROC) (GLenum mode, GLuint id);\r\ntypedef void (GLAPIENTRY * PFNGLGENTRANSFORMFEEDBACKSPROC) (GLsizei n, GLuint* ids);\r\ntypedef GLboolean (GLAPIENTRY * PFNGLISTRANSFORMFEEDBACKPROC) (GLuint id);\r\ntypedef void (GLAPIENTRY * PFNGLPAUSETRANSFORMFEEDBACKPROC) (void);\r\ntypedef void (GLAPIENTRY * PFNGLRESUMETRANSFORMFEEDBACKPROC) (void);\r\n\r\n#define glBindTransformFeedback GLEW_GET_FUN(__glewBindTransformFeedback)\r\n#define glDeleteTransformFeedbacks GLEW_GET_FUN(__glewDeleteTransformFeedbacks)\r\n#define glDrawTransformFeedback GLEW_GET_FUN(__glewDrawTransformFeedback)\r\n#define glGenTransformFeedbacks GLEW_GET_FUN(__glewGenTransformFeedbacks)\r\n#define glIsTransformFeedback GLEW_GET_FUN(__glewIsTransformFeedback)\r\n#define glPauseTransformFeedback GLEW_GET_FUN(__glewPauseTransformFeedback)\r\n#define glResumeTransformFeedback GLEW_GET_FUN(__glewResumeTransformFeedback)\r\n\r\n#define GLEW_ARB_transform_feedback2 GLEW_GET_VAR(__GLEW_ARB_transform_feedback2)\r\n\r\n#endif /* GL_ARB_transform_feedback2 */\r\n\r\n/* ----------------------- GL_ARB_transform_feedback3 ---------------------- */\r\n\r\n#ifndef GL_ARB_transform_feedback3\r\n#define GL_ARB_transform_feedback3 1\r\n\r\n#define GL_MAX_TRANSFORM_FEEDBACK_BUFFERS 0x8E70\r\n#define GL_MAX_VERTEX_STREAMS 0x8E71\r\n\r\ntypedef void (GLAPIENTRY * PFNGLBEGINQUERYINDEXEDPROC) (GLenum target, GLuint index, GLuint id);\r\ntypedef void (GLAPIENTRY * PFNGLDRAWTRANSFORMFEEDBACKSTREAMPROC) (GLenum mode, GLuint id, GLuint stream);\r\ntypedef void (GLAPIENTRY * PFNGLENDQUERYINDEXEDPROC) (GLenum target, GLuint index);\r\ntypedef void (GLAPIENTRY * PFNGLGETQUERYINDEXEDIVPROC) (GLenum target, GLuint index, GLenum pname, GLint* params);\r\n\r\n#define glBeginQueryIndexed GLEW_GET_FUN(__glewBeginQueryIndexed)\r\n#define glDrawTransformFeedbackStream GLEW_GET_FUN(__glewDrawTransformFeedbackStream)\r\n#define glEndQueryIndexed GLEW_GET_FUN(__glewEndQueryIndexed)\r\n#define glGetQueryIndexediv GLEW_GET_FUN(__glewGetQueryIndexediv)\r\n\r\n#define GLEW_ARB_transform_feedback3 GLEW_GET_VAR(__GLEW_ARB_transform_feedback3)\r\n\r\n#endif /* GL_ARB_transform_feedback3 */\r\n\r\n/* ------------------ GL_ARB_transform_feedback_instanced ------------------ */\r\n\r\n#ifndef GL_ARB_transform_feedback_instanced\r\n#define GL_ARB_transform_feedback_instanced 1\r\n\r\ntypedef void (GLAPIENTRY * PFNGLDRAWTRANSFORMFEEDBACKINSTANCEDPROC) (GLenum mode, GLuint id, GLsizei primcount);\r\ntypedef void (GLAPIENTRY * PFNGLDRAWTRANSFORMFEEDBACKSTREAMINSTANCEDPROC) (GLenum mode, GLuint id, GLuint stream, GLsizei primcount);\r\n\r\n#define glDrawTransformFeedbackInstanced GLEW_GET_FUN(__glewDrawTransformFeedbackInstanced)\r\n#define glDrawTransformFeedbackStreamInstanced GLEW_GET_FUN(__glewDrawTransformFeedbackStreamInstanced)\r\n\r\n#define GLEW_ARB_transform_feedback_instanced GLEW_GET_VAR(__GLEW_ARB_transform_feedback_instanced)\r\n\r\n#endif /* GL_ARB_transform_feedback_instanced */\r\n\r\n/* ---------------- GL_ARB_transform_feedback_overflow_query --------------- */\r\n\r\n#ifndef GL_ARB_transform_feedback_overflow_query\r\n#define GL_ARB_transform_feedback_overflow_query 1\r\n\r\n#define GL_TRANSFORM_FEEDBACK_OVERFLOW_ARB 0x82EC\r\n#define GL_TRANSFORM_FEEDBACK_STREAM_OVERFLOW_ARB 0x82ED\r\n\r\n#define GLEW_ARB_transform_feedback_overflow_query GLEW_GET_VAR(__GLEW_ARB_transform_feedback_overflow_query)\r\n\r\n#endif /* GL_ARB_transform_feedback_overflow_query */\r\n\r\n/* ------------------------ GL_ARB_transpose_matrix ------------------------ */\r\n\r\n#ifndef GL_ARB_transpose_matrix\r\n#define GL_ARB_transpose_matrix 1\r\n\r\n#define GL_TRANSPOSE_MODELVIEW_MATRIX_ARB 0x84E3\r\n#define GL_TRANSPOSE_PROJECTION_MATRIX_ARB 0x84E4\r\n#define GL_TRANSPOSE_TEXTURE_MATRIX_ARB 0x84E5\r\n#define GL_TRANSPOSE_COLOR_MATRIX_ARB 0x84E6\r\n\r\ntypedef void (GLAPIENTRY * PFNGLLOADTRANSPOSEMATRIXDARBPROC) (GLdouble m[16]);\r\ntypedef void (GLAPIENTRY * PFNGLLOADTRANSPOSEMATRIXFARBPROC) (GLfloat m[16]);\r\ntypedef void (GLAPIENTRY * PFNGLMULTTRANSPOSEMATRIXDARBPROC) (GLdouble m[16]);\r\ntypedef void (GLAPIENTRY * PFNGLMULTTRANSPOSEMATRIXFARBPROC) (GLfloat m[16]);\r\n\r\n#define glLoadTransposeMatrixdARB GLEW_GET_FUN(__glewLoadTransposeMatrixdARB)\r\n#define glLoadTransposeMatrixfARB GLEW_GET_FUN(__glewLoadTransposeMatrixfARB)\r\n#define glMultTransposeMatrixdARB GLEW_GET_FUN(__glewMultTransposeMatrixdARB)\r\n#define glMultTransposeMatrixfARB GLEW_GET_FUN(__glewMultTransposeMatrixfARB)\r\n\r\n#define GLEW_ARB_transpose_matrix GLEW_GET_VAR(__GLEW_ARB_transpose_matrix)\r\n\r\n#endif /* GL_ARB_transpose_matrix */\r\n\r\n/* ---------------------- GL_ARB_uniform_buffer_object --------------------- */\r\n\r\n#ifndef GL_ARB_uniform_buffer_object\r\n#define GL_ARB_uniform_buffer_object 1\r\n\r\n#define GL_UNIFORM_BUFFER 0x8A11\r\n#define GL_UNIFORM_BUFFER_BINDING 0x8A28\r\n#define GL_UNIFORM_BUFFER_START 0x8A29\r\n#define GL_UNIFORM_BUFFER_SIZE 0x8A2A\r\n#define GL_MAX_VERTEX_UNIFORM_BLOCKS 0x8A2B\r\n#define GL_MAX_GEOMETRY_UNIFORM_BLOCKS 0x8A2C\r\n#define GL_MAX_FRAGMENT_UNIFORM_BLOCKS 0x8A2D\r\n#define GL_MAX_COMBINED_UNIFORM_BLOCKS 0x8A2E\r\n#define GL_MAX_UNIFORM_BUFFER_BINDINGS 0x8A2F\r\n#define GL_MAX_UNIFORM_BLOCK_SIZE 0x8A30\r\n#define GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS 0x8A31\r\n#define GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS 0x8A32\r\n#define GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS 0x8A33\r\n#define GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT 0x8A34\r\n#define GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH 0x8A35\r\n#define GL_ACTIVE_UNIFORM_BLOCKS 0x8A36\r\n#define GL_UNIFORM_TYPE 0x8A37\r\n#define GL_UNIFORM_SIZE 0x8A38\r\n#define GL_UNIFORM_NAME_LENGTH 0x8A39\r\n#define GL_UNIFORM_BLOCK_INDEX 0x8A3A\r\n#define GL_UNIFORM_OFFSET 0x8A3B\r\n#define GL_UNIFORM_ARRAY_STRIDE 0x8A3C\r\n#define GL_UNIFORM_MATRIX_STRIDE 0x8A3D\r\n#define GL_UNIFORM_IS_ROW_MAJOR 0x8A3E\r\n#define GL_UNIFORM_BLOCK_BINDING 0x8A3F\r\n#define GL_UNIFORM_BLOCK_DATA_SIZE 0x8A40\r\n#define GL_UNIFORM_BLOCK_NAME_LENGTH 0x8A41\r\n#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS 0x8A42\r\n#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES 0x8A43\r\n#define GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER 0x8A44\r\n#define GL_UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER 0x8A45\r\n#define GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER 0x8A46\r\n#define GL_INVALID_INDEX 0xFFFFFFFF\r\n\r\ntypedef void (GLAPIENTRY * PFNGLBINDBUFFERBASEPROC) (GLenum target, GLuint index, GLuint buffer);\r\ntypedef void (GLAPIENTRY * PFNGLBINDBUFFERRANGEPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size);\r\ntypedef void (GLAPIENTRY * PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC) (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformBlockName);\r\ntypedef void (GLAPIENTRY * PFNGLGETACTIVEUNIFORMBLOCKIVPROC) (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETACTIVEUNIFORMNAMEPROC) (GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformName);\r\ntypedef void (GLAPIENTRY * PFNGLGETACTIVEUNIFORMSIVPROC) (GLuint program, GLsizei uniformCount, const GLuint* uniformIndices, GLenum pname, GLint* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETINTEGERI_VPROC) (GLenum target, GLuint index, GLint* data);\r\ntypedef GLuint (GLAPIENTRY * PFNGLGETUNIFORMBLOCKINDEXPROC) (GLuint program, const GLchar* uniformBlockName);\r\ntypedef void (GLAPIENTRY * PFNGLGETUNIFORMINDICESPROC) (GLuint program, GLsizei uniformCount, const GLchar* const * uniformNames, GLuint* uniformIndices);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORMBLOCKBINDINGPROC) (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding);\r\n\r\n#define glBindBufferBase GLEW_GET_FUN(__glewBindBufferBase)\r\n#define glBindBufferRange GLEW_GET_FUN(__glewBindBufferRange)\r\n#define glGetActiveUniformBlockName GLEW_GET_FUN(__glewGetActiveUniformBlockName)\r\n#define glGetActiveUniformBlockiv GLEW_GET_FUN(__glewGetActiveUniformBlockiv)\r\n#define glGetActiveUniformName GLEW_GET_FUN(__glewGetActiveUniformName)\r\n#define glGetActiveUniformsiv GLEW_GET_FUN(__glewGetActiveUniformsiv)\r\n#define glGetIntegeri_v GLEW_GET_FUN(__glewGetIntegeri_v)\r\n#define glGetUniformBlockIndex GLEW_GET_FUN(__glewGetUniformBlockIndex)\r\n#define glGetUniformIndices GLEW_GET_FUN(__glewGetUniformIndices)\r\n#define glUniformBlockBinding GLEW_GET_FUN(__glewUniformBlockBinding)\r\n\r\n#define GLEW_ARB_uniform_buffer_object GLEW_GET_VAR(__GLEW_ARB_uniform_buffer_object)\r\n\r\n#endif /* GL_ARB_uniform_buffer_object */\r\n\r\n/* ------------------------ GL_ARB_vertex_array_bgra ----------------------- */\r\n\r\n#ifndef GL_ARB_vertex_array_bgra\r\n#define GL_ARB_vertex_array_bgra 1\r\n\r\n#define GL_BGRA 0x80E1\r\n\r\n#define GLEW_ARB_vertex_array_bgra GLEW_GET_VAR(__GLEW_ARB_vertex_array_bgra)\r\n\r\n#endif /* GL_ARB_vertex_array_bgra */\r\n\r\n/* ----------------------- GL_ARB_vertex_array_object ---------------------- */\r\n\r\n#ifndef GL_ARB_vertex_array_object\r\n#define GL_ARB_vertex_array_object 1\r\n\r\n#define GL_VERTEX_ARRAY_BINDING 0x85B5\r\n\r\ntypedef void (GLAPIENTRY * PFNGLBINDVERTEXARRAYPROC) (GLuint array);\r\ntypedef void (GLAPIENTRY * PFNGLDELETEVERTEXARRAYSPROC) (GLsizei n, const GLuint* arrays);\r\ntypedef void (GLAPIENTRY * PFNGLGENVERTEXARRAYSPROC) (GLsizei n, GLuint* arrays);\r\ntypedef GLboolean (GLAPIENTRY * PFNGLISVERTEXARRAYPROC) (GLuint array);\r\n\r\n#define glBindVertexArray GLEW_GET_FUN(__glewBindVertexArray)\r\n#define glDeleteVertexArrays GLEW_GET_FUN(__glewDeleteVertexArrays)\r\n#define glGenVertexArrays GLEW_GET_FUN(__glewGenVertexArrays)\r\n#define glIsVertexArray GLEW_GET_FUN(__glewIsVertexArray)\r\n\r\n#define GLEW_ARB_vertex_array_object GLEW_GET_VAR(__GLEW_ARB_vertex_array_object)\r\n\r\n#endif /* GL_ARB_vertex_array_object */\r\n\r\n/* ----------------------- GL_ARB_vertex_attrib_64bit ---------------------- */\r\n\r\n#ifndef GL_ARB_vertex_attrib_64bit\r\n#define GL_ARB_vertex_attrib_64bit 1\r\n\r\ntypedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBLDVPROC) (GLuint index, GLenum pname, GLdouble* params);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL1DPROC) (GLuint index, GLdouble x);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL1DVPROC) (GLuint index, const GLdouble* v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL2DPROC) (GLuint index, GLdouble x, GLdouble y);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL2DVPROC) (GLuint index, const GLdouble* v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL3DVPROC) (GLuint index, const GLdouble* v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL4DVPROC) (GLuint index, const GLdouble* v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBLPOINTERPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const void* pointer);\r\n\r\n#define glGetVertexAttribLdv GLEW_GET_FUN(__glewGetVertexAttribLdv)\r\n#define glVertexAttribL1d GLEW_GET_FUN(__glewVertexAttribL1d)\r\n#define glVertexAttribL1dv GLEW_GET_FUN(__glewVertexAttribL1dv)\r\n#define glVertexAttribL2d GLEW_GET_FUN(__glewVertexAttribL2d)\r\n#define glVertexAttribL2dv GLEW_GET_FUN(__glewVertexAttribL2dv)\r\n#define glVertexAttribL3d GLEW_GET_FUN(__glewVertexAttribL3d)\r\n#define glVertexAttribL3dv GLEW_GET_FUN(__glewVertexAttribL3dv)\r\n#define glVertexAttribL4d GLEW_GET_FUN(__glewVertexAttribL4d)\r\n#define glVertexAttribL4dv GLEW_GET_FUN(__glewVertexAttribL4dv)\r\n#define glVertexAttribLPointer GLEW_GET_FUN(__glewVertexAttribLPointer)\r\n\r\n#define GLEW_ARB_vertex_attrib_64bit GLEW_GET_VAR(__GLEW_ARB_vertex_attrib_64bit)\r\n\r\n#endif /* GL_ARB_vertex_attrib_64bit */\r\n\r\n/* ---------------------- GL_ARB_vertex_attrib_binding --------------------- */\r\n\r\n#ifndef GL_ARB_vertex_attrib_binding\r\n#define GL_ARB_vertex_attrib_binding 1\r\n\r\n#define GL_VERTEX_ATTRIB_BINDING 0x82D4\r\n#define GL_VERTEX_ATTRIB_RELATIVE_OFFSET 0x82D5\r\n#define GL_VERTEX_BINDING_DIVISOR 0x82D6\r\n#define GL_VERTEX_BINDING_OFFSET 0x82D7\r\n#define GL_VERTEX_BINDING_STRIDE 0x82D8\r\n#define GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET 0x82D9\r\n#define GL_MAX_VERTEX_ATTRIB_BINDINGS 0x82DA\r\n#define GL_VERTEX_BINDING_BUFFER 0x8F4F\r\n\r\ntypedef void (GLAPIENTRY * PFNGLBINDVERTEXBUFFERPROC) (GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXARRAYBINDVERTEXBUFFEREXTPROC) (GLuint vaobj, GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXARRAYVERTEXATTRIBBINDINGEXTPROC) (GLuint vaobj, GLuint attribindex, GLuint bindingindex);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXARRAYVERTEXATTRIBFORMATEXTPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXARRAYVERTEXATTRIBIFORMATEXTPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXARRAYVERTEXATTRIBLFORMATEXTPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXARRAYVERTEXBINDINGDIVISOREXTPROC) (GLuint vaobj, GLuint bindingindex, GLuint divisor);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBBINDINGPROC) (GLuint attribindex, GLuint bindingindex);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBIFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBLFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXBINDINGDIVISORPROC) (GLuint bindingindex, GLuint divisor);\r\n\r\n#define glBindVertexBuffer GLEW_GET_FUN(__glewBindVertexBuffer)\r\n#define glVertexArrayBindVertexBufferEXT GLEW_GET_FUN(__glewVertexArrayBindVertexBufferEXT)\r\n#define glVertexArrayVertexAttribBindingEXT GLEW_GET_FUN(__glewVertexArrayVertexAttribBindingEXT)\r\n#define glVertexArrayVertexAttribFormatEXT GLEW_GET_FUN(__glewVertexArrayVertexAttribFormatEXT)\r\n#define glVertexArrayVertexAttribIFormatEXT GLEW_GET_FUN(__glewVertexArrayVertexAttribIFormatEXT)\r\n#define glVertexArrayVertexAttribLFormatEXT GLEW_GET_FUN(__glewVertexArrayVertexAttribLFormatEXT)\r\n#define glVertexArrayVertexBindingDivisorEXT GLEW_GET_FUN(__glewVertexArrayVertexBindingDivisorEXT)\r\n#define glVertexAttribBinding GLEW_GET_FUN(__glewVertexAttribBinding)\r\n#define glVertexAttribFormat GLEW_GET_FUN(__glewVertexAttribFormat)\r\n#define glVertexAttribIFormat GLEW_GET_FUN(__glewVertexAttribIFormat)\r\n#define glVertexAttribLFormat GLEW_GET_FUN(__glewVertexAttribLFormat)\r\n#define glVertexBindingDivisor GLEW_GET_FUN(__glewVertexBindingDivisor)\r\n\r\n#define GLEW_ARB_vertex_attrib_binding GLEW_GET_VAR(__GLEW_ARB_vertex_attrib_binding)\r\n\r\n#endif /* GL_ARB_vertex_attrib_binding */\r\n\r\n/* -------------------------- GL_ARB_vertex_blend -------------------------- */\r\n\r\n#ifndef GL_ARB_vertex_blend\r\n#define GL_ARB_vertex_blend 1\r\n\r\n#define GL_MODELVIEW0_ARB 0x1700\r\n#define GL_MODELVIEW1_ARB 0x850A\r\n#define GL_MAX_VERTEX_UNITS_ARB 0x86A4\r\n#define GL_ACTIVE_VERTEX_UNITS_ARB 0x86A5\r\n#define GL_WEIGHT_SUM_UNITY_ARB 0x86A6\r\n#define GL_VERTEX_BLEND_ARB 0x86A7\r\n#define GL_CURRENT_WEIGHT_ARB 0x86A8\r\n#define GL_WEIGHT_ARRAY_TYPE_ARB 0x86A9\r\n#define GL_WEIGHT_ARRAY_STRIDE_ARB 0x86AA\r\n#define GL_WEIGHT_ARRAY_SIZE_ARB 0x86AB\r\n#define GL_WEIGHT_ARRAY_POINTER_ARB 0x86AC\r\n#define GL_WEIGHT_ARRAY_ARB 0x86AD\r\n#define GL_MODELVIEW2_ARB 0x8722\r\n#define GL_MODELVIEW3_ARB 0x8723\r\n#define GL_MODELVIEW4_ARB 0x8724\r\n#define GL_MODELVIEW5_ARB 0x8725\r\n#define GL_MODELVIEW6_ARB 0x8726\r\n#define GL_MODELVIEW7_ARB 0x8727\r\n#define GL_MODELVIEW8_ARB 0x8728\r\n#define GL_MODELVIEW9_ARB 0x8729\r\n#define GL_MODELVIEW10_ARB 0x872A\r\n#define GL_MODELVIEW11_ARB 0x872B\r\n#define GL_MODELVIEW12_ARB 0x872C\r\n#define GL_MODELVIEW13_ARB 0x872D\r\n#define GL_MODELVIEW14_ARB 0x872E\r\n#define GL_MODELVIEW15_ARB 0x872F\r\n#define GL_MODELVIEW16_ARB 0x8730\r\n#define GL_MODELVIEW17_ARB 0x8731\r\n#define GL_MODELVIEW18_ARB 0x8732\r\n#define GL_MODELVIEW19_ARB 0x8733\r\n#define GL_MODELVIEW20_ARB 0x8734\r\n#define GL_MODELVIEW21_ARB 0x8735\r\n#define GL_MODELVIEW22_ARB 0x8736\r\n#define GL_MODELVIEW23_ARB 0x8737\r\n#define GL_MODELVIEW24_ARB 0x8738\r\n#define GL_MODELVIEW25_ARB 0x8739\r\n#define GL_MODELVIEW26_ARB 0x873A\r\n#define GL_MODELVIEW27_ARB 0x873B\r\n#define GL_MODELVIEW28_ARB 0x873C\r\n#define GL_MODELVIEW29_ARB 0x873D\r\n#define GL_MODELVIEW30_ARB 0x873E\r\n#define GL_MODELVIEW31_ARB 0x873F\r\n\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXBLENDARBPROC) (GLint count);\r\ntypedef void (GLAPIENTRY * PFNGLWEIGHTPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, void *pointer);\r\ntypedef void (GLAPIENTRY * PFNGLWEIGHTBVARBPROC) (GLint size, GLbyte *weights);\r\ntypedef void (GLAPIENTRY * PFNGLWEIGHTDVARBPROC) (GLint size, GLdouble *weights);\r\ntypedef void (GLAPIENTRY * PFNGLWEIGHTFVARBPROC) (GLint size, GLfloat *weights);\r\ntypedef void (GLAPIENTRY * PFNGLWEIGHTIVARBPROC) (GLint size, GLint *weights);\r\ntypedef void (GLAPIENTRY * PFNGLWEIGHTSVARBPROC) (GLint size, GLshort *weights);\r\ntypedef void (GLAPIENTRY * PFNGLWEIGHTUBVARBPROC) (GLint size, GLubyte *weights);\r\ntypedef void (GLAPIENTRY * PFNGLWEIGHTUIVARBPROC) (GLint size, GLuint *weights);\r\ntypedef void (GLAPIENTRY * PFNGLWEIGHTUSVARBPROC) (GLint size, GLushort *weights);\r\n\r\n#define glVertexBlendARB GLEW_GET_FUN(__glewVertexBlendARB)\r\n#define glWeightPointerARB GLEW_GET_FUN(__glewWeightPointerARB)\r\n#define glWeightbvARB GLEW_GET_FUN(__glewWeightbvARB)\r\n#define glWeightdvARB GLEW_GET_FUN(__glewWeightdvARB)\r\n#define glWeightfvARB GLEW_GET_FUN(__glewWeightfvARB)\r\n#define glWeightivARB GLEW_GET_FUN(__glewWeightivARB)\r\n#define glWeightsvARB GLEW_GET_FUN(__glewWeightsvARB)\r\n#define glWeightubvARB GLEW_GET_FUN(__glewWeightubvARB)\r\n#define glWeightuivARB GLEW_GET_FUN(__glewWeightuivARB)\r\n#define glWeightusvARB GLEW_GET_FUN(__glewWeightusvARB)\r\n\r\n#define GLEW_ARB_vertex_blend GLEW_GET_VAR(__GLEW_ARB_vertex_blend)\r\n\r\n#endif /* GL_ARB_vertex_blend */\r\n\r\n/* ---------------------- GL_ARB_vertex_buffer_object ---------------------- */\r\n\r\n#ifndef GL_ARB_vertex_buffer_object\r\n#define GL_ARB_vertex_buffer_object 1\r\n\r\n#define GL_BUFFER_SIZE_ARB 0x8764\r\n#define GL_BUFFER_USAGE_ARB 0x8765\r\n#define GL_ARRAY_BUFFER_ARB 0x8892\r\n#define GL_ELEMENT_ARRAY_BUFFER_ARB 0x8893\r\n#define GL_ARRAY_BUFFER_BINDING_ARB 0x8894\r\n#define GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB 0x8895\r\n#define GL_VERTEX_ARRAY_BUFFER_BINDING_ARB 0x8896\r\n#define GL_NORMAL_ARRAY_BUFFER_BINDING_ARB 0x8897\r\n#define GL_COLOR_ARRAY_BUFFER_BINDING_ARB 0x8898\r\n#define GL_INDEX_ARRAY_BUFFER_BINDING_ARB 0x8899\r\n#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB 0x889A\r\n#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB 0x889B\r\n#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB 0x889C\r\n#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB 0x889D\r\n#define GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB 0x889E\r\n#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB 0x889F\r\n#define GL_READ_ONLY_ARB 0x88B8\r\n#define GL_WRITE_ONLY_ARB 0x88B9\r\n#define GL_READ_WRITE_ARB 0x88BA\r\n#define GL_BUFFER_ACCESS_ARB 0x88BB\r\n#define GL_BUFFER_MAPPED_ARB 0x88BC\r\n#define GL_BUFFER_MAP_POINTER_ARB 0x88BD\r\n#define GL_STREAM_DRAW_ARB 0x88E0\r\n#define GL_STREAM_READ_ARB 0x88E1\r\n#define GL_STREAM_COPY_ARB 0x88E2\r\n#define GL_STATIC_DRAW_ARB 0x88E4\r\n#define GL_STATIC_READ_ARB 0x88E5\r\n#define GL_STATIC_COPY_ARB 0x88E6\r\n#define GL_DYNAMIC_DRAW_ARB 0x88E8\r\n#define GL_DYNAMIC_READ_ARB 0x88E9\r\n#define GL_DYNAMIC_COPY_ARB 0x88EA\r\n\r\ntypedef ptrdiff_t GLintptrARB;\r\ntypedef ptrdiff_t GLsizeiptrARB;\r\n\r\ntypedef void (GLAPIENTRY * PFNGLBINDBUFFERARBPROC) (GLenum target, GLuint buffer);\r\ntypedef void (GLAPIENTRY * PFNGLBUFFERDATAARBPROC) (GLenum target, GLsizeiptrARB size, const void *data, GLenum usage);\r\ntypedef void (GLAPIENTRY * PFNGLBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const void *data);\r\ntypedef void (GLAPIENTRY * PFNGLDELETEBUFFERSARBPROC) (GLsizei n, const GLuint* buffers);\r\ntypedef void (GLAPIENTRY * PFNGLGENBUFFERSARBPROC) (GLsizei n, GLuint* buffers);\r\ntypedef void (GLAPIENTRY * PFNGLGETBUFFERPARAMETERIVARBPROC) (GLenum target, GLenum pname, GLint* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETBUFFERPOINTERVARBPROC) (GLenum target, GLenum pname, void** params);\r\ntypedef void (GLAPIENTRY * PFNGLGETBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, void *data);\r\ntypedef GLboolean (GLAPIENTRY * PFNGLISBUFFERARBPROC) (GLuint buffer);\r\ntypedef void * (GLAPIENTRY * PFNGLMAPBUFFERARBPROC) (GLenum target, GLenum access);\r\ntypedef GLboolean (GLAPIENTRY * PFNGLUNMAPBUFFERARBPROC) (GLenum target);\r\n\r\n#define glBindBufferARB GLEW_GET_FUN(__glewBindBufferARB)\r\n#define glBufferDataARB GLEW_GET_FUN(__glewBufferDataARB)\r\n#define glBufferSubDataARB GLEW_GET_FUN(__glewBufferSubDataARB)\r\n#define glDeleteBuffersARB GLEW_GET_FUN(__glewDeleteBuffersARB)\r\n#define glGenBuffersARB GLEW_GET_FUN(__glewGenBuffersARB)\r\n#define glGetBufferParameterivARB GLEW_GET_FUN(__glewGetBufferParameterivARB)\r\n#define glGetBufferPointervARB GLEW_GET_FUN(__glewGetBufferPointervARB)\r\n#define glGetBufferSubDataARB GLEW_GET_FUN(__glewGetBufferSubDataARB)\r\n#define glIsBufferARB GLEW_GET_FUN(__glewIsBufferARB)\r\n#define glMapBufferARB GLEW_GET_FUN(__glewMapBufferARB)\r\n#define glUnmapBufferARB GLEW_GET_FUN(__glewUnmapBufferARB)\r\n\r\n#define GLEW_ARB_vertex_buffer_object GLEW_GET_VAR(__GLEW_ARB_vertex_buffer_object)\r\n\r\n#endif /* GL_ARB_vertex_buffer_object */\r\n\r\n/* ------------------------- GL_ARB_vertex_program ------------------------- */\r\n\r\n#ifndef GL_ARB_vertex_program\r\n#define GL_ARB_vertex_program 1\r\n\r\n#define GL_COLOR_SUM_ARB 0x8458\r\n#define GL_VERTEX_PROGRAM_ARB 0x8620\r\n#define GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB 0x8622\r\n#define GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB 0x8623\r\n#define GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB 0x8624\r\n#define GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB 0x8625\r\n#define GL_CURRENT_VERTEX_ATTRIB_ARB 0x8626\r\n#define GL_PROGRAM_LENGTH_ARB 0x8627\r\n#define GL_PROGRAM_STRING_ARB 0x8628\r\n#define GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB 0x862E\r\n#define GL_MAX_PROGRAM_MATRICES_ARB 0x862F\r\n#define GL_CURRENT_MATRIX_STACK_DEPTH_ARB 0x8640\r\n#define GL_CURRENT_MATRIX_ARB 0x8641\r\n#define GL_VERTEX_PROGRAM_POINT_SIZE_ARB 0x8642\r\n#define GL_VERTEX_PROGRAM_TWO_SIDE_ARB 0x8643\r\n#define GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB 0x8645\r\n#define GL_PROGRAM_ERROR_POSITION_ARB 0x864B\r\n#define GL_PROGRAM_BINDING_ARB 0x8677\r\n#define GL_MAX_VERTEX_ATTRIBS_ARB 0x8869\r\n#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB 0x886A\r\n#define GL_PROGRAM_ERROR_STRING_ARB 0x8874\r\n#define GL_PROGRAM_FORMAT_ASCII_ARB 0x8875\r\n#define GL_PROGRAM_FORMAT_ARB 0x8876\r\n#define GL_PROGRAM_INSTRUCTIONS_ARB 0x88A0\r\n#define GL_MAX_PROGRAM_INSTRUCTIONS_ARB 0x88A1\r\n#define GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A2\r\n#define GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A3\r\n#define GL_PROGRAM_TEMPORARIES_ARB 0x88A4\r\n#define GL_MAX_PROGRAM_TEMPORARIES_ARB 0x88A5\r\n#define GL_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A6\r\n#define GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A7\r\n#define GL_PROGRAM_PARAMETERS_ARB 0x88A8\r\n#define GL_MAX_PROGRAM_PARAMETERS_ARB 0x88A9\r\n#define GL_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AA\r\n#define GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AB\r\n#define GL_PROGRAM_ATTRIBS_ARB 0x88AC\r\n#define GL_MAX_PROGRAM_ATTRIBS_ARB 0x88AD\r\n#define GL_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AE\r\n#define GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AF\r\n#define GL_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B0\r\n#define GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B1\r\n#define GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B2\r\n#define GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B3\r\n#define GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB 0x88B4\r\n#define GL_MAX_PROGRAM_ENV_PARAMETERS_ARB 0x88B5\r\n#define GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB 0x88B6\r\n#define GL_TRANSPOSE_CURRENT_MATRIX_ARB 0x88B7\r\n#define GL_MATRIX0_ARB 0x88C0\r\n#define GL_MATRIX1_ARB 0x88C1\r\n#define GL_MATRIX2_ARB 0x88C2\r\n#define GL_MATRIX3_ARB 0x88C3\r\n#define GL_MATRIX4_ARB 0x88C4\r\n#define GL_MATRIX5_ARB 0x88C5\r\n#define GL_MATRIX6_ARB 0x88C6\r\n#define GL_MATRIX7_ARB 0x88C7\r\n#define GL_MATRIX8_ARB 0x88C8\r\n#define GL_MATRIX9_ARB 0x88C9\r\n#define GL_MATRIX10_ARB 0x88CA\r\n#define GL_MATRIX11_ARB 0x88CB\r\n#define GL_MATRIX12_ARB 0x88CC\r\n#define GL_MATRIX13_ARB 0x88CD\r\n#define GL_MATRIX14_ARB 0x88CE\r\n#define GL_MATRIX15_ARB 0x88CF\r\n#define GL_MATRIX16_ARB 0x88D0\r\n#define GL_MATRIX17_ARB 0x88D1\r\n#define GL_MATRIX18_ARB 0x88D2\r\n#define GL_MATRIX19_ARB 0x88D3\r\n#define GL_MATRIX20_ARB 0x88D4\r\n#define GL_MATRIX21_ARB 0x88D5\r\n#define GL_MATRIX22_ARB 0x88D6\r\n#define GL_MATRIX23_ARB 0x88D7\r\n#define GL_MATRIX24_ARB 0x88D8\r\n#define GL_MATRIX25_ARB 0x88D9\r\n#define GL_MATRIX26_ARB 0x88DA\r\n#define GL_MATRIX27_ARB 0x88DB\r\n#define GL_MATRIX28_ARB 0x88DC\r\n#define GL_MATRIX29_ARB 0x88DD\r\n#define GL_MATRIX30_ARB 0x88DE\r\n#define GL_MATRIX31_ARB 0x88DF\r\n\r\ntypedef void (GLAPIENTRY * PFNGLBINDPROGRAMARBPROC) (GLenum target, GLuint program);\r\ntypedef void (GLAPIENTRY * PFNGLDELETEPROGRAMSARBPROC) (GLsizei n, const GLuint* programs);\r\ntypedef void (GLAPIENTRY * PFNGLDISABLEVERTEXATTRIBARRAYARBPROC) (GLuint index);\r\ntypedef void (GLAPIENTRY * PFNGLENABLEVERTEXATTRIBARRAYARBPROC) (GLuint index);\r\ntypedef void (GLAPIENTRY * PFNGLGENPROGRAMSARBPROC) (GLsizei n, GLuint* programs);\r\ntypedef void (GLAPIENTRY * PFNGLGETPROGRAMENVPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETPROGRAMENVPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETPROGRAMSTRINGARBPROC) (GLenum target, GLenum pname, void *string);\r\ntypedef void (GLAPIENTRY * PFNGLGETPROGRAMIVARBPROC) (GLenum target, GLenum pname, GLint* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBPOINTERVARBPROC) (GLuint index, GLenum pname, void** pointer);\r\ntypedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBDVARBPROC) (GLuint index, GLenum pname, GLdouble* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBFVARBPROC) (GLuint index, GLenum pname, GLfloat* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBIVARBPROC) (GLuint index, GLenum pname, GLint* params);\r\ntypedef GLboolean (GLAPIENTRY * PFNGLISPROGRAMARBPROC) (GLuint program);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble* params);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat* params);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble* params);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat* params);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMSTRINGARBPROC) (GLenum target, GLenum format, GLsizei len, const void *string);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1DARBPROC) (GLuint index, GLdouble x);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1DVARBPROC) (GLuint index, const GLdouble* v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1FARBPROC) (GLuint index, GLfloat x);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1FVARBPROC) (GLuint index, const GLfloat* v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1SARBPROC) (GLuint index, GLshort x);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1SVARBPROC) (GLuint index, const GLshort* v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2DARBPROC) (GLuint index, GLdouble x, GLdouble y);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2DVARBPROC) (GLuint index, const GLdouble* v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2FARBPROC) (GLuint index, GLfloat x, GLfloat y);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2FVARBPROC) (GLuint index, const GLfloat* v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2SARBPROC) (GLuint index, GLshort x, GLshort y);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2SVARBPROC) (GLuint index, const GLshort* v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3DVARBPROC) (GLuint index, const GLdouble* v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3FVARBPROC) (GLuint index, const GLfloat* v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3SVARBPROC) (GLuint index, const GLshort* v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NBVARBPROC) (GLuint index, const GLbyte* v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NIVARBPROC) (GLuint index, const GLint* v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NSVARBPROC) (GLuint index, const GLshort* v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NUBARBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NUBVARBPROC) (GLuint index, const GLubyte* v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NUIVARBPROC) (GLuint index, const GLuint* v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NUSVARBPROC) (GLuint index, const GLushort* v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4BVARBPROC) (GLuint index, const GLbyte* v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4DVARBPROC) (GLuint index, const GLdouble* v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4FVARBPROC) (GLuint index, const GLfloat* v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4IVARBPROC) (GLuint index, const GLint* v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4SVARBPROC) (GLuint index, const GLshort* v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4UBVARBPROC) (GLuint index, const GLubyte* v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4UIVARBPROC) (GLuint index, const GLuint* v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4USVARBPROC) (GLuint index, const GLushort* v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBPOINTERARBPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer);\r\n\r\n#define glBindProgramARB GLEW_GET_FUN(__glewBindProgramARB)\r\n#define glDeleteProgramsARB GLEW_GET_FUN(__glewDeleteProgramsARB)\r\n#define glDisableVertexAttribArrayARB GLEW_GET_FUN(__glewDisableVertexAttribArrayARB)\r\n#define glEnableVertexAttribArrayARB GLEW_GET_FUN(__glewEnableVertexAttribArrayARB)\r\n#define glGenProgramsARB GLEW_GET_FUN(__glewGenProgramsARB)\r\n#define glGetProgramEnvParameterdvARB GLEW_GET_FUN(__glewGetProgramEnvParameterdvARB)\r\n#define glGetProgramEnvParameterfvARB GLEW_GET_FUN(__glewGetProgramEnvParameterfvARB)\r\n#define glGetProgramLocalParameterdvARB GLEW_GET_FUN(__glewGetProgramLocalParameterdvARB)\r\n#define glGetProgramLocalParameterfvARB GLEW_GET_FUN(__glewGetProgramLocalParameterfvARB)\r\n#define glGetProgramStringARB GLEW_GET_FUN(__glewGetProgramStringARB)\r\n#define glGetProgramivARB GLEW_GET_FUN(__glewGetProgramivARB)\r\n#define glGetVertexAttribPointervARB GLEW_GET_FUN(__glewGetVertexAttribPointervARB)\r\n#define glGetVertexAttribdvARB GLEW_GET_FUN(__glewGetVertexAttribdvARB)\r\n#define glGetVertexAttribfvARB GLEW_GET_FUN(__glewGetVertexAttribfvARB)\r\n#define glGetVertexAttribivARB GLEW_GET_FUN(__glewGetVertexAttribivARB)\r\n#define glIsProgramARB GLEW_GET_FUN(__glewIsProgramARB)\r\n#define glProgramEnvParameter4dARB GLEW_GET_FUN(__glewProgramEnvParameter4dARB)\r\n#define glProgramEnvParameter4dvARB GLEW_GET_FUN(__glewProgramEnvParameter4dvARB)\r\n#define glProgramEnvParameter4fARB GLEW_GET_FUN(__glewProgramEnvParameter4fARB)\r\n#define glProgramEnvParameter4fvARB GLEW_GET_FUN(__glewProgramEnvParameter4fvARB)\r\n#define glProgramLocalParameter4dARB GLEW_GET_FUN(__glewProgramLocalParameter4dARB)\r\n#define glProgramLocalParameter4dvARB GLEW_GET_FUN(__glewProgramLocalParameter4dvARB)\r\n#define glProgramLocalParameter4fARB GLEW_GET_FUN(__glewProgramLocalParameter4fARB)\r\n#define glProgramLocalParameter4fvARB GLEW_GET_FUN(__glewProgramLocalParameter4fvARB)\r\n#define glProgramStringARB GLEW_GET_FUN(__glewProgramStringARB)\r\n#define glVertexAttrib1dARB GLEW_GET_FUN(__glewVertexAttrib1dARB)\r\n#define glVertexAttrib1dvARB GLEW_GET_FUN(__glewVertexAttrib1dvARB)\r\n#define glVertexAttrib1fARB GLEW_GET_FUN(__glewVertexAttrib1fARB)\r\n#define glVertexAttrib1fvARB GLEW_GET_FUN(__glewVertexAttrib1fvARB)\r\n#define glVertexAttrib1sARB GLEW_GET_FUN(__glewVertexAttrib1sARB)\r\n#define glVertexAttrib1svARB GLEW_GET_FUN(__glewVertexAttrib1svARB)\r\n#define glVertexAttrib2dARB GLEW_GET_FUN(__glewVertexAttrib2dARB)\r\n#define glVertexAttrib2dvARB GLEW_GET_FUN(__glewVertexAttrib2dvARB)\r\n#define glVertexAttrib2fARB GLEW_GET_FUN(__glewVertexAttrib2fARB)\r\n#define glVertexAttrib2fvARB GLEW_GET_FUN(__glewVertexAttrib2fvARB)\r\n#define glVertexAttrib2sARB GLEW_GET_FUN(__glewVertexAttrib2sARB)\r\n#define glVertexAttrib2svARB GLEW_GET_FUN(__glewVertexAttrib2svARB)\r\n#define glVertexAttrib3dARB GLEW_GET_FUN(__glewVertexAttrib3dARB)\r\n#define glVertexAttrib3dvARB GLEW_GET_FUN(__glewVertexAttrib3dvARB)\r\n#define glVertexAttrib3fARB GLEW_GET_FUN(__glewVertexAttrib3fARB)\r\n#define glVertexAttrib3fvARB GLEW_GET_FUN(__glewVertexAttrib3fvARB)\r\n#define glVertexAttrib3sARB GLEW_GET_FUN(__glewVertexAttrib3sARB)\r\n#define glVertexAttrib3svARB GLEW_GET_FUN(__glewVertexAttrib3svARB)\r\n#define glVertexAttrib4NbvARB GLEW_GET_FUN(__glewVertexAttrib4NbvARB)\r\n#define glVertexAttrib4NivARB GLEW_GET_FUN(__glewVertexAttrib4NivARB)\r\n#define glVertexAttrib4NsvARB GLEW_GET_FUN(__glewVertexAttrib4NsvARB)\r\n#define glVertexAttrib4NubARB GLEW_GET_FUN(__glewVertexAttrib4NubARB)\r\n#define glVertexAttrib4NubvARB GLEW_GET_FUN(__glewVertexAttrib4NubvARB)\r\n#define glVertexAttrib4NuivARB GLEW_GET_FUN(__glewVertexAttrib4NuivARB)\r\n#define glVertexAttrib4NusvARB GLEW_GET_FUN(__glewVertexAttrib4NusvARB)\r\n#define glVertexAttrib4bvARB GLEW_GET_FUN(__glewVertexAttrib4bvARB)\r\n#define glVertexAttrib4dARB GLEW_GET_FUN(__glewVertexAttrib4dARB)\r\n#define glVertexAttrib4dvARB GLEW_GET_FUN(__glewVertexAttrib4dvARB)\r\n#define glVertexAttrib4fARB GLEW_GET_FUN(__glewVertexAttrib4fARB)\r\n#define glVertexAttrib4fvARB GLEW_GET_FUN(__glewVertexAttrib4fvARB)\r\n#define glVertexAttrib4ivARB GLEW_GET_FUN(__glewVertexAttrib4ivARB)\r\n#define glVertexAttrib4sARB GLEW_GET_FUN(__glewVertexAttrib4sARB)\r\n#define glVertexAttrib4svARB GLEW_GET_FUN(__glewVertexAttrib4svARB)\r\n#define glVertexAttrib4ubvARB GLEW_GET_FUN(__glewVertexAttrib4ubvARB)\r\n#define glVertexAttrib4uivARB GLEW_GET_FUN(__glewVertexAttrib4uivARB)\r\n#define glVertexAttrib4usvARB GLEW_GET_FUN(__glewVertexAttrib4usvARB)\r\n#define glVertexAttribPointerARB GLEW_GET_FUN(__glewVertexAttribPointerARB)\r\n\r\n#define GLEW_ARB_vertex_program GLEW_GET_VAR(__GLEW_ARB_vertex_program)\r\n\r\n#endif /* GL_ARB_vertex_program */\r\n\r\n/* -------------------------- GL_ARB_vertex_shader ------------------------- */\r\n\r\n#ifndef GL_ARB_vertex_shader\r\n#define GL_ARB_vertex_shader 1\r\n\r\n#define GL_VERTEX_SHADER_ARB 0x8B31\r\n#define GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB 0x8B4A\r\n#define GL_MAX_VARYING_FLOATS_ARB 0x8B4B\r\n#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB 0x8B4C\r\n#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB 0x8B4D\r\n#define GL_OBJECT_ACTIVE_ATTRIBUTES_ARB 0x8B89\r\n#define GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB 0x8B8A\r\n\r\ntypedef void (GLAPIENTRY * PFNGLBINDATTRIBLOCATIONARBPROC) (GLhandleARB programObj, GLuint index, const GLcharARB* name);\r\ntypedef void (GLAPIENTRY * PFNGLGETACTIVEATTRIBARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei* length, GLint *size, GLenum *type, GLcharARB *name);\r\ntypedef GLint (GLAPIENTRY * PFNGLGETATTRIBLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB* name);\r\n\r\n#define glBindAttribLocationARB GLEW_GET_FUN(__glewBindAttribLocationARB)\r\n#define glGetActiveAttribARB GLEW_GET_FUN(__glewGetActiveAttribARB)\r\n#define glGetAttribLocationARB GLEW_GET_FUN(__glewGetAttribLocationARB)\r\n\r\n#define GLEW_ARB_vertex_shader GLEW_GET_VAR(__GLEW_ARB_vertex_shader)\r\n\r\n#endif /* GL_ARB_vertex_shader */\r\n\r\n/* ------------------- GL_ARB_vertex_type_10f_11f_11f_rev ------------------ */\r\n\r\n#ifndef GL_ARB_vertex_type_10f_11f_11f_rev\r\n#define GL_ARB_vertex_type_10f_11f_11f_rev 1\r\n\r\n#define GL_UNSIGNED_INT_10F_11F_11F_REV 0x8C3B\r\n\r\n#define GLEW_ARB_vertex_type_10f_11f_11f_rev GLEW_GET_VAR(__GLEW_ARB_vertex_type_10f_11f_11f_rev)\r\n\r\n#endif /* GL_ARB_vertex_type_10f_11f_11f_rev */\r\n\r\n/* ------------------- GL_ARB_vertex_type_2_10_10_10_rev ------------------- */\r\n\r\n#ifndef GL_ARB_vertex_type_2_10_10_10_rev\r\n#define GL_ARB_vertex_type_2_10_10_10_rev 1\r\n\r\n#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368\r\n#define GL_INT_2_10_10_10_REV 0x8D9F\r\n\r\ntypedef void (GLAPIENTRY * PFNGLCOLORP3UIPROC) (GLenum type, GLuint color);\r\ntypedef void (GLAPIENTRY * PFNGLCOLORP3UIVPROC) (GLenum type, const GLuint* color);\r\ntypedef void (GLAPIENTRY * PFNGLCOLORP4UIPROC) (GLenum type, GLuint color);\r\ntypedef void (GLAPIENTRY * PFNGLCOLORP4UIVPROC) (GLenum type, const GLuint* color);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORDP1UIPROC) (GLenum texture, GLenum type, GLuint coords);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORDP1UIVPROC) (GLenum texture, GLenum type, const GLuint* coords);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORDP2UIPROC) (GLenum texture, GLenum type, GLuint coords);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORDP2UIVPROC) (GLenum texture, GLenum type, const GLuint* coords);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORDP3UIPROC) (GLenum texture, GLenum type, GLuint coords);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORDP3UIVPROC) (GLenum texture, GLenum type, const GLuint* coords);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORDP4UIPROC) (GLenum texture, GLenum type, GLuint coords);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORDP4UIVPROC) (GLenum texture, GLenum type, const GLuint* coords);\r\ntypedef void (GLAPIENTRY * PFNGLNORMALP3UIPROC) (GLenum type, GLuint coords);\r\ntypedef void (GLAPIENTRY * PFNGLNORMALP3UIVPROC) (GLenum type, const GLuint* coords);\r\ntypedef void (GLAPIENTRY * PFNGLSECONDARYCOLORP3UIPROC) (GLenum type, GLuint color);\r\ntypedef void (GLAPIENTRY * PFNGLSECONDARYCOLORP3UIVPROC) (GLenum type, const GLuint* color);\r\ntypedef void (GLAPIENTRY * PFNGLTEXCOORDP1UIPROC) (GLenum type, GLuint coords);\r\ntypedef void (GLAPIENTRY * PFNGLTEXCOORDP1UIVPROC) (GLenum type, const GLuint* coords);\r\ntypedef void (GLAPIENTRY * PFNGLTEXCOORDP2UIPROC) (GLenum type, GLuint coords);\r\ntypedef void (GLAPIENTRY * PFNGLTEXCOORDP2UIVPROC) (GLenum type, const GLuint* coords);\r\ntypedef void (GLAPIENTRY * PFNGLTEXCOORDP3UIPROC) (GLenum type, GLuint coords);\r\ntypedef void (GLAPIENTRY * PFNGLTEXCOORDP3UIVPROC) (GLenum type, const GLuint* coords);\r\ntypedef void (GLAPIENTRY * PFNGLTEXCOORDP4UIPROC) (GLenum type, GLuint coords);\r\ntypedef void (GLAPIENTRY * PFNGLTEXCOORDP4UIVPROC) (GLenum type, const GLuint* coords);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBP1UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBP1UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint* value);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBP2UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBP2UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint* value);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBP3UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBP3UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint* value);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBP4UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBP4UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint* value);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXP2UIPROC) (GLenum type, GLuint value);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXP2UIVPROC) (GLenum type, const GLuint* value);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXP3UIPROC) (GLenum type, GLuint value);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXP3UIVPROC) (GLenum type, const GLuint* value);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXP4UIPROC) (GLenum type, GLuint value);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXP4UIVPROC) (GLenum type, const GLuint* value);\r\n\r\n#define glColorP3ui GLEW_GET_FUN(__glewColorP3ui)\r\n#define glColorP3uiv GLEW_GET_FUN(__glewColorP3uiv)\r\n#define glColorP4ui GLEW_GET_FUN(__glewColorP4ui)\r\n#define glColorP4uiv GLEW_GET_FUN(__glewColorP4uiv)\r\n#define glMultiTexCoordP1ui GLEW_GET_FUN(__glewMultiTexCoordP1ui)\r\n#define glMultiTexCoordP1uiv GLEW_GET_FUN(__glewMultiTexCoordP1uiv)\r\n#define glMultiTexCoordP2ui GLEW_GET_FUN(__glewMultiTexCoordP2ui)\r\n#define glMultiTexCoordP2uiv GLEW_GET_FUN(__glewMultiTexCoordP2uiv)\r\n#define glMultiTexCoordP3ui GLEW_GET_FUN(__glewMultiTexCoordP3ui)\r\n#define glMultiTexCoordP3uiv GLEW_GET_FUN(__glewMultiTexCoordP3uiv)\r\n#define glMultiTexCoordP4ui GLEW_GET_FUN(__glewMultiTexCoordP4ui)\r\n#define glMultiTexCoordP4uiv GLEW_GET_FUN(__glewMultiTexCoordP4uiv)\r\n#define glNormalP3ui GLEW_GET_FUN(__glewNormalP3ui)\r\n#define glNormalP3uiv GLEW_GET_FUN(__glewNormalP3uiv)\r\n#define glSecondaryColorP3ui GLEW_GET_FUN(__glewSecondaryColorP3ui)\r\n#define glSecondaryColorP3uiv GLEW_GET_FUN(__glewSecondaryColorP3uiv)\r\n#define glTexCoordP1ui GLEW_GET_FUN(__glewTexCoordP1ui)\r\n#define glTexCoordP1uiv GLEW_GET_FUN(__glewTexCoordP1uiv)\r\n#define glTexCoordP2ui GLEW_GET_FUN(__glewTexCoordP2ui)\r\n#define glTexCoordP2uiv GLEW_GET_FUN(__glewTexCoordP2uiv)\r\n#define glTexCoordP3ui GLEW_GET_FUN(__glewTexCoordP3ui)\r\n#define glTexCoordP3uiv GLEW_GET_FUN(__glewTexCoordP3uiv)\r\n#define glTexCoordP4ui GLEW_GET_FUN(__glewTexCoordP4ui)\r\n#define glTexCoordP4uiv GLEW_GET_FUN(__glewTexCoordP4uiv)\r\n#define glVertexAttribP1ui GLEW_GET_FUN(__glewVertexAttribP1ui)\r\n#define glVertexAttribP1uiv GLEW_GET_FUN(__glewVertexAttribP1uiv)\r\n#define glVertexAttribP2ui GLEW_GET_FUN(__glewVertexAttribP2ui)\r\n#define glVertexAttribP2uiv GLEW_GET_FUN(__glewVertexAttribP2uiv)\r\n#define glVertexAttribP3ui GLEW_GET_FUN(__glewVertexAttribP3ui)\r\n#define glVertexAttribP3uiv GLEW_GET_FUN(__glewVertexAttribP3uiv)\r\n#define glVertexAttribP4ui GLEW_GET_FUN(__glewVertexAttribP4ui)\r\n#define glVertexAttribP4uiv GLEW_GET_FUN(__glewVertexAttribP4uiv)\r\n#define glVertexP2ui GLEW_GET_FUN(__glewVertexP2ui)\r\n#define glVertexP2uiv GLEW_GET_FUN(__glewVertexP2uiv)\r\n#define glVertexP3ui GLEW_GET_FUN(__glewVertexP3ui)\r\n#define glVertexP3uiv GLEW_GET_FUN(__glewVertexP3uiv)\r\n#define glVertexP4ui GLEW_GET_FUN(__glewVertexP4ui)\r\n#define glVertexP4uiv GLEW_GET_FUN(__glewVertexP4uiv)\r\n\r\n#define GLEW_ARB_vertex_type_2_10_10_10_rev GLEW_GET_VAR(__GLEW_ARB_vertex_type_2_10_10_10_rev)\r\n\r\n#endif /* GL_ARB_vertex_type_2_10_10_10_rev */\r\n\r\n/* ------------------------- GL_ARB_viewport_array ------------------------- */\r\n\r\n#ifndef GL_ARB_viewport_array\r\n#define GL_ARB_viewport_array 1\r\n\r\n#define GL_DEPTH_RANGE 0x0B70\r\n#define GL_VIEWPORT 0x0BA2\r\n#define GL_SCISSOR_BOX 0x0C10\r\n#define GL_SCISSOR_TEST 0x0C11\r\n#define GL_MAX_VIEWPORTS 0x825B\r\n#define GL_VIEWPORT_SUBPIXEL_BITS 0x825C\r\n#define GL_VIEWPORT_BOUNDS_RANGE 0x825D\r\n#define GL_LAYER_PROVOKING_VERTEX 0x825E\r\n#define GL_VIEWPORT_INDEX_PROVOKING_VERTEX 0x825F\r\n#define GL_UNDEFINED_VERTEX 0x8260\r\n#define GL_FIRST_VERTEX_CONVENTION 0x8E4D\r\n#define GL_LAST_VERTEX_CONVENTION 0x8E4E\r\n#define GL_PROVOKING_VERTEX 0x8E4F\r\n\r\ntypedef void (GLAPIENTRY * PFNGLDEPTHRANGEARRAYVPROC) (GLuint first, GLsizei count, const GLclampd * v);\r\ntypedef void (GLAPIENTRY * PFNGLDEPTHRANGEINDEXEDPROC) (GLuint index, GLclampd n, GLclampd f);\r\ntypedef void (GLAPIENTRY * PFNGLGETDOUBLEI_VPROC) (GLenum target, GLuint index, GLdouble* data);\r\ntypedef void (GLAPIENTRY * PFNGLGETFLOATI_VPROC) (GLenum target, GLuint index, GLfloat* data);\r\ntypedef void (GLAPIENTRY * PFNGLSCISSORARRAYVPROC) (GLuint first, GLsizei count, const GLint * v);\r\ntypedef void (GLAPIENTRY * PFNGLSCISSORINDEXEDPROC) (GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height);\r\ntypedef void (GLAPIENTRY * PFNGLSCISSORINDEXEDVPROC) (GLuint index, const GLint * v);\r\ntypedef void (GLAPIENTRY * PFNGLVIEWPORTARRAYVPROC) (GLuint first, GLsizei count, const GLfloat * v);\r\ntypedef void (GLAPIENTRY * PFNGLVIEWPORTINDEXEDFPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h);\r\ntypedef void (GLAPIENTRY * PFNGLVIEWPORTINDEXEDFVPROC) (GLuint index, const GLfloat * v);\r\n\r\n#define glDepthRangeArrayv GLEW_GET_FUN(__glewDepthRangeArrayv)\r\n#define glDepthRangeIndexed GLEW_GET_FUN(__glewDepthRangeIndexed)\r\n#define glGetDoublei_v GLEW_GET_FUN(__glewGetDoublei_v)\r\n#define glGetFloati_v GLEW_GET_FUN(__glewGetFloati_v)\r\n#define glScissorArrayv GLEW_GET_FUN(__glewScissorArrayv)\r\n#define glScissorIndexed GLEW_GET_FUN(__glewScissorIndexed)\r\n#define glScissorIndexedv GLEW_GET_FUN(__glewScissorIndexedv)\r\n#define glViewportArrayv GLEW_GET_FUN(__glewViewportArrayv)\r\n#define glViewportIndexedf GLEW_GET_FUN(__glewViewportIndexedf)\r\n#define glViewportIndexedfv GLEW_GET_FUN(__glewViewportIndexedfv)\r\n\r\n#define GLEW_ARB_viewport_array GLEW_GET_VAR(__GLEW_ARB_viewport_array)\r\n\r\n#endif /* GL_ARB_viewport_array */\r\n\r\n/* --------------------------- GL_ARB_window_pos --------------------------- */\r\n\r\n#ifndef GL_ARB_window_pos\r\n#define GL_ARB_window_pos 1\r\n\r\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS2DARBPROC) (GLdouble x, GLdouble y);\r\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS2DVARBPROC) (const GLdouble* p);\r\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS2FARBPROC) (GLfloat x, GLfloat y);\r\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS2FVARBPROC) (const GLfloat* p);\r\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS2IARBPROC) (GLint x, GLint y);\r\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS2IVARBPROC) (const GLint* p);\r\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS2SARBPROC) (GLshort x, GLshort y);\r\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS2SVARBPROC) (const GLshort* p);\r\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS3DARBPROC) (GLdouble x, GLdouble y, GLdouble z);\r\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS3DVARBPROC) (const GLdouble* p);\r\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS3FARBPROC) (GLfloat x, GLfloat y, GLfloat z);\r\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS3FVARBPROC) (const GLfloat* p);\r\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS3IARBPROC) (GLint x, GLint y, GLint z);\r\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS3IVARBPROC) (const GLint* p);\r\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS3SARBPROC) (GLshort x, GLshort y, GLshort z);\r\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS3SVARBPROC) (const GLshort* p);\r\n\r\n#define glWindowPos2dARB GLEW_GET_FUN(__glewWindowPos2dARB)\r\n#define glWindowPos2dvARB GLEW_GET_FUN(__glewWindowPos2dvARB)\r\n#define glWindowPos2fARB GLEW_GET_FUN(__glewWindowPos2fARB)\r\n#define glWindowPos2fvARB GLEW_GET_FUN(__glewWindowPos2fvARB)\r\n#define glWindowPos2iARB GLEW_GET_FUN(__glewWindowPos2iARB)\r\n#define glWindowPos2ivARB GLEW_GET_FUN(__glewWindowPos2ivARB)\r\n#define glWindowPos2sARB GLEW_GET_FUN(__glewWindowPos2sARB)\r\n#define glWindowPos2svARB GLEW_GET_FUN(__glewWindowPos2svARB)\r\n#define glWindowPos3dARB GLEW_GET_FUN(__glewWindowPos3dARB)\r\n#define glWindowPos3dvARB GLEW_GET_FUN(__glewWindowPos3dvARB)\r\n#define glWindowPos3fARB GLEW_GET_FUN(__glewWindowPos3fARB)\r\n#define glWindowPos3fvARB GLEW_GET_FUN(__glewWindowPos3fvARB)\r\n#define glWindowPos3iARB GLEW_GET_FUN(__glewWindowPos3iARB)\r\n#define glWindowPos3ivARB GLEW_GET_FUN(__glewWindowPos3ivARB)\r\n#define glWindowPos3sARB GLEW_GET_FUN(__glewWindowPos3sARB)\r\n#define glWindowPos3svARB GLEW_GET_FUN(__glewWindowPos3svARB)\r\n\r\n#define GLEW_ARB_window_pos GLEW_GET_VAR(__GLEW_ARB_window_pos)\r\n\r\n#endif /* GL_ARB_window_pos */\r\n\r\n/* ------------------------- GL_ATIX_point_sprites ------------------------- */\r\n\r\n#ifndef GL_ATIX_point_sprites\r\n#define GL_ATIX_point_sprites 1\r\n\r\n#define GL_TEXTURE_POINT_MODE_ATIX 0x60B0\r\n#define GL_TEXTURE_POINT_ONE_COORD_ATIX 0x60B1\r\n#define GL_TEXTURE_POINT_SPRITE_ATIX 0x60B2\r\n#define GL_POINT_SPRITE_CULL_MODE_ATIX 0x60B3\r\n#define GL_POINT_SPRITE_CULL_CENTER_ATIX 0x60B4\r\n#define GL_POINT_SPRITE_CULL_CLIP_ATIX 0x60B5\r\n\r\n#define GLEW_ATIX_point_sprites GLEW_GET_VAR(__GLEW_ATIX_point_sprites)\r\n\r\n#endif /* GL_ATIX_point_sprites */\r\n\r\n/* ---------------------- GL_ATIX_texture_env_combine3 --------------------- */\r\n\r\n#ifndef GL_ATIX_texture_env_combine3\r\n#define GL_ATIX_texture_env_combine3 1\r\n\r\n#define GL_MODULATE_ADD_ATIX 0x8744\r\n#define GL_MODULATE_SIGNED_ADD_ATIX 0x8745\r\n#define GL_MODULATE_SUBTRACT_ATIX 0x8746\r\n\r\n#define GLEW_ATIX_texture_env_combine3 GLEW_GET_VAR(__GLEW_ATIX_texture_env_combine3)\r\n\r\n#endif /* GL_ATIX_texture_env_combine3 */\r\n\r\n/* ----------------------- GL_ATIX_texture_env_route ----------------------- */\r\n\r\n#ifndef GL_ATIX_texture_env_route\r\n#define GL_ATIX_texture_env_route 1\r\n\r\n#define GL_SECONDARY_COLOR_ATIX 0x8747\r\n#define GL_TEXTURE_OUTPUT_RGB_ATIX 0x8748\r\n#define GL_TEXTURE_OUTPUT_ALPHA_ATIX 0x8749\r\n\r\n#define GLEW_ATIX_texture_env_route GLEW_GET_VAR(__GLEW_ATIX_texture_env_route)\r\n\r\n#endif /* GL_ATIX_texture_env_route */\r\n\r\n/* ---------------- GL_ATIX_vertex_shader_output_point_size ---------------- */\r\n\r\n#ifndef GL_ATIX_vertex_shader_output_point_size\r\n#define GL_ATIX_vertex_shader_output_point_size 1\r\n\r\n#define GL_OUTPUT_POINT_SIZE_ATIX 0x610E\r\n\r\n#define GLEW_ATIX_vertex_shader_output_point_size GLEW_GET_VAR(__GLEW_ATIX_vertex_shader_output_point_size)\r\n\r\n#endif /* GL_ATIX_vertex_shader_output_point_size */\r\n\r\n/* -------------------------- GL_ATI_draw_buffers -------------------------- */\r\n\r\n#ifndef GL_ATI_draw_buffers\r\n#define GL_ATI_draw_buffers 1\r\n\r\n#define GL_MAX_DRAW_BUFFERS_ATI 0x8824\r\n#define GL_DRAW_BUFFER0_ATI 0x8825\r\n#define GL_DRAW_BUFFER1_ATI 0x8826\r\n#define GL_DRAW_BUFFER2_ATI 0x8827\r\n#define GL_DRAW_BUFFER3_ATI 0x8828\r\n#define GL_DRAW_BUFFER4_ATI 0x8829\r\n#define GL_DRAW_BUFFER5_ATI 0x882A\r\n#define GL_DRAW_BUFFER6_ATI 0x882B\r\n#define GL_DRAW_BUFFER7_ATI 0x882C\r\n#define GL_DRAW_BUFFER8_ATI 0x882D\r\n#define GL_DRAW_BUFFER9_ATI 0x882E\r\n#define GL_DRAW_BUFFER10_ATI 0x882F\r\n#define GL_DRAW_BUFFER11_ATI 0x8830\r\n#define GL_DRAW_BUFFER12_ATI 0x8831\r\n#define GL_DRAW_BUFFER13_ATI 0x8832\r\n#define GL_DRAW_BUFFER14_ATI 0x8833\r\n#define GL_DRAW_BUFFER15_ATI 0x8834\r\n\r\ntypedef void (GLAPIENTRY * PFNGLDRAWBUFFERSATIPROC) (GLsizei n, const GLenum* bufs);\r\n\r\n#define glDrawBuffersATI GLEW_GET_FUN(__glewDrawBuffersATI)\r\n\r\n#define GLEW_ATI_draw_buffers GLEW_GET_VAR(__GLEW_ATI_draw_buffers)\r\n\r\n#endif /* GL_ATI_draw_buffers */\r\n\r\n/* -------------------------- GL_ATI_element_array ------------------------- */\r\n\r\n#ifndef GL_ATI_element_array\r\n#define GL_ATI_element_array 1\r\n\r\n#define GL_ELEMENT_ARRAY_ATI 0x8768\r\n#define GL_ELEMENT_ARRAY_TYPE_ATI 0x8769\r\n#define GL_ELEMENT_ARRAY_POINTER_ATI 0x876A\r\n\r\ntypedef void (GLAPIENTRY * PFNGLDRAWELEMENTARRAYATIPROC) (GLenum mode, GLsizei count);\r\ntypedef void (GLAPIENTRY * PFNGLDRAWRANGEELEMENTARRAYATIPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count);\r\ntypedef void (GLAPIENTRY * PFNGLELEMENTPOINTERATIPROC) (GLenum type, const void *pointer);\r\n\r\n#define glDrawElementArrayATI GLEW_GET_FUN(__glewDrawElementArrayATI)\r\n#define glDrawRangeElementArrayATI GLEW_GET_FUN(__glewDrawRangeElementArrayATI)\r\n#define glElementPointerATI GLEW_GET_FUN(__glewElementPointerATI)\r\n\r\n#define GLEW_ATI_element_array GLEW_GET_VAR(__GLEW_ATI_element_array)\r\n\r\n#endif /* GL_ATI_element_array */\r\n\r\n/* ------------------------- GL_ATI_envmap_bumpmap ------------------------- */\r\n\r\n#ifndef GL_ATI_envmap_bumpmap\r\n#define GL_ATI_envmap_bumpmap 1\r\n\r\n#define GL_BUMP_ROT_MATRIX_ATI 0x8775\r\n#define GL_BUMP_ROT_MATRIX_SIZE_ATI 0x8776\r\n#define GL_BUMP_NUM_TEX_UNITS_ATI 0x8777\r\n#define GL_BUMP_TEX_UNITS_ATI 0x8778\r\n#define GL_DUDV_ATI 0x8779\r\n#define GL_DU8DV8_ATI 0x877A\r\n#define GL_BUMP_ENVMAP_ATI 0x877B\r\n#define GL_BUMP_TARGET_ATI 0x877C\r\n\r\ntypedef void (GLAPIENTRY * PFNGLGETTEXBUMPPARAMETERFVATIPROC) (GLenum pname, GLfloat *param);\r\ntypedef void (GLAPIENTRY * PFNGLGETTEXBUMPPARAMETERIVATIPROC) (GLenum pname, GLint *param);\r\ntypedef void (GLAPIENTRY * PFNGLTEXBUMPPARAMETERFVATIPROC) (GLenum pname, GLfloat *param);\r\ntypedef void (GLAPIENTRY * PFNGLTEXBUMPPARAMETERIVATIPROC) (GLenum pname, GLint *param);\r\n\r\n#define glGetTexBumpParameterfvATI GLEW_GET_FUN(__glewGetTexBumpParameterfvATI)\r\n#define glGetTexBumpParameterivATI GLEW_GET_FUN(__glewGetTexBumpParameterivATI)\r\n#define glTexBumpParameterfvATI GLEW_GET_FUN(__glewTexBumpParameterfvATI)\r\n#define glTexBumpParameterivATI GLEW_GET_FUN(__glewTexBumpParameterivATI)\r\n\r\n#define GLEW_ATI_envmap_bumpmap GLEW_GET_VAR(__GLEW_ATI_envmap_bumpmap)\r\n\r\n#endif /* GL_ATI_envmap_bumpmap */\r\n\r\n/* ------------------------- GL_ATI_fragment_shader ------------------------ */\r\n\r\n#ifndef GL_ATI_fragment_shader\r\n#define GL_ATI_fragment_shader 1\r\n\r\n#define GL_2X_BIT_ATI 0x00000001\r\n#define GL_RED_BIT_ATI 0x00000001\r\n#define GL_4X_BIT_ATI 0x00000002\r\n#define GL_COMP_BIT_ATI 0x00000002\r\n#define GL_GREEN_BIT_ATI 0x00000002\r\n#define GL_8X_BIT_ATI 0x00000004\r\n#define GL_BLUE_BIT_ATI 0x00000004\r\n#define GL_NEGATE_BIT_ATI 0x00000004\r\n#define GL_BIAS_BIT_ATI 0x00000008\r\n#define GL_HALF_BIT_ATI 0x00000008\r\n#define GL_QUARTER_BIT_ATI 0x00000010\r\n#define GL_EIGHTH_BIT_ATI 0x00000020\r\n#define GL_SATURATE_BIT_ATI 0x00000040\r\n#define GL_FRAGMENT_SHADER_ATI 0x8920\r\n#define GL_REG_0_ATI 0x8921\r\n#define GL_REG_1_ATI 0x8922\r\n#define GL_REG_2_ATI 0x8923\r\n#define GL_REG_3_ATI 0x8924\r\n#define GL_REG_4_ATI 0x8925\r\n#define GL_REG_5_ATI 0x8926\r\n#define GL_CON_0_ATI 0x8941\r\n#define GL_CON_1_ATI 0x8942\r\n#define GL_CON_2_ATI 0x8943\r\n#define GL_CON_3_ATI 0x8944\r\n#define GL_CON_4_ATI 0x8945\r\n#define GL_CON_5_ATI 0x8946\r\n#define GL_CON_6_ATI 0x8947\r\n#define GL_CON_7_ATI 0x8948\r\n#define GL_MOV_ATI 0x8961\r\n#define GL_ADD_ATI 0x8963\r\n#define GL_MUL_ATI 0x8964\r\n#define GL_SUB_ATI 0x8965\r\n#define GL_DOT3_ATI 0x8966\r\n#define GL_DOT4_ATI 0x8967\r\n#define GL_MAD_ATI 0x8968\r\n#define GL_LERP_ATI 0x8969\r\n#define GL_CND_ATI 0x896A\r\n#define GL_CND0_ATI 0x896B\r\n#define GL_DOT2_ADD_ATI 0x896C\r\n#define GL_SECONDARY_INTERPOLATOR_ATI 0x896D\r\n#define GL_NUM_FRAGMENT_REGISTERS_ATI 0x896E\r\n#define GL_NUM_FRAGMENT_CONSTANTS_ATI 0x896F\r\n#define GL_NUM_PASSES_ATI 0x8970\r\n#define GL_NUM_INSTRUCTIONS_PER_PASS_ATI 0x8971\r\n#define GL_NUM_INSTRUCTIONS_TOTAL_ATI 0x8972\r\n#define GL_NUM_INPUT_INTERPOLATOR_COMPONENTS_ATI 0x8973\r\n#define GL_NUM_LOOPBACK_COMPONENTS_ATI 0x8974\r\n#define GL_COLOR_ALPHA_PAIRING_ATI 0x8975\r\n#define GL_SWIZZLE_STR_ATI 0x8976\r\n#define GL_SWIZZLE_STQ_ATI 0x8977\r\n#define GL_SWIZZLE_STR_DR_ATI 0x8978\r\n#define GL_SWIZZLE_STQ_DQ_ATI 0x8979\r\n#define GL_SWIZZLE_STRQ_ATI 0x897A\r\n#define GL_SWIZZLE_STRQ_DQ_ATI 0x897B\r\n\r\ntypedef void (GLAPIENTRY * PFNGLALPHAFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod);\r\ntypedef void (GLAPIENTRY * PFNGLALPHAFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod);\r\ntypedef void (GLAPIENTRY * PFNGLALPHAFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod);\r\ntypedef void (GLAPIENTRY * PFNGLBEGINFRAGMENTSHADERATIPROC) (void);\r\ntypedef void (GLAPIENTRY * PFNGLBINDFRAGMENTSHADERATIPROC) (GLuint id);\r\ntypedef void (GLAPIENTRY * PFNGLCOLORFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod);\r\ntypedef void (GLAPIENTRY * PFNGLCOLORFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod);\r\ntypedef void (GLAPIENTRY * PFNGLCOLORFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod);\r\ntypedef void (GLAPIENTRY * PFNGLDELETEFRAGMENTSHADERATIPROC) (GLuint id);\r\ntypedef void (GLAPIENTRY * PFNGLENDFRAGMENTSHADERATIPROC) (void);\r\ntypedef GLuint (GLAPIENTRY * PFNGLGENFRAGMENTSHADERSATIPROC) (GLuint range);\r\ntypedef void (GLAPIENTRY * PFNGLPASSTEXCOORDATIPROC) (GLuint dst, GLuint coord, GLenum swizzle);\r\ntypedef void (GLAPIENTRY * PFNGLSAMPLEMAPATIPROC) (GLuint dst, GLuint interp, GLenum swizzle);\r\ntypedef void (GLAPIENTRY * PFNGLSETFRAGMENTSHADERCONSTANTATIPROC) (GLuint dst, const GLfloat* value);\r\n\r\n#define glAlphaFragmentOp1ATI GLEW_GET_FUN(__glewAlphaFragmentOp1ATI)\r\n#define glAlphaFragmentOp2ATI GLEW_GET_FUN(__glewAlphaFragmentOp2ATI)\r\n#define glAlphaFragmentOp3ATI GLEW_GET_FUN(__glewAlphaFragmentOp3ATI)\r\n#define glBeginFragmentShaderATI GLEW_GET_FUN(__glewBeginFragmentShaderATI)\r\n#define glBindFragmentShaderATI GLEW_GET_FUN(__glewBindFragmentShaderATI)\r\n#define glColorFragmentOp1ATI GLEW_GET_FUN(__glewColorFragmentOp1ATI)\r\n#define glColorFragmentOp2ATI GLEW_GET_FUN(__glewColorFragmentOp2ATI)\r\n#define glColorFragmentOp3ATI GLEW_GET_FUN(__glewColorFragmentOp3ATI)\r\n#define glDeleteFragmentShaderATI GLEW_GET_FUN(__glewDeleteFragmentShaderATI)\r\n#define glEndFragmentShaderATI GLEW_GET_FUN(__glewEndFragmentShaderATI)\r\n#define glGenFragmentShadersATI GLEW_GET_FUN(__glewGenFragmentShadersATI)\r\n#define glPassTexCoordATI GLEW_GET_FUN(__glewPassTexCoordATI)\r\n#define glSampleMapATI GLEW_GET_FUN(__glewSampleMapATI)\r\n#define glSetFragmentShaderConstantATI GLEW_GET_FUN(__glewSetFragmentShaderConstantATI)\r\n\r\n#define GLEW_ATI_fragment_shader GLEW_GET_VAR(__GLEW_ATI_fragment_shader)\r\n\r\n#endif /* GL_ATI_fragment_shader */\r\n\r\n/* ------------------------ GL_ATI_map_object_buffer ----------------------- */\r\n\r\n#ifndef GL_ATI_map_object_buffer\r\n#define GL_ATI_map_object_buffer 1\r\n\r\ntypedef void * (GLAPIENTRY * PFNGLMAPOBJECTBUFFERATIPROC) (GLuint buffer);\r\ntypedef void (GLAPIENTRY * PFNGLUNMAPOBJECTBUFFERATIPROC) (GLuint buffer);\r\n\r\n#define glMapObjectBufferATI GLEW_GET_FUN(__glewMapObjectBufferATI)\r\n#define glUnmapObjectBufferATI GLEW_GET_FUN(__glewUnmapObjectBufferATI)\r\n\r\n#define GLEW_ATI_map_object_buffer GLEW_GET_VAR(__GLEW_ATI_map_object_buffer)\r\n\r\n#endif /* GL_ATI_map_object_buffer */\r\n\r\n/* ----------------------------- GL_ATI_meminfo ---------------------------- */\r\n\r\n#ifndef GL_ATI_meminfo\r\n#define GL_ATI_meminfo 1\r\n\r\n#define GL_VBO_FREE_MEMORY_ATI 0x87FB\r\n#define GL_TEXTURE_FREE_MEMORY_ATI 0x87FC\r\n#define GL_RENDERBUFFER_FREE_MEMORY_ATI 0x87FD\r\n\r\n#define GLEW_ATI_meminfo GLEW_GET_VAR(__GLEW_ATI_meminfo)\r\n\r\n#endif /* GL_ATI_meminfo */\r\n\r\n/* -------------------------- GL_ATI_pn_triangles -------------------------- */\r\n\r\n#ifndef GL_ATI_pn_triangles\r\n#define GL_ATI_pn_triangles 1\r\n\r\n#define GL_PN_TRIANGLES_ATI 0x87F0\r\n#define GL_MAX_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F1\r\n#define GL_PN_TRIANGLES_POINT_MODE_ATI 0x87F2\r\n#define GL_PN_TRIANGLES_NORMAL_MODE_ATI 0x87F3\r\n#define GL_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F4\r\n#define GL_PN_TRIANGLES_POINT_MODE_LINEAR_ATI 0x87F5\r\n#define GL_PN_TRIANGLES_POINT_MODE_CUBIC_ATI 0x87F6\r\n#define GL_PN_TRIANGLES_NORMAL_MODE_LINEAR_ATI 0x87F7\r\n#define GL_PN_TRIANGLES_NORMAL_MODE_QUADRATIC_ATI 0x87F8\r\n\r\ntypedef void (GLAPIENTRY * PFNGLPNTRIANGLESFATIPROC) (GLenum pname, GLfloat param);\r\ntypedef void (GLAPIENTRY * PFNGLPNTRIANGLESIATIPROC) (GLenum pname, GLint param);\r\n\r\n#define glPNTrianglesfATI GLEW_GET_FUN(__glewPNTrianglesfATI)\r\n#define glPNTrianglesiATI GLEW_GET_FUN(__glewPNTrianglesiATI)\r\n\r\n#define GLEW_ATI_pn_triangles GLEW_GET_VAR(__GLEW_ATI_pn_triangles)\r\n\r\n#endif /* GL_ATI_pn_triangles */\r\n\r\n/* ------------------------ GL_ATI_separate_stencil ------------------------ */\r\n\r\n#ifndef GL_ATI_separate_stencil\r\n#define GL_ATI_separate_stencil 1\r\n\r\n#define GL_STENCIL_BACK_FUNC_ATI 0x8800\r\n#define GL_STENCIL_BACK_FAIL_ATI 0x8801\r\n#define GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI 0x8802\r\n#define GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI 0x8803\r\n\r\ntypedef void (GLAPIENTRY * PFNGLSTENCILFUNCSEPARATEATIPROC) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask);\r\ntypedef void (GLAPIENTRY * PFNGLSTENCILOPSEPARATEATIPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass);\r\n\r\n#define glStencilFuncSeparateATI GLEW_GET_FUN(__glewStencilFuncSeparateATI)\r\n#define glStencilOpSeparateATI GLEW_GET_FUN(__glewStencilOpSeparateATI)\r\n\r\n#define GLEW_ATI_separate_stencil GLEW_GET_VAR(__GLEW_ATI_separate_stencil)\r\n\r\n#endif /* GL_ATI_separate_stencil */\r\n\r\n/* ----------------------- GL_ATI_shader_texture_lod ----------------------- */\r\n\r\n#ifndef GL_ATI_shader_texture_lod\r\n#define GL_ATI_shader_texture_lod 1\r\n\r\n#define GLEW_ATI_shader_texture_lod GLEW_GET_VAR(__GLEW_ATI_shader_texture_lod)\r\n\r\n#endif /* GL_ATI_shader_texture_lod */\r\n\r\n/* ---------------------- GL_ATI_text_fragment_shader ---------------------- */\r\n\r\n#ifndef GL_ATI_text_fragment_shader\r\n#define GL_ATI_text_fragment_shader 1\r\n\r\n#define GL_TEXT_FRAGMENT_SHADER_ATI 0x8200\r\n\r\n#define GLEW_ATI_text_fragment_shader GLEW_GET_VAR(__GLEW_ATI_text_fragment_shader)\r\n\r\n#endif /* GL_ATI_text_fragment_shader */\r\n\r\n/* --------------------- GL_ATI_texture_compression_3dc -------------------- */\r\n\r\n#ifndef GL_ATI_texture_compression_3dc\r\n#define GL_ATI_texture_compression_3dc 1\r\n\r\n#define GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI 0x8837\r\n\r\n#define GLEW_ATI_texture_compression_3dc GLEW_GET_VAR(__GLEW_ATI_texture_compression_3dc)\r\n\r\n#endif /* GL_ATI_texture_compression_3dc */\r\n\r\n/* ---------------------- GL_ATI_texture_env_combine3 ---------------------- */\r\n\r\n#ifndef GL_ATI_texture_env_combine3\r\n#define GL_ATI_texture_env_combine3 1\r\n\r\n#define GL_MODULATE_ADD_ATI 0x8744\r\n#define GL_MODULATE_SIGNED_ADD_ATI 0x8745\r\n#define GL_MODULATE_SUBTRACT_ATI 0x8746\r\n\r\n#define GLEW_ATI_texture_env_combine3 GLEW_GET_VAR(__GLEW_ATI_texture_env_combine3)\r\n\r\n#endif /* GL_ATI_texture_env_combine3 */\r\n\r\n/* -------------------------- GL_ATI_texture_float ------------------------- */\r\n\r\n#ifndef GL_ATI_texture_float\r\n#define GL_ATI_texture_float 1\r\n\r\n#define GL_RGBA_FLOAT32_ATI 0x8814\r\n#define GL_RGB_FLOAT32_ATI 0x8815\r\n#define GL_ALPHA_FLOAT32_ATI 0x8816\r\n#define GL_INTENSITY_FLOAT32_ATI 0x8817\r\n#define GL_LUMINANCE_FLOAT32_ATI 0x8818\r\n#define GL_LUMINANCE_ALPHA_FLOAT32_ATI 0x8819\r\n#define GL_RGBA_FLOAT16_ATI 0x881A\r\n#define GL_RGB_FLOAT16_ATI 0x881B\r\n#define GL_ALPHA_FLOAT16_ATI 0x881C\r\n#define GL_INTENSITY_FLOAT16_ATI 0x881D\r\n#define GL_LUMINANCE_FLOAT16_ATI 0x881E\r\n#define GL_LUMINANCE_ALPHA_FLOAT16_ATI 0x881F\r\n\r\n#define GLEW_ATI_texture_float GLEW_GET_VAR(__GLEW_ATI_texture_float)\r\n\r\n#endif /* GL_ATI_texture_float */\r\n\r\n/* ----------------------- GL_ATI_texture_mirror_once ---------------------- */\r\n\r\n#ifndef GL_ATI_texture_mirror_once\r\n#define GL_ATI_texture_mirror_once 1\r\n\r\n#define GL_MIRROR_CLAMP_ATI 0x8742\r\n#define GL_MIRROR_CLAMP_TO_EDGE_ATI 0x8743\r\n\r\n#define GLEW_ATI_texture_mirror_once GLEW_GET_VAR(__GLEW_ATI_texture_mirror_once)\r\n\r\n#endif /* GL_ATI_texture_mirror_once */\r\n\r\n/* ----------------------- GL_ATI_vertex_array_object ---------------------- */\r\n\r\n#ifndef GL_ATI_vertex_array_object\r\n#define GL_ATI_vertex_array_object 1\r\n\r\n#define GL_STATIC_ATI 0x8760\r\n#define GL_DYNAMIC_ATI 0x8761\r\n#define GL_PRESERVE_ATI 0x8762\r\n#define GL_DISCARD_ATI 0x8763\r\n#define GL_OBJECT_BUFFER_SIZE_ATI 0x8764\r\n#define GL_OBJECT_BUFFER_USAGE_ATI 0x8765\r\n#define GL_ARRAY_OBJECT_BUFFER_ATI 0x8766\r\n#define GL_ARRAY_OBJECT_OFFSET_ATI 0x8767\r\n\r\ntypedef void (GLAPIENTRY * PFNGLARRAYOBJECTATIPROC) (GLenum array, GLint size, GLenum type, GLsizei stride, GLuint buffer, GLuint offset);\r\ntypedef void (GLAPIENTRY * PFNGLFREEOBJECTBUFFERATIPROC) (GLuint buffer);\r\ntypedef void (GLAPIENTRY * PFNGLGETARRAYOBJECTFVATIPROC) (GLenum array, GLenum pname, GLfloat* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETARRAYOBJECTIVATIPROC) (GLenum array, GLenum pname, GLint* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETOBJECTBUFFERFVATIPROC) (GLuint buffer, GLenum pname, GLfloat* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETOBJECTBUFFERIVATIPROC) (GLuint buffer, GLenum pname, GLint* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETVARIANTARRAYOBJECTFVATIPROC) (GLuint id, GLenum pname, GLfloat* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETVARIANTARRAYOBJECTIVATIPROC) (GLuint id, GLenum pname, GLint* params);\r\ntypedef GLboolean (GLAPIENTRY * PFNGLISOBJECTBUFFERATIPROC) (GLuint buffer);\r\ntypedef GLuint (GLAPIENTRY * PFNGLNEWOBJECTBUFFERATIPROC) (GLsizei size, const void *pointer, GLenum usage);\r\ntypedef void (GLAPIENTRY * PFNGLUPDATEOBJECTBUFFERATIPROC) (GLuint buffer, GLuint offset, GLsizei size, const void *pointer, GLenum preserve);\r\ntypedef void (GLAPIENTRY * PFNGLVARIANTARRAYOBJECTATIPROC) (GLuint id, GLenum type, GLsizei stride, GLuint buffer, GLuint offset);\r\n\r\n#define glArrayObjectATI GLEW_GET_FUN(__glewArrayObjectATI)\r\n#define glFreeObjectBufferATI GLEW_GET_FUN(__glewFreeObjectBufferATI)\r\n#define glGetArrayObjectfvATI GLEW_GET_FUN(__glewGetArrayObjectfvATI)\r\n#define glGetArrayObjectivATI GLEW_GET_FUN(__glewGetArrayObjectivATI)\r\n#define glGetObjectBufferfvATI GLEW_GET_FUN(__glewGetObjectBufferfvATI)\r\n#define glGetObjectBufferivATI GLEW_GET_FUN(__glewGetObjectBufferivATI)\r\n#define glGetVariantArrayObjectfvATI GLEW_GET_FUN(__glewGetVariantArrayObjectfvATI)\r\n#define glGetVariantArrayObjectivATI GLEW_GET_FUN(__glewGetVariantArrayObjectivATI)\r\n#define glIsObjectBufferATI GLEW_GET_FUN(__glewIsObjectBufferATI)\r\n#define glNewObjectBufferATI GLEW_GET_FUN(__glewNewObjectBufferATI)\r\n#define glUpdateObjectBufferATI GLEW_GET_FUN(__glewUpdateObjectBufferATI)\r\n#define glVariantArrayObjectATI GLEW_GET_FUN(__glewVariantArrayObjectATI)\r\n\r\n#define GLEW_ATI_vertex_array_object GLEW_GET_VAR(__GLEW_ATI_vertex_array_object)\r\n\r\n#endif /* GL_ATI_vertex_array_object */\r\n\r\n/* ------------------- GL_ATI_vertex_attrib_array_object ------------------- */\r\n\r\n#ifndef GL_ATI_vertex_attrib_array_object\r\n#define GL_ATI_vertex_attrib_array_object 1\r\n\r\ntypedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBARRAYOBJECTFVATIPROC) (GLuint index, GLenum pname, GLfloat* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBARRAYOBJECTIVATIPROC) (GLuint index, GLenum pname, GLint* params);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBARRAYOBJECTATIPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint buffer, GLuint offset);\r\n\r\n#define glGetVertexAttribArrayObjectfvATI GLEW_GET_FUN(__glewGetVertexAttribArrayObjectfvATI)\r\n#define glGetVertexAttribArrayObjectivATI GLEW_GET_FUN(__glewGetVertexAttribArrayObjectivATI)\r\n#define glVertexAttribArrayObjectATI GLEW_GET_FUN(__glewVertexAttribArrayObjectATI)\r\n\r\n#define GLEW_ATI_vertex_attrib_array_object GLEW_GET_VAR(__GLEW_ATI_vertex_attrib_array_object)\r\n\r\n#endif /* GL_ATI_vertex_attrib_array_object */\r\n\r\n/* ------------------------- GL_ATI_vertex_streams ------------------------- */\r\n\r\n#ifndef GL_ATI_vertex_streams\r\n#define GL_ATI_vertex_streams 1\r\n\r\n#define GL_MAX_VERTEX_STREAMS_ATI 0x876B\r\n#define GL_VERTEX_SOURCE_ATI 0x876C\r\n#define GL_VERTEX_STREAM0_ATI 0x876D\r\n#define GL_VERTEX_STREAM1_ATI 0x876E\r\n#define GL_VERTEX_STREAM2_ATI 0x876F\r\n#define GL_VERTEX_STREAM3_ATI 0x8770\r\n#define GL_VERTEX_STREAM4_ATI 0x8771\r\n#define GL_VERTEX_STREAM5_ATI 0x8772\r\n#define GL_VERTEX_STREAM6_ATI 0x8773\r\n#define GL_VERTEX_STREAM7_ATI 0x8774\r\n\r\ntypedef void (GLAPIENTRY * PFNGLCLIENTACTIVEVERTEXSTREAMATIPROC) (GLenum stream);\r\ntypedef void (GLAPIENTRY * PFNGLNORMALSTREAM3BATIPROC) (GLenum stream, GLbyte x, GLbyte y, GLbyte z);\r\ntypedef void (GLAPIENTRY * PFNGLNORMALSTREAM3BVATIPROC) (GLenum stream, const GLbyte *coords);\r\ntypedef void (GLAPIENTRY * PFNGLNORMALSTREAM3DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z);\r\ntypedef void (GLAPIENTRY * PFNGLNORMALSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords);\r\ntypedef void (GLAPIENTRY * PFNGLNORMALSTREAM3FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z);\r\ntypedef void (GLAPIENTRY * PFNGLNORMALSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords);\r\ntypedef void (GLAPIENTRY * PFNGLNORMALSTREAM3IATIPROC) (GLenum stream, GLint x, GLint y, GLint z);\r\ntypedef void (GLAPIENTRY * PFNGLNORMALSTREAM3IVATIPROC) (GLenum stream, const GLint *coords);\r\ntypedef void (GLAPIENTRY * PFNGLNORMALSTREAM3SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z);\r\ntypedef void (GLAPIENTRY * PFNGLNORMALSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXBLENDENVFATIPROC) (GLenum pname, GLfloat param);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXBLENDENVIATIPROC) (GLenum pname, GLint param);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXSTREAM1DATIPROC) (GLenum stream, GLdouble x);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXSTREAM1DVATIPROC) (GLenum stream, const GLdouble *coords);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXSTREAM1FATIPROC) (GLenum stream, GLfloat x);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXSTREAM1FVATIPROC) (GLenum stream, const GLfloat *coords);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXSTREAM1IATIPROC) (GLenum stream, GLint x);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXSTREAM1IVATIPROC) (GLenum stream, const GLint *coords);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXSTREAM1SATIPROC) (GLenum stream, GLshort x);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXSTREAM1SVATIPROC) (GLenum stream, const GLshort *coords);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXSTREAM2DATIPROC) (GLenum stream, GLdouble x, GLdouble y);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXSTREAM2DVATIPROC) (GLenum stream, const GLdouble *coords);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXSTREAM2FATIPROC) (GLenum stream, GLfloat x, GLfloat y);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXSTREAM2FVATIPROC) (GLenum stream, const GLfloat *coords);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXSTREAM2IATIPROC) (GLenum stream, GLint x, GLint y);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXSTREAM2IVATIPROC) (GLenum stream, const GLint *coords);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXSTREAM2SATIPROC) (GLenum stream, GLshort x, GLshort y);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXSTREAM2SVATIPROC) (GLenum stream, const GLshort *coords);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXSTREAM3DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXSTREAM3FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXSTREAM3IATIPROC) (GLenum stream, GLint x, GLint y, GLint z);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXSTREAM3IVATIPROC) (GLenum stream, const GLint *coords);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXSTREAM3SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXSTREAM4DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z, GLdouble w);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXSTREAM4DVATIPROC) (GLenum stream, const GLdouble *coords);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXSTREAM4FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z, GLfloat w);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXSTREAM4FVATIPROC) (GLenum stream, const GLfloat *coords);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXSTREAM4IATIPROC) (GLenum stream, GLint x, GLint y, GLint z, GLint w);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXSTREAM4IVATIPROC) (GLenum stream, const GLint *coords);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXSTREAM4SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z, GLshort w);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXSTREAM4SVATIPROC) (GLenum stream, const GLshort *coords);\r\n\r\n#define glClientActiveVertexStreamATI GLEW_GET_FUN(__glewClientActiveVertexStreamATI)\r\n#define glNormalStream3bATI GLEW_GET_FUN(__glewNormalStream3bATI)\r\n#define glNormalStream3bvATI GLEW_GET_FUN(__glewNormalStream3bvATI)\r\n#define glNormalStream3dATI GLEW_GET_FUN(__glewNormalStream3dATI)\r\n#define glNormalStream3dvATI GLEW_GET_FUN(__glewNormalStream3dvATI)\r\n#define glNormalStream3fATI GLEW_GET_FUN(__glewNormalStream3fATI)\r\n#define glNormalStream3fvATI GLEW_GET_FUN(__glewNormalStream3fvATI)\r\n#define glNormalStream3iATI GLEW_GET_FUN(__glewNormalStream3iATI)\r\n#define glNormalStream3ivATI GLEW_GET_FUN(__glewNormalStream3ivATI)\r\n#define glNormalStream3sATI GLEW_GET_FUN(__glewNormalStream3sATI)\r\n#define glNormalStream3svATI GLEW_GET_FUN(__glewNormalStream3svATI)\r\n#define glVertexBlendEnvfATI GLEW_GET_FUN(__glewVertexBlendEnvfATI)\r\n#define glVertexBlendEnviATI GLEW_GET_FUN(__glewVertexBlendEnviATI)\r\n#define glVertexStream1dATI GLEW_GET_FUN(__glewVertexStream1dATI)\r\n#define glVertexStream1dvATI GLEW_GET_FUN(__glewVertexStream1dvATI)\r\n#define glVertexStream1fATI GLEW_GET_FUN(__glewVertexStream1fATI)\r\n#define glVertexStream1fvATI GLEW_GET_FUN(__glewVertexStream1fvATI)\r\n#define glVertexStream1iATI GLEW_GET_FUN(__glewVertexStream1iATI)\r\n#define glVertexStream1ivATI GLEW_GET_FUN(__glewVertexStream1ivATI)\r\n#define glVertexStream1sATI GLEW_GET_FUN(__glewVertexStream1sATI)\r\n#define glVertexStream1svATI GLEW_GET_FUN(__glewVertexStream1svATI)\r\n#define glVertexStream2dATI GLEW_GET_FUN(__glewVertexStream2dATI)\r\n#define glVertexStream2dvATI GLEW_GET_FUN(__glewVertexStream2dvATI)\r\n#define glVertexStream2fATI GLEW_GET_FUN(__glewVertexStream2fATI)\r\n#define glVertexStream2fvATI GLEW_GET_FUN(__glewVertexStream2fvATI)\r\n#define glVertexStream2iATI GLEW_GET_FUN(__glewVertexStream2iATI)\r\n#define glVertexStream2ivATI GLEW_GET_FUN(__glewVertexStream2ivATI)\r\n#define glVertexStream2sATI GLEW_GET_FUN(__glewVertexStream2sATI)\r\n#define glVertexStream2svATI GLEW_GET_FUN(__glewVertexStream2svATI)\r\n#define glVertexStream3dATI GLEW_GET_FUN(__glewVertexStream3dATI)\r\n#define glVertexStream3dvATI GLEW_GET_FUN(__glewVertexStream3dvATI)\r\n#define glVertexStream3fATI GLEW_GET_FUN(__glewVertexStream3fATI)\r\n#define glVertexStream3fvATI GLEW_GET_FUN(__glewVertexStream3fvATI)\r\n#define glVertexStream3iATI GLEW_GET_FUN(__glewVertexStream3iATI)\r\n#define glVertexStream3ivATI GLEW_GET_FUN(__glewVertexStream3ivATI)\r\n#define glVertexStream3sATI GLEW_GET_FUN(__glewVertexStream3sATI)\r\n#define glVertexStream3svATI GLEW_GET_FUN(__glewVertexStream3svATI)\r\n#define glVertexStream4dATI GLEW_GET_FUN(__glewVertexStream4dATI)\r\n#define glVertexStream4dvATI GLEW_GET_FUN(__glewVertexStream4dvATI)\r\n#define glVertexStream4fATI GLEW_GET_FUN(__glewVertexStream4fATI)\r\n#define glVertexStream4fvATI GLEW_GET_FUN(__glewVertexStream4fvATI)\r\n#define glVertexStream4iATI GLEW_GET_FUN(__glewVertexStream4iATI)\r\n#define glVertexStream4ivATI GLEW_GET_FUN(__glewVertexStream4ivATI)\r\n#define glVertexStream4sATI GLEW_GET_FUN(__glewVertexStream4sATI)\r\n#define glVertexStream4svATI GLEW_GET_FUN(__glewVertexStream4svATI)\r\n\r\n#define GLEW_ATI_vertex_streams GLEW_GET_VAR(__GLEW_ATI_vertex_streams)\r\n\r\n#endif /* GL_ATI_vertex_streams */\r\n\r\n/* --------------------------- GL_EXT_422_pixels --------------------------- */\r\n\r\n#ifndef GL_EXT_422_pixels\r\n#define GL_EXT_422_pixels 1\r\n\r\n#define GL_422_EXT 0x80CC\r\n#define GL_422_REV_EXT 0x80CD\r\n#define GL_422_AVERAGE_EXT 0x80CE\r\n#define GL_422_REV_AVERAGE_EXT 0x80CF\r\n\r\n#define GLEW_EXT_422_pixels GLEW_GET_VAR(__GLEW_EXT_422_pixels)\r\n\r\n#endif /* GL_EXT_422_pixels */\r\n\r\n/* ---------------------------- GL_EXT_Cg_shader --------------------------- */\r\n\r\n#ifndef GL_EXT_Cg_shader\r\n#define GL_EXT_Cg_shader 1\r\n\r\n#define GL_CG_VERTEX_SHADER_EXT 0x890E\r\n#define GL_CG_FRAGMENT_SHADER_EXT 0x890F\r\n\r\n#define GLEW_EXT_Cg_shader GLEW_GET_VAR(__GLEW_EXT_Cg_shader)\r\n\r\n#endif /* GL_EXT_Cg_shader */\r\n\r\n/* ------------------------------ GL_EXT_abgr ------------------------------ */\r\n\r\n#ifndef GL_EXT_abgr\r\n#define GL_EXT_abgr 1\r\n\r\n#define GL_ABGR_EXT 0x8000\r\n\r\n#define GLEW_EXT_abgr GLEW_GET_VAR(__GLEW_EXT_abgr)\r\n\r\n#endif /* GL_EXT_abgr */\r\n\r\n/* ------------------------------ GL_EXT_bgra ------------------------------ */\r\n\r\n#ifndef GL_EXT_bgra\r\n#define GL_EXT_bgra 1\r\n\r\n#define GL_BGR_EXT 0x80E0\r\n#define GL_BGRA_EXT 0x80E1\r\n\r\n#define GLEW_EXT_bgra GLEW_GET_VAR(__GLEW_EXT_bgra)\r\n\r\n#endif /* GL_EXT_bgra */\r\n\r\n/* ------------------------ GL_EXT_bindable_uniform ------------------------ */\r\n\r\n#ifndef GL_EXT_bindable_uniform\r\n#define GL_EXT_bindable_uniform 1\r\n\r\n#define GL_MAX_VERTEX_BINDABLE_UNIFORMS_EXT 0x8DE2\r\n#define GL_MAX_FRAGMENT_BINDABLE_UNIFORMS_EXT 0x8DE3\r\n#define GL_MAX_GEOMETRY_BINDABLE_UNIFORMS_EXT 0x8DE4\r\n#define GL_MAX_BINDABLE_UNIFORM_SIZE_EXT 0x8DED\r\n#define GL_UNIFORM_BUFFER_EXT 0x8DEE\r\n#define GL_UNIFORM_BUFFER_BINDING_EXT 0x8DEF\r\n\r\ntypedef GLint (GLAPIENTRY * PFNGLGETUNIFORMBUFFERSIZEEXTPROC) (GLuint program, GLint location);\r\ntypedef GLintptr (GLAPIENTRY * PFNGLGETUNIFORMOFFSETEXTPROC) (GLuint program, GLint location);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORMBUFFEREXTPROC) (GLuint program, GLint location, GLuint buffer);\r\n\r\n#define glGetUniformBufferSizeEXT GLEW_GET_FUN(__glewGetUniformBufferSizeEXT)\r\n#define glGetUniformOffsetEXT GLEW_GET_FUN(__glewGetUniformOffsetEXT)\r\n#define glUniformBufferEXT GLEW_GET_FUN(__glewUniformBufferEXT)\r\n\r\n#define GLEW_EXT_bindable_uniform GLEW_GET_VAR(__GLEW_EXT_bindable_uniform)\r\n\r\n#endif /* GL_EXT_bindable_uniform */\r\n\r\n/* --------------------------- GL_EXT_blend_color -------------------------- */\r\n\r\n#ifndef GL_EXT_blend_color\r\n#define GL_EXT_blend_color 1\r\n\r\n#define GL_CONSTANT_COLOR_EXT 0x8001\r\n#define GL_ONE_MINUS_CONSTANT_COLOR_EXT 0x8002\r\n#define GL_CONSTANT_ALPHA_EXT 0x8003\r\n#define GL_ONE_MINUS_CONSTANT_ALPHA_EXT 0x8004\r\n#define GL_BLEND_COLOR_EXT 0x8005\r\n\r\ntypedef void (GLAPIENTRY * PFNGLBLENDCOLOREXTPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);\r\n\r\n#define glBlendColorEXT GLEW_GET_FUN(__glewBlendColorEXT)\r\n\r\n#define GLEW_EXT_blend_color GLEW_GET_VAR(__GLEW_EXT_blend_color)\r\n\r\n#endif /* GL_EXT_blend_color */\r\n\r\n/* --------------------- GL_EXT_blend_equation_separate -------------------- */\r\n\r\n#ifndef GL_EXT_blend_equation_separate\r\n#define GL_EXT_blend_equation_separate 1\r\n\r\n#define GL_BLEND_EQUATION_RGB_EXT 0x8009\r\n#define GL_BLEND_EQUATION_ALPHA_EXT 0x883D\r\n\r\ntypedef void (GLAPIENTRY * PFNGLBLENDEQUATIONSEPARATEEXTPROC) (GLenum modeRGB, GLenum modeAlpha);\r\n\r\n#define glBlendEquationSeparateEXT GLEW_GET_FUN(__glewBlendEquationSeparateEXT)\r\n\r\n#define GLEW_EXT_blend_equation_separate GLEW_GET_VAR(__GLEW_EXT_blend_equation_separate)\r\n\r\n#endif /* GL_EXT_blend_equation_separate */\r\n\r\n/* ----------------------- GL_EXT_blend_func_separate ---------------------- */\r\n\r\n#ifndef GL_EXT_blend_func_separate\r\n#define GL_EXT_blend_func_separate 1\r\n\r\n#define GL_BLEND_DST_RGB_EXT 0x80C8\r\n#define GL_BLEND_SRC_RGB_EXT 0x80C9\r\n#define GL_BLEND_DST_ALPHA_EXT 0x80CA\r\n#define GL_BLEND_SRC_ALPHA_EXT 0x80CB\r\n\r\ntypedef void (GLAPIENTRY * PFNGLBLENDFUNCSEPARATEEXTPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha);\r\n\r\n#define glBlendFuncSeparateEXT GLEW_GET_FUN(__glewBlendFuncSeparateEXT)\r\n\r\n#define GLEW_EXT_blend_func_separate GLEW_GET_VAR(__GLEW_EXT_blend_func_separate)\r\n\r\n#endif /* GL_EXT_blend_func_separate */\r\n\r\n/* ------------------------- GL_EXT_blend_logic_op ------------------------- */\r\n\r\n#ifndef GL_EXT_blend_logic_op\r\n#define GL_EXT_blend_logic_op 1\r\n\r\n#define GLEW_EXT_blend_logic_op GLEW_GET_VAR(__GLEW_EXT_blend_logic_op)\r\n\r\n#endif /* GL_EXT_blend_logic_op */\r\n\r\n/* -------------------------- GL_EXT_blend_minmax -------------------------- */\r\n\r\n#ifndef GL_EXT_blend_minmax\r\n#define GL_EXT_blend_minmax 1\r\n\r\n#define GL_FUNC_ADD_EXT 0x8006\r\n#define GL_MIN_EXT 0x8007\r\n#define GL_MAX_EXT 0x8008\r\n#define GL_BLEND_EQUATION_EXT 0x8009\r\n\r\ntypedef void (GLAPIENTRY * PFNGLBLENDEQUATIONEXTPROC) (GLenum mode);\r\n\r\n#define glBlendEquationEXT GLEW_GET_FUN(__glewBlendEquationEXT)\r\n\r\n#define GLEW_EXT_blend_minmax GLEW_GET_VAR(__GLEW_EXT_blend_minmax)\r\n\r\n#endif /* GL_EXT_blend_minmax */\r\n\r\n/* ------------------------- GL_EXT_blend_subtract ------------------------- */\r\n\r\n#ifndef GL_EXT_blend_subtract\r\n#define GL_EXT_blend_subtract 1\r\n\r\n#define GL_FUNC_SUBTRACT_EXT 0x800A\r\n#define GL_FUNC_REVERSE_SUBTRACT_EXT 0x800B\r\n\r\n#define GLEW_EXT_blend_subtract GLEW_GET_VAR(__GLEW_EXT_blend_subtract)\r\n\r\n#endif /* GL_EXT_blend_subtract */\r\n\r\n/* ------------------------ GL_EXT_clip_volume_hint ------------------------ */\r\n\r\n#ifndef GL_EXT_clip_volume_hint\r\n#define GL_EXT_clip_volume_hint 1\r\n\r\n#define GL_CLIP_VOLUME_CLIPPING_HINT_EXT 0x80F0\r\n\r\n#define GLEW_EXT_clip_volume_hint GLEW_GET_VAR(__GLEW_EXT_clip_volume_hint)\r\n\r\n#endif /* GL_EXT_clip_volume_hint */\r\n\r\n/* ------------------------------ GL_EXT_cmyka ----------------------------- */\r\n\r\n#ifndef GL_EXT_cmyka\r\n#define GL_EXT_cmyka 1\r\n\r\n#define GL_CMYK_EXT 0x800C\r\n#define GL_CMYKA_EXT 0x800D\r\n#define GL_PACK_CMYK_HINT_EXT 0x800E\r\n#define GL_UNPACK_CMYK_HINT_EXT 0x800F\r\n\r\n#define GLEW_EXT_cmyka GLEW_GET_VAR(__GLEW_EXT_cmyka)\r\n\r\n#endif /* GL_EXT_cmyka */\r\n\r\n/* ------------------------- GL_EXT_color_subtable ------------------------- */\r\n\r\n#ifndef GL_EXT_color_subtable\r\n#define GL_EXT_color_subtable 1\r\n\r\ntypedef void (GLAPIENTRY * PFNGLCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const void *data);\r\ntypedef void (GLAPIENTRY * PFNGLCOPYCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width);\r\n\r\n#define glColorSubTableEXT GLEW_GET_FUN(__glewColorSubTableEXT)\r\n#define glCopyColorSubTableEXT GLEW_GET_FUN(__glewCopyColorSubTableEXT)\r\n\r\n#define GLEW_EXT_color_subtable GLEW_GET_VAR(__GLEW_EXT_color_subtable)\r\n\r\n#endif /* GL_EXT_color_subtable */\r\n\r\n/* ---------------------- GL_EXT_compiled_vertex_array --------------------- */\r\n\r\n#ifndef GL_EXT_compiled_vertex_array\r\n#define GL_EXT_compiled_vertex_array 1\r\n\r\n#define GL_ARRAY_ELEMENT_LOCK_FIRST_EXT 0x81A8\r\n#define GL_ARRAY_ELEMENT_LOCK_COUNT_EXT 0x81A9\r\n\r\ntypedef void (GLAPIENTRY * PFNGLLOCKARRAYSEXTPROC) (GLint first, GLsizei count);\r\ntypedef void (GLAPIENTRY * PFNGLUNLOCKARRAYSEXTPROC) (void);\r\n\r\n#define glLockArraysEXT GLEW_GET_FUN(__glewLockArraysEXT)\r\n#define glUnlockArraysEXT GLEW_GET_FUN(__glewUnlockArraysEXT)\r\n\r\n#define GLEW_EXT_compiled_vertex_array GLEW_GET_VAR(__GLEW_EXT_compiled_vertex_array)\r\n\r\n#endif /* GL_EXT_compiled_vertex_array */\r\n\r\n/* --------------------------- GL_EXT_convolution -------------------------- */\r\n\r\n#ifndef GL_EXT_convolution\r\n#define GL_EXT_convolution 1\r\n\r\n#define GL_CONVOLUTION_1D_EXT 0x8010\r\n#define GL_CONVOLUTION_2D_EXT 0x8011\r\n#define GL_SEPARABLE_2D_EXT 0x8012\r\n#define GL_CONVOLUTION_BORDER_MODE_EXT 0x8013\r\n#define GL_CONVOLUTION_FILTER_SCALE_EXT 0x8014\r\n#define GL_CONVOLUTION_FILTER_BIAS_EXT 0x8015\r\n#define GL_REDUCE_EXT 0x8016\r\n#define GL_CONVOLUTION_FORMAT_EXT 0x8017\r\n#define GL_CONVOLUTION_WIDTH_EXT 0x8018\r\n#define GL_CONVOLUTION_HEIGHT_EXT 0x8019\r\n#define GL_MAX_CONVOLUTION_WIDTH_EXT 0x801A\r\n#define GL_MAX_CONVOLUTION_HEIGHT_EXT 0x801B\r\n#define GL_POST_CONVOLUTION_RED_SCALE_EXT 0x801C\r\n#define GL_POST_CONVOLUTION_GREEN_SCALE_EXT 0x801D\r\n#define GL_POST_CONVOLUTION_BLUE_SCALE_EXT 0x801E\r\n#define GL_POST_CONVOLUTION_ALPHA_SCALE_EXT 0x801F\r\n#define GL_POST_CONVOLUTION_RED_BIAS_EXT 0x8020\r\n#define GL_POST_CONVOLUTION_GREEN_BIAS_EXT 0x8021\r\n#define GL_POST_CONVOLUTION_BLUE_BIAS_EXT 0x8022\r\n#define GL_POST_CONVOLUTION_ALPHA_BIAS_EXT 0x8023\r\n\r\ntypedef void (GLAPIENTRY * PFNGLCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *image);\r\ntypedef void (GLAPIENTRY * PFNGLCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *image);\r\ntypedef void (GLAPIENTRY * PFNGLCONVOLUTIONPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat param);\r\ntypedef void (GLAPIENTRY * PFNGLCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat* params);\r\ntypedef void (GLAPIENTRY * PFNGLCONVOLUTIONPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint param);\r\ntypedef void (GLAPIENTRY * PFNGLCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint* params);\r\ntypedef void (GLAPIENTRY * PFNGLCOPYCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width);\r\ntypedef void (GLAPIENTRY * PFNGLCOPYCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height);\r\ntypedef void (GLAPIENTRY * PFNGLGETCONVOLUTIONFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, void *image);\r\ntypedef void (GLAPIENTRY * PFNGLGETCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETSEPARABLEFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, void *row, void *column, void *span);\r\ntypedef void (GLAPIENTRY * PFNGLSEPARABLEFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *row, const void *column);\r\n\r\n#define glConvolutionFilter1DEXT GLEW_GET_FUN(__glewConvolutionFilter1DEXT)\r\n#define glConvolutionFilter2DEXT GLEW_GET_FUN(__glewConvolutionFilter2DEXT)\r\n#define glConvolutionParameterfEXT GLEW_GET_FUN(__glewConvolutionParameterfEXT)\r\n#define glConvolutionParameterfvEXT GLEW_GET_FUN(__glewConvolutionParameterfvEXT)\r\n#define glConvolutionParameteriEXT GLEW_GET_FUN(__glewConvolutionParameteriEXT)\r\n#define glConvolutionParameterivEXT GLEW_GET_FUN(__glewConvolutionParameterivEXT)\r\n#define glCopyConvolutionFilter1DEXT GLEW_GET_FUN(__glewCopyConvolutionFilter1DEXT)\r\n#define glCopyConvolutionFilter2DEXT GLEW_GET_FUN(__glewCopyConvolutionFilter2DEXT)\r\n#define glGetConvolutionFilterEXT GLEW_GET_FUN(__glewGetConvolutionFilterEXT)\r\n#define glGetConvolutionParameterfvEXT GLEW_GET_FUN(__glewGetConvolutionParameterfvEXT)\r\n#define glGetConvolutionParameterivEXT GLEW_GET_FUN(__glewGetConvolutionParameterivEXT)\r\n#define glGetSeparableFilterEXT GLEW_GET_FUN(__glewGetSeparableFilterEXT)\r\n#define glSeparableFilter2DEXT GLEW_GET_FUN(__glewSeparableFilter2DEXT)\r\n\r\n#define GLEW_EXT_convolution GLEW_GET_VAR(__GLEW_EXT_convolution)\r\n\r\n#endif /* GL_EXT_convolution */\r\n\r\n/* ------------------------ GL_EXT_coordinate_frame ------------------------ */\r\n\r\n#ifndef GL_EXT_coordinate_frame\r\n#define GL_EXT_coordinate_frame 1\r\n\r\n#define GL_TANGENT_ARRAY_EXT 0x8439\r\n#define GL_BINORMAL_ARRAY_EXT 0x843A\r\n#define GL_CURRENT_TANGENT_EXT 0x843B\r\n#define GL_CURRENT_BINORMAL_EXT 0x843C\r\n#define GL_TANGENT_ARRAY_TYPE_EXT 0x843E\r\n#define GL_TANGENT_ARRAY_STRIDE_EXT 0x843F\r\n#define GL_BINORMAL_ARRAY_TYPE_EXT 0x8440\r\n#define GL_BINORMAL_ARRAY_STRIDE_EXT 0x8441\r\n#define GL_TANGENT_ARRAY_POINTER_EXT 0x8442\r\n#define GL_BINORMAL_ARRAY_POINTER_EXT 0x8443\r\n#define GL_MAP1_TANGENT_EXT 0x8444\r\n#define GL_MAP2_TANGENT_EXT 0x8445\r\n#define GL_MAP1_BINORMAL_EXT 0x8446\r\n#define GL_MAP2_BINORMAL_EXT 0x8447\r\n\r\ntypedef void (GLAPIENTRY * PFNGLBINORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, void *pointer);\r\ntypedef void (GLAPIENTRY * PFNGLTANGENTPOINTEREXTPROC) (GLenum type, GLsizei stride, void *pointer);\r\n\r\n#define glBinormalPointerEXT GLEW_GET_FUN(__glewBinormalPointerEXT)\r\n#define glTangentPointerEXT GLEW_GET_FUN(__glewTangentPointerEXT)\r\n\r\n#define GLEW_EXT_coordinate_frame GLEW_GET_VAR(__GLEW_EXT_coordinate_frame)\r\n\r\n#endif /* GL_EXT_coordinate_frame */\r\n\r\n/* -------------------------- GL_EXT_copy_texture -------------------------- */\r\n\r\n#ifndef GL_EXT_copy_texture\r\n#define GL_EXT_copy_texture 1\r\n\r\ntypedef void (GLAPIENTRY * PFNGLCOPYTEXIMAGE1DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border);\r\ntypedef void (GLAPIENTRY * PFNGLCOPYTEXIMAGE2DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);\r\ntypedef void (GLAPIENTRY * PFNGLCOPYTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width);\r\ntypedef void (GLAPIENTRY * PFNGLCOPYTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);\r\ntypedef void (GLAPIENTRY * PFNGLCOPYTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);\r\n\r\n#define glCopyTexImage1DEXT GLEW_GET_FUN(__glewCopyTexImage1DEXT)\r\n#define glCopyTexImage2DEXT GLEW_GET_FUN(__glewCopyTexImage2DEXT)\r\n#define glCopyTexSubImage1DEXT GLEW_GET_FUN(__glewCopyTexSubImage1DEXT)\r\n#define glCopyTexSubImage2DEXT GLEW_GET_FUN(__glewCopyTexSubImage2DEXT)\r\n#define glCopyTexSubImage3DEXT GLEW_GET_FUN(__glewCopyTexSubImage3DEXT)\r\n\r\n#define GLEW_EXT_copy_texture GLEW_GET_VAR(__GLEW_EXT_copy_texture)\r\n\r\n#endif /* GL_EXT_copy_texture */\r\n\r\n/* --------------------------- GL_EXT_cull_vertex -------------------------- */\r\n\r\n#ifndef GL_EXT_cull_vertex\r\n#define GL_EXT_cull_vertex 1\r\n\r\n#define GL_CULL_VERTEX_EXT 0x81AA\r\n#define GL_CULL_VERTEX_EYE_POSITION_EXT 0x81AB\r\n#define GL_CULL_VERTEX_OBJECT_POSITION_EXT 0x81AC\r\n\r\ntypedef void (GLAPIENTRY * PFNGLCULLPARAMETERDVEXTPROC) (GLenum pname, GLdouble* params);\r\ntypedef void (GLAPIENTRY * PFNGLCULLPARAMETERFVEXTPROC) (GLenum pname, GLfloat* params);\r\n\r\n#define glCullParameterdvEXT GLEW_GET_FUN(__glewCullParameterdvEXT)\r\n#define glCullParameterfvEXT GLEW_GET_FUN(__glewCullParameterfvEXT)\r\n\r\n#define GLEW_EXT_cull_vertex GLEW_GET_VAR(__GLEW_EXT_cull_vertex)\r\n\r\n#endif /* GL_EXT_cull_vertex */\r\n\r\n/* --------------------------- GL_EXT_debug_label -------------------------- */\r\n\r\n#ifndef GL_EXT_debug_label\r\n#define GL_EXT_debug_label 1\r\n\r\n#define GL_PROGRAM_PIPELINE_OBJECT_EXT 0x8A4F\r\n#define GL_PROGRAM_OBJECT_EXT 0x8B40\r\n#define GL_SHADER_OBJECT_EXT 0x8B48\r\n#define GL_BUFFER_OBJECT_EXT 0x9151\r\n#define GL_QUERY_OBJECT_EXT 0x9153\r\n#define GL_VERTEX_ARRAY_OBJECT_EXT 0x9154\r\n\r\ntypedef void (GLAPIENTRY * PFNGLGETOBJECTLABELEXTPROC) (GLenum type, GLuint object, GLsizei bufSize, GLsizei* length, GLchar *label);\r\ntypedef void (GLAPIENTRY * PFNGLLABELOBJECTEXTPROC) (GLenum type, GLuint object, GLsizei length, const GLchar* label);\r\n\r\n#define glGetObjectLabelEXT GLEW_GET_FUN(__glewGetObjectLabelEXT)\r\n#define glLabelObjectEXT GLEW_GET_FUN(__glewLabelObjectEXT)\r\n\r\n#define GLEW_EXT_debug_label GLEW_GET_VAR(__GLEW_EXT_debug_label)\r\n\r\n#endif /* GL_EXT_debug_label */\r\n\r\n/* -------------------------- GL_EXT_debug_marker -------------------------- */\r\n\r\n#ifndef GL_EXT_debug_marker\r\n#define GL_EXT_debug_marker 1\r\n\r\ntypedef void (GLAPIENTRY * PFNGLINSERTEVENTMARKEREXTPROC) (GLsizei length, const GLchar* marker);\r\ntypedef void (GLAPIENTRY * PFNGLPOPGROUPMARKEREXTPROC) (void);\r\ntypedef void (GLAPIENTRY * PFNGLPUSHGROUPMARKEREXTPROC) (GLsizei length, const GLchar* marker);\r\n\r\n#define glInsertEventMarkerEXT GLEW_GET_FUN(__glewInsertEventMarkerEXT)\r\n#define glPopGroupMarkerEXT GLEW_GET_FUN(__glewPopGroupMarkerEXT)\r\n#define glPushGroupMarkerEXT GLEW_GET_FUN(__glewPushGroupMarkerEXT)\r\n\r\n#define GLEW_EXT_debug_marker GLEW_GET_VAR(__GLEW_EXT_debug_marker)\r\n\r\n#endif /* GL_EXT_debug_marker */\r\n\r\n/* ------------------------ GL_EXT_depth_bounds_test ----------------------- */\r\n\r\n#ifndef GL_EXT_depth_bounds_test\r\n#define GL_EXT_depth_bounds_test 1\r\n\r\n#define GL_DEPTH_BOUNDS_TEST_EXT 0x8890\r\n#define GL_DEPTH_BOUNDS_EXT 0x8891\r\n\r\ntypedef void (GLAPIENTRY * PFNGLDEPTHBOUNDSEXTPROC) (GLclampd zmin, GLclampd zmax);\r\n\r\n#define glDepthBoundsEXT GLEW_GET_FUN(__glewDepthBoundsEXT)\r\n\r\n#define GLEW_EXT_depth_bounds_test GLEW_GET_VAR(__GLEW_EXT_depth_bounds_test)\r\n\r\n#endif /* GL_EXT_depth_bounds_test */\r\n\r\n/* ----------------------- GL_EXT_direct_state_access ---------------------- */\r\n\r\n#ifndef GL_EXT_direct_state_access\r\n#define GL_EXT_direct_state_access 1\r\n\r\n#define GL_PROGRAM_MATRIX_EXT 0x8E2D\r\n#define GL_TRANSPOSE_PROGRAM_MATRIX_EXT 0x8E2E\r\n#define GL_PROGRAM_MATRIX_STACK_DEPTH_EXT 0x8E2F\r\n\r\ntypedef void (GLAPIENTRY * PFNGLBINDMULTITEXTUREEXTPROC) (GLenum texunit, GLenum target, GLuint texture);\r\ntypedef GLenum (GLAPIENTRY * PFNGLCHECKNAMEDFRAMEBUFFERSTATUSEXTPROC) (GLuint framebuffer, GLenum target);\r\ntypedef void (GLAPIENTRY * PFNGLCLIENTATTRIBDEFAULTEXTPROC) (GLbitfield mask);\r\ntypedef void (GLAPIENTRY * PFNGLCOMPRESSEDMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *data);\r\ntypedef void (GLAPIENTRY * PFNGLCOMPRESSEDMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data);\r\ntypedef void (GLAPIENTRY * PFNGLCOMPRESSEDMULTITEXIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data);\r\ntypedef void (GLAPIENTRY * PFNGLCOMPRESSEDMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data);\r\ntypedef void (GLAPIENTRY * PFNGLCOMPRESSEDMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data);\r\ntypedef void (GLAPIENTRY * PFNGLCOMPRESSEDMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data);\r\ntypedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *data);\r\ntypedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data);\r\ntypedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXTUREIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data);\r\ntypedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data);\r\ntypedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data);\r\ntypedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data);\r\ntypedef void (GLAPIENTRY * PFNGLCOPYMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border);\r\ntypedef void (GLAPIENTRY * PFNGLCOPYMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);\r\ntypedef void (GLAPIENTRY * PFNGLCOPYMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width);\r\ntypedef void (GLAPIENTRY * PFNGLCOPYMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);\r\ntypedef void (GLAPIENTRY * PFNGLCOPYMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);\r\ntypedef void (GLAPIENTRY * PFNGLCOPYTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border);\r\ntypedef void (GLAPIENTRY * PFNGLCOPYTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);\r\ntypedef void (GLAPIENTRY * PFNGLCOPYTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width);\r\ntypedef void (GLAPIENTRY * PFNGLCOPYTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);\r\ntypedef void (GLAPIENTRY * PFNGLCOPYTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);\r\ntypedef void (GLAPIENTRY * PFNGLDISABLECLIENTSTATEINDEXEDEXTPROC) (GLenum array, GLuint index);\r\ntypedef void (GLAPIENTRY * PFNGLDISABLECLIENTSTATEIEXTPROC) (GLenum array, GLuint index);\r\ntypedef void (GLAPIENTRY * PFNGLDISABLEVERTEXARRAYATTRIBEXTPROC) (GLuint vaobj, GLuint index);\r\ntypedef void (GLAPIENTRY * PFNGLDISABLEVERTEXARRAYEXTPROC) (GLuint vaobj, GLenum array);\r\ntypedef void (GLAPIENTRY * PFNGLENABLECLIENTSTATEINDEXEDEXTPROC) (GLenum array, GLuint index);\r\ntypedef void (GLAPIENTRY * PFNGLENABLECLIENTSTATEIEXTPROC) (GLenum array, GLuint index);\r\ntypedef void (GLAPIENTRY * PFNGLENABLEVERTEXARRAYATTRIBEXTPROC) (GLuint vaobj, GLuint index);\r\ntypedef void (GLAPIENTRY * PFNGLENABLEVERTEXARRAYEXTPROC) (GLuint vaobj, GLenum array);\r\ntypedef void (GLAPIENTRY * PFNGLFLUSHMAPPEDNAMEDBUFFERRANGEEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length);\r\ntypedef void (GLAPIENTRY * PFNGLFRAMEBUFFERDRAWBUFFEREXTPROC) (GLuint framebuffer, GLenum mode);\r\ntypedef void (GLAPIENTRY * PFNGLFRAMEBUFFERDRAWBUFFERSEXTPROC) (GLuint framebuffer, GLsizei n, const GLenum* bufs);\r\ntypedef void (GLAPIENTRY * PFNGLFRAMEBUFFERREADBUFFEREXTPROC) (GLuint framebuffer, GLenum mode);\r\ntypedef void (GLAPIENTRY * PFNGLGENERATEMULTITEXMIPMAPEXTPROC) (GLenum texunit, GLenum target);\r\ntypedef void (GLAPIENTRY * PFNGLGENERATETEXTUREMIPMAPEXTPROC) (GLuint texture, GLenum target);\r\ntypedef void (GLAPIENTRY * PFNGLGETCOMPRESSEDMULTITEXIMAGEEXTPROC) (GLenum texunit, GLenum target, GLint level, void *img);\r\ntypedef void (GLAPIENTRY * PFNGLGETCOMPRESSEDTEXTUREIMAGEEXTPROC) (GLuint texture, GLenum target, GLint level, void *img);\r\ntypedef void (GLAPIENTRY * PFNGLGETDOUBLEINDEXEDVEXTPROC) (GLenum target, GLuint index, GLdouble* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETDOUBLEI_VEXTPROC) (GLenum pname, GLuint index, GLdouble* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETFLOATINDEXEDVEXTPROC) (GLenum target, GLuint index, GLfloat* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETFLOATI_VEXTPROC) (GLenum pname, GLuint index, GLfloat* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETFRAMEBUFFERPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum pname, GLint* param);\r\ntypedef void (GLAPIENTRY * PFNGLGETMULTITEXENVFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETMULTITEXENVIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETMULTITEXGENDVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLdouble* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETMULTITEXGENFVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLfloat* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETMULTITEXGENIVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLint* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETMULTITEXIMAGEEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum format, GLenum type, void *pixels);\r\ntypedef void (GLAPIENTRY * PFNGLGETMULTITEXLEVELPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum pname, GLfloat* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETMULTITEXLEVELPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum pname, GLint* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETMULTITEXPARAMETERIIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETMULTITEXPARAMETERIUIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLuint* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETMULTITEXPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETMULTITEXPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETNAMEDBUFFERPARAMETERIVEXTPROC) (GLuint buffer, GLenum pname, GLint* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETNAMEDBUFFERPOINTERVEXTPROC) (GLuint buffer, GLenum pname, void** params);\r\ntypedef void (GLAPIENTRY * PFNGLGETNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, void *data);\r\ntypedef void (GLAPIENTRY * PFNGLGETNAMEDFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum pname, GLint* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETNAMEDPROGRAMLOCALPARAMETERIIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLint* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETNAMEDPROGRAMLOCALPARAMETERIUIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLuint* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETNAMEDPROGRAMLOCALPARAMETERDVEXTPROC) (GLuint program, GLenum target, GLuint index, GLdouble* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETNAMEDPROGRAMLOCALPARAMETERFVEXTPROC) (GLuint program, GLenum target, GLuint index, GLfloat* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETNAMEDPROGRAMSTRINGEXTPROC) (GLuint program, GLenum target, GLenum pname, void *string);\r\ntypedef void (GLAPIENTRY * PFNGLGETNAMEDPROGRAMIVEXTPROC) (GLuint program, GLenum target, GLenum pname, GLint* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETNAMEDRENDERBUFFERPARAMETERIVEXTPROC) (GLuint renderbuffer, GLenum pname, GLint* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETPOINTERINDEXEDVEXTPROC) (GLenum target, GLuint index, void** params);\r\ntypedef void (GLAPIENTRY * PFNGLGETPOINTERI_VEXTPROC) (GLenum pname, GLuint index, void** params);\r\ntypedef void (GLAPIENTRY * PFNGLGETTEXTUREIMAGEEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum format, GLenum type, void *pixels);\r\ntypedef void (GLAPIENTRY * PFNGLGETTEXTURELEVELPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum pname, GLfloat* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETTEXTURELEVELPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum pname, GLint* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETTEXTUREPARAMETERIIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETTEXTUREPARAMETERIUIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLuint* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETTEXTUREPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLfloat* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETTEXTUREPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETVERTEXARRAYINTEGERI_VEXTPROC) (GLuint vaobj, GLuint index, GLenum pname, GLint* param);\r\ntypedef void (GLAPIENTRY * PFNGLGETVERTEXARRAYINTEGERVEXTPROC) (GLuint vaobj, GLenum pname, GLint* param);\r\ntypedef void (GLAPIENTRY * PFNGLGETVERTEXARRAYPOINTERI_VEXTPROC) (GLuint vaobj, GLuint index, GLenum pname, void** param);\r\ntypedef void (GLAPIENTRY * PFNGLGETVERTEXARRAYPOINTERVEXTPROC) (GLuint vaobj, GLenum pname, void** param);\r\ntypedef void * (GLAPIENTRY * PFNGLMAPNAMEDBUFFEREXTPROC) (GLuint buffer, GLenum access);\r\ntypedef void * (GLAPIENTRY * PFNGLMAPNAMEDBUFFERRANGEEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access);\r\ntypedef void (GLAPIENTRY * PFNGLMATRIXFRUSTUMEXTPROC) (GLenum matrixMode, GLdouble l, GLdouble r, GLdouble b, GLdouble t, GLdouble n, GLdouble f);\r\ntypedef void (GLAPIENTRY * PFNGLMATRIXLOADIDENTITYEXTPROC) (GLenum matrixMode);\r\ntypedef void (GLAPIENTRY * PFNGLMATRIXLOADTRANSPOSEDEXTPROC) (GLenum matrixMode, const GLdouble* m);\r\ntypedef void (GLAPIENTRY * PFNGLMATRIXLOADTRANSPOSEFEXTPROC) (GLenum matrixMode, const GLfloat* m);\r\ntypedef void (GLAPIENTRY * PFNGLMATRIXLOADDEXTPROC) (GLenum matrixMode, const GLdouble* m);\r\ntypedef void (GLAPIENTRY * PFNGLMATRIXLOADFEXTPROC) (GLenum matrixMode, const GLfloat* m);\r\ntypedef void (GLAPIENTRY * PFNGLMATRIXMULTTRANSPOSEDEXTPROC) (GLenum matrixMode, const GLdouble* m);\r\ntypedef void (GLAPIENTRY * PFNGLMATRIXMULTTRANSPOSEFEXTPROC) (GLenum matrixMode, const GLfloat* m);\r\ntypedef void (GLAPIENTRY * PFNGLMATRIXMULTDEXTPROC) (GLenum matrixMode, const GLdouble* m);\r\ntypedef void (GLAPIENTRY * PFNGLMATRIXMULTFEXTPROC) (GLenum matrixMode, const GLfloat* m);\r\ntypedef void (GLAPIENTRY * PFNGLMATRIXORTHOEXTPROC) (GLenum matrixMode, GLdouble l, GLdouble r, GLdouble b, GLdouble t, GLdouble n, GLdouble f);\r\ntypedef void (GLAPIENTRY * PFNGLMATRIXPOPEXTPROC) (GLenum matrixMode);\r\ntypedef void (GLAPIENTRY * PFNGLMATRIXPUSHEXTPROC) (GLenum matrixMode);\r\ntypedef void (GLAPIENTRY * PFNGLMATRIXROTATEDEXTPROC) (GLenum matrixMode, GLdouble angle, GLdouble x, GLdouble y, GLdouble z);\r\ntypedef void (GLAPIENTRY * PFNGLMATRIXROTATEFEXTPROC) (GLenum matrixMode, GLfloat angle, GLfloat x, GLfloat y, GLfloat z);\r\ntypedef void (GLAPIENTRY * PFNGLMATRIXSCALEDEXTPROC) (GLenum matrixMode, GLdouble x, GLdouble y, GLdouble z);\r\ntypedef void (GLAPIENTRY * PFNGLMATRIXSCALEFEXTPROC) (GLenum matrixMode, GLfloat x, GLfloat y, GLfloat z);\r\ntypedef void (GLAPIENTRY * PFNGLMATRIXTRANSLATEDEXTPROC) (GLenum matrixMode, GLdouble x, GLdouble y, GLdouble z);\r\ntypedef void (GLAPIENTRY * PFNGLMATRIXTRANSLATEFEXTPROC) (GLenum matrixMode, GLfloat x, GLfloat y, GLfloat z);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXBUFFEREXTPROC) (GLenum texunit, GLenum target, GLenum internalformat, GLuint buffer);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORDPOINTEREXTPROC) (GLenum texunit, GLint size, GLenum type, GLsizei stride, const void *pointer);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXENVFEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat param);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXENVFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLfloat* params);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXENVIEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint param);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXENVIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint* params);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXGENDEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLdouble param);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXGENDVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLdouble* params);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXGENFEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLfloat param);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXGENFVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLfloat* params);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXGENIEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLint param);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXGENIVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLint* params);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void *pixels);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXPARAMETERIIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint* params);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXPARAMETERIUIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLuint* params);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXPARAMETERFEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat param);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLfloat* param);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXPARAMETERIEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint param);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint* param);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXRENDERBUFFEREXTPROC) (GLenum texunit, GLenum target, GLuint renderbuffer);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels);\r\ntypedef void (GLAPIENTRY * PFNGLNAMEDBUFFERDATAEXTPROC) (GLuint buffer, GLsizeiptr size, const void *data, GLenum usage);\r\ntypedef void (GLAPIENTRY * PFNGLNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data);\r\ntypedef void (GLAPIENTRY * PFNGLNAMEDCOPYBUFFERSUBDATAEXTPROC) (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size);\r\ntypedef void (GLAPIENTRY * PFNGLNAMEDFRAMEBUFFERRENDERBUFFEREXTPROC) (GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);\r\ntypedef void (GLAPIENTRY * PFNGLNAMEDFRAMEBUFFERTEXTURE1DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level);\r\ntypedef void (GLAPIENTRY * PFNGLNAMEDFRAMEBUFFERTEXTURE2DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level);\r\ntypedef void (GLAPIENTRY * PFNGLNAMEDFRAMEBUFFERTEXTURE3DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset);\r\ntypedef void (GLAPIENTRY * PFNGLNAMEDFRAMEBUFFERTEXTUREEXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level);\r\ntypedef void (GLAPIENTRY * PFNGLNAMEDFRAMEBUFFERTEXTUREFACEEXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLenum face);\r\ntypedef void (GLAPIENTRY * PFNGLNAMEDFRAMEBUFFERTEXTURELAYEREXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer);\r\ntypedef void (GLAPIENTRY * PFNGLNAMEDPROGRAMLOCALPARAMETER4DEXTPROC) (GLuint program, GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);\r\ntypedef void (GLAPIENTRY * PFNGLNAMEDPROGRAMLOCALPARAMETER4DVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLdouble* params);\r\ntypedef void (GLAPIENTRY * PFNGLNAMEDPROGRAMLOCALPARAMETER4FEXTPROC) (GLuint program, GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);\r\ntypedef void (GLAPIENTRY * PFNGLNAMEDPROGRAMLOCALPARAMETER4FVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLfloat* params);\r\ntypedef void (GLAPIENTRY * PFNGLNAMEDPROGRAMLOCALPARAMETERI4IEXTPROC) (GLuint program, GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w);\r\ntypedef void (GLAPIENTRY * PFNGLNAMEDPROGRAMLOCALPARAMETERI4IVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLint* params);\r\ntypedef void (GLAPIENTRY * PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIEXTPROC) (GLuint program, GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w);\r\ntypedef void (GLAPIENTRY * PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLuint* params);\r\ntypedef void (GLAPIENTRY * PFNGLNAMEDPROGRAMLOCALPARAMETERS4FVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLfloat* params);\r\ntypedef void (GLAPIENTRY * PFNGLNAMEDPROGRAMLOCALPARAMETERSI4IVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLint* params);\r\ntypedef void (GLAPIENTRY * PFNGLNAMEDPROGRAMLOCALPARAMETERSI4UIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLuint* params);\r\ntypedef void (GLAPIENTRY * PFNGLNAMEDPROGRAMSTRINGEXTPROC) (GLuint program, GLenum target, GLenum format, GLsizei len, const void *string);\r\ntypedef void (GLAPIENTRY * PFNGLNAMEDRENDERBUFFERSTORAGEEXTPROC) (GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height);\r\ntypedef void (GLAPIENTRY * PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLECOVERAGEEXTPROC) (GLuint renderbuffer, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height);\r\ntypedef void (GLAPIENTRY * PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1FEXTPROC) (GLuint program, GLint location, GLfloat v0);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat* value);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1IEXTPROC) (GLuint program, GLint location, GLint v0);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint* value);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1UIEXTPROC) (GLuint program, GLint location, GLuint v0);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint* value);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat* value);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint* value);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint* value);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat* value);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint* value);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint* value);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat* value);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint* value);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint* value);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX2X3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX2X4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX3X2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX3X4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX4X2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX4X3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);\r\ntypedef void (GLAPIENTRY * PFNGLPUSHCLIENTATTRIBDEFAULTEXTPROC) (GLbitfield mask);\r\ntypedef void (GLAPIENTRY * PFNGLTEXTUREBUFFEREXTPROC) (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer);\r\ntypedef void (GLAPIENTRY * PFNGLTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void *pixels);\r\ntypedef void (GLAPIENTRY * PFNGLTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels);\r\ntypedef void (GLAPIENTRY * PFNGLTEXTUREIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels);\r\ntypedef void (GLAPIENTRY * PFNGLTEXTUREPARAMETERIIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLint* params);\r\ntypedef void (GLAPIENTRY * PFNGLTEXTUREPARAMETERIUIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLuint* params);\r\ntypedef void (GLAPIENTRY * PFNGLTEXTUREPARAMETERFEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLfloat param);\r\ntypedef void (GLAPIENTRY * PFNGLTEXTUREPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLfloat* param);\r\ntypedef void (GLAPIENTRY * PFNGLTEXTUREPARAMETERIEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint param);\r\ntypedef void (GLAPIENTRY * PFNGLTEXTUREPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLint* param);\r\ntypedef void (GLAPIENTRY * PFNGLTEXTURERENDERBUFFEREXTPROC) (GLuint texture, GLenum target, GLuint renderbuffer);\r\ntypedef void (GLAPIENTRY * PFNGLTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels);\r\ntypedef void (GLAPIENTRY * PFNGLTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels);\r\ntypedef void (GLAPIENTRY * PFNGLTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels);\r\ntypedef GLboolean (GLAPIENTRY * PFNGLUNMAPNAMEDBUFFEREXTPROC) (GLuint buffer);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXARRAYCOLOROFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXARRAYEDGEFLAGOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLsizei stride, GLintptr offset);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXARRAYFOGCOORDOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXARRAYINDEXOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXARRAYMULTITEXCOORDOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLenum texunit, GLint size, GLenum type, GLsizei stride, GLintptr offset);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXARRAYNORMALOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXARRAYSECONDARYCOLOROFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXARRAYTEXCOORDOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXARRAYVERTEXATTRIBDIVISOREXTPROC) (GLuint vaobj, GLuint index, GLuint divisor);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXARRAYVERTEXATTRIBIOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXARRAYVERTEXATTRIBOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLintptr offset);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXARRAYVERTEXOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset);\r\n\r\n#define glBindMultiTextureEXT GLEW_GET_FUN(__glewBindMultiTextureEXT)\r\n#define glCheckNamedFramebufferStatusEXT GLEW_GET_FUN(__glewCheckNamedFramebufferStatusEXT)\r\n#define glClientAttribDefaultEXT GLEW_GET_FUN(__glewClientAttribDefaultEXT)\r\n#define glCompressedMultiTexImage1DEXT GLEW_GET_FUN(__glewCompressedMultiTexImage1DEXT)\r\n#define glCompressedMultiTexImage2DEXT GLEW_GET_FUN(__glewCompressedMultiTexImage2DEXT)\r\n#define glCompressedMultiTexImage3DEXT GLEW_GET_FUN(__glewCompressedMultiTexImage3DEXT)\r\n#define glCompressedMultiTexSubImage1DEXT GLEW_GET_FUN(__glewCompressedMultiTexSubImage1DEXT)\r\n#define glCompressedMultiTexSubImage2DEXT GLEW_GET_FUN(__glewCompressedMultiTexSubImage2DEXT)\r\n#define glCompressedMultiTexSubImage3DEXT GLEW_GET_FUN(__glewCompressedMultiTexSubImage3DEXT)\r\n#define glCompressedTextureImage1DEXT GLEW_GET_FUN(__glewCompressedTextureImage1DEXT)\r\n#define glCompressedTextureImage2DEXT GLEW_GET_FUN(__glewCompressedTextureImage2DEXT)\r\n#define glCompressedTextureImage3DEXT GLEW_GET_FUN(__glewCompressedTextureImage3DEXT)\r\n#define glCompressedTextureSubImage1DEXT GLEW_GET_FUN(__glewCompressedTextureSubImage1DEXT)\r\n#define glCompressedTextureSubImage2DEXT GLEW_GET_FUN(__glewCompressedTextureSubImage2DEXT)\r\n#define glCompressedTextureSubImage3DEXT GLEW_GET_FUN(__glewCompressedTextureSubImage3DEXT)\r\n#define glCopyMultiTexImage1DEXT GLEW_GET_FUN(__glewCopyMultiTexImage1DEXT)\r\n#define glCopyMultiTexImage2DEXT GLEW_GET_FUN(__glewCopyMultiTexImage2DEXT)\r\n#define glCopyMultiTexSubImage1DEXT GLEW_GET_FUN(__glewCopyMultiTexSubImage1DEXT)\r\n#define glCopyMultiTexSubImage2DEXT GLEW_GET_FUN(__glewCopyMultiTexSubImage2DEXT)\r\n#define glCopyMultiTexSubImage3DEXT GLEW_GET_FUN(__glewCopyMultiTexSubImage3DEXT)\r\n#define glCopyTextureImage1DEXT GLEW_GET_FUN(__glewCopyTextureImage1DEXT)\r\n#define glCopyTextureImage2DEXT GLEW_GET_FUN(__glewCopyTextureImage2DEXT)\r\n#define glCopyTextureSubImage1DEXT GLEW_GET_FUN(__glewCopyTextureSubImage1DEXT)\r\n#define glCopyTextureSubImage2DEXT GLEW_GET_FUN(__glewCopyTextureSubImage2DEXT)\r\n#define glCopyTextureSubImage3DEXT GLEW_GET_FUN(__glewCopyTextureSubImage3DEXT)\r\n#define glDisableClientStateIndexedEXT GLEW_GET_FUN(__glewDisableClientStateIndexedEXT)\r\n#define glDisableClientStateiEXT GLEW_GET_FUN(__glewDisableClientStateiEXT)\r\n#define glDisableVertexArrayAttribEXT GLEW_GET_FUN(__glewDisableVertexArrayAttribEXT)\r\n#define glDisableVertexArrayEXT GLEW_GET_FUN(__glewDisableVertexArrayEXT)\r\n#define glEnableClientStateIndexedEXT GLEW_GET_FUN(__glewEnableClientStateIndexedEXT)\r\n#define glEnableClientStateiEXT GLEW_GET_FUN(__glewEnableClientStateiEXT)\r\n#define glEnableVertexArrayAttribEXT GLEW_GET_FUN(__glewEnableVertexArrayAttribEXT)\r\n#define glEnableVertexArrayEXT GLEW_GET_FUN(__glewEnableVertexArrayEXT)\r\n#define glFlushMappedNamedBufferRangeEXT GLEW_GET_FUN(__glewFlushMappedNamedBufferRangeEXT)\r\n#define glFramebufferDrawBufferEXT GLEW_GET_FUN(__glewFramebufferDrawBufferEXT)\r\n#define glFramebufferDrawBuffersEXT GLEW_GET_FUN(__glewFramebufferDrawBuffersEXT)\r\n#define glFramebufferReadBufferEXT GLEW_GET_FUN(__glewFramebufferReadBufferEXT)\r\n#define glGenerateMultiTexMipmapEXT GLEW_GET_FUN(__glewGenerateMultiTexMipmapEXT)\r\n#define glGenerateTextureMipmapEXT GLEW_GET_FUN(__glewGenerateTextureMipmapEXT)\r\n#define glGetCompressedMultiTexImageEXT GLEW_GET_FUN(__glewGetCompressedMultiTexImageEXT)\r\n#define glGetCompressedTextureImageEXT GLEW_GET_FUN(__glewGetCompressedTextureImageEXT)\r\n#define glGetDoubleIndexedvEXT GLEW_GET_FUN(__glewGetDoubleIndexedvEXT)\r\n#define glGetDoublei_vEXT GLEW_GET_FUN(__glewGetDoublei_vEXT)\r\n#define glGetFloatIndexedvEXT GLEW_GET_FUN(__glewGetFloatIndexedvEXT)\r\n#define glGetFloati_vEXT GLEW_GET_FUN(__glewGetFloati_vEXT)\r\n#define glGetFramebufferParameterivEXT GLEW_GET_FUN(__glewGetFramebufferParameterivEXT)\r\n#define glGetMultiTexEnvfvEXT GLEW_GET_FUN(__glewGetMultiTexEnvfvEXT)\r\n#define glGetMultiTexEnvivEXT GLEW_GET_FUN(__glewGetMultiTexEnvivEXT)\r\n#define glGetMultiTexGendvEXT GLEW_GET_FUN(__glewGetMultiTexGendvEXT)\r\n#define glGetMultiTexGenfvEXT GLEW_GET_FUN(__glewGetMultiTexGenfvEXT)\r\n#define glGetMultiTexGenivEXT GLEW_GET_FUN(__glewGetMultiTexGenivEXT)\r\n#define glGetMultiTexImageEXT GLEW_GET_FUN(__glewGetMultiTexImageEXT)\r\n#define glGetMultiTexLevelParameterfvEXT GLEW_GET_FUN(__glewGetMultiTexLevelParameterfvEXT)\r\n#define glGetMultiTexLevelParameterivEXT GLEW_GET_FUN(__glewGetMultiTexLevelParameterivEXT)\r\n#define glGetMultiTexParameterIivEXT GLEW_GET_FUN(__glewGetMultiTexParameterIivEXT)\r\n#define glGetMultiTexParameterIuivEXT GLEW_GET_FUN(__glewGetMultiTexParameterIuivEXT)\r\n#define glGetMultiTexParameterfvEXT GLEW_GET_FUN(__glewGetMultiTexParameterfvEXT)\r\n#define glGetMultiTexParameterivEXT GLEW_GET_FUN(__glewGetMultiTexParameterivEXT)\r\n#define glGetNamedBufferParameterivEXT GLEW_GET_FUN(__glewGetNamedBufferParameterivEXT)\r\n#define glGetNamedBufferPointervEXT GLEW_GET_FUN(__glewGetNamedBufferPointervEXT)\r\n#define glGetNamedBufferSubDataEXT GLEW_GET_FUN(__glewGetNamedBufferSubDataEXT)\r\n#define glGetNamedFramebufferAttachmentParameterivEXT GLEW_GET_FUN(__glewGetNamedFramebufferAttachmentParameterivEXT)\r\n#define glGetNamedProgramLocalParameterIivEXT GLEW_GET_FUN(__glewGetNamedProgramLocalParameterIivEXT)\r\n#define glGetNamedProgramLocalParameterIuivEXT GLEW_GET_FUN(__glewGetNamedProgramLocalParameterIuivEXT)\r\n#define glGetNamedProgramLocalParameterdvEXT GLEW_GET_FUN(__glewGetNamedProgramLocalParameterdvEXT)\r\n#define glGetNamedProgramLocalParameterfvEXT GLEW_GET_FUN(__glewGetNamedProgramLocalParameterfvEXT)\r\n#define glGetNamedProgramStringEXT GLEW_GET_FUN(__glewGetNamedProgramStringEXT)\r\n#define glGetNamedProgramivEXT GLEW_GET_FUN(__glewGetNamedProgramivEXT)\r\n#define glGetNamedRenderbufferParameterivEXT GLEW_GET_FUN(__glewGetNamedRenderbufferParameterivEXT)\r\n#define glGetPointerIndexedvEXT GLEW_GET_FUN(__glewGetPointerIndexedvEXT)\r\n#define glGetPointeri_vEXT GLEW_GET_FUN(__glewGetPointeri_vEXT)\r\n#define glGetTextureImageEXT GLEW_GET_FUN(__glewGetTextureImageEXT)\r\n#define glGetTextureLevelParameterfvEXT GLEW_GET_FUN(__glewGetTextureLevelParameterfvEXT)\r\n#define glGetTextureLevelParameterivEXT GLEW_GET_FUN(__glewGetTextureLevelParameterivEXT)\r\n#define glGetTextureParameterIivEXT GLEW_GET_FUN(__glewGetTextureParameterIivEXT)\r\n#define glGetTextureParameterIuivEXT GLEW_GET_FUN(__glewGetTextureParameterIuivEXT)\r\n#define glGetTextureParameterfvEXT GLEW_GET_FUN(__glewGetTextureParameterfvEXT)\r\n#define glGetTextureParameterivEXT GLEW_GET_FUN(__glewGetTextureParameterivEXT)\r\n#define glGetVertexArrayIntegeri_vEXT GLEW_GET_FUN(__glewGetVertexArrayIntegeri_vEXT)\r\n#define glGetVertexArrayIntegervEXT GLEW_GET_FUN(__glewGetVertexArrayIntegervEXT)\r\n#define glGetVertexArrayPointeri_vEXT GLEW_GET_FUN(__glewGetVertexArrayPointeri_vEXT)\r\n#define glGetVertexArrayPointervEXT GLEW_GET_FUN(__glewGetVertexArrayPointervEXT)\r\n#define glMapNamedBufferEXT GLEW_GET_FUN(__glewMapNamedBufferEXT)\r\n#define glMapNamedBufferRangeEXT GLEW_GET_FUN(__glewMapNamedBufferRangeEXT)\r\n#define glMatrixFrustumEXT GLEW_GET_FUN(__glewMatrixFrustumEXT)\r\n#define glMatrixLoadIdentityEXT GLEW_GET_FUN(__glewMatrixLoadIdentityEXT)\r\n#define glMatrixLoadTransposedEXT GLEW_GET_FUN(__glewMatrixLoadTransposedEXT)\r\n#define glMatrixLoadTransposefEXT GLEW_GET_FUN(__glewMatrixLoadTransposefEXT)\r\n#define glMatrixLoaddEXT GLEW_GET_FUN(__glewMatrixLoaddEXT)\r\n#define glMatrixLoadfEXT GLEW_GET_FUN(__glewMatrixLoadfEXT)\r\n#define glMatrixMultTransposedEXT GLEW_GET_FUN(__glewMatrixMultTransposedEXT)\r\n#define glMatrixMultTransposefEXT GLEW_GET_FUN(__glewMatrixMultTransposefEXT)\r\n#define glMatrixMultdEXT GLEW_GET_FUN(__glewMatrixMultdEXT)\r\n#define glMatrixMultfEXT GLEW_GET_FUN(__glewMatrixMultfEXT)\r\n#define glMatrixOrthoEXT GLEW_GET_FUN(__glewMatrixOrthoEXT)\r\n#define glMatrixPopEXT GLEW_GET_FUN(__glewMatrixPopEXT)\r\n#define glMatrixPushEXT GLEW_GET_FUN(__glewMatrixPushEXT)\r\n#define glMatrixRotatedEXT GLEW_GET_FUN(__glewMatrixRotatedEXT)\r\n#define glMatrixRotatefEXT GLEW_GET_FUN(__glewMatrixRotatefEXT)\r\n#define glMatrixScaledEXT GLEW_GET_FUN(__glewMatrixScaledEXT)\r\n#define glMatrixScalefEXT GLEW_GET_FUN(__glewMatrixScalefEXT)\r\n#define glMatrixTranslatedEXT GLEW_GET_FUN(__glewMatrixTranslatedEXT)\r\n#define glMatrixTranslatefEXT GLEW_GET_FUN(__glewMatrixTranslatefEXT)\r\n#define glMultiTexBufferEXT GLEW_GET_FUN(__glewMultiTexBufferEXT)\r\n#define glMultiTexCoordPointerEXT GLEW_GET_FUN(__glewMultiTexCoordPointerEXT)\r\n#define glMultiTexEnvfEXT GLEW_GET_FUN(__glewMultiTexEnvfEXT)\r\n#define glMultiTexEnvfvEXT GLEW_GET_FUN(__glewMultiTexEnvfvEXT)\r\n#define glMultiTexEnviEXT GLEW_GET_FUN(__glewMultiTexEnviEXT)\r\n#define glMultiTexEnvivEXT GLEW_GET_FUN(__glewMultiTexEnvivEXT)\r\n#define glMultiTexGendEXT GLEW_GET_FUN(__glewMultiTexGendEXT)\r\n#define glMultiTexGendvEXT GLEW_GET_FUN(__glewMultiTexGendvEXT)\r\n#define glMultiTexGenfEXT GLEW_GET_FUN(__glewMultiTexGenfEXT)\r\n#define glMultiTexGenfvEXT GLEW_GET_FUN(__glewMultiTexGenfvEXT)\r\n#define glMultiTexGeniEXT GLEW_GET_FUN(__glewMultiTexGeniEXT)\r\n#define glMultiTexGenivEXT GLEW_GET_FUN(__glewMultiTexGenivEXT)\r\n#define glMultiTexImage1DEXT GLEW_GET_FUN(__glewMultiTexImage1DEXT)\r\n#define glMultiTexImage2DEXT GLEW_GET_FUN(__glewMultiTexImage2DEXT)\r\n#define glMultiTexImage3DEXT GLEW_GET_FUN(__glewMultiTexImage3DEXT)\r\n#define glMultiTexParameterIivEXT GLEW_GET_FUN(__glewMultiTexParameterIivEXT)\r\n#define glMultiTexParameterIuivEXT GLEW_GET_FUN(__glewMultiTexParameterIuivEXT)\r\n#define glMultiTexParameterfEXT GLEW_GET_FUN(__glewMultiTexParameterfEXT)\r\n#define glMultiTexParameterfvEXT GLEW_GET_FUN(__glewMultiTexParameterfvEXT)\r\n#define glMultiTexParameteriEXT GLEW_GET_FUN(__glewMultiTexParameteriEXT)\r\n#define glMultiTexParameterivEXT GLEW_GET_FUN(__glewMultiTexParameterivEXT)\r\n#define glMultiTexRenderbufferEXT GLEW_GET_FUN(__glewMultiTexRenderbufferEXT)\r\n#define glMultiTexSubImage1DEXT GLEW_GET_FUN(__glewMultiTexSubImage1DEXT)\r\n#define glMultiTexSubImage2DEXT GLEW_GET_FUN(__glewMultiTexSubImage2DEXT)\r\n#define glMultiTexSubImage3DEXT GLEW_GET_FUN(__glewMultiTexSubImage3DEXT)\r\n#define glNamedBufferDataEXT GLEW_GET_FUN(__glewNamedBufferDataEXT)\r\n#define glNamedBufferSubDataEXT GLEW_GET_FUN(__glewNamedBufferSubDataEXT)\r\n#define glNamedCopyBufferSubDataEXT GLEW_GET_FUN(__glewNamedCopyBufferSubDataEXT)\r\n#define glNamedFramebufferRenderbufferEXT GLEW_GET_FUN(__glewNamedFramebufferRenderbufferEXT)\r\n#define glNamedFramebufferTexture1DEXT GLEW_GET_FUN(__glewNamedFramebufferTexture1DEXT)\r\n#define glNamedFramebufferTexture2DEXT GLEW_GET_FUN(__glewNamedFramebufferTexture2DEXT)\r\n#define glNamedFramebufferTexture3DEXT GLEW_GET_FUN(__glewNamedFramebufferTexture3DEXT)\r\n#define glNamedFramebufferTextureEXT GLEW_GET_FUN(__glewNamedFramebufferTextureEXT)\r\n#define glNamedFramebufferTextureFaceEXT GLEW_GET_FUN(__glewNamedFramebufferTextureFaceEXT)\r\n#define glNamedFramebufferTextureLayerEXT GLEW_GET_FUN(__glewNamedFramebufferTextureLayerEXT)\r\n#define glNamedProgramLocalParameter4dEXT GLEW_GET_FUN(__glewNamedProgramLocalParameter4dEXT)\r\n#define glNamedProgramLocalParameter4dvEXT GLEW_GET_FUN(__glewNamedProgramLocalParameter4dvEXT)\r\n#define glNamedProgramLocalParameter4fEXT GLEW_GET_FUN(__glewNamedProgramLocalParameter4fEXT)\r\n#define glNamedProgramLocalParameter4fvEXT GLEW_GET_FUN(__glewNamedProgramLocalParameter4fvEXT)\r\n#define glNamedProgramLocalParameterI4iEXT GLEW_GET_FUN(__glewNamedProgramLocalParameterI4iEXT)\r\n#define glNamedProgramLocalParameterI4ivEXT GLEW_GET_FUN(__glewNamedProgramLocalParameterI4ivEXT)\r\n#define glNamedProgramLocalParameterI4uiEXT GLEW_GET_FUN(__glewNamedProgramLocalParameterI4uiEXT)\r\n#define glNamedProgramLocalParameterI4uivEXT GLEW_GET_FUN(__glewNamedProgramLocalParameterI4uivEXT)\r\n#define glNamedProgramLocalParameters4fvEXT GLEW_GET_FUN(__glewNamedProgramLocalParameters4fvEXT)\r\n#define glNamedProgramLocalParametersI4ivEXT GLEW_GET_FUN(__glewNamedProgramLocalParametersI4ivEXT)\r\n#define glNamedProgramLocalParametersI4uivEXT GLEW_GET_FUN(__glewNamedProgramLocalParametersI4uivEXT)\r\n#define glNamedProgramStringEXT GLEW_GET_FUN(__glewNamedProgramStringEXT)\r\n#define glNamedRenderbufferStorageEXT GLEW_GET_FUN(__glewNamedRenderbufferStorageEXT)\r\n#define glNamedRenderbufferStorageMultisampleCoverageEXT GLEW_GET_FUN(__glewNamedRenderbufferStorageMultisampleCoverageEXT)\r\n#define glNamedRenderbufferStorageMultisampleEXT GLEW_GET_FUN(__glewNamedRenderbufferStorageMultisampleEXT)\r\n#define glProgramUniform1fEXT GLEW_GET_FUN(__glewProgramUniform1fEXT)\r\n#define glProgramUniform1fvEXT GLEW_GET_FUN(__glewProgramUniform1fvEXT)\r\n#define glProgramUniform1iEXT GLEW_GET_FUN(__glewProgramUniform1iEXT)\r\n#define glProgramUniform1ivEXT GLEW_GET_FUN(__glewProgramUniform1ivEXT)\r\n#define glProgramUniform1uiEXT GLEW_GET_FUN(__glewProgramUniform1uiEXT)\r\n#define glProgramUniform1uivEXT GLEW_GET_FUN(__glewProgramUniform1uivEXT)\r\n#define glProgramUniform2fEXT GLEW_GET_FUN(__glewProgramUniform2fEXT)\r\n#define glProgramUniform2fvEXT GLEW_GET_FUN(__glewProgramUniform2fvEXT)\r\n#define glProgramUniform2iEXT GLEW_GET_FUN(__glewProgramUniform2iEXT)\r\n#define glProgramUniform2ivEXT GLEW_GET_FUN(__glewProgramUniform2ivEXT)\r\n#define glProgramUniform2uiEXT GLEW_GET_FUN(__glewProgramUniform2uiEXT)\r\n#define glProgramUniform2uivEXT GLEW_GET_FUN(__glewProgramUniform2uivEXT)\r\n#define glProgramUniform3fEXT GLEW_GET_FUN(__glewProgramUniform3fEXT)\r\n#define glProgramUniform3fvEXT GLEW_GET_FUN(__glewProgramUniform3fvEXT)\r\n#define glProgramUniform3iEXT GLEW_GET_FUN(__glewProgramUniform3iEXT)\r\n#define glProgramUniform3ivEXT GLEW_GET_FUN(__glewProgramUniform3ivEXT)\r\n#define glProgramUniform3uiEXT GLEW_GET_FUN(__glewProgramUniform3uiEXT)\r\n#define glProgramUniform3uivEXT GLEW_GET_FUN(__glewProgramUniform3uivEXT)\r\n#define glProgramUniform4fEXT GLEW_GET_FUN(__glewProgramUniform4fEXT)\r\n#define glProgramUniform4fvEXT GLEW_GET_FUN(__glewProgramUniform4fvEXT)\r\n#define glProgramUniform4iEXT GLEW_GET_FUN(__glewProgramUniform4iEXT)\r\n#define glProgramUniform4ivEXT GLEW_GET_FUN(__glewProgramUniform4ivEXT)\r\n#define glProgramUniform4uiEXT GLEW_GET_FUN(__glewProgramUniform4uiEXT)\r\n#define glProgramUniform4uivEXT GLEW_GET_FUN(__glewProgramUniform4uivEXT)\r\n#define glProgramUniformMatrix2fvEXT GLEW_GET_FUN(__glewProgramUniformMatrix2fvEXT)\r\n#define glProgramUniformMatrix2x3fvEXT GLEW_GET_FUN(__glewProgramUniformMatrix2x3fvEXT)\r\n#define glProgramUniformMatrix2x4fvEXT GLEW_GET_FUN(__glewProgramUniformMatrix2x4fvEXT)\r\n#define glProgramUniformMatrix3fvEXT GLEW_GET_FUN(__glewProgramUniformMatrix3fvEXT)\r\n#define glProgramUniformMatrix3x2fvEXT GLEW_GET_FUN(__glewProgramUniformMatrix3x2fvEXT)\r\n#define glProgramUniformMatrix3x4fvEXT GLEW_GET_FUN(__glewProgramUniformMatrix3x4fvEXT)\r\n#define glProgramUniformMatrix4fvEXT GLEW_GET_FUN(__glewProgramUniformMatrix4fvEXT)\r\n#define glProgramUniformMatrix4x2fvEXT GLEW_GET_FUN(__glewProgramUniformMatrix4x2fvEXT)\r\n#define glProgramUniformMatrix4x3fvEXT GLEW_GET_FUN(__glewProgramUniformMatrix4x3fvEXT)\r\n#define glPushClientAttribDefaultEXT GLEW_GET_FUN(__glewPushClientAttribDefaultEXT)\r\n#define glTextureBufferEXT GLEW_GET_FUN(__glewTextureBufferEXT)\r\n#define glTextureImage1DEXT GLEW_GET_FUN(__glewTextureImage1DEXT)\r\n#define glTextureImage2DEXT GLEW_GET_FUN(__glewTextureImage2DEXT)\r\n#define glTextureImage3DEXT GLEW_GET_FUN(__glewTextureImage3DEXT)\r\n#define glTextureParameterIivEXT GLEW_GET_FUN(__glewTextureParameterIivEXT)\r\n#define glTextureParameterIuivEXT GLEW_GET_FUN(__glewTextureParameterIuivEXT)\r\n#define glTextureParameterfEXT GLEW_GET_FUN(__glewTextureParameterfEXT)\r\n#define glTextureParameterfvEXT GLEW_GET_FUN(__glewTextureParameterfvEXT)\r\n#define glTextureParameteriEXT GLEW_GET_FUN(__glewTextureParameteriEXT)\r\n#define glTextureParameterivEXT GLEW_GET_FUN(__glewTextureParameterivEXT)\r\n#define glTextureRenderbufferEXT GLEW_GET_FUN(__glewTextureRenderbufferEXT)\r\n#define glTextureSubImage1DEXT GLEW_GET_FUN(__glewTextureSubImage1DEXT)\r\n#define glTextureSubImage2DEXT GLEW_GET_FUN(__glewTextureSubImage2DEXT)\r\n#define glTextureSubImage3DEXT GLEW_GET_FUN(__glewTextureSubImage3DEXT)\r\n#define glUnmapNamedBufferEXT GLEW_GET_FUN(__glewUnmapNamedBufferEXT)\r\n#define glVertexArrayColorOffsetEXT GLEW_GET_FUN(__glewVertexArrayColorOffsetEXT)\r\n#define glVertexArrayEdgeFlagOffsetEXT GLEW_GET_FUN(__glewVertexArrayEdgeFlagOffsetEXT)\r\n#define glVertexArrayFogCoordOffsetEXT GLEW_GET_FUN(__glewVertexArrayFogCoordOffsetEXT)\r\n#define glVertexArrayIndexOffsetEXT GLEW_GET_FUN(__glewVertexArrayIndexOffsetEXT)\r\n#define glVertexArrayMultiTexCoordOffsetEXT GLEW_GET_FUN(__glewVertexArrayMultiTexCoordOffsetEXT)\r\n#define glVertexArrayNormalOffsetEXT GLEW_GET_FUN(__glewVertexArrayNormalOffsetEXT)\r\n#define glVertexArraySecondaryColorOffsetEXT GLEW_GET_FUN(__glewVertexArraySecondaryColorOffsetEXT)\r\n#define glVertexArrayTexCoordOffsetEXT GLEW_GET_FUN(__glewVertexArrayTexCoordOffsetEXT)\r\n#define glVertexArrayVertexAttribDivisorEXT GLEW_GET_FUN(__glewVertexArrayVertexAttribDivisorEXT)\r\n#define glVertexArrayVertexAttribIOffsetEXT GLEW_GET_FUN(__glewVertexArrayVertexAttribIOffsetEXT)\r\n#define glVertexArrayVertexAttribOffsetEXT GLEW_GET_FUN(__glewVertexArrayVertexAttribOffsetEXT)\r\n#define glVertexArrayVertexOffsetEXT GLEW_GET_FUN(__glewVertexArrayVertexOffsetEXT)\r\n\r\n#define GLEW_EXT_direct_state_access GLEW_GET_VAR(__GLEW_EXT_direct_state_access)\r\n\r\n#endif /* GL_EXT_direct_state_access */\r\n\r\n/* -------------------------- GL_EXT_draw_buffers2 ------------------------- */\r\n\r\n#ifndef GL_EXT_draw_buffers2\r\n#define GL_EXT_draw_buffers2 1\r\n\r\ntypedef void (GLAPIENTRY * PFNGLCOLORMASKINDEXEDEXTPROC) (GLuint buf, GLboolean r, GLboolean g, GLboolean b, GLboolean a);\r\ntypedef void (GLAPIENTRY * PFNGLDISABLEINDEXEDEXTPROC) (GLenum target, GLuint index);\r\ntypedef void (GLAPIENTRY * PFNGLENABLEINDEXEDEXTPROC) (GLenum target, GLuint index);\r\ntypedef void (GLAPIENTRY * PFNGLGETBOOLEANINDEXEDVEXTPROC) (GLenum value, GLuint index, GLboolean* data);\r\ntypedef void (GLAPIENTRY * PFNGLGETINTEGERINDEXEDVEXTPROC) (GLenum value, GLuint index, GLint* data);\r\ntypedef GLboolean (GLAPIENTRY * PFNGLISENABLEDINDEXEDEXTPROC) (GLenum target, GLuint index);\r\n\r\n#define glColorMaskIndexedEXT GLEW_GET_FUN(__glewColorMaskIndexedEXT)\r\n#define glDisableIndexedEXT GLEW_GET_FUN(__glewDisableIndexedEXT)\r\n#define glEnableIndexedEXT GLEW_GET_FUN(__glewEnableIndexedEXT)\r\n#define glGetBooleanIndexedvEXT GLEW_GET_FUN(__glewGetBooleanIndexedvEXT)\r\n#define glGetIntegerIndexedvEXT GLEW_GET_FUN(__glewGetIntegerIndexedvEXT)\r\n#define glIsEnabledIndexedEXT GLEW_GET_FUN(__glewIsEnabledIndexedEXT)\r\n\r\n#define GLEW_EXT_draw_buffers2 GLEW_GET_VAR(__GLEW_EXT_draw_buffers2)\r\n\r\n#endif /* GL_EXT_draw_buffers2 */\r\n\r\n/* ------------------------- GL_EXT_draw_instanced ------------------------- */\r\n\r\n#ifndef GL_EXT_draw_instanced\r\n#define GL_EXT_draw_instanced 1\r\n\r\ntypedef void (GLAPIENTRY * PFNGLDRAWARRAYSINSTANCEDEXTPROC) (GLenum mode, GLint start, GLsizei count, GLsizei primcount);\r\ntypedef void (GLAPIENTRY * PFNGLDRAWELEMENTSINSTANCEDEXTPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount);\r\n\r\n#define glDrawArraysInstancedEXT GLEW_GET_FUN(__glewDrawArraysInstancedEXT)\r\n#define glDrawElementsInstancedEXT GLEW_GET_FUN(__glewDrawElementsInstancedEXT)\r\n\r\n#define GLEW_EXT_draw_instanced GLEW_GET_VAR(__GLEW_EXT_draw_instanced)\r\n\r\n#endif /* GL_EXT_draw_instanced */\r\n\r\n/* ----------------------- GL_EXT_draw_range_elements ---------------------- */\r\n\r\n#ifndef GL_EXT_draw_range_elements\r\n#define GL_EXT_draw_range_elements 1\r\n\r\n#define GL_MAX_ELEMENTS_VERTICES_EXT 0x80E8\r\n#define GL_MAX_ELEMENTS_INDICES_EXT 0x80E9\r\n\r\ntypedef void (GLAPIENTRY * PFNGLDRAWRANGEELEMENTSEXTPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices);\r\n\r\n#define glDrawRangeElementsEXT GLEW_GET_FUN(__glewDrawRangeElementsEXT)\r\n\r\n#define GLEW_EXT_draw_range_elements GLEW_GET_VAR(__GLEW_EXT_draw_range_elements)\r\n\r\n#endif /* GL_EXT_draw_range_elements */\r\n\r\n/* ---------------------------- GL_EXT_fog_coord --------------------------- */\r\n\r\n#ifndef GL_EXT_fog_coord\r\n#define GL_EXT_fog_coord 1\r\n\r\n#define GL_FOG_COORDINATE_SOURCE_EXT 0x8450\r\n#define GL_FOG_COORDINATE_EXT 0x8451\r\n#define GL_FRAGMENT_DEPTH_EXT 0x8452\r\n#define GL_CURRENT_FOG_COORDINATE_EXT 0x8453\r\n#define GL_FOG_COORDINATE_ARRAY_TYPE_EXT 0x8454\r\n#define GL_FOG_COORDINATE_ARRAY_STRIDE_EXT 0x8455\r\n#define GL_FOG_COORDINATE_ARRAY_POINTER_EXT 0x8456\r\n#define GL_FOG_COORDINATE_ARRAY_EXT 0x8457\r\n\r\ntypedef void (GLAPIENTRY * PFNGLFOGCOORDPOINTEREXTPROC) (GLenum type, GLsizei stride, const void *pointer);\r\ntypedef void (GLAPIENTRY * PFNGLFOGCOORDDEXTPROC) (GLdouble coord);\r\ntypedef void (GLAPIENTRY * PFNGLFOGCOORDDVEXTPROC) (const GLdouble *coord);\r\ntypedef void (GLAPIENTRY * PFNGLFOGCOORDFEXTPROC) (GLfloat coord);\r\ntypedef void (GLAPIENTRY * PFNGLFOGCOORDFVEXTPROC) (const GLfloat *coord);\r\n\r\n#define glFogCoordPointerEXT GLEW_GET_FUN(__glewFogCoordPointerEXT)\r\n#define glFogCoorddEXT GLEW_GET_FUN(__glewFogCoorddEXT)\r\n#define glFogCoorddvEXT GLEW_GET_FUN(__glewFogCoorddvEXT)\r\n#define glFogCoordfEXT GLEW_GET_FUN(__glewFogCoordfEXT)\r\n#define glFogCoordfvEXT GLEW_GET_FUN(__glewFogCoordfvEXT)\r\n\r\n#define GLEW_EXT_fog_coord GLEW_GET_VAR(__GLEW_EXT_fog_coord)\r\n\r\n#endif /* GL_EXT_fog_coord */\r\n\r\n/* ------------------------ GL_EXT_fragment_lighting ----------------------- */\r\n\r\n#ifndef GL_EXT_fragment_lighting\r\n#define GL_EXT_fragment_lighting 1\r\n\r\n#define GL_FRAGMENT_LIGHTING_EXT 0x8400\r\n#define GL_FRAGMENT_COLOR_MATERIAL_EXT 0x8401\r\n#define GL_FRAGMENT_COLOR_MATERIAL_FACE_EXT 0x8402\r\n#define GL_FRAGMENT_COLOR_MATERIAL_PARAMETER_EXT 0x8403\r\n#define GL_MAX_FRAGMENT_LIGHTS_EXT 0x8404\r\n#define GL_MAX_ACTIVE_LIGHTS_EXT 0x8405\r\n#define GL_CURRENT_RASTER_NORMAL_EXT 0x8406\r\n#define GL_LIGHT_ENV_MODE_EXT 0x8407\r\n#define GL_FRAGMENT_LIGHT_MODEL_LOCAL_VIEWER_EXT 0x8408\r\n#define GL_FRAGMENT_LIGHT_MODEL_TWO_SIDE_EXT 0x8409\r\n#define GL_FRAGMENT_LIGHT_MODEL_AMBIENT_EXT 0x840A\r\n#define GL_FRAGMENT_LIGHT_MODEL_NORMAL_INTERPOLATION_EXT 0x840B\r\n#define GL_FRAGMENT_LIGHT0_EXT 0x840C\r\n#define GL_FRAGMENT_LIGHT7_EXT 0x8413\r\n\r\ntypedef void (GLAPIENTRY * PFNGLFRAGMENTCOLORMATERIALEXTPROC) (GLenum face, GLenum mode);\r\ntypedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTMODELFEXTPROC) (GLenum pname, GLfloat param);\r\ntypedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTMODELFVEXTPROC) (GLenum pname, GLfloat* params);\r\ntypedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTMODELIEXTPROC) (GLenum pname, GLint param);\r\ntypedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTMODELIVEXTPROC) (GLenum pname, GLint* params);\r\ntypedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTFEXTPROC) (GLenum light, GLenum pname, GLfloat param);\r\ntypedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTFVEXTPROC) (GLenum light, GLenum pname, GLfloat* params);\r\ntypedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTIEXTPROC) (GLenum light, GLenum pname, GLint param);\r\ntypedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTIVEXTPROC) (GLenum light, GLenum pname, GLint* params);\r\ntypedef void (GLAPIENTRY * PFNGLFRAGMENTMATERIALFEXTPROC) (GLenum face, GLenum pname, const GLfloat param);\r\ntypedef void (GLAPIENTRY * PFNGLFRAGMENTMATERIALFVEXTPROC) (GLenum face, GLenum pname, const GLfloat* params);\r\ntypedef void (GLAPIENTRY * PFNGLFRAGMENTMATERIALIEXTPROC) (GLenum face, GLenum pname, const GLint param);\r\ntypedef void (GLAPIENTRY * PFNGLFRAGMENTMATERIALIVEXTPROC) (GLenum face, GLenum pname, const GLint* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETFRAGMENTLIGHTFVEXTPROC) (GLenum light, GLenum pname, GLfloat* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETFRAGMENTLIGHTIVEXTPROC) (GLenum light, GLenum pname, GLint* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETFRAGMENTMATERIALFVEXTPROC) (GLenum face, GLenum pname, const GLfloat* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETFRAGMENTMATERIALIVEXTPROC) (GLenum face, GLenum pname, const GLint* params);\r\ntypedef void (GLAPIENTRY * PFNGLLIGHTENVIEXTPROC) (GLenum pname, GLint param);\r\n\r\n#define glFragmentColorMaterialEXT GLEW_GET_FUN(__glewFragmentColorMaterialEXT)\r\n#define glFragmentLightModelfEXT GLEW_GET_FUN(__glewFragmentLightModelfEXT)\r\n#define glFragmentLightModelfvEXT GLEW_GET_FUN(__glewFragmentLightModelfvEXT)\r\n#define glFragmentLightModeliEXT GLEW_GET_FUN(__glewFragmentLightModeliEXT)\r\n#define glFragmentLightModelivEXT GLEW_GET_FUN(__glewFragmentLightModelivEXT)\r\n#define glFragmentLightfEXT GLEW_GET_FUN(__glewFragmentLightfEXT)\r\n#define glFragmentLightfvEXT GLEW_GET_FUN(__glewFragmentLightfvEXT)\r\n#define glFragmentLightiEXT GLEW_GET_FUN(__glewFragmentLightiEXT)\r\n#define glFragmentLightivEXT GLEW_GET_FUN(__glewFragmentLightivEXT)\r\n#define glFragmentMaterialfEXT GLEW_GET_FUN(__glewFragmentMaterialfEXT)\r\n#define glFragmentMaterialfvEXT GLEW_GET_FUN(__glewFragmentMaterialfvEXT)\r\n#define glFragmentMaterialiEXT GLEW_GET_FUN(__glewFragmentMaterialiEXT)\r\n#define glFragmentMaterialivEXT GLEW_GET_FUN(__glewFragmentMaterialivEXT)\r\n#define glGetFragmentLightfvEXT GLEW_GET_FUN(__glewGetFragmentLightfvEXT)\r\n#define glGetFragmentLightivEXT GLEW_GET_FUN(__glewGetFragmentLightivEXT)\r\n#define glGetFragmentMaterialfvEXT GLEW_GET_FUN(__glewGetFragmentMaterialfvEXT)\r\n#define glGetFragmentMaterialivEXT GLEW_GET_FUN(__glewGetFragmentMaterialivEXT)\r\n#define glLightEnviEXT GLEW_GET_FUN(__glewLightEnviEXT)\r\n\r\n#define GLEW_EXT_fragment_lighting GLEW_GET_VAR(__GLEW_EXT_fragment_lighting)\r\n\r\n#endif /* GL_EXT_fragment_lighting */\r\n\r\n/* ------------------------ GL_EXT_framebuffer_blit ------------------------ */\r\n\r\n#ifndef GL_EXT_framebuffer_blit\r\n#define GL_EXT_framebuffer_blit 1\r\n\r\n#define GL_DRAW_FRAMEBUFFER_BINDING_EXT 0x8CA6\r\n#define GL_READ_FRAMEBUFFER_EXT 0x8CA8\r\n#define GL_DRAW_FRAMEBUFFER_EXT 0x8CA9\r\n#define GL_READ_FRAMEBUFFER_BINDING_EXT 0x8CAA\r\n\r\ntypedef void (GLAPIENTRY * PFNGLBLITFRAMEBUFFEREXTPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);\r\n\r\n#define glBlitFramebufferEXT GLEW_GET_FUN(__glewBlitFramebufferEXT)\r\n\r\n#define GLEW_EXT_framebuffer_blit GLEW_GET_VAR(__GLEW_EXT_framebuffer_blit)\r\n\r\n#endif /* GL_EXT_framebuffer_blit */\r\n\r\n/* --------------------- GL_EXT_framebuffer_multisample -------------------- */\r\n\r\n#ifndef GL_EXT_framebuffer_multisample\r\n#define GL_EXT_framebuffer_multisample 1\r\n\r\n#define GL_RENDERBUFFER_SAMPLES_EXT 0x8CAB\r\n#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x8D56\r\n#define GL_MAX_SAMPLES_EXT 0x8D57\r\n\r\ntypedef void (GLAPIENTRY * PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);\r\n\r\n#define glRenderbufferStorageMultisampleEXT GLEW_GET_FUN(__glewRenderbufferStorageMultisampleEXT)\r\n\r\n#define GLEW_EXT_framebuffer_multisample GLEW_GET_VAR(__GLEW_EXT_framebuffer_multisample)\r\n\r\n#endif /* GL_EXT_framebuffer_multisample */\r\n\r\n/* --------------- GL_EXT_framebuffer_multisample_blit_scaled -------------- */\r\n\r\n#ifndef GL_EXT_framebuffer_multisample_blit_scaled\r\n#define GL_EXT_framebuffer_multisample_blit_scaled 1\r\n\r\n#define GL_SCALED_RESOLVE_FASTEST_EXT 0x90BA\r\n#define GL_SCALED_RESOLVE_NICEST_EXT 0x90BB\r\n\r\n#define GLEW_EXT_framebuffer_multisample_blit_scaled GLEW_GET_VAR(__GLEW_EXT_framebuffer_multisample_blit_scaled)\r\n\r\n#endif /* GL_EXT_framebuffer_multisample_blit_scaled */\r\n\r\n/* ----------------------- GL_EXT_framebuffer_object ----------------------- */\r\n\r\n#ifndef GL_EXT_framebuffer_object\r\n#define GL_EXT_framebuffer_object 1\r\n\r\n#define GL_INVALID_FRAMEBUFFER_OPERATION_EXT 0x0506\r\n#define GL_MAX_RENDERBUFFER_SIZE_EXT 0x84E8\r\n#define GL_FRAMEBUFFER_BINDING_EXT 0x8CA6\r\n#define GL_RENDERBUFFER_BINDING_EXT 0x8CA7\r\n#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT 0x8CD0\r\n#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT 0x8CD1\r\n#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT 0x8CD2\r\n#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT 0x8CD3\r\n#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT 0x8CD4\r\n#define GL_FRAMEBUFFER_COMPLETE_EXT 0x8CD5\r\n#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT 0x8CD6\r\n#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT 0x8CD7\r\n#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT 0x8CD9\r\n#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT 0x8CDA\r\n#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT 0x8CDB\r\n#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT 0x8CDC\r\n#define GL_FRAMEBUFFER_UNSUPPORTED_EXT 0x8CDD\r\n#define GL_MAX_COLOR_ATTACHMENTS_EXT 0x8CDF\r\n#define GL_COLOR_ATTACHMENT0_EXT 0x8CE0\r\n#define GL_COLOR_ATTACHMENT1_EXT 0x8CE1\r\n#define GL_COLOR_ATTACHMENT2_EXT 0x8CE2\r\n#define GL_COLOR_ATTACHMENT3_EXT 0x8CE3\r\n#define GL_COLOR_ATTACHMENT4_EXT 0x8CE4\r\n#define GL_COLOR_ATTACHMENT5_EXT 0x8CE5\r\n#define GL_COLOR_ATTACHMENT6_EXT 0x8CE6\r\n#define GL_COLOR_ATTACHMENT7_EXT 0x8CE7\r\n#define GL_COLOR_ATTACHMENT8_EXT 0x8CE8\r\n#define GL_COLOR_ATTACHMENT9_EXT 0x8CE9\r\n#define GL_COLOR_ATTACHMENT10_EXT 0x8CEA\r\n#define GL_COLOR_ATTACHMENT11_EXT 0x8CEB\r\n#define GL_COLOR_ATTACHMENT12_EXT 0x8CEC\r\n#define GL_COLOR_ATTACHMENT13_EXT 0x8CED\r\n#define GL_COLOR_ATTACHMENT14_EXT 0x8CEE\r\n#define GL_COLOR_ATTACHMENT15_EXT 0x8CEF\r\n#define GL_DEPTH_ATTACHMENT_EXT 0x8D00\r\n#define GL_STENCIL_ATTACHMENT_EXT 0x8D20\r\n#define GL_FRAMEBUFFER_EXT 0x8D40\r\n#define GL_RENDERBUFFER_EXT 0x8D41\r\n#define GL_RENDERBUFFER_WIDTH_EXT 0x8D42\r\n#define GL_RENDERBUFFER_HEIGHT_EXT 0x8D43\r\n#define GL_RENDERBUFFER_INTERNAL_FORMAT_EXT 0x8D44\r\n#define GL_STENCIL_INDEX1_EXT 0x8D46\r\n#define GL_STENCIL_INDEX4_EXT 0x8D47\r\n#define GL_STENCIL_INDEX8_EXT 0x8D48\r\n#define GL_STENCIL_INDEX16_EXT 0x8D49\r\n#define GL_RENDERBUFFER_RED_SIZE_EXT 0x8D50\r\n#define GL_RENDERBUFFER_GREEN_SIZE_EXT 0x8D51\r\n#define GL_RENDERBUFFER_BLUE_SIZE_EXT 0x8D52\r\n#define GL_RENDERBUFFER_ALPHA_SIZE_EXT 0x8D53\r\n#define GL_RENDERBUFFER_DEPTH_SIZE_EXT 0x8D54\r\n#define GL_RENDERBUFFER_STENCIL_SIZE_EXT 0x8D55\r\n\r\ntypedef void (GLAPIENTRY * PFNGLBINDFRAMEBUFFEREXTPROC) (GLenum target, GLuint framebuffer);\r\ntypedef void (GLAPIENTRY * PFNGLBINDRENDERBUFFEREXTPROC) (GLenum target, GLuint renderbuffer);\r\ntypedef GLenum (GLAPIENTRY * PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) (GLenum target);\r\ntypedef void (GLAPIENTRY * PFNGLDELETEFRAMEBUFFERSEXTPROC) (GLsizei n, const GLuint* framebuffers);\r\ntypedef void (GLAPIENTRY * PFNGLDELETERENDERBUFFERSEXTPROC) (GLsizei n, const GLuint* renderbuffers);\r\ntypedef void (GLAPIENTRY * PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);\r\ntypedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURE1DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);\r\ntypedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);\r\ntypedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURE3DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset);\r\ntypedef void (GLAPIENTRY * PFNGLGENFRAMEBUFFERSEXTPROC) (GLsizei n, GLuint* framebuffers);\r\ntypedef void (GLAPIENTRY * PFNGLGENRENDERBUFFERSEXTPROC) (GLsizei n, GLuint* renderbuffers);\r\ntypedef void (GLAPIENTRY * PFNGLGENERATEMIPMAPEXTPROC) (GLenum target);\r\ntypedef void (GLAPIENTRY * PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) (GLenum target, GLenum attachment, GLenum pname, GLint* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint* params);\r\ntypedef GLboolean (GLAPIENTRY * PFNGLISFRAMEBUFFEREXTPROC) (GLuint framebuffer);\r\ntypedef GLboolean (GLAPIENTRY * PFNGLISRENDERBUFFEREXTPROC) (GLuint renderbuffer);\r\ntypedef void (GLAPIENTRY * PFNGLRENDERBUFFERSTORAGEEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height);\r\n\r\n#define glBindFramebufferEXT GLEW_GET_FUN(__glewBindFramebufferEXT)\r\n#define glBindRenderbufferEXT GLEW_GET_FUN(__glewBindRenderbufferEXT)\r\n#define glCheckFramebufferStatusEXT GLEW_GET_FUN(__glewCheckFramebufferStatusEXT)\r\n#define glDeleteFramebuffersEXT GLEW_GET_FUN(__glewDeleteFramebuffersEXT)\r\n#define glDeleteRenderbuffersEXT GLEW_GET_FUN(__glewDeleteRenderbuffersEXT)\r\n#define glFramebufferRenderbufferEXT GLEW_GET_FUN(__glewFramebufferRenderbufferEXT)\r\n#define glFramebufferTexture1DEXT GLEW_GET_FUN(__glewFramebufferTexture1DEXT)\r\n#define glFramebufferTexture2DEXT GLEW_GET_FUN(__glewFramebufferTexture2DEXT)\r\n#define glFramebufferTexture3DEXT GLEW_GET_FUN(__glewFramebufferTexture3DEXT)\r\n#define glGenFramebuffersEXT GLEW_GET_FUN(__glewGenFramebuffersEXT)\r\n#define glGenRenderbuffersEXT GLEW_GET_FUN(__glewGenRenderbuffersEXT)\r\n#define glGenerateMipmapEXT GLEW_GET_FUN(__glewGenerateMipmapEXT)\r\n#define glGetFramebufferAttachmentParameterivEXT GLEW_GET_FUN(__glewGetFramebufferAttachmentParameterivEXT)\r\n#define glGetRenderbufferParameterivEXT GLEW_GET_FUN(__glewGetRenderbufferParameterivEXT)\r\n#define glIsFramebufferEXT GLEW_GET_FUN(__glewIsFramebufferEXT)\r\n#define glIsRenderbufferEXT GLEW_GET_FUN(__glewIsRenderbufferEXT)\r\n#define glRenderbufferStorageEXT GLEW_GET_FUN(__glewRenderbufferStorageEXT)\r\n\r\n#define GLEW_EXT_framebuffer_object GLEW_GET_VAR(__GLEW_EXT_framebuffer_object)\r\n\r\n#endif /* GL_EXT_framebuffer_object */\r\n\r\n/* ------------------------ GL_EXT_framebuffer_sRGB ------------------------ */\r\n\r\n#ifndef GL_EXT_framebuffer_sRGB\r\n#define GL_EXT_framebuffer_sRGB 1\r\n\r\n#define GL_FRAMEBUFFER_SRGB_EXT 0x8DB9\r\n#define GL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x8DBA\r\n\r\n#define GLEW_EXT_framebuffer_sRGB GLEW_GET_VAR(__GLEW_EXT_framebuffer_sRGB)\r\n\r\n#endif /* GL_EXT_framebuffer_sRGB */\r\n\r\n/* ------------------------ GL_EXT_geometry_shader4 ------------------------ */\r\n\r\n#ifndef GL_EXT_geometry_shader4\r\n#define GL_EXT_geometry_shader4 1\r\n\r\n#define GL_LINES_ADJACENCY_EXT 0xA\r\n#define GL_LINE_STRIP_ADJACENCY_EXT 0xB\r\n#define GL_TRIANGLES_ADJACENCY_EXT 0xC\r\n#define GL_TRIANGLE_STRIP_ADJACENCY_EXT 0xD\r\n#define GL_PROGRAM_POINT_SIZE_EXT 0x8642\r\n#define GL_MAX_VARYING_COMPONENTS_EXT 0x8B4B\r\n#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT 0x8C29\r\n#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT 0x8CD4\r\n#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_EXT 0x8DA7\r\n#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT 0x8DA8\r\n#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_EXT 0x8DA9\r\n#define GL_GEOMETRY_SHADER_EXT 0x8DD9\r\n#define GL_GEOMETRY_VERTICES_OUT_EXT 0x8DDA\r\n#define GL_GEOMETRY_INPUT_TYPE_EXT 0x8DDB\r\n#define GL_GEOMETRY_OUTPUT_TYPE_EXT 0x8DDC\r\n#define GL_MAX_GEOMETRY_VARYING_COMPONENTS_EXT 0x8DDD\r\n#define GL_MAX_VERTEX_VARYING_COMPONENTS_EXT 0x8DDE\r\n#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_EXT 0x8DDF\r\n#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_EXT 0x8DE0\r\n#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_EXT 0x8DE1\r\n\r\ntypedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTUREEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level);\r\ntypedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTUREFACEEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMPARAMETERIEXTPROC) (GLuint program, GLenum pname, GLint value);\r\n\r\n#define glFramebufferTextureEXT GLEW_GET_FUN(__glewFramebufferTextureEXT)\r\n#define glFramebufferTextureFaceEXT GLEW_GET_FUN(__glewFramebufferTextureFaceEXT)\r\n#define glProgramParameteriEXT GLEW_GET_FUN(__glewProgramParameteriEXT)\r\n\r\n#define GLEW_EXT_geometry_shader4 GLEW_GET_VAR(__GLEW_EXT_geometry_shader4)\r\n\r\n#endif /* GL_EXT_geometry_shader4 */\r\n\r\n/* --------------------- GL_EXT_gpu_program_parameters --------------------- */\r\n\r\n#ifndef GL_EXT_gpu_program_parameters\r\n#define GL_EXT_gpu_program_parameters 1\r\n\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat* params);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat* params);\r\n\r\n#define glProgramEnvParameters4fvEXT GLEW_GET_FUN(__glewProgramEnvParameters4fvEXT)\r\n#define glProgramLocalParameters4fvEXT GLEW_GET_FUN(__glewProgramLocalParameters4fvEXT)\r\n\r\n#define GLEW_EXT_gpu_program_parameters GLEW_GET_VAR(__GLEW_EXT_gpu_program_parameters)\r\n\r\n#endif /* GL_EXT_gpu_program_parameters */\r\n\r\n/* --------------------------- GL_EXT_gpu_shader4 -------------------------- */\r\n\r\n#ifndef GL_EXT_gpu_shader4\r\n#define GL_EXT_gpu_shader4 1\r\n\r\n#define GL_VERTEX_ATTRIB_ARRAY_INTEGER_EXT 0x88FD\r\n#define GL_SAMPLER_1D_ARRAY_EXT 0x8DC0\r\n#define GL_SAMPLER_2D_ARRAY_EXT 0x8DC1\r\n#define GL_SAMPLER_BUFFER_EXT 0x8DC2\r\n#define GL_SAMPLER_1D_ARRAY_SHADOW_EXT 0x8DC3\r\n#define GL_SAMPLER_2D_ARRAY_SHADOW_EXT 0x8DC4\r\n#define GL_SAMPLER_CUBE_SHADOW_EXT 0x8DC5\r\n#define GL_UNSIGNED_INT_VEC2_EXT 0x8DC6\r\n#define GL_UNSIGNED_INT_VEC3_EXT 0x8DC7\r\n#define GL_UNSIGNED_INT_VEC4_EXT 0x8DC8\r\n#define GL_INT_SAMPLER_1D_EXT 0x8DC9\r\n#define GL_INT_SAMPLER_2D_EXT 0x8DCA\r\n#define GL_INT_SAMPLER_3D_EXT 0x8DCB\r\n#define GL_INT_SAMPLER_CUBE_EXT 0x8DCC\r\n#define GL_INT_SAMPLER_2D_RECT_EXT 0x8DCD\r\n#define GL_INT_SAMPLER_1D_ARRAY_EXT 0x8DCE\r\n#define GL_INT_SAMPLER_2D_ARRAY_EXT 0x8DCF\r\n#define GL_INT_SAMPLER_BUFFER_EXT 0x8DD0\r\n#define GL_UNSIGNED_INT_SAMPLER_1D_EXT 0x8DD1\r\n#define GL_UNSIGNED_INT_SAMPLER_2D_EXT 0x8DD2\r\n#define GL_UNSIGNED_INT_SAMPLER_3D_EXT 0x8DD3\r\n#define GL_UNSIGNED_INT_SAMPLER_CUBE_EXT 0x8DD4\r\n#define GL_UNSIGNED_INT_SAMPLER_2D_RECT_EXT 0x8DD5\r\n#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY_EXT 0x8DD6\r\n#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY_EXT 0x8DD7\r\n#define GL_UNSIGNED_INT_SAMPLER_BUFFER_EXT 0x8DD8\r\n\r\ntypedef void (GLAPIENTRY * PFNGLBINDFRAGDATALOCATIONEXTPROC) (GLuint program, GLuint color, const GLchar *name);\r\ntypedef GLint (GLAPIENTRY * PFNGLGETFRAGDATALOCATIONEXTPROC) (GLuint program, const GLchar *name);\r\ntypedef void (GLAPIENTRY * PFNGLGETUNIFORMUIVEXTPROC) (GLuint program, GLint location, GLuint *params);\r\ntypedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBIIVEXTPROC) (GLuint index, GLenum pname, GLint *params);\r\ntypedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBIUIVEXTPROC) (GLuint index, GLenum pname, GLuint *params);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORM1UIEXTPROC) (GLint location, GLuint v0);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORM1UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORM2UIEXTPROC) (GLint location, GLuint v0, GLuint v1);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORM2UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORM3UIEXTPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORM3UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORM4UIEXTPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORM4UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI1IEXTPROC) (GLuint index, GLint x);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI1IVEXTPROC) (GLuint index, const GLint *v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI1UIEXTPROC) (GLuint index, GLuint x);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI1UIVEXTPROC) (GLuint index, const GLuint *v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI2IEXTPROC) (GLuint index, GLint x, GLint y);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI2IVEXTPROC) (GLuint index, const GLint *v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI2UIEXTPROC) (GLuint index, GLuint x, GLuint y);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI2UIVEXTPROC) (GLuint index, const GLuint *v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI3IEXTPROC) (GLuint index, GLint x, GLint y, GLint z);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI3IVEXTPROC) (GLuint index, const GLint *v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI3UIEXTPROC) (GLuint index, GLuint x, GLuint y, GLuint z);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI3UIVEXTPROC) (GLuint index, const GLuint *v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4BVEXTPROC) (GLuint index, const GLbyte *v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4IEXTPROC) (GLuint index, GLint x, GLint y, GLint z, GLint w);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4IVEXTPROC) (GLuint index, const GLint *v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4SVEXTPROC) (GLuint index, const GLshort *v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4UBVEXTPROC) (GLuint index, const GLubyte *v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4UIEXTPROC) (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4UIVEXTPROC) (GLuint index, const GLuint *v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4USVEXTPROC) (GLuint index, const GLushort *v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBIPOINTEREXTPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer);\r\n\r\n#define glBindFragDataLocationEXT GLEW_GET_FUN(__glewBindFragDataLocationEXT)\r\n#define glGetFragDataLocationEXT GLEW_GET_FUN(__glewGetFragDataLocationEXT)\r\n#define glGetUniformuivEXT GLEW_GET_FUN(__glewGetUniformuivEXT)\r\n#define glGetVertexAttribIivEXT GLEW_GET_FUN(__glewGetVertexAttribIivEXT)\r\n#define glGetVertexAttribIuivEXT GLEW_GET_FUN(__glewGetVertexAttribIuivEXT)\r\n#define glUniform1uiEXT GLEW_GET_FUN(__glewUniform1uiEXT)\r\n#define glUniform1uivEXT GLEW_GET_FUN(__glewUniform1uivEXT)\r\n#define glUniform2uiEXT GLEW_GET_FUN(__glewUniform2uiEXT)\r\n#define glUniform2uivEXT GLEW_GET_FUN(__glewUniform2uivEXT)\r\n#define glUniform3uiEXT GLEW_GET_FUN(__glewUniform3uiEXT)\r\n#define glUniform3uivEXT GLEW_GET_FUN(__glewUniform3uivEXT)\r\n#define glUniform4uiEXT GLEW_GET_FUN(__glewUniform4uiEXT)\r\n#define glUniform4uivEXT GLEW_GET_FUN(__glewUniform4uivEXT)\r\n#define glVertexAttribI1iEXT GLEW_GET_FUN(__glewVertexAttribI1iEXT)\r\n#define glVertexAttribI1ivEXT GLEW_GET_FUN(__glewVertexAttribI1ivEXT)\r\n#define glVertexAttribI1uiEXT GLEW_GET_FUN(__glewVertexAttribI1uiEXT)\r\n#define glVertexAttribI1uivEXT GLEW_GET_FUN(__glewVertexAttribI1uivEXT)\r\n#define glVertexAttribI2iEXT GLEW_GET_FUN(__glewVertexAttribI2iEXT)\r\n#define glVertexAttribI2ivEXT GLEW_GET_FUN(__glewVertexAttribI2ivEXT)\r\n#define glVertexAttribI2uiEXT GLEW_GET_FUN(__glewVertexAttribI2uiEXT)\r\n#define glVertexAttribI2uivEXT GLEW_GET_FUN(__glewVertexAttribI2uivEXT)\r\n#define glVertexAttribI3iEXT GLEW_GET_FUN(__glewVertexAttribI3iEXT)\r\n#define glVertexAttribI3ivEXT GLEW_GET_FUN(__glewVertexAttribI3ivEXT)\r\n#define glVertexAttribI3uiEXT GLEW_GET_FUN(__glewVertexAttribI3uiEXT)\r\n#define glVertexAttribI3uivEXT GLEW_GET_FUN(__glewVertexAttribI3uivEXT)\r\n#define glVertexAttribI4bvEXT GLEW_GET_FUN(__glewVertexAttribI4bvEXT)\r\n#define glVertexAttribI4iEXT GLEW_GET_FUN(__glewVertexAttribI4iEXT)\r\n#define glVertexAttribI4ivEXT GLEW_GET_FUN(__glewVertexAttribI4ivEXT)\r\n#define glVertexAttribI4svEXT GLEW_GET_FUN(__glewVertexAttribI4svEXT)\r\n#define glVertexAttribI4ubvEXT GLEW_GET_FUN(__glewVertexAttribI4ubvEXT)\r\n#define glVertexAttribI4uiEXT GLEW_GET_FUN(__glewVertexAttribI4uiEXT)\r\n#define glVertexAttribI4uivEXT GLEW_GET_FUN(__glewVertexAttribI4uivEXT)\r\n#define glVertexAttribI4usvEXT GLEW_GET_FUN(__glewVertexAttribI4usvEXT)\r\n#define glVertexAttribIPointerEXT GLEW_GET_FUN(__glewVertexAttribIPointerEXT)\r\n\r\n#define GLEW_EXT_gpu_shader4 GLEW_GET_VAR(__GLEW_EXT_gpu_shader4)\r\n\r\n#endif /* GL_EXT_gpu_shader4 */\r\n\r\n/* ---------------------------- GL_EXT_histogram --------------------------- */\r\n\r\n#ifndef GL_EXT_histogram\r\n#define GL_EXT_histogram 1\r\n\r\n#define GL_HISTOGRAM_EXT 0x8024\r\n#define GL_PROXY_HISTOGRAM_EXT 0x8025\r\n#define GL_HISTOGRAM_WIDTH_EXT 0x8026\r\n#define GL_HISTOGRAM_FORMAT_EXT 0x8027\r\n#define GL_HISTOGRAM_RED_SIZE_EXT 0x8028\r\n#define GL_HISTOGRAM_GREEN_SIZE_EXT 0x8029\r\n#define GL_HISTOGRAM_BLUE_SIZE_EXT 0x802A\r\n#define GL_HISTOGRAM_ALPHA_SIZE_EXT 0x802B\r\n#define GL_HISTOGRAM_LUMINANCE_SIZE_EXT 0x802C\r\n#define GL_HISTOGRAM_SINK_EXT 0x802D\r\n#define GL_MINMAX_EXT 0x802E\r\n#define GL_MINMAX_FORMAT_EXT 0x802F\r\n#define GL_MINMAX_SINK_EXT 0x8030\r\n\r\ntypedef void (GLAPIENTRY * PFNGLGETHISTOGRAMEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values);\r\ntypedef void (GLAPIENTRY * PFNGLGETHISTOGRAMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETHISTOGRAMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETMINMAXEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values);\r\ntypedef void (GLAPIENTRY * PFNGLGETMINMAXPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETMINMAXPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint* params);\r\ntypedef void (GLAPIENTRY * PFNGLHISTOGRAMEXTPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink);\r\ntypedef void (GLAPIENTRY * PFNGLMINMAXEXTPROC) (GLenum target, GLenum internalformat, GLboolean sink);\r\ntypedef void (GLAPIENTRY * PFNGLRESETHISTOGRAMEXTPROC) (GLenum target);\r\ntypedef void (GLAPIENTRY * PFNGLRESETMINMAXEXTPROC) (GLenum target);\r\n\r\n#define glGetHistogramEXT GLEW_GET_FUN(__glewGetHistogramEXT)\r\n#define glGetHistogramParameterfvEXT GLEW_GET_FUN(__glewGetHistogramParameterfvEXT)\r\n#define glGetHistogramParameterivEXT GLEW_GET_FUN(__glewGetHistogramParameterivEXT)\r\n#define glGetMinmaxEXT GLEW_GET_FUN(__glewGetMinmaxEXT)\r\n#define glGetMinmaxParameterfvEXT GLEW_GET_FUN(__glewGetMinmaxParameterfvEXT)\r\n#define glGetMinmaxParameterivEXT GLEW_GET_FUN(__glewGetMinmaxParameterivEXT)\r\n#define glHistogramEXT GLEW_GET_FUN(__glewHistogramEXT)\r\n#define glMinmaxEXT GLEW_GET_FUN(__glewMinmaxEXT)\r\n#define glResetHistogramEXT GLEW_GET_FUN(__glewResetHistogramEXT)\r\n#define glResetMinmaxEXT GLEW_GET_FUN(__glewResetMinmaxEXT)\r\n\r\n#define GLEW_EXT_histogram GLEW_GET_VAR(__GLEW_EXT_histogram)\r\n\r\n#endif /* GL_EXT_histogram */\r\n\r\n/* ----------------------- GL_EXT_index_array_formats ---------------------- */\r\n\r\n#ifndef GL_EXT_index_array_formats\r\n#define GL_EXT_index_array_formats 1\r\n\r\n#define GLEW_EXT_index_array_formats GLEW_GET_VAR(__GLEW_EXT_index_array_formats)\r\n\r\n#endif /* GL_EXT_index_array_formats */\r\n\r\n/* --------------------------- GL_EXT_index_func --------------------------- */\r\n\r\n#ifndef GL_EXT_index_func\r\n#define GL_EXT_index_func 1\r\n\r\ntypedef void (GLAPIENTRY * PFNGLINDEXFUNCEXTPROC) (GLenum func, GLfloat ref);\r\n\r\n#define glIndexFuncEXT GLEW_GET_FUN(__glewIndexFuncEXT)\r\n\r\n#define GLEW_EXT_index_func GLEW_GET_VAR(__GLEW_EXT_index_func)\r\n\r\n#endif /* GL_EXT_index_func */\r\n\r\n/* ------------------------- GL_EXT_index_material ------------------------- */\r\n\r\n#ifndef GL_EXT_index_material\r\n#define GL_EXT_index_material 1\r\n\r\ntypedef void (GLAPIENTRY * PFNGLINDEXMATERIALEXTPROC) (GLenum face, GLenum mode);\r\n\r\n#define glIndexMaterialEXT GLEW_GET_FUN(__glewIndexMaterialEXT)\r\n\r\n#define GLEW_EXT_index_material GLEW_GET_VAR(__GLEW_EXT_index_material)\r\n\r\n#endif /* GL_EXT_index_material */\r\n\r\n/* -------------------------- GL_EXT_index_texture ------------------------- */\r\n\r\n#ifndef GL_EXT_index_texture\r\n#define GL_EXT_index_texture 1\r\n\r\n#define GLEW_EXT_index_texture GLEW_GET_VAR(__GLEW_EXT_index_texture)\r\n\r\n#endif /* GL_EXT_index_texture */\r\n\r\n/* -------------------------- GL_EXT_light_texture ------------------------- */\r\n\r\n#ifndef GL_EXT_light_texture\r\n#define GL_EXT_light_texture 1\r\n\r\n#define GL_FRAGMENT_MATERIAL_EXT 0x8349\r\n#define GL_FRAGMENT_NORMAL_EXT 0x834A\r\n#define GL_FRAGMENT_COLOR_EXT 0x834C\r\n#define GL_ATTENUATION_EXT 0x834D\r\n#define GL_SHADOW_ATTENUATION_EXT 0x834E\r\n#define GL_TEXTURE_APPLICATION_MODE_EXT 0x834F\r\n#define GL_TEXTURE_LIGHT_EXT 0x8350\r\n#define GL_TEXTURE_MATERIAL_FACE_EXT 0x8351\r\n#define GL_TEXTURE_MATERIAL_PARAMETER_EXT 0x8352\r\n\r\ntypedef void (GLAPIENTRY * PFNGLAPPLYTEXTUREEXTPROC) (GLenum mode);\r\ntypedef void (GLAPIENTRY * PFNGLTEXTURELIGHTEXTPROC) (GLenum pname);\r\ntypedef void (GLAPIENTRY * PFNGLTEXTUREMATERIALEXTPROC) (GLenum face, GLenum mode);\r\n\r\n#define glApplyTextureEXT GLEW_GET_FUN(__glewApplyTextureEXT)\r\n#define glTextureLightEXT GLEW_GET_FUN(__glewTextureLightEXT)\r\n#define glTextureMaterialEXT GLEW_GET_FUN(__glewTextureMaterialEXT)\r\n\r\n#define GLEW_EXT_light_texture GLEW_GET_VAR(__GLEW_EXT_light_texture)\r\n\r\n#endif /* GL_EXT_light_texture */\r\n\r\n/* ------------------------- GL_EXT_misc_attribute ------------------------- */\r\n\r\n#ifndef GL_EXT_misc_attribute\r\n#define GL_EXT_misc_attribute 1\r\n\r\n#define GLEW_EXT_misc_attribute GLEW_GET_VAR(__GLEW_EXT_misc_attribute)\r\n\r\n#endif /* GL_EXT_misc_attribute */\r\n\r\n/* ------------------------ GL_EXT_multi_draw_arrays ----------------------- */\r\n\r\n#ifndef GL_EXT_multi_draw_arrays\r\n#define GL_EXT_multi_draw_arrays 1\r\n\r\ntypedef void (GLAPIENTRY * PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, const GLint* first, const GLsizei *count, GLsizei primcount);\r\ntypedef void (GLAPIENTRY * PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, GLsizei* count, GLenum type, const void *const *indices, GLsizei primcount);\r\n\r\n#define glMultiDrawArraysEXT GLEW_GET_FUN(__glewMultiDrawArraysEXT)\r\n#define glMultiDrawElementsEXT GLEW_GET_FUN(__glewMultiDrawElementsEXT)\r\n\r\n#define GLEW_EXT_multi_draw_arrays GLEW_GET_VAR(__GLEW_EXT_multi_draw_arrays)\r\n\r\n#endif /* GL_EXT_multi_draw_arrays */\r\n\r\n/* --------------------------- GL_EXT_multisample -------------------------- */\r\n\r\n#ifndef GL_EXT_multisample\r\n#define GL_EXT_multisample 1\r\n\r\n#define GL_MULTISAMPLE_EXT 0x809D\r\n#define GL_SAMPLE_ALPHA_TO_MASK_EXT 0x809E\r\n#define GL_SAMPLE_ALPHA_TO_ONE_EXT 0x809F\r\n#define GL_SAMPLE_MASK_EXT 0x80A0\r\n#define GL_1PASS_EXT 0x80A1\r\n#define GL_2PASS_0_EXT 0x80A2\r\n#define GL_2PASS_1_EXT 0x80A3\r\n#define GL_4PASS_0_EXT 0x80A4\r\n#define GL_4PASS_1_EXT 0x80A5\r\n#define GL_4PASS_2_EXT 0x80A6\r\n#define GL_4PASS_3_EXT 0x80A7\r\n#define GL_SAMPLE_BUFFERS_EXT 0x80A8\r\n#define GL_SAMPLES_EXT 0x80A9\r\n#define GL_SAMPLE_MASK_VALUE_EXT 0x80AA\r\n#define GL_SAMPLE_MASK_INVERT_EXT 0x80AB\r\n#define GL_SAMPLE_PATTERN_EXT 0x80AC\r\n#define GL_MULTISAMPLE_BIT_EXT 0x20000000\r\n\r\ntypedef void (GLAPIENTRY * PFNGLSAMPLEMASKEXTPROC) (GLclampf value, GLboolean invert);\r\ntypedef void (GLAPIENTRY * PFNGLSAMPLEPATTERNEXTPROC) (GLenum pattern);\r\n\r\n#define glSampleMaskEXT GLEW_GET_FUN(__glewSampleMaskEXT)\r\n#define glSamplePatternEXT GLEW_GET_FUN(__glewSamplePatternEXT)\r\n\r\n#define GLEW_EXT_multisample GLEW_GET_VAR(__GLEW_EXT_multisample)\r\n\r\n#endif /* GL_EXT_multisample */\r\n\r\n/* ---------------------- GL_EXT_packed_depth_stencil ---------------------- */\r\n\r\n#ifndef GL_EXT_packed_depth_stencil\r\n#define GL_EXT_packed_depth_stencil 1\r\n\r\n#define GL_DEPTH_STENCIL_EXT 0x84F9\r\n#define GL_UNSIGNED_INT_24_8_EXT 0x84FA\r\n#define GL_DEPTH24_STENCIL8_EXT 0x88F0\r\n#define GL_TEXTURE_STENCIL_SIZE_EXT 0x88F1\r\n\r\n#define GLEW_EXT_packed_depth_stencil GLEW_GET_VAR(__GLEW_EXT_packed_depth_stencil)\r\n\r\n#endif /* GL_EXT_packed_depth_stencil */\r\n\r\n/* -------------------------- GL_EXT_packed_float -------------------------- */\r\n\r\n#ifndef GL_EXT_packed_float\r\n#define GL_EXT_packed_float 1\r\n\r\n#define GL_R11F_G11F_B10F_EXT 0x8C3A\r\n#define GL_UNSIGNED_INT_10F_11F_11F_REV_EXT 0x8C3B\r\n#define GL_RGBA_SIGNED_COMPONENTS_EXT 0x8C3C\r\n\r\n#define GLEW_EXT_packed_float GLEW_GET_VAR(__GLEW_EXT_packed_float)\r\n\r\n#endif /* GL_EXT_packed_float */\r\n\r\n/* -------------------------- GL_EXT_packed_pixels ------------------------- */\r\n\r\n#ifndef GL_EXT_packed_pixels\r\n#define GL_EXT_packed_pixels 1\r\n\r\n#define GL_UNSIGNED_BYTE_3_3_2_EXT 0x8032\r\n#define GL_UNSIGNED_SHORT_4_4_4_4_EXT 0x8033\r\n#define GL_UNSIGNED_SHORT_5_5_5_1_EXT 0x8034\r\n#define GL_UNSIGNED_INT_8_8_8_8_EXT 0x8035\r\n#define GL_UNSIGNED_INT_10_10_10_2_EXT 0x8036\r\n\r\n#define GLEW_EXT_packed_pixels GLEW_GET_VAR(__GLEW_EXT_packed_pixels)\r\n\r\n#endif /* GL_EXT_packed_pixels */\r\n\r\n/* ------------------------ GL_EXT_paletted_texture ------------------------ */\r\n\r\n#ifndef GL_EXT_paletted_texture\r\n#define GL_EXT_paletted_texture 1\r\n\r\n#define GL_TEXTURE_1D 0x0DE0\r\n#define GL_TEXTURE_2D 0x0DE1\r\n#define GL_PROXY_TEXTURE_1D 0x8063\r\n#define GL_PROXY_TEXTURE_2D 0x8064\r\n#define GL_COLOR_TABLE_FORMAT_EXT 0x80D8\r\n#define GL_COLOR_TABLE_WIDTH_EXT 0x80D9\r\n#define GL_COLOR_TABLE_RED_SIZE_EXT 0x80DA\r\n#define GL_COLOR_TABLE_GREEN_SIZE_EXT 0x80DB\r\n#define GL_COLOR_TABLE_BLUE_SIZE_EXT 0x80DC\r\n#define GL_COLOR_TABLE_ALPHA_SIZE_EXT 0x80DD\r\n#define GL_COLOR_TABLE_LUMINANCE_SIZE_EXT 0x80DE\r\n#define GL_COLOR_TABLE_INTENSITY_SIZE_EXT 0x80DF\r\n#define GL_COLOR_INDEX1_EXT 0x80E2\r\n#define GL_COLOR_INDEX2_EXT 0x80E3\r\n#define GL_COLOR_INDEX4_EXT 0x80E4\r\n#define GL_COLOR_INDEX8_EXT 0x80E5\r\n#define GL_COLOR_INDEX12_EXT 0x80E6\r\n#define GL_COLOR_INDEX16_EXT 0x80E7\r\n#define GL_TEXTURE_INDEX_SIZE_EXT 0x80ED\r\n#define GL_TEXTURE_CUBE_MAP_ARB 0x8513\r\n#define GL_PROXY_TEXTURE_CUBE_MAP_ARB 0x851B\r\n\r\ntypedef void (GLAPIENTRY * PFNGLCOLORTABLEEXTPROC) (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const void *data);\r\ntypedef void (GLAPIENTRY * PFNGLGETCOLORTABLEEXTPROC) (GLenum target, GLenum format, GLenum type, void *data);\r\ntypedef void (GLAPIENTRY * PFNGLGETCOLORTABLEPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETCOLORTABLEPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint* params);\r\n\r\n#define glColorTableEXT GLEW_GET_FUN(__glewColorTableEXT)\r\n#define glGetColorTableEXT GLEW_GET_FUN(__glewGetColorTableEXT)\r\n#define glGetColorTableParameterfvEXT GLEW_GET_FUN(__glewGetColorTableParameterfvEXT)\r\n#define glGetColorTableParameterivEXT GLEW_GET_FUN(__glewGetColorTableParameterivEXT)\r\n\r\n#define GLEW_EXT_paletted_texture GLEW_GET_VAR(__GLEW_EXT_paletted_texture)\r\n\r\n#endif /* GL_EXT_paletted_texture */\r\n\r\n/* ----------------------- GL_EXT_pixel_buffer_object ---------------------- */\r\n\r\n#ifndef GL_EXT_pixel_buffer_object\r\n#define GL_EXT_pixel_buffer_object 1\r\n\r\n#define GL_PIXEL_PACK_BUFFER_EXT 0x88EB\r\n#define GL_PIXEL_UNPACK_BUFFER_EXT 0x88EC\r\n#define GL_PIXEL_PACK_BUFFER_BINDING_EXT 0x88ED\r\n#define GL_PIXEL_UNPACK_BUFFER_BINDING_EXT 0x88EF\r\n\r\n#define GLEW_EXT_pixel_buffer_object GLEW_GET_VAR(__GLEW_EXT_pixel_buffer_object)\r\n\r\n#endif /* GL_EXT_pixel_buffer_object */\r\n\r\n/* ------------------------- GL_EXT_pixel_transform ------------------------ */\r\n\r\n#ifndef GL_EXT_pixel_transform\r\n#define GL_EXT_pixel_transform 1\r\n\r\n#define GL_PIXEL_TRANSFORM_2D_EXT 0x8330\r\n#define GL_PIXEL_MAG_FILTER_EXT 0x8331\r\n#define GL_PIXEL_MIN_FILTER_EXT 0x8332\r\n#define GL_PIXEL_CUBIC_WEIGHT_EXT 0x8333\r\n#define GL_CUBIC_EXT 0x8334\r\n#define GL_AVERAGE_EXT 0x8335\r\n#define GL_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8336\r\n#define GL_MAX_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8337\r\n#define GL_PIXEL_TRANSFORM_2D_MATRIX_EXT 0x8338\r\n\r\ntypedef void (GLAPIENTRY * PFNGLGETPIXELTRANSFORMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETPIXELTRANSFORMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint* params);\r\ntypedef void (GLAPIENTRY * PFNGLPIXELTRANSFORMPARAMETERFEXTPROC) (GLenum target, GLenum pname, const GLfloat param);\r\ntypedef void (GLAPIENTRY * PFNGLPIXELTRANSFORMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat* params);\r\ntypedef void (GLAPIENTRY * PFNGLPIXELTRANSFORMPARAMETERIEXTPROC) (GLenum target, GLenum pname, const GLint param);\r\ntypedef void (GLAPIENTRY * PFNGLPIXELTRANSFORMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint* params);\r\n\r\n#define glGetPixelTransformParameterfvEXT GLEW_GET_FUN(__glewGetPixelTransformParameterfvEXT)\r\n#define glGetPixelTransformParameterivEXT GLEW_GET_FUN(__glewGetPixelTransformParameterivEXT)\r\n#define glPixelTransformParameterfEXT GLEW_GET_FUN(__glewPixelTransformParameterfEXT)\r\n#define glPixelTransformParameterfvEXT GLEW_GET_FUN(__glewPixelTransformParameterfvEXT)\r\n#define glPixelTransformParameteriEXT GLEW_GET_FUN(__glewPixelTransformParameteriEXT)\r\n#define glPixelTransformParameterivEXT GLEW_GET_FUN(__glewPixelTransformParameterivEXT)\r\n\r\n#define GLEW_EXT_pixel_transform GLEW_GET_VAR(__GLEW_EXT_pixel_transform)\r\n\r\n#endif /* GL_EXT_pixel_transform */\r\n\r\n/* ------------------- GL_EXT_pixel_transform_color_table ------------------ */\r\n\r\n#ifndef GL_EXT_pixel_transform_color_table\r\n#define GL_EXT_pixel_transform_color_table 1\r\n\r\n#define GLEW_EXT_pixel_transform_color_table GLEW_GET_VAR(__GLEW_EXT_pixel_transform_color_table)\r\n\r\n#endif /* GL_EXT_pixel_transform_color_table */\r\n\r\n/* ------------------------ GL_EXT_point_parameters ------------------------ */\r\n\r\n#ifndef GL_EXT_point_parameters\r\n#define GL_EXT_point_parameters 1\r\n\r\n#define GL_POINT_SIZE_MIN_EXT 0x8126\r\n#define GL_POINT_SIZE_MAX_EXT 0x8127\r\n#define GL_POINT_FADE_THRESHOLD_SIZE_EXT 0x8128\r\n#define GL_DISTANCE_ATTENUATION_EXT 0x8129\r\n\r\ntypedef void (GLAPIENTRY * PFNGLPOINTPARAMETERFEXTPROC) (GLenum pname, GLfloat param);\r\ntypedef void (GLAPIENTRY * PFNGLPOINTPARAMETERFVEXTPROC) (GLenum pname, const GLfloat* params);\r\n\r\n#define glPointParameterfEXT GLEW_GET_FUN(__glewPointParameterfEXT)\r\n#define glPointParameterfvEXT GLEW_GET_FUN(__glewPointParameterfvEXT)\r\n\r\n#define GLEW_EXT_point_parameters GLEW_GET_VAR(__GLEW_EXT_point_parameters)\r\n\r\n#endif /* GL_EXT_point_parameters */\r\n\r\n/* ------------------------- GL_EXT_polygon_offset ------------------------- */\r\n\r\n#ifndef GL_EXT_polygon_offset\r\n#define GL_EXT_polygon_offset 1\r\n\r\n#define GL_POLYGON_OFFSET_EXT 0x8037\r\n#define GL_POLYGON_OFFSET_FACTOR_EXT 0x8038\r\n#define GL_POLYGON_OFFSET_BIAS_EXT 0x8039\r\n\r\ntypedef void (GLAPIENTRY * PFNGLPOLYGONOFFSETEXTPROC) (GLfloat factor, GLfloat bias);\r\n\r\n#define glPolygonOffsetEXT GLEW_GET_FUN(__glewPolygonOffsetEXT)\r\n\r\n#define GLEW_EXT_polygon_offset GLEW_GET_VAR(__GLEW_EXT_polygon_offset)\r\n\r\n#endif /* GL_EXT_polygon_offset */\r\n\r\n/* ---------------------- GL_EXT_polygon_offset_clamp ---------------------- */\r\n\r\n#ifndef GL_EXT_polygon_offset_clamp\r\n#define GL_EXT_polygon_offset_clamp 1\r\n\r\n#define GL_POLYGON_OFFSET_CLAMP_EXT 0x8E1B\r\n\r\ntypedef void (GLAPIENTRY * PFNGLPOLYGONOFFSETCLAMPEXTPROC) (GLfloat factor, GLfloat units, GLfloat clamp);\r\n\r\n#define glPolygonOffsetClampEXT GLEW_GET_FUN(__glewPolygonOffsetClampEXT)\r\n\r\n#define GLEW_EXT_polygon_offset_clamp GLEW_GET_VAR(__GLEW_EXT_polygon_offset_clamp)\r\n\r\n#endif /* GL_EXT_polygon_offset_clamp */\r\n\r\n/* ----------------------- GL_EXT_post_depth_coverage ---------------------- */\r\n\r\n#ifndef GL_EXT_post_depth_coverage\r\n#define GL_EXT_post_depth_coverage 1\r\n\r\n#define GLEW_EXT_post_depth_coverage GLEW_GET_VAR(__GLEW_EXT_post_depth_coverage)\r\n\r\n#endif /* GL_EXT_post_depth_coverage */\r\n\r\n/* ------------------------ GL_EXT_provoking_vertex ------------------------ */\r\n\r\n#ifndef GL_EXT_provoking_vertex\r\n#define GL_EXT_provoking_vertex 1\r\n\r\n#define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION_EXT 0x8E4C\r\n#define GL_FIRST_VERTEX_CONVENTION_EXT 0x8E4D\r\n#define GL_LAST_VERTEX_CONVENTION_EXT 0x8E4E\r\n#define GL_PROVOKING_VERTEX_EXT 0x8E4F\r\n\r\ntypedef void (GLAPIENTRY * PFNGLPROVOKINGVERTEXEXTPROC) (GLenum mode);\r\n\r\n#define glProvokingVertexEXT GLEW_GET_FUN(__glewProvokingVertexEXT)\r\n\r\n#define GLEW_EXT_provoking_vertex GLEW_GET_VAR(__GLEW_EXT_provoking_vertex)\r\n\r\n#endif /* GL_EXT_provoking_vertex */\r\n\r\n/* ----------------------- GL_EXT_raster_multisample ----------------------- */\r\n\r\n#ifndef GL_EXT_raster_multisample\r\n#define GL_EXT_raster_multisample 1\r\n\r\n#define GL_COLOR_SAMPLES_NV 0x8E20\r\n#define GL_RASTER_MULTISAMPLE_EXT 0x9327\r\n#define GL_RASTER_SAMPLES_EXT 0x9328\r\n#define GL_MAX_RASTER_SAMPLES_EXT 0x9329\r\n#define GL_RASTER_FIXED_SAMPLE_LOCATIONS_EXT 0x932A\r\n#define GL_MULTISAMPLE_RASTERIZATION_ALLOWED_EXT 0x932B\r\n#define GL_EFFECTIVE_RASTER_SAMPLES_EXT 0x932C\r\n#define GL_DEPTH_SAMPLES_NV 0x932D\r\n#define GL_STENCIL_SAMPLES_NV 0x932E\r\n#define GL_MIXED_DEPTH_SAMPLES_SUPPORTED_NV 0x932F\r\n#define GL_MIXED_STENCIL_SAMPLES_SUPPORTED_NV 0x9330\r\n#define GL_COVERAGE_MODULATION_TABLE_NV 0x9331\r\n#define GL_COVERAGE_MODULATION_NV 0x9332\r\n#define GL_COVERAGE_MODULATION_TABLE_SIZE_NV 0x9333\r\n\r\ntypedef void (GLAPIENTRY * PFNGLCOVERAGEMODULATIONNVPROC) (GLenum components);\r\ntypedef void (GLAPIENTRY * PFNGLCOVERAGEMODULATIONTABLENVPROC) (GLsizei n, const GLfloat* v);\r\ntypedef void (GLAPIENTRY * PFNGLGETCOVERAGEMODULATIONTABLENVPROC) (GLsizei bufsize, GLfloat* v);\r\ntypedef void (GLAPIENTRY * PFNGLRASTERSAMPLESEXTPROC) (GLuint samples, GLboolean fixedsamplelocations);\r\n\r\n#define glCoverageModulationNV GLEW_GET_FUN(__glewCoverageModulationNV)\r\n#define glCoverageModulationTableNV GLEW_GET_FUN(__glewCoverageModulationTableNV)\r\n#define glGetCoverageModulationTableNV GLEW_GET_FUN(__glewGetCoverageModulationTableNV)\r\n#define glRasterSamplesEXT GLEW_GET_FUN(__glewRasterSamplesEXT)\r\n\r\n#define GLEW_EXT_raster_multisample GLEW_GET_VAR(__GLEW_EXT_raster_multisample)\r\n\r\n#endif /* GL_EXT_raster_multisample */\r\n\r\n/* ------------------------- GL_EXT_rescale_normal ------------------------- */\r\n\r\n#ifndef GL_EXT_rescale_normal\r\n#define GL_EXT_rescale_normal 1\r\n\r\n#define GL_RESCALE_NORMAL_EXT 0x803A\r\n\r\n#define GLEW_EXT_rescale_normal GLEW_GET_VAR(__GLEW_EXT_rescale_normal)\r\n\r\n#endif /* GL_EXT_rescale_normal */\r\n\r\n/* -------------------------- GL_EXT_scene_marker -------------------------- */\r\n\r\n#ifndef GL_EXT_scene_marker\r\n#define GL_EXT_scene_marker 1\r\n\r\ntypedef void (GLAPIENTRY * PFNGLBEGINSCENEEXTPROC) (void);\r\ntypedef void (GLAPIENTRY * PFNGLENDSCENEEXTPROC) (void);\r\n\r\n#define glBeginSceneEXT GLEW_GET_FUN(__glewBeginSceneEXT)\r\n#define glEndSceneEXT GLEW_GET_FUN(__glewEndSceneEXT)\r\n\r\n#define GLEW_EXT_scene_marker GLEW_GET_VAR(__GLEW_EXT_scene_marker)\r\n\r\n#endif /* GL_EXT_scene_marker */\r\n\r\n/* ------------------------- GL_EXT_secondary_color ------------------------ */\r\n\r\n#ifndef GL_EXT_secondary_color\r\n#define GL_EXT_secondary_color 1\r\n\r\n#define GL_COLOR_SUM_EXT 0x8458\r\n#define GL_CURRENT_SECONDARY_COLOR_EXT 0x8459\r\n#define GL_SECONDARY_COLOR_ARRAY_SIZE_EXT 0x845A\r\n#define GL_SECONDARY_COLOR_ARRAY_TYPE_EXT 0x845B\r\n#define GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT 0x845C\r\n#define GL_SECONDARY_COLOR_ARRAY_POINTER_EXT 0x845D\r\n#define GL_SECONDARY_COLOR_ARRAY_EXT 0x845E\r\n\r\ntypedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3BEXTPROC) (GLbyte red, GLbyte green, GLbyte blue);\r\ntypedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3BVEXTPROC) (const GLbyte *v);\r\ntypedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3DEXTPROC) (GLdouble red, GLdouble green, GLdouble blue);\r\ntypedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3DVEXTPROC) (const GLdouble *v);\r\ntypedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3FEXTPROC) (GLfloat red, GLfloat green, GLfloat blue);\r\ntypedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3FVEXTPROC) (const GLfloat *v);\r\ntypedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3IEXTPROC) (GLint red, GLint green, GLint blue);\r\ntypedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3IVEXTPROC) (const GLint *v);\r\ntypedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3SEXTPROC) (GLshort red, GLshort green, GLshort blue);\r\ntypedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3SVEXTPROC) (const GLshort *v);\r\ntypedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3UBEXTPROC) (GLubyte red, GLubyte green, GLubyte blue);\r\ntypedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3UBVEXTPROC) (const GLubyte *v);\r\ntypedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3UIEXTPROC) (GLuint red, GLuint green, GLuint blue);\r\ntypedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3UIVEXTPROC) (const GLuint *v);\r\ntypedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3USEXTPROC) (GLushort red, GLushort green, GLushort blue);\r\ntypedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3USVEXTPROC) (const GLushort *v);\r\ntypedef void (GLAPIENTRY * PFNGLSECONDARYCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, const void *pointer);\r\n\r\n#define glSecondaryColor3bEXT GLEW_GET_FUN(__glewSecondaryColor3bEXT)\r\n#define glSecondaryColor3bvEXT GLEW_GET_FUN(__glewSecondaryColor3bvEXT)\r\n#define glSecondaryColor3dEXT GLEW_GET_FUN(__glewSecondaryColor3dEXT)\r\n#define glSecondaryColor3dvEXT GLEW_GET_FUN(__glewSecondaryColor3dvEXT)\r\n#define glSecondaryColor3fEXT GLEW_GET_FUN(__glewSecondaryColor3fEXT)\r\n#define glSecondaryColor3fvEXT GLEW_GET_FUN(__glewSecondaryColor3fvEXT)\r\n#define glSecondaryColor3iEXT GLEW_GET_FUN(__glewSecondaryColor3iEXT)\r\n#define glSecondaryColor3ivEXT GLEW_GET_FUN(__glewSecondaryColor3ivEXT)\r\n#define glSecondaryColor3sEXT GLEW_GET_FUN(__glewSecondaryColor3sEXT)\r\n#define glSecondaryColor3svEXT GLEW_GET_FUN(__glewSecondaryColor3svEXT)\r\n#define glSecondaryColor3ubEXT GLEW_GET_FUN(__glewSecondaryColor3ubEXT)\r\n#define glSecondaryColor3ubvEXT GLEW_GET_FUN(__glewSecondaryColor3ubvEXT)\r\n#define glSecondaryColor3uiEXT GLEW_GET_FUN(__glewSecondaryColor3uiEXT)\r\n#define glSecondaryColor3uivEXT GLEW_GET_FUN(__glewSecondaryColor3uivEXT)\r\n#define glSecondaryColor3usEXT GLEW_GET_FUN(__glewSecondaryColor3usEXT)\r\n#define glSecondaryColor3usvEXT GLEW_GET_FUN(__glewSecondaryColor3usvEXT)\r\n#define glSecondaryColorPointerEXT GLEW_GET_FUN(__glewSecondaryColorPointerEXT)\r\n\r\n#define GLEW_EXT_secondary_color GLEW_GET_VAR(__GLEW_EXT_secondary_color)\r\n\r\n#endif /* GL_EXT_secondary_color */\r\n\r\n/* --------------------- GL_EXT_separate_shader_objects -------------------- */\r\n\r\n#ifndef GL_EXT_separate_shader_objects\r\n#define GL_EXT_separate_shader_objects 1\r\n\r\n#define GL_ACTIVE_PROGRAM_EXT 0x8B8D\r\n\r\ntypedef void (GLAPIENTRY * PFNGLACTIVEPROGRAMEXTPROC) (GLuint program);\r\ntypedef GLuint (GLAPIENTRY * PFNGLCREATESHADERPROGRAMEXTPROC) (GLenum type, const GLchar* string);\r\ntypedef void (GLAPIENTRY * PFNGLUSESHADERPROGRAMEXTPROC) (GLenum type, GLuint program);\r\n\r\n#define glActiveProgramEXT GLEW_GET_FUN(__glewActiveProgramEXT)\r\n#define glCreateShaderProgramEXT GLEW_GET_FUN(__glewCreateShaderProgramEXT)\r\n#define glUseShaderProgramEXT GLEW_GET_FUN(__glewUseShaderProgramEXT)\r\n\r\n#define GLEW_EXT_separate_shader_objects GLEW_GET_VAR(__GLEW_EXT_separate_shader_objects)\r\n\r\n#endif /* GL_EXT_separate_shader_objects */\r\n\r\n/* --------------------- GL_EXT_separate_specular_color -------------------- */\r\n\r\n#ifndef GL_EXT_separate_specular_color\r\n#define GL_EXT_separate_specular_color 1\r\n\r\n#define GL_LIGHT_MODEL_COLOR_CONTROL_EXT 0x81F8\r\n#define GL_SINGLE_COLOR_EXT 0x81F9\r\n#define GL_SEPARATE_SPECULAR_COLOR_EXT 0x81FA\r\n\r\n#define GLEW_EXT_separate_specular_color GLEW_GET_VAR(__GLEW_EXT_separate_specular_color)\r\n\r\n#endif /* GL_EXT_separate_specular_color */\r\n\r\n/* ------------------- GL_EXT_shader_image_load_formatted ------------------ */\r\n\r\n#ifndef GL_EXT_shader_image_load_formatted\r\n#define GL_EXT_shader_image_load_formatted 1\r\n\r\n#define GLEW_EXT_shader_image_load_formatted GLEW_GET_VAR(__GLEW_EXT_shader_image_load_formatted)\r\n\r\n#endif /* GL_EXT_shader_image_load_formatted */\r\n\r\n/* --------------------- GL_EXT_shader_image_load_store -------------------- */\r\n\r\n#ifndef GL_EXT_shader_image_load_store\r\n#define GL_EXT_shader_image_load_store 1\r\n\r\n#define GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT_EXT 0x00000001\r\n#define GL_ELEMENT_ARRAY_BARRIER_BIT_EXT 0x00000002\r\n#define GL_UNIFORM_BARRIER_BIT_EXT 0x00000004\r\n#define GL_TEXTURE_FETCH_BARRIER_BIT_EXT 0x00000008\r\n#define GL_SHADER_IMAGE_ACCESS_BARRIER_BIT_EXT 0x00000020\r\n#define GL_COMMAND_BARRIER_BIT_EXT 0x00000040\r\n#define GL_PIXEL_BUFFER_BARRIER_BIT_EXT 0x00000080\r\n#define GL_TEXTURE_UPDATE_BARRIER_BIT_EXT 0x00000100\r\n#define GL_BUFFER_UPDATE_BARRIER_BIT_EXT 0x00000200\r\n#define GL_FRAMEBUFFER_BARRIER_BIT_EXT 0x00000400\r\n#define GL_TRANSFORM_FEEDBACK_BARRIER_BIT_EXT 0x00000800\r\n#define GL_ATOMIC_COUNTER_BARRIER_BIT_EXT 0x00001000\r\n#define GL_MAX_IMAGE_UNITS_EXT 0x8F38\r\n#define GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS_EXT 0x8F39\r\n#define GL_IMAGE_BINDING_NAME_EXT 0x8F3A\r\n#define GL_IMAGE_BINDING_LEVEL_EXT 0x8F3B\r\n#define GL_IMAGE_BINDING_LAYERED_EXT 0x8F3C\r\n#define GL_IMAGE_BINDING_LAYER_EXT 0x8F3D\r\n#define GL_IMAGE_BINDING_ACCESS_EXT 0x8F3E\r\n#define GL_IMAGE_1D_EXT 0x904C\r\n#define GL_IMAGE_2D_EXT 0x904D\r\n#define GL_IMAGE_3D_EXT 0x904E\r\n#define GL_IMAGE_2D_RECT_EXT 0x904F\r\n#define GL_IMAGE_CUBE_EXT 0x9050\r\n#define GL_IMAGE_BUFFER_EXT 0x9051\r\n#define GL_IMAGE_1D_ARRAY_EXT 0x9052\r\n#define GL_IMAGE_2D_ARRAY_EXT 0x9053\r\n#define GL_IMAGE_CUBE_MAP_ARRAY_EXT 0x9054\r\n#define GL_IMAGE_2D_MULTISAMPLE_EXT 0x9055\r\n#define GL_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x9056\r\n#define GL_INT_IMAGE_1D_EXT 0x9057\r\n#define GL_INT_IMAGE_2D_EXT 0x9058\r\n#define GL_INT_IMAGE_3D_EXT 0x9059\r\n#define GL_INT_IMAGE_2D_RECT_EXT 0x905A\r\n#define GL_INT_IMAGE_CUBE_EXT 0x905B\r\n#define GL_INT_IMAGE_BUFFER_EXT 0x905C\r\n#define GL_INT_IMAGE_1D_ARRAY_EXT 0x905D\r\n#define GL_INT_IMAGE_2D_ARRAY_EXT 0x905E\r\n#define GL_INT_IMAGE_CUBE_MAP_ARRAY_EXT 0x905F\r\n#define GL_INT_IMAGE_2D_MULTISAMPLE_EXT 0x9060\r\n#define GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x9061\r\n#define GL_UNSIGNED_INT_IMAGE_1D_EXT 0x9062\r\n#define GL_UNSIGNED_INT_IMAGE_2D_EXT 0x9063\r\n#define GL_UNSIGNED_INT_IMAGE_3D_EXT 0x9064\r\n#define GL_UNSIGNED_INT_IMAGE_2D_RECT_EXT 0x9065\r\n#define GL_UNSIGNED_INT_IMAGE_CUBE_EXT 0x9066\r\n#define GL_UNSIGNED_INT_IMAGE_BUFFER_EXT 0x9067\r\n#define GL_UNSIGNED_INT_IMAGE_1D_ARRAY_EXT 0x9068\r\n#define GL_UNSIGNED_INT_IMAGE_2D_ARRAY_EXT 0x9069\r\n#define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY_EXT 0x906A\r\n#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_EXT 0x906B\r\n#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x906C\r\n#define GL_MAX_IMAGE_SAMPLES_EXT 0x906D\r\n#define GL_IMAGE_BINDING_FORMAT_EXT 0x906E\r\n#define GL_ALL_BARRIER_BITS_EXT 0xFFFFFFFF\r\n\r\ntypedef void (GLAPIENTRY * PFNGLBINDIMAGETEXTUREEXTPROC) (GLuint index, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLint format);\r\ntypedef void (GLAPIENTRY * PFNGLMEMORYBARRIEREXTPROC) (GLbitfield barriers);\r\n\r\n#define glBindImageTextureEXT GLEW_GET_FUN(__glewBindImageTextureEXT)\r\n#define glMemoryBarrierEXT GLEW_GET_FUN(__glewMemoryBarrierEXT)\r\n\r\n#define GLEW_EXT_shader_image_load_store GLEW_GET_VAR(__GLEW_EXT_shader_image_load_store)\r\n\r\n#endif /* GL_EXT_shader_image_load_store */\r\n\r\n/* ----------------------- GL_EXT_shader_integer_mix ----------------------- */\r\n\r\n#ifndef GL_EXT_shader_integer_mix\r\n#define GL_EXT_shader_integer_mix 1\r\n\r\n#define GLEW_EXT_shader_integer_mix GLEW_GET_VAR(__GLEW_EXT_shader_integer_mix)\r\n\r\n#endif /* GL_EXT_shader_integer_mix */\r\n\r\n/* -------------------------- GL_EXT_shadow_funcs -------------------------- */\r\n\r\n#ifndef GL_EXT_shadow_funcs\r\n#define GL_EXT_shadow_funcs 1\r\n\r\n#define GLEW_EXT_shadow_funcs GLEW_GET_VAR(__GLEW_EXT_shadow_funcs)\r\n\r\n#endif /* GL_EXT_shadow_funcs */\r\n\r\n/* --------------------- GL_EXT_shared_texture_palette --------------------- */\r\n\r\n#ifndef GL_EXT_shared_texture_palette\r\n#define GL_EXT_shared_texture_palette 1\r\n\r\n#define GL_SHARED_TEXTURE_PALETTE_EXT 0x81FB\r\n\r\n#define GLEW_EXT_shared_texture_palette GLEW_GET_VAR(__GLEW_EXT_shared_texture_palette)\r\n\r\n#endif /* GL_EXT_shared_texture_palette */\r\n\r\n/* ------------------------- GL_EXT_sparse_texture2 ------------------------ */\r\n\r\n#ifndef GL_EXT_sparse_texture2\r\n#define GL_EXT_sparse_texture2 1\r\n\r\n#define GLEW_EXT_sparse_texture2 GLEW_GET_VAR(__GLEW_EXT_sparse_texture2)\r\n\r\n#endif /* GL_EXT_sparse_texture2 */\r\n\r\n/* ------------------------ GL_EXT_stencil_clear_tag ----------------------- */\r\n\r\n#ifndef GL_EXT_stencil_clear_tag\r\n#define GL_EXT_stencil_clear_tag 1\r\n\r\n#define GL_STENCIL_TAG_BITS_EXT 0x88F2\r\n#define GL_STENCIL_CLEAR_TAG_VALUE_EXT 0x88F3\r\n\r\n#define GLEW_EXT_stencil_clear_tag GLEW_GET_VAR(__GLEW_EXT_stencil_clear_tag)\r\n\r\n#endif /* GL_EXT_stencil_clear_tag */\r\n\r\n/* ------------------------ GL_EXT_stencil_two_side ------------------------ */\r\n\r\n#ifndef GL_EXT_stencil_two_side\r\n#define GL_EXT_stencil_two_side 1\r\n\r\n#define GL_STENCIL_TEST_TWO_SIDE_EXT 0x8910\r\n#define GL_ACTIVE_STENCIL_FACE_EXT 0x8911\r\n\r\ntypedef void (GLAPIENTRY * PFNGLACTIVESTENCILFACEEXTPROC) (GLenum face);\r\n\r\n#define glActiveStencilFaceEXT GLEW_GET_FUN(__glewActiveStencilFaceEXT)\r\n\r\n#define GLEW_EXT_stencil_two_side GLEW_GET_VAR(__GLEW_EXT_stencil_two_side)\r\n\r\n#endif /* GL_EXT_stencil_two_side */\r\n\r\n/* -------------------------- GL_EXT_stencil_wrap -------------------------- */\r\n\r\n#ifndef GL_EXT_stencil_wrap\r\n#define GL_EXT_stencil_wrap 1\r\n\r\n#define GL_INCR_WRAP_EXT 0x8507\r\n#define GL_DECR_WRAP_EXT 0x8508\r\n\r\n#define GLEW_EXT_stencil_wrap GLEW_GET_VAR(__GLEW_EXT_stencil_wrap)\r\n\r\n#endif /* GL_EXT_stencil_wrap */\r\n\r\n/* --------------------------- GL_EXT_subtexture --------------------------- */\r\n\r\n#ifndef GL_EXT_subtexture\r\n#define GL_EXT_subtexture 1\r\n\r\ntypedef void (GLAPIENTRY * PFNGLTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels);\r\ntypedef void (GLAPIENTRY * PFNGLTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels);\r\ntypedef void (GLAPIENTRY * PFNGLTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels);\r\n\r\n#define glTexSubImage1DEXT GLEW_GET_FUN(__glewTexSubImage1DEXT)\r\n#define glTexSubImage2DEXT GLEW_GET_FUN(__glewTexSubImage2DEXT)\r\n#define glTexSubImage3DEXT GLEW_GET_FUN(__glewTexSubImage3DEXT)\r\n\r\n#define GLEW_EXT_subtexture GLEW_GET_VAR(__GLEW_EXT_subtexture)\r\n\r\n#endif /* GL_EXT_subtexture */\r\n\r\n/* ----------------------------- GL_EXT_texture ---------------------------- */\r\n\r\n#ifndef GL_EXT_texture\r\n#define GL_EXT_texture 1\r\n\r\n#define GL_ALPHA4_EXT 0x803B\r\n#define GL_ALPHA8_EXT 0x803C\r\n#define GL_ALPHA12_EXT 0x803D\r\n#define GL_ALPHA16_EXT 0x803E\r\n#define GL_LUMINANCE4_EXT 0x803F\r\n#define GL_LUMINANCE8_EXT 0x8040\r\n#define GL_LUMINANCE12_EXT 0x8041\r\n#define GL_LUMINANCE16_EXT 0x8042\r\n#define GL_LUMINANCE4_ALPHA4_EXT 0x8043\r\n#define GL_LUMINANCE6_ALPHA2_EXT 0x8044\r\n#define GL_LUMINANCE8_ALPHA8_EXT 0x8045\r\n#define GL_LUMINANCE12_ALPHA4_EXT 0x8046\r\n#define GL_LUMINANCE12_ALPHA12_EXT 0x8047\r\n#define GL_LUMINANCE16_ALPHA16_EXT 0x8048\r\n#define GL_INTENSITY_EXT 0x8049\r\n#define GL_INTENSITY4_EXT 0x804A\r\n#define GL_INTENSITY8_EXT 0x804B\r\n#define GL_INTENSITY12_EXT 0x804C\r\n#define GL_INTENSITY16_EXT 0x804D\r\n#define GL_RGB2_EXT 0x804E\r\n#define GL_RGB4_EXT 0x804F\r\n#define GL_RGB5_EXT 0x8050\r\n#define GL_RGB8_EXT 0x8051\r\n#define GL_RGB10_EXT 0x8052\r\n#define GL_RGB12_EXT 0x8053\r\n#define GL_RGB16_EXT 0x8054\r\n#define GL_RGBA2_EXT 0x8055\r\n#define GL_RGBA4_EXT 0x8056\r\n#define GL_RGB5_A1_EXT 0x8057\r\n#define GL_RGBA8_EXT 0x8058\r\n#define GL_RGB10_A2_EXT 0x8059\r\n#define GL_RGBA12_EXT 0x805A\r\n#define GL_RGBA16_EXT 0x805B\r\n#define GL_TEXTURE_RED_SIZE_EXT 0x805C\r\n#define GL_TEXTURE_GREEN_SIZE_EXT 0x805D\r\n#define GL_TEXTURE_BLUE_SIZE_EXT 0x805E\r\n#define GL_TEXTURE_ALPHA_SIZE_EXT 0x805F\r\n#define GL_TEXTURE_LUMINANCE_SIZE_EXT 0x8060\r\n#define GL_TEXTURE_INTENSITY_SIZE_EXT 0x8061\r\n#define GL_REPLACE_EXT 0x8062\r\n#define GL_PROXY_TEXTURE_1D_EXT 0x8063\r\n#define GL_PROXY_TEXTURE_2D_EXT 0x8064\r\n\r\n#define GLEW_EXT_texture GLEW_GET_VAR(__GLEW_EXT_texture)\r\n\r\n#endif /* GL_EXT_texture */\r\n\r\n/* ---------------------------- GL_EXT_texture3D --------------------------- */\r\n\r\n#ifndef GL_EXT_texture3D\r\n#define GL_EXT_texture3D 1\r\n\r\n#define GL_PACK_SKIP_IMAGES_EXT 0x806B\r\n#define GL_PACK_IMAGE_HEIGHT_EXT 0x806C\r\n#define GL_UNPACK_SKIP_IMAGES_EXT 0x806D\r\n#define GL_UNPACK_IMAGE_HEIGHT_EXT 0x806E\r\n#define GL_TEXTURE_3D_EXT 0x806F\r\n#define GL_PROXY_TEXTURE_3D_EXT 0x8070\r\n#define GL_TEXTURE_DEPTH_EXT 0x8071\r\n#define GL_TEXTURE_WRAP_R_EXT 0x8072\r\n#define GL_MAX_3D_TEXTURE_SIZE_EXT 0x8073\r\n\r\ntypedef void (GLAPIENTRY * PFNGLTEXIMAGE3DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels);\r\n\r\n#define glTexImage3DEXT GLEW_GET_FUN(__glewTexImage3DEXT)\r\n\r\n#define GLEW_EXT_texture3D GLEW_GET_VAR(__GLEW_EXT_texture3D)\r\n\r\n#endif /* GL_EXT_texture3D */\r\n\r\n/* -------------------------- GL_EXT_texture_array ------------------------- */\r\n\r\n#ifndef GL_EXT_texture_array\r\n#define GL_EXT_texture_array 1\r\n\r\n#define GL_COMPARE_REF_DEPTH_TO_TEXTURE_EXT 0x884E\r\n#define GL_MAX_ARRAY_TEXTURE_LAYERS_EXT 0x88FF\r\n#define GL_TEXTURE_1D_ARRAY_EXT 0x8C18\r\n#define GL_PROXY_TEXTURE_1D_ARRAY_EXT 0x8C19\r\n#define GL_TEXTURE_2D_ARRAY_EXT 0x8C1A\r\n#define GL_PROXY_TEXTURE_2D_ARRAY_EXT 0x8C1B\r\n#define GL_TEXTURE_BINDING_1D_ARRAY_EXT 0x8C1C\r\n#define GL_TEXTURE_BINDING_2D_ARRAY_EXT 0x8C1D\r\n\r\ntypedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURELAYEREXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer);\r\n\r\n#define glFramebufferTextureLayerEXT GLEW_GET_FUN(__glewFramebufferTextureLayerEXT)\r\n\r\n#define GLEW_EXT_texture_array GLEW_GET_VAR(__GLEW_EXT_texture_array)\r\n\r\n#endif /* GL_EXT_texture_array */\r\n\r\n/* ---------------------- GL_EXT_texture_buffer_object --------------------- */\r\n\r\n#ifndef GL_EXT_texture_buffer_object\r\n#define GL_EXT_texture_buffer_object 1\r\n\r\n#define GL_TEXTURE_BUFFER_EXT 0x8C2A\r\n#define GL_MAX_TEXTURE_BUFFER_SIZE_EXT 0x8C2B\r\n#define GL_TEXTURE_BINDING_BUFFER_EXT 0x8C2C\r\n#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_EXT 0x8C2D\r\n#define GL_TEXTURE_BUFFER_FORMAT_EXT 0x8C2E\r\n\r\ntypedef void (GLAPIENTRY * PFNGLTEXBUFFEREXTPROC) (GLenum target, GLenum internalformat, GLuint buffer);\r\n\r\n#define glTexBufferEXT GLEW_GET_FUN(__glewTexBufferEXT)\r\n\r\n#define GLEW_EXT_texture_buffer_object GLEW_GET_VAR(__GLEW_EXT_texture_buffer_object)\r\n\r\n#endif /* GL_EXT_texture_buffer_object */\r\n\r\n/* -------------------- GL_EXT_texture_compression_dxt1 -------------------- */\r\n\r\n#ifndef GL_EXT_texture_compression_dxt1\r\n#define GL_EXT_texture_compression_dxt1 1\r\n\r\n#define GLEW_EXT_texture_compression_dxt1 GLEW_GET_VAR(__GLEW_EXT_texture_compression_dxt1)\r\n\r\n#endif /* GL_EXT_texture_compression_dxt1 */\r\n\r\n/* -------------------- GL_EXT_texture_compression_latc -------------------- */\r\n\r\n#ifndef GL_EXT_texture_compression_latc\r\n#define GL_EXT_texture_compression_latc 1\r\n\r\n#define GL_COMPRESSED_LUMINANCE_LATC1_EXT 0x8C70\r\n#define GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT 0x8C71\r\n#define GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT 0x8C72\r\n#define GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT 0x8C73\r\n\r\n#define GLEW_EXT_texture_compression_latc GLEW_GET_VAR(__GLEW_EXT_texture_compression_latc)\r\n\r\n#endif /* GL_EXT_texture_compression_latc */\r\n\r\n/* -------------------- GL_EXT_texture_compression_rgtc -------------------- */\r\n\r\n#ifndef GL_EXT_texture_compression_rgtc\r\n#define GL_EXT_texture_compression_rgtc 1\r\n\r\n#define GL_COMPRESSED_RED_RGTC1_EXT 0x8DBB\r\n#define GL_COMPRESSED_SIGNED_RED_RGTC1_EXT 0x8DBC\r\n#define GL_COMPRESSED_RED_GREEN_RGTC2_EXT 0x8DBD\r\n#define GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT 0x8DBE\r\n\r\n#define GLEW_EXT_texture_compression_rgtc GLEW_GET_VAR(__GLEW_EXT_texture_compression_rgtc)\r\n\r\n#endif /* GL_EXT_texture_compression_rgtc */\r\n\r\n/* -------------------- GL_EXT_texture_compression_s3tc -------------------- */\r\n\r\n#ifndef GL_EXT_texture_compression_s3tc\r\n#define GL_EXT_texture_compression_s3tc 1\r\n\r\n#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0\r\n#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1\r\n#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2\r\n#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3\r\n\r\n#define GLEW_EXT_texture_compression_s3tc GLEW_GET_VAR(__GLEW_EXT_texture_compression_s3tc)\r\n\r\n#endif /* GL_EXT_texture_compression_s3tc */\r\n\r\n/* ------------------------ GL_EXT_texture_cube_map ------------------------ */\r\n\r\n#ifndef GL_EXT_texture_cube_map\r\n#define GL_EXT_texture_cube_map 1\r\n\r\n#define GL_NORMAL_MAP_EXT 0x8511\r\n#define GL_REFLECTION_MAP_EXT 0x8512\r\n#define GL_TEXTURE_CUBE_MAP_EXT 0x8513\r\n#define GL_TEXTURE_BINDING_CUBE_MAP_EXT 0x8514\r\n#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_EXT 0x8515\r\n#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_EXT 0x8516\r\n#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_EXT 0x8517\r\n#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_EXT 0x8518\r\n#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_EXT 0x8519\r\n#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_EXT 0x851A\r\n#define GL_PROXY_TEXTURE_CUBE_MAP_EXT 0x851B\r\n#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_EXT 0x851C\r\n\r\n#define GLEW_EXT_texture_cube_map GLEW_GET_VAR(__GLEW_EXT_texture_cube_map)\r\n\r\n#endif /* GL_EXT_texture_cube_map */\r\n\r\n/* ----------------------- GL_EXT_texture_edge_clamp ----------------------- */\r\n\r\n#ifndef GL_EXT_texture_edge_clamp\r\n#define GL_EXT_texture_edge_clamp 1\r\n\r\n#define GL_CLAMP_TO_EDGE_EXT 0x812F\r\n\r\n#define GLEW_EXT_texture_edge_clamp GLEW_GET_VAR(__GLEW_EXT_texture_edge_clamp)\r\n\r\n#endif /* GL_EXT_texture_edge_clamp */\r\n\r\n/* --------------------------- GL_EXT_texture_env -------------------------- */\r\n\r\n#ifndef GL_EXT_texture_env\r\n#define GL_EXT_texture_env 1\r\n\r\n#define GLEW_EXT_texture_env GLEW_GET_VAR(__GLEW_EXT_texture_env)\r\n\r\n#endif /* GL_EXT_texture_env */\r\n\r\n/* ------------------------- GL_EXT_texture_env_add ------------------------ */\r\n\r\n#ifndef GL_EXT_texture_env_add\r\n#define GL_EXT_texture_env_add 1\r\n\r\n#define GLEW_EXT_texture_env_add GLEW_GET_VAR(__GLEW_EXT_texture_env_add)\r\n\r\n#endif /* GL_EXT_texture_env_add */\r\n\r\n/* ----------------------- GL_EXT_texture_env_combine ---------------------- */\r\n\r\n#ifndef GL_EXT_texture_env_combine\r\n#define GL_EXT_texture_env_combine 1\r\n\r\n#define GL_COMBINE_EXT 0x8570\r\n#define GL_COMBINE_RGB_EXT 0x8571\r\n#define GL_COMBINE_ALPHA_EXT 0x8572\r\n#define GL_RGB_SCALE_EXT 0x8573\r\n#define GL_ADD_SIGNED_EXT 0x8574\r\n#define GL_INTERPOLATE_EXT 0x8575\r\n#define GL_CONSTANT_EXT 0x8576\r\n#define GL_PRIMARY_COLOR_EXT 0x8577\r\n#define GL_PREVIOUS_EXT 0x8578\r\n#define GL_SOURCE0_RGB_EXT 0x8580\r\n#define GL_SOURCE1_RGB_EXT 0x8581\r\n#define GL_SOURCE2_RGB_EXT 0x8582\r\n#define GL_SOURCE0_ALPHA_EXT 0x8588\r\n#define GL_SOURCE1_ALPHA_EXT 0x8589\r\n#define GL_SOURCE2_ALPHA_EXT 0x858A\r\n#define GL_OPERAND0_RGB_EXT 0x8590\r\n#define GL_OPERAND1_RGB_EXT 0x8591\r\n#define GL_OPERAND2_RGB_EXT 0x8592\r\n#define GL_OPERAND0_ALPHA_EXT 0x8598\r\n#define GL_OPERAND1_ALPHA_EXT 0x8599\r\n#define GL_OPERAND2_ALPHA_EXT 0x859A\r\n\r\n#define GLEW_EXT_texture_env_combine GLEW_GET_VAR(__GLEW_EXT_texture_env_combine)\r\n\r\n#endif /* GL_EXT_texture_env_combine */\r\n\r\n/* ------------------------ GL_EXT_texture_env_dot3 ------------------------ */\r\n\r\n#ifndef GL_EXT_texture_env_dot3\r\n#define GL_EXT_texture_env_dot3 1\r\n\r\n#define GL_DOT3_RGB_EXT 0x8740\r\n#define GL_DOT3_RGBA_EXT 0x8741\r\n\r\n#define GLEW_EXT_texture_env_dot3 GLEW_GET_VAR(__GLEW_EXT_texture_env_dot3)\r\n\r\n#endif /* GL_EXT_texture_env_dot3 */\r\n\r\n/* ------------------- GL_EXT_texture_filter_anisotropic ------------------- */\r\n\r\n#ifndef GL_EXT_texture_filter_anisotropic\r\n#define GL_EXT_texture_filter_anisotropic 1\r\n\r\n#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE\r\n#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF\r\n\r\n#define GLEW_EXT_texture_filter_anisotropic GLEW_GET_VAR(__GLEW_EXT_texture_filter_anisotropic)\r\n\r\n#endif /* GL_EXT_texture_filter_anisotropic */\r\n\r\n/* ---------------------- GL_EXT_texture_filter_minmax --------------------- */\r\n\r\n#ifndef GL_EXT_texture_filter_minmax\r\n#define GL_EXT_texture_filter_minmax 1\r\n\r\n#define GL_TEXTURE_REDUCTION_MODE_EXT 0x9366\r\n#define GL_WEIGHTED_AVERAGE_EXT 0x9367\r\n\r\n#define GLEW_EXT_texture_filter_minmax GLEW_GET_VAR(__GLEW_EXT_texture_filter_minmax)\r\n\r\n#endif /* GL_EXT_texture_filter_minmax */\r\n\r\n/* ------------------------- GL_EXT_texture_integer ------------------------ */\r\n\r\n#ifndef GL_EXT_texture_integer\r\n#define GL_EXT_texture_integer 1\r\n\r\n#define GL_RGBA32UI_EXT 0x8D70\r\n#define GL_RGB32UI_EXT 0x8D71\r\n#define GL_ALPHA32UI_EXT 0x8D72\r\n#define GL_INTENSITY32UI_EXT 0x8D73\r\n#define GL_LUMINANCE32UI_EXT 0x8D74\r\n#define GL_LUMINANCE_ALPHA32UI_EXT 0x8D75\r\n#define GL_RGBA16UI_EXT 0x8D76\r\n#define GL_RGB16UI_EXT 0x8D77\r\n#define GL_ALPHA16UI_EXT 0x8D78\r\n#define GL_INTENSITY16UI_EXT 0x8D79\r\n#define GL_LUMINANCE16UI_EXT 0x8D7A\r\n#define GL_LUMINANCE_ALPHA16UI_EXT 0x8D7B\r\n#define GL_RGBA8UI_EXT 0x8D7C\r\n#define GL_RGB8UI_EXT 0x8D7D\r\n#define GL_ALPHA8UI_EXT 0x8D7E\r\n#define GL_INTENSITY8UI_EXT 0x8D7F\r\n#define GL_LUMINANCE8UI_EXT 0x8D80\r\n#define GL_LUMINANCE_ALPHA8UI_EXT 0x8D81\r\n#define GL_RGBA32I_EXT 0x8D82\r\n#define GL_RGB32I_EXT 0x8D83\r\n#define GL_ALPHA32I_EXT 0x8D84\r\n#define GL_INTENSITY32I_EXT 0x8D85\r\n#define GL_LUMINANCE32I_EXT 0x8D86\r\n#define GL_LUMINANCE_ALPHA32I_EXT 0x8D87\r\n#define GL_RGBA16I_EXT 0x8D88\r\n#define GL_RGB16I_EXT 0x8D89\r\n#define GL_ALPHA16I_EXT 0x8D8A\r\n#define GL_INTENSITY16I_EXT 0x8D8B\r\n#define GL_LUMINANCE16I_EXT 0x8D8C\r\n#define GL_LUMINANCE_ALPHA16I_EXT 0x8D8D\r\n#define GL_RGBA8I_EXT 0x8D8E\r\n#define GL_RGB8I_EXT 0x8D8F\r\n#define GL_ALPHA8I_EXT 0x8D90\r\n#define GL_INTENSITY8I_EXT 0x8D91\r\n#define GL_LUMINANCE8I_EXT 0x8D92\r\n#define GL_LUMINANCE_ALPHA8I_EXT 0x8D93\r\n#define GL_RED_INTEGER_EXT 0x8D94\r\n#define GL_GREEN_INTEGER_EXT 0x8D95\r\n#define GL_BLUE_INTEGER_EXT 0x8D96\r\n#define GL_ALPHA_INTEGER_EXT 0x8D97\r\n#define GL_RGB_INTEGER_EXT 0x8D98\r\n#define GL_RGBA_INTEGER_EXT 0x8D99\r\n#define GL_BGR_INTEGER_EXT 0x8D9A\r\n#define GL_BGRA_INTEGER_EXT 0x8D9B\r\n#define GL_LUMINANCE_INTEGER_EXT 0x8D9C\r\n#define GL_LUMINANCE_ALPHA_INTEGER_EXT 0x8D9D\r\n#define GL_RGBA_INTEGER_MODE_EXT 0x8D9E\r\n\r\ntypedef void (GLAPIENTRY * PFNGLCLEARCOLORIIEXTPROC) (GLint red, GLint green, GLint blue, GLint alpha);\r\ntypedef void (GLAPIENTRY * PFNGLCLEARCOLORIUIEXTPROC) (GLuint red, GLuint green, GLuint blue, GLuint alpha);\r\ntypedef void (GLAPIENTRY * PFNGLGETTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, GLint *params);\r\ntypedef void (GLAPIENTRY * PFNGLGETTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, GLuint *params);\r\ntypedef void (GLAPIENTRY * PFNGLTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, const GLint *params);\r\ntypedef void (GLAPIENTRY * PFNGLTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, const GLuint *params);\r\n\r\n#define glClearColorIiEXT GLEW_GET_FUN(__glewClearColorIiEXT)\r\n#define glClearColorIuiEXT GLEW_GET_FUN(__glewClearColorIuiEXT)\r\n#define glGetTexParameterIivEXT GLEW_GET_FUN(__glewGetTexParameterIivEXT)\r\n#define glGetTexParameterIuivEXT GLEW_GET_FUN(__glewGetTexParameterIuivEXT)\r\n#define glTexParameterIivEXT GLEW_GET_FUN(__glewTexParameterIivEXT)\r\n#define glTexParameterIuivEXT GLEW_GET_FUN(__glewTexParameterIuivEXT)\r\n\r\n#define GLEW_EXT_texture_integer GLEW_GET_VAR(__GLEW_EXT_texture_integer)\r\n\r\n#endif /* GL_EXT_texture_integer */\r\n\r\n/* ------------------------ GL_EXT_texture_lod_bias ------------------------ */\r\n\r\n#ifndef GL_EXT_texture_lod_bias\r\n#define GL_EXT_texture_lod_bias 1\r\n\r\n#define GL_MAX_TEXTURE_LOD_BIAS_EXT 0x84FD\r\n#define GL_TEXTURE_FILTER_CONTROL_EXT 0x8500\r\n#define GL_TEXTURE_LOD_BIAS_EXT 0x8501\r\n\r\n#define GLEW_EXT_texture_lod_bias GLEW_GET_VAR(__GLEW_EXT_texture_lod_bias)\r\n\r\n#endif /* GL_EXT_texture_lod_bias */\r\n\r\n/* ---------------------- GL_EXT_texture_mirror_clamp ---------------------- */\r\n\r\n#ifndef GL_EXT_texture_mirror_clamp\r\n#define GL_EXT_texture_mirror_clamp 1\r\n\r\n#define GL_MIRROR_CLAMP_EXT 0x8742\r\n#define GL_MIRROR_CLAMP_TO_EDGE_EXT 0x8743\r\n#define GL_MIRROR_CLAMP_TO_BORDER_EXT 0x8912\r\n\r\n#define GLEW_EXT_texture_mirror_clamp GLEW_GET_VAR(__GLEW_EXT_texture_mirror_clamp)\r\n\r\n#endif /* GL_EXT_texture_mirror_clamp */\r\n\r\n/* ------------------------- GL_EXT_texture_object ------------------------- */\r\n\r\n#ifndef GL_EXT_texture_object\r\n#define GL_EXT_texture_object 1\r\n\r\n#define GL_TEXTURE_PRIORITY_EXT 0x8066\r\n#define GL_TEXTURE_RESIDENT_EXT 0x8067\r\n#define GL_TEXTURE_1D_BINDING_EXT 0x8068\r\n#define GL_TEXTURE_2D_BINDING_EXT 0x8069\r\n#define GL_TEXTURE_3D_BINDING_EXT 0x806A\r\n\r\ntypedef GLboolean (GLAPIENTRY * PFNGLARETEXTURESRESIDENTEXTPROC) (GLsizei n, const GLuint* textures, GLboolean* residences);\r\ntypedef void (GLAPIENTRY * PFNGLBINDTEXTUREEXTPROC) (GLenum target, GLuint texture);\r\ntypedef void (GLAPIENTRY * PFNGLDELETETEXTURESEXTPROC) (GLsizei n, const GLuint* textures);\r\ntypedef void (GLAPIENTRY * PFNGLGENTEXTURESEXTPROC) (GLsizei n, GLuint* textures);\r\ntypedef GLboolean (GLAPIENTRY * PFNGLISTEXTUREEXTPROC) (GLuint texture);\r\ntypedef void (GLAPIENTRY * PFNGLPRIORITIZETEXTURESEXTPROC) (GLsizei n, const GLuint* textures, const GLclampf* priorities);\r\n\r\n#define glAreTexturesResidentEXT GLEW_GET_FUN(__glewAreTexturesResidentEXT)\r\n#define glBindTextureEXT GLEW_GET_FUN(__glewBindTextureEXT)\r\n#define glDeleteTexturesEXT GLEW_GET_FUN(__glewDeleteTexturesEXT)\r\n#define glGenTexturesEXT GLEW_GET_FUN(__glewGenTexturesEXT)\r\n#define glIsTextureEXT GLEW_GET_FUN(__glewIsTextureEXT)\r\n#define glPrioritizeTexturesEXT GLEW_GET_FUN(__glewPrioritizeTexturesEXT)\r\n\r\n#define GLEW_EXT_texture_object GLEW_GET_VAR(__GLEW_EXT_texture_object)\r\n\r\n#endif /* GL_EXT_texture_object */\r\n\r\n/* --------------------- GL_EXT_texture_perturb_normal --------------------- */\r\n\r\n#ifndef GL_EXT_texture_perturb_normal\r\n#define GL_EXT_texture_perturb_normal 1\r\n\r\n#define GL_PERTURB_EXT 0x85AE\r\n#define GL_TEXTURE_NORMAL_EXT 0x85AF\r\n\r\ntypedef void (GLAPIENTRY * PFNGLTEXTURENORMALEXTPROC) (GLenum mode);\r\n\r\n#define glTextureNormalEXT GLEW_GET_FUN(__glewTextureNormalEXT)\r\n\r\n#define GLEW_EXT_texture_perturb_normal GLEW_GET_VAR(__GLEW_EXT_texture_perturb_normal)\r\n\r\n#endif /* GL_EXT_texture_perturb_normal */\r\n\r\n/* ------------------------ GL_EXT_texture_rectangle ----------------------- */\r\n\r\n#ifndef GL_EXT_texture_rectangle\r\n#define GL_EXT_texture_rectangle 1\r\n\r\n#define GL_TEXTURE_RECTANGLE_EXT 0x84F5\r\n#define GL_TEXTURE_BINDING_RECTANGLE_EXT 0x84F6\r\n#define GL_PROXY_TEXTURE_RECTANGLE_EXT 0x84F7\r\n#define GL_MAX_RECTANGLE_TEXTURE_SIZE_EXT 0x84F8\r\n\r\n#define GLEW_EXT_texture_rectangle GLEW_GET_VAR(__GLEW_EXT_texture_rectangle)\r\n\r\n#endif /* GL_EXT_texture_rectangle */\r\n\r\n/* -------------------------- GL_EXT_texture_sRGB -------------------------- */\r\n\r\n#ifndef GL_EXT_texture_sRGB\r\n#define GL_EXT_texture_sRGB 1\r\n\r\n#define GL_SRGB_EXT 0x8C40\r\n#define GL_SRGB8_EXT 0x8C41\r\n#define GL_SRGB_ALPHA_EXT 0x8C42\r\n#define GL_SRGB8_ALPHA8_EXT 0x8C43\r\n#define GL_SLUMINANCE_ALPHA_EXT 0x8C44\r\n#define GL_SLUMINANCE8_ALPHA8_EXT 0x8C45\r\n#define GL_SLUMINANCE_EXT 0x8C46\r\n#define GL_SLUMINANCE8_EXT 0x8C47\r\n#define GL_COMPRESSED_SRGB_EXT 0x8C48\r\n#define GL_COMPRESSED_SRGB_ALPHA_EXT 0x8C49\r\n#define GL_COMPRESSED_SLUMINANCE_EXT 0x8C4A\r\n#define GL_COMPRESSED_SLUMINANCE_ALPHA_EXT 0x8C4B\r\n#define GL_COMPRESSED_SRGB_S3TC_DXT1_EXT 0x8C4C\r\n#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT 0x8C4D\r\n#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT 0x8C4E\r\n#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT 0x8C4F\r\n\r\n#define GLEW_EXT_texture_sRGB GLEW_GET_VAR(__GLEW_EXT_texture_sRGB)\r\n\r\n#endif /* GL_EXT_texture_sRGB */\r\n\r\n/* ----------------------- GL_EXT_texture_sRGB_decode ---------------------- */\r\n\r\n#ifndef GL_EXT_texture_sRGB_decode\r\n#define GL_EXT_texture_sRGB_decode 1\r\n\r\n#define GL_TEXTURE_SRGB_DECODE_EXT 0x8A48\r\n#define GL_DECODE_EXT 0x8A49\r\n#define GL_SKIP_DECODE_EXT 0x8A4A\r\n\r\n#define GLEW_EXT_texture_sRGB_decode GLEW_GET_VAR(__GLEW_EXT_texture_sRGB_decode)\r\n\r\n#endif /* GL_EXT_texture_sRGB_decode */\r\n\r\n/* --------------------- GL_EXT_texture_shared_exponent -------------------- */\r\n\r\n#ifndef GL_EXT_texture_shared_exponent\r\n#define GL_EXT_texture_shared_exponent 1\r\n\r\n#define GL_RGB9_E5_EXT 0x8C3D\r\n#define GL_UNSIGNED_INT_5_9_9_9_REV_EXT 0x8C3E\r\n#define GL_TEXTURE_SHARED_SIZE_EXT 0x8C3F\r\n\r\n#define GLEW_EXT_texture_shared_exponent GLEW_GET_VAR(__GLEW_EXT_texture_shared_exponent)\r\n\r\n#endif /* GL_EXT_texture_shared_exponent */\r\n\r\n/* -------------------------- GL_EXT_texture_snorm ------------------------- */\r\n\r\n#ifndef GL_EXT_texture_snorm\r\n#define GL_EXT_texture_snorm 1\r\n\r\n#define GL_RED_SNORM 0x8F90\r\n#define GL_RG_SNORM 0x8F91\r\n#define GL_RGB_SNORM 0x8F92\r\n#define GL_RGBA_SNORM 0x8F93\r\n#define GL_R8_SNORM 0x8F94\r\n#define GL_RG8_SNORM 0x8F95\r\n#define GL_RGB8_SNORM 0x8F96\r\n#define GL_RGBA8_SNORM 0x8F97\r\n#define GL_R16_SNORM 0x8F98\r\n#define GL_RG16_SNORM 0x8F99\r\n#define GL_RGB16_SNORM 0x8F9A\r\n#define GL_RGBA16_SNORM 0x8F9B\r\n#define GL_SIGNED_NORMALIZED 0x8F9C\r\n#define GL_ALPHA_SNORM 0x9010\r\n#define GL_LUMINANCE_SNORM 0x9011\r\n#define GL_LUMINANCE_ALPHA_SNORM 0x9012\r\n#define GL_INTENSITY_SNORM 0x9013\r\n#define GL_ALPHA8_SNORM 0x9014\r\n#define GL_LUMINANCE8_SNORM 0x9015\r\n#define GL_LUMINANCE8_ALPHA8_SNORM 0x9016\r\n#define GL_INTENSITY8_SNORM 0x9017\r\n#define GL_ALPHA16_SNORM 0x9018\r\n#define GL_LUMINANCE16_SNORM 0x9019\r\n#define GL_LUMINANCE16_ALPHA16_SNORM 0x901A\r\n#define GL_INTENSITY16_SNORM 0x901B\r\n\r\n#define GLEW_EXT_texture_snorm GLEW_GET_VAR(__GLEW_EXT_texture_snorm)\r\n\r\n#endif /* GL_EXT_texture_snorm */\r\n\r\n/* ------------------------- GL_EXT_texture_swizzle ------------------------ */\r\n\r\n#ifndef GL_EXT_texture_swizzle\r\n#define GL_EXT_texture_swizzle 1\r\n\r\n#define GL_TEXTURE_SWIZZLE_R_EXT 0x8E42\r\n#define GL_TEXTURE_SWIZZLE_G_EXT 0x8E43\r\n#define GL_TEXTURE_SWIZZLE_B_EXT 0x8E44\r\n#define GL_TEXTURE_SWIZZLE_A_EXT 0x8E45\r\n#define GL_TEXTURE_SWIZZLE_RGBA_EXT 0x8E46\r\n\r\n#define GLEW_EXT_texture_swizzle GLEW_GET_VAR(__GLEW_EXT_texture_swizzle)\r\n\r\n#endif /* GL_EXT_texture_swizzle */\r\n\r\n/* --------------------------- GL_EXT_timer_query -------------------------- */\r\n\r\n#ifndef GL_EXT_timer_query\r\n#define GL_EXT_timer_query 1\r\n\r\n#define GL_TIME_ELAPSED_EXT 0x88BF\r\n\r\ntypedef void (GLAPIENTRY * PFNGLGETQUERYOBJECTI64VEXTPROC) (GLuint id, GLenum pname, GLint64EXT *params);\r\ntypedef void (GLAPIENTRY * PFNGLGETQUERYOBJECTUI64VEXTPROC) (GLuint id, GLenum pname, GLuint64EXT *params);\r\n\r\n#define glGetQueryObjecti64vEXT GLEW_GET_FUN(__glewGetQueryObjecti64vEXT)\r\n#define glGetQueryObjectui64vEXT GLEW_GET_FUN(__glewGetQueryObjectui64vEXT)\r\n\r\n#define GLEW_EXT_timer_query GLEW_GET_VAR(__GLEW_EXT_timer_query)\r\n\r\n#endif /* GL_EXT_timer_query */\r\n\r\n/* ----------------------- GL_EXT_transform_feedback ----------------------- */\r\n\r\n#ifndef GL_EXT_transform_feedback\r\n#define GL_EXT_transform_feedback 1\r\n\r\n#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH_EXT 0x8C76\r\n#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE_EXT 0x8C7F\r\n#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_EXT 0x8C80\r\n#define GL_TRANSFORM_FEEDBACK_VARYINGS_EXT 0x8C83\r\n#define GL_TRANSFORM_FEEDBACK_BUFFER_START_EXT 0x8C84\r\n#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_EXT 0x8C85\r\n#define GL_PRIMITIVES_GENERATED_EXT 0x8C87\r\n#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_EXT 0x8C88\r\n#define GL_RASTERIZER_DISCARD_EXT 0x8C89\r\n#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_EXT 0x8C8A\r\n#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_EXT 0x8C8B\r\n#define GL_INTERLEAVED_ATTRIBS_EXT 0x8C8C\r\n#define GL_SEPARATE_ATTRIBS_EXT 0x8C8D\r\n#define GL_TRANSFORM_FEEDBACK_BUFFER_EXT 0x8C8E\r\n#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_EXT 0x8C8F\r\n\r\ntypedef void (GLAPIENTRY * PFNGLBEGINTRANSFORMFEEDBACKEXTPROC) (GLenum primitiveMode);\r\ntypedef void (GLAPIENTRY * PFNGLBINDBUFFERBASEEXTPROC) (GLenum target, GLuint index, GLuint buffer);\r\ntypedef void (GLAPIENTRY * PFNGLBINDBUFFEROFFSETEXTPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset);\r\ntypedef void (GLAPIENTRY * PFNGLBINDBUFFERRANGEEXTPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size);\r\ntypedef void (GLAPIENTRY * PFNGLENDTRANSFORMFEEDBACKEXTPROC) (void);\r\ntypedef void (GLAPIENTRY * PFNGLGETTRANSFORMFEEDBACKVARYINGEXTPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLsizei *size, GLenum *type, GLchar *name);\r\ntypedef void (GLAPIENTRY * PFNGLTRANSFORMFEEDBACKVARYINGSEXTPROC) (GLuint program, GLsizei count, const GLchar * const* varyings, GLenum bufferMode);\r\n\r\n#define glBeginTransformFeedbackEXT GLEW_GET_FUN(__glewBeginTransformFeedbackEXT)\r\n#define glBindBufferBaseEXT GLEW_GET_FUN(__glewBindBufferBaseEXT)\r\n#define glBindBufferOffsetEXT GLEW_GET_FUN(__glewBindBufferOffsetEXT)\r\n#define glBindBufferRangeEXT GLEW_GET_FUN(__glewBindBufferRangeEXT)\r\n#define glEndTransformFeedbackEXT GLEW_GET_FUN(__glewEndTransformFeedbackEXT)\r\n#define glGetTransformFeedbackVaryingEXT GLEW_GET_FUN(__glewGetTransformFeedbackVaryingEXT)\r\n#define glTransformFeedbackVaryingsEXT GLEW_GET_FUN(__glewTransformFeedbackVaryingsEXT)\r\n\r\n#define GLEW_EXT_transform_feedback GLEW_GET_VAR(__GLEW_EXT_transform_feedback)\r\n\r\n#endif /* GL_EXT_transform_feedback */\r\n\r\n/* -------------------------- GL_EXT_vertex_array -------------------------- */\r\n\r\n#ifndef GL_EXT_vertex_array\r\n#define GL_EXT_vertex_array 1\r\n\r\n#define GL_DOUBLE_EXT 0x140A\r\n#define GL_VERTEX_ARRAY_EXT 0x8074\r\n#define GL_NORMAL_ARRAY_EXT 0x8075\r\n#define GL_COLOR_ARRAY_EXT 0x8076\r\n#define GL_INDEX_ARRAY_EXT 0x8077\r\n#define GL_TEXTURE_COORD_ARRAY_EXT 0x8078\r\n#define GL_EDGE_FLAG_ARRAY_EXT 0x8079\r\n#define GL_VERTEX_ARRAY_SIZE_EXT 0x807A\r\n#define GL_VERTEX_ARRAY_TYPE_EXT 0x807B\r\n#define GL_VERTEX_ARRAY_STRIDE_EXT 0x807C\r\n#define GL_VERTEX_ARRAY_COUNT_EXT 0x807D\r\n#define GL_NORMAL_ARRAY_TYPE_EXT 0x807E\r\n#define GL_NORMAL_ARRAY_STRIDE_EXT 0x807F\r\n#define GL_NORMAL_ARRAY_COUNT_EXT 0x8080\r\n#define GL_COLOR_ARRAY_SIZE_EXT 0x8081\r\n#define GL_COLOR_ARRAY_TYPE_EXT 0x8082\r\n#define GL_COLOR_ARRAY_STRIDE_EXT 0x8083\r\n#define GL_COLOR_ARRAY_COUNT_EXT 0x8084\r\n#define GL_INDEX_ARRAY_TYPE_EXT 0x8085\r\n#define GL_INDEX_ARRAY_STRIDE_EXT 0x8086\r\n#define GL_INDEX_ARRAY_COUNT_EXT 0x8087\r\n#define GL_TEXTURE_COORD_ARRAY_SIZE_EXT 0x8088\r\n#define GL_TEXTURE_COORD_ARRAY_TYPE_EXT 0x8089\r\n#define GL_TEXTURE_COORD_ARRAY_STRIDE_EXT 0x808A\r\n#define GL_TEXTURE_COORD_ARRAY_COUNT_EXT 0x808B\r\n#define GL_EDGE_FLAG_ARRAY_STRIDE_EXT 0x808C\r\n#define GL_EDGE_FLAG_ARRAY_COUNT_EXT 0x808D\r\n#define GL_VERTEX_ARRAY_POINTER_EXT 0x808E\r\n#define GL_NORMAL_ARRAY_POINTER_EXT 0x808F\r\n#define GL_COLOR_ARRAY_POINTER_EXT 0x8090\r\n#define GL_INDEX_ARRAY_POINTER_EXT 0x8091\r\n#define GL_TEXTURE_COORD_ARRAY_POINTER_EXT 0x8092\r\n#define GL_EDGE_FLAG_ARRAY_POINTER_EXT 0x8093\r\n\r\ntypedef void (GLAPIENTRY * PFNGLARRAYELEMENTEXTPROC) (GLint i);\r\ntypedef void (GLAPIENTRY * PFNGLCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const void *pointer);\r\ntypedef void (GLAPIENTRY * PFNGLDRAWARRAYSEXTPROC) (GLenum mode, GLint first, GLsizei count);\r\ntypedef void (GLAPIENTRY * PFNGLEDGEFLAGPOINTEREXTPROC) (GLsizei stride, GLsizei count, const GLboolean* pointer);\r\ntypedef void (GLAPIENTRY * PFNGLINDEXPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const void *pointer);\r\ntypedef void (GLAPIENTRY * PFNGLNORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const void *pointer);\r\ntypedef void (GLAPIENTRY * PFNGLTEXCOORDPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const void *pointer);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const void *pointer);\r\n\r\n#define glArrayElementEXT GLEW_GET_FUN(__glewArrayElementEXT)\r\n#define glColorPointerEXT GLEW_GET_FUN(__glewColorPointerEXT)\r\n#define glDrawArraysEXT GLEW_GET_FUN(__glewDrawArraysEXT)\r\n#define glEdgeFlagPointerEXT GLEW_GET_FUN(__glewEdgeFlagPointerEXT)\r\n#define glIndexPointerEXT GLEW_GET_FUN(__glewIndexPointerEXT)\r\n#define glNormalPointerEXT GLEW_GET_FUN(__glewNormalPointerEXT)\r\n#define glTexCoordPointerEXT GLEW_GET_FUN(__glewTexCoordPointerEXT)\r\n#define glVertexPointerEXT GLEW_GET_FUN(__glewVertexPointerEXT)\r\n\r\n#define GLEW_EXT_vertex_array GLEW_GET_VAR(__GLEW_EXT_vertex_array)\r\n\r\n#endif /* GL_EXT_vertex_array */\r\n\r\n/* ------------------------ GL_EXT_vertex_array_bgra ----------------------- */\r\n\r\n#ifndef GL_EXT_vertex_array_bgra\r\n#define GL_EXT_vertex_array_bgra 1\r\n\r\n#define GL_BGRA 0x80E1\r\n\r\n#define GLEW_EXT_vertex_array_bgra GLEW_GET_VAR(__GLEW_EXT_vertex_array_bgra)\r\n\r\n#endif /* GL_EXT_vertex_array_bgra */\r\n\r\n/* ----------------------- GL_EXT_vertex_attrib_64bit ---------------------- */\r\n\r\n#ifndef GL_EXT_vertex_attrib_64bit\r\n#define GL_EXT_vertex_attrib_64bit 1\r\n\r\n#define GL_DOUBLE_MAT2_EXT 0x8F46\r\n#define GL_DOUBLE_MAT3_EXT 0x8F47\r\n#define GL_DOUBLE_MAT4_EXT 0x8F48\r\n#define GL_DOUBLE_MAT2x3_EXT 0x8F49\r\n#define GL_DOUBLE_MAT2x4_EXT 0x8F4A\r\n#define GL_DOUBLE_MAT3x2_EXT 0x8F4B\r\n#define GL_DOUBLE_MAT3x4_EXT 0x8F4C\r\n#define GL_DOUBLE_MAT4x2_EXT 0x8F4D\r\n#define GL_DOUBLE_MAT4x3_EXT 0x8F4E\r\n#define GL_DOUBLE_VEC2_EXT 0x8FFC\r\n#define GL_DOUBLE_VEC3_EXT 0x8FFD\r\n#define GL_DOUBLE_VEC4_EXT 0x8FFE\r\n\r\ntypedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBLDVEXTPROC) (GLuint index, GLenum pname, GLdouble* params);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXARRAYVERTEXATTRIBLOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL1DEXTPROC) (GLuint index, GLdouble x);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL1DVEXTPROC) (GLuint index, const GLdouble* v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL2DEXTPROC) (GLuint index, GLdouble x, GLdouble y);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL2DVEXTPROC) (GLuint index, const GLdouble* v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL3DEXTPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL3DVEXTPROC) (GLuint index, const GLdouble* v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL4DEXTPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL4DVEXTPROC) (GLuint index, const GLdouble* v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBLPOINTEREXTPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer);\r\n\r\n#define glGetVertexAttribLdvEXT GLEW_GET_FUN(__glewGetVertexAttribLdvEXT)\r\n#define glVertexArrayVertexAttribLOffsetEXT GLEW_GET_FUN(__glewVertexArrayVertexAttribLOffsetEXT)\r\n#define glVertexAttribL1dEXT GLEW_GET_FUN(__glewVertexAttribL1dEXT)\r\n#define glVertexAttribL1dvEXT GLEW_GET_FUN(__glewVertexAttribL1dvEXT)\r\n#define glVertexAttribL2dEXT GLEW_GET_FUN(__glewVertexAttribL2dEXT)\r\n#define glVertexAttribL2dvEXT GLEW_GET_FUN(__glewVertexAttribL2dvEXT)\r\n#define glVertexAttribL3dEXT GLEW_GET_FUN(__glewVertexAttribL3dEXT)\r\n#define glVertexAttribL3dvEXT GLEW_GET_FUN(__glewVertexAttribL3dvEXT)\r\n#define glVertexAttribL4dEXT GLEW_GET_FUN(__glewVertexAttribL4dEXT)\r\n#define glVertexAttribL4dvEXT GLEW_GET_FUN(__glewVertexAttribL4dvEXT)\r\n#define glVertexAttribLPointerEXT GLEW_GET_FUN(__glewVertexAttribLPointerEXT)\r\n\r\n#define GLEW_EXT_vertex_attrib_64bit GLEW_GET_VAR(__GLEW_EXT_vertex_attrib_64bit)\r\n\r\n#endif /* GL_EXT_vertex_attrib_64bit */\r\n\r\n/* -------------------------- GL_EXT_vertex_shader ------------------------- */\r\n\r\n#ifndef GL_EXT_vertex_shader\r\n#define GL_EXT_vertex_shader 1\r\n\r\n#define GL_VERTEX_SHADER_EXT 0x8780\r\n#define GL_VERTEX_SHADER_BINDING_EXT 0x8781\r\n#define GL_OP_INDEX_EXT 0x8782\r\n#define GL_OP_NEGATE_EXT 0x8783\r\n#define GL_OP_DOT3_EXT 0x8784\r\n#define GL_OP_DOT4_EXT 0x8785\r\n#define GL_OP_MUL_EXT 0x8786\r\n#define GL_OP_ADD_EXT 0x8787\r\n#define GL_OP_MADD_EXT 0x8788\r\n#define GL_OP_FRAC_EXT 0x8789\r\n#define GL_OP_MAX_EXT 0x878A\r\n#define GL_OP_MIN_EXT 0x878B\r\n#define GL_OP_SET_GE_EXT 0x878C\r\n#define GL_OP_SET_LT_EXT 0x878D\r\n#define GL_OP_CLAMP_EXT 0x878E\r\n#define GL_OP_FLOOR_EXT 0x878F\r\n#define GL_OP_ROUND_EXT 0x8790\r\n#define GL_OP_EXP_BASE_2_EXT 0x8791\r\n#define GL_OP_LOG_BASE_2_EXT 0x8792\r\n#define GL_OP_POWER_EXT 0x8793\r\n#define GL_OP_RECIP_EXT 0x8794\r\n#define GL_OP_RECIP_SQRT_EXT 0x8795\r\n#define GL_OP_SUB_EXT 0x8796\r\n#define GL_OP_CROSS_PRODUCT_EXT 0x8797\r\n#define GL_OP_MULTIPLY_MATRIX_EXT 0x8798\r\n#define GL_OP_MOV_EXT 0x8799\r\n#define GL_OUTPUT_VERTEX_EXT 0x879A\r\n#define GL_OUTPUT_COLOR0_EXT 0x879B\r\n#define GL_OUTPUT_COLOR1_EXT 0x879C\r\n#define GL_OUTPUT_TEXTURE_COORD0_EXT 0x879D\r\n#define GL_OUTPUT_TEXTURE_COORD1_EXT 0x879E\r\n#define GL_OUTPUT_TEXTURE_COORD2_EXT 0x879F\r\n#define GL_OUTPUT_TEXTURE_COORD3_EXT 0x87A0\r\n#define GL_OUTPUT_TEXTURE_COORD4_EXT 0x87A1\r\n#define GL_OUTPUT_TEXTURE_COORD5_EXT 0x87A2\r\n#define GL_OUTPUT_TEXTURE_COORD6_EXT 0x87A3\r\n#define GL_OUTPUT_TEXTURE_COORD7_EXT 0x87A4\r\n#define GL_OUTPUT_TEXTURE_COORD8_EXT 0x87A5\r\n#define GL_OUTPUT_TEXTURE_COORD9_EXT 0x87A6\r\n#define GL_OUTPUT_TEXTURE_COORD10_EXT 0x87A7\r\n#define GL_OUTPUT_TEXTURE_COORD11_EXT 0x87A8\r\n#define GL_OUTPUT_TEXTURE_COORD12_EXT 0x87A9\r\n#define GL_OUTPUT_TEXTURE_COORD13_EXT 0x87AA\r\n#define GL_OUTPUT_TEXTURE_COORD14_EXT 0x87AB\r\n#define GL_OUTPUT_TEXTURE_COORD15_EXT 0x87AC\r\n#define GL_OUTPUT_TEXTURE_COORD16_EXT 0x87AD\r\n#define GL_OUTPUT_TEXTURE_COORD17_EXT 0x87AE\r\n#define GL_OUTPUT_TEXTURE_COORD18_EXT 0x87AF\r\n#define GL_OUTPUT_TEXTURE_COORD19_EXT 0x87B0\r\n#define GL_OUTPUT_TEXTURE_COORD20_EXT 0x87B1\r\n#define GL_OUTPUT_TEXTURE_COORD21_EXT 0x87B2\r\n#define GL_OUTPUT_TEXTURE_COORD22_EXT 0x87B3\r\n#define GL_OUTPUT_TEXTURE_COORD23_EXT 0x87B4\r\n#define GL_OUTPUT_TEXTURE_COORD24_EXT 0x87B5\r\n#define GL_OUTPUT_TEXTURE_COORD25_EXT 0x87B6\r\n#define GL_OUTPUT_TEXTURE_COORD26_EXT 0x87B7\r\n#define GL_OUTPUT_TEXTURE_COORD27_EXT 0x87B8\r\n#define GL_OUTPUT_TEXTURE_COORD28_EXT 0x87B9\r\n#define GL_OUTPUT_TEXTURE_COORD29_EXT 0x87BA\r\n#define GL_OUTPUT_TEXTURE_COORD30_EXT 0x87BB\r\n#define GL_OUTPUT_TEXTURE_COORD31_EXT 0x87BC\r\n#define GL_OUTPUT_FOG_EXT 0x87BD\r\n#define GL_SCALAR_EXT 0x87BE\r\n#define GL_VECTOR_EXT 0x87BF\r\n#define GL_MATRIX_EXT 0x87C0\r\n#define GL_VARIANT_EXT 0x87C1\r\n#define GL_INVARIANT_EXT 0x87C2\r\n#define GL_LOCAL_CONSTANT_EXT 0x87C3\r\n#define GL_LOCAL_EXT 0x87C4\r\n#define GL_MAX_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87C5\r\n#define GL_MAX_VERTEX_SHADER_VARIANTS_EXT 0x87C6\r\n#define GL_MAX_VERTEX_SHADER_INVARIANTS_EXT 0x87C7\r\n#define GL_MAX_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87C8\r\n#define GL_MAX_VERTEX_SHADER_LOCALS_EXT 0x87C9\r\n#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CA\r\n#define GL_MAX_OPTIMIZED_VERTEX_SHADER_VARIANTS_EXT 0x87CB\r\n#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INVARIANTS_EXT 0x87CC\r\n#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87CD\r\n#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCALS_EXT 0x87CE\r\n#define GL_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CF\r\n#define GL_VERTEX_SHADER_VARIANTS_EXT 0x87D0\r\n#define GL_VERTEX_SHADER_INVARIANTS_EXT 0x87D1\r\n#define GL_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87D2\r\n#define GL_VERTEX_SHADER_LOCALS_EXT 0x87D3\r\n#define GL_VERTEX_SHADER_OPTIMIZED_EXT 0x87D4\r\n#define GL_X_EXT 0x87D5\r\n#define GL_Y_EXT 0x87D6\r\n#define GL_Z_EXT 0x87D7\r\n#define GL_W_EXT 0x87D8\r\n#define GL_NEGATIVE_X_EXT 0x87D9\r\n#define GL_NEGATIVE_Y_EXT 0x87DA\r\n#define GL_NEGATIVE_Z_EXT 0x87DB\r\n#define GL_NEGATIVE_W_EXT 0x87DC\r\n#define GL_ZERO_EXT 0x87DD\r\n#define GL_ONE_EXT 0x87DE\r\n#define GL_NEGATIVE_ONE_EXT 0x87DF\r\n#define GL_NORMALIZED_RANGE_EXT 0x87E0\r\n#define GL_FULL_RANGE_EXT 0x87E1\r\n#define GL_CURRENT_VERTEX_EXT 0x87E2\r\n#define GL_MVP_MATRIX_EXT 0x87E3\r\n#define GL_VARIANT_VALUE_EXT 0x87E4\r\n#define GL_VARIANT_DATATYPE_EXT 0x87E5\r\n#define GL_VARIANT_ARRAY_STRIDE_EXT 0x87E6\r\n#define GL_VARIANT_ARRAY_TYPE_EXT 0x87E7\r\n#define GL_VARIANT_ARRAY_EXT 0x87E8\r\n#define GL_VARIANT_ARRAY_POINTER_EXT 0x87E9\r\n#define GL_INVARIANT_VALUE_EXT 0x87EA\r\n#define GL_INVARIANT_DATATYPE_EXT 0x87EB\r\n#define GL_LOCAL_CONSTANT_VALUE_EXT 0x87EC\r\n#define GL_LOCAL_CONSTANT_DATATYPE_EXT 0x87ED\r\n\r\ntypedef void (GLAPIENTRY * PFNGLBEGINVERTEXSHADEREXTPROC) (void);\r\ntypedef GLuint (GLAPIENTRY * PFNGLBINDLIGHTPARAMETEREXTPROC) (GLenum light, GLenum value);\r\ntypedef GLuint (GLAPIENTRY * PFNGLBINDMATERIALPARAMETEREXTPROC) (GLenum face, GLenum value);\r\ntypedef GLuint (GLAPIENTRY * PFNGLBINDPARAMETEREXTPROC) (GLenum value);\r\ntypedef GLuint (GLAPIENTRY * PFNGLBINDTEXGENPARAMETEREXTPROC) (GLenum unit, GLenum coord, GLenum value);\r\ntypedef GLuint (GLAPIENTRY * PFNGLBINDTEXTUREUNITPARAMETEREXTPROC) (GLenum unit, GLenum value);\r\ntypedef void (GLAPIENTRY * PFNGLBINDVERTEXSHADEREXTPROC) (GLuint id);\r\ntypedef void (GLAPIENTRY * PFNGLDELETEVERTEXSHADEREXTPROC) (GLuint id);\r\ntypedef void (GLAPIENTRY * PFNGLDISABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id);\r\ntypedef void (GLAPIENTRY * PFNGLENABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id);\r\ntypedef void (GLAPIENTRY * PFNGLENDVERTEXSHADEREXTPROC) (void);\r\ntypedef void (GLAPIENTRY * PFNGLEXTRACTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num);\r\ntypedef GLuint (GLAPIENTRY * PFNGLGENSYMBOLSEXTPROC) (GLenum dataType, GLenum storageType, GLenum range, GLuint components);\r\ntypedef GLuint (GLAPIENTRY * PFNGLGENVERTEXSHADERSEXTPROC) (GLuint range);\r\ntypedef void (GLAPIENTRY * PFNGLGETINVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data);\r\ntypedef void (GLAPIENTRY * PFNGLGETINVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data);\r\ntypedef void (GLAPIENTRY * PFNGLGETINVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data);\r\ntypedef void (GLAPIENTRY * PFNGLGETLOCALCONSTANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data);\r\ntypedef void (GLAPIENTRY * PFNGLGETLOCALCONSTANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data);\r\ntypedef void (GLAPIENTRY * PFNGLGETLOCALCONSTANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data);\r\ntypedef void (GLAPIENTRY * PFNGLGETVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data);\r\ntypedef void (GLAPIENTRY * PFNGLGETVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data);\r\ntypedef void (GLAPIENTRY * PFNGLGETVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data);\r\ntypedef void (GLAPIENTRY * PFNGLGETVARIANTPOINTERVEXTPROC) (GLuint id, GLenum value, void **data);\r\ntypedef void (GLAPIENTRY * PFNGLINSERTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num);\r\ntypedef GLboolean (GLAPIENTRY * PFNGLISVARIANTENABLEDEXTPROC) (GLuint id, GLenum cap);\r\ntypedef void (GLAPIENTRY * PFNGLSETINVARIANTEXTPROC) (GLuint id, GLenum type, void *addr);\r\ntypedef void (GLAPIENTRY * PFNGLSETLOCALCONSTANTEXTPROC) (GLuint id, GLenum type, void *addr);\r\ntypedef void (GLAPIENTRY * PFNGLSHADEROP1EXTPROC) (GLenum op, GLuint res, GLuint arg1);\r\ntypedef void (GLAPIENTRY * PFNGLSHADEROP2EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2);\r\ntypedef void (GLAPIENTRY * PFNGLSHADEROP3EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2, GLuint arg3);\r\ntypedef void (GLAPIENTRY * PFNGLSWIZZLEEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW);\r\ntypedef void (GLAPIENTRY * PFNGLVARIANTPOINTEREXTPROC) (GLuint id, GLenum type, GLuint stride, void *addr);\r\ntypedef void (GLAPIENTRY * PFNGLVARIANTBVEXTPROC) (GLuint id, GLbyte *addr);\r\ntypedef void (GLAPIENTRY * PFNGLVARIANTDVEXTPROC) (GLuint id, GLdouble *addr);\r\ntypedef void (GLAPIENTRY * PFNGLVARIANTFVEXTPROC) (GLuint id, GLfloat *addr);\r\ntypedef void (GLAPIENTRY * PFNGLVARIANTIVEXTPROC) (GLuint id, GLint *addr);\r\ntypedef void (GLAPIENTRY * PFNGLVARIANTSVEXTPROC) (GLuint id, GLshort *addr);\r\ntypedef void (GLAPIENTRY * PFNGLVARIANTUBVEXTPROC) (GLuint id, GLubyte *addr);\r\ntypedef void (GLAPIENTRY * PFNGLVARIANTUIVEXTPROC) (GLuint id, GLuint *addr);\r\ntypedef void (GLAPIENTRY * PFNGLVARIANTUSVEXTPROC) (GLuint id, GLushort *addr);\r\ntypedef void (GLAPIENTRY * PFNGLWRITEMASKEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW);\r\n\r\n#define glBeginVertexShaderEXT GLEW_GET_FUN(__glewBeginVertexShaderEXT)\r\n#define glBindLightParameterEXT GLEW_GET_FUN(__glewBindLightParameterEXT)\r\n#define glBindMaterialParameterEXT GLEW_GET_FUN(__glewBindMaterialParameterEXT)\r\n#define glBindParameterEXT GLEW_GET_FUN(__glewBindParameterEXT)\r\n#define glBindTexGenParameterEXT GLEW_GET_FUN(__glewBindTexGenParameterEXT)\r\n#define glBindTextureUnitParameterEXT GLEW_GET_FUN(__glewBindTextureUnitParameterEXT)\r\n#define glBindVertexShaderEXT GLEW_GET_FUN(__glewBindVertexShaderEXT)\r\n#define glDeleteVertexShaderEXT GLEW_GET_FUN(__glewDeleteVertexShaderEXT)\r\n#define glDisableVariantClientStateEXT GLEW_GET_FUN(__glewDisableVariantClientStateEXT)\r\n#define glEnableVariantClientStateEXT GLEW_GET_FUN(__glewEnableVariantClientStateEXT)\r\n#define glEndVertexShaderEXT GLEW_GET_FUN(__glewEndVertexShaderEXT)\r\n#define glExtractComponentEXT GLEW_GET_FUN(__glewExtractComponentEXT)\r\n#define glGenSymbolsEXT GLEW_GET_FUN(__glewGenSymbolsEXT)\r\n#define glGenVertexShadersEXT GLEW_GET_FUN(__glewGenVertexShadersEXT)\r\n#define glGetInvariantBooleanvEXT GLEW_GET_FUN(__glewGetInvariantBooleanvEXT)\r\n#define glGetInvariantFloatvEXT GLEW_GET_FUN(__glewGetInvariantFloatvEXT)\r\n#define glGetInvariantIntegervEXT GLEW_GET_FUN(__glewGetInvariantIntegervEXT)\r\n#define glGetLocalConstantBooleanvEXT GLEW_GET_FUN(__glewGetLocalConstantBooleanvEXT)\r\n#define glGetLocalConstantFloatvEXT GLEW_GET_FUN(__glewGetLocalConstantFloatvEXT)\r\n#define glGetLocalConstantIntegervEXT GLEW_GET_FUN(__glewGetLocalConstantIntegervEXT)\r\n#define glGetVariantBooleanvEXT GLEW_GET_FUN(__glewGetVariantBooleanvEXT)\r\n#define glGetVariantFloatvEXT GLEW_GET_FUN(__glewGetVariantFloatvEXT)\r\n#define glGetVariantIntegervEXT GLEW_GET_FUN(__glewGetVariantIntegervEXT)\r\n#define glGetVariantPointervEXT GLEW_GET_FUN(__glewGetVariantPointervEXT)\r\n#define glInsertComponentEXT GLEW_GET_FUN(__glewInsertComponentEXT)\r\n#define glIsVariantEnabledEXT GLEW_GET_FUN(__glewIsVariantEnabledEXT)\r\n#define glSetInvariantEXT GLEW_GET_FUN(__glewSetInvariantEXT)\r\n#define glSetLocalConstantEXT GLEW_GET_FUN(__glewSetLocalConstantEXT)\r\n#define glShaderOp1EXT GLEW_GET_FUN(__glewShaderOp1EXT)\r\n#define glShaderOp2EXT GLEW_GET_FUN(__glewShaderOp2EXT)\r\n#define glShaderOp3EXT GLEW_GET_FUN(__glewShaderOp3EXT)\r\n#define glSwizzleEXT GLEW_GET_FUN(__glewSwizzleEXT)\r\n#define glVariantPointerEXT GLEW_GET_FUN(__glewVariantPointerEXT)\r\n#define glVariantbvEXT GLEW_GET_FUN(__glewVariantbvEXT)\r\n#define glVariantdvEXT GLEW_GET_FUN(__glewVariantdvEXT)\r\n#define glVariantfvEXT GLEW_GET_FUN(__glewVariantfvEXT)\r\n#define glVariantivEXT GLEW_GET_FUN(__glewVariantivEXT)\r\n#define glVariantsvEXT GLEW_GET_FUN(__glewVariantsvEXT)\r\n#define glVariantubvEXT GLEW_GET_FUN(__glewVariantubvEXT)\r\n#define glVariantuivEXT GLEW_GET_FUN(__glewVariantuivEXT)\r\n#define glVariantusvEXT GLEW_GET_FUN(__glewVariantusvEXT)\r\n#define glWriteMaskEXT GLEW_GET_FUN(__glewWriteMaskEXT)\r\n\r\n#define GLEW_EXT_vertex_shader GLEW_GET_VAR(__GLEW_EXT_vertex_shader)\r\n\r\n#endif /* GL_EXT_vertex_shader */\r\n\r\n/* ------------------------ GL_EXT_vertex_weighting ------------------------ */\r\n\r\n#ifndef GL_EXT_vertex_weighting\r\n#define GL_EXT_vertex_weighting 1\r\n\r\n#define GL_MODELVIEW0_STACK_DEPTH_EXT 0x0BA3\r\n#define GL_MODELVIEW0_MATRIX_EXT 0x0BA6\r\n#define GL_MODELVIEW0_EXT 0x1700\r\n#define GL_MODELVIEW1_STACK_DEPTH_EXT 0x8502\r\n#define GL_MODELVIEW1_MATRIX_EXT 0x8506\r\n#define GL_VERTEX_WEIGHTING_EXT 0x8509\r\n#define GL_MODELVIEW1_EXT 0x850A\r\n#define GL_CURRENT_VERTEX_WEIGHT_EXT 0x850B\r\n#define GL_VERTEX_WEIGHT_ARRAY_EXT 0x850C\r\n#define GL_VERTEX_WEIGHT_ARRAY_SIZE_EXT 0x850D\r\n#define GL_VERTEX_WEIGHT_ARRAY_TYPE_EXT 0x850E\r\n#define GL_VERTEX_WEIGHT_ARRAY_STRIDE_EXT 0x850F\r\n#define GL_VERTEX_WEIGHT_ARRAY_POINTER_EXT 0x8510\r\n\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXWEIGHTPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, void *pointer);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXWEIGHTFEXTPROC) (GLfloat weight);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXWEIGHTFVEXTPROC) (GLfloat* weight);\r\n\r\n#define glVertexWeightPointerEXT GLEW_GET_FUN(__glewVertexWeightPointerEXT)\r\n#define glVertexWeightfEXT GLEW_GET_FUN(__glewVertexWeightfEXT)\r\n#define glVertexWeightfvEXT GLEW_GET_FUN(__glewVertexWeightfvEXT)\r\n\r\n#define GLEW_EXT_vertex_weighting GLEW_GET_VAR(__GLEW_EXT_vertex_weighting)\r\n\r\n#endif /* GL_EXT_vertex_weighting */\r\n\r\n/* ------------------------- GL_EXT_x11_sync_object ------------------------ */\r\n\r\n#ifndef GL_EXT_x11_sync_object\r\n#define GL_EXT_x11_sync_object 1\r\n\r\n#define GL_SYNC_X11_FENCE_EXT 0x90E1\r\n\r\ntypedef GLsync (GLAPIENTRY * PFNGLIMPORTSYNCEXTPROC) (GLenum external_sync_type, GLintptr external_sync, GLbitfield flags);\r\n\r\n#define glImportSyncEXT GLEW_GET_FUN(__glewImportSyncEXT)\r\n\r\n#define GLEW_EXT_x11_sync_object GLEW_GET_VAR(__GLEW_EXT_x11_sync_object)\r\n\r\n#endif /* GL_EXT_x11_sync_object */\r\n\r\n/* ---------------------- GL_GREMEDY_frame_terminator ---------------------- */\r\n\r\n#ifndef GL_GREMEDY_frame_terminator\r\n#define GL_GREMEDY_frame_terminator 1\r\n\r\ntypedef void (GLAPIENTRY * PFNGLFRAMETERMINATORGREMEDYPROC) (void);\r\n\r\n#define glFrameTerminatorGREMEDY GLEW_GET_FUN(__glewFrameTerminatorGREMEDY)\r\n\r\n#define GLEW_GREMEDY_frame_terminator GLEW_GET_VAR(__GLEW_GREMEDY_frame_terminator)\r\n\r\n#endif /* GL_GREMEDY_frame_terminator */\r\n\r\n/* ------------------------ GL_GREMEDY_string_marker ----------------------- */\r\n\r\n#ifndef GL_GREMEDY_string_marker\r\n#define GL_GREMEDY_string_marker 1\r\n\r\ntypedef void (GLAPIENTRY * PFNGLSTRINGMARKERGREMEDYPROC) (GLsizei len, const void *string);\r\n\r\n#define glStringMarkerGREMEDY GLEW_GET_FUN(__glewStringMarkerGREMEDY)\r\n\r\n#define GLEW_GREMEDY_string_marker GLEW_GET_VAR(__GLEW_GREMEDY_string_marker)\r\n\r\n#endif /* GL_GREMEDY_string_marker */\r\n\r\n/* --------------------- GL_HP_convolution_border_modes -------------------- */\r\n\r\n#ifndef GL_HP_convolution_border_modes\r\n#define GL_HP_convolution_border_modes 1\r\n\r\n#define GLEW_HP_convolution_border_modes GLEW_GET_VAR(__GLEW_HP_convolution_border_modes)\r\n\r\n#endif /* GL_HP_convolution_border_modes */\r\n\r\n/* ------------------------- GL_HP_image_transform ------------------------- */\r\n\r\n#ifndef GL_HP_image_transform\r\n#define GL_HP_image_transform 1\r\n\r\ntypedef void (GLAPIENTRY * PFNGLGETIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, const GLfloat* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, const GLint* params);\r\ntypedef void (GLAPIENTRY * PFNGLIMAGETRANSFORMPARAMETERFHPPROC) (GLenum target, GLenum pname, const GLfloat param);\r\ntypedef void (GLAPIENTRY * PFNGLIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, const GLfloat* params);\r\ntypedef void (GLAPIENTRY * PFNGLIMAGETRANSFORMPARAMETERIHPPROC) (GLenum target, GLenum pname, const GLint param);\r\ntypedef void (GLAPIENTRY * PFNGLIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, const GLint* params);\r\n\r\n#define glGetImageTransformParameterfvHP GLEW_GET_FUN(__glewGetImageTransformParameterfvHP)\r\n#define glGetImageTransformParameterivHP GLEW_GET_FUN(__glewGetImageTransformParameterivHP)\r\n#define glImageTransformParameterfHP GLEW_GET_FUN(__glewImageTransformParameterfHP)\r\n#define glImageTransformParameterfvHP GLEW_GET_FUN(__glewImageTransformParameterfvHP)\r\n#define glImageTransformParameteriHP GLEW_GET_FUN(__glewImageTransformParameteriHP)\r\n#define glImageTransformParameterivHP GLEW_GET_FUN(__glewImageTransformParameterivHP)\r\n\r\n#define GLEW_HP_image_transform GLEW_GET_VAR(__GLEW_HP_image_transform)\r\n\r\n#endif /* GL_HP_image_transform */\r\n\r\n/* -------------------------- GL_HP_occlusion_test ------------------------- */\r\n\r\n#ifndef GL_HP_occlusion_test\r\n#define GL_HP_occlusion_test 1\r\n\r\n#define GLEW_HP_occlusion_test GLEW_GET_VAR(__GLEW_HP_occlusion_test)\r\n\r\n#endif /* GL_HP_occlusion_test */\r\n\r\n/* ------------------------- GL_HP_texture_lighting ------------------------ */\r\n\r\n#ifndef GL_HP_texture_lighting\r\n#define GL_HP_texture_lighting 1\r\n\r\n#define GLEW_HP_texture_lighting GLEW_GET_VAR(__GLEW_HP_texture_lighting)\r\n\r\n#endif /* GL_HP_texture_lighting */\r\n\r\n/* --------------------------- GL_IBM_cull_vertex -------------------------- */\r\n\r\n#ifndef GL_IBM_cull_vertex\r\n#define GL_IBM_cull_vertex 1\r\n\r\n#define GL_CULL_VERTEX_IBM 103050\r\n\r\n#define GLEW_IBM_cull_vertex GLEW_GET_VAR(__GLEW_IBM_cull_vertex)\r\n\r\n#endif /* GL_IBM_cull_vertex */\r\n\r\n/* ---------------------- GL_IBM_multimode_draw_arrays --------------------- */\r\n\r\n#ifndef GL_IBM_multimode_draw_arrays\r\n#define GL_IBM_multimode_draw_arrays 1\r\n\r\ntypedef void (GLAPIENTRY * PFNGLMULTIMODEDRAWARRAYSIBMPROC) (const GLenum* mode, const GLint *first, const GLsizei *count, GLsizei primcount, GLint modestride);\r\ntypedef void (GLAPIENTRY * PFNGLMULTIMODEDRAWELEMENTSIBMPROC) (const GLenum* mode, const GLsizei *count, GLenum type, const void *const *indices, GLsizei primcount, GLint modestride);\r\n\r\n#define glMultiModeDrawArraysIBM GLEW_GET_FUN(__glewMultiModeDrawArraysIBM)\r\n#define glMultiModeDrawElementsIBM GLEW_GET_FUN(__glewMultiModeDrawElementsIBM)\r\n\r\n#define GLEW_IBM_multimode_draw_arrays GLEW_GET_VAR(__GLEW_IBM_multimode_draw_arrays)\r\n\r\n#endif /* GL_IBM_multimode_draw_arrays */\r\n\r\n/* ------------------------- GL_IBM_rasterpos_clip ------------------------- */\r\n\r\n#ifndef GL_IBM_rasterpos_clip\r\n#define GL_IBM_rasterpos_clip 1\r\n\r\n#define GL_RASTER_POSITION_UNCLIPPED_IBM 103010\r\n\r\n#define GLEW_IBM_rasterpos_clip GLEW_GET_VAR(__GLEW_IBM_rasterpos_clip)\r\n\r\n#endif /* GL_IBM_rasterpos_clip */\r\n\r\n/* --------------------------- GL_IBM_static_data -------------------------- */\r\n\r\n#ifndef GL_IBM_static_data\r\n#define GL_IBM_static_data 1\r\n\r\n#define GL_ALL_STATIC_DATA_IBM 103060\r\n#define GL_STATIC_VERTEX_ARRAY_IBM 103061\r\n\r\n#define GLEW_IBM_static_data GLEW_GET_VAR(__GLEW_IBM_static_data)\r\n\r\n#endif /* GL_IBM_static_data */\r\n\r\n/* --------------------- GL_IBM_texture_mirrored_repeat -------------------- */\r\n\r\n#ifndef GL_IBM_texture_mirrored_repeat\r\n#define GL_IBM_texture_mirrored_repeat 1\r\n\r\n#define GL_MIRRORED_REPEAT_IBM 0x8370\r\n\r\n#define GLEW_IBM_texture_mirrored_repeat GLEW_GET_VAR(__GLEW_IBM_texture_mirrored_repeat)\r\n\r\n#endif /* GL_IBM_texture_mirrored_repeat */\r\n\r\n/* ----------------------- GL_IBM_vertex_array_lists ----------------------- */\r\n\r\n#ifndef GL_IBM_vertex_array_lists\r\n#define GL_IBM_vertex_array_lists 1\r\n\r\n#define GL_VERTEX_ARRAY_LIST_IBM 103070\r\n#define GL_NORMAL_ARRAY_LIST_IBM 103071\r\n#define GL_COLOR_ARRAY_LIST_IBM 103072\r\n#define GL_INDEX_ARRAY_LIST_IBM 103073\r\n#define GL_TEXTURE_COORD_ARRAY_LIST_IBM 103074\r\n#define GL_EDGE_FLAG_ARRAY_LIST_IBM 103075\r\n#define GL_FOG_COORDINATE_ARRAY_LIST_IBM 103076\r\n#define GL_SECONDARY_COLOR_ARRAY_LIST_IBM 103077\r\n#define GL_VERTEX_ARRAY_LIST_STRIDE_IBM 103080\r\n#define GL_NORMAL_ARRAY_LIST_STRIDE_IBM 103081\r\n#define GL_COLOR_ARRAY_LIST_STRIDE_IBM 103082\r\n#define GL_INDEX_ARRAY_LIST_STRIDE_IBM 103083\r\n#define GL_TEXTURE_COORD_ARRAY_LIST_STRIDE_IBM 103084\r\n#define GL_EDGE_FLAG_ARRAY_LIST_STRIDE_IBM 103085\r\n#define GL_FOG_COORDINATE_ARRAY_LIST_STRIDE_IBM 103086\r\n#define GL_SECONDARY_COLOR_ARRAY_LIST_STRIDE_IBM 103087\r\n\r\ntypedef void (GLAPIENTRY * PFNGLCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const void** pointer, GLint ptrstride);\r\ntypedef void (GLAPIENTRY * PFNGLEDGEFLAGPOINTERLISTIBMPROC) (GLint stride, const GLboolean ** pointer, GLint ptrstride);\r\ntypedef void (GLAPIENTRY * PFNGLFOGCOORDPOINTERLISTIBMPROC) (GLenum type, GLint stride, const void** pointer, GLint ptrstride);\r\ntypedef void (GLAPIENTRY * PFNGLINDEXPOINTERLISTIBMPROC) (GLenum type, GLint stride, const void** pointer, GLint ptrstride);\r\ntypedef void (GLAPIENTRY * PFNGLNORMALPOINTERLISTIBMPROC) (GLenum type, GLint stride, const void** pointer, GLint ptrstride);\r\ntypedef void (GLAPIENTRY * PFNGLSECONDARYCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const void** pointer, GLint ptrstride);\r\ntypedef void (GLAPIENTRY * PFNGLTEXCOORDPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const void** pointer, GLint ptrstride);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const void** pointer, GLint ptrstride);\r\n\r\n#define glColorPointerListIBM GLEW_GET_FUN(__glewColorPointerListIBM)\r\n#define glEdgeFlagPointerListIBM GLEW_GET_FUN(__glewEdgeFlagPointerListIBM)\r\n#define glFogCoordPointerListIBM GLEW_GET_FUN(__glewFogCoordPointerListIBM)\r\n#define glIndexPointerListIBM GLEW_GET_FUN(__glewIndexPointerListIBM)\r\n#define glNormalPointerListIBM GLEW_GET_FUN(__glewNormalPointerListIBM)\r\n#define glSecondaryColorPointerListIBM GLEW_GET_FUN(__glewSecondaryColorPointerListIBM)\r\n#define glTexCoordPointerListIBM GLEW_GET_FUN(__glewTexCoordPointerListIBM)\r\n#define glVertexPointerListIBM GLEW_GET_FUN(__glewVertexPointerListIBM)\r\n\r\n#define GLEW_IBM_vertex_array_lists GLEW_GET_VAR(__GLEW_IBM_vertex_array_lists)\r\n\r\n#endif /* GL_IBM_vertex_array_lists */\r\n\r\n/* -------------------------- GL_INGR_color_clamp -------------------------- */\r\n\r\n#ifndef GL_INGR_color_clamp\r\n#define GL_INGR_color_clamp 1\r\n\r\n#define GL_RED_MIN_CLAMP_INGR 0x8560\r\n#define GL_GREEN_MIN_CLAMP_INGR 0x8561\r\n#define GL_BLUE_MIN_CLAMP_INGR 0x8562\r\n#define GL_ALPHA_MIN_CLAMP_INGR 0x8563\r\n#define GL_RED_MAX_CLAMP_INGR 0x8564\r\n#define GL_GREEN_MAX_CLAMP_INGR 0x8565\r\n#define GL_BLUE_MAX_CLAMP_INGR 0x8566\r\n#define GL_ALPHA_MAX_CLAMP_INGR 0x8567\r\n\r\n#define GLEW_INGR_color_clamp GLEW_GET_VAR(__GLEW_INGR_color_clamp)\r\n\r\n#endif /* GL_INGR_color_clamp */\r\n\r\n/* ------------------------- GL_INGR_interlace_read ------------------------ */\r\n\r\n#ifndef GL_INGR_interlace_read\r\n#define GL_INGR_interlace_read 1\r\n\r\n#define GL_INTERLACE_READ_INGR 0x8568\r\n\r\n#define GLEW_INGR_interlace_read GLEW_GET_VAR(__GLEW_INGR_interlace_read)\r\n\r\n#endif /* GL_INGR_interlace_read */\r\n\r\n/* ------------------- GL_INTEL_fragment_shader_ordering ------------------- */\r\n\r\n#ifndef GL_INTEL_fragment_shader_ordering\r\n#define GL_INTEL_fragment_shader_ordering 1\r\n\r\n#define GLEW_INTEL_fragment_shader_ordering GLEW_GET_VAR(__GLEW_INTEL_fragment_shader_ordering)\r\n\r\n#endif /* GL_INTEL_fragment_shader_ordering */\r\n\r\n/* ----------------------- GL_INTEL_framebuffer_CMAA ----------------------- */\r\n\r\n#ifndef GL_INTEL_framebuffer_CMAA\r\n#define GL_INTEL_framebuffer_CMAA 1\r\n\r\n#define GLEW_INTEL_framebuffer_CMAA GLEW_GET_VAR(__GLEW_INTEL_framebuffer_CMAA)\r\n\r\n#endif /* GL_INTEL_framebuffer_CMAA */\r\n\r\n/* -------------------------- GL_INTEL_map_texture ------------------------- */\r\n\r\n#ifndef GL_INTEL_map_texture\r\n#define GL_INTEL_map_texture 1\r\n\r\n#define GL_LAYOUT_DEFAULT_INTEL 0\r\n#define GL_LAYOUT_LINEAR_INTEL 1\r\n#define GL_LAYOUT_LINEAR_CPU_CACHED_INTEL 2\r\n#define GL_TEXTURE_MEMORY_LAYOUT_INTEL 0x83FF\r\n\r\ntypedef void * (GLAPIENTRY * PFNGLMAPTEXTURE2DINTELPROC) (GLuint texture, GLint level, GLbitfield access, GLint* stride, GLenum *layout);\r\ntypedef void (GLAPIENTRY * PFNGLSYNCTEXTUREINTELPROC) (GLuint texture);\r\ntypedef void (GLAPIENTRY * PFNGLUNMAPTEXTURE2DINTELPROC) (GLuint texture, GLint level);\r\n\r\n#define glMapTexture2DINTEL GLEW_GET_FUN(__glewMapTexture2DINTEL)\r\n#define glSyncTextureINTEL GLEW_GET_FUN(__glewSyncTextureINTEL)\r\n#define glUnmapTexture2DINTEL GLEW_GET_FUN(__glewUnmapTexture2DINTEL)\r\n\r\n#define GLEW_INTEL_map_texture GLEW_GET_VAR(__GLEW_INTEL_map_texture)\r\n\r\n#endif /* GL_INTEL_map_texture */\r\n\r\n/* ------------------------ GL_INTEL_parallel_arrays ----------------------- */\r\n\r\n#ifndef GL_INTEL_parallel_arrays\r\n#define GL_INTEL_parallel_arrays 1\r\n\r\n#define GL_PARALLEL_ARRAYS_INTEL 0x83F4\r\n#define GL_VERTEX_ARRAY_PARALLEL_POINTERS_INTEL 0x83F5\r\n#define GL_NORMAL_ARRAY_PARALLEL_POINTERS_INTEL 0x83F6\r\n#define GL_COLOR_ARRAY_PARALLEL_POINTERS_INTEL 0x83F7\r\n#define GL_TEXTURE_COORD_ARRAY_PARALLEL_POINTERS_INTEL 0x83F8\r\n\r\ntypedef void (GLAPIENTRY * PFNGLCOLORPOINTERVINTELPROC) (GLint size, GLenum type, const void** pointer);\r\ntypedef void (GLAPIENTRY * PFNGLNORMALPOINTERVINTELPROC) (GLenum type, const void** pointer);\r\ntypedef void (GLAPIENTRY * PFNGLTEXCOORDPOINTERVINTELPROC) (GLint size, GLenum type, const void** pointer);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXPOINTERVINTELPROC) (GLint size, GLenum type, const void** pointer);\r\n\r\n#define glColorPointervINTEL GLEW_GET_FUN(__glewColorPointervINTEL)\r\n#define glNormalPointervINTEL GLEW_GET_FUN(__glewNormalPointervINTEL)\r\n#define glTexCoordPointervINTEL GLEW_GET_FUN(__glewTexCoordPointervINTEL)\r\n#define glVertexPointervINTEL GLEW_GET_FUN(__glewVertexPointervINTEL)\r\n\r\n#define GLEW_INTEL_parallel_arrays GLEW_GET_VAR(__GLEW_INTEL_parallel_arrays)\r\n\r\n#endif /* GL_INTEL_parallel_arrays */\r\n\r\n/* ----------------------- GL_INTEL_performance_query ---------------------- */\r\n\r\n#ifndef GL_INTEL_performance_query\r\n#define GL_INTEL_performance_query 1\r\n\r\n#define GL_PERFQUERY_SINGLE_CONTEXT_INTEL 0x0000\r\n#define GL_PERFQUERY_GLOBAL_CONTEXT_INTEL 0x0001\r\n#define GL_PERFQUERY_DONOT_FLUSH_INTEL 0x83F9\r\n#define GL_PERFQUERY_FLUSH_INTEL 0x83FA\r\n#define GL_PERFQUERY_WAIT_INTEL 0x83FB\r\n#define GL_PERFQUERY_COUNTER_EVENT_INTEL 0x94F0\r\n#define GL_PERFQUERY_COUNTER_DURATION_NORM_INTEL 0x94F1\r\n#define GL_PERFQUERY_COUNTER_DURATION_RAW_INTEL 0x94F2\r\n#define GL_PERFQUERY_COUNTER_THROUGHPUT_INTEL 0x94F3\r\n#define GL_PERFQUERY_COUNTER_RAW_INTEL 0x94F4\r\n#define GL_PERFQUERY_COUNTER_TIMESTAMP_INTEL 0x94F5\r\n#define GL_PERFQUERY_COUNTER_DATA_UINT32_INTEL 0x94F8\r\n#define GL_PERFQUERY_COUNTER_DATA_UINT64_INTEL 0x94F9\r\n#define GL_PERFQUERY_COUNTER_DATA_FLOAT_INTEL 0x94FA\r\n#define GL_PERFQUERY_COUNTER_DATA_DOUBLE_INTEL 0x94FB\r\n#define GL_PERFQUERY_COUNTER_DATA_BOOL32_INTEL 0x94FC\r\n#define GL_PERFQUERY_QUERY_NAME_LENGTH_MAX_INTEL 0x94FD\r\n#define GL_PERFQUERY_COUNTER_NAME_LENGTH_MAX_INTEL 0x94FE\r\n#define GL_PERFQUERY_COUNTER_DESC_LENGTH_MAX_INTEL 0x94FF\r\n#define GL_PERFQUERY_GPA_EXTENDED_COUNTERS_INTEL 0x9500\r\n\r\ntypedef void (GLAPIENTRY * PFNGLBEGINPERFQUERYINTELPROC) (GLuint queryHandle);\r\ntypedef void (GLAPIENTRY * PFNGLCREATEPERFQUERYINTELPROC) (GLuint queryId, GLuint* queryHandle);\r\ntypedef void (GLAPIENTRY * PFNGLDELETEPERFQUERYINTELPROC) (GLuint queryHandle);\r\ntypedef void (GLAPIENTRY * PFNGLENDPERFQUERYINTELPROC) (GLuint queryHandle);\r\ntypedef void (GLAPIENTRY * PFNGLGETFIRSTPERFQUERYIDINTELPROC) (GLuint* queryId);\r\ntypedef void (GLAPIENTRY * PFNGLGETNEXTPERFQUERYIDINTELPROC) (GLuint queryId, GLuint* nextQueryId);\r\ntypedef void (GLAPIENTRY * PFNGLGETPERFCOUNTERINFOINTELPROC) (GLuint queryId, GLuint counterId, GLuint counterNameLength, GLchar* counterName, GLuint counterDescLength, GLchar *counterDesc, GLuint *counterOffset, GLuint *counterDataSize, GLuint *counterTypeEnum, GLuint *counterDataTypeEnum, GLuint64 *rawCounterMaxValue);\r\ntypedef void (GLAPIENTRY * PFNGLGETPERFQUERYDATAINTELPROC) (GLuint queryHandle, GLuint flags, GLsizei dataSize, void *data, GLuint *bytesWritten);\r\ntypedef void (GLAPIENTRY * PFNGLGETPERFQUERYIDBYNAMEINTELPROC) (GLchar* queryName, GLuint *queryId);\r\ntypedef void (GLAPIENTRY * PFNGLGETPERFQUERYINFOINTELPROC) (GLuint queryId, GLuint queryNameLength, GLchar* queryName, GLuint *dataSize, GLuint *noCounters, GLuint *noInstances, GLuint *capsMask);\r\n\r\n#define glBeginPerfQueryINTEL GLEW_GET_FUN(__glewBeginPerfQueryINTEL)\r\n#define glCreatePerfQueryINTEL GLEW_GET_FUN(__glewCreatePerfQueryINTEL)\r\n#define glDeletePerfQueryINTEL GLEW_GET_FUN(__glewDeletePerfQueryINTEL)\r\n#define glEndPerfQueryINTEL GLEW_GET_FUN(__glewEndPerfQueryINTEL)\r\n#define glGetFirstPerfQueryIdINTEL GLEW_GET_FUN(__glewGetFirstPerfQueryIdINTEL)\r\n#define glGetNextPerfQueryIdINTEL GLEW_GET_FUN(__glewGetNextPerfQueryIdINTEL)\r\n#define glGetPerfCounterInfoINTEL GLEW_GET_FUN(__glewGetPerfCounterInfoINTEL)\r\n#define glGetPerfQueryDataINTEL GLEW_GET_FUN(__glewGetPerfQueryDataINTEL)\r\n#define glGetPerfQueryIdByNameINTEL GLEW_GET_FUN(__glewGetPerfQueryIdByNameINTEL)\r\n#define glGetPerfQueryInfoINTEL GLEW_GET_FUN(__glewGetPerfQueryInfoINTEL)\r\n\r\n#define GLEW_INTEL_performance_query GLEW_GET_VAR(__GLEW_INTEL_performance_query)\r\n\r\n#endif /* GL_INTEL_performance_query */\r\n\r\n/* ------------------------ GL_INTEL_texture_scissor ----------------------- */\r\n\r\n#ifndef GL_INTEL_texture_scissor\r\n#define GL_INTEL_texture_scissor 1\r\n\r\ntypedef void (GLAPIENTRY * PFNGLTEXSCISSORFUNCINTELPROC) (GLenum target, GLenum lfunc, GLenum hfunc);\r\ntypedef void (GLAPIENTRY * PFNGLTEXSCISSORINTELPROC) (GLenum target, GLclampf tlow, GLclampf thigh);\r\n\r\n#define glTexScissorFuncINTEL GLEW_GET_FUN(__glewTexScissorFuncINTEL)\r\n#define glTexScissorINTEL GLEW_GET_FUN(__glewTexScissorINTEL)\r\n\r\n#define GLEW_INTEL_texture_scissor GLEW_GET_VAR(__GLEW_INTEL_texture_scissor)\r\n\r\n#endif /* GL_INTEL_texture_scissor */\r\n\r\n/* --------------------- GL_KHR_blend_equation_advanced -------------------- */\r\n\r\n#ifndef GL_KHR_blend_equation_advanced\r\n#define GL_KHR_blend_equation_advanced 1\r\n\r\n#define GL_BLEND_ADVANCED_COHERENT_KHR 0x9285\r\n#define GL_MULTIPLY_KHR 0x9294\r\n#define GL_SCREEN_KHR 0x9295\r\n#define GL_OVERLAY_KHR 0x9296\r\n#define GL_DARKEN_KHR 0x9297\r\n#define GL_LIGHTEN_KHR 0x9298\r\n#define GL_COLORDODGE_KHR 0x9299\r\n#define GL_COLORBURN_KHR 0x929A\r\n#define GL_HARDLIGHT_KHR 0x929B\r\n#define GL_SOFTLIGHT_KHR 0x929C\r\n#define GL_DIFFERENCE_KHR 0x929E\r\n#define GL_EXCLUSION_KHR 0x92A0\r\n#define GL_HSL_HUE_KHR 0x92AD\r\n#define GL_HSL_SATURATION_KHR 0x92AE\r\n#define GL_HSL_COLOR_KHR 0x92AF\r\n#define GL_HSL_LUMINOSITY_KHR 0x92B0\r\n\r\ntypedef void (GLAPIENTRY * PFNGLBLENDBARRIERKHRPROC) (void);\r\n\r\n#define glBlendBarrierKHR GLEW_GET_FUN(__glewBlendBarrierKHR)\r\n\r\n#define GLEW_KHR_blend_equation_advanced GLEW_GET_VAR(__GLEW_KHR_blend_equation_advanced)\r\n\r\n#endif /* GL_KHR_blend_equation_advanced */\r\n\r\n/* ---------------- GL_KHR_blend_equation_advanced_coherent ---------------- */\r\n\r\n#ifndef GL_KHR_blend_equation_advanced_coherent\r\n#define GL_KHR_blend_equation_advanced_coherent 1\r\n\r\n#define GLEW_KHR_blend_equation_advanced_coherent GLEW_GET_VAR(__GLEW_KHR_blend_equation_advanced_coherent)\r\n\r\n#endif /* GL_KHR_blend_equation_advanced_coherent */\r\n\r\n/* ---------------------- GL_KHR_context_flush_control --------------------- */\r\n\r\n#ifndef GL_KHR_context_flush_control\r\n#define GL_KHR_context_flush_control 1\r\n\r\n#define GL_CONTEXT_RELEASE_BEHAVIOR 0x82FB\r\n#define GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH 0x82FC\r\n\r\n#define GLEW_KHR_context_flush_control GLEW_GET_VAR(__GLEW_KHR_context_flush_control)\r\n\r\n#endif /* GL_KHR_context_flush_control */\r\n\r\n/* ------------------------------ GL_KHR_debug ----------------------------- */\r\n\r\n#ifndef GL_KHR_debug\r\n#define GL_KHR_debug 1\r\n\r\n#define GL_CONTEXT_FLAG_DEBUG_BIT 0x00000002\r\n#define GL_STACK_OVERFLOW 0x0503\r\n#define GL_STACK_UNDERFLOW 0x0504\r\n#define GL_DEBUG_OUTPUT_SYNCHRONOUS 0x8242\r\n#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH 0x8243\r\n#define GL_DEBUG_CALLBACK_FUNCTION 0x8244\r\n#define GL_DEBUG_CALLBACK_USER_PARAM 0x8245\r\n#define GL_DEBUG_SOURCE_API 0x8246\r\n#define GL_DEBUG_SOURCE_WINDOW_SYSTEM 0x8247\r\n#define GL_DEBUG_SOURCE_SHADER_COMPILER 0x8248\r\n#define GL_DEBUG_SOURCE_THIRD_PARTY 0x8249\r\n#define GL_DEBUG_SOURCE_APPLICATION 0x824A\r\n#define GL_DEBUG_SOURCE_OTHER 0x824B\r\n#define GL_DEBUG_TYPE_ERROR 0x824C\r\n#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR 0x824D\r\n#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR 0x824E\r\n#define GL_DEBUG_TYPE_PORTABILITY 0x824F\r\n#define GL_DEBUG_TYPE_PERFORMANCE 0x8250\r\n#define GL_DEBUG_TYPE_OTHER 0x8251\r\n#define GL_DEBUG_TYPE_MARKER 0x8268\r\n#define GL_DEBUG_TYPE_PUSH_GROUP 0x8269\r\n#define GL_DEBUG_TYPE_POP_GROUP 0x826A\r\n#define GL_DEBUG_SEVERITY_NOTIFICATION 0x826B\r\n#define GL_MAX_DEBUG_GROUP_STACK_DEPTH 0x826C\r\n#define GL_DEBUG_GROUP_STACK_DEPTH 0x826D\r\n#define GL_BUFFER 0x82E0\r\n#define GL_SHADER 0x82E1\r\n#define GL_PROGRAM 0x82E2\r\n#define GL_QUERY 0x82E3\r\n#define GL_PROGRAM_PIPELINE 0x82E4\r\n#define GL_SAMPLER 0x82E6\r\n#define GL_DISPLAY_LIST 0x82E7\r\n#define GL_MAX_LABEL_LENGTH 0x82E8\r\n#define GL_MAX_DEBUG_MESSAGE_LENGTH 0x9143\r\n#define GL_MAX_DEBUG_LOGGED_MESSAGES 0x9144\r\n#define GL_DEBUG_LOGGED_MESSAGES 0x9145\r\n#define GL_DEBUG_SEVERITY_HIGH 0x9146\r\n#define GL_DEBUG_SEVERITY_MEDIUM 0x9147\r\n#define GL_DEBUG_SEVERITY_LOW 0x9148\r\n#define GL_DEBUG_OUTPUT 0x92E0\r\n\r\ntypedef void (GLAPIENTRY *GLDEBUGPROC)(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* message, const void* userParam);\r\n\r\ntypedef void (GLAPIENTRY * PFNGLDEBUGMESSAGECALLBACKPROC) (GLDEBUGPROC callback, const void *userParam);\r\ntypedef void (GLAPIENTRY * PFNGLDEBUGMESSAGECONTROLPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint* ids, GLboolean enabled);\r\ntypedef void (GLAPIENTRY * PFNGLDEBUGMESSAGEINSERTPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* buf);\r\ntypedef GLuint (GLAPIENTRY * PFNGLGETDEBUGMESSAGELOGPROC) (GLuint count, GLsizei bufSize, GLenum* sources, GLenum* types, GLuint* ids, GLenum* severities, GLsizei* lengths, GLchar* messageLog);\r\ntypedef void (GLAPIENTRY * PFNGLGETOBJECTLABELPROC) (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei* length, GLchar *label);\r\ntypedef void (GLAPIENTRY * PFNGLGETOBJECTPTRLABELPROC) (const void *ptr, GLsizei bufSize, GLsizei* length, GLchar *label);\r\ntypedef void (GLAPIENTRY * PFNGLOBJECTLABELPROC) (GLenum identifier, GLuint name, GLsizei length, const GLchar* label);\r\ntypedef void (GLAPIENTRY * PFNGLOBJECTPTRLABELPROC) (const void *ptr, GLsizei length, const GLchar* label);\r\ntypedef void (GLAPIENTRY * PFNGLPOPDEBUGGROUPPROC) (void);\r\ntypedef void (GLAPIENTRY * PFNGLPUSHDEBUGGROUPPROC) (GLenum source, GLuint id, GLsizei length, const GLchar * message);\r\n\r\n#define glDebugMessageCallback GLEW_GET_FUN(__glewDebugMessageCallback)\r\n#define glDebugMessageControl GLEW_GET_FUN(__glewDebugMessageControl)\r\n#define glDebugMessageInsert GLEW_GET_FUN(__glewDebugMessageInsert)\r\n#define glGetDebugMessageLog GLEW_GET_FUN(__glewGetDebugMessageLog)\r\n#define glGetObjectLabel GLEW_GET_FUN(__glewGetObjectLabel)\r\n#define glGetObjectPtrLabel GLEW_GET_FUN(__glewGetObjectPtrLabel)\r\n#define glObjectLabel GLEW_GET_FUN(__glewObjectLabel)\r\n#define glObjectPtrLabel GLEW_GET_FUN(__glewObjectPtrLabel)\r\n#define glPopDebugGroup GLEW_GET_FUN(__glewPopDebugGroup)\r\n#define glPushDebugGroup GLEW_GET_FUN(__glewPushDebugGroup)\r\n\r\n#define GLEW_KHR_debug GLEW_GET_VAR(__GLEW_KHR_debug)\r\n\r\n#endif /* GL_KHR_debug */\r\n\r\n/* ---------------------------- GL_KHR_no_error ---------------------------- */\r\n\r\n#ifndef GL_KHR_no_error\r\n#define GL_KHR_no_error 1\r\n\r\n#define GL_CONTEXT_FLAG_NO_ERROR_BIT_KHR 0x00000008\r\n\r\n#define GLEW_KHR_no_error GLEW_GET_VAR(__GLEW_KHR_no_error)\r\n\r\n#endif /* GL_KHR_no_error */\r\n\r\n/* ------------------ GL_KHR_robust_buffer_access_behavior ----------------- */\r\n\r\n#ifndef GL_KHR_robust_buffer_access_behavior\r\n#define GL_KHR_robust_buffer_access_behavior 1\r\n\r\n#define GLEW_KHR_robust_buffer_access_behavior GLEW_GET_VAR(__GLEW_KHR_robust_buffer_access_behavior)\r\n\r\n#endif /* GL_KHR_robust_buffer_access_behavior */\r\n\r\n/* --------------------------- GL_KHR_robustness --------------------------- */\r\n\r\n#ifndef GL_KHR_robustness\r\n#define GL_KHR_robustness 1\r\n\r\n#define GL_CONTEXT_LOST 0x0507\r\n#define GL_LOSE_CONTEXT_ON_RESET 0x8252\r\n#define GL_GUILTY_CONTEXT_RESET 0x8253\r\n#define GL_INNOCENT_CONTEXT_RESET 0x8254\r\n#define GL_UNKNOWN_CONTEXT_RESET 0x8255\r\n#define GL_RESET_NOTIFICATION_STRATEGY 0x8256\r\n#define GL_NO_RESET_NOTIFICATION 0x8261\r\n#define GL_CONTEXT_ROBUST_ACCESS 0x90F3\r\n\r\ntypedef void (GLAPIENTRY * PFNGLGETNUNIFORMFVPROC) (GLuint program, GLint location, GLsizei bufSize, GLfloat* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETNUNIFORMIVPROC) (GLuint program, GLint location, GLsizei bufSize, GLint* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETNUNIFORMUIVPROC) (GLuint program, GLint location, GLsizei bufSize, GLuint* params);\r\ntypedef void (GLAPIENTRY * PFNGLREADNPIXELSPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data);\r\n\r\n#define glGetnUniformfv GLEW_GET_FUN(__glewGetnUniformfv)\r\n#define glGetnUniformiv GLEW_GET_FUN(__glewGetnUniformiv)\r\n#define glGetnUniformuiv GLEW_GET_FUN(__glewGetnUniformuiv)\r\n#define glReadnPixels GLEW_GET_FUN(__glewReadnPixels)\r\n\r\n#define GLEW_KHR_robustness GLEW_GET_VAR(__GLEW_KHR_robustness)\r\n\r\n#endif /* GL_KHR_robustness */\r\n\r\n/* ------------------ GL_KHR_texture_compression_astc_hdr ------------------ */\r\n\r\n#ifndef GL_KHR_texture_compression_astc_hdr\r\n#define GL_KHR_texture_compression_astc_hdr 1\r\n\r\n#define GL_COMPRESSED_RGBA_ASTC_4x4_KHR 0x93B0\r\n#define GL_COMPRESSED_RGBA_ASTC_5x4_KHR 0x93B1\r\n#define GL_COMPRESSED_RGBA_ASTC_5x5_KHR 0x93B2\r\n#define GL_COMPRESSED_RGBA_ASTC_6x5_KHR 0x93B3\r\n#define GL_COMPRESSED_RGBA_ASTC_6x6_KHR 0x93B4\r\n#define GL_COMPRESSED_RGBA_ASTC_8x5_KHR 0x93B5\r\n#define GL_COMPRESSED_RGBA_ASTC_8x6_KHR 0x93B6\r\n#define GL_COMPRESSED_RGBA_ASTC_8x8_KHR 0x93B7\r\n#define GL_COMPRESSED_RGBA_ASTC_10x5_KHR 0x93B8\r\n#define GL_COMPRESSED_RGBA_ASTC_10x6_KHR 0x93B9\r\n#define GL_COMPRESSED_RGBA_ASTC_10x8_KHR 0x93BA\r\n#define GL_COMPRESSED_RGBA_ASTC_10x10_KHR 0x93BB\r\n#define GL_COMPRESSED_RGBA_ASTC_12x10_KHR 0x93BC\r\n#define GL_COMPRESSED_RGBA_ASTC_12x12_KHR 0x93BD\r\n#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR 0x93D0\r\n#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR 0x93D1\r\n#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR 0x93D2\r\n#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR 0x93D3\r\n#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR 0x93D4\r\n#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR 0x93D5\r\n#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR 0x93D6\r\n#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR 0x93D7\r\n#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR 0x93D8\r\n#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR 0x93D9\r\n#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR 0x93DA\r\n#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR 0x93DB\r\n#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR 0x93DC\r\n#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR 0x93DD\r\n\r\n#define GLEW_KHR_texture_compression_astc_hdr GLEW_GET_VAR(__GLEW_KHR_texture_compression_astc_hdr)\r\n\r\n#endif /* GL_KHR_texture_compression_astc_hdr */\r\n\r\n/* ------------------ GL_KHR_texture_compression_astc_ldr ------------------ */\r\n\r\n#ifndef GL_KHR_texture_compression_astc_ldr\r\n#define GL_KHR_texture_compression_astc_ldr 1\r\n\r\n#define GL_COMPRESSED_RGBA_ASTC_4x4_KHR 0x93B0\r\n#define GL_COMPRESSED_RGBA_ASTC_5x4_KHR 0x93B1\r\n#define GL_COMPRESSED_RGBA_ASTC_5x5_KHR 0x93B2\r\n#define GL_COMPRESSED_RGBA_ASTC_6x5_KHR 0x93B3\r\n#define GL_COMPRESSED_RGBA_ASTC_6x6_KHR 0x93B4\r\n#define GL_COMPRESSED_RGBA_ASTC_8x5_KHR 0x93B5\r\n#define GL_COMPRESSED_RGBA_ASTC_8x6_KHR 0x93B6\r\n#define GL_COMPRESSED_RGBA_ASTC_8x8_KHR 0x93B7\r\n#define GL_COMPRESSED_RGBA_ASTC_10x5_KHR 0x93B8\r\n#define GL_COMPRESSED_RGBA_ASTC_10x6_KHR 0x93B9\r\n#define GL_COMPRESSED_RGBA_ASTC_10x8_KHR 0x93BA\r\n#define GL_COMPRESSED_RGBA_ASTC_10x10_KHR 0x93BB\r\n#define GL_COMPRESSED_RGBA_ASTC_12x10_KHR 0x93BC\r\n#define GL_COMPRESSED_RGBA_ASTC_12x12_KHR 0x93BD\r\n#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR 0x93D0\r\n#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR 0x93D1\r\n#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR 0x93D2\r\n#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR 0x93D3\r\n#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR 0x93D4\r\n#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR 0x93D5\r\n#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR 0x93D6\r\n#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR 0x93D7\r\n#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR 0x93D8\r\n#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR 0x93D9\r\n#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR 0x93DA\r\n#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR 0x93DB\r\n#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR 0x93DC\r\n#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR 0x93DD\r\n\r\n#define GLEW_KHR_texture_compression_astc_ldr GLEW_GET_VAR(__GLEW_KHR_texture_compression_astc_ldr)\r\n\r\n#endif /* GL_KHR_texture_compression_astc_ldr */\r\n\r\n/* -------------------------- GL_KTX_buffer_region ------------------------- */\r\n\r\n#ifndef GL_KTX_buffer_region\r\n#define GL_KTX_buffer_region 1\r\n\r\n#define GL_KTX_FRONT_REGION 0x0\r\n#define GL_KTX_BACK_REGION 0x1\r\n#define GL_KTX_Z_REGION 0x2\r\n#define GL_KTX_STENCIL_REGION 0x3\r\n\r\ntypedef GLuint (GLAPIENTRY * PFNGLBUFFERREGIONENABLEDPROC) (void);\r\ntypedef void (GLAPIENTRY * PFNGLDELETEBUFFERREGIONPROC) (GLenum region);\r\ntypedef void (GLAPIENTRY * PFNGLDRAWBUFFERREGIONPROC) (GLuint region, GLint x, GLint y, GLsizei width, GLsizei height, GLint xDest, GLint yDest);\r\ntypedef GLuint (GLAPIENTRY * PFNGLNEWBUFFERREGIONPROC) (GLenum region);\r\ntypedef void (GLAPIENTRY * PFNGLREADBUFFERREGIONPROC) (GLuint region, GLint x, GLint y, GLsizei width, GLsizei height);\r\n\r\n#define glBufferRegionEnabled GLEW_GET_FUN(__glewBufferRegionEnabled)\r\n#define glDeleteBufferRegion GLEW_GET_FUN(__glewDeleteBufferRegion)\r\n#define glDrawBufferRegion GLEW_GET_FUN(__glewDrawBufferRegion)\r\n#define glNewBufferRegion GLEW_GET_FUN(__glewNewBufferRegion)\r\n#define glReadBufferRegion GLEW_GET_FUN(__glewReadBufferRegion)\r\n\r\n#define GLEW_KTX_buffer_region GLEW_GET_VAR(__GLEW_KTX_buffer_region)\r\n\r\n#endif /* GL_KTX_buffer_region */\r\n\r\n/* ------------------------- GL_MESAX_texture_stack ------------------------ */\r\n\r\n#ifndef GL_MESAX_texture_stack\r\n#define GL_MESAX_texture_stack 1\r\n\r\n#define GL_TEXTURE_1D_STACK_MESAX 0x8759\r\n#define GL_TEXTURE_2D_STACK_MESAX 0x875A\r\n#define GL_PROXY_TEXTURE_1D_STACK_MESAX 0x875B\r\n#define GL_PROXY_TEXTURE_2D_STACK_MESAX 0x875C\r\n#define GL_TEXTURE_1D_STACK_BINDING_MESAX 0x875D\r\n#define GL_TEXTURE_2D_STACK_BINDING_MESAX 0x875E\r\n\r\n#define GLEW_MESAX_texture_stack GLEW_GET_VAR(__GLEW_MESAX_texture_stack)\r\n\r\n#endif /* GL_MESAX_texture_stack */\r\n\r\n/* -------------------------- GL_MESA_pack_invert -------------------------- */\r\n\r\n#ifndef GL_MESA_pack_invert\r\n#define GL_MESA_pack_invert 1\r\n\r\n#define GL_PACK_INVERT_MESA 0x8758\r\n\r\n#define GLEW_MESA_pack_invert GLEW_GET_VAR(__GLEW_MESA_pack_invert)\r\n\r\n#endif /* GL_MESA_pack_invert */\r\n\r\n/* ------------------------- GL_MESA_resize_buffers ------------------------ */\r\n\r\n#ifndef GL_MESA_resize_buffers\r\n#define GL_MESA_resize_buffers 1\r\n\r\ntypedef void (GLAPIENTRY * PFNGLRESIZEBUFFERSMESAPROC) (void);\r\n\r\n#define glResizeBuffersMESA GLEW_GET_FUN(__glewResizeBuffersMESA)\r\n\r\n#define GLEW_MESA_resize_buffers GLEW_GET_VAR(__GLEW_MESA_resize_buffers)\r\n\r\n#endif /* GL_MESA_resize_buffers */\r\n\r\n/* --------------------------- GL_MESA_window_pos -------------------------- */\r\n\r\n#ifndef GL_MESA_window_pos\r\n#define GL_MESA_window_pos 1\r\n\r\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS2DMESAPROC) (GLdouble x, GLdouble y);\r\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS2DVMESAPROC) (const GLdouble* p);\r\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS2FMESAPROC) (GLfloat x, GLfloat y);\r\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS2FVMESAPROC) (const GLfloat* p);\r\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS2IMESAPROC) (GLint x, GLint y);\r\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS2IVMESAPROC) (const GLint* p);\r\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS2SMESAPROC) (GLshort x, GLshort y);\r\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS2SVMESAPROC) (const GLshort* p);\r\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS3DMESAPROC) (GLdouble x, GLdouble y, GLdouble z);\r\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS3DVMESAPROC) (const GLdouble* p);\r\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS3FMESAPROC) (GLfloat x, GLfloat y, GLfloat z);\r\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS3FVMESAPROC) (const GLfloat* p);\r\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS3IMESAPROC) (GLint x, GLint y, GLint z);\r\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS3IVMESAPROC) (const GLint* p);\r\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS3SMESAPROC) (GLshort x, GLshort y, GLshort z);\r\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS3SVMESAPROC) (const GLshort* p);\r\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS4DMESAPROC) (GLdouble x, GLdouble y, GLdouble z, GLdouble);\r\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS4DVMESAPROC) (const GLdouble* p);\r\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS4FMESAPROC) (GLfloat x, GLfloat y, GLfloat z, GLfloat w);\r\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS4FVMESAPROC) (const GLfloat* p);\r\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS4IMESAPROC) (GLint x, GLint y, GLint z, GLint w);\r\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS4IVMESAPROC) (const GLint* p);\r\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS4SMESAPROC) (GLshort x, GLshort y, GLshort z, GLshort w);\r\ntypedef void (GLAPIENTRY * PFNGLWINDOWPOS4SVMESAPROC) (const GLshort* p);\r\n\r\n#define glWindowPos2dMESA GLEW_GET_FUN(__glewWindowPos2dMESA)\r\n#define glWindowPos2dvMESA GLEW_GET_FUN(__glewWindowPos2dvMESA)\r\n#define glWindowPos2fMESA GLEW_GET_FUN(__glewWindowPos2fMESA)\r\n#define glWindowPos2fvMESA GLEW_GET_FUN(__glewWindowPos2fvMESA)\r\n#define glWindowPos2iMESA GLEW_GET_FUN(__glewWindowPos2iMESA)\r\n#define glWindowPos2ivMESA GLEW_GET_FUN(__glewWindowPos2ivMESA)\r\n#define glWindowPos2sMESA GLEW_GET_FUN(__glewWindowPos2sMESA)\r\n#define glWindowPos2svMESA GLEW_GET_FUN(__glewWindowPos2svMESA)\r\n#define glWindowPos3dMESA GLEW_GET_FUN(__glewWindowPos3dMESA)\r\n#define glWindowPos3dvMESA GLEW_GET_FUN(__glewWindowPos3dvMESA)\r\n#define glWindowPos3fMESA GLEW_GET_FUN(__glewWindowPos3fMESA)\r\n#define glWindowPos3fvMESA GLEW_GET_FUN(__glewWindowPos3fvMESA)\r\n#define glWindowPos3iMESA GLEW_GET_FUN(__glewWindowPos3iMESA)\r\n#define glWindowPos3ivMESA GLEW_GET_FUN(__glewWindowPos3ivMESA)\r\n#define glWindowPos3sMESA GLEW_GET_FUN(__glewWindowPos3sMESA)\r\n#define glWindowPos3svMESA GLEW_GET_FUN(__glewWindowPos3svMESA)\r\n#define glWindowPos4dMESA GLEW_GET_FUN(__glewWindowPos4dMESA)\r\n#define glWindowPos4dvMESA GLEW_GET_FUN(__glewWindowPos4dvMESA)\r\n#define glWindowPos4fMESA GLEW_GET_FUN(__glewWindowPos4fMESA)\r\n#define glWindowPos4fvMESA GLEW_GET_FUN(__glewWindowPos4fvMESA)\r\n#define glWindowPos4iMESA GLEW_GET_FUN(__glewWindowPos4iMESA)\r\n#define glWindowPos4ivMESA GLEW_GET_FUN(__glewWindowPos4ivMESA)\r\n#define glWindowPos4sMESA GLEW_GET_FUN(__glewWindowPos4sMESA)\r\n#define glWindowPos4svMESA GLEW_GET_FUN(__glewWindowPos4svMESA)\r\n\r\n#define GLEW_MESA_window_pos GLEW_GET_VAR(__GLEW_MESA_window_pos)\r\n\r\n#endif /* GL_MESA_window_pos */\r\n\r\n/* ------------------------- GL_MESA_ycbcr_texture ------------------------- */\r\n\r\n#ifndef GL_MESA_ycbcr_texture\r\n#define GL_MESA_ycbcr_texture 1\r\n\r\n#define GL_UNSIGNED_SHORT_8_8_MESA 0x85BA\r\n#define GL_UNSIGNED_SHORT_8_8_REV_MESA 0x85BB\r\n#define GL_YCBCR_MESA 0x8757\r\n\r\n#define GLEW_MESA_ycbcr_texture GLEW_GET_VAR(__GLEW_MESA_ycbcr_texture)\r\n\r\n#endif /* GL_MESA_ycbcr_texture */\r\n\r\n/* ----------------------- GL_NVX_conditional_render ----------------------- */\r\n\r\n#ifndef GL_NVX_conditional_render\r\n#define GL_NVX_conditional_render 1\r\n\r\ntypedef void (GLAPIENTRY * PFNGLBEGINCONDITIONALRENDERNVXPROC) (GLuint id);\r\ntypedef void (GLAPIENTRY * PFNGLENDCONDITIONALRENDERNVXPROC) (void);\r\n\r\n#define glBeginConditionalRenderNVX GLEW_GET_FUN(__glewBeginConditionalRenderNVX)\r\n#define glEndConditionalRenderNVX GLEW_GET_FUN(__glewEndConditionalRenderNVX)\r\n\r\n#define GLEW_NVX_conditional_render GLEW_GET_VAR(__GLEW_NVX_conditional_render)\r\n\r\n#endif /* GL_NVX_conditional_render */\r\n\r\n/* ------------------------- GL_NVX_gpu_memory_info ------------------------ */\r\n\r\n#ifndef GL_NVX_gpu_memory_info\r\n#define GL_NVX_gpu_memory_info 1\r\n\r\n#define GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX 0x9047\r\n#define GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX 0x9048\r\n#define GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX 0x9049\r\n#define GL_GPU_MEMORY_INFO_EVICTION_COUNT_NVX 0x904A\r\n#define GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX 0x904B\r\n\r\n#define GLEW_NVX_gpu_memory_info GLEW_GET_VAR(__GLEW_NVX_gpu_memory_info)\r\n\r\n#endif /* GL_NVX_gpu_memory_info */\r\n\r\n/* ------------------- GL_NV_bindless_multi_draw_indirect ------------------ */\r\n\r\n#ifndef GL_NV_bindless_multi_draw_indirect\r\n#define GL_NV_bindless_multi_draw_indirect 1\r\n\r\ntypedef void (GLAPIENTRY * PFNGLMULTIDRAWARRAYSINDIRECTBINDLESSNVPROC) (GLenum mode, const void *indirect, GLsizei drawCount, GLsizei stride, GLint vertexBufferCount);\r\ntypedef void (GLAPIENTRY * PFNGLMULTIDRAWELEMENTSINDIRECTBINDLESSNVPROC) (GLenum mode, GLenum type, const void *indirect, GLsizei drawCount, GLsizei stride, GLint vertexBufferCount);\r\n\r\n#define glMultiDrawArraysIndirectBindlessNV GLEW_GET_FUN(__glewMultiDrawArraysIndirectBindlessNV)\r\n#define glMultiDrawElementsIndirectBindlessNV GLEW_GET_FUN(__glewMultiDrawElementsIndirectBindlessNV)\r\n\r\n#define GLEW_NV_bindless_multi_draw_indirect GLEW_GET_VAR(__GLEW_NV_bindless_multi_draw_indirect)\r\n\r\n#endif /* GL_NV_bindless_multi_draw_indirect */\r\n\r\n/* ---------------- GL_NV_bindless_multi_draw_indirect_count --------------- */\r\n\r\n#ifndef GL_NV_bindless_multi_draw_indirect_count\r\n#define GL_NV_bindless_multi_draw_indirect_count 1\r\n\r\ntypedef void (GLAPIENTRY * PFNGLMULTIDRAWARRAYSINDIRECTBINDLESSCOUNTNVPROC) (GLenum mode, const void *indirect, GLintptr drawCount, GLsizei maxDrawCount, GLsizei stride, GLint vertexBufferCount);\r\ntypedef void (GLAPIENTRY * PFNGLMULTIDRAWELEMENTSINDIRECTBINDLESSCOUNTNVPROC) (GLenum mode, GLenum type, const void *indirect, GLintptr drawCount, GLsizei maxDrawCount, GLsizei stride, GLint vertexBufferCount);\r\n\r\n#define glMultiDrawArraysIndirectBindlessCountNV GLEW_GET_FUN(__glewMultiDrawArraysIndirectBindlessCountNV)\r\n#define glMultiDrawElementsIndirectBindlessCountNV GLEW_GET_FUN(__glewMultiDrawElementsIndirectBindlessCountNV)\r\n\r\n#define GLEW_NV_bindless_multi_draw_indirect_count GLEW_GET_VAR(__GLEW_NV_bindless_multi_draw_indirect_count)\r\n\r\n#endif /* GL_NV_bindless_multi_draw_indirect_count */\r\n\r\n/* ------------------------- GL_NV_bindless_texture ------------------------ */\r\n\r\n#ifndef GL_NV_bindless_texture\r\n#define GL_NV_bindless_texture 1\r\n\r\ntypedef GLuint64 (GLAPIENTRY * PFNGLGETIMAGEHANDLENVPROC) (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format);\r\ntypedef GLuint64 (GLAPIENTRY * PFNGLGETTEXTUREHANDLENVPROC) (GLuint texture);\r\ntypedef GLuint64 (GLAPIENTRY * PFNGLGETTEXTURESAMPLERHANDLENVPROC) (GLuint texture, GLuint sampler);\r\ntypedef GLboolean (GLAPIENTRY * PFNGLISIMAGEHANDLERESIDENTNVPROC) (GLuint64 handle);\r\ntypedef GLboolean (GLAPIENTRY * PFNGLISTEXTUREHANDLERESIDENTNVPROC) (GLuint64 handle);\r\ntypedef void (GLAPIENTRY * PFNGLMAKEIMAGEHANDLENONRESIDENTNVPROC) (GLuint64 handle);\r\ntypedef void (GLAPIENTRY * PFNGLMAKEIMAGEHANDLERESIDENTNVPROC) (GLuint64 handle, GLenum access);\r\ntypedef void (GLAPIENTRY * PFNGLMAKETEXTUREHANDLENONRESIDENTNVPROC) (GLuint64 handle);\r\ntypedef void (GLAPIENTRY * PFNGLMAKETEXTUREHANDLERESIDENTNVPROC) (GLuint64 handle);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMHANDLEUI64NVPROC) (GLuint program, GLint location, GLuint64 value);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMHANDLEUI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64* values);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORMHANDLEUI64NVPROC) (GLint location, GLuint64 value);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORMHANDLEUI64VNVPROC) (GLint location, GLsizei count, const GLuint64* value);\r\n\r\n#define glGetImageHandleNV GLEW_GET_FUN(__glewGetImageHandleNV)\r\n#define glGetTextureHandleNV GLEW_GET_FUN(__glewGetTextureHandleNV)\r\n#define glGetTextureSamplerHandleNV GLEW_GET_FUN(__glewGetTextureSamplerHandleNV)\r\n#define glIsImageHandleResidentNV GLEW_GET_FUN(__glewIsImageHandleResidentNV)\r\n#define glIsTextureHandleResidentNV GLEW_GET_FUN(__glewIsTextureHandleResidentNV)\r\n#define glMakeImageHandleNonResidentNV GLEW_GET_FUN(__glewMakeImageHandleNonResidentNV)\r\n#define glMakeImageHandleResidentNV GLEW_GET_FUN(__glewMakeImageHandleResidentNV)\r\n#define glMakeTextureHandleNonResidentNV GLEW_GET_FUN(__glewMakeTextureHandleNonResidentNV)\r\n#define glMakeTextureHandleResidentNV GLEW_GET_FUN(__glewMakeTextureHandleResidentNV)\r\n#define glProgramUniformHandleui64NV GLEW_GET_FUN(__glewProgramUniformHandleui64NV)\r\n#define glProgramUniformHandleui64vNV GLEW_GET_FUN(__glewProgramUniformHandleui64vNV)\r\n#define glUniformHandleui64NV GLEW_GET_FUN(__glewUniformHandleui64NV)\r\n#define glUniformHandleui64vNV GLEW_GET_FUN(__glewUniformHandleui64vNV)\r\n\r\n#define GLEW_NV_bindless_texture GLEW_GET_VAR(__GLEW_NV_bindless_texture)\r\n\r\n#endif /* GL_NV_bindless_texture */\r\n\r\n/* --------------------- GL_NV_blend_equation_advanced --------------------- */\r\n\r\n#ifndef GL_NV_blend_equation_advanced\r\n#define GL_NV_blend_equation_advanced 1\r\n\r\n#define GL_XOR_NV 0x1506\r\n#define GL_RED_NV 0x1903\r\n#define GL_GREEN_NV 0x1904\r\n#define GL_BLUE_NV 0x1905\r\n#define GL_BLEND_PREMULTIPLIED_SRC_NV 0x9280\r\n#define GL_BLEND_OVERLAP_NV 0x9281\r\n#define GL_UNCORRELATED_NV 0x9282\r\n#define GL_DISJOINT_NV 0x9283\r\n#define GL_CONJOINT_NV 0x9284\r\n#define GL_BLEND_ADVANCED_COHERENT_NV 0x9285\r\n#define GL_SRC_NV 0x9286\r\n#define GL_DST_NV 0x9287\r\n#define GL_SRC_OVER_NV 0x9288\r\n#define GL_DST_OVER_NV 0x9289\r\n#define GL_SRC_IN_NV 0x928A\r\n#define GL_DST_IN_NV 0x928B\r\n#define GL_SRC_OUT_NV 0x928C\r\n#define GL_DST_OUT_NV 0x928D\r\n#define GL_SRC_ATOP_NV 0x928E\r\n#define GL_DST_ATOP_NV 0x928F\r\n#define GL_PLUS_NV 0x9291\r\n#define GL_PLUS_DARKER_NV 0x9292\r\n#define GL_MULTIPLY_NV 0x9294\r\n#define GL_SCREEN_NV 0x9295\r\n#define GL_OVERLAY_NV 0x9296\r\n#define GL_DARKEN_NV 0x9297\r\n#define GL_LIGHTEN_NV 0x9298\r\n#define GL_COLORDODGE_NV 0x9299\r\n#define GL_COLORBURN_NV 0x929A\r\n#define GL_HARDLIGHT_NV 0x929B\r\n#define GL_SOFTLIGHT_NV 0x929C\r\n#define GL_DIFFERENCE_NV 0x929E\r\n#define GL_MINUS_NV 0x929F\r\n#define GL_EXCLUSION_NV 0x92A0\r\n#define GL_CONTRAST_NV 0x92A1\r\n#define GL_INVERT_RGB_NV 0x92A3\r\n#define GL_LINEARDODGE_NV 0x92A4\r\n#define GL_LINEARBURN_NV 0x92A5\r\n#define GL_VIVIDLIGHT_NV 0x92A6\r\n#define GL_LINEARLIGHT_NV 0x92A7\r\n#define GL_PINLIGHT_NV 0x92A8\r\n#define GL_HARDMIX_NV 0x92A9\r\n#define GL_HSL_HUE_NV 0x92AD\r\n#define GL_HSL_SATURATION_NV 0x92AE\r\n#define GL_HSL_COLOR_NV 0x92AF\r\n#define GL_HSL_LUMINOSITY_NV 0x92B0\r\n#define GL_PLUS_CLAMPED_NV 0x92B1\r\n#define GL_PLUS_CLAMPED_ALPHA_NV 0x92B2\r\n#define GL_MINUS_CLAMPED_NV 0x92B3\r\n#define GL_INVERT_OVG_NV 0x92B4\r\n\r\ntypedef void (GLAPIENTRY * PFNGLBLENDBARRIERNVPROC) (void);\r\ntypedef void (GLAPIENTRY * PFNGLBLENDPARAMETERINVPROC) (GLenum pname, GLint value);\r\n\r\n#define glBlendBarrierNV GLEW_GET_FUN(__glewBlendBarrierNV)\r\n#define glBlendParameteriNV GLEW_GET_FUN(__glewBlendParameteriNV)\r\n\r\n#define GLEW_NV_blend_equation_advanced GLEW_GET_VAR(__GLEW_NV_blend_equation_advanced)\r\n\r\n#endif /* GL_NV_blend_equation_advanced */\r\n\r\n/* ----------------- GL_NV_blend_equation_advanced_coherent ---------------- */\r\n\r\n#ifndef GL_NV_blend_equation_advanced_coherent\r\n#define GL_NV_blend_equation_advanced_coherent 1\r\n\r\n#define GLEW_NV_blend_equation_advanced_coherent GLEW_GET_VAR(__GLEW_NV_blend_equation_advanced_coherent)\r\n\r\n#endif /* GL_NV_blend_equation_advanced_coherent */\r\n\r\n/* --------------------------- GL_NV_blend_square -------------------------- */\r\n\r\n#ifndef GL_NV_blend_square\r\n#define GL_NV_blend_square 1\r\n\r\n#define GLEW_NV_blend_square GLEW_GET_VAR(__GLEW_NV_blend_square)\r\n\r\n#endif /* GL_NV_blend_square */\r\n\r\n/* ------------------------- GL_NV_compute_program5 ------------------------ */\r\n\r\n#ifndef GL_NV_compute_program5\r\n#define GL_NV_compute_program5 1\r\n\r\n#define GL_COMPUTE_PROGRAM_NV 0x90FB\r\n#define GL_COMPUTE_PROGRAM_PARAMETER_BUFFER_NV 0x90FC\r\n\r\n#define GLEW_NV_compute_program5 GLEW_GET_VAR(__GLEW_NV_compute_program5)\r\n\r\n#endif /* GL_NV_compute_program5 */\r\n\r\n/* ------------------------ GL_NV_conditional_render ----------------------- */\r\n\r\n#ifndef GL_NV_conditional_render\r\n#define GL_NV_conditional_render 1\r\n\r\n#define GL_QUERY_WAIT_NV 0x8E13\r\n#define GL_QUERY_NO_WAIT_NV 0x8E14\r\n#define GL_QUERY_BY_REGION_WAIT_NV 0x8E15\r\n#define GL_QUERY_BY_REGION_NO_WAIT_NV 0x8E16\r\n\r\ntypedef void (GLAPIENTRY * PFNGLBEGINCONDITIONALRENDERNVPROC) (GLuint id, GLenum mode);\r\ntypedef void (GLAPIENTRY * PFNGLENDCONDITIONALRENDERNVPROC) (void);\r\n\r\n#define glBeginConditionalRenderNV GLEW_GET_FUN(__glewBeginConditionalRenderNV)\r\n#define glEndConditionalRenderNV GLEW_GET_FUN(__glewEndConditionalRenderNV)\r\n\r\n#define GLEW_NV_conditional_render GLEW_GET_VAR(__GLEW_NV_conditional_render)\r\n\r\n#endif /* GL_NV_conditional_render */\r\n\r\n/* ----------------------- GL_NV_conservative_raster ----------------------- */\r\n\r\n#ifndef GL_NV_conservative_raster\r\n#define GL_NV_conservative_raster 1\r\n\r\n#define GL_CONSERVATIVE_RASTERIZATION_NV 0x9346\r\n#define GL_SUBPIXEL_PRECISION_BIAS_X_BITS_NV 0x9347\r\n#define GL_SUBPIXEL_PRECISION_BIAS_Y_BITS_NV 0x9348\r\n#define GL_MAX_SUBPIXEL_PRECISION_BIAS_BITS_NV 0x9349\r\n\r\ntypedef void (GLAPIENTRY * PFNGLSUBPIXELPRECISIONBIASNVPROC) (GLuint xbits, GLuint ybits);\r\n\r\n#define glSubpixelPrecisionBiasNV GLEW_GET_FUN(__glewSubpixelPrecisionBiasNV)\r\n\r\n#define GLEW_NV_conservative_raster GLEW_GET_VAR(__GLEW_NV_conservative_raster)\r\n\r\n#endif /* GL_NV_conservative_raster */\r\n\r\n/* -------------------- GL_NV_conservative_raster_dilate ------------------- */\r\n\r\n#ifndef GL_NV_conservative_raster_dilate\r\n#define GL_NV_conservative_raster_dilate 1\r\n\r\n#define GL_CONSERVATIVE_RASTER_DILATE_NV 0x9379\r\n#define GL_CONSERVATIVE_RASTER_DILATE_RANGE_NV 0x937A\r\n#define GL_CONSERVATIVE_RASTER_DILATE_GRANULARITY_NV 0x937B\r\n\r\ntypedef void (GLAPIENTRY * PFNGLCONSERVATIVERASTERPARAMETERFNVPROC) (GLenum pname, GLfloat value);\r\n\r\n#define glConservativeRasterParameterfNV GLEW_GET_FUN(__glewConservativeRasterParameterfNV)\r\n\r\n#define GLEW_NV_conservative_raster_dilate GLEW_GET_VAR(__GLEW_NV_conservative_raster_dilate)\r\n\r\n#endif /* GL_NV_conservative_raster_dilate */\r\n\r\n/* ----------------------- GL_NV_copy_depth_to_color ----------------------- */\r\n\r\n#ifndef GL_NV_copy_depth_to_color\r\n#define GL_NV_copy_depth_to_color 1\r\n\r\n#define GL_DEPTH_STENCIL_TO_RGBA_NV 0x886E\r\n#define GL_DEPTH_STENCIL_TO_BGRA_NV 0x886F\r\n\r\n#define GLEW_NV_copy_depth_to_color GLEW_GET_VAR(__GLEW_NV_copy_depth_to_color)\r\n\r\n#endif /* GL_NV_copy_depth_to_color */\r\n\r\n/* ---------------------------- GL_NV_copy_image --------------------------- */\r\n\r\n#ifndef GL_NV_copy_image\r\n#define GL_NV_copy_image 1\r\n\r\ntypedef void (GLAPIENTRY * PFNGLCOPYIMAGESUBDATANVPROC) (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth);\r\n\r\n#define glCopyImageSubDataNV GLEW_GET_FUN(__glewCopyImageSubDataNV)\r\n\r\n#define GLEW_NV_copy_image GLEW_GET_VAR(__GLEW_NV_copy_image)\r\n\r\n#endif /* GL_NV_copy_image */\r\n\r\n/* -------------------------- GL_NV_deep_texture3D ------------------------- */\r\n\r\n#ifndef GL_NV_deep_texture3D\r\n#define GL_NV_deep_texture3D 1\r\n\r\n#define GL_MAX_DEEP_3D_TEXTURE_WIDTH_HEIGHT_NV 0x90D0\r\n#define GL_MAX_DEEP_3D_TEXTURE_DEPTH_NV 0x90D1\r\n\r\n#define GLEW_NV_deep_texture3D GLEW_GET_VAR(__GLEW_NV_deep_texture3D)\r\n\r\n#endif /* GL_NV_deep_texture3D */\r\n\r\n/* ------------------------ GL_NV_depth_buffer_float ----------------------- */\r\n\r\n#ifndef GL_NV_depth_buffer_float\r\n#define GL_NV_depth_buffer_float 1\r\n\r\n#define GL_DEPTH_COMPONENT32F_NV 0x8DAB\r\n#define GL_DEPTH32F_STENCIL8_NV 0x8DAC\r\n#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV_NV 0x8DAD\r\n#define GL_DEPTH_BUFFER_FLOAT_MODE_NV 0x8DAF\r\n\r\ntypedef void (GLAPIENTRY * PFNGLCLEARDEPTHDNVPROC) (GLdouble depth);\r\ntypedef void (GLAPIENTRY * PFNGLDEPTHBOUNDSDNVPROC) (GLdouble zmin, GLdouble zmax);\r\ntypedef void (GLAPIENTRY * PFNGLDEPTHRANGEDNVPROC) (GLdouble zNear, GLdouble zFar);\r\n\r\n#define glClearDepthdNV GLEW_GET_FUN(__glewClearDepthdNV)\r\n#define glDepthBoundsdNV GLEW_GET_FUN(__glewDepthBoundsdNV)\r\n#define glDepthRangedNV GLEW_GET_FUN(__glewDepthRangedNV)\r\n\r\n#define GLEW_NV_depth_buffer_float GLEW_GET_VAR(__GLEW_NV_depth_buffer_float)\r\n\r\n#endif /* GL_NV_depth_buffer_float */\r\n\r\n/* --------------------------- GL_NV_depth_clamp --------------------------- */\r\n\r\n#ifndef GL_NV_depth_clamp\r\n#define GL_NV_depth_clamp 1\r\n\r\n#define GL_DEPTH_CLAMP_NV 0x864F\r\n\r\n#define GLEW_NV_depth_clamp GLEW_GET_VAR(__GLEW_NV_depth_clamp)\r\n\r\n#endif /* GL_NV_depth_clamp */\r\n\r\n/* ---------------------- GL_NV_depth_range_unclamped ---------------------- */\r\n\r\n#ifndef GL_NV_depth_range_unclamped\r\n#define GL_NV_depth_range_unclamped 1\r\n\r\n#define GL_SAMPLE_COUNT_BITS_NV 0x8864\r\n#define GL_CURRENT_SAMPLE_COUNT_QUERY_NV 0x8865\r\n#define GL_QUERY_RESULT_NV 0x8866\r\n#define GL_QUERY_RESULT_AVAILABLE_NV 0x8867\r\n#define GL_SAMPLE_COUNT_NV 0x8914\r\n\r\n#define GLEW_NV_depth_range_unclamped GLEW_GET_VAR(__GLEW_NV_depth_range_unclamped)\r\n\r\n#endif /* GL_NV_depth_range_unclamped */\r\n\r\n/* --------------------------- GL_NV_draw_texture -------------------------- */\r\n\r\n#ifndef GL_NV_draw_texture\r\n#define GL_NV_draw_texture 1\r\n\r\ntypedef void (GLAPIENTRY * PFNGLDRAWTEXTURENVPROC) (GLuint texture, GLuint sampler, GLfloat x0, GLfloat y0, GLfloat x1, GLfloat y1, GLfloat z, GLfloat s0, GLfloat t0, GLfloat s1, GLfloat t1);\r\n\r\n#define glDrawTextureNV GLEW_GET_FUN(__glewDrawTextureNV)\r\n\r\n#define GLEW_NV_draw_texture GLEW_GET_VAR(__GLEW_NV_draw_texture)\r\n\r\n#endif /* GL_NV_draw_texture */\r\n\r\n/* ---------------------------- GL_NV_evaluators --------------------------- */\r\n\r\n#ifndef GL_NV_evaluators\r\n#define GL_NV_evaluators 1\r\n\r\n#define GL_EVAL_2D_NV 0x86C0\r\n#define GL_EVAL_TRIANGULAR_2D_NV 0x86C1\r\n#define GL_MAP_TESSELLATION_NV 0x86C2\r\n#define GL_MAP_ATTRIB_U_ORDER_NV 0x86C3\r\n#define GL_MAP_ATTRIB_V_ORDER_NV 0x86C4\r\n#define GL_EVAL_FRACTIONAL_TESSELLATION_NV 0x86C5\r\n#define GL_EVAL_VERTEX_ATTRIB0_NV 0x86C6\r\n#define GL_EVAL_VERTEX_ATTRIB1_NV 0x86C7\r\n#define GL_EVAL_VERTEX_ATTRIB2_NV 0x86C8\r\n#define GL_EVAL_VERTEX_ATTRIB3_NV 0x86C9\r\n#define GL_EVAL_VERTEX_ATTRIB4_NV 0x86CA\r\n#define GL_EVAL_VERTEX_ATTRIB5_NV 0x86CB\r\n#define GL_EVAL_VERTEX_ATTRIB6_NV 0x86CC\r\n#define GL_EVAL_VERTEX_ATTRIB7_NV 0x86CD\r\n#define GL_EVAL_VERTEX_ATTRIB8_NV 0x86CE\r\n#define GL_EVAL_VERTEX_ATTRIB9_NV 0x86CF\r\n#define GL_EVAL_VERTEX_ATTRIB10_NV 0x86D0\r\n#define GL_EVAL_VERTEX_ATTRIB11_NV 0x86D1\r\n#define GL_EVAL_VERTEX_ATTRIB12_NV 0x86D2\r\n#define GL_EVAL_VERTEX_ATTRIB13_NV 0x86D3\r\n#define GL_EVAL_VERTEX_ATTRIB14_NV 0x86D4\r\n#define GL_EVAL_VERTEX_ATTRIB15_NV 0x86D5\r\n#define GL_MAX_MAP_TESSELLATION_NV 0x86D6\r\n#define GL_MAX_RATIONAL_EVAL_ORDER_NV 0x86D7\r\n\r\ntypedef void (GLAPIENTRY * PFNGLEVALMAPSNVPROC) (GLenum target, GLenum mode);\r\ntypedef void (GLAPIENTRY * PFNGLGETMAPATTRIBPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETMAPATTRIBPARAMETERIVNVPROC) (GLenum target, GLuint index, GLenum pname, GLint* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLboolean packed, void *points);\r\ntypedef void (GLAPIENTRY * PFNGLGETMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, GLfloat* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, GLint* params);\r\ntypedef void (GLAPIENTRY * PFNGLMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLint uorder, GLint vorder, GLboolean packed, const void *points);\r\ntypedef void (GLAPIENTRY * PFNGLMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, const GLfloat* params);\r\ntypedef void (GLAPIENTRY * PFNGLMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, const GLint* params);\r\n\r\n#define glEvalMapsNV GLEW_GET_FUN(__glewEvalMapsNV)\r\n#define glGetMapAttribParameterfvNV GLEW_GET_FUN(__glewGetMapAttribParameterfvNV)\r\n#define glGetMapAttribParameterivNV GLEW_GET_FUN(__glewGetMapAttribParameterivNV)\r\n#define glGetMapControlPointsNV GLEW_GET_FUN(__glewGetMapControlPointsNV)\r\n#define glGetMapParameterfvNV GLEW_GET_FUN(__glewGetMapParameterfvNV)\r\n#define glGetMapParameterivNV GLEW_GET_FUN(__glewGetMapParameterivNV)\r\n#define glMapControlPointsNV GLEW_GET_FUN(__glewMapControlPointsNV)\r\n#define glMapParameterfvNV GLEW_GET_FUN(__glewMapParameterfvNV)\r\n#define glMapParameterivNV GLEW_GET_FUN(__glewMapParameterivNV)\r\n\r\n#define GLEW_NV_evaluators GLEW_GET_VAR(__GLEW_NV_evaluators)\r\n\r\n#endif /* GL_NV_evaluators */\r\n\r\n/* ----------------------- GL_NV_explicit_multisample ---------------------- */\r\n\r\n#ifndef GL_NV_explicit_multisample\r\n#define GL_NV_explicit_multisample 1\r\n\r\n#define GL_SAMPLE_POSITION_NV 0x8E50\r\n#define GL_SAMPLE_MASK_NV 0x8E51\r\n#define GL_SAMPLE_MASK_VALUE_NV 0x8E52\r\n#define GL_TEXTURE_BINDING_RENDERBUFFER_NV 0x8E53\r\n#define GL_TEXTURE_RENDERBUFFER_DATA_STORE_BINDING_NV 0x8E54\r\n#define GL_TEXTURE_RENDERBUFFER_NV 0x8E55\r\n#define GL_SAMPLER_RENDERBUFFER_NV 0x8E56\r\n#define GL_INT_SAMPLER_RENDERBUFFER_NV 0x8E57\r\n#define GL_UNSIGNED_INT_SAMPLER_RENDERBUFFER_NV 0x8E58\r\n#define GL_MAX_SAMPLE_MASK_WORDS_NV 0x8E59\r\n\r\ntypedef void (GLAPIENTRY * PFNGLGETMULTISAMPLEFVNVPROC) (GLenum pname, GLuint index, GLfloat* val);\r\ntypedef void (GLAPIENTRY * PFNGLSAMPLEMASKINDEXEDNVPROC) (GLuint index, GLbitfield mask);\r\ntypedef void (GLAPIENTRY * PFNGLTEXRENDERBUFFERNVPROC) (GLenum target, GLuint renderbuffer);\r\n\r\n#define glGetMultisamplefvNV GLEW_GET_FUN(__glewGetMultisamplefvNV)\r\n#define glSampleMaskIndexedNV GLEW_GET_FUN(__glewSampleMaskIndexedNV)\r\n#define glTexRenderbufferNV GLEW_GET_FUN(__glewTexRenderbufferNV)\r\n\r\n#define GLEW_NV_explicit_multisample GLEW_GET_VAR(__GLEW_NV_explicit_multisample)\r\n\r\n#endif /* GL_NV_explicit_multisample */\r\n\r\n/* ------------------------------ GL_NV_fence ------------------------------ */\r\n\r\n#ifndef GL_NV_fence\r\n#define GL_NV_fence 1\r\n\r\n#define GL_ALL_COMPLETED_NV 0x84F2\r\n#define GL_FENCE_STATUS_NV 0x84F3\r\n#define GL_FENCE_CONDITION_NV 0x84F4\r\n\r\ntypedef void (GLAPIENTRY * PFNGLDELETEFENCESNVPROC) (GLsizei n, const GLuint* fences);\r\ntypedef void (GLAPIENTRY * PFNGLFINISHFENCENVPROC) (GLuint fence);\r\ntypedef void (GLAPIENTRY * PFNGLGENFENCESNVPROC) (GLsizei n, GLuint* fences);\r\ntypedef void (GLAPIENTRY * PFNGLGETFENCEIVNVPROC) (GLuint fence, GLenum pname, GLint* params);\r\ntypedef GLboolean (GLAPIENTRY * PFNGLISFENCENVPROC) (GLuint fence);\r\ntypedef void (GLAPIENTRY * PFNGLSETFENCENVPROC) (GLuint fence, GLenum condition);\r\ntypedef GLboolean (GLAPIENTRY * PFNGLTESTFENCENVPROC) (GLuint fence);\r\n\r\n#define glDeleteFencesNV GLEW_GET_FUN(__glewDeleteFencesNV)\r\n#define glFinishFenceNV GLEW_GET_FUN(__glewFinishFenceNV)\r\n#define glGenFencesNV GLEW_GET_FUN(__glewGenFencesNV)\r\n#define glGetFenceivNV GLEW_GET_FUN(__glewGetFenceivNV)\r\n#define glIsFenceNV GLEW_GET_FUN(__glewIsFenceNV)\r\n#define glSetFenceNV GLEW_GET_FUN(__glewSetFenceNV)\r\n#define glTestFenceNV GLEW_GET_FUN(__glewTestFenceNV)\r\n\r\n#define GLEW_NV_fence GLEW_GET_VAR(__GLEW_NV_fence)\r\n\r\n#endif /* GL_NV_fence */\r\n\r\n/* -------------------------- GL_NV_fill_rectangle ------------------------- */\r\n\r\n#ifndef GL_NV_fill_rectangle\r\n#define GL_NV_fill_rectangle 1\r\n\r\n#define GL_FILL_RECTANGLE_NV 0x933C\r\n\r\n#define GLEW_NV_fill_rectangle GLEW_GET_VAR(__GLEW_NV_fill_rectangle)\r\n\r\n#endif /* GL_NV_fill_rectangle */\r\n\r\n/* --------------------------- GL_NV_float_buffer -------------------------- */\r\n\r\n#ifndef GL_NV_float_buffer\r\n#define GL_NV_float_buffer 1\r\n\r\n#define GL_FLOAT_R_NV 0x8880\r\n#define GL_FLOAT_RG_NV 0x8881\r\n#define GL_FLOAT_RGB_NV 0x8882\r\n#define GL_FLOAT_RGBA_NV 0x8883\r\n#define GL_FLOAT_R16_NV 0x8884\r\n#define GL_FLOAT_R32_NV 0x8885\r\n#define GL_FLOAT_RG16_NV 0x8886\r\n#define GL_FLOAT_RG32_NV 0x8887\r\n#define GL_FLOAT_RGB16_NV 0x8888\r\n#define GL_FLOAT_RGB32_NV 0x8889\r\n#define GL_FLOAT_RGBA16_NV 0x888A\r\n#define GL_FLOAT_RGBA32_NV 0x888B\r\n#define GL_TEXTURE_FLOAT_COMPONENTS_NV 0x888C\r\n#define GL_FLOAT_CLEAR_COLOR_VALUE_NV 0x888D\r\n#define GL_FLOAT_RGBA_MODE_NV 0x888E\r\n\r\n#define GLEW_NV_float_buffer GLEW_GET_VAR(__GLEW_NV_float_buffer)\r\n\r\n#endif /* GL_NV_float_buffer */\r\n\r\n/* --------------------------- GL_NV_fog_distance -------------------------- */\r\n\r\n#ifndef GL_NV_fog_distance\r\n#define GL_NV_fog_distance 1\r\n\r\n#define GL_FOG_DISTANCE_MODE_NV 0x855A\r\n#define GL_EYE_RADIAL_NV 0x855B\r\n#define GL_EYE_PLANE_ABSOLUTE_NV 0x855C\r\n\r\n#define GLEW_NV_fog_distance GLEW_GET_VAR(__GLEW_NV_fog_distance)\r\n\r\n#endif /* GL_NV_fog_distance */\r\n\r\n/* -------------------- GL_NV_fragment_coverage_to_color ------------------- */\r\n\r\n#ifndef GL_NV_fragment_coverage_to_color\r\n#define GL_NV_fragment_coverage_to_color 1\r\n\r\n#define GL_FRAGMENT_COVERAGE_TO_COLOR_NV 0x92DD\r\n#define GL_FRAGMENT_COVERAGE_COLOR_NV 0x92DE\r\n\r\ntypedef void (GLAPIENTRY * PFNGLFRAGMENTCOVERAGECOLORNVPROC) (GLuint color);\r\n\r\n#define glFragmentCoverageColorNV GLEW_GET_FUN(__glewFragmentCoverageColorNV)\r\n\r\n#define GLEW_NV_fragment_coverage_to_color GLEW_GET_VAR(__GLEW_NV_fragment_coverage_to_color)\r\n\r\n#endif /* GL_NV_fragment_coverage_to_color */\r\n\r\n/* ------------------------- GL_NV_fragment_program ------------------------ */\r\n\r\n#ifndef GL_NV_fragment_program\r\n#define GL_NV_fragment_program 1\r\n\r\n#define GL_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMETERS_NV 0x8868\r\n#define GL_FRAGMENT_PROGRAM_NV 0x8870\r\n#define GL_MAX_TEXTURE_COORDS_NV 0x8871\r\n#define GL_MAX_TEXTURE_IMAGE_UNITS_NV 0x8872\r\n#define GL_FRAGMENT_PROGRAM_BINDING_NV 0x8873\r\n#define GL_PROGRAM_ERROR_STRING_NV 0x8874\r\n\r\ntypedef void (GLAPIENTRY * PFNGLGETPROGRAMNAMEDPARAMETERDVNVPROC) (GLuint id, GLsizei len, const GLubyte* name, GLdouble *params);\r\ntypedef void (GLAPIENTRY * PFNGLGETPROGRAMNAMEDPARAMETERFVNVPROC) (GLuint id, GLsizei len, const GLubyte* name, GLfloat *params);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMNAMEDPARAMETER4DNVPROC) (GLuint id, GLsizei len, const GLubyte* name, GLdouble x, GLdouble y, GLdouble z, GLdouble w);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMNAMEDPARAMETER4DVNVPROC) (GLuint id, GLsizei len, const GLubyte* name, const GLdouble v[]);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMNAMEDPARAMETER4FNVPROC) (GLuint id, GLsizei len, const GLubyte* name, GLfloat x, GLfloat y, GLfloat z, GLfloat w);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMNAMEDPARAMETER4FVNVPROC) (GLuint id, GLsizei len, const GLubyte* name, const GLfloat v[]);\r\n\r\n#define glGetProgramNamedParameterdvNV GLEW_GET_FUN(__glewGetProgramNamedParameterdvNV)\r\n#define glGetProgramNamedParameterfvNV GLEW_GET_FUN(__glewGetProgramNamedParameterfvNV)\r\n#define glProgramNamedParameter4dNV GLEW_GET_FUN(__glewProgramNamedParameter4dNV)\r\n#define glProgramNamedParameter4dvNV GLEW_GET_FUN(__glewProgramNamedParameter4dvNV)\r\n#define glProgramNamedParameter4fNV GLEW_GET_FUN(__glewProgramNamedParameter4fNV)\r\n#define glProgramNamedParameter4fvNV GLEW_GET_FUN(__glewProgramNamedParameter4fvNV)\r\n\r\n#define GLEW_NV_fragment_program GLEW_GET_VAR(__GLEW_NV_fragment_program)\r\n\r\n#endif /* GL_NV_fragment_program */\r\n\r\n/* ------------------------ GL_NV_fragment_program2 ------------------------ */\r\n\r\n#ifndef GL_NV_fragment_program2\r\n#define GL_NV_fragment_program2 1\r\n\r\n#define GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV 0x88F4\r\n#define GL_MAX_PROGRAM_CALL_DEPTH_NV 0x88F5\r\n#define GL_MAX_PROGRAM_IF_DEPTH_NV 0x88F6\r\n#define GL_MAX_PROGRAM_LOOP_DEPTH_NV 0x88F7\r\n#define GL_MAX_PROGRAM_LOOP_COUNT_NV 0x88F8\r\n\r\n#define GLEW_NV_fragment_program2 GLEW_GET_VAR(__GLEW_NV_fragment_program2)\r\n\r\n#endif /* GL_NV_fragment_program2 */\r\n\r\n/* ------------------------ GL_NV_fragment_program4 ------------------------ */\r\n\r\n#ifndef GL_NV_fragment_program4\r\n#define GL_NV_fragment_program4 1\r\n\r\n#define GLEW_NV_fragment_program4 GLEW_GET_VAR(__GLEW_NV_fragment_program4)\r\n\r\n#endif /* GL_NV_fragment_program4 */\r\n\r\n/* --------------------- GL_NV_fragment_program_option --------------------- */\r\n\r\n#ifndef GL_NV_fragment_program_option\r\n#define GL_NV_fragment_program_option 1\r\n\r\n#define GLEW_NV_fragment_program_option GLEW_GET_VAR(__GLEW_NV_fragment_program_option)\r\n\r\n#endif /* GL_NV_fragment_program_option */\r\n\r\n/* -------------------- GL_NV_fragment_shader_interlock -------------------- */\r\n\r\n#ifndef GL_NV_fragment_shader_interlock\r\n#define GL_NV_fragment_shader_interlock 1\r\n\r\n#define GLEW_NV_fragment_shader_interlock GLEW_GET_VAR(__GLEW_NV_fragment_shader_interlock)\r\n\r\n#endif /* GL_NV_fragment_shader_interlock */\r\n\r\n/* -------------------- GL_NV_framebuffer_mixed_samples -------------------- */\r\n\r\n#ifndef GL_NV_framebuffer_mixed_samples\r\n#define GL_NV_framebuffer_mixed_samples 1\r\n\r\n#define GL_COLOR_SAMPLES_NV 0x8E20\r\n#define GL_RASTER_MULTISAMPLE_EXT 0x9327\r\n#define GL_RASTER_SAMPLES_EXT 0x9328\r\n#define GL_MAX_RASTER_SAMPLES_EXT 0x9329\r\n#define GL_RASTER_FIXED_SAMPLE_LOCATIONS_EXT 0x932A\r\n#define GL_MULTISAMPLE_RASTERIZATION_ALLOWED_EXT 0x932B\r\n#define GL_EFFECTIVE_RASTER_SAMPLES_EXT 0x932C\r\n#define GL_DEPTH_SAMPLES_NV 0x932D\r\n#define GL_STENCIL_SAMPLES_NV 0x932E\r\n#define GL_MIXED_DEPTH_SAMPLES_SUPPORTED_NV 0x932F\r\n#define GL_MIXED_STENCIL_SAMPLES_SUPPORTED_NV 0x9330\r\n#define GL_COVERAGE_MODULATION_TABLE_NV 0x9331\r\n#define GL_COVERAGE_MODULATION_NV 0x9332\r\n#define GL_COVERAGE_MODULATION_TABLE_SIZE_NV 0x9333\r\n\r\n#define GLEW_NV_framebuffer_mixed_samples GLEW_GET_VAR(__GLEW_NV_framebuffer_mixed_samples)\r\n\r\n#endif /* GL_NV_framebuffer_mixed_samples */\r\n\r\n/* ----------------- GL_NV_framebuffer_multisample_coverage ---------------- */\r\n\r\n#ifndef GL_NV_framebuffer_multisample_coverage\r\n#define GL_NV_framebuffer_multisample_coverage 1\r\n\r\n#define GL_RENDERBUFFER_COVERAGE_SAMPLES_NV 0x8CAB\r\n#define GL_RENDERBUFFER_COLOR_SAMPLES_NV 0x8E10\r\n#define GL_MAX_MULTISAMPLE_COVERAGE_MODES_NV 0x8E11\r\n#define GL_MULTISAMPLE_COVERAGE_MODES_NV 0x8E12\r\n\r\ntypedef void (GLAPIENTRY * PFNGLRENDERBUFFERSTORAGEMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height);\r\n\r\n#define glRenderbufferStorageMultisampleCoverageNV GLEW_GET_FUN(__glewRenderbufferStorageMultisampleCoverageNV)\r\n\r\n#define GLEW_NV_framebuffer_multisample_coverage GLEW_GET_VAR(__GLEW_NV_framebuffer_multisample_coverage)\r\n\r\n#endif /* GL_NV_framebuffer_multisample_coverage */\r\n\r\n/* ------------------------ GL_NV_geometry_program4 ------------------------ */\r\n\r\n#ifndef GL_NV_geometry_program4\r\n#define GL_NV_geometry_program4 1\r\n\r\n#define GL_GEOMETRY_PROGRAM_NV 0x8C26\r\n#define GL_MAX_PROGRAM_OUTPUT_VERTICES_NV 0x8C27\r\n#define GL_MAX_PROGRAM_TOTAL_OUTPUT_COMPONENTS_NV 0x8C28\r\n\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMVERTEXLIMITNVPROC) (GLenum target, GLint limit);\r\n\r\n#define glProgramVertexLimitNV GLEW_GET_FUN(__glewProgramVertexLimitNV)\r\n\r\n#define GLEW_NV_geometry_program4 GLEW_GET_VAR(__GLEW_NV_geometry_program4)\r\n\r\n#endif /* GL_NV_geometry_program4 */\r\n\r\n/* ------------------------- GL_NV_geometry_shader4 ------------------------ */\r\n\r\n#ifndef GL_NV_geometry_shader4\r\n#define GL_NV_geometry_shader4 1\r\n\r\n#define GLEW_NV_geometry_shader4 GLEW_GET_VAR(__GLEW_NV_geometry_shader4)\r\n\r\n#endif /* GL_NV_geometry_shader4 */\r\n\r\n/* ------------------- GL_NV_geometry_shader_passthrough ------------------- */\r\n\r\n#ifndef GL_NV_geometry_shader_passthrough\r\n#define GL_NV_geometry_shader_passthrough 1\r\n\r\n#define GLEW_NV_geometry_shader_passthrough GLEW_GET_VAR(__GLEW_NV_geometry_shader_passthrough)\r\n\r\n#endif /* GL_NV_geometry_shader_passthrough */\r\n\r\n/* --------------------------- GL_NV_gpu_program4 -------------------------- */\r\n\r\n#ifndef GL_NV_gpu_program4\r\n#define GL_NV_gpu_program4 1\r\n\r\n#define GL_MIN_PROGRAM_TEXEL_OFFSET_NV 0x8904\r\n#define GL_MAX_PROGRAM_TEXEL_OFFSET_NV 0x8905\r\n#define GL_PROGRAM_ATTRIB_COMPONENTS_NV 0x8906\r\n#define GL_PROGRAM_RESULT_COMPONENTS_NV 0x8907\r\n#define GL_MAX_PROGRAM_ATTRIB_COMPONENTS_NV 0x8908\r\n#define GL_MAX_PROGRAM_RESULT_COMPONENTS_NV 0x8909\r\n#define GL_MAX_PROGRAM_GENERIC_ATTRIBS_NV 0x8DA5\r\n#define GL_MAX_PROGRAM_GENERIC_RESULTS_NV 0x8DA6\r\n\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETERI4INVPROC) (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETERI4IVNVPROC) (GLenum target, GLuint index, const GLint *params);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETERI4UINVPROC) (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETERI4UIVNVPROC) (GLenum target, GLuint index, const GLuint *params);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETERSI4IVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLint *params);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETERSI4UIVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLuint *params);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETERI4INVPROC) (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETERI4IVNVPROC) (GLenum target, GLuint index, const GLint *params);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETERI4UINVPROC) (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETERI4UIVNVPROC) (GLenum target, GLuint index, const GLuint *params);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETERSI4IVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLint *params);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETERSI4UIVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLuint *params);\r\n\r\n#define glProgramEnvParameterI4iNV GLEW_GET_FUN(__glewProgramEnvParameterI4iNV)\r\n#define glProgramEnvParameterI4ivNV GLEW_GET_FUN(__glewProgramEnvParameterI4ivNV)\r\n#define glProgramEnvParameterI4uiNV GLEW_GET_FUN(__glewProgramEnvParameterI4uiNV)\r\n#define glProgramEnvParameterI4uivNV GLEW_GET_FUN(__glewProgramEnvParameterI4uivNV)\r\n#define glProgramEnvParametersI4ivNV GLEW_GET_FUN(__glewProgramEnvParametersI4ivNV)\r\n#define glProgramEnvParametersI4uivNV GLEW_GET_FUN(__glewProgramEnvParametersI4uivNV)\r\n#define glProgramLocalParameterI4iNV GLEW_GET_FUN(__glewProgramLocalParameterI4iNV)\r\n#define glProgramLocalParameterI4ivNV GLEW_GET_FUN(__glewProgramLocalParameterI4ivNV)\r\n#define glProgramLocalParameterI4uiNV GLEW_GET_FUN(__glewProgramLocalParameterI4uiNV)\r\n#define glProgramLocalParameterI4uivNV GLEW_GET_FUN(__glewProgramLocalParameterI4uivNV)\r\n#define glProgramLocalParametersI4ivNV GLEW_GET_FUN(__glewProgramLocalParametersI4ivNV)\r\n#define glProgramLocalParametersI4uivNV GLEW_GET_FUN(__glewProgramLocalParametersI4uivNV)\r\n\r\n#define GLEW_NV_gpu_program4 GLEW_GET_VAR(__GLEW_NV_gpu_program4)\r\n\r\n#endif /* GL_NV_gpu_program4 */\r\n\r\n/* --------------------------- GL_NV_gpu_program5 -------------------------- */\r\n\r\n#ifndef GL_NV_gpu_program5\r\n#define GL_NV_gpu_program5 1\r\n\r\n#define GL_MAX_GEOMETRY_PROGRAM_INVOCATIONS_NV 0x8E5A\r\n#define GL_MIN_FRAGMENT_INTERPOLATION_OFFSET_NV 0x8E5B\r\n#define GL_MAX_FRAGMENT_INTERPOLATION_OFFSET_NV 0x8E5C\r\n#define GL_FRAGMENT_PROGRAM_INTERPOLATION_OFFSET_BITS_NV 0x8E5D\r\n#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET_NV 0x8E5E\r\n#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET_NV 0x8E5F\r\n\r\n#define GLEW_NV_gpu_program5 GLEW_GET_VAR(__GLEW_NV_gpu_program5)\r\n\r\n#endif /* GL_NV_gpu_program5 */\r\n\r\n/* -------------------- GL_NV_gpu_program5_mem_extended -------------------- */\r\n\r\n#ifndef GL_NV_gpu_program5_mem_extended\r\n#define GL_NV_gpu_program5_mem_extended 1\r\n\r\n#define GLEW_NV_gpu_program5_mem_extended GLEW_GET_VAR(__GLEW_NV_gpu_program5_mem_extended)\r\n\r\n#endif /* GL_NV_gpu_program5_mem_extended */\r\n\r\n/* ------------------------- GL_NV_gpu_program_fp64 ------------------------ */\r\n\r\n#ifndef GL_NV_gpu_program_fp64\r\n#define GL_NV_gpu_program_fp64 1\r\n\r\n#define GLEW_NV_gpu_program_fp64 GLEW_GET_VAR(__GLEW_NV_gpu_program_fp64)\r\n\r\n#endif /* GL_NV_gpu_program_fp64 */\r\n\r\n/* --------------------------- GL_NV_gpu_shader5 --------------------------- */\r\n\r\n#ifndef GL_NV_gpu_shader5\r\n#define GL_NV_gpu_shader5 1\r\n\r\n#define GL_INT64_NV 0x140E\r\n#define GL_UNSIGNED_INT64_NV 0x140F\r\n#define GL_INT8_NV 0x8FE0\r\n#define GL_INT8_VEC2_NV 0x8FE1\r\n#define GL_INT8_VEC3_NV 0x8FE2\r\n#define GL_INT8_VEC4_NV 0x8FE3\r\n#define GL_INT16_NV 0x8FE4\r\n#define GL_INT16_VEC2_NV 0x8FE5\r\n#define GL_INT16_VEC3_NV 0x8FE6\r\n#define GL_INT16_VEC4_NV 0x8FE7\r\n#define GL_INT64_VEC2_NV 0x8FE9\r\n#define GL_INT64_VEC3_NV 0x8FEA\r\n#define GL_INT64_VEC4_NV 0x8FEB\r\n#define GL_UNSIGNED_INT8_NV 0x8FEC\r\n#define GL_UNSIGNED_INT8_VEC2_NV 0x8FED\r\n#define GL_UNSIGNED_INT8_VEC3_NV 0x8FEE\r\n#define GL_UNSIGNED_INT8_VEC4_NV 0x8FEF\r\n#define GL_UNSIGNED_INT16_NV 0x8FF0\r\n#define GL_UNSIGNED_INT16_VEC2_NV 0x8FF1\r\n#define GL_UNSIGNED_INT16_VEC3_NV 0x8FF2\r\n#define GL_UNSIGNED_INT16_VEC4_NV 0x8FF3\r\n#define GL_UNSIGNED_INT64_VEC2_NV 0x8FF5\r\n#define GL_UNSIGNED_INT64_VEC3_NV 0x8FF6\r\n#define GL_UNSIGNED_INT64_VEC4_NV 0x8FF7\r\n#define GL_FLOAT16_NV 0x8FF8\r\n#define GL_FLOAT16_VEC2_NV 0x8FF9\r\n#define GL_FLOAT16_VEC3_NV 0x8FFA\r\n#define GL_FLOAT16_VEC4_NV 0x8FFB\r\n\r\ntypedef void (GLAPIENTRY * PFNGLGETUNIFORMI64VNVPROC) (GLuint program, GLint location, GLint64EXT* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETUNIFORMUI64VNVPROC) (GLuint program, GLint location, GLuint64EXT* params);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1I64NVPROC) (GLuint program, GLint location, GLint64EXT x);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT* value);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT* value);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT* value);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT* value);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT* value);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT* value);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT* value);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT* value);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORM1I64NVPROC) (GLint location, GLint64EXT x);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORM1I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT* value);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORM1UI64NVPROC) (GLint location, GLuint64EXT x);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORM1UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT* value);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORM2I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORM2I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT* value);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORM2UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORM2UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT* value);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORM3I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORM3I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT* value);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORM3UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORM3UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT* value);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORM4I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORM4I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT* value);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORM4UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORM4UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT* value);\r\n\r\n#define glGetUniformi64vNV GLEW_GET_FUN(__glewGetUniformi64vNV)\r\n#define glGetUniformui64vNV GLEW_GET_FUN(__glewGetUniformui64vNV)\r\n#define glProgramUniform1i64NV GLEW_GET_FUN(__glewProgramUniform1i64NV)\r\n#define glProgramUniform1i64vNV GLEW_GET_FUN(__glewProgramUniform1i64vNV)\r\n#define glProgramUniform1ui64NV GLEW_GET_FUN(__glewProgramUniform1ui64NV)\r\n#define glProgramUniform1ui64vNV GLEW_GET_FUN(__glewProgramUniform1ui64vNV)\r\n#define glProgramUniform2i64NV GLEW_GET_FUN(__glewProgramUniform2i64NV)\r\n#define glProgramUniform2i64vNV GLEW_GET_FUN(__glewProgramUniform2i64vNV)\r\n#define glProgramUniform2ui64NV GLEW_GET_FUN(__glewProgramUniform2ui64NV)\r\n#define glProgramUniform2ui64vNV GLEW_GET_FUN(__glewProgramUniform2ui64vNV)\r\n#define glProgramUniform3i64NV GLEW_GET_FUN(__glewProgramUniform3i64NV)\r\n#define glProgramUniform3i64vNV GLEW_GET_FUN(__glewProgramUniform3i64vNV)\r\n#define glProgramUniform3ui64NV GLEW_GET_FUN(__glewProgramUniform3ui64NV)\r\n#define glProgramUniform3ui64vNV GLEW_GET_FUN(__glewProgramUniform3ui64vNV)\r\n#define glProgramUniform4i64NV GLEW_GET_FUN(__glewProgramUniform4i64NV)\r\n#define glProgramUniform4i64vNV GLEW_GET_FUN(__glewProgramUniform4i64vNV)\r\n#define glProgramUniform4ui64NV GLEW_GET_FUN(__glewProgramUniform4ui64NV)\r\n#define glProgramUniform4ui64vNV GLEW_GET_FUN(__glewProgramUniform4ui64vNV)\r\n#define glUniform1i64NV GLEW_GET_FUN(__glewUniform1i64NV)\r\n#define glUniform1i64vNV GLEW_GET_FUN(__glewUniform1i64vNV)\r\n#define glUniform1ui64NV GLEW_GET_FUN(__glewUniform1ui64NV)\r\n#define glUniform1ui64vNV GLEW_GET_FUN(__glewUniform1ui64vNV)\r\n#define glUniform2i64NV GLEW_GET_FUN(__glewUniform2i64NV)\r\n#define glUniform2i64vNV GLEW_GET_FUN(__glewUniform2i64vNV)\r\n#define glUniform2ui64NV GLEW_GET_FUN(__glewUniform2ui64NV)\r\n#define glUniform2ui64vNV GLEW_GET_FUN(__glewUniform2ui64vNV)\r\n#define glUniform3i64NV GLEW_GET_FUN(__glewUniform3i64NV)\r\n#define glUniform3i64vNV GLEW_GET_FUN(__glewUniform3i64vNV)\r\n#define glUniform3ui64NV GLEW_GET_FUN(__glewUniform3ui64NV)\r\n#define glUniform3ui64vNV GLEW_GET_FUN(__glewUniform3ui64vNV)\r\n#define glUniform4i64NV GLEW_GET_FUN(__glewUniform4i64NV)\r\n#define glUniform4i64vNV GLEW_GET_FUN(__glewUniform4i64vNV)\r\n#define glUniform4ui64NV GLEW_GET_FUN(__glewUniform4ui64NV)\r\n#define glUniform4ui64vNV GLEW_GET_FUN(__glewUniform4ui64vNV)\r\n\r\n#define GLEW_NV_gpu_shader5 GLEW_GET_VAR(__GLEW_NV_gpu_shader5)\r\n\r\n#endif /* GL_NV_gpu_shader5 */\r\n\r\n/* ---------------------------- GL_NV_half_float --------------------------- */\r\n\r\n#ifndef GL_NV_half_float\r\n#define GL_NV_half_float 1\r\n\r\n#define GL_HALF_FLOAT_NV 0x140B\r\n\r\ntypedef unsigned short GLhalf;\r\n\r\ntypedef void (GLAPIENTRY * PFNGLCOLOR3HNVPROC) (GLhalf red, GLhalf green, GLhalf blue);\r\ntypedef void (GLAPIENTRY * PFNGLCOLOR3HVNVPROC) (const GLhalf* v);\r\ntypedef void (GLAPIENTRY * PFNGLCOLOR4HNVPROC) (GLhalf red, GLhalf green, GLhalf blue, GLhalf alpha);\r\ntypedef void (GLAPIENTRY * PFNGLCOLOR4HVNVPROC) (const GLhalf* v);\r\ntypedef void (GLAPIENTRY * PFNGLFOGCOORDHNVPROC) (GLhalf fog);\r\ntypedef void (GLAPIENTRY * PFNGLFOGCOORDHVNVPROC) (const GLhalf* fog);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1HNVPROC) (GLenum target, GLhalf s);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1HVNVPROC) (GLenum target, const GLhalf* v);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2HNVPROC) (GLenum target, GLhalf s, GLhalf t);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2HVNVPROC) (GLenum target, const GLhalf* v);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3HNVPROC) (GLenum target, GLhalf s, GLhalf t, GLhalf r);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3HVNVPROC) (GLenum target, const GLhalf* v);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4HNVPROC) (GLenum target, GLhalf s, GLhalf t, GLhalf r, GLhalf q);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4HVNVPROC) (GLenum target, const GLhalf* v);\r\ntypedef void (GLAPIENTRY * PFNGLNORMAL3HNVPROC) (GLhalf nx, GLhalf ny, GLhalf nz);\r\ntypedef void (GLAPIENTRY * PFNGLNORMAL3HVNVPROC) (const GLhalf* v);\r\ntypedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3HNVPROC) (GLhalf red, GLhalf green, GLhalf blue);\r\ntypedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3HVNVPROC) (const GLhalf* v);\r\ntypedef void (GLAPIENTRY * PFNGLTEXCOORD1HNVPROC) (GLhalf s);\r\ntypedef void (GLAPIENTRY * PFNGLTEXCOORD1HVNVPROC) (const GLhalf* v);\r\ntypedef void (GLAPIENTRY * PFNGLTEXCOORD2HNVPROC) (GLhalf s, GLhalf t);\r\ntypedef void (GLAPIENTRY * PFNGLTEXCOORD2HVNVPROC) (const GLhalf* v);\r\ntypedef void (GLAPIENTRY * PFNGLTEXCOORD3HNVPROC) (GLhalf s, GLhalf t, GLhalf r);\r\ntypedef void (GLAPIENTRY * PFNGLTEXCOORD3HVNVPROC) (const GLhalf* v);\r\ntypedef void (GLAPIENTRY * PFNGLTEXCOORD4HNVPROC) (GLhalf s, GLhalf t, GLhalf r, GLhalf q);\r\ntypedef void (GLAPIENTRY * PFNGLTEXCOORD4HVNVPROC) (const GLhalf* v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEX2HNVPROC) (GLhalf x, GLhalf y);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEX2HVNVPROC) (const GLhalf* v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEX3HNVPROC) (GLhalf x, GLhalf y, GLhalf z);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEX3HVNVPROC) (const GLhalf* v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEX4HNVPROC) (GLhalf x, GLhalf y, GLhalf z, GLhalf w);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEX4HVNVPROC) (const GLhalf* v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1HNVPROC) (GLuint index, GLhalf x);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1HVNVPROC) (GLuint index, const GLhalf* v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2HNVPROC) (GLuint index, GLhalf x, GLhalf y);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2HVNVPROC) (GLuint index, const GLhalf* v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3HNVPROC) (GLuint index, GLhalf x, GLhalf y, GLhalf z);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3HVNVPROC) (GLuint index, const GLhalf* v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4HNVPROC) (GLuint index, GLhalf x, GLhalf y, GLhalf z, GLhalf w);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4HVNVPROC) (GLuint index, const GLhalf* v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS1HVNVPROC) (GLuint index, GLsizei n, const GLhalf* v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS2HVNVPROC) (GLuint index, GLsizei n, const GLhalf* v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS3HVNVPROC) (GLuint index, GLsizei n, const GLhalf* v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS4HVNVPROC) (GLuint index, GLsizei n, const GLhalf* v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXWEIGHTHNVPROC) (GLhalf weight);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXWEIGHTHVNVPROC) (const GLhalf* weight);\r\n\r\n#define glColor3hNV GLEW_GET_FUN(__glewColor3hNV)\r\n#define glColor3hvNV GLEW_GET_FUN(__glewColor3hvNV)\r\n#define glColor4hNV GLEW_GET_FUN(__glewColor4hNV)\r\n#define glColor4hvNV GLEW_GET_FUN(__glewColor4hvNV)\r\n#define glFogCoordhNV GLEW_GET_FUN(__glewFogCoordhNV)\r\n#define glFogCoordhvNV GLEW_GET_FUN(__glewFogCoordhvNV)\r\n#define glMultiTexCoord1hNV GLEW_GET_FUN(__glewMultiTexCoord1hNV)\r\n#define glMultiTexCoord1hvNV GLEW_GET_FUN(__glewMultiTexCoord1hvNV)\r\n#define glMultiTexCoord2hNV GLEW_GET_FUN(__glewMultiTexCoord2hNV)\r\n#define glMultiTexCoord2hvNV GLEW_GET_FUN(__glewMultiTexCoord2hvNV)\r\n#define glMultiTexCoord3hNV GLEW_GET_FUN(__glewMultiTexCoord3hNV)\r\n#define glMultiTexCoord3hvNV GLEW_GET_FUN(__glewMultiTexCoord3hvNV)\r\n#define glMultiTexCoord4hNV GLEW_GET_FUN(__glewMultiTexCoord4hNV)\r\n#define glMultiTexCoord4hvNV GLEW_GET_FUN(__glewMultiTexCoord4hvNV)\r\n#define glNormal3hNV GLEW_GET_FUN(__glewNormal3hNV)\r\n#define glNormal3hvNV GLEW_GET_FUN(__glewNormal3hvNV)\r\n#define glSecondaryColor3hNV GLEW_GET_FUN(__glewSecondaryColor3hNV)\r\n#define glSecondaryColor3hvNV GLEW_GET_FUN(__glewSecondaryColor3hvNV)\r\n#define glTexCoord1hNV GLEW_GET_FUN(__glewTexCoord1hNV)\r\n#define glTexCoord1hvNV GLEW_GET_FUN(__glewTexCoord1hvNV)\r\n#define glTexCoord2hNV GLEW_GET_FUN(__glewTexCoord2hNV)\r\n#define glTexCoord2hvNV GLEW_GET_FUN(__glewTexCoord2hvNV)\r\n#define glTexCoord3hNV GLEW_GET_FUN(__glewTexCoord3hNV)\r\n#define glTexCoord3hvNV GLEW_GET_FUN(__glewTexCoord3hvNV)\r\n#define glTexCoord4hNV GLEW_GET_FUN(__glewTexCoord4hNV)\r\n#define glTexCoord4hvNV GLEW_GET_FUN(__glewTexCoord4hvNV)\r\n#define glVertex2hNV GLEW_GET_FUN(__glewVertex2hNV)\r\n#define glVertex2hvNV GLEW_GET_FUN(__glewVertex2hvNV)\r\n#define glVertex3hNV GLEW_GET_FUN(__glewVertex3hNV)\r\n#define glVertex3hvNV GLEW_GET_FUN(__glewVertex3hvNV)\r\n#define glVertex4hNV GLEW_GET_FUN(__glewVertex4hNV)\r\n#define glVertex4hvNV GLEW_GET_FUN(__glewVertex4hvNV)\r\n#define glVertexAttrib1hNV GLEW_GET_FUN(__glewVertexAttrib1hNV)\r\n#define glVertexAttrib1hvNV GLEW_GET_FUN(__glewVertexAttrib1hvNV)\r\n#define glVertexAttrib2hNV GLEW_GET_FUN(__glewVertexAttrib2hNV)\r\n#define glVertexAttrib2hvNV GLEW_GET_FUN(__glewVertexAttrib2hvNV)\r\n#define glVertexAttrib3hNV GLEW_GET_FUN(__glewVertexAttrib3hNV)\r\n#define glVertexAttrib3hvNV GLEW_GET_FUN(__glewVertexAttrib3hvNV)\r\n#define glVertexAttrib4hNV GLEW_GET_FUN(__glewVertexAttrib4hNV)\r\n#define glVertexAttrib4hvNV GLEW_GET_FUN(__glewVertexAttrib4hvNV)\r\n#define glVertexAttribs1hvNV GLEW_GET_FUN(__glewVertexAttribs1hvNV)\r\n#define glVertexAttribs2hvNV GLEW_GET_FUN(__glewVertexAttribs2hvNV)\r\n#define glVertexAttribs3hvNV GLEW_GET_FUN(__glewVertexAttribs3hvNV)\r\n#define glVertexAttribs4hvNV GLEW_GET_FUN(__glewVertexAttribs4hvNV)\r\n#define glVertexWeighthNV GLEW_GET_FUN(__glewVertexWeighthNV)\r\n#define glVertexWeighthvNV GLEW_GET_FUN(__glewVertexWeighthvNV)\r\n\r\n#define GLEW_NV_half_float GLEW_GET_VAR(__GLEW_NV_half_float)\r\n\r\n#endif /* GL_NV_half_float */\r\n\r\n/* ------------------- GL_NV_internalformat_sample_query ------------------- */\r\n\r\n#ifndef GL_NV_internalformat_sample_query\r\n#define GL_NV_internalformat_sample_query 1\r\n\r\n#define GL_MULTISAMPLES_NV 0x9371\r\n#define GL_SUPERSAMPLE_SCALE_X_NV 0x9372\r\n#define GL_SUPERSAMPLE_SCALE_Y_NV 0x9373\r\n#define GL_CONFORMANT_NV 0x9374\r\n\r\ntypedef void (GLAPIENTRY * PFNGLGETINTERNALFORMATSAMPLEIVNVPROC) (GLenum target, GLenum internalformat, GLsizei samples, GLenum pname, GLsizei bufSize, GLint* params);\r\n\r\n#define glGetInternalformatSampleivNV GLEW_GET_FUN(__glewGetInternalformatSampleivNV)\r\n\r\n#define GLEW_NV_internalformat_sample_query GLEW_GET_VAR(__GLEW_NV_internalformat_sample_query)\r\n\r\n#endif /* GL_NV_internalformat_sample_query */\r\n\r\n/* ------------------------ GL_NV_light_max_exponent ----------------------- */\r\n\r\n#ifndef GL_NV_light_max_exponent\r\n#define GL_NV_light_max_exponent 1\r\n\r\n#define GL_MAX_SHININESS_NV 0x8504\r\n#define GL_MAX_SPOT_EXPONENT_NV 0x8505\r\n\r\n#define GLEW_NV_light_max_exponent GLEW_GET_VAR(__GLEW_NV_light_max_exponent)\r\n\r\n#endif /* GL_NV_light_max_exponent */\r\n\r\n/* ----------------------- GL_NV_multisample_coverage ---------------------- */\r\n\r\n#ifndef GL_NV_multisample_coverage\r\n#define GL_NV_multisample_coverage 1\r\n\r\n#define GL_COLOR_SAMPLES_NV 0x8E20\r\n\r\n#define GLEW_NV_multisample_coverage GLEW_GET_VAR(__GLEW_NV_multisample_coverage)\r\n\r\n#endif /* GL_NV_multisample_coverage */\r\n\r\n/* --------------------- GL_NV_multisample_filter_hint --------------------- */\r\n\r\n#ifndef GL_NV_multisample_filter_hint\r\n#define GL_NV_multisample_filter_hint 1\r\n\r\n#define GL_MULTISAMPLE_FILTER_HINT_NV 0x8534\r\n\r\n#define GLEW_NV_multisample_filter_hint GLEW_GET_VAR(__GLEW_NV_multisample_filter_hint)\r\n\r\n#endif /* GL_NV_multisample_filter_hint */\r\n\r\n/* ------------------------- GL_NV_occlusion_query ------------------------- */\r\n\r\n#ifndef GL_NV_occlusion_query\r\n#define GL_NV_occlusion_query 1\r\n\r\n#define GL_PIXEL_COUNTER_BITS_NV 0x8864\r\n#define GL_CURRENT_OCCLUSION_QUERY_ID_NV 0x8865\r\n#define GL_PIXEL_COUNT_NV 0x8866\r\n#define GL_PIXEL_COUNT_AVAILABLE_NV 0x8867\r\n\r\ntypedef void (GLAPIENTRY * PFNGLBEGINOCCLUSIONQUERYNVPROC) (GLuint id);\r\ntypedef void (GLAPIENTRY * PFNGLDELETEOCCLUSIONQUERIESNVPROC) (GLsizei n, const GLuint* ids);\r\ntypedef void (GLAPIENTRY * PFNGLENDOCCLUSIONQUERYNVPROC) (void);\r\ntypedef void (GLAPIENTRY * PFNGLGENOCCLUSIONQUERIESNVPROC) (GLsizei n, GLuint* ids);\r\ntypedef void (GLAPIENTRY * PFNGLGETOCCLUSIONQUERYIVNVPROC) (GLuint id, GLenum pname, GLint* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETOCCLUSIONQUERYUIVNVPROC) (GLuint id, GLenum pname, GLuint* params);\r\ntypedef GLboolean (GLAPIENTRY * PFNGLISOCCLUSIONQUERYNVPROC) (GLuint id);\r\n\r\n#define glBeginOcclusionQueryNV GLEW_GET_FUN(__glewBeginOcclusionQueryNV)\r\n#define glDeleteOcclusionQueriesNV GLEW_GET_FUN(__glewDeleteOcclusionQueriesNV)\r\n#define glEndOcclusionQueryNV GLEW_GET_FUN(__glewEndOcclusionQueryNV)\r\n#define glGenOcclusionQueriesNV GLEW_GET_FUN(__glewGenOcclusionQueriesNV)\r\n#define glGetOcclusionQueryivNV GLEW_GET_FUN(__glewGetOcclusionQueryivNV)\r\n#define glGetOcclusionQueryuivNV GLEW_GET_FUN(__glewGetOcclusionQueryuivNV)\r\n#define glIsOcclusionQueryNV GLEW_GET_FUN(__glewIsOcclusionQueryNV)\r\n\r\n#define GLEW_NV_occlusion_query GLEW_GET_VAR(__GLEW_NV_occlusion_query)\r\n\r\n#endif /* GL_NV_occlusion_query */\r\n\r\n/* ----------------------- GL_NV_packed_depth_stencil ---------------------- */\r\n\r\n#ifndef GL_NV_packed_depth_stencil\r\n#define GL_NV_packed_depth_stencil 1\r\n\r\n#define GL_DEPTH_STENCIL_NV 0x84F9\r\n#define GL_UNSIGNED_INT_24_8_NV 0x84FA\r\n\r\n#define GLEW_NV_packed_depth_stencil GLEW_GET_VAR(__GLEW_NV_packed_depth_stencil)\r\n\r\n#endif /* GL_NV_packed_depth_stencil */\r\n\r\n/* --------------------- GL_NV_parameter_buffer_object --------------------- */\r\n\r\n#ifndef GL_NV_parameter_buffer_object\r\n#define GL_NV_parameter_buffer_object 1\r\n\r\n#define GL_MAX_PROGRAM_PARAMETER_BUFFER_BINDINGS_NV 0x8DA0\r\n#define GL_MAX_PROGRAM_PARAMETER_BUFFER_SIZE_NV 0x8DA1\r\n#define GL_VERTEX_PROGRAM_PARAMETER_BUFFER_NV 0x8DA2\r\n#define GL_GEOMETRY_PROGRAM_PARAMETER_BUFFER_NV 0x8DA3\r\n#define GL_FRAGMENT_PROGRAM_PARAMETER_BUFFER_NV 0x8DA4\r\n\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMBUFFERPARAMETERSIIVNVPROC) (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLint *params);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMBUFFERPARAMETERSIUIVNVPROC) (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLuint *params);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMBUFFERPARAMETERSFVNVPROC) (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLfloat *params);\r\n\r\n#define glProgramBufferParametersIivNV GLEW_GET_FUN(__glewProgramBufferParametersIivNV)\r\n#define glProgramBufferParametersIuivNV GLEW_GET_FUN(__glewProgramBufferParametersIuivNV)\r\n#define glProgramBufferParametersfvNV GLEW_GET_FUN(__glewProgramBufferParametersfvNV)\r\n\r\n#define GLEW_NV_parameter_buffer_object GLEW_GET_VAR(__GLEW_NV_parameter_buffer_object)\r\n\r\n#endif /* GL_NV_parameter_buffer_object */\r\n\r\n/* --------------------- GL_NV_parameter_buffer_object2 -------------------- */\r\n\r\n#ifndef GL_NV_parameter_buffer_object2\r\n#define GL_NV_parameter_buffer_object2 1\r\n\r\n#define GLEW_NV_parameter_buffer_object2 GLEW_GET_VAR(__GLEW_NV_parameter_buffer_object2)\r\n\r\n#endif /* GL_NV_parameter_buffer_object2 */\r\n\r\n/* -------------------------- GL_NV_path_rendering ------------------------- */\r\n\r\n#ifndef GL_NV_path_rendering\r\n#define GL_NV_path_rendering 1\r\n\r\n#define GL_CLOSE_PATH_NV 0x00\r\n#define GL_BOLD_BIT_NV 0x01\r\n#define GL_GLYPH_WIDTH_BIT_NV 0x01\r\n#define GL_GLYPH_HEIGHT_BIT_NV 0x02\r\n#define GL_ITALIC_BIT_NV 0x02\r\n#define GL_MOVE_TO_NV 0x02\r\n#define GL_RELATIVE_MOVE_TO_NV 0x03\r\n#define GL_GLYPH_HORIZONTAL_BEARING_X_BIT_NV 0x04\r\n#define GL_LINE_TO_NV 0x04\r\n#define GL_RELATIVE_LINE_TO_NV 0x05\r\n#define GL_HORIZONTAL_LINE_TO_NV 0x06\r\n#define GL_RELATIVE_HORIZONTAL_LINE_TO_NV 0x07\r\n#define GL_GLYPH_HORIZONTAL_BEARING_Y_BIT_NV 0x08\r\n#define GL_VERTICAL_LINE_TO_NV 0x08\r\n#define GL_RELATIVE_VERTICAL_LINE_TO_NV 0x09\r\n#define GL_QUADRATIC_CURVE_TO_NV 0x0A\r\n#define GL_RELATIVE_QUADRATIC_CURVE_TO_NV 0x0B\r\n#define GL_CUBIC_CURVE_TO_NV 0x0C\r\n#define GL_RELATIVE_CUBIC_CURVE_TO_NV 0x0D\r\n#define GL_SMOOTH_QUADRATIC_CURVE_TO_NV 0x0E\r\n#define GL_RELATIVE_SMOOTH_QUADRATIC_CURVE_TO_NV 0x0F\r\n#define GL_GLYPH_HORIZONTAL_BEARING_ADVANCE_BIT_NV 0x10\r\n#define GL_SMOOTH_CUBIC_CURVE_TO_NV 0x10\r\n#define GL_RELATIVE_SMOOTH_CUBIC_CURVE_TO_NV 0x11\r\n#define GL_SMALL_CCW_ARC_TO_NV 0x12\r\n#define GL_RELATIVE_SMALL_CCW_ARC_TO_NV 0x13\r\n#define GL_SMALL_CW_ARC_TO_NV 0x14\r\n#define GL_RELATIVE_SMALL_CW_ARC_TO_NV 0x15\r\n#define GL_LARGE_CCW_ARC_TO_NV 0x16\r\n#define GL_RELATIVE_LARGE_CCW_ARC_TO_NV 0x17\r\n#define GL_LARGE_CW_ARC_TO_NV 0x18\r\n#define GL_RELATIVE_LARGE_CW_ARC_TO_NV 0x19\r\n#define GL_CONIC_CURVE_TO_NV 0x1A\r\n#define GL_RELATIVE_CONIC_CURVE_TO_NV 0x1B\r\n#define GL_GLYPH_VERTICAL_BEARING_X_BIT_NV 0x20\r\n#define GL_GLYPH_VERTICAL_BEARING_Y_BIT_NV 0x40\r\n#define GL_GLYPH_VERTICAL_BEARING_ADVANCE_BIT_NV 0x80\r\n#define GL_ROUNDED_RECT_NV 0xE8\r\n#define GL_RELATIVE_ROUNDED_RECT_NV 0xE9\r\n#define GL_ROUNDED_RECT2_NV 0xEA\r\n#define GL_RELATIVE_ROUNDED_RECT2_NV 0xEB\r\n#define GL_ROUNDED_RECT4_NV 0xEC\r\n#define GL_RELATIVE_ROUNDED_RECT4_NV 0xED\r\n#define GL_ROUNDED_RECT8_NV 0xEE\r\n#define GL_RELATIVE_ROUNDED_RECT8_NV 0xEF\r\n#define GL_RESTART_PATH_NV 0xF0\r\n#define GL_DUP_FIRST_CUBIC_CURVE_TO_NV 0xF2\r\n#define GL_DUP_LAST_CUBIC_CURVE_TO_NV 0xF4\r\n#define GL_RECT_NV 0xF6\r\n#define GL_RELATIVE_RECT_NV 0xF7\r\n#define GL_CIRCULAR_CCW_ARC_TO_NV 0xF8\r\n#define GL_CIRCULAR_CW_ARC_TO_NV 0xFA\r\n#define GL_CIRCULAR_TANGENT_ARC_TO_NV 0xFC\r\n#define GL_ARC_TO_NV 0xFE\r\n#define GL_RELATIVE_ARC_TO_NV 0xFF\r\n#define GL_GLYPH_HAS_KERNING_BIT_NV 0x100\r\n#define GL_PRIMARY_COLOR_NV 0x852C\r\n#define GL_SECONDARY_COLOR_NV 0x852D\r\n#define GL_PRIMARY_COLOR 0x8577\r\n#define GL_PATH_FORMAT_SVG_NV 0x9070\r\n#define GL_PATH_FORMAT_PS_NV 0x9071\r\n#define GL_STANDARD_FONT_NAME_NV 0x9072\r\n#define GL_SYSTEM_FONT_NAME_NV 0x9073\r\n#define GL_FILE_NAME_NV 0x9074\r\n#define GL_PATH_STROKE_WIDTH_NV 0x9075\r\n#define GL_PATH_END_CAPS_NV 0x9076\r\n#define GL_PATH_INITIAL_END_CAP_NV 0x9077\r\n#define GL_PATH_TERMINAL_END_CAP_NV 0x9078\r\n#define GL_PATH_JOIN_STYLE_NV 0x9079\r\n#define GL_PATH_MITER_LIMIT_NV 0x907A\r\n#define GL_PATH_DASH_CAPS_NV 0x907B\r\n#define GL_PATH_INITIAL_DASH_CAP_NV 0x907C\r\n#define GL_PATH_TERMINAL_DASH_CAP_NV 0x907D\r\n#define GL_PATH_DASH_OFFSET_NV 0x907E\r\n#define GL_PATH_CLIENT_LENGTH_NV 0x907F\r\n#define GL_PATH_FILL_MODE_NV 0x9080\r\n#define GL_PATH_FILL_MASK_NV 0x9081\r\n#define GL_PATH_FILL_COVER_MODE_NV 0x9082\r\n#define GL_PATH_STROKE_COVER_MODE_NV 0x9083\r\n#define GL_PATH_STROKE_MASK_NV 0x9084\r\n#define GL_PATH_STROKE_BOUND_NV 0x9086\r\n#define GL_COUNT_UP_NV 0x9088\r\n#define GL_COUNT_DOWN_NV 0x9089\r\n#define GL_PATH_OBJECT_BOUNDING_BOX_NV 0x908A\r\n#define GL_CONVEX_HULL_NV 0x908B\r\n#define GL_BOUNDING_BOX_NV 0x908D\r\n#define GL_TRANSLATE_X_NV 0x908E\r\n#define GL_TRANSLATE_Y_NV 0x908F\r\n#define GL_TRANSLATE_2D_NV 0x9090\r\n#define GL_TRANSLATE_3D_NV 0x9091\r\n#define GL_AFFINE_2D_NV 0x9092\r\n#define GL_AFFINE_3D_NV 0x9094\r\n#define GL_TRANSPOSE_AFFINE_2D_NV 0x9096\r\n#define GL_TRANSPOSE_AFFINE_3D_NV 0x9098\r\n#define GL_UTF8_NV 0x909A\r\n#define GL_UTF16_NV 0x909B\r\n#define GL_BOUNDING_BOX_OF_BOUNDING_BOXES_NV 0x909C\r\n#define GL_PATH_COMMAND_COUNT_NV 0x909D\r\n#define GL_PATH_COORD_COUNT_NV 0x909E\r\n#define GL_PATH_DASH_ARRAY_COUNT_NV 0x909F\r\n#define GL_PATH_COMPUTED_LENGTH_NV 0x90A0\r\n#define GL_PATH_FILL_BOUNDING_BOX_NV 0x90A1\r\n#define GL_PATH_STROKE_BOUNDING_BOX_NV 0x90A2\r\n#define GL_SQUARE_NV 0x90A3\r\n#define GL_ROUND_NV 0x90A4\r\n#define GL_TRIANGULAR_NV 0x90A5\r\n#define GL_BEVEL_NV 0x90A6\r\n#define GL_MITER_REVERT_NV 0x90A7\r\n#define GL_MITER_TRUNCATE_NV 0x90A8\r\n#define GL_SKIP_MISSING_GLYPH_NV 0x90A9\r\n#define GL_USE_MISSING_GLYPH_NV 0x90AA\r\n#define GL_PATH_ERROR_POSITION_NV 0x90AB\r\n#define GL_PATH_FOG_GEN_MODE_NV 0x90AC\r\n#define GL_ACCUM_ADJACENT_PAIRS_NV 0x90AD\r\n#define GL_ADJACENT_PAIRS_NV 0x90AE\r\n#define GL_FIRST_TO_REST_NV 0x90AF\r\n#define GL_PATH_GEN_MODE_NV 0x90B0\r\n#define GL_PATH_GEN_COEFF_NV 0x90B1\r\n#define GL_PATH_GEN_COLOR_FORMAT_NV 0x90B2\r\n#define GL_PATH_GEN_COMPONENTS_NV 0x90B3\r\n#define GL_PATH_DASH_OFFSET_RESET_NV 0x90B4\r\n#define GL_MOVE_TO_RESETS_NV 0x90B5\r\n#define GL_MOVE_TO_CONTINUES_NV 0x90B6\r\n#define GL_PATH_STENCIL_FUNC_NV 0x90B7\r\n#define GL_PATH_STENCIL_REF_NV 0x90B8\r\n#define GL_PATH_STENCIL_VALUE_MASK_NV 0x90B9\r\n#define GL_PATH_STENCIL_DEPTH_OFFSET_FACTOR_NV 0x90BD\r\n#define GL_PATH_STENCIL_DEPTH_OFFSET_UNITS_NV 0x90BE\r\n#define GL_PATH_COVER_DEPTH_FUNC_NV 0x90BF\r\n#define GL_FONT_GLYPHS_AVAILABLE_NV 0x9368\r\n#define GL_FONT_TARGET_UNAVAILABLE_NV 0x9369\r\n#define GL_FONT_UNAVAILABLE_NV 0x936A\r\n#define GL_FONT_UNINTELLIGIBLE_NV 0x936B\r\n#define GL_STANDARD_FONT_FORMAT_NV 0x936C\r\n#define GL_FRAGMENT_INPUT_NV 0x936D\r\n#define GL_FONT_X_MIN_BOUNDS_BIT_NV 0x00010000\r\n#define GL_FONT_Y_MIN_BOUNDS_BIT_NV 0x00020000\r\n#define GL_FONT_X_MAX_BOUNDS_BIT_NV 0x00040000\r\n#define GL_FONT_Y_MAX_BOUNDS_BIT_NV 0x00080000\r\n#define GL_FONT_UNITS_PER_EM_BIT_NV 0x00100000\r\n#define GL_FONT_ASCENDER_BIT_NV 0x00200000\r\n#define GL_FONT_DESCENDER_BIT_NV 0x00400000\r\n#define GL_FONT_HEIGHT_BIT_NV 0x00800000\r\n#define GL_FONT_MAX_ADVANCE_WIDTH_BIT_NV 0x01000000\r\n#define GL_FONT_MAX_ADVANCE_HEIGHT_BIT_NV 0x02000000\r\n#define GL_FONT_UNDERLINE_POSITION_BIT_NV 0x04000000\r\n#define GL_FONT_UNDERLINE_THICKNESS_BIT_NV 0x08000000\r\n#define GL_FONT_HAS_KERNING_BIT_NV 0x10000000\r\n#define GL_FONT_NUM_GLYPH_INDICES_BIT_NV 0x20000000\r\n\r\ntypedef void (GLAPIENTRY * PFNGLCOPYPATHNVPROC) (GLuint resultPath, GLuint srcPath);\r\ntypedef void (GLAPIENTRY * PFNGLCOVERFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues);\r\ntypedef void (GLAPIENTRY * PFNGLCOVERFILLPATHNVPROC) (GLuint path, GLenum coverMode);\r\ntypedef void (GLAPIENTRY * PFNGLCOVERSTROKEPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues);\r\ntypedef void (GLAPIENTRY * PFNGLCOVERSTROKEPATHNVPROC) (GLuint path, GLenum coverMode);\r\ntypedef void (GLAPIENTRY * PFNGLDELETEPATHSNVPROC) (GLuint path, GLsizei range);\r\ntypedef GLuint (GLAPIENTRY * PFNGLGENPATHSNVPROC) (GLsizei range);\r\ntypedef void (GLAPIENTRY * PFNGLGETPATHCOLORGENFVNVPROC) (GLenum color, GLenum pname, GLfloat* value);\r\ntypedef void (GLAPIENTRY * PFNGLGETPATHCOLORGENIVNVPROC) (GLenum color, GLenum pname, GLint* value);\r\ntypedef void (GLAPIENTRY * PFNGLGETPATHCOMMANDSNVPROC) (GLuint path, GLubyte* commands);\r\ntypedef void (GLAPIENTRY * PFNGLGETPATHCOORDSNVPROC) (GLuint path, GLfloat* coords);\r\ntypedef void (GLAPIENTRY * PFNGLGETPATHDASHARRAYNVPROC) (GLuint path, GLfloat* dashArray);\r\ntypedef GLfloat (GLAPIENTRY * PFNGLGETPATHLENGTHNVPROC) (GLuint path, GLsizei startSegment, GLsizei numSegments);\r\ntypedef void (GLAPIENTRY * PFNGLGETPATHMETRICRANGENVPROC) (GLbitfield metricQueryMask, GLuint firstPathName, GLsizei numPaths, GLsizei stride, GLfloat* metrics);\r\ntypedef void (GLAPIENTRY * PFNGLGETPATHMETRICSNVPROC) (GLbitfield metricQueryMask, GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLsizei stride, GLfloat *metrics);\r\ntypedef void (GLAPIENTRY * PFNGLGETPATHPARAMETERFVNVPROC) (GLuint path, GLenum pname, GLfloat* value);\r\ntypedef void (GLAPIENTRY * PFNGLGETPATHPARAMETERIVNVPROC) (GLuint path, GLenum pname, GLint* value);\r\ntypedef void (GLAPIENTRY * PFNGLGETPATHSPACINGNVPROC) (GLenum pathListMode, GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLfloat advanceScale, GLfloat kerningScale, GLenum transformType, GLfloat *returnedSpacing);\r\ntypedef void (GLAPIENTRY * PFNGLGETPATHTEXGENFVNVPROC) (GLenum texCoordSet, GLenum pname, GLfloat* value);\r\ntypedef void (GLAPIENTRY * PFNGLGETPATHTEXGENIVNVPROC) (GLenum texCoordSet, GLenum pname, GLint* value);\r\ntypedef void (GLAPIENTRY * PFNGLGETPROGRAMRESOURCEFVNVPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum* props, GLsizei bufSize, GLsizei *length, GLfloat *params);\r\ntypedef void (GLAPIENTRY * PFNGLINTERPOLATEPATHSNVPROC) (GLuint resultPath, GLuint pathA, GLuint pathB, GLfloat weight);\r\ntypedef GLboolean (GLAPIENTRY * PFNGLISPATHNVPROC) (GLuint path);\r\ntypedef GLboolean (GLAPIENTRY * PFNGLISPOINTINFILLPATHNVPROC) (GLuint path, GLuint mask, GLfloat x, GLfloat y);\r\ntypedef GLboolean (GLAPIENTRY * PFNGLISPOINTINSTROKEPATHNVPROC) (GLuint path, GLfloat x, GLfloat y);\r\ntypedef void (GLAPIENTRY * PFNGLMATRIXLOAD3X2FNVPROC) (GLenum matrixMode, const GLfloat* m);\r\ntypedef void (GLAPIENTRY * PFNGLMATRIXLOAD3X3FNVPROC) (GLenum matrixMode, const GLfloat* m);\r\ntypedef void (GLAPIENTRY * PFNGLMATRIXLOADTRANSPOSE3X3FNVPROC) (GLenum matrixMode, const GLfloat* m);\r\ntypedef void (GLAPIENTRY * PFNGLMATRIXMULT3X2FNVPROC) (GLenum matrixMode, const GLfloat* m);\r\ntypedef void (GLAPIENTRY * PFNGLMATRIXMULT3X3FNVPROC) (GLenum matrixMode, const GLfloat* m);\r\ntypedef void (GLAPIENTRY * PFNGLMATRIXMULTTRANSPOSE3X3FNVPROC) (GLenum matrixMode, const GLfloat* m);\r\ntypedef void (GLAPIENTRY * PFNGLPATHCOLORGENNVPROC) (GLenum color, GLenum genMode, GLenum colorFormat, const GLfloat* coeffs);\r\ntypedef void (GLAPIENTRY * PFNGLPATHCOMMANDSNVPROC) (GLuint path, GLsizei numCommands, const GLubyte* commands, GLsizei numCoords, GLenum coordType, const void*coords);\r\ntypedef void (GLAPIENTRY * PFNGLPATHCOORDSNVPROC) (GLuint path, GLsizei numCoords, GLenum coordType, const void *coords);\r\ntypedef void (GLAPIENTRY * PFNGLPATHCOVERDEPTHFUNCNVPROC) (GLenum zfunc);\r\ntypedef void (GLAPIENTRY * PFNGLPATHDASHARRAYNVPROC) (GLuint path, GLsizei dashCount, const GLfloat* dashArray);\r\ntypedef void (GLAPIENTRY * PFNGLPATHFOGGENNVPROC) (GLenum genMode);\r\ntypedef GLenum (GLAPIENTRY * PFNGLPATHGLYPHINDEXARRAYNVPROC) (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint firstGlyphIndex, GLsizei numGlyphs, GLuint pathParameterTemplate, GLfloat emScale);\r\ntypedef GLenum (GLAPIENTRY * PFNGLPATHGLYPHINDEXRANGENVPROC) (GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint pathParameterTemplate, GLfloat emScale, GLuint baseAndCount[2]);\r\ntypedef void (GLAPIENTRY * PFNGLPATHGLYPHRANGENVPROC) (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint firstGlyph, GLsizei numGlyphs, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale);\r\ntypedef void (GLAPIENTRY * PFNGLPATHGLYPHSNVPROC) (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLsizei numGlyphs, GLenum type, const void*charcodes, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale);\r\ntypedef GLenum (GLAPIENTRY * PFNGLPATHMEMORYGLYPHINDEXARRAYNVPROC) (GLuint firstPathName, GLenum fontTarget, GLsizeiptr fontSize, const void *fontData, GLsizei faceIndex, GLuint firstGlyphIndex, GLsizei numGlyphs, GLuint pathParameterTemplate, GLfloat emScale);\r\ntypedef void (GLAPIENTRY * PFNGLPATHPARAMETERFNVPROC) (GLuint path, GLenum pname, GLfloat value);\r\ntypedef void (GLAPIENTRY * PFNGLPATHPARAMETERFVNVPROC) (GLuint path, GLenum pname, const GLfloat* value);\r\ntypedef void (GLAPIENTRY * PFNGLPATHPARAMETERINVPROC) (GLuint path, GLenum pname, GLint value);\r\ntypedef void (GLAPIENTRY * PFNGLPATHPARAMETERIVNVPROC) (GLuint path, GLenum pname, const GLint* value);\r\ntypedef void (GLAPIENTRY * PFNGLPATHSTENCILDEPTHOFFSETNVPROC) (GLfloat factor, GLfloat units);\r\ntypedef void (GLAPIENTRY * PFNGLPATHSTENCILFUNCNVPROC) (GLenum func, GLint ref, GLuint mask);\r\ntypedef void (GLAPIENTRY * PFNGLPATHSTRINGNVPROC) (GLuint path, GLenum format, GLsizei length, const void *pathString);\r\ntypedef void (GLAPIENTRY * PFNGLPATHSUBCOMMANDSNVPROC) (GLuint path, GLsizei commandStart, GLsizei commandsToDelete, GLsizei numCommands, const GLubyte* commands, GLsizei numCoords, GLenum coordType, const void*coords);\r\ntypedef void (GLAPIENTRY * PFNGLPATHSUBCOORDSNVPROC) (GLuint path, GLsizei coordStart, GLsizei numCoords, GLenum coordType, const void *coords);\r\ntypedef void (GLAPIENTRY * PFNGLPATHTEXGENNVPROC) (GLenum texCoordSet, GLenum genMode, GLint components, const GLfloat* coeffs);\r\ntypedef GLboolean (GLAPIENTRY * PFNGLPOINTALONGPATHNVPROC) (GLuint path, GLsizei startSegment, GLsizei numSegments, GLfloat distance, GLfloat* x, GLfloat *y, GLfloat *tangentX, GLfloat *tangentY);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMPATHFRAGMENTINPUTGENNVPROC) (GLuint program, GLint location, GLenum genMode, GLint components, const GLfloat* coeffs);\r\ntypedef void (GLAPIENTRY * PFNGLSTENCILFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum transformType, const GLfloat *transformValues);\r\ntypedef void (GLAPIENTRY * PFNGLSTENCILFILLPATHNVPROC) (GLuint path, GLenum fillMode, GLuint mask);\r\ntypedef void (GLAPIENTRY * PFNGLSTENCILSTROKEPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum transformType, const GLfloat *transformValues);\r\ntypedef void (GLAPIENTRY * PFNGLSTENCILSTROKEPATHNVPROC) (GLuint path, GLint reference, GLuint mask);\r\ntypedef void (GLAPIENTRY * PFNGLSTENCILTHENCOVERFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum coverMode, GLenum transformType, const GLfloat *transformValues);\r\ntypedef void (GLAPIENTRY * PFNGLSTENCILTHENCOVERFILLPATHNVPROC) (GLuint path, GLenum fillMode, GLuint mask, GLenum coverMode);\r\ntypedef void (GLAPIENTRY * PFNGLSTENCILTHENCOVERSTROKEPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum coverMode, GLenum transformType, const GLfloat *transformValues);\r\ntypedef void (GLAPIENTRY * PFNGLSTENCILTHENCOVERSTROKEPATHNVPROC) (GLuint path, GLint reference, GLuint mask, GLenum coverMode);\r\ntypedef void (GLAPIENTRY * PFNGLTRANSFORMPATHNVPROC) (GLuint resultPath, GLuint srcPath, GLenum transformType, const GLfloat* transformValues);\r\ntypedef void (GLAPIENTRY * PFNGLWEIGHTPATHSNVPROC) (GLuint resultPath, GLsizei numPaths, const GLuint paths[], const GLfloat weights[]);\r\n\r\n#define glCopyPathNV GLEW_GET_FUN(__glewCopyPathNV)\r\n#define glCoverFillPathInstancedNV GLEW_GET_FUN(__glewCoverFillPathInstancedNV)\r\n#define glCoverFillPathNV GLEW_GET_FUN(__glewCoverFillPathNV)\r\n#define glCoverStrokePathInstancedNV GLEW_GET_FUN(__glewCoverStrokePathInstancedNV)\r\n#define glCoverStrokePathNV GLEW_GET_FUN(__glewCoverStrokePathNV)\r\n#define glDeletePathsNV GLEW_GET_FUN(__glewDeletePathsNV)\r\n#define glGenPathsNV GLEW_GET_FUN(__glewGenPathsNV)\r\n#define glGetPathColorGenfvNV GLEW_GET_FUN(__glewGetPathColorGenfvNV)\r\n#define glGetPathColorGenivNV GLEW_GET_FUN(__glewGetPathColorGenivNV)\r\n#define glGetPathCommandsNV GLEW_GET_FUN(__glewGetPathCommandsNV)\r\n#define glGetPathCoordsNV GLEW_GET_FUN(__glewGetPathCoordsNV)\r\n#define glGetPathDashArrayNV GLEW_GET_FUN(__glewGetPathDashArrayNV)\r\n#define glGetPathLengthNV GLEW_GET_FUN(__glewGetPathLengthNV)\r\n#define glGetPathMetricRangeNV GLEW_GET_FUN(__glewGetPathMetricRangeNV)\r\n#define glGetPathMetricsNV GLEW_GET_FUN(__glewGetPathMetricsNV)\r\n#define glGetPathParameterfvNV GLEW_GET_FUN(__glewGetPathParameterfvNV)\r\n#define glGetPathParameterivNV GLEW_GET_FUN(__glewGetPathParameterivNV)\r\n#define glGetPathSpacingNV GLEW_GET_FUN(__glewGetPathSpacingNV)\r\n#define glGetPathTexGenfvNV GLEW_GET_FUN(__glewGetPathTexGenfvNV)\r\n#define glGetPathTexGenivNV GLEW_GET_FUN(__glewGetPathTexGenivNV)\r\n#define glGetProgramResourcefvNV GLEW_GET_FUN(__glewGetProgramResourcefvNV)\r\n#define glInterpolatePathsNV GLEW_GET_FUN(__glewInterpolatePathsNV)\r\n#define glIsPathNV GLEW_GET_FUN(__glewIsPathNV)\r\n#define glIsPointInFillPathNV GLEW_GET_FUN(__glewIsPointInFillPathNV)\r\n#define glIsPointInStrokePathNV GLEW_GET_FUN(__glewIsPointInStrokePathNV)\r\n#define glMatrixLoad3x2fNV GLEW_GET_FUN(__glewMatrixLoad3x2fNV)\r\n#define glMatrixLoad3x3fNV GLEW_GET_FUN(__glewMatrixLoad3x3fNV)\r\n#define glMatrixLoadTranspose3x3fNV GLEW_GET_FUN(__glewMatrixLoadTranspose3x3fNV)\r\n#define glMatrixMult3x2fNV GLEW_GET_FUN(__glewMatrixMult3x2fNV)\r\n#define glMatrixMult3x3fNV GLEW_GET_FUN(__glewMatrixMult3x3fNV)\r\n#define glMatrixMultTranspose3x3fNV GLEW_GET_FUN(__glewMatrixMultTranspose3x3fNV)\r\n#define glPathColorGenNV GLEW_GET_FUN(__glewPathColorGenNV)\r\n#define glPathCommandsNV GLEW_GET_FUN(__glewPathCommandsNV)\r\n#define glPathCoordsNV GLEW_GET_FUN(__glewPathCoordsNV)\r\n#define glPathCoverDepthFuncNV GLEW_GET_FUN(__glewPathCoverDepthFuncNV)\r\n#define glPathDashArrayNV GLEW_GET_FUN(__glewPathDashArrayNV)\r\n#define glPathFogGenNV GLEW_GET_FUN(__glewPathFogGenNV)\r\n#define glPathGlyphIndexArrayNV GLEW_GET_FUN(__glewPathGlyphIndexArrayNV)\r\n#define glPathGlyphIndexRangeNV GLEW_GET_FUN(__glewPathGlyphIndexRangeNV)\r\n#define glPathGlyphRangeNV GLEW_GET_FUN(__glewPathGlyphRangeNV)\r\n#define glPathGlyphsNV GLEW_GET_FUN(__glewPathGlyphsNV)\r\n#define glPathMemoryGlyphIndexArrayNV GLEW_GET_FUN(__glewPathMemoryGlyphIndexArrayNV)\r\n#define glPathParameterfNV GLEW_GET_FUN(__glewPathParameterfNV)\r\n#define glPathParameterfvNV GLEW_GET_FUN(__glewPathParameterfvNV)\r\n#define glPathParameteriNV GLEW_GET_FUN(__glewPathParameteriNV)\r\n#define glPathParameterivNV GLEW_GET_FUN(__glewPathParameterivNV)\r\n#define glPathStencilDepthOffsetNV GLEW_GET_FUN(__glewPathStencilDepthOffsetNV)\r\n#define glPathStencilFuncNV GLEW_GET_FUN(__glewPathStencilFuncNV)\r\n#define glPathStringNV GLEW_GET_FUN(__glewPathStringNV)\r\n#define glPathSubCommandsNV GLEW_GET_FUN(__glewPathSubCommandsNV)\r\n#define glPathSubCoordsNV GLEW_GET_FUN(__glewPathSubCoordsNV)\r\n#define glPathTexGenNV GLEW_GET_FUN(__glewPathTexGenNV)\r\n#define glPointAlongPathNV GLEW_GET_FUN(__glewPointAlongPathNV)\r\n#define glProgramPathFragmentInputGenNV GLEW_GET_FUN(__glewProgramPathFragmentInputGenNV)\r\n#define glStencilFillPathInstancedNV GLEW_GET_FUN(__glewStencilFillPathInstancedNV)\r\n#define glStencilFillPathNV GLEW_GET_FUN(__glewStencilFillPathNV)\r\n#define glStencilStrokePathInstancedNV GLEW_GET_FUN(__glewStencilStrokePathInstancedNV)\r\n#define glStencilStrokePathNV GLEW_GET_FUN(__glewStencilStrokePathNV)\r\n#define glStencilThenCoverFillPathInstancedNV GLEW_GET_FUN(__glewStencilThenCoverFillPathInstancedNV)\r\n#define glStencilThenCoverFillPathNV GLEW_GET_FUN(__glewStencilThenCoverFillPathNV)\r\n#define glStencilThenCoverStrokePathInstancedNV GLEW_GET_FUN(__glewStencilThenCoverStrokePathInstancedNV)\r\n#define glStencilThenCoverStrokePathNV GLEW_GET_FUN(__glewStencilThenCoverStrokePathNV)\r\n#define glTransformPathNV GLEW_GET_FUN(__glewTransformPathNV)\r\n#define glWeightPathsNV GLEW_GET_FUN(__glewWeightPathsNV)\r\n\r\n#define GLEW_NV_path_rendering GLEW_GET_VAR(__GLEW_NV_path_rendering)\r\n\r\n#endif /* GL_NV_path_rendering */\r\n\r\n/* -------------------- GL_NV_path_rendering_shared_edge ------------------- */\r\n\r\n#ifndef GL_NV_path_rendering_shared_edge\r\n#define GL_NV_path_rendering_shared_edge 1\r\n\r\n#define GL_SHARED_EDGE_NV 0xC0\r\n\r\n#define GLEW_NV_path_rendering_shared_edge GLEW_GET_VAR(__GLEW_NV_path_rendering_shared_edge)\r\n\r\n#endif /* GL_NV_path_rendering_shared_edge */\r\n\r\n/* ------------------------- GL_NV_pixel_data_range ------------------------ */\r\n\r\n#ifndef GL_NV_pixel_data_range\r\n#define GL_NV_pixel_data_range 1\r\n\r\n#define GL_WRITE_PIXEL_DATA_RANGE_NV 0x8878\r\n#define GL_READ_PIXEL_DATA_RANGE_NV 0x8879\r\n#define GL_WRITE_PIXEL_DATA_RANGE_LENGTH_NV 0x887A\r\n#define GL_READ_PIXEL_DATA_RANGE_LENGTH_NV 0x887B\r\n#define GL_WRITE_PIXEL_DATA_RANGE_POINTER_NV 0x887C\r\n#define GL_READ_PIXEL_DATA_RANGE_POINTER_NV 0x887D\r\n\r\ntypedef void (GLAPIENTRY * PFNGLFLUSHPIXELDATARANGENVPROC) (GLenum target);\r\ntypedef void (GLAPIENTRY * PFNGLPIXELDATARANGENVPROC) (GLenum target, GLsizei length, void *pointer);\r\n\r\n#define glFlushPixelDataRangeNV GLEW_GET_FUN(__glewFlushPixelDataRangeNV)\r\n#define glPixelDataRangeNV GLEW_GET_FUN(__glewPixelDataRangeNV)\r\n\r\n#define GLEW_NV_pixel_data_range GLEW_GET_VAR(__GLEW_NV_pixel_data_range)\r\n\r\n#endif /* GL_NV_pixel_data_range */\r\n\r\n/* --------------------------- GL_NV_point_sprite -------------------------- */\r\n\r\n#ifndef GL_NV_point_sprite\r\n#define GL_NV_point_sprite 1\r\n\r\n#define GL_POINT_SPRITE_NV 0x8861\r\n#define GL_COORD_REPLACE_NV 0x8862\r\n#define GL_POINT_SPRITE_R_MODE_NV 0x8863\r\n\r\ntypedef void (GLAPIENTRY * PFNGLPOINTPARAMETERINVPROC) (GLenum pname, GLint param);\r\ntypedef void (GLAPIENTRY * PFNGLPOINTPARAMETERIVNVPROC) (GLenum pname, const GLint* params);\r\n\r\n#define glPointParameteriNV GLEW_GET_FUN(__glewPointParameteriNV)\r\n#define glPointParameterivNV GLEW_GET_FUN(__glewPointParameterivNV)\r\n\r\n#define GLEW_NV_point_sprite GLEW_GET_VAR(__GLEW_NV_point_sprite)\r\n\r\n#endif /* GL_NV_point_sprite */\r\n\r\n/* -------------------------- GL_NV_present_video -------------------------- */\r\n\r\n#ifndef GL_NV_present_video\r\n#define GL_NV_present_video 1\r\n\r\n#define GL_FRAME_NV 0x8E26\r\n#define GL_FIELDS_NV 0x8E27\r\n#define GL_CURRENT_TIME_NV 0x8E28\r\n#define GL_NUM_FILL_STREAMS_NV 0x8E29\r\n#define GL_PRESENT_TIME_NV 0x8E2A\r\n#define GL_PRESENT_DURATION_NV 0x8E2B\r\n\r\ntypedef void (GLAPIENTRY * PFNGLGETVIDEOI64VNVPROC) (GLuint video_slot, GLenum pname, GLint64EXT* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETVIDEOIVNVPROC) (GLuint video_slot, GLenum pname, GLint* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETVIDEOUI64VNVPROC) (GLuint video_slot, GLenum pname, GLuint64EXT* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETVIDEOUIVNVPROC) (GLuint video_slot, GLenum pname, GLuint* params);\r\ntypedef void (GLAPIENTRY * PFNGLPRESENTFRAMEDUALFILLNVPROC) (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLenum target1, GLuint fill1, GLenum target2, GLuint fill2, GLenum target3, GLuint fill3);\r\ntypedef void (GLAPIENTRY * PFNGLPRESENTFRAMEKEYEDNVPROC) (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLuint key0, GLenum target1, GLuint fill1, GLuint key1);\r\n\r\n#define glGetVideoi64vNV GLEW_GET_FUN(__glewGetVideoi64vNV)\r\n#define glGetVideoivNV GLEW_GET_FUN(__glewGetVideoivNV)\r\n#define glGetVideoui64vNV GLEW_GET_FUN(__glewGetVideoui64vNV)\r\n#define glGetVideouivNV GLEW_GET_FUN(__glewGetVideouivNV)\r\n#define glPresentFrameDualFillNV GLEW_GET_FUN(__glewPresentFrameDualFillNV)\r\n#define glPresentFrameKeyedNV GLEW_GET_FUN(__glewPresentFrameKeyedNV)\r\n\r\n#define GLEW_NV_present_video GLEW_GET_VAR(__GLEW_NV_present_video)\r\n\r\n#endif /* GL_NV_present_video */\r\n\r\n/* ------------------------ GL_NV_primitive_restart ------------------------ */\r\n\r\n#ifndef GL_NV_primitive_restart\r\n#define GL_NV_primitive_restart 1\r\n\r\n#define GL_PRIMITIVE_RESTART_NV 0x8558\r\n#define GL_PRIMITIVE_RESTART_INDEX_NV 0x8559\r\n\r\ntypedef void (GLAPIENTRY * PFNGLPRIMITIVERESTARTINDEXNVPROC) (GLuint index);\r\ntypedef void (GLAPIENTRY * PFNGLPRIMITIVERESTARTNVPROC) (void);\r\n\r\n#define glPrimitiveRestartIndexNV GLEW_GET_FUN(__glewPrimitiveRestartIndexNV)\r\n#define glPrimitiveRestartNV GLEW_GET_FUN(__glewPrimitiveRestartNV)\r\n\r\n#define GLEW_NV_primitive_restart GLEW_GET_VAR(__GLEW_NV_primitive_restart)\r\n\r\n#endif /* GL_NV_primitive_restart */\r\n\r\n/* ------------------------ GL_NV_register_combiners ----------------------- */\r\n\r\n#ifndef GL_NV_register_combiners\r\n#define GL_NV_register_combiners 1\r\n\r\n#define GL_REGISTER_COMBINERS_NV 0x8522\r\n#define GL_VARIABLE_A_NV 0x8523\r\n#define GL_VARIABLE_B_NV 0x8524\r\n#define GL_VARIABLE_C_NV 0x8525\r\n#define GL_VARIABLE_D_NV 0x8526\r\n#define GL_VARIABLE_E_NV 0x8527\r\n#define GL_VARIABLE_F_NV 0x8528\r\n#define GL_VARIABLE_G_NV 0x8529\r\n#define GL_CONSTANT_COLOR0_NV 0x852A\r\n#define GL_CONSTANT_COLOR1_NV 0x852B\r\n#define GL_PRIMARY_COLOR_NV 0x852C\r\n#define GL_SECONDARY_COLOR_NV 0x852D\r\n#define GL_SPARE0_NV 0x852E\r\n#define GL_SPARE1_NV 0x852F\r\n#define GL_DISCARD_NV 0x8530\r\n#define GL_E_TIMES_F_NV 0x8531\r\n#define GL_SPARE0_PLUS_SECONDARY_COLOR_NV 0x8532\r\n#define GL_UNSIGNED_IDENTITY_NV 0x8536\r\n#define GL_UNSIGNED_INVERT_NV 0x8537\r\n#define GL_EXPAND_NORMAL_NV 0x8538\r\n#define GL_EXPAND_NEGATE_NV 0x8539\r\n#define GL_HALF_BIAS_NORMAL_NV 0x853A\r\n#define GL_HALF_BIAS_NEGATE_NV 0x853B\r\n#define GL_SIGNED_IDENTITY_NV 0x853C\r\n#define GL_SIGNED_NEGATE_NV 0x853D\r\n#define GL_SCALE_BY_TWO_NV 0x853E\r\n#define GL_SCALE_BY_FOUR_NV 0x853F\r\n#define GL_SCALE_BY_ONE_HALF_NV 0x8540\r\n#define GL_BIAS_BY_NEGATIVE_ONE_HALF_NV 0x8541\r\n#define GL_COMBINER_INPUT_NV 0x8542\r\n#define GL_COMBINER_MAPPING_NV 0x8543\r\n#define GL_COMBINER_COMPONENT_USAGE_NV 0x8544\r\n#define GL_COMBINER_AB_DOT_PRODUCT_NV 0x8545\r\n#define GL_COMBINER_CD_DOT_PRODUCT_NV 0x8546\r\n#define GL_COMBINER_MUX_SUM_NV 0x8547\r\n#define GL_COMBINER_SCALE_NV 0x8548\r\n#define GL_COMBINER_BIAS_NV 0x8549\r\n#define GL_COMBINER_AB_OUTPUT_NV 0x854A\r\n#define GL_COMBINER_CD_OUTPUT_NV 0x854B\r\n#define GL_COMBINER_SUM_OUTPUT_NV 0x854C\r\n#define GL_MAX_GENERAL_COMBINERS_NV 0x854D\r\n#define GL_NUM_GENERAL_COMBINERS_NV 0x854E\r\n#define GL_COLOR_SUM_CLAMP_NV 0x854F\r\n#define GL_COMBINER0_NV 0x8550\r\n#define GL_COMBINER1_NV 0x8551\r\n#define GL_COMBINER2_NV 0x8552\r\n#define GL_COMBINER3_NV 0x8553\r\n#define GL_COMBINER4_NV 0x8554\r\n#define GL_COMBINER5_NV 0x8555\r\n#define GL_COMBINER6_NV 0x8556\r\n#define GL_COMBINER7_NV 0x8557\r\n\r\ntypedef void (GLAPIENTRY * PFNGLCOMBINERINPUTNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage);\r\ntypedef void (GLAPIENTRY * PFNGLCOMBINEROUTPUTNVPROC) (GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum);\r\ntypedef void (GLAPIENTRY * PFNGLCOMBINERPARAMETERFNVPROC) (GLenum pname, GLfloat param);\r\ntypedef void (GLAPIENTRY * PFNGLCOMBINERPARAMETERFVNVPROC) (GLenum pname, const GLfloat* params);\r\ntypedef void (GLAPIENTRY * PFNGLCOMBINERPARAMETERINVPROC) (GLenum pname, GLint param);\r\ntypedef void (GLAPIENTRY * PFNGLCOMBINERPARAMETERIVNVPROC) (GLenum pname, const GLint* params);\r\ntypedef void (GLAPIENTRY * PFNGLFINALCOMBINERINPUTNVPROC) (GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage);\r\ntypedef void (GLAPIENTRY * PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLfloat* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLint* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC) (GLenum variable, GLenum pname, GLfloat* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC) (GLenum variable, GLenum pname, GLint* params);\r\n\r\n#define glCombinerInputNV GLEW_GET_FUN(__glewCombinerInputNV)\r\n#define glCombinerOutputNV GLEW_GET_FUN(__glewCombinerOutputNV)\r\n#define glCombinerParameterfNV GLEW_GET_FUN(__glewCombinerParameterfNV)\r\n#define glCombinerParameterfvNV GLEW_GET_FUN(__glewCombinerParameterfvNV)\r\n#define glCombinerParameteriNV GLEW_GET_FUN(__glewCombinerParameteriNV)\r\n#define glCombinerParameterivNV GLEW_GET_FUN(__glewCombinerParameterivNV)\r\n#define glFinalCombinerInputNV GLEW_GET_FUN(__glewFinalCombinerInputNV)\r\n#define glGetCombinerInputParameterfvNV GLEW_GET_FUN(__glewGetCombinerInputParameterfvNV)\r\n#define glGetCombinerInputParameterivNV GLEW_GET_FUN(__glewGetCombinerInputParameterivNV)\r\n#define glGetCombinerOutputParameterfvNV GLEW_GET_FUN(__glewGetCombinerOutputParameterfvNV)\r\n#define glGetCombinerOutputParameterivNV GLEW_GET_FUN(__glewGetCombinerOutputParameterivNV)\r\n#define glGetFinalCombinerInputParameterfvNV GLEW_GET_FUN(__glewGetFinalCombinerInputParameterfvNV)\r\n#define glGetFinalCombinerInputParameterivNV GLEW_GET_FUN(__glewGetFinalCombinerInputParameterivNV)\r\n\r\n#define GLEW_NV_register_combiners GLEW_GET_VAR(__GLEW_NV_register_combiners)\r\n\r\n#endif /* GL_NV_register_combiners */\r\n\r\n/* ----------------------- GL_NV_register_combiners2 ----------------------- */\r\n\r\n#ifndef GL_NV_register_combiners2\r\n#define GL_NV_register_combiners2 1\r\n\r\n#define GL_PER_STAGE_CONSTANTS_NV 0x8535\r\n\r\ntypedef void (GLAPIENTRY * PFNGLCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, const GLfloat* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, GLfloat* params);\r\n\r\n#define glCombinerStageParameterfvNV GLEW_GET_FUN(__glewCombinerStageParameterfvNV)\r\n#define glGetCombinerStageParameterfvNV GLEW_GET_FUN(__glewGetCombinerStageParameterfvNV)\r\n\r\n#define GLEW_NV_register_combiners2 GLEW_GET_VAR(__GLEW_NV_register_combiners2)\r\n\r\n#endif /* GL_NV_register_combiners2 */\r\n\r\n/* ------------------------- GL_NV_sample_locations ------------------------ */\r\n\r\n#ifndef GL_NV_sample_locations\r\n#define GL_NV_sample_locations 1\r\n\r\n#define GL_SAMPLE_LOCATION_NV 0x8E50\r\n#define GL_SAMPLE_LOCATION_SUBPIXEL_BITS_NV 0x933D\r\n#define GL_SAMPLE_LOCATION_PIXEL_GRID_WIDTH_NV 0x933E\r\n#define GL_SAMPLE_LOCATION_PIXEL_GRID_HEIGHT_NV 0x933F\r\n#define GL_PROGRAMMABLE_SAMPLE_LOCATION_TABLE_SIZE_NV 0x9340\r\n#define GL_PROGRAMMABLE_SAMPLE_LOCATION_NV 0x9341\r\n#define GL_FRAMEBUFFER_PROGRAMMABLE_SAMPLE_LOCATIONS_NV 0x9342\r\n#define GL_FRAMEBUFFER_SAMPLE_LOCATION_PIXEL_GRID_NV 0x9343\r\n\r\ntypedef void (GLAPIENTRY * PFNGLFRAMEBUFFERSAMPLELOCATIONSFVNVPROC) (GLenum target, GLuint start, GLsizei count, const GLfloat* v);\r\ntypedef void (GLAPIENTRY * PFNGLNAMEDFRAMEBUFFERSAMPLELOCATIONSFVNVPROC) (GLuint framebuffer, GLuint start, GLsizei count, const GLfloat* v);\r\n\r\n#define glFramebufferSampleLocationsfvNV GLEW_GET_FUN(__glewFramebufferSampleLocationsfvNV)\r\n#define glNamedFramebufferSampleLocationsfvNV GLEW_GET_FUN(__glewNamedFramebufferSampleLocationsfvNV)\r\n\r\n#define GLEW_NV_sample_locations GLEW_GET_VAR(__GLEW_NV_sample_locations)\r\n\r\n#endif /* GL_NV_sample_locations */\r\n\r\n/* ------------------ GL_NV_sample_mask_override_coverage ------------------ */\r\n\r\n#ifndef GL_NV_sample_mask_override_coverage\r\n#define GL_NV_sample_mask_override_coverage 1\r\n\r\n#define GLEW_NV_sample_mask_override_coverage GLEW_GET_VAR(__GLEW_NV_sample_mask_override_coverage)\r\n\r\n#endif /* GL_NV_sample_mask_override_coverage */\r\n\r\n/* ---------------------- GL_NV_shader_atomic_counters --------------------- */\r\n\r\n#ifndef GL_NV_shader_atomic_counters\r\n#define GL_NV_shader_atomic_counters 1\r\n\r\n#define GLEW_NV_shader_atomic_counters GLEW_GET_VAR(__GLEW_NV_shader_atomic_counters)\r\n\r\n#endif /* GL_NV_shader_atomic_counters */\r\n\r\n/* ----------------------- GL_NV_shader_atomic_float ----------------------- */\r\n\r\n#ifndef GL_NV_shader_atomic_float\r\n#define GL_NV_shader_atomic_float 1\r\n\r\n#define GLEW_NV_shader_atomic_float GLEW_GET_VAR(__GLEW_NV_shader_atomic_float)\r\n\r\n#endif /* GL_NV_shader_atomic_float */\r\n\r\n/* -------------------- GL_NV_shader_atomic_fp16_vector -------------------- */\r\n\r\n#ifndef GL_NV_shader_atomic_fp16_vector\r\n#define GL_NV_shader_atomic_fp16_vector 1\r\n\r\n#define GLEW_NV_shader_atomic_fp16_vector GLEW_GET_VAR(__GLEW_NV_shader_atomic_fp16_vector)\r\n\r\n#endif /* GL_NV_shader_atomic_fp16_vector */\r\n\r\n/* ----------------------- GL_NV_shader_atomic_int64 ----------------------- */\r\n\r\n#ifndef GL_NV_shader_atomic_int64\r\n#define GL_NV_shader_atomic_int64 1\r\n\r\n#define GLEW_NV_shader_atomic_int64 GLEW_GET_VAR(__GLEW_NV_shader_atomic_int64)\r\n\r\n#endif /* GL_NV_shader_atomic_int64 */\r\n\r\n/* ------------------------ GL_NV_shader_buffer_load ----------------------- */\r\n\r\n#ifndef GL_NV_shader_buffer_load\r\n#define GL_NV_shader_buffer_load 1\r\n\r\n#define GL_BUFFER_GPU_ADDRESS_NV 0x8F1D\r\n#define GL_GPU_ADDRESS_NV 0x8F34\r\n#define GL_MAX_SHADER_BUFFER_ADDRESS_NV 0x8F35\r\n\r\ntypedef void (GLAPIENTRY * PFNGLGETBUFFERPARAMETERUI64VNVPROC) (GLenum target, GLenum pname, GLuint64EXT* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETINTEGERUI64VNVPROC) (GLenum value, GLuint64EXT* result);\r\ntypedef void (GLAPIENTRY * PFNGLGETNAMEDBUFFERPARAMETERUI64VNVPROC) (GLuint buffer, GLenum pname, GLuint64EXT* params);\r\ntypedef GLboolean (GLAPIENTRY * PFNGLISBUFFERRESIDENTNVPROC) (GLenum target);\r\ntypedef GLboolean (GLAPIENTRY * PFNGLISNAMEDBUFFERRESIDENTNVPROC) (GLuint buffer);\r\ntypedef void (GLAPIENTRY * PFNGLMAKEBUFFERNONRESIDENTNVPROC) (GLenum target);\r\ntypedef void (GLAPIENTRY * PFNGLMAKEBUFFERRESIDENTNVPROC) (GLenum target, GLenum access);\r\ntypedef void (GLAPIENTRY * PFNGLMAKENAMEDBUFFERNONRESIDENTNVPROC) (GLuint buffer);\r\ntypedef void (GLAPIENTRY * PFNGLMAKENAMEDBUFFERRESIDENTNVPROC) (GLuint buffer, GLenum access);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMUI64NVPROC) (GLuint program, GLint location, GLuint64EXT value);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMUI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT* value);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORMUI64NVPROC) (GLint location, GLuint64EXT value);\r\ntypedef void (GLAPIENTRY * PFNGLUNIFORMUI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT* value);\r\n\r\n#define glGetBufferParameterui64vNV GLEW_GET_FUN(__glewGetBufferParameterui64vNV)\r\n#define glGetIntegerui64vNV GLEW_GET_FUN(__glewGetIntegerui64vNV)\r\n#define glGetNamedBufferParameterui64vNV GLEW_GET_FUN(__glewGetNamedBufferParameterui64vNV)\r\n#define glIsBufferResidentNV GLEW_GET_FUN(__glewIsBufferResidentNV)\r\n#define glIsNamedBufferResidentNV GLEW_GET_FUN(__glewIsNamedBufferResidentNV)\r\n#define glMakeBufferNonResidentNV GLEW_GET_FUN(__glewMakeBufferNonResidentNV)\r\n#define glMakeBufferResidentNV GLEW_GET_FUN(__glewMakeBufferResidentNV)\r\n#define glMakeNamedBufferNonResidentNV GLEW_GET_FUN(__glewMakeNamedBufferNonResidentNV)\r\n#define glMakeNamedBufferResidentNV GLEW_GET_FUN(__glewMakeNamedBufferResidentNV)\r\n#define glProgramUniformui64NV GLEW_GET_FUN(__glewProgramUniformui64NV)\r\n#define glProgramUniformui64vNV GLEW_GET_FUN(__glewProgramUniformui64vNV)\r\n#define glUniformui64NV GLEW_GET_FUN(__glewUniformui64NV)\r\n#define glUniformui64vNV GLEW_GET_FUN(__glewUniformui64vNV)\r\n\r\n#define GLEW_NV_shader_buffer_load GLEW_GET_VAR(__GLEW_NV_shader_buffer_load)\r\n\r\n#endif /* GL_NV_shader_buffer_load */\r\n\r\n/* ------------------- GL_NV_shader_storage_buffer_object ------------------ */\r\n\r\n#ifndef GL_NV_shader_storage_buffer_object\r\n#define GL_NV_shader_storage_buffer_object 1\r\n\r\n#define GLEW_NV_shader_storage_buffer_object GLEW_GET_VAR(__GLEW_NV_shader_storage_buffer_object)\r\n\r\n#endif /* GL_NV_shader_storage_buffer_object */\r\n\r\n/* ----------------------- GL_NV_shader_thread_group ----------------------- */\r\n\r\n#ifndef GL_NV_shader_thread_group\r\n#define GL_NV_shader_thread_group 1\r\n\r\n#define GL_WARP_SIZE_NV 0x9339\r\n#define GL_WARPS_PER_SM_NV 0x933A\r\n#define GL_SM_COUNT_NV 0x933B\r\n\r\n#define GLEW_NV_shader_thread_group GLEW_GET_VAR(__GLEW_NV_shader_thread_group)\r\n\r\n#endif /* GL_NV_shader_thread_group */\r\n\r\n/* ---------------------- GL_NV_shader_thread_shuffle ---------------------- */\r\n\r\n#ifndef GL_NV_shader_thread_shuffle\r\n#define GL_NV_shader_thread_shuffle 1\r\n\r\n#define GLEW_NV_shader_thread_shuffle GLEW_GET_VAR(__GLEW_NV_shader_thread_shuffle)\r\n\r\n#endif /* GL_NV_shader_thread_shuffle */\r\n\r\n/* ---------------------- GL_NV_tessellation_program5 ---------------------- */\r\n\r\n#ifndef GL_NV_tessellation_program5\r\n#define GL_NV_tessellation_program5 1\r\n\r\n#define GL_MAX_PROGRAM_PATCH_ATTRIBS_NV 0x86D8\r\n#define GL_TESS_CONTROL_PROGRAM_NV 0x891E\r\n#define GL_TESS_EVALUATION_PROGRAM_NV 0x891F\r\n#define GL_TESS_CONTROL_PROGRAM_PARAMETER_BUFFER_NV 0x8C74\r\n#define GL_TESS_EVALUATION_PROGRAM_PARAMETER_BUFFER_NV 0x8C75\r\n\r\n#define GLEW_NV_tessellation_program5 GLEW_GET_VAR(__GLEW_NV_tessellation_program5)\r\n\r\n#endif /* GL_NV_tessellation_program5 */\r\n\r\n/* -------------------------- GL_NV_texgen_emboss -------------------------- */\r\n\r\n#ifndef GL_NV_texgen_emboss\r\n#define GL_NV_texgen_emboss 1\r\n\r\n#define GL_EMBOSS_LIGHT_NV 0x855D\r\n#define GL_EMBOSS_CONSTANT_NV 0x855E\r\n#define GL_EMBOSS_MAP_NV 0x855F\r\n\r\n#define GLEW_NV_texgen_emboss GLEW_GET_VAR(__GLEW_NV_texgen_emboss)\r\n\r\n#endif /* GL_NV_texgen_emboss */\r\n\r\n/* ------------------------ GL_NV_texgen_reflection ------------------------ */\r\n\r\n#ifndef GL_NV_texgen_reflection\r\n#define GL_NV_texgen_reflection 1\r\n\r\n#define GL_NORMAL_MAP_NV 0x8511\r\n#define GL_REFLECTION_MAP_NV 0x8512\r\n\r\n#define GLEW_NV_texgen_reflection GLEW_GET_VAR(__GLEW_NV_texgen_reflection)\r\n\r\n#endif /* GL_NV_texgen_reflection */\r\n\r\n/* ------------------------- GL_NV_texture_barrier ------------------------- */\r\n\r\n#ifndef GL_NV_texture_barrier\r\n#define GL_NV_texture_barrier 1\r\n\r\ntypedef void (GLAPIENTRY * PFNGLTEXTUREBARRIERNVPROC) (void);\r\n\r\n#define glTextureBarrierNV GLEW_GET_FUN(__glewTextureBarrierNV)\r\n\r\n#define GLEW_NV_texture_barrier GLEW_GET_VAR(__GLEW_NV_texture_barrier)\r\n\r\n#endif /* GL_NV_texture_barrier */\r\n\r\n/* --------------------- GL_NV_texture_compression_vtc --------------------- */\r\n\r\n#ifndef GL_NV_texture_compression_vtc\r\n#define GL_NV_texture_compression_vtc 1\r\n\r\n#define GLEW_NV_texture_compression_vtc GLEW_GET_VAR(__GLEW_NV_texture_compression_vtc)\r\n\r\n#endif /* GL_NV_texture_compression_vtc */\r\n\r\n/* ----------------------- GL_NV_texture_env_combine4 ---------------------- */\r\n\r\n#ifndef GL_NV_texture_env_combine4\r\n#define GL_NV_texture_env_combine4 1\r\n\r\n#define GL_COMBINE4_NV 0x8503\r\n#define GL_SOURCE3_RGB_NV 0x8583\r\n#define GL_SOURCE3_ALPHA_NV 0x858B\r\n#define GL_OPERAND3_RGB_NV 0x8593\r\n#define GL_OPERAND3_ALPHA_NV 0x859B\r\n\r\n#define GLEW_NV_texture_env_combine4 GLEW_GET_VAR(__GLEW_NV_texture_env_combine4)\r\n\r\n#endif /* GL_NV_texture_env_combine4 */\r\n\r\n/* ---------------------- GL_NV_texture_expand_normal ---------------------- */\r\n\r\n#ifndef GL_NV_texture_expand_normal\r\n#define GL_NV_texture_expand_normal 1\r\n\r\n#define GL_TEXTURE_UNSIGNED_REMAP_MODE_NV 0x888F\r\n\r\n#define GLEW_NV_texture_expand_normal GLEW_GET_VAR(__GLEW_NV_texture_expand_normal)\r\n\r\n#endif /* GL_NV_texture_expand_normal */\r\n\r\n/* ----------------------- GL_NV_texture_multisample ----------------------- */\r\n\r\n#ifndef GL_NV_texture_multisample\r\n#define GL_NV_texture_multisample 1\r\n\r\n#define GL_TEXTURE_COVERAGE_SAMPLES_NV 0x9045\r\n#define GL_TEXTURE_COLOR_SAMPLES_NV 0x9046\r\n\r\ntypedef void (GLAPIENTRY * PFNGLTEXIMAGE2DMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations);\r\ntypedef void (GLAPIENTRY * PFNGLTEXIMAGE3DMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations);\r\ntypedef void (GLAPIENTRY * PFNGLTEXTUREIMAGE2DMULTISAMPLECOVERAGENVPROC) (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations);\r\ntypedef void (GLAPIENTRY * PFNGLTEXTUREIMAGE2DMULTISAMPLENVPROC) (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations);\r\ntypedef void (GLAPIENTRY * PFNGLTEXTUREIMAGE3DMULTISAMPLECOVERAGENVPROC) (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations);\r\ntypedef void (GLAPIENTRY * PFNGLTEXTUREIMAGE3DMULTISAMPLENVPROC) (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations);\r\n\r\n#define glTexImage2DMultisampleCoverageNV GLEW_GET_FUN(__glewTexImage2DMultisampleCoverageNV)\r\n#define glTexImage3DMultisampleCoverageNV GLEW_GET_FUN(__glewTexImage3DMultisampleCoverageNV)\r\n#define glTextureImage2DMultisampleCoverageNV GLEW_GET_FUN(__glewTextureImage2DMultisampleCoverageNV)\r\n#define glTextureImage2DMultisampleNV GLEW_GET_FUN(__glewTextureImage2DMultisampleNV)\r\n#define glTextureImage3DMultisampleCoverageNV GLEW_GET_FUN(__glewTextureImage3DMultisampleCoverageNV)\r\n#define glTextureImage3DMultisampleNV GLEW_GET_FUN(__glewTextureImage3DMultisampleNV)\r\n\r\n#define GLEW_NV_texture_multisample GLEW_GET_VAR(__GLEW_NV_texture_multisample)\r\n\r\n#endif /* GL_NV_texture_multisample */\r\n\r\n/* ------------------------ GL_NV_texture_rectangle ------------------------ */\r\n\r\n#ifndef GL_NV_texture_rectangle\r\n#define GL_NV_texture_rectangle 1\r\n\r\n#define GL_TEXTURE_RECTANGLE_NV 0x84F5\r\n#define GL_TEXTURE_BINDING_RECTANGLE_NV 0x84F6\r\n#define GL_PROXY_TEXTURE_RECTANGLE_NV 0x84F7\r\n#define GL_MAX_RECTANGLE_TEXTURE_SIZE_NV 0x84F8\r\n\r\n#define GLEW_NV_texture_rectangle GLEW_GET_VAR(__GLEW_NV_texture_rectangle)\r\n\r\n#endif /* GL_NV_texture_rectangle */\r\n\r\n/* -------------------------- GL_NV_texture_shader ------------------------- */\r\n\r\n#ifndef GL_NV_texture_shader\r\n#define GL_NV_texture_shader 1\r\n\r\n#define GL_OFFSET_TEXTURE_RECTANGLE_NV 0x864C\r\n#define GL_OFFSET_TEXTURE_RECTANGLE_SCALE_NV 0x864D\r\n#define GL_DOT_PRODUCT_TEXTURE_RECTANGLE_NV 0x864E\r\n#define GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV 0x86D9\r\n#define GL_UNSIGNED_INT_S8_S8_8_8_NV 0x86DA\r\n#define GL_UNSIGNED_INT_8_8_S8_S8_REV_NV 0x86DB\r\n#define GL_DSDT_MAG_INTENSITY_NV 0x86DC\r\n#define GL_SHADER_CONSISTENT_NV 0x86DD\r\n#define GL_TEXTURE_SHADER_NV 0x86DE\r\n#define GL_SHADER_OPERATION_NV 0x86DF\r\n#define GL_CULL_MODES_NV 0x86E0\r\n#define GL_OFFSET_TEXTURE_2D_MATRIX_NV 0x86E1\r\n#define GL_OFFSET_TEXTURE_MATRIX_NV 0x86E1\r\n#define GL_OFFSET_TEXTURE_2D_SCALE_NV 0x86E2\r\n#define GL_OFFSET_TEXTURE_SCALE_NV 0x86E2\r\n#define GL_OFFSET_TEXTURE_2D_BIAS_NV 0x86E3\r\n#define GL_OFFSET_TEXTURE_BIAS_NV 0x86E3\r\n#define GL_PREVIOUS_TEXTURE_INPUT_NV 0x86E4\r\n#define GL_CONST_EYE_NV 0x86E5\r\n#define GL_PASS_THROUGH_NV 0x86E6\r\n#define GL_CULL_FRAGMENT_NV 0x86E7\r\n#define GL_OFFSET_TEXTURE_2D_NV 0x86E8\r\n#define GL_DEPENDENT_AR_TEXTURE_2D_NV 0x86E9\r\n#define GL_DEPENDENT_GB_TEXTURE_2D_NV 0x86EA\r\n#define GL_DOT_PRODUCT_NV 0x86EC\r\n#define GL_DOT_PRODUCT_DEPTH_REPLACE_NV 0x86ED\r\n#define GL_DOT_PRODUCT_TEXTURE_2D_NV 0x86EE\r\n#define GL_DOT_PRODUCT_TEXTURE_CUBE_MAP_NV 0x86F0\r\n#define GL_DOT_PRODUCT_DIFFUSE_CUBE_MAP_NV 0x86F1\r\n#define GL_DOT_PRODUCT_REFLECT_CUBE_MAP_NV 0x86F2\r\n#define GL_DOT_PRODUCT_CONST_EYE_REFLECT_CUBE_MAP_NV 0x86F3\r\n#define GL_HILO_NV 0x86F4\r\n#define GL_DSDT_NV 0x86F5\r\n#define GL_DSDT_MAG_NV 0x86F6\r\n#define GL_DSDT_MAG_VIB_NV 0x86F7\r\n#define GL_HILO16_NV 0x86F8\r\n#define GL_SIGNED_HILO_NV 0x86F9\r\n#define GL_SIGNED_HILO16_NV 0x86FA\r\n#define GL_SIGNED_RGBA_NV 0x86FB\r\n#define GL_SIGNED_RGBA8_NV 0x86FC\r\n#define GL_SIGNED_RGB_NV 0x86FE\r\n#define GL_SIGNED_RGB8_NV 0x86FF\r\n#define GL_SIGNED_LUMINANCE_NV 0x8701\r\n#define GL_SIGNED_LUMINANCE8_NV 0x8702\r\n#define GL_SIGNED_LUMINANCE_ALPHA_NV 0x8703\r\n#define GL_SIGNED_LUMINANCE8_ALPHA8_NV 0x8704\r\n#define GL_SIGNED_ALPHA_NV 0x8705\r\n#define GL_SIGNED_ALPHA8_NV 0x8706\r\n#define GL_SIGNED_INTENSITY_NV 0x8707\r\n#define GL_SIGNED_INTENSITY8_NV 0x8708\r\n#define GL_DSDT8_NV 0x8709\r\n#define GL_DSDT8_MAG8_NV 0x870A\r\n#define GL_DSDT8_MAG8_INTENSITY8_NV 0x870B\r\n#define GL_SIGNED_RGB_UNSIGNED_ALPHA_NV 0x870C\r\n#define GL_SIGNED_RGB8_UNSIGNED_ALPHA8_NV 0x870D\r\n#define GL_HI_SCALE_NV 0x870E\r\n#define GL_LO_SCALE_NV 0x870F\r\n#define GL_DS_SCALE_NV 0x8710\r\n#define GL_DT_SCALE_NV 0x8711\r\n#define GL_MAGNITUDE_SCALE_NV 0x8712\r\n#define GL_VIBRANCE_SCALE_NV 0x8713\r\n#define GL_HI_BIAS_NV 0x8714\r\n#define GL_LO_BIAS_NV 0x8715\r\n#define GL_DS_BIAS_NV 0x8716\r\n#define GL_DT_BIAS_NV 0x8717\r\n#define GL_MAGNITUDE_BIAS_NV 0x8718\r\n#define GL_VIBRANCE_BIAS_NV 0x8719\r\n#define GL_TEXTURE_BORDER_VALUES_NV 0x871A\r\n#define GL_TEXTURE_HI_SIZE_NV 0x871B\r\n#define GL_TEXTURE_LO_SIZE_NV 0x871C\r\n#define GL_TEXTURE_DS_SIZE_NV 0x871D\r\n#define GL_TEXTURE_DT_SIZE_NV 0x871E\r\n#define GL_TEXTURE_MAG_SIZE_NV 0x871F\r\n\r\n#define GLEW_NV_texture_shader GLEW_GET_VAR(__GLEW_NV_texture_shader)\r\n\r\n#endif /* GL_NV_texture_shader */\r\n\r\n/* ------------------------- GL_NV_texture_shader2 ------------------------- */\r\n\r\n#ifndef GL_NV_texture_shader2\r\n#define GL_NV_texture_shader2 1\r\n\r\n#define GL_UNSIGNED_INT_S8_S8_8_8_NV 0x86DA\r\n#define GL_UNSIGNED_INT_8_8_S8_S8_REV_NV 0x86DB\r\n#define GL_DSDT_MAG_INTENSITY_NV 0x86DC\r\n#define GL_DOT_PRODUCT_TEXTURE_3D_NV 0x86EF\r\n#define GL_HILO_NV 0x86F4\r\n#define GL_DSDT_NV 0x86F5\r\n#define GL_DSDT_MAG_NV 0x86F6\r\n#define GL_DSDT_MAG_VIB_NV 0x86F7\r\n#define GL_HILO16_NV 0x86F8\r\n#define GL_SIGNED_HILO_NV 0x86F9\r\n#define GL_SIGNED_HILO16_NV 0x86FA\r\n#define GL_SIGNED_RGBA_NV 0x86FB\r\n#define GL_SIGNED_RGBA8_NV 0x86FC\r\n#define GL_SIGNED_RGB_NV 0x86FE\r\n#define GL_SIGNED_RGB8_NV 0x86FF\r\n#define GL_SIGNED_LUMINANCE_NV 0x8701\r\n#define GL_SIGNED_LUMINANCE8_NV 0x8702\r\n#define GL_SIGNED_LUMINANCE_ALPHA_NV 0x8703\r\n#define GL_SIGNED_LUMINANCE8_ALPHA8_NV 0x8704\r\n#define GL_SIGNED_ALPHA_NV 0x8705\r\n#define GL_SIGNED_ALPHA8_NV 0x8706\r\n#define GL_SIGNED_INTENSITY_NV 0x8707\r\n#define GL_SIGNED_INTENSITY8_NV 0x8708\r\n#define GL_DSDT8_NV 0x8709\r\n#define GL_DSDT8_MAG8_NV 0x870A\r\n#define GL_DSDT8_MAG8_INTENSITY8_NV 0x870B\r\n#define GL_SIGNED_RGB_UNSIGNED_ALPHA_NV 0x870C\r\n#define GL_SIGNED_RGB8_UNSIGNED_ALPHA8_NV 0x870D\r\n\r\n#define GLEW_NV_texture_shader2 GLEW_GET_VAR(__GLEW_NV_texture_shader2)\r\n\r\n#endif /* GL_NV_texture_shader2 */\r\n\r\n/* ------------------------- GL_NV_texture_shader3 ------------------------- */\r\n\r\n#ifndef GL_NV_texture_shader3\r\n#define GL_NV_texture_shader3 1\r\n\r\n#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_NV 0x8850\r\n#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_SCALE_NV 0x8851\r\n#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8852\r\n#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_SCALE_NV 0x8853\r\n#define GL_OFFSET_HILO_TEXTURE_2D_NV 0x8854\r\n#define GL_OFFSET_HILO_TEXTURE_RECTANGLE_NV 0x8855\r\n#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_2D_NV 0x8856\r\n#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8857\r\n#define GL_DEPENDENT_HILO_TEXTURE_2D_NV 0x8858\r\n#define GL_DEPENDENT_RGB_TEXTURE_3D_NV 0x8859\r\n#define GL_DEPENDENT_RGB_TEXTURE_CUBE_MAP_NV 0x885A\r\n#define GL_DOT_PRODUCT_PASS_THROUGH_NV 0x885B\r\n#define GL_DOT_PRODUCT_TEXTURE_1D_NV 0x885C\r\n#define GL_DOT_PRODUCT_AFFINE_DEPTH_REPLACE_NV 0x885D\r\n#define GL_HILO8_NV 0x885E\r\n#define GL_SIGNED_HILO8_NV 0x885F\r\n#define GL_FORCE_BLUE_TO_ONE_NV 0x8860\r\n\r\n#define GLEW_NV_texture_shader3 GLEW_GET_VAR(__GLEW_NV_texture_shader3)\r\n\r\n#endif /* GL_NV_texture_shader3 */\r\n\r\n/* ------------------------ GL_NV_transform_feedback ----------------------- */\r\n\r\n#ifndef GL_NV_transform_feedback\r\n#define GL_NV_transform_feedback 1\r\n\r\n#define GL_BACK_PRIMARY_COLOR_NV 0x8C77\r\n#define GL_BACK_SECONDARY_COLOR_NV 0x8C78\r\n#define GL_TEXTURE_COORD_NV 0x8C79\r\n#define GL_CLIP_DISTANCE_NV 0x8C7A\r\n#define GL_VERTEX_ID_NV 0x8C7B\r\n#define GL_PRIMITIVE_ID_NV 0x8C7C\r\n#define GL_GENERIC_ATTRIB_NV 0x8C7D\r\n#define GL_TRANSFORM_FEEDBACK_ATTRIBS_NV 0x8C7E\r\n#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE_NV 0x8C7F\r\n#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_NV 0x8C80\r\n#define GL_ACTIVE_VARYINGS_NV 0x8C81\r\n#define GL_ACTIVE_VARYING_MAX_LENGTH_NV 0x8C82\r\n#define GL_TRANSFORM_FEEDBACK_VARYINGS_NV 0x8C83\r\n#define GL_TRANSFORM_FEEDBACK_BUFFER_START_NV 0x8C84\r\n#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_NV 0x8C85\r\n#define GL_TRANSFORM_FEEDBACK_RECORD_NV 0x8C86\r\n#define GL_PRIMITIVES_GENERATED_NV 0x8C87\r\n#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_NV 0x8C88\r\n#define GL_RASTERIZER_DISCARD_NV 0x8C89\r\n#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_NV 0x8C8A\r\n#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_NV 0x8C8B\r\n#define GL_INTERLEAVED_ATTRIBS_NV 0x8C8C\r\n#define GL_SEPARATE_ATTRIBS_NV 0x8C8D\r\n#define GL_TRANSFORM_FEEDBACK_BUFFER_NV 0x8C8E\r\n#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_NV 0x8C8F\r\n\r\ntypedef void (GLAPIENTRY * PFNGLACTIVEVARYINGNVPROC) (GLuint program, const GLchar *name);\r\ntypedef void (GLAPIENTRY * PFNGLBEGINTRANSFORMFEEDBACKNVPROC) (GLenum primitiveMode);\r\ntypedef void (GLAPIENTRY * PFNGLBINDBUFFERBASENVPROC) (GLenum target, GLuint index, GLuint buffer);\r\ntypedef void (GLAPIENTRY * PFNGLBINDBUFFEROFFSETNVPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset);\r\ntypedef void (GLAPIENTRY * PFNGLBINDBUFFERRANGENVPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size);\r\ntypedef void (GLAPIENTRY * PFNGLENDTRANSFORMFEEDBACKNVPROC) (void);\r\ntypedef void (GLAPIENTRY * PFNGLGETACTIVEVARYINGNVPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name);\r\ntypedef void (GLAPIENTRY * PFNGLGETTRANSFORMFEEDBACKVARYINGNVPROC) (GLuint program, GLuint index, GLint *location);\r\ntypedef GLint (GLAPIENTRY * PFNGLGETVARYINGLOCATIONNVPROC) (GLuint program, const GLchar *name);\r\ntypedef void (GLAPIENTRY * PFNGLTRANSFORMFEEDBACKATTRIBSNVPROC) (GLuint count, const GLint *attribs, GLenum bufferMode);\r\ntypedef void (GLAPIENTRY * PFNGLTRANSFORMFEEDBACKVARYINGSNVPROC) (GLuint program, GLsizei count, const GLint *locations, GLenum bufferMode);\r\n\r\n#define glActiveVaryingNV GLEW_GET_FUN(__glewActiveVaryingNV)\r\n#define glBeginTransformFeedbackNV GLEW_GET_FUN(__glewBeginTransformFeedbackNV)\r\n#define glBindBufferBaseNV GLEW_GET_FUN(__glewBindBufferBaseNV)\r\n#define glBindBufferOffsetNV GLEW_GET_FUN(__glewBindBufferOffsetNV)\r\n#define glBindBufferRangeNV GLEW_GET_FUN(__glewBindBufferRangeNV)\r\n#define glEndTransformFeedbackNV GLEW_GET_FUN(__glewEndTransformFeedbackNV)\r\n#define glGetActiveVaryingNV GLEW_GET_FUN(__glewGetActiveVaryingNV)\r\n#define glGetTransformFeedbackVaryingNV GLEW_GET_FUN(__glewGetTransformFeedbackVaryingNV)\r\n#define glGetVaryingLocationNV GLEW_GET_FUN(__glewGetVaryingLocationNV)\r\n#define glTransformFeedbackAttribsNV GLEW_GET_FUN(__glewTransformFeedbackAttribsNV)\r\n#define glTransformFeedbackVaryingsNV GLEW_GET_FUN(__glewTransformFeedbackVaryingsNV)\r\n\r\n#define GLEW_NV_transform_feedback GLEW_GET_VAR(__GLEW_NV_transform_feedback)\r\n\r\n#endif /* GL_NV_transform_feedback */\r\n\r\n/* ----------------------- GL_NV_transform_feedback2 ----------------------- */\r\n\r\n#ifndef GL_NV_transform_feedback2\r\n#define GL_NV_transform_feedback2 1\r\n\r\n#define GL_TRANSFORM_FEEDBACK_NV 0x8E22\r\n#define GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED_NV 0x8E23\r\n#define GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE_NV 0x8E24\r\n#define GL_TRANSFORM_FEEDBACK_BINDING_NV 0x8E25\r\n\r\ntypedef void (GLAPIENTRY * PFNGLBINDTRANSFORMFEEDBACKNVPROC) (GLenum target, GLuint id);\r\ntypedef void (GLAPIENTRY * PFNGLDELETETRANSFORMFEEDBACKSNVPROC) (GLsizei n, const GLuint* ids);\r\ntypedef void (GLAPIENTRY * PFNGLDRAWTRANSFORMFEEDBACKNVPROC) (GLenum mode, GLuint id);\r\ntypedef void (GLAPIENTRY * PFNGLGENTRANSFORMFEEDBACKSNVPROC) (GLsizei n, GLuint* ids);\r\ntypedef GLboolean (GLAPIENTRY * PFNGLISTRANSFORMFEEDBACKNVPROC) (GLuint id);\r\ntypedef void (GLAPIENTRY * PFNGLPAUSETRANSFORMFEEDBACKNVPROC) (void);\r\ntypedef void (GLAPIENTRY * PFNGLRESUMETRANSFORMFEEDBACKNVPROC) (void);\r\n\r\n#define glBindTransformFeedbackNV GLEW_GET_FUN(__glewBindTransformFeedbackNV)\r\n#define glDeleteTransformFeedbacksNV GLEW_GET_FUN(__glewDeleteTransformFeedbacksNV)\r\n#define glDrawTransformFeedbackNV GLEW_GET_FUN(__glewDrawTransformFeedbackNV)\r\n#define glGenTransformFeedbacksNV GLEW_GET_FUN(__glewGenTransformFeedbacksNV)\r\n#define glIsTransformFeedbackNV GLEW_GET_FUN(__glewIsTransformFeedbackNV)\r\n#define glPauseTransformFeedbackNV GLEW_GET_FUN(__glewPauseTransformFeedbackNV)\r\n#define glResumeTransformFeedbackNV GLEW_GET_FUN(__glewResumeTransformFeedbackNV)\r\n\r\n#define GLEW_NV_transform_feedback2 GLEW_GET_VAR(__GLEW_NV_transform_feedback2)\r\n\r\n#endif /* GL_NV_transform_feedback2 */\r\n\r\n/* ------------------ GL_NV_uniform_buffer_unified_memory ------------------ */\r\n\r\n#ifndef GL_NV_uniform_buffer_unified_memory\r\n#define GL_NV_uniform_buffer_unified_memory 1\r\n\r\n#define GL_UNIFORM_BUFFER_UNIFIED_NV 0x936E\r\n#define GL_UNIFORM_BUFFER_ADDRESS_NV 0x936F\r\n#define GL_UNIFORM_BUFFER_LENGTH_NV 0x9370\r\n\r\n#define GLEW_NV_uniform_buffer_unified_memory GLEW_GET_VAR(__GLEW_NV_uniform_buffer_unified_memory)\r\n\r\n#endif /* GL_NV_uniform_buffer_unified_memory */\r\n\r\n/* -------------------------- GL_NV_vdpau_interop -------------------------- */\r\n\r\n#ifndef GL_NV_vdpau_interop\r\n#define GL_NV_vdpau_interop 1\r\n\r\n#define GL_SURFACE_STATE_NV 0x86EB\r\n#define GL_SURFACE_REGISTERED_NV 0x86FD\r\n#define GL_SURFACE_MAPPED_NV 0x8700\r\n#define GL_WRITE_DISCARD_NV 0x88BE\r\n\r\ntypedef GLintptr GLvdpauSurfaceNV;\r\n\r\ntypedef void (GLAPIENTRY * PFNGLVDPAUFININVPROC) (void);\r\ntypedef void (GLAPIENTRY * PFNGLVDPAUGETSURFACEIVNVPROC) (GLvdpauSurfaceNV surface, GLenum pname, GLsizei bufSize, GLsizei* length, GLint *values);\r\ntypedef void (GLAPIENTRY * PFNGLVDPAUINITNVPROC) (const void* vdpDevice, const void*getProcAddress);\r\ntypedef void (GLAPIENTRY * PFNGLVDPAUISSURFACENVPROC) (GLvdpauSurfaceNV surface);\r\ntypedef void (GLAPIENTRY * PFNGLVDPAUMAPSURFACESNVPROC) (GLsizei numSurfaces, const GLvdpauSurfaceNV* surfaces);\r\ntypedef GLvdpauSurfaceNV (GLAPIENTRY * PFNGLVDPAUREGISTEROUTPUTSURFACENVPROC) (const void* vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames);\r\ntypedef GLvdpauSurfaceNV (GLAPIENTRY * PFNGLVDPAUREGISTERVIDEOSURFACENVPROC) (const void* vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames);\r\ntypedef void (GLAPIENTRY * PFNGLVDPAUSURFACEACCESSNVPROC) (GLvdpauSurfaceNV surface, GLenum access);\r\ntypedef void (GLAPIENTRY * PFNGLVDPAUUNMAPSURFACESNVPROC) (GLsizei numSurface, const GLvdpauSurfaceNV* surfaces);\r\ntypedef void (GLAPIENTRY * PFNGLVDPAUUNREGISTERSURFACENVPROC) (GLvdpauSurfaceNV surface);\r\n\r\n#define glVDPAUFiniNV GLEW_GET_FUN(__glewVDPAUFiniNV)\r\n#define glVDPAUGetSurfaceivNV GLEW_GET_FUN(__glewVDPAUGetSurfaceivNV)\r\n#define glVDPAUInitNV GLEW_GET_FUN(__glewVDPAUInitNV)\r\n#define glVDPAUIsSurfaceNV GLEW_GET_FUN(__glewVDPAUIsSurfaceNV)\r\n#define glVDPAUMapSurfacesNV GLEW_GET_FUN(__glewVDPAUMapSurfacesNV)\r\n#define glVDPAURegisterOutputSurfaceNV GLEW_GET_FUN(__glewVDPAURegisterOutputSurfaceNV)\r\n#define glVDPAURegisterVideoSurfaceNV GLEW_GET_FUN(__glewVDPAURegisterVideoSurfaceNV)\r\n#define glVDPAUSurfaceAccessNV GLEW_GET_FUN(__glewVDPAUSurfaceAccessNV)\r\n#define glVDPAUUnmapSurfacesNV GLEW_GET_FUN(__glewVDPAUUnmapSurfacesNV)\r\n#define glVDPAUUnregisterSurfaceNV GLEW_GET_FUN(__glewVDPAUUnregisterSurfaceNV)\r\n\r\n#define GLEW_NV_vdpau_interop GLEW_GET_VAR(__GLEW_NV_vdpau_interop)\r\n\r\n#endif /* GL_NV_vdpau_interop */\r\n\r\n/* ------------------------ GL_NV_vertex_array_range ----------------------- */\r\n\r\n#ifndef GL_NV_vertex_array_range\r\n#define GL_NV_vertex_array_range 1\r\n\r\n#define GL_VERTEX_ARRAY_RANGE_NV 0x851D\r\n#define GL_VERTEX_ARRAY_RANGE_LENGTH_NV 0x851E\r\n#define GL_VERTEX_ARRAY_RANGE_VALID_NV 0x851F\r\n#define GL_MAX_VERTEX_ARRAY_RANGE_ELEMENT_NV 0x8520\r\n#define GL_VERTEX_ARRAY_RANGE_POINTER_NV 0x8521\r\n\r\ntypedef void (GLAPIENTRY * PFNGLFLUSHVERTEXARRAYRANGENVPROC) (void);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXARRAYRANGENVPROC) (GLsizei length, void *pointer);\r\n\r\n#define glFlushVertexArrayRangeNV GLEW_GET_FUN(__glewFlushVertexArrayRangeNV)\r\n#define glVertexArrayRangeNV GLEW_GET_FUN(__glewVertexArrayRangeNV)\r\n\r\n#define GLEW_NV_vertex_array_range GLEW_GET_VAR(__GLEW_NV_vertex_array_range)\r\n\r\n#endif /* GL_NV_vertex_array_range */\r\n\r\n/* ----------------------- GL_NV_vertex_array_range2 ----------------------- */\r\n\r\n#ifndef GL_NV_vertex_array_range2\r\n#define GL_NV_vertex_array_range2 1\r\n\r\n#define GL_VERTEX_ARRAY_RANGE_WITHOUT_FLUSH_NV 0x8533\r\n\r\n#define GLEW_NV_vertex_array_range2 GLEW_GET_VAR(__GLEW_NV_vertex_array_range2)\r\n\r\n#endif /* GL_NV_vertex_array_range2 */\r\n\r\n/* ------------------- GL_NV_vertex_attrib_integer_64bit ------------------- */\r\n\r\n#ifndef GL_NV_vertex_attrib_integer_64bit\r\n#define GL_NV_vertex_attrib_integer_64bit 1\r\n\r\n#define GL_INT64_NV 0x140E\r\n#define GL_UNSIGNED_INT64_NV 0x140F\r\n\r\ntypedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBLI64VNVPROC) (GLuint index, GLenum pname, GLint64EXT* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBLUI64VNVPROC) (GLuint index, GLenum pname, GLuint64EXT* params);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL1I64NVPROC) (GLuint index, GLint64EXT x);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL1I64VNVPROC) (GLuint index, const GLint64EXT* v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL1UI64NVPROC) (GLuint index, GLuint64EXT x);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL1UI64VNVPROC) (GLuint index, const GLuint64EXT* v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL2I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL2I64VNVPROC) (GLuint index, const GLint64EXT* v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL2UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL2UI64VNVPROC) (GLuint index, const GLuint64EXT* v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL3I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL3I64VNVPROC) (GLuint index, const GLint64EXT* v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL3UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL3UI64VNVPROC) (GLuint index, const GLuint64EXT* v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL4I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL4I64VNVPROC) (GLuint index, const GLint64EXT* v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL4UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBL4UI64VNVPROC) (GLuint index, const GLuint64EXT* v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBLFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLsizei stride);\r\n\r\n#define glGetVertexAttribLi64vNV GLEW_GET_FUN(__glewGetVertexAttribLi64vNV)\r\n#define glGetVertexAttribLui64vNV GLEW_GET_FUN(__glewGetVertexAttribLui64vNV)\r\n#define glVertexAttribL1i64NV GLEW_GET_FUN(__glewVertexAttribL1i64NV)\r\n#define glVertexAttribL1i64vNV GLEW_GET_FUN(__glewVertexAttribL1i64vNV)\r\n#define glVertexAttribL1ui64NV GLEW_GET_FUN(__glewVertexAttribL1ui64NV)\r\n#define glVertexAttribL1ui64vNV GLEW_GET_FUN(__glewVertexAttribL1ui64vNV)\r\n#define glVertexAttribL2i64NV GLEW_GET_FUN(__glewVertexAttribL2i64NV)\r\n#define glVertexAttribL2i64vNV GLEW_GET_FUN(__glewVertexAttribL2i64vNV)\r\n#define glVertexAttribL2ui64NV GLEW_GET_FUN(__glewVertexAttribL2ui64NV)\r\n#define glVertexAttribL2ui64vNV GLEW_GET_FUN(__glewVertexAttribL2ui64vNV)\r\n#define glVertexAttribL3i64NV GLEW_GET_FUN(__glewVertexAttribL3i64NV)\r\n#define glVertexAttribL3i64vNV GLEW_GET_FUN(__glewVertexAttribL3i64vNV)\r\n#define glVertexAttribL3ui64NV GLEW_GET_FUN(__glewVertexAttribL3ui64NV)\r\n#define glVertexAttribL3ui64vNV GLEW_GET_FUN(__glewVertexAttribL3ui64vNV)\r\n#define glVertexAttribL4i64NV GLEW_GET_FUN(__glewVertexAttribL4i64NV)\r\n#define glVertexAttribL4i64vNV GLEW_GET_FUN(__glewVertexAttribL4i64vNV)\r\n#define glVertexAttribL4ui64NV GLEW_GET_FUN(__glewVertexAttribL4ui64NV)\r\n#define glVertexAttribL4ui64vNV GLEW_GET_FUN(__glewVertexAttribL4ui64vNV)\r\n#define glVertexAttribLFormatNV GLEW_GET_FUN(__glewVertexAttribLFormatNV)\r\n\r\n#define GLEW_NV_vertex_attrib_integer_64bit GLEW_GET_VAR(__GLEW_NV_vertex_attrib_integer_64bit)\r\n\r\n#endif /* GL_NV_vertex_attrib_integer_64bit */\r\n\r\n/* ------------------- GL_NV_vertex_buffer_unified_memory ------------------ */\r\n\r\n#ifndef GL_NV_vertex_buffer_unified_memory\r\n#define GL_NV_vertex_buffer_unified_memory 1\r\n\r\n#define GL_VERTEX_ATTRIB_ARRAY_UNIFIED_NV 0x8F1E\r\n#define GL_ELEMENT_ARRAY_UNIFIED_NV 0x8F1F\r\n#define GL_VERTEX_ATTRIB_ARRAY_ADDRESS_NV 0x8F20\r\n#define GL_VERTEX_ARRAY_ADDRESS_NV 0x8F21\r\n#define GL_NORMAL_ARRAY_ADDRESS_NV 0x8F22\r\n#define GL_COLOR_ARRAY_ADDRESS_NV 0x8F23\r\n#define GL_INDEX_ARRAY_ADDRESS_NV 0x8F24\r\n#define GL_TEXTURE_COORD_ARRAY_ADDRESS_NV 0x8F25\r\n#define GL_EDGE_FLAG_ARRAY_ADDRESS_NV 0x8F26\r\n#define GL_SECONDARY_COLOR_ARRAY_ADDRESS_NV 0x8F27\r\n#define GL_FOG_COORD_ARRAY_ADDRESS_NV 0x8F28\r\n#define GL_ELEMENT_ARRAY_ADDRESS_NV 0x8F29\r\n#define GL_VERTEX_ATTRIB_ARRAY_LENGTH_NV 0x8F2A\r\n#define GL_VERTEX_ARRAY_LENGTH_NV 0x8F2B\r\n#define GL_NORMAL_ARRAY_LENGTH_NV 0x8F2C\r\n#define GL_COLOR_ARRAY_LENGTH_NV 0x8F2D\r\n#define GL_INDEX_ARRAY_LENGTH_NV 0x8F2E\r\n#define GL_TEXTURE_COORD_ARRAY_LENGTH_NV 0x8F2F\r\n#define GL_EDGE_FLAG_ARRAY_LENGTH_NV 0x8F30\r\n#define GL_SECONDARY_COLOR_ARRAY_LENGTH_NV 0x8F31\r\n#define GL_FOG_COORD_ARRAY_LENGTH_NV 0x8F32\r\n#define GL_ELEMENT_ARRAY_LENGTH_NV 0x8F33\r\n#define GL_DRAW_INDIRECT_UNIFIED_NV 0x8F40\r\n#define GL_DRAW_INDIRECT_ADDRESS_NV 0x8F41\r\n#define GL_DRAW_INDIRECT_LENGTH_NV 0x8F42\r\n\r\ntypedef void (GLAPIENTRY * PFNGLBUFFERADDRESSRANGENVPROC) (GLenum pname, GLuint index, GLuint64EXT address, GLsizeiptr length);\r\ntypedef void (GLAPIENTRY * PFNGLCOLORFORMATNVPROC) (GLint size, GLenum type, GLsizei stride);\r\ntypedef void (GLAPIENTRY * PFNGLEDGEFLAGFORMATNVPROC) (GLsizei stride);\r\ntypedef void (GLAPIENTRY * PFNGLFOGCOORDFORMATNVPROC) (GLenum type, GLsizei stride);\r\ntypedef void (GLAPIENTRY * PFNGLGETINTEGERUI64I_VNVPROC) (GLenum value, GLuint index, GLuint64EXT result[]);\r\ntypedef void (GLAPIENTRY * PFNGLINDEXFORMATNVPROC) (GLenum type, GLsizei stride);\r\ntypedef void (GLAPIENTRY * PFNGLNORMALFORMATNVPROC) (GLenum type, GLsizei stride);\r\ntypedef void (GLAPIENTRY * PFNGLSECONDARYCOLORFORMATNVPROC) (GLint size, GLenum type, GLsizei stride);\r\ntypedef void (GLAPIENTRY * PFNGLTEXCOORDFORMATNVPROC) (GLint size, GLenum type, GLsizei stride);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBIFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLsizei stride);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXFORMATNVPROC) (GLint size, GLenum type, GLsizei stride);\r\n\r\n#define glBufferAddressRangeNV GLEW_GET_FUN(__glewBufferAddressRangeNV)\r\n#define glColorFormatNV GLEW_GET_FUN(__glewColorFormatNV)\r\n#define glEdgeFlagFormatNV GLEW_GET_FUN(__glewEdgeFlagFormatNV)\r\n#define glFogCoordFormatNV GLEW_GET_FUN(__glewFogCoordFormatNV)\r\n#define glGetIntegerui64i_vNV GLEW_GET_FUN(__glewGetIntegerui64i_vNV)\r\n#define glIndexFormatNV GLEW_GET_FUN(__glewIndexFormatNV)\r\n#define glNormalFormatNV GLEW_GET_FUN(__glewNormalFormatNV)\r\n#define glSecondaryColorFormatNV GLEW_GET_FUN(__glewSecondaryColorFormatNV)\r\n#define glTexCoordFormatNV GLEW_GET_FUN(__glewTexCoordFormatNV)\r\n#define glVertexAttribFormatNV GLEW_GET_FUN(__glewVertexAttribFormatNV)\r\n#define glVertexAttribIFormatNV GLEW_GET_FUN(__glewVertexAttribIFormatNV)\r\n#define glVertexFormatNV GLEW_GET_FUN(__glewVertexFormatNV)\r\n\r\n#define GLEW_NV_vertex_buffer_unified_memory GLEW_GET_VAR(__GLEW_NV_vertex_buffer_unified_memory)\r\n\r\n#endif /* GL_NV_vertex_buffer_unified_memory */\r\n\r\n/* -------------------------- GL_NV_vertex_program ------------------------- */\r\n\r\n#ifndef GL_NV_vertex_program\r\n#define GL_NV_vertex_program 1\r\n\r\n#define GL_VERTEX_PROGRAM_NV 0x8620\r\n#define GL_VERTEX_STATE_PROGRAM_NV 0x8621\r\n#define GL_ATTRIB_ARRAY_SIZE_NV 0x8623\r\n#define GL_ATTRIB_ARRAY_STRIDE_NV 0x8624\r\n#define GL_ATTRIB_ARRAY_TYPE_NV 0x8625\r\n#define GL_CURRENT_ATTRIB_NV 0x8626\r\n#define GL_PROGRAM_LENGTH_NV 0x8627\r\n#define GL_PROGRAM_STRING_NV 0x8628\r\n#define GL_MODELVIEW_PROJECTION_NV 0x8629\r\n#define GL_IDENTITY_NV 0x862A\r\n#define GL_INVERSE_NV 0x862B\r\n#define GL_TRANSPOSE_NV 0x862C\r\n#define GL_INVERSE_TRANSPOSE_NV 0x862D\r\n#define GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV 0x862E\r\n#define GL_MAX_TRACK_MATRICES_NV 0x862F\r\n#define GL_MATRIX0_NV 0x8630\r\n#define GL_MATRIX1_NV 0x8631\r\n#define GL_MATRIX2_NV 0x8632\r\n#define GL_MATRIX3_NV 0x8633\r\n#define GL_MATRIX4_NV 0x8634\r\n#define GL_MATRIX5_NV 0x8635\r\n#define GL_MATRIX6_NV 0x8636\r\n#define GL_MATRIX7_NV 0x8637\r\n#define GL_CURRENT_MATRIX_STACK_DEPTH_NV 0x8640\r\n#define GL_CURRENT_MATRIX_NV 0x8641\r\n#define GL_VERTEX_PROGRAM_POINT_SIZE_NV 0x8642\r\n#define GL_VERTEX_PROGRAM_TWO_SIDE_NV 0x8643\r\n#define GL_PROGRAM_PARAMETER_NV 0x8644\r\n#define GL_ATTRIB_ARRAY_POINTER_NV 0x8645\r\n#define GL_PROGRAM_TARGET_NV 0x8646\r\n#define GL_PROGRAM_RESIDENT_NV 0x8647\r\n#define GL_TRACK_MATRIX_NV 0x8648\r\n#define GL_TRACK_MATRIX_TRANSFORM_NV 0x8649\r\n#define GL_VERTEX_PROGRAM_BINDING_NV 0x864A\r\n#define GL_PROGRAM_ERROR_POSITION_NV 0x864B\r\n#define GL_VERTEX_ATTRIB_ARRAY0_NV 0x8650\r\n#define GL_VERTEX_ATTRIB_ARRAY1_NV 0x8651\r\n#define GL_VERTEX_ATTRIB_ARRAY2_NV 0x8652\r\n#define GL_VERTEX_ATTRIB_ARRAY3_NV 0x8653\r\n#define GL_VERTEX_ATTRIB_ARRAY4_NV 0x8654\r\n#define GL_VERTEX_ATTRIB_ARRAY5_NV 0x8655\r\n#define GL_VERTEX_ATTRIB_ARRAY6_NV 0x8656\r\n#define GL_VERTEX_ATTRIB_ARRAY7_NV 0x8657\r\n#define GL_VERTEX_ATTRIB_ARRAY8_NV 0x8658\r\n#define GL_VERTEX_ATTRIB_ARRAY9_NV 0x8659\r\n#define GL_VERTEX_ATTRIB_ARRAY10_NV 0x865A\r\n#define GL_VERTEX_ATTRIB_ARRAY11_NV 0x865B\r\n#define GL_VERTEX_ATTRIB_ARRAY12_NV 0x865C\r\n#define GL_VERTEX_ATTRIB_ARRAY13_NV 0x865D\r\n#define GL_VERTEX_ATTRIB_ARRAY14_NV 0x865E\r\n#define GL_VERTEX_ATTRIB_ARRAY15_NV 0x865F\r\n#define GL_MAP1_VERTEX_ATTRIB0_4_NV 0x8660\r\n#define GL_MAP1_VERTEX_ATTRIB1_4_NV 0x8661\r\n#define GL_MAP1_VERTEX_ATTRIB2_4_NV 0x8662\r\n#define GL_MAP1_VERTEX_ATTRIB3_4_NV 0x8663\r\n#define GL_MAP1_VERTEX_ATTRIB4_4_NV 0x8664\r\n#define GL_MAP1_VERTEX_ATTRIB5_4_NV 0x8665\r\n#define GL_MAP1_VERTEX_ATTRIB6_4_NV 0x8666\r\n#define GL_MAP1_VERTEX_ATTRIB7_4_NV 0x8667\r\n#define GL_MAP1_VERTEX_ATTRIB8_4_NV 0x8668\r\n#define GL_MAP1_VERTEX_ATTRIB9_4_NV 0x8669\r\n#define GL_MAP1_VERTEX_ATTRIB10_4_NV 0x866A\r\n#define GL_MAP1_VERTEX_ATTRIB11_4_NV 0x866B\r\n#define GL_MAP1_VERTEX_ATTRIB12_4_NV 0x866C\r\n#define GL_MAP1_VERTEX_ATTRIB13_4_NV 0x866D\r\n#define GL_MAP1_VERTEX_ATTRIB14_4_NV 0x866E\r\n#define GL_MAP1_VERTEX_ATTRIB15_4_NV 0x866F\r\n#define GL_MAP2_VERTEX_ATTRIB0_4_NV 0x8670\r\n#define GL_MAP2_VERTEX_ATTRIB1_4_NV 0x8671\r\n#define GL_MAP2_VERTEX_ATTRIB2_4_NV 0x8672\r\n#define GL_MAP2_VERTEX_ATTRIB3_4_NV 0x8673\r\n#define GL_MAP2_VERTEX_ATTRIB4_4_NV 0x8674\r\n#define GL_MAP2_VERTEX_ATTRIB5_4_NV 0x8675\r\n#define GL_MAP2_VERTEX_ATTRIB6_4_NV 0x8676\r\n#define GL_MAP2_VERTEX_ATTRIB7_4_NV 0x8677\r\n#define GL_MAP2_VERTEX_ATTRIB8_4_NV 0x8678\r\n#define GL_MAP2_VERTEX_ATTRIB9_4_NV 0x8679\r\n#define GL_MAP2_VERTEX_ATTRIB10_4_NV 0x867A\r\n#define GL_MAP2_VERTEX_ATTRIB11_4_NV 0x867B\r\n#define GL_MAP2_VERTEX_ATTRIB12_4_NV 0x867C\r\n#define GL_MAP2_VERTEX_ATTRIB13_4_NV 0x867D\r\n#define GL_MAP2_VERTEX_ATTRIB14_4_NV 0x867E\r\n#define GL_MAP2_VERTEX_ATTRIB15_4_NV 0x867F\r\n\r\ntypedef GLboolean (GLAPIENTRY * PFNGLAREPROGRAMSRESIDENTNVPROC) (GLsizei n, const GLuint* ids, GLboolean *residences);\r\ntypedef void (GLAPIENTRY * PFNGLBINDPROGRAMNVPROC) (GLenum target, GLuint id);\r\ntypedef void (GLAPIENTRY * PFNGLDELETEPROGRAMSNVPROC) (GLsizei n, const GLuint* ids);\r\ntypedef void (GLAPIENTRY * PFNGLEXECUTEPROGRAMNVPROC) (GLenum target, GLuint id, const GLfloat* params);\r\ntypedef void (GLAPIENTRY * PFNGLGENPROGRAMSNVPROC) (GLsizei n, GLuint* ids);\r\ntypedef void (GLAPIENTRY * PFNGLGETPROGRAMPARAMETERDVNVPROC) (GLenum target, GLuint index, GLenum pname, GLdouble* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETPROGRAMPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETPROGRAMSTRINGNVPROC) (GLuint id, GLenum pname, GLubyte* program);\r\ntypedef void (GLAPIENTRY * PFNGLGETPROGRAMIVNVPROC) (GLuint id, GLenum pname, GLint* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETTRACKMATRIXIVNVPROC) (GLenum target, GLuint address, GLenum pname, GLint* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBPOINTERVNVPROC) (GLuint index, GLenum pname, void** pointer);\r\ntypedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBDVNVPROC) (GLuint index, GLenum pname, GLdouble* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBFVNVPROC) (GLuint index, GLenum pname, GLfloat* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBIVNVPROC) (GLuint index, GLenum pname, GLint* params);\r\ntypedef GLboolean (GLAPIENTRY * PFNGLISPROGRAMNVPROC) (GLuint id);\r\ntypedef void (GLAPIENTRY * PFNGLLOADPROGRAMNVPROC) (GLenum target, GLuint id, GLsizei len, const GLubyte* program);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMPARAMETER4DNVPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMPARAMETER4DVNVPROC) (GLenum target, GLuint index, const GLdouble* params);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMPARAMETER4FNVPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMPARAMETER4FVNVPROC) (GLenum target, GLuint index, const GLfloat* params);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMPARAMETERS4DVNVPROC) (GLenum target, GLuint index, GLsizei num, const GLdouble* params);\r\ntypedef void (GLAPIENTRY * PFNGLPROGRAMPARAMETERS4FVNVPROC) (GLenum target, GLuint index, GLsizei num, const GLfloat* params);\r\ntypedef void (GLAPIENTRY * PFNGLREQUESTRESIDENTPROGRAMSNVPROC) (GLsizei n, GLuint* ids);\r\ntypedef void (GLAPIENTRY * PFNGLTRACKMATRIXNVPROC) (GLenum target, GLuint address, GLenum matrix, GLenum transform);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1DNVPROC) (GLuint index, GLdouble x);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1DVNVPROC) (GLuint index, const GLdouble* v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1FNVPROC) (GLuint index, GLfloat x);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1FVNVPROC) (GLuint index, const GLfloat* v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1SNVPROC) (GLuint index, GLshort x);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1SVNVPROC) (GLuint index, const GLshort* v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2DNVPROC) (GLuint index, GLdouble x, GLdouble y);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2DVNVPROC) (GLuint index, const GLdouble* v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2FNVPROC) (GLuint index, GLfloat x, GLfloat y);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2FVNVPROC) (GLuint index, const GLfloat* v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2SNVPROC) (GLuint index, GLshort x, GLshort y);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2SVNVPROC) (GLuint index, const GLshort* v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3DVNVPROC) (GLuint index, const GLdouble* v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3FVNVPROC) (GLuint index, const GLfloat* v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3SVNVPROC) (GLuint index, const GLshort* v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4DVNVPROC) (GLuint index, const GLdouble* v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4FVNVPROC) (GLuint index, const GLfloat* v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4SVNVPROC) (GLuint index, const GLshort* v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4UBNVPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4UBVNVPROC) (GLuint index, const GLubyte* v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBPOINTERNVPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS1DVNVPROC) (GLuint index, GLsizei n, const GLdouble* v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS1FVNVPROC) (GLuint index, GLsizei n, const GLfloat* v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS1SVNVPROC) (GLuint index, GLsizei n, const GLshort* v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS2DVNVPROC) (GLuint index, GLsizei n, const GLdouble* v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS2FVNVPROC) (GLuint index, GLsizei n, const GLfloat* v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS2SVNVPROC) (GLuint index, GLsizei n, const GLshort* v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS3DVNVPROC) (GLuint index, GLsizei n, const GLdouble* v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS3FVNVPROC) (GLuint index, GLsizei n, const GLfloat* v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS3SVNVPROC) (GLuint index, GLsizei n, const GLshort* v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS4DVNVPROC) (GLuint index, GLsizei n, const GLdouble* v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS4FVNVPROC) (GLuint index, GLsizei n, const GLfloat* v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS4SVNVPROC) (GLuint index, GLsizei n, const GLshort* v);\r\ntypedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS4UBVNVPROC) (GLuint index, GLsizei n, const GLubyte* v);\r\n\r\n#define glAreProgramsResidentNV GLEW_GET_FUN(__glewAreProgramsResidentNV)\r\n#define glBindProgramNV GLEW_GET_FUN(__glewBindProgramNV)\r\n#define glDeleteProgramsNV GLEW_GET_FUN(__glewDeleteProgramsNV)\r\n#define glExecuteProgramNV GLEW_GET_FUN(__glewExecuteProgramNV)\r\n#define glGenProgramsNV GLEW_GET_FUN(__glewGenProgramsNV)\r\n#define glGetProgramParameterdvNV GLEW_GET_FUN(__glewGetProgramParameterdvNV)\r\n#define glGetProgramParameterfvNV GLEW_GET_FUN(__glewGetProgramParameterfvNV)\r\n#define glGetProgramStringNV GLEW_GET_FUN(__glewGetProgramStringNV)\r\n#define glGetProgramivNV GLEW_GET_FUN(__glewGetProgramivNV)\r\n#define glGetTrackMatrixivNV GLEW_GET_FUN(__glewGetTrackMatrixivNV)\r\n#define glGetVertexAttribPointervNV GLEW_GET_FUN(__glewGetVertexAttribPointervNV)\r\n#define glGetVertexAttribdvNV GLEW_GET_FUN(__glewGetVertexAttribdvNV)\r\n#define glGetVertexAttribfvNV GLEW_GET_FUN(__glewGetVertexAttribfvNV)\r\n#define glGetVertexAttribivNV GLEW_GET_FUN(__glewGetVertexAttribivNV)\r\n#define glIsProgramNV GLEW_GET_FUN(__glewIsProgramNV)\r\n#define glLoadProgramNV GLEW_GET_FUN(__glewLoadProgramNV)\r\n#define glProgramParameter4dNV GLEW_GET_FUN(__glewProgramParameter4dNV)\r\n#define glProgramParameter4dvNV GLEW_GET_FUN(__glewProgramParameter4dvNV)\r\n#define glProgramParameter4fNV GLEW_GET_FUN(__glewProgramParameter4fNV)\r\n#define glProgramParameter4fvNV GLEW_GET_FUN(__glewProgramParameter4fvNV)\r\n#define glProgramParameters4dvNV GLEW_GET_FUN(__glewProgramParameters4dvNV)\r\n#define glProgramParameters4fvNV GLEW_GET_FUN(__glewProgramParameters4fvNV)\r\n#define glRequestResidentProgramsNV GLEW_GET_FUN(__glewRequestResidentProgramsNV)\r\n#define glTrackMatrixNV GLEW_GET_FUN(__glewTrackMatrixNV)\r\n#define glVertexAttrib1dNV GLEW_GET_FUN(__glewVertexAttrib1dNV)\r\n#define glVertexAttrib1dvNV GLEW_GET_FUN(__glewVertexAttrib1dvNV)\r\n#define glVertexAttrib1fNV GLEW_GET_FUN(__glewVertexAttrib1fNV)\r\n#define glVertexAttrib1fvNV GLEW_GET_FUN(__glewVertexAttrib1fvNV)\r\n#define glVertexAttrib1sNV GLEW_GET_FUN(__glewVertexAttrib1sNV)\r\n#define glVertexAttrib1svNV GLEW_GET_FUN(__glewVertexAttrib1svNV)\r\n#define glVertexAttrib2dNV GLEW_GET_FUN(__glewVertexAttrib2dNV)\r\n#define glVertexAttrib2dvNV GLEW_GET_FUN(__glewVertexAttrib2dvNV)\r\n#define glVertexAttrib2fNV GLEW_GET_FUN(__glewVertexAttrib2fNV)\r\n#define glVertexAttrib2fvNV GLEW_GET_FUN(__glewVertexAttrib2fvNV)\r\n#define glVertexAttrib2sNV GLEW_GET_FUN(__glewVertexAttrib2sNV)\r\n#define glVertexAttrib2svNV GLEW_GET_FUN(__glewVertexAttrib2svNV)\r\n#define glVertexAttrib3dNV GLEW_GET_FUN(__glewVertexAttrib3dNV)\r\n#define glVertexAttrib3dvNV GLEW_GET_FUN(__glewVertexAttrib3dvNV)\r\n#define glVertexAttrib3fNV GLEW_GET_FUN(__glewVertexAttrib3fNV)\r\n#define glVertexAttrib3fvNV GLEW_GET_FUN(__glewVertexAttrib3fvNV)\r\n#define glVertexAttrib3sNV GLEW_GET_FUN(__glewVertexAttrib3sNV)\r\n#define glVertexAttrib3svNV GLEW_GET_FUN(__glewVertexAttrib3svNV)\r\n#define glVertexAttrib4dNV GLEW_GET_FUN(__glewVertexAttrib4dNV)\r\n#define glVertexAttrib4dvNV GLEW_GET_FUN(__glewVertexAttrib4dvNV)\r\n#define glVertexAttrib4fNV GLEW_GET_FUN(__glewVertexAttrib4fNV)\r\n#define glVertexAttrib4fvNV GLEW_GET_FUN(__glewVertexAttrib4fvNV)\r\n#define glVertexAttrib4sNV GLEW_GET_FUN(__glewVertexAttrib4sNV)\r\n#define glVertexAttrib4svNV GLEW_GET_FUN(__glewVertexAttrib4svNV)\r\n#define glVertexAttrib4ubNV GLEW_GET_FUN(__glewVertexAttrib4ubNV)\r\n#define glVertexAttrib4ubvNV GLEW_GET_FUN(__glewVertexAttrib4ubvNV)\r\n#define glVertexAttribPointerNV GLEW_GET_FUN(__glewVertexAttribPointerNV)\r\n#define glVertexAttribs1dvNV GLEW_GET_FUN(__glewVertexAttribs1dvNV)\r\n#define glVertexAttribs1fvNV GLEW_GET_FUN(__glewVertexAttribs1fvNV)\r\n#define glVertexAttribs1svNV GLEW_GET_FUN(__glewVertexAttribs1svNV)\r\n#define glVertexAttribs2dvNV GLEW_GET_FUN(__glewVertexAttribs2dvNV)\r\n#define glVertexAttribs2fvNV GLEW_GET_FUN(__glewVertexAttribs2fvNV)\r\n#define glVertexAttribs2svNV GLEW_GET_FUN(__glewVertexAttribs2svNV)\r\n#define glVertexAttribs3dvNV GLEW_GET_FUN(__glewVertexAttribs3dvNV)\r\n#define glVertexAttribs3fvNV GLEW_GET_FUN(__glewVertexAttribs3fvNV)\r\n#define glVertexAttribs3svNV GLEW_GET_FUN(__glewVertexAttribs3svNV)\r\n#define glVertexAttribs4dvNV GLEW_GET_FUN(__glewVertexAttribs4dvNV)\r\n#define glVertexAttribs4fvNV GLEW_GET_FUN(__glewVertexAttribs4fvNV)\r\n#define glVertexAttribs4svNV GLEW_GET_FUN(__glewVertexAttribs4svNV)\r\n#define glVertexAttribs4ubvNV GLEW_GET_FUN(__glewVertexAttribs4ubvNV)\r\n\r\n#define GLEW_NV_vertex_program GLEW_GET_VAR(__GLEW_NV_vertex_program)\r\n\r\n#endif /* GL_NV_vertex_program */\r\n\r\n/* ------------------------ GL_NV_vertex_program1_1 ------------------------ */\r\n\r\n#ifndef GL_NV_vertex_program1_1\r\n#define GL_NV_vertex_program1_1 1\r\n\r\n#define GLEW_NV_vertex_program1_1 GLEW_GET_VAR(__GLEW_NV_vertex_program1_1)\r\n\r\n#endif /* GL_NV_vertex_program1_1 */\r\n\r\n/* ------------------------- GL_NV_vertex_program2 ------------------------- */\r\n\r\n#ifndef GL_NV_vertex_program2\r\n#define GL_NV_vertex_program2 1\r\n\r\n#define GLEW_NV_vertex_program2 GLEW_GET_VAR(__GLEW_NV_vertex_program2)\r\n\r\n#endif /* GL_NV_vertex_program2 */\r\n\r\n/* ---------------------- GL_NV_vertex_program2_option --------------------- */\r\n\r\n#ifndef GL_NV_vertex_program2_option\r\n#define GL_NV_vertex_program2_option 1\r\n\r\n#define GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV 0x88F4\r\n#define GL_MAX_PROGRAM_CALL_DEPTH_NV 0x88F5\r\n\r\n#define GLEW_NV_vertex_program2_option GLEW_GET_VAR(__GLEW_NV_vertex_program2_option)\r\n\r\n#endif /* GL_NV_vertex_program2_option */\r\n\r\n/* ------------------------- GL_NV_vertex_program3 ------------------------- */\r\n\r\n#ifndef GL_NV_vertex_program3\r\n#define GL_NV_vertex_program3 1\r\n\r\n#define MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB 0x8B4C\r\n\r\n#define GLEW_NV_vertex_program3 GLEW_GET_VAR(__GLEW_NV_vertex_program3)\r\n\r\n#endif /* GL_NV_vertex_program3 */\r\n\r\n/* ------------------------- GL_NV_vertex_program4 ------------------------- */\r\n\r\n#ifndef GL_NV_vertex_program4\r\n#define GL_NV_vertex_program4 1\r\n\r\n#define GL_VERTEX_ATTRIB_ARRAY_INTEGER_NV 0x88FD\r\n\r\n#define GLEW_NV_vertex_program4 GLEW_GET_VAR(__GLEW_NV_vertex_program4)\r\n\r\n#endif /* GL_NV_vertex_program4 */\r\n\r\n/* -------------------------- GL_NV_video_capture -------------------------- */\r\n\r\n#ifndef GL_NV_video_capture\r\n#define GL_NV_video_capture 1\r\n\r\n#define GL_VIDEO_BUFFER_NV 0x9020\r\n#define GL_VIDEO_BUFFER_BINDING_NV 0x9021\r\n#define GL_FIELD_UPPER_NV 0x9022\r\n#define GL_FIELD_LOWER_NV 0x9023\r\n#define GL_NUM_VIDEO_CAPTURE_STREAMS_NV 0x9024\r\n#define GL_NEXT_VIDEO_CAPTURE_BUFFER_STATUS_NV 0x9025\r\n#define GL_VIDEO_CAPTURE_TO_422_SUPPORTED_NV 0x9026\r\n#define GL_LAST_VIDEO_CAPTURE_STATUS_NV 0x9027\r\n#define GL_VIDEO_BUFFER_PITCH_NV 0x9028\r\n#define GL_VIDEO_COLOR_CONVERSION_MATRIX_NV 0x9029\r\n#define GL_VIDEO_COLOR_CONVERSION_MAX_NV 0x902A\r\n#define GL_VIDEO_COLOR_CONVERSION_MIN_NV 0x902B\r\n#define GL_VIDEO_COLOR_CONVERSION_OFFSET_NV 0x902C\r\n#define GL_VIDEO_BUFFER_INTERNAL_FORMAT_NV 0x902D\r\n#define GL_PARTIAL_SUCCESS_NV 0x902E\r\n#define GL_SUCCESS_NV 0x902F\r\n#define GL_FAILURE_NV 0x9030\r\n#define GL_YCBYCR8_422_NV 0x9031\r\n#define GL_YCBAYCR8A_4224_NV 0x9032\r\n#define GL_Z6Y10Z6CB10Z6Y10Z6CR10_422_NV 0x9033\r\n#define GL_Z6Y10Z6CB10Z6A10Z6Y10Z6CR10Z6A10_4224_NV 0x9034\r\n#define GL_Z4Y12Z4CB12Z4Y12Z4CR12_422_NV 0x9035\r\n#define GL_Z4Y12Z4CB12Z4A12Z4Y12Z4CR12Z4A12_4224_NV 0x9036\r\n#define GL_Z4Y12Z4CB12Z4CR12_444_NV 0x9037\r\n#define GL_VIDEO_CAPTURE_FRAME_WIDTH_NV 0x9038\r\n#define GL_VIDEO_CAPTURE_FRAME_HEIGHT_NV 0x9039\r\n#define GL_VIDEO_CAPTURE_FIELD_UPPER_HEIGHT_NV 0x903A\r\n#define GL_VIDEO_CAPTURE_FIELD_LOWER_HEIGHT_NV 0x903B\r\n#define GL_VIDEO_CAPTURE_SURFACE_ORIGIN_NV 0x903C\r\n\r\ntypedef void (GLAPIENTRY * PFNGLBEGINVIDEOCAPTURENVPROC) (GLuint video_capture_slot);\r\ntypedef void (GLAPIENTRY * PFNGLBINDVIDEOCAPTURESTREAMBUFFERNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLintptrARB offset);\r\ntypedef void (GLAPIENTRY * PFNGLBINDVIDEOCAPTURESTREAMTEXTURENVPROC) (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLenum target, GLuint texture);\r\ntypedef void (GLAPIENTRY * PFNGLENDVIDEOCAPTURENVPROC) (GLuint video_capture_slot);\r\ntypedef void (GLAPIENTRY * PFNGLGETVIDEOCAPTURESTREAMDVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLdouble* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETVIDEOCAPTURESTREAMFVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLfloat* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETVIDEOCAPTURESTREAMIVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLint* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETVIDEOCAPTUREIVNVPROC) (GLuint video_capture_slot, GLenum pname, GLint* params);\r\ntypedef GLenum (GLAPIENTRY * PFNGLVIDEOCAPTURENVPROC) (GLuint video_capture_slot, GLuint* sequence_num, GLuint64EXT *capture_time);\r\ntypedef void (GLAPIENTRY * PFNGLVIDEOCAPTURESTREAMPARAMETERDVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLdouble* params);\r\ntypedef void (GLAPIENTRY * PFNGLVIDEOCAPTURESTREAMPARAMETERFVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLfloat* params);\r\ntypedef void (GLAPIENTRY * PFNGLVIDEOCAPTURESTREAMPARAMETERIVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLint* params);\r\n\r\n#define glBeginVideoCaptureNV GLEW_GET_FUN(__glewBeginVideoCaptureNV)\r\n#define glBindVideoCaptureStreamBufferNV GLEW_GET_FUN(__glewBindVideoCaptureStreamBufferNV)\r\n#define glBindVideoCaptureStreamTextureNV GLEW_GET_FUN(__glewBindVideoCaptureStreamTextureNV)\r\n#define glEndVideoCaptureNV GLEW_GET_FUN(__glewEndVideoCaptureNV)\r\n#define glGetVideoCaptureStreamdvNV GLEW_GET_FUN(__glewGetVideoCaptureStreamdvNV)\r\n#define glGetVideoCaptureStreamfvNV GLEW_GET_FUN(__glewGetVideoCaptureStreamfvNV)\r\n#define glGetVideoCaptureStreamivNV GLEW_GET_FUN(__glewGetVideoCaptureStreamivNV)\r\n#define glGetVideoCaptureivNV GLEW_GET_FUN(__glewGetVideoCaptureivNV)\r\n#define glVideoCaptureNV GLEW_GET_FUN(__glewVideoCaptureNV)\r\n#define glVideoCaptureStreamParameterdvNV GLEW_GET_FUN(__glewVideoCaptureStreamParameterdvNV)\r\n#define glVideoCaptureStreamParameterfvNV GLEW_GET_FUN(__glewVideoCaptureStreamParameterfvNV)\r\n#define glVideoCaptureStreamParameterivNV GLEW_GET_FUN(__glewVideoCaptureStreamParameterivNV)\r\n\r\n#define GLEW_NV_video_capture GLEW_GET_VAR(__GLEW_NV_video_capture)\r\n\r\n#endif /* GL_NV_video_capture */\r\n\r\n/* ------------------------- GL_NV_viewport_array2 ------------------------- */\r\n\r\n#ifndef GL_NV_viewport_array2\r\n#define GL_NV_viewport_array2 1\r\n\r\n#define GLEW_NV_viewport_array2 GLEW_GET_VAR(__GLEW_NV_viewport_array2)\r\n\r\n#endif /* GL_NV_viewport_array2 */\r\n\r\n/* ------------------------ GL_OES_byte_coordinates ------------------------ */\r\n\r\n#ifndef GL_OES_byte_coordinates\r\n#define GL_OES_byte_coordinates 1\r\n\r\n#define GLEW_OES_byte_coordinates GLEW_GET_VAR(__GLEW_OES_byte_coordinates)\r\n\r\n#endif /* GL_OES_byte_coordinates */\r\n\r\n/* ------------------- GL_OES_compressed_paletted_texture ------------------ */\r\n\r\n#ifndef GL_OES_compressed_paletted_texture\r\n#define GL_OES_compressed_paletted_texture 1\r\n\r\n#define GL_PALETTE4_RGB8_OES 0x8B90\r\n#define GL_PALETTE4_RGBA8_OES 0x8B91\r\n#define GL_PALETTE4_R5_G6_B5_OES 0x8B92\r\n#define GL_PALETTE4_RGBA4_OES 0x8B93\r\n#define GL_PALETTE4_RGB5_A1_OES 0x8B94\r\n#define GL_PALETTE8_RGB8_OES 0x8B95\r\n#define GL_PALETTE8_RGBA8_OES 0x8B96\r\n#define GL_PALETTE8_R5_G6_B5_OES 0x8B97\r\n#define GL_PALETTE8_RGBA4_OES 0x8B98\r\n#define GL_PALETTE8_RGB5_A1_OES 0x8B99\r\n\r\n#define GLEW_OES_compressed_paletted_texture GLEW_GET_VAR(__GLEW_OES_compressed_paletted_texture)\r\n\r\n#endif /* GL_OES_compressed_paletted_texture */\r\n\r\n/* --------------------------- GL_OES_read_format -------------------------- */\r\n\r\n#ifndef GL_OES_read_format\r\n#define GL_OES_read_format 1\r\n\r\n#define GL_IMPLEMENTATION_COLOR_READ_TYPE_OES 0x8B9A\r\n#define GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES 0x8B9B\r\n\r\n#define GLEW_OES_read_format GLEW_GET_VAR(__GLEW_OES_read_format)\r\n\r\n#endif /* GL_OES_read_format */\r\n\r\n/* ------------------------ GL_OES_single_precision ------------------------ */\r\n\r\n#ifndef GL_OES_single_precision\r\n#define GL_OES_single_precision 1\r\n\r\ntypedef void (GLAPIENTRY * PFNGLCLEARDEPTHFOESPROC) (GLclampf depth);\r\ntypedef void (GLAPIENTRY * PFNGLCLIPPLANEFOESPROC) (GLenum plane, const GLfloat* equation);\r\ntypedef void (GLAPIENTRY * PFNGLDEPTHRANGEFOESPROC) (GLclampf n, GLclampf f);\r\ntypedef void (GLAPIENTRY * PFNGLFRUSTUMFOESPROC) (GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f);\r\ntypedef void (GLAPIENTRY * PFNGLGETCLIPPLANEFOESPROC) (GLenum plane, GLfloat* equation);\r\ntypedef void (GLAPIENTRY * PFNGLORTHOFOESPROC) (GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f);\r\n\r\n#define glClearDepthfOES GLEW_GET_FUN(__glewClearDepthfOES)\r\n#define glClipPlanefOES GLEW_GET_FUN(__glewClipPlanefOES)\r\n#define glDepthRangefOES GLEW_GET_FUN(__glewDepthRangefOES)\r\n#define glFrustumfOES GLEW_GET_FUN(__glewFrustumfOES)\r\n#define glGetClipPlanefOES GLEW_GET_FUN(__glewGetClipPlanefOES)\r\n#define glOrthofOES GLEW_GET_FUN(__glewOrthofOES)\r\n\r\n#define GLEW_OES_single_precision GLEW_GET_VAR(__GLEW_OES_single_precision)\r\n\r\n#endif /* GL_OES_single_precision */\r\n\r\n/* ---------------------------- GL_OML_interlace --------------------------- */\r\n\r\n#ifndef GL_OML_interlace\r\n#define GL_OML_interlace 1\r\n\r\n#define GL_INTERLACE_OML 0x8980\r\n#define GL_INTERLACE_READ_OML 0x8981\r\n\r\n#define GLEW_OML_interlace GLEW_GET_VAR(__GLEW_OML_interlace)\r\n\r\n#endif /* GL_OML_interlace */\r\n\r\n/* ---------------------------- GL_OML_resample ---------------------------- */\r\n\r\n#ifndef GL_OML_resample\r\n#define GL_OML_resample 1\r\n\r\n#define GL_PACK_RESAMPLE_OML 0x8984\r\n#define GL_UNPACK_RESAMPLE_OML 0x8985\r\n#define GL_RESAMPLE_REPLICATE_OML 0x8986\r\n#define GL_RESAMPLE_ZERO_FILL_OML 0x8987\r\n#define GL_RESAMPLE_AVERAGE_OML 0x8988\r\n#define GL_RESAMPLE_DECIMATE_OML 0x8989\r\n\r\n#define GLEW_OML_resample GLEW_GET_VAR(__GLEW_OML_resample)\r\n\r\n#endif /* GL_OML_resample */\r\n\r\n/* ---------------------------- GL_OML_subsample --------------------------- */\r\n\r\n#ifndef GL_OML_subsample\r\n#define GL_OML_subsample 1\r\n\r\n#define GL_FORMAT_SUBSAMPLE_24_24_OML 0x8982\r\n#define GL_FORMAT_SUBSAMPLE_244_244_OML 0x8983\r\n\r\n#define GLEW_OML_subsample GLEW_GET_VAR(__GLEW_OML_subsample)\r\n\r\n#endif /* GL_OML_subsample */\r\n\r\n/* ---------------------------- GL_OVR_multiview --------------------------- */\r\n\r\n#ifndef GL_OVR_multiview\r\n#define GL_OVR_multiview 1\r\n\r\n#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_NUM_VIEWS_OVR 0x9630\r\n#define GL_MAX_VIEWS_OVR 0x9631\r\n#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_BASE_VIEW_INDEX_OVR 0x9632\r\n#define GL_FRAMEBUFFER_INCOMPLETE_VIEW_TARGETS_OVR 0x9633\r\n\r\ntypedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTUREMULTIVIEWOVRPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint baseViewIndex, GLsizei numViews);\r\n\r\n#define glFramebufferTextureMultiviewOVR GLEW_GET_FUN(__glewFramebufferTextureMultiviewOVR)\r\n\r\n#define GLEW_OVR_multiview GLEW_GET_VAR(__GLEW_OVR_multiview)\r\n\r\n#endif /* GL_OVR_multiview */\r\n\r\n/* --------------------------- GL_OVR_multiview2 --------------------------- */\r\n\r\n#ifndef GL_OVR_multiview2\r\n#define GL_OVR_multiview2 1\r\n\r\n#define GLEW_OVR_multiview2 GLEW_GET_VAR(__GLEW_OVR_multiview2)\r\n\r\n#endif /* GL_OVR_multiview2 */\r\n\r\n/* --------------------------- GL_PGI_misc_hints --------------------------- */\r\n\r\n#ifndef GL_PGI_misc_hints\r\n#define GL_PGI_misc_hints 1\r\n\r\n#define GL_PREFER_DOUBLEBUFFER_HINT_PGI 107000\r\n#define GL_CONSERVE_MEMORY_HINT_PGI 107005\r\n#define GL_RECLAIM_MEMORY_HINT_PGI 107006\r\n#define GL_NATIVE_GRAPHICS_HANDLE_PGI 107010\r\n#define GL_NATIVE_GRAPHICS_BEGIN_HINT_PGI 107011\r\n#define GL_NATIVE_GRAPHICS_END_HINT_PGI 107012\r\n#define GL_ALWAYS_FAST_HINT_PGI 107020\r\n#define GL_ALWAYS_SOFT_HINT_PGI 107021\r\n#define GL_ALLOW_DRAW_OBJ_HINT_PGI 107022\r\n#define GL_ALLOW_DRAW_WIN_HINT_PGI 107023\r\n#define GL_ALLOW_DRAW_FRG_HINT_PGI 107024\r\n#define GL_ALLOW_DRAW_MEM_HINT_PGI 107025\r\n#define GL_STRICT_DEPTHFUNC_HINT_PGI 107030\r\n#define GL_STRICT_LIGHTING_HINT_PGI 107031\r\n#define GL_STRICT_SCISSOR_HINT_PGI 107032\r\n#define GL_FULL_STIPPLE_HINT_PGI 107033\r\n#define GL_CLIP_NEAR_HINT_PGI 107040\r\n#define GL_CLIP_FAR_HINT_PGI 107041\r\n#define GL_WIDE_LINE_HINT_PGI 107042\r\n#define GL_BACK_NORMALS_HINT_PGI 107043\r\n\r\n#define GLEW_PGI_misc_hints GLEW_GET_VAR(__GLEW_PGI_misc_hints)\r\n\r\n#endif /* GL_PGI_misc_hints */\r\n\r\n/* -------------------------- GL_PGI_vertex_hints -------------------------- */\r\n\r\n#ifndef GL_PGI_vertex_hints\r\n#define GL_PGI_vertex_hints 1\r\n\r\n#define GL_VERTEX23_BIT_PGI 0x00000004\r\n#define GL_VERTEX4_BIT_PGI 0x00000008\r\n#define GL_COLOR3_BIT_PGI 0x00010000\r\n#define GL_COLOR4_BIT_PGI 0x00020000\r\n#define GL_EDGEFLAG_BIT_PGI 0x00040000\r\n#define GL_INDEX_BIT_PGI 0x00080000\r\n#define GL_MAT_AMBIENT_BIT_PGI 0x00100000\r\n#define GL_VERTEX_DATA_HINT_PGI 107050\r\n#define GL_VERTEX_CONSISTENT_HINT_PGI 107051\r\n#define GL_MATERIAL_SIDE_HINT_PGI 107052\r\n#define GL_MAX_VERTEX_HINT_PGI 107053\r\n#define GL_MAT_AMBIENT_AND_DIFFUSE_BIT_PGI 0x00200000\r\n#define GL_MAT_DIFFUSE_BIT_PGI 0x00400000\r\n#define GL_MAT_EMISSION_BIT_PGI 0x00800000\r\n#define GL_MAT_COLOR_INDEXES_BIT_PGI 0x01000000\r\n#define GL_MAT_SHININESS_BIT_PGI 0x02000000\r\n#define GL_MAT_SPECULAR_BIT_PGI 0x04000000\r\n#define GL_NORMAL_BIT_PGI 0x08000000\r\n#define GL_TEXCOORD1_BIT_PGI 0x10000000\r\n#define GL_TEXCOORD2_BIT_PGI 0x20000000\r\n#define GL_TEXCOORD3_BIT_PGI 0x40000000\r\n#define GL_TEXCOORD4_BIT_PGI 0x80000000\r\n\r\n#define GLEW_PGI_vertex_hints GLEW_GET_VAR(__GLEW_PGI_vertex_hints)\r\n\r\n#endif /* GL_PGI_vertex_hints */\r\n\r\n/* ---------------------- GL_REGAL_ES1_0_compatibility --------------------- */\r\n\r\n#ifndef GL_REGAL_ES1_0_compatibility\r\n#define GL_REGAL_ES1_0_compatibility 1\r\n\r\ntypedef int GLclampx;\r\n\r\ntypedef void (GLAPIENTRY * PFNGLALPHAFUNCXPROC) (GLenum func, GLclampx ref);\r\ntypedef void (GLAPIENTRY * PFNGLCLEARCOLORXPROC) (GLclampx red, GLclampx green, GLclampx blue, GLclampx alpha);\r\ntypedef void (GLAPIENTRY * PFNGLCLEARDEPTHXPROC) (GLclampx depth);\r\ntypedef void (GLAPIENTRY * PFNGLCOLOR4XPROC) (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha);\r\ntypedef void (GLAPIENTRY * PFNGLDEPTHRANGEXPROC) (GLclampx zNear, GLclampx zFar);\r\ntypedef void (GLAPIENTRY * PFNGLFOGXPROC) (GLenum pname, GLfixed param);\r\ntypedef void (GLAPIENTRY * PFNGLFOGXVPROC) (GLenum pname, const GLfixed* params);\r\ntypedef void (GLAPIENTRY * PFNGLFRUSTUMFPROC) (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar);\r\ntypedef void (GLAPIENTRY * PFNGLFRUSTUMXPROC) (GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar);\r\ntypedef void (GLAPIENTRY * PFNGLLIGHTMODELXPROC) (GLenum pname, GLfixed param);\r\ntypedef void (GLAPIENTRY * PFNGLLIGHTMODELXVPROC) (GLenum pname, const GLfixed* params);\r\ntypedef void (GLAPIENTRY * PFNGLLIGHTXPROC) (GLenum light, GLenum pname, GLfixed param);\r\ntypedef void (GLAPIENTRY * PFNGLLIGHTXVPROC) (GLenum light, GLenum pname, const GLfixed* params);\r\ntypedef void (GLAPIENTRY * PFNGLLINEWIDTHXPROC) (GLfixed width);\r\ntypedef void (GLAPIENTRY * PFNGLLOADMATRIXXPROC) (const GLfixed* m);\r\ntypedef void (GLAPIENTRY * PFNGLMATERIALXPROC) (GLenum face, GLenum pname, GLfixed param);\r\ntypedef void (GLAPIENTRY * PFNGLMATERIALXVPROC) (GLenum face, GLenum pname, const GLfixed* params);\r\ntypedef void (GLAPIENTRY * PFNGLMULTMATRIXXPROC) (const GLfixed* m);\r\ntypedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4XPROC) (GLenum target, GLfixed s, GLfixed t, GLfixed r, GLfixed q);\r\ntypedef void (GLAPIENTRY * PFNGLNORMAL3XPROC) (GLfixed nx, GLfixed ny, GLfixed nz);\r\ntypedef void (GLAPIENTRY * PFNGLORTHOFPROC) (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar);\r\ntypedef void (GLAPIENTRY * PFNGLORTHOXPROC) (GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar);\r\ntypedef void (GLAPIENTRY * PFNGLPOINTSIZEXPROC) (GLfixed size);\r\ntypedef void (GLAPIENTRY * PFNGLPOLYGONOFFSETXPROC) (GLfixed factor, GLfixed units);\r\ntypedef void (GLAPIENTRY * PFNGLROTATEXPROC) (GLfixed angle, GLfixed x, GLfixed y, GLfixed z);\r\ntypedef void (GLAPIENTRY * PFNGLSAMPLECOVERAGEXPROC) (GLclampx value, GLboolean invert);\r\ntypedef void (GLAPIENTRY * PFNGLSCALEXPROC) (GLfixed x, GLfixed y, GLfixed z);\r\ntypedef void (GLAPIENTRY * PFNGLTEXENVXPROC) (GLenum target, GLenum pname, GLfixed param);\r\ntypedef void (GLAPIENTRY * PFNGLTEXENVXVPROC) (GLenum target, GLenum pname, const GLfixed* params);\r\ntypedef void (GLAPIENTRY * PFNGLTEXPARAMETERXPROC) (GLenum target, GLenum pname, GLfixed param);\r\ntypedef void (GLAPIENTRY * PFNGLTRANSLATEXPROC) (GLfixed x, GLfixed y, GLfixed z);\r\n\r\n#define glAlphaFuncx GLEW_GET_FUN(__glewAlphaFuncx)\r\n#define glClearColorx GLEW_GET_FUN(__glewClearColorx)\r\n#define glClearDepthx GLEW_GET_FUN(__glewClearDepthx)\r\n#define glColor4x GLEW_GET_FUN(__glewColor4x)\r\n#define glDepthRangex GLEW_GET_FUN(__glewDepthRangex)\r\n#define glFogx GLEW_GET_FUN(__glewFogx)\r\n#define glFogxv GLEW_GET_FUN(__glewFogxv)\r\n#define glFrustumf GLEW_GET_FUN(__glewFrustumf)\r\n#define glFrustumx GLEW_GET_FUN(__glewFrustumx)\r\n#define glLightModelx GLEW_GET_FUN(__glewLightModelx)\r\n#define glLightModelxv GLEW_GET_FUN(__glewLightModelxv)\r\n#define glLightx GLEW_GET_FUN(__glewLightx)\r\n#define glLightxv GLEW_GET_FUN(__glewLightxv)\r\n#define glLineWidthx GLEW_GET_FUN(__glewLineWidthx)\r\n#define glLoadMatrixx GLEW_GET_FUN(__glewLoadMatrixx)\r\n#define glMaterialx GLEW_GET_FUN(__glewMaterialx)\r\n#define glMaterialxv GLEW_GET_FUN(__glewMaterialxv)\r\n#define glMultMatrixx GLEW_GET_FUN(__glewMultMatrixx)\r\n#define glMultiTexCoord4x GLEW_GET_FUN(__glewMultiTexCoord4x)\r\n#define glNormal3x GLEW_GET_FUN(__glewNormal3x)\r\n#define glOrthof GLEW_GET_FUN(__glewOrthof)\r\n#define glOrthox GLEW_GET_FUN(__glewOrthox)\r\n#define glPointSizex GLEW_GET_FUN(__glewPointSizex)\r\n#define glPolygonOffsetx GLEW_GET_FUN(__glewPolygonOffsetx)\r\n#define glRotatex GLEW_GET_FUN(__glewRotatex)\r\n#define glSampleCoveragex GLEW_GET_FUN(__glewSampleCoveragex)\r\n#define glScalex GLEW_GET_FUN(__glewScalex)\r\n#define glTexEnvx GLEW_GET_FUN(__glewTexEnvx)\r\n#define glTexEnvxv GLEW_GET_FUN(__glewTexEnvxv)\r\n#define glTexParameterx GLEW_GET_FUN(__glewTexParameterx)\r\n#define glTranslatex GLEW_GET_FUN(__glewTranslatex)\r\n\r\n#define GLEW_REGAL_ES1_0_compatibility GLEW_GET_VAR(__GLEW_REGAL_ES1_0_compatibility)\r\n\r\n#endif /* GL_REGAL_ES1_0_compatibility */\r\n\r\n/* ---------------------- GL_REGAL_ES1_1_compatibility --------------------- */\r\n\r\n#ifndef GL_REGAL_ES1_1_compatibility\r\n#define GL_REGAL_ES1_1_compatibility 1\r\n\r\ntypedef void (GLAPIENTRY * PFNGLCLIPPLANEFPROC) (GLenum plane, const GLfloat* equation);\r\ntypedef void (GLAPIENTRY * PFNGLCLIPPLANEXPROC) (GLenum plane, const GLfixed* equation);\r\ntypedef void (GLAPIENTRY * PFNGLGETCLIPPLANEFPROC) (GLenum pname, GLfloat eqn[4]);\r\ntypedef void (GLAPIENTRY * PFNGLGETCLIPPLANEXPROC) (GLenum pname, GLfixed eqn[4]);\r\ntypedef void (GLAPIENTRY * PFNGLGETFIXEDVPROC) (GLenum pname, GLfixed* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETLIGHTXVPROC) (GLenum light, GLenum pname, GLfixed* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETMATERIALXVPROC) (GLenum face, GLenum pname, GLfixed* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETTEXENVXVPROC) (GLenum env, GLenum pname, GLfixed* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETTEXPARAMETERXVPROC) (GLenum target, GLenum pname, GLfixed* params);\r\ntypedef void (GLAPIENTRY * PFNGLPOINTPARAMETERXPROC) (GLenum pname, GLfixed param);\r\ntypedef void (GLAPIENTRY * PFNGLPOINTPARAMETERXVPROC) (GLenum pname, const GLfixed* params);\r\ntypedef void (GLAPIENTRY * PFNGLPOINTSIZEPOINTEROESPROC) (GLenum type, GLsizei stride, const void *pointer);\r\ntypedef void (GLAPIENTRY * PFNGLTEXPARAMETERXVPROC) (GLenum target, GLenum pname, const GLfixed* params);\r\n\r\n#define glClipPlanef GLEW_GET_FUN(__glewClipPlanef)\r\n#define glClipPlanex GLEW_GET_FUN(__glewClipPlanex)\r\n#define glGetClipPlanef GLEW_GET_FUN(__glewGetClipPlanef)\r\n#define glGetClipPlanex GLEW_GET_FUN(__glewGetClipPlanex)\r\n#define glGetFixedv GLEW_GET_FUN(__glewGetFixedv)\r\n#define glGetLightxv GLEW_GET_FUN(__glewGetLightxv)\r\n#define glGetMaterialxv GLEW_GET_FUN(__glewGetMaterialxv)\r\n#define glGetTexEnvxv GLEW_GET_FUN(__glewGetTexEnvxv)\r\n#define glGetTexParameterxv GLEW_GET_FUN(__glewGetTexParameterxv)\r\n#define glPointParameterx GLEW_GET_FUN(__glewPointParameterx)\r\n#define glPointParameterxv GLEW_GET_FUN(__glewPointParameterxv)\r\n#define glPointSizePointerOES GLEW_GET_FUN(__glewPointSizePointerOES)\r\n#define glTexParameterxv GLEW_GET_FUN(__glewTexParameterxv)\r\n\r\n#define GLEW_REGAL_ES1_1_compatibility GLEW_GET_VAR(__GLEW_REGAL_ES1_1_compatibility)\r\n\r\n#endif /* GL_REGAL_ES1_1_compatibility */\r\n\r\n/* ---------------------------- GL_REGAL_enable ---------------------------- */\r\n\r\n#ifndef GL_REGAL_enable\r\n#define GL_REGAL_enable 1\r\n\r\n#define GL_ERROR_REGAL 0x9322\r\n#define GL_DEBUG_REGAL 0x9323\r\n#define GL_LOG_REGAL 0x9324\r\n#define GL_EMULATION_REGAL 0x9325\r\n#define GL_DRIVER_REGAL 0x9326\r\n#define GL_MISSING_REGAL 0x9360\r\n#define GL_TRACE_REGAL 0x9361\r\n#define GL_CACHE_REGAL 0x9362\r\n#define GL_CODE_REGAL 0x9363\r\n#define GL_STATISTICS_REGAL 0x9364\r\n\r\n#define GLEW_REGAL_enable GLEW_GET_VAR(__GLEW_REGAL_enable)\r\n\r\n#endif /* GL_REGAL_enable */\r\n\r\n/* ------------------------- GL_REGAL_error_string ------------------------- */\r\n\r\n#ifndef GL_REGAL_error_string\r\n#define GL_REGAL_error_string 1\r\n\r\ntypedef const GLchar* (GLAPIENTRY * PFNGLERRORSTRINGREGALPROC) (GLenum error);\r\n\r\n#define glErrorStringREGAL GLEW_GET_FUN(__glewErrorStringREGAL)\r\n\r\n#define GLEW_REGAL_error_string GLEW_GET_VAR(__GLEW_REGAL_error_string)\r\n\r\n#endif /* GL_REGAL_error_string */\r\n\r\n/* ------------------------ GL_REGAL_extension_query ----------------------- */\r\n\r\n#ifndef GL_REGAL_extension_query\r\n#define GL_REGAL_extension_query 1\r\n\r\ntypedef GLboolean (GLAPIENTRY * PFNGLGETEXTENSIONREGALPROC) (const GLchar* ext);\r\ntypedef GLboolean (GLAPIENTRY * PFNGLISSUPPORTEDREGALPROC) (const GLchar* ext);\r\n\r\n#define glGetExtensionREGAL GLEW_GET_FUN(__glewGetExtensionREGAL)\r\n#define glIsSupportedREGAL GLEW_GET_FUN(__glewIsSupportedREGAL)\r\n\r\n#define GLEW_REGAL_extension_query GLEW_GET_VAR(__GLEW_REGAL_extension_query)\r\n\r\n#endif /* GL_REGAL_extension_query */\r\n\r\n/* ------------------------------ GL_REGAL_log ----------------------------- */\r\n\r\n#ifndef GL_REGAL_log\r\n#define GL_REGAL_log 1\r\n\r\n#define GL_LOG_ERROR_REGAL 0x9319\r\n#define GL_LOG_WARNING_REGAL 0x931A\r\n#define GL_LOG_INFO_REGAL 0x931B\r\n#define GL_LOG_APP_REGAL 0x931C\r\n#define GL_LOG_DRIVER_REGAL 0x931D\r\n#define GL_LOG_INTERNAL_REGAL 0x931E\r\n#define GL_LOG_DEBUG_REGAL 0x931F\r\n#define GL_LOG_STATUS_REGAL 0x9320\r\n#define GL_LOG_HTTP_REGAL 0x9321\r\n\r\ntypedef void (APIENTRY *GLLOGPROCREGAL)(GLenum stream, GLsizei length, const GLchar *message, void *context);\r\n\r\ntypedef void (GLAPIENTRY * PFNGLLOGMESSAGECALLBACKREGALPROC) (GLLOGPROCREGAL callback);\r\n\r\n#define glLogMessageCallbackREGAL GLEW_GET_FUN(__glewLogMessageCallbackREGAL)\r\n\r\n#define GLEW_REGAL_log GLEW_GET_VAR(__GLEW_REGAL_log)\r\n\r\n#endif /* GL_REGAL_log */\r\n\r\n/* ------------------------- GL_REGAL_proc_address ------------------------- */\r\n\r\n#ifndef GL_REGAL_proc_address\r\n#define GL_REGAL_proc_address 1\r\n\r\ntypedef void * (GLAPIENTRY * PFNGLGETPROCADDRESSREGALPROC) (const GLchar *name);\r\n\r\n#define glGetProcAddressREGAL GLEW_GET_FUN(__glewGetProcAddressREGAL)\r\n\r\n#define GLEW_REGAL_proc_address GLEW_GET_VAR(__GLEW_REGAL_proc_address)\r\n\r\n#endif /* GL_REGAL_proc_address */\r\n\r\n/* ----------------------- GL_REND_screen_coordinates ---------------------- */\r\n\r\n#ifndef GL_REND_screen_coordinates\r\n#define GL_REND_screen_coordinates 1\r\n\r\n#define GL_SCREEN_COORDINATES_REND 0x8490\r\n#define GL_INVERTED_SCREEN_W_REND 0x8491\r\n\r\n#define GLEW_REND_screen_coordinates GLEW_GET_VAR(__GLEW_REND_screen_coordinates)\r\n\r\n#endif /* GL_REND_screen_coordinates */\r\n\r\n/* ------------------------------- GL_S3_s3tc ------------------------------ */\r\n\r\n#ifndef GL_S3_s3tc\r\n#define GL_S3_s3tc 1\r\n\r\n#define GL_RGB_S3TC 0x83A0\r\n#define GL_RGB4_S3TC 0x83A1\r\n#define GL_RGBA_S3TC 0x83A2\r\n#define GL_RGBA4_S3TC 0x83A3\r\n#define GL_RGBA_DXT5_S3TC 0x83A4\r\n#define GL_RGBA4_DXT5_S3TC 0x83A5\r\n\r\n#define GLEW_S3_s3tc GLEW_GET_VAR(__GLEW_S3_s3tc)\r\n\r\n#endif /* GL_S3_s3tc */\r\n\r\n/* -------------------------- GL_SGIS_color_range -------------------------- */\r\n\r\n#ifndef GL_SGIS_color_range\r\n#define GL_SGIS_color_range 1\r\n\r\n#define GL_EXTENDED_RANGE_SGIS 0x85A5\r\n#define GL_MIN_RED_SGIS 0x85A6\r\n#define GL_MAX_RED_SGIS 0x85A7\r\n#define GL_MIN_GREEN_SGIS 0x85A8\r\n#define GL_MAX_GREEN_SGIS 0x85A9\r\n#define GL_MIN_BLUE_SGIS 0x85AA\r\n#define GL_MAX_BLUE_SGIS 0x85AB\r\n#define GL_MIN_ALPHA_SGIS 0x85AC\r\n#define GL_MAX_ALPHA_SGIS 0x85AD\r\n\r\n#define GLEW_SGIS_color_range GLEW_GET_VAR(__GLEW_SGIS_color_range)\r\n\r\n#endif /* GL_SGIS_color_range */\r\n\r\n/* ------------------------- GL_SGIS_detail_texture ------------------------ */\r\n\r\n#ifndef GL_SGIS_detail_texture\r\n#define GL_SGIS_detail_texture 1\r\n\r\ntypedef void (GLAPIENTRY * PFNGLDETAILTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat* points);\r\ntypedef void (GLAPIENTRY * PFNGLGETDETAILTEXFUNCSGISPROC) (GLenum target, GLfloat* points);\r\n\r\n#define glDetailTexFuncSGIS GLEW_GET_FUN(__glewDetailTexFuncSGIS)\r\n#define glGetDetailTexFuncSGIS GLEW_GET_FUN(__glewGetDetailTexFuncSGIS)\r\n\r\n#define GLEW_SGIS_detail_texture GLEW_GET_VAR(__GLEW_SGIS_detail_texture)\r\n\r\n#endif /* GL_SGIS_detail_texture */\r\n\r\n/* -------------------------- GL_SGIS_fog_function ------------------------- */\r\n\r\n#ifndef GL_SGIS_fog_function\r\n#define GL_SGIS_fog_function 1\r\n\r\ntypedef void (GLAPIENTRY * PFNGLFOGFUNCSGISPROC) (GLsizei n, const GLfloat* points);\r\ntypedef void (GLAPIENTRY * PFNGLGETFOGFUNCSGISPROC) (GLfloat* points);\r\n\r\n#define glFogFuncSGIS GLEW_GET_FUN(__glewFogFuncSGIS)\r\n#define glGetFogFuncSGIS GLEW_GET_FUN(__glewGetFogFuncSGIS)\r\n\r\n#define GLEW_SGIS_fog_function GLEW_GET_VAR(__GLEW_SGIS_fog_function)\r\n\r\n#endif /* GL_SGIS_fog_function */\r\n\r\n/* ------------------------ GL_SGIS_generate_mipmap ------------------------ */\r\n\r\n#ifndef GL_SGIS_generate_mipmap\r\n#define GL_SGIS_generate_mipmap 1\r\n\r\n#define GL_GENERATE_MIPMAP_SGIS 0x8191\r\n#define GL_GENERATE_MIPMAP_HINT_SGIS 0x8192\r\n\r\n#define GLEW_SGIS_generate_mipmap GLEW_GET_VAR(__GLEW_SGIS_generate_mipmap)\r\n\r\n#endif /* GL_SGIS_generate_mipmap */\r\n\r\n/* -------------------------- GL_SGIS_multisample -------------------------- */\r\n\r\n#ifndef GL_SGIS_multisample\r\n#define GL_SGIS_multisample 1\r\n\r\n#define GL_MULTISAMPLE_SGIS 0x809D\r\n#define GL_SAMPLE_ALPHA_TO_MASK_SGIS 0x809E\r\n#define GL_SAMPLE_ALPHA_TO_ONE_SGIS 0x809F\r\n#define GL_SAMPLE_MASK_SGIS 0x80A0\r\n#define GL_1PASS_SGIS 0x80A1\r\n#define GL_2PASS_0_SGIS 0x80A2\r\n#define GL_2PASS_1_SGIS 0x80A3\r\n#define GL_4PASS_0_SGIS 0x80A4\r\n#define GL_4PASS_1_SGIS 0x80A5\r\n#define GL_4PASS_2_SGIS 0x80A6\r\n#define GL_4PASS_3_SGIS 0x80A7\r\n#define GL_SAMPLE_BUFFERS_SGIS 0x80A8\r\n#define GL_SAMPLES_SGIS 0x80A9\r\n#define GL_SAMPLE_MASK_VALUE_SGIS 0x80AA\r\n#define GL_SAMPLE_MASK_INVERT_SGIS 0x80AB\r\n#define GL_SAMPLE_PATTERN_SGIS 0x80AC\r\n\r\ntypedef void (GLAPIENTRY * PFNGLSAMPLEMASKSGISPROC) (GLclampf value, GLboolean invert);\r\ntypedef void (GLAPIENTRY * PFNGLSAMPLEPATTERNSGISPROC) (GLenum pattern);\r\n\r\n#define glSampleMaskSGIS GLEW_GET_FUN(__glewSampleMaskSGIS)\r\n#define glSamplePatternSGIS GLEW_GET_FUN(__glewSamplePatternSGIS)\r\n\r\n#define GLEW_SGIS_multisample GLEW_GET_VAR(__GLEW_SGIS_multisample)\r\n\r\n#endif /* GL_SGIS_multisample */\r\n\r\n/* ------------------------- GL_SGIS_pixel_texture ------------------------- */\r\n\r\n#ifndef GL_SGIS_pixel_texture\r\n#define GL_SGIS_pixel_texture 1\r\n\r\n#define GLEW_SGIS_pixel_texture GLEW_GET_VAR(__GLEW_SGIS_pixel_texture)\r\n\r\n#endif /* GL_SGIS_pixel_texture */\r\n\r\n/* ----------------------- GL_SGIS_point_line_texgen ----------------------- */\r\n\r\n#ifndef GL_SGIS_point_line_texgen\r\n#define GL_SGIS_point_line_texgen 1\r\n\r\n#define GL_EYE_DISTANCE_TO_POINT_SGIS 0x81F0\r\n#define GL_OBJECT_DISTANCE_TO_POINT_SGIS 0x81F1\r\n#define GL_EYE_DISTANCE_TO_LINE_SGIS 0x81F2\r\n#define GL_OBJECT_DISTANCE_TO_LINE_SGIS 0x81F3\r\n#define GL_EYE_POINT_SGIS 0x81F4\r\n#define GL_OBJECT_POINT_SGIS 0x81F5\r\n#define GL_EYE_LINE_SGIS 0x81F6\r\n#define GL_OBJECT_LINE_SGIS 0x81F7\r\n\r\n#define GLEW_SGIS_point_line_texgen GLEW_GET_VAR(__GLEW_SGIS_point_line_texgen)\r\n\r\n#endif /* GL_SGIS_point_line_texgen */\r\n\r\n/* ------------------------ GL_SGIS_sharpen_texture ------------------------ */\r\n\r\n#ifndef GL_SGIS_sharpen_texture\r\n#define GL_SGIS_sharpen_texture 1\r\n\r\ntypedef void (GLAPIENTRY * PFNGLGETSHARPENTEXFUNCSGISPROC) (GLenum target, GLfloat* points);\r\ntypedef void (GLAPIENTRY * PFNGLSHARPENTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat* points);\r\n\r\n#define glGetSharpenTexFuncSGIS GLEW_GET_FUN(__glewGetSharpenTexFuncSGIS)\r\n#define glSharpenTexFuncSGIS GLEW_GET_FUN(__glewSharpenTexFuncSGIS)\r\n\r\n#define GLEW_SGIS_sharpen_texture GLEW_GET_VAR(__GLEW_SGIS_sharpen_texture)\r\n\r\n#endif /* GL_SGIS_sharpen_texture */\r\n\r\n/* --------------------------- GL_SGIS_texture4D --------------------------- */\r\n\r\n#ifndef GL_SGIS_texture4D\r\n#define GL_SGIS_texture4D 1\r\n\r\ntypedef void (GLAPIENTRY * PFNGLTEXIMAGE4DSGISPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLsizei extent, GLint border, GLenum format, GLenum type, const void *pixels);\r\ntypedef void (GLAPIENTRY * PFNGLTEXSUBIMAGE4DSGISPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint woffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei extent, GLenum format, GLenum type, const void *pixels);\r\n\r\n#define glTexImage4DSGIS GLEW_GET_FUN(__glewTexImage4DSGIS)\r\n#define glTexSubImage4DSGIS GLEW_GET_FUN(__glewTexSubImage4DSGIS)\r\n\r\n#define GLEW_SGIS_texture4D GLEW_GET_VAR(__GLEW_SGIS_texture4D)\r\n\r\n#endif /* GL_SGIS_texture4D */\r\n\r\n/* ---------------------- GL_SGIS_texture_border_clamp --------------------- */\r\n\r\n#ifndef GL_SGIS_texture_border_clamp\r\n#define GL_SGIS_texture_border_clamp 1\r\n\r\n#define GL_CLAMP_TO_BORDER_SGIS 0x812D\r\n\r\n#define GLEW_SGIS_texture_border_clamp GLEW_GET_VAR(__GLEW_SGIS_texture_border_clamp)\r\n\r\n#endif /* GL_SGIS_texture_border_clamp */\r\n\r\n/* ----------------------- GL_SGIS_texture_edge_clamp ---------------------- */\r\n\r\n#ifndef GL_SGIS_texture_edge_clamp\r\n#define GL_SGIS_texture_edge_clamp 1\r\n\r\n#define GL_CLAMP_TO_EDGE_SGIS 0x812F\r\n\r\n#define GLEW_SGIS_texture_edge_clamp GLEW_GET_VAR(__GLEW_SGIS_texture_edge_clamp)\r\n\r\n#endif /* GL_SGIS_texture_edge_clamp */\r\n\r\n/* ------------------------ GL_SGIS_texture_filter4 ------------------------ */\r\n\r\n#ifndef GL_SGIS_texture_filter4\r\n#define GL_SGIS_texture_filter4 1\r\n\r\ntypedef void (GLAPIENTRY * PFNGLGETTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLfloat* weights);\r\ntypedef void (GLAPIENTRY * PFNGLTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLsizei n, const GLfloat* weights);\r\n\r\n#define glGetTexFilterFuncSGIS GLEW_GET_FUN(__glewGetTexFilterFuncSGIS)\r\n#define glTexFilterFuncSGIS GLEW_GET_FUN(__glewTexFilterFuncSGIS)\r\n\r\n#define GLEW_SGIS_texture_filter4 GLEW_GET_VAR(__GLEW_SGIS_texture_filter4)\r\n\r\n#endif /* GL_SGIS_texture_filter4 */\r\n\r\n/* -------------------------- GL_SGIS_texture_lod -------------------------- */\r\n\r\n#ifndef GL_SGIS_texture_lod\r\n#define GL_SGIS_texture_lod 1\r\n\r\n#define GL_TEXTURE_MIN_LOD_SGIS 0x813A\r\n#define GL_TEXTURE_MAX_LOD_SGIS 0x813B\r\n#define GL_TEXTURE_BASE_LEVEL_SGIS 0x813C\r\n#define GL_TEXTURE_MAX_LEVEL_SGIS 0x813D\r\n\r\n#define GLEW_SGIS_texture_lod GLEW_GET_VAR(__GLEW_SGIS_texture_lod)\r\n\r\n#endif /* GL_SGIS_texture_lod */\r\n\r\n/* ------------------------- GL_SGIS_texture_select ------------------------ */\r\n\r\n#ifndef GL_SGIS_texture_select\r\n#define GL_SGIS_texture_select 1\r\n\r\n#define GLEW_SGIS_texture_select GLEW_GET_VAR(__GLEW_SGIS_texture_select)\r\n\r\n#endif /* GL_SGIS_texture_select */\r\n\r\n/* ----------------------------- GL_SGIX_async ----------------------------- */\r\n\r\n#ifndef GL_SGIX_async\r\n#define GL_SGIX_async 1\r\n\r\n#define GL_ASYNC_MARKER_SGIX 0x8329\r\n\r\ntypedef void (GLAPIENTRY * PFNGLASYNCMARKERSGIXPROC) (GLuint marker);\r\ntypedef void (GLAPIENTRY * PFNGLDELETEASYNCMARKERSSGIXPROC) (GLuint marker, GLsizei range);\r\ntypedef GLint (GLAPIENTRY * PFNGLFINISHASYNCSGIXPROC) (GLuint* markerp);\r\ntypedef GLuint (GLAPIENTRY * PFNGLGENASYNCMARKERSSGIXPROC) (GLsizei range);\r\ntypedef GLboolean (GLAPIENTRY * PFNGLISASYNCMARKERSGIXPROC) (GLuint marker);\r\ntypedef GLint (GLAPIENTRY * PFNGLPOLLASYNCSGIXPROC) (GLuint* markerp);\r\n\r\n#define glAsyncMarkerSGIX GLEW_GET_FUN(__glewAsyncMarkerSGIX)\r\n#define glDeleteAsyncMarkersSGIX GLEW_GET_FUN(__glewDeleteAsyncMarkersSGIX)\r\n#define glFinishAsyncSGIX GLEW_GET_FUN(__glewFinishAsyncSGIX)\r\n#define glGenAsyncMarkersSGIX GLEW_GET_FUN(__glewGenAsyncMarkersSGIX)\r\n#define glIsAsyncMarkerSGIX GLEW_GET_FUN(__glewIsAsyncMarkerSGIX)\r\n#define glPollAsyncSGIX GLEW_GET_FUN(__glewPollAsyncSGIX)\r\n\r\n#define GLEW_SGIX_async GLEW_GET_VAR(__GLEW_SGIX_async)\r\n\r\n#endif /* GL_SGIX_async */\r\n\r\n/* ------------------------ GL_SGIX_async_histogram ------------------------ */\r\n\r\n#ifndef GL_SGIX_async_histogram\r\n#define GL_SGIX_async_histogram 1\r\n\r\n#define GL_ASYNC_HISTOGRAM_SGIX 0x832C\r\n#define GL_MAX_ASYNC_HISTOGRAM_SGIX 0x832D\r\n\r\n#define GLEW_SGIX_async_histogram GLEW_GET_VAR(__GLEW_SGIX_async_histogram)\r\n\r\n#endif /* GL_SGIX_async_histogram */\r\n\r\n/* -------------------------- GL_SGIX_async_pixel -------------------------- */\r\n\r\n#ifndef GL_SGIX_async_pixel\r\n#define GL_SGIX_async_pixel 1\r\n\r\n#define GL_ASYNC_TEX_IMAGE_SGIX 0x835C\r\n#define GL_ASYNC_DRAW_PIXELS_SGIX 0x835D\r\n#define GL_ASYNC_READ_PIXELS_SGIX 0x835E\r\n#define GL_MAX_ASYNC_TEX_IMAGE_SGIX 0x835F\r\n#define GL_MAX_ASYNC_DRAW_PIXELS_SGIX 0x8360\r\n#define GL_MAX_ASYNC_READ_PIXELS_SGIX 0x8361\r\n\r\n#define GLEW_SGIX_async_pixel GLEW_GET_VAR(__GLEW_SGIX_async_pixel)\r\n\r\n#endif /* GL_SGIX_async_pixel */\r\n\r\n/* ----------------------- GL_SGIX_blend_alpha_minmax ---------------------- */\r\n\r\n#ifndef GL_SGIX_blend_alpha_minmax\r\n#define GL_SGIX_blend_alpha_minmax 1\r\n\r\n#define GL_ALPHA_MIN_SGIX 0x8320\r\n#define GL_ALPHA_MAX_SGIX 0x8321\r\n\r\n#define GLEW_SGIX_blend_alpha_minmax GLEW_GET_VAR(__GLEW_SGIX_blend_alpha_minmax)\r\n\r\n#endif /* GL_SGIX_blend_alpha_minmax */\r\n\r\n/* ---------------------------- GL_SGIX_clipmap ---------------------------- */\r\n\r\n#ifndef GL_SGIX_clipmap\r\n#define GL_SGIX_clipmap 1\r\n\r\n#define GLEW_SGIX_clipmap GLEW_GET_VAR(__GLEW_SGIX_clipmap)\r\n\r\n#endif /* GL_SGIX_clipmap */\r\n\r\n/* ---------------------- GL_SGIX_convolution_accuracy --------------------- */\r\n\r\n#ifndef GL_SGIX_convolution_accuracy\r\n#define GL_SGIX_convolution_accuracy 1\r\n\r\n#define GL_CONVOLUTION_HINT_SGIX 0x8316\r\n\r\n#define GLEW_SGIX_convolution_accuracy GLEW_GET_VAR(__GLEW_SGIX_convolution_accuracy)\r\n\r\n#endif /* GL_SGIX_convolution_accuracy */\r\n\r\n/* ------------------------- GL_SGIX_depth_texture ------------------------- */\r\n\r\n#ifndef GL_SGIX_depth_texture\r\n#define GL_SGIX_depth_texture 1\r\n\r\n#define GL_DEPTH_COMPONENT16_SGIX 0x81A5\r\n#define GL_DEPTH_COMPONENT24_SGIX 0x81A6\r\n#define GL_DEPTH_COMPONENT32_SGIX 0x81A7\r\n\r\n#define GLEW_SGIX_depth_texture GLEW_GET_VAR(__GLEW_SGIX_depth_texture)\r\n\r\n#endif /* GL_SGIX_depth_texture */\r\n\r\n/* -------------------------- GL_SGIX_flush_raster ------------------------- */\r\n\r\n#ifndef GL_SGIX_flush_raster\r\n#define GL_SGIX_flush_raster 1\r\n\r\ntypedef void (GLAPIENTRY * PFNGLFLUSHRASTERSGIXPROC) (void);\r\n\r\n#define glFlushRasterSGIX GLEW_GET_FUN(__glewFlushRasterSGIX)\r\n\r\n#define GLEW_SGIX_flush_raster GLEW_GET_VAR(__GLEW_SGIX_flush_raster)\r\n\r\n#endif /* GL_SGIX_flush_raster */\r\n\r\n/* --------------------------- GL_SGIX_fog_offset -------------------------- */\r\n\r\n#ifndef GL_SGIX_fog_offset\r\n#define GL_SGIX_fog_offset 1\r\n\r\n#define GL_FOG_OFFSET_SGIX 0x8198\r\n#define GL_FOG_OFFSET_VALUE_SGIX 0x8199\r\n\r\n#define GLEW_SGIX_fog_offset GLEW_GET_VAR(__GLEW_SGIX_fog_offset)\r\n\r\n#endif /* GL_SGIX_fog_offset */\r\n\r\n/* -------------------------- GL_SGIX_fog_texture -------------------------- */\r\n\r\n#ifndef GL_SGIX_fog_texture\r\n#define GL_SGIX_fog_texture 1\r\n\r\n#define GL_FOG_PATCHY_FACTOR_SGIX 0\r\n#define GL_FRAGMENT_FOG_SGIX 0\r\n#define GL_TEXTURE_FOG_SGIX 0\r\n\r\ntypedef void (GLAPIENTRY * PFNGLTEXTUREFOGSGIXPROC) (GLenum pname);\r\n\r\n#define glTextureFogSGIX GLEW_GET_FUN(__glewTextureFogSGIX)\r\n\r\n#define GLEW_SGIX_fog_texture GLEW_GET_VAR(__GLEW_SGIX_fog_texture)\r\n\r\n#endif /* GL_SGIX_fog_texture */\r\n\r\n/* ------------------- GL_SGIX_fragment_specular_lighting ------------------ */\r\n\r\n#ifndef GL_SGIX_fragment_specular_lighting\r\n#define GL_SGIX_fragment_specular_lighting 1\r\n\r\ntypedef void (GLAPIENTRY * PFNGLFRAGMENTCOLORMATERIALSGIXPROC) (GLenum face, GLenum mode);\r\ntypedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTMODELFSGIXPROC) (GLenum pname, GLfloat param);\r\ntypedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTMODELFVSGIXPROC) (GLenum pname, GLfloat* params);\r\ntypedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTMODELISGIXPROC) (GLenum pname, GLint param);\r\ntypedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTMODELIVSGIXPROC) (GLenum pname, GLint* params);\r\ntypedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTFSGIXPROC) (GLenum light, GLenum pname, GLfloat param);\r\ntypedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, GLfloat* params);\r\ntypedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTISGIXPROC) (GLenum light, GLenum pname, GLint param);\r\ntypedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, GLint* params);\r\ntypedef void (GLAPIENTRY * PFNGLFRAGMENTMATERIALFSGIXPROC) (GLenum face, GLenum pname, const GLfloat param);\r\ntypedef void (GLAPIENTRY * PFNGLFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, const GLfloat* params);\r\ntypedef void (GLAPIENTRY * PFNGLFRAGMENTMATERIALISGIXPROC) (GLenum face, GLenum pname, const GLint param);\r\ntypedef void (GLAPIENTRY * PFNGLFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, const GLint* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum value, GLfloat* data);\r\ntypedef void (GLAPIENTRY * PFNGLGETFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum value, GLint* data);\r\ntypedef void (GLAPIENTRY * PFNGLGETFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, const GLfloat* data);\r\ntypedef void (GLAPIENTRY * PFNGLGETFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, const GLint* data);\r\n\r\n#define glFragmentColorMaterialSGIX GLEW_GET_FUN(__glewFragmentColorMaterialSGIX)\r\n#define glFragmentLightModelfSGIX GLEW_GET_FUN(__glewFragmentLightModelfSGIX)\r\n#define glFragmentLightModelfvSGIX GLEW_GET_FUN(__glewFragmentLightModelfvSGIX)\r\n#define glFragmentLightModeliSGIX GLEW_GET_FUN(__glewFragmentLightModeliSGIX)\r\n#define glFragmentLightModelivSGIX GLEW_GET_FUN(__glewFragmentLightModelivSGIX)\r\n#define glFragmentLightfSGIX GLEW_GET_FUN(__glewFragmentLightfSGIX)\r\n#define glFragmentLightfvSGIX GLEW_GET_FUN(__glewFragmentLightfvSGIX)\r\n#define glFragmentLightiSGIX GLEW_GET_FUN(__glewFragmentLightiSGIX)\r\n#define glFragmentLightivSGIX GLEW_GET_FUN(__glewFragmentLightivSGIX)\r\n#define glFragmentMaterialfSGIX GLEW_GET_FUN(__glewFragmentMaterialfSGIX)\r\n#define glFragmentMaterialfvSGIX GLEW_GET_FUN(__glewFragmentMaterialfvSGIX)\r\n#define glFragmentMaterialiSGIX GLEW_GET_FUN(__glewFragmentMaterialiSGIX)\r\n#define glFragmentMaterialivSGIX GLEW_GET_FUN(__glewFragmentMaterialivSGIX)\r\n#define glGetFragmentLightfvSGIX GLEW_GET_FUN(__glewGetFragmentLightfvSGIX)\r\n#define glGetFragmentLightivSGIX GLEW_GET_FUN(__glewGetFragmentLightivSGIX)\r\n#define glGetFragmentMaterialfvSGIX GLEW_GET_FUN(__glewGetFragmentMaterialfvSGIX)\r\n#define glGetFragmentMaterialivSGIX GLEW_GET_FUN(__glewGetFragmentMaterialivSGIX)\r\n\r\n#define GLEW_SGIX_fragment_specular_lighting GLEW_GET_VAR(__GLEW_SGIX_fragment_specular_lighting)\r\n\r\n#endif /* GL_SGIX_fragment_specular_lighting */\r\n\r\n/* --------------------------- GL_SGIX_framezoom --------------------------- */\r\n\r\n#ifndef GL_SGIX_framezoom\r\n#define GL_SGIX_framezoom 1\r\n\r\ntypedef void (GLAPIENTRY * PFNGLFRAMEZOOMSGIXPROC) (GLint factor);\r\n\r\n#define glFrameZoomSGIX GLEW_GET_FUN(__glewFrameZoomSGIX)\r\n\r\n#define GLEW_SGIX_framezoom GLEW_GET_VAR(__GLEW_SGIX_framezoom)\r\n\r\n#endif /* GL_SGIX_framezoom */\r\n\r\n/* --------------------------- GL_SGIX_interlace --------------------------- */\r\n\r\n#ifndef GL_SGIX_interlace\r\n#define GL_SGIX_interlace 1\r\n\r\n#define GL_INTERLACE_SGIX 0x8094\r\n\r\n#define GLEW_SGIX_interlace GLEW_GET_VAR(__GLEW_SGIX_interlace)\r\n\r\n#endif /* GL_SGIX_interlace */\r\n\r\n/* ------------------------- GL_SGIX_ir_instrument1 ------------------------ */\r\n\r\n#ifndef GL_SGIX_ir_instrument1\r\n#define GL_SGIX_ir_instrument1 1\r\n\r\n#define GLEW_SGIX_ir_instrument1 GLEW_GET_VAR(__GLEW_SGIX_ir_instrument1)\r\n\r\n#endif /* GL_SGIX_ir_instrument1 */\r\n\r\n/* ------------------------- GL_SGIX_list_priority ------------------------- */\r\n\r\n#ifndef GL_SGIX_list_priority\r\n#define GL_SGIX_list_priority 1\r\n\r\n#define GLEW_SGIX_list_priority GLEW_GET_VAR(__GLEW_SGIX_list_priority)\r\n\r\n#endif /* GL_SGIX_list_priority */\r\n\r\n/* ------------------------- GL_SGIX_pixel_texture ------------------------- */\r\n\r\n#ifndef GL_SGIX_pixel_texture\r\n#define GL_SGIX_pixel_texture 1\r\n\r\ntypedef void (GLAPIENTRY * PFNGLPIXELTEXGENSGIXPROC) (GLenum mode);\r\n\r\n#define glPixelTexGenSGIX GLEW_GET_FUN(__glewPixelTexGenSGIX)\r\n\r\n#define GLEW_SGIX_pixel_texture GLEW_GET_VAR(__GLEW_SGIX_pixel_texture)\r\n\r\n#endif /* GL_SGIX_pixel_texture */\r\n\r\n/* ----------------------- GL_SGIX_pixel_texture_bits ---------------------- */\r\n\r\n#ifndef GL_SGIX_pixel_texture_bits\r\n#define GL_SGIX_pixel_texture_bits 1\r\n\r\n#define GLEW_SGIX_pixel_texture_bits GLEW_GET_VAR(__GLEW_SGIX_pixel_texture_bits)\r\n\r\n#endif /* GL_SGIX_pixel_texture_bits */\r\n\r\n/* ------------------------ GL_SGIX_reference_plane ------------------------ */\r\n\r\n#ifndef GL_SGIX_reference_plane\r\n#define GL_SGIX_reference_plane 1\r\n\r\ntypedef void (GLAPIENTRY * PFNGLREFERENCEPLANESGIXPROC) (const GLdouble* equation);\r\n\r\n#define glReferencePlaneSGIX GLEW_GET_FUN(__glewReferencePlaneSGIX)\r\n\r\n#define GLEW_SGIX_reference_plane GLEW_GET_VAR(__GLEW_SGIX_reference_plane)\r\n\r\n#endif /* GL_SGIX_reference_plane */\r\n\r\n/* ---------------------------- GL_SGIX_resample --------------------------- */\r\n\r\n#ifndef GL_SGIX_resample\r\n#define GL_SGIX_resample 1\r\n\r\n#define GL_PACK_RESAMPLE_SGIX 0x842E\r\n#define GL_UNPACK_RESAMPLE_SGIX 0x842F\r\n#define GL_RESAMPLE_DECIMATE_SGIX 0x8430\r\n#define GL_RESAMPLE_REPLICATE_SGIX 0x8433\r\n#define GL_RESAMPLE_ZERO_FILL_SGIX 0x8434\r\n\r\n#define GLEW_SGIX_resample GLEW_GET_VAR(__GLEW_SGIX_resample)\r\n\r\n#endif /* GL_SGIX_resample */\r\n\r\n/* ----------------------------- GL_SGIX_shadow ---------------------------- */\r\n\r\n#ifndef GL_SGIX_shadow\r\n#define GL_SGIX_shadow 1\r\n\r\n#define GL_TEXTURE_COMPARE_SGIX 0x819A\r\n#define GL_TEXTURE_COMPARE_OPERATOR_SGIX 0x819B\r\n#define GL_TEXTURE_LEQUAL_R_SGIX 0x819C\r\n#define GL_TEXTURE_GEQUAL_R_SGIX 0x819D\r\n\r\n#define GLEW_SGIX_shadow GLEW_GET_VAR(__GLEW_SGIX_shadow)\r\n\r\n#endif /* GL_SGIX_shadow */\r\n\r\n/* ------------------------- GL_SGIX_shadow_ambient ------------------------ */\r\n\r\n#ifndef GL_SGIX_shadow_ambient\r\n#define GL_SGIX_shadow_ambient 1\r\n\r\n#define GL_SHADOW_AMBIENT_SGIX 0x80BF\r\n\r\n#define GLEW_SGIX_shadow_ambient GLEW_GET_VAR(__GLEW_SGIX_shadow_ambient)\r\n\r\n#endif /* GL_SGIX_shadow_ambient */\r\n\r\n/* ----------------------------- GL_SGIX_sprite ---------------------------- */\r\n\r\n#ifndef GL_SGIX_sprite\r\n#define GL_SGIX_sprite 1\r\n\r\ntypedef void (GLAPIENTRY * PFNGLSPRITEPARAMETERFSGIXPROC) (GLenum pname, GLfloat param);\r\ntypedef void (GLAPIENTRY * PFNGLSPRITEPARAMETERFVSGIXPROC) (GLenum pname, GLfloat* params);\r\ntypedef void (GLAPIENTRY * PFNGLSPRITEPARAMETERISGIXPROC) (GLenum pname, GLint param);\r\ntypedef void (GLAPIENTRY * PFNGLSPRITEPARAMETERIVSGIXPROC) (GLenum pname, GLint* params);\r\n\r\n#define glSpriteParameterfSGIX GLEW_GET_FUN(__glewSpriteParameterfSGIX)\r\n#define glSpriteParameterfvSGIX GLEW_GET_FUN(__glewSpriteParameterfvSGIX)\r\n#define glSpriteParameteriSGIX GLEW_GET_FUN(__glewSpriteParameteriSGIX)\r\n#define glSpriteParameterivSGIX GLEW_GET_FUN(__glewSpriteParameterivSGIX)\r\n\r\n#define GLEW_SGIX_sprite GLEW_GET_VAR(__GLEW_SGIX_sprite)\r\n\r\n#endif /* GL_SGIX_sprite */\r\n\r\n/* ----------------------- GL_SGIX_tag_sample_buffer ----------------------- */\r\n\r\n#ifndef GL_SGIX_tag_sample_buffer\r\n#define GL_SGIX_tag_sample_buffer 1\r\n\r\ntypedef void (GLAPIENTRY * PFNGLTAGSAMPLEBUFFERSGIXPROC) (void);\r\n\r\n#define glTagSampleBufferSGIX GLEW_GET_FUN(__glewTagSampleBufferSGIX)\r\n\r\n#define GLEW_SGIX_tag_sample_buffer GLEW_GET_VAR(__GLEW_SGIX_tag_sample_buffer)\r\n\r\n#endif /* GL_SGIX_tag_sample_buffer */\r\n\r\n/* ------------------------ GL_SGIX_texture_add_env ------------------------ */\r\n\r\n#ifndef GL_SGIX_texture_add_env\r\n#define GL_SGIX_texture_add_env 1\r\n\r\n#define GLEW_SGIX_texture_add_env GLEW_GET_VAR(__GLEW_SGIX_texture_add_env)\r\n\r\n#endif /* GL_SGIX_texture_add_env */\r\n\r\n/* -------------------- GL_SGIX_texture_coordinate_clamp ------------------- */\r\n\r\n#ifndef GL_SGIX_texture_coordinate_clamp\r\n#define GL_SGIX_texture_coordinate_clamp 1\r\n\r\n#define GL_TEXTURE_MAX_CLAMP_S_SGIX 0x8369\r\n#define GL_TEXTURE_MAX_CLAMP_T_SGIX 0x836A\r\n#define GL_TEXTURE_MAX_CLAMP_R_SGIX 0x836B\r\n\r\n#define GLEW_SGIX_texture_coordinate_clamp GLEW_GET_VAR(__GLEW_SGIX_texture_coordinate_clamp)\r\n\r\n#endif /* GL_SGIX_texture_coordinate_clamp */\r\n\r\n/* ------------------------ GL_SGIX_texture_lod_bias ----------------------- */\r\n\r\n#ifndef GL_SGIX_texture_lod_bias\r\n#define GL_SGIX_texture_lod_bias 1\r\n\r\n#define GLEW_SGIX_texture_lod_bias GLEW_GET_VAR(__GLEW_SGIX_texture_lod_bias)\r\n\r\n#endif /* GL_SGIX_texture_lod_bias */\r\n\r\n/* ---------------------- GL_SGIX_texture_multi_buffer --------------------- */\r\n\r\n#ifndef GL_SGIX_texture_multi_buffer\r\n#define GL_SGIX_texture_multi_buffer 1\r\n\r\n#define GL_TEXTURE_MULTI_BUFFER_HINT_SGIX 0x812E\r\n\r\n#define GLEW_SGIX_texture_multi_buffer GLEW_GET_VAR(__GLEW_SGIX_texture_multi_buffer)\r\n\r\n#endif /* GL_SGIX_texture_multi_buffer */\r\n\r\n/* ------------------------- GL_SGIX_texture_range ------------------------- */\r\n\r\n#ifndef GL_SGIX_texture_range\r\n#define GL_SGIX_texture_range 1\r\n\r\n#define GL_RGB_SIGNED_SGIX 0x85E0\r\n#define GL_RGBA_SIGNED_SGIX 0x85E1\r\n#define GL_ALPHA_SIGNED_SGIX 0x85E2\r\n#define GL_LUMINANCE_SIGNED_SGIX 0x85E3\r\n#define GL_INTENSITY_SIGNED_SGIX 0x85E4\r\n#define GL_LUMINANCE_ALPHA_SIGNED_SGIX 0x85E5\r\n#define GL_RGB16_SIGNED_SGIX 0x85E6\r\n#define GL_RGBA16_SIGNED_SGIX 0x85E7\r\n#define GL_ALPHA16_SIGNED_SGIX 0x85E8\r\n#define GL_LUMINANCE16_SIGNED_SGIX 0x85E9\r\n#define GL_INTENSITY16_SIGNED_SGIX 0x85EA\r\n#define GL_LUMINANCE16_ALPHA16_SIGNED_SGIX 0x85EB\r\n#define GL_RGB_EXTENDED_RANGE_SGIX 0x85EC\r\n#define GL_RGBA_EXTENDED_RANGE_SGIX 0x85ED\r\n#define GL_ALPHA_EXTENDED_RANGE_SGIX 0x85EE\r\n#define GL_LUMINANCE_EXTENDED_RANGE_SGIX 0x85EF\r\n#define GL_INTENSITY_EXTENDED_RANGE_SGIX 0x85F0\r\n#define GL_LUMINANCE_ALPHA_EXTENDED_RANGE_SGIX 0x85F1\r\n#define GL_RGB16_EXTENDED_RANGE_SGIX 0x85F2\r\n#define GL_RGBA16_EXTENDED_RANGE_SGIX 0x85F3\r\n#define GL_ALPHA16_EXTENDED_RANGE_SGIX 0x85F4\r\n#define GL_LUMINANCE16_EXTENDED_RANGE_SGIX 0x85F5\r\n#define GL_INTENSITY16_EXTENDED_RANGE_SGIX 0x85F6\r\n#define GL_LUMINANCE16_ALPHA16_EXTENDED_RANGE_SGIX 0x85F7\r\n#define GL_MIN_LUMINANCE_SGIS 0x85F8\r\n#define GL_MAX_LUMINANCE_SGIS 0x85F9\r\n#define GL_MIN_INTENSITY_SGIS 0x85FA\r\n#define GL_MAX_INTENSITY_SGIS 0x85FB\r\n\r\n#define GLEW_SGIX_texture_range GLEW_GET_VAR(__GLEW_SGIX_texture_range)\r\n\r\n#endif /* GL_SGIX_texture_range */\r\n\r\n/* ----------------------- GL_SGIX_texture_scale_bias ---------------------- */\r\n\r\n#ifndef GL_SGIX_texture_scale_bias\r\n#define GL_SGIX_texture_scale_bias 1\r\n\r\n#define GL_POST_TEXTURE_FILTER_BIAS_SGIX 0x8179\r\n#define GL_POST_TEXTURE_FILTER_SCALE_SGIX 0x817A\r\n#define GL_POST_TEXTURE_FILTER_BIAS_RANGE_SGIX 0x817B\r\n#define GL_POST_TEXTURE_FILTER_SCALE_RANGE_SGIX 0x817C\r\n\r\n#define GLEW_SGIX_texture_scale_bias GLEW_GET_VAR(__GLEW_SGIX_texture_scale_bias)\r\n\r\n#endif /* GL_SGIX_texture_scale_bias */\r\n\r\n/* ------------------------- GL_SGIX_vertex_preclip ------------------------ */\r\n\r\n#ifndef GL_SGIX_vertex_preclip\r\n#define GL_SGIX_vertex_preclip 1\r\n\r\n#define GL_VERTEX_PRECLIP_SGIX 0x83EE\r\n#define GL_VERTEX_PRECLIP_HINT_SGIX 0x83EF\r\n\r\n#define GLEW_SGIX_vertex_preclip GLEW_GET_VAR(__GLEW_SGIX_vertex_preclip)\r\n\r\n#endif /* GL_SGIX_vertex_preclip */\r\n\r\n/* ---------------------- GL_SGIX_vertex_preclip_hint ---------------------- */\r\n\r\n#ifndef GL_SGIX_vertex_preclip_hint\r\n#define GL_SGIX_vertex_preclip_hint 1\r\n\r\n#define GL_VERTEX_PRECLIP_SGIX 0x83EE\r\n#define GL_VERTEX_PRECLIP_HINT_SGIX 0x83EF\r\n\r\n#define GLEW_SGIX_vertex_preclip_hint GLEW_GET_VAR(__GLEW_SGIX_vertex_preclip_hint)\r\n\r\n#endif /* GL_SGIX_vertex_preclip_hint */\r\n\r\n/* ----------------------------- GL_SGIX_ycrcb ----------------------------- */\r\n\r\n#ifndef GL_SGIX_ycrcb\r\n#define GL_SGIX_ycrcb 1\r\n\r\n#define GLEW_SGIX_ycrcb GLEW_GET_VAR(__GLEW_SGIX_ycrcb)\r\n\r\n#endif /* GL_SGIX_ycrcb */\r\n\r\n/* -------------------------- GL_SGI_color_matrix -------------------------- */\r\n\r\n#ifndef GL_SGI_color_matrix\r\n#define GL_SGI_color_matrix 1\r\n\r\n#define GL_COLOR_MATRIX_SGI 0x80B1\r\n#define GL_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B2\r\n#define GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B3\r\n#define GL_POST_COLOR_MATRIX_RED_SCALE_SGI 0x80B4\r\n#define GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI 0x80B5\r\n#define GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI 0x80B6\r\n#define GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI 0x80B7\r\n#define GL_POST_COLOR_MATRIX_RED_BIAS_SGI 0x80B8\r\n#define GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI 0x80B9\r\n#define GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI 0x80BA\r\n#define GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI 0x80BB\r\n\r\n#define GLEW_SGI_color_matrix GLEW_GET_VAR(__GLEW_SGI_color_matrix)\r\n\r\n#endif /* GL_SGI_color_matrix */\r\n\r\n/* --------------------------- GL_SGI_color_table -------------------------- */\r\n\r\n#ifndef GL_SGI_color_table\r\n#define GL_SGI_color_table 1\r\n\r\n#define GL_COLOR_TABLE_SGI 0x80D0\r\n#define GL_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D1\r\n#define GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D2\r\n#define GL_PROXY_COLOR_TABLE_SGI 0x80D3\r\n#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D4\r\n#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D5\r\n#define GL_COLOR_TABLE_SCALE_SGI 0x80D6\r\n#define GL_COLOR_TABLE_BIAS_SGI 0x80D7\r\n#define GL_COLOR_TABLE_FORMAT_SGI 0x80D8\r\n#define GL_COLOR_TABLE_WIDTH_SGI 0x80D9\r\n#define GL_COLOR_TABLE_RED_SIZE_SGI 0x80DA\r\n#define GL_COLOR_TABLE_GREEN_SIZE_SGI 0x80DB\r\n#define GL_COLOR_TABLE_BLUE_SIZE_SGI 0x80DC\r\n#define GL_COLOR_TABLE_ALPHA_SIZE_SGI 0x80DD\r\n#define GL_COLOR_TABLE_LUMINANCE_SIZE_SGI 0x80DE\r\n#define GL_COLOR_TABLE_INTENSITY_SIZE_SGI 0x80DF\r\n\r\ntypedef void (GLAPIENTRY * PFNGLCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, const GLfloat* params);\r\ntypedef void (GLAPIENTRY * PFNGLCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, const GLint* params);\r\ntypedef void (GLAPIENTRY * PFNGLCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *table);\r\ntypedef void (GLAPIENTRY * PFNGLCOPYCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width);\r\ntypedef void (GLAPIENTRY * PFNGLGETCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, GLfloat* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, GLint* params);\r\ntypedef void (GLAPIENTRY * PFNGLGETCOLORTABLESGIPROC) (GLenum target, GLenum format, GLenum type, void *table);\r\n\r\n#define glColorTableParameterfvSGI GLEW_GET_FUN(__glewColorTableParameterfvSGI)\r\n#define glColorTableParameterivSGI GLEW_GET_FUN(__glewColorTableParameterivSGI)\r\n#define glColorTableSGI GLEW_GET_FUN(__glewColorTableSGI)\r\n#define glCopyColorTableSGI GLEW_GET_FUN(__glewCopyColorTableSGI)\r\n#define glGetColorTableParameterfvSGI GLEW_GET_FUN(__glewGetColorTableParameterfvSGI)\r\n#define glGetColorTableParameterivSGI GLEW_GET_FUN(__glewGetColorTableParameterivSGI)\r\n#define glGetColorTableSGI GLEW_GET_FUN(__glewGetColorTableSGI)\r\n\r\n#define GLEW_SGI_color_table GLEW_GET_VAR(__GLEW_SGI_color_table)\r\n\r\n#endif /* GL_SGI_color_table */\r\n\r\n/* ----------------------- GL_SGI_texture_color_table ---------------------- */\r\n\r\n#ifndef GL_SGI_texture_color_table\r\n#define GL_SGI_texture_color_table 1\r\n\r\n#define GL_TEXTURE_COLOR_TABLE_SGI 0x80BC\r\n#define GL_PROXY_TEXTURE_COLOR_TABLE_SGI 0x80BD\r\n\r\n#define GLEW_SGI_texture_color_table GLEW_GET_VAR(__GLEW_SGI_texture_color_table)\r\n\r\n#endif /* GL_SGI_texture_color_table */\r\n\r\n/* ------------------------- GL_SUNX_constant_data ------------------------- */\r\n\r\n#ifndef GL_SUNX_constant_data\r\n#define GL_SUNX_constant_data 1\r\n\r\n#define GL_UNPACK_CONSTANT_DATA_SUNX 0x81D5\r\n#define GL_TEXTURE_CONSTANT_DATA_SUNX 0x81D6\r\n\r\ntypedef void (GLAPIENTRY * PFNGLFINISHTEXTURESUNXPROC) (void);\r\n\r\n#define glFinishTextureSUNX GLEW_GET_FUN(__glewFinishTextureSUNX)\r\n\r\n#define GLEW_SUNX_constant_data GLEW_GET_VAR(__GLEW_SUNX_constant_data)\r\n\r\n#endif /* GL_SUNX_constant_data */\r\n\r\n/* -------------------- GL_SUN_convolution_border_modes -------------------- */\r\n\r\n#ifndef GL_SUN_convolution_border_modes\r\n#define GL_SUN_convolution_border_modes 1\r\n\r\n#define GL_WRAP_BORDER_SUN 0x81D4\r\n\r\n#define GLEW_SUN_convolution_border_modes GLEW_GET_VAR(__GLEW_SUN_convolution_border_modes)\r\n\r\n#endif /* GL_SUN_convolution_border_modes */\r\n\r\n/* -------------------------- GL_SUN_global_alpha -------------------------- */\r\n\r\n#ifndef GL_SUN_global_alpha\r\n#define GL_SUN_global_alpha 1\r\n\r\n#define GL_GLOBAL_ALPHA_SUN 0x81D9\r\n#define GL_GLOBAL_ALPHA_FACTOR_SUN 0x81DA\r\n\r\ntypedef void (GLAPIENTRY * PFNGLGLOBALALPHAFACTORBSUNPROC) (GLbyte factor);\r\ntypedef void (GLAPIENTRY * PFNGLGLOBALALPHAFACTORDSUNPROC) (GLdouble factor);\r\ntypedef void (GLAPIENTRY * PFNGLGLOBALALPHAFACTORFSUNPROC) (GLfloat factor);\r\ntypedef void (GLAPIENTRY * PFNGLGLOBALALPHAFACTORISUNPROC) (GLint factor);\r\ntypedef void (GLAPIENTRY * PFNGLGLOBALALPHAFACTORSSUNPROC) (GLshort factor);\r\ntypedef void (GLAPIENTRY * PFNGLGLOBALALPHAFACTORUBSUNPROC) (GLubyte factor);\r\ntypedef void (GLAPIENTRY * PFNGLGLOBALALPHAFACTORUISUNPROC) (GLuint factor);\r\ntypedef void (GLAPIENTRY * PFNGLGLOBALALPHAFACTORUSSUNPROC) (GLushort factor);\r\n\r\n#define glGlobalAlphaFactorbSUN GLEW_GET_FUN(__glewGlobalAlphaFactorbSUN)\r\n#define glGlobalAlphaFactordSUN GLEW_GET_FUN(__glewGlobalAlphaFactordSUN)\r\n#define glGlobalAlphaFactorfSUN GLEW_GET_FUN(__glewGlobalAlphaFactorfSUN)\r\n#define glGlobalAlphaFactoriSUN GLEW_GET_FUN(__glewGlobalAlphaFactoriSUN)\r\n#define glGlobalAlphaFactorsSUN GLEW_GET_FUN(__glewGlobalAlphaFactorsSUN)\r\n#define glGlobalAlphaFactorubSUN GLEW_GET_FUN(__glewGlobalAlphaFactorubSUN)\r\n#define glGlobalAlphaFactoruiSUN GLEW_GET_FUN(__glewGlobalAlphaFactoruiSUN)\r\n#define glGlobalAlphaFactorusSUN GLEW_GET_FUN(__glewGlobalAlphaFactorusSUN)\r\n\r\n#define GLEW_SUN_global_alpha GLEW_GET_VAR(__GLEW_SUN_global_alpha)\r\n\r\n#endif /* GL_SUN_global_alpha */\r\n\r\n/* --------------------------- GL_SUN_mesh_array --------------------------- */\r\n\r\n#ifndef GL_SUN_mesh_array\r\n#define GL_SUN_mesh_array 1\r\n\r\n#define GL_QUAD_MESH_SUN 0x8614\r\n#define GL_TRIANGLE_MESH_SUN 0x8615\r\n\r\n#define GLEW_SUN_mesh_array GLEW_GET_VAR(__GLEW_SUN_mesh_array)\r\n\r\n#endif /* GL_SUN_mesh_array */\r\n\r\n/* ------------------------ GL_SUN_read_video_pixels ----------------------- */\r\n\r\n#ifndef GL_SUN_read_video_pixels\r\n#define GL_SUN_read_video_pixels 1\r\n\r\ntypedef void (GLAPIENTRY * PFNGLREADVIDEOPIXELSSUNPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void* pixels);\r\n\r\n#define glReadVideoPixelsSUN GLEW_GET_FUN(__glewReadVideoPixelsSUN)\r\n\r\n#define GLEW_SUN_read_video_pixels GLEW_GET_VAR(__GLEW_SUN_read_video_pixels)\r\n\r\n#endif /* GL_SUN_read_video_pixels */\r\n\r\n/* --------------------------- GL_SUN_slice_accum -------------------------- */\r\n\r\n#ifndef GL_SUN_slice_accum\r\n#define GL_SUN_slice_accum 1\r\n\r\n#define GL_SLICE_ACCUM_SUN 0x85CC\r\n\r\n#define GLEW_SUN_slice_accum GLEW_GET_VAR(__GLEW_SUN_slice_accum)\r\n\r\n#endif /* GL_SUN_slice_accum */\r\n\r\n/* -------------------------- GL_SUN_triangle_list ------------------------- */\r\n\r\n#ifndef GL_SUN_triangle_list\r\n#define GL_SUN_triangle_list 1\r\n\r\n#define GL_RESTART_SUN 0x01\r\n#define GL_REPLACE_MIDDLE_SUN 0x02\r\n#define GL_REPLACE_OLDEST_SUN 0x03\r\n#define GL_TRIANGLE_LIST_SUN 0x81D7\r\n#define GL_REPLACEMENT_CODE_SUN 0x81D8\r\n#define GL_REPLACEMENT_CODE_ARRAY_SUN 0x85C0\r\n#define GL_REPLACEMENT_CODE_ARRAY_TYPE_SUN 0x85C1\r\n#define GL_REPLACEMENT_CODE_ARRAY_STRIDE_SUN 0x85C2\r\n#define GL_REPLACEMENT_CODE_ARRAY_POINTER_SUN 0x85C3\r\n#define GL_R1UI_V3F_SUN 0x85C4\r\n#define GL_R1UI_C4UB_V3F_SUN 0x85C5\r\n#define GL_R1UI_C3F_V3F_SUN 0x85C6\r\n#define GL_R1UI_N3F_V3F_SUN 0x85C7\r\n#define GL_R1UI_C4F_N3F_V3F_SUN 0x85C8\r\n#define GL_R1UI_T2F_V3F_SUN 0x85C9\r\n#define GL_R1UI_T2F_N3F_V3F_SUN 0x85CA\r\n#define GL_R1UI_T2F_C4F_N3F_V3F_SUN 0x85CB\r\n\r\ntypedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEPOINTERSUNPROC) (GLenum type, GLsizei stride, const void *pointer);\r\ntypedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUBSUNPROC) (GLubyte code);\r\ntypedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUBVSUNPROC) (const GLubyte* code);\r\ntypedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUISUNPROC) (GLuint code);\r\ntypedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUIVSUNPROC) (const GLuint* code);\r\ntypedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUSSUNPROC) (GLushort code);\r\ntypedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUSVSUNPROC) (const GLushort* code);\r\n\r\n#define glReplacementCodePointerSUN GLEW_GET_FUN(__glewReplacementCodePointerSUN)\r\n#define glReplacementCodeubSUN GLEW_GET_FUN(__glewReplacementCodeubSUN)\r\n#define glReplacementCodeubvSUN GLEW_GET_FUN(__glewReplacementCodeubvSUN)\r\n#define glReplacementCodeuiSUN GLEW_GET_FUN(__glewReplacementCodeuiSUN)\r\n#define glReplacementCodeuivSUN GLEW_GET_FUN(__glewReplacementCodeuivSUN)\r\n#define glReplacementCodeusSUN GLEW_GET_FUN(__glewReplacementCodeusSUN)\r\n#define glReplacementCodeusvSUN GLEW_GET_FUN(__glewReplacementCodeusvSUN)\r\n\r\n#define GLEW_SUN_triangle_list GLEW_GET_VAR(__GLEW_SUN_triangle_list)\r\n\r\n#endif /* GL_SUN_triangle_list */\r\n\r\n/* ----------------------------- GL_SUN_vertex ----------------------------- */\r\n\r\n#ifndef GL_SUN_vertex\r\n#define GL_SUN_vertex 1\r\n\r\ntypedef void (GLAPIENTRY * PFNGLCOLOR3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z);\r\ntypedef void (GLAPIENTRY * PFNGLCOLOR3FVERTEX3FVSUNPROC) (const GLfloat* c, const GLfloat *v);\r\ntypedef void (GLAPIENTRY * PFNGLCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);\r\ntypedef void (GLAPIENTRY * PFNGLCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat* c, const GLfloat *n, const GLfloat *v);\r\ntypedef void (GLAPIENTRY * PFNGLCOLOR4UBVERTEX2FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y);\r\ntypedef void (GLAPIENTRY * PFNGLCOLOR4UBVERTEX2FVSUNPROC) (const GLubyte* c, const GLfloat *v);\r\ntypedef void (GLAPIENTRY * PFNGLCOLOR4UBVERTEX3FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z);\r\ntypedef void (GLAPIENTRY * PFNGLCOLOR4UBVERTEX3FVSUNPROC) (const GLubyte* c, const GLfloat *v);\r\ntypedef void (GLAPIENTRY * PFNGLNORMAL3FVERTEX3FSUNPROC) (GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);\r\ntypedef void (GLAPIENTRY * PFNGLNORMAL3FVERTEX3FVSUNPROC) (const GLfloat* n, const GLfloat *v);\r\ntypedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z);\r\ntypedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FVSUNPROC) (const GLuint* rc, const GLfloat *c, const GLfloat *v);\r\ntypedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);\r\ntypedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint* rc, const GLfloat *c, const GLfloat *n, const GLfloat *v);\r\ntypedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FSUNPROC) (GLuint rc, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z);\r\ntypedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FVSUNPROC) (const GLuint* rc, const GLubyte *c, const GLfloat *v);\r\ntypedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);\r\ntypedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FVSUNPROC) (const GLuint* rc, const GLfloat *n, const GLfloat *v);\r\ntypedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);\r\ntypedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint* rc, const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v);\r\ntypedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);\r\ntypedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLuint* rc, const GLfloat *tc, const GLfloat *n, const GLfloat *v);\r\ntypedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z);\r\ntypedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FVSUNPROC) (const GLuint* rc, const GLfloat *tc, const GLfloat *v);\r\ntypedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUIVERTEX3FSUNPROC) (GLuint rc, GLfloat x, GLfloat y, GLfloat z);\r\ntypedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUIVERTEX3FVSUNPROC) (const GLuint* rc, const GLfloat *v);\r\ntypedef void (GLAPIENTRY * PFNGLTEXCOORD2FCOLOR3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z);\r\ntypedef void (GLAPIENTRY * PFNGLTEXCOORD2FCOLOR3FVERTEX3FVSUNPROC) (const GLfloat* tc, const GLfloat *c, const GLfloat *v);\r\ntypedef void (GLAPIENTRY * PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);\r\ntypedef void (GLAPIENTRY * PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat* tc, const GLfloat *c, const GLfloat *n, const GLfloat *v);\r\ntypedef void (GLAPIENTRY * PFNGLTEXCOORD2FCOLOR4UBVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z);\r\ntypedef void (GLAPIENTRY * PFNGLTEXCOORD2FCOLOR4UBVERTEX3FVSUNPROC) (const GLfloat* tc, const GLubyte *c, const GLfloat *v);\r\ntypedef void (GLAPIENTRY * PFNGLTEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);\r\ntypedef void (GLAPIENTRY * PFNGLTEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat* tc, const GLfloat *n, const GLfloat *v);\r\ntypedef void (GLAPIENTRY * PFNGLTEXCOORD2FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z);\r\ntypedef void (GLAPIENTRY * PFNGLTEXCOORD2FVERTEX3FVSUNPROC) (const GLfloat* tc, const GLfloat *v);\r\ntypedef void (GLAPIENTRY * PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z, GLfloat w);\r\ntypedef void (GLAPIENTRY * PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FVSUNPROC) (const GLfloat* tc, const GLfloat *c, const GLfloat *n, const GLfloat *v);\r\ntypedef void (GLAPIENTRY * PFNGLTEXCOORD4FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat x, GLfloat y, GLfloat z, GLfloat w);\r\ntypedef void (GLAPIENTRY * PFNGLTEXCOORD4FVERTEX4FVSUNPROC) (const GLfloat* tc, const GLfloat *v);\r\n\r\n#define glColor3fVertex3fSUN GLEW_GET_FUN(__glewColor3fVertex3fSUN)\r\n#define glColor3fVertex3fvSUN GLEW_GET_FUN(__glewColor3fVertex3fvSUN)\r\n#define glColor4fNormal3fVertex3fSUN GLEW_GET_FUN(__glewColor4fNormal3fVertex3fSUN)\r\n#define glColor4fNormal3fVertex3fvSUN GLEW_GET_FUN(__glewColor4fNormal3fVertex3fvSUN)\r\n#define glColor4ubVertex2fSUN GLEW_GET_FUN(__glewColor4ubVertex2fSUN)\r\n#define glColor4ubVertex2fvSUN GLEW_GET_FUN(__glewColor4ubVertex2fvSUN)\r\n#define glColor4ubVertex3fSUN GLEW_GET_FUN(__glewColor4ubVertex3fSUN)\r\n#define glColor4ubVertex3fvSUN GLEW_GET_FUN(__glewColor4ubVertex3fvSUN)\r\n#define glNormal3fVertex3fSUN GLEW_GET_FUN(__glewNormal3fVertex3fSUN)\r\n#define glNormal3fVertex3fvSUN GLEW_GET_FUN(__glewNormal3fVertex3fvSUN)\r\n#define glReplacementCodeuiColor3fVertex3fSUN GLEW_GET_FUN(__glewReplacementCodeuiColor3fVertex3fSUN)\r\n#define glReplacementCodeuiColor3fVertex3fvSUN GLEW_GET_FUN(__glewReplacementCodeuiColor3fVertex3fvSUN)\r\n#define glReplacementCodeuiColor4fNormal3fVertex3fSUN GLEW_GET_FUN(__glewReplacementCodeuiColor4fNormal3fVertex3fSUN)\r\n#define glReplacementCodeuiColor4fNormal3fVertex3fvSUN GLEW_GET_FUN(__glewReplacementCodeuiColor4fNormal3fVertex3fvSUN)\r\n#define glReplacementCodeuiColor4ubVertex3fSUN GLEW_GET_FUN(__glewReplacementCodeuiColor4ubVertex3fSUN)\r\n#define glReplacementCodeuiColor4ubVertex3fvSUN GLEW_GET_FUN(__glewReplacementCodeuiColor4ubVertex3fvSUN)\r\n#define glReplacementCodeuiNormal3fVertex3fSUN GLEW_GET_FUN(__glewReplacementCodeuiNormal3fVertex3fSUN)\r\n#define glReplacementCodeuiNormal3fVertex3fvSUN GLEW_GET_FUN(__glewReplacementCodeuiNormal3fVertex3fvSUN)\r\n#define glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN GLEW_GET_FUN(__glewReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN)\r\n#define glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN GLEW_GET_FUN(__glewReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN)\r\n#define glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN GLEW_GET_FUN(__glewReplacementCodeuiTexCoord2fNormal3fVertex3fSUN)\r\n#define glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN GLEW_GET_FUN(__glewReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN)\r\n#define glReplacementCodeuiTexCoord2fVertex3fSUN GLEW_GET_FUN(__glewReplacementCodeuiTexCoord2fVertex3fSUN)\r\n#define glReplacementCodeuiTexCoord2fVertex3fvSUN GLEW_GET_FUN(__glewReplacementCodeuiTexCoord2fVertex3fvSUN)\r\n#define glReplacementCodeuiVertex3fSUN GLEW_GET_FUN(__glewReplacementCodeuiVertex3fSUN)\r\n#define glReplacementCodeuiVertex3fvSUN GLEW_GET_FUN(__glewReplacementCodeuiVertex3fvSUN)\r\n#define glTexCoord2fColor3fVertex3fSUN GLEW_GET_FUN(__glewTexCoord2fColor3fVertex3fSUN)\r\n#define glTexCoord2fColor3fVertex3fvSUN GLEW_GET_FUN(__glewTexCoord2fColor3fVertex3fvSUN)\r\n#define glTexCoord2fColor4fNormal3fVertex3fSUN GLEW_GET_FUN(__glewTexCoord2fColor4fNormal3fVertex3fSUN)\r\n#define glTexCoord2fColor4fNormal3fVertex3fvSUN GLEW_GET_FUN(__glewTexCoord2fColor4fNormal3fVertex3fvSUN)\r\n#define glTexCoord2fColor4ubVertex3fSUN GLEW_GET_FUN(__glewTexCoord2fColor4ubVertex3fSUN)\r\n#define glTexCoord2fColor4ubVertex3fvSUN GLEW_GET_FUN(__glewTexCoord2fColor4ubVertex3fvSUN)\r\n#define glTexCoord2fNormal3fVertex3fSUN GLEW_GET_FUN(__glewTexCoord2fNormal3fVertex3fSUN)\r\n#define glTexCoord2fNormal3fVertex3fvSUN GLEW_GET_FUN(__glewTexCoord2fNormal3fVertex3fvSUN)\r\n#define glTexCoord2fVertex3fSUN GLEW_GET_FUN(__glewTexCoord2fVertex3fSUN)\r\n#define glTexCoord2fVertex3fvSUN GLEW_GET_FUN(__glewTexCoord2fVertex3fvSUN)\r\n#define glTexCoord4fColor4fNormal3fVertex4fSUN GLEW_GET_FUN(__glewTexCoord4fColor4fNormal3fVertex4fSUN)\r\n#define glTexCoord4fColor4fNormal3fVertex4fvSUN GLEW_GET_FUN(__glewTexCoord4fColor4fNormal3fVertex4fvSUN)\r\n#define glTexCoord4fVertex4fSUN GLEW_GET_FUN(__glewTexCoord4fVertex4fSUN)\r\n#define glTexCoord4fVertex4fvSUN GLEW_GET_FUN(__glewTexCoord4fVertex4fvSUN)\r\n\r\n#define GLEW_SUN_vertex GLEW_GET_VAR(__GLEW_SUN_vertex)\r\n\r\n#endif /* GL_SUN_vertex */\r\n\r\n/* -------------------------- GL_WIN_phong_shading ------------------------- */\r\n\r\n#ifndef GL_WIN_phong_shading\r\n#define GL_WIN_phong_shading 1\r\n\r\n#define GL_PHONG_WIN 0x80EA\r\n#define GL_PHONG_HINT_WIN 0x80EB\r\n\r\n#define GLEW_WIN_phong_shading GLEW_GET_VAR(__GLEW_WIN_phong_shading)\r\n\r\n#endif /* GL_WIN_phong_shading */\r\n\r\n/* -------------------------- GL_WIN_specular_fog -------------------------- */\r\n\r\n#ifndef GL_WIN_specular_fog\r\n#define GL_WIN_specular_fog 1\r\n\r\n#define GL_FOG_SPECULAR_TEXTURE_WIN 0x80EC\r\n\r\n#define GLEW_WIN_specular_fog GLEW_GET_VAR(__GLEW_WIN_specular_fog)\r\n\r\n#endif /* GL_WIN_specular_fog */\r\n\r\n/* ---------------------------- GL_WIN_swap_hint --------------------------- */\r\n\r\n#ifndef GL_WIN_swap_hint\r\n#define GL_WIN_swap_hint 1\r\n\r\ntypedef void (GLAPIENTRY * PFNGLADDSWAPHINTRECTWINPROC) (GLint x, GLint y, GLsizei width, GLsizei height);\r\n\r\n#define glAddSwapHintRectWIN GLEW_GET_FUN(__glewAddSwapHintRectWIN)\r\n\r\n#define GLEW_WIN_swap_hint GLEW_GET_VAR(__GLEW_WIN_swap_hint)\r\n\r\n#endif /* GL_WIN_swap_hint */\r\n\r\n/* ------------------------------------------------------------------------- */\r\n\r\n#if defined(GLEW_MX) && defined(_WIN32)\r\n#define GLEW_FUN_EXPORT\r\n#else\r\n#define GLEW_FUN_EXPORT GLEWAPI\r\n#endif /* GLEW_MX */\r\n\r\n#if defined(GLEW_MX)\r\n#define GLEW_VAR_EXPORT\r\n#else\r\n#define GLEW_VAR_EXPORT GLEWAPI\r\n#endif /* GLEW_MX */\r\n\r\n#if defined(GLEW_MX) && defined(_WIN32)\r\nstruct GLEWContextStruct\r\n{\r\n#endif /* GLEW_MX */\r\n\r\nGLEW_FUN_EXPORT PFNGLCOPYTEXSUBIMAGE3DPROC __glewCopyTexSubImage3D;\r\nGLEW_FUN_EXPORT PFNGLDRAWRANGEELEMENTSPROC __glewDrawRangeElements;\r\nGLEW_FUN_EXPORT PFNGLTEXIMAGE3DPROC __glewTexImage3D;\r\nGLEW_FUN_EXPORT PFNGLTEXSUBIMAGE3DPROC __glewTexSubImage3D;\r\n\r\nGLEW_FUN_EXPORT PFNGLACTIVETEXTUREPROC __glewActiveTexture;\r\nGLEW_FUN_EXPORT PFNGLCLIENTACTIVETEXTUREPROC __glewClientActiveTexture;\r\nGLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXIMAGE1DPROC __glewCompressedTexImage1D;\r\nGLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXIMAGE2DPROC __glewCompressedTexImage2D;\r\nGLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXIMAGE3DPROC __glewCompressedTexImage3D;\r\nGLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC __glewCompressedTexSubImage1D;\r\nGLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC __glewCompressedTexSubImage2D;\r\nGLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC __glewCompressedTexSubImage3D;\r\nGLEW_FUN_EXPORT PFNGLGETCOMPRESSEDTEXIMAGEPROC __glewGetCompressedTexImage;\r\nGLEW_FUN_EXPORT PFNGLLOADTRANSPOSEMATRIXDPROC __glewLoadTransposeMatrixd;\r\nGLEW_FUN_EXPORT PFNGLLOADTRANSPOSEMATRIXFPROC __glewLoadTransposeMatrixf;\r\nGLEW_FUN_EXPORT PFNGLMULTTRANSPOSEMATRIXDPROC __glewMultTransposeMatrixd;\r\nGLEW_FUN_EXPORT PFNGLMULTTRANSPOSEMATRIXFPROC __glewMultTransposeMatrixf;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD1DPROC __glewMultiTexCoord1d;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD1DVPROC __glewMultiTexCoord1dv;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD1FPROC __glewMultiTexCoord1f;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD1FVPROC __glewMultiTexCoord1fv;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD1IPROC __glewMultiTexCoord1i;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD1IVPROC __glewMultiTexCoord1iv;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD1SPROC __glewMultiTexCoord1s;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD1SVPROC __glewMultiTexCoord1sv;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD2DPROC __glewMultiTexCoord2d;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD2DVPROC __glewMultiTexCoord2dv;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD2FPROC __glewMultiTexCoord2f;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD2FVPROC __glewMultiTexCoord2fv;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD2IPROC __glewMultiTexCoord2i;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD2IVPROC __glewMultiTexCoord2iv;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD2SPROC __glewMultiTexCoord2s;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD2SVPROC __glewMultiTexCoord2sv;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD3DPROC __glewMultiTexCoord3d;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD3DVPROC __glewMultiTexCoord3dv;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD3FPROC __glewMultiTexCoord3f;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD3FVPROC __glewMultiTexCoord3fv;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD3IPROC __glewMultiTexCoord3i;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD3IVPROC __glewMultiTexCoord3iv;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD3SPROC __glewMultiTexCoord3s;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD3SVPROC __glewMultiTexCoord3sv;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD4DPROC __glewMultiTexCoord4d;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD4DVPROC __glewMultiTexCoord4dv;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD4FPROC __glewMultiTexCoord4f;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD4FVPROC __glewMultiTexCoord4fv;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD4IPROC __glewMultiTexCoord4i;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD4IVPROC __glewMultiTexCoord4iv;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD4SPROC __glewMultiTexCoord4s;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD4SVPROC __glewMultiTexCoord4sv;\r\nGLEW_FUN_EXPORT PFNGLSAMPLECOVERAGEPROC __glewSampleCoverage;\r\n\r\nGLEW_FUN_EXPORT PFNGLBLENDCOLORPROC __glewBlendColor;\r\nGLEW_FUN_EXPORT PFNGLBLENDEQUATIONPROC __glewBlendEquation;\r\nGLEW_FUN_EXPORT PFNGLBLENDFUNCSEPARATEPROC __glewBlendFuncSeparate;\r\nGLEW_FUN_EXPORT PFNGLFOGCOORDPOINTERPROC __glewFogCoordPointer;\r\nGLEW_FUN_EXPORT PFNGLFOGCOORDDPROC __glewFogCoordd;\r\nGLEW_FUN_EXPORT PFNGLFOGCOORDDVPROC __glewFogCoorddv;\r\nGLEW_FUN_EXPORT PFNGLFOGCOORDFPROC __glewFogCoordf;\r\nGLEW_FUN_EXPORT PFNGLFOGCOORDFVPROC __glewFogCoordfv;\r\nGLEW_FUN_EXPORT PFNGLMULTIDRAWARRAYSPROC __glewMultiDrawArrays;\r\nGLEW_FUN_EXPORT PFNGLMULTIDRAWELEMENTSPROC __glewMultiDrawElements;\r\nGLEW_FUN_EXPORT PFNGLPOINTPARAMETERFPROC __glewPointParameterf;\r\nGLEW_FUN_EXPORT PFNGLPOINTPARAMETERFVPROC __glewPointParameterfv;\r\nGLEW_FUN_EXPORT PFNGLPOINTPARAMETERIPROC __glewPointParameteri;\r\nGLEW_FUN_EXPORT PFNGLPOINTPARAMETERIVPROC __glewPointParameteriv;\r\nGLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3BPROC __glewSecondaryColor3b;\r\nGLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3BVPROC __glewSecondaryColor3bv;\r\nGLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3DPROC __glewSecondaryColor3d;\r\nGLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3DVPROC __glewSecondaryColor3dv;\r\nGLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3FPROC __glewSecondaryColor3f;\r\nGLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3FVPROC __glewSecondaryColor3fv;\r\nGLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3IPROC __glewSecondaryColor3i;\r\nGLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3IVPROC __glewSecondaryColor3iv;\r\nGLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3SPROC __glewSecondaryColor3s;\r\nGLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3SVPROC __glewSecondaryColor3sv;\r\nGLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3UBPROC __glewSecondaryColor3ub;\r\nGLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3UBVPROC __glewSecondaryColor3ubv;\r\nGLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3UIPROC __glewSecondaryColor3ui;\r\nGLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3UIVPROC __glewSecondaryColor3uiv;\r\nGLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3USPROC __glewSecondaryColor3us;\r\nGLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3USVPROC __glewSecondaryColor3usv;\r\nGLEW_FUN_EXPORT PFNGLSECONDARYCOLORPOINTERPROC __glewSecondaryColorPointer;\r\nGLEW_FUN_EXPORT PFNGLWINDOWPOS2DPROC __glewWindowPos2d;\r\nGLEW_FUN_EXPORT PFNGLWINDOWPOS2DVPROC __glewWindowPos2dv;\r\nGLEW_FUN_EXPORT PFNGLWINDOWPOS2FPROC __glewWindowPos2f;\r\nGLEW_FUN_EXPORT PFNGLWINDOWPOS2FVPROC __glewWindowPos2fv;\r\nGLEW_FUN_EXPORT PFNGLWINDOWPOS2IPROC __glewWindowPos2i;\r\nGLEW_FUN_EXPORT PFNGLWINDOWPOS2IVPROC __glewWindowPos2iv;\r\nGLEW_FUN_EXPORT PFNGLWINDOWPOS2SPROC __glewWindowPos2s;\r\nGLEW_FUN_EXPORT PFNGLWINDOWPOS2SVPROC __glewWindowPos2sv;\r\nGLEW_FUN_EXPORT PFNGLWINDOWPOS3DPROC __glewWindowPos3d;\r\nGLEW_FUN_EXPORT PFNGLWINDOWPOS3DVPROC __glewWindowPos3dv;\r\nGLEW_FUN_EXPORT PFNGLWINDOWPOS3FPROC __glewWindowPos3f;\r\nGLEW_FUN_EXPORT PFNGLWINDOWPOS3FVPROC __glewWindowPos3fv;\r\nGLEW_FUN_EXPORT PFNGLWINDOWPOS3IPROC __glewWindowPos3i;\r\nGLEW_FUN_EXPORT PFNGLWINDOWPOS3IVPROC __glewWindowPos3iv;\r\nGLEW_FUN_EXPORT PFNGLWINDOWPOS3SPROC __glewWindowPos3s;\r\nGLEW_FUN_EXPORT PFNGLWINDOWPOS3SVPROC __glewWindowPos3sv;\r\n\r\nGLEW_FUN_EXPORT PFNGLBEGINQUERYPROC __glewBeginQuery;\r\nGLEW_FUN_EXPORT PFNGLBINDBUFFERPROC __glewBindBuffer;\r\nGLEW_FUN_EXPORT PFNGLBUFFERDATAPROC __glewBufferData;\r\nGLEW_FUN_EXPORT PFNGLBUFFERSUBDATAPROC __glewBufferSubData;\r\nGLEW_FUN_EXPORT PFNGLDELETEBUFFERSPROC __glewDeleteBuffers;\r\nGLEW_FUN_EXPORT PFNGLDELETEQUERIESPROC __glewDeleteQueries;\r\nGLEW_FUN_EXPORT PFNGLENDQUERYPROC __glewEndQuery;\r\nGLEW_FUN_EXPORT PFNGLGENBUFFERSPROC __glewGenBuffers;\r\nGLEW_FUN_EXPORT PFNGLGENQUERIESPROC __glewGenQueries;\r\nGLEW_FUN_EXPORT PFNGLGETBUFFERPARAMETERIVPROC __glewGetBufferParameteriv;\r\nGLEW_FUN_EXPORT PFNGLGETBUFFERPOINTERVPROC __glewGetBufferPointerv;\r\nGLEW_FUN_EXPORT PFNGLGETBUFFERSUBDATAPROC __glewGetBufferSubData;\r\nGLEW_FUN_EXPORT PFNGLGETQUERYOBJECTIVPROC __glewGetQueryObjectiv;\r\nGLEW_FUN_EXPORT PFNGLGETQUERYOBJECTUIVPROC __glewGetQueryObjectuiv;\r\nGLEW_FUN_EXPORT PFNGLGETQUERYIVPROC __glewGetQueryiv;\r\nGLEW_FUN_EXPORT PFNGLISBUFFERPROC __glewIsBuffer;\r\nGLEW_FUN_EXPORT PFNGLISQUERYPROC __glewIsQuery;\r\nGLEW_FUN_EXPORT PFNGLMAPBUFFERPROC __glewMapBuffer;\r\nGLEW_FUN_EXPORT PFNGLUNMAPBUFFERPROC __glewUnmapBuffer;\r\n\r\nGLEW_FUN_EXPORT PFNGLATTACHSHADERPROC __glewAttachShader;\r\nGLEW_FUN_EXPORT PFNGLBINDATTRIBLOCATIONPROC __glewBindAttribLocation;\r\nGLEW_FUN_EXPORT PFNGLBLENDEQUATIONSEPARATEPROC __glewBlendEquationSeparate;\r\nGLEW_FUN_EXPORT PFNGLCOMPILESHADERPROC __glewCompileShader;\r\nGLEW_FUN_EXPORT PFNGLCREATEPROGRAMPROC __glewCreateProgram;\r\nGLEW_FUN_EXPORT PFNGLCREATESHADERPROC __glewCreateShader;\r\nGLEW_FUN_EXPORT PFNGLDELETEPROGRAMPROC __glewDeleteProgram;\r\nGLEW_FUN_EXPORT PFNGLDELETESHADERPROC __glewDeleteShader;\r\nGLEW_FUN_EXPORT PFNGLDETACHSHADERPROC __glewDetachShader;\r\nGLEW_FUN_EXPORT PFNGLDISABLEVERTEXATTRIBARRAYPROC __glewDisableVertexAttribArray;\r\nGLEW_FUN_EXPORT PFNGLDRAWBUFFERSPROC __glewDrawBuffers;\r\nGLEW_FUN_EXPORT PFNGLENABLEVERTEXATTRIBARRAYPROC __glewEnableVertexAttribArray;\r\nGLEW_FUN_EXPORT PFNGLGETACTIVEATTRIBPROC __glewGetActiveAttrib;\r\nGLEW_FUN_EXPORT PFNGLGETACTIVEUNIFORMPROC __glewGetActiveUniform;\r\nGLEW_FUN_EXPORT PFNGLGETATTACHEDSHADERSPROC __glewGetAttachedShaders;\r\nGLEW_FUN_EXPORT PFNGLGETATTRIBLOCATIONPROC __glewGetAttribLocation;\r\nGLEW_FUN_EXPORT PFNGLGETPROGRAMINFOLOGPROC __glewGetProgramInfoLog;\r\nGLEW_FUN_EXPORT PFNGLGETPROGRAMIVPROC __glewGetProgramiv;\r\nGLEW_FUN_EXPORT PFNGLGETSHADERINFOLOGPROC __glewGetShaderInfoLog;\r\nGLEW_FUN_EXPORT PFNGLGETSHADERSOURCEPROC __glewGetShaderSource;\r\nGLEW_FUN_EXPORT PFNGLGETSHADERIVPROC __glewGetShaderiv;\r\nGLEW_FUN_EXPORT PFNGLGETUNIFORMLOCATIONPROC __glewGetUniformLocation;\r\nGLEW_FUN_EXPORT PFNGLGETUNIFORMFVPROC __glewGetUniformfv;\r\nGLEW_FUN_EXPORT PFNGLGETUNIFORMIVPROC __glewGetUniformiv;\r\nGLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBPOINTERVPROC __glewGetVertexAttribPointerv;\r\nGLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBDVPROC __glewGetVertexAttribdv;\r\nGLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBFVPROC __glewGetVertexAttribfv;\r\nGLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBIVPROC __glewGetVertexAttribiv;\r\nGLEW_FUN_EXPORT PFNGLISPROGRAMPROC __glewIsProgram;\r\nGLEW_FUN_EXPORT PFNGLISSHADERPROC __glewIsShader;\r\nGLEW_FUN_EXPORT PFNGLLINKPROGRAMPROC __glewLinkProgram;\r\nGLEW_FUN_EXPORT PFNGLSHADERSOURCEPROC __glewShaderSource;\r\nGLEW_FUN_EXPORT PFNGLSTENCILFUNCSEPARATEPROC __glewStencilFuncSeparate;\r\nGLEW_FUN_EXPORT PFNGLSTENCILMASKSEPARATEPROC __glewStencilMaskSeparate;\r\nGLEW_FUN_EXPORT PFNGLSTENCILOPSEPARATEPROC __glewStencilOpSeparate;\r\nGLEW_FUN_EXPORT PFNGLUNIFORM1FPROC __glewUniform1f;\r\nGLEW_FUN_EXPORT PFNGLUNIFORM1FVPROC __glewUniform1fv;\r\nGLEW_FUN_EXPORT PFNGLUNIFORM1IPROC __glewUniform1i;\r\nGLEW_FUN_EXPORT PFNGLUNIFORM1IVPROC __glewUniform1iv;\r\nGLEW_FUN_EXPORT PFNGLUNIFORM2FPROC __glewUniform2f;\r\nGLEW_FUN_EXPORT PFNGLUNIFORM2FVPROC __glewUniform2fv;\r\nGLEW_FUN_EXPORT PFNGLUNIFORM2IPROC __glewUniform2i;\r\nGLEW_FUN_EXPORT PFNGLUNIFORM2IVPROC __glewUniform2iv;\r\nGLEW_FUN_EXPORT PFNGLUNIFORM3FPROC __glewUniform3f;\r\nGLEW_FUN_EXPORT PFNGLUNIFORM3FVPROC __glewUniform3fv;\r\nGLEW_FUN_EXPORT PFNGLUNIFORM3IPROC __glewUniform3i;\r\nGLEW_FUN_EXPORT PFNGLUNIFORM3IVPROC __glewUniform3iv;\r\nGLEW_FUN_EXPORT PFNGLUNIFORM4FPROC __glewUniform4f;\r\nGLEW_FUN_EXPORT PFNGLUNIFORM4FVPROC __glewUniform4fv;\r\nGLEW_FUN_EXPORT PFNGLUNIFORM4IPROC __glewUniform4i;\r\nGLEW_FUN_EXPORT PFNGLUNIFORM4IVPROC __glewUniform4iv;\r\nGLEW_FUN_EXPORT PFNGLUNIFORMMATRIX2FVPROC __glewUniformMatrix2fv;\r\nGLEW_FUN_EXPORT PFNGLUNIFORMMATRIX3FVPROC __glewUniformMatrix3fv;\r\nGLEW_FUN_EXPORT PFNGLUNIFORMMATRIX4FVPROC __glewUniformMatrix4fv;\r\nGLEW_FUN_EXPORT PFNGLUSEPROGRAMPROC __glewUseProgram;\r\nGLEW_FUN_EXPORT PFNGLVALIDATEPROGRAMPROC __glewValidateProgram;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB1DPROC __glewVertexAttrib1d;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB1DVPROC __glewVertexAttrib1dv;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB1FPROC __glewVertexAttrib1f;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB1FVPROC __glewVertexAttrib1fv;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB1SPROC __glewVertexAttrib1s;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB1SVPROC __glewVertexAttrib1sv;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB2DPROC __glewVertexAttrib2d;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB2DVPROC __glewVertexAttrib2dv;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB2FPROC __glewVertexAttrib2f;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB2FVPROC __glewVertexAttrib2fv;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB2SPROC __glewVertexAttrib2s;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB2SVPROC __glewVertexAttrib2sv;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB3DPROC __glewVertexAttrib3d;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB3DVPROC __glewVertexAttrib3dv;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB3FPROC __glewVertexAttrib3f;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB3FVPROC __glewVertexAttrib3fv;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB3SPROC __glewVertexAttrib3s;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB3SVPROC __glewVertexAttrib3sv;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NBVPROC __glewVertexAttrib4Nbv;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NIVPROC __glewVertexAttrib4Niv;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NSVPROC __glewVertexAttrib4Nsv;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NUBPROC __glewVertexAttrib4Nub;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NUBVPROC __glewVertexAttrib4Nubv;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NUIVPROC __glewVertexAttrib4Nuiv;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NUSVPROC __glewVertexAttrib4Nusv;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB4BVPROC __glewVertexAttrib4bv;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB4DPROC __glewVertexAttrib4d;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB4DVPROC __glewVertexAttrib4dv;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB4FPROC __glewVertexAttrib4f;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB4FVPROC __glewVertexAttrib4fv;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB4IVPROC __glewVertexAttrib4iv;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB4SPROC __glewVertexAttrib4s;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB4SVPROC __glewVertexAttrib4sv;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB4UBVPROC __glewVertexAttrib4ubv;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB4UIVPROC __glewVertexAttrib4uiv;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB4USVPROC __glewVertexAttrib4usv;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBPOINTERPROC __glewVertexAttribPointer;\r\n\r\nGLEW_FUN_EXPORT PFNGLUNIFORMMATRIX2X3FVPROC __glewUniformMatrix2x3fv;\r\nGLEW_FUN_EXPORT PFNGLUNIFORMMATRIX2X4FVPROC __glewUniformMatrix2x4fv;\r\nGLEW_FUN_EXPORT PFNGLUNIFORMMATRIX3X2FVPROC __glewUniformMatrix3x2fv;\r\nGLEW_FUN_EXPORT PFNGLUNIFORMMATRIX3X4FVPROC __glewUniformMatrix3x4fv;\r\nGLEW_FUN_EXPORT PFNGLUNIFORMMATRIX4X2FVPROC __glewUniformMatrix4x2fv;\r\nGLEW_FUN_EXPORT PFNGLUNIFORMMATRIX4X3FVPROC __glewUniformMatrix4x3fv;\r\n\r\nGLEW_FUN_EXPORT PFNGLBEGINCONDITIONALRENDERPROC __glewBeginConditionalRender;\r\nGLEW_FUN_EXPORT PFNGLBEGINTRANSFORMFEEDBACKPROC __glewBeginTransformFeedback;\r\nGLEW_FUN_EXPORT PFNGLBINDFRAGDATALOCATIONPROC __glewBindFragDataLocation;\r\nGLEW_FUN_EXPORT PFNGLCLAMPCOLORPROC __glewClampColor;\r\nGLEW_FUN_EXPORT PFNGLCLEARBUFFERFIPROC __glewClearBufferfi;\r\nGLEW_FUN_EXPORT PFNGLCLEARBUFFERFVPROC __glewClearBufferfv;\r\nGLEW_FUN_EXPORT PFNGLCLEARBUFFERIVPROC __glewClearBufferiv;\r\nGLEW_FUN_EXPORT PFNGLCLEARBUFFERUIVPROC __glewClearBufferuiv;\r\nGLEW_FUN_EXPORT PFNGLCOLORMASKIPROC __glewColorMaski;\r\nGLEW_FUN_EXPORT PFNGLDISABLEIPROC __glewDisablei;\r\nGLEW_FUN_EXPORT PFNGLENABLEIPROC __glewEnablei;\r\nGLEW_FUN_EXPORT PFNGLENDCONDITIONALRENDERPROC __glewEndConditionalRender;\r\nGLEW_FUN_EXPORT PFNGLENDTRANSFORMFEEDBACKPROC __glewEndTransformFeedback;\r\nGLEW_FUN_EXPORT PFNGLGETBOOLEANI_VPROC __glewGetBooleani_v;\r\nGLEW_FUN_EXPORT PFNGLGETFRAGDATALOCATIONPROC __glewGetFragDataLocation;\r\nGLEW_FUN_EXPORT PFNGLGETSTRINGIPROC __glewGetStringi;\r\nGLEW_FUN_EXPORT PFNGLGETTEXPARAMETERIIVPROC __glewGetTexParameterIiv;\r\nGLEW_FUN_EXPORT PFNGLGETTEXPARAMETERIUIVPROC __glewGetTexParameterIuiv;\r\nGLEW_FUN_EXPORT PFNGLGETTRANSFORMFEEDBACKVARYINGPROC __glewGetTransformFeedbackVarying;\r\nGLEW_FUN_EXPORT PFNGLGETUNIFORMUIVPROC __glewGetUniformuiv;\r\nGLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBIIVPROC __glewGetVertexAttribIiv;\r\nGLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBIUIVPROC __glewGetVertexAttribIuiv;\r\nGLEW_FUN_EXPORT PFNGLISENABLEDIPROC __glewIsEnabledi;\r\nGLEW_FUN_EXPORT PFNGLTEXPARAMETERIIVPROC __glewTexParameterIiv;\r\nGLEW_FUN_EXPORT PFNGLTEXPARAMETERIUIVPROC __glewTexParameterIuiv;\r\nGLEW_FUN_EXPORT PFNGLTRANSFORMFEEDBACKVARYINGSPROC __glewTransformFeedbackVaryings;\r\nGLEW_FUN_EXPORT PFNGLUNIFORM1UIPROC __glewUniform1ui;\r\nGLEW_FUN_EXPORT PFNGLUNIFORM1UIVPROC __glewUniform1uiv;\r\nGLEW_FUN_EXPORT PFNGLUNIFORM2UIPROC __glewUniform2ui;\r\nGLEW_FUN_EXPORT PFNGLUNIFORM2UIVPROC __glewUniform2uiv;\r\nGLEW_FUN_EXPORT PFNGLUNIFORM3UIPROC __glewUniform3ui;\r\nGLEW_FUN_EXPORT PFNGLUNIFORM3UIVPROC __glewUniform3uiv;\r\nGLEW_FUN_EXPORT PFNGLUNIFORM4UIPROC __glewUniform4ui;\r\nGLEW_FUN_EXPORT PFNGLUNIFORM4UIVPROC __glewUniform4uiv;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBI1IPROC __glewVertexAttribI1i;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBI1IVPROC __glewVertexAttribI1iv;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBI1UIPROC __glewVertexAttribI1ui;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBI1UIVPROC __glewVertexAttribI1uiv;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBI2IPROC __glewVertexAttribI2i;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBI2IVPROC __glewVertexAttribI2iv;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBI2UIPROC __glewVertexAttribI2ui;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBI2UIVPROC __glewVertexAttribI2uiv;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBI3IPROC __glewVertexAttribI3i;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBI3IVPROC __glewVertexAttribI3iv;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBI3UIPROC __glewVertexAttribI3ui;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBI3UIVPROC __glewVertexAttribI3uiv;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4BVPROC __glewVertexAttribI4bv;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4IPROC __glewVertexAttribI4i;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4IVPROC __glewVertexAttribI4iv;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4SVPROC __glewVertexAttribI4sv;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4UBVPROC __glewVertexAttribI4ubv;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4UIPROC __glewVertexAttribI4ui;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4UIVPROC __glewVertexAttribI4uiv;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4USVPROC __glewVertexAttribI4usv;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBIPOINTERPROC __glewVertexAttribIPointer;\r\n\r\nGLEW_FUN_EXPORT PFNGLDRAWARRAYSINSTANCEDPROC __glewDrawArraysInstanced;\r\nGLEW_FUN_EXPORT PFNGLDRAWELEMENTSINSTANCEDPROC __glewDrawElementsInstanced;\r\nGLEW_FUN_EXPORT PFNGLPRIMITIVERESTARTINDEXPROC __glewPrimitiveRestartIndex;\r\nGLEW_FUN_EXPORT PFNGLTEXBUFFERPROC __glewTexBuffer;\r\n\r\nGLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTUREPROC __glewFramebufferTexture;\r\nGLEW_FUN_EXPORT PFNGLGETBUFFERPARAMETERI64VPROC __glewGetBufferParameteri64v;\r\nGLEW_FUN_EXPORT PFNGLGETINTEGER64I_VPROC __glewGetInteger64i_v;\r\n\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBDIVISORPROC __glewVertexAttribDivisor;\r\n\r\nGLEW_FUN_EXPORT PFNGLBLENDEQUATIONSEPARATEIPROC __glewBlendEquationSeparatei;\r\nGLEW_FUN_EXPORT PFNGLBLENDEQUATIONIPROC __glewBlendEquationi;\r\nGLEW_FUN_EXPORT PFNGLBLENDFUNCSEPARATEIPROC __glewBlendFuncSeparatei;\r\nGLEW_FUN_EXPORT PFNGLBLENDFUNCIPROC __glewBlendFunci;\r\nGLEW_FUN_EXPORT PFNGLMINSAMPLESHADINGPROC __glewMinSampleShading;\r\n\r\nGLEW_FUN_EXPORT PFNGLGETGRAPHICSRESETSTATUSPROC __glewGetGraphicsResetStatus;\r\nGLEW_FUN_EXPORT PFNGLGETNCOMPRESSEDTEXIMAGEPROC __glewGetnCompressedTexImage;\r\nGLEW_FUN_EXPORT PFNGLGETNTEXIMAGEPROC __glewGetnTexImage;\r\nGLEW_FUN_EXPORT PFNGLGETNUNIFORMDVPROC __glewGetnUniformdv;\r\n\r\nGLEW_FUN_EXPORT PFNGLTBUFFERMASK3DFXPROC __glewTbufferMask3DFX;\r\n\r\nGLEW_FUN_EXPORT PFNGLDEBUGMESSAGECALLBACKAMDPROC __glewDebugMessageCallbackAMD;\r\nGLEW_FUN_EXPORT PFNGLDEBUGMESSAGEENABLEAMDPROC __glewDebugMessageEnableAMD;\r\nGLEW_FUN_EXPORT PFNGLDEBUGMESSAGEINSERTAMDPROC __glewDebugMessageInsertAMD;\r\nGLEW_FUN_EXPORT PFNGLGETDEBUGMESSAGELOGAMDPROC __glewGetDebugMessageLogAMD;\r\n\r\nGLEW_FUN_EXPORT PFNGLBLENDEQUATIONINDEXEDAMDPROC __glewBlendEquationIndexedAMD;\r\nGLEW_FUN_EXPORT PFNGLBLENDEQUATIONSEPARATEINDEXEDAMDPROC __glewBlendEquationSeparateIndexedAMD;\r\nGLEW_FUN_EXPORT PFNGLBLENDFUNCINDEXEDAMDPROC __glewBlendFuncIndexedAMD;\r\nGLEW_FUN_EXPORT PFNGLBLENDFUNCSEPARATEINDEXEDAMDPROC __glewBlendFuncSeparateIndexedAMD;\r\n\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBPARAMETERIAMDPROC __glewVertexAttribParameteriAMD;\r\n\r\nGLEW_FUN_EXPORT PFNGLMULTIDRAWARRAYSINDIRECTAMDPROC __glewMultiDrawArraysIndirectAMD;\r\nGLEW_FUN_EXPORT PFNGLMULTIDRAWELEMENTSINDIRECTAMDPROC __glewMultiDrawElementsIndirectAMD;\r\n\r\nGLEW_FUN_EXPORT PFNGLDELETENAMESAMDPROC __glewDeleteNamesAMD;\r\nGLEW_FUN_EXPORT PFNGLGENNAMESAMDPROC __glewGenNamesAMD;\r\nGLEW_FUN_EXPORT PFNGLISNAMEAMDPROC __glewIsNameAMD;\r\n\r\nGLEW_FUN_EXPORT PFNGLQUERYOBJECTPARAMETERUIAMDPROC __glewQueryObjectParameteruiAMD;\r\n\r\nGLEW_FUN_EXPORT PFNGLBEGINPERFMONITORAMDPROC __glewBeginPerfMonitorAMD;\r\nGLEW_FUN_EXPORT PFNGLDELETEPERFMONITORSAMDPROC __glewDeletePerfMonitorsAMD;\r\nGLEW_FUN_EXPORT PFNGLENDPERFMONITORAMDPROC __glewEndPerfMonitorAMD;\r\nGLEW_FUN_EXPORT PFNGLGENPERFMONITORSAMDPROC __glewGenPerfMonitorsAMD;\r\nGLEW_FUN_EXPORT PFNGLGETPERFMONITORCOUNTERDATAAMDPROC __glewGetPerfMonitorCounterDataAMD;\r\nGLEW_FUN_EXPORT PFNGLGETPERFMONITORCOUNTERINFOAMDPROC __glewGetPerfMonitorCounterInfoAMD;\r\nGLEW_FUN_EXPORT PFNGLGETPERFMONITORCOUNTERSTRINGAMDPROC __glewGetPerfMonitorCounterStringAMD;\r\nGLEW_FUN_EXPORT PFNGLGETPERFMONITORCOUNTERSAMDPROC __glewGetPerfMonitorCountersAMD;\r\nGLEW_FUN_EXPORT PFNGLGETPERFMONITORGROUPSTRINGAMDPROC __glewGetPerfMonitorGroupStringAMD;\r\nGLEW_FUN_EXPORT PFNGLGETPERFMONITORGROUPSAMDPROC __glewGetPerfMonitorGroupsAMD;\r\nGLEW_FUN_EXPORT PFNGLSELECTPERFMONITORCOUNTERSAMDPROC __glewSelectPerfMonitorCountersAMD;\r\n\r\nGLEW_FUN_EXPORT PFNGLSETMULTISAMPLEFVAMDPROC __glewSetMultisamplefvAMD;\r\n\r\nGLEW_FUN_EXPORT PFNGLTEXSTORAGESPARSEAMDPROC __glewTexStorageSparseAMD;\r\nGLEW_FUN_EXPORT PFNGLTEXTURESTORAGESPARSEAMDPROC __glewTextureStorageSparseAMD;\r\n\r\nGLEW_FUN_EXPORT PFNGLSTENCILOPVALUEAMDPROC __glewStencilOpValueAMD;\r\n\r\nGLEW_FUN_EXPORT PFNGLTESSELLATIONFACTORAMDPROC __glewTessellationFactorAMD;\r\nGLEW_FUN_EXPORT PFNGLTESSELLATIONMODEAMDPROC __glewTessellationModeAMD;\r\n\r\nGLEW_FUN_EXPORT PFNGLBLITFRAMEBUFFERANGLEPROC __glewBlitFramebufferANGLE;\r\n\r\nGLEW_FUN_EXPORT PFNGLRENDERBUFFERSTORAGEMULTISAMPLEANGLEPROC __glewRenderbufferStorageMultisampleANGLE;\r\n\r\nGLEW_FUN_EXPORT PFNGLDRAWARRAYSINSTANCEDANGLEPROC __glewDrawArraysInstancedANGLE;\r\nGLEW_FUN_EXPORT PFNGLDRAWELEMENTSINSTANCEDANGLEPROC __glewDrawElementsInstancedANGLE;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBDIVISORANGLEPROC __glewVertexAttribDivisorANGLE;\r\n\r\nGLEW_FUN_EXPORT PFNGLBEGINQUERYANGLEPROC __glewBeginQueryANGLE;\r\nGLEW_FUN_EXPORT PFNGLDELETEQUERIESANGLEPROC __glewDeleteQueriesANGLE;\r\nGLEW_FUN_EXPORT PFNGLENDQUERYANGLEPROC __glewEndQueryANGLE;\r\nGLEW_FUN_EXPORT PFNGLGENQUERIESANGLEPROC __glewGenQueriesANGLE;\r\nGLEW_FUN_EXPORT PFNGLGETQUERYOBJECTI64VANGLEPROC __glewGetQueryObjecti64vANGLE;\r\nGLEW_FUN_EXPORT PFNGLGETQUERYOBJECTIVANGLEPROC __glewGetQueryObjectivANGLE;\r\nGLEW_FUN_EXPORT PFNGLGETQUERYOBJECTUI64VANGLEPROC __glewGetQueryObjectui64vANGLE;\r\nGLEW_FUN_EXPORT PFNGLGETQUERYOBJECTUIVANGLEPROC __glewGetQueryObjectuivANGLE;\r\nGLEW_FUN_EXPORT PFNGLGETQUERYIVANGLEPROC __glewGetQueryivANGLE;\r\nGLEW_FUN_EXPORT PFNGLISQUERYANGLEPROC __glewIsQueryANGLE;\r\nGLEW_FUN_EXPORT PFNGLQUERYCOUNTERANGLEPROC __glewQueryCounterANGLE;\r\n\r\nGLEW_FUN_EXPORT PFNGLGETTRANSLATEDSHADERSOURCEANGLEPROC __glewGetTranslatedShaderSourceANGLE;\r\n\r\nGLEW_FUN_EXPORT PFNGLDRAWELEMENTARRAYAPPLEPROC __glewDrawElementArrayAPPLE;\r\nGLEW_FUN_EXPORT PFNGLDRAWRANGEELEMENTARRAYAPPLEPROC __glewDrawRangeElementArrayAPPLE;\r\nGLEW_FUN_EXPORT PFNGLELEMENTPOINTERAPPLEPROC __glewElementPointerAPPLE;\r\nGLEW_FUN_EXPORT PFNGLMULTIDRAWELEMENTARRAYAPPLEPROC __glewMultiDrawElementArrayAPPLE;\r\nGLEW_FUN_EXPORT PFNGLMULTIDRAWRANGEELEMENTARRAYAPPLEPROC __glewMultiDrawRangeElementArrayAPPLE;\r\n\r\nGLEW_FUN_EXPORT PFNGLDELETEFENCESAPPLEPROC __glewDeleteFencesAPPLE;\r\nGLEW_FUN_EXPORT PFNGLFINISHFENCEAPPLEPROC __glewFinishFenceAPPLE;\r\nGLEW_FUN_EXPORT PFNGLFINISHOBJECTAPPLEPROC __glewFinishObjectAPPLE;\r\nGLEW_FUN_EXPORT PFNGLGENFENCESAPPLEPROC __glewGenFencesAPPLE;\r\nGLEW_FUN_EXPORT PFNGLISFENCEAPPLEPROC __glewIsFenceAPPLE;\r\nGLEW_FUN_EXPORT PFNGLSETFENCEAPPLEPROC __glewSetFenceAPPLE;\r\nGLEW_FUN_EXPORT PFNGLTESTFENCEAPPLEPROC __glewTestFenceAPPLE;\r\nGLEW_FUN_EXPORT PFNGLTESTOBJECTAPPLEPROC __glewTestObjectAPPLE;\r\n\r\nGLEW_FUN_EXPORT PFNGLBUFFERPARAMETERIAPPLEPROC __glewBufferParameteriAPPLE;\r\nGLEW_FUN_EXPORT PFNGLFLUSHMAPPEDBUFFERRANGEAPPLEPROC __glewFlushMappedBufferRangeAPPLE;\r\n\r\nGLEW_FUN_EXPORT PFNGLGETOBJECTPARAMETERIVAPPLEPROC __glewGetObjectParameterivAPPLE;\r\nGLEW_FUN_EXPORT PFNGLOBJECTPURGEABLEAPPLEPROC __glewObjectPurgeableAPPLE;\r\nGLEW_FUN_EXPORT PFNGLOBJECTUNPURGEABLEAPPLEPROC __glewObjectUnpurgeableAPPLE;\r\n\r\nGLEW_FUN_EXPORT PFNGLGETTEXPARAMETERPOINTERVAPPLEPROC __glewGetTexParameterPointervAPPLE;\r\nGLEW_FUN_EXPORT PFNGLTEXTURERANGEAPPLEPROC __glewTextureRangeAPPLE;\r\n\r\nGLEW_FUN_EXPORT PFNGLBINDVERTEXARRAYAPPLEPROC __glewBindVertexArrayAPPLE;\r\nGLEW_FUN_EXPORT PFNGLDELETEVERTEXARRAYSAPPLEPROC __glewDeleteVertexArraysAPPLE;\r\nGLEW_FUN_EXPORT PFNGLGENVERTEXARRAYSAPPLEPROC __glewGenVertexArraysAPPLE;\r\nGLEW_FUN_EXPORT PFNGLISVERTEXARRAYAPPLEPROC __glewIsVertexArrayAPPLE;\r\n\r\nGLEW_FUN_EXPORT PFNGLFLUSHVERTEXARRAYRANGEAPPLEPROC __glewFlushVertexArrayRangeAPPLE;\r\nGLEW_FUN_EXPORT PFNGLVERTEXARRAYPARAMETERIAPPLEPROC __glewVertexArrayParameteriAPPLE;\r\nGLEW_FUN_EXPORT PFNGLVERTEXARRAYRANGEAPPLEPROC __glewVertexArrayRangeAPPLE;\r\n\r\nGLEW_FUN_EXPORT PFNGLDISABLEVERTEXATTRIBAPPLEPROC __glewDisableVertexAttribAPPLE;\r\nGLEW_FUN_EXPORT PFNGLENABLEVERTEXATTRIBAPPLEPROC __glewEnableVertexAttribAPPLE;\r\nGLEW_FUN_EXPORT PFNGLISVERTEXATTRIBENABLEDAPPLEPROC __glewIsVertexAttribEnabledAPPLE;\r\nGLEW_FUN_EXPORT PFNGLMAPVERTEXATTRIB1DAPPLEPROC __glewMapVertexAttrib1dAPPLE;\r\nGLEW_FUN_EXPORT PFNGLMAPVERTEXATTRIB1FAPPLEPROC __glewMapVertexAttrib1fAPPLE;\r\nGLEW_FUN_EXPORT PFNGLMAPVERTEXATTRIB2DAPPLEPROC __glewMapVertexAttrib2dAPPLE;\r\nGLEW_FUN_EXPORT PFNGLMAPVERTEXATTRIB2FAPPLEPROC __glewMapVertexAttrib2fAPPLE;\r\n\r\nGLEW_FUN_EXPORT PFNGLCLEARDEPTHFPROC __glewClearDepthf;\r\nGLEW_FUN_EXPORT PFNGLDEPTHRANGEFPROC __glewDepthRangef;\r\nGLEW_FUN_EXPORT PFNGLGETSHADERPRECISIONFORMATPROC __glewGetShaderPrecisionFormat;\r\nGLEW_FUN_EXPORT PFNGLRELEASESHADERCOMPILERPROC __glewReleaseShaderCompiler;\r\nGLEW_FUN_EXPORT PFNGLSHADERBINARYPROC __glewShaderBinary;\r\n\r\nGLEW_FUN_EXPORT PFNGLMEMORYBARRIERBYREGIONPROC __glewMemoryBarrierByRegion;\r\n\r\nGLEW_FUN_EXPORT PFNGLPRIMITIVEBOUNDINGBOXARBPROC __glewPrimitiveBoundingBoxARB;\r\n\r\nGLEW_FUN_EXPORT PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEPROC __glewDrawArraysInstancedBaseInstance;\r\nGLEW_FUN_EXPORT PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEPROC __glewDrawElementsInstancedBaseInstance;\r\nGLEW_FUN_EXPORT PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEPROC __glewDrawElementsInstancedBaseVertexBaseInstance;\r\n\r\nGLEW_FUN_EXPORT PFNGLGETIMAGEHANDLEARBPROC __glewGetImageHandleARB;\r\nGLEW_FUN_EXPORT PFNGLGETTEXTUREHANDLEARBPROC __glewGetTextureHandleARB;\r\nGLEW_FUN_EXPORT PFNGLGETTEXTURESAMPLERHANDLEARBPROC __glewGetTextureSamplerHandleARB;\r\nGLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBLUI64VARBPROC __glewGetVertexAttribLui64vARB;\r\nGLEW_FUN_EXPORT PFNGLISIMAGEHANDLERESIDENTARBPROC __glewIsImageHandleResidentARB;\r\nGLEW_FUN_EXPORT PFNGLISTEXTUREHANDLERESIDENTARBPROC __glewIsTextureHandleResidentARB;\r\nGLEW_FUN_EXPORT PFNGLMAKEIMAGEHANDLENONRESIDENTARBPROC __glewMakeImageHandleNonResidentARB;\r\nGLEW_FUN_EXPORT PFNGLMAKEIMAGEHANDLERESIDENTARBPROC __glewMakeImageHandleResidentARB;\r\nGLEW_FUN_EXPORT PFNGLMAKETEXTUREHANDLENONRESIDENTARBPROC __glewMakeTextureHandleNonResidentARB;\r\nGLEW_FUN_EXPORT PFNGLMAKETEXTUREHANDLERESIDENTARBPROC __glewMakeTextureHandleResidentARB;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMHANDLEUI64ARBPROC __glewProgramUniformHandleui64ARB;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMHANDLEUI64VARBPROC __glewProgramUniformHandleui64vARB;\r\nGLEW_FUN_EXPORT PFNGLUNIFORMHANDLEUI64ARBPROC __glewUniformHandleui64ARB;\r\nGLEW_FUN_EXPORT PFNGLUNIFORMHANDLEUI64VARBPROC __glewUniformHandleui64vARB;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBL1UI64ARBPROC __glewVertexAttribL1ui64ARB;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBL1UI64VARBPROC __glewVertexAttribL1ui64vARB;\r\n\r\nGLEW_FUN_EXPORT PFNGLBINDFRAGDATALOCATIONINDEXEDPROC __glewBindFragDataLocationIndexed;\r\nGLEW_FUN_EXPORT PFNGLGETFRAGDATAINDEXPROC __glewGetFragDataIndex;\r\n\r\nGLEW_FUN_EXPORT PFNGLBUFFERSTORAGEPROC __glewBufferStorage;\r\nGLEW_FUN_EXPORT PFNGLNAMEDBUFFERSTORAGEEXTPROC __glewNamedBufferStorageEXT;\r\n\r\nGLEW_FUN_EXPORT PFNGLCREATESYNCFROMCLEVENTARBPROC __glewCreateSyncFromCLeventARB;\r\n\r\nGLEW_FUN_EXPORT PFNGLCLEARBUFFERDATAPROC __glewClearBufferData;\r\nGLEW_FUN_EXPORT PFNGLCLEARBUFFERSUBDATAPROC __glewClearBufferSubData;\r\nGLEW_FUN_EXPORT PFNGLCLEARNAMEDBUFFERDATAEXTPROC __glewClearNamedBufferDataEXT;\r\nGLEW_FUN_EXPORT PFNGLCLEARNAMEDBUFFERSUBDATAEXTPROC __glewClearNamedBufferSubDataEXT;\r\n\r\nGLEW_FUN_EXPORT PFNGLCLEARTEXIMAGEPROC __glewClearTexImage;\r\nGLEW_FUN_EXPORT PFNGLCLEARTEXSUBIMAGEPROC __glewClearTexSubImage;\r\n\r\nGLEW_FUN_EXPORT PFNGLCLIPCONTROLPROC __glewClipControl;\r\n\r\nGLEW_FUN_EXPORT PFNGLCLAMPCOLORARBPROC __glewClampColorARB;\r\n\r\nGLEW_FUN_EXPORT PFNGLDISPATCHCOMPUTEPROC __glewDispatchCompute;\r\nGLEW_FUN_EXPORT PFNGLDISPATCHCOMPUTEINDIRECTPROC __glewDispatchComputeIndirect;\r\n\r\nGLEW_FUN_EXPORT PFNGLDISPATCHCOMPUTEGROUPSIZEARBPROC __glewDispatchComputeGroupSizeARB;\r\n\r\nGLEW_FUN_EXPORT PFNGLCOPYBUFFERSUBDATAPROC __glewCopyBufferSubData;\r\n\r\nGLEW_FUN_EXPORT PFNGLCOPYIMAGESUBDATAPROC __glewCopyImageSubData;\r\n\r\nGLEW_FUN_EXPORT PFNGLDEBUGMESSAGECALLBACKARBPROC __glewDebugMessageCallbackARB;\r\nGLEW_FUN_EXPORT PFNGLDEBUGMESSAGECONTROLARBPROC __glewDebugMessageControlARB;\r\nGLEW_FUN_EXPORT PFNGLDEBUGMESSAGEINSERTARBPROC __glewDebugMessageInsertARB;\r\nGLEW_FUN_EXPORT PFNGLGETDEBUGMESSAGELOGARBPROC __glewGetDebugMessageLogARB;\r\n\r\nGLEW_FUN_EXPORT PFNGLBINDTEXTUREUNITPROC __glewBindTextureUnit;\r\nGLEW_FUN_EXPORT PFNGLBLITNAMEDFRAMEBUFFERPROC __glewBlitNamedFramebuffer;\r\nGLEW_FUN_EXPORT PFNGLCHECKNAMEDFRAMEBUFFERSTATUSPROC __glewCheckNamedFramebufferStatus;\r\nGLEW_FUN_EXPORT PFNGLCLEARNAMEDBUFFERDATAPROC __glewClearNamedBufferData;\r\nGLEW_FUN_EXPORT PFNGLCLEARNAMEDBUFFERSUBDATAPROC __glewClearNamedBufferSubData;\r\nGLEW_FUN_EXPORT PFNGLCLEARNAMEDFRAMEBUFFERFIPROC __glewClearNamedFramebufferfi;\r\nGLEW_FUN_EXPORT PFNGLCLEARNAMEDFRAMEBUFFERFVPROC __glewClearNamedFramebufferfv;\r\nGLEW_FUN_EXPORT PFNGLCLEARNAMEDFRAMEBUFFERIVPROC __glewClearNamedFramebufferiv;\r\nGLEW_FUN_EXPORT PFNGLCLEARNAMEDFRAMEBUFFERUIVPROC __glewClearNamedFramebufferuiv;\r\nGLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXTURESUBIMAGE1DPROC __glewCompressedTextureSubImage1D;\r\nGLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXTURESUBIMAGE2DPROC __glewCompressedTextureSubImage2D;\r\nGLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXTURESUBIMAGE3DPROC __glewCompressedTextureSubImage3D;\r\nGLEW_FUN_EXPORT PFNGLCOPYNAMEDBUFFERSUBDATAPROC __glewCopyNamedBufferSubData;\r\nGLEW_FUN_EXPORT PFNGLCOPYTEXTURESUBIMAGE1DPROC __glewCopyTextureSubImage1D;\r\nGLEW_FUN_EXPORT PFNGLCOPYTEXTURESUBIMAGE2DPROC __glewCopyTextureSubImage2D;\r\nGLEW_FUN_EXPORT PFNGLCOPYTEXTURESUBIMAGE3DPROC __glewCopyTextureSubImage3D;\r\nGLEW_FUN_EXPORT PFNGLCREATEBUFFERSPROC __glewCreateBuffers;\r\nGLEW_FUN_EXPORT PFNGLCREATEFRAMEBUFFERSPROC __glewCreateFramebuffers;\r\nGLEW_FUN_EXPORT PFNGLCREATEPROGRAMPIPELINESPROC __glewCreateProgramPipelines;\r\nGLEW_FUN_EXPORT PFNGLCREATEQUERIESPROC __glewCreateQueries;\r\nGLEW_FUN_EXPORT PFNGLCREATERENDERBUFFERSPROC __glewCreateRenderbuffers;\r\nGLEW_FUN_EXPORT PFNGLCREATESAMPLERSPROC __glewCreateSamplers;\r\nGLEW_FUN_EXPORT PFNGLCREATETEXTURESPROC __glewCreateTextures;\r\nGLEW_FUN_EXPORT PFNGLCREATETRANSFORMFEEDBACKSPROC __glewCreateTransformFeedbacks;\r\nGLEW_FUN_EXPORT PFNGLCREATEVERTEXARRAYSPROC __glewCreateVertexArrays;\r\nGLEW_FUN_EXPORT PFNGLDISABLEVERTEXARRAYATTRIBPROC __glewDisableVertexArrayAttrib;\r\nGLEW_FUN_EXPORT PFNGLENABLEVERTEXARRAYATTRIBPROC __glewEnableVertexArrayAttrib;\r\nGLEW_FUN_EXPORT PFNGLFLUSHMAPPEDNAMEDBUFFERRANGEPROC __glewFlushMappedNamedBufferRange;\r\nGLEW_FUN_EXPORT PFNGLGENERATETEXTUREMIPMAPPROC __glewGenerateTextureMipmap;\r\nGLEW_FUN_EXPORT PFNGLGETCOMPRESSEDTEXTUREIMAGEPROC __glewGetCompressedTextureImage;\r\nGLEW_FUN_EXPORT PFNGLGETNAMEDBUFFERPARAMETERI64VPROC __glewGetNamedBufferParameteri64v;\r\nGLEW_FUN_EXPORT PFNGLGETNAMEDBUFFERPARAMETERIVPROC __glewGetNamedBufferParameteriv;\r\nGLEW_FUN_EXPORT PFNGLGETNAMEDBUFFERPOINTERVPROC __glewGetNamedBufferPointerv;\r\nGLEW_FUN_EXPORT PFNGLGETNAMEDBUFFERSUBDATAPROC __glewGetNamedBufferSubData;\r\nGLEW_FUN_EXPORT PFNGLGETNAMEDFRAMEBUFFERATTACHMENTPARAMETERIVPROC __glewGetNamedFramebufferAttachmentParameteriv;\r\nGLEW_FUN_EXPORT PFNGLGETNAMEDFRAMEBUFFERPARAMETERIVPROC __glewGetNamedFramebufferParameteriv;\r\nGLEW_FUN_EXPORT PFNGLGETNAMEDRENDERBUFFERPARAMETERIVPROC __glewGetNamedRenderbufferParameteriv;\r\nGLEW_FUN_EXPORT PFNGLGETQUERYBUFFEROBJECTI64VPROC __glewGetQueryBufferObjecti64v;\r\nGLEW_FUN_EXPORT PFNGLGETQUERYBUFFEROBJECTIVPROC __glewGetQueryBufferObjectiv;\r\nGLEW_FUN_EXPORT PFNGLGETQUERYBUFFEROBJECTUI64VPROC __glewGetQueryBufferObjectui64v;\r\nGLEW_FUN_EXPORT PFNGLGETQUERYBUFFEROBJECTUIVPROC __glewGetQueryBufferObjectuiv;\r\nGLEW_FUN_EXPORT PFNGLGETTEXTUREIMAGEPROC __glewGetTextureImage;\r\nGLEW_FUN_EXPORT PFNGLGETTEXTURELEVELPARAMETERFVPROC __glewGetTextureLevelParameterfv;\r\nGLEW_FUN_EXPORT PFNGLGETTEXTURELEVELPARAMETERIVPROC __glewGetTextureLevelParameteriv;\r\nGLEW_FUN_EXPORT PFNGLGETTEXTUREPARAMETERIIVPROC __glewGetTextureParameterIiv;\r\nGLEW_FUN_EXPORT PFNGLGETTEXTUREPARAMETERIUIVPROC __glewGetTextureParameterIuiv;\r\nGLEW_FUN_EXPORT PFNGLGETTEXTUREPARAMETERFVPROC __glewGetTextureParameterfv;\r\nGLEW_FUN_EXPORT PFNGLGETTEXTUREPARAMETERIVPROC __glewGetTextureParameteriv;\r\nGLEW_FUN_EXPORT PFNGLGETTRANSFORMFEEDBACKI64_VPROC __glewGetTransformFeedbacki64_v;\r\nGLEW_FUN_EXPORT PFNGLGETTRANSFORMFEEDBACKI_VPROC __glewGetTransformFeedbacki_v;\r\nGLEW_FUN_EXPORT PFNGLGETTRANSFORMFEEDBACKIVPROC __glewGetTransformFeedbackiv;\r\nGLEW_FUN_EXPORT PFNGLGETVERTEXARRAYINDEXED64IVPROC __glewGetVertexArrayIndexed64iv;\r\nGLEW_FUN_EXPORT PFNGLGETVERTEXARRAYINDEXEDIVPROC __glewGetVertexArrayIndexediv;\r\nGLEW_FUN_EXPORT PFNGLGETVERTEXARRAYIVPROC __glewGetVertexArrayiv;\r\nGLEW_FUN_EXPORT PFNGLINVALIDATENAMEDFRAMEBUFFERDATAPROC __glewInvalidateNamedFramebufferData;\r\nGLEW_FUN_EXPORT PFNGLINVALIDATENAMEDFRAMEBUFFERSUBDATAPROC __glewInvalidateNamedFramebufferSubData;\r\nGLEW_FUN_EXPORT PFNGLMAPNAMEDBUFFERPROC __glewMapNamedBuffer;\r\nGLEW_FUN_EXPORT PFNGLMAPNAMEDBUFFERRANGEPROC __glewMapNamedBufferRange;\r\nGLEW_FUN_EXPORT PFNGLNAMEDBUFFERDATAPROC __glewNamedBufferData;\r\nGLEW_FUN_EXPORT PFNGLNAMEDBUFFERSTORAGEPROC __glewNamedBufferStorage;\r\nGLEW_FUN_EXPORT PFNGLNAMEDBUFFERSUBDATAPROC __glewNamedBufferSubData;\r\nGLEW_FUN_EXPORT PFNGLNAMEDFRAMEBUFFERDRAWBUFFERPROC __glewNamedFramebufferDrawBuffer;\r\nGLEW_FUN_EXPORT PFNGLNAMEDFRAMEBUFFERDRAWBUFFERSPROC __glewNamedFramebufferDrawBuffers;\r\nGLEW_FUN_EXPORT PFNGLNAMEDFRAMEBUFFERPARAMETERIPROC __glewNamedFramebufferParameteri;\r\nGLEW_FUN_EXPORT PFNGLNAMEDFRAMEBUFFERREADBUFFERPROC __glewNamedFramebufferReadBuffer;\r\nGLEW_FUN_EXPORT PFNGLNAMEDFRAMEBUFFERRENDERBUFFERPROC __glewNamedFramebufferRenderbuffer;\r\nGLEW_FUN_EXPORT PFNGLNAMEDFRAMEBUFFERTEXTUREPROC __glewNamedFramebufferTexture;\r\nGLEW_FUN_EXPORT PFNGLNAMEDFRAMEBUFFERTEXTURELAYERPROC __glewNamedFramebufferTextureLayer;\r\nGLEW_FUN_EXPORT PFNGLNAMEDRENDERBUFFERSTORAGEPROC __glewNamedRenderbufferStorage;\r\nGLEW_FUN_EXPORT PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEPROC __glewNamedRenderbufferStorageMultisample;\r\nGLEW_FUN_EXPORT PFNGLTEXTUREBUFFERPROC __glewTextureBuffer;\r\nGLEW_FUN_EXPORT PFNGLTEXTUREBUFFERRANGEPROC __glewTextureBufferRange;\r\nGLEW_FUN_EXPORT PFNGLTEXTUREPARAMETERIIVPROC __glewTextureParameterIiv;\r\nGLEW_FUN_EXPORT PFNGLTEXTUREPARAMETERIUIVPROC __glewTextureParameterIuiv;\r\nGLEW_FUN_EXPORT PFNGLTEXTUREPARAMETERFPROC __glewTextureParameterf;\r\nGLEW_FUN_EXPORT PFNGLTEXTUREPARAMETERFVPROC __glewTextureParameterfv;\r\nGLEW_FUN_EXPORT PFNGLTEXTUREPARAMETERIPROC __glewTextureParameteri;\r\nGLEW_FUN_EXPORT PFNGLTEXTUREPARAMETERIVPROC __glewTextureParameteriv;\r\nGLEW_FUN_EXPORT PFNGLTEXTURESTORAGE1DPROC __glewTextureStorage1D;\r\nGLEW_FUN_EXPORT PFNGLTEXTURESTORAGE2DPROC __glewTextureStorage2D;\r\nGLEW_FUN_EXPORT PFNGLTEXTURESTORAGE2DMULTISAMPLEPROC __glewTextureStorage2DMultisample;\r\nGLEW_FUN_EXPORT PFNGLTEXTURESTORAGE3DPROC __glewTextureStorage3D;\r\nGLEW_FUN_EXPORT PFNGLTEXTURESTORAGE3DMULTISAMPLEPROC __glewTextureStorage3DMultisample;\r\nGLEW_FUN_EXPORT PFNGLTEXTURESUBIMAGE1DPROC __glewTextureSubImage1D;\r\nGLEW_FUN_EXPORT PFNGLTEXTURESUBIMAGE2DPROC __glewTextureSubImage2D;\r\nGLEW_FUN_EXPORT PFNGLTEXTURESUBIMAGE3DPROC __glewTextureSubImage3D;\r\nGLEW_FUN_EXPORT PFNGLTRANSFORMFEEDBACKBUFFERBASEPROC __glewTransformFeedbackBufferBase;\r\nGLEW_FUN_EXPORT PFNGLTRANSFORMFEEDBACKBUFFERRANGEPROC __glewTransformFeedbackBufferRange;\r\nGLEW_FUN_EXPORT PFNGLUNMAPNAMEDBUFFERPROC __glewUnmapNamedBuffer;\r\nGLEW_FUN_EXPORT PFNGLVERTEXARRAYATTRIBBINDINGPROC __glewVertexArrayAttribBinding;\r\nGLEW_FUN_EXPORT PFNGLVERTEXARRAYATTRIBFORMATPROC __glewVertexArrayAttribFormat;\r\nGLEW_FUN_EXPORT PFNGLVERTEXARRAYATTRIBIFORMATPROC __glewVertexArrayAttribIFormat;\r\nGLEW_FUN_EXPORT PFNGLVERTEXARRAYATTRIBLFORMATPROC __glewVertexArrayAttribLFormat;\r\nGLEW_FUN_EXPORT PFNGLVERTEXARRAYBINDINGDIVISORPROC __glewVertexArrayBindingDivisor;\r\nGLEW_FUN_EXPORT PFNGLVERTEXARRAYELEMENTBUFFERPROC __glewVertexArrayElementBuffer;\r\nGLEW_FUN_EXPORT PFNGLVERTEXARRAYVERTEXBUFFERPROC __glewVertexArrayVertexBuffer;\r\nGLEW_FUN_EXPORT PFNGLVERTEXARRAYVERTEXBUFFERSPROC __glewVertexArrayVertexBuffers;\r\n\r\nGLEW_FUN_EXPORT PFNGLDRAWBUFFERSARBPROC __glewDrawBuffersARB;\r\n\r\nGLEW_FUN_EXPORT PFNGLBLENDEQUATIONSEPARATEIARBPROC __glewBlendEquationSeparateiARB;\r\nGLEW_FUN_EXPORT PFNGLBLENDEQUATIONIARBPROC __glewBlendEquationiARB;\r\nGLEW_FUN_EXPORT PFNGLBLENDFUNCSEPARATEIARBPROC __glewBlendFuncSeparateiARB;\r\nGLEW_FUN_EXPORT PFNGLBLENDFUNCIARBPROC __glewBlendFunciARB;\r\n\r\nGLEW_FUN_EXPORT PFNGLDRAWELEMENTSBASEVERTEXPROC __glewDrawElementsBaseVertex;\r\nGLEW_FUN_EXPORT PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC __glewDrawElementsInstancedBaseVertex;\r\nGLEW_FUN_EXPORT PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC __glewDrawRangeElementsBaseVertex;\r\nGLEW_FUN_EXPORT PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC __glewMultiDrawElementsBaseVertex;\r\n\r\nGLEW_FUN_EXPORT PFNGLDRAWARRAYSINDIRECTPROC __glewDrawArraysIndirect;\r\nGLEW_FUN_EXPORT PFNGLDRAWELEMENTSINDIRECTPROC __glewDrawElementsIndirect;\r\n\r\nGLEW_FUN_EXPORT PFNGLFRAMEBUFFERPARAMETERIPROC __glewFramebufferParameteri;\r\nGLEW_FUN_EXPORT PFNGLGETFRAMEBUFFERPARAMETERIVPROC __glewGetFramebufferParameteriv;\r\nGLEW_FUN_EXPORT PFNGLGETNAMEDFRAMEBUFFERPARAMETERIVEXTPROC __glewGetNamedFramebufferParameterivEXT;\r\nGLEW_FUN_EXPORT PFNGLNAMEDFRAMEBUFFERPARAMETERIEXTPROC __glewNamedFramebufferParameteriEXT;\r\n\r\nGLEW_FUN_EXPORT PFNGLBINDFRAMEBUFFERPROC __glewBindFramebuffer;\r\nGLEW_FUN_EXPORT PFNGLBINDRENDERBUFFERPROC __glewBindRenderbuffer;\r\nGLEW_FUN_EXPORT PFNGLBLITFRAMEBUFFERPROC __glewBlitFramebuffer;\r\nGLEW_FUN_EXPORT PFNGLCHECKFRAMEBUFFERSTATUSPROC __glewCheckFramebufferStatus;\r\nGLEW_FUN_EXPORT PFNGLDELETEFRAMEBUFFERSPROC __glewDeleteFramebuffers;\r\nGLEW_FUN_EXPORT PFNGLDELETERENDERBUFFERSPROC __glewDeleteRenderbuffers;\r\nGLEW_FUN_EXPORT PFNGLFRAMEBUFFERRENDERBUFFERPROC __glewFramebufferRenderbuffer;\r\nGLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURE1DPROC __glewFramebufferTexture1D;\r\nGLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURE2DPROC __glewFramebufferTexture2D;\r\nGLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURE3DPROC __glewFramebufferTexture3D;\r\nGLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURELAYERPROC __glewFramebufferTextureLayer;\r\nGLEW_FUN_EXPORT PFNGLGENFRAMEBUFFERSPROC __glewGenFramebuffers;\r\nGLEW_FUN_EXPORT PFNGLGENRENDERBUFFERSPROC __glewGenRenderbuffers;\r\nGLEW_FUN_EXPORT PFNGLGENERATEMIPMAPPROC __glewGenerateMipmap;\r\nGLEW_FUN_EXPORT PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC __glewGetFramebufferAttachmentParameteriv;\r\nGLEW_FUN_EXPORT PFNGLGETRENDERBUFFERPARAMETERIVPROC __glewGetRenderbufferParameteriv;\r\nGLEW_FUN_EXPORT PFNGLISFRAMEBUFFERPROC __glewIsFramebuffer;\r\nGLEW_FUN_EXPORT PFNGLISRENDERBUFFERPROC __glewIsRenderbuffer;\r\nGLEW_FUN_EXPORT PFNGLRENDERBUFFERSTORAGEPROC __glewRenderbufferStorage;\r\nGLEW_FUN_EXPORT PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC __glewRenderbufferStorageMultisample;\r\n\r\nGLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTUREARBPROC __glewFramebufferTextureARB;\r\nGLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTUREFACEARBPROC __glewFramebufferTextureFaceARB;\r\nGLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURELAYERARBPROC __glewFramebufferTextureLayerARB;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMPARAMETERIARBPROC __glewProgramParameteriARB;\r\n\r\nGLEW_FUN_EXPORT PFNGLGETPROGRAMBINARYPROC __glewGetProgramBinary;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMBINARYPROC __glewProgramBinary;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMPARAMETERIPROC __glewProgramParameteri;\r\n\r\nGLEW_FUN_EXPORT PFNGLGETCOMPRESSEDTEXTURESUBIMAGEPROC __glewGetCompressedTextureSubImage;\r\nGLEW_FUN_EXPORT PFNGLGETTEXTURESUBIMAGEPROC __glewGetTextureSubImage;\r\n\r\nGLEW_FUN_EXPORT PFNGLGETUNIFORMDVPROC __glewGetUniformdv;\r\nGLEW_FUN_EXPORT PFNGLUNIFORM1DPROC __glewUniform1d;\r\nGLEW_FUN_EXPORT PFNGLUNIFORM1DVPROC __glewUniform1dv;\r\nGLEW_FUN_EXPORT PFNGLUNIFORM2DPROC __glewUniform2d;\r\nGLEW_FUN_EXPORT PFNGLUNIFORM2DVPROC __glewUniform2dv;\r\nGLEW_FUN_EXPORT PFNGLUNIFORM3DPROC __glewUniform3d;\r\nGLEW_FUN_EXPORT PFNGLUNIFORM3DVPROC __glewUniform3dv;\r\nGLEW_FUN_EXPORT PFNGLUNIFORM4DPROC __glewUniform4d;\r\nGLEW_FUN_EXPORT PFNGLUNIFORM4DVPROC __glewUniform4dv;\r\nGLEW_FUN_EXPORT PFNGLUNIFORMMATRIX2DVPROC __glewUniformMatrix2dv;\r\nGLEW_FUN_EXPORT PFNGLUNIFORMMATRIX2X3DVPROC __glewUniformMatrix2x3dv;\r\nGLEW_FUN_EXPORT PFNGLUNIFORMMATRIX2X4DVPROC __glewUniformMatrix2x4dv;\r\nGLEW_FUN_EXPORT PFNGLUNIFORMMATRIX3DVPROC __glewUniformMatrix3dv;\r\nGLEW_FUN_EXPORT PFNGLUNIFORMMATRIX3X2DVPROC __glewUniformMatrix3x2dv;\r\nGLEW_FUN_EXPORT PFNGLUNIFORMMATRIX3X4DVPROC __glewUniformMatrix3x4dv;\r\nGLEW_FUN_EXPORT PFNGLUNIFORMMATRIX4DVPROC __glewUniformMatrix4dv;\r\nGLEW_FUN_EXPORT PFNGLUNIFORMMATRIX4X2DVPROC __glewUniformMatrix4x2dv;\r\nGLEW_FUN_EXPORT PFNGLUNIFORMMATRIX4X3DVPROC __glewUniformMatrix4x3dv;\r\n\r\nGLEW_FUN_EXPORT PFNGLGETUNIFORMI64VARBPROC __glewGetUniformi64vARB;\r\nGLEW_FUN_EXPORT PFNGLGETUNIFORMUI64VARBPROC __glewGetUniformui64vARB;\r\nGLEW_FUN_EXPORT PFNGLGETNUNIFORMI64VARBPROC __glewGetnUniformi64vARB;\r\nGLEW_FUN_EXPORT PFNGLGETNUNIFORMUI64VARBPROC __glewGetnUniformui64vARB;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1I64ARBPROC __glewProgramUniform1i64ARB;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1I64VARBPROC __glewProgramUniform1i64vARB;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1UI64ARBPROC __glewProgramUniform1ui64ARB;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1UI64VARBPROC __glewProgramUniform1ui64vARB;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2I64ARBPROC __glewProgramUniform2i64ARB;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2I64VARBPROC __glewProgramUniform2i64vARB;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2UI64ARBPROC __glewProgramUniform2ui64ARB;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2UI64VARBPROC __glewProgramUniform2ui64vARB;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3I64ARBPROC __glewProgramUniform3i64ARB;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3I64VARBPROC __glewProgramUniform3i64vARB;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3UI64ARBPROC __glewProgramUniform3ui64ARB;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3UI64VARBPROC __glewProgramUniform3ui64vARB;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4I64ARBPROC __glewProgramUniform4i64ARB;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4I64VARBPROC __glewProgramUniform4i64vARB;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4UI64ARBPROC __glewProgramUniform4ui64ARB;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4UI64VARBPROC __glewProgramUniform4ui64vARB;\r\nGLEW_FUN_EXPORT PFNGLUNIFORM1I64ARBPROC __glewUniform1i64ARB;\r\nGLEW_FUN_EXPORT PFNGLUNIFORM1I64VARBPROC __glewUniform1i64vARB;\r\nGLEW_FUN_EXPORT PFNGLUNIFORM1UI64ARBPROC __glewUniform1ui64ARB;\r\nGLEW_FUN_EXPORT PFNGLUNIFORM1UI64VARBPROC __glewUniform1ui64vARB;\r\nGLEW_FUN_EXPORT PFNGLUNIFORM2I64ARBPROC __glewUniform2i64ARB;\r\nGLEW_FUN_EXPORT PFNGLUNIFORM2I64VARBPROC __glewUniform2i64vARB;\r\nGLEW_FUN_EXPORT PFNGLUNIFORM2UI64ARBPROC __glewUniform2ui64ARB;\r\nGLEW_FUN_EXPORT PFNGLUNIFORM2UI64VARBPROC __glewUniform2ui64vARB;\r\nGLEW_FUN_EXPORT PFNGLUNIFORM3I64ARBPROC __glewUniform3i64ARB;\r\nGLEW_FUN_EXPORT PFNGLUNIFORM3I64VARBPROC __glewUniform3i64vARB;\r\nGLEW_FUN_EXPORT PFNGLUNIFORM3UI64ARBPROC __glewUniform3ui64ARB;\r\nGLEW_FUN_EXPORT PFNGLUNIFORM3UI64VARBPROC __glewUniform3ui64vARB;\r\nGLEW_FUN_EXPORT PFNGLUNIFORM4I64ARBPROC __glewUniform4i64ARB;\r\nGLEW_FUN_EXPORT PFNGLUNIFORM4I64VARBPROC __glewUniform4i64vARB;\r\nGLEW_FUN_EXPORT PFNGLUNIFORM4UI64ARBPROC __glewUniform4ui64ARB;\r\nGLEW_FUN_EXPORT PFNGLUNIFORM4UI64VARBPROC __glewUniform4ui64vARB;\r\n\r\nGLEW_FUN_EXPORT PFNGLCOLORSUBTABLEPROC __glewColorSubTable;\r\nGLEW_FUN_EXPORT PFNGLCOLORTABLEPROC __glewColorTable;\r\nGLEW_FUN_EXPORT PFNGLCOLORTABLEPARAMETERFVPROC __glewColorTableParameterfv;\r\nGLEW_FUN_EXPORT PFNGLCOLORTABLEPARAMETERIVPROC __glewColorTableParameteriv;\r\nGLEW_FUN_EXPORT PFNGLCONVOLUTIONFILTER1DPROC __glewConvolutionFilter1D;\r\nGLEW_FUN_EXPORT PFNGLCONVOLUTIONFILTER2DPROC __glewConvolutionFilter2D;\r\nGLEW_FUN_EXPORT PFNGLCONVOLUTIONPARAMETERFPROC __glewConvolutionParameterf;\r\nGLEW_FUN_EXPORT PFNGLCONVOLUTIONPARAMETERFVPROC __glewConvolutionParameterfv;\r\nGLEW_FUN_EXPORT PFNGLCONVOLUTIONPARAMETERIPROC __glewConvolutionParameteri;\r\nGLEW_FUN_EXPORT PFNGLCONVOLUTIONPARAMETERIVPROC __glewConvolutionParameteriv;\r\nGLEW_FUN_EXPORT PFNGLCOPYCOLORSUBTABLEPROC __glewCopyColorSubTable;\r\nGLEW_FUN_EXPORT PFNGLCOPYCOLORTABLEPROC __glewCopyColorTable;\r\nGLEW_FUN_EXPORT PFNGLCOPYCONVOLUTIONFILTER1DPROC __glewCopyConvolutionFilter1D;\r\nGLEW_FUN_EXPORT PFNGLCOPYCONVOLUTIONFILTER2DPROC __glewCopyConvolutionFilter2D;\r\nGLEW_FUN_EXPORT PFNGLGETCOLORTABLEPROC __glewGetColorTable;\r\nGLEW_FUN_EXPORT PFNGLGETCOLORTABLEPARAMETERFVPROC __glewGetColorTableParameterfv;\r\nGLEW_FUN_EXPORT PFNGLGETCOLORTABLEPARAMETERIVPROC __glewGetColorTableParameteriv;\r\nGLEW_FUN_EXPORT PFNGLGETCONVOLUTIONFILTERPROC __glewGetConvolutionFilter;\r\nGLEW_FUN_EXPORT PFNGLGETCONVOLUTIONPARAMETERFVPROC __glewGetConvolutionParameterfv;\r\nGLEW_FUN_EXPORT PFNGLGETCONVOLUTIONPARAMETERIVPROC __glewGetConvolutionParameteriv;\r\nGLEW_FUN_EXPORT PFNGLGETHISTOGRAMPROC __glewGetHistogram;\r\nGLEW_FUN_EXPORT PFNGLGETHISTOGRAMPARAMETERFVPROC __glewGetHistogramParameterfv;\r\nGLEW_FUN_EXPORT PFNGLGETHISTOGRAMPARAMETERIVPROC __glewGetHistogramParameteriv;\r\nGLEW_FUN_EXPORT PFNGLGETMINMAXPROC __glewGetMinmax;\r\nGLEW_FUN_EXPORT PFNGLGETMINMAXPARAMETERFVPROC __glewGetMinmaxParameterfv;\r\nGLEW_FUN_EXPORT PFNGLGETMINMAXPARAMETERIVPROC __glewGetMinmaxParameteriv;\r\nGLEW_FUN_EXPORT PFNGLGETSEPARABLEFILTERPROC __glewGetSeparableFilter;\r\nGLEW_FUN_EXPORT PFNGLHISTOGRAMPROC __glewHistogram;\r\nGLEW_FUN_EXPORT PFNGLMINMAXPROC __glewMinmax;\r\nGLEW_FUN_EXPORT PFNGLRESETHISTOGRAMPROC __glewResetHistogram;\r\nGLEW_FUN_EXPORT PFNGLRESETMINMAXPROC __glewResetMinmax;\r\nGLEW_FUN_EXPORT PFNGLSEPARABLEFILTER2DPROC __glewSeparableFilter2D;\r\n\r\nGLEW_FUN_EXPORT PFNGLMULTIDRAWARRAYSINDIRECTCOUNTARBPROC __glewMultiDrawArraysIndirectCountARB;\r\nGLEW_FUN_EXPORT PFNGLMULTIDRAWELEMENTSINDIRECTCOUNTARBPROC __glewMultiDrawElementsIndirectCountARB;\r\n\r\nGLEW_FUN_EXPORT PFNGLDRAWARRAYSINSTANCEDARBPROC __glewDrawArraysInstancedARB;\r\nGLEW_FUN_EXPORT PFNGLDRAWELEMENTSINSTANCEDARBPROC __glewDrawElementsInstancedARB;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBDIVISORARBPROC __glewVertexAttribDivisorARB;\r\n\r\nGLEW_FUN_EXPORT PFNGLGETINTERNALFORMATIVPROC __glewGetInternalformativ;\r\n\r\nGLEW_FUN_EXPORT PFNGLGETINTERNALFORMATI64VPROC __glewGetInternalformati64v;\r\n\r\nGLEW_FUN_EXPORT PFNGLINVALIDATEBUFFERDATAPROC __glewInvalidateBufferData;\r\nGLEW_FUN_EXPORT PFNGLINVALIDATEBUFFERSUBDATAPROC __glewInvalidateBufferSubData;\r\nGLEW_FUN_EXPORT PFNGLINVALIDATEFRAMEBUFFERPROC __glewInvalidateFramebuffer;\r\nGLEW_FUN_EXPORT PFNGLINVALIDATESUBFRAMEBUFFERPROC __glewInvalidateSubFramebuffer;\r\nGLEW_FUN_EXPORT PFNGLINVALIDATETEXIMAGEPROC __glewInvalidateTexImage;\r\nGLEW_FUN_EXPORT PFNGLINVALIDATETEXSUBIMAGEPROC __glewInvalidateTexSubImage;\r\n\r\nGLEW_FUN_EXPORT PFNGLFLUSHMAPPEDBUFFERRANGEPROC __glewFlushMappedBufferRange;\r\nGLEW_FUN_EXPORT PFNGLMAPBUFFERRANGEPROC __glewMapBufferRange;\r\n\r\nGLEW_FUN_EXPORT PFNGLCURRENTPALETTEMATRIXARBPROC __glewCurrentPaletteMatrixARB;\r\nGLEW_FUN_EXPORT PFNGLMATRIXINDEXPOINTERARBPROC __glewMatrixIndexPointerARB;\r\nGLEW_FUN_EXPORT PFNGLMATRIXINDEXUBVARBPROC __glewMatrixIndexubvARB;\r\nGLEW_FUN_EXPORT PFNGLMATRIXINDEXUIVARBPROC __glewMatrixIndexuivARB;\r\nGLEW_FUN_EXPORT PFNGLMATRIXINDEXUSVARBPROC __glewMatrixIndexusvARB;\r\n\r\nGLEW_FUN_EXPORT PFNGLBINDBUFFERSBASEPROC __glewBindBuffersBase;\r\nGLEW_FUN_EXPORT PFNGLBINDBUFFERSRANGEPROC __glewBindBuffersRange;\r\nGLEW_FUN_EXPORT PFNGLBINDIMAGETEXTURESPROC __glewBindImageTextures;\r\nGLEW_FUN_EXPORT PFNGLBINDSAMPLERSPROC __glewBindSamplers;\r\nGLEW_FUN_EXPORT PFNGLBINDTEXTURESPROC __glewBindTextures;\r\nGLEW_FUN_EXPORT PFNGLBINDVERTEXBUFFERSPROC __glewBindVertexBuffers;\r\n\r\nGLEW_FUN_EXPORT PFNGLMULTIDRAWARRAYSINDIRECTPROC __glewMultiDrawArraysIndirect;\r\nGLEW_FUN_EXPORT PFNGLMULTIDRAWELEMENTSINDIRECTPROC __glewMultiDrawElementsIndirect;\r\n\r\nGLEW_FUN_EXPORT PFNGLSAMPLECOVERAGEARBPROC __glewSampleCoverageARB;\r\n\r\nGLEW_FUN_EXPORT PFNGLACTIVETEXTUREARBPROC __glewActiveTextureARB;\r\nGLEW_FUN_EXPORT PFNGLCLIENTACTIVETEXTUREARBPROC __glewClientActiveTextureARB;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD1DARBPROC __glewMultiTexCoord1dARB;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD1DVARBPROC __glewMultiTexCoord1dvARB;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD1FARBPROC __glewMultiTexCoord1fARB;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD1FVARBPROC __glewMultiTexCoord1fvARB;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD1IARBPROC __glewMultiTexCoord1iARB;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD1IVARBPROC __glewMultiTexCoord1ivARB;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD1SARBPROC __glewMultiTexCoord1sARB;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD1SVARBPROC __glewMultiTexCoord1svARB;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD2DARBPROC __glewMultiTexCoord2dARB;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD2DVARBPROC __glewMultiTexCoord2dvARB;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD2FARBPROC __glewMultiTexCoord2fARB;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD2FVARBPROC __glewMultiTexCoord2fvARB;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD2IARBPROC __glewMultiTexCoord2iARB;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD2IVARBPROC __glewMultiTexCoord2ivARB;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD2SARBPROC __glewMultiTexCoord2sARB;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD2SVARBPROC __glewMultiTexCoord2svARB;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD3DARBPROC __glewMultiTexCoord3dARB;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD3DVARBPROC __glewMultiTexCoord3dvARB;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD3FARBPROC __glewMultiTexCoord3fARB;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD3FVARBPROC __glewMultiTexCoord3fvARB;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD3IARBPROC __glewMultiTexCoord3iARB;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD3IVARBPROC __glewMultiTexCoord3ivARB;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD3SARBPROC __glewMultiTexCoord3sARB;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD3SVARBPROC __glewMultiTexCoord3svARB;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD4DARBPROC __glewMultiTexCoord4dARB;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD4DVARBPROC __glewMultiTexCoord4dvARB;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD4FARBPROC __glewMultiTexCoord4fARB;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD4FVARBPROC __glewMultiTexCoord4fvARB;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD4IARBPROC __glewMultiTexCoord4iARB;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD4IVARBPROC __glewMultiTexCoord4ivARB;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD4SARBPROC __glewMultiTexCoord4sARB;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD4SVARBPROC __glewMultiTexCoord4svARB;\r\n\r\nGLEW_FUN_EXPORT PFNGLBEGINQUERYARBPROC __glewBeginQueryARB;\r\nGLEW_FUN_EXPORT PFNGLDELETEQUERIESARBPROC __glewDeleteQueriesARB;\r\nGLEW_FUN_EXPORT PFNGLENDQUERYARBPROC __glewEndQueryARB;\r\nGLEW_FUN_EXPORT PFNGLGENQUERIESARBPROC __glewGenQueriesARB;\r\nGLEW_FUN_EXPORT PFNGLGETQUERYOBJECTIVARBPROC __glewGetQueryObjectivARB;\r\nGLEW_FUN_EXPORT PFNGLGETQUERYOBJECTUIVARBPROC __glewGetQueryObjectuivARB;\r\nGLEW_FUN_EXPORT PFNGLGETQUERYIVARBPROC __glewGetQueryivARB;\r\nGLEW_FUN_EXPORT PFNGLISQUERYARBPROC __glewIsQueryARB;\r\n\r\nGLEW_FUN_EXPORT PFNGLMAXSHADERCOMPILERTHREADSARBPROC __glewMaxShaderCompilerThreadsARB;\r\n\r\nGLEW_FUN_EXPORT PFNGLPOINTPARAMETERFARBPROC __glewPointParameterfARB;\r\nGLEW_FUN_EXPORT PFNGLPOINTPARAMETERFVARBPROC __glewPointParameterfvARB;\r\n\r\nGLEW_FUN_EXPORT PFNGLGETPROGRAMINTERFACEIVPROC __glewGetProgramInterfaceiv;\r\nGLEW_FUN_EXPORT PFNGLGETPROGRAMRESOURCEINDEXPROC __glewGetProgramResourceIndex;\r\nGLEW_FUN_EXPORT PFNGLGETPROGRAMRESOURCELOCATIONPROC __glewGetProgramResourceLocation;\r\nGLEW_FUN_EXPORT PFNGLGETPROGRAMRESOURCELOCATIONINDEXPROC __glewGetProgramResourceLocationIndex;\r\nGLEW_FUN_EXPORT PFNGLGETPROGRAMRESOURCENAMEPROC __glewGetProgramResourceName;\r\nGLEW_FUN_EXPORT PFNGLGETPROGRAMRESOURCEIVPROC __glewGetProgramResourceiv;\r\n\r\nGLEW_FUN_EXPORT PFNGLPROVOKINGVERTEXPROC __glewProvokingVertex;\r\n\r\nGLEW_FUN_EXPORT PFNGLGETGRAPHICSRESETSTATUSARBPROC __glewGetGraphicsResetStatusARB;\r\nGLEW_FUN_EXPORT PFNGLGETNCOLORTABLEARBPROC __glewGetnColorTableARB;\r\nGLEW_FUN_EXPORT PFNGLGETNCOMPRESSEDTEXIMAGEARBPROC __glewGetnCompressedTexImageARB;\r\nGLEW_FUN_EXPORT PFNGLGETNCONVOLUTIONFILTERARBPROC __glewGetnConvolutionFilterARB;\r\nGLEW_FUN_EXPORT PFNGLGETNHISTOGRAMARBPROC __glewGetnHistogramARB;\r\nGLEW_FUN_EXPORT PFNGLGETNMAPDVARBPROC __glewGetnMapdvARB;\r\nGLEW_FUN_EXPORT PFNGLGETNMAPFVARBPROC __glewGetnMapfvARB;\r\nGLEW_FUN_EXPORT PFNGLGETNMAPIVARBPROC __glewGetnMapivARB;\r\nGLEW_FUN_EXPORT PFNGLGETNMINMAXARBPROC __glewGetnMinmaxARB;\r\nGLEW_FUN_EXPORT PFNGLGETNPIXELMAPFVARBPROC __glewGetnPixelMapfvARB;\r\nGLEW_FUN_EXPORT PFNGLGETNPIXELMAPUIVARBPROC __glewGetnPixelMapuivARB;\r\nGLEW_FUN_EXPORT PFNGLGETNPIXELMAPUSVARBPROC __glewGetnPixelMapusvARB;\r\nGLEW_FUN_EXPORT PFNGLGETNPOLYGONSTIPPLEARBPROC __glewGetnPolygonStippleARB;\r\nGLEW_FUN_EXPORT PFNGLGETNSEPARABLEFILTERARBPROC __glewGetnSeparableFilterARB;\r\nGLEW_FUN_EXPORT PFNGLGETNTEXIMAGEARBPROC __glewGetnTexImageARB;\r\nGLEW_FUN_EXPORT PFNGLGETNUNIFORMDVARBPROC __glewGetnUniformdvARB;\r\nGLEW_FUN_EXPORT PFNGLGETNUNIFORMFVARBPROC __glewGetnUniformfvARB;\r\nGLEW_FUN_EXPORT PFNGLGETNUNIFORMIVARBPROC __glewGetnUniformivARB;\r\nGLEW_FUN_EXPORT PFNGLGETNUNIFORMUIVARBPROC __glewGetnUniformuivARB;\r\nGLEW_FUN_EXPORT PFNGLREADNPIXELSARBPROC __glewReadnPixelsARB;\r\n\r\nGLEW_FUN_EXPORT PFNGLFRAMEBUFFERSAMPLELOCATIONSFVARBPROC __glewFramebufferSampleLocationsfvARB;\r\nGLEW_FUN_EXPORT PFNGLNAMEDFRAMEBUFFERSAMPLELOCATIONSFVARBPROC __glewNamedFramebufferSampleLocationsfvARB;\r\n\r\nGLEW_FUN_EXPORT PFNGLMINSAMPLESHADINGARBPROC __glewMinSampleShadingARB;\r\n\r\nGLEW_FUN_EXPORT PFNGLBINDSAMPLERPROC __glewBindSampler;\r\nGLEW_FUN_EXPORT PFNGLDELETESAMPLERSPROC __glewDeleteSamplers;\r\nGLEW_FUN_EXPORT PFNGLGENSAMPLERSPROC __glewGenSamplers;\r\nGLEW_FUN_EXPORT PFNGLGETSAMPLERPARAMETERIIVPROC __glewGetSamplerParameterIiv;\r\nGLEW_FUN_EXPORT PFNGLGETSAMPLERPARAMETERIUIVPROC __glewGetSamplerParameterIuiv;\r\nGLEW_FUN_EXPORT PFNGLGETSAMPLERPARAMETERFVPROC __glewGetSamplerParameterfv;\r\nGLEW_FUN_EXPORT PFNGLGETSAMPLERPARAMETERIVPROC __glewGetSamplerParameteriv;\r\nGLEW_FUN_EXPORT PFNGLISSAMPLERPROC __glewIsSampler;\r\nGLEW_FUN_EXPORT PFNGLSAMPLERPARAMETERIIVPROC __glewSamplerParameterIiv;\r\nGLEW_FUN_EXPORT PFNGLSAMPLERPARAMETERIUIVPROC __glewSamplerParameterIuiv;\r\nGLEW_FUN_EXPORT PFNGLSAMPLERPARAMETERFPROC __glewSamplerParameterf;\r\nGLEW_FUN_EXPORT PFNGLSAMPLERPARAMETERFVPROC __glewSamplerParameterfv;\r\nGLEW_FUN_EXPORT PFNGLSAMPLERPARAMETERIPROC __glewSamplerParameteri;\r\nGLEW_FUN_EXPORT PFNGLSAMPLERPARAMETERIVPROC __glewSamplerParameteriv;\r\n\r\nGLEW_FUN_EXPORT PFNGLACTIVESHADERPROGRAMPROC __glewActiveShaderProgram;\r\nGLEW_FUN_EXPORT PFNGLBINDPROGRAMPIPELINEPROC __glewBindProgramPipeline;\r\nGLEW_FUN_EXPORT PFNGLCREATESHADERPROGRAMVPROC __glewCreateShaderProgramv;\r\nGLEW_FUN_EXPORT PFNGLDELETEPROGRAMPIPELINESPROC __glewDeleteProgramPipelines;\r\nGLEW_FUN_EXPORT PFNGLGENPROGRAMPIPELINESPROC __glewGenProgramPipelines;\r\nGLEW_FUN_EXPORT PFNGLGETPROGRAMPIPELINEINFOLOGPROC __glewGetProgramPipelineInfoLog;\r\nGLEW_FUN_EXPORT PFNGLGETPROGRAMPIPELINEIVPROC __glewGetProgramPipelineiv;\r\nGLEW_FUN_EXPORT PFNGLISPROGRAMPIPELINEPROC __glewIsProgramPipeline;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1DPROC __glewProgramUniform1d;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1DVPROC __glewProgramUniform1dv;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1FPROC __glewProgramUniform1f;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1FVPROC __glewProgramUniform1fv;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1IPROC __glewProgramUniform1i;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1IVPROC __glewProgramUniform1iv;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1UIPROC __glewProgramUniform1ui;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1UIVPROC __glewProgramUniform1uiv;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2DPROC __glewProgramUniform2d;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2DVPROC __glewProgramUniform2dv;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2FPROC __glewProgramUniform2f;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2FVPROC __glewProgramUniform2fv;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2IPROC __glewProgramUniform2i;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2IVPROC __glewProgramUniform2iv;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2UIPROC __glewProgramUniform2ui;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2UIVPROC __glewProgramUniform2uiv;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3DPROC __glewProgramUniform3d;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3DVPROC __glewProgramUniform3dv;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3FPROC __glewProgramUniform3f;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3FVPROC __glewProgramUniform3fv;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3IPROC __glewProgramUniform3i;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3IVPROC __glewProgramUniform3iv;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3UIPROC __glewProgramUniform3ui;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3UIVPROC __glewProgramUniform3uiv;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4DPROC __glewProgramUniform4d;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4DVPROC __glewProgramUniform4dv;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4FPROC __glewProgramUniform4f;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4FVPROC __glewProgramUniform4fv;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4IPROC __glewProgramUniform4i;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4IVPROC __glewProgramUniform4iv;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4UIPROC __glewProgramUniform4ui;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4UIVPROC __glewProgramUniform4uiv;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX2DVPROC __glewProgramUniformMatrix2dv;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX2FVPROC __glewProgramUniformMatrix2fv;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX2X3DVPROC __glewProgramUniformMatrix2x3dv;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX2X3FVPROC __glewProgramUniformMatrix2x3fv;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX2X4DVPROC __glewProgramUniformMatrix2x4dv;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX2X4FVPROC __glewProgramUniformMatrix2x4fv;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX3DVPROC __glewProgramUniformMatrix3dv;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX3FVPROC __glewProgramUniformMatrix3fv;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX3X2DVPROC __glewProgramUniformMatrix3x2dv;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX3X2FVPROC __glewProgramUniformMatrix3x2fv;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX3X4DVPROC __glewProgramUniformMatrix3x4dv;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX3X4FVPROC __glewProgramUniformMatrix3x4fv;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX4DVPROC __glewProgramUniformMatrix4dv;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX4FVPROC __glewProgramUniformMatrix4fv;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX4X2DVPROC __glewProgramUniformMatrix4x2dv;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX4X2FVPROC __glewProgramUniformMatrix4x2fv;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX4X3DVPROC __glewProgramUniformMatrix4x3dv;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX4X3FVPROC __glewProgramUniformMatrix4x3fv;\r\nGLEW_FUN_EXPORT PFNGLUSEPROGRAMSTAGESPROC __glewUseProgramStages;\r\nGLEW_FUN_EXPORT PFNGLVALIDATEPROGRAMPIPELINEPROC __glewValidateProgramPipeline;\r\n\r\nGLEW_FUN_EXPORT PFNGLGETACTIVEATOMICCOUNTERBUFFERIVPROC __glewGetActiveAtomicCounterBufferiv;\r\n\r\nGLEW_FUN_EXPORT PFNGLBINDIMAGETEXTUREPROC __glewBindImageTexture;\r\nGLEW_FUN_EXPORT PFNGLMEMORYBARRIERPROC __glewMemoryBarrier;\r\n\r\nGLEW_FUN_EXPORT PFNGLATTACHOBJECTARBPROC __glewAttachObjectARB;\r\nGLEW_FUN_EXPORT PFNGLCOMPILESHADERARBPROC __glewCompileShaderARB;\r\nGLEW_FUN_EXPORT PFNGLCREATEPROGRAMOBJECTARBPROC __glewCreateProgramObjectARB;\r\nGLEW_FUN_EXPORT PFNGLCREATESHADEROBJECTARBPROC __glewCreateShaderObjectARB;\r\nGLEW_FUN_EXPORT PFNGLDELETEOBJECTARBPROC __glewDeleteObjectARB;\r\nGLEW_FUN_EXPORT PFNGLDETACHOBJECTARBPROC __glewDetachObjectARB;\r\nGLEW_FUN_EXPORT PFNGLGETACTIVEUNIFORMARBPROC __glewGetActiveUniformARB;\r\nGLEW_FUN_EXPORT PFNGLGETATTACHEDOBJECTSARBPROC __glewGetAttachedObjectsARB;\r\nGLEW_FUN_EXPORT PFNGLGETHANDLEARBPROC __glewGetHandleARB;\r\nGLEW_FUN_EXPORT PFNGLGETINFOLOGARBPROC __glewGetInfoLogARB;\r\nGLEW_FUN_EXPORT PFNGLGETOBJECTPARAMETERFVARBPROC __glewGetObjectParameterfvARB;\r\nGLEW_FUN_EXPORT PFNGLGETOBJECTPARAMETERIVARBPROC __glewGetObjectParameterivARB;\r\nGLEW_FUN_EXPORT PFNGLGETSHADERSOURCEARBPROC __glewGetShaderSourceARB;\r\nGLEW_FUN_EXPORT PFNGLGETUNIFORMLOCATIONARBPROC __glewGetUniformLocationARB;\r\nGLEW_FUN_EXPORT PFNGLGETUNIFORMFVARBPROC __glewGetUniformfvARB;\r\nGLEW_FUN_EXPORT PFNGLGETUNIFORMIVARBPROC __glewGetUniformivARB;\r\nGLEW_FUN_EXPORT PFNGLLINKPROGRAMARBPROC __glewLinkProgramARB;\r\nGLEW_FUN_EXPORT PFNGLSHADERSOURCEARBPROC __glewShaderSourceARB;\r\nGLEW_FUN_EXPORT PFNGLUNIFORM1FARBPROC __glewUniform1fARB;\r\nGLEW_FUN_EXPORT PFNGLUNIFORM1FVARBPROC __glewUniform1fvARB;\r\nGLEW_FUN_EXPORT PFNGLUNIFORM1IARBPROC __glewUniform1iARB;\r\nGLEW_FUN_EXPORT PFNGLUNIFORM1IVARBPROC __glewUniform1ivARB;\r\nGLEW_FUN_EXPORT PFNGLUNIFORM2FARBPROC __glewUniform2fARB;\r\nGLEW_FUN_EXPORT PFNGLUNIFORM2FVARBPROC __glewUniform2fvARB;\r\nGLEW_FUN_EXPORT PFNGLUNIFORM2IARBPROC __glewUniform2iARB;\r\nGLEW_FUN_EXPORT PFNGLUNIFORM2IVARBPROC __glewUniform2ivARB;\r\nGLEW_FUN_EXPORT PFNGLUNIFORM3FARBPROC __glewUniform3fARB;\r\nGLEW_FUN_EXPORT PFNGLUNIFORM3FVARBPROC __glewUniform3fvARB;\r\nGLEW_FUN_EXPORT PFNGLUNIFORM3IARBPROC __glewUniform3iARB;\r\nGLEW_FUN_EXPORT PFNGLUNIFORM3IVARBPROC __glewUniform3ivARB;\r\nGLEW_FUN_EXPORT PFNGLUNIFORM4FARBPROC __glewUniform4fARB;\r\nGLEW_FUN_EXPORT PFNGLUNIFORM4FVARBPROC __glewUniform4fvARB;\r\nGLEW_FUN_EXPORT PFNGLUNIFORM4IARBPROC __glewUniform4iARB;\r\nGLEW_FUN_EXPORT PFNGLUNIFORM4IVARBPROC __glewUniform4ivARB;\r\nGLEW_FUN_EXPORT PFNGLUNIFORMMATRIX2FVARBPROC __glewUniformMatrix2fvARB;\r\nGLEW_FUN_EXPORT PFNGLUNIFORMMATRIX3FVARBPROC __glewUniformMatrix3fvARB;\r\nGLEW_FUN_EXPORT PFNGLUNIFORMMATRIX4FVARBPROC __glewUniformMatrix4fvARB;\r\nGLEW_FUN_EXPORT PFNGLUSEPROGRAMOBJECTARBPROC __glewUseProgramObjectARB;\r\nGLEW_FUN_EXPORT PFNGLVALIDATEPROGRAMARBPROC __glewValidateProgramARB;\r\n\r\nGLEW_FUN_EXPORT PFNGLSHADERSTORAGEBLOCKBINDINGPROC __glewShaderStorageBlockBinding;\r\n\r\nGLEW_FUN_EXPORT PFNGLGETACTIVESUBROUTINENAMEPROC __glewGetActiveSubroutineName;\r\nGLEW_FUN_EXPORT PFNGLGETACTIVESUBROUTINEUNIFORMNAMEPROC __glewGetActiveSubroutineUniformName;\r\nGLEW_FUN_EXPORT PFNGLGETACTIVESUBROUTINEUNIFORMIVPROC __glewGetActiveSubroutineUniformiv;\r\nGLEW_FUN_EXPORT PFNGLGETPROGRAMSTAGEIVPROC __glewGetProgramStageiv;\r\nGLEW_FUN_EXPORT PFNGLGETSUBROUTINEINDEXPROC __glewGetSubroutineIndex;\r\nGLEW_FUN_EXPORT PFNGLGETSUBROUTINEUNIFORMLOCATIONPROC __glewGetSubroutineUniformLocation;\r\nGLEW_FUN_EXPORT PFNGLGETUNIFORMSUBROUTINEUIVPROC __glewGetUniformSubroutineuiv;\r\nGLEW_FUN_EXPORT PFNGLUNIFORMSUBROUTINESUIVPROC __glewUniformSubroutinesuiv;\r\n\r\nGLEW_FUN_EXPORT PFNGLCOMPILESHADERINCLUDEARBPROC __glewCompileShaderIncludeARB;\r\nGLEW_FUN_EXPORT PFNGLDELETENAMEDSTRINGARBPROC __glewDeleteNamedStringARB;\r\nGLEW_FUN_EXPORT PFNGLGETNAMEDSTRINGARBPROC __glewGetNamedStringARB;\r\nGLEW_FUN_EXPORT PFNGLGETNAMEDSTRINGIVARBPROC __glewGetNamedStringivARB;\r\nGLEW_FUN_EXPORT PFNGLISNAMEDSTRINGARBPROC __glewIsNamedStringARB;\r\nGLEW_FUN_EXPORT PFNGLNAMEDSTRINGARBPROC __glewNamedStringARB;\r\n\r\nGLEW_FUN_EXPORT PFNGLBUFFERPAGECOMMITMENTARBPROC __glewBufferPageCommitmentARB;\r\n\r\nGLEW_FUN_EXPORT PFNGLTEXPAGECOMMITMENTARBPROC __glewTexPageCommitmentARB;\r\nGLEW_FUN_EXPORT PFNGLTEXTUREPAGECOMMITMENTEXTPROC __glewTexturePageCommitmentEXT;\r\n\r\nGLEW_FUN_EXPORT PFNGLCLIENTWAITSYNCPROC __glewClientWaitSync;\r\nGLEW_FUN_EXPORT PFNGLDELETESYNCPROC __glewDeleteSync;\r\nGLEW_FUN_EXPORT PFNGLFENCESYNCPROC __glewFenceSync;\r\nGLEW_FUN_EXPORT PFNGLGETINTEGER64VPROC __glewGetInteger64v;\r\nGLEW_FUN_EXPORT PFNGLGETSYNCIVPROC __glewGetSynciv;\r\nGLEW_FUN_EXPORT PFNGLISSYNCPROC __glewIsSync;\r\nGLEW_FUN_EXPORT PFNGLWAITSYNCPROC __glewWaitSync;\r\n\r\nGLEW_FUN_EXPORT PFNGLPATCHPARAMETERFVPROC __glewPatchParameterfv;\r\nGLEW_FUN_EXPORT PFNGLPATCHPARAMETERIPROC __glewPatchParameteri;\r\n\r\nGLEW_FUN_EXPORT PFNGLTEXTUREBARRIERPROC __glewTextureBarrier;\r\n\r\nGLEW_FUN_EXPORT PFNGLTEXBUFFERARBPROC __glewTexBufferARB;\r\n\r\nGLEW_FUN_EXPORT PFNGLTEXBUFFERRANGEPROC __glewTexBufferRange;\r\nGLEW_FUN_EXPORT PFNGLTEXTUREBUFFERRANGEEXTPROC __glewTextureBufferRangeEXT;\r\n\r\nGLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXIMAGE1DARBPROC __glewCompressedTexImage1DARB;\r\nGLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXIMAGE2DARBPROC __glewCompressedTexImage2DARB;\r\nGLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXIMAGE3DARBPROC __glewCompressedTexImage3DARB;\r\nGLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC __glewCompressedTexSubImage1DARB;\r\nGLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC __glewCompressedTexSubImage2DARB;\r\nGLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC __glewCompressedTexSubImage3DARB;\r\nGLEW_FUN_EXPORT PFNGLGETCOMPRESSEDTEXIMAGEARBPROC __glewGetCompressedTexImageARB;\r\n\r\nGLEW_FUN_EXPORT PFNGLGETMULTISAMPLEFVPROC __glewGetMultisamplefv;\r\nGLEW_FUN_EXPORT PFNGLSAMPLEMASKIPROC __glewSampleMaski;\r\nGLEW_FUN_EXPORT PFNGLTEXIMAGE2DMULTISAMPLEPROC __glewTexImage2DMultisample;\r\nGLEW_FUN_EXPORT PFNGLTEXIMAGE3DMULTISAMPLEPROC __glewTexImage3DMultisample;\r\n\r\nGLEW_FUN_EXPORT PFNGLTEXSTORAGE1DPROC __glewTexStorage1D;\r\nGLEW_FUN_EXPORT PFNGLTEXSTORAGE2DPROC __glewTexStorage2D;\r\nGLEW_FUN_EXPORT PFNGLTEXSTORAGE3DPROC __glewTexStorage3D;\r\nGLEW_FUN_EXPORT PFNGLTEXTURESTORAGE1DEXTPROC __glewTextureStorage1DEXT;\r\nGLEW_FUN_EXPORT PFNGLTEXTURESTORAGE2DEXTPROC __glewTextureStorage2DEXT;\r\nGLEW_FUN_EXPORT PFNGLTEXTURESTORAGE3DEXTPROC __glewTextureStorage3DEXT;\r\n\r\nGLEW_FUN_EXPORT PFNGLTEXSTORAGE2DMULTISAMPLEPROC __glewTexStorage2DMultisample;\r\nGLEW_FUN_EXPORT PFNGLTEXSTORAGE3DMULTISAMPLEPROC __glewTexStorage3DMultisample;\r\nGLEW_FUN_EXPORT PFNGLTEXTURESTORAGE2DMULTISAMPLEEXTPROC __glewTextureStorage2DMultisampleEXT;\r\nGLEW_FUN_EXPORT PFNGLTEXTURESTORAGE3DMULTISAMPLEEXTPROC __glewTextureStorage3DMultisampleEXT;\r\n\r\nGLEW_FUN_EXPORT PFNGLTEXTUREVIEWPROC __glewTextureView;\r\n\r\nGLEW_FUN_EXPORT PFNGLGETQUERYOBJECTI64VPROC __glewGetQueryObjecti64v;\r\nGLEW_FUN_EXPORT PFNGLGETQUERYOBJECTUI64VPROC __glewGetQueryObjectui64v;\r\nGLEW_FUN_EXPORT PFNGLQUERYCOUNTERPROC __glewQueryCounter;\r\n\r\nGLEW_FUN_EXPORT PFNGLBINDTRANSFORMFEEDBACKPROC __glewBindTransformFeedback;\r\nGLEW_FUN_EXPORT PFNGLDELETETRANSFORMFEEDBACKSPROC __glewDeleteTransformFeedbacks;\r\nGLEW_FUN_EXPORT PFNGLDRAWTRANSFORMFEEDBACKPROC __glewDrawTransformFeedback;\r\nGLEW_FUN_EXPORT PFNGLGENTRANSFORMFEEDBACKSPROC __glewGenTransformFeedbacks;\r\nGLEW_FUN_EXPORT PFNGLISTRANSFORMFEEDBACKPROC __glewIsTransformFeedback;\r\nGLEW_FUN_EXPORT PFNGLPAUSETRANSFORMFEEDBACKPROC __glewPauseTransformFeedback;\r\nGLEW_FUN_EXPORT PFNGLRESUMETRANSFORMFEEDBACKPROC __glewResumeTransformFeedback;\r\n\r\nGLEW_FUN_EXPORT PFNGLBEGINQUERYINDEXEDPROC __glewBeginQueryIndexed;\r\nGLEW_FUN_EXPORT PFNGLDRAWTRANSFORMFEEDBACKSTREAMPROC __glewDrawTransformFeedbackStream;\r\nGLEW_FUN_EXPORT PFNGLENDQUERYINDEXEDPROC __glewEndQueryIndexed;\r\nGLEW_FUN_EXPORT PFNGLGETQUERYINDEXEDIVPROC __glewGetQueryIndexediv;\r\n\r\nGLEW_FUN_EXPORT PFNGLDRAWTRANSFORMFEEDBACKINSTANCEDPROC __glewDrawTransformFeedbackInstanced;\r\nGLEW_FUN_EXPORT PFNGLDRAWTRANSFORMFEEDBACKSTREAMINSTANCEDPROC __glewDrawTransformFeedbackStreamInstanced;\r\n\r\nGLEW_FUN_EXPORT PFNGLLOADTRANSPOSEMATRIXDARBPROC __glewLoadTransposeMatrixdARB;\r\nGLEW_FUN_EXPORT PFNGLLOADTRANSPOSEMATRIXFARBPROC __glewLoadTransposeMatrixfARB;\r\nGLEW_FUN_EXPORT PFNGLMULTTRANSPOSEMATRIXDARBPROC __glewMultTransposeMatrixdARB;\r\nGLEW_FUN_EXPORT PFNGLMULTTRANSPOSEMATRIXFARBPROC __glewMultTransposeMatrixfARB;\r\n\r\nGLEW_FUN_EXPORT PFNGLBINDBUFFERBASEPROC __glewBindBufferBase;\r\nGLEW_FUN_EXPORT PFNGLBINDBUFFERRANGEPROC __glewBindBufferRange;\r\nGLEW_FUN_EXPORT PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC __glewGetActiveUniformBlockName;\r\nGLEW_FUN_EXPORT PFNGLGETACTIVEUNIFORMBLOCKIVPROC __glewGetActiveUniformBlockiv;\r\nGLEW_FUN_EXPORT PFNGLGETACTIVEUNIFORMNAMEPROC __glewGetActiveUniformName;\r\nGLEW_FUN_EXPORT PFNGLGETACTIVEUNIFORMSIVPROC __glewGetActiveUniformsiv;\r\nGLEW_FUN_EXPORT PFNGLGETINTEGERI_VPROC __glewGetIntegeri_v;\r\nGLEW_FUN_EXPORT PFNGLGETUNIFORMBLOCKINDEXPROC __glewGetUniformBlockIndex;\r\nGLEW_FUN_EXPORT PFNGLGETUNIFORMINDICESPROC __glewGetUniformIndices;\r\nGLEW_FUN_EXPORT PFNGLUNIFORMBLOCKBINDINGPROC __glewUniformBlockBinding;\r\n\r\nGLEW_FUN_EXPORT PFNGLBINDVERTEXARRAYPROC __glewBindVertexArray;\r\nGLEW_FUN_EXPORT PFNGLDELETEVERTEXARRAYSPROC __glewDeleteVertexArrays;\r\nGLEW_FUN_EXPORT PFNGLGENVERTEXARRAYSPROC __glewGenVertexArrays;\r\nGLEW_FUN_EXPORT PFNGLISVERTEXARRAYPROC __glewIsVertexArray;\r\n\r\nGLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBLDVPROC __glewGetVertexAttribLdv;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBL1DPROC __glewVertexAttribL1d;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBL1DVPROC __glewVertexAttribL1dv;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBL2DPROC __glewVertexAttribL2d;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBL2DVPROC __glewVertexAttribL2dv;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBL3DPROC __glewVertexAttribL3d;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBL3DVPROC __glewVertexAttribL3dv;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBL4DPROC __glewVertexAttribL4d;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBL4DVPROC __glewVertexAttribL4dv;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBLPOINTERPROC __glewVertexAttribLPointer;\r\n\r\nGLEW_FUN_EXPORT PFNGLBINDVERTEXBUFFERPROC __glewBindVertexBuffer;\r\nGLEW_FUN_EXPORT PFNGLVERTEXARRAYBINDVERTEXBUFFEREXTPROC __glewVertexArrayBindVertexBufferEXT;\r\nGLEW_FUN_EXPORT PFNGLVERTEXARRAYVERTEXATTRIBBINDINGEXTPROC __glewVertexArrayVertexAttribBindingEXT;\r\nGLEW_FUN_EXPORT PFNGLVERTEXARRAYVERTEXATTRIBFORMATEXTPROC __glewVertexArrayVertexAttribFormatEXT;\r\nGLEW_FUN_EXPORT PFNGLVERTEXARRAYVERTEXATTRIBIFORMATEXTPROC __glewVertexArrayVertexAttribIFormatEXT;\r\nGLEW_FUN_EXPORT PFNGLVERTEXARRAYVERTEXATTRIBLFORMATEXTPROC __glewVertexArrayVertexAttribLFormatEXT;\r\nGLEW_FUN_EXPORT PFNGLVERTEXARRAYVERTEXBINDINGDIVISOREXTPROC __glewVertexArrayVertexBindingDivisorEXT;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBBINDINGPROC __glewVertexAttribBinding;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBFORMATPROC __glewVertexAttribFormat;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBIFORMATPROC __glewVertexAttribIFormat;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBLFORMATPROC __glewVertexAttribLFormat;\r\nGLEW_FUN_EXPORT PFNGLVERTEXBINDINGDIVISORPROC __glewVertexBindingDivisor;\r\n\r\nGLEW_FUN_EXPORT PFNGLVERTEXBLENDARBPROC __glewVertexBlendARB;\r\nGLEW_FUN_EXPORT PFNGLWEIGHTPOINTERARBPROC __glewWeightPointerARB;\r\nGLEW_FUN_EXPORT PFNGLWEIGHTBVARBPROC __glewWeightbvARB;\r\nGLEW_FUN_EXPORT PFNGLWEIGHTDVARBPROC __glewWeightdvARB;\r\nGLEW_FUN_EXPORT PFNGLWEIGHTFVARBPROC __glewWeightfvARB;\r\nGLEW_FUN_EXPORT PFNGLWEIGHTIVARBPROC __glewWeightivARB;\r\nGLEW_FUN_EXPORT PFNGLWEIGHTSVARBPROC __glewWeightsvARB;\r\nGLEW_FUN_EXPORT PFNGLWEIGHTUBVARBPROC __glewWeightubvARB;\r\nGLEW_FUN_EXPORT PFNGLWEIGHTUIVARBPROC __glewWeightuivARB;\r\nGLEW_FUN_EXPORT PFNGLWEIGHTUSVARBPROC __glewWeightusvARB;\r\n\r\nGLEW_FUN_EXPORT PFNGLBINDBUFFERARBPROC __glewBindBufferARB;\r\nGLEW_FUN_EXPORT PFNGLBUFFERDATAARBPROC __glewBufferDataARB;\r\nGLEW_FUN_EXPORT PFNGLBUFFERSUBDATAARBPROC __glewBufferSubDataARB;\r\nGLEW_FUN_EXPORT PFNGLDELETEBUFFERSARBPROC __glewDeleteBuffersARB;\r\nGLEW_FUN_EXPORT PFNGLGENBUFFERSARBPROC __glewGenBuffersARB;\r\nGLEW_FUN_EXPORT PFNGLGETBUFFERPARAMETERIVARBPROC __glewGetBufferParameterivARB;\r\nGLEW_FUN_EXPORT PFNGLGETBUFFERPOINTERVARBPROC __glewGetBufferPointervARB;\r\nGLEW_FUN_EXPORT PFNGLGETBUFFERSUBDATAARBPROC __glewGetBufferSubDataARB;\r\nGLEW_FUN_EXPORT PFNGLISBUFFERARBPROC __glewIsBufferARB;\r\nGLEW_FUN_EXPORT PFNGLMAPBUFFERARBPROC __glewMapBufferARB;\r\nGLEW_FUN_EXPORT PFNGLUNMAPBUFFERARBPROC __glewUnmapBufferARB;\r\n\r\nGLEW_FUN_EXPORT PFNGLBINDPROGRAMARBPROC __glewBindProgramARB;\r\nGLEW_FUN_EXPORT PFNGLDELETEPROGRAMSARBPROC __glewDeleteProgramsARB;\r\nGLEW_FUN_EXPORT PFNGLDISABLEVERTEXATTRIBARRAYARBPROC __glewDisableVertexAttribArrayARB;\r\nGLEW_FUN_EXPORT PFNGLENABLEVERTEXATTRIBARRAYARBPROC __glewEnableVertexAttribArrayARB;\r\nGLEW_FUN_EXPORT PFNGLGENPROGRAMSARBPROC __glewGenProgramsARB;\r\nGLEW_FUN_EXPORT PFNGLGETPROGRAMENVPARAMETERDVARBPROC __glewGetProgramEnvParameterdvARB;\r\nGLEW_FUN_EXPORT PFNGLGETPROGRAMENVPARAMETERFVARBPROC __glewGetProgramEnvParameterfvARB;\r\nGLEW_FUN_EXPORT PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC __glewGetProgramLocalParameterdvARB;\r\nGLEW_FUN_EXPORT PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC __glewGetProgramLocalParameterfvARB;\r\nGLEW_FUN_EXPORT PFNGLGETPROGRAMSTRINGARBPROC __glewGetProgramStringARB;\r\nGLEW_FUN_EXPORT PFNGLGETPROGRAMIVARBPROC __glewGetProgramivARB;\r\nGLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBPOINTERVARBPROC __glewGetVertexAttribPointervARB;\r\nGLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBDVARBPROC __glewGetVertexAttribdvARB;\r\nGLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBFVARBPROC __glewGetVertexAttribfvARB;\r\nGLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBIVARBPROC __glewGetVertexAttribivARB;\r\nGLEW_FUN_EXPORT PFNGLISPROGRAMARBPROC __glewIsProgramARB;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETER4DARBPROC __glewProgramEnvParameter4dARB;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETER4DVARBPROC __glewProgramEnvParameter4dvARB;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETER4FARBPROC __glewProgramEnvParameter4fARB;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETER4FVARBPROC __glewProgramEnvParameter4fvARB;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETER4DARBPROC __glewProgramLocalParameter4dARB;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETER4DVARBPROC __glewProgramLocalParameter4dvARB;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETER4FARBPROC __glewProgramLocalParameter4fARB;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETER4FVARBPROC __glewProgramLocalParameter4fvARB;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMSTRINGARBPROC __glewProgramStringARB;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB1DARBPROC __glewVertexAttrib1dARB;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB1DVARBPROC __glewVertexAttrib1dvARB;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB1FARBPROC __glewVertexAttrib1fARB;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB1FVARBPROC __glewVertexAttrib1fvARB;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB1SARBPROC __glewVertexAttrib1sARB;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB1SVARBPROC __glewVertexAttrib1svARB;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB2DARBPROC __glewVertexAttrib2dARB;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB2DVARBPROC __glewVertexAttrib2dvARB;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB2FARBPROC __glewVertexAttrib2fARB;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB2FVARBPROC __glewVertexAttrib2fvARB;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB2SARBPROC __glewVertexAttrib2sARB;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB2SVARBPROC __glewVertexAttrib2svARB;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB3DARBPROC __glewVertexAttrib3dARB;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB3DVARBPROC __glewVertexAttrib3dvARB;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB3FARBPROC __glewVertexAttrib3fARB;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB3FVARBPROC __glewVertexAttrib3fvARB;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB3SARBPROC __glewVertexAttrib3sARB;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB3SVARBPROC __glewVertexAttrib3svARB;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NBVARBPROC __glewVertexAttrib4NbvARB;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NIVARBPROC __glewVertexAttrib4NivARB;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NSVARBPROC __glewVertexAttrib4NsvARB;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NUBARBPROC __glewVertexAttrib4NubARB;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NUBVARBPROC __glewVertexAttrib4NubvARB;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NUIVARBPROC __glewVertexAttrib4NuivARB;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NUSVARBPROC __glewVertexAttrib4NusvARB;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB4BVARBPROC __glewVertexAttrib4bvARB;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB4DARBPROC __glewVertexAttrib4dARB;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB4DVARBPROC __glewVertexAttrib4dvARB;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB4FARBPROC __glewVertexAttrib4fARB;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB4FVARBPROC __glewVertexAttrib4fvARB;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB4IVARBPROC __glewVertexAttrib4ivARB;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB4SARBPROC __glewVertexAttrib4sARB;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB4SVARBPROC __glewVertexAttrib4svARB;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB4UBVARBPROC __glewVertexAttrib4ubvARB;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB4UIVARBPROC __glewVertexAttrib4uivARB;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB4USVARBPROC __glewVertexAttrib4usvARB;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBPOINTERARBPROC __glewVertexAttribPointerARB;\r\n\r\nGLEW_FUN_EXPORT PFNGLBINDATTRIBLOCATIONARBPROC __glewBindAttribLocationARB;\r\nGLEW_FUN_EXPORT PFNGLGETACTIVEATTRIBARBPROC __glewGetActiveAttribARB;\r\nGLEW_FUN_EXPORT PFNGLGETATTRIBLOCATIONARBPROC __glewGetAttribLocationARB;\r\n\r\nGLEW_FUN_EXPORT PFNGLCOLORP3UIPROC __glewColorP3ui;\r\nGLEW_FUN_EXPORT PFNGLCOLORP3UIVPROC __glewColorP3uiv;\r\nGLEW_FUN_EXPORT PFNGLCOLORP4UIPROC __glewColorP4ui;\r\nGLEW_FUN_EXPORT PFNGLCOLORP4UIVPROC __glewColorP4uiv;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORDP1UIPROC __glewMultiTexCoordP1ui;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORDP1UIVPROC __glewMultiTexCoordP1uiv;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORDP2UIPROC __glewMultiTexCoordP2ui;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORDP2UIVPROC __glewMultiTexCoordP2uiv;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORDP3UIPROC __glewMultiTexCoordP3ui;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORDP3UIVPROC __glewMultiTexCoordP3uiv;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORDP4UIPROC __glewMultiTexCoordP4ui;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORDP4UIVPROC __glewMultiTexCoordP4uiv;\r\nGLEW_FUN_EXPORT PFNGLNORMALP3UIPROC __glewNormalP3ui;\r\nGLEW_FUN_EXPORT PFNGLNORMALP3UIVPROC __glewNormalP3uiv;\r\nGLEW_FUN_EXPORT PFNGLSECONDARYCOLORP3UIPROC __glewSecondaryColorP3ui;\r\nGLEW_FUN_EXPORT PFNGLSECONDARYCOLORP3UIVPROC __glewSecondaryColorP3uiv;\r\nGLEW_FUN_EXPORT PFNGLTEXCOORDP1UIPROC __glewTexCoordP1ui;\r\nGLEW_FUN_EXPORT PFNGLTEXCOORDP1UIVPROC __glewTexCoordP1uiv;\r\nGLEW_FUN_EXPORT PFNGLTEXCOORDP2UIPROC __glewTexCoordP2ui;\r\nGLEW_FUN_EXPORT PFNGLTEXCOORDP2UIVPROC __glewTexCoordP2uiv;\r\nGLEW_FUN_EXPORT PFNGLTEXCOORDP3UIPROC __glewTexCoordP3ui;\r\nGLEW_FUN_EXPORT PFNGLTEXCOORDP3UIVPROC __glewTexCoordP3uiv;\r\nGLEW_FUN_EXPORT PFNGLTEXCOORDP4UIPROC __glewTexCoordP4ui;\r\nGLEW_FUN_EXPORT PFNGLTEXCOORDP4UIVPROC __glewTexCoordP4uiv;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBP1UIPROC __glewVertexAttribP1ui;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBP1UIVPROC __glewVertexAttribP1uiv;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBP2UIPROC __glewVertexAttribP2ui;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBP2UIVPROC __glewVertexAttribP2uiv;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBP3UIPROC __glewVertexAttribP3ui;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBP3UIVPROC __glewVertexAttribP3uiv;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBP4UIPROC __glewVertexAttribP4ui;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBP4UIVPROC __glewVertexAttribP4uiv;\r\nGLEW_FUN_EXPORT PFNGLVERTEXP2UIPROC __glewVertexP2ui;\r\nGLEW_FUN_EXPORT PFNGLVERTEXP2UIVPROC __glewVertexP2uiv;\r\nGLEW_FUN_EXPORT PFNGLVERTEXP3UIPROC __glewVertexP3ui;\r\nGLEW_FUN_EXPORT PFNGLVERTEXP3UIVPROC __glewVertexP3uiv;\r\nGLEW_FUN_EXPORT PFNGLVERTEXP4UIPROC __glewVertexP4ui;\r\nGLEW_FUN_EXPORT PFNGLVERTEXP4UIVPROC __glewVertexP4uiv;\r\n\r\nGLEW_FUN_EXPORT PFNGLDEPTHRANGEARRAYVPROC __glewDepthRangeArrayv;\r\nGLEW_FUN_EXPORT PFNGLDEPTHRANGEINDEXEDPROC __glewDepthRangeIndexed;\r\nGLEW_FUN_EXPORT PFNGLGETDOUBLEI_VPROC __glewGetDoublei_v;\r\nGLEW_FUN_EXPORT PFNGLGETFLOATI_VPROC __glewGetFloati_v;\r\nGLEW_FUN_EXPORT PFNGLSCISSORARRAYVPROC __glewScissorArrayv;\r\nGLEW_FUN_EXPORT PFNGLSCISSORINDEXEDPROC __glewScissorIndexed;\r\nGLEW_FUN_EXPORT PFNGLSCISSORINDEXEDVPROC __glewScissorIndexedv;\r\nGLEW_FUN_EXPORT PFNGLVIEWPORTARRAYVPROC __glewViewportArrayv;\r\nGLEW_FUN_EXPORT PFNGLVIEWPORTINDEXEDFPROC __glewViewportIndexedf;\r\nGLEW_FUN_EXPORT PFNGLVIEWPORTINDEXEDFVPROC __glewViewportIndexedfv;\r\n\r\nGLEW_FUN_EXPORT PFNGLWINDOWPOS2DARBPROC __glewWindowPos2dARB;\r\nGLEW_FUN_EXPORT PFNGLWINDOWPOS2DVARBPROC __glewWindowPos2dvARB;\r\nGLEW_FUN_EXPORT PFNGLWINDOWPOS2FARBPROC __glewWindowPos2fARB;\r\nGLEW_FUN_EXPORT PFNGLWINDOWPOS2FVARBPROC __glewWindowPos2fvARB;\r\nGLEW_FUN_EXPORT PFNGLWINDOWPOS2IARBPROC __glewWindowPos2iARB;\r\nGLEW_FUN_EXPORT PFNGLWINDOWPOS2IVARBPROC __glewWindowPos2ivARB;\r\nGLEW_FUN_EXPORT PFNGLWINDOWPOS2SARBPROC __glewWindowPos2sARB;\r\nGLEW_FUN_EXPORT PFNGLWINDOWPOS2SVARBPROC __glewWindowPos2svARB;\r\nGLEW_FUN_EXPORT PFNGLWINDOWPOS3DARBPROC __glewWindowPos3dARB;\r\nGLEW_FUN_EXPORT PFNGLWINDOWPOS3DVARBPROC __glewWindowPos3dvARB;\r\nGLEW_FUN_EXPORT PFNGLWINDOWPOS3FARBPROC __glewWindowPos3fARB;\r\nGLEW_FUN_EXPORT PFNGLWINDOWPOS3FVARBPROC __glewWindowPos3fvARB;\r\nGLEW_FUN_EXPORT PFNGLWINDOWPOS3IARBPROC __glewWindowPos3iARB;\r\nGLEW_FUN_EXPORT PFNGLWINDOWPOS3IVARBPROC __glewWindowPos3ivARB;\r\nGLEW_FUN_EXPORT PFNGLWINDOWPOS3SARBPROC __glewWindowPos3sARB;\r\nGLEW_FUN_EXPORT PFNGLWINDOWPOS3SVARBPROC __glewWindowPos3svARB;\r\n\r\nGLEW_FUN_EXPORT PFNGLDRAWBUFFERSATIPROC __glewDrawBuffersATI;\r\n\r\nGLEW_FUN_EXPORT PFNGLDRAWELEMENTARRAYATIPROC __glewDrawElementArrayATI;\r\nGLEW_FUN_EXPORT PFNGLDRAWRANGEELEMENTARRAYATIPROC __glewDrawRangeElementArrayATI;\r\nGLEW_FUN_EXPORT PFNGLELEMENTPOINTERATIPROC __glewElementPointerATI;\r\n\r\nGLEW_FUN_EXPORT PFNGLGETTEXBUMPPARAMETERFVATIPROC __glewGetTexBumpParameterfvATI;\r\nGLEW_FUN_EXPORT PFNGLGETTEXBUMPPARAMETERIVATIPROC __glewGetTexBumpParameterivATI;\r\nGLEW_FUN_EXPORT PFNGLTEXBUMPPARAMETERFVATIPROC __glewTexBumpParameterfvATI;\r\nGLEW_FUN_EXPORT PFNGLTEXBUMPPARAMETERIVATIPROC __glewTexBumpParameterivATI;\r\n\r\nGLEW_FUN_EXPORT PFNGLALPHAFRAGMENTOP1ATIPROC __glewAlphaFragmentOp1ATI;\r\nGLEW_FUN_EXPORT PFNGLALPHAFRAGMENTOP2ATIPROC __glewAlphaFragmentOp2ATI;\r\nGLEW_FUN_EXPORT PFNGLALPHAFRAGMENTOP3ATIPROC __glewAlphaFragmentOp3ATI;\r\nGLEW_FUN_EXPORT PFNGLBEGINFRAGMENTSHADERATIPROC __glewBeginFragmentShaderATI;\r\nGLEW_FUN_EXPORT PFNGLBINDFRAGMENTSHADERATIPROC __glewBindFragmentShaderATI;\r\nGLEW_FUN_EXPORT PFNGLCOLORFRAGMENTOP1ATIPROC __glewColorFragmentOp1ATI;\r\nGLEW_FUN_EXPORT PFNGLCOLORFRAGMENTOP2ATIPROC __glewColorFragmentOp2ATI;\r\nGLEW_FUN_EXPORT PFNGLCOLORFRAGMENTOP3ATIPROC __glewColorFragmentOp3ATI;\r\nGLEW_FUN_EXPORT PFNGLDELETEFRAGMENTSHADERATIPROC __glewDeleteFragmentShaderATI;\r\nGLEW_FUN_EXPORT PFNGLENDFRAGMENTSHADERATIPROC __glewEndFragmentShaderATI;\r\nGLEW_FUN_EXPORT PFNGLGENFRAGMENTSHADERSATIPROC __glewGenFragmentShadersATI;\r\nGLEW_FUN_EXPORT PFNGLPASSTEXCOORDATIPROC __glewPassTexCoordATI;\r\nGLEW_FUN_EXPORT PFNGLSAMPLEMAPATIPROC __glewSampleMapATI;\r\nGLEW_FUN_EXPORT PFNGLSETFRAGMENTSHADERCONSTANTATIPROC __glewSetFragmentShaderConstantATI;\r\n\r\nGLEW_FUN_EXPORT PFNGLMAPOBJECTBUFFERATIPROC __glewMapObjectBufferATI;\r\nGLEW_FUN_EXPORT PFNGLUNMAPOBJECTBUFFERATIPROC __glewUnmapObjectBufferATI;\r\n\r\nGLEW_FUN_EXPORT PFNGLPNTRIANGLESFATIPROC __glewPNTrianglesfATI;\r\nGLEW_FUN_EXPORT PFNGLPNTRIANGLESIATIPROC __glewPNTrianglesiATI;\r\n\r\nGLEW_FUN_EXPORT PFNGLSTENCILFUNCSEPARATEATIPROC __glewStencilFuncSeparateATI;\r\nGLEW_FUN_EXPORT PFNGLSTENCILOPSEPARATEATIPROC __glewStencilOpSeparateATI;\r\n\r\nGLEW_FUN_EXPORT PFNGLARRAYOBJECTATIPROC __glewArrayObjectATI;\r\nGLEW_FUN_EXPORT PFNGLFREEOBJECTBUFFERATIPROC __glewFreeObjectBufferATI;\r\nGLEW_FUN_EXPORT PFNGLGETARRAYOBJECTFVATIPROC __glewGetArrayObjectfvATI;\r\nGLEW_FUN_EXPORT PFNGLGETARRAYOBJECTIVATIPROC __glewGetArrayObjectivATI;\r\nGLEW_FUN_EXPORT PFNGLGETOBJECTBUFFERFVATIPROC __glewGetObjectBufferfvATI;\r\nGLEW_FUN_EXPORT PFNGLGETOBJECTBUFFERIVATIPROC __glewGetObjectBufferivATI;\r\nGLEW_FUN_EXPORT PFNGLGETVARIANTARRAYOBJECTFVATIPROC __glewGetVariantArrayObjectfvATI;\r\nGLEW_FUN_EXPORT PFNGLGETVARIANTARRAYOBJECTIVATIPROC __glewGetVariantArrayObjectivATI;\r\nGLEW_FUN_EXPORT PFNGLISOBJECTBUFFERATIPROC __glewIsObjectBufferATI;\r\nGLEW_FUN_EXPORT PFNGLNEWOBJECTBUFFERATIPROC __glewNewObjectBufferATI;\r\nGLEW_FUN_EXPORT PFNGLUPDATEOBJECTBUFFERATIPROC __glewUpdateObjectBufferATI;\r\nGLEW_FUN_EXPORT PFNGLVARIANTARRAYOBJECTATIPROC __glewVariantArrayObjectATI;\r\n\r\nGLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBARRAYOBJECTFVATIPROC __glewGetVertexAttribArrayObjectfvATI;\r\nGLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBARRAYOBJECTIVATIPROC __glewGetVertexAttribArrayObjectivATI;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBARRAYOBJECTATIPROC __glewVertexAttribArrayObjectATI;\r\n\r\nGLEW_FUN_EXPORT PFNGLCLIENTACTIVEVERTEXSTREAMATIPROC __glewClientActiveVertexStreamATI;\r\nGLEW_FUN_EXPORT PFNGLNORMALSTREAM3BATIPROC __glewNormalStream3bATI;\r\nGLEW_FUN_EXPORT PFNGLNORMALSTREAM3BVATIPROC __glewNormalStream3bvATI;\r\nGLEW_FUN_EXPORT PFNGLNORMALSTREAM3DATIPROC __glewNormalStream3dATI;\r\nGLEW_FUN_EXPORT PFNGLNORMALSTREAM3DVATIPROC __glewNormalStream3dvATI;\r\nGLEW_FUN_EXPORT PFNGLNORMALSTREAM3FATIPROC __glewNormalStream3fATI;\r\nGLEW_FUN_EXPORT PFNGLNORMALSTREAM3FVATIPROC __glewNormalStream3fvATI;\r\nGLEW_FUN_EXPORT PFNGLNORMALSTREAM3IATIPROC __glewNormalStream3iATI;\r\nGLEW_FUN_EXPORT PFNGLNORMALSTREAM3IVATIPROC __glewNormalStream3ivATI;\r\nGLEW_FUN_EXPORT PFNGLNORMALSTREAM3SATIPROC __glewNormalStream3sATI;\r\nGLEW_FUN_EXPORT PFNGLNORMALSTREAM3SVATIPROC __glewNormalStream3svATI;\r\nGLEW_FUN_EXPORT PFNGLVERTEXBLENDENVFATIPROC __glewVertexBlendEnvfATI;\r\nGLEW_FUN_EXPORT PFNGLVERTEXBLENDENVIATIPROC __glewVertexBlendEnviATI;\r\nGLEW_FUN_EXPORT PFNGLVERTEXSTREAM1DATIPROC __glewVertexStream1dATI;\r\nGLEW_FUN_EXPORT PFNGLVERTEXSTREAM1DVATIPROC __glewVertexStream1dvATI;\r\nGLEW_FUN_EXPORT PFNGLVERTEXSTREAM1FATIPROC __glewVertexStream1fATI;\r\nGLEW_FUN_EXPORT PFNGLVERTEXSTREAM1FVATIPROC __glewVertexStream1fvATI;\r\nGLEW_FUN_EXPORT PFNGLVERTEXSTREAM1IATIPROC __glewVertexStream1iATI;\r\nGLEW_FUN_EXPORT PFNGLVERTEXSTREAM1IVATIPROC __glewVertexStream1ivATI;\r\nGLEW_FUN_EXPORT PFNGLVERTEXSTREAM1SATIPROC __glewVertexStream1sATI;\r\nGLEW_FUN_EXPORT PFNGLVERTEXSTREAM1SVATIPROC __glewVertexStream1svATI;\r\nGLEW_FUN_EXPORT PFNGLVERTEXSTREAM2DATIPROC __glewVertexStream2dATI;\r\nGLEW_FUN_EXPORT PFNGLVERTEXSTREAM2DVATIPROC __glewVertexStream2dvATI;\r\nGLEW_FUN_EXPORT PFNGLVERTEXSTREAM2FATIPROC __glewVertexStream2fATI;\r\nGLEW_FUN_EXPORT PFNGLVERTEXSTREAM2FVATIPROC __glewVertexStream2fvATI;\r\nGLEW_FUN_EXPORT PFNGLVERTEXSTREAM2IATIPROC __glewVertexStream2iATI;\r\nGLEW_FUN_EXPORT PFNGLVERTEXSTREAM2IVATIPROC __glewVertexStream2ivATI;\r\nGLEW_FUN_EXPORT PFNGLVERTEXSTREAM2SATIPROC __glewVertexStream2sATI;\r\nGLEW_FUN_EXPORT PFNGLVERTEXSTREAM2SVATIPROC __glewVertexStream2svATI;\r\nGLEW_FUN_EXPORT PFNGLVERTEXSTREAM3DATIPROC __glewVertexStream3dATI;\r\nGLEW_FUN_EXPORT PFNGLVERTEXSTREAM3DVATIPROC __glewVertexStream3dvATI;\r\nGLEW_FUN_EXPORT PFNGLVERTEXSTREAM3FATIPROC __glewVertexStream3fATI;\r\nGLEW_FUN_EXPORT PFNGLVERTEXSTREAM3FVATIPROC __glewVertexStream3fvATI;\r\nGLEW_FUN_EXPORT PFNGLVERTEXSTREAM3IATIPROC __glewVertexStream3iATI;\r\nGLEW_FUN_EXPORT PFNGLVERTEXSTREAM3IVATIPROC __glewVertexStream3ivATI;\r\nGLEW_FUN_EXPORT PFNGLVERTEXSTREAM3SATIPROC __glewVertexStream3sATI;\r\nGLEW_FUN_EXPORT PFNGLVERTEXSTREAM3SVATIPROC __glewVertexStream3svATI;\r\nGLEW_FUN_EXPORT PFNGLVERTEXSTREAM4DATIPROC __glewVertexStream4dATI;\r\nGLEW_FUN_EXPORT PFNGLVERTEXSTREAM4DVATIPROC __glewVertexStream4dvATI;\r\nGLEW_FUN_EXPORT PFNGLVERTEXSTREAM4FATIPROC __glewVertexStream4fATI;\r\nGLEW_FUN_EXPORT PFNGLVERTEXSTREAM4FVATIPROC __glewVertexStream4fvATI;\r\nGLEW_FUN_EXPORT PFNGLVERTEXSTREAM4IATIPROC __glewVertexStream4iATI;\r\nGLEW_FUN_EXPORT PFNGLVERTEXSTREAM4IVATIPROC __glewVertexStream4ivATI;\r\nGLEW_FUN_EXPORT PFNGLVERTEXSTREAM4SATIPROC __glewVertexStream4sATI;\r\nGLEW_FUN_EXPORT PFNGLVERTEXSTREAM4SVATIPROC __glewVertexStream4svATI;\r\n\r\nGLEW_FUN_EXPORT PFNGLGETUNIFORMBUFFERSIZEEXTPROC __glewGetUniformBufferSizeEXT;\r\nGLEW_FUN_EXPORT PFNGLGETUNIFORMOFFSETEXTPROC __glewGetUniformOffsetEXT;\r\nGLEW_FUN_EXPORT PFNGLUNIFORMBUFFEREXTPROC __glewUniformBufferEXT;\r\n\r\nGLEW_FUN_EXPORT PFNGLBLENDCOLOREXTPROC __glewBlendColorEXT;\r\n\r\nGLEW_FUN_EXPORT PFNGLBLENDEQUATIONSEPARATEEXTPROC __glewBlendEquationSeparateEXT;\r\n\r\nGLEW_FUN_EXPORT PFNGLBLENDFUNCSEPARATEEXTPROC __glewBlendFuncSeparateEXT;\r\n\r\nGLEW_FUN_EXPORT PFNGLBLENDEQUATIONEXTPROC __glewBlendEquationEXT;\r\n\r\nGLEW_FUN_EXPORT PFNGLCOLORSUBTABLEEXTPROC __glewColorSubTableEXT;\r\nGLEW_FUN_EXPORT PFNGLCOPYCOLORSUBTABLEEXTPROC __glewCopyColorSubTableEXT;\r\n\r\nGLEW_FUN_EXPORT PFNGLLOCKARRAYSEXTPROC __glewLockArraysEXT;\r\nGLEW_FUN_EXPORT PFNGLUNLOCKARRAYSEXTPROC __glewUnlockArraysEXT;\r\n\r\nGLEW_FUN_EXPORT PFNGLCONVOLUTIONFILTER1DEXTPROC __glewConvolutionFilter1DEXT;\r\nGLEW_FUN_EXPORT PFNGLCONVOLUTIONFILTER2DEXTPROC __glewConvolutionFilter2DEXT;\r\nGLEW_FUN_EXPORT PFNGLCONVOLUTIONPARAMETERFEXTPROC __glewConvolutionParameterfEXT;\r\nGLEW_FUN_EXPORT PFNGLCONVOLUTIONPARAMETERFVEXTPROC __glewConvolutionParameterfvEXT;\r\nGLEW_FUN_EXPORT PFNGLCONVOLUTIONPARAMETERIEXTPROC __glewConvolutionParameteriEXT;\r\nGLEW_FUN_EXPORT PFNGLCONVOLUTIONPARAMETERIVEXTPROC __glewConvolutionParameterivEXT;\r\nGLEW_FUN_EXPORT PFNGLCOPYCONVOLUTIONFILTER1DEXTPROC __glewCopyConvolutionFilter1DEXT;\r\nGLEW_FUN_EXPORT PFNGLCOPYCONVOLUTIONFILTER2DEXTPROC __glewCopyConvolutionFilter2DEXT;\r\nGLEW_FUN_EXPORT PFNGLGETCONVOLUTIONFILTEREXTPROC __glewGetConvolutionFilterEXT;\r\nGLEW_FUN_EXPORT PFNGLGETCONVOLUTIONPARAMETERFVEXTPROC __glewGetConvolutionParameterfvEXT;\r\nGLEW_FUN_EXPORT PFNGLGETCONVOLUTIONPARAMETERIVEXTPROC __glewGetConvolutionParameterivEXT;\r\nGLEW_FUN_EXPORT PFNGLGETSEPARABLEFILTEREXTPROC __glewGetSeparableFilterEXT;\r\nGLEW_FUN_EXPORT PFNGLSEPARABLEFILTER2DEXTPROC __glewSeparableFilter2DEXT;\r\n\r\nGLEW_FUN_EXPORT PFNGLBINORMALPOINTEREXTPROC __glewBinormalPointerEXT;\r\nGLEW_FUN_EXPORT PFNGLTANGENTPOINTEREXTPROC __glewTangentPointerEXT;\r\n\r\nGLEW_FUN_EXPORT PFNGLCOPYTEXIMAGE1DEXTPROC __glewCopyTexImage1DEXT;\r\nGLEW_FUN_EXPORT PFNGLCOPYTEXIMAGE2DEXTPROC __glewCopyTexImage2DEXT;\r\nGLEW_FUN_EXPORT PFNGLCOPYTEXSUBIMAGE1DEXTPROC __glewCopyTexSubImage1DEXT;\r\nGLEW_FUN_EXPORT PFNGLCOPYTEXSUBIMAGE2DEXTPROC __glewCopyTexSubImage2DEXT;\r\nGLEW_FUN_EXPORT PFNGLCOPYTEXSUBIMAGE3DEXTPROC __glewCopyTexSubImage3DEXT;\r\n\r\nGLEW_FUN_EXPORT PFNGLCULLPARAMETERDVEXTPROC __glewCullParameterdvEXT;\r\nGLEW_FUN_EXPORT PFNGLCULLPARAMETERFVEXTPROC __glewCullParameterfvEXT;\r\n\r\nGLEW_FUN_EXPORT PFNGLGETOBJECTLABELEXTPROC __glewGetObjectLabelEXT;\r\nGLEW_FUN_EXPORT PFNGLLABELOBJECTEXTPROC __glewLabelObjectEXT;\r\n\r\nGLEW_FUN_EXPORT PFNGLINSERTEVENTMARKEREXTPROC __glewInsertEventMarkerEXT;\r\nGLEW_FUN_EXPORT PFNGLPOPGROUPMARKEREXTPROC __glewPopGroupMarkerEXT;\r\nGLEW_FUN_EXPORT PFNGLPUSHGROUPMARKEREXTPROC __glewPushGroupMarkerEXT;\r\n\r\nGLEW_FUN_EXPORT PFNGLDEPTHBOUNDSEXTPROC __glewDepthBoundsEXT;\r\n\r\nGLEW_FUN_EXPORT PFNGLBINDMULTITEXTUREEXTPROC __glewBindMultiTextureEXT;\r\nGLEW_FUN_EXPORT PFNGLCHECKNAMEDFRAMEBUFFERSTATUSEXTPROC __glewCheckNamedFramebufferStatusEXT;\r\nGLEW_FUN_EXPORT PFNGLCLIENTATTRIBDEFAULTEXTPROC __glewClientAttribDefaultEXT;\r\nGLEW_FUN_EXPORT PFNGLCOMPRESSEDMULTITEXIMAGE1DEXTPROC __glewCompressedMultiTexImage1DEXT;\r\nGLEW_FUN_EXPORT PFNGLCOMPRESSEDMULTITEXIMAGE2DEXTPROC __glewCompressedMultiTexImage2DEXT;\r\nGLEW_FUN_EXPORT PFNGLCOMPRESSEDMULTITEXIMAGE3DEXTPROC __glewCompressedMultiTexImage3DEXT;\r\nGLEW_FUN_EXPORT PFNGLCOMPRESSEDMULTITEXSUBIMAGE1DEXTPROC __glewCompressedMultiTexSubImage1DEXT;\r\nGLEW_FUN_EXPORT PFNGLCOMPRESSEDMULTITEXSUBIMAGE2DEXTPROC __glewCompressedMultiTexSubImage2DEXT;\r\nGLEW_FUN_EXPORT PFNGLCOMPRESSEDMULTITEXSUBIMAGE3DEXTPROC __glewCompressedMultiTexSubImage3DEXT;\r\nGLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXTUREIMAGE1DEXTPROC __glewCompressedTextureImage1DEXT;\r\nGLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXTUREIMAGE2DEXTPROC __glewCompressedTextureImage2DEXT;\r\nGLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXTUREIMAGE3DEXTPROC __glewCompressedTextureImage3DEXT;\r\nGLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXTURESUBIMAGE1DEXTPROC __glewCompressedTextureSubImage1DEXT;\r\nGLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXTURESUBIMAGE2DEXTPROC __glewCompressedTextureSubImage2DEXT;\r\nGLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXTURESUBIMAGE3DEXTPROC __glewCompressedTextureSubImage3DEXT;\r\nGLEW_FUN_EXPORT PFNGLCOPYMULTITEXIMAGE1DEXTPROC __glewCopyMultiTexImage1DEXT;\r\nGLEW_FUN_EXPORT PFNGLCOPYMULTITEXIMAGE2DEXTPROC __glewCopyMultiTexImage2DEXT;\r\nGLEW_FUN_EXPORT PFNGLCOPYMULTITEXSUBIMAGE1DEXTPROC __glewCopyMultiTexSubImage1DEXT;\r\nGLEW_FUN_EXPORT PFNGLCOPYMULTITEXSUBIMAGE2DEXTPROC __glewCopyMultiTexSubImage2DEXT;\r\nGLEW_FUN_EXPORT PFNGLCOPYMULTITEXSUBIMAGE3DEXTPROC __glewCopyMultiTexSubImage3DEXT;\r\nGLEW_FUN_EXPORT PFNGLCOPYTEXTUREIMAGE1DEXTPROC __glewCopyTextureImage1DEXT;\r\nGLEW_FUN_EXPORT PFNGLCOPYTEXTUREIMAGE2DEXTPROC __glewCopyTextureImage2DEXT;\r\nGLEW_FUN_EXPORT PFNGLCOPYTEXTURESUBIMAGE1DEXTPROC __glewCopyTextureSubImage1DEXT;\r\nGLEW_FUN_EXPORT PFNGLCOPYTEXTURESUBIMAGE2DEXTPROC __glewCopyTextureSubImage2DEXT;\r\nGLEW_FUN_EXPORT PFNGLCOPYTEXTURESUBIMAGE3DEXTPROC __glewCopyTextureSubImage3DEXT;\r\nGLEW_FUN_EXPORT PFNGLDISABLECLIENTSTATEINDEXEDEXTPROC __glewDisableClientStateIndexedEXT;\r\nGLEW_FUN_EXPORT PFNGLDISABLECLIENTSTATEIEXTPROC __glewDisableClientStateiEXT;\r\nGLEW_FUN_EXPORT PFNGLDISABLEVERTEXARRAYATTRIBEXTPROC __glewDisableVertexArrayAttribEXT;\r\nGLEW_FUN_EXPORT PFNGLDISABLEVERTEXARRAYEXTPROC __glewDisableVertexArrayEXT;\r\nGLEW_FUN_EXPORT PFNGLENABLECLIENTSTATEINDEXEDEXTPROC __glewEnableClientStateIndexedEXT;\r\nGLEW_FUN_EXPORT PFNGLENABLECLIENTSTATEIEXTPROC __glewEnableClientStateiEXT;\r\nGLEW_FUN_EXPORT PFNGLENABLEVERTEXARRAYATTRIBEXTPROC __glewEnableVertexArrayAttribEXT;\r\nGLEW_FUN_EXPORT PFNGLENABLEVERTEXARRAYEXTPROC __glewEnableVertexArrayEXT;\r\nGLEW_FUN_EXPORT PFNGLFLUSHMAPPEDNAMEDBUFFERRANGEEXTPROC __glewFlushMappedNamedBufferRangeEXT;\r\nGLEW_FUN_EXPORT PFNGLFRAMEBUFFERDRAWBUFFEREXTPROC __glewFramebufferDrawBufferEXT;\r\nGLEW_FUN_EXPORT PFNGLFRAMEBUFFERDRAWBUFFERSEXTPROC __glewFramebufferDrawBuffersEXT;\r\nGLEW_FUN_EXPORT PFNGLFRAMEBUFFERREADBUFFEREXTPROC __glewFramebufferReadBufferEXT;\r\nGLEW_FUN_EXPORT PFNGLGENERATEMULTITEXMIPMAPEXTPROC __glewGenerateMultiTexMipmapEXT;\r\nGLEW_FUN_EXPORT PFNGLGENERATETEXTUREMIPMAPEXTPROC __glewGenerateTextureMipmapEXT;\r\nGLEW_FUN_EXPORT PFNGLGETCOMPRESSEDMULTITEXIMAGEEXTPROC __glewGetCompressedMultiTexImageEXT;\r\nGLEW_FUN_EXPORT PFNGLGETCOMPRESSEDTEXTUREIMAGEEXTPROC __glewGetCompressedTextureImageEXT;\r\nGLEW_FUN_EXPORT PFNGLGETDOUBLEINDEXEDVEXTPROC __glewGetDoubleIndexedvEXT;\r\nGLEW_FUN_EXPORT PFNGLGETDOUBLEI_VEXTPROC __glewGetDoublei_vEXT;\r\nGLEW_FUN_EXPORT PFNGLGETFLOATINDEXEDVEXTPROC __glewGetFloatIndexedvEXT;\r\nGLEW_FUN_EXPORT PFNGLGETFLOATI_VEXTPROC __glewGetFloati_vEXT;\r\nGLEW_FUN_EXPORT PFNGLGETFRAMEBUFFERPARAMETERIVEXTPROC __glewGetFramebufferParameterivEXT;\r\nGLEW_FUN_EXPORT PFNGLGETMULTITEXENVFVEXTPROC __glewGetMultiTexEnvfvEXT;\r\nGLEW_FUN_EXPORT PFNGLGETMULTITEXENVIVEXTPROC __glewGetMultiTexEnvivEXT;\r\nGLEW_FUN_EXPORT PFNGLGETMULTITEXGENDVEXTPROC __glewGetMultiTexGendvEXT;\r\nGLEW_FUN_EXPORT PFNGLGETMULTITEXGENFVEXTPROC __glewGetMultiTexGenfvEXT;\r\nGLEW_FUN_EXPORT PFNGLGETMULTITEXGENIVEXTPROC __glewGetMultiTexGenivEXT;\r\nGLEW_FUN_EXPORT PFNGLGETMULTITEXIMAGEEXTPROC __glewGetMultiTexImageEXT;\r\nGLEW_FUN_EXPORT PFNGLGETMULTITEXLEVELPARAMETERFVEXTPROC __glewGetMultiTexLevelParameterfvEXT;\r\nGLEW_FUN_EXPORT PFNGLGETMULTITEXLEVELPARAMETERIVEXTPROC __glewGetMultiTexLevelParameterivEXT;\r\nGLEW_FUN_EXPORT PFNGLGETMULTITEXPARAMETERIIVEXTPROC __glewGetMultiTexParameterIivEXT;\r\nGLEW_FUN_EXPORT PFNGLGETMULTITEXPARAMETERIUIVEXTPROC __glewGetMultiTexParameterIuivEXT;\r\nGLEW_FUN_EXPORT PFNGLGETMULTITEXPARAMETERFVEXTPROC __glewGetMultiTexParameterfvEXT;\r\nGLEW_FUN_EXPORT PFNGLGETMULTITEXPARAMETERIVEXTPROC __glewGetMultiTexParameterivEXT;\r\nGLEW_FUN_EXPORT PFNGLGETNAMEDBUFFERPARAMETERIVEXTPROC __glewGetNamedBufferParameterivEXT;\r\nGLEW_FUN_EXPORT PFNGLGETNAMEDBUFFERPOINTERVEXTPROC __glewGetNamedBufferPointervEXT;\r\nGLEW_FUN_EXPORT PFNGLGETNAMEDBUFFERSUBDATAEXTPROC __glewGetNamedBufferSubDataEXT;\r\nGLEW_FUN_EXPORT PFNGLGETNAMEDFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC __glewGetNamedFramebufferAttachmentParameterivEXT;\r\nGLEW_FUN_EXPORT PFNGLGETNAMEDPROGRAMLOCALPARAMETERIIVEXTPROC __glewGetNamedProgramLocalParameterIivEXT;\r\nGLEW_FUN_EXPORT PFNGLGETNAMEDPROGRAMLOCALPARAMETERIUIVEXTPROC __glewGetNamedProgramLocalParameterIuivEXT;\r\nGLEW_FUN_EXPORT PFNGLGETNAMEDPROGRAMLOCALPARAMETERDVEXTPROC __glewGetNamedProgramLocalParameterdvEXT;\r\nGLEW_FUN_EXPORT PFNGLGETNAMEDPROGRAMLOCALPARAMETERFVEXTPROC __glewGetNamedProgramLocalParameterfvEXT;\r\nGLEW_FUN_EXPORT PFNGLGETNAMEDPROGRAMSTRINGEXTPROC __glewGetNamedProgramStringEXT;\r\nGLEW_FUN_EXPORT PFNGLGETNAMEDPROGRAMIVEXTPROC __glewGetNamedProgramivEXT;\r\nGLEW_FUN_EXPORT PFNGLGETNAMEDRENDERBUFFERPARAMETERIVEXTPROC __glewGetNamedRenderbufferParameterivEXT;\r\nGLEW_FUN_EXPORT PFNGLGETPOINTERINDEXEDVEXTPROC __glewGetPointerIndexedvEXT;\r\nGLEW_FUN_EXPORT PFNGLGETPOINTERI_VEXTPROC __glewGetPointeri_vEXT;\r\nGLEW_FUN_EXPORT PFNGLGETTEXTUREIMAGEEXTPROC __glewGetTextureImageEXT;\r\nGLEW_FUN_EXPORT PFNGLGETTEXTURELEVELPARAMETERFVEXTPROC __glewGetTextureLevelParameterfvEXT;\r\nGLEW_FUN_EXPORT PFNGLGETTEXTURELEVELPARAMETERIVEXTPROC __glewGetTextureLevelParameterivEXT;\r\nGLEW_FUN_EXPORT PFNGLGETTEXTUREPARAMETERIIVEXTPROC __glewGetTextureParameterIivEXT;\r\nGLEW_FUN_EXPORT PFNGLGETTEXTUREPARAMETERIUIVEXTPROC __glewGetTextureParameterIuivEXT;\r\nGLEW_FUN_EXPORT PFNGLGETTEXTUREPARAMETERFVEXTPROC __glewGetTextureParameterfvEXT;\r\nGLEW_FUN_EXPORT PFNGLGETTEXTUREPARAMETERIVEXTPROC __glewGetTextureParameterivEXT;\r\nGLEW_FUN_EXPORT PFNGLGETVERTEXARRAYINTEGERI_VEXTPROC __glewGetVertexArrayIntegeri_vEXT;\r\nGLEW_FUN_EXPORT PFNGLGETVERTEXARRAYINTEGERVEXTPROC __glewGetVertexArrayIntegervEXT;\r\nGLEW_FUN_EXPORT PFNGLGETVERTEXARRAYPOINTERI_VEXTPROC __glewGetVertexArrayPointeri_vEXT;\r\nGLEW_FUN_EXPORT PFNGLGETVERTEXARRAYPOINTERVEXTPROC __glewGetVertexArrayPointervEXT;\r\nGLEW_FUN_EXPORT PFNGLMAPNAMEDBUFFEREXTPROC __glewMapNamedBufferEXT;\r\nGLEW_FUN_EXPORT PFNGLMAPNAMEDBUFFERRANGEEXTPROC __glewMapNamedBufferRangeEXT;\r\nGLEW_FUN_EXPORT PFNGLMATRIXFRUSTUMEXTPROC __glewMatrixFrustumEXT;\r\nGLEW_FUN_EXPORT PFNGLMATRIXLOADIDENTITYEXTPROC __glewMatrixLoadIdentityEXT;\r\nGLEW_FUN_EXPORT PFNGLMATRIXLOADTRANSPOSEDEXTPROC __glewMatrixLoadTransposedEXT;\r\nGLEW_FUN_EXPORT PFNGLMATRIXLOADTRANSPOSEFEXTPROC __glewMatrixLoadTransposefEXT;\r\nGLEW_FUN_EXPORT PFNGLMATRIXLOADDEXTPROC __glewMatrixLoaddEXT;\r\nGLEW_FUN_EXPORT PFNGLMATRIXLOADFEXTPROC __glewMatrixLoadfEXT;\r\nGLEW_FUN_EXPORT PFNGLMATRIXMULTTRANSPOSEDEXTPROC __glewMatrixMultTransposedEXT;\r\nGLEW_FUN_EXPORT PFNGLMATRIXMULTTRANSPOSEFEXTPROC __glewMatrixMultTransposefEXT;\r\nGLEW_FUN_EXPORT PFNGLMATRIXMULTDEXTPROC __glewMatrixMultdEXT;\r\nGLEW_FUN_EXPORT PFNGLMATRIXMULTFEXTPROC __glewMatrixMultfEXT;\r\nGLEW_FUN_EXPORT PFNGLMATRIXORTHOEXTPROC __glewMatrixOrthoEXT;\r\nGLEW_FUN_EXPORT PFNGLMATRIXPOPEXTPROC __glewMatrixPopEXT;\r\nGLEW_FUN_EXPORT PFNGLMATRIXPUSHEXTPROC __glewMatrixPushEXT;\r\nGLEW_FUN_EXPORT PFNGLMATRIXROTATEDEXTPROC __glewMatrixRotatedEXT;\r\nGLEW_FUN_EXPORT PFNGLMATRIXROTATEFEXTPROC __glewMatrixRotatefEXT;\r\nGLEW_FUN_EXPORT PFNGLMATRIXSCALEDEXTPROC __glewMatrixScaledEXT;\r\nGLEW_FUN_EXPORT PFNGLMATRIXSCALEFEXTPROC __glewMatrixScalefEXT;\r\nGLEW_FUN_EXPORT PFNGLMATRIXTRANSLATEDEXTPROC __glewMatrixTranslatedEXT;\r\nGLEW_FUN_EXPORT PFNGLMATRIXTRANSLATEFEXTPROC __glewMatrixTranslatefEXT;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXBUFFEREXTPROC __glewMultiTexBufferEXT;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORDPOINTEREXTPROC __glewMultiTexCoordPointerEXT;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXENVFEXTPROC __glewMultiTexEnvfEXT;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXENVFVEXTPROC __glewMultiTexEnvfvEXT;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXENVIEXTPROC __glewMultiTexEnviEXT;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXENVIVEXTPROC __glewMultiTexEnvivEXT;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXGENDEXTPROC __glewMultiTexGendEXT;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXGENDVEXTPROC __glewMultiTexGendvEXT;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXGENFEXTPROC __glewMultiTexGenfEXT;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXGENFVEXTPROC __glewMultiTexGenfvEXT;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXGENIEXTPROC __glewMultiTexGeniEXT;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXGENIVEXTPROC __glewMultiTexGenivEXT;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXIMAGE1DEXTPROC __glewMultiTexImage1DEXT;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXIMAGE2DEXTPROC __glewMultiTexImage2DEXT;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXIMAGE3DEXTPROC __glewMultiTexImage3DEXT;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXPARAMETERIIVEXTPROC __glewMultiTexParameterIivEXT;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXPARAMETERIUIVEXTPROC __glewMultiTexParameterIuivEXT;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXPARAMETERFEXTPROC __glewMultiTexParameterfEXT;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXPARAMETERFVEXTPROC __glewMultiTexParameterfvEXT;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXPARAMETERIEXTPROC __glewMultiTexParameteriEXT;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXPARAMETERIVEXTPROC __glewMultiTexParameterivEXT;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXRENDERBUFFEREXTPROC __glewMultiTexRenderbufferEXT;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXSUBIMAGE1DEXTPROC __glewMultiTexSubImage1DEXT;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXSUBIMAGE2DEXTPROC __glewMultiTexSubImage2DEXT;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXSUBIMAGE3DEXTPROC __glewMultiTexSubImage3DEXT;\r\nGLEW_FUN_EXPORT PFNGLNAMEDBUFFERDATAEXTPROC __glewNamedBufferDataEXT;\r\nGLEW_FUN_EXPORT PFNGLNAMEDBUFFERSUBDATAEXTPROC __glewNamedBufferSubDataEXT;\r\nGLEW_FUN_EXPORT PFNGLNAMEDCOPYBUFFERSUBDATAEXTPROC __glewNamedCopyBufferSubDataEXT;\r\nGLEW_FUN_EXPORT PFNGLNAMEDFRAMEBUFFERRENDERBUFFEREXTPROC __glewNamedFramebufferRenderbufferEXT;\r\nGLEW_FUN_EXPORT PFNGLNAMEDFRAMEBUFFERTEXTURE1DEXTPROC __glewNamedFramebufferTexture1DEXT;\r\nGLEW_FUN_EXPORT PFNGLNAMEDFRAMEBUFFERTEXTURE2DEXTPROC __glewNamedFramebufferTexture2DEXT;\r\nGLEW_FUN_EXPORT PFNGLNAMEDFRAMEBUFFERTEXTURE3DEXTPROC __glewNamedFramebufferTexture3DEXT;\r\nGLEW_FUN_EXPORT PFNGLNAMEDFRAMEBUFFERTEXTUREEXTPROC __glewNamedFramebufferTextureEXT;\r\nGLEW_FUN_EXPORT PFNGLNAMEDFRAMEBUFFERTEXTUREFACEEXTPROC __glewNamedFramebufferTextureFaceEXT;\r\nGLEW_FUN_EXPORT PFNGLNAMEDFRAMEBUFFERTEXTURELAYEREXTPROC __glewNamedFramebufferTextureLayerEXT;\r\nGLEW_FUN_EXPORT PFNGLNAMEDPROGRAMLOCALPARAMETER4DEXTPROC __glewNamedProgramLocalParameter4dEXT;\r\nGLEW_FUN_EXPORT PFNGLNAMEDPROGRAMLOCALPARAMETER4DVEXTPROC __glewNamedProgramLocalParameter4dvEXT;\r\nGLEW_FUN_EXPORT PFNGLNAMEDPROGRAMLOCALPARAMETER4FEXTPROC __glewNamedProgramLocalParameter4fEXT;\r\nGLEW_FUN_EXPORT PFNGLNAMEDPROGRAMLOCALPARAMETER4FVEXTPROC __glewNamedProgramLocalParameter4fvEXT;\r\nGLEW_FUN_EXPORT PFNGLNAMEDPROGRAMLOCALPARAMETERI4IEXTPROC __glewNamedProgramLocalParameterI4iEXT;\r\nGLEW_FUN_EXPORT PFNGLNAMEDPROGRAMLOCALPARAMETERI4IVEXTPROC __glewNamedProgramLocalParameterI4ivEXT;\r\nGLEW_FUN_EXPORT PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIEXTPROC __glewNamedProgramLocalParameterI4uiEXT;\r\nGLEW_FUN_EXPORT PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIVEXTPROC __glewNamedProgramLocalParameterI4uivEXT;\r\nGLEW_FUN_EXPORT PFNGLNAMEDPROGRAMLOCALPARAMETERS4FVEXTPROC __glewNamedProgramLocalParameters4fvEXT;\r\nGLEW_FUN_EXPORT PFNGLNAMEDPROGRAMLOCALPARAMETERSI4IVEXTPROC __glewNamedProgramLocalParametersI4ivEXT;\r\nGLEW_FUN_EXPORT PFNGLNAMEDPROGRAMLOCALPARAMETERSI4UIVEXTPROC __glewNamedProgramLocalParametersI4uivEXT;\r\nGLEW_FUN_EXPORT PFNGLNAMEDPROGRAMSTRINGEXTPROC __glewNamedProgramStringEXT;\r\nGLEW_FUN_EXPORT PFNGLNAMEDRENDERBUFFERSTORAGEEXTPROC __glewNamedRenderbufferStorageEXT;\r\nGLEW_FUN_EXPORT PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLECOVERAGEEXTPROC __glewNamedRenderbufferStorageMultisampleCoverageEXT;\r\nGLEW_FUN_EXPORT PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC __glewNamedRenderbufferStorageMultisampleEXT;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1FEXTPROC __glewProgramUniform1fEXT;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1FVEXTPROC __glewProgramUniform1fvEXT;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1IEXTPROC __glewProgramUniform1iEXT;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1IVEXTPROC __glewProgramUniform1ivEXT;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1UIEXTPROC __glewProgramUniform1uiEXT;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1UIVEXTPROC __glewProgramUniform1uivEXT;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2FEXTPROC __glewProgramUniform2fEXT;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2FVEXTPROC __glewProgramUniform2fvEXT;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2IEXTPROC __glewProgramUniform2iEXT;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2IVEXTPROC __glewProgramUniform2ivEXT;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2UIEXTPROC __glewProgramUniform2uiEXT;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2UIVEXTPROC __glewProgramUniform2uivEXT;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3FEXTPROC __glewProgramUniform3fEXT;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3FVEXTPROC __glewProgramUniform3fvEXT;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3IEXTPROC __glewProgramUniform3iEXT;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3IVEXTPROC __glewProgramUniform3ivEXT;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3UIEXTPROC __glewProgramUniform3uiEXT;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3UIVEXTPROC __glewProgramUniform3uivEXT;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4FEXTPROC __glewProgramUniform4fEXT;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4FVEXTPROC __glewProgramUniform4fvEXT;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4IEXTPROC __glewProgramUniform4iEXT;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4IVEXTPROC __glewProgramUniform4ivEXT;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4UIEXTPROC __glewProgramUniform4uiEXT;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4UIVEXTPROC __glewProgramUniform4uivEXT;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX2FVEXTPROC __glewProgramUniformMatrix2fvEXT;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX2X3FVEXTPROC __glewProgramUniformMatrix2x3fvEXT;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX2X4FVEXTPROC __glewProgramUniformMatrix2x4fvEXT;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX3FVEXTPROC __glewProgramUniformMatrix3fvEXT;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX3X2FVEXTPROC __glewProgramUniformMatrix3x2fvEXT;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX3X4FVEXTPROC __glewProgramUniformMatrix3x4fvEXT;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX4FVEXTPROC __glewProgramUniformMatrix4fvEXT;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX4X2FVEXTPROC __glewProgramUniformMatrix4x2fvEXT;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX4X3FVEXTPROC __glewProgramUniformMatrix4x3fvEXT;\r\nGLEW_FUN_EXPORT PFNGLPUSHCLIENTATTRIBDEFAULTEXTPROC __glewPushClientAttribDefaultEXT;\r\nGLEW_FUN_EXPORT PFNGLTEXTUREBUFFEREXTPROC __glewTextureBufferEXT;\r\nGLEW_FUN_EXPORT PFNGLTEXTUREIMAGE1DEXTPROC __glewTextureImage1DEXT;\r\nGLEW_FUN_EXPORT PFNGLTEXTUREIMAGE2DEXTPROC __glewTextureImage2DEXT;\r\nGLEW_FUN_EXPORT PFNGLTEXTUREIMAGE3DEXTPROC __glewTextureImage3DEXT;\r\nGLEW_FUN_EXPORT PFNGLTEXTUREPARAMETERIIVEXTPROC __glewTextureParameterIivEXT;\r\nGLEW_FUN_EXPORT PFNGLTEXTUREPARAMETERIUIVEXTPROC __glewTextureParameterIuivEXT;\r\nGLEW_FUN_EXPORT PFNGLTEXTUREPARAMETERFEXTPROC __glewTextureParameterfEXT;\r\nGLEW_FUN_EXPORT PFNGLTEXTUREPARAMETERFVEXTPROC __glewTextureParameterfvEXT;\r\nGLEW_FUN_EXPORT PFNGLTEXTUREPARAMETERIEXTPROC __glewTextureParameteriEXT;\r\nGLEW_FUN_EXPORT PFNGLTEXTUREPARAMETERIVEXTPROC __glewTextureParameterivEXT;\r\nGLEW_FUN_EXPORT PFNGLTEXTURERENDERBUFFEREXTPROC __glewTextureRenderbufferEXT;\r\nGLEW_FUN_EXPORT PFNGLTEXTURESUBIMAGE1DEXTPROC __glewTextureSubImage1DEXT;\r\nGLEW_FUN_EXPORT PFNGLTEXTURESUBIMAGE2DEXTPROC __glewTextureSubImage2DEXT;\r\nGLEW_FUN_EXPORT PFNGLTEXTURESUBIMAGE3DEXTPROC __glewTextureSubImage3DEXT;\r\nGLEW_FUN_EXPORT PFNGLUNMAPNAMEDBUFFEREXTPROC __glewUnmapNamedBufferEXT;\r\nGLEW_FUN_EXPORT PFNGLVERTEXARRAYCOLOROFFSETEXTPROC __glewVertexArrayColorOffsetEXT;\r\nGLEW_FUN_EXPORT PFNGLVERTEXARRAYEDGEFLAGOFFSETEXTPROC __glewVertexArrayEdgeFlagOffsetEXT;\r\nGLEW_FUN_EXPORT PFNGLVERTEXARRAYFOGCOORDOFFSETEXTPROC __glewVertexArrayFogCoordOffsetEXT;\r\nGLEW_FUN_EXPORT PFNGLVERTEXARRAYINDEXOFFSETEXTPROC __glewVertexArrayIndexOffsetEXT;\r\nGLEW_FUN_EXPORT PFNGLVERTEXARRAYMULTITEXCOORDOFFSETEXTPROC __glewVertexArrayMultiTexCoordOffsetEXT;\r\nGLEW_FUN_EXPORT PFNGLVERTEXARRAYNORMALOFFSETEXTPROC __glewVertexArrayNormalOffsetEXT;\r\nGLEW_FUN_EXPORT PFNGLVERTEXARRAYSECONDARYCOLOROFFSETEXTPROC __glewVertexArraySecondaryColorOffsetEXT;\r\nGLEW_FUN_EXPORT PFNGLVERTEXARRAYTEXCOORDOFFSETEXTPROC __glewVertexArrayTexCoordOffsetEXT;\r\nGLEW_FUN_EXPORT PFNGLVERTEXARRAYVERTEXATTRIBDIVISOREXTPROC __glewVertexArrayVertexAttribDivisorEXT;\r\nGLEW_FUN_EXPORT PFNGLVERTEXARRAYVERTEXATTRIBIOFFSETEXTPROC __glewVertexArrayVertexAttribIOffsetEXT;\r\nGLEW_FUN_EXPORT PFNGLVERTEXARRAYVERTEXATTRIBOFFSETEXTPROC __glewVertexArrayVertexAttribOffsetEXT;\r\nGLEW_FUN_EXPORT PFNGLVERTEXARRAYVERTEXOFFSETEXTPROC __glewVertexArrayVertexOffsetEXT;\r\n\r\nGLEW_FUN_EXPORT PFNGLCOLORMASKINDEXEDEXTPROC __glewColorMaskIndexedEXT;\r\nGLEW_FUN_EXPORT PFNGLDISABLEINDEXEDEXTPROC __glewDisableIndexedEXT;\r\nGLEW_FUN_EXPORT PFNGLENABLEINDEXEDEXTPROC __glewEnableIndexedEXT;\r\nGLEW_FUN_EXPORT PFNGLGETBOOLEANINDEXEDVEXTPROC __glewGetBooleanIndexedvEXT;\r\nGLEW_FUN_EXPORT PFNGLGETINTEGERINDEXEDVEXTPROC __glewGetIntegerIndexedvEXT;\r\nGLEW_FUN_EXPORT PFNGLISENABLEDINDEXEDEXTPROC __glewIsEnabledIndexedEXT;\r\n\r\nGLEW_FUN_EXPORT PFNGLDRAWARRAYSINSTANCEDEXTPROC __glewDrawArraysInstancedEXT;\r\nGLEW_FUN_EXPORT PFNGLDRAWELEMENTSINSTANCEDEXTPROC __glewDrawElementsInstancedEXT;\r\n\r\nGLEW_FUN_EXPORT PFNGLDRAWRANGEELEMENTSEXTPROC __glewDrawRangeElementsEXT;\r\n\r\nGLEW_FUN_EXPORT PFNGLFOGCOORDPOINTEREXTPROC __glewFogCoordPointerEXT;\r\nGLEW_FUN_EXPORT PFNGLFOGCOORDDEXTPROC __glewFogCoorddEXT;\r\nGLEW_FUN_EXPORT PFNGLFOGCOORDDVEXTPROC __glewFogCoorddvEXT;\r\nGLEW_FUN_EXPORT PFNGLFOGCOORDFEXTPROC __glewFogCoordfEXT;\r\nGLEW_FUN_EXPORT PFNGLFOGCOORDFVEXTPROC __glewFogCoordfvEXT;\r\n\r\nGLEW_FUN_EXPORT PFNGLFRAGMENTCOLORMATERIALEXTPROC __glewFragmentColorMaterialEXT;\r\nGLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTMODELFEXTPROC __glewFragmentLightModelfEXT;\r\nGLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTMODELFVEXTPROC __glewFragmentLightModelfvEXT;\r\nGLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTMODELIEXTPROC __glewFragmentLightModeliEXT;\r\nGLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTMODELIVEXTPROC __glewFragmentLightModelivEXT;\r\nGLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTFEXTPROC __glewFragmentLightfEXT;\r\nGLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTFVEXTPROC __glewFragmentLightfvEXT;\r\nGLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTIEXTPROC __glewFragmentLightiEXT;\r\nGLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTIVEXTPROC __glewFragmentLightivEXT;\r\nGLEW_FUN_EXPORT PFNGLFRAGMENTMATERIALFEXTPROC __glewFragmentMaterialfEXT;\r\nGLEW_FUN_EXPORT PFNGLFRAGMENTMATERIALFVEXTPROC __glewFragmentMaterialfvEXT;\r\nGLEW_FUN_EXPORT PFNGLFRAGMENTMATERIALIEXTPROC __glewFragmentMaterialiEXT;\r\nGLEW_FUN_EXPORT PFNGLFRAGMENTMATERIALIVEXTPROC __glewFragmentMaterialivEXT;\r\nGLEW_FUN_EXPORT PFNGLGETFRAGMENTLIGHTFVEXTPROC __glewGetFragmentLightfvEXT;\r\nGLEW_FUN_EXPORT PFNGLGETFRAGMENTLIGHTIVEXTPROC __glewGetFragmentLightivEXT;\r\nGLEW_FUN_EXPORT PFNGLGETFRAGMENTMATERIALFVEXTPROC __glewGetFragmentMaterialfvEXT;\r\nGLEW_FUN_EXPORT PFNGLGETFRAGMENTMATERIALIVEXTPROC __glewGetFragmentMaterialivEXT;\r\nGLEW_FUN_EXPORT PFNGLLIGHTENVIEXTPROC __glewLightEnviEXT;\r\n\r\nGLEW_FUN_EXPORT PFNGLBLITFRAMEBUFFEREXTPROC __glewBlitFramebufferEXT;\r\n\r\nGLEW_FUN_EXPORT PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC __glewRenderbufferStorageMultisampleEXT;\r\n\r\nGLEW_FUN_EXPORT PFNGLBINDFRAMEBUFFEREXTPROC __glewBindFramebufferEXT;\r\nGLEW_FUN_EXPORT PFNGLBINDRENDERBUFFEREXTPROC __glewBindRenderbufferEXT;\r\nGLEW_FUN_EXPORT PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC __glewCheckFramebufferStatusEXT;\r\nGLEW_FUN_EXPORT PFNGLDELETEFRAMEBUFFERSEXTPROC __glewDeleteFramebuffersEXT;\r\nGLEW_FUN_EXPORT PFNGLDELETERENDERBUFFERSEXTPROC __glewDeleteRenderbuffersEXT;\r\nGLEW_FUN_EXPORT PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC __glewFramebufferRenderbufferEXT;\r\nGLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURE1DEXTPROC __glewFramebufferTexture1DEXT;\r\nGLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURE2DEXTPROC __glewFramebufferTexture2DEXT;\r\nGLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURE3DEXTPROC __glewFramebufferTexture3DEXT;\r\nGLEW_FUN_EXPORT PFNGLGENFRAMEBUFFERSEXTPROC __glewGenFramebuffersEXT;\r\nGLEW_FUN_EXPORT PFNGLGENRENDERBUFFERSEXTPROC __glewGenRenderbuffersEXT;\r\nGLEW_FUN_EXPORT PFNGLGENERATEMIPMAPEXTPROC __glewGenerateMipmapEXT;\r\nGLEW_FUN_EXPORT PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC __glewGetFramebufferAttachmentParameterivEXT;\r\nGLEW_FUN_EXPORT PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC __glewGetRenderbufferParameterivEXT;\r\nGLEW_FUN_EXPORT PFNGLISFRAMEBUFFEREXTPROC __glewIsFramebufferEXT;\r\nGLEW_FUN_EXPORT PFNGLISRENDERBUFFEREXTPROC __glewIsRenderbufferEXT;\r\nGLEW_FUN_EXPORT PFNGLRENDERBUFFERSTORAGEEXTPROC __glewRenderbufferStorageEXT;\r\n\r\nGLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTUREEXTPROC __glewFramebufferTextureEXT;\r\nGLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTUREFACEEXTPROC __glewFramebufferTextureFaceEXT;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMPARAMETERIEXTPROC __glewProgramParameteriEXT;\r\n\r\nGLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETERS4FVEXTPROC __glewProgramEnvParameters4fvEXT;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETERS4FVEXTPROC __glewProgramLocalParameters4fvEXT;\r\n\r\nGLEW_FUN_EXPORT PFNGLBINDFRAGDATALOCATIONEXTPROC __glewBindFragDataLocationEXT;\r\nGLEW_FUN_EXPORT PFNGLGETFRAGDATALOCATIONEXTPROC __glewGetFragDataLocationEXT;\r\nGLEW_FUN_EXPORT PFNGLGETUNIFORMUIVEXTPROC __glewGetUniformuivEXT;\r\nGLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBIIVEXTPROC __glewGetVertexAttribIivEXT;\r\nGLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBIUIVEXTPROC __glewGetVertexAttribIuivEXT;\r\nGLEW_FUN_EXPORT PFNGLUNIFORM1UIEXTPROC __glewUniform1uiEXT;\r\nGLEW_FUN_EXPORT PFNGLUNIFORM1UIVEXTPROC __glewUniform1uivEXT;\r\nGLEW_FUN_EXPORT PFNGLUNIFORM2UIEXTPROC __glewUniform2uiEXT;\r\nGLEW_FUN_EXPORT PFNGLUNIFORM2UIVEXTPROC __glewUniform2uivEXT;\r\nGLEW_FUN_EXPORT PFNGLUNIFORM3UIEXTPROC __glewUniform3uiEXT;\r\nGLEW_FUN_EXPORT PFNGLUNIFORM3UIVEXTPROC __glewUniform3uivEXT;\r\nGLEW_FUN_EXPORT PFNGLUNIFORM4UIEXTPROC __glewUniform4uiEXT;\r\nGLEW_FUN_EXPORT PFNGLUNIFORM4UIVEXTPROC __glewUniform4uivEXT;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBI1IEXTPROC __glewVertexAttribI1iEXT;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBI1IVEXTPROC __glewVertexAttribI1ivEXT;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBI1UIEXTPROC __glewVertexAttribI1uiEXT;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBI1UIVEXTPROC __glewVertexAttribI1uivEXT;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBI2IEXTPROC __glewVertexAttribI2iEXT;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBI2IVEXTPROC __glewVertexAttribI2ivEXT;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBI2UIEXTPROC __glewVertexAttribI2uiEXT;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBI2UIVEXTPROC __glewVertexAttribI2uivEXT;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBI3IEXTPROC __glewVertexAttribI3iEXT;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBI3IVEXTPROC __glewVertexAttribI3ivEXT;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBI3UIEXTPROC __glewVertexAttribI3uiEXT;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBI3UIVEXTPROC __glewVertexAttribI3uivEXT;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4BVEXTPROC __glewVertexAttribI4bvEXT;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4IEXTPROC __glewVertexAttribI4iEXT;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4IVEXTPROC __glewVertexAttribI4ivEXT;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4SVEXTPROC __glewVertexAttribI4svEXT;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4UBVEXTPROC __glewVertexAttribI4ubvEXT;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4UIEXTPROC __glewVertexAttribI4uiEXT;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4UIVEXTPROC __glewVertexAttribI4uivEXT;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4USVEXTPROC __glewVertexAttribI4usvEXT;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBIPOINTEREXTPROC __glewVertexAttribIPointerEXT;\r\n\r\nGLEW_FUN_EXPORT PFNGLGETHISTOGRAMEXTPROC __glewGetHistogramEXT;\r\nGLEW_FUN_EXPORT PFNGLGETHISTOGRAMPARAMETERFVEXTPROC __glewGetHistogramParameterfvEXT;\r\nGLEW_FUN_EXPORT PFNGLGETHISTOGRAMPARAMETERIVEXTPROC __glewGetHistogramParameterivEXT;\r\nGLEW_FUN_EXPORT PFNGLGETMINMAXEXTPROC __glewGetMinmaxEXT;\r\nGLEW_FUN_EXPORT PFNGLGETMINMAXPARAMETERFVEXTPROC __glewGetMinmaxParameterfvEXT;\r\nGLEW_FUN_EXPORT PFNGLGETMINMAXPARAMETERIVEXTPROC __glewGetMinmaxParameterivEXT;\r\nGLEW_FUN_EXPORT PFNGLHISTOGRAMEXTPROC __glewHistogramEXT;\r\nGLEW_FUN_EXPORT PFNGLMINMAXEXTPROC __glewMinmaxEXT;\r\nGLEW_FUN_EXPORT PFNGLRESETHISTOGRAMEXTPROC __glewResetHistogramEXT;\r\nGLEW_FUN_EXPORT PFNGLRESETMINMAXEXTPROC __glewResetMinmaxEXT;\r\n\r\nGLEW_FUN_EXPORT PFNGLINDEXFUNCEXTPROC __glewIndexFuncEXT;\r\n\r\nGLEW_FUN_EXPORT PFNGLINDEXMATERIALEXTPROC __glewIndexMaterialEXT;\r\n\r\nGLEW_FUN_EXPORT PFNGLAPPLYTEXTUREEXTPROC __glewApplyTextureEXT;\r\nGLEW_FUN_EXPORT PFNGLTEXTURELIGHTEXTPROC __glewTextureLightEXT;\r\nGLEW_FUN_EXPORT PFNGLTEXTUREMATERIALEXTPROC __glewTextureMaterialEXT;\r\n\r\nGLEW_FUN_EXPORT PFNGLMULTIDRAWARRAYSEXTPROC __glewMultiDrawArraysEXT;\r\nGLEW_FUN_EXPORT PFNGLMULTIDRAWELEMENTSEXTPROC __glewMultiDrawElementsEXT;\r\n\r\nGLEW_FUN_EXPORT PFNGLSAMPLEMASKEXTPROC __glewSampleMaskEXT;\r\nGLEW_FUN_EXPORT PFNGLSAMPLEPATTERNEXTPROC __glewSamplePatternEXT;\r\n\r\nGLEW_FUN_EXPORT PFNGLCOLORTABLEEXTPROC __glewColorTableEXT;\r\nGLEW_FUN_EXPORT PFNGLGETCOLORTABLEEXTPROC __glewGetColorTableEXT;\r\nGLEW_FUN_EXPORT PFNGLGETCOLORTABLEPARAMETERFVEXTPROC __glewGetColorTableParameterfvEXT;\r\nGLEW_FUN_EXPORT PFNGLGETCOLORTABLEPARAMETERIVEXTPROC __glewGetColorTableParameterivEXT;\r\n\r\nGLEW_FUN_EXPORT PFNGLGETPIXELTRANSFORMPARAMETERFVEXTPROC __glewGetPixelTransformParameterfvEXT;\r\nGLEW_FUN_EXPORT PFNGLGETPIXELTRANSFORMPARAMETERIVEXTPROC __glewGetPixelTransformParameterivEXT;\r\nGLEW_FUN_EXPORT PFNGLPIXELTRANSFORMPARAMETERFEXTPROC __glewPixelTransformParameterfEXT;\r\nGLEW_FUN_EXPORT PFNGLPIXELTRANSFORMPARAMETERFVEXTPROC __glewPixelTransformParameterfvEXT;\r\nGLEW_FUN_EXPORT PFNGLPIXELTRANSFORMPARAMETERIEXTPROC __glewPixelTransformParameteriEXT;\r\nGLEW_FUN_EXPORT PFNGLPIXELTRANSFORMPARAMETERIVEXTPROC __glewPixelTransformParameterivEXT;\r\n\r\nGLEW_FUN_EXPORT PFNGLPOINTPARAMETERFEXTPROC __glewPointParameterfEXT;\r\nGLEW_FUN_EXPORT PFNGLPOINTPARAMETERFVEXTPROC __glewPointParameterfvEXT;\r\n\r\nGLEW_FUN_EXPORT PFNGLPOLYGONOFFSETEXTPROC __glewPolygonOffsetEXT;\r\n\r\nGLEW_FUN_EXPORT PFNGLPOLYGONOFFSETCLAMPEXTPROC __glewPolygonOffsetClampEXT;\r\n\r\nGLEW_FUN_EXPORT PFNGLPROVOKINGVERTEXEXTPROC __glewProvokingVertexEXT;\r\n\r\nGLEW_FUN_EXPORT PFNGLCOVERAGEMODULATIONNVPROC __glewCoverageModulationNV;\r\nGLEW_FUN_EXPORT PFNGLCOVERAGEMODULATIONTABLENVPROC __glewCoverageModulationTableNV;\r\nGLEW_FUN_EXPORT PFNGLGETCOVERAGEMODULATIONTABLENVPROC __glewGetCoverageModulationTableNV;\r\nGLEW_FUN_EXPORT PFNGLRASTERSAMPLESEXTPROC __glewRasterSamplesEXT;\r\n\r\nGLEW_FUN_EXPORT PFNGLBEGINSCENEEXTPROC __glewBeginSceneEXT;\r\nGLEW_FUN_EXPORT PFNGLENDSCENEEXTPROC __glewEndSceneEXT;\r\n\r\nGLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3BEXTPROC __glewSecondaryColor3bEXT;\r\nGLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3BVEXTPROC __glewSecondaryColor3bvEXT;\r\nGLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3DEXTPROC __glewSecondaryColor3dEXT;\r\nGLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3DVEXTPROC __glewSecondaryColor3dvEXT;\r\nGLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3FEXTPROC __glewSecondaryColor3fEXT;\r\nGLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3FVEXTPROC __glewSecondaryColor3fvEXT;\r\nGLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3IEXTPROC __glewSecondaryColor3iEXT;\r\nGLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3IVEXTPROC __glewSecondaryColor3ivEXT;\r\nGLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3SEXTPROC __glewSecondaryColor3sEXT;\r\nGLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3SVEXTPROC __glewSecondaryColor3svEXT;\r\nGLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3UBEXTPROC __glewSecondaryColor3ubEXT;\r\nGLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3UBVEXTPROC __glewSecondaryColor3ubvEXT;\r\nGLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3UIEXTPROC __glewSecondaryColor3uiEXT;\r\nGLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3UIVEXTPROC __glewSecondaryColor3uivEXT;\r\nGLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3USEXTPROC __glewSecondaryColor3usEXT;\r\nGLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3USVEXTPROC __glewSecondaryColor3usvEXT;\r\nGLEW_FUN_EXPORT PFNGLSECONDARYCOLORPOINTEREXTPROC __glewSecondaryColorPointerEXT;\r\n\r\nGLEW_FUN_EXPORT PFNGLACTIVEPROGRAMEXTPROC __glewActiveProgramEXT;\r\nGLEW_FUN_EXPORT PFNGLCREATESHADERPROGRAMEXTPROC __glewCreateShaderProgramEXT;\r\nGLEW_FUN_EXPORT PFNGLUSESHADERPROGRAMEXTPROC __glewUseShaderProgramEXT;\r\n\r\nGLEW_FUN_EXPORT PFNGLBINDIMAGETEXTUREEXTPROC __glewBindImageTextureEXT;\r\nGLEW_FUN_EXPORT PFNGLMEMORYBARRIEREXTPROC __glewMemoryBarrierEXT;\r\n\r\nGLEW_FUN_EXPORT PFNGLACTIVESTENCILFACEEXTPROC __glewActiveStencilFaceEXT;\r\n\r\nGLEW_FUN_EXPORT PFNGLTEXSUBIMAGE1DEXTPROC __glewTexSubImage1DEXT;\r\nGLEW_FUN_EXPORT PFNGLTEXSUBIMAGE2DEXTPROC __glewTexSubImage2DEXT;\r\nGLEW_FUN_EXPORT PFNGLTEXSUBIMAGE3DEXTPROC __glewTexSubImage3DEXT;\r\n\r\nGLEW_FUN_EXPORT PFNGLTEXIMAGE3DEXTPROC __glewTexImage3DEXT;\r\n\r\nGLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURELAYEREXTPROC __glewFramebufferTextureLayerEXT;\r\n\r\nGLEW_FUN_EXPORT PFNGLTEXBUFFEREXTPROC __glewTexBufferEXT;\r\n\r\nGLEW_FUN_EXPORT PFNGLCLEARCOLORIIEXTPROC __glewClearColorIiEXT;\r\nGLEW_FUN_EXPORT PFNGLCLEARCOLORIUIEXTPROC __glewClearColorIuiEXT;\r\nGLEW_FUN_EXPORT PFNGLGETTEXPARAMETERIIVEXTPROC __glewGetTexParameterIivEXT;\r\nGLEW_FUN_EXPORT PFNGLGETTEXPARAMETERIUIVEXTPROC __glewGetTexParameterIuivEXT;\r\nGLEW_FUN_EXPORT PFNGLTEXPARAMETERIIVEXTPROC __glewTexParameterIivEXT;\r\nGLEW_FUN_EXPORT PFNGLTEXPARAMETERIUIVEXTPROC __glewTexParameterIuivEXT;\r\n\r\nGLEW_FUN_EXPORT PFNGLARETEXTURESRESIDENTEXTPROC __glewAreTexturesResidentEXT;\r\nGLEW_FUN_EXPORT PFNGLBINDTEXTUREEXTPROC __glewBindTextureEXT;\r\nGLEW_FUN_EXPORT PFNGLDELETETEXTURESEXTPROC __glewDeleteTexturesEXT;\r\nGLEW_FUN_EXPORT PFNGLGENTEXTURESEXTPROC __glewGenTexturesEXT;\r\nGLEW_FUN_EXPORT PFNGLISTEXTUREEXTPROC __glewIsTextureEXT;\r\nGLEW_FUN_EXPORT PFNGLPRIORITIZETEXTURESEXTPROC __glewPrioritizeTexturesEXT;\r\n\r\nGLEW_FUN_EXPORT PFNGLTEXTURENORMALEXTPROC __glewTextureNormalEXT;\r\n\r\nGLEW_FUN_EXPORT PFNGLGETQUERYOBJECTI64VEXTPROC __glewGetQueryObjecti64vEXT;\r\nGLEW_FUN_EXPORT PFNGLGETQUERYOBJECTUI64VEXTPROC __glewGetQueryObjectui64vEXT;\r\n\r\nGLEW_FUN_EXPORT PFNGLBEGINTRANSFORMFEEDBACKEXTPROC __glewBeginTransformFeedbackEXT;\r\nGLEW_FUN_EXPORT PFNGLBINDBUFFERBASEEXTPROC __glewBindBufferBaseEXT;\r\nGLEW_FUN_EXPORT PFNGLBINDBUFFEROFFSETEXTPROC __glewBindBufferOffsetEXT;\r\nGLEW_FUN_EXPORT PFNGLBINDBUFFERRANGEEXTPROC __glewBindBufferRangeEXT;\r\nGLEW_FUN_EXPORT PFNGLENDTRANSFORMFEEDBACKEXTPROC __glewEndTransformFeedbackEXT;\r\nGLEW_FUN_EXPORT PFNGLGETTRANSFORMFEEDBACKVARYINGEXTPROC __glewGetTransformFeedbackVaryingEXT;\r\nGLEW_FUN_EXPORT PFNGLTRANSFORMFEEDBACKVARYINGSEXTPROC __glewTransformFeedbackVaryingsEXT;\r\n\r\nGLEW_FUN_EXPORT PFNGLARRAYELEMENTEXTPROC __glewArrayElementEXT;\r\nGLEW_FUN_EXPORT PFNGLCOLORPOINTEREXTPROC __glewColorPointerEXT;\r\nGLEW_FUN_EXPORT PFNGLDRAWARRAYSEXTPROC __glewDrawArraysEXT;\r\nGLEW_FUN_EXPORT PFNGLEDGEFLAGPOINTEREXTPROC __glewEdgeFlagPointerEXT;\r\nGLEW_FUN_EXPORT PFNGLINDEXPOINTEREXTPROC __glewIndexPointerEXT;\r\nGLEW_FUN_EXPORT PFNGLNORMALPOINTEREXTPROC __glewNormalPointerEXT;\r\nGLEW_FUN_EXPORT PFNGLTEXCOORDPOINTEREXTPROC __glewTexCoordPointerEXT;\r\nGLEW_FUN_EXPORT PFNGLVERTEXPOINTEREXTPROC __glewVertexPointerEXT;\r\n\r\nGLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBLDVEXTPROC __glewGetVertexAttribLdvEXT;\r\nGLEW_FUN_EXPORT PFNGLVERTEXARRAYVERTEXATTRIBLOFFSETEXTPROC __glewVertexArrayVertexAttribLOffsetEXT;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBL1DEXTPROC __glewVertexAttribL1dEXT;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBL1DVEXTPROC __glewVertexAttribL1dvEXT;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBL2DEXTPROC __glewVertexAttribL2dEXT;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBL2DVEXTPROC __glewVertexAttribL2dvEXT;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBL3DEXTPROC __glewVertexAttribL3dEXT;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBL3DVEXTPROC __glewVertexAttribL3dvEXT;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBL4DEXTPROC __glewVertexAttribL4dEXT;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBL4DVEXTPROC __glewVertexAttribL4dvEXT;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBLPOINTEREXTPROC __glewVertexAttribLPointerEXT;\r\n\r\nGLEW_FUN_EXPORT PFNGLBEGINVERTEXSHADEREXTPROC __glewBeginVertexShaderEXT;\r\nGLEW_FUN_EXPORT PFNGLBINDLIGHTPARAMETEREXTPROC __glewBindLightParameterEXT;\r\nGLEW_FUN_EXPORT PFNGLBINDMATERIALPARAMETEREXTPROC __glewBindMaterialParameterEXT;\r\nGLEW_FUN_EXPORT PFNGLBINDPARAMETEREXTPROC __glewBindParameterEXT;\r\nGLEW_FUN_EXPORT PFNGLBINDTEXGENPARAMETEREXTPROC __glewBindTexGenParameterEXT;\r\nGLEW_FUN_EXPORT PFNGLBINDTEXTUREUNITPARAMETEREXTPROC __glewBindTextureUnitParameterEXT;\r\nGLEW_FUN_EXPORT PFNGLBINDVERTEXSHADEREXTPROC __glewBindVertexShaderEXT;\r\nGLEW_FUN_EXPORT PFNGLDELETEVERTEXSHADEREXTPROC __glewDeleteVertexShaderEXT;\r\nGLEW_FUN_EXPORT PFNGLDISABLEVARIANTCLIENTSTATEEXTPROC __glewDisableVariantClientStateEXT;\r\nGLEW_FUN_EXPORT PFNGLENABLEVARIANTCLIENTSTATEEXTPROC __glewEnableVariantClientStateEXT;\r\nGLEW_FUN_EXPORT PFNGLENDVERTEXSHADEREXTPROC __glewEndVertexShaderEXT;\r\nGLEW_FUN_EXPORT PFNGLEXTRACTCOMPONENTEXTPROC __glewExtractComponentEXT;\r\nGLEW_FUN_EXPORT PFNGLGENSYMBOLSEXTPROC __glewGenSymbolsEXT;\r\nGLEW_FUN_EXPORT PFNGLGENVERTEXSHADERSEXTPROC __glewGenVertexShadersEXT;\r\nGLEW_FUN_EXPORT PFNGLGETINVARIANTBOOLEANVEXTPROC __glewGetInvariantBooleanvEXT;\r\nGLEW_FUN_EXPORT PFNGLGETINVARIANTFLOATVEXTPROC __glewGetInvariantFloatvEXT;\r\nGLEW_FUN_EXPORT PFNGLGETINVARIANTINTEGERVEXTPROC __glewGetInvariantIntegervEXT;\r\nGLEW_FUN_EXPORT PFNGLGETLOCALCONSTANTBOOLEANVEXTPROC __glewGetLocalConstantBooleanvEXT;\r\nGLEW_FUN_EXPORT PFNGLGETLOCALCONSTANTFLOATVEXTPROC __glewGetLocalConstantFloatvEXT;\r\nGLEW_FUN_EXPORT PFNGLGETLOCALCONSTANTINTEGERVEXTPROC __glewGetLocalConstantIntegervEXT;\r\nGLEW_FUN_EXPORT PFNGLGETVARIANTBOOLEANVEXTPROC __glewGetVariantBooleanvEXT;\r\nGLEW_FUN_EXPORT PFNGLGETVARIANTFLOATVEXTPROC __glewGetVariantFloatvEXT;\r\nGLEW_FUN_EXPORT PFNGLGETVARIANTINTEGERVEXTPROC __glewGetVariantIntegervEXT;\r\nGLEW_FUN_EXPORT PFNGLGETVARIANTPOINTERVEXTPROC __glewGetVariantPointervEXT;\r\nGLEW_FUN_EXPORT PFNGLINSERTCOMPONENTEXTPROC __glewInsertComponentEXT;\r\nGLEW_FUN_EXPORT PFNGLISVARIANTENABLEDEXTPROC __glewIsVariantEnabledEXT;\r\nGLEW_FUN_EXPORT PFNGLSETINVARIANTEXTPROC __glewSetInvariantEXT;\r\nGLEW_FUN_EXPORT PFNGLSETLOCALCONSTANTEXTPROC __glewSetLocalConstantEXT;\r\nGLEW_FUN_EXPORT PFNGLSHADEROP1EXTPROC __glewShaderOp1EXT;\r\nGLEW_FUN_EXPORT PFNGLSHADEROP2EXTPROC __glewShaderOp2EXT;\r\nGLEW_FUN_EXPORT PFNGLSHADEROP3EXTPROC __glewShaderOp3EXT;\r\nGLEW_FUN_EXPORT PFNGLSWIZZLEEXTPROC __glewSwizzleEXT;\r\nGLEW_FUN_EXPORT PFNGLVARIANTPOINTEREXTPROC __glewVariantPointerEXT;\r\nGLEW_FUN_EXPORT PFNGLVARIANTBVEXTPROC __glewVariantbvEXT;\r\nGLEW_FUN_EXPORT PFNGLVARIANTDVEXTPROC __glewVariantdvEXT;\r\nGLEW_FUN_EXPORT PFNGLVARIANTFVEXTPROC __glewVariantfvEXT;\r\nGLEW_FUN_EXPORT PFNGLVARIANTIVEXTPROC __glewVariantivEXT;\r\nGLEW_FUN_EXPORT PFNGLVARIANTSVEXTPROC __glewVariantsvEXT;\r\nGLEW_FUN_EXPORT PFNGLVARIANTUBVEXTPROC __glewVariantubvEXT;\r\nGLEW_FUN_EXPORT PFNGLVARIANTUIVEXTPROC __glewVariantuivEXT;\r\nGLEW_FUN_EXPORT PFNGLVARIANTUSVEXTPROC __glewVariantusvEXT;\r\nGLEW_FUN_EXPORT PFNGLWRITEMASKEXTPROC __glewWriteMaskEXT;\r\n\r\nGLEW_FUN_EXPORT PFNGLVERTEXWEIGHTPOINTEREXTPROC __glewVertexWeightPointerEXT;\r\nGLEW_FUN_EXPORT PFNGLVERTEXWEIGHTFEXTPROC __glewVertexWeightfEXT;\r\nGLEW_FUN_EXPORT PFNGLVERTEXWEIGHTFVEXTPROC __glewVertexWeightfvEXT;\r\n\r\nGLEW_FUN_EXPORT PFNGLIMPORTSYNCEXTPROC __glewImportSyncEXT;\r\n\r\nGLEW_FUN_EXPORT PFNGLFRAMETERMINATORGREMEDYPROC __glewFrameTerminatorGREMEDY;\r\n\r\nGLEW_FUN_EXPORT PFNGLSTRINGMARKERGREMEDYPROC __glewStringMarkerGREMEDY;\r\n\r\nGLEW_FUN_EXPORT PFNGLGETIMAGETRANSFORMPARAMETERFVHPPROC __glewGetImageTransformParameterfvHP;\r\nGLEW_FUN_EXPORT PFNGLGETIMAGETRANSFORMPARAMETERIVHPPROC __glewGetImageTransformParameterivHP;\r\nGLEW_FUN_EXPORT PFNGLIMAGETRANSFORMPARAMETERFHPPROC __glewImageTransformParameterfHP;\r\nGLEW_FUN_EXPORT PFNGLIMAGETRANSFORMPARAMETERFVHPPROC __glewImageTransformParameterfvHP;\r\nGLEW_FUN_EXPORT PFNGLIMAGETRANSFORMPARAMETERIHPPROC __glewImageTransformParameteriHP;\r\nGLEW_FUN_EXPORT PFNGLIMAGETRANSFORMPARAMETERIVHPPROC __glewImageTransformParameterivHP;\r\n\r\nGLEW_FUN_EXPORT PFNGLMULTIMODEDRAWARRAYSIBMPROC __glewMultiModeDrawArraysIBM;\r\nGLEW_FUN_EXPORT PFNGLMULTIMODEDRAWELEMENTSIBMPROC __glewMultiModeDrawElementsIBM;\r\n\r\nGLEW_FUN_EXPORT PFNGLCOLORPOINTERLISTIBMPROC __glewColorPointerListIBM;\r\nGLEW_FUN_EXPORT PFNGLEDGEFLAGPOINTERLISTIBMPROC __glewEdgeFlagPointerListIBM;\r\nGLEW_FUN_EXPORT PFNGLFOGCOORDPOINTERLISTIBMPROC __glewFogCoordPointerListIBM;\r\nGLEW_FUN_EXPORT PFNGLINDEXPOINTERLISTIBMPROC __glewIndexPointerListIBM;\r\nGLEW_FUN_EXPORT PFNGLNORMALPOINTERLISTIBMPROC __glewNormalPointerListIBM;\r\nGLEW_FUN_EXPORT PFNGLSECONDARYCOLORPOINTERLISTIBMPROC __glewSecondaryColorPointerListIBM;\r\nGLEW_FUN_EXPORT PFNGLTEXCOORDPOINTERLISTIBMPROC __glewTexCoordPointerListIBM;\r\nGLEW_FUN_EXPORT PFNGLVERTEXPOINTERLISTIBMPROC __glewVertexPointerListIBM;\r\n\r\nGLEW_FUN_EXPORT PFNGLMAPTEXTURE2DINTELPROC __glewMapTexture2DINTEL;\r\nGLEW_FUN_EXPORT PFNGLSYNCTEXTUREINTELPROC __glewSyncTextureINTEL;\r\nGLEW_FUN_EXPORT PFNGLUNMAPTEXTURE2DINTELPROC __glewUnmapTexture2DINTEL;\r\n\r\nGLEW_FUN_EXPORT PFNGLCOLORPOINTERVINTELPROC __glewColorPointervINTEL;\r\nGLEW_FUN_EXPORT PFNGLNORMALPOINTERVINTELPROC __glewNormalPointervINTEL;\r\nGLEW_FUN_EXPORT PFNGLTEXCOORDPOINTERVINTELPROC __glewTexCoordPointervINTEL;\r\nGLEW_FUN_EXPORT PFNGLVERTEXPOINTERVINTELPROC __glewVertexPointervINTEL;\r\n\r\nGLEW_FUN_EXPORT PFNGLBEGINPERFQUERYINTELPROC __glewBeginPerfQueryINTEL;\r\nGLEW_FUN_EXPORT PFNGLCREATEPERFQUERYINTELPROC __glewCreatePerfQueryINTEL;\r\nGLEW_FUN_EXPORT PFNGLDELETEPERFQUERYINTELPROC __glewDeletePerfQueryINTEL;\r\nGLEW_FUN_EXPORT PFNGLENDPERFQUERYINTELPROC __glewEndPerfQueryINTEL;\r\nGLEW_FUN_EXPORT PFNGLGETFIRSTPERFQUERYIDINTELPROC __glewGetFirstPerfQueryIdINTEL;\r\nGLEW_FUN_EXPORT PFNGLGETNEXTPERFQUERYIDINTELPROC __glewGetNextPerfQueryIdINTEL;\r\nGLEW_FUN_EXPORT PFNGLGETPERFCOUNTERINFOINTELPROC __glewGetPerfCounterInfoINTEL;\r\nGLEW_FUN_EXPORT PFNGLGETPERFQUERYDATAINTELPROC __glewGetPerfQueryDataINTEL;\r\nGLEW_FUN_EXPORT PFNGLGETPERFQUERYIDBYNAMEINTELPROC __glewGetPerfQueryIdByNameINTEL;\r\nGLEW_FUN_EXPORT PFNGLGETPERFQUERYINFOINTELPROC __glewGetPerfQueryInfoINTEL;\r\n\r\nGLEW_FUN_EXPORT PFNGLTEXSCISSORFUNCINTELPROC __glewTexScissorFuncINTEL;\r\nGLEW_FUN_EXPORT PFNGLTEXSCISSORINTELPROC __glewTexScissorINTEL;\r\n\r\nGLEW_FUN_EXPORT PFNGLBLENDBARRIERKHRPROC __glewBlendBarrierKHR;\r\n\r\nGLEW_FUN_EXPORT PFNGLDEBUGMESSAGECALLBACKPROC __glewDebugMessageCallback;\r\nGLEW_FUN_EXPORT PFNGLDEBUGMESSAGECONTROLPROC __glewDebugMessageControl;\r\nGLEW_FUN_EXPORT PFNGLDEBUGMESSAGEINSERTPROC __glewDebugMessageInsert;\r\nGLEW_FUN_EXPORT PFNGLGETDEBUGMESSAGELOGPROC __glewGetDebugMessageLog;\r\nGLEW_FUN_EXPORT PFNGLGETOBJECTLABELPROC __glewGetObjectLabel;\r\nGLEW_FUN_EXPORT PFNGLGETOBJECTPTRLABELPROC __glewGetObjectPtrLabel;\r\nGLEW_FUN_EXPORT PFNGLOBJECTLABELPROC __glewObjectLabel;\r\nGLEW_FUN_EXPORT PFNGLOBJECTPTRLABELPROC __glewObjectPtrLabel;\r\nGLEW_FUN_EXPORT PFNGLPOPDEBUGGROUPPROC __glewPopDebugGroup;\r\nGLEW_FUN_EXPORT PFNGLPUSHDEBUGGROUPPROC __glewPushDebugGroup;\r\n\r\nGLEW_FUN_EXPORT PFNGLGETNUNIFORMFVPROC __glewGetnUniformfv;\r\nGLEW_FUN_EXPORT PFNGLGETNUNIFORMIVPROC __glewGetnUniformiv;\r\nGLEW_FUN_EXPORT PFNGLGETNUNIFORMUIVPROC __glewGetnUniformuiv;\r\nGLEW_FUN_EXPORT PFNGLREADNPIXELSPROC __glewReadnPixels;\r\n\r\nGLEW_FUN_EXPORT PFNGLBUFFERREGIONENABLEDPROC __glewBufferRegionEnabled;\r\nGLEW_FUN_EXPORT PFNGLDELETEBUFFERREGIONPROC __glewDeleteBufferRegion;\r\nGLEW_FUN_EXPORT PFNGLDRAWBUFFERREGIONPROC __glewDrawBufferRegion;\r\nGLEW_FUN_EXPORT PFNGLNEWBUFFERREGIONPROC __glewNewBufferRegion;\r\nGLEW_FUN_EXPORT PFNGLREADBUFFERREGIONPROC __glewReadBufferRegion;\r\n\r\nGLEW_FUN_EXPORT PFNGLRESIZEBUFFERSMESAPROC __glewResizeBuffersMESA;\r\n\r\nGLEW_FUN_EXPORT PFNGLWINDOWPOS2DMESAPROC __glewWindowPos2dMESA;\r\nGLEW_FUN_EXPORT PFNGLWINDOWPOS2DVMESAPROC __glewWindowPos2dvMESA;\r\nGLEW_FUN_EXPORT PFNGLWINDOWPOS2FMESAPROC __glewWindowPos2fMESA;\r\nGLEW_FUN_EXPORT PFNGLWINDOWPOS2FVMESAPROC __glewWindowPos2fvMESA;\r\nGLEW_FUN_EXPORT PFNGLWINDOWPOS2IMESAPROC __glewWindowPos2iMESA;\r\nGLEW_FUN_EXPORT PFNGLWINDOWPOS2IVMESAPROC __glewWindowPos2ivMESA;\r\nGLEW_FUN_EXPORT PFNGLWINDOWPOS2SMESAPROC __glewWindowPos2sMESA;\r\nGLEW_FUN_EXPORT PFNGLWINDOWPOS2SVMESAPROC __glewWindowPos2svMESA;\r\nGLEW_FUN_EXPORT PFNGLWINDOWPOS3DMESAPROC __glewWindowPos3dMESA;\r\nGLEW_FUN_EXPORT PFNGLWINDOWPOS3DVMESAPROC __glewWindowPos3dvMESA;\r\nGLEW_FUN_EXPORT PFNGLWINDOWPOS3FMESAPROC __glewWindowPos3fMESA;\r\nGLEW_FUN_EXPORT PFNGLWINDOWPOS3FVMESAPROC __glewWindowPos3fvMESA;\r\nGLEW_FUN_EXPORT PFNGLWINDOWPOS3IMESAPROC __glewWindowPos3iMESA;\r\nGLEW_FUN_EXPORT PFNGLWINDOWPOS3IVMESAPROC __glewWindowPos3ivMESA;\r\nGLEW_FUN_EXPORT PFNGLWINDOWPOS3SMESAPROC __glewWindowPos3sMESA;\r\nGLEW_FUN_EXPORT PFNGLWINDOWPOS3SVMESAPROC __glewWindowPos3svMESA;\r\nGLEW_FUN_EXPORT PFNGLWINDOWPOS4DMESAPROC __glewWindowPos4dMESA;\r\nGLEW_FUN_EXPORT PFNGLWINDOWPOS4DVMESAPROC __glewWindowPos4dvMESA;\r\nGLEW_FUN_EXPORT PFNGLWINDOWPOS4FMESAPROC __glewWindowPos4fMESA;\r\nGLEW_FUN_EXPORT PFNGLWINDOWPOS4FVMESAPROC __glewWindowPos4fvMESA;\r\nGLEW_FUN_EXPORT PFNGLWINDOWPOS4IMESAPROC __glewWindowPos4iMESA;\r\nGLEW_FUN_EXPORT PFNGLWINDOWPOS4IVMESAPROC __glewWindowPos4ivMESA;\r\nGLEW_FUN_EXPORT PFNGLWINDOWPOS4SMESAPROC __glewWindowPos4sMESA;\r\nGLEW_FUN_EXPORT PFNGLWINDOWPOS4SVMESAPROC __glewWindowPos4svMESA;\r\n\r\nGLEW_FUN_EXPORT PFNGLBEGINCONDITIONALRENDERNVXPROC __glewBeginConditionalRenderNVX;\r\nGLEW_FUN_EXPORT PFNGLENDCONDITIONALRENDERNVXPROC __glewEndConditionalRenderNVX;\r\n\r\nGLEW_FUN_EXPORT PFNGLMULTIDRAWARRAYSINDIRECTBINDLESSNVPROC __glewMultiDrawArraysIndirectBindlessNV;\r\nGLEW_FUN_EXPORT PFNGLMULTIDRAWELEMENTSINDIRECTBINDLESSNVPROC __glewMultiDrawElementsIndirectBindlessNV;\r\n\r\nGLEW_FUN_EXPORT PFNGLMULTIDRAWARRAYSINDIRECTBINDLESSCOUNTNVPROC __glewMultiDrawArraysIndirectBindlessCountNV;\r\nGLEW_FUN_EXPORT PFNGLMULTIDRAWELEMENTSINDIRECTBINDLESSCOUNTNVPROC __glewMultiDrawElementsIndirectBindlessCountNV;\r\n\r\nGLEW_FUN_EXPORT PFNGLGETIMAGEHANDLENVPROC __glewGetImageHandleNV;\r\nGLEW_FUN_EXPORT PFNGLGETTEXTUREHANDLENVPROC __glewGetTextureHandleNV;\r\nGLEW_FUN_EXPORT PFNGLGETTEXTURESAMPLERHANDLENVPROC __glewGetTextureSamplerHandleNV;\r\nGLEW_FUN_EXPORT PFNGLISIMAGEHANDLERESIDENTNVPROC __glewIsImageHandleResidentNV;\r\nGLEW_FUN_EXPORT PFNGLISTEXTUREHANDLERESIDENTNVPROC __glewIsTextureHandleResidentNV;\r\nGLEW_FUN_EXPORT PFNGLMAKEIMAGEHANDLENONRESIDENTNVPROC __glewMakeImageHandleNonResidentNV;\r\nGLEW_FUN_EXPORT PFNGLMAKEIMAGEHANDLERESIDENTNVPROC __glewMakeImageHandleResidentNV;\r\nGLEW_FUN_EXPORT PFNGLMAKETEXTUREHANDLENONRESIDENTNVPROC __glewMakeTextureHandleNonResidentNV;\r\nGLEW_FUN_EXPORT PFNGLMAKETEXTUREHANDLERESIDENTNVPROC __glewMakeTextureHandleResidentNV;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMHANDLEUI64NVPROC __glewProgramUniformHandleui64NV;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMHANDLEUI64VNVPROC __glewProgramUniformHandleui64vNV;\r\nGLEW_FUN_EXPORT PFNGLUNIFORMHANDLEUI64NVPROC __glewUniformHandleui64NV;\r\nGLEW_FUN_EXPORT PFNGLUNIFORMHANDLEUI64VNVPROC __glewUniformHandleui64vNV;\r\n\r\nGLEW_FUN_EXPORT PFNGLBLENDBARRIERNVPROC __glewBlendBarrierNV;\r\nGLEW_FUN_EXPORT PFNGLBLENDPARAMETERINVPROC __glewBlendParameteriNV;\r\n\r\nGLEW_FUN_EXPORT PFNGLBEGINCONDITIONALRENDERNVPROC __glewBeginConditionalRenderNV;\r\nGLEW_FUN_EXPORT PFNGLENDCONDITIONALRENDERNVPROC __glewEndConditionalRenderNV;\r\n\r\nGLEW_FUN_EXPORT PFNGLSUBPIXELPRECISIONBIASNVPROC __glewSubpixelPrecisionBiasNV;\r\n\r\nGLEW_FUN_EXPORT PFNGLCONSERVATIVERASTERPARAMETERFNVPROC __glewConservativeRasterParameterfNV;\r\n\r\nGLEW_FUN_EXPORT PFNGLCOPYIMAGESUBDATANVPROC __glewCopyImageSubDataNV;\r\n\r\nGLEW_FUN_EXPORT PFNGLCLEARDEPTHDNVPROC __glewClearDepthdNV;\r\nGLEW_FUN_EXPORT PFNGLDEPTHBOUNDSDNVPROC __glewDepthBoundsdNV;\r\nGLEW_FUN_EXPORT PFNGLDEPTHRANGEDNVPROC __glewDepthRangedNV;\r\n\r\nGLEW_FUN_EXPORT PFNGLDRAWTEXTURENVPROC __glewDrawTextureNV;\r\n\r\nGLEW_FUN_EXPORT PFNGLEVALMAPSNVPROC __glewEvalMapsNV;\r\nGLEW_FUN_EXPORT PFNGLGETMAPATTRIBPARAMETERFVNVPROC __glewGetMapAttribParameterfvNV;\r\nGLEW_FUN_EXPORT PFNGLGETMAPATTRIBPARAMETERIVNVPROC __glewGetMapAttribParameterivNV;\r\nGLEW_FUN_EXPORT PFNGLGETMAPCONTROLPOINTSNVPROC __glewGetMapControlPointsNV;\r\nGLEW_FUN_EXPORT PFNGLGETMAPPARAMETERFVNVPROC __glewGetMapParameterfvNV;\r\nGLEW_FUN_EXPORT PFNGLGETMAPPARAMETERIVNVPROC __glewGetMapParameterivNV;\r\nGLEW_FUN_EXPORT PFNGLMAPCONTROLPOINTSNVPROC __glewMapControlPointsNV;\r\nGLEW_FUN_EXPORT PFNGLMAPPARAMETERFVNVPROC __glewMapParameterfvNV;\r\nGLEW_FUN_EXPORT PFNGLMAPPARAMETERIVNVPROC __glewMapParameterivNV;\r\n\r\nGLEW_FUN_EXPORT PFNGLGETMULTISAMPLEFVNVPROC __glewGetMultisamplefvNV;\r\nGLEW_FUN_EXPORT PFNGLSAMPLEMASKINDEXEDNVPROC __glewSampleMaskIndexedNV;\r\nGLEW_FUN_EXPORT PFNGLTEXRENDERBUFFERNVPROC __glewTexRenderbufferNV;\r\n\r\nGLEW_FUN_EXPORT PFNGLDELETEFENCESNVPROC __glewDeleteFencesNV;\r\nGLEW_FUN_EXPORT PFNGLFINISHFENCENVPROC __glewFinishFenceNV;\r\nGLEW_FUN_EXPORT PFNGLGENFENCESNVPROC __glewGenFencesNV;\r\nGLEW_FUN_EXPORT PFNGLGETFENCEIVNVPROC __glewGetFenceivNV;\r\nGLEW_FUN_EXPORT PFNGLISFENCENVPROC __glewIsFenceNV;\r\nGLEW_FUN_EXPORT PFNGLSETFENCENVPROC __glewSetFenceNV;\r\nGLEW_FUN_EXPORT PFNGLTESTFENCENVPROC __glewTestFenceNV;\r\n\r\nGLEW_FUN_EXPORT PFNGLFRAGMENTCOVERAGECOLORNVPROC __glewFragmentCoverageColorNV;\r\n\r\nGLEW_FUN_EXPORT PFNGLGETPROGRAMNAMEDPARAMETERDVNVPROC __glewGetProgramNamedParameterdvNV;\r\nGLEW_FUN_EXPORT PFNGLGETPROGRAMNAMEDPARAMETERFVNVPROC __glewGetProgramNamedParameterfvNV;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMNAMEDPARAMETER4DNVPROC __glewProgramNamedParameter4dNV;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMNAMEDPARAMETER4DVNVPROC __glewProgramNamedParameter4dvNV;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMNAMEDPARAMETER4FNVPROC __glewProgramNamedParameter4fNV;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMNAMEDPARAMETER4FVNVPROC __glewProgramNamedParameter4fvNV;\r\n\r\nGLEW_FUN_EXPORT PFNGLRENDERBUFFERSTORAGEMULTISAMPLECOVERAGENVPROC __glewRenderbufferStorageMultisampleCoverageNV;\r\n\r\nGLEW_FUN_EXPORT PFNGLPROGRAMVERTEXLIMITNVPROC __glewProgramVertexLimitNV;\r\n\r\nGLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETERI4INVPROC __glewProgramEnvParameterI4iNV;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETERI4IVNVPROC __glewProgramEnvParameterI4ivNV;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETERI4UINVPROC __glewProgramEnvParameterI4uiNV;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETERI4UIVNVPROC __glewProgramEnvParameterI4uivNV;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETERSI4IVNVPROC __glewProgramEnvParametersI4ivNV;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETERSI4UIVNVPROC __glewProgramEnvParametersI4uivNV;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETERI4INVPROC __glewProgramLocalParameterI4iNV;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETERI4IVNVPROC __glewProgramLocalParameterI4ivNV;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETERI4UINVPROC __glewProgramLocalParameterI4uiNV;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETERI4UIVNVPROC __glewProgramLocalParameterI4uivNV;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETERSI4IVNVPROC __glewProgramLocalParametersI4ivNV;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETERSI4UIVNVPROC __glewProgramLocalParametersI4uivNV;\r\n\r\nGLEW_FUN_EXPORT PFNGLGETUNIFORMI64VNVPROC __glewGetUniformi64vNV;\r\nGLEW_FUN_EXPORT PFNGLGETUNIFORMUI64VNVPROC __glewGetUniformui64vNV;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1I64NVPROC __glewProgramUniform1i64NV;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1I64VNVPROC __glewProgramUniform1i64vNV;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1UI64NVPROC __glewProgramUniform1ui64NV;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1UI64VNVPROC __glewProgramUniform1ui64vNV;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2I64NVPROC __glewProgramUniform2i64NV;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2I64VNVPROC __glewProgramUniform2i64vNV;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2UI64NVPROC __glewProgramUniform2ui64NV;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2UI64VNVPROC __glewProgramUniform2ui64vNV;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3I64NVPROC __glewProgramUniform3i64NV;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3I64VNVPROC __glewProgramUniform3i64vNV;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3UI64NVPROC __glewProgramUniform3ui64NV;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3UI64VNVPROC __glewProgramUniform3ui64vNV;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4I64NVPROC __glewProgramUniform4i64NV;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4I64VNVPROC __glewProgramUniform4i64vNV;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4UI64NVPROC __glewProgramUniform4ui64NV;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4UI64VNVPROC __glewProgramUniform4ui64vNV;\r\nGLEW_FUN_EXPORT PFNGLUNIFORM1I64NVPROC __glewUniform1i64NV;\r\nGLEW_FUN_EXPORT PFNGLUNIFORM1I64VNVPROC __glewUniform1i64vNV;\r\nGLEW_FUN_EXPORT PFNGLUNIFORM1UI64NVPROC __glewUniform1ui64NV;\r\nGLEW_FUN_EXPORT PFNGLUNIFORM1UI64VNVPROC __glewUniform1ui64vNV;\r\nGLEW_FUN_EXPORT PFNGLUNIFORM2I64NVPROC __glewUniform2i64NV;\r\nGLEW_FUN_EXPORT PFNGLUNIFORM2I64VNVPROC __glewUniform2i64vNV;\r\nGLEW_FUN_EXPORT PFNGLUNIFORM2UI64NVPROC __glewUniform2ui64NV;\r\nGLEW_FUN_EXPORT PFNGLUNIFORM2UI64VNVPROC __glewUniform2ui64vNV;\r\nGLEW_FUN_EXPORT PFNGLUNIFORM3I64NVPROC __glewUniform3i64NV;\r\nGLEW_FUN_EXPORT PFNGLUNIFORM3I64VNVPROC __glewUniform3i64vNV;\r\nGLEW_FUN_EXPORT PFNGLUNIFORM3UI64NVPROC __glewUniform3ui64NV;\r\nGLEW_FUN_EXPORT PFNGLUNIFORM3UI64VNVPROC __glewUniform3ui64vNV;\r\nGLEW_FUN_EXPORT PFNGLUNIFORM4I64NVPROC __glewUniform4i64NV;\r\nGLEW_FUN_EXPORT PFNGLUNIFORM4I64VNVPROC __glewUniform4i64vNV;\r\nGLEW_FUN_EXPORT PFNGLUNIFORM4UI64NVPROC __glewUniform4ui64NV;\r\nGLEW_FUN_EXPORT PFNGLUNIFORM4UI64VNVPROC __glewUniform4ui64vNV;\r\n\r\nGLEW_FUN_EXPORT PFNGLCOLOR3HNVPROC __glewColor3hNV;\r\nGLEW_FUN_EXPORT PFNGLCOLOR3HVNVPROC __glewColor3hvNV;\r\nGLEW_FUN_EXPORT PFNGLCOLOR4HNVPROC __glewColor4hNV;\r\nGLEW_FUN_EXPORT PFNGLCOLOR4HVNVPROC __glewColor4hvNV;\r\nGLEW_FUN_EXPORT PFNGLFOGCOORDHNVPROC __glewFogCoordhNV;\r\nGLEW_FUN_EXPORT PFNGLFOGCOORDHVNVPROC __glewFogCoordhvNV;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD1HNVPROC __glewMultiTexCoord1hNV;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD1HVNVPROC __glewMultiTexCoord1hvNV;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD2HNVPROC __glewMultiTexCoord2hNV;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD2HVNVPROC __glewMultiTexCoord2hvNV;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD3HNVPROC __glewMultiTexCoord3hNV;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD3HVNVPROC __glewMultiTexCoord3hvNV;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD4HNVPROC __glewMultiTexCoord4hNV;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD4HVNVPROC __glewMultiTexCoord4hvNV;\r\nGLEW_FUN_EXPORT PFNGLNORMAL3HNVPROC __glewNormal3hNV;\r\nGLEW_FUN_EXPORT PFNGLNORMAL3HVNVPROC __glewNormal3hvNV;\r\nGLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3HNVPROC __glewSecondaryColor3hNV;\r\nGLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3HVNVPROC __glewSecondaryColor3hvNV;\r\nGLEW_FUN_EXPORT PFNGLTEXCOORD1HNVPROC __glewTexCoord1hNV;\r\nGLEW_FUN_EXPORT PFNGLTEXCOORD1HVNVPROC __glewTexCoord1hvNV;\r\nGLEW_FUN_EXPORT PFNGLTEXCOORD2HNVPROC __glewTexCoord2hNV;\r\nGLEW_FUN_EXPORT PFNGLTEXCOORD2HVNVPROC __glewTexCoord2hvNV;\r\nGLEW_FUN_EXPORT PFNGLTEXCOORD3HNVPROC __glewTexCoord3hNV;\r\nGLEW_FUN_EXPORT PFNGLTEXCOORD3HVNVPROC __glewTexCoord3hvNV;\r\nGLEW_FUN_EXPORT PFNGLTEXCOORD4HNVPROC __glewTexCoord4hNV;\r\nGLEW_FUN_EXPORT PFNGLTEXCOORD4HVNVPROC __glewTexCoord4hvNV;\r\nGLEW_FUN_EXPORT PFNGLVERTEX2HNVPROC __glewVertex2hNV;\r\nGLEW_FUN_EXPORT PFNGLVERTEX2HVNVPROC __glewVertex2hvNV;\r\nGLEW_FUN_EXPORT PFNGLVERTEX3HNVPROC __glewVertex3hNV;\r\nGLEW_FUN_EXPORT PFNGLVERTEX3HVNVPROC __glewVertex3hvNV;\r\nGLEW_FUN_EXPORT PFNGLVERTEX4HNVPROC __glewVertex4hNV;\r\nGLEW_FUN_EXPORT PFNGLVERTEX4HVNVPROC __glewVertex4hvNV;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB1HNVPROC __glewVertexAttrib1hNV;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB1HVNVPROC __glewVertexAttrib1hvNV;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB2HNVPROC __glewVertexAttrib2hNV;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB2HVNVPROC __glewVertexAttrib2hvNV;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB3HNVPROC __glewVertexAttrib3hNV;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB3HVNVPROC __glewVertexAttrib3hvNV;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB4HNVPROC __glewVertexAttrib4hNV;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB4HVNVPROC __glewVertexAttrib4hvNV;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBS1HVNVPROC __glewVertexAttribs1hvNV;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBS2HVNVPROC __glewVertexAttribs2hvNV;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBS3HVNVPROC __glewVertexAttribs3hvNV;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBS4HVNVPROC __glewVertexAttribs4hvNV;\r\nGLEW_FUN_EXPORT PFNGLVERTEXWEIGHTHNVPROC __glewVertexWeighthNV;\r\nGLEW_FUN_EXPORT PFNGLVERTEXWEIGHTHVNVPROC __glewVertexWeighthvNV;\r\n\r\nGLEW_FUN_EXPORT PFNGLGETINTERNALFORMATSAMPLEIVNVPROC __glewGetInternalformatSampleivNV;\r\n\r\nGLEW_FUN_EXPORT PFNGLBEGINOCCLUSIONQUERYNVPROC __glewBeginOcclusionQueryNV;\r\nGLEW_FUN_EXPORT PFNGLDELETEOCCLUSIONQUERIESNVPROC __glewDeleteOcclusionQueriesNV;\r\nGLEW_FUN_EXPORT PFNGLENDOCCLUSIONQUERYNVPROC __glewEndOcclusionQueryNV;\r\nGLEW_FUN_EXPORT PFNGLGENOCCLUSIONQUERIESNVPROC __glewGenOcclusionQueriesNV;\r\nGLEW_FUN_EXPORT PFNGLGETOCCLUSIONQUERYIVNVPROC __glewGetOcclusionQueryivNV;\r\nGLEW_FUN_EXPORT PFNGLGETOCCLUSIONQUERYUIVNVPROC __glewGetOcclusionQueryuivNV;\r\nGLEW_FUN_EXPORT PFNGLISOCCLUSIONQUERYNVPROC __glewIsOcclusionQueryNV;\r\n\r\nGLEW_FUN_EXPORT PFNGLPROGRAMBUFFERPARAMETERSIIVNVPROC __glewProgramBufferParametersIivNV;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMBUFFERPARAMETERSIUIVNVPROC __glewProgramBufferParametersIuivNV;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMBUFFERPARAMETERSFVNVPROC __glewProgramBufferParametersfvNV;\r\n\r\nGLEW_FUN_EXPORT PFNGLCOPYPATHNVPROC __glewCopyPathNV;\r\nGLEW_FUN_EXPORT PFNGLCOVERFILLPATHINSTANCEDNVPROC __glewCoverFillPathInstancedNV;\r\nGLEW_FUN_EXPORT PFNGLCOVERFILLPATHNVPROC __glewCoverFillPathNV;\r\nGLEW_FUN_EXPORT PFNGLCOVERSTROKEPATHINSTANCEDNVPROC __glewCoverStrokePathInstancedNV;\r\nGLEW_FUN_EXPORT PFNGLCOVERSTROKEPATHNVPROC __glewCoverStrokePathNV;\r\nGLEW_FUN_EXPORT PFNGLDELETEPATHSNVPROC __glewDeletePathsNV;\r\nGLEW_FUN_EXPORT PFNGLGENPATHSNVPROC __glewGenPathsNV;\r\nGLEW_FUN_EXPORT PFNGLGETPATHCOLORGENFVNVPROC __glewGetPathColorGenfvNV;\r\nGLEW_FUN_EXPORT PFNGLGETPATHCOLORGENIVNVPROC __glewGetPathColorGenivNV;\r\nGLEW_FUN_EXPORT PFNGLGETPATHCOMMANDSNVPROC __glewGetPathCommandsNV;\r\nGLEW_FUN_EXPORT PFNGLGETPATHCOORDSNVPROC __glewGetPathCoordsNV;\r\nGLEW_FUN_EXPORT PFNGLGETPATHDASHARRAYNVPROC __glewGetPathDashArrayNV;\r\nGLEW_FUN_EXPORT PFNGLGETPATHLENGTHNVPROC __glewGetPathLengthNV;\r\nGLEW_FUN_EXPORT PFNGLGETPATHMETRICRANGENVPROC __glewGetPathMetricRangeNV;\r\nGLEW_FUN_EXPORT PFNGLGETPATHMETRICSNVPROC __glewGetPathMetricsNV;\r\nGLEW_FUN_EXPORT PFNGLGETPATHPARAMETERFVNVPROC __glewGetPathParameterfvNV;\r\nGLEW_FUN_EXPORT PFNGLGETPATHPARAMETERIVNVPROC __glewGetPathParameterivNV;\r\nGLEW_FUN_EXPORT PFNGLGETPATHSPACINGNVPROC __glewGetPathSpacingNV;\r\nGLEW_FUN_EXPORT PFNGLGETPATHTEXGENFVNVPROC __glewGetPathTexGenfvNV;\r\nGLEW_FUN_EXPORT PFNGLGETPATHTEXGENIVNVPROC __glewGetPathTexGenivNV;\r\nGLEW_FUN_EXPORT PFNGLGETPROGRAMRESOURCEFVNVPROC __glewGetProgramResourcefvNV;\r\nGLEW_FUN_EXPORT PFNGLINTERPOLATEPATHSNVPROC __glewInterpolatePathsNV;\r\nGLEW_FUN_EXPORT PFNGLISPATHNVPROC __glewIsPathNV;\r\nGLEW_FUN_EXPORT PFNGLISPOINTINFILLPATHNVPROC __glewIsPointInFillPathNV;\r\nGLEW_FUN_EXPORT PFNGLISPOINTINSTROKEPATHNVPROC __glewIsPointInStrokePathNV;\r\nGLEW_FUN_EXPORT PFNGLMATRIXLOAD3X2FNVPROC __glewMatrixLoad3x2fNV;\r\nGLEW_FUN_EXPORT PFNGLMATRIXLOAD3X3FNVPROC __glewMatrixLoad3x3fNV;\r\nGLEW_FUN_EXPORT PFNGLMATRIXLOADTRANSPOSE3X3FNVPROC __glewMatrixLoadTranspose3x3fNV;\r\nGLEW_FUN_EXPORT PFNGLMATRIXMULT3X2FNVPROC __glewMatrixMult3x2fNV;\r\nGLEW_FUN_EXPORT PFNGLMATRIXMULT3X3FNVPROC __glewMatrixMult3x3fNV;\r\nGLEW_FUN_EXPORT PFNGLMATRIXMULTTRANSPOSE3X3FNVPROC __glewMatrixMultTranspose3x3fNV;\r\nGLEW_FUN_EXPORT PFNGLPATHCOLORGENNVPROC __glewPathColorGenNV;\r\nGLEW_FUN_EXPORT PFNGLPATHCOMMANDSNVPROC __glewPathCommandsNV;\r\nGLEW_FUN_EXPORT PFNGLPATHCOORDSNVPROC __glewPathCoordsNV;\r\nGLEW_FUN_EXPORT PFNGLPATHCOVERDEPTHFUNCNVPROC __glewPathCoverDepthFuncNV;\r\nGLEW_FUN_EXPORT PFNGLPATHDASHARRAYNVPROC __glewPathDashArrayNV;\r\nGLEW_FUN_EXPORT PFNGLPATHFOGGENNVPROC __glewPathFogGenNV;\r\nGLEW_FUN_EXPORT PFNGLPATHGLYPHINDEXARRAYNVPROC __glewPathGlyphIndexArrayNV;\r\nGLEW_FUN_EXPORT PFNGLPATHGLYPHINDEXRANGENVPROC __glewPathGlyphIndexRangeNV;\r\nGLEW_FUN_EXPORT PFNGLPATHGLYPHRANGENVPROC __glewPathGlyphRangeNV;\r\nGLEW_FUN_EXPORT PFNGLPATHGLYPHSNVPROC __glewPathGlyphsNV;\r\nGLEW_FUN_EXPORT PFNGLPATHMEMORYGLYPHINDEXARRAYNVPROC __glewPathMemoryGlyphIndexArrayNV;\r\nGLEW_FUN_EXPORT PFNGLPATHPARAMETERFNVPROC __glewPathParameterfNV;\r\nGLEW_FUN_EXPORT PFNGLPATHPARAMETERFVNVPROC __glewPathParameterfvNV;\r\nGLEW_FUN_EXPORT PFNGLPATHPARAMETERINVPROC __glewPathParameteriNV;\r\nGLEW_FUN_EXPORT PFNGLPATHPARAMETERIVNVPROC __glewPathParameterivNV;\r\nGLEW_FUN_EXPORT PFNGLPATHSTENCILDEPTHOFFSETNVPROC __glewPathStencilDepthOffsetNV;\r\nGLEW_FUN_EXPORT PFNGLPATHSTENCILFUNCNVPROC __glewPathStencilFuncNV;\r\nGLEW_FUN_EXPORT PFNGLPATHSTRINGNVPROC __glewPathStringNV;\r\nGLEW_FUN_EXPORT PFNGLPATHSUBCOMMANDSNVPROC __glewPathSubCommandsNV;\r\nGLEW_FUN_EXPORT PFNGLPATHSUBCOORDSNVPROC __glewPathSubCoordsNV;\r\nGLEW_FUN_EXPORT PFNGLPATHTEXGENNVPROC __glewPathTexGenNV;\r\nGLEW_FUN_EXPORT PFNGLPOINTALONGPATHNVPROC __glewPointAlongPathNV;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMPATHFRAGMENTINPUTGENNVPROC __glewProgramPathFragmentInputGenNV;\r\nGLEW_FUN_EXPORT PFNGLSTENCILFILLPATHINSTANCEDNVPROC __glewStencilFillPathInstancedNV;\r\nGLEW_FUN_EXPORT PFNGLSTENCILFILLPATHNVPROC __glewStencilFillPathNV;\r\nGLEW_FUN_EXPORT PFNGLSTENCILSTROKEPATHINSTANCEDNVPROC __glewStencilStrokePathInstancedNV;\r\nGLEW_FUN_EXPORT PFNGLSTENCILSTROKEPATHNVPROC __glewStencilStrokePathNV;\r\nGLEW_FUN_EXPORT PFNGLSTENCILTHENCOVERFILLPATHINSTANCEDNVPROC __glewStencilThenCoverFillPathInstancedNV;\r\nGLEW_FUN_EXPORT PFNGLSTENCILTHENCOVERFILLPATHNVPROC __glewStencilThenCoverFillPathNV;\r\nGLEW_FUN_EXPORT PFNGLSTENCILTHENCOVERSTROKEPATHINSTANCEDNVPROC __glewStencilThenCoverStrokePathInstancedNV;\r\nGLEW_FUN_EXPORT PFNGLSTENCILTHENCOVERSTROKEPATHNVPROC __glewStencilThenCoverStrokePathNV;\r\nGLEW_FUN_EXPORT PFNGLTRANSFORMPATHNVPROC __glewTransformPathNV;\r\nGLEW_FUN_EXPORT PFNGLWEIGHTPATHSNVPROC __glewWeightPathsNV;\r\n\r\nGLEW_FUN_EXPORT PFNGLFLUSHPIXELDATARANGENVPROC __glewFlushPixelDataRangeNV;\r\nGLEW_FUN_EXPORT PFNGLPIXELDATARANGENVPROC __glewPixelDataRangeNV;\r\n\r\nGLEW_FUN_EXPORT PFNGLPOINTPARAMETERINVPROC __glewPointParameteriNV;\r\nGLEW_FUN_EXPORT PFNGLPOINTPARAMETERIVNVPROC __glewPointParameterivNV;\r\n\r\nGLEW_FUN_EXPORT PFNGLGETVIDEOI64VNVPROC __glewGetVideoi64vNV;\r\nGLEW_FUN_EXPORT PFNGLGETVIDEOIVNVPROC __glewGetVideoivNV;\r\nGLEW_FUN_EXPORT PFNGLGETVIDEOUI64VNVPROC __glewGetVideoui64vNV;\r\nGLEW_FUN_EXPORT PFNGLGETVIDEOUIVNVPROC __glewGetVideouivNV;\r\nGLEW_FUN_EXPORT PFNGLPRESENTFRAMEDUALFILLNVPROC __glewPresentFrameDualFillNV;\r\nGLEW_FUN_EXPORT PFNGLPRESENTFRAMEKEYEDNVPROC __glewPresentFrameKeyedNV;\r\n\r\nGLEW_FUN_EXPORT PFNGLPRIMITIVERESTARTINDEXNVPROC __glewPrimitiveRestartIndexNV;\r\nGLEW_FUN_EXPORT PFNGLPRIMITIVERESTARTNVPROC __glewPrimitiveRestartNV;\r\n\r\nGLEW_FUN_EXPORT PFNGLCOMBINERINPUTNVPROC __glewCombinerInputNV;\r\nGLEW_FUN_EXPORT PFNGLCOMBINEROUTPUTNVPROC __glewCombinerOutputNV;\r\nGLEW_FUN_EXPORT PFNGLCOMBINERPARAMETERFNVPROC __glewCombinerParameterfNV;\r\nGLEW_FUN_EXPORT PFNGLCOMBINERPARAMETERFVNVPROC __glewCombinerParameterfvNV;\r\nGLEW_FUN_EXPORT PFNGLCOMBINERPARAMETERINVPROC __glewCombinerParameteriNV;\r\nGLEW_FUN_EXPORT PFNGLCOMBINERPARAMETERIVNVPROC __glewCombinerParameterivNV;\r\nGLEW_FUN_EXPORT PFNGLFINALCOMBINERINPUTNVPROC __glewFinalCombinerInputNV;\r\nGLEW_FUN_EXPORT PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC __glewGetCombinerInputParameterfvNV;\r\nGLEW_FUN_EXPORT PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC __glewGetCombinerInputParameterivNV;\r\nGLEW_FUN_EXPORT PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC __glewGetCombinerOutputParameterfvNV;\r\nGLEW_FUN_EXPORT PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC __glewGetCombinerOutputParameterivNV;\r\nGLEW_FUN_EXPORT PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC __glewGetFinalCombinerInputParameterfvNV;\r\nGLEW_FUN_EXPORT PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC __glewGetFinalCombinerInputParameterivNV;\r\n\r\nGLEW_FUN_EXPORT PFNGLCOMBINERSTAGEPARAMETERFVNVPROC __glewCombinerStageParameterfvNV;\r\nGLEW_FUN_EXPORT PFNGLGETCOMBINERSTAGEPARAMETERFVNVPROC __glewGetCombinerStageParameterfvNV;\r\n\r\nGLEW_FUN_EXPORT PFNGLFRAMEBUFFERSAMPLELOCATIONSFVNVPROC __glewFramebufferSampleLocationsfvNV;\r\nGLEW_FUN_EXPORT PFNGLNAMEDFRAMEBUFFERSAMPLELOCATIONSFVNVPROC __glewNamedFramebufferSampleLocationsfvNV;\r\n\r\nGLEW_FUN_EXPORT PFNGLGETBUFFERPARAMETERUI64VNVPROC __glewGetBufferParameterui64vNV;\r\nGLEW_FUN_EXPORT PFNGLGETINTEGERUI64VNVPROC __glewGetIntegerui64vNV;\r\nGLEW_FUN_EXPORT PFNGLGETNAMEDBUFFERPARAMETERUI64VNVPROC __glewGetNamedBufferParameterui64vNV;\r\nGLEW_FUN_EXPORT PFNGLISBUFFERRESIDENTNVPROC __glewIsBufferResidentNV;\r\nGLEW_FUN_EXPORT PFNGLISNAMEDBUFFERRESIDENTNVPROC __glewIsNamedBufferResidentNV;\r\nGLEW_FUN_EXPORT PFNGLMAKEBUFFERNONRESIDENTNVPROC __glewMakeBufferNonResidentNV;\r\nGLEW_FUN_EXPORT PFNGLMAKEBUFFERRESIDENTNVPROC __glewMakeBufferResidentNV;\r\nGLEW_FUN_EXPORT PFNGLMAKENAMEDBUFFERNONRESIDENTNVPROC __glewMakeNamedBufferNonResidentNV;\r\nGLEW_FUN_EXPORT PFNGLMAKENAMEDBUFFERRESIDENTNVPROC __glewMakeNamedBufferResidentNV;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMUI64NVPROC __glewProgramUniformui64NV;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMUI64VNVPROC __glewProgramUniformui64vNV;\r\nGLEW_FUN_EXPORT PFNGLUNIFORMUI64NVPROC __glewUniformui64NV;\r\nGLEW_FUN_EXPORT PFNGLUNIFORMUI64VNVPROC __glewUniformui64vNV;\r\n\r\nGLEW_FUN_EXPORT PFNGLTEXTUREBARRIERNVPROC __glewTextureBarrierNV;\r\n\r\nGLEW_FUN_EXPORT PFNGLTEXIMAGE2DMULTISAMPLECOVERAGENVPROC __glewTexImage2DMultisampleCoverageNV;\r\nGLEW_FUN_EXPORT PFNGLTEXIMAGE3DMULTISAMPLECOVERAGENVPROC __glewTexImage3DMultisampleCoverageNV;\r\nGLEW_FUN_EXPORT PFNGLTEXTUREIMAGE2DMULTISAMPLECOVERAGENVPROC __glewTextureImage2DMultisampleCoverageNV;\r\nGLEW_FUN_EXPORT PFNGLTEXTUREIMAGE2DMULTISAMPLENVPROC __glewTextureImage2DMultisampleNV;\r\nGLEW_FUN_EXPORT PFNGLTEXTUREIMAGE3DMULTISAMPLECOVERAGENVPROC __glewTextureImage3DMultisampleCoverageNV;\r\nGLEW_FUN_EXPORT PFNGLTEXTUREIMAGE3DMULTISAMPLENVPROC __glewTextureImage3DMultisampleNV;\r\n\r\nGLEW_FUN_EXPORT PFNGLACTIVEVARYINGNVPROC __glewActiveVaryingNV;\r\nGLEW_FUN_EXPORT PFNGLBEGINTRANSFORMFEEDBACKNVPROC __glewBeginTransformFeedbackNV;\r\nGLEW_FUN_EXPORT PFNGLBINDBUFFERBASENVPROC __glewBindBufferBaseNV;\r\nGLEW_FUN_EXPORT PFNGLBINDBUFFEROFFSETNVPROC __glewBindBufferOffsetNV;\r\nGLEW_FUN_EXPORT PFNGLBINDBUFFERRANGENVPROC __glewBindBufferRangeNV;\r\nGLEW_FUN_EXPORT PFNGLENDTRANSFORMFEEDBACKNVPROC __glewEndTransformFeedbackNV;\r\nGLEW_FUN_EXPORT PFNGLGETACTIVEVARYINGNVPROC __glewGetActiveVaryingNV;\r\nGLEW_FUN_EXPORT PFNGLGETTRANSFORMFEEDBACKVARYINGNVPROC __glewGetTransformFeedbackVaryingNV;\r\nGLEW_FUN_EXPORT PFNGLGETVARYINGLOCATIONNVPROC __glewGetVaryingLocationNV;\r\nGLEW_FUN_EXPORT PFNGLTRANSFORMFEEDBACKATTRIBSNVPROC __glewTransformFeedbackAttribsNV;\r\nGLEW_FUN_EXPORT PFNGLTRANSFORMFEEDBACKVARYINGSNVPROC __glewTransformFeedbackVaryingsNV;\r\n\r\nGLEW_FUN_EXPORT PFNGLBINDTRANSFORMFEEDBACKNVPROC __glewBindTransformFeedbackNV;\r\nGLEW_FUN_EXPORT PFNGLDELETETRANSFORMFEEDBACKSNVPROC __glewDeleteTransformFeedbacksNV;\r\nGLEW_FUN_EXPORT PFNGLDRAWTRANSFORMFEEDBACKNVPROC __glewDrawTransformFeedbackNV;\r\nGLEW_FUN_EXPORT PFNGLGENTRANSFORMFEEDBACKSNVPROC __glewGenTransformFeedbacksNV;\r\nGLEW_FUN_EXPORT PFNGLISTRANSFORMFEEDBACKNVPROC __glewIsTransformFeedbackNV;\r\nGLEW_FUN_EXPORT PFNGLPAUSETRANSFORMFEEDBACKNVPROC __glewPauseTransformFeedbackNV;\r\nGLEW_FUN_EXPORT PFNGLRESUMETRANSFORMFEEDBACKNVPROC __glewResumeTransformFeedbackNV;\r\n\r\nGLEW_FUN_EXPORT PFNGLVDPAUFININVPROC __glewVDPAUFiniNV;\r\nGLEW_FUN_EXPORT PFNGLVDPAUGETSURFACEIVNVPROC __glewVDPAUGetSurfaceivNV;\r\nGLEW_FUN_EXPORT PFNGLVDPAUINITNVPROC __glewVDPAUInitNV;\r\nGLEW_FUN_EXPORT PFNGLVDPAUISSURFACENVPROC __glewVDPAUIsSurfaceNV;\r\nGLEW_FUN_EXPORT PFNGLVDPAUMAPSURFACESNVPROC __glewVDPAUMapSurfacesNV;\r\nGLEW_FUN_EXPORT PFNGLVDPAUREGISTEROUTPUTSURFACENVPROC __glewVDPAURegisterOutputSurfaceNV;\r\nGLEW_FUN_EXPORT PFNGLVDPAUREGISTERVIDEOSURFACENVPROC __glewVDPAURegisterVideoSurfaceNV;\r\nGLEW_FUN_EXPORT PFNGLVDPAUSURFACEACCESSNVPROC __glewVDPAUSurfaceAccessNV;\r\nGLEW_FUN_EXPORT PFNGLVDPAUUNMAPSURFACESNVPROC __glewVDPAUUnmapSurfacesNV;\r\nGLEW_FUN_EXPORT PFNGLVDPAUUNREGISTERSURFACENVPROC __glewVDPAUUnregisterSurfaceNV;\r\n\r\nGLEW_FUN_EXPORT PFNGLFLUSHVERTEXARRAYRANGENVPROC __glewFlushVertexArrayRangeNV;\r\nGLEW_FUN_EXPORT PFNGLVERTEXARRAYRANGENVPROC __glewVertexArrayRangeNV;\r\n\r\nGLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBLI64VNVPROC __glewGetVertexAttribLi64vNV;\r\nGLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBLUI64VNVPROC __glewGetVertexAttribLui64vNV;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBL1I64NVPROC __glewVertexAttribL1i64NV;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBL1I64VNVPROC __glewVertexAttribL1i64vNV;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBL1UI64NVPROC __glewVertexAttribL1ui64NV;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBL1UI64VNVPROC __glewVertexAttribL1ui64vNV;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBL2I64NVPROC __glewVertexAttribL2i64NV;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBL2I64VNVPROC __glewVertexAttribL2i64vNV;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBL2UI64NVPROC __glewVertexAttribL2ui64NV;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBL2UI64VNVPROC __glewVertexAttribL2ui64vNV;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBL3I64NVPROC __glewVertexAttribL3i64NV;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBL3I64VNVPROC __glewVertexAttribL3i64vNV;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBL3UI64NVPROC __glewVertexAttribL3ui64NV;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBL3UI64VNVPROC __glewVertexAttribL3ui64vNV;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBL4I64NVPROC __glewVertexAttribL4i64NV;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBL4I64VNVPROC __glewVertexAttribL4i64vNV;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBL4UI64NVPROC __glewVertexAttribL4ui64NV;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBL4UI64VNVPROC __glewVertexAttribL4ui64vNV;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBLFORMATNVPROC __glewVertexAttribLFormatNV;\r\n\r\nGLEW_FUN_EXPORT PFNGLBUFFERADDRESSRANGENVPROC __glewBufferAddressRangeNV;\r\nGLEW_FUN_EXPORT PFNGLCOLORFORMATNVPROC __glewColorFormatNV;\r\nGLEW_FUN_EXPORT PFNGLEDGEFLAGFORMATNVPROC __glewEdgeFlagFormatNV;\r\nGLEW_FUN_EXPORT PFNGLFOGCOORDFORMATNVPROC __glewFogCoordFormatNV;\r\nGLEW_FUN_EXPORT PFNGLGETINTEGERUI64I_VNVPROC __glewGetIntegerui64i_vNV;\r\nGLEW_FUN_EXPORT PFNGLINDEXFORMATNVPROC __glewIndexFormatNV;\r\nGLEW_FUN_EXPORT PFNGLNORMALFORMATNVPROC __glewNormalFormatNV;\r\nGLEW_FUN_EXPORT PFNGLSECONDARYCOLORFORMATNVPROC __glewSecondaryColorFormatNV;\r\nGLEW_FUN_EXPORT PFNGLTEXCOORDFORMATNVPROC __glewTexCoordFormatNV;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBFORMATNVPROC __glewVertexAttribFormatNV;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBIFORMATNVPROC __glewVertexAttribIFormatNV;\r\nGLEW_FUN_EXPORT PFNGLVERTEXFORMATNVPROC __glewVertexFormatNV;\r\n\r\nGLEW_FUN_EXPORT PFNGLAREPROGRAMSRESIDENTNVPROC __glewAreProgramsResidentNV;\r\nGLEW_FUN_EXPORT PFNGLBINDPROGRAMNVPROC __glewBindProgramNV;\r\nGLEW_FUN_EXPORT PFNGLDELETEPROGRAMSNVPROC __glewDeleteProgramsNV;\r\nGLEW_FUN_EXPORT PFNGLEXECUTEPROGRAMNVPROC __glewExecuteProgramNV;\r\nGLEW_FUN_EXPORT PFNGLGENPROGRAMSNVPROC __glewGenProgramsNV;\r\nGLEW_FUN_EXPORT PFNGLGETPROGRAMPARAMETERDVNVPROC __glewGetProgramParameterdvNV;\r\nGLEW_FUN_EXPORT PFNGLGETPROGRAMPARAMETERFVNVPROC __glewGetProgramParameterfvNV;\r\nGLEW_FUN_EXPORT PFNGLGETPROGRAMSTRINGNVPROC __glewGetProgramStringNV;\r\nGLEW_FUN_EXPORT PFNGLGETPROGRAMIVNVPROC __glewGetProgramivNV;\r\nGLEW_FUN_EXPORT PFNGLGETTRACKMATRIXIVNVPROC __glewGetTrackMatrixivNV;\r\nGLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBPOINTERVNVPROC __glewGetVertexAttribPointervNV;\r\nGLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBDVNVPROC __glewGetVertexAttribdvNV;\r\nGLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBFVNVPROC __glewGetVertexAttribfvNV;\r\nGLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBIVNVPROC __glewGetVertexAttribivNV;\r\nGLEW_FUN_EXPORT PFNGLISPROGRAMNVPROC __glewIsProgramNV;\r\nGLEW_FUN_EXPORT PFNGLLOADPROGRAMNVPROC __glewLoadProgramNV;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMPARAMETER4DNVPROC __glewProgramParameter4dNV;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMPARAMETER4DVNVPROC __glewProgramParameter4dvNV;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMPARAMETER4FNVPROC __glewProgramParameter4fNV;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMPARAMETER4FVNVPROC __glewProgramParameter4fvNV;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMPARAMETERS4DVNVPROC __glewProgramParameters4dvNV;\r\nGLEW_FUN_EXPORT PFNGLPROGRAMPARAMETERS4FVNVPROC __glewProgramParameters4fvNV;\r\nGLEW_FUN_EXPORT PFNGLREQUESTRESIDENTPROGRAMSNVPROC __glewRequestResidentProgramsNV;\r\nGLEW_FUN_EXPORT PFNGLTRACKMATRIXNVPROC __glewTrackMatrixNV;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB1DNVPROC __glewVertexAttrib1dNV;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB1DVNVPROC __glewVertexAttrib1dvNV;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB1FNVPROC __glewVertexAttrib1fNV;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB1FVNVPROC __glewVertexAttrib1fvNV;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB1SNVPROC __glewVertexAttrib1sNV;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB1SVNVPROC __glewVertexAttrib1svNV;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB2DNVPROC __glewVertexAttrib2dNV;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB2DVNVPROC __glewVertexAttrib2dvNV;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB2FNVPROC __glewVertexAttrib2fNV;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB2FVNVPROC __glewVertexAttrib2fvNV;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB2SNVPROC __glewVertexAttrib2sNV;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB2SVNVPROC __glewVertexAttrib2svNV;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB3DNVPROC __glewVertexAttrib3dNV;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB3DVNVPROC __glewVertexAttrib3dvNV;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB3FNVPROC __glewVertexAttrib3fNV;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB3FVNVPROC __glewVertexAttrib3fvNV;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB3SNVPROC __glewVertexAttrib3sNV;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB3SVNVPROC __glewVertexAttrib3svNV;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB4DNVPROC __glewVertexAttrib4dNV;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB4DVNVPROC __glewVertexAttrib4dvNV;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB4FNVPROC __glewVertexAttrib4fNV;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB4FVNVPROC __glewVertexAttrib4fvNV;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB4SNVPROC __glewVertexAttrib4sNV;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB4SVNVPROC __glewVertexAttrib4svNV;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB4UBNVPROC __glewVertexAttrib4ubNV;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIB4UBVNVPROC __glewVertexAttrib4ubvNV;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBPOINTERNVPROC __glewVertexAttribPointerNV;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBS1DVNVPROC __glewVertexAttribs1dvNV;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBS1FVNVPROC __glewVertexAttribs1fvNV;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBS1SVNVPROC __glewVertexAttribs1svNV;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBS2DVNVPROC __glewVertexAttribs2dvNV;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBS2FVNVPROC __glewVertexAttribs2fvNV;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBS2SVNVPROC __glewVertexAttribs2svNV;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBS3DVNVPROC __glewVertexAttribs3dvNV;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBS3FVNVPROC __glewVertexAttribs3fvNV;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBS3SVNVPROC __glewVertexAttribs3svNV;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBS4DVNVPROC __glewVertexAttribs4dvNV;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBS4FVNVPROC __glewVertexAttribs4fvNV;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBS4SVNVPROC __glewVertexAttribs4svNV;\r\nGLEW_FUN_EXPORT PFNGLVERTEXATTRIBS4UBVNVPROC __glewVertexAttribs4ubvNV;\r\n\r\nGLEW_FUN_EXPORT PFNGLBEGINVIDEOCAPTURENVPROC __glewBeginVideoCaptureNV;\r\nGLEW_FUN_EXPORT PFNGLBINDVIDEOCAPTURESTREAMBUFFERNVPROC __glewBindVideoCaptureStreamBufferNV;\r\nGLEW_FUN_EXPORT PFNGLBINDVIDEOCAPTURESTREAMTEXTURENVPROC __glewBindVideoCaptureStreamTextureNV;\r\nGLEW_FUN_EXPORT PFNGLENDVIDEOCAPTURENVPROC __glewEndVideoCaptureNV;\r\nGLEW_FUN_EXPORT PFNGLGETVIDEOCAPTURESTREAMDVNVPROC __glewGetVideoCaptureStreamdvNV;\r\nGLEW_FUN_EXPORT PFNGLGETVIDEOCAPTURESTREAMFVNVPROC __glewGetVideoCaptureStreamfvNV;\r\nGLEW_FUN_EXPORT PFNGLGETVIDEOCAPTURESTREAMIVNVPROC __glewGetVideoCaptureStreamivNV;\r\nGLEW_FUN_EXPORT PFNGLGETVIDEOCAPTUREIVNVPROC __glewGetVideoCaptureivNV;\r\nGLEW_FUN_EXPORT PFNGLVIDEOCAPTURENVPROC __glewVideoCaptureNV;\r\nGLEW_FUN_EXPORT PFNGLVIDEOCAPTURESTREAMPARAMETERDVNVPROC __glewVideoCaptureStreamParameterdvNV;\r\nGLEW_FUN_EXPORT PFNGLVIDEOCAPTURESTREAMPARAMETERFVNVPROC __glewVideoCaptureStreamParameterfvNV;\r\nGLEW_FUN_EXPORT PFNGLVIDEOCAPTURESTREAMPARAMETERIVNVPROC __glewVideoCaptureStreamParameterivNV;\r\n\r\nGLEW_FUN_EXPORT PFNGLCLEARDEPTHFOESPROC __glewClearDepthfOES;\r\nGLEW_FUN_EXPORT PFNGLCLIPPLANEFOESPROC __glewClipPlanefOES;\r\nGLEW_FUN_EXPORT PFNGLDEPTHRANGEFOESPROC __glewDepthRangefOES;\r\nGLEW_FUN_EXPORT PFNGLFRUSTUMFOESPROC __glewFrustumfOES;\r\nGLEW_FUN_EXPORT PFNGLGETCLIPPLANEFOESPROC __glewGetClipPlanefOES;\r\nGLEW_FUN_EXPORT PFNGLORTHOFOESPROC __glewOrthofOES;\r\n\r\nGLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTUREMULTIVIEWOVRPROC __glewFramebufferTextureMultiviewOVR;\r\n\r\nGLEW_FUN_EXPORT PFNGLALPHAFUNCXPROC __glewAlphaFuncx;\r\nGLEW_FUN_EXPORT PFNGLCLEARCOLORXPROC __glewClearColorx;\r\nGLEW_FUN_EXPORT PFNGLCLEARDEPTHXPROC __glewClearDepthx;\r\nGLEW_FUN_EXPORT PFNGLCOLOR4XPROC __glewColor4x;\r\nGLEW_FUN_EXPORT PFNGLDEPTHRANGEXPROC __glewDepthRangex;\r\nGLEW_FUN_EXPORT PFNGLFOGXPROC __glewFogx;\r\nGLEW_FUN_EXPORT PFNGLFOGXVPROC __glewFogxv;\r\nGLEW_FUN_EXPORT PFNGLFRUSTUMFPROC __glewFrustumf;\r\nGLEW_FUN_EXPORT PFNGLFRUSTUMXPROC __glewFrustumx;\r\nGLEW_FUN_EXPORT PFNGLLIGHTMODELXPROC __glewLightModelx;\r\nGLEW_FUN_EXPORT PFNGLLIGHTMODELXVPROC __glewLightModelxv;\r\nGLEW_FUN_EXPORT PFNGLLIGHTXPROC __glewLightx;\r\nGLEW_FUN_EXPORT PFNGLLIGHTXVPROC __glewLightxv;\r\nGLEW_FUN_EXPORT PFNGLLINEWIDTHXPROC __glewLineWidthx;\r\nGLEW_FUN_EXPORT PFNGLLOADMATRIXXPROC __glewLoadMatrixx;\r\nGLEW_FUN_EXPORT PFNGLMATERIALXPROC __glewMaterialx;\r\nGLEW_FUN_EXPORT PFNGLMATERIALXVPROC __glewMaterialxv;\r\nGLEW_FUN_EXPORT PFNGLMULTMATRIXXPROC __glewMultMatrixx;\r\nGLEW_FUN_EXPORT PFNGLMULTITEXCOORD4XPROC __glewMultiTexCoord4x;\r\nGLEW_FUN_EXPORT PFNGLNORMAL3XPROC __glewNormal3x;\r\nGLEW_FUN_EXPORT PFNGLORTHOFPROC __glewOrthof;\r\nGLEW_FUN_EXPORT PFNGLORTHOXPROC __glewOrthox;\r\nGLEW_FUN_EXPORT PFNGLPOINTSIZEXPROC __glewPointSizex;\r\nGLEW_FUN_EXPORT PFNGLPOLYGONOFFSETXPROC __glewPolygonOffsetx;\r\nGLEW_FUN_EXPORT PFNGLROTATEXPROC __glewRotatex;\r\nGLEW_FUN_EXPORT PFNGLSAMPLECOVERAGEXPROC __glewSampleCoveragex;\r\nGLEW_FUN_EXPORT PFNGLSCALEXPROC __glewScalex;\r\nGLEW_FUN_EXPORT PFNGLTEXENVXPROC __glewTexEnvx;\r\nGLEW_FUN_EXPORT PFNGLTEXENVXVPROC __glewTexEnvxv;\r\nGLEW_FUN_EXPORT PFNGLTEXPARAMETERXPROC __glewTexParameterx;\r\nGLEW_FUN_EXPORT PFNGLTRANSLATEXPROC __glewTranslatex;\r\n\r\nGLEW_FUN_EXPORT PFNGLCLIPPLANEFPROC __glewClipPlanef;\r\nGLEW_FUN_EXPORT PFNGLCLIPPLANEXPROC __glewClipPlanex;\r\nGLEW_FUN_EXPORT PFNGLGETCLIPPLANEFPROC __glewGetClipPlanef;\r\nGLEW_FUN_EXPORT PFNGLGETCLIPPLANEXPROC __glewGetClipPlanex;\r\nGLEW_FUN_EXPORT PFNGLGETFIXEDVPROC __glewGetFixedv;\r\nGLEW_FUN_EXPORT PFNGLGETLIGHTXVPROC __glewGetLightxv;\r\nGLEW_FUN_EXPORT PFNGLGETMATERIALXVPROC __glewGetMaterialxv;\r\nGLEW_FUN_EXPORT PFNGLGETTEXENVXVPROC __glewGetTexEnvxv;\r\nGLEW_FUN_EXPORT PFNGLGETTEXPARAMETERXVPROC __glewGetTexParameterxv;\r\nGLEW_FUN_EXPORT PFNGLPOINTPARAMETERXPROC __glewPointParameterx;\r\nGLEW_FUN_EXPORT PFNGLPOINTPARAMETERXVPROC __glewPointParameterxv;\r\nGLEW_FUN_EXPORT PFNGLPOINTSIZEPOINTEROESPROC __glewPointSizePointerOES;\r\nGLEW_FUN_EXPORT PFNGLTEXPARAMETERXVPROC __glewTexParameterxv;\r\n\r\nGLEW_FUN_EXPORT PFNGLERRORSTRINGREGALPROC __glewErrorStringREGAL;\r\n\r\nGLEW_FUN_EXPORT PFNGLGETEXTENSIONREGALPROC __glewGetExtensionREGAL;\r\nGLEW_FUN_EXPORT PFNGLISSUPPORTEDREGALPROC __glewIsSupportedREGAL;\r\n\r\nGLEW_FUN_EXPORT PFNGLLOGMESSAGECALLBACKREGALPROC __glewLogMessageCallbackREGAL;\r\n\r\nGLEW_FUN_EXPORT PFNGLGETPROCADDRESSREGALPROC __glewGetProcAddressREGAL;\r\n\r\nGLEW_FUN_EXPORT PFNGLDETAILTEXFUNCSGISPROC __glewDetailTexFuncSGIS;\r\nGLEW_FUN_EXPORT PFNGLGETDETAILTEXFUNCSGISPROC __glewGetDetailTexFuncSGIS;\r\n\r\nGLEW_FUN_EXPORT PFNGLFOGFUNCSGISPROC __glewFogFuncSGIS;\r\nGLEW_FUN_EXPORT PFNGLGETFOGFUNCSGISPROC __glewGetFogFuncSGIS;\r\n\r\nGLEW_FUN_EXPORT PFNGLSAMPLEMASKSGISPROC __glewSampleMaskSGIS;\r\nGLEW_FUN_EXPORT PFNGLSAMPLEPATTERNSGISPROC __glewSamplePatternSGIS;\r\n\r\nGLEW_FUN_EXPORT PFNGLGETSHARPENTEXFUNCSGISPROC __glewGetSharpenTexFuncSGIS;\r\nGLEW_FUN_EXPORT PFNGLSHARPENTEXFUNCSGISPROC __glewSharpenTexFuncSGIS;\r\n\r\nGLEW_FUN_EXPORT PFNGLTEXIMAGE4DSGISPROC __glewTexImage4DSGIS;\r\nGLEW_FUN_EXPORT PFNGLTEXSUBIMAGE4DSGISPROC __glewTexSubImage4DSGIS;\r\n\r\nGLEW_FUN_EXPORT PFNGLGETTEXFILTERFUNCSGISPROC __glewGetTexFilterFuncSGIS;\r\nGLEW_FUN_EXPORT PFNGLTEXFILTERFUNCSGISPROC __glewTexFilterFuncSGIS;\r\n\r\nGLEW_FUN_EXPORT PFNGLASYNCMARKERSGIXPROC __glewAsyncMarkerSGIX;\r\nGLEW_FUN_EXPORT PFNGLDELETEASYNCMARKERSSGIXPROC __glewDeleteAsyncMarkersSGIX;\r\nGLEW_FUN_EXPORT PFNGLFINISHASYNCSGIXPROC __glewFinishAsyncSGIX;\r\nGLEW_FUN_EXPORT PFNGLGENASYNCMARKERSSGIXPROC __glewGenAsyncMarkersSGIX;\r\nGLEW_FUN_EXPORT PFNGLISASYNCMARKERSGIXPROC __glewIsAsyncMarkerSGIX;\r\nGLEW_FUN_EXPORT PFNGLPOLLASYNCSGIXPROC __glewPollAsyncSGIX;\r\n\r\nGLEW_FUN_EXPORT PFNGLFLUSHRASTERSGIXPROC __glewFlushRasterSGIX;\r\n\r\nGLEW_FUN_EXPORT PFNGLTEXTUREFOGSGIXPROC __glewTextureFogSGIX;\r\n\r\nGLEW_FUN_EXPORT PFNGLFRAGMENTCOLORMATERIALSGIXPROC __glewFragmentColorMaterialSGIX;\r\nGLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTMODELFSGIXPROC __glewFragmentLightModelfSGIX;\r\nGLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTMODELFVSGIXPROC __glewFragmentLightModelfvSGIX;\r\nGLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTMODELISGIXPROC __glewFragmentLightModeliSGIX;\r\nGLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTMODELIVSGIXPROC __glewFragmentLightModelivSGIX;\r\nGLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTFSGIXPROC __glewFragmentLightfSGIX;\r\nGLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTFVSGIXPROC __glewFragmentLightfvSGIX;\r\nGLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTISGIXPROC __glewFragmentLightiSGIX;\r\nGLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTIVSGIXPROC __glewFragmentLightivSGIX;\r\nGLEW_FUN_EXPORT PFNGLFRAGMENTMATERIALFSGIXPROC __glewFragmentMaterialfSGIX;\r\nGLEW_FUN_EXPORT PFNGLFRAGMENTMATERIALFVSGIXPROC __glewFragmentMaterialfvSGIX;\r\nGLEW_FUN_EXPORT PFNGLFRAGMENTMATERIALISGIXPROC __glewFragmentMaterialiSGIX;\r\nGLEW_FUN_EXPORT PFNGLFRAGMENTMATERIALIVSGIXPROC __glewFragmentMaterialivSGIX;\r\nGLEW_FUN_EXPORT PFNGLGETFRAGMENTLIGHTFVSGIXPROC __glewGetFragmentLightfvSGIX;\r\nGLEW_FUN_EXPORT PFNGLGETFRAGMENTLIGHTIVSGIXPROC __glewGetFragmentLightivSGIX;\r\nGLEW_FUN_EXPORT PFNGLGETFRAGMENTMATERIALFVSGIXPROC __glewGetFragmentMaterialfvSGIX;\r\nGLEW_FUN_EXPORT PFNGLGETFRAGMENTMATERIALIVSGIXPROC __glewGetFragmentMaterialivSGIX;\r\n\r\nGLEW_FUN_EXPORT PFNGLFRAMEZOOMSGIXPROC __glewFrameZoomSGIX;\r\n\r\nGLEW_FUN_EXPORT PFNGLPIXELTEXGENSGIXPROC __glewPixelTexGenSGIX;\r\n\r\nGLEW_FUN_EXPORT PFNGLREFERENCEPLANESGIXPROC __glewReferencePlaneSGIX;\r\n\r\nGLEW_FUN_EXPORT PFNGLSPRITEPARAMETERFSGIXPROC __glewSpriteParameterfSGIX;\r\nGLEW_FUN_EXPORT PFNGLSPRITEPARAMETERFVSGIXPROC __glewSpriteParameterfvSGIX;\r\nGLEW_FUN_EXPORT PFNGLSPRITEPARAMETERISGIXPROC __glewSpriteParameteriSGIX;\r\nGLEW_FUN_EXPORT PFNGLSPRITEPARAMETERIVSGIXPROC __glewSpriteParameterivSGIX;\r\n\r\nGLEW_FUN_EXPORT PFNGLTAGSAMPLEBUFFERSGIXPROC __glewTagSampleBufferSGIX;\r\n\r\nGLEW_FUN_EXPORT PFNGLCOLORTABLEPARAMETERFVSGIPROC __glewColorTableParameterfvSGI;\r\nGLEW_FUN_EXPORT PFNGLCOLORTABLEPARAMETERIVSGIPROC __glewColorTableParameterivSGI;\r\nGLEW_FUN_EXPORT PFNGLCOLORTABLESGIPROC __glewColorTableSGI;\r\nGLEW_FUN_EXPORT PFNGLCOPYCOLORTABLESGIPROC __glewCopyColorTableSGI;\r\nGLEW_FUN_EXPORT PFNGLGETCOLORTABLEPARAMETERFVSGIPROC __glewGetColorTableParameterfvSGI;\r\nGLEW_FUN_EXPORT PFNGLGETCOLORTABLEPARAMETERIVSGIPROC __glewGetColorTableParameterivSGI;\r\nGLEW_FUN_EXPORT PFNGLGETCOLORTABLESGIPROC __glewGetColorTableSGI;\r\n\r\nGLEW_FUN_EXPORT PFNGLFINISHTEXTURESUNXPROC __glewFinishTextureSUNX;\r\n\r\nGLEW_FUN_EXPORT PFNGLGLOBALALPHAFACTORBSUNPROC __glewGlobalAlphaFactorbSUN;\r\nGLEW_FUN_EXPORT PFNGLGLOBALALPHAFACTORDSUNPROC __glewGlobalAlphaFactordSUN;\r\nGLEW_FUN_EXPORT PFNGLGLOBALALPHAFACTORFSUNPROC __glewGlobalAlphaFactorfSUN;\r\nGLEW_FUN_EXPORT PFNGLGLOBALALPHAFACTORISUNPROC __glewGlobalAlphaFactoriSUN;\r\nGLEW_FUN_EXPORT PFNGLGLOBALALPHAFACTORSSUNPROC __glewGlobalAlphaFactorsSUN;\r\nGLEW_FUN_EXPORT PFNGLGLOBALALPHAFACTORUBSUNPROC __glewGlobalAlphaFactorubSUN;\r\nGLEW_FUN_EXPORT PFNGLGLOBALALPHAFACTORUISUNPROC __glewGlobalAlphaFactoruiSUN;\r\nGLEW_FUN_EXPORT PFNGLGLOBALALPHAFACTORUSSUNPROC __glewGlobalAlphaFactorusSUN;\r\n\r\nGLEW_FUN_EXPORT PFNGLREADVIDEOPIXELSSUNPROC __glewReadVideoPixelsSUN;\r\n\r\nGLEW_FUN_EXPORT PFNGLREPLACEMENTCODEPOINTERSUNPROC __glewReplacementCodePointerSUN;\r\nGLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUBSUNPROC __glewReplacementCodeubSUN;\r\nGLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUBVSUNPROC __glewReplacementCodeubvSUN;\r\nGLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUISUNPROC __glewReplacementCodeuiSUN;\r\nGLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUIVSUNPROC __glewReplacementCodeuivSUN;\r\nGLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUSSUNPROC __glewReplacementCodeusSUN;\r\nGLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUSVSUNPROC __glewReplacementCodeusvSUN;\r\n\r\nGLEW_FUN_EXPORT PFNGLCOLOR3FVERTEX3FSUNPROC __glewColor3fVertex3fSUN;\r\nGLEW_FUN_EXPORT PFNGLCOLOR3FVERTEX3FVSUNPROC __glewColor3fVertex3fvSUN;\r\nGLEW_FUN_EXPORT PFNGLCOLOR4FNORMAL3FVERTEX3FSUNPROC __glewColor4fNormal3fVertex3fSUN;\r\nGLEW_FUN_EXPORT PFNGLCOLOR4FNORMAL3FVERTEX3FVSUNPROC __glewColor4fNormal3fVertex3fvSUN;\r\nGLEW_FUN_EXPORT PFNGLCOLOR4UBVERTEX2FSUNPROC __glewColor4ubVertex2fSUN;\r\nGLEW_FUN_EXPORT PFNGLCOLOR4UBVERTEX2FVSUNPROC __glewColor4ubVertex2fvSUN;\r\nGLEW_FUN_EXPORT PFNGLCOLOR4UBVERTEX3FSUNPROC __glewColor4ubVertex3fSUN;\r\nGLEW_FUN_EXPORT PFNGLCOLOR4UBVERTEX3FVSUNPROC __glewColor4ubVertex3fvSUN;\r\nGLEW_FUN_EXPORT PFNGLNORMAL3FVERTEX3FSUNPROC __glewNormal3fVertex3fSUN;\r\nGLEW_FUN_EXPORT PFNGLNORMAL3FVERTEX3FVSUNPROC __glewNormal3fVertex3fvSUN;\r\nGLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FSUNPROC __glewReplacementCodeuiColor3fVertex3fSUN;\r\nGLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FVSUNPROC __glewReplacementCodeuiColor3fVertex3fvSUN;\r\nGLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FSUNPROC __glewReplacementCodeuiColor4fNormal3fVertex3fSUN;\r\nGLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FVSUNPROC __glewReplacementCodeuiColor4fNormal3fVertex3fvSUN;\r\nGLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FSUNPROC __glewReplacementCodeuiColor4ubVertex3fSUN;\r\nGLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FVSUNPROC __glewReplacementCodeuiColor4ubVertex3fvSUN;\r\nGLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FSUNPROC __glewReplacementCodeuiNormal3fVertex3fSUN;\r\nGLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FVSUNPROC __glewReplacementCodeuiNormal3fVertex3fvSUN;\r\nGLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC __glewReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN;\r\nGLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC __glewReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN;\r\nGLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FSUNPROC __glewReplacementCodeuiTexCoord2fNormal3fVertex3fSUN;\r\nGLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FVSUNPROC __glewReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN;\r\nGLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FSUNPROC __glewReplacementCodeuiTexCoord2fVertex3fSUN;\r\nGLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FVSUNPROC __glewReplacementCodeuiTexCoord2fVertex3fvSUN;\r\nGLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUIVERTEX3FSUNPROC __glewReplacementCodeuiVertex3fSUN;\r\nGLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUIVERTEX3FVSUNPROC __glewReplacementCodeuiVertex3fvSUN;\r\nGLEW_FUN_EXPORT PFNGLTEXCOORD2FCOLOR3FVERTEX3FSUNPROC __glewTexCoord2fColor3fVertex3fSUN;\r\nGLEW_FUN_EXPORT PFNGLTEXCOORD2FCOLOR3FVERTEX3FVSUNPROC __glewTexCoord2fColor3fVertex3fvSUN;\r\nGLEW_FUN_EXPORT PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC __glewTexCoord2fColor4fNormal3fVertex3fSUN;\r\nGLEW_FUN_EXPORT PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC __glewTexCoord2fColor4fNormal3fVertex3fvSUN;\r\nGLEW_FUN_EXPORT PFNGLTEXCOORD2FCOLOR4UBVERTEX3FSUNPROC __glewTexCoord2fColor4ubVertex3fSUN;\r\nGLEW_FUN_EXPORT PFNGLTEXCOORD2FCOLOR4UBVERTEX3FVSUNPROC __glewTexCoord2fColor4ubVertex3fvSUN;\r\nGLEW_FUN_EXPORT PFNGLTEXCOORD2FNORMAL3FVERTEX3FSUNPROC __glewTexCoord2fNormal3fVertex3fSUN;\r\nGLEW_FUN_EXPORT PFNGLTEXCOORD2FNORMAL3FVERTEX3FVSUNPROC __glewTexCoord2fNormal3fVertex3fvSUN;\r\nGLEW_FUN_EXPORT PFNGLTEXCOORD2FVERTEX3FSUNPROC __glewTexCoord2fVertex3fSUN;\r\nGLEW_FUN_EXPORT PFNGLTEXCOORD2FVERTEX3FVSUNPROC __glewTexCoord2fVertex3fvSUN;\r\nGLEW_FUN_EXPORT PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FSUNPROC __glewTexCoord4fColor4fNormal3fVertex4fSUN;\r\nGLEW_FUN_EXPORT PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FVSUNPROC __glewTexCoord4fColor4fNormal3fVertex4fvSUN;\r\nGLEW_FUN_EXPORT PFNGLTEXCOORD4FVERTEX4FSUNPROC __glewTexCoord4fVertex4fSUN;\r\nGLEW_FUN_EXPORT PFNGLTEXCOORD4FVERTEX4FVSUNPROC __glewTexCoord4fVertex4fvSUN;\r\n\r\nGLEW_FUN_EXPORT PFNGLADDSWAPHINTRECTWINPROC __glewAddSwapHintRectWIN;\r\n\r\n#if defined(GLEW_MX) && !defined(_WIN32)\r\nstruct GLEWContextStruct\r\n{\r\n#endif /* GLEW_MX */\r\n\r\nGLEW_VAR_EXPORT GLboolean __GLEW_VERSION_1_1;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_VERSION_1_2;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_VERSION_1_2_1;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_VERSION_1_3;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_VERSION_1_4;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_VERSION_1_5;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_VERSION_2_0;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_VERSION_2_1;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_VERSION_3_0;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_VERSION_3_1;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_VERSION_3_2;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_VERSION_3_3;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_VERSION_4_0;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_VERSION_4_1;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_VERSION_4_2;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_VERSION_4_3;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_VERSION_4_4;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_VERSION_4_5;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_3DFX_multisample;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_3DFX_tbuffer;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_3DFX_texture_compression_FXT1;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_AMD_blend_minmax_factor;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_AMD_conservative_depth;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_AMD_debug_output;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_AMD_depth_clamp_separate;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_AMD_draw_buffers_blend;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_AMD_gcn_shader;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_AMD_gpu_shader_int64;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_AMD_interleaved_elements;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_AMD_multi_draw_indirect;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_AMD_name_gen_delete;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_AMD_occlusion_query_event;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_AMD_performance_monitor;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_AMD_pinned_memory;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_AMD_query_buffer_object;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_AMD_sample_positions;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_AMD_seamless_cubemap_per_texture;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_AMD_shader_atomic_counter_ops;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_AMD_shader_stencil_export;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_AMD_shader_stencil_value_export;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_AMD_shader_trinary_minmax;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_AMD_sparse_texture;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_AMD_stencil_operation_extended;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_AMD_texture_texture4;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_AMD_transform_feedback3_lines_triangles;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_AMD_transform_feedback4;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_AMD_vertex_shader_layer;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_AMD_vertex_shader_tessellator;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_AMD_vertex_shader_viewport_index;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ANGLE_depth_texture;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ANGLE_framebuffer_blit;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ANGLE_framebuffer_multisample;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ANGLE_instanced_arrays;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ANGLE_pack_reverse_row_order;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ANGLE_program_binary;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ANGLE_texture_compression_dxt1;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ANGLE_texture_compression_dxt3;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ANGLE_texture_compression_dxt5;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ANGLE_texture_usage;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ANGLE_timer_query;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ANGLE_translated_shader_source;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_APPLE_aux_depth_stencil;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_APPLE_client_storage;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_APPLE_element_array;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_APPLE_fence;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_APPLE_float_pixels;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_APPLE_flush_buffer_range;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_APPLE_object_purgeable;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_APPLE_pixel_buffer;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_APPLE_rgb_422;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_APPLE_row_bytes;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_APPLE_specular_vector;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_APPLE_texture_range;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_APPLE_transform_hint;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_APPLE_vertex_array_object;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_APPLE_vertex_array_range;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_APPLE_vertex_program_evaluators;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_APPLE_ycbcr_422;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_ES2_compatibility;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_ES3_1_compatibility;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_ES3_2_compatibility;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_ES3_compatibility;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_arrays_of_arrays;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_base_instance;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_bindless_texture;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_blend_func_extended;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_buffer_storage;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_cl_event;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_clear_buffer_object;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_clear_texture;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_clip_control;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_color_buffer_float;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_compatibility;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_compressed_texture_pixel_storage;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_compute_shader;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_compute_variable_group_size;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_conditional_render_inverted;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_conservative_depth;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_copy_buffer;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_copy_image;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_cull_distance;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_debug_output;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_depth_buffer_float;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_depth_clamp;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_depth_texture;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_derivative_control;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_direct_state_access;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_draw_buffers;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_draw_buffers_blend;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_draw_elements_base_vertex;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_draw_indirect;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_draw_instanced;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_enhanced_layouts;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_explicit_attrib_location;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_explicit_uniform_location;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_fragment_coord_conventions;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_fragment_layer_viewport;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_fragment_program;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_fragment_program_shadow;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_fragment_shader;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_fragment_shader_interlock;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_framebuffer_no_attachments;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_framebuffer_object;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_framebuffer_sRGB;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_geometry_shader4;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_get_program_binary;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_get_texture_sub_image;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_gpu_shader5;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_gpu_shader_fp64;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_gpu_shader_int64;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_half_float_pixel;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_half_float_vertex;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_imaging;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_indirect_parameters;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_instanced_arrays;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_internalformat_query;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_internalformat_query2;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_invalidate_subdata;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_map_buffer_alignment;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_map_buffer_range;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_matrix_palette;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_multi_bind;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_multi_draw_indirect;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_multisample;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_multitexture;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_occlusion_query;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_occlusion_query2;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_parallel_shader_compile;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_pipeline_statistics_query;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_pixel_buffer_object;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_point_parameters;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_point_sprite;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_post_depth_coverage;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_program_interface_query;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_provoking_vertex;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_query_buffer_object;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_robust_buffer_access_behavior;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_robustness;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_robustness_application_isolation;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_robustness_share_group_isolation;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_sample_locations;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_sample_shading;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_sampler_objects;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_seamless_cube_map;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_seamless_cubemap_per_texture;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_separate_shader_objects;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_shader_atomic_counter_ops;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_shader_atomic_counters;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_shader_ballot;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_shader_bit_encoding;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_shader_clock;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_shader_draw_parameters;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_shader_group_vote;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_shader_image_load_store;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_shader_image_size;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_shader_objects;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_shader_precision;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_shader_stencil_export;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_shader_storage_buffer_object;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_shader_subroutine;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_shader_texture_image_samples;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_shader_texture_lod;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_shader_viewport_layer_array;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_shading_language_100;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_shading_language_420pack;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_shading_language_include;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_shading_language_packing;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_shadow;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_shadow_ambient;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_sparse_buffer;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_sparse_texture;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_sparse_texture2;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_sparse_texture_clamp;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_stencil_texturing;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_sync;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_tessellation_shader;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_barrier;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_border_clamp;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_buffer_object;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_buffer_object_rgb32;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_buffer_range;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_compression;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_compression_bptc;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_compression_rgtc;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_cube_map;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_cube_map_array;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_env_add;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_env_combine;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_env_crossbar;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_env_dot3;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_filter_minmax;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_float;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_gather;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_mirror_clamp_to_edge;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_mirrored_repeat;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_multisample;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_non_power_of_two;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_query_levels;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_query_lod;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_rectangle;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_rg;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_rgb10_a2ui;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_stencil8;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_storage;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_storage_multisample;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_swizzle;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_view;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_timer_query;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_transform_feedback2;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_transform_feedback3;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_transform_feedback_instanced;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_transform_feedback_overflow_query;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_transpose_matrix;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_uniform_buffer_object;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_vertex_array_bgra;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_vertex_array_object;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_vertex_attrib_64bit;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_vertex_attrib_binding;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_vertex_blend;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_vertex_buffer_object;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_vertex_program;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_vertex_shader;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_vertex_type_10f_11f_11f_rev;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_vertex_type_2_10_10_10_rev;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_viewport_array;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ARB_window_pos;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ATIX_point_sprites;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ATIX_texture_env_combine3;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ATIX_texture_env_route;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ATIX_vertex_shader_output_point_size;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ATI_draw_buffers;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ATI_element_array;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ATI_envmap_bumpmap;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ATI_fragment_shader;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ATI_map_object_buffer;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ATI_meminfo;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ATI_pn_triangles;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ATI_separate_stencil;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ATI_shader_texture_lod;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ATI_text_fragment_shader;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ATI_texture_compression_3dc;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ATI_texture_env_combine3;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ATI_texture_float;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ATI_texture_mirror_once;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ATI_vertex_array_object;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ATI_vertex_attrib_array_object;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_ATI_vertex_streams;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_422_pixels;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_Cg_shader;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_abgr;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_bgra;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_bindable_uniform;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_blend_color;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_blend_equation_separate;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_blend_func_separate;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_blend_logic_op;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_blend_minmax;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_blend_subtract;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_clip_volume_hint;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_cmyka;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_color_subtable;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_compiled_vertex_array;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_convolution;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_coordinate_frame;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_copy_texture;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_cull_vertex;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_debug_label;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_debug_marker;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_depth_bounds_test;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_direct_state_access;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_draw_buffers2;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_draw_instanced;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_draw_range_elements;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_fog_coord;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_fragment_lighting;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_framebuffer_blit;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_framebuffer_multisample;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_framebuffer_multisample_blit_scaled;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_framebuffer_object;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_framebuffer_sRGB;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_geometry_shader4;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_gpu_program_parameters;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_gpu_shader4;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_histogram;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_index_array_formats;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_index_func;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_index_material;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_index_texture;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_light_texture;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_misc_attribute;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_multi_draw_arrays;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_multisample;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_packed_depth_stencil;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_packed_float;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_packed_pixels;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_paletted_texture;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_pixel_buffer_object;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_pixel_transform;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_pixel_transform_color_table;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_point_parameters;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_polygon_offset;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_polygon_offset_clamp;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_post_depth_coverage;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_provoking_vertex;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_raster_multisample;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_rescale_normal;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_scene_marker;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_secondary_color;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_separate_shader_objects;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_separate_specular_color;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_shader_image_load_formatted;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_shader_image_load_store;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_shader_integer_mix;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_shadow_funcs;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_shared_texture_palette;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_sparse_texture2;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_stencil_clear_tag;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_stencil_two_side;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_stencil_wrap;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_subtexture;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture3D;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_array;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_buffer_object;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_compression_dxt1;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_compression_latc;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_compression_rgtc;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_compression_s3tc;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_cube_map;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_edge_clamp;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_env;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_env_add;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_env_combine;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_env_dot3;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_filter_anisotropic;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_filter_minmax;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_integer;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_lod_bias;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_mirror_clamp;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_object;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_perturb_normal;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_rectangle;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_sRGB;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_sRGB_decode;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_shared_exponent;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_snorm;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_swizzle;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_timer_query;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_transform_feedback;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_vertex_array;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_vertex_array_bgra;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_vertex_attrib_64bit;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_vertex_shader;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_vertex_weighting;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_EXT_x11_sync_object;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_GREMEDY_frame_terminator;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_GREMEDY_string_marker;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_HP_convolution_border_modes;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_HP_image_transform;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_HP_occlusion_test;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_HP_texture_lighting;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_IBM_cull_vertex;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_IBM_multimode_draw_arrays;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_IBM_rasterpos_clip;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_IBM_static_data;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_IBM_texture_mirrored_repeat;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_IBM_vertex_array_lists;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_INGR_color_clamp;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_INGR_interlace_read;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_INTEL_fragment_shader_ordering;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_INTEL_framebuffer_CMAA;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_INTEL_map_texture;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_INTEL_parallel_arrays;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_INTEL_performance_query;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_INTEL_texture_scissor;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_KHR_blend_equation_advanced;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_KHR_blend_equation_advanced_coherent;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_KHR_context_flush_control;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_KHR_debug;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_KHR_no_error;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_KHR_robust_buffer_access_behavior;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_KHR_robustness;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_KHR_texture_compression_astc_hdr;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_KHR_texture_compression_astc_ldr;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_KTX_buffer_region;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_MESAX_texture_stack;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_MESA_pack_invert;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_MESA_resize_buffers;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_MESA_window_pos;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_MESA_ycbcr_texture;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_NVX_conditional_render;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_NVX_gpu_memory_info;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_bindless_multi_draw_indirect;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_bindless_multi_draw_indirect_count;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_bindless_texture;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_blend_equation_advanced;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_blend_equation_advanced_coherent;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_blend_square;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_compute_program5;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_conditional_render;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_conservative_raster;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_conservative_raster_dilate;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_copy_depth_to_color;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_copy_image;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_deep_texture3D;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_depth_buffer_float;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_depth_clamp;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_depth_range_unclamped;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_draw_texture;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_evaluators;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_explicit_multisample;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_fence;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_fill_rectangle;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_float_buffer;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_fog_distance;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_fragment_coverage_to_color;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_fragment_program;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_fragment_program2;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_fragment_program4;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_fragment_program_option;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_fragment_shader_interlock;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_framebuffer_mixed_samples;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_framebuffer_multisample_coverage;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_geometry_program4;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_geometry_shader4;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_geometry_shader_passthrough;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_gpu_program4;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_gpu_program5;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_gpu_program5_mem_extended;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_gpu_program_fp64;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_gpu_shader5;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_half_float;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_internalformat_sample_query;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_light_max_exponent;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_multisample_coverage;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_multisample_filter_hint;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_occlusion_query;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_packed_depth_stencil;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_parameter_buffer_object;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_parameter_buffer_object2;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_path_rendering;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_path_rendering_shared_edge;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_pixel_data_range;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_point_sprite;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_present_video;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_primitive_restart;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_register_combiners;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_register_combiners2;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_sample_locations;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_sample_mask_override_coverage;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_shader_atomic_counters;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_shader_atomic_float;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_shader_atomic_fp16_vector;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_shader_atomic_int64;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_shader_buffer_load;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_shader_storage_buffer_object;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_shader_thread_group;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_shader_thread_shuffle;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_tessellation_program5;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_texgen_emboss;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_texgen_reflection;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_texture_barrier;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_texture_compression_vtc;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_texture_env_combine4;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_texture_expand_normal;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_texture_multisample;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_texture_rectangle;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_texture_shader;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_texture_shader2;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_texture_shader3;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_transform_feedback;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_transform_feedback2;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_uniform_buffer_unified_memory;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_vdpau_interop;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_array_range;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_array_range2;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_attrib_integer_64bit;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_buffer_unified_memory;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_program;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_program1_1;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_program2;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_program2_option;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_program3;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_program4;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_video_capture;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_NV_viewport_array2;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_OES_byte_coordinates;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_OES_compressed_paletted_texture;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_OES_read_format;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_OES_single_precision;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_OML_interlace;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_OML_resample;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_OML_subsample;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_OVR_multiview;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_OVR_multiview2;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_PGI_misc_hints;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_PGI_vertex_hints;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_REGAL_ES1_0_compatibility;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_REGAL_ES1_1_compatibility;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_REGAL_enable;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_REGAL_error_string;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_REGAL_extension_query;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_REGAL_log;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_REGAL_proc_address;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_REND_screen_coordinates;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_S3_s3tc;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_SGIS_color_range;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_SGIS_detail_texture;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_SGIS_fog_function;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_SGIS_generate_mipmap;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_SGIS_multisample;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_SGIS_pixel_texture;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_SGIS_point_line_texgen;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_SGIS_sharpen_texture;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_SGIS_texture4D;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_SGIS_texture_border_clamp;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_SGIS_texture_edge_clamp;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_SGIS_texture_filter4;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_SGIS_texture_lod;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_SGIS_texture_select;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_SGIX_async;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_SGIX_async_histogram;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_SGIX_async_pixel;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_SGIX_blend_alpha_minmax;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_SGIX_clipmap;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_SGIX_convolution_accuracy;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_SGIX_depth_texture;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_SGIX_flush_raster;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_SGIX_fog_offset;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_SGIX_fog_texture;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_SGIX_fragment_specular_lighting;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_SGIX_framezoom;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_SGIX_interlace;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_SGIX_ir_instrument1;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_SGIX_list_priority;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_SGIX_pixel_texture;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_SGIX_pixel_texture_bits;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_SGIX_reference_plane;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_SGIX_resample;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_SGIX_shadow;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_SGIX_shadow_ambient;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_SGIX_sprite;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_SGIX_tag_sample_buffer;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_SGIX_texture_add_env;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_SGIX_texture_coordinate_clamp;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_SGIX_texture_lod_bias;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_SGIX_texture_multi_buffer;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_SGIX_texture_range;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_SGIX_texture_scale_bias;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_SGIX_vertex_preclip;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_SGIX_vertex_preclip_hint;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_SGIX_ycrcb;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_SGI_color_matrix;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_SGI_color_table;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_SGI_texture_color_table;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_SUNX_constant_data;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_SUN_convolution_border_modes;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_SUN_global_alpha;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_SUN_mesh_array;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_SUN_read_video_pixels;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_SUN_slice_accum;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_SUN_triangle_list;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_SUN_vertex;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_WIN_phong_shading;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_WIN_specular_fog;\r\nGLEW_VAR_EXPORT GLboolean __GLEW_WIN_swap_hint;\r\n\r\n#ifdef GLEW_MX\r\n}; /* GLEWContextStruct */\r\n#endif /* GLEW_MX */\r\n\r\n/* ------------------------------------------------------------------------- */\r\n\r\n/* error codes */\r\n#define GLEW_OK 0\r\n#define GLEW_NO_ERROR 0\r\n#define GLEW_ERROR_NO_GL_VERSION 1  /* missing GL version */\r\n#define GLEW_ERROR_GL_VERSION_10_ONLY 2  /* Need at least OpenGL 1.1 */\r\n#define GLEW_ERROR_GLX_VERSION_11_ONLY 3  /* Need at least GLX 1.2 */\r\n\r\n/* string codes */\r\n#define GLEW_VERSION 1\r\n#define GLEW_VERSION_MAJOR 2\r\n#define GLEW_VERSION_MINOR 3\r\n#define GLEW_VERSION_MICRO 4\r\n\r\n/* ------------------------------------------------------------------------- */\r\n\r\n/* GLEW version info */\r\n\r\n/*\r\nVERSION 1.13.0\r\nVERSION_MAJOR 1\r\nVERSION_MINOR 13\r\nVERSION_MICRO 0\r\n*/\r\n\r\n/* API */\r\n#ifdef GLEW_MX\r\n\r\ntypedef struct GLEWContextStruct GLEWContext;\r\nGLEWAPI GLenum GLEWAPIENTRY glewContextInit (GLEWContext *ctx);\r\nGLEWAPI GLboolean GLEWAPIENTRY glewContextIsSupported (const GLEWContext *ctx, const char *name);\r\n\r\n#define glewInit() glewContextInit(glewGetContext())\r\n#define glewIsSupported(x) glewContextIsSupported(glewGetContext(), x)\r\n#define glewIsExtensionSupported(x) glewIsSupported(x)\r\n\r\n#define GLEW_GET_VAR(x) (*(const GLboolean*)&(glewGetContext()->x))\r\n#ifdef _WIN32\r\n#  define GLEW_GET_FUN(x) glewGetContext()->x\r\n#else\r\n#  define GLEW_GET_FUN(x) x\r\n#endif\r\n\r\n#else /* GLEW_MX */\r\n\r\nGLEWAPI GLenum GLEWAPIENTRY glewInit (void);\r\nGLEWAPI GLboolean GLEWAPIENTRY glewIsSupported (const char *name);\r\n#define glewIsExtensionSupported(x) glewIsSupported(x)\r\n\r\n#define GLEW_GET_VAR(x) (*(const GLboolean*)&x)\r\n#define GLEW_GET_FUN(x) x\r\n\r\n#endif /* GLEW_MX */\r\n\r\nGLEWAPI GLboolean glewExperimental;\r\nGLEWAPI GLboolean GLEWAPIENTRY glewGetExtension (const char *name);\r\nGLEWAPI const GLubyte * GLEWAPIENTRY glewGetErrorString (GLenum error);\r\nGLEWAPI const GLubyte * GLEWAPIENTRY glewGetString (GLenum name);\r\n\r\n#ifdef __cplusplus\r\n}\r\n#endif\r\n\r\n#ifdef GLEW_APIENTRY_DEFINED\r\n#undef GLEW_APIENTRY_DEFINED\r\n#undef APIENTRY\r\n#endif\r\n\r\n#ifdef GLEW_CALLBACK_DEFINED\r\n#undef GLEW_CALLBACK_DEFINED\r\n#undef CALLBACK\r\n#endif\r\n\r\n#ifdef GLEW_WINGDIAPI_DEFINED\r\n#undef GLEW_WINGDIAPI_DEFINED\r\n#undef WINGDIAPI\r\n#endif\r\n\r\n#undef GLAPI\r\n/* #undef GLEWAPI */\r\n\r\n#endif /* __glew_h__ */\r\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/GL/glxew.h",
    "content": "/*\r\n** The OpenGL Extension Wrangler Library\r\n** Copyright (C) 2008-2015, Nigel Stewart <nigels[]users sourceforge net>\r\n** Copyright (C) 2002-2008, Milan Ikits <milan ikits[]ieee org>\r\n** Copyright (C) 2002-2008, Marcelo E. Magallon <mmagallo[]debian org>\r\n** Copyright (C) 2002, Lev Povalahev\r\n** All rights reserved.\r\n** \r\n** Redistribution and use in source and binary forms, with or without \r\n** modification, are permitted provided that the following conditions are met:\r\n** \r\n** * Redistributions of source code must retain the above copyright notice, \r\n**   this list of conditions and the following disclaimer.\r\n** * Redistributions in binary form must reproduce the above copyright notice, \r\n**   this list of conditions and the following disclaimer in the documentation \r\n**   and/or other materials provided with the distribution.\r\n** * The name of the author may be used to endorse or promote products \r\n**   derived from this software without specific prior written permission.\r\n**\r\n** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" \r\n** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE \r\n** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r\n** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE \r\n** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR \r\n** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF \r\n** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\r\n** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\r\n** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\r\n** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF\r\n** THE POSSIBILITY OF SUCH DAMAGE.\r\n*/\r\n\r\n/*\r\n * Mesa 3-D graphics library\r\n * Version:  7.0\r\n *\r\n * Copyright (C) 1999-2007  Brian Paul   All Rights Reserved.\r\n *\r\n * Permission is hereby granted, free of charge, to any person obtaining a\r\n * copy of this software and associated documentation files (the \"Software\"),\r\n * to deal in the Software without restriction, including without limitation\r\n * the rights to use, copy, modify, merge, publish, distribute, sublicense,\r\n * and/or sell copies of the Software, and to permit persons to whom the\r\n * Software is furnished to do so, subject to the following conditions:\r\n *\r\n * The above copyright notice and this permission notice shall be included\r\n * in all copies or substantial portions of the Software.\r\n *\r\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\r\n * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL\r\n * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN\r\n * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r\n * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r\n */\r\n\r\n/*\r\n** Copyright (c) 2007 The Khronos Group Inc.\r\n** \r\n** Permission is hereby granted, free of charge, to any person obtaining a\r\n** copy of this software and/or associated documentation files (the\r\n** \"Materials\"), to deal in the Materials without restriction, including\r\n** without limitation the rights to use, copy, modify, merge, publish,\r\n** distribute, sublicense, and/or sell copies of the Materials, and to\r\n** permit persons to whom the Materials are furnished to do so, subject to\r\n** the following conditions:\r\n** \r\n** The above copyright notice and this permission notice shall be included\r\n** in all copies or substantial portions of the Materials.\r\n** \r\n** THE MATERIALS ARE PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\r\n** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r\n** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\r\n** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\r\n** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\r\n** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\r\n** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.\r\n*/\r\n\r\n#ifndef __glxew_h__\r\n#define __glxew_h__\r\n#define __GLXEW_H__\r\n\r\n#ifdef __glxext_h_\r\n#error glxext.h included before glxew.h\r\n#endif\r\n\r\n#if defined(GLX_H) || defined(__GLX_glx_h__) || defined(__glx_h__)\r\n#error glx.h included before glxew.h\r\n#endif\r\n\r\n#define __glxext_h_\r\n\r\n#define GLX_H\r\n#define __GLX_glx_h__\r\n#define __glx_h__\r\n\r\n#include <X11/Xlib.h>\r\n#include <X11/Xutil.h>\r\n#include <X11/Xmd.h>\r\n#include <GL/glew.h>\r\n\r\n#ifdef __cplusplus\r\nextern \"C\" {\r\n#endif\r\n\r\n/* ---------------------------- GLX_VERSION_1_0 --------------------------- */\r\n\r\n#ifndef GLX_VERSION_1_0\r\n#define GLX_VERSION_1_0 1\r\n\r\n#define GLX_USE_GL 1\r\n#define GLX_BUFFER_SIZE 2\r\n#define GLX_LEVEL 3\r\n#define GLX_RGBA 4\r\n#define GLX_DOUBLEBUFFER 5\r\n#define GLX_STEREO 6\r\n#define GLX_AUX_BUFFERS 7\r\n#define GLX_RED_SIZE 8\r\n#define GLX_GREEN_SIZE 9\r\n#define GLX_BLUE_SIZE 10\r\n#define GLX_ALPHA_SIZE 11\r\n#define GLX_DEPTH_SIZE 12\r\n#define GLX_STENCIL_SIZE 13\r\n#define GLX_ACCUM_RED_SIZE 14\r\n#define GLX_ACCUM_GREEN_SIZE 15\r\n#define GLX_ACCUM_BLUE_SIZE 16\r\n#define GLX_ACCUM_ALPHA_SIZE 17\r\n#define GLX_BAD_SCREEN 1\r\n#define GLX_BAD_ATTRIBUTE 2\r\n#define GLX_NO_EXTENSION 3\r\n#define GLX_BAD_VISUAL 4\r\n#define GLX_BAD_CONTEXT 5\r\n#define GLX_BAD_VALUE 6\r\n#define GLX_BAD_ENUM 7\r\n\r\ntypedef XID GLXDrawable;\r\ntypedef XID GLXPixmap;\r\n#ifdef __sun\r\ntypedef struct __glXContextRec *GLXContext;\r\n#else\r\ntypedef struct __GLXcontextRec *GLXContext;\r\n#endif\r\n\r\ntypedef unsigned int GLXVideoDeviceNV; \r\n\r\nextern Bool glXQueryExtension (Display *dpy, int *errorBase, int *eventBase);\r\nextern Bool glXQueryVersion (Display *dpy, int *major, int *minor);\r\nextern int glXGetConfig (Display *dpy, XVisualInfo *vis, int attrib, int *value);\r\nextern XVisualInfo* glXChooseVisual (Display *dpy, int screen, int *attribList);\r\nextern GLXPixmap glXCreateGLXPixmap (Display *dpy, XVisualInfo *vis, Pixmap pixmap);\r\nextern void glXDestroyGLXPixmap (Display *dpy, GLXPixmap pix);\r\nextern GLXContext glXCreateContext (Display *dpy, XVisualInfo *vis, GLXContext shareList, Bool direct);\r\nextern void glXDestroyContext (Display *dpy, GLXContext ctx);\r\nextern Bool glXIsDirect (Display *dpy, GLXContext ctx);\r\nextern void glXCopyContext (Display *dpy, GLXContext src, GLXContext dst, GLulong mask);\r\nextern Bool glXMakeCurrent (Display *dpy, GLXDrawable drawable, GLXContext ctx);\r\nextern GLXContext glXGetCurrentContext (void);\r\nextern GLXDrawable glXGetCurrentDrawable (void);\r\nextern void glXWaitGL (void);\r\nextern void glXWaitX (void);\r\nextern void glXSwapBuffers (Display *dpy, GLXDrawable drawable);\r\nextern void glXUseXFont (Font font, int first, int count, int listBase);\r\n\r\n#define GLXEW_VERSION_1_0 GLXEW_GET_VAR(__GLXEW_VERSION_1_0)\r\n\r\n#endif /* GLX_VERSION_1_0 */\r\n\r\n/* ---------------------------- GLX_VERSION_1_1 --------------------------- */\r\n\r\n#ifndef GLX_VERSION_1_1\r\n#define GLX_VERSION_1_1\r\n\r\n#define GLX_VENDOR 0x1\r\n#define GLX_VERSION 0x2\r\n#define GLX_EXTENSIONS 0x3\r\n\r\nextern const char* glXQueryExtensionsString (Display *dpy, int screen);\r\nextern const char* glXGetClientString (Display *dpy, int name);\r\nextern const char* glXQueryServerString (Display *dpy, int screen, int name);\r\n\r\n#define GLXEW_VERSION_1_1 GLXEW_GET_VAR(__GLXEW_VERSION_1_1)\r\n\r\n#endif /* GLX_VERSION_1_1 */\r\n\r\n/* ---------------------------- GLX_VERSION_1_2 ---------------------------- */\r\n\r\n#ifndef GLX_VERSION_1_2\r\n#define GLX_VERSION_1_2 1\r\n\r\ntypedef Display* ( * PFNGLXGETCURRENTDISPLAYPROC) (void);\r\n\r\n#define glXGetCurrentDisplay GLXEW_GET_FUN(__glewXGetCurrentDisplay)\r\n\r\n#define GLXEW_VERSION_1_2 GLXEW_GET_VAR(__GLXEW_VERSION_1_2)\r\n\r\n#endif /* GLX_VERSION_1_2 */\r\n\r\n/* ---------------------------- GLX_VERSION_1_3 ---------------------------- */\r\n\r\n#ifndef GLX_VERSION_1_3\r\n#define GLX_VERSION_1_3 1\r\n\r\n#define GLX_FRONT_LEFT_BUFFER_BIT 0x00000001\r\n#define GLX_RGBA_BIT 0x00000001\r\n#define GLX_WINDOW_BIT 0x00000001\r\n#define GLX_COLOR_INDEX_BIT 0x00000002\r\n#define GLX_FRONT_RIGHT_BUFFER_BIT 0x00000002\r\n#define GLX_PIXMAP_BIT 0x00000002\r\n#define GLX_BACK_LEFT_BUFFER_BIT 0x00000004\r\n#define GLX_PBUFFER_BIT 0x00000004\r\n#define GLX_BACK_RIGHT_BUFFER_BIT 0x00000008\r\n#define GLX_AUX_BUFFERS_BIT 0x00000010\r\n#define GLX_CONFIG_CAVEAT 0x20\r\n#define GLX_DEPTH_BUFFER_BIT 0x00000020\r\n#define GLX_X_VISUAL_TYPE 0x22\r\n#define GLX_TRANSPARENT_TYPE 0x23\r\n#define GLX_TRANSPARENT_INDEX_VALUE 0x24\r\n#define GLX_TRANSPARENT_RED_VALUE 0x25\r\n#define GLX_TRANSPARENT_GREEN_VALUE 0x26\r\n#define GLX_TRANSPARENT_BLUE_VALUE 0x27\r\n#define GLX_TRANSPARENT_ALPHA_VALUE 0x28\r\n#define GLX_STENCIL_BUFFER_BIT 0x00000040\r\n#define GLX_ACCUM_BUFFER_BIT 0x00000080\r\n#define GLX_NONE 0x8000\r\n#define GLX_SLOW_CONFIG 0x8001\r\n#define GLX_TRUE_COLOR 0x8002\r\n#define GLX_DIRECT_COLOR 0x8003\r\n#define GLX_PSEUDO_COLOR 0x8004\r\n#define GLX_STATIC_COLOR 0x8005\r\n#define GLX_GRAY_SCALE 0x8006\r\n#define GLX_STATIC_GRAY 0x8007\r\n#define GLX_TRANSPARENT_RGB 0x8008\r\n#define GLX_TRANSPARENT_INDEX 0x8009\r\n#define GLX_VISUAL_ID 0x800B\r\n#define GLX_SCREEN 0x800C\r\n#define GLX_NON_CONFORMANT_CONFIG 0x800D\r\n#define GLX_DRAWABLE_TYPE 0x8010\r\n#define GLX_RENDER_TYPE 0x8011\r\n#define GLX_X_RENDERABLE 0x8012\r\n#define GLX_FBCONFIG_ID 0x8013\r\n#define GLX_RGBA_TYPE 0x8014\r\n#define GLX_COLOR_INDEX_TYPE 0x8015\r\n#define GLX_MAX_PBUFFER_WIDTH 0x8016\r\n#define GLX_MAX_PBUFFER_HEIGHT 0x8017\r\n#define GLX_MAX_PBUFFER_PIXELS 0x8018\r\n#define GLX_PRESERVED_CONTENTS 0x801B\r\n#define GLX_LARGEST_PBUFFER 0x801C\r\n#define GLX_WIDTH 0x801D\r\n#define GLX_HEIGHT 0x801E\r\n#define GLX_EVENT_MASK 0x801F\r\n#define GLX_DAMAGED 0x8020\r\n#define GLX_SAVED 0x8021\r\n#define GLX_WINDOW 0x8022\r\n#define GLX_PBUFFER 0x8023\r\n#define GLX_PBUFFER_HEIGHT 0x8040\r\n#define GLX_PBUFFER_WIDTH 0x8041\r\n#define GLX_PBUFFER_CLOBBER_MASK 0x08000000\r\n#define GLX_DONT_CARE 0xFFFFFFFF\r\n\r\ntypedef XID GLXFBConfigID;\r\ntypedef XID GLXPbuffer;\r\ntypedef XID GLXWindow;\r\ntypedef struct __GLXFBConfigRec *GLXFBConfig;\r\n\r\ntypedef struct {\r\n  int event_type; \r\n  int draw_type; \r\n  unsigned long serial; \r\n  Bool send_event; \r\n  Display *display; \r\n  GLXDrawable drawable; \r\n  unsigned int buffer_mask; \r\n  unsigned int aux_buffer; \r\n  int x, y; \r\n  int width, height; \r\n  int count; \r\n} GLXPbufferClobberEvent;\r\ntypedef union __GLXEvent {\r\n  GLXPbufferClobberEvent glxpbufferclobber; \r\n  long pad[24]; \r\n} GLXEvent;\r\n\r\ntypedef GLXFBConfig* ( * PFNGLXCHOOSEFBCONFIGPROC) (Display *dpy, int screen, const int *attrib_list, int *nelements);\r\ntypedef GLXContext ( * PFNGLXCREATENEWCONTEXTPROC) (Display *dpy, GLXFBConfig config, int render_type, GLXContext share_list, Bool direct);\r\ntypedef GLXPbuffer ( * PFNGLXCREATEPBUFFERPROC) (Display *dpy, GLXFBConfig config, const int *attrib_list);\r\ntypedef GLXPixmap ( * PFNGLXCREATEPIXMAPPROC) (Display *dpy, GLXFBConfig config, Pixmap pixmap, const int *attrib_list);\r\ntypedef GLXWindow ( * PFNGLXCREATEWINDOWPROC) (Display *dpy, GLXFBConfig config, Window win, const int *attrib_list);\r\ntypedef void ( * PFNGLXDESTROYPBUFFERPROC) (Display *dpy, GLXPbuffer pbuf);\r\ntypedef void ( * PFNGLXDESTROYPIXMAPPROC) (Display *dpy, GLXPixmap pixmap);\r\ntypedef void ( * PFNGLXDESTROYWINDOWPROC) (Display *dpy, GLXWindow win);\r\ntypedef GLXDrawable ( * PFNGLXGETCURRENTREADDRAWABLEPROC) (void);\r\ntypedef int ( * PFNGLXGETFBCONFIGATTRIBPROC) (Display *dpy, GLXFBConfig config, int attribute, int *value);\r\ntypedef GLXFBConfig* ( * PFNGLXGETFBCONFIGSPROC) (Display *dpy, int screen, int *nelements);\r\ntypedef void ( * PFNGLXGETSELECTEDEVENTPROC) (Display *dpy, GLXDrawable draw, unsigned long *event_mask);\r\ntypedef XVisualInfo* ( * PFNGLXGETVISUALFROMFBCONFIGPROC) (Display *dpy, GLXFBConfig config);\r\ntypedef Bool ( * PFNGLXMAKECONTEXTCURRENTPROC) (Display *display, GLXDrawable draw, GLXDrawable read, GLXContext ctx);\r\ntypedef int ( * PFNGLXQUERYCONTEXTPROC) (Display *dpy, GLXContext ctx, int attribute, int *value);\r\ntypedef void ( * PFNGLXQUERYDRAWABLEPROC) (Display *dpy, GLXDrawable draw, int attribute, unsigned int *value);\r\ntypedef void ( * PFNGLXSELECTEVENTPROC) (Display *dpy, GLXDrawable draw, unsigned long event_mask);\r\n\r\n#define glXChooseFBConfig GLXEW_GET_FUN(__glewXChooseFBConfig)\r\n#define glXCreateNewContext GLXEW_GET_FUN(__glewXCreateNewContext)\r\n#define glXCreatePbuffer GLXEW_GET_FUN(__glewXCreatePbuffer)\r\n#define glXCreatePixmap GLXEW_GET_FUN(__glewXCreatePixmap)\r\n#define glXCreateWindow GLXEW_GET_FUN(__glewXCreateWindow)\r\n#define glXDestroyPbuffer GLXEW_GET_FUN(__glewXDestroyPbuffer)\r\n#define glXDestroyPixmap GLXEW_GET_FUN(__glewXDestroyPixmap)\r\n#define glXDestroyWindow GLXEW_GET_FUN(__glewXDestroyWindow)\r\n#define glXGetCurrentReadDrawable GLXEW_GET_FUN(__glewXGetCurrentReadDrawable)\r\n#define glXGetFBConfigAttrib GLXEW_GET_FUN(__glewXGetFBConfigAttrib)\r\n#define glXGetFBConfigs GLXEW_GET_FUN(__glewXGetFBConfigs)\r\n#define glXGetSelectedEvent GLXEW_GET_FUN(__glewXGetSelectedEvent)\r\n#define glXGetVisualFromFBConfig GLXEW_GET_FUN(__glewXGetVisualFromFBConfig)\r\n#define glXMakeContextCurrent GLXEW_GET_FUN(__glewXMakeContextCurrent)\r\n#define glXQueryContext GLXEW_GET_FUN(__glewXQueryContext)\r\n#define glXQueryDrawable GLXEW_GET_FUN(__glewXQueryDrawable)\r\n#define glXSelectEvent GLXEW_GET_FUN(__glewXSelectEvent)\r\n\r\n#define GLXEW_VERSION_1_3 GLXEW_GET_VAR(__GLXEW_VERSION_1_3)\r\n\r\n#endif /* GLX_VERSION_1_3 */\r\n\r\n/* ---------------------------- GLX_VERSION_1_4 ---------------------------- */\r\n\r\n#ifndef GLX_VERSION_1_4\r\n#define GLX_VERSION_1_4 1\r\n\r\n#define GLX_SAMPLE_BUFFERS 100000\r\n#define GLX_SAMPLES 100001\r\n\r\nextern void ( * glXGetProcAddress (const GLubyte *procName)) (void);\r\n\r\n#define GLXEW_VERSION_1_4 GLXEW_GET_VAR(__GLXEW_VERSION_1_4)\r\n\r\n#endif /* GLX_VERSION_1_4 */\r\n\r\n/* -------------------------- GLX_3DFX_multisample ------------------------- */\r\n\r\n#ifndef GLX_3DFX_multisample\r\n#define GLX_3DFX_multisample 1\r\n\r\n#define GLX_SAMPLE_BUFFERS_3DFX 0x8050\r\n#define GLX_SAMPLES_3DFX 0x8051\r\n\r\n#define GLXEW_3DFX_multisample GLXEW_GET_VAR(__GLXEW_3DFX_multisample)\r\n\r\n#endif /* GLX_3DFX_multisample */\r\n\r\n/* ------------------------ GLX_AMD_gpu_association ------------------------ */\r\n\r\n#ifndef GLX_AMD_gpu_association\r\n#define GLX_AMD_gpu_association 1\r\n\r\n#define GLX_GPU_VENDOR_AMD 0x1F00\r\n#define GLX_GPU_RENDERER_STRING_AMD 0x1F01\r\n#define GLX_GPU_OPENGL_VERSION_STRING_AMD 0x1F02\r\n#define GLX_GPU_FASTEST_TARGET_GPUS_AMD 0x21A2\r\n#define GLX_GPU_RAM_AMD 0x21A3\r\n#define GLX_GPU_CLOCK_AMD 0x21A4\r\n#define GLX_GPU_NUM_PIPES_AMD 0x21A5\r\n#define GLX_GPU_NUM_SIMD_AMD 0x21A6\r\n#define GLX_GPU_NUM_RB_AMD 0x21A7\r\n#define GLX_GPU_NUM_SPI_AMD 0x21A8\r\n\r\ntypedef void ( * PFNGLXBLITCONTEXTFRAMEBUFFERAMDPROC) (GLXContext dstCtx, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);\r\ntypedef GLXContext ( * PFNGLXCREATEASSOCIATEDCONTEXTAMDPROC) (unsigned int id, GLXContext share_list);\r\ntypedef GLXContext ( * PFNGLXCREATEASSOCIATEDCONTEXTATTRIBSAMDPROC) (unsigned int id, GLXContext share_context, const int* attribList);\r\ntypedef Bool ( * PFNGLXDELETEASSOCIATEDCONTEXTAMDPROC) (GLXContext ctx);\r\ntypedef unsigned int ( * PFNGLXGETCONTEXTGPUIDAMDPROC) (GLXContext ctx);\r\ntypedef GLXContext ( * PFNGLXGETCURRENTASSOCIATEDCONTEXTAMDPROC) (void);\r\ntypedef unsigned int ( * PFNGLXGETGPUIDSAMDPROC) (unsigned int maxCount, unsigned int* ids);\r\ntypedef int ( * PFNGLXGETGPUINFOAMDPROC) (unsigned int id, int property, GLenum dataType, unsigned int size, void* data);\r\ntypedef Bool ( * PFNGLXMAKEASSOCIATEDCONTEXTCURRENTAMDPROC) (GLXContext ctx);\r\n\r\n#define glXBlitContextFramebufferAMD GLXEW_GET_FUN(__glewXBlitContextFramebufferAMD)\r\n#define glXCreateAssociatedContextAMD GLXEW_GET_FUN(__glewXCreateAssociatedContextAMD)\r\n#define glXCreateAssociatedContextAttribsAMD GLXEW_GET_FUN(__glewXCreateAssociatedContextAttribsAMD)\r\n#define glXDeleteAssociatedContextAMD GLXEW_GET_FUN(__glewXDeleteAssociatedContextAMD)\r\n#define glXGetContextGPUIDAMD GLXEW_GET_FUN(__glewXGetContextGPUIDAMD)\r\n#define glXGetCurrentAssociatedContextAMD GLXEW_GET_FUN(__glewXGetCurrentAssociatedContextAMD)\r\n#define glXGetGPUIDsAMD GLXEW_GET_FUN(__glewXGetGPUIDsAMD)\r\n#define glXGetGPUInfoAMD GLXEW_GET_FUN(__glewXGetGPUInfoAMD)\r\n#define glXMakeAssociatedContextCurrentAMD GLXEW_GET_FUN(__glewXMakeAssociatedContextCurrentAMD)\r\n\r\n#define GLXEW_AMD_gpu_association GLXEW_GET_VAR(__GLXEW_AMD_gpu_association)\r\n\r\n#endif /* GLX_AMD_gpu_association */\r\n\r\n/* --------------------- GLX_ARB_context_flush_control --------------------- */\r\n\r\n#ifndef GLX_ARB_context_flush_control\r\n#define GLX_ARB_context_flush_control 1\r\n\r\n#define GLX_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB 0x0000\r\n#define GLX_CONTEXT_RELEASE_BEHAVIOR_ARB 0x2097\r\n#define GLX_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB 0x2098\r\n\r\n#define GLXEW_ARB_context_flush_control GLXEW_GET_VAR(__GLXEW_ARB_context_flush_control)\r\n\r\n#endif /* GLX_ARB_context_flush_control */\r\n\r\n/* ------------------------- GLX_ARB_create_context ------------------------ */\r\n\r\n#ifndef GLX_ARB_create_context\r\n#define GLX_ARB_create_context 1\r\n\r\n#define GLX_CONTEXT_DEBUG_BIT_ARB 0x0001\r\n#define GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x0002\r\n#define GLX_CONTEXT_MAJOR_VERSION_ARB 0x2091\r\n#define GLX_CONTEXT_MINOR_VERSION_ARB 0x2092\r\n#define GLX_CONTEXT_FLAGS_ARB 0x2094\r\n\r\ntypedef GLXContext ( * PFNGLXCREATECONTEXTATTRIBSARBPROC) (Display* dpy, GLXFBConfig config, GLXContext share_context, Bool direct, const int *attrib_list);\r\n\r\n#define glXCreateContextAttribsARB GLXEW_GET_FUN(__glewXCreateContextAttribsARB)\r\n\r\n#define GLXEW_ARB_create_context GLXEW_GET_VAR(__GLXEW_ARB_create_context)\r\n\r\n#endif /* GLX_ARB_create_context */\r\n\r\n/* --------------------- GLX_ARB_create_context_profile -------------------- */\r\n\r\n#ifndef GLX_ARB_create_context_profile\r\n#define GLX_ARB_create_context_profile 1\r\n\r\n#define GLX_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001\r\n#define GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002\r\n#define GLX_CONTEXT_PROFILE_MASK_ARB 0x9126\r\n\r\n#define GLXEW_ARB_create_context_profile GLXEW_GET_VAR(__GLXEW_ARB_create_context_profile)\r\n\r\n#endif /* GLX_ARB_create_context_profile */\r\n\r\n/* ------------------- GLX_ARB_create_context_robustness ------------------- */\r\n\r\n#ifndef GLX_ARB_create_context_robustness\r\n#define GLX_ARB_create_context_robustness 1\r\n\r\n#define GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB 0x00000004\r\n#define GLX_LOSE_CONTEXT_ON_RESET_ARB 0x8252\r\n#define GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB 0x8256\r\n#define GLX_NO_RESET_NOTIFICATION_ARB 0x8261\r\n\r\n#define GLXEW_ARB_create_context_robustness GLXEW_GET_VAR(__GLXEW_ARB_create_context_robustness)\r\n\r\n#endif /* GLX_ARB_create_context_robustness */\r\n\r\n/* ------------------------- GLX_ARB_fbconfig_float ------------------------ */\r\n\r\n#ifndef GLX_ARB_fbconfig_float\r\n#define GLX_ARB_fbconfig_float 1\r\n\r\n#define GLX_RGBA_FLOAT_BIT_ARB 0x00000004\r\n#define GLX_RGBA_FLOAT_TYPE_ARB 0x20B9\r\n\r\n#define GLXEW_ARB_fbconfig_float GLXEW_GET_VAR(__GLXEW_ARB_fbconfig_float)\r\n\r\n#endif /* GLX_ARB_fbconfig_float */\r\n\r\n/* ------------------------ GLX_ARB_framebuffer_sRGB ----------------------- */\r\n\r\n#ifndef GLX_ARB_framebuffer_sRGB\r\n#define GLX_ARB_framebuffer_sRGB 1\r\n\r\n#define GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20B2\r\n\r\n#define GLXEW_ARB_framebuffer_sRGB GLXEW_GET_VAR(__GLXEW_ARB_framebuffer_sRGB)\r\n\r\n#endif /* GLX_ARB_framebuffer_sRGB */\r\n\r\n/* ------------------------ GLX_ARB_get_proc_address ----------------------- */\r\n\r\n#ifndef GLX_ARB_get_proc_address\r\n#define GLX_ARB_get_proc_address 1\r\n\r\nextern void ( * glXGetProcAddressARB (const GLubyte *procName)) (void);\r\n\r\n#define GLXEW_ARB_get_proc_address GLXEW_GET_VAR(__GLXEW_ARB_get_proc_address)\r\n\r\n#endif /* GLX_ARB_get_proc_address */\r\n\r\n/* -------------------------- GLX_ARB_multisample -------------------------- */\r\n\r\n#ifndef GLX_ARB_multisample\r\n#define GLX_ARB_multisample 1\r\n\r\n#define GLX_SAMPLE_BUFFERS_ARB 100000\r\n#define GLX_SAMPLES_ARB 100001\r\n\r\n#define GLXEW_ARB_multisample GLXEW_GET_VAR(__GLXEW_ARB_multisample)\r\n\r\n#endif /* GLX_ARB_multisample */\r\n\r\n/* ---------------- GLX_ARB_robustness_application_isolation --------------- */\r\n\r\n#ifndef GLX_ARB_robustness_application_isolation\r\n#define GLX_ARB_robustness_application_isolation 1\r\n\r\n#define GLX_CONTEXT_RESET_ISOLATION_BIT_ARB 0x00000008\r\n\r\n#define GLXEW_ARB_robustness_application_isolation GLXEW_GET_VAR(__GLXEW_ARB_robustness_application_isolation)\r\n\r\n#endif /* GLX_ARB_robustness_application_isolation */\r\n\r\n/* ---------------- GLX_ARB_robustness_share_group_isolation --------------- */\r\n\r\n#ifndef GLX_ARB_robustness_share_group_isolation\r\n#define GLX_ARB_robustness_share_group_isolation 1\r\n\r\n#define GLX_CONTEXT_RESET_ISOLATION_BIT_ARB 0x00000008\r\n\r\n#define GLXEW_ARB_robustness_share_group_isolation GLXEW_GET_VAR(__GLXEW_ARB_robustness_share_group_isolation)\r\n\r\n#endif /* GLX_ARB_robustness_share_group_isolation */\r\n\r\n/* ---------------------- GLX_ARB_vertex_buffer_object --------------------- */\r\n\r\n#ifndef GLX_ARB_vertex_buffer_object\r\n#define GLX_ARB_vertex_buffer_object 1\r\n\r\n#define GLX_CONTEXT_ALLOW_BUFFER_BYTE_ORDER_MISMATCH_ARB 0x2095\r\n\r\n#define GLXEW_ARB_vertex_buffer_object GLXEW_GET_VAR(__GLXEW_ARB_vertex_buffer_object)\r\n\r\n#endif /* GLX_ARB_vertex_buffer_object */\r\n\r\n/* ----------------------- GLX_ATI_pixel_format_float ---------------------- */\r\n\r\n#ifndef GLX_ATI_pixel_format_float\r\n#define GLX_ATI_pixel_format_float 1\r\n\r\n#define GLX_RGBA_FLOAT_ATI_BIT 0x00000100\r\n\r\n#define GLXEW_ATI_pixel_format_float GLXEW_GET_VAR(__GLXEW_ATI_pixel_format_float)\r\n\r\n#endif /* GLX_ATI_pixel_format_float */\r\n\r\n/* ------------------------- GLX_ATI_render_texture ------------------------ */\r\n\r\n#ifndef GLX_ATI_render_texture\r\n#define GLX_ATI_render_texture 1\r\n\r\n#define GLX_BIND_TO_TEXTURE_RGB_ATI 0x9800\r\n#define GLX_BIND_TO_TEXTURE_RGBA_ATI 0x9801\r\n#define GLX_TEXTURE_FORMAT_ATI 0x9802\r\n#define GLX_TEXTURE_TARGET_ATI 0x9803\r\n#define GLX_MIPMAP_TEXTURE_ATI 0x9804\r\n#define GLX_TEXTURE_RGB_ATI 0x9805\r\n#define GLX_TEXTURE_RGBA_ATI 0x9806\r\n#define GLX_NO_TEXTURE_ATI 0x9807\r\n#define GLX_TEXTURE_CUBE_MAP_ATI 0x9808\r\n#define GLX_TEXTURE_1D_ATI 0x9809\r\n#define GLX_TEXTURE_2D_ATI 0x980A\r\n#define GLX_MIPMAP_LEVEL_ATI 0x980B\r\n#define GLX_CUBE_MAP_FACE_ATI 0x980C\r\n#define GLX_TEXTURE_CUBE_MAP_POSITIVE_X_ATI 0x980D\r\n#define GLX_TEXTURE_CUBE_MAP_NEGATIVE_X_ATI 0x980E\r\n#define GLX_TEXTURE_CUBE_MAP_POSITIVE_Y_ATI 0x980F\r\n#define GLX_TEXTURE_CUBE_MAP_NEGATIVE_Y_ATI 0x9810\r\n#define GLX_TEXTURE_CUBE_MAP_POSITIVE_Z_ATI 0x9811\r\n#define GLX_TEXTURE_CUBE_MAP_NEGATIVE_Z_ATI 0x9812\r\n#define GLX_FRONT_LEFT_ATI 0x9813\r\n#define GLX_FRONT_RIGHT_ATI 0x9814\r\n#define GLX_BACK_LEFT_ATI 0x9815\r\n#define GLX_BACK_RIGHT_ATI 0x9816\r\n#define GLX_AUX0_ATI 0x9817\r\n#define GLX_AUX1_ATI 0x9818\r\n#define GLX_AUX2_ATI 0x9819\r\n#define GLX_AUX3_ATI 0x981A\r\n#define GLX_AUX4_ATI 0x981B\r\n#define GLX_AUX5_ATI 0x981C\r\n#define GLX_AUX6_ATI 0x981D\r\n#define GLX_AUX7_ATI 0x981E\r\n#define GLX_AUX8_ATI 0x981F\r\n#define GLX_AUX9_ATI 0x9820\r\n#define GLX_BIND_TO_TEXTURE_LUMINANCE_ATI 0x9821\r\n#define GLX_BIND_TO_TEXTURE_INTENSITY_ATI 0x9822\r\n\r\ntypedef void ( * PFNGLXBINDTEXIMAGEATIPROC) (Display *dpy, GLXPbuffer pbuf, int buffer);\r\ntypedef void ( * PFNGLXDRAWABLEATTRIBATIPROC) (Display *dpy, GLXDrawable draw, const int *attrib_list);\r\ntypedef void ( * PFNGLXRELEASETEXIMAGEATIPROC) (Display *dpy, GLXPbuffer pbuf, int buffer);\r\n\r\n#define glXBindTexImageATI GLXEW_GET_FUN(__glewXBindTexImageATI)\r\n#define glXDrawableAttribATI GLXEW_GET_FUN(__glewXDrawableAttribATI)\r\n#define glXReleaseTexImageATI GLXEW_GET_FUN(__glewXReleaseTexImageATI)\r\n\r\n#define GLXEW_ATI_render_texture GLXEW_GET_VAR(__GLXEW_ATI_render_texture)\r\n\r\n#endif /* GLX_ATI_render_texture */\r\n\r\n/* --------------------------- GLX_EXT_buffer_age -------------------------- */\r\n\r\n#ifndef GLX_EXT_buffer_age\r\n#define GLX_EXT_buffer_age 1\r\n\r\n#define GLX_BACK_BUFFER_AGE_EXT 0x20F4\r\n\r\n#define GLXEW_EXT_buffer_age GLXEW_GET_VAR(__GLXEW_EXT_buffer_age)\r\n\r\n#endif /* GLX_EXT_buffer_age */\r\n\r\n/* ------------------- GLX_EXT_create_context_es2_profile ------------------ */\r\n\r\n#ifndef GLX_EXT_create_context_es2_profile\r\n#define GLX_EXT_create_context_es2_profile 1\r\n\r\n#define GLX_CONTEXT_ES2_PROFILE_BIT_EXT 0x00000004\r\n\r\n#define GLXEW_EXT_create_context_es2_profile GLXEW_GET_VAR(__GLXEW_EXT_create_context_es2_profile)\r\n\r\n#endif /* GLX_EXT_create_context_es2_profile */\r\n\r\n/* ------------------- GLX_EXT_create_context_es_profile ------------------- */\r\n\r\n#ifndef GLX_EXT_create_context_es_profile\r\n#define GLX_EXT_create_context_es_profile 1\r\n\r\n#define GLX_CONTEXT_ES_PROFILE_BIT_EXT 0x00000004\r\n\r\n#define GLXEW_EXT_create_context_es_profile GLXEW_GET_VAR(__GLXEW_EXT_create_context_es_profile)\r\n\r\n#endif /* GLX_EXT_create_context_es_profile */\r\n\r\n/* --------------------- GLX_EXT_fbconfig_packed_float --------------------- */\r\n\r\n#ifndef GLX_EXT_fbconfig_packed_float\r\n#define GLX_EXT_fbconfig_packed_float 1\r\n\r\n#define GLX_RGBA_UNSIGNED_FLOAT_BIT_EXT 0x00000008\r\n#define GLX_RGBA_UNSIGNED_FLOAT_TYPE_EXT 0x20B1\r\n\r\n#define GLXEW_EXT_fbconfig_packed_float GLXEW_GET_VAR(__GLXEW_EXT_fbconfig_packed_float)\r\n\r\n#endif /* GLX_EXT_fbconfig_packed_float */\r\n\r\n/* ------------------------ GLX_EXT_framebuffer_sRGB ----------------------- */\r\n\r\n#ifndef GLX_EXT_framebuffer_sRGB\r\n#define GLX_EXT_framebuffer_sRGB 1\r\n\r\n#define GLX_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x20B2\r\n\r\n#define GLXEW_EXT_framebuffer_sRGB GLXEW_GET_VAR(__GLXEW_EXT_framebuffer_sRGB)\r\n\r\n#endif /* GLX_EXT_framebuffer_sRGB */\r\n\r\n/* ------------------------- GLX_EXT_import_context ------------------------ */\r\n\r\n#ifndef GLX_EXT_import_context\r\n#define GLX_EXT_import_context 1\r\n\r\n#define GLX_SHARE_CONTEXT_EXT 0x800A\r\n#define GLX_VISUAL_ID_EXT 0x800B\r\n#define GLX_SCREEN_EXT 0x800C\r\n\r\ntypedef XID GLXContextID;\r\n\r\ntypedef void ( * PFNGLXFREECONTEXTEXTPROC) (Display* dpy, GLXContext context);\r\ntypedef GLXContextID ( * PFNGLXGETCONTEXTIDEXTPROC) (const GLXContext context);\r\ntypedef GLXContext ( * PFNGLXIMPORTCONTEXTEXTPROC) (Display* dpy, GLXContextID contextID);\r\ntypedef int ( * PFNGLXQUERYCONTEXTINFOEXTPROC) (Display* dpy, GLXContext context, int attribute,int *value);\r\n\r\n#define glXFreeContextEXT GLXEW_GET_FUN(__glewXFreeContextEXT)\r\n#define glXGetContextIDEXT GLXEW_GET_FUN(__glewXGetContextIDEXT)\r\n#define glXImportContextEXT GLXEW_GET_FUN(__glewXImportContextEXT)\r\n#define glXQueryContextInfoEXT GLXEW_GET_FUN(__glewXQueryContextInfoEXT)\r\n\r\n#define GLXEW_EXT_import_context GLXEW_GET_VAR(__GLXEW_EXT_import_context)\r\n\r\n#endif /* GLX_EXT_import_context */\r\n\r\n/* -------------------------- GLX_EXT_scene_marker ------------------------- */\r\n\r\n#ifndef GLX_EXT_scene_marker\r\n#define GLX_EXT_scene_marker 1\r\n\r\n#define GLXEW_EXT_scene_marker GLXEW_GET_VAR(__GLXEW_EXT_scene_marker)\r\n\r\n#endif /* GLX_EXT_scene_marker */\r\n\r\n/* -------------------------- GLX_EXT_stereo_tree -------------------------- */\r\n\r\n#ifndef GLX_EXT_stereo_tree\r\n#define GLX_EXT_stereo_tree 1\r\n\r\n#define GLX_STEREO_NOTIFY_EXT 0x00000000\r\n#define GLX_STEREO_NOTIFY_MASK_EXT 0x00000001\r\n#define GLX_STEREO_TREE_EXT 0x20F5\r\n\r\n#define GLXEW_EXT_stereo_tree GLXEW_GET_VAR(__GLXEW_EXT_stereo_tree)\r\n\r\n#endif /* GLX_EXT_stereo_tree */\r\n\r\n/* -------------------------- GLX_EXT_swap_control ------------------------- */\r\n\r\n#ifndef GLX_EXT_swap_control\r\n#define GLX_EXT_swap_control 1\r\n\r\n#define GLX_SWAP_INTERVAL_EXT 0x20F1\r\n#define GLX_MAX_SWAP_INTERVAL_EXT 0x20F2\r\n\r\ntypedef void ( * PFNGLXSWAPINTERVALEXTPROC) (Display* dpy, GLXDrawable drawable, int interval);\r\n\r\n#define glXSwapIntervalEXT GLXEW_GET_FUN(__glewXSwapIntervalEXT)\r\n\r\n#define GLXEW_EXT_swap_control GLXEW_GET_VAR(__GLXEW_EXT_swap_control)\r\n\r\n#endif /* GLX_EXT_swap_control */\r\n\r\n/* ----------------------- GLX_EXT_swap_control_tear ----------------------- */\r\n\r\n#ifndef GLX_EXT_swap_control_tear\r\n#define GLX_EXT_swap_control_tear 1\r\n\r\n#define GLX_LATE_SWAPS_TEAR_EXT 0x20F3\r\n\r\n#define GLXEW_EXT_swap_control_tear GLXEW_GET_VAR(__GLXEW_EXT_swap_control_tear)\r\n\r\n#endif /* GLX_EXT_swap_control_tear */\r\n\r\n/* ---------------------- GLX_EXT_texture_from_pixmap ---------------------- */\r\n\r\n#ifndef GLX_EXT_texture_from_pixmap\r\n#define GLX_EXT_texture_from_pixmap 1\r\n\r\n#define GLX_TEXTURE_1D_BIT_EXT 0x00000001\r\n#define GLX_TEXTURE_2D_BIT_EXT 0x00000002\r\n#define GLX_TEXTURE_RECTANGLE_BIT_EXT 0x00000004\r\n#define GLX_BIND_TO_TEXTURE_RGB_EXT 0x20D0\r\n#define GLX_BIND_TO_TEXTURE_RGBA_EXT 0x20D1\r\n#define GLX_BIND_TO_MIPMAP_TEXTURE_EXT 0x20D2\r\n#define GLX_BIND_TO_TEXTURE_TARGETS_EXT 0x20D3\r\n#define GLX_Y_INVERTED_EXT 0x20D4\r\n#define GLX_TEXTURE_FORMAT_EXT 0x20D5\r\n#define GLX_TEXTURE_TARGET_EXT 0x20D6\r\n#define GLX_MIPMAP_TEXTURE_EXT 0x20D7\r\n#define GLX_TEXTURE_FORMAT_NONE_EXT 0x20D8\r\n#define GLX_TEXTURE_FORMAT_RGB_EXT 0x20D9\r\n#define GLX_TEXTURE_FORMAT_RGBA_EXT 0x20DA\r\n#define GLX_TEXTURE_1D_EXT 0x20DB\r\n#define GLX_TEXTURE_2D_EXT 0x20DC\r\n#define GLX_TEXTURE_RECTANGLE_EXT 0x20DD\r\n#define GLX_FRONT_LEFT_EXT 0x20DE\r\n#define GLX_FRONT_RIGHT_EXT 0x20DF\r\n#define GLX_BACK_LEFT_EXT 0x20E0\r\n#define GLX_BACK_RIGHT_EXT 0x20E1\r\n#define GLX_AUX0_EXT 0x20E2\r\n#define GLX_AUX1_EXT 0x20E3\r\n#define GLX_AUX2_EXT 0x20E4\r\n#define GLX_AUX3_EXT 0x20E5\r\n#define GLX_AUX4_EXT 0x20E6\r\n#define GLX_AUX5_EXT 0x20E7\r\n#define GLX_AUX6_EXT 0x20E8\r\n#define GLX_AUX7_EXT 0x20E9\r\n#define GLX_AUX8_EXT 0x20EA\r\n#define GLX_AUX9_EXT 0x20EB\r\n\r\ntypedef void ( * PFNGLXBINDTEXIMAGEEXTPROC) (Display* display, GLXDrawable drawable, int buffer, const int *attrib_list);\r\ntypedef void ( * PFNGLXRELEASETEXIMAGEEXTPROC) (Display* display, GLXDrawable drawable, int buffer);\r\n\r\n#define glXBindTexImageEXT GLXEW_GET_FUN(__glewXBindTexImageEXT)\r\n#define glXReleaseTexImageEXT GLXEW_GET_FUN(__glewXReleaseTexImageEXT)\r\n\r\n#define GLXEW_EXT_texture_from_pixmap GLXEW_GET_VAR(__GLXEW_EXT_texture_from_pixmap)\r\n\r\n#endif /* GLX_EXT_texture_from_pixmap */\r\n\r\n/* -------------------------- GLX_EXT_visual_info -------------------------- */\r\n\r\n#ifndef GLX_EXT_visual_info\r\n#define GLX_EXT_visual_info 1\r\n\r\n#define GLX_X_VISUAL_TYPE_EXT 0x22\r\n#define GLX_TRANSPARENT_TYPE_EXT 0x23\r\n#define GLX_TRANSPARENT_INDEX_VALUE_EXT 0x24\r\n#define GLX_TRANSPARENT_RED_VALUE_EXT 0x25\r\n#define GLX_TRANSPARENT_GREEN_VALUE_EXT 0x26\r\n#define GLX_TRANSPARENT_BLUE_VALUE_EXT 0x27\r\n#define GLX_TRANSPARENT_ALPHA_VALUE_EXT 0x28\r\n#define GLX_NONE_EXT 0x8000\r\n#define GLX_TRUE_COLOR_EXT 0x8002\r\n#define GLX_DIRECT_COLOR_EXT 0x8003\r\n#define GLX_PSEUDO_COLOR_EXT 0x8004\r\n#define GLX_STATIC_COLOR_EXT 0x8005\r\n#define GLX_GRAY_SCALE_EXT 0x8006\r\n#define GLX_STATIC_GRAY_EXT 0x8007\r\n#define GLX_TRANSPARENT_RGB_EXT 0x8008\r\n#define GLX_TRANSPARENT_INDEX_EXT 0x8009\r\n\r\n#define GLXEW_EXT_visual_info GLXEW_GET_VAR(__GLXEW_EXT_visual_info)\r\n\r\n#endif /* GLX_EXT_visual_info */\r\n\r\n/* ------------------------- GLX_EXT_visual_rating ------------------------- */\r\n\r\n#ifndef GLX_EXT_visual_rating\r\n#define GLX_EXT_visual_rating 1\r\n\r\n#define GLX_VISUAL_CAVEAT_EXT 0x20\r\n#define GLX_SLOW_VISUAL_EXT 0x8001\r\n#define GLX_NON_CONFORMANT_VISUAL_EXT 0x800D\r\n\r\n#define GLXEW_EXT_visual_rating GLXEW_GET_VAR(__GLXEW_EXT_visual_rating)\r\n\r\n#endif /* GLX_EXT_visual_rating */\r\n\r\n/* -------------------------- GLX_INTEL_swap_event ------------------------- */\r\n\r\n#ifndef GLX_INTEL_swap_event\r\n#define GLX_INTEL_swap_event 1\r\n\r\n#define GLX_EXCHANGE_COMPLETE_INTEL 0x8180\r\n#define GLX_COPY_COMPLETE_INTEL 0x8181\r\n#define GLX_FLIP_COMPLETE_INTEL 0x8182\r\n#define GLX_BUFFER_SWAP_COMPLETE_INTEL_MASK 0x04000000\r\n\r\n#define GLXEW_INTEL_swap_event GLXEW_GET_VAR(__GLXEW_INTEL_swap_event)\r\n\r\n#endif /* GLX_INTEL_swap_event */\r\n\r\n/* -------------------------- GLX_MESA_agp_offset -------------------------- */\r\n\r\n#ifndef GLX_MESA_agp_offset\r\n#define GLX_MESA_agp_offset 1\r\n\r\ntypedef unsigned int ( * PFNGLXGETAGPOFFSETMESAPROC) (const void* pointer);\r\n\r\n#define glXGetAGPOffsetMESA GLXEW_GET_FUN(__glewXGetAGPOffsetMESA)\r\n\r\n#define GLXEW_MESA_agp_offset GLXEW_GET_VAR(__GLXEW_MESA_agp_offset)\r\n\r\n#endif /* GLX_MESA_agp_offset */\r\n\r\n/* ------------------------ GLX_MESA_copy_sub_buffer ----------------------- */\r\n\r\n#ifndef GLX_MESA_copy_sub_buffer\r\n#define GLX_MESA_copy_sub_buffer 1\r\n\r\ntypedef void ( * PFNGLXCOPYSUBBUFFERMESAPROC) (Display* dpy, GLXDrawable drawable, int x, int y, int width, int height);\r\n\r\n#define glXCopySubBufferMESA GLXEW_GET_FUN(__glewXCopySubBufferMESA)\r\n\r\n#define GLXEW_MESA_copy_sub_buffer GLXEW_GET_VAR(__GLXEW_MESA_copy_sub_buffer)\r\n\r\n#endif /* GLX_MESA_copy_sub_buffer */\r\n\r\n/* ------------------------ GLX_MESA_pixmap_colormap ----------------------- */\r\n\r\n#ifndef GLX_MESA_pixmap_colormap\r\n#define GLX_MESA_pixmap_colormap 1\r\n\r\ntypedef GLXPixmap ( * PFNGLXCREATEGLXPIXMAPMESAPROC) (Display* dpy, XVisualInfo *visual, Pixmap pixmap, Colormap cmap);\r\n\r\n#define glXCreateGLXPixmapMESA GLXEW_GET_FUN(__glewXCreateGLXPixmapMESA)\r\n\r\n#define GLXEW_MESA_pixmap_colormap GLXEW_GET_VAR(__GLXEW_MESA_pixmap_colormap)\r\n\r\n#endif /* GLX_MESA_pixmap_colormap */\r\n\r\n/* ------------------------ GLX_MESA_query_renderer ------------------------ */\r\n\r\n#ifndef GLX_MESA_query_renderer\r\n#define GLX_MESA_query_renderer 1\r\n\r\n#define GLX_RENDERER_VENDOR_ID_MESA 0x8183\r\n#define GLX_RENDERER_DEVICE_ID_MESA 0x8184\r\n#define GLX_RENDERER_VERSION_MESA 0x8185\r\n#define GLX_RENDERER_ACCELERATED_MESA 0x8186\r\n#define GLX_RENDERER_VIDEO_MEMORY_MESA 0x8187\r\n#define GLX_RENDERER_UNIFIED_MEMORY_ARCHITECTURE_MESA 0x8188\r\n#define GLX_RENDERER_PREFERRED_PROFILE_MESA 0x8189\r\n#define GLX_RENDERER_OPENGL_CORE_PROFILE_VERSION_MESA 0x818A\r\n#define GLX_RENDERER_OPENGL_COMPATIBILITY_PROFILE_VERSION_MESA 0x818B\r\n#define GLX_RENDERER_OPENGL_ES_PROFILE_VERSION_MESA 0x818C\r\n#define GLX_RENDERER_OPENGL_ES2_PROFILE_VERSION_MESA 0x818D\r\n#define GLX_RENDERER_ID_MESA 0x818E\r\n\r\ntypedef Bool ( * PFNGLXQUERYCURRENTRENDERERINTEGERMESAPROC) (int attribute, unsigned int* value);\r\ntypedef const char* ( * PFNGLXQUERYCURRENTRENDERERSTRINGMESAPROC) (int attribute);\r\ntypedef Bool ( * PFNGLXQUERYRENDERERINTEGERMESAPROC) (Display* dpy, int screen, int renderer, int attribute, unsigned int *value);\r\ntypedef const char* ( * PFNGLXQUERYRENDERERSTRINGMESAPROC) (Display *dpy, int screen, int renderer, int attribute);\r\n\r\n#define glXQueryCurrentRendererIntegerMESA GLXEW_GET_FUN(__glewXQueryCurrentRendererIntegerMESA)\r\n#define glXQueryCurrentRendererStringMESA GLXEW_GET_FUN(__glewXQueryCurrentRendererStringMESA)\r\n#define glXQueryRendererIntegerMESA GLXEW_GET_FUN(__glewXQueryRendererIntegerMESA)\r\n#define glXQueryRendererStringMESA GLXEW_GET_FUN(__glewXQueryRendererStringMESA)\r\n\r\n#define GLXEW_MESA_query_renderer GLXEW_GET_VAR(__GLXEW_MESA_query_renderer)\r\n\r\n#endif /* GLX_MESA_query_renderer */\r\n\r\n/* ------------------------ GLX_MESA_release_buffers ----------------------- */\r\n\r\n#ifndef GLX_MESA_release_buffers\r\n#define GLX_MESA_release_buffers 1\r\n\r\ntypedef Bool ( * PFNGLXRELEASEBUFFERSMESAPROC) (Display* dpy, GLXDrawable d);\r\n\r\n#define glXReleaseBuffersMESA GLXEW_GET_FUN(__glewXReleaseBuffersMESA)\r\n\r\n#define GLXEW_MESA_release_buffers GLXEW_GET_VAR(__GLXEW_MESA_release_buffers)\r\n\r\n#endif /* GLX_MESA_release_buffers */\r\n\r\n/* ------------------------- GLX_MESA_set_3dfx_mode ------------------------ */\r\n\r\n#ifndef GLX_MESA_set_3dfx_mode\r\n#define GLX_MESA_set_3dfx_mode 1\r\n\r\n#define GLX_3DFX_WINDOW_MODE_MESA 0x1\r\n#define GLX_3DFX_FULLSCREEN_MODE_MESA 0x2\r\n\r\ntypedef GLboolean ( * PFNGLXSET3DFXMODEMESAPROC) (GLint mode);\r\n\r\n#define glXSet3DfxModeMESA GLXEW_GET_FUN(__glewXSet3DfxModeMESA)\r\n\r\n#define GLXEW_MESA_set_3dfx_mode GLXEW_GET_VAR(__GLXEW_MESA_set_3dfx_mode)\r\n\r\n#endif /* GLX_MESA_set_3dfx_mode */\r\n\r\n/* ------------------------- GLX_MESA_swap_control ------------------------- */\r\n\r\n#ifndef GLX_MESA_swap_control\r\n#define GLX_MESA_swap_control 1\r\n\r\ntypedef int ( * PFNGLXGETSWAPINTERVALMESAPROC) (void);\r\ntypedef int ( * PFNGLXSWAPINTERVALMESAPROC) (unsigned int interval);\r\n\r\n#define glXGetSwapIntervalMESA GLXEW_GET_FUN(__glewXGetSwapIntervalMESA)\r\n#define glXSwapIntervalMESA GLXEW_GET_FUN(__glewXSwapIntervalMESA)\r\n\r\n#define GLXEW_MESA_swap_control GLXEW_GET_VAR(__GLXEW_MESA_swap_control)\r\n\r\n#endif /* GLX_MESA_swap_control */\r\n\r\n/* --------------------------- GLX_NV_copy_buffer -------------------------- */\r\n\r\n#ifndef GLX_NV_copy_buffer\r\n#define GLX_NV_copy_buffer 1\r\n\r\ntypedef void ( * PFNGLXCOPYBUFFERSUBDATANVPROC) (Display* dpy, GLXContext readCtx, GLXContext writeCtx, GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size);\r\ntypedef void ( * PFNGLXNAMEDCOPYBUFFERSUBDATANVPROC) (Display* dpy, GLXContext readCtx, GLXContext writeCtx, GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size);\r\n\r\n#define glXCopyBufferSubDataNV GLXEW_GET_FUN(__glewXCopyBufferSubDataNV)\r\n#define glXNamedCopyBufferSubDataNV GLXEW_GET_FUN(__glewXNamedCopyBufferSubDataNV)\r\n\r\n#define GLXEW_NV_copy_buffer GLXEW_GET_VAR(__GLXEW_NV_copy_buffer)\r\n\r\n#endif /* GLX_NV_copy_buffer */\r\n\r\n/* --------------------------- GLX_NV_copy_image --------------------------- */\r\n\r\n#ifndef GLX_NV_copy_image\r\n#define GLX_NV_copy_image 1\r\n\r\ntypedef void ( * PFNGLXCOPYIMAGESUBDATANVPROC) (Display *dpy, GLXContext srcCtx, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLXContext dstCtx, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth);\r\n\r\n#define glXCopyImageSubDataNV GLXEW_GET_FUN(__glewXCopyImageSubDataNV)\r\n\r\n#define GLXEW_NV_copy_image GLXEW_GET_VAR(__GLXEW_NV_copy_image)\r\n\r\n#endif /* GLX_NV_copy_image */\r\n\r\n/* ------------------------ GLX_NV_delay_before_swap ----------------------- */\r\n\r\n#ifndef GLX_NV_delay_before_swap\r\n#define GLX_NV_delay_before_swap 1\r\n\r\ntypedef Bool ( * PFNGLXDELAYBEFORESWAPNVPROC) (Display* dpy, GLXDrawable drawable, GLfloat seconds);\r\n\r\n#define glXDelayBeforeSwapNV GLXEW_GET_FUN(__glewXDelayBeforeSwapNV)\r\n\r\n#define GLXEW_NV_delay_before_swap GLXEW_GET_VAR(__GLXEW_NV_delay_before_swap)\r\n\r\n#endif /* GLX_NV_delay_before_swap */\r\n\r\n/* -------------------------- GLX_NV_float_buffer -------------------------- */\r\n\r\n#ifndef GLX_NV_float_buffer\r\n#define GLX_NV_float_buffer 1\r\n\r\n#define GLX_FLOAT_COMPONENTS_NV 0x20B0\r\n\r\n#define GLXEW_NV_float_buffer GLXEW_GET_VAR(__GLXEW_NV_float_buffer)\r\n\r\n#endif /* GLX_NV_float_buffer */\r\n\r\n/* ---------------------- GLX_NV_multisample_coverage ---------------------- */\r\n\r\n#ifndef GLX_NV_multisample_coverage\r\n#define GLX_NV_multisample_coverage 1\r\n\r\n#define GLX_COLOR_SAMPLES_NV 0x20B3\r\n#define GLX_COVERAGE_SAMPLES_NV 100001\r\n\r\n#define GLXEW_NV_multisample_coverage GLXEW_GET_VAR(__GLXEW_NV_multisample_coverage)\r\n\r\n#endif /* GLX_NV_multisample_coverage */\r\n\r\n/* -------------------------- GLX_NV_present_video ------------------------- */\r\n\r\n#ifndef GLX_NV_present_video\r\n#define GLX_NV_present_video 1\r\n\r\n#define GLX_NUM_VIDEO_SLOTS_NV 0x20F0\r\n\r\ntypedef int ( * PFNGLXBINDVIDEODEVICENVPROC) (Display* dpy, unsigned int video_slot, unsigned int video_device, const int *attrib_list);\r\ntypedef unsigned int* ( * PFNGLXENUMERATEVIDEODEVICESNVPROC) (Display *dpy, int screen, int *nelements);\r\n\r\n#define glXBindVideoDeviceNV GLXEW_GET_FUN(__glewXBindVideoDeviceNV)\r\n#define glXEnumerateVideoDevicesNV GLXEW_GET_FUN(__glewXEnumerateVideoDevicesNV)\r\n\r\n#define GLXEW_NV_present_video GLXEW_GET_VAR(__GLXEW_NV_present_video)\r\n\r\n#endif /* GLX_NV_present_video */\r\n\r\n/* --------------------------- GLX_NV_swap_group --------------------------- */\r\n\r\n#ifndef GLX_NV_swap_group\r\n#define GLX_NV_swap_group 1\r\n\r\ntypedef Bool ( * PFNGLXBINDSWAPBARRIERNVPROC) (Display* dpy, GLuint group, GLuint barrier);\r\ntypedef Bool ( * PFNGLXJOINSWAPGROUPNVPROC) (Display* dpy, GLXDrawable drawable, GLuint group);\r\ntypedef Bool ( * PFNGLXQUERYFRAMECOUNTNVPROC) (Display* dpy, int screen, GLuint *count);\r\ntypedef Bool ( * PFNGLXQUERYMAXSWAPGROUPSNVPROC) (Display* dpy, int screen, GLuint *maxGroups, GLuint *maxBarriers);\r\ntypedef Bool ( * PFNGLXQUERYSWAPGROUPNVPROC) (Display* dpy, GLXDrawable drawable, GLuint *group, GLuint *barrier);\r\ntypedef Bool ( * PFNGLXRESETFRAMECOUNTNVPROC) (Display* dpy, int screen);\r\n\r\n#define glXBindSwapBarrierNV GLXEW_GET_FUN(__glewXBindSwapBarrierNV)\r\n#define glXJoinSwapGroupNV GLXEW_GET_FUN(__glewXJoinSwapGroupNV)\r\n#define glXQueryFrameCountNV GLXEW_GET_FUN(__glewXQueryFrameCountNV)\r\n#define glXQueryMaxSwapGroupsNV GLXEW_GET_FUN(__glewXQueryMaxSwapGroupsNV)\r\n#define glXQuerySwapGroupNV GLXEW_GET_FUN(__glewXQuerySwapGroupNV)\r\n#define glXResetFrameCountNV GLXEW_GET_FUN(__glewXResetFrameCountNV)\r\n\r\n#define GLXEW_NV_swap_group GLXEW_GET_VAR(__GLXEW_NV_swap_group)\r\n\r\n#endif /* GLX_NV_swap_group */\r\n\r\n/* ----------------------- GLX_NV_vertex_array_range ----------------------- */\r\n\r\n#ifndef GLX_NV_vertex_array_range\r\n#define GLX_NV_vertex_array_range 1\r\n\r\ntypedef void * ( * PFNGLXALLOCATEMEMORYNVPROC) (GLsizei size, GLfloat readFrequency, GLfloat writeFrequency, GLfloat priority);\r\ntypedef void ( * PFNGLXFREEMEMORYNVPROC) (void *pointer);\r\n\r\n#define glXAllocateMemoryNV GLXEW_GET_FUN(__glewXAllocateMemoryNV)\r\n#define glXFreeMemoryNV GLXEW_GET_FUN(__glewXFreeMemoryNV)\r\n\r\n#define GLXEW_NV_vertex_array_range GLXEW_GET_VAR(__GLXEW_NV_vertex_array_range)\r\n\r\n#endif /* GLX_NV_vertex_array_range */\r\n\r\n/* -------------------------- GLX_NV_video_capture ------------------------- */\r\n\r\n#ifndef GLX_NV_video_capture\r\n#define GLX_NV_video_capture 1\r\n\r\n#define GLX_DEVICE_ID_NV 0x20CD\r\n#define GLX_UNIQUE_ID_NV 0x20CE\r\n#define GLX_NUM_VIDEO_CAPTURE_SLOTS_NV 0x20CF\r\n\r\ntypedef XID GLXVideoCaptureDeviceNV;\r\n\r\ntypedef int ( * PFNGLXBINDVIDEOCAPTUREDEVICENVPROC) (Display* dpy, unsigned int video_capture_slot, GLXVideoCaptureDeviceNV device);\r\ntypedef GLXVideoCaptureDeviceNV * ( * PFNGLXENUMERATEVIDEOCAPTUREDEVICESNVPROC) (Display* dpy, int screen, int *nelements);\r\ntypedef void ( * PFNGLXLOCKVIDEOCAPTUREDEVICENVPROC) (Display* dpy, GLXVideoCaptureDeviceNV device);\r\ntypedef int ( * PFNGLXQUERYVIDEOCAPTUREDEVICENVPROC) (Display* dpy, GLXVideoCaptureDeviceNV device, int attribute, int *value);\r\ntypedef void ( * PFNGLXRELEASEVIDEOCAPTUREDEVICENVPROC) (Display* dpy, GLXVideoCaptureDeviceNV device);\r\n\r\n#define glXBindVideoCaptureDeviceNV GLXEW_GET_FUN(__glewXBindVideoCaptureDeviceNV)\r\n#define glXEnumerateVideoCaptureDevicesNV GLXEW_GET_FUN(__glewXEnumerateVideoCaptureDevicesNV)\r\n#define glXLockVideoCaptureDeviceNV GLXEW_GET_FUN(__glewXLockVideoCaptureDeviceNV)\r\n#define glXQueryVideoCaptureDeviceNV GLXEW_GET_FUN(__glewXQueryVideoCaptureDeviceNV)\r\n#define glXReleaseVideoCaptureDeviceNV GLXEW_GET_FUN(__glewXReleaseVideoCaptureDeviceNV)\r\n\r\n#define GLXEW_NV_video_capture GLXEW_GET_VAR(__GLXEW_NV_video_capture)\r\n\r\n#endif /* GLX_NV_video_capture */\r\n\r\n/* ---------------------------- GLX_NV_video_out --------------------------- */\r\n\r\n#ifndef GLX_NV_video_out\r\n#define GLX_NV_video_out 1\r\n\r\n#define GLX_VIDEO_OUT_COLOR_NV 0x20C3\r\n#define GLX_VIDEO_OUT_ALPHA_NV 0x20C4\r\n#define GLX_VIDEO_OUT_DEPTH_NV 0x20C5\r\n#define GLX_VIDEO_OUT_COLOR_AND_ALPHA_NV 0x20C6\r\n#define GLX_VIDEO_OUT_COLOR_AND_DEPTH_NV 0x20C7\r\n#define GLX_VIDEO_OUT_FRAME_NV 0x20C8\r\n#define GLX_VIDEO_OUT_FIELD_1_NV 0x20C9\r\n#define GLX_VIDEO_OUT_FIELD_2_NV 0x20CA\r\n#define GLX_VIDEO_OUT_STACKED_FIELDS_1_2_NV 0x20CB\r\n#define GLX_VIDEO_OUT_STACKED_FIELDS_2_1_NV 0x20CC\r\n\r\ntypedef int ( * PFNGLXBINDVIDEOIMAGENVPROC) (Display* dpy, GLXVideoDeviceNV VideoDevice, GLXPbuffer pbuf, int iVideoBuffer);\r\ntypedef int ( * PFNGLXGETVIDEODEVICENVPROC) (Display* dpy, int screen, int numVideoDevices, GLXVideoDeviceNV *pVideoDevice);\r\ntypedef int ( * PFNGLXGETVIDEOINFONVPROC) (Display* dpy, int screen, GLXVideoDeviceNV VideoDevice, unsigned long *pulCounterOutputPbuffer, unsigned long *pulCounterOutputVideo);\r\ntypedef int ( * PFNGLXRELEASEVIDEODEVICENVPROC) (Display* dpy, int screen, GLXVideoDeviceNV VideoDevice);\r\ntypedef int ( * PFNGLXRELEASEVIDEOIMAGENVPROC) (Display* dpy, GLXPbuffer pbuf);\r\ntypedef int ( * PFNGLXSENDPBUFFERTOVIDEONVPROC) (Display* dpy, GLXPbuffer pbuf, int iBufferType, unsigned long *pulCounterPbuffer, GLboolean bBlock);\r\n\r\n#define glXBindVideoImageNV GLXEW_GET_FUN(__glewXBindVideoImageNV)\r\n#define glXGetVideoDeviceNV GLXEW_GET_FUN(__glewXGetVideoDeviceNV)\r\n#define glXGetVideoInfoNV GLXEW_GET_FUN(__glewXGetVideoInfoNV)\r\n#define glXReleaseVideoDeviceNV GLXEW_GET_FUN(__glewXReleaseVideoDeviceNV)\r\n#define glXReleaseVideoImageNV GLXEW_GET_FUN(__glewXReleaseVideoImageNV)\r\n#define glXSendPbufferToVideoNV GLXEW_GET_FUN(__glewXSendPbufferToVideoNV)\r\n\r\n#define GLXEW_NV_video_out GLXEW_GET_VAR(__GLXEW_NV_video_out)\r\n\r\n#endif /* GLX_NV_video_out */\r\n\r\n/* -------------------------- GLX_OML_swap_method -------------------------- */\r\n\r\n#ifndef GLX_OML_swap_method\r\n#define GLX_OML_swap_method 1\r\n\r\n#define GLX_SWAP_METHOD_OML 0x8060\r\n#define GLX_SWAP_EXCHANGE_OML 0x8061\r\n#define GLX_SWAP_COPY_OML 0x8062\r\n#define GLX_SWAP_UNDEFINED_OML 0x8063\r\n\r\n#define GLXEW_OML_swap_method GLXEW_GET_VAR(__GLXEW_OML_swap_method)\r\n\r\n#endif /* GLX_OML_swap_method */\r\n\r\n/* -------------------------- GLX_OML_sync_control ------------------------- */\r\n\r\n#ifndef GLX_OML_sync_control\r\n#define GLX_OML_sync_control 1\r\n\r\ntypedef Bool ( * PFNGLXGETMSCRATEOMLPROC) (Display* dpy, GLXDrawable drawable, int32_t* numerator, int32_t* denominator);\r\ntypedef Bool ( * PFNGLXGETSYNCVALUESOMLPROC) (Display* dpy, GLXDrawable drawable, int64_t* ust, int64_t* msc, int64_t* sbc);\r\ntypedef int64_t ( * PFNGLXSWAPBUFFERSMSCOMLPROC) (Display* dpy, GLXDrawable drawable, int64_t target_msc, int64_t divisor, int64_t remainder);\r\ntypedef Bool ( * PFNGLXWAITFORMSCOMLPROC) (Display* dpy, GLXDrawable drawable, int64_t target_msc, int64_t divisor, int64_t remainder, int64_t* ust, int64_t* msc, int64_t* sbc);\r\ntypedef Bool ( * PFNGLXWAITFORSBCOMLPROC) (Display* dpy, GLXDrawable drawable, int64_t target_sbc, int64_t* ust, int64_t* msc, int64_t* sbc);\r\n\r\n#define glXGetMscRateOML GLXEW_GET_FUN(__glewXGetMscRateOML)\r\n#define glXGetSyncValuesOML GLXEW_GET_FUN(__glewXGetSyncValuesOML)\r\n#define glXSwapBuffersMscOML GLXEW_GET_FUN(__glewXSwapBuffersMscOML)\r\n#define glXWaitForMscOML GLXEW_GET_FUN(__glewXWaitForMscOML)\r\n#define glXWaitForSbcOML GLXEW_GET_FUN(__glewXWaitForSbcOML)\r\n\r\n#define GLXEW_OML_sync_control GLXEW_GET_VAR(__GLXEW_OML_sync_control)\r\n\r\n#endif /* GLX_OML_sync_control */\r\n\r\n/* ------------------------ GLX_SGIS_blended_overlay ----------------------- */\r\n\r\n#ifndef GLX_SGIS_blended_overlay\r\n#define GLX_SGIS_blended_overlay 1\r\n\r\n#define GLX_BLENDED_RGBA_SGIS 0x8025\r\n\r\n#define GLXEW_SGIS_blended_overlay GLXEW_GET_VAR(__GLXEW_SGIS_blended_overlay)\r\n\r\n#endif /* GLX_SGIS_blended_overlay */\r\n\r\n/* -------------------------- GLX_SGIS_color_range ------------------------- */\r\n\r\n#ifndef GLX_SGIS_color_range\r\n#define GLX_SGIS_color_range 1\r\n\r\n#define GLXEW_SGIS_color_range GLXEW_GET_VAR(__GLXEW_SGIS_color_range)\r\n\r\n#endif /* GLX_SGIS_color_range */\r\n\r\n/* -------------------------- GLX_SGIS_multisample ------------------------- */\r\n\r\n#ifndef GLX_SGIS_multisample\r\n#define GLX_SGIS_multisample 1\r\n\r\n#define GLX_SAMPLE_BUFFERS_SGIS 100000\r\n#define GLX_SAMPLES_SGIS 100001\r\n\r\n#define GLXEW_SGIS_multisample GLXEW_GET_VAR(__GLXEW_SGIS_multisample)\r\n\r\n#endif /* GLX_SGIS_multisample */\r\n\r\n/* ---------------------- GLX_SGIS_shared_multisample ---------------------- */\r\n\r\n#ifndef GLX_SGIS_shared_multisample\r\n#define GLX_SGIS_shared_multisample 1\r\n\r\n#define GLX_MULTISAMPLE_SUB_RECT_WIDTH_SGIS 0x8026\r\n#define GLX_MULTISAMPLE_SUB_RECT_HEIGHT_SGIS 0x8027\r\n\r\n#define GLXEW_SGIS_shared_multisample GLXEW_GET_VAR(__GLXEW_SGIS_shared_multisample)\r\n\r\n#endif /* GLX_SGIS_shared_multisample */\r\n\r\n/* --------------------------- GLX_SGIX_fbconfig --------------------------- */\r\n\r\n#ifndef GLX_SGIX_fbconfig\r\n#define GLX_SGIX_fbconfig 1\r\n\r\n#define GLX_RGBA_BIT_SGIX 0x00000001\r\n#define GLX_WINDOW_BIT_SGIX 0x00000001\r\n#define GLX_COLOR_INDEX_BIT_SGIX 0x00000002\r\n#define GLX_PIXMAP_BIT_SGIX 0x00000002\r\n#define GLX_SCREEN_EXT 0x800C\r\n#define GLX_DRAWABLE_TYPE_SGIX 0x8010\r\n#define GLX_RENDER_TYPE_SGIX 0x8011\r\n#define GLX_X_RENDERABLE_SGIX 0x8012\r\n#define GLX_FBCONFIG_ID_SGIX 0x8013\r\n#define GLX_RGBA_TYPE_SGIX 0x8014\r\n#define GLX_COLOR_INDEX_TYPE_SGIX 0x8015\r\n\r\ntypedef XID GLXFBConfigIDSGIX;\r\ntypedef struct __GLXFBConfigRec *GLXFBConfigSGIX;\r\n\r\ntypedef GLXFBConfigSGIX* ( * PFNGLXCHOOSEFBCONFIGSGIXPROC) (Display *dpy, int screen, const int *attrib_list, int *nelements);\r\ntypedef GLXContext ( * PFNGLXCREATECONTEXTWITHCONFIGSGIXPROC) (Display* dpy, GLXFBConfig config, int render_type, GLXContext share_list, Bool direct);\r\ntypedef GLXPixmap ( * PFNGLXCREATEGLXPIXMAPWITHCONFIGSGIXPROC) (Display* dpy, GLXFBConfig config, Pixmap pixmap);\r\ntypedef int ( * PFNGLXGETFBCONFIGATTRIBSGIXPROC) (Display* dpy, GLXFBConfigSGIX config, int attribute, int *value);\r\ntypedef GLXFBConfigSGIX ( * PFNGLXGETFBCONFIGFROMVISUALSGIXPROC) (Display* dpy, XVisualInfo *vis);\r\ntypedef XVisualInfo* ( * PFNGLXGETVISUALFROMFBCONFIGSGIXPROC) (Display *dpy, GLXFBConfig config);\r\n\r\n#define glXChooseFBConfigSGIX GLXEW_GET_FUN(__glewXChooseFBConfigSGIX)\r\n#define glXCreateContextWithConfigSGIX GLXEW_GET_FUN(__glewXCreateContextWithConfigSGIX)\r\n#define glXCreateGLXPixmapWithConfigSGIX GLXEW_GET_FUN(__glewXCreateGLXPixmapWithConfigSGIX)\r\n#define glXGetFBConfigAttribSGIX GLXEW_GET_FUN(__glewXGetFBConfigAttribSGIX)\r\n#define glXGetFBConfigFromVisualSGIX GLXEW_GET_FUN(__glewXGetFBConfigFromVisualSGIX)\r\n#define glXGetVisualFromFBConfigSGIX GLXEW_GET_FUN(__glewXGetVisualFromFBConfigSGIX)\r\n\r\n#define GLXEW_SGIX_fbconfig GLXEW_GET_VAR(__GLXEW_SGIX_fbconfig)\r\n\r\n#endif /* GLX_SGIX_fbconfig */\r\n\r\n/* --------------------------- GLX_SGIX_hyperpipe -------------------------- */\r\n\r\n#ifndef GLX_SGIX_hyperpipe\r\n#define GLX_SGIX_hyperpipe 1\r\n\r\n#define GLX_HYPERPIPE_DISPLAY_PIPE_SGIX 0x00000001\r\n#define GLX_PIPE_RECT_SGIX 0x00000001\r\n#define GLX_HYPERPIPE_RENDER_PIPE_SGIX 0x00000002\r\n#define GLX_PIPE_RECT_LIMITS_SGIX 0x00000002\r\n#define GLX_HYPERPIPE_STEREO_SGIX 0x00000003\r\n#define GLX_HYPERPIPE_PIXEL_AVERAGE_SGIX 0x00000004\r\n#define GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX 80\r\n#define GLX_BAD_HYPERPIPE_CONFIG_SGIX 91\r\n#define GLX_BAD_HYPERPIPE_SGIX 92\r\n#define GLX_HYPERPIPE_ID_SGIX 0x8030\r\n\r\ntypedef struct {\r\n  char pipeName[GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX]; \r\n  int  networkId; \r\n} GLXHyperpipeNetworkSGIX;\r\ntypedef struct {\r\n  char pipeName[GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX]; \r\n  int XOrigin; \r\n  int YOrigin; \r\n  int maxHeight; \r\n  int maxWidth; \r\n} GLXPipeRectLimits;\r\ntypedef struct {\r\n  char pipeName[GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX]; \r\n  int channel; \r\n  unsigned int participationType; \r\n  int timeSlice; \r\n} GLXHyperpipeConfigSGIX;\r\ntypedef struct {\r\n  char pipeName[GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX]; \r\n  int srcXOrigin; \r\n  int srcYOrigin; \r\n  int srcWidth; \r\n  int srcHeight; \r\n  int destXOrigin; \r\n  int destYOrigin; \r\n  int destWidth; \r\n  int destHeight; \r\n} GLXPipeRect;\r\n\r\ntypedef int ( * PFNGLXBINDHYPERPIPESGIXPROC) (Display *dpy, int hpId);\r\ntypedef int ( * PFNGLXDESTROYHYPERPIPECONFIGSGIXPROC) (Display *dpy, int hpId);\r\ntypedef int ( * PFNGLXHYPERPIPEATTRIBSGIXPROC) (Display *dpy, int timeSlice, int attrib, int size, void *attribList);\r\ntypedef int ( * PFNGLXHYPERPIPECONFIGSGIXPROC) (Display *dpy, int networkId, int npipes, GLXHyperpipeConfigSGIX *cfg, int *hpId);\r\ntypedef int ( * PFNGLXQUERYHYPERPIPEATTRIBSGIXPROC) (Display *dpy, int timeSlice, int attrib, int size, void *returnAttribList);\r\ntypedef int ( * PFNGLXQUERYHYPERPIPEBESTATTRIBSGIXPROC) (Display *dpy, int timeSlice, int attrib, int size, void *attribList, void *returnAttribList);\r\ntypedef GLXHyperpipeConfigSGIX * ( * PFNGLXQUERYHYPERPIPECONFIGSGIXPROC) (Display *dpy, int hpId, int *npipes);\r\ntypedef GLXHyperpipeNetworkSGIX * ( * PFNGLXQUERYHYPERPIPENETWORKSGIXPROC) (Display *dpy, int *npipes);\r\n\r\n#define glXBindHyperpipeSGIX GLXEW_GET_FUN(__glewXBindHyperpipeSGIX)\r\n#define glXDestroyHyperpipeConfigSGIX GLXEW_GET_FUN(__glewXDestroyHyperpipeConfigSGIX)\r\n#define glXHyperpipeAttribSGIX GLXEW_GET_FUN(__glewXHyperpipeAttribSGIX)\r\n#define glXHyperpipeConfigSGIX GLXEW_GET_FUN(__glewXHyperpipeConfigSGIX)\r\n#define glXQueryHyperpipeAttribSGIX GLXEW_GET_FUN(__glewXQueryHyperpipeAttribSGIX)\r\n#define glXQueryHyperpipeBestAttribSGIX GLXEW_GET_FUN(__glewXQueryHyperpipeBestAttribSGIX)\r\n#define glXQueryHyperpipeConfigSGIX GLXEW_GET_FUN(__glewXQueryHyperpipeConfigSGIX)\r\n#define glXQueryHyperpipeNetworkSGIX GLXEW_GET_FUN(__glewXQueryHyperpipeNetworkSGIX)\r\n\r\n#define GLXEW_SGIX_hyperpipe GLXEW_GET_VAR(__GLXEW_SGIX_hyperpipe)\r\n\r\n#endif /* GLX_SGIX_hyperpipe */\r\n\r\n/* ---------------------------- GLX_SGIX_pbuffer --------------------------- */\r\n\r\n#ifndef GLX_SGIX_pbuffer\r\n#define GLX_SGIX_pbuffer 1\r\n\r\n#define GLX_FRONT_LEFT_BUFFER_BIT_SGIX 0x00000001\r\n#define GLX_FRONT_RIGHT_BUFFER_BIT_SGIX 0x00000002\r\n#define GLX_BACK_LEFT_BUFFER_BIT_SGIX 0x00000004\r\n#define GLX_PBUFFER_BIT_SGIX 0x00000004\r\n#define GLX_BACK_RIGHT_BUFFER_BIT_SGIX 0x00000008\r\n#define GLX_AUX_BUFFERS_BIT_SGIX 0x00000010\r\n#define GLX_DEPTH_BUFFER_BIT_SGIX 0x00000020\r\n#define GLX_STENCIL_BUFFER_BIT_SGIX 0x00000040\r\n#define GLX_ACCUM_BUFFER_BIT_SGIX 0x00000080\r\n#define GLX_SAMPLE_BUFFERS_BIT_SGIX 0x00000100\r\n#define GLX_MAX_PBUFFER_WIDTH_SGIX 0x8016\r\n#define GLX_MAX_PBUFFER_HEIGHT_SGIX 0x8017\r\n#define GLX_MAX_PBUFFER_PIXELS_SGIX 0x8018\r\n#define GLX_OPTIMAL_PBUFFER_WIDTH_SGIX 0x8019\r\n#define GLX_OPTIMAL_PBUFFER_HEIGHT_SGIX 0x801A\r\n#define GLX_PRESERVED_CONTENTS_SGIX 0x801B\r\n#define GLX_LARGEST_PBUFFER_SGIX 0x801C\r\n#define GLX_WIDTH_SGIX 0x801D\r\n#define GLX_HEIGHT_SGIX 0x801E\r\n#define GLX_EVENT_MASK_SGIX 0x801F\r\n#define GLX_DAMAGED_SGIX 0x8020\r\n#define GLX_SAVED_SGIX 0x8021\r\n#define GLX_WINDOW_SGIX 0x8022\r\n#define GLX_PBUFFER_SGIX 0x8023\r\n#define GLX_BUFFER_CLOBBER_MASK_SGIX 0x08000000\r\n\r\ntypedef XID GLXPbufferSGIX;\r\ntypedef struct { int type; unsigned long serial; Bool send_event; Display *display; GLXDrawable drawable; int event_type; int draw_type; unsigned int mask; int x, y; int width, height; int count; } GLXBufferClobberEventSGIX;\r\n\r\ntypedef GLXPbuffer ( * PFNGLXCREATEGLXPBUFFERSGIXPROC) (Display* dpy, GLXFBConfig config, unsigned int width, unsigned int height, int *attrib_list);\r\ntypedef void ( * PFNGLXDESTROYGLXPBUFFERSGIXPROC) (Display* dpy, GLXPbuffer pbuf);\r\ntypedef void ( * PFNGLXGETSELECTEDEVENTSGIXPROC) (Display* dpy, GLXDrawable drawable, unsigned long *mask);\r\ntypedef void ( * PFNGLXQUERYGLXPBUFFERSGIXPROC) (Display* dpy, GLXPbuffer pbuf, int attribute, unsigned int *value);\r\ntypedef void ( * PFNGLXSELECTEVENTSGIXPROC) (Display* dpy, GLXDrawable drawable, unsigned long mask);\r\n\r\n#define glXCreateGLXPbufferSGIX GLXEW_GET_FUN(__glewXCreateGLXPbufferSGIX)\r\n#define glXDestroyGLXPbufferSGIX GLXEW_GET_FUN(__glewXDestroyGLXPbufferSGIX)\r\n#define glXGetSelectedEventSGIX GLXEW_GET_FUN(__glewXGetSelectedEventSGIX)\r\n#define glXQueryGLXPbufferSGIX GLXEW_GET_FUN(__glewXQueryGLXPbufferSGIX)\r\n#define glXSelectEventSGIX GLXEW_GET_FUN(__glewXSelectEventSGIX)\r\n\r\n#define GLXEW_SGIX_pbuffer GLXEW_GET_VAR(__GLXEW_SGIX_pbuffer)\r\n\r\n#endif /* GLX_SGIX_pbuffer */\r\n\r\n/* ------------------------- GLX_SGIX_swap_barrier ------------------------- */\r\n\r\n#ifndef GLX_SGIX_swap_barrier\r\n#define GLX_SGIX_swap_barrier 1\r\n\r\ntypedef void ( * PFNGLXBINDSWAPBARRIERSGIXPROC) (Display *dpy, GLXDrawable drawable, int barrier);\r\ntypedef Bool ( * PFNGLXQUERYMAXSWAPBARRIERSSGIXPROC) (Display *dpy, int screen, int *max);\r\n\r\n#define glXBindSwapBarrierSGIX GLXEW_GET_FUN(__glewXBindSwapBarrierSGIX)\r\n#define glXQueryMaxSwapBarriersSGIX GLXEW_GET_FUN(__glewXQueryMaxSwapBarriersSGIX)\r\n\r\n#define GLXEW_SGIX_swap_barrier GLXEW_GET_VAR(__GLXEW_SGIX_swap_barrier)\r\n\r\n#endif /* GLX_SGIX_swap_barrier */\r\n\r\n/* -------------------------- GLX_SGIX_swap_group -------------------------- */\r\n\r\n#ifndef GLX_SGIX_swap_group\r\n#define GLX_SGIX_swap_group 1\r\n\r\ntypedef void ( * PFNGLXJOINSWAPGROUPSGIXPROC) (Display *dpy, GLXDrawable drawable, GLXDrawable member);\r\n\r\n#define glXJoinSwapGroupSGIX GLXEW_GET_FUN(__glewXJoinSwapGroupSGIX)\r\n\r\n#define GLXEW_SGIX_swap_group GLXEW_GET_VAR(__GLXEW_SGIX_swap_group)\r\n\r\n#endif /* GLX_SGIX_swap_group */\r\n\r\n/* ------------------------- GLX_SGIX_video_resize ------------------------- */\r\n\r\n#ifndef GLX_SGIX_video_resize\r\n#define GLX_SGIX_video_resize 1\r\n\r\n#define GLX_SYNC_FRAME_SGIX 0x00000000\r\n#define GLX_SYNC_SWAP_SGIX 0x00000001\r\n\r\ntypedef int ( * PFNGLXBINDCHANNELTOWINDOWSGIXPROC) (Display* display, int screen, int channel, Window window);\r\ntypedef int ( * PFNGLXCHANNELRECTSGIXPROC) (Display* display, int screen, int channel, int x, int y, int w, int h);\r\ntypedef int ( * PFNGLXCHANNELRECTSYNCSGIXPROC) (Display* display, int screen, int channel, GLenum synctype);\r\ntypedef int ( * PFNGLXQUERYCHANNELDELTASSGIXPROC) (Display* display, int screen, int channel, int *x, int *y, int *w, int *h);\r\ntypedef int ( * PFNGLXQUERYCHANNELRECTSGIXPROC) (Display* display, int screen, int channel, int *dx, int *dy, int *dw, int *dh);\r\n\r\n#define glXBindChannelToWindowSGIX GLXEW_GET_FUN(__glewXBindChannelToWindowSGIX)\r\n#define glXChannelRectSGIX GLXEW_GET_FUN(__glewXChannelRectSGIX)\r\n#define glXChannelRectSyncSGIX GLXEW_GET_FUN(__glewXChannelRectSyncSGIX)\r\n#define glXQueryChannelDeltasSGIX GLXEW_GET_FUN(__glewXQueryChannelDeltasSGIX)\r\n#define glXQueryChannelRectSGIX GLXEW_GET_FUN(__glewXQueryChannelRectSGIX)\r\n\r\n#define GLXEW_SGIX_video_resize GLXEW_GET_VAR(__GLXEW_SGIX_video_resize)\r\n\r\n#endif /* GLX_SGIX_video_resize */\r\n\r\n/* ---------------------- GLX_SGIX_visual_select_group --------------------- */\r\n\r\n#ifndef GLX_SGIX_visual_select_group\r\n#define GLX_SGIX_visual_select_group 1\r\n\r\n#define GLX_VISUAL_SELECT_GROUP_SGIX 0x8028\r\n\r\n#define GLXEW_SGIX_visual_select_group GLXEW_GET_VAR(__GLXEW_SGIX_visual_select_group)\r\n\r\n#endif /* GLX_SGIX_visual_select_group */\r\n\r\n/* ---------------------------- GLX_SGI_cushion ---------------------------- */\r\n\r\n#ifndef GLX_SGI_cushion\r\n#define GLX_SGI_cushion 1\r\n\r\ntypedef void ( * PFNGLXCUSHIONSGIPROC) (Display* dpy, Window window, float cushion);\r\n\r\n#define glXCushionSGI GLXEW_GET_FUN(__glewXCushionSGI)\r\n\r\n#define GLXEW_SGI_cushion GLXEW_GET_VAR(__GLXEW_SGI_cushion)\r\n\r\n#endif /* GLX_SGI_cushion */\r\n\r\n/* ----------------------- GLX_SGI_make_current_read ----------------------- */\r\n\r\n#ifndef GLX_SGI_make_current_read\r\n#define GLX_SGI_make_current_read 1\r\n\r\ntypedef GLXDrawable ( * PFNGLXGETCURRENTREADDRAWABLESGIPROC) (void);\r\ntypedef Bool ( * PFNGLXMAKECURRENTREADSGIPROC) (Display* dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx);\r\n\r\n#define glXGetCurrentReadDrawableSGI GLXEW_GET_FUN(__glewXGetCurrentReadDrawableSGI)\r\n#define glXMakeCurrentReadSGI GLXEW_GET_FUN(__glewXMakeCurrentReadSGI)\r\n\r\n#define GLXEW_SGI_make_current_read GLXEW_GET_VAR(__GLXEW_SGI_make_current_read)\r\n\r\n#endif /* GLX_SGI_make_current_read */\r\n\r\n/* -------------------------- GLX_SGI_swap_control ------------------------- */\r\n\r\n#ifndef GLX_SGI_swap_control\r\n#define GLX_SGI_swap_control 1\r\n\r\ntypedef int ( * PFNGLXSWAPINTERVALSGIPROC) (int interval);\r\n\r\n#define glXSwapIntervalSGI GLXEW_GET_FUN(__glewXSwapIntervalSGI)\r\n\r\n#define GLXEW_SGI_swap_control GLXEW_GET_VAR(__GLXEW_SGI_swap_control)\r\n\r\n#endif /* GLX_SGI_swap_control */\r\n\r\n/* --------------------------- GLX_SGI_video_sync -------------------------- */\r\n\r\n#ifndef GLX_SGI_video_sync\r\n#define GLX_SGI_video_sync 1\r\n\r\ntypedef int ( * PFNGLXGETVIDEOSYNCSGIPROC) (unsigned int* count);\r\ntypedef int ( * PFNGLXWAITVIDEOSYNCSGIPROC) (int divisor, int remainder, unsigned int* count);\r\n\r\n#define glXGetVideoSyncSGI GLXEW_GET_FUN(__glewXGetVideoSyncSGI)\r\n#define glXWaitVideoSyncSGI GLXEW_GET_FUN(__glewXWaitVideoSyncSGI)\r\n\r\n#define GLXEW_SGI_video_sync GLXEW_GET_VAR(__GLXEW_SGI_video_sync)\r\n\r\n#endif /* GLX_SGI_video_sync */\r\n\r\n/* --------------------- GLX_SUN_get_transparent_index --------------------- */\r\n\r\n#ifndef GLX_SUN_get_transparent_index\r\n#define GLX_SUN_get_transparent_index 1\r\n\r\ntypedef Status ( * PFNGLXGETTRANSPARENTINDEXSUNPROC) (Display* dpy, Window overlay, Window underlay, unsigned long *pTransparentIndex);\r\n\r\n#define glXGetTransparentIndexSUN GLXEW_GET_FUN(__glewXGetTransparentIndexSUN)\r\n\r\n#define GLXEW_SUN_get_transparent_index GLXEW_GET_VAR(__GLXEW_SUN_get_transparent_index)\r\n\r\n#endif /* GLX_SUN_get_transparent_index */\r\n\r\n/* -------------------------- GLX_SUN_video_resize ------------------------- */\r\n\r\n#ifndef GLX_SUN_video_resize\r\n#define GLX_SUN_video_resize 1\r\n\r\n#define GLX_VIDEO_RESIZE_SUN 0x8171\r\n#define GL_VIDEO_RESIZE_COMPENSATION_SUN 0x85CD\r\n\r\ntypedef int ( * PFNGLXGETVIDEORESIZESUNPROC) (Display* display, GLXDrawable window, float* factor);\r\ntypedef int ( * PFNGLXVIDEORESIZESUNPROC) (Display* display, GLXDrawable window, float factor);\r\n\r\n#define glXGetVideoResizeSUN GLXEW_GET_FUN(__glewXGetVideoResizeSUN)\r\n#define glXVideoResizeSUN GLXEW_GET_FUN(__glewXVideoResizeSUN)\r\n\r\n#define GLXEW_SUN_video_resize GLXEW_GET_VAR(__GLXEW_SUN_video_resize)\r\n\r\n#endif /* GLX_SUN_video_resize */\r\n\r\n/* ------------------------------------------------------------------------- */\r\n\r\n#ifdef GLEW_MX\r\n#define GLXEW_FUN_EXPORT GLEW_FUN_EXPORT\r\n#define GLXEW_VAR_EXPORT\r\n#else\r\n#define GLXEW_FUN_EXPORT GLEW_FUN_EXPORT\r\n#define GLXEW_VAR_EXPORT GLEW_VAR_EXPORT\r\n#endif /* GLEW_MX */\r\n\r\nGLXEW_FUN_EXPORT PFNGLXGETCURRENTDISPLAYPROC __glewXGetCurrentDisplay;\r\n\r\nGLXEW_FUN_EXPORT PFNGLXCHOOSEFBCONFIGPROC __glewXChooseFBConfig;\r\nGLXEW_FUN_EXPORT PFNGLXCREATENEWCONTEXTPROC __glewXCreateNewContext;\r\nGLXEW_FUN_EXPORT PFNGLXCREATEPBUFFERPROC __glewXCreatePbuffer;\r\nGLXEW_FUN_EXPORT PFNGLXCREATEPIXMAPPROC __glewXCreatePixmap;\r\nGLXEW_FUN_EXPORT PFNGLXCREATEWINDOWPROC __glewXCreateWindow;\r\nGLXEW_FUN_EXPORT PFNGLXDESTROYPBUFFERPROC __glewXDestroyPbuffer;\r\nGLXEW_FUN_EXPORT PFNGLXDESTROYPIXMAPPROC __glewXDestroyPixmap;\r\nGLXEW_FUN_EXPORT PFNGLXDESTROYWINDOWPROC __glewXDestroyWindow;\r\nGLXEW_FUN_EXPORT PFNGLXGETCURRENTREADDRAWABLEPROC __glewXGetCurrentReadDrawable;\r\nGLXEW_FUN_EXPORT PFNGLXGETFBCONFIGATTRIBPROC __glewXGetFBConfigAttrib;\r\nGLXEW_FUN_EXPORT PFNGLXGETFBCONFIGSPROC __glewXGetFBConfigs;\r\nGLXEW_FUN_EXPORT PFNGLXGETSELECTEDEVENTPROC __glewXGetSelectedEvent;\r\nGLXEW_FUN_EXPORT PFNGLXGETVISUALFROMFBCONFIGPROC __glewXGetVisualFromFBConfig;\r\nGLXEW_FUN_EXPORT PFNGLXMAKECONTEXTCURRENTPROC __glewXMakeContextCurrent;\r\nGLXEW_FUN_EXPORT PFNGLXQUERYCONTEXTPROC __glewXQueryContext;\r\nGLXEW_FUN_EXPORT PFNGLXQUERYDRAWABLEPROC __glewXQueryDrawable;\r\nGLXEW_FUN_EXPORT PFNGLXSELECTEVENTPROC __glewXSelectEvent;\r\n\r\nGLXEW_FUN_EXPORT PFNGLXBLITCONTEXTFRAMEBUFFERAMDPROC __glewXBlitContextFramebufferAMD;\r\nGLXEW_FUN_EXPORT PFNGLXCREATEASSOCIATEDCONTEXTAMDPROC __glewXCreateAssociatedContextAMD;\r\nGLXEW_FUN_EXPORT PFNGLXCREATEASSOCIATEDCONTEXTATTRIBSAMDPROC __glewXCreateAssociatedContextAttribsAMD;\r\nGLXEW_FUN_EXPORT PFNGLXDELETEASSOCIATEDCONTEXTAMDPROC __glewXDeleteAssociatedContextAMD;\r\nGLXEW_FUN_EXPORT PFNGLXGETCONTEXTGPUIDAMDPROC __glewXGetContextGPUIDAMD;\r\nGLXEW_FUN_EXPORT PFNGLXGETCURRENTASSOCIATEDCONTEXTAMDPROC __glewXGetCurrentAssociatedContextAMD;\r\nGLXEW_FUN_EXPORT PFNGLXGETGPUIDSAMDPROC __glewXGetGPUIDsAMD;\r\nGLXEW_FUN_EXPORT PFNGLXGETGPUINFOAMDPROC __glewXGetGPUInfoAMD;\r\nGLXEW_FUN_EXPORT PFNGLXMAKEASSOCIATEDCONTEXTCURRENTAMDPROC __glewXMakeAssociatedContextCurrentAMD;\r\n\r\nGLXEW_FUN_EXPORT PFNGLXCREATECONTEXTATTRIBSARBPROC __glewXCreateContextAttribsARB;\r\n\r\nGLXEW_FUN_EXPORT PFNGLXBINDTEXIMAGEATIPROC __glewXBindTexImageATI;\r\nGLXEW_FUN_EXPORT PFNGLXDRAWABLEATTRIBATIPROC __glewXDrawableAttribATI;\r\nGLXEW_FUN_EXPORT PFNGLXRELEASETEXIMAGEATIPROC __glewXReleaseTexImageATI;\r\n\r\nGLXEW_FUN_EXPORT PFNGLXFREECONTEXTEXTPROC __glewXFreeContextEXT;\r\nGLXEW_FUN_EXPORT PFNGLXGETCONTEXTIDEXTPROC __glewXGetContextIDEXT;\r\nGLXEW_FUN_EXPORT PFNGLXIMPORTCONTEXTEXTPROC __glewXImportContextEXT;\r\nGLXEW_FUN_EXPORT PFNGLXQUERYCONTEXTINFOEXTPROC __glewXQueryContextInfoEXT;\r\n\r\nGLXEW_FUN_EXPORT PFNGLXSWAPINTERVALEXTPROC __glewXSwapIntervalEXT;\r\n\r\nGLXEW_FUN_EXPORT PFNGLXBINDTEXIMAGEEXTPROC __glewXBindTexImageEXT;\r\nGLXEW_FUN_EXPORT PFNGLXRELEASETEXIMAGEEXTPROC __glewXReleaseTexImageEXT;\r\n\r\nGLXEW_FUN_EXPORT PFNGLXGETAGPOFFSETMESAPROC __glewXGetAGPOffsetMESA;\r\n\r\nGLXEW_FUN_EXPORT PFNGLXCOPYSUBBUFFERMESAPROC __glewXCopySubBufferMESA;\r\n\r\nGLXEW_FUN_EXPORT PFNGLXCREATEGLXPIXMAPMESAPROC __glewXCreateGLXPixmapMESA;\r\n\r\nGLXEW_FUN_EXPORT PFNGLXQUERYCURRENTRENDERERINTEGERMESAPROC __glewXQueryCurrentRendererIntegerMESA;\r\nGLXEW_FUN_EXPORT PFNGLXQUERYCURRENTRENDERERSTRINGMESAPROC __glewXQueryCurrentRendererStringMESA;\r\nGLXEW_FUN_EXPORT PFNGLXQUERYRENDERERINTEGERMESAPROC __glewXQueryRendererIntegerMESA;\r\nGLXEW_FUN_EXPORT PFNGLXQUERYRENDERERSTRINGMESAPROC __glewXQueryRendererStringMESA;\r\n\r\nGLXEW_FUN_EXPORT PFNGLXRELEASEBUFFERSMESAPROC __glewXReleaseBuffersMESA;\r\n\r\nGLXEW_FUN_EXPORT PFNGLXSET3DFXMODEMESAPROC __glewXSet3DfxModeMESA;\r\n\r\nGLXEW_FUN_EXPORT PFNGLXGETSWAPINTERVALMESAPROC __glewXGetSwapIntervalMESA;\r\nGLXEW_FUN_EXPORT PFNGLXSWAPINTERVALMESAPROC __glewXSwapIntervalMESA;\r\n\r\nGLXEW_FUN_EXPORT PFNGLXCOPYBUFFERSUBDATANVPROC __glewXCopyBufferSubDataNV;\r\nGLXEW_FUN_EXPORT PFNGLXNAMEDCOPYBUFFERSUBDATANVPROC __glewXNamedCopyBufferSubDataNV;\r\n\r\nGLXEW_FUN_EXPORT PFNGLXCOPYIMAGESUBDATANVPROC __glewXCopyImageSubDataNV;\r\n\r\nGLXEW_FUN_EXPORT PFNGLXDELAYBEFORESWAPNVPROC __glewXDelayBeforeSwapNV;\r\n\r\nGLXEW_FUN_EXPORT PFNGLXBINDVIDEODEVICENVPROC __glewXBindVideoDeviceNV;\r\nGLXEW_FUN_EXPORT PFNGLXENUMERATEVIDEODEVICESNVPROC __glewXEnumerateVideoDevicesNV;\r\n\r\nGLXEW_FUN_EXPORT PFNGLXBINDSWAPBARRIERNVPROC __glewXBindSwapBarrierNV;\r\nGLXEW_FUN_EXPORT PFNGLXJOINSWAPGROUPNVPROC __glewXJoinSwapGroupNV;\r\nGLXEW_FUN_EXPORT PFNGLXQUERYFRAMECOUNTNVPROC __glewXQueryFrameCountNV;\r\nGLXEW_FUN_EXPORT PFNGLXQUERYMAXSWAPGROUPSNVPROC __glewXQueryMaxSwapGroupsNV;\r\nGLXEW_FUN_EXPORT PFNGLXQUERYSWAPGROUPNVPROC __glewXQuerySwapGroupNV;\r\nGLXEW_FUN_EXPORT PFNGLXRESETFRAMECOUNTNVPROC __glewXResetFrameCountNV;\r\n\r\nGLXEW_FUN_EXPORT PFNGLXALLOCATEMEMORYNVPROC __glewXAllocateMemoryNV;\r\nGLXEW_FUN_EXPORT PFNGLXFREEMEMORYNVPROC __glewXFreeMemoryNV;\r\n\r\nGLXEW_FUN_EXPORT PFNGLXBINDVIDEOCAPTUREDEVICENVPROC __glewXBindVideoCaptureDeviceNV;\r\nGLXEW_FUN_EXPORT PFNGLXENUMERATEVIDEOCAPTUREDEVICESNVPROC __glewXEnumerateVideoCaptureDevicesNV;\r\nGLXEW_FUN_EXPORT PFNGLXLOCKVIDEOCAPTUREDEVICENVPROC __glewXLockVideoCaptureDeviceNV;\r\nGLXEW_FUN_EXPORT PFNGLXQUERYVIDEOCAPTUREDEVICENVPROC __glewXQueryVideoCaptureDeviceNV;\r\nGLXEW_FUN_EXPORT PFNGLXRELEASEVIDEOCAPTUREDEVICENVPROC __glewXReleaseVideoCaptureDeviceNV;\r\n\r\nGLXEW_FUN_EXPORT PFNGLXBINDVIDEOIMAGENVPROC __glewXBindVideoImageNV;\r\nGLXEW_FUN_EXPORT PFNGLXGETVIDEODEVICENVPROC __glewXGetVideoDeviceNV;\r\nGLXEW_FUN_EXPORT PFNGLXGETVIDEOINFONVPROC __glewXGetVideoInfoNV;\r\nGLXEW_FUN_EXPORT PFNGLXRELEASEVIDEODEVICENVPROC __glewXReleaseVideoDeviceNV;\r\nGLXEW_FUN_EXPORT PFNGLXRELEASEVIDEOIMAGENVPROC __glewXReleaseVideoImageNV;\r\nGLXEW_FUN_EXPORT PFNGLXSENDPBUFFERTOVIDEONVPROC __glewXSendPbufferToVideoNV;\r\n\r\nGLXEW_FUN_EXPORT PFNGLXGETMSCRATEOMLPROC __glewXGetMscRateOML;\r\nGLXEW_FUN_EXPORT PFNGLXGETSYNCVALUESOMLPROC __glewXGetSyncValuesOML;\r\nGLXEW_FUN_EXPORT PFNGLXSWAPBUFFERSMSCOMLPROC __glewXSwapBuffersMscOML;\r\nGLXEW_FUN_EXPORT PFNGLXWAITFORMSCOMLPROC __glewXWaitForMscOML;\r\nGLXEW_FUN_EXPORT PFNGLXWAITFORSBCOMLPROC __glewXWaitForSbcOML;\r\n\r\nGLXEW_FUN_EXPORT PFNGLXCHOOSEFBCONFIGSGIXPROC __glewXChooseFBConfigSGIX;\r\nGLXEW_FUN_EXPORT PFNGLXCREATECONTEXTWITHCONFIGSGIXPROC __glewXCreateContextWithConfigSGIX;\r\nGLXEW_FUN_EXPORT PFNGLXCREATEGLXPIXMAPWITHCONFIGSGIXPROC __glewXCreateGLXPixmapWithConfigSGIX;\r\nGLXEW_FUN_EXPORT PFNGLXGETFBCONFIGATTRIBSGIXPROC __glewXGetFBConfigAttribSGIX;\r\nGLXEW_FUN_EXPORT PFNGLXGETFBCONFIGFROMVISUALSGIXPROC __glewXGetFBConfigFromVisualSGIX;\r\nGLXEW_FUN_EXPORT PFNGLXGETVISUALFROMFBCONFIGSGIXPROC __glewXGetVisualFromFBConfigSGIX;\r\n\r\nGLXEW_FUN_EXPORT PFNGLXBINDHYPERPIPESGIXPROC __glewXBindHyperpipeSGIX;\r\nGLXEW_FUN_EXPORT PFNGLXDESTROYHYPERPIPECONFIGSGIXPROC __glewXDestroyHyperpipeConfigSGIX;\r\nGLXEW_FUN_EXPORT PFNGLXHYPERPIPEATTRIBSGIXPROC __glewXHyperpipeAttribSGIX;\r\nGLXEW_FUN_EXPORT PFNGLXHYPERPIPECONFIGSGIXPROC __glewXHyperpipeConfigSGIX;\r\nGLXEW_FUN_EXPORT PFNGLXQUERYHYPERPIPEATTRIBSGIXPROC __glewXQueryHyperpipeAttribSGIX;\r\nGLXEW_FUN_EXPORT PFNGLXQUERYHYPERPIPEBESTATTRIBSGIXPROC __glewXQueryHyperpipeBestAttribSGIX;\r\nGLXEW_FUN_EXPORT PFNGLXQUERYHYPERPIPECONFIGSGIXPROC __glewXQueryHyperpipeConfigSGIX;\r\nGLXEW_FUN_EXPORT PFNGLXQUERYHYPERPIPENETWORKSGIXPROC __glewXQueryHyperpipeNetworkSGIX;\r\n\r\nGLXEW_FUN_EXPORT PFNGLXCREATEGLXPBUFFERSGIXPROC __glewXCreateGLXPbufferSGIX;\r\nGLXEW_FUN_EXPORT PFNGLXDESTROYGLXPBUFFERSGIXPROC __glewXDestroyGLXPbufferSGIX;\r\nGLXEW_FUN_EXPORT PFNGLXGETSELECTEDEVENTSGIXPROC __glewXGetSelectedEventSGIX;\r\nGLXEW_FUN_EXPORT PFNGLXQUERYGLXPBUFFERSGIXPROC __glewXQueryGLXPbufferSGIX;\r\nGLXEW_FUN_EXPORT PFNGLXSELECTEVENTSGIXPROC __glewXSelectEventSGIX;\r\n\r\nGLXEW_FUN_EXPORT PFNGLXBINDSWAPBARRIERSGIXPROC __glewXBindSwapBarrierSGIX;\r\nGLXEW_FUN_EXPORT PFNGLXQUERYMAXSWAPBARRIERSSGIXPROC __glewXQueryMaxSwapBarriersSGIX;\r\n\r\nGLXEW_FUN_EXPORT PFNGLXJOINSWAPGROUPSGIXPROC __glewXJoinSwapGroupSGIX;\r\n\r\nGLXEW_FUN_EXPORT PFNGLXBINDCHANNELTOWINDOWSGIXPROC __glewXBindChannelToWindowSGIX;\r\nGLXEW_FUN_EXPORT PFNGLXCHANNELRECTSGIXPROC __glewXChannelRectSGIX;\r\nGLXEW_FUN_EXPORT PFNGLXCHANNELRECTSYNCSGIXPROC __glewXChannelRectSyncSGIX;\r\nGLXEW_FUN_EXPORT PFNGLXQUERYCHANNELDELTASSGIXPROC __glewXQueryChannelDeltasSGIX;\r\nGLXEW_FUN_EXPORT PFNGLXQUERYCHANNELRECTSGIXPROC __glewXQueryChannelRectSGIX;\r\n\r\nGLXEW_FUN_EXPORT PFNGLXCUSHIONSGIPROC __glewXCushionSGI;\r\n\r\nGLXEW_FUN_EXPORT PFNGLXGETCURRENTREADDRAWABLESGIPROC __glewXGetCurrentReadDrawableSGI;\r\nGLXEW_FUN_EXPORT PFNGLXMAKECURRENTREADSGIPROC __glewXMakeCurrentReadSGI;\r\n\r\nGLXEW_FUN_EXPORT PFNGLXSWAPINTERVALSGIPROC __glewXSwapIntervalSGI;\r\n\r\nGLXEW_FUN_EXPORT PFNGLXGETVIDEOSYNCSGIPROC __glewXGetVideoSyncSGI;\r\nGLXEW_FUN_EXPORT PFNGLXWAITVIDEOSYNCSGIPROC __glewXWaitVideoSyncSGI;\r\n\r\nGLXEW_FUN_EXPORT PFNGLXGETTRANSPARENTINDEXSUNPROC __glewXGetTransparentIndexSUN;\r\n\r\nGLXEW_FUN_EXPORT PFNGLXGETVIDEORESIZESUNPROC __glewXGetVideoResizeSUN;\r\nGLXEW_FUN_EXPORT PFNGLXVIDEORESIZESUNPROC __glewXVideoResizeSUN;\r\n\r\n#if defined(GLEW_MX)\r\nstruct GLXEWContextStruct\r\n{\r\n#endif /* GLEW_MX */\r\n\r\nGLXEW_VAR_EXPORT GLboolean __GLXEW_VERSION_1_0;\r\nGLXEW_VAR_EXPORT GLboolean __GLXEW_VERSION_1_1;\r\nGLXEW_VAR_EXPORT GLboolean __GLXEW_VERSION_1_2;\r\nGLXEW_VAR_EXPORT GLboolean __GLXEW_VERSION_1_3;\r\nGLXEW_VAR_EXPORT GLboolean __GLXEW_VERSION_1_4;\r\nGLXEW_VAR_EXPORT GLboolean __GLXEW_3DFX_multisample;\r\nGLXEW_VAR_EXPORT GLboolean __GLXEW_AMD_gpu_association;\r\nGLXEW_VAR_EXPORT GLboolean __GLXEW_ARB_context_flush_control;\r\nGLXEW_VAR_EXPORT GLboolean __GLXEW_ARB_create_context;\r\nGLXEW_VAR_EXPORT GLboolean __GLXEW_ARB_create_context_profile;\r\nGLXEW_VAR_EXPORT GLboolean __GLXEW_ARB_create_context_robustness;\r\nGLXEW_VAR_EXPORT GLboolean __GLXEW_ARB_fbconfig_float;\r\nGLXEW_VAR_EXPORT GLboolean __GLXEW_ARB_framebuffer_sRGB;\r\nGLXEW_VAR_EXPORT GLboolean __GLXEW_ARB_get_proc_address;\r\nGLXEW_VAR_EXPORT GLboolean __GLXEW_ARB_multisample;\r\nGLXEW_VAR_EXPORT GLboolean __GLXEW_ARB_robustness_application_isolation;\r\nGLXEW_VAR_EXPORT GLboolean __GLXEW_ARB_robustness_share_group_isolation;\r\nGLXEW_VAR_EXPORT GLboolean __GLXEW_ARB_vertex_buffer_object;\r\nGLXEW_VAR_EXPORT GLboolean __GLXEW_ATI_pixel_format_float;\r\nGLXEW_VAR_EXPORT GLboolean __GLXEW_ATI_render_texture;\r\nGLXEW_VAR_EXPORT GLboolean __GLXEW_EXT_buffer_age;\r\nGLXEW_VAR_EXPORT GLboolean __GLXEW_EXT_create_context_es2_profile;\r\nGLXEW_VAR_EXPORT GLboolean __GLXEW_EXT_create_context_es_profile;\r\nGLXEW_VAR_EXPORT GLboolean __GLXEW_EXT_fbconfig_packed_float;\r\nGLXEW_VAR_EXPORT GLboolean __GLXEW_EXT_framebuffer_sRGB;\r\nGLXEW_VAR_EXPORT GLboolean __GLXEW_EXT_import_context;\r\nGLXEW_VAR_EXPORT GLboolean __GLXEW_EXT_scene_marker;\r\nGLXEW_VAR_EXPORT GLboolean __GLXEW_EXT_stereo_tree;\r\nGLXEW_VAR_EXPORT GLboolean __GLXEW_EXT_swap_control;\r\nGLXEW_VAR_EXPORT GLboolean __GLXEW_EXT_swap_control_tear;\r\nGLXEW_VAR_EXPORT GLboolean __GLXEW_EXT_texture_from_pixmap;\r\nGLXEW_VAR_EXPORT GLboolean __GLXEW_EXT_visual_info;\r\nGLXEW_VAR_EXPORT GLboolean __GLXEW_EXT_visual_rating;\r\nGLXEW_VAR_EXPORT GLboolean __GLXEW_INTEL_swap_event;\r\nGLXEW_VAR_EXPORT GLboolean __GLXEW_MESA_agp_offset;\r\nGLXEW_VAR_EXPORT GLboolean __GLXEW_MESA_copy_sub_buffer;\r\nGLXEW_VAR_EXPORT GLboolean __GLXEW_MESA_pixmap_colormap;\r\nGLXEW_VAR_EXPORT GLboolean __GLXEW_MESA_query_renderer;\r\nGLXEW_VAR_EXPORT GLboolean __GLXEW_MESA_release_buffers;\r\nGLXEW_VAR_EXPORT GLboolean __GLXEW_MESA_set_3dfx_mode;\r\nGLXEW_VAR_EXPORT GLboolean __GLXEW_MESA_swap_control;\r\nGLXEW_VAR_EXPORT GLboolean __GLXEW_NV_copy_buffer;\r\nGLXEW_VAR_EXPORT GLboolean __GLXEW_NV_copy_image;\r\nGLXEW_VAR_EXPORT GLboolean __GLXEW_NV_delay_before_swap;\r\nGLXEW_VAR_EXPORT GLboolean __GLXEW_NV_float_buffer;\r\nGLXEW_VAR_EXPORT GLboolean __GLXEW_NV_multisample_coverage;\r\nGLXEW_VAR_EXPORT GLboolean __GLXEW_NV_present_video;\r\nGLXEW_VAR_EXPORT GLboolean __GLXEW_NV_swap_group;\r\nGLXEW_VAR_EXPORT GLboolean __GLXEW_NV_vertex_array_range;\r\nGLXEW_VAR_EXPORT GLboolean __GLXEW_NV_video_capture;\r\nGLXEW_VAR_EXPORT GLboolean __GLXEW_NV_video_out;\r\nGLXEW_VAR_EXPORT GLboolean __GLXEW_OML_swap_method;\r\nGLXEW_VAR_EXPORT GLboolean __GLXEW_OML_sync_control;\r\nGLXEW_VAR_EXPORT GLboolean __GLXEW_SGIS_blended_overlay;\r\nGLXEW_VAR_EXPORT GLboolean __GLXEW_SGIS_color_range;\r\nGLXEW_VAR_EXPORT GLboolean __GLXEW_SGIS_multisample;\r\nGLXEW_VAR_EXPORT GLboolean __GLXEW_SGIS_shared_multisample;\r\nGLXEW_VAR_EXPORT GLboolean __GLXEW_SGIX_fbconfig;\r\nGLXEW_VAR_EXPORT GLboolean __GLXEW_SGIX_hyperpipe;\r\nGLXEW_VAR_EXPORT GLboolean __GLXEW_SGIX_pbuffer;\r\nGLXEW_VAR_EXPORT GLboolean __GLXEW_SGIX_swap_barrier;\r\nGLXEW_VAR_EXPORT GLboolean __GLXEW_SGIX_swap_group;\r\nGLXEW_VAR_EXPORT GLboolean __GLXEW_SGIX_video_resize;\r\nGLXEW_VAR_EXPORT GLboolean __GLXEW_SGIX_visual_select_group;\r\nGLXEW_VAR_EXPORT GLboolean __GLXEW_SGI_cushion;\r\nGLXEW_VAR_EXPORT GLboolean __GLXEW_SGI_make_current_read;\r\nGLXEW_VAR_EXPORT GLboolean __GLXEW_SGI_swap_control;\r\nGLXEW_VAR_EXPORT GLboolean __GLXEW_SGI_video_sync;\r\nGLXEW_VAR_EXPORT GLboolean __GLXEW_SUN_get_transparent_index;\r\nGLXEW_VAR_EXPORT GLboolean __GLXEW_SUN_video_resize;\r\n\r\n#ifdef GLEW_MX\r\n}; /* GLXEWContextStruct */\r\n#endif /* GLEW_MX */\r\n\r\n/* ------------------------------------------------------------------------ */\r\n\r\n#ifdef GLEW_MX\r\n\r\ntypedef struct GLXEWContextStruct GLXEWContext;\r\nGLEWAPI GLenum GLEWAPIENTRY glxewContextInit (GLXEWContext *ctx);\r\nGLEWAPI GLboolean GLEWAPIENTRY glxewContextIsSupported (const GLXEWContext *ctx, const char *name);\r\n\r\n#define glxewInit() glxewContextInit(glxewGetContext())\r\n#define glxewIsSupported(x) glxewContextIsSupported(glxewGetContext(), x)\r\n\r\n#define GLXEW_GET_VAR(x) (*(const GLboolean*)&(glxewGetContext()->x))\r\n#define GLXEW_GET_FUN(x) x\r\n\r\n#else /* GLEW_MX */\r\n\r\nGLEWAPI GLenum GLEWAPIENTRY glxewInit ();\r\nGLEWAPI GLboolean GLEWAPIENTRY glxewIsSupported (const char *name);\r\n\r\n#define GLXEW_GET_VAR(x) (*(const GLboolean*)&x)\r\n#define GLXEW_GET_FUN(x) x\r\n\r\n#endif /* GLEW_MX */\r\n\r\nGLEWAPI GLboolean GLEWAPIENTRY glxewGetExtension (const char *name);\r\n\r\n#ifdef __cplusplus\r\n}\r\n#endif\r\n\r\n#endif /* __glxew_h__ */\r\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/GL/wglew.h",
    "content": "/*\r\n** The OpenGL Extension Wrangler Library\r\n** Copyright (C) 2008-2015, Nigel Stewart <nigels[]users sourceforge net>\r\n** Copyright (C) 2002-2008, Milan Ikits <milan ikits[]ieee org>\r\n** Copyright (C) 2002-2008, Marcelo E. Magallon <mmagallo[]debian org>\r\n** Copyright (C) 2002, Lev Povalahev\r\n** All rights reserved.\r\n** \r\n** Redistribution and use in source and binary forms, with or without \r\n** modification, are permitted provided that the following conditions are met:\r\n** \r\n** * Redistributions of source code must retain the above copyright notice, \r\n**   this list of conditions and the following disclaimer.\r\n** * Redistributions in binary form must reproduce the above copyright notice, \r\n**   this list of conditions and the following disclaimer in the documentation \r\n**   and/or other materials provided with the distribution.\r\n** * The name of the author may be used to endorse or promote products \r\n**   derived from this software without specific prior written permission.\r\n**\r\n** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" \r\n** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE \r\n** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r\n** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE \r\n** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR \r\n** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF \r\n** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\r\n** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\r\n** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\r\n** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF\r\n** THE POSSIBILITY OF SUCH DAMAGE.\r\n*/\r\n\r\n/*\r\n** Copyright (c) 2007 The Khronos Group Inc.\r\n** \r\n** Permission is hereby granted, free of charge, to any person obtaining a\r\n** copy of this software and/or associated documentation files (the\r\n** \"Materials\"), to deal in the Materials without restriction, including\r\n** without limitation the rights to use, copy, modify, merge, publish,\r\n** distribute, sublicense, and/or sell copies of the Materials, and to\r\n** permit persons to whom the Materials are furnished to do so, subject to\r\n** the following conditions:\r\n** \r\n** The above copyright notice and this permission notice shall be included\r\n** in all copies or substantial portions of the Materials.\r\n** \r\n** THE MATERIALS ARE PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\r\n** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r\n** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\r\n** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\r\n** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\r\n** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\r\n** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.\r\n*/\r\n\r\n#ifndef __wglew_h__\r\n#define __wglew_h__\r\n#define __WGLEW_H__\r\n\r\n#ifdef __wglext_h_\r\n#error wglext.h included before wglew.h\r\n#endif\r\n\r\n#define __wglext_h_\r\n\r\n#if !defined(WINAPI)\r\n#  ifndef WIN32_LEAN_AND_MEAN\r\n#    define WIN32_LEAN_AND_MEAN 1\r\n#  endif\r\n#include <windows.h>\r\n#  undef WIN32_LEAN_AND_MEAN\r\n#endif\r\n\r\n/*\r\n * GLEW_STATIC needs to be set when using the static version.\r\n * GLEW_BUILD is set when building the DLL version.\r\n */\r\n#ifdef GLEW_STATIC\r\n#  define GLEWAPI extern\r\n#else\r\n#  ifdef GLEW_BUILD\r\n#    define GLEWAPI extern __declspec(dllexport)\r\n#  else\r\n#    define GLEWAPI extern __declspec(dllimport)\r\n#  endif\r\n#endif\r\n\r\n#ifdef __cplusplus\r\nextern \"C\" {\r\n#endif\r\n\r\n/* -------------------------- WGL_3DFX_multisample ------------------------- */\r\n\r\n#ifndef WGL_3DFX_multisample\r\n#define WGL_3DFX_multisample 1\r\n\r\n#define WGL_SAMPLE_BUFFERS_3DFX 0x2060\r\n#define WGL_SAMPLES_3DFX 0x2061\r\n\r\n#define WGLEW_3DFX_multisample WGLEW_GET_VAR(__WGLEW_3DFX_multisample)\r\n\r\n#endif /* WGL_3DFX_multisample */\r\n\r\n/* ------------------------- WGL_3DL_stereo_control ------------------------ */\r\n\r\n#ifndef WGL_3DL_stereo_control\r\n#define WGL_3DL_stereo_control 1\r\n\r\n#define WGL_STEREO_EMITTER_ENABLE_3DL 0x2055\r\n#define WGL_STEREO_EMITTER_DISABLE_3DL 0x2056\r\n#define WGL_STEREO_POLARITY_NORMAL_3DL 0x2057\r\n#define WGL_STEREO_POLARITY_INVERT_3DL 0x2058\r\n\r\ntypedef BOOL (WINAPI * PFNWGLSETSTEREOEMITTERSTATE3DLPROC) (HDC hDC, UINT uState);\r\n\r\n#define wglSetStereoEmitterState3DL WGLEW_GET_FUN(__wglewSetStereoEmitterState3DL)\r\n\r\n#define WGLEW_3DL_stereo_control WGLEW_GET_VAR(__WGLEW_3DL_stereo_control)\r\n\r\n#endif /* WGL_3DL_stereo_control */\r\n\r\n/* ------------------------ WGL_AMD_gpu_association ------------------------ */\r\n\r\n#ifndef WGL_AMD_gpu_association\r\n#define WGL_AMD_gpu_association 1\r\n\r\n#define WGL_GPU_VENDOR_AMD 0x1F00\r\n#define WGL_GPU_RENDERER_STRING_AMD 0x1F01\r\n#define WGL_GPU_OPENGL_VERSION_STRING_AMD 0x1F02\r\n#define WGL_GPU_FASTEST_TARGET_GPUS_AMD 0x21A2\r\n#define WGL_GPU_RAM_AMD 0x21A3\r\n#define WGL_GPU_CLOCK_AMD 0x21A4\r\n#define WGL_GPU_NUM_PIPES_AMD 0x21A5\r\n#define WGL_GPU_NUM_SIMD_AMD 0x21A6\r\n#define WGL_GPU_NUM_RB_AMD 0x21A7\r\n#define WGL_GPU_NUM_SPI_AMD 0x21A8\r\n\r\ntypedef VOID (WINAPI * PFNWGLBLITCONTEXTFRAMEBUFFERAMDPROC) (HGLRC dstCtx, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);\r\ntypedef HGLRC (WINAPI * PFNWGLCREATEASSOCIATEDCONTEXTAMDPROC) (UINT id);\r\ntypedef HGLRC (WINAPI * PFNWGLCREATEASSOCIATEDCONTEXTATTRIBSAMDPROC) (UINT id, HGLRC hShareContext, const int* attribList);\r\ntypedef BOOL (WINAPI * PFNWGLDELETEASSOCIATEDCONTEXTAMDPROC) (HGLRC hglrc);\r\ntypedef UINT (WINAPI * PFNWGLGETCONTEXTGPUIDAMDPROC) (HGLRC hglrc);\r\ntypedef HGLRC (WINAPI * PFNWGLGETCURRENTASSOCIATEDCONTEXTAMDPROC) (void);\r\ntypedef UINT (WINAPI * PFNWGLGETGPUIDSAMDPROC) (UINT maxCount, UINT* ids);\r\ntypedef INT (WINAPI * PFNWGLGETGPUINFOAMDPROC) (UINT id, INT property, GLenum dataType, UINT size, void* data);\r\ntypedef BOOL (WINAPI * PFNWGLMAKEASSOCIATEDCONTEXTCURRENTAMDPROC) (HGLRC hglrc);\r\n\r\n#define wglBlitContextFramebufferAMD WGLEW_GET_FUN(__wglewBlitContextFramebufferAMD)\r\n#define wglCreateAssociatedContextAMD WGLEW_GET_FUN(__wglewCreateAssociatedContextAMD)\r\n#define wglCreateAssociatedContextAttribsAMD WGLEW_GET_FUN(__wglewCreateAssociatedContextAttribsAMD)\r\n#define wglDeleteAssociatedContextAMD WGLEW_GET_FUN(__wglewDeleteAssociatedContextAMD)\r\n#define wglGetContextGPUIDAMD WGLEW_GET_FUN(__wglewGetContextGPUIDAMD)\r\n#define wglGetCurrentAssociatedContextAMD WGLEW_GET_FUN(__wglewGetCurrentAssociatedContextAMD)\r\n#define wglGetGPUIDsAMD WGLEW_GET_FUN(__wglewGetGPUIDsAMD)\r\n#define wglGetGPUInfoAMD WGLEW_GET_FUN(__wglewGetGPUInfoAMD)\r\n#define wglMakeAssociatedContextCurrentAMD WGLEW_GET_FUN(__wglewMakeAssociatedContextCurrentAMD)\r\n\r\n#define WGLEW_AMD_gpu_association WGLEW_GET_VAR(__WGLEW_AMD_gpu_association)\r\n\r\n#endif /* WGL_AMD_gpu_association */\r\n\r\n/* ------------------------- WGL_ARB_buffer_region ------------------------- */\r\n\r\n#ifndef WGL_ARB_buffer_region\r\n#define WGL_ARB_buffer_region 1\r\n\r\n#define WGL_FRONT_COLOR_BUFFER_BIT_ARB 0x00000001\r\n#define WGL_BACK_COLOR_BUFFER_BIT_ARB 0x00000002\r\n#define WGL_DEPTH_BUFFER_BIT_ARB 0x00000004\r\n#define WGL_STENCIL_BUFFER_BIT_ARB 0x00000008\r\n\r\ntypedef HANDLE (WINAPI * PFNWGLCREATEBUFFERREGIONARBPROC) (HDC hDC, int iLayerPlane, UINT uType);\r\ntypedef VOID (WINAPI * PFNWGLDELETEBUFFERREGIONARBPROC) (HANDLE hRegion);\r\ntypedef BOOL (WINAPI * PFNWGLRESTOREBUFFERREGIONARBPROC) (HANDLE hRegion, int x, int y, int width, int height, int xSrc, int ySrc);\r\ntypedef BOOL (WINAPI * PFNWGLSAVEBUFFERREGIONARBPROC) (HANDLE hRegion, int x, int y, int width, int height);\r\n\r\n#define wglCreateBufferRegionARB WGLEW_GET_FUN(__wglewCreateBufferRegionARB)\r\n#define wglDeleteBufferRegionARB WGLEW_GET_FUN(__wglewDeleteBufferRegionARB)\r\n#define wglRestoreBufferRegionARB WGLEW_GET_FUN(__wglewRestoreBufferRegionARB)\r\n#define wglSaveBufferRegionARB WGLEW_GET_FUN(__wglewSaveBufferRegionARB)\r\n\r\n#define WGLEW_ARB_buffer_region WGLEW_GET_VAR(__WGLEW_ARB_buffer_region)\r\n\r\n#endif /* WGL_ARB_buffer_region */\r\n\r\n/* --------------------- WGL_ARB_context_flush_control --------------------- */\r\n\r\n#ifndef WGL_ARB_context_flush_control\r\n#define WGL_ARB_context_flush_control 1\r\n\r\n#define WGL_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB 0x0000\r\n#define WGL_CONTEXT_RELEASE_BEHAVIOR_ARB 0x2097\r\n#define WGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB 0x2098\r\n\r\n#define WGLEW_ARB_context_flush_control WGLEW_GET_VAR(__WGLEW_ARB_context_flush_control)\r\n\r\n#endif /* WGL_ARB_context_flush_control */\r\n\r\n/* ------------------------- WGL_ARB_create_context ------------------------ */\r\n\r\n#ifndef WGL_ARB_create_context\r\n#define WGL_ARB_create_context 1\r\n\r\n#define WGL_CONTEXT_DEBUG_BIT_ARB 0x0001\r\n#define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x0002\r\n#define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091\r\n#define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092\r\n#define WGL_CONTEXT_LAYER_PLANE_ARB 0x2093\r\n#define WGL_CONTEXT_FLAGS_ARB 0x2094\r\n#define ERROR_INVALID_VERSION_ARB 0x2095\r\n#define ERROR_INVALID_PROFILE_ARB 0x2096\r\n\r\ntypedef HGLRC (WINAPI * PFNWGLCREATECONTEXTATTRIBSARBPROC) (HDC hDC, HGLRC hShareContext, const int* attribList);\r\n\r\n#define wglCreateContextAttribsARB WGLEW_GET_FUN(__wglewCreateContextAttribsARB)\r\n\r\n#define WGLEW_ARB_create_context WGLEW_GET_VAR(__WGLEW_ARB_create_context)\r\n\r\n#endif /* WGL_ARB_create_context */\r\n\r\n/* --------------------- WGL_ARB_create_context_profile -------------------- */\r\n\r\n#ifndef WGL_ARB_create_context_profile\r\n#define WGL_ARB_create_context_profile 1\r\n\r\n#define WGL_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001\r\n#define WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002\r\n#define WGL_CONTEXT_PROFILE_MASK_ARB 0x9126\r\n\r\n#define WGLEW_ARB_create_context_profile WGLEW_GET_VAR(__WGLEW_ARB_create_context_profile)\r\n\r\n#endif /* WGL_ARB_create_context_profile */\r\n\r\n/* ------------------- WGL_ARB_create_context_robustness ------------------- */\r\n\r\n#ifndef WGL_ARB_create_context_robustness\r\n#define WGL_ARB_create_context_robustness 1\r\n\r\n#define WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB 0x00000004\r\n#define WGL_LOSE_CONTEXT_ON_RESET_ARB 0x8252\r\n#define WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB 0x8256\r\n#define WGL_NO_RESET_NOTIFICATION_ARB 0x8261\r\n\r\n#define WGLEW_ARB_create_context_robustness WGLEW_GET_VAR(__WGLEW_ARB_create_context_robustness)\r\n\r\n#endif /* WGL_ARB_create_context_robustness */\r\n\r\n/* ----------------------- WGL_ARB_extensions_string ----------------------- */\r\n\r\n#ifndef WGL_ARB_extensions_string\r\n#define WGL_ARB_extensions_string 1\r\n\r\ntypedef const char* (WINAPI * PFNWGLGETEXTENSIONSSTRINGARBPROC) (HDC hdc);\r\n\r\n#define wglGetExtensionsStringARB WGLEW_GET_FUN(__wglewGetExtensionsStringARB)\r\n\r\n#define WGLEW_ARB_extensions_string WGLEW_GET_VAR(__WGLEW_ARB_extensions_string)\r\n\r\n#endif /* WGL_ARB_extensions_string */\r\n\r\n/* ------------------------ WGL_ARB_framebuffer_sRGB ----------------------- */\r\n\r\n#ifndef WGL_ARB_framebuffer_sRGB\r\n#define WGL_ARB_framebuffer_sRGB 1\r\n\r\n#define WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20A9\r\n\r\n#define WGLEW_ARB_framebuffer_sRGB WGLEW_GET_VAR(__WGLEW_ARB_framebuffer_sRGB)\r\n\r\n#endif /* WGL_ARB_framebuffer_sRGB */\r\n\r\n/* ----------------------- WGL_ARB_make_current_read ----------------------- */\r\n\r\n#ifndef WGL_ARB_make_current_read\r\n#define WGL_ARB_make_current_read 1\r\n\r\n#define ERROR_INVALID_PIXEL_TYPE_ARB 0x2043\r\n#define ERROR_INCOMPATIBLE_DEVICE_CONTEXTS_ARB 0x2054\r\n\r\ntypedef HDC (WINAPI * PFNWGLGETCURRENTREADDCARBPROC) (VOID);\r\ntypedef BOOL (WINAPI * PFNWGLMAKECONTEXTCURRENTARBPROC) (HDC hDrawDC, HDC hReadDC, HGLRC hglrc);\r\n\r\n#define wglGetCurrentReadDCARB WGLEW_GET_FUN(__wglewGetCurrentReadDCARB)\r\n#define wglMakeContextCurrentARB WGLEW_GET_FUN(__wglewMakeContextCurrentARB)\r\n\r\n#define WGLEW_ARB_make_current_read WGLEW_GET_VAR(__WGLEW_ARB_make_current_read)\r\n\r\n#endif /* WGL_ARB_make_current_read */\r\n\r\n/* -------------------------- WGL_ARB_multisample -------------------------- */\r\n\r\n#ifndef WGL_ARB_multisample\r\n#define WGL_ARB_multisample 1\r\n\r\n#define WGL_SAMPLE_BUFFERS_ARB 0x2041\r\n#define WGL_SAMPLES_ARB 0x2042\r\n\r\n#define WGLEW_ARB_multisample WGLEW_GET_VAR(__WGLEW_ARB_multisample)\r\n\r\n#endif /* WGL_ARB_multisample */\r\n\r\n/* ---------------------------- WGL_ARB_pbuffer ---------------------------- */\r\n\r\n#ifndef WGL_ARB_pbuffer\r\n#define WGL_ARB_pbuffer 1\r\n\r\n#define WGL_DRAW_TO_PBUFFER_ARB 0x202D\r\n#define WGL_MAX_PBUFFER_PIXELS_ARB 0x202E\r\n#define WGL_MAX_PBUFFER_WIDTH_ARB 0x202F\r\n#define WGL_MAX_PBUFFER_HEIGHT_ARB 0x2030\r\n#define WGL_PBUFFER_LARGEST_ARB 0x2033\r\n#define WGL_PBUFFER_WIDTH_ARB 0x2034\r\n#define WGL_PBUFFER_HEIGHT_ARB 0x2035\r\n#define WGL_PBUFFER_LOST_ARB 0x2036\r\n\r\nDECLARE_HANDLE(HPBUFFERARB);\r\n\r\ntypedef HPBUFFERARB (WINAPI * PFNWGLCREATEPBUFFERARBPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int* piAttribList);\r\ntypedef BOOL (WINAPI * PFNWGLDESTROYPBUFFERARBPROC) (HPBUFFERARB hPbuffer);\r\ntypedef HDC (WINAPI * PFNWGLGETPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer);\r\ntypedef BOOL (WINAPI * PFNWGLQUERYPBUFFERARBPROC) (HPBUFFERARB hPbuffer, int iAttribute, int* piValue);\r\ntypedef int (WINAPI * PFNWGLRELEASEPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer, HDC hDC);\r\n\r\n#define wglCreatePbufferARB WGLEW_GET_FUN(__wglewCreatePbufferARB)\r\n#define wglDestroyPbufferARB WGLEW_GET_FUN(__wglewDestroyPbufferARB)\r\n#define wglGetPbufferDCARB WGLEW_GET_FUN(__wglewGetPbufferDCARB)\r\n#define wglQueryPbufferARB WGLEW_GET_FUN(__wglewQueryPbufferARB)\r\n#define wglReleasePbufferDCARB WGLEW_GET_FUN(__wglewReleasePbufferDCARB)\r\n\r\n#define WGLEW_ARB_pbuffer WGLEW_GET_VAR(__WGLEW_ARB_pbuffer)\r\n\r\n#endif /* WGL_ARB_pbuffer */\r\n\r\n/* -------------------------- WGL_ARB_pixel_format ------------------------- */\r\n\r\n#ifndef WGL_ARB_pixel_format\r\n#define WGL_ARB_pixel_format 1\r\n\r\n#define WGL_NUMBER_PIXEL_FORMATS_ARB 0x2000\r\n#define WGL_DRAW_TO_WINDOW_ARB 0x2001\r\n#define WGL_DRAW_TO_BITMAP_ARB 0x2002\r\n#define WGL_ACCELERATION_ARB 0x2003\r\n#define WGL_NEED_PALETTE_ARB 0x2004\r\n#define WGL_NEED_SYSTEM_PALETTE_ARB 0x2005\r\n#define WGL_SWAP_LAYER_BUFFERS_ARB 0x2006\r\n#define WGL_SWAP_METHOD_ARB 0x2007\r\n#define WGL_NUMBER_OVERLAYS_ARB 0x2008\r\n#define WGL_NUMBER_UNDERLAYS_ARB 0x2009\r\n#define WGL_TRANSPARENT_ARB 0x200A\r\n#define WGL_SHARE_DEPTH_ARB 0x200C\r\n#define WGL_SHARE_STENCIL_ARB 0x200D\r\n#define WGL_SHARE_ACCUM_ARB 0x200E\r\n#define WGL_SUPPORT_GDI_ARB 0x200F\r\n#define WGL_SUPPORT_OPENGL_ARB 0x2010\r\n#define WGL_DOUBLE_BUFFER_ARB 0x2011\r\n#define WGL_STEREO_ARB 0x2012\r\n#define WGL_PIXEL_TYPE_ARB 0x2013\r\n#define WGL_COLOR_BITS_ARB 0x2014\r\n#define WGL_RED_BITS_ARB 0x2015\r\n#define WGL_RED_SHIFT_ARB 0x2016\r\n#define WGL_GREEN_BITS_ARB 0x2017\r\n#define WGL_GREEN_SHIFT_ARB 0x2018\r\n#define WGL_BLUE_BITS_ARB 0x2019\r\n#define WGL_BLUE_SHIFT_ARB 0x201A\r\n#define WGL_ALPHA_BITS_ARB 0x201B\r\n#define WGL_ALPHA_SHIFT_ARB 0x201C\r\n#define WGL_ACCUM_BITS_ARB 0x201D\r\n#define WGL_ACCUM_RED_BITS_ARB 0x201E\r\n#define WGL_ACCUM_GREEN_BITS_ARB 0x201F\r\n#define WGL_ACCUM_BLUE_BITS_ARB 0x2020\r\n#define WGL_ACCUM_ALPHA_BITS_ARB 0x2021\r\n#define WGL_DEPTH_BITS_ARB 0x2022\r\n#define WGL_STENCIL_BITS_ARB 0x2023\r\n#define WGL_AUX_BUFFERS_ARB 0x2024\r\n#define WGL_NO_ACCELERATION_ARB 0x2025\r\n#define WGL_GENERIC_ACCELERATION_ARB 0x2026\r\n#define WGL_FULL_ACCELERATION_ARB 0x2027\r\n#define WGL_SWAP_EXCHANGE_ARB 0x2028\r\n#define WGL_SWAP_COPY_ARB 0x2029\r\n#define WGL_SWAP_UNDEFINED_ARB 0x202A\r\n#define WGL_TYPE_RGBA_ARB 0x202B\r\n#define WGL_TYPE_COLORINDEX_ARB 0x202C\r\n#define WGL_TRANSPARENT_RED_VALUE_ARB 0x2037\r\n#define WGL_TRANSPARENT_GREEN_VALUE_ARB 0x2038\r\n#define WGL_TRANSPARENT_BLUE_VALUE_ARB 0x2039\r\n#define WGL_TRANSPARENT_ALPHA_VALUE_ARB 0x203A\r\n#define WGL_TRANSPARENT_INDEX_VALUE_ARB 0x203B\r\n\r\ntypedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATARBPROC) (HDC hdc, const int* piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats);\r\ntypedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBFVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int* piAttributes, FLOAT *pfValues);\r\ntypedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int* piAttributes, int *piValues);\r\n\r\n#define wglChoosePixelFormatARB WGLEW_GET_FUN(__wglewChoosePixelFormatARB)\r\n#define wglGetPixelFormatAttribfvARB WGLEW_GET_FUN(__wglewGetPixelFormatAttribfvARB)\r\n#define wglGetPixelFormatAttribivARB WGLEW_GET_FUN(__wglewGetPixelFormatAttribivARB)\r\n\r\n#define WGLEW_ARB_pixel_format WGLEW_GET_VAR(__WGLEW_ARB_pixel_format)\r\n\r\n#endif /* WGL_ARB_pixel_format */\r\n\r\n/* ----------------------- WGL_ARB_pixel_format_float ---------------------- */\r\n\r\n#ifndef WGL_ARB_pixel_format_float\r\n#define WGL_ARB_pixel_format_float 1\r\n\r\n#define WGL_TYPE_RGBA_FLOAT_ARB 0x21A0\r\n\r\n#define WGLEW_ARB_pixel_format_float WGLEW_GET_VAR(__WGLEW_ARB_pixel_format_float)\r\n\r\n#endif /* WGL_ARB_pixel_format_float */\r\n\r\n/* ------------------------- WGL_ARB_render_texture ------------------------ */\r\n\r\n#ifndef WGL_ARB_render_texture\r\n#define WGL_ARB_render_texture 1\r\n\r\n#define WGL_BIND_TO_TEXTURE_RGB_ARB 0x2070\r\n#define WGL_BIND_TO_TEXTURE_RGBA_ARB 0x2071\r\n#define WGL_TEXTURE_FORMAT_ARB 0x2072\r\n#define WGL_TEXTURE_TARGET_ARB 0x2073\r\n#define WGL_MIPMAP_TEXTURE_ARB 0x2074\r\n#define WGL_TEXTURE_RGB_ARB 0x2075\r\n#define WGL_TEXTURE_RGBA_ARB 0x2076\r\n#define WGL_NO_TEXTURE_ARB 0x2077\r\n#define WGL_TEXTURE_CUBE_MAP_ARB 0x2078\r\n#define WGL_TEXTURE_1D_ARB 0x2079\r\n#define WGL_TEXTURE_2D_ARB 0x207A\r\n#define WGL_MIPMAP_LEVEL_ARB 0x207B\r\n#define WGL_CUBE_MAP_FACE_ARB 0x207C\r\n#define WGL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x207D\r\n#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x207E\r\n#define WGL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x207F\r\n#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x2080\r\n#define WGL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x2081\r\n#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x2082\r\n#define WGL_FRONT_LEFT_ARB 0x2083\r\n#define WGL_FRONT_RIGHT_ARB 0x2084\r\n#define WGL_BACK_LEFT_ARB 0x2085\r\n#define WGL_BACK_RIGHT_ARB 0x2086\r\n#define WGL_AUX0_ARB 0x2087\r\n#define WGL_AUX1_ARB 0x2088\r\n#define WGL_AUX2_ARB 0x2089\r\n#define WGL_AUX3_ARB 0x208A\r\n#define WGL_AUX4_ARB 0x208B\r\n#define WGL_AUX5_ARB 0x208C\r\n#define WGL_AUX6_ARB 0x208D\r\n#define WGL_AUX7_ARB 0x208E\r\n#define WGL_AUX8_ARB 0x208F\r\n#define WGL_AUX9_ARB 0x2090\r\n\r\ntypedef BOOL (WINAPI * PFNWGLBINDTEXIMAGEARBPROC) (HPBUFFERARB hPbuffer, int iBuffer);\r\ntypedef BOOL (WINAPI * PFNWGLRELEASETEXIMAGEARBPROC) (HPBUFFERARB hPbuffer, int iBuffer);\r\ntypedef BOOL (WINAPI * PFNWGLSETPBUFFERATTRIBARBPROC) (HPBUFFERARB hPbuffer, const int* piAttribList);\r\n\r\n#define wglBindTexImageARB WGLEW_GET_FUN(__wglewBindTexImageARB)\r\n#define wglReleaseTexImageARB WGLEW_GET_FUN(__wglewReleaseTexImageARB)\r\n#define wglSetPbufferAttribARB WGLEW_GET_FUN(__wglewSetPbufferAttribARB)\r\n\r\n#define WGLEW_ARB_render_texture WGLEW_GET_VAR(__WGLEW_ARB_render_texture)\r\n\r\n#endif /* WGL_ARB_render_texture */\r\n\r\n/* ---------------- WGL_ARB_robustness_application_isolation --------------- */\r\n\r\n#ifndef WGL_ARB_robustness_application_isolation\r\n#define WGL_ARB_robustness_application_isolation 1\r\n\r\n#define WGL_CONTEXT_RESET_ISOLATION_BIT_ARB 0x00000008\r\n\r\n#define WGLEW_ARB_robustness_application_isolation WGLEW_GET_VAR(__WGLEW_ARB_robustness_application_isolation)\r\n\r\n#endif /* WGL_ARB_robustness_application_isolation */\r\n\r\n/* ---------------- WGL_ARB_robustness_share_group_isolation --------------- */\r\n\r\n#ifndef WGL_ARB_robustness_share_group_isolation\r\n#define WGL_ARB_robustness_share_group_isolation 1\r\n\r\n#define WGL_CONTEXT_RESET_ISOLATION_BIT_ARB 0x00000008\r\n\r\n#define WGLEW_ARB_robustness_share_group_isolation WGLEW_GET_VAR(__WGLEW_ARB_robustness_share_group_isolation)\r\n\r\n#endif /* WGL_ARB_robustness_share_group_isolation */\r\n\r\n/* ----------------------- WGL_ATI_pixel_format_float ---------------------- */\r\n\r\n#ifndef WGL_ATI_pixel_format_float\r\n#define WGL_ATI_pixel_format_float 1\r\n\r\n#define WGL_TYPE_RGBA_FLOAT_ATI 0x21A0\r\n#define GL_RGBA_FLOAT_MODE_ATI 0x8820\r\n#define GL_COLOR_CLEAR_UNCLAMPED_VALUE_ATI 0x8835\r\n\r\n#define WGLEW_ATI_pixel_format_float WGLEW_GET_VAR(__WGLEW_ATI_pixel_format_float)\r\n\r\n#endif /* WGL_ATI_pixel_format_float */\r\n\r\n/* -------------------- WGL_ATI_render_texture_rectangle ------------------- */\r\n\r\n#ifndef WGL_ATI_render_texture_rectangle\r\n#define WGL_ATI_render_texture_rectangle 1\r\n\r\n#define WGL_TEXTURE_RECTANGLE_ATI 0x21A5\r\n\r\n#define WGLEW_ATI_render_texture_rectangle WGLEW_GET_VAR(__WGLEW_ATI_render_texture_rectangle)\r\n\r\n#endif /* WGL_ATI_render_texture_rectangle */\r\n\r\n/* ------------------- WGL_EXT_create_context_es2_profile ------------------ */\r\n\r\n#ifndef WGL_EXT_create_context_es2_profile\r\n#define WGL_EXT_create_context_es2_profile 1\r\n\r\n#define WGL_CONTEXT_ES2_PROFILE_BIT_EXT 0x00000004\r\n\r\n#define WGLEW_EXT_create_context_es2_profile WGLEW_GET_VAR(__WGLEW_EXT_create_context_es2_profile)\r\n\r\n#endif /* WGL_EXT_create_context_es2_profile */\r\n\r\n/* ------------------- WGL_EXT_create_context_es_profile ------------------- */\r\n\r\n#ifndef WGL_EXT_create_context_es_profile\r\n#define WGL_EXT_create_context_es_profile 1\r\n\r\n#define WGL_CONTEXT_ES_PROFILE_BIT_EXT 0x00000004\r\n\r\n#define WGLEW_EXT_create_context_es_profile WGLEW_GET_VAR(__WGLEW_EXT_create_context_es_profile)\r\n\r\n#endif /* WGL_EXT_create_context_es_profile */\r\n\r\n/* -------------------------- WGL_EXT_depth_float -------------------------- */\r\n\r\n#ifndef WGL_EXT_depth_float\r\n#define WGL_EXT_depth_float 1\r\n\r\n#define WGL_DEPTH_FLOAT_EXT 0x2040\r\n\r\n#define WGLEW_EXT_depth_float WGLEW_GET_VAR(__WGLEW_EXT_depth_float)\r\n\r\n#endif /* WGL_EXT_depth_float */\r\n\r\n/* ---------------------- WGL_EXT_display_color_table ---------------------- */\r\n\r\n#ifndef WGL_EXT_display_color_table\r\n#define WGL_EXT_display_color_table 1\r\n\r\ntypedef GLboolean (WINAPI * PFNWGLBINDDISPLAYCOLORTABLEEXTPROC) (GLushort id);\r\ntypedef GLboolean (WINAPI * PFNWGLCREATEDISPLAYCOLORTABLEEXTPROC) (GLushort id);\r\ntypedef void (WINAPI * PFNWGLDESTROYDISPLAYCOLORTABLEEXTPROC) (GLushort id);\r\ntypedef GLboolean (WINAPI * PFNWGLLOADDISPLAYCOLORTABLEEXTPROC) (GLushort* table, GLuint length);\r\n\r\n#define wglBindDisplayColorTableEXT WGLEW_GET_FUN(__wglewBindDisplayColorTableEXT)\r\n#define wglCreateDisplayColorTableEXT WGLEW_GET_FUN(__wglewCreateDisplayColorTableEXT)\r\n#define wglDestroyDisplayColorTableEXT WGLEW_GET_FUN(__wglewDestroyDisplayColorTableEXT)\r\n#define wglLoadDisplayColorTableEXT WGLEW_GET_FUN(__wglewLoadDisplayColorTableEXT)\r\n\r\n#define WGLEW_EXT_display_color_table WGLEW_GET_VAR(__WGLEW_EXT_display_color_table)\r\n\r\n#endif /* WGL_EXT_display_color_table */\r\n\r\n/* ----------------------- WGL_EXT_extensions_string ----------------------- */\r\n\r\n#ifndef WGL_EXT_extensions_string\r\n#define WGL_EXT_extensions_string 1\r\n\r\ntypedef const char* (WINAPI * PFNWGLGETEXTENSIONSSTRINGEXTPROC) (void);\r\n\r\n#define wglGetExtensionsStringEXT WGLEW_GET_FUN(__wglewGetExtensionsStringEXT)\r\n\r\n#define WGLEW_EXT_extensions_string WGLEW_GET_VAR(__WGLEW_EXT_extensions_string)\r\n\r\n#endif /* WGL_EXT_extensions_string */\r\n\r\n/* ------------------------ WGL_EXT_framebuffer_sRGB ----------------------- */\r\n\r\n#ifndef WGL_EXT_framebuffer_sRGB\r\n#define WGL_EXT_framebuffer_sRGB 1\r\n\r\n#define WGL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x20A9\r\n\r\n#define WGLEW_EXT_framebuffer_sRGB WGLEW_GET_VAR(__WGLEW_EXT_framebuffer_sRGB)\r\n\r\n#endif /* WGL_EXT_framebuffer_sRGB */\r\n\r\n/* ----------------------- WGL_EXT_make_current_read ----------------------- */\r\n\r\n#ifndef WGL_EXT_make_current_read\r\n#define WGL_EXT_make_current_read 1\r\n\r\n#define ERROR_INVALID_PIXEL_TYPE_EXT 0x2043\r\n\r\ntypedef HDC (WINAPI * PFNWGLGETCURRENTREADDCEXTPROC) (VOID);\r\ntypedef BOOL (WINAPI * PFNWGLMAKECONTEXTCURRENTEXTPROC) (HDC hDrawDC, HDC hReadDC, HGLRC hglrc);\r\n\r\n#define wglGetCurrentReadDCEXT WGLEW_GET_FUN(__wglewGetCurrentReadDCEXT)\r\n#define wglMakeContextCurrentEXT WGLEW_GET_FUN(__wglewMakeContextCurrentEXT)\r\n\r\n#define WGLEW_EXT_make_current_read WGLEW_GET_VAR(__WGLEW_EXT_make_current_read)\r\n\r\n#endif /* WGL_EXT_make_current_read */\r\n\r\n/* -------------------------- WGL_EXT_multisample -------------------------- */\r\n\r\n#ifndef WGL_EXT_multisample\r\n#define WGL_EXT_multisample 1\r\n\r\n#define WGL_SAMPLE_BUFFERS_EXT 0x2041\r\n#define WGL_SAMPLES_EXT 0x2042\r\n\r\n#define WGLEW_EXT_multisample WGLEW_GET_VAR(__WGLEW_EXT_multisample)\r\n\r\n#endif /* WGL_EXT_multisample */\r\n\r\n/* ---------------------------- WGL_EXT_pbuffer ---------------------------- */\r\n\r\n#ifndef WGL_EXT_pbuffer\r\n#define WGL_EXT_pbuffer 1\r\n\r\n#define WGL_DRAW_TO_PBUFFER_EXT 0x202D\r\n#define WGL_MAX_PBUFFER_PIXELS_EXT 0x202E\r\n#define WGL_MAX_PBUFFER_WIDTH_EXT 0x202F\r\n#define WGL_MAX_PBUFFER_HEIGHT_EXT 0x2030\r\n#define WGL_OPTIMAL_PBUFFER_WIDTH_EXT 0x2031\r\n#define WGL_OPTIMAL_PBUFFER_HEIGHT_EXT 0x2032\r\n#define WGL_PBUFFER_LARGEST_EXT 0x2033\r\n#define WGL_PBUFFER_WIDTH_EXT 0x2034\r\n#define WGL_PBUFFER_HEIGHT_EXT 0x2035\r\n\r\nDECLARE_HANDLE(HPBUFFEREXT);\r\n\r\ntypedef HPBUFFEREXT (WINAPI * PFNWGLCREATEPBUFFEREXTPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int* piAttribList);\r\ntypedef BOOL (WINAPI * PFNWGLDESTROYPBUFFEREXTPROC) (HPBUFFEREXT hPbuffer);\r\ntypedef HDC (WINAPI * PFNWGLGETPBUFFERDCEXTPROC) (HPBUFFEREXT hPbuffer);\r\ntypedef BOOL (WINAPI * PFNWGLQUERYPBUFFEREXTPROC) (HPBUFFEREXT hPbuffer, int iAttribute, int* piValue);\r\ntypedef int (WINAPI * PFNWGLRELEASEPBUFFERDCEXTPROC) (HPBUFFEREXT hPbuffer, HDC hDC);\r\n\r\n#define wglCreatePbufferEXT WGLEW_GET_FUN(__wglewCreatePbufferEXT)\r\n#define wglDestroyPbufferEXT WGLEW_GET_FUN(__wglewDestroyPbufferEXT)\r\n#define wglGetPbufferDCEXT WGLEW_GET_FUN(__wglewGetPbufferDCEXT)\r\n#define wglQueryPbufferEXT WGLEW_GET_FUN(__wglewQueryPbufferEXT)\r\n#define wglReleasePbufferDCEXT WGLEW_GET_FUN(__wglewReleasePbufferDCEXT)\r\n\r\n#define WGLEW_EXT_pbuffer WGLEW_GET_VAR(__WGLEW_EXT_pbuffer)\r\n\r\n#endif /* WGL_EXT_pbuffer */\r\n\r\n/* -------------------------- WGL_EXT_pixel_format ------------------------- */\r\n\r\n#ifndef WGL_EXT_pixel_format\r\n#define WGL_EXT_pixel_format 1\r\n\r\n#define WGL_NUMBER_PIXEL_FORMATS_EXT 0x2000\r\n#define WGL_DRAW_TO_WINDOW_EXT 0x2001\r\n#define WGL_DRAW_TO_BITMAP_EXT 0x2002\r\n#define WGL_ACCELERATION_EXT 0x2003\r\n#define WGL_NEED_PALETTE_EXT 0x2004\r\n#define WGL_NEED_SYSTEM_PALETTE_EXT 0x2005\r\n#define WGL_SWAP_LAYER_BUFFERS_EXT 0x2006\r\n#define WGL_SWAP_METHOD_EXT 0x2007\r\n#define WGL_NUMBER_OVERLAYS_EXT 0x2008\r\n#define WGL_NUMBER_UNDERLAYS_EXT 0x2009\r\n#define WGL_TRANSPARENT_EXT 0x200A\r\n#define WGL_TRANSPARENT_VALUE_EXT 0x200B\r\n#define WGL_SHARE_DEPTH_EXT 0x200C\r\n#define WGL_SHARE_STENCIL_EXT 0x200D\r\n#define WGL_SHARE_ACCUM_EXT 0x200E\r\n#define WGL_SUPPORT_GDI_EXT 0x200F\r\n#define WGL_SUPPORT_OPENGL_EXT 0x2010\r\n#define WGL_DOUBLE_BUFFER_EXT 0x2011\r\n#define WGL_STEREO_EXT 0x2012\r\n#define WGL_PIXEL_TYPE_EXT 0x2013\r\n#define WGL_COLOR_BITS_EXT 0x2014\r\n#define WGL_RED_BITS_EXT 0x2015\r\n#define WGL_RED_SHIFT_EXT 0x2016\r\n#define WGL_GREEN_BITS_EXT 0x2017\r\n#define WGL_GREEN_SHIFT_EXT 0x2018\r\n#define WGL_BLUE_BITS_EXT 0x2019\r\n#define WGL_BLUE_SHIFT_EXT 0x201A\r\n#define WGL_ALPHA_BITS_EXT 0x201B\r\n#define WGL_ALPHA_SHIFT_EXT 0x201C\r\n#define WGL_ACCUM_BITS_EXT 0x201D\r\n#define WGL_ACCUM_RED_BITS_EXT 0x201E\r\n#define WGL_ACCUM_GREEN_BITS_EXT 0x201F\r\n#define WGL_ACCUM_BLUE_BITS_EXT 0x2020\r\n#define WGL_ACCUM_ALPHA_BITS_EXT 0x2021\r\n#define WGL_DEPTH_BITS_EXT 0x2022\r\n#define WGL_STENCIL_BITS_EXT 0x2023\r\n#define WGL_AUX_BUFFERS_EXT 0x2024\r\n#define WGL_NO_ACCELERATION_EXT 0x2025\r\n#define WGL_GENERIC_ACCELERATION_EXT 0x2026\r\n#define WGL_FULL_ACCELERATION_EXT 0x2027\r\n#define WGL_SWAP_EXCHANGE_EXT 0x2028\r\n#define WGL_SWAP_COPY_EXT 0x2029\r\n#define WGL_SWAP_UNDEFINED_EXT 0x202A\r\n#define WGL_TYPE_RGBA_EXT 0x202B\r\n#define WGL_TYPE_COLORINDEX_EXT 0x202C\r\n\r\ntypedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATEXTPROC) (HDC hdc, const int* piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats);\r\ntypedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBFVEXTPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int* piAttributes, FLOAT *pfValues);\r\ntypedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVEXTPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int* piAttributes, int *piValues);\r\n\r\n#define wglChoosePixelFormatEXT WGLEW_GET_FUN(__wglewChoosePixelFormatEXT)\r\n#define wglGetPixelFormatAttribfvEXT WGLEW_GET_FUN(__wglewGetPixelFormatAttribfvEXT)\r\n#define wglGetPixelFormatAttribivEXT WGLEW_GET_FUN(__wglewGetPixelFormatAttribivEXT)\r\n\r\n#define WGLEW_EXT_pixel_format WGLEW_GET_VAR(__WGLEW_EXT_pixel_format)\r\n\r\n#endif /* WGL_EXT_pixel_format */\r\n\r\n/* ------------------- WGL_EXT_pixel_format_packed_float ------------------- */\r\n\r\n#ifndef WGL_EXT_pixel_format_packed_float\r\n#define WGL_EXT_pixel_format_packed_float 1\r\n\r\n#define WGL_TYPE_RGBA_UNSIGNED_FLOAT_EXT 0x20A8\r\n\r\n#define WGLEW_EXT_pixel_format_packed_float WGLEW_GET_VAR(__WGLEW_EXT_pixel_format_packed_float)\r\n\r\n#endif /* WGL_EXT_pixel_format_packed_float */\r\n\r\n/* -------------------------- WGL_EXT_swap_control ------------------------- */\r\n\r\n#ifndef WGL_EXT_swap_control\r\n#define WGL_EXT_swap_control 1\r\n\r\ntypedef int (WINAPI * PFNWGLGETSWAPINTERVALEXTPROC) (void);\r\ntypedef BOOL (WINAPI * PFNWGLSWAPINTERVALEXTPROC) (int interval);\r\n\r\n#define wglGetSwapIntervalEXT WGLEW_GET_FUN(__wglewGetSwapIntervalEXT)\r\n#define wglSwapIntervalEXT WGLEW_GET_FUN(__wglewSwapIntervalEXT)\r\n\r\n#define WGLEW_EXT_swap_control WGLEW_GET_VAR(__WGLEW_EXT_swap_control)\r\n\r\n#endif /* WGL_EXT_swap_control */\r\n\r\n/* ----------------------- WGL_EXT_swap_control_tear ----------------------- */\r\n\r\n#ifndef WGL_EXT_swap_control_tear\r\n#define WGL_EXT_swap_control_tear 1\r\n\r\n#define WGLEW_EXT_swap_control_tear WGLEW_GET_VAR(__WGLEW_EXT_swap_control_tear)\r\n\r\n#endif /* WGL_EXT_swap_control_tear */\r\n\r\n/* --------------------- WGL_I3D_digital_video_control --------------------- */\r\n\r\n#ifndef WGL_I3D_digital_video_control\r\n#define WGL_I3D_digital_video_control 1\r\n\r\n#define WGL_DIGITAL_VIDEO_CURSOR_ALPHA_FRAMEBUFFER_I3D 0x2050\r\n#define WGL_DIGITAL_VIDEO_CURSOR_ALPHA_VALUE_I3D 0x2051\r\n#define WGL_DIGITAL_VIDEO_CURSOR_INCLUDED_I3D 0x2052\r\n#define WGL_DIGITAL_VIDEO_GAMMA_CORRECTED_I3D 0x2053\r\n\r\ntypedef BOOL (WINAPI * PFNWGLGETDIGITALVIDEOPARAMETERSI3DPROC) (HDC hDC, int iAttribute, int* piValue);\r\ntypedef BOOL (WINAPI * PFNWGLSETDIGITALVIDEOPARAMETERSI3DPROC) (HDC hDC, int iAttribute, const int* piValue);\r\n\r\n#define wglGetDigitalVideoParametersI3D WGLEW_GET_FUN(__wglewGetDigitalVideoParametersI3D)\r\n#define wglSetDigitalVideoParametersI3D WGLEW_GET_FUN(__wglewSetDigitalVideoParametersI3D)\r\n\r\n#define WGLEW_I3D_digital_video_control WGLEW_GET_VAR(__WGLEW_I3D_digital_video_control)\r\n\r\n#endif /* WGL_I3D_digital_video_control */\r\n\r\n/* ----------------------------- WGL_I3D_gamma ----------------------------- */\r\n\r\n#ifndef WGL_I3D_gamma\r\n#define WGL_I3D_gamma 1\r\n\r\n#define WGL_GAMMA_TABLE_SIZE_I3D 0x204E\r\n#define WGL_GAMMA_EXCLUDE_DESKTOP_I3D 0x204F\r\n\r\ntypedef BOOL (WINAPI * PFNWGLGETGAMMATABLEI3DPROC) (HDC hDC, int iEntries, USHORT* puRed, USHORT *puGreen, USHORT *puBlue);\r\ntypedef BOOL (WINAPI * PFNWGLGETGAMMATABLEPARAMETERSI3DPROC) (HDC hDC, int iAttribute, int* piValue);\r\ntypedef BOOL (WINAPI * PFNWGLSETGAMMATABLEI3DPROC) (HDC hDC, int iEntries, const USHORT* puRed, const USHORT *puGreen, const USHORT *puBlue);\r\ntypedef BOOL (WINAPI * PFNWGLSETGAMMATABLEPARAMETERSI3DPROC) (HDC hDC, int iAttribute, const int* piValue);\r\n\r\n#define wglGetGammaTableI3D WGLEW_GET_FUN(__wglewGetGammaTableI3D)\r\n#define wglGetGammaTableParametersI3D WGLEW_GET_FUN(__wglewGetGammaTableParametersI3D)\r\n#define wglSetGammaTableI3D WGLEW_GET_FUN(__wglewSetGammaTableI3D)\r\n#define wglSetGammaTableParametersI3D WGLEW_GET_FUN(__wglewSetGammaTableParametersI3D)\r\n\r\n#define WGLEW_I3D_gamma WGLEW_GET_VAR(__WGLEW_I3D_gamma)\r\n\r\n#endif /* WGL_I3D_gamma */\r\n\r\n/* ---------------------------- WGL_I3D_genlock ---------------------------- */\r\n\r\n#ifndef WGL_I3D_genlock\r\n#define WGL_I3D_genlock 1\r\n\r\n#define WGL_GENLOCK_SOURCE_MULTIVIEW_I3D 0x2044\r\n#define WGL_GENLOCK_SOURCE_EXTERNAL_SYNC_I3D 0x2045\r\n#define WGL_GENLOCK_SOURCE_EXTERNAL_FIELD_I3D 0x2046\r\n#define WGL_GENLOCK_SOURCE_EXTERNAL_TTL_I3D 0x2047\r\n#define WGL_GENLOCK_SOURCE_DIGITAL_SYNC_I3D 0x2048\r\n#define WGL_GENLOCK_SOURCE_DIGITAL_FIELD_I3D 0x2049\r\n#define WGL_GENLOCK_SOURCE_EDGE_FALLING_I3D 0x204A\r\n#define WGL_GENLOCK_SOURCE_EDGE_RISING_I3D 0x204B\r\n#define WGL_GENLOCK_SOURCE_EDGE_BOTH_I3D 0x204C\r\n\r\ntypedef BOOL (WINAPI * PFNWGLDISABLEGENLOCKI3DPROC) (HDC hDC);\r\ntypedef BOOL (WINAPI * PFNWGLENABLEGENLOCKI3DPROC) (HDC hDC);\r\ntypedef BOOL (WINAPI * PFNWGLGENLOCKSAMPLERATEI3DPROC) (HDC hDC, UINT uRate);\r\ntypedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEDELAYI3DPROC) (HDC hDC, UINT uDelay);\r\ntypedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEEDGEI3DPROC) (HDC hDC, UINT uEdge);\r\ntypedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEI3DPROC) (HDC hDC, UINT uSource);\r\ntypedef BOOL (WINAPI * PFNWGLGETGENLOCKSAMPLERATEI3DPROC) (HDC hDC, UINT* uRate);\r\ntypedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEDELAYI3DPROC) (HDC hDC, UINT* uDelay);\r\ntypedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEEDGEI3DPROC) (HDC hDC, UINT* uEdge);\r\ntypedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEI3DPROC) (HDC hDC, UINT* uSource);\r\ntypedef BOOL (WINAPI * PFNWGLISENABLEDGENLOCKI3DPROC) (HDC hDC, BOOL* pFlag);\r\ntypedef BOOL (WINAPI * PFNWGLQUERYGENLOCKMAXSOURCEDELAYI3DPROC) (HDC hDC, UINT* uMaxLineDelay, UINT *uMaxPixelDelay);\r\n\r\n#define wglDisableGenlockI3D WGLEW_GET_FUN(__wglewDisableGenlockI3D)\r\n#define wglEnableGenlockI3D WGLEW_GET_FUN(__wglewEnableGenlockI3D)\r\n#define wglGenlockSampleRateI3D WGLEW_GET_FUN(__wglewGenlockSampleRateI3D)\r\n#define wglGenlockSourceDelayI3D WGLEW_GET_FUN(__wglewGenlockSourceDelayI3D)\r\n#define wglGenlockSourceEdgeI3D WGLEW_GET_FUN(__wglewGenlockSourceEdgeI3D)\r\n#define wglGenlockSourceI3D WGLEW_GET_FUN(__wglewGenlockSourceI3D)\r\n#define wglGetGenlockSampleRateI3D WGLEW_GET_FUN(__wglewGetGenlockSampleRateI3D)\r\n#define wglGetGenlockSourceDelayI3D WGLEW_GET_FUN(__wglewGetGenlockSourceDelayI3D)\r\n#define wglGetGenlockSourceEdgeI3D WGLEW_GET_FUN(__wglewGetGenlockSourceEdgeI3D)\r\n#define wglGetGenlockSourceI3D WGLEW_GET_FUN(__wglewGetGenlockSourceI3D)\r\n#define wglIsEnabledGenlockI3D WGLEW_GET_FUN(__wglewIsEnabledGenlockI3D)\r\n#define wglQueryGenlockMaxSourceDelayI3D WGLEW_GET_FUN(__wglewQueryGenlockMaxSourceDelayI3D)\r\n\r\n#define WGLEW_I3D_genlock WGLEW_GET_VAR(__WGLEW_I3D_genlock)\r\n\r\n#endif /* WGL_I3D_genlock */\r\n\r\n/* -------------------------- WGL_I3D_image_buffer ------------------------- */\r\n\r\n#ifndef WGL_I3D_image_buffer\r\n#define WGL_I3D_image_buffer 1\r\n\r\n#define WGL_IMAGE_BUFFER_MIN_ACCESS_I3D 0x00000001\r\n#define WGL_IMAGE_BUFFER_LOCK_I3D 0x00000002\r\n\r\ntypedef BOOL (WINAPI * PFNWGLASSOCIATEIMAGEBUFFEREVENTSI3DPROC) (HDC hdc, HANDLE* pEvent, LPVOID *pAddress, DWORD *pSize, UINT count);\r\ntypedef LPVOID (WINAPI * PFNWGLCREATEIMAGEBUFFERI3DPROC) (HDC hDC, DWORD dwSize, UINT uFlags);\r\ntypedef BOOL (WINAPI * PFNWGLDESTROYIMAGEBUFFERI3DPROC) (HDC hDC, LPVOID pAddress);\r\ntypedef BOOL (WINAPI * PFNWGLRELEASEIMAGEBUFFEREVENTSI3DPROC) (HDC hdc, LPVOID* pAddress, UINT count);\r\n\r\n#define wglAssociateImageBufferEventsI3D WGLEW_GET_FUN(__wglewAssociateImageBufferEventsI3D)\r\n#define wglCreateImageBufferI3D WGLEW_GET_FUN(__wglewCreateImageBufferI3D)\r\n#define wglDestroyImageBufferI3D WGLEW_GET_FUN(__wglewDestroyImageBufferI3D)\r\n#define wglReleaseImageBufferEventsI3D WGLEW_GET_FUN(__wglewReleaseImageBufferEventsI3D)\r\n\r\n#define WGLEW_I3D_image_buffer WGLEW_GET_VAR(__WGLEW_I3D_image_buffer)\r\n\r\n#endif /* WGL_I3D_image_buffer */\r\n\r\n/* ------------------------ WGL_I3D_swap_frame_lock ------------------------ */\r\n\r\n#ifndef WGL_I3D_swap_frame_lock\r\n#define WGL_I3D_swap_frame_lock 1\r\n\r\ntypedef BOOL (WINAPI * PFNWGLDISABLEFRAMELOCKI3DPROC) (VOID);\r\ntypedef BOOL (WINAPI * PFNWGLENABLEFRAMELOCKI3DPROC) (VOID);\r\ntypedef BOOL (WINAPI * PFNWGLISENABLEDFRAMELOCKI3DPROC) (BOOL* pFlag);\r\ntypedef BOOL (WINAPI * PFNWGLQUERYFRAMELOCKMASTERI3DPROC) (BOOL* pFlag);\r\n\r\n#define wglDisableFrameLockI3D WGLEW_GET_FUN(__wglewDisableFrameLockI3D)\r\n#define wglEnableFrameLockI3D WGLEW_GET_FUN(__wglewEnableFrameLockI3D)\r\n#define wglIsEnabledFrameLockI3D WGLEW_GET_FUN(__wglewIsEnabledFrameLockI3D)\r\n#define wglQueryFrameLockMasterI3D WGLEW_GET_FUN(__wglewQueryFrameLockMasterI3D)\r\n\r\n#define WGLEW_I3D_swap_frame_lock WGLEW_GET_VAR(__WGLEW_I3D_swap_frame_lock)\r\n\r\n#endif /* WGL_I3D_swap_frame_lock */\r\n\r\n/* ------------------------ WGL_I3D_swap_frame_usage ----------------------- */\r\n\r\n#ifndef WGL_I3D_swap_frame_usage\r\n#define WGL_I3D_swap_frame_usage 1\r\n\r\ntypedef BOOL (WINAPI * PFNWGLBEGINFRAMETRACKINGI3DPROC) (void);\r\ntypedef BOOL (WINAPI * PFNWGLENDFRAMETRACKINGI3DPROC) (void);\r\ntypedef BOOL (WINAPI * PFNWGLGETFRAMEUSAGEI3DPROC) (float* pUsage);\r\ntypedef BOOL (WINAPI * PFNWGLQUERYFRAMETRACKINGI3DPROC) (DWORD* pFrameCount, DWORD *pMissedFrames, float *pLastMissedUsage);\r\n\r\n#define wglBeginFrameTrackingI3D WGLEW_GET_FUN(__wglewBeginFrameTrackingI3D)\r\n#define wglEndFrameTrackingI3D WGLEW_GET_FUN(__wglewEndFrameTrackingI3D)\r\n#define wglGetFrameUsageI3D WGLEW_GET_FUN(__wglewGetFrameUsageI3D)\r\n#define wglQueryFrameTrackingI3D WGLEW_GET_FUN(__wglewQueryFrameTrackingI3D)\r\n\r\n#define WGLEW_I3D_swap_frame_usage WGLEW_GET_VAR(__WGLEW_I3D_swap_frame_usage)\r\n\r\n#endif /* WGL_I3D_swap_frame_usage */\r\n\r\n/* --------------------------- WGL_NV_DX_interop --------------------------- */\r\n\r\n#ifndef WGL_NV_DX_interop\r\n#define WGL_NV_DX_interop 1\r\n\r\n#define WGL_ACCESS_READ_ONLY_NV 0x0000\r\n#define WGL_ACCESS_READ_WRITE_NV 0x0001\r\n#define WGL_ACCESS_WRITE_DISCARD_NV 0x0002\r\n\r\ntypedef BOOL (WINAPI * PFNWGLDXCLOSEDEVICENVPROC) (HANDLE hDevice);\r\ntypedef BOOL (WINAPI * PFNWGLDXLOCKOBJECTSNVPROC) (HANDLE hDevice, GLint count, HANDLE* hObjects);\r\ntypedef BOOL (WINAPI * PFNWGLDXOBJECTACCESSNVPROC) (HANDLE hObject, GLenum access);\r\ntypedef HANDLE (WINAPI * PFNWGLDXOPENDEVICENVPROC) (void* dxDevice);\r\ntypedef HANDLE (WINAPI * PFNWGLDXREGISTEROBJECTNVPROC) (HANDLE hDevice, void* dxObject, GLuint name, GLenum type, GLenum access);\r\ntypedef BOOL (WINAPI * PFNWGLDXSETRESOURCESHAREHANDLENVPROC) (void* dxObject, HANDLE shareHandle);\r\ntypedef BOOL (WINAPI * PFNWGLDXUNLOCKOBJECTSNVPROC) (HANDLE hDevice, GLint count, HANDLE* hObjects);\r\ntypedef BOOL (WINAPI * PFNWGLDXUNREGISTEROBJECTNVPROC) (HANDLE hDevice, HANDLE hObject);\r\n\r\n#define wglDXCloseDeviceNV WGLEW_GET_FUN(__wglewDXCloseDeviceNV)\r\n#define wglDXLockObjectsNV WGLEW_GET_FUN(__wglewDXLockObjectsNV)\r\n#define wglDXObjectAccessNV WGLEW_GET_FUN(__wglewDXObjectAccessNV)\r\n#define wglDXOpenDeviceNV WGLEW_GET_FUN(__wglewDXOpenDeviceNV)\r\n#define wglDXRegisterObjectNV WGLEW_GET_FUN(__wglewDXRegisterObjectNV)\r\n#define wglDXSetResourceShareHandleNV WGLEW_GET_FUN(__wglewDXSetResourceShareHandleNV)\r\n#define wglDXUnlockObjectsNV WGLEW_GET_FUN(__wglewDXUnlockObjectsNV)\r\n#define wglDXUnregisterObjectNV WGLEW_GET_FUN(__wglewDXUnregisterObjectNV)\r\n\r\n#define WGLEW_NV_DX_interop WGLEW_GET_VAR(__WGLEW_NV_DX_interop)\r\n\r\n#endif /* WGL_NV_DX_interop */\r\n\r\n/* --------------------------- WGL_NV_DX_interop2 -------------------------- */\r\n\r\n#ifndef WGL_NV_DX_interop2\r\n#define WGL_NV_DX_interop2 1\r\n\r\n#define WGLEW_NV_DX_interop2 WGLEW_GET_VAR(__WGLEW_NV_DX_interop2)\r\n\r\n#endif /* WGL_NV_DX_interop2 */\r\n\r\n/* --------------------------- WGL_NV_copy_image --------------------------- */\r\n\r\n#ifndef WGL_NV_copy_image\r\n#define WGL_NV_copy_image 1\r\n\r\ntypedef BOOL (WINAPI * PFNWGLCOPYIMAGESUBDATANVPROC) (HGLRC hSrcRC, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, HGLRC hDstRC, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth);\r\n\r\n#define wglCopyImageSubDataNV WGLEW_GET_FUN(__wglewCopyImageSubDataNV)\r\n\r\n#define WGLEW_NV_copy_image WGLEW_GET_VAR(__WGLEW_NV_copy_image)\r\n\r\n#endif /* WGL_NV_copy_image */\r\n\r\n/* ------------------------ WGL_NV_delay_before_swap ----------------------- */\r\n\r\n#ifndef WGL_NV_delay_before_swap\r\n#define WGL_NV_delay_before_swap 1\r\n\r\ntypedef BOOL (WINAPI * PFNWGLDELAYBEFORESWAPNVPROC) (HDC hDC, GLfloat seconds);\r\n\r\n#define wglDelayBeforeSwapNV WGLEW_GET_FUN(__wglewDelayBeforeSwapNV)\r\n\r\n#define WGLEW_NV_delay_before_swap WGLEW_GET_VAR(__WGLEW_NV_delay_before_swap)\r\n\r\n#endif /* WGL_NV_delay_before_swap */\r\n\r\n/* -------------------------- WGL_NV_float_buffer -------------------------- */\r\n\r\n#ifndef WGL_NV_float_buffer\r\n#define WGL_NV_float_buffer 1\r\n\r\n#define WGL_FLOAT_COMPONENTS_NV 0x20B0\r\n#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_R_NV 0x20B1\r\n#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RG_NV 0x20B2\r\n#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGB_NV 0x20B3\r\n#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGBA_NV 0x20B4\r\n#define WGL_TEXTURE_FLOAT_R_NV 0x20B5\r\n#define WGL_TEXTURE_FLOAT_RG_NV 0x20B6\r\n#define WGL_TEXTURE_FLOAT_RGB_NV 0x20B7\r\n#define WGL_TEXTURE_FLOAT_RGBA_NV 0x20B8\r\n\r\n#define WGLEW_NV_float_buffer WGLEW_GET_VAR(__WGLEW_NV_float_buffer)\r\n\r\n#endif /* WGL_NV_float_buffer */\r\n\r\n/* -------------------------- WGL_NV_gpu_affinity -------------------------- */\r\n\r\n#ifndef WGL_NV_gpu_affinity\r\n#define WGL_NV_gpu_affinity 1\r\n\r\n#define WGL_ERROR_INCOMPATIBLE_AFFINITY_MASKS_NV 0x20D0\r\n#define WGL_ERROR_MISSING_AFFINITY_MASK_NV 0x20D1\r\n\r\nDECLARE_HANDLE(HGPUNV);\r\ntypedef struct _GPU_DEVICE {\r\n  DWORD cb; \r\n  CHAR DeviceName[32]; \r\n  CHAR DeviceString[128]; \r\n  DWORD Flags; \r\n  RECT rcVirtualScreen; \r\n} GPU_DEVICE, *PGPU_DEVICE;\r\n\r\ntypedef HDC (WINAPI * PFNWGLCREATEAFFINITYDCNVPROC) (const HGPUNV *phGpuList);\r\ntypedef BOOL (WINAPI * PFNWGLDELETEDCNVPROC) (HDC hdc);\r\ntypedef BOOL (WINAPI * PFNWGLENUMGPUDEVICESNVPROC) (HGPUNV hGpu, UINT iDeviceIndex, PGPU_DEVICE lpGpuDevice);\r\ntypedef BOOL (WINAPI * PFNWGLENUMGPUSFROMAFFINITYDCNVPROC) (HDC hAffinityDC, UINT iGpuIndex, HGPUNV *hGpu);\r\ntypedef BOOL (WINAPI * PFNWGLENUMGPUSNVPROC) (UINT iGpuIndex, HGPUNV *phGpu);\r\n\r\n#define wglCreateAffinityDCNV WGLEW_GET_FUN(__wglewCreateAffinityDCNV)\r\n#define wglDeleteDCNV WGLEW_GET_FUN(__wglewDeleteDCNV)\r\n#define wglEnumGpuDevicesNV WGLEW_GET_FUN(__wglewEnumGpuDevicesNV)\r\n#define wglEnumGpusFromAffinityDCNV WGLEW_GET_FUN(__wglewEnumGpusFromAffinityDCNV)\r\n#define wglEnumGpusNV WGLEW_GET_FUN(__wglewEnumGpusNV)\r\n\r\n#define WGLEW_NV_gpu_affinity WGLEW_GET_VAR(__WGLEW_NV_gpu_affinity)\r\n\r\n#endif /* WGL_NV_gpu_affinity */\r\n\r\n/* ---------------------- WGL_NV_multisample_coverage ---------------------- */\r\n\r\n#ifndef WGL_NV_multisample_coverage\r\n#define WGL_NV_multisample_coverage 1\r\n\r\n#define WGL_COVERAGE_SAMPLES_NV 0x2042\r\n#define WGL_COLOR_SAMPLES_NV 0x20B9\r\n\r\n#define WGLEW_NV_multisample_coverage WGLEW_GET_VAR(__WGLEW_NV_multisample_coverage)\r\n\r\n#endif /* WGL_NV_multisample_coverage */\r\n\r\n/* -------------------------- WGL_NV_present_video ------------------------- */\r\n\r\n#ifndef WGL_NV_present_video\r\n#define WGL_NV_present_video 1\r\n\r\n#define WGL_NUM_VIDEO_SLOTS_NV 0x20F0\r\n\r\nDECLARE_HANDLE(HVIDEOOUTPUTDEVICENV);\r\n\r\ntypedef BOOL (WINAPI * PFNWGLBINDVIDEODEVICENVPROC) (HDC hDc, unsigned int uVideoSlot, HVIDEOOUTPUTDEVICENV hVideoDevice, const int* piAttribList);\r\ntypedef int (WINAPI * PFNWGLENUMERATEVIDEODEVICESNVPROC) (HDC hDc, HVIDEOOUTPUTDEVICENV* phDeviceList);\r\ntypedef BOOL (WINAPI * PFNWGLQUERYCURRENTCONTEXTNVPROC) (int iAttribute, int* piValue);\r\n\r\n#define wglBindVideoDeviceNV WGLEW_GET_FUN(__wglewBindVideoDeviceNV)\r\n#define wglEnumerateVideoDevicesNV WGLEW_GET_FUN(__wglewEnumerateVideoDevicesNV)\r\n#define wglQueryCurrentContextNV WGLEW_GET_FUN(__wglewQueryCurrentContextNV)\r\n\r\n#define WGLEW_NV_present_video WGLEW_GET_VAR(__WGLEW_NV_present_video)\r\n\r\n#endif /* WGL_NV_present_video */\r\n\r\n/* ---------------------- WGL_NV_render_depth_texture ---------------------- */\r\n\r\n#ifndef WGL_NV_render_depth_texture\r\n#define WGL_NV_render_depth_texture 1\r\n\r\n#define WGL_NO_TEXTURE_ARB 0x2077\r\n#define WGL_BIND_TO_TEXTURE_DEPTH_NV 0x20A3\r\n#define WGL_BIND_TO_TEXTURE_RECTANGLE_DEPTH_NV 0x20A4\r\n#define WGL_DEPTH_TEXTURE_FORMAT_NV 0x20A5\r\n#define WGL_TEXTURE_DEPTH_COMPONENT_NV 0x20A6\r\n#define WGL_DEPTH_COMPONENT_NV 0x20A7\r\n\r\n#define WGLEW_NV_render_depth_texture WGLEW_GET_VAR(__WGLEW_NV_render_depth_texture)\r\n\r\n#endif /* WGL_NV_render_depth_texture */\r\n\r\n/* -------------------- WGL_NV_render_texture_rectangle -------------------- */\r\n\r\n#ifndef WGL_NV_render_texture_rectangle\r\n#define WGL_NV_render_texture_rectangle 1\r\n\r\n#define WGL_BIND_TO_TEXTURE_RECTANGLE_RGB_NV 0x20A0\r\n#define WGL_BIND_TO_TEXTURE_RECTANGLE_RGBA_NV 0x20A1\r\n#define WGL_TEXTURE_RECTANGLE_NV 0x20A2\r\n\r\n#define WGLEW_NV_render_texture_rectangle WGLEW_GET_VAR(__WGLEW_NV_render_texture_rectangle)\r\n\r\n#endif /* WGL_NV_render_texture_rectangle */\r\n\r\n/* --------------------------- WGL_NV_swap_group --------------------------- */\r\n\r\n#ifndef WGL_NV_swap_group\r\n#define WGL_NV_swap_group 1\r\n\r\ntypedef BOOL (WINAPI * PFNWGLBINDSWAPBARRIERNVPROC) (GLuint group, GLuint barrier);\r\ntypedef BOOL (WINAPI * PFNWGLJOINSWAPGROUPNVPROC) (HDC hDC, GLuint group);\r\ntypedef BOOL (WINAPI * PFNWGLQUERYFRAMECOUNTNVPROC) (HDC hDC, GLuint* count);\r\ntypedef BOOL (WINAPI * PFNWGLQUERYMAXSWAPGROUPSNVPROC) (HDC hDC, GLuint* maxGroups, GLuint *maxBarriers);\r\ntypedef BOOL (WINAPI * PFNWGLQUERYSWAPGROUPNVPROC) (HDC hDC, GLuint* group, GLuint *barrier);\r\ntypedef BOOL (WINAPI * PFNWGLRESETFRAMECOUNTNVPROC) (HDC hDC);\r\n\r\n#define wglBindSwapBarrierNV WGLEW_GET_FUN(__wglewBindSwapBarrierNV)\r\n#define wglJoinSwapGroupNV WGLEW_GET_FUN(__wglewJoinSwapGroupNV)\r\n#define wglQueryFrameCountNV WGLEW_GET_FUN(__wglewQueryFrameCountNV)\r\n#define wglQueryMaxSwapGroupsNV WGLEW_GET_FUN(__wglewQueryMaxSwapGroupsNV)\r\n#define wglQuerySwapGroupNV WGLEW_GET_FUN(__wglewQuerySwapGroupNV)\r\n#define wglResetFrameCountNV WGLEW_GET_FUN(__wglewResetFrameCountNV)\r\n\r\n#define WGLEW_NV_swap_group WGLEW_GET_VAR(__WGLEW_NV_swap_group)\r\n\r\n#endif /* WGL_NV_swap_group */\r\n\r\n/* ----------------------- WGL_NV_vertex_array_range ----------------------- */\r\n\r\n#ifndef WGL_NV_vertex_array_range\r\n#define WGL_NV_vertex_array_range 1\r\n\r\ntypedef void * (WINAPI * PFNWGLALLOCATEMEMORYNVPROC) (GLsizei size, GLfloat readFrequency, GLfloat writeFrequency, GLfloat priority);\r\ntypedef void (WINAPI * PFNWGLFREEMEMORYNVPROC) (void *pointer);\r\n\r\n#define wglAllocateMemoryNV WGLEW_GET_FUN(__wglewAllocateMemoryNV)\r\n#define wglFreeMemoryNV WGLEW_GET_FUN(__wglewFreeMemoryNV)\r\n\r\n#define WGLEW_NV_vertex_array_range WGLEW_GET_VAR(__WGLEW_NV_vertex_array_range)\r\n\r\n#endif /* WGL_NV_vertex_array_range */\r\n\r\n/* -------------------------- WGL_NV_video_capture ------------------------- */\r\n\r\n#ifndef WGL_NV_video_capture\r\n#define WGL_NV_video_capture 1\r\n\r\n#define WGL_UNIQUE_ID_NV 0x20CE\r\n#define WGL_NUM_VIDEO_CAPTURE_SLOTS_NV 0x20CF\r\n\r\nDECLARE_HANDLE(HVIDEOINPUTDEVICENV);\r\n\r\ntypedef BOOL (WINAPI * PFNWGLBINDVIDEOCAPTUREDEVICENVPROC) (UINT uVideoSlot, HVIDEOINPUTDEVICENV hDevice);\r\ntypedef UINT (WINAPI * PFNWGLENUMERATEVIDEOCAPTUREDEVICESNVPROC) (HDC hDc, HVIDEOINPUTDEVICENV* phDeviceList);\r\ntypedef BOOL (WINAPI * PFNWGLLOCKVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice);\r\ntypedef BOOL (WINAPI * PFNWGLQUERYVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice, int iAttribute, int* piValue);\r\ntypedef BOOL (WINAPI * PFNWGLRELEASEVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice);\r\n\r\n#define wglBindVideoCaptureDeviceNV WGLEW_GET_FUN(__wglewBindVideoCaptureDeviceNV)\r\n#define wglEnumerateVideoCaptureDevicesNV WGLEW_GET_FUN(__wglewEnumerateVideoCaptureDevicesNV)\r\n#define wglLockVideoCaptureDeviceNV WGLEW_GET_FUN(__wglewLockVideoCaptureDeviceNV)\r\n#define wglQueryVideoCaptureDeviceNV WGLEW_GET_FUN(__wglewQueryVideoCaptureDeviceNV)\r\n#define wglReleaseVideoCaptureDeviceNV WGLEW_GET_FUN(__wglewReleaseVideoCaptureDeviceNV)\r\n\r\n#define WGLEW_NV_video_capture WGLEW_GET_VAR(__WGLEW_NV_video_capture)\r\n\r\n#endif /* WGL_NV_video_capture */\r\n\r\n/* -------------------------- WGL_NV_video_output -------------------------- */\r\n\r\n#ifndef WGL_NV_video_output\r\n#define WGL_NV_video_output 1\r\n\r\n#define WGL_BIND_TO_VIDEO_RGB_NV 0x20C0\r\n#define WGL_BIND_TO_VIDEO_RGBA_NV 0x20C1\r\n#define WGL_BIND_TO_VIDEO_RGB_AND_DEPTH_NV 0x20C2\r\n#define WGL_VIDEO_OUT_COLOR_NV 0x20C3\r\n#define WGL_VIDEO_OUT_ALPHA_NV 0x20C4\r\n#define WGL_VIDEO_OUT_DEPTH_NV 0x20C5\r\n#define WGL_VIDEO_OUT_COLOR_AND_ALPHA_NV 0x20C6\r\n#define WGL_VIDEO_OUT_COLOR_AND_DEPTH_NV 0x20C7\r\n#define WGL_VIDEO_OUT_FRAME 0x20C8\r\n#define WGL_VIDEO_OUT_FIELD_1 0x20C9\r\n#define WGL_VIDEO_OUT_FIELD_2 0x20CA\r\n#define WGL_VIDEO_OUT_STACKED_FIELDS_1_2 0x20CB\r\n#define WGL_VIDEO_OUT_STACKED_FIELDS_2_1 0x20CC\r\n\r\nDECLARE_HANDLE(HPVIDEODEV);\r\n\r\ntypedef BOOL (WINAPI * PFNWGLBINDVIDEOIMAGENVPROC) (HPVIDEODEV hVideoDevice, HPBUFFERARB hPbuffer, int iVideoBuffer);\r\ntypedef BOOL (WINAPI * PFNWGLGETVIDEODEVICENVPROC) (HDC hDC, int numDevices, HPVIDEODEV* hVideoDevice);\r\ntypedef BOOL (WINAPI * PFNWGLGETVIDEOINFONVPROC) (HPVIDEODEV hpVideoDevice, unsigned long* pulCounterOutputPbuffer, unsigned long *pulCounterOutputVideo);\r\ntypedef BOOL (WINAPI * PFNWGLRELEASEVIDEODEVICENVPROC) (HPVIDEODEV hVideoDevice);\r\ntypedef BOOL (WINAPI * PFNWGLRELEASEVIDEOIMAGENVPROC) (HPBUFFERARB hPbuffer, int iVideoBuffer);\r\ntypedef BOOL (WINAPI * PFNWGLSENDPBUFFERTOVIDEONVPROC) (HPBUFFERARB hPbuffer, int iBufferType, unsigned long* pulCounterPbuffer, BOOL bBlock);\r\n\r\n#define wglBindVideoImageNV WGLEW_GET_FUN(__wglewBindVideoImageNV)\r\n#define wglGetVideoDeviceNV WGLEW_GET_FUN(__wglewGetVideoDeviceNV)\r\n#define wglGetVideoInfoNV WGLEW_GET_FUN(__wglewGetVideoInfoNV)\r\n#define wglReleaseVideoDeviceNV WGLEW_GET_FUN(__wglewReleaseVideoDeviceNV)\r\n#define wglReleaseVideoImageNV WGLEW_GET_FUN(__wglewReleaseVideoImageNV)\r\n#define wglSendPbufferToVideoNV WGLEW_GET_FUN(__wglewSendPbufferToVideoNV)\r\n\r\n#define WGLEW_NV_video_output WGLEW_GET_VAR(__WGLEW_NV_video_output)\r\n\r\n#endif /* WGL_NV_video_output */\r\n\r\n/* -------------------------- WGL_OML_sync_control ------------------------- */\r\n\r\n#ifndef WGL_OML_sync_control\r\n#define WGL_OML_sync_control 1\r\n\r\ntypedef BOOL (WINAPI * PFNWGLGETMSCRATEOMLPROC) (HDC hdc, INT32* numerator, INT32 *denominator);\r\ntypedef BOOL (WINAPI * PFNWGLGETSYNCVALUESOMLPROC) (HDC hdc, INT64* ust, INT64 *msc, INT64 *sbc);\r\ntypedef INT64 (WINAPI * PFNWGLSWAPBUFFERSMSCOMLPROC) (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder);\r\ntypedef INT64 (WINAPI * PFNWGLSWAPLAYERBUFFERSMSCOMLPROC) (HDC hdc, INT fuPlanes, INT64 target_msc, INT64 divisor, INT64 remainder);\r\ntypedef BOOL (WINAPI * PFNWGLWAITFORMSCOMLPROC) (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder, INT64* ust, INT64 *msc, INT64 *sbc);\r\ntypedef BOOL (WINAPI * PFNWGLWAITFORSBCOMLPROC) (HDC hdc, INT64 target_sbc, INT64* ust, INT64 *msc, INT64 *sbc);\r\n\r\n#define wglGetMscRateOML WGLEW_GET_FUN(__wglewGetMscRateOML)\r\n#define wglGetSyncValuesOML WGLEW_GET_FUN(__wglewGetSyncValuesOML)\r\n#define wglSwapBuffersMscOML WGLEW_GET_FUN(__wglewSwapBuffersMscOML)\r\n#define wglSwapLayerBuffersMscOML WGLEW_GET_FUN(__wglewSwapLayerBuffersMscOML)\r\n#define wglWaitForMscOML WGLEW_GET_FUN(__wglewWaitForMscOML)\r\n#define wglWaitForSbcOML WGLEW_GET_FUN(__wglewWaitForSbcOML)\r\n\r\n#define WGLEW_OML_sync_control WGLEW_GET_VAR(__WGLEW_OML_sync_control)\r\n\r\n#endif /* WGL_OML_sync_control */\r\n\r\n/* ------------------------------------------------------------------------- */\r\n\r\n#ifdef GLEW_MX\r\n#define WGLEW_FUN_EXPORT\r\n#define WGLEW_VAR_EXPORT\r\n#else\r\n#define WGLEW_FUN_EXPORT GLEW_FUN_EXPORT\r\n#define WGLEW_VAR_EXPORT GLEW_VAR_EXPORT\r\n#endif /* GLEW_MX */\r\n\r\n#ifdef GLEW_MX\r\nstruct WGLEWContextStruct\r\n{\r\n#endif /* GLEW_MX */\r\n\r\nWGLEW_FUN_EXPORT PFNWGLSETSTEREOEMITTERSTATE3DLPROC __wglewSetStereoEmitterState3DL;\r\n\r\nWGLEW_FUN_EXPORT PFNWGLBLITCONTEXTFRAMEBUFFERAMDPROC __wglewBlitContextFramebufferAMD;\r\nWGLEW_FUN_EXPORT PFNWGLCREATEASSOCIATEDCONTEXTAMDPROC __wglewCreateAssociatedContextAMD;\r\nWGLEW_FUN_EXPORT PFNWGLCREATEASSOCIATEDCONTEXTATTRIBSAMDPROC __wglewCreateAssociatedContextAttribsAMD;\r\nWGLEW_FUN_EXPORT PFNWGLDELETEASSOCIATEDCONTEXTAMDPROC __wglewDeleteAssociatedContextAMD;\r\nWGLEW_FUN_EXPORT PFNWGLGETCONTEXTGPUIDAMDPROC __wglewGetContextGPUIDAMD;\r\nWGLEW_FUN_EXPORT PFNWGLGETCURRENTASSOCIATEDCONTEXTAMDPROC __wglewGetCurrentAssociatedContextAMD;\r\nWGLEW_FUN_EXPORT PFNWGLGETGPUIDSAMDPROC __wglewGetGPUIDsAMD;\r\nWGLEW_FUN_EXPORT PFNWGLGETGPUINFOAMDPROC __wglewGetGPUInfoAMD;\r\nWGLEW_FUN_EXPORT PFNWGLMAKEASSOCIATEDCONTEXTCURRENTAMDPROC __wglewMakeAssociatedContextCurrentAMD;\r\n\r\nWGLEW_FUN_EXPORT PFNWGLCREATEBUFFERREGIONARBPROC __wglewCreateBufferRegionARB;\r\nWGLEW_FUN_EXPORT PFNWGLDELETEBUFFERREGIONARBPROC __wglewDeleteBufferRegionARB;\r\nWGLEW_FUN_EXPORT PFNWGLRESTOREBUFFERREGIONARBPROC __wglewRestoreBufferRegionARB;\r\nWGLEW_FUN_EXPORT PFNWGLSAVEBUFFERREGIONARBPROC __wglewSaveBufferRegionARB;\r\n\r\nWGLEW_FUN_EXPORT PFNWGLCREATECONTEXTATTRIBSARBPROC __wglewCreateContextAttribsARB;\r\n\r\nWGLEW_FUN_EXPORT PFNWGLGETEXTENSIONSSTRINGARBPROC __wglewGetExtensionsStringARB;\r\n\r\nWGLEW_FUN_EXPORT PFNWGLGETCURRENTREADDCARBPROC __wglewGetCurrentReadDCARB;\r\nWGLEW_FUN_EXPORT PFNWGLMAKECONTEXTCURRENTARBPROC __wglewMakeContextCurrentARB;\r\n\r\nWGLEW_FUN_EXPORT PFNWGLCREATEPBUFFERARBPROC __wglewCreatePbufferARB;\r\nWGLEW_FUN_EXPORT PFNWGLDESTROYPBUFFERARBPROC __wglewDestroyPbufferARB;\r\nWGLEW_FUN_EXPORT PFNWGLGETPBUFFERDCARBPROC __wglewGetPbufferDCARB;\r\nWGLEW_FUN_EXPORT PFNWGLQUERYPBUFFERARBPROC __wglewQueryPbufferARB;\r\nWGLEW_FUN_EXPORT PFNWGLRELEASEPBUFFERDCARBPROC __wglewReleasePbufferDCARB;\r\n\r\nWGLEW_FUN_EXPORT PFNWGLCHOOSEPIXELFORMATARBPROC __wglewChoosePixelFormatARB;\r\nWGLEW_FUN_EXPORT PFNWGLGETPIXELFORMATATTRIBFVARBPROC __wglewGetPixelFormatAttribfvARB;\r\nWGLEW_FUN_EXPORT PFNWGLGETPIXELFORMATATTRIBIVARBPROC __wglewGetPixelFormatAttribivARB;\r\n\r\nWGLEW_FUN_EXPORT PFNWGLBINDTEXIMAGEARBPROC __wglewBindTexImageARB;\r\nWGLEW_FUN_EXPORT PFNWGLRELEASETEXIMAGEARBPROC __wglewReleaseTexImageARB;\r\nWGLEW_FUN_EXPORT PFNWGLSETPBUFFERATTRIBARBPROC __wglewSetPbufferAttribARB;\r\n\r\nWGLEW_FUN_EXPORT PFNWGLBINDDISPLAYCOLORTABLEEXTPROC __wglewBindDisplayColorTableEXT;\r\nWGLEW_FUN_EXPORT PFNWGLCREATEDISPLAYCOLORTABLEEXTPROC __wglewCreateDisplayColorTableEXT;\r\nWGLEW_FUN_EXPORT PFNWGLDESTROYDISPLAYCOLORTABLEEXTPROC __wglewDestroyDisplayColorTableEXT;\r\nWGLEW_FUN_EXPORT PFNWGLLOADDISPLAYCOLORTABLEEXTPROC __wglewLoadDisplayColorTableEXT;\r\n\r\nWGLEW_FUN_EXPORT PFNWGLGETEXTENSIONSSTRINGEXTPROC __wglewGetExtensionsStringEXT;\r\n\r\nWGLEW_FUN_EXPORT PFNWGLGETCURRENTREADDCEXTPROC __wglewGetCurrentReadDCEXT;\r\nWGLEW_FUN_EXPORT PFNWGLMAKECONTEXTCURRENTEXTPROC __wglewMakeContextCurrentEXT;\r\n\r\nWGLEW_FUN_EXPORT PFNWGLCREATEPBUFFEREXTPROC __wglewCreatePbufferEXT;\r\nWGLEW_FUN_EXPORT PFNWGLDESTROYPBUFFEREXTPROC __wglewDestroyPbufferEXT;\r\nWGLEW_FUN_EXPORT PFNWGLGETPBUFFERDCEXTPROC __wglewGetPbufferDCEXT;\r\nWGLEW_FUN_EXPORT PFNWGLQUERYPBUFFEREXTPROC __wglewQueryPbufferEXT;\r\nWGLEW_FUN_EXPORT PFNWGLRELEASEPBUFFERDCEXTPROC __wglewReleasePbufferDCEXT;\r\n\r\nWGLEW_FUN_EXPORT PFNWGLCHOOSEPIXELFORMATEXTPROC __wglewChoosePixelFormatEXT;\r\nWGLEW_FUN_EXPORT PFNWGLGETPIXELFORMATATTRIBFVEXTPROC __wglewGetPixelFormatAttribfvEXT;\r\nWGLEW_FUN_EXPORT PFNWGLGETPIXELFORMATATTRIBIVEXTPROC __wglewGetPixelFormatAttribivEXT;\r\n\r\nWGLEW_FUN_EXPORT PFNWGLGETSWAPINTERVALEXTPROC __wglewGetSwapIntervalEXT;\r\nWGLEW_FUN_EXPORT PFNWGLSWAPINTERVALEXTPROC __wglewSwapIntervalEXT;\r\n\r\nWGLEW_FUN_EXPORT PFNWGLGETDIGITALVIDEOPARAMETERSI3DPROC __wglewGetDigitalVideoParametersI3D;\r\nWGLEW_FUN_EXPORT PFNWGLSETDIGITALVIDEOPARAMETERSI3DPROC __wglewSetDigitalVideoParametersI3D;\r\n\r\nWGLEW_FUN_EXPORT PFNWGLGETGAMMATABLEI3DPROC __wglewGetGammaTableI3D;\r\nWGLEW_FUN_EXPORT PFNWGLGETGAMMATABLEPARAMETERSI3DPROC __wglewGetGammaTableParametersI3D;\r\nWGLEW_FUN_EXPORT PFNWGLSETGAMMATABLEI3DPROC __wglewSetGammaTableI3D;\r\nWGLEW_FUN_EXPORT PFNWGLSETGAMMATABLEPARAMETERSI3DPROC __wglewSetGammaTableParametersI3D;\r\n\r\nWGLEW_FUN_EXPORT PFNWGLDISABLEGENLOCKI3DPROC __wglewDisableGenlockI3D;\r\nWGLEW_FUN_EXPORT PFNWGLENABLEGENLOCKI3DPROC __wglewEnableGenlockI3D;\r\nWGLEW_FUN_EXPORT PFNWGLGENLOCKSAMPLERATEI3DPROC __wglewGenlockSampleRateI3D;\r\nWGLEW_FUN_EXPORT PFNWGLGENLOCKSOURCEDELAYI3DPROC __wglewGenlockSourceDelayI3D;\r\nWGLEW_FUN_EXPORT PFNWGLGENLOCKSOURCEEDGEI3DPROC __wglewGenlockSourceEdgeI3D;\r\nWGLEW_FUN_EXPORT PFNWGLGENLOCKSOURCEI3DPROC __wglewGenlockSourceI3D;\r\nWGLEW_FUN_EXPORT PFNWGLGETGENLOCKSAMPLERATEI3DPROC __wglewGetGenlockSampleRateI3D;\r\nWGLEW_FUN_EXPORT PFNWGLGETGENLOCKSOURCEDELAYI3DPROC __wglewGetGenlockSourceDelayI3D;\r\nWGLEW_FUN_EXPORT PFNWGLGETGENLOCKSOURCEEDGEI3DPROC __wglewGetGenlockSourceEdgeI3D;\r\nWGLEW_FUN_EXPORT PFNWGLGETGENLOCKSOURCEI3DPROC __wglewGetGenlockSourceI3D;\r\nWGLEW_FUN_EXPORT PFNWGLISENABLEDGENLOCKI3DPROC __wglewIsEnabledGenlockI3D;\r\nWGLEW_FUN_EXPORT PFNWGLQUERYGENLOCKMAXSOURCEDELAYI3DPROC __wglewQueryGenlockMaxSourceDelayI3D;\r\n\r\nWGLEW_FUN_EXPORT PFNWGLASSOCIATEIMAGEBUFFEREVENTSI3DPROC __wglewAssociateImageBufferEventsI3D;\r\nWGLEW_FUN_EXPORT PFNWGLCREATEIMAGEBUFFERI3DPROC __wglewCreateImageBufferI3D;\r\nWGLEW_FUN_EXPORT PFNWGLDESTROYIMAGEBUFFERI3DPROC __wglewDestroyImageBufferI3D;\r\nWGLEW_FUN_EXPORT PFNWGLRELEASEIMAGEBUFFEREVENTSI3DPROC __wglewReleaseImageBufferEventsI3D;\r\n\r\nWGLEW_FUN_EXPORT PFNWGLDISABLEFRAMELOCKI3DPROC __wglewDisableFrameLockI3D;\r\nWGLEW_FUN_EXPORT PFNWGLENABLEFRAMELOCKI3DPROC __wglewEnableFrameLockI3D;\r\nWGLEW_FUN_EXPORT PFNWGLISENABLEDFRAMELOCKI3DPROC __wglewIsEnabledFrameLockI3D;\r\nWGLEW_FUN_EXPORT PFNWGLQUERYFRAMELOCKMASTERI3DPROC __wglewQueryFrameLockMasterI3D;\r\n\r\nWGLEW_FUN_EXPORT PFNWGLBEGINFRAMETRACKINGI3DPROC __wglewBeginFrameTrackingI3D;\r\nWGLEW_FUN_EXPORT PFNWGLENDFRAMETRACKINGI3DPROC __wglewEndFrameTrackingI3D;\r\nWGLEW_FUN_EXPORT PFNWGLGETFRAMEUSAGEI3DPROC __wglewGetFrameUsageI3D;\r\nWGLEW_FUN_EXPORT PFNWGLQUERYFRAMETRACKINGI3DPROC __wglewQueryFrameTrackingI3D;\r\n\r\nWGLEW_FUN_EXPORT PFNWGLDXCLOSEDEVICENVPROC __wglewDXCloseDeviceNV;\r\nWGLEW_FUN_EXPORT PFNWGLDXLOCKOBJECTSNVPROC __wglewDXLockObjectsNV;\r\nWGLEW_FUN_EXPORT PFNWGLDXOBJECTACCESSNVPROC __wglewDXObjectAccessNV;\r\nWGLEW_FUN_EXPORT PFNWGLDXOPENDEVICENVPROC __wglewDXOpenDeviceNV;\r\nWGLEW_FUN_EXPORT PFNWGLDXREGISTEROBJECTNVPROC __wglewDXRegisterObjectNV;\r\nWGLEW_FUN_EXPORT PFNWGLDXSETRESOURCESHAREHANDLENVPROC __wglewDXSetResourceShareHandleNV;\r\nWGLEW_FUN_EXPORT PFNWGLDXUNLOCKOBJECTSNVPROC __wglewDXUnlockObjectsNV;\r\nWGLEW_FUN_EXPORT PFNWGLDXUNREGISTEROBJECTNVPROC __wglewDXUnregisterObjectNV;\r\n\r\nWGLEW_FUN_EXPORT PFNWGLCOPYIMAGESUBDATANVPROC __wglewCopyImageSubDataNV;\r\n\r\nWGLEW_FUN_EXPORT PFNWGLDELAYBEFORESWAPNVPROC __wglewDelayBeforeSwapNV;\r\n\r\nWGLEW_FUN_EXPORT PFNWGLCREATEAFFINITYDCNVPROC __wglewCreateAffinityDCNV;\r\nWGLEW_FUN_EXPORT PFNWGLDELETEDCNVPROC __wglewDeleteDCNV;\r\nWGLEW_FUN_EXPORT PFNWGLENUMGPUDEVICESNVPROC __wglewEnumGpuDevicesNV;\r\nWGLEW_FUN_EXPORT PFNWGLENUMGPUSFROMAFFINITYDCNVPROC __wglewEnumGpusFromAffinityDCNV;\r\nWGLEW_FUN_EXPORT PFNWGLENUMGPUSNVPROC __wglewEnumGpusNV;\r\n\r\nWGLEW_FUN_EXPORT PFNWGLBINDVIDEODEVICENVPROC __wglewBindVideoDeviceNV;\r\nWGLEW_FUN_EXPORT PFNWGLENUMERATEVIDEODEVICESNVPROC __wglewEnumerateVideoDevicesNV;\r\nWGLEW_FUN_EXPORT PFNWGLQUERYCURRENTCONTEXTNVPROC __wglewQueryCurrentContextNV;\r\n\r\nWGLEW_FUN_EXPORT PFNWGLBINDSWAPBARRIERNVPROC __wglewBindSwapBarrierNV;\r\nWGLEW_FUN_EXPORT PFNWGLJOINSWAPGROUPNVPROC __wglewJoinSwapGroupNV;\r\nWGLEW_FUN_EXPORT PFNWGLQUERYFRAMECOUNTNVPROC __wglewQueryFrameCountNV;\r\nWGLEW_FUN_EXPORT PFNWGLQUERYMAXSWAPGROUPSNVPROC __wglewQueryMaxSwapGroupsNV;\r\nWGLEW_FUN_EXPORT PFNWGLQUERYSWAPGROUPNVPROC __wglewQuerySwapGroupNV;\r\nWGLEW_FUN_EXPORT PFNWGLRESETFRAMECOUNTNVPROC __wglewResetFrameCountNV;\r\n\r\nWGLEW_FUN_EXPORT PFNWGLALLOCATEMEMORYNVPROC __wglewAllocateMemoryNV;\r\nWGLEW_FUN_EXPORT PFNWGLFREEMEMORYNVPROC __wglewFreeMemoryNV;\r\n\r\nWGLEW_FUN_EXPORT PFNWGLBINDVIDEOCAPTUREDEVICENVPROC __wglewBindVideoCaptureDeviceNV;\r\nWGLEW_FUN_EXPORT PFNWGLENUMERATEVIDEOCAPTUREDEVICESNVPROC __wglewEnumerateVideoCaptureDevicesNV;\r\nWGLEW_FUN_EXPORT PFNWGLLOCKVIDEOCAPTUREDEVICENVPROC __wglewLockVideoCaptureDeviceNV;\r\nWGLEW_FUN_EXPORT PFNWGLQUERYVIDEOCAPTUREDEVICENVPROC __wglewQueryVideoCaptureDeviceNV;\r\nWGLEW_FUN_EXPORT PFNWGLRELEASEVIDEOCAPTUREDEVICENVPROC __wglewReleaseVideoCaptureDeviceNV;\r\n\r\nWGLEW_FUN_EXPORT PFNWGLBINDVIDEOIMAGENVPROC __wglewBindVideoImageNV;\r\nWGLEW_FUN_EXPORT PFNWGLGETVIDEODEVICENVPROC __wglewGetVideoDeviceNV;\r\nWGLEW_FUN_EXPORT PFNWGLGETVIDEOINFONVPROC __wglewGetVideoInfoNV;\r\nWGLEW_FUN_EXPORT PFNWGLRELEASEVIDEODEVICENVPROC __wglewReleaseVideoDeviceNV;\r\nWGLEW_FUN_EXPORT PFNWGLRELEASEVIDEOIMAGENVPROC __wglewReleaseVideoImageNV;\r\nWGLEW_FUN_EXPORT PFNWGLSENDPBUFFERTOVIDEONVPROC __wglewSendPbufferToVideoNV;\r\n\r\nWGLEW_FUN_EXPORT PFNWGLGETMSCRATEOMLPROC __wglewGetMscRateOML;\r\nWGLEW_FUN_EXPORT PFNWGLGETSYNCVALUESOMLPROC __wglewGetSyncValuesOML;\r\nWGLEW_FUN_EXPORT PFNWGLSWAPBUFFERSMSCOMLPROC __wglewSwapBuffersMscOML;\r\nWGLEW_FUN_EXPORT PFNWGLSWAPLAYERBUFFERSMSCOMLPROC __wglewSwapLayerBuffersMscOML;\r\nWGLEW_FUN_EXPORT PFNWGLWAITFORMSCOMLPROC __wglewWaitForMscOML;\r\nWGLEW_FUN_EXPORT PFNWGLWAITFORSBCOMLPROC __wglewWaitForSbcOML;\r\nWGLEW_VAR_EXPORT GLboolean __WGLEW_3DFX_multisample;\r\nWGLEW_VAR_EXPORT GLboolean __WGLEW_3DL_stereo_control;\r\nWGLEW_VAR_EXPORT GLboolean __WGLEW_AMD_gpu_association;\r\nWGLEW_VAR_EXPORT GLboolean __WGLEW_ARB_buffer_region;\r\nWGLEW_VAR_EXPORT GLboolean __WGLEW_ARB_context_flush_control;\r\nWGLEW_VAR_EXPORT GLboolean __WGLEW_ARB_create_context;\r\nWGLEW_VAR_EXPORT GLboolean __WGLEW_ARB_create_context_profile;\r\nWGLEW_VAR_EXPORT GLboolean __WGLEW_ARB_create_context_robustness;\r\nWGLEW_VAR_EXPORT GLboolean __WGLEW_ARB_extensions_string;\r\nWGLEW_VAR_EXPORT GLboolean __WGLEW_ARB_framebuffer_sRGB;\r\nWGLEW_VAR_EXPORT GLboolean __WGLEW_ARB_make_current_read;\r\nWGLEW_VAR_EXPORT GLboolean __WGLEW_ARB_multisample;\r\nWGLEW_VAR_EXPORT GLboolean __WGLEW_ARB_pbuffer;\r\nWGLEW_VAR_EXPORT GLboolean __WGLEW_ARB_pixel_format;\r\nWGLEW_VAR_EXPORT GLboolean __WGLEW_ARB_pixel_format_float;\r\nWGLEW_VAR_EXPORT GLboolean __WGLEW_ARB_render_texture;\r\nWGLEW_VAR_EXPORT GLboolean __WGLEW_ARB_robustness_application_isolation;\r\nWGLEW_VAR_EXPORT GLboolean __WGLEW_ARB_robustness_share_group_isolation;\r\nWGLEW_VAR_EXPORT GLboolean __WGLEW_ATI_pixel_format_float;\r\nWGLEW_VAR_EXPORT GLboolean __WGLEW_ATI_render_texture_rectangle;\r\nWGLEW_VAR_EXPORT GLboolean __WGLEW_EXT_create_context_es2_profile;\r\nWGLEW_VAR_EXPORT GLboolean __WGLEW_EXT_create_context_es_profile;\r\nWGLEW_VAR_EXPORT GLboolean __WGLEW_EXT_depth_float;\r\nWGLEW_VAR_EXPORT GLboolean __WGLEW_EXT_display_color_table;\r\nWGLEW_VAR_EXPORT GLboolean __WGLEW_EXT_extensions_string;\r\nWGLEW_VAR_EXPORT GLboolean __WGLEW_EXT_framebuffer_sRGB;\r\nWGLEW_VAR_EXPORT GLboolean __WGLEW_EXT_make_current_read;\r\nWGLEW_VAR_EXPORT GLboolean __WGLEW_EXT_multisample;\r\nWGLEW_VAR_EXPORT GLboolean __WGLEW_EXT_pbuffer;\r\nWGLEW_VAR_EXPORT GLboolean __WGLEW_EXT_pixel_format;\r\nWGLEW_VAR_EXPORT GLboolean __WGLEW_EXT_pixel_format_packed_float;\r\nWGLEW_VAR_EXPORT GLboolean __WGLEW_EXT_swap_control;\r\nWGLEW_VAR_EXPORT GLboolean __WGLEW_EXT_swap_control_tear;\r\nWGLEW_VAR_EXPORT GLboolean __WGLEW_I3D_digital_video_control;\r\nWGLEW_VAR_EXPORT GLboolean __WGLEW_I3D_gamma;\r\nWGLEW_VAR_EXPORT GLboolean __WGLEW_I3D_genlock;\r\nWGLEW_VAR_EXPORT GLboolean __WGLEW_I3D_image_buffer;\r\nWGLEW_VAR_EXPORT GLboolean __WGLEW_I3D_swap_frame_lock;\r\nWGLEW_VAR_EXPORT GLboolean __WGLEW_I3D_swap_frame_usage;\r\nWGLEW_VAR_EXPORT GLboolean __WGLEW_NV_DX_interop;\r\nWGLEW_VAR_EXPORT GLboolean __WGLEW_NV_DX_interop2;\r\nWGLEW_VAR_EXPORT GLboolean __WGLEW_NV_copy_image;\r\nWGLEW_VAR_EXPORT GLboolean __WGLEW_NV_delay_before_swap;\r\nWGLEW_VAR_EXPORT GLboolean __WGLEW_NV_float_buffer;\r\nWGLEW_VAR_EXPORT GLboolean __WGLEW_NV_gpu_affinity;\r\nWGLEW_VAR_EXPORT GLboolean __WGLEW_NV_multisample_coverage;\r\nWGLEW_VAR_EXPORT GLboolean __WGLEW_NV_present_video;\r\nWGLEW_VAR_EXPORT GLboolean __WGLEW_NV_render_depth_texture;\r\nWGLEW_VAR_EXPORT GLboolean __WGLEW_NV_render_texture_rectangle;\r\nWGLEW_VAR_EXPORT GLboolean __WGLEW_NV_swap_group;\r\nWGLEW_VAR_EXPORT GLboolean __WGLEW_NV_vertex_array_range;\r\nWGLEW_VAR_EXPORT GLboolean __WGLEW_NV_video_capture;\r\nWGLEW_VAR_EXPORT GLboolean __WGLEW_NV_video_output;\r\nWGLEW_VAR_EXPORT GLboolean __WGLEW_OML_sync_control;\r\n\r\n#ifdef GLEW_MX\r\n}; /* WGLEWContextStruct */\r\n#endif /* GLEW_MX */\r\n\r\n/* ------------------------------------------------------------------------- */\r\n\r\n#ifdef GLEW_MX\r\n\r\ntypedef struct WGLEWContextStruct WGLEWContext;\r\nGLEWAPI GLenum GLEWAPIENTRY wglewContextInit (WGLEWContext *ctx);\r\nGLEWAPI GLboolean GLEWAPIENTRY wglewContextIsSupported (const WGLEWContext *ctx, const char *name);\r\n\r\n#define wglewInit() wglewContextInit(wglewGetContext())\r\n#define wglewIsSupported(x) wglewContextIsSupported(wglewGetContext(), x)\r\n\r\n#define WGLEW_GET_VAR(x) (*(const GLboolean*)&(wglewGetContext()->x))\r\n#define WGLEW_GET_FUN(x) wglewGetContext()->x\r\n\r\n#else /* GLEW_MX */\r\n\r\nGLEWAPI GLenum GLEWAPIENTRY wglewInit ();\r\nGLEWAPI GLboolean GLEWAPIENTRY wglewIsSupported (const char *name);\r\n\r\n#define WGLEW_GET_VAR(x) (*(const GLboolean*)&x)\r\n#define WGLEW_GET_FUN(x) x\r\n\r\n#endif /* GLEW_MX */\r\n\r\nGLEWAPI GLboolean GLEWAPIENTRY wglewGetExtension (const char *name);\r\n\r\n#ifdef __cplusplus\r\n}\r\n#endif\r\n\r\n#undef GLEWAPI\r\n\r\n#endif /* __wglew_h__ */\r\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/Audio/AlResource.hpp",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n#ifndef SFML_ALRESOURCE_HPP\n#define SFML_ALRESOURCE_HPP\n\n////////////////////////////////////////////////////////////\n// Headers\n////////////////////////////////////////////////////////////\n#include <SFML/Audio/Export.hpp>\n\n\nnamespace sf\n{\n////////////////////////////////////////////////////////////\n/// \\brief Base class for classes that require an OpenAL context\n///\n////////////////////////////////////////////////////////////\nclass SFML_AUDIO_API AlResource\n{\nprotected:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Default constructor\n    ///\n    ////////////////////////////////////////////////////////////\n    AlResource();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Destructor\n    ///\n    ////////////////////////////////////////////////////////////\n    ~AlResource();\n};\n\n} // namespace sf\n\n\n#endif // SFML_ALRESOURCE_HPP\n\n////////////////////////////////////////////////////////////\n/// \\class sf::AlResource\n/// \\ingroup audio\n///\n/// This class is for internal use only, it must be the base\n/// of every class that requires a valid OpenAL context in\n/// order to work.\n///\n////////////////////////////////////////////////////////////\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/Audio/Export.hpp",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n#ifndef SFML_AUDIO_EXPORT_HPP\n#define SFML_AUDIO_EXPORT_HPP\n\n////////////////////////////////////////////////////////////\n// Headers\n////////////////////////////////////////////////////////////\n#include <SFML/Config.hpp>\n\n\n////////////////////////////////////////////////////////////\n// Define portable import / export macros\n////////////////////////////////////////////////////////////\n#if defined(SFML_AUDIO_EXPORTS)\n\n    #define SFML_AUDIO_API SFML_API_EXPORT\n\n#else\n\n    #define SFML_AUDIO_API SFML_API_IMPORT\n\n#endif\n\n\n#endif // SFML_AUDIO_EXPORT_HPP\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/Audio/InputSoundFile.hpp",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n#ifndef SFML_INPUTSOUNDFILE_HPP\n#define SFML_INPUTSOUNDFILE_HPP\n\n////////////////////////////////////////////////////////////\n// Headers\n////////////////////////////////////////////////////////////\n#include <SFML/Audio/Export.hpp>\n#include <SFML/System/NonCopyable.hpp>\n#include <SFML/System/Time.hpp>\n#include <string>\n\n\nnamespace sf\n{\nclass InputStream;\nclass SoundFileReader;\n\n////////////////////////////////////////////////////////////\n/// \\brief Provide read access to sound files\n///\n////////////////////////////////////////////////////////////\nclass SFML_AUDIO_API InputSoundFile : NonCopyable\n{\npublic:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Default constructor\n    ///\n    ////////////////////////////////////////////////////////////\n    InputSoundFile();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Destructor\n    ///\n    ////////////////////////////////////////////////////////////\n    ~InputSoundFile();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Open a sound file from the disk for reading\n    ///\n    /// The supported audio formats are: WAV (PCM only), OGG/Vorbis, FLAC.\n    /// The supported sample sizes for FLAC and WAV are 8, 16, 24 and 32 bit.\n    ///\n    /// \\param filename Path of the sound file to load\n    ///\n    /// \\return True if the file was successfully opened\n    ///\n    ////////////////////////////////////////////////////////////\n    bool openFromFile(const std::string& filename);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Open a sound file in memory for reading\n    ///\n    /// The supported audio formats are: WAV (PCM only), OGG/Vorbis, FLAC.\n    /// The supported sample sizes for FLAC and WAV are 8, 16, 24 and 32 bit.\n    ///\n    /// \\param data        Pointer to the file data in memory\n    /// \\param sizeInBytes Size of the data to load, in bytes\n    ///\n    /// \\return True if the file was successfully opened\n    ///\n    ////////////////////////////////////////////////////////////\n    bool openFromMemory(const void* data, std::size_t sizeInBytes);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Open a sound file from a custom stream for reading\n    ///\n    /// The supported audio formats are: WAV (PCM only), OGG/Vorbis, FLAC.\n    /// The supported sample sizes for FLAC and WAV are 8, 16, 24 and 32 bit.\n    ///\n    /// \\param stream Source stream to read from\n    ///\n    /// \\return True if the file was successfully opened\n    ///\n    ////////////////////////////////////////////////////////////\n    bool openFromStream(InputStream& stream);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Open the sound file from the disk for writing\n    ///\n    /// \\param filename     Path of the sound file to write\n    /// \\param channelCount Number of channels in the sound\n    /// \\param sampleRate   Sample rate of the sound\n    ///\n    /// \\return True if the file was successfully opened\n    ///\n    ////////////////////////////////////////////////////////////\n    bool openForWriting(const std::string& filename, unsigned int channelCount, unsigned int sampleRate);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the total number of audio samples in the file\n    ///\n    /// \\return Number of samples\n    ///\n    ////////////////////////////////////////////////////////////\n    Uint64 getSampleCount() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the number of channels used by the sound\n    ///\n    /// \\return Number of channels (1 = mono, 2 = stereo)\n    ///\n    ////////////////////////////////////////////////////////////\n    unsigned int getChannelCount() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the sample rate of the sound\n    ///\n    /// \\return Sample rate, in samples per second\n    ///\n    ////////////////////////////////////////////////////////////\n    unsigned int getSampleRate() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the total duration of the sound file\n    ///\n    /// This function is provided for convenience, the duration is\n    /// deduced from the other sound file attributes.\n    ///\n    /// \\return Duration of the sound file\n    ///\n    ////////////////////////////////////////////////////////////\n    Time getDuration() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Change the current read position to the given sample offset\n    ///\n    /// This function takes a sample offset to provide maximum\n    /// precision. If you need to jump to a given time, use the\n    /// other overload.\n    ///\n    /// The sample offset takes the channels into account.\n    /// Offsets can be calculated like this:\n    /// `sampleNumber * sampleRate * channelCount`\n    /// If the given offset exceeds to total number of samples,\n    /// this function jumps to the end of the sound file.\n    ///\n    /// \\param sampleOffset Index of the sample to jump to, relative to the beginning\n    ///\n    ////////////////////////////////////////////////////////////\n    void seek(Uint64 sampleOffset);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Change the current read position to the given time offset\n    ///\n    /// Using a time offset is handy but imprecise. If you need an accurate\n    /// result, consider using the overload which takes a sample offset.\n    ///\n    /// If the given time exceeds to total duration, this function jumps\n    /// to the end of the sound file.\n    ///\n    /// \\param timeOffset Time to jump to, relative to the beginning\n    ///\n    ////////////////////////////////////////////////////////////\n    void seek(Time timeOffset);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Read audio samples from the open file\n    ///\n    /// \\param samples  Pointer to the sample array to fill\n    /// \\param maxCount Maximum number of samples to read\n    ///\n    /// \\return Number of samples actually read (may be less than \\a maxCount)\n    ///\n    ////////////////////////////////////////////////////////////\n    Uint64 read(Int16* samples, Uint64 maxCount);\n\nprivate:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Close the current file\n    ///\n    ////////////////////////////////////////////////////////////\n    void close();\n\n    ////////////////////////////////////////////////////////////\n    // Member data\n    ////////////////////////////////////////////////////////////\n    SoundFileReader* m_reader;       ///< Reader that handles I/O on the file's format\n    InputStream*     m_stream;       ///< Input stream used to access the file's data\n    bool             m_streamOwned;  ///< Is the stream internal or external?\n    Uint64           m_sampleCount;  ///< Total number of samples in the file\n    unsigned int     m_channelCount; ///< Number of channels of the sound\n    unsigned int     m_sampleRate;   ///< Number of samples per second\n};\n\n} // namespace sf\n\n\n#endif // SFML_INPUTSOUNDFILE_HPP\n\n\n////////////////////////////////////////////////////////////\n/// \\class sf::InputSoundFile\n/// \\ingroup audio\n///\n/// This class decodes audio samples from a sound file. It is\n/// used internally by higher-level classes such as sf::SoundBuffer\n/// and sf::Music, but can also be useful if you want to process\n/// or analyze audio files without playing them, or if you want to\n/// implement your own version of sf::Music with more specific\n/// features.\n///\n/// Usage example:\n/// \\code\n/// // Open a sound file\n/// sf::InputSoundFile file;\n/// if (!file.openFromFile(\"music.ogg\"))\n///     /* error */;\n///\n/// // Print the sound attributes\n/// std::cout << \"duration: \" << file.getDuration().asSeconds() << std::endl;\n/// std::cout << \"channels: \" << file.getChannelCount() << std::endl;\n/// std::cout << \"sample rate: \" << file.getSampleRate() << std::endl;\n/// std::cout << \"sample count: \" << file.getSampleCount() << std::endl;\n///\n/// // Read and process batches of samples until the end of file is reached\n/// sf::Int16 samples[1024];\n/// sf::Uint64 count;\n/// do\n/// {\n///     count = file.read(samples, 1024);\n///\n///     // process, analyze, play, convert, or whatever\n///     // you want to do with the samples...\n/// }\n/// while (count > 0);\n/// \\endcode\n///\n/// \\see sf::SoundFileReader, sf::OutputSoundFile\n///\n////////////////////////////////////////////////////////////\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/Audio/Listener.hpp",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n#ifndef SFML_LISTENER_HPP\n#define SFML_LISTENER_HPP\n\n////////////////////////////////////////////////////////////\n// Headers\n////////////////////////////////////////////////////////////\n#include <SFML/Audio/Export.hpp>\n#include <SFML/System/Vector3.hpp>\n\n\nnamespace sf\n{\n////////////////////////////////////////////////////////////\n/// \\brief The audio listener is the point in the scene\n///        from where all the sounds are heard\n///\n////////////////////////////////////////////////////////////\nclass SFML_AUDIO_API Listener\n{\npublic:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Change the global volume of all the sounds and musics\n    ///\n    /// The volume is a number between 0 and 100; it is combined with\n    /// the individual volume of each sound / music.\n    /// The default value for the volume is 100 (maximum).\n    ///\n    /// \\param volume New global volume, in the range [0, 100]\n    ///\n    /// \\see getGlobalVolume\n    ///\n    ////////////////////////////////////////////////////////////\n    static void setGlobalVolume(float volume);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the current value of the global volume\n    ///\n    /// \\return Current global volume, in the range [0, 100]\n    ///\n    /// \\see setGlobalVolume\n    ///\n    ////////////////////////////////////////////////////////////\n    static float getGlobalVolume();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Set the position of the listener in the scene\n    ///\n    /// The default listener's position is (0, 0, 0).\n    ///\n    /// \\param x X coordinate of the listener's position\n    /// \\param y Y coordinate of the listener's position\n    /// \\param z Z coordinate of the listener's position\n    ///\n    /// \\see getPosition, setDirection\n    ///\n    ////////////////////////////////////////////////////////////\n    static void setPosition(float x, float y, float z);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Set the position of the listener in the scene\n    ///\n    /// The default listener's position is (0, 0, 0).\n    ///\n    /// \\param position New listener's position\n    ///\n    /// \\see getPosition, setDirection\n    ///\n    ////////////////////////////////////////////////////////////\n    static void setPosition(const Vector3f& position);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the current position of the listener in the scene\n    ///\n    /// \\return Listener's position\n    ///\n    /// \\see setPosition\n    ///\n    ////////////////////////////////////////////////////////////\n    static Vector3f getPosition();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Set the forward vector of the listener in the scene\n    ///\n    /// The direction (also called \"at vector\") is the vector\n    /// pointing forward from the listener's perspective. Together\n    /// with the up vector, it defines the 3D orientation of the\n    /// listener in the scene. The direction vector doesn't\n    /// have to be normalized.\n    /// The default listener's direction is (0, 0, -1).\n    ///\n    /// \\param x X coordinate of the listener's direction\n    /// \\param y Y coordinate of the listener's direction\n    /// \\param z Z coordinate of the listener's direction\n    ///\n    /// \\see getDirection, setUpVector, setPosition\n    ///\n    ////////////////////////////////////////////////////////////\n    static void setDirection(float x, float y, float z);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Set the forward vector of the listener in the scene\n    ///\n    /// The direction (also called \"at vector\") is the vector\n    /// pointing forward from the listener's perspective. Together\n    /// with the up vector, it defines the 3D orientation of the\n    /// listener in the scene. The direction vector doesn't\n    /// have to be normalized.\n    /// The default listener's direction is (0, 0, -1).\n    ///\n    /// \\param direction New listener's direction\n    ///\n    /// \\see getDirection, setUpVector, setPosition\n    ///\n    ////////////////////////////////////////////////////////////\n    static void setDirection(const Vector3f& direction);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the current forward vector of the listener in the scene\n    ///\n    /// \\return Listener's forward vector (not normalized)\n    ///\n    /// \\see setDirection\n    ///\n    ////////////////////////////////////////////////////////////\n    static Vector3f getDirection();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Set the upward vector of the listener in the scene\n    ///\n    /// The up vector is the vector that points upward from the\n    /// listener's perspective. Together with the direction, it\n    /// defines the 3D orientation of the listener in the scene.\n    /// The up vector doesn't have to be normalized.\n    /// The default listener's up vector is (0, 1, 0). It is usually\n    /// not necessary to change it, especially in 2D scenarios.\n    ///\n    /// \\param x X coordinate of the listener's up vector\n    /// \\param y Y coordinate of the listener's up vector\n    /// \\param z Z coordinate of the listener's up vector\n    ///\n    /// \\see getUpVector, setDirection, setPosition\n    ///\n    ////////////////////////////////////////////////////////////\n    static void setUpVector(float x, float y, float z);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Set the upward vector of the listener in the scene\n    ///\n    /// The up vector is the vector that points upward from the\n    /// listener's perspective. Together with the direction, it\n    /// defines the 3D orientation of the listener in the scene.\n    /// The up vector doesn't have to be normalized.\n    /// The default listener's up vector is (0, 1, 0). It is usually\n    /// not necessary to change it, especially in 2D scenarios.\n    ///\n    /// \\param upVector New listener's up vector\n    ///\n    /// \\see getUpVector, setDirection, setPosition\n    ///\n    ////////////////////////////////////////////////////////////\n    static void setUpVector(const Vector3f& upVector);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the current upward vector of the listener in the scene\n    ///\n    /// \\return Listener's upward vector (not normalized)\n    ///\n    /// \\see setUpVector\n    ///\n    ////////////////////////////////////////////////////////////\n    static Vector3f getUpVector();\n};\n\n} // namespace sf\n\n\n#endif // SFML_LISTENER_HPP\n\n\n////////////////////////////////////////////////////////////\n/// \\class sf::Listener\n/// \\ingroup audio\n///\n/// The audio listener defines the global properties of the\n/// audio environment, it defines where and how sounds and musics\n/// are heard. If sf::View is the eyes of the user, then sf::Listener\n/// is his ears (by the way, they are often linked together --\n/// same position, orientation, etc.).\n///\n/// sf::Listener is a simple interface, which allows to setup the\n/// listener in the 3D audio environment (position, direction and\n/// up vector), and to adjust the global volume.\n///\n/// Because the listener is unique in the scene, sf::Listener only\n/// contains static functions and doesn't have to be instantiated.\n///\n/// Usage example:\n/// \\code\n/// // Move the listener to the position (1, 0, -5)\n/// sf::Listener::setPosition(1, 0, -5);\n///\n/// // Make it face the right axis (1, 0, 0)\n/// sf::Listener::setDirection(1, 0, 0);\n///\n/// // Reduce the global volume\n/// sf::Listener::setGlobalVolume(50);\n/// \\endcode\n///\n////////////////////////////////////////////////////////////\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/Audio/Music.hpp",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n#ifndef SFML_MUSIC_HPP\n#define SFML_MUSIC_HPP\n\n////////////////////////////////////////////////////////////\n// Headers\n////////////////////////////////////////////////////////////\n#include <SFML/Audio/Export.hpp>\n#include <SFML/Audio/SoundStream.hpp>\n#include <SFML/Audio/InputSoundFile.hpp>\n#include <SFML/System/Mutex.hpp>\n#include <SFML/System/Time.hpp>\n#include <string>\n#include <vector>\n\n\nnamespace sf\n{\nclass InputStream;\n\n////////////////////////////////////////////////////////////\n/// \\brief Streamed music played from an audio file\n///\n////////////////////////////////////////////////////////////\nclass SFML_AUDIO_API Music : public SoundStream\n{\npublic:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Default constructor\n    ///\n    ////////////////////////////////////////////////////////////\n    Music();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Destructor\n    ///\n    ////////////////////////////////////////////////////////////\n    ~Music();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Open a music from an audio file\n    ///\n    /// This function doesn't start playing the music (call play()\n    /// to do so).\n    /// See the documentation of sf::InputSoundFile for the list\n    /// of supported formats.\n    ///\n    /// \\warning Since the music is not loaded at once but rather\n    /// streamed continuously, the file must remain accessible until\n    /// the sf::Music object loads a new music or is destroyed.\n    ///\n    /// \\param filename Path of the music file to open\n    ///\n    /// \\return True if loading succeeded, false if it failed\n    ///\n    /// \\see openFromMemory, openFromStream\n    ///\n    ////////////////////////////////////////////////////////////\n    bool openFromFile(const std::string& filename);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Open a music from an audio file in memory\n    ///\n    /// This function doesn't start playing the music (call play()\n    /// to do so).\n    /// See the documentation of sf::InputSoundFile for the list\n    /// of supported formats.\n    ///\n    /// \\warning Since the music is not loaded at once but rather streamed\n    /// continuously, the \\a data buffer must remain accessible until\n    /// the sf::Music object loads a new music or is destroyed. That is,\n    /// you can't deallocate the buffer right after calling this function.\n    ///\n    /// \\param data        Pointer to the file data in memory\n    /// \\param sizeInBytes Size of the data to load, in bytes\n    ///\n    /// \\return True if loading succeeded, false if it failed\n    ///\n    /// \\see openFromFile, openFromStream\n    ///\n    ////////////////////////////////////////////////////////////\n    bool openFromMemory(const void* data, std::size_t sizeInBytes);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Open a music from an audio file in a custom stream\n    ///\n    /// This function doesn't start playing the music (call play()\n    /// to do so).\n    /// See the documentation of sf::InputSoundFile for the list\n    /// of supported formats.\n    ///\n    /// \\warning Since the music is not loaded at once but rather\n    /// streamed continuously, the \\a stream must remain accessible\n    /// until the sf::Music object loads a new music or is destroyed.\n    ///\n    /// \\param stream Source stream to read from\n    ///\n    /// \\return True if loading succeeded, false if it failed\n    ///\n    /// \\see openFromFile, openFromMemory\n    ///\n    ////////////////////////////////////////////////////////////\n    bool openFromStream(InputStream& stream);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the total duration of the music\n    ///\n    /// \\return Music duration\n    ///\n    ////////////////////////////////////////////////////////////\n    Time getDuration() const;\n\nprotected:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Request a new chunk of audio samples from the stream source\n    ///\n    /// This function fills the chunk from the next samples\n    /// to read from the audio file.\n    ///\n    /// \\param data Chunk of data to fill\n    ///\n    /// \\return True to continue playback, false to stop\n    ///\n    ////////////////////////////////////////////////////////////\n    virtual bool onGetData(Chunk& data);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Change the current playing position in the stream source\n    ///\n    /// \\param timeOffset New playing position, from the beginning of the music\n    ///\n    ////////////////////////////////////////////////////////////\n    virtual void onSeek(Time timeOffset);\n\nprivate:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Initialize the internal state after loading a new music\n    ///\n    ////////////////////////////////////////////////////////////\n    void initialize();\n\n    ////////////////////////////////////////////////////////////\n    // Member data\n    ////////////////////////////////////////////////////////////\n    InputSoundFile     m_file;     ///< The streamed music file\n    Time               m_duration; ///< Music duration\n    std::vector<Int16> m_samples;  ///< Temporary buffer of samples\n    Mutex              m_mutex;    ///< Mutex protecting the data\n};\n\n} // namespace sf\n\n\n#endif // SFML_MUSIC_HPP\n\n\n////////////////////////////////////////////////////////////\n/// \\class sf::Music\n/// \\ingroup audio\n///\n/// Musics are sounds that are streamed rather than completely\n/// loaded in memory. This is especially useful for compressed\n/// musics that usually take hundreds of MB when they are\n/// uncompressed: by streaming it instead of loading it entirely,\n/// you avoid saturating the memory and have almost no loading delay.\n/// This implies that the underlying resource (file, stream or\n/// memory buffer) must remain valid for the lifetime of the\n/// sf::Music object.\n///\n/// Apart from that, a sf::Music has almost the same features as\n/// the sf::SoundBuffer / sf::Sound pair: you can play/pause/stop\n/// it, request its parameters (channels, sample rate), change\n/// the way it is played (pitch, volume, 3D position, ...), etc.\n///\n/// As a sound stream, a music is played in its own thread in order\n/// not to block the rest of the program. This means that you can\n/// leave the music alone after calling play(), it will manage itself\n/// very well.\n///\n/// Usage example:\n/// \\code\n/// // Declare a new music\n/// sf::Music music;\n///\n/// // Open it from an audio file\n/// if (!music.openFromFile(\"music.ogg\"))\n/// {\n///     // error...\n/// }\n///\n/// // Change some parameters\n/// music.setPosition(0, 1, 10); // change its 3D position\n/// music.setPitch(2);           // increase the pitch\n/// music.setVolume(50);         // reduce the volume\n/// music.setLoop(true);         // make it loop\n///\n/// // Play it\n/// music.play();\n/// \\endcode\n///\n/// \\see sf::Sound, sf::SoundStream\n///\n////////////////////////////////////////////////////////////\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/Audio/OutputSoundFile.hpp",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n#ifndef SFML_OUTPUTSOUNDFILE_HPP\n#define SFML_OUTPUTSOUNDFILE_HPP\n\n////////////////////////////////////////////////////////////\n// Headers\n////////////////////////////////////////////////////////////\n#include <SFML/Audio/Export.hpp>\n#include <SFML/System/NonCopyable.hpp>\n#include <string>\n\n\nnamespace sf\n{\nclass SoundFileWriter;\n\n////////////////////////////////////////////////////////////\n/// \\brief Provide write access to sound files\n///\n////////////////////////////////////////////////////////////\nclass SFML_AUDIO_API OutputSoundFile : NonCopyable\n{\npublic:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Default constructor\n    ///\n    ////////////////////////////////////////////////////////////\n    OutputSoundFile();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Destructor\n    ///\n    /// Closes the file if it was still open.\n    ///\n    ////////////////////////////////////////////////////////////\n    ~OutputSoundFile();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Open the sound file from the disk for writing\n    ///\n    /// The supported audio formats are: WAV, OGG/Vorbis, FLAC.\n    ///\n    /// \\param filename     Path of the sound file to write\n    /// \\param sampleRate   Sample rate of the sound\n    /// \\param channelCount Number of channels in the sound\n    ///\n    /// \\return True if the file was successfully opened\n    ///\n    ////////////////////////////////////////////////////////////\n    bool openFromFile(const std::string& filename, unsigned int sampleRate, unsigned int channelCount);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Write audio samples to the file\n    ///\n    /// \\param samples     Pointer to the sample array to write\n    /// \\param count       Number of samples to write\n    ///\n    ////////////////////////////////////////////////////////////\n    void write(const Int16* samples, Uint64 count);\n\nprivate:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Close the current file\n    ///\n    ////////////////////////////////////////////////////////////\n    void close();\n\n    ////////////////////////////////////////////////////////////\n    // Member data\n    ////////////////////////////////////////////////////////////\n    SoundFileWriter* m_writer; ///< Writer that handles I/O on the file's format\n};\n\n} // namespace sf\n\n\n#endif // SFML_OUTPUTSOUNDFILE_HPP\n\n\n////////////////////////////////////////////////////////////\n/// \\class sf::OutputSoundFile\n/// \\ingroup audio\n///\n/// This class encodes audio samples to a sound file. It is\n/// used internally by higher-level classes such as sf::SoundBuffer,\n/// but can also be useful if you want to create audio files from\n/// custom data sources, like generated audio samples.\n///\n/// Usage example:\n/// \\code\n/// // Create a sound file, ogg/vorbis format, 44100 Hz, stereo\n/// sf::OutputSoundFile file;\n/// if (!file.openFromFile(\"music.ogg\", 44100, 2))\n///     /* error */;\n///\n/// while (...)\n/// {\n///     // Read or generate audio samples from your custom source\n///     std::vector<sf::Int16> samples = ...;\n///\n///     // Write them to the file\n///     file.write(samples.data(), samples.size());\n/// }\n/// \\endcode\n///\n/// \\see sf::SoundFileWriter, sf::InputSoundFile\n///\n////////////////////////////////////////////////////////////\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/Audio/Sound.hpp",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n#ifndef SFML_SOUND_HPP\n#define SFML_SOUND_HPP\n\n////////////////////////////////////////////////////////////\n// Headers\n////////////////////////////////////////////////////////////\n#include <SFML/Audio/Export.hpp>\n#include <SFML/Audio/SoundSource.hpp>\n#include <SFML/System/Time.hpp>\n#include <cstdlib>\n\n\nnamespace sf\n{\nclass SoundBuffer;\n\n////////////////////////////////////////////////////////////\n/// \\brief Regular sound that can be played in the audio environment\n///\n////////////////////////////////////////////////////////////\nclass SFML_AUDIO_API Sound : public SoundSource\n{\npublic:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Default constructor\n    ///\n    ////////////////////////////////////////////////////////////\n    Sound();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Construct the sound with a buffer\n    ///\n    /// \\param buffer Sound buffer containing the audio data to play with the sound\n    ///\n    ////////////////////////////////////////////////////////////\n    explicit Sound(const SoundBuffer& buffer);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Copy constructor\n    ///\n    /// \\param copy Instance to copy\n    ///\n    ////////////////////////////////////////////////////////////\n    Sound(const Sound& copy);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Destructor\n    ///\n    ////////////////////////////////////////////////////////////\n    ~Sound();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Start or resume playing the sound\n    ///\n    /// This function starts the stream if it was stopped, resumes\n    /// it if it was paused, and restarts it from beginning if it\n    /// was it already playing.\n    /// This function uses its own thread so that it doesn't block\n    /// the rest of the program while the sound is played.\n    ///\n    /// \\see pause, stop\n    ///\n    ////////////////////////////////////////////////////////////\n    void play();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Pause the sound\n    ///\n    /// This function pauses the sound if it was playing,\n    /// otherwise (sound already paused or stopped) it has no effect.\n    ///\n    /// \\see play, stop\n    ///\n    ////////////////////////////////////////////////////////////\n    void pause();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief stop playing the sound\n    ///\n    /// This function stops the sound if it was playing or paused,\n    /// and does nothing if it was already stopped.\n    /// It also resets the playing position (unlike pause()).\n    ///\n    /// \\see play, pause\n    ///\n    ////////////////////////////////////////////////////////////\n    void stop();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Set the source buffer containing the audio data to play\n    ///\n    /// It is important to note that the sound buffer is not copied,\n    /// thus the sf::SoundBuffer instance must remain alive as long\n    /// as it is attached to the sound.\n    ///\n    /// \\param buffer Sound buffer to attach to the sound\n    ///\n    /// \\see getBuffer\n    ///\n    ////////////////////////////////////////////////////////////\n    void setBuffer(const SoundBuffer& buffer);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Set whether or not the sound should loop after reaching the end\n    ///\n    /// If set, the sound will restart from beginning after\n    /// reaching the end and so on, until it is stopped or\n    /// setLoop(false) is called.\n    /// The default looping state for sound is false.\n    ///\n    /// \\param loop True to play in loop, false to play once\n    ///\n    /// \\see getLoop\n    ///\n    ////////////////////////////////////////////////////////////\n    void setLoop(bool loop);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Change the current playing position of the sound\n    ///\n    /// The playing position can be changed when the sound is\n    /// either paused or playing. Changing the playing position\n    /// when the sound is stopped has no effect, since playing\n    /// the sound will reset its position.\n    ///\n    /// \\param timeOffset New playing position, from the beginning of the sound\n    ///\n    /// \\see getPlayingOffset\n    ///\n    ////////////////////////////////////////////////////////////\n    void setPlayingOffset(Time timeOffset);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the audio buffer attached to the sound\n    ///\n    /// \\return Sound buffer attached to the sound (can be NULL)\n    ///\n    ////////////////////////////////////////////////////////////\n    const SoundBuffer* getBuffer() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Tell whether or not the sound is in loop mode\n    ///\n    /// \\return True if the sound is looping, false otherwise\n    ///\n    /// \\see setLoop\n    ///\n    ////////////////////////////////////////////////////////////\n    bool getLoop() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the current playing position of the sound\n    ///\n    /// \\return Current playing position, from the beginning of the sound\n    ///\n    /// \\see setPlayingOffset\n    ///\n    ////////////////////////////////////////////////////////////\n    Time getPlayingOffset() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the current status of the sound (stopped, paused, playing)\n    ///\n    /// \\return Current status of the sound\n    ///\n    ////////////////////////////////////////////////////////////\n    Status getStatus() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Overload of assignment operator\n    ///\n    /// \\param right Instance to assign\n    ///\n    /// \\return Reference to self\n    ///\n    ////////////////////////////////////////////////////////////\n    Sound& operator =(const Sound& right);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Reset the internal buffer of the sound\n    ///\n    /// This function is for internal use only, you don't have\n    /// to use it. It is called by the sf::SoundBuffer that\n    /// this sound uses, when it is destroyed in order to prevent\n    /// the sound from using a dead buffer.\n    ///\n    ////////////////////////////////////////////////////////////\n    void resetBuffer();\n\nprivate:\n\n    ////////////////////////////////////////////////////////////\n    // Member data\n    ////////////////////////////////////////////////////////////\n    const SoundBuffer* m_buffer; ///< Sound buffer bound to the source\n};\n\n} // namespace sf\n\n\n#endif // SFML_SOUND_HPP\n\n\n////////////////////////////////////////////////////////////\n/// \\class sf::Sound\n/// \\ingroup audio\n///\n/// sf::Sound is the class to use to play sounds.\n/// It provides:\n/// \\li Control (play, pause, stop)\n/// \\li Ability to modify output parameters in real-time (pitch, volume, ...)\n/// \\li 3D spatial features (position, attenuation, ...).\n///\n/// sf::Sound is perfect for playing short sounds that can\n/// fit in memory and require no latency, like foot steps or\n/// gun shots. For longer sounds, like background musics\n/// or long speeches, rather see sf::Music (which is based\n/// on streaming).\n///\n/// In order to work, a sound must be given a buffer of audio\n/// data to play. Audio data (samples) is stored in sf::SoundBuffer,\n/// and attached to a sound with the setBuffer() function.\n/// The buffer object attached to a sound must remain alive\n/// as long as the sound uses it. Note that multiple sounds\n/// can use the same sound buffer at the same time.\n///\n/// Usage example:\n/// \\code\n/// sf::SoundBuffer buffer;\n/// buffer.loadFromFile(\"sound.wav\");\n///\n/// sf::Sound sound;\n/// sound.setBuffer(buffer);\n/// sound.play();\n/// \\endcode\n///\n/// \\see sf::SoundBuffer, sf::Music\n///\n////////////////////////////////////////////////////////////\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/Audio/SoundBuffer.hpp",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n#ifndef SFML_SOUNDBUFFER_HPP\n#define SFML_SOUNDBUFFER_HPP\n\n////////////////////////////////////////////////////////////\n// Headers\n////////////////////////////////////////////////////////////\n#include <SFML/Audio/Export.hpp>\n#include <SFML/Audio/AlResource.hpp>\n#include <SFML/System/Time.hpp>\n#include <string>\n#include <vector>\n#include <set>\n\n\nnamespace sf\n{\nclass Sound;\nclass InputSoundFile;\nclass InputStream;\n\n////////////////////////////////////////////////////////////\n/// \\brief Storage for audio samples defining a sound\n///\n////////////////////////////////////////////////////////////\nclass SFML_AUDIO_API SoundBuffer : AlResource\n{\npublic:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Default constructor\n    ///\n    ////////////////////////////////////////////////////////////\n    SoundBuffer();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Copy constructor\n    ///\n    /// \\param copy Instance to copy\n    ///\n    ////////////////////////////////////////////////////////////\n    SoundBuffer(const SoundBuffer& copy);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Destructor\n    ///\n    ////////////////////////////////////////////////////////////\n    ~SoundBuffer();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Load the sound buffer from a file\n    ///\n    /// See the documentation of sf::InputSoundFile for the list\n    /// of supported formats.\n    ///\n    /// \\param filename Path of the sound file to load\n    ///\n    /// \\return True if loading succeeded, false if it failed\n    ///\n    /// \\see loadFromMemory, loadFromStream, loadFromSamples, saveToFile\n    ///\n    ////////////////////////////////////////////////////////////\n    bool loadFromFile(const std::string& filename);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Load the sound buffer from a file in memory\n    ///\n    /// See the documentation of sf::InputSoundFile for the list\n    /// of supported formats.\n    ///\n    /// \\param data        Pointer to the file data in memory\n    /// \\param sizeInBytes Size of the data to load, in bytes\n    ///\n    /// \\return True if loading succeeded, false if it failed\n    ///\n    /// \\see loadFromFile, loadFromStream, loadFromSamples\n    ///\n    ////////////////////////////////////////////////////////////\n    bool loadFromMemory(const void* data, std::size_t sizeInBytes);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Load the sound buffer from a custom stream\n    ///\n    /// See the documentation of sf::InputSoundFile for the list\n    /// of supported formats.\n    ///\n    /// \\param stream Source stream to read from\n    ///\n    /// \\return True if loading succeeded, false if it failed\n    ///\n    /// \\see loadFromFile, loadFromMemory, loadFromSamples\n    ///\n    ////////////////////////////////////////////////////////////\n    bool loadFromStream(InputStream& stream);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Load the sound buffer from an array of audio samples\n    ///\n    /// The assumed format of the audio samples is 16 bits signed integer\n    /// (sf::Int16).\n    ///\n    /// \\param samples      Pointer to the array of samples in memory\n    /// \\param sampleCount  Number of samples in the array\n    /// \\param channelCount Number of channels (1 = mono, 2 = stereo, ...)\n    /// \\param sampleRate   Sample rate (number of samples to play per second)\n    ///\n    /// \\return True if loading succeeded, false if it failed\n    ///\n    /// \\see loadFromFile, loadFromMemory, saveToFile\n    ///\n    ////////////////////////////////////////////////////////////\n    bool loadFromSamples(const Int16* samples, Uint64 sampleCount, unsigned int channelCount, unsigned int sampleRate);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Save the sound buffer to an audio file\n    ///\n    /// See the documentation of sf::OutputSoundFile for the list\n    /// of supported formats.\n    ///\n    /// \\param filename Path of the sound file to write\n    ///\n    /// \\return True if saving succeeded, false if it failed\n    ///\n    /// \\see loadFromFile, loadFromMemory, loadFromSamples\n    ///\n    ////////////////////////////////////////////////////////////\n    bool saveToFile(const std::string& filename) const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the array of audio samples stored in the buffer\n    ///\n    /// The format of the returned samples is 16 bits signed integer\n    /// (sf::Int16). The total number of samples in this array\n    /// is given by the getSampleCount() function.\n    ///\n    /// \\return Read-only pointer to the array of sound samples\n    ///\n    /// \\see getSampleCount\n    ///\n    ////////////////////////////////////////////////////////////\n    const Int16* getSamples() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the number of samples stored in the buffer\n    ///\n    /// The array of samples can be accessed with the getSamples()\n    /// function.\n    ///\n    /// \\return Number of samples\n    ///\n    /// \\see getSamples\n    ///\n    ////////////////////////////////////////////////////////////\n    Uint64 getSampleCount() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the sample rate of the sound\n    ///\n    /// The sample rate is the number of samples played per second.\n    /// The higher, the better the quality (for example, 44100\n    /// samples/s is CD quality).\n    ///\n    /// \\return Sample rate (number of samples per second)\n    ///\n    /// \\see getChannelCount, getDuration\n    ///\n    ////////////////////////////////////////////////////////////\n    unsigned int getSampleRate() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the number of channels used by the sound\n    ///\n    /// If the sound is mono then the number of channels will\n    /// be 1, 2 for stereo, etc.\n    ///\n    /// \\return Number of channels\n    ///\n    /// \\see getSampleRate, getDuration\n    ///\n    ////////////////////////////////////////////////////////////\n    unsigned int getChannelCount() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the total duration of the sound\n    ///\n    /// \\return Sound duration\n    ///\n    /// \\see getSampleRate, getChannelCount\n    ///\n    ////////////////////////////////////////////////////////////\n    Time getDuration() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Overload of assignment operator\n    ///\n    /// \\param right Instance to assign\n    ///\n    /// \\return Reference to self\n    ///\n    ////////////////////////////////////////////////////////////\n    SoundBuffer& operator =(const SoundBuffer& right);\n\nprivate:\n\n    friend class Sound;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Initialize the internal state after loading a new sound\n    ///\n    /// \\param file Sound file providing access to the new loaded sound\n    ///\n    /// \\return True on successful initialization, false on failure\n    ///\n    ////////////////////////////////////////////////////////////\n    bool initialize(InputSoundFile& file);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Update the internal buffer with the cached audio samples\n    ///\n    /// \\param channelCount Number of channels\n    /// \\param sampleRate   Sample rate (number of samples per second)\n    ///\n    /// \\return True on success, false if any error happened\n    ///\n    ////////////////////////////////////////////////////////////\n    bool update(unsigned int channelCount, unsigned int sampleRate);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Add a sound to the list of sounds that use this buffer\n    ///\n    /// \\param sound Sound instance to attach\n    ///\n    ////////////////////////////////////////////////////////////\n    void attachSound(Sound* sound) const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Remove a sound from the list of sounds that use this buffer\n    ///\n    /// \\param sound Sound instance to detach\n    ///\n    ////////////////////////////////////////////////////////////\n    void detachSound(Sound* sound) const;\n\n    ////////////////////////////////////////////////////////////\n    // Types\n    ////////////////////////////////////////////////////////////\n    typedef std::set<Sound*> SoundList; ///< Set of unique sound instances\n\n    ////////////////////////////////////////////////////////////\n    // Member data\n    ////////////////////////////////////////////////////////////\n    unsigned int       m_buffer;   ///< OpenAL buffer identifier\n    std::vector<Int16> m_samples;  ///< Samples buffer\n    Time               m_duration; ///< Sound duration\n    mutable SoundList  m_sounds;   ///< List of sounds that are using this buffer\n};\n\n} // namespace sf\n\n\n#endif // SFML_SOUNDBUFFER_HPP\n\n\n////////////////////////////////////////////////////////////\n/// \\class sf::SoundBuffer\n/// \\ingroup audio\n///\n/// A sound buffer holds the data of a sound, which is\n/// an array of audio samples. A sample is a 16 bits signed integer\n/// that defines the amplitude of the sound at a given time.\n/// The sound is then reconstituted by playing these samples at\n/// a high rate (for example, 44100 samples per second is the\n/// standard rate used for playing CDs). In short, audio samples\n/// are like texture pixels, and a sf::SoundBuffer is similar to\n/// a sf::Texture.\n///\n/// A sound buffer can be loaded from a file (see loadFromFile()\n/// for the complete list of supported formats), from memory, from\n/// a custom stream (see sf::InputStream) or directly from an array\n/// of samples. It can also be saved back to a file.\n///\n/// Sound buffers alone are not very useful: they hold the audio data\n/// but cannot be played. To do so, you need to use the sf::Sound class,\n/// which provides functions to play/pause/stop the sound as well as\n/// changing the way it is outputted (volume, pitch, 3D position, ...).\n/// This separation allows more flexibility and better performances:\n/// indeed a sf::SoundBuffer is a heavy resource, and any operation on it\n/// is slow (often too slow for real-time applications). On the other\n/// side, a sf::Sound is a lightweight object, which can use the audio data\n/// of a sound buffer and change the way it is played without actually\n/// modifying that data. Note that it is also possible to bind\n/// several sf::Sound instances to the same sf::SoundBuffer.\n///\n/// It is important to note that the sf::Sound instance doesn't\n/// copy the buffer that it uses, it only keeps a reference to it.\n/// Thus, a sf::SoundBuffer must not be destructed while it is\n/// used by a sf::Sound (i.e. never write a function that\n/// uses a local sf::SoundBuffer instance for loading a sound).\n///\n/// Usage example:\n/// \\code\n/// // Declare a new sound buffer\n/// sf::SoundBuffer buffer;\n///\n/// // Load it from a file\n/// if (!buffer.loadFromFile(\"sound.wav\"))\n/// {\n///     // error...\n/// }\n///\n/// // Create a sound source and bind it to the buffer\n/// sf::Sound sound1;\n/// sound1.setBuffer(buffer);\n///\n/// // Play the sound\n/// sound1.play();\n///\n/// // Create another sound source bound to the same buffer\n/// sf::Sound sound2;\n/// sound2.setBuffer(buffer);\n///\n/// // Play it with a higher pitch -- the first sound remains unchanged\n/// sound2.setPitch(2);\n/// sound2.play();\n/// \\endcode\n///\n/// \\see sf::Sound, sf::SoundBufferRecorder\n///\n////////////////////////////////////////////////////////////\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/Audio/SoundBufferRecorder.hpp",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n#ifndef SFML_SOUNDBUFFERRECORDER_HPP\n#define SFML_SOUNDBUFFERRECORDER_HPP\n\n////////////////////////////////////////////////////////////\n// Headers\n////////////////////////////////////////////////////////////\n#include <SFML/Audio/Export.hpp>\n#include <SFML/Audio/SoundBuffer.hpp>\n#include <SFML/Audio/SoundRecorder.hpp>\n#include <vector>\n\n\nnamespace sf\n{\n////////////////////////////////////////////////////////////\n/// \\brief Specialized SoundRecorder which stores the captured\n///        audio data into a sound buffer\n///\n////////////////////////////////////////////////////////////\nclass SFML_AUDIO_API SoundBufferRecorder : public SoundRecorder\n{\npublic:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief destructor\n    ///\n    ////////////////////////////////////////////////////////////\n    ~SoundBufferRecorder();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the sound buffer containing the captured audio data\n    ///\n    /// The sound buffer is valid only after the capture has ended.\n    /// This function provides a read-only access to the internal\n    /// sound buffer, but it can be copied if you need to\n    /// make any modification to it.\n    ///\n    /// \\return Read-only access to the sound buffer\n    ///\n    ////////////////////////////////////////////////////////////\n    const SoundBuffer& getBuffer() const;\n\nprotected:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Start capturing audio data\n    ///\n    /// \\return True to start the capture, or false to abort it\n    ///\n    ////////////////////////////////////////////////////////////\n    virtual bool onStart();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Process a new chunk of recorded samples\n    ///\n    /// \\param samples     Pointer to the new chunk of recorded samples\n    /// \\param sampleCount Number of samples pointed by \\a samples\n    ///\n    /// \\return True to continue the capture, or false to stop it\n    ///\n    ////////////////////////////////////////////////////////////\n    virtual bool onProcessSamples(const Int16* samples, std::size_t sampleCount);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Stop capturing audio data\n    ///\n    ////////////////////////////////////////////////////////////\n    virtual void onStop();\n\nprivate:\n\n    ////////////////////////////////////////////////////////////\n    // Member data\n    ////////////////////////////////////////////////////////////\n    std::vector<Int16> m_samples; ///< Temporary sample buffer to hold the recorded data\n    SoundBuffer        m_buffer;  ///< Sound buffer that will contain the recorded data\n};\n\n} // namespace sf\n\n#endif // SFML_SOUNDBUFFERRECORDER_HPP\n\n\n////////////////////////////////////////////////////////////\n/// \\class sf::SoundBufferRecorder\n/// \\ingroup audio\n///\n/// sf::SoundBufferRecorder allows to access a recorded sound\n/// through a sf::SoundBuffer, so that it can be played, saved\n/// to a file, etc.\n///\n/// It has the same simple interface as its base class (start(), stop())\n/// and adds a function to retrieve the recorded sound buffer\n/// (getBuffer()).\n///\n/// As usual, don't forget to call the isAvailable() function\n/// before using this class (see sf::SoundRecorder for more details\n/// about this).\n///\n/// Usage example:\n/// \\code\n/// if (sf::SoundBufferRecorder::isAvailable())\n/// {\n///     // Record some audio data\n///     sf::SoundBufferRecorder recorder;\n///     recorder.start();\n///     ...\n///     recorder.stop();\n///\n///     // Get the buffer containing the captured audio data\n///     const sf::SoundBuffer& buffer = recorder.getBuffer();\n///\n///     // Save it to a file (for example...)\n///     buffer.saveToFile(\"my_record.ogg\");\n/// }\n/// \\endcode\n///\n/// \\see sf::SoundRecorder\n///\n////////////////////////////////////////////////////////////\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/Audio/SoundFileFactory.hpp",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n#ifndef SFML_SOUNDFILEFACTORY_HPP\n#define SFML_SOUNDFILEFACTORY_HPP\n\n////////////////////////////////////////////////////////////\n// Headers\n////////////////////////////////////////////////////////////\n#include <SFML/Audio/Export.hpp>\n#include <string>\n#include <vector>\n\n\nnamespace sf\n{\nclass InputStream;\nclass SoundFileReader;\nclass SoundFileWriter;\n\n////////////////////////////////////////////////////////////\n/// \\brief Manages and instantiates sound file readers and writers\n///\n////////////////////////////////////////////////////////////\nclass SFML_AUDIO_API SoundFileFactory\n{\npublic:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Register a new reader\n    ///\n    /// \\see unregisterReader\n    ///\n    ////////////////////////////////////////////////////////////\n    template <typename T>\n    static void registerReader();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Unregister a reader\n    ///\n    /// \\see registerReader\n    ///\n    ////////////////////////////////////////////////////////////\n    template <typename T>\n    static void unregisterReader();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Register a new writer\n    ///\n    /// \\see unregisterWriter\n    ///\n    ////////////////////////////////////////////////////////////\n    template <typename T>\n    static void registerWriter();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Unregister a writer\n    ///\n    /// \\see registerWriter\n    ///\n    ////////////////////////////////////////////////////////////\n    template <typename T>\n    static void unregisterWriter();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Instantiate the right reader for the given file on disk\n    ///\n    /// It's up to the caller to release the returned reader\n    ///\n    /// \\param filename Path of the sound file\n    ///\n    /// \\return A new sound file reader that can read the given file, or null if no reader can handle it\n    ///\n    /// \\see createReaderFromMemory, createReaderFromStream\n    ///\n    ////////////////////////////////////////////////////////////\n    static SoundFileReader* createReaderFromFilename(const std::string& filename);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Instantiate the right codec for the given file in memory\n    ///\n    /// It's up to the caller to release the returned reader\n    ///\n    /// \\param data        Pointer to the file data in memory\n    /// \\param sizeInBytes Total size of the file data, in bytes\n    ///\n    /// \\return A new sound file codec that can read the given file, or null if no codec can handle it\n    ///\n    /// \\see createReaderFromFilename, createReaderFromStream\n    ///\n    ////////////////////////////////////////////////////////////\n    static SoundFileReader* createReaderFromMemory(const void* data, std::size_t sizeInBytes);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Instantiate the right codec for the given file in stream\n    ///\n    /// It's up to the caller to release the returned reader\n    ///\n    /// \\param stream Source stream to read from\n    ///\n    /// \\return A new sound file codec that can read the given file, or null if no codec can handle it\n    ///\n    /// \\see createReaderFromFilename, createReaderFromMemory\n    ///\n    ////////////////////////////////////////////////////////////\n    static SoundFileReader* createReaderFromStream(InputStream& stream);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Instantiate the right writer for the given file on disk\n    ///\n    /// It's up to the caller to release the returned writer\n    ///\n    /// \\param filename Path of the sound file\n    ///\n    /// \\return A new sound file writer that can write given file, or null if no writer can handle it\n    ///\n    ////////////////////////////////////////////////////////////\n    static SoundFileWriter* createWriterFromFilename(const std::string& filename);\n\nprivate:\n\n    ////////////////////////////////////////////////////////////\n    // Types\n    ////////////////////////////////////////////////////////////\n    struct ReaderFactory\n    {\n        bool (*check)(InputStream&);\n        SoundFileReader* (*create)();\n    };\n    typedef std::vector<ReaderFactory> ReaderFactoryArray;\n\n    struct WriterFactory\n    {\n        bool (*check)(const std::string&);\n        SoundFileWriter* (*create)();\n    };\n    typedef std::vector<WriterFactory> WriterFactoryArray;\n\n    ////////////////////////////////////////////////////////////\n    // Static member data\n    ////////////////////////////////////////////////////////////\n    static ReaderFactoryArray s_readers; ///< List of all registered readers\n    static WriterFactoryArray s_writers; ///< List of all registered writers\n};\n\n} // namespace sf\n\n#include <SFML/Audio/SoundFileFactory.inl>\n\n#endif // SFML_SOUNDFILEFACTORY_HPP\n\n\n////////////////////////////////////////////////////////////\n/// \\class sf::SoundFileFactory\n/// \\ingroup audio\n///\n/// This class is where all the sound file readers and writers are\n/// registered. You should normally only need to use its registration\n/// and unregistration functions; readers/writers creation and manipulation\n/// are wrapped into the higher-level classes sf::InputSoundFile and\n/// sf::OutputSoundFile.\n///\n/// To register a new reader (writer) use the sf::SoundFileFactory::registerReader\n/// (registerWriter) static function. You don't have to call the unregisterReader\n/// (unregisterWriter) function, unless you want to unregister a format before your\n/// application ends (typically, when a plugin is unloaded).\n///\n/// Usage example:\n/// \\code\n/// sf::SoundFileFactory::registerReader<MySoundFileReader>();\n/// sf::SoundFileFactory::registerWriter<MySoundFileWriter>();\n/// \\endcode\n///\n/// \\see sf::InputSoundFile, sf::OutputSoundFile, sf::SoundFileReader, sf::SoundFileWriter\n///\n////////////////////////////////////////////////////////////\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/Audio/SoundFileFactory.inl",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n////////////////////////////////////////////////////////////\n// Headers\n////////////////////////////////////////////////////////////\n\n\nnamespace sf\n{\nnamespace priv\n{\n    template <typename T> SoundFileReader* createReader() {return new T;}\n    template <typename T> SoundFileWriter* createWriter() {return new T;}\n}\n\n////////////////////////////////////////////////////////////\ntemplate <typename T>\nvoid SoundFileFactory::registerReader()\n{\n    // Make sure the same class won't be registered twice\n    unregisterReader<T>();\n\n    // Create a new factory with the functions provided by the class\n    ReaderFactory factory;\n    factory.check = &T::check;\n    factory.create = &priv::createReader<T>;\n\n    // Add it\n    s_readers.push_back(factory);\n}\n\n\n////////////////////////////////////////////////////////////\ntemplate <typename T>\nvoid SoundFileFactory::unregisterReader()\n{\n    // Remove the instance(s) of the reader from the array of factories\n    for (ReaderFactoryArray::iterator it = s_readers.begin(); it != s_readers.end(); )\n    {\n        if (it->create == &priv::createReader<T>)\n            it = s_readers.erase(it);\n        else\n            ++it;\n    }\n}\n\n////////////////////////////////////////////////////////////\ntemplate <typename T>\nvoid SoundFileFactory::registerWriter()\n{\n    // Make sure the same class won't be registered twice\n    unregisterWriter<T>();\n\n    // Create a new factory with the functions provided by the class\n    WriterFactory factory;\n    factory.check = &T::check;\n    factory.create = &priv::createWriter<T>;\n\n    // Add it\n    s_writers.push_back(factory);\n}\n\n\n////////////////////////////////////////////////////////////\ntemplate <typename T>\nvoid SoundFileFactory::unregisterWriter()\n{\n    // Remove the instance(s) of the writer from the array of factories\n    for (WriterFactoryArray::iterator it = s_writers.begin(); it != s_writers.end(); )\n    {\n        if (it->create == &priv::createWriter<T>)\n            it = s_writers.erase(it);\n        else\n            ++it;\n    }\n}\n\n} // namespace sf\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/Audio/SoundFileReader.hpp",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n#ifndef SFML_SOUNDFILEREADER_HPP\n#define SFML_SOUNDFILEREADER_HPP\n\n////////////////////////////////////////////////////////////\n// Headers\n////////////////////////////////////////////////////////////\n#include <SFML/Audio/Export.hpp>\n#include <string>\n\n\nnamespace sf\n{\nclass InputStream;\n\n////////////////////////////////////////////////////////////\n/// \\brief Abstract base class for sound file decoding\n///\n////////////////////////////////////////////////////////////\nclass SFML_AUDIO_API SoundFileReader\n{\npublic:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Structure holding the audio properties of a sound file\n    ///\n    ////////////////////////////////////////////////////////////\n    struct Info\n    {\n        Uint64       sampleCount;  ///< Total number of samples in the file\n        unsigned int channelCount; ///< Number of channels of the sound\n        unsigned int sampleRate;   ///< Samples rate of the sound, in samples per second\n    };\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Virtual destructor\n    ///\n    ////////////////////////////////////////////////////////////\n    virtual ~SoundFileReader() {}\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Open a sound file for reading\n    ///\n    /// The provided stream reference is valid as long as the\n    /// SoundFileReader is alive, so it is safe to use/store it\n    /// during the whole lifetime of the reader.\n    ///\n    /// \\param stream Source stream to read from\n    /// \\param info   Structure to fill with the properties of the loaded sound\n    ///\n    /// \\return True if the file was successfully opened\n    ///\n    ////////////////////////////////////////////////////////////\n    virtual bool open(InputStream& stream, Info& info) = 0;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Change the current read position to the given sample offset\n    ///\n    /// The sample offset takes the channels into account.\n    /// Offsets can be calculated like this:\n    /// `sampleNumber * sampleRate * channelCount`\n    /// If the given offset exceeds to total number of samples,\n    /// this function must jump to the end of the file.\n    ///\n    /// \\param sampleOffset Index of the sample to jump to, relative to the beginning\n    ///\n    ////////////////////////////////////////////////////////////\n    virtual void seek(Uint64 sampleOffset) = 0;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Read audio samples from the open file\n    ///\n    /// \\param samples  Pointer to the sample array to fill\n    /// \\param maxCount Maximum number of samples to read\n    ///\n    /// \\return Number of samples actually read (may be less than \\a maxCount)\n    ///\n    ////////////////////////////////////////////////////////////\n    virtual Uint64 read(Int16* samples, Uint64 maxCount) = 0;\n};\n\n} // namespace sf\n\n\n#endif // SFML_SOUNDFILEREADER_HPP\n\n\n////////////////////////////////////////////////////////////\n/// \\class sf::SoundFileReader\n/// \\ingroup audio\n///\n/// This class allows users to read audio file formats not natively\n/// supported by SFML, and thus extend the set of supported readable\n/// audio formats.\n///\n/// A valid sound file reader must override the open, seek and write functions,\n/// as well as providing a static check function; the latter is used by\n/// SFML to find a suitable writer for a given input file.\n///\n/// To register a new reader, use the sf::SoundFileFactory::registerReader\n/// template function.\n///\n/// Usage example:\n/// \\code\n/// class MySoundFileReader : public sf::SoundFileReader\n/// {\n/// public:\n///\n///     static bool check(sf::InputStream& stream)\n///     {\n///         // typically, read the first few header bytes and check fields that identify the format\n///         // return true if the reader can handle the format\n///     }\n///\n///     virtual bool open(sf::InputStream& stream, Info& info)\n///     {\n///         // read the sound file header and fill the sound attributes\n///         // (channel count, sample count and sample rate)\n///         // return true on success\n///     }\n///\n///     virtual void seek(sf::Uint64 sampleOffset)\n///     {\n///         // advance to the sampleOffset-th sample from the beginning of the sound\n///     }\n///\n///     virtual sf::Uint64 read(sf::Int16* samples, sf::Uint64 maxCount)\n///     {\n///         // read up to 'maxCount' samples into the 'samples' array,\n///         // convert them (for example from normalized float) if they are not stored\n///         // as 16-bits signed integers in the file\n///         // return the actual number of samples read\n///     }\n/// };\n///\n/// sf::SoundFileFactory::registerReader<MySoundFileReader>();\n/// \\endcode\n///\n/// \\see sf::InputSoundFile, sf::SoundFileFactory, sf::SoundFileWriter\n///\n////////////////////////////////////////////////////////////\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/Audio/SoundFileWriter.hpp",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n#ifndef SFML_SOUNDFILEWRITER_HPP\n#define SFML_SOUNDFILEWRITER_HPP\n\n////////////////////////////////////////////////////////////\n// Headers\n////////////////////////////////////////////////////////////\n#include <SFML/Audio/Export.hpp>\n#include <string>\n\n\nnamespace sf\n{\n////////////////////////////////////////////////////////////\n/// \\brief Abstract base class for sound file encoding\n///\n////////////////////////////////////////////////////////////\nclass SFML_AUDIO_API SoundFileWriter\n{\npublic:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Virtual destructor\n    ///\n    ////////////////////////////////////////////////////////////\n    virtual ~SoundFileWriter() {}\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Open a sound file for writing\n    ///\n    /// \\param filename     Path of the file to open\n    /// \\param sampleRate   Sample rate of the sound\n    /// \\param channelCount Number of channels of the sound\n    ///\n    /// \\return True if the file was successfully opened\n    ///\n    ////////////////////////////////////////////////////////////\n    virtual bool open(const std::string& filename, unsigned int sampleRate, unsigned int channelCount) = 0;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Write audio samples to the open file\n    ///\n    /// \\param samples Pointer to the sample array to write\n    /// \\param count   Number of samples to write\n    ///\n    ////////////////////////////////////////////////////////////\n    virtual void write(const Int16* samples, Uint64 count) = 0;\n};\n\n} // namespace sf\n\n\n#endif // SFML_SOUNDFILEWRITER_HPP\n\n\n////////////////////////////////////////////////////////////\n/// \\class sf::SoundFileWriter\n/// \\ingroup audio\n///\n/// This class allows users to write audio file formats not natively\n/// supported by SFML, and thus extend the set of supported writable\n/// audio formats.\n///\n/// A valid sound file writer must override the open and write functions,\n/// as well as providing a static check function; the latter is used by\n/// SFML to find a suitable writer for a given filename.\n///\n/// To register a new writer, use the sf::SoundFileFactory::registerWriter\n/// template function.\n///\n/// Usage example:\n/// \\code\n/// class MySoundFileWriter : public sf::SoundFileWriter\n/// {\n/// public:\n///\n///     static bool check(const std::string& filename)\n///     {\n///         // typically, check the extension\n///         // return true if the writer can handle the format\n///     }\n///\n///     virtual bool open(const std::string& filename, unsigned int sampleRate, unsigned int channelCount)\n///     {\n///         // open the file 'filename' for writing,\n///         // write the given sample rate and channel count to the file header\n///         // return true on success\n///     }\n///\n///     virtual void write(const sf::Int16* samples, sf::Uint64 count)\n///     {\n///         // write 'count' samples stored at address 'samples',\n///         // convert them (for example to normalized float) if the format requires it\n///     }\n/// };\n///\n/// sf::SoundFileFactory::registerWriter<MySoundFileWriter>();\n/// \\endcode\n///\n/// \\see sf::OutputSoundFile, sf::SoundFileFactory, sf::SoundFileReader\n///\n////////////////////////////////////////////////////////////\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/Audio/SoundRecorder.hpp",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n#ifndef SFML_SOUNDRECORDER_HPP\n#define SFML_SOUNDRECORDER_HPP\n\n////////////////////////////////////////////////////////////\n// Headers\n////////////////////////////////////////////////////////////\n#include <SFML/Audio/Export.hpp>\n#include <SFML/Audio/AlResource.hpp>\n#include <SFML/System/Thread.hpp>\n#include <SFML/System/Time.hpp>\n#include <vector>\n#include <string>\n\n\nnamespace sf\n{\n////////////////////////////////////////////////////////////\n/// \\brief Abstract base class for capturing sound data\n///\n////////////////////////////////////////////////////////////\nclass SFML_AUDIO_API SoundRecorder : AlResource\n{\npublic:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief destructor\n    ///\n    ////////////////////////////////////////////////////////////\n    virtual ~SoundRecorder();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Start the capture\n    ///\n    /// The \\a sampleRate parameter defines the number of audio samples\n    /// captured per second. The higher, the better the quality\n    /// (for example, 44100 samples/sec is CD quality).\n    /// This function uses its own thread so that it doesn't block\n    /// the rest of the program while the capture runs.\n    /// Please note that only one capture can happen at the same time.\n    /// You can select which capture device will be used, by passing\n    /// the name to the setDevice() method. If none was selected\n    /// before, the default capture device will be used. You can get a\n    /// list of the names of all available capture devices by calling\n    /// getAvailableDevices().\n    ///\n    /// \\param sampleRate Desired capture rate, in number of samples per second\n    ///\n    /// \\return True, if start of capture was successful\n    ///\n    /// \\see stop, getAvailableDevices\n    ///\n    ////////////////////////////////////////////////////////////\n    bool start(unsigned int sampleRate = 44100);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Stop the capture\n    ///\n    /// \\see start\n    ///\n    ////////////////////////////////////////////////////////////\n    void stop();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the sample rate\n    ///\n    /// The sample rate defines the number of audio samples\n    /// captured per second. The higher, the better the quality\n    /// (for example, 44100 samples/sec is CD quality).\n    ///\n    /// \\return Sample rate, in samples per second\n    ///\n    ////////////////////////////////////////////////////////////\n    unsigned int getSampleRate() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get a list of the names of all available audio capture devices\n    ///\n    /// This function returns a vector of strings, containing\n    /// the names of all available audio capture devices.\n    ///\n    /// \\return A vector of strings containing the names\n    ///\n    ////////////////////////////////////////////////////////////\n    static std::vector<std::string> getAvailableDevices();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the name of the default audio capture device\n    ///\n    /// This function returns the name of the default audio\n    /// capture device. If none is available, an empty string\n    /// is returned.\n    ///\n    /// \\return The name of the default audio capture device\n    ///\n    ////////////////////////////////////////////////////////////\n    static std::string getDefaultDevice();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Set the audio capture device\n    ///\n    /// This function sets the audio capture device to the device\n    /// with the given \\a name. It can be called on the fly (i.e:\n    /// while recording). If you do so while recording and\n    /// opening the device fails, it stops the recording.\n    ///\n    /// \\param name The name of the audio capture device\n    ///\n    /// \\return True, if it was able to set the requested device\n    ///\n    /// \\see getAvailableDevices, getDefaultDevice\n    ///\n    ////////////////////////////////////////////////////////////\n    bool setDevice(const std::string& name);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the name of the current audio capture device\n    ///\n    /// \\return The name of the current audio capture device\n    ///\n    ////////////////////////////////////////////////////////////\n    const std::string& getDevice() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Set the channel count of the audio capture device\n    ///\n    /// This method allows you to specify the number of channels\n    /// used for recording. Currently only 16-bit mono and\n    /// 16-bit stereo are supported.\n    ///\n    /// \\param channelCount Number of channels. Currently only\n    ///                     mono (1) and stereo (2) are supported.\n    ///\n    /// \\see getChannelCount\n    ///\n    ////////////////////////////////////////////////////////////\n    void setChannelCount(unsigned int channelCount);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the number of channels used by this recorder\n    ///\n    /// Currently only mono and stereo are supported, so the\n    /// value is either 1 (for mono) or 2 (for stereo).\n    ///\n    /// \\return Number of channels\n    ///\n    /// \\see setChannelCount\n    ///\n    ////////////////////////////////////////////////////////////\n    unsigned int getChannelCount() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Check if the system supports audio capture\n    ///\n    /// This function should always be called before using\n    /// the audio capture features. If it returns false, then\n    /// any attempt to use sf::SoundRecorder or one of its derived\n    /// classes will fail.\n    ///\n    /// \\return True if audio capture is supported, false otherwise\n    ///\n    ////////////////////////////////////////////////////////////\n    static bool isAvailable();\n\nprotected:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Default constructor\n    ///\n    /// This constructor is only meant to be called by derived classes.\n    ///\n    ////////////////////////////////////////////////////////////\n    SoundRecorder();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Set the processing interval\n    ///\n    /// The processing interval controls the period\n    /// between calls to the onProcessSamples function. You may\n    /// want to use a small interval if you want to process the\n    /// recorded data in real time, for example.\n    ///\n    /// Note: this is only a hint, the actual period may vary.\n    /// So don't rely on this parameter to implement precise timing.\n    ///\n    /// The default processing interval is 100 ms.\n    ///\n    /// \\param interval Processing interval\n    ///\n    ////////////////////////////////////////////////////////////\n    void setProcessingInterval(Time interval);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Start capturing audio data\n    ///\n    /// This virtual function may be overridden by a derived class\n    /// if something has to be done every time a new capture\n    /// starts. If not, this function can be ignored; the default\n    /// implementation does nothing.\n    ///\n    /// \\return True to start the capture, or false to abort it\n    ///\n    ////////////////////////////////////////////////////////////\n    virtual bool onStart();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Process a new chunk of recorded samples\n    ///\n    /// This virtual function is called every time a new chunk of\n    /// recorded data is available. The derived class can then do\n    /// whatever it wants with it (storing it, playing it, sending\n    /// it over the network, etc.).\n    ///\n    /// \\param samples     Pointer to the new chunk of recorded samples\n    /// \\param sampleCount Number of samples pointed by \\a samples\n    ///\n    /// \\return True to continue the capture, or false to stop it\n    ///\n    ////////////////////////////////////////////////////////////\n    virtual bool onProcessSamples(const Int16* samples, std::size_t sampleCount) = 0;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Stop capturing audio data\n    ///\n    /// This virtual function may be overridden by a derived class\n    /// if something has to be done every time the capture\n    /// ends. If not, this function can be ignored; the default\n    /// implementation does nothing.\n    ///\n    ////////////////////////////////////////////////////////////\n    virtual void onStop();\n\nprivate:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Function called as the entry point of the thread\n    ///\n    /// This function starts the recording loop, and returns\n    /// only when the capture is stopped.\n    ///\n    ////////////////////////////////////////////////////////////\n    void record();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the new available audio samples and process them\n    ///\n    /// This function is called continuously during the\n    /// capture loop. It retrieves the captured samples and\n    /// forwards them to the derived class.\n    ///\n    ////////////////////////////////////////////////////////////\n    void processCapturedSamples();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Clean up the recorder's internal resources\n    ///\n    /// This function is called when the capture stops.\n    ///\n    ////////////////////////////////////////////////////////////\n    void cleanup();\n\n    ////////////////////////////////////////////////////////////\n    // Member data\n    ////////////////////////////////////////////////////////////\n    Thread             m_thread;             ///< Thread running the background recording task\n    std::vector<Int16> m_samples;            ///< Buffer to store captured samples\n    unsigned int       m_sampleRate;         ///< Sample rate\n    Time               m_processingInterval; ///< Time period between calls to onProcessSamples\n    bool               m_isCapturing;        ///< Capturing state\n    std::string        m_deviceName;         ///< Name of the audio capture device\n    unsigned int       m_channelCount;       ///< Number of recording channels\n};\n\n} // namespace sf\n\n\n#endif // SFML_SOUNDRECORDER_HPP\n\n\n////////////////////////////////////////////////////////////\n/// \\class sf::SoundRecorder\n/// \\ingroup audio\n///\n/// sf::SoundBuffer provides a simple interface to access\n/// the audio recording capabilities of the computer\n/// (the microphone). As an abstract base class, it only cares\n/// about capturing sound samples, the task of making something\n/// useful with them is left to the derived class. Note that\n/// SFML provides a built-in specialization for saving the\n/// captured data to a sound buffer (see sf::SoundBufferRecorder).\n///\n/// A derived class has only one virtual function to override:\n/// \\li onProcessSamples provides the new chunks of audio samples while the capture happens\n///\n/// Moreover, two additional virtual functions can be overridden\n/// as well if necessary:\n/// \\li onStart is called before the capture happens, to perform custom initializations\n/// \\li onStop is called after the capture ends, to perform custom cleanup\n///\n/// A derived class can also control the frequency of the onProcessSamples\n/// calls, with the setProcessingInterval protected function. The default\n/// interval is chosen so that recording thread doesn't consume too much\n/// CPU, but it can be changed to a smaller value if you need to process\n/// the recorded data in real time, for example.\n///\n/// The audio capture feature may not be supported or activated\n/// on every platform, thus it is recommended to check its\n/// availability with the isAvailable() function. If it returns\n/// false, then any attempt to use an audio recorder will fail.\n///\n/// If you have multiple sound input devices connected to your\n/// computer (for example: microphone, external soundcard, webcam mic, ...)\n/// you can get a list of all available devices through the\n/// getAvailableDevices() function. You can then select a device\n/// by calling setDevice() with the appropriate device. Otherwise\n/// the default capturing device will be used.\n///\n/// By default the recording is in 16-bit mono. Using the\n/// setChannelCount method you can change the number of channels\n/// used by the audio capture device to record. Note that you\n/// have to decide whether you want to record in mono or stereo\n/// before starting the recording.\n///\n/// It is important to note that the audio capture happens in a\n/// separate thread, so that it doesn't block the rest of the\n/// program. In particular, the onProcessSamples virtual function\n/// (but not onStart and not onStop) will be called\n/// from this separate thread. It is important to keep this in\n/// mind, because you may have to take care of synchronization\n/// issues if you share data between threads.\n/// Another thing to bear in mind is that you must call stop()\n/// in the destructor of your derived class, so that the recording\n/// thread finishes before your object is destroyed.\n///\n/// Usage example:\n/// \\code\n/// class CustomRecorder : public sf::SoundRecorder\n/// {\n///     ~CustomRecorder()\n///     {\n///         // Make sure to stop the recording thread\n///         stop();\n///     }\n///\n///     virtual bool onStart() // optional\n///     {\n///         // Initialize whatever has to be done before the capture starts\n///         ...\n///\n///         // Return true to start playing\n///         return true;\n///     }\n///\n///     virtual bool onProcessSamples(const Int16* samples, std::size_t sampleCount)\n///     {\n///         // Do something with the new chunk of samples (store them, send them, ...)\n///         ...\n///\n///         // Return true to continue playing\n///         return true;\n///     }\n///\n///     virtual void onStop() // optional\n///     {\n///         // Clean up whatever has to be done after the capture ends\n///         ...\n///     }\n/// }\n///\n/// // Usage\n/// if (CustomRecorder::isAvailable())\n/// {\n///     CustomRecorder recorder;\n///\n///     if (!recorder.start())\n///         return -1;\n///\n///     ...\n///     recorder.stop();\n/// }\n/// \\endcode\n///\n/// \\see sf::SoundBufferRecorder\n///\n////////////////////////////////////////////////////////////\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/Audio/SoundSource.hpp",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n#ifndef SFML_SOUNDSOURCE_HPP\n#define SFML_SOUNDSOURCE_HPP\n\n////////////////////////////////////////////////////////////\n// Headers\n////////////////////////////////////////////////////////////\n#include <SFML/Audio/Export.hpp>\n#include <SFML/Audio/AlResource.hpp>\n#include <SFML/System/Vector3.hpp>\n\n\nnamespace sf\n{\n////////////////////////////////////////////////////////////\n/// \\brief Base class defining a sound's properties\n///\n////////////////////////////////////////////////////////////\nclass SFML_AUDIO_API SoundSource : AlResource\n{\npublic:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Enumeration of the sound source states\n    ///\n    ////////////////////////////////////////////////////////////\n    enum Status\n    {\n        Stopped, ///< Sound is not playing\n        Paused,  ///< Sound is paused\n        Playing  ///< Sound is playing\n    };\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Copy constructor\n    ///\n    /// \\param copy Instance to copy\n    ///\n    ////////////////////////////////////////////////////////////\n    SoundSource(const SoundSource& copy);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Destructor\n    ///\n    ////////////////////////////////////////////////////////////\n    virtual ~SoundSource();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Set the pitch of the sound\n    ///\n    /// The pitch represents the perceived fundamental frequency\n    /// of a sound; thus you can make a sound more acute or grave\n    /// by changing its pitch. A side effect of changing the pitch\n    /// is to modify the playing speed of the sound as well.\n    /// The default value for the pitch is 1.\n    ///\n    /// \\param pitch New pitch to apply to the sound\n    ///\n    /// \\see getPitch\n    ///\n    ////////////////////////////////////////////////////////////\n    void setPitch(float pitch);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Set the volume of the sound\n    ///\n    /// The volume is a value between 0 (mute) and 100 (full volume).\n    /// The default value for the volume is 100.\n    ///\n    /// \\param volume Volume of the sound\n    ///\n    /// \\see getVolume\n    ///\n    ////////////////////////////////////////////////////////////\n    void setVolume(float volume);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Set the 3D position of the sound in the audio scene\n    ///\n    /// Only sounds with one channel (mono sounds) can be\n    /// spatialized.\n    /// The default position of a sound is (0, 0, 0).\n    ///\n    /// \\param x X coordinate of the position of the sound in the scene\n    /// \\param y Y coordinate of the position of the sound in the scene\n    /// \\param z Z coordinate of the position of the sound in the scene\n    ///\n    /// \\see getPosition\n    ///\n    ////////////////////////////////////////////////////////////\n    void setPosition(float x, float y, float z);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Set the 3D position of the sound in the audio scene\n    ///\n    /// Only sounds with one channel (mono sounds) can be\n    /// spatialized.\n    /// The default position of a sound is (0, 0, 0).\n    ///\n    /// \\param position Position of the sound in the scene\n    ///\n    /// \\see getPosition\n    ///\n    ////////////////////////////////////////////////////////////\n    void setPosition(const Vector3f& position);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Make the sound's position relative to the listener or absolute\n    ///\n    /// Making a sound relative to the listener will ensure that it will always\n    /// be played the same way regardless of the position of the listener.\n    /// This can be useful for non-spatialized sounds, sounds that are\n    /// produced by the listener, or sounds attached to it.\n    /// The default value is false (position is absolute).\n    ///\n    /// \\param relative True to set the position relative, false to set it absolute\n    ///\n    /// \\see isRelativeToListener\n    ///\n    ////////////////////////////////////////////////////////////\n    void setRelativeToListener(bool relative);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Set the minimum distance of the sound\n    ///\n    /// The \"minimum distance\" of a sound is the maximum\n    /// distance at which it is heard at its maximum volume. Further\n    /// than the minimum distance, it will start to fade out according\n    /// to its attenuation factor. A value of 0 (\"inside the head\n    /// of the listener\") is an invalid value and is forbidden.\n    /// The default value of the minimum distance is 1.\n    ///\n    /// \\param distance New minimum distance of the sound\n    ///\n    /// \\see getMinDistance, setAttenuation\n    ///\n    ////////////////////////////////////////////////////////////\n    void setMinDistance(float distance);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Set the attenuation factor of the sound\n    ///\n    /// The attenuation is a multiplicative factor which makes\n    /// the sound more or less loud according to its distance\n    /// from the listener. An attenuation of 0 will produce a\n    /// non-attenuated sound, i.e. its volume will always be the same\n    /// whether it is heard from near or from far. On the other hand,\n    /// an attenuation value such as 100 will make the sound fade out\n    /// very quickly as it gets further from the listener.\n    /// The default value of the attenuation is 1.\n    ///\n    /// \\param attenuation New attenuation factor of the sound\n    ///\n    /// \\see getAttenuation, setMinDistance\n    ///\n    ////////////////////////////////////////////////////////////\n    void setAttenuation(float attenuation);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the pitch of the sound\n    ///\n    /// \\return Pitch of the sound\n    ///\n    /// \\see setPitch\n    ///\n    ////////////////////////////////////////////////////////////\n    float getPitch() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the volume of the sound\n    ///\n    /// \\return Volume of the sound, in the range [0, 100]\n    ///\n    /// \\see setVolume\n    ///\n    ////////////////////////////////////////////////////////////\n    float getVolume() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the 3D position of the sound in the audio scene\n    ///\n    /// \\return Position of the sound\n    ///\n    /// \\see setPosition\n    ///\n    ////////////////////////////////////////////////////////////\n    Vector3f getPosition() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Tell whether the sound's position is relative to the\n    ///        listener or is absolute\n    ///\n    /// \\return True if the position is relative, false if it's absolute\n    ///\n    /// \\see setRelativeToListener\n    ///\n    ////////////////////////////////////////////////////////////\n    bool isRelativeToListener() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the minimum distance of the sound\n    ///\n    /// \\return Minimum distance of the sound\n    ///\n    /// \\see setMinDistance, getAttenuation\n    ///\n    ////////////////////////////////////////////////////////////\n    float getMinDistance() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the attenuation factor of the sound\n    ///\n    /// \\return Attenuation factor of the sound\n    ///\n    /// \\see setAttenuation, getMinDistance\n    ///\n    ////////////////////////////////////////////////////////////\n    float getAttenuation() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Overload of assignment operator\n    ///\n    /// \\param right Instance to assign\n    ///\n    /// \\return Reference to self\n    ///\n    ////////////////////////////////////////////////////////////\n    SoundSource& operator =(const SoundSource& right);\n\nprotected:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Default constructor\n    ///\n    /// This constructor is meant to be called by derived classes only.\n    ///\n    ////////////////////////////////////////////////////////////\n    SoundSource();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the current status of the sound (stopped, paused, playing)\n    ///\n    /// \\return Current status of the sound\n    ///\n    ////////////////////////////////////////////////////////////\n    Status getStatus() const;\n\n    ////////////////////////////////////////////////////////////\n    // Member data\n    ////////////////////////////////////////////////////////////\n    unsigned int m_source; ///< OpenAL source identifier\n};\n\n} // namespace sf\n\n\n#endif // SFML_SOUNDSOURCE_HPP\n\n\n////////////////////////////////////////////////////////////\n/// \\class sf::SoundSource\n/// \\ingroup audio\n///\n/// sf::SoundSource is not meant to be used directly, it\n/// only serves as a common base for all audio objects\n/// that can live in the audio environment.\n///\n/// It defines several properties for the sound: pitch,\n/// volume, position, attenuation, etc. All of them can be\n/// changed at any time with no impact on performances.\n///\n/// \\see sf::Sound, sf::SoundStream\n///\n////////////////////////////////////////////////////////////\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/Audio/SoundStream.hpp",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n#ifndef SFML_SOUNDSTREAM_HPP\n#define SFML_SOUNDSTREAM_HPP\n\n////////////////////////////////////////////////////////////\n// Headers\n////////////////////////////////////////////////////////////\n#include <SFML/Audio/Export.hpp>\n#include <SFML/Audio/SoundSource.hpp>\n#include <SFML/System/Thread.hpp>\n#include <SFML/System/Time.hpp>\n#include <SFML/System/Mutex.hpp>\n#include <cstdlib>\n\n\nnamespace sf\n{\n////////////////////////////////////////////////////////////\n/// \\brief Abstract base class for streamed audio sources\n///\n////////////////////////////////////////////////////////////\nclass SFML_AUDIO_API SoundStream : public SoundSource\n{\npublic:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Structure defining a chunk of audio data to stream\n    ///\n    ////////////////////////////////////////////////////////////\n    struct Chunk\n    {\n        const Int16* samples;     ///< Pointer to the audio samples\n        std::size_t  sampleCount; ///< Number of samples pointed by Samples\n    };\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Destructor\n    ///\n    ////////////////////////////////////////////////////////////\n    virtual ~SoundStream();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Start or resume playing the audio stream\n    ///\n    /// This function starts the stream if it was stopped, resumes\n    /// it if it was paused, and restarts it from the beginning if\n    /// it was already playing.\n    /// This function uses its own thread so that it doesn't block\n    /// the rest of the program while the stream is played.\n    ///\n    /// \\see pause, stop\n    ///\n    ////////////////////////////////////////////////////////////\n    void play();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Pause the audio stream\n    ///\n    /// This function pauses the stream if it was playing,\n    /// otherwise (stream already paused or stopped) it has no effect.\n    ///\n    /// \\see play, stop\n    ///\n    ////////////////////////////////////////////////////////////\n    void pause();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Stop playing the audio stream\n    ///\n    /// This function stops the stream if it was playing or paused,\n    /// and does nothing if it was already stopped.\n    /// It also resets the playing position (unlike pause()).\n    ///\n    /// \\see play, pause\n    ///\n    ////////////////////////////////////////////////////////////\n    void stop();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Return the number of channels of the stream\n    ///\n    /// 1 channel means a mono sound, 2 means stereo, etc.\n    ///\n    /// \\return Number of channels\n    ///\n    ////////////////////////////////////////////////////////////\n    unsigned int getChannelCount() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the stream sample rate of the stream\n    ///\n    /// The sample rate is the number of audio samples played per\n    /// second. The higher, the better the quality.\n    ///\n    /// \\return Sample rate, in number of samples per second\n    ///\n    ////////////////////////////////////////////////////////////\n    unsigned int getSampleRate() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the current status of the stream (stopped, paused, playing)\n    ///\n    /// \\return Current status\n    ///\n    ////////////////////////////////////////////////////////////\n    Status getStatus() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Change the current playing position of the stream\n    ///\n    /// The playing position can be changed when the stream is\n    /// either paused or playing. Changing the playing position\n    /// when the stream is stopped has no effect, since playing\n    /// the stream would reset its position.\n    ///\n    /// \\param timeOffset New playing position, from the beginning of the stream\n    ///\n    /// \\see getPlayingOffset\n    ///\n    ////////////////////////////////////////////////////////////\n    void setPlayingOffset(Time timeOffset);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the current playing position of the stream\n    ///\n    /// \\return Current playing position, from the beginning of the stream\n    ///\n    /// \\see setPlayingOffset\n    ///\n    ////////////////////////////////////////////////////////////\n    Time getPlayingOffset() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Set whether or not the stream should loop after reaching the end\n    ///\n    /// If set, the stream will restart from beginning after\n    /// reaching the end and so on, until it is stopped or\n    /// setLoop(false) is called.\n    /// The default looping state for streams is false.\n    ///\n    /// \\param loop True to play in loop, false to play once\n    ///\n    /// \\see getLoop\n    ///\n    ////////////////////////////////////////////////////////////\n    void setLoop(bool loop);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Tell whether or not the stream is in loop mode\n    ///\n    /// \\return True if the stream is looping, false otherwise\n    ///\n    /// \\see setLoop\n    ///\n    ////////////////////////////////////////////////////////////\n    bool getLoop() const;\n\nprotected:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Default constructor\n    ///\n    /// This constructor is only meant to be called by derived classes.\n    ///\n    ////////////////////////////////////////////////////////////\n    SoundStream();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Define the audio stream parameters\n    ///\n    /// This function must be called by derived classes as soon\n    /// as they know the audio settings of the stream to play.\n    /// Any attempt to manipulate the stream (play(), ...) before\n    /// calling this function will fail.\n    /// It can be called multiple times if the settings of the\n    /// audio stream change, but only when the stream is stopped.\n    ///\n    /// \\param channelCount Number of channels of the stream\n    /// \\param sampleRate   Sample rate, in samples per second\n    ///\n    ////////////////////////////////////////////////////////////\n    void initialize(unsigned int channelCount, unsigned int sampleRate);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Request a new chunk of audio samples from the stream source\n    ///\n    /// This function must be overridden by derived classes to provide\n    /// the audio samples to play. It is called continuously by the\n    /// streaming loop, in a separate thread.\n    /// The source can choose to stop the streaming loop at any time, by\n    /// returning false to the caller.\n    /// If you return true (i.e. continue streaming) it is important that\n    /// the returned array of samples is not empty; this would stop the stream\n    /// due to an internal limitation.\n    ///\n    /// \\param data Chunk of data to fill\n    ///\n    /// \\return True to continue playback, false to stop\n    ///\n    ////////////////////////////////////////////////////////////\n    virtual bool onGetData(Chunk& data) = 0;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Change the current playing position in the stream source\n    ///\n    /// This function must be overridden by derived classes to\n    /// allow random seeking into the stream source.\n    ///\n    /// \\param timeOffset New playing position, relative to the beginning of the stream\n    ///\n    ////////////////////////////////////////////////////////////\n    virtual void onSeek(Time timeOffset) = 0;\n\nprivate:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Function called as the entry point of the thread\n    ///\n    /// This function starts the streaming loop, and returns\n    /// only when the sound is stopped.\n    ///\n    ////////////////////////////////////////////////////////////\n    void streamData();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Fill a new buffer with audio samples, and append\n    ///        it to the playing queue\n    ///\n    /// This function is called as soon as a buffer has been fully\n    /// consumed; it fills it again and inserts it back into the\n    /// playing queue.\n    ///\n    /// \\param bufferNum Number of the buffer to fill (in [0, BufferCount])\n    ///\n    /// \\return True if the stream source has requested to stop, false otherwise\n    ///\n    ////////////////////////////////////////////////////////////\n    bool fillAndPushBuffer(unsigned int bufferNum);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Fill the audio buffers and put them all into the playing queue\n    ///\n    /// This function is called when playing starts and the\n    /// playing queue is empty.\n    ///\n    /// \\return True if the derived class has requested to stop, false otherwise\n    ///\n    ////////////////////////////////////////////////////////////\n    bool fillQueue();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Clear all the audio buffers and empty the playing queue\n    ///\n    /// This function is called when the stream is stopped.\n    ///\n    ////////////////////////////////////////////////////////////\n    void clearQueue();\n\n    enum\n    {\n        BufferCount = 3 ///< Number of audio buffers used by the streaming loop\n    };\n\n    ////////////////////////////////////////////////////////////\n    // Member data\n    ////////////////////////////////////////////////////////////\n    Thread        m_thread;                  ///< Thread running the background tasks\n    mutable Mutex m_threadMutex;             ///< Thread mutex\n    Status        m_threadStartState;        ///< State the thread starts in (Playing, Paused, Stopped)\n    bool          m_isStreaming;             ///< Streaming state (true = playing, false = stopped)\n    unsigned int  m_buffers[BufferCount];    ///< Sound buffers used to store temporary audio data\n    unsigned int  m_channelCount;            ///< Number of channels (1 = mono, 2 = stereo, ...)\n    unsigned int  m_sampleRate;              ///< Frequency (samples / second)\n    Uint32        m_format;                  ///< Format of the internal sound buffers\n    bool          m_loop;                    ///< Loop flag (true to loop, false to play once)\n    Uint64        m_samplesProcessed;        ///< Number of buffers processed since beginning of the stream\n    bool          m_endBuffers[BufferCount]; ///< Each buffer is marked as \"end buffer\" or not, for proper duration calculation\n};\n\n} // namespace sf\n\n\n#endif // SFML_SOUNDSTREAM_HPP\n\n\n////////////////////////////////////////////////////////////\n/// \\class sf::SoundStream\n/// \\ingroup audio\n///\n/// Unlike audio buffers (see sf::SoundBuffer), audio streams\n/// are never completely loaded in memory. Instead, the audio\n/// data is acquired continuously while the stream is playing.\n/// This behavior allows to play a sound with no loading delay,\n/// and keeps the memory consumption very low.\n///\n/// Sound sources that need to be streamed are usually big files\n/// (compressed audio musics that would eat hundreds of MB in memory)\n/// or files that would take a lot of time to be received\n/// (sounds played over the network).\n///\n/// sf::SoundStream is a base class that doesn't care about the\n/// stream source, which is left to the derived class. SFML provides\n/// a built-in specialization for big files (see sf::Music).\n/// No network stream source is provided, but you can write your own\n/// by combining this class with the network module.\n///\n/// A derived class has to override two virtual functions:\n/// \\li onGetData fills a new chunk of audio data to be played\n/// \\li onSeek changes the current playing position in the source\n///\n/// It is important to note that each SoundStream is played in its\n/// own separate thread, so that the streaming loop doesn't block the\n/// rest of the program. In particular, the OnGetData and OnSeek\n/// virtual functions may sometimes be called from this separate thread.\n/// It is important to keep this in mind, because you may have to take\n/// care of synchronization issues if you share data between threads.\n///\n/// Usage example:\n/// \\code\n/// class CustomStream : public sf::SoundStream\n/// {\n/// public:\n///\n///     bool open(const std::string& location)\n///     {\n///         // Open the source and get audio settings\n///         ...\n///         unsigned int channelCount = ...;\n///         unsigned int sampleRate = ...;\n///\n///         // Initialize the stream -- important!\n///         initialize(channelCount, sampleRate);\n///     }\n///\n/// private:\n///\n///     virtual bool onGetData(Chunk& data)\n///     {\n///         // Fill the chunk with audio data from the stream source\n///         // (note: must not be empty if you want to continue playing)\n///         data.samples = ...;\n///         data.sampleCount = ...;\n///\n///         // Return true to continue playing\n///         return true;\n///     }\n///\n///     virtual void onSeek(Uint32 timeOffset)\n///     {\n///         // Change the current position in the stream source\n///         ...\n///     }\n/// }\n///\n/// // Usage\n/// CustomStream stream;\n/// stream.open(\"path/to/stream\");\n/// stream.play();\n/// \\endcode\n///\n/// \\see sf::Music\n///\n////////////////////////////////////////////////////////////\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/Audio.hpp",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n#ifndef SFML_AUDIO_HPP\n#define SFML_AUDIO_HPP\n\n////////////////////////////////////////////////////////////\n// Headers\n////////////////////////////////////////////////////////////\n\n#include <SFML/System.hpp>\n#include <SFML/Audio/InputSoundFile.hpp>\n#include <SFML/Audio/Listener.hpp>\n#include <SFML/Audio/Music.hpp>\n#include <SFML/Audio/OutputSoundFile.hpp>\n#include <SFML/Audio/Sound.hpp>\n#include <SFML/Audio/SoundBuffer.hpp>\n#include <SFML/Audio/SoundBufferRecorder.hpp>\n#include <SFML/Audio/SoundFileFactory.hpp>\n#include <SFML/Audio/SoundFileReader.hpp>\n#include <SFML/Audio/SoundFileWriter.hpp>\n#include <SFML/Audio/SoundRecorder.hpp>\n#include <SFML/Audio/SoundSource.hpp>\n#include <SFML/Audio/SoundStream.hpp>\n\n\n#endif // SFML_AUDIO_HPP\n\n////////////////////////////////////////////////////////////\n/// \\defgroup audio Audio module\n///\n/// Sounds, streaming (musics or custom sources), recording,\n/// spatialization.\n///\n////////////////////////////////////////////////////////////\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/Config.hpp",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n#ifndef SFML_CONFIG_HPP\n#define SFML_CONFIG_HPP\n\n\n////////////////////////////////////////////////////////////\n// Define the SFML version\n////////////////////////////////////////////////////////////\n#define SFML_VERSION_MAJOR 2\n#define SFML_VERSION_MINOR 4\n#define SFML_VERSION_PATCH 2\n\n\n////////////////////////////////////////////////////////////\n// Identify the operating system\n// see http://nadeausoftware.com/articles/2012/01/c_c_tip_how_use_compiler_predefined_macros_detect_operating_system\n////////////////////////////////////////////////////////////\n#if defined(_WIN32)\n\n    // Windows\n    #define SFML_SYSTEM_WINDOWS\n    #ifndef NOMINMAX\n        #define NOMINMAX\n    #endif\n\n#elif defined(__APPLE__) && defined(__MACH__)\n\n    // Apple platform, see which one it is\n    #include \"TargetConditionals.h\"\n\n    #if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR\n\n        // iOS\n        #define SFML_SYSTEM_IOS\n\n    #elif TARGET_OS_MAC\n\n        // MacOS\n        #define SFML_SYSTEM_MACOS\n\n    #else\n\n        // Unsupported Apple system\n        #error This Apple operating system is not supported by SFML library\n\n    #endif\n\n#elif defined(__unix__)\n\n    // UNIX system, see which one it is\n    #if defined(__ANDROID__)\n\n        // Android\n        #define SFML_SYSTEM_ANDROID\n\n    #elif defined(__linux__)\n\n         // Linux\n        #define SFML_SYSTEM_LINUX\n\n    #elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)\n\n        // FreeBSD\n        #define SFML_SYSTEM_FREEBSD\n\n    #else\n\n        // Unsupported UNIX system\n        #error This UNIX operating system is not supported by SFML library\n\n    #endif\n\n#else\n\n    // Unsupported system\n    #error This operating system is not supported by SFML library\n\n#endif\n\n\n////////////////////////////////////////////////////////////\n// Define a portable debug macro\n////////////////////////////////////////////////////////////\n#if !defined(NDEBUG)\n\n    #define SFML_DEBUG\n\n#endif\n\n\n////////////////////////////////////////////////////////////\n// Define helpers to create portable import / export macros for each module\n////////////////////////////////////////////////////////////\n#if !defined(SFML_STATIC)\n\n    #if defined(SFML_SYSTEM_WINDOWS)\n\n        // Windows compilers need specific (and different) keywords for export and import\n        #define SFML_API_EXPORT __declspec(dllexport)\n        #define SFML_API_IMPORT __declspec(dllimport)\n\n        // For Visual C++ compilers, we also need to turn off this annoying C4251 warning\n        #ifdef _MSC_VER\n\n            #pragma warning(disable: 4251)\n\n        #endif\n\n    #else // Linux, FreeBSD, Mac OS X\n\n        #if __GNUC__ >= 4\n\n            // GCC 4 has special keywords for showing/hidding symbols,\n            // the same keyword is used for both importing and exporting\n            #define SFML_API_EXPORT __attribute__ ((__visibility__ (\"default\")))\n            #define SFML_API_IMPORT __attribute__ ((__visibility__ (\"default\")))\n\n        #else\n\n            // GCC < 4 has no mechanism to explicitely hide symbols, everything's exported\n            #define SFML_API_EXPORT\n            #define SFML_API_IMPORT\n\n        #endif\n\n    #endif\n\n#else\n\n    // Static build doesn't need import/export macros\n    #define SFML_API_EXPORT\n    #define SFML_API_IMPORT\n\n#endif\n\n\n////////////////////////////////////////////////////////////\n// Cross-platform warning for deprecated functions and classes\n//\n// Usage:\n// class SFML_DEPRECATED MyClass\n// {\n//     SFML_DEPRECATED void memberFunc();\n// };\n//\n// SFML_DEPRECATED void globalFunc();\n////////////////////////////////////////////////////////////\n#if defined(SFML_NO_DEPRECATED_WARNINGS)\n\n    // User explicitly requests to disable deprecation warnings\n    #define SFML_DEPRECATED\n\n#elif defined(_MSC_VER)\n\n    // Microsoft C++ compiler\n    // Note: On newer MSVC versions, using deprecated functions causes a compiler error. In order to\n    // trigger a warning instead of an error, the compiler flag /sdl- (instead of /sdl) must be specified.\n    #define SFML_DEPRECATED __declspec(deprecated)\n\n#elif defined(__GNUC__)\n\n    // g++ and Clang\n    #define SFML_DEPRECATED __attribute__ ((deprecated))\n\n#else\n\n    // Other compilers are not supported, leave class or function as-is.\n    // With a bit of luck, the #pragma directive works, otherwise users get a warning (no error!) for unrecognized #pragma.\n    #pragma message(\"SFML_DEPRECATED is not supported for your compiler, please contact the SFML team\")\n    #define SFML_DEPRECATED\n\n#endif\n\n\n////////////////////////////////////////////////////////////\n// Define portable fixed-size types\n////////////////////////////////////////////////////////////\nnamespace sf\n{\n    // All \"common\" platforms use the same size for char, short and int\n    // (basically there are 3 types for 3 sizes, so no other match is possible),\n    // we can use them without doing any kind of check\n\n    // 8 bits integer types\n    typedef signed   char Int8;\n    typedef unsigned char Uint8;\n\n    // 16 bits integer types\n    typedef signed   short Int16;\n    typedef unsigned short Uint16;\n\n    // 32 bits integer types\n    typedef signed   int Int32;\n    typedef unsigned int Uint32;\n\n    // 64 bits integer types\n    #if defined(_MSC_VER)\n        typedef signed   __int64 Int64;\n        typedef unsigned __int64 Uint64;\n    #else\n        typedef signed   long long Int64;\n        typedef unsigned long long Uint64;\n    #endif\n\n} // namespace sf\n\n\n#endif // SFML_CONFIG_HPP\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/Graphics/BlendMode.hpp",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n#ifndef SFML_BLENDMODE_HPP\n#define SFML_BLENDMODE_HPP\n\n////////////////////////////////////////////////////////////\n// Headers\n////////////////////////////////////////////////////////////\n#include <SFML/Graphics/Export.hpp>\n\n\nnamespace sf\n{\n\n////////////////////////////////////////////////////////////\n/// \\brief Blending modes for drawing\n///\n////////////////////////////////////////////////////////////\nstruct SFML_GRAPHICS_API BlendMode\n{\n    ////////////////////////////////////////////////////////\n    /// \\brief Enumeration of the blending factors\n    ///\n    /// The factors are mapped directly to their OpenGL equivalents,\n    /// specified by glBlendFunc() or glBlendFuncSeparate().\n    ////////////////////////////////////////////////////////\n    enum Factor\n    {\n        Zero,             ///< (0, 0, 0, 0)\n        One,              ///< (1, 1, 1, 1)\n        SrcColor,         ///< (src.r, src.g, src.b, src.a)\n        OneMinusSrcColor, ///< (1, 1, 1, 1) - (src.r, src.g, src.b, src.a)\n        DstColor,         ///< (dst.r, dst.g, dst.b, dst.a)\n        OneMinusDstColor, ///< (1, 1, 1, 1) - (dst.r, dst.g, dst.b, dst.a)\n        SrcAlpha,         ///< (src.a, src.a, src.a, src.a)\n        OneMinusSrcAlpha, ///< (1, 1, 1, 1) - (src.a, src.a, src.a, src.a)\n        DstAlpha,         ///< (dst.a, dst.a, dst.a, dst.a)\n        OneMinusDstAlpha  ///< (1, 1, 1, 1) - (dst.a, dst.a, dst.a, dst.a)\n    };\n\n    ////////////////////////////////////////////////////////\n    /// \\brief Enumeration of the blending equations\n    ///\n    /// The equations are mapped directly to their OpenGL equivalents,\n    /// specified by glBlendEquation() or glBlendEquationSeparate().\n    ////////////////////////////////////////////////////////\n    enum Equation\n    {\n        Add,            ///< Pixel = Src * SrcFactor + Dst * DstFactor\n        Subtract,       ///< Pixel = Src * SrcFactor - Dst * DstFactor\n        ReverseSubtract ///< Pixel = Dst * DstFactor - Src * SrcFactor\n    };\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Default constructor\n    ///\n    /// Constructs a blending mode that does alpha blending.\n    ///\n    ////////////////////////////////////////////////////////////\n    BlendMode();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Construct the blend mode given the factors and equation.\n    ///\n    /// This constructor uses the same factors and equation for both\n    /// color and alpha components. It also defaults to the Add equation.\n    ///\n    /// \\param sourceFactor      Specifies how to compute the source factor for the color and alpha channels.\n    /// \\param destinationFactor Specifies how to compute the destination factor for the color and alpha channels.\n    /// \\param blendEquation     Specifies how to combine the source and destination colors and alpha.\n    ///\n    ////////////////////////////////////////////////////////////\n    BlendMode(Factor sourceFactor, Factor destinationFactor, Equation blendEquation = Add);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Construct the blend mode given the factors and equation.\n    ///\n    /// \\param colorSourceFactor      Specifies how to compute the source factor for the color channels.\n    /// \\param colorDestinationFactor Specifies how to compute the destination factor for the color channels.\n    /// \\param colorBlendEquation     Specifies how to combine the source and destination colors.\n    /// \\param alphaSourceFactor      Specifies how to compute the source factor.\n    /// \\param alphaDestinationFactor Specifies how to compute the destination factor.\n    /// \\param alphaBlendEquation     Specifies how to combine the source and destination alphas.\n    ///\n    ////////////////////////////////////////////////////////////\n    BlendMode(Factor colorSourceFactor, Factor colorDestinationFactor,\n              Equation colorBlendEquation, Factor alphaSourceFactor,\n              Factor alphaDestinationFactor, Equation alphaBlendEquation);\n\n    ////////////////////////////////////////////////////////////\n    // Member Data\n    ////////////////////////////////////////////////////////////\n    Factor   colorSrcFactor; ///< Source blending factor for the color channels\n    Factor   colorDstFactor; ///< Destination blending factor for the color channels\n    Equation colorEquation;  ///< Blending equation for the color channels\n    Factor   alphaSrcFactor; ///< Source blending factor for the alpha channel\n    Factor   alphaDstFactor; ///< Destination blending factor for the alpha channel\n    Equation alphaEquation;  ///< Blending equation for the alpha channel\n};\n\n////////////////////////////////////////////////////////////\n/// \\relates BlendMode\n/// \\brief Overload of the == operator\n///\n/// \\param left  Left operand\n/// \\param right Right operand\n///\n/// \\return True if blending modes are equal, false if they are different\n///\n////////////////////////////////////////////////////////////\nSFML_GRAPHICS_API bool operator ==(const BlendMode& left, const BlendMode& right);\n\n////////////////////////////////////////////////////////////\n/// \\relates BlendMode\n/// \\brief Overload of the != operator\n///\n/// \\param left  Left operand\n/// \\param right Right operand\n///\n/// \\return True if blending modes are different, false if they are equal\n///\n////////////////////////////////////////////////////////////\nSFML_GRAPHICS_API bool operator !=(const BlendMode& left, const BlendMode& right);\n\n////////////////////////////////////////////////////////////\n// Commonly used blending modes\n////////////////////////////////////////////////////////////\nSFML_GRAPHICS_API extern const BlendMode BlendAlpha;    ///< Blend source and dest according to dest alpha\nSFML_GRAPHICS_API extern const BlendMode BlendAdd;      ///< Add source to dest\nSFML_GRAPHICS_API extern const BlendMode BlendMultiply; ///< Multiply source and dest\nSFML_GRAPHICS_API extern const BlendMode BlendNone;     ///< Overwrite dest with source\n\n} // namespace sf\n\n\n#endif // SFML_BLENDMODE_HPP\n\n\n////////////////////////////////////////////////////////////\n/// \\class sf::BlendMode\n/// \\ingroup graphics\n///\n/// sf::BlendMode is a class that represents a blend mode. A blend\n/// mode determines how the colors of an object you draw are\n/// mixed with the colors that are already in the buffer.\n///\n/// The class is composed of 6 components, each of which has its\n/// own public member variable:\n/// \\li %Color Source Factor (@ref colorSrcFactor)\n/// \\li %Color Destination Factor (@ref colorDstFactor)\n/// \\li %Color Blend Equation (@ref colorEquation)\n/// \\li Alpha Source Factor (@ref alphaSrcFactor)\n/// \\li Alpha Destination Factor (@ref alphaDstFactor)\n/// \\li Alpha Blend Equation (@ref alphaEquation)\n///\n/// The source factor specifies how the pixel you are drawing contributes\n/// to the final color. The destination factor specifies how the pixel\n/// already drawn in the buffer contributes to the final color.\n///\n/// The color channels RGB (red, green, blue; simply referred to as\n/// color) and A (alpha; the transparency) can be treated separately. This\n/// separation can be useful for specific blend modes, but most often you\n/// won't need it and will simply treat the color as a single unit.\n///\n/// The blend factors and equations correspond to their OpenGL equivalents.\n/// In general, the color of the resulting pixel is calculated according\n/// to the following formula (\\a src is the color of the source pixel, \\a dst\n/// the color of the destination pixel, the other variables correspond to the\n/// public members, with the equations being + or - operators):\n/// \\code\n/// dst.rgb = colorSrcFactor * src.rgb (colorEquation) colorDstFactor * dst.rgb\n/// dst.a   = alphaSrcFactor * src.a   (alphaEquation) alphaDstFactor * dst.a\n/// \\endcode\n/// All factors and colors are represented as floating point numbers between\n/// 0 and 1. Where necessary, the result is clamped to fit in that range.\n///\n/// The most common blending modes are defined as constants\n/// in the sf namespace:\n///\n/// \\code\n/// sf::BlendMode alphaBlending          = sf::BlendAlpha;\n/// sf::BlendMode additiveBlending       = sf::BlendAdd;\n/// sf::BlendMode multiplicativeBlending = sf::BlendMultiply;\n/// sf::BlendMode noBlending             = sf::BlendNone;\n/// \\endcode\n///\n/// In SFML, a blend mode can be specified every time you draw a sf::Drawable\n/// object to a render target. It is part of the sf::RenderStates compound\n/// that is passed to the member function sf::RenderTarget::draw().\n///\n/// \\see sf::RenderStates, sf::RenderTarget\n///\n////////////////////////////////////////////////////////////\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/Graphics/CircleShape.hpp",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n#ifndef SFML_CIRCLESHAPE_HPP\n#define SFML_CIRCLESHAPE_HPP\n\n////////////////////////////////////////////////////////////\n// Headers\n////////////////////////////////////////////////////////////\n#include <SFML/Graphics/Export.hpp>\n#include <SFML/Graphics/Shape.hpp>\n\n\nnamespace sf\n{\n////////////////////////////////////////////////////////////\n/// \\brief Specialized shape representing a circle\n///\n////////////////////////////////////////////////////////////\nclass SFML_GRAPHICS_API CircleShape : public Shape\n{\npublic:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Default constructor\n    ///\n    /// \\param radius     Radius of the circle\n    /// \\param pointCount Number of points composing the circle\n    ///\n    ////////////////////////////////////////////////////////////\n    explicit CircleShape(float radius = 0, std::size_t pointCount = 30);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Set the radius of the circle\n    ///\n    /// \\param radius New radius of the circle\n    ///\n    /// \\see getRadius\n    ///\n    ////////////////////////////////////////////////////////////\n    void setRadius(float radius);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the radius of the circle\n    ///\n    /// \\return Radius of the circle\n    ///\n    /// \\see setRadius\n    ///\n    ////////////////////////////////////////////////////////////\n    float getRadius() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Set the number of points of the circle\n    ///\n    /// \\param count New number of points of the circle\n    ///\n    /// \\see getPointCount\n    ///\n    ////////////////////////////////////////////////////////////\n    void setPointCount(std::size_t count);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the number of points of the circle\n    ///\n    /// \\return Number of points of the circle\n    ///\n    /// \\see setPointCount\n    ///\n    ////////////////////////////////////////////////////////////\n    virtual std::size_t getPointCount() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get a point of the circle\n    ///\n    /// The returned point is in local coordinates, that is,\n    /// the shape's transforms (position, rotation, scale) are\n    /// not taken into account.\n    /// The result is undefined if \\a index is out of the valid range.\n    ///\n    /// \\param index Index of the point to get, in range [0 .. getPointCount() - 1]\n    ///\n    /// \\return index-th point of the shape\n    ///\n    ////////////////////////////////////////////////////////////\n    virtual Vector2f getPoint(std::size_t index) const;\n\nprivate:\n\n    ////////////////////////////////////////////////////////////\n    // Member data\n    ////////////////////////////////////////////////////////////\n    float       m_radius;     ///< Radius of the circle\n    std::size_t m_pointCount; ///< Number of points composing the circle\n};\n\n} // namespace sf\n\n\n#endif // SFML_CIRCLESHAPE_HPP\n\n\n////////////////////////////////////////////////////////////\n/// \\class sf::CircleShape\n/// \\ingroup graphics\n///\n/// This class inherits all the functions of sf::Transformable\n/// (position, rotation, scale, bounds, ...) as well as the\n/// functions of sf::Shape (outline, color, texture, ...).\n///\n/// Usage example:\n/// \\code\n/// sf::CircleShape circle;\n/// circle.setRadius(150);\n/// circle.setOutlineColor(sf::Color::Red);\n/// circle.setOutlineThickness(5);\n/// circle.setPosition(10, 20);\n/// ...\n/// window.draw(circle);\n/// \\endcode\n///\n/// Since the graphics card can't draw perfect circles, we have to\n/// fake them with multiple triangles connected to each other. The\n/// \"points count\" property of sf::CircleShape defines how many of these\n/// triangles to use, and therefore defines the quality of the circle.\n///\n/// The number of points can also be used for another purpose; with\n/// small numbers you can create any regular polygon shape:\n/// equilateral triangle, square, pentagon, hexagon, ...\n///\n/// \\see sf::Shape, sf::RectangleShape, sf::ConvexShape\n///\n////////////////////////////////////////////////////////////\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/Graphics/Color.hpp",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n#ifndef SFML_COLOR_HPP\n#define SFML_COLOR_HPP\n\n////////////////////////////////////////////////////////////\n// Headers\n////////////////////////////////////////////////////////////\n#include <SFML/Graphics/Export.hpp>\n\n\nnamespace sf\n{\n////////////////////////////////////////////////////////////\n/// \\brief Utility class for manipulating RGBA colors\n///\n////////////////////////////////////////////////////////////\nclass SFML_GRAPHICS_API Color\n{\npublic:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Default constructor\n    ///\n    /// Constructs an opaque black color. It is equivalent to\n    /// sf::Color(0, 0, 0, 255).\n    ///\n    ////////////////////////////////////////////////////////////\n    Color();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Construct the color from its 4 RGBA components\n    ///\n    /// \\param red   Red component (in the range [0, 255])\n    /// \\param green Green component (in the range [0, 255])\n    /// \\param blue  Blue component (in the range [0, 255])\n    /// \\param alpha Alpha (opacity) component (in the range [0, 255])\n    ///\n    ////////////////////////////////////////////////////////////\n    Color(Uint8 red, Uint8 green, Uint8 blue, Uint8 alpha = 255);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Construct the color from 32-bit unsigned integer\n    ///\n    /// \\param color Number containing the RGBA components (in that order)\n    ///\n    ////////////////////////////////////////////////////////////\n    explicit Color(Uint32 color);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Retrieve the color as a 32-bit unsigned integer\n    ///\n    /// \\return Color represented as a 32-bit unsigned integer\n    ///\n    ////////////////////////////////////////////////////////////\n    Uint32 toInteger() const;\n\n    ////////////////////////////////////////////////////////////\n    // Static member data\n    ////////////////////////////////////////////////////////////\n    static const Color Black;       ///< Black predefined color\n    static const Color White;       ///< White predefined color\n    static const Color Red;         ///< Red predefined color\n    static const Color Green;       ///< Green predefined color\n    static const Color Blue;        ///< Blue predefined color\n    static const Color Yellow;      ///< Yellow predefined color\n    static const Color Magenta;     ///< Magenta predefined color\n    static const Color Cyan;        ///< Cyan predefined color\n    static const Color Transparent; ///< Transparent (black) predefined color\n\n    ////////////////////////////////////////////////////////////\n    // Member data\n    ////////////////////////////////////////////////////////////\n    Uint8 r; ///< Red component\n    Uint8 g; ///< Green component\n    Uint8 b; ///< Blue component\n    Uint8 a; ///< Alpha (opacity) component\n};\n\n////////////////////////////////////////////////////////////\n/// \\relates Color\n/// \\brief Overload of the == operator\n///\n/// This operator compares two colors and check if they are equal.\n///\n/// \\param left  Left operand\n/// \\param right Right operand\n///\n/// \\return True if colors are equal, false if they are different\n///\n////////////////////////////////////////////////////////////\nSFML_GRAPHICS_API bool operator ==(const Color& left, const Color& right);\n\n////////////////////////////////////////////////////////////\n/// \\relates Color\n/// \\brief Overload of the != operator\n///\n/// This operator compares two colors and check if they are different.\n///\n/// \\param left  Left operand\n/// \\param right Right operand\n///\n/// \\return True if colors are different, false if they are equal\n///\n////////////////////////////////////////////////////////////\nSFML_GRAPHICS_API bool operator !=(const Color& left, const Color& right);\n\n////////////////////////////////////////////////////////////\n/// \\relates Color\n/// \\brief Overload of the binary + operator\n///\n/// This operator returns the component-wise sum of two colors.\n/// Components that exceed 255 are clamped to 255.\n///\n/// \\param left  Left operand\n/// \\param right Right operand\n///\n/// \\return Result of \\a left + \\a right\n///\n////////////////////////////////////////////////////////////\nSFML_GRAPHICS_API Color operator +(const Color& left, const Color& right);\n\n////////////////////////////////////////////////////////////\n/// \\relates Color\n/// \\brief Overload of the binary - operator\n///\n/// This operator returns the component-wise subtraction of two colors.\n/// Components below 0 are clamped to 0.\n///\n/// \\param left  Left operand\n/// \\param right Right operand\n///\n/// \\return Result of \\a left - \\a right\n///\n////////////////////////////////////////////////////////////\nSFML_GRAPHICS_API Color operator -(const Color& left, const Color& right);\n\n////////////////////////////////////////////////////////////\n/// \\relates Color\n/// \\brief Overload of the binary * operator\n///\n/// This operator returns the component-wise multiplication\n/// (also called \"modulation\") of two colors.\n/// Components are then divided by 255 so that the result is\n/// still in the range [0, 255].\n///\n/// \\param left  Left operand\n/// \\param right Right operand\n///\n/// \\return Result of \\a left * \\a right\n///\n////////////////////////////////////////////////////////////\nSFML_GRAPHICS_API Color operator *(const Color& left, const Color& right);\n\n////////////////////////////////////////////////////////////\n/// \\relates Color\n/// \\brief Overload of the binary += operator\n///\n/// This operator computes the component-wise sum of two colors,\n/// and assigns the result to the left operand.\n/// Components that exceed 255 are clamped to 255.\n///\n/// \\param left  Left operand\n/// \\param right Right operand\n///\n/// \\return Reference to \\a left\n///\n////////////////////////////////////////////////////////////\nSFML_GRAPHICS_API Color& operator +=(Color& left, const Color& right);\n\n////////////////////////////////////////////////////////////\n/// \\relates Color\n/// \\brief Overload of the binary -= operator\n///\n/// This operator computes the component-wise subtraction of two colors,\n/// and assigns the result to the left operand.\n/// Components below 0 are clamped to 0.\n///\n/// \\param left  Left operand\n/// \\param right Right operand\n///\n/// \\return Reference to \\a left\n///\n////////////////////////////////////////////////////////////\nSFML_GRAPHICS_API Color& operator -=(Color& left, const Color& right);\n\n////////////////////////////////////////////////////////////\n/// \\relates Color\n/// \\brief Overload of the binary *= operator\n///\n/// This operator returns the component-wise multiplication\n/// (also called \"modulation\") of two colors, and assigns\n/// the result to the left operand.\n/// Components are then divided by 255 so that the result is\n/// still in the range [0, 255].\n///\n/// \\param left  Left operand\n/// \\param right Right operand\n///\n/// \\return Reference to \\a left\n///\n////////////////////////////////////////////////////////////\nSFML_GRAPHICS_API Color& operator *=(Color& left, const Color& right);\n\n} // namespace sf\n\n\n#endif // SFML_COLOR_HPP\n\n\n////////////////////////////////////////////////////////////\n/// \\class sf::Color\n/// \\ingroup graphics\n///\n/// sf::Color is a simple color class composed of 4 components:\n/// \\li Red\n/// \\li Green\n/// \\li Blue\n/// \\li Alpha (opacity)\n///\n/// Each component is a public member, an unsigned integer in\n/// the range [0, 255]. Thus, colors can be constructed and\n/// manipulated very easily:\n///\n/// \\code\n/// sf::Color color(255, 0, 0); // red\n/// color.r = 0;                // make it black\n/// color.b = 128;              // make it dark blue\n/// \\endcode\n///\n/// The fourth component of colors, named \"alpha\", represents\n/// the opacity of the color. A color with an alpha value of\n/// 255 will be fully opaque, while an alpha value of 0 will\n/// make a color fully transparent, whatever the value of the\n/// other components is.\n///\n/// The most common colors are already defined as static variables:\n/// \\code\n/// sf::Color black       = sf::Color::Black;\n/// sf::Color white       = sf::Color::White;\n/// sf::Color red         = sf::Color::Red;\n/// sf::Color green       = sf::Color::Green;\n/// sf::Color blue        = sf::Color::Blue;\n/// sf::Color yellow      = sf::Color::Yellow;\n/// sf::Color magenta     = sf::Color::Magenta;\n/// sf::Color cyan        = sf::Color::Cyan;\n/// sf::Color transparent = sf::Color::Transparent;\n/// \\endcode\n///\n/// Colors can also be added and modulated (multiplied) using the\n/// overloaded operators + and *.\n///\n////////////////////////////////////////////////////////////\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/Graphics/ConvexShape.hpp",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n#ifndef SFML_CONVEXSHAPE_HPP\n#define SFML_CONVEXSHAPE_HPP\n\n////////////////////////////////////////////////////////////\n// Headers\n////////////////////////////////////////////////////////////\n#include <SFML/Graphics/Export.hpp>\n#include <SFML/Graphics/Shape.hpp>\n#include <vector>\n\n\nnamespace sf\n{\n////////////////////////////////////////////////////////////\n/// \\brief Specialized shape representing a convex polygon\n///\n////////////////////////////////////////////////////////////\nclass SFML_GRAPHICS_API ConvexShape : public Shape\n{\npublic:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Default constructor\n    ///\n    /// \\param pointCount Number of points of the polygon\n    ///\n    ////////////////////////////////////////////////////////////\n    explicit ConvexShape(std::size_t pointCount = 0);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Set the number of points of the polygon\n    ///\n    /// \\a count must be greater than 2 to define a valid shape.\n    ///\n    /// \\param count New number of points of the polygon\n    ///\n    /// \\see getPointCount\n    ///\n    ////////////////////////////////////////////////////////////\n    void setPointCount(std::size_t count);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the number of points of the polygon\n    ///\n    /// \\return Number of points of the polygon\n    ///\n    /// \\see setPointCount\n    ///\n    ////////////////////////////////////////////////////////////\n    virtual std::size_t getPointCount() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Set the position of a point\n    ///\n    /// Don't forget that the polygon must remain convex, and\n    /// the points need to stay ordered!\n    /// setPointCount must be called first in order to set the total\n    /// number of points. The result is undefined if \\a index is out\n    /// of the valid range.\n    ///\n    /// \\param index Index of the point to change, in range [0 .. getPointCount() - 1]\n    /// \\param point New position of the point\n    ///\n    /// \\see getPoint\n    ///\n    ////////////////////////////////////////////////////////////\n    void setPoint(std::size_t index, const Vector2f& point);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the position of a point\n    ///\n    /// The returned point is in local coordinates, that is,\n    /// the shape's transforms (position, rotation, scale) are\n    /// not taken into account.\n    /// The result is undefined if \\a index is out of the valid range.\n    ///\n    /// \\param index Index of the point to get, in range [0 .. getPointCount() - 1]\n    ///\n    /// \\return Position of the index-th point of the polygon\n    ///\n    /// \\see setPoint\n    ///\n    ////////////////////////////////////////////////////////////\n    virtual Vector2f getPoint(std::size_t index) const;\n\nprivate:\n\n    ////////////////////////////////////////////////////////////\n    // Member data\n    ////////////////////////////////////////////////////////////\n    std::vector<Vector2f> m_points; ///< Points composing the convex polygon\n};\n\n} // namespace sf\n\n\n#endif // SFML_CONVEXSHAPE_HPP\n\n\n////////////////////////////////////////////////////////////\n/// \\class sf::ConvexShape\n/// \\ingroup graphics\n///\n/// This class inherits all the functions of sf::Transformable\n/// (position, rotation, scale, bounds, ...) as well as the\n/// functions of sf::Shape (outline, color, texture, ...).\n///\n/// It is important to keep in mind that a convex shape must\n/// always be... convex, otherwise it may not be drawn correctly.\n/// Moreover, the points must be defined in order; using a random\n/// order would result in an incorrect shape.\n///\n/// Usage example:\n/// \\code\n/// sf::ConvexShape polygon;\n/// polygon.setPointCount(3);\n/// polygon.setPoint(0, sf::Vector2f(0, 0));\n/// polygon.setPoint(1, sf::Vector2f(0, 10));\n/// polygon.setPoint(2, sf::Vector2f(25, 5));\n/// polygon.setOutlineColor(sf::Color::Red);\n/// polygon.setOutlineThickness(5);\n/// polygon.setPosition(10, 20);\n/// ...\n/// window.draw(polygon);\n/// \\endcode\n///\n/// \\see sf::Shape, sf::RectangleShape, sf::CircleShape\n///\n////////////////////////////////////////////////////////////\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/Graphics/Drawable.hpp",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n#ifndef SFML_DRAWABLE_HPP\n#define SFML_DRAWABLE_HPP\n\n////////////////////////////////////////////////////////////\n// Headers\n////////////////////////////////////////////////////////////\n#include <SFML/Graphics/Export.hpp>\n#include <SFML/Graphics/RenderStates.hpp>\n\n\nnamespace sf\n{\nclass RenderTarget;\n\n////////////////////////////////////////////////////////////\n/// \\brief Abstract base class for objects that can be drawn\n///        to a render target\n///\n////////////////////////////////////////////////////////////\nclass SFML_GRAPHICS_API Drawable\n{\npublic:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Virtual destructor\n    ///\n    ////////////////////////////////////////////////////////////\n    virtual ~Drawable() {}\n\nprotected:\n\n    friend class RenderTarget;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Draw the object to a render target\n    ///\n    /// This is a pure virtual function that has to be implemented\n    /// by the derived class to define how the drawable should be\n    /// drawn.\n    ///\n    /// \\param target Render target to draw to\n    /// \\param states Current render states\n    ///\n    ////////////////////////////////////////////////////////////\n    virtual void draw(RenderTarget& target, RenderStates states) const = 0;\n};\n\n} // namespace sf\n\n\n#endif // SFML_DRAWABLE_HPP\n\n\n////////////////////////////////////////////////////////////\n/// \\class sf::Drawable\n/// \\ingroup graphics\n///\n/// sf::Drawable is a very simple base class that allows objects\n/// of derived classes to be drawn to a sf::RenderTarget.\n///\n/// All you have to do in your derived class is to override the\n/// draw virtual function.\n///\n/// Note that inheriting from sf::Drawable is not mandatory,\n/// but it allows this nice syntax \"window.draw(object)\" rather\n/// than \"object.draw(window)\", which is more consistent with other\n/// SFML classes.\n///\n/// Example:\n/// \\code\n/// class MyDrawable : public sf::Drawable\n/// {\n/// public:\n///\n///    ...\n///\n/// private:\n///\n///     virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const\n///     {\n///         // You can draw other high-level objects\n///         target.draw(m_sprite, states);\n///\n///         // ... or use the low-level API\n///         states.texture = &m_texture;\n///         target.draw(m_vertices, states);\n///\n///         // ... or draw with OpenGL directly\n///         glBegin(GL_QUADS);\n///         ...\n///         glEnd();\n///     }\n///\n///     sf::Sprite m_sprite;\n///     sf::Texture m_texture;\n///     sf::VertexArray m_vertices;\n/// };\n/// \\endcode\n///\n/// \\see sf::RenderTarget\n///\n////////////////////////////////////////////////////////////\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/Graphics/Export.hpp",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n#ifndef SFML_GRAPHICS_EXPORT_HPP\n#define SFML_GRAPHICS_EXPORT_HPP\n\n////////////////////////////////////////////////////////////\n// Headers\n////////////////////////////////////////////////////////////\n#include <SFML/Config.hpp>\n\n\n////////////////////////////////////////////////////////////\n// Define portable import / export macros\n////////////////////////////////////////////////////////////\n#if defined(SFML_GRAPHICS_EXPORTS)\n\n    #define SFML_GRAPHICS_API SFML_API_EXPORT\n\n#else\n\n    #define SFML_GRAPHICS_API SFML_API_IMPORT\n\n#endif\n\n\n#endif // SFML_GRAPHICS_EXPORT_HPP\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/Graphics/Font.hpp",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n#ifndef SFML_FONT_HPP\n#define SFML_FONT_HPP\n\n////////////////////////////////////////////////////////////\n// Headers\n////////////////////////////////////////////////////////////\n#include <SFML/Graphics/Export.hpp>\n#include <SFML/Graphics/Glyph.hpp>\n#include <SFML/Graphics/Texture.hpp>\n#include <SFML/Graphics/Rect.hpp>\n#include <SFML/System/Vector2.hpp>\n#include <SFML/System/String.hpp>\n#include <map>\n#include <string>\n#include <vector>\n\n\nnamespace sf\n{\nclass InputStream;\n\n////////////////////////////////////////////////////////////\n/// \\brief Class for loading and manipulating character fonts\n///\n////////////////////////////////////////////////////////////\nclass SFML_GRAPHICS_API Font\n{\npublic:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Holds various information about a font\n    ///\n    ////////////////////////////////////////////////////////////\n    struct Info\n    {\n        std::string family; ///< The font family\n    };\n\npublic:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Default constructor\n    ///\n    /// This constructor defines an empty font\n    ///\n    ////////////////////////////////////////////////////////////\n    Font();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Copy constructor\n    ///\n    /// \\param copy Instance to copy\n    ///\n    ////////////////////////////////////////////////////////////\n    Font(const Font& copy);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Destructor\n    ///\n    /// Cleans up all the internal resources used by the font\n    ///\n    ////////////////////////////////////////////////////////////\n    ~Font();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Load the font from a file\n    ///\n    /// The supported font formats are: TrueType, Type 1, CFF,\n    /// OpenType, SFNT, X11 PCF, Windows FNT, BDF, PFR and Type 42.\n    /// Note that this function know nothing about the standard\n    /// fonts installed on the user's system, thus you can't\n    /// load them directly.\n    ///\n    /// \\warning SFML cannot preload all the font data in this\n    /// function, so the file has to remain accessible until\n    /// the sf::Font object loads a new font or is destroyed.\n    ///\n    /// \\param filename Path of the font file to load\n    ///\n    /// \\return True if loading succeeded, false if it failed\n    ///\n    /// \\see loadFromMemory, loadFromStream\n    ///\n    ////////////////////////////////////////////////////////////\n    bool loadFromFile(const std::string& filename);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Load the font from a file in memory\n    ///\n    /// The supported font formats are: TrueType, Type 1, CFF,\n    /// OpenType, SFNT, X11 PCF, Windows FNT, BDF, PFR and Type 42.\n    ///\n    /// \\warning SFML cannot preload all the font data in this\n    /// function, so the buffer pointed by \\a data has to remain\n    /// valid until the sf::Font object loads a new font or\n    /// is destroyed.\n    ///\n    /// \\param data        Pointer to the file data in memory\n    /// \\param sizeInBytes Size of the data to load, in bytes\n    ///\n    /// \\return True if loading succeeded, false if it failed\n    ///\n    /// \\see loadFromFile, loadFromStream\n    ///\n    ////////////////////////////////////////////////////////////\n    bool loadFromMemory(const void* data, std::size_t sizeInBytes);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Load the font from a custom stream\n    ///\n    /// The supported font formats are: TrueType, Type 1, CFF,\n    /// OpenType, SFNT, X11 PCF, Windows FNT, BDF, PFR and Type 42.\n    /// Warning: SFML cannot preload all the font data in this\n    /// function, so the contents of \\a stream have to remain\n    /// valid as long as the font is used.\n    ///\n    /// \\warning SFML cannot preload all the font data in this\n    /// function, so the stream has to remain accessible until\n    /// the sf::Font object loads a new font or is destroyed.\n    ///\n    /// \\param stream Source stream to read from\n    ///\n    /// \\return True if loading succeeded, false if it failed\n    ///\n    /// \\see loadFromFile, loadFromMemory\n    ///\n    ////////////////////////////////////////////////////////////\n    bool loadFromStream(InputStream& stream);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the font information\n    ///\n    /// \\return A structure that holds the font information\n    ///\n    ////////////////////////////////////////////////////////////\n    const Info& getInfo() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Retrieve a glyph of the font\n    ///\n    /// If the font is a bitmap font, not all character sizes\n    /// might be available. If the glyph is not available at the\n    /// requested size, an empty glyph is returned.\n    ///\n    /// Be aware that using a negative value for the outline\n    /// thickness will cause distorted rendering.\n    ///\n    /// \\param codePoint        Unicode code point of the character to get\n    /// \\param characterSize    Reference character size\n    /// \\param bold             Retrieve the bold version or the regular one?\n    /// \\param outlineThickness Thickness of outline (when != 0 the glyph will not be filled)\n    ///\n    /// \\return The glyph corresponding to \\a codePoint and \\a characterSize\n    ///\n    ////////////////////////////////////////////////////////////\n    const Glyph& getGlyph(Uint32 codePoint, unsigned int characterSize, bool bold, float outlineThickness = 0) const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the kerning offset of two glyphs\n    ///\n    /// The kerning is an extra offset (negative) to apply between two\n    /// glyphs when rendering them, to make the pair look more \"natural\".\n    /// For example, the pair \"AV\" have a special kerning to make them\n    /// closer than other characters. Most of the glyphs pairs have a\n    /// kerning offset of zero, though.\n    ///\n    /// \\param first         Unicode code point of the first character\n    /// \\param second        Unicode code point of the second character\n    /// \\param characterSize Reference character size\n    ///\n    /// \\return Kerning value for \\a first and \\a second, in pixels\n    ///\n    ////////////////////////////////////////////////////////////\n    float getKerning(Uint32 first, Uint32 second, unsigned int characterSize) const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the line spacing\n    ///\n    /// Line spacing is the vertical offset to apply between two\n    /// consecutive lines of text.\n    ///\n    /// \\param characterSize Reference character size\n    ///\n    /// \\return Line spacing, in pixels\n    ///\n    ////////////////////////////////////////////////////////////\n    float getLineSpacing(unsigned int characterSize) const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the position of the underline\n    ///\n    /// Underline position is the vertical offset to apply between the\n    /// baseline and the underline.\n    ///\n    /// \\param characterSize Reference character size\n    ///\n    /// \\return Underline position, in pixels\n    ///\n    /// \\see getUnderlineThickness\n    ///\n    ////////////////////////////////////////////////////////////\n    float getUnderlinePosition(unsigned int characterSize) const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the thickness of the underline\n    ///\n    /// Underline thickness is the vertical size of the underline.\n    ///\n    /// \\param characterSize Reference character size\n    ///\n    /// \\return Underline thickness, in pixels\n    ///\n    /// \\see getUnderlinePosition\n    ///\n    ////////////////////////////////////////////////////////////\n    float getUnderlineThickness(unsigned int characterSize) const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Retrieve the texture containing the loaded glyphs of a certain size\n    ///\n    /// The contents of the returned texture changes as more glyphs\n    /// are requested, thus it is not very relevant. It is mainly\n    /// used internally by sf::Text.\n    ///\n    /// \\param characterSize Reference character size\n    ///\n    /// \\return Texture containing the glyphs of the requested size\n    ///\n    ////////////////////////////////////////////////////////////\n    const Texture& getTexture(unsigned int characterSize) const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Overload of assignment operator\n    ///\n    /// \\param right Instance to assign\n    ///\n    /// \\return Reference to self\n    ///\n    ////////////////////////////////////////////////////////////\n    Font& operator =(const Font& right);\n\nprivate:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Structure defining a row of glyphs\n    ///\n    ////////////////////////////////////////////////////////////\n    struct Row\n    {\n        Row(unsigned int rowTop, unsigned int rowHeight) : width(0), top(rowTop), height(rowHeight) {}\n\n        unsigned int width;  ///< Current width of the row\n        unsigned int top;    ///< Y position of the row into the texture\n        unsigned int height; ///< Height of the row\n    };\n\n    ////////////////////////////////////////////////////////////\n    // Types\n    ////////////////////////////////////////////////////////////\n    typedef std::map<Uint64, Glyph> GlyphTable; ///< Table mapping a codepoint to its glyph\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Structure defining a page of glyphs\n    ///\n    ////////////////////////////////////////////////////////////\n    struct Page\n    {\n        Page();\n\n        GlyphTable       glyphs;  ///< Table mapping code points to their corresponding glyph\n        Texture          texture; ///< Texture containing the pixels of the glyphs\n        unsigned int     nextRow; ///< Y position of the next new row in the texture\n        std::vector<Row> rows;    ///< List containing the position of all the existing rows\n    };\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Free all the internal resources\n    ///\n    ////////////////////////////////////////////////////////////\n    void cleanup();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Load a new glyph and store it in the cache\n    ///\n    /// \\param codePoint        Unicode code point of the character to load\n    /// \\param characterSize    Reference character size\n    /// \\param bold             Retrieve the bold version or the regular one?\n    /// \\param outlineThickness Thickness of outline (when != 0 the glyph will not be filled)\n    ///\n    /// \\return The glyph corresponding to \\a codePoint and \\a characterSize\n    ///\n    ////////////////////////////////////////////////////////////\n    Glyph loadGlyph(Uint32 codePoint, unsigned int characterSize, bool bold, float outlineThickness) const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Find a suitable rectangle within the texture for a glyph\n    ///\n    /// \\param page   Page of glyphs to search in\n    /// \\param width  Width of the rectangle\n    /// \\param height Height of the rectangle\n    ///\n    /// \\return Found rectangle within the texture\n    ///\n    ////////////////////////////////////////////////////////////\n    IntRect findGlyphRect(Page& page, unsigned int width, unsigned int height) const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Make sure that the given size is the current one\n    ///\n    /// \\param characterSize Reference character size\n    ///\n    /// \\return True on success, false if any error happened\n    ///\n    ////////////////////////////////////////////////////////////\n    bool setCurrentSize(unsigned int characterSize) const;\n\n    ////////////////////////////////////////////////////////////\n    // Types\n    ////////////////////////////////////////////////////////////\n    typedef std::map<unsigned int, Page> PageTable; ///< Table mapping a character size to its page (texture)\n\n    ////////////////////////////////////////////////////////////\n    // Member data\n    ////////////////////////////////////////////////////////////\n    void*                      m_library;     ///< Pointer to the internal library interface (it is typeless to avoid exposing implementation details)\n    void*                      m_face;        ///< Pointer to the internal font face (it is typeless to avoid exposing implementation details)\n    void*                      m_streamRec;   ///< Pointer to the stream rec instance (it is typeless to avoid exposing implementation details)\n    void*                      m_stroker;     ///< Pointer to the stroker (it is typeless to avoid exposing implementation details)\n    int*                       m_refCount;    ///< Reference counter used by implicit sharing\n    Info                       m_info;        ///< Information about the font\n    mutable PageTable          m_pages;       ///< Table containing the glyphs pages by character size\n    mutable std::vector<Uint8> m_pixelBuffer; ///< Pixel buffer holding a glyph's pixels before being written to the texture\n    #ifdef SFML_SYSTEM_ANDROID\n    void*                      m_stream; ///< Asset file streamer (if loaded from file)\n    #endif\n};\n\n} // namespace sf\n\n\n#endif // SFML_FONT_HPP\n\n\n////////////////////////////////////////////////////////////\n/// \\class sf::Font\n/// \\ingroup graphics\n///\n/// Fonts can be loaded from a file, from memory or from a custom\n/// stream, and supports the most common types of fonts. See\n/// the loadFromFile function for the complete list of supported formats.\n///\n/// Once it is loaded, a sf::Font instance provides three\n/// types of information about the font:\n/// \\li Global metrics, such as the line spacing\n/// \\li Per-glyph metrics, such as bounding box or kerning\n/// \\li Pixel representation of glyphs\n///\n/// Fonts alone are not very useful: they hold the font data\n/// but cannot make anything useful of it. To do so you need to\n/// use the sf::Text class, which is able to properly output text\n/// with several options such as character size, style, color,\n/// position, rotation, etc.\n/// This separation allows more flexibility and better performances:\n/// indeed a sf::Font is a heavy resource, and any operation on it\n/// is slow (often too slow for real-time applications). On the other\n/// side, a sf::Text is a lightweight object which can combine the\n/// glyphs data and metrics of a sf::Font to display any text on a\n/// render target.\n/// Note that it is also possible to bind several sf::Text instances\n/// to the same sf::Font.\n///\n/// It is important to note that the sf::Text instance doesn't\n/// copy the font that it uses, it only keeps a reference to it.\n/// Thus, a sf::Font must not be destructed while it is\n/// used by a sf::Text (i.e. never write a function that\n/// uses a local sf::Font instance for creating a text).\n///\n/// Usage example:\n/// \\code\n/// // Declare a new font\n/// sf::Font font;\n///\n/// // Load it from a file\n/// if (!font.loadFromFile(\"arial.ttf\"))\n/// {\n///     // error...\n/// }\n///\n/// // Create a text which uses our font\n/// sf::Text text1;\n/// text1.setFont(font);\n/// text1.setCharacterSize(30);\n/// text1.setStyle(sf::Text::Regular);\n///\n/// // Create another text using the same font, but with different parameters\n/// sf::Text text2;\n/// text2.setFont(font);\n/// text2.setCharacterSize(50);\n/// text2.setStyle(sf::Text::Italic);\n/// \\endcode\n///\n/// Apart from loading font files, and passing them to instances\n/// of sf::Text, you should normally not have to deal directly\n/// with this class. However, it may be useful to access the\n/// font metrics or rasterized glyphs for advanced usage.\n///\n/// Note that if the font is a bitmap font, it is not scalable,\n/// thus not all requested sizes will be available to use. This\n/// needs to be taken into consideration when using sf::Text.\n/// If you need to display text of a certain size, make sure the\n/// corresponding bitmap font that supports that size is used.\n///\n/// \\see sf::Text\n///\n////////////////////////////////////////////////////////////\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/Graphics/Glsl.hpp",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n#ifndef SFML_GLSL_HPP\n#define SFML_GLSL_HPP\n\n////////////////////////////////////////////////////////////\n// Headers\n////////////////////////////////////////////////////////////\n#include <SFML/Graphics/Transform.hpp>\n#include <SFML/Graphics/Color.hpp>\n#include <SFML/System/Vector2.hpp>\n#include <SFML/System/Vector3.hpp>\n\n\nnamespace sf\n{\nnamespace priv\n{\n    // Forward declarations\n    template <std::size_t Columns, std::size_t Rows>\n    struct Matrix;\n\n    template <typename T>\n    struct Vector4;\n\n#include <SFML/Graphics/Glsl.inl>\n\n} // namespace priv\n\n\n////////////////////////////////////////////////////////////\n/// \\brief Namespace with GLSL types\n///\n////////////////////////////////////////////////////////////\nnamespace Glsl\n{\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief 2D float vector (\\p vec2 in GLSL)\n    ///\n    ////////////////////////////////////////////////////////////\n    typedef Vector2<float> Vec2;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief 2D int vector (\\p ivec2 in GLSL)\n    ///\n    ////////////////////////////////////////////////////////////\n    typedef Vector2<int> Ivec2;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief 2D bool vector (\\p bvec2 in GLSL)\n    ///\n    ////////////////////////////////////////////////////////////\n    typedef Vector2<bool> Bvec2;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief 3D float vector (\\p vec3 in GLSL)\n    ///\n    ////////////////////////////////////////////////////////////\n    typedef Vector3<float> Vec3;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief 3D int vector (\\p ivec3 in GLSL)\n    ///\n    ////////////////////////////////////////////////////////////\n    typedef Vector3<int> Ivec3;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief 3D bool vector (\\p bvec3 in GLSL)\n    ///\n    ////////////////////////////////////////////////////////////\n    typedef Vector3<bool> Bvec3;\n\n#ifdef SFML_DOXYGEN\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief 4D float vector (\\p vec4 in GLSL)\n    ///\n    /// 4D float vectors can be implicitly converted from sf::Color\n    /// instances. Each color channel is normalized from integers\n    /// in [0, 255] to floating point values in [0, 1].\n    /// \\code\n    /// sf::Glsl::Vec4 zeroVector;\n    /// sf::Glsl::Vec4 vector(1.f, 2.f, 3.f, 4.f);\n    /// sf::Glsl::Vec4 color = sf::Color::Cyan;\n    /// \\endcode\n    ////////////////////////////////////////////////////////////\n    typedef implementation-defined Vec4;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief 4D int vector (\\p ivec4 in GLSL)\n    ///\n    /// 4D int vectors can be implicitly converted from sf::Color\n    /// instances. Each color channel remains unchanged inside\n    /// the integer interval [0, 255].\n    /// \\code\n    /// sf::Glsl::Ivec4 zeroVector;\n    /// sf::Glsl::Ivec4 vector(1, 2, 3, 4);\n    /// sf::Glsl::Ivec4 color = sf::Color::Cyan;\n    /// \\endcode\n    ////////////////////////////////////////////////////////////\n    typedef implementation-defined Ivec4;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief 4D bool vector (\\p bvec4 in GLSL)\n    ///\n    ////////////////////////////////////////////////////////////\n    typedef implementation-defined Bvec4;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief 3x3 float matrix (\\p mat3 in GLSL)\n    ///\n    /// The matrix can be constructed from an array with 3x3\n    /// elements, aligned in column-major order. For example,\n    /// a translation by (x, y) looks as follows:\n    /// \\code\n    /// float array[9] =\n    /// {\n    ///     1, 0, 0,\n    ///     0, 1, 0,\n    ///     x, y, 1\n    /// };\n    ///\n    /// sf::Glsl::Mat3 matrix(array);\n    /// \\endcode\n    ///\n    /// Mat3 can also be implicitly converted from sf::Transform:\n    /// \\code\n    /// sf::Transform transform;\n    /// sf::Glsl::Mat3 matrix = transform;\n    /// \\endcode\n    ////////////////////////////////////////////////////////////\n    typedef implementation-defined Mat3;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief 4x4 float matrix (\\p mat4 in GLSL)\n    ///\n    /// The matrix can be constructed from an array with 4x4\n    /// elements, aligned in column-major order. For example,\n    /// a translation by (x, y, z) looks as follows:\n    /// \\code\n    /// float array[16] =\n    /// {\n    ///     1, 0, 0, 0,\n    ///     0, 1, 0, 0,\n    ///     0, 0, 1, 0,\n    ///     x, y, z, 1\n    /// };\n    ///\n    /// sf::Glsl::Mat4 matrix(array);\n    /// \\endcode\n    ///\n    /// Mat4 can also be implicitly converted from sf::Transform:\n    /// \\code\n    /// sf::Transform transform;\n    /// sf::Glsl::Mat4 matrix = transform;\n    /// \\endcode\n    ////////////////////////////////////////////////////////////\n    typedef implementation-defined Mat4;\n\n#else // SFML_DOXYGEN\n\n    typedef priv::Vector4<float> Vec4;\n    typedef priv::Vector4<int> Ivec4;\n    typedef priv::Vector4<bool> Bvec4;\n    typedef priv::Matrix<3, 3> Mat3;\n    typedef priv::Matrix<4, 4> Mat4;\n\n#endif // SFML_DOXYGEN\n\n} // namespace Glsl\n} // namespace sf\n\n#endif // SFML_GLSL_HPP\n\n\n////////////////////////////////////////////////////////////\n/// \\namespace sf::Glsl\n/// \\ingroup graphics\n///\n/// \\details The sf::Glsl namespace contains types that match\n/// their equivalents in GLSL, the OpenGL shading language.\n/// These types are exclusively used by the sf::Shader class.\n///\n/// Types that already exist in SFML, such as \\ref sf::Vector2<T>\n/// and \\ref sf::Vector3<T>, are reused as typedefs, so you can use\n/// the types in this namespace as well as the original ones.\n/// Others are newly defined, such as Glsl::Vec4 or Glsl::Mat3. Their\n/// actual type is an implementation detail and should not be used.\n///\n/// All vector types support a default constructor that\n/// initializes every component to zero, in addition to a\n/// constructor with one parameter for each component.\n/// The components are stored in member variables called\n/// x, y, z, and w.\n///\n/// All matrix types support a constructor with a float*\n/// parameter that points to a float array of the appropriate\n/// size (that is, 9 in a 3x3 matrix, 16 in a 4x4 matrix).\n/// Furthermore, they can be converted from sf::Transform\n/// objects.\n///\n/// \\see sf::Shader\n///\n////////////////////////////////////////////////////////////\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/Graphics/Glsl.inl",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n\n////////////////////////////////////////////////////////////\n/// \\brief Helper functions to copy sf::Transform to sf::Glsl::Mat3/4\n///\n////////////////////////////////////////////////////////////\nvoid SFML_GRAPHICS_API copyMatrix(const Transform& source, Matrix<3, 3>& dest);\nvoid SFML_GRAPHICS_API copyMatrix(const Transform& source, Matrix<4, 4>& dest);\n\n////////////////////////////////////////////////////////////\n/// \\brief Copy array-based matrix with given number of elements\n///\n/// Indirection to std::copy() to avoid inclusion of\n/// <algorithm> and MSVC's annoying 4996 warning in header\n///\n////////////////////////////////////////////////////////////\nvoid SFML_GRAPHICS_API copyMatrix(const float* source, std::size_t elements, float* dest);\n\n////////////////////////////////////////////////////////////\n/// \\brief Helper functions to copy sf::Color to sf::Glsl::Vec4/Ivec4\n///\n////////////////////////////////////////////////////////////\nvoid SFML_GRAPHICS_API copyVector(const Color& source, Vector4<float>& dest);\nvoid SFML_GRAPHICS_API copyVector(const Color& source, Vector4<int>& dest);\n\n\n////////////////////////////////////////////////////////////\n/// \\brief Matrix type, used to set uniforms in GLSL\n///\n////////////////////////////////////////////////////////////\ntemplate <std::size_t Columns, std::size_t Rows>\nstruct Matrix\n{\n    ////////////////////////////////////////////////////////////\n    /// \\brief Construct from raw data\n    ///\n    /// \\param pointer Points to the beginning of an array that\n    ///                has the size of the matrix. The elements\n    ///                are copied to the instance.\n    ///\n    ////////////////////////////////////////////////////////////\n    explicit Matrix(const float* pointer)\n    {\n        copyMatrix(pointer, Columns * Rows, array);\n    }\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Construct implicitly from SFML transform\n    ///\n    /// This constructor is only supported for 3x3 and 4x4\n    /// matrices.\n    ///\n    /// \\param transform Object containing a transform.\n    ///\n    ////////////////////////////////////////////////////////////\n    Matrix(const Transform& transform)\n    {\n        copyMatrix(transform, *this);\n    }\n\n    float array[Columns * Rows]; ///< Array holding matrix data\n};\n\n////////////////////////////////////////////////////////////\n/// \\brief 4D vector type, used to set uniforms in GLSL\n///\n////////////////////////////////////////////////////////////\ntemplate <typename T>\nstruct Vector4\n{\n    ////////////////////////////////////////////////////////////\n    /// \\brief Default constructor, creates a zero vector\n    ///\n    ////////////////////////////////////////////////////////////\n    Vector4() :\n    x(0),\n    y(0),\n    z(0),\n    w(0)\n    {\n    }\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Construct from 4 vector components\n    ///\n    /// \\param X Component of the 4D vector\n    /// \\param Y Component of the 4D vector\n    /// \\param Z Component of the 4D vector\n    /// \\param W Component of the 4D vector\n    ///\n    ////////////////////////////////////////////////////////////\n    Vector4(T X, T Y, T Z, T W) :\n    x(X),\n    y(Y),\n    z(Z),\n    w(W)\n    {\n    }\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Conversion constructor\n    ///\n    /// \\param other 4D vector of different type\n    ///\n    ////////////////////////////////////////////////////////////\n    template <typename U>\n    explicit Vector4(const Vector4<U>& other) :\n    x(static_cast<T>(other.x)),\n    y(static_cast<T>(other.y)),\n    z(static_cast<T>(other.z)),\n    w(static_cast<T>(other.w))\n    {\n    }\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Construct float vector implicitly from color\n    ///\n    /// \\param color Color instance. Is normalized to [0, 1]\n    ///              for floats, and left as-is for ints.\n    ///\n    ////////////////////////////////////////////////////////////\n    Vector4(const Color& color)\n    // uninitialized\n    {\n        copyVector(color, *this);\n    }\n\n    T x; ///< 1st component (X) of the 4D vector\n    T y; ///< 2nd component (Y) of the 4D vector\n    T z; ///< 3rd component (Z) of the 4D vector\n    T w; ///< 4th component (W) of the 4D vector\n};\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/Graphics/Glyph.hpp",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n#ifndef SFML_GLYPH_HPP\n#define SFML_GLYPH_HPP\n\n////////////////////////////////////////////////////////////\n// Headers\n////////////////////////////////////////////////////////////\n#include <SFML/Graphics/Export.hpp>\n#include <SFML/Graphics/Rect.hpp>\n\n\nnamespace sf\n{\n////////////////////////////////////////////////////////////\n/// \\brief Structure describing a glyph\n///\n////////////////////////////////////////////////////////////\nclass SFML_GRAPHICS_API Glyph\n{\npublic:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Default constructor\n    ///\n    ////////////////////////////////////////////////////////////\n    Glyph() : advance(0) {}\n\n    ////////////////////////////////////////////////////////////\n    // Member data\n    ////////////////////////////////////////////////////////////\n    float     advance;     ///< Offset to move horizontally to the next character\n    FloatRect bounds;      ///< Bounding rectangle of the glyph, in coordinates relative to the baseline\n    IntRect   textureRect; ///< Texture coordinates of the glyph inside the font's texture\n};\n\n} // namespace sf\n\n\n#endif // SFML_GLYPH_HPP\n\n\n////////////////////////////////////////////////////////////\n/// \\class sf::Glyph\n/// \\ingroup graphics\n///\n/// A glyph is the visual representation of a character.\n///\n/// The sf::Glyph structure provides the information needed\n/// to handle the glyph:\n/// \\li its coordinates in the font's texture\n/// \\li its bounding rectangle\n/// \\li the offset to apply to get the starting position of the next glyph\n///\n/// \\see sf::Font\n///\n////////////////////////////////////////////////////////////\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/Graphics/Image.hpp",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n#ifndef SFML_IMAGE_HPP\n#define SFML_IMAGE_HPP\n\n////////////////////////////////////////////////////////////\n// Headers\n////////////////////////////////////////////////////////////\n#include <SFML/Graphics/Export.hpp>\n#include <SFML/Graphics/Color.hpp>\n#include <SFML/Graphics/Rect.hpp>\n#include <string>\n#include <vector>\n\n\nnamespace sf\n{\nclass InputStream;\n\n////////////////////////////////////////////////////////////\n/// \\brief Class for loading, manipulating and saving images\n///\n////////////////////////////////////////////////////////////\nclass SFML_GRAPHICS_API Image\n{\npublic:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Default constructor\n    ///\n    /// Creates an empty image.\n    ///\n    ////////////////////////////////////////////////////////////\n    Image();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Destructor\n    ///\n    ////////////////////////////////////////////////////////////\n    ~Image();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Create the image and fill it with a unique color\n    ///\n    /// \\param width  Width of the image\n    /// \\param height Height of the image\n    /// \\param color  Fill color\n    ///\n    ////////////////////////////////////////////////////////////\n    void create(unsigned int width, unsigned int height, const Color& color = Color(0, 0, 0));\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Create the image from an array of pixels\n    ///\n    /// The \\a pixel array is assumed to contain 32-bits RGBA pixels,\n    /// and have the given \\a width and \\a height. If not, this is\n    /// an undefined behavior.\n    /// If \\a pixels is null, an empty image is created.\n    ///\n    /// \\param width  Width of the image\n    /// \\param height Height of the image\n    /// \\param pixels Array of pixels to copy to the image\n    ///\n    ////////////////////////////////////////////////////////////\n    void create(unsigned int width, unsigned int height, const Uint8* pixels);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Load the image from a file on disk\n    ///\n    /// The supported image formats are bmp, png, tga, jpg, gif,\n    /// psd, hdr and pic. Some format options are not supported,\n    /// like progressive jpeg.\n    /// If this function fails, the image is left unchanged.\n    ///\n    /// \\param filename Path of the image file to load\n    ///\n    /// \\return True if loading was successful\n    ///\n    /// \\see loadFromMemory, loadFromStream, saveToFile\n    ///\n    ////////////////////////////////////////////////////////////\n    bool loadFromFile(const std::string& filename);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Load the image from a file in memory\n    ///\n    /// The supported image formats are bmp, png, tga, jpg, gif,\n    /// psd, hdr and pic. Some format options are not supported,\n    /// like progressive jpeg.\n    /// If this function fails, the image is left unchanged.\n    ///\n    /// \\param data Pointer to the file data in memory\n    /// \\param size Size of the data to load, in bytes\n    ///\n    /// \\return True if loading was successful\n    ///\n    /// \\see loadFromFile, loadFromStream\n    ///\n    ////////////////////////////////////////////////////////////\n    bool loadFromMemory(const void* data, std::size_t size);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Load the image from a custom stream\n    ///\n    /// The supported image formats are bmp, png, tga, jpg, gif,\n    /// psd, hdr and pic. Some format options are not supported,\n    /// like progressive jpeg.\n    /// If this function fails, the image is left unchanged.\n    ///\n    /// \\param stream Source stream to read from\n    ///\n    /// \\return True if loading was successful\n    ///\n    /// \\see loadFromFile, loadFromMemory\n    ///\n    ////////////////////////////////////////////////////////////\n    bool loadFromStream(InputStream& stream);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Save the image to a file on disk\n    ///\n    /// The format of the image is automatically deduced from\n    /// the extension. The supported image formats are bmp, png,\n    /// tga and jpg. The destination file is overwritten\n    /// if it already exists. This function fails if the image is empty.\n    ///\n    /// \\param filename Path of the file to save\n    ///\n    /// \\return True if saving was successful\n    ///\n    /// \\see create, loadFromFile, loadFromMemory\n    ///\n    ////////////////////////////////////////////////////////////\n    bool saveToFile(const std::string& filename) const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Return the size (width and height) of the image\n    ///\n    /// \\return Size of the image, in pixels\n    ///\n    ////////////////////////////////////////////////////////////\n    Vector2u getSize() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Create a transparency mask from a specified color-key\n    ///\n    /// This function sets the alpha value of every pixel matching\n    /// the given color to \\a alpha (0 by default), so that they\n    /// become transparent.\n    ///\n    /// \\param color Color to make transparent\n    /// \\param alpha Alpha value to assign to transparent pixels\n    ///\n    ////////////////////////////////////////////////////////////\n    void createMaskFromColor(const Color& color, Uint8 alpha = 0);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Copy pixels from another image onto this one\n    ///\n    /// This function does a slow pixel copy and should not be\n    /// used intensively. It can be used to prepare a complex\n    /// static image from several others, but if you need this\n    /// kind of feature in real-time you'd better use sf::RenderTexture.\n    ///\n    /// If \\a sourceRect is empty, the whole image is copied.\n    /// If \\a applyAlpha is set to true, the transparency of\n    /// source pixels is applied. If it is false, the pixels are\n    /// copied unchanged with their alpha value.\n    ///\n    /// \\param source     Source image to copy\n    /// \\param destX      X coordinate of the destination position\n    /// \\param destY      Y coordinate of the destination position\n    /// \\param sourceRect Sub-rectangle of the source image to copy\n    /// \\param applyAlpha Should the copy take into account the source transparency?\n    ///\n    ////////////////////////////////////////////////////////////\n    void copy(const Image& source, unsigned int destX, unsigned int destY, const IntRect& sourceRect = IntRect(0, 0, 0, 0), bool applyAlpha = false);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Change the color of a pixel\n    ///\n    /// This function doesn't check the validity of the pixel\n    /// coordinates, using out-of-range values will result in\n    /// an undefined behavior.\n    ///\n    /// \\param x     X coordinate of pixel to change\n    /// \\param y     Y coordinate of pixel to change\n    /// \\param color New color of the pixel\n    ///\n    /// \\see getPixel\n    ///\n    ////////////////////////////////////////////////////////////\n    void setPixel(unsigned int x, unsigned int y, const Color& color);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the color of a pixel\n    ///\n    /// This function doesn't check the validity of the pixel\n    /// coordinates, using out-of-range values will result in\n    /// an undefined behavior.\n    ///\n    /// \\param x X coordinate of pixel to get\n    /// \\param y Y coordinate of pixel to get\n    ///\n    /// \\return Color of the pixel at coordinates (x, y)\n    ///\n    /// \\see setPixel\n    ///\n    ////////////////////////////////////////////////////////////\n    Color getPixel(unsigned int x, unsigned int y) const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get a read-only pointer to the array of pixels\n    ///\n    /// The returned value points to an array of RGBA pixels made of\n    /// 8 bits integers components. The size of the array is\n    /// width * height * 4 (getSize().x * getSize().y * 4).\n    /// Warning: the returned pointer may become invalid if you\n    /// modify the image, so you should never store it for too long.\n    /// If the image is empty, a null pointer is returned.\n    ///\n    /// \\return Read-only pointer to the array of pixels\n    ///\n    ////////////////////////////////////////////////////////////\n    const Uint8* getPixelsPtr() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Flip the image horizontally (left <-> right)\n    ///\n    ////////////////////////////////////////////////////////////\n    void flipHorizontally();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Flip the image vertically (top <-> bottom)\n    ///\n    ////////////////////////////////////////////////////////////\n    void flipVertically();\n\nprivate:\n\n    ////////////////////////////////////////////////////////////\n    // Member data\n    ////////////////////////////////////////////////////////////\n    Vector2u           m_size;   ///< Image size\n    std::vector<Uint8> m_pixels; ///< Pixels of the image\n    #ifdef SFML_SYSTEM_ANDROID\n    void*              m_stream; ///< Asset file streamer (if loaded from file)\n    #endif\n};\n\n} // namespace sf\n\n\n#endif // SFML_IMAGE_HPP\n\n\n////////////////////////////////////////////////////////////\n/// \\class sf::Image\n/// \\ingroup graphics\n///\n/// sf::Image is an abstraction to manipulate images\n/// as bidimensional arrays of pixels. The class provides\n/// functions to load, read, write and save pixels, as well\n/// as many other useful functions.\n///\n/// sf::Image can handle a unique internal representation of\n/// pixels, which is RGBA 32 bits. This means that a pixel\n/// must be composed of 8 bits red, green, blue and alpha\n/// channels -- just like a sf::Color.\n/// All the functions that return an array of pixels follow\n/// this rule, and all parameters that you pass to sf::Image\n/// functions (such as loadFromMemory) must use this\n/// representation as well.\n///\n/// A sf::Image can be copied, but it is a heavy resource and\n/// if possible you should always use [const] references to\n/// pass or return them to avoid useless copies.\n///\n/// Usage example:\n/// \\code\n/// // Load an image file from a file\n/// sf::Image background;\n/// if (!background.loadFromFile(\"background.jpg\"))\n///     return -1;\n///\n/// // Create a 20x20 image filled with black color\n/// sf::Image image;\n/// image.create(20, 20, sf::Color::Black);\n///\n/// // Copy image1 on image2 at position (10, 10)\n/// image.copy(background, 10, 10);\n///\n/// // Make the top-left pixel transparent\n/// sf::Color color = image.getPixel(0, 0);\n/// color.a = 0;\n/// image.setPixel(0, 0, color);\n///\n/// // Save the image to a file\n/// if (!image.saveToFile(\"result.png\"))\n///     return -1;\n/// \\endcode\n///\n/// \\see sf::Texture\n///\n////////////////////////////////////////////////////////////\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/Graphics/PrimitiveType.hpp",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n#ifndef SFML_PRIMITIVETYPE_HPP\n#define SFML_PRIMITIVETYPE_HPP\n\nnamespace sf\n{\n////////////////////////////////////////////////////////////\n/// \\ingroup graphics\n/// \\brief Types of primitives that a sf::VertexArray can render\n///\n/// Points and lines have no area, therefore their thickness\n/// will always be 1 pixel, regardless the current transform\n/// and view.\n///\n////////////////////////////////////////////////////////////\nenum PrimitiveType\n{\n    Points,        ///< List of individual points\n    Lines,         ///< List of individual lines\n    LineStrip,     ///< List of connected lines, a point uses the previous point to form a line\n    Triangles,     ///< List of individual triangles\n    TriangleStrip, ///< List of connected triangles, a point uses the two previous points to form a triangle\n    TriangleFan,   ///< List of connected triangles, a point uses the common center and the previous point to form a triangle\n    Quads,         ///< List of individual quads (deprecated, don't work with OpenGL ES)\n\n    // Deprecated names\n    LinesStrip     = LineStrip,     ///< \\deprecated Use LineStrip instead\n    TrianglesStrip = TriangleStrip, ///< \\deprecated Use TriangleStrip instead\n    TrianglesFan   = TriangleFan    ///< \\deprecated Use TriangleFan instead\n};\n\n} // namespace sf\n\n\n#endif // SFML_PRIMITIVETYPE_HPP\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/Graphics/Rect.hpp",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n#ifndef SFML_RECT_HPP\n#define SFML_RECT_HPP\n\n////////////////////////////////////////////////////////////\n// Headers\n////////////////////////////////////////////////////////////\n#include <SFML/System/Vector2.hpp>\n#include <algorithm>\n\n\nnamespace sf\n{\n////////////////////////////////////////////////////////////\n/// \\brief Utility class for manipulating 2D axis aligned rectangles\n///\n////////////////////////////////////////////////////////////\ntemplate <typename T>\nclass Rect\n{\npublic:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Default constructor\n    ///\n    /// Creates an empty rectangle (it is equivalent to calling\n    /// Rect(0, 0, 0, 0)).\n    ///\n    ////////////////////////////////////////////////////////////\n    Rect();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Construct the rectangle from its coordinates\n    ///\n    /// Be careful, the last two parameters are the width\n    /// and height, not the right and bottom coordinates!\n    ///\n    /// \\param rectLeft   Left coordinate of the rectangle\n    /// \\param rectTop    Top coordinate of the rectangle\n    /// \\param rectWidth  Width of the rectangle\n    /// \\param rectHeight Height of the rectangle\n    ///\n    ////////////////////////////////////////////////////////////\n    Rect(T rectLeft, T rectTop, T rectWidth, T rectHeight);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Construct the rectangle from position and size\n    ///\n    /// Be careful, the last parameter is the size,\n    /// not the bottom-right corner!\n    ///\n    /// \\param position Position of the top-left corner of the rectangle\n    /// \\param size     Size of the rectangle\n    ///\n    ////////////////////////////////////////////////////////////\n    Rect(const Vector2<T>& position, const Vector2<T>& size);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Construct the rectangle from another type of rectangle\n    ///\n    /// This constructor doesn't replace the copy constructor,\n    /// it's called only when U != T.\n    /// A call to this constructor will fail to compile if U\n    /// is not convertible to T.\n    ///\n    /// \\param rectangle Rectangle to convert\n    ///\n    ////////////////////////////////////////////////////////////\n    template <typename U>\n    explicit Rect(const Rect<U>& rectangle);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Check if a point is inside the rectangle's area\n    ///\n    /// This check is non-inclusive. If the point lies on the\n    /// edge of the rectangle, this function will return false.\n    ///\n    /// \\param x X coordinate of the point to test\n    /// \\param y Y coordinate of the point to test\n    ///\n    /// \\return True if the point is inside, false otherwise\n    ///\n    /// \\see intersects\n    ///\n    ////////////////////////////////////////////////////////////\n    bool contains(T x, T y) const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Check if a point is inside the rectangle's area\n    ///\n    /// This check is non-inclusive. If the point lies on the\n    /// edge of the rectangle, this function will return false.\n    ///\n    /// \\param point Point to test\n    ///\n    /// \\return True if the point is inside, false otherwise\n    ///\n    /// \\see intersects\n    ///\n    ////////////////////////////////////////////////////////////\n    bool contains(const Vector2<T>& point) const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Check the intersection between two rectangles\n    ///\n    /// \\param rectangle Rectangle to test\n    ///\n    /// \\return True if rectangles overlap, false otherwise\n    ///\n    /// \\see contains\n    ///\n    ////////////////////////////////////////////////////////////\n    bool intersects(const Rect<T>& rectangle) const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Check the intersection between two rectangles\n    ///\n    /// This overload returns the overlapped rectangle in the\n    /// \\a intersection parameter.\n    ///\n    /// \\param rectangle    Rectangle to test\n    /// \\param intersection Rectangle to be filled with the intersection\n    ///\n    /// \\return True if rectangles overlap, false otherwise\n    ///\n    /// \\see contains\n    ///\n    ////////////////////////////////////////////////////////////\n    bool intersects(const Rect<T>& rectangle, Rect<T>& intersection) const;\n\n    ////////////////////////////////////////////////////////////\n    // Member data\n    ////////////////////////////////////////////////////////////\n    T left;   ///< Left coordinate of the rectangle\n    T top;    ///< Top coordinate of the rectangle\n    T width;  ///< Width of the rectangle\n    T height; ///< Height of the rectangle\n};\n\n////////////////////////////////////////////////////////////\n/// \\relates Rect\n/// \\brief Overload of binary operator ==\n///\n/// This operator compares strict equality between two rectangles.\n///\n/// \\param left  Left operand (a rectangle)\n/// \\param right Right operand (a rectangle)\n///\n/// \\return True if \\a left is equal to \\a right\n///\n////////////////////////////////////////////////////////////\ntemplate <typename T>\nbool operator ==(const Rect<T>& left, const Rect<T>& right);\n\n////////////////////////////////////////////////////////////\n/// \\relates Rect\n/// \\brief Overload of binary operator !=\n///\n/// This operator compares strict difference between two rectangles.\n///\n/// \\param left  Left operand (a rectangle)\n/// \\param right Right operand (a rectangle)\n///\n/// \\return True if \\a left is not equal to \\a right\n///\n////////////////////////////////////////////////////////////\ntemplate <typename T>\nbool operator !=(const Rect<T>& left, const Rect<T>& right);\n\n#include <SFML/Graphics/Rect.inl>\n\n// Create typedefs for the most common types\ntypedef Rect<int>   IntRect;\ntypedef Rect<float> FloatRect;\n\n} // namespace sf\n\n\n#endif // SFML_RECT_HPP\n\n\n////////////////////////////////////////////////////////////\n/// \\class sf::Rect\n/// \\ingroup graphics\n///\n/// A rectangle is defined by its top-left corner and its size.\n/// It is a very simple class defined for convenience, so\n/// its member variables (left, top, width and height) are public\n/// and can be accessed directly, just like the vector classes\n/// (Vector2 and Vector3).\n///\n/// To keep things simple, sf::Rect doesn't define\n/// functions to emulate the properties that are not directly\n/// members (such as right, bottom, center, etc.), it rather\n/// only provides intersection functions.\n///\n/// sf::Rect uses the usual rules for its boundaries:\n/// \\li The left and top edges are included in the rectangle's area\n/// \\li The right (left + width) and bottom (top + height) edges are excluded from the rectangle's area\n///\n/// This means that sf::IntRect(0, 0, 1, 1) and sf::IntRect(1, 1, 1, 1)\n/// don't intersect.\n///\n/// sf::Rect is a template and may be used with any numeric type, but\n/// for simplicity the instantiations used by SFML are typedef'd:\n/// \\li sf::Rect<int> is sf::IntRect\n/// \\li sf::Rect<float> is sf::FloatRect\n///\n/// So that you don't have to care about the template syntax.\n///\n/// Usage example:\n/// \\code\n/// // Define a rectangle, located at (0, 0) with a size of 20x5\n/// sf::IntRect r1(0, 0, 20, 5);\n///\n/// // Define another rectangle, located at (4, 2) with a size of 18x10\n/// sf::Vector2i position(4, 2);\n/// sf::Vector2i size(18, 10);\n/// sf::IntRect r2(position, size);\n///\n/// // Test intersections with the point (3, 1)\n/// bool b1 = r1.contains(3, 1); // true\n/// bool b2 = r2.contains(3, 1); // false\n///\n/// // Test the intersection between r1 and r2\n/// sf::IntRect result;\n/// bool b3 = r1.intersects(r2, result); // true\n/// // result == (4, 2, 16, 3)\n/// \\endcode\n///\n////////////////////////////////////////////////////////////\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/Graphics/Rect.inl",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n\n////////////////////////////////////////////////////////////\ntemplate <typename T>\nRect<T>::Rect() :\nleft  (0),\ntop   (0),\nwidth (0),\nheight(0)\n{\n\n}\n\n\n////////////////////////////////////////////////////////////\ntemplate <typename T>\nRect<T>::Rect(T rectLeft, T rectTop, T rectWidth, T rectHeight) :\nleft  (rectLeft),\ntop   (rectTop),\nwidth (rectWidth),\nheight(rectHeight)\n{\n\n}\n\n\n////////////////////////////////////////////////////////////\ntemplate <typename T>\nRect<T>::Rect(const Vector2<T>& position, const Vector2<T>& size) :\nleft  (position.x),\ntop   (position.y),\nwidth (size.x),\nheight(size.y)\n{\n\n}\n\n\n////////////////////////////////////////////////////////////\ntemplate <typename T>\ntemplate <typename U>\nRect<T>::Rect(const Rect<U>& rectangle) :\nleft  (static_cast<T>(rectangle.left)),\ntop   (static_cast<T>(rectangle.top)),\nwidth (static_cast<T>(rectangle.width)),\nheight(static_cast<T>(rectangle.height))\n{\n}\n\n\n////////////////////////////////////////////////////////////\ntemplate <typename T>\nbool Rect<T>::contains(T x, T y) const\n{\n    // Rectangles with negative dimensions are allowed, so we must handle them correctly\n\n    // Compute the real min and max of the rectangle on both axes\n    T minX = std::min(left, static_cast<T>(left + width));\n    T maxX = std::max(left, static_cast<T>(left + width));\n    T minY = std::min(top, static_cast<T>(top + height));\n    T maxY = std::max(top, static_cast<T>(top + height));\n\n    return (x >= minX) && (x < maxX) && (y >= minY) && (y < maxY);\n}\n\n\n////////////////////////////////////////////////////////////\ntemplate <typename T>\nbool Rect<T>::contains(const Vector2<T>& point) const\n{\n    return contains(point.x, point.y);\n}\n\n\n////////////////////////////////////////////////////////////\ntemplate <typename T>\nbool Rect<T>::intersects(const Rect<T>& rectangle) const\n{\n    Rect<T> intersection;\n    return intersects(rectangle, intersection);\n}\n\n\n////////////////////////////////////////////////////////////\ntemplate <typename T>\nbool Rect<T>::intersects(const Rect<T>& rectangle, Rect<T>& intersection) const\n{\n    // Rectangles with negative dimensions are allowed, so we must handle them correctly\n\n    // Compute the min and max of the first rectangle on both axes\n    T r1MinX = std::min(left, static_cast<T>(left + width));\n    T r1MaxX = std::max(left, static_cast<T>(left + width));\n    T r1MinY = std::min(top, static_cast<T>(top + height));\n    T r1MaxY = std::max(top, static_cast<T>(top + height));\n\n    // Compute the min and max of the second rectangle on both axes\n    T r2MinX = std::min(rectangle.left, static_cast<T>(rectangle.left + rectangle.width));\n    T r2MaxX = std::max(rectangle.left, static_cast<T>(rectangle.left + rectangle.width));\n    T r2MinY = std::min(rectangle.top, static_cast<T>(rectangle.top + rectangle.height));\n    T r2MaxY = std::max(rectangle.top, static_cast<T>(rectangle.top + rectangle.height));\n\n    // Compute the intersection boundaries\n    T interLeft   = std::max(r1MinX, r2MinX);\n    T interTop    = std::max(r1MinY, r2MinY);\n    T interRight  = std::min(r1MaxX, r2MaxX);\n    T interBottom = std::min(r1MaxY, r2MaxY);\n\n    // If the intersection is valid (positive non zero area), then there is an intersection\n    if ((interLeft < interRight) && (interTop < interBottom))\n    {\n        intersection = Rect<T>(interLeft, interTop, interRight - interLeft, interBottom - interTop);\n        return true;\n    }\n    else\n    {\n        intersection = Rect<T>(0, 0, 0, 0);\n        return false;\n    }\n}\n\n\n////////////////////////////////////////////////////////////\ntemplate <typename T>\ninline bool operator ==(const Rect<T>& left, const Rect<T>& right)\n{\n    return (left.left == right.left) && (left.width == right.width) &&\n           (left.top == right.top) && (left.height == right.height);\n}\n\n\n////////////////////////////////////////////////////////////\ntemplate <typename T>\ninline bool operator !=(const Rect<T>& left, const Rect<T>& right)\n{\n    return !(left == right);\n}\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/Graphics/RectangleShape.hpp",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n#ifndef SFML_RECTANGLESHAPE_HPP\n#define SFML_RECTANGLESHAPE_HPP\n\n////////////////////////////////////////////////////////////\n// Headers\n////////////////////////////////////////////////////////////\n#include <SFML/Graphics/Export.hpp>\n#include <SFML/Graphics/Shape.hpp>\n\n\nnamespace sf\n{\n////////////////////////////////////////////////////////////\n/// \\brief Specialized shape representing a rectangle\n///\n////////////////////////////////////////////////////////////\nclass SFML_GRAPHICS_API RectangleShape : public Shape\n{\npublic:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Default constructor\n    ///\n    /// \\param size Size of the rectangle\n    ///\n    ////////////////////////////////////////////////////////////\n    explicit RectangleShape(const Vector2f& size = Vector2f(0, 0));\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Set the size of the rectangle\n    ///\n    /// \\param size New size of the rectangle\n    ///\n    /// \\see getSize\n    ///\n    ////////////////////////////////////////////////////////////\n    void setSize(const Vector2f& size);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the size of the rectangle\n    ///\n    /// \\return Size of the rectangle\n    ///\n    /// \\see setSize\n    ///\n    ////////////////////////////////////////////////////////////\n    const Vector2f& getSize() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the number of points defining the shape\n    ///\n    /// \\return Number of points of the shape. For rectangle\n    ///         shapes, this number is always 4.\n    ///\n    ////////////////////////////////////////////////////////////\n    virtual std::size_t getPointCount() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get a point of the rectangle\n    ///\n    /// The returned point is in local coordinates, that is,\n    /// the shape's transforms (position, rotation, scale) are\n    /// not taken into account.\n    /// The result is undefined if \\a index is out of the valid range.\n    ///\n    /// \\param index Index of the point to get, in range [0 .. 3]\n    ///\n    /// \\return index-th point of the shape\n    ///\n    ////////////////////////////////////////////////////////////\n    virtual Vector2f getPoint(std::size_t index) const;\n\nprivate:\n\n    ////////////////////////////////////////////////////////////\n    // Member data\n    ////////////////////////////////////////////////////////////\n    Vector2f m_size; ///< Size of the rectangle\n};\n\n} // namespace sf\n\n\n#endif // SFML_RECTANGLESHAPE_HPP\n\n\n////////////////////////////////////////////////////////////\n/// \\class sf::RectangleShape\n/// \\ingroup graphics\n///\n/// This class inherits all the functions of sf::Transformable\n/// (position, rotation, scale, bounds, ...) as well as the\n/// functions of sf::Shape (outline, color, texture, ...).\n///\n/// Usage example:\n/// \\code\n/// sf::RectangleShape rectangle;\n/// rectangle.setSize(sf::Vector2f(100, 50));\n/// rectangle.setOutlineColor(sf::Color::Red);\n/// rectangle.setOutlineThickness(5);\n/// rectangle.setPosition(10, 20);\n/// ...\n/// window.draw(rectangle);\n/// \\endcode\n///\n/// \\see sf::Shape, sf::CircleShape, sf::ConvexShape\n///\n////////////////////////////////////////////////////////////\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/Graphics/RenderStates.hpp",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n#ifndef SFML_RENDERSTATES_HPP\n#define SFML_RENDERSTATES_HPP\n\n////////////////////////////////////////////////////////////\n// Headers\n////////////////////////////////////////////////////////////\n#include <SFML/Graphics/Export.hpp>\n#include <SFML/Graphics/BlendMode.hpp>\n#include <SFML/Graphics/Transform.hpp>\n\n\nnamespace sf\n{\nclass Shader;\nclass Texture;\n\n////////////////////////////////////////////////////////////\n/// \\brief Define the states used for drawing to a RenderTarget\n///\n////////////////////////////////////////////////////////////\nclass SFML_GRAPHICS_API RenderStates\n{\npublic:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Default constructor\n    ///\n    /// Constructing a default set of render states is equivalent\n    /// to using sf::RenderStates::Default.\n    /// The default set defines:\n    /// \\li the BlendAlpha blend mode\n    /// \\li the identity transform\n    /// \\li a null texture\n    /// \\li a null shader\n    ///\n    ////////////////////////////////////////////////////////////\n    RenderStates();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Construct a default set of render states with a custom blend mode\n    ///\n    /// \\param theBlendMode Blend mode to use\n    ///\n    ////////////////////////////////////////////////////////////\n    RenderStates(const BlendMode& theBlendMode);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Construct a default set of render states with a custom transform\n    ///\n    /// \\param theTransform Transform to use\n    ///\n    ////////////////////////////////////////////////////////////\n    RenderStates(const Transform& theTransform);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Construct a default set of render states with a custom texture\n    ///\n    /// \\param theTexture Texture to use\n    ///\n    ////////////////////////////////////////////////////////////\n    RenderStates(const Texture* theTexture);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Construct a default set of render states with a custom shader\n    ///\n    /// \\param theShader Shader to use\n    ///\n    ////////////////////////////////////////////////////////////\n    RenderStates(const Shader* theShader);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Construct a set of render states with all its attributes\n    ///\n    /// \\param theBlendMode Blend mode to use\n    /// \\param theTransform Transform to use\n    /// \\param theTexture   Texture to use\n    /// \\param theShader    Shader to use\n    ///\n    ////////////////////////////////////////////////////////////\n    RenderStates(const BlendMode& theBlendMode, const Transform& theTransform,\n                 const Texture* theTexture, const Shader* theShader);\n\n    ////////////////////////////////////////////////////////////\n    // Static member data\n    ////////////////////////////////////////////////////////////\n    static const RenderStates Default; ///< Special instance holding the default render states\n\n    ////////////////////////////////////////////////////////////\n    // Member data\n    ////////////////////////////////////////////////////////////\n    BlendMode      blendMode; ///< Blending mode\n    Transform      transform; ///< Transform\n    const Texture* texture;   ///< Texture\n    const Shader*  shader;    ///< Shader\n};\n\n} // namespace sf\n\n\n#endif // SFML_RENDERSTATES_HPP\n\n\n////////////////////////////////////////////////////////////\n/// \\class sf::RenderStates\n/// \\ingroup graphics\n///\n/// There are four global states that can be applied to\n/// the drawn objects:\n/// \\li the blend mode: how pixels of the object are blended with the background\n/// \\li the transform: how the object is positioned/rotated/scaled\n/// \\li the texture: what image is mapped to the object\n/// \\li the shader: what custom effect is applied to the object\n///\n/// High-level objects such as sprites or text force some of\n/// these states when they are drawn. For example, a sprite\n/// will set its own texture, so that you don't have to care\n/// about it when drawing the sprite.\n///\n/// The transform is a special case: sprites, texts and shapes\n/// (and it's a good idea to do it with your own drawable classes\n/// too) combine their transform with the one that is passed in the\n/// RenderStates structure. So that you can use a \"global\" transform\n/// on top of each object's transform.\n///\n/// Most objects, especially high-level drawables, can be drawn\n/// directly without defining render states explicitly -- the\n/// default set of states is ok in most cases.\n/// \\code\n/// window.draw(sprite);\n/// \\endcode\n///\n/// If you want to use a single specific render state,\n/// for example a shader, you can pass it directly to the Draw\n/// function: sf::RenderStates has an implicit one-argument\n/// constructor for each state.\n/// \\code\n/// window.draw(sprite, shader);\n/// \\endcode\n///\n/// When you're inside the Draw function of a drawable\n/// object (inherited from sf::Drawable), you can\n/// either pass the render states unmodified, or change\n/// some of them.\n/// For example, a transformable object will combine the\n/// current transform with its own transform. A sprite will\n/// set its texture. Etc.\n///\n/// \\see sf::RenderTarget, sf::Drawable\n///\n////////////////////////////////////////////////////////////\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/Graphics/RenderTarget.hpp",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n#ifndef SFML_RENDERTARGET_HPP\n#define SFML_RENDERTARGET_HPP\n\n////////////////////////////////////////////////////////////\n// Headers\n////////////////////////////////////////////////////////////\n#include <SFML/Graphics/Export.hpp>\n#include <SFML/Graphics/Color.hpp>\n#include <SFML/Graphics/Rect.hpp>\n#include <SFML/Graphics/View.hpp>\n#include <SFML/Graphics/Transform.hpp>\n#include <SFML/Graphics/BlendMode.hpp>\n#include <SFML/Graphics/RenderStates.hpp>\n#include <SFML/Graphics/PrimitiveType.hpp>\n#include <SFML/Graphics/Vertex.hpp>\n#include <SFML/System/NonCopyable.hpp>\n\n\nnamespace sf\n{\nclass Drawable;\n\n////////////////////////////////////////////////////////////\n/// \\brief Base class for all render targets (window, texture, ...)\n///\n////////////////////////////////////////////////////////////\nclass SFML_GRAPHICS_API RenderTarget : NonCopyable\n{\npublic:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Destructor\n    ///\n    ////////////////////////////////////////////////////////////\n    virtual ~RenderTarget();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Clear the entire target with a single color\n    ///\n    /// This function is usually called once every frame,\n    /// to clear the previous contents of the target.\n    ///\n    /// \\param color Fill color to use to clear the render target\n    ///\n    ////////////////////////////////////////////////////////////\n    void clear(const Color& color = Color(0, 0, 0, 255));\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Change the current active view\n    ///\n    /// The view is like a 2D camera, it controls which part of\n    /// the 2D scene is visible, and how it is viewed in the\n    /// render target.\n    /// The new view will affect everything that is drawn, until\n    /// another view is set.\n    /// The render target keeps its own copy of the view object,\n    /// so it is not necessary to keep the original one alive\n    /// after calling this function.\n    /// To restore the original view of the target, you can pass\n    /// the result of getDefaultView() to this function.\n    ///\n    /// \\param view New view to use\n    ///\n    /// \\see getView, getDefaultView\n    ///\n    ////////////////////////////////////////////////////////////\n    void setView(const View& view);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the view currently in use in the render target\n    ///\n    /// \\return The view object that is currently used\n    ///\n    /// \\see setView, getDefaultView\n    ///\n    ////////////////////////////////////////////////////////////\n    const View& getView() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the default view of the render target\n    ///\n    /// The default view has the initial size of the render target,\n    /// and never changes after the target has been created.\n    ///\n    /// \\return The default view of the render target\n    ///\n    /// \\see setView, getView\n    ///\n    ////////////////////////////////////////////////////////////\n    const View& getDefaultView() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the viewport of a view, applied to this render target\n    ///\n    /// The viewport is defined in the view as a ratio, this function\n    /// simply applies this ratio to the current dimensions of the\n    /// render target to calculate the pixels rectangle that the viewport\n    /// actually covers in the target.\n    ///\n    /// \\param view The view for which we want to compute the viewport\n    ///\n    /// \\return Viewport rectangle, expressed in pixels\n    ///\n    ////////////////////////////////////////////////////////////\n    IntRect getViewport(const View& view) const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Convert a point from target coordinates to world\n    ///        coordinates, using the current view\n    ///\n    /// This function is an overload of the mapPixelToCoords\n    /// function that implicitly uses the current view.\n    /// It is equivalent to:\n    /// \\code\n    /// target.mapPixelToCoords(point, target.getView());\n    /// \\endcode\n    ///\n    /// \\param point Pixel to convert\n    ///\n    /// \\return The converted point, in \"world\" coordinates\n    ///\n    /// \\see mapCoordsToPixel\n    ///\n    ////////////////////////////////////////////////////////////\n    Vector2f mapPixelToCoords(const Vector2i& point) const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Convert a point from target coordinates to world coordinates\n    ///\n    /// This function finds the 2D position that matches the\n    /// given pixel of the render target. In other words, it does\n    /// the inverse of what the graphics card does, to find the\n    /// initial position of a rendered pixel.\n    ///\n    /// Initially, both coordinate systems (world units and target pixels)\n    /// match perfectly. But if you define a custom view or resize your\n    /// render target, this assertion is not true anymore, i.e. a point\n    /// located at (10, 50) in your render target may map to the point\n    /// (150, 75) in your 2D world -- if the view is translated by (140, 25).\n    ///\n    /// For render-windows, this function is typically used to find\n    /// which point (or object) is located below the mouse cursor.\n    ///\n    /// This version uses a custom view for calculations, see the other\n    /// overload of the function if you want to use the current view of the\n    /// render target.\n    ///\n    /// \\param point Pixel to convert\n    /// \\param view The view to use for converting the point\n    ///\n    /// \\return The converted point, in \"world\" units\n    ///\n    /// \\see mapCoordsToPixel\n    ///\n    ////////////////////////////////////////////////////////////\n    Vector2f mapPixelToCoords(const Vector2i& point, const View& view) const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Convert a point from world coordinates to target\n    ///        coordinates, using the current view\n    ///\n    /// This function is an overload of the mapCoordsToPixel\n    /// function that implicitly uses the current view.\n    /// It is equivalent to:\n    /// \\code\n    /// target.mapCoordsToPixel(point, target.getView());\n    /// \\endcode\n    ///\n    /// \\param point Point to convert\n    ///\n    /// \\return The converted point, in target coordinates (pixels)\n    ///\n    /// \\see mapPixelToCoords\n    ///\n    ////////////////////////////////////////////////////////////\n    Vector2i mapCoordsToPixel(const Vector2f& point) const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Convert a point from world coordinates to target coordinates\n    ///\n    /// This function finds the pixel of the render target that matches\n    /// the given 2D point. In other words, it goes through the same process\n    /// as the graphics card, to compute the final position of a rendered point.\n    ///\n    /// Initially, both coordinate systems (world units and target pixels)\n    /// match perfectly. But if you define a custom view or resize your\n    /// render target, this assertion is not true anymore, i.e. a point\n    /// located at (150, 75) in your 2D world may map to the pixel\n    /// (10, 50) of your render target -- if the view is translated by (140, 25).\n    ///\n    /// This version uses a custom view for calculations, see the other\n    /// overload of the function if you want to use the current view of the\n    /// render target.\n    ///\n    /// \\param point Point to convert\n    /// \\param view The view to use for converting the point\n    ///\n    /// \\return The converted point, in target coordinates (pixels)\n    ///\n    /// \\see mapPixelToCoords\n    ///\n    ////////////////////////////////////////////////////////////\n    Vector2i mapCoordsToPixel(const Vector2f& point, const View& view) const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Draw a drawable object to the render target\n    ///\n    /// \\param drawable Object to draw\n    /// \\param states   Render states to use for drawing\n    ///\n    ////////////////////////////////////////////////////////////\n    void draw(const Drawable& drawable, const RenderStates& states = RenderStates::Default);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Draw primitives defined by an array of vertices\n    ///\n    /// \\param vertices    Pointer to the vertices\n    /// \\param vertexCount Number of vertices in the array\n    /// \\param type        Type of primitives to draw\n    /// \\param states      Render states to use for drawing\n    ///\n    ////////////////////////////////////////////////////////////\n    void draw(const Vertex* vertices, std::size_t vertexCount,\n              PrimitiveType type, const RenderStates& states = RenderStates::Default);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Return the size of the rendering region of the target\n    ///\n    /// \\return Size in pixels\n    ///\n    ////////////////////////////////////////////////////////////\n    virtual Vector2u getSize() const = 0;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Save the current OpenGL render states and matrices\n    ///\n    /// This function can be used when you mix SFML drawing\n    /// and direct OpenGL rendering. Combined with popGLStates,\n    /// it ensures that:\n    /// \\li SFML's internal states are not messed up by your OpenGL code\n    /// \\li your OpenGL states are not modified by a call to a SFML function\n    ///\n    /// More specifically, it must be used around code that\n    /// calls Draw functions. Example:\n    /// \\code\n    /// // OpenGL code here...\n    /// window.pushGLStates();\n    /// window.draw(...);\n    /// window.draw(...);\n    /// window.popGLStates();\n    /// // OpenGL code here...\n    /// \\endcode\n    ///\n    /// Note that this function is quite expensive: it saves all the\n    /// possible OpenGL states and matrices, even the ones you\n    /// don't care about. Therefore it should be used wisely.\n    /// It is provided for convenience, but the best results will\n    /// be achieved if you handle OpenGL states yourself (because\n    /// you know which states have really changed, and need to be\n    /// saved and restored). Take a look at the resetGLStates\n    /// function if you do so.\n    ///\n    /// \\see popGLStates\n    ///\n    ////////////////////////////////////////////////////////////\n    void pushGLStates();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Restore the previously saved OpenGL render states and matrices\n    ///\n    /// See the description of pushGLStates to get a detailed\n    /// description of these functions.\n    ///\n    /// \\see pushGLStates\n    ///\n    ////////////////////////////////////////////////////////////\n    void popGLStates();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Reset the internal OpenGL states so that the target is ready for drawing\n    ///\n    /// This function can be used when you mix SFML drawing\n    /// and direct OpenGL rendering, if you choose not to use\n    /// pushGLStates/popGLStates. It makes sure that all OpenGL\n    /// states needed by SFML are set, so that subsequent draw()\n    /// calls will work as expected.\n    ///\n    /// Example:\n    /// \\code\n    /// // OpenGL code here...\n    /// glPushAttrib(...);\n    /// window.resetGLStates();\n    /// window.draw(...);\n    /// window.draw(...);\n    /// glPopAttrib(...);\n    /// // OpenGL code here...\n    /// \\endcode\n    ///\n    ////////////////////////////////////////////////////////////\n    void resetGLStates();\n\nprotected:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Default constructor\n    ///\n    ////////////////////////////////////////////////////////////\n    RenderTarget();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Performs the common initialization step after creation\n    ///\n    /// The derived classes must call this function after the\n    /// target is created and ready for drawing.\n    ///\n    ////////////////////////////////////////////////////////////\n    void initialize();\n\nprivate:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Apply the current view\n    ///\n    ////////////////////////////////////////////////////////////\n    void applyCurrentView();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Apply a new blending mode\n    ///\n    /// \\param mode Blending mode to apply\n    ///\n    ////////////////////////////////////////////////////////////\n    void applyBlendMode(const BlendMode& mode);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Apply a new transform\n    ///\n    /// \\param transform Transform to apply\n    ///\n    ////////////////////////////////////////////////////////////\n    void applyTransform(const Transform& transform);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Apply a new texture\n    ///\n    /// \\param texture Texture to apply\n    ///\n    ////////////////////////////////////////////////////////////\n    void applyTexture(const Texture* texture);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Apply a new shader\n    ///\n    /// \\param shader Shader to apply\n    ///\n    ////////////////////////////////////////////////////////////\n    void applyShader(const Shader* shader);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Activate the target for rendering\n    ///\n    /// This function must be implemented by derived classes to make\n    /// their OpenGL context current; it is called by the base class\n    /// everytime it's going to use OpenGL calls.\n    ///\n    /// \\param active True to make the target active, false to deactivate it\n    ///\n    /// \\return True if the function succeeded\n    ///\n    ////////////////////////////////////////////////////////////\n    virtual bool activate(bool active) = 0;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Render states cache\n    ///\n    ////////////////////////////////////////////////////////////\n    struct StatesCache\n    {\n        enum {VertexCacheSize = 4};\n\n        bool      glStatesSet;    ///< Are our internal GL states set yet?\n        bool      viewChanged;    ///< Has the current view changed since last draw?\n        BlendMode lastBlendMode;  ///< Cached blending mode\n        Uint64    lastTextureId;  ///< Cached texture\n        bool      useVertexCache; ///< Did we previously use the vertex cache?\n        Vertex    vertexCache[VertexCacheSize]; ///< Pre-transformed vertices cache\n    };\n\n    ////////////////////////////////////////////////////////////\n    // Member data\n    ////////////////////////////////////////////////////////////\n    View        m_defaultView; ///< Default view\n    View        m_view;        ///< Current view\n    StatesCache m_cache;       ///< Render states cache\n};\n\n} // namespace sf\n\n\n#endif // SFML_RENDERTARGET_HPP\n\n\n////////////////////////////////////////////////////////////\n/// \\class sf::RenderTarget\n/// \\ingroup graphics\n///\n/// sf::RenderTarget defines the common behavior of all the\n/// 2D render targets usable in the graphics module. It makes\n/// it possible to draw 2D entities like sprites, shapes, text\n/// without using any OpenGL command directly.\n///\n/// A sf::RenderTarget is also able to use views (sf::View),\n/// which are a kind of 2D cameras. With views you can globally\n/// scroll, rotate or zoom everything that is drawn,\n/// without having to transform every single entity. See the\n/// documentation of sf::View for more details and sample pieces of\n/// code about this class.\n///\n/// On top of that, render targets are still able to render direct\n/// OpenGL stuff. It is even possible to mix together OpenGL calls\n/// and regular SFML drawing commands. When doing so, make sure that\n/// OpenGL states are not messed up by calling the\n/// pushGLStates/popGLStates functions.\n///\n/// \\see sf::RenderWindow, sf::RenderTexture, sf::View\n///\n////////////////////////////////////////////////////////////\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/Graphics/RenderTexture.hpp",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n#ifndef SFML_RENDERTEXTURE_HPP\n#define SFML_RENDERTEXTURE_HPP\n\n////////////////////////////////////////////////////////////\n// Headers\n////////////////////////////////////////////////////////////\n#include <SFML/Graphics/Export.hpp>\n#include <SFML/Graphics/Texture.hpp>\n#include <SFML/Graphics/RenderTarget.hpp>\n\n\nnamespace sf\n{\nnamespace priv\n{\n    class RenderTextureImpl;\n}\n\n////////////////////////////////////////////////////////////\n/// \\brief Target for off-screen 2D rendering into a texture\n///\n////////////////////////////////////////////////////////////\nclass SFML_GRAPHICS_API RenderTexture : public RenderTarget\n{\npublic:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Default constructor\n    ///\n    /// Constructs an empty, invalid render-texture. You must\n    /// call create to have a valid render-texture.\n    ///\n    /// \\see create\n    ///\n    ////////////////////////////////////////////////////////////\n    RenderTexture();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Destructor\n    ///\n    ////////////////////////////////////////////////////////////\n    virtual ~RenderTexture();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Create the render-texture\n    ///\n    /// Before calling this function, the render-texture is in\n    /// an invalid state, thus it is mandatory to call it before\n    /// doing anything with the render-texture.\n    /// The last parameter, \\a depthBuffer, is useful if you want\n    /// to use the render-texture for 3D OpenGL rendering that requires\n    /// a depth buffer. Otherwise it is unnecessary, and you should\n    /// leave this parameter to false (which is its default value).\n    ///\n    /// \\param width       Width of the render-texture\n    /// \\param height      Height of the render-texture\n    /// \\param depthBuffer Do you want this render-texture to have a depth buffer?\n    ///\n    /// \\return True if creation has been successful\n    ///\n    ////////////////////////////////////////////////////////////\n    bool create(unsigned int width, unsigned int height, bool depthBuffer = false);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Enable or disable texture smoothing\n    ///\n    /// This function is similar to Texture::setSmooth.\n    /// This parameter is disabled by default.\n    ///\n    /// \\param smooth True to enable smoothing, false to disable it\n    ///\n    /// \\see isSmooth\n    ///\n    ////////////////////////////////////////////////////////////\n    void setSmooth(bool smooth);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Tell whether the smooth filtering is enabled or not\n    ///\n    /// \\return True if texture smoothing is enabled\n    ///\n    /// \\see setSmooth\n    ///\n    ////////////////////////////////////////////////////////////\n    bool isSmooth() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Enable or disable texture repeating\n    ///\n    /// This function is similar to Texture::setRepeated.\n    /// This parameter is disabled by default.\n    ///\n    /// \\param repeated True to enable repeating, false to disable it\n    ///\n    /// \\see isRepeated\n    ///\n    ////////////////////////////////////////////////////////////\n    void setRepeated(bool repeated);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Tell whether the texture is repeated or not\n    ///\n    /// \\return True if texture is repeated\n    ///\n    /// \\see setRepeated\n    ///\n    ////////////////////////////////////////////////////////////\n    bool isRepeated() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Generate a mipmap using the current texture data\n    ///\n    /// This function is similar to Texture::generateMipmap and operates\n    /// on the texture used as the target for drawing.\n    /// Be aware that any draw operation may modify the base level image data.\n    /// For this reason, calling this function only makes sense after all\n    /// drawing is completed and display has been called. Not calling display\n    /// after subsequent drawing will lead to undefined behavior if a mipmap\n    /// had been previously generated.\n    ///\n    /// \\return True if mipmap generation was successful, false if unsuccessful\n    ///\n    ////////////////////////////////////////////////////////////\n    bool generateMipmap();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Activate or deactivate the render-texture for rendering\n    ///\n    /// This function makes the render-texture's context current for\n    /// future OpenGL rendering operations (so you shouldn't care\n    /// about it if you're not doing direct OpenGL stuff).\n    /// Only one context can be current in a thread, so if you\n    /// want to draw OpenGL geometry to another render target\n    /// (like a RenderWindow) don't forget to activate it again.\n    ///\n    /// \\param active True to activate, false to deactivate\n    ///\n    /// \\return True if operation was successful, false otherwise\n    ///\n    ////////////////////////////////////////////////////////////\n    bool setActive(bool active = true);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Update the contents of the target texture\n    ///\n    /// This function updates the target texture with what\n    /// has been drawn so far. Like for windows, calling this\n    /// function is mandatory at the end of rendering. Not calling\n    /// it may leave the texture in an undefined state.\n    ///\n    ////////////////////////////////////////////////////////////\n    void display();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Return the size of the rendering region of the texture\n    ///\n    /// The returned value is the size that you passed to\n    /// the create function.\n    ///\n    /// \\return Size in pixels\n    ///\n    ////////////////////////////////////////////////////////////\n    virtual Vector2u getSize() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get a read-only reference to the target texture\n    ///\n    /// After drawing to the render-texture and calling Display,\n    /// you can retrieve the updated texture using this function,\n    /// and draw it using a sprite (for example).\n    /// The internal sf::Texture of a render-texture is always the\n    /// same instance, so that it is possible to call this function\n    /// once and keep a reference to the texture even after it is\n    /// modified.\n    ///\n    /// \\return Const reference to the texture\n    ///\n    ////////////////////////////////////////////////////////////\n    const Texture& getTexture() const;\n\nprivate:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Activate the target for rendering\n    ///\n    /// This function is called by the base class\n    /// everytime it's going to use OpenGL calls.\n    ///\n    /// \\param active True to make the target active, false to deactivate it\n    ///\n    /// \\return True if the function succeeded\n    ///\n    ////////////////////////////////////////////////////////////\n    virtual bool activate(bool active);\n\n    ////////////////////////////////////////////////////////////\n    // Member data\n    ////////////////////////////////////////////////////////////\n    priv::RenderTextureImpl* m_impl;    ///< Platform/hardware specific implementation\n    Texture                  m_texture; ///< Target texture to draw on\n};\n\n} // namespace sf\n\n\n#endif // SFML_RENDERTEXTURE_HPP\n\n\n////////////////////////////////////////////////////////////\n/// \\class sf::RenderTexture\n/// \\ingroup graphics\n///\n/// sf::RenderTexture is the little brother of sf::RenderWindow.\n/// It implements the same 2D drawing and OpenGL-related functions\n/// (see their base class sf::RenderTarget for more details),\n/// the difference is that the result is stored in an off-screen\n/// texture rather than being show in a window.\n///\n/// Rendering to a texture can be useful in a variety of situations:\n/// \\li precomputing a complex static texture (like a level's background from multiple tiles)\n/// \\li applying post-effects to the whole scene with shaders\n/// \\li creating a sprite from a 3D object rendered with OpenGL\n/// \\li etc.\n///\n/// Usage example:\n///\n/// \\code\n/// // Create a new render-window\n/// sf::RenderWindow window(sf::VideoMode(800, 600), \"SFML window\");\n///\n/// // Create a new render-texture\n/// sf::RenderTexture texture;\n/// if (!texture.create(500, 500))\n///     return -1;\n///\n/// // The main loop\n/// while (window.isOpen())\n/// {\n///    // Event processing\n///    // ...\n///\n///    // Clear the whole texture with red color\n///    texture.clear(sf::Color::Red);\n///\n///    // Draw stuff to the texture\n///    texture.draw(sprite);  // sprite is a sf::Sprite\n///    texture.draw(shape);   // shape is a sf::Shape\n///    texture.draw(text);    // text is a sf::Text\n///\n///    // We're done drawing to the texture\n///    texture.display();\n///\n///    // Now we start rendering to the window, clear it first\n///    window.clear();\n///\n///    // Draw the texture\n///    sf::Sprite sprite(texture.getTexture());\n///    window.draw(sprite);\n///\n///    // End the current frame and display its contents on screen\n///    window.display();\n/// }\n/// \\endcode\n///\n/// Like sf::RenderWindow, sf::RenderTexture is still able to render direct\n/// OpenGL stuff. It is even possible to mix together OpenGL calls\n/// and regular SFML drawing commands. If you need a depth buffer for\n/// 3D rendering, don't forget to request it when calling RenderTexture::create.\n///\n/// \\see sf::RenderTarget, sf::RenderWindow, sf::View, sf::Texture\n///\n////////////////////////////////////////////////////////////\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/Graphics/RenderWindow.hpp",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n#ifndef SFML_RENDERWINDOW_HPP\n#define SFML_RENDERWINDOW_HPP\n\n////////////////////////////////////////////////////////////\n// Headers\n////////////////////////////////////////////////////////////\n#include <SFML/Graphics/Export.hpp>\n#include <SFML/Graphics/RenderTarget.hpp>\n#include <SFML/Graphics/Image.hpp>\n#include <SFML/Window/Window.hpp>\n#include <string>\n\n\nnamespace sf\n{\n////////////////////////////////////////////////////////////\n/// \\brief Window that can serve as a target for 2D drawing\n///\n////////////////////////////////////////////////////////////\nclass SFML_GRAPHICS_API RenderWindow : public Window, public RenderTarget\n{\npublic:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Default constructor\n    ///\n    /// This constructor doesn't actually create the window,\n    /// use the other constructors or call create() to do so.\n    ///\n    ////////////////////////////////////////////////////////////\n    RenderWindow();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Construct a new window\n    ///\n    /// This constructor creates the window with the size and pixel\n    /// depth defined in \\a mode. An optional style can be passed to\n    /// customize the look and behavior of the window (borders,\n    /// title bar, resizable, closable, ...).\n    ///\n    /// The fourth parameter is an optional structure specifying\n    /// advanced OpenGL context settings such as antialiasing,\n    /// depth-buffer bits, etc. You shouldn't care about these\n    /// parameters for a regular usage of the graphics module.\n    ///\n    /// \\param mode     Video mode to use (defines the width, height and depth of the rendering area of the window)\n    /// \\param title    Title of the window\n    /// \\param style    %Window style, a bitwise OR combination of sf::Style enumerators\n    /// \\param settings Additional settings for the underlying OpenGL context\n    ///\n    ////////////////////////////////////////////////////////////\n    RenderWindow(VideoMode mode, const String& title, Uint32 style = Style::Default, const ContextSettings& settings = ContextSettings());\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Construct the window from an existing control\n    ///\n    /// Use this constructor if you want to create an SFML\n    /// rendering area into an already existing control.\n    ///\n    /// The second parameter is an optional structure specifying\n    /// advanced OpenGL context settings such as antialiasing,\n    /// depth-buffer bits, etc. You shouldn't care about these\n    /// parameters for a regular usage of the graphics module.\n    ///\n    /// \\param handle   Platform-specific handle of the control (\\a HWND on\n    ///                 Windows, \\a %Window on Linux/FreeBSD, \\a NSWindow on OS X)\n    /// \\param settings Additional settings for the underlying OpenGL context\n    ///\n    ////////////////////////////////////////////////////////////\n    explicit RenderWindow(WindowHandle handle, const ContextSettings& settings = ContextSettings());\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Destructor\n    ///\n    /// Closes the window and frees all the resources attached to it.\n    ///\n    ////////////////////////////////////////////////////////////\n    virtual ~RenderWindow();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the size of the rendering region of the window\n    ///\n    /// The size doesn't include the titlebar and borders\n    /// of the window.\n    ///\n    /// \\return Size in pixels\n    ///\n    ////////////////////////////////////////////////////////////\n    virtual Vector2u getSize() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Copy the current contents of the window to an image\n    ///\n    /// \\deprecated\n    /// Use a sf::Texture and its sf::Texture::update(const Window&)\n    /// function and copy its contents into an sf::Image instead.\n    /// \\code\n    /// sf::Vector2u windowSize = window.getSize();\n    /// sf::Texture texture;\n    /// texture.create(windowSize.x, windowSize.y);\n    /// texture.update(window);\n    /// sf::Image screenshot = texture.copyToImage();\n    /// \\endcode\n    ///\n    /// This is a slow operation, whose main purpose is to make\n    /// screenshots of the application. If you want to update an\n    /// image with the contents of the window and then use it for\n    /// drawing, you should rather use a sf::Texture and its\n    /// update(Window&) function.\n    /// You can also draw things directly to a texture with the\n    /// sf::RenderTexture class.\n    ///\n    /// \\return Image containing the captured contents\n    ///\n    ////////////////////////////////////////////////////////////\n    SFML_DEPRECATED Image capture() const;\n\nprotected:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Function called after the window has been created\n    ///\n    /// This function is called so that derived classes can\n    /// perform their own specific initialization as soon as\n    /// the window is created.\n    ///\n    ////////////////////////////////////////////////////////////\n    virtual void onCreate();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Function called after the window has been resized\n    ///\n    /// This function is called so that derived classes can\n    /// perform custom actions when the size of the window changes.\n    ///\n    ////////////////////////////////////////////////////////////\n    virtual void onResize();\n\nprivate:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Activate the target for rendering\n    ///\n    /// \\param active True to make the target active, false to deactivate it\n    ///\n    /// \\return True if the function succeeded\n    ///\n    ////////////////////////////////////////////////////////////\n    virtual bool activate(bool active);\n};\n\n} // namespace sf\n\n\n#endif // SFML_RENDERWINDOW_HPP\n\n\n////////////////////////////////////////////////////////////\n/// \\class sf::RenderWindow\n/// \\ingroup graphics\n///\n/// sf::RenderWindow is the main class of the Graphics module.\n/// It defines an OS window that can be painted using the other\n/// classes of the graphics module.\n///\n/// sf::RenderWindow is derived from sf::Window, thus it inherits\n/// all its features: events, window management, OpenGL rendering,\n/// etc. See the documentation of sf::Window for a more complete\n/// description of all these features, as well as code examples.\n///\n/// On top of that, sf::RenderWindow adds more features related to\n/// 2D drawing with the graphics module (see its base class\n/// sf::RenderTarget for more details).\n/// Here is a typical rendering and event loop with a sf::RenderWindow:\n///\n/// \\code\n/// // Declare and create a new render-window\n/// sf::RenderWindow window(sf::VideoMode(800, 600), \"SFML window\");\n///\n/// // Limit the framerate to 60 frames per second (this step is optional)\n/// window.setFramerateLimit(60);\n///\n/// // The main loop - ends as soon as the window is closed\n/// while (window.isOpen())\n/// {\n///    // Event processing\n///    sf::Event event;\n///    while (window.pollEvent(event))\n///    {\n///        // Request for closing the window\n///        if (event.type == sf::Event::Closed)\n///            window.close();\n///    }\n///\n///    // Clear the whole window before rendering a new frame\n///    window.clear();\n///\n///    // Draw some graphical entities\n///    window.draw(sprite);\n///    window.draw(circle);\n///    window.draw(text);\n///\n///    // End the current frame and display its contents on screen\n///    window.display();\n/// }\n/// \\endcode\n///\n/// Like sf::Window, sf::RenderWindow is still able to render direct\n/// OpenGL stuff. It is even possible to mix together OpenGL calls\n/// and regular SFML drawing commands.\n///\n/// \\code\n/// // Create the render window\n/// sf::RenderWindow window(sf::VideoMode(800, 600), \"SFML OpenGL\");\n///\n/// // Create a sprite and a text to display\n/// sf::Sprite sprite;\n/// sf::Text text;\n/// ...\n///\n/// // Perform OpenGL initializations\n/// glMatrixMode(GL_PROJECTION);\n/// ...\n///\n/// // Start the rendering loop\n/// while (window.isOpen())\n/// {\n///     // Process events\n///     ...\n///\n///     // Draw a background sprite\n///     window.pushGLStates();\n///     window.draw(sprite);\n///     window.popGLStates();\n///\n///     // Draw a 3D object using OpenGL\n///     glBegin(GL_QUADS);\n///         glVertex3f(...);\n///         ...\n///     glEnd();\n///\n///     // Draw text on top of the 3D object\n///     window.pushGLStates();\n///     window.draw(text);\n///     window.popGLStates();\n///\n///     // Finally, display the rendered frame on screen\n///     window.display();\n/// }\n/// \\endcode\n///\n/// \\see sf::Window, sf::RenderTarget, sf::RenderTexture, sf::View\n///\n////////////////////////////////////////////////////////////\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/Graphics/Shader.hpp",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n#ifndef SFML_SHADER_HPP\n#define SFML_SHADER_HPP\n\n////////////////////////////////////////////////////////////\n// Headers\n////////////////////////////////////////////////////////////\n#include <SFML/Graphics/Export.hpp>\n#include <SFML/Graphics/Glsl.hpp>\n#include <SFML/Window/GlResource.hpp>\n#include <SFML/System/NonCopyable.hpp>\n#include <SFML/System/Vector2.hpp>\n#include <SFML/System/Vector3.hpp>\n#include <map>\n#include <string>\n\n\nnamespace sf\n{\nclass Color;\nclass InputStream;\nclass Texture;\nclass Transform;\n\n////////////////////////////////////////////////////////////\n/// \\brief Shader class (vertex, geometry and fragment)\n///\n////////////////////////////////////////////////////////////\nclass SFML_GRAPHICS_API Shader : GlResource, NonCopyable\n{\npublic:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Types of shaders\n    ///\n    ////////////////////////////////////////////////////////////\n    enum Type\n    {\n        Vertex,   ///< %Vertex shader\n        Geometry, ///< Geometry shader\n        Fragment  ///< Fragment (pixel) shader\n    };\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Special type that can be passed to setUniform(),\n    ///        and that represents the texture of the object being drawn\n    ///\n    /// \\see setUniform(const std::string&, CurrentTextureType)\n    ///\n    ////////////////////////////////////////////////////////////\n    struct CurrentTextureType {};\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Represents the texture of the object being drawn\n    ///\n    /// \\see setUniform(const std::string&, CurrentTextureType)\n    ///\n    ////////////////////////////////////////////////////////////\n    static CurrentTextureType CurrentTexture;\n\npublic:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Default constructor\n    ///\n    /// This constructor creates an invalid shader.\n    ///\n    ////////////////////////////////////////////////////////////\n    Shader();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Destructor\n    ///\n    ////////////////////////////////////////////////////////////\n    ~Shader();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Load the vertex, geometry or fragment shader from a file\n    ///\n    /// This function loads a single shader, vertex, geometry or\n    /// fragment, identified by the second argument.\n    /// The source must be a text file containing a valid\n    /// shader in GLSL language. GLSL is a C-like language\n    /// dedicated to OpenGL shaders; you'll probably need to\n    /// read a good documentation for it before writing your\n    /// own shaders.\n    ///\n    /// \\param filename Path of the vertex, geometry or fragment shader file to load\n    /// \\param type     Type of shader (vertex, geometry or fragment)\n    ///\n    /// \\return True if loading succeeded, false if it failed\n    ///\n    /// \\see loadFromMemory, loadFromStream\n    ///\n    ////////////////////////////////////////////////////////////\n    bool loadFromFile(const std::string& filename, Type type);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Load both the vertex and fragment shaders from files\n    ///\n    /// This function loads both the vertex and the fragment\n    /// shaders. If one of them fails to load, the shader is left\n    /// empty (the valid shader is unloaded).\n    /// The sources must be text files containing valid shaders\n    /// in GLSL language. GLSL is a C-like language dedicated to\n    /// OpenGL shaders; you'll probably need to read a good documentation\n    /// for it before writing your own shaders.\n    ///\n    /// \\param vertexShaderFilename   Path of the vertex shader file to load\n    /// \\param fragmentShaderFilename Path of the fragment shader file to load\n    ///\n    /// \\return True if loading succeeded, false if it failed\n    ///\n    /// \\see loadFromMemory, loadFromStream\n    ///\n    ////////////////////////////////////////////////////////////\n    bool loadFromFile(const std::string& vertexShaderFilename, const std::string& fragmentShaderFilename);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Load the vertex, geometry and fragment shaders from files\n    ///\n    /// This function loads the vertex, geometry and fragment\n    /// shaders. If one of them fails to load, the shader is left\n    /// empty (the valid shader is unloaded).\n    /// The sources must be text files containing valid shaders\n    /// in GLSL language. GLSL is a C-like language dedicated to\n    /// OpenGL shaders; you'll probably need to read a good documentation\n    /// for it before writing your own shaders.\n    ///\n    /// \\param vertexShaderFilename   Path of the vertex shader file to load\n    /// \\param geometryShaderFilename Path of the geometry shader file to load\n    /// \\param fragmentShaderFilename Path of the fragment shader file to load\n    ///\n    /// \\return True if loading succeeded, false if it failed\n    ///\n    /// \\see loadFromMemory, loadFromStream\n    ///\n    ////////////////////////////////////////////////////////////\n    bool loadFromFile(const std::string& vertexShaderFilename, const std::string& geometryShaderFilename, const std::string& fragmentShaderFilename);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Load the vertex, geometry or fragment shader from a source code in memory\n    ///\n    /// This function loads a single shader, vertex, geometry\n    /// or fragment, identified by the second argument.\n    /// The source code must be a valid shader in GLSL language.\n    /// GLSL is a C-like language dedicated to OpenGL shaders;\n    /// you'll probably need to read a good documentation for\n    /// it before writing your own shaders.\n    ///\n    /// \\param shader String containing the source code of the shader\n    /// \\param type   Type of shader (vertex, geometry or fragment)\n    ///\n    /// \\return True if loading succeeded, false if it failed\n    ///\n    /// \\see loadFromFile, loadFromStream\n    ///\n    ////////////////////////////////////////////////////////////\n    bool loadFromMemory(const std::string& shader, Type type);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Load both the vertex and fragment shaders from source codes in memory\n    ///\n    /// This function loads both the vertex and the fragment\n    /// shaders. If one of them fails to load, the shader is left\n    /// empty (the valid shader is unloaded).\n    /// The sources must be valid shaders in GLSL language. GLSL is\n    /// a C-like language dedicated to OpenGL shaders; you'll\n    /// probably need to read a good documentation for it before\n    /// writing your own shaders.\n    ///\n    /// \\param vertexShader   String containing the source code of the vertex shader\n    /// \\param fragmentShader String containing the source code of the fragment shader\n    ///\n    /// \\return True if loading succeeded, false if it failed\n    ///\n    /// \\see loadFromFile, loadFromStream\n    ///\n    ////////////////////////////////////////////////////////////\n    bool loadFromMemory(const std::string& vertexShader, const std::string& fragmentShader);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Load the vertex, geometry and fragment shaders from source codes in memory\n    ///\n    /// This function loads the vertex, geometry and fragment\n    /// shaders. If one of them fails to load, the shader is left\n    /// empty (the valid shader is unloaded).\n    /// The sources must be valid shaders in GLSL language. GLSL is\n    /// a C-like language dedicated to OpenGL shaders; you'll\n    /// probably need to read a good documentation for it before\n    /// writing your own shaders.\n    ///\n    /// \\param vertexShader   String containing the source code of the vertex shader\n    /// \\param geometryShader String containing the source code of the geometry shader\n    /// \\param fragmentShader String containing the source code of the fragment shader\n    ///\n    /// \\return True if loading succeeded, false if it failed\n    ///\n    /// \\see loadFromFile, loadFromStream\n    ///\n    ////////////////////////////////////////////////////////////\n    bool loadFromMemory(const std::string& vertexShader, const std::string& geometryShader, const std::string& fragmentShader);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Load the vertex, geometry or fragment shader from a custom stream\n    ///\n    /// This function loads a single shader, vertex, geometry\n    /// or fragment, identified by the second argument.\n    /// The source code must be a valid shader in GLSL language.\n    /// GLSL is a C-like language dedicated to OpenGL shaders;\n    /// you'll probably need to read a good documentation for it\n    /// before writing your own shaders.\n    ///\n    /// \\param stream Source stream to read from\n    /// \\param type   Type of shader (vertex, geometry or fragment)\n    ///\n    /// \\return True if loading succeeded, false if it failed\n    ///\n    /// \\see loadFromFile, loadFromMemory\n    ///\n    ////////////////////////////////////////////////////////////\n    bool loadFromStream(InputStream& stream, Type type);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Load both the vertex and fragment shaders from custom streams\n    ///\n    /// This function loads both the vertex and the fragment\n    /// shaders. If one of them fails to load, the shader is left\n    /// empty (the valid shader is unloaded).\n    /// The source codes must be valid shaders in GLSL language.\n    /// GLSL is a C-like language dedicated to OpenGL shaders;\n    /// you'll probably need to read a good documentation for\n    /// it before writing your own shaders.\n    ///\n    /// \\param vertexShaderStream   Source stream to read the vertex shader from\n    /// \\param fragmentShaderStream Source stream to read the fragment shader from\n    ///\n    /// \\return True if loading succeeded, false if it failed\n    ///\n    /// \\see loadFromFile, loadFromMemory\n    ///\n    ////////////////////////////////////////////////////////////\n    bool loadFromStream(InputStream& vertexShaderStream, InputStream& fragmentShaderStream);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Load the vertex, geometry and fragment shaders from custom streams\n    ///\n    /// This function loads the vertex, geometry and fragment\n    /// shaders. If one of them fails to load, the shader is left\n    /// empty (the valid shader is unloaded).\n    /// The source codes must be valid shaders in GLSL language.\n    /// GLSL is a C-like language dedicated to OpenGL shaders;\n    /// you'll probably need to read a good documentation for\n    /// it before writing your own shaders.\n    ///\n    /// \\param vertexShaderStream   Source stream to read the vertex shader from\n    /// \\param geometryShaderStream Source stream to read the geometry shader from\n    /// \\param fragmentShaderStream Source stream to read the fragment shader from\n    ///\n    /// \\return True if loading succeeded, false if it failed\n    ///\n    /// \\see loadFromFile, loadFromMemory\n    ///\n    ////////////////////////////////////////////////////////////\n    bool loadFromStream(InputStream& vertexShaderStream, InputStream& geometryShaderStream, InputStream& fragmentShaderStream);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Specify value for \\p float uniform\n    ///\n    /// \\param name Name of the uniform variable in GLSL\n    /// \\param x    Value of the float scalar\n    ///\n    ////////////////////////////////////////////////////////////\n    void setUniform(const std::string& name, float x);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Specify value for \\p vec2 uniform\n    ///\n    /// \\param name   Name of the uniform variable in GLSL\n    /// \\param vector Value of the vec2 vector\n    ///\n    ////////////////////////////////////////////////////////////\n    void setUniform(const std::string& name, const Glsl::Vec2& vector);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Specify value for \\p vec3 uniform\n    ///\n    /// \\param name   Name of the uniform variable in GLSL\n    /// \\param vector Value of the vec3 vector\n    ///\n    ////////////////////////////////////////////////////////////\n    void setUniform(const std::string& name, const Glsl::Vec3& vector);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Specify value for \\p vec4 uniform\n    ///\n    /// This overload can also be called with sf::Color objects\n    /// that are converted to sf::Glsl::Vec4.\n    ///\n    /// It is important to note that the components of the color are\n    /// normalized before being passed to the shader. Therefore,\n    /// they are converted from range [0 .. 255] to range [0 .. 1].\n    /// For example, a sf::Color(255, 127, 0, 255) will be transformed\n    /// to a vec4(1.0, 0.5, 0.0, 1.0) in the shader.\n    ///\n    /// \\param name   Name of the uniform variable in GLSL\n    /// \\param vector Value of the vec4 vector\n    ///\n    ////////////////////////////////////////////////////////////\n    void setUniform(const std::string& name, const Glsl::Vec4& vector);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Specify value for \\p int uniform\n    ///\n    /// \\param name Name of the uniform variable in GLSL\n    /// \\param x    Value of the int scalar\n    ///\n    ////////////////////////////////////////////////////////////\n    void setUniform(const std::string& name, int x);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Specify value for \\p ivec2 uniform\n    ///\n    /// \\param name   Name of the uniform variable in GLSL\n    /// \\param vector Value of the ivec2 vector\n    ///\n    ////////////////////////////////////////////////////////////\n    void setUniform(const std::string& name, const Glsl::Ivec2& vector);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Specify value for \\p ivec3 uniform\n    ///\n    /// \\param name   Name of the uniform variable in GLSL\n    /// \\param vector Value of the ivec3 vector\n    ///\n    ////////////////////////////////////////////////////////////\n    void setUniform(const std::string& name, const Glsl::Ivec3& vector);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Specify value for \\p ivec4 uniform\n    ///\n    /// This overload can also be called with sf::Color objects\n    /// that are converted to sf::Glsl::Ivec4.\n    ///\n    /// If color conversions are used, the ivec4 uniform in GLSL\n    /// will hold the same values as the original sf::Color\n    /// instance. For example, sf::Color(255, 127, 0, 255) is\n    /// mapped to ivec4(255, 127, 0, 255).\n    ///\n    /// \\param name   Name of the uniform variable in GLSL\n    /// \\param vector Value of the ivec4 vector\n    ///\n    ////////////////////////////////////////////////////////////\n    void setUniform(const std::string& name, const Glsl::Ivec4& vector);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Specify value for \\p bool uniform\n    ///\n    /// \\param name Name of the uniform variable in GLSL\n    /// \\param x    Value of the bool scalar\n    ///\n    ////////////////////////////////////////////////////////////\n    void setUniform(const std::string& name, bool x);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Specify value for \\p bvec2 uniform\n    ///\n    /// \\param name   Name of the uniform variable in GLSL\n    /// \\param vector Value of the bvec2 vector\n    ///\n    ////////////////////////////////////////////////////////////\n    void setUniform(const std::string& name, const Glsl::Bvec2& vector);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Specify value for \\p bvec3 uniform\n    ///\n    /// \\param name   Name of the uniform variable in GLSL\n    /// \\param vector Value of the bvec3 vector\n    ///\n    ////////////////////////////////////////////////////////////\n    void setUniform(const std::string& name, const Glsl::Bvec3& vector);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Specify value for \\p bvec4 uniform\n    ///\n    /// \\param name   Name of the uniform variable in GLSL\n    /// \\param vector Value of the bvec4 vector\n    ///\n    ////////////////////////////////////////////////////////////\n    void setUniform(const std::string& name, const Glsl::Bvec4& vector);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Specify value for \\p mat3 matrix\n    ///\n    /// \\param name   Name of the uniform variable in GLSL\n    /// \\param matrix Value of the mat3 matrix\n    ///\n    ////////////////////////////////////////////////////////////\n    void setUniform(const std::string& name, const Glsl::Mat3& matrix);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Specify value for \\p mat4 matrix\n    ///\n    /// \\param name   Name of the uniform variable in GLSL\n    /// \\param matrix Value of the mat4 matrix\n    ///\n    ////////////////////////////////////////////////////////////\n    void setUniform(const std::string& name, const Glsl::Mat4& matrix);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Specify a texture as \\p sampler2D uniform\n    ///\n    /// \\a name is the name of the variable to change in the shader.\n    /// The corresponding parameter in the shader must be a 2D texture\n    /// (\\p sampler2D GLSL type).\n    ///\n    /// Example:\n    /// \\code\n    /// uniform sampler2D the_texture; // this is the variable in the shader\n    /// \\endcode\n    /// \\code\n    /// sf::Texture texture;\n    /// ...\n    /// shader.setUniform(\"the_texture\", texture);\n    /// \\endcode\n    /// It is important to note that \\a texture must remain alive as long\n    /// as the shader uses it, no copy is made internally.\n    ///\n    /// To use the texture of the object being drawn, which cannot be\n    /// known in advance, you can pass the special value\n    /// sf::Shader::CurrentTexture:\n    /// \\code\n    /// shader.setUniform(\"the_texture\", sf::Shader::CurrentTexture).\n    /// \\endcode\n    ///\n    /// \\param name    Name of the texture in the shader\n    /// \\param texture Texture to assign\n    ///\n    ////////////////////////////////////////////////////////////\n    void setUniform(const std::string& name, const Texture& texture);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Specify current texture as \\p sampler2D uniform\n    ///\n    /// This overload maps a shader texture variable to the\n    /// texture of the object being drawn, which cannot be\n    /// known in advance. The second argument must be\n    /// sf::Shader::CurrentTexture.\n    /// The corresponding parameter in the shader must be a 2D texture\n    /// (\\p sampler2D GLSL type).\n    ///\n    /// Example:\n    /// \\code\n    /// uniform sampler2D current; // this is the variable in the shader\n    /// \\endcode\n    /// \\code\n    /// shader.setUniform(\"current\", sf::Shader::CurrentTexture);\n    /// \\endcode\n    ///\n    /// \\param name Name of the texture in the shader\n    ///\n    ////////////////////////////////////////////////////////////\n    void setUniform(const std::string& name, CurrentTextureType);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Specify values for \\p float[] array uniform\n    ///\n    /// \\param name        Name of the uniform variable in GLSL\n    /// \\param scalarArray pointer to array of \\p float values\n    /// \\param length      Number of elements in the array\n    ///\n    ////////////////////////////////////////////////////////////\n    void setUniformArray(const std::string& name, const float* scalarArray, std::size_t length);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Specify values for \\p vec2[] array uniform\n    ///\n    /// \\param name        Name of the uniform variable in GLSL\n    /// \\param vectorArray pointer to array of \\p vec2 values\n    /// \\param length      Number of elements in the array\n    ///\n    ////////////////////////////////////////////////////////////\n    void setUniformArray(const std::string& name, const Glsl::Vec2* vectorArray, std::size_t length);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Specify values for \\p vec3[] array uniform\n    ///\n    /// \\param name        Name of the uniform variable in GLSL\n    /// \\param vectorArray pointer to array of \\p vec3 values\n    /// \\param length      Number of elements in the array\n    ///\n    ////////////////////////////////////////////////////////////\n    void setUniformArray(const std::string& name, const Glsl::Vec3* vectorArray, std::size_t length);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Specify values for \\p vec4[] array uniform\n    ///\n    /// \\param name        Name of the uniform variable in GLSL\n    /// \\param vectorArray pointer to array of \\p vec4 values\n    /// \\param length      Number of elements in the array\n    ///\n    ////////////////////////////////////////////////////////////\n    void setUniformArray(const std::string& name, const Glsl::Vec4* vectorArray, std::size_t length);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Specify values for \\p mat3[] array uniform\n    ///\n    /// \\param name        Name of the uniform variable in GLSL\n    /// \\param matrixArray pointer to array of \\p mat3 values\n    /// \\param length      Number of elements in the array\n    ///\n    ////////////////////////////////////////////////////////////\n    void setUniformArray(const std::string& name, const Glsl::Mat3* matrixArray, std::size_t length);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Specify values for \\p mat4[] array uniform\n    ///\n    /// \\param name        Name of the uniform variable in GLSL\n    /// \\param matrixArray pointer to array of \\p mat4 values\n    /// \\param length      Number of elements in the array\n    ///\n    ////////////////////////////////////////////////////////////\n    void setUniformArray(const std::string& name, const Glsl::Mat4* matrixArray, std::size_t length);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Change a float parameter of the shader\n    ///\n    /// \\deprecated Use setUniform(const std::string&, float) instead.\n    ///\n    ////////////////////////////////////////////////////////////\n    SFML_DEPRECATED void setParameter(const std::string& name, float x);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Change a 2-components vector parameter of the shader\n    ///\n    /// \\deprecated Use setUniform(const std::string&, const Glsl::Vec2&) instead.\n    ///\n    ////////////////////////////////////////////////////////////\n    SFML_DEPRECATED void setParameter(const std::string& name, float x, float y);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Change a 3-components vector parameter of the shader\n    ///\n    /// \\deprecated Use setUniform(const std::string&, const Glsl::Vec3&) instead.\n    ///\n    ////////////////////////////////////////////////////////////\n    SFML_DEPRECATED void setParameter(const std::string& name, float x, float y, float z);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Change a 4-components vector parameter of the shader\n    ///\n    /// \\deprecated Use setUniform(const std::string&, const Glsl::Vec4&) instead.\n    ///\n    ////////////////////////////////////////////////////////////\n    SFML_DEPRECATED void setParameter(const std::string& name, float x, float y, float z, float w);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Change a 2-components vector parameter of the shader\n    ///\n    /// \\deprecated Use setUniform(const std::string&, const Glsl::Vec2&) instead.\n    ///\n    ////////////////////////////////////////////////////////////\n    SFML_DEPRECATED void setParameter(const std::string& name, const Vector2f& vector);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Change a 3-components vector parameter of the shader\n    ///\n    /// \\deprecated Use setUniform(const std::string&, const Glsl::Vec3&) instead.\n    ///\n    ////////////////////////////////////////////////////////////\n    SFML_DEPRECATED void setParameter(const std::string& name, const Vector3f& vector);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Change a color parameter of the shader\n    ///\n    /// \\deprecated Use setUniform(const std::string&, const Glsl::Vec4&) instead.\n    ///\n    ////////////////////////////////////////////////////////////\n    SFML_DEPRECATED void setParameter(const std::string& name, const Color& color);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Change a matrix parameter of the shader\n    ///\n    /// \\deprecated Use setUniform(const std::string&, const Glsl::Mat4&) instead.\n    ///\n    ////////////////////////////////////////////////////////////\n    SFML_DEPRECATED void setParameter(const std::string& name, const Transform& transform);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Change a texture parameter of the shader\n    ///\n    /// \\deprecated Use setUniform(const std::string&, const Texture&) instead.\n    ///\n    ////////////////////////////////////////////////////////////\n    SFML_DEPRECATED void setParameter(const std::string& name, const Texture& texture);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Change a texture parameter of the shader\n    ///\n    /// \\deprecated Use setUniform(const std::string&, CurrentTextureType) instead.\n    ///\n    ////////////////////////////////////////////////////////////\n    SFML_DEPRECATED void setParameter(const std::string& name, CurrentTextureType);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the underlying OpenGL handle of the shader.\n    ///\n    /// You shouldn't need to use this function, unless you have\n    /// very specific stuff to implement that SFML doesn't support,\n    /// or implement a temporary workaround until a bug is fixed.\n    ///\n    /// \\return OpenGL handle of the shader or 0 if not yet loaded\n    ///\n    ////////////////////////////////////////////////////////////\n    unsigned int getNativeHandle() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Bind a shader for rendering\n    ///\n    /// This function is not part of the graphics API, it mustn't be\n    /// used when drawing SFML entities. It must be used only if you\n    /// mix sf::Shader with OpenGL code.\n    ///\n    /// \\code\n    /// sf::Shader s1, s2;\n    /// ...\n    /// sf::Shader::bind(&s1);\n    /// // draw OpenGL stuff that use s1...\n    /// sf::Shader::bind(&s2);\n    /// // draw OpenGL stuff that use s2...\n    /// sf::Shader::bind(NULL);\n    /// // draw OpenGL stuff that use no shader...\n    /// \\endcode\n    ///\n    /// \\param shader Shader to bind, can be null to use no shader\n    ///\n    ////////////////////////////////////////////////////////////\n    static void bind(const Shader* shader);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Tell whether or not the system supports shaders\n    ///\n    /// This function should always be called before using\n    /// the shader features. If it returns false, then\n    /// any attempt to use sf::Shader will fail.\n    ///\n    /// \\return True if shaders are supported, false otherwise\n    ///\n    ////////////////////////////////////////////////////////////\n    static bool isAvailable();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Tell whether or not the system supports geometry shaders\n    ///\n    /// This function should always be called before using\n    /// the geometry shader features. If it returns false, then\n    /// any attempt to use sf::Shader geometry shader features will fail.\n    ///\n    /// This function can only return true if isAvailable() would also\n    /// return true, since shaders in general have to be supported in\n    /// order for geometry shaders to be supported as well.\n    ///\n    /// Note: The first call to this function, whether by your\n    /// code or SFML will result in a context switch.\n    ///\n    /// \\return True if geometry shaders are supported, false otherwise\n    ///\n    ////////////////////////////////////////////////////////////\n    static bool isGeometryAvailable();\n\nprivate:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Compile the shader(s) and create the program\n    ///\n    /// If one of the arguments is NULL, the corresponding shader\n    /// is not created.\n    ///\n    /// \\param vertexShaderCode   Source code of the vertex shader\n    /// \\param geometryShaderCode Source code of the geometry shader\n    /// \\param fragmentShaderCode Source code of the fragment shader\n    ///\n    /// \\return True on success, false if any error happened\n    ///\n    ////////////////////////////////////////////////////////////\n    bool compile(const char* vertexShaderCode, const char* geometryShaderCode, const char* fragmentShaderCode);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Bind all the textures used by the shader\n    ///\n    /// This function each texture to a different unit, and\n    /// updates the corresponding variables in the shader accordingly.\n    ///\n    ////////////////////////////////////////////////////////////\n    void bindTextures() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the location ID of a shader uniform\n    ///\n    /// \\param name Name of the uniform variable to search\n    ///\n    /// \\return Location ID of the uniform, or -1 if not found\n    ///\n    ////////////////////////////////////////////////////////////\n    int getUniformLocation(const std::string& name);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief RAII object to save and restore the program\n    ///        binding while uniforms are being set\n    ///\n    /// Implementation is private in the .cpp file.\n    ///\n    ////////////////////////////////////////////////////////////\n    struct UniformBinder;\n\n    ////////////////////////////////////////////////////////////\n    // Types\n    ////////////////////////////////////////////////////////////\n    typedef std::map<int, const Texture*> TextureTable;\n    typedef std::map<std::string, int> UniformTable;\n\n    ////////////////////////////////////////////////////////////\n    // Member data\n    ////////////////////////////////////////////////////////////\n    unsigned int m_shaderProgram;  ///< OpenGL identifier for the program\n    int          m_currentTexture; ///< Location of the current texture in the shader\n    TextureTable m_textures;       ///< Texture variables in the shader, mapped to their location\n    UniformTable m_uniforms;       ///< Parameters location cache\n};\n\n} // namespace sf\n\n\n#endif // SFML_SHADER_HPP\n\n\n////////////////////////////////////////////////////////////\n/// \\class sf::Shader\n/// \\ingroup graphics\n///\n/// Shaders are programs written using a specific language,\n/// executed directly by the graphics card and allowing\n/// to apply real-time operations to the rendered entities.\n///\n/// There are three kinds of shaders:\n/// \\li %Vertex shaders, that process vertices\n/// \\li Geometry shaders, that process primitives\n/// \\li Fragment (pixel) shaders, that process pixels\n///\n/// A sf::Shader can be composed of either a vertex shader\n/// alone, a geometry shader alone, a fragment shader alone,\n/// or any combination of them. (see the variants of the\n/// load functions).\n///\n/// Shaders are written in GLSL, which is a C-like\n/// language dedicated to OpenGL shaders. You'll probably\n/// need to learn its basics before writing your own shaders\n/// for SFML.\n///\n/// Like any C/C++ program, a GLSL shader has its own variables\n/// called \\a uniforms that you can set from your C++ application.\n/// sf::Shader handles different types of uniforms:\n/// \\li scalars: \\p float, \\p int, \\p bool\n/// \\li vectors (2, 3 or 4 components)\n/// \\li matrices (3x3 or 4x4)\n/// \\li samplers (textures)\n///\n/// Some SFML-specific types can be converted:\n/// \\li sf::Color as a 4D vector (\\p vec4)\n/// \\li sf::Transform as matrices (\\p mat3 or \\p mat4)\n///\n/// Every uniform variable in a shader can be set through one of the\n/// setUniform() or setUniformArray() overloads. For example, if you\n/// have a shader with the following uniforms:\n/// \\code\n/// uniform float offset;\n/// uniform vec3 point;\n/// uniform vec4 color;\n/// uniform mat4 matrix;\n/// uniform sampler2D overlay;\n/// uniform sampler2D current;\n/// \\endcode\n/// You can set their values from C++ code as follows, using the types\n/// defined in the sf::Glsl namespace:\n/// \\code\n/// shader.setUniform(\"offset\", 2.f);\n/// shader.setUniform(\"point\", sf::Vector3f(0.5f, 0.8f, 0.3f));\n/// shader.setUniform(\"color\", sf::Glsl::Vec4(color));          // color is a sf::Color\n/// shader.setUniform(\"matrix\", sf::Glsl::Mat4(transform));     // transform is a sf::Transform\n/// shader.setUniform(\"overlay\", texture);                      // texture is a sf::Texture\n/// shader.setUniform(\"current\", sf::Shader::CurrentTexture);\n/// \\endcode\n///\n/// The old setParameter() overloads are deprecated and will be removed in a\n/// future version. You should use their setUniform() equivalents instead.\n///\n/// The special Shader::CurrentTexture argument maps the\n/// given \\p sampler2D uniform to the current texture of the\n/// object being drawn (which cannot be known in advance).\n///\n/// To apply a shader to a drawable, you must pass it as an\n/// additional parameter to the \\ref Window::draw() draw() function:\n/// \\code\n/// window.draw(sprite, &shader);\n/// \\endcode\n///\n/// ... which is in fact just a shortcut for this:\n/// \\code\n/// sf::RenderStates states;\n/// states.shader = &shader;\n/// window.draw(sprite, states);\n/// \\endcode\n///\n/// In the code above we pass a pointer to the shader, because it may\n/// be null (which means \"no shader\").\n///\n/// Shaders can be used on any drawable, but some combinations are\n/// not interesting. For example, using a vertex shader on a sf::Sprite\n/// is limited because there are only 4 vertices, the sprite would\n/// have to be subdivided in order to apply wave effects.\n/// Another bad example is a fragment shader with sf::Text: the texture\n/// of the text is not the actual text that you see on screen, it is\n/// a big texture containing all the characters of the font in an\n/// arbitrary order; thus, texture lookups on pixels other than the\n/// current one may not give you the expected result.\n///\n/// Shaders can also be used to apply global post-effects to the\n/// current contents of the target (like the old sf::PostFx class\n/// in SFML 1). This can be done in two different ways:\n/// \\li draw everything to a sf::RenderTexture, then draw it to\n///     the main target using the shader\n/// \\li draw everything directly to the main target, then use\n///     sf::Texture::update(Window&) to copy its contents to a texture\n///     and draw it to the main target using the shader\n///\n/// The first technique is more optimized because it doesn't involve\n/// retrieving the target's pixels to system memory, but the\n/// second one doesn't impact the rendering process and can be\n/// easily inserted anywhere without impacting all the code.\n///\n/// Like sf::Texture that can be used as a raw OpenGL texture,\n/// sf::Shader can also be used directly as a raw shader for\n/// custom OpenGL geometry.\n/// \\code\n/// sf::Shader::bind(&shader);\n/// ... render OpenGL geometry ...\n/// sf::Shader::bind(NULL);\n/// \\endcode\n///\n/// \\see sf::Glsl\n///\n////////////////////////////////////////////////////////////\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/Graphics/Shape.hpp",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n#ifndef SFML_SHAPE_HPP\n#define SFML_SHAPE_HPP\n\n////////////////////////////////////////////////////////////\n// Headers\n////////////////////////////////////////////////////////////\n#include <SFML/Graphics/Export.hpp>\n#include <SFML/Graphics/Drawable.hpp>\n#include <SFML/Graphics/Transformable.hpp>\n#include <SFML/Graphics/VertexArray.hpp>\n#include <SFML/System/Vector2.hpp>\n\n\nnamespace sf\n{\n////////////////////////////////////////////////////////////\n/// \\brief Base class for textured shapes with outline\n///\n////////////////////////////////////////////////////////////\nclass SFML_GRAPHICS_API Shape : public Drawable, public Transformable\n{\npublic:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Virtual destructor\n    ///\n    ////////////////////////////////////////////////////////////\n    virtual ~Shape();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Change the source texture of the shape\n    ///\n    /// The \\a texture argument refers to a texture that must\n    /// exist as long as the shape uses it. Indeed, the shape\n    /// doesn't store its own copy of the texture, but rather keeps\n    /// a pointer to the one that you passed to this function.\n    /// If the source texture is destroyed and the shape tries to\n    /// use it, the behavior is undefined.\n    /// \\a texture can be NULL to disable texturing.\n    /// If \\a resetRect is true, the TextureRect property of\n    /// the shape is automatically adjusted to the size of the new\n    /// texture. If it is false, the texture rect is left unchanged.\n    ///\n    /// \\param texture   New texture\n    /// \\param resetRect Should the texture rect be reset to the size of the new texture?\n    ///\n    /// \\see getTexture, setTextureRect\n    ///\n    ////////////////////////////////////////////////////////////\n    void setTexture(const Texture* texture, bool resetRect = false);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Set the sub-rectangle of the texture that the shape will display\n    ///\n    /// The texture rect is useful when you don't want to display\n    /// the whole texture, but rather a part of it.\n    /// By default, the texture rect covers the entire texture.\n    ///\n    /// \\param rect Rectangle defining the region of the texture to display\n    ///\n    /// \\see getTextureRect, setTexture\n    ///\n    ////////////////////////////////////////////////////////////\n    void setTextureRect(const IntRect& rect);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Set the fill color of the shape\n    ///\n    /// This color is modulated (multiplied) with the shape's\n    /// texture if any. It can be used to colorize the shape,\n    /// or change its global opacity.\n    /// You can use sf::Color::Transparent to make the inside of\n    /// the shape transparent, and have the outline alone.\n    /// By default, the shape's fill color is opaque white.\n    ///\n    /// \\param color New color of the shape\n    ///\n    /// \\see getFillColor, setOutlineColor\n    ///\n    ////////////////////////////////////////////////////////////\n    void setFillColor(const Color& color);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Set the outline color of the shape\n    ///\n    /// By default, the shape's outline color is opaque white.\n    ///\n    /// \\param color New outline color of the shape\n    ///\n    /// \\see getOutlineColor, setFillColor\n    ///\n    ////////////////////////////////////////////////////////////\n    void setOutlineColor(const Color& color);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Set the thickness of the shape's outline\n    ///\n    /// Note that negative values are allowed (so that the outline\n    /// expands towards the center of the shape), and using zero\n    /// disables the outline.\n    /// By default, the outline thickness is 0.\n    ///\n    /// \\param thickness New outline thickness\n    ///\n    /// \\see getOutlineThickness\n    ///\n    ////////////////////////////////////////////////////////////\n    void setOutlineThickness(float thickness);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the source texture of the shape\n    ///\n    /// If the shape has no source texture, a NULL pointer is returned.\n    /// The returned pointer is const, which means that you can't\n    /// modify the texture when you retrieve it with this function.\n    ///\n    /// \\return Pointer to the shape's texture\n    ///\n    /// \\see setTexture\n    ///\n    ////////////////////////////////////////////////////////////\n    const Texture* getTexture() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the sub-rectangle of the texture displayed by the shape\n    ///\n    /// \\return Texture rectangle of the shape\n    ///\n    /// \\see setTextureRect\n    ///\n    ////////////////////////////////////////////////////////////\n    const IntRect& getTextureRect() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the fill color of the shape\n    ///\n    /// \\return Fill color of the shape\n    ///\n    /// \\see setFillColor\n    ///\n    ////////////////////////////////////////////////////////////\n    const Color& getFillColor() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the outline color of the shape\n    ///\n    /// \\return Outline color of the shape\n    ///\n    /// \\see setOutlineColor\n    ///\n    ////////////////////////////////////////////////////////////\n    const Color& getOutlineColor() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the outline thickness of the shape\n    ///\n    /// \\return Outline thickness of the shape\n    ///\n    /// \\see setOutlineThickness\n    ///\n    ////////////////////////////////////////////////////////////\n    float getOutlineThickness() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the total number of points of the shape\n    ///\n    /// \\return Number of points of the shape\n    ///\n    /// \\see getPoint\n    ///\n    ////////////////////////////////////////////////////////////\n    virtual std::size_t getPointCount() const = 0;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get a point of the shape\n    ///\n    /// The returned point is in local coordinates, that is,\n    /// the shape's transforms (position, rotation, scale) are\n    /// not taken into account.\n    /// The result is undefined if \\a index is out of the valid range.\n    ///\n    /// \\param index Index of the point to get, in range [0 .. getPointCount() - 1]\n    ///\n    /// \\return index-th point of the shape\n    ///\n    /// \\see getPointCount\n    ///\n    ////////////////////////////////////////////////////////////\n    virtual Vector2f getPoint(std::size_t index) const = 0;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the local bounding rectangle of the entity\n    ///\n    /// The returned rectangle is in local coordinates, which means\n    /// that it ignores the transformations (translation, rotation,\n    /// scale, ...) that are applied to the entity.\n    /// In other words, this function returns the bounds of the\n    /// entity in the entity's coordinate system.\n    ///\n    /// \\return Local bounding rectangle of the entity\n    ///\n    ////////////////////////////////////////////////////////////\n    FloatRect getLocalBounds() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the global (non-minimal) bounding rectangle of the entity\n    ///\n    /// The returned rectangle is in global coordinates, which means\n    /// that it takes into account the transformations (translation,\n    /// rotation, scale, ...) that are applied to the entity.\n    /// In other words, this function returns the bounds of the\n    /// shape in the global 2D world's coordinate system.\n    ///\n    /// This function does not necessarily return the \\a minimal\n    /// bounding rectangle. It merely ensures that the returned\n    /// rectangle covers all the vertices (but possibly more).\n    /// This allows for a fast approximation of the bounds as a\n    /// first check; you may want to use more precise checks\n    /// on top of that.\n    ///\n    /// \\return Global bounding rectangle of the entity\n    ///\n    ////////////////////////////////////////////////////////////\n    FloatRect getGlobalBounds() const;\n\nprotected:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Default constructor\n    ///\n    ////////////////////////////////////////////////////////////\n    Shape();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Recompute the internal geometry of the shape\n    ///\n    /// This function must be called by the derived class everytime\n    /// the shape's points change (i.e. the result of either\n    /// getPointCount or getPoint is different).\n    ///\n    ////////////////////////////////////////////////////////////\n    void update();\n\nprivate:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Draw the shape to a render target\n    ///\n    /// \\param target Render target to draw to\n    /// \\param states Current render states\n    ///\n    ////////////////////////////////////////////////////////////\n    virtual void draw(RenderTarget& target, RenderStates states) const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Update the fill vertices' color\n    ///\n    ////////////////////////////////////////////////////////////\n    void updateFillColors();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Update the fill vertices' texture coordinates\n    ///\n    ////////////////////////////////////////////////////////////\n    void updateTexCoords();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Update the outline vertices' position\n    ///\n    ////////////////////////////////////////////////////////////\n    void updateOutline();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Update the outline vertices' color\n    ///\n    ////////////////////////////////////////////////////////////\n    void updateOutlineColors();\n\nprivate:\n\n    ////////////////////////////////////////////////////////////\n    // Member data\n    ////////////////////////////////////////////////////////////\n    const Texture* m_texture;          ///< Texture of the shape\n    IntRect        m_textureRect;      ///< Rectangle defining the area of the source texture to display\n    Color          m_fillColor;        ///< Fill color\n    Color          m_outlineColor;     ///< Outline color\n    float          m_outlineThickness; ///< Thickness of the shape's outline\n    VertexArray    m_vertices;         ///< Vertex array containing the fill geometry\n    VertexArray    m_outlineVertices;  ///< Vertex array containing the outline geometry\n    FloatRect      m_insideBounds;     ///< Bounding rectangle of the inside (fill)\n    FloatRect      m_bounds;           ///< Bounding rectangle of the whole shape (outline + fill)\n};\n\n} // namespace sf\n\n\n#endif // SFML_SHAPE_HPP\n\n\n////////////////////////////////////////////////////////////\n/// \\class sf::Shape\n/// \\ingroup graphics\n///\n/// sf::Shape is a drawable class that allows to define and\n/// display a custom convex shape on a render target.\n/// It's only an abstract base, it needs to be specialized for\n/// concrete types of shapes (circle, rectangle, convex polygon,\n/// star, ...).\n///\n/// In addition to the attributes provided by the specialized\n/// shape classes, a shape always has the following attributes:\n/// \\li a texture\n/// \\li a texture rectangle\n/// \\li a fill color\n/// \\li an outline color\n/// \\li an outline thickness\n///\n/// Each feature is optional, and can be disabled easily:\n/// \\li the texture can be null\n/// \\li the fill/outline colors can be sf::Color::Transparent\n/// \\li the outline thickness can be zero\n///\n/// You can write your own derived shape class, there are only\n/// two virtual functions to override:\n/// \\li getPointCount must return the number of points of the shape\n/// \\li getPoint must return the points of the shape\n///\n/// \\see sf::RectangleShape, sf::CircleShape, sf::ConvexShape, sf::Transformable\n///\n////////////////////////////////////////////////////////////\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/Graphics/Sprite.hpp",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n#ifndef SFML_SPRITE_HPP\n#define SFML_SPRITE_HPP\n\n////////////////////////////////////////////////////////////\n// Headers\n////////////////////////////////////////////////////////////\n#include <SFML/Graphics/Export.hpp>\n#include <SFML/Graphics/Drawable.hpp>\n#include <SFML/Graphics/Transformable.hpp>\n#include <SFML/Graphics/Vertex.hpp>\n#include <SFML/Graphics/Rect.hpp>\n\n\nnamespace sf\n{\nclass Texture;\n\n////////////////////////////////////////////////////////////\n/// \\brief Drawable representation of a texture, with its\n///        own transformations, color, etc.\n///\n////////////////////////////////////////////////////////////\nclass SFML_GRAPHICS_API Sprite : public Drawable, public Transformable\n{\npublic:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Default constructor\n    ///\n    /// Creates an empty sprite with no source texture.\n    ///\n    ////////////////////////////////////////////////////////////\n    Sprite();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Construct the sprite from a source texture\n    ///\n    /// \\param texture Source texture\n    ///\n    /// \\see setTexture\n    ///\n    ////////////////////////////////////////////////////////////\n    explicit Sprite(const Texture& texture);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Construct the sprite from a sub-rectangle of a source texture\n    ///\n    /// \\param texture   Source texture\n    /// \\param rectangle Sub-rectangle of the texture to assign to the sprite\n    ///\n    /// \\see setTexture, setTextureRect\n    ///\n    ////////////////////////////////////////////////////////////\n    Sprite(const Texture& texture, const IntRect& rectangle);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Change the source texture of the sprite\n    ///\n    /// The \\a texture argument refers to a texture that must\n    /// exist as long as the sprite uses it. Indeed, the sprite\n    /// doesn't store its own copy of the texture, but rather keeps\n    /// a pointer to the one that you passed to this function.\n    /// If the source texture is destroyed and the sprite tries to\n    /// use it, the behavior is undefined.\n    /// If \\a resetRect is true, the TextureRect property of\n    /// the sprite is automatically adjusted to the size of the new\n    /// texture. If it is false, the texture rect is left unchanged.\n    ///\n    /// \\param texture   New texture\n    /// \\param resetRect Should the texture rect be reset to the size of the new texture?\n    ///\n    /// \\see getTexture, setTextureRect\n    ///\n    ////////////////////////////////////////////////////////////\n    void setTexture(const Texture& texture, bool resetRect = false);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Set the sub-rectangle of the texture that the sprite will display\n    ///\n    /// The texture rect is useful when you don't want to display\n    /// the whole texture, but rather a part of it.\n    /// By default, the texture rect covers the entire texture.\n    ///\n    /// \\param rectangle Rectangle defining the region of the texture to display\n    ///\n    /// \\see getTextureRect, setTexture\n    ///\n    ////////////////////////////////////////////////////////////\n    void setTextureRect(const IntRect& rectangle);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Set the global color of the sprite\n    ///\n    /// This color is modulated (multiplied) with the sprite's\n    /// texture. It can be used to colorize the sprite, or change\n    /// its global opacity.\n    /// By default, the sprite's color is opaque white.\n    ///\n    /// \\param color New color of the sprite\n    ///\n    /// \\see getColor\n    ///\n    ////////////////////////////////////////////////////////////\n    void setColor(const Color& color);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the source texture of the sprite\n    ///\n    /// If the sprite has no source texture, a NULL pointer is returned.\n    /// The returned pointer is const, which means that you can't\n    /// modify the texture when you retrieve it with this function.\n    ///\n    /// \\return Pointer to the sprite's texture\n    ///\n    /// \\see setTexture\n    ///\n    ////////////////////////////////////////////////////////////\n    const Texture* getTexture() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the sub-rectangle of the texture displayed by the sprite\n    ///\n    /// \\return Texture rectangle of the sprite\n    ///\n    /// \\see setTextureRect\n    ///\n    ////////////////////////////////////////////////////////////\n    const IntRect& getTextureRect() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the global color of the sprite\n    ///\n    /// \\return Global color of the sprite\n    ///\n    /// \\see setColor\n    ///\n    ////////////////////////////////////////////////////////////\n    const Color& getColor() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the local bounding rectangle of the entity\n    ///\n    /// The returned rectangle is in local coordinates, which means\n    /// that it ignores the transformations (translation, rotation,\n    /// scale, ...) that are applied to the entity.\n    /// In other words, this function returns the bounds of the\n    /// entity in the entity's coordinate system.\n    ///\n    /// \\return Local bounding rectangle of the entity\n    ///\n    ////////////////////////////////////////////////////////////\n    FloatRect getLocalBounds() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the global bounding rectangle of the entity\n    ///\n    /// The returned rectangle is in global coordinates, which means\n    /// that it takes into account the transformations (translation,\n    /// rotation, scale, ...) that are applied to the entity.\n    /// In other words, this function returns the bounds of the\n    /// sprite in the global 2D world's coordinate system.\n    ///\n    /// \\return Global bounding rectangle of the entity\n    ///\n    ////////////////////////////////////////////////////////////\n    FloatRect getGlobalBounds() const;\n\nprivate:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Draw the sprite to a render target\n    ///\n    /// \\param target Render target to draw to\n    /// \\param states Current render states\n    ///\n    ////////////////////////////////////////////////////////////\n    virtual void draw(RenderTarget& target, RenderStates states) const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Update the vertices' positions\n    ///\n    ////////////////////////////////////////////////////////////\n    void updatePositions();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Update the vertices' texture coordinates\n    ///\n    ////////////////////////////////////////////////////////////\n    void updateTexCoords();\n\n    ////////////////////////////////////////////////////////////\n    // Member data\n    ////////////////////////////////////////////////////////////\n    Vertex         m_vertices[4]; ///< Vertices defining the sprite's geometry\n    const Texture* m_texture;     ///< Texture of the sprite\n    IntRect        m_textureRect; ///< Rectangle defining the area of the source texture to display\n};\n\n} // namespace sf\n\n\n#endif // SFML_SPRITE_HPP\n\n\n////////////////////////////////////////////////////////////\n/// \\class sf::Sprite\n/// \\ingroup graphics\n///\n/// sf::Sprite is a drawable class that allows to easily display\n/// a texture (or a part of it) on a render target.\n///\n/// It inherits all the functions from sf::Transformable:\n/// position, rotation, scale, origin. It also adds sprite-specific\n/// properties such as the texture to use, the part of it to display,\n/// and some convenience functions to change the overall color of the\n/// sprite, or to get its bounding rectangle.\n///\n/// sf::Sprite works in combination with the sf::Texture class, which\n/// loads and provides the pixel data of a given texture.\n///\n/// The separation of sf::Sprite and sf::Texture allows more flexibility\n/// and better performances: indeed a sf::Texture is a heavy resource,\n/// and any operation on it is slow (often too slow for real-time\n/// applications). On the other side, a sf::Sprite is a lightweight\n/// object which can use the pixel data of a sf::Texture and draw\n/// it with its own transformation/color/blending attributes.\n///\n/// It is important to note that the sf::Sprite instance doesn't\n/// copy the texture that it uses, it only keeps a reference to it.\n/// Thus, a sf::Texture must not be destroyed while it is\n/// used by a sf::Sprite (i.e. never write a function that\n/// uses a local sf::Texture instance for creating a sprite).\n///\n/// See also the note on coordinates and undistorted rendering in sf::Transformable.\n///\n/// Usage example:\n/// \\code\n/// // Declare and load a texture\n/// sf::Texture texture;\n/// texture.loadFromFile(\"texture.png\");\n///\n/// // Create a sprite\n/// sf::Sprite sprite;\n/// sprite.setTexture(texture);\n/// sprite.setTextureRect(sf::IntRect(10, 10, 50, 30));\n/// sprite.setColor(sf::Color(255, 255, 255, 200));\n/// sprite.setPosition(100, 25);\n///\n/// // Draw it\n/// window.draw(sprite);\n/// \\endcode\n///\n/// \\see sf::Texture, sf::Transformable\n///\n////////////////////////////////////////////////////////////\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/Graphics/Text.hpp",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n#ifndef SFML_TEXT_HPP\n#define SFML_TEXT_HPP\n\n////////////////////////////////////////////////////////////\n// Headers\n////////////////////////////////////////////////////////////\n#include <SFML/Graphics/Export.hpp>\n#include <SFML/Graphics/Drawable.hpp>\n#include <SFML/Graphics/Transformable.hpp>\n#include <SFML/Graphics/Font.hpp>\n#include <SFML/Graphics/Rect.hpp>\n#include <SFML/Graphics/VertexArray.hpp>\n#include <SFML/System/String.hpp>\n#include <string>\n#include <vector>\n\n\nnamespace sf\n{\n////////////////////////////////////////////////////////////\n/// \\brief Graphical text that can be drawn to a render target\n///\n////////////////////////////////////////////////////////////\nclass SFML_GRAPHICS_API Text : public Drawable, public Transformable\n{\npublic:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Enumeration of the string drawing styles\n    ///\n    ////////////////////////////////////////////////////////////\n    enum Style\n    {\n        Regular       = 0,      ///< Regular characters, no style\n        Bold          = 1 << 0, ///< Bold characters\n        Italic        = 1 << 1, ///< Italic characters\n        Underlined    = 1 << 2, ///< Underlined characters\n        StrikeThrough = 1 << 3  ///< Strike through characters\n    };\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Default constructor\n    ///\n    /// Creates an empty text.\n    ///\n    ////////////////////////////////////////////////////////////\n    Text();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Construct the text from a string, font and size\n    ///\n    /// Note that if the used font is a bitmap font, it is not\n    /// scalable, thus not all requested sizes will be available\n    /// to use. This needs to be taken into consideration when\n    /// setting the character size. If you need to display text\n    /// of a certain size, make sure the corresponding bitmap\n    /// font that supports that size is used.\n    ///\n    /// \\param string         Text assigned to the string\n    /// \\param font           Font used to draw the string\n    /// \\param characterSize  Base size of characters, in pixels\n    ///\n    ////////////////////////////////////////////////////////////\n    Text(const String& string, const Font& font, unsigned int characterSize = 30);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Set the text's string\n    ///\n    /// The \\a string argument is a sf::String, which can\n    /// automatically be constructed from standard string types.\n    /// So, the following calls are all valid:\n    /// \\code\n    /// text.setString(\"hello\");\n    /// text.setString(L\"hello\");\n    /// text.setString(std::string(\"hello\"));\n    /// text.setString(std::wstring(L\"hello\"));\n    /// \\endcode\n    /// A text's string is empty by default.\n    ///\n    /// \\param string New string\n    ///\n    /// \\see getString\n    ///\n    ////////////////////////////////////////////////////////////\n    void setString(const String& string);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Set the text's font\n    ///\n    /// The \\a font argument refers to a font that must\n    /// exist as long as the text uses it. Indeed, the text\n    /// doesn't store its own copy of the font, but rather keeps\n    /// a pointer to the one that you passed to this function.\n    /// If the font is destroyed and the text tries to\n    /// use it, the behavior is undefined.\n    ///\n    /// \\param font New font\n    ///\n    /// \\see getFont\n    ///\n    ////////////////////////////////////////////////////////////\n    void setFont(const Font& font);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Set the character size\n    ///\n    /// The default size is 30.\n    ///\n    /// Note that if the used font is a bitmap font, it is not\n    /// scalable, thus not all requested sizes will be available\n    /// to use. This needs to be taken into consideration when\n    /// setting the character size. If you need to display text\n    /// of a certain size, make sure the corresponding bitmap\n    /// font that supports that size is used.\n    ///\n    /// \\param size New character size, in pixels\n    ///\n    /// \\see getCharacterSize\n    ///\n    ////////////////////////////////////////////////////////////\n    void setCharacterSize(unsigned int size);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Set the text's style\n    ///\n    /// You can pass a combination of one or more styles, for\n    /// example sf::Text::Bold | sf::Text::Italic.\n    /// The default style is sf::Text::Regular.\n    ///\n    /// \\param style New style\n    ///\n    /// \\see getStyle\n    ///\n    ////////////////////////////////////////////////////////////\n    void setStyle(Uint32 style);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Set the fill color of the text\n    ///\n    /// By default, the text's fill color is opaque white.\n    /// Setting the fill color to a transparent color with an outline\n    /// will cause the outline to be displayed in the fill area of the text.\n    ///\n    /// \\param color New fill color of the text\n    ///\n    /// \\see getFillColor\n    ///\n    /// \\deprecated There is now fill and outline colors instead\n    /// of a single global color.\n    /// Use setFillColor() or setOutlineColor() instead.\n    ///\n    ////////////////////////////////////////////////////////////\n    SFML_DEPRECATED void setColor(const Color& color);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Set the fill color of the text\n    ///\n    /// By default, the text's fill color is opaque white.\n    /// Setting the fill color to a transparent color with an outline\n    /// will cause the outline to be displayed in the fill area of the text.\n    ///\n    /// \\param color New fill color of the text\n    ///\n    /// \\see getFillColor\n    ///\n    ////////////////////////////////////////////////////////////\n    void setFillColor(const Color& color);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Set the outline color of the text\n    ///\n    /// By default, the text's outline color is opaque black.\n    ///\n    /// \\param color New outline color of the text\n    ///\n    /// \\see getOutlineColor\n    ///\n    ////////////////////////////////////////////////////////////\n    void setOutlineColor(const Color& color);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Set the thickness of the text's outline\n    ///\n    /// By default, the outline thickness is 0.\n    ///\n    /// Be aware that using a negative value for the outline\n    /// thickness will cause distorted rendering.\n    ///\n    /// \\param thickness New outline thickness, in pixels\n    ///\n    /// \\see getOutlineThickness\n    ///\n    ////////////////////////////////////////////////////////////\n    void setOutlineThickness(float thickness);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the text's string\n    ///\n    /// The returned string is a sf::String, which can automatically\n    /// be converted to standard string types. So, the following\n    /// lines of code are all valid:\n    /// \\code\n    /// sf::String   s1 = text.getString();\n    /// std::string  s2 = text.getString();\n    /// std::wstring s3 = text.getString();\n    /// \\endcode\n    ///\n    /// \\return Text's string\n    ///\n    /// \\see setString\n    ///\n    ////////////////////////////////////////////////////////////\n    const String& getString() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the text's font\n    ///\n    /// If the text has no font attached, a NULL pointer is returned.\n    /// The returned pointer is const, which means that you\n    /// cannot modify the font when you get it from this function.\n    ///\n    /// \\return Pointer to the text's font\n    ///\n    /// \\see setFont\n    ///\n    ////////////////////////////////////////////////////////////\n    const Font* getFont() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the character size\n    ///\n    /// \\return Size of the characters, in pixels\n    ///\n    /// \\see setCharacterSize\n    ///\n    ////////////////////////////////////////////////////////////\n    unsigned int getCharacterSize() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the text's style\n    ///\n    /// \\return Text's style\n    ///\n    /// \\see setStyle\n    ///\n    ////////////////////////////////////////////////////////////\n    Uint32 getStyle() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the fill color of the text\n    ///\n    /// \\return Fill color of the text\n    ///\n    /// \\see setFillColor\n    ///\n    /// \\deprecated There is now fill and outline colors instead\n    /// of a single global color.\n    /// Use getFillColor() or getOutlineColor() instead.\n    ///\n    ////////////////////////////////////////////////////////////\n    SFML_DEPRECATED const Color& getColor() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the fill color of the text\n    ///\n    /// \\return Fill color of the text\n    ///\n    /// \\see setFillColor\n    ///\n    ////////////////////////////////////////////////////////////\n    const Color& getFillColor() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the outline color of the text\n    ///\n    /// \\return Outline color of the text\n    ///\n    /// \\see setOutlineColor\n    ///\n    ////////////////////////////////////////////////////////////\n    const Color& getOutlineColor() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the outline thickness of the text\n    ///\n    /// \\return Outline thickness of the text, in pixels\n    ///\n    /// \\see setOutlineThickness\n    ///\n    ////////////////////////////////////////////////////////////\n    float getOutlineThickness() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Return the position of the \\a index-th character\n    ///\n    /// This function computes the visual position of a character\n    /// from its index in the string. The returned position is\n    /// in global coordinates (translation, rotation, scale and\n    /// origin are applied).\n    /// If \\a index is out of range, the position of the end of\n    /// the string is returned.\n    ///\n    /// \\param index Index of the character\n    ///\n    /// \\return Position of the character\n    ///\n    ////////////////////////////////////////////////////////////\n    Vector2f findCharacterPos(std::size_t index) const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the local bounding rectangle of the entity\n    ///\n    /// The returned rectangle is in local coordinates, which means\n    /// that it ignores the transformations (translation, rotation,\n    /// scale, ...) that are applied to the entity.\n    /// In other words, this function returns the bounds of the\n    /// entity in the entity's coordinate system.\n    ///\n    /// \\return Local bounding rectangle of the entity\n    ///\n    ////////////////////////////////////////////////////////////\n    FloatRect getLocalBounds() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the global bounding rectangle of the entity\n    ///\n    /// The returned rectangle is in global coordinates, which means\n    /// that it takes into account the transformations (translation,\n    /// rotation, scale, ...) that are applied to the entity.\n    /// In other words, this function returns the bounds of the\n    /// text in the global 2D world's coordinate system.\n    ///\n    /// \\return Global bounding rectangle of the entity\n    ///\n    ////////////////////////////////////////////////////////////\n    FloatRect getGlobalBounds() const;\n\nprivate:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Draw the text to a render target\n    ///\n    /// \\param target Render target to draw to\n    /// \\param states Current render states\n    ///\n    ////////////////////////////////////////////////////////////\n    virtual void draw(RenderTarget& target, RenderStates states) const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Make sure the text's geometry is updated\n    ///\n    /// All the attributes related to rendering are cached, such\n    /// that the geometry is only updated when necessary.\n    ///\n    ////////////////////////////////////////////////////////////\n    void ensureGeometryUpdate() const;\n\n    ////////////////////////////////////////////////////////////\n    // Member data\n    ////////////////////////////////////////////////////////////\n    String              m_string;             ///< String to display\n    const Font*         m_font;               ///< Font used to display the string\n    unsigned int        m_characterSize;      ///< Base size of characters, in pixels\n    Uint32              m_style;              ///< Text style (see Style enum)\n    Color               m_fillColor;          ///< Text fill color\n    Color               m_outlineColor;       ///< Text outline color\n    float               m_outlineThickness;   ///< Thickness of the text's outline\n    mutable VertexArray m_vertices;           ///< Vertex array containing the fill geometry\n    mutable VertexArray m_outlineVertices;    ///< Vertex array containing the outline geometry\n    mutable FloatRect   m_bounds;             ///< Bounding rectangle of the text (in local coordinates)\n    mutable bool        m_geometryNeedUpdate; ///< Does the geometry need to be recomputed?\n};\n\n} // namespace sf\n\n\n#endif // SFML_TEXT_HPP\n\n\n////////////////////////////////////////////////////////////\n/// \\class sf::Text\n/// \\ingroup graphics\n///\n/// sf::Text is a drawable class that allows to easily display\n/// some text with custom style and color on a render target.\n///\n/// It inherits all the functions from sf::Transformable:\n/// position, rotation, scale, origin. It also adds text-specific\n/// properties such as the font to use, the character size,\n/// the font style (bold, italic, underlined, strike through), the\n/// global color and the text to display of course.\n/// It also provides convenience functions to calculate the\n/// graphical size of the text, or to get the global position\n/// of a given character.\n///\n/// sf::Text works in combination with the sf::Font class, which\n/// loads and provides the glyphs (visual characters) of a given font.\n///\n/// The separation of sf::Font and sf::Text allows more flexibility\n/// and better performances: indeed a sf::Font is a heavy resource,\n/// and any operation on it is slow (often too slow for real-time\n/// applications). On the other side, a sf::Text is a lightweight\n/// object which can combine the glyphs data and metrics of a sf::Font\n/// to display any text on a render target.\n///\n/// It is important to note that the sf::Text instance doesn't\n/// copy the font that it uses, it only keeps a reference to it.\n/// Thus, a sf::Font must not be destructed while it is\n/// used by a sf::Text (i.e. never write a function that\n/// uses a local sf::Font instance for creating a text).\n///\n/// See also the note on coordinates and undistorted rendering in sf::Transformable.\n///\n/// Usage example:\n/// \\code\n/// // Declare and load a font\n/// sf::Font font;\n/// font.loadFromFile(\"arial.ttf\");\n///\n/// // Create a text\n/// sf::Text text(\"hello\", font);\n/// text.setCharacterSize(30);\n/// text.setStyle(sf::Text::Bold);\n/// text.setColor(sf::Color::Red);\n///\n/// // Draw it\n/// window.draw(text);\n/// \\endcode\n///\n/// \\see sf::Font, sf::Transformable\n///\n////////////////////////////////////////////////////////////\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/Graphics/Texture.hpp",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n#ifndef SFML_TEXTURE_HPP\n#define SFML_TEXTURE_HPP\n\n////////////////////////////////////////////////////////////\n// Headers\n////////////////////////////////////////////////////////////\n#include <SFML/Graphics/Export.hpp>\n#include <SFML/Graphics/Image.hpp>\n#include <SFML/Window/GlResource.hpp>\n\n\nnamespace sf\n{\nclass Window;\nclass RenderTarget;\nclass RenderTexture;\nclass InputStream;\n\n////////////////////////////////////////////////////////////\n/// \\brief Image living on the graphics card that can be used for drawing\n///\n////////////////////////////////////////////////////////////\nclass SFML_GRAPHICS_API Texture : GlResource\n{\npublic:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Types of texture coordinates that can be used for rendering\n    ///\n    ////////////////////////////////////////////////////////////\n    enum CoordinateType\n    {\n        Normalized, ///< Texture coordinates in range [0 .. 1]\n        Pixels      ///< Texture coordinates in range [0 .. size]\n    };\n\npublic:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Default constructor\n    ///\n    /// Creates an empty texture.\n    ///\n    ////////////////////////////////////////////////////////////\n    Texture();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Copy constructor\n    ///\n    /// \\param copy instance to copy\n    ///\n    ////////////////////////////////////////////////////////////\n    Texture(const Texture& copy);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Destructor\n    ///\n    ////////////////////////////////////////////////////////////\n    ~Texture();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Create the texture\n    ///\n    /// If this function fails, the texture is left unchanged.\n    ///\n    /// \\param width  Width of the texture\n    /// \\param height Height of the texture\n    ///\n    /// \\return True if creation was successful\n    ///\n    ////////////////////////////////////////////////////////////\n    bool create(unsigned int width, unsigned int height);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Load the texture from a file on disk\n    ///\n    /// This function is a shortcut for the following code:\n    /// \\code\n    /// sf::Image image;\n    /// image.loadFromFile(filename);\n    /// texture.loadFromImage(image, area);\n    /// \\endcode\n    ///\n    /// The \\a area argument can be used to load only a sub-rectangle\n    /// of the whole image. If you want the entire image then leave\n    /// the default value (which is an empty IntRect).\n    /// If the \\a area rectangle crosses the bounds of the image, it\n    /// is adjusted to fit the image size.\n    ///\n    /// The maximum size for a texture depends on the graphics\n    /// driver and can be retrieved with the getMaximumSize function.\n    ///\n    /// If this function fails, the texture is left unchanged.\n    ///\n    /// \\param filename Path of the image file to load\n    /// \\param area     Area of the image to load\n    ///\n    /// \\return True if loading was successful\n    ///\n    /// \\see loadFromMemory, loadFromStream, loadFromImage\n    ///\n    ////////////////////////////////////////////////////////////\n    bool loadFromFile(const std::string& filename, const IntRect& area = IntRect());\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Load the texture from a file in memory\n    ///\n    /// This function is a shortcut for the following code:\n    /// \\code\n    /// sf::Image image;\n    /// image.loadFromMemory(data, size);\n    /// texture.loadFromImage(image, area);\n    /// \\endcode\n    ///\n    /// The \\a area argument can be used to load only a sub-rectangle\n    /// of the whole image. If you want the entire image then leave\n    /// the default value (which is an empty IntRect).\n    /// If the \\a area rectangle crosses the bounds of the image, it\n    /// is adjusted to fit the image size.\n    ///\n    /// The maximum size for a texture depends on the graphics\n    /// driver and can be retrieved with the getMaximumSize function.\n    ///\n    /// If this function fails, the texture is left unchanged.\n    ///\n    /// \\param data Pointer to the file data in memory\n    /// \\param size Size of the data to load, in bytes\n    /// \\param area Area of the image to load\n    ///\n    /// \\return True if loading was successful\n    ///\n    /// \\see loadFromFile, loadFromStream, loadFromImage\n    ///\n    ////////////////////////////////////////////////////////////\n    bool loadFromMemory(const void* data, std::size_t size, const IntRect& area = IntRect());\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Load the texture from a custom stream\n    ///\n    /// This function is a shortcut for the following code:\n    /// \\code\n    /// sf::Image image;\n    /// image.loadFromStream(stream);\n    /// texture.loadFromImage(image, area);\n    /// \\endcode\n    ///\n    /// The \\a area argument can be used to load only a sub-rectangle\n    /// of the whole image. If you want the entire image then leave\n    /// the default value (which is an empty IntRect).\n    /// If the \\a area rectangle crosses the bounds of the image, it\n    /// is adjusted to fit the image size.\n    ///\n    /// The maximum size for a texture depends on the graphics\n    /// driver and can be retrieved with the getMaximumSize function.\n    ///\n    /// If this function fails, the texture is left unchanged.\n    ///\n    /// \\param stream Source stream to read from\n    /// \\param area   Area of the image to load\n    ///\n    /// \\return True if loading was successful\n    ///\n    /// \\see loadFromFile, loadFromMemory, loadFromImage\n    ///\n    ////////////////////////////////////////////////////////////\n    bool loadFromStream(InputStream& stream, const IntRect& area = IntRect());\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Load the texture from an image\n    ///\n    /// The \\a area argument can be used to load only a sub-rectangle\n    /// of the whole image. If you want the entire image then leave\n    /// the default value (which is an empty IntRect).\n    /// If the \\a area rectangle crosses the bounds of the image, it\n    /// is adjusted to fit the image size.\n    ///\n    /// The maximum size for a texture depends on the graphics\n    /// driver and can be retrieved with the getMaximumSize function.\n    ///\n    /// If this function fails, the texture is left unchanged.\n    ///\n    /// \\param image Image to load into the texture\n    /// \\param area  Area of the image to load\n    ///\n    /// \\return True if loading was successful\n    ///\n    /// \\see loadFromFile, loadFromMemory\n    ///\n    ////////////////////////////////////////////////////////////\n    bool loadFromImage(const Image& image, const IntRect& area = IntRect());\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Return the size of the texture\n    ///\n    /// \\return Size in pixels\n    ///\n    ////////////////////////////////////////////////////////////\n    Vector2u getSize() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Copy the texture pixels to an image\n    ///\n    /// This function performs a slow operation that downloads\n    /// the texture's pixels from the graphics card and copies\n    /// them to a new image, potentially applying transformations\n    /// to pixels if necessary (texture may be padded or flipped).\n    ///\n    /// \\return Image containing the texture's pixels\n    ///\n    /// \\see loadFromImage\n    ///\n    ////////////////////////////////////////////////////////////\n    Image copyToImage() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Update the whole texture from an array of pixels\n    ///\n    /// The \\a pixel array is assumed to have the same size as\n    /// the \\a area rectangle, and to contain 32-bits RGBA pixels.\n    ///\n    /// No additional check is performed on the size of the pixel\n    /// array, passing invalid arguments will lead to an undefined\n    /// behavior.\n    ///\n    /// This function does nothing if \\a pixels is null or if the\n    /// texture was not previously created.\n    ///\n    /// \\param pixels Array of pixels to copy to the texture\n    ///\n    ////////////////////////////////////////////////////////////\n    void update(const Uint8* pixels);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Update a part of the texture from an array of pixels\n    ///\n    /// The size of the \\a pixel array must match the \\a width and\n    /// \\a height arguments, and it must contain 32-bits RGBA pixels.\n    ///\n    /// No additional check is performed on the size of the pixel\n    /// array or the bounds of the area to update, passing invalid\n    /// arguments will lead to an undefined behavior.\n    ///\n    /// This function does nothing if \\a pixels is null or if the\n    /// texture was not previously created.\n    ///\n    /// \\param pixels Array of pixels to copy to the texture\n    /// \\param width  Width of the pixel region contained in \\a pixels\n    /// \\param height Height of the pixel region contained in \\a pixels\n    /// \\param x      X offset in the texture where to copy the source pixels\n    /// \\param y      Y offset in the texture where to copy the source pixels\n    ///\n    ////////////////////////////////////////////////////////////\n    void update(const Uint8* pixels, unsigned int width, unsigned int height, unsigned int x, unsigned int y);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Update the texture from an image\n    ///\n    /// Although the source image can be smaller than the texture,\n    /// this function is usually used for updating the whole texture.\n    /// The other overload, which has (x, y) additional arguments,\n    /// is more convenient for updating a sub-area of the texture.\n    ///\n    /// No additional check is performed on the size of the image,\n    /// passing an image bigger than the texture will lead to an\n    /// undefined behavior.\n    ///\n    /// This function does nothing if the texture was not\n    /// previously created.\n    ///\n    /// \\param image Image to copy to the texture\n    ///\n    ////////////////////////////////////////////////////////////\n    void update(const Image& image);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Update a part of the texture from an image\n    ///\n    /// No additional check is performed on the size of the image,\n    /// passing an invalid combination of image size and offset\n    /// will lead to an undefined behavior.\n    ///\n    /// This function does nothing if the texture was not\n    /// previously created.\n    ///\n    /// \\param image Image to copy to the texture\n    /// \\param x     X offset in the texture where to copy the source image\n    /// \\param y     Y offset in the texture where to copy the source image\n    ///\n    ////////////////////////////////////////////////////////////\n    void update(const Image& image, unsigned int x, unsigned int y);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Update the texture from the contents of a window\n    ///\n    /// Although the source window can be smaller than the texture,\n    /// this function is usually used for updating the whole texture.\n    /// The other overload, which has (x, y) additional arguments,\n    /// is more convenient for updating a sub-area of the texture.\n    ///\n    /// No additional check is performed on the size of the window,\n    /// passing a window bigger than the texture will lead to an\n    /// undefined behavior.\n    ///\n    /// This function does nothing if either the texture or the window\n    /// was not previously created.\n    ///\n    /// \\param window Window to copy to the texture\n    ///\n    ////////////////////////////////////////////////////////////\n    void update(const Window& window);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Update a part of the texture from the contents of a window\n    ///\n    /// No additional check is performed on the size of the window,\n    /// passing an invalid combination of window size and offset\n    /// will lead to an undefined behavior.\n    ///\n    /// This function does nothing if either the texture or the window\n    /// was not previously created.\n    ///\n    /// \\param window Window to copy to the texture\n    /// \\param x      X offset in the texture where to copy the source window\n    /// \\param y      Y offset in the texture where to copy the source window\n    ///\n    ////////////////////////////////////////////////////////////\n    void update(const Window& window, unsigned int x, unsigned int y);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Enable or disable the smooth filter\n    ///\n    /// When the filter is activated, the texture appears smoother\n    /// so that pixels are less noticeable. However if you want\n    /// the texture to look exactly the same as its source file,\n    /// you should leave it disabled.\n    /// The smooth filter is disabled by default.\n    ///\n    /// \\param smooth True to enable smoothing, false to disable it\n    ///\n    /// \\see isSmooth\n    ///\n    ////////////////////////////////////////////////////////////\n    void setSmooth(bool smooth);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Tell whether the smooth filter is enabled or not\n    ///\n    /// \\return True if smoothing is enabled, false if it is disabled\n    ///\n    /// \\see setSmooth\n    ///\n    ////////////////////////////////////////////////////////////\n    bool isSmooth() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Enable or disable conversion from sRGB\n    ///\n    /// When providing texture data from an image file or memory, it can\n    /// either be stored in a linear color space or an sRGB color space.\n    /// Most digital images account for gamma correction already, so they\n    /// would need to be \"uncorrected\" back to linear color space before\n    /// being processed by the hardware. The hardware can automatically\n    /// convert it from the sRGB color space to a linear color space when\n    /// it gets sampled. When the rendered image gets output to the final\n    /// framebuffer, it gets converted back to sRGB.\n    ///\n    /// After enabling or disabling sRGB conversion, make sure to reload\n    /// the texture data in order for the setting to take effect.\n    ///\n    /// This option is only useful in conjunction with an sRGB capable\n    /// framebuffer. This can be requested during window creation.\n    ///\n    /// \\param sRgb True to enable sRGB conversion, false to disable it\n    ///\n    /// \\see isSrgb\n    ///\n    ////////////////////////////////////////////////////////////\n    void setSrgb(bool sRgb);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Tell whether the texture source is converted from sRGB or not\n    ///\n    /// \\return True if the texture source is converted from sRGB, false if not\n    ///\n    /// \\see setSrgb\n    ///\n    ////////////////////////////////////////////////////////////\n    bool isSrgb() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Enable or disable repeating\n    ///\n    /// Repeating is involved when using texture coordinates\n    /// outside the texture rectangle [0, 0, width, height].\n    /// In this case, if repeat mode is enabled, the whole texture\n    /// will be repeated as many times as needed to reach the\n    /// coordinate (for example, if the X texture coordinate is\n    /// 3 * width, the texture will be repeated 3 times).\n    /// If repeat mode is disabled, the \"extra space\" will instead\n    /// be filled with border pixels.\n    /// Warning: on very old graphics cards, white pixels may appear\n    /// when the texture is repeated. With such cards, repeat mode\n    /// can be used reliably only if the texture has power-of-two\n    /// dimensions (such as 256x128).\n    /// Repeating is disabled by default.\n    ///\n    /// \\param repeated True to repeat the texture, false to disable repeating\n    ///\n    /// \\see isRepeated\n    ///\n    ////////////////////////////////////////////////////////////\n    void setRepeated(bool repeated);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Tell whether the texture is repeated or not\n    ///\n    /// \\return True if repeat mode is enabled, false if it is disabled\n    ///\n    /// \\see setRepeated\n    ///\n    ////////////////////////////////////////////////////////////\n    bool isRepeated() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Generate a mipmap using the current texture data\n    ///\n    /// Mipmaps are pre-computed chains of optimized textures. Each\n    /// level of texture in a mipmap is generated by halving each of\n    /// the previous level's dimensions. This is done until the final\n    /// level has the size of 1x1. The textures generated in this process may\n    /// make use of more advanced filters which might improve the visual quality\n    /// of textures when they are applied to objects much smaller than they are.\n    /// This is known as minification. Because fewer texels (texture elements)\n    /// have to be sampled from when heavily minified, usage of mipmaps\n    /// can also improve rendering performance in certain scenarios.\n    ///\n    /// Mipmap generation relies on the necessary OpenGL extension being\n    /// available. If it is unavailable or generation fails due to another\n    /// reason, this function will return false. Mipmap data is only valid from\n    /// the time it is generated until the next time the base level image is\n    /// modified, at which point this function will have to be called again to\n    /// regenerate it.\n    ///\n    /// \\return True if mipmap generation was successful, false if unsuccessful\n    ///\n    ////////////////////////////////////////////////////////////\n    bool generateMipmap();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Overload of assignment operator\n    ///\n    /// \\param right Instance to assign\n    ///\n    /// \\return Reference to self\n    ///\n    ////////////////////////////////////////////////////////////\n    Texture& operator =(const Texture& right);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the underlying OpenGL handle of the texture.\n    ///\n    /// You shouldn't need to use this function, unless you have\n    /// very specific stuff to implement that SFML doesn't support,\n    /// or implement a temporary workaround until a bug is fixed.\n    ///\n    /// \\return OpenGL handle of the texture or 0 if not yet created\n    ///\n    ////////////////////////////////////////////////////////////\n    unsigned int getNativeHandle() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Bind a texture for rendering\n    ///\n    /// This function is not part of the graphics API, it mustn't be\n    /// used when drawing SFML entities. It must be used only if you\n    /// mix sf::Texture with OpenGL code.\n    ///\n    /// \\code\n    /// sf::Texture t1, t2;\n    /// ...\n    /// sf::Texture::bind(&t1);\n    /// // draw OpenGL stuff that use t1...\n    /// sf::Texture::bind(&t2);\n    /// // draw OpenGL stuff that use t2...\n    /// sf::Texture::bind(NULL);\n    /// // draw OpenGL stuff that use no texture...\n    /// \\endcode\n    ///\n    /// The \\a coordinateType argument controls how texture\n    /// coordinates will be interpreted. If Normalized (the default), they\n    /// must be in range [0 .. 1], which is the default way of handling\n    /// texture coordinates with OpenGL. If Pixels, they must be given\n    /// in pixels (range [0 .. size]). This mode is used internally by\n    /// the graphics classes of SFML, it makes the definition of texture\n    /// coordinates more intuitive for the high-level API, users don't need\n    /// to compute normalized values.\n    ///\n    /// \\param texture Pointer to the texture to bind, can be null to use no texture\n    /// \\param coordinateType Type of texture coordinates to use\n    ///\n    ////////////////////////////////////////////////////////////\n    static void bind(const Texture* texture, CoordinateType coordinateType = Normalized);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the maximum texture size allowed\n    ///\n    /// This maximum size is defined by the graphics driver.\n    /// You can expect a value of 512 pixels for low-end graphics\n    /// card, and up to 8192 pixels or more for newer hardware.\n    ///\n    /// \\return Maximum size allowed for textures, in pixels\n    ///\n    ////////////////////////////////////////////////////////////\n    static unsigned int getMaximumSize();\n\nprivate:\n\n    friend class RenderTexture;\n    friend class RenderTarget;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get a valid image size according to hardware support\n    ///\n    /// This function checks whether the graphics driver supports\n    /// non power of two sizes or not, and adjusts the size\n    /// accordingly.\n    /// The returned size is greater than or equal to the original size.\n    ///\n    /// \\param size size to convert\n    ///\n    /// \\return Valid nearest size (greater than or equal to specified size)\n    ///\n    ////////////////////////////////////////////////////////////\n    static unsigned int getValidSize(unsigned int size);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Invalidate the mipmap if one exists\n    ///\n    /// This also resets the texture's minifying function.\n    /// This function is mainly for internal use by RenderTexture.\n    ///\n    ////////////////////////////////////////////////////////////\n    void invalidateMipmap();\n\n    ////////////////////////////////////////////////////////////\n    // Member data\n    ////////////////////////////////////////////////////////////\n    Vector2u     m_size;          ///< Public texture size\n    Vector2u     m_actualSize;    ///< Actual texture size (can be greater than public size because of padding)\n    unsigned int m_texture;       ///< Internal texture identifier\n    bool         m_isSmooth;      ///< Status of the smooth filter\n    bool         m_sRgb;          ///< Should the texture source be converted from sRGB?\n    bool         m_isRepeated;    ///< Is the texture in repeat mode?\n    mutable bool m_pixelsFlipped; ///< To work around the inconsistency in Y orientation\n    bool         m_fboAttachment; ///< Is this texture owned by a framebuffer object?\n    bool         m_hasMipmap;     ///< Has the mipmap been generated?\n    Uint64       m_cacheId;       ///< Unique number that identifies the texture to the render target's cache\n};\n\n} // namespace sf\n\n\n#endif // SFML_TEXTURE_HPP\n\n////////////////////////////////////////////////////////////\n/// \\class sf::Texture\n/// \\ingroup graphics\n///\n/// sf::Texture stores pixels that can be drawn, with a sprite\n/// for example. A texture lives in the graphics card memory,\n/// therefore it is very fast to draw a texture to a render target,\n/// or copy a render target to a texture (the graphics card can\n/// access both directly).\n///\n/// Being stored in the graphics card memory has some drawbacks.\n/// A texture cannot be manipulated as freely as a sf::Image,\n/// you need to prepare the pixels first and then upload them\n/// to the texture in a single operation (see Texture::update).\n///\n/// sf::Texture makes it easy to convert from/to sf::Image, but\n/// keep in mind that these calls require transfers between\n/// the graphics card and the central memory, therefore they are\n/// slow operations.\n///\n/// A texture can be loaded from an image, but also directly\n/// from a file/memory/stream. The necessary shortcuts are defined\n/// so that you don't need an image first for the most common cases.\n/// However, if you want to perform some modifications on the pixels\n/// before creating the final texture, you can load your file to a\n/// sf::Image, do whatever you need with the pixels, and then call\n/// Texture::loadFromImage.\n///\n/// Since they live in the graphics card memory, the pixels of a texture\n/// cannot be accessed without a slow copy first. And they cannot be\n/// accessed individually. Therefore, if you need to read the texture's\n/// pixels (like for pixel-perfect collisions), it is recommended to\n/// store the collision information separately, for example in an array\n/// of booleans.\n///\n/// Like sf::Image, sf::Texture can handle a unique internal\n/// representation of pixels, which is RGBA 32 bits. This means\n/// that a pixel must be composed of 8 bits red, green, blue and\n/// alpha channels -- just like a sf::Color.\n///\n/// Usage example:\n/// \\code\n/// // This example shows the most common use of sf::Texture:\n/// // drawing a sprite\n///\n/// // Load a texture from a file\n/// sf::Texture texture;\n/// if (!texture.loadFromFile(\"texture.png\"))\n///     return -1;\n///\n/// // Assign it to a sprite\n/// sf::Sprite sprite;\n/// sprite.setTexture(texture);\n///\n/// // Draw the textured sprite\n/// window.draw(sprite);\n/// \\endcode\n///\n/// \\code\n/// // This example shows another common use of sf::Texture:\n/// // streaming real-time data, like video frames\n///\n/// // Create an empty texture\n/// sf::Texture texture;\n/// if (!texture.create(640, 480))\n///     return -1;\n///\n/// // Create a sprite that will display the texture\n/// sf::Sprite sprite(texture);\n///\n/// while (...) // the main loop\n/// {\n///     ...\n///\n///     // update the texture\n///     sf::Uint8* pixels = ...; // get a fresh chunk of pixels (the next frame of a movie, for example)\n///     texture.update(pixels);\n///\n///     // draw it\n///     window.draw(sprite);\n///\n///     ...\n/// }\n///\n/// \\endcode\n///\n/// Like sf::Shader that can be used as a raw OpenGL shader,\n/// sf::Texture can also be used directly as a raw texture for\n/// custom OpenGL geometry.\n/// \\code\n/// sf::Texture::bind(&texture);\n/// ... render OpenGL geometry ...\n/// sf::Texture::bind(NULL);\n/// \\endcode\n///\n/// \\see sf::Sprite, sf::Image, sf::RenderTexture\n///\n////////////////////////////////////////////////////////////\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/Graphics/Transform.hpp",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n#ifndef SFML_TRANSFORM_HPP\n#define SFML_TRANSFORM_HPP\n\n////////////////////////////////////////////////////////////\n// Headers\n////////////////////////////////////////////////////////////\n#include <SFML/Graphics/Export.hpp>\n#include <SFML/Graphics/Rect.hpp>\n#include <SFML/System/Vector2.hpp>\n\n\nnamespace sf\n{\n////////////////////////////////////////////////////////////\n/// \\brief Define a 3x3 transform matrix\n///\n////////////////////////////////////////////////////////////\nclass SFML_GRAPHICS_API Transform\n{\npublic:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Default constructor\n    ///\n    /// Creates an identity transform (a transform that does nothing).\n    ///\n    ////////////////////////////////////////////////////////////\n    Transform();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Construct a transform from a 3x3 matrix\n    ///\n    /// \\param a00 Element (0, 0) of the matrix\n    /// \\param a01 Element (0, 1) of the matrix\n    /// \\param a02 Element (0, 2) of the matrix\n    /// \\param a10 Element (1, 0) of the matrix\n    /// \\param a11 Element (1, 1) of the matrix\n    /// \\param a12 Element (1, 2) of the matrix\n    /// \\param a20 Element (2, 0) of the matrix\n    /// \\param a21 Element (2, 1) of the matrix\n    /// \\param a22 Element (2, 2) of the matrix\n    ///\n    ////////////////////////////////////////////////////////////\n    Transform(float a00, float a01, float a02,\n              float a10, float a11, float a12,\n              float a20, float a21, float a22);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Return the transform as a 4x4 matrix\n    ///\n    /// This function returns a pointer to an array of 16 floats\n    /// containing the transform elements as a 4x4 matrix, which\n    /// is directly compatible with OpenGL functions.\n    ///\n    /// \\code\n    /// sf::Transform transform = ...;\n    /// glLoadMatrixf(transform.getMatrix());\n    /// \\endcode\n    ///\n    /// \\return Pointer to a 4x4 matrix\n    ///\n    ////////////////////////////////////////////////////////////\n    const float* getMatrix() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Return the inverse of the transform\n    ///\n    /// If the inverse cannot be computed, an identity transform\n    /// is returned.\n    ///\n    /// \\return A new transform which is the inverse of self\n    ///\n    ////////////////////////////////////////////////////////////\n    Transform getInverse() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Transform a 2D point\n    ///\n    /// \\param x X coordinate of the point to transform\n    /// \\param y Y coordinate of the point to transform\n    ///\n    /// \\return Transformed point\n    ///\n    ////////////////////////////////////////////////////////////\n    Vector2f transformPoint(float x, float y) const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Transform a 2D point\n    ///\n    /// \\param point Point to transform\n    ///\n    /// \\return Transformed point\n    ///\n    ////////////////////////////////////////////////////////////\n    Vector2f transformPoint(const Vector2f& point) const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Transform a rectangle\n    ///\n    /// Since SFML doesn't provide support for oriented rectangles,\n    /// the result of this function is always an axis-aligned\n    /// rectangle. Which means that if the transform contains a\n    /// rotation, the bounding rectangle of the transformed rectangle\n    /// is returned.\n    ///\n    /// \\param rectangle Rectangle to transform\n    ///\n    /// \\return Transformed rectangle\n    ///\n    ////////////////////////////////////////////////////////////\n    FloatRect transformRect(const FloatRect& rectangle) const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Combine the current transform with another one\n    ///\n    /// The result is a transform that is equivalent to applying\n    /// *this followed by \\a transform. Mathematically, it is\n    /// equivalent to a matrix multiplication.\n    ///\n    /// \\param transform Transform to combine with this transform\n    ///\n    /// \\return Reference to *this\n    ///\n    ////////////////////////////////////////////////////////////\n    Transform& combine(const Transform& transform);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Combine the current transform with a translation\n    ///\n    /// This function returns a reference to *this, so that calls\n    /// can be chained.\n    /// \\code\n    /// sf::Transform transform;\n    /// transform.translate(100, 200).rotate(45);\n    /// \\endcode\n    ///\n    /// \\param x Offset to apply on X axis\n    /// \\param y Offset to apply on Y axis\n    ///\n    /// \\return Reference to *this\n    ///\n    /// \\see rotate, scale\n    ///\n    ////////////////////////////////////////////////////////////\n    Transform& translate(float x, float y);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Combine the current transform with a translation\n    ///\n    /// This function returns a reference to *this, so that calls\n    /// can be chained.\n    /// \\code\n    /// sf::Transform transform;\n    /// transform.translate(sf::Vector2f(100, 200)).rotate(45);\n    /// \\endcode\n    ///\n    /// \\param offset Translation offset to apply\n    ///\n    /// \\return Reference to *this\n    ///\n    /// \\see rotate, scale\n    ///\n    ////////////////////////////////////////////////////////////\n    Transform& translate(const Vector2f& offset);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Combine the current transform with a rotation\n    ///\n    /// This function returns a reference to *this, so that calls\n    /// can be chained.\n    /// \\code\n    /// sf::Transform transform;\n    /// transform.rotate(90).translate(50, 20);\n    /// \\endcode\n    ///\n    /// \\param angle Rotation angle, in degrees\n    ///\n    /// \\return Reference to *this\n    ///\n    /// \\see translate, scale\n    ///\n    ////////////////////////////////////////////////////////////\n    Transform& rotate(float angle);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Combine the current transform with a rotation\n    ///\n    /// The center of rotation is provided for convenience as a second\n    /// argument, so that you can build rotations around arbitrary points\n    /// more easily (and efficiently) than the usual\n    /// translate(-center).rotate(angle).translate(center).\n    ///\n    /// This function returns a reference to *this, so that calls\n    /// can be chained.\n    /// \\code\n    /// sf::Transform transform;\n    /// transform.rotate(90, 8, 3).translate(50, 20);\n    /// \\endcode\n    ///\n    /// \\param angle Rotation angle, in degrees\n    /// \\param centerX X coordinate of the center of rotation\n    /// \\param centerY Y coordinate of the center of rotation\n    ///\n    /// \\return Reference to *this\n    ///\n    /// \\see translate, scale\n    ///\n    ////////////////////////////////////////////////////////////\n    Transform& rotate(float angle, float centerX, float centerY);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Combine the current transform with a rotation\n    ///\n    /// The center of rotation is provided for convenience as a second\n    /// argument, so that you can build rotations around arbitrary points\n    /// more easily (and efficiently) than the usual\n    /// translate(-center).rotate(angle).translate(center).\n    ///\n    /// This function returns a reference to *this, so that calls\n    /// can be chained.\n    /// \\code\n    /// sf::Transform transform;\n    /// transform.rotate(90, sf::Vector2f(8, 3)).translate(sf::Vector2f(50, 20));\n    /// \\endcode\n    ///\n    /// \\param angle Rotation angle, in degrees\n    /// \\param center Center of rotation\n    ///\n    /// \\return Reference to *this\n    ///\n    /// \\see translate, scale\n    ///\n    ////////////////////////////////////////////////////////////\n    Transform& rotate(float angle, const Vector2f& center);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Combine the current transform with a scaling\n    ///\n    /// This function returns a reference to *this, so that calls\n    /// can be chained.\n    /// \\code\n    /// sf::Transform transform;\n    /// transform.scale(2, 1).rotate(45);\n    /// \\endcode\n    ///\n    /// \\param scaleX Scaling factor on the X axis\n    /// \\param scaleY Scaling factor on the Y axis\n    ///\n    /// \\return Reference to *this\n    ///\n    /// \\see translate, rotate\n    ///\n    ////////////////////////////////////////////////////////////\n    Transform& scale(float scaleX, float scaleY);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Combine the current transform with a scaling\n    ///\n    /// The center of scaling is provided for convenience as a second\n    /// argument, so that you can build scaling around arbitrary points\n    /// more easily (and efficiently) than the usual\n    /// translate(-center).scale(factors).translate(center).\n    ///\n    /// This function returns a reference to *this, so that calls\n    /// can be chained.\n    /// \\code\n    /// sf::Transform transform;\n    /// transform.scale(2, 1, 8, 3).rotate(45);\n    /// \\endcode\n    ///\n    /// \\param scaleX Scaling factor on X axis\n    /// \\param scaleY Scaling factor on Y axis\n    /// \\param centerX X coordinate of the center of scaling\n    /// \\param centerY Y coordinate of the center of scaling\n    ///\n    /// \\return Reference to *this\n    ///\n    /// \\see translate, rotate\n    ///\n    ////////////////////////////////////////////////////////////\n    Transform& scale(float scaleX, float scaleY, float centerX, float centerY);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Combine the current transform with a scaling\n    ///\n    /// This function returns a reference to *this, so that calls\n    /// can be chained.\n    /// \\code\n    /// sf::Transform transform;\n    /// transform.scale(sf::Vector2f(2, 1)).rotate(45);\n    /// \\endcode\n    ///\n    /// \\param factors Scaling factors\n    ///\n    /// \\return Reference to *this\n    ///\n    /// \\see translate, rotate\n    ///\n    ////////////////////////////////////////////////////////////\n    Transform& scale(const Vector2f& factors);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Combine the current transform with a scaling\n    ///\n    /// The center of scaling is provided for convenience as a second\n    /// argument, so that you can build scaling around arbitrary points\n    /// more easily (and efficiently) than the usual\n    /// translate(-center).scale(factors).translate(center).\n    ///\n    /// This function returns a reference to *this, so that calls\n    /// can be chained.\n    /// \\code\n    /// sf::Transform transform;\n    /// transform.scale(sf::Vector2f(2, 1), sf::Vector2f(8, 3)).rotate(45);\n    /// \\endcode\n    ///\n    /// \\param factors Scaling factors\n    /// \\param center Center of scaling\n    ///\n    /// \\return Reference to *this\n    ///\n    /// \\see translate, rotate\n    ///\n    ////////////////////////////////////////////////////////////\n    Transform& scale(const Vector2f& factors, const Vector2f& center);\n\n    ////////////////////////////////////////////////////////////\n    // Static member data\n    ////////////////////////////////////////////////////////////\n    static const Transform Identity; ///< The identity transform (does nothing)\n\nprivate:\n\n    ////////////////////////////////////////////////////////////\n    // Member data\n    ////////////////////////////////////////////////////////////\n    float m_matrix[16]; ///< 4x4 matrix defining the transformation\n};\n\n////////////////////////////////////////////////////////////\n/// \\relates sf::Transform\n/// \\brief Overload of binary operator * to combine two transforms\n///\n/// This call is equivalent to calling Transform(left).combine(right).\n///\n/// \\param left Left operand (the first transform)\n/// \\param right Right operand (the second transform)\n///\n/// \\return New combined transform\n///\n////////////////////////////////////////////////////////////\nSFML_GRAPHICS_API Transform operator *(const Transform& left, const Transform& right);\n\n////////////////////////////////////////////////////////////\n/// \\relates sf::Transform\n/// \\brief Overload of binary operator *= to combine two transforms\n///\n/// This call is equivalent to calling left.combine(right).\n///\n/// \\param left Left operand (the first transform)\n/// \\param right Right operand (the second transform)\n///\n/// \\return The combined transform\n///\n////////////////////////////////////////////////////////////\nSFML_GRAPHICS_API Transform& operator *=(Transform& left, const Transform& right);\n\n////////////////////////////////////////////////////////////\n/// \\relates sf::Transform\n/// \\brief Overload of binary operator * to transform a point\n///\n/// This call is equivalent to calling left.transformPoint(right).\n///\n/// \\param left Left operand (the transform)\n/// \\param right Right operand (the point to transform)\n///\n/// \\return New transformed point\n///\n////////////////////////////////////////////////////////////\nSFML_GRAPHICS_API Vector2f operator *(const Transform& left, const Vector2f& right);\n\n} // namespace sf\n\n\n#endif // SFML_TRANSFORM_HPP\n\n\n////////////////////////////////////////////////////////////\n/// \\class sf::Transform\n/// \\ingroup graphics\n///\n/// A sf::Transform specifies how to translate, rotate, scale,\n/// shear, project, whatever things. In mathematical terms, it defines\n/// how to transform a coordinate system into another.\n///\n/// For example, if you apply a rotation transform to a sprite, the\n/// result will be a rotated sprite. And anything that is transformed\n/// by this rotation transform will be rotated the same way, according\n/// to its initial position.\n///\n/// Transforms are typically used for drawing. But they can also be\n/// used for any computation that requires to transform points between\n/// the local and global coordinate systems of an entity (like collision\n/// detection).\n///\n/// Example:\n/// \\code\n/// // define a translation transform\n/// sf::Transform translation;\n/// translation.translate(20, 50);\n///\n/// // define a rotation transform\n/// sf::Transform rotation;\n/// rotation.rotate(45);\n///\n/// // combine them\n/// sf::Transform transform = translation * rotation;\n///\n/// // use the result to transform stuff...\n/// sf::Vector2f point = transform.transformPoint(10, 20);\n/// sf::FloatRect rect = transform.transformRect(sf::FloatRect(0, 0, 10, 100));\n/// \\endcode\n///\n/// \\see sf::Transformable, sf::RenderStates\n///\n////////////////////////////////////////////////////////////\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/Graphics/Transformable.hpp",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n#ifndef SFML_TRANSFORMABLE_HPP\n#define SFML_TRANSFORMABLE_HPP\n\n////////////////////////////////////////////////////////////\n// Headers\n////////////////////////////////////////////////////////////\n#include <SFML/Graphics/Export.hpp>\n#include <SFML/Graphics/Transform.hpp>\n\n\nnamespace sf\n{\n////////////////////////////////////////////////////////////\n/// \\brief Decomposed transform defined by a position, a rotation and a scale\n///\n////////////////////////////////////////////////////////////\nclass SFML_GRAPHICS_API Transformable\n{\npublic:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Default constructor\n    ///\n    ////////////////////////////////////////////////////////////\n    Transformable();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Virtual destructor\n    ///\n    ////////////////////////////////////////////////////////////\n    virtual ~Transformable();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief set the position of the object\n    ///\n    /// This function completely overwrites the previous position.\n    /// See the move function to apply an offset based on the previous position instead.\n    /// The default position of a transformable object is (0, 0).\n    ///\n    /// \\param x X coordinate of the new position\n    /// \\param y Y coordinate of the new position\n    ///\n    /// \\see move, getPosition\n    ///\n    ////////////////////////////////////////////////////////////\n    void setPosition(float x, float y);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief set the position of the object\n    ///\n    /// This function completely overwrites the previous position.\n    /// See the move function to apply an offset based on the previous position instead.\n    /// The default position of a transformable object is (0, 0).\n    ///\n    /// \\param position New position\n    ///\n    /// \\see move, getPosition\n    ///\n    ////////////////////////////////////////////////////////////\n    void setPosition(const Vector2f& position);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief set the orientation of the object\n    ///\n    /// This function completely overwrites the previous rotation.\n    /// See the rotate function to add an angle based on the previous rotation instead.\n    /// The default rotation of a transformable object is 0.\n    ///\n    /// \\param angle New rotation, in degrees\n    ///\n    /// \\see rotate, getRotation\n    ///\n    ////////////////////////////////////////////////////////////\n    void setRotation(float angle);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief set the scale factors of the object\n    ///\n    /// This function completely overwrites the previous scale.\n    /// See the scale function to add a factor based on the previous scale instead.\n    /// The default scale of a transformable object is (1, 1).\n    ///\n    /// \\param factorX New horizontal scale factor\n    /// \\param factorY New vertical scale factor\n    ///\n    /// \\see scale, getScale\n    ///\n    ////////////////////////////////////////////////////////////\n    void setScale(float factorX, float factorY);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief set the scale factors of the object\n    ///\n    /// This function completely overwrites the previous scale.\n    /// See the scale function to add a factor based on the previous scale instead.\n    /// The default scale of a transformable object is (1, 1).\n    ///\n    /// \\param factors New scale factors\n    ///\n    /// \\see scale, getScale\n    ///\n    ////////////////////////////////////////////////////////////\n    void setScale(const Vector2f& factors);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief set the local origin of the object\n    ///\n    /// The origin of an object defines the center point for\n    /// all transformations (position, scale, rotation).\n    /// The coordinates of this point must be relative to the\n    /// top-left corner of the object, and ignore all\n    /// transformations (position, scale, rotation).\n    /// The default origin of a transformable object is (0, 0).\n    ///\n    /// \\param x X coordinate of the new origin\n    /// \\param y Y coordinate of the new origin\n    ///\n    /// \\see getOrigin\n    ///\n    ////////////////////////////////////////////////////////////\n    void setOrigin(float x, float y);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief set the local origin of the object\n    ///\n    /// The origin of an object defines the center point for\n    /// all transformations (position, scale, rotation).\n    /// The coordinates of this point must be relative to the\n    /// top-left corner of the object, and ignore all\n    /// transformations (position, scale, rotation).\n    /// The default origin of a transformable object is (0, 0).\n    ///\n    /// \\param origin New origin\n    ///\n    /// \\see getOrigin\n    ///\n    ////////////////////////////////////////////////////////////\n    void setOrigin(const Vector2f& origin);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief get the position of the object\n    ///\n    /// \\return Current position\n    ///\n    /// \\see setPosition\n    ///\n    ////////////////////////////////////////////////////////////\n    const Vector2f& getPosition() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief get the orientation of the object\n    ///\n    /// The rotation is always in the range [0, 360].\n    ///\n    /// \\return Current rotation, in degrees\n    ///\n    /// \\see setRotation\n    ///\n    ////////////////////////////////////////////////////////////\n    float getRotation() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief get the current scale of the object\n    ///\n    /// \\return Current scale factors\n    ///\n    /// \\see setScale\n    ///\n    ////////////////////////////////////////////////////////////\n    const Vector2f& getScale() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief get the local origin of the object\n    ///\n    /// \\return Current origin\n    ///\n    /// \\see setOrigin\n    ///\n    ////////////////////////////////////////////////////////////\n    const Vector2f& getOrigin() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Move the object by a given offset\n    ///\n    /// This function adds to the current position of the object,\n    /// unlike setPosition which overwrites it.\n    /// Thus, it is equivalent to the following code:\n    /// \\code\n    /// sf::Vector2f pos = object.getPosition();\n    /// object.setPosition(pos.x + offsetX, pos.y + offsetY);\n    /// \\endcode\n    ///\n    /// \\param offsetX X offset\n    /// \\param offsetY Y offset\n    ///\n    /// \\see setPosition\n    ///\n    ////////////////////////////////////////////////////////////\n    void move(float offsetX, float offsetY);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Move the object by a given offset\n    ///\n    /// This function adds to the current position of the object,\n    /// unlike setPosition which overwrites it.\n    /// Thus, it is equivalent to the following code:\n    /// \\code\n    /// object.setPosition(object.getPosition() + offset);\n    /// \\endcode\n    ///\n    /// \\param offset Offset\n    ///\n    /// \\see setPosition\n    ///\n    ////////////////////////////////////////////////////////////\n    void move(const Vector2f& offset);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Rotate the object\n    ///\n    /// This function adds to the current rotation of the object,\n    /// unlike setRotation which overwrites it.\n    /// Thus, it is equivalent to the following code:\n    /// \\code\n    /// object.setRotation(object.getRotation() + angle);\n    /// \\endcode\n    ///\n    /// \\param angle Angle of rotation, in degrees\n    ///\n    ////////////////////////////////////////////////////////////\n    void rotate(float angle);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Scale the object\n    ///\n    /// This function multiplies the current scale of the object,\n    /// unlike setScale which overwrites it.\n    /// Thus, it is equivalent to the following code:\n    /// \\code\n    /// sf::Vector2f scale = object.getScale();\n    /// object.setScale(scale.x * factorX, scale.y * factorY);\n    /// \\endcode\n    ///\n    /// \\param factorX Horizontal scale factor\n    /// \\param factorY Vertical scale factor\n    ///\n    /// \\see setScale\n    ///\n    ////////////////////////////////////////////////////////////\n    void scale(float factorX, float factorY);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Scale the object\n    ///\n    /// This function multiplies the current scale of the object,\n    /// unlike setScale which overwrites it.\n    /// Thus, it is equivalent to the following code:\n    /// \\code\n    /// sf::Vector2f scale = object.getScale();\n    /// object.setScale(scale.x * factor.x, scale.y * factor.y);\n    /// \\endcode\n    ///\n    /// \\param factor Scale factors\n    ///\n    /// \\see setScale\n    ///\n    ////////////////////////////////////////////////////////////\n    void scale(const Vector2f& factor);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief get the combined transform of the object\n    ///\n    /// \\return Transform combining the position/rotation/scale/origin of the object\n    ///\n    /// \\see getInverseTransform\n    ///\n    ////////////////////////////////////////////////////////////\n    const Transform& getTransform() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief get the inverse of the combined transform of the object\n    ///\n    /// \\return Inverse of the combined transformations applied to the object\n    ///\n    /// \\see getTransform\n    ///\n    ////////////////////////////////////////////////////////////\n    const Transform& getInverseTransform() const;\n\nprivate:\n\n    ////////////////////////////////////////////////////////////\n    // Member data\n    ////////////////////////////////////////////////////////////\n    Vector2f          m_origin;                     ///< Origin of translation/rotation/scaling of the object\n    Vector2f          m_position;                   ///< Position of the object in the 2D world\n    float             m_rotation;                   ///< Orientation of the object, in degrees\n    Vector2f          m_scale;                      ///< Scale of the object\n    mutable Transform m_transform;                  ///< Combined transformation of the object\n    mutable bool      m_transformNeedUpdate;        ///< Does the transform need to be recomputed?\n    mutable Transform m_inverseTransform;           ///< Combined transformation of the object\n    mutable bool      m_inverseTransformNeedUpdate; ///< Does the transform need to be recomputed?\n};\n\n} // namespace sf\n\n\n#endif // SFML_TRANSFORMABLE_HPP\n\n\n////////////////////////////////////////////////////////////\n/// \\class sf::Transformable\n/// \\ingroup graphics\n///\n/// This class is provided for convenience, on top of sf::Transform.\n///\n/// sf::Transform, as a low-level class, offers a great level of\n/// flexibility but it is not always convenient to manage. Indeed,\n/// one can easily combine any kind of operation, such as a translation\n/// followed by a rotation followed by a scaling, but once the result\n/// transform is built, there's no way to go backward and, let's say,\n/// change only the rotation without modifying the translation and scaling.\n/// The entire transform must be recomputed, which means that you\n/// need to retrieve the initial translation and scale factors as\n/// well, and combine them the same way you did before updating the\n/// rotation. This is a tedious operation, and it requires to store\n/// all the individual components of the final transform.\n///\n/// That's exactly what sf::Transformable was written for: it hides\n/// these variables and the composed transform behind an easy to use\n/// interface. You can set or get any of the individual components\n/// without worrying about the others. It also provides the composed\n/// transform (as a sf::Transform), and keeps it up-to-date.\n///\n/// In addition to the position, rotation and scale, sf::Transformable\n/// provides an \"origin\" component, which represents the local origin\n/// of the three other components. Let's take an example with a 10x10\n/// pixels sprite. By default, the sprite is positioned/rotated/scaled\n/// relatively to its top-left corner, because it is the local point\n/// (0, 0). But if we change the origin to be (5, 5), the sprite will\n/// be positioned/rotated/scaled around its center instead. And if\n/// we set the origin to (10, 10), it will be transformed around its\n/// bottom-right corner.\n///\n/// To keep the sf::Transformable class simple, there's only one\n/// origin for all the components. You cannot position the sprite\n/// relatively to its top-left corner while rotating it around its\n/// center, for example. To do such things, use sf::Transform directly.\n///\n/// sf::Transformable can be used as a base class. It is often\n/// combined with sf::Drawable -- that's what SFML's sprites,\n/// texts and shapes do.\n/// \\code\n/// class MyEntity : public sf::Transformable, public sf::Drawable\n/// {\n///     virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const\n///     {\n///         states.transform *= getTransform();\n///         target.draw(..., states);\n///     }\n/// };\n///\n/// MyEntity entity;\n/// entity.setPosition(10, 20);\n/// entity.setRotation(45);\n/// window.draw(entity);\n/// \\endcode\n///\n/// It can also be used as a member, if you don't want to use\n/// its API directly (because you don't need all its functions,\n/// or you have different naming conventions for example).\n/// \\code\n/// class MyEntity\n/// {\n/// public:\n///     void SetPosition(const MyVector& v)\n///     {\n///         myTransform.setPosition(v.x(), v.y());\n///     }\n///\n///     void Draw(sf::RenderTarget& target) const\n///     {\n///         target.draw(..., myTransform.getTransform());\n///     }\n///\n/// private:\n///     sf::Transformable myTransform;\n/// };\n/// \\endcode\n///\n/// A note on coordinates and undistorted rendering: \\n\n/// By default, SFML (or more exactly, OpenGL) may interpolate drawable objects\n/// such as sprites or texts when rendering. While this allows transitions\n/// like slow movements or rotations to appear smoothly, it can lead to\n/// unwanted results in some cases, for example blurred or distorted objects.\n/// In order to render a sf::Drawable object pixel-perfectly, make sure\n/// the involved coordinates allow a 1:1 mapping of pixels in the window\n/// to texels (pixels in the texture). More specifically, this means:\n/// * The object's position, origin and scale have no fractional part\n/// * The object's and the view's rotation are a multiple of 90 degrees\n/// * The view's center and size have no fractional part\n///\n/// \\see sf::Transform\n///\n////////////////////////////////////////////////////////////\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/Graphics/Vertex.hpp",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n#ifndef SFML_VERTEX_HPP\n#define SFML_VERTEX_HPP\n\n////////////////////////////////////////////////////////////\n// Headers\n////////////////////////////////////////////////////////////\n#include <SFML/Graphics/Export.hpp>\n#include <SFML/Graphics/Color.hpp>\n#include <SFML/System/Vector2.hpp>\n\n\nnamespace sf\n{\n////////////////////////////////////////////////////////////\n/// \\brief Define a point with color and texture coordinates\n///\n////////////////////////////////////////////////////////////\nclass SFML_GRAPHICS_API Vertex\n{\npublic:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Default constructor\n    ///\n    ////////////////////////////////////////////////////////////\n    Vertex();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Construct the vertex from its position\n    ///\n    /// The vertex color is white and texture coordinates are (0, 0).\n    ///\n    /// \\param thePosition Vertex position\n    ///\n    ////////////////////////////////////////////////////////////\n    Vertex(const Vector2f& thePosition);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Construct the vertex from its position and color\n    ///\n    /// The texture coordinates are (0, 0).\n    ///\n    /// \\param thePosition Vertex position\n    /// \\param theColor    Vertex color\n    ///\n    ////////////////////////////////////////////////////////////\n    Vertex(const Vector2f& thePosition, const Color& theColor);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Construct the vertex from its position and texture coordinates\n    ///\n    /// The vertex color is white.\n    ///\n    /// \\param thePosition  Vertex position\n    /// \\param theTexCoords Vertex texture coordinates\n    ///\n    ////////////////////////////////////////////////////////////\n    Vertex(const Vector2f& thePosition, const Vector2f& theTexCoords);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Construct the vertex from its position, color and texture coordinates\n    ///\n    /// \\param thePosition  Vertex position\n    /// \\param theColor     Vertex color\n    /// \\param theTexCoords Vertex texture coordinates\n    ///\n    ////////////////////////////////////////////////////////////\n    Vertex(const Vector2f& thePosition, const Color& theColor, const Vector2f& theTexCoords);\n\n    ////////////////////////////////////////////////////////////\n    // Member data\n    ////////////////////////////////////////////////////////////\n    Vector2f  position;  ///< 2D position of the vertex\n    Color     color;     ///< Color of the vertex\n    Vector2f  texCoords; ///< Coordinates of the texture's pixel to map to the vertex\n};\n\n} // namespace sf\n\n\n#endif // SFML_VERTEX_HPP\n\n\n////////////////////////////////////////////////////////////\n/// \\class sf::Vertex\n/// \\ingroup graphics\n///\n/// A vertex is an improved point. It has a position and other\n/// extra attributes that will be used for drawing: in SFML,\n/// vertices also have a color and a pair of texture coordinates.\n///\n/// The vertex is the building block of drawing. Everything which\n/// is visible on screen is made of vertices. They are grouped\n/// as 2D primitives (triangles, quads, ...), and these primitives\n/// are grouped to create even more complex 2D entities such as\n/// sprites, texts, etc.\n///\n/// If you use the graphical entities of SFML (sprite, text, shape)\n/// you won't have to deal with vertices directly. But if you want\n/// to define your own 2D entities, such as tiled maps or particle\n/// systems, using vertices will allow you to get maximum performances.\n///\n/// Example:\n/// \\code\n/// // define a 100x100 square, red, with a 10x10 texture mapped on it\n/// sf::Vertex vertices[] =\n/// {\n///     sf::Vertex(sf::Vector2f(  0,   0), sf::Color::Red, sf::Vector2f( 0,  0)),\n///     sf::Vertex(sf::Vector2f(  0, 100), sf::Color::Red, sf::Vector2f( 0, 10)),\n///     sf::Vertex(sf::Vector2f(100, 100), sf::Color::Red, sf::Vector2f(10, 10)),\n///     sf::Vertex(sf::Vector2f(100,   0), sf::Color::Red, sf::Vector2f(10,  0))\n/// };\n///\n/// // draw it\n/// window.draw(vertices, 4, sf::Quads);\n/// \\endcode\n///\n/// Note: although texture coordinates are supposed to be an integer\n/// amount of pixels, their type is float because of some buggy graphics\n/// drivers that are not able to process integer coordinates correctly.\n///\n/// \\see sf::VertexArray\n///\n////////////////////////////////////////////////////////////\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/Graphics/VertexArray.hpp",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n#ifndef SFML_VERTEXARRAY_HPP\n#define SFML_VERTEXARRAY_HPP\n\n////////////////////////////////////////////////////////////\n// Headers\n////////////////////////////////////////////////////////////\n#include <SFML/Graphics/Export.hpp>\n#include <SFML/Graphics/Vertex.hpp>\n#include <SFML/Graphics/PrimitiveType.hpp>\n#include <SFML/Graphics/Rect.hpp>\n#include <SFML/Graphics/Drawable.hpp>\n#include <vector>\n\n\nnamespace sf\n{\n////////////////////////////////////////////////////////////\n/// \\brief Define a set of one or more 2D primitives\n///\n////////////////////////////////////////////////////////////\nclass SFML_GRAPHICS_API VertexArray : public Drawable\n{\npublic:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Default constructor\n    ///\n    /// Creates an empty vertex array.\n    ///\n    ////////////////////////////////////////////////////////////\n    VertexArray();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Construct the vertex array with a type and an initial number of vertices\n    ///\n    /// \\param type        Type of primitives\n    /// \\param vertexCount Initial number of vertices in the array\n    ///\n    ////////////////////////////////////////////////////////////\n    explicit VertexArray(PrimitiveType type, std::size_t vertexCount = 0);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Return the vertex count\n    ///\n    /// \\return Number of vertices in the array\n    ///\n    ////////////////////////////////////////////////////////////\n    std::size_t getVertexCount() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get a read-write access to a vertex by its index\n    ///\n    /// This function doesn't check \\a index, it must be in range\n    /// [0, getVertexCount() - 1]. The behavior is undefined\n    /// otherwise.\n    ///\n    /// \\param index Index of the vertex to get\n    ///\n    /// \\return Reference to the index-th vertex\n    ///\n    /// \\see getVertexCount\n    ///\n    ////////////////////////////////////////////////////////////\n    Vertex& operator [](std::size_t index);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get a read-only access to a vertex by its index\n    ///\n    /// This function doesn't check \\a index, it must be in range\n    /// [0, getVertexCount() - 1]. The behavior is undefined\n    /// otherwise.\n    ///\n    /// \\param index Index of the vertex to get\n    ///\n    /// \\return Const reference to the index-th vertex\n    ///\n    /// \\see getVertexCount\n    ///\n    ////////////////////////////////////////////////////////////\n    const Vertex& operator [](std::size_t index) const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Clear the vertex array\n    ///\n    /// This function removes all the vertices from the array.\n    /// It doesn't deallocate the corresponding memory, so that\n    /// adding new vertices after clearing doesn't involve\n    /// reallocating all the memory.\n    ///\n    ////////////////////////////////////////////////////////////\n    void clear();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Resize the vertex array\n    ///\n    /// If \\a vertexCount is greater than the current size, the previous\n    /// vertices are kept and new (default-constructed) vertices are\n    /// added.\n    /// If \\a vertexCount is less than the current size, existing vertices\n    /// are removed from the array.\n    ///\n    /// \\param vertexCount New size of the array (number of vertices)\n    ///\n    ////////////////////////////////////////////////////////////\n    void resize(std::size_t vertexCount);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Add a vertex to the array\n    ///\n    /// \\param vertex Vertex to add\n    ///\n    ////////////////////////////////////////////////////////////\n    void append(const Vertex& vertex);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Set the type of primitives to draw\n    ///\n    /// This function defines how the vertices must be interpreted\n    /// when it's time to draw them:\n    /// \\li As points\n    /// \\li As lines\n    /// \\li As triangles\n    /// \\li As quads\n    /// The default primitive type is sf::Points.\n    ///\n    /// \\param type Type of primitive\n    ///\n    ////////////////////////////////////////////////////////////\n    void setPrimitiveType(PrimitiveType type);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the type of primitives drawn by the vertex array\n    ///\n    /// \\return Primitive type\n    ///\n    ////////////////////////////////////////////////////////////\n    PrimitiveType getPrimitiveType() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Compute the bounding rectangle of the vertex array\n    ///\n    /// This function returns the minimal axis-aligned rectangle\n    /// that contains all the vertices of the array.\n    ///\n    /// \\return Bounding rectangle of the vertex array\n    ///\n    ////////////////////////////////////////////////////////////\n    FloatRect getBounds() const;\n\nprivate:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Draw the vertex array to a render target\n    ///\n    /// \\param target Render target to draw to\n    /// \\param states Current render states\n    ///\n    ////////////////////////////////////////////////////////////\n    virtual void draw(RenderTarget& target, RenderStates states) const;\n\nprivate:\n\n    ////////////////////////////////////////////////////////////\n    // Member data\n    ////////////////////////////////////////////////////////////\n    std::vector<Vertex> m_vertices;      ///< Vertices contained in the array\n    PrimitiveType       m_primitiveType; ///< Type of primitives to draw\n};\n\n} // namespace sf\n\n\n#endif // SFML_VERTEXARRAY_HPP\n\n\n////////////////////////////////////////////////////////////\n/// \\class sf::VertexArray\n/// \\ingroup graphics\n///\n/// sf::VertexArray is a very simple wrapper around a dynamic\n/// array of vertices and a primitives type.\n///\n/// It inherits sf::Drawable, but unlike other drawables it\n/// is not transformable.\n///\n/// Example:\n/// \\code\n/// sf::VertexArray lines(sf::LineStrip, 4);\n/// lines[0].position = sf::Vector2f(10, 0);\n/// lines[1].position = sf::Vector2f(20, 0);\n/// lines[2].position = sf::Vector2f(30, 5);\n/// lines[3].position = sf::Vector2f(40, 2);\n///\n/// window.draw(lines);\n/// \\endcode\n///\n/// \\see sf::Vertex\n///\n////////////////////////////////////////////////////////////\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/Graphics/View.hpp",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n#ifndef SFML_VIEW_HPP\n#define SFML_VIEW_HPP\n\n////////////////////////////////////////////////////////////\n// Headers\n////////////////////////////////////////////////////////////\n#include <SFML/Graphics/Export.hpp>\n#include <SFML/Graphics/Rect.hpp>\n#include <SFML/Graphics/Transform.hpp>\n#include <SFML/System/Vector2.hpp>\n\n\nnamespace sf\n{\n////////////////////////////////////////////////////////////\n/// \\brief 2D camera that defines what region is shown on screen\n///\n////////////////////////////////////////////////////////////\nclass SFML_GRAPHICS_API View\n{\npublic:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Default constructor\n    ///\n    /// This constructor creates a default view of (0, 0, 1000, 1000)\n    ///\n    ////////////////////////////////////////////////////////////\n    View();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Construct the view from a rectangle\n    ///\n    /// \\param rectangle Rectangle defining the zone to display\n    ///\n    ////////////////////////////////////////////////////////////\n    explicit View(const FloatRect& rectangle);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Construct the view from its center and size\n    ///\n    /// \\param center Center of the zone to display\n    /// \\param size   Size of zone to display\n    ///\n    ////////////////////////////////////////////////////////////\n    View(const Vector2f& center, const Vector2f& size);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Set the center of the view\n    ///\n    /// \\param x X coordinate of the new center\n    /// \\param y Y coordinate of the new center\n    ///\n    /// \\see setSize, getCenter\n    ///\n    ////////////////////////////////////////////////////////////\n    void setCenter(float x, float y);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Set the center of the view\n    ///\n    /// \\param center New center\n    ///\n    /// \\see setSize, getCenter\n    ///\n    ////////////////////////////////////////////////////////////\n    void setCenter(const Vector2f& center);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Set the size of the view\n    ///\n    /// \\param width  New width of the view\n    /// \\param height New height of the view\n    ///\n    /// \\see setCenter, getCenter\n    ///\n    ////////////////////////////////////////////////////////////\n    void setSize(float width, float height);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Set the size of the view\n    ///\n    /// \\param size New size\n    ///\n    /// \\see setCenter, getCenter\n    ///\n    ////////////////////////////////////////////////////////////\n    void setSize(const Vector2f& size);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Set the orientation of the view\n    ///\n    /// The default rotation of a view is 0 degree.\n    ///\n    /// \\param angle New angle, in degrees\n    ///\n    /// \\see getRotation\n    ///\n    ////////////////////////////////////////////////////////////\n    void setRotation(float angle);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Set the target viewport\n    ///\n    /// The viewport is the rectangle into which the contents of the\n    /// view are displayed, expressed as a factor (between 0 and 1)\n    /// of the size of the RenderTarget to which the view is applied.\n    /// For example, a view which takes the left side of the target would\n    /// be defined with View.setViewport(sf::FloatRect(0, 0, 0.5, 1)).\n    /// By default, a view has a viewport which covers the entire target.\n    ///\n    /// \\param viewport New viewport rectangle\n    ///\n    /// \\see getViewport\n    ///\n    ////////////////////////////////////////////////////////////\n    void setViewport(const FloatRect& viewport);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Reset the view to the given rectangle\n    ///\n    /// Note that this function resets the rotation angle to 0.\n    ///\n    /// \\param rectangle Rectangle defining the zone to display\n    ///\n    /// \\see setCenter, setSize, setRotation\n    ///\n    ////////////////////////////////////////////////////////////\n    void reset(const FloatRect& rectangle);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the center of the view\n    ///\n    /// \\return Center of the view\n    ///\n    /// \\see getSize, setCenter\n    ///\n    ////////////////////////////////////////////////////////////\n    const Vector2f& getCenter() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the size of the view\n    ///\n    /// \\return Size of the view\n    ///\n    /// \\see getCenter, setSize\n    ///\n    ////////////////////////////////////////////////////////////\n    const Vector2f& getSize() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the current orientation of the view\n    ///\n    /// \\return Rotation angle of the view, in degrees\n    ///\n    /// \\see setRotation\n    ///\n    ////////////////////////////////////////////////////////////\n    float getRotation() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the target viewport rectangle of the view\n    ///\n    /// \\return Viewport rectangle, expressed as a factor of the target size\n    ///\n    /// \\see setViewport\n    ///\n    ////////////////////////////////////////////////////////////\n    const FloatRect& getViewport() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Move the view relatively to its current position\n    ///\n    /// \\param offsetX X coordinate of the move offset\n    /// \\param offsetY Y coordinate of the move offset\n    ///\n    /// \\see setCenter, rotate, zoom\n    ///\n    ////////////////////////////////////////////////////////////\n    void move(float offsetX, float offsetY);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Move the view relatively to its current position\n    ///\n    /// \\param offset Move offset\n    ///\n    /// \\see setCenter, rotate, zoom\n    ///\n    ////////////////////////////////////////////////////////////\n    void move(const Vector2f& offset);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Rotate the view relatively to its current orientation\n    ///\n    /// \\param angle Angle to rotate, in degrees\n    ///\n    /// \\see setRotation, move, zoom\n    ///\n    ////////////////////////////////////////////////////////////\n    void rotate(float angle);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Resize the view rectangle relatively to its current size\n    ///\n    /// Resizing the view simulates a zoom, as the zone displayed on\n    /// screen grows or shrinks.\n    /// \\a factor is a multiplier:\n    /// \\li 1 keeps the size unchanged\n    /// \\li > 1 makes the view bigger (objects appear smaller)\n    /// \\li < 1 makes the view smaller (objects appear bigger)\n    ///\n    /// \\param factor Zoom factor to apply\n    ///\n    /// \\see setSize, move, rotate\n    ///\n    ////////////////////////////////////////////////////////////\n    void zoom(float factor);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the projection transform of the view\n    ///\n    /// This function is meant for internal use only.\n    ///\n    /// \\return Projection transform defining the view\n    ///\n    /// \\see getInverseTransform\n    ///\n    ////////////////////////////////////////////////////////////\n    const Transform& getTransform() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the inverse projection transform of the view\n    ///\n    /// This function is meant for internal use only.\n    ///\n    /// \\return Inverse of the projection transform defining the view\n    ///\n    /// \\see getTransform\n    ///\n    ////////////////////////////////////////////////////////////\n    const Transform& getInverseTransform() const;\n\nprivate:\n\n    ////////////////////////////////////////////////////////////\n    // Member data\n    ////////////////////////////////////////////////////////////\n    Vector2f          m_center;              ///< Center of the view, in scene coordinates\n    Vector2f          m_size;                ///< Size of the view, in scene coordinates\n    float             m_rotation;            ///< Angle of rotation of the view rectangle, in degrees\n    FloatRect         m_viewport;            ///< Viewport rectangle, expressed as a factor of the render-target's size\n    mutable Transform m_transform;           ///< Precomputed projection transform corresponding to the view\n    mutable Transform m_inverseTransform;    ///< Precomputed inverse projection transform corresponding to the view\n    mutable bool      m_transformUpdated;    ///< Internal state telling if the transform needs to be updated\n    mutable bool      m_invTransformUpdated; ///< Internal state telling if the inverse transform needs to be updated\n};\n\n} // namespace sf\n\n\n#endif // SFML_VIEW_HPP\n\n\n////////////////////////////////////////////////////////////\n/// \\class sf::View\n/// \\ingroup graphics\n///\n/// sf::View defines a camera in the 2D scene. This is a\n/// very powerful concept: you can scroll, rotate or zoom\n/// the entire scene without altering the way that your\n/// drawable objects are drawn.\n///\n/// A view is composed of a source rectangle, which defines\n/// what part of the 2D scene is shown, and a target viewport,\n/// which defines where the contents of the source rectangle\n/// will be displayed on the render target (window or texture).\n///\n/// The viewport allows to map the scene to a custom part\n/// of the render target, and can be used for split-screen\n/// or for displaying a minimap, for example. If the source\n/// rectangle doesn't have the same size as the viewport, its\n/// contents will be stretched to fit in.\n///\n/// To apply a view, you have to assign it to the render target.\n/// Then, objects drawn in this render target will be\n/// affected by the view until you use another view.\n///\n/// Usage example:\n/// \\code\n/// sf::RenderWindow window;\n/// sf::View view;\n///\n/// // Initialize the view to a rectangle located at (100, 100) and with a size of 400x200\n/// view.reset(sf::FloatRect(100, 100, 400, 200));\n///\n/// // Rotate it by 45 degrees\n/// view.rotate(45);\n///\n/// // Set its target viewport to be half of the window\n/// view.setViewport(sf::FloatRect(0.f, 0.f, 0.5f, 1.f));\n///\n/// // Apply it\n/// window.setView(view);\n///\n/// // Render stuff\n/// window.draw(someSprite);\n///\n/// // Set the default view back\n/// window.setView(window.getDefaultView());\n///\n/// // Render stuff not affected by the view\n/// window.draw(someText);\n/// \\endcode\n///\n/// See also the note on coordinates and undistorted rendering in sf::Transformable.\n///\n/// \\see sf::RenderWindow, sf::RenderTexture\n///\n////////////////////////////////////////////////////////////\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/Graphics.hpp",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n#ifndef SFML_GRAPHICS_HPP\n#define SFML_GRAPHICS_HPP\n\n////////////////////////////////////////////////////////////\n// Headers\n////////////////////////////////////////////////////////////\n\n#include <SFML/Window.hpp>\n#include <SFML/Graphics/BlendMode.hpp>\n#include <SFML/Graphics/CircleShape.hpp>\n#include <SFML/Graphics/Color.hpp>\n#include <SFML/Graphics/ConvexShape.hpp>\n#include <SFML/Graphics/Drawable.hpp>\n#include <SFML/Graphics/Font.hpp>\n#include <SFML/Graphics/Glyph.hpp>\n#include <SFML/Graphics/Image.hpp>\n#include <SFML/Graphics/PrimitiveType.hpp>\n#include <SFML/Graphics/Rect.hpp>\n#include <SFML/Graphics/RectangleShape.hpp>\n#include <SFML/Graphics/RenderStates.hpp>\n#include <SFML/Graphics/RenderTarget.hpp>\n#include <SFML/Graphics/RenderTexture.hpp>\n#include <SFML/Graphics/RenderWindow.hpp>\n#include <SFML/Graphics/Shader.hpp>\n#include <SFML/Graphics/Shape.hpp>\n#include <SFML/Graphics/Sprite.hpp>\n#include <SFML/Graphics/Text.hpp>\n#include <SFML/Graphics/Texture.hpp>\n#include <SFML/Graphics/Transform.hpp>\n#include <SFML/Graphics/Transformable.hpp>\n#include <SFML/Graphics/Vertex.hpp>\n#include <SFML/Graphics/VertexArray.hpp>\n#include <SFML/Graphics/View.hpp>\n\n\n#endif // SFML_GRAPHICS_HPP\n\n////////////////////////////////////////////////////////////\n/// \\defgroup graphics Graphics module\n///\n/// 2D graphics module: sprites, text, shapes, ...\n///\n////////////////////////////////////////////////////////////\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/Main.hpp",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n#ifndef SFML_MAIN_HPP\n#define SFML_MAIN_HPP\n\n////////////////////////////////////////////////////////////\n// Headers\n////////////////////////////////////////////////////////////\n#include <SFML/Config.hpp>\n\n\n#if defined(SFML_SYSTEM_IOS)\n\n    // On iOS, we have no choice but to have our own main,\n    // so we need to rename the user one and call it later\n    #define main sfmlMain\n\n#endif\n\n\n#endif // SFML_MAIN_HPP\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/Network/Export.hpp",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n#ifndef SFML_NETWORK_EXPORT_HPP\n#define SFML_NETWORK_EXPORT_HPP\n\n////////////////////////////////////////////////////////////\n// Headers\n////////////////////////////////////////////////////////////\n#include <SFML/Config.hpp>\n\n\n////////////////////////////////////////////////////////////\n// Define portable import / export macros\n////////////////////////////////////////////////////////////\n#if defined(SFML_NETWORK_EXPORTS)\n\n    #define SFML_NETWORK_API SFML_API_EXPORT\n\n#else\n\n    #define SFML_NETWORK_API SFML_API_IMPORT\n\n#endif\n\n\n#endif // SFML_NETWORK_EXPORT_HPP\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/Network/Ftp.hpp",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n#ifndef SFML_FTP_HPP\n#define SFML_FTP_HPP\n\n////////////////////////////////////////////////////////////\n// Headers\n////////////////////////////////////////////////////////////\n#include <SFML/Network/Export.hpp>\n#include <SFML/Network/TcpSocket.hpp>\n#include <SFML/System/NonCopyable.hpp>\n#include <SFML/System/Time.hpp>\n#include <string>\n#include <vector>\n\n\nnamespace sf\n{\nclass IpAddress;\n\n////////////////////////////////////////////////////////////\n/// \\brief A FTP client\n///\n////////////////////////////////////////////////////////////\nclass SFML_NETWORK_API Ftp : NonCopyable\n{\npublic:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Enumeration of transfer modes\n    ///\n    ////////////////////////////////////////////////////////////\n    enum TransferMode\n    {\n        Binary, ///< Binary mode (file is transfered as a sequence of bytes)\n        Ascii,  ///< Text mode using ASCII encoding\n        Ebcdic  ///< Text mode using EBCDIC encoding\n    };\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Define a FTP response\n    ///\n    ////////////////////////////////////////////////////////////\n    class SFML_NETWORK_API Response\n    {\n    public:\n\n        ////////////////////////////////////////////////////////////\n        /// \\brief Status codes possibly returned by a FTP response\n        ///\n        ////////////////////////////////////////////////////////////\n        enum Status\n        {\n            // 1xx: the requested action is being initiated,\n            // expect another reply before proceeding with a new command\n            RestartMarkerReply          = 110, ///< Restart marker reply\n            ServiceReadySoon            = 120, ///< Service ready in N minutes\n            DataConnectionAlreadyOpened = 125, ///< Data connection already opened, transfer starting\n            OpeningDataConnection       = 150, ///< File status ok, about to open data connection\n\n            // 2xx: the requested action has been successfully completed\n            Ok                    = 200, ///< Command ok\n            PointlessCommand      = 202, ///< Command not implemented\n            SystemStatus          = 211, ///< System status, or system help reply\n            DirectoryStatus       = 212, ///< Directory status\n            FileStatus            = 213, ///< File status\n            HelpMessage           = 214, ///< Help message\n            SystemType            = 215, ///< NAME system type, where NAME is an official system name from the list in the Assigned Numbers document\n            ServiceReady          = 220, ///< Service ready for new user\n            ClosingConnection     = 221, ///< Service closing control connection\n            DataConnectionOpened  = 225, ///< Data connection open, no transfer in progress\n            ClosingDataConnection = 226, ///< Closing data connection, requested file action successful\n            EnteringPassiveMode   = 227, ///< Entering passive mode\n            LoggedIn              = 230, ///< User logged in, proceed. Logged out if appropriate\n            FileActionOk          = 250, ///< Requested file action ok\n            DirectoryOk           = 257, ///< PATHNAME created\n\n            // 3xx: the command has been accepted, but the requested action\n            // is dormant, pending receipt of further information\n            NeedPassword       = 331, ///< User name ok, need password\n            NeedAccountToLogIn = 332, ///< Need account for login\n            NeedInformation    = 350, ///< Requested file action pending further information\n\n            // 4xx: the command was not accepted and the requested action did not take place,\n            // but the error condition is temporary and the action may be requested again\n            ServiceUnavailable        = 421, ///< Service not available, closing control connection\n            DataConnectionUnavailable = 425, ///< Can't open data connection\n            TransferAborted           = 426, ///< Connection closed, transfer aborted\n            FileActionAborted         = 450, ///< Requested file action not taken\n            LocalError                = 451, ///< Requested action aborted, local error in processing\n            InsufficientStorageSpace  = 452, ///< Requested action not taken; insufficient storage space in system, file unavailable\n\n            // 5xx: the command was not accepted and\n            // the requested action did not take place\n            CommandUnknown          = 500, ///< Syntax error, command unrecognized\n            ParametersUnknown       = 501, ///< Syntax error in parameters or arguments\n            CommandNotImplemented   = 502, ///< Command not implemented\n            BadCommandSequence      = 503, ///< Bad sequence of commands\n            ParameterNotImplemented = 504, ///< Command not implemented for that parameter\n            NotLoggedIn             = 530, ///< Not logged in\n            NeedAccountToStore      = 532, ///< Need account for storing files\n            FileUnavailable         = 550, ///< Requested action not taken, file unavailable\n            PageTypeUnknown         = 551, ///< Requested action aborted, page type unknown\n            NotEnoughMemory         = 552, ///< Requested file action aborted, exceeded storage allocation\n            FilenameNotAllowed      = 553, ///< Requested action not taken, file name not allowed\n\n            // 10xx: SFML custom codes\n            InvalidResponse  = 1000, ///< Not part of the FTP standard, generated by SFML when a received response cannot be parsed\n            ConnectionFailed = 1001, ///< Not part of the FTP standard, generated by SFML when the low-level socket connection with the server fails\n            ConnectionClosed = 1002, ///< Not part of the FTP standard, generated by SFML when the low-level socket connection is unexpectedly closed\n            InvalidFile      = 1003  ///< Not part of the FTP standard, generated by SFML when a local file cannot be read or written\n        };\n\n        ////////////////////////////////////////////////////////////\n        /// \\brief Default constructor\n        ///\n        /// This constructor is used by the FTP client to build\n        /// the response.\n        ///\n        /// \\param code    Response status code\n        /// \\param message Response message\n        ///\n        ////////////////////////////////////////////////////////////\n        explicit Response(Status code = InvalidResponse, const std::string& message = \"\");\n\n        ////////////////////////////////////////////////////////////\n        /// \\brief Check if the status code means a success\n        ///\n        /// This function is defined for convenience, it is\n        /// equivalent to testing if the status code is < 400.\n        ///\n        /// \\return True if the status is a success, false if it is a failure\n        ///\n        ////////////////////////////////////////////////////////////\n        bool isOk() const;\n\n        ////////////////////////////////////////////////////////////\n        /// \\brief Get the status code of the response\n        ///\n        /// \\return Status code\n        ///\n        ////////////////////////////////////////////////////////////\n        Status getStatus() const;\n\n        ////////////////////////////////////////////////////////////\n        /// \\brief Get the full message contained in the response\n        ///\n        /// \\return The response message\n        ///\n        ////////////////////////////////////////////////////////////\n        const std::string& getMessage() const;\n\n    private:\n\n        ////////////////////////////////////////////////////////////\n        // Member data\n        ////////////////////////////////////////////////////////////\n        Status      m_status;  ///< Status code returned from the server\n        std::string m_message; ///< Last message received from the server\n    };\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Specialization of FTP response returning a directory\n    ///\n    ////////////////////////////////////////////////////////////\n    class SFML_NETWORK_API DirectoryResponse : public Response\n    {\n    public:\n\n        ////////////////////////////////////////////////////////////\n        /// \\brief Default constructor\n        ///\n        /// \\param response Source response\n        ///\n        ////////////////////////////////////////////////////////////\n        DirectoryResponse(const Response& response);\n\n        ////////////////////////////////////////////////////////////\n        /// \\brief Get the directory returned in the response\n        ///\n        /// \\return Directory name\n        ///\n        ////////////////////////////////////////////////////////////\n        const std::string& getDirectory() const;\n\n    private:\n\n        ////////////////////////////////////////////////////////////\n        // Member data\n        ////////////////////////////////////////////////////////////\n        std::string m_directory; ///< Directory extracted from the response message\n    };\n\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Specialization of FTP response returning a\n    ///        filename listing\n    ////////////////////////////////////////////////////////////\n    class SFML_NETWORK_API ListingResponse : public Response\n    {\n    public:\n\n        ////////////////////////////////////////////////////////////\n        /// \\brief Default constructor\n        ///\n        /// \\param response  Source response\n        /// \\param data      Data containing the raw listing\n        ///\n        ////////////////////////////////////////////////////////////\n        ListingResponse(const Response& response, const std::string& data);\n\n        ////////////////////////////////////////////////////////////\n        /// \\brief Return the array of directory/file names\n        ///\n        /// \\return Array containing the requested listing\n        ///\n        ////////////////////////////////////////////////////////////\n        const std::vector<std::string>& getListing() const;\n\n    private:\n\n        ////////////////////////////////////////////////////////////\n        // Member data\n        ////////////////////////////////////////////////////////////\n        std::vector<std::string> m_listing; ///< Directory/file names extracted from the data\n    };\n\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Destructor\n    ///\n    /// Automatically closes the connection with the server if\n    /// it is still opened.\n    ///\n    ////////////////////////////////////////////////////////////\n    ~Ftp();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Connect to the specified FTP server\n    ///\n    /// The port has a default value of 21, which is the standard\n    /// port used by the FTP protocol. You shouldn't use a different\n    /// value, unless you really know what you do.\n    /// This function tries to connect to the server so it may take\n    /// a while to complete, especially if the server is not\n    /// reachable. To avoid blocking your application for too long,\n    /// you can use a timeout. The default value, Time::Zero, means that the\n    /// system timeout will be used (which is usually pretty long).\n    ///\n    /// \\param server  Name or address of the FTP server to connect to\n    /// \\param port    Port used for the connection\n    /// \\param timeout Maximum time to wait\n    ///\n    /// \\return Server response to the request\n    ///\n    /// \\see disconnect\n    ///\n    ////////////////////////////////////////////////////////////\n    Response connect(const IpAddress& server, unsigned short port = 21, Time timeout = Time::Zero);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Close the connection with the server\n    ///\n    /// \\return Server response to the request\n    ///\n    /// \\see connect\n    ///\n    ////////////////////////////////////////////////////////////\n    Response disconnect();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Log in using an anonymous account\n    ///\n    /// Logging in is mandatory after connecting to the server.\n    /// Users that are not logged in cannot perform any operation.\n    ///\n    /// \\return Server response to the request\n    ///\n    ////////////////////////////////////////////////////////////\n    Response login();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Log in using a username and a password\n    ///\n    /// Logging in is mandatory after connecting to the server.\n    /// Users that are not logged in cannot perform any operation.\n    ///\n    /// \\param name     User name\n    /// \\param password Password\n    ///\n    /// \\return Server response to the request\n    ///\n    ////////////////////////////////////////////////////////////\n    Response login(const std::string& name, const std::string& password);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Send a null command to keep the connection alive\n    ///\n    /// This command is useful because the server may close the\n    /// connection automatically if no command is sent.\n    ///\n    /// \\return Server response to the request\n    ///\n    ////////////////////////////////////////////////////////////\n    Response keepAlive();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the current working directory\n    ///\n    /// The working directory is the root path for subsequent\n    /// operations involving directories and/or filenames.\n    ///\n    /// \\return Server response to the request\n    ///\n    /// \\see getDirectoryListing, changeDirectory, parentDirectory\n    ///\n    ////////////////////////////////////////////////////////////\n    DirectoryResponse getWorkingDirectory();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the contents of the given directory\n    ///\n    /// This function retrieves the sub-directories and files\n    /// contained in the given directory. It is not recursive.\n    /// The \\a directory parameter is relative to the current\n    /// working directory.\n    ///\n    /// \\param directory Directory to list\n    ///\n    /// \\return Server response to the request\n    ///\n    /// \\see getWorkingDirectory, changeDirectory, parentDirectory\n    ///\n    ////////////////////////////////////////////////////////////\n    ListingResponse getDirectoryListing(const std::string& directory = \"\");\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Change the current working directory\n    ///\n    /// The new directory must be relative to the current one.\n    ///\n    /// \\param directory New working directory\n    ///\n    /// \\return Server response to the request\n    ///\n    /// \\see getWorkingDirectory, getDirectoryListing, parentDirectory\n    ///\n    ////////////////////////////////////////////////////////////\n    Response changeDirectory(const std::string& directory);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Go to the parent directory of the current one\n    ///\n    /// \\return Server response to the request\n    ///\n    /// \\see getWorkingDirectory, getDirectoryListing, changeDirectory\n    ///\n    ////////////////////////////////////////////////////////////\n    Response parentDirectory();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Create a new directory\n    ///\n    /// The new directory is created as a child of the current\n    /// working directory.\n    ///\n    /// \\param name Name of the directory to create\n    ///\n    /// \\return Server response to the request\n    ///\n    /// \\see deleteDirectory\n    ///\n    ////////////////////////////////////////////////////////////\n    Response createDirectory(const std::string& name);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Remove an existing directory\n    ///\n    /// The directory to remove must be relative to the\n    /// current working directory.\n    /// Use this function with caution, the directory will\n    /// be removed permanently!\n    ///\n    /// \\param name Name of the directory to remove\n    ///\n    /// \\return Server response to the request\n    ///\n    /// \\see createDirectory\n    ///\n    ////////////////////////////////////////////////////////////\n    Response deleteDirectory(const std::string& name);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Rename an existing file\n    ///\n    /// The filenames must be relative to the current working\n    /// directory.\n    ///\n    /// \\param file    File to rename\n    /// \\param newName New name of the file\n    ///\n    /// \\return Server response to the request\n    ///\n    /// \\see deleteFile\n    ///\n    ////////////////////////////////////////////////////////////\n    Response renameFile(const std::string& file, const std::string& newName);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Remove an existing file\n    ///\n    /// The file name must be relative to the current working\n    /// directory.\n    /// Use this function with caution, the file will be\n    /// removed permanently!\n    ///\n    /// \\param name File to remove\n    ///\n    /// \\return Server response to the request\n    ///\n    /// \\see renameFile\n    ///\n    ////////////////////////////////////////////////////////////\n    Response deleteFile(const std::string& name);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Download a file from the server\n    ///\n    /// The filename of the distant file is relative to the\n    /// current working directory of the server, and the local\n    /// destination path is relative to the current directory\n    /// of your application.\n    /// If a file with the same filename as the distant file\n    /// already exists in the local destination path, it will\n    /// be overwritten.\n    ///\n    /// \\param remoteFile Filename of the distant file to download\n    /// \\param localPath  The directory in which to put the file on the local computer\n    /// \\param mode       Transfer mode\n    ///\n    /// \\return Server response to the request\n    ///\n    /// \\see upload\n    ///\n    ////////////////////////////////////////////////////////////\n    Response download(const std::string& remoteFile, const std::string& localPath, TransferMode mode = Binary);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Upload a file to the server\n    ///\n    /// The name of the local file is relative to the current\n    /// working directory of your application, and the\n    /// remote path is relative to the current directory of the\n    /// FTP server.\n    ///\n    /// \\param localFile  Path of the local file to upload\n    /// \\param remotePath The directory in which to put the file on the server\n    /// \\param mode       Transfer mode\n    ///\n    /// \\return Server response to the request\n    ///\n    /// \\see download\n    ///\n    ////////////////////////////////////////////////////////////\n    Response upload(const std::string& localFile, const std::string& remotePath, TransferMode mode = Binary);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Send a command to the FTP server\n    ///\n    /// While the most often used commands are provided as member\n    /// functions in the sf::Ftp class, this method can be used\n    /// to send any FTP command to the server. If the command\n    /// requires one or more parameters, they can be specified\n    /// in \\a parameter. If the server returns information, you\n    /// can extract it from the response using Response::getMessage().\n    ///\n    /// \\param command   Command to send\n    /// \\param parameter Command parameter\n    ///\n    /// \\return Server response to the request\n    ///\n    ////////////////////////////////////////////////////////////\n    Response sendCommand(const std::string& command, const std::string& parameter = \"\");\n\nprivate:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Receive a response from the server\n    ///\n    /// This function must be called after each call to\n    /// sendCommand that expects a response.\n    ///\n    /// \\return Server response to the request\n    ///\n    ////////////////////////////////////////////////////////////\n    Response getResponse();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Utility class for exchanging datas with the server\n    ///        on the data channel\n    ///\n    ////////////////////////////////////////////////////////////\n    class DataChannel;\n\n    friend class DataChannel;\n\n    ////////////////////////////////////////////////////////////\n    // Member data\n    ////////////////////////////////////////////////////////////\n    TcpSocket   m_commandSocket; ///< Socket holding the control connection with the server\n    std::string m_receiveBuffer; ///< Received command data that is yet to be processed\n};\n\n} // namespace sf\n\n\n#endif // SFML_FTP_HPP\n\n\n////////////////////////////////////////////////////////////\n/// \\class sf::Ftp\n/// \\ingroup network\n///\n/// sf::Ftp is a very simple FTP client that allows you\n/// to communicate with a FTP server. The FTP protocol allows\n/// you to manipulate a remote file system (list files,\n/// upload, download, create, remove, ...).\n///\n/// Using the FTP client consists of 4 parts:\n/// \\li Connecting to the FTP server\n/// \\li Logging in (either as a registered user or anonymously)\n/// \\li Sending commands to the server\n/// \\li Disconnecting (this part can be done implicitly by the destructor)\n///\n/// Every command returns a FTP response, which contains the\n/// status code as well as a message from the server. Some\n/// commands such as getWorkingDirectory() and getDirectoryListing()\n/// return additional data, and use a class derived from\n/// sf::Ftp::Response to provide this data. The most often used\n/// commands are directly provided as member functions, but it is\n/// also possible to use specific commands with the sendCommand() function.\n///\n/// Note that response statuses >= 1000 are not part of the FTP standard,\n/// they are generated by SFML when an internal error occurs.\n///\n/// All commands, especially upload and download, may take some\n/// time to complete. This is important to know if you don't want\n/// to block your application while the server is completing\n/// the task.\n///\n/// Usage example:\n/// \\code\n/// // Create a new FTP client\n/// sf::Ftp ftp;\n///\n/// // Connect to the server\n/// sf::Ftp::Response response = ftp.connect(\"ftp://ftp.myserver.com\");\n/// if (response.isOk())\n///     std::cout << \"Connected\" << std::endl;\n///\n/// // Log in\n/// response = ftp.login(\"laurent\", \"dF6Zm89D\");\n/// if (response.isOk())\n///     std::cout << \"Logged in\" << std::endl;\n///\n/// // Print the working directory\n/// sf::Ftp::DirectoryResponse directory = ftp.getWorkingDirectory();\n/// if (directory.isOk())\n///     std::cout << \"Working directory: \" << directory.getDirectory() << std::endl;\n///\n/// // Create a new directory\n/// response = ftp.createDirectory(\"files\");\n/// if (response.isOk())\n///     std::cout << \"Created new directory\" << std::endl;\n///\n/// // Upload a file to this new directory\n/// response = ftp.upload(\"local-path/file.txt\", \"files\", sf::Ftp::Ascii);\n/// if (response.isOk())\n///     std::cout << \"File uploaded\" << std::endl;\n///\n/// // Send specific commands (here: FEAT to list supported FTP features)\n/// response = ftp.sendCommand(\"FEAT\");\n/// if (response.isOk())\n///     std::cout << \"Feature list:\\n\" << response.getMessage() << std::endl;\n///\n/// // Disconnect from the server (optional)\n/// ftp.disconnect();\n/// \\endcode\n///\n////////////////////////////////////////////////////////////\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/Network/Http.hpp",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n#ifndef SFML_HTTP_HPP\n#define SFML_HTTP_HPP\n\n////////////////////////////////////////////////////////////\n// Headers\n////////////////////////////////////////////////////////////\n#include <SFML/Network/Export.hpp>\n#include <SFML/Network/IpAddress.hpp>\n#include <SFML/Network/TcpSocket.hpp>\n#include <SFML/System/NonCopyable.hpp>\n#include <SFML/System/Time.hpp>\n#include <map>\n#include <string>\n\n\nnamespace sf\n{\n////////////////////////////////////////////////////////////\n/// \\brief A HTTP client\n///\n////////////////////////////////////////////////////////////\nclass SFML_NETWORK_API Http : NonCopyable\n{\npublic:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Define a HTTP request\n    ///\n    ////////////////////////////////////////////////////////////\n    class SFML_NETWORK_API Request\n    {\n    public:\n\n        ////////////////////////////////////////////////////////////\n        /// \\brief Enumerate the available HTTP methods for a request\n        ///\n        ////////////////////////////////////////////////////////////\n        enum Method\n        {\n            Get,   ///< Request in get mode, standard method to retrieve a page\n            Post,  ///< Request in post mode, usually to send data to a page\n            Head,  ///< Request a page's header only\n            Put,   ///< Request in put mode, useful for a REST API\n            Delete ///< Request in delete mode, useful for a REST API\n        };\n\n        ////////////////////////////////////////////////////////////\n        /// \\brief Default constructor\n        ///\n        /// This constructor creates a GET request, with the root\n        /// URI (\"/\") and an empty body.\n        ///\n        /// \\param uri    Target URI\n        /// \\param method Method to use for the request\n        /// \\param body   Content of the request's body\n        ///\n        ////////////////////////////////////////////////////////////\n        Request(const std::string& uri = \"/\", Method method = Get, const std::string& body = \"\");\n\n        ////////////////////////////////////////////////////////////\n        /// \\brief Set the value of a field\n        ///\n        /// The field is created if it doesn't exist. The name of\n        /// the field is case-insensitive.\n        /// By default, a request doesn't contain any field (but the\n        /// mandatory fields are added later by the HTTP client when\n        /// sending the request).\n        ///\n        /// \\param field Name of the field to set\n        /// \\param value Value of the field\n        ///\n        ////////////////////////////////////////////////////////////\n        void setField(const std::string& field, const std::string& value);\n\n        ////////////////////////////////////////////////////////////\n        /// \\brief Set the request method\n        ///\n        /// See the Method enumeration for a complete list of all\n        /// the availale methods.\n        /// The method is Http::Request::Get by default.\n        ///\n        /// \\param method Method to use for the request\n        ///\n        ////////////////////////////////////////////////////////////\n        void setMethod(Method method);\n\n        ////////////////////////////////////////////////////////////\n        /// \\brief Set the requested URI\n        ///\n        /// The URI is the resource (usually a web page or a file)\n        /// that you want to get or post.\n        /// The URI is \"/\" (the root page) by default.\n        ///\n        /// \\param uri URI to request, relative to the host\n        ///\n        ////////////////////////////////////////////////////////////\n        void setUri(const std::string& uri);\n\n        ////////////////////////////////////////////////////////////\n        /// \\brief Set the HTTP version for the request\n        ///\n        /// The HTTP version is 1.0 by default.\n        ///\n        /// \\param major Major HTTP version number\n        /// \\param minor Minor HTTP version number\n        ///\n        ////////////////////////////////////////////////////////////\n        void setHttpVersion(unsigned int major, unsigned int minor);\n\n        ////////////////////////////////////////////////////////////\n        /// \\brief Set the body of the request\n        ///\n        /// The body of a request is optional and only makes sense\n        /// for POST requests. It is ignored for all other methods.\n        /// The body is empty by default.\n        ///\n        /// \\param body Content of the body\n        ///\n        ////////////////////////////////////////////////////////////\n        void setBody(const std::string& body);\n\n    private:\n\n        friend class Http;\n\n        ////////////////////////////////////////////////////////////\n        /// \\brief Prepare the final request to send to the server\n        ///\n        /// This is used internally by Http before sending the\n        /// request to the web server.\n        ///\n        /// \\return String containing the request, ready to be sent\n        ///\n        ////////////////////////////////////////////////////////////\n        std::string prepare() const;\n\n        ////////////////////////////////////////////////////////////\n        /// \\brief Check if the request defines a field\n        ///\n        /// This function uses case-insensitive comparisons.\n        ///\n        /// \\param field Name of the field to test\n        ///\n        /// \\return True if the field exists, false otherwise\n        ///\n        ////////////////////////////////////////////////////////////\n        bool hasField(const std::string& field) const;\n\n        ////////////////////////////////////////////////////////////\n        // Types\n        ////////////////////////////////////////////////////////////\n        typedef std::map<std::string, std::string> FieldTable;\n\n        ////////////////////////////////////////////////////////////\n        // Member data\n        ////////////////////////////////////////////////////////////\n        FieldTable   m_fields;       ///< Fields of the header associated to their value\n        Method       m_method;       ///< Method to use for the request\n        std::string  m_uri;          ///< Target URI of the request\n        unsigned int m_majorVersion; ///< Major HTTP version\n        unsigned int m_minorVersion; ///< Minor HTTP version\n        std::string  m_body;         ///< Body of the request\n    };\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Define a HTTP response\n    ///\n    ////////////////////////////////////////////////////////////\n    class SFML_NETWORK_API Response\n    {\n    public:\n\n        ////////////////////////////////////////////////////////////\n        /// \\brief Enumerate all the valid status codes for a response\n        ///\n        ////////////////////////////////////////////////////////////\n        enum Status\n        {\n            // 2xx: success\n            Ok             = 200, ///< Most common code returned when operation was successful\n            Created        = 201, ///< The resource has successfully been created\n            Accepted       = 202, ///< The request has been accepted, but will be processed later by the server\n            NoContent      = 204, ///< The server didn't send any data in return\n            ResetContent   = 205, ///< The server informs the client that it should clear the view (form) that caused the request to be sent\n            PartialContent = 206, ///< The server has sent a part of the resource, as a response to a partial GET request\n\n            // 3xx: redirection\n            MultipleChoices  = 300, ///< The requested page can be accessed from several locations\n            MovedPermanently = 301, ///< The requested page has permanently moved to a new location\n            MovedTemporarily = 302, ///< The requested page has temporarily moved to a new location\n            NotModified      = 304, ///< For conditional requests, means the requested page hasn't changed and doesn't need to be refreshed\n\n            // 4xx: client error\n            BadRequest          = 400, ///< The server couldn't understand the request (syntax error)\n            Unauthorized        = 401, ///< The requested page needs an authentication to be accessed\n            Forbidden           = 403, ///< The requested page cannot be accessed at all, even with authentication\n            NotFound            = 404, ///< The requested page doesn't exist\n            RangeNotSatisfiable = 407, ///< The server can't satisfy the partial GET request (with a \"Range\" header field)\n\n            // 5xx: server error\n            InternalServerError = 500, ///< The server encountered an unexpected error\n            NotImplemented      = 501, ///< The server doesn't implement a requested feature\n            BadGateway          = 502, ///< The gateway server has received an error from the source server\n            ServiceNotAvailable = 503, ///< The server is temporarily unavailable (overloaded, in maintenance, ...)\n            GatewayTimeout      = 504, ///< The gateway server couldn't receive a response from the source server\n            VersionNotSupported = 505, ///< The server doesn't support the requested HTTP version\n\n            // 10xx: SFML custom codes\n            InvalidResponse  = 1000, ///< Response is not a valid HTTP one\n            ConnectionFailed = 1001  ///< Connection with server failed\n        };\n\n        ////////////////////////////////////////////////////////////\n        /// \\brief Default constructor\n        ///\n        /// Constructs an empty response.\n        ///\n        ////////////////////////////////////////////////////////////\n        Response();\n\n        ////////////////////////////////////////////////////////////\n        /// \\brief Get the value of a field\n        ///\n        /// If the field \\a field is not found in the response header,\n        /// the empty string is returned. This function uses\n        /// case-insensitive comparisons.\n        ///\n        /// \\param field Name of the field to get\n        ///\n        /// \\return Value of the field, or empty string if not found\n        ///\n        ////////////////////////////////////////////////////////////\n        const std::string& getField(const std::string& field) const;\n\n        ////////////////////////////////////////////////////////////\n        /// \\brief Get the response status code\n        ///\n        /// The status code should be the first thing to be checked\n        /// after receiving a response, it defines whether it is a\n        /// success, a failure or anything else (see the Status\n        /// enumeration).\n        ///\n        /// \\return Status code of the response\n        ///\n        ////////////////////////////////////////////////////////////\n        Status getStatus() const;\n\n        ////////////////////////////////////////////////////////////\n        /// \\brief Get the major HTTP version number of the response\n        ///\n        /// \\return Major HTTP version number\n        ///\n        /// \\see getMinorHttpVersion\n        ///\n        ////////////////////////////////////////////////////////////\n        unsigned int getMajorHttpVersion() const;\n\n        ////////////////////////////////////////////////////////////\n        /// \\brief Get the minor HTTP version number of the response\n        ///\n        /// \\return Minor HTTP version number\n        ///\n        /// \\see getMajorHttpVersion\n        ///\n        ////////////////////////////////////////////////////////////\n        unsigned int getMinorHttpVersion() const;\n\n        ////////////////////////////////////////////////////////////\n        /// \\brief Get the body of the response\n        ///\n        /// The body of a response may contain:\n        /// \\li the requested page (for GET requests)\n        /// \\li a response from the server (for POST requests)\n        /// \\li nothing (for HEAD requests)\n        /// \\li an error message (in case of an error)\n        ///\n        /// \\return The response body\n        ///\n        ////////////////////////////////////////////////////////////\n        const std::string& getBody() const;\n\n    private:\n\n        friend class Http;\n\n        ////////////////////////////////////////////////////////////\n        /// \\brief Construct the header from a response string\n        ///\n        /// This function is used by Http to build the response\n        /// of a request.\n        ///\n        /// \\param data Content of the response to parse\n        ///\n        ////////////////////////////////////////////////////////////\n        void parse(const std::string& data);\n\n\n        ////////////////////////////////////////////////////////////\n        /// \\brief Read values passed in the answer header\n        ///\n        /// This function is used by Http to extract values passed\n        /// in the response.\n        ///\n        /// \\param in String stream containing the header values\n        ///\n        ////////////////////////////////////////////////////////////\n        void parseFields(std::istream &in);\n\n        ////////////////////////////////////////////////////////////\n        // Types\n        ////////////////////////////////////////////////////////////\n        typedef std::map<std::string, std::string> FieldTable;\n\n        ////////////////////////////////////////////////////////////\n        // Member data\n        ////////////////////////////////////////////////////////////\n        FieldTable   m_fields;       ///< Fields of the header\n        Status       m_status;       ///< Status code\n        unsigned int m_majorVersion; ///< Major HTTP version\n        unsigned int m_minorVersion; ///< Minor HTTP version\n        std::string  m_body;         ///< Body of the response\n    };\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Default constructor\n    ///\n    ////////////////////////////////////////////////////////////\n    Http();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Construct the HTTP client with the target host\n    ///\n    /// This is equivalent to calling setHost(host, port).\n    /// The port has a default value of 0, which means that the\n    /// HTTP client will use the right port according to the\n    /// protocol used (80 for HTTP). You should leave it like\n    /// this unless you really need a port other than the\n    /// standard one, or use an unknown protocol.\n    ///\n    /// \\param host Web server to connect to\n    /// \\param port Port to use for connection\n    ///\n    ////////////////////////////////////////////////////////////\n    Http(const std::string& host, unsigned short port = 0);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Set the target host\n    ///\n    /// This function just stores the host address and port, it\n    /// doesn't actually connect to it until you send a request.\n    /// The port has a default value of 0, which means that the\n    /// HTTP client will use the right port according to the\n    /// protocol used (80 for HTTP). You should leave it like\n    /// this unless you really need a port other than the\n    /// standard one, or use an unknown protocol.\n    ///\n    /// \\param host Web server to connect to\n    /// \\param port Port to use for connection\n    ///\n    ////////////////////////////////////////////////////////////\n    void setHost(const std::string& host, unsigned short port = 0);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Send a HTTP request and return the server's response.\n    ///\n    /// You must have a valid host before sending a request (see setHost).\n    /// Any missing mandatory header field in the request will be added\n    /// with an appropriate value.\n    /// Warning: this function waits for the server's response and may\n    /// not return instantly; use a thread if you don't want to block your\n    /// application, or use a timeout to limit the time to wait. A value\n    /// of Time::Zero means that the client will use the system default timeout\n    /// (which is usually pretty long).\n    ///\n    /// \\param request Request to send\n    /// \\param timeout Maximum time to wait\n    ///\n    /// \\return Server's response\n    ///\n    ////////////////////////////////////////////////////////////\n    Response sendRequest(const Request& request, Time timeout = Time::Zero);\n\nprivate:\n\n    ////////////////////////////////////////////////////////////\n    // Member data\n    ////////////////////////////////////////////////////////////\n    TcpSocket      m_connection; ///< Connection to the host\n    IpAddress      m_host;       ///< Web host address\n    std::string    m_hostName;   ///< Web host name\n    unsigned short m_port;       ///< Port used for connection with host\n};\n\n} // namespace sf\n\n\n#endif // SFML_HTTP_HPP\n\n\n////////////////////////////////////////////////////////////\n/// \\class sf::Http\n/// \\ingroup network\n///\n/// sf::Http is a very simple HTTP client that allows you\n/// to communicate with a web server. You can retrieve\n/// web pages, send data to an interactive resource,\n/// download a remote file, etc. The HTTPS protocol is\n/// not supported.\n///\n/// The HTTP client is split into 3 classes:\n/// \\li sf::Http::Request\n/// \\li sf::Http::Response\n/// \\li sf::Http\n///\n/// sf::Http::Request builds the request that will be\n/// sent to the server. A request is made of:\n/// \\li a method (what you want to do)\n/// \\li a target URI (usually the name of the web page or file)\n/// \\li one or more header fields (options that you can pass to the server)\n/// \\li an optional body (for POST requests)\n///\n/// sf::Http::Response parse the response from the web server\n/// and provides getters to read them. The response contains:\n/// \\li a status code\n/// \\li header fields (that may be answers to the ones that you requested)\n/// \\li a body, which contains the contents of the requested resource\n///\n/// sf::Http provides a simple function, SendRequest, to send a\n/// sf::Http::Request and return the corresponding sf::Http::Response\n/// from the server.\n///\n/// Usage example:\n/// \\code\n/// // Create a new HTTP client\n/// sf::Http http;\n///\n/// // We'll work on http://www.sfml-dev.org\n/// http.setHost(\"http://www.sfml-dev.org\");\n///\n/// // Prepare a request to get the 'features.php' page\n/// sf::Http::Request request(\"features.php\");\n///\n/// // Send the request\n/// sf::Http::Response response = http.sendRequest(request);\n///\n/// // Check the status code and display the result\n/// sf::Http::Response::Status status = response.getStatus();\n/// if (status == sf::Http::Response::Ok)\n/// {\n///     std::cout << response.getBody() << std::endl;\n/// }\n/// else\n/// {\n///     std::cout << \"Error \" << status << std::endl;\n/// }\n/// \\endcode\n///\n////////////////////////////////////////////////////////////\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/Network/IpAddress.hpp",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n#ifndef SFML_IPADDRESS_HPP\n#define SFML_IPADDRESS_HPP\n\n////////////////////////////////////////////////////////////\n// Headers\n////////////////////////////////////////////////////////////\n#include <SFML/Network/Export.hpp>\n#include <SFML/System/Time.hpp>\n#include <istream>\n#include <ostream>\n#include <string>\n\n\nnamespace sf\n{\n////////////////////////////////////////////////////////////\n/// \\brief Encapsulate an IPv4 network address\n///\n////////////////////////////////////////////////////////////\nclass SFML_NETWORK_API IpAddress\n{\npublic:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Default constructor\n    ///\n    /// This constructor creates an empty (invalid) address\n    ///\n    ////////////////////////////////////////////////////////////\n    IpAddress();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Construct the address from a string\n    ///\n    /// Here \\a address can be either a decimal address\n    /// (ex: \"192.168.1.56\") or a network name (ex: \"localhost\").\n    ///\n    /// \\param address IP address or network name\n    ///\n    ////////////////////////////////////////////////////////////\n    IpAddress(const std::string& address);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Construct the address from a string\n    ///\n    /// Here \\a address can be either a decimal address\n    /// (ex: \"192.168.1.56\") or a network name (ex: \"localhost\").\n    /// This is equivalent to the constructor taking a std::string\n    /// parameter, it is defined for convenience so that the\n    /// implicit conversions from literal strings to IpAddress work.\n    ///\n    /// \\param address IP address or network name\n    ///\n    ////////////////////////////////////////////////////////////\n    IpAddress(const char* address);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Construct the address from 4 bytes\n    ///\n    /// Calling IpAddress(a, b, c, d) is equivalent to calling\n    /// IpAddress(\"a.b.c.d\"), but safer as it doesn't have to\n    /// parse a string to get the address components.\n    ///\n    /// \\param byte0 First byte of the address\n    /// \\param byte1 Second byte of the address\n    /// \\param byte2 Third byte of the address\n    /// \\param byte3 Fourth byte of the address\n    ///\n    ////////////////////////////////////////////////////////////\n    IpAddress(Uint8 byte0, Uint8 byte1, Uint8 byte2, Uint8 byte3);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Construct the address from a 32-bits integer\n    ///\n    /// This constructor uses the internal representation of\n    /// the address directly. It should be used for optimization\n    /// purposes, and only if you got that representation from\n    /// IpAddress::toInteger().\n    ///\n    /// \\param address 4 bytes of the address packed into a 32-bits integer\n    ///\n    /// \\see toInteger\n    ///\n    ////////////////////////////////////////////////////////////\n    explicit IpAddress(Uint32 address);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get a string representation of the address\n    ///\n    /// The returned string is the decimal representation of the\n    /// IP address (like \"192.168.1.56\"), even if it was constructed\n    /// from a host name.\n    ///\n    /// \\return String representation of the address\n    ///\n    /// \\see toInteger\n    ///\n    ////////////////////////////////////////////////////////////\n    std::string toString() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get an integer representation of the address\n    ///\n    /// The returned number is the internal representation of the\n    /// address, and should be used for optimization purposes only\n    /// (like sending the address through a socket).\n    /// The integer produced by this function can then be converted\n    /// back to a sf::IpAddress with the proper constructor.\n    ///\n    /// \\return 32-bits unsigned integer representation of the address\n    ///\n    /// \\see toString\n    ///\n    ////////////////////////////////////////////////////////////\n    Uint32 toInteger() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the computer's local address\n    ///\n    /// The local address is the address of the computer from the\n    /// LAN point of view, i.e. something like 192.168.1.56. It is\n    /// meaningful only for communications over the local network.\n    /// Unlike getPublicAddress, this function is fast and may be\n    /// used safely anywhere.\n    ///\n    /// \\return Local IP address of the computer\n    ///\n    /// \\see getPublicAddress\n    ///\n    ////////////////////////////////////////////////////////////\n    static IpAddress getLocalAddress();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the computer's public address\n    ///\n    /// The public address is the address of the computer from the\n    /// internet point of view, i.e. something like 89.54.1.169.\n    /// It is necessary for communications over the world wide web.\n    /// The only way to get a public address is to ask it to a\n    /// distant website; as a consequence, this function depends on\n    /// both your network connection and the server, and may be\n    /// very slow. You should use it as few as possible. Because\n    /// this function depends on the network connection and on a distant\n    /// server, you may use a time limit if you don't want your program\n    /// to be possibly stuck waiting in case there is a problem; this\n    /// limit is deactivated by default.\n    ///\n    /// \\param timeout Maximum time to wait\n    ///\n    /// \\return Public IP address of the computer\n    ///\n    /// \\see getLocalAddress\n    ///\n    ////////////////////////////////////////////////////////////\n    static IpAddress getPublicAddress(Time timeout = Time::Zero);\n\n    ////////////////////////////////////////////////////////////\n    // Static member data\n    ////////////////////////////////////////////////////////////\n    static const IpAddress None;      ///< Value representing an empty/invalid address\n    static const IpAddress Any;       ///< Value representing any address (0.0.0.0)\n    static const IpAddress LocalHost; ///< The \"localhost\" address (for connecting a computer to itself locally)\n    static const IpAddress Broadcast; ///< The \"broadcast\" address (for sending UDP messages to everyone on a local network)\n\nprivate:\n\n    friend SFML_NETWORK_API bool operator <(const IpAddress& left, const IpAddress& right);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Resolve the given address string\n    ///\n    /// \\param address Address string\n    ///\n    ////////////////////////////////////////////////////////////\n    void resolve(const std::string& address);\n\n    ////////////////////////////////////////////////////////////\n    // Member data\n    ////////////////////////////////////////////////////////////\n    Uint32 m_address; ///< Address stored as an unsigned 32 bits integer\n    bool   m_valid;   ///< Is the address valid?\n};\n\n////////////////////////////////////////////////////////////\n/// \\brief Overload of == operator to compare two IP addresses\n///\n/// \\param left  Left operand (a IP address)\n/// \\param right Right operand (a IP address)\n///\n/// \\return True if both addresses are equal\n///\n////////////////////////////////////////////////////////////\nSFML_NETWORK_API bool operator ==(const IpAddress& left, const IpAddress& right);\n\n////////////////////////////////////////////////////////////\n/// \\brief Overload of != operator to compare two IP addresses\n///\n/// \\param left  Left operand (a IP address)\n/// \\param right Right operand (a IP address)\n///\n/// \\return True if both addresses are different\n///\n////////////////////////////////////////////////////////////\nSFML_NETWORK_API bool operator !=(const IpAddress& left, const IpAddress& right);\n\n////////////////////////////////////////////////////////////\n/// \\brief Overload of < operator to compare two IP addresses\n///\n/// \\param left  Left operand (a IP address)\n/// \\param right Right operand (a IP address)\n///\n/// \\return True if \\a left is lesser than \\a right\n///\n////////////////////////////////////////////////////////////\nSFML_NETWORK_API bool operator <(const IpAddress& left, const IpAddress& right);\n\n////////////////////////////////////////////////////////////\n/// \\brief Overload of > operator to compare two IP addresses\n///\n/// \\param left  Left operand (a IP address)\n/// \\param right Right operand (a IP address)\n///\n/// \\return True if \\a left is greater than \\a right\n///\n////////////////////////////////////////////////////////////\nSFML_NETWORK_API bool operator >(const IpAddress& left, const IpAddress& right);\n\n////////////////////////////////////////////////////////////\n/// \\brief Overload of <= operator to compare two IP addresses\n///\n/// \\param left  Left operand (a IP address)\n/// \\param right Right operand (a IP address)\n///\n/// \\return True if \\a left is lesser or equal than \\a right\n///\n////////////////////////////////////////////////////////////\nSFML_NETWORK_API bool operator <=(const IpAddress& left, const IpAddress& right);\n\n////////////////////////////////////////////////////////////\n/// \\brief Overload of >= operator to compare two IP addresses\n///\n/// \\param left  Left operand (a IP address)\n/// \\param right Right operand (a IP address)\n///\n/// \\return True if \\a left is greater or equal than \\a right\n///\n////////////////////////////////////////////////////////////\nSFML_NETWORK_API bool operator >=(const IpAddress& left, const IpAddress& right);\n\n////////////////////////////////////////////////////////////\n/// \\brief Overload of >> operator to extract an IP address from an input stream\n///\n/// \\param stream  Input stream\n/// \\param address IP address to extract\n///\n/// \\return Reference to the input stream\n///\n////////////////////////////////////////////////////////////\nSFML_NETWORK_API std::istream& operator >>(std::istream& stream, IpAddress& address);\n\n////////////////////////////////////////////////////////////\n/// \\brief Overload of << operator to print an IP address to an output stream\n///\n/// \\param stream  Output stream\n/// \\param address IP address to print\n///\n/// \\return Reference to the output stream\n///\n////////////////////////////////////////////////////////////\nSFML_NETWORK_API std::ostream& operator <<(std::ostream& stream, const IpAddress& address);\n\n} // namespace sf\n\n\n#endif // SFML_IPADDRESS_HPP\n\n\n////////////////////////////////////////////////////////////\n/// \\class sf::IpAddress\n/// \\ingroup network\n///\n/// sf::IpAddress is a utility class for manipulating network\n/// addresses. It provides a set a implicit constructors and\n/// conversion functions to easily build or transform an IP\n/// address from/to various representations.\n///\n/// Usage example:\n/// \\code\n/// sf::IpAddress a0;                                     // an invalid address\n/// sf::IpAddress a1 = sf::IpAddress::None;               // an invalid address (same as a0)\n/// sf::IpAddress a2(\"127.0.0.1\");                        // the local host address\n/// sf::IpAddress a3 = sf::IpAddress::Broadcast;          // the broadcast address\n/// sf::IpAddress a4(192, 168, 1, 56);                    // a local address\n/// sf::IpAddress a5(\"my_computer\");                      // a local address created from a network name\n/// sf::IpAddress a6(\"89.54.1.169\");                      // a distant address\n/// sf::IpAddress a7(\"www.google.com\");                   // a distant address created from a network name\n/// sf::IpAddress a8 = sf::IpAddress::getLocalAddress();  // my address on the local network\n/// sf::IpAddress a9 = sf::IpAddress::getPublicAddress(); // my address on the internet\n/// \\endcode\n///\n/// Note that sf::IpAddress currently doesn't support IPv6\n/// nor other types of network addresses.\n///\n////////////////////////////////////////////////////////////\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/Network/Packet.hpp",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n#ifndef SFML_PACKET_HPP\n#define SFML_PACKET_HPP\n\n////////////////////////////////////////////////////////////\n// Headers\n////////////////////////////////////////////////////////////\n#include <SFML/Network/Export.hpp>\n#include <string>\n#include <vector>\n\n\nnamespace sf\n{\nclass String;\nclass TcpSocket;\nclass UdpSocket;\n\n////////////////////////////////////////////////////////////\n/// \\brief Utility class to build blocks of data to transfer\n///        over the network\n///\n////////////////////////////////////////////////////////////\nclass SFML_NETWORK_API Packet\n{\n    // A bool-like type that cannot be converted to integer or pointer types\n    typedef bool (Packet::*BoolType)(std::size_t);\n\npublic:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Default constructor\n    ///\n    /// Creates an empty packet.\n    ///\n    ////////////////////////////////////////////////////////////\n    Packet();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Virtual destructor\n    ///\n    ////////////////////////////////////////////////////////////\n    virtual ~Packet();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Append data to the end of the packet\n    ///\n    /// \\param data        Pointer to the sequence of bytes to append\n    /// \\param sizeInBytes Number of bytes to append\n    ///\n    /// \\see clear\n    ///\n    ////////////////////////////////////////////////////////////\n    void append(const void* data, std::size_t sizeInBytes);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Clear the packet\n    ///\n    /// After calling Clear, the packet is empty.\n    ///\n    /// \\see append\n    ///\n    ////////////////////////////////////////////////////////////\n    void clear();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get a pointer to the data contained in the packet\n    ///\n    /// Warning: the returned pointer may become invalid after\n    /// you append data to the packet, therefore it should never\n    /// be stored.\n    /// The return pointer is NULL if the packet is empty.\n    ///\n    /// \\return Pointer to the data\n    ///\n    /// \\see getDataSize\n    ///\n    ////////////////////////////////////////////////////////////\n    const void* getData() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the size of the data contained in the packet\n    ///\n    /// This function returns the number of bytes pointed to by\n    /// what getData returns.\n    ///\n    /// \\return Data size, in bytes\n    ///\n    /// \\see getData\n    ///\n    ////////////////////////////////////////////////////////////\n    std::size_t getDataSize() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Tell if the reading position has reached the\n    ///        end of the packet\n    ///\n    /// This function is useful to know if there is some data\n    /// left to be read, without actually reading it.\n    ///\n    /// \\return True if all data was read, false otherwise\n    ///\n    /// \\see operator bool\n    ///\n    ////////////////////////////////////////////////////////////\n    bool endOfPacket() const;\n\npublic:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Test the validity of the packet, for reading\n    ///\n    /// This operator allows to test the packet as a boolean\n    /// variable, to check if a reading operation was successful.\n    ///\n    /// A packet will be in an invalid state if it has no more\n    /// data to read.\n    ///\n    /// This behavior is the same as standard C++ streams.\n    ///\n    /// Usage example:\n    /// \\code\n    /// float x;\n    /// packet >> x;\n    /// if (packet)\n    /// {\n    ///    // ok, x was extracted successfully\n    /// }\n    ///\n    /// // -- or --\n    ///\n    /// float x;\n    /// if (packet >> x)\n    /// {\n    ///    // ok, x was extracted successfully\n    /// }\n    /// \\endcode\n    ///\n    /// Don't focus on the return type, it's equivalent to bool but\n    /// it disallows unwanted implicit conversions to integer or\n    /// pointer types.\n    ///\n    /// \\return True if last data extraction from packet was successful\n    ///\n    /// \\see endOfPacket\n    ///\n    ////////////////////////////////////////////////////////////\n    operator BoolType() const;\n\n    ////////////////////////////////////////////////////////////\n    /// Overloads of operator >> to read data from the packet\n    ///\n    ////////////////////////////////////////////////////////////\n    Packet& operator >>(bool&         data);\n    Packet& operator >>(Int8&         data);\n    Packet& operator >>(Uint8&        data);\n    Packet& operator >>(Int16&        data);\n    Packet& operator >>(Uint16&       data);\n    Packet& operator >>(Int32&        data);\n    Packet& operator >>(Uint32&       data);\n    Packet& operator >>(Int64&        data);\n    Packet& operator >>(Uint64&       data);\n    Packet& operator >>(float&        data);\n    Packet& operator >>(double&       data);\n    Packet& operator >>(char*         data);\n    Packet& operator >>(std::string&  data);\n    Packet& operator >>(wchar_t*      data);\n    Packet& operator >>(std::wstring& data);\n    Packet& operator >>(String&       data);\n\n    ////////////////////////////////////////////////////////////\n    /// Overloads of operator << to write data into the packet\n    ///\n    ////////////////////////////////////////////////////////////\n    Packet& operator <<(bool                data);\n    Packet& operator <<(Int8                data);\n    Packet& operator <<(Uint8               data);\n    Packet& operator <<(Int16               data);\n    Packet& operator <<(Uint16              data);\n    Packet& operator <<(Int32               data);\n    Packet& operator <<(Uint32              data);\n    Packet& operator <<(Int64               data);\n    Packet& operator <<(Uint64              data);\n    Packet& operator <<(float               data);\n    Packet& operator <<(double              data);\n    Packet& operator <<(const char*         data);\n    Packet& operator <<(const std::string&  data);\n    Packet& operator <<(const wchar_t*      data);\n    Packet& operator <<(const std::wstring& data);\n    Packet& operator <<(const String&       data);\n\nprotected:\n\n    friend class TcpSocket;\n    friend class UdpSocket;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Called before the packet is sent over the network\n    ///\n    /// This function can be defined by derived classes to\n    /// transform the data before it is sent; this can be\n    /// used for compression, encryption, etc.\n    /// The function must return a pointer to the modified data,\n    /// as well as the number of bytes pointed.\n    /// The default implementation provides the packet's data\n    /// without transforming it.\n    ///\n    /// \\param size Variable to fill with the size of data to send\n    ///\n    /// \\return Pointer to the array of bytes to send\n    ///\n    /// \\see onReceive\n    ///\n    ////////////////////////////////////////////////////////////\n    virtual const void* onSend(std::size_t& size);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Called after the packet is received over the network\n    ///\n    /// This function can be defined by derived classes to\n    /// transform the data after it is received; this can be\n    /// used for decompression, decryption, etc.\n    /// The function receives a pointer to the received data,\n    /// and must fill the packet with the transformed bytes.\n    /// The default implementation fills the packet directly\n    /// without transforming the data.\n    ///\n    /// \\param data Pointer to the received bytes\n    /// \\param size Number of bytes\n    ///\n    /// \\see onSend\n    ///\n    ////////////////////////////////////////////////////////////\n    virtual void onReceive(const void* data, std::size_t size);\n\nprivate:\n\n    ////////////////////////////////////////////////////////////\n    /// Disallow comparisons between packets\n    ///\n    ////////////////////////////////////////////////////////////\n    bool operator ==(const Packet& right) const;\n    bool operator !=(const Packet& right) const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Check if the packet can extract a given number of bytes\n    ///\n    /// This function updates accordingly the state of the packet.\n    ///\n    /// \\param size Size to check\n    ///\n    /// \\return True if \\a size bytes can be read from the packet\n    ///\n    ////////////////////////////////////////////////////////////\n    bool checkSize(std::size_t size);\n\n    ////////////////////////////////////////////////////////////\n    // Member data\n    ////////////////////////////////////////////////////////////\n    std::vector<char> m_data;    ///< Data stored in the packet\n    std::size_t       m_readPos; ///< Current reading position in the packet\n    std::size_t       m_sendPos; ///< Current send position in the packet (for handling partial sends)\n    bool              m_isValid; ///< Reading state of the packet\n};\n\n} // namespace sf\n\n\n#endif // SFML_PACKET_HPP\n\n\n////////////////////////////////////////////////////////////\n/// \\class sf::Packet\n/// \\ingroup network\n///\n/// Packets provide a safe and easy way to serialize data,\n/// in order to send it over the network using sockets\n/// (sf::TcpSocket, sf::UdpSocket).\n///\n/// Packets solve 2 fundamental problems that arise when\n/// transferring data over the network:\n/// \\li data is interpreted correctly according to the endianness\n/// \\li the bounds of the packet are preserved (one send == one receive)\n///\n/// The sf::Packet class provides both input and output modes.\n/// It is designed to follow the behavior of standard C++ streams,\n/// using operators >> and << to extract and insert data.\n///\n/// It is recommended to use only fixed-size types (like sf::Int32, etc.),\n/// to avoid possible differences between the sender and the receiver.\n/// Indeed, the native C++ types may have different sizes on two platforms\n/// and your data may be corrupted if that happens.\n///\n/// Usage example:\n/// \\code\n/// sf::Uint32 x = 24;\n/// std::string s = \"hello\";\n/// double d = 5.89;\n///\n/// // Group the variables to send into a packet\n/// sf::Packet packet;\n/// packet << x << s << d;\n///\n/// // Send it over the network (socket is a valid sf::TcpSocket)\n/// socket.send(packet);\n///\n/// -----------------------------------------------------------------\n///\n/// // Receive the packet at the other end\n/// sf::Packet packet;\n/// socket.receive(packet);\n///\n/// // Extract the variables contained in the packet\n/// sf::Uint32 x;\n/// std::string s;\n/// double d;\n/// if (packet >> x >> s >> d)\n/// {\n///     // Data extracted successfully...\n/// }\n/// \\endcode\n///\n/// Packets have built-in operator >> and << overloads for\n/// standard types:\n/// \\li bool\n/// \\li fixed-size integer types (sf::Int8/16/32, sf::Uint8/16/32)\n/// \\li floating point numbers (float, double)\n/// \\li string types (char*, wchar_t*, std::string, std::wstring, sf::String)\n///\n/// Like standard streams, it is also possible to define your own\n/// overloads of operators >> and << in order to handle your\n/// custom types.\n///\n/// \\code\n/// struct MyStruct\n/// {\n///     float       number;\n///     sf::Int8    integer;\n///     std::string str;\n/// };\n///\n/// sf::Packet& operator <<(sf::Packet& packet, const MyStruct& m)\n/// {\n///     return packet << m.number << m.integer << m.str;\n/// }\n///\n/// sf::Packet& operator >>(sf::Packet& packet, MyStruct& m)\n/// {\n///     return packet >> m.number >> m.integer >> m.str;\n/// }\n/// \\endcode\n///\n/// Packets also provide an extra feature that allows to apply\n/// custom transformations to the data before it is sent,\n/// and after it is received. This is typically used to\n/// handle automatic compression or encryption of the data.\n/// This is achieved by inheriting from sf::Packet, and overriding\n/// the onSend and onReceive functions.\n///\n/// Here is an example:\n/// \\code\n/// class ZipPacket : public sf::Packet\n/// {\n///     virtual const void* onSend(std::size_t& size)\n///     {\n///         const void* srcData = getData();\n///         std::size_t srcSize = getDataSize();\n///\n///         return MySuperZipFunction(srcData, srcSize, &size);\n///     }\n///\n///     virtual void onReceive(const void* data, std::size_t size)\n///     {\n///         std::size_t dstSize;\n///         const void* dstData = MySuperUnzipFunction(data, size, &dstSize);\n///\n///         append(dstData, dstSize);\n///     }\n/// };\n///\n/// // Use like regular packets:\n/// ZipPacket packet;\n/// packet << x << s << d;\n/// ...\n/// \\endcode\n///\n/// \\see sf::TcpSocket, sf::UdpSocket\n///\n////////////////////////////////////////////////////////////\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/Network/Socket.hpp",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n#ifndef SFML_SOCKET_HPP\n#define SFML_SOCKET_HPP\n\n////////////////////////////////////////////////////////////\n// Headers\n////////////////////////////////////////////////////////////\n#include <SFML/Network/Export.hpp>\n#include <SFML/Network/SocketHandle.hpp>\n#include <SFML/System/NonCopyable.hpp>\n#include <vector>\n\n\nnamespace sf\n{\nclass SocketSelector;\n\n////////////////////////////////////////////////////////////\n/// \\brief Base class for all the socket types\n///\n////////////////////////////////////////////////////////////\nclass SFML_NETWORK_API Socket : NonCopyable\n{\npublic:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Status codes that may be returned by socket functions\n    ///\n    ////////////////////////////////////////////////////////////\n    enum Status\n    {\n        Done,         ///< The socket has sent / received the data\n        NotReady,     ///< The socket is not ready to send / receive data yet\n        Partial,      ///< The socket sent a part of the data\n        Disconnected, ///< The TCP socket has been disconnected\n        Error         ///< An unexpected error happened\n    };\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Some special values used by sockets\n    ///\n    ////////////////////////////////////////////////////////////\n    enum\n    {\n        AnyPort = 0 ///< Special value that tells the system to pick any available port\n    };\n\npublic:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Destructor\n    ///\n    ////////////////////////////////////////////////////////////\n    virtual ~Socket();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Set the blocking state of the socket\n    ///\n    /// In blocking mode, calls will not return until they have\n    /// completed their task. For example, a call to Receive in\n    /// blocking mode won't return until some data was actually\n    /// received.\n    /// In non-blocking mode, calls will always return immediately,\n    /// using the return code to signal whether there was data\n    /// available or not.\n    /// By default, all sockets are blocking.\n    ///\n    /// \\param blocking True to set the socket as blocking, false for non-blocking\n    ///\n    /// \\see isBlocking\n    ///\n    ////////////////////////////////////////////////////////////\n    void setBlocking(bool blocking);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Tell whether the socket is in blocking or non-blocking mode\n    ///\n    /// \\return True if the socket is blocking, false otherwise\n    ///\n    /// \\see setBlocking\n    ///\n    ////////////////////////////////////////////////////////////\n    bool isBlocking() const;\n\nprotected:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Types of protocols that the socket can use\n    ///\n    ////////////////////////////////////////////////////////////\n    enum Type\n    {\n        Tcp, ///< TCP protocol\n        Udp  ///< UDP protocol\n    };\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Default constructor\n    ///\n    /// This constructor can only be accessed by derived classes.\n    ///\n    /// \\param type Type of the socket (TCP or UDP)\n    ///\n    ////////////////////////////////////////////////////////////\n    Socket(Type type);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Return the internal handle of the socket\n    ///\n    /// The returned handle may be invalid if the socket\n    /// was not created yet (or already destroyed).\n    /// This function can only be accessed by derived classes.\n    ///\n    /// \\return The internal (OS-specific) handle of the socket\n    ///\n    ////////////////////////////////////////////////////////////\n    SocketHandle getHandle() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Create the internal representation of the socket\n    ///\n    /// This function can only be accessed by derived classes.\n    ///\n    ////////////////////////////////////////////////////////////\n    void create();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Create the internal representation of the socket\n    ///        from a socket handle\n    ///\n    /// This function can only be accessed by derived classes.\n    ///\n    /// \\param handle OS-specific handle of the socket to wrap\n    ///\n    ////////////////////////////////////////////////////////////\n    void create(SocketHandle handle);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Close the socket gracefully\n    ///\n    /// This function can only be accessed by derived classes.\n    ///\n    ////////////////////////////////////////////////////////////\n    void close();\n\nprivate:\n\n    friend class SocketSelector;\n\n    ////////////////////////////////////////////////////////////\n    // Member data\n    ////////////////////////////////////////////////////////////\n    Type         m_type;       ///< Type of the socket (TCP or UDP)\n    SocketHandle m_socket;     ///< Socket descriptor\n    bool         m_isBlocking; ///< Current blocking mode of the socket\n};\n\n} // namespace sf\n\n\n#endif // SFML_SOCKET_HPP\n\n\n////////////////////////////////////////////////////////////\n/// \\class sf::Socket\n/// \\ingroup network\n///\n/// This class mainly defines internal stuff to be used by\n/// derived classes.\n///\n/// The only public features that it defines, and which\n/// is therefore common to all the socket classes, is the\n/// blocking state. All sockets can be set as blocking or\n/// non-blocking.\n///\n/// In blocking mode, socket functions will hang until\n/// the operation completes, which means that the entire\n/// program (well, in fact the current thread if you use\n/// multiple ones) will be stuck waiting for your socket\n/// operation to complete.\n///\n/// In non-blocking mode, all the socket functions will\n/// return immediately. If the socket is not ready to complete\n/// the requested operation, the function simply returns\n/// the proper status code (Socket::NotReady).\n///\n/// The default mode, which is blocking, is the one that is\n/// generally used, in combination with threads or selectors.\n/// The non-blocking mode is rather used in real-time\n/// applications that run an endless loop that can poll\n/// the socket often enough, and cannot afford blocking\n/// this loop.\n///\n/// \\see sf::TcpListener, sf::TcpSocket, sf::UdpSocket\n///\n////////////////////////////////////////////////////////////\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/Network/SocketHandle.hpp",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n#ifndef SFML_SOCKETHANDLE_HPP\n#define SFML_SOCKETHANDLE_HPP\n\n////////////////////////////////////////////////////////////\n// Headers\n////////////////////////////////////////////////////////////\n#include <SFML/Config.hpp>\n\n#if defined(SFML_SYSTEM_WINDOWS)\n    #include <basetsd.h>\n#endif\n\n\nnamespace sf\n{\n////////////////////////////////////////////////////////////\n// Define the low-level socket handle type, specific to\n// each platform\n////////////////////////////////////////////////////////////\n#if defined(SFML_SYSTEM_WINDOWS)\n\n    typedef UINT_PTR SocketHandle;\n\n#else\n\n    typedef int SocketHandle;\n\n#endif\n\n} // namespace sf\n\n\n#endif // SFML_SOCKETHANDLE_HPP\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/Network/SocketSelector.hpp",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n#ifndef SFML_SOCKETSELECTOR_HPP\n#define SFML_SOCKETSELECTOR_HPP\n\n////////////////////////////////////////////////////////////\n// Headers\n////////////////////////////////////////////////////////////\n#include <SFML/Network/Export.hpp>\n#include <SFML/System/Time.hpp>\n\n\nnamespace sf\n{\nclass Socket;\n\n////////////////////////////////////////////////////////////\n/// \\brief Multiplexer that allows to read from multiple sockets\n///\n////////////////////////////////////////////////////////////\nclass SFML_NETWORK_API SocketSelector\n{\npublic:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Default constructor\n    ///\n    ////////////////////////////////////////////////////////////\n    SocketSelector();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Copy constructor\n    ///\n    /// \\param copy Instance to copy\n    ///\n    ////////////////////////////////////////////////////////////\n    SocketSelector(const SocketSelector& copy);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Destructor\n    ///\n    ////////////////////////////////////////////////////////////\n    ~SocketSelector();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Add a new socket to the selector\n    ///\n    /// This function keeps a weak reference to the socket,\n    /// so you have to make sure that the socket is not destroyed\n    /// while it is stored in the selector.\n    /// This function does nothing if the socket is not valid.\n    ///\n    /// \\param socket Reference to the socket to add\n    ///\n    /// \\see remove, clear\n    ///\n    ////////////////////////////////////////////////////////////\n    void add(Socket& socket);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Remove a socket from the selector\n    ///\n    /// This function doesn't destroy the socket, it simply\n    /// removes the reference that the selector has to it.\n    ///\n    /// \\param socket Reference to the socket to remove\n    ///\n    /// \\see add, clear\n    ///\n    ////////////////////////////////////////////////////////////\n    void remove(Socket& socket);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Remove all the sockets stored in the selector\n    ///\n    /// This function doesn't destroy any instance, it simply\n    /// removes all the references that the selector has to\n    /// external sockets.\n    ///\n    /// \\see add, remove\n    ///\n    ////////////////////////////////////////////////////////////\n    void clear();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Wait until one or more sockets are ready to receive\n    ///\n    /// This function returns as soon as at least one socket has\n    /// some data available to be received. To know which sockets are\n    /// ready, use the isReady function.\n    /// If you use a timeout and no socket is ready before the timeout\n    /// is over, the function returns false.\n    ///\n    /// \\param timeout Maximum time to wait, (use Time::Zero for infinity)\n    ///\n    /// \\return True if there are sockets ready, false otherwise\n    ///\n    /// \\see isReady\n    ///\n    ////////////////////////////////////////////////////////////\n    bool wait(Time timeout = Time::Zero);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Test a socket to know if it is ready to receive data\n    ///\n    /// This function must be used after a call to Wait, to know\n    /// which sockets are ready to receive data. If a socket is\n    /// ready, a call to receive will never block because we know\n    /// that there is data available to read.\n    /// Note that if this function returns true for a TcpListener,\n    /// this means that it is ready to accept a new connection.\n    ///\n    /// \\param socket Socket to test\n    ///\n    /// \\return True if the socket is ready to read, false otherwise\n    ///\n    /// \\see isReady\n    ///\n    ////////////////////////////////////////////////////////////\n    bool isReady(Socket& socket) const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Overload of assignment operator\n    ///\n    /// \\param right Instance to assign\n    ///\n    /// \\return Reference to self\n    ///\n    ////////////////////////////////////////////////////////////\n    SocketSelector& operator =(const SocketSelector& right);\n\nprivate:\n\n    struct SocketSelectorImpl;\n\n    ////////////////////////////////////////////////////////////\n    // Member data\n    ////////////////////////////////////////////////////////////\n    SocketSelectorImpl* m_impl; ///< Opaque pointer to the implementation (which requires OS-specific types)\n};\n\n} // namespace sf\n\n\n#endif // SFML_SOCKETSELECTOR_HPP\n\n\n////////////////////////////////////////////////////////////\n/// \\class sf::SocketSelector\n/// \\ingroup network\n///\n/// Socket selectors provide a way to wait until some data is\n/// available on a set of sockets, instead of just one. This\n/// is convenient when you have multiple sockets that may\n/// possibly receive data, but you don't know which one will\n/// be ready first. In particular, it avoids to use a thread\n/// for each socket; with selectors, a single thread can handle\n/// all the sockets.\n///\n/// All types of sockets can be used in a selector:\n/// \\li sf::TcpListener\n/// \\li sf::TcpSocket\n/// \\li sf::UdpSocket\n///\n/// A selector doesn't store its own copies of the sockets\n/// (socket classes are not copyable anyway), it simply keeps\n/// a reference to the original sockets that you pass to the\n/// \"add\" function. Therefore, you can't use the selector as a\n/// socket container, you must store them outside and make sure\n/// that they are alive as long as they are used in the selector.\n///\n/// Using a selector is simple:\n/// \\li populate the selector with all the sockets that you want to observe\n/// \\li make it wait until there is data available on any of the sockets\n/// \\li test each socket to find out which ones are ready\n///\n/// Usage example:\n/// \\code\n/// // Create a socket to listen to new connections\n/// sf::TcpListener listener;\n/// listener.listen(55001);\n///\n/// // Create a list to store the future clients\n/// std::list<sf::TcpSocket*> clients;\n///\n/// // Create a selector\n/// sf::SocketSelector selector;\n///\n/// // Add the listener to the selector\n/// selector.add(listener);\n///\n/// // Endless loop that waits for new connections\n/// while (running)\n/// {\n///     // Make the selector wait for data on any socket\n///     if (selector.wait())\n///     {\n///         // Test the listener\n///         if (selector.isReady(listener))\n///         {\n///             // The listener is ready: there is a pending connection\n///             sf::TcpSocket* client = new sf::TcpSocket;\n///             if (listener.accept(*client) == sf::Socket::Done)\n///             {\n///                 // Add the new client to the clients list\n///                 clients.push_back(client);\n///\n///                 // Add the new client to the selector so that we will\n///                 // be notified when he sends something\n///                 selector.add(*client);\n///             }\n///             else\n///             {\n///                 // Error, we won't get a new connection, delete the socket\n///                 delete client;\n///             }\n///         }\n///         else\n///         {\n///             // The listener socket is not ready, test all other sockets (the clients)\n///             for (std::list<sf::TcpSocket*>::iterator it = clients.begin(); it != clients.end(); ++it)\n///             {\n///                 sf::TcpSocket& client = **it;\n///                 if (selector.isReady(client))\n///                 {\n///                     // The client has sent some data, we can receive it\n///                     sf::Packet packet;\n///                     if (client.receive(packet) == sf::Socket::Done)\n///                     {\n///                         ...\n///                     }\n///                 }\n///             }\n///         }\n///     }\n/// }\n/// \\endcode\n///\n/// \\see sf::Socket\n///\n////////////////////////////////////////////////////////////\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/Network/TcpListener.hpp",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n#ifndef SFML_TCPLISTENER_HPP\n#define SFML_TCPLISTENER_HPP\n\n////////////////////////////////////////////////////////////\n// Headers\n////////////////////////////////////////////////////////////\n#include <SFML/Network/Export.hpp>\n#include <SFML/Network/Socket.hpp>\n#include <SFML/Network/IpAddress.hpp>\n\n\nnamespace sf\n{\nclass TcpSocket;\n\n////////////////////////////////////////////////////////////\n/// \\brief Socket that listens to new TCP connections\n///\n////////////////////////////////////////////////////////////\nclass SFML_NETWORK_API TcpListener : public Socket\n{\npublic:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Default constructor\n    ///\n    ////////////////////////////////////////////////////////////\n    TcpListener();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the port to which the socket is bound locally\n    ///\n    /// If the socket is not listening to a port, this function\n    /// returns 0.\n    ///\n    /// \\return Port to which the socket is bound\n    ///\n    /// \\see listen\n    ///\n    ////////////////////////////////////////////////////////////\n    unsigned short getLocalPort() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Start listening for connections\n    ///\n    /// This functions makes the socket listen to the specified\n    /// port, waiting for new connections.\n    /// If the socket was previously listening to another port,\n    /// it will be stopped first and bound to the new port.\n    ///\n    /// \\param port    Port to listen for new connections\n    /// \\param address Address of the interface to listen on\n    ///\n    /// \\return Status code\n    ///\n    /// \\see accept, close\n    ///\n    ////////////////////////////////////////////////////////////\n    Status listen(unsigned short port, const IpAddress& address = IpAddress::Any);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Stop listening and close the socket\n    ///\n    /// This function gracefully stops the listener. If the\n    /// socket is not listening, this function has no effect.\n    ///\n    /// \\see listen\n    ///\n    ////////////////////////////////////////////////////////////\n    void close();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Accept a new connection\n    ///\n    /// If the socket is in blocking mode, this function will\n    /// not return until a connection is actually received.\n    ///\n    /// \\param socket Socket that will hold the new connection\n    ///\n    /// \\return Status code\n    ///\n    /// \\see listen\n    ///\n    ////////////////////////////////////////////////////////////\n    Status accept(TcpSocket& socket);\n};\n\n\n} // namespace sf\n\n\n#endif // SFML_TCPLISTENER_HPP\n\n\n////////////////////////////////////////////////////////////\n/// \\class sf::TcpListener\n/// \\ingroup network\n///\n/// A listener socket is a special type of socket that listens to\n/// a given port and waits for connections on that port.\n/// This is all it can do.\n///\n/// When a new connection is received, you must call accept and\n/// the listener returns a new instance of sf::TcpSocket that\n/// is properly initialized and can be used to communicate with\n/// the new client.\n///\n/// Listener sockets are specific to the TCP protocol,\n/// UDP sockets are connectionless and can therefore communicate\n/// directly. As a consequence, a listener socket will always\n/// return the new connections as sf::TcpSocket instances.\n///\n/// A listener is automatically closed on destruction, like all\n/// other types of socket. However if you want to stop listening\n/// before the socket is destroyed, you can call its close()\n/// function.\n///\n/// Usage example:\n/// \\code\n/// // Create a listener socket and make it wait for new\n/// // connections on port 55001\n/// sf::TcpListener listener;\n/// listener.listen(55001);\n///\n/// // Endless loop that waits for new connections\n/// while (running)\n/// {\n///     sf::TcpSocket client;\n///     if (listener.accept(client) == sf::Socket::Done)\n///     {\n///         // A new client just connected!\n///         std::cout << \"New connection received from \" << client.getRemoteAddress() << std::endl;\n///         doSomethingWith(client);\n///     }\n/// }\n/// \\endcode\n///\n/// \\see sf::TcpSocket, sf::Socket\n///\n////////////////////////////////////////////////////////////\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/Network/TcpSocket.hpp",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n#ifndef SFML_TCPSOCKET_HPP\n#define SFML_TCPSOCKET_HPP\n\n////////////////////////////////////////////////////////////\n// Headers\n////////////////////////////////////////////////////////////\n#include <SFML/Network/Export.hpp>\n#include <SFML/Network/Socket.hpp>\n#include <SFML/System/Time.hpp>\n\n\nnamespace sf\n{\nclass TcpListener;\nclass IpAddress;\nclass Packet;\n\n////////////////////////////////////////////////////////////\n/// \\brief Specialized socket using the TCP protocol\n///\n////////////////////////////////////////////////////////////\nclass SFML_NETWORK_API TcpSocket : public Socket\n{\npublic:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Default constructor\n    ///\n    ////////////////////////////////////////////////////////////\n    TcpSocket();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the port to which the socket is bound locally\n    ///\n    /// If the socket is not connected, this function returns 0.\n    ///\n    /// \\return Port to which the socket is bound\n    ///\n    /// \\see connect, getRemotePort\n    ///\n    ////////////////////////////////////////////////////////////\n    unsigned short getLocalPort() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the address of the connected peer\n    ///\n    /// It the socket is not connected, this function returns\n    /// sf::IpAddress::None.\n    ///\n    /// \\return Address of the remote peer\n    ///\n    /// \\see getRemotePort\n    ///\n    ////////////////////////////////////////////////////////////\n    IpAddress getRemoteAddress() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the port of the connected peer to which\n    ///        the socket is connected\n    ///\n    /// If the socket is not connected, this function returns 0.\n    ///\n    /// \\return Remote port to which the socket is connected\n    ///\n    /// \\see getRemoteAddress\n    ///\n    ////////////////////////////////////////////////////////////\n    unsigned short getRemotePort() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Connect the socket to a remote peer\n    ///\n    /// In blocking mode, this function may take a while, especially\n    /// if the remote peer is not reachable. The last parameter allows\n    /// you to stop trying to connect after a given timeout.\n    /// If the socket was previously connected, it is first disconnected.\n    ///\n    /// \\param remoteAddress Address of the remote peer\n    /// \\param remotePort    Port of the remote peer\n    /// \\param timeout       Optional maximum time to wait\n    ///\n    /// \\return Status code\n    ///\n    /// \\see disconnect\n    ///\n    ////////////////////////////////////////////////////////////\n    Status connect(const IpAddress& remoteAddress, unsigned short remotePort, Time timeout = Time::Zero);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Disconnect the socket from its remote peer\n    ///\n    /// This function gracefully closes the connection. If the\n    /// socket is not connected, this function has no effect.\n    ///\n    /// \\see connect\n    ///\n    ////////////////////////////////////////////////////////////\n    void disconnect();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Send raw data to the remote peer\n    ///\n    /// To be able to handle partial sends over non-blocking\n    /// sockets, use the send(const void*, std::size_t, std::size_t&)\n    /// overload instead.\n    /// This function will fail if the socket is not connected.\n    ///\n    /// \\param data Pointer to the sequence of bytes to send\n    /// \\param size Number of bytes to send\n    ///\n    /// \\return Status code\n    ///\n    /// \\see receive\n    ///\n    ////////////////////////////////////////////////////////////\n    Status send(const void* data, std::size_t size);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Send raw data to the remote peer\n    ///\n    /// This function will fail if the socket is not connected.\n    ///\n    /// \\param data Pointer to the sequence of bytes to send\n    /// \\param size Number of bytes to send\n    /// \\param sent The number of bytes sent will be written here\n    ///\n    /// \\return Status code\n    ///\n    /// \\see receive\n    ///\n    ////////////////////////////////////////////////////////////\n    Status send(const void* data, std::size_t size, std::size_t& sent);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Receive raw data from the remote peer\n    ///\n    /// In blocking mode, this function will wait until some\n    /// bytes are actually received.\n    /// This function will fail if the socket is not connected.\n    ///\n    /// \\param data     Pointer to the array to fill with the received bytes\n    /// \\param size     Maximum number of bytes that can be received\n    /// \\param received This variable is filled with the actual number of bytes received\n    ///\n    /// \\return Status code\n    ///\n    /// \\see send\n    ///\n    ////////////////////////////////////////////////////////////\n    Status receive(void* data, std::size_t size, std::size_t& received);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Send a formatted packet of data to the remote peer\n    ///\n    /// In non-blocking mode, if this function returns sf::Socket::Partial,\n    /// you \\em must retry sending the same unmodified packet before sending\n    /// anything else in order to guarantee the packet arrives at the remote\n    /// peer uncorrupted.\n    /// This function will fail if the socket is not connected.\n    ///\n    /// \\param packet Packet to send\n    ///\n    /// \\return Status code\n    ///\n    /// \\see receive\n    ///\n    ////////////////////////////////////////////////////////////\n    Status send(Packet& packet);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Receive a formatted packet of data from the remote peer\n    ///\n    /// In blocking mode, this function will wait until the whole packet\n    /// has been received.\n    /// This function will fail if the socket is not connected.\n    ///\n    /// \\param packet Packet to fill with the received data\n    ///\n    /// \\return Status code\n    ///\n    /// \\see send\n    ///\n    ////////////////////////////////////////////////////////////\n    Status receive(Packet& packet);\n\nprivate:\n\n    friend class TcpListener;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Structure holding the data of a pending packet\n    ///\n    ////////////////////////////////////////////////////////////\n    struct PendingPacket\n    {\n        PendingPacket();\n\n        Uint32            Size;         ///< Data of packet size\n        std::size_t       SizeReceived; ///< Number of size bytes received so far\n        std::vector<char> Data;         ///< Data of the packet\n    };\n\n    ////////////////////////////////////////////////////////////\n    // Member data\n    ////////////////////////////////////////////////////////////\n    PendingPacket m_pendingPacket; ///< Temporary data of the packet currently being received\n};\n\n} // namespace sf\n\n\n#endif // SFML_TCPSOCKET_HPP\n\n\n////////////////////////////////////////////////////////////\n/// \\class sf::TcpSocket\n/// \\ingroup network\n///\n/// TCP is a connected protocol, which means that a TCP\n/// socket can only communicate with the host it is connected\n/// to. It can't send or receive anything if it is not connected.\n///\n/// The TCP protocol is reliable but adds a slight overhead.\n/// It ensures that your data will always be received in order\n/// and without errors (no data corrupted, lost or duplicated).\n///\n/// When a socket is connected to a remote host, you can\n/// retrieve informations about this host with the\n/// getRemoteAddress and getRemotePort functions. You can\n/// also get the local port to which the socket is bound\n/// (which is automatically chosen when the socket is connected),\n/// with the getLocalPort function.\n///\n/// Sending and receiving data can use either the low-level\n/// or the high-level functions. The low-level functions\n/// process a raw sequence of bytes, and cannot ensure that\n/// one call to Send will exactly match one call to Receive\n/// at the other end of the socket.\n///\n/// The high-level interface uses packets (see sf::Packet),\n/// which are easier to use and provide more safety regarding\n/// the data that is exchanged. You can look at the sf::Packet\n/// class to get more details about how they work.\n///\n/// The socket is automatically disconnected when it is destroyed,\n/// but if you want to explicitly close the connection while\n/// the socket instance is still alive, you can call disconnect.\n///\n/// Usage example:\n/// \\code\n/// // ----- The client -----\n///\n/// // Create a socket and connect it to 192.168.1.50 on port 55001\n/// sf::TcpSocket socket;\n/// socket.connect(\"192.168.1.50\", 55001);\n///\n/// // Send a message to the connected host\n/// std::string message = \"Hi, I am a client\";\n/// socket.send(message.c_str(), message.size() + 1);\n///\n/// // Receive an answer from the server\n/// char buffer[1024];\n/// std::size_t received = 0;\n/// socket.receive(buffer, sizeof(buffer), received);\n/// std::cout << \"The server said: \" << buffer << std::endl;\n///\n/// // ----- The server -----\n///\n/// // Create a listener to wait for incoming connections on port 55001\n/// sf::TcpListener listener;\n/// listener.listen(55001);\n///\n/// // Wait for a connection\n/// sf::TcpSocket socket;\n/// listener.accept(socket);\n/// std::cout << \"New client connected: \" << socket.getRemoteAddress() << std::endl;\n///\n/// // Receive a message from the client\n/// char buffer[1024];\n/// std::size_t received = 0;\n/// socket.receive(buffer, sizeof(buffer), received);\n/// std::cout << \"The client said: \" << buffer << std::endl;\n///\n/// // Send an answer\n/// std::string message = \"Welcome, client\";\n/// socket.send(message.c_str(), message.size() + 1);\n/// \\endcode\n///\n/// \\see sf::Socket, sf::UdpSocket, sf::Packet\n///\n////////////////////////////////////////////////////////////\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/Network/UdpSocket.hpp",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n#ifndef SFML_UDPSOCKET_HPP\n#define SFML_UDPSOCKET_HPP\n\n////////////////////////////////////////////////////////////\n// Headers\n////////////////////////////////////////////////////////////\n#include <SFML/Network/Export.hpp>\n#include <SFML/Network/Socket.hpp>\n#include <SFML/Network/IpAddress.hpp>\n#include <vector>\n\n\nnamespace sf\n{\nclass Packet;\n\n////////////////////////////////////////////////////////////\n/// \\brief Specialized socket using the UDP protocol\n///\n////////////////////////////////////////////////////////////\nclass SFML_NETWORK_API UdpSocket : public Socket\n{\npublic:\n\n    ////////////////////////////////////////////////////////////\n    // Constants\n    ////////////////////////////////////////////////////////////\n    enum\n    {\n        MaxDatagramSize = 65507 ///< The maximum number of bytes that can be sent in a single UDP datagram\n    };\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Default constructor\n    ///\n    ////////////////////////////////////////////////////////////\n    UdpSocket();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the port to which the socket is bound locally\n    ///\n    /// If the socket is not bound to a port, this function\n    /// returns 0.\n    ///\n    /// \\return Port to which the socket is bound\n    ///\n    /// \\see bind\n    ///\n    ////////////////////////////////////////////////////////////\n    unsigned short getLocalPort() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Bind the socket to a specific port\n    ///\n    /// Binding the socket to a port is necessary for being\n    /// able to receive data on that port.\n    /// You can use the special value Socket::AnyPort to tell the\n    /// system to automatically pick an available port, and then\n    /// call getLocalPort to retrieve the chosen port.\n    ///\n    /// \\param port    Port to bind the socket to\n    /// \\param address Address of the interface to bind to\n    ///\n    /// \\return Status code\n    ///\n    /// \\see unbind, getLocalPort\n    ///\n    ////////////////////////////////////////////////////////////\n    Status bind(unsigned short port, const IpAddress& address = IpAddress::Any);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Unbind the socket from the local port to which it is bound\n    ///\n    /// The port that the socket was previously bound to is immediately\n    /// made available to the operating system after this function is called.\n    /// This means that a subsequent call to bind() will be able to re-bind\n    /// the port if no other process has done so in the mean time.\n    /// If the socket is not bound to a port, this function has no effect.\n    ///\n    /// \\see bind\n    ///\n    ////////////////////////////////////////////////////////////\n    void unbind();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Send raw data to a remote peer\n    ///\n    /// Make sure that \\a size is not greater than\n    /// UdpSocket::MaxDatagramSize, otherwise this function will\n    /// fail and no data will be sent.\n    ///\n    /// \\param data          Pointer to the sequence of bytes to send\n    /// \\param size          Number of bytes to send\n    /// \\param remoteAddress Address of the receiver\n    /// \\param remotePort    Port of the receiver to send the data to\n    ///\n    /// \\return Status code\n    ///\n    /// \\see receive\n    ///\n    ////////////////////////////////////////////////////////////\n    Status send(const void* data, std::size_t size, const IpAddress& remoteAddress, unsigned short remotePort);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Receive raw data from a remote peer\n    ///\n    /// In blocking mode, this function will wait until some\n    /// bytes are actually received.\n    /// Be careful to use a buffer which is large enough for\n    /// the data that you intend to receive, if it is too small\n    /// then an error will be returned and *all* the data will\n    /// be lost.\n    ///\n    /// \\param data          Pointer to the array to fill with the received bytes\n    /// \\param size          Maximum number of bytes that can be received\n    /// \\param received      This variable is filled with the actual number of bytes received\n    /// \\param remoteAddress Address of the peer that sent the data\n    /// \\param remotePort    Port of the peer that sent the data\n    ///\n    /// \\return Status code\n    ///\n    /// \\see send\n    ///\n    ////////////////////////////////////////////////////////////\n    Status receive(void* data, std::size_t size, std::size_t& received, IpAddress& remoteAddress, unsigned short& remotePort);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Send a formatted packet of data to a remote peer\n    ///\n    /// Make sure that the packet size is not greater than\n    /// UdpSocket::MaxDatagramSize, otherwise this function will\n    /// fail and no data will be sent.\n    ///\n    /// \\param packet        Packet to send\n    /// \\param remoteAddress Address of the receiver\n    /// \\param remotePort    Port of the receiver to send the data to\n    ///\n    /// \\return Status code\n    ///\n    /// \\see receive\n    ///\n    ////////////////////////////////////////////////////////////\n    Status send(Packet& packet, const IpAddress& remoteAddress, unsigned short remotePort);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Receive a formatted packet of data from a remote peer\n    ///\n    /// In blocking mode, this function will wait until the whole packet\n    /// has been received.\n    ///\n    /// \\param packet        Packet to fill with the received data\n    /// \\param remoteAddress Address of the peer that sent the data\n    /// \\param remotePort    Port of the peer that sent the data\n    ///\n    /// \\return Status code\n    ///\n    /// \\see send\n    ///\n    ////////////////////////////////////////////////////////////\n    Status receive(Packet& packet, IpAddress& remoteAddress, unsigned short& remotePort);\n\nprivate:\n\n    ////////////////////////////////////////////////////////////\n    // Member data\n    ////////////////////////////////////////////////////////////\n    std::vector<char> m_buffer; ///< Temporary buffer holding the received data in Receive(Packet)\n};\n\n} // namespace sf\n\n\n#endif // SFML_UDPSOCKET_HPP\n\n\n////////////////////////////////////////////////////////////\n/// \\class sf::UdpSocket\n/// \\ingroup network\n///\n/// A UDP socket is a connectionless socket. Instead of\n/// connecting once to a remote host, like TCP sockets,\n/// it can send to and receive from any host at any time.\n///\n/// It is a datagram protocol: bounded blocks of data (datagrams)\n/// are transfered over the network rather than a continuous\n/// stream of data (TCP). Therefore, one call to send will always\n/// match one call to receive (if the datagram is not lost),\n/// with the same data that was sent.\n///\n/// The UDP protocol is lightweight but unreliable. Unreliable\n/// means that datagrams may be duplicated, be lost or\n/// arrive reordered. However, if a datagram arrives, its\n/// data is guaranteed to be valid.\n///\n/// UDP is generally used for real-time communication\n/// (audio or video streaming, real-time games, etc.) where\n/// speed is crucial and lost data doesn't matter much.\n///\n/// Sending and receiving data can use either the low-level\n/// or the high-level functions. The low-level functions\n/// process a raw sequence of bytes, whereas the high-level\n/// interface uses packets (see sf::Packet), which are easier\n/// to use and provide more safety regarding the data that is\n/// exchanged. You can look at the sf::Packet class to get\n/// more details about how they work.\n///\n/// It is important to note that UdpSocket is unable to send\n/// datagrams bigger than MaxDatagramSize. In this case, it\n/// returns an error and doesn't send anything. This applies\n/// to both raw data and packets. Indeed, even packets are\n/// unable to split and recompose data, due to the unreliability\n/// of the protocol (dropped, mixed or duplicated datagrams may\n/// lead to a big mess when trying to recompose a packet).\n///\n/// If the socket is bound to a port, it is automatically\n/// unbound from it when the socket is destroyed. However,\n/// you can unbind the socket explicitly with the Unbind\n/// function if necessary, to stop receiving messages or\n/// make the port available for other sockets.\n///\n/// Usage example:\n/// \\code\n/// // ----- The client -----\n///\n/// // Create a socket and bind it to the port 55001\n/// sf::UdpSocket socket;\n/// socket.bind(55001);\n///\n/// // Send a message to 192.168.1.50 on port 55002\n/// std::string message = \"Hi, I am \" + sf::IpAddress::getLocalAddress().toString();\n/// socket.send(message.c_str(), message.size() + 1, \"192.168.1.50\", 55002);\n///\n/// // Receive an answer (most likely from 192.168.1.50, but could be anyone else)\n/// char buffer[1024];\n/// std::size_t received = 0;\n/// sf::IpAddress sender;\n/// unsigned short port;\n/// socket.receive(buffer, sizeof(buffer), received, sender, port);\n/// std::cout << sender.ToString() << \" said: \" << buffer << std::endl;\n///\n/// // ----- The server -----\n///\n/// // Create a socket and bind it to the port 55002\n/// sf::UdpSocket socket;\n/// socket.bind(55002);\n///\n/// // Receive a message from anyone\n/// char buffer[1024];\n/// std::size_t received = 0;\n/// sf::IpAddress sender;\n/// unsigned short port;\n/// socket.receive(buffer, sizeof(buffer), received, sender, port);\n/// std::cout << sender.ToString() << \" said: \" << buffer << std::endl;\n///\n/// // Send an answer\n/// std::string message = \"Welcome \" + sender.toString();\n/// socket.send(message.c_str(), message.size() + 1, sender, port);\n/// \\endcode\n///\n/// \\see sf::Socket, sf::TcpSocket, sf::Packet\n///\n////////////////////////////////////////////////////////////\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/Network.hpp",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n#ifndef SFML_NETWORK_HPP\n#define SFML_NETWORK_HPP\n\n////////////////////////////////////////////////////////////\n// Headers\n////////////////////////////////////////////////////////////\n\n#include <SFML/System.hpp>\n#include <SFML/Network/Ftp.hpp>\n#include <SFML/Network/Http.hpp>\n#include <SFML/Network/IpAddress.hpp>\n#include <SFML/Network/Packet.hpp>\n#include <SFML/Network/Socket.hpp>\n#include <SFML/Network/SocketHandle.hpp>\n#include <SFML/Network/SocketSelector.hpp>\n#include <SFML/Network/TcpListener.hpp>\n#include <SFML/Network/TcpSocket.hpp>\n#include <SFML/Network/UdpSocket.hpp>\n\n\n#endif // SFML_NETWORK_HPP\n\n////////////////////////////////////////////////////////////\n/// \\defgroup network Network module\n///\n/// Socket-based communication, utilities and higher-level\n/// network protocols (HTTP, FTP).\n///\n////////////////////////////////////////////////////////////\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/OpenGL.hpp",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n#ifndef SFML_OPENGL_HPP\n#define SFML_OPENGL_HPP\n\n\n////////////////////////////////////////////////////////////\n/// Headers\n////////////////////////////////////////////////////////////\n#include <SFML/Config.hpp>\n\n\n////////////////////////////////////////////////////////////\n/// This file just includes the OpenGL headers,\n/// which have actually different paths on each system\n////////////////////////////////////////////////////////////\n#if defined(SFML_SYSTEM_WINDOWS)\n\n    // The Visual C++ version of gl.h uses WINGDIAPI and APIENTRY but doesn't define them\n    #ifdef _MSC_VER\n        #include <windows.h>\n    #endif\n\n    #include <GL/gl.h>\n\n#elif defined(SFML_SYSTEM_LINUX) || defined(SFML_SYSTEM_FREEBSD)\n\n    #if defined(SFML_OPENGL_ES)\n        #include <GLES/gl.h>\n        #include <GLES/glext.h>\n    #else\n        #include <GL/gl.h>\n    #endif\n\n#elif defined(SFML_SYSTEM_MACOS)\n\n    #include <OpenGL/gl.h>\n\n#elif defined (SFML_SYSTEM_IOS)\n\n    #include <OpenGLES/ES1/gl.h>\n    #include <OpenGLES/ES1/glext.h>\n\n#elif defined (SFML_SYSTEM_ANDROID)\n\n    #include <GLES/gl.h>\n    #include <GLES/glext.h>\n    \n    // We're not using OpenGL ES 2+ yet, but we can use the sRGB extension\n    #include <GLES2/gl2ext.h>\n\n#endif\n\n\n#endif // SFML_OPENGL_HPP\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/System/Clock.hpp",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n#ifndef SFML_CLOCK_HPP\n#define SFML_CLOCK_HPP\n\n////////////////////////////////////////////////////////////\n// Headers\n////////////////////////////////////////////////////////////\n#include <SFML/System/Export.hpp>\n#include <SFML/System/Time.hpp>\n\n\nnamespace sf\n{\n////////////////////////////////////////////////////////////\n/// \\brief Utility class that measures the elapsed time\n///\n////////////////////////////////////////////////////////////\nclass SFML_SYSTEM_API Clock\n{\npublic:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Default constructor\n    ///\n    /// The clock starts automatically after being constructed.\n    ///\n    ////////////////////////////////////////////////////////////\n    Clock();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the elapsed time\n    ///\n    /// This function returns the time elapsed since the last call\n    /// to restart() (or the construction of the instance if restart()\n    /// has not been called).\n    ///\n    /// \\return Time elapsed\n    ///\n    ////////////////////////////////////////////////////////////\n    Time getElapsedTime() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Restart the clock\n    ///\n    /// This function puts the time counter back to zero.\n    /// It also returns the time elapsed since the clock was started.\n    ///\n    /// \\return Time elapsed\n    ///\n    ////////////////////////////////////////////////////////////\n    Time restart();\n\nprivate:\n\n    ////////////////////////////////////////////////////////////\n    // Member data\n    ////////////////////////////////////////////////////////////\n    Time m_startTime; ///< Time of last reset, in microseconds\n};\n\n} // namespace sf\n\n\n#endif // SFML_CLOCK_HPP\n\n\n////////////////////////////////////////////////////////////\n/// \\class sf::Clock\n/// \\ingroup system\n///\n/// sf::Clock is a lightweight class for measuring time.\n///\n/// Its provides the most precise time that the underlying\n/// OS can achieve (generally microseconds or nanoseconds).\n/// It also ensures monotonicity, which means that the returned\n/// time can never go backward, even if the system time is\n/// changed.\n///\n/// Usage example:\n/// \\code\n/// sf::Clock clock;\n/// ...\n/// Time time1 = clock.getElapsedTime();\n/// ...\n/// Time time2 = clock.restart();\n/// \\endcode\n///\n/// The sf::Time value returned by the clock can then be\n/// converted to a number of seconds, milliseconds or even\n/// microseconds.\n///\n/// \\see sf::Time\n///\n////////////////////////////////////////////////////////////\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/System/Err.hpp",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n#ifndef SFML_ERR_HPP\n#define SFML_ERR_HPP\n\n////////////////////////////////////////////////////////////\n// Headers\n////////////////////////////////////////////////////////////\n#include <SFML/System/Export.hpp>\n#include <ostream>\n\n\nnamespace sf\n{\n////////////////////////////////////////////////////////////\n/// \\brief Standard stream used by SFML to output warnings and errors\n///\n////////////////////////////////////////////////////////////\nSFML_SYSTEM_API std::ostream& err();\n\n} // namespace sf\n\n\n#endif // SFML_ERR_HPP\n\n\n////////////////////////////////////////////////////////////\n/// \\fn sf::err\n/// \\ingroup system\n///\n/// By default, sf::err() outputs to the same location as std::cerr,\n/// (-> the stderr descriptor) which is the console if there's\n/// one available.\n///\n/// It is a standard std::ostream instance, so it supports all the\n/// insertion operations defined by the STL\n/// (operator <<, manipulators, etc.).\n///\n/// sf::err() can be redirected to write to another output, independently\n/// of std::cerr, by using the rdbuf() function provided by the\n/// std::ostream class.\n///\n/// Example:\n/// \\code\n/// // Redirect to a file\n/// std::ofstream file(\"sfml-log.txt\");\n/// std::streambuf* previous = sf::err().rdbuf(file.rdbuf());\n///\n/// // Redirect to nothing\n/// sf::err().rdbuf(NULL);\n///\n/// // Restore the original output\n/// sf::err().rdbuf(previous);\n/// \\endcode\n///\n/// \\return Reference to std::ostream representing the SFML error stream\n///\n////////////////////////////////////////////////////////////\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/System/Export.hpp",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n#ifndef SFML_SYSTEM_EXPORT_HPP\n#define SFML_SYSTEM_EXPORT_HPP\n\n////////////////////////////////////////////////////////////\n// Headers\n////////////////////////////////////////////////////////////\n#include <SFML/Config.hpp>\n\n\n////////////////////////////////////////////////////////////\n// Define portable import / export macros\n////////////////////////////////////////////////////////////\n#if defined(SFML_SYSTEM_EXPORTS)\n\n    #define SFML_SYSTEM_API SFML_API_EXPORT\n\n#else\n\n    #define SFML_SYSTEM_API SFML_API_IMPORT\n\n#endif\n\n\n#endif // SFML_SYSTEM_EXPORT_HPP\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/System/FileInputStream.hpp",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n#ifndef SFML_FILEINPUTSTREAM_HPP\n#define SFML_FILEINPUTSTREAM_HPP\n\n////////////////////////////////////////////////////////////\n// Headers\n////////////////////////////////////////////////////////////\n#include <SFML/Config.hpp>\n#include <SFML/System/Export.hpp>\n#include <SFML/System/InputStream.hpp>\n#include <SFML/System/NonCopyable.hpp>\n#include <cstdio>\n#include <string>\n\n#ifdef ANDROID\nnamespace sf\n{\nnamespace priv\n{\nclass SFML_SYSTEM_API ResourceStream;\n}\n}\n#endif\n\n\nnamespace sf\n{\n////////////////////////////////////////////////////////////\n/// \\brief Implementation of input stream based on a file\n///\n////////////////////////////////////////////////////////////\nclass SFML_SYSTEM_API FileInputStream : public InputStream, NonCopyable\n{\npublic:\n    ////////////////////////////////////////////////////////////\n    /// \\brief Default constructor\n    ///\n    ////////////////////////////////////////////////////////////\n    FileInputStream();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Default destructor\n    ///\n    ////////////////////////////////////////////////////////////\n    virtual ~FileInputStream();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Open the stream from a file path\n    ///\n    /// \\param filename Name of the file to open\n    ///\n    /// \\return True on success, false on error\n    ///\n    ////////////////////////////////////////////////////////////\n    bool open(const std::string& filename);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Read data from the stream\n    ///\n    /// After reading, the stream's reading position must be\n    /// advanced by the amount of bytes read.\n    ///\n    /// \\param data Buffer where to copy the read data\n    /// \\param size Desired number of bytes to read\n    ///\n    /// \\return The number of bytes actually read, or -1 on error\n    ///\n    ////////////////////////////////////////////////////////////\n    virtual Int64 read(void* data, Int64 size);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Change the current reading position\n    ///\n    /// \\param position The position to seek to, from the beginning\n    ///\n    /// \\return The position actually sought to, or -1 on error\n    ///\n    ////////////////////////////////////////////////////////////\n    virtual Int64 seek(Int64 position);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the current reading position in the stream\n    ///\n    /// \\return The current position, or -1 on error.\n    ///\n    ////////////////////////////////////////////////////////////\n    virtual Int64 tell();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Return the size of the stream\n    ///\n    /// \\return The total number of bytes available in the stream, or -1 on error\n    ///\n    ////////////////////////////////////////////////////////////\n    virtual Int64 getSize();\n\nprivate:\n\n    ////////////////////////////////////////////////////////////\n    // Member data\n    ////////////////////////////////////////////////////////////\n#ifdef ANDROID\n    priv::ResourceStream* m_file;\n#else\n    std::FILE* m_file; ///< stdio file stream\n#endif\n};\n\n} // namespace sf\n\n\n#endif // SFML_FILEINPUTSTREAM_HPP\n\n\n////////////////////////////////////////////////////////////\n/// \\class sf::FileInputStream\n/// \\ingroup system\n///\n/// This class is a specialization of InputStream that\n/// reads from a file on disk.\n///\n/// It wraps a file in the common InputStream interface\n/// and therefore allows to use generic classes or functions\n/// that accept such a stream, with a file on disk as the data\n/// source.\n///\n/// In addition to the virtual functions inherited from\n/// InputStream, FileInputStream adds a function to\n/// specify the file to open.\n///\n/// SFML resource classes can usually be loaded directly from\n/// a filename, so this class shouldn't be useful to you unless\n/// you create your own algorithms that operate on an InputStream.\n///\n/// Usage example:\n/// \\code\n/// void process(InputStream& stream);\n///\n/// FileInputStream stream;\n/// if (stream.open(\"some_file.dat\"))\n///    process(stream);\n/// \\endcode\n///\n/// InputStream, MemoryInputStream\n///\n////////////////////////////////////////////////////////////\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/System/InputStream.hpp",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n#ifndef SFML_INPUTSTREAM_HPP\n#define SFML_INPUTSTREAM_HPP\n\n////////////////////////////////////////////////////////////\n// Headers\n////////////////////////////////////////////////////////////\n#include <SFML/Config.hpp>\n#include <SFML/System/Export.hpp>\n\n\nnamespace sf\n{\n////////////////////////////////////////////////////////////\n/// \\brief Abstract class for custom file input streams\n///\n////////////////////////////////////////////////////////////\nclass SFML_SYSTEM_API InputStream\n{\npublic:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Virtual destructor\n    ///\n    ////////////////////////////////////////////////////////////\n    virtual ~InputStream() {}\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Read data from the stream\n    ///\n    /// After reading, the stream's reading position must be\n    /// advanced by the amount of bytes read.\n    ///\n    /// \\param data Buffer where to copy the read data\n    /// \\param size Desired number of bytes to read\n    ///\n    /// \\return The number of bytes actually read, or -1 on error\n    ///\n    ////////////////////////////////////////////////////////////\n    virtual Int64 read(void* data, Int64 size) = 0;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Change the current reading position\n    ///\n    /// \\param position The position to seek to, from the beginning\n    ///\n    /// \\return The position actually sought to, or -1 on error\n    ///\n    ////////////////////////////////////////////////////////////\n    virtual Int64 seek(Int64 position) = 0;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the current reading position in the stream\n    ///\n    /// \\return The current position, or -1 on error.\n    ///\n    ////////////////////////////////////////////////////////////\n    virtual Int64 tell() = 0;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Return the size of the stream\n    ///\n    /// \\return The total number of bytes available in the stream, or -1 on error\n    ///\n    ////////////////////////////////////////////////////////////\n    virtual Int64 getSize() = 0;\n};\n\n} // namespace sf\n\n\n#endif // SFML_INPUTSTREAM_HPP\n\n\n////////////////////////////////////////////////////////////\n/// \\class sf::InputStream\n/// \\ingroup system\n///\n/// This class allows users to define their own file input sources\n/// from which SFML can load resources.\n///\n/// SFML resource classes like sf::Texture and\n/// sf::SoundBuffer provide loadFromFile and loadFromMemory functions,\n/// which read data from conventional sources. However, if you\n/// have data coming from a different source (over a network,\n/// embedded, encrypted, compressed, etc) you can derive your\n/// own class from sf::InputStream and load SFML resources with\n/// their loadFromStream function.\n///\n/// Usage example:\n/// \\code\n/// // custom stream class that reads from inside a zip file\n/// class ZipStream : public sf::InputStream\n/// {\n/// public:\n///\n///     ZipStream(std::string archive);\n///\n///     bool open(std::string filename);\n///\n///     Int64 read(void* data, Int64 size);\n///\n///     Int64 seek(Int64 position);\n///\n///     Int64 tell();\n///\n///     Int64 getSize();\n///\n/// private:\n///\n///     ...\n/// };\n///\n/// // now you can load textures...\n/// sf::Texture texture;\n/// ZipStream stream(\"resources.zip\");\n/// stream.open(\"images/img.png\");\n/// texture.loadFromStream(stream);\n///\n/// // musics...\n/// sf::Music music;\n/// ZipStream stream(\"resources.zip\");\n/// stream.open(\"musics/msc.ogg\");\n/// music.openFromStream(stream);\n///\n/// // etc.\n/// \\endcode\n///\n////////////////////////////////////////////////////////////\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/System/Lock.hpp",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n#ifndef SFML_LOCK_HPP\n#define SFML_LOCK_HPP\n\n////////////////////////////////////////////////////////////\n// Headers\n////////////////////////////////////////////////////////////\n#include <SFML/System/Export.hpp>\n#include <SFML/System/NonCopyable.hpp>\n\n\nnamespace sf\n{\nclass Mutex;\n\n////////////////////////////////////////////////////////////\n/// \\brief Automatic wrapper for locking and unlocking mutexes\n///\n////////////////////////////////////////////////////////////\nclass SFML_SYSTEM_API Lock : NonCopyable\n{\npublic:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Construct the lock with a target mutex\n    ///\n    /// The mutex passed to sf::Lock is automatically locked.\n    ///\n    /// \\param mutex Mutex to lock\n    ///\n    ////////////////////////////////////////////////////////////\n    explicit Lock(Mutex& mutex);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Destructor\n    ///\n    /// The destructor of sf::Lock automatically unlocks its mutex.\n    ///\n    ////////////////////////////////////////////////////////////\n    ~Lock();\n\nprivate:\n\n    ////////////////////////////////////////////////////////////\n    // Member data\n    ////////////////////////////////////////////////////////////\n    Mutex& m_mutex; ///< Mutex to lock / unlock\n};\n\n} // namespace sf\n\n\n#endif // SFML_LOCK_HPP\n\n\n////////////////////////////////////////////////////////////\n/// \\class sf::Lock\n/// \\ingroup system\n///\n/// sf::Lock is a RAII wrapper for sf::Mutex. By unlocking\n/// it in its destructor, it ensures that the mutex will\n/// always be released when the current scope (most likely\n/// a function) ends.\n/// This is even more important when an exception or an early\n/// return statement can interrupt the execution flow of the\n/// function.\n///\n/// For maximum robustness, sf::Lock should always be used\n/// to lock/unlock a mutex.\n///\n/// Usage example:\n/// \\code\n/// sf::Mutex mutex;\n///\n/// void function()\n/// {\n///     sf::Lock lock(mutex); // mutex is now locked\n///\n///     functionThatMayThrowAnException(); // mutex is unlocked if this function throws\n///\n///     if (someCondition)\n///         return; // mutex is unlocked\n///\n/// } // mutex is unlocked\n/// \\endcode\n///\n/// Because the mutex is not explicitly unlocked in the code,\n/// it may remain locked longer than needed. If the region\n/// of the code that needs to be protected by the mutex is\n/// not the entire function, a good practice is to create a\n/// smaller, inner scope so that the lock is limited to this\n/// part of the code.\n///\n/// \\code\n/// sf::Mutex mutex;\n///\n/// void function()\n/// {\n///     {\n///       sf::Lock lock(mutex);\n///       codeThatRequiresProtection();\n///\n///     } // mutex is unlocked here\n///\n///     codeThatDoesntCareAboutTheMutex();\n/// }\n/// \\endcode\n///\n/// Having a mutex locked longer than required is a bad practice\n/// which can lead to bad performances. Don't forget that when\n/// a mutex is locked, other threads may be waiting doing nothing\n/// until it is released.\n///\n/// \\see sf::Mutex\n///\n////////////////////////////////////////////////////////////\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/System/MemoryInputStream.hpp",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n#ifndef SFML_MEMORYINPUTSTREAM_HPP\n#define SFML_MEMORYINPUTSTREAM_HPP\n\n////////////////////////////////////////////////////////////\n// Headers\n////////////////////////////////////////////////////////////\n#include <SFML/Config.hpp>\n#include <SFML/System/InputStream.hpp>\n#include <SFML/System/Export.hpp>\n#include <cstdlib>\n\n\nnamespace sf\n{\n////////////////////////////////////////////////////////////\n/// \\brief Implementation of input stream based on a memory chunk\n///\n////////////////////////////////////////////////////////////\nclass SFML_SYSTEM_API MemoryInputStream : public InputStream\n{\npublic:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Default constructor\n    ///\n    ////////////////////////////////////////////////////////////\n    MemoryInputStream();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Open the stream from its data\n    ///\n    /// \\param data        Pointer to the data in memory\n    /// \\param sizeInBytes Size of the data, in bytes\n    ///\n    ////////////////////////////////////////////////////////////\n    void open(const void* data, std::size_t sizeInBytes);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Read data from the stream\n    ///\n    /// After reading, the stream's reading position must be\n    /// advanced by the amount of bytes read.\n    ///\n    /// \\param data Buffer where to copy the read data\n    /// \\param size Desired number of bytes to read\n    ///\n    /// \\return The number of bytes actually read, or -1 on error\n    ///\n    ////////////////////////////////////////////////////////////\n    virtual Int64 read(void* data, Int64 size);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Change the current reading position\n    ///\n    /// \\param position The position to seek to, from the beginning\n    ///\n    /// \\return The position actually sought to, or -1 on error\n    ///\n    ////////////////////////////////////////////////////////////\n    virtual Int64 seek(Int64 position);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the current reading position in the stream\n    ///\n    /// \\return The current position, or -1 on error.\n    ///\n    ////////////////////////////////////////////////////////////\n    virtual Int64 tell();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Return the size of the stream\n    ///\n    /// \\return The total number of bytes available in the stream, or -1 on error\n    ///\n    ////////////////////////////////////////////////////////////\n    virtual Int64 getSize();\n\nprivate:\n\n    ////////////////////////////////////////////////////////////\n    // Member data\n    ////////////////////////////////////////////////////////////\n    const char* m_data;   ///< Pointer to the data in memory\n    Int64       m_size;   ///< Total size of the data\n    Int64       m_offset; ///< Current reading position\n};\n\n} // namespace sf\n\n\n#endif // SFML_MEMORYINPUTSTREAM_HPP\n\n\n////////////////////////////////////////////////////////////\n/// \\class sf::MemoryInputStream\n/// \\ingroup system\n///\n/// This class is a specialization of InputStream that\n/// reads from data in memory.\n///\n/// It wraps a memory chunk in the common InputStream interface\n/// and therefore allows to use generic classes or functions\n/// that accept such a stream, with content already loaded in memory.\n///\n/// In addition to the virtual functions inherited from\n/// InputStream, MemoryInputStream adds a function to\n/// specify the pointer and size of the data in memory.\n///\n/// SFML resource classes can usually be loaded directly from\n/// memory, so this class shouldn't be useful to you unless\n/// you create your own algorithms that operate on an InputStream.\n///\n/// Usage example:\n/// \\code\n/// void process(InputStream& stream);\n///\n/// MemoryInputStream stream;\n/// stream.open(thePtr, theSize);\n/// process(stream);\n/// \\endcode\n///\n/// InputStream, FileInputStream\n///\n////////////////////////////////////////////////////////////\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/System/Mutex.hpp",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n#ifndef SFML_MUTEX_HPP\n#define SFML_MUTEX_HPP\n\n////////////////////////////////////////////////////////////\n// Headers\n////////////////////////////////////////////////////////////\n#include <SFML/System/Export.hpp>\n#include <SFML/System/NonCopyable.hpp>\n\n\nnamespace sf\n{\nnamespace priv\n{\n    class MutexImpl;\n}\n\n////////////////////////////////////////////////////////////\n/// \\brief Blocks concurrent access to shared resources\n///        from multiple threads\n///\n////////////////////////////////////////////////////////////\nclass SFML_SYSTEM_API Mutex : NonCopyable\n{\npublic:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Default constructor\n    ///\n    ////////////////////////////////////////////////////////////\n    Mutex();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Destructor\n    ///\n    ////////////////////////////////////////////////////////////\n    ~Mutex();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Lock the mutex\n    ///\n    /// If the mutex is already locked in another thread,\n    /// this call will block the execution until the mutex\n    /// is released.\n    ///\n    /// \\see unlock\n    ///\n    ////////////////////////////////////////////////////////////\n    void lock();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Unlock the mutex\n    ///\n    /// \\see lock\n    ///\n    ////////////////////////////////////////////////////////////\n    void unlock();\n\nprivate:\n\n    ////////////////////////////////////////////////////////////\n    // Member data\n    ////////////////////////////////////////////////////////////\n    priv::MutexImpl* m_mutexImpl; ///< OS-specific implementation\n};\n\n} // namespace sf\n\n\n#endif // SFML_MUTEX_HPP\n\n\n////////////////////////////////////////////////////////////\n/// \\class sf::Mutex\n/// \\ingroup system\n///\n/// Mutex stands for \"MUTual EXclusion\". A mutex is a\n/// synchronization object, used when multiple threads are involved.\n///\n/// When you want to protect a part of the code from being accessed\n/// simultaneously by multiple threads, you typically use a\n/// mutex. When a thread is locked by a mutex, any other thread\n/// trying to lock it will be blocked until the mutex is released\n/// by the thread that locked it. This way, you can allow only\n/// one thread at a time to access a critical region of your code.\n///\n/// Usage example:\n/// \\code\n/// Database database; // this is a critical resource that needs some protection\n/// sf::Mutex mutex;\n///\n/// void thread1()\n/// {\n///     mutex.lock(); // this call will block the thread if the mutex is already locked by thread2\n///     database.write(...);\n///     mutex.unlock(); // if thread2 was waiting, it will now be unblocked\n/// }\n///\n/// void thread2()\n/// {\n///     mutex.lock(); // this call will block the thread if the mutex is already locked by thread1\n///     database.write(...);\n///     mutex.unlock(); // if thread1 was waiting, it will now be unblocked\n/// }\n/// \\endcode\n///\n/// Be very careful with mutexes. A bad usage can lead to bad problems,\n/// like deadlocks (two threads are waiting for each other and the\n/// application is globally stuck).\n///\n/// To make the usage of mutexes more robust, particularly in\n/// environments where exceptions can be thrown, you should\n/// use the helper class sf::Lock to lock/unlock mutexes.\n///\n/// SFML mutexes are recursive, which means that you can lock\n/// a mutex multiple times in the same thread without creating\n/// a deadlock. In this case, the first call to lock() behaves\n/// as usual, and the following ones have no effect.\n/// However, you must call unlock() exactly as many times as you\n/// called lock(). If you don't, the mutex won't be released.\n///\n/// \\see sf::Lock\n///\n////////////////////////////////////////////////////////////\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/System/NativeActivity.hpp",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n#ifndef SFML_NATIVEACTIVITY_HPP\n#define SFML_NATIVEACTIVITY_HPP\n\n\n////////////////////////////////////////////////////////////\n// Headers\n////////////////////////////////////////////////////////////\n#include <SFML/System/Export.hpp>\n\n\n#if !defined(SFML_SYSTEM_ANDROID)\n#error NativeActivity.hpp: This header is Android only.\n#endif\n\n\nstruct ANativeActivity;\n\nnamespace sf\n{\n////////////////////////////////////////////////////////////\n/// \\ingroup system\n/// \\brief Return a pointer to the Android native activity\n///\n/// You shouldn't have to use this function, unless you want\n/// to implement very specific details, that SFML doesn't\n/// support, or to use a workaround for a known issue.\n///\n/// \\return Pointer to Android native activity structure\n///\n/// \\sfplatform{Android,SFML/System/NativeActivity.hpp}\n///\n////////////////////////////////////////////////////////////\nSFML_SYSTEM_API ANativeActivity* getNativeActivity();\n\n} // namespace sf\n\n\n#endif // SFML_NATIVEACTIVITY_HPP\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/System/NonCopyable.hpp",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n#ifndef SFML_NONCOPYABLE_HPP\n#define SFML_NONCOPYABLE_HPP\n\n////////////////////////////////////////////////////////////\n// Headers\n////////////////////////////////////////////////////////////\n#include <SFML/System/Export.hpp>\n\n\nnamespace sf\n{\n////////////////////////////////////////////////////////////\n/// \\brief Utility class that makes any derived\n///        class non-copyable\n///\n////////////////////////////////////////////////////////////\nclass SFML_SYSTEM_API NonCopyable\n{\nprotected:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Default constructor\n    ///\n    /// Because this class has a copy constructor, the compiler\n    /// will not automatically generate the default constructor.\n    /// That's why we must define it explicitly.\n    ///\n    ////////////////////////////////////////////////////////////\n    NonCopyable() {}\n\nprivate:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Disabled copy constructor\n    ///\n    /// By making the copy constructor private, the compiler will\n    /// trigger an error if anyone outside tries to use it.\n    /// To prevent NonCopyable or friend classes from using it,\n    /// we also give no definition, so that the linker will\n    /// produce an error if the first protection was inefficient.\n    ///\n    ////////////////////////////////////////////////////////////\n    NonCopyable(const NonCopyable&);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Disabled assignment operator\n    ///\n    /// By making the assignment operator private, the compiler will\n    /// trigger an error if anyone outside tries to use it.\n    /// To prevent NonCopyable or friend classes from using it,\n    /// we also give no definition, so that the linker will\n    /// produce an error if the first protection was inefficient.\n    ///\n    ////////////////////////////////////////////////////////////\n    NonCopyable& operator =(const NonCopyable&);\n};\n\n} // namespace sf\n\n\n#endif // SFML_NONCOPYABLE_HPP\n\n\n////////////////////////////////////////////////////////////\n/// \\class sf::NonCopyable\n/// \\ingroup system\n///\n/// This class makes its instances non-copyable, by explicitly\n/// disabling its copy constructor and its assignment operator.\n///\n/// To create a non-copyable class, simply inherit from\n/// sf::NonCopyable.\n///\n/// The type of inheritance (public or private) doesn't matter,\n/// the copy constructor and assignment operator are declared private\n/// in sf::NonCopyable so they will end up being inaccessible in both\n/// cases. Thus you can use a shorter syntax for inheriting from it\n/// (see below).\n///\n/// Usage example:\n/// \\code\n/// class MyNonCopyableClass : sf::NonCopyable\n/// {\n///     ...\n/// };\n/// \\endcode\n///\n/// Deciding whether the instances of a class can be copied\n/// or not is a very important design choice. You are strongly\n/// encouraged to think about it before writing a class,\n/// and to use sf::NonCopyable when necessary to prevent\n/// many potential future errors when using it. This is also\n/// a very important indication to users of your class.\n///\n////////////////////////////////////////////////////////////\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/System/Sleep.hpp",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n#ifndef SFML_SLEEP_HPP\n#define SFML_SLEEP_HPP\n\n////////////////////////////////////////////////////////////\n// Headers\n////////////////////////////////////////////////////////////\n#include <SFML/System/Export.hpp>\n#include <SFML/System/Time.hpp>\n\n\nnamespace sf\n{\n////////////////////////////////////////////////////////////\n/// \\ingroup system\n/// \\brief Make the current thread sleep for a given duration\n///\n/// sf::sleep is the best way to block a program or one of its\n/// threads, as it doesn't consume any CPU power.\n///\n/// \\param duration Time to sleep\n///\n////////////////////////////////////////////////////////////\nvoid SFML_SYSTEM_API sleep(Time duration);\n\n} // namespace sf\n\n\n#endif // SFML_SLEEP_HPP\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/System/String.hpp",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n#ifndef SFML_STRING_HPP\n#define SFML_STRING_HPP\n\n////////////////////////////////////////////////////////////\n// Headers\n////////////////////////////////////////////////////////////\n#include <SFML/System/Export.hpp>\n#include <SFML/System/Utf.hpp>\n#include <iterator>\n#include <locale>\n#include <string>\n\n\nnamespace sf\n{\n////////////////////////////////////////////////////////////\n/// \\brief Utility string class that automatically handles\n///        conversions between types and encodings\n///\n////////////////////////////////////////////////////////////\nclass SFML_SYSTEM_API String\n{\npublic:\n\n    ////////////////////////////////////////////////////////////\n    // Types\n    ////////////////////////////////////////////////////////////\n    typedef std::basic_string<Uint32>::iterator       Iterator;      ///< Iterator type\n    typedef std::basic_string<Uint32>::const_iterator ConstIterator; ///< Read-only iterator type\n\n    ////////////////////////////////////////////////////////////\n    // Static member data\n    ////////////////////////////////////////////////////////////\n    static const std::size_t InvalidPos; ///< Represents an invalid position in the string\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Default constructor\n    ///\n    /// This constructor creates an empty string.\n    ///\n    ////////////////////////////////////////////////////////////\n    String();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Construct from a single ANSI character and a locale\n    ///\n    /// The source character is converted to UTF-32 according\n    /// to the given locale.\n    ///\n    /// \\param ansiChar ANSI character to convert\n    /// \\param locale   Locale to use for conversion\n    ///\n    ////////////////////////////////////////////////////////////\n    String(char ansiChar, const std::locale& locale = std::locale());\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Construct from single wide character\n    ///\n    /// \\param wideChar Wide character to convert\n    ///\n    ////////////////////////////////////////////////////////////\n    String(wchar_t wideChar);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Construct from single UTF-32 character\n    ///\n    /// \\param utf32Char UTF-32 character to convert\n    ///\n    ////////////////////////////////////////////////////////////\n    String(Uint32 utf32Char);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Construct from a null-terminated C-style ANSI string and a locale\n    ///\n    /// The source string is converted to UTF-32 according\n    /// to the given locale.\n    ///\n    /// \\param ansiString ANSI string to convert\n    /// \\param locale     Locale to use for conversion\n    ///\n    ////////////////////////////////////////////////////////////\n    String(const char* ansiString, const std::locale& locale = std::locale());\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Construct from an ANSI string and a locale\n    ///\n    /// The source string is converted to UTF-32 according\n    /// to the given locale.\n    ///\n    /// \\param ansiString ANSI string to convert\n    /// \\param locale     Locale to use for conversion\n    ///\n    ////////////////////////////////////////////////////////////\n    String(const std::string& ansiString, const std::locale& locale = std::locale());\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Construct from null-terminated C-style wide string\n    ///\n    /// \\param wideString Wide string to convert\n    ///\n    ////////////////////////////////////////////////////////////\n    String(const wchar_t* wideString);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Construct from a wide string\n    ///\n    /// \\param wideString Wide string to convert\n    ///\n    ////////////////////////////////////////////////////////////\n    String(const std::wstring& wideString);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Construct from a null-terminated C-style UTF-32 string\n    ///\n    /// \\param utf32String UTF-32 string to assign\n    ///\n    ////////////////////////////////////////////////////////////\n    String(const Uint32* utf32String);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Construct from an UTF-32 string\n    ///\n    /// \\param utf32String UTF-32 string to assign\n    ///\n    ////////////////////////////////////////////////////////////\n    String(const std::basic_string<Uint32>& utf32String);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Copy constructor\n    ///\n    /// \\param copy Instance to copy\n    ///\n    ////////////////////////////////////////////////////////////\n    String(const String& copy);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Create a new sf::String from a UTF-8 encoded string\n    ///\n    /// \\param begin Forward iterator to the beginning of the UTF-8 sequence\n    /// \\param end   Forward iterator to the end of the UTF-8 sequence\n    ///\n    /// \\return A sf::String containing the source string\n    ///\n    /// \\see fromUtf16, fromUtf32\n    ///\n    ////////////////////////////////////////////////////////////\n    template <typename T>\n    static String fromUtf8(T begin, T end);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Create a new sf::String from a UTF-16 encoded string\n    ///\n    /// \\param begin Forward iterator to the beginning of the UTF-16 sequence\n    /// \\param end   Forward iterator to the end of the UTF-16 sequence\n    ///\n    /// \\return A sf::String containing the source string\n    ///\n    /// \\see fromUtf8, fromUtf32\n    ///\n    ////////////////////////////////////////////////////////////\n    template <typename T>\n    static String fromUtf16(T begin, T end);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Create a new sf::String from a UTF-32 encoded string\n    ///\n    /// This function is provided for consistency, it is equivalent to\n    /// using the constructors that takes a const sf::Uint32* or\n    /// a std::basic_string<sf::Uint32>.\n    ///\n    /// \\param begin Forward iterator to the beginning of the UTF-32 sequence\n    /// \\param end   Forward iterator to the end of the UTF-32 sequence\n    ///\n    /// \\return A sf::String containing the source string\n    ///\n    /// \\see fromUtf8, fromUtf16\n    ///\n    ////////////////////////////////////////////////////////////\n    template <typename T>\n    static String fromUtf32(T begin, T end);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Implicit conversion operator to std::string (ANSI string)\n    ///\n    /// The current global locale is used for conversion. If you\n    /// want to explicitly specify a locale, see toAnsiString.\n    /// Characters that do not fit in the target encoding are\n    /// discarded from the returned string.\n    /// This operator is defined for convenience, and is equivalent\n    /// to calling toAnsiString().\n    ///\n    /// \\return Converted ANSI string\n    ///\n    /// \\see toAnsiString, operator std::wstring\n    ///\n    ////////////////////////////////////////////////////////////\n    operator std::string() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Implicit conversion operator to std::wstring (wide string)\n    ///\n    /// Characters that do not fit in the target encoding are\n    /// discarded from the returned string.\n    /// This operator is defined for convenience, and is equivalent\n    /// to calling toWideString().\n    ///\n    /// \\return Converted wide string\n    ///\n    /// \\see toWideString, operator std::string\n    ///\n    ////////////////////////////////////////////////////////////\n    operator std::wstring() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Convert the Unicode string to an ANSI string\n    ///\n    /// The UTF-32 string is converted to an ANSI string in\n    /// the encoding defined by \\a locale.\n    /// Characters that do not fit in the target encoding are\n    /// discarded from the returned string.\n    ///\n    /// \\param locale Locale to use for conversion\n    ///\n    /// \\return Converted ANSI string\n    ///\n    /// \\see toWideString, operator std::string\n    ///\n    ////////////////////////////////////////////////////////////\n    std::string toAnsiString(const std::locale& locale = std::locale()) const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Convert the Unicode string to a wide string\n    ///\n    /// Characters that do not fit in the target encoding are\n    /// discarded from the returned string.\n    ///\n    /// \\return Converted wide string\n    ///\n    /// \\see toAnsiString, operator std::wstring\n    ///\n    ////////////////////////////////////////////////////////////\n    std::wstring toWideString() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Convert the Unicode string to a UTF-8 string\n    ///\n    /// \\return Converted UTF-8 string\n    ///\n    /// \\see toUtf16, toUtf32\n    ///\n    ////////////////////////////////////////////////////////////\n    std::basic_string<Uint8> toUtf8() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Convert the Unicode string to a UTF-16 string\n    ///\n    /// \\return Converted UTF-16 string\n    ///\n    /// \\see toUtf8, toUtf32\n    ///\n    ////////////////////////////////////////////////////////////\n    std::basic_string<Uint16> toUtf16() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Convert the Unicode string to a UTF-32 string\n    ///\n    /// This function doesn't perform any conversion, since the\n    /// string is already stored as UTF-32 internally.\n    ///\n    /// \\return Converted UTF-32 string\n    ///\n    /// \\see toUtf8, toUtf16\n    ///\n    ////////////////////////////////////////////////////////////\n    std::basic_string<Uint32> toUtf32() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Overload of assignment operator\n    ///\n    /// \\param right Instance to assign\n    ///\n    /// \\return Reference to self\n    ///\n    ////////////////////////////////////////////////////////////\n    String& operator =(const String& right);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Overload of += operator to append an UTF-32 string\n    ///\n    /// \\param right String to append\n    ///\n    /// \\return Reference to self\n    ///\n    ////////////////////////////////////////////////////////////\n    String& operator +=(const String& right);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Overload of [] operator to access a character by its position\n    ///\n    /// This function provides read-only access to characters.\n    /// Note: the behavior is undefined if \\a index is out of range.\n    ///\n    /// \\param index Index of the character to get\n    ///\n    /// \\return Character at position \\a index\n    ///\n    ////////////////////////////////////////////////////////////\n    Uint32 operator [](std::size_t index) const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Overload of [] operator to access a character by its position\n    ///\n    /// This function provides read and write access to characters.\n    /// Note: the behavior is undefined if \\a index is out of range.\n    ///\n    /// \\param index Index of the character to get\n    ///\n    /// \\return Reference to the character at position \\a index\n    ///\n    ////////////////////////////////////////////////////////////\n    Uint32& operator [](std::size_t index);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Clear the string\n    ///\n    /// This function removes all the characters from the string.\n    ///\n    /// \\see isEmpty, erase\n    ///\n    ////////////////////////////////////////////////////////////\n    void clear();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the size of the string\n    ///\n    /// \\return Number of characters in the string\n    ///\n    /// \\see isEmpty\n    ///\n    ////////////////////////////////////////////////////////////\n    std::size_t getSize() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Check whether the string is empty or not\n    ///\n    /// \\return True if the string is empty (i.e. contains no character)\n    ///\n    /// \\see clear, getSize\n    ///\n    ////////////////////////////////////////////////////////////\n    bool isEmpty() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Erase one or more characters from the string\n    ///\n    /// This function removes a sequence of \\a count characters\n    /// starting from \\a position.\n    ///\n    /// \\param position Position of the first character to erase\n    /// \\param count    Number of characters to erase\n    ///\n    ////////////////////////////////////////////////////////////\n    void erase(std::size_t position, std::size_t count = 1);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Insert one or more characters into the string\n    ///\n    /// This function inserts the characters of \\a str\n    /// into the string, starting from \\a position.\n    ///\n    /// \\param position Position of insertion\n    /// \\param str      Characters to insert\n    ///\n    ////////////////////////////////////////////////////////////\n    void insert(std::size_t position, const String& str);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Find a sequence of one or more characters in the string\n    ///\n    /// This function searches for the characters of \\a str\n    /// in the string, starting from \\a start.\n    ///\n    /// \\param str   Characters to find\n    /// \\param start Where to begin searching\n    ///\n    /// \\return Position of \\a str in the string, or String::InvalidPos if not found\n    ///\n    ////////////////////////////////////////////////////////////\n    std::size_t find(const String& str, std::size_t start = 0) const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Replace a substring with another string\n    ///\n    /// This function replaces the substring that starts at index \\a position\n    /// and spans \\a length characters with the string \\a replaceWith.\n    ///\n    /// \\param position    Index of the first character to be replaced\n    /// \\param length      Number of characters to replace. You can pass InvalidPos to\n    ///                    replace all characters until the end of the string.\n    /// \\param replaceWith String that replaces the given substring.\n    ///\n    ////////////////////////////////////////////////////////////\n    void replace(std::size_t position, std::size_t length, const String& replaceWith);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Replace all occurrences of a substring with a replacement string\n    ///\n    /// This function replaces all occurrences of \\a searchFor in this string\n    /// with the string \\a replaceWith.\n    ///\n    /// \\param searchFor   The value being searched for\n    /// \\param replaceWith The value that replaces found \\a searchFor values\n    ///\n    ////////////////////////////////////////////////////////////\n    void replace(const String& searchFor, const String& replaceWith);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Return a part of the string\n    ///\n    /// This function returns the substring that starts at index \\a position\n    /// and spans \\a length characters.\n    ///\n    /// \\param position Index of the first character\n    /// \\param length   Number of characters to include in the substring (if\n    ///                 the string is shorter, as many characters as possible\n    ///                 are included). \\ref InvalidPos can be used to include all\n    ///                 characters until the end of the string.\n    ///\n    /// \\return String object containing a substring of this object\n    ///\n    ////////////////////////////////////////////////////////////\n    String substring(std::size_t position, std::size_t length = InvalidPos) const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get a pointer to the C-style array of characters\n    ///\n    /// This functions provides a read-only access to a\n    /// null-terminated C-style representation of the string.\n    /// The returned pointer is temporary and is meant only for\n    /// immediate use, thus it is not recommended to store it.\n    ///\n    /// \\return Read-only pointer to the array of characters\n    ///\n    ////////////////////////////////////////////////////////////\n    const Uint32* getData() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Return an iterator to the beginning of the string\n    ///\n    /// \\return Read-write iterator to the beginning of the string characters\n    ///\n    /// \\see end\n    ///\n    ////////////////////////////////////////////////////////////\n    Iterator begin();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Return an iterator to the beginning of the string\n    ///\n    /// \\return Read-only iterator to the beginning of the string characters\n    ///\n    /// \\see end\n    ///\n    ////////////////////////////////////////////////////////////\n    ConstIterator begin() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Return an iterator to the end of the string\n    ///\n    /// The end iterator refers to 1 position past the last character;\n    /// thus it represents an invalid character and should never be\n    /// accessed.\n    ///\n    /// \\return Read-write iterator to the end of the string characters\n    ///\n    /// \\see begin\n    ///\n    ////////////////////////////////////////////////////////////\n    Iterator end();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Return an iterator to the end of the string\n    ///\n    /// The end iterator refers to 1 position past the last character;\n    /// thus it represents an invalid character and should never be\n    /// accessed.\n    ///\n    /// \\return Read-only iterator to the end of the string characters\n    ///\n    /// \\see begin\n    ///\n    ////////////////////////////////////////////////////////////\n    ConstIterator end() const;\n\nprivate:\n\n    friend SFML_SYSTEM_API bool operator ==(const String& left, const String& right);\n    friend SFML_SYSTEM_API bool operator <(const String& left, const String& right);\n\n    ////////////////////////////////////////////////////////////\n    // Member data\n    ////////////////////////////////////////////////////////////\n    std::basic_string<Uint32> m_string; ///< Internal string of UTF-32 characters\n};\n\n////////////////////////////////////////////////////////////\n/// \\relates String\n/// \\brief Overload of == operator to compare two UTF-32 strings\n///\n/// \\param left  Left operand (a string)\n/// \\param right Right operand (a string)\n///\n/// \\return True if both strings are equal\n///\n////////////////////////////////////////////////////////////\nSFML_SYSTEM_API bool operator ==(const String& left, const String& right);\n\n////////////////////////////////////////////////////////////\n/// \\relates String\n/// \\brief Overload of != operator to compare two UTF-32 strings\n///\n/// \\param left  Left operand (a string)\n/// \\param right Right operand (a string)\n///\n/// \\return True if both strings are different\n///\n////////////////////////////////////////////////////////////\nSFML_SYSTEM_API bool operator !=(const String& left, const String& right);\n\n////////////////////////////////////////////////////////////\n/// \\relates String\n/// \\brief Overload of < operator to compare two UTF-32 strings\n///\n/// \\param left  Left operand (a string)\n/// \\param right Right operand (a string)\n///\n/// \\return True if \\a left is lexicographically before \\a right\n///\n////////////////////////////////////////////////////////////\nSFML_SYSTEM_API bool operator <(const String& left, const String& right);\n\n////////////////////////////////////////////////////////////\n/// \\relates String\n/// \\brief Overload of > operator to compare two UTF-32 strings\n///\n/// \\param left  Left operand (a string)\n/// \\param right Right operand (a string)\n///\n/// \\return True if \\a left is lexicographically after \\a right\n///\n////////////////////////////////////////////////////////////\nSFML_SYSTEM_API bool operator >(const String& left, const String& right);\n\n////////////////////////////////////////////////////////////\n/// \\relates String\n/// \\brief Overload of <= operator to compare two UTF-32 strings\n///\n/// \\param left  Left operand (a string)\n/// \\param right Right operand (a string)\n///\n/// \\return True if \\a left is lexicographically before or equivalent to \\a right\n///\n////////////////////////////////////////////////////////////\nSFML_SYSTEM_API bool operator <=(const String& left, const String& right);\n\n////////////////////////////////////////////////////////////\n/// \\relates String\n/// \\brief Overload of >= operator to compare two UTF-32 strings\n///\n/// \\param left  Left operand (a string)\n/// \\param right Right operand (a string)\n///\n/// \\return True if \\a left is lexicographically after or equivalent to \\a right\n///\n////////////////////////////////////////////////////////////\nSFML_SYSTEM_API bool operator >=(const String& left, const String& right);\n\n////////////////////////////////////////////////////////////\n/// \\relates String\n/// \\brief Overload of binary + operator to concatenate two strings\n///\n/// \\param left  Left operand (a string)\n/// \\param right Right operand (a string)\n///\n/// \\return Concatenated string\n///\n////////////////////////////////////////////////////////////\nSFML_SYSTEM_API String operator +(const String& left, const String& right);\n\n#include <SFML/System/String.inl>\n\n} // namespace sf\n\n\n#endif // SFML_STRING_HPP\n\n\n////////////////////////////////////////////////////////////\n/// \\class sf::String\n/// \\ingroup system\n///\n/// sf::String is a utility string class defined mainly for\n/// convenience. It is a Unicode string (implemented using\n/// UTF-32), thus it can store any character in the world\n/// (European, Chinese, Arabic, Hebrew, etc.).\n///\n/// It automatically handles conversions from/to ANSI and\n/// wide strings, so that you can work with standard string\n/// classes and still be compatible with functions taking a\n/// sf::String.\n///\n/// \\code\n/// sf::String s;\n///\n/// std::string s1 = s;  // automatically converted to ANSI string\n/// std::wstring s2 = s; // automatically converted to wide string\n/// s = \"hello\";         // automatically converted from ANSI string\n/// s = L\"hello\";        // automatically converted from wide string\n/// s += 'a';            // automatically converted from ANSI string\n/// s += L'a';           // automatically converted from wide string\n/// \\endcode\n///\n/// Conversions involving ANSI strings use the default user locale. However\n/// it is possible to use a custom locale if necessary:\n/// \\code\n/// std::locale locale;\n/// sf::String s;\n/// ...\n/// std::string s1 = s.toAnsiString(locale);\n/// s = sf::String(\"hello\", locale);\n/// \\endcode\n///\n/// sf::String defines the most important functions of the\n/// standard std::string class: removing, random access, iterating,\n/// appending, comparing, etc. However it is a simple class\n/// provided for convenience, and you may have to consider using\n/// a more optimized class if your program requires complex string\n/// handling. The automatic conversion functions will then take\n/// care of converting your string to sf::String whenever SFML\n/// requires it.\n///\n/// Please note that SFML also defines a low-level, generic\n/// interface for Unicode handling, see the sf::Utf classes.\n///\n////////////////////////////////////////////////////////////\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/System/String.inl",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n\n////////////////////////////////////////////////////////////\ntemplate <typename T>\nString String::fromUtf8(T begin, T end)\n{\n    String string;\n    Utf8::toUtf32(begin, end, std::back_inserter(string.m_string));\n    return string;\n}\n\n\n////////////////////////////////////////////////////////////\ntemplate <typename T>\nString String::fromUtf16(T begin, T end)\n{\n    String string;\n    Utf16::toUtf32(begin, end, std::back_inserter(string.m_string));\n    return string;\n}\n\n\n////////////////////////////////////////////////////////////\ntemplate <typename T>\nString String::fromUtf32(T begin, T end)\n{\n    String string;\n    string.m_string.assign(begin, end);\n    return string;\n}\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/System/Thread.hpp",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n#ifndef SFML_THREAD_HPP\n#define SFML_THREAD_HPP\n\n////////////////////////////////////////////////////////////\n// Headers\n////////////////////////////////////////////////////////////\n#include <SFML/System/Export.hpp>\n#include <SFML/System/NonCopyable.hpp>\n#include <cstdlib>\n\n\nnamespace sf\n{\nnamespace priv\n{\n    class ThreadImpl;\n    struct ThreadFunc;\n}\n\n////////////////////////////////////////////////////////////\n/// \\brief Utility class to manipulate threads\n///\n////////////////////////////////////////////////////////////\nclass SFML_SYSTEM_API Thread : NonCopyable\n{\npublic:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Construct the thread from a functor with no argument\n    ///\n    /// This constructor works for function objects, as well\n    /// as free functions.\n    ///\n    /// Use this constructor for this kind of function:\n    /// \\code\n    /// void function();\n    ///\n    /// // --- or ----\n    ///\n    /// struct Functor\n    /// {\n    ///     void operator()();\n    /// };\n    /// \\endcode\n    /// Note: this does *not* run the thread, use launch().\n    ///\n    /// \\param function Functor or free function to use as the entry point of the thread\n    ///\n    ////////////////////////////////////////////////////////////\n    template <typename F>\n    Thread(F function);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Construct the thread from a functor with an argument\n    ///\n    /// This constructor works for function objects, as well\n    /// as free functions.\n    /// It is a template, which means that the argument can\n    /// have any type (int, std::string, void*, Toto, ...).\n    ///\n    /// Use this constructor for this kind of function:\n    /// \\code\n    /// void function(int arg);\n    ///\n    /// // --- or ----\n    ///\n    /// struct Functor\n    /// {\n    ///     void operator()(std::string arg);\n    /// };\n    /// \\endcode\n    /// Note: this does *not* run the thread, use launch().\n    ///\n    /// \\param function Functor or free function to use as the entry point of the thread\n    /// \\param argument argument to forward to the function\n    ///\n    ////////////////////////////////////////////////////////////\n    template <typename F, typename A>\n    Thread(F function, A argument);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Construct the thread from a member function and an object\n    ///\n    /// This constructor is a template, which means that you can\n    /// use it with any class.\n    /// Use this constructor for this kind of function:\n    /// \\code\n    /// class MyClass\n    /// {\n    /// public:\n    ///\n    ///     void function();\n    /// };\n    /// \\endcode\n    /// Note: this does *not* run the thread, use launch().\n    ///\n    /// \\param function Entry point of the thread\n    /// \\param object Pointer to the object to use\n    ///\n    ////////////////////////////////////////////////////////////\n    template <typename C>\n    Thread(void(C::*function)(), C* object);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Destructor\n    ///\n    /// This destructor calls wait(), so that the internal thread\n    /// cannot survive after its sf::Thread instance is destroyed.\n    ///\n    ////////////////////////////////////////////////////////////\n    ~Thread();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Run the thread\n    ///\n    /// This function starts the entry point passed to the\n    /// thread's constructor, and returns immediately.\n    /// After this function returns, the thread's function is\n    /// running in parallel to the calling code.\n    ///\n    ////////////////////////////////////////////////////////////\n    void launch();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Wait until the thread finishes\n    ///\n    /// This function will block the execution until the\n    /// thread's function ends.\n    /// Warning: if the thread function never ends, the calling\n    /// thread will block forever.\n    /// If this function is called from its owner thread, it\n    /// returns without doing anything.\n    ///\n    ////////////////////////////////////////////////////////////\n    void wait();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Terminate the thread\n    ///\n    /// This function immediately stops the thread, without waiting\n    /// for its function to finish.\n    /// Terminating a thread with this function is not safe,\n    /// and can lead to local variables not being destroyed\n    /// on some operating systems. You should rather try to make\n    /// the thread function terminate by itself.\n    ///\n    ////////////////////////////////////////////////////////////\n    void terminate();\n\nprivate:\n\n    friend class priv::ThreadImpl;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Internal entry point of the thread\n    ///\n    /// This function is called by the thread implementation.\n    ///\n    ////////////////////////////////////////////////////////////\n    void run();\n\n    ////////////////////////////////////////////////////////////\n    // Member data\n    ////////////////////////////////////////////////////////////\n    priv::ThreadImpl* m_impl;       ///< OS-specific implementation of the thread\n    priv::ThreadFunc* m_entryPoint; ///< Abstraction of the function to run\n};\n\n#include <SFML/System/Thread.inl>\n\n} // namespace sf\n\n#endif // SFML_THREAD_HPP\n\n\n////////////////////////////////////////////////////////////\n/// \\class sf::Thread\n/// \\ingroup system\n///\n/// Threads provide a way to run multiple parts of the code\n/// in parallel. When you launch a new thread, the execution\n/// is split and both the new thread and the caller run\n/// in parallel.\n///\n/// To use a sf::Thread, you construct it directly with the\n/// function to execute as the entry point of the thread.\n/// sf::Thread has multiple template constructors, which means\n/// that you can use several types of entry points:\n/// \\li non-member functions with no argument\n/// \\li non-member functions with one argument of any type\n/// \\li functors with no argument (this one is particularly useful for compatibility with boost/std::%bind)\n/// \\li functors with one argument of any type\n/// \\li member functions from any class with no argument\n///\n/// The function argument, if any, is copied in the sf::Thread\n/// instance, as well as the functor (if the corresponding\n/// constructor is used). Class instances, however, are passed\n/// by pointer so you must make sure that the object won't be\n/// destroyed while the thread is still using it.\n///\n/// The thread ends when its function is terminated. If the\n/// owner sf::Thread instance is destroyed before the\n/// thread is finished, the destructor will wait (see wait())\n///\n/// Usage examples:\n/// \\code\n/// // example 1: non member function with one argument\n///\n/// void threadFunc(int argument)\n/// {\n///     ...\n/// }\n///\n/// sf::Thread thread(&threadFunc, 5);\n/// thread.launch(); // start the thread (internally calls threadFunc(5))\n/// \\endcode\n///\n/// \\code\n/// // example 2: member function\n///\n/// class Task\n/// {\n/// public:\n///     void run()\n///     {\n///         ...\n///     }\n/// };\n///\n/// Task task;\n/// sf::Thread thread(&Task::run, &task);\n/// thread.launch(); // start the thread (internally calls task.run())\n/// \\endcode\n///\n/// \\code\n/// // example 3: functor\n///\n/// struct Task\n/// {\n///     void operator()()\n///     {\n///         ...\n///     }\n/// };\n///\n/// sf::Thread thread(Task());\n/// thread.launch(); // start the thread (internally calls operator() on the Task instance)\n/// \\endcode\n///\n/// Creating parallel threads of execution can be dangerous:\n/// all threads inside the same process share the same memory space,\n/// which means that you may end up accessing the same variable\n/// from multiple threads at the same time. To prevent this\n/// kind of situations, you can use mutexes (see sf::Mutex).\n///\n/// \\see sf::Mutex\n///\n////////////////////////////////////////////////////////////\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/System/Thread.inl",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\nnamespace priv\n{\n// Base class for abstract thread functions\nstruct ThreadFunc\n{\n    virtual ~ThreadFunc() {}\n    virtual void run() = 0;\n};\n\n// Specialization using a functor (including free functions) with no argument\ntemplate <typename T>\nstruct ThreadFunctor : ThreadFunc\n{\n    ThreadFunctor(T functor) : m_functor(functor) {}\n    virtual void run() {m_functor();}\n    T m_functor;\n};\n\n// Specialization using a functor (including free functions) with one argument\ntemplate <typename F, typename A>\nstruct ThreadFunctorWithArg : ThreadFunc\n{\n    ThreadFunctorWithArg(F function, A arg) : m_function(function), m_arg(arg) {}\n    virtual void run() {m_function(m_arg);}\n    F m_function;\n    A m_arg;\n};\n\n// Specialization using a member function\ntemplate <typename C>\nstruct ThreadMemberFunc : ThreadFunc\n{\n    ThreadMemberFunc(void(C::*function)(), C* object) : m_function(function), m_object(object) {}\n    virtual void run() {(m_object->*m_function)();}\n    void(C::*m_function)();\n    C* m_object;\n};\n\n} // namespace priv\n\n\n////////////////////////////////////////////////////////////\ntemplate <typename F>\nThread::Thread(F functor) :\nm_impl      (NULL),\nm_entryPoint(new priv::ThreadFunctor<F>(functor))\n{\n}\n\n\n////////////////////////////////////////////////////////////\ntemplate <typename F, typename A>\nThread::Thread(F function, A argument) :\nm_impl      (NULL),\nm_entryPoint(new priv::ThreadFunctorWithArg<F, A>(function, argument))\n{\n}\n\n\n////////////////////////////////////////////////////////////\ntemplate <typename C>\nThread::Thread(void(C::*function)(), C* object) :\nm_impl      (NULL),\nm_entryPoint(new priv::ThreadMemberFunc<C>(function, object))\n{\n}\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/System/ThreadLocal.hpp",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n#ifndef SFML_THREADLOCAL_HPP\n#define SFML_THREADLOCAL_HPP\n\n////////////////////////////////////////////////////////////\n// Headers\n////////////////////////////////////////////////////////////\n#include <SFML/System/Export.hpp>\n#include <SFML/System/NonCopyable.hpp>\n#include <cstdlib>\n\n\nnamespace sf\n{\nnamespace priv\n{\n    class ThreadLocalImpl;\n}\n\n////////////////////////////////////////////////////////////\n/// \\brief Defines variables with thread-local storage\n///\n////////////////////////////////////////////////////////////\nclass SFML_SYSTEM_API ThreadLocal : NonCopyable\n{\npublic:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Default constructor\n    ///\n    /// \\param value Optional value to initialize the variable\n    ///\n    ////////////////////////////////////////////////////////////\n    ThreadLocal(void* value = NULL);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Destructor\n    ///\n    ////////////////////////////////////////////////////////////\n    ~ThreadLocal();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Set the thread-specific value of the variable\n    ///\n    /// \\param value Value of the variable for the current thread\n    ///\n    ////////////////////////////////////////////////////////////\n    void setValue(void* value);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Retrieve the thread-specific value of the variable\n    ///\n    /// \\return Value of the variable for the current thread\n    ///\n    ////////////////////////////////////////////////////////////\n    void* getValue() const;\n\nprivate:\n\n    ////////////////////////////////////////////////////////////\n    // Member data\n    ////////////////////////////////////////////////////////////\n    priv::ThreadLocalImpl* m_impl; ///< Pointer to the OS specific implementation\n};\n\n} // namespace sf\n\n\n#endif // SFML_THREADLOCAL_HPP\n\n\n////////////////////////////////////////////////////////////\n/// \\class sf::ThreadLocal\n/// \\ingroup system\n///\n/// This class manipulates void* parameters and thus is not\n/// appropriate for strongly-typed variables. You should rather\n/// use the sf::ThreadLocalPtr template class.\n///\n////////////////////////////////////////////////////////////\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/System/ThreadLocalPtr.hpp",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n#ifndef SFML_THREADLOCALPTR_HPP\n#define SFML_THREADLOCALPTR_HPP\n\n////////////////////////////////////////////////////////////\n// Headers\n////////////////////////////////////////////////////////////\n#include <SFML/System/ThreadLocal.hpp>\n\n\nnamespace sf\n{\n////////////////////////////////////////////////////////////\n/// \\brief Pointer to a thread-local variable\n///\n////////////////////////////////////////////////////////////\ntemplate <typename T>\nclass ThreadLocalPtr : private ThreadLocal\n{\npublic:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Default constructor\n    ///\n    /// \\param value Optional value to initialize the variable\n    ///\n    ////////////////////////////////////////////////////////////\n    ThreadLocalPtr(T* value = NULL);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Overload of unary operator *\n    ///\n    /// Like raw pointers, applying the * operator returns a\n    /// reference to the pointed-to object.\n    ///\n    /// \\return Reference to the thread-local variable\n    ///\n    ////////////////////////////////////////////////////////////\n    T& operator *() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Overload of operator ->\n    ///\n    /// Similarly to raw pointers, applying the -> operator\n    /// returns the pointed-to object.\n    ///\n    /// \\return Pointer to the thread-local variable\n    ///\n    ////////////////////////////////////////////////////////////\n    T* operator ->() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Conversion operator to implicitly convert the\n    ///        pointer to its raw pointer type (T*)\n    ///\n    /// \\return Pointer to the actual object\n    ///\n    ////////////////////////////////////////////////////////////\n    operator T*() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Assignment operator for a raw pointer parameter\n    ///\n    /// \\param value Pointer to assign\n    ///\n    /// \\return Reference to self\n    ///\n    ////////////////////////////////////////////////////////////\n    ThreadLocalPtr<T>& operator =(T* value);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Assignment operator for a ThreadLocalPtr parameter\n    ///\n    /// \\param right ThreadLocalPtr to assign\n    ///\n    /// \\return Reference to self\n    ///\n    ////////////////////////////////////////////////////////////\n    ThreadLocalPtr<T>& operator =(const ThreadLocalPtr<T>& right);\n};\n\n} // namespace sf\n\n#include <SFML/System/ThreadLocalPtr.inl>\n\n\n#endif // SFML_THREADLOCALPTR_HPP\n\n\n////////////////////////////////////////////////////////////\n/// \\class sf::ThreadLocalPtr\n/// \\ingroup system\n///\n/// sf::ThreadLocalPtr is a type-safe wrapper for storing\n/// pointers to thread-local variables. A thread-local\n/// variable holds a different value for each different\n/// thread, unlike normal variables that are shared.\n///\n/// Its usage is completely transparent, so that it is similar\n/// to manipulating the raw pointer directly (like any smart pointer).\n///\n/// Usage example:\n/// \\code\n/// MyClass object1;\n/// MyClass object2;\n/// sf::ThreadLocalPtr<MyClass> objectPtr;\n///\n/// void thread1()\n/// {\n///     objectPtr = &object1; // doesn't impact thread2\n///     ...\n/// }\n///\n/// void thread2()\n/// {\n///     objectPtr = &object2; // doesn't impact thread1\n///     ...\n/// }\n///\n/// int main()\n/// {\n///     // Create and launch the two threads\n///     sf::Thread t1(&thread1);\n///     sf::Thread t2(&thread2);\n///     t1.launch();\n///     t2.launch();\n///\n///     return 0;\n/// }\n/// \\endcode\n///\n/// ThreadLocalPtr is designed for internal use; however you\n/// can use it if you feel like it fits well your implementation.\n///\n////////////////////////////////////////////////////////////\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/System/ThreadLocalPtr.inl",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n\nnamespace sf\n{\n////////////////////////////////////////////////////////////\ntemplate <typename T>\nThreadLocalPtr<T>::ThreadLocalPtr(T* value) :\nThreadLocal(value)\n{\n}\n\n\n////////////////////////////////////////////////////////////\ntemplate <typename T>\nT& ThreadLocalPtr<T>::operator *() const\n{\n    return *static_cast<T*>(getValue());\n}\n\n\n////////////////////////////////////////////////////////////\ntemplate <typename T>\nT* ThreadLocalPtr<T>::operator ->() const\n{\n    return static_cast<T*>(getValue());\n}\n\n\n////////////////////////////////////////////////////////////\ntemplate <typename T>\nThreadLocalPtr<T>::operator T*() const\n{\n    return static_cast<T*>(getValue());\n}\n\n\n////////////////////////////////////////////////////////////\ntemplate <typename T>\nThreadLocalPtr<T>& ThreadLocalPtr<T>::operator =(T* value)\n{\n    setValue(value);\n    return *this;\n}\n\n\n////////////////////////////////////////////////////////////\ntemplate <typename T>\nThreadLocalPtr<T>& ThreadLocalPtr<T>::operator =(const ThreadLocalPtr<T>& right)\n{\n    setValue(right.getValue());\n    return *this;\n}\n\n} // namespace sf\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/System/Time.hpp",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n#ifndef SFML_TIME_HPP\n#define SFML_TIME_HPP\n\n////////////////////////////////////////////////////////////\n// Headers\n////////////////////////////////////////////////////////////\n#include <SFML/System/Export.hpp>\n\n\nnamespace sf\n{\n////////////////////////////////////////////////////////////\n/// \\brief Represents a time value\n///\n////////////////////////////////////////////////////////////\nclass SFML_SYSTEM_API Time\n{\npublic:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Default constructor\n    ///\n    /// Sets the time value to zero.\n    ///\n    ////////////////////////////////////////////////////////////\n    Time();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Return the time value as a number of seconds\n    ///\n    /// \\return Time in seconds\n    ///\n    /// \\see asMilliseconds, asMicroseconds\n    ///\n    ////////////////////////////////////////////////////////////\n    float asSeconds() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Return the time value as a number of milliseconds\n    ///\n    /// \\return Time in milliseconds\n    ///\n    /// \\see asSeconds, asMicroseconds\n    ///\n    ////////////////////////////////////////////////////////////\n    Int32 asMilliseconds() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Return the time value as a number of microseconds\n    ///\n    /// \\return Time in microseconds\n    ///\n    /// \\see asSeconds, asMilliseconds\n    ///\n    ////////////////////////////////////////////////////////////\n    Int64 asMicroseconds() const;\n\n    ////////////////////////////////////////////////////////////\n    // Static member data\n    ////////////////////////////////////////////////////////////\n    static const Time Zero; ///< Predefined \"zero\" time value\n\nprivate:\n\n    friend SFML_SYSTEM_API Time seconds(float);\n    friend SFML_SYSTEM_API Time milliseconds(Int32);\n    friend SFML_SYSTEM_API Time microseconds(Int64);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Construct from a number of microseconds\n    ///\n    /// This function is internal. To construct time values,\n    /// use sf::seconds, sf::milliseconds or sf::microseconds instead.\n    ///\n    /// \\param microseconds Number of microseconds\n    ///\n    ////////////////////////////////////////////////////////////\n    explicit Time(Int64 microseconds);\n\nprivate:\n\n    ////////////////////////////////////////////////////////////\n    // Member data\n    ////////////////////////////////////////////////////////////\n    Int64 m_microseconds; ///< Time value stored as microseconds\n};\n\n////////////////////////////////////////////////////////////\n/// \\relates Time\n/// \\brief Construct a time value from a number of seconds\n///\n/// \\param amount Number of seconds\n///\n/// \\return Time value constructed from the amount of seconds\n///\n/// \\see milliseconds, microseconds\n///\n////////////////////////////////////////////////////////////\nSFML_SYSTEM_API Time seconds(float amount);\n\n////////////////////////////////////////////////////////////\n/// \\relates Time\n/// \\brief Construct a time value from a number of milliseconds\n///\n/// \\param amount Number of milliseconds\n///\n/// \\return Time value constructed from the amount of milliseconds\n///\n/// \\see seconds, microseconds\n///\n////////////////////////////////////////////////////////////\nSFML_SYSTEM_API Time milliseconds(Int32 amount);\n\n////////////////////////////////////////////////////////////\n/// \\relates Time\n/// \\brief Construct a time value from a number of microseconds\n///\n/// \\param amount Number of microseconds\n///\n/// \\return Time value constructed from the amount of microseconds\n///\n/// \\see seconds, milliseconds\n///\n////////////////////////////////////////////////////////////\nSFML_SYSTEM_API Time microseconds(Int64 amount);\n\n////////////////////////////////////////////////////////////\n/// \\relates Time\n/// \\brief Overload of == operator to compare two time values\n///\n/// \\param left  Left operand (a time)\n/// \\param right Right operand (a time)\n///\n/// \\return True if both time values are equal\n///\n////////////////////////////////////////////////////////////\nSFML_SYSTEM_API bool operator ==(Time left, Time right);\n\n////////////////////////////////////////////////////////////\n/// \\relates Time\n/// \\brief Overload of != operator to compare two time values\n///\n/// \\param left  Left operand (a time)\n/// \\param right Right operand (a time)\n///\n/// \\return True if both time values are different\n///\n////////////////////////////////////////////////////////////\nSFML_SYSTEM_API bool operator !=(Time left, Time right);\n\n////////////////////////////////////////////////////////////\n/// \\relates Time\n/// \\brief Overload of < operator to compare two time values\n///\n/// \\param left  Left operand (a time)\n/// \\param right Right operand (a time)\n///\n/// \\return True if \\a left is lesser than \\a right\n///\n////////////////////////////////////////////////////////////\nSFML_SYSTEM_API bool operator <(Time left, Time right);\n\n////////////////////////////////////////////////////////////\n/// \\relates Time\n/// \\brief Overload of > operator to compare two time values\n///\n/// \\param left  Left operand (a time)\n/// \\param right Right operand (a time)\n///\n/// \\return True if \\a left is greater than \\a right\n///\n////////////////////////////////////////////////////////////\nSFML_SYSTEM_API bool operator >(Time left, Time right);\n\n////////////////////////////////////////////////////////////\n/// \\relates Time\n/// \\brief Overload of <= operator to compare two time values\n///\n/// \\param left  Left operand (a time)\n/// \\param right Right operand (a time)\n///\n/// \\return True if \\a left is lesser or equal than \\a right\n///\n////////////////////////////////////////////////////////////\nSFML_SYSTEM_API bool operator <=(Time left, Time right);\n\n////////////////////////////////////////////////////////////\n/// \\relates Time\n/// \\brief Overload of >= operator to compare two time values\n///\n/// \\param left  Left operand (a time)\n/// \\param right Right operand (a time)\n///\n/// \\return True if \\a left is greater or equal than \\a right\n///\n////////////////////////////////////////////////////////////\nSFML_SYSTEM_API bool operator >=(Time left, Time right);\n\n////////////////////////////////////////////////////////////\n/// \\relates Time\n/// \\brief Overload of unary - operator to negate a time value\n///\n/// \\param right Right operand (a time)\n///\n/// \\return Opposite of the time value\n///\n////////////////////////////////////////////////////////////\nSFML_SYSTEM_API Time operator -(Time right);\n\n////////////////////////////////////////////////////////////\n/// \\relates Time\n/// \\brief Overload of binary + operator to add two time values\n///\n/// \\param left  Left operand (a time)\n/// \\param right Right operand (a time)\n///\n/// \\return Sum of the two times values\n///\n////////////////////////////////////////////////////////////\nSFML_SYSTEM_API Time operator +(Time left, Time right);\n\n////////////////////////////////////////////////////////////\n/// \\relates Time\n/// \\brief Overload of binary += operator to add/assign two time values\n///\n/// \\param left  Left operand (a time)\n/// \\param right Right operand (a time)\n///\n/// \\return Sum of the two times values\n///\n////////////////////////////////////////////////////////////\nSFML_SYSTEM_API Time& operator +=(Time& left, Time right);\n\n////////////////////////////////////////////////////////////\n/// \\relates Time\n/// \\brief Overload of binary - operator to subtract two time values\n///\n/// \\param left  Left operand (a time)\n/// \\param right Right operand (a time)\n///\n/// \\return Difference of the two times values\n///\n////////////////////////////////////////////////////////////\nSFML_SYSTEM_API Time operator -(Time left, Time right);\n\n////////////////////////////////////////////////////////////\n/// \\relates Time\n/// \\brief Overload of binary -= operator to subtract/assign two time values\n///\n/// \\param left  Left operand (a time)\n/// \\param right Right operand (a time)\n///\n/// \\return Difference of the two times values\n///\n////////////////////////////////////////////////////////////\nSFML_SYSTEM_API Time& operator -=(Time& left, Time right);\n\n////////////////////////////////////////////////////////////\n/// \\relates Time\n/// \\brief Overload of binary * operator to scale a time value\n///\n/// \\param left  Left operand (a time)\n/// \\param right Right operand (a number)\n///\n/// \\return \\a left multiplied by \\a right\n///\n////////////////////////////////////////////////////////////\nSFML_SYSTEM_API Time operator *(Time left, float right);\n\n////////////////////////////////////////////////////////////\n/// \\relates Time\n/// \\brief Overload of binary * operator to scale a time value\n///\n/// \\param left  Left operand (a time)\n/// \\param right Right operand (a number)\n///\n/// \\return \\a left multiplied by \\a right\n///\n////////////////////////////////////////////////////////////\nSFML_SYSTEM_API Time operator *(Time left, Int64 right);\n\n////////////////////////////////////////////////////////////\n/// \\relates Time\n/// \\brief Overload of binary * operator to scale a time value\n///\n/// \\param left  Left operand (a number)\n/// \\param right Right operand (a time)\n///\n/// \\return \\a left multiplied by \\a right\n///\n////////////////////////////////////////////////////////////\nSFML_SYSTEM_API Time operator *(float left, Time right);\n\n////////////////////////////////////////////////////////////\n/// \\relates Time\n/// \\brief Overload of binary * operator to scale a time value\n///\n/// \\param left  Left operand (a number)\n/// \\param right Right operand (a time)\n///\n/// \\return \\a left multiplied by \\a right\n///\n////////////////////////////////////////////////////////////\nSFML_SYSTEM_API Time operator *(Int64 left, Time right);\n\n////////////////////////////////////////////////////////////\n/// \\relates Time\n/// \\brief Overload of binary *= operator to scale/assign a time value\n///\n/// \\param left  Left operand (a time)\n/// \\param right Right operand (a number)\n///\n/// \\return \\a left multiplied by \\a right\n///\n////////////////////////////////////////////////////////////\nSFML_SYSTEM_API Time& operator *=(Time& left, float right);\n\n////////////////////////////////////////////////////////////\n/// \\relates Time\n/// \\brief Overload of binary *= operator to scale/assign a time value\n///\n/// \\param left  Left operand (a time)\n/// \\param right Right operand (a number)\n///\n/// \\return \\a left multiplied by \\a right\n///\n////////////////////////////////////////////////////////////\nSFML_SYSTEM_API Time& operator *=(Time& left, Int64 right);\n\n////////////////////////////////////////////////////////////\n/// \\relates Time\n/// \\brief Overload of binary / operator to scale a time value\n///\n/// \\param left  Left operand (a time)\n/// \\param right Right operand (a number)\n///\n/// \\return \\a left divided by \\a right\n///\n////////////////////////////////////////////////////////////\nSFML_SYSTEM_API Time operator /(Time left, float right);\n\n////////////////////////////////////////////////////////////\n/// \\relates Time\n/// \\brief Overload of binary / operator to scale a time value\n///\n/// \\param left  Left operand (a time)\n/// \\param right Right operand (a number)\n///\n/// \\return \\a left divided by \\a right\n///\n////////////////////////////////////////////////////////////\nSFML_SYSTEM_API Time operator /(Time left, Int64 right);\n\n////////////////////////////////////////////////////////////\n/// \\relates Time\n/// \\brief Overload of binary /= operator to scale/assign a time value\n///\n/// \\param left  Left operand (a time)\n/// \\param right Right operand (a number)\n///\n/// \\return \\a left divided by \\a right\n///\n////////////////////////////////////////////////////////////\nSFML_SYSTEM_API Time& operator /=(Time& left, float right);\n\n////////////////////////////////////////////////////////////\n/// \\relates Time\n/// \\brief Overload of binary /= operator to scale/assign a time value\n///\n/// \\param left  Left operand (a time)\n/// \\param right Right operand (a number)\n///\n/// \\return \\a left divided by \\a right\n///\n////////////////////////////////////////////////////////////\nSFML_SYSTEM_API Time& operator /=(Time& left, Int64 right);\n\n////////////////////////////////////////////////////////////\n/// \\relates Time\n/// \\brief Overload of binary / operator to compute the ratio of two time values\n///\n/// \\param left  Left operand (a time)\n/// \\param right Right operand (a time)\n///\n/// \\return \\a left divided by \\a right\n///\n////////////////////////////////////////////////////////////\nSFML_SYSTEM_API float operator /(Time left, Time right);\n\n////////////////////////////////////////////////////////////\n/// \\relates Time\n/// \\brief Overload of binary % operator to compute remainder of a time value\n///\n/// \\param left  Left operand (a time)\n/// \\param right Right operand (a time)\n///\n/// \\return \\a left modulo \\a right\n///\n////////////////////////////////////////////////////////////\nSFML_SYSTEM_API Time operator %(Time left, Time right);\n\n////////////////////////////////////////////////////////////\n/// \\relates Time\n/// \\brief Overload of binary %= operator to compute/assign remainder of a time value\n///\n/// \\param left  Left operand (a time)\n/// \\param right Right operand (a time)\n///\n/// \\return \\a left modulo \\a right\n///\n////////////////////////////////////////////////////////////\nSFML_SYSTEM_API Time& operator %=(Time& left, Time right);\n\n} // namespace sf\n\n\n#endif // SFML_TIME_HPP\n\n\n////////////////////////////////////////////////////////////\n/// \\class sf::Time\n/// \\ingroup system\n///\n/// sf::Time encapsulates a time value in a flexible way.\n/// It allows to define a time value either as a number of\n/// seconds, milliseconds or microseconds. It also works the\n/// other way round: you can read a time value as either\n/// a number of seconds, milliseconds or microseconds.\n///\n/// By using such a flexible interface, the API doesn't\n/// impose any fixed type or resolution for time values,\n/// and let the user choose its own favorite representation.\n///\n/// Time values support the usual mathematical operations:\n/// you can add or subtract two times, multiply or divide\n/// a time by a number, compare two times, etc.\n///\n/// Since they represent a time span and not an absolute time\n/// value, times can also be negative.\n///\n/// Usage example:\n/// \\code\n/// sf::Time t1 = sf::seconds(0.1f);\n/// Int32 milli = t1.asMilliseconds(); // 100\n///\n/// sf::Time t2 = sf::milliseconds(30);\n/// Int64 micro = t2.asMicroseconds(); // 30000\n///\n/// sf::Time t3 = sf::microseconds(-800000);\n/// float sec = t3.asSeconds(); // -0.8\n/// \\endcode\n///\n/// \\code\n/// void update(sf::Time elapsed)\n/// {\n///    position += speed * elapsed.asSeconds();\n/// }\n///\n/// update(sf::milliseconds(100));\n/// \\endcode\n///\n/// \\see sf::Clock\n///\n////////////////////////////////////////////////////////////\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/System/Utf.hpp",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n#ifndef SFML_UTF_HPP\n#define SFML_UTF_HPP\n\n////////////////////////////////////////////////////////////\n// Headers\n////////////////////////////////////////////////////////////\n#include <SFML/Config.hpp>\n#include <algorithm>\n#include <locale>\n#include <string>\n#include <cstdlib>\n\n\nnamespace sf\n{\ntemplate <unsigned int N>\nclass Utf;\n\n////////////////////////////////////////////////////////////\n/// \\brief Specialization of the Utf template for UTF-8\n///\n////////////////////////////////////////////////////////////\ntemplate <>\nclass Utf<8>\n{\npublic:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Decode a single UTF-8 character\n    ///\n    /// Decoding a character means finding its unique 32-bits\n    /// code (called the codepoint) in the Unicode standard.\n    ///\n    /// \\param begin       Iterator pointing to the beginning of the input sequence\n    /// \\param end         Iterator pointing to the end of the input sequence\n    /// \\param output      Codepoint of the decoded UTF-8 character\n    /// \\param replacement Replacement character to use in case the UTF-8 sequence is invalid\n    ///\n    /// \\return Iterator pointing to one past the last read element of the input sequence\n    ///\n    ////////////////////////////////////////////////////////////\n    template <typename In>\n    static In decode(In begin, In end, Uint32& output, Uint32 replacement = 0);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Encode a single UTF-8 character\n    ///\n    /// Encoding a character means converting a unique 32-bits\n    /// code (called the codepoint) in the target encoding, UTF-8.\n    ///\n    /// \\param input       Codepoint to encode as UTF-8\n    /// \\param output      Iterator pointing to the beginning of the output sequence\n    /// \\param replacement Replacement for characters not convertible to UTF-8 (use 0 to skip them)\n    ///\n    /// \\return Iterator to the end of the output sequence which has been written\n    ///\n    ////////////////////////////////////////////////////////////\n    template <typename Out>\n    static Out encode(Uint32 input, Out output, Uint8 replacement = 0);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Advance to the next UTF-8 character\n    ///\n    /// This function is necessary for multi-elements encodings, as\n    /// a single character may use more than 1 storage element.\n    ///\n    /// \\param begin Iterator pointing to the beginning of the input sequence\n    /// \\param end   Iterator pointing to the end of the input sequence\n    ///\n    /// \\return Iterator pointing to one past the last read element of the input sequence\n    ///\n    ////////////////////////////////////////////////////////////\n    template <typename In>\n    static In next(In begin, In end);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Count the number of characters of a UTF-8 sequence\n    ///\n    /// This function is necessary for multi-elements encodings, as\n    /// a single character may use more than 1 storage element, thus the\n    /// total size can be different from (begin - end).\n    ///\n    /// \\param begin Iterator pointing to the beginning of the input sequence\n    /// \\param end   Iterator pointing to the end of the input sequence\n    ///\n    /// \\return Iterator pointing to one past the last read element of the input sequence\n    ///\n    ////////////////////////////////////////////////////////////\n    template <typename In>\n    static std::size_t count(In begin, In end);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Convert an ANSI characters range to UTF-8\n    ///\n    /// The current global locale will be used by default, unless you\n    /// pass a custom one in the \\a locale parameter.\n    ///\n    /// \\param begin  Iterator pointing to the beginning of the input sequence\n    /// \\param end    Iterator pointing to the end of the input sequence\n    /// \\param output Iterator pointing to the beginning of the output sequence\n    /// \\param locale Locale to use for conversion\n    ///\n    /// \\return Iterator to the end of the output sequence which has been written\n    ///\n    ////////////////////////////////////////////////////////////\n    template <typename In, typename Out>\n    static Out fromAnsi(In begin, In end, Out output, const std::locale& locale = std::locale());\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Convert a wide characters range to UTF-8\n    ///\n    /// \\param begin  Iterator pointing to the beginning of the input sequence\n    /// \\param end    Iterator pointing to the end of the input sequence\n    /// \\param output Iterator pointing to the beginning of the output sequence\n    ///\n    /// \\return Iterator to the end of the output sequence which has been written\n    ///\n    ////////////////////////////////////////////////////////////\n    template <typename In, typename Out>\n    static Out fromWide(In begin, In end, Out output);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Convert a latin-1 (ISO-5589-1) characters range to UTF-8\n    ///\n    /// \\param begin  Iterator pointing to the beginning of the input sequence\n    /// \\param end    Iterator pointing to the end of the input sequence\n    /// \\param output Iterator pointing to the beginning of the output sequence\n    ///\n    /// \\return Iterator to the end of the output sequence which has been written\n    ///\n    ////////////////////////////////////////////////////////////\n    template <typename In, typename Out>\n    static Out fromLatin1(In begin, In end, Out output);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Convert an UTF-8 characters range to ANSI characters\n    ///\n    /// The current global locale will be used by default, unless you\n    /// pass a custom one in the \\a locale parameter.\n    ///\n    /// \\param begin       Iterator pointing to the beginning of the input sequence\n    /// \\param end         Iterator pointing to the end of the input sequence\n    /// \\param output      Iterator pointing to the beginning of the output sequence\n    /// \\param replacement Replacement for characters not convertible to ANSI (use 0 to skip them)\n    /// \\param locale      Locale to use for conversion\n    ///\n    /// \\return Iterator to the end of the output sequence which has been written\n    ///\n    ////////////////////////////////////////////////////////////\n    template <typename In, typename Out>\n    static Out toAnsi(In begin, In end, Out output, char replacement = 0, const std::locale& locale = std::locale());\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Convert an UTF-8 characters range to wide characters\n    ///\n    /// \\param begin       Iterator pointing to the beginning of the input sequence\n    /// \\param end         Iterator pointing to the end of the input sequence\n    /// \\param output      Iterator pointing to the beginning of the output sequence\n    /// \\param replacement Replacement for characters not convertible to wide (use 0 to skip them)\n    ///\n    /// \\return Iterator to the end of the output sequence which has been written\n    ///\n    ////////////////////////////////////////////////////////////\n    template <typename In, typename Out>\n    static Out toWide(In begin, In end, Out output, wchar_t replacement = 0);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Convert an UTF-8 characters range to latin-1 (ISO-5589-1) characters\n    ///\n    /// \\param begin       Iterator pointing to the beginning of the input sequence\n    /// \\param end         Iterator pointing to the end of the input sequence\n    /// \\param output      Iterator pointing to the beginning of the output sequence\n    /// \\param replacement Replacement for characters not convertible to wide (use 0 to skip them)\n    ///\n    /// \\return Iterator to the end of the output sequence which has been written\n    ///\n    ////////////////////////////////////////////////////////////\n    template <typename In, typename Out>\n    static Out toLatin1(In begin, In end, Out output, char replacement = 0);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Convert a UTF-8 characters range to UTF-8\n    ///\n    /// This functions does nothing more than a direct copy;\n    /// it is defined only to provide the same interface as other\n    /// specializations of the sf::Utf<> template, and allow\n    /// generic code to be written on top of it.\n    ///\n    /// \\param begin  Iterator pointing to the beginning of the input sequence\n    /// \\param end    Iterator pointing to the end of the input sequence\n    /// \\param output Iterator pointing to the beginning of the output sequence\n    ///\n    /// \\return Iterator to the end of the output sequence which has been written\n    ///\n    ////////////////////////////////////////////////////////////\n    template <typename In, typename Out>\n    static Out toUtf8(In begin, In end, Out output);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Convert a UTF-8 characters range to UTF-16\n    ///\n    /// \\param begin  Iterator pointing to the beginning of the input sequence\n    /// \\param end    Iterator pointing to the end of the input sequence\n    /// \\param output Iterator pointing to the beginning of the output sequence\n    ///\n    /// \\return Iterator to the end of the output sequence which has been written\n    ///\n    ////////////////////////////////////////////////////////////\n    template <typename In, typename Out>\n    static Out toUtf16(In begin, In end, Out output);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Convert a UTF-8 characters range to UTF-32\n    ///\n    /// \\param begin  Iterator pointing to the beginning of the input sequence\n    /// \\param end    Iterator pointing to the end of the input sequence\n    /// \\param output Iterator pointing to the beginning of the output sequence\n    ///\n    /// \\return Iterator to the end of the output sequence which has been written\n    ///\n    ////////////////////////////////////////////////////////////\n    template <typename In, typename Out>\n    static Out toUtf32(In begin, In end, Out output);\n};\n\n////////////////////////////////////////////////////////////\n/// \\brief Specialization of the Utf template for UTF-16\n///\n////////////////////////////////////////////////////////////\ntemplate <>\nclass Utf<16>\n{\npublic:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Decode a single UTF-16 character\n    ///\n    /// Decoding a character means finding its unique 32-bits\n    /// code (called the codepoint) in the Unicode standard.\n    ///\n    /// \\param begin       Iterator pointing to the beginning of the input sequence\n    /// \\param end         Iterator pointing to the end of the input sequence\n    /// \\param output      Codepoint of the decoded UTF-16 character\n    /// \\param replacement Replacement character to use in case the UTF-8 sequence is invalid\n    ///\n    /// \\return Iterator pointing to one past the last read element of the input sequence\n    ///\n    ////////////////////////////////////////////////////////////\n    template <typename In>\n    static In decode(In begin, In end, Uint32& output, Uint32 replacement = 0);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Encode a single UTF-16 character\n    ///\n    /// Encoding a character means converting a unique 32-bits\n    /// code (called the codepoint) in the target encoding, UTF-16.\n    ///\n    /// \\param input       Codepoint to encode as UTF-16\n    /// \\param output      Iterator pointing to the beginning of the output sequence\n    /// \\param replacement Replacement for characters not convertible to UTF-16 (use 0 to skip them)\n    ///\n    /// \\return Iterator to the end of the output sequence which has been written\n    ///\n    ////////////////////////////////////////////////////////////\n    template <typename Out>\n    static Out encode(Uint32 input, Out output, Uint16 replacement = 0);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Advance to the next UTF-16 character\n    ///\n    /// This function is necessary for multi-elements encodings, as\n    /// a single character may use more than 1 storage element.\n    ///\n    /// \\param begin Iterator pointing to the beginning of the input sequence\n    /// \\param end   Iterator pointing to the end of the input sequence\n    ///\n    /// \\return Iterator pointing to one past the last read element of the input sequence\n    ///\n    ////////////////////////////////////////////////////////////\n    template <typename In>\n    static In next(In begin, In end);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Count the number of characters of a UTF-16 sequence\n    ///\n    /// This function is necessary for multi-elements encodings, as\n    /// a single character may use more than 1 storage element, thus the\n    /// total size can be different from (begin - end).\n    ///\n    /// \\param begin Iterator pointing to the beginning of the input sequence\n    /// \\param end   Iterator pointing to the end of the input sequence\n    ///\n    /// \\return Iterator pointing to one past the last read element of the input sequence\n    ///\n    ////////////////////////////////////////////////////////////\n    template <typename In>\n    static std::size_t count(In begin, In end);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Convert an ANSI characters range to UTF-16\n    ///\n    /// The current global locale will be used by default, unless you\n    /// pass a custom one in the \\a locale parameter.\n    ///\n    /// \\param begin  Iterator pointing to the beginning of the input sequence\n    /// \\param end    Iterator pointing to the end of the input sequence\n    /// \\param output Iterator pointing to the beginning of the output sequence\n    /// \\param locale Locale to use for conversion\n    ///\n    /// \\return Iterator to the end of the output sequence which has been written\n    ///\n    ////////////////////////////////////////////////////////////\n    template <typename In, typename Out>\n    static Out fromAnsi(In begin, In end, Out output, const std::locale& locale = std::locale());\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Convert a wide characters range to UTF-16\n    ///\n    /// \\param begin  Iterator pointing to the beginning of the input sequence\n    /// \\param end    Iterator pointing to the end of the input sequence\n    /// \\param output Iterator pointing to the beginning of the output sequence\n    ///\n    /// \\return Iterator to the end of the output sequence which has been written\n    ///\n    ////////////////////////////////////////////////////////////\n    template <typename In, typename Out>\n    static Out fromWide(In begin, In end, Out output);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Convert a latin-1 (ISO-5589-1) characters range to UTF-16\n    ///\n    /// \\param begin  Iterator pointing to the beginning of the input sequence\n    /// \\param end    Iterator pointing to the end of the input sequence\n    /// \\param output Iterator pointing to the beginning of the output sequence\n    ///\n    /// \\return Iterator to the end of the output sequence which has been written\n    ///\n    ////////////////////////////////////////////////////////////\n    template <typename In, typename Out>\n    static Out fromLatin1(In begin, In end, Out output);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Convert an UTF-16 characters range to ANSI characters\n    ///\n    /// The current global locale will be used by default, unless you\n    /// pass a custom one in the \\a locale parameter.\n    ///\n    /// \\param begin       Iterator pointing to the beginning of the input sequence\n    /// \\param end         Iterator pointing to the end of the input sequence\n    /// \\param output      Iterator pointing to the beginning of the output sequence\n    /// \\param replacement Replacement for characters not convertible to ANSI (use 0 to skip them)\n    /// \\param locale      Locale to use for conversion\n    ///\n    /// \\return Iterator to the end of the output sequence which has been written\n    ///\n    ////////////////////////////////////////////////////////////\n    template <typename In, typename Out>\n    static Out toAnsi(In begin, In end, Out output, char replacement = 0, const std::locale& locale = std::locale());\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Convert an UTF-16 characters range to wide characters\n    ///\n    /// \\param begin       Iterator pointing to the beginning of the input sequence\n    /// \\param end         Iterator pointing to the end of the input sequence\n    /// \\param output      Iterator pointing to the beginning of the output sequence\n    /// \\param replacement Replacement for characters not convertible to wide (use 0 to skip them)\n    ///\n    /// \\return Iterator to the end of the output sequence which has been written\n    ///\n    ////////////////////////////////////////////////////////////\n    template <typename In, typename Out>\n    static Out toWide(In begin, In end, Out output, wchar_t replacement = 0);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Convert an UTF-16 characters range to latin-1 (ISO-5589-1) characters\n    ///\n    /// \\param begin       Iterator pointing to the beginning of the input sequence\n    /// \\param end         Iterator pointing to the end of the input sequence\n    /// \\param output      Iterator pointing to the beginning of the output sequence\n    /// \\param replacement Replacement for characters not convertible to wide (use 0 to skip them)\n    ///\n    /// \\return Iterator to the end of the output sequence which has been written\n    ///\n    ////////////////////////////////////////////////////////////\n    template <typename In, typename Out>\n    static Out toLatin1(In begin, In end, Out output, char replacement = 0);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Convert a UTF-16 characters range to UTF-8\n    ///\n    /// \\param begin  Iterator pointing to the beginning of the input sequence\n    /// \\param end    Iterator pointing to the end of the input sequence\n    /// \\param output Iterator pointing to the beginning of the output sequence\n    ///\n    /// \\return Iterator to the end of the output sequence which has been written\n    ///\n    ////////////////////////////////////////////////////////////\n    template <typename In, typename Out>\n    static Out toUtf8(In begin, In end, Out output);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Convert a UTF-16 characters range to UTF-16\n    ///\n    /// This functions does nothing more than a direct copy;\n    /// it is defined only to provide the same interface as other\n    /// specializations of the sf::Utf<> template, and allow\n    /// generic code to be written on top of it.\n    ///\n    /// \\param begin  Iterator pointing to the beginning of the input sequence\n    /// \\param end    Iterator pointing to the end of the input sequence\n    /// \\param output Iterator pointing to the beginning of the output sequence\n    ///\n    /// \\return Iterator to the end of the output sequence which has been written\n    ///\n    ////////////////////////////////////////////////////////////\n    template <typename In, typename Out>\n    static Out toUtf16(In begin, In end, Out output);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Convert a UTF-16 characters range to UTF-32\n    ///\n    /// \\param begin  Iterator pointing to the beginning of the input sequence\n    /// \\param end    Iterator pointing to the end of the input sequence\n    /// \\param output Iterator pointing to the beginning of the output sequence\n    ///\n    /// \\return Iterator to the end of the output sequence which has been written\n    ///\n    ////////////////////////////////////////////////////////////\n    template <typename In, typename Out>\n    static Out toUtf32(In begin, In end, Out output);\n};\n\n////////////////////////////////////////////////////////////\n/// \\brief Specialization of the Utf template for UTF-32\n///\n////////////////////////////////////////////////////////////\ntemplate <>\nclass Utf<32>\n{\npublic:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Decode a single UTF-32 character\n    ///\n    /// Decoding a character means finding its unique 32-bits\n    /// code (called the codepoint) in the Unicode standard.\n    /// For UTF-32, the character value is the same as the codepoint.\n    ///\n    /// \\param begin       Iterator pointing to the beginning of the input sequence\n    /// \\param end         Iterator pointing to the end of the input sequence\n    /// \\param output      Codepoint of the decoded UTF-32 character\n    /// \\param replacement Replacement character to use in case the UTF-8 sequence is invalid\n    ///\n    /// \\return Iterator pointing to one past the last read element of the input sequence\n    ///\n    ////////////////////////////////////////////////////////////\n    template <typename In>\n    static In decode(In begin, In end, Uint32& output, Uint32 replacement = 0);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Encode a single UTF-32 character\n    ///\n    /// Encoding a character means converting a unique 32-bits\n    /// code (called the codepoint) in the target encoding, UTF-32.\n    /// For UTF-32, the codepoint is the same as the character value.\n    ///\n    /// \\param input       Codepoint to encode as UTF-32\n    /// \\param output      Iterator pointing to the beginning of the output sequence\n    /// \\param replacement Replacement for characters not convertible to UTF-32 (use 0 to skip them)\n    ///\n    /// \\return Iterator to the end of the output sequence which has been written\n    ///\n    ////////////////////////////////////////////////////////////\n    template <typename Out>\n    static Out encode(Uint32 input, Out output, Uint32 replacement = 0);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Advance to the next UTF-32 character\n    ///\n    /// This function is trivial for UTF-32, which can store\n    /// every character in a single storage element.\n    ///\n    /// \\param begin Iterator pointing to the beginning of the input sequence\n    /// \\param end   Iterator pointing to the end of the input sequence\n    ///\n    /// \\return Iterator pointing to one past the last read element of the input sequence\n    ///\n    ////////////////////////////////////////////////////////////\n    template <typename In>\n    static In next(In begin, In end);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Count the number of characters of a UTF-32 sequence\n    ///\n    /// This function is trivial for UTF-32, which can store\n    /// every character in a single storage element.\n    ///\n    /// \\param begin Iterator pointing to the beginning of the input sequence\n    /// \\param end   Iterator pointing to the end of the input sequence\n    ///\n    /// \\return Iterator pointing to one past the last read element of the input sequence\n    ///\n    ////////////////////////////////////////////////////////////\n    template <typename In>\n    static std::size_t count(In begin, In end);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Convert an ANSI characters range to UTF-32\n    ///\n    /// The current global locale will be used by default, unless you\n    /// pass a custom one in the \\a locale parameter.\n    ///\n    /// \\param begin  Iterator pointing to the beginning of the input sequence\n    /// \\param end    Iterator pointing to the end of the input sequence\n    /// \\param output Iterator pointing to the beginning of the output sequence\n    /// \\param locale Locale to use for conversion\n    ///\n    /// \\return Iterator to the end of the output sequence which has been written\n    ///\n    ////////////////////////////////////////////////////////////\n    template <typename In, typename Out>\n    static Out fromAnsi(In begin, In end, Out output, const std::locale& locale = std::locale());\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Convert a wide characters range to UTF-32\n    ///\n    /// \\param begin  Iterator pointing to the beginning of the input sequence\n    /// \\param end    Iterator pointing to the end of the input sequence\n    /// \\param output Iterator pointing to the beginning of the output sequence\n    ///\n    /// \\return Iterator to the end of the output sequence which has been written\n    ///\n    ////////////////////////////////////////////////////////////\n    template <typename In, typename Out>\n    static Out fromWide(In begin, In end, Out output);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Convert a latin-1 (ISO-5589-1) characters range to UTF-32\n    ///\n    /// \\param begin  Iterator pointing to the beginning of the input sequence\n    /// \\param end    Iterator pointing to the end of the input sequence\n    /// \\param output Iterator pointing to the beginning of the output sequence\n    ///\n    /// \\return Iterator to the end of the output sequence which has been written\n    ///\n    ////////////////////////////////////////////////////////////\n    template <typename In, typename Out>\n    static Out fromLatin1(In begin, In end, Out output);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Convert an UTF-32 characters range to ANSI characters\n    ///\n    /// The current global locale will be used by default, unless you\n    /// pass a custom one in the \\a locale parameter.\n    ///\n    /// \\param begin       Iterator pointing to the beginning of the input sequence\n    /// \\param end         Iterator pointing to the end of the input sequence\n    /// \\param output      Iterator pointing to the beginning of the output sequence\n    /// \\param replacement Replacement for characters not convertible to ANSI (use 0 to skip them)\n    /// \\param locale      Locale to use for conversion\n    ///\n    /// \\return Iterator to the end of the output sequence which has been written\n    ///\n    ////////////////////////////////////////////////////////////\n    template <typename In, typename Out>\n    static Out toAnsi(In begin, In end, Out output, char replacement = 0, const std::locale& locale = std::locale());\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Convert an UTF-32 characters range to wide characters\n    ///\n    /// \\param begin       Iterator pointing to the beginning of the input sequence\n    /// \\param end         Iterator pointing to the end of the input sequence\n    /// \\param output      Iterator pointing to the beginning of the output sequence\n    /// \\param replacement Replacement for characters not convertible to wide (use 0 to skip them)\n    ///\n    /// \\return Iterator to the end of the output sequence which has been written\n    ///\n    ////////////////////////////////////////////////////////////\n    template <typename In, typename Out>\n    static Out toWide(In begin, In end, Out output, wchar_t replacement = 0);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Convert an UTF-16 characters range to latin-1 (ISO-5589-1) characters\n    ///\n    /// \\param begin       Iterator pointing to the beginning of the input sequence\n    /// \\param end         Iterator pointing to the end of the input sequence\n    /// \\param output      Iterator pointing to the beginning of the output sequence\n    /// \\param replacement Replacement for characters not convertible to wide (use 0 to skip them)\n    ///\n    /// \\return Iterator to the end of the output sequence which has been written\n    ///\n    ////////////////////////////////////////////////////////////\n    template <typename In, typename Out>\n    static Out toLatin1(In begin, In end, Out output, char replacement = 0);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Convert a UTF-32 characters range to UTF-8\n    ///\n    /// \\param begin  Iterator pointing to the beginning of the input sequence\n    /// \\param end    Iterator pointing to the end of the input sequence\n    /// \\param output Iterator pointing to the beginning of the output sequence\n    ///\n    /// \\return Iterator to the end of the output sequence which has been written\n    ///\n    ////////////////////////////////////////////////////////////\n    template <typename In, typename Out>\n    static Out toUtf8(In begin, In end, Out output);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Convert a UTF-32 characters range to UTF-16\n    ///\n    /// \\param begin  Iterator pointing to the beginning of the input sequence\n    /// \\param end    Iterator pointing to the end of the input sequence\n    /// \\param output Iterator pointing to the beginning of the output sequence\n    ///\n    /// \\return Iterator to the end of the output sequence which has been written\n    ///\n    ////////////////////////////////////////////////////////////\n    template <typename In, typename Out>\n    static Out toUtf16(In begin, In end, Out output);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Convert a UTF-32 characters range to UTF-32\n    ///\n    /// This functions does nothing more than a direct copy;\n    /// it is defined only to provide the same interface as other\n    /// specializations of the sf::Utf<> template, and allow\n    /// generic code to be written on top of it.\n    ///\n    /// \\param begin  Iterator pointing to the beginning of the input sequence\n    /// \\param end    Iterator pointing to the end of the input sequence\n    /// \\param output Iterator pointing to the beginning of the output sequence\n    ///\n    /// \\return Iterator to the end of the output sequence which has been written\n    ///\n    ////////////////////////////////////////////////////////////\n    template <typename In, typename Out>\n    static Out toUtf32(In begin, In end, Out output);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Decode a single ANSI character to UTF-32\n    ///\n    /// This function does not exist in other specializations\n    /// of sf::Utf<>, it is defined for convenience (it is used by\n    /// several other conversion functions).\n    ///\n    /// \\param input  Input ANSI character\n    /// \\param locale Locale to use for conversion\n    ///\n    /// \\return Converted character\n    ///\n    ////////////////////////////////////////////////////////////\n    template <typename In>\n    static Uint32 decodeAnsi(In input, const std::locale& locale = std::locale());\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Decode a single wide character to UTF-32\n    ///\n    /// This function does not exist in other specializations\n    /// of sf::Utf<>, it is defined for convenience (it is used by\n    /// several other conversion functions).\n    ///\n    /// \\param input Input wide character\n    ///\n    /// \\return Converted character\n    ///\n    ////////////////////////////////////////////////////////////\n    template <typename In>\n    static Uint32 decodeWide(In input);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Encode a single UTF-32 character to ANSI\n    ///\n    /// This function does not exist in other specializations\n    /// of sf::Utf<>, it is defined for convenience (it is used by\n    /// several other conversion functions).\n    ///\n    /// \\param codepoint   Iterator pointing to the beginning of the input sequence\n    /// \\param output      Iterator pointing to the beginning of the output sequence\n    /// \\param replacement Replacement if the input character is not convertible to ANSI (use 0 to skip it)\n    /// \\param locale      Locale to use for conversion\n    ///\n    /// \\return Iterator to the end of the output sequence which has been written\n    ///\n    ////////////////////////////////////////////////////////////\n    template <typename Out>\n    static Out encodeAnsi(Uint32 codepoint, Out output, char replacement = 0, const std::locale& locale = std::locale());\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Encode a single UTF-32 character to wide\n    ///\n    /// This function does not exist in other specializations\n    /// of sf::Utf<>, it is defined for convenience (it is used by\n    /// several other conversion functions).\n    ///\n    /// \\param codepoint   Iterator pointing to the beginning of the input sequence\n    /// \\param output      Iterator pointing to the beginning of the output sequence\n    /// \\param replacement Replacement if the input character is not convertible to wide (use 0 to skip it)\n    ///\n    /// \\return Iterator to the end of the output sequence which has been written\n    ///\n    ////////////////////////////////////////////////////////////\n    template <typename Out>\n    static Out encodeWide(Uint32 codepoint, Out output, wchar_t replacement = 0);\n};\n\n#include <SFML/System/Utf.inl>\n\n// Make typedefs to get rid of the template syntax\ntypedef Utf<8>  Utf8;\ntypedef Utf<16> Utf16;\ntypedef Utf<32> Utf32;\n\n} // namespace sf\n\n\n#endif // SFML_UTF_HPP\n\n\n////////////////////////////////////////////////////////////\n/// \\class sf::Utf\n/// \\ingroup system\n///\n/// Utility class providing generic functions for UTF conversions.\n///\n/// sf::Utf is a low-level, generic interface for counting, iterating,\n/// encoding and decoding Unicode characters and strings. It is able\n/// to handle ANSI, wide, latin-1, UTF-8, UTF-16 and UTF-32 encodings.\n///\n/// sf::Utf<X> functions are all static, these classes are not meant to\n/// be instantiated. All the functions are template, so that you\n/// can use any character / string type for a given encoding.\n///\n/// It has 3 specializations:\n/// \\li sf::Utf<8> (typedef'd to sf::Utf8)\n/// \\li sf::Utf<16> (typedef'd to sf::Utf16)\n/// \\li sf::Utf<32> (typedef'd to sf::Utf32)\n///\n////////////////////////////////////////////////////////////\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/System/Utf.inl",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n\n////////////////////////////////////////////////////////////\n// References:\n//\n// http://www.unicode.org/\n// http://www.unicode.org/Public/PROGRAMS/CVTUTF/ConvertUTF.c\n// http://www.unicode.org/Public/PROGRAMS/CVTUTF/ConvertUTF.h\n// http://people.w3.org/rishida/scripts/uniview/conversion\n//\n////////////////////////////////////////////////////////////\n\n\n////////////////////////////////////////////////////////////\ntemplate <typename In>\nIn Utf<8>::decode(In begin, In end, Uint32& output, Uint32 replacement)\n{\n    // Some useful precomputed data\n    static const int trailing[256] =\n    {\n        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,\n        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,\n        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,\n        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,\n        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,\n        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,\n        1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\n        2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5\n    };\n    static const Uint32 offsets[6] =\n    {\n        0x00000000, 0x00003080, 0x000E2080, 0x03C82080, 0xFA082080, 0x82082080\n    };\n\n    // decode the character\n    int trailingBytes = trailing[static_cast<Uint8>(*begin)];\n    if (begin + trailingBytes < end)\n    {\n        output = 0;\n        switch (trailingBytes)\n        {\n            case 5: output += static_cast<Uint8>(*begin++); output <<= 6;\n            case 4: output += static_cast<Uint8>(*begin++); output <<= 6;\n            case 3: output += static_cast<Uint8>(*begin++); output <<= 6;\n            case 2: output += static_cast<Uint8>(*begin++); output <<= 6;\n            case 1: output += static_cast<Uint8>(*begin++); output <<= 6;\n            case 0: output += static_cast<Uint8>(*begin++);\n        }\n        output -= offsets[trailingBytes];\n    }\n    else\n    {\n        // Incomplete character\n        begin = end;\n        output = replacement;\n    }\n\n    return begin;\n}\n\n\n////////////////////////////////////////////////////////////\ntemplate <typename Out>\nOut Utf<8>::encode(Uint32 input, Out output, Uint8 replacement)\n{\n    // Some useful precomputed data\n    static const Uint8 firstBytes[7] =\n    {\n        0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC\n    };\n\n    // encode the character\n    if ((input > 0x0010FFFF) || ((input >= 0xD800) && (input <= 0xDBFF)))\n    {\n        // Invalid character\n        if (replacement)\n            *output++ = replacement;\n    }\n    else\n    {\n        // Valid character\n\n        // Get the number of bytes to write\n        std::size_t bytestoWrite = 1;\n        if      (input <  0x80)       bytestoWrite = 1;\n        else if (input <  0x800)      bytestoWrite = 2;\n        else if (input <  0x10000)    bytestoWrite = 3;\n        else if (input <= 0x0010FFFF) bytestoWrite = 4;\n\n        // Extract the bytes to write\n        Uint8 bytes[4];\n        switch (bytestoWrite)\n        {\n            case 4: bytes[3] = static_cast<Uint8>((input | 0x80) & 0xBF); input >>= 6;\n            case 3: bytes[2] = static_cast<Uint8>((input | 0x80) & 0xBF); input >>= 6;\n            case 2: bytes[1] = static_cast<Uint8>((input | 0x80) & 0xBF); input >>= 6;\n            case 1: bytes[0] = static_cast<Uint8> (input | firstBytes[bytestoWrite]);\n        }\n\n        // Add them to the output\n        output = std::copy(bytes, bytes + bytestoWrite, output);\n    }\n\n    return output;\n}\n\n\n////////////////////////////////////////////////////////////\ntemplate <typename In>\nIn Utf<8>::next(In begin, In end)\n{\n    Uint32 codepoint;\n    return decode(begin, end, codepoint);\n}\n\n\n////////////////////////////////////////////////////////////\ntemplate <typename In>\nstd::size_t Utf<8>::count(In begin, In end)\n{\n    std::size_t length = 0;\n    while (begin < end)\n    {\n        begin = next(begin, end);\n        ++length;\n    }\n\n    return length;\n}\n\n\n////////////////////////////////////////////////////////////\ntemplate <typename In, typename Out>\nOut Utf<8>::fromAnsi(In begin, In end, Out output, const std::locale& locale)\n{\n    while (begin < end)\n    {\n        Uint32 codepoint = Utf<32>::decodeAnsi(*begin++, locale);\n        output = encode(codepoint, output);\n    }\n\n    return output;\n}\n\n\n////////////////////////////////////////////////////////////\ntemplate <typename In, typename Out>\nOut Utf<8>::fromWide(In begin, In end, Out output)\n{\n    while (begin < end)\n    {\n        Uint32 codepoint = Utf<32>::decodeWide(*begin++);\n        output = encode(codepoint, output);\n    }\n\n    return output;\n}\n\n\n////////////////////////////////////////////////////////////\ntemplate <typename In, typename Out>\nOut Utf<8>::fromLatin1(In begin, In end, Out output)\n{\n    // Latin-1 is directly compatible with Unicode encodings,\n    // and can thus be treated as (a sub-range of) UTF-32\n    while (begin < end)\n        output = encode(*begin++, output);\n\n    return output;\n}\n\n\n////////////////////////////////////////////////////////////\ntemplate <typename In, typename Out>\nOut Utf<8>::toAnsi(In begin, In end, Out output, char replacement, const std::locale& locale)\n{\n    while (begin < end)\n    {\n        Uint32 codepoint;\n        begin = decode(begin, end, codepoint);\n        output = Utf<32>::encodeAnsi(codepoint, output, replacement, locale);\n    }\n\n    return output;\n}\n\n\n////////////////////////////////////////////////////////////\ntemplate <typename In, typename Out>\nOut Utf<8>::toWide(In begin, In end, Out output, wchar_t replacement)\n{\n    while (begin < end)\n    {\n        Uint32 codepoint;\n        begin = decode(begin, end, codepoint);\n        output = Utf<32>::encodeWide(codepoint, output, replacement);\n    }\n\n    return output;\n}\n\n\n////////////////////////////////////////////////////////////\ntemplate <typename In, typename Out>\nOut Utf<8>::toLatin1(In begin, In end, Out output, char replacement)\n{\n    // Latin-1 is directly compatible with Unicode encodings,\n    // and can thus be treated as (a sub-range of) UTF-32\n    while (begin < end)\n    {\n        Uint32 codepoint;\n        begin = decode(begin, end, codepoint);\n        *output++ = codepoint < 256 ? static_cast<char>(codepoint) : replacement;\n    }\n\n    return output;\n}\n\n\n////////////////////////////////////////////////////////////\ntemplate <typename In, typename Out>\nOut Utf<8>::toUtf8(In begin, In end, Out output)\n{\n    return std::copy(begin, end, output);\n}\n\n\n////////////////////////////////////////////////////////////\ntemplate <typename In, typename Out>\nOut Utf<8>::toUtf16(In begin, In end, Out output)\n{\n    while (begin < end)\n    {\n        Uint32 codepoint;\n        begin = decode(begin, end, codepoint);\n        output = Utf<16>::encode(codepoint, output);\n    }\n\n    return output;\n}\n\n\n////////////////////////////////////////////////////////////\ntemplate <typename In, typename Out>\nOut Utf<8>::toUtf32(In begin, In end, Out output)\n{\n    while (begin < end)\n    {\n        Uint32 codepoint;\n        begin = decode(begin, end, codepoint);\n        *output++ = codepoint;\n    }\n\n    return output;\n}\n\n\n////////////////////////////////////////////////////////////\ntemplate <typename In>\nIn Utf<16>::decode(In begin, In end, Uint32& output, Uint32 replacement)\n{\n    Uint16 first = *begin++;\n\n    // If it's a surrogate pair, first convert to a single UTF-32 character\n    if ((first >= 0xD800) && (first <= 0xDBFF))\n    {\n        if (begin < end)\n        {\n            Uint32 second = *begin++;\n            if ((second >= 0xDC00) && (second <= 0xDFFF))\n            {\n                // The second element is valid: convert the two elements to a UTF-32 character\n                output = static_cast<Uint32>(((first - 0xD800) << 10) + (second - 0xDC00) + 0x0010000);\n            }\n            else\n            {\n                // Invalid character\n                output = replacement;\n            }\n        }\n        else\n        {\n            // Invalid character\n            begin = end;\n            output = replacement;\n        }\n    }\n    else\n    {\n        // We can make a direct copy\n        output = first;\n    }\n\n    return begin;\n}\n\n\n////////////////////////////////////////////////////////////\ntemplate <typename Out>\nOut Utf<16>::encode(Uint32 input, Out output, Uint16 replacement)\n{\n    if (input <= 0xFFFF)\n    {\n        // The character can be copied directly, we just need to check if it's in the valid range\n        if ((input >= 0xD800) && (input <= 0xDFFF))\n        {\n            // Invalid character (this range is reserved)\n            if (replacement)\n                *output++ = replacement;\n        }\n        else\n        {\n            // Valid character directly convertible to a single UTF-16 character\n            *output++ = static_cast<Uint16>(input);\n        }\n    }\n    else if (input > 0x0010FFFF)\n    {\n        // Invalid character (greater than the maximum Unicode value)\n        if (replacement)\n            *output++ = replacement;\n    }\n    else\n    {\n        // The input character will be converted to two UTF-16 elements\n        input -= 0x0010000;\n        *output++ = static_cast<Uint16>((input >> 10)     + 0xD800);\n        *output++ = static_cast<Uint16>((input & 0x3FFUL) + 0xDC00);\n    }\n\n    return output;\n}\n\n\n////////////////////////////////////////////////////////////\ntemplate <typename In>\nIn Utf<16>::next(In begin, In end)\n{\n    Uint32 codepoint;\n    return decode(begin, end, codepoint);\n}\n\n\n////////////////////////////////////////////////////////////\ntemplate <typename In>\nstd::size_t Utf<16>::count(In begin, In end)\n{\n    std::size_t length = 0;\n    while (begin < end)\n    {\n        begin = next(begin, end);\n        ++length;\n    }\n\n    return length;\n}\n\n\n////////////////////////////////////////////////////////////\ntemplate <typename In, typename Out>\nOut Utf<16>::fromAnsi(In begin, In end, Out output, const std::locale& locale)\n{\n    while (begin < end)\n    {\n        Uint32 codepoint = Utf<32>::decodeAnsi(*begin++, locale);\n        output = encode(codepoint, output);\n    }\n\n    return output;\n}\n\n\n////////////////////////////////////////////////////////////\ntemplate <typename In, typename Out>\nOut Utf<16>::fromWide(In begin, In end, Out output)\n{\n    while (begin < end)\n    {\n        Uint32 codepoint = Utf<32>::decodeWide(*begin++);\n        output = encode(codepoint, output);\n    }\n\n    return output;\n}\n\n\n////////////////////////////////////////////////////////////\ntemplate <typename In, typename Out>\nOut Utf<16>::fromLatin1(In begin, In end, Out output)\n{\n    // Latin-1 is directly compatible with Unicode encodings,\n    // and can thus be treated as (a sub-range of) UTF-32\n    return std::copy(begin, end, output);\n}\n\n\n////////////////////////////////////////////////////////////\ntemplate <typename In, typename Out>\nOut Utf<16>::toAnsi(In begin, In end, Out output, char replacement, const std::locale& locale)\n{\n    while (begin < end)\n    {\n        Uint32 codepoint;\n        begin = decode(begin, end, codepoint);\n        output = Utf<32>::encodeAnsi(codepoint, output, replacement, locale);\n    }\n\n    return output;\n}\n\n\n////////////////////////////////////////////////////////////\ntemplate <typename In, typename Out>\nOut Utf<16>::toWide(In begin, In end, Out output, wchar_t replacement)\n{\n    while (begin < end)\n    {\n        Uint32 codepoint;\n        begin = decode(begin, end, codepoint);\n        output = Utf<32>::encodeWide(codepoint, output, replacement);\n    }\n\n    return output;\n}\n\n\n////////////////////////////////////////////////////////////\ntemplate <typename In, typename Out>\nOut Utf<16>::toLatin1(In begin, In end, Out output, char replacement)\n{\n    // Latin-1 is directly compatible with Unicode encodings,\n    // and can thus be treated as (a sub-range of) UTF-32\n    while (begin < end)\n    {\n        *output++ = *begin < 256 ? static_cast<char>(*begin) : replacement;\n        begin++;\n    }\n\n    return output;\n}\n\n\n////////////////////////////////////////////////////////////\ntemplate <typename In, typename Out>\nOut Utf<16>::toUtf8(In begin, In end, Out output)\n{\n    while (begin < end)\n    {\n        Uint32 codepoint;\n        begin = decode(begin, end, codepoint);\n        output = Utf<8>::encode(codepoint, output);\n    }\n\n    return output;\n}\n\n\n////////////////////////////////////////////////////////////\ntemplate <typename In, typename Out>\nOut Utf<16>::toUtf16(In begin, In end, Out output)\n{\n    return std::copy(begin, end, output);\n}\n\n\n////////////////////////////////////////////////////////////\ntemplate <typename In, typename Out>\nOut Utf<16>::toUtf32(In begin, In end, Out output)\n{\n    while (begin < end)\n    {\n        Uint32 codepoint;\n        begin = decode(begin, end, codepoint);\n        *output++ = codepoint;\n    }\n\n    return output;\n}\n\n\n////////////////////////////////////////////////////////////\ntemplate <typename In>\nIn Utf<32>::decode(In begin, In /*end*/, Uint32& output, Uint32 /*replacement*/)\n{\n    output = *begin++;\n    return begin;\n}\n\n\n////////////////////////////////////////////////////////////\ntemplate <typename Out>\nOut Utf<32>::encode(Uint32 input, Out output, Uint32 /*replacement*/)\n{\n    *output++ = input;\n    return output;\n}\n\n\n////////////////////////////////////////////////////////////\ntemplate <typename In>\nIn Utf<32>::next(In begin, In /*end*/)\n{\n    return ++begin;\n}\n\n\n////////////////////////////////////////////////////////////\ntemplate <typename In>\nstd::size_t Utf<32>::count(In begin, In end)\n{\n    return begin - end;\n}\n\n\n////////////////////////////////////////////////////////////\ntemplate <typename In, typename Out>\nOut Utf<32>::fromAnsi(In begin, In end, Out output, const std::locale& locale)\n{\n    while (begin < end)\n        *output++ = decodeAnsi(*begin++, locale);\n\n    return output;\n}\n\n\n////////////////////////////////////////////////////////////\ntemplate <typename In, typename Out>\nOut Utf<32>::fromWide(In begin, In end, Out output)\n{\n    while (begin < end)\n        *output++ = decodeWide(*begin++);\n\n    return output;\n}\n\n\n////////////////////////////////////////////////////////////\ntemplate <typename In, typename Out>\nOut Utf<32>::fromLatin1(In begin, In end, Out output)\n{\n    // Latin-1 is directly compatible with Unicode encodings,\n    // and can thus be treated as (a sub-range of) UTF-32\n    return std::copy(begin, end, output);\n}\n\n\n////////////////////////////////////////////////////////////\ntemplate <typename In, typename Out>\nOut Utf<32>::toAnsi(In begin, In end, Out output, char replacement, const std::locale& locale)\n{\n    while (begin < end)\n        output = encodeAnsi(*begin++, output, replacement, locale);\n\n    return output;\n}\n\n\n////////////////////////////////////////////////////////////\ntemplate <typename In, typename Out>\nOut Utf<32>::toWide(In begin, In end, Out output, wchar_t replacement)\n{\n    while (begin < end)\n        output = encodeWide(*begin++, output, replacement);\n\n    return output;\n}\n\n\n////////////////////////////////////////////////////////////\ntemplate <typename In, typename Out>\nOut Utf<32>::toLatin1(In begin, In end, Out output, char replacement)\n{\n    // Latin-1 is directly compatible with Unicode encodings,\n    // and can thus be treated as (a sub-range of) UTF-32\n    while (begin < end)\n    {\n        *output++ = *begin < 256 ? static_cast<char>(*begin) : replacement;\n        begin++;\n    }\n\n    return output;\n}\n\n\n////////////////////////////////////////////////////////////\ntemplate <typename In, typename Out>\nOut Utf<32>::toUtf8(In begin, In end, Out output)\n{\n    while (begin < end)\n        output = Utf<8>::encode(*begin++, output);\n\n    return output;\n}\n\n////////////////////////////////////////////////////////////\ntemplate <typename In, typename Out>\nOut Utf<32>::toUtf16(In begin, In end, Out output)\n{\n    while (begin < end)\n        output = Utf<16>::encode(*begin++, output);\n\n    return output;\n}\n\n\n////////////////////////////////////////////////////////////\ntemplate <typename In, typename Out>\nOut Utf<32>::toUtf32(In begin, In end, Out output)\n{\n    return std::copy(begin, end, output);\n}\n\n\n////////////////////////////////////////////////////////////\ntemplate <typename In>\nUint32 Utf<32>::decodeAnsi(In input, const std::locale& locale)\n{\n    // On Windows, GCC's standard library (glibc++) has almost\n    // no support for Unicode stuff. As a consequence, in this\n    // context we can only use the default locale and ignore\n    // the one passed as parameter.\n\n    #if defined(SFML_SYSTEM_WINDOWS) &&                       /* if Windows ... */                          \\\n       (defined(__GLIBCPP__) || defined (__GLIBCXX__)) &&     /* ... and standard library is glibc++ ... */ \\\n      !(defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION)) /* ... and STLPort is not used on top of it */\n\n        (void)locale; // to avoid warnings\n\n        wchar_t character = 0;\n        mbtowc(&character, &input, 1);\n        return static_cast<Uint32>(character);\n\n    #else\n\n        // Get the facet of the locale which deals with character conversion\n        const std::ctype<wchar_t>& facet = std::use_facet< std::ctype<wchar_t> >(locale);\n\n        // Use the facet to convert each character of the input string\n        return static_cast<Uint32>(facet.widen(input));\n\n    #endif\n}\n\n\n////////////////////////////////////////////////////////////\ntemplate <typename In>\nUint32 Utf<32>::decodeWide(In input)\n{\n    // The encoding of wide characters is not well defined and is left to the system;\n    // however we can safely assume that it is UCS-2 on Windows and\n    // UCS-4 on Unix systems.\n    // In both cases, a simple copy is enough (UCS-2 is a subset of UCS-4,\n    // and UCS-4 *is* UTF-32).\n\n    return input;\n}\n\n\n////////////////////////////////////////////////////////////\ntemplate <typename Out>\nOut Utf<32>::encodeAnsi(Uint32 codepoint, Out output, char replacement, const std::locale& locale)\n{\n    // On Windows, gcc's standard library (glibc++) has almost\n    // no support for Unicode stuff. As a consequence, in this\n    // context we can only use the default locale and ignore\n    // the one passed as parameter.\n\n    #if defined(SFML_SYSTEM_WINDOWS) &&                       /* if Windows ... */                          \\\n       (defined(__GLIBCPP__) || defined (__GLIBCXX__)) &&     /* ... and standard library is glibc++ ... */ \\\n      !(defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION)) /* ... and STLPort is not used on top of it */\n\n        (void)locale; // to avoid warnings\n\n        char character = 0;\n        if (wctomb(&character, static_cast<wchar_t>(codepoint)) >= 0)\n            *output++ = character;\n        else if (replacement)\n            *output++ = replacement;\n\n        return output;\n\n    #else\n\n        // Get the facet of the locale which deals with character conversion\n        const std::ctype<wchar_t>& facet = std::use_facet< std::ctype<wchar_t> >(locale);\n\n        // Use the facet to convert each character of the input string\n        *output++ = facet.narrow(static_cast<wchar_t>(codepoint), replacement);\n\n        return output;\n\n    #endif\n}\n\n\n////////////////////////////////////////////////////////////\ntemplate <typename Out>\nOut Utf<32>::encodeWide(Uint32 codepoint, Out output, wchar_t replacement)\n{\n    // The encoding of wide characters is not well defined and is left to the system;\n    // however we can safely assume that it is UCS-2 on Windows and\n    // UCS-4 on Unix systems.\n    // For UCS-2 we need to check if the source characters fits in (UCS-2 is a subset of UCS-4).\n    // For UCS-4 we can do a direct copy (UCS-4 *is* UTF-32).\n\n    switch (sizeof(wchar_t))\n    {\n        case 4:\n        {\n            *output++ = static_cast<wchar_t>(codepoint);\n            break;\n        }\n\n        default:\n        {\n            if ((codepoint <= 0xFFFF) && ((codepoint < 0xD800) || (codepoint > 0xDFFF)))\n            {\n                *output++ = static_cast<wchar_t>(codepoint);\n            }\n            else if (replacement)\n            {\n                *output++ = replacement;\n            }\n            break;\n        }\n    }\n\n    return output;\n}\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/System/Vector2.hpp",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n#ifndef SFML_VECTOR2_HPP\n#define SFML_VECTOR2_HPP\n\n\nnamespace sf\n{\n////////////////////////////////////////////////////////////\n/// \\brief Utility template class for manipulating\n///        2-dimensional vectors\n///\n////////////////////////////////////////////////////////////\ntemplate <typename T>\nclass Vector2\n{\npublic:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Default constructor\n    ///\n    /// Creates a Vector2(0, 0).\n    ///\n    ////////////////////////////////////////////////////////////\n    Vector2();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Construct the vector from its coordinates\n    ///\n    /// \\param X X coordinate\n    /// \\param Y Y coordinate\n    ///\n    ////////////////////////////////////////////////////////////\n    Vector2(T X, T Y);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Construct the vector from another type of vector\n    ///\n    /// This constructor doesn't replace the copy constructor,\n    /// it's called only when U != T.\n    /// A call to this constructor will fail to compile if U\n    /// is not convertible to T.\n    ///\n    /// \\param vector Vector to convert\n    ///\n    ////////////////////////////////////////////////////////////\n    template <typename U>\n    explicit Vector2(const Vector2<U>& vector);\n\n    ////////////////////////////////////////////////////////////\n    // Member data\n    ////////////////////////////////////////////////////////////\n    T x; ///< X coordinate of the vector\n    T y; ///< Y coordinate of the vector\n};\n\n////////////////////////////////////////////////////////////\n/// \\relates Vector2\n/// \\brief Overload of unary operator -\n///\n/// \\param right Vector to negate\n///\n/// \\return Memberwise opposite of the vector\n///\n////////////////////////////////////////////////////////////\ntemplate <typename T>\nVector2<T> operator -(const Vector2<T>& right);\n\n////////////////////////////////////////////////////////////\n/// \\relates Vector2\n/// \\brief Overload of binary operator +=\n///\n/// This operator performs a memberwise addition of both vectors,\n/// and assigns the result to \\a left.\n///\n/// \\param left  Left operand (a vector)\n/// \\param right Right operand (a vector)\n///\n/// \\return Reference to \\a left\n///\n////////////////////////////////////////////////////////////\ntemplate <typename T>\nVector2<T>& operator +=(Vector2<T>& left, const Vector2<T>& right);\n\n////////////////////////////////////////////////////////////\n/// \\relates Vector2\n/// \\brief Overload of binary operator -=\n///\n/// This operator performs a memberwise subtraction of both vectors,\n/// and assigns the result to \\a left.\n///\n/// \\param left  Left operand (a vector)\n/// \\param right Right operand (a vector)\n///\n/// \\return Reference to \\a left\n///\n////////////////////////////////////////////////////////////\ntemplate <typename T>\nVector2<T>& operator -=(Vector2<T>& left, const Vector2<T>& right);\n\n////////////////////////////////////////////////////////////\n/// \\relates Vector2\n/// \\brief Overload of binary operator +\n///\n/// \\param left  Left operand (a vector)\n/// \\param right Right operand (a vector)\n///\n/// \\return Memberwise addition of both vectors\n///\n////////////////////////////////////////////////////////////\ntemplate <typename T>\nVector2<T> operator +(const Vector2<T>& left, const Vector2<T>& right);\n\n////////////////////////////////////////////////////////////\n/// \\relates Vector2\n/// \\brief Overload of binary operator -\n///\n/// \\param left  Left operand (a vector)\n/// \\param right Right operand (a vector)\n///\n/// \\return Memberwise subtraction of both vectors\n///\n////////////////////////////////////////////////////////////\ntemplate <typename T>\nVector2<T> operator -(const Vector2<T>& left, const Vector2<T>& right);\n\n////////////////////////////////////////////////////////////\n/// \\relates Vector2\n/// \\brief Overload of binary operator *\n///\n/// \\param left  Left operand (a vector)\n/// \\param right Right operand (a scalar value)\n///\n/// \\return Memberwise multiplication by \\a right\n///\n////////////////////////////////////////////////////////////\ntemplate <typename T>\nVector2<T> operator *(const Vector2<T>& left, T right);\n\n////////////////////////////////////////////////////////////\n/// \\relates Vector2\n/// \\brief Overload of binary operator *\n///\n/// \\param left  Left operand (a scalar value)\n/// \\param right Right operand (a vector)\n///\n/// \\return Memberwise multiplication by \\a left\n///\n////////////////////////////////////////////////////////////\ntemplate <typename T>\nVector2<T> operator *(T left, const Vector2<T>& right);\n\n////////////////////////////////////////////////////////////\n/// \\relates Vector2\n/// \\brief Overload of binary operator *=\n///\n/// This operator performs a memberwise multiplication by \\a right,\n/// and assigns the result to \\a left.\n///\n/// \\param left  Left operand (a vector)\n/// \\param right Right operand (a scalar value)\n///\n/// \\return Reference to \\a left\n///\n////////////////////////////////////////////////////////////\ntemplate <typename T>\nVector2<T>& operator *=(Vector2<T>& left, T right);\n\n////////////////////////////////////////////////////////////\n/// \\relates Vector2\n/// \\brief Overload of binary operator /\n///\n/// \\param left  Left operand (a vector)\n/// \\param right Right operand (a scalar value)\n///\n/// \\return Memberwise division by \\a right\n///\n////////////////////////////////////////////////////////////\ntemplate <typename T>\nVector2<T> operator /(const Vector2<T>& left, T right);\n\n////////////////////////////////////////////////////////////\n/// \\relates Vector2\n/// \\brief Overload of binary operator /=\n///\n/// This operator performs a memberwise division by \\a right,\n/// and assigns the result to \\a left.\n///\n/// \\param left  Left operand (a vector)\n/// \\param right Right operand (a scalar value)\n///\n/// \\return Reference to \\a left\n///\n////////////////////////////////////////////////////////////\ntemplate <typename T>\nVector2<T>& operator /=(Vector2<T>& left, T right);\n\n////////////////////////////////////////////////////////////\n/// \\relates Vector2\n/// \\brief Overload of binary operator ==\n///\n/// This operator compares strict equality between two vectors.\n///\n/// \\param left  Left operand (a vector)\n/// \\param right Right operand (a vector)\n///\n/// \\return True if \\a left is equal to \\a right\n///\n////////////////////////////////////////////////////////////\ntemplate <typename T>\nbool operator ==(const Vector2<T>& left, const Vector2<T>& right);\n\n////////////////////////////////////////////////////////////\n/// \\relates Vector2\n/// \\brief Overload of binary operator !=\n///\n/// This operator compares strict difference between two vectors.\n///\n/// \\param left  Left operand (a vector)\n/// \\param right Right operand (a vector)\n///\n/// \\return True if \\a left is not equal to \\a right\n///\n////////////////////////////////////////////////////////////\ntemplate <typename T>\nbool operator !=(const Vector2<T>& left, const Vector2<T>& right);\n\n#include <SFML/System/Vector2.inl>\n\n// Define the most common types\ntypedef Vector2<int>          Vector2i;\ntypedef Vector2<unsigned int> Vector2u;\ntypedef Vector2<float>        Vector2f;\n\n} // namespace sf\n\n\n#endif // SFML_VECTOR2_HPP\n\n\n////////////////////////////////////////////////////////////\n/// \\class sf::Vector2\n/// \\ingroup system\n///\n/// sf::Vector2 is a simple class that defines a mathematical\n/// vector with two coordinates (x and y). It can be used to\n/// represent anything that has two dimensions: a size, a point,\n/// a velocity, etc.\n///\n/// The template parameter T is the type of the coordinates. It\n/// can be any type that supports arithmetic operations (+, -, /, *)\n/// and comparisons (==, !=), for example int or float.\n///\n/// You generally don't have to care about the templated form (sf::Vector2<T>),\n/// the most common specializations have special typedefs:\n/// \\li sf::Vector2<float> is sf::Vector2f\n/// \\li sf::Vector2<int> is sf::Vector2i\n/// \\li sf::Vector2<unsigned int> is sf::Vector2u\n///\n/// The sf::Vector2 class has a small and simple interface, its x and y members\n/// can be accessed directly (there are no accessors like setX(), getX()) and it\n/// contains no mathematical function like dot product, cross product, length, etc.\n///\n/// Usage example:\n/// \\code\n/// sf::Vector2f v1(16.5f, 24.f);\n/// v1.x = 18.2f;\n/// float y = v1.y;\n///\n/// sf::Vector2f v2 = v1 * 5.f;\n/// sf::Vector2f v3;\n/// v3 = v1 + v2;\n///\n/// bool different = (v2 != v3);\n/// \\endcode\n///\n/// Note: for 3-dimensional vectors, see sf::Vector3.\n///\n////////////////////////////////////////////////////////////\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/System/Vector2.inl",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n\n////////////////////////////////////////////////////////////\ntemplate <typename T>\ninline Vector2<T>::Vector2() :\nx(0),\ny(0)\n{\n\n}\n\n\n////////////////////////////////////////////////////////////\ntemplate <typename T>\ninline Vector2<T>::Vector2(T X, T Y) :\nx(X),\ny(Y)\n{\n\n}\n\n\n////////////////////////////////////////////////////////////\ntemplate <typename T>\ntemplate <typename U>\ninline Vector2<T>::Vector2(const Vector2<U>& vector) :\nx(static_cast<T>(vector.x)),\ny(static_cast<T>(vector.y))\n{\n}\n\n\n////////////////////////////////////////////////////////////\ntemplate <typename T>\ninline Vector2<T> operator -(const Vector2<T>& right)\n{\n    return Vector2<T>(-right.x, -right.y);\n}\n\n\n////////////////////////////////////////////////////////////\ntemplate <typename T>\ninline Vector2<T>& operator +=(Vector2<T>& left, const Vector2<T>& right)\n{\n    left.x += right.x;\n    left.y += right.y;\n\n    return left;\n}\n\n\n////////////////////////////////////////////////////////////\ntemplate <typename T>\ninline Vector2<T>& operator -=(Vector2<T>& left, const Vector2<T>& right)\n{\n    left.x -= right.x;\n    left.y -= right.y;\n\n    return left;\n}\n\n\n////////////////////////////////////////////////////////////\ntemplate <typename T>\ninline Vector2<T> operator +(const Vector2<T>& left, const Vector2<T>& right)\n{\n    return Vector2<T>(left.x + right.x, left.y + right.y);\n}\n\n\n////////////////////////////////////////////////////////////\ntemplate <typename T>\ninline Vector2<T> operator -(const Vector2<T>& left, const Vector2<T>& right)\n{\n    return Vector2<T>(left.x - right.x, left.y - right.y);\n}\n\n\n////////////////////////////////////////////////////////////\ntemplate <typename T>\ninline Vector2<T> operator *(const Vector2<T>& left, T right)\n{\n    return Vector2<T>(left.x * right, left.y * right);\n}\n\n\n////////////////////////////////////////////////////////////\ntemplate <typename T>\ninline Vector2<T> operator *(T left, const Vector2<T>& right)\n{\n    return Vector2<T>(right.x * left, right.y * left);\n}\n\n\n////////////////////////////////////////////////////////////\ntemplate <typename T>\ninline Vector2<T>& operator *=(Vector2<T>& left, T right)\n{\n    left.x *= right;\n    left.y *= right;\n\n    return left;\n}\n\n\n////////////////////////////////////////////////////////////\ntemplate <typename T>\ninline Vector2<T> operator /(const Vector2<T>& left, T right)\n{\n    return Vector2<T>(left.x / right, left.y / right);\n}\n\n\n////////////////////////////////////////////////////////////\ntemplate <typename T>\ninline Vector2<T>& operator /=(Vector2<T>& left, T right)\n{\n    left.x /= right;\n    left.y /= right;\n\n    return left;\n}\n\n\n////////////////////////////////////////////////////////////\ntemplate <typename T>\ninline bool operator ==(const Vector2<T>& left, const Vector2<T>& right)\n{\n    return (left.x == right.x) && (left.y == right.y);\n}\n\n\n////////////////////////////////////////////////////////////\ntemplate <typename T>\ninline bool operator !=(const Vector2<T>& left, const Vector2<T>& right)\n{\n    return (left.x != right.x) || (left.y != right.y);\n}\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/System/Vector3.hpp",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n#ifndef SFML_VECTOR3_HPP\n#define SFML_VECTOR3_HPP\n\n\nnamespace sf\n{\n////////////////////////////////////////////////////////////\n/// \\brief Utility template class for manipulating\n///        3-dimensional vectors\n///\n////////////////////////////////////////////////////////////\ntemplate <typename T>\nclass Vector3\n{\npublic:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Default constructor\n    ///\n    /// Creates a Vector3(0, 0, 0).\n    ///\n    ////////////////////////////////////////////////////////////\n    Vector3();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Construct the vector from its coordinates\n    ///\n    /// \\param X X coordinate\n    /// \\param Y Y coordinate\n    /// \\param Z Z coordinate\n    ///\n    ////////////////////////////////////////////////////////////\n    Vector3(T X, T Y, T Z);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Construct the vector from another type of vector\n    ///\n    /// This constructor doesn't replace the copy constructor,\n    /// it's called only when U != T.\n    /// A call to this constructor will fail to compile if U\n    /// is not convertible to T.\n    ///\n    /// \\param vector Vector to convert\n    ///\n    ////////////////////////////////////////////////////////////\n    template <typename U>\n    explicit Vector3(const Vector3<U>& vector);\n\n    ////////////////////////////////////////////////////////////\n    // Member data\n    ////////////////////////////////////////////////////////////\n    T x; ///< X coordinate of the vector\n    T y; ///< Y coordinate of the vector\n    T z; ///< Z coordinate of the vector\n};\n\n////////////////////////////////////////////////////////////\n/// \\relates Vector3\n/// \\brief Overload of unary operator -\n///\n/// \\param left Vector to negate\n///\n/// \\return Memberwise opposite of the vector\n///\n////////////////////////////////////////////////////////////\ntemplate <typename T>\nVector3<T> operator -(const Vector3<T>& left);\n\n////////////////////////////////////////////////////////////\n/// \\relates Vector3\n/// \\brief Overload of binary operator +=\n///\n/// This operator performs a memberwise addition of both vectors,\n/// and assigns the result to \\a left.\n///\n/// \\param left  Left operand (a vector)\n/// \\param right Right operand (a vector)\n///\n/// \\return Reference to \\a left\n///\n////////////////////////////////////////////////////////////\ntemplate <typename T>\nVector3<T>& operator +=(Vector3<T>& left, const Vector3<T>& right);\n\n////////////////////////////////////////////////////////////\n/// \\relates Vector3\n/// \\brief Overload of binary operator -=\n///\n/// This operator performs a memberwise subtraction of both vectors,\n/// and assigns the result to \\a left.\n///\n/// \\param left  Left operand (a vector)\n/// \\param right Right operand (a vector)\n///\n/// \\return Reference to \\a left\n///\n////////////////////////////////////////////////////////////\ntemplate <typename T>\nVector3<T>& operator -=(Vector3<T>& left, const Vector3<T>& right);\n\n////////////////////////////////////////////////////////////\n/// \\relates Vector3\n/// \\brief Overload of binary operator +\n///\n/// \\param left  Left operand (a vector)\n/// \\param right Right operand (a vector)\n///\n/// \\return Memberwise addition of both vectors\n///\n////////////////////////////////////////////////////////////\ntemplate <typename T>\nVector3<T> operator +(const Vector3<T>& left, const Vector3<T>& right);\n\n////////////////////////////////////////////////////////////\n/// \\relates Vector3\n/// \\brief Overload of binary operator -\n///\n/// \\param left  Left operand (a vector)\n/// \\param right Right operand (a vector)\n///\n/// \\return Memberwise subtraction of both vectors\n///\n////////////////////////////////////////////////////////////\ntemplate <typename T>\nVector3<T> operator -(const Vector3<T>& left, const Vector3<T>& right);\n\n////////////////////////////////////////////////////////////\n/// \\relates Vector3\n/// \\brief Overload of binary operator *\n///\n/// \\param left  Left operand (a vector)\n/// \\param right Right operand (a scalar value)\n///\n/// \\return Memberwise multiplication by \\a right\n///\n////////////////////////////////////////////////////////////\ntemplate <typename T>\nVector3<T> operator *(const Vector3<T>& left, T right);\n\n////////////////////////////////////////////////////////////\n/// \\relates Vector3\n/// \\brief Overload of binary operator *\n///\n/// \\param left  Left operand (a scalar value)\n/// \\param right Right operand (a vector)\n///\n/// \\return Memberwise multiplication by \\a left\n///\n////////////////////////////////////////////////////////////\ntemplate <typename T>\nVector3<T> operator *(T left, const Vector3<T>& right);\n\n////////////////////////////////////////////////////////////\n/// \\relates Vector3\n/// \\brief Overload of binary operator *=\n///\n/// This operator performs a memberwise multiplication by \\a right,\n/// and assigns the result to \\a left.\n///\n/// \\param left  Left operand (a vector)\n/// \\param right Right operand (a scalar value)\n///\n/// \\return Reference to \\a left\n///\n////////////////////////////////////////////////////////////\ntemplate <typename T>\nVector3<T>& operator *=(Vector3<T>& left, T right);\n\n////////////////////////////////////////////////////////////\n/// \\relates Vector3\n/// \\brief Overload of binary operator /\n///\n/// \\param left  Left operand (a vector)\n/// \\param right Right operand (a scalar value)\n///\n/// \\return Memberwise division by \\a right\n///\n////////////////////////////////////////////////////////////\ntemplate <typename T>\nVector3<T> operator /(const Vector3<T>& left, T right);\n\n////////////////////////////////////////////////////////////\n/// \\relates Vector3\n/// \\brief Overload of binary operator /=\n///\n/// This operator performs a memberwise division by \\a right,\n/// and assigns the result to \\a left.\n///\n/// \\param left  Left operand (a vector)\n/// \\param right Right operand (a scalar value)\n///\n/// \\return Reference to \\a left\n///\n////////////////////////////////////////////////////////////\ntemplate <typename T>\nVector3<T>& operator /=(Vector3<T>& left, T right);\n\n////////////////////////////////////////////////////////////\n/// \\relates Vector3\n/// \\brief Overload of binary operator ==\n///\n/// This operator compares strict equality between two vectors.\n///\n/// \\param left  Left operand (a vector)\n/// \\param right Right operand (a vector)\n///\n/// \\return True if \\a left is equal to \\a right\n///\n////////////////////////////////////////////////////////////\ntemplate <typename T>\nbool operator ==(const Vector3<T>& left, const Vector3<T>& right);\n\n////////////////////////////////////////////////////////////\n/// \\relates Vector3\n/// \\brief Overload of binary operator !=\n///\n/// This operator compares strict difference between two vectors.\n///\n/// \\param left  Left operand (a vector)\n/// \\param right Right operand (a vector)\n///\n/// \\return True if \\a left is not equal to \\a right\n///\n////////////////////////////////////////////////////////////\ntemplate <typename T>\nbool operator !=(const Vector3<T>& left, const Vector3<T>& right);\n\n#include <SFML/System/Vector3.inl>\n\n// Define the most common types\ntypedef Vector3<int>   Vector3i;\ntypedef Vector3<float> Vector3f;\n\n} // namespace sf\n\n\n#endif // SFML_VECTOR3_HPP\n\n\n////////////////////////////////////////////////////////////\n/// \\class sf::Vector3\n/// \\ingroup system\n///\n/// sf::Vector3 is a simple class that defines a mathematical\n/// vector with three coordinates (x, y and z). It can be used to\n/// represent anything that has three dimensions: a size, a point,\n/// a velocity, etc.\n///\n/// The template parameter T is the type of the coordinates. It\n/// can be any type that supports arithmetic operations (+, -, /, *)\n/// and comparisons (==, !=), for example int or float.\n///\n/// You generally don't have to care about the templated form (sf::Vector3<T>),\n/// the most common specializations have special typedefs:\n/// \\li sf::Vector3<float> is sf::Vector3f\n/// \\li sf::Vector3<int> is sf::Vector3i\n///\n/// The sf::Vector3 class has a small and simple interface, its x and y members\n/// can be accessed directly (there are no accessors like setX(), getX()) and it\n/// contains no mathematical function like dot product, cross product, length, etc.\n///\n/// Usage example:\n/// \\code\n/// sf::Vector3f v1(16.5f, 24.f, -8.2f);\n/// v1.x = 18.2f;\n/// float y = v1.y;\n/// float z = v1.z;\n///\n/// sf::Vector3f v2 = v1 * 5.f;\n/// sf::Vector3f v3;\n/// v3 = v1 + v2;\n///\n/// bool different = (v2 != v3);\n/// \\endcode\n///\n/// Note: for 2-dimensional vectors, see sf::Vector2.\n///\n////////////////////////////////////////////////////////////\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/System/Vector3.inl",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n\n////////////////////////////////////////////////////////////\ntemplate <typename T>\ninline Vector3<T>::Vector3() :\nx(0),\ny(0),\nz(0)\n{\n\n}\n\n\n////////////////////////////////////////////////////////////\ntemplate <typename T>\ninline Vector3<T>::Vector3(T X, T Y, T Z) :\nx(X),\ny(Y),\nz(Z)\n{\n\n}\n\n\n////////////////////////////////////////////////////////////\ntemplate <typename T>\ntemplate <typename U>\ninline Vector3<T>::Vector3(const Vector3<U>& vector) :\nx(static_cast<T>(vector.x)),\ny(static_cast<T>(vector.y)),\nz(static_cast<T>(vector.z))\n{\n}\n\n\n////////////////////////////////////////////////////////////\ntemplate <typename T>\ninline Vector3<T> operator -(const Vector3<T>& left)\n{\n    return Vector3<T>(-left.x, -left.y, -left.z);\n}\n\n\n////////////////////////////////////////////////////////////\ntemplate <typename T>\ninline Vector3<T>& operator +=(Vector3<T>& left, const Vector3<T>& right)\n{\n    left.x += right.x;\n    left.y += right.y;\n    left.z += right.z;\n\n    return left;\n}\n\n\n////////////////////////////////////////////////////////////\ntemplate <typename T>\ninline Vector3<T>& operator -=(Vector3<T>& left, const Vector3<T>& right)\n{\n    left.x -= right.x;\n    left.y -= right.y;\n    left.z -= right.z;\n\n    return left;\n}\n\n\n////////////////////////////////////////////////////////////\ntemplate <typename T>\ninline Vector3<T> operator +(const Vector3<T>& left, const Vector3<T>& right)\n{\n    return Vector3<T>(left.x + right.x, left.y + right.y, left.z + right.z);\n}\n\n\n////////////////////////////////////////////////////////////\ntemplate <typename T>\ninline Vector3<T> operator -(const Vector3<T>& left, const Vector3<T>& right)\n{\n    return Vector3<T>(left.x - right.x, left.y - right.y, left.z - right.z);\n}\n\n\n////////////////////////////////////////////////////////////\ntemplate <typename T>\ninline Vector3<T> operator *(const Vector3<T>& left, T right)\n{\n    return Vector3<T>(left.x * right, left.y * right, left.z * right);\n}\n\n\n////////////////////////////////////////////////////////////\ntemplate <typename T>\ninline Vector3<T> operator *(T left, const Vector3<T>& right)\n{\n    return Vector3<T>(right.x * left, right.y * left, right.z * left);\n}\n\n\n////////////////////////////////////////////////////////////\ntemplate <typename T>\ninline Vector3<T>& operator *=(Vector3<T>& left, T right)\n{\n    left.x *= right;\n    left.y *= right;\n    left.z *= right;\n\n    return left;\n}\n\n\n////////////////////////////////////////////////////////////\ntemplate <typename T>\ninline Vector3<T> operator /(const Vector3<T>& left, T right)\n{\n    return Vector3<T>(left.x / right, left.y / right, left.z / right);\n}\n\n\n////////////////////////////////////////////////////////////\ntemplate <typename T>\ninline Vector3<T>& operator /=(Vector3<T>& left, T right)\n{\n    left.x /= right;\n    left.y /= right;\n    left.z /= right;\n\n    return left;\n}\n\n\n////////////////////////////////////////////////////////////\ntemplate <typename T>\ninline bool operator ==(const Vector3<T>& left, const Vector3<T>& right)\n{\n    return (left.x == right.x) && (left.y == right.y) && (left.z == right.z);\n}\n\n\n////////////////////////////////////////////////////////////\ntemplate <typename T>\ninline bool operator !=(const Vector3<T>& left, const Vector3<T>& right)\n{\n    return (left.x != right.x) || (left.y != right.y) || (left.z != right.z);\n}\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/System.hpp",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n#ifndef SFML_SYSTEM_HPP\n#define SFML_SYSTEM_HPP\n\n////////////////////////////////////////////////////////////\n// Headers\n////////////////////////////////////////////////////////////\n\n#include <SFML/Config.hpp>\n#include <SFML/System/Clock.hpp>\n#include <SFML/System/Err.hpp>\n#include <SFML/System/FileInputStream.hpp>\n#include <SFML/System/InputStream.hpp>\n#include <SFML/System/Lock.hpp>\n#include <SFML/System/MemoryInputStream.hpp>\n#include <SFML/System/Mutex.hpp>\n#include <SFML/System/NonCopyable.hpp>\n#include <SFML/System/Sleep.hpp>\n#include <SFML/System/String.hpp>\n#include <SFML/System/Thread.hpp>\n#include <SFML/System/ThreadLocal.hpp>\n#include <SFML/System/ThreadLocalPtr.hpp>\n#include <SFML/System/Time.hpp>\n#include <SFML/System/Utf.hpp>\n#include <SFML/System/Vector2.hpp>\n#include <SFML/System/Vector3.hpp>\n\n#endif // SFML_SYSTEM_HPP\n\n////////////////////////////////////////////////////////////\n/// \\defgroup system System module\n///\n/// Base module of SFML, defining various utilities. It provides\n/// vector classes, Unicode strings and conversion functions,\n/// threads and mutexes, timing classes.\n///\n////////////////////////////////////////////////////////////\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/Window/Context.hpp",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n#ifndef SFML_CONTEXT_HPP\n#define SFML_CONTEXT_HPP\n\n////////////////////////////////////////////////////////////\n// Headers\n////////////////////////////////////////////////////////////\n#include <SFML/Window/Export.hpp>\n#include <SFML/Window/GlResource.hpp>\n#include <SFML/Window/ContextSettings.hpp>\n#include <SFML/System/NonCopyable.hpp>\n\n\nnamespace sf\n{\nnamespace priv\n{\n    class GlContext;\n}\n\ntypedef void (*GlFunctionPointer)();\n\n////////////////////////////////////////////////////////////\n/// \\brief Class holding a valid drawing context\n///\n////////////////////////////////////////////////////////////\nclass SFML_WINDOW_API Context : GlResource, NonCopyable\n{\npublic:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Default constructor\n    ///\n    /// The constructor creates and activates the context\n    ///\n    ////////////////////////////////////////////////////////////\n    Context();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Destructor\n    ///\n    /// The destructor deactivates and destroys the context\n    ///\n    ////////////////////////////////////////////////////////////\n    ~Context();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Activate or deactivate explicitly the context\n    ///\n    /// \\param active True to activate, false to deactivate\n    ///\n    /// \\return True on success, false on failure\n    ///\n    ////////////////////////////////////////////////////////////\n    bool setActive(bool active);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the settings of the context\n    ///\n    /// Note that these settings may be different than the ones\n    /// passed to the constructor; they are indeed adjusted if the\n    /// original settings are not directly supported by the system.\n    ///\n    /// \\return Structure containing the settings\n    ///\n    ////////////////////////////////////////////////////////////\n    const ContextSettings& getSettings() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Check whether a given OpenGL extension is available\n    ///\n    /// \\param name Name of the extension to check for\n    ///\n    /// \\return True if available, false if unavailable\n    ///\n    ////////////////////////////////////////////////////////////\n    static bool isExtensionAvailable(const char* name);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the address of an OpenGL function\n    ///\n    /// \\param name Name of the function to get the address of\n    ///\n    /// \\return Address of the OpenGL function, 0 on failure\n    ///\n    ////////////////////////////////////////////////////////////\n    static GlFunctionPointer getFunction(const char* name);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the currently active context\n    ///\n    /// \\return The currently active context or NULL if none is active\n    ///\n    ////////////////////////////////////////////////////////////\n    static const Context* getActiveContext();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Construct a in-memory context\n    ///\n    /// This constructor is for internal use, you don't need\n    /// to bother with it.\n    ///\n    /// \\param settings Creation parameters\n    /// \\param width    Back buffer width\n    /// \\param height   Back buffer height\n    ///\n    ////////////////////////////////////////////////////////////\n    Context(const ContextSettings& settings, unsigned int width, unsigned int height);\n\nprivate:\n\n    ////////////////////////////////////////////////////////////\n    // Member data\n    ////////////////////////////////////////////////////////////\n    priv::GlContext* m_context; ///< Internal OpenGL context\n};\n\n} // namespace sf\n\n\n#endif // SFML_CONTEXT_HPP\n\n////////////////////////////////////////////////////////////\n/// \\class sf::Context\n/// \\ingroup window\n///\n/// If you need to make OpenGL calls without having an\n/// active window (like in a thread), you can use an\n/// instance of this class to get a valid context.\n///\n/// Having a valid context is necessary for *every* OpenGL call.\n///\n/// Note that a context is only active in its current thread,\n/// if you create a new thread it will have no valid context\n/// by default.\n///\n/// To use a sf::Context instance, just construct it and let it\n/// live as long as you need a valid context. No explicit activation\n/// is needed, all it has to do is to exist. Its destructor\n/// will take care of deactivating and freeing all the attached\n/// resources.\n///\n/// Usage example:\n/// \\code\n/// void threadFunction(void*)\n/// {\n///    sf::Context context;\n///    // from now on, you have a valid context\n///\n///    // you can make OpenGL calls\n///    glClear(GL_DEPTH_BUFFER_BIT);\n/// }\n/// // the context is automatically deactivated and destroyed\n/// // by the sf::Context destructor\n/// \\endcode\n///\n////////////////////////////////////////////////////////////\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/Window/ContextSettings.hpp",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n#ifndef SFML_CONTEXTSETTINGS_HPP\n#define SFML_CONTEXTSETTINGS_HPP\n\n\nnamespace sf\n{\n////////////////////////////////////////////////////////////\n/// \\brief Structure defining the settings of the OpenGL\n///        context attached to a window\n///\n////////////////////////////////////////////////////////////\nstruct ContextSettings\n{\n    ////////////////////////////////////////////////////////////\n    /// \\brief Enumeration of the context attribute flags\n    ///\n    ////////////////////////////////////////////////////////////\n    enum Attribute\n    {\n        Default = 0,      ///< Non-debug, compatibility context (this and the core attribute are mutually exclusive)\n        Core    = 1 << 0, ///< Core attribute\n        Debug   = 1 << 2  ///< Debug attribute\n    };\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Default constructor\n    ///\n    /// \\param depth        Depth buffer bits\n    /// \\param stencil      Stencil buffer bits\n    /// \\param antialiasing Antialiasing level\n    /// \\param major        Major number of the context version\n    /// \\param minor        Minor number of the context version\n    /// \\param attributes   Attribute flags of the context\n    /// \\param sRgb         sRGB capable framebuffer\n    ///\n    ////////////////////////////////////////////////////////////\n    explicit ContextSettings(unsigned int depth = 0, unsigned int stencil = 0, unsigned int antialiasing = 0, unsigned int major = 1, unsigned int minor = 1, unsigned int attributes = Default, bool sRgb = false) :\n    depthBits        (depth),\n    stencilBits      (stencil),\n    antialiasingLevel(antialiasing),\n    majorVersion     (major),\n    minorVersion     (minor),\n    attributeFlags   (attributes),\n    sRgbCapable      (sRgb)\n    {\n    }\n\n    ////////////////////////////////////////////////////////////\n    // Member data\n    ////////////////////////////////////////////////////////////\n    unsigned int depthBits;         ///< Bits of the depth buffer\n    unsigned int stencilBits;       ///< Bits of the stencil buffer\n    unsigned int antialiasingLevel; ///< Level of antialiasing\n    unsigned int majorVersion;      ///< Major number of the context version to create\n    unsigned int minorVersion;      ///< Minor number of the context version to create\n    Uint32       attributeFlags;    ///< The attribute flags to create the context with\n    bool         sRgbCapable;       ///< Whether the context framebuffer is sRGB capable\n};\n\n} // namespace sf\n\n\n#endif // SFML_CONTEXTSETTINGS_HPP\n\n\n////////////////////////////////////////////////////////////\n/// \\class sf::ContextSettings\n/// \\ingroup window\n///\n/// ContextSettings allows to define several advanced settings\n/// of the OpenGL context attached to a window. All these\n/// settings with the exception of the compatibility flag\n/// and anti-aliasing level have no impact on the regular\n/// SFML rendering (graphics module), so you may need to use\n/// this structure only if you're using SFML as a windowing\n/// system for custom OpenGL rendering.\n///\n/// The depthBits and stencilBits members define the number\n/// of bits per pixel requested for the (respectively) depth\n/// and stencil buffers.\n///\n/// antialiasingLevel represents the requested number of\n/// multisampling levels for anti-aliasing.\n///\n/// majorVersion and minorVersion define the version of the\n/// OpenGL context that you want. Only versions greater or\n/// equal to 3.0 are relevant; versions lesser than 3.0 are\n/// all handled the same way (i.e. you can use any version\n/// < 3.0 if you don't want an OpenGL 3 context).\n///\n/// When requesting a context with a version greater or equal\n/// to 3.2, you have the option of specifying whether the\n/// context should follow the core or compatibility profile\n/// of all newer (>= 3.2) OpenGL specifications. For versions\n/// 3.0 and 3.1 there is only the core profile. By default\n/// a compatibility context is created. You only need to specify\n/// the core flag if you want a core profile context to use with\n/// your own OpenGL rendering.\n/// <b>Warning: The graphics module will not function if you\n/// request a core profile context. Make sure the attributes are\n/// set to Default if you want to use the graphics module.</b>\n///\n/// Setting the debug attribute flag will request a context with\n/// additional debugging features enabled. Depending on the\n/// system, this might be required for advanced OpenGL debugging.\n/// OpenGL debugging is disabled by default.\n///\n/// <b>Special Note for OS X:</b>\n/// Apple only supports choosing between either a legacy context\n/// (OpenGL 2.1) or a core context (OpenGL version depends on the\n/// operating system version but is at least 3.2). Compatibility\n/// contexts are not supported. Further information is available on the\n/// <a href=\"https://developer.apple.com/opengl/capabilities/index.html\">\n/// OpenGL Capabilities Tables</a> page. OS X also currently does\n/// not support debug contexts.\n///\n/// Please note that these values are only a hint.\n/// No failure will be reported if one or more of these values\n/// are not supported by the system; instead, SFML will try to\n/// find the closest valid match. You can then retrieve the\n/// settings that the window actually used to create its context,\n/// with Window::getSettings().\n///\n////////////////////////////////////////////////////////////\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/Window/Event.hpp",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n#ifndef SFML_EVENT_HPP\n#define SFML_EVENT_HPP\n\n////////////////////////////////////////////////////////////\n// Headers\n////////////////////////////////////////////////////////////\n#include <SFML/Config.hpp>\n#include <SFML/Window/Joystick.hpp>\n#include <SFML/Window/Keyboard.hpp>\n#include <SFML/Window/Mouse.hpp>\n#include <SFML/Window/Sensor.hpp>\n\n\nnamespace sf\n{\n////////////////////////////////////////////////////////////\n/// \\brief Defines a system event and its parameters\n///\n////////////////////////////////////////////////////////////\nclass Event\n{\npublic:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Size events parameters (Resized)\n    ///\n    ////////////////////////////////////////////////////////////\n    struct SizeEvent\n    {\n        unsigned int width;  ///< New width, in pixels\n        unsigned int height; ///< New height, in pixels\n    };\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Keyboard event parameters (KeyPressed, KeyReleased)\n    ///\n    ////////////////////////////////////////////////////////////\n    struct KeyEvent\n    {\n        Keyboard::Key code;    ///< Code of the key that has been pressed\n        bool          alt;     ///< Is the Alt key pressed?\n        bool          control; ///< Is the Control key pressed?\n        bool          shift;   ///< Is the Shift key pressed?\n        bool          system;  ///< Is the System key pressed?\n    };\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Text event parameters (TextEntered)\n    ///\n    ////////////////////////////////////////////////////////////\n    struct TextEvent\n    {\n        Uint32 unicode; ///< UTF-32 Unicode value of the character\n    };\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Mouse move event parameters (MouseMoved)\n    ///\n    ////////////////////////////////////////////////////////////\n    struct MouseMoveEvent\n    {\n        int x; ///< X position of the mouse pointer, relative to the left of the owner window\n        int y; ///< Y position of the mouse pointer, relative to the top of the owner window\n    };\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Mouse buttons events parameters\n    ///        (MouseButtonPressed, MouseButtonReleased)\n    ///\n    ////////////////////////////////////////////////////////////\n    struct MouseButtonEvent\n    {\n        Mouse::Button button; ///< Code of the button that has been pressed\n        int           x;      ///< X position of the mouse pointer, relative to the left of the owner window\n        int           y;      ///< Y position of the mouse pointer, relative to the top of the owner window\n    };\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Mouse wheel events parameters (MouseWheelMoved)\n    ///\n    /// \\deprecated This event is deprecated and potentially inaccurate.\n    ///             Use MouseWheelScrollEvent instead.\n    ///\n    ////////////////////////////////////////////////////////////\n    struct MouseWheelEvent\n    {\n        int delta; ///< Number of ticks the wheel has moved (positive is up, negative is down)\n        int x;     ///< X position of the mouse pointer, relative to the left of the owner window\n        int y;     ///< Y position of the mouse pointer, relative to the top of the owner window\n    };\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Mouse wheel events parameters (MouseWheelScrolled)\n    ///\n    ////////////////////////////////////////////////////////////\n    struct MouseWheelScrollEvent\n    {\n        Mouse::Wheel wheel; ///< Which wheel (for mice with multiple ones)\n        float        delta; ///< Wheel offset (positive is up/left, negative is down/right). High-precision mice may use non-integral offsets.\n        int          x;     ///< X position of the mouse pointer, relative to the left of the owner window\n        int          y;     ///< Y position of the mouse pointer, relative to the top of the owner window\n    };\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Joystick connection events parameters\n    ///        (JoystickConnected, JoystickDisconnected)\n    ///\n    ////////////////////////////////////////////////////////////\n    struct JoystickConnectEvent\n    {\n        unsigned int joystickId; ///< Index of the joystick (in range [0 .. Joystick::Count - 1])\n    };\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Joystick axis move event parameters (JoystickMoved)\n    ///\n    ////////////////////////////////////////////////////////////\n    struct JoystickMoveEvent\n    {\n        unsigned int   joystickId; ///< Index of the joystick (in range [0 .. Joystick::Count - 1])\n        Joystick::Axis axis;       ///< Axis on which the joystick moved\n        float          position;   ///< New position on the axis (in range [-100 .. 100])\n    };\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Joystick buttons events parameters\n    ///        (JoystickButtonPressed, JoystickButtonReleased)\n    ///\n    ////////////////////////////////////////////////////////////\n    struct JoystickButtonEvent\n    {\n        unsigned int joystickId; ///< Index of the joystick (in range [0 .. Joystick::Count - 1])\n        unsigned int button;     ///< Index of the button that has been pressed (in range [0 .. Joystick::ButtonCount - 1])\n    };\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Touch events parameters (TouchBegan, TouchMoved, TouchEnded)\n    ///\n    ////////////////////////////////////////////////////////////\n    struct TouchEvent\n    {\n        unsigned int finger; ///< Index of the finger in case of multi-touch events\n        int x;               ///< X position of the touch, relative to the left of the owner window\n        int y;               ///< Y position of the touch, relative to the top of the owner window\n    };\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Sensor event parameters (SensorChanged)\n    ///\n    ////////////////////////////////////////////////////////////\n    struct SensorEvent\n    {\n        Sensor::Type type; ///< Type of the sensor\n        float x;           ///< Current value of the sensor on X axis\n        float y;           ///< Current value of the sensor on Y axis\n        float z;           ///< Current value of the sensor on Z axis\n    };\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Enumeration of the different types of events\n    ///\n    ////////////////////////////////////////////////////////////\n    enum EventType\n    {\n        Closed,                 ///< The window requested to be closed (no data)\n        Resized,                ///< The window was resized (data in event.size)\n        LostFocus,              ///< The window lost the focus (no data)\n        GainedFocus,            ///< The window gained the focus (no data)\n        TextEntered,            ///< A character was entered (data in event.text)\n        KeyPressed,             ///< A key was pressed (data in event.key)\n        KeyReleased,            ///< A key was released (data in event.key)\n        MouseWheelMoved,        ///< The mouse wheel was scrolled (data in event.mouseWheel) (deprecated)\n        MouseWheelScrolled,     ///< The mouse wheel was scrolled (data in event.mouseWheelScroll)\n        MouseButtonPressed,     ///< A mouse button was pressed (data in event.mouseButton)\n        MouseButtonReleased,    ///< A mouse button was released (data in event.mouseButton)\n        MouseMoved,             ///< The mouse cursor moved (data in event.mouseMove)\n        MouseEntered,           ///< The mouse cursor entered the area of the window (no data)\n        MouseLeft,              ///< The mouse cursor left the area of the window (no data)\n        JoystickButtonPressed,  ///< A joystick button was pressed (data in event.joystickButton)\n        JoystickButtonReleased, ///< A joystick button was released (data in event.joystickButton)\n        JoystickMoved,          ///< The joystick moved along an axis (data in event.joystickMove)\n        JoystickConnected,      ///< A joystick was connected (data in event.joystickConnect)\n        JoystickDisconnected,   ///< A joystick was disconnected (data in event.joystickConnect)\n        TouchBegan,             ///< A touch event began (data in event.touch)\n        TouchMoved,             ///< A touch moved (data in event.touch)\n        TouchEnded,             ///< A touch event ended (data in event.touch)\n        SensorChanged,          ///< A sensor value changed (data in event.sensor)\n\n        Count                   ///< Keep last -- the total number of event types\n    };\n\n    ////////////////////////////////////////////////////////////\n    // Member data\n    ////////////////////////////////////////////////////////////\n    EventType type; ///< Type of the event\n\n    union\n    {\n        SizeEvent             size;              ///< Size event parameters (Event::Resized)\n        KeyEvent              key;               ///< Key event parameters (Event::KeyPressed, Event::KeyReleased)\n        TextEvent             text;              ///< Text event parameters (Event::TextEntered)\n        MouseMoveEvent        mouseMove;         ///< Mouse move event parameters (Event::MouseMoved)\n        MouseButtonEvent      mouseButton;       ///< Mouse button event parameters (Event::MouseButtonPressed, Event::MouseButtonReleased)\n        MouseWheelEvent       mouseWheel;        ///< Mouse wheel event parameters (Event::MouseWheelMoved) (deprecated)\n        MouseWheelScrollEvent mouseWheelScroll;  ///< Mouse wheel event parameters (Event::MouseWheelScrolled)\n        JoystickMoveEvent     joystickMove;      ///< Joystick move event parameters (Event::JoystickMoved)\n        JoystickButtonEvent   joystickButton;    ///< Joystick button event parameters (Event::JoystickButtonPressed, Event::JoystickButtonReleased)\n        JoystickConnectEvent  joystickConnect;   ///< Joystick (dis)connect event parameters (Event::JoystickConnected, Event::JoystickDisconnected)\n        TouchEvent            touch;             ///< Touch events parameters (Event::TouchBegan, Event::TouchMoved, Event::TouchEnded)\n        SensorEvent           sensor;            ///< Sensor event parameters (Event::SensorChanged)\n    };\n};\n\n} // namespace sf\n\n\n#endif // SFML_EVENT_HPP\n\n\n////////////////////////////////////////////////////////////\n/// \\class sf::Event\n/// \\ingroup window\n///\n/// sf::Event holds all the informations about a system event\n/// that just happened. Events are retrieved using the\n/// sf::Window::pollEvent and sf::Window::waitEvent functions.\n///\n/// A sf::Event instance contains the type of the event\n/// (mouse moved, key pressed, window closed, ...) as well\n/// as the details about this particular event. Please note that\n/// the event parameters are defined in a union, which means that\n/// only the member matching the type of the event will be properly\n/// filled; all other members will have undefined values and must not\n/// be read if the type of the event doesn't match. For example,\n/// if you received a KeyPressed event, then you must read the\n/// event.key member, all other members such as event.MouseMove\n/// or event.text will have undefined values.\n///\n/// Usage example:\n/// \\code\n/// sf::Event event;\n/// while (window.pollEvent(event))\n/// {\n///     // Request for closing the window\n///     if (event.type == sf::Event::Closed)\n///         window.close();\n///\n///     // The escape key was pressed\n///     if ((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Escape))\n///         window.close();\n///\n///     // The window was resized\n///     if (event.type == sf::Event::Resized)\n///         doSomethingWithTheNewSize(event.size.width, event.size.height);\n///\n///     // etc ...\n/// }\n/// \\endcode\n///\n////////////////////////////////////////////////////////////\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/Window/Export.hpp",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n#ifndef SFML_WINDOW_EXPORT_HPP\n#define SFML_WINDOW_EXPORT_HPP\n\n////////////////////////////////////////////////////////////\n// Headers\n////////////////////////////////////////////////////////////\n#include <SFML/Config.hpp>\n\n\n////////////////////////////////////////////////////////////\n// Define portable import / export macros\n////////////////////////////////////////////////////////////\n#if defined(SFML_WINDOW_EXPORTS)\n\n    #define SFML_WINDOW_API SFML_API_EXPORT\n\n#else\n\n    #define SFML_WINDOW_API SFML_API_IMPORT\n\n#endif\n\n\n#endif // SFML_WINDOW_EXPORT_HPP\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/Window/GlResource.hpp",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n#ifndef SFML_GLRESOURCE_HPP\n#define SFML_GLRESOURCE_HPP\n\n////////////////////////////////////////////////////////////\n// Headers\n////////////////////////////////////////////////////////////\n#include <SFML/Window/Export.hpp>\n#include <SFML/System/NonCopyable.hpp>\n\n\nnamespace sf\n{\n\nclass Context;\n\n////////////////////////////////////////////////////////////\n/// \\brief Base class for classes that require an OpenGL context\n///\n////////////////////////////////////////////////////////////\nclass SFML_WINDOW_API GlResource\n{\nprotected:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Default constructor\n    ///\n    ////////////////////////////////////////////////////////////\n    GlResource();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Destructor\n    ///\n    ////////////////////////////////////////////////////////////\n    ~GlResource();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Empty function for ABI compatibility, use acquireTransientContext instead\n    ///\n    ////////////////////////////////////////////////////////////\n    static void ensureGlContext();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief RAII helper class to temporarily lock an available context for use\n    ///\n    ////////////////////////////////////////////////////////////\n    class SFML_WINDOW_API TransientContextLock : NonCopyable\n    {\n    public:\n        ////////////////////////////////////////////////////////////\n        /// \\brief Default constructor\n        ///\n        ////////////////////////////////////////////////////////////\n        TransientContextLock();\n\n        ////////////////////////////////////////////////////////////\n        /// \\brief Destructor\n        ///\n        ////////////////////////////////////////////////////////////\n        ~TransientContextLock();\n\n    private:\n        Context* m_context; ///< Temporary context, in case we needed to create one\n    };\n};\n\n} // namespace sf\n\n\n#endif // SFML_GLRESOURCE_HPP\n\n////////////////////////////////////////////////////////////\n/// \\class sf::GlResource\n/// \\ingroup window\n///\n/// This class is for internal use only, it must be the base\n/// of every class that requires a valid OpenGL context in\n/// order to work.\n///\n////////////////////////////////////////////////////////////\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/Window/Joystick.hpp",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n#ifndef SFML_JOYSTICK_HPP\n#define SFML_JOYSTICK_HPP\n\n////////////////////////////////////////////////////////////\n// Headers\n////////////////////////////////////////////////////////////\n#include <SFML/Window/Export.hpp>\n#include <SFML/System/String.hpp>\n\n\nnamespace sf\n{\n////////////////////////////////////////////////////////////\n/// \\brief Give access to the real-time state of the joysticks\n///\n////////////////////////////////////////////////////////////\nclass SFML_WINDOW_API Joystick\n{\npublic:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Constants related to joysticks capabilities\n    ///\n    ////////////////////////////////////////////////////////////\n    enum\n    {\n        Count       = 8,  ///< Maximum number of supported joysticks\n        ButtonCount = 32, ///< Maximum number of supported buttons\n        AxisCount   = 8   ///< Maximum number of supported axes\n    };\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Axes supported by SFML joysticks\n    ///\n    ////////////////////////////////////////////////////////////\n    enum Axis\n    {\n        X,    ///< The X axis\n        Y,    ///< The Y axis\n        Z,    ///< The Z axis\n        R,    ///< The R axis\n        U,    ///< The U axis\n        V,    ///< The V axis\n        PovX, ///< The X axis of the point-of-view hat\n        PovY  ///< The Y axis of the point-of-view hat\n    };\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Structure holding a joystick's identification\n    ///\n    ////////////////////////////////////////////////////////////\n    struct SFML_WINDOW_API Identification\n    {\n        Identification();\n\n        String       name;      ///< Name of the joystick\n        unsigned int vendorId;  ///< Manufacturer identifier\n        unsigned int productId; ///< Product identifier\n    };\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Check if a joystick is connected\n    ///\n    /// \\param joystick Index of the joystick to check\n    ///\n    /// \\return True if the joystick is connected, false otherwise\n    ///\n    ////////////////////////////////////////////////////////////\n    static bool isConnected(unsigned int joystick);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Return the number of buttons supported by a joystick\n    ///\n    /// If the joystick is not connected, this function returns 0.\n    ///\n    /// \\param joystick Index of the joystick\n    ///\n    /// \\return Number of buttons supported by the joystick\n    ///\n    ////////////////////////////////////////////////////////////\n    static unsigned int getButtonCount(unsigned int joystick);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Check if a joystick supports a given axis\n    ///\n    /// If the joystick is not connected, this function returns false.\n    ///\n    /// \\param joystick Index of the joystick\n    /// \\param axis     Axis to check\n    ///\n    /// \\return True if the joystick supports the axis, false otherwise\n    ///\n    ////////////////////////////////////////////////////////////\n    static bool hasAxis(unsigned int joystick, Axis axis);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Check if a joystick button is pressed\n    ///\n    /// If the joystick is not connected, this function returns false.\n    ///\n    /// \\param joystick Index of the joystick\n    /// \\param button   Button to check\n    ///\n    /// \\return True if the button is pressed, false otherwise\n    ///\n    ////////////////////////////////////////////////////////////\n    static bool isButtonPressed(unsigned int joystick, unsigned int button);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the current position of a joystick axis\n    ///\n    /// If the joystick is not connected, this function returns 0.\n    ///\n    /// \\param joystick Index of the joystick\n    /// \\param axis     Axis to check\n    ///\n    /// \\return Current position of the axis, in range [-100 .. 100]\n    ///\n    ////////////////////////////////////////////////////////////\n    static float getAxisPosition(unsigned int joystick, Axis axis);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the joystick information\n    ///\n    /// \\param joystick Index of the joystick\n    ///\n    /// \\return Structure containing joystick information.\n    ///\n    ////////////////////////////////////////////////////////////\n    static Identification getIdentification(unsigned int joystick);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Update the states of all joysticks\n    ///\n    /// This function is used internally by SFML, so you normally\n    /// don't have to call it explicitly. However, you may need to\n    /// call it if you have no window yet (or no window at all):\n    /// in this case the joystick states are not updated automatically.\n    ///\n    ////////////////////////////////////////////////////////////\n    static void update();\n};\n\n} // namespace sf\n\n\n#endif // SFML_JOYSTICK_HPP\n\n\n////////////////////////////////////////////////////////////\n/// \\class sf::Joystick\n/// \\ingroup window\n///\n/// sf::Joystick provides an interface to the state of the\n/// joysticks. It only contains static functions, so it's not\n/// meant to be instantiated. Instead, each joystick is identified\n/// by an index that is passed to the functions of this class.\n///\n/// This class allows users to query the state of joysticks at any\n/// time and directly, without having to deal with a window and\n/// its events. Compared to the JoystickMoved, JoystickButtonPressed\n/// and JoystickButtonReleased events, sf::Joystick can retrieve the\n/// state of axes and buttons of joysticks at any time\n/// (you don't need to store and update a boolean on your side\n/// in order to know if a button is pressed or released), and you\n/// always get the real state of joysticks, even if they are\n/// moved, pressed or released when your window is out of focus\n/// and no event is triggered.\n///\n/// SFML supports:\n/// \\li 8 joysticks (sf::Joystick::Count)\n/// \\li 32 buttons per joystick (sf::Joystick::ButtonCount)\n/// \\li 8 axes per joystick (sf::Joystick::AxisCount)\n///\n/// Unlike the keyboard or mouse, the state of joysticks is sometimes\n/// not directly available (depending on the OS), therefore an update()\n/// function must be called in order to update the current state of\n/// joysticks. When you have a window with event handling, this is done\n/// automatically, you don't need to call anything. But if you have no\n/// window, or if you want to check joysticks state before creating one,\n/// you must call sf::Joystick::update explicitly.\n///\n/// Usage example:\n/// \\code\n/// // Is joystick #0 connected?\n/// bool connected = sf::Joystick::isConnected(0);\n///\n/// // How many buttons does joystick #0 support?\n/// unsigned int buttons = sf::Joystick::getButtonCount(0);\n///\n/// // Does joystick #0 define a X axis?\n/// bool hasX = sf::Joystick::hasAxis(0, sf::Joystick::X);\n///\n/// // Is button #2 pressed on joystick #0?\n/// bool pressed = sf::Joystick::isButtonPressed(0, 2);\n///\n/// // What's the current position of the Y axis on joystick #0?\n/// float position = sf::Joystick::getAxisPosition(0, sf::Joystick::Y);\n/// \\endcode\n///\n/// \\see sf::Keyboard, sf::Mouse\n///\n////////////////////////////////////////////////////////////\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/Window/Keyboard.hpp",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n#ifndef SFML_KEYBOARD_HPP\n#define SFML_KEYBOARD_HPP\n\n////////////////////////////////////////////////////////////\n// Headers\n////////////////////////////////////////////////////////////\n#include <SFML/Window/Export.hpp>\n\n\nnamespace sf\n{\n////////////////////////////////////////////////////////////\n/// \\brief Give access to the real-time state of the keyboard\n///\n////////////////////////////////////////////////////////////\nclass SFML_WINDOW_API Keyboard\n{\npublic:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Key codes\n    ///\n    ////////////////////////////////////////////////////////////\n    enum Key\n    {\n        Unknown = -1, ///< Unhandled key\n        A = 0,        ///< The A key\n        B,            ///< The B key\n        C,            ///< The C key\n        D,            ///< The D key\n        E,            ///< The E key\n        F,            ///< The F key\n        G,            ///< The G key\n        H,            ///< The H key\n        I,            ///< The I key\n        J,            ///< The J key\n        K,            ///< The K key\n        L,            ///< The L key\n        M,            ///< The M key\n        N,            ///< The N key\n        O,            ///< The O key\n        P,            ///< The P key\n        Q,            ///< The Q key\n        R,            ///< The R key\n        S,            ///< The S key\n        T,            ///< The T key\n        U,            ///< The U key\n        V,            ///< The V key\n        W,            ///< The W key\n        X,            ///< The X key\n        Y,            ///< The Y key\n        Z,            ///< The Z key\n        Num0,         ///< The 0 key\n        Num1,         ///< The 1 key\n        Num2,         ///< The 2 key\n        Num3,         ///< The 3 key\n        Num4,         ///< The 4 key\n        Num5,         ///< The 5 key\n        Num6,         ///< The 6 key\n        Num7,         ///< The 7 key\n        Num8,         ///< The 8 key\n        Num9,         ///< The 9 key\n        Escape,       ///< The Escape key\n        LControl,     ///< The left Control key\n        LShift,       ///< The left Shift key\n        LAlt,         ///< The left Alt key\n        LSystem,      ///< The left OS specific key: window (Windows and Linux), apple (MacOS X), ...\n        RControl,     ///< The right Control key\n        RShift,       ///< The right Shift key\n        RAlt,         ///< The right Alt key\n        RSystem,      ///< The right OS specific key: window (Windows and Linux), apple (MacOS X), ...\n        Menu,         ///< The Menu key\n        LBracket,     ///< The [ key\n        RBracket,     ///< The ] key\n        SemiColon,    ///< The ; key\n        Comma,        ///< The , key\n        Period,       ///< The . key\n        Quote,        ///< The ' key\n        Slash,        ///< The / key\n        BackSlash,    ///< The \\ key\n        Tilde,        ///< The ~ key\n        Equal,        ///< The = key\n        Dash,         ///< The - key\n        Space,        ///< The Space key\n        Return,       ///< The Return key\n        BackSpace,    ///< The Backspace key\n        Tab,          ///< The Tabulation key\n        PageUp,       ///< The Page up key\n        PageDown,     ///< The Page down key\n        End,          ///< The End key\n        Home,         ///< The Home key\n        Insert,       ///< The Insert key\n        Delete,       ///< The Delete key\n        Add,          ///< The + key\n        Subtract,     ///< The - key\n        Multiply,     ///< The * key\n        Divide,       ///< The / key\n        Left,         ///< Left arrow\n        Right,        ///< Right arrow\n        Up,           ///< Up arrow\n        Down,         ///< Down arrow\n        Numpad0,      ///< The numpad 0 key\n        Numpad1,      ///< The numpad 1 key\n        Numpad2,      ///< The numpad 2 key\n        Numpad3,      ///< The numpad 3 key\n        Numpad4,      ///< The numpad 4 key\n        Numpad5,      ///< The numpad 5 key\n        Numpad6,      ///< The numpad 6 key\n        Numpad7,      ///< The numpad 7 key\n        Numpad8,      ///< The numpad 8 key\n        Numpad9,      ///< The numpad 9 key\n        F1,           ///< The F1 key\n        F2,           ///< The F2 key\n        F3,           ///< The F3 key\n        F4,           ///< The F4 key\n        F5,           ///< The F5 key\n        F6,           ///< The F6 key\n        F7,           ///< The F7 key\n        F8,           ///< The F8 key\n        F9,           ///< The F9 key\n        F10,          ///< The F10 key\n        F11,          ///< The F11 key\n        F12,          ///< The F12 key\n        F13,          ///< The F13 key\n        F14,          ///< The F14 key\n        F15,          ///< The F15 key\n        Pause,        ///< The Pause key\n\n        KeyCount      ///< Keep last -- the total number of keyboard keys\n    };\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Check if a key is pressed\n    ///\n    /// \\param key Key to check\n    ///\n    /// \\return True if the key is pressed, false otherwise\n    ///\n    ////////////////////////////////////////////////////////////\n    static bool isKeyPressed(Key key);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Show or hide the virtual keyboard\n    ///\n    /// Warning: the virtual keyboard is not supported on all\n    /// systems. It will typically be implemented on mobile OSes\n    /// (Android, iOS) but not on desktop OSes (Windows, Linux, ...).\n    ///\n    /// If the virtual keyboard is not available, this function does\n    /// nothing.\n    ///\n    /// \\param visible True to show, false to hide\n    ///\n    ////////////////////////////////////////////////////////////\n    static void setVirtualKeyboardVisible(bool visible);\n};\n\n} // namespace sf\n\n\n#endif // SFML_KEYBOARD_HPP\n\n\n////////////////////////////////////////////////////////////\n/// \\class sf::Keyboard\n/// \\ingroup window\n///\n/// sf::Keyboard provides an interface to the state of the\n/// keyboard. It only contains static functions (a single\n/// keyboard is assumed), so it's not meant to be instantiated.\n///\n/// This class allows users to query the keyboard state at any\n/// time and directly, without having to deal with a window and\n/// its events. Compared to the KeyPressed and KeyReleased events,\n/// sf::Keyboard can retrieve the state of a key at any time\n/// (you don't need to store and update a boolean on your side\n/// in order to know if a key is pressed or released), and you\n/// always get the real state of the keyboard, even if keys are\n/// pressed or released when your window is out of focus and no\n/// event is triggered.\n///\n/// Usage example:\n/// \\code\n/// if (sf::Keyboard::isKeyPressed(sf::Keyboard::Left))\n/// {\n///     // move left...\n/// }\n/// else if (sf::Keyboard::isKeyPressed(sf::Keyboard::Right))\n/// {\n///     // move right...\n/// }\n/// else if (sf::Keyboard::isKeyPressed(sf::Keyboard::Escape))\n/// {\n///     // quit...\n/// }\n/// \\endcode\n///\n/// \\see sf::Joystick, sf::Mouse, sf::Touch\n///\n////////////////////////////////////////////////////////////\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/Window/Mouse.hpp",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n#ifndef SFML_MOUSE_HPP\n#define SFML_MOUSE_HPP\n\n////////////////////////////////////////////////////////////\n// Headers\n////////////////////////////////////////////////////////////\n#include <SFML/Window/Export.hpp>\n#include <SFML/System/Vector2.hpp>\n\n\nnamespace sf\n{\nclass Window;\n\n////////////////////////////////////////////////////////////\n/// \\brief Give access to the real-time state of the mouse\n///\n////////////////////////////////////////////////////////////\nclass SFML_WINDOW_API Mouse\n{\npublic:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Mouse buttons\n    ///\n    ////////////////////////////////////////////////////////////\n    enum Button\n    {\n        Left,       ///< The left mouse button\n        Right,      ///< The right mouse button\n        Middle,     ///< The middle (wheel) mouse button\n        XButton1,   ///< The first extra mouse button\n        XButton2,   ///< The second extra mouse button\n\n        ButtonCount ///< Keep last -- the total number of mouse buttons\n    };\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Mouse wheels\n    ///\n    ////////////////////////////////////////////////////////////\n    enum Wheel\n    {\n        VerticalWheel,  ///< The vertical mouse wheel\n        HorizontalWheel ///< The horizontal mouse wheel\n    };\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Check if a mouse button is pressed\n    ///\n    /// \\param button Button to check\n    ///\n    /// \\return True if the button is pressed, false otherwise\n    ///\n    ////////////////////////////////////////////////////////////\n    static bool isButtonPressed(Button button);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the current position of the mouse in desktop coordinates\n    ///\n    /// This function returns the global position of the mouse\n    /// cursor on the desktop.\n    ///\n    /// \\return Current position of the mouse\n    ///\n    ////////////////////////////////////////////////////////////\n    static Vector2i getPosition();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the current position of the mouse in window coordinates\n    ///\n    /// This function returns the current position of the mouse\n    /// cursor, relative to the given window.\n    ///\n    /// \\param relativeTo Reference window\n    ///\n    /// \\return Current position of the mouse\n    ///\n    ////////////////////////////////////////////////////////////\n    static Vector2i getPosition(const Window& relativeTo);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Set the current position of the mouse in desktop coordinates\n    ///\n    /// This function sets the global position of the mouse\n    /// cursor on the desktop.\n    ///\n    /// \\param position New position of the mouse\n    ///\n    ////////////////////////////////////////////////////////////\n    static void setPosition(const Vector2i& position);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Set the current position of the mouse in window coordinates\n    ///\n    /// This function sets the current position of the mouse\n    /// cursor, relative to the given window.\n    ///\n    /// \\param position New position of the mouse\n    /// \\param relativeTo Reference window\n    ///\n    ////////////////////////////////////////////////////////////\n    static void setPosition(const Vector2i& position, const Window& relativeTo);\n};\n\n} // namespace sf\n\n\n#endif // SFML_MOUSE_HPP\n\n\n////////////////////////////////////////////////////////////\n/// \\class sf::Mouse\n/// \\ingroup window\n///\n/// sf::Mouse provides an interface to the state of the\n/// mouse. It only contains static functions (a single\n/// mouse is assumed), so it's not meant to be instantiated.\n///\n/// This class allows users to query the mouse state at any\n/// time and directly, without having to deal with a window and\n/// its events. Compared to the MouseMoved, MouseButtonPressed\n/// and MouseButtonReleased events, sf::Mouse can retrieve the\n/// state of the cursor and the buttons at any time\n/// (you don't need to store and update a boolean on your side\n/// in order to know if a button is pressed or released), and you\n/// always get the real state of the mouse, even if it is\n/// moved, pressed or released when your window is out of focus\n/// and no event is triggered.\n///\n/// The setPosition and getPosition functions can be used to change\n/// or retrieve the current position of the mouse pointer. There are\n/// two versions: one that operates in global coordinates (relative\n/// to the desktop) and one that operates in window coordinates\n/// (relative to a specific window).\n///\n/// Usage example:\n/// \\code\n/// if (sf::Mouse::isButtonPressed(sf::Mouse::Left))\n/// {\n///     // left click...\n/// }\n///\n/// // get global mouse position\n/// sf::Vector2i position = sf::Mouse::getPosition();\n///\n/// // set mouse position relative to a window\n/// sf::Mouse::setPosition(sf::Vector2i(100, 200), window);\n/// \\endcode\n///\n/// \\see sf::Joystick, sf::Keyboard, sf::Touch\n///\n////////////////////////////////////////////////////////////\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/Window/Sensor.hpp",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n#ifndef SFML_SENSOR_HPP\n#define SFML_SENSOR_HPP\n\n////////////////////////////////////////////////////////////\n// Headers\n////////////////////////////////////////////////////////////\n#include <SFML/Window/Export.hpp>\n#include <SFML/System/Vector3.hpp>\n#include <SFML/System/Time.hpp>\n\n\nnamespace sf\n{\n////////////////////////////////////////////////////////////\n/// \\brief Give access to the real-time state of the sensors\n///\n////////////////////////////////////////////////////////////\nclass SFML_WINDOW_API Sensor\n{\npublic:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Sensor type\n    ///\n    ////////////////////////////////////////////////////////////\n    enum Type\n    {\n        Accelerometer,    ///< Measures the raw acceleration (m/s^2)\n        Gyroscope,        ///< Measures the raw rotation rates (degrees/s)\n        Magnetometer,     ///< Measures the ambient magnetic field (micro-teslas)\n        Gravity,          ///< Measures the direction and intensity of gravity, independent of device acceleration (m/s^2)\n        UserAcceleration, ///< Measures the direction and intensity of device acceleration, independent of the gravity (m/s^2)\n        Orientation,      ///< Measures the absolute 3D orientation (degrees)\n\n        Count             ///< Keep last -- the total number of sensor types\n    };\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Check if a sensor is available on the underlying platform\n    ///\n    /// \\param sensor Sensor to check\n    ///\n    /// \\return True if the sensor is available, false otherwise\n    ///\n    ////////////////////////////////////////////////////////////\n    static bool isAvailable(Type sensor);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Enable or disable a sensor\n    ///\n    /// All sensors are disabled by default, to avoid consuming too\n    /// much battery power. Once a sensor is enabled, it starts\n    /// sending events of the corresponding type.\n    ///\n    /// This function does nothing if the sensor is unavailable.\n    ///\n    /// \\param sensor  Sensor to enable\n    /// \\param enabled True to enable, false to disable\n    ///\n    ////////////////////////////////////////////////////////////\n    static void setEnabled(Type sensor, bool enabled);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the current sensor value\n    ///\n    /// \\param sensor Sensor to read\n    ///\n    /// \\return The current sensor value\n    ///\n    ////////////////////////////////////////////////////////////\n    static Vector3f getValue(Type sensor);\n};\n\n} // namespace sf\n\n\n#endif // SFML_SENSOR_HPP\n\n\n////////////////////////////////////////////////////////////\n/// \\class sf::Sensor\n/// \\ingroup window\n///\n/// sf::Sensor provides an interface to the state of the\n/// various sensors that a device provides. It only contains static\n/// functions, so it's not meant to be instantiated.\n///\n/// This class allows users to query the sensors values at any\n/// time and directly, without having to deal with a window and\n/// its events. Compared to the SensorChanged event, sf::Sensor\n/// can retrieve the state of a sensor at any time (you don't need to\n/// store and update its current value on your side).\n///\n/// Depending on the OS and hardware of the device (phone, tablet, ...),\n/// some sensor types may not be available. You should always check\n/// the availability of a sensor before trying to read it, with the\n/// sf::Sensor::isAvailable function.\n///\n/// You may wonder why some sensor types look so similar, for example\n/// Accelerometer and Gravity / UserAcceleration. The first one\n/// is the raw measurement of the acceleration, and takes into account\n/// both the earth gravity and the user movement. The others are\n/// more precise: they provide these components separately, which is\n/// usually more useful. In fact they are not direct sensors, they\n/// are computed internally based on the raw acceleration and other sensors.\n/// This is exactly the same for Gyroscope vs Orientation.\n///\n/// Because sensors consume a non-negligible amount of current, they are\n/// all disabled by default. You must call sf::Sensor::setEnabled for each\n/// sensor in which you are interested.\n///\n/// Usage example:\n/// \\code\n/// if (sf::Sensor::isAvailable(sf::Sensor::Gravity))\n/// {\n///     // gravity sensor is available\n/// }\n///\n/// // enable the gravity sensor\n/// sf::Sensor::setEnabled(sf::Sensor::Gravity, true);\n///\n/// // get the current value of gravity\n/// sf::Vector3f gravity = sf::Sensor::getValue(sf::Sensor::Gravity);\n/// \\endcode\n///\n////////////////////////////////////////////////////////////\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/Window/Touch.hpp",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n#ifndef SFML_TOUCH_HPP\n#define SFML_TOUCH_HPP\n\n////////////////////////////////////////////////////////////\n// Headers\n////////////////////////////////////////////////////////////\n#include <SFML/Window/Export.hpp>\n#include <SFML/System/Vector2.hpp>\n\n\nnamespace sf\n{\nclass Window;\n\n////////////////////////////////////////////////////////////\n/// \\brief Give access to the real-time state of the touches\n///\n////////////////////////////////////////////////////////////\nclass SFML_WINDOW_API Touch\n{\npublic:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Check if a touch event is currently down\n    ///\n    /// \\param finger Finger index\n    ///\n    /// \\return True if \\a finger is currently touching the screen, false otherwise\n    ///\n    ////////////////////////////////////////////////////////////\n    static bool isDown(unsigned int finger);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the current position of a touch in desktop coordinates\n    ///\n    /// This function returns the current touch position\n    /// in global (desktop) coordinates.\n    ///\n    /// \\param finger Finger index\n    ///\n    /// \\return Current position of \\a finger, or undefined if it's not down\n    ///\n    ////////////////////////////////////////////////////////////\n    static Vector2i getPosition(unsigned int finger);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the current position of a touch in window coordinates\n    ///\n    /// This function returns the current touch position\n    /// relative to the given window.\n    ///\n    /// \\param finger Finger index\n    /// \\param relativeTo Reference window\n    ///\n    /// \\return Current position of \\a finger, or undefined if it's not down\n    ///\n    ////////////////////////////////////////////////////////////\n    static Vector2i getPosition(unsigned int finger, const Window& relativeTo);\n};\n\n} // namespace sf\n\n\n#endif // SFML_TOUCH_HPP\n\n\n////////////////////////////////////////////////////////////\n/// \\class sf::Touch\n/// \\ingroup window\n///\n/// sf::Touch provides an interface to the state of the\n/// touches. It only contains static functions, so it's not\n/// meant to be instantiated.\n///\n/// This class allows users to query the touches state at any\n/// time and directly, without having to deal with a window and\n/// its events. Compared to the TouchBegan, TouchMoved\n/// and TouchEnded events, sf::Touch can retrieve the\n/// state of the touches at any time (you don't need to store and\n/// update a boolean on your side in order to know if a touch is down),\n/// and you always get the real state of the touches, even if they\n/// happen when your window is out of focus and no event is triggered.\n///\n/// The getPosition function can be used to retrieve the current\n/// position of a touch. There are two versions: one that operates\n/// in global coordinates (relative to the desktop) and one that\n/// operates in window coordinates (relative to a specific window).\n///\n/// Touches are identified by an index (the \"finger\"), so that in\n/// multi-touch events, individual touches can be tracked correctly.\n/// As long as a finger touches the screen, it will keep the same index\n/// even if other fingers start or stop touching the screen in the\n/// meantime. As a consequence, active touch indices may not always be\n/// sequential (i.e. touch number 0 may be released while touch number 1\n/// is still down).\n///\n/// Usage example:\n/// \\code\n/// if (sf::Touch::isDown(0))\n/// {\n///     // touch 0 is down\n/// }\n///\n/// // get global position of touch 1\n/// sf::Vector2i globalPos = sf::Touch::getPosition(1);\n///\n/// // get position of touch 1 relative to a window\n/// sf::Vector2i relativePos = sf::Touch::getPosition(1, window);\n/// \\endcode\n///\n/// \\see sf::Joystick, sf::Keyboard, sf::Mouse\n///\n////////////////////////////////////////////////////////////\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/Window/VideoMode.hpp",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n#ifndef SFML_VIDEOMODE_HPP\n#define SFML_VIDEOMODE_HPP\n\n////////////////////////////////////////////////////////////\n// Headers\n////////////////////////////////////////////////////////////\n#include <SFML/Window/Export.hpp>\n#include <vector>\n\n\nnamespace sf\n{\n////////////////////////////////////////////////////////////\n/// \\brief VideoMode defines a video mode (width, height, bpp)\n///\n////////////////////////////////////////////////////////////\nclass SFML_WINDOW_API VideoMode\n{\npublic:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Default constructor\n    ///\n    /// This constructors initializes all members to 0.\n    ///\n    ////////////////////////////////////////////////////////////\n    VideoMode();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Construct the video mode with its attributes\n    ///\n    /// \\param modeWidth        Width in pixels\n    /// \\param modeHeight       Height in pixels\n    /// \\param modeBitsPerPixel Pixel depths in bits per pixel\n    ///\n    ////////////////////////////////////////////////////////////\n    VideoMode(unsigned int modeWidth, unsigned int modeHeight, unsigned int modeBitsPerPixel = 32);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the current desktop video mode\n    ///\n    /// \\return Current desktop video mode\n    ///\n    ////////////////////////////////////////////////////////////\n    static VideoMode getDesktopMode();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Retrieve all the video modes supported in fullscreen mode\n    ///\n    /// When creating a fullscreen window, the video mode is restricted\n    /// to be compatible with what the graphics driver and monitor\n    /// support. This function returns the complete list of all video\n    /// modes that can be used in fullscreen mode.\n    /// The returned array is sorted from best to worst, so that\n    /// the first element will always give the best mode (higher\n    /// width, height and bits-per-pixel).\n    ///\n    /// \\return Array containing all the supported fullscreen modes\n    ///\n    ////////////////////////////////////////////////////////////\n    static const std::vector<VideoMode>& getFullscreenModes();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Tell whether or not the video mode is valid\n    ///\n    /// The validity of video modes is only relevant when using\n    /// fullscreen windows; otherwise any video mode can be used\n    /// with no restriction.\n    ///\n    /// \\return True if the video mode is valid for fullscreen mode\n    ///\n    ////////////////////////////////////////////////////////////\n    bool isValid() const;\n\n    ////////////////////////////////////////////////////////////\n    // Member data\n    ////////////////////////////////////////////////////////////\n    unsigned int width;        ///< Video mode width, in pixels\n    unsigned int height;       ///< Video mode height, in pixels\n    unsigned int bitsPerPixel; ///< Video mode pixel depth, in bits per pixels\n};\n\n////////////////////////////////////////////////////////////\n/// \\relates VideoMode\n/// \\brief Overload of == operator to compare two video modes\n///\n/// \\param left  Left operand (a video mode)\n/// \\param right Right operand (a video mode)\n///\n/// \\return True if modes are equal\n///\n////////////////////////////////////////////////////////////\nSFML_WINDOW_API bool operator ==(const VideoMode& left, const VideoMode& right);\n\n////////////////////////////////////////////////////////////\n/// \\relates VideoMode\n/// \\brief Overload of != operator to compare two video modes\n///\n/// \\param left  Left operand (a video mode)\n/// \\param right Right operand (a video mode)\n///\n/// \\return True if modes are different\n///\n////////////////////////////////////////////////////////////\nSFML_WINDOW_API bool operator !=(const VideoMode& left, const VideoMode& right);\n\n////////////////////////////////////////////////////////////\n/// \\relates VideoMode\n/// \\brief Overload of < operator to compare video modes\n///\n/// \\param left  Left operand (a video mode)\n/// \\param right Right operand (a video mode)\n///\n/// \\return True if \\a left is lesser than \\a right\n///\n////////////////////////////////////////////////////////////\nSFML_WINDOW_API bool operator <(const VideoMode& left, const VideoMode& right);\n\n////////////////////////////////////////////////////////////\n/// \\relates VideoMode\n/// \\brief Overload of > operator to compare video modes\n///\n/// \\param left  Left operand (a video mode)\n/// \\param right Right operand (a video mode)\n///\n/// \\return True if \\a left is greater than \\a right\n///\n////////////////////////////////////////////////////////////\nSFML_WINDOW_API bool operator >(const VideoMode& left, const VideoMode& right);\n\n////////////////////////////////////////////////////////////\n/// \\relates VideoMode\n/// \\brief Overload of <= operator to compare video modes\n///\n/// \\param left  Left operand (a video mode)\n/// \\param right Right operand (a video mode)\n///\n/// \\return True if \\a left is lesser or equal than \\a right\n///\n////////////////////////////////////////////////////////////\nSFML_WINDOW_API bool operator <=(const VideoMode& left, const VideoMode& right);\n\n////////////////////////////////////////////////////////////\n/// \\relates VideoMode\n/// \\brief Overload of >= operator to compare video modes\n///\n/// \\param left  Left operand (a video mode)\n/// \\param right Right operand (a video mode)\n///\n/// \\return True if \\a left is greater or equal than \\a right\n///\n////////////////////////////////////////////////////////////\nSFML_WINDOW_API bool operator >=(const VideoMode& left, const VideoMode& right);\n\n} // namespace sf\n\n\n#endif // SFML_VIDEOMODE_HPP\n\n\n////////////////////////////////////////////////////////////\n/// \\class sf::VideoMode\n/// \\ingroup window\n///\n/// A video mode is defined by a width and a height (in pixels)\n/// and a depth (in bits per pixel). Video modes are used to\n/// setup windows (sf::Window) at creation time.\n///\n/// The main usage of video modes is for fullscreen mode:\n/// indeed you must use one of the valid video modes\n/// allowed by the OS (which are defined by what the monitor\n/// and the graphics card support), otherwise your window\n/// creation will just fail.\n///\n/// sf::VideoMode provides a static function for retrieving\n/// the list of all the video modes supported by the system:\n/// getFullscreenModes().\n///\n/// A custom video mode can also be checked directly for\n/// fullscreen compatibility with its isValid() function.\n///\n/// Additionally, sf::VideoMode provides a static function\n/// to get the mode currently used by the desktop: getDesktopMode().\n/// This allows to build windows with the same size or pixel\n/// depth as the current resolution.\n///\n/// Usage example:\n/// \\code\n/// // Display the list of all the video modes available for fullscreen\n/// std::vector<sf::VideoMode> modes = sf::VideoMode::getFullscreenModes();\n/// for (std::size_t i = 0; i < modes.size(); ++i)\n/// {\n///     sf::VideoMode mode = modes[i];\n///     std::cout << \"Mode #\" << i << \": \"\n///               << mode.width << \"x\" << mode.height << \" - \"\n///               << mode.bitsPerPixel << \" bpp\" << std::endl;\n/// }\n///\n/// // Create a window with the same pixel depth as the desktop\n/// sf::VideoMode desktop = sf::VideoMode::getDesktopMode();\n/// window.create(sf::VideoMode(1024, 768, desktop.bitsPerPixel), \"SFML window\");\n/// \\endcode\n///\n////////////////////////////////////////////////////////////\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/Window/Window.hpp",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n#ifndef SFML_WINDOW_HPP\n#define SFML_WINDOW_HPP\n\n////////////////////////////////////////////////////////////\n// Headers\n////////////////////////////////////////////////////////////\n#include <SFML/Window/Export.hpp>\n#include <SFML/Window/ContextSettings.hpp>\n#include <SFML/Window/VideoMode.hpp>\n#include <SFML/Window/WindowHandle.hpp>\n#include <SFML/Window/WindowStyle.hpp>\n#include <SFML/Window/GlResource.hpp>\n#include <SFML/System/Clock.hpp>\n#include <SFML/System/Vector2.hpp>\n#include <SFML/System/NonCopyable.hpp>\n#include <SFML/System/String.hpp>\n\n\nnamespace sf\n{\nnamespace priv\n{\n    class GlContext;\n    class WindowImpl;\n}\n\nclass Event;\n\n////////////////////////////////////////////////////////////\n/// \\brief Window that serves as a target for OpenGL rendering\n///\n////////////////////////////////////////////////////////////\nclass SFML_WINDOW_API Window : GlResource, NonCopyable\n{\npublic:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Default constructor\n    ///\n    /// This constructor doesn't actually create the window,\n    /// use the other constructors or call create() to do so.\n    ///\n    ////////////////////////////////////////////////////////////\n    Window();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Construct a new window\n    ///\n    /// This constructor creates the window with the size and pixel\n    /// depth defined in \\a mode. An optional style can be passed to\n    /// customize the look and behavior of the window (borders,\n    /// title bar, resizable, closable, ...). If \\a style contains\n    /// Style::Fullscreen, then \\a mode must be a valid video mode.\n    ///\n    /// The fourth parameter is an optional structure specifying\n    /// advanced OpenGL context settings such as antialiasing,\n    /// depth-buffer bits, etc.\n    ///\n    /// \\param mode     Video mode to use (defines the width, height and depth of the rendering area of the window)\n    /// \\param title    Title of the window\n    /// \\param style    %Window style, a bitwise OR combination of sf::Style enumerators\n    /// \\param settings Additional settings for the underlying OpenGL context\n    ///\n    ////////////////////////////////////////////////////////////\n    Window(VideoMode mode, const String& title, Uint32 style = Style::Default, const ContextSettings& settings = ContextSettings());\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Construct the window from an existing control\n    ///\n    /// Use this constructor if you want to create an OpenGL\n    /// rendering area into an already existing control.\n    ///\n    /// The second parameter is an optional structure specifying\n    /// advanced OpenGL context settings such as antialiasing,\n    /// depth-buffer bits, etc.\n    ///\n    /// \\param handle   Platform-specific handle of the control\n    /// \\param settings Additional settings for the underlying OpenGL context\n    ///\n    ////////////////////////////////////////////////////////////\n    explicit Window(WindowHandle handle, const ContextSettings& settings = ContextSettings());\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Destructor\n    ///\n    /// Closes the window and frees all the resources attached to it.\n    ///\n    ////////////////////////////////////////////////////////////\n    virtual ~Window();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Create (or recreate) the window\n    ///\n    /// If the window was already created, it closes it first.\n    /// If \\a style contains Style::Fullscreen, then \\a mode\n    /// must be a valid video mode.\n    ///\n    /// The fourth parameter is an optional structure specifying\n    /// advanced OpenGL context settings such as antialiasing,\n    /// depth-buffer bits, etc.\n    ///\n    /// \\param mode     Video mode to use (defines the width, height and depth of the rendering area of the window)\n    /// \\param title    Title of the window\n    /// \\param style    %Window style, a bitwise OR combination of sf::Style enumerators\n    /// \\param settings Additional settings for the underlying OpenGL context\n    ///\n    ////////////////////////////////////////////////////////////\n    void create(VideoMode mode, const String& title, Uint32 style = Style::Default, const ContextSettings& settings = ContextSettings());\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Create (or recreate) the window from an existing control\n    ///\n    /// Use this function if you want to create an OpenGL\n    /// rendering area into an already existing control.\n    /// If the window was already created, it closes it first.\n    ///\n    /// The second parameter is an optional structure specifying\n    /// advanced OpenGL context settings such as antialiasing,\n    /// depth-buffer bits, etc.\n    ///\n    /// \\param handle   Platform-specific handle of the control\n    /// \\param settings Additional settings for the underlying OpenGL context\n    ///\n    ////////////////////////////////////////////////////////////\n    void create(WindowHandle handle, const ContextSettings& settings = ContextSettings());\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Close the window and destroy all the attached resources\n    ///\n    /// After calling this function, the sf::Window instance remains\n    /// valid and you can call create() to recreate the window.\n    /// All other functions such as pollEvent() or display() will\n    /// still work (i.e. you don't have to test isOpen() every time),\n    /// and will have no effect on closed windows.\n    ///\n    ////////////////////////////////////////////////////////////\n    void close();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Tell whether or not the window is open\n    ///\n    /// This function returns whether or not the window exists.\n    /// Note that a hidden window (setVisible(false)) is open\n    /// (therefore this function would return true).\n    ///\n    /// \\return True if the window is open, false if it has been closed\n    ///\n    ////////////////////////////////////////////////////////////\n    bool isOpen() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the settings of the OpenGL context of the window\n    ///\n    /// Note that these settings may be different from what was\n    /// passed to the constructor or the create() function,\n    /// if one or more settings were not supported. In this case,\n    /// SFML chose the closest match.\n    ///\n    /// \\return Structure containing the OpenGL context settings\n    ///\n    ////////////////////////////////////////////////////////////\n    const ContextSettings& getSettings() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Pop the event on top of the event queue, if any, and return it\n    ///\n    /// This function is not blocking: if there's no pending event then\n    /// it will return false and leave \\a event unmodified.\n    /// Note that more than one event may be present in the event queue,\n    /// thus you should always call this function in a loop\n    /// to make sure that you process every pending event.\n    /// \\code\n    /// sf::Event event;\n    /// while (window.pollEvent(event))\n    /// {\n    ///    // process event...\n    /// }\n    /// \\endcode\n    ///\n    /// \\param event Event to be returned\n    ///\n    /// \\return True if an event was returned, or false if the event queue was empty\n    ///\n    /// \\see waitEvent\n    ///\n    ////////////////////////////////////////////////////////////\n    bool pollEvent(Event& event);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Wait for an event and return it\n    ///\n    /// This function is blocking: if there's no pending event then\n    /// it will wait until an event is received.\n    /// After this function returns (and no error occurred),\n    /// the \\a event object is always valid and filled properly.\n    /// This function is typically used when you have a thread that\n    /// is dedicated to events handling: you want to make this thread\n    /// sleep as long as no new event is received.\n    /// \\code\n    /// sf::Event event;\n    /// if (window.waitEvent(event))\n    /// {\n    ///    // process event...\n    /// }\n    /// \\endcode\n    ///\n    /// \\param event Event to be returned\n    ///\n    /// \\return False if any error occurred\n    ///\n    /// \\see pollEvent\n    ///\n    ////////////////////////////////////////////////////////////\n    bool waitEvent(Event& event);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the position of the window\n    ///\n    /// \\return Position of the window, in pixels\n    ///\n    /// \\see setPosition\n    ///\n    ////////////////////////////////////////////////////////////\n    Vector2i getPosition() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Change the position of the window on screen\n    ///\n    /// This function only works for top-level windows\n    /// (i.e. it will be ignored for windows created from\n    /// the handle of a child window/control).\n    ///\n    /// \\param position New position, in pixels\n    ///\n    /// \\see getPosition\n    ///\n    ////////////////////////////////////////////////////////////\n    void setPosition(const Vector2i& position);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the size of the rendering region of the window\n    ///\n    /// The size doesn't include the titlebar and borders\n    /// of the window.\n    ///\n    /// \\return Size in pixels\n    ///\n    /// \\see setSize\n    ///\n    ////////////////////////////////////////////////////////////\n    Vector2u getSize() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Change the size of the rendering region of the window\n    ///\n    /// \\param size New size, in pixels\n    ///\n    /// \\see getSize\n    ///\n    ////////////////////////////////////////////////////////////\n    void setSize(const Vector2u& size);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Change the title of the window\n    ///\n    /// \\param title New title\n    ///\n    /// \\see setIcon\n    ///\n    ////////////////////////////////////////////////////////////\n    void setTitle(const String& title);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Change the window's icon\n    ///\n    /// \\a pixels must be an array of \\a width x \\a height pixels\n    /// in 32-bits RGBA format.\n    ///\n    /// The OS default icon is used by default.\n    ///\n    /// \\param width  Icon's width, in pixels\n    /// \\param height Icon's height, in pixels\n    /// \\param pixels Pointer to the array of pixels in memory. The\n    ///               pixels are copied, so you need not keep the\n    ///               source alive after calling this function.\n    ///\n    /// \\see setTitle\n    ///\n    ////////////////////////////////////////////////////////////\n    void setIcon(unsigned int width, unsigned int height, const Uint8* pixels);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Show or hide the window\n    ///\n    /// The window is shown by default.\n    ///\n    /// \\param visible True to show the window, false to hide it\n    ///\n    ////////////////////////////////////////////////////////////\n    void setVisible(bool visible);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Enable or disable vertical synchronization\n    ///\n    /// Activating vertical synchronization will limit the number\n    /// of frames displayed to the refresh rate of the monitor.\n    /// This can avoid some visual artifacts, and limit the framerate\n    /// to a good value (but not constant across different computers).\n    ///\n    /// Vertical synchronization is disabled by default.\n    ///\n    /// \\param enabled True to enable v-sync, false to deactivate it\n    ///\n    ////////////////////////////////////////////////////////////\n    void setVerticalSyncEnabled(bool enabled);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Show or hide the mouse cursor\n    ///\n    /// The mouse cursor is visible by default.\n    ///\n    /// \\param visible True to show the mouse cursor, false to hide it\n    ///\n    ////////////////////////////////////////////////////////////\n    void setMouseCursorVisible(bool visible);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Grab or release the mouse cursor\n    ///\n    /// If set, grabs the mouse cursor inside this window's client\n    /// area so it may no longer be moved outside its bounds.\n    /// Note that grabbing is only active while the window has\n    /// focus.\n    ///\n    /// \\param grabbed True to enable, false to disable\n    ///\n    ////////////////////////////////////////////////////////////\n    void setMouseCursorGrabbed(bool grabbed);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Enable or disable automatic key-repeat\n    ///\n    /// If key repeat is enabled, you will receive repeated\n    /// KeyPressed events while keeping a key pressed. If it is disabled,\n    /// you will only get a single event when the key is pressed.\n    ///\n    /// Key repeat is enabled by default.\n    ///\n    /// \\param enabled True to enable, false to disable\n    ///\n    ////////////////////////////////////////////////////////////\n    void setKeyRepeatEnabled(bool enabled);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Limit the framerate to a maximum fixed frequency\n    ///\n    /// If a limit is set, the window will use a small delay after\n    /// each call to display() to ensure that the current frame\n    /// lasted long enough to match the framerate limit.\n    /// SFML will try to match the given limit as much as it can,\n    /// but since it internally uses sf::sleep, whose precision\n    /// depends on the underlying OS, the results may be a little\n    /// unprecise as well (for example, you can get 65 FPS when\n    /// requesting 60).\n    ///\n    /// \\param limit Framerate limit, in frames per seconds (use 0 to disable limit)\n    ///\n    ////////////////////////////////////////////////////////////\n    void setFramerateLimit(unsigned int limit);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Change the joystick threshold\n    ///\n    /// The joystick threshold is the value below which\n    /// no JoystickMoved event will be generated.\n    ///\n    /// The threshold value is 0.1 by default.\n    ///\n    /// \\param threshold New threshold, in the range [0, 100]\n    ///\n    ////////////////////////////////////////////////////////////\n    void setJoystickThreshold(float threshold);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Activate or deactivate the window as the current target\n    ///        for OpenGL rendering\n    ///\n    /// A window is active only on the current thread, if you want to\n    /// make it active on another thread you have to deactivate it\n    /// on the previous thread first if it was active.\n    /// Only one window can be active on a thread at a time, thus\n    /// the window previously active (if any) automatically gets deactivated.\n    /// This is not to be confused with requestFocus().\n    ///\n    /// \\param active True to activate, false to deactivate\n    ///\n    /// \\return True if operation was successful, false otherwise\n    ///\n    ////////////////////////////////////////////////////////////\n    bool setActive(bool active = true) const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Request the current window to be made the active\n    ///        foreground window\n    ///\n    /// At any given time, only one window may have the input focus\n    /// to receive input events such as keystrokes or mouse events.\n    /// If a window requests focus, it only hints to the operating\n    /// system, that it would like to be focused. The operating system\n    /// is free to deny the request.\n    /// This is not to be confused with setActive().\n    ///\n    /// \\see hasFocus\n    ///\n    ////////////////////////////////////////////////////////////\n    void requestFocus();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Check whether the window has the input focus\n    ///\n    /// At any given time, only one window may have the input focus\n    /// to receive input events such as keystrokes or most mouse\n    /// events.\n    ///\n    /// \\return True if window has focus, false otherwise\n    /// \\see requestFocus\n    ///\n    ////////////////////////////////////////////////////////////\n    bool hasFocus() const;\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Display on screen what has been rendered to the window so far\n    ///\n    /// This function is typically called after all OpenGL rendering\n    /// has been done for the current frame, in order to show\n    /// it on screen.\n    ///\n    ////////////////////////////////////////////////////////////\n    void display();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Get the OS-specific handle of the window\n    ///\n    /// The type of the returned handle is sf::WindowHandle,\n    /// which is a typedef to the handle type defined by the OS.\n    /// You shouldn't need to use this function, unless you have\n    /// very specific stuff to implement that SFML doesn't support,\n    /// or implement a temporary workaround until a bug is fixed.\n    ///\n    /// \\return System handle of the window\n    ///\n    ////////////////////////////////////////////////////////////\n    WindowHandle getSystemHandle() const;\n\nprotected:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Function called after the window has been created\n    ///\n    /// This function is called so that derived classes can\n    /// perform their own specific initialization as soon as\n    /// the window is created.\n    ///\n    ////////////////////////////////////////////////////////////\n    virtual void onCreate();\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Function called after the window has been resized\n    ///\n    /// This function is called so that derived classes can\n    /// perform custom actions when the size of the window changes.\n    ///\n    ////////////////////////////////////////////////////////////\n    virtual void onResize();\n\nprivate:\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Processes an event before it is sent to the user\n    ///\n    /// This function is called every time an event is received\n    /// from the internal window (through pollEvent or waitEvent).\n    /// It filters out unwanted events, and performs whatever internal\n    /// stuff the window needs before the event is returned to the\n    /// user.\n    ///\n    /// \\param event Event to filter\n    ///\n    ////////////////////////////////////////////////////////////\n    bool filterEvent(const Event& event);\n\n    ////////////////////////////////////////////////////////////\n    /// \\brief Perform some common internal initializations\n    ///\n    ////////////////////////////////////////////////////////////\n    void initialize();\n\n    ////////////////////////////////////////////////////////////\n    // Member data\n    ////////////////////////////////////////////////////////////\n    priv::WindowImpl* m_impl;           ///< Platform-specific implementation of the window\n    priv::GlContext*  m_context;        ///< Platform-specific implementation of the OpenGL context\n    Clock             m_clock;          ///< Clock for measuring the elapsed time between frames\n    Time              m_frameTimeLimit; ///< Current framerate limit\n    Vector2u          m_size;           ///< Current size of the window\n};\n\n} // namespace sf\n\n\n#endif // SFML_WINDOW_HPP\n\n\n////////////////////////////////////////////////////////////\n/// \\class sf::Window\n/// \\ingroup window\n///\n/// sf::Window is the main class of the Window module. It defines\n/// an OS window that is able to receive an OpenGL rendering.\n///\n/// A sf::Window can create its own new window, or be embedded into\n/// an already existing control using the create(handle) function.\n/// This can be useful for embedding an OpenGL rendering area into\n/// a view which is part of a bigger GUI with existing windows,\n/// controls, etc. It can also serve as embedding an OpenGL rendering\n/// area into a window created by another (probably richer) GUI library\n/// like Qt or wxWidgets.\n///\n/// The sf::Window class provides a simple interface for manipulating\n/// the window: move, resize, show/hide, control mouse cursor, etc.\n/// It also provides event handling through its pollEvent() and waitEvent()\n/// functions.\n///\n/// Note that OpenGL experts can pass their own parameters (antialiasing\n/// level, bits for the depth and stencil buffers, etc.) to the\n/// OpenGL context attached to the window, with the sf::ContextSettings\n/// structure which is passed as an optional argument when creating the\n/// window.\n///\n/// Usage example:\n/// \\code\n/// // Declare and create a new window\n/// sf::Window window(sf::VideoMode(800, 600), \"SFML window\");\n///\n/// // Limit the framerate to 60 frames per second (this step is optional)\n/// window.setFramerateLimit(60);\n///\n/// // The main loop - ends as soon as the window is closed\n/// while (window.isOpen())\n/// {\n///    // Event processing\n///    sf::Event event;\n///    while (window.pollEvent(event))\n///    {\n///        // Request for closing the window\n///        if (event.type == sf::Event::Closed)\n///            window.close();\n///    }\n///\n///    // Activate the window for OpenGL rendering\n///    window.setActive();\n///\n///    // OpenGL drawing commands go here...\n///\n///    // End the current frame and display its contents on screen\n///    window.display();\n/// }\n/// \\endcode\n///\n////////////////////////////////////////////////////////////\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/Window/WindowHandle.hpp",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n#ifndef SFML_WINDOWHANDLE_HPP\n#define SFML_WINDOWHANDLE_HPP\n\n////////////////////////////////////////////////////////////\n// Headers\n////////////////////////////////////////////////////////////\n#include <SFML/Config.hpp>\n\n// Windows' HWND is a typedef on struct HWND__*\n#if defined(SFML_SYSTEM_WINDOWS)\n    struct HWND__;\n#endif\n\nnamespace sf\n{\n#if defined(SFML_SYSTEM_WINDOWS)\n\n    // Window handle is HWND (HWND__*) on Windows\n    typedef HWND__* WindowHandle;\n\n#elif defined(SFML_SYSTEM_LINUX) || defined(SFML_SYSTEM_FREEBSD)\n\n    // Window handle is Window (unsigned long) on Unix - X11\n    typedef unsigned long WindowHandle;\n\n#elif defined(SFML_SYSTEM_MACOS)\n\n    // Window handle is NSWindow or NSView (void*) on Mac OS X - Cocoa\n    typedef void* WindowHandle;\n\n#elif defined(SFML_SYSTEM_IOS)\n\n    // Window handle is UIWindow (void*) on iOS - UIKit\n    typedef void* WindowHandle;\n\n#elif defined(SFML_SYSTEM_ANDROID)\n\n    // Window handle is ANativeWindow* (void*) on Android\n    typedef void* WindowHandle;\n\n#elif defined(SFML_DOXYGEN)\n\n    // Define typedef symbol so that Doxygen can attach some documentation to it\n    typedef \"platform–specific\" WindowHandle;\n\n#endif\n\n} // namespace sf\n\n\n#endif // SFML_WINDOWHANDLE_HPP\n\n////////////////////////////////////////////////////////////\n/// \\typedef sf::WindowHandle\n/// \\ingroup window\n///\n/// Define a low-level window handle type, specific to\n/// each platform.\n///\n/// Platform        | Type\n/// ----------------|------------------------------------------------------------\n/// Windows         | \\p HWND\n/// Linux/FreeBSD   | \\p %Window\n/// Mac OS X        | either \\p NSWindow* or \\p NSView*, disguised as \\p void*\n/// iOS             | \\p UIWindow*\n/// Android         | \\p ANativeWindow*\n///\n/// \\par Mac OS X Specification\n///\n/// On Mac OS X, a sf::Window can be created either from an\n/// existing \\p NSWindow* or an \\p NSView*. When the window\n/// is created from a window, SFML will use its content view\n/// as the OpenGL area. sf::Window::getSystemHandle() will\n/// return the handle that was used to create the window,\n/// which is a \\p NSWindow* by default.\n///\n////////////////////////////////////////////////////////////\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/Window/WindowStyle.hpp",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n#ifndef SFML_WINDOWSTYLE_HPP\n#define SFML_WINDOWSTYLE_HPP\n\n\nnamespace sf\n{\nnamespace Style\n{\n    ////////////////////////////////////////////////////////////\n    /// \\ingroup window\n    /// \\brief Enumeration of the window styles\n    ///\n    ////////////////////////////////////////////////////////////\n    enum\n    {\n        None       = 0,      ///< No border / title bar (this flag and all others are mutually exclusive)\n        Titlebar   = 1 << 0, ///< Title bar + fixed border\n        Resize     = 1 << 1, ///< Title bar + resizable border + maximize button\n        Close      = 1 << 2, ///< Title bar + close button\n        Fullscreen = 1 << 3, ///< Fullscreen mode (this flag and all others are mutually exclusive)\n\n        Default = Titlebar | Resize | Close ///< Default window style\n    };\n}\n\n} // namespace sf\n\n\n#endif // SFML_WINDOWSTYLE_HPP\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SFML/Window.hpp",
    "content": "////////////////////////////////////////////////////////////\n//\n// SFML - Simple and Fast Multimedia Library\n// Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org)\n//\n// This software is provided 'as-is', without any express or implied warranty.\n// In no event will the authors be held liable for any damages arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it freely,\n// subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented;\n//    you must not claim that you wrote the original software.\n//    If you use this software in a product, an acknowledgment\n//    in the product documentation would be appreciated but is not required.\n//\n// 2. Altered source versions must be plainly marked as such,\n//    and must not be misrepresented as being the original software.\n//\n// 3. This notice may not be removed or altered from any source distribution.\n//\n////////////////////////////////////////////////////////////\n\n#ifndef SFML_SFML_WINDOW_HPP\n#define SFML_SFML_WINDOW_HPP\n\n////////////////////////////////////////////////////////////\n// Headers\n////////////////////////////////////////////////////////////\n\n#include <SFML/System.hpp>\n#include <SFML/Window/Context.hpp>\n#include <SFML/Window/ContextSettings.hpp>\n#include <SFML/Window/Event.hpp>\n#include <SFML/Window/Joystick.hpp>\n#include <SFML/Window/Keyboard.hpp>\n#include <SFML/Window/Mouse.hpp>\n#include <SFML/Window/Sensor.hpp>\n#include <SFML/Window/Touch.hpp>\n#include <SFML/Window/VideoMode.hpp>\n#include <SFML/Window/Window.hpp>\n#include <SFML/Window/WindowHandle.hpp>\n#include <SFML/Window/WindowStyle.hpp>\n\n\n\n#endif // SFML_SFML_WINDOW_HPP\n\n////////////////////////////////////////////////////////////\n/// \\defgroup window Window module\n///\n/// Provides OpenGL-based windows, and abstractions for\n/// events and input handling.\n///\n////////////////////////////////////////////////////////////\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SHA1/HMAC_SHA1.h",
    "content": "/*\r\n\t100% free public domain implementation of the HMAC-SHA1 algorithm\r\n\tby Chien-Chung, Chung (Jim Chung) <jimchung1221@gmail.com>\r\n*/\r\n\r\n\r\n#ifndef __HMAC_SHA1_H__\r\n#define __HMAC_SHA1_H__\r\n\r\n#include \"SHA1.h\"\r\n\r\ntypedef unsigned char BYTE ;\r\n\r\nclass CHMAC_SHA1 : public CSHA1\r\n{\r\n    private:\r\n\t\tBYTE m_ipad[64];\r\n        BYTE m_opad[64];\r\n\r\n\t\tchar * szReport ;\r\n\t\tchar * SHA1_Key ;\r\n\t\tchar * AppendBuf1 ;\r\n\t\tchar * AppendBuf2 ;\r\n\r\n\r\n\tpublic:\r\n\t\t\r\n\t\tenum {\r\n\t\t\tSHA1_DIGEST_LENGTH\t= 20,\r\n\t\t\tSHA1_BLOCK_SIZE\t\t= 64,\r\n\t\t\tHMAC_BUF_LEN\t\t= 4096\r\n\t\t} ;\r\n\r\n\t\tCHMAC_SHA1()\r\n\t\t\t:szReport(new char[HMAC_BUF_LEN]),\r\n             AppendBuf1(new char[HMAC_BUF_LEN]),\r\n             AppendBuf2(new char[HMAC_BUF_LEN]),\r\n             SHA1_Key(new char[HMAC_BUF_LEN])\r\n\t\t{}\r\n\r\n        ~CHMAC_SHA1()\r\n        {\r\n            delete[] szReport ;\r\n            delete[] AppendBuf1 ;\r\n            delete[] AppendBuf2 ;\r\n            delete[] SHA1_Key ;\r\n        }\r\n\r\n        void HMAC_SHA1(BYTE *text, int text_len, BYTE *key, int key_len, BYTE *digest);\r\n};\r\n\r\n\r\n#endif /* __HMAC_SHA1_H__ */\r\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SHA1/SHA1.h",
    "content": "/*\r\n  100% free public domain implementation of the SHA-1 algorithm\r\n  by Dominik Reichl <dominik.reichl@t-online.de>\r\n  Web: http://www.dominik-reichl.de/\r\n\r\n  Version 2.1 - 2012-06-19\r\n  - Deconstructor (resetting internal variables) is now only\r\n    implemented if SHA1_WIPE_VARIABLES is defined (which is the\r\n    default).\r\n  - Renamed inclusion guard to contain a GUID.\r\n  - Demo application is now using C++/STL objects and functions.\r\n  - Unicode build of the demo application now outputs the hashes of both\r\n    the ANSI and Unicode representations of strings.\r\n  - Various other demo application improvements.\r\n\r\n  Version 2.0 - 2012-06-14\r\n  - Added 'limits.h' include.\r\n  - Renamed inclusion guard and macros for compliancy (names beginning\r\n    with an underscore are reserved).\r\n\r\n  Version 1.9 - 2011-11-10\r\n  - Added Unicode test vectors.\r\n  - Improved support for hashing files using the HashFile method that\r\n    are larger than 4 GB.\r\n  - Improved file hashing performance (by using a larger buffer).\r\n  - Disabled unnecessary compiler warnings.\r\n  - Internal variables are now private.\r\n\r\n  Version 1.8 - 2009-03-16\r\n  - Converted project files to Visual Studio 2008 format.\r\n  - Added Unicode support for HashFile utility method.\r\n  - Added support for hashing files using the HashFile method that are\r\n    larger than 2 GB.\r\n  - HashFile now returns an error code instead of copying an error\r\n    message into the output buffer.\r\n  - GetHash now returns an error code and validates the input parameter.\r\n  - Added ReportHashStl STL utility method.\r\n  - Added REPORT_HEX_SHORT reporting mode.\r\n  - Improved Linux compatibility of test program.\r\n\r\n  Version 1.7 - 2006-12-21\r\n  - Fixed buffer underrun warning that appeared when compiling with\r\n    Borland C Builder (thanks to Rex Bloom and Tim Gallagher for the\r\n    patch).\r\n  - Breaking change: ReportHash writes the final hash to the start\r\n    of the buffer, i.e. it's not appending it to the string anymore.\r\n  - Made some function parameters const.\r\n  - Added Visual Studio 2005 project files to demo project.\r\n\r\n  Version 1.6 - 2005-02-07 (thanks to Howard Kapustein for patches)\r\n  - You can set the endianness in your files, no need to modify the\r\n    header file of the CSHA1 class anymore.\r\n  - Aligned data support.\r\n  - Made support/compilation of the utility functions (ReportHash and\r\n    HashFile) optional (useful when bytes count, for example in embedded\r\n    environments).\r\n\r\n  Version 1.5 - 2005-01-01\r\n  - 64-bit compiler compatibility added.\r\n  - Made variable wiping optional (define SHA1_WIPE_VARIABLES).\r\n  - Removed unnecessary variable initializations.\r\n  - ROL32 improvement for the Microsoft compiler (using _rotl).\r\n\r\n  Version 1.4 - 2004-07-22\r\n  - CSHA1 now compiles fine with GCC 3.3 under Mac OS X (thanks to Larry\r\n    Hastings).\r\n\r\n  Version 1.3 - 2003-08-17\r\n  - Fixed a small memory bug and made a buffer array a class member to\r\n    ensure correct working when using multiple CSHA1 class instances at\r\n    one time.\r\n\r\n  Version 1.2 - 2002-11-16\r\n  - Borlands C++ compiler seems to have problems with string addition\r\n    using sprintf. Fixed the bug which caused the digest report function\r\n    not to work properly. CSHA1 is now Borland compatible.\r\n\r\n  Version 1.1 - 2002-10-11\r\n  - Removed two unnecessary header file includes and changed BOOL to\r\n    bool. Fixed some minor bugs in the web page contents.\r\n\r\n  Version 1.0 - 2002-06-20\r\n  - First official release.\r\n\r\n  ================ Test Vectors ================\r\n\r\n  SHA1(\"abc\" in ANSI) =\r\n    A9993E36 4706816A BA3E2571 7850C26C 9CD0D89D\r\n  SHA1(\"abc\" in Unicode LE) =\r\n    9F04F41A 84851416 2050E3D6 8C1A7ABB 441DC2B5\r\n\r\n  SHA1(\"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq\"\r\n    in ANSI) =\r\n    84983E44 1C3BD26E BAAE4AA1 F95129E5 E54670F1\r\n  SHA1(\"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq\"\r\n    in Unicode LE) =\r\n    51D7D876 9AC72C40 9C5B0E3F 69C60ADC 9A039014\r\n\r\n  SHA1(A million repetitions of \"a\" in ANSI) =\r\n    34AA973C D4C4DAA4 F61EEB2B DBAD2731 6534016F\r\n  SHA1(A million repetitions of \"a\" in Unicode LE) =\r\n    C4609560 A108A0C6 26AA7F2B 38A65566 739353C5\r\n*/\r\n\r\n#ifndef SHA1_H_A545E61D43E9404E8D736869AB3CBFE7\r\n#define SHA1_H_A545E61D43E9404E8D736869AB3CBFE7\r\n\r\n#if !defined(SHA1_UTILITY_FUNCTIONS) && !defined(SHA1_NO_UTILITY_FUNCTIONS)\r\n#define SHA1_UTILITY_FUNCTIONS\r\n#endif\r\n\r\n#if !defined(SHA1_STL_FUNCTIONS) && !defined(SHA1_NO_STL_FUNCTIONS)\r\n#define SHA1_STL_FUNCTIONS\r\n#if !defined(SHA1_UTILITY_FUNCTIONS)\r\n#error STL functions require SHA1_UTILITY_FUNCTIONS.\r\n#endif\r\n#endif\r\n\r\n#include <memory.h>\r\n#include <limits.h>\r\n\r\n#ifdef SHA1_UTILITY_FUNCTIONS\r\n#include <stdio.h>\r\n#include <string.h>\r\n#endif\r\n\r\n#ifdef SHA1_STL_FUNCTIONS\r\n#include <string>\r\n#endif\r\n\r\n#ifdef _MSC_VER\r\n#include <stdlib.h>\r\n#endif\r\n\r\n// You can define the endian mode in your files without modifying the SHA-1\r\n// source files. Just #define SHA1_LITTLE_ENDIAN or #define SHA1_BIG_ENDIAN\r\n// in your files, before including the SHA1.h header file. If you don't\r\n// define anything, the class defaults to little endian.\r\n#if !defined(SHA1_LITTLE_ENDIAN) && !defined(SHA1_BIG_ENDIAN)\r\n#define SHA1_LITTLE_ENDIAN\r\n#endif\r\n\r\n// If you want variable wiping, #define SHA1_WIPE_VARIABLES, if not,\r\n// #define SHA1_NO_WIPE_VARIABLES. If you don't define anything, it\r\n// defaults to wiping.\r\n#if !defined(SHA1_WIPE_VARIABLES) && !defined(SHA1_NO_WIPE_VARIABLES)\r\n#define SHA1_WIPE_VARIABLES\r\n#endif\r\n\r\n#if defined(SHA1_HAS_TCHAR)\r\n#include <tchar.h>\r\n#else\r\n#ifdef _MSC_VER\r\n#include <tchar.h>\r\n#else\r\n#ifndef TCHAR\r\n#define TCHAR char\r\n#endif\r\n#ifndef _T\r\n#define _T(__x) (__x)\r\n#define _tmain main\r\n#define _tprintf printf\r\n#define _getts gets\r\n#define _tcslen strlen\r\n#define _tfopen fopen\r\n#define _tcscpy strcpy\r\n#define _tcscat strcat\r\n#define _sntprintf snprintf\r\n#endif\r\n#endif\r\n#endif\r\n\r\n///////////////////////////////////////////////////////////////////////////\r\n// Define variable types\r\n\r\n#ifndef UINT_8\r\n#ifdef _MSC_VER // Compiling with Microsoft compiler\r\n#define UINT_8 unsigned __int8\r\n#else // !_MSC_VER\r\n#define UINT_8 unsigned char\r\n#endif // _MSC_VER\r\n#endif\r\n\r\n#ifndef UINT_32\r\n#ifdef _MSC_VER // Compiling with Microsoft compiler\r\n#define UINT_32 unsigned __int32\r\n#else // !_MSC_VER\r\n#if (ULONG_MAX == 0xFFFFFFFFUL)\r\n#define UINT_32 unsigned long\r\n#else\r\n#define UINT_32 unsigned int\r\n#endif\r\n#endif // _MSC_VER\r\n#endif // UINT_32\r\n\r\n#ifndef INT_64\r\n#ifdef _MSC_VER // Compiling with Microsoft compiler\r\n#define INT_64 __int64\r\n#else // !_MSC_VER\r\n#define INT_64 long long\r\n#endif // _MSC_VER\r\n#endif // INT_64\r\n\r\n#ifndef UINT_64\r\n#ifdef _MSC_VER // Compiling with Microsoft compiler\r\n#define UINT_64 unsigned __int64\r\n#else // !_MSC_VER\r\n#define UINT_64 unsigned long long\r\n#endif // _MSC_VER\r\n#endif // UINT_64\r\n\r\n///////////////////////////////////////////////////////////////////////////\r\n// Declare SHA-1 workspace\r\n\r\ntypedef union\r\n{\r\n\tUINT_8 c[64];\r\n\tUINT_32 l[16];\r\n} SHA1_WORKSPACE_BLOCK;\r\n\r\nclass CSHA1\r\n{\r\npublic:\r\n#ifdef SHA1_UTILITY_FUNCTIONS\r\n\t// Different formats for ReportHash(Stl)\r\n\tenum REPORT_TYPE\r\n\t{\r\n\t\tREPORT_HEX = 0,\r\n\t\tREPORT_DIGIT = 1,\r\n\t\tREPORT_HEX_SHORT = 2\r\n\t};\r\n#endif\r\n\r\n\t// Constructor and destructor\r\n\tCSHA1();\r\n\r\n#ifdef SHA1_WIPE_VARIABLES\r\n\t~CSHA1();\r\n#endif\r\n\r\n\tvoid Reset();\r\n\r\n\t// Hash in binary data and strings\r\n\tvoid Update(const UINT_8* pbData, UINT_32 uLen);\r\n\r\n#ifdef SHA1_UTILITY_FUNCTIONS\r\n\t// Hash in file contents\r\n\tbool HashFile(const TCHAR* tszFileName);\r\n#endif\r\n\r\n\t// Finalize hash; call it before using ReportHash(Stl)\r\n\tvoid Final();\r\n\r\n#ifdef SHA1_UTILITY_FUNCTIONS\r\n\tbool ReportHash(TCHAR* tszReport, REPORT_TYPE rtReportType = REPORT_HEX) const;\r\n#endif\r\n\r\n#ifdef SHA1_STL_FUNCTIONS\r\n\tbool ReportHashStl(std::basic_string<TCHAR>& strOut, REPORT_TYPE rtReportType =\r\n\t\tREPORT_HEX) const;\r\n#endif\r\n\r\n\t// Get the raw message digest (20 bytes)\r\n\tbool GetHash(UINT_8* pbDest20) const;\r\n\r\nprivate:\r\n\t// Private SHA-1 transformation\r\n\tvoid Transform(UINT_32* pState, const UINT_8* pBuffer);\r\n\r\n\t// Member variables\r\n\tUINT_32 m_state[5];\r\n\tUINT_32 m_count[2];\r\n\tUINT_32 m_reserved0[1]; // Memory alignment padding\r\n\tUINT_8 m_buffer[64];\r\n\tUINT_8 m_digest[20];\r\n\tUINT_32 m_reserved1[3]; // Memory alignment padding\r\n\r\n\tUINT_8 m_workspace[64];\r\n\tSHA1_WORKSPACE_BLOCK* m_block; // SHA1 pointer to the byte array above\r\n};\r\n\r\n#endif // SHA1_H_A545E61D43E9404E8D736869AB3CBFE7\r\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/SHA256/sha256.h",
    "content": "// //////////////////////////////////////////////////////////\n// sha256.h\n// Copyright (c) 2014,2015 Stephan Brumme. All rights reserved.\n// see http://create.stephan-brumme.com/disclaimer.html\n//\n\n#pragma once\n\n//#include \"hash.h\"\n#include <string>\n\n// define fixed size integer types\n#ifdef _MSC_VER\n// Windows\ntypedef unsigned __int8  uint8_t;\ntypedef unsigned __int32 uint32_t;\ntypedef unsigned __int64 uint64_t;\n#else\n// GCC\n#include <stdint.h>\n#endif\n\n\n/// compute SHA256 hash\n/** Usage:\n    SHA256 sha256;\n    std::string myHash  = sha256(\"Hello World\");     // std::string\n    std::string myHash2 = sha256(\"How are you\", 11); // arbitrary data, 11 bytes\n\n    // or in a streaming fashion:\n\n    SHA256 sha256;\n    while (more data available)\n      sha256.add(pointer to fresh data, number of new bytes);\n    std::string myHash3 = sha256.getHash();\n  */\nclass SHA256 //: public Hash\n{\npublic:\n  /// split into 64 byte blocks (=> 512 bits), hash is 32 bytes long\n  enum { BlockSize = 512 / 8, HashBytes = 32 };\n\n  /// same as reset()\n  SHA256();\n\n  /// compute SHA256 of a memory block\n  std::string operator()(const void* data, size_t numBytes);\n  /// compute SHA256 of a string, excluding final zero\n  std::string operator()(const std::string& text);\n\n  /// add arbitrary number of bytes\n  void add(const void* data, size_t numBytes);\n\n  /// return latest hash as 64 hex characters\n  std::string getHash();\n  /// return latest hash as bytes\n  void        getHash(unsigned char buffer[HashBytes]);\n\n  /// restart\n  void reset();\n\nprivate:\n  /// process 64 bytes\n  void processBlock(const void* data);\n  /// process everything left in the internal buffer\n  void processBuffer();\n\n  /// size of processed data in bytes\n  uint64_t m_numBytes;\n  /// valid bytes in m_buffer\n  size_t   m_bufferSize;\n  /// bytes not processed yet\n  uint8_t  m_buffer[BlockSize];\n\n  enum { HashValues = HashBytes / 4 };\n  /// hash, stored as integers\n  uint32_t m_hash[HashValues];\n};\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/aes/aes.h",
    "content": "/* The MIT License\n\n   Copyright (C) 2011 Zilong Tan (labytan@gmail.com)\n\n   Permission is hereby granted, free of charge, to any person obtaining\n   a copy of this software and associated documentation files (the\n   \"Software\"), to deal in the Software without restriction, including\n   without limitation the rights to use, copy, modify, merge, publish,\n   distribute, sublicense, and/or sell copies of the Software, and to\n   permit persons to whom the Software is furnished to do so, subject to\n   the following conditions:\n\n   The above copyright notice and this permission notice shall be\n   included in all copies or substantial portions of the Software.\n\n   THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n   NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS\n   BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\n   ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\n   CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n   SOFTWARE.\n*/\n\n/*\n * aes.h\n *\n * @version 3.0 (December 2000)\n *\n * Optimised ANSI C code for the Rijndael cipher (now AES)\n *\n * @author Vincent Rijmen <vincent.rijmen@esat.kuleuven.ac.be>\n * @author Antoon Bosselaers <antoon.bosselaers@esat.kuleuven.ac.be>\n * @author Paulo Barreto <paulo.barreto@terra.com.br>\n *\n * This code is hereby placed in the public domain.\n *\n * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ''AS IS'' AND ANY EXPRESS\n * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE\n * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,\n * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\n#ifndef __ULIB_AES_H\n#define __ULIB_AES_H\n\n#include <stdint.h>\n\n#define AES_MAXNR 14\n#define AES_BLOCK_SIZE 16\n\nstruct aes_key_st {\n        uint32_t rd_key[4 *(AES_MAXNR + 1)];\n        int rounds;\n};\n\ntypedef struct aes_key_st AES_KEY;\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n        /* bits can be 128, 192 or 256 */\n        int  AES_set_encrypt_key(const unsigned char *userKey, const int bits,\n                                AES_KEY *key);\n        int  AES_set_decrypt_key(const unsigned char *userKey, const int bits,\n                                AES_KEY *key);\n\n        /* in/out can be the same for ECB encryption/decryption */\n        void AES_encrypt(const unsigned char *in, unsigned char *out,\n                         const AES_KEY *key);\n        void AES_decrypt(const unsigned char *in, unsigned char *out,\n                         const AES_KEY *key);\n\n        /* in/out can be the same */\n        void AES_cbc_encrypt(const unsigned char *in, unsigned char *out, unsigned char *ivec,\n                             unsigned long nblock, const AES_KEY *key);\n\n        /* in/out MUST be DIFFERENT */\n        void AES_cbc_decrypt(const unsigned char *in, unsigned char *out, unsigned char *ivec,\n                             unsigned long nblock, const AES_KEY *key);\n\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/base64/base64.h",
    "content": "#include <string>\n\nstd::string base64_encode(unsigned char const* , unsigned int len);\nstd::string base64_decode(std::string const& s);\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/json/assertions.h",
    "content": "// Copyright 2007-2010 Baptiste Lepilleur\n// Distributed under MIT license, or public domain if desired and\n// recognized in your jurisdiction.\n// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE\n\n#ifndef CPPTL_JSON_ASSERTIONS_H_INCLUDED\n#define CPPTL_JSON_ASSERTIONS_H_INCLUDED\n\n#include <stdlib.h>\n\n#if !defined(JSON_IS_AMALGAMATION)\n#include \"config.h\"\n#endif // if !defined(JSON_IS_AMALGAMATION)\n\n#if JSON_USE_EXCEPTION\n#include <stdexcept>\n#define JSON_ASSERT(condition)                                                 \\\n  assert(condition); // @todo <= change this into an exception throw\n#define JSON_FAIL_MESSAGE(message) throw std::runtime_error(message);\n#else // JSON_USE_EXCEPTION\n#define JSON_ASSERT(condition) assert(condition);\n\n// The call to assert() will show the failure message in debug builds. In\n// release bugs we write to invalid memory in order to crash hard, so that a\n// debugger or crash reporter gets the chance to take over. We still call exit()\n// afterward in order to tell the compiler that this macro doesn't return.\n#define JSON_FAIL_MESSAGE(message)                                             \\\n  {                                                                            \\\n    assert(false &&message);                                                   \\\n    strcpy(reinterpret_cast<char *>(666), message);                            \\\n    exit(123);                                                                 \\\n  }\n\n#endif\n\n#define JSON_ASSERT_MESSAGE(condition, message)                                \\\n  if (!(condition)) {                                                          \\\n    JSON_FAIL_MESSAGE(message)                                                 \\\n  }\n\n#endif // CPPTL_JSON_ASSERTIONS_H_INCLUDED\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/json/autolink.h",
    "content": "// Copyright 2007-2010 Baptiste Lepilleur\n// Distributed under MIT license, or public domain if desired and\n// recognized in your jurisdiction.\n// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE\n\n#ifndef JSON_AUTOLINK_H_INCLUDED\n#define JSON_AUTOLINK_H_INCLUDED\n\n#include \"config.h\"\n\n#ifdef JSON_IN_CPPTL\n#include <cpptl/cpptl_autolink.h>\n#endif\n\n#if !defined(JSON_NO_AUTOLINK) && !defined(JSON_DLL_BUILD) &&                  \\\n    !defined(JSON_IN_CPPTL)\n#define CPPTL_AUTOLINK_NAME \"json\"\n#undef CPPTL_AUTOLINK_DLL\n#ifdef JSON_DLL\n#define CPPTL_AUTOLINK_DLL\n#endif\n#include \"autolink.h\"\n#endif\n\n#endif // JSON_AUTOLINK_H_INCLUDED\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/json/config.h",
    "content": "// Copyright 2007-2010 Baptiste Lepilleur\n// Distributed under MIT license, or public domain if desired and\n// recognized in your jurisdiction.\n// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE\n\n#ifndef JSON_CONFIG_H_INCLUDED\n#define JSON_CONFIG_H_INCLUDED\n\n/// If defined, indicates that json library is embedded in CppTL library.\n//# define JSON_IN_CPPTL 1\n\n/// If defined, indicates that json may leverage CppTL library\n//#  define JSON_USE_CPPTL 1\n/// If defined, indicates that cpptl vector based map should be used instead of\n/// std::map\n/// as Value container.\n//#  define JSON_USE_CPPTL_SMALLMAP 1\n/// If defined, indicates that Json specific container should be used\n/// (hash table & simple deque container with customizable allocator).\n/// THIS FEATURE IS STILL EXPERIMENTAL! There is know bugs: See #3177332\n//#  define JSON_VALUE_USE_INTERNAL_MAP 1\n/// Force usage of standard new/malloc based allocator instead of memory pool\n/// based allocator.\n/// The memory pools allocator used optimization (initializing Value and\n/// ValueInternalLink\n/// as if it was a POD) that may cause some validation tool to report errors.\n/// Only has effects if JSON_VALUE_USE_INTERNAL_MAP is defined.\n//#  define JSON_USE_SIMPLE_INTERNAL_ALLOCATOR 1\n\n// If non-zero, the library uses exceptions to report bad input instead of C\n// assertion macros. The default is to use exceptions.\n#ifndef JSON_USE_EXCEPTION\n#define JSON_USE_EXCEPTION 1\n#endif\n\n/// If defined, indicates that the source file is amalgated\n/// to prevent private header inclusion.\n/// Remarks: it is automatically defined in the generated amalgated header.\n// #define JSON_IS_AMALGAMATION\n\n#ifdef JSON_IN_CPPTL\n#include <cpptl/config.h>\n#ifndef JSON_USE_CPPTL\n#define JSON_USE_CPPTL 1\n#endif\n#endif\n\n#ifdef JSON_IN_CPPTL\n#define JSON_API CPPTL_API\n#elif defined(JSON_DLL_BUILD)\n#if defined(_MSC_VER)\n#define JSON_API __declspec(dllexport)\n#define JSONCPP_DISABLE_DLL_INTERFACE_WARNING\n#endif // if defined(_MSC_VER)\n#elif defined(JSON_DLL)\n#if defined(_MSC_VER)\n#define JSON_API __declspec(dllimport)\n#define JSONCPP_DISABLE_DLL_INTERFACE_WARNING\n#endif // if defined(_MSC_VER)\n#endif // ifdef JSON_IN_CPPTL\n#if !defined(JSON_API)\n#define JSON_API\n#endif\n\n// If JSON_NO_INT64 is defined, then Json only support C++ \"int\" type for\n// integer\n// Storages, and 64 bits integer support is disabled.\n// #define JSON_NO_INT64 1\n\n#if defined(_MSC_VER) && _MSC_VER <= 1200 // MSVC 6\n// Microsoft Visual Studio 6 only support conversion from __int64 to double\n// (no conversion from unsigned __int64).\n#define JSON_USE_INT64_DOUBLE_CONVERSION 1\n// Disable warning 4786 for VS6 caused by STL (identifier was truncated to '255'\n// characters in the debug information)\n// All projects I've ever seen with VS6 were using this globally (not bothering\n// with pragma push/pop).\n#pragma warning(disable : 4786)\n#endif // if defined(_MSC_VER)  &&  _MSC_VER < 1200 // MSVC 6\n\n#if defined(_MSC_VER) && _MSC_VER >= 1500 // MSVC 2008\n/// Indicates that the following function is deprecated.\n#define JSONCPP_DEPRECATED(message) __declspec(deprecated(message))\n#endif\n\n#if !defined(JSONCPP_DEPRECATED)\n#define JSONCPP_DEPRECATED(message)\n#endif // if !defined(JSONCPP_DEPRECATED)\n\nnamespace Json {\ntypedef int Int;\ntypedef unsigned int UInt;\n#if defined(JSON_NO_INT64)\ntypedef int LargestInt;\ntypedef unsigned int LargestUInt;\n#undef JSON_HAS_INT64\n#else                 // if defined(JSON_NO_INT64)\n// For Microsoft Visual use specific types as long long is not supported\n#if defined(_MSC_VER) // Microsoft Visual Studio\ntypedef __int64 Int64;\ntypedef unsigned __int64 UInt64;\n#else                 // if defined(_MSC_VER) // Other platforms, use long long\ntypedef long long int Int64;\ntypedef unsigned long long int UInt64;\n#endif // if defined(_MSC_VER)\ntypedef Int64 LargestInt;\ntypedef UInt64 LargestUInt;\n#define JSON_HAS_INT64\n#endif // if defined(JSON_NO_INT64)\n} // end namespace Json\n\n#endif // JSON_CONFIG_H_INCLUDED\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/json/features.h",
    "content": "// Copyright 2007-2010 Baptiste Lepilleur\n// Distributed under MIT license, or public domain if desired and\n// recognized in your jurisdiction.\n// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE\n\n#ifndef CPPTL_JSON_FEATURES_H_INCLUDED\n#define CPPTL_JSON_FEATURES_H_INCLUDED\n\n#if !defined(JSON_IS_AMALGAMATION)\n#include \"forwards.h\"\n#endif // if !defined(JSON_IS_AMALGAMATION)\n\nnamespace Json {\n\n/** \\brief Configuration passed to reader and writer.\n * This configuration object can be used to force the Reader or Writer\n * to behave in a standard conforming way.\n */\nclass JSON_API Features {\npublic:\n  /** \\brief A configuration that allows all features and assumes all strings\n   * are UTF-8.\n   * - C & C++ comments are allowed\n   * - Root object can be any JSON value\n   * - Assumes Value strings are encoded in UTF-8\n   */\n  static Features all();\n\n  /** \\brief A configuration that is strictly compatible with the JSON\n   * specification.\n   * - Comments are forbidden.\n   * - Root object must be either an array or an object value.\n   * - Assumes Value strings are encoded in UTF-8\n   */\n  static Features strictMode();\n\n  /** \\brief Initialize the configuration like JsonConfig::allFeatures;\n   */\n  Features();\n\n  /// \\c true if comments are allowed. Default: \\c true.\n  bool allowComments_;\n\n  /// \\c true if root must be either an array or an object value. Default: \\c\n  /// false.\n  bool strictRoot_;\n\n  /// \\c true if dropped null placeholders are allowed. Default: \\c false.\n  bool allowDroppedNullPlaceholders_;\n\n  /// \\c true if numeric object key are allowed. Default: \\c false.\n  bool allowNumericKeys_;\n};\n\n} // namespace Json\n\n#endif // CPPTL_JSON_FEATURES_H_INCLUDED\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/json/forwards.h",
    "content": "// Copyright 2007-2010 Baptiste Lepilleur\n// Distributed under MIT license, or public domain if desired and\n// recognized in your jurisdiction.\n// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE\n\n#ifndef JSON_FORWARDS_H_INCLUDED\n#define JSON_FORWARDS_H_INCLUDED\n\n#if !defined(JSON_IS_AMALGAMATION)\n#include \"config.h\"\n#endif // if !defined(JSON_IS_AMALGAMATION)\n\nnamespace Json {\n\n// writer.h\nclass FastWriter;\nclass StyledWriter;\n\n// reader.h\nclass Reader;\n\n// features.h\nclass Features;\n\n// value.h\ntypedef unsigned int ArrayIndex;\nclass StaticString;\nclass Path;\nclass PathArgument;\nclass Value;\nclass ValueIteratorBase;\nclass ValueIterator;\nclass ValueConstIterator;\n#ifdef JSON_VALUE_USE_INTERNAL_MAP\nclass ValueMapAllocator;\nclass ValueInternalLink;\nclass ValueInternalArray;\nclass ValueInternalMap;\n#endif // #ifdef JSON_VALUE_USE_INTERNAL_MAP\n\n} // namespace Json\n\n#endif // JSON_FORWARDS_H_INCLUDED\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/json/json.h",
    "content": "// Copyright 2007-2010 Baptiste Lepilleur\n// Distributed under MIT license, or public domain if desired and\n// recognized in your jurisdiction.\n// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE\n\n#ifndef JSON_JSON_H_INCLUDED\n#define JSON_JSON_H_INCLUDED\n\n#include \"autolink.h\"\n#include \"value.h\"\n#include \"reader.h\"\n#include \"writer.h\"\n#include \"features.h\"\n\n#endif // JSON_JSON_H_INCLUDED\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/json/json_batchallocator.h",
    "content": "// Copyright 2007-2010 Baptiste Lepilleur\n// Distributed under MIT license, or public domain if desired and\n// recognized in your jurisdiction.\n// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE\n\n#ifndef JSONCPP_BATCHALLOCATOR_H_INCLUDED\n#define JSONCPP_BATCHALLOCATOR_H_INCLUDED\n\n#include <stdlib.h>\n#include <assert.h>\n\n#ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION\n\nnamespace Json {\n\n/* Fast memory allocator.\n *\n * This memory allocator allocates memory for a batch of object (specified by\n * the page size, the number of object in each page).\n *\n * It does not allow the destruction of a single object. All the allocated\n * objects can be destroyed at once. The memory can be either released or reused\n * for future allocation.\n *\n * The in-place new operator must be used to construct the object using the\n * pointer returned by allocate.\n */\ntemplate <typename AllocatedType, const unsigned int objectPerAllocation>\nclass BatchAllocator {\npublic:\n  BatchAllocator(unsigned int objectsPerPage = 255)\n      : freeHead_(0), objectsPerPage_(objectsPerPage) {\n    //      printf( \"Size: %d => %s\\n\", sizeof(AllocatedType),\n    // typeid(AllocatedType).name() );\n    assert(sizeof(AllocatedType) * objectPerAllocation >=\n           sizeof(AllocatedType *)); // We must be able to store a slist in the\n                                     // object free space.\n    assert(objectsPerPage >= 16);\n    batches_ = allocateBatch(0); // allocated a dummy page\n    currentBatch_ = batches_;\n  }\n\n  ~BatchAllocator() {\n    for (BatchInfo *batch = batches_; batch;) {\n      BatchInfo *nextBatch = batch->next_;\n      free(batch);\n      batch = nextBatch;\n    }\n  }\n\n  /// allocate space for an array of objectPerAllocation object.\n  /// @warning it is the responsability of the caller to call objects\n  /// constructors.\n  AllocatedType *allocate() {\n    if (freeHead_) // returns node from free list.\n    {\n      AllocatedType *object = freeHead_;\n      freeHead_ = *(AllocatedType **)object;\n      return object;\n    }\n    if (currentBatch_->used_ == currentBatch_->end_) {\n      currentBatch_ = currentBatch_->next_;\n      while (currentBatch_ && currentBatch_->used_ == currentBatch_->end_)\n        currentBatch_ = currentBatch_->next_;\n\n      if (!currentBatch_) // no free batch found, allocate a new one\n      {\n        currentBatch_ = allocateBatch(objectsPerPage_);\n        currentBatch_->next_ = batches_; // insert at the head of the list\n        batches_ = currentBatch_;\n      }\n    }\n    AllocatedType *allocated = currentBatch_->used_;\n    currentBatch_->used_ += objectPerAllocation;\n    return allocated;\n  }\n\n  /// Release the object.\n  /// @warning it is the responsability of the caller to actually destruct the\n  /// object.\n  void release(AllocatedType *object) {\n    assert(object != 0);\n    *(AllocatedType **)object = freeHead_;\n    freeHead_ = object;\n  }\n\nprivate:\n  struct BatchInfo {\n    BatchInfo *next_;\n    AllocatedType *used_;\n    AllocatedType *end_;\n    AllocatedType buffer_[objectPerAllocation];\n  };\n\n  // disabled copy constructor and assignement operator.\n  BatchAllocator(const BatchAllocator &);\n  void operator=(const BatchAllocator &);\n\n  static BatchInfo *allocateBatch(unsigned int objectsPerPage) {\n    const unsigned int mallocSize =\n        sizeof(BatchInfo) - sizeof(AllocatedType) * objectPerAllocation +\n        sizeof(AllocatedType) * objectPerAllocation * objectsPerPage;\n    BatchInfo *batch = static_cast<BatchInfo *>(malloc(mallocSize));\n    batch->next_ = 0;\n    batch->used_ = batch->buffer_;\n    batch->end_ = batch->buffer_ + objectsPerPage;\n    return batch;\n  }\n\n  BatchInfo *batches_;\n  BatchInfo *currentBatch_;\n  /// Head of a single linked list within the allocated space of freeed object\n  AllocatedType *freeHead_;\n  unsigned int objectsPerPage_;\n};\n\n} // namespace Json\n\n#endif // ifndef JSONCPP_DOC_INCLUDE_IMPLEMENTATION\n\n#endif // JSONCPP_BATCHALLOCATOR_H_INCLUDED\n// vim: et ts=2 sts=2 sw=2 tw=0\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/json/json_internalarray.inl",
    "content": "// Copyright 2007-2010 Baptiste Lepilleur\n// Distributed under MIT license, or public domain if desired and\n// recognized in your jurisdiction.\n// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE\n\n// included by json_value.cpp\n\nnamespace Json {\n\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// class ValueInternalArray\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n\nValueArrayAllocator::~ValueArrayAllocator()\n{\n}\n\n// //////////////////////////////////////////////////////////////////\n// class DefaultValueArrayAllocator\n// //////////////////////////////////////////////////////////////////\n#ifdef JSON_USE_SIMPLE_INTERNAL_ALLOCATOR\nclass DefaultValueArrayAllocator : public ValueArrayAllocator\n{\npublic: // overridden from ValueArrayAllocator\n   virtual ~DefaultValueArrayAllocator()\n   {\n   }\n\n   virtual ValueInternalArray *newArray()\n   {\n      return new ValueInternalArray();\n   }\n\n   virtual ValueInternalArray *newArrayCopy( const ValueInternalArray &other )\n   {\n      return new ValueInternalArray( other );\n   }\n\n   virtual void destructArray( ValueInternalArray *array )\n   {\n      delete array;\n   }\n\n   virtual void reallocateArrayPageIndex( Value **&indexes, \n                                          ValueInternalArray::PageIndex &indexCount,\n                                          ValueInternalArray::PageIndex minNewIndexCount )\n   {\n      ValueInternalArray::PageIndex newIndexCount = (indexCount*3)/2 + 1;\n      if ( minNewIndexCount > newIndexCount )\n         newIndexCount = minNewIndexCount;\n      void *newIndexes = realloc( indexes, sizeof(Value*) * newIndexCount );\n      JSON_ASSERT_MESSAGE(newIndexes, \"Couldn't realloc.\");\n      indexCount = newIndexCount;\n      indexes = static_cast<Value **>( newIndexes );\n   }\n   virtual void releaseArrayPageIndex( Value **indexes, \n                                       ValueInternalArray::PageIndex indexCount )\n   {\n      if ( indexes )\n         free( indexes );\n   }\n\n   virtual Value *allocateArrayPage()\n   {\n      return static_cast<Value *>( malloc( sizeof(Value) * ValueInternalArray::itemsPerPage ) );\n   }\n\n   virtual void releaseArrayPage( Value *value )\n   {\n      if ( value )\n         free( value );\n   }\n};\n\n#else // #ifdef JSON_USE_SIMPLE_INTERNAL_ALLOCATOR\n/// @todo make this thread-safe (lock when accessign batch allocator)\nclass DefaultValueArrayAllocator : public ValueArrayAllocator\n{\npublic: // overridden from ValueArrayAllocator\n   virtual ~DefaultValueArrayAllocator()\n   {\n   }\n\n   virtual ValueInternalArray *newArray()\n   {\n      ValueInternalArray *array = arraysAllocator_.allocate();\n      new (array) ValueInternalArray(); // placement new\n      return array;\n   }\n\n   virtual ValueInternalArray *newArrayCopy( const ValueInternalArray &other )\n   {\n      ValueInternalArray *array = arraysAllocator_.allocate();\n      new (array) ValueInternalArray( other ); // placement new\n      return array;\n   }\n\n   virtual void destructArray( ValueInternalArray *array )\n   {\n      if ( array )\n      {\n         array->~ValueInternalArray();\n         arraysAllocator_.release( array );\n      }\n   }\n\n   virtual void reallocateArrayPageIndex( Value **&indexes, \n                                          ValueInternalArray::PageIndex &indexCount,\n                                          ValueInternalArray::PageIndex minNewIndexCount )\n   {\n      ValueInternalArray::PageIndex newIndexCount = (indexCount*3)/2 + 1;\n      if ( minNewIndexCount > newIndexCount )\n         newIndexCount = minNewIndexCount;\n      void *newIndexes = realloc( indexes, sizeof(Value*) * newIndexCount );\n      JSON_ASSERT_MESSAGE(newIndexes, \"Couldn't realloc.\");\n      indexCount = newIndexCount;\n      indexes = static_cast<Value **>( newIndexes );\n   }\n   virtual void releaseArrayPageIndex( Value **indexes, \n                                       ValueInternalArray::PageIndex indexCount )\n   {\n      if ( indexes )\n         free( indexes );\n   }\n\n   virtual Value *allocateArrayPage()\n   {\n      return static_cast<Value *>( pagesAllocator_.allocate() );\n   }\n\n   virtual void releaseArrayPage( Value *value )\n   {\n      if ( value )\n         pagesAllocator_.release( value );\n   }\nprivate:\n   BatchAllocator<ValueInternalArray,1> arraysAllocator_;\n   BatchAllocator<Value,ValueInternalArray::itemsPerPage> pagesAllocator_;\n};\n#endif // #ifdef JSON_USE_SIMPLE_INTERNAL_ALLOCATOR\n\nstatic ValueArrayAllocator *&arrayAllocator()\n{\n   static DefaultValueArrayAllocator defaultAllocator;\n   static ValueArrayAllocator *arrayAllocator = &defaultAllocator;\n   return arrayAllocator;\n}\n\nstatic struct DummyArrayAllocatorInitializer {\n   DummyArrayAllocatorInitializer() \n   {\n      arrayAllocator();      // ensure arrayAllocator() statics are initialized before main().\n   }\n} dummyArrayAllocatorInitializer;\n\n// //////////////////////////////////////////////////////////////////\n// class ValueInternalArray\n// //////////////////////////////////////////////////////////////////\nbool \nValueInternalArray::equals( const IteratorState &x, \n                            const IteratorState &other )\n{\n   return x.array_ == other.array_  \n          &&  x.currentItemIndex_ == other.currentItemIndex_  \n          &&  x.currentPageIndex_ == other.currentPageIndex_;\n}\n\n\nvoid \nValueInternalArray::increment( IteratorState &it )\n{\n   JSON_ASSERT_MESSAGE( it.array_  &&\n      (it.currentPageIndex_ - it.array_->pages_)*itemsPerPage + it.currentItemIndex_\n      != it.array_->size_,\n      \"ValueInternalArray::increment(): moving iterator beyond end\" );\n   ++(it.currentItemIndex_);\n   if ( it.currentItemIndex_ == itemsPerPage )\n   {\n      it.currentItemIndex_ = 0;\n      ++(it.currentPageIndex_);\n   }\n}\n\n\nvoid \nValueInternalArray::decrement( IteratorState &it )\n{\n   JSON_ASSERT_MESSAGE( it.array_  &&  it.currentPageIndex_ == it.array_->pages_ \n                        &&  it.currentItemIndex_ == 0,\n      \"ValueInternalArray::decrement(): moving iterator beyond end\" );\n   if ( it.currentItemIndex_ == 0 )\n   {\n      it.currentItemIndex_ = itemsPerPage-1;\n      --(it.currentPageIndex_);\n   }\n   else\n   {\n      --(it.currentItemIndex_);\n   }\n}\n\n\nValue &\nValueInternalArray::unsafeDereference( const IteratorState &it )\n{\n   return (*(it.currentPageIndex_))[it.currentItemIndex_];\n}\n\n\nValue &\nValueInternalArray::dereference( const IteratorState &it )\n{\n   JSON_ASSERT_MESSAGE( it.array_  &&\n      (it.currentPageIndex_ - it.array_->pages_)*itemsPerPage + it.currentItemIndex_\n      < it.array_->size_,\n      \"ValueInternalArray::dereference(): dereferencing invalid iterator\" );\n   return unsafeDereference( it );\n}\n\nvoid \nValueInternalArray::makeBeginIterator( IteratorState &it ) const\n{\n   it.array_ = const_cast<ValueInternalArray *>( this );\n   it.currentItemIndex_ = 0;\n   it.currentPageIndex_ = pages_;\n}\n\n\nvoid \nValueInternalArray::makeIterator( IteratorState &it, ArrayIndex index ) const\n{\n   it.array_ = const_cast<ValueInternalArray *>( this );\n   it.currentItemIndex_ = index % itemsPerPage;\n   it.currentPageIndex_ = pages_ + index / itemsPerPage;\n}\n\n\nvoid \nValueInternalArray::makeEndIterator( IteratorState &it ) const\n{\n   makeIterator( it, size_ );\n}\n\n\nValueInternalArray::ValueInternalArray()\n   : pages_( 0 )\n   , size_( 0 )\n   , pageCount_( 0 )\n{\n}\n\n\nValueInternalArray::ValueInternalArray( const ValueInternalArray &other )\n   : pages_( 0 )\n   , size_( other.size_ )\n   , pageCount_( 0 )\n{\n   PageIndex minNewPages = other.size_ / itemsPerPage;\n   arrayAllocator()->reallocateArrayPageIndex( pages_, pageCount_, minNewPages );\n   JSON_ASSERT_MESSAGE( pageCount_ >= minNewPages, \n                        \"ValueInternalArray::reserve(): bad reallocation\" );\n   IteratorState itOther;\n   other.makeBeginIterator( itOther );\n   Value *value;\n   for ( ArrayIndex index = 0; index < size_; ++index, increment(itOther) )\n   {\n      if ( index % itemsPerPage == 0 )\n      {\n         PageIndex pageIndex = index / itemsPerPage;\n         value = arrayAllocator()->allocateArrayPage();\n         pages_[pageIndex] = value;\n      }\n      new (value) Value( dereference( itOther ) );\n   }\n}\n\n\nValueInternalArray &\nValueInternalArray::operator=(ValueInternalArray other)\n{\n   swap(other);\n   return *this;\n}\n\n\nValueInternalArray::~ValueInternalArray()\n{\n   // destroy all constructed items\n   IteratorState it;\n   IteratorState itEnd;\n   makeBeginIterator( it);\n   makeEndIterator( itEnd );\n   for ( ; !equals(it,itEnd); increment(it) )\n   {\n      Value *value = &dereference(it);\n      value->~Value();\n   }\n   // release all pages\n   PageIndex lastPageIndex = size_ / itemsPerPage;\n   for ( PageIndex pageIndex = 0; pageIndex < lastPageIndex; ++pageIndex )\n      arrayAllocator()->releaseArrayPage( pages_[pageIndex] );\n   // release pages index\n   arrayAllocator()->releaseArrayPageIndex( pages_, pageCount_ );\n}\n\n\nvoid \nValueInternalArray::swap( ValueInternalArray &other )\n{\n   Value **tempPages = pages_;\n   pages_ = other.pages_;\n   other.pages_ = tempPages;\n   ArrayIndex tempSize = size_;\n   size_ = other.size_;\n   other.size_ = tempSize;\n   PageIndex tempPageCount = pageCount_;\n   pageCount_ = other.pageCount_;\n   other.pageCount_ = tempPageCount;\n}\n\nvoid \nValueInternalArray::clear()\n{\n   ValueInternalArray dummy;\n   swap( dummy );\n}\n\n\nvoid \nValueInternalArray::resize( ArrayIndex newSize )\n{\n   if ( newSize == 0 )\n      clear();\n   else if ( newSize < size_ )\n   {\n      IteratorState it;\n      IteratorState itEnd;\n      makeIterator( it, newSize );\n      makeIterator( itEnd, size_ );\n      for ( ; !equals(it,itEnd); increment(it) )\n      {\n         Value *value = &dereference(it);\n         value->~Value();\n      }\n      PageIndex pageIndex = (newSize + itemsPerPage - 1) / itemsPerPage;\n      PageIndex lastPageIndex = size_ / itemsPerPage;\n      for ( ; pageIndex < lastPageIndex; ++pageIndex )\n         arrayAllocator()->releaseArrayPage( pages_[pageIndex] );\n      size_ = newSize;\n   }\n   else if ( newSize > size_ )\n      resolveReference( newSize );\n}\n\n\nvoid \nValueInternalArray::makeIndexValid( ArrayIndex index )\n{\n   // Need to enlarge page index ?\n   if ( index >= pageCount_ * itemsPerPage )\n   {\n      PageIndex minNewPages = (index + 1) / itemsPerPage;\n      arrayAllocator()->reallocateArrayPageIndex( pages_, pageCount_, minNewPages );\n      JSON_ASSERT_MESSAGE( pageCount_ >= minNewPages, \"ValueInternalArray::reserve(): bad reallocation\" );\n   }\n\n   // Need to allocate new pages ?\n   ArrayIndex nextPageIndex = \n      (size_ % itemsPerPage) != 0 ? size_ - (size_%itemsPerPage) + itemsPerPage\n                                  : size_;\n   if ( nextPageIndex <= index )\n   {\n      PageIndex pageIndex = nextPageIndex / itemsPerPage;\n      PageIndex pageToAllocate = (index - nextPageIndex) / itemsPerPage + 1;\n      for ( ; pageToAllocate-- > 0; ++pageIndex )\n         pages_[pageIndex] = arrayAllocator()->allocateArrayPage();\n   }\n\n   // Initialize all new entries\n   IteratorState it;\n   IteratorState itEnd;\n   makeIterator( it, size_ );\n   size_ = index + 1;\n   makeIterator( itEnd, size_ );\n   for ( ; !equals(it,itEnd); increment(it) )\n   {\n      Value *value = &dereference(it);\n      new (value) Value(); // Construct a default value using placement new\n   }\n}\n\nValue &\nValueInternalArray::resolveReference( ArrayIndex index )\n{\n   if ( index >= size_ )\n      makeIndexValid( index );\n   return pages_[index/itemsPerPage][index%itemsPerPage];\n}\n\nValue *\nValueInternalArray::find( ArrayIndex index ) const\n{\n   if ( index >= size_ )\n      return 0;\n   return &(pages_[index/itemsPerPage][index%itemsPerPage]);\n}\n\nValueInternalArray::ArrayIndex \nValueInternalArray::size() const\n{\n   return size_;\n}\n\nint \nValueInternalArray::distance( const IteratorState &x, const IteratorState &y )\n{\n   return indexOf(y) - indexOf(x);\n}\n\n\nValueInternalArray::ArrayIndex \nValueInternalArray::indexOf( const IteratorState &iterator )\n{\n   if ( !iterator.array_ )\n      return ArrayIndex(-1);\n   return ArrayIndex(\n      (iterator.currentPageIndex_ - iterator.array_->pages_) * itemsPerPage \n      + iterator.currentItemIndex_ );\n}\n\n\nint \nValueInternalArray::compare( const ValueInternalArray &other ) const\n{\n   int sizeDiff( size_ - other.size_ );\n   if ( sizeDiff != 0 )\n      return sizeDiff;\n   \n   for ( ArrayIndex index =0; index < size_; ++index )\n   {\n      int diff = pages_[index/itemsPerPage][index%itemsPerPage].compare( \n         other.pages_[index/itemsPerPage][index%itemsPerPage] );\n      if ( diff != 0 )\n         return diff;\n   }\n   return 0;\n}\n\n} // namespace Json\n// vim: et ts=3 sts=3 sw=3 tw=0\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/json/json_internalmap.inl",
    "content": "// Copyright 2007-2010 Baptiste Lepilleur\n// Distributed under MIT license, or public domain if desired and\n// recognized in your jurisdiction.\n// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE\n\n// included by json_value.cpp\n\nnamespace Json {\n\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// class ValueInternalMap\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n\n/** \\internal MUST be safely initialized using memset( this, 0, sizeof(ValueInternalLink) );\n   * This optimization is used by the fast allocator.\n   */\nValueInternalLink::ValueInternalLink()\n   : previous_( 0 )\n   , next_( 0 )\n{\n}\n\nValueInternalLink::~ValueInternalLink()\n{ \n   for ( int index =0; index < itemPerLink; ++index )\n   {\n      if ( !items_[index].isItemAvailable() )\n      {\n         if ( !items_[index].isMemberNameStatic() )\n            free( keys_[index] );\n      }\n      else\n         break;\n   }\n}\n\n\n\nValueMapAllocator::~ValueMapAllocator()\n{\n}\n\n#ifdef JSON_USE_SIMPLE_INTERNAL_ALLOCATOR\nclass DefaultValueMapAllocator : public ValueMapAllocator\n{\npublic: // overridden from ValueMapAllocator\n   virtual ValueInternalMap *newMap()\n   {\n      return new ValueInternalMap();\n   }\n\n   virtual ValueInternalMap *newMapCopy( const ValueInternalMap &other )\n   {\n      return new ValueInternalMap( other );\n   }\n\n   virtual void destructMap( ValueInternalMap *map )\n   {\n      delete map;\n   }\n\n   virtual ValueInternalLink *allocateMapBuckets( unsigned int size )\n   {\n      return new ValueInternalLink[size];\n   }\n\n   virtual void releaseMapBuckets( ValueInternalLink *links )\n   {\n      delete [] links;\n   }\n\n   virtual ValueInternalLink *allocateMapLink()\n   {\n      return new ValueInternalLink();\n   }\n\n   virtual void releaseMapLink( ValueInternalLink *link )\n   {\n      delete link;\n   }\n};\n#else\n/// @todo make this thread-safe (lock when accessign batch allocator)\nclass DefaultValueMapAllocator : public ValueMapAllocator\n{\npublic: // overridden from ValueMapAllocator\n   virtual ValueInternalMap *newMap()\n   {\n      ValueInternalMap *map = mapsAllocator_.allocate();\n      new (map) ValueInternalMap(); // placement new\n      return map;\n   }\n\n   virtual ValueInternalMap *newMapCopy( const ValueInternalMap &other )\n   {\n      ValueInternalMap *map = mapsAllocator_.allocate();\n      new (map) ValueInternalMap( other ); // placement new\n      return map;\n   }\n\n   virtual void destructMap( ValueInternalMap *map )\n   {\n      if ( map )\n      {\n         map->~ValueInternalMap();\n         mapsAllocator_.release( map );\n      }\n   }\n\n   virtual ValueInternalLink *allocateMapBuckets( unsigned int size )\n   {\n      return new ValueInternalLink[size];\n   }\n\n   virtual void releaseMapBuckets( ValueInternalLink *links )\n   {\n      delete [] links;\n   }\n\n   virtual ValueInternalLink *allocateMapLink()\n   {\n      ValueInternalLink *link = linksAllocator_.allocate();\n      memset( link, 0, sizeof(ValueInternalLink) );\n      return link;\n   }\n\n   virtual void releaseMapLink( ValueInternalLink *link )\n   {\n      link->~ValueInternalLink();\n      linksAllocator_.release( link );\n   }\nprivate:\n   BatchAllocator<ValueInternalMap,1> mapsAllocator_;\n   BatchAllocator<ValueInternalLink,1> linksAllocator_;\n};\n#endif\n\nstatic ValueMapAllocator *&mapAllocator()\n{\n   static DefaultValueMapAllocator defaultAllocator;\n   static ValueMapAllocator *mapAllocator = &defaultAllocator;\n   return mapAllocator;\n}\n\nstatic struct DummyMapAllocatorInitializer {\n   DummyMapAllocatorInitializer() \n   {\n      mapAllocator();      // ensure mapAllocator() statics are initialized before main().\n   }\n} dummyMapAllocatorInitializer;\n\n\n\n// h(K) = value * K >> w ; with w = 32 & K prime w.r.t. 2^32.\n\n/*\nuse linked list hash map. \nbuckets array is a container.\nlinked list element contains 6 key/values. (memory = (16+4) * 6 + 4 = 124)\nvalue have extra state: valid, available, deleted\n*/\n\n\nValueInternalMap::ValueInternalMap()\n   : buckets_( 0 )\n   , tailLink_( 0 )\n   , bucketsSize_( 0 )\n   , itemCount_( 0 )\n{\n}\n\n\nValueInternalMap::ValueInternalMap( const ValueInternalMap &other )\n   : buckets_( 0 )\n   , tailLink_( 0 )\n   , bucketsSize_( 0 )\n   , itemCount_( 0 )\n{\n   reserve( other.itemCount_ );\n   IteratorState it;\n   IteratorState itEnd;\n   other.makeBeginIterator( it );\n   other.makeEndIterator( itEnd );\n   for ( ; !equals(it,itEnd); increment(it) )\n   {\n      bool isStatic;\n      const char *memberName = key( it, isStatic );\n      const Value &aValue = value( it );\n      resolveReference(memberName, isStatic) = aValue;\n   }\n}\n\n\nValueInternalMap &\nValueInternalMap::operator=(ValueInternalMap other)\n{\n   swap(other);\n   return *this;\n}\n\n\nValueInternalMap::~ValueInternalMap()\n{\n   if ( buckets_ )\n   {\n      for ( BucketIndex bucketIndex =0; bucketIndex < bucketsSize_; ++bucketIndex )\n      {\n         ValueInternalLink *link = buckets_[bucketIndex].next_;\n         while ( link )\n         {\n            ValueInternalLink *linkToRelease = link;\n            link = link->next_;\n            mapAllocator()->releaseMapLink( linkToRelease );\n         }\n      }\n      mapAllocator()->releaseMapBuckets( buckets_ );\n   }\n}\n\n\nvoid \nValueInternalMap::swap( ValueInternalMap &other )\n{\n   ValueInternalLink *tempBuckets = buckets_;\n   buckets_ = other.buckets_;\n   other.buckets_ = tempBuckets;\n   ValueInternalLink *tempTailLink = tailLink_;\n   tailLink_ = other.tailLink_;\n   other.tailLink_ = tempTailLink;\n   BucketIndex tempBucketsSize = bucketsSize_;\n   bucketsSize_ = other.bucketsSize_;\n   other.bucketsSize_ = tempBucketsSize;\n   BucketIndex tempItemCount = itemCount_;\n   itemCount_ = other.itemCount_;\n   other.itemCount_ = tempItemCount;\n}\n\n\nvoid \nValueInternalMap::clear()\n{\n   ValueInternalMap dummy;\n   swap( dummy );\n}\n\n\nValueInternalMap::BucketIndex \nValueInternalMap::size() const\n{\n   return itemCount_;\n}\n\nbool \nValueInternalMap::reserveDelta( BucketIndex growth )\n{\n   return reserve( itemCount_ + growth );\n}\n\nbool \nValueInternalMap::reserve( BucketIndex newItemCount )\n{\n   if ( !buckets_  &&  newItemCount > 0 )\n   {\n      buckets_ = mapAllocator()->allocateMapBuckets( 1 );\n      bucketsSize_ = 1;\n      tailLink_ = &buckets_[0];\n   }\n//   BucketIndex idealBucketCount = (newItemCount + ValueInternalLink::itemPerLink) / ValueInternalLink::itemPerLink;\n   return true;\n}\n\n\nconst Value *\nValueInternalMap::find( const char *key ) const\n{\n   if ( !bucketsSize_ )\n      return 0;\n   HashKey hashedKey = hash( key );\n   BucketIndex bucketIndex = hashedKey % bucketsSize_;\n   for ( const ValueInternalLink *current = &buckets_[bucketIndex]; \n         current != 0; \n         current = current->next_ )\n   {\n      for ( BucketIndex index=0; index < ValueInternalLink::itemPerLink; ++index )\n      {\n         if ( current->items_[index].isItemAvailable() )\n            return 0;\n         if ( strcmp( key, current->keys_[index] ) == 0 )\n            return &current->items_[index];\n      }\n   }\n   return 0;\n}\n\n\nValue *\nValueInternalMap::find( const char *key )\n{\n   const ValueInternalMap *constThis = this;\n   return const_cast<Value *>( constThis->find( key ) );\n}\n\n\nValue &\nValueInternalMap::resolveReference( const char *key,\n                                    bool isStatic )\n{\n   HashKey hashedKey = hash( key );\n   if ( bucketsSize_ )\n   {\n      BucketIndex bucketIndex = hashedKey % bucketsSize_;\n      ValueInternalLink **previous = 0;\n      BucketIndex index;\n      for ( ValueInternalLink *current = &buckets_[bucketIndex]; \n            current != 0; \n            previous = &current->next_, current = current->next_ )\n      {\n         for ( index=0; index < ValueInternalLink::itemPerLink; ++index )\n         {\n            if ( current->items_[index].isItemAvailable() )\n               return setNewItem( key, isStatic, current, index );\n            if ( strcmp( key, current->keys_[index] ) == 0 )\n               return current->items_[index];\n         }\n      }\n   }\n\n   reserveDelta( 1 );\n   return unsafeAdd( key, isStatic, hashedKey );\n}\n\n\nvoid \nValueInternalMap::remove( const char *key )\n{\n   HashKey hashedKey = hash( key );\n   if ( !bucketsSize_ )\n      return;\n   BucketIndex bucketIndex = hashedKey % bucketsSize_;\n   for ( ValueInternalLink *link = &buckets_[bucketIndex]; \n         link != 0; \n         link = link->next_ )\n   {\n      BucketIndex index;\n      for ( index =0; index < ValueInternalLink::itemPerLink; ++index )\n      {\n         if ( link->items_[index].isItemAvailable() )\n            return;\n         if ( strcmp( key, link->keys_[index] ) == 0 )\n         {\n            doActualRemove( link, index, bucketIndex );\n            return;\n         }\n      }\n   }\n}\n\nvoid \nValueInternalMap::doActualRemove( ValueInternalLink *link, \n                                  BucketIndex index,\n                                  BucketIndex bucketIndex )\n{\n   // find last item of the bucket and swap it with the 'removed' one.\n   // set removed items flags to 'available'.\n   // if last page only contains 'available' items, then desallocate it (it's empty)\n   ValueInternalLink *&lastLink = getLastLinkInBucket( index );\n   BucketIndex lastItemIndex = 1; // a link can never be empty, so start at 1\n   for ( ;   \n         lastItemIndex < ValueInternalLink::itemPerLink; \n         ++lastItemIndex ) // may be optimized with dicotomic search\n   {\n      if ( lastLink->items_[lastItemIndex].isItemAvailable() )\n         break;\n   }\n   \n   BucketIndex lastUsedIndex = lastItemIndex - 1;\n   Value *valueToDelete = &link->items_[index];\n   Value *valueToPreserve = &lastLink->items_[lastUsedIndex];\n   if ( valueToDelete != valueToPreserve )\n      valueToDelete->swap( *valueToPreserve );\n   if ( lastUsedIndex == 0 )  // page is now empty\n   {  // remove it from bucket linked list and delete it.\n      ValueInternalLink *linkPreviousToLast = lastLink->previous_;\n      if ( linkPreviousToLast != 0 )   // can not deleted bucket link.\n      {\n         mapAllocator()->releaseMapLink( lastLink );\n         linkPreviousToLast->next_ = 0;\n         lastLink = linkPreviousToLast;\n      }\n   }\n   else\n   {\n      Value dummy;\n      valueToPreserve->swap( dummy ); // restore deleted to default Value.\n      valueToPreserve->setItemUsed( false );\n   }\n   --itemCount_;\n}\n\n\nValueInternalLink *&\nValueInternalMap::getLastLinkInBucket( BucketIndex bucketIndex )\n{\n   if ( bucketIndex == bucketsSize_ - 1 )\n      return tailLink_;\n   ValueInternalLink *&previous = buckets_[bucketIndex+1].previous_;\n   if ( !previous )\n      previous = &buckets_[bucketIndex];\n   return previous;\n}\n\n\nValue &\nValueInternalMap::setNewItem( const char *key, \n                              bool isStatic,\n                              ValueInternalLink *link, \n                              BucketIndex index )\n{\n   char *duplicatedKey = makeMemberName( key );\n   ++itemCount_;\n   link->keys_[index] = duplicatedKey;\n   link->items_[index].setItemUsed();\n   link->items_[index].setMemberNameIsStatic( isStatic );\n   return link->items_[index]; // items already default constructed.\n}\n\n\nValue &\nValueInternalMap::unsafeAdd( const char *key, \n                             bool isStatic, \n                             HashKey hashedKey )\n{\n   JSON_ASSERT_MESSAGE( bucketsSize_ > 0, \"ValueInternalMap::unsafeAdd(): internal logic error.\" );\n   BucketIndex bucketIndex = hashedKey % bucketsSize_;\n   ValueInternalLink *&previousLink = getLastLinkInBucket( bucketIndex );\n   ValueInternalLink *link = previousLink;\n   BucketIndex index;\n   for ( index =0; index < ValueInternalLink::itemPerLink; ++index )\n   {\n      if ( link->items_[index].isItemAvailable() )\n         break;\n   }\n   if ( index == ValueInternalLink::itemPerLink ) // need to add a new page\n   {\n      ValueInternalLink *newLink = mapAllocator()->allocateMapLink();\n      index = 0;\n      link->next_ = newLink;\n      previousLink = newLink;\n      link = newLink;\n   }\n   return setNewItem( key, isStatic, link, index );\n}\n\n\nValueInternalMap::HashKey \nValueInternalMap::hash( const char *key ) const\n{\n   HashKey hash = 0;\n   while ( *key )\n      hash += *key++ * 37;\n   return hash;\n}\n\n\nint \nValueInternalMap::compare( const ValueInternalMap &other ) const\n{\n   int sizeDiff( itemCount_ - other.itemCount_ );\n   if ( sizeDiff != 0 )\n      return sizeDiff;\n   // Strict order guaranty is required. Compare all keys FIRST, then compare values.\n   IteratorState it;\n   IteratorState itEnd;\n   makeBeginIterator( it );\n   makeEndIterator( itEnd );\n   for ( ; !equals(it,itEnd); increment(it) )\n   {\n      if ( !other.find( key( it ) ) )\n         return 1;\n   }\n\n   // All keys are equals, let's compare values\n   makeBeginIterator( it );\n   for ( ; !equals(it,itEnd); increment(it) )\n   {\n      const Value *otherValue = other.find( key( it ) );\n      int valueDiff = value(it).compare( *otherValue );\n      if ( valueDiff != 0 )\n         return valueDiff;\n   }\n   return 0;\n}\n\n\nvoid \nValueInternalMap::makeBeginIterator( IteratorState &it ) const\n{\n   it.map_ = const_cast<ValueInternalMap *>( this );\n   it.bucketIndex_ = 0;\n   it.itemIndex_ = 0;\n   it.link_ = buckets_;\n}\n\n\nvoid \nValueInternalMap::makeEndIterator( IteratorState &it ) const\n{\n   it.map_ = const_cast<ValueInternalMap *>( this );\n   it.bucketIndex_ = bucketsSize_;\n   it.itemIndex_ = 0;\n   it.link_ = 0;\n}\n\n\nbool \nValueInternalMap::equals( const IteratorState &x, const IteratorState &other )\n{\n   return x.map_ == other.map_  \n          &&  x.bucketIndex_ == other.bucketIndex_  \n          &&  x.link_ == other.link_\n          &&  x.itemIndex_ == other.itemIndex_;\n}\n\n\nvoid \nValueInternalMap::incrementBucket( IteratorState &iterator )\n{\n   ++iterator.bucketIndex_;\n   JSON_ASSERT_MESSAGE( iterator.bucketIndex_ <= iterator.map_->bucketsSize_,\n      \"ValueInternalMap::increment(): attempting to iterate beyond end.\" );\n   if ( iterator.bucketIndex_ == iterator.map_->bucketsSize_ )\n      iterator.link_ = 0;\n   else\n      iterator.link_ = &(iterator.map_->buckets_[iterator.bucketIndex_]);\n   iterator.itemIndex_ = 0;\n}\n\n\nvoid \nValueInternalMap::increment( IteratorState &iterator )\n{\n   JSON_ASSERT_MESSAGE( iterator.map_, \"Attempting to iterator using invalid iterator.\" );\n   ++iterator.itemIndex_;\n   if ( iterator.itemIndex_ == ValueInternalLink::itemPerLink )\n   {\n      JSON_ASSERT_MESSAGE( iterator.link_ != 0,\n         \"ValueInternalMap::increment(): attempting to iterate beyond end.\" );\n      iterator.link_ = iterator.link_->next_;\n      if ( iterator.link_ == 0 )\n         incrementBucket( iterator );\n   }\n   else if ( iterator.link_->items_[iterator.itemIndex_].isItemAvailable() )\n   {\n      incrementBucket( iterator );\n   }\n}\n\n\nvoid \nValueInternalMap::decrement( IteratorState &iterator )\n{\n   if ( iterator.itemIndex_ == 0 )\n   {\n      JSON_ASSERT_MESSAGE( iterator.map_, \"Attempting to iterate using invalid iterator.\" );\n      if ( iterator.link_ == &iterator.map_->buckets_[iterator.bucketIndex_] )\n      {\n         JSON_ASSERT_MESSAGE( iterator.bucketIndex_ > 0, \"Attempting to iterate beyond beginning.\" );\n         --(iterator.bucketIndex_);\n      }\n      iterator.link_ = iterator.link_->previous_;\n      iterator.itemIndex_ = ValueInternalLink::itemPerLink - 1;\n   }\n}\n\n\nconst char *\nValueInternalMap::key( const IteratorState &iterator )\n{\n   JSON_ASSERT_MESSAGE( iterator.link_, \"Attempting to iterate using invalid iterator.\" );\n   return iterator.link_->keys_[iterator.itemIndex_];\n}\n\nconst char *\nValueInternalMap::key( const IteratorState &iterator, bool &isStatic )\n{\n   JSON_ASSERT_MESSAGE( iterator.link_, \"Attempting to iterate using invalid iterator.\" );\n   isStatic = iterator.link_->items_[iterator.itemIndex_].isMemberNameStatic();\n   return iterator.link_->keys_[iterator.itemIndex_];\n}\n\n\nValue &\nValueInternalMap::value( const IteratorState &iterator )\n{\n   JSON_ASSERT_MESSAGE( iterator.link_, \"Attempting to iterate using invalid iterator.\" );\n   return iterator.link_->items_[iterator.itemIndex_];\n}\n\n\nint \nValueInternalMap::distance( const IteratorState &x, const IteratorState &y )\n{\n   int offset = 0;\n   IteratorState it = x;\n   while ( !equals( it, y ) )\n      increment( it );\n   return offset;\n}\n\n} // namespace Json\n// vim: et ts=3 sts=3 sw=3 tw=0\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/json/json_tool.h",
    "content": "// Copyright 2007-2010 Baptiste Lepilleur\n// Distributed under MIT license, or public domain if desired and\n// recognized in your jurisdiction.\n// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE\n\n#ifndef LIB_JSONCPP_JSON_TOOL_H_INCLUDED\n#define LIB_JSONCPP_JSON_TOOL_H_INCLUDED\n\n/* This header provides common string manipulation support, such as UTF-8,\n * portable conversion from/to string...\n *\n * It is an internal header that must not be exposed.\n */\n\nnamespace Json {\n\n/// Converts a unicode code-point to UTF-8.\nstatic inline std::string codePointToUTF8(unsigned int cp) {\n  std::string result;\n\n  // based on description from http://en.wikipedia.org/wiki/UTF-8\n\n  if (cp <= 0x7f) {\n    result.resize(1);\n    result[0] = static_cast<char>(cp);\n  } else if (cp <= 0x7FF) {\n    result.resize(2);\n    result[1] = static_cast<char>(0x80 | (0x3f & cp));\n    result[0] = static_cast<char>(0xC0 | (0x1f & (cp >> 6)));\n  } else if (cp <= 0xFFFF) {\n    result.resize(3);\n    result[2] = static_cast<char>(0x80 | (0x3f & cp));\n    result[1] = 0x80 | static_cast<char>((0x3f & (cp >> 6)));\n    result[0] = 0xE0 | static_cast<char>((0xf & (cp >> 12)));\n  } else if (cp <= 0x10FFFF) {\n    result.resize(4);\n    result[3] = static_cast<char>(0x80 | (0x3f & cp));\n    result[2] = static_cast<char>(0x80 | (0x3f & (cp >> 6)));\n    result[1] = static_cast<char>(0x80 | (0x3f & (cp >> 12)));\n    result[0] = static_cast<char>(0xF0 | (0x7 & (cp >> 18)));\n  }\n\n  return result;\n}\n\n/// Returns true if ch is a control character (in range [0,32[).\nstatic inline bool isControlCharacter(char ch) { return ch > 0 && ch <= 0x1F; }\n\nenum {\n  /// Constant that specify the size of the buffer that must be passed to\n  /// uintToString.\n  uintToStringBufferSize = 3 * sizeof(LargestUInt) + 1\n};\n\n// Defines a char buffer for use with uintToString().\ntypedef char UIntToStringBuffer[uintToStringBufferSize];\n\n/** Converts an unsigned integer to string.\n * @param value Unsigned interger to convert to string\n * @param current Input/Output string buffer.\n *        Must have at least uintToStringBufferSize chars free.\n */\nstatic inline void uintToString(LargestUInt value, char *&current) {\n  *--current = 0;\n  do {\n    *--current = char(value % 10) + '0';\n    value /= 10;\n  } while (value != 0);\n}\n\n/** Change ',' to '.' everywhere in buffer.\n *\n * We had a sophisticated way, but it did not work in WinCE.\n * @see https://github.com/open-source-parsers/jsoncpp/pull/9\n */\nstatic inline void fixNumericLocale(char* begin, char* end) {\n  while (begin < end) {\n    if (*begin == ',') {\n      *begin = '.';\n    }\n    ++begin;\n  }\n}\n\n} // namespace Json {\n\n#endif // LIB_JSONCPP_JSON_TOOL_H_INCLUDED\n// vim: et ts=2 sts=2 sw=2 tw=0\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/json/json_valueiterator.inl",
    "content": "// Copyright 2007-2010 Baptiste Lepilleur\n// Distributed under MIT license, or public domain if desired and\n// recognized in your jurisdiction.\n// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE\n\n// included by json_value.cpp\n\nnamespace Json {\n\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// class ValueIteratorBase\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n\nValueIteratorBase::ValueIteratorBase()\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\n   : current_()\n   , isNull_( true )\n{\n}\n#else\n   : isArray_( true )\n   , isNull_( true )\n{\n   iterator_.array_ = ValueInternalArray::IteratorState();\n}\n#endif\n\n\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\nValueIteratorBase::ValueIteratorBase( const Value::ObjectValues::iterator &current )\n   : current_( current )\n   , isNull_( false )\n{\n}\n#else\nValueIteratorBase::ValueIteratorBase( const ValueInternalArray::IteratorState &state )\n   : isArray_( true )\n{\n   iterator_.array_ = state;\n}\n\n\nValueIteratorBase::ValueIteratorBase( const ValueInternalMap::IteratorState &state )\n   : isArray_( false )\n{\n   iterator_.map_ = state;\n}\n#endif\n\nValue &\nValueIteratorBase::deref() const\n{\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\n   return current_->second;\n#else\n   if ( isArray_ )\n      return ValueInternalArray::dereference( iterator_.array_ );\n   return ValueInternalMap::value( iterator_.map_ );\n#endif\n}\n\n\nvoid \nValueIteratorBase::increment()\n{\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\n   ++current_;\n#else\n   if ( isArray_ )\n      ValueInternalArray::increment( iterator_.array_ );\n   ValueInternalMap::increment( iterator_.map_ );\n#endif\n}\n\n\nvoid \nValueIteratorBase::decrement()\n{\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\n   --current_;\n#else\n   if ( isArray_ )\n      ValueInternalArray::decrement( iterator_.array_ );\n   ValueInternalMap::decrement( iterator_.map_ );\n#endif\n}\n\n\nValueIteratorBase::difference_type \nValueIteratorBase::computeDistance( const SelfType &other ) const\n{\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\n# ifdef JSON_USE_CPPTL_SMALLMAP\n   return current_ - other.current_;\n# else\n   // Iterator for null value are initialized using the default\n   // constructor, which initialize current_ to the default\n   // std::map::iterator. As begin() and end() are two instance \n   // of the default std::map::iterator, they can not be compared.\n   // To allow this, we handle this comparison specifically.\n   if ( isNull_  &&  other.isNull_ )\n   {\n      return 0;\n   }\n\n\n   // Usage of std::distance is not portable (does not compile with Sun Studio 12 RogueWave STL,\n   // which is the one used by default).\n   // Using a portable hand-made version for non random iterator instead:\n   //   return difference_type( std::distance( current_, other.current_ ) );\n   difference_type myDistance = 0;\n   for ( Value::ObjectValues::iterator it = current_; it != other.current_; ++it )\n   {\n      ++myDistance;\n   }\n   return myDistance;\n# endif\n#else\n   if ( isArray_ )\n      return ValueInternalArray::distance( iterator_.array_, other.iterator_.array_ );\n   return ValueInternalMap::distance( iterator_.map_, other.iterator_.map_ );\n#endif\n}\n\n\nbool \nValueIteratorBase::isEqual( const SelfType &other ) const\n{\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\n   if ( isNull_ )\n   {\n      return other.isNull_;\n   }\n   return current_ == other.current_;\n#else\n   if ( isArray_ )\n      return ValueInternalArray::equals( iterator_.array_, other.iterator_.array_ );\n   return ValueInternalMap::equals( iterator_.map_, other.iterator_.map_ );\n#endif\n}\n\n\nvoid \nValueIteratorBase::copy( const SelfType &other )\n{\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\n   current_ = other.current_;\n   isNull_ = other.isNull_;\n#else\n   if ( isArray_ )\n      iterator_.array_ = other.iterator_.array_;\n   iterator_.map_ = other.iterator_.map_;\n#endif\n}\n\n\nValue \nValueIteratorBase::key() const\n{\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\n   const Value::CZString czstring = (*current_).first;\n   if ( czstring.c_str() )\n   {\n      if ( czstring.isStaticString() )\n         return Value( StaticString( czstring.c_str() ) );\n      return Value( czstring.c_str() );\n   }\n   return Value( czstring.index() );\n#else\n   if ( isArray_ )\n      return Value( ValueInternalArray::indexOf( iterator_.array_ ) );\n   bool isStatic;\n   const char *memberName = ValueInternalMap::key( iterator_.map_, isStatic );\n   if ( isStatic )\n      return Value( StaticString( memberName ) );\n   return Value( memberName );\n#endif\n}\n\n\nUInt \nValueIteratorBase::index() const\n{\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\n   const Value::CZString czstring = (*current_).first;\n   if ( !czstring.c_str() )\n      return czstring.index();\n   return Value::UInt( -1 );\n#else\n   if ( isArray_ )\n      return Value::UInt( ValueInternalArray::indexOf( iterator_.array_ ) );\n   return Value::UInt( -1 );\n#endif\n}\n\n\nconst char *\nValueIteratorBase::memberName() const\n{\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\n   const char *name = (*current_).first.c_str();\n   return name ? name : \"\";\n#else\n   if ( !isArray_ )\n      return ValueInternalMap::key( iterator_.map_ );\n   return \"\";\n#endif\n}\n\n\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// class ValueConstIterator\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n\nValueConstIterator::ValueConstIterator()\n{\n}\n\n\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\nValueConstIterator::ValueConstIterator( const Value::ObjectValues::iterator &current )\n   : ValueIteratorBase( current )\n{\n}\n#else\nValueConstIterator::ValueConstIterator( const ValueInternalArray::IteratorState &state )\n   : ValueIteratorBase( state )\n{\n}\n\nValueConstIterator::ValueConstIterator( const ValueInternalMap::IteratorState &state )\n   : ValueIteratorBase( state )\n{\n}\n#endif\n\nValueConstIterator &\nValueConstIterator::operator =( const ValueIteratorBase &other )\n{\n   copy( other );\n   return *this;\n}\n\n\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// class ValueIterator\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n\nValueIterator::ValueIterator()\n{\n}\n\n\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\nValueIterator::ValueIterator( const Value::ObjectValues::iterator &current )\n   : ValueIteratorBase( current )\n{\n}\n#else\nValueIterator::ValueIterator( const ValueInternalArray::IteratorState &state )\n   : ValueIteratorBase( state )\n{\n}\n\nValueIterator::ValueIterator( const ValueInternalMap::IteratorState &state )\n   : ValueIteratorBase( state )\n{\n}\n#endif\n\nValueIterator::ValueIterator( const ValueConstIterator &other )\n   : ValueIteratorBase( other )\n{\n}\n\nValueIterator::ValueIterator( const ValueIterator &other )\n   : ValueIteratorBase( other )\n{\n}\n\nValueIterator &\nValueIterator::operator =( const SelfType &other )\n{\n   copy( other );\n   return *this;\n}\n\n} // namespace Json\n// vim: et ts=3 sts=3 sw=3 tw=0\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/json/reader.h",
    "content": "// Copyright 2007-2010 Baptiste Lepilleur\n// Distributed under MIT license, or public domain if desired and\n// recognized in your jurisdiction.\n// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE\n\n#ifndef CPPTL_JSON_READER_H_INCLUDED\n#define CPPTL_JSON_READER_H_INCLUDED\n\n#if !defined(JSON_IS_AMALGAMATION)\n#include \"features.h\"\n#include \"value.h\"\n#endif // if !defined(JSON_IS_AMALGAMATION)\n#include <deque>\n#include <iosfwd>\n#include <stack>\n#include <string>\n\n// Disable warning C4251: <data member>: <type> needs to have dll-interface to\n// be used by...\n#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)\n#pragma warning(push)\n#pragma warning(disable : 4251)\n#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)\n\nnamespace Json {\n\n/** \\brief Unserialize a <a HREF=\"http://www.json.org\">JSON</a> document into a\n *Value.\n *\n */\nclass JSON_API Reader {\npublic:\n  typedef char Char;\n  typedef const Char *Location;\n\n  /** \\brief An error tagged with where in the JSON text it was encountered.\n   *\n   * The offsets give the [start, limit) range of bytes within the text. Note\n   * that this is bytes, not codepoints.\n   *\n   */\n  struct StructuredError {\n    size_t offset_start;\n    size_t offset_limit;\n    std::string message;\n  };\n\n  /** \\brief Constructs a Reader allowing all features\n   * for parsing.\n   */\n  Reader();\n\n  /** \\brief Constructs a Reader allowing the specified feature set\n   * for parsing.\n   */\n  Reader(const Features &features);\n\n  /** \\brief Read a Value from a <a HREF=\"http://www.json.org\">JSON</a>\n   * document.\n   * \\param document UTF-8 encoded string containing the document to read.\n   * \\param root [out] Contains the root value of the document if it was\n   *             successfully parsed.\n   * \\param collectComments \\c true to collect comment and allow writing them\n   * back during\n   *                        serialization, \\c false to discard comments.\n   *                        This parameter is ignored if\n   * Features::allowComments_\n   *                        is \\c false.\n   * \\return \\c true if the document was successfully parsed, \\c false if an\n   * error occurred.\n   */\n  bool\n  parse(const std::string &document, Value &root, bool collectComments = true);\n\n  /** \\brief Read a Value from a <a HREF=\"http://www.json.org\">JSON</a>\n   document.\n   * \\param beginDoc Pointer on the beginning of the UTF-8 encoded string of the\n   document to read.\n   * \\param endDoc Pointer on the end of the UTF-8 encoded string of the\n   document to read.\n   \\               Must be >= beginDoc.\n   * \\param root [out] Contains the root value of the document if it was\n   *             successfully parsed.\n   * \\param collectComments \\c true to collect comment and allow writing them\n   back during\n   *                        serialization, \\c false to discard comments.\n   *                        This parameter is ignored if\n   Features::allowComments_\n   *                        is \\c false.\n   * \\return \\c true if the document was successfully parsed, \\c false if an\n   error occurred.\n   */\n  bool parse(const char *beginDoc,\n             const char *endDoc,\n             Value &root,\n             bool collectComments = true);\n\n  /// \\brief Parse from input stream.\n  /// \\see Json::operator>>(std::istream&, Json::Value&).\n  bool parse(std::istream &is, Value &root, bool collectComments = true);\n\n  /** \\brief Returns a user friendly string that list errors in the parsed\n   * document.\n   * \\return Formatted error message with the list of errors with their location\n   * in\n   *         the parsed document. An empty string is returned if no error\n   * occurred\n   *         during parsing.\n   * \\deprecated Use getFormattedErrorMessages() instead (typo fix).\n   */\n  JSONCPP_DEPRECATED(\"Use getFormattedErrorMessages instead\")\n  std::string getFormatedErrorMessages() const;\n\n  /** \\brief Returns a user friendly string that list errors in the parsed\n   * document.\n   * \\return Formatted error message with the list of errors with their location\n   * in\n   *         the parsed document. An empty string is returned if no error\n   * occurred\n   *         during parsing.\n   */\n  std::string getFormattedErrorMessages() const;\n\n  /** \\brief Returns a vector of structured erros encounted while parsing.\n   * \\return A (possibly empty) vector of StructuredError objects. Currently\n   *         only one error can be returned, but the caller should tolerate\n   * multiple\n   *         errors.  This can occur if the parser recovers from a non-fatal\n   *         parse error and then encounters additional errors.\n   */\n  std::vector<StructuredError> getStructuredErrors() const;\n\nprivate:\n  enum TokenType {\n    tokenEndOfStream = 0,\n    tokenObjectBegin,\n    tokenObjectEnd,\n    tokenArrayBegin,\n    tokenArrayEnd,\n    tokenString,\n    tokenNumber,\n    tokenTrue,\n    tokenFalse,\n    tokenNull,\n    tokenArraySeparator,\n    tokenMemberSeparator,\n    tokenComment,\n    tokenError\n  };\n\n  class Token {\n  public:\n    TokenType type_;\n    Location start_;\n    Location end_;\n  };\n\n  class ErrorInfo {\n  public:\n    Token token_;\n    std::string message_;\n    Location extra_;\n  };\n\n  typedef std::deque<ErrorInfo> Errors;\n\n  bool expectToken(TokenType type, Token &token, const char *message);\n  bool readToken(Token &token);\n  void skipSpaces();\n  bool match(Location pattern, int patternLength);\n  bool readComment();\n  bool readCStyleComment();\n  bool readCppStyleComment();\n  bool readString();\n  void readNumber();\n  bool readValue();\n  bool readObject(Token &token);\n  bool readArray(Token &token);\n  bool decodeNumber(Token &token);\n  bool decodeNumber(Token &token, Value &decoded);\n  bool decodeString(Token &token);\n  bool decodeString(Token &token, std::string &decoded);\n  bool decodeDouble(Token &token);\n  bool decodeDouble(Token &token, Value &decoded);\n  bool decodeUnicodeCodePoint(Token &token,\n                              Location &current,\n                              Location end,\n                              unsigned int &unicode);\n  bool decodeUnicodeEscapeSequence(Token &token,\n                                   Location &current,\n                                   Location end,\n                                   unsigned int &unicode);\n  bool addError(const std::string &message, Token &token, Location extra = 0);\n  bool recoverFromError(TokenType skipUntilToken);\n  bool addErrorAndRecover(const std::string &message,\n                          Token &token,\n                          TokenType skipUntilToken);\n  void skipUntilSpace();\n  Value &currentValue();\n  Char getNextChar();\n  void\n  getLocationLineAndColumn(Location location, int &line, int &column) const;\n  std::string getLocationLineAndColumn(Location location) const;\n  void addComment(Location begin, Location end, CommentPlacement placement);\n  void skipCommentTokens(Token &token);\n\n  typedef std::stack<Value *> Nodes;\n  Nodes nodes_;\n  Errors errors_;\n  std::string document_;\n  Location begin_;\n  Location end_;\n  Location current_;\n  Location lastValueEnd_;\n  Value *lastValue_;\n  std::string commentsBefore_;\n  Features features_;\n  bool collectComments_;\n};\n\n/** \\brief Read from 'sin' into 'root'.\n\n Always keep comments from the input JSON.\n\n This can be used to read a file into a particular sub-object.\n For example:\n \\code\n Json::Value root;\n cin >> root[\"dir\"][\"file\"];\n cout << root;\n \\endcode\n Result:\n \\verbatim\n {\n \"dir\": {\n     \"file\": {\n     // The input stream JSON would be nested here.\n     }\n }\n }\n \\endverbatim\n \\throw std::exception on parse error.\n \\see Json::operator<<()\n*/\nJSON_API std::istream &operator>>(std::istream &, Value &);\n\n} // namespace Json\n\n#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)\n#pragma warning(pop)\n#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)\n\n#endif // CPPTL_JSON_READER_H_INCLUDED\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/json/value.h",
    "content": "// Copyright 2007-2010 Baptiste Lepilleur\n// Distributed under MIT license, or public domain if desired and\n// recognized in your jurisdiction.\n// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE\n\n#ifndef CPPTL_JSON_H_INCLUDED\n#define CPPTL_JSON_H_INCLUDED\n\n#if !defined(JSON_IS_AMALGAMATION)\n#include \"forwards.h\"\n#endif // if !defined(JSON_IS_AMALGAMATION)\n#include <string>\n#include <vector>\n\n#ifndef JSON_USE_CPPTL_SMALLMAP\n#include <map>\n#else\n#include <cpptl/smallmap.h>\n#endif\n#ifdef JSON_USE_CPPTL\n#include <cpptl/forwards.h>\n#endif\n\n// Disable warning C4251: <data member>: <type> needs to have dll-interface to\n// be used by...\n#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)\n#pragma warning(push)\n#pragma warning(disable : 4251)\n#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)\n\n/** \\brief JSON (JavaScript Object Notation).\n */\nnamespace Json {\n\n/** \\brief Type of the value held by a Value object.\n */\nenum ValueType {\n  nullValue = 0, ///< 'null' value\n  intValue,      ///< signed integer value\n  uintValue,     ///< unsigned integer value\n  realValue,     ///< double value\n  stringValue,   ///< UTF-8 string value\n  booleanValue,  ///< bool value\n  arrayValue,    ///< array value (ordered list)\n  objectValue    ///< object value (collection of name/value pairs).\n};\n\nenum CommentPlacement {\n  commentBefore = 0,      ///< a comment placed on the line before a value\n  commentAfterOnSameLine, ///< a comment just after a value on the same line\n  commentAfter, ///< a comment on the line after a value (only make sense for\n  /// root value)\n  numberOfCommentPlacement\n};\n\n//# ifdef JSON_USE_CPPTL\n//   typedef CppTL::AnyEnumerator<const char *> EnumMemberNames;\n//   typedef CppTL::AnyEnumerator<const Value &> EnumValues;\n//# endif\n\n/** \\brief Lightweight wrapper to tag static string.\n *\n * Value constructor and objectValue member assignement takes advantage of the\n * StaticString and avoid the cost of string duplication when storing the\n * string or the member name.\n *\n * Example of usage:\n * \\code\n * Json::Value aValue( StaticString(\"some text\") );\n * Json::Value object;\n * static const StaticString code(\"code\");\n * object[code] = 1234;\n * \\endcode\n */\nclass JSON_API StaticString {\npublic:\n  explicit StaticString(const char *czstring) : str_(czstring) {}\n\n  operator const char *() const { return str_; }\n\n  const char *c_str() const { return str_; }\n\nprivate:\n  const char *str_;\n};\n\n/** \\brief Represents a <a HREF=\"http://www.json.org\">JSON</a> value.\n *\n * This class is a discriminated union wrapper that can represents a:\n * - signed integer [range: Value::minInt - Value::maxInt]\n * - unsigned integer (range: 0 - Value::maxUInt)\n * - double\n * - UTF-8 string\n * - boolean\n * - 'null'\n * - an ordered list of Value\n * - collection of name/value pairs (javascript object)\n *\n * The type of the held value is represented by a #ValueType and\n * can be obtained using type().\n *\n * values of an #objectValue or #arrayValue can be accessed using operator[]()\n *methods.\n * Non const methods will automatically create the a #nullValue element\n * if it does not exist.\n * The sequence of an #arrayValue will be automatically resize and initialized\n * with #nullValue. resize() can be used to enlarge or truncate an #arrayValue.\n *\n * The get() methods can be used to obtanis default value in the case the\n *required element\n * does not exist.\n *\n * It is possible to iterate over the list of a #objectValue values using\n * the getMemberNames() method.\n */\nclass JSON_API Value {\n  friend class ValueIteratorBase;\n#ifdef JSON_VALUE_USE_INTERNAL_MAP\n  friend class ValueInternalLink;\n  friend class ValueInternalMap;\n#endif\npublic:\n  typedef std::vector<std::string> Members;\n  typedef ValueIterator iterator;\n  typedef ValueConstIterator const_iterator;\n  typedef Json::UInt UInt;\n  typedef Json::Int Int;\n#if defined(JSON_HAS_INT64)\n  typedef Json::UInt64 UInt64;\n  typedef Json::Int64 Int64;\n#endif // defined(JSON_HAS_INT64)\n  typedef Json::LargestInt LargestInt;\n  typedef Json::LargestUInt LargestUInt;\n  typedef Json::ArrayIndex ArrayIndex;\n\n  static const Value& null;\n  /// Minimum signed integer value that can be stored in a Json::Value.\n  static const LargestInt minLargestInt;\n  /// Maximum signed integer value that can be stored in a Json::Value.\n  static const LargestInt maxLargestInt;\n  /// Maximum unsigned integer value that can be stored in a Json::Value.\n  static const LargestUInt maxLargestUInt;\n\n  /// Minimum signed int value that can be stored in a Json::Value.\n  static const Int minInt;\n  /// Maximum signed int value that can be stored in a Json::Value.\n  static const Int maxInt;\n  /// Maximum unsigned int value that can be stored in a Json::Value.\n  static const UInt maxUInt;\n\n#if defined(JSON_HAS_INT64)\n  /// Minimum signed 64 bits int value that can be stored in a Json::Value.\n  static const Int64 minInt64;\n  /// Maximum signed 64 bits int value that can be stored in a Json::Value.\n  static const Int64 maxInt64;\n  /// Maximum unsigned 64 bits int value that can be stored in a Json::Value.\n  static const UInt64 maxUInt64;\n#endif // defined(JSON_HAS_INT64)\n\nprivate:\n#ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\n  class CZString {\n  public:\n    enum DuplicationPolicy {\n      noDuplication = 0,\n      duplicate,\n      duplicateOnCopy\n    };\n    CZString(ArrayIndex index);\n    CZString(const char *cstr, DuplicationPolicy allocate);\n    CZString(const CZString &other);\n    ~CZString();\n    CZString &operator=(CZString other);\n    bool operator<(const CZString &other) const;\n    bool operator==(const CZString &other) const;\n    ArrayIndex index() const;\n    const char *c_str() const;\n    bool isStaticString() const;\n\n  private:\n    void swap(CZString &other);\n    const char *cstr_;\n    ArrayIndex index_;\n  };\n\npublic:\n#ifndef JSON_USE_CPPTL_SMALLMAP\n  typedef std::map<CZString, Value> ObjectValues;\n#else\n  typedef CppTL::SmallMap<CZString, Value> ObjectValues;\n#endif // ifndef JSON_USE_CPPTL_SMALLMAP\n#endif // ifndef JSON_VALUE_USE_INTERNAL_MAP\n#endif // ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION\n\npublic:\n  /** \\brief Create a default Value of the given type.\n\n    This is a very useful constructor.\n    To create an empty array, pass arrayValue.\n    To create an empty object, pass objectValue.\n    Another Value can then be set to this one by assignment.\nThis is useful since clear() and resize() will not alter types.\n\n    Examples:\n\\code\nJson::Value null_value; // null\nJson::Value arr_value(Json::arrayValue); // []\nJson::Value obj_value(Json::objectValue); // {}\n\\endcode\n  */\n  Value(ValueType type = nullValue);\n  Value(Int value);\n  Value(UInt value);\n#if defined(JSON_HAS_INT64)\n  Value(Int64 value);\n  Value(UInt64 value);\n#endif // if defined(JSON_HAS_INT64)\n  Value(double value);\n  Value(const char *value);\n  Value(const char *beginValue, const char *endValue);\n  /** \\brief Constructs a value from a static string.\n\n   * Like other value string constructor but do not duplicate the string for\n   * internal storage. The given string must remain alive after the call to this\n   * constructor.\n   * Example of usage:\n   * \\code\n   * Json::Value aValue( StaticString(\"some text\") );\n   * \\endcode\n   */\n  Value(const StaticString &value);\n  Value(const std::string &value);\n#ifdef JSON_USE_CPPTL\n  Value(const CppTL::ConstString &value);\n#endif\n  Value(bool value);\n  Value(const Value &other);\n  ~Value();\n\n  Value &operator=(Value other);\n  /// Swap values.\n  /// \\note Currently, comments are intentionally not swapped, for\n  /// both logic and efficiency.\n  void swap(Value &other);\n\n  ValueType type() const;\n\n  bool operator<(const Value &other) const;\n  bool operator<=(const Value &other) const;\n  bool operator>=(const Value &other) const;\n  bool operator>(const Value &other) const;\n\n  bool operator==(const Value &other) const;\n  bool operator!=(const Value &other) const;\n\n  int compare(const Value &other) const;\n\n  const char *asCString() const;\n  std::string asString() const;\n#ifdef JSON_USE_CPPTL\n  CppTL::ConstString asConstString() const;\n#endif\n  Int asInt() const;\n  UInt asUInt() const;\n#if defined(JSON_HAS_INT64)\n  Int64 asInt64() const;\n  UInt64 asUInt64() const;\n#endif // if defined(JSON_HAS_INT64)\n  LargestInt asLargestInt() const;\n  LargestUInt asLargestUInt() const;\n  float asFloat() const;\n  double asDouble() const;\n  bool asBool() const;\n\n  bool isNull() const;\n  bool isBool() const;\n  bool isInt() const;\n  bool isInt64() const;\n  bool isUInt() const;\n  bool isUInt64() const;\n  bool isIntegral() const;\n  bool isDouble() const;\n  bool isNumeric() const;\n  bool isString() const;\n  bool isArray() const;\n  bool isObject() const;\n\n  bool isConvertibleTo(ValueType other) const;\n\n  /// Number of values in array or object\n  ArrayIndex size() const;\n\n  /// \\brief Return true if empty array, empty object, or null;\n  /// otherwise, false.\n  bool empty() const;\n\n  /// Return isNull()\n  bool operator!() const;\n\n  /// Remove all object members and array elements.\n  /// \\pre type() is arrayValue, objectValue, or nullValue\n  /// \\post type() is unchanged\n  void clear();\n\n  /// Resize the array to size elements.\n  /// New elements are initialized to null.\n  /// May only be called on nullValue or arrayValue.\n  /// \\pre type() is arrayValue or nullValue\n  /// \\post type() is arrayValue\n  void resize(ArrayIndex size);\n\n  /// Access an array element (zero based index ).\n  /// If the array contains less than index element, then null value are\n  /// inserted\n  /// in the array so that its size is index+1.\n  /// (You may need to say 'value[0u]' to get your compiler to distinguish\n  ///  this from the operator[] which takes a string.)\n  Value &operator[](ArrayIndex index);\n\n  /// Access an array element (zero based index ).\n  /// If the array contains less than index element, then null value are\n  /// inserted\n  /// in the array so that its size is index+1.\n  /// (You may need to say 'value[0u]' to get your compiler to distinguish\n  ///  this from the operator[] which takes a string.)\n  Value &operator[](int index);\n\n  /// Access an array element (zero based index )\n  /// (You may need to say 'value[0u]' to get your compiler to distinguish\n  ///  this from the operator[] which takes a string.)\n  const Value &operator[](ArrayIndex index) const;\n\n  /// Access an array element (zero based index )\n  /// (You may need to say 'value[0u]' to get your compiler to distinguish\n  ///  this from the operator[] which takes a string.)\n  const Value &operator[](int index) const;\n\n  /// If the array contains at least index+1 elements, returns the element\n  /// value,\n  /// otherwise returns defaultValue.\n  Value get(ArrayIndex index, const Value &defaultValue) const;\n  /// Return true if index < size().\n  bool isValidIndex(ArrayIndex index) const;\n  /// \\brief Append value to array at the end.\n  ///\n  /// Equivalent to jsonvalue[jsonvalue.size()] = value;\n  Value &append(const Value &value);\n\n  /// Access an object value by name, create a null member if it does not exist.\n  Value &operator[](const char *key);\n  /// Access an object value by name, returns null if there is no member with\n  /// that name.\n  const Value &operator[](const char *key) const;\n  /// Access an object value by name, create a null member if it does not exist.\n  Value &operator[](const std::string &key);\n  /// Access an object value by name, returns null if there is no member with\n  /// that name.\n  const Value &operator[](const std::string &key) const;\n  /** \\brief Access an object value by name, create a null member if it does not\n   exist.\n\n   * If the object as no entry for that name, then the member name used to store\n   * the new entry is not duplicated.\n   * Example of use:\n   * \\code\n   * Json::Value object;\n   * static const StaticString code(\"code\");\n   * object[code] = 1234;\n   * \\endcode\n   */\n  Value &operator[](const StaticString &key);\n#ifdef JSON_USE_CPPTL\n  /// Access an object value by name, create a null member if it does not exist.\n  Value &operator[](const CppTL::ConstString &key);\n  /// Access an object value by name, returns null if there is no member with\n  /// that name.\n  const Value &operator[](const CppTL::ConstString &key) const;\n#endif\n  /// Return the member named key if it exist, defaultValue otherwise.\n  Value get(const char *key, const Value &defaultValue) const;\n  /// Return the member named key if it exist, defaultValue otherwise.\n  Value get(const std::string &key, const Value &defaultValue) const;\n#ifdef JSON_USE_CPPTL\n  /// Return the member named key if it exist, defaultValue otherwise.\n  Value get(const CppTL::ConstString &key, const Value &defaultValue) const;\n#endif\n  /// \\brief Remove and return the named member.\n  ///\n  /// Do nothing if it did not exist.\n  /// \\return the removed Value, or null.\n  /// \\pre type() is objectValue or nullValue\n  /// \\post type() is unchanged\n  Value removeMember(const char *key);\n  /// Same as removeMember(const char*)\n  Value removeMember(const std::string &key);\n\n  /// Return true if the object has a member named key.\n  bool isMember(const char *key) const;\n  /// Return true if the object has a member named key.\n  bool isMember(const std::string &key) const;\n#ifdef JSON_USE_CPPTL\n  /// Return true if the object has a member named key.\n  bool isMember(const CppTL::ConstString &key) const;\n#endif\n\n  /// \\brief Return a list of the member names.\n  ///\n  /// If null, return an empty list.\n  /// \\pre type() is objectValue or nullValue\n  /// \\post if type() was nullValue, it remains nullValue\n  Members getMemberNames() const;\n\n  //# ifdef JSON_USE_CPPTL\n  //      EnumMemberNames enumMemberNames() const;\n  //      EnumValues enumValues() const;\n  //# endif\n\n  /// Comments must be //... or /* ... */\n  void setComment(const char *comment, CommentPlacement placement);\n  /// Comments must be //... or /* ... */\n  void setComment(const std::string &comment, CommentPlacement placement);\n  bool hasComment(CommentPlacement placement) const;\n  /// Include delimiters and embedded newlines.\n  std::string getComment(CommentPlacement placement) const;\n\n  std::string toStyledString() const;\n\n  const_iterator begin() const;\n  const_iterator end() const;\n\n  iterator begin();\n  iterator end();\n\n  // Accessors for the [start, limit) range of bytes within the JSON text from\n  // which this value was parsed, if any.\n  void setOffsetStart(size_t start);\n  void setOffsetLimit(size_t limit);\n  size_t getOffsetStart() const;\n  size_t getOffsetLimit() const;\n\nprivate:\n  Value &resolveReference(const char *key, bool isStatic);\n\n#ifdef JSON_VALUE_USE_INTERNAL_MAP\n  inline bool isItemAvailable() const { return itemIsUsed_ == 0; }\n\n  inline void setItemUsed(bool isUsed = true) { itemIsUsed_ = isUsed ? 1 : 0; }\n\n  inline bool isMemberNameStatic() const { return memberNameIsStatic_ == 0; }\n\n  inline void setMemberNameIsStatic(bool isStatic) {\n    memberNameIsStatic_ = isStatic ? 1 : 0;\n  }\n#endif // # ifdef JSON_VALUE_USE_INTERNAL_MAP\n\nprivate:\n  struct CommentInfo {\n    CommentInfo();\n    ~CommentInfo();\n\n    void setComment(const char *text);\n\n    char *comment_;\n  };\n\n  // struct MemberNamesTransform\n  //{\n  //   typedef const char *result_type;\n  //   const char *operator()( const CZString &name ) const\n  //   {\n  //      return name.c_str();\n  //   }\n  //};\n\n  union ValueHolder {\n    LargestInt int_;\n    LargestUInt uint_;\n    double real_;\n    bool bool_;\n    char *string_;\n#ifdef JSON_VALUE_USE_INTERNAL_MAP\n    ValueInternalArray *array_;\n    ValueInternalMap *map_;\n#else\n    ObjectValues *map_;\n#endif\n  } value_;\n  ValueType type_ : 8;\n  int allocated_ : 1; // Notes: if declared as bool, bitfield is useless.\n#ifdef JSON_VALUE_USE_INTERNAL_MAP\n  unsigned int itemIsUsed_ : 1; // used by the ValueInternalMap container.\n  int memberNameIsStatic_ : 1;  // used by the ValueInternalMap container.\n#endif\n  CommentInfo *comments_;\n\n  // [start, limit) byte offsets in the source JSON text from which this Value\n  // was extracted.\n  size_t start_;\n  size_t limit_;\n};\n\n/** \\brief Experimental and untested: represents an element of the \"path\" to\n * access a node.\n */\nclass JSON_API PathArgument {\npublic:\n  friend class Path;\n\n  PathArgument();\n  PathArgument(ArrayIndex index);\n  PathArgument(const char *key);\n  PathArgument(const std::string &key);\n\nprivate:\n  enum Kind {\n    kindNone = 0,\n    kindIndex,\n    kindKey\n  };\n  std::string key_;\n  ArrayIndex index_;\n  Kind kind_;\n};\n\n/** \\brief Experimental and untested: represents a \"path\" to access a node.\n *\n * Syntax:\n * - \".\" => root node\n * - \".[n]\" => elements at index 'n' of root node (an array value)\n * - \".name\" => member named 'name' of root node (an object value)\n * - \".name1.name2.name3\"\n * - \".[0][1][2].name1[3]\"\n * - \".%\" => member name is provided as parameter\n * - \".[%]\" => index is provied as parameter\n */\nclass JSON_API Path {\npublic:\n  Path(const std::string &path,\n       const PathArgument &a1 = PathArgument(),\n       const PathArgument &a2 = PathArgument(),\n       const PathArgument &a3 = PathArgument(),\n       const PathArgument &a4 = PathArgument(),\n       const PathArgument &a5 = PathArgument());\n\n  const Value &resolve(const Value &root) const;\n  Value resolve(const Value &root, const Value &defaultValue) const;\n  /// Creates the \"path\" to access the specified node and returns a reference on\n  /// the node.\n  Value &make(Value &root) const;\n\nprivate:\n  typedef std::vector<const PathArgument *> InArgs;\n  typedef std::vector<PathArgument> Args;\n\n  void makePath(const std::string &path, const InArgs &in);\n  void addPathInArg(const std::string &path,\n                    const InArgs &in,\n                    InArgs::const_iterator &itInArg,\n                    PathArgument::Kind kind);\n  void invalidPath(const std::string &path, int location);\n\n  Args args_;\n};\n\n#ifdef JSON_VALUE_USE_INTERNAL_MAP\n/** \\brief Allocator to customize Value internal map.\n * Below is an example of a simple implementation (default implementation\n actually\n * use memory pool for speed).\n * \\code\n   class DefaultValueMapAllocator : public ValueMapAllocator\n   {\n   public: // overridden from ValueMapAllocator\n      virtual ValueInternalMap *newMap()\n      {\n         return new ValueInternalMap();\n      }\n\n      virtual ValueInternalMap *newMapCopy( const ValueInternalMap &other )\n      {\n         return new ValueInternalMap( other );\n      }\n\n      virtual void destructMap( ValueInternalMap *map )\n      {\n         delete map;\n      }\n\n      virtual ValueInternalLink *allocateMapBuckets( unsigned int size )\n      {\n         return new ValueInternalLink[size];\n      }\n\n      virtual void releaseMapBuckets( ValueInternalLink *links )\n      {\n         delete [] links;\n      }\n\n      virtual ValueInternalLink *allocateMapLink()\n      {\n         return new ValueInternalLink();\n      }\n\n      virtual void releaseMapLink( ValueInternalLink *link )\n      {\n         delete link;\n      }\n   };\n * \\endcode\n */\nclass JSON_API ValueMapAllocator {\npublic:\n  virtual ~ValueMapAllocator();\n  virtual ValueInternalMap *newMap() = 0;\n  virtual ValueInternalMap *newMapCopy(const ValueInternalMap &other) = 0;\n  virtual void destructMap(ValueInternalMap *map) = 0;\n  virtual ValueInternalLink *allocateMapBuckets(unsigned int size) = 0;\n  virtual void releaseMapBuckets(ValueInternalLink *links) = 0;\n  virtual ValueInternalLink *allocateMapLink() = 0;\n  virtual void releaseMapLink(ValueInternalLink *link) = 0;\n};\n\n/** \\brief ValueInternalMap hash-map bucket chain link (for internal use only).\n * \\internal previous_ & next_ allows for bidirectional traversal.\n */\nclass JSON_API ValueInternalLink {\npublic:\n  enum {\n    itemPerLink = 6\n  }; // sizeof(ValueInternalLink) = 128 on 32 bits architecture.\n  enum InternalFlags {\n    flagAvailable = 0,\n    flagUsed = 1\n  };\n\n  ValueInternalLink();\n\n  ~ValueInternalLink();\n\n  Value items_[itemPerLink];\n  char *keys_[itemPerLink];\n  ValueInternalLink *previous_;\n  ValueInternalLink *next_;\n};\n\n/** \\brief A linked page based hash-table implementation used internally by\n *Value.\n * \\internal ValueInternalMap is a tradional bucket based hash-table, with a\n *linked\n * list in each bucket to handle collision. There is an addional twist in that\n * each node of the collision linked list is a page containing a fixed amount of\n * value. This provides a better compromise between memory usage and speed.\n *\n * Each bucket is made up of a chained list of ValueInternalLink. The last\n * link of a given bucket can be found in the 'previous_' field of the following\n *bucket.\n * The last link of the last bucket is stored in tailLink_ as it has no\n *following bucket.\n * Only the last link of a bucket may contains 'available' item. The last link\n *always\n * contains at least one element unless is it the bucket one very first link.\n */\nclass JSON_API ValueInternalMap {\n  friend class ValueIteratorBase;\n  friend class Value;\n\npublic:\n  typedef unsigned int HashKey;\n  typedef unsigned int BucketIndex;\n\n#ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION\n  struct IteratorState {\n    IteratorState() : map_(0), link_(0), itemIndex_(0), bucketIndex_(0) {}\n    ValueInternalMap *map_;\n    ValueInternalLink *link_;\n    BucketIndex itemIndex_;\n    BucketIndex bucketIndex_;\n  };\n#endif // ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION\n\n  ValueInternalMap();\n  ValueInternalMap(const ValueInternalMap &other);\n  ValueInternalMap &operator=(ValueInternalMap other);\n  ~ValueInternalMap();\n\n  void swap(ValueInternalMap &other);\n\n  BucketIndex size() const;\n\n  void clear();\n\n  bool reserveDelta(BucketIndex growth);\n\n  bool reserve(BucketIndex newItemCount);\n\n  const Value *find(const char *key) const;\n\n  Value *find(const char *key);\n\n  Value &resolveReference(const char *key, bool isStatic);\n\n  void remove(const char *key);\n\n  void doActualRemove(ValueInternalLink *link,\n                      BucketIndex index,\n                      BucketIndex bucketIndex);\n\n  ValueInternalLink *&getLastLinkInBucket(BucketIndex bucketIndex);\n\n  Value &setNewItem(const char *key,\n                    bool isStatic,\n                    ValueInternalLink *link,\n                    BucketIndex index);\n\n  Value &unsafeAdd(const char *key, bool isStatic, HashKey hashedKey);\n\n  HashKey hash(const char *key) const;\n\n  int compare(const ValueInternalMap &other) const;\n\nprivate:\n  void makeBeginIterator(IteratorState &it) const;\n  void makeEndIterator(IteratorState &it) const;\n  static bool equals(const IteratorState &x, const IteratorState &other);\n  static void increment(IteratorState &iterator);\n  static void incrementBucket(IteratorState &iterator);\n  static void decrement(IteratorState &iterator);\n  static const char *key(const IteratorState &iterator);\n  static const char *key(const IteratorState &iterator, bool &isStatic);\n  static Value &value(const IteratorState &iterator);\n  static int distance(const IteratorState &x, const IteratorState &y);\n\nprivate:\n  ValueInternalLink *buckets_;\n  ValueInternalLink *tailLink_;\n  BucketIndex bucketsSize_;\n  BucketIndex itemCount_;\n};\n\n/** \\brief A simplified deque implementation used internally by Value.\n* \\internal\n* It is based on a list of fixed \"page\", each page contains a fixed number of\n*items.\n* Instead of using a linked-list, a array of pointer is used for fast item\n*look-up.\n* Look-up for an element is as follow:\n* - compute page index: pageIndex = itemIndex / itemsPerPage\n* - look-up item in page: pages_[pageIndex][itemIndex % itemsPerPage]\n*\n* Insertion is amortized constant time (only the array containing the index of\n*pointers\n* need to be reallocated when items are appended).\n*/\nclass JSON_API ValueInternalArray {\n  friend class Value;\n  friend class ValueIteratorBase;\n\npublic:\n  enum {\n    itemsPerPage = 8\n  }; // should be a power of 2 for fast divide and modulo.\n  typedef Value::ArrayIndex ArrayIndex;\n  typedef unsigned int PageIndex;\n\n#ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION\n  struct IteratorState // Must be a POD\n      {\n    IteratorState() : array_(0), currentPageIndex_(0), currentItemIndex_(0) {}\n    ValueInternalArray *array_;\n    Value **currentPageIndex_;\n    unsigned int currentItemIndex_;\n  };\n#endif // ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION\n\n  ValueInternalArray();\n  ValueInternalArray(const ValueInternalArray &other);\n  ValueInternalArray &operator=(ValueInternalArray other);\n  ~ValueInternalArray();\n  void swap(ValueInternalArray &other);\n\n  void clear();\n  void resize(ArrayIndex newSize);\n\n  Value &resolveReference(ArrayIndex index);\n\n  Value *find(ArrayIndex index) const;\n\n  ArrayIndex size() const;\n\n  int compare(const ValueInternalArray &other) const;\n\nprivate:\n  static bool equals(const IteratorState &x, const IteratorState &other);\n  static void increment(IteratorState &iterator);\n  static void decrement(IteratorState &iterator);\n  static Value &dereference(const IteratorState &iterator);\n  static Value &unsafeDereference(const IteratorState &iterator);\n  static int distance(const IteratorState &x, const IteratorState &y);\n  static ArrayIndex indexOf(const IteratorState &iterator);\n  void makeBeginIterator(IteratorState &it) const;\n  void makeEndIterator(IteratorState &it) const;\n  void makeIterator(IteratorState &it, ArrayIndex index) const;\n\n  void makeIndexValid(ArrayIndex index);\n\n  Value **pages_;\n  ArrayIndex size_;\n  PageIndex pageCount_;\n};\n\n/** \\brief Experimental: do not use. Allocator to customize Value internal\narray.\n * Below is an example of a simple implementation (actual implementation use\n * memory pool).\n   \\code\nclass DefaultValueArrayAllocator : public ValueArrayAllocator\n{\npublic: // overridden from ValueArrayAllocator\nvirtual ~DefaultValueArrayAllocator()\n{\n}\n\nvirtual ValueInternalArray *newArray()\n{\n   return new ValueInternalArray();\n}\n\nvirtual ValueInternalArray *newArrayCopy( const ValueInternalArray &other )\n{\n   return new ValueInternalArray( other );\n}\n\nvirtual void destruct( ValueInternalArray *array )\n{\n   delete array;\n}\n\nvirtual void reallocateArrayPageIndex( Value **&indexes,\n                                       ValueInternalArray::PageIndex\n&indexCount,\n                                       ValueInternalArray::PageIndex\nminNewIndexCount )\n{\n   ValueInternalArray::PageIndex newIndexCount = (indexCount*3)/2 + 1;\n   if ( minNewIndexCount > newIndexCount )\n      newIndexCount = minNewIndexCount;\n   void *newIndexes = realloc( indexes, sizeof(Value*) * newIndexCount );\n   if ( !newIndexes )\n      throw std::bad_alloc();\n   indexCount = newIndexCount;\n   indexes = static_cast<Value **>( newIndexes );\n}\nvirtual void releaseArrayPageIndex( Value **indexes,\n                                    ValueInternalArray::PageIndex indexCount )\n{\n   if ( indexes )\n      free( indexes );\n}\n\nvirtual Value *allocateArrayPage()\n{\n   return static_cast<Value *>( malloc( sizeof(Value) *\nValueInternalArray::itemsPerPage ) );\n}\n\nvirtual void releaseArrayPage( Value *value )\n{\n   if ( value )\n      free( value );\n}\n};\n   \\endcode\n */\nclass JSON_API ValueArrayAllocator {\npublic:\n  virtual ~ValueArrayAllocator();\n  virtual ValueInternalArray *newArray() = 0;\n  virtual ValueInternalArray *newArrayCopy(const ValueInternalArray &other) = 0;\n  virtual void destructArray(ValueInternalArray *array) = 0;\n  /** \\brief Reallocate array page index.\n   * Reallocates an array of pointer on each page.\n   * \\param indexes [input] pointer on the current index. May be \\c NULL.\n   *                [output] pointer on the new index of at least\n   *                         \\a minNewIndexCount pages.\n   * \\param indexCount [input] current number of pages in the index.\n   *                   [output] number of page the reallocated index can handle.\n   *                            \\b MUST be >= \\a minNewIndexCount.\n   * \\param minNewIndexCount Minimum number of page the new index must be able\n   * to\n   *                         handle.\n   */\n  virtual void\n  reallocateArrayPageIndex(Value **&indexes,\n                           ValueInternalArray::PageIndex &indexCount,\n                           ValueInternalArray::PageIndex minNewIndexCount) = 0;\n  virtual void\n  releaseArrayPageIndex(Value **indexes,\n                        ValueInternalArray::PageIndex indexCount) = 0;\n  virtual Value *allocateArrayPage() = 0;\n  virtual void releaseArrayPage(Value *value) = 0;\n};\n#endif // #ifdef JSON_VALUE_USE_INTERNAL_MAP\n\n/** \\brief base class for Value iterators.\n *\n */\nclass JSON_API ValueIteratorBase {\npublic:\n  typedef std::bidirectional_iterator_tag iterator_category;\n  typedef unsigned int size_t;\n  typedef int difference_type;\n  typedef ValueIteratorBase SelfType;\n\n  ValueIteratorBase();\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\n  explicit ValueIteratorBase(const Value::ObjectValues::iterator &current);\n#else\n  ValueIteratorBase(const ValueInternalArray::IteratorState &state);\n  ValueIteratorBase(const ValueInternalMap::IteratorState &state);\n#endif\n\n  bool operator==(const SelfType &other) const { return isEqual(other); }\n\n  bool operator!=(const SelfType &other) const { return !isEqual(other); }\n\n  difference_type operator-(const SelfType &other) const {\n    return computeDistance(other);\n  }\n\n  /// Return either the index or the member name of the referenced value as a\n  /// Value.\n  Value key() const;\n\n  /// Return the index of the referenced Value. -1 if it is not an arrayValue.\n  UInt index() const;\n\n  /// Return the member name of the referenced Value. \"\" if it is not an\n  /// objectValue.\n  const char *memberName() const;\n\nprotected:\n  Value &deref() const;\n\n  void increment();\n\n  void decrement();\n\n  difference_type computeDistance(const SelfType &other) const;\n\n  bool isEqual(const SelfType &other) const;\n\n  void copy(const SelfType &other);\n\nprivate:\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\n  Value::ObjectValues::iterator current_;\n  // Indicates that iterator is for a null value.\n  bool isNull_;\n#else\n  union {\n    ValueInternalArray::IteratorState array_;\n    ValueInternalMap::IteratorState map_;\n  } iterator_;\n  bool isArray_;\n#endif\n};\n\n/** \\brief const iterator for object and array value.\n *\n */\nclass JSON_API ValueConstIterator : public ValueIteratorBase {\n  friend class Value;\n\npublic:\n  typedef const Value value_type;\n  typedef unsigned int size_t;\n  typedef int difference_type;\n  typedef const Value &reference;\n  typedef const Value *pointer;\n  typedef ValueConstIterator SelfType;\n\n  ValueConstIterator();\n\nprivate:\n/*! \\internal Use by Value to create an iterator.\n */\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\n  explicit ValueConstIterator(const Value::ObjectValues::iterator &current);\n#else\n  ValueConstIterator(const ValueInternalArray::IteratorState &state);\n  ValueConstIterator(const ValueInternalMap::IteratorState &state);\n#endif\npublic:\n  SelfType &operator=(const ValueIteratorBase &other);\n\n  SelfType operator++(int) {\n    SelfType temp(*this);\n    ++*this;\n    return temp;\n  }\n\n  SelfType operator--(int) {\n    SelfType temp(*this);\n    --*this;\n    return temp;\n  }\n\n  SelfType &operator--() {\n    decrement();\n    return *this;\n  }\n\n  SelfType &operator++() {\n    increment();\n    return *this;\n  }\n\n  reference operator*() const { return deref(); }\n};\n\n/** \\brief Iterator for object and array value.\n */\nclass JSON_API ValueIterator : public ValueIteratorBase {\n  friend class Value;\n\npublic:\n  typedef Value value_type;\n  typedef unsigned int size_t;\n  typedef int difference_type;\n  typedef Value &reference;\n  typedef Value *pointer;\n  typedef ValueIterator SelfType;\n\n  ValueIterator();\n  ValueIterator(const ValueConstIterator &other);\n  ValueIterator(const ValueIterator &other);\n\nprivate:\n/*! \\internal Use by Value to create an iterator.\n */\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\n  explicit ValueIterator(const Value::ObjectValues::iterator &current);\n#else\n  ValueIterator(const ValueInternalArray::IteratorState &state);\n  ValueIterator(const ValueInternalMap::IteratorState &state);\n#endif\npublic:\n  SelfType &operator=(const SelfType &other);\n\n  SelfType operator++(int) {\n    SelfType temp(*this);\n    ++*this;\n    return temp;\n  }\n\n  SelfType operator--(int) {\n    SelfType temp(*this);\n    --*this;\n    return temp;\n  }\n\n  SelfType &operator--() {\n    decrement();\n    return *this;\n  }\n\n  SelfType &operator++() {\n    increment();\n    return *this;\n  }\n\n  reference operator*() const { return deref(); }\n};\n\n} // namespace Json\n\n#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)\n#pragma warning(pop)\n#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)\n\n#endif // CPPTL_JSON_H_INCLUDED\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/json/writer.h",
    "content": "// Copyright 2007-2010 Baptiste Lepilleur\n// Distributed under MIT license, or public domain if desired and\n// recognized in your jurisdiction.\n// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE\n\n#ifndef JSON_WRITER_H_INCLUDED\n#define JSON_WRITER_H_INCLUDED\n\n#if !defined(JSON_IS_AMALGAMATION)\n#include \"value.h\"\n#endif // if !defined(JSON_IS_AMALGAMATION)\n#include <vector>\n#include <string>\n\n// Disable warning C4251: <data member>: <type> needs to have dll-interface to\n// be used by...\n#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)\n#pragma warning(push)\n#pragma warning(disable : 4251)\n#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)\n\nnamespace Json {\n\nclass Value;\n\n/** \\brief Abstract class for writers.\n */\nclass JSON_API Writer {\npublic:\n  virtual ~Writer();\n\n  virtual std::string write(const Value &root) = 0;\n};\n\n/** \\brief Outputs a Value in <a HREF=\"http://www.json.org\">JSON</a> format\n *without formatting (not human friendly).\n *\n * The JSON document is written in a single line. It is not intended for 'human'\n *consumption,\n * but may be usefull to support feature such as RPC where bandwith is limited.\n * \\sa Reader, Value\n */\nclass JSON_API FastWriter : public Writer {\npublic:\n  FastWriter();\n  virtual ~FastWriter() {}\n\n  void enableYAMLCompatibility();\n\n  /** \\brief Drop the \"null\" string from the writer's output for nullValues.\n   * Strictly speaking, this is not valid JSON. But when the output is being\n   * fed to a browser's Javascript, it makes for smaller output and the\n   * browser can handle the output just fine.\n   */\n  void dropNullPlaceholders();\n\n  void omitEndingLineFeed();\n\npublic: // overridden from Writer\n  virtual std::string write(const Value &root);\n\nprivate:\n  void writeValue(const Value &value);\n\n  std::string document_;\n  bool yamlCompatiblityEnabled_;\n  bool dropNullPlaceholders_;\n  bool omitEndingLineFeed_;\n};\n\n/** \\brief Writes a Value in <a HREF=\"http://www.json.org\">JSON</a> format in a\n *human friendly way.\n *\n * The rules for line break and indent are as follow:\n * - Object value:\n *     - if empty then print {} without indent and line break\n *     - if not empty the print '{', line break & indent, print one value per\n *line\n *       and then unindent and line break and print '}'.\n * - Array value:\n *     - if empty then print [] without indent and line break\n *     - if the array contains no object value, empty array or some other value\n *types,\n *       and all the values fit on one lines, then print the array on a single\n *line.\n *     - otherwise, it the values do not fit on one line, or the array contains\n *       object or non empty array, then print one value per line.\n *\n * If the Value have comments then they are outputed according to their\n *#CommentPlacement.\n *\n * \\sa Reader, Value, Value::setComment()\n */\nclass JSON_API StyledWriter : public Writer {\npublic:\n  StyledWriter();\n  virtual ~StyledWriter() {}\n\npublic: // overridden from Writer\n  /** \\brief Serialize a Value in <a HREF=\"http://www.json.org\">JSON</a> format.\n   * \\param root Value to serialize.\n   * \\return String containing the JSON document that represents the root value.\n   */\n  virtual std::string write(const Value &root);\n\nprivate:\n  void writeValue(const Value &value);\n  void writeArrayValue(const Value &value);\n  bool isMultineArray(const Value &value);\n  void pushValue(const std::string &value);\n  void writeIndent();\n  void writeWithIndent(const std::string &value);\n  void indent();\n  void unindent();\n  void writeCommentBeforeValue(const Value &root);\n  void writeCommentAfterValueOnSameLine(const Value &root);\n  bool hasCommentForValue(const Value &value);\n  static std::string normalizeEOL(const std::string &text);\n\n  typedef std::vector<std::string> ChildValues;\n\n  ChildValues childValues_;\n  std::string document_;\n  std::string indentString_;\n  int rightMargin_;\n  int indentSize_;\n  bool addChildValues_;\n};\n\n/** \\brief Writes a Value in <a HREF=\"http://www.json.org\">JSON</a> format in a\n human friendly way,\n     to a stream rather than to a string.\n *\n * The rules for line break and indent are as follow:\n * - Object value:\n *     - if empty then print {} without indent and line break\n *     - if not empty the print '{', line break & indent, print one value per\n line\n *       and then unindent and line break and print '}'.\n * - Array value:\n *     - if empty then print [] without indent and line break\n *     - if the array contains no object value, empty array or some other value\n types,\n *       and all the values fit on one lines, then print the array on a single\n line.\n *     - otherwise, it the values do not fit on one line, or the array contains\n *       object or non empty array, then print one value per line.\n *\n * If the Value have comments then they are outputed according to their\n #CommentPlacement.\n *\n * \\param indentation Each level will be indented by this amount extra.\n * \\sa Reader, Value, Value::setComment()\n */\nclass JSON_API StyledStreamWriter {\npublic:\n  StyledStreamWriter(std::string indentation = \"\\t\");\n  ~StyledStreamWriter() {}\n\npublic:\n  /** \\brief Serialize a Value in <a HREF=\"http://www.json.org\">JSON</a> format.\n   * \\param out Stream to write to. (Can be ostringstream, e.g.)\n   * \\param root Value to serialize.\n   * \\note There is no point in deriving from Writer, since write() should not\n   * return a value.\n   */\n  void write(std::ostream &out, const Value &root);\n\nprivate:\n  void writeValue(const Value &value);\n  void writeArrayValue(const Value &value);\n  bool isMultineArray(const Value &value);\n  void pushValue(const std::string &value);\n  void writeIndent();\n  void writeWithIndent(const std::string &value);\n  void indent();\n  void unindent();\n  void writeCommentBeforeValue(const Value &root);\n  void writeCommentAfterValueOnSameLine(const Value &root);\n  bool hasCommentForValue(const Value &value);\n  static std::string normalizeEOL(const std::string &text);\n\n  typedef std::vector<std::string> ChildValues;\n\n  ChildValues childValues_;\n  std::ostream *document_;\n  std::string indentString_;\n  int rightMargin_;\n  std::string indentation_;\n  bool addChildValues_;\n};\n\n#if defined(JSON_HAS_INT64)\nstd::string JSON_API valueToString(Int value);\nstd::string JSON_API valueToString(UInt value);\n#endif // if defined(JSON_HAS_INT64)\nstd::string JSON_API valueToString(LargestInt value);\nstd::string JSON_API valueToString(LargestUInt value);\nstd::string JSON_API valueToString(double value);\nstd::string JSON_API valueToString(bool value);\nstd::string JSON_API valueToQuotedString(const char *value);\n\n/// \\brief Output using the StyledStreamWriter.\n/// \\see Json::operator>>()\nJSON_API std::ostream &operator<<(std::ostream &, const Value &root);\n\n} // namespace Json\n\n#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)\n#pragma warning(pop)\n#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)\n\n#endif // JSON_WRITER_H_INCLUDED\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/md5/md5.h",
    "content": "/* MD5\n converted to C++ class by Frank Thilo (thilo@unix-ag.org)\n for bzflag (http://www.bzflag.org)\n\n   based on:\n\n   md5.h and md5.c\n   reference implementation of RFC 1321\n\n   Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All\nrights reserved.\n\nLicense to copy and use this software is granted provided that it\nis identified as the \"RSA Data Security, Inc. MD5 Message-Digest\nAlgorithm\" in all material mentioning or referencing this software\nor this function.\n\nLicense is also granted to make and use derivative works provided\nthat such works are identified as \"derived from the RSA Data\nSecurity, Inc. MD5 Message-Digest Algorithm\" in all material\nmentioning or referencing the derived work.\n\nRSA Data Security, Inc. makes no representations concerning either\nthe merchantability of this software or the suitability of this\nsoftware for any particular purpose. It is provided \"as is\"\nwithout express or implied warranty of any kind.\n\nThese notices must be retained in any copies of any part of this\ndocumentation and/or software.\n\n*/\n\n#ifndef BZF_MD5_H\n#define BZF_MD5_H\n\n#include <cstring>\n#include <iostream>\n\n\n// a small class for calculating MD5 hashes of strings or byte arrays\n// it is not meant to be fast or secure\n//\n// usage: 1) feed it blocks of uchars with update()\n//      2) finalize()\n//      3) get hexdigest() string\n//      or\n//      MD5(std::string).hexdigest()\n//\n// assumes that char is 8 bit and int is 32 bit\nclass MD5\n{\npublic:\n  typedef unsigned int size_type; // must be 32bit\n\n  MD5();\n  MD5(const std::string& text);\n  void update(const unsigned char *buf, size_type length);\n  void update(const char *buf, size_type length);\n  MD5& finalize();\n  std::string hexdigest() const;\n  friend std::ostream& operator<<(std::ostream&, MD5 md5);\n  std::string binarydigest() const {return std::string(reinterpret_cast<const char*>(digest), 16);} //Ian Copland, 09/06/2014: added accessor for the raw digest.\n    \nprivate:\n  void init();\n  typedef unsigned char uint1; //  8bit\n  typedef unsigned int uint4;  // 32bit\n  enum {blocksize = 64}; // VC6 won't eat a const static int here\n\n  void transform(const uint1 block[blocksize]);\n  static void decode(uint4 output[], const uint1 input[], size_type len);\n  static void encode(uint1 output[], const uint4 input[], size_type len);\n\n  bool finalized;\n  uint1 buffer[blocksize]; // bytes that didn't fit in last 64 byte chunk\n  uint4 count[2];   // 64bit counter for number of bits (lo, hi)\n  uint4 state[4];   // digest so far\n  uint1 digest[16]; // the result\n\n  // low level logic operations\n  static inline uint4 F(uint4 x, uint4 y, uint4 z);\n  static inline uint4 G(uint4 x, uint4 y, uint4 z);\n  static inline uint4 H(uint4 x, uint4 y, uint4 z);\n  static inline uint4 I(uint4 x, uint4 y, uint4 z);\n  static inline uint4 rotate_left(uint4 x, int n);\n  static inline void FF(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac);\n  static inline void GG(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac);\n  static inline void HH(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac);\n  static inline void II(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac);\n};\n\nstd::string md5(const std::string str);\n\n#endif\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/minizip/crypt.h",
    "content": "/* crypt.h -- base code for crypt/uncrypt ZIPfile\n\n\n   Version 1.01e, February 12th, 2005\n\n   Copyright (C) 1998-2005 Gilles Vollant\n\n   This code is a modified version of crypting code in Infozip distribution\n\n   The encryption/decryption parts of this source code (as opposed to the\n   non-echoing password parts) were originally written in Europe.  The\n   whole source package can be freely distributed, including from the USA.\n   (Prior to January 2000, re-export from the US was a violation of US law.)\n\n   This encryption code is a direct transcription of the algorithm from\n   Roger Schlafly, described by Phil Katz in the file appnote.txt.  This\n   file (appnote.txt) is distributed with the PKZIP program (even in the\n   version without encryption capabilities).\n\n   If you don't need crypting in your application, just define symbols\n   NOCRYPT and NOUNCRYPT.\n\n   This code support the \"Traditional PKWARE Encryption\".\n\n   The new AES encryption added on Zip format by Winzip (see the page\n   http://www.winzip.com/aes_info.htm ) and PKWare PKZip 5.x Strong\n   Encryption is not supported.\n*/\n\n#define CRC32(c, b) ((*(pcrc_32_tab+(((int)(c) ^ (b)) & 0xff))) ^ ((c) >> 8))\n\n/***********************************************************************\n * Return the next byte in the pseudo-random sequence\n */\nstatic int decrypt_byte(unsigned long* pkeys, const unsigned long* pcrc_32_tab)\n{\n    unsigned temp;  /* POTENTIAL BUG:  temp*(temp^1) may overflow in an\n                     * unpredictable manner on 16-bit systems; not a problem\n                     * with any known compiler so far, though */\n\n    temp = ((unsigned)(*(pkeys+2)) & 0xffff) | 2;\n    return (int)(((temp * (temp ^ 1)) >> 8) & 0xff);\n}\n\n/***********************************************************************\n * Update the encryption keys with the next byte of plain text\n */\nstatic int update_keys(unsigned long* pkeys,const unsigned long* pcrc_32_tab,int c)\n{\n    (*(pkeys+0)) = CRC32((*(pkeys+0)), c);\n    (*(pkeys+1)) += (*(pkeys+0)) & 0xff;\n    (*(pkeys+1)) = (*(pkeys+1)) * 134775813L + 1;\n    {\n      register int keyshift = (int)((*(pkeys+1)) >> 24);\n      (*(pkeys+2)) = CRC32((*(pkeys+2)), keyshift);\n    }\n    return c;\n}\n\n\n/***********************************************************************\n * Initialize the encryption keys and the random header according to\n * the given password.\n */\nstatic void init_keys(const char* passwd,unsigned long* pkeys,const unsigned long* pcrc_32_tab)\n{\n    *(pkeys+0) = 305419896L;\n    *(pkeys+1) = 591751049L;\n    *(pkeys+2) = 878082192L;\n    while (*passwd != '\\0') {\n        update_keys(pkeys,pcrc_32_tab,(int)*passwd);\n        passwd++;\n    }\n}\n\n#define zdecode(pkeys,pcrc_32_tab,c) \\\n    (update_keys(pkeys,pcrc_32_tab,c ^= decrypt_byte(pkeys,pcrc_32_tab)))\n\n#define zencode(pkeys,pcrc_32_tab,c,t) \\\n    (t=decrypt_byte(pkeys,pcrc_32_tab), update_keys(pkeys,pcrc_32_tab,c), t^(c))\n\n#ifdef INCLUDECRYPTINGCODE_IFCRYPTALLOWED\n\n#define RAND_HEAD_LEN  12\n   /* \"last resort\" source for second part of crypt seed pattern */\n#  ifndef ZCR_SEED2\n#    define ZCR_SEED2 3141592654UL     /* use PI as default pattern */\n#  endif\n\nstatic int crypthead(const char* passwd,      /* password string */\n                     unsigned char* buf,      /* where to write header */\n                     int bufSize,\n                     unsigned long* pkeys,\n                     const unsigned long* pcrc_32_tab,\n                     unsigned long crcForCrypting)\n{\n    int n;                       /* index in random header */\n    int t;                       /* temporary */\n    int c;                       /* random byte */\n    unsigned char header[RAND_HEAD_LEN-2]; /* random header */\n    static unsigned calls = 0;   /* ensure different random header each time */\n\n    if (bufSize<RAND_HEAD_LEN)\n      return 0;\n\n    /* First generate RAND_HEAD_LEN-2 random bytes. We encrypt the\n     * output of rand() to get less predictability, since rand() is\n     * often poorly implemented.\n     */\n    if (++calls == 1)\n    {\n        srand((unsigned)(time(NULL) ^ ZCR_SEED2));\n    }\n    init_keys(passwd, pkeys, pcrc_32_tab);\n    for (n = 0; n < RAND_HEAD_LEN-2; n++)\n    {\n        c = (rand() >> 7) & 0xff;\n        header[n] = (unsigned char)zencode(pkeys, pcrc_32_tab, c, t);\n    }\n    /* Encrypt random header (last two bytes is high word of crc) */\n    init_keys(passwd, pkeys, pcrc_32_tab);\n    for (n = 0; n < RAND_HEAD_LEN-2; n++)\n    {\n        buf[n] = (unsigned char)zencode(pkeys, pcrc_32_tab, header[n], t);\n    }\n    buf[n++] = (unsigned char)zencode(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 16) & 0xff, t);\n    buf[n++] = (unsigned char)zencode(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 24) & 0xff, t);\n    return n;\n}\n\n#endif\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/minizip/ioapi.h",
    "content": "/* ioapi.h -- IO base function header for compress/uncompress .zip\n   part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )\n\n         Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html )\n\n         Modifications for Zip64 support\n         Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )\n\n         For more info read MiniZip_info.txt\n\n         Changes\n\n    Oct-2009 - Defined ZPOS64_T to fpos_t on windows and u_int64_t on linux. (might need to find a better why for this)\n    Oct-2009 - Change to fseeko64, ftello64 and fopen64 so large files would work on linux.\n               More if/def section may be needed to support other platforms\n    Oct-2009 - Defined fxxxx64 calls to normal fopen/ftell/fseek so they would compile on windows.\n                          (but you should use iowin32.c for windows instead)\n\n*/\n\n#ifndef _ZLIBIOAPI64_H\n#define _ZLIBIOAPI64_H\n\n#if (!defined(_WIN32)) && (!defined(WIN32))\n\n  // Linux needs this to support file operation on files larger then 4+GB\n  // But might need better if/def to select just the platforms that needs them.\n\n        #ifndef __USE_FILE_OFFSET64\n                #define __USE_FILE_OFFSET64\n        #endif\n        #ifndef __USE_LARGEFILE64\n                #define __USE_LARGEFILE64\n        #endif\n        #ifndef _LARGEFILE64_SOURCE\n                #define _LARGEFILE64_SOURCE\n        #endif\n        #ifndef _FILE_OFFSET_BIT\n                #define _FILE_OFFSET_BIT 64\n        #endif\n#endif\n\n#include <stdio.h>\n#include <stdlib.h>\n#include \"zlib.h\"\n\n#if defined(USE_FILE32API)\n#define fopen64 fopen\n#define ftello64 ftell\n#define fseeko64 fseek\n#else\n#ifdef _MSC_VER\n #define fopen64 fopen\n #if (_MSC_VER >= 1400) && (!(defined(NO_MSCVER_FILE64_FUNC)))\n  #define ftello64 _ftelli64\n  #define fseeko64 _fseeki64\n #else // old MSC\n  #define ftello64 ftell\n  #define fseeko64 fseek\n #endif\n#endif\n#endif\n\n/*\n#ifndef ZPOS64_T\n  #ifdef _WIN32\n                #define ZPOS64_T fpos_t\n  #else\n    #include <stdint.h>\n    #define ZPOS64_T uint64_t\n  #endif\n#endif\n*/\n\n#ifdef HAVE_MINIZIP64_CONF_H\n#include \"mz64conf.h\"\n#endif\n\n/* a type choosen by DEFINE */\n#ifdef HAVE_64BIT_INT_CUSTOM\ntypedef  64BIT_INT_CUSTOM_TYPE ZPOS64_T;\n#else\n#ifdef HAS_STDINT_H\n#include \"stdint.h\"\ntypedef uint64_t ZPOS64_T;\n#else\n\n\n#if defined(_MSC_VER) || defined(__BORLANDC__)\ntypedef unsigned __int64 ZPOS64_T;\n#else\ntypedef unsigned long long int ZPOS64_T;\n#endif\n#endif\n#endif\n\n\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n\n#define ZLIB_FILEFUNC_SEEK_CUR (1)\n#define ZLIB_FILEFUNC_SEEK_END (2)\n#define ZLIB_FILEFUNC_SEEK_SET (0)\n\n#define ZLIB_FILEFUNC_MODE_READ      (1)\n#define ZLIB_FILEFUNC_MODE_WRITE     (2)\n#define ZLIB_FILEFUNC_MODE_READWRITEFILTER (3)\n\n#define ZLIB_FILEFUNC_MODE_EXISTING (4)\n#define ZLIB_FILEFUNC_MODE_CREATE   (8)\n\n\n#ifndef ZCALLBACK\n #if (defined(WIN32) || defined(_WIN32) || defined (WINDOWS) || defined (_WINDOWS)) && defined(CALLBACK) && defined (USEWINDOWS_CALLBACK)\n   #define ZCALLBACK CALLBACK\n #else\n   #define ZCALLBACK\n #endif\n#endif\n\n\n\n\ntypedef voidpf   (ZCALLBACK *open_file_func)      OF((voidpf opaque, const char* filename, int mode));\ntypedef uLong    (ZCALLBACK *read_file_func)      OF((voidpf opaque, voidpf stream, void* buf, uLong size));\ntypedef uLong    (ZCALLBACK *write_file_func)     OF((voidpf opaque, voidpf stream, const void* buf, uLong size));\ntypedef int      (ZCALLBACK *close_file_func)     OF((voidpf opaque, voidpf stream));\ntypedef int      (ZCALLBACK *testerror_file_func) OF((voidpf opaque, voidpf stream));\n\ntypedef long     (ZCALLBACK *tell_file_func)      OF((voidpf opaque, voidpf stream));\ntypedef long     (ZCALLBACK *seek_file_func)      OF((voidpf opaque, voidpf stream, uLong offset, int origin));\n\n\n/* here is the \"old\" 32 bits structure structure */\ntypedef struct zlib_filefunc_def_s\n{\n    open_file_func      zopen_file;\n    read_file_func      zread_file;\n    write_file_func     zwrite_file;\n    tell_file_func      ztell_file;\n    seek_file_func      zseek_file;\n    close_file_func     zclose_file;\n    testerror_file_func zerror_file;\n    voidpf              opaque;\n} zlib_filefunc_def;\n\ntypedef ZPOS64_T (ZCALLBACK *tell64_file_func)    OF((voidpf opaque, voidpf stream));\ntypedef long     (ZCALLBACK *seek64_file_func)    OF((voidpf opaque, voidpf stream, ZPOS64_T offset, int origin));\ntypedef voidpf   (ZCALLBACK *open64_file_func)    OF((voidpf opaque, const void* filename, int mode));\n\ntypedef struct zlib_filefunc64_def_s\n{\n    open64_file_func    zopen64_file;\n    read_file_func      zread_file;\n    write_file_func     zwrite_file;\n    tell64_file_func    ztell64_file;\n    seek64_file_func    zseek64_file;\n    close_file_func     zclose_file;\n    testerror_file_func zerror_file;\n    voidpf              opaque;\n} zlib_filefunc64_def;\n\nvoid fill_fopen64_filefunc OF((zlib_filefunc64_def* pzlib_filefunc_def));\nvoid fill_fopen_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def));\n\n/* now internal definition, only for zip.c and unzip.h */\ntypedef struct zlib_filefunc64_32_def_s\n{\n    zlib_filefunc64_def zfile_func64;\n    open_file_func      zopen32_file;\n    tell_file_func      ztell32_file;\n    seek_file_func      zseek32_file;\n} zlib_filefunc64_32_def;\n\n\n#define ZREAD64(filefunc,filestream,buf,size)     ((*((filefunc).zfile_func64.zread_file))   ((filefunc).zfile_func64.opaque,filestream,buf,size))\n#define ZWRITE64(filefunc,filestream,buf,size)    ((*((filefunc).zfile_func64.zwrite_file))  ((filefunc).zfile_func64.opaque,filestream,buf,size))\n//#define ZTELL64(filefunc,filestream)            ((*((filefunc).ztell64_file)) ((filefunc).opaque,filestream))\n//#define ZSEEK64(filefunc,filestream,pos,mode)   ((*((filefunc).zseek64_file)) ((filefunc).opaque,filestream,pos,mode))\n#define ZCLOSE64(filefunc,filestream)             ((*((filefunc).zfile_func64.zclose_file))  ((filefunc).zfile_func64.opaque,filestream))\n#define ZERROR64(filefunc,filestream)             ((*((filefunc).zfile_func64.zerror_file))  ((filefunc).zfile_func64.opaque,filestream))\n\nvoidpf call_zopen64 OF((const zlib_filefunc64_32_def* pfilefunc,const void*filename,int mode));\nlong    call_zseek64 OF((const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZPOS64_T offset, int origin));\nZPOS64_T call_ztell64 OF((const zlib_filefunc64_32_def* pfilefunc,voidpf filestream));\n\nvoid    fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filefunc64_32,const zlib_filefunc_def* p_filefunc32);\n\n#define ZOPEN64(filefunc,filename,mode)         (call_zopen64((&(filefunc)),(filename),(mode)))\n#define ZTELL64(filefunc,filestream)            (call_ztell64((&(filefunc)),(filestream)))\n#define ZSEEK64(filefunc,filestream,pos,mode)   (call_zseek64((&(filefunc)),(filestream),(pos),(mode)))\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/minizip/mztools.h",
    "content": "/*\n  Additional tools for Minizip\n  Code: Xavier Roche '2004\n  License: Same as ZLIB (www.gzip.org)\n*/\n\n#ifndef _zip_tools_H\n#define _zip_tools_H\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#ifndef _ZLIB_H\n#include \"zlib.h\"\n#endif\n\n#include \"unzip.h\"\n\n/* Repair a ZIP file (missing central directory)\n   file: file to recover\n   fileOut: output file after recovery\n   fileOutTmp: temporary file name used for recovery\n*/\nextern int ZEXPORT unzRepair(const char* file,\n                             const char* fileOut,\n                             const char* fileOutTmp,\n                             uLong* nRecovered,\n                             uLong* bytesRecovered);\n\n#endif\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/minizip/unzip.h",
    "content": "/* unzip.h -- IO for uncompress .zip files using zlib\n   Version 1.1, February 14h, 2010\n   part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )\n\n         Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html )\n\n         Modifications of Unzip for Zip64\n         Copyright (C) 2007-2008 Even Rouault\n\n         Modifications for Zip64 support on both zip and unzip\n         Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )\n\n         For more info read MiniZip_info.txt\n\n         ---------------------------------------------------------------------------------\n\n        Condition of use and distribution are the same than zlib :\n\n  This software is provided 'as-is', without any express or implied\n  warranty.  In no event will the authors be held liable for any damages\n  arising from the use of this software.\n\n  Permission is granted to anyone to use this software for any purpose,\n  including commercial applications, and to alter it and redistribute it\n  freely, subject to the following restrictions:\n\n  1. The origin of this software must not be misrepresented; you must not\n     claim that you wrote the original software. If you use this software\n     in a product, an acknowledgment in the product documentation would be\n     appreciated but is not required.\n  2. Altered source versions must be plainly marked as such, and must not be\n     misrepresented as being the original software.\n  3. This notice may not be removed or altered from any source distribution.\n\n  ---------------------------------------------------------------------------------\n\n        Changes\n\n        See header of unzip64.c\n\n*/\n\n#ifndef _unz64_H\n#define _unz64_H\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#ifndef _ZLIB_H\n#include \"zlib.h\"\n#endif\n\n#ifndef  _ZLIBIOAPI_H\n#include \"ioapi.h\"\n#endif\n\n#ifdef HAVE_BZIP2\n#include \"bzlib.h\"\n#endif\n\n#define Z_BZIP2ED 12\n\n#if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP)\n/* like the STRICT of WIN32, we define a pointer that cannot be converted\n    from (void*) without cast */\ntypedef struct TagunzFile__ { int unused; } unzFile__;\ntypedef unzFile__ *unzFile;\n#else\ntypedef voidp unzFile;\n#endif\n\n\n#define UNZ_OK                          (0)\n#define UNZ_END_OF_LIST_OF_FILE         (-100)\n#define UNZ_ERRNO                       (Z_ERRNO)\n#define UNZ_EOF                         (0)\n#define UNZ_PARAMERROR                  (-102)\n#define UNZ_BADZIPFILE                  (-103)\n#define UNZ_INTERNALERROR               (-104)\n#define UNZ_CRCERROR                    (-105)\n\n/* tm_unz contain date/time info */\ntypedef struct tm_unz_s\n{\n    uInt tm_sec;            /* seconds after the minute - [0,59] */\n    uInt tm_min;            /* minutes after the hour - [0,59] */\n    uInt tm_hour;           /* hours since midnight - [0,23] */\n    uInt tm_mday;           /* day of the month - [1,31] */\n    uInt tm_mon;            /* months since January - [0,11] */\n    uInt tm_year;           /* years - [1980..2044] */\n} tm_unz;\n\n/* unz_global_info structure contain global data about the ZIPfile\n   These data comes from the end of central dir */\ntypedef struct unz_global_info64_s\n{\n    ZPOS64_T number_entry;         /* total number of entries in\n                                     the central dir on this disk */\n    uLong size_comment;         /* size of the global comment of the zipfile */\n} unz_global_info64;\n\ntypedef struct unz_global_info_s\n{\n    uLong number_entry;         /* total number of entries in\n                                     the central dir on this disk */\n    uLong size_comment;         /* size of the global comment of the zipfile */\n} unz_global_info;\n\n/* unz_file_info contain information about a file in the zipfile */\ntypedef struct unz_file_info64_s\n{\n    uLong version;              /* version made by                 2 bytes */\n    uLong version_needed;       /* version needed to extract       2 bytes */\n    uLong flag;                 /* general purpose bit flag        2 bytes */\n    uLong compression_method;   /* compression method              2 bytes */\n    uLong dosDate;              /* last mod file date in Dos fmt   4 bytes */\n    uLong crc;                  /* crc-32                          4 bytes */\n    ZPOS64_T compressed_size;   /* compressed size                 8 bytes */\n    ZPOS64_T uncompressed_size; /* uncompressed size               8 bytes */\n    uLong size_filename;        /* filename length                 2 bytes */\n    uLong size_file_extra;      /* extra field length              2 bytes */\n    uLong size_file_comment;    /* file comment length             2 bytes */\n\n    uLong disk_num_start;       /* disk number start               2 bytes */\n    uLong internal_fa;          /* internal file attributes        2 bytes */\n    uLong external_fa;          /* external file attributes        4 bytes */\n\n    tm_unz tmu_date;\n} unz_file_info64;\n\ntypedef struct unz_file_info_s\n{\n    uLong version;              /* version made by                 2 bytes */\n    uLong version_needed;       /* version needed to extract       2 bytes */\n    uLong flag;                 /* general purpose bit flag        2 bytes */\n    uLong compression_method;   /* compression method              2 bytes */\n    uLong dosDate;              /* last mod file date in Dos fmt   4 bytes */\n    uLong crc;                  /* crc-32                          4 bytes */\n    uLong compressed_size;      /* compressed size                 4 bytes */\n    uLong uncompressed_size;    /* uncompressed size               4 bytes */\n    uLong size_filename;        /* filename length                 2 bytes */\n    uLong size_file_extra;      /* extra field length              2 bytes */\n    uLong size_file_comment;    /* file comment length             2 bytes */\n\n    uLong disk_num_start;       /* disk number start               2 bytes */\n    uLong internal_fa;          /* internal file attributes        2 bytes */\n    uLong external_fa;          /* external file attributes        4 bytes */\n\n    tm_unz tmu_date;\n} unz_file_info;\n\nextern int ZEXPORT unzStringFileNameCompare OF ((const char* fileName1,\n                                                 const char* fileName2,\n                                                 int iCaseSensitivity));\n/*\n   Compare two filename (fileName1,fileName2).\n   If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp)\n   If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi\n                                or strcasecmp)\n   If iCaseSenisivity = 0, case sensitivity is defaut of your operating system\n    (like 1 on Unix, 2 on Windows)\n*/\n\n\nextern unzFile ZEXPORT unzOpen OF((const char *path));\nextern unzFile ZEXPORT unzOpen64 OF((const void *path));\n/*\n  Open a Zip file. path contain the full pathname (by example,\n     on a Windows XP computer \"c:\\\\zlib\\\\zlib113.zip\" or on an Unix computer\n     \"zlib/zlib113.zip\".\n     If the zipfile cannot be opened (file don't exist or in not valid), the\n       return value is NULL.\n     Else, the return value is a unzFile Handle, usable with other function\n       of this unzip package.\n     the \"64\" function take a const void* pointer, because the path is just the\n       value passed to the open64_file_func callback.\n     Under Windows, if UNICODE is defined, using fill_fopen64_filefunc, the path\n       is a pointer to a wide unicode string (LPCTSTR is LPCWSTR), so const char*\n       does not describe the reality\n*/\n\n\nextern unzFile ZEXPORT unzOpen2 OF((const char *path,\n                                    zlib_filefunc_def* pzlib_filefunc_def));\n/*\n   Open a Zip file, like unzOpen, but provide a set of file low level API\n      for read/write the zip file (see ioapi.h)\n*/\n\nextern unzFile ZEXPORT unzOpen2_64 OF((const void *path,\n                                    zlib_filefunc64_def* pzlib_filefunc_def));\n/*\n   Open a Zip file, like unz64Open, but provide a set of file low level API\n      for read/write the zip file (see ioapi.h)\n*/\n\nextern int ZEXPORT unzClose OF((unzFile file));\n/*\n  Close a ZipFile opened with unzipOpen.\n  If there is files inside the .Zip opened with unzOpenCurrentFile (see later),\n    these files MUST be closed with unzipCloseCurrentFile before call unzipClose.\n  return UNZ_OK if there is no problem. */\n\nextern int ZEXPORT unzGetGlobalInfo OF((unzFile file,\n                                        unz_global_info *pglobal_info));\n\nextern int ZEXPORT unzGetGlobalInfo64 OF((unzFile file,\n                                        unz_global_info64 *pglobal_info));\n/*\n  Write info about the ZipFile in the *pglobal_info structure.\n  No preparation of the structure is needed\n  return UNZ_OK if there is no problem. */\n\n\nextern int ZEXPORT unzGetGlobalComment OF((unzFile file,\n                                           char *szComment,\n                                           uLong uSizeBuf));\n/*\n  Get the global comment string of the ZipFile, in the szComment buffer.\n  uSizeBuf is the size of the szComment buffer.\n  return the number of byte copied or an error code <0\n*/\n\n\n/***************************************************************************/\n/* Unzip package allow you browse the directory of the zipfile */\n\nextern int ZEXPORT unzGoToFirstFile OF((unzFile file));\n/*\n  Set the current file of the zipfile to the first file.\n  return UNZ_OK if there is no problem\n*/\n\nextern int ZEXPORT unzGoToNextFile OF((unzFile file));\n/*\n  Set the current file of the zipfile to the next file.\n  return UNZ_OK if there is no problem\n  return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest.\n*/\n\nextern int ZEXPORT unzLocateFile OF((unzFile file,\n                     const char *szFileName,\n                     int iCaseSensitivity));\n/*\n  Try locate the file szFileName in the zipfile.\n  For the iCaseSensitivity signification, see unzStringFileNameCompare\n\n  return value :\n  UNZ_OK if the file is found. It becomes the current file.\n  UNZ_END_OF_LIST_OF_FILE if the file is not found\n*/\n\n\n/* ****************************************** */\n/* Ryan supplied functions */\n/* unz_file_info contain information about a file in the zipfile */\ntypedef struct unz_file_pos_s\n{\n    uLong pos_in_zip_directory;   /* offset in zip file directory */\n    uLong num_of_file;            /* # of file */\n} unz_file_pos;\n\nextern int ZEXPORT unzGetFilePos(\n    unzFile file,\n    unz_file_pos* file_pos);\n\nextern int ZEXPORT unzGoToFilePos(\n    unzFile file,\n    unz_file_pos* file_pos);\n\ntypedef struct unz64_file_pos_s\n{\n    ZPOS64_T pos_in_zip_directory;   /* offset in zip file directory */\n    ZPOS64_T num_of_file;            /* # of file */\n} unz64_file_pos;\n\nextern int ZEXPORT unzGetFilePos64(\n    unzFile file,\n    unz64_file_pos* file_pos);\n\nextern int ZEXPORT unzGoToFilePos64(\n    unzFile file,\n    const unz64_file_pos* file_pos);\n\n/* ****************************************** */\n\nextern int ZEXPORT unzGetCurrentFileInfo64 OF((unzFile file,\n                         unz_file_info64 *pfile_info,\n                         char *szFileName,\n                         uLong fileNameBufferSize,\n                         void *extraField,\n                         uLong extraFieldBufferSize,\n                         char *szComment,\n                         uLong commentBufferSize));\n\nextern int ZEXPORT unzGetCurrentFileInfo OF((unzFile file,\n                         unz_file_info *pfile_info,\n                         char *szFileName,\n                         uLong fileNameBufferSize,\n                         void *extraField,\n                         uLong extraFieldBufferSize,\n                         char *szComment,\n                         uLong commentBufferSize));\n/*\n  Get Info about the current file\n  if pfile_info!=NULL, the *pfile_info structure will contain somes info about\n        the current file\n  if szFileName!=NULL, the filemane string will be copied in szFileName\n            (fileNameBufferSize is the size of the buffer)\n  if extraField!=NULL, the extra field information will be copied in extraField\n            (extraFieldBufferSize is the size of the buffer).\n            This is the Central-header version of the extra field\n  if szComment!=NULL, the comment string of the file will be copied in szComment\n            (commentBufferSize is the size of the buffer)\n*/\n\n\n/** Addition for GDAL : START */\n\nextern ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64 OF((unzFile file));\n\n/** Addition for GDAL : END */\n\n\n/***************************************************************************/\n/* for reading the content of the current zipfile, you can open it, read data\n   from it, and close it (you can close it before reading all the file)\n   */\n\nextern int ZEXPORT unzOpenCurrentFile OF((unzFile file));\n/*\n  Open for reading data the current file in the zipfile.\n  If there is no error, the return value is UNZ_OK.\n*/\n\nextern int ZEXPORT unzOpenCurrentFilePassword OF((unzFile file,\n                                                  const char* password));\n/*\n  Open for reading data the current file in the zipfile.\n  password is a crypting password\n  If there is no error, the return value is UNZ_OK.\n*/\n\nextern int ZEXPORT unzOpenCurrentFile2 OF((unzFile file,\n                                           int* method,\n                                           int* level,\n                                           int raw));\n/*\n  Same than unzOpenCurrentFile, but open for read raw the file (not uncompress)\n    if raw==1\n  *method will receive method of compression, *level will receive level of\n     compression\n  note : you can set level parameter as NULL (if you did not want known level,\n         but you CANNOT set method parameter as NULL\n*/\n\nextern int ZEXPORT unzOpenCurrentFile3 OF((unzFile file,\n                                           int* method,\n                                           int* level,\n                                           int raw,\n                                           const char* password));\n/*\n  Same than unzOpenCurrentFile, but open for read raw the file (not uncompress)\n    if raw==1\n  *method will receive method of compression, *level will receive level of\n     compression\n  note : you can set level parameter as NULL (if you did not want known level,\n         but you CANNOT set method parameter as NULL\n*/\n\n\nextern int ZEXPORT unzCloseCurrentFile OF((unzFile file));\n/*\n  Close the file in zip opened with unzOpenCurrentFile\n  Return UNZ_CRCERROR if all the file was read but the CRC is not good\n*/\n\nextern int ZEXPORT unzReadCurrentFile OF((unzFile file,\n                      voidp buf,\n                      unsigned len));\n/*\n  Read bytes from the current file (opened by unzOpenCurrentFile)\n  buf contain buffer where data must be copied\n  len the size of buf.\n\n  return the number of byte copied if somes bytes are copied\n  return 0 if the end of file was reached\n  return <0 with error code if there is an error\n    (UNZ_ERRNO for IO error, or zLib error for uncompress error)\n*/\n\nextern z_off_t ZEXPORT unztell OF((unzFile file));\n\nextern ZPOS64_T ZEXPORT unztell64 OF((unzFile file));\n/*\n  Give the current position in uncompressed data\n*/\n\nextern int ZEXPORT unzeof OF((unzFile file));\n/*\n  return 1 if the end of file was reached, 0 elsewhere\n*/\n\nextern int ZEXPORT unzGetLocalExtrafield OF((unzFile file,\n                                             voidp buf,\n                                             unsigned len));\n/*\n  Read extra field from the current file (opened by unzOpenCurrentFile)\n  This is the local-header version of the extra field (sometimes, there is\n    more info in the local-header version than in the central-header)\n\n  if buf==NULL, it return the size of the local extra field\n\n  if buf!=NULL, len is the size of the buffer, the extra header is copied in\n    buf.\n  the return value is the number of bytes copied in buf, or (if <0)\n    the error code\n*/\n\n/***************************************************************************/\n\n/* Get the current file offset */\nextern ZPOS64_T ZEXPORT unzGetOffset64 (unzFile file);\nextern uLong ZEXPORT unzGetOffset (unzFile file);\n\n/* Set the current file offset */\nextern int ZEXPORT unzSetOffset64 (unzFile file, ZPOS64_T pos);\nextern int ZEXPORT unzSetOffset (unzFile file, uLong pos);\n\n\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* _unz64_H */\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/minizip/zip.h",
    "content": "/* zip.h -- IO on .zip files using zlib\n   Version 1.1, February 14h, 2010\n   part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )\n\n         Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html )\n\n         Modifications for Zip64 support\n         Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )\n\n         For more info read MiniZip_info.txt\n\n         ---------------------------------------------------------------------------\n\n   Condition of use and distribution are the same than zlib :\n\n  This software is provided 'as-is', without any express or implied\n  warranty.  In no event will the authors be held liable for any damages\n  arising from the use of this software.\n\n  Permission is granted to anyone to use this software for any purpose,\n  including commercial applications, and to alter it and redistribute it\n  freely, subject to the following restrictions:\n\n  1. The origin of this software must not be misrepresented; you must not\n     claim that you wrote the original software. If you use this software\n     in a product, an acknowledgment in the product documentation would be\n     appreciated but is not required.\n  2. Altered source versions must be plainly marked as such, and must not be\n     misrepresented as being the original software.\n  3. This notice may not be removed or altered from any source distribution.\n\n        ---------------------------------------------------------------------------\n\n        Changes\n\n        See header of zip.h\n\n*/\n\n#ifndef _zip12_H\n#define _zip12_H\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n//#define HAVE_BZIP2\n\n#ifndef _ZLIB_H\n#include \"zlib.h\"\n#endif\n\n#ifndef _ZLIBIOAPI_H\n#include \"ioapi.h\"\n#endif\n\n#ifdef HAVE_BZIP2\n#include \"bzlib.h\"\n#endif\n\n#define Z_BZIP2ED 12\n\n#if defined(STRICTZIP) || defined(STRICTZIPUNZIP)\n/* like the STRICT of WIN32, we define a pointer that cannot be converted\n    from (void*) without cast */\ntypedef struct TagzipFile__ { int unused; } zipFile__;\ntypedef zipFile__ *zipFile;\n#else\ntypedef voidp zipFile;\n#endif\n\n#define ZIP_OK                          (0)\n#define ZIP_EOF                         (0)\n#define ZIP_ERRNO                       (Z_ERRNO)\n#define ZIP_PARAMERROR                  (-102)\n#define ZIP_BADZIPFILE                  (-103)\n#define ZIP_INTERNALERROR               (-104)\n\n#ifndef DEF_MEM_LEVEL\n#  if MAX_MEM_LEVEL >= 8\n#    define DEF_MEM_LEVEL 8\n#  else\n#    define DEF_MEM_LEVEL  MAX_MEM_LEVEL\n#  endif\n#endif\n/* default memLevel */\n\n/* tm_zip contain date/time info */\ntypedef struct tm_zip_s\n{\n    uInt tm_sec;            /* seconds after the minute - [0,59] */\n    uInt tm_min;            /* minutes after the hour - [0,59] */\n    uInt tm_hour;           /* hours since midnight - [0,23] */\n    uInt tm_mday;           /* day of the month - [1,31] */\n    uInt tm_mon;            /* months since January - [0,11] */\n    uInt tm_year;           /* years - [1980..2044] */\n} tm_zip;\n\ntypedef struct\n{\n    tm_zip      tmz_date;       /* date in understandable format           */\n    uLong       dosDate;       /* if dos_date == 0, tmu_date is used      */\n/*    uLong       flag;        */   /* general purpose bit flag        2 bytes */\n\n    uLong       internal_fa;    /* internal file attributes        2 bytes */\n    uLong       external_fa;    /* external file attributes        4 bytes */\n} zip_fileinfo;\n\ntypedef const char* zipcharpc;\n\n\n#define APPEND_STATUS_CREATE        (0)\n#define APPEND_STATUS_CREATEAFTER   (1)\n#define APPEND_STATUS_ADDINZIP      (2)\n\nextern zipFile ZEXPORT zipOpen OF((const char *pathname, int append));\nextern zipFile ZEXPORT zipOpen64 OF((const void *pathname, int append));\n/*\n  Create a zipfile.\n     pathname contain on Windows XP a filename like \"c:\\\\zlib\\\\zlib113.zip\" or on\n       an Unix computer \"zlib/zlib113.zip\".\n     if the file pathname exist and append==APPEND_STATUS_CREATEAFTER, the zip\n       will be created at the end of the file.\n         (useful if the file contain a self extractor code)\n     if the file pathname exist and append==APPEND_STATUS_ADDINZIP, we will\n       add files in existing zip (be sure you don't add file that doesn't exist)\n     If the zipfile cannot be opened, the return value is NULL.\n     Else, the return value is a zipFile Handle, usable with other function\n       of this zip package.\n*/\n\n/* Note : there is no delete function into a zipfile.\n   If you want delete file into a zipfile, you must open a zipfile, and create another\n   Of couse, you can use RAW reading and writing to copy the file you did not want delte\n*/\n\nextern zipFile ZEXPORT zipOpen2 OF((const char *pathname,\n                                   int append,\n                                   zipcharpc* globalcomment,\n                                   zlib_filefunc_def* pzlib_filefunc_def));\n\nextern zipFile ZEXPORT zipOpen2_64 OF((const void *pathname,\n                                   int append,\n                                   zipcharpc* globalcomment,\n                                   zlib_filefunc64_def* pzlib_filefunc_def));\n\nextern int ZEXPORT zipOpenNewFileInZip OF((zipFile file,\n                       const char* filename,\n                       const zip_fileinfo* zipfi,\n                       const void* extrafield_local,\n                       uInt size_extrafield_local,\n                       const void* extrafield_global,\n                       uInt size_extrafield_global,\n                       const char* comment,\n                       int method,\n                       int level));\n\nextern int ZEXPORT zipOpenNewFileInZip64 OF((zipFile file,\n                       const char* filename,\n                       const zip_fileinfo* zipfi,\n                       const void* extrafield_local,\n                       uInt size_extrafield_local,\n                       const void* extrafield_global,\n                       uInt size_extrafield_global,\n                       const char* comment,\n                       int method,\n                       int level,\n                       int zip64));\n\n/*\n  Open a file in the ZIP for writing.\n  filename : the filename in zip (if NULL, '-' without quote will be used\n  *zipfi contain supplemental information\n  if extrafield_local!=NULL and size_extrafield_local>0, extrafield_local\n    contains the extrafield data the the local header\n  if extrafield_global!=NULL and size_extrafield_global>0, extrafield_global\n    contains the extrafield data the the local header\n  if comment != NULL, comment contain the comment string\n  method contain the compression method (0 for store, Z_DEFLATED for deflate)\n  level contain the level of compression (can be Z_DEFAULT_COMPRESSION)\n  zip64 is set to 1 if a zip64 extended information block should be added to the local file header.\n                    this MUST be '1' if the uncompressed size is >= 0xffffffff.\n\n*/\n\n\nextern int ZEXPORT zipOpenNewFileInZip2 OF((zipFile file,\n                                            const char* filename,\n                                            const zip_fileinfo* zipfi,\n                                            const void* extrafield_local,\n                                            uInt size_extrafield_local,\n                                            const void* extrafield_global,\n                                            uInt size_extrafield_global,\n                                            const char* comment,\n                                            int method,\n                                            int level,\n                                            int raw));\n\n\nextern int ZEXPORT zipOpenNewFileInZip2_64 OF((zipFile file,\n                                            const char* filename,\n                                            const zip_fileinfo* zipfi,\n                                            const void* extrafield_local,\n                                            uInt size_extrafield_local,\n                                            const void* extrafield_global,\n                                            uInt size_extrafield_global,\n                                            const char* comment,\n                                            int method,\n                                            int level,\n                                            int raw,\n                                            int zip64));\n/*\n  Same than zipOpenNewFileInZip, except if raw=1, we write raw file\n */\n\nextern int ZEXPORT zipOpenNewFileInZip3 OF((zipFile file,\n                                            const char* filename,\n                                            const zip_fileinfo* zipfi,\n                                            const void* extrafield_local,\n                                            uInt size_extrafield_local,\n                                            const void* extrafield_global,\n                                            uInt size_extrafield_global,\n                                            const char* comment,\n                                            int method,\n                                            int level,\n                                            int raw,\n                                            int windowBits,\n                                            int memLevel,\n                                            int strategy,\n                                            const char* password,\n                                            uLong crcForCrypting));\n\nextern int ZEXPORT zipOpenNewFileInZip3_64 OF((zipFile file,\n                                            const char* filename,\n                                            const zip_fileinfo* zipfi,\n                                            const void* extrafield_local,\n                                            uInt size_extrafield_local,\n                                            const void* extrafield_global,\n                                            uInt size_extrafield_global,\n                                            const char* comment,\n                                            int method,\n                                            int level,\n                                            int raw,\n                                            int windowBits,\n                                            int memLevel,\n                                            int strategy,\n                                            const char* password,\n                                            uLong crcForCrypting,\n                                            int zip64\n                                            ));\n\n/*\n  Same than zipOpenNewFileInZip2, except\n    windowBits,memLevel,,strategy : see parameter strategy in deflateInit2\n    password : crypting password (NULL for no crypting)\n    crcForCrypting : crc of file to compress (needed for crypting)\n */\n\nextern int ZEXPORT zipOpenNewFileInZip4 OF((zipFile file,\n                                            const char* filename,\n                                            const zip_fileinfo* zipfi,\n                                            const void* extrafield_local,\n                                            uInt size_extrafield_local,\n                                            const void* extrafield_global,\n                                            uInt size_extrafield_global,\n                                            const char* comment,\n                                            int method,\n                                            int level,\n                                            int raw,\n                                            int windowBits,\n                                            int memLevel,\n                                            int strategy,\n                                            const char* password,\n                                            uLong crcForCrypting,\n                                            uLong versionMadeBy,\n                                            uLong flagBase\n                                            ));\n\n\nextern int ZEXPORT zipOpenNewFileInZip4_64 OF((zipFile file,\n                                            const char* filename,\n                                            const zip_fileinfo* zipfi,\n                                            const void* extrafield_local,\n                                            uInt size_extrafield_local,\n                                            const void* extrafield_global,\n                                            uInt size_extrafield_global,\n                                            const char* comment,\n                                            int method,\n                                            int level,\n                                            int raw,\n                                            int windowBits,\n                                            int memLevel,\n                                            int strategy,\n                                            const char* password,\n                                            uLong crcForCrypting,\n                                            uLong versionMadeBy,\n                                            uLong flagBase,\n                                            int zip64\n                                            ));\n/*\n  Same than zipOpenNewFileInZip4, except\n    versionMadeBy : value for Version made by field\n    flag : value for flag field (compression level info will be added)\n */\n\n\nextern int ZEXPORT zipWriteInFileInZip OF((zipFile file,\n                       const void* buf,\n                       unsigned len));\n/*\n  Write data in the zipfile\n*/\n\nextern int ZEXPORT zipCloseFileInZip OF((zipFile file));\n/*\n  Close the current file in the zipfile\n*/\n\nextern int ZEXPORT zipCloseFileInZipRaw OF((zipFile file,\n                                            uLong uncompressed_size,\n                                            uLong crc32));\n\nextern int ZEXPORT zipCloseFileInZipRaw64 OF((zipFile file,\n                                            ZPOS64_T uncompressed_size,\n                                            uLong crc32));\n\n/*\n  Close the current file in the zipfile, for file opened with\n    parameter raw=1 in zipOpenNewFileInZip2\n  uncompressed_size and crc32 are value for the uncompressed size\n*/\n\nextern int ZEXPORT zipClose OF((zipFile file,\n                const char* global_comment));\n/*\n  Close the zipfile\n*/\n\n\nextern int ZEXPORT zipRemoveExtraInfoBlock OF((char* pData, int* dataLen, short sHeader));\n/*\n  zipRemoveExtraInfoBlock -  Added by Mathias Svensson\n\n  Remove extra information block from a extra information data for the local file header or central directory header\n\n  It is needed to remove ZIP64 extra information blocks when before data is written if using RAW mode.\n\n  0x0001 is the signature header for the ZIP64 extra information blocks\n\n  usage.\n                        Remove ZIP64 Extra information from a central director extra field data\n              zipRemoveExtraInfoBlock(pCenDirExtraFieldData, &nCenDirExtraFieldDataLen, 0x0001);\n\n                        Remove ZIP64 Extra information from a Local File Header extra field data\n        zipRemoveExtraInfoBlock(pLocalHeaderExtraFieldData, &nLocalHeaderExtraFieldDataLen, 0x0001);\n*/\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* _zip64_H */\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/png/png.h",
    "content": "\n/* png.h - header file for PNG reference library\n *\n * libpng version 1.6.10 - March 6, 2014\n * Copyright (c) 1998-2014 Glenn Randers-Pehrson\n * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)\n * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)\n *\n * This code is released under the libpng license (See LICENSE, below)\n *\n * Authors and maintainers:\n *   libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat\n *   libpng versions 0.89c, June 1996, through 0.96, May 1997: Andreas Dilger\n *   libpng versions 0.97, January 1998, through 1.6.10 - March 6, 2014: Glenn\n *   See also \"Contributing Authors\", below.\n *\n * Note about libpng version numbers:\n *\n *   Due to various miscommunications, unforeseen code incompatibilities\n *   and occasional factors outside the authors' control, version numbering\n *   on the library has not always been consistent and straightforward.\n *   The following table summarizes matters since version 0.89c, which was\n *   the first widely used release:\n *\n *    source                 png.h  png.h  shared-lib\n *    version                string   int  version\n *    -------                ------ -----  ----------\n *    0.89c \"1.0 beta 3\"     0.89      89  1.0.89\n *    0.90  \"1.0 beta 4\"     0.90      90  0.90  [should have been 2.0.90]\n *    0.95  \"1.0 beta 5\"     0.95      95  0.95  [should have been 2.0.95]\n *    0.96  \"1.0 beta 6\"     0.96      96  0.96  [should have been 2.0.96]\n *    0.97b \"1.00.97 beta 7\" 1.00.97   97  1.0.1 [should have been 2.0.97]\n *    0.97c                  0.97      97  2.0.97\n *    0.98                   0.98      98  2.0.98\n *    0.99                   0.99      98  2.0.99\n *    0.99a-m                0.99      99  2.0.99\n *    1.00                   1.00     100  2.1.0 [100 should be 10000]\n *    1.0.0      (from here on, the   100  2.1.0 [100 should be 10000]\n *    1.0.1       png.h string is   10001  2.1.0\n *    1.0.1a-e    identical to the  10002  from here on, the shared library\n *    1.0.2       source version)   10002  is 2.V where V is the source code\n *    1.0.2a-b                      10003  version, except as noted.\n *    1.0.3                         10003\n *    1.0.3a-d                      10004\n *    1.0.4                         10004\n *    1.0.4a-f                      10005\n *    1.0.5 (+ 2 patches)           10005\n *    1.0.5a-d                      10006\n *    1.0.5e-r                      10100 (not source compatible)\n *    1.0.5s-v                      10006 (not binary compatible)\n *    1.0.6 (+ 3 patches)           10006 (still binary incompatible)\n *    1.0.6d-f                      10007 (still binary incompatible)\n *    1.0.6g                        10007\n *    1.0.6h                        10007  10.6h (testing xy.z so-numbering)\n *    1.0.6i                        10007  10.6i\n *    1.0.6j                        10007  2.1.0.6j (incompatible with 1.0.0)\n *    1.0.7beta11-14        DLLNUM  10007  2.1.0.7beta11-14 (binary compatible)\n *    1.0.7beta15-18           1    10007  2.1.0.7beta15-18 (binary compatible)\n *    1.0.7rc1-2               1    10007  2.1.0.7rc1-2 (binary compatible)\n *    1.0.7                    1    10007  (still compatible)\n *    1.0.8beta1-4             1    10008  2.1.0.8beta1-4\n *    1.0.8rc1                 1    10008  2.1.0.8rc1\n *    1.0.8                    1    10008  2.1.0.8\n *    1.0.9beta1-6             1    10009  2.1.0.9beta1-6\n *    1.0.9rc1                 1    10009  2.1.0.9rc1\n *    1.0.9beta7-10            1    10009  2.1.0.9beta7-10\n *    1.0.9rc2                 1    10009  2.1.0.9rc2\n *    1.0.9                    1    10009  2.1.0.9\n *    1.0.10beta1              1    10010  2.1.0.10beta1\n *    1.0.10rc1                1    10010  2.1.0.10rc1\n *    1.0.10                   1    10010  2.1.0.10\n *    1.0.11beta1-3            1    10011  2.1.0.11beta1-3\n *    1.0.11rc1                1    10011  2.1.0.11rc1\n *    1.0.11                   1    10011  2.1.0.11\n *    1.0.12beta1-2            2    10012  2.1.0.12beta1-2\n *    1.0.12rc1                2    10012  2.1.0.12rc1\n *    1.0.12                   2    10012  2.1.0.12\n *    1.1.0a-f                 -    10100  2.1.1.0a-f (branch abandoned)\n *    1.2.0beta1-2             2    10200  2.1.2.0beta1-2\n *    1.2.0beta3-5             3    10200  3.1.2.0beta3-5\n *    1.2.0rc1                 3    10200  3.1.2.0rc1\n *    1.2.0                    3    10200  3.1.2.0\n *    1.2.1beta1-4             3    10201  3.1.2.1beta1-4\n *    1.2.1rc1-2               3    10201  3.1.2.1rc1-2\n *    1.2.1                    3    10201  3.1.2.1\n *    1.2.2beta1-6            12    10202  12.so.0.1.2.2beta1-6\n *    1.0.13beta1             10    10013  10.so.0.1.0.13beta1\n *    1.0.13rc1               10    10013  10.so.0.1.0.13rc1\n *    1.2.2rc1                12    10202  12.so.0.1.2.2rc1\n *    1.0.13                  10    10013  10.so.0.1.0.13\n *    1.2.2                   12    10202  12.so.0.1.2.2\n *    1.2.3rc1-6              12    10203  12.so.0.1.2.3rc1-6\n *    1.2.3                   12    10203  12.so.0.1.2.3\n *    1.2.4beta1-3            13    10204  12.so.0.1.2.4beta1-3\n *    1.0.14rc1               13    10014  10.so.0.1.0.14rc1\n *    1.2.4rc1                13    10204  12.so.0.1.2.4rc1\n *    1.0.14                  10    10014  10.so.0.1.0.14\n *    1.2.4                   13    10204  12.so.0.1.2.4\n *    1.2.5beta1-2            13    10205  12.so.0.1.2.5beta1-2\n *    1.0.15rc1-3             10    10015  10.so.0.1.0.15rc1-3\n *    1.2.5rc1-3              13    10205  12.so.0.1.2.5rc1-3\n *    1.0.15                  10    10015  10.so.0.1.0.15\n *    1.2.5                   13    10205  12.so.0.1.2.5\n *    1.2.6beta1-4            13    10206  12.so.0.1.2.6beta1-4\n *    1.0.16                  10    10016  10.so.0.1.0.16\n *    1.2.6                   13    10206  12.so.0.1.2.6\n *    1.2.7beta1-2            13    10207  12.so.0.1.2.7beta1-2\n *    1.0.17rc1               10    10017  12.so.0.1.0.17rc1\n *    1.2.7rc1                13    10207  12.so.0.1.2.7rc1\n *    1.0.17                  10    10017  12.so.0.1.0.17\n *    1.2.7                   13    10207  12.so.0.1.2.7\n *    1.2.8beta1-5            13    10208  12.so.0.1.2.8beta1-5\n *    1.0.18rc1-5             10    10018  12.so.0.1.0.18rc1-5\n *    1.2.8rc1-5              13    10208  12.so.0.1.2.8rc1-5\n *    1.0.18                  10    10018  12.so.0.1.0.18\n *    1.2.8                   13    10208  12.so.0.1.2.8\n *    1.2.9beta1-3            13    10209  12.so.0.1.2.9beta1-3\n *    1.2.9beta4-11           13    10209  12.so.0.9[.0]\n *    1.2.9rc1                13    10209  12.so.0.9[.0]\n *    1.2.9                   13    10209  12.so.0.9[.0]\n *    1.2.10beta1-7           13    10210  12.so.0.10[.0]\n *    1.2.10rc1-2             13    10210  12.so.0.10[.0]\n *    1.2.10                  13    10210  12.so.0.10[.0]\n *    1.4.0beta1-5            14    10400  14.so.0.0[.0]\n *    1.2.11beta1-4           13    10211  12.so.0.11[.0]\n *    1.4.0beta7-8            14    10400  14.so.0.0[.0]\n *    1.2.11                  13    10211  12.so.0.11[.0]\n *    1.2.12                  13    10212  12.so.0.12[.0]\n *    1.4.0beta9-14           14    10400  14.so.0.0[.0]\n *    1.2.13                  13    10213  12.so.0.13[.0]\n *    1.4.0beta15-36          14    10400  14.so.0.0[.0]\n *    1.4.0beta37-87          14    10400  14.so.14.0[.0]\n *    1.4.0rc01               14    10400  14.so.14.0[.0]\n *    1.4.0beta88-109         14    10400  14.so.14.0[.0]\n *    1.4.0rc02-08            14    10400  14.so.14.0[.0]\n *    1.4.0                   14    10400  14.so.14.0[.0]\n *    1.4.1beta01-03          14    10401  14.so.14.1[.0]\n *    1.4.1rc01               14    10401  14.so.14.1[.0]\n *    1.4.1beta04-12          14    10401  14.so.14.1[.0]\n *    1.4.1                   14    10401  14.so.14.1[.0]\n *    1.4.2                   14    10402  14.so.14.2[.0]\n *    1.4.3                   14    10403  14.so.14.3[.0]\n *    1.4.4                   14    10404  14.so.14.4[.0]\n *    1.5.0beta01-58          15    10500  15.so.15.0[.0]\n *    1.5.0rc01-07            15    10500  15.so.15.0[.0]\n *    1.5.0                   15    10500  15.so.15.0[.0]\n *    1.5.1beta01-11          15    10501  15.so.15.1[.0]\n *    1.5.1rc01-02            15    10501  15.so.15.1[.0]\n *    1.5.1                   15    10501  15.so.15.1[.0]\n *    1.5.2beta01-03          15    10502  15.so.15.2[.0]\n *    1.5.2rc01-03            15    10502  15.so.15.2[.0]\n *    1.5.2                   15    10502  15.so.15.2[.0]\n *    1.5.3beta01-10          15    10503  15.so.15.3[.0]\n *    1.5.3rc01-02            15    10503  15.so.15.3[.0]\n *    1.5.3beta11             15    10503  15.so.15.3[.0]\n *    1.5.3 [omitted]\n *    1.5.4beta01-08          15    10504  15.so.15.4[.0]\n *    1.5.4rc01               15    10504  15.so.15.4[.0]\n *    1.5.4                   15    10504  15.so.15.4[.0]\n *    1.5.5beta01-08          15    10505  15.so.15.5[.0]\n *    1.5.5rc01               15    10505  15.so.15.5[.0]\n *    1.5.5                   15    10505  15.so.15.5[.0]\n *    1.5.6beta01-07          15    10506  15.so.15.6[.0]\n *    1.5.6rc01-03            15    10506  15.so.15.6[.0]\n *    1.5.6                   15    10506  15.so.15.6[.0]\n *    1.5.7beta01-05          15    10507  15.so.15.7[.0]\n *    1.5.7rc01-03            15    10507  15.so.15.7[.0]\n *    1.5.7                   15    10507  15.so.15.7[.0]\n *    1.6.0beta01-40          16    10600  16.so.16.0[.0]\n *    1.6.0rc01-08            16    10600  16.so.16.0[.0]\n *    1.6.0                   16    10600  16.so.16.0[.0]\n *    1.6.1beta01-09          16    10601  16.so.16.1[.0]\n *    1.6.1rc01               16    10601  16.so.16.1[.0]\n *    1.6.1                   16    10601  16.so.16.1[.0]\n *    1.6.2beta01             16    10602  16.so.16.2[.0]\n *    1.6.2rc01-06            16    10602  16.so.16.2[.0]\n *    1.6.2                   16    10602  16.so.16.2[.0]\n *    1.6.3beta01-11          16    10603  16.so.16.3[.0]\n *    1.6.3rc01               16    10603  16.so.16.3[.0]\n *    1.6.3                   16    10603  16.so.16.3[.0]\n *    1.6.4beta01-02          16    10604  16.so.16.4[.0]\n *    1.6.4rc01               16    10604  16.so.16.4[.0]\n *    1.6.4                   16    10604  16.so.16.4[.0]\n *    1.6.5                   16    10605  16.so.16.5[.0]\n *    1.6.6                   16    10606  16.so.16.6[.0]\n *    1.6.7beta01-04          16    10607  16.so.16.7[.0]\n *    1.6.7rc01-03            16    10607  16.so.16.7[.0]\n *    1.6.7                   16    10607  16.so.16.7[.0]\n *    1.6.8beta01-02          16    10608  16.so.16.8[.0]\n *    1.6.8rc01-02            16    10608  16.so.16.8[.0]\n *    1.6.8                   16    10608  16.so.16.8[.0]\n *    1.6.9beta01-04          16    10609  16.so.16.9[.0]\n *    1.6.9rc01-02            16    10609  16.so.16.9[.0]\n *    1.6.9                   16    10609  16.so.16.9[.0]\n *    1.6.10beta01-03         16    10610  16.so.16.10[.0]\n *    1.6.10betarc01-04       16    10610  16.so.16.10[.0]\n *    1.6.10beta              16    10610  16.so.16.10[.0]\n *\n *   Henceforth the source version will match the shared-library major\n *   and minor numbers; the shared-library major version number will be\n *   used for changes in backward compatibility, as it is intended.  The\n *   PNG_LIBPNG_VER macro, which is not used within libpng but is available\n *   for applications, is an unsigned integer of the form xyyzz corresponding\n *   to the source version x.y.z (leading zeros in y and z).  Beta versions\n *   were given the previous public release number plus a letter, until\n *   version 1.0.6j; from then on they were given the upcoming public\n *   release number plus \"betaNN\" or \"rcNN\".\n *\n *   Binary incompatibility exists only when applications make direct access\n *   to the info_ptr or png_ptr members through png.h, and the compiled\n *   application is loaded with a different version of the library.\n *\n *   DLLNUM will change each time there are forward or backward changes\n *   in binary compatibility (e.g., when a new feature is added).\n *\n * See libpng-manual.txt or libpng.3 for more information.  The PNG\n * specification is available as a W3C Recommendation and as an ISO\n * Specification, <http://www.w3.org/TR/2003/REC-PNG-20031110/\n */\n\n/*\n * COPYRIGHT NOTICE, DISCLAIMER, and LICENSE:\n *\n * If you modify libpng you may insert additional notices immediately following\n * this sentence.\n *\n * This code is released under the libpng license.\n *\n * libpng versions 1.2.6, August 15, 2004, through 1.6.10, March 6, 2014, are\n * Copyright (c) 2004, 2006-2013 Glenn Randers-Pehrson, and are\n * distributed according to the same disclaimer and license as libpng-1.2.5\n * with the following individual added to the list of Contributing Authors:\n *\n *    Cosmin Truta\n *\n * libpng versions 1.0.7, July 1, 2000, through 1.2.5, October 3, 2002, are\n * Copyright (c) 2000-2002 Glenn Randers-Pehrson, and are\n * distributed according to the same disclaimer and license as libpng-1.0.6\n * with the following individuals added to the list of Contributing Authors:\n *\n *    Simon-Pierre Cadieux\n *    Eric S. Raymond\n *    Gilles Vollant\n *\n * and with the following additions to the disclaimer:\n *\n *    There is no warranty against interference with your enjoyment of the\n *    library or against infringement.  There is no warranty that our\n *    efforts or the library will fulfill any of your particular purposes\n *    or needs.  This library is provided with all faults, and the entire\n *    risk of satisfactory quality, performance, accuracy, and effort is with\n *    the user.\n *\n * libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are\n * Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson, and are\n * distributed according to the same disclaimer and license as libpng-0.96,\n * with the following individuals added to the list of Contributing Authors:\n *\n *    Tom Lane\n *    Glenn Randers-Pehrson\n *    Willem van Schaik\n *\n * libpng versions 0.89, June 1996, through 0.96, May 1997, are\n * Copyright (c) 1996, 1997 Andreas Dilger\n * Distributed according to the same disclaimer and license as libpng-0.88,\n * with the following individuals added to the list of Contributing Authors:\n *\n *    John Bowler\n *    Kevin Bracey\n *    Sam Bushell\n *    Magnus Holmgren\n *    Greg Roelofs\n *    Tom Tanner\n *\n * libpng versions 0.5, May 1995, through 0.88, January 1996, are\n * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.\n *\n * For the purposes of this copyright and license, \"Contributing Authors\"\n * is defined as the following set of individuals:\n *\n *    Andreas Dilger\n *    Dave Martindale\n *    Guy Eric Schalnat\n *    Paul Schmidt\n *    Tim Wegner\n *\n * The PNG Reference Library is supplied \"AS IS\".  The Contributing Authors\n * and Group 42, Inc. disclaim all warranties, expressed or implied,\n * including, without limitation, the warranties of merchantability and of\n * fitness for any purpose.  The Contributing Authors and Group 42, Inc.\n * assume no liability for direct, indirect, incidental, special, exemplary,\n * or consequential damages, which may result from the use of the PNG\n * Reference Library, even if advised of the possibility of such damage.\n *\n * Permission is hereby granted to use, copy, modify, and distribute this\n * source code, or portions hereof, for any purpose, without fee, subject\n * to the following restrictions:\n *\n *   1. The origin of this source code must not be misrepresented.\n *\n *   2. Altered versions must be plainly marked as such and must not\n *      be misrepresented as being the original source.\n *\n *   3. This Copyright notice may not be removed or altered from\n *      any source or altered source distribution.\n *\n * The Contributing Authors and Group 42, Inc. specifically permit, without\n * fee, and encourage the use of this source code as a component to\n * supporting the PNG file format in commercial products.  If you use this\n * source code in a product, acknowledgment is not required but would be\n * appreciated.\n */\n\n/*\n * A \"png_get_copyright\" function is available, for convenient use in \"about\"\n * boxes and the like:\n *\n *     printf(\"%s\", png_get_copyright(NULL));\n *\n * Also, the PNG logo (in PNG format, of course) is supplied in the\n * files \"pngbar.png\" and \"pngbar.jpg (88x31) and \"pngnow.png\" (98x31).\n */\n\n/*\n * Libpng is OSI Certified Open Source Software.  OSI Certified is a\n * certification mark of the Open Source Initiative.\n */\n\n/*\n * The contributing authors would like to thank all those who helped\n * with testing, bug fixes, and patience.  This wouldn't have been\n * possible without all of you.\n *\n * Thanks to Frank J. T. Wojcik for helping with the documentation.\n */\n\n/*\n * Y2K compliance in libpng:\n * =========================\n *\n *    March 6, 2014\n *\n *    Since the PNG Development group is an ad-hoc body, we can't make\n *    an official declaration.\n *\n *    This is your unofficial assurance that libpng from version 0.71 and\n *    upward through 1.6.10 are Y2K compliant.  It is my belief that\n *    earlier versions were also Y2K compliant.\n *\n *    Libpng only has two year fields.  One is a 2-byte unsigned integer\n *    that will hold years up to 65535.  The other, which is deprecated,\n *    holds the date in text format, and will hold years up to 9999.\n *\n *    The integer is\n *        \"png_uint_16 year\" in png_time_struct.\n *\n *    The string is\n *        \"char time_buffer[29]\" in png_struct.  This is no longer used\n *    in libpng-1.6.x and will be removed from libpng-1.7.0.\n *\n *    There are seven time-related functions:\n *        png.c: png_convert_to_rfc_1123_buffer() in png.c\n *          (formerly png_convert_to_rfc_1123() prior to libpng-1.5.x and\n *          png_convert_to_rfc_1152() in error prior to libpng-0.98)\n *        png_convert_from_struct_tm() in pngwrite.c, called in pngwrite.c\n *        png_convert_from_time_t() in pngwrite.c\n *        png_get_tIME() in pngget.c\n *        png_handle_tIME() in pngrutil.c, called in pngread.c\n *        png_set_tIME() in pngset.c\n *        png_write_tIME() in pngwutil.c, called in pngwrite.c\n *\n *    All handle dates properly in a Y2K environment.  The\n *    png_convert_from_time_t() function calls gmtime() to convert from system\n *    clock time, which returns (year - 1900), which we properly convert to\n *    the full 4-digit year.  There is a possibility that libpng applications\n *    are not passing 4-digit years into the png_convert_to_rfc_1123_buffer()\n *    function, or that they are incorrectly passing only a 2-digit year\n *    instead of \"year - 1900\" into the png_convert_from_struct_tm() function,\n *    but this is not under our control.  The libpng documentation has always\n *    stated that it works with 4-digit years, and the APIs have been\n *    documented as such.\n *\n *    The tIME chunk itself is also Y2K compliant.  It uses a 2-byte unsigned\n *    integer to hold the year, and can hold years as large as 65535.\n *\n *    zlib, upon which libpng depends, is also Y2K compliant.  It contains\n *    no date-related code.\n *\n *       Glenn Randers-Pehrson\n *       libpng maintainer\n *       PNG Development Group\n */\n\n#ifndef PNG_H\n#define PNG_H\n\n/* This is not the place to learn how to use libpng. The file libpng-manual.txt\n * describes how to use libpng, and the file example.c summarizes it\n * with some code on which to build.  This file is useful for looking\n * at the actual function definitions and structure components.\n *\n * If you just need to read a PNG file and don't want to read the documentation\n * skip to the end of this file and read the section entitled 'simplified API'.\n */\n\n/* Version information for png.h - this should match the version in png.c */\n#define PNG_LIBPNG_VER_STRING \"1.6.10\"\n#define PNG_HEADER_VERSION_STRING \\\n     \" libpng version 1.6.10 - March 6, 2014\\n\"\n\n#define PNG_LIBPNG_VER_SONUM   16\n#define PNG_LIBPNG_VER_DLLNUM  16\n\n/* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */\n#define PNG_LIBPNG_VER_MAJOR   1\n#define PNG_LIBPNG_VER_MINOR   6\n#define PNG_LIBPNG_VER_RELEASE 10\n\n/* This should match the numeric part of the final component of\n * PNG_LIBPNG_VER_STRING, omitting any leading zero:\n */\n\n#define PNG_LIBPNG_VER_BUILD  0\n\n/* Release Status */\n#define PNG_LIBPNG_BUILD_ALPHA    1\n#define PNG_LIBPNG_BUILD_BETA     2\n#define PNG_LIBPNG_BUILD_RC       3\n#define PNG_LIBPNG_BUILD_STABLE   4\n#define PNG_LIBPNG_BUILD_RELEASE_STATUS_MASK 7\n\n/* Release-Specific Flags */\n#define PNG_LIBPNG_BUILD_PATCH    8 /* Can be OR'ed with\n                                       PNG_LIBPNG_BUILD_STABLE only */\n#define PNG_LIBPNG_BUILD_PRIVATE 16 /* Cannot be OR'ed with\n                                       PNG_LIBPNG_BUILD_SPECIAL */\n#define PNG_LIBPNG_BUILD_SPECIAL 32 /* Cannot be OR'ed with\n                                       PNG_LIBPNG_BUILD_PRIVATE */\n\n#define PNG_LIBPNG_BUILD_BASE_TYPE PNG_LIBPNG_BUILD_STABLE\n\n/* Careful here.  At one time, Guy wanted to use 082, but that would be octal.\n * We must not include leading zeros.\n * Versions 0.7 through 1.0.0 were in the range 0 to 100 here (only\n * version 1.0.0 was mis-numbered 100 instead of 10000).  From\n * version 1.0.1 it's    xxyyzz, where x=major, y=minor, z=release\n */\n#define PNG_LIBPNG_VER 10610 /* 1.6.10 */\n\n/* Library configuration: these options cannot be changed after\n * the library has been built.\n */\n#ifndef PNGLCONF_H\n    /* If pnglibconf.h is missing, you can\n     * copy scripts/pnglibconf.h.prebuilt to pnglibconf.h\n     */\n#   include \"pnglibconf.h\"\n#endif\n\n#ifndef PNG_VERSION_INFO_ONLY\n   /* Machine specific configuration. */\n#  include \"pngconf.h\"\n#endif\n\n/*\n * Added at libpng-1.2.8\n *\n * Ref MSDN: Private as priority over Special\n * VS_FF_PRIVATEBUILD File *was not* built using standard release\n * procedures. If this value is given, the StringFileInfo block must\n * contain a PrivateBuild string.\n *\n * VS_FF_SPECIALBUILD File *was* built by the original company using\n * standard release procedures but is a variation of the standard\n * file of the same version number. If this value is given, the\n * StringFileInfo block must contain a SpecialBuild string.\n */\n\n#ifdef PNG_USER_PRIVATEBUILD /* From pnglibconf.h */\n#  define PNG_LIBPNG_BUILD_TYPE \\\n       (PNG_LIBPNG_BUILD_BASE_TYPE | PNG_LIBPNG_BUILD_PRIVATE)\n#else\n#  ifdef PNG_LIBPNG_SPECIALBUILD\n#    define PNG_LIBPNG_BUILD_TYPE \\\n         (PNG_LIBPNG_BUILD_BASE_TYPE | PNG_LIBPNG_BUILD_SPECIAL)\n#  else\n#    define PNG_LIBPNG_BUILD_TYPE (PNG_LIBPNG_BUILD_BASE_TYPE)\n#  endif\n#endif\n\n#ifndef PNG_VERSION_INFO_ONLY\n\n/* Inhibit C++ name-mangling for libpng functions but not for system calls. */\n#ifdef __cplusplus\nextern \"C\" {\n#endif /* __cplusplus */\n\n/* Version information for C files, stored in png.c.  This had better match\n * the version above.\n */\n#define png_libpng_ver png_get_header_ver(NULL)\n\n/* This file is arranged in several sections:\n *\n * 1. Any configuration options that can be specified by for the application\n *    code when it is built.  (Build time configuration is in pnglibconf.h)\n * 2. Type definitions (base types are defined in pngconf.h), structure\n *    definitions.\n * 3. Exported library functions.\n * 4. Simplified API.\n *\n * The library source code has additional files (principally pngpriv.h) that\n * allow configuration of the library.\n */\n/* Section 1: run time configuration\n * See pnglibconf.h for build time configuration\n *\n * Run time configuration allows the application to choose between\n * implementations of certain arithmetic APIs.  The default is set\n * at build time and recorded in pnglibconf.h, but it is safe to\n * override these (and only these) settings.  Note that this won't\n * change what the library does, only application code, and the\n * settings can (and probably should) be made on a per-file basis\n * by setting the #defines before including png.h\n *\n * Use macros to read integers from PNG data or use the exported\n * functions?\n *   PNG_USE_READ_MACROS: use the macros (see below)  Note that\n *     the macros evaluate their argument multiple times.\n *   PNG_NO_USE_READ_MACROS: call the relevant library function.\n *\n * Use the alternative algorithm for compositing alpha samples that\n * does not use division?\n *   PNG_READ_COMPOSITE_NODIV_SUPPORTED: use the 'no division'\n *      algorithm.\n *   PNG_NO_READ_COMPOSITE_NODIV: use the 'division' algorithm.\n *\n * How to handle benign errors if PNG_ALLOW_BENIGN_ERRORS is\n * false?\n *   PNG_ALLOW_BENIGN_ERRORS: map calls to the benign error\n *      APIs to png_warning.\n * Otherwise the calls are mapped to png_error.\n */\n\n/* Section 2: type definitions, including structures and compile time\n * constants.\n * See pngconf.h for base types that vary by machine/system\n */\n\n/* This triggers a compiler error in png.c, if png.c and png.h\n * do not agree upon the version number.\n */\ntypedef char* png_libpng_version_1_6_10;\n\n/* Basic control structions.  Read libpng-manual.txt or libpng.3 for more info.\n *\n * png_struct is the cache of information used while reading or writing a single\n * PNG file.  One of these is always required, although the simplified API\n * (below) hides the creation and destruction of it.\n */\ntypedef struct png_struct_def png_struct;\ntypedef const png_struct * png_const_structp;\ntypedef png_struct * png_structp;\ntypedef png_struct * * png_structpp;\n\n/* png_info contains information read from or to be written to a PNG file.  One\n * or more of these must exist while reading or creating a PNG file.  The\n * information is not used by libpng during read but is used to control what\n * gets written when a PNG file is created.  \"png_get_\" function calls read\n * information during read and \"png_set_\" functions calls write information\n * when creating a PNG.\n * been moved into a separate header file that is not accessible to\n * applications.  Read libpng-manual.txt or libpng.3 for more info.\n */\ntypedef struct png_info_def png_info;\ntypedef png_info * png_infop;\ntypedef const png_info * png_const_infop;\ntypedef png_info * * png_infopp;\n\n/* Types with names ending 'p' are pointer types.  The corresponding types with\n * names ending 'rp' are identical pointer types except that the pointer is\n * marked 'restrict', which means that it is the only pointer to the object\n * passed to the function.  Applications should not use the 'restrict' types;\n * it is always valid to pass 'p' to a pointer with a function argument of the\n * corresponding 'rp' type.  Different compilers have different rules with\n * regard to type matching in the presence of 'restrict'.  For backward\n * compatibility libpng callbacks never have 'restrict' in their parameters and,\n * consequentially, writing portable application code is extremely difficult if\n * an attempt is made to use 'restrict'.\n */\ntypedef png_struct * PNG_RESTRICT png_structrp;\ntypedef const png_struct * PNG_RESTRICT png_const_structrp;\ntypedef png_info * PNG_RESTRICT png_inforp;\ntypedef const png_info * PNG_RESTRICT png_const_inforp;\n\n/* Three color definitions.  The order of the red, green, and blue, (and the\n * exact size) is not important, although the size of the fields need to\n * be png_byte or png_uint_16 (as defined below).\n */\ntypedef struct png_color_struct\n{\n   png_byte red;\n   png_byte green;\n   png_byte blue;\n} png_color;\ntypedef png_color * png_colorp;\ntypedef const png_color * png_const_colorp;\ntypedef png_color * * png_colorpp;\n\ntypedef struct png_color_16_struct\n{\n   png_byte index;    /* used for palette files */\n   png_uint_16 red;   /* for use in red green blue files */\n   png_uint_16 green;\n   png_uint_16 blue;\n   png_uint_16 gray;  /* for use in grayscale files */\n} png_color_16;\ntypedef png_color_16 * png_color_16p;\ntypedef const png_color_16 * png_const_color_16p;\ntypedef png_color_16 * * png_color_16pp;\n\ntypedef struct png_color_8_struct\n{\n   png_byte red;   /* for use in red green blue files */\n   png_byte green;\n   png_byte blue;\n   png_byte gray;  /* for use in grayscale files */\n   png_byte alpha; /* for alpha channel files */\n} png_color_8;\ntypedef png_color_8 * png_color_8p;\ntypedef const png_color_8 * png_const_color_8p;\ntypedef png_color_8 * * png_color_8pp;\n\n/*\n * The following two structures are used for the in-core representation\n * of sPLT chunks.\n */\ntypedef struct png_sPLT_entry_struct\n{\n   png_uint_16 red;\n   png_uint_16 green;\n   png_uint_16 blue;\n   png_uint_16 alpha;\n   png_uint_16 frequency;\n} png_sPLT_entry;\ntypedef png_sPLT_entry * png_sPLT_entryp;\ntypedef const png_sPLT_entry * png_const_sPLT_entryp;\ntypedef png_sPLT_entry * * png_sPLT_entrypp;\n\n/*  When the depth of the sPLT palette is 8 bits, the color and alpha samples\n *  occupy the LSB of their respective members, and the MSB of each member\n *  is zero-filled.  The frequency member always occupies the full 16 bits.\n */\n\ntypedef struct png_sPLT_struct\n{\n   png_charp name;           /* palette name */\n   png_byte depth;           /* depth of palette samples */\n   png_sPLT_entryp entries;  /* palette entries */\n   png_int_32 nentries;      /* number of palette entries */\n} png_sPLT_t;\ntypedef png_sPLT_t * png_sPLT_tp;\ntypedef const png_sPLT_t * png_const_sPLT_tp;\ntypedef png_sPLT_t * * png_sPLT_tpp;\n\n#ifdef PNG_TEXT_SUPPORTED\n/* png_text holds the contents of a text/ztxt/itxt chunk in a PNG file,\n * and whether that contents is compressed or not.  The \"key\" field\n * points to a regular zero-terminated C string.  The \"text\" fields can be a\n * regular C string, an empty string, or a NULL pointer.\n * However, the structure returned by png_get_text() will always contain\n * the \"text\" field as a regular zero-terminated C string (possibly\n * empty), never a NULL pointer, so it can be safely used in printf() and\n * other string-handling functions.  Note that the \"itxt_length\", \"lang\", and\n * \"lang_key\" members of the structure only exist when the library is built\n * with iTXt chunk support.  Prior to libpng-1.4.0 the library was built by\n * default without iTXt support. Also note that when iTXt *is* supported,\n * the \"lang\" and \"lang_key\" fields contain NULL pointers when the\n * \"compression\" field contains * PNG_TEXT_COMPRESSION_NONE or\n * PNG_TEXT_COMPRESSION_zTXt. Note that the \"compression value\" is not the\n * same as what appears in the PNG tEXt/zTXt/iTXt chunk's \"compression flag\"\n * which is always 0 or 1, or its \"compression method\" which is always 0.\n */\ntypedef struct png_text_struct\n{\n   int  compression;       /* compression value:\n                             -1: tEXt, none\n                              0: zTXt, deflate\n                              1: iTXt, none\n                              2: iTXt, deflate  */\n   png_charp key;          /* keyword, 1-79 character description of \"text\" */\n   png_charp text;         /* comment, may be an empty string (ie \"\")\n                              or a NULL pointer */\n   png_size_t text_length; /* length of the text string */\n   png_size_t itxt_length; /* length of the itxt string */\n   png_charp lang;         /* language code, 0-79 characters\n                              or a NULL pointer */\n   png_charp lang_key;     /* keyword translated UTF-8 string, 0 or more\n                              chars or a NULL pointer */\n} png_text;\ntypedef png_text * png_textp;\ntypedef const png_text * png_const_textp;\ntypedef png_text * * png_textpp;\n#endif\n\n/* Supported compression types for text in PNG files (tEXt, and zTXt).\n * The values of the PNG_TEXT_COMPRESSION_ defines should NOT be changed. */\n#define PNG_TEXT_COMPRESSION_NONE_WR -3\n#define PNG_TEXT_COMPRESSION_zTXt_WR -2\n#define PNG_TEXT_COMPRESSION_NONE    -1\n#define PNG_TEXT_COMPRESSION_zTXt     0\n#define PNG_ITXT_COMPRESSION_NONE     1\n#define PNG_ITXT_COMPRESSION_zTXt     2\n#define PNG_TEXT_COMPRESSION_LAST     3  /* Not a valid value */\n\n/* png_time is a way to hold the time in an machine independent way.\n * Two conversions are provided, both from time_t and struct tm.  There\n * is no portable way to convert to either of these structures, as far\n * as I know.  If you know of a portable way, send it to me.  As a side\n * note - PNG has always been Year 2000 compliant!\n */\ntypedef struct png_time_struct\n{\n   png_uint_16 year; /* full year, as in, 1995 */\n   png_byte month;   /* month of year, 1 - 12 */\n   png_byte day;     /* day of month, 1 - 31 */\n   png_byte hour;    /* hour of day, 0 - 23 */\n   png_byte minute;  /* minute of hour, 0 - 59 */\n   png_byte second;  /* second of minute, 0 - 60 (for leap seconds) */\n} png_time;\ntypedef png_time * png_timep;\ntypedef const png_time * png_const_timep;\ntypedef png_time * * png_timepp;\n\n#if defined(PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED) ||\\\n   defined(PNG_USER_CHUNKS_SUPPORTED)\n/* png_unknown_chunk is a structure to hold queued chunks for which there is\n * no specific support.  The idea is that we can use this to queue\n * up private chunks for output even though the library doesn't actually\n * know about their semantics.\n *\n * The data in the structure is set by libpng on read and used on write.\n */\ntypedef struct png_unknown_chunk_t\n{\n    png_byte name[5]; /* Textual chunk name with '\\0' terminator */\n    png_byte *data;   /* Data, should not be modified on read! */\n    png_size_t size;\n\n    /* On write 'location' must be set using the flag values listed below.\n     * Notice that on read it is set by libpng however the values stored have\n     * more bits set than are listed below.  Always treat the value as a\n     * bitmask.  On write set only one bit - setting multiple bits may cause the\n     * chunk to be written in multiple places.\n     */\n    png_byte location; /* mode of operation at read time */\n}\npng_unknown_chunk;\n\ntypedef png_unknown_chunk * png_unknown_chunkp;\ntypedef const png_unknown_chunk * png_const_unknown_chunkp;\ntypedef png_unknown_chunk * * png_unknown_chunkpp;\n#endif\n\n/* Flag values for the unknown chunk location byte. */\n#define PNG_HAVE_IHDR  0x01\n#define PNG_HAVE_PLTE  0x02\n#define PNG_AFTER_IDAT 0x08\n\n/* Maximum positive integer used in PNG is (2^31)-1 */\n#define PNG_UINT_31_MAX ((png_uint_32)0x7fffffffL)\n#define PNG_UINT_32_MAX ((png_uint_32)(-1))\n#define PNG_SIZE_MAX ((png_size_t)(-1))\n\n/* These are constants for fixed point values encoded in the\n * PNG specification manner (x100000)\n */\n#define PNG_FP_1    100000\n#define PNG_FP_HALF  50000\n#define PNG_FP_MAX  ((png_fixed_point)0x7fffffffL)\n#define PNG_FP_MIN  (-PNG_FP_MAX)\n\n/* These describe the color_type field in png_info. */\n/* color type masks */\n#define PNG_COLOR_MASK_PALETTE    1\n#define PNG_COLOR_MASK_COLOR      2\n#define PNG_COLOR_MASK_ALPHA      4\n\n/* color types.  Note that not all combinations are legal */\n#define PNG_COLOR_TYPE_GRAY 0\n#define PNG_COLOR_TYPE_PALETTE  (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_PALETTE)\n#define PNG_COLOR_TYPE_RGB        (PNG_COLOR_MASK_COLOR)\n#define PNG_COLOR_TYPE_RGB_ALPHA  (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_ALPHA)\n#define PNG_COLOR_TYPE_GRAY_ALPHA (PNG_COLOR_MASK_ALPHA)\n/* aliases */\n#define PNG_COLOR_TYPE_RGBA  PNG_COLOR_TYPE_RGB_ALPHA\n#define PNG_COLOR_TYPE_GA  PNG_COLOR_TYPE_GRAY_ALPHA\n\n/* This is for compression type. PNG 1.0-1.2 only define the single type. */\n#define PNG_COMPRESSION_TYPE_BASE 0 /* Deflate method 8, 32K window */\n#define PNG_COMPRESSION_TYPE_DEFAULT PNG_COMPRESSION_TYPE_BASE\n\n/* This is for filter type. PNG 1.0-1.2 only define the single type. */\n#define PNG_FILTER_TYPE_BASE      0 /* Single row per-byte filtering */\n#define PNG_INTRAPIXEL_DIFFERENCING 64 /* Used only in MNG datastreams */\n#define PNG_FILTER_TYPE_DEFAULT   PNG_FILTER_TYPE_BASE\n\n/* These are for the interlacing type.  These values should NOT be changed. */\n#define PNG_INTERLACE_NONE        0 /* Non-interlaced image */\n#define PNG_INTERLACE_ADAM7       1 /* Adam7 interlacing */\n#define PNG_INTERLACE_LAST        2 /* Not a valid value */\n\n/* These are for the oFFs chunk.  These values should NOT be changed. */\n#define PNG_OFFSET_PIXEL          0 /* Offset in pixels */\n#define PNG_OFFSET_MICROMETER     1 /* Offset in micrometers (1/10^6 meter) */\n#define PNG_OFFSET_LAST           2 /* Not a valid value */\n\n/* These are for the pCAL chunk.  These values should NOT be changed. */\n#define PNG_EQUATION_LINEAR       0 /* Linear transformation */\n#define PNG_EQUATION_BASE_E       1 /* Exponential base e transform */\n#define PNG_EQUATION_ARBITRARY    2 /* Arbitrary base exponential transform */\n#define PNG_EQUATION_HYPERBOLIC   3 /* Hyperbolic sine transformation */\n#define PNG_EQUATION_LAST         4 /* Not a valid value */\n\n/* These are for the sCAL chunk.  These values should NOT be changed. */\n#define PNG_SCALE_UNKNOWN         0 /* unknown unit (image scale) */\n#define PNG_SCALE_METER           1 /* meters per pixel */\n#define PNG_SCALE_RADIAN          2 /* radians per pixel */\n#define PNG_SCALE_LAST            3 /* Not a valid value */\n\n/* These are for the pHYs chunk.  These values should NOT be changed. */\n#define PNG_RESOLUTION_UNKNOWN    0 /* pixels/unknown unit (aspect ratio) */\n#define PNG_RESOLUTION_METER      1 /* pixels/meter */\n#define PNG_RESOLUTION_LAST       2 /* Not a valid value */\n\n/* These are for the sRGB chunk.  These values should NOT be changed. */\n#define PNG_sRGB_INTENT_PERCEPTUAL 0\n#define PNG_sRGB_INTENT_RELATIVE   1\n#define PNG_sRGB_INTENT_SATURATION 2\n#define PNG_sRGB_INTENT_ABSOLUTE   3\n#define PNG_sRGB_INTENT_LAST       4 /* Not a valid value */\n\n/* This is for text chunks */\n#define PNG_KEYWORD_MAX_LENGTH     79\n\n/* Maximum number of entries in PLTE/sPLT/tRNS arrays */\n#define PNG_MAX_PALETTE_LENGTH    256\n\n/* These determine if an ancillary chunk's data has been successfully read\n * from the PNG header, or if the application has filled in the corresponding\n * data in the info_struct to be written into the output file.  The values\n * of the PNG_INFO_<chunk> defines should NOT be changed.\n */\n#define PNG_INFO_gAMA 0x0001\n#define PNG_INFO_sBIT 0x0002\n#define PNG_INFO_cHRM 0x0004\n#define PNG_INFO_PLTE 0x0008\n#define PNG_INFO_tRNS 0x0010\n#define PNG_INFO_bKGD 0x0020\n#define PNG_INFO_hIST 0x0040\n#define PNG_INFO_pHYs 0x0080\n#define PNG_INFO_oFFs 0x0100\n#define PNG_INFO_tIME 0x0200\n#define PNG_INFO_pCAL 0x0400\n#define PNG_INFO_sRGB 0x0800   /* GR-P, 0.96a */\n#define PNG_INFO_iCCP 0x1000   /* ESR, 1.0.6 */\n#define PNG_INFO_sPLT 0x2000   /* ESR, 1.0.6 */\n#define PNG_INFO_sCAL 0x4000   /* ESR, 1.0.6 */\n#define PNG_INFO_IDAT 0x8000   /* ESR, 1.0.6 */\n\n/* This is used for the transformation routines, as some of them\n * change these values for the row.  It also should enable using\n * the routines for other purposes.\n */\ntypedef struct png_row_info_struct\n{\n   png_uint_32 width;    /* width of row */\n   png_size_t rowbytes;  /* number of bytes in row */\n   png_byte color_type;  /* color type of row */\n   png_byte bit_depth;   /* bit depth of row */\n   png_byte channels;    /* number of channels (1, 2, 3, or 4) */\n   png_byte pixel_depth; /* bits per pixel (depth * channels) */\n} png_row_info;\n\ntypedef png_row_info * png_row_infop;\ntypedef png_row_info * * png_row_infopp;\n\n/* These are the function types for the I/O functions and for the functions\n * that allow the user to override the default I/O functions with his or her\n * own.  The png_error_ptr type should match that of user-supplied warning\n * and error functions, while the png_rw_ptr type should match that of the\n * user read/write data functions.  Note that the 'write' function must not\n * modify the buffer it is passed. The 'read' function, on the other hand, is\n * expected to return the read data in the buffer.\n */\ntypedef PNG_CALLBACK(void, *png_error_ptr, (png_structp, png_const_charp));\ntypedef PNG_CALLBACK(void, *png_rw_ptr, (png_structp, png_bytep, png_size_t));\ntypedef PNG_CALLBACK(void, *png_flush_ptr, (png_structp));\ntypedef PNG_CALLBACK(void, *png_read_status_ptr, (png_structp, png_uint_32,\n    int));\ntypedef PNG_CALLBACK(void, *png_write_status_ptr, (png_structp, png_uint_32,\n    int));\n\n#ifdef PNG_PROGRESSIVE_READ_SUPPORTED\ntypedef PNG_CALLBACK(void, *png_progressive_info_ptr, (png_structp, png_infop));\ntypedef PNG_CALLBACK(void, *png_progressive_end_ptr, (png_structp, png_infop));\n\n/* The following callback receives png_uint_32 row_number, int pass for the\n * png_bytep data of the row.  When transforming an interlaced image the\n * row number is the row number within the sub-image of the interlace pass, so\n * the value will increase to the height of the sub-image (not the full image)\n * then reset to 0 for the next pass.\n *\n * Use PNG_ROW_FROM_PASS_ROW(row, pass) and PNG_COL_FROM_PASS_COL(col, pass) to\n * find the output pixel (x,y) given an interlaced sub-image pixel\n * (row,col,pass).  (See below for these macros.)\n */\ntypedef PNG_CALLBACK(void, *png_progressive_row_ptr, (png_structp, png_bytep,\n    png_uint_32, int));\n#endif\n\n#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \\\n    defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)\ntypedef PNG_CALLBACK(void, *png_user_transform_ptr, (png_structp, png_row_infop,\n    png_bytep));\n#endif\n\n#ifdef PNG_USER_CHUNKS_SUPPORTED\ntypedef PNG_CALLBACK(int, *png_user_chunk_ptr, (png_structp,\n    png_unknown_chunkp));\n#endif\n#ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED\n/* not used anywhere */\n/* typedef PNG_CALLBACK(void, *png_unknown_chunk_ptr, (png_structp)); */\n#endif\n\n#ifdef PNG_SETJMP_SUPPORTED\n/* This must match the function definition in <setjmp.h>, and the application\n * must include this before png.h to obtain the definition of jmp_buf.  The\n * function is required to be PNG_NORETURN, but this is not checked.  If the\n * function does return the application will crash via an abort() or similar\n * system level call.\n *\n * If you get a warning here while building the library you may need to make\n * changes to ensure that pnglibconf.h records the calling convention used by\n * your compiler.  This may be very difficult - try using a different compiler\n * to build the library!\n */\nPNG_FUNCTION(void, (PNGCAPI *png_longjmp_ptr), PNGARG((jmp_buf, int)), typedef);\n#endif\n\n/* Transform masks for the high-level interface */\n#define PNG_TRANSFORM_IDENTITY       0x0000    /* read and write */\n#define PNG_TRANSFORM_STRIP_16       0x0001    /* read only */\n#define PNG_TRANSFORM_STRIP_ALPHA    0x0002    /* read only */\n#define PNG_TRANSFORM_PACKING        0x0004    /* read and write */\n#define PNG_TRANSFORM_PACKSWAP       0x0008    /* read and write */\n#define PNG_TRANSFORM_EXPAND         0x0010    /* read only */\n#define PNG_TRANSFORM_INVERT_MONO    0x0020    /* read and write */\n#define PNG_TRANSFORM_SHIFT          0x0040    /* read and write */\n#define PNG_TRANSFORM_BGR            0x0080    /* read and write */\n#define PNG_TRANSFORM_SWAP_ALPHA     0x0100    /* read and write */\n#define PNG_TRANSFORM_SWAP_ENDIAN    0x0200    /* read and write */\n#define PNG_TRANSFORM_INVERT_ALPHA   0x0400    /* read and write */\n#define PNG_TRANSFORM_STRIP_FILLER   0x0800    /* write only */\n/* Added to libpng-1.2.34 */\n#define PNG_TRANSFORM_STRIP_FILLER_BEFORE PNG_TRANSFORM_STRIP_FILLER\n#define PNG_TRANSFORM_STRIP_FILLER_AFTER 0x1000 /* write only */\n/* Added to libpng-1.4.0 */\n#define PNG_TRANSFORM_GRAY_TO_RGB   0x2000      /* read only */\n/* Added to libpng-1.5.4 */\n#define PNG_TRANSFORM_EXPAND_16     0x4000      /* read only */\n#define PNG_TRANSFORM_SCALE_16      0x8000      /* read only */\n\n/* Flags for MNG supported features */\n#define PNG_FLAG_MNG_EMPTY_PLTE     0x01\n#define PNG_FLAG_MNG_FILTER_64      0x04\n#define PNG_ALL_MNG_FEATURES        0x05\n\n/* NOTE: prior to 1.5 these functions had no 'API' style declaration,\n * this allowed the zlib default functions to be used on Windows\n * platforms.  In 1.5 the zlib default malloc (which just calls malloc and\n * ignores the first argument) should be completely compatible with the\n * following.\n */\ntypedef PNG_CALLBACK(png_voidp, *png_malloc_ptr, (png_structp,\n    png_alloc_size_t));\ntypedef PNG_CALLBACK(void, *png_free_ptr, (png_structp, png_voidp));\n\n/* Section 3: exported functions\n * Here are the function definitions most commonly used.  This is not\n * the place to find out how to use libpng.  See libpng-manual.txt for the\n * full explanation, see example.c for the summary.  This just provides\n * a simple one line description of the use of each function.\n *\n * The PNG_EXPORT() and PNG_EXPORTA() macros used below are defined in\n * pngconf.h and in the *.dfn files in the scripts directory.\n *\n *   PNG_EXPORT(ordinal, type, name, (args));\n *\n *       ordinal:    ordinal that is used while building\n *                   *.def files. The ordinal value is only\n *                   relevant when preprocessing png.h with\n *                   the *.dfn files for building symbol table\n *                   entries, and are removed by pngconf.h.\n *       type:       return type of the function\n *       name:       function name\n *       args:       function arguments, with types\n *\n * When we wish to append attributes to a function prototype we use\n * the PNG_EXPORTA() macro instead.\n *\n *   PNG_EXPORTA(ordinal, type, name, (args), attributes);\n *\n *       ordinal, type, name, and args: same as in PNG_EXPORT().\n *       attributes: function attributes\n */\n\n/* Returns the version number of the library */\nPNG_EXPORT(1, png_uint_32, png_access_version_number, (void));\n\n/* Tell lib we have already handled the first <num_bytes> magic bytes.\n * Handling more than 8 bytes from the beginning of the file is an error.\n */\nPNG_EXPORT(2, void, png_set_sig_bytes, (png_structrp png_ptr, int num_bytes));\n\n/* Check sig[start] through sig[start + num_to_check - 1] to see if it's a\n * PNG file.  Returns zero if the supplied bytes match the 8-byte PNG\n * signature, and non-zero otherwise.  Having num_to_check == 0 or\n * start > 7 will always fail (ie return non-zero).\n */\nPNG_EXPORT(3, int, png_sig_cmp, (png_const_bytep sig, png_size_t start,\n    png_size_t num_to_check));\n\n/* Simple signature checking function.  This is the same as calling\n * png_check_sig(sig, n) := !png_sig_cmp(sig, 0, n).\n */\n#define png_check_sig(sig, n) !png_sig_cmp((sig), 0, (n))\n\n/* Allocate and initialize png_ptr struct for reading, and any other memory. */\nPNG_EXPORTA(4, png_structp, png_create_read_struct,\n    (png_const_charp user_png_ver, png_voidp error_ptr,\n    png_error_ptr error_fn, png_error_ptr warn_fn),\n    PNG_ALLOCATED);\n\n/* Allocate and initialize png_ptr struct for writing, and any other memory */\nPNG_EXPORTA(5, png_structp, png_create_write_struct,\n    (png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn,\n    png_error_ptr warn_fn),\n    PNG_ALLOCATED);\n\nPNG_EXPORT(6, png_size_t, png_get_compression_buffer_size,\n    (png_const_structrp png_ptr));\n\nPNG_EXPORT(7, void, png_set_compression_buffer_size, (png_structrp png_ptr,\n    png_size_t size));\n\n/* Moved from pngconf.h in 1.4.0 and modified to ensure setjmp/longjmp\n * match up.\n */\n#ifdef PNG_SETJMP_SUPPORTED\n/* This function returns the jmp_buf built in to *png_ptr.  It must be\n * supplied with an appropriate 'longjmp' function to use on that jmp_buf\n * unless the default error function is overridden in which case NULL is\n * acceptable.  The size of the jmp_buf is checked against the actual size\n * allocated by the library - the call will return NULL on a mismatch\n * indicating an ABI mismatch.\n */\nPNG_EXPORT(8, jmp_buf*, png_set_longjmp_fn, (png_structrp png_ptr,\n    png_longjmp_ptr longjmp_fn, size_t jmp_buf_size));\n#  define png_jmpbuf(png_ptr) \\\n      (*png_set_longjmp_fn((png_ptr), longjmp, (sizeof (jmp_buf))))\n#else\n#  define png_jmpbuf(png_ptr) \\\n      (LIBPNG_WAS_COMPILED_WITH__PNG_NO_SETJMP)\n#endif\n/* This function should be used by libpng applications in place of\n * longjmp(png_ptr->jmpbuf, val).  If longjmp_fn() has been set, it\n * will use it; otherwise it will call PNG_ABORT().  This function was\n * added in libpng-1.5.0.\n */\nPNG_EXPORTA(9, void, png_longjmp, (png_const_structrp png_ptr, int val),\n    PNG_NORETURN);\n\n#ifdef PNG_READ_SUPPORTED\n/* Reset the compression stream */\nPNG_EXPORTA(10, int, png_reset_zstream, (png_structrp png_ptr), PNG_DEPRECATED);\n#endif\n\n/* New functions added in libpng-1.0.2 (not enabled by default until 1.2.0) */\n#ifdef PNG_USER_MEM_SUPPORTED\nPNG_EXPORTA(11, png_structp, png_create_read_struct_2,\n    (png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn,\n    png_error_ptr warn_fn,\n    png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn),\n    PNG_ALLOCATED);\nPNG_EXPORTA(12, png_structp, png_create_write_struct_2,\n    (png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn,\n    png_error_ptr warn_fn,\n    png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn),\n    PNG_ALLOCATED);\n#endif\n\n/* Write the PNG file signature. */\nPNG_EXPORT(13, void, png_write_sig, (png_structrp png_ptr));\n\n/* Write a PNG chunk - size, type, (optional) data, CRC. */\nPNG_EXPORT(14, void, png_write_chunk, (png_structrp png_ptr, png_const_bytep\n    chunk_name, png_const_bytep data, png_size_t length));\n\n/* Write the start of a PNG chunk - length and chunk name. */\nPNG_EXPORT(15, void, png_write_chunk_start, (png_structrp png_ptr,\n    png_const_bytep chunk_name, png_uint_32 length));\n\n/* Write the data of a PNG chunk started with png_write_chunk_start(). */\nPNG_EXPORT(16, void, png_write_chunk_data, (png_structrp png_ptr,\n    png_const_bytep data, png_size_t length));\n\n/* Finish a chunk started with png_write_chunk_start() (includes CRC). */\nPNG_EXPORT(17, void, png_write_chunk_end, (png_structrp png_ptr));\n\n/* Allocate and initialize the info structure */\nPNG_EXPORTA(18, png_infop, png_create_info_struct, (png_const_structrp png_ptr),\n    PNG_ALLOCATED);\n\n/* DEPRECATED: this function allowed init structures to be created using the\n * default allocation method (typically malloc).  Use is deprecated in 1.6.0 and\n * the API will be removed in the future.\n */\nPNG_EXPORTA(19, void, png_info_init_3, (png_infopp info_ptr,\n    png_size_t png_info_struct_size), PNG_DEPRECATED);\n\n/* Writes all the PNG information before the image. */\nPNG_EXPORT(20, void, png_write_info_before_PLTE,\n    (png_structrp png_ptr, png_const_inforp info_ptr));\nPNG_EXPORT(21, void, png_write_info,\n    (png_structrp png_ptr, png_const_inforp info_ptr));\n\n#ifdef PNG_SEQUENTIAL_READ_SUPPORTED\n/* Read the information before the actual image data. */\nPNG_EXPORT(22, void, png_read_info,\n    (png_structrp png_ptr, png_inforp info_ptr));\n#endif\n\n#ifdef PNG_TIME_RFC1123_SUPPORTED\n   /* Convert to a US string format: there is no localization support in this\n    * routine.  The original implementation used a 29 character buffer in\n    * png_struct, this will be removed in future versions.\n    */\n#if PNG_LIBPNG_VER < 10700\n/* To do: remove this from libpng17 (and from libpng17/png.c and pngstruct.h) */\nPNG_EXPORTA(23, png_const_charp, png_convert_to_rfc1123, (png_structrp png_ptr,\n    png_const_timep ptime),PNG_DEPRECATED);\n#endif\nPNG_EXPORT(241, int, png_convert_to_rfc1123_buffer, (char out[29],\n    png_const_timep ptime));\n#endif\n\n#ifdef PNG_CONVERT_tIME_SUPPORTED\n/* Convert from a struct tm to png_time */\nPNG_EXPORT(24, void, png_convert_from_struct_tm, (png_timep ptime,\n    const struct tm * ttime));\n\n/* Convert from time_t to png_time.  Uses gmtime() */\nPNG_EXPORT(25, void, png_convert_from_time_t, (png_timep ptime, time_t ttime));\n#endif /* PNG_CONVERT_tIME_SUPPORTED */\n\n#ifdef PNG_READ_EXPAND_SUPPORTED\n/* Expand data to 24-bit RGB, or 8-bit grayscale, with alpha if available. */\nPNG_EXPORT(26, void, png_set_expand, (png_structrp png_ptr));\nPNG_EXPORT(27, void, png_set_expand_gray_1_2_4_to_8, (png_structrp png_ptr));\nPNG_EXPORT(28, void, png_set_palette_to_rgb, (png_structrp png_ptr));\nPNG_EXPORT(29, void, png_set_tRNS_to_alpha, (png_structrp png_ptr));\n#endif\n\n#ifdef PNG_READ_EXPAND_16_SUPPORTED\n/* Expand to 16-bit channels, forces conversion of palette to RGB and expansion\n * of a tRNS chunk if present.\n */\nPNG_EXPORT(221, void, png_set_expand_16, (png_structrp png_ptr));\n#endif\n\n#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED)\n/* Use blue, green, red order for pixels. */\nPNG_EXPORT(30, void, png_set_bgr, (png_structrp png_ptr));\n#endif\n\n#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED\n/* Expand the grayscale to 24-bit RGB if necessary. */\nPNG_EXPORT(31, void, png_set_gray_to_rgb, (png_structrp png_ptr));\n#endif\n\n#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED\n/* Reduce RGB to grayscale. */\n#define PNG_ERROR_ACTION_NONE  1\n#define PNG_ERROR_ACTION_WARN  2\n#define PNG_ERROR_ACTION_ERROR 3\n#define PNG_RGB_TO_GRAY_DEFAULT (-1)/*for red/green coefficients*/\n\nPNG_FP_EXPORT(32, void, png_set_rgb_to_gray, (png_structrp png_ptr,\n    int error_action, double red, double green))\nPNG_FIXED_EXPORT(33, void, png_set_rgb_to_gray_fixed, (png_structrp png_ptr,\n    int error_action, png_fixed_point red, png_fixed_point green))\n\nPNG_EXPORT(34, png_byte, png_get_rgb_to_gray_status, (png_const_structrp\n    png_ptr));\n#endif\n\n#ifdef PNG_BUILD_GRAYSCALE_PALETTE_SUPPORTED\nPNG_EXPORT(35, void, png_build_grayscale_palette, (int bit_depth,\n    png_colorp palette));\n#endif\n\n#ifdef PNG_READ_ALPHA_MODE_SUPPORTED\n/* How the alpha channel is interpreted - this affects how the color channels\n * of a PNG file are returned to the calling application when an alpha channel,\n * or a tRNS chunk in a palette file, is present.\n *\n * This has no effect on the way pixels are written into a PNG output\n * datastream. The color samples in a PNG datastream are never premultiplied\n * with the alpha samples.\n *\n * The default is to return data according to the PNG specification: the alpha\n * channel is a linear measure of the contribution of the pixel to the\n * corresponding composited pixel, and the color channels are unassociated\n * (not premultiplied).  The gamma encoded color channels must be scaled\n * according to the contribution and to do this it is necessary to undo\n * the encoding, scale the color values, perform the composition and reencode\n * the values.  This is the 'PNG' mode.\n *\n * The alternative is to 'associate' the alpha with the color information by\n * storing color channel values that have been scaled by the alpha.\n * image.  These are the 'STANDARD', 'ASSOCIATED' or 'PREMULTIPLIED' modes\n * (the latter being the two common names for associated alpha color channels).\n *\n * For the 'OPTIMIZED' mode, a pixel is treated as opaque only if the alpha\n * value is equal to the maximum value.\n *\n * The final choice is to gamma encode the alpha channel as well.  This is\n * broken because, in practice, no implementation that uses this choice\n * correctly undoes the encoding before handling alpha composition.  Use this\n * choice only if other serious errors in the software or hardware you use\n * mandate it; the typical serious error is for dark halos to appear around\n * opaque areas of the composited PNG image because of arithmetic overflow.\n *\n * The API function png_set_alpha_mode specifies which of these choices to use\n * with an enumerated 'mode' value and the gamma of the required output:\n */\n#define PNG_ALPHA_PNG           0 /* according to the PNG standard */\n#define PNG_ALPHA_STANDARD      1 /* according to Porter/Duff */\n#define PNG_ALPHA_ASSOCIATED    1 /* as above; this is the normal practice */\n#define PNG_ALPHA_PREMULTIPLIED 1 /* as above */\n#define PNG_ALPHA_OPTIMIZED     2 /* 'PNG' for opaque pixels, else 'STANDARD' */\n#define PNG_ALPHA_BROKEN        3 /* the alpha channel is gamma encoded */\n\nPNG_FP_EXPORT(227, void, png_set_alpha_mode, (png_structrp png_ptr, int mode,\n    double output_gamma))\nPNG_FIXED_EXPORT(228, void, png_set_alpha_mode_fixed, (png_structrp png_ptr,\n    int mode, png_fixed_point output_gamma))\n#endif\n\n#if defined(PNG_GAMMA_SUPPORTED) || defined(PNG_READ_ALPHA_MODE_SUPPORTED)\n/* The output_gamma value is a screen gamma in libpng terminology: it expresses\n * how to decode the output values, not how they are encoded.\n */\n#define PNG_DEFAULT_sRGB -1       /* sRGB gamma and color space */\n#define PNG_GAMMA_MAC_18 -2       /* Old Mac '1.8' gamma and color space */\n#define PNG_GAMMA_sRGB   220000   /* Television standards--matches sRGB gamma */\n#define PNG_GAMMA_LINEAR PNG_FP_1 /* Linear */\n#endif\n\n/* The following are examples of calls to png_set_alpha_mode to achieve the\n * required overall gamma correction and, where necessary, alpha\n * premultiplication.\n *\n * png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_DEFAULT_sRGB);\n *    This is the default libpng handling of the alpha channel - it is not\n *    pre-multiplied into the color components.  In addition the call states\n *    that the output is for a sRGB system and causes all PNG files without gAMA\n *    chunks to be assumed to be encoded using sRGB.\n *\n * png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_GAMMA_MAC);\n *    In this case the output is assumed to be something like an sRGB conformant\n *    display preceeded by a power-law lookup table of power 1.45.  This is how\n *    early Mac systems behaved.\n *\n * png_set_alpha_mode(pp, PNG_ALPHA_STANDARD, PNG_GAMMA_LINEAR);\n *    This is the classic Jim Blinn approach and will work in academic\n *    environments where everything is done by the book.  It has the shortcoming\n *    of assuming that input PNG data with no gamma information is linear - this\n *    is unlikely to be correct unless the PNG files where generated locally.\n *    Most of the time the output precision will be so low as to show\n *    significant banding in dark areas of the image.\n *\n * png_set_expand_16(pp);\n * png_set_alpha_mode(pp, PNG_ALPHA_STANDARD, PNG_DEFAULT_sRGB);\n *    This is a somewhat more realistic Jim Blinn inspired approach.  PNG files\n *    are assumed to have the sRGB encoding if not marked with a gamma value and\n *    the output is always 16 bits per component.  This permits accurate scaling\n *    and processing of the data.  If you know that your input PNG files were\n *    generated locally you might need to replace PNG_DEFAULT_sRGB with the\n *    correct value for your system.\n *\n * png_set_alpha_mode(pp, PNG_ALPHA_OPTIMIZED, PNG_DEFAULT_sRGB);\n *    If you just need to composite the PNG image onto an existing background\n *    and if you control the code that does this you can use the optimization\n *    setting.  In this case you just copy completely opaque pixels to the\n *    output.  For pixels that are not completely transparent (you just skip\n *    those) you do the composition math using png_composite or png_composite_16\n *    below then encode the resultant 8-bit or 16-bit values to match the output\n *    encoding.\n *\n * Other cases\n *    If neither the PNG nor the standard linear encoding work for you because\n *    of the software or hardware you use then you have a big problem.  The PNG\n *    case will probably result in halos around the image.  The linear encoding\n *    will probably result in a washed out, too bright, image (it's actually too\n *    contrasty.)  Try the ALPHA_OPTIMIZED mode above - this will probably\n *    substantially reduce the halos.  Alternatively try:\n *\n * png_set_alpha_mode(pp, PNG_ALPHA_BROKEN, PNG_DEFAULT_sRGB);\n *    This option will also reduce the halos, but there will be slight dark\n *    halos round the opaque parts of the image where the background is light.\n *    In the OPTIMIZED mode the halos will be light halos where the background\n *    is dark.  Take your pick - the halos are unavoidable unless you can get\n *    your hardware/software fixed!  (The OPTIMIZED approach is slightly\n *    faster.)\n *\n * When the default gamma of PNG files doesn't match the output gamma.\n *    If you have PNG files with no gamma information png_set_alpha_mode allows\n *    you to provide a default gamma, but it also sets the ouput gamma to the\n *    matching value.  If you know your PNG files have a gamma that doesn't\n *    match the output you can take advantage of the fact that\n *    png_set_alpha_mode always sets the output gamma but only sets the PNG\n *    default if it is not already set:\n *\n * png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_DEFAULT_sRGB);\n * png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_GAMMA_MAC);\n *    The first call sets both the default and the output gamma values, the\n *    second call overrides the output gamma without changing the default.  This\n *    is easier than achieving the same effect with png_set_gamma.  You must use\n *    PNG_ALPHA_PNG for the first call - internal checking in png_set_alpha will\n *    fire if more than one call to png_set_alpha_mode and png_set_background is\n *    made in the same read operation, however multiple calls with PNG_ALPHA_PNG\n *    are ignored.\n */\n\n#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED\nPNG_EXPORT(36, void, png_set_strip_alpha, (png_structrp png_ptr));\n#endif\n\n#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) || \\\n    defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED)\nPNG_EXPORT(37, void, png_set_swap_alpha, (png_structrp png_ptr));\n#endif\n\n#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) || \\\n    defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED)\nPNG_EXPORT(38, void, png_set_invert_alpha, (png_structrp png_ptr));\n#endif\n\n#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED)\n/* Add a filler byte to 8-bit Gray or 24-bit RGB images. */\nPNG_EXPORT(39, void, png_set_filler, (png_structrp png_ptr, png_uint_32 filler,\n    int flags));\n/* The values of the PNG_FILLER_ defines should NOT be changed */\n#  define PNG_FILLER_BEFORE 0\n#  define PNG_FILLER_AFTER 1\n/* Add an alpha byte to 8-bit Gray or 24-bit RGB images. */\nPNG_EXPORT(40, void, png_set_add_alpha, (png_structrp png_ptr,\n    png_uint_32 filler, int flags));\n#endif /* PNG_READ_FILLER_SUPPORTED || PNG_WRITE_FILLER_SUPPORTED */\n\n#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED)\n/* Swap bytes in 16-bit depth files. */\nPNG_EXPORT(41, void, png_set_swap, (png_structrp png_ptr));\n#endif\n\n#if defined(PNG_READ_PACK_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED)\n/* Use 1 byte per pixel in 1, 2, or 4-bit depth files. */\nPNG_EXPORT(42, void, png_set_packing, (png_structrp png_ptr));\n#endif\n\n#if defined(PNG_READ_PACKSWAP_SUPPORTED) || \\\n    defined(PNG_WRITE_PACKSWAP_SUPPORTED)\n/* Swap packing order of pixels in bytes. */\nPNG_EXPORT(43, void, png_set_packswap, (png_structrp png_ptr));\n#endif\n\n#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED)\n/* Converts files to legal bit depths. */\nPNG_EXPORT(44, void, png_set_shift, (png_structrp png_ptr, png_const_color_8p\n    true_bits));\n#endif\n\n#if defined(PNG_READ_INTERLACING_SUPPORTED) || \\\n    defined(PNG_WRITE_INTERLACING_SUPPORTED)\n/* Have the code handle the interlacing.  Returns the number of passes.\n * MUST be called before png_read_update_info or png_start_read_image,\n * otherwise it will not have the desired effect.  Note that it is still\n * necessary to call png_read_row or png_read_rows png_get_image_height\n * times for each pass.\n*/\nPNG_EXPORT(45, int, png_set_interlace_handling, (png_structrp png_ptr));\n#endif\n\n#if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED)\n/* Invert monochrome files */\nPNG_EXPORT(46, void, png_set_invert_mono, (png_structrp png_ptr));\n#endif\n\n#ifdef PNG_READ_BACKGROUND_SUPPORTED\n/* Handle alpha and tRNS by replacing with a background color.  Prior to\n * libpng-1.5.4 this API must not be called before the PNG file header has been\n * read.  Doing so will result in unexpected behavior and possible warnings or\n * errors if the PNG file contains a bKGD chunk.\n */\nPNG_FP_EXPORT(47, void, png_set_background, (png_structrp png_ptr,\n    png_const_color_16p background_color, int background_gamma_code,\n    int need_expand, double background_gamma))\nPNG_FIXED_EXPORT(215, void, png_set_background_fixed, (png_structrp png_ptr,\n    png_const_color_16p background_color, int background_gamma_code,\n    int need_expand, png_fixed_point background_gamma))\n#endif\n#ifdef PNG_READ_BACKGROUND_SUPPORTED\n#  define PNG_BACKGROUND_GAMMA_UNKNOWN 0\n#  define PNG_BACKGROUND_GAMMA_SCREEN  1\n#  define PNG_BACKGROUND_GAMMA_FILE    2\n#  define PNG_BACKGROUND_GAMMA_UNIQUE  3\n#endif\n\n#ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED\n/* Scale a 16-bit depth file down to 8-bit, accurately. */\nPNG_EXPORT(229, void, png_set_scale_16, (png_structrp png_ptr));\n#endif\n\n#ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED\n#define PNG_READ_16_TO_8 SUPPORTED /* Name prior to 1.5.4 */\n/* Strip the second byte of information from a 16-bit depth file. */\nPNG_EXPORT(48, void, png_set_strip_16, (png_structrp png_ptr));\n#endif\n\n#ifdef PNG_READ_QUANTIZE_SUPPORTED\n/* Turn on quantizing, and reduce the palette to the number of colors\n * available.\n */\nPNG_EXPORT(49, void, png_set_quantize, (png_structrp png_ptr,\n    png_colorp palette, int num_palette, int maximum_colors,\n    png_const_uint_16p histogram, int full_quantize));\n#endif\n\n#ifdef PNG_READ_GAMMA_SUPPORTED\n/* The threshold on gamma processing is configurable but hard-wired into the\n * library.  The following is the floating point variant.\n */\n#define PNG_GAMMA_THRESHOLD (PNG_GAMMA_THRESHOLD_FIXED*.00001)\n\n/* Handle gamma correction. Screen_gamma=(display_exponent).\n * NOTE: this API simply sets the screen and file gamma values. It will\n * therefore override the value for gamma in a PNG file if it is called after\n * the file header has been read - use with care  - call before reading the PNG\n * file for best results!\n *\n * These routines accept the same gamma values as png_set_alpha_mode (described\n * above).  The PNG_GAMMA_ defines and PNG_DEFAULT_sRGB can be passed to either\n * API (floating point or fixed.)  Notice, however, that the 'file_gamma' value\n * is the inverse of a 'screen gamma' value.\n */\nPNG_FP_EXPORT(50, void, png_set_gamma, (png_structrp png_ptr,\n    double screen_gamma, double override_file_gamma))\nPNG_FIXED_EXPORT(208, void, png_set_gamma_fixed, (png_structrp png_ptr,\n    png_fixed_point screen_gamma, png_fixed_point override_file_gamma))\n#endif\n\n#ifdef PNG_WRITE_FLUSH_SUPPORTED\n/* Set how many lines between output flushes - 0 for no flushing */\nPNG_EXPORT(51, void, png_set_flush, (png_structrp png_ptr, int nrows));\n/* Flush the current PNG output buffer */\nPNG_EXPORT(52, void, png_write_flush, (png_structrp png_ptr));\n#endif\n\n/* Optional update palette with requested transformations */\nPNG_EXPORT(53, void, png_start_read_image, (png_structrp png_ptr));\n\n/* Optional call to update the users info structure */\nPNG_EXPORT(54, void, png_read_update_info, (png_structrp png_ptr,\n    png_inforp info_ptr));\n\n#ifdef PNG_SEQUENTIAL_READ_SUPPORTED\n/* Read one or more rows of image data. */\nPNG_EXPORT(55, void, png_read_rows, (png_structrp png_ptr, png_bytepp row,\n    png_bytepp display_row, png_uint_32 num_rows));\n#endif\n\n#ifdef PNG_SEQUENTIAL_READ_SUPPORTED\n/* Read a row of data. */\nPNG_EXPORT(56, void, png_read_row, (png_structrp png_ptr, png_bytep row,\n    png_bytep display_row));\n#endif\n\n#ifdef PNG_SEQUENTIAL_READ_SUPPORTED\n/* Read the whole image into memory at once. */\nPNG_EXPORT(57, void, png_read_image, (png_structrp png_ptr, png_bytepp image));\n#endif\n\n/* Write a row of image data */\nPNG_EXPORT(58, void, png_write_row, (png_structrp png_ptr,\n    png_const_bytep row));\n\n/* Write a few rows of image data: (*row) is not written; however, the type\n * is declared as writeable to maintain compatibility with previous versions\n * of libpng and to allow the 'display_row' array from read_rows to be passed\n * unchanged to write_rows.\n */\nPNG_EXPORT(59, void, png_write_rows, (png_structrp png_ptr, png_bytepp row,\n    png_uint_32 num_rows));\n\n/* Write the image data */\nPNG_EXPORT(60, void, png_write_image, (png_structrp png_ptr, png_bytepp image));\n\n/* Write the end of the PNG file. */\nPNG_EXPORT(61, void, png_write_end, (png_structrp png_ptr,\n    png_inforp info_ptr));\n\n#ifdef PNG_SEQUENTIAL_READ_SUPPORTED\n/* Read the end of the PNG file. */\nPNG_EXPORT(62, void, png_read_end, (png_structrp png_ptr, png_inforp info_ptr));\n#endif\n\n/* Free any memory associated with the png_info_struct */\nPNG_EXPORT(63, void, png_destroy_info_struct, (png_const_structrp png_ptr,\n    png_infopp info_ptr_ptr));\n\n/* Free any memory associated with the png_struct and the png_info_structs */\nPNG_EXPORT(64, void, png_destroy_read_struct, (png_structpp png_ptr_ptr,\n    png_infopp info_ptr_ptr, png_infopp end_info_ptr_ptr));\n\n/* Free any memory associated with the png_struct and the png_info_structs */\nPNG_EXPORT(65, void, png_destroy_write_struct, (png_structpp png_ptr_ptr,\n    png_infopp info_ptr_ptr));\n\n/* Set the libpng method of handling chunk CRC errors */\nPNG_EXPORT(66, void, png_set_crc_action, (png_structrp png_ptr, int crit_action,\n    int ancil_action));\n\n/* Values for png_set_crc_action() say how to handle CRC errors in\n * ancillary and critical chunks, and whether to use the data contained\n * therein.  Note that it is impossible to \"discard\" data in a critical\n * chunk.  For versions prior to 0.90, the action was always error/quit,\n * whereas in version 0.90 and later, the action for CRC errors in ancillary\n * chunks is warn/discard.  These values should NOT be changed.\n *\n *      value                       action:critical     action:ancillary\n */\n#define PNG_CRC_DEFAULT       0  /* error/quit          warn/discard data */\n#define PNG_CRC_ERROR_QUIT    1  /* error/quit          error/quit        */\n#define PNG_CRC_WARN_DISCARD  2  /* (INVALID)           warn/discard data */\n#define PNG_CRC_WARN_USE      3  /* warn/use data       warn/use data     */\n#define PNG_CRC_QUIET_USE     4  /* quiet/use data      quiet/use data    */\n#define PNG_CRC_NO_CHANGE     5  /* use current value   use current value */\n\n/* These functions give the user control over the scan-line filtering in\n * libpng and the compression methods used by zlib.  These functions are\n * mainly useful for testing, as the defaults should work with most users.\n * Those users who are tight on memory or want faster performance at the\n * expense of compression can modify them.  See the compression library\n * header file (zlib.h) for an explination of the compression functions.\n */\n\n/* Set the filtering method(s) used by libpng.  Currently, the only valid\n * value for \"method\" is 0.\n */\nPNG_EXPORT(67, void, png_set_filter, (png_structrp png_ptr, int method,\n    int filters));\n\n/* Flags for png_set_filter() to say which filters to use.  The flags\n * are chosen so that they don't conflict with real filter types\n * below, in case they are supplied instead of the #defined constants.\n * These values should NOT be changed.\n */\n#define PNG_NO_FILTERS     0x00\n#define PNG_FILTER_NONE    0x08\n#define PNG_FILTER_SUB     0x10\n#define PNG_FILTER_UP      0x20\n#define PNG_FILTER_AVG     0x40\n#define PNG_FILTER_PAETH   0x80\n#define PNG_ALL_FILTERS (PNG_FILTER_NONE | PNG_FILTER_SUB | PNG_FILTER_UP | \\\n                         PNG_FILTER_AVG | PNG_FILTER_PAETH)\n\n/* Filter values (not flags) - used in pngwrite.c, pngwutil.c for now.\n * These defines should NOT be changed.\n */\n#define PNG_FILTER_VALUE_NONE  0\n#define PNG_FILTER_VALUE_SUB   1\n#define PNG_FILTER_VALUE_UP    2\n#define PNG_FILTER_VALUE_AVG   3\n#define PNG_FILTER_VALUE_PAETH 4\n#define PNG_FILTER_VALUE_LAST  5\n\n#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED /* EXPERIMENTAL */\n/* The \"heuristic_method\" is given by one of the PNG_FILTER_HEURISTIC_\n * defines, either the default (minimum-sum-of-absolute-differences), or\n * the experimental method (weighted-minimum-sum-of-absolute-differences).\n *\n * Weights are factors >= 1.0, indicating how important it is to keep the\n * filter type consistent between rows.  Larger numbers mean the current\n * filter is that many times as likely to be the same as the \"num_weights\"\n * previous filters.  This is cumulative for each previous row with a weight.\n * There needs to be \"num_weights\" values in \"filter_weights\", or it can be\n * NULL if the weights aren't being specified.  Weights have no influence on\n * the selection of the first row filter.  Well chosen weights can (in theory)\n * improve the compression for a given image.\n *\n * Costs are factors >= 1.0 indicating the relative decoding costs of a\n * filter type.  Higher costs indicate more decoding expense, and are\n * therefore less likely to be selected over a filter with lower computational\n * costs.  There needs to be a value in \"filter_costs\" for each valid filter\n * type (given by PNG_FILTER_VALUE_LAST), or it can be NULL if you aren't\n * setting the costs.  Costs try to improve the speed of decompression without\n * unduly increasing the compressed image size.\n *\n * A negative weight or cost indicates the default value is to be used, and\n * values in the range [0.0, 1.0) indicate the value is to remain unchanged.\n * The default values for both weights and costs are currently 1.0, but may\n * change if good general weighting/cost heuristics can be found.  If both\n * the weights and costs are set to 1.0, this degenerates the WEIGHTED method\n * to the UNWEIGHTED method, but with added encoding time/computation.\n */\nPNG_FP_EXPORT(68, void, png_set_filter_heuristics, (png_structrp png_ptr,\n    int heuristic_method, int num_weights, png_const_doublep filter_weights,\n    png_const_doublep filter_costs))\nPNG_FIXED_EXPORT(209, void, png_set_filter_heuristics_fixed,\n    (png_structrp png_ptr, int heuristic_method, int num_weights,\n    png_const_fixed_point_p filter_weights,\n    png_const_fixed_point_p filter_costs))\n#endif /*  PNG_WRITE_WEIGHTED_FILTER_SUPPORTED */\n\n/* Heuristic used for row filter selection.  These defines should NOT be\n * changed.\n */\n#define PNG_FILTER_HEURISTIC_DEFAULT    0  /* Currently \"UNWEIGHTED\" */\n#define PNG_FILTER_HEURISTIC_UNWEIGHTED 1  /* Used by libpng < 0.95 */\n#define PNG_FILTER_HEURISTIC_WEIGHTED   2  /* Experimental feature */\n#define PNG_FILTER_HEURISTIC_LAST       3  /* Not a valid value */\n\n#ifdef PNG_WRITE_SUPPORTED\n/* Set the library compression level.  Currently, valid values range from\n * 0 - 9, corresponding directly to the zlib compression levels 0 - 9\n * (0 - no compression, 9 - \"maximal\" compression).  Note that tests have\n * shown that zlib compression levels 3-6 usually perform as well as level 9\n * for PNG images, and do considerably fewer caclulations.  In the future,\n * these values may not correspond directly to the zlib compression levels.\n */\nPNG_EXPORT(69, void, png_set_compression_level, (png_structrp png_ptr,\n    int level));\n\nPNG_EXPORT(70, void, png_set_compression_mem_level, (png_structrp png_ptr,\n    int mem_level));\n\nPNG_EXPORT(71, void, png_set_compression_strategy, (png_structrp png_ptr,\n    int strategy));\n\n/* If PNG_WRITE_OPTIMIZE_CMF_SUPPORTED is defined, libpng will use a\n * smaller value of window_bits if it can do so safely.\n */\nPNG_EXPORT(72, void, png_set_compression_window_bits, (png_structrp png_ptr,\n    int window_bits));\n\nPNG_EXPORT(73, void, png_set_compression_method, (png_structrp png_ptr,\n    int method));\n#endif\n\n#ifdef PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED\n/* Also set zlib parameters for compressing non-IDAT chunks */\nPNG_EXPORT(222, void, png_set_text_compression_level, (png_structrp png_ptr,\n    int level));\n\nPNG_EXPORT(223, void, png_set_text_compression_mem_level, (png_structrp png_ptr,\n    int mem_level));\n\nPNG_EXPORT(224, void, png_set_text_compression_strategy, (png_structrp png_ptr,\n    int strategy));\n\n/* If PNG_WRITE_OPTIMIZE_CMF_SUPPORTED is defined, libpng will use a\n * smaller value of window_bits if it can do so safely.\n */\nPNG_EXPORT(225, void, png_set_text_compression_window_bits,\n    (png_structrp png_ptr, int window_bits));\n\nPNG_EXPORT(226, void, png_set_text_compression_method, (png_structrp png_ptr,\n    int method));\n#endif /* PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED */\n\n/* These next functions are called for input/output, memory, and error\n * handling.  They are in the file pngrio.c, pngwio.c, and pngerror.c,\n * and call standard C I/O routines such as fread(), fwrite(), and\n * fprintf().  These functions can be made to use other I/O routines\n * at run time for those applications that need to handle I/O in a\n * different manner by calling png_set_???_fn().  See libpng-manual.txt for\n * more information.\n */\n\n#ifdef PNG_STDIO_SUPPORTED\n/* Initialize the input/output for the PNG file to the default functions. */\nPNG_EXPORT(74, void, png_init_io, (png_structrp png_ptr, png_FILE_p fp));\n#endif\n\n/* Replace the (error and abort), and warning functions with user\n * supplied functions.  If no messages are to be printed you must still\n * write and use replacement functions. The replacement error_fn should\n * still do a longjmp to the last setjmp location if you are using this\n * method of error handling.  If error_fn or warning_fn is NULL, the\n * default function will be used.\n */\n\nPNG_EXPORT(75, void, png_set_error_fn, (png_structrp png_ptr,\n    png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warning_fn));\n\n/* Return the user pointer associated with the error functions */\nPNG_EXPORT(76, png_voidp, png_get_error_ptr, (png_const_structrp png_ptr));\n\n/* Replace the default data output functions with a user supplied one(s).\n * If buffered output is not used, then output_flush_fn can be set to NULL.\n * If PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng compile time\n * output_flush_fn will be ignored (and thus can be NULL).\n * It is probably a mistake to use NULL for output_flush_fn if\n * write_data_fn is not also NULL unless you have built libpng with\n * PNG_WRITE_FLUSH_SUPPORTED undefined, because in this case libpng's\n * default flush function, which uses the standard *FILE structure, will\n * be used.\n */\nPNG_EXPORT(77, void, png_set_write_fn, (png_structrp png_ptr, png_voidp io_ptr,\n    png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn));\n\n/* Replace the default data input function with a user supplied one. */\nPNG_EXPORT(78, void, png_set_read_fn, (png_structrp png_ptr, png_voidp io_ptr,\n    png_rw_ptr read_data_fn));\n\n/* Return the user pointer associated with the I/O functions */\nPNG_EXPORT(79, png_voidp, png_get_io_ptr, (png_const_structrp png_ptr));\n\nPNG_EXPORT(80, void, png_set_read_status_fn, (png_structrp png_ptr,\n    png_read_status_ptr read_row_fn));\n\nPNG_EXPORT(81, void, png_set_write_status_fn, (png_structrp png_ptr,\n    png_write_status_ptr write_row_fn));\n\n#ifdef PNG_USER_MEM_SUPPORTED\n/* Replace the default memory allocation functions with user supplied one(s). */\nPNG_EXPORT(82, void, png_set_mem_fn, (png_structrp png_ptr, png_voidp mem_ptr,\n    png_malloc_ptr malloc_fn, png_free_ptr free_fn));\n/* Return the user pointer associated with the memory functions */\nPNG_EXPORT(83, png_voidp, png_get_mem_ptr, (png_const_structrp png_ptr));\n#endif\n\n#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED\nPNG_EXPORT(84, void, png_set_read_user_transform_fn, (png_structrp png_ptr,\n    png_user_transform_ptr read_user_transform_fn));\n#endif\n\n#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED\nPNG_EXPORT(85, void, png_set_write_user_transform_fn, (png_structrp png_ptr,\n    png_user_transform_ptr write_user_transform_fn));\n#endif\n\n#ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED\nPNG_EXPORT(86, void, png_set_user_transform_info, (png_structrp png_ptr,\n    png_voidp user_transform_ptr, int user_transform_depth,\n    int user_transform_channels));\n/* Return the user pointer associated with the user transform functions */\nPNG_EXPORT(87, png_voidp, png_get_user_transform_ptr,\n    (png_const_structrp png_ptr));\n#endif\n\n#ifdef PNG_USER_TRANSFORM_INFO_SUPPORTED\n/* Return information about the row currently being processed.  Note that these\n * APIs do not fail but will return unexpected results if called outside a user\n * transform callback.  Also note that when transforming an interlaced image the\n * row number is the row number within the sub-image of the interlace pass, so\n * the value will increase to the height of the sub-image (not the full image)\n * then reset to 0 for the next pass.\n *\n * Use PNG_ROW_FROM_PASS_ROW(row, pass) and PNG_COL_FROM_PASS_COL(col, pass) to\n * find the output pixel (x,y) given an interlaced sub-image pixel\n * (row,col,pass).  (See below for these macros.)\n */\nPNG_EXPORT(217, png_uint_32, png_get_current_row_number, (png_const_structrp));\nPNG_EXPORT(218, png_byte, png_get_current_pass_number, (png_const_structrp));\n#endif\n\n#ifdef PNG_READ_USER_CHUNKS_SUPPORTED\n/* This callback is called only for *unknown* chunks.  If\n * PNG_HANDLE_AS_UNKNOWN_SUPPORTED is set then it is possible to set known\n * chunks to be treated as unknown, however in this case the callback must do\n * any processing required by the chunk (e.g. by calling the appropriate\n * png_set_ APIs.)\n *\n * There is no write support - on write, by default, all the chunks in the\n * 'unknown' list are written in the specified position.\n *\n * The integer return from the callback function is interpreted thus:\n *\n * negative: An error occured, png_chunk_error will be called.\n *     zero: The chunk was not handled, the chunk will be saved. A critical\n *           chunk will cause an error at this point unless it is to be saved.\n * positive: The chunk was handled, libpng will ignore/discard it.\n *\n * See \"INTERACTION WTIH USER CHUNK CALLBACKS\" below for important notes about\n * how this behavior will change in libpng 1.7\n */\nPNG_EXPORT(88, void, png_set_read_user_chunk_fn, (png_structrp png_ptr,\n    png_voidp user_chunk_ptr, png_user_chunk_ptr read_user_chunk_fn));\n#endif\n\n#ifdef PNG_USER_CHUNKS_SUPPORTED\nPNG_EXPORT(89, png_voidp, png_get_user_chunk_ptr, (png_const_structrp png_ptr));\n#endif\n\n#ifdef PNG_PROGRESSIVE_READ_SUPPORTED\n/* Sets the function callbacks for the push reader, and a pointer to a\n * user-defined structure available to the callback functions.\n */\nPNG_EXPORT(90, void, png_set_progressive_read_fn, (png_structrp png_ptr,\n    png_voidp progressive_ptr, png_progressive_info_ptr info_fn,\n    png_progressive_row_ptr row_fn, png_progressive_end_ptr end_fn));\n\n/* Returns the user pointer associated with the push read functions */\nPNG_EXPORT(91, png_voidp, png_get_progressive_ptr,\n    (png_const_structrp png_ptr));\n\n/* Function to be called when data becomes available */\nPNG_EXPORT(92, void, png_process_data, (png_structrp png_ptr,\n    png_inforp info_ptr, png_bytep buffer, png_size_t buffer_size));\n\n/* A function which may be called *only* within png_process_data to stop the\n * processing of any more data.  The function returns the number of bytes\n * remaining, excluding any that libpng has cached internally.  A subsequent\n * call to png_process_data must supply these bytes again.  If the argument\n * 'save' is set to true the routine will first save all the pending data and\n * will always return 0.\n */\nPNG_EXPORT(219, png_size_t, png_process_data_pause, (png_structrp, int save));\n\n/* A function which may be called *only* outside (after) a call to\n * png_process_data.  It returns the number of bytes of data to skip in the\n * input.  Normally it will return 0, but if it returns a non-zero value the\n * application must skip than number of bytes of input data and pass the\n * following data to the next call to png_process_data.\n */\nPNG_EXPORT(220, png_uint_32, png_process_data_skip, (png_structrp));\n\n#ifdef PNG_READ_INTERLACING_SUPPORTED\n/* Function that combines rows.  'new_row' is a flag that should come from\n * the callback and be non-NULL if anything needs to be done; the library\n * stores its own version of the new data internally and ignores the passed\n * in value.\n */\nPNG_EXPORT(93, void, png_progressive_combine_row, (png_const_structrp png_ptr,\n    png_bytep old_row, png_const_bytep new_row));\n#endif /* PNG_READ_INTERLACING_SUPPORTED */\n#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */\n\nPNG_EXPORTA(94, png_voidp, png_malloc, (png_const_structrp png_ptr,\n    png_alloc_size_t size), PNG_ALLOCATED);\n/* Added at libpng version 1.4.0 */\nPNG_EXPORTA(95, png_voidp, png_calloc, (png_const_structrp png_ptr,\n    png_alloc_size_t size), PNG_ALLOCATED);\n\n/* Added at libpng version 1.2.4 */\nPNG_EXPORTA(96, png_voidp, png_malloc_warn, (png_const_structrp png_ptr,\n    png_alloc_size_t size), PNG_ALLOCATED);\n\n/* Frees a pointer allocated by png_malloc() */\nPNG_EXPORT(97, void, png_free, (png_const_structrp png_ptr, png_voidp ptr));\n\n/* Free data that was allocated internally */\nPNG_EXPORT(98, void, png_free_data, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 free_me, int num));\n\n/* Reassign responsibility for freeing existing data, whether allocated\n * by libpng or by the application; this works on the png_info structure passed\n * in, it does not change the state for other png_info structures.\n *\n * It is unlikely that this function works correctly as of 1.6.0 and using it\n * may result either in memory leaks or double free of allocated data.\n */\nPNG_EXPORT(99, void, png_data_freer, (png_const_structrp png_ptr,\n    png_inforp info_ptr, int freer, png_uint_32 mask));\n\n/* Assignments for png_data_freer */\n#define PNG_DESTROY_WILL_FREE_DATA 1\n#define PNG_SET_WILL_FREE_DATA 1\n#define PNG_USER_WILL_FREE_DATA 2\n/* Flags for png_ptr->free_me and info_ptr->free_me */\n#define PNG_FREE_HIST 0x0008\n#define PNG_FREE_ICCP 0x0010\n#define PNG_FREE_SPLT 0x0020\n#define PNG_FREE_ROWS 0x0040\n#define PNG_FREE_PCAL 0x0080\n#define PNG_FREE_SCAL 0x0100\n#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED\n#  define PNG_FREE_UNKN 0x0200\n#endif\n/*      PNG_FREE_LIST 0x0400    removed in 1.6.0 because it is ignored */\n#define PNG_FREE_PLTE 0x1000\n#define PNG_FREE_TRNS 0x2000\n#define PNG_FREE_TEXT 0x4000\n#define PNG_FREE_ALL  0x7fff\n#define PNG_FREE_MUL  0x4220 /* PNG_FREE_SPLT|PNG_FREE_TEXT|PNG_FREE_UNKN */\n\n#ifdef PNG_USER_MEM_SUPPORTED\nPNG_EXPORTA(100, png_voidp, png_malloc_default, (png_const_structrp png_ptr,\n    png_alloc_size_t size), PNG_ALLOCATED PNG_DEPRECATED);\nPNG_EXPORTA(101, void, png_free_default, (png_const_structrp png_ptr,\n    png_voidp ptr), PNG_DEPRECATED);\n#endif\n\n#ifdef PNG_ERROR_TEXT_SUPPORTED\n/* Fatal error in PNG image of libpng - can't continue */\nPNG_EXPORTA(102, void, png_error, (png_const_structrp png_ptr,\n    png_const_charp error_message), PNG_NORETURN);\n\n/* The same, but the chunk name is prepended to the error string. */\nPNG_EXPORTA(103, void, png_chunk_error, (png_const_structrp png_ptr,\n    png_const_charp error_message), PNG_NORETURN);\n\n#else\n/* Fatal error in PNG image of libpng - can't continue */\nPNG_EXPORTA(104, void, png_err, (png_const_structrp png_ptr), PNG_NORETURN);\n#  define png_error(s1,s2) png_err(s1)\n#  define png_chunk_error(s1,s2) png_err(s1)\n#endif\n\n#ifdef PNG_WARNINGS_SUPPORTED\n/* Non-fatal error in libpng.  Can continue, but may have a problem. */\nPNG_EXPORT(105, void, png_warning, (png_const_structrp png_ptr,\n    png_const_charp warning_message));\n\n/* Non-fatal error in libpng, chunk name is prepended to message. */\nPNG_EXPORT(106, void, png_chunk_warning, (png_const_structrp png_ptr,\n    png_const_charp warning_message));\n#else\n#  define png_warning(s1,s2) ((void)(s1))\n#  define png_chunk_warning(s1,s2) ((void)(s1))\n#endif\n\n#ifdef PNG_BENIGN_ERRORS_SUPPORTED\n/* Benign error in libpng.  Can continue, but may have a problem.\n * User can choose whether to handle as a fatal error or as a warning. */\nPNG_EXPORT(107, void, png_benign_error, (png_const_structrp png_ptr,\n    png_const_charp warning_message));\n\n#ifdef PNG_READ_SUPPORTED\n/* Same, chunk name is prepended to message (only during read) */\nPNG_EXPORT(108, void, png_chunk_benign_error, (png_const_structrp png_ptr,\n    png_const_charp warning_message));\n#endif\n\nPNG_EXPORT(109, void, png_set_benign_errors,\n    (png_structrp png_ptr, int allowed));\n#else\n#  ifdef PNG_ALLOW_BENIGN_ERRORS\n#    define png_benign_error png_warning\n#    define png_chunk_benign_error png_chunk_warning\n#  else\n#    define png_benign_error png_error\n#    define png_chunk_benign_error png_chunk_error\n#  endif\n#endif\n\n/* The png_set_<chunk> functions are for storing values in the png_info_struct.\n * Similarly, the png_get_<chunk> calls are used to read values from the\n * png_info_struct, either storing the parameters in the passed variables, or\n * setting pointers into the png_info_struct where the data is stored.  The\n * png_get_<chunk> functions return a non-zero value if the data was available\n * in info_ptr, or return zero and do not change any of the parameters if the\n * data was not available.\n *\n * These functions should be used instead of directly accessing png_info\n * to avoid problems with future changes in the size and internal layout of\n * png_info_struct.\n */\n/* Returns \"flag\" if chunk data is valid in info_ptr. */\nPNG_EXPORT(110, png_uint_32, png_get_valid, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr, png_uint_32 flag));\n\n/* Returns number of bytes needed to hold a transformed row. */\nPNG_EXPORT(111, png_size_t, png_get_rowbytes, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr));\n\n#ifdef PNG_INFO_IMAGE_SUPPORTED\n/* Returns row_pointers, which is an array of pointers to scanlines that was\n * returned from png_read_png().\n */\nPNG_EXPORT(112, png_bytepp, png_get_rows, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr));\n\n/* Set row_pointers, which is an array of pointers to scanlines for use\n * by png_write_png().\n */\nPNG_EXPORT(113, void, png_set_rows, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_bytepp row_pointers));\n#endif\n\n/* Returns number of color channels in image. */\nPNG_EXPORT(114, png_byte, png_get_channels, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr));\n\n#ifdef PNG_EASY_ACCESS_SUPPORTED\n/* Returns image width in pixels. */\nPNG_EXPORT(115, png_uint_32, png_get_image_width, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr));\n\n/* Returns image height in pixels. */\nPNG_EXPORT(116, png_uint_32, png_get_image_height, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr));\n\n/* Returns image bit_depth. */\nPNG_EXPORT(117, png_byte, png_get_bit_depth, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr));\n\n/* Returns image color_type. */\nPNG_EXPORT(118, png_byte, png_get_color_type, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr));\n\n/* Returns image filter_type. */\nPNG_EXPORT(119, png_byte, png_get_filter_type, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr));\n\n/* Returns image interlace_type. */\nPNG_EXPORT(120, png_byte, png_get_interlace_type, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr));\n\n/* Returns image compression_type. */\nPNG_EXPORT(121, png_byte, png_get_compression_type, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr));\n\n/* Returns image resolution in pixels per meter, from pHYs chunk data. */\nPNG_EXPORT(122, png_uint_32, png_get_pixels_per_meter,\n    (png_const_structrp png_ptr, png_const_inforp info_ptr));\nPNG_EXPORT(123, png_uint_32, png_get_x_pixels_per_meter,\n    (png_const_structrp png_ptr, png_const_inforp info_ptr));\nPNG_EXPORT(124, png_uint_32, png_get_y_pixels_per_meter,\n    (png_const_structrp png_ptr, png_const_inforp info_ptr));\n\n/* Returns pixel aspect ratio, computed from pHYs chunk data.  */\nPNG_FP_EXPORT(125, float, png_get_pixel_aspect_ratio,\n    (png_const_structrp png_ptr, png_const_inforp info_ptr))\nPNG_FIXED_EXPORT(210, png_fixed_point, png_get_pixel_aspect_ratio_fixed,\n    (png_const_structrp png_ptr, png_const_inforp info_ptr))\n\n/* Returns image x, y offset in pixels or microns, from oFFs chunk data. */\nPNG_EXPORT(126, png_int_32, png_get_x_offset_pixels,\n    (png_const_structrp png_ptr, png_const_inforp info_ptr));\nPNG_EXPORT(127, png_int_32, png_get_y_offset_pixels,\n    (png_const_structrp png_ptr, png_const_inforp info_ptr));\nPNG_EXPORT(128, png_int_32, png_get_x_offset_microns,\n    (png_const_structrp png_ptr, png_const_inforp info_ptr));\nPNG_EXPORT(129, png_int_32, png_get_y_offset_microns,\n    (png_const_structrp png_ptr, png_const_inforp info_ptr));\n\n#endif /* PNG_EASY_ACCESS_SUPPORTED */\n\n#ifdef PNG_READ_SUPPORTED\n/* Returns pointer to signature string read from PNG header */\nPNG_EXPORT(130, png_const_bytep, png_get_signature, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr));\n#endif\n\n#ifdef PNG_bKGD_SUPPORTED\nPNG_EXPORT(131, png_uint_32, png_get_bKGD, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_color_16p *background));\n#endif\n\n#ifdef PNG_bKGD_SUPPORTED\nPNG_EXPORT(132, void, png_set_bKGD, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_const_color_16p background));\n#endif\n\n#ifdef PNG_cHRM_SUPPORTED\nPNG_FP_EXPORT(133, png_uint_32, png_get_cHRM, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr, double *white_x, double *white_y, double *red_x,\n    double *red_y, double *green_x, double *green_y, double *blue_x,\n    double *blue_y))\nPNG_FP_EXPORT(230, png_uint_32, png_get_cHRM_XYZ, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr, double *red_X, double *red_Y, double *red_Z,\n    double *green_X, double *green_Y, double *green_Z, double *blue_X,\n    double *blue_Y, double *blue_Z))\nPNG_FIXED_EXPORT(134, png_uint_32, png_get_cHRM_fixed,\n    (png_const_structrp png_ptr, png_const_inforp info_ptr,\n    png_fixed_point *int_white_x, png_fixed_point *int_white_y,\n    png_fixed_point *int_red_x, png_fixed_point *int_red_y,\n    png_fixed_point *int_green_x, png_fixed_point *int_green_y,\n    png_fixed_point *int_blue_x, png_fixed_point *int_blue_y))\nPNG_FIXED_EXPORT(231, png_uint_32, png_get_cHRM_XYZ_fixed,\n    (png_const_structrp png_ptr, png_const_inforp info_ptr,\n    png_fixed_point *int_red_X, png_fixed_point *int_red_Y,\n    png_fixed_point *int_red_Z, png_fixed_point *int_green_X,\n    png_fixed_point *int_green_Y, png_fixed_point *int_green_Z,\n    png_fixed_point *int_blue_X, png_fixed_point *int_blue_Y,\n    png_fixed_point *int_blue_Z))\n#endif\n\n#ifdef PNG_cHRM_SUPPORTED\nPNG_FP_EXPORT(135, void, png_set_cHRM, (png_const_structrp png_ptr,\n    png_inforp info_ptr,\n    double white_x, double white_y, double red_x, double red_y, double green_x,\n    double green_y, double blue_x, double blue_y))\nPNG_FP_EXPORT(232, void, png_set_cHRM_XYZ, (png_const_structrp png_ptr,\n    png_inforp info_ptr, double red_X, double red_Y, double red_Z,\n    double green_X, double green_Y, double green_Z, double blue_X,\n    double blue_Y, double blue_Z))\nPNG_FIXED_EXPORT(136, void, png_set_cHRM_fixed, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_fixed_point int_white_x,\n    png_fixed_point int_white_y, png_fixed_point int_red_x,\n    png_fixed_point int_red_y, png_fixed_point int_green_x,\n    png_fixed_point int_green_y, png_fixed_point int_blue_x,\n    png_fixed_point int_blue_y))\nPNG_FIXED_EXPORT(233, void, png_set_cHRM_XYZ_fixed, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_fixed_point int_red_X, png_fixed_point int_red_Y,\n    png_fixed_point int_red_Z, png_fixed_point int_green_X,\n    png_fixed_point int_green_Y, png_fixed_point int_green_Z,\n    png_fixed_point int_blue_X, png_fixed_point int_blue_Y,\n    png_fixed_point int_blue_Z))\n#endif\n\n#ifdef PNG_gAMA_SUPPORTED\nPNG_FP_EXPORT(137, png_uint_32, png_get_gAMA, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr, double *file_gamma))\nPNG_FIXED_EXPORT(138, png_uint_32, png_get_gAMA_fixed,\n    (png_const_structrp png_ptr, png_const_inforp info_ptr,\n    png_fixed_point *int_file_gamma))\n#endif\n\n#ifdef PNG_gAMA_SUPPORTED\nPNG_FP_EXPORT(139, void, png_set_gAMA, (png_const_structrp png_ptr,\n    png_inforp info_ptr, double file_gamma))\nPNG_FIXED_EXPORT(140, void, png_set_gAMA_fixed, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_fixed_point int_file_gamma))\n#endif\n\n#ifdef PNG_hIST_SUPPORTED\nPNG_EXPORT(141, png_uint_32, png_get_hIST, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_uint_16p *hist));\n#endif\n\n#ifdef PNG_hIST_SUPPORTED\nPNG_EXPORT(142, void, png_set_hIST, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_const_uint_16p hist));\n#endif\n\nPNG_EXPORT(143, png_uint_32, png_get_IHDR, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr, png_uint_32 *width, png_uint_32 *height,\n    int *bit_depth, int *color_type, int *interlace_method,\n    int *compression_method, int *filter_method));\n\nPNG_EXPORT(144, void, png_set_IHDR, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 width, png_uint_32 height, int bit_depth,\n    int color_type, int interlace_method, int compression_method,\n    int filter_method));\n\n#ifdef PNG_oFFs_SUPPORTED\nPNG_EXPORT(145, png_uint_32, png_get_oFFs, (png_const_structrp png_ptr,\n   png_const_inforp info_ptr, png_int_32 *offset_x, png_int_32 *offset_y,\n   int *unit_type));\n#endif\n\n#ifdef PNG_oFFs_SUPPORTED\nPNG_EXPORT(146, void, png_set_oFFs, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_int_32 offset_x, png_int_32 offset_y,\n    int unit_type));\n#endif\n\n#ifdef PNG_pCAL_SUPPORTED\nPNG_EXPORT(147, png_uint_32, png_get_pCAL, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_charp *purpose, png_int_32 *X0,\n    png_int_32 *X1, int *type, int *nparams, png_charp *units,\n    png_charpp *params));\n#endif\n\n#ifdef PNG_pCAL_SUPPORTED\nPNG_EXPORT(148, void, png_set_pCAL, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_const_charp purpose, png_int_32 X0, png_int_32 X1,\n    int type, int nparams, png_const_charp units, png_charpp params));\n#endif\n\n#ifdef PNG_pHYs_SUPPORTED\nPNG_EXPORT(149, png_uint_32, png_get_pHYs, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr, png_uint_32 *res_x, png_uint_32 *res_y,\n    int *unit_type));\n#endif\n\n#ifdef PNG_pHYs_SUPPORTED\nPNG_EXPORT(150, void, png_set_pHYs, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 res_x, png_uint_32 res_y, int unit_type));\n#endif\n\nPNG_EXPORT(151, png_uint_32, png_get_PLTE, (png_const_structrp png_ptr,\n   png_inforp info_ptr, png_colorp *palette, int *num_palette));\n\nPNG_EXPORT(152, void, png_set_PLTE, (png_structrp png_ptr,\n    png_inforp info_ptr, png_const_colorp palette, int num_palette));\n\n#ifdef PNG_sBIT_SUPPORTED\nPNG_EXPORT(153, png_uint_32, png_get_sBIT, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_color_8p *sig_bit));\n#endif\n\n#ifdef PNG_sBIT_SUPPORTED\nPNG_EXPORT(154, void, png_set_sBIT, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_const_color_8p sig_bit));\n#endif\n\n#ifdef PNG_sRGB_SUPPORTED\nPNG_EXPORT(155, png_uint_32, png_get_sRGB, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr, int *file_srgb_intent));\n#endif\n\n#ifdef PNG_sRGB_SUPPORTED\nPNG_EXPORT(156, void, png_set_sRGB, (png_const_structrp png_ptr,\n    png_inforp info_ptr, int srgb_intent));\nPNG_EXPORT(157, void, png_set_sRGB_gAMA_and_cHRM, (png_const_structrp png_ptr,\n    png_inforp info_ptr, int srgb_intent));\n#endif\n\n#ifdef PNG_iCCP_SUPPORTED\nPNG_EXPORT(158, png_uint_32, png_get_iCCP, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_charpp name, int *compression_type,\n    png_bytepp profile, png_uint_32 *proflen));\n#endif\n\n#ifdef PNG_iCCP_SUPPORTED\nPNG_EXPORT(159, void, png_set_iCCP, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_const_charp name, int compression_type,\n    png_const_bytep profile, png_uint_32 proflen));\n#endif\n\n#ifdef PNG_sPLT_SUPPORTED\nPNG_EXPORT(160, int, png_get_sPLT, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_sPLT_tpp entries));\n#endif\n\n#ifdef PNG_sPLT_SUPPORTED\nPNG_EXPORT(161, void, png_set_sPLT, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_const_sPLT_tp entries, int nentries));\n#endif\n\n#ifdef PNG_TEXT_SUPPORTED\n/* png_get_text also returns the number of text chunks in *num_text */\nPNG_EXPORT(162, int, png_get_text, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_textp *text_ptr, int *num_text));\n#endif\n\n/* Note while png_set_text() will accept a structure whose text,\n * language, and  translated keywords are NULL pointers, the structure\n * returned by png_get_text will always contain regular\n * zero-terminated C strings.  They might be empty strings but\n * they will never be NULL pointers.\n */\n\n#ifdef PNG_TEXT_SUPPORTED\nPNG_EXPORT(163, void, png_set_text, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_const_textp text_ptr, int num_text));\n#endif\n\n#ifdef PNG_tIME_SUPPORTED\nPNG_EXPORT(164, png_uint_32, png_get_tIME, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_timep *mod_time));\n#endif\n\n#ifdef PNG_tIME_SUPPORTED\nPNG_EXPORT(165, void, png_set_tIME, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_const_timep mod_time));\n#endif\n\n#ifdef PNG_tRNS_SUPPORTED\nPNG_EXPORT(166, png_uint_32, png_get_tRNS, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_bytep *trans_alpha, int *num_trans,\n    png_color_16p *trans_color));\n#endif\n\n#ifdef PNG_tRNS_SUPPORTED\nPNG_EXPORT(167, void, png_set_tRNS, (png_structrp png_ptr,\n    png_inforp info_ptr, png_const_bytep trans_alpha, int num_trans,\n    png_const_color_16p trans_color));\n#endif\n\n#ifdef PNG_sCAL_SUPPORTED\nPNG_FP_EXPORT(168, png_uint_32, png_get_sCAL, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr, int *unit, double *width, double *height))\n#if defined(PNG_FLOATING_ARITHMETIC_SUPPORTED) || \\\n   defined(PNG_FLOATING_POINT_SUPPORTED)\n/* NOTE: this API is currently implemented using floating point arithmetic,\n * consequently it can only be used on systems with floating point support.\n * In any case the range of values supported by png_fixed_point is small and it\n * is highly recommended that png_get_sCAL_s be used instead.\n */\nPNG_FIXED_EXPORT(214, png_uint_32, png_get_sCAL_fixed,\n    (png_const_structrp png_ptr, png_const_inforp info_ptr, int *unit,\n    png_fixed_point *width, png_fixed_point *height))\n#endif\nPNG_EXPORT(169, png_uint_32, png_get_sCAL_s,\n    (png_const_structrp png_ptr, png_const_inforp info_ptr, int *unit,\n    png_charpp swidth, png_charpp sheight));\n\nPNG_FP_EXPORT(170, void, png_set_sCAL, (png_const_structrp png_ptr,\n    png_inforp info_ptr, int unit, double width, double height))\nPNG_FIXED_EXPORT(213, void, png_set_sCAL_fixed, (png_const_structrp png_ptr,\n   png_inforp info_ptr, int unit, png_fixed_point width,\n   png_fixed_point height))\nPNG_EXPORT(171, void, png_set_sCAL_s, (png_const_structrp png_ptr,\n    png_inforp info_ptr, int unit,\n    png_const_charp swidth, png_const_charp sheight));\n#endif /* PNG_sCAL_SUPPORTED */\n\n#ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED\n/* Provide the default handling for all unknown chunks or, optionally, for\n * specific unknown chunks.\n *\n * NOTE: prior to 1.6.0 the handling specified for particular chunks on read was\n * ignored and the default was used, the per-chunk setting only had an effect on\n * write.  If you wish to have chunk-specific handling on read in code that must\n * work on earlier versions you must use a user chunk callback to specify the\n * desired handling (keep or discard.)\n *\n * The 'keep' parameter is a PNG_HANDLE_CHUNK_ value as listed below.  The\n * parameter is interpreted as follows:\n *\n * READ:\n *    PNG_HANDLE_CHUNK_AS_DEFAULT:\n *       Known chunks: do normal libpng processing, do not keep the chunk (but\n *          see the comments below about PNG_HANDLE_AS_UNKNOWN_SUPPORTED)\n *       Unknown chunks: for a specific chunk use the global default, when used\n *          as the default discard the chunk data.\n *    PNG_HANDLE_CHUNK_NEVER:\n *       Discard the chunk data.\n *    PNG_HANDLE_CHUNK_IF_SAFE:\n *       Keep the chunk data if the chunk is not critical else raise a chunk\n *       error.\n *    PNG_HANDLE_CHUNK_ALWAYS:\n *       Keep the chunk data.\n *\n * If the chunk data is saved it can be retrieved using png_get_unknown_chunks,\n * below.  Notice that specifying \"AS_DEFAULT\" as a global default is equivalent\n * to specifying \"NEVER\", however when \"AS_DEFAULT\" is used for specific chunks\n * it simply resets the behavior to the libpng default.\n *\n * INTERACTION WTIH USER CHUNK CALLBACKS:\n * The per-chunk handling is always used when there is a png_user_chunk_ptr\n * callback and the callback returns 0; the chunk is then always stored *unless*\n * it is critical and the per-chunk setting is other than ALWAYS.  Notice that\n * the global default is *not* used in this case.  (In effect the per-chunk\n * value is incremented to at least IF_SAFE.)\n *\n * IMPORTANT NOTE: this behavior will change in libpng 1.7 - the global and\n * per-chunk defaults will be honored.  If you want to preserve the current\n * behavior when your callback returns 0 you must set PNG_HANDLE_CHUNK_IF_SAFE\n * as the default - if you don't do this libpng 1.6 will issue a warning.\n *\n * If you want unhandled unknown chunks to be discarded in libpng 1.6 and\n * earlier simply return '1' (handled).\n *\n * PNG_HANDLE_AS_UNKNOWN_SUPPORTED:\n *    If this is *not* set known chunks will always be handled by libpng and\n *    will never be stored in the unknown chunk list.  Known chunks listed to\n *    png_set_keep_unknown_chunks will have no effect.  If it is set then known\n *    chunks listed with a keep other than AS_DEFAULT will *never* be processed\n *    by libpng, in addition critical chunks must either be processed by the\n *    callback or saved.\n *\n *    The IHDR and IEND chunks must not be listed.  Because this turns off the\n *    default handling for chunks that would otherwise be recognized the\n *    behavior of libpng transformations may well become incorrect!\n *\n * WRITE:\n *    When writing chunks the options only apply to the chunks specified by\n *    png_set_unknown_chunks (below), libpng will *always* write known chunks\n *    required by png_set_ calls and will always write the core critical chunks\n *    (as required for PLTE).\n *\n *    Each chunk in the png_set_unknown_chunks list is looked up in the\n *    png_set_keep_unknown_chunks list to find the keep setting, this is then\n *    interpreted as follows:\n *\n *    PNG_HANDLE_CHUNK_AS_DEFAULT:\n *       Write safe-to-copy chunks and write other chunks if the global\n *       default is set to _ALWAYS, otherwise don't write this chunk.\n *    PNG_HANDLE_CHUNK_NEVER:\n *       Do not write the chunk.\n *    PNG_HANDLE_CHUNK_IF_SAFE:\n *       Write the chunk if it is safe-to-copy, otherwise do not write it.\n *    PNG_HANDLE_CHUNK_ALWAYS:\n *       Write the chunk.\n *\n * Note that the default behavior is effectively the opposite of the read case -\n * in read unknown chunks are not stored by default, in write they are written\n * by default.  Also the behavior of PNG_HANDLE_CHUNK_IF_SAFE is very different\n * - on write the safe-to-copy bit is checked, on read the critical bit is\n * checked and on read if the chunk is critical an error will be raised.\n *\n * num_chunks:\n * ===========\n *    If num_chunks is positive, then the \"keep\" parameter specifies the manner\n *    for handling only those chunks appearing in the chunk_list array,\n *    otherwise the chunk list array is ignored.\n *\n *    If num_chunks is 0 the \"keep\" parameter specifies the default behavior for\n *    unknown chunks, as described above.\n *\n *    If num_chunks is negative, then the \"keep\" parameter specifies the manner\n *    for handling all unknown chunks plus all chunks recognized by libpng\n *    except for the IHDR, PLTE, tRNS, IDAT, and IEND chunks (which continue to\n *    be processed by libpng.\n */\nPNG_EXPORT(172, void, png_set_keep_unknown_chunks, (png_structrp png_ptr,\n    int keep, png_const_bytep chunk_list, int num_chunks));\n\n/* The \"keep\" PNG_HANDLE_CHUNK_ parameter for the specified chunk is returned;\n * the result is therefore true (non-zero) if special handling is required,\n * false for the default handling.\n */\nPNG_EXPORT(173, int, png_handle_as_unknown, (png_const_structrp png_ptr,\n    png_const_bytep chunk_name));\n#endif\n\n#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED\nPNG_EXPORT(174, void, png_set_unknown_chunks, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_const_unknown_chunkp unknowns,\n    int num_unknowns));\n   /* NOTE: prior to 1.6.0 this routine set the 'location' field of the added\n    * unknowns to the location currently stored in the png_struct.  This is\n    * invariably the wrong value on write.  To fix this call the following API\n    * for each chunk in the list with the correct location.  If you know your\n    * code won't be compiled on earlier versions you can rely on\n    * png_set_unknown_chunks(write-ptr, png_get_unknown_chunks(read-ptr)) doing\n    * the correct thing.\n    */\n\nPNG_EXPORT(175, void, png_set_unknown_chunk_location,\n    (png_const_structrp png_ptr, png_inforp info_ptr, int chunk, int location));\n\nPNG_EXPORT(176, int, png_get_unknown_chunks, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_unknown_chunkpp entries));\n#endif\n\n/* Png_free_data() will turn off the \"valid\" flag for anything it frees.\n * If you need to turn it off for a chunk that your application has freed,\n * you can use png_set_invalid(png_ptr, info_ptr, PNG_INFO_CHNK);\n */\nPNG_EXPORT(177, void, png_set_invalid, (png_const_structrp png_ptr,\n    png_inforp info_ptr, int mask));\n\n#ifdef PNG_INFO_IMAGE_SUPPORTED\n/* The \"params\" pointer is currently not used and is for future expansion. */\n#ifdef PNG_SEQUENTIAL_READ_SUPPORTED\nPNG_EXPORT(178, void, png_read_png, (png_structrp png_ptr, png_inforp info_ptr,\n    int transforms, png_voidp params));\n#endif\n#ifdef PNG_WRITE_SUPPORTED\nPNG_EXPORT(179, void, png_write_png, (png_structrp png_ptr, png_inforp info_ptr,\n    int transforms, png_voidp params));\n#endif\n#endif\n\nPNG_EXPORT(180, png_const_charp, png_get_copyright,\n    (png_const_structrp png_ptr));\nPNG_EXPORT(181, png_const_charp, png_get_header_ver,\n    (png_const_structrp png_ptr));\nPNG_EXPORT(182, png_const_charp, png_get_header_version,\n    (png_const_structrp png_ptr));\nPNG_EXPORT(183, png_const_charp, png_get_libpng_ver,\n    (png_const_structrp png_ptr));\n\n#ifdef PNG_MNG_FEATURES_SUPPORTED\nPNG_EXPORT(184, png_uint_32, png_permit_mng_features, (png_structrp png_ptr,\n    png_uint_32 mng_features_permitted));\n#endif\n\n/* For use in png_set_keep_unknown, added to version 1.2.6 */\n#define PNG_HANDLE_CHUNK_AS_DEFAULT   0\n#define PNG_HANDLE_CHUNK_NEVER        1\n#define PNG_HANDLE_CHUNK_IF_SAFE      2\n#define PNG_HANDLE_CHUNK_ALWAYS       3\n#define PNG_HANDLE_CHUNK_LAST         4\n\n/* Strip the prepended error numbers (\"#nnn \") from error and warning\n * messages before passing them to the error or warning handler.\n */\n#ifdef PNG_ERROR_NUMBERS_SUPPORTED\nPNG_EXPORT(185, void, png_set_strip_error_numbers, (png_structrp png_ptr,\n    png_uint_32 strip_mode));\n#endif\n\n/* Added in libpng-1.2.6 */\n#ifdef PNG_SET_USER_LIMITS_SUPPORTED\nPNG_EXPORT(186, void, png_set_user_limits, (png_structrp png_ptr,\n    png_uint_32 user_width_max, png_uint_32 user_height_max));\nPNG_EXPORT(187, png_uint_32, png_get_user_width_max,\n    (png_const_structrp png_ptr));\nPNG_EXPORT(188, png_uint_32, png_get_user_height_max,\n    (png_const_structrp png_ptr));\n/* Added in libpng-1.4.0 */\nPNG_EXPORT(189, void, png_set_chunk_cache_max, (png_structrp png_ptr,\n    png_uint_32 user_chunk_cache_max));\nPNG_EXPORT(190, png_uint_32, png_get_chunk_cache_max,\n    (png_const_structrp png_ptr));\n/* Added in libpng-1.4.1 */\nPNG_EXPORT(191, void, png_set_chunk_malloc_max, (png_structrp png_ptr,\n    png_alloc_size_t user_chunk_cache_max));\nPNG_EXPORT(192, png_alloc_size_t, png_get_chunk_malloc_max,\n    (png_const_structrp png_ptr));\n#endif\n\n#if defined(PNG_INCH_CONVERSIONS_SUPPORTED)\nPNG_EXPORT(193, png_uint_32, png_get_pixels_per_inch,\n    (png_const_structrp png_ptr, png_const_inforp info_ptr));\n\nPNG_EXPORT(194, png_uint_32, png_get_x_pixels_per_inch,\n    (png_const_structrp png_ptr, png_const_inforp info_ptr));\n\nPNG_EXPORT(195, png_uint_32, png_get_y_pixels_per_inch,\n    (png_const_structrp png_ptr, png_const_inforp info_ptr));\n\nPNG_FP_EXPORT(196, float, png_get_x_offset_inches,\n    (png_const_structrp png_ptr, png_const_inforp info_ptr))\n#ifdef PNG_FIXED_POINT_SUPPORTED /* otherwise not implemented. */\nPNG_FIXED_EXPORT(211, png_fixed_point, png_get_x_offset_inches_fixed,\n    (png_const_structrp png_ptr, png_const_inforp info_ptr))\n#endif\n\nPNG_FP_EXPORT(197, float, png_get_y_offset_inches, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr))\n#ifdef PNG_FIXED_POINT_SUPPORTED /* otherwise not implemented. */\nPNG_FIXED_EXPORT(212, png_fixed_point, png_get_y_offset_inches_fixed,\n    (png_const_structrp png_ptr, png_const_inforp info_ptr))\n#endif\n\n#  ifdef PNG_pHYs_SUPPORTED\nPNG_EXPORT(198, png_uint_32, png_get_pHYs_dpi, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr, png_uint_32 *res_x, png_uint_32 *res_y,\n    int *unit_type));\n#  endif /* PNG_pHYs_SUPPORTED */\n#endif  /* PNG_INCH_CONVERSIONS_SUPPORTED */\n\n/* Added in libpng-1.4.0 */\n#ifdef PNG_IO_STATE_SUPPORTED\nPNG_EXPORT(199, png_uint_32, png_get_io_state, (png_const_structrp png_ptr));\n\n/* Removed from libpng 1.6; use png_get_io_chunk_type. */\nPNG_REMOVED(200, png_const_bytep, png_get_io_chunk_name, (png_structrp png_ptr),\n    PNG_DEPRECATED)\n\nPNG_EXPORT(216, png_uint_32, png_get_io_chunk_type,\n    (png_const_structrp png_ptr));\n\n/* The flags returned by png_get_io_state() are the following: */\n#  define PNG_IO_NONE        0x0000   /* no I/O at this moment */\n#  define PNG_IO_READING     0x0001   /* currently reading */\n#  define PNG_IO_WRITING     0x0002   /* currently writing */\n#  define PNG_IO_SIGNATURE   0x0010   /* currently at the file signature */\n#  define PNG_IO_CHUNK_HDR   0x0020   /* currently at the chunk header */\n#  define PNG_IO_CHUNK_DATA  0x0040   /* currently at the chunk data */\n#  define PNG_IO_CHUNK_CRC   0x0080   /* currently at the chunk crc */\n#  define PNG_IO_MASK_OP     0x000f   /* current operation: reading/writing */\n#  define PNG_IO_MASK_LOC    0x00f0   /* current location: sig/hdr/data/crc */\n#endif /* ?PNG_IO_STATE_SUPPORTED */\n\n/* Interlace support.  The following macros are always defined so that if\n * libpng interlace handling is turned off the macros may be used to handle\n * interlaced images within the application.\n */\n#define PNG_INTERLACE_ADAM7_PASSES 7\n\n/* Two macros to return the first row and first column of the original,\n * full, image which appears in a given pass.  'pass' is in the range 0\n * to 6 and the result is in the range 0 to 7.\n */\n#define PNG_PASS_START_ROW(pass) (((1&~(pass))<<(3-((pass)>>1)))&7)\n#define PNG_PASS_START_COL(pass) (((1& (pass))<<(3-(((pass)+1)>>1)))&7)\n\n/* A macro to return the offset between pixels in the output row for a pair of\n * pixels in the input - effectively the inverse of the 'COL_SHIFT' macro that\n * follows.  Note that ROW_OFFSET is the offset from one row to the next whereas\n * COL_OFFSET is from one column to the next, within a row.\n */\n#define PNG_PASS_ROW_OFFSET(pass) ((pass)>2?(8>>(((pass)-1)>>1)):8)\n#define PNG_PASS_COL_OFFSET(pass) (1<<((7-(pass))>>1))\n\n/* Two macros to help evaluate the number of rows or columns in each\n * pass.  This is expressed as a shift - effectively log2 of the number or\n * rows or columns in each 8x8 tile of the original image.\n */\n#define PNG_PASS_ROW_SHIFT(pass) ((pass)>2?(8-(pass))>>1:3)\n#define PNG_PASS_COL_SHIFT(pass) ((pass)>1?(7-(pass))>>1:3)\n\n/* Hence two macros to determine the number of rows or columns in a given\n * pass of an image given its height or width.  In fact these macros may\n * return non-zero even though the sub-image is empty, because the other\n * dimension may be empty for a small image.\n */\n#define PNG_PASS_ROWS(height, pass) (((height)+(((1<<PNG_PASS_ROW_SHIFT(pass))\\\n   -1)-PNG_PASS_START_ROW(pass)))>>PNG_PASS_ROW_SHIFT(pass))\n#define PNG_PASS_COLS(width, pass) (((width)+(((1<<PNG_PASS_COL_SHIFT(pass))\\\n   -1)-PNG_PASS_START_COL(pass)))>>PNG_PASS_COL_SHIFT(pass))\n\n/* For the reader row callbacks (both progressive and sequential) it is\n * necessary to find the row in the output image given a row in an interlaced\n * image, so two more macros:\n */\n#define PNG_ROW_FROM_PASS_ROW(y_in, pass) \\\n   (((y_in)<<PNG_PASS_ROW_SHIFT(pass))+PNG_PASS_START_ROW(pass))\n#define PNG_COL_FROM_PASS_COL(x_in, pass) \\\n   (((x_in)<<PNG_PASS_COL_SHIFT(pass))+PNG_PASS_START_COL(pass))\n\n/* Two macros which return a boolean (0 or 1) saying whether the given row\n * or column is in a particular pass.  These use a common utility macro that\n * returns a mask for a given pass - the offset 'off' selects the row or\n * column version.  The mask has the appropriate bit set for each column in\n * the tile.\n */\n#define PNG_PASS_MASK(pass,off) ( \\\n   ((0x110145AF>>(((7-(off))-(pass))<<2)) & 0xF) | \\\n   ((0x01145AF0>>(((7-(off))-(pass))<<2)) & 0xF0))\n\n#define PNG_ROW_IN_INTERLACE_PASS(y, pass) \\\n   ((PNG_PASS_MASK(pass,0) >> ((y)&7)) & 1)\n#define PNG_COL_IN_INTERLACE_PASS(x, pass) \\\n   ((PNG_PASS_MASK(pass,1) >> ((x)&7)) & 1)\n\n#ifdef PNG_READ_COMPOSITE_NODIV_SUPPORTED\n/* With these routines we avoid an integer divide, which will be slower on\n * most machines.  However, it does take more operations than the corresponding\n * divide method, so it may be slower on a few RISC systems.  There are two\n * shifts (by 8 or 16 bits) and an addition, versus a single integer divide.\n *\n * Note that the rounding factors are NOT supposed to be the same!  128 and\n * 32768 are correct for the NODIV code; 127 and 32767 are correct for the\n * standard method.\n *\n * [Optimized code by Greg Roelofs and Mark Adler...blame us for bugs. :-) ]\n */\n\n /* fg and bg should be in `gamma 1.0' space; alpha is the opacity */\n\n#  define png_composite(composite, fg, alpha, bg)         \\\n     { png_uint_16 temp = (png_uint_16)((png_uint_16)(fg) \\\n           * (png_uint_16)(alpha)                         \\\n           + (png_uint_16)(bg)*(png_uint_16)(255          \\\n           - (png_uint_16)(alpha)) + 128);                \\\n       (composite) = (png_byte)((temp + (temp >> 8)) >> 8); }\n\n#  define png_composite_16(composite, fg, alpha, bg)       \\\n     { png_uint_32 temp = (png_uint_32)((png_uint_32)(fg)  \\\n           * (png_uint_32)(alpha)                          \\\n           + (png_uint_32)(bg)*(65535                      \\\n           - (png_uint_32)(alpha)) + 32768);               \\\n       (composite) = (png_uint_16)((temp + (temp >> 16)) >> 16); }\n\n#else  /* Standard method using integer division */\n\n#  define png_composite(composite, fg, alpha, bg)                          \\\n     (composite) = (png_byte)(((png_uint_16)(fg) * (png_uint_16)(alpha) +  \\\n     (png_uint_16)(bg) * (png_uint_16)(255 - (png_uint_16)(alpha)) +       \\\n     127) / 255)\n\n#  define png_composite_16(composite, fg, alpha, bg)                         \\\n     (composite) = (png_uint_16)(((png_uint_32)(fg) * (png_uint_32)(alpha) + \\\n     (png_uint_32)(bg)*(png_uint_32)(65535 - (png_uint_32)(alpha)) +         \\\n     32767) / 65535)\n#endif /* PNG_READ_COMPOSITE_NODIV_SUPPORTED */\n\n#ifdef PNG_READ_INT_FUNCTIONS_SUPPORTED\nPNG_EXPORT(201, png_uint_32, png_get_uint_32, (png_const_bytep buf));\nPNG_EXPORT(202, png_uint_16, png_get_uint_16, (png_const_bytep buf));\nPNG_EXPORT(203, png_int_32, png_get_int_32, (png_const_bytep buf));\n#endif\n\nPNG_EXPORT(204, png_uint_32, png_get_uint_31, (png_const_structrp png_ptr,\n    png_const_bytep buf));\n/* No png_get_int_16 -- may be added if there's a real need for it. */\n\n/* Place a 32-bit number into a buffer in PNG byte order (big-endian). */\n#ifdef PNG_WRITE_INT_FUNCTIONS_SUPPORTED\nPNG_EXPORT(205, void, png_save_uint_32, (png_bytep buf, png_uint_32 i));\n#endif\n#ifdef PNG_SAVE_INT_32_SUPPORTED\nPNG_EXPORT(206, void, png_save_int_32, (png_bytep buf, png_int_32 i));\n#endif\n\n/* Place a 16-bit number into a buffer in PNG byte order.\n * The parameter is declared unsigned int, not png_uint_16,\n * just to avoid potential problems on pre-ANSI C compilers.\n */\n#ifdef PNG_WRITE_INT_FUNCTIONS_SUPPORTED\nPNG_EXPORT(207, void, png_save_uint_16, (png_bytep buf, unsigned int i));\n/* No png_save_int_16 -- may be added if there's a real need for it. */\n#endif\n\n#ifdef PNG_USE_READ_MACROS\n/* Inline macros to do direct reads of bytes from the input buffer.\n * The png_get_int_32() routine assumes we are using two's complement\n * format for negative values, which is almost certainly true.\n */\n#  define PNG_get_uint_32(buf) \\\n     (((png_uint_32)(*(buf)) << 24) + \\\n      ((png_uint_32)(*((buf) + 1)) << 16) + \\\n      ((png_uint_32)(*((buf) + 2)) << 8) + \\\n      ((png_uint_32)(*((buf) + 3))))\n\n   /* From libpng-1.4.0 until 1.4.4, the png_get_uint_16 macro (but not the\n    * function) incorrectly returned a value of type png_uint_32.\n    */\n#  define PNG_get_uint_16(buf) \\\n     ((png_uint_16) \\\n      (((unsigned int)(*(buf)) << 8) + \\\n       ((unsigned int)(*((buf) + 1)))))\n\n#  define PNG_get_int_32(buf) \\\n     ((png_int_32)((*(buf) & 0x80) \\\n      ? -((png_int_32)((png_get_uint_32(buf) ^ 0xffffffffL) + 1)) \\\n      : (png_int_32)png_get_uint_32(buf)))\n\n   /* If PNG_PREFIX is defined the same thing as below happens in pnglibconf.h,\n    * but defining a macro name prefixed with PNG_PREFIX.\n    */\n#  ifndef PNG_PREFIX\n#     define png_get_uint_32(buf) PNG_get_uint_32(buf)\n#     define png_get_uint_16(buf) PNG_get_uint_16(buf)\n#     define png_get_int_32(buf)  PNG_get_int_32(buf)\n#  endif\n#else\n#  ifdef PNG_PREFIX\n      /* No macros; revert to the (redefined) function */\n#     define PNG_get_uint_32 (png_get_uint_32)\n#     define PNG_get_uint_16 (png_get_uint_16)\n#     define PNG_get_int_32  (png_get_int_32)\n#  endif\n#endif\n\n/*******************************************************************************\n *  SIMPLIFIED API\n *******************************************************************************\n *\n * Please read the documentation in libpng-manual.txt (TODO: write said\n * documentation) if you don't understand what follows.\n *\n * The simplified API hides the details of both libpng and the PNG file format\n * itself.  It allows PNG files to be read into a very limited number of\n * in-memory bitmap formats or to be written from the same formats.  If these\n * formats do not accomodate your needs then you can, and should, use the more\n * sophisticated APIs above - these support a wide variety of in-memory formats\n * and a wide variety of sophisticated transformations to those formats as well\n * as a wide variety of APIs to manipulate ancillary information.\n *\n * To read a PNG file using the simplified API:\n *\n * 1) Declare a 'png_image' structure (see below) on the stack and set the\n *    version field to PNG_IMAGE_VERSION.\n * 2) Call the appropriate png_image_begin_read... function.\n * 3) Set the png_image 'format' member to the required sample format.\n * 4) Allocate a buffer for the image and, if required, the color-map.\n * 5) Call png_image_finish_read to read the image and, if required, the\n *    color-map into your buffers.\n *\n * There are no restrictions on the format of the PNG input itself; all valid\n * color types, bit depths, and interlace methods are acceptable, and the\n * input image is transformed as necessary to the requested in-memory format\n * during the png_image_finish_read() step.  The only caveat is that if you\n * request a color-mapped image from a PNG that is full-color or makes\n * complex use of an alpha channel the transformation is extremely lossy and the\n * result may look terrible.\n *\n * To write a PNG file using the simplified API:\n *\n * 1) Declare a 'png_image' structure on the stack and memset() it to all zero.\n * 2) Initialize the members of the structure that describe the image, setting\n *    the 'format' member to the format of the image samples.\n * 3) Call the appropriate png_image_write... function with a pointer to the\n *    image and, if necessary, the color-map to write the PNG data.\n *\n * png_image is a structure that describes the in-memory format of an image\n * when it is being read or defines the in-memory format of an image that you\n * need to write:\n */\n#define PNG_IMAGE_VERSION 1\n\ntypedef struct png_control *png_controlp;\ntypedef struct\n{\n   png_controlp opaque;    /* Initialize to NULL, free with png_image_free */\n   png_uint_32  version;   /* Set to PNG_IMAGE_VERSION */\n   png_uint_32  width;     /* Image width in pixels (columns) */\n   png_uint_32  height;    /* Image height in pixels (rows) */\n   png_uint_32  format;    /* Image format as defined below */\n   png_uint_32  flags;     /* A bit mask containing informational flags */\n   png_uint_32  colormap_entries;\n                           /* Number of entries in the color-map */\n\n   /* In the event of an error or warning the following field will be set to a\n    * non-zero value and the 'message' field will contain a '\\0' terminated\n    * string with the libpng error or warning message.  If both warnings and\n    * an error were encountered, only the error is recorded.  If there\n    * are multiple warnings, only the first one is recorded.\n    *\n    * The upper 30 bits of this value are reserved, the low two bits contain\n    * a value as follows:\n    */\n#  define PNG_IMAGE_WARNING 1\n#  define PNG_IMAGE_ERROR 2\n   /*\n    * The result is a two bit code such that a value more than 1 indicates\n    * a failure in the API just called:\n    *\n    *    0 - no warning or error\n    *    1 - warning\n    *    2 - error\n    *    3 - error preceded by warning\n    */\n#  define PNG_IMAGE_FAILED(png_cntrl) ((((png_cntrl).warning_or_error)&0x03)>1)\n\n   png_uint_32  warning_or_error;\n\n   char         message[64];\n} png_image, *png_imagep;\n\n/* The samples of the image have one to four channels whose components have\n * original values in the range 0 to 1.0:\n *\n * 1: A single gray or luminance channel (G).\n * 2: A gray/luminance channel and an alpha channel (GA).\n * 3: Three red, green, blue color channels (RGB).\n * 4: Three color channels and an alpha channel (RGBA).\n *\n * The components are encoded in one of two ways:\n *\n * a) As a small integer, value 0..255, contained in a single byte.  For the\n * alpha channel the original value is simply value/255.  For the color or\n * luminance channels the value is encoded according to the sRGB specification\n * and matches the 8-bit format expected by typical display devices.\n *\n * The color/gray channels are not scaled (pre-multiplied) by the alpha\n * channel and are suitable for passing to color management software.\n *\n * b) As a value in the range 0..65535, contained in a 2-byte integer.  All\n * channels can be converted to the original value by dividing by 65535; all\n * channels are linear.  Color channels use the RGB encoding (RGB end-points) of\n * the sRGB specification.  This encoding is identified by the\n * PNG_FORMAT_FLAG_LINEAR flag below.\n *\n * When the simplified API needs to convert between sRGB and linear colorspaces,\n * the actual sRGB transfer curve defined in the sRGB specification (see the\n * article at http://en.wikipedia.org/wiki/SRGB) is used, not the gamma=1/2.2\n * approximation used elsewhere in libpng.\n *\n * When an alpha channel is present it is expected to denote pixel coverage\n * of the color or luminance channels and is returned as an associated alpha\n * channel: the color/gray channels are scaled (pre-multiplied) by the alpha\n * value.\n *\n * The samples are either contained directly in the image data, between 1 and 8\n * bytes per pixel according to the encoding, or are held in a color-map indexed\n * by bytes in the image data.  In the case of a color-map the color-map entries\n * are individual samples, encoded as above, and the image data has one byte per\n * pixel to select the relevant sample from the color-map.\n */\n\n/* PNG_FORMAT_*\n *\n * #defines to be used in png_image::format.  Each #define identifies a\n * particular layout of sample data and, if present, alpha values.  There are\n * separate defines for each of the two component encodings.\n *\n * A format is built up using single bit flag values.  All combinations are\n * valid.  Formats can be built up from the flag values or you can use one of\n * the predefined values below.  When testing formats always use the FORMAT_FLAG\n * macros to test for individual features - future versions of the library may\n * add new flags.\n *\n * When reading or writing color-mapped images the format should be set to the\n * format of the entries in the color-map then png_image_{read,write}_colormap\n * called to read or write the color-map and set the format correctly for the\n * image data.  Do not set the PNG_FORMAT_FLAG_COLORMAP bit directly!\n *\n * NOTE: libpng can be built with particular features disabled, if you see\n * compiler errors because the definition of one of the following flags has been\n * compiled out it is because libpng does not have the required support.  It is\n * possible, however, for the libpng configuration to enable the format on just\n * read or just write; in that case you may see an error at run time.  You can\n * guard against this by checking for the definition of the appropriate\n * \"_SUPPORTED\" macro, one of:\n *\n *    PNG_SIMPLIFIED_{READ,WRITE}_{BGR,AFIRST}_SUPPORTED\n */\n#define PNG_FORMAT_FLAG_ALPHA    0x01U /* format with an alpha channel */\n#define PNG_FORMAT_FLAG_COLOR    0x02U /* color format: otherwise grayscale */\n#define PNG_FORMAT_FLAG_LINEAR   0x04U /* 2 byte channels else 1 byte */\n#define PNG_FORMAT_FLAG_COLORMAP 0x08U /* image data is color-mapped */\n\n#ifdef PNG_FORMAT_BGR_SUPPORTED\n#  define PNG_FORMAT_FLAG_BGR    0x10U /* BGR colors, else order is RGB */\n#endif\n\n#ifdef PNG_FORMAT_AFIRST_SUPPORTED\n#  define PNG_FORMAT_FLAG_AFIRST 0x20U /* alpha channel comes first */\n#endif\n\n/* Commonly used formats have predefined macros.\n *\n * First the single byte (sRGB) formats:\n */\n#define PNG_FORMAT_GRAY 0\n#define PNG_FORMAT_GA   PNG_FORMAT_FLAG_ALPHA\n#define PNG_FORMAT_AG   (PNG_FORMAT_GA|PNG_FORMAT_FLAG_AFIRST)\n#define PNG_FORMAT_RGB  PNG_FORMAT_FLAG_COLOR\n#define PNG_FORMAT_BGR  (PNG_FORMAT_FLAG_COLOR|PNG_FORMAT_FLAG_BGR)\n#define PNG_FORMAT_RGBA (PNG_FORMAT_RGB|PNG_FORMAT_FLAG_ALPHA)\n#define PNG_FORMAT_ARGB (PNG_FORMAT_RGBA|PNG_FORMAT_FLAG_AFIRST)\n#define PNG_FORMAT_BGRA (PNG_FORMAT_BGR|PNG_FORMAT_FLAG_ALPHA)\n#define PNG_FORMAT_ABGR (PNG_FORMAT_BGRA|PNG_FORMAT_FLAG_AFIRST)\n\n/* Then the linear 2-byte formats.  When naming these \"Y\" is used to\n * indicate a luminance (gray) channel.\n */\n#define PNG_FORMAT_LINEAR_Y PNG_FORMAT_FLAG_LINEAR\n#define PNG_FORMAT_LINEAR_Y_ALPHA (PNG_FORMAT_FLAG_LINEAR|PNG_FORMAT_FLAG_ALPHA)\n#define PNG_FORMAT_LINEAR_RGB (PNG_FORMAT_FLAG_LINEAR|PNG_FORMAT_FLAG_COLOR)\n#define PNG_FORMAT_LINEAR_RGB_ALPHA \\\n   (PNG_FORMAT_FLAG_LINEAR|PNG_FORMAT_FLAG_COLOR|PNG_FORMAT_FLAG_ALPHA)\n\n/* With color-mapped formats the image data is one byte for each pixel, the byte\n * is an index into the color-map which is formatted as above.  To obtain a\n * color-mapped format it is sufficient just to add the PNG_FOMAT_FLAG_COLORMAP\n * to one of the above definitions, or you can use one of the definitions below.\n */\n#define PNG_FORMAT_RGB_COLORMAP  (PNG_FORMAT_RGB|PNG_FORMAT_FLAG_COLORMAP)\n#define PNG_FORMAT_BGR_COLORMAP  (PNG_FORMAT_BGR|PNG_FORMAT_FLAG_COLORMAP)\n#define PNG_FORMAT_RGBA_COLORMAP (PNG_FORMAT_RGBA|PNG_FORMAT_FLAG_COLORMAP)\n#define PNG_FORMAT_ARGB_COLORMAP (PNG_FORMAT_ARGB|PNG_FORMAT_FLAG_COLORMAP)\n#define PNG_FORMAT_BGRA_COLORMAP (PNG_FORMAT_BGRA|PNG_FORMAT_FLAG_COLORMAP)\n#define PNG_FORMAT_ABGR_COLORMAP (PNG_FORMAT_ABGR|PNG_FORMAT_FLAG_COLORMAP)\n\n/* PNG_IMAGE macros\n *\n * These are convenience macros to derive information from a png_image\n * structure.  The PNG_IMAGE_SAMPLE_ macros return values appropriate to the\n * actual image sample values - either the entries in the color-map or the\n * pixels in the image.  The PNG_IMAGE_PIXEL_ macros return corresponding values\n * for the pixels and will always return 1 for color-mapped formats.  The\n * remaining macros return information about the rows in the image and the\n * complete image.\n *\n * NOTE: All the macros that take a png_image::format parameter are compile time\n * constants if the format parameter is, itself, a constant.  Therefore these\n * macros can be used in array declarations and case labels where required.\n * Similarly the macros are also pre-processor constants (sizeof is not used) so\n * they can be used in #if tests.\n *\n * First the information about the samples.\n */\n#define PNG_IMAGE_SAMPLE_CHANNELS(fmt)\\\n   (((fmt)&(PNG_FORMAT_FLAG_COLOR|PNG_FORMAT_FLAG_ALPHA))+1)\n   /* Return the total number of channels in a given format: 1..4 */\n\n#define PNG_IMAGE_SAMPLE_COMPONENT_SIZE(fmt)\\\n   ((((fmt) & PNG_FORMAT_FLAG_LINEAR) >> 2)+1)\n   /* Return the size in bytes of a single component of a pixel or color-map\n    * entry (as appropriate) in the image: 1 or 2.\n    */\n\n#define PNG_IMAGE_SAMPLE_SIZE(fmt)\\\n   (PNG_IMAGE_SAMPLE_CHANNELS(fmt) * PNG_IMAGE_SAMPLE_COMPONENT_SIZE(fmt))\n   /* This is the size of the sample data for one sample.  If the image is\n    * color-mapped it is the size of one color-map entry (and image pixels are\n    * one byte in size), otherwise it is the size of one image pixel.\n    */\n\n#define PNG_IMAGE_MAXIMUM_COLORMAP_COMPONENTS(fmt)\\\n   (PNG_IMAGE_SAMPLE_CHANNELS(fmt) * 256)\n   /* The maximum size of the color-map required by the format expressed in a\n    * count of components.  This can be used to compile-time allocate a\n    * color-map:\n    *\n    * png_uint_16 colormap[PNG_IMAGE_MAXIMUM_COLORMAP_COMPONENTS(linear_fmt)];\n    *\n    * png_byte colormap[PNG_IMAGE_MAXIMUM_COLORMAP_COMPONENTS(sRGB_fmt)];\n    *\n    * Alternatively use the PNG_IMAGE_COLORMAP_SIZE macro below to use the\n    * information from one of the png_image_begin_read_ APIs and dynamically\n    * allocate the required memory.\n    */\n\n/* Corresponding information about the pixels */\n#define PNG_IMAGE_PIXEL_(test,fmt)\\\n   (((fmt)&PNG_FORMAT_FLAG_COLORMAP)?1:test(fmt))\n\n#define PNG_IMAGE_PIXEL_CHANNELS(fmt)\\\n   PNG_IMAGE_PIXEL_(PNG_IMAGE_SAMPLE_CHANNELS,fmt)\n   /* The number of separate channels (components) in a pixel; 1 for a\n    * color-mapped image.\n    */\n\n#define PNG_IMAGE_PIXEL_COMPONENT_SIZE(fmt)\\\n   PNG_IMAGE_PIXEL_(PNG_IMAGE_SAMPLE_COMPONENT_SIZE,fmt)\n   /* The size, in bytes, of each component in a pixel; 1 for a color-mapped\n    * image.\n    */\n\n#define PNG_IMAGE_PIXEL_SIZE(fmt) PNG_IMAGE_PIXEL_(PNG_IMAGE_SAMPLE_SIZE,fmt)\n   /* The size, in bytes, of a complete pixel; 1 for a color-mapped image. */\n\n/* Information about the whole row, or whole image */\n#define PNG_IMAGE_ROW_STRIDE(image)\\\n   (PNG_IMAGE_PIXEL_CHANNELS((image).format) * (image).width)\n   /* Return the total number of components in a single row of the image; this\n    * is the minimum 'row stride', the minimum count of components between each\n    * row.  For a color-mapped image this is the minimum number of bytes in a\n    * row.\n    */\n\n#define PNG_IMAGE_BUFFER_SIZE(image, row_stride)\\\n   (PNG_IMAGE_PIXEL_COMPONENT_SIZE((image).format)*(image).height*(row_stride))\n   /* Return the size, in bytes, of an image buffer given a png_image and a row\n    * stride - the number of components to leave space for in each row.\n    */\n\n#define PNG_IMAGE_SIZE(image)\\\n   PNG_IMAGE_BUFFER_SIZE(image, PNG_IMAGE_ROW_STRIDE(image))\n   /* Return the size, in bytes, of the image in memory given just a png_image;\n    * the row stride is the minimum stride required for the image.\n    */\n\n#define PNG_IMAGE_COLORMAP_SIZE(image)\\\n   (PNG_IMAGE_SAMPLE_SIZE((image).format) * (image).colormap_entries)\n   /* Return the size, in bytes, of the color-map of this image.  If the image\n    * format is not a color-map format this will return a size sufficient for\n    * 256 entries in the given format; check PNG_FORMAT_FLAG_COLORMAP if\n    * you don't want to allocate a color-map in this case.\n    */\n\n/* PNG_IMAGE_FLAG_*\n *\n * Flags containing additional information about the image are held in the\n * 'flags' field of png_image.\n */\n#define PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB 0x01\n   /* This indicates the the RGB values of the in-memory bitmap do not\n    * correspond to the red, green and blue end-points defined by sRGB.\n    */\n\n#define PNG_IMAGE_FLAG_FAST 0x02\n   /* On write emphasise speed over compression; the resultant PNG file will be\n    * larger but will be produced significantly faster, particular for large\n    * images.  Do not use this option for images which will be distributed, only\n    * used it when producing intermediate files that will be read back in\n    * repeatedly.  For a typical 24-bit image the option will double the read\n    * speed at the cost of increasing the image size by 25%, however for many\n    * more compressible images the PNG file can be 10 times larger with only a\n    * slight speed gain.\n    */\n\n#define PNG_IMAGE_FLAG_16BIT_sRGB 0x04\n   /* On read if the image is a 16-bit per component image and there is no gAMA\n    * or sRGB chunk assume that the components are sRGB encoded.  Notice that\n    * images output by the simplified API always have gamma information; setting\n    * this flag only affects the interpretation of 16-bit images from an\n    * external source.  It is recommended that the application expose this flag\n    * to the user; the user can normally easily recognize the difference between\n    * linear and sRGB encoding.  This flag has no effect on write - the data\n    * passed to the write APIs must have the correct encoding (as defined\n    * above.)\n    *\n    * If the flag is not set (the default) input 16-bit per component data is\n    * assumed to be linear.\n    *\n    * NOTE: the flag can only be set after the png_image_begin_read_ call,\n    * because that call initializes the 'flags' field.\n    */\n\n#ifdef PNG_SIMPLIFIED_READ_SUPPORTED\n/* READ APIs\n * ---------\n *\n * The png_image passed to the read APIs must have been initialized by setting\n * the png_controlp field 'opaque' to NULL (or, safer, memset the whole thing.)\n */\n#ifdef PNG_STDIO_SUPPORTED\nPNG_EXPORT(234, int, png_image_begin_read_from_file, (png_imagep image,\n   const char *file_name));\n   /* The named file is opened for read and the image header is filled in\n    * from the PNG header in the file.\n    */\n\nPNG_EXPORT(235, int, png_image_begin_read_from_stdio, (png_imagep image,\n   FILE* file));\n   /* The PNG header is read from the stdio FILE object. */\n#endif /* PNG_STDIO_SUPPORTED */\n\nPNG_EXPORT(236, int, png_image_begin_read_from_memory, (png_imagep image,\n   png_const_voidp memory, png_size_t size));\n   /* The PNG header is read from the given memory buffer. */\n\nPNG_EXPORT(237, int, png_image_finish_read, (png_imagep image,\n   png_const_colorp background, void *buffer, png_int_32 row_stride,\n   void *colormap));\n   /* Finish reading the image into the supplied buffer and clean up the\n    * png_image structure.\n    *\n    * row_stride is the step, in byte or 2-byte units as appropriate,\n    * between adjacent rows.  A positive stride indicates that the top-most row\n    * is first in the buffer - the normal top-down arrangement.  A negative\n    * stride indicates that the bottom-most row is first in the buffer.\n    *\n    * background need only be supplied if an alpha channel must be removed from\n    * a png_byte format and the removal is to be done by compositing on a solid\n    * color; otherwise it may be NULL and any composition will be done directly\n    * onto the buffer.  The value is an sRGB color to use for the background,\n    * for grayscale output the green channel is used.\n    *\n    * background must be supplied when an alpha channel must be removed from a\n    * single byte color-mapped output format, in other words if:\n    *\n    * 1) The original format from png_image_begin_read_from_* had\n    *    PNG_FORMAT_FLAG_ALPHA set.\n    * 2) The format set by the application does not.\n    * 3) The format set by the application has PNG_FORMAT_FLAG_COLORMAP set and\n    *    PNG_FORMAT_FLAG_LINEAR *not* set.\n    *\n    * For linear output removing the alpha channel is always done by compositing\n    * on black and background is ignored.\n    *\n    * colormap must be supplied when PNG_FORMAT_FLAG_COLORMAP is set.  It must\n    * be at least the size (in bytes) returned by PNG_IMAGE_COLORMAP_SIZE.\n    * image->colormap_entries will be updated to the actual number of entries\n    * written to the colormap; this may be less than the original value.\n    */\n\nPNG_EXPORT(238, void, png_image_free, (png_imagep image));\n   /* Free any data allocated by libpng in image->opaque, setting the pointer to\n    * NULL.  May be called at any time after the structure is initialized.\n    */\n#endif /* PNG_SIMPLIFIED_READ_SUPPORTED */\n\n#ifdef PNG_SIMPLIFIED_WRITE_SUPPORTED\n#ifdef PNG_STDIO_SUPPORTED\n/* WRITE APIS\n * ----------\n * For write you must initialize a png_image structure to describe the image to\n * be written.  To do this use memset to set the whole structure to 0 then\n * initialize fields describing your image.\n *\n * version: must be set to PNG_IMAGE_VERSION\n * opaque: must be initialized to NULL\n * width: image width in pixels\n * height: image height in rows\n * format: the format of the data (image and color-map) you wish to write\n * flags: set to 0 unless one of the defined flags applies; set\n *    PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB for color format images where the RGB\n *    values do not correspond to the colors in sRGB.\n * colormap_entries: set to the number of entries in the color-map (0 to 256)\n */\nPNG_EXPORT(239, int, png_image_write_to_file, (png_imagep image,\n   const char *file, int convert_to_8bit, const void *buffer,\n   png_int_32 row_stride, const void *colormap));\n   /* Write the image to the named file. */\n\nPNG_EXPORT(240, int, png_image_write_to_stdio, (png_imagep image, FILE *file,\n   int convert_to_8_bit, const void *buffer, png_int_32 row_stride,\n   const void *colormap));\n   /* Write the image to the given (FILE*). */\n\n/* With both write APIs if image is in one of the linear formats with 16-bit\n * data then setting convert_to_8_bit will cause the output to be an 8-bit PNG\n * gamma encoded according to the sRGB specification, otherwise a 16-bit linear\n * encoded PNG file is written.\n *\n * With color-mapped data formats the colormap parameter point to a color-map\n * with at least image->colormap_entries encoded in the specified format.  If\n * the format is linear the written PNG color-map will be converted to sRGB\n * regardless of the convert_to_8_bit flag.\n *\n * With all APIs row_stride is handled as in the read APIs - it is the spacing\n * from one row to the next in component sized units (1 or 2 bytes) and if\n * negative indicates a bottom-up row layout in the buffer.\n *\n * Note that the write API does not support interlacing or sub-8-bit pixels.\n */\n#endif /* PNG_STDIO_SUPPORTED */\n#endif /* PNG_SIMPLIFIED_WRITE_SUPPORTED */\n/*******************************************************************************\n *  END OF SIMPLIFIED API\n ******************************************************************************/\n\n#ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED\nPNG_EXPORT(242, void, png_set_check_for_invalid_index,\n    (png_structrp png_ptr, int allowed));\n#  ifdef PNG_GET_PALETTE_MAX_SUPPORTED\nPNG_EXPORT(243, int, png_get_palette_max, (png_const_structp png_ptr,\n    png_const_infop info_ptr));\n#  endif\n#endif /* CHECK_FOR_INVALID_INDEX */\n\n/*******************************************************************************\n *  IMPLEMENTATION OPTIONS\n *******************************************************************************\n *\n * Support for arbitrary implementation-specific optimizations.  The API allows\n * particular options to be turned on or off.  'Option' is the number of the\n * option and 'onoff' is 0 (off) or non-0 (on).  The value returned is given\n * by the PNG_OPTION_ defines below.\n *\n * HARDWARE: normally hardware capabilites, such as the Intel SSE instructions,\n *           are detected at run time, however sometimes it may be impossible\n *           to do this in user mode, in which case it is necessary to discover\n *           the capabilities in an OS specific way.  Such capabilities are\n *           listed here when libpng has support for them and must be turned\n *           ON by the application if present.\n *\n * SOFTWARE: sometimes software optimizations actually result in performance\n *           decrease on some architectures or systems, or with some sets of\n *           PNG images.  'Software' options allow such optimizations to be\n *           selected at run time.\n */\n#ifdef PNG_SET_OPTION_SUPPORTED\n#ifdef PNG_ARM_NEON_API_SUPPORTED\n#  define PNG_ARM_NEON   0 /* HARDWARE: ARM Neon SIMD instructions supported */\n#endif\n#define PNG_MAXIMUM_INFLATE_WINDOW 2 /* SOFTWARE: force maximum window */\n#define PNG_OPTION_NEXT  4 /* Next option - numbers must be even */\n\n/* Return values: NOTE: there are four values and 'off' is *not* zero */\n#define PNG_OPTION_UNSET   0 /* Unset - defaults to off */\n#define PNG_OPTION_INVALID 1 /* Option number out of range */\n#define PNG_OPTION_OFF     2\n#define PNG_OPTION_ON      3\n\nPNG_EXPORT(244, int, png_set_option, (png_structrp png_ptr, int option,\n   int onoff));\n#endif\n\n/*******************************************************************************\n *  END OF HARDWARE OPTIONS\n ******************************************************************************/\n\n/* Maintainer: Put new public prototypes here ^, in libpng.3, and project\n * defs, scripts/pnglibconf.h, and scripts/pnglibconf.h.prebuilt\n */\n\n/* The last ordinal number (this is the *last* one already used; the next\n * one to use is one more than this.)  Maintainer, remember to add an entry to\n * scripts/symbols.def as well.\n */\n#ifdef PNG_EXPORT_LAST_ORDINAL\n  PNG_EXPORT_LAST_ORDINAL(244);\n#endif\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* PNG_VERSION_INFO_ONLY */\n/* Do not put anything past this line */\n#endif /* PNG_H */\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/png/pngconf.h",
    "content": "\n/* pngconf.h - machine configurable file for libpng\n *\n * libpng version 1.6.10 - March 6, 2014\n *\n * Copyright (c) 1998-2013 Glenn Randers-Pehrson\n * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)\n * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)\n *\n * This code is released under the libpng license.\n * For conditions of distribution and use, see the disclaimer\n * and license in png.h\n *\n */\n\n/* Any machine specific code is near the front of this file, so if you\n * are configuring libpng for a machine, you may want to read the section\n * starting here down to where it starts to typedef png_color, png_text,\n * and png_info.\n */\n\n#ifndef PNGCONF_H\n#define PNGCONF_H\n\n/* To do: Do all of this in scripts/pnglibconf.dfa */\n#ifdef PNG_SAFE_LIMITS_SUPPORTED\n#  ifdef PNG_USER_WIDTH_MAX\n#    undef PNG_USER_WIDTH_MAX\n#    define PNG_USER_WIDTH_MAX 1000000L\n#  endif\n#  ifdef PNG_USER_HEIGHT_MAX\n#    undef PNG_USER_HEIGHT_MAX\n#    define PNG_USER_HEIGHT_MAX 1000000L\n#  endif\n#  ifdef PNG_USER_CHUNK_MALLOC_MAX\n#    undef PNG_USER_CHUNK_MALLOC_MAX\n#    define PNG_USER_CHUNK_MALLOC_MAX 4000000L\n#  endif\n#  ifdef PNG_USER_CHUNK_CACHE_MAX\n#    undef PNG_USER_CHUNK_CACHE_MAX\n#    define PNG_USER_CHUNK_CACHE_MAX 128\n#  endif\n#endif\n\n#ifndef PNG_BUILDING_SYMBOL_TABLE /* else includes may cause problems */\n\n/* From libpng 1.6.0 libpng requires an ANSI X3.159-1989 (\"ISOC90\") compliant C\n * compiler for correct compilation.  The following header files are required by\n * the standard.  If your compiler doesn't provide these header files, or they\n * do not match the standard, you will need to provide/improve them.\n */\n#include <limits.h>\n#include <stddef.h>\n\n/* Library header files.  These header files are all defined by ISOC90; libpng\n * expects conformant implementations, however, an ISOC90 conformant system need\n * not provide these header files if the functionality cannot be implemented.\n * In this case it will be necessary to disable the relevant parts of libpng in\n * the build of pnglibconf.h.\n *\n * Prior to 1.6.0 string.h was included here; the API changes in 1.6.0 to not\n * include this unnecessary header file.\n */\n\n#ifdef PNG_STDIO_SUPPORTED\n   /* Required for the definition of FILE: */\n#  include <stdio.h>\n#endif\n\n#ifdef PNG_SETJMP_SUPPORTED\n   /* Required for the definition of jmp_buf and the declaration of longjmp: */\n#  include <setjmp.h>\n#endif\n\n#ifdef PNG_CONVERT_tIME_SUPPORTED\n   /* Required for struct tm: */\n#  include <time.h>\n#endif\n\n#endif /* PNG_BUILDING_SYMBOL_TABLE */\n\n/* Prior to 1.6.0 it was possible to turn off 'const' in declarations using\n * PNG_NO_CONST; this is no longer supported except for data declarations which\n * apparently still cause problems in 2011 on some compilers.\n */\n#define PNG_CONST const /* backward compatibility only */\n\n/* This controls optimization of the reading of 16 and 32 bit values\n * from PNG files.  It can be set on a per-app-file basis - it\n * just changes whether a macro is used when the function is called.\n * The library builder sets the default; if read functions are not\n * built into the library the macro implementation is forced on.\n */\n#ifndef PNG_READ_INT_FUNCTIONS_SUPPORTED\n#  define PNG_USE_READ_MACROS\n#endif\n#if !defined(PNG_NO_USE_READ_MACROS) && !defined(PNG_USE_READ_MACROS)\n#  if PNG_DEFAULT_READ_MACROS\n#    define PNG_USE_READ_MACROS\n#  endif\n#endif\n\n/* COMPILER SPECIFIC OPTIONS.\n *\n * These options are provided so that a variety of difficult compilers\n * can be used.  Some are fixed at build time (e.g. PNG_API_RULE\n * below) but still have compiler specific implementations, others\n * may be changed on a per-file basis when compiling against libpng.\n */\n\n/* The PNGARG macro was used in versions of libpng prior to 1.6.0 to protect\n * against legacy (pre ISOC90) compilers that did not understand function\n * prototypes.  It is not required for modern C compilers.\n */\n#ifndef PNGARG\n#  define PNGARG(arglist) arglist\n#endif\n\n/* Function calling conventions.\n * =============================\n * Normally it is not necessary to specify to the compiler how to call\n * a function - it just does it - however on x86 systems derived from\n * Microsoft and Borland C compilers ('IBM PC', 'DOS', 'Windows' systems\n * and some others) there are multiple ways to call a function and the\n * default can be changed on the compiler command line.  For this reason\n * libpng specifies the calling convention of every exported function and\n * every function called via a user supplied function pointer.  This is\n * done in this file by defining the following macros:\n *\n * PNGAPI    Calling convention for exported functions.\n * PNGCBAPI  Calling convention for user provided (callback) functions.\n * PNGCAPI   Calling convention used by the ANSI-C library (required\n *           for longjmp callbacks and sometimes used internally to\n *           specify the calling convention for zlib).\n *\n * These macros should never be overridden.  If it is necessary to\n * change calling convention in a private build this can be done\n * by setting PNG_API_RULE (which defaults to 0) to one of the values\n * below to select the correct 'API' variants.\n *\n * PNG_API_RULE=0 Use PNGCAPI - the 'C' calling convention - throughout.\n *                This is correct in every known environment.\n * PNG_API_RULE=1 Use the operating system convention for PNGAPI and\n *                the 'C' calling convention (from PNGCAPI) for\n *                callbacks (PNGCBAPI).  This is no longer required\n *                in any known environment - if it has to be used\n *                please post an explanation of the problem to the\n *                libpng mailing list.\n *\n * These cases only differ if the operating system does not use the C\n * calling convention, at present this just means the above cases\n * (x86 DOS/Windows sytems) and, even then, this does not apply to\n * Cygwin running on those systems.\n *\n * Note that the value must be defined in pnglibconf.h so that what\n * the application uses to call the library matches the conventions\n * set when building the library.\n */\n\n/* Symbol export\n * =============\n * When building a shared library it is almost always necessary to tell\n * the compiler which symbols to export.  The png.h macro 'PNG_EXPORT'\n * is used to mark the symbols.  On some systems these symbols can be\n * extracted at link time and need no special processing by the compiler,\n * on other systems the symbols are flagged by the compiler and just\n * the declaration requires a special tag applied (unfortunately) in a\n * compiler dependent way.  Some systems can do either.\n *\n * A small number of older systems also require a symbol from a DLL to\n * be flagged to the program that calls it.  This is a problem because\n * we do not know in the header file included by application code that\n * the symbol will come from a shared library, as opposed to a statically\n * linked one.  For this reason the application must tell us by setting\n * the magic flag PNG_USE_DLL to turn on the special processing before\n * it includes png.h.\n *\n * Four additional macros are used to make this happen:\n *\n * PNG_IMPEXP The magic (if any) to cause a symbol to be exported from\n *            the build or imported if PNG_USE_DLL is set - compiler\n *            and system specific.\n *\n * PNG_EXPORT_TYPE(type) A macro that pre or appends PNG_IMPEXP to\n *                       'type', compiler specific.\n *\n * PNG_DLL_EXPORT Set to the magic to use during a libpng build to\n *                make a symbol exported from the DLL.  Not used in the\n *                public header files; see pngpriv.h for how it is used\n *                in the libpng build.\n *\n * PNG_DLL_IMPORT Set to the magic to force the libpng symbols to come\n *                from a DLL - used to define PNG_IMPEXP when\n *                PNG_USE_DLL is set.\n */\n\n/* System specific discovery.\n * ==========================\n * This code is used at build time to find PNG_IMPEXP, the API settings\n * and PNG_EXPORT_TYPE(), it may also set a macro to indicate the DLL\n * import processing is possible.  On Windows systems it also sets\n * compiler-specific macros to the values required to change the calling\n * conventions of the various functions.\n */\n#if defined(_Windows) || defined(_WINDOWS) || defined(WIN32) ||\\\n    defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)\n  /* Windows system (DOS doesn't support DLLs).  Includes builds under Cygwin or\n   * MinGW on any architecture currently supported by Windows.  Also includes\n   * Watcom builds but these need special treatment because they are not\n   * compatible with GCC or Visual C because of different calling conventions.\n   */\n#  if PNG_API_RULE == 2\n    /* If this line results in an error, either because __watcall is not\n     * understood or because of a redefine just below you cannot use *this*\n     * build of the library with the compiler you are using.  *This* build was\n     * build using Watcom and applications must also be built using Watcom!\n     */\n#    define PNGCAPI __watcall\n#  endif\n\n#  if defined(__GNUC__) || (defined(_MSC_VER) && (_MSC_VER >= 800))\n#    define PNGCAPI __cdecl\n#    if PNG_API_RULE == 1\n       /* If this line results in an error __stdcall is not understood and\n        * PNG_API_RULE should not have been set to '1'.\n        */\n#      define PNGAPI __stdcall\n#    endif\n#  else\n    /* An older compiler, or one not detected (erroneously) above,\n     * if necessary override on the command line to get the correct\n     * variants for the compiler.\n     */\n#    ifndef PNGCAPI\n#      define PNGCAPI _cdecl\n#    endif\n#    if PNG_API_RULE == 1 && !defined(PNGAPI)\n#      define PNGAPI _stdcall\n#    endif\n#  endif /* compiler/api */\n\n  /* NOTE: PNGCBAPI always defaults to PNGCAPI. */\n\n#  if defined(PNGAPI) && !defined(PNG_USER_PRIVATEBUILD)\n#     error \"PNG_USER_PRIVATEBUILD must be defined if PNGAPI is changed\"\n#  endif\n\n#  if (defined(_MSC_VER) && _MSC_VER < 800) ||\\\n      (defined(__BORLANDC__) && __BORLANDC__ < 0x500)\n    /* older Borland and MSC\n     * compilers used '__export' and required this to be after\n     * the type.\n     */\n#    ifndef PNG_EXPORT_TYPE\n#      define PNG_EXPORT_TYPE(type) type PNG_IMPEXP\n#    endif\n#    define PNG_DLL_EXPORT __export\n#  else /* newer compiler */\n#    define PNG_DLL_EXPORT __declspec(dllexport)\n#    ifndef PNG_DLL_IMPORT\n#      define PNG_DLL_IMPORT __declspec(dllimport)\n#    endif\n#  endif /* compiler */\n\n#else /* !Windows */\n#  if (defined(__IBMC__) || defined(__IBMCPP__)) && defined(__OS2__)\n#    define PNGAPI _System\n#  else /* !Windows/x86 && !OS/2 */\n    /* Use the defaults, or define PNG*API on the command line (but\n     * this will have to be done for every compile!)\n     */\n#  endif /* other system, !OS/2 */\n#endif /* !Windows/x86 */\n\n/* Now do all the defaulting . */\n#ifndef PNGCAPI\n#  define PNGCAPI\n#endif\n#ifndef PNGCBAPI\n#  define PNGCBAPI PNGCAPI\n#endif\n#ifndef PNGAPI\n#  define PNGAPI PNGCAPI\n#endif\n\n/* PNG_IMPEXP may be set on the compilation system command line or (if not set)\n * then in an internal header file when building the library, otherwise (when\n * using the library) it is set here.\n */\n#ifndef PNG_IMPEXP\n#  if defined(PNG_USE_DLL) && defined(PNG_DLL_IMPORT)\n     /* This forces use of a DLL, disallowing static linking */\n#    define PNG_IMPEXP PNG_DLL_IMPORT\n#  endif\n\n#  ifndef PNG_IMPEXP\n#    define PNG_IMPEXP\n#  endif\n#endif\n\n/* In 1.5.2 the definition of PNG_FUNCTION has been changed to always treat\n * 'attributes' as a storage class - the attributes go at the start of the\n * function definition, and attributes are always appended regardless of the\n * compiler.  This considerably simplifies these macros but may cause problems\n * if any compilers both need function attributes and fail to handle them as\n * a storage class (this is unlikely.)\n */\n#ifndef PNG_FUNCTION\n#  define PNG_FUNCTION(type, name, args, attributes) attributes type name args\n#endif\n\n#ifndef PNG_EXPORT_TYPE\n#  define PNG_EXPORT_TYPE(type) PNG_IMPEXP type\n#endif\n\n   /* The ordinal value is only relevant when preprocessing png.h for symbol\n    * table entries, so we discard it here.  See the .dfn files in the\n    * scripts directory.\n    */\n#ifndef PNG_EXPORTA\n\n#  define PNG_EXPORTA(ordinal, type, name, args, attributes)\\\n      PNG_FUNCTION(PNG_EXPORT_TYPE(type),(PNGAPI name),PNGARG(args), \\\n        extern attributes)\n#endif\n\n/* ANSI-C (C90) does not permit a macro to be invoked with an empty argument,\n * so make something non-empty to satisfy the requirement:\n */\n#define PNG_EMPTY /*empty list*/\n\n#define PNG_EXPORT(ordinal, type, name, args)\\\n   PNG_EXPORTA(ordinal, type, name, args, PNG_EMPTY)\n\n/* Use PNG_REMOVED to comment out a removed interface. */\n#ifndef PNG_REMOVED\n#  define PNG_REMOVED(ordinal, type, name, args, attributes)\n#endif\n\n#ifndef PNG_CALLBACK\n#  define PNG_CALLBACK(type, name, args) type (PNGCBAPI name) PNGARG(args)\n#endif\n\n/* Support for compiler specific function attributes.  These are used\n * so that where compiler support is available incorrect use of API\n * functions in png.h will generate compiler warnings.\n *\n * Added at libpng-1.2.41.\n */\n\n#ifndef PNG_NO_PEDANTIC_WARNINGS\n#  ifndef PNG_PEDANTIC_WARNINGS_SUPPORTED\n#    define PNG_PEDANTIC_WARNINGS_SUPPORTED\n#  endif\n#endif\n\n#ifdef PNG_PEDANTIC_WARNINGS_SUPPORTED\n  /* Support for compiler specific function attributes.  These are used\n   * so that where compiler support is available, incorrect use of API\n   * functions in png.h will generate compiler warnings.  Added at libpng\n   * version 1.2.41.  Disabling these removes the warnings but may also produce\n   * less efficient code.\n   */\n#  if defined(__clang__)\n     /* Clang defines both __clang__ and __GNUC__. Check __clang__ first. */\n#    if !defined(PNG_USE_RESULT) && __has_attribute(__warn_unused_result__)\n#      define PNG_USE_RESULT __attribute__((__warn_unused_result__))\n#    endif\n#    if !defined(PNG_NORETURN) && __has_attribute(__noreturn__)\n#      define PNG_NORETURN __attribute__((__noreturn__))\n#    endif\n#    if !defined(PNG_ALLOCATED) && __has_attribute(__malloc__)\n#      define PNG_ALLOCATED __attribute__((__malloc__))\n#    endif\n#    if !defined(PNG_DEPRECATED) && __has_attribute(__deprecated__)\n#      define PNG_DEPRECATED __attribute__((__deprecated__))\n#    endif\n#    if !defined(PNG_PRIVATE)\n#      ifdef __has_extension\n#        if __has_extension(attribute_unavailable_with_message)\n#          define PNG_PRIVATE __attribute__((__unavailable__(\\\n             \"This function is not exported by libpng.\")))\n#        endif\n#      endif\n#    endif\n#    ifndef PNG_RESTRICT\n#      define PNG_RESTRICT __restrict\n#    endif\n\n#  elif defined(__GNUC__)\n#    ifndef PNG_USE_RESULT\n#      define PNG_USE_RESULT __attribute__((__warn_unused_result__))\n#    endif\n#    ifndef PNG_NORETURN\n#      define PNG_NORETURN   __attribute__((__noreturn__))\n#    endif\n#    if __GNUC__ >= 3\n#      ifndef PNG_ALLOCATED\n#        define PNG_ALLOCATED  __attribute__((__malloc__))\n#      endif\n#      ifndef PNG_DEPRECATED\n#        define PNG_DEPRECATED __attribute__((__deprecated__))\n#      endif\n#      ifndef PNG_PRIVATE\n#        if 0 /* Doesn't work so we use deprecated instead*/\n#          define PNG_PRIVATE \\\n            __attribute__((warning(\"This function is not exported by libpng.\")))\n#        else\n#          define PNG_PRIVATE \\\n            __attribute__((__deprecated__))\n#        endif\n#      endif\n#      if ((__GNUC__ > 3) || !defined(__GNUC_MINOR__) || (__GNUC_MINOR__ >= 1))\n#        ifndef PNG_RESTRICT\n#          define PNG_RESTRICT __restrict\n#        endif\n#      endif /* __GNUC__.__GNUC_MINOR__ > 3.0 */\n#    endif /* __GNUC__ >= 3 */\n\n#  elif defined(_MSC_VER)  && (_MSC_VER >= 1300)\n#    ifndef PNG_USE_RESULT\n#      define PNG_USE_RESULT /* not supported */\n#    endif\n#    ifndef PNG_NORETURN\n#      define PNG_NORETURN   __declspec(noreturn)\n#    endif\n#    ifndef PNG_ALLOCATED\n#      if (_MSC_VER >= 1400)\n#        define PNG_ALLOCATED __declspec(restrict)\n#      endif\n#    endif\n#    ifndef PNG_DEPRECATED\n#      define PNG_DEPRECATED __declspec(deprecated)\n#    endif\n#    ifndef PNG_PRIVATE\n#      define PNG_PRIVATE __declspec(deprecated)\n#    endif\n#    ifndef PNG_RESTRICT\n#      if (_MSC_VER >= 1400)\n#        define PNG_RESTRICT __restrict\n#      endif\n#    endif\n\n#  elif defined(__WATCOMC__)\n#    ifndef PNG_RESTRICT\n#      define PNG_RESTRICT __restrict\n#    endif\n#  endif\n#endif /* PNG_PEDANTIC_WARNINGS */\n\n#ifndef PNG_DEPRECATED\n#  define PNG_DEPRECATED  /* Use of this function is deprecated */\n#endif\n#ifndef PNG_USE_RESULT\n#  define PNG_USE_RESULT  /* The result of this function must be checked */\n#endif\n#ifndef PNG_NORETURN\n#  define PNG_NORETURN    /* This function does not return */\n#endif\n#ifndef PNG_ALLOCATED\n#  define PNG_ALLOCATED   /* The result of the function is new memory */\n#endif\n#ifndef PNG_PRIVATE\n#  define PNG_PRIVATE     /* This is a private libpng function */\n#endif\n#ifndef PNG_RESTRICT\n#  define PNG_RESTRICT    /* The C99 \"restrict\" feature */\n#endif\n\n#ifndef PNG_FP_EXPORT     /* A floating point API. */\n#  ifdef PNG_FLOATING_POINT_SUPPORTED\n#     define PNG_FP_EXPORT(ordinal, type, name, args)\\\n         PNG_EXPORT(ordinal, type, name, args);\n#  else                   /* No floating point APIs */\n#     define PNG_FP_EXPORT(ordinal, type, name, args)\n#  endif\n#endif\n#ifndef PNG_FIXED_EXPORT  /* A fixed point API. */\n#  ifdef PNG_FIXED_POINT_SUPPORTED\n#     define PNG_FIXED_EXPORT(ordinal, type, name, args)\\\n         PNG_EXPORT(ordinal, type, name, args);\n#  else                   /* No fixed point APIs */\n#     define PNG_FIXED_EXPORT(ordinal, type, name, args)\n#  endif\n#endif\n\n#ifndef PNG_BUILDING_SYMBOL_TABLE\n/* Some typedefs to get us started.  These should be safe on most of the common\n * platforms.\n *\n * png_uint_32 and png_int_32 may, currently, be larger than required to hold a\n * 32-bit value however this is not normally advisable.\n *\n * png_uint_16 and png_int_16 should always be two bytes in size - this is\n * verified at library build time.\n *\n * png_byte must always be one byte in size.\n *\n * The checks below use constants from limits.h, as defined by the ISOC90\n * standard.\n */\n#if CHAR_BIT == 8 && UCHAR_MAX == 255\n   typedef unsigned char png_byte;\n#else\n#  error \"libpng requires 8 bit bytes\"\n#endif\n\n#if INT_MIN == -32768 && INT_MAX == 32767\n   typedef int png_int_16;\n#elif SHRT_MIN == -32768 && SHRT_MAX == 32767\n   typedef short png_int_16;\n#else\n#  error \"libpng requires a signed 16 bit type\"\n#endif\n\n#if UINT_MAX == 65535\n   typedef unsigned int png_uint_16;\n#elif USHRT_MAX == 65535\n   typedef unsigned short png_uint_16;\n#else\n#  error \"libpng requires an unsigned 16 bit type\"\n#endif\n\n#if INT_MIN < -2147483646 && INT_MAX > 2147483646\n   typedef int png_int_32;\n#elif LONG_MIN < -2147483646 && LONG_MAX > 2147483646\n   typedef long int png_int_32;\n#else\n#  error \"libpng requires a signed 32 bit (or more) type\"\n#endif\n\n#if UINT_MAX > 4294967294\n   typedef unsigned int png_uint_32;\n#elif ULONG_MAX > 4294967294\n   typedef unsigned long int png_uint_32;\n#else\n#  error \"libpng requires an unsigned 32 bit (or more) type\"\n#endif\n\n/* Prior to 1.6.0 it was possible to disable the use of size_t, 1.6.0, however,\n * requires an ISOC90 compiler and relies on consistent behavior of sizeof.\n */\ntypedef size_t png_size_t;\ntypedef ptrdiff_t png_ptrdiff_t;\n\n/* libpng needs to know the maximum value of 'size_t' and this controls the\n * definition of png_alloc_size_t, below.  This maximum value of size_t limits\n * but does not control the maximum allocations the library makes - there is\n * direct application control of this through png_set_user_limits().\n */\n#ifndef PNG_SMALL_SIZE_T\n   /* Compiler specific tests for systems where size_t is known to be less than\n    * 32 bits (some of these systems may no longer work because of the lack of\n    * 'far' support; see above.)\n    */\n#  if (defined(__TURBOC__) && !defined(__FLAT__)) ||\\\n   (defined(_MSC_VER) && defined(MAXSEG_64K))\n#     define PNG_SMALL_SIZE_T\n#  endif\n#endif\n\n/* png_alloc_size_t is guaranteed to be no smaller than png_size_t, and no\n * smaller than png_uint_32.  Casts from png_size_t or png_uint_32 to\n * png_alloc_size_t are not necessary; in fact, it is recommended not to use\n * them at all so that the compiler can complain when something turns out to be\n * problematic.\n *\n * Casts in the other direction (from png_alloc_size_t to png_size_t or\n * png_uint_32) should be explicitly applied; however, we do not expect to\n * encounter practical situations that require such conversions.\n *\n * PNG_SMALL_SIZE_T must be defined if the maximum value of size_t is less than\n * 4294967295 - i.e. less than the maximum value of png_uint_32.\n */\n#ifdef PNG_SMALL_SIZE_T\n   typedef png_uint_32 png_alloc_size_t;\n#else\n   typedef png_size_t png_alloc_size_t;\n#endif\n\n/* Prior to 1.6.0 libpng offered limited support for Microsoft C compiler\n * implementations of Intel CPU specific support of user-mode segmented address\n * spaces, where 16-bit pointers address more than 65536 bytes of memory using\n * separate 'segment' registers.  The implementation requires two different\n * types of pointer (only one of which includes the segment value.)\n *\n * If required this support is available in version 1.2 of libpng and may be\n * available in versions through 1.5, although the correctness of the code has\n * not been verified recently.\n */\n\n/* Typedef for floating-point numbers that are converted to fixed-point with a\n * multiple of 100,000, e.g., gamma\n */\ntypedef png_int_32 png_fixed_point;\n\n/* Add typedefs for pointers */\ntypedef void                  * png_voidp;\ntypedef const void            * png_const_voidp;\ntypedef png_byte              * png_bytep;\ntypedef const png_byte        * png_const_bytep;\ntypedef png_uint_32           * png_uint_32p;\ntypedef const png_uint_32     * png_const_uint_32p;\ntypedef png_int_32            * png_int_32p;\ntypedef const png_int_32      * png_const_int_32p;\ntypedef png_uint_16           * png_uint_16p;\ntypedef const png_uint_16     * png_const_uint_16p;\ntypedef png_int_16            * png_int_16p;\ntypedef const png_int_16      * png_const_int_16p;\ntypedef char                  * png_charp;\ntypedef const char            * png_const_charp;\ntypedef png_fixed_point       * png_fixed_point_p;\ntypedef const png_fixed_point * png_const_fixed_point_p;\ntypedef png_size_t            * png_size_tp;\ntypedef const png_size_t      * png_const_size_tp;\n\n#ifdef PNG_STDIO_SUPPORTED\ntypedef FILE            * png_FILE_p;\n#endif\n\n#ifdef PNG_FLOATING_POINT_SUPPORTED\ntypedef double       * png_doublep;\ntypedef const double * png_const_doublep;\n#endif\n\n/* Pointers to pointers; i.e. arrays */\ntypedef png_byte        * * png_bytepp;\ntypedef png_uint_32     * * png_uint_32pp;\ntypedef png_int_32      * * png_int_32pp;\ntypedef png_uint_16     * * png_uint_16pp;\ntypedef png_int_16      * * png_int_16pp;\ntypedef const char      * * png_const_charpp;\ntypedef char            * * png_charpp;\ntypedef png_fixed_point * * png_fixed_point_pp;\n#ifdef PNG_FLOATING_POINT_SUPPORTED\ntypedef double          * * png_doublepp;\n#endif\n\n/* Pointers to pointers to pointers; i.e., pointer to array */\ntypedef char            * * * png_charppp;\n\n#endif /* PNG_BUILDING_SYMBOL_TABLE */\n\n#endif /* PNGCONF_H */\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/png/pngdebug.h",
    "content": "\n/* pngdebug.h - Debugging macros for libpng, also used in pngtest.c\n *\n * Copyright (c) 1998-2013 Glenn Randers-Pehrson\n * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)\n * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)\n *\n * Last changed in libpng 1.6.8 [December 19, 2013]\n *\n * This code is released under the libpng license.\n * For conditions of distribution and use, see the disclaimer\n * and license in png.h\n */\n\n/* Define PNG_DEBUG at compile time for debugging information.  Higher\n * numbers for PNG_DEBUG mean more debugging information.  This has\n * only been added since version 0.95 so it is not implemented throughout\n * libpng yet, but more support will be added as needed.\n *\n * png_debug[1-2]?(level, message ,arg{0-2})\n *   Expands to a statement (either a simple expression or a compound\n *   do..while(0) statement) that outputs a message with parameter\n *   substitution if PNG_DEBUG is defined to 2 or more.  If PNG_DEBUG\n *   is undefined, 0 or 1 every png_debug expands to a simple expression\n *   (actually ((void)0)).\n *\n *   level: level of detail of message, starting at 0.  A level 'n'\n *          message is preceded by 'n' 3-space indentations (not implemented\n *          on Microsoft compilers unless PNG_DEBUG_FILE is also\n *          defined, to allow debug DLL compilation with no standard IO).\n *   message: a printf(3) style text string.  A trailing '\\n' is added\n *            to the message.\n *   arg: 0 to 2 arguments for printf(3) style substitution in message.\n */\n#ifndef PNGDEBUG_H\n#define PNGDEBUG_H\n/* These settings control the formatting of messages in png.c and pngerror.c */\n/* Moved to pngdebug.h at 1.5.0 */\n#  ifndef PNG_LITERAL_SHARP\n#    define PNG_LITERAL_SHARP 0x23\n#  endif\n#  ifndef PNG_LITERAL_LEFT_SQUARE_BRACKET\n#    define PNG_LITERAL_LEFT_SQUARE_BRACKET 0x5b\n#  endif\n#  ifndef PNG_LITERAL_RIGHT_SQUARE_BRACKET\n#    define PNG_LITERAL_RIGHT_SQUARE_BRACKET 0x5d\n#  endif\n#  ifndef PNG_STRING_NEWLINE\n#    define PNG_STRING_NEWLINE \"\\n\"\n#  endif\n\n#ifdef PNG_DEBUG\n#  if (PNG_DEBUG > 0)\n#    if !defined(PNG_DEBUG_FILE) && defined(_MSC_VER)\n#      include <crtdbg.h>\n#      if (PNG_DEBUG > 1)\n#        ifndef _DEBUG\n#          define _DEBUG\n#        endif\n#        ifndef png_debug\n#          define png_debug(l,m)  _RPT0(_CRT_WARN,m PNG_STRING_NEWLINE)\n#        endif\n#        ifndef png_debug1\n#          define png_debug1(l,m,p1)  _RPT1(_CRT_WARN,m PNG_STRING_NEWLINE,p1)\n#        endif\n#        ifndef png_debug2\n#          define png_debug2(l,m,p1,p2) \\\n             _RPT2(_CRT_WARN,m PNG_STRING_NEWLINE,p1,p2)\n#        endif\n#      endif\n#    else /* PNG_DEBUG_FILE || !_MSC_VER */\n#      ifndef PNG_STDIO_SUPPORTED\n#        include <stdio.h> /* not included yet */\n#      endif\n#      ifndef PNG_DEBUG_FILE\n#        define PNG_DEBUG_FILE stderr\n#      endif /* PNG_DEBUG_FILE */\n\n#      if (PNG_DEBUG > 1)\n#        ifdef __STDC__\n#          ifndef png_debug\n#            define png_debug(l,m) \\\n       do { \\\n       int num_tabs=l; \\\n       fprintf(PNG_DEBUG_FILE,\"%s\" m PNG_STRING_NEWLINE,(num_tabs==1 ? \"   \" : \\\n         (num_tabs==2 ? \"      \" : (num_tabs>2 ? \"         \" : \"\")))); \\\n       } while (0)\n#          endif\n#          ifndef png_debug1\n#            define png_debug1(l,m,p1) \\\n       do { \\\n       int num_tabs=l; \\\n       fprintf(PNG_DEBUG_FILE,\"%s\" m PNG_STRING_NEWLINE,(num_tabs==1 ? \"   \" : \\\n         (num_tabs==2 ? \"      \" : (num_tabs>2 ? \"         \" : \"\"))),p1); \\\n       } while (0)\n#          endif\n#          ifndef png_debug2\n#            define png_debug2(l,m,p1,p2) \\\n       do { \\\n       int num_tabs=l; \\\n       fprintf(PNG_DEBUG_FILE,\"%s\" m PNG_STRING_NEWLINE,(num_tabs==1 ? \"   \" : \\\n         (num_tabs==2 ? \"      \" : (num_tabs>2 ? \"         \" : \"\"))),p1,p2);\\\n       } while (0)\n#          endif\n#        else /* __STDC __ */\n#          ifndef png_debug\n#            define png_debug(l,m) \\\n       do { \\\n       int num_tabs=l; \\\n       char format[256]; \\\n       snprintf(format,256,\"%s%s%s\",(num_tabs==1 ? \"\\t\" : \\\n         (num_tabs==2 ? \"\\t\\t\":(num_tabs>2 ? \"\\t\\t\\t\":\"\"))), \\\n         m,PNG_STRING_NEWLINE); \\\n       fprintf(PNG_DEBUG_FILE,format); \\\n       } while (0)\n#          endif\n#          ifndef png_debug1\n#            define png_debug1(l,m,p1) \\\n       do { \\\n       int num_tabs=l; \\\n       char format[256]; \\\n       snprintf(format,256,\"%s%s%s\",(num_tabs==1 ? \"\\t\" : \\\n         (num_tabs==2 ? \"\\t\\t\":(num_tabs>2 ? \"\\t\\t\\t\":\"\"))), \\\n         m,PNG_STRING_NEWLINE); \\\n       fprintf(PNG_DEBUG_FILE,format,p1); \\\n       } while (0)\n#          endif\n#          ifndef png_debug2\n#            define png_debug2(l,m,p1,p2) \\\n       do { \\\n       int num_tabs=l; \\\n       char format[256]; \\\n       snprintf(format,256,\"%s%s%s\",(num_tabs==1 ? \"\\t\" : \\\n         (num_tabs==2 ? \"\\t\\t\":(num_tabs>2 ? \"\\t\\t\\t\":\"\"))), \\\n         m,PNG_STRING_NEWLINE); \\\n       fprintf(PNG_DEBUG_FILE,format,p1,p2); \\\n       } while (0)\n#          endif\n#        endif /* __STDC __ */\n#      endif /* (PNG_DEBUG > 1) */\n\n#    endif /* _MSC_VER */\n#  endif /* (PNG_DEBUG > 0) */\n#endif /* PNG_DEBUG */\n#ifndef png_debug\n#  define png_debug(l, m) ((void)0)\n#endif\n#ifndef png_debug1\n#  define png_debug1(l, m, p1) ((void)0)\n#endif\n#ifndef png_debug2\n#  define png_debug2(l, m, p1, p2) ((void)0)\n#endif\n#endif /* PNGDEBUG_H */\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/png/pnginfo.h",
    "content": "\n/* pnginfo.h - header file for PNG reference library\n *\n * Copyright (c) 1998-2013 Glenn Randers-Pehrson\n * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)\n * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)\n *\n * Last changed in libpng 1.6.1 [March 28, 2013]\n *\n * This code is released under the libpng license.\n * For conditions of distribution and use, see the disclaimer\n * and license in png.h\n */\n\n /* png_info is a structure that holds the information in a PNG file so\n * that the application can find out the characteristics of the image.\n * If you are reading the file, this structure will tell you what is\n * in the PNG file.  If you are writing the file, fill in the information\n * you want to put into the PNG file, using png_set_*() functions, then\n * call png_write_info().\n *\n * The names chosen should be very close to the PNG specification, so\n * consult that document for information about the meaning of each field.\n *\n * With libpng < 0.95, it was only possible to directly set and read the\n * the values in the png_info_struct, which meant that the contents and\n * order of the values had to remain fixed.  With libpng 0.95 and later,\n * however, there are now functions that abstract the contents of\n * png_info_struct from the application, so this makes it easier to use\n * libpng with dynamic libraries, and even makes it possible to use\n * libraries that don't have all of the libpng ancillary chunk-handing\n * functionality.  In libpng-1.5.0 this was moved into a separate private\n * file that is not visible to applications.\n *\n * The following members may have allocated storage attached that should be\n * cleaned up before the structure is discarded: palette, trans, text,\n * pcal_purpose, pcal_units, pcal_params, hist, iccp_name, iccp_profile,\n * splt_palettes, scal_unit, row_pointers, and unknowns.   By default, these\n * are automatically freed when the info structure is deallocated, if they were\n * allocated internally by libpng.  This behavior can be changed by means\n * of the png_data_freer() function.\n *\n * More allocation details: all the chunk-reading functions that\n * change these members go through the corresponding png_set_*\n * functions.  A function to clear these members is available: see\n * png_free_data().  The png_set_* functions do not depend on being\n * able to point info structure members to any of the storage they are\n * passed (they make their own copies), EXCEPT that the png_set_text\n * functions use the same storage passed to them in the text_ptr or\n * itxt_ptr structure argument, and the png_set_rows and png_set_unknowns\n * functions do not make their own copies.\n */\n#ifndef PNGINFO_H\n#define PNGINFO_H\n\nstruct png_info_def\n{\n   /* The following are necessary for every PNG file */\n   png_uint_32 width;  /* width of image in pixels (from IHDR) */\n   png_uint_32 height; /* height of image in pixels (from IHDR) */\n   png_uint_32 valid;  /* valid chunk data (see PNG_INFO_ below) */\n   png_size_t rowbytes; /* bytes needed to hold an untransformed row */\n   png_colorp palette;      /* array of color values (valid & PNG_INFO_PLTE) */\n   png_uint_16 num_palette; /* number of color entries in \"palette\" (PLTE) */\n   png_uint_16 num_trans;   /* number of transparent palette color (tRNS) */\n   png_byte bit_depth;      /* 1, 2, 4, 8, or 16 bits/channel (from IHDR) */\n   png_byte color_type;     /* see PNG_COLOR_TYPE_ below (from IHDR) */\n   /* The following three should have been named *_method not *_type */\n   png_byte compression_type; /* must be PNG_COMPRESSION_TYPE_BASE (IHDR) */\n   png_byte filter_type;    /* must be PNG_FILTER_TYPE_BASE (from IHDR) */\n   png_byte interlace_type; /* One of PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */\n\n   /* The following are set by png_set_IHDR, called from the application on\n    * write, but the are never actually used by the write code.\n    */\n   png_byte channels;       /* number of data channels per pixel (1, 2, 3, 4) */\n   png_byte pixel_depth;    /* number of bits per pixel */\n   png_byte spare_byte;     /* to align the data, and for future use */\n\n#ifdef PNG_READ_SUPPORTED\n   /* This is never set during write */\n   png_byte signature[8];   /* magic bytes read by libpng from start of file */\n#endif\n\n   /* The rest of the data is optional.  If you are reading, check the\n    * valid field to see if the information in these are valid.  If you\n    * are writing, set the valid field to those chunks you want written,\n    * and initialize the appropriate fields below.\n    */\n\n#if defined(PNG_COLORSPACE_SUPPORTED) || defined(PNG_GAMMA_SUPPORTED)\n   /* png_colorspace only contains 'flags' if neither GAMMA or COLORSPACE are\n    * defined.  When COLORSPACE is switched on all the colorspace-defining\n    * chunks should be enabled, when GAMMA is switched on all the gamma-defining\n    * chunks should be enabled.  If this is not done it becomes possible to read\n    * inconsistent PNG files and assign a probably incorrect interpretation to\n    * the information.  (In other words, by carefully choosing which chunks to\n    * recognize the system configuration can select an interpretation for PNG\n    * files containing ambiguous data and this will result in inconsistent\n    * behavior between different libpng builds!)\n    */\n   png_colorspace colorspace;\n#endif\n\n#ifdef PNG_iCCP_SUPPORTED\n   /* iCCP chunk data. */\n   png_charp iccp_name;     /* profile name */\n   png_bytep iccp_profile;  /* International Color Consortium profile data */\n   png_uint_32 iccp_proflen;  /* ICC profile data length */\n#endif\n\n#ifdef PNG_TEXT_SUPPORTED\n   /* The tEXt, and zTXt chunks contain human-readable textual data in\n    * uncompressed, compressed, and optionally compressed forms, respectively.\n    * The data in \"text\" is an array of pointers to uncompressed,\n    * null-terminated C strings. Each chunk has a keyword that describes the\n    * textual data contained in that chunk.  Keywords are not required to be\n    * unique, and the text string may be empty.  Any number of text chunks may\n    * be in an image.\n    */\n   int num_text; /* number of comments read or comments to write */\n   int max_text; /* current size of text array */\n   png_textp text; /* array of comments read or comments to write */\n#endif /* PNG_TEXT_SUPPORTED */\n\n#ifdef PNG_tIME_SUPPORTED\n   /* The tIME chunk holds the last time the displayed image data was\n    * modified.  See the png_time struct for the contents of this struct.\n    */\n   png_time mod_time;\n#endif\n\n#ifdef PNG_sBIT_SUPPORTED\n   /* The sBIT chunk specifies the number of significant high-order bits\n    * in the pixel data.  Values are in the range [1, bit_depth], and are\n    * only specified for the channels in the pixel data.  The contents of\n    * the low-order bits is not specified.  Data is valid if\n    * (valid & PNG_INFO_sBIT) is non-zero.\n    */\n   png_color_8 sig_bit; /* significant bits in color channels */\n#endif\n\n#if defined(PNG_tRNS_SUPPORTED) || defined(PNG_READ_EXPAND_SUPPORTED) || \\\ndefined(PNG_READ_BACKGROUND_SUPPORTED)\n   /* The tRNS chunk supplies transparency data for paletted images and\n    * other image types that don't need a full alpha channel.  There are\n    * \"num_trans\" transparency values for a paletted image, stored in the\n    * same order as the palette colors, starting from index 0.  Values\n    * for the data are in the range [0, 255], ranging from fully transparent\n    * to fully opaque, respectively.  For non-paletted images, there is a\n    * single color specified that should be treated as fully transparent.\n    * Data is valid if (valid & PNG_INFO_tRNS) is non-zero.\n    */\n   png_bytep trans_alpha;    /* alpha values for paletted image */\n   png_color_16 trans_color; /* transparent color for non-palette image */\n#endif\n\n#if defined(PNG_bKGD_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)\n   /* The bKGD chunk gives the suggested image background color if the\n    * display program does not have its own background color and the image\n    * is needs to composited onto a background before display.  The colors\n    * in \"background\" are normally in the same color space/depth as the\n    * pixel data.  Data is valid if (valid & PNG_INFO_bKGD) is non-zero.\n    */\n   png_color_16 background;\n#endif\n\n#ifdef PNG_oFFs_SUPPORTED\n   /* The oFFs chunk gives the offset in \"offset_unit_type\" units rightwards\n    * and downwards from the top-left corner of the display, page, or other\n    * application-specific co-ordinate space.  See the PNG_OFFSET_ defines\n    * below for the unit types.  Valid if (valid & PNG_INFO_oFFs) non-zero.\n    */\n   png_int_32 x_offset; /* x offset on page */\n   png_int_32 y_offset; /* y offset on page */\n   png_byte offset_unit_type; /* offset units type */\n#endif\n\n#ifdef PNG_pHYs_SUPPORTED\n   /* The pHYs chunk gives the physical pixel density of the image for\n    * display or printing in \"phys_unit_type\" units (see PNG_RESOLUTION_\n    * defines below).  Data is valid if (valid & PNG_INFO_pHYs) is non-zero.\n    */\n   png_uint_32 x_pixels_per_unit; /* horizontal pixel density */\n   png_uint_32 y_pixels_per_unit; /* vertical pixel density */\n   png_byte phys_unit_type; /* resolution type (see PNG_RESOLUTION_ below) */\n#endif\n\n#ifdef PNG_hIST_SUPPORTED\n   /* The hIST chunk contains the relative frequency or importance of the\n    * various palette entries, so that a viewer can intelligently select a\n    * reduced-color palette, if required.  Data is an array of \"num_palette\"\n    * values in the range [0,65535]. Data valid if (valid & PNG_INFO_hIST)\n    * is non-zero.\n    */\n   png_uint_16p hist;\n#endif\n\n#ifdef PNG_pCAL_SUPPORTED\n   /* The pCAL chunk describes a transformation between the stored pixel\n    * values and original physical data values used to create the image.\n    * The integer range [0, 2^bit_depth - 1] maps to the floating-point\n    * range given by [pcal_X0, pcal_X1], and are further transformed by a\n    * (possibly non-linear) transformation function given by \"pcal_type\"\n    * and \"pcal_params\" into \"pcal_units\".  Please see the PNG_EQUATION_\n    * defines below, and the PNG-Group's PNG extensions document for a\n    * complete description of the transformations and how they should be\n    * implemented, and for a description of the ASCII parameter strings.\n    * Data values are valid if (valid & PNG_INFO_pCAL) non-zero.\n    */\n   png_charp pcal_purpose;  /* pCAL chunk description string */\n   png_int_32 pcal_X0;      /* minimum value */\n   png_int_32 pcal_X1;      /* maximum value */\n   png_charp pcal_units;    /* Latin-1 string giving physical units */\n   png_charpp pcal_params;  /* ASCII strings containing parameter values */\n   png_byte pcal_type;      /* equation type (see PNG_EQUATION_ below) */\n   png_byte pcal_nparams;   /* number of parameters given in pcal_params */\n#endif\n\n/* New members added in libpng-1.0.6 */\n   png_uint_32 free_me;     /* flags items libpng is responsible for freeing */\n\n#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED\n   /* Storage for unknown chunks that the library doesn't recognize. */\n   png_unknown_chunkp unknown_chunks;\n\n   /* The type of this field is limited by the type of \n    * png_struct::user_chunk_cache_max, else overflow can occur.\n    */\n   int                unknown_chunks_num;\n#endif\n\n#ifdef PNG_sPLT_SUPPORTED\n   /* Data on sPLT chunks (there may be more than one). */\n   png_sPLT_tp splt_palettes;\n   int         splt_palettes_num; /* Match type returned by png_get API */\n#endif\n\n#ifdef PNG_sCAL_SUPPORTED\n   /* The sCAL chunk describes the actual physical dimensions of the\n    * subject matter of the graphic.  The chunk contains a unit specification\n    * a byte value, and two ASCII strings representing floating-point\n    * values.  The values are width and height corresponsing to one pixel\n    * in the image.  Data values are valid if (valid & PNG_INFO_sCAL) is\n    * non-zero.\n    */\n   png_byte scal_unit;         /* unit of physical scale */\n   png_charp scal_s_width;     /* string containing height */\n   png_charp scal_s_height;    /* string containing width */\n#endif\n\n#ifdef PNG_INFO_IMAGE_SUPPORTED\n   /* Memory has been allocated if (valid & PNG_ALLOCATED_INFO_ROWS)\n      non-zero */\n   /* Data valid if (valid & PNG_INFO_IDAT) non-zero */\n   png_bytepp row_pointers;        /* the image bits */\n#endif\n\n};\n#endif /* PNGINFO_H */\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/png/pnglibconf.h",
    "content": "/* libpng 1.6.10 STANDARD API DEFINITION */\n\n/* pnglibconf.h - library build configuration */\n\n/* Libpng version 1.6.10 - March 6, 2014 */\n\n/* Copyright (c) 1998-2013 Glenn Randers-Pehrson */\n\n/* This code is released under the libpng license. */\n/* For conditions of distribution and use, see the disclaimer */\n/* and license in png.h */\n\n/* pnglibconf.h */\n/* Machine generated file: DO NOT EDIT */\n/* Derived from: scripts/pnglibconf.dfa */\n#ifndef PNGLCONF_H\n#define PNGLCONF_H\n/* options */\n#define PNG_16BIT_SUPPORTED\n#define PNG_ALIGNED_MEMORY_SUPPORTED\n/*#undef PNG_ARM_NEON_API_SUPPORTED*/\n/*#undef PNG_ARM_NEON_CHECK_SUPPORTED*/\n#define PNG_BENIGN_ERRORS_SUPPORTED\n#define PNG_BENIGN_READ_ERRORS_SUPPORTED\n/*#undef PNG_BENIGN_WRITE_ERRORS_SUPPORTED*/\n#define PNG_BUILD_GRAYSCALE_PALETTE_SUPPORTED\n#define PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED\n#define PNG_COLORSPACE_SUPPORTED\n#define PNG_CONSOLE_IO_SUPPORTED\n#define PNG_CONVERT_tIME_SUPPORTED\n#define PNG_EASY_ACCESS_SUPPORTED\n/*#undef PNG_ERROR_NUMBERS_SUPPORTED*/\n#define PNG_ERROR_TEXT_SUPPORTED\n#define PNG_FIXED_POINT_SUPPORTED\n#define PNG_FLOATING_ARITHMETIC_SUPPORTED\n#define PNG_FLOATING_POINT_SUPPORTED\n#define PNG_FORMAT_AFIRST_SUPPORTED\n#define PNG_FORMAT_BGR_SUPPORTED\n#define PNG_GAMMA_SUPPORTED\n#define PNG_GET_PALETTE_MAX_SUPPORTED\n#define PNG_HANDLE_AS_UNKNOWN_SUPPORTED\n#define PNG_INCH_CONVERSIONS_SUPPORTED\n#define PNG_INFO_IMAGE_SUPPORTED\n#define PNG_IO_STATE_SUPPORTED\n#define PNG_MNG_FEATURES_SUPPORTED\n#define PNG_POINTER_INDEXING_SUPPORTED\n#define PNG_PROGRESSIVE_READ_SUPPORTED\n#define PNG_READ_16BIT_SUPPORTED\n#define PNG_READ_ALPHA_MODE_SUPPORTED\n#define PNG_READ_ANCILLARY_CHUNKS_SUPPORTED\n#define PNG_READ_BACKGROUND_SUPPORTED\n#define PNG_READ_BGR_SUPPORTED\n#define PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED\n#define PNG_READ_COMPOSITE_NODIV_SUPPORTED\n#define PNG_READ_COMPRESSED_TEXT_SUPPORTED\n#define PNG_READ_EXPAND_16_SUPPORTED\n#define PNG_READ_EXPAND_SUPPORTED\n#define PNG_READ_FILLER_SUPPORTED\n#define PNG_READ_GAMMA_SUPPORTED\n#define PNG_READ_GET_PALETTE_MAX_SUPPORTED\n#define PNG_READ_GRAY_TO_RGB_SUPPORTED\n#define PNG_READ_INTERLACING_SUPPORTED\n#define PNG_READ_INT_FUNCTIONS_SUPPORTED\n#define PNG_READ_INVERT_ALPHA_SUPPORTED\n#define PNG_READ_INVERT_SUPPORTED\n#define PNG_READ_OPT_PLTE_SUPPORTED\n#define PNG_READ_PACKSWAP_SUPPORTED\n#define PNG_READ_PACK_SUPPORTED\n#define PNG_READ_QUANTIZE_SUPPORTED\n#define PNG_READ_RGB_TO_GRAY_SUPPORTED\n#define PNG_READ_SCALE_16_TO_8_SUPPORTED\n#define PNG_READ_SHIFT_SUPPORTED\n#define PNG_READ_STRIP_16_TO_8_SUPPORTED\n#define PNG_READ_STRIP_ALPHA_SUPPORTED\n#define PNG_READ_SUPPORTED\n#define PNG_READ_SWAP_ALPHA_SUPPORTED\n#define PNG_READ_SWAP_SUPPORTED\n#define PNG_READ_TEXT_SUPPORTED\n#define PNG_READ_TRANSFORMS_SUPPORTED\n#define PNG_READ_UNKNOWN_CHUNKS_SUPPORTED\n#define PNG_READ_USER_CHUNKS_SUPPORTED\n#define PNG_READ_USER_TRANSFORM_SUPPORTED\n#define PNG_READ_bKGD_SUPPORTED\n#define PNG_READ_cHRM_SUPPORTED\n#define PNG_READ_gAMA_SUPPORTED\n#define PNG_READ_hIST_SUPPORTED\n#define PNG_READ_iCCP_SUPPORTED\n#define PNG_READ_iTXt_SUPPORTED\n#define PNG_READ_oFFs_SUPPORTED\n#define PNG_READ_pCAL_SUPPORTED\n#define PNG_READ_pHYs_SUPPORTED\n#define PNG_READ_sBIT_SUPPORTED\n#define PNG_READ_sCAL_SUPPORTED\n#define PNG_READ_sPLT_SUPPORTED\n#define PNG_READ_sRGB_SUPPORTED\n#define PNG_READ_tEXt_SUPPORTED\n#define PNG_READ_tIME_SUPPORTED\n#define PNG_READ_tRNS_SUPPORTED\n#define PNG_READ_zTXt_SUPPORTED\n/*#undef PNG_SAFE_LIMITS_SUPPORTED*/\n#define PNG_SAVE_INT_32_SUPPORTED\n#define PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED\n#define PNG_SEQUENTIAL_READ_SUPPORTED\n#define PNG_SETJMP_SUPPORTED\n#define PNG_SET_CHUNK_CACHE_LIMIT_SUPPORTED\n#define PNG_SET_CHUNK_MALLOC_LIMIT_SUPPORTED\n#define PNG_SET_OPTION_SUPPORTED\n#define PNG_SET_UNKNOWN_CHUNKS_SUPPORTED\n#define PNG_SET_USER_LIMITS_SUPPORTED\n#define PNG_SIMPLIFIED_READ_AFIRST_SUPPORTED\n#define PNG_SIMPLIFIED_READ_BGR_SUPPORTED\n#define PNG_SIMPLIFIED_READ_SUPPORTED\n#define PNG_SIMPLIFIED_WRITE_AFIRST_SUPPORTED\n#define PNG_SIMPLIFIED_WRITE_BGR_SUPPORTED\n#define PNG_SIMPLIFIED_WRITE_SUPPORTED\n#define PNG_STDIO_SUPPORTED\n#define PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED\n#define PNG_TEXT_SUPPORTED\n#define PNG_TIME_RFC1123_SUPPORTED\n#define PNG_UNKNOWN_CHUNKS_SUPPORTED\n#define PNG_USER_CHUNKS_SUPPORTED\n#define PNG_USER_LIMITS_SUPPORTED\n#define PNG_USER_MEM_SUPPORTED\n#define PNG_USER_TRANSFORM_INFO_SUPPORTED\n#define PNG_USER_TRANSFORM_PTR_SUPPORTED\n#define PNG_WARNINGS_SUPPORTED\n#define PNG_WRITE_16BIT_SUPPORTED\n#define PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED\n#define PNG_WRITE_BGR_SUPPORTED\n#define PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED\n#define PNG_WRITE_COMPRESSED_TEXT_SUPPORTED\n#define PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED\n#define PNG_WRITE_FILLER_SUPPORTED\n#define PNG_WRITE_FILTER_SUPPORTED\n#define PNG_WRITE_FLUSH_SUPPORTED\n#define PNG_WRITE_GET_PALETTE_MAX_SUPPORTED\n#define PNG_WRITE_INTERLACING_SUPPORTED\n#define PNG_WRITE_INT_FUNCTIONS_SUPPORTED\n#define PNG_WRITE_INVERT_ALPHA_SUPPORTED\n#define PNG_WRITE_INVERT_SUPPORTED\n#define PNG_WRITE_OPTIMIZE_CMF_SUPPORTED\n#define PNG_WRITE_PACKSWAP_SUPPORTED\n#define PNG_WRITE_PACK_SUPPORTED\n#define PNG_WRITE_SHIFT_SUPPORTED\n#define PNG_WRITE_SUPPORTED\n#define PNG_WRITE_SWAP_ALPHA_SUPPORTED\n#define PNG_WRITE_SWAP_SUPPORTED\n#define PNG_WRITE_TEXT_SUPPORTED\n#define PNG_WRITE_TRANSFORMS_SUPPORTED\n#define PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED\n#define PNG_WRITE_USER_TRANSFORM_SUPPORTED\n#define PNG_WRITE_WEIGHTED_FILTER_SUPPORTED\n#define PNG_WRITE_bKGD_SUPPORTED\n#define PNG_WRITE_cHRM_SUPPORTED\n#define PNG_WRITE_gAMA_SUPPORTED\n#define PNG_WRITE_hIST_SUPPORTED\n#define PNG_WRITE_iCCP_SUPPORTED\n#define PNG_WRITE_iTXt_SUPPORTED\n#define PNG_WRITE_oFFs_SUPPORTED\n#define PNG_WRITE_pCAL_SUPPORTED\n#define PNG_WRITE_pHYs_SUPPORTED\n#define PNG_WRITE_sBIT_SUPPORTED\n#define PNG_WRITE_sCAL_SUPPORTED\n#define PNG_WRITE_sPLT_SUPPORTED\n#define PNG_WRITE_sRGB_SUPPORTED\n#define PNG_WRITE_tEXt_SUPPORTED\n#define PNG_WRITE_tIME_SUPPORTED\n#define PNG_WRITE_tRNS_SUPPORTED\n#define PNG_WRITE_zTXt_SUPPORTED\n#define PNG_bKGD_SUPPORTED\n#define PNG_cHRM_SUPPORTED\n#define PNG_gAMA_SUPPORTED\n#define PNG_hIST_SUPPORTED\n#define PNG_iCCP_SUPPORTED\n#define PNG_iTXt_SUPPORTED\n#define PNG_oFFs_SUPPORTED\n#define PNG_pCAL_SUPPORTED\n#define PNG_pHYs_SUPPORTED\n#define PNG_sBIT_SUPPORTED\n#define PNG_sCAL_SUPPORTED\n#define PNG_sPLT_SUPPORTED\n#define PNG_sRGB_SUPPORTED\n#define PNG_tEXt_SUPPORTED\n#define PNG_tIME_SUPPORTED\n#define PNG_tRNS_SUPPORTED\n#define PNG_zTXt_SUPPORTED\n/* end of options */\n/* settings */\n#define PNG_API_RULE 0\n#define PNG_CALLOC_SUPPORTED\n#define PNG_COST_SHIFT 3\n#define PNG_DEFAULT_READ_MACROS 1\n#define PNG_GAMMA_THRESHOLD_FIXED 5000\n#define PNG_IDAT_READ_SIZE PNG_ZBUF_SIZE\n#define PNG_INFLATE_BUF_SIZE 1024\n#define PNG_MAX_GAMMA_8 11\n#define PNG_QUANTIZE_BLUE_BITS 5\n#define PNG_QUANTIZE_GREEN_BITS 5\n#define PNG_QUANTIZE_RED_BITS 5\n#define PNG_TEXT_Z_DEFAULT_COMPRESSION (-1)\n#define PNG_TEXT_Z_DEFAULT_STRATEGY 0\n#define PNG_WEIGHT_SHIFT 8\n#define PNG_ZBUF_SIZE 8192\n#define PNG_ZLIB_VERNUM 0 /* unknown */\n#define PNG_Z_DEFAULT_COMPRESSION (-1)\n#define PNG_Z_DEFAULT_NOFILTER_STRATEGY 0\n#define PNG_Z_DEFAULT_STRATEGY 1\n#define PNG_sCAL_PRECISION 5\n#define PNG_sRGB_PROFILE_CHECKS 2\n/* end of settings */\n#endif /* PNGLCONF_H */\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/png/pngpriv.h",
    "content": "\n/* pngpriv.h - private declarations for use inside libpng\n *\n * For conditions of distribution and use, see copyright notice in png.h\n * Copyright (c) 1998-2014 Glenn Randers-Pehrson\n * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)\n * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)\n *\n * Last changed in libpng 1.6.10 [March 6, 2014]\n *\n * This code is released under the libpng license.\n * For conditions of distribution and use, see the disclaimer\n * and license in png.h\n */\n\n/* The symbols declared in this file (including the functions declared\n * as extern) are PRIVATE.  They are not part of the libpng public\n * interface, and are not recommended for use by regular applications.\n * Some of them may become public in the future; others may stay private,\n * change in an incompatible way, or even disappear.\n * Although the libpng users are not forbidden to include this header,\n * they should be well aware of the issues that may arise from doing so.\n */\n\n#ifndef PNGPRIV_H\n#define PNGPRIV_H\n\n/* Feature Test Macros.  The following are defined here to ensure that correctly\n * implemented libraries reveal the APIs libpng needs to build and hide those\n * that are not needed and potentially damaging to the compilation.\n *\n * Feature Test Macros must be defined before any system header is included (see\n * POSIX 1003.1 2.8.2 \"POSIX Symbols.\"\n *\n * These macros only have an effect if the operating system supports either\n * POSIX 1003.1 or C99, or both.  On other operating systems (particularly\n * Windows/Visual Studio) there is no effect; the OS specific tests below are\n * still required (as of 2011-05-02.)\n */\n#define _POSIX_SOURCE 1 /* Just the POSIX 1003.1 and C89 APIs */\n\n#ifndef PNG_VERSION_INFO_ONLY\n/* Standard library headers not required by png.h: */\n#  include <stdlib.h>\n#  include <string.h>\n#endif\n\n#define PNGLIB_BUILD /*libpng is being built, not used*/\n\n/* If HAVE_CONFIG_H is defined during the build then the build system must\n * provide an appropriate \"config.h\" file on the include path.  The header file\n * must provide definitions as required below (search for \"HAVE_CONFIG_H\");\n * see configure.ac for more details of the requirements.  The macro\n * \"PNG_NO_CONFIG_H\" is provided for maintainers to test for dependencies on\n * 'configure'; define this macro to prevent the configure build including the\n * configure generated config.h.  Libpng is expected to compile without *any*\n * special build system support on a reasonably ANSI-C compliant system.\n */\n#if defined(HAVE_CONFIG_H) && !defined(PNG_NO_CONFIG_H)\n#  include <config.h>\n\n   /* Pick up the definition of 'restrict' from config.h if it was read: */\n#  define PNG_RESTRICT restrict\n#endif\n\n/* To support symbol prefixing it is necessary to know *before* including png.h\n * whether the fixed point (and maybe other) APIs are exported, because if they\n * are not internal definitions may be required.  This is handled below just\n * before png.h is included, but load the configuration now if it is available.\n */\n#ifndef PNGLCONF_H\n#  include \"pnglibconf.h\"\n#endif\n\n/* Local renames may change non-exported API functions from png.h */\n#if defined(PNG_PREFIX) && !defined(PNGPREFIX_H)\n#  include \"pngprefix.h\"\n#endif\n\n#ifdef PNG_USER_CONFIG\n#  include \"pngusr.h\"\n   /* These should have been defined in pngusr.h */\n#  ifndef PNG_USER_PRIVATEBUILD\n#    define PNG_USER_PRIVATEBUILD \"Custom libpng build\"\n#  endif\n#  ifndef PNG_USER_DLLFNAME_POSTFIX\n#    define PNG_USER_DLLFNAME_POSTFIX \"Cb\"\n#  endif\n#endif\n\n/* Compile time options.\n * =====================\n * In a multi-arch build the compiler may compile the code several times for the\n * same object module, producing different binaries for different architectures.\n * When this happens configure-time setting of the target host options cannot be\n * done and this interferes with the handling of the ARM NEON optimizations, and\n * possibly other similar optimizations.  Put additional tests here; in general\n * this is needed when the same option can be changed at both compile time and\n * run time depending on the target OS (i.e. iOS vs Android.)\n *\n * NOTE: symbol prefixing does not pass $(CFLAGS) to the preprocessor, because\n * this is not possible with certain compilers (Oracle SUN OS CC), as a result\n * it is necessary to ensure that all extern functions that *might* be used\n * regardless of $(CFLAGS) get declared in this file.  The test on __ARM_NEON__\n * below is one example of this behavior because it is controlled by the\n * presence or not of -mfpu=neon on the GCC command line, it is possible to do\n * this in $(CC), e.g. \"CC=gcc -mfpu=neon\", but people who build libpng rarely\n * do this.\n */\n#ifndef PNG_ARM_NEON_OPT\n   /* ARM NEON optimizations are being controlled by the compiler settings,\n    * typically the target FPU.  If the FPU has been set to NEON (-mfpu=neon\n    * with GCC) then the compiler will define __ARM_NEON__ and we can rely\n    * unconditionally on NEON instructions not crashing, otherwise we must\n    * disable use of NEON instructions.\n    *\n    * NOTE: at present these optimizations depend on 'ALIGNED_MEMORY', so they\n    * can only be turned on automatically if that is supported too.  If\n    * PNG_ARM_NEON_OPT is set in CPPFLAGS (to >0) then arm/arm_init.c will fail\n    * to compile with an appropriate #error if ALIGNED_MEMORY has been turned\n    * off.\n    */\n#  if defined(__ARM_NEON__) && defined(PNG_ALIGNED_MEMORY_SUPPORTED)\n#     define PNG_ARM_NEON_OPT 2\n#  else\n#     define PNG_ARM_NEON_OPT 0\n#  endif\n#endif\n\n#if PNG_ARM_NEON_OPT > 0\n   /* NEON optimizations are to be at least considered by libpng, so enable the\n    * callbacks to do this.\n    */\n#  define PNG_FILTER_OPTIMIZATIONS png_init_filter_functions_neon\n\n   /* By default the 'intrinsics' code in arm/filter_neon_intrinsics.c is used\n    * if possible - if __ARM_NEON__ is set and the compiler version is not known\n    * to be broken.  This is controlled by PNG_ARM_NEON_IMPLEMENTATION which can\n    * be:\n    *\n    *    1  The intrinsics code (the default with __ARM_NEON__)\n    *    2  The hand coded assembler (the default without __ARM_NEON__)\n    *\n    * It is possible to set PNG_ARM_NEON_IMPLEMENTATION in CPPFLAGS, however\n    * this is *NOT* supported and may cease to work even after a minor revision\n    * to libpng.  It *is* valid to do this for testing purposes, e.g. speed\n    * testing or a new compiler, but the results should be communicated to the\n    * libpng implementation list for incorporation in the next minor release.\n    */\n#  ifndef PNG_ARM_NEON_IMPLEMENTATION\n#     ifdef __ARM_NEON__\n#        if defined(__clang__)\n            /* At present it is unknown by the libpng developers which versions\n             * of clang support the intrinsics, however some or perhaps all\n             * versions do not work with the assembler so this may be\n             * irrelevant, so just use the default (do nothing here.)\n             */\n#        elif defined(__GNUC__)\n            /* GCC 4.5.4 NEON support is known to be broken.  4.6.3 is known to\n             * work, so if this *is* GCC, or G++, look for a version >4.5\n             */\n#           if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 6)\n#              define PNG_ARM_NEON_IMPLEMENTATION 2\n#           endif /* no GNUC support */\n#        endif /* __GNUC__ */\n#     else /* !defined __ARM_NEON__ */\n         /* The 'intrinsics' code simply won't compile without this -mfpu=neon:\n          */\n#        define PNG_ARM_NEON_IMPLEMENTATION 2\n#     endif /* __ARM_NEON__ */\n#  endif /* !defined PNG_ARM_NEON_IMPLEMENTATION */\n\n#  ifndef PNG_ARM_NEON_IMPLEMENTATION\n      /* Use the intrinsics code by default. */\n#     define PNG_ARM_NEON_IMPLEMENTATION 1\n#  endif\n#endif /* PNG_ARM_NEON_OPT > 0 */\n\n/* Is this a build of a DLL where compilation of the object modules requires\n * different preprocessor settings to those required for a simple library?  If\n * so PNG_BUILD_DLL must be set.\n *\n * If libpng is used inside a DLL but that DLL does not export the libpng APIs\n * PNG_BUILD_DLL must not be set.  To avoid the code below kicking in build a\n * static library of libpng then link the DLL against that.\n */\n#ifndef PNG_BUILD_DLL\n#  ifdef DLL_EXPORT\n      /* This is set by libtool when files are compiled for a DLL; libtool\n       * always compiles twice, even on systems where it isn't necessary.  Set\n       * PNG_BUILD_DLL in case it is necessary:\n       */\n#     define PNG_BUILD_DLL\n#  else\n#     ifdef _WINDLL\n         /* This is set by the Microsoft Visual Studio IDE in projects that\n          * build a DLL.  It can't easily be removed from those projects (it\n          * isn't visible in the Visual Studio UI) so it is a fairly reliable\n          * indication that PNG_IMPEXP needs to be set to the DLL export\n          * attributes.\n          */\n#        define PNG_BUILD_DLL\n#     else\n#        ifdef __DLL__\n            /* This is set by the Borland C system when compiling for a DLL\n             * (as above.)\n             */\n#           define PNG_BUILD_DLL\n#        else\n            /* Add additional compiler cases here. */\n#        endif\n#     endif\n#  endif\n#endif /* Setting PNG_BUILD_DLL if required */\n\n/* See pngconf.h for more details: the builder of the library may set this on\n * the command line to the right thing for the specific compilation system or it\n * may be automagically set above (at present we know of no system where it does\n * need to be set on the command line.)\n *\n * PNG_IMPEXP must be set here when building the library to prevent pngconf.h\n * setting it to the \"import\" setting for a DLL build.\n */\n#ifndef PNG_IMPEXP\n#  ifdef PNG_BUILD_DLL\n#     define PNG_IMPEXP PNG_DLL_EXPORT\n#  else\n      /* Not building a DLL, or the DLL doesn't require specific export\n       * definitions.\n       */\n#     define PNG_IMPEXP\n#  endif\n#endif\n\n/* No warnings for private or deprecated functions in the build: */\n#ifndef PNG_DEPRECATED\n#  define PNG_DEPRECATED\n#endif\n#ifndef PNG_PRIVATE\n#  define PNG_PRIVATE\n#endif\n\n/* Symbol preprocessing support.\n *\n * To enable listing global, but internal, symbols the following macros should\n * always be used to declare an extern data or function object in this file.\n */\n#ifndef PNG_INTERNAL_DATA\n#  define PNG_INTERNAL_DATA(type, name, array) extern type name array\n#endif\n\n#ifndef PNG_INTERNAL_FUNCTION\n#  define PNG_INTERNAL_FUNCTION(type, name, args, attributes)\\\n      extern PNG_FUNCTION(type, name, args, PNG_EMPTY attributes)\n#endif\n\n#ifndef PNG_INTERNAL_CALLBACK\n#  define PNG_INTERNAL_CALLBACK(type, name, args, attributes)\\\n      extern PNG_FUNCTION(type, (PNGCBAPI name), args, PNG_EMPTY attributes)\n#endif\n\n/* If floating or fixed point APIs are disabled they may still be compiled\n * internally.  To handle this make sure they are declared as the appropriate\n * internal extern function (otherwise the symbol prefixing stuff won't work and\n * the functions will be used without definitions.)\n *\n * NOTE: although all the API functions are declared here they are not all\n * actually built!  Because the declarations are still made it is necessary to\n * fake out types that they depend on.\n */\n#ifndef PNG_FP_EXPORT\n#  ifndef PNG_FLOATING_POINT_SUPPORTED\n#     define PNG_FP_EXPORT(ordinal, type, name, args)\\\n         PNG_INTERNAL_FUNCTION(type, name, args, PNG_EMPTY);\n#     ifndef PNG_VERSION_INFO_ONLY\n         typedef struct png_incomplete png_double;\n         typedef png_double*           png_doublep;\n         typedef const png_double*     png_const_doublep;\n         typedef png_double**          png_doublepp;\n#     endif\n#  endif\n#endif\n#ifndef PNG_FIXED_EXPORT\n#  ifndef PNG_FIXED_POINT_SUPPORTED\n#     define PNG_FIXED_EXPORT(ordinal, type, name, args)\\\n         PNG_INTERNAL_FUNCTION(type, name, args, PNG_EMPTY);\n#  endif\n#endif\n\n#include \"png.h\"\n\n/* pngconf.h does not set PNG_DLL_EXPORT unless it is required, so: */\n#ifndef PNG_DLL_EXPORT\n#  define PNG_DLL_EXPORT\n#endif\n\n/* SECURITY and SAFETY:\n *\n * By default libpng is built without any internal limits on image size,\n * individual heap (png_malloc) allocations or the total amount of memory used.\n * If PNG_SAFE_LIMITS_SUPPORTED is defined, however, the limits below are used\n * (unless individually overridden).  These limits are believed to be fairly\n * safe, but builders of secure systems should verify the values against the\n * real system capabilities.\n */\n#ifdef PNG_SAFE_LIMITS_SUPPORTED\n   /* 'safe' limits */\n#  ifndef PNG_USER_WIDTH_MAX\n#     define PNG_USER_WIDTH_MAX 1000000\n#  endif\n#  ifndef PNG_USER_HEIGHT_MAX\n#     define PNG_USER_HEIGHT_MAX 1000000\n#  endif\n#  ifndef PNG_USER_CHUNK_CACHE_MAX\n#     define PNG_USER_CHUNK_CACHE_MAX 128\n#  endif\n#  ifndef PNG_USER_CHUNK_MALLOC_MAX\n#     define PNG_USER_CHUNK_MALLOC_MAX 8000000\n#  endif\n#else\n   /* values for no limits */\n#  ifndef PNG_USER_WIDTH_MAX\n#     define PNG_USER_WIDTH_MAX 0x7fffffff\n#  endif\n#  ifndef PNG_USER_HEIGHT_MAX\n#     define PNG_USER_HEIGHT_MAX 0x7fffffff\n#  endif\n#  ifndef PNG_USER_CHUNK_CACHE_MAX\n#     define PNG_USER_CHUNK_CACHE_MAX 0\n#  endif\n#  ifndef PNG_USER_CHUNK_MALLOC_MAX\n#     define PNG_USER_CHUNK_MALLOC_MAX 0\n#  endif\n#endif\n\n/* Moved to pngpriv.h at libpng-1.5.0 */\n/* NOTE: some of these may have been used in external applications as\n * these definitions were exposed in pngconf.h prior to 1.5.\n */\n\n/* If you are running on a machine where you cannot allocate more\n * than 64K of memory at once, uncomment this.  While libpng will not\n * normally need that much memory in a chunk (unless you load up a very\n * large file), zlib needs to know how big of a chunk it can use, and\n * libpng thus makes sure to check any memory allocation to verify it\n * will fit into memory.\n *\n * zlib provides 'MAXSEG_64K' which, if defined, indicates the\n * same limit and pngconf.h (already included) sets the limit\n * if certain operating systems are detected.\n */\n#if defined(MAXSEG_64K) && !defined(PNG_MAX_MALLOC_64K)\n#  define PNG_MAX_MALLOC_64K\n#endif\n\n#ifndef PNG_UNUSED\n/* Unused formal parameter warnings are silenced using the following macro\n * which is expected to have no bad effects on performance (optimizing\n * compilers will probably remove it entirely).  Note that if you replace\n * it with something other than whitespace, you must include the terminating\n * semicolon.\n */\n#  define PNG_UNUSED(param) (void)param;\n#endif\n\n/* Just a little check that someone hasn't tried to define something\n * contradictory.\n */\n#if (PNG_ZBUF_SIZE > 65536L) && defined(PNG_MAX_MALLOC_64K)\n#  undef PNG_ZBUF_SIZE\n#  define PNG_ZBUF_SIZE 65536L\n#endif\n\n/* If warnings or errors are turned off the code is disabled or redirected here.\n * From 1.5.4 functions have been added to allow very limited formatting of\n * error and warning messages - this code will also be disabled here.\n */\n#ifdef PNG_WARNINGS_SUPPORTED\n#  define PNG_WARNING_PARAMETERS(p) png_warning_parameters p;\n#else\n#  define png_warning_parameter(p,number,string) ((void)0)\n#  define png_warning_parameter_unsigned(p,number,format,value) ((void)0)\n#  define png_warning_parameter_signed(p,number,format,value) ((void)0)\n#  define png_formatted_warning(pp,p,message) ((void)(pp))\n#  define PNG_WARNING_PARAMETERS(p)\n#endif\n#ifndef PNG_ERROR_TEXT_SUPPORTED\n#  define png_fixed_error(s1,s2) png_err(s1)\n#endif\n\n/* C allows up-casts from (void*) to any pointer and (const void*) to any\n * pointer to a const object.  C++ regards this as a type error and requires an\n * explicit, static, cast and provides the static_cast<> rune to ensure that\n * const is not cast away.\n */\n#ifdef __cplusplus\n#  define png_voidcast(type, value) static_cast<type>(value)\n#  define png_constcast(type, value) const_cast<type>(value)\n#  define png_aligncast(type, value) \\\n   static_cast<type>(static_cast<void*>(value))\n#  define png_aligncastconst(type, value) \\\n   static_cast<type>(static_cast<const void*>(value))\n#else\n#  define png_voidcast(type, value) (value)\n#  define png_constcast(type, value) ((type)(value))\n#  define png_aligncast(type, value) ((void*)(value))\n#  define png_aligncastconst(type, value) ((const void*)(value))\n#endif /* __cplusplus */\n\n/* Some fixed point APIs are still required even if not exported because\n * they get used by the corresponding floating point APIs.  This magic\n * deals with this:\n */\n#ifdef PNG_FIXED_POINT_SUPPORTED\n#  define PNGFAPI PNGAPI\n#else\n#  define PNGFAPI /* PRIVATE */\n#endif\n\n#ifndef PNG_VERSION_INFO_ONLY\n/* Other defines specific to compilers can go here.  Try to keep\n * them inside an appropriate ifdef/endif pair for portability.\n */\n#if defined(PNG_FLOATING_POINT_SUPPORTED) ||\\\n    defined(PNG_FLOATING_ARITHMETIC_SUPPORTED)\n   /* png.c requires the following ANSI-C constants if the conversion of\n    * floating point to ASCII is implemented therein:\n    *\n    *  DBL_DIG  Maximum number of decimal digits (can be set to any constant)\n    *  DBL_MIN  Smallest normalized fp number (can be set to an arbitrary value)\n    *  DBL_MAX  Maximum floating point number (can be set to an arbitrary value)\n    */\n#  include <float.h>\n\n#  if (defined(__MWERKS__) && defined(macintosh)) || defined(applec) || \\\n    defined(THINK_C) || defined(__SC__) || defined(TARGET_OS_MAC)\n     /* We need to check that <math.h> hasn't already been included earlier\n      * as it seems it doesn't agree with <fp.h>, yet we should really use\n      * <fp.h> if possible.\n      */\n#    if !defined(__MATH_H__) && !defined(__MATH_H) && !defined(__cmath__)\n#      include <fp.h>\n#    endif\n#  else\n#    include <math.h>\n#  endif\n#  if defined(_AMIGA) && defined(__SASC) && defined(_M68881)\n     /* Amiga SAS/C: We must include builtin FPU functions when compiling using\n      * MATH=68881\n      */\n#    include <m68881.h>\n#  endif\n#endif\n\n/* This provides the non-ANSI (far) memory allocation routines. */\n#if defined(__TURBOC__) && defined(__MSDOS__)\n#  include <mem.h>\n#  include <alloc.h>\n#endif\n\n#if defined(WIN32) || defined(_Windows) || defined(_WINDOWS) || \\\n    defined(_WIN32) || defined(__WIN32__)\n#  include <windows.h>  /* defines _WINDOWS_ macro */\n#endif\n#endif /* PNG_VERSION_INFO_ONLY */\n\n/* Moved here around 1.5.0beta36 from pngconf.h */\n/* Users may want to use these so they are not private.  Any library\n * functions that are passed far data must be model-independent.\n */\n\n/* Memory model/platform independent fns */\n#ifndef PNG_ABORT\n#  ifdef _WINDOWS_\n#    define PNG_ABORT() ExitProcess(0)\n#  else\n#    define PNG_ABORT() abort()\n#  endif\n#endif\n\n/* These macros may need to be architecture dependent. */\n#define PNG_ALIGN_NONE   0 /* do not use data alignment */\n#define PNG_ALIGN_ALWAYS 1 /* assume unaligned accesses are OK */\n#ifdef offsetof\n#  define PNG_ALIGN_OFFSET 2 /* use offsetof to determine alignment */\n#else\n#  define PNG_ALIGN_OFFSET -1 /* prevent the use of this */\n#endif\n#define PNG_ALIGN_SIZE   3 /* use sizeof to determine alignment */\n\n#ifndef PNG_ALIGN_TYPE\n   /* Default to using aligned access optimizations and requiring alignment to a\n    * multiple of the data type size.  Override in a compiler specific fashion\n    * if necessary by inserting tests here:\n    */\n#  define PNG_ALIGN_TYPE PNG_ALIGN_SIZE\n#endif\n\n#if PNG_ALIGN_TYPE == PNG_ALIGN_SIZE\n   /* This is used because in some compiler implementations non-aligned\n    * structure members are supported, so the offsetof approach below fails.\n    * Set PNG_ALIGN_SIZE=0 for compiler combinations where unaligned access\n    * is good for performance.  Do not do this unless you have tested the result\n    * and understand it.\n    */\n#  define png_alignof(type) (sizeof (type))\n#else\n#  if PNG_ALIGN_TYPE == PNG_ALIGN_OFFSET\n#     define png_alignof(type) offsetof(struct{char c; type t;}, t)\n#  else\n#     if PNG_ALIGN_TYPE == PNG_ALIGN_ALWAYS\n#        define png_alignof(type) (1)\n#     endif\n      /* Else leave png_alignof undefined to prevent use thereof */\n#  endif\n#endif\n\n/* This implicitly assumes alignment is always to a power of 2. */\n#ifdef png_alignof\n#  define png_isaligned(ptr, type)\\\n   ((((const char*)ptr-(const char*)0) & (png_alignof(type)-1)) == 0)\n#else\n#  define png_isaligned(ptr, type) 0\n#endif\n\n/* End of memory model/platform independent support */\n/* End of 1.5.0beta36 move from pngconf.h */\n\n/* CONSTANTS and UTILITY MACROS\n * These are used internally by libpng and not exposed in the API\n */\n\n/* Various modes of operation.  Note that after an init, mode is set to\n * zero automatically when the structure is created.  Three of these\n * are defined in png.h because they need to be visible to applications\n * that call png_set_unknown_chunk().\n */\n/* #define PNG_HAVE_IHDR            0x01 (defined in png.h) */\n/* #define PNG_HAVE_PLTE            0x02 (defined in png.h) */\n#define PNG_HAVE_IDAT               0x04\n/* #define PNG_AFTER_IDAT           0x08 (defined in png.h) */\n#define PNG_HAVE_IEND               0x10\n                   /*               0x20 (unused) */\n                   /*               0x40 (unused) */\n                   /*               0x80 (unused) */\n#define PNG_HAVE_CHUNK_HEADER      0x100\n#define PNG_WROTE_tIME             0x200\n#define PNG_WROTE_INFO_BEFORE_PLTE 0x400\n#define PNG_BACKGROUND_IS_GRAY     0x800\n#define PNG_HAVE_PNG_SIGNATURE    0x1000\n#define PNG_HAVE_CHUNK_AFTER_IDAT 0x2000 /* Have another chunk after IDAT */\n                   /*             0x4000 (unused) */\n#define PNG_IS_READ_STRUCT        0x8000 /* Else is a write struct */\n\n/* Flags for the transformations the PNG library does on the image data */\n#define PNG_BGR                 0x0001\n#define PNG_INTERLACE           0x0002\n#define PNG_PACK                0x0004\n#define PNG_SHIFT               0x0008\n#define PNG_SWAP_BYTES          0x0010\n#define PNG_INVERT_MONO         0x0020\n#define PNG_QUANTIZE            0x0040\n#define PNG_COMPOSE             0x0080     /* Was PNG_BACKGROUND */\n#define PNG_BACKGROUND_EXPAND   0x0100\n#define PNG_EXPAND_16           0x0200     /* Added to libpng 1.5.2 */\n#define PNG_16_TO_8             0x0400     /* Becomes 'chop' in 1.5.4 */\n#define PNG_RGBA                0x0800\n#define PNG_EXPAND              0x1000\n#define PNG_GAMMA               0x2000\n#define PNG_GRAY_TO_RGB         0x4000\n#define PNG_FILLER              0x8000\n#define PNG_PACKSWAP           0x10000\n#define PNG_SWAP_ALPHA         0x20000\n#define PNG_STRIP_ALPHA        0x40000\n#define PNG_INVERT_ALPHA       0x80000\n#define PNG_USER_TRANSFORM    0x100000\n#define PNG_RGB_TO_GRAY_ERR   0x200000\n#define PNG_RGB_TO_GRAY_WARN  0x400000\n#define PNG_RGB_TO_GRAY       0x600000 /* two bits, RGB_TO_GRAY_ERR|WARN */\n#define PNG_ENCODE_ALPHA      0x800000 /* Added to libpng-1.5.4 */\n#define PNG_ADD_ALPHA         0x1000000 /* Added to libpng-1.2.7 */\n#define PNG_EXPAND_tRNS       0x2000000 /* Added to libpng-1.2.9 */\n#define PNG_SCALE_16_TO_8     0x4000000 /* Added to libpng-1.5.4 */\n                       /*   0x8000000 unused */\n                       /*  0x10000000 unused */\n                       /*  0x20000000 unused */\n                       /*  0x40000000 unused */\n/* Flags for png_create_struct */\n#define PNG_STRUCT_PNG   0x0001\n#define PNG_STRUCT_INFO  0x0002\n\n/* Scaling factor for filter heuristic weighting calculations */\n#define PNG_WEIGHT_FACTOR (1<<(PNG_WEIGHT_SHIFT))\n#define PNG_COST_FACTOR (1<<(PNG_COST_SHIFT))\n\n/* Flags for the png_ptr->flags rather than declaring a byte for each one */\n#define PNG_FLAG_ZLIB_CUSTOM_STRATEGY     0x0001\n#define PNG_FLAG_ZSTREAM_INITIALIZED      0x0002 /* Added to libpng-1.6.0 */\n                                  /*      0x0004    unused */\n#define PNG_FLAG_ZSTREAM_ENDED            0x0008 /* Added to libpng-1.6.0 */\n                                  /*      0x0010    unused */\n                                  /*      0x0020    unused */\n#define PNG_FLAG_ROW_INIT                 0x0040\n#define PNG_FLAG_FILLER_AFTER             0x0080\n#define PNG_FLAG_CRC_ANCILLARY_USE        0x0100\n#define PNG_FLAG_CRC_ANCILLARY_NOWARN     0x0200\n#define PNG_FLAG_CRC_CRITICAL_USE         0x0400\n#define PNG_FLAG_CRC_CRITICAL_IGNORE      0x0800\n#define PNG_FLAG_ASSUME_sRGB              0x1000 /* Added to libpng-1.5.4 */\n#define PNG_FLAG_OPTIMIZE_ALPHA           0x2000 /* Added to libpng-1.5.4 */\n#define PNG_FLAG_DETECT_UNINITIALIZED     0x4000 /* Added to libpng-1.5.4 */\n/* #define PNG_FLAG_KEEP_UNKNOWN_CHUNKS      0x8000 */\n/* #define PNG_FLAG_KEEP_UNSAFE_CHUNKS      0x10000 */\n#define PNG_FLAG_LIBRARY_MISMATCH        0x20000\n#define PNG_FLAG_STRIP_ERROR_NUMBERS     0x40000\n#define PNG_FLAG_STRIP_ERROR_TEXT        0x80000\n#define PNG_FLAG_BENIGN_ERRORS_WARN     0x100000 /* Added to libpng-1.4.0 */\n#define PNG_FLAG_APP_WARNINGS_WARN      0x200000 /* Added to libpng-1.6.0 */\n#define PNG_FLAG_APP_ERRORS_WARN        0x400000 /* Added to libpng-1.6.0 */\n                                  /*    0x800000    unused */\n                                  /*   0x1000000    unused */\n                                  /*   0x2000000    unused */\n                                  /*   0x4000000    unused */\n                                  /*   0x8000000    unused */\n                                  /*  0x10000000    unused */\n                                  /*  0x20000000    unused */\n                                  /*  0x40000000    unused */\n\n#define PNG_FLAG_CRC_ANCILLARY_MASK (PNG_FLAG_CRC_ANCILLARY_USE | \\\n                                     PNG_FLAG_CRC_ANCILLARY_NOWARN)\n\n#define PNG_FLAG_CRC_CRITICAL_MASK  (PNG_FLAG_CRC_CRITICAL_USE | \\\n                                     PNG_FLAG_CRC_CRITICAL_IGNORE)\n\n#define PNG_FLAG_CRC_MASK           (PNG_FLAG_CRC_ANCILLARY_MASK | \\\n                                     PNG_FLAG_CRC_CRITICAL_MASK)\n\n/* Save typing and make code easier to understand */\n\n#define PNG_COLOR_DIST(c1, c2) (abs((int)((c1).red) - (int)((c2).red)) + \\\n   abs((int)((c1).green) - (int)((c2).green)) + \\\n   abs((int)((c1).blue) - (int)((c2).blue)))\n\n/* Added to libpng-1.6.0: scale a 16-bit value in the range 0..65535 to 0..255\n * by dividing by 257 *with rounding*.  This macro is exact for the given range.\n * See the discourse in pngrtran.c png_do_scale_16_to_8.  The values in the\n * macro were established by experiment (modifying the added value).  The macro\n * has a second variant that takes a value already scaled by 255 and divides by\n * 65535 - this has a maximum error of .502.  Over the range 0..65535*65535 it\n * only gives off-by-one errors and only for 0.5% (1 in 200) of the values.\n */\n#define PNG_DIV65535(v24) (((v24) + 32895) >> 16)\n#define PNG_DIV257(v16) PNG_DIV65535((png_uint_32)(v16) * 255)\n\n/* Added to libpng-1.2.6 JB */\n#define PNG_ROWBYTES(pixel_bits, width) \\\n    ((pixel_bits) >= 8 ? \\\n    ((png_size_t)(width) * (((png_size_t)(pixel_bits)) >> 3)) : \\\n    (( ((png_size_t)(width) * ((png_size_t)(pixel_bits))) + 7) >> 3) )\n\n/* PNG_OUT_OF_RANGE returns true if value is outside the range\n * ideal-delta..ideal+delta.  Each argument is evaluated twice.\n * \"ideal\" and \"delta\" should be constants, normally simple\n * integers, \"value\" a variable. Added to libpng-1.2.6 JB\n */\n#define PNG_OUT_OF_RANGE(value, ideal, delta) \\\n   ( (value) < (ideal)-(delta) || (value) > (ideal)+(delta) )\n\n/* Conversions between fixed and floating point, only defined if\n * required (to make sure the code doesn't accidentally use float\n * when it is supposedly disabled.)\n */\n#ifdef PNG_FLOATING_POINT_SUPPORTED\n/* The floating point conversion can't overflow, though it can and\n * does lose accuracy relative to the original fixed point value.\n * In practice this doesn't matter because png_fixed_point only\n * stores numbers with very low precision.  The png_ptr and s\n * arguments are unused by default but are there in case error\n * checking becomes a requirement.\n */\n#define png_float(png_ptr, fixed, s) (.00001 * (fixed))\n\n/* The fixed point conversion performs range checking and evaluates\n * its argument multiple times, so must be used with care.  The\n * range checking uses the PNG specification values for a signed\n * 32 bit fixed point value except that the values are deliberately\n * rounded-to-zero to an integral value - 21474 (21474.83 is roughly\n * (2^31-1) * 100000). 's' is a string that describes the value being\n * converted.\n *\n * NOTE: this macro will raise a png_error if the range check fails,\n * therefore it is normally only appropriate to use this on values\n * that come from API calls or other sources where an out of range\n * error indicates a programming error, not a data error!\n *\n * NOTE: by default this is off - the macro is not used - because the\n * function call saves a lot of code.\n */\n#ifdef PNG_FIXED_POINT_MACRO_SUPPORTED\n#define png_fixed(png_ptr, fp, s) ((fp) <= 21474 && (fp) >= -21474 ?\\\n    ((png_fixed_point)(100000 * (fp))) : (png_fixed_error(png_ptr, s),0))\n#endif\n/* else the corresponding function is defined below, inside the scope of the\n * cplusplus test.\n */\n#endif\n\n/* Constants for known chunk types.  If you need to add a chunk, define the name\n * here.  For historical reasons these constants have the form png_<name>; i.e.\n * the prefix is lower case.  Please use decimal values as the parameters to\n * match the ISO PNG specification and to avoid relying on the C locale\n * interpretation of character values.\n *\n * Prior to 1.5.6 these constants were strings, as of 1.5.6 png_uint_32 values\n * are computed and a new macro (PNG_STRING_FROM_CHUNK) added to allow a string\n * to be generated if required.\n *\n * PNG_32b correctly produces a value shifted by up to 24 bits, even on\n * architectures where (int) is only 16 bits.\n */\n#define PNG_32b(b,s) ((png_uint_32)(b) << (s))\n#define PNG_U32(b1,b2,b3,b4) \\\n   (PNG_32b(b1,24) | PNG_32b(b2,16) | PNG_32b(b3,8) | PNG_32b(b4,0))\n\n/* Constants for known chunk types.\n *\n * MAINTAINERS: If you need to add a chunk, define the name here.\n * For historical reasons these constants have the form png_<name>; i.e.\n * the prefix is lower case.  Please use decimal values as the parameters to\n * match the ISO PNG specification and to avoid relying on the C locale\n * interpretation of character values.  Please keep the list sorted.\n *\n * Notice that PNG_U32 is used to define a 32-bit value for the 4 byte chunk\n * type.  In fact the specification does not express chunk types this way,\n * however using a 32-bit value means that the chunk type can be read from the\n * stream using exactly the same code as used for a 32-bit unsigned value and\n * can be examined far more efficiently (using one arithmetic compare).\n *\n * Prior to 1.5.6 the chunk type constants were expressed as C strings.  The\n * libpng API still uses strings for 'unknown' chunks and a macro,\n * PNG_STRING_FROM_CHUNK, allows a string to be generated if required.  Notice\n * that for portable code numeric values must still be used; the string \"IHDR\"\n * is not portable and neither is PNG_U32('I', 'H', 'D', 'R').\n *\n * In 1.7.0 the definitions will be made public in png.h to avoid having to\n * duplicate the same definitions in application code.\n */\n#define png_IDAT PNG_U32( 73,  68,  65,  84)\n#define png_IEND PNG_U32( 73,  69,  78,  68)\n#define png_IHDR PNG_U32( 73,  72,  68,  82)\n#define png_PLTE PNG_U32( 80,  76,  84,  69)\n#define png_bKGD PNG_U32( 98,  75,  71,  68)\n#define png_cHRM PNG_U32( 99,  72,  82,  77)\n#define png_fRAc PNG_U32(102,  82,  65,  99) /* registered, not defined */\n#define png_gAMA PNG_U32(103,  65,  77,  65)\n#define png_gIFg PNG_U32(103,  73,  70, 103)\n#define png_gIFt PNG_U32(103,  73,  70, 116) /* deprecated */\n#define png_gIFx PNG_U32(103,  73,  70, 120)\n#define png_hIST PNG_U32(104,  73,  83,  84)\n#define png_iCCP PNG_U32(105,  67,  67,  80)\n#define png_iTXt PNG_U32(105,  84,  88, 116)\n#define png_oFFs PNG_U32(111,  70,  70, 115)\n#define png_pCAL PNG_U32(112,  67,  65,  76)\n#define png_pHYs PNG_U32(112,  72,  89, 115)\n#define png_sBIT PNG_U32(115,  66,  73,  84)\n#define png_sCAL PNG_U32(115,  67,  65,  76)\n#define png_sPLT PNG_U32(115,  80,  76,  84)\n#define png_sRGB PNG_U32(115,  82,  71,  66)\n#define png_sTER PNG_U32(115,  84,  69,  82)\n#define png_tEXt PNG_U32(116,  69,  88, 116)\n#define png_tIME PNG_U32(116,  73,  77,  69)\n#define png_tRNS PNG_U32(116,  82,  78,  83)\n#define png_zTXt PNG_U32(122,  84,  88, 116)\n\n/* The following will work on (signed char*) strings, whereas the get_uint_32\n * macro will fail on top-bit-set values because of the sign extension.\n */\n#define PNG_CHUNK_FROM_STRING(s)\\\n   PNG_U32(0xff&(s)[0], 0xff&(s)[1], 0xff&(s)[2], 0xff&(s)[3])\n\n/* This uses (char), not (png_byte) to avoid warnings on systems where (char) is\n * signed and the argument is a (char[])  This macro will fail miserably on\n * systems where (char) is more than 8 bits.\n */\n#define PNG_STRING_FROM_CHUNK(s,c)\\\n   (void)(((char*)(s))[0]=(char)((c)>>24), ((char*)(s))[1]=(char)((c)>>16),\\\n   ((char*)(s))[2]=(char)((c)>>8), ((char*)(s))[3]=(char)((c)))\n\n/* Do the same but terminate with a null character. */\n#define PNG_CSTRING_FROM_CHUNK(s,c)\\\n   (void)(PNG_STRING_FROM_CHUNK(s,c), ((char*)(s))[4] = 0)\n\n/* Test on flag values as defined in the spec (section 5.4): */\n#define PNG_CHUNK_ANCILLARY(c)   (1 & ((c) >> 29))\n#define PNG_CHUNK_CRITICAL(c)     (!PNG_CHUNK_ANCILLARY(c))\n#define PNG_CHUNK_PRIVATE(c)      (1 & ((c) >> 21))\n#define PNG_CHUNK_RESERVED(c)     (1 & ((c) >> 13))\n#define PNG_CHUNK_SAFE_TO_COPY(c) (1 & ((c) >>  5))\n\n/* Gamma values (new at libpng-1.5.4): */\n#define PNG_GAMMA_MAC_OLD 151724  /* Assume '1.8' is really 2.2/1.45! */\n#define PNG_GAMMA_MAC_INVERSE 65909\n#define PNG_GAMMA_sRGB_INVERSE 45455\n\n/* Almost everything below is C specific; the #defines above can be used in\n * non-C code (so long as it is C-preprocessed) the rest of this stuff cannot.\n */\n#ifndef PNG_VERSION_INFO_ONLY\n\n#include \"pngstruct.h\"\n#include \"pnginfo.h\"\n\n/* Validate the include paths - the include path used to generate pnglibconf.h\n * must match that used in the build, or we must be using pnglibconf.h.prebuilt:\n */\n#if PNG_ZLIB_VERNUM != 0 && PNG_ZLIB_VERNUM != ZLIB_VERNUM\n#  error ZLIB_VERNUM != PNG_ZLIB_VERNUM \\\n      \"-I (include path) error: see the notes in pngpriv.h\"\n   /* This means that when pnglibconf.h was built the copy of zlib.h that it\n    * used is not the same as the one being used here.  Because the build of\n    * libpng makes decisions to use inflateInit2 and inflateReset2 based on the\n    * zlib version number and because this affects handling of certain broken\n    * PNG files the -I directives must match.\n    *\n    * The most likely explanation is that you passed a -I in CFLAGS, this will\n    * not work; all the preprocessor directories and in particular all the -I\n    * directives must be in CPPFLAGS.\n    */\n#endif\n\n/* This is used for 16 bit gamma tables -- only the top level pointers are\n * const; this could be changed:\n */\ntypedef const png_uint_16p * png_const_uint_16pp;\n\n/* Added to libpng-1.5.7: sRGB conversion tables */\n#if defined(PNG_SIMPLIFIED_READ_SUPPORTED) ||\\\n   defined(PNG_SIMPLIFIED_WRITE_SUPPORTED)\n#ifdef PNG_SIMPLIFIED_READ_SUPPORTED\nPNG_INTERNAL_DATA(const png_uint_16, png_sRGB_table, [256]);\n   /* Convert from an sRGB encoded value 0..255 to a 16-bit linear value,\n    * 0..65535.  This table gives the closest 16-bit answers (no errors).\n    */\n#endif\n\nPNG_INTERNAL_DATA(const png_uint_16, png_sRGB_base, [512]);\nPNG_INTERNAL_DATA(const png_byte, png_sRGB_delta, [512]);\n\n#define PNG_sRGB_FROM_LINEAR(linear) ((png_byte)((png_sRGB_base[(linear)>>15] +\\\n   ((((linear)&0x7fff)*png_sRGB_delta[(linear)>>15])>>12)) >> 8))\n   /* Given a value 'linear' in the range 0..255*65535 calculate the 8-bit sRGB\n    * encoded value with maximum error 0.646365.  Note that the input is not a\n    * 16-bit value; it has been multiplied by 255! */\n#endif /* PNG_SIMPLIFIED_READ/WRITE */\n\n\n/* Inhibit C++ name-mangling for libpng functions but not for system calls. */\n#ifdef __cplusplus\nextern \"C\" {\n#endif /* __cplusplus */\n\n/* Internal functions; these are not exported from a DLL however because they\n * are used within several of the C source files they have to be C extern.\n *\n * All of these functions must be declared with PNG_INTERNAL_FUNCTION.\n */\n\n/* Zlib support */\n#define PNG_UNEXPECTED_ZLIB_RETURN (-7)\nPNG_INTERNAL_FUNCTION(void, png_zstream_error,(png_structrp png_ptr, int ret),\n   PNG_EMPTY);\n   /* Used by the zlib handling functions to ensure that z_stream::msg is always\n    * set before they return.\n    */\n\n#ifdef PNG_WRITE_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_free_buffer_list,(png_structrp png_ptr,\n   png_compression_bufferp *list),PNG_EMPTY);\n   /* Free the buffer list used by the compressed write code. */\n#endif\n\n#if defined(PNG_FLOATING_POINT_SUPPORTED) && \\\n   !defined(PNG_FIXED_POINT_MACRO_SUPPORTED) && \\\n   (defined(PNG_gAMA_SUPPORTED) || defined(PNG_cHRM_SUPPORTED) || \\\n   defined(PNG_sCAL_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) || \\\n   defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)) || \\\n   (defined(PNG_sCAL_SUPPORTED) && \\\n   defined(PNG_FLOATING_ARITHMETIC_SUPPORTED))\nPNG_INTERNAL_FUNCTION(png_fixed_point,png_fixed,(png_const_structrp png_ptr,\n   double fp, png_const_charp text),PNG_EMPTY);\n#endif\n\n/* Check the user version string for compatibility, returns false if the version\n * numbers aren't compatible.\n */\nPNG_INTERNAL_FUNCTION(int,png_user_version_check,(png_structrp png_ptr,\n   png_const_charp user_png_ver),PNG_EMPTY);\n\n/* Internal base allocator - no messages, NULL on failure to allocate.  This\n * does, however, call the application provided allocator and that could call\n * png_error (although that would be a bug in the application implementation.)\n */\nPNG_INTERNAL_FUNCTION(png_voidp,png_malloc_base,(png_const_structrp png_ptr,\n   png_alloc_size_t size),PNG_ALLOCATED);\n\n#if defined(PNG_TEXT_SUPPORTED) || defined(PNG_sPLT_SUPPORTED) ||\\\n   defined(PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED)\n/* Internal array allocator, outputs no error or warning messages on failure,\n * just returns NULL.  \n */\nPNG_INTERNAL_FUNCTION(png_voidp,png_malloc_array,(png_const_structrp png_ptr,\n   int nelements, size_t element_size),PNG_ALLOCATED);\n\n/* The same but an existing array is extended by add_elements.  This function\n * also memsets the new elements to 0 and copies the old elements.  The old\n * array is not freed or altered.\n */\nPNG_INTERNAL_FUNCTION(png_voidp,png_realloc_array,(png_const_structrp png_ptr,\n   png_const_voidp array, int old_elements, int add_elements,\n   size_t element_size),PNG_ALLOCATED);\n#endif /* text, sPLT or unknown chunks */\n\n/* Magic to create a struct when there is no struct to call the user supplied\n * memory allocators.  Because error handling has not been set up the memory\n * handlers can't safely call png_error, but this is an obscure and undocumented\n * restriction so libpng has to assume that the 'free' handler, at least, might\n * call png_error.\n */\nPNG_INTERNAL_FUNCTION(png_structp,png_create_png_struct,\n   (png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn,\n    png_error_ptr warn_fn, png_voidp mem_ptr, png_malloc_ptr malloc_fn,\n    png_free_ptr free_fn),PNG_ALLOCATED);\n\n/* Free memory from internal libpng struct */\nPNG_INTERNAL_FUNCTION(void,png_destroy_png_struct,(png_structrp png_ptr),\n   PNG_EMPTY);\n\n/* Free an allocated jmp_buf (always succeeds) */\nPNG_INTERNAL_FUNCTION(void,png_free_jmpbuf,(png_structrp png_ptr),PNG_EMPTY);\n\n/* Function to allocate memory for zlib.  PNGAPI is disallowed. */\nPNG_INTERNAL_FUNCTION(voidpf,png_zalloc,(voidpf png_ptr, uInt items, uInt size),\n   PNG_ALLOCATED);\n\n/* Function to free memory for zlib.  PNGAPI is disallowed. */\nPNG_INTERNAL_FUNCTION(void,png_zfree,(voidpf png_ptr, voidpf ptr),PNG_EMPTY);\n\n/* Next four functions are used internally as callbacks.  PNGCBAPI is required\n * but not PNG_EXPORT.  PNGAPI added at libpng version 1.2.3, changed to\n * PNGCBAPI at 1.5.0\n */\n\nPNG_INTERNAL_FUNCTION(void PNGCBAPI,png_default_read_data,(png_structp png_ptr,\n    png_bytep data, png_size_t length),PNG_EMPTY);\n\n#ifdef PNG_PROGRESSIVE_READ_SUPPORTED\nPNG_INTERNAL_FUNCTION(void PNGCBAPI,png_push_fill_buffer,(png_structp png_ptr,\n    png_bytep buffer, png_size_t length),PNG_EMPTY);\n#endif\n\nPNG_INTERNAL_FUNCTION(void PNGCBAPI,png_default_write_data,(png_structp png_ptr,\n    png_bytep data, png_size_t length),PNG_EMPTY);\n\n#ifdef PNG_WRITE_FLUSH_SUPPORTED\n#  ifdef PNG_STDIO_SUPPORTED\nPNG_INTERNAL_FUNCTION(void PNGCBAPI,png_default_flush,(png_structp png_ptr),\n   PNG_EMPTY);\n#  endif\n#endif\n\n/* Reset the CRC variable */\nPNG_INTERNAL_FUNCTION(void,png_reset_crc,(png_structrp png_ptr),PNG_EMPTY);\n\n/* Write the \"data\" buffer to whatever output you are using */\nPNG_INTERNAL_FUNCTION(void,png_write_data,(png_structrp png_ptr,\n    png_const_bytep data, png_size_t length),PNG_EMPTY);\n\n/* Read and check the PNG file signature */\nPNG_INTERNAL_FUNCTION(void,png_read_sig,(png_structrp png_ptr,\n   png_inforp info_ptr),PNG_EMPTY);\n\n/* Read the chunk header (length + type name) */\nPNG_INTERNAL_FUNCTION(png_uint_32,png_read_chunk_header,(png_structrp png_ptr),\n   PNG_EMPTY);\n\n/* Read data from whatever input you are using into the \"data\" buffer */\nPNG_INTERNAL_FUNCTION(void,png_read_data,(png_structrp png_ptr, png_bytep data,\n    png_size_t length),PNG_EMPTY);\n\n/* Read bytes into buf, and update png_ptr->crc */\nPNG_INTERNAL_FUNCTION(void,png_crc_read,(png_structrp png_ptr, png_bytep buf,\n    png_uint_32 length),PNG_EMPTY);\n\n/* Read \"skip\" bytes, read the file crc, and (optionally) verify png_ptr->crc */\nPNG_INTERNAL_FUNCTION(int,png_crc_finish,(png_structrp png_ptr,\n   png_uint_32 skip),PNG_EMPTY);\n\n/* Read the CRC from the file and compare it to the libpng calculated CRC */\nPNG_INTERNAL_FUNCTION(int,png_crc_error,(png_structrp png_ptr),PNG_EMPTY);\n\n/* Calculate the CRC over a section of data.  Note that we are only\n * passing a maximum of 64K on systems that have this as a memory limit,\n * since this is the maximum buffer size we can specify.\n */\nPNG_INTERNAL_FUNCTION(void,png_calculate_crc,(png_structrp png_ptr,\n   png_const_bytep ptr, png_size_t length),PNG_EMPTY);\n\n#ifdef PNG_WRITE_FLUSH_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_flush,(png_structrp png_ptr),PNG_EMPTY);\n#endif\n\n/* Write various chunks */\n\n/* Write the IHDR chunk, and update the png_struct with the necessary\n * information.\n */\nPNG_INTERNAL_FUNCTION(void,png_write_IHDR,(png_structrp png_ptr,\n   png_uint_32 width, png_uint_32 height, int bit_depth, int color_type,\n   int compression_method, int filter_method, int interlace_method),PNG_EMPTY);\n\nPNG_INTERNAL_FUNCTION(void,png_write_PLTE,(png_structrp png_ptr,\n   png_const_colorp palette, png_uint_32 num_pal),PNG_EMPTY);\n\nPNG_INTERNAL_FUNCTION(void,png_compress_IDAT,(png_structrp png_ptr,\n   png_const_bytep row_data, png_alloc_size_t row_data_length, int flush),\n   PNG_EMPTY);\n\nPNG_INTERNAL_FUNCTION(void,png_write_IEND,(png_structrp png_ptr),PNG_EMPTY);\n\n#ifdef PNG_WRITE_gAMA_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_write_gAMA_fixed,(png_structrp png_ptr,\n    png_fixed_point file_gamma),PNG_EMPTY);\n#endif\n\n#ifdef PNG_WRITE_sBIT_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_write_sBIT,(png_structrp png_ptr,\n    png_const_color_8p sbit, int color_type),PNG_EMPTY);\n#endif\n\n#ifdef PNG_WRITE_cHRM_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_write_cHRM_fixed,(png_structrp png_ptr,\n    const png_xy *xy), PNG_EMPTY);\n    /* The xy value must have been previously validated */\n#endif\n\n#ifdef PNG_WRITE_sRGB_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_write_sRGB,(png_structrp png_ptr,\n    int intent),PNG_EMPTY);\n#endif\n\n#ifdef PNG_WRITE_iCCP_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_write_iCCP,(png_structrp png_ptr,\n   png_const_charp name, png_const_bytep profile), PNG_EMPTY);\n   /* The profile must have been previously validated for correctness, the\n    * length comes from the first four bytes.  Only the base, deflate,\n    * compression is supported.\n    */\n#endif\n\n#ifdef PNG_WRITE_sPLT_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_write_sPLT,(png_structrp png_ptr,\n    png_const_sPLT_tp palette),PNG_EMPTY);\n#endif\n\n#ifdef PNG_WRITE_tRNS_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_write_tRNS,(png_structrp png_ptr,\n    png_const_bytep trans, png_const_color_16p values, int number,\n    int color_type),PNG_EMPTY);\n#endif\n\n#ifdef PNG_WRITE_bKGD_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_write_bKGD,(png_structrp png_ptr,\n    png_const_color_16p values, int color_type),PNG_EMPTY);\n#endif\n\n#ifdef PNG_WRITE_hIST_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_write_hIST,(png_structrp png_ptr,\n    png_const_uint_16p hist, int num_hist),PNG_EMPTY);\n#endif\n\n/* Chunks that have keywords */\n#ifdef PNG_WRITE_tEXt_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_write_tEXt,(png_structrp png_ptr,\n   png_const_charp key, png_const_charp text, png_size_t text_len),PNG_EMPTY);\n#endif\n\n#ifdef PNG_WRITE_zTXt_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_write_zTXt,(png_structrp png_ptr, png_const_charp\n    key, png_const_charp text, png_size_t text_len, int compression),PNG_EMPTY);\n#endif\n\n#ifdef PNG_WRITE_iTXt_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_write_iTXt,(png_structrp png_ptr,\n    int compression, png_const_charp key, png_const_charp lang,\n    png_const_charp lang_key, png_const_charp text),PNG_EMPTY);\n#endif\n\n#ifdef PNG_TEXT_SUPPORTED  /* Added at version 1.0.14 and 1.2.4 */\nPNG_INTERNAL_FUNCTION(int,png_set_text_2,(png_const_structrp png_ptr,\n    png_inforp info_ptr, png_const_textp text_ptr, int num_text),PNG_EMPTY);\n#endif\n\n#ifdef PNG_WRITE_oFFs_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_write_oFFs,(png_structrp png_ptr,\n    png_int_32 x_offset, png_int_32 y_offset, int unit_type),PNG_EMPTY);\n#endif\n\n#ifdef PNG_WRITE_pCAL_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_write_pCAL,(png_structrp png_ptr,\n    png_charp purpose, png_int_32 X0, png_int_32 X1, int type, int nparams,\n    png_const_charp units, png_charpp params),PNG_EMPTY);\n#endif\n\n#ifdef PNG_WRITE_pHYs_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_write_pHYs,(png_structrp png_ptr,\n    png_uint_32 x_pixels_per_unit, png_uint_32 y_pixels_per_unit,\n    int unit_type),PNG_EMPTY);\n#endif\n\n#ifdef PNG_WRITE_tIME_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_write_tIME,(png_structrp png_ptr,\n    png_const_timep mod_time),PNG_EMPTY);\n#endif\n\n#ifdef PNG_WRITE_sCAL_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_write_sCAL_s,(png_structrp png_ptr,\n    int unit, png_const_charp width, png_const_charp height),PNG_EMPTY);\n#endif\n\n/* Called when finished processing a row of data */\nPNG_INTERNAL_FUNCTION(void,png_write_finish_row,(png_structrp png_ptr),\n    PNG_EMPTY);\n\n/* Internal use only.   Called before first row of data */\nPNG_INTERNAL_FUNCTION(void,png_write_start_row,(png_structrp png_ptr),\n    PNG_EMPTY);\n\n/* Combine a row of data, dealing with alpha, etc. if requested.  'row' is an\n * array of png_ptr->width pixels.  If the image is not interlaced or this\n * is the final pass this just does a memcpy, otherwise the \"display\" flag\n * is used to determine whether to copy pixels that are not in the current pass.\n *\n * Because 'png_do_read_interlace' (below) replicates pixels this allows this\n * function to achieve the documented 'blocky' appearance during interlaced read\n * if display is 1 and the 'sparkle' appearance, where existing pixels in 'row'\n * are not changed if they are not in the current pass, when display is 0.\n *\n * 'display' must be 0 or 1, otherwise the memcpy will be done regardless.\n *\n * The API always reads from the png_struct row buffer and always assumes that\n * it is full width (png_do_read_interlace has already been called.)\n *\n * This function is only ever used to write to row buffers provided by the\n * caller of the relevant libpng API and the row must have already been\n * transformed by the read transformations.\n *\n * The PNG_USE_COMPILE_TIME_MASKS option causes generation of pre-computed\n * bitmasks for use within the code, otherwise runtime generated masks are used.\n * The default is compile time masks.\n */\n#ifndef PNG_USE_COMPILE_TIME_MASKS\n#  define PNG_USE_COMPILE_TIME_MASKS 1\n#endif\nPNG_INTERNAL_FUNCTION(void,png_combine_row,(png_const_structrp png_ptr,\n    png_bytep row, int display),PNG_EMPTY);\n\n#ifdef PNG_READ_INTERLACING_SUPPORTED\n/* Expand an interlaced row: the 'row_info' describes the pass data that has\n * been read in and must correspond to the pixels in 'row', the pixels are\n * expanded (moved apart) in 'row' to match the final layout, when doing this\n * the pixels are *replicated* to the intervening space.  This is essential for\n * the correct operation of png_combine_row, above.\n */\nPNG_INTERNAL_FUNCTION(void,png_do_read_interlace,(png_row_infop row_info,\n    png_bytep row, int pass, png_uint_32 transformations),PNG_EMPTY);\n#endif\n\n/* GRR TO DO (2.0 or whenever):  simplify other internal calling interfaces */\n\n#ifdef PNG_WRITE_INTERLACING_SUPPORTED\n/* Grab pixels out of a row for an interlaced pass */\nPNG_INTERNAL_FUNCTION(void,png_do_write_interlace,(png_row_infop row_info,\n    png_bytep row, int pass),PNG_EMPTY);\n#endif\n\n/* Unfilter a row: check the filter value before calling this, there is no point\n * calling it for PNG_FILTER_VALUE_NONE.\n */\nPNG_INTERNAL_FUNCTION(void,png_read_filter_row,(png_structrp pp, png_row_infop\n    row_info, png_bytep row, png_const_bytep prev_row, int filter),PNG_EMPTY);\n\nPNG_INTERNAL_FUNCTION(void,png_read_filter_row_up_neon,(png_row_infop row_info,\n    png_bytep row, png_const_bytep prev_row),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub3_neon,(png_row_infop\n    row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub4_neon,(png_row_infop\n    row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_read_filter_row_avg3_neon,(png_row_infop\n    row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_read_filter_row_avg4_neon,(png_row_infop\n    row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth3_neon,(png_row_infop\n    row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth4_neon,(png_row_infop\n    row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);\n\n/* Choose the best filter to use and filter the row data */\nPNG_INTERNAL_FUNCTION(void,png_write_find_filter,(png_structrp png_ptr,\n    png_row_infop row_info),PNG_EMPTY);\n\n#ifdef PNG_SEQUENTIAL_READ_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_read_IDAT_data,(png_structrp png_ptr,\n   png_bytep output, png_alloc_size_t avail_out),PNG_EMPTY);\n   /* Read 'avail_out' bytes of data from the IDAT stream.  If the output buffer\n    * is NULL the function checks, instead, for the end of the stream.  In this\n    * case a benign error will be issued if the stream end is not found or if\n    * extra data has to be consumed.\n    */\nPNG_INTERNAL_FUNCTION(void,png_read_finish_IDAT,(png_structrp png_ptr),\n   PNG_EMPTY);\n   /* This cleans up when the IDAT LZ stream does not end when the last image\n    * byte is read; there is still some pending input.\n    */\n\nPNG_INTERNAL_FUNCTION(void,png_read_finish_row,(png_structrp png_ptr),\n   PNG_EMPTY);\n   /* Finish a row while reading, dealing with interlacing passes, etc. */\n#endif /* PNG_SEQUENTIAL_READ_SUPPORTED */\n\n/* Initialize the row buffers, etc. */\nPNG_INTERNAL_FUNCTION(void,png_read_start_row,(png_structrp png_ptr),PNG_EMPTY);\n\n#ifdef PNG_READ_TRANSFORMS_SUPPORTED\n/* Optional call to update the users info structure */\nPNG_INTERNAL_FUNCTION(void,png_read_transform_info,(png_structrp png_ptr,\n    png_inforp info_ptr),PNG_EMPTY);\n#endif\n\n/* Shared transform functions, defined in pngtran.c */\n#if defined(PNG_WRITE_FILLER_SUPPORTED) || \\\n    defined(PNG_READ_STRIP_ALPHA_SUPPORTED)\nPNG_INTERNAL_FUNCTION(void,png_do_strip_channel,(png_row_infop row_info,\n    png_bytep row, int at_start),PNG_EMPTY);\n#endif\n\n#ifdef PNG_16BIT_SUPPORTED\n#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED)\nPNG_INTERNAL_FUNCTION(void,png_do_swap,(png_row_infop row_info,\n    png_bytep row),PNG_EMPTY);\n#endif\n#endif\n\n#if defined(PNG_READ_PACKSWAP_SUPPORTED) || \\\n    defined(PNG_WRITE_PACKSWAP_SUPPORTED)\nPNG_INTERNAL_FUNCTION(void,png_do_packswap,(png_row_infop row_info,\n    png_bytep row),PNG_EMPTY);\n#endif\n\n#if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED)\nPNG_INTERNAL_FUNCTION(void,png_do_invert,(png_row_infop row_info,\n    png_bytep row),PNG_EMPTY);\n#endif\n\n#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED)\nPNG_INTERNAL_FUNCTION(void,png_do_bgr,(png_row_infop row_info,\n    png_bytep row),PNG_EMPTY);\n#endif\n\n/* The following decodes the appropriate chunks, and does error correction,\n * then calls the appropriate callback for the chunk if it is valid.\n */\n\n/* Decode the IHDR chunk */\nPNG_INTERNAL_FUNCTION(void,png_handle_IHDR,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_handle_PLTE,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_handle_IEND,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\n\n#ifdef PNG_READ_bKGD_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_handle_bKGD,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\n#endif\n\n#ifdef PNG_READ_cHRM_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_handle_cHRM,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\n#endif\n\n#ifdef PNG_READ_gAMA_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_handle_gAMA,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\n#endif\n\n#ifdef PNG_READ_hIST_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_handle_hIST,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\n#endif\n\n#ifdef PNG_READ_iCCP_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_handle_iCCP,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\n#endif /* PNG_READ_iCCP_SUPPORTED */\n\n#ifdef PNG_READ_iTXt_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_handle_iTXt,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\n#endif\n\n#ifdef PNG_READ_oFFs_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_handle_oFFs,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\n#endif\n\n#ifdef PNG_READ_pCAL_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_handle_pCAL,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\n#endif\n\n#ifdef PNG_READ_pHYs_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_handle_pHYs,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\n#endif\n\n#ifdef PNG_READ_sBIT_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_handle_sBIT,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\n#endif\n\n#ifdef PNG_READ_sCAL_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_handle_sCAL,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\n#endif\n\n#ifdef PNG_READ_sPLT_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_handle_sPLT,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\n#endif /* PNG_READ_sPLT_SUPPORTED */\n\n#ifdef PNG_READ_sRGB_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_handle_sRGB,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\n#endif\n\n#ifdef PNG_READ_tEXt_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_handle_tEXt,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\n#endif\n\n#ifdef PNG_READ_tIME_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_handle_tIME,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\n#endif\n\n#ifdef PNG_READ_tRNS_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_handle_tRNS,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\n#endif\n\n#ifdef PNG_READ_zTXt_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_handle_zTXt,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\n#endif\n\nPNG_INTERNAL_FUNCTION(void,png_check_chunk_name,(png_structrp png_ptr,\n    png_uint_32 chunk_name),PNG_EMPTY);\n\nPNG_INTERNAL_FUNCTION(void,png_handle_unknown,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length, int keep),PNG_EMPTY);\n   /* This is the function that gets called for unknown chunks.  The 'keep'\n    * argument is either non-zero for a known chunk that has been set to be\n    * handled as unknown or zero for an unknown chunk.  By default the function\n    * just skips the chunk or errors out if it is critical.\n    */\n\n#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) ||\\\n    defined(PNG_HANDLE_AS_UNKNOWN_SUPPORTED)\nPNG_INTERNAL_FUNCTION(int,png_chunk_unknown_handling,\n    (png_const_structrp png_ptr, png_uint_32 chunk_name),PNG_EMPTY);\n   /* Exactly as the API png_handle_as_unknown() except that the argument is a\n    * 32-bit chunk name, not a string.\n    */\n#endif /* READ_UNKNOWN_CHUNKS || HANDLE_AS_UNKNOWN */\n\n/* Handle the transformations for reading and writing */\n#ifdef PNG_READ_TRANSFORMS_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_do_read_transformations,(png_structrp png_ptr,\n   png_row_infop row_info),PNG_EMPTY);\n#endif\n#ifdef PNG_WRITE_TRANSFORMS_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_do_write_transformations,(png_structrp png_ptr,\n   png_row_infop row_info),PNG_EMPTY);\n#endif\n\n#ifdef PNG_READ_TRANSFORMS_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_init_read_transformations,(png_structrp png_ptr),\n    PNG_EMPTY);\n#endif\n\n#ifdef PNG_PROGRESSIVE_READ_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_push_read_chunk,(png_structrp png_ptr,\n    png_inforp info_ptr),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_push_read_sig,(png_structrp png_ptr,\n    png_inforp info_ptr),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_push_check_crc,(png_structrp png_ptr),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_push_crc_skip,(png_structrp png_ptr,\n    png_uint_32 length),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_push_crc_finish,(png_structrp png_ptr),\n    PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_push_save_buffer,(png_structrp png_ptr),\n    PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_push_restore_buffer,(png_structrp png_ptr,\n    png_bytep buffer, png_size_t buffer_length),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_push_read_IDAT,(png_structrp png_ptr),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_process_IDAT_data,(png_structrp png_ptr,\n    png_bytep buffer, png_size_t buffer_length),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_push_process_row,(png_structrp png_ptr),\n    PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_push_handle_unknown,(png_structrp png_ptr,\n   png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_push_have_info,(png_structrp png_ptr,\n   png_inforp info_ptr),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_push_have_end,(png_structrp png_ptr,\n   png_inforp info_ptr),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_push_have_row,(png_structrp png_ptr,\n     png_bytep row),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_push_read_end,(png_structrp png_ptr,\n    png_inforp info_ptr),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_process_some_data,(png_structrp png_ptr,\n    png_inforp info_ptr),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_read_push_finish_row,(png_structrp png_ptr),\n    PNG_EMPTY);\n#  ifdef PNG_READ_tEXt_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_push_handle_tEXt,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_push_read_tEXt,(png_structrp png_ptr,\n    png_inforp info_ptr),PNG_EMPTY);\n#  endif\n#  ifdef PNG_READ_zTXt_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_push_handle_zTXt,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_push_read_zTXt,(png_structrp png_ptr,\n    png_inforp info_ptr),PNG_EMPTY);\n#  endif\n#  ifdef PNG_READ_iTXt_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_push_handle_iTXt,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_push_read_iTXt,(png_structrp png_ptr,\n    png_inforp info_ptr),PNG_EMPTY);\n#  endif\n\n#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */\n\n/* Added at libpng version 1.6.0 */\n#ifdef PNG_GAMMA_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_colorspace_set_gamma,(png_const_structrp png_ptr,\n    png_colorspacerp colorspace, png_fixed_point gAMA), PNG_EMPTY);\n   /* Set the colorspace gamma with a value provided by the application or by\n    * the gAMA chunk on read.  The value will override anything set by an ICC\n    * profile.\n    */\n\nPNG_INTERNAL_FUNCTION(void,png_colorspace_sync_info,(png_const_structrp png_ptr,\n    png_inforp info_ptr), PNG_EMPTY);\n    /* Synchronize the info 'valid' flags with the colorspace */\n\nPNG_INTERNAL_FUNCTION(void,png_colorspace_sync,(png_const_structrp png_ptr,\n    png_inforp info_ptr), PNG_EMPTY);\n    /* Copy the png_struct colorspace to the info_struct and call the above to\n     * synchronize the flags.  Checks for NULL info_ptr and does nothing.\n     */\n#endif\n\n/* Added at libpng version 1.4.0 */\n#ifdef PNG_COLORSPACE_SUPPORTED\n/* These internal functions are for maintaining the colorspace structure within\n * a png_info or png_struct (or, indeed, both).\n */\nPNG_INTERNAL_FUNCTION(int,png_colorspace_set_chromaticities,\n   (png_const_structrp png_ptr, png_colorspacerp colorspace, const png_xy *xy,\n    int preferred), PNG_EMPTY);\n\nPNG_INTERNAL_FUNCTION(int,png_colorspace_set_endpoints,\n   (png_const_structrp png_ptr, png_colorspacerp colorspace, const png_XYZ *XYZ,\n    int preferred), PNG_EMPTY);\n\n#ifdef PNG_sRGB_SUPPORTED\nPNG_INTERNAL_FUNCTION(int,png_colorspace_set_sRGB,(png_const_structrp png_ptr,\n   png_colorspacerp colorspace, int intent), PNG_EMPTY);\n   /* This does set the colorspace gAMA and cHRM values too, but doesn't set the\n    * flags to write them, if it returns false there was a problem and an error\n    * message has already been output (but the colorspace may still need to be\n    * synced to record the invalid flag).\n    */\n#endif /* sRGB */\n\n#ifdef PNG_iCCP_SUPPORTED\nPNG_INTERNAL_FUNCTION(int,png_colorspace_set_ICC,(png_const_structrp png_ptr,\n   png_colorspacerp colorspace, png_const_charp name,\n   png_uint_32 profile_length, png_const_bytep profile, int color_type),\n   PNG_EMPTY);\n   /* The 'name' is used for information only */\n\n/* Routines for checking parts of an ICC profile. */\nPNG_INTERNAL_FUNCTION(int,png_icc_check_length,(png_const_structrp png_ptr,\n   png_colorspacerp colorspace, png_const_charp name,\n   png_uint_32 profile_length), PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(int,png_icc_check_header,(png_const_structrp png_ptr,\n   png_colorspacerp colorspace, png_const_charp name,\n   png_uint_32 profile_length,\n   png_const_bytep profile /* first 132 bytes only */, int color_type),\n   PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(int,png_icc_check_tag_table,(png_const_structrp png_ptr,\n   png_colorspacerp colorspace, png_const_charp name,\n   png_uint_32 profile_length,\n   png_const_bytep profile /* header plus whole tag table */), PNG_EMPTY);\n#ifdef PNG_sRGB_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_icc_set_sRGB,(\n   png_const_structrp png_ptr, png_colorspacerp colorspace,\n   png_const_bytep profile, uLong adler), PNG_EMPTY);\n   /* 'adler' is the Adler32 checksum of the uncompressed profile data. It may\n    * be zero to indicate that it is not available.  It is used, if provided,\n    * as a fast check on the profile when checking to see if it is sRGB.\n    */\n#endif\n#endif /* iCCP */\n\n#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_colorspace_set_rgb_coefficients,\n   (png_structrp png_ptr), PNG_EMPTY);\n   /* Set the rgb_to_gray coefficients from the colorspace Y values */\n#endif /* READ_RGB_TO_GRAY */\n#endif /* COLORSPACE */\n\n/* Added at libpng version 1.4.0 */\nPNG_INTERNAL_FUNCTION(void,png_check_IHDR,(png_const_structrp png_ptr,\n    png_uint_32 width, png_uint_32 height, int bit_depth,\n    int color_type, int interlace_type, int compression_type,\n    int filter_type),PNG_EMPTY);\n\n/* Added at libpng version 1.5.10 */\n#if defined(PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED) || \\\n    defined(PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED)\nPNG_INTERNAL_FUNCTION(void,png_do_check_palette_indexes,\n   (png_structrp png_ptr, png_row_infop row_info),PNG_EMPTY);\n#endif\n\n#if defined(PNG_FLOATING_POINT_SUPPORTED) && defined(PNG_ERROR_TEXT_SUPPORTED)\nPNG_INTERNAL_FUNCTION(void,png_fixed_error,(png_const_structrp png_ptr,\n   png_const_charp name),PNG_NORETURN);\n#endif\n\n/* Puts 'string' into 'buffer' at buffer[pos], taking care never to overwrite\n * the end.  Always leaves the buffer nul terminated.  Never errors out (and\n * there is no error code.)\n */\nPNG_INTERNAL_FUNCTION(size_t,png_safecat,(png_charp buffer, size_t bufsize,\n   size_t pos, png_const_charp string),PNG_EMPTY);\n\n/* Various internal functions to handle formatted warning messages, currently\n * only implemented for warnings.\n */\n#if defined(PNG_WARNINGS_SUPPORTED) || defined(PNG_TIME_RFC1123_SUPPORTED)\n/* Utility to dump an unsigned value into a buffer, given a start pointer and\n * and end pointer (which should point just *beyond* the end of the buffer!)\n * Returns the pointer to the start of the formatted string.  This utility only\n * does unsigned values.\n */\nPNG_INTERNAL_FUNCTION(png_charp,png_format_number,(png_const_charp start,\n   png_charp end, int format, png_alloc_size_t number),PNG_EMPTY);\n\n/* Convenience macro that takes an array: */\n#define PNG_FORMAT_NUMBER(buffer,format,number) \\\n   png_format_number(buffer, buffer + (sizeof buffer), format, number)\n\n/* Suggested size for a number buffer (enough for 64 bits and a sign!) */\n#define PNG_NUMBER_BUFFER_SIZE 24\n\n/* These are the integer formats currently supported, the name is formed from\n * the standard printf(3) format string.\n */\n#define PNG_NUMBER_FORMAT_u     1 /* chose unsigned API! */\n#define PNG_NUMBER_FORMAT_02u   2\n#define PNG_NUMBER_FORMAT_d     1 /* chose signed API! */\n#define PNG_NUMBER_FORMAT_02d   2\n#define PNG_NUMBER_FORMAT_x     3\n#define PNG_NUMBER_FORMAT_02x   4\n#define PNG_NUMBER_FORMAT_fixed 5 /* choose the signed API */\n#endif\n\n#ifdef PNG_WARNINGS_SUPPORTED\n/* New defines and members adding in libpng-1.5.4 */\n#  define PNG_WARNING_PARAMETER_SIZE 32\n#  define PNG_WARNING_PARAMETER_COUNT 8 /* Maximum 9; see pngerror.c */\n\n/* An l-value of this type has to be passed to the APIs below to cache the\n * values of the parameters to a formatted warning message.\n */\ntypedef char png_warning_parameters[PNG_WARNING_PARAMETER_COUNT][\n   PNG_WARNING_PARAMETER_SIZE];\n\nPNG_INTERNAL_FUNCTION(void,png_warning_parameter,(png_warning_parameters p,\n   int number, png_const_charp string),PNG_EMPTY);\n   /* Parameters are limited in size to PNG_WARNING_PARAMETER_SIZE characters,\n    * including the trailing '\\0'.\n    */\nPNG_INTERNAL_FUNCTION(void,png_warning_parameter_unsigned,\n   (png_warning_parameters p, int number, int format, png_alloc_size_t value),\n   PNG_EMPTY);\n   /* Use png_alloc_size_t because it is an unsigned type as big as any we\n    * need to output.  Use the following for a signed value.\n    */\nPNG_INTERNAL_FUNCTION(void,png_warning_parameter_signed,\n   (png_warning_parameters p, int number, int format, png_int_32 value),\n   PNG_EMPTY);\n\nPNG_INTERNAL_FUNCTION(void,png_formatted_warning,(png_const_structrp png_ptr,\n   png_warning_parameters p, png_const_charp message),PNG_EMPTY);\n   /* 'message' follows the X/Open approach of using @1, @2 to insert\n    * parameters previously supplied using the above functions.  Errors in\n    * specifying the parameters will simply result in garbage substitutions.\n    */\n#endif\n\n#ifdef PNG_BENIGN_ERRORS_SUPPORTED\n/* Application errors (new in 1.6); use these functions (declared below) for\n * errors in the parameters or order of API function calls on read.  The\n * 'warning' should be used for an error that can be handled completely; the\n * 'error' for one which can be handled safely but which may lose application\n * information or settings.\n *\n * By default these both result in a png_error call prior to release, while in a\n * released version the 'warning' is just a warning.  However if the application\n * explicitly disables benign errors (explicitly permitting the code to lose\n * information) they both turn into warnings.\n *\n * If benign errors aren't supported they end up as the corresponding base call\n * (png_warning or png_error.)\n */\nPNG_INTERNAL_FUNCTION(void,png_app_warning,(png_const_structrp png_ptr,\n   png_const_charp message),PNG_EMPTY);\n   /* The application provided invalid parameters to an API function or called\n    * an API function at the wrong time, libpng can completely recover.\n    */\n\nPNG_INTERNAL_FUNCTION(void,png_app_error,(png_const_structrp png_ptr,\n   png_const_charp message),PNG_EMPTY);\n   /* As above but libpng will ignore the call, or attempt some other partial\n    * recovery from the error.\n    */\n#else\n#  define png_app_warning(pp,s) png_warning(pp,s)\n#  define png_app_error(pp,s) png_error(pp,s)\n#endif\n\nPNG_INTERNAL_FUNCTION(void,png_chunk_report,(png_const_structrp png_ptr,\n   png_const_charp message, int error),PNG_EMPTY);\n   /* Report a recoverable issue in chunk data.  On read this is used to report\n    * a problem found while reading a particular chunk and the\n    * png_chunk_benign_error or png_chunk_warning function is used as\n    * appropriate.  On write this is used to report an error that comes from\n    * data set via an application call to a png_set_ API and png_app_error or\n    * png_app_warning is used as appropriate.\n    *\n    * The 'error' parameter must have one of the following values:\n    */\n#define PNG_CHUNK_WARNING     0 /* never an error */\n#define PNG_CHUNK_WRITE_ERROR 1 /* an error only on write */\n#define PNG_CHUNK_ERROR       2 /* always an error */\n\n/* ASCII to FP interfaces, currently only implemented if sCAL\n * support is required.\n */\n#if defined(PNG_sCAL_SUPPORTED)\n/* MAX_DIGITS is actually the maximum number of characters in an sCAL\n * width or height, derived from the precision (number of significant\n * digits - a build time settable option) and assumptions about the\n * maximum ridiculous exponent.\n */\n#define PNG_sCAL_MAX_DIGITS (PNG_sCAL_PRECISION+1/*.*/+1/*E*/+10/*exponent*/)\n\n#ifdef PNG_FLOATING_POINT_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_ascii_from_fp,(png_const_structrp png_ptr,\n   png_charp ascii, png_size_t size, double fp, unsigned int precision),\n   PNG_EMPTY);\n#endif /* FLOATING_POINT */\n\n#ifdef PNG_FIXED_POINT_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_ascii_from_fixed,(png_const_structrp png_ptr,\n   png_charp ascii, png_size_t size, png_fixed_point fp),PNG_EMPTY);\n#endif /* FIXED_POINT */\n#endif /* sCAL */\n\n#if defined(PNG_sCAL_SUPPORTED) || defined(PNG_pCAL_SUPPORTED)\n/* An internal API to validate the format of a floating point number.\n * The result is the index of the next character.  If the number is\n * not valid it will be the index of a character in the supposed number.\n *\n * The format of a number is defined in the PNG extensions specification\n * and this API is strictly conformant to that spec, not anyone elses!\n *\n * The format as a regular expression is:\n *\n * [+-]?[0-9]+.?([Ee][+-]?[0-9]+)?\n *\n * or:\n *\n * [+-]?.[0-9]+(.[0-9]+)?([Ee][+-]?[0-9]+)?\n *\n * The complexity is that either integer or fraction must be present and the\n * fraction is permitted to have no digits only if the integer is present.\n *\n * NOTE: The dangling E problem.\n *   There is a PNG valid floating point number in the following:\n *\n *       PNG floating point numbers are not greedy.\n *\n *   Working this out requires *TWO* character lookahead (because of the\n *   sign), the parser does not do this - it will fail at the 'r' - this\n *   doesn't matter for PNG sCAL chunk values, but it requires more care\n *   if the value were ever to be embedded in something more complex.  Use\n *   ANSI-C strtod if you need the lookahead.\n */\n/* State table for the parser. */\n#define PNG_FP_INTEGER    0  /* before or in integer */\n#define PNG_FP_FRACTION   1  /* before or in fraction */\n#define PNG_FP_EXPONENT   2  /* before or in exponent */\n#define PNG_FP_STATE      3  /* mask for the above */\n#define PNG_FP_SAW_SIGN   4  /* Saw +/- in current state */\n#define PNG_FP_SAW_DIGIT  8  /* Saw a digit in current state */\n#define PNG_FP_SAW_DOT   16  /* Saw a dot in current state */\n#define PNG_FP_SAW_E     32  /* Saw an E (or e) in current state */\n#define PNG_FP_SAW_ANY   60  /* Saw any of the above 4 */\n\n/* These three values don't affect the parser.  They are set but not used.\n */\n#define PNG_FP_WAS_VALID 64  /* Preceding substring is a valid fp number */\n#define PNG_FP_NEGATIVE 128  /* A negative number, including \"-0\" */\n#define PNG_FP_NONZERO  256  /* A non-zero value */\n#define PNG_FP_STICKY   448  /* The above three flags */\n\n/* This is available for the caller to store in 'state' if required.  Do not\n * call the parser after setting it (the parser sometimes clears it.)\n */\n#define PNG_FP_INVALID  512  /* Available for callers as a distinct value */\n\n/* Result codes for the parser (boolean - true meants ok, false means\n * not ok yet.)\n */\n#define PNG_FP_MAYBE      0  /* The number may be valid in the future */\n#define PNG_FP_OK         1  /* The number is valid */\n\n/* Tests on the sticky non-zero and negative flags.  To pass these checks\n * the state must also indicate that the whole number is valid - this is\n * achieved by testing PNG_FP_SAW_DIGIT (see the implementation for why this\n * is equivalent to PNG_FP_OK above.)\n */\n#define PNG_FP_NZ_MASK (PNG_FP_SAW_DIGIT | PNG_FP_NEGATIVE | PNG_FP_NONZERO)\n   /* NZ_MASK: the string is valid and a non-zero negative value */\n#define PNG_FP_Z_MASK (PNG_FP_SAW_DIGIT | PNG_FP_NONZERO)\n   /* Z MASK: the string is valid and a non-zero value. */\n   /* PNG_FP_SAW_DIGIT: the string is valid. */\n#define PNG_FP_IS_ZERO(state) (((state) & PNG_FP_Z_MASK) == PNG_FP_SAW_DIGIT)\n#define PNG_FP_IS_POSITIVE(state) (((state) & PNG_FP_NZ_MASK) == PNG_FP_Z_MASK)\n#define PNG_FP_IS_NEGATIVE(state) (((state) & PNG_FP_NZ_MASK) == PNG_FP_NZ_MASK)\n\n/* The actual parser.  This can be called repeatedly. It updates\n * the index into the string and the state variable (which must\n * be initialized to 0).  It returns a result code, as above.  There\n * is no point calling the parser any more if it fails to advance to\n * the end of the string - it is stuck on an invalid character (or\n * terminated by '\\0').\n *\n * Note that the pointer will consume an E or even an E+ and then leave\n * a 'maybe' state even though a preceding integer.fraction is valid.\n * The PNG_FP_WAS_VALID flag indicates that a preceding substring was\n * a valid number.  It's possible to recover from this by calling\n * the parser again (from the start, with state 0) but with a string\n * that omits the last character (i.e. set the size to the index of\n * the problem character.)  This has not been tested within libpng.\n */\nPNG_INTERNAL_FUNCTION(int,png_check_fp_number,(png_const_charp string,\n   png_size_t size, int *statep, png_size_tp whereami),PNG_EMPTY);\n\n/* This is the same but it checks a complete string and returns true\n * only if it just contains a floating point number.  As of 1.5.4 this\n * function also returns the state at the end of parsing the number if\n * it was valid (otherwise it returns 0.)  This can be used for testing\n * for negative or zero values using the sticky flag.\n */\nPNG_INTERNAL_FUNCTION(int,png_check_fp_string,(png_const_charp string,\n   png_size_t size),PNG_EMPTY);\n#endif /* pCAL || sCAL */\n\n#if defined(PNG_GAMMA_SUPPORTED) ||\\\n    defined(PNG_INCH_CONVERSIONS_SUPPORTED) || defined(PNG_READ_pHYs_SUPPORTED)\n/* Added at libpng version 1.5.0 */\n/* This is a utility to provide a*times/div (rounded) and indicate\n * if there is an overflow.  The result is a boolean - false (0)\n * for overflow, true (1) if no overflow, in which case *res\n * holds the result.\n */\nPNG_INTERNAL_FUNCTION(int,png_muldiv,(png_fixed_point_p res, png_fixed_point a,\n   png_int_32 multiplied_by, png_int_32 divided_by),PNG_EMPTY);\n#endif\n\n#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_INCH_CONVERSIONS_SUPPORTED)\n/* Same deal, but issue a warning on overflow and return 0. */\nPNG_INTERNAL_FUNCTION(png_fixed_point,png_muldiv_warn,\n   (png_const_structrp png_ptr, png_fixed_point a, png_int_32 multiplied_by,\n   png_int_32 divided_by),PNG_EMPTY);\n#endif\n\n#ifdef PNG_GAMMA_SUPPORTED\n/* Calculate a reciprocal - used for gamma values.  This returns\n * 0 if the argument is 0 in order to maintain an undefined value;\n * there are no warnings.\n */\nPNG_INTERNAL_FUNCTION(png_fixed_point,png_reciprocal,(png_fixed_point a),\n   PNG_EMPTY);\n\n#ifdef PNG_READ_GAMMA_SUPPORTED\n/* The same but gives a reciprocal of the product of two fixed point\n * values.  Accuracy is suitable for gamma calculations but this is\n * not exact - use png_muldiv for that.  Only required at present on read.\n */\nPNG_INTERNAL_FUNCTION(png_fixed_point,png_reciprocal2,(png_fixed_point a,\n   png_fixed_point b),PNG_EMPTY);\n#endif\n\n/* Return true if the gamma value is significantly different from 1.0 */\nPNG_INTERNAL_FUNCTION(int,png_gamma_significant,(png_fixed_point gamma_value),\n   PNG_EMPTY);\n#endif\n\n#ifdef PNG_READ_GAMMA_SUPPORTED\n/* Internal fixed point gamma correction.  These APIs are called as\n * required to convert single values - they don't need to be fast,\n * they are not used when processing image pixel values.\n *\n * While the input is an 'unsigned' value it must actually be the\n * correct bit value - 0..255 or 0..65535 as required.\n */\nPNG_INTERNAL_FUNCTION(png_uint_16,png_gamma_correct,(png_structrp png_ptr,\n   unsigned int value, png_fixed_point gamma_value),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(png_uint_16,png_gamma_16bit_correct,(unsigned int value,\n   png_fixed_point gamma_value),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(png_byte,png_gamma_8bit_correct,(unsigned int value,\n   png_fixed_point gamma_value),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_destroy_gamma_table,(png_structrp png_ptr),\n   PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_build_gamma_table,(png_structrp png_ptr,\n   int bit_depth),PNG_EMPTY);\n#endif\n\n/* SIMPLIFIED READ/WRITE SUPPORT */\n#if defined(PNG_SIMPLIFIED_READ_SUPPORTED) ||\\\n   defined(PNG_SIMPLIFIED_WRITE_SUPPORTED)\n/* The internal structure that png_image::opaque points to. */\ntypedef struct png_control\n{\n   png_structp png_ptr;\n   png_infop   info_ptr;\n   png_voidp   error_buf;           /* Always a jmp_buf at present. */\n\n   png_const_bytep memory;          /* Memory buffer. */\n   png_size_t      size;            /* Size of the memory buffer. */\n\n   unsigned int for_write       :1; /* Otherwise it is a read structure */\n   unsigned int owned_file      :1; /* We own the file in io_ptr */\n} png_control;\n\n/* Return the pointer to the jmp_buf from a png_control: necessary because C\n * does not reveal the type of the elements of jmp_buf.\n */\n#ifdef __cplusplus\n#  define png_control_jmp_buf(pc) (((jmp_buf*)((pc)->error_buf))[0])\n#else\n#  define png_control_jmp_buf(pc) ((pc)->error_buf)\n#endif\n\n/* Utility to safely execute a piece of libpng code catching and logging any\n * errors that might occur.  Returns true on success, false on failure (either\n * of the function or as a result of a png_error.)\n */\nPNG_INTERNAL_CALLBACK(void,png_safe_error,(png_structp png_ptr,\n   png_const_charp error_message),PNG_NORETURN);\n\n#ifdef PNG_WARNINGS_SUPPORTED\nPNG_INTERNAL_CALLBACK(void,png_safe_warning,(png_structp png_ptr,\n   png_const_charp warning_message),PNG_EMPTY);\n#else\n#  define png_safe_warning 0/*dummy argument*/\n#endif\n\nPNG_INTERNAL_FUNCTION(int,png_safe_execute,(png_imagep image,\n   int (*function)(png_voidp), png_voidp arg),PNG_EMPTY);\n\n/* Utility to log an error; this also cleans up the png_image; the function\n * always returns 0 (false).\n */\nPNG_INTERNAL_FUNCTION(int,png_image_error,(png_imagep image,\n   png_const_charp error_message),PNG_EMPTY);\n\n#ifndef PNG_SIMPLIFIED_READ_SUPPORTED\n/* png_image_free is used by the write code but not exported */\nPNG_INTERNAL_FUNCTION(void, png_image_free, (png_imagep image), PNG_EMPTY);\n#endif /* !SIMPLIFIED_READ */\n\n#endif /* SIMPLIFIED READ/WRITE */\n\n/* These are initialization functions for hardware specific PNG filter\n * optimizations; list these here then select the appropriate one at compile\n * time using the macro PNG_FILTER_OPTIMIZATIONS.  If the macro is not defined\n * the generic code is used.\n */\n#ifdef PNG_FILTER_OPTIMIZATIONS\nPNG_INTERNAL_FUNCTION(void, PNG_FILTER_OPTIMIZATIONS, (png_structp png_ptr,\n   unsigned int bpp), PNG_EMPTY);\n   /* Just declare the optimization that will be used */\n#else\n   /* List *all* the possible optimizations here - this branch is required if\n    * the builder of libpng passes the definition of PNG_FILTER_OPTIMIZATIONS in\n    * CFLAGS in place of CPPFLAGS *and* uses symbol prefixing.\n    */\nPNG_INTERNAL_FUNCTION(void, png_init_filter_functions_neon,\n   (png_structp png_ptr, unsigned int bpp), PNG_EMPTY);\n#endif\n\n/* Maintainer: Put new private prototypes here ^ */\n\n#include \"pngdebug.h\"\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* PNG_VERSION_INFO_ONLY */\n#endif /* PNGPRIV_H */\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/png/pngstruct.h",
    "content": "\n/* pngstruct.h - header file for PNG reference library\n *\n * Copyright (c) 1998-2013 Glenn Randers-Pehrson\n * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)\n * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)\n *\n * Last changed in libpng 1.6.1 [March 28, 2013]\n *\n * This code is released under the libpng license.\n * For conditions of distribution and use, see the disclaimer\n * and license in png.h\n */\n\n/* The structure that holds the information to read and write PNG files.\n * The only people who need to care about what is inside of this are the\n * people who will be modifying the library for their own special needs.\n * It should NOT be accessed directly by an application.\n */\n\n#ifndef PNGSTRUCT_H\n#define PNGSTRUCT_H\n/* zlib.h defines the structure z_stream, an instance of which is included\n * in this structure and is required for decompressing the LZ compressed\n * data in PNG files.\n */\n#ifndef ZLIB_CONST\n   /* We must ensure that zlib uses 'const' in declarations. */\n#  define ZLIB_CONST\n#endif\n#include \"zlib.h\"\n#ifdef const\n   /* zlib.h sometimes #defines const to nothing, undo this. */\n#  undef const\n#endif\n\n/* zlib.h has mediocre z_const use before 1.2.6, this stuff is for compatibility\n * with older builds.\n */\n#if ZLIB_VERNUM < 0x1260\n#  define PNGZ_MSG_CAST(s) png_constcast(char*,s)\n#  define PNGZ_INPUT_CAST(b) png_constcast(png_bytep,b)\n#else\n#  define PNGZ_MSG_CAST(s) (s)\n#  define PNGZ_INPUT_CAST(b) (b)\n#endif\n\n/* zlib.h declares a magic type 'uInt' that limits the amount of data that zlib\n * can handle at once.  This type need be no larger than 16 bits (so maximum of\n * 65535), this define allows us to discover how big it is, but limited by the\n * maximuum for png_size_t.  The value can be overriden in a library build\n * (pngusr.h, or set it in CPPFLAGS) and it works to set it to a considerably\n * lower value (e.g. 255 works).  A lower value may help memory usage (slightly)\n * and may even improve performance on some systems (and degrade it on others.)\n */\n#ifndef ZLIB_IO_MAX\n#  define ZLIB_IO_MAX ((uInt)-1)\n#endif\n\n#ifdef PNG_WRITE_SUPPORTED\n/* The type of a compression buffer list used by the write code. */\ntypedef struct png_compression_buffer\n{\n   struct png_compression_buffer *next;\n   png_byte                       output[1]; /* actually zbuf_size */\n} png_compression_buffer, *png_compression_bufferp;\n\n#define PNG_COMPRESSION_BUFFER_SIZE(pp)\\\n   (offsetof(png_compression_buffer, output) + (pp)->zbuffer_size)\n#endif\n\n/* Colorspace support; structures used in png_struct, png_info and in internal\n * functions to hold and communicate information about the color space.\n *\n * PNG_COLORSPACE_SUPPORTED is only required if the application will perform\n * colorspace corrections, otherwise all the colorspace information can be\n * skipped and the size of libpng can be reduced (significantly) by compiling\n * out the colorspace support.\n */\n#ifdef PNG_COLORSPACE_SUPPORTED\n/* The chromaticities of the red, green and blue colorants and the chromaticity\n * of the corresponding white point (i.e. of rgb(1.0,1.0,1.0)).\n */\ntypedef struct png_xy\n{\n   png_fixed_point redx, redy;\n   png_fixed_point greenx, greeny;\n   png_fixed_point bluex, bluey;\n   png_fixed_point whitex, whitey;\n} png_xy;\n\n/* The same data as above but encoded as CIE XYZ values.  When this data comes\n * from chromaticities the sum of the Y values is assumed to be 1.0\n */\ntypedef struct png_XYZ\n{\n   png_fixed_point red_X, red_Y, red_Z;\n   png_fixed_point green_X, green_Y, green_Z;\n   png_fixed_point blue_X, blue_Y, blue_Z;\n} png_XYZ;\n#endif /* COLORSPACE */\n\n#if defined(PNG_COLORSPACE_SUPPORTED) || defined(PNG_GAMMA_SUPPORTED)\n/* A colorspace is all the above plus, potentially, profile information,\n * however at present libpng does not use the profile internally so it is only\n * stored in the png_info struct (if iCCP is supported.)  The rendering intent\n * is retained here and is checked.\n *\n * The file gamma encoding information is also stored here and gamma correction\n * is done by libpng, whereas color correction must currently be done by the\n * application.\n */\ntypedef struct png_colorspace\n{\n#ifdef PNG_GAMMA_SUPPORTED\n   png_fixed_point gamma;        /* File gamma */\n#endif\n\n#ifdef PNG_COLORSPACE_SUPPORTED\n   png_xy      end_points_xy;    /* End points as chromaticities */\n   png_XYZ     end_points_XYZ;   /* End points as CIE XYZ colorant values */\n   png_uint_16 rendering_intent; /* Rendering intent of a profile */\n#endif\n\n   /* Flags are always defined to simplify the code. */\n   png_uint_16 flags;            /* As defined below */\n} png_colorspace, * PNG_RESTRICT png_colorspacerp;\n\ntypedef const png_colorspace * PNG_RESTRICT png_const_colorspacerp;\n\n/* General flags for the 'flags' field */\n#define PNG_COLORSPACE_HAVE_GAMMA           0x0001\n#define PNG_COLORSPACE_HAVE_ENDPOINTS       0x0002\n#define PNG_COLORSPACE_HAVE_INTENT          0x0004\n#define PNG_COLORSPACE_FROM_gAMA            0x0008\n#define PNG_COLORSPACE_FROM_cHRM            0x0010\n#define PNG_COLORSPACE_FROM_sRGB            0x0020\n#define PNG_COLORSPACE_ENDPOINTS_MATCH_sRGB 0x0040\n#define PNG_COLORSPACE_MATCHES_sRGB         0x0080 /* exact match on profile */\n#define PNG_COLORSPACE_INVALID              0x8000\n#define PNG_COLORSPACE_CANCEL(flags)        (0xffff ^ (flags))\n#endif /* COLORSPACE || GAMMA */\n\nstruct png_struct_def\n{\n#ifdef PNG_SETJMP_SUPPORTED\n   jmp_buf jmp_buf_local;     /* New name in 1.6.0 for jmp_buf in png_struct */\n   png_longjmp_ptr longjmp_fn;/* setjmp non-local goto function. */\n   jmp_buf *jmp_buf_ptr;      /* passed to longjmp_fn */\n   size_t jmp_buf_size;       /* size of the above, if allocated */\n#endif\n   png_error_ptr error_fn;    /* function for printing errors and aborting */\n#ifdef PNG_WARNINGS_SUPPORTED\n   png_error_ptr warning_fn;  /* function for printing warnings */\n#endif\n   png_voidp error_ptr;       /* user supplied struct for error functions */\n   png_rw_ptr write_data_fn;  /* function for writing output data */\n   png_rw_ptr read_data_fn;   /* function for reading input data */\n   png_voidp io_ptr;          /* ptr to application struct for I/O functions */\n\n#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED\n   png_user_transform_ptr read_user_transform_fn; /* user read transform */\n#endif\n\n#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED\n   png_user_transform_ptr write_user_transform_fn; /* user write transform */\n#endif\n\n/* These were added in libpng-1.0.2 */\n#ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED\n#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \\\n    defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)\n   png_voidp user_transform_ptr; /* user supplied struct for user transform */\n   png_byte user_transform_depth;    /* bit depth of user transformed pixels */\n   png_byte user_transform_channels; /* channels in user transformed pixels */\n#endif\n#endif\n\n   png_uint_32 mode;          /* tells us where we are in the PNG file */\n   png_uint_32 flags;         /* flags indicating various things to libpng */\n   png_uint_32 transformations; /* which transformations to perform */\n\n   png_uint_32 zowner;        /* ID (chunk type) of zstream owner, 0 if none */\n   z_stream    zstream;       /* decompression structure */\n\n#ifdef PNG_WRITE_SUPPORTED\n   png_compression_bufferp zbuffer_list; /* Created on demand during write */\n   uInt                    zbuffer_size; /* size of the actual buffer */\n\n   int zlib_level;            /* holds zlib compression level */\n   int zlib_method;           /* holds zlib compression method */\n   int zlib_window_bits;      /* holds zlib compression window bits */\n   int zlib_mem_level;        /* holds zlib compression memory level */\n   int zlib_strategy;         /* holds zlib compression strategy */\n#endif\n/* Added at libpng 1.5.4 */\n#ifdef PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED\n   int zlib_text_level;            /* holds zlib compression level */\n   int zlib_text_method;           /* holds zlib compression method */\n   int zlib_text_window_bits;      /* holds zlib compression window bits */\n   int zlib_text_mem_level;        /* holds zlib compression memory level */\n   int zlib_text_strategy;         /* holds zlib compression strategy */\n#endif\n/* End of material added at libpng 1.5.4 */\n/* Added at libpng 1.6.0 */\n#ifdef PNG_WRITE_SUPPORTED\n   int zlib_set_level;        /* Actual values set into the zstream on write */\n   int zlib_set_method;\n   int zlib_set_window_bits;\n   int zlib_set_mem_level;\n   int zlib_set_strategy;\n#endif\n\n   png_uint_32 width;         /* width of image in pixels */\n   png_uint_32 height;        /* height of image in pixels */\n   png_uint_32 num_rows;      /* number of rows in current pass */\n   png_uint_32 usr_width;     /* width of row at start of write */\n   png_size_t rowbytes;       /* size of row in bytes */\n   png_uint_32 iwidth;        /* width of current interlaced row in pixels */\n   png_uint_32 row_number;    /* current row in interlace pass */\n   png_uint_32 chunk_name;    /* PNG_CHUNK() id of current chunk */\n   png_bytep prev_row;        /* buffer to save previous (unfiltered) row.\n                               * This is a pointer into big_prev_row\n                               */\n   png_bytep row_buf;         /* buffer to save current (unfiltered) row.\n                               * This is a pointer into big_row_buf\n                               */\n#ifdef PNG_WRITE_SUPPORTED\n   png_bytep sub_row;         /* buffer to save \"sub\" row when filtering */\n   png_bytep up_row;          /* buffer to save \"up\" row when filtering */\n   png_bytep avg_row;         /* buffer to save \"avg\" row when filtering */\n   png_bytep paeth_row;       /* buffer to save \"Paeth\" row when filtering */\n#endif\n   png_size_t info_rowbytes;  /* Added in 1.5.4: cache of updated row bytes */\n\n   png_uint_32 idat_size;     /* current IDAT size for read */\n   png_uint_32 crc;           /* current chunk CRC value */\n   png_colorp palette;        /* palette from the input file */\n   png_uint_16 num_palette;   /* number of color entries in palette */\n\n/* Added at libpng-1.5.10 */\n#ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED\n   int num_palette_max;       /* maximum palette index found in IDAT */\n#endif\n\n   png_uint_16 num_trans;     /* number of transparency values */\n   png_byte compression;      /* file compression type (always 0) */\n   png_byte filter;           /* file filter type (always 0) */\n   png_byte interlaced;       /* PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */\n   png_byte pass;             /* current interlace pass (0 - 6) */\n   png_byte do_filter;        /* row filter flags (see PNG_FILTER_ below ) */\n   png_byte color_type;       /* color type of file */\n   png_byte bit_depth;        /* bit depth of file */\n   png_byte usr_bit_depth;    /* bit depth of users row: write only */\n   png_byte pixel_depth;      /* number of bits per pixel */\n   png_byte channels;         /* number of channels in file */\n#ifdef PNG_WRITE_SUPPORTED\n   png_byte usr_channels;     /* channels at start of write: write only */\n#endif\n   png_byte sig_bytes;        /* magic bytes read/written from start of file */\n   png_byte maximum_pixel_depth;\n                              /* pixel depth used for the row buffers */\n   png_byte transformed_pixel_depth;\n                              /* pixel depth after read/write transforms */\n#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED)\n   png_uint_16 filler;           /* filler bytes for pixel expansion */\n#endif\n\n#if defined(PNG_bKGD_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) ||\\\n   defined(PNG_READ_ALPHA_MODE_SUPPORTED)\n   png_byte background_gamma_type;\n   png_fixed_point background_gamma;\n   png_color_16 background;   /* background color in screen gamma space */\n#ifdef PNG_READ_GAMMA_SUPPORTED\n   png_color_16 background_1; /* background normalized to gamma 1.0 */\n#endif\n#endif /* PNG_bKGD_SUPPORTED */\n\n#ifdef PNG_WRITE_FLUSH_SUPPORTED\n   png_flush_ptr output_flush_fn; /* Function for flushing output */\n   png_uint_32 flush_dist;    /* how many rows apart to flush, 0 - no flush */\n   png_uint_32 flush_rows;    /* number of rows written since last flush */\n#endif\n\n#ifdef PNG_READ_GAMMA_SUPPORTED\n   int gamma_shift;      /* number of \"insignificant\" bits in 16-bit gamma */\n   png_fixed_point screen_gamma; /* screen gamma value (display_exponent) */\n\n   png_bytep gamma_table;     /* gamma table for 8-bit depth files */\n   png_uint_16pp gamma_16_table; /* gamma table for 16-bit depth files */\n#if defined(PNG_READ_BACKGROUND_SUPPORTED) || \\\n   defined(PNG_READ_ALPHA_MODE_SUPPORTED) || \\\n   defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)\n   png_bytep gamma_from_1;    /* converts from 1.0 to screen */\n   png_bytep gamma_to_1;      /* converts from file to 1.0 */\n   png_uint_16pp gamma_16_from_1; /* converts from 1.0 to screen */\n   png_uint_16pp gamma_16_to_1; /* converts from file to 1.0 */\n#endif /* READ_BACKGROUND || READ_ALPHA_MODE || RGB_TO_GRAY */\n#endif\n\n#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_sBIT_SUPPORTED)\n   png_color_8 sig_bit;       /* significant bits in each available channel */\n#endif\n\n#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED)\n   png_color_8 shift;         /* shift for significant bit tranformation */\n#endif\n\n#if defined(PNG_tRNS_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) \\\n || defined(PNG_READ_EXPAND_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)\n   png_bytep trans_alpha;           /* alpha values for paletted files */\n   png_color_16 trans_color;  /* transparent color for non-paletted files */\n#endif\n\n   png_read_status_ptr read_row_fn;   /* called after each row is decoded */\n   png_write_status_ptr write_row_fn; /* called after each row is encoded */\n#ifdef PNG_PROGRESSIVE_READ_SUPPORTED\n   png_progressive_info_ptr info_fn; /* called after header data fully read */\n   png_progressive_row_ptr row_fn;   /* called after a prog. row is decoded */\n   png_progressive_end_ptr end_fn;   /* called after image is complete */\n   png_bytep save_buffer_ptr;        /* current location in save_buffer */\n   png_bytep save_buffer;            /* buffer for previously read data */\n   png_bytep current_buffer_ptr;     /* current location in current_buffer */\n   png_bytep current_buffer;         /* buffer for recently used data */\n   png_uint_32 push_length;          /* size of current input chunk */\n   png_uint_32 skip_length;          /* bytes to skip in input data */\n   png_size_t save_buffer_size;      /* amount of data now in save_buffer */\n   png_size_t save_buffer_max;       /* total size of save_buffer */\n   png_size_t buffer_size;           /* total amount of available input data */\n   png_size_t current_buffer_size;   /* amount of data now in current_buffer */\n   int process_mode;                 /* what push library is currently doing */\n   int cur_palette;                  /* current push library palette index */\n\n#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */\n\n#if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__)\n/* For the Borland special 64K segment handler */\n   png_bytepp offset_table_ptr;\n   png_bytep offset_table;\n   png_uint_16 offset_table_number;\n   png_uint_16 offset_table_count;\n   png_uint_16 offset_table_count_free;\n#endif\n\n#ifdef PNG_READ_QUANTIZE_SUPPORTED\n   png_bytep palette_lookup; /* lookup table for quantizing */\n   png_bytep quantize_index; /* index translation for palette files */\n#endif\n\n#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED\n   png_byte heuristic_method;        /* heuristic for row filter selection */\n   png_byte num_prev_filters;        /* number of weights for previous rows */\n   png_bytep prev_filters;           /* filter type(s) of previous row(s) */\n   png_uint_16p filter_weights;      /* weight(s) for previous line(s) */\n   png_uint_16p inv_filter_weights;  /* 1/weight(s) for previous line(s) */\n   png_uint_16p filter_costs;        /* relative filter calculation cost */\n   png_uint_16p inv_filter_costs;    /* 1/relative filter calculation cost */\n#endif\n\n   /* Options */\n#ifdef PNG_SET_OPTION_SUPPORTED\n   png_byte options;           /* On/off state (up to 4 options) */\n#endif\n\n#if PNG_LIBPNG_VER < 10700\n/* To do: remove this from libpng-1.7 */\n#ifdef PNG_TIME_RFC1123_SUPPORTED\n   char time_buffer[29]; /* String to hold RFC 1123 time text */\n#endif\n#endif\n\n/* New members added in libpng-1.0.6 */\n\n   png_uint_32 free_me;    /* flags items libpng is responsible for freeing */\n\n#ifdef PNG_USER_CHUNKS_SUPPORTED\n   png_voidp user_chunk_ptr;\n#ifdef PNG_READ_USER_CHUNKS_SUPPORTED\n   png_user_chunk_ptr read_user_chunk_fn; /* user read chunk handler */\n#endif\n#endif\n\n#ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED\n   int          unknown_default; /* As PNG_HANDLE_* */\n   unsigned int num_chunk_list;  /* Number of entries in the list */\n   png_bytep    chunk_list;      /* List of png_byte[5]; the textual chunk name\n                                  * followed by a PNG_HANDLE_* byte */\n#endif\n\n/* New members added in libpng-1.0.3 */\n#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED\n   png_byte rgb_to_gray_status;\n   /* Added in libpng 1.5.5 to record setting of coefficients: */\n   png_byte rgb_to_gray_coefficients_set;\n   /* These were changed from png_byte in libpng-1.0.6 */\n   png_uint_16 rgb_to_gray_red_coeff;\n   png_uint_16 rgb_to_gray_green_coeff;\n   /* deleted in 1.5.5: rgb_to_gray_blue_coeff; */\n#endif\n\n/* New member added in libpng-1.0.4 (renamed in 1.0.9) */\n#if defined(PNG_MNG_FEATURES_SUPPORTED)\n/* Changed from png_byte to png_uint_32 at version 1.2.0 */\n   png_uint_32 mng_features_permitted;\n#endif\n\n/* New member added in libpng-1.0.9, ifdef'ed out in 1.0.12, enabled in 1.2.0 */\n#ifdef PNG_MNG_FEATURES_SUPPORTED\n   png_byte filter_type;\n#endif\n\n/* New members added in libpng-1.2.0 */\n\n/* New members added in libpng-1.0.2 but first enabled by default in 1.2.0 */\n#ifdef PNG_USER_MEM_SUPPORTED\n   png_voidp mem_ptr;             /* user supplied struct for mem functions */\n   png_malloc_ptr malloc_fn;      /* function for allocating memory */\n   png_free_ptr free_fn;          /* function for freeing memory */\n#endif\n\n/* New member added in libpng-1.0.13 and 1.2.0 */\n   png_bytep big_row_buf;         /* buffer to save current (unfiltered) row */\n\n#ifdef PNG_READ_QUANTIZE_SUPPORTED\n/* The following three members were added at version 1.0.14 and 1.2.4 */\n   png_bytep quantize_sort;          /* working sort array */\n   png_bytep index_to_palette;       /* where the original index currently is\n                                        in the palette */\n   png_bytep palette_to_index;       /* which original index points to this\n                                         palette color */\n#endif\n\n/* New members added in libpng-1.0.16 and 1.2.6 */\n   png_byte compression_type;\n\n#ifdef PNG_USER_LIMITS_SUPPORTED\n   png_uint_32 user_width_max;\n   png_uint_32 user_height_max;\n\n   /* Added in libpng-1.4.0: Total number of sPLT, text, and unknown\n    * chunks that can be stored (0 means unlimited).\n    */\n   png_uint_32 user_chunk_cache_max;\n\n   /* Total memory that a zTXt, sPLT, iTXt, iCCP, or unknown chunk\n    * can occupy when decompressed.  0 means unlimited.\n    */\n   png_alloc_size_t user_chunk_malloc_max;\n#endif\n\n/* New member added in libpng-1.0.25 and 1.2.17 */\n#ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED\n   /* Temporary storage for unknown chunk that the library doesn't recognize,\n    * used while reading the chunk.\n    */\n   png_unknown_chunk unknown_chunk;\n#endif\n\n/* New member added in libpng-1.2.26 */\n  png_size_t old_big_row_buf_size;\n\n#ifdef PNG_READ_SUPPORTED\n/* New member added in libpng-1.2.30 */\n  png_bytep        read_buffer;      /* buffer for reading chunk data */\n  png_alloc_size_t read_buffer_size; /* current size of the buffer */\n#endif\n#ifdef PNG_SEQUENTIAL_READ_SUPPORTED\n  uInt             IDAT_read_size;   /* limit on read buffer size for IDAT */\n#endif\n\n#ifdef PNG_IO_STATE_SUPPORTED\n/* New member added in libpng-1.4.0 */\n   png_uint_32 io_state;\n#endif\n\n/* New member added in libpng-1.5.6 */\n   png_bytep big_prev_row;\n\n/* New member added in libpng-1.5.7 */\n   void (*read_filter[PNG_FILTER_VALUE_LAST-1])(png_row_infop row_info,\n      png_bytep row, png_const_bytep prev_row);\n\n#ifdef PNG_READ_SUPPORTED\n#if defined(PNG_COLORSPACE_SUPPORTED) || defined(PNG_GAMMA_SUPPORTED)\n   png_colorspace   colorspace;\n#endif\n#endif\n};\n#endif /* PNGSTRUCT_H */\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/rapidxml/rapidxml.hpp",
    "content": "#ifndef RAPIDXML_HPP_INCLUDED\r\n#define RAPIDXML_HPP_INCLUDED\r\n\r\n// Copyright (C) 2006, 2009 Marcin Kalicinski\r\n// Version 1.13\r\n// Revision $DateTime: 2009/05/13 01:46:17 $\r\n//! \\file rapidxml.hpp This file contains rapidxml parser and DOM implementation\r\n\r\n// If standard library is disabled, user must provide implementations of required functions and typedefs\r\n#if !defined(RAPIDXML_NO_STDLIB)\r\n    #include <cstdlib>      // For std::size_t\r\n    #include <cassert>      // For assert\r\n    #include <new>          // For placement new\r\n#endif\r\n\r\n// On MSVC, disable \"conditional expression is constant\" warning (level 4). \r\n// This warning is almost impossible to avoid with certain types of templated code\r\n#ifdef _MSC_VER\r\n    #pragma warning(push)\r\n    #pragma warning(disable:4127)   // Conditional expression is constant\r\n#endif\r\n\r\n///////////////////////////////////////////////////////////////////////////\r\n// RAPIDXML_PARSE_ERROR\r\n    \r\n#if defined(RAPIDXML_NO_EXCEPTIONS)\r\n\r\n#define RAPIDXML_PARSE_ERROR(what, where) { parse_error_handler(what, where); assert(0); }\r\n\r\nnamespace rapidxml\r\n{\r\n    //! When exceptions are disabled by defining RAPIDXML_NO_EXCEPTIONS, \r\n    //! this function is called to notify user about the error.\r\n    //! It must be defined by the user.\r\n    //! <br><br>\r\n    //! This function cannot return. If it does, the results are undefined.\r\n    //! <br><br>\r\n    //! A very simple definition might look like that:\r\n    //! <pre>\r\n    //! void %rapidxml::%parse_error_handler(const char *what, void *where)\r\n    //! {\r\n    //!     std::cout << \"Parse error: \" << what << \"\\n\";\r\n    //!     std::abort();\r\n    //! }\r\n    //! </pre>\r\n    //! \\param what Human readable description of the error.\r\n    //! \\param where Pointer to character data where error was detected.\r\n    void parse_error_handler(const char *what, void *where);\r\n}\r\n\r\n#else\r\n    \r\n#include <exception>    // For std::exception\r\n\r\n#define RAPIDXML_PARSE_ERROR(what, where) throw parse_error(what, where)\r\n\r\nnamespace rapidxml\r\n{\r\n\r\n    //! Parse error exception. \r\n    //! This exception is thrown by the parser when an error occurs. \r\n    //! Use what() function to get human-readable error message. \r\n    //! Use where() function to get a pointer to position within source text where error was detected.\r\n    //! <br><br>\r\n    //! If throwing exceptions by the parser is undesirable, \r\n    //! it can be disabled by defining RAPIDXML_NO_EXCEPTIONS macro before rapidxml.hpp is included.\r\n    //! This will cause the parser to call rapidxml::parse_error_handler() function instead of throwing an exception.\r\n    //! This function must be defined by the user.\r\n    //! <br><br>\r\n    //! This class derives from <code>std::exception</code> class.\r\n    class parse_error: public std::exception\r\n    {\r\n    \r\n    public:\r\n    \r\n        //! Constructs parse error\r\n        parse_error(const char *what, void *where)\r\n            : m_what(what)\r\n            , m_where(where)\r\n        {\r\n        }\r\n\r\n        //! Gets human readable description of error.\r\n        //! \\return Pointer to null terminated description of the error.\r\n        virtual const char *what() const throw()\r\n        {\r\n            return m_what;\r\n        }\r\n\r\n        //! Gets pointer to character data where error happened.\r\n        //! Ch should be the same as char type of xml_document that produced the error.\r\n        //! \\return Pointer to location within the parsed string where error occured.\r\n        template<class Ch>\r\n        Ch *where() const\r\n        {\r\n            return reinterpret_cast<Ch *>(m_where);\r\n        }\r\n\r\n    private:  \r\n\r\n        const char *m_what;\r\n        void *m_where;\r\n\r\n    };\r\n}\r\n\r\n#endif\r\n\r\n///////////////////////////////////////////////////////////////////////////\r\n// Pool sizes\r\n\r\n#ifndef RAPIDXML_STATIC_POOL_SIZE\r\n    // Size of static memory block of memory_pool.\r\n    // Define RAPIDXML_STATIC_POOL_SIZE before including rapidxml.hpp if you want to override the default value.\r\n    // No dynamic memory allocations are performed by memory_pool until static memory is exhausted.\r\n    #define RAPIDXML_STATIC_POOL_SIZE (64 * 1024)\r\n#endif\r\n\r\n#ifndef RAPIDXML_DYNAMIC_POOL_SIZE\r\n    // Size of dynamic memory block of memory_pool.\r\n    // Define RAPIDXML_DYNAMIC_POOL_SIZE before including rapidxml.hpp if you want to override the default value.\r\n    // After the static block is exhausted, dynamic blocks with approximately this size are allocated by memory_pool.\r\n    #define RAPIDXML_DYNAMIC_POOL_SIZE (64 * 1024)\r\n#endif\r\n\r\n#ifndef RAPIDXML_ALIGNMENT\r\n    // Memory allocation alignment.\r\n    // Define RAPIDXML_ALIGNMENT before including rapidxml.hpp if you want to override the default value, which is the size of pointer.\r\n    // All memory allocations for nodes, attributes and strings will be aligned to this value.\r\n    // This must be a power of 2 and at least 1, otherwise memory_pool will not work.\r\n    #define RAPIDXML_ALIGNMENT sizeof(void *)\r\n#endif\r\n\r\nnamespace rapidxml\r\n{\r\n    // Forward declarations\r\n    template<class Ch> class xml_node;\r\n    template<class Ch> class xml_attribute;\r\n    template<class Ch> class xml_document;\r\n    \r\n    //! Enumeration listing all node types produced by the parser.\r\n    //! Use xml_node::type() function to query node type.\r\n    enum node_type\r\n    {\r\n        node_document,      //!< A document node. Name and value are empty.\r\n        node_element,       //!< An element node. Name contains element name. Value contains text of first data node.\r\n        node_data,          //!< A data node. Name is empty. Value contains data text.\r\n        node_cdata,         //!< A CDATA node. Name is empty. Value contains data text.\r\n        node_comment,       //!< A comment node. Name is empty. Value contains comment text.\r\n        node_declaration,   //!< A declaration node. Name and value are empty. Declaration parameters (version, encoding and standalone) are in node attributes.\r\n        node_doctype,       //!< A DOCTYPE node. Name is empty. Value contains DOCTYPE text.\r\n        node_pi             //!< A PI node. Name contains target. Value contains instructions.\r\n    };\r\n\r\n    ///////////////////////////////////////////////////////////////////////\r\n    // Parsing flags\r\n\r\n    //! Parse flag instructing the parser to not create data nodes. \r\n    //! Text of first data node will still be placed in value of parent element, unless rapidxml::parse_no_element_values flag is also specified.\r\n    //! Can be combined with other flags by use of | operator.\r\n    //! <br><br>\r\n    //! See xml_document::parse() function.\r\n    const int parse_no_data_nodes = 0x1;            \r\n\r\n    //! Parse flag instructing the parser to not use text of first data node as a value of parent element.\r\n    //! Can be combined with other flags by use of | operator.\r\n    //! Note that child data nodes of element node take precendence over its value when printing. \r\n    //! That is, if element has one or more child data nodes <em>and</em> a value, the value will be ignored.\r\n    //! Use rapidxml::parse_no_data_nodes flag to prevent creation of data nodes if you want to manipulate data using values of elements.\r\n    //! <br><br>\r\n    //! See xml_document::parse() function.\r\n    const int parse_no_element_values = 0x2;\r\n    \r\n    //! Parse flag instructing the parser to not place zero terminators after strings in the source text.\r\n    //! By default zero terminators are placed, modifying source text.\r\n    //! Can be combined with other flags by use of | operator.\r\n    //! <br><br>\r\n    //! See xml_document::parse() function.\r\n    const int parse_no_string_terminators = 0x4;\r\n    \r\n    //! Parse flag instructing the parser to not translate entities in the source text.\r\n    //! By default entities are translated, modifying source text.\r\n    //! Can be combined with other flags by use of | operator.\r\n    //! <br><br>\r\n    //! See xml_document::parse() function.\r\n    const int parse_no_entity_translation = 0x8;\r\n    \r\n    //! Parse flag instructing the parser to disable UTF-8 handling and assume plain 8 bit characters.\r\n    //! By default, UTF-8 handling is enabled.\r\n    //! Can be combined with other flags by use of | operator.\r\n    //! <br><br>\r\n    //! See xml_document::parse() function.\r\n    const int parse_no_utf8 = 0x10;\r\n    \r\n    //! Parse flag instructing the parser to create XML declaration node.\r\n    //! By default, declaration node is not created.\r\n    //! Can be combined with other flags by use of | operator.\r\n    //! <br><br>\r\n    //! See xml_document::parse() function.\r\n    const int parse_declaration_node = 0x20;\r\n    \r\n    //! Parse flag instructing the parser to create comments nodes.\r\n    //! By default, comment nodes are not created.\r\n    //! Can be combined with other flags by use of | operator.\r\n    //! <br><br>\r\n    //! See xml_document::parse() function.\r\n    const int parse_comment_nodes = 0x40;\r\n    \r\n    //! Parse flag instructing the parser to create DOCTYPE node.\r\n    //! By default, doctype node is not created.\r\n    //! Although W3C specification allows at most one DOCTYPE node, RapidXml will silently accept documents with more than one.\r\n    //! Can be combined with other flags by use of | operator.\r\n    //! <br><br>\r\n    //! See xml_document::parse() function.\r\n    const int parse_doctype_node = 0x80;\r\n    \r\n    //! Parse flag instructing the parser to create PI nodes.\r\n    //! By default, PI nodes are not created.\r\n    //! Can be combined with other flags by use of | operator.\r\n    //! <br><br>\r\n    //! See xml_document::parse() function.\r\n    const int parse_pi_nodes = 0x100;\r\n    \r\n    //! Parse flag instructing the parser to validate closing tag names. \r\n    //! If not set, name inside closing tag is irrelevant to the parser.\r\n    //! By default, closing tags are not validated.\r\n    //! Can be combined with other flags by use of | operator.\r\n    //! <br><br>\r\n    //! See xml_document::parse() function.\r\n    const int parse_validate_closing_tags = 0x200;\r\n    \r\n    //! Parse flag instructing the parser to trim all leading and trailing whitespace of data nodes.\r\n    //! By default, whitespace is not trimmed. \r\n    //! This flag does not cause the parser to modify source text.\r\n    //! Can be combined with other flags by use of | operator.\r\n    //! <br><br>\r\n    //! See xml_document::parse() function.\r\n    const int parse_trim_whitespace = 0x400;\r\n\r\n    //! Parse flag instructing the parser to condense all whitespace runs of data nodes to a single space character.\r\n    //! Trimming of leading and trailing whitespace of data is controlled by rapidxml::parse_trim_whitespace flag.\r\n    //! By default, whitespace is not normalized. \r\n    //! If this flag is specified, source text will be modified.\r\n    //! Can be combined with other flags by use of | operator.\r\n    //! <br><br>\r\n    //! See xml_document::parse() function.\r\n    const int parse_normalize_whitespace = 0x800;\r\n\r\n    // Compound flags\r\n    \r\n    //! Parse flags which represent default behaviour of the parser. \r\n    //! This is always equal to 0, so that all other flags can be simply ored together.\r\n    //! Normally there is no need to inconveniently disable flags by anding with their negated (~) values.\r\n    //! This also means that meaning of each flag is a <i>negation</i> of the default setting. \r\n    //! For example, if flag name is rapidxml::parse_no_utf8, it means that utf-8 is <i>enabled</i> by default,\r\n    //! and using the flag will disable it.\r\n    //! <br><br>\r\n    //! See xml_document::parse() function.\r\n    const int parse_default = 0;\r\n    \r\n    //! A combination of parse flags that forbids any modifications of the source text. \r\n    //! This also results in faster parsing. However, note that the following will occur:\r\n    //! <ul>\r\n    //! <li>names and values of nodes will not be zero terminated, you have to use xml_base::name_size() and xml_base::value_size() functions to determine where name and value ends</li>\r\n    //! <li>entities will not be translated</li>\r\n    //! <li>whitespace will not be normalized</li>\r\n    //! </ul>\r\n    //! See xml_document::parse() function.\r\n    const int parse_non_destructive = parse_no_string_terminators | parse_no_entity_translation;\r\n    \r\n    //! A combination of parse flags resulting in fastest possible parsing, without sacrificing important data.\r\n    //! <br><br>\r\n    //! See xml_document::parse() function.\r\n    const int parse_fastest = parse_non_destructive | parse_no_data_nodes;\r\n    \r\n    //! A combination of parse flags resulting in largest amount of data being extracted. \r\n    //! This usually results in slowest parsing.\r\n    //! <br><br>\r\n    //! See xml_document::parse() function.\r\n    const int parse_full = parse_declaration_node | parse_comment_nodes | parse_doctype_node | parse_pi_nodes | parse_validate_closing_tags;\r\n\r\n    ///////////////////////////////////////////////////////////////////////\r\n    // Internals\r\n\r\n    //! \\cond internal\r\n    namespace internal\r\n    {\r\n\r\n        // Struct that contains lookup tables for the parser\r\n        // It must be a template to allow correct linking (because it has static data members, which are defined in a header file).\r\n        template<int Dummy>\r\n        struct lookup_tables\r\n        {\r\n            static const unsigned char lookup_whitespace[256];              // Whitespace table\r\n            static const unsigned char lookup_node_name[256];               // Node name table\r\n            static const unsigned char lookup_text[256];                    // Text table\r\n            static const unsigned char lookup_text_pure_no_ws[256];         // Text table\r\n            static const unsigned char lookup_text_pure_with_ws[256];       // Text table\r\n            static const unsigned char lookup_attribute_name[256];          // Attribute name table\r\n            static const unsigned char lookup_attribute_data_1[256];        // Attribute data table with single quote\r\n            static const unsigned char lookup_attribute_data_1_pure[256];   // Attribute data table with single quote\r\n            static const unsigned char lookup_attribute_data_2[256];        // Attribute data table with double quotes\r\n            static const unsigned char lookup_attribute_data_2_pure[256];   // Attribute data table with double quotes\r\n            static const unsigned char lookup_digits[256];                  // Digits\r\n            static const unsigned char lookup_upcase[256];                  // To uppercase conversion table for ASCII characters\r\n        };\r\n\r\n        // Find length of the string\r\n        template<class Ch>\r\n        inline std::size_t measure(const Ch *p)\r\n        {\r\n            const Ch *tmp = p;\r\n            while (*tmp) \r\n                ++tmp;\r\n            return tmp - p;\r\n        }\r\n\r\n        // Compare strings for equality\r\n        template<class Ch>\r\n        inline bool compare(const Ch *p1, std::size_t size1, const Ch *p2, std::size_t size2, bool case_sensitive)\r\n        {\r\n            if (size1 != size2)\r\n                return false;\r\n            if (case_sensitive)\r\n            {\r\n                for (const Ch *end = p1 + size1; p1 < end; ++p1, ++p2)\r\n                    if (*p1 != *p2)\r\n                        return false;\r\n            }\r\n            else\r\n            {\r\n                for (const Ch *end = p1 + size1; p1 < end; ++p1, ++p2)\r\n                    if (lookup_tables<0>::lookup_upcase[static_cast<unsigned char>(*p1)] != lookup_tables<0>::lookup_upcase[static_cast<unsigned char>(*p2)])\r\n                        return false;\r\n            }\r\n            return true;\r\n        }\r\n    }\r\n    //! \\endcond\r\n\r\n    ///////////////////////////////////////////////////////////////////////\r\n    // Memory pool\r\n    \r\n    //! This class is used by the parser to create new nodes and attributes, without overheads of dynamic memory allocation.\r\n    //! In most cases, you will not need to use this class directly. \r\n    //! However, if you need to create nodes manually or modify names/values of nodes, \r\n    //! you are encouraged to use memory_pool of relevant xml_document to allocate the memory. \r\n    //! Not only is this faster than allocating them by using <code>new</code> operator, \r\n    //! but also their lifetime will be tied to the lifetime of document, \r\n    //! possibly simplyfing memory management. \r\n    //! <br><br>\r\n    //! Call allocate_node() or allocate_attribute() functions to obtain new nodes or attributes from the pool. \r\n    //! You can also call allocate_string() function to allocate strings.\r\n    //! Such strings can then be used as names or values of nodes without worrying about their lifetime.\r\n    //! Note that there is no <code>free()</code> function -- all allocations are freed at once when clear() function is called, \r\n    //! or when the pool is destroyed.\r\n    //! <br><br>\r\n    //! It is also possible to create a standalone memory_pool, and use it \r\n    //! to allocate nodes, whose lifetime will not be tied to any document.\r\n    //! <br><br>\r\n    //! Pool maintains <code>RAPIDXML_STATIC_POOL_SIZE</code> bytes of statically allocated memory. \r\n    //! Until static memory is exhausted, no dynamic memory allocations are done.\r\n    //! When static memory is exhausted, pool allocates additional blocks of memory of size <code>RAPIDXML_DYNAMIC_POOL_SIZE</code> each,\r\n    //! by using global <code>new[]</code> and <code>delete[]</code> operators. \r\n    //! This behaviour can be changed by setting custom allocation routines. \r\n    //! Use set_allocator() function to set them.\r\n    //! <br><br>\r\n    //! Allocations for nodes, attributes and strings are aligned at <code>RAPIDXML_ALIGNMENT</code> bytes.\r\n    //! This value defaults to the size of pointer on target architecture.\r\n    //! <br><br>\r\n    //! To obtain absolutely top performance from the parser,\r\n    //! it is important that all nodes are allocated from a single, contiguous block of memory.\r\n    //! Otherwise, cache misses when jumping between two (or more) disjoint blocks of memory can slow down parsing quite considerably.\r\n    //! If required, you can tweak <code>RAPIDXML_STATIC_POOL_SIZE</code>, <code>RAPIDXML_DYNAMIC_POOL_SIZE</code> and <code>RAPIDXML_ALIGNMENT</code> \r\n    //! to obtain best wasted memory to performance compromise.\r\n    //! To do it, define their values before rapidxml.hpp file is included.\r\n    //! \\param Ch Character type of created nodes. \r\n    template<class Ch = char>\r\n    class memory_pool\r\n    {\r\n        \r\n    public:\r\n\r\n        //! \\cond internal\r\n        typedef void *(rapidxml_alloc_func)(std::size_t);       // Type of user-defined function used to allocate memory\r\n        typedef void (free_func)(void *);              // Type of user-defined function used to free memory\r\n        //! \\endcond\r\n        \r\n        //! Constructs empty pool with default allocator functions.\r\n        memory_pool()\r\n            : m_rapidxml_alloc_func(0)\r\n            , m_free_func(0)\r\n        {\r\n            init();\r\n        }\r\n\r\n        //! Destroys pool and frees all the memory. \r\n        //! This causes memory occupied by nodes allocated by the pool to be freed.\r\n        //! Nodes allocated from the pool are no longer valid.\r\n        ~memory_pool()\r\n        {\r\n            clear();\r\n        }\r\n\r\n        //! Allocates a new node from the pool, and optionally assigns name and value to it. \r\n        //! If the allocation request cannot be accomodated, this function will throw <code>std::bad_alloc</code>.\r\n        //! If exceptions are disabled by defining RAPIDXML_NO_EXCEPTIONS, this function\r\n        //! will call rapidxml::parse_error_handler() function.\r\n        //! \\param type Type of node to create.\r\n        //! \\param name Name to assign to the node, or 0 to assign no name.\r\n        //! \\param value Value to assign to the node, or 0 to assign no value.\r\n        //! \\param name_size Size of name to assign, or 0 to automatically calculate size from name string.\r\n        //! \\param value_size Size of value to assign, or 0 to automatically calculate size from value string.\r\n        //! \\return Pointer to allocated node. This pointer will never be NULL.\r\n        xml_node<Ch> *allocate_node(node_type type, \r\n                                    const Ch *name = 0, const Ch *value = 0, \r\n                                    std::size_t name_size = 0, std::size_t value_size = 0)\r\n        {\r\n            void *memory = allocate_aligned(sizeof(xml_node<Ch>));\r\n            xml_node<Ch> *node = new(memory) xml_node<Ch>(type);\r\n            if (name)\r\n            {\r\n                if (name_size > 0)\r\n                    node->name(name, name_size);\r\n                else\r\n                    node->name(name);\r\n            }\r\n            if (value)\r\n            {\r\n                if (value_size > 0)\r\n                    node->value(value, value_size);\r\n                else\r\n                    node->value(value);\r\n            }\r\n            return node;\r\n        }\r\n\r\n        //! Allocates a new attribute from the pool, and optionally assigns name and value to it.\r\n        //! If the allocation request cannot be accomodated, this function will throw <code>std::bad_alloc</code>.\r\n        //! If exceptions are disabled by defining RAPIDXML_NO_EXCEPTIONS, this function\r\n        //! will call rapidxml::parse_error_handler() function.\r\n        //! \\param name Name to assign to the attribute, or 0 to assign no name.\r\n        //! \\param value Value to assign to the attribute, or 0 to assign no value.\r\n        //! \\param name_size Size of name to assign, or 0 to automatically calculate size from name string.\r\n        //! \\param value_size Size of value to assign, or 0 to automatically calculate size from value string.\r\n        //! \\return Pointer to allocated attribute. This pointer will never be NULL.\r\n        xml_attribute<Ch> *allocate_attribute(const Ch *name = 0, const Ch *value = 0, \r\n                                              std::size_t name_size = 0, std::size_t value_size = 0)\r\n        {\r\n            void *memory = allocate_aligned(sizeof(xml_attribute<Ch>));\r\n            xml_attribute<Ch> *attribute = new(memory) xml_attribute<Ch>;\r\n            if (name)\r\n            {\r\n                if (name_size > 0)\r\n                    attribute->name(name, name_size);\r\n                else\r\n                    attribute->name(name);\r\n            }\r\n            if (value)\r\n            {\r\n                if (value_size > 0)\r\n                    attribute->value(value, value_size);\r\n                else\r\n                    attribute->value(value);\r\n            }\r\n            return attribute;\r\n        }\r\n\r\n        //! Allocates a char array of given size from the pool, and optionally copies a given string to it.\r\n        //! If the allocation request cannot be accomodated, this function will throw <code>std::bad_alloc</code>.\r\n        //! If exceptions are disabled by defining RAPIDXML_NO_EXCEPTIONS, this function\r\n        //! will call rapidxml::parse_error_handler() function.\r\n        //! \\param source String to initialize the allocated memory with, or 0 to not initialize it.\r\n        //! \\param size Number of characters to allocate, or zero to calculate it automatically from source string length; if size is 0, source string must be specified and null terminated.\r\n        //! \\return Pointer to allocated char array. This pointer will never be NULL.\r\n        Ch *allocate_string(const Ch *source = 0, std::size_t size = 0)\r\n        {\r\n            assert(source || size);     // Either source or size (or both) must be specified\r\n            if (size == 0)\r\n                size = internal::measure(source) + 1;\r\n            Ch *result = static_cast<Ch *>(allocate_aligned(size * sizeof(Ch)));\r\n            if (source)\r\n                for (std::size_t i = 0; i < size; ++i)\r\n                    result[i] = source[i];\r\n            return result;\r\n        }\r\n\r\n        //! Clones an xml_node and its hierarchy of child nodes and attributes.\r\n        //! Nodes and attributes are allocated from this memory pool.\r\n        //! Names and values are not cloned, they are shared between the clone and the source.\r\n        //! Result node can be optionally specified as a second parameter, \r\n        //! in which case its contents will be replaced with cloned source node.\r\n        //! This is useful when you want to clone entire document.\r\n        //! \\param source Node to clone.\r\n        //! \\param result Node to put results in, or 0 to automatically allocate result node\r\n        //! \\return Pointer to cloned node. This pointer will never be NULL.\r\n        xml_node<Ch> *clone_node(const xml_node<Ch> *source, xml_node<Ch> *result = 0)\r\n        {\r\n            // Prepare result node\r\n            if (result)\r\n            {\r\n                result->remove_all_attributes();\r\n                result->remove_all_nodes();\r\n                result->type(source->type());\r\n            }\r\n            else\r\n                result = allocate_node(source->type());\r\n\r\n            // Clone name and value\r\n            result->name(source->name(), source->name_size());\r\n            result->value(source->value(), source->value_size());\r\n\r\n            // Clone child nodes and attributes\r\n            for (xml_node<Ch> *child = source->first_node(); child; child = child->next_sibling())\r\n                result->append_node(clone_node(child));\r\n            for (xml_attribute<Ch> *attr = source->first_attribute(); attr; attr = attr->next_attribute())\r\n                result->append_attribute(allocate_attribute(attr->name(), attr->value(), attr->name_size(), attr->value_size()));\r\n\r\n            return result;\r\n        }\r\n\r\n        //! Clears the pool. \r\n        //! This causes memory occupied by nodes allocated by the pool to be freed.\r\n        //! Any nodes or strings allocated from the pool will no longer be valid.\r\n        void clear()\r\n        {\r\n            while (m_begin != m_static_memory)\r\n            {\r\n                char *previous_begin = reinterpret_cast<header *>(align(m_begin))->previous_begin;\r\n                if (m_free_func)\r\n                    m_free_func(m_begin);\r\n                else\r\n                    delete[] m_begin;\r\n                m_begin = previous_begin;\r\n            }\r\n            init();\r\n        }\r\n\r\n        //! Sets or resets the user-defined memory allocation functions for the pool.\r\n        //! This can only be called when no memory is allocated from the pool yet, otherwise results are undefined.\r\n        //! Allocation function must not return invalid pointer on failure. It should either throw,\r\n        //! stop the program, or use <code>longjmp()</code> function to pass control to other place of program. \r\n        //! If it returns invalid pointer, results are undefined.\r\n        //! <br><br>\r\n        //! User defined allocation functions must have the following forms:\r\n        //! <br><code>\r\n        //! <br>void *allocate(std::size_t size);\r\n        //! <br>void free(void *pointer);\r\n        //! </code><br>\r\n        //! \\param af Allocation function, or 0 to restore default function\r\n        //! \\param ff Free function, or 0 to restore default function\r\n        void set_allocator(rapidxml_alloc_func *af, free_func *ff)\r\n        {\r\n            assert(m_begin == m_static_memory && m_ptr == align(m_begin));    // Verify that no memory is allocated yet\r\n            m_rapidxml_alloc_func = af;\r\n            m_free_func = ff;\r\n        }\r\n\r\n    private:\r\n\r\n        struct header\r\n        {\r\n            char *previous_begin;\r\n        };\r\n\r\n        void init()\r\n        {\r\n            m_begin = m_static_memory;\r\n            m_ptr = align(m_begin);\r\n            m_end = m_static_memory + sizeof(m_static_memory);\r\n        }\r\n        \r\n        char *align(char *ptr)\r\n        {\r\n            std::size_t alignment = ((RAPIDXML_ALIGNMENT - (std::size_t(ptr) & (RAPIDXML_ALIGNMENT - 1))) & (RAPIDXML_ALIGNMENT - 1));\r\n            return ptr + alignment;\r\n        }\r\n        \r\n        char *allocate_raw(std::size_t size)\r\n        {\r\n            // Allocate\r\n            void *memory;   \r\n            if (m_rapidxml_alloc_func)   // Allocate memory using either user-specified allocation function or global operator new[]\r\n            {\r\n                memory = m_rapidxml_alloc_func(size);\r\n                assert(memory); // Allocator is not allowed to return 0, on failure it must either throw, stop the program or use longjmp\r\n            }\r\n            else\r\n            {\r\n                memory = new char[size];\r\n#ifdef RAPIDXML_NO_EXCEPTIONS\r\n                if (!memory)            // If exceptions are disabled, verify memory allocation, because new will not be able to throw bad_alloc\r\n                    RAPIDXML_PARSE_ERROR(\"out of memory\", 0);\r\n#endif\r\n            }\r\n            return static_cast<char *>(memory);\r\n        }\r\n        \r\n        void *allocate_aligned(std::size_t size)\r\n        {\r\n            // Calculate aligned pointer\r\n            char *result = align(m_ptr);\r\n\r\n            // If not enough memory left in current pool, allocate a new pool\r\n            if (result + size > m_end)\r\n            {\r\n                // Calculate required pool size (may be bigger than RAPIDXML_DYNAMIC_POOL_SIZE)\r\n                std::size_t pool_size = RAPIDXML_DYNAMIC_POOL_SIZE;\r\n                if (pool_size < size)\r\n                    pool_size = size;\r\n                \r\n                // Allocate\r\n                std::size_t alloc_size = sizeof(header) + (2 * RAPIDXML_ALIGNMENT - 2) + pool_size;     // 2 alignments required in worst case: one for header, one for actual allocation\r\n                char *raw_memory = allocate_raw(alloc_size);\r\n                    \r\n                // Setup new pool in allocated memory\r\n                char *pool = align(raw_memory);\r\n                header *new_header = reinterpret_cast<header *>(pool);\r\n                new_header->previous_begin = m_begin;\r\n                m_begin = raw_memory;\r\n                m_ptr = pool + sizeof(header);\r\n                m_end = raw_memory + alloc_size;\r\n\r\n                // Calculate aligned pointer again using new pool\r\n                result = align(m_ptr);\r\n            }\r\n\r\n            // Update pool and return aligned pointer\r\n            m_ptr = result + size;\r\n            return result;\r\n        }\r\n\r\n        char *m_begin;                                      // Start of raw memory making up current pool\r\n        char *m_ptr;                                        // First free byte in current pool\r\n        char *m_end;                                        // One past last available byte in current pool\r\n        char m_static_memory[RAPIDXML_STATIC_POOL_SIZE];    // Static raw memory\r\n        rapidxml_alloc_func *m_rapidxml_alloc_func;                           // Allocator function, or 0 if default is to be used\r\n        free_func *m_free_func;                             // Free function, or 0 if default is to be used\r\n    };\r\n\r\n    ///////////////////////////////////////////////////////////////////////////\r\n    // XML base\r\n\r\n    //! Base class for xml_node and xml_attribute implementing common functions: \r\n    //! name(), name_size(), value(), value_size() and parent().\r\n    //! \\param Ch Character type to use\r\n    template<class Ch = char>\r\n    class xml_base\r\n    {\r\n\r\n    public:\r\n        \r\n        ///////////////////////////////////////////////////////////////////////////\r\n        // Construction & destruction\r\n    \r\n        // Construct a base with empty name, value and parent\r\n        xml_base()\r\n            : m_name(0)\r\n            , m_value(0)\r\n            , m_parent(0)\r\n        {\r\n        }\r\n\r\n        ///////////////////////////////////////////////////////////////////////////\r\n        // Node data access\r\n    \r\n        //! Gets name of the node. \r\n        //! Interpretation of name depends on type of node.\r\n        //! Note that name will not be zero-terminated if rapidxml::parse_no_string_terminators option was selected during parse.\r\n        //! <br><br>\r\n        //! Use name_size() function to determine length of the name.\r\n        //! \\return Name of node, or empty string if node has no name.\r\n        Ch *name() const\r\n        {\r\n            return m_name ? m_name : nullstr();\r\n        }\r\n\r\n        //! Gets size of node name, not including terminator character.\r\n        //! This function works correctly irrespective of whether name is or is not zero terminated.\r\n        //! \\return Size of node name, in characters.\r\n        std::size_t name_size() const\r\n        {\r\n            return m_name ? m_name_size : 0;\r\n        }\r\n\r\n        //! Gets value of node. \r\n        //! Interpretation of value depends on type of node.\r\n        //! Note that value will not be zero-terminated if rapidxml::parse_no_string_terminators option was selected during parse.\r\n        //! <br><br>\r\n        //! Use value_size() function to determine length of the value.\r\n        //! \\return Value of node, or empty string if node has no value.\r\n        Ch *value() const\r\n        {\r\n            return m_value ? m_value : nullstr();\r\n        }\r\n\r\n        //! Gets size of node value, not including terminator character.\r\n        //! This function works correctly irrespective of whether value is or is not zero terminated.\r\n        //! \\return Size of node value, in characters.\r\n        std::size_t value_size() const\r\n        {\r\n            return m_value ? m_value_size : 0;\r\n        }\r\n\r\n        ///////////////////////////////////////////////////////////////////////////\r\n        // Node modification\r\n    \r\n        //! Sets name of node to a non zero-terminated string.\r\n        //! See \\ref ownership_of_strings.\r\n        //! <br><br>\r\n        //! Note that node does not own its name or value, it only stores a pointer to it. \r\n        //! It will not delete or otherwise free the pointer on destruction.\r\n        //! It is reponsibility of the user to properly manage lifetime of the string.\r\n        //! The easiest way to achieve it is to use memory_pool of the document to allocate the string -\r\n        //! on destruction of the document the string will be automatically freed.\r\n        //! <br><br>\r\n        //! Size of name must be specified separately, because name does not have to be zero terminated.\r\n        //! Use name(const Ch *) function to have the length automatically calculated (string must be zero terminated).\r\n        //! \\param name Name of node to set. Does not have to be zero terminated.\r\n        //! \\param size Size of name, in characters. This does not include zero terminator, if one is present.\r\n        void name(const Ch *name, std::size_t size)\r\n        {\r\n            m_name = const_cast<Ch *>(name);\r\n            m_name_size = size;\r\n        }\r\n\r\n        //! Sets name of node to a zero-terminated string.\r\n        //! See also \\ref ownership_of_strings and xml_node::name(const Ch *, std::size_t).\r\n        //! \\param name Name of node to set. Must be zero terminated.\r\n        void name(const Ch *name)\r\n        {\r\n            this->name(name, internal::measure(name));\r\n        }\r\n\r\n        //! Sets value of node to a non zero-terminated string.\r\n        //! See \\ref ownership_of_strings.\r\n        //! <br><br>\r\n        //! Note that node does not own its name or value, it only stores a pointer to it. \r\n        //! It will not delete or otherwise free the pointer on destruction.\r\n        //! It is reponsibility of the user to properly manage lifetime of the string.\r\n        //! The easiest way to achieve it is to use memory_pool of the document to allocate the string -\r\n        //! on destruction of the document the string will be automatically freed.\r\n        //! <br><br>\r\n        //! Size of value must be specified separately, because it does not have to be zero terminated.\r\n        //! Use value(const Ch *) function to have the length automatically calculated (string must be zero terminated).\r\n        //! <br><br>\r\n        //! If an element has a child node of type node_data, it will take precedence over element value when printing.\r\n        //! If you want to manipulate data of elements using values, use parser flag rapidxml::parse_no_data_nodes to prevent creation of data nodes by the parser.\r\n        //! \\param value value of node to set. Does not have to be zero terminated.\r\n        //! \\param size Size of value, in characters. This does not include zero terminator, if one is present.\r\n        void value(const Ch *value, std::size_t size)\r\n        {\r\n            m_value = const_cast<Ch *>(value);\r\n            m_value_size = size;\r\n        }\r\n\r\n        //! Sets value of node to a zero-terminated string.\r\n        //! See also \\ref ownership_of_strings and xml_node::value(const Ch *, std::size_t).\r\n        //! \\param value Vame of node to set. Must be zero terminated.\r\n        void value(const Ch *value)\r\n        {\r\n            this->value(value, internal::measure(value));\r\n        }\r\n\r\n        ///////////////////////////////////////////////////////////////////////////\r\n        // Related nodes access\r\n    \r\n        //! Gets node parent.\r\n        //! \\return Pointer to parent node, or 0 if there is no parent.\r\n        xml_node<Ch> *parent() const\r\n        {\r\n            return m_parent;\r\n        }\r\n\r\n    protected:\r\n\r\n        // Return empty string\r\n        static Ch *nullstr()\r\n        {\r\n            static Ch zero = Ch('\\0');\r\n            return &zero;\r\n        }\r\n\r\n        Ch *m_name;                         // Name of node, or 0 if no name\r\n        Ch *m_value;                        // Value of node, or 0 if no value\r\n        std::size_t m_name_size;            // Length of node name, or undefined of no name\r\n        std::size_t m_value_size;           // Length of node value, or undefined if no value\r\n        xml_node<Ch> *m_parent;             // Pointer to parent node, or 0 if none\r\n\r\n    };\r\n\r\n    //! Class representing attribute node of XML document. \r\n    //! Each attribute has name and value strings, which are available through name() and value() functions (inherited from xml_base).\r\n    //! Note that after parse, both name and value of attribute will point to interior of source text used for parsing. \r\n    //! Thus, this text must persist in memory for the lifetime of attribute.\r\n    //! \\param Ch Character type to use.\r\n    template<class Ch = char>\r\n    class xml_attribute: public xml_base<Ch>\r\n    {\r\n\r\n        friend class xml_node<Ch>;\r\n    \r\n    public:\r\n\r\n        ///////////////////////////////////////////////////////////////////////////\r\n        // Construction & destruction\r\n    \r\n        //! Constructs an empty attribute with the specified type. \r\n        //! Consider using memory_pool of appropriate xml_document if allocating attributes manually.\r\n        xml_attribute()\r\n        {\r\n        }\r\n\r\n        ///////////////////////////////////////////////////////////////////////////\r\n        // Related nodes access\r\n    \r\n        //! Gets document of which attribute is a child.\r\n        //! \\return Pointer to document that contains this attribute, or 0 if there is no parent document.\r\n        xml_document<Ch> *document() const\r\n        {\r\n            if (xml_node<Ch> *node = this->parent())\r\n            {\r\n                while (node->parent())\r\n                    node = node->parent();\r\n                return node->type() == node_document ? static_cast<xml_document<Ch> *>(node) : 0;\r\n            }\r\n            else\r\n                return 0;\r\n        }\r\n\r\n        //! Gets previous attribute, optionally matching attribute name. \r\n        //! \\param name Name of attribute to find, or 0 to return previous attribute regardless of its name; this string doesn't have to be zero-terminated if name_size is non-zero\r\n        //! \\param name_size Size of name, in characters, or 0 to have size calculated automatically from string\r\n        //! \\param case_sensitive Should name comparison be case-sensitive; non case-sensitive comparison works properly only for ASCII characters\r\n        //! \\return Pointer to found attribute, or 0 if not found.\r\n        xml_attribute<Ch> *previous_attribute(const Ch *name = 0, std::size_t name_size = 0, bool case_sensitive = true) const\r\n        {\r\n            if (name)\r\n            {\r\n                if (name_size == 0)\r\n                    name_size = internal::measure(name);\r\n                for (xml_attribute<Ch> *attribute = m_prev_attribute; attribute; attribute = attribute->m_prev_attribute)\r\n                    if (internal::compare(attribute->name(), attribute->name_size(), name, name_size, case_sensitive))\r\n                        return attribute;\r\n                return 0;\r\n            }\r\n            else\r\n                return this->m_parent ? m_prev_attribute : 0;\r\n        }\r\n\r\n        //! Gets next attribute, optionally matching attribute name. \r\n        //! \\param name Name of attribute to find, or 0 to return next attribute regardless of its name; this string doesn't have to be zero-terminated if name_size is non-zero\r\n        //! \\param name_size Size of name, in characters, or 0 to have size calculated automatically from string\r\n        //! \\param case_sensitive Should name comparison be case-sensitive; non case-sensitive comparison works properly only for ASCII characters\r\n        //! \\return Pointer to found attribute, or 0 if not found.\r\n        xml_attribute<Ch> *next_attribute(const Ch *name = 0, std::size_t name_size = 0, bool case_sensitive = true) const\r\n        {\r\n            if (name)\r\n            {\r\n                if (name_size == 0)\r\n                    name_size = internal::measure(name);\r\n                for (xml_attribute<Ch> *attribute = m_next_attribute; attribute; attribute = attribute->m_next_attribute)\r\n                    if (internal::compare(attribute->name(), attribute->name_size(), name, name_size, case_sensitive))\r\n                        return attribute;\r\n                return 0;\r\n            }\r\n            else\r\n                return this->m_parent ? m_next_attribute : 0;\r\n        }\r\n\r\n    private:\r\n\r\n        xml_attribute<Ch> *m_prev_attribute;        // Pointer to previous sibling of attribute, or 0 if none; only valid if parent is non-zero\r\n        xml_attribute<Ch> *m_next_attribute;        // Pointer to next sibling of attribute, or 0 if none; only valid if parent is non-zero\r\n    \r\n    };\r\n\r\n    ///////////////////////////////////////////////////////////////////////////\r\n    // XML node\r\n\r\n    //! Class representing a node of XML document. \r\n    //! Each node may have associated name and value strings, which are available through name() and value() functions. \r\n    //! Interpretation of name and value depends on type of the node.\r\n    //! Type of node can be determined by using type() function.\r\n    //! <br><br>\r\n    //! Note that after parse, both name and value of node, if any, will point interior of source text used for parsing. \r\n    //! Thus, this text must persist in the memory for the lifetime of node.\r\n    //! \\param Ch Character type to use.\r\n    template<class Ch = char>\r\n    class xml_node: public xml_base<Ch>\r\n    {\r\n\r\n    public:\r\n\r\n        ///////////////////////////////////////////////////////////////////////////\r\n        // Construction & destruction\r\n    \r\n        //! Constructs an empty node with the specified type. \r\n        //! Consider using memory_pool of appropriate document to allocate nodes manually.\r\n        //! \\param type Type of node to construct.\r\n        xml_node(node_type type)\r\n            : m_type(type)\r\n            , m_first_node(0)\r\n            , m_first_attribute(0)\r\n        {\r\n        }\r\n\r\n        ///////////////////////////////////////////////////////////////////////////\r\n        // Node data access\r\n    \r\n        //! Gets type of node.\r\n        //! \\return Type of node.\r\n        node_type type() const\r\n        {\r\n            return m_type;\r\n        }\r\n\r\n        ///////////////////////////////////////////////////////////////////////////\r\n        // Related nodes access\r\n    \r\n        //! Gets document of which node is a child.\r\n        //! \\return Pointer to document that contains this node, or 0 if there is no parent document.\r\n        xml_document<Ch> *document() const\r\n        {\r\n            xml_node<Ch> *node = const_cast<xml_node<Ch> *>(this);\r\n            while (node->parent())\r\n                node = node->parent();\r\n            return node->type() == node_document ? static_cast<xml_document<Ch> *>(node) : 0;\r\n        }\r\n\r\n        //! Gets first child node, optionally matching node name.\r\n        //! \\param name Name of child to find, or 0 to return first child regardless of its name; this string doesn't have to be zero-terminated if name_size is non-zero\r\n        //! \\param name_size Size of name, in characters, or 0 to have size calculated automatically from string\r\n        //! \\param case_sensitive Should name comparison be case-sensitive; non case-sensitive comparison works properly only for ASCII characters\r\n        //! \\return Pointer to found child, or 0 if not found.\r\n        xml_node<Ch> *first_node(const Ch *name = 0, std::size_t name_size = 0, bool case_sensitive = true) const\r\n        {\r\n            if (name)\r\n            {\r\n                if (name_size == 0)\r\n                    name_size = internal::measure(name);\r\n                for (xml_node<Ch> *child = m_first_node; child; child = child->next_sibling())\r\n                    if (internal::compare(child->name(), child->name_size(), name, name_size, case_sensitive))\r\n                        return child;\r\n                return 0;\r\n            }\r\n            else\r\n                return m_first_node;\r\n        }\r\n\r\n        //! Gets last child node, optionally matching node name. \r\n        //! Behaviour is undefined if node has no children.\r\n        //! Use first_node() to test if node has children.\r\n        //! \\param name Name of child to find, or 0 to return last child regardless of its name; this string doesn't have to be zero-terminated if name_size is non-zero\r\n        //! \\param name_size Size of name, in characters, or 0 to have size calculated automatically from string\r\n        //! \\param case_sensitive Should name comparison be case-sensitive; non case-sensitive comparison works properly only for ASCII characters\r\n        //! \\return Pointer to found child, or 0 if not found.\r\n        xml_node<Ch> *last_node(const Ch *name = 0, std::size_t name_size = 0, bool case_sensitive = true) const\r\n        {\r\n            assert(m_first_node);  // Cannot query for last child if node has no children\r\n            if (name)\r\n            {\r\n                if (name_size == 0)\r\n                    name_size = internal::measure(name);\r\n                for (xml_node<Ch> *child = m_last_node; child; child = child->previous_sibling())\r\n                    if (internal::compare(child->name(), child->name_size(), name, name_size, case_sensitive))\r\n                        return child;\r\n                return 0;\r\n            }\r\n            else\r\n                return m_last_node;\r\n        }\r\n\r\n        //! Gets previous sibling node, optionally matching node name. \r\n        //! Behaviour is undefined if node has no parent.\r\n        //! Use parent() to test if node has a parent.\r\n        //! \\param name Name of sibling to find, or 0 to return previous sibling regardless of its name; this string doesn't have to be zero-terminated if name_size is non-zero\r\n        //! \\param name_size Size of name, in characters, or 0 to have size calculated automatically from string\r\n        //! \\param case_sensitive Should name comparison be case-sensitive; non case-sensitive comparison works properly only for ASCII characters\r\n        //! \\return Pointer to found sibling, or 0 if not found.\r\n        xml_node<Ch> *previous_sibling(const Ch *name = 0, std::size_t name_size = 0, bool case_sensitive = true) const\r\n        {\r\n            assert(this->m_parent);     // Cannot query for siblings if node has no parent\r\n            if (name)\r\n            {\r\n                if (name_size == 0)\r\n                    name_size = internal::measure(name);\r\n                for (xml_node<Ch> *sibling = m_prev_sibling; sibling; sibling = sibling->m_prev_sibling)\r\n                    if (internal::compare(sibling->name(), sibling->name_size(), name, name_size, case_sensitive))\r\n                        return sibling;\r\n                return 0;\r\n            }\r\n            else\r\n                return m_prev_sibling;\r\n        }\r\n\r\n        //! Gets next sibling node, optionally matching node name. \r\n        //! Behaviour is undefined if node has no parent.\r\n        //! Use parent() to test if node has a parent.\r\n        //! \\param name Name of sibling to find, or 0 to return next sibling regardless of its name; this string doesn't have to be zero-terminated if name_size is non-zero\r\n        //! \\param name_size Size of name, in characters, or 0 to have size calculated automatically from string\r\n        //! \\param case_sensitive Should name comparison be case-sensitive; non case-sensitive comparison works properly only for ASCII characters\r\n        //! \\return Pointer to found sibling, or 0 if not found.\r\n        xml_node<Ch> *next_sibling(const Ch *name = 0, std::size_t name_size = 0, bool case_sensitive = true) const\r\n        {\r\n            assert(this->m_parent);     // Cannot query for siblings if node has no parent\r\n            if (name)\r\n            {\r\n                if (name_size == 0)\r\n                    name_size = internal::measure(name);\r\n                for (xml_node<Ch> *sibling = m_next_sibling; sibling; sibling = sibling->m_next_sibling)\r\n                    if (internal::compare(sibling->name(), sibling->name_size(), name, name_size, case_sensitive))\r\n                        return sibling;\r\n                return 0;\r\n            }\r\n            else\r\n                return m_next_sibling;\r\n        }\r\n\r\n        //! Gets first attribute of node, optionally matching attribute name.\r\n        //! \\param name Name of attribute to find, or 0 to return first attribute regardless of its name; this string doesn't have to be zero-terminated if name_size is non-zero\r\n        //! \\param name_size Size of name, in characters, or 0 to have size calculated automatically from string\r\n        //! \\param case_sensitive Should name comparison be case-sensitive; non case-sensitive comparison works properly only for ASCII characters\r\n        //! \\return Pointer to found attribute, or 0 if not found.\r\n        xml_attribute<Ch> *first_attribute(const Ch *name = 0, std::size_t name_size = 0, bool case_sensitive = true) const\r\n        {\r\n            if (name)\r\n            {\r\n                if (name_size == 0)\r\n                    name_size = internal::measure(name);\r\n                for (xml_attribute<Ch> *attribute = m_first_attribute; attribute; attribute = attribute->m_next_attribute)\r\n                    if (internal::compare(attribute->name(), attribute->name_size(), name, name_size, case_sensitive))\r\n                        return attribute;\r\n                return 0;\r\n            }\r\n            else\r\n                return m_first_attribute;\r\n        }\r\n\r\n        //! Gets last attribute of node, optionally matching attribute name.\r\n        //! \\param name Name of attribute to find, or 0 to return last attribute regardless of its name; this string doesn't have to be zero-terminated if name_size is non-zero\r\n        //! \\param name_size Size of name, in characters, or 0 to have size calculated automatically from string\r\n        //! \\param case_sensitive Should name comparison be case-sensitive; non case-sensitive comparison works properly only for ASCII characters\r\n        //! \\return Pointer to found attribute, or 0 if not found.\r\n        xml_attribute<Ch> *last_attribute(const Ch *name = 0, std::size_t name_size = 0, bool case_sensitive = true) const\r\n        {\r\n            if (name)\r\n            {\r\n                if (name_size == 0)\r\n                    name_size = internal::measure(name);\r\n                for (xml_attribute<Ch> *attribute = m_last_attribute; attribute; attribute = attribute->m_prev_attribute)\r\n                    if (internal::compare(attribute->name(), attribute->name_size(), name, name_size, case_sensitive))\r\n                        return attribute;\r\n                return 0;\r\n            }\r\n            else\r\n                return m_first_attribute ? m_last_attribute : 0;\r\n        }\r\n\r\n        ///////////////////////////////////////////////////////////////////////////\r\n        // Node modification\r\n    \r\n        //! Sets type of node.\r\n        //! \\param type Type of node to set.\r\n        void type(node_type type)\r\n        {\r\n            m_type = type;\r\n        }\r\n\r\n        ///////////////////////////////////////////////////////////////////////////\r\n        // Node manipulation\r\n\r\n        //! Prepends a new child node.\r\n        //! The prepended child becomes the first child, and all existing children are moved one position back.\r\n        //! \\param child Node to prepend.\r\n        void prepend_node(xml_node<Ch> *child)\r\n        {\r\n            assert(child && !child->parent() && child->type() != node_document);\r\n            if (first_node())\r\n            {\r\n                child->m_next_sibling = m_first_node;\r\n                m_first_node->m_prev_sibling = child;\r\n            }\r\n            else\r\n            {\r\n                child->m_next_sibling = 0;\r\n                m_last_node = child;\r\n            }\r\n            m_first_node = child;\r\n            child->m_parent = this;\r\n            child->m_prev_sibling = 0;\r\n        }\r\n\r\n        //! Appends a new child node. \r\n        //! The appended child becomes the last child.\r\n        //! \\param child Node to append.\r\n        void append_node(xml_node<Ch> *child)\r\n        {\r\n            assert(child && !child->parent() && child->type() != node_document);\r\n            if (first_node())\r\n            {\r\n                child->m_prev_sibling = m_last_node;\r\n                m_last_node->m_next_sibling = child;\r\n            }\r\n            else\r\n            {\r\n                child->m_prev_sibling = 0;\r\n                m_first_node = child;\r\n            }\r\n            m_last_node = child;\r\n            child->m_parent = this;\r\n            child->m_next_sibling = 0;\r\n        }\r\n\r\n        //! Inserts a new child node at specified place inside the node. \r\n        //! All children after and including the specified node are moved one position back.\r\n        //! \\param where Place where to insert the child, or 0 to insert at the back.\r\n        //! \\param child Node to insert.\r\n        void insert_node(xml_node<Ch> *where, xml_node<Ch> *child)\r\n        {\r\n            assert(!where || where->parent() == this);\r\n            assert(child && !child->parent() && child->type() != node_document);\r\n            if (where == m_first_node)\r\n                prepend_node(child);\r\n            else if (where == 0)\r\n                append_node(child);\r\n            else\r\n            {\r\n                child->m_prev_sibling = where->m_prev_sibling;\r\n                child->m_next_sibling = where;\r\n                where->m_prev_sibling->m_next_sibling = child;\r\n                where->m_prev_sibling = child;\r\n                child->m_parent = this;\r\n            }\r\n        }\r\n\r\n        //! Removes first child node. \r\n        //! If node has no children, behaviour is undefined.\r\n        //! Use first_node() to test if node has children.\r\n        void remove_first_node()\r\n        {\r\n            assert(first_node());\r\n            xml_node<Ch> *child = m_first_node;\r\n            m_first_node = child->m_next_sibling;\r\n            if (child->m_next_sibling)\r\n                child->m_next_sibling->m_prev_sibling = 0;\r\n            else\r\n                m_last_node = 0;\r\n            child->m_parent = 0;\r\n        }\r\n\r\n        //! Removes last child of the node. \r\n        //! If node has no children, behaviour is undefined.\r\n        //! Use first_node() to test if node has children.\r\n        void remove_last_node()\r\n        {\r\n            assert(first_node());\r\n            xml_node<Ch> *child = m_last_node;\r\n            if (child->m_prev_sibling)\r\n            {\r\n                m_last_node = child->m_prev_sibling;\r\n                child->m_prev_sibling->m_next_sibling = 0;\r\n            }\r\n            else\r\n                m_first_node = 0;\r\n            child->m_parent = 0;\r\n        }\r\n\r\n        //! Removes specified child from the node\r\n        // \\param where Pointer to child to be removed.\r\n        void remove_node(xml_node<Ch> *where)\r\n        {\r\n            assert(where && where->parent() == this);\r\n            assert(first_node());\r\n            if (where == m_first_node)\r\n                remove_first_node();\r\n            else if (where == m_last_node)\r\n                remove_last_node();\r\n            else\r\n            {\r\n                where->m_prev_sibling->m_next_sibling = where->m_next_sibling;\r\n                where->m_next_sibling->m_prev_sibling = where->m_prev_sibling;\r\n                where->m_parent = 0;\r\n            }\r\n        }\r\n\r\n        //! Removes all child nodes (but not attributes).\r\n        void remove_all_nodes()\r\n        {\r\n            for (xml_node<Ch> *node = first_node(); node; node = node->m_next_sibling)\r\n                node->m_parent = 0;\r\n            m_first_node = 0;\r\n        }\r\n\r\n        //! Prepends a new attribute to the node.\r\n        //! \\param attribute Attribute to prepend.\r\n        void prepend_attribute(xml_attribute<Ch> *attribute)\r\n        {\r\n            assert(attribute && !attribute->parent());\r\n            if (first_attribute())\r\n            {\r\n                attribute->m_next_attribute = m_first_attribute;\r\n                m_first_attribute->m_prev_attribute = attribute;\r\n            }\r\n            else\r\n            {\r\n                attribute->m_next_attribute = 0;\r\n                m_last_attribute = attribute;\r\n            }\r\n            m_first_attribute = attribute;\r\n            attribute->m_parent = this;\r\n            attribute->m_prev_attribute = 0;\r\n        }\r\n\r\n        //! Appends a new attribute to the node.\r\n        //! \\param attribute Attribute to append.\r\n        void append_attribute(xml_attribute<Ch> *attribute)\r\n        {\r\n            assert(attribute && !attribute->parent());\r\n            if (first_attribute())\r\n            {\r\n                attribute->m_prev_attribute = m_last_attribute;\r\n                m_last_attribute->m_next_attribute = attribute;\r\n            }\r\n            else\r\n            {\r\n                attribute->m_prev_attribute = 0;\r\n                m_first_attribute = attribute;\r\n            }\r\n            m_last_attribute = attribute;\r\n            attribute->m_parent = this;\r\n            attribute->m_next_attribute = 0;\r\n        }\r\n\r\n        //! Inserts a new attribute at specified place inside the node. \r\n        //! All attributes after and including the specified attribute are moved one position back.\r\n        //! \\param where Place where to insert the attribute, or 0 to insert at the back.\r\n        //! \\param attribute Attribute to insert.\r\n        void insert_attribute(xml_attribute<Ch> *where, xml_attribute<Ch> *attribute)\r\n        {\r\n            assert(!where || where->parent() == this);\r\n            assert(attribute && !attribute->parent());\r\n            if (where == m_first_attribute)\r\n                prepend_attribute(attribute);\r\n            else if (where == 0)\r\n                append_attribute(attribute);\r\n            else\r\n            {\r\n                attribute->m_prev_attribute = where->m_prev_attribute;\r\n                attribute->m_next_attribute = where;\r\n                where->m_prev_attribute->m_next_attribute = attribute;\r\n                where->m_prev_attribute = attribute;\r\n                attribute->m_parent = this;\r\n            }\r\n        }\r\n\r\n        //! Removes first attribute of the node. \r\n        //! If node has no attributes, behaviour is undefined.\r\n        //! Use first_attribute() to test if node has attributes.\r\n        void remove_first_attribute()\r\n        {\r\n            assert(first_attribute());\r\n            xml_attribute<Ch> *attribute = m_first_attribute;\r\n            if (attribute->m_next_attribute)\r\n            {\r\n                attribute->m_next_attribute->m_prev_attribute = 0;\r\n            }\r\n            else\r\n                m_last_attribute = 0;\r\n            attribute->m_parent = 0;\r\n            m_first_attribute = attribute->m_next_attribute;\r\n        }\r\n\r\n        //! Removes last attribute of the node. \r\n        //! If node has no attributes, behaviour is undefined.\r\n        //! Use first_attribute() to test if node has attributes.\r\n        void remove_last_attribute()\r\n        {\r\n            assert(first_attribute());\r\n            xml_attribute<Ch> *attribute = m_last_attribute;\r\n            if (attribute->m_prev_attribute)\r\n            {\r\n                attribute->m_prev_attribute->m_next_attribute = 0;\r\n                m_last_attribute = attribute->m_prev_attribute;\r\n            }\r\n            else\r\n                m_first_attribute = 0;\r\n            attribute->m_parent = 0;\r\n        }\r\n\r\n        //! Removes specified attribute from node.\r\n        //! \\param where Pointer to attribute to be removed.\r\n        void remove_attribute(xml_attribute<Ch> *where)\r\n        {\r\n            assert(first_attribute() && where->parent() == this);\r\n            if (where == m_first_attribute)\r\n                remove_first_attribute();\r\n            else if (where == m_last_attribute)\r\n                remove_last_attribute();\r\n            else\r\n            {\r\n                where->m_prev_attribute->m_next_attribute = where->m_next_attribute;\r\n                where->m_next_attribute->m_prev_attribute = where->m_prev_attribute;\r\n                where->m_parent = 0;\r\n            }\r\n        }\r\n\r\n        //! Removes all attributes of node.\r\n        void remove_all_attributes()\r\n        {\r\n            for (xml_attribute<Ch> *attribute = first_attribute(); attribute; attribute = attribute->m_next_attribute)\r\n                attribute->m_parent = 0;\r\n            m_first_attribute = 0;\r\n        }\r\n        \r\n    private:\r\n\r\n        ///////////////////////////////////////////////////////////////////////////\r\n        // Restrictions\r\n\r\n        // No copying\r\n        xml_node(const xml_node &);\r\n        void operator =(const xml_node &);\r\n    \r\n        ///////////////////////////////////////////////////////////////////////////\r\n        // Data members\r\n    \r\n        // Note that some of the pointers below have UNDEFINED values if certain other pointers are 0.\r\n        // This is required for maximum performance, as it allows the parser to omit initialization of \r\n        // unneded/redundant values.\r\n        //\r\n        // The rules are as follows:\r\n        // 1. first_node and first_attribute contain valid pointers, or 0 if node has no children/attributes respectively\r\n        // 2. last_node and last_attribute are valid only if node has at least one child/attribute respectively, otherwise they contain garbage\r\n        // 3. prev_sibling and next_sibling are valid only if node has a parent, otherwise they contain garbage\r\n\r\n        node_type m_type;                       // Type of node; always valid\r\n        xml_node<Ch> *m_first_node;             // Pointer to first child node, or 0 if none; always valid\r\n        xml_node<Ch> *m_last_node;              // Pointer to last child node, or 0 if none; this value is only valid if m_first_node is non-zero\r\n        xml_attribute<Ch> *m_first_attribute;   // Pointer to first attribute of node, or 0 if none; always valid\r\n        xml_attribute<Ch> *m_last_attribute;    // Pointer to last attribute of node, or 0 if none; this value is only valid if m_first_attribute is non-zero\r\n        xml_node<Ch> *m_prev_sibling;           // Pointer to previous sibling of node, or 0 if none; this value is only valid if m_parent is non-zero\r\n        xml_node<Ch> *m_next_sibling;           // Pointer to next sibling of node, or 0 if none; this value is only valid if m_parent is non-zero\r\n\r\n    };\r\n\r\n    ///////////////////////////////////////////////////////////////////////////\r\n    // XML document\r\n    \r\n    //! This class represents root of the DOM hierarchy. \r\n    //! It is also an xml_node and a memory_pool through public inheritance.\r\n    //! Use parse() function to build a DOM tree from a zero-terminated XML text string.\r\n    //! parse() function allocates memory for nodes and attributes by using functions of xml_document, \r\n    //! which are inherited from memory_pool.\r\n    //! To access root node of the document, use the document itself, as if it was an xml_node.\r\n    //! \\param Ch Character type to use.\r\n    template<class Ch = char>\r\n    class xml_document: public xml_node<Ch>, public memory_pool<Ch>\r\n    {\r\n    \r\n    public:\r\n\r\n        //! Constructs empty XML document\r\n        xml_document()\r\n            : xml_node<Ch>(node_document)\r\n        {\r\n        }\r\n\r\n        //! Parses zero-terminated XML string according to given flags.\r\n        //! Passed string will be modified by the parser, unless rapidxml::parse_non_destructive flag is used.\r\n        //! The string must persist for the lifetime of the document.\r\n        //! In case of error, rapidxml::parse_error exception will be thrown.\r\n        //! <br><br>\r\n        //! If you want to parse contents of a file, you must first load the file into the memory, and pass pointer to its beginning.\r\n        //! Make sure that data is zero-terminated.\r\n        //! <br><br>\r\n        //! Document can be parsed into multiple times. \r\n        //! Each new call to parse removes previous nodes and attributes (if any), but does not clear memory pool.\r\n        //! \\param text XML data to parse; pointer is non-const to denote fact that this data may be modified by the parser.\r\n        template<int Flags>\r\n        void parse(Ch *text)\r\n        {\r\n            assert(text);\r\n            \r\n            // Remove current contents\r\n            this->remove_all_nodes();\r\n            this->remove_all_attributes();\r\n            \r\n            // Parse BOM, if any\r\n            parse_bom<Flags>(text);\r\n            \r\n            // Parse children\r\n            while (1)\r\n            {\r\n                // Skip whitespace before node\r\n                skip<whitespace_pred, Flags>(text);\r\n                if (*text == 0)\r\n                    break;\r\n\r\n                // Parse and append new child\r\n                if (*text == Ch('<'))\r\n                {\r\n                    ++text;     // Skip '<'\r\n                    if (xml_node<Ch> *node = parse_node<Flags>(text))\r\n                        this->append_node(node);\r\n                }\r\n                else\r\n                    RAPIDXML_PARSE_ERROR(\"expected <\", text);\r\n            }\r\n\r\n        }\r\n\r\n        //! Clears the document by deleting all nodes and clearing the memory pool.\r\n        //! All nodes owned by document pool are destroyed.\r\n        void clear()\r\n        {\r\n            this->remove_all_nodes();\r\n            this->remove_all_attributes();\r\n            memory_pool<Ch>::clear();\r\n        }\r\n        \r\n    private:\r\n\r\n        ///////////////////////////////////////////////////////////////////////\r\n        // Internal character utility functions\r\n        \r\n        // Detect whitespace character\r\n        struct whitespace_pred\r\n        {\r\n            static unsigned char test(Ch ch)\r\n            {\r\n                return internal::lookup_tables<0>::lookup_whitespace[static_cast<unsigned char>(ch)];\r\n            }\r\n        };\r\n\r\n        // Detect node name character\r\n        struct node_name_pred\r\n        {\r\n            static unsigned char test(Ch ch)\r\n            {\r\n                return internal::lookup_tables<0>::lookup_node_name[static_cast<unsigned char>(ch)];\r\n            }\r\n        };\r\n\r\n        // Detect attribute name character\r\n        struct attribute_name_pred\r\n        {\r\n            static unsigned char test(Ch ch)\r\n            {\r\n                return internal::lookup_tables<0>::lookup_attribute_name[static_cast<unsigned char>(ch)];\r\n            }\r\n        };\r\n\r\n        // Detect text character (PCDATA)\r\n        struct text_pred\r\n        {\r\n            static unsigned char test(Ch ch)\r\n            {\r\n                return internal::lookup_tables<0>::lookup_text[static_cast<unsigned char>(ch)];\r\n            }\r\n        };\r\n\r\n        // Detect text character (PCDATA) that does not require processing\r\n        struct text_pure_no_ws_pred\r\n        {\r\n            static unsigned char test(Ch ch)\r\n            {\r\n                return internal::lookup_tables<0>::lookup_text_pure_no_ws[static_cast<unsigned char>(ch)];\r\n            }\r\n        };\r\n\r\n        // Detect text character (PCDATA) that does not require processing\r\n        struct text_pure_with_ws_pred\r\n        {\r\n            static unsigned char test(Ch ch)\r\n            {\r\n                return internal::lookup_tables<0>::lookup_text_pure_with_ws[static_cast<unsigned char>(ch)];\r\n            }\r\n        };\r\n\r\n        // Detect attribute value character\r\n        template<Ch Quote>\r\n        struct attribute_value_pred\r\n        {\r\n            static unsigned char test(Ch ch)\r\n            {\r\n                if (Quote == Ch('\\''))\r\n                    return internal::lookup_tables<0>::lookup_attribute_data_1[static_cast<unsigned char>(ch)];\r\n                if (Quote == Ch('\\\"'))\r\n                    return internal::lookup_tables<0>::lookup_attribute_data_2[static_cast<unsigned char>(ch)];\r\n                return 0;       // Should never be executed, to avoid warnings on Comeau\r\n            }\r\n        };\r\n\r\n        // Detect attribute value character\r\n        template<Ch Quote>\r\n        struct attribute_value_pure_pred\r\n        {\r\n            static unsigned char test(Ch ch)\r\n            {\r\n                if (Quote == Ch('\\''))\r\n                    return internal::lookup_tables<0>::lookup_attribute_data_1_pure[static_cast<unsigned char>(ch)];\r\n                if (Quote == Ch('\\\"'))\r\n                    return internal::lookup_tables<0>::lookup_attribute_data_2_pure[static_cast<unsigned char>(ch)];\r\n                return 0;       // Should never be executed, to avoid warnings on Comeau\r\n            }\r\n        };\r\n\r\n        // Insert coded character, using UTF8 or 8-bit ASCII\r\n        template<int Flags>\r\n        static void insert_coded_character(Ch *&text, unsigned long code)\r\n        {\r\n            if (Flags & parse_no_utf8)\r\n            {\r\n                // Insert 8-bit ASCII character\r\n                // Todo: possibly verify that code is less than 256 and use replacement char otherwise?\r\n                text[0] = static_cast<unsigned char>(code);\r\n                text += 1;\r\n            }\r\n            else\r\n            {\r\n                // Insert UTF8 sequence\r\n                if (code < 0x80)    // 1 byte sequence\r\n                {\r\n\t                text[0] = static_cast<unsigned char>(code);\r\n                    text += 1;\r\n                }\r\n                else if (code < 0x800)  // 2 byte sequence\r\n                {\r\n\t                text[1] = static_cast<unsigned char>((code | 0x80) & 0xBF); code >>= 6;\r\n\t                text[0] = static_cast<unsigned char>(code | 0xC0);\r\n                    text += 2;\r\n                }\r\n\t            else if (code < 0x10000)    // 3 byte sequence\r\n                {\r\n\t                text[2] = static_cast<unsigned char>((code | 0x80) & 0xBF); code >>= 6;\r\n\t                text[1] = static_cast<unsigned char>((code | 0x80) & 0xBF); code >>= 6;\r\n\t                text[0] = static_cast<unsigned char>(code | 0xE0);\r\n                    text += 3;\r\n                }\r\n\t            else if (code < 0x110000)   // 4 byte sequence\r\n                {\r\n\t                text[3] = static_cast<unsigned char>((code | 0x80) & 0xBF); code >>= 6;\r\n\t                text[2] = static_cast<unsigned char>((code | 0x80) & 0xBF); code >>= 6;\r\n\t                text[1] = static_cast<unsigned char>((code | 0x80) & 0xBF); code >>= 6;\r\n\t                text[0] = static_cast<unsigned char>(code | 0xF0);\r\n                    text += 4;\r\n                }\r\n                else    // Invalid, only codes up to 0x10FFFF are allowed in Unicode\r\n                {\r\n                    RAPIDXML_PARSE_ERROR(\"invalid numeric character entity\", text);\r\n                }\r\n            }\r\n        }\r\n\r\n        // Skip characters until predicate evaluates to true\r\n        template<class StopPred, int Flags>\r\n        static void skip(Ch *&text)\r\n        {\r\n            Ch *tmp = text;\r\n            while (StopPred::test(*tmp))\r\n                ++tmp;\r\n            text = tmp;\r\n        }\r\n\r\n        // Skip characters until predicate evaluates to true while doing the following:\r\n        // - replacing XML character entity references with proper characters (&apos; &amp; &quot; &lt; &gt; &#...;)\r\n        // - condensing whitespace sequences to single space character\r\n        template<class StopPred, class StopPredPure, int Flags>\r\n        static Ch *skip_and_expand_character_refs(Ch *&text)\r\n        {\r\n            // If entity translation, whitespace condense and whitespace trimming is disabled, use plain skip\r\n            if (Flags & parse_no_entity_translation && \r\n                !(Flags & parse_normalize_whitespace) &&\r\n                !(Flags & parse_trim_whitespace))\r\n            {\r\n                skip<StopPred, Flags>(text);\r\n                return text;\r\n            }\r\n            \r\n            // Use simple skip until first modification is detected\r\n            skip<StopPredPure, Flags>(text);\r\n\r\n            // Use translation skip\r\n            Ch *src = text;\r\n            Ch *dest = src;\r\n            while (StopPred::test(*src))\r\n            {\r\n                // If entity translation is enabled    \r\n                if (!(Flags & parse_no_entity_translation))\r\n                {\r\n                    // Test if replacement is needed\r\n                    if (src[0] == Ch('&'))\r\n                    {\r\n                        switch (src[1])\r\n                        {\r\n\r\n                        // &amp; &apos;\r\n                        case Ch('a'): \r\n                            if (src[2] == Ch('m') && src[3] == Ch('p') && src[4] == Ch(';'))\r\n                            {\r\n                                *dest = Ch('&');\r\n                                ++dest;\r\n                                src += 5;\r\n                                continue;\r\n                            }\r\n                            if (src[2] == Ch('p') && src[3] == Ch('o') && src[4] == Ch('s') && src[5] == Ch(';'))\r\n                            {\r\n                                *dest = Ch('\\'');\r\n                                ++dest;\r\n                                src += 6;\r\n                                continue;\r\n                            }\r\n                            break;\r\n\r\n                        // &quot;\r\n                        case Ch('q'): \r\n                            if (src[2] == Ch('u') && src[3] == Ch('o') && src[4] == Ch('t') && src[5] == Ch(';'))\r\n                            {\r\n                                *dest = Ch('\"');\r\n                                ++dest;\r\n                                src += 6;\r\n                                continue;\r\n                            }\r\n                            break;\r\n\r\n                        // &gt;\r\n                        case Ch('g'): \r\n                            if (src[2] == Ch('t') && src[3] == Ch(';'))\r\n                            {\r\n                                *dest = Ch('>');\r\n                                ++dest;\r\n                                src += 4;\r\n                                continue;\r\n                            }\r\n                            break;\r\n\r\n                        // &lt;\r\n                        case Ch('l'): \r\n                            if (src[2] == Ch('t') && src[3] == Ch(';'))\r\n                            {\r\n                                *dest = Ch('<');\r\n                                ++dest;\r\n                                src += 4;\r\n                                continue;\r\n                            }\r\n                            break;\r\n\r\n                        // &#...; - assumes ASCII\r\n                        case Ch('#'): \r\n                            if (src[2] == Ch('x'))\r\n                            {\r\n                                unsigned long code = 0;\r\n                                src += 3;   // Skip &#x\r\n                                while (1)\r\n                                {\r\n                                    unsigned char digit = internal::lookup_tables<0>::lookup_digits[static_cast<unsigned char>(*src)];\r\n                                    if (digit == 0xFF)\r\n                                        break;\r\n                                    code = code * 16 + digit;\r\n                                    ++src;\r\n                                }\r\n                                insert_coded_character<Flags>(dest, code);    // Put character in output\r\n                            }\r\n                            else\r\n                            {\r\n                                unsigned long code = 0;\r\n                                src += 2;   // Skip &#\r\n                                while (1)\r\n                                {\r\n                                    unsigned char digit = internal::lookup_tables<0>::lookup_digits[static_cast<unsigned char>(*src)];\r\n                                    if (digit == 0xFF)\r\n                                        break;\r\n                                    code = code * 10 + digit;\r\n                                    ++src;\r\n                                }\r\n                                insert_coded_character<Flags>(dest, code);    // Put character in output\r\n                            }\r\n                            if (*src == Ch(';'))\r\n                                ++src;\r\n                            else\r\n                                RAPIDXML_PARSE_ERROR(\"expected ;\", src);\r\n                            continue;\r\n\r\n                        // Something else\r\n                        default:\r\n                            // Ignore, just copy '&' verbatim\r\n                            break;\r\n\r\n                        }\r\n                    }\r\n                }\r\n                \r\n                // If whitespace condensing is enabled\r\n                if (Flags & parse_normalize_whitespace)\r\n                {\r\n                    // Test if condensing is needed                 \r\n                    if (whitespace_pred::test(*src))\r\n                    {\r\n                        *dest = Ch(' '); ++dest;    // Put single space in dest\r\n                        ++src;                      // Skip first whitespace char\r\n                        // Skip remaining whitespace chars\r\n                        while (whitespace_pred::test(*src))\r\n                            ++src;\r\n                        continue;\r\n                    }\r\n                }\r\n\r\n                // No replacement, only copy character\r\n                *dest++ = *src++;\r\n\r\n            }\r\n\r\n            // Return new end\r\n            text = src;\r\n            return dest;\r\n\r\n        }\r\n\r\n        ///////////////////////////////////////////////////////////////////////\r\n        // Internal parsing functions\r\n        \r\n        // Parse BOM, if any\r\n        template<int Flags>\r\n        void parse_bom(Ch *&text)\r\n        {\r\n            // UTF-8?\r\n            if (static_cast<unsigned char>(text[0]) == 0xEF && \r\n                static_cast<unsigned char>(text[1]) == 0xBB && \r\n                static_cast<unsigned char>(text[2]) == 0xBF)\r\n            {\r\n                text += 3;      // Skup utf-8 bom\r\n            }\r\n        }\r\n\r\n        // Parse XML declaration (<?xml...)\r\n        template<int Flags>\r\n        xml_node<Ch> *parse_xml_declaration(Ch *&text)\r\n        {\r\n            // If parsing of declaration is disabled\r\n            if (!(Flags & parse_declaration_node))\r\n            {\r\n                // Skip until end of declaration\r\n                while (text[0] != Ch('?') || text[1] != Ch('>'))\r\n                {\r\n                    if (!text[0])\r\n                        RAPIDXML_PARSE_ERROR(\"unexpected end of data\", text);\r\n                    ++text;\r\n                }\r\n                text += 2;    // Skip '?>'\r\n                return 0;\r\n            }\r\n\r\n            // Create declaration\r\n            xml_node<Ch> *declaration = this->allocate_node(node_declaration);\r\n\r\n            // Skip whitespace before attributes or ?>\r\n            skip<whitespace_pred, Flags>(text);\r\n\r\n            // Parse declaration attributes\r\n            parse_node_attributes<Flags>(text, declaration);\r\n            \r\n            // Skip ?>\r\n            if (text[0] != Ch('?') || text[1] != Ch('>'))\r\n                RAPIDXML_PARSE_ERROR(\"expected ?>\", text);\r\n            text += 2;\r\n            \r\n            return declaration;\r\n        }\r\n\r\n        // Parse XML comment (<!--...)\r\n        template<int Flags>\r\n        xml_node<Ch> *parse_comment(Ch *&text)\r\n        {\r\n            // If parsing of comments is disabled\r\n            if (!(Flags & parse_comment_nodes))\r\n            {\r\n                // Skip until end of comment\r\n                while (text[0] != Ch('-') || text[1] != Ch('-') || text[2] != Ch('>'))\r\n                {\r\n                    if (!text[0])\r\n                        RAPIDXML_PARSE_ERROR(\"unexpected end of data\", text);\r\n                    ++text;\r\n                }\r\n                text += 3;     // Skip '-->'\r\n                return 0;      // Do not produce comment node\r\n            }\r\n\r\n            // Remember value start\r\n            Ch *value = text;\r\n\r\n            // Skip until end of comment\r\n            while (text[0] != Ch('-') || text[1] != Ch('-') || text[2] != Ch('>'))\r\n            {\r\n                if (!text[0])\r\n                    RAPIDXML_PARSE_ERROR(\"unexpected end of data\", text);\r\n                ++text;\r\n            }\r\n\r\n            // Create comment node\r\n            xml_node<Ch> *comment = this->allocate_node(node_comment);\r\n            comment->value(value, text - value);\r\n            \r\n            // Place zero terminator after comment value\r\n            if (!(Flags & parse_no_string_terminators))\r\n                *text = Ch('\\0');\r\n            \r\n            text += 3;     // Skip '-->'\r\n            return comment;\r\n        }\r\n\r\n        // Parse DOCTYPE\r\n        template<int Flags>\r\n        xml_node<Ch> *parse_doctype(Ch *&text)\r\n        {\r\n            // Remember value start\r\n            Ch *value = text;\r\n\r\n            // Skip to >\r\n            while (*text != Ch('>'))\r\n            {\r\n                // Determine character type\r\n                switch (*text)\r\n                {\r\n                \r\n                // If '[' encountered, scan for matching ending ']' using naive algorithm with depth\r\n                // This works for all W3C test files except for 2 most wicked\r\n                case Ch('['):\r\n                {\r\n                    ++text;     // Skip '['\r\n                    int depth = 1;\r\n                    while (depth > 0)\r\n                    {\r\n                        switch (*text)\r\n                        {\r\n                            case Ch('['): ++depth; break;\r\n                            case Ch(']'): --depth; break;\r\n                            case 0: RAPIDXML_PARSE_ERROR(\"unexpected end of data\", text);\r\n                        }\r\n                        ++text;\r\n                    }\r\n                    break;\r\n                }\r\n                \r\n                // Error on end of text\r\n                case Ch('\\0'):\r\n                    RAPIDXML_PARSE_ERROR(\"unexpected end of data\", text);\r\n                \r\n                // Other character, skip it\r\n                default:\r\n                    ++text;\r\n\r\n                }\r\n            }\r\n            \r\n            // If DOCTYPE nodes enabled\r\n            if (Flags & parse_doctype_node)\r\n            {\r\n                // Create a new doctype node\r\n                xml_node<Ch> *doctype = this->allocate_node(node_doctype);\r\n                doctype->value(value, text - value);\r\n                \r\n                // Place zero terminator after value\r\n                if (!(Flags & parse_no_string_terminators))\r\n                    *text = Ch('\\0');\r\n\r\n                text += 1;      // skip '>'\r\n                return doctype;\r\n            }\r\n            else\r\n            {\r\n                text += 1;      // skip '>'\r\n                return 0;\r\n            }\r\n\r\n        }\r\n\r\n        // Parse PI\r\n        template<int Flags>\r\n        xml_node<Ch> *parse_pi(Ch *&text)\r\n        {\r\n            // If creation of PI nodes is enabled\r\n            if (Flags & parse_pi_nodes)\r\n            {\r\n                // Create pi node\r\n                xml_node<Ch> *pi = this->allocate_node(node_pi);\r\n\r\n                // Extract PI target name\r\n                Ch *name = text;\r\n                skip<node_name_pred, Flags>(text);\r\n                if (text == name)\r\n                    RAPIDXML_PARSE_ERROR(\"expected PI target\", text);\r\n                pi->name(name, text - name);\r\n                \r\n                // Skip whitespace between pi target and pi\r\n                skip<whitespace_pred, Flags>(text);\r\n\r\n                // Remember start of pi\r\n                Ch *value = text;\r\n                \r\n                // Skip to '?>'\r\n                while (text[0] != Ch('?') || text[1] != Ch('>'))\r\n                {\r\n                    if (*text == Ch('\\0'))\r\n                        RAPIDXML_PARSE_ERROR(\"unexpected end of data\", text);\r\n                    ++text;\r\n                }\r\n\r\n                // Set pi value (verbatim, no entity expansion or whitespace normalization)\r\n                pi->value(value, text - value);     \r\n                \r\n                // Place zero terminator after name and value\r\n                if (!(Flags & parse_no_string_terminators))\r\n                {\r\n                    pi->name()[pi->name_size()] = Ch('\\0');\r\n                    pi->value()[pi->value_size()] = Ch('\\0');\r\n                }\r\n                \r\n                text += 2;                          // Skip '?>'\r\n                return pi;\r\n            }\r\n            else\r\n            {\r\n                // Skip to '?>'\r\n                while (text[0] != Ch('?') || text[1] != Ch('>'))\r\n                {\r\n                    if (*text == Ch('\\0'))\r\n                        RAPIDXML_PARSE_ERROR(\"unexpected end of data\", text);\r\n                    ++text;\r\n                }\r\n                text += 2;    // Skip '?>'\r\n                return 0;\r\n            }\r\n        }\r\n\r\n        // Parse and append data\r\n        // Return character that ends data.\r\n        // This is necessary because this character might have been overwritten by a terminating 0\r\n        template<int Flags>\r\n        Ch parse_and_append_data(xml_node<Ch> *node, Ch *&text, Ch *contents_start)\r\n        {\r\n            // Backup to contents start if whitespace trimming is disabled\r\n            if (!(Flags & parse_trim_whitespace))\r\n                text = contents_start;     \r\n            \r\n            // Skip until end of data\r\n            Ch *value = text, *end;\r\n            if (Flags & parse_normalize_whitespace)\r\n                end = skip_and_expand_character_refs<text_pred, text_pure_with_ws_pred, Flags>(text);   \r\n            else\r\n                end = skip_and_expand_character_refs<text_pred, text_pure_no_ws_pred, Flags>(text);\r\n\r\n            // Trim trailing whitespace if flag is set; leading was already trimmed by whitespace skip after >\r\n            if (Flags & parse_trim_whitespace)\r\n            {\r\n                if (Flags & parse_normalize_whitespace)\r\n                {\r\n                    // Whitespace is already condensed to single space characters by skipping function, so just trim 1 char off the end\r\n                    if (*(end - 1) == Ch(' '))\r\n                        --end;\r\n                }\r\n                else\r\n                {\r\n                    // Backup until non-whitespace character is found\r\n                    while (whitespace_pred::test(*(end - 1)))\r\n                        --end;\r\n                }\r\n            }\r\n            \r\n            // If characters are still left between end and value (this test is only necessary if normalization is enabled)\r\n            // Create new data node\r\n            if (!(Flags & parse_no_data_nodes))\r\n            {\r\n                xml_node<Ch> *data = this->allocate_node(node_data);\r\n                data->value(value, end - value);\r\n                node->append_node(data);\r\n            }\r\n\r\n            // Add data to parent node if no data exists yet\r\n            if (!(Flags & parse_no_element_values)) \r\n                if (*node->value() == Ch('\\0'))\r\n                    node->value(value, end - value);\r\n\r\n            // Place zero terminator after value\r\n            if (!(Flags & parse_no_string_terminators))\r\n            {\r\n                Ch ch = *text;\r\n                *end = Ch('\\0');\r\n                return ch;      // Return character that ends data; this is required because zero terminator overwritten it\r\n            }\r\n\r\n            // Return character that ends data\r\n            return *text;\r\n        }\r\n\r\n        // Parse CDATA\r\n        template<int Flags>\r\n        xml_node<Ch> *parse_cdata(Ch *&text)\r\n        {\r\n            // If CDATA is disabled\r\n            if (Flags & parse_no_data_nodes)\r\n            {\r\n                // Skip until end of cdata\r\n                while (text[0] != Ch(']') || text[1] != Ch(']') || text[2] != Ch('>'))\r\n                {\r\n                    if (!text[0])\r\n                        RAPIDXML_PARSE_ERROR(\"unexpected end of data\", text);\r\n                    ++text;\r\n                }\r\n                text += 3;      // Skip ]]>\r\n                return 0;       // Do not produce CDATA node\r\n            }\r\n\r\n            // Skip until end of cdata\r\n            Ch *value = text;\r\n            while (text[0] != Ch(']') || text[1] != Ch(']') || text[2] != Ch('>'))\r\n            {\r\n                if (!text[0])\r\n                    RAPIDXML_PARSE_ERROR(\"unexpected end of data\", text);\r\n                ++text;\r\n            }\r\n\r\n            // Create new cdata node\r\n            xml_node<Ch> *cdata = this->allocate_node(node_cdata);\r\n            cdata->value(value, text - value);\r\n\r\n            // Place zero terminator after value\r\n            if (!(Flags & parse_no_string_terminators))\r\n                *text = Ch('\\0');\r\n\r\n            text += 3;      // Skip ]]>\r\n            return cdata;\r\n        }\r\n        \r\n        // Parse element node\r\n        template<int Flags>\r\n        xml_node<Ch> *parse_element(Ch *&text)\r\n        {\r\n            // Create element node\r\n            xml_node<Ch> *element = this->allocate_node(node_element);\r\n\r\n            // Extract element name\r\n            Ch *name = text;\r\n            skip<node_name_pred, Flags>(text);\r\n            if (text == name)\r\n                RAPIDXML_PARSE_ERROR(\"expected element name\", text);\r\n            element->name(name, text - name);\r\n            \r\n            // Skip whitespace between element name and attributes or >\r\n            skip<whitespace_pred, Flags>(text);\r\n\r\n            // Parse attributes, if any\r\n            parse_node_attributes<Flags>(text, element);\r\n\r\n            // Determine ending type\r\n            if (*text == Ch('>'))\r\n            {\r\n                ++text;\r\n                parse_node_contents<Flags>(text, element);\r\n            }\r\n            else if (*text == Ch('/'))\r\n            {\r\n                ++text;\r\n                if (*text != Ch('>'))\r\n                    RAPIDXML_PARSE_ERROR(\"expected >\", text);\r\n                ++text;\r\n            }\r\n            else\r\n                RAPIDXML_PARSE_ERROR(\"expected >\", text);\r\n\r\n            // Place zero terminator after name\r\n            if (!(Flags & parse_no_string_terminators))\r\n                element->name()[element->name_size()] = Ch('\\0');\r\n\r\n            // Return parsed element\r\n            return element;\r\n        }\r\n\r\n        // Determine node type, and parse it\r\n        template<int Flags>\r\n        xml_node<Ch> *parse_node(Ch *&text)\r\n        {\r\n            // Parse proper node type\r\n            switch (text[0])\r\n            {\r\n\r\n            // <...\r\n            default: \r\n                // Parse and append element node\r\n                return parse_element<Flags>(text);\r\n\r\n            // <?...\r\n            case Ch('?'): \r\n                ++text;     // Skip ?\r\n                if ((text[0] == Ch('x') || text[0] == Ch('X')) &&\r\n                    (text[1] == Ch('m') || text[1] == Ch('M')) && \r\n                    (text[2] == Ch('l') || text[2] == Ch('L')) &&\r\n                    whitespace_pred::test(text[3]))\r\n                {\r\n                    // '<?xml ' - xml declaration\r\n                    text += 4;      // Skip 'xml '\r\n                    return parse_xml_declaration<Flags>(text);\r\n                }\r\n                else\r\n                {\r\n                    // Parse PI\r\n                    return parse_pi<Flags>(text);\r\n                }\r\n            \r\n            // <!...\r\n            case Ch('!'): \r\n\r\n                // Parse proper subset of <! node\r\n                switch (text[1])    \r\n                {\r\n                \r\n                // <!-\r\n                case Ch('-'):\r\n                    if (text[2] == Ch('-'))\r\n                    {\r\n                        // '<!--' - xml comment\r\n                        text += 3;     // Skip '!--'\r\n                        return parse_comment<Flags>(text);\r\n                    }\r\n                    break;\r\n\r\n                // <![\r\n                case Ch('['):\r\n                    if (text[2] == Ch('C') && text[3] == Ch('D') && text[4] == Ch('A') && \r\n                        text[5] == Ch('T') && text[6] == Ch('A') && text[7] == Ch('['))\r\n                    {\r\n                        // '<![CDATA[' - cdata\r\n                        text += 8;     // Skip '![CDATA['\r\n                        return parse_cdata<Flags>(text);\r\n                    }\r\n                    break;\r\n\r\n                // <!D\r\n                case Ch('D'):\r\n                    if (text[2] == Ch('O') && text[3] == Ch('C') && text[4] == Ch('T') && \r\n                        text[5] == Ch('Y') && text[6] == Ch('P') && text[7] == Ch('E') && \r\n                        whitespace_pred::test(text[8]))\r\n                    {\r\n                        // '<!DOCTYPE ' - doctype\r\n                        text += 9;      // skip '!DOCTYPE '\r\n                        return parse_doctype<Flags>(text);\r\n                    }\r\n\r\n                }   // switch\r\n\r\n                // Attempt to skip other, unrecognized node types starting with <!\r\n                ++text;     // Skip !\r\n                while (*text != Ch('>'))\r\n                {\r\n                    if (*text == 0)\r\n                        RAPIDXML_PARSE_ERROR(\"unexpected end of data\", text);\r\n                    ++text;\r\n                }\r\n                ++text;     // Skip '>'\r\n                return 0;   // No node recognized\r\n\r\n            }\r\n        }\r\n\r\n        // Parse contents of the node - children, data etc.\r\n        template<int Flags>\r\n        void parse_node_contents(Ch *&text, xml_node<Ch> *node)\r\n        {\r\n            // For all children and text\r\n            while (1)\r\n            {\r\n                // Skip whitespace between > and node contents\r\n                Ch *contents_start = text;      // Store start of node contents before whitespace is skipped\r\n                skip<whitespace_pred, Flags>(text);\r\n                Ch next_char = *text;\r\n\r\n            // After data nodes, instead of continuing the loop, control jumps here.\r\n            // This is because zero termination inside parse_and_append_data() function\r\n            // would wreak havoc with the above code.\r\n            // Also, skipping whitespace after data nodes is unnecessary.\r\n            after_data_node:    \r\n                \r\n                // Determine what comes next: node closing, child node, data node, or 0?\r\n                switch (next_char)\r\n                {\r\n                \r\n                // Node closing or child node\r\n                case Ch('<'):\r\n                    if (text[1] == Ch('/'))\r\n                    {\r\n                        // Node closing\r\n                        text += 2;      // Skip '</'\r\n                        if (Flags & parse_validate_closing_tags)\r\n                        {\r\n                            // Skip and validate closing tag name\r\n                            Ch *closing_name = text;\r\n                            skip<node_name_pred, Flags>(text);\r\n                            if (!internal::compare(node->name(), node->name_size(), closing_name, text - closing_name, true))\r\n                                RAPIDXML_PARSE_ERROR(\"invalid closing tag name\", text);\r\n                        }\r\n                        else\r\n                        {\r\n                            // No validation, just skip name\r\n                            skip<node_name_pred, Flags>(text);\r\n                        }\r\n                        // Skip remaining whitespace after node name\r\n                        skip<whitespace_pred, Flags>(text);\r\n                        if (*text != Ch('>'))\r\n                            RAPIDXML_PARSE_ERROR(\"expected >\", text);\r\n                        ++text;     // Skip '>'\r\n                        return;     // Node closed, finished parsing contents\r\n                    }\r\n                    else\r\n                    {\r\n                        // Child node\r\n                        ++text;     // Skip '<'\r\n                        if (xml_node<Ch> *child = parse_node<Flags>(text))\r\n                            node->append_node(child);\r\n                    }\r\n                    break;\r\n\r\n                // End of data - error\r\n                case Ch('\\0'):\r\n                    RAPIDXML_PARSE_ERROR(\"unexpected end of data\", text);\r\n\r\n                // Data node\r\n                default:\r\n                    next_char = parse_and_append_data<Flags>(node, text, contents_start);\r\n                    goto after_data_node;   // Bypass regular processing after data nodes\r\n\r\n                }\r\n            }\r\n        }\r\n        \r\n        // Parse XML attributes of the node\r\n        template<int Flags>\r\n        void parse_node_attributes(Ch *&text, xml_node<Ch> *node)\r\n        {\r\n            // For all attributes \r\n            while (attribute_name_pred::test(*text))\r\n            {\r\n                // Extract attribute name\r\n                Ch *name = text;\r\n                ++text;     // Skip first character of attribute name\r\n                skip<attribute_name_pred, Flags>(text);\r\n                if (text == name)\r\n                    RAPIDXML_PARSE_ERROR(\"expected attribute name\", name);\r\n\r\n                // Create new attribute\r\n                xml_attribute<Ch> *attribute = this->allocate_attribute();\r\n                attribute->name(name, text - name);\r\n                node->append_attribute(attribute);\r\n\r\n                // Skip whitespace after attribute name\r\n                skip<whitespace_pred, Flags>(text);\r\n\r\n                // Skip =\r\n                if (*text != Ch('='))\r\n                    RAPIDXML_PARSE_ERROR(\"expected =\", text);\r\n                ++text;\r\n\r\n                // Add terminating zero after name\r\n                if (!(Flags & parse_no_string_terminators))\r\n                    attribute->name()[attribute->name_size()] = 0;\r\n\r\n                // Skip whitespace after =\r\n                skip<whitespace_pred, Flags>(text);\r\n\r\n                // Skip quote and remember if it was ' or \"\r\n                Ch quote = *text;\r\n                if (quote != Ch('\\'') && quote != Ch('\"'))\r\n                    RAPIDXML_PARSE_ERROR(\"expected ' or \\\"\", text);\r\n                ++text;\r\n\r\n                // Extract attribute value and expand char refs in it\r\n                Ch *value = text, *end;\r\n                const int AttFlags = Flags & ~parse_normalize_whitespace;   // No whitespace normalization in attributes\r\n                if (quote == Ch('\\''))\r\n                    end = skip_and_expand_character_refs<attribute_value_pred<Ch('\\'')>, attribute_value_pure_pred<Ch('\\'')>, AttFlags>(text);\r\n                else\r\n                    end = skip_and_expand_character_refs<attribute_value_pred<Ch('\"')>, attribute_value_pure_pred<Ch('\"')>, AttFlags>(text);\r\n                \r\n                // Set attribute value\r\n                attribute->value(value, end - value);\r\n                \r\n                // Make sure that end quote is present\r\n                if (*text != quote)\r\n                    RAPIDXML_PARSE_ERROR(\"expected ' or \\\"\", text);\r\n                ++text;     // Skip quote\r\n\r\n                // Add terminating zero after value\r\n                if (!(Flags & parse_no_string_terminators))\r\n                    attribute->value()[attribute->value_size()] = 0;\r\n\r\n                // Skip whitespace after attribute value\r\n                skip<whitespace_pred, Flags>(text);\r\n            }\r\n        }\r\n\r\n    };\r\n\r\n    //! \\cond internal\r\n    namespace internal\r\n    {\r\n\r\n        // Whitespace (space \\n \\r \\t)\r\n        template<int Dummy>\r\n        const unsigned char lookup_tables<Dummy>::lookup_whitespace[256] = \r\n        {\r\n          // 0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F\r\n             0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  1,  0,  0,  1,  0,  0,  // 0\r\n             0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  // 1\r\n             1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  // 2\r\n             0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  // 3\r\n             0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  // 4\r\n             0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  // 5\r\n             0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  // 6\r\n             0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  // 7\r\n             0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  // 8\r\n             0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  // 9\r\n             0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  // A\r\n             0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  // B\r\n             0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  // C\r\n             0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  // D\r\n             0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  // E\r\n             0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0   // F\r\n        };\r\n\r\n        // Node name (anything but space \\n \\r \\t / > ? \\0)\r\n        template<int Dummy>\r\n        const unsigned char lookup_tables<Dummy>::lookup_node_name[256] = \r\n        {\r\n          // 0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F\r\n             0,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  1,  1,  0,  1,  1,  // 0\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 1\r\n             0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  // 2\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  // 3\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 4\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 5\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 6\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 7\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 8\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 9\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // A\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // B\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // C\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // D\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // E\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1   // F\r\n        };\r\n\r\n        // Text (i.e. PCDATA) (anything but < \\0)\r\n        template<int Dummy>\r\n        const unsigned char lookup_tables<Dummy>::lookup_text[256] = \r\n        {\r\n          // 0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F\r\n             0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 0\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 1\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 2\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  1,  1,  1,  // 3\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 4\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 5\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 6\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 7\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 8\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 9\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // A\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // B\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // C\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // D\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // E\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1   // F\r\n        };\r\n\r\n        // Text (i.e. PCDATA) that does not require processing when ws normalization is disabled \r\n        // (anything but < \\0 &)\r\n        template<int Dummy>\r\n        const unsigned char lookup_tables<Dummy>::lookup_text_pure_no_ws[256] = \r\n        {\r\n          // 0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F\r\n             0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 0\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 1\r\n             1,  1,  1,  1,  1,  1,  0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 2\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  1,  1,  1,  // 3\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 4\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 5\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 6\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 7\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 8\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 9\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // A\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // B\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // C\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // D\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // E\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1   // F\r\n        };\r\n\r\n        // Text (i.e. PCDATA) that does not require processing when ws normalizationis is enabled\r\n        // (anything but < \\0 & space \\n \\r \\t)\r\n        template<int Dummy>\r\n        const unsigned char lookup_tables<Dummy>::lookup_text_pure_with_ws[256] = \r\n        {\r\n          // 0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F\r\n             0,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  1,  1,  0,  1,  1,  // 0\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 1\r\n             0,  1,  1,  1,  1,  1,  0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 2\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  1,  1,  1,  // 3\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 4\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 5\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 6\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 7\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 8\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 9\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // A\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // B\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // C\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // D\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // E\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1   // F\r\n        };\r\n\r\n        // Attribute name (anything but space \\n \\r \\t / < > = ? ! \\0)\r\n        template<int Dummy>\r\n        const unsigned char lookup_tables<Dummy>::lookup_attribute_name[256] = \r\n        {\r\n          // 0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F\r\n             0,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  1,  1,  0,  1,  1,  // 0\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 1\r\n             0,  0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  // 2\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  // 3\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 4\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 5\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 6\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 7\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 8\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 9\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // A\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // B\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // C\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // D\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // E\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1   // F\r\n        };\r\n\r\n        // Attribute data with single quote (anything but ' \\0)\r\n        template<int Dummy>\r\n        const unsigned char lookup_tables<Dummy>::lookup_attribute_data_1[256] = \r\n        {\r\n          // 0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F\r\n             0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 0\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 1\r\n             1,  1,  1,  1,  1,  1,  1,  0,  1,  1,  1,  1,  1,  1,  1,  1,  // 2\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 3\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 4\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 5\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 6\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 7\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 8\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 9\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // A\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // B\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // C\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // D\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // E\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1   // F\r\n        };\r\n\r\n        // Attribute data with single quote that does not require processing (anything but ' \\0 &)\r\n        template<int Dummy>\r\n        const unsigned char lookup_tables<Dummy>::lookup_attribute_data_1_pure[256] = \r\n        {\r\n          // 0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F\r\n             0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 0\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 1\r\n             1,  1,  1,  1,  1,  1,  0,  0,  1,  1,  1,  1,  1,  1,  1,  1,  // 2\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 3\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 4\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 5\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 6\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 7\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 8\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 9\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // A\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // B\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // C\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // D\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // E\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1   // F\r\n        };\r\n\r\n        // Attribute data with double quote (anything but \" \\0)\r\n        template<int Dummy>\r\n        const unsigned char lookup_tables<Dummy>::lookup_attribute_data_2[256] = \r\n        {\r\n          // 0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F\r\n             0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 0\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 1\r\n             1,  1,  0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 2\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 3\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 4\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 5\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 6\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 7\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 8\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 9\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // A\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // B\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // C\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // D\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // E\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1   // F\r\n        };\r\n\r\n        // Attribute data with double quote that does not require processing (anything but \" \\0 &)\r\n        template<int Dummy>\r\n        const unsigned char lookup_tables<Dummy>::lookup_attribute_data_2_pure[256] = \r\n        {\r\n          // 0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F\r\n             0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 0\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 1\r\n             1,  1,  0,  1,  1,  1,  0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 2\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 3\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 4\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 5\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 6\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 7\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 8\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 9\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // A\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // B\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // C\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // D\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // E\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1   // F\r\n        };\r\n\r\n        // Digits (dec and hex, 255 denotes end of numeric character reference)\r\n        template<int Dummy>\r\n        const unsigned char lookup_tables<Dummy>::lookup_digits[256] = \r\n        {\r\n          // 0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F\r\n           255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  // 0\r\n           255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  // 1\r\n           255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  // 2\r\n             0,  1,  2,  3,  4,  5,  6,  7,  8,  9,255,255,255,255,255,255,  // 3\r\n           255, 10, 11, 12, 13, 14, 15,255,255,255,255,255,255,255,255,255,  // 4\r\n           255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  // 5\r\n           255, 10, 11, 12, 13, 14, 15,255,255,255,255,255,255,255,255,255,  // 6\r\n           255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  // 7\r\n           255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  // 8\r\n           255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  // 9\r\n           255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  // A\r\n           255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  // B\r\n           255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  // C\r\n           255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  // D\r\n           255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  // E\r\n           255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255   // F\r\n        };\r\n    \r\n        // Upper case conversion\r\n        template<int Dummy>\r\n        const unsigned char lookup_tables<Dummy>::lookup_upcase[256] = \r\n        {\r\n          // 0,  1,  2,  3,  4,  5,  6,  7,  8,  9,  A   B   C   D   E   F\r\n           0,  1,  2,  3,  4,  5,  6,  7,  8,  9,  10, 11, 12, 13, 14, 15,   // 0\r\n           16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,   // 1\r\n           32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,   // 2\r\n           48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,   // 3\r\n           64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,   // 4\r\n           80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,   // 5\r\n           96, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,   // 6\r\n           80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 123,124,125,126,127,  // 7\r\n           128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,  // 8\r\n           144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,  // 9\r\n           160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,  // A\r\n           176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,  // B\r\n           192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,  // C\r\n           208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,  // D\r\n           224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,  // E\r\n           240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255   // F\r\n        };\r\n    }\r\n    //! \\endcond\r\n\r\n}\r\n\r\n// Undefine internal macros\r\n#undef RAPIDXML_PARSE_ERROR\r\n\r\n// On MSVC, restore warnings state\r\n#ifdef _MSC_VER\r\n    #pragma warning(pop)\r\n#endif\r\n\r\n#endif\r\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/rapidxml/rapidxml_iterators.hpp",
    "content": "#ifndef RAPIDXML_ITERATORS_HPP_INCLUDED\r\n#define RAPIDXML_ITERATORS_HPP_INCLUDED\r\n\r\n// Copyright (C) 2006, 2009 Marcin Kalicinski\r\n// Version 1.13\r\n// Revision $DateTime: 2009/05/13 01:46:17 $\r\n//! \\file rapidxml_iterators.hpp This file contains rapidxml iterators\r\n\r\n#include \"rapidxml.hpp\"\r\n\r\nnamespace rapidxml\r\n{\r\n\r\n    //! Iterator of child nodes of xml_node\r\n    template<class Ch>\r\n    class node_iterator\r\n    {\r\n    \r\n    public:\r\n\r\n        typedef typename xml_node<Ch> value_type;\r\n        typedef typename xml_node<Ch> &reference;\r\n        typedef typename xml_node<Ch> *pointer;\r\n        typedef std::ptrdiff_t difference_type;\r\n        typedef std::bidirectional_iterator_tag iterator_category;\r\n        \r\n        node_iterator()\r\n            : m_node(0)\r\n        {\r\n        }\r\n\r\n        node_iterator(xml_node<Ch> *node)\r\n            : m_node(node->first_node())\r\n        {\r\n        }\r\n        \r\n        reference operator *() const\r\n        {\r\n            assert(m_node);\r\n            return *m_node;\r\n        }\r\n\r\n        pointer operator->() const\r\n        {\r\n            assert(m_node);\r\n            return m_node;\r\n        }\r\n\r\n        node_iterator& operator++()\r\n        {\r\n            assert(m_node);\r\n            m_node = m_node->next_sibling();\r\n            return *this;\r\n        }\r\n\r\n        node_iterator operator++(int)\r\n        {\r\n            node_iterator tmp = *this;\r\n            ++this;\r\n            return tmp;\r\n        }\r\n\r\n        node_iterator& operator--()\r\n        {\r\n            assert(m_node && m_node->previous_sibling());\r\n            m_node = m_node->previous_sibling();\r\n            return *this;\r\n        }\r\n\r\n        node_iterator operator--(int)\r\n        {\r\n            node_iterator tmp = *this;\r\n            ++this;\r\n            return tmp;\r\n        }\r\n\r\n        bool operator ==(const node_iterator<Ch> &rhs)\r\n        {\r\n            return m_node == rhs.m_node;\r\n        }\r\n\r\n        bool operator !=(const node_iterator<Ch> &rhs)\r\n        {\r\n            return m_node != rhs.m_node;\r\n        }\r\n\r\n    private:\r\n\r\n        xml_node<Ch> *m_node;\r\n\r\n    };\r\n\r\n    //! Iterator of child attributes of xml_node\r\n    template<class Ch>\r\n    class attribute_iterator\r\n    {\r\n    \r\n    public:\r\n\r\n        typedef typename xml_attribute<Ch> value_type;\r\n        typedef typename xml_attribute<Ch> &reference;\r\n        typedef typename xml_attribute<Ch> *pointer;\r\n        typedef std::ptrdiff_t difference_type;\r\n        typedef std::bidirectional_iterator_tag iterator_category;\r\n        \r\n        attribute_iterator()\r\n            : m_attribute(0)\r\n        {\r\n        }\r\n\r\n        attribute_iterator(xml_node<Ch> *node)\r\n            : m_attribute(node->first_attribute())\r\n        {\r\n        }\r\n        \r\n        reference operator *() const\r\n        {\r\n            assert(m_attribute);\r\n            return *m_attribute;\r\n        }\r\n\r\n        pointer operator->() const\r\n        {\r\n            assert(m_attribute);\r\n            return m_attribute;\r\n        }\r\n\r\n        attribute_iterator& operator++()\r\n        {\r\n            assert(m_attribute);\r\n            m_attribute = m_attribute->next_attribute();\r\n            return *this;\r\n        }\r\n\r\n        attribute_iterator operator++(int)\r\n        {\r\n            attribute_iterator tmp = *this;\r\n            ++this;\r\n            return tmp;\r\n        }\r\n\r\n        attribute_iterator& operator--()\r\n        {\r\n            assert(m_attribute && m_attribute->previous_attribute());\r\n            m_attribute = m_attribute->previous_attribute();\r\n            return *this;\r\n        }\r\n\r\n        attribute_iterator operator--(int)\r\n        {\r\n            attribute_iterator tmp = *this;\r\n            ++this;\r\n            return tmp;\r\n        }\r\n\r\n        bool operator ==(const attribute_iterator<Ch> &rhs)\r\n        {\r\n            return m_attribute == rhs.m_attribute;\r\n        }\r\n\r\n        bool operator !=(const attribute_iterator<Ch> &rhs)\r\n        {\r\n            return m_attribute != rhs.m_attribute;\r\n        }\r\n\r\n    private:\r\n\r\n        xml_attribute<Ch> *m_attribute;\r\n\r\n    };\r\n\r\n}\r\n\r\n#endif\r\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/rapidxml/rapidxml_print.hpp",
    "content": "#ifndef RAPIDXML_PRINT_HPP_INCLUDED\r\n#define RAPIDXML_PRINT_HPP_INCLUDED\r\n\r\n// Copyright (C) 2006, 2009 Marcin Kalicinski\r\n// Version 1.13\r\n// Revision $DateTime: 2009/05/13 01:46:17 $\r\n//! \\file rapidxml_print.hpp This file contains rapidxml printer implementation\r\n\r\n#include \"rapidxml.hpp\"\r\n\r\n// Only include streams if not disabled\r\n#ifndef RAPIDXML_NO_STREAMS\r\n    #include <ostream>\r\n    #include <iterator>\r\n#endif\r\n\r\nnamespace rapidxml\r\n{\r\n\r\n    ///////////////////////////////////////////////////////////////////////\r\n    // Printing flags\r\n\r\n    const int print_no_indenting = 0x1;   //!< Printer flag instructing the printer to suppress indenting of XML. See print() function.\r\n\r\n    ///////////////////////////////////////////////////////////////////////\r\n    // Internal\r\n\r\n    //! \\cond internal\r\n    namespace internal\r\n    {\r\n        ///////////////////////////////////////////////////////////////////////////\r\n        // Function declarations\r\n        \r\n        template<class OutIt, class Ch>\r\n        inline OutIt copy_chars(const Ch *begin, const Ch *end, OutIt out);\r\n        \r\n        template<class OutIt, class Ch>\r\n        inline OutIt copy_and_expand_chars(const Ch *begin, const Ch *end, Ch noexpand, OutIt out);\r\n        \r\n        template<class OutIt, class Ch>\r\n        inline OutIt fill_chars(OutIt out, int n, Ch ch);\r\n        \r\n        template<class Ch, Ch ch>\r\n        inline bool find_char(const Ch *begin, const Ch *end);\r\n        \r\n        template<class OutIt, class Ch>\r\n        inline OutIt print_node(OutIt out, const xml_node<Ch> *node, int flags, int indent);\r\n        \r\n        template<class OutIt, class Ch>\r\n        inline OutIt print_children(OutIt out, const xml_node<Ch> *node, int flags, int indent);\r\n        \r\n        template<class OutIt, class Ch>\r\n        inline OutIt print_attributes(OutIt out, const xml_node<Ch> *node, int flags);\r\n        \r\n        template<class OutIt, class Ch>\r\n        inline OutIt print_data_node(OutIt out, const xml_node<Ch> *node, int flags, int indent);\r\n        \r\n        template<class OutIt, class Ch>\r\n        inline OutIt print_cdata_node(OutIt out, const xml_node<Ch> *node, int flags, int indent);\r\n        \r\n        template<class OutIt, class Ch>\r\n        inline OutIt print_element_node(OutIt out, const xml_node<Ch> *node, int flags, int indent);\r\n        \r\n        template<class OutIt, class Ch>\r\n        inline OutIt print_declaration_node(OutIt out, const xml_node<Ch> *node, int flags, int indent);\r\n        \r\n        template<class OutIt, class Ch>\r\n        inline OutIt print_comment_node(OutIt out, const xml_node<Ch> *node, int flags, int indent);\r\n        \r\n        template<class OutIt, class Ch>\r\n        inline OutIt print_doctype_node(OutIt out, const xml_node<Ch> *node, int flags, int indent);\r\n        \r\n        template<class OutIt, class Ch>\r\n        inline OutIt print_pi_node(OutIt out, const xml_node<Ch> *node, int flags, int indent);\r\n        \r\n        ///////////////////////////////////////////////////////////////////////////\r\n        // Internal character operations\r\n    \r\n        // Copy characters from given range to given output iterator\r\n        template<class OutIt, class Ch>\r\n        inline OutIt copy_chars(const Ch *begin, const Ch *end, OutIt out)\r\n        {\r\n            while (begin != end)\r\n                *out++ = *begin++;\r\n            return out;\r\n        }\r\n        \r\n        // Copy characters from given range to given output iterator and expand\r\n        // characters into references (&lt; &gt; &apos; &quot; &amp;)\r\n        template<class OutIt, class Ch>\r\n        inline OutIt copy_and_expand_chars(const Ch *begin, const Ch *end, Ch noexpand, OutIt out)\r\n        {\r\n            while (begin != end)\r\n            {\r\n                if (*begin == noexpand)\r\n                {\r\n                    *out++ = *begin;    // No expansion, copy character\r\n                }\r\n                else\r\n                {\r\n                    switch (*begin)\r\n                    {\r\n                    case Ch('<'):\r\n                        *out++ = Ch('&'); *out++ = Ch('l'); *out++ = Ch('t'); *out++ = Ch(';');\r\n                        break;\r\n                    case Ch('>'): \r\n                        *out++ = Ch('&'); *out++ = Ch('g'); *out++ = Ch('t'); *out++ = Ch(';');\r\n                        break;\r\n                    case Ch('\\''): \r\n                        *out++ = Ch('&'); *out++ = Ch('a'); *out++ = Ch('p'); *out++ = Ch('o'); *out++ = Ch('s'); *out++ = Ch(';');\r\n                        break;\r\n                    case Ch('\"'): \r\n                        *out++ = Ch('&'); *out++ = Ch('q'); *out++ = Ch('u'); *out++ = Ch('o'); *out++ = Ch('t'); *out++ = Ch(';');\r\n                        break;\r\n                    case Ch('&'): \r\n                        *out++ = Ch('&'); *out++ = Ch('a'); *out++ = Ch('m'); *out++ = Ch('p'); *out++ = Ch(';'); \r\n                        break;\r\n                    default:\r\n                        *out++ = *begin;    // No expansion, copy character\r\n                    }\r\n                }\r\n                ++begin;    // Step to next character\r\n            }\r\n            return out;\r\n        }\r\n\r\n        // Fill given output iterator with repetitions of the same character\r\n        template<class OutIt, class Ch>\r\n        inline OutIt fill_chars(OutIt out, int n, Ch ch)\r\n        {\r\n            for (int i = 0; i < n; ++i)\r\n                *out++ = ch;\r\n            return out;\r\n        }\r\n\r\n        // Find character\r\n        template<class Ch, Ch ch>\r\n        inline bool find_char(const Ch *begin, const Ch *end)\r\n        {\r\n            while (begin != end)\r\n                if (*begin++ == ch)\r\n                    return true;\r\n            return false;\r\n        }\r\n\r\n        ///////////////////////////////////////////////////////////////////////////\r\n        // Internal printing operations\r\n    \r\n        // Print node\r\n        template<class OutIt, class Ch>\r\n        inline OutIt print_node(OutIt out, const xml_node<Ch> *node, int flags, int indent)\r\n        {\r\n            // Print proper node type\r\n            switch (node->type())\r\n            {\r\n\r\n            // Document\r\n            case node_document:\r\n                out = print_children(out, node, flags, indent);\r\n                break;\r\n\r\n            // Element\r\n            case node_element:\r\n                out = print_element_node(out, node, flags, indent);\r\n                break;\r\n            \r\n            // Data\r\n            case node_data:\r\n                out = print_data_node(out, node, flags, indent);\r\n                break;\r\n            \r\n            // CDATA\r\n            case node_cdata:\r\n                out = print_cdata_node(out, node, flags, indent);\r\n                break;\r\n\r\n            // Declaration\r\n            case node_declaration:\r\n                out = print_declaration_node(out, node, flags, indent);\r\n                break;\r\n\r\n            // Comment\r\n            case node_comment:\r\n                out = print_comment_node(out, node, flags, indent);\r\n                break;\r\n            \r\n            // Doctype\r\n            case node_doctype:\r\n                out = print_doctype_node(out, node, flags, indent);\r\n                break;\r\n\r\n            // Pi\r\n            case node_pi:\r\n                out = print_pi_node(out, node, flags, indent);\r\n                break;\r\n\r\n                // Unknown\r\n            default:\r\n                assert(0);\r\n                break;\r\n            }\r\n            \r\n            // If indenting not disabled, add line break after node\r\n            if (!(flags & print_no_indenting))\r\n                *out = Ch('\\n'), ++out;\r\n\r\n            // Return modified iterator\r\n            return out;\r\n        }\r\n        \r\n        // Print children of the node                               \r\n        template<class OutIt, class Ch>\r\n        inline OutIt print_children(OutIt out, const xml_node<Ch> *node, int flags, int indent)\r\n        {\r\n            for (xml_node<Ch> *child = node->first_node(); child; child = child->next_sibling())\r\n                out = print_node(out, child, flags, indent);\r\n            return out;\r\n        }\r\n\r\n        // Print attributes of the node\r\n        template<class OutIt, class Ch>\r\n        inline OutIt print_attributes(OutIt out, const xml_node<Ch> *node, int flags)\r\n        {\r\n            for (xml_attribute<Ch> *attribute = node->first_attribute(); attribute; attribute = attribute->next_attribute())\r\n            {\r\n                if (attribute->name() && attribute->value())\r\n                {\r\n                    // Print attribute name\r\n                    *out = Ch(' '), ++out;\r\n                    out = copy_chars(attribute->name(), attribute->name() + attribute->name_size(), out);\r\n                    *out = Ch('='), ++out;\r\n                    // Print attribute value using appropriate quote type\r\n                    if (find_char<Ch, Ch('\"')>(attribute->value(), attribute->value() + attribute->value_size()))\r\n                    {\r\n                        *out = Ch('\\''), ++out;\r\n                        out = copy_and_expand_chars(attribute->value(), attribute->value() + attribute->value_size(), Ch('\"'), out);\r\n                        *out = Ch('\\''), ++out;\r\n                    }\r\n                    else\r\n                    {\r\n                        *out = Ch('\"'), ++out;\r\n                        out = copy_and_expand_chars(attribute->value(), attribute->value() + attribute->value_size(), Ch('\\''), out);\r\n                        *out = Ch('\"'), ++out;\r\n                    }\r\n                }\r\n            }\r\n            return out;\r\n        }\r\n\r\n        // Print data node\r\n        template<class OutIt, class Ch>\r\n        inline OutIt print_data_node(OutIt out, const xml_node<Ch> *node, int flags, int indent)\r\n        {\r\n            assert(node->type() == node_data);\r\n            if (!(flags & print_no_indenting))\r\n                out = fill_chars(out, indent, Ch('\\t'));\r\n            out = copy_and_expand_chars(node->value(), node->value() + node->value_size(), Ch(0), out);\r\n            return out;\r\n        }\r\n\r\n        // Print data node\r\n        template<class OutIt, class Ch>\r\n        inline OutIt print_cdata_node(OutIt out, const xml_node<Ch> *node, int flags, int indent)\r\n        {\r\n            assert(node->type() == node_cdata);\r\n            if (!(flags & print_no_indenting))\r\n                out = fill_chars(out, indent, Ch('\\t'));\r\n            *out = Ch('<'); ++out;\r\n            *out = Ch('!'); ++out;\r\n            *out = Ch('['); ++out;\r\n            *out = Ch('C'); ++out;\r\n            *out = Ch('D'); ++out;\r\n            *out = Ch('A'); ++out;\r\n            *out = Ch('T'); ++out;\r\n            *out = Ch('A'); ++out;\r\n            *out = Ch('['); ++out;\r\n            out = copy_chars(node->value(), node->value() + node->value_size(), out);\r\n            *out = Ch(']'); ++out;\r\n            *out = Ch(']'); ++out;\r\n            *out = Ch('>'); ++out;\r\n            return out;\r\n        }\r\n\r\n        // Print element node\r\n        template<class OutIt, class Ch>\r\n        inline OutIt print_element_node(OutIt out, const xml_node<Ch> *node, int flags, int indent)\r\n        {\r\n            assert(node->type() == node_element);\r\n\r\n            // Print element name and attributes, if any\r\n            if (!(flags & print_no_indenting))\r\n                out = fill_chars(out, indent, Ch('\\t'));\r\n            *out = Ch('<'), ++out;\r\n            out = copy_chars(node->name(), node->name() + node->name_size(), out);\r\n            out = print_attributes(out, node, flags);\r\n            \r\n            // If node is childless\r\n            if (node->value_size() == 0 && !node->first_node())\r\n            {\r\n                // Print childless node tag ending\r\n                *out = Ch('/'), ++out;\r\n                *out = Ch('>'), ++out;\r\n            }\r\n            else\r\n            {\r\n                // Print normal node tag ending\r\n                *out = Ch('>'), ++out;\r\n\r\n                // Test if node contains a single data node only (and no other nodes)\r\n                xml_node<Ch> *child = node->first_node();\r\n                if (!child)\r\n                {\r\n                    // If node has no children, only print its value without indenting\r\n                    out = copy_and_expand_chars(node->value(), node->value() + node->value_size(), Ch(0), out);\r\n                }\r\n                else if (child->next_sibling() == 0 && child->type() == node_data)\r\n                {\r\n                    // If node has a sole data child, only print its value without indenting\r\n                    out = copy_and_expand_chars(child->value(), child->value() + child->value_size(), Ch(0), out);\r\n                }\r\n                else\r\n                {\r\n                    // Print all children with full indenting\r\n                    if (!(flags & print_no_indenting))\r\n                        *out = Ch('\\n'), ++out;\r\n                    out = print_children(out, node, flags, indent + 1);\r\n                    if (!(flags & print_no_indenting))\r\n                        out = fill_chars(out, indent, Ch('\\t'));\r\n                }\r\n\r\n                // Print node end\r\n                *out = Ch('<'), ++out;\r\n                *out = Ch('/'), ++out;\r\n                out = copy_chars(node->name(), node->name() + node->name_size(), out);\r\n                *out = Ch('>'), ++out;\r\n            }\r\n            return out;\r\n        }\r\n\r\n        // Print declaration node\r\n        template<class OutIt, class Ch>\r\n        inline OutIt print_declaration_node(OutIt out, const xml_node<Ch> *node, int flags, int indent)\r\n        {\r\n            // Print declaration start\r\n            if (!(flags & print_no_indenting))\r\n                out = fill_chars(out, indent, Ch('\\t'));\r\n            *out = Ch('<'), ++out;\r\n            *out = Ch('?'), ++out;\r\n            *out = Ch('x'), ++out;\r\n            *out = Ch('m'), ++out;\r\n            *out = Ch('l'), ++out;\r\n\r\n            // Print attributes\r\n            out = print_attributes(out, node, flags);\r\n            \r\n            // Print declaration end\r\n            *out = Ch('?'), ++out;\r\n            *out = Ch('>'), ++out;\r\n            \r\n            return out;\r\n        }\r\n\r\n        // Print comment node\r\n        template<class OutIt, class Ch>\r\n        inline OutIt print_comment_node(OutIt out, const xml_node<Ch> *node, int flags, int indent)\r\n        {\r\n            assert(node->type() == node_comment);\r\n            if (!(flags & print_no_indenting))\r\n                out = fill_chars(out, indent, Ch('\\t'));\r\n            *out = Ch('<'), ++out;\r\n            *out = Ch('!'), ++out;\r\n            *out = Ch('-'), ++out;\r\n            *out = Ch('-'), ++out;\r\n            out = copy_chars(node->value(), node->value() + node->value_size(), out);\r\n            *out = Ch('-'), ++out;\r\n            *out = Ch('-'), ++out;\r\n            *out = Ch('>'), ++out;\r\n            return out;\r\n        }\r\n\r\n        // Print doctype node\r\n        template<class OutIt, class Ch>\r\n        inline OutIt print_doctype_node(OutIt out, const xml_node<Ch> *node, int flags, int indent)\r\n        {\r\n            assert(node->type() == node_doctype);\r\n            if (!(flags & print_no_indenting))\r\n                out = fill_chars(out, indent, Ch('\\t'));\r\n            *out = Ch('<'), ++out;\r\n            *out = Ch('!'), ++out;\r\n            *out = Ch('D'), ++out;\r\n            *out = Ch('O'), ++out;\r\n            *out = Ch('C'), ++out;\r\n            *out = Ch('T'), ++out;\r\n            *out = Ch('Y'), ++out;\r\n            *out = Ch('P'), ++out;\r\n            *out = Ch('E'), ++out;\r\n            *out = Ch(' '), ++out;\r\n            out = copy_chars(node->value(), node->value() + node->value_size(), out);\r\n            *out = Ch('>'), ++out;\r\n            return out;\r\n        }\r\n\r\n        // Print pi node\r\n        template<class OutIt, class Ch>\r\n        inline OutIt print_pi_node(OutIt out, const xml_node<Ch> *node, int flags, int indent)\r\n        {\r\n            assert(node->type() == node_pi);\r\n            if (!(flags & print_no_indenting))\r\n                out = fill_chars(out, indent, Ch('\\t'));\r\n            *out = Ch('<'), ++out;\r\n            *out = Ch('?'), ++out;\r\n            out = copy_chars(node->name(), node->name() + node->name_size(), out);\r\n            *out = Ch(' '), ++out;\r\n            out = copy_chars(node->value(), node->value() + node->value_size(), out);\r\n            *out = Ch('?'), ++out;\r\n            *out = Ch('>'), ++out;\r\n            return out;\r\n        }\r\n\r\n    }\r\n    //! \\endcond\r\n\r\n    ///////////////////////////////////////////////////////////////////////////\r\n    // Printing\r\n\r\n    //! Prints XML to given output iterator.\r\n    //! \\param out Output iterator to print to.\r\n    //! \\param node Node to be printed. Pass xml_document to print entire document.\r\n    //! \\param flags Flags controlling how XML is printed.\r\n    //! \\return Output iterator pointing to position immediately after last character of printed text.\r\n    template<class OutIt, class Ch> \r\n    inline OutIt print(OutIt out, const xml_node<Ch> &node, int flags = 0)\r\n    {\r\n        return internal::print_node(out, &node, flags, 0);\r\n    }\r\n\r\n#ifndef RAPIDXML_NO_STREAMS\r\n\r\n    //! Prints XML to given output stream.\r\n    //! \\param out Output stream to print to.\r\n    //! \\param node Node to be printed. Pass xml_document to print entire document.\r\n    //! \\param flags Flags controlling how XML is printed.\r\n    //! \\return Output stream.\r\n    template<class Ch> \r\n    inline std::basic_ostream<Ch> &print(std::basic_ostream<Ch> &out, const xml_node<Ch> &node, int flags = 0)\r\n    {\r\n        print(std::ostream_iterator<Ch>(out), node, flags);\r\n        return out;\r\n    }\r\n\r\n    //! Prints formatted XML to given output stream. Uses default printing flags. Use print() function to customize printing process.\r\n    //! \\param out Output stream to print to.\r\n    //! \\param node Node to be printed.\r\n    //! \\return Output stream.\r\n    template<class Ch> \r\n    inline std::basic_ostream<Ch> &operator <<(std::basic_ostream<Ch> &out, const xml_node<Ch> &node)\r\n    {\r\n        return print(out, node);\r\n    }\r\n\r\n#endif\r\n\r\n}\r\n\r\n#endif\r\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/rapidxml/rapidxml_utils.hpp",
    "content": "#ifndef RAPIDXML_UTILS_HPP_INCLUDED\r\n#define RAPIDXML_UTILS_HPP_INCLUDED\r\n\r\n// Copyright (C) 2006, 2009 Marcin Kalicinski\r\n// Version 1.13\r\n// Revision $DateTime: 2009/05/13 01:46:17 $\r\n//! \\file rapidxml_utils.hpp This file contains high-level rapidxml utilities that can be useful\r\n//! in certain simple scenarios. They should probably not be used if maximizing performance is the main objective.\r\n\r\n#include \"rapidxml.hpp\"\r\n#include <vector>\r\n#include <string>\r\n#include <fstream>\r\n#include <stdexcept>\r\n\r\nnamespace rapidxml\r\n{\r\n\r\n    //! Represents data loaded from a file\r\n    template<class Ch = char>\r\n    class file\r\n    {\r\n        \r\n    public:\r\n        \r\n        //! Loads file into the memory. Data will be automatically destroyed by the destructor.\r\n        //! \\param filename Filename to load.\r\n        file(const char *filename)\r\n        {\r\n            using namespace std;\r\n\r\n            // Open stream\r\n            basic_ifstream<Ch> stream(filename, ios::binary);\r\n            if (!stream)\r\n                throw runtime_error(string(\"cannot open file \") + filename);\r\n            stream.unsetf(ios::skipws);\r\n            \r\n            // Determine stream size\r\n            stream.seekg(0, ios::end);\r\n            size_t size = stream.tellg();\r\n            stream.seekg(0);   \r\n            \r\n            // Load data and add terminating 0\r\n            m_data.resize(size + 1);\r\n            stream.read(&m_data.front(), static_cast<streamsize>(size));\r\n            m_data[size] = 0;\r\n        }\r\n\r\n        //! Loads file into the memory. Data will be automatically destroyed by the destructor\r\n        //! \\param stream Stream to load from\r\n        file(std::basic_istream<Ch> &stream)\r\n        {\r\n            using namespace std;\r\n\r\n            // Load data and add terminating 0\r\n            stream.unsetf(ios::skipws);\r\n            m_data.assign(istreambuf_iterator<Ch>(stream), istreambuf_iterator<Ch>());\r\n            if (stream.fail() || stream.bad())\r\n                throw runtime_error(\"error reading stream\");\r\n            m_data.push_back(0);\r\n        }\r\n        \r\n        //! Gets file data.\r\n        //! \\return Pointer to data of file.\r\n        Ch *data()\r\n        {\r\n            return &m_data.front();\r\n        }\r\n\r\n        //! Gets file data.\r\n        //! \\return Pointer to data of file.\r\n        const Ch *data() const\r\n        {\r\n            return &m_data.front();\r\n        }\r\n\r\n        //! Gets file data size.\r\n        //! \\return Size of file data, in characters.\r\n        std::size_t size() const\r\n        {\r\n            return m_data.size();\r\n        }\r\n\r\n    private:\r\n\r\n        std::vector<Ch> m_data;   // File data\r\n\r\n    };\r\n\r\n    //! Counts children of node. Time complexity is O(n).\r\n    //! \\return Number of children of node\r\n    template<class Ch>\r\n    inline std::size_t count_children(xml_node<Ch> *node)\r\n    {\r\n        xml_node<Ch> *child = node->first_node();\r\n        std::size_t count = 0;\r\n        while (child)\r\n        {\r\n            ++count;\r\n            child = child->next_sibling();\r\n        }\r\n        return count;\r\n    }\r\n\r\n    //! Counts attributes of node. Time complexity is O(n).\r\n    //! \\return Number of attributes of node\r\n    template<class Ch>\r\n    inline std::size_t count_attributes(xml_node<Ch> *node)\r\n    {\r\n        xml_attribute<Ch> *attr = node->first_attribute();\r\n        std::size_t count = 0;\r\n        while (attr)\r\n        {\r\n            ++count;\r\n            attr = attr->next_attribute();\r\n        }\r\n        return count;\r\n    }\r\n\r\n}\r\n\r\n#endif\r\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/zconf.h",
    "content": "/* zconf.h -- configuration of the zlib compression library\n * Copyright (C) 1995-2010 Jean-loup Gailly.\n * For conditions of distribution and use, see copyright notice in zlib.h\n */\n\n/* @(#) $Id$ */\n\n#ifndef ZCONF_H\n#define ZCONF_H\n\n/*\n * If you *really* need a unique prefix for all types and library functions,\n * compile with -DZ_PREFIX. The \"standard\" zlib should be compiled without it.\n * Even better than compiling with -DZ_PREFIX would be to use configure to set\n * this permanently in zconf.h using \"./configure --zprefix\".\n */\n#ifdef Z_PREFIX     /* may be set to #if 1 by ./configure */\n\n/* all linked symbols */\n#  define _dist_code            z__dist_code\n#  define _length_code          z__length_code\n#  define _tr_align             z__tr_align\n#  define _tr_flush_block       z__tr_flush_block\n#  define _tr_init              z__tr_init\n#  define _tr_stored_block      z__tr_stored_block\n#  define _tr_tally             z__tr_tally\n#  define adler32               z_adler32\n#  define adler32_combine       z_adler32_combine\n#  define adler32_combine64     z_adler32_combine64\n#  define compress              z_compress\n#  define compress2             z_compress2\n#  define compressBound         z_compressBound\n#  define crc32                 z_crc32\n#  define crc32_combine         z_crc32_combine\n#  define crc32_combine64       z_crc32_combine64\n#  define deflate               z_deflate\n#  define deflateBound          z_deflateBound\n#  define deflateCopy           z_deflateCopy\n#  define deflateEnd            z_deflateEnd\n#  define deflateInit2_         z_deflateInit2_\n#  define deflateInit_          z_deflateInit_\n#  define deflateParams         z_deflateParams\n#  define deflatePrime          z_deflatePrime\n#  define deflateReset          z_deflateReset\n#  define deflateSetDictionary  z_deflateSetDictionary\n#  define deflateSetHeader      z_deflateSetHeader\n#  define deflateTune           z_deflateTune\n#  define deflate_copyright     z_deflate_copyright\n#  define get_crc_table         z_get_crc_table\n#  define gz_error              z_gz_error\n#  define gz_intmax             z_gz_intmax\n#  define gz_strwinerror        z_gz_strwinerror\n#  define gzbuffer              z_gzbuffer\n#  define gzclearerr            z_gzclearerr\n#  define gzclose               z_gzclose\n#  define gzclose_r             z_gzclose_r\n#  define gzclose_w             z_gzclose_w\n#  define gzdirect              z_gzdirect\n#  define gzdopen               z_gzdopen\n#  define gzeof                 z_gzeof\n#  define gzerror               z_gzerror\n#  define gzflush               z_gzflush\n#  define gzgetc                z_gzgetc\n#  define gzgets                z_gzgets\n#  define gzoffset              z_gzoffset\n#  define gzoffset64            z_gzoffset64\n#  define gzopen                z_gzopen\n#  define gzopen64              z_gzopen64\n#  define gzprintf              z_gzprintf\n#  define gzputc                z_gzputc\n#  define gzputs                z_gzputs\n#  define gzread                z_gzread\n#  define gzrewind              z_gzrewind\n#  define gzseek                z_gzseek\n#  define gzseek64              z_gzseek64\n#  define gzsetparams           z_gzsetparams\n#  define gztell                z_gztell\n#  define gztell64              z_gztell64\n#  define gzungetc              z_gzungetc\n#  define gzwrite               z_gzwrite\n#  define inflate               z_inflate\n#  define inflateBack           z_inflateBack\n#  define inflateBackEnd        z_inflateBackEnd\n#  define inflateBackInit_      z_inflateBackInit_\n#  define inflateCopy           z_inflateCopy\n#  define inflateEnd            z_inflateEnd\n#  define inflateGetHeader      z_inflateGetHeader\n#  define inflateInit2_         z_inflateInit2_\n#  define inflateInit_          z_inflateInit_\n#  define inflateMark           z_inflateMark\n#  define inflatePrime          z_inflatePrime\n#  define inflateReset          z_inflateReset\n#  define inflateReset2         z_inflateReset2\n#  define inflateSetDictionary  z_inflateSetDictionary\n#  define inflateSync           z_inflateSync\n#  define inflateSyncPoint      z_inflateSyncPoint\n#  define inflateUndermine      z_inflateUndermine\n#  define inflate_copyright     z_inflate_copyright\n#  define inflate_fast          z_inflate_fast\n#  define inflate_table         z_inflate_table\n#  define uncompress            z_uncompress\n#  define zError                z_zError\n#  define zcalloc               z_zcalloc\n#  define zcfree                z_zcfree\n#  define zlibCompileFlags      z_zlibCompileFlags\n#  define zlibVersion           z_zlibVersion\n\n/* all zlib typedefs in zlib.h and zconf.h */\n#  define Byte                  z_Byte\n#  define Bytef                 z_Bytef\n#  define alloc_func            z_alloc_func\n#  define charf                 z_charf\n#  define free_func             z_free_func\n#  define gzFile                z_gzFile\n#  define gz_header             z_gz_header\n#  define gz_headerp            z_gz_headerp\n#  define in_func               z_in_func\n#  define intf                  z_intf\n#  define out_func              z_out_func\n#  define uInt                  z_uInt\n#  define uIntf                 z_uIntf\n#  define uLong                 z_uLong\n#  define uLongf                z_uLongf\n#  define voidp                 z_voidp\n#  define voidpc                z_voidpc\n#  define voidpf                z_voidpf\n\n/* all zlib structs in zlib.h and zconf.h */\n#  define gz_header_s           z_gz_header_s\n#  define internal_state        z_internal_state\n\n#endif\n\n#if defined(__MSDOS__) && !defined(MSDOS)\n#  define MSDOS\n#endif\n#if (defined(OS_2) || defined(__OS2__)) && !defined(OS2)\n#  define OS2\n#endif\n#if defined(_WINDOWS) && !defined(WINDOWS)\n#  define WINDOWS\n#endif\n#if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__)\n#  ifndef WIN32\n#    define WIN32\n#  endif\n#endif\n#if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32)\n#  if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__)\n#    ifndef SYS16BIT\n#      define SYS16BIT\n#    endif\n#  endif\n#endif\n\n/*\n * Compile with -DMAXSEG_64K if the alloc function cannot allocate more\n * than 64k bytes at a time (needed on systems with 16-bit int).\n */\n#ifdef SYS16BIT\n#  define MAXSEG_64K\n#endif\n#ifdef MSDOS\n#  define UNALIGNED_OK\n#endif\n\n#ifdef __STDC_VERSION__\n#  ifndef STDC\n#    define STDC\n#  endif\n#  if __STDC_VERSION__ >= 199901L\n#    ifndef STDC99\n#      define STDC99\n#    endif\n#  endif\n#endif\n#if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus))\n#  define STDC\n#endif\n#if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__))\n#  define STDC\n#endif\n#if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32))\n#  define STDC\n#endif\n#if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__))\n#  define STDC\n#endif\n\n#if defined(__OS400__) && !defined(STDC)    /* iSeries (formerly AS/400). */\n#  define STDC\n#endif\n\n#ifndef STDC\n#  ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */\n#    define const       /* note: need a more gentle solution here */\n#  endif\n#endif\n\n/* Some Mac compilers merge all .h files incorrectly: */\n#if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__)\n#  define NO_DUMMY_DECL\n#endif\n\n/* Maximum value for memLevel in deflateInit2 */\n#ifndef MAX_MEM_LEVEL\n#  ifdef MAXSEG_64K\n#    define MAX_MEM_LEVEL 8\n#  else\n#    define MAX_MEM_LEVEL 9\n#  endif\n#endif\n\n/* Maximum value for windowBits in deflateInit2 and inflateInit2.\n * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files\n * created by gzip. (Files created by minigzip can still be extracted by\n * gzip.)\n */\n#ifndef MAX_WBITS\n#  define MAX_WBITS   15 /* 32K LZ77 window */\n#endif\n\n/* The memory requirements for deflate are (in bytes):\n            (1 << (windowBits+2)) +  (1 << (memLevel+9))\n that is: 128K for windowBits=15  +  128K for memLevel = 8  (default values)\n plus a few kilobytes for small objects. For example, if you want to reduce\n the default memory requirements from 256K to 128K, compile with\n     make CFLAGS=\"-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7\"\n Of course this will generally degrade compression (there's no free lunch).\n\n   The memory requirements for inflate are (in bytes) 1 << windowBits\n that is, 32K for windowBits=15 (default value) plus a few kilobytes\n for small objects.\n*/\n\n                        /* Type declarations */\n\n#ifndef OF /* function prototypes */\n#  ifdef STDC\n#    define OF(args)  args\n#  else\n#    define OF(args)  ()\n#  endif\n#endif\n\n/* The following definitions for FAR are needed only for MSDOS mixed\n * model programming (small or medium model with some far allocations).\n * This was tested only with MSC; for other MSDOS compilers you may have\n * to define NO_MEMCPY in zutil.h.  If you don't need the mixed model,\n * just define FAR to be empty.\n */\n#ifdef SYS16BIT\n#  if defined(M_I86SM) || defined(M_I86MM)\n     /* MSC small or medium model */\n#    define SMALL_MEDIUM\n#    ifdef _MSC_VER\n#      define FAR _far\n#    else\n#      define FAR far\n#    endif\n#  endif\n#  if (defined(__SMALL__) || defined(__MEDIUM__))\n     /* Turbo C small or medium model */\n#    define SMALL_MEDIUM\n#    ifdef __BORLANDC__\n#      define FAR _far\n#    else\n#      define FAR far\n#    endif\n#  endif\n#endif\n\n#if defined(WINDOWS) || defined(WIN32)\n   /* If building or using zlib as a DLL, define ZLIB_DLL.\n    * This is not mandatory, but it offers a little performance increase.\n    */\n#  ifdef ZLIB_DLL\n#    if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500))\n#      ifdef ZLIB_INTERNAL\n#        define ZEXTERN extern __declspec(dllexport)\n#      else\n#        define ZEXTERN extern __declspec(dllimport)\n#      endif\n#    endif\n#  endif  /* ZLIB_DLL */\n   /* If building or using zlib with the WINAPI/WINAPIV calling convention,\n    * define ZLIB_WINAPI.\n    * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI.\n    */\n#  ifdef ZLIB_WINAPI\n#    ifdef FAR\n#      undef FAR\n#    endif\n#    include <windows.h>\n     /* No need for _export, use ZLIB.DEF instead. */\n     /* For complete Windows compatibility, use WINAPI, not __stdcall. */\n#    define ZEXPORT WINAPI\n#    ifdef WIN32\n#      define ZEXPORTVA WINAPIV\n#    else\n#      define ZEXPORTVA FAR CDECL\n#    endif\n#  endif\n#endif\n\n#if defined (__BEOS__)\n#  ifdef ZLIB_DLL\n#    ifdef ZLIB_INTERNAL\n#      define ZEXPORT   __declspec(dllexport)\n#      define ZEXPORTVA __declspec(dllexport)\n#    else\n#      define ZEXPORT   __declspec(dllimport)\n#      define ZEXPORTVA __declspec(dllimport)\n#    endif\n#  endif\n#endif\n\n#ifndef ZEXTERN\n#  define ZEXTERN extern\n#endif\n#ifndef ZEXPORT\n#  define ZEXPORT\n#endif\n#ifndef ZEXPORTVA\n#  define ZEXPORTVA\n#endif\n\n#ifndef FAR\n#  define FAR\n#endif\n\n#if !defined(__MACTYPES__)\ntypedef unsigned char  Byte;  /* 8 bits */\n#endif\ntypedef unsigned int   uInt;  /* 16 bits or more */\ntypedef unsigned long  uLong; /* 32 bits or more */\n\n#ifdef SMALL_MEDIUM\n   /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */\n#  define Bytef Byte FAR\n#else\n   typedef Byte  FAR Bytef;\n#endif\ntypedef char  FAR charf;\ntypedef int   FAR intf;\ntypedef uInt  FAR uIntf;\ntypedef uLong FAR uLongf;\n\n#ifdef STDC\n   typedef void const *voidpc;\n   typedef void FAR   *voidpf;\n   typedef void       *voidp;\n#else\n   typedef Byte const *voidpc;\n   typedef Byte FAR   *voidpf;\n   typedef Byte       *voidp;\n#endif\n\n#ifdef HAVE_UNISTD_H    /* may be set to #if 1 by ./configure */\n#  define Z_HAVE_UNISTD_H\n#endif\n\n#ifdef STDC\n#  include <sys/types.h>    /* for off_t */\n#endif\n\n/* a little trick to accommodate both \"#define _LARGEFILE64_SOURCE\" and\n * \"#define _LARGEFILE64_SOURCE 1\" as requesting 64-bit operations, (even\n * though the former does not conform to the LFS document), but considering\n * both \"#undef _LARGEFILE64_SOURCE\" and \"#define _LARGEFILE64_SOURCE 0\" as\n * equivalently requesting no 64-bit operations\n */\n#if -_LARGEFILE64_SOURCE - -1 == 1\n#  undef _LARGEFILE64_SOURCE\n#endif\n\n#if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE)\n#  include <unistd.h>       /* for SEEK_* and off_t */\n#  ifdef VMS\n#    include <unixio.h>     /* for off_t */\n#  endif\n#  ifndef z_off_t\n#    define z_off_t off_t\n#  endif\n#endif\n\n#ifndef SEEK_SET\n#  define SEEK_SET        0       /* Seek from beginning of file.  */\n#  define SEEK_CUR        1       /* Seek from current position.  */\n#  define SEEK_END        2       /* Set file pointer to EOF plus \"offset\" */\n#endif\n\n#ifndef z_off_t\n#  define z_off_t long\n#endif\n\n#if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0\n#  define z_off64_t off64_t\n#else\n#  define z_off64_t z_off_t\n#endif\n\n#if defined(__OS400__)\n#  define NO_vsnprintf\n#endif\n\n#if defined(__MVS__)\n#  define NO_vsnprintf\n#endif\n\n/* MVS linker does not support external names larger than 8 bytes */\n#if defined(__MVS__)\n  #pragma map(deflateInit_,\"DEIN\")\n  #pragma map(deflateInit2_,\"DEIN2\")\n  #pragma map(deflateEnd,\"DEEND\")\n  #pragma map(deflateBound,\"DEBND\")\n  #pragma map(inflateInit_,\"ININ\")\n  #pragma map(inflateInit2_,\"ININ2\")\n  #pragma map(inflateEnd,\"INEND\")\n  #pragma map(inflateSync,\"INSY\")\n  #pragma map(inflateSetDictionary,\"INSEDI\")\n  #pragma map(compressBound,\"CMBND\")\n  #pragma map(inflate_table,\"INTABL\")\n  #pragma map(inflate_fast,\"INFA\")\n  #pragma map(inflate_copyright,\"INCOPY\")\n#endif\n\n#endif /* ZCONF_H */\n"
  },
  {
    "path": "Libraries/Core/Windows/Headers/zlib.h",
    "content": "/* zlib.h -- interface of the 'zlib' general purpose compression library\n  version 1.2.5, April 19th, 2010\n\n  Copyright (C) 1995-2010 Jean-loup Gailly and Mark Adler\n\n  This software is provided 'as-is', without any express or implied\n  warranty.  In no event will the authors be held liable for any damages\n  arising from the use of this software.\n\n  Permission is granted to anyone to use this software for any purpose,\n  including commercial applications, and to alter it and redistribute it\n  freely, subject to the following restrictions:\n\n  1. The origin of this software must not be misrepresented; you must not\n     claim that you wrote the original software. If you use this software\n     in a product, an acknowledgment in the product documentation would be\n     appreciated but is not required.\n  2. Altered source versions must be plainly marked as such, and must not be\n     misrepresented as being the original software.\n  3. This notice may not be removed or altered from any source distribution.\n\n  Jean-loup Gailly        Mark Adler\n  jloup@gzip.org          madler@alumni.caltech.edu\n\n\n  The data format used by the zlib library is described by RFCs (Request for\n  Comments) 1950 to 1952 in the files http://www.ietf.org/rfc/rfc1950.txt\n  (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format).\n*/\n\n#ifndef ZLIB_H\n#define ZLIB_H\n\n#include \"zconf.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#define ZLIB_VERSION \"1.2.5\"\n#define ZLIB_VERNUM 0x1250\n#define ZLIB_VER_MAJOR 1\n#define ZLIB_VER_MINOR 2\n#define ZLIB_VER_REVISION 5\n#define ZLIB_VER_SUBREVISION 0\n\n/*\n    The 'zlib' compression library provides in-memory compression and\n  decompression functions, including integrity checks of the uncompressed data.\n  This version of the library supports only one compression method (deflation)\n  but other algorithms will be added later and will have the same stream\n  interface.\n\n    Compression can be done in a single step if the buffers are large enough,\n  or can be done by repeated calls of the compression function.  In the latter\n  case, the application must provide more input and/or consume the output\n  (providing more output space) before each call.\n\n    The compressed data format used by default by the in-memory functions is\n  the zlib format, which is a zlib wrapper documented in RFC 1950, wrapped\n  around a deflate stream, which is itself documented in RFC 1951.\n\n    The library also supports reading and writing files in gzip (.gz) format\n  with an interface similar to that of stdio using the functions that start\n  with \"gz\".  The gzip format is different from the zlib format.  gzip is a\n  gzip wrapper, documented in RFC 1952, wrapped around a deflate stream.\n\n    This library can optionally read and write gzip streams in memory as well.\n\n    The zlib format was designed to be compact and fast for use in memory\n  and on communications channels.  The gzip format was designed for single-\n  file compression on file systems, has a larger header than zlib to maintain\n  directory information, and uses a different, slower check method than zlib.\n\n    The library does not install any signal handler.  The decoder checks\n  the consistency of the compressed data, so the library should never crash\n  even in case of corrupted input.\n*/\n\ntypedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size));\ntypedef void   (*free_func)  OF((voidpf opaque, voidpf address));\n\nstruct internal_state;\n\ntypedef struct z_stream_s {\n    Bytef    *next_in;  /* next input byte */\n    uInt     avail_in;  /* number of bytes available at next_in */\n    uLong    total_in;  /* total nb of input bytes read so far */\n\n    Bytef    *next_out; /* next output byte should be put there */\n    uInt     avail_out; /* remaining free space at next_out */\n    uLong    total_out; /* total nb of bytes output so far */\n\n    char     *msg;      /* last error message, NULL if no error */\n    struct internal_state FAR *state; /* not visible by applications */\n\n    alloc_func zalloc;  /* used to allocate the internal state */\n    free_func  zfree;   /* used to free the internal state */\n    voidpf     opaque;  /* private data object passed to zalloc and zfree */\n\n    int     data_type;  /* best guess about the data type: binary or text */\n    uLong   adler;      /* adler32 value of the uncompressed data */\n    uLong   reserved;   /* reserved for future use */\n} z_stream;\n\ntypedef z_stream FAR *z_streamp;\n\n/*\n     gzip header information passed to and from zlib routines.  See RFC 1952\n  for more details on the meanings of these fields.\n*/\ntypedef struct gz_header_s {\n    int     text;       /* true if compressed data believed to be text */\n    uLong   time;       /* modification time */\n    int     xflags;     /* extra flags (not used when writing a gzip file) */\n    int     os;         /* operating system */\n    Bytef   *extra;     /* pointer to extra field or Z_NULL if none */\n    uInt    extra_len;  /* extra field length (valid if extra != Z_NULL) */\n    uInt    extra_max;  /* space at extra (only when reading header) */\n    Bytef   *name;      /* pointer to zero-terminated file name or Z_NULL */\n    uInt    name_max;   /* space at name (only when reading header) */\n    Bytef   *comment;   /* pointer to zero-terminated comment or Z_NULL */\n    uInt    comm_max;   /* space at comment (only when reading header) */\n    int     hcrc;       /* true if there was or will be a header crc */\n    int     done;       /* true when done reading gzip header (not used\n                           when writing a gzip file) */\n} gz_header;\n\ntypedef gz_header FAR *gz_headerp;\n\n/*\n     The application must update next_in and avail_in when avail_in has dropped\n   to zero.  It must update next_out and avail_out when avail_out has dropped\n   to zero.  The application must initialize zalloc, zfree and opaque before\n   calling the init function.  All other fields are set by the compression\n   library and must not be updated by the application.\n\n     The opaque value provided by the application will be passed as the first\n   parameter for calls of zalloc and zfree.  This can be useful for custom\n   memory management.  The compression library attaches no meaning to the\n   opaque value.\n\n     zalloc must return Z_NULL if there is not enough memory for the object.\n   If zlib is used in a multi-threaded application, zalloc and zfree must be\n   thread safe.\n\n     On 16-bit systems, the functions zalloc and zfree must be able to allocate\n   exactly 65536 bytes, but will not be required to allocate more than this if\n   the symbol MAXSEG_64K is defined (see zconf.h).  WARNING: On MSDOS, pointers\n   returned by zalloc for objects of exactly 65536 bytes *must* have their\n   offset normalized to zero.  The default allocation function provided by this\n   library ensures this (see zutil.c).  To reduce memory requirements and avoid\n   any allocation of 64K objects, at the expense of compression ratio, compile\n   the library with -DMAX_WBITS=14 (see zconf.h).\n\n     The fields total_in and total_out can be used for statistics or progress\n   reports.  After compression, total_in holds the total size of the\n   uncompressed data and may be saved for use in the decompressor (particularly\n   if the decompressor wants to decompress everything in a single step).\n*/\n\n                        /* constants */\n\n#define Z_NO_FLUSH      0\n#define Z_PARTIAL_FLUSH 1\n#define Z_SYNC_FLUSH    2\n#define Z_FULL_FLUSH    3\n#define Z_FINISH        4\n#define Z_BLOCK         5\n#define Z_TREES         6\n/* Allowed flush values; see deflate() and inflate() below for details */\n\n#define Z_OK            0\n#define Z_STREAM_END    1\n#define Z_NEED_DICT     2\n#define Z_ERRNO        (-1)\n#define Z_STREAM_ERROR (-2)\n#define Z_DATA_ERROR   (-3)\n#define Z_MEM_ERROR    (-4)\n#define Z_BUF_ERROR    (-5)\n#define Z_VERSION_ERROR (-6)\n/* Return codes for the compression/decompression functions. Negative values\n * are errors, positive values are used for special but normal events.\n */\n\n#define Z_NO_COMPRESSION         0\n#define Z_BEST_SPEED             1\n#define Z_BEST_COMPRESSION       9\n#define Z_DEFAULT_COMPRESSION  (-1)\n/* compression levels */\n\n#define Z_FILTERED            1\n#define Z_HUFFMAN_ONLY        2\n#define Z_RLE                 3\n#define Z_FIXED               4\n#define Z_DEFAULT_STRATEGY    0\n/* compression strategy; see deflateInit2() below for details */\n\n#define Z_BINARY   0\n#define Z_TEXT     1\n#define Z_ASCII    Z_TEXT   /* for compatibility with 1.2.2 and earlier */\n#define Z_UNKNOWN  2\n/* Possible values of the data_type field (though see inflate()) */\n\n#define Z_DEFLATED   8\n/* The deflate compression method (the only one supported in this version) */\n\n#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */\n\n#define zlib_version zlibVersion()\n/* for compatibility with versions < 1.0.2 */\n\n\n                        /* basic functions */\n\nZEXTERN const char * ZEXPORT zlibVersion OF((void));\n/* The application can compare zlibVersion and ZLIB_VERSION for consistency.\n   If the first character differs, the library code actually used is not\n   compatible with the zlib.h header file used by the application.  This check\n   is automatically made by deflateInit and inflateInit.\n */\n\n/*\nZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level));\n\n     Initializes the internal stream state for compression.  The fields\n   zalloc, zfree and opaque must be initialized before by the caller.  If\n   zalloc and zfree are set to Z_NULL, deflateInit updates them to use default\n   allocation functions.\n\n     The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9:\n   1 gives best speed, 9 gives best compression, 0 gives no compression at all\n   (the input data is simply copied a block at a time).  Z_DEFAULT_COMPRESSION\n   requests a default compromise between speed and compression (currently\n   equivalent to level 6).\n\n     deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough\n   memory, Z_STREAM_ERROR if level is not a valid compression level, or\n   Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible\n   with the version assumed by the caller (ZLIB_VERSION).  msg is set to null\n   if there is no error message.  deflateInit does not perform any compression:\n   this will be done by deflate().\n*/\n\n\nZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush));\n/*\n    deflate compresses as much data as possible, and stops when the input\n  buffer becomes empty or the output buffer becomes full.  It may introduce\n  some output latency (reading input without producing any output) except when\n  forced to flush.\n\n    The detailed semantics are as follows.  deflate performs one or both of the\n  following actions:\n\n  - Compress more input starting at next_in and update next_in and avail_in\n    accordingly.  If not all input can be processed (because there is not\n    enough room in the output buffer), next_in and avail_in are updated and\n    processing will resume at this point for the next call of deflate().\n\n  - Provide more output starting at next_out and update next_out and avail_out\n    accordingly.  This action is forced if the parameter flush is non zero.\n    Forcing flush frequently degrades the compression ratio, so this parameter\n    should be set only when necessary (in interactive applications).  Some\n    output may be provided even if flush is not set.\n\n    Before the call of deflate(), the application should ensure that at least\n  one of the actions is possible, by providing more input and/or consuming more\n  output, and updating avail_in or avail_out accordingly; avail_out should\n  never be zero before the call.  The application can consume the compressed\n  output when it wants, for example when the output buffer is full (avail_out\n  == 0), or after each call of deflate().  If deflate returns Z_OK and with\n  zero avail_out, it must be called again after making room in the output\n  buffer because there might be more output pending.\n\n    Normally the parameter flush is set to Z_NO_FLUSH, which allows deflate to\n  decide how much data to accumulate before producing output, in order to\n  maximize compression.\n\n    If the parameter flush is set to Z_SYNC_FLUSH, all pending output is\n  flushed to the output buffer and the output is aligned on a byte boundary, so\n  that the decompressor can get all input data available so far.  (In\n  particular avail_in is zero after the call if enough output space has been\n  provided before the call.) Flushing may degrade compression for some\n  compression algorithms and so it should be used only when necessary.  This\n  completes the current deflate block and follows it with an empty stored block\n  that is three bits plus filler bits to the next byte, followed by four bytes\n  (00 00 ff ff).\n\n    If flush is set to Z_PARTIAL_FLUSH, all pending output is flushed to the\n  output buffer, but the output is not aligned to a byte boundary.  All of the\n  input data so far will be available to the decompressor, as for Z_SYNC_FLUSH.\n  This completes the current deflate block and follows it with an empty fixed\n  codes block that is 10 bits long.  This assures that enough bytes are output\n  in order for the decompressor to finish the block before the empty fixed code\n  block.\n\n    If flush is set to Z_BLOCK, a deflate block is completed and emitted, as\n  for Z_SYNC_FLUSH, but the output is not aligned on a byte boundary, and up to\n  seven bits of the current block are held to be written as the next byte after\n  the next deflate block is completed.  In this case, the decompressor may not\n  be provided enough bits at this point in order to complete decompression of\n  the data provided so far to the compressor.  It may need to wait for the next\n  block to be emitted.  This is for advanced applications that need to control\n  the emission of deflate blocks.\n\n    If flush is set to Z_FULL_FLUSH, all output is flushed as with\n  Z_SYNC_FLUSH, and the compression state is reset so that decompression can\n  restart from this point if previous compressed data has been damaged or if\n  random access is desired.  Using Z_FULL_FLUSH too often can seriously degrade\n  compression.\n\n    If deflate returns with avail_out == 0, this function must be called again\n  with the same value of the flush parameter and more output space (updated\n  avail_out), until the flush is complete (deflate returns with non-zero\n  avail_out).  In the case of a Z_FULL_FLUSH or Z_SYNC_FLUSH, make sure that\n  avail_out is greater than six to avoid repeated flush markers due to\n  avail_out == 0 on return.\n\n    If the parameter flush is set to Z_FINISH, pending input is processed,\n  pending output is flushed and deflate returns with Z_STREAM_END if there was\n  enough output space; if deflate returns with Z_OK, this function must be\n  called again with Z_FINISH and more output space (updated avail_out) but no\n  more input data, until it returns with Z_STREAM_END or an error.  After\n  deflate has returned Z_STREAM_END, the only possible operations on the stream\n  are deflateReset or deflateEnd.\n\n    Z_FINISH can be used immediately after deflateInit if all the compression\n  is to be done in a single step.  In this case, avail_out must be at least the\n  value returned by deflateBound (see below).  If deflate does not return\n  Z_STREAM_END, then it must be called again as described above.\n\n    deflate() sets strm->adler to the adler32 checksum of all input read\n  so far (that is, total_in bytes).\n\n    deflate() may update strm->data_type if it can make a good guess about\n  the input data type (Z_BINARY or Z_TEXT).  In doubt, the data is considered\n  binary.  This field is only for information purposes and does not affect the\n  compression algorithm in any manner.\n\n    deflate() returns Z_OK if some progress has been made (more input\n  processed or more output produced), Z_STREAM_END if all input has been\n  consumed and all output has been produced (only when flush is set to\n  Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example\n  if next_in or next_out was Z_NULL), Z_BUF_ERROR if no progress is possible\n  (for example avail_in or avail_out was zero).  Note that Z_BUF_ERROR is not\n  fatal, and deflate() can be called again with more input and more output\n  space to continue compressing.\n*/\n\n\nZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm));\n/*\n     All dynamically allocated data structures for this stream are freed.\n   This function discards any unprocessed input and does not flush any pending\n   output.\n\n     deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the\n   stream state was inconsistent, Z_DATA_ERROR if the stream was freed\n   prematurely (some input or output was discarded).  In the error case, msg\n   may be set but then points to a static string (which must not be\n   deallocated).\n*/\n\n\n/*\nZEXTERN int ZEXPORT inflateInit OF((z_streamp strm));\n\n     Initializes the internal stream state for decompression.  The fields\n   next_in, avail_in, zalloc, zfree and opaque must be initialized before by\n   the caller.  If next_in is not Z_NULL and avail_in is large enough (the\n   exact value depends on the compression method), inflateInit determines the\n   compression method from the zlib header and allocates all data structures\n   accordingly; otherwise the allocation will be deferred to the first call of\n   inflate.  If zalloc and zfree are set to Z_NULL, inflateInit updates them to\n   use default allocation functions.\n\n     inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough\n   memory, Z_VERSION_ERROR if the zlib library version is incompatible with the\n   version assumed by the caller, or Z_STREAM_ERROR if the parameters are\n   invalid, such as a null pointer to the structure.  msg is set to null if\n   there is no error message.  inflateInit does not perform any decompression\n   apart from possibly reading the zlib header if present: actual decompression\n   will be done by inflate().  (So next_in and avail_in may be modified, but\n   next_out and avail_out are unused and unchanged.) The current implementation\n   of inflateInit() does not process any header information -- that is deferred\n   until inflate() is called.\n*/\n\n\nZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush));\n/*\n    inflate decompresses as much data as possible, and stops when the input\n  buffer becomes empty or the output buffer becomes full.  It may introduce\n  some output latency (reading input without producing any output) except when\n  forced to flush.\n\n  The detailed semantics are as follows.  inflate performs one or both of the\n  following actions:\n\n  - Decompress more input starting at next_in and update next_in and avail_in\n    accordingly.  If not all input can be processed (because there is not\n    enough room in the output buffer), next_in is updated and processing will\n    resume at this point for the next call of inflate().\n\n  - Provide more output starting at next_out and update next_out and avail_out\n    accordingly.  inflate() provides as much output as possible, until there is\n    no more input data or no more space in the output buffer (see below about\n    the flush parameter).\n\n    Before the call of inflate(), the application should ensure that at least\n  one of the actions is possible, by providing more input and/or consuming more\n  output, and updating the next_* and avail_* values accordingly.  The\n  application can consume the uncompressed output when it wants, for example\n  when the output buffer is full (avail_out == 0), or after each call of\n  inflate().  If inflate returns Z_OK and with zero avail_out, it must be\n  called again after making room in the output buffer because there might be\n  more output pending.\n\n    The flush parameter of inflate() can be Z_NO_FLUSH, Z_SYNC_FLUSH, Z_FINISH,\n  Z_BLOCK, or Z_TREES.  Z_SYNC_FLUSH requests that inflate() flush as much\n  output as possible to the output buffer.  Z_BLOCK requests that inflate()\n  stop if and when it gets to the next deflate block boundary.  When decoding\n  the zlib or gzip format, this will cause inflate() to return immediately\n  after the header and before the first block.  When doing a raw inflate,\n  inflate() will go ahead and process the first block, and will return when it\n  gets to the end of that block, or when it runs out of data.\n\n    The Z_BLOCK option assists in appending to or combining deflate streams.\n  Also to assist in this, on return inflate() will set strm->data_type to the\n  number of unused bits in the last byte taken from strm->next_in, plus 64 if\n  inflate() is currently decoding the last block in the deflate stream, plus\n  128 if inflate() returned immediately after decoding an end-of-block code or\n  decoding the complete header up to just before the first byte of the deflate\n  stream.  The end-of-block will not be indicated until all of the uncompressed\n  data from that block has been written to strm->next_out.  The number of\n  unused bits may in general be greater than seven, except when bit 7 of\n  data_type is set, in which case the number of unused bits will be less than\n  eight.  data_type is set as noted here every time inflate() returns for all\n  flush options, and so can be used to determine the amount of currently\n  consumed input in bits.\n\n    The Z_TREES option behaves as Z_BLOCK does, but it also returns when the\n  end of each deflate block header is reached, before any actual data in that\n  block is decoded.  This allows the caller to determine the length of the\n  deflate block header for later use in random access within a deflate block.\n  256 is added to the value of strm->data_type when inflate() returns\n  immediately after reaching the end of the deflate block header.\n\n    inflate() should normally be called until it returns Z_STREAM_END or an\n  error.  However if all decompression is to be performed in a single step (a\n  single call of inflate), the parameter flush should be set to Z_FINISH.  In\n  this case all pending input is processed and all pending output is flushed;\n  avail_out must be large enough to hold all the uncompressed data.  (The size\n  of the uncompressed data may have been saved by the compressor for this\n  purpose.) The next operation on this stream must be inflateEnd to deallocate\n  the decompression state.  The use of Z_FINISH is never required, but can be\n  used to inform inflate that a faster approach may be used for the single\n  inflate() call.\n\n     In this implementation, inflate() always flushes as much output as\n  possible to the output buffer, and always uses the faster approach on the\n  first call.  So the only effect of the flush parameter in this implementation\n  is on the return value of inflate(), as noted below, or when it returns early\n  because Z_BLOCK or Z_TREES is used.\n\n     If a preset dictionary is needed after this call (see inflateSetDictionary\n  below), inflate sets strm->adler to the adler32 checksum of the dictionary\n  chosen by the compressor and returns Z_NEED_DICT; otherwise it sets\n  strm->adler to the adler32 checksum of all output produced so far (that is,\n  total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as described\n  below.  At the end of the stream, inflate() checks that its computed adler32\n  checksum is equal to that saved by the compressor and returns Z_STREAM_END\n  only if the checksum is correct.\n\n    inflate() can decompress and check either zlib-wrapped or gzip-wrapped\n  deflate data.  The header type is detected automatically, if requested when\n  initializing with inflateInit2().  Any information contained in the gzip\n  header is not retained, so applications that need that information should\n  instead use raw inflate, see inflateInit2() below, or inflateBack() and\n  perform their own processing of the gzip header and trailer.\n\n    inflate() returns Z_OK if some progress has been made (more input processed\n  or more output produced), Z_STREAM_END if the end of the compressed data has\n  been reached and all uncompressed output has been produced, Z_NEED_DICT if a\n  preset dictionary is needed at this point, Z_DATA_ERROR if the input data was\n  corrupted (input stream not conforming to the zlib format or incorrect check\n  value), Z_STREAM_ERROR if the stream structure was inconsistent (for example\n  next_in or next_out was Z_NULL), Z_MEM_ERROR if there was not enough memory,\n  Z_BUF_ERROR if no progress is possible or if there was not enough room in the\n  output buffer when Z_FINISH is used.  Note that Z_BUF_ERROR is not fatal, and\n  inflate() can be called again with more input and more output space to\n  continue decompressing.  If Z_DATA_ERROR is returned, the application may\n  then call inflateSync() to look for a good compression block if a partial\n  recovery of the data is desired.\n*/\n\n\nZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm));\n/*\n     All dynamically allocated data structures for this stream are freed.\n   This function discards any unprocessed input and does not flush any pending\n   output.\n\n     inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state\n   was inconsistent.  In the error case, msg may be set but then points to a\n   static string (which must not be deallocated).\n*/\n\n\n                        /* Advanced functions */\n\n/*\n    The following functions are needed only in some special applications.\n*/\n\n/*\nZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm,\n                                     int  level,\n                                     int  method,\n                                     int  windowBits,\n                                     int  memLevel,\n                                     int  strategy));\n\n     This is another version of deflateInit with more compression options.  The\n   fields next_in, zalloc, zfree and opaque must be initialized before by the\n   caller.\n\n     The method parameter is the compression method.  It must be Z_DEFLATED in\n   this version of the library.\n\n     The windowBits parameter is the base two logarithm of the window size\n   (the size of the history buffer).  It should be in the range 8..15 for this\n   version of the library.  Larger values of this parameter result in better\n   compression at the expense of memory usage.  The default value is 15 if\n   deflateInit is used instead.\n\n     windowBits can also be -8..-15 for raw deflate.  In this case, -windowBits\n   determines the window size.  deflate() will then generate raw deflate data\n   with no zlib header or trailer, and will not compute an adler32 check value.\n\n     windowBits can also be greater than 15 for optional gzip encoding.  Add\n   16 to windowBits to write a simple gzip header and trailer around the\n   compressed data instead of a zlib wrapper.  The gzip header will have no\n   file name, no extra data, no comment, no modification time (set to zero), no\n   header crc, and the operating system will be set to 255 (unknown).  If a\n   gzip stream is being written, strm->adler is a crc32 instead of an adler32.\n\n     The memLevel parameter specifies how much memory should be allocated\n   for the internal compression state.  memLevel=1 uses minimum memory but is\n   slow and reduces compression ratio; memLevel=9 uses maximum memory for\n   optimal speed.  The default value is 8.  See zconf.h for total memory usage\n   as a function of windowBits and memLevel.\n\n     The strategy parameter is used to tune the compression algorithm.  Use the\n   value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a\n   filter (or predictor), Z_HUFFMAN_ONLY to force Huffman encoding only (no\n   string match), or Z_RLE to limit match distances to one (run-length\n   encoding).  Filtered data consists mostly of small values with a somewhat\n   random distribution.  In this case, the compression algorithm is tuned to\n   compress them better.  The effect of Z_FILTERED is to force more Huffman\n   coding and less string matching; it is somewhat intermediate between\n   Z_DEFAULT_STRATEGY and Z_HUFFMAN_ONLY.  Z_RLE is designed to be almost as\n   fast as Z_HUFFMAN_ONLY, but give better compression for PNG image data.  The\n   strategy parameter only affects the compression ratio but not the\n   correctness of the compressed output even if it is not set appropriately.\n   Z_FIXED prevents the use of dynamic Huffman codes, allowing for a simpler\n   decoder for special applications.\n\n     deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough\n   memory, Z_STREAM_ERROR if any parameter is invalid (such as an invalid\n   method), or Z_VERSION_ERROR if the zlib library version (zlib_version) is\n   incompatible with the version assumed by the caller (ZLIB_VERSION).  msg is\n   set to null if there is no error message.  deflateInit2 does not perform any\n   compression: this will be done by deflate().\n*/\n\nZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm,\n                                             const Bytef *dictionary,\n                                             uInt  dictLength));\n/*\n     Initializes the compression dictionary from the given byte sequence\n   without producing any compressed output.  This function must be called\n   immediately after deflateInit, deflateInit2 or deflateReset, before any call\n   of deflate.  The compressor and decompressor must use exactly the same\n   dictionary (see inflateSetDictionary).\n\n     The dictionary should consist of strings (byte sequences) that are likely\n   to be encountered later in the data to be compressed, with the most commonly\n   used strings preferably put towards the end of the dictionary.  Using a\n   dictionary is most useful when the data to be compressed is short and can be\n   predicted with good accuracy; the data can then be compressed better than\n   with the default empty dictionary.\n\n     Depending on the size of the compression data structures selected by\n   deflateInit or deflateInit2, a part of the dictionary may in effect be\n   discarded, for example if the dictionary is larger than the window size\n   provided in deflateInit or deflateInit2.  Thus the strings most likely to be\n   useful should be put at the end of the dictionary, not at the front.  In\n   addition, the current implementation of deflate will use at most the window\n   size minus 262 bytes of the provided dictionary.\n\n     Upon return of this function, strm->adler is set to the adler32 value\n   of the dictionary; the decompressor may later use this value to determine\n   which dictionary has been used by the compressor.  (The adler32 value\n   applies to the whole dictionary even if only a subset of the dictionary is\n   actually used by the compressor.) If a raw deflate was requested, then the\n   adler32 value is not computed and strm->adler is not set.\n\n     deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a\n   parameter is invalid (e.g.  dictionary being Z_NULL) or the stream state is\n   inconsistent (for example if deflate has already been called for this stream\n   or if the compression method is bsort).  deflateSetDictionary does not\n   perform any compression: this will be done by deflate().\n*/\n\nZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest,\n                                    z_streamp source));\n/*\n     Sets the destination stream as a complete copy of the source stream.\n\n     This function can be useful when several compression strategies will be\n   tried, for example when there are several ways of pre-processing the input\n   data with a filter.  The streams that will be discarded should then be freed\n   by calling deflateEnd.  Note that deflateCopy duplicates the internal\n   compression state which can be quite large, so this strategy is slow and can\n   consume lots of memory.\n\n     deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not\n   enough memory, Z_STREAM_ERROR if the source stream state was inconsistent\n   (such as zalloc being Z_NULL).  msg is left unchanged in both source and\n   destination.\n*/\n\nZEXTERN int ZEXPORT deflateReset OF((z_streamp strm));\n/*\n     This function is equivalent to deflateEnd followed by deflateInit,\n   but does not free and reallocate all the internal compression state.  The\n   stream will keep the same compression level and any other attributes that\n   may have been set by deflateInit2.\n\n     deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source\n   stream state was inconsistent (such as zalloc or state being Z_NULL).\n*/\n\nZEXTERN int ZEXPORT deflateParams OF((z_streamp strm,\n                                      int level,\n                                      int strategy));\n/*\n     Dynamically update the compression level and compression strategy.  The\n   interpretation of level and strategy is as in deflateInit2.  This can be\n   used to switch between compression and straight copy of the input data, or\n   to switch to a different kind of input data requiring a different strategy.\n   If the compression level is changed, the input available so far is\n   compressed with the old level (and may be flushed); the new level will take\n   effect only at the next call of deflate().\n\n     Before the call of deflateParams, the stream state must be set as for\n   a call of deflate(), since the currently available input may have to be\n   compressed and flushed.  In particular, strm->avail_out must be non-zero.\n\n     deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source\n   stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR if\n   strm->avail_out was zero.\n*/\n\nZEXTERN int ZEXPORT deflateTune OF((z_streamp strm,\n                                    int good_length,\n                                    int max_lazy,\n                                    int nice_length,\n                                    int max_chain));\n/*\n     Fine tune deflate's internal compression parameters.  This should only be\n   used by someone who understands the algorithm used by zlib's deflate for\n   searching for the best matching string, and even then only by the most\n   fanatic optimizer trying to squeeze out the last compressed bit for their\n   specific input data.  Read the deflate.c source code for the meaning of the\n   max_lazy, good_length, nice_length, and max_chain parameters.\n\n     deflateTune() can be called after deflateInit() or deflateInit2(), and\n   returns Z_OK on success, or Z_STREAM_ERROR for an invalid deflate stream.\n */\n\nZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm,\n                                       uLong sourceLen));\n/*\n     deflateBound() returns an upper bound on the compressed size after\n   deflation of sourceLen bytes.  It must be called after deflateInit() or\n   deflateInit2(), and after deflateSetHeader(), if used.  This would be used\n   to allocate an output buffer for deflation in a single pass, and so would be\n   called before deflate().\n*/\n\nZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm,\n                                     int bits,\n                                     int value));\n/*\n     deflatePrime() inserts bits in the deflate output stream.  The intent\n   is that this function is used to start off the deflate output with the bits\n   leftover from a previous deflate stream when appending to it.  As such, this\n   function can only be used for raw deflate, and must be used before the first\n   deflate() call after a deflateInit2() or deflateReset().  bits must be less\n   than or equal to 16, and that many of the least significant bits of value\n   will be inserted in the output.\n\n     deflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source\n   stream state was inconsistent.\n*/\n\nZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm,\n                                         gz_headerp head));\n/*\n     deflateSetHeader() provides gzip header information for when a gzip\n   stream is requested by deflateInit2().  deflateSetHeader() may be called\n   after deflateInit2() or deflateReset() and before the first call of\n   deflate().  The text, time, os, extra field, name, and comment information\n   in the provided gz_header structure are written to the gzip header (xflag is\n   ignored -- the extra flags are set according to the compression level).  The\n   caller must assure that, if not Z_NULL, name and comment are terminated with\n   a zero byte, and that if extra is not Z_NULL, that extra_len bytes are\n   available there.  If hcrc is true, a gzip header crc is included.  Note that\n   the current versions of the command-line version of gzip (up through version\n   1.3.x) do not support header crc's, and will report that it is a \"multi-part\n   gzip file\" and give up.\n\n     If deflateSetHeader is not used, the default gzip header has text false,\n   the time set to zero, and os set to 255, with no extra, name, or comment\n   fields.  The gzip header is returned to the default state by deflateReset().\n\n     deflateSetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source\n   stream state was inconsistent.\n*/\n\n/*\nZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm,\n                                     int  windowBits));\n\n     This is another version of inflateInit with an extra parameter.  The\n   fields next_in, avail_in, zalloc, zfree and opaque must be initialized\n   before by the caller.\n\n     The windowBits parameter is the base two logarithm of the maximum window\n   size (the size of the history buffer).  It should be in the range 8..15 for\n   this version of the library.  The default value is 15 if inflateInit is used\n   instead.  windowBits must be greater than or equal to the windowBits value\n   provided to deflateInit2() while compressing, or it must be equal to 15 if\n   deflateInit2() was not used.  If a compressed stream with a larger window\n   size is given as input, inflate() will return with the error code\n   Z_DATA_ERROR instead of trying to allocate a larger window.\n\n     windowBits can also be zero to request that inflate use the window size in\n   the zlib header of the compressed stream.\n\n     windowBits can also be -8..-15 for raw inflate.  In this case, -windowBits\n   determines the window size.  inflate() will then process raw deflate data,\n   not looking for a zlib or gzip header, not generating a check value, and not\n   looking for any check values for comparison at the end of the stream.  This\n   is for use with other formats that use the deflate compressed data format\n   such as zip.  Those formats provide their own check values.  If a custom\n   format is developed using the raw deflate format for compressed data, it is\n   recommended that a check value such as an adler32 or a crc32 be applied to\n   the uncompressed data as is done in the zlib, gzip, and zip formats.  For\n   most applications, the zlib format should be used as is.  Note that comments\n   above on the use in deflateInit2() applies to the magnitude of windowBits.\n\n     windowBits can also be greater than 15 for optional gzip decoding.  Add\n   32 to windowBits to enable zlib and gzip decoding with automatic header\n   detection, or add 16 to decode only the gzip format (the zlib format will\n   return a Z_DATA_ERROR).  If a gzip stream is being decoded, strm->adler is a\n   crc32 instead of an adler32.\n\n     inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough\n   memory, Z_VERSION_ERROR if the zlib library version is incompatible with the\n   version assumed by the caller, or Z_STREAM_ERROR if the parameters are\n   invalid, such as a null pointer to the structure.  msg is set to null if\n   there is no error message.  inflateInit2 does not perform any decompression\n   apart from possibly reading the zlib header if present: actual decompression\n   will be done by inflate().  (So next_in and avail_in may be modified, but\n   next_out and avail_out are unused and unchanged.) The current implementation\n   of inflateInit2() does not process any header information -- that is\n   deferred until inflate() is called.\n*/\n\nZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm,\n                                             const Bytef *dictionary,\n                                             uInt  dictLength));\n/*\n     Initializes the decompression dictionary from the given uncompressed byte\n   sequence.  This function must be called immediately after a call of inflate,\n   if that call returned Z_NEED_DICT.  The dictionary chosen by the compressor\n   can be determined from the adler32 value returned by that call of inflate.\n   The compressor and decompressor must use exactly the same dictionary (see\n   deflateSetDictionary).  For raw inflate, this function can be called\n   immediately after inflateInit2() or inflateReset() and before any call of\n   inflate() to set the dictionary.  The application must insure that the\n   dictionary that was used for compression is provided.\n\n     inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a\n   parameter is invalid (e.g.  dictionary being Z_NULL) or the stream state is\n   inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the\n   expected one (incorrect adler32 value).  inflateSetDictionary does not\n   perform any decompression: this will be done by subsequent calls of\n   inflate().\n*/\n\nZEXTERN int ZEXPORT inflateSync OF((z_streamp strm));\n/*\n     Skips invalid compressed data until a full flush point (see above the\n   description of deflate with Z_FULL_FLUSH) can be found, or until all\n   available input is skipped.  No output is provided.\n\n     inflateSync returns Z_OK if a full flush point has been found, Z_BUF_ERROR\n   if no more input was provided, Z_DATA_ERROR if no flush point has been\n   found, or Z_STREAM_ERROR if the stream structure was inconsistent.  In the\n   success case, the application may save the current current value of total_in\n   which indicates where valid compressed data was found.  In the error case,\n   the application may repeatedly call inflateSync, providing more input each\n   time, until success or end of the input data.\n*/\n\nZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest,\n                                    z_streamp source));\n/*\n     Sets the destination stream as a complete copy of the source stream.\n\n     This function can be useful when randomly accessing a large stream.  The\n   first pass through the stream can periodically record the inflate state,\n   allowing restarting inflate at those points when randomly accessing the\n   stream.\n\n     inflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not\n   enough memory, Z_STREAM_ERROR if the source stream state was inconsistent\n   (such as zalloc being Z_NULL).  msg is left unchanged in both source and\n   destination.\n*/\n\nZEXTERN int ZEXPORT inflateReset OF((z_streamp strm));\n/*\n     This function is equivalent to inflateEnd followed by inflateInit,\n   but does not free and reallocate all the internal decompression state.  The\n   stream will keep attributes that may have been set by inflateInit2.\n\n     inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source\n   stream state was inconsistent (such as zalloc or state being Z_NULL).\n*/\n\nZEXTERN int ZEXPORT inflateReset2 OF((z_streamp strm,\n                                      int windowBits));\n/*\n     This function is the same as inflateReset, but it also permits changing\n   the wrap and window size requests.  The windowBits parameter is interpreted\n   the same as it is for inflateInit2.\n\n     inflateReset2 returns Z_OK if success, or Z_STREAM_ERROR if the source\n   stream state was inconsistent (such as zalloc or state being Z_NULL), or if\n   the windowBits parameter is invalid.\n*/\n\nZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm,\n                                     int bits,\n                                     int value));\n/*\n     This function inserts bits in the inflate input stream.  The intent is\n   that this function is used to start inflating at a bit position in the\n   middle of a byte.  The provided bits will be used before any bytes are used\n   from next_in.  This function should only be used with raw inflate, and\n   should be used before the first inflate() call after inflateInit2() or\n   inflateReset().  bits must be less than or equal to 16, and that many of the\n   least significant bits of value will be inserted in the input.\n\n     If bits is negative, then the input stream bit buffer is emptied.  Then\n   inflatePrime() can be called again to put bits in the buffer.  This is used\n   to clear out bits leftover after feeding inflate a block description prior\n   to feeding inflate codes.\n\n     inflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source\n   stream state was inconsistent.\n*/\n\nZEXTERN long ZEXPORT inflateMark OF((z_streamp strm));\n/*\n     This function returns two values, one in the lower 16 bits of the return\n   value, and the other in the remaining upper bits, obtained by shifting the\n   return value down 16 bits.  If the upper value is -1 and the lower value is\n   zero, then inflate() is currently decoding information outside of a block.\n   If the upper value is -1 and the lower value is non-zero, then inflate is in\n   the middle of a stored block, with the lower value equaling the number of\n   bytes from the input remaining to copy.  If the upper value is not -1, then\n   it is the number of bits back from the current bit position in the input of\n   the code (literal or length/distance pair) currently being processed.  In\n   that case the lower value is the number of bytes already emitted for that\n   code.\n\n     A code is being processed if inflate is waiting for more input to complete\n   decoding of the code, or if it has completed decoding but is waiting for\n   more output space to write the literal or match data.\n\n     inflateMark() is used to mark locations in the input data for random\n   access, which may be at bit positions, and to note those cases where the\n   output of a code may span boundaries of random access blocks.  The current\n   location in the input stream can be determined from avail_in and data_type\n   as noted in the description for the Z_BLOCK flush parameter for inflate.\n\n     inflateMark returns the value noted above or -1 << 16 if the provided\n   source stream state was inconsistent.\n*/\n\nZEXTERN int ZEXPORT inflateGetHeader OF((z_streamp strm,\n                                         gz_headerp head));\n/*\n     inflateGetHeader() requests that gzip header information be stored in the\n   provided gz_header structure.  inflateGetHeader() may be called after\n   inflateInit2() or inflateReset(), and before the first call of inflate().\n   As inflate() processes the gzip stream, head->done is zero until the header\n   is completed, at which time head->done is set to one.  If a zlib stream is\n   being decoded, then head->done is set to -1 to indicate that there will be\n   no gzip header information forthcoming.  Note that Z_BLOCK or Z_TREES can be\n   used to force inflate() to return immediately after header processing is\n   complete and before any actual data is decompressed.\n\n     The text, time, xflags, and os fields are filled in with the gzip header\n   contents.  hcrc is set to true if there is a header CRC.  (The header CRC\n   was valid if done is set to one.) If extra is not Z_NULL, then extra_max\n   contains the maximum number of bytes to write to extra.  Once done is true,\n   extra_len contains the actual extra field length, and extra contains the\n   extra field, or that field truncated if extra_max is less than extra_len.\n   If name is not Z_NULL, then up to name_max characters are written there,\n   terminated with a zero unless the length is greater than name_max.  If\n   comment is not Z_NULL, then up to comm_max characters are written there,\n   terminated with a zero unless the length is greater than comm_max.  When any\n   of extra, name, or comment are not Z_NULL and the respective field is not\n   present in the header, then that field is set to Z_NULL to signal its\n   absence.  This allows the use of deflateSetHeader() with the returned\n   structure to duplicate the header.  However if those fields are set to\n   allocated memory, then the application will need to save those pointers\n   elsewhere so that they can be eventually freed.\n\n     If inflateGetHeader is not used, then the header information is simply\n   discarded.  The header is always checked for validity, including the header\n   CRC if present.  inflateReset() will reset the process to discard the header\n   information.  The application would need to call inflateGetHeader() again to\n   retrieve the header from the next gzip stream.\n\n     inflateGetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source\n   stream state was inconsistent.\n*/\n\n/*\nZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits,\n                                        unsigned char FAR *window));\n\n     Initialize the internal stream state for decompression using inflateBack()\n   calls.  The fields zalloc, zfree and opaque in strm must be initialized\n   before the call.  If zalloc and zfree are Z_NULL, then the default library-\n   derived memory allocation routines are used.  windowBits is the base two\n   logarithm of the window size, in the range 8..15.  window is a caller\n   supplied buffer of that size.  Except for special applications where it is\n   assured that deflate was used with small window sizes, windowBits must be 15\n   and a 32K byte window must be supplied to be able to decompress general\n   deflate streams.\n\n     See inflateBack() for the usage of these routines.\n\n     inflateBackInit will return Z_OK on success, Z_STREAM_ERROR if any of\n   the paramaters are invalid, Z_MEM_ERROR if the internal state could not be\n   allocated, or Z_VERSION_ERROR if the version of the library does not match\n   the version of the header file.\n*/\n\ntypedef unsigned (*in_func) OF((void FAR *, unsigned char FAR * FAR *));\ntypedef int (*out_func) OF((void FAR *, unsigned char FAR *, unsigned));\n\nZEXTERN int ZEXPORT inflateBack OF((z_streamp strm,\n                                    in_func in, void FAR *in_desc,\n                                    out_func out, void FAR *out_desc));\n/*\n     inflateBack() does a raw inflate with a single call using a call-back\n   interface for input and output.  This is more efficient than inflate() for\n   file i/o applications in that it avoids copying between the output and the\n   sliding window by simply making the window itself the output buffer.  This\n   function trusts the application to not change the output buffer passed by\n   the output function, at least until inflateBack() returns.\n\n     inflateBackInit() must be called first to allocate the internal state\n   and to initialize the state with the user-provided window buffer.\n   inflateBack() may then be used multiple times to inflate a complete, raw\n   deflate stream with each call.  inflateBackEnd() is then called to free the\n   allocated state.\n\n     A raw deflate stream is one with no zlib or gzip header or trailer.\n   This routine would normally be used in a utility that reads zip or gzip\n   files and writes out uncompressed files.  The utility would decode the\n   header and process the trailer on its own, hence this routine expects only\n   the raw deflate stream to decompress.  This is different from the normal\n   behavior of inflate(), which expects either a zlib or gzip header and\n   trailer around the deflate stream.\n\n     inflateBack() uses two subroutines supplied by the caller that are then\n   called by inflateBack() for input and output.  inflateBack() calls those\n   routines until it reads a complete deflate stream and writes out all of the\n   uncompressed data, or until it encounters an error.  The function's\n   parameters and return types are defined above in the in_func and out_func\n   typedefs.  inflateBack() will call in(in_desc, &buf) which should return the\n   number of bytes of provided input, and a pointer to that input in buf.  If\n   there is no input available, in() must return zero--buf is ignored in that\n   case--and inflateBack() will return a buffer error.  inflateBack() will call\n   out(out_desc, buf, len) to write the uncompressed data buf[0..len-1].  out()\n   should return zero on success, or non-zero on failure.  If out() returns\n   non-zero, inflateBack() will return with an error.  Neither in() nor out()\n   are permitted to change the contents of the window provided to\n   inflateBackInit(), which is also the buffer that out() uses to write from.\n   The length written by out() will be at most the window size.  Any non-zero\n   amount of input may be provided by in().\n\n     For convenience, inflateBack() can be provided input on the first call by\n   setting strm->next_in and strm->avail_in.  If that input is exhausted, then\n   in() will be called.  Therefore strm->next_in must be initialized before\n   calling inflateBack().  If strm->next_in is Z_NULL, then in() will be called\n   immediately for input.  If strm->next_in is not Z_NULL, then strm->avail_in\n   must also be initialized, and then if strm->avail_in is not zero, input will\n   initially be taken from strm->next_in[0 ..  strm->avail_in - 1].\n\n     The in_desc and out_desc parameters of inflateBack() is passed as the\n   first parameter of in() and out() respectively when they are called.  These\n   descriptors can be optionally used to pass any information that the caller-\n   supplied in() and out() functions need to do their job.\n\n     On return, inflateBack() will set strm->next_in and strm->avail_in to\n   pass back any unused input that was provided by the last in() call.  The\n   return values of inflateBack() can be Z_STREAM_END on success, Z_BUF_ERROR\n   if in() or out() returned an error, Z_DATA_ERROR if there was a format error\n   in the deflate stream (in which case strm->msg is set to indicate the nature\n   of the error), or Z_STREAM_ERROR if the stream was not properly initialized.\n   In the case of Z_BUF_ERROR, an input or output error can be distinguished\n   using strm->next_in which will be Z_NULL only if in() returned an error.  If\n   strm->next_in is not Z_NULL, then the Z_BUF_ERROR was due to out() returning\n   non-zero.  (in() will always be called before out(), so strm->next_in is\n   assured to be defined if out() returns non-zero.) Note that inflateBack()\n   cannot return Z_OK.\n*/\n\nZEXTERN int ZEXPORT inflateBackEnd OF((z_streamp strm));\n/*\n     All memory allocated by inflateBackInit() is freed.\n\n     inflateBackEnd() returns Z_OK on success, or Z_STREAM_ERROR if the stream\n   state was inconsistent.\n*/\n\nZEXTERN uLong ZEXPORT zlibCompileFlags OF((void));\n/* Return flags indicating compile-time options.\n\n    Type sizes, two bits each, 00 = 16 bits, 01 = 32, 10 = 64, 11 = other:\n     1.0: size of uInt\n     3.2: size of uLong\n     5.4: size of voidpf (pointer)\n     7.6: size of z_off_t\n\n    Compiler, assembler, and debug options:\n     8: DEBUG\n     9: ASMV or ASMINF -- use ASM code\n     10: ZLIB_WINAPI -- exported functions use the WINAPI calling convention\n     11: 0 (reserved)\n\n    One-time table building (smaller code, but not thread-safe if true):\n     12: BUILDFIXED -- build static block decoding tables when needed\n     13: DYNAMIC_CRC_TABLE -- build CRC calculation tables when needed\n     14,15: 0 (reserved)\n\n    Library content (indicates missing functionality):\n     16: NO_GZCOMPRESS -- gz* functions cannot compress (to avoid linking\n                          deflate code when not needed)\n     17: NO_GZIP -- deflate can't write gzip streams, and inflate can't detect\n                    and decode gzip streams (to avoid linking crc code)\n     18-19: 0 (reserved)\n\n    Operation variations (changes in library functionality):\n     20: PKZIP_BUG_WORKAROUND -- slightly more permissive inflate\n     21: FASTEST -- deflate algorithm with only one, lowest compression level\n     22,23: 0 (reserved)\n\n    The sprintf variant used by gzprintf (zero is best):\n     24: 0 = vs*, 1 = s* -- 1 means limited to 20 arguments after the format\n     25: 0 = *nprintf, 1 = *printf -- 1 means gzprintf() not secure!\n     26: 0 = returns value, 1 = void -- 1 means inferred string length returned\n\n    Remainder:\n     27-31: 0 (reserved)\n */\n\n\n                        /* utility functions */\n\n/*\n     The following utility functions are implemented on top of the basic\n   stream-oriented functions.  To simplify the interface, some default options\n   are assumed (compression level and memory usage, standard memory allocation\n   functions).  The source code of these utility functions can be modified if\n   you need special options.\n*/\n\nZEXTERN int ZEXPORT compress OF((Bytef *dest,   uLongf *destLen,\n                                 const Bytef *source, uLong sourceLen));\n/*\n     Compresses the source buffer into the destination buffer.  sourceLen is\n   the byte length of the source buffer.  Upon entry, destLen is the total size\n   of the destination buffer, which must be at least the value returned by\n   compressBound(sourceLen).  Upon exit, destLen is the actual size of the\n   compressed buffer.\n\n     compress returns Z_OK if success, Z_MEM_ERROR if there was not\n   enough memory, Z_BUF_ERROR if there was not enough room in the output\n   buffer.\n*/\n\nZEXTERN int ZEXPORT compress2 OF((Bytef *dest,   uLongf *destLen,\n                                  const Bytef *source, uLong sourceLen,\n                                  int level));\n/*\n     Compresses the source buffer into the destination buffer.  The level\n   parameter has the same meaning as in deflateInit.  sourceLen is the byte\n   length of the source buffer.  Upon entry, destLen is the total size of the\n   destination buffer, which must be at least the value returned by\n   compressBound(sourceLen).  Upon exit, destLen is the actual size of the\n   compressed buffer.\n\n     compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough\n   memory, Z_BUF_ERROR if there was not enough room in the output buffer,\n   Z_STREAM_ERROR if the level parameter is invalid.\n*/\n\nZEXTERN uLong ZEXPORT compressBound OF((uLong sourceLen));\n/*\n     compressBound() returns an upper bound on the compressed size after\n   compress() or compress2() on sourceLen bytes.  It would be used before a\n   compress() or compress2() call to allocate the destination buffer.\n*/\n\nZEXTERN int ZEXPORT uncompress OF((Bytef *dest,   uLongf *destLen,\n                                   const Bytef *source, uLong sourceLen));\n/*\n     Decompresses the source buffer into the destination buffer.  sourceLen is\n   the byte length of the source buffer.  Upon entry, destLen is the total size\n   of the destination buffer, which must be large enough to hold the entire\n   uncompressed data.  (The size of the uncompressed data must have been saved\n   previously by the compressor and transmitted to the decompressor by some\n   mechanism outside the scope of this compression library.) Upon exit, destLen\n   is the actual size of the uncompressed buffer.\n\n     uncompress returns Z_OK if success, Z_MEM_ERROR if there was not\n   enough memory, Z_BUF_ERROR if there was not enough room in the output\n   buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete.\n*/\n\n\n                        /* gzip file access functions */\n\n/*\n     This library supports reading and writing files in gzip (.gz) format with\n   an interface similar to that of stdio, using the functions that start with\n   \"gz\".  The gzip format is different from the zlib format.  gzip is a gzip\n   wrapper, documented in RFC 1952, wrapped around a deflate stream.\n*/\n\ntypedef voidp gzFile;       /* opaque gzip file descriptor */\n\n/*\nZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode));\n\n     Opens a gzip (.gz) file for reading or writing.  The mode parameter is as\n   in fopen (\"rb\" or \"wb\") but can also include a compression level (\"wb9\") or\n   a strategy: 'f' for filtered data as in \"wb6f\", 'h' for Huffman-only\n   compression as in \"wb1h\", 'R' for run-length encoding as in \"wb1R\", or 'F'\n   for fixed code compression as in \"wb9F\".  (See the description of\n   deflateInit2 for more information about the strategy parameter.) Also \"a\"\n   can be used instead of \"w\" to request that the gzip stream that will be\n   written be appended to the file.  \"+\" will result in an error, since reading\n   and writing to the same gzip file is not supported.\n\n     gzopen can be used to read a file which is not in gzip format; in this\n   case gzread will directly read from the file without decompression.\n\n     gzopen returns NULL if the file could not be opened, if there was\n   insufficient memory to allocate the gzFile state, or if an invalid mode was\n   specified (an 'r', 'w', or 'a' was not provided, or '+' was provided).\n   errno can be checked to determine if the reason gzopen failed was that the\n   file could not be opened.\n*/\n\nZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode));\n/*\n     gzdopen associates a gzFile with the file descriptor fd.  File descriptors\n   are obtained from calls like open, dup, creat, pipe or fileno (if the file\n   has been previously opened with fopen).  The mode parameter is as in gzopen.\n\n     The next call of gzclose on the returned gzFile will also close the file\n   descriptor fd, just like fclose(fdopen(fd, mode)) closes the file descriptor\n   fd.  If you want to keep fd open, use fd = dup(fd_keep); gz = gzdopen(fd,\n   mode);.  The duplicated descriptor should be saved to avoid a leak, since\n   gzdopen does not close fd if it fails.\n\n     gzdopen returns NULL if there was insufficient memory to allocate the\n   gzFile state, if an invalid mode was specified (an 'r', 'w', or 'a' was not\n   provided, or '+' was provided), or if fd is -1.  The file descriptor is not\n   used until the next gz* read, write, seek, or close operation, so gzdopen\n   will not detect if fd is invalid (unless fd is -1).\n*/\n\nZEXTERN int ZEXPORT gzbuffer OF((gzFile file, unsigned size));\n/*\n     Set the internal buffer size used by this library's functions.  The\n   default buffer size is 8192 bytes.  This function must be called after\n   gzopen() or gzdopen(), and before any other calls that read or write the\n   file.  The buffer memory allocation is always deferred to the first read or\n   write.  Two buffers are allocated, either both of the specified size when\n   writing, or one of the specified size and the other twice that size when\n   reading.  A larger buffer size of, for example, 64K or 128K bytes will\n   noticeably increase the speed of decompression (reading).\n\n     The new buffer size also affects the maximum length for gzprintf().\n\n     gzbuffer() returns 0 on success, or -1 on failure, such as being called\n   too late.\n*/\n\nZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy));\n/*\n     Dynamically update the compression level or strategy.  See the description\n   of deflateInit2 for the meaning of these parameters.\n\n     gzsetparams returns Z_OK if success, or Z_STREAM_ERROR if the file was not\n   opened for writing.\n*/\n\nZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len));\n/*\n     Reads the given number of uncompressed bytes from the compressed file.  If\n   the input file was not in gzip format, gzread copies the given number of\n   bytes into the buffer.\n\n     After reaching the end of a gzip stream in the input, gzread will continue\n   to read, looking for another gzip stream, or failing that, reading the rest\n   of the input file directly without decompression.  The entire input file\n   will be read if gzread is called until it returns less than the requested\n   len.\n\n     gzread returns the number of uncompressed bytes actually read, less than\n   len for end of file, or -1 for error.\n*/\n\nZEXTERN int ZEXPORT gzwrite OF((gzFile file,\n                                voidpc buf, unsigned len));\n/*\n     Writes the given number of uncompressed bytes into the compressed file.\n   gzwrite returns the number of uncompressed bytes written or 0 in case of\n   error.\n*/\n\nZEXTERN int ZEXPORTVA gzprintf OF((gzFile file, const char *format, ...));\n/*\n     Converts, formats, and writes the arguments to the compressed file under\n   control of the format string, as in fprintf.  gzprintf returns the number of\n   uncompressed bytes actually written, or 0 in case of error.  The number of\n   uncompressed bytes written is limited to 8191, or one less than the buffer\n   size given to gzbuffer().  The caller should assure that this limit is not\n   exceeded.  If it is exceeded, then gzprintf() will return an error (0) with\n   nothing written.  In this case, there may also be a buffer overflow with\n   unpredictable consequences, which is possible only if zlib was compiled with\n   the insecure functions sprintf() or vsprintf() because the secure snprintf()\n   or vsnprintf() functions were not available.  This can be determined using\n   zlibCompileFlags().\n*/\n\nZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s));\n/*\n     Writes the given null-terminated string to the compressed file, excluding\n   the terminating null character.\n\n     gzputs returns the number of characters written, or -1 in case of error.\n*/\n\nZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len));\n/*\n     Reads bytes from the compressed file until len-1 characters are read, or a\n   newline character is read and transferred to buf, or an end-of-file\n   condition is encountered.  If any characters are read or if len == 1, the\n   string is terminated with a null character.  If no characters are read due\n   to an end-of-file or len < 1, then the buffer is left untouched.\n\n     gzgets returns buf which is a null-terminated string, or it returns NULL\n   for end-of-file or in case of error.  If there was an error, the contents at\n   buf are indeterminate.\n*/\n\nZEXTERN int ZEXPORT gzputc OF((gzFile file, int c));\n/*\n     Writes c, converted to an unsigned char, into the compressed file.  gzputc\n   returns the value that was written, or -1 in case of error.\n*/\n\nZEXTERN int ZEXPORT gzgetc OF((gzFile file));\n/*\n     Reads one byte from the compressed file.  gzgetc returns this byte or -1\n   in case of end of file or error.\n*/\n\nZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file));\n/*\n     Push one character back onto the stream to be read as the first character\n   on the next read.  At least one character of push-back is allowed.\n   gzungetc() returns the character pushed, or -1 on failure.  gzungetc() will\n   fail if c is -1, and may fail if a character has been pushed but not read\n   yet.  If gzungetc is used immediately after gzopen or gzdopen, at least the\n   output buffer size of pushed characters is allowed.  (See gzbuffer above.)\n   The pushed character will be discarded if the stream is repositioned with\n   gzseek() or gzrewind().\n*/\n\nZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush));\n/*\n     Flushes all pending output into the compressed file.  The parameter flush\n   is as in the deflate() function.  The return value is the zlib error number\n   (see function gzerror below).  gzflush is only permitted when writing.\n\n     If the flush parameter is Z_FINISH, the remaining data is written and the\n   gzip stream is completed in the output.  If gzwrite() is called again, a new\n   gzip stream will be started in the output.  gzread() is able to read such\n   concatented gzip streams.\n\n     gzflush should be called only when strictly necessary because it will\n   degrade compression if called too often.\n*/\n\n/*\nZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file,\n                                   z_off_t offset, int whence));\n\n     Sets the starting position for the next gzread or gzwrite on the given\n   compressed file.  The offset represents a number of bytes in the\n   uncompressed data stream.  The whence parameter is defined as in lseek(2);\n   the value SEEK_END is not supported.\n\n     If the file is opened for reading, this function is emulated but can be\n   extremely slow.  If the file is opened for writing, only forward seeks are\n   supported; gzseek then compresses a sequence of zeroes up to the new\n   starting position.\n\n     gzseek returns the resulting offset location as measured in bytes from\n   the beginning of the uncompressed stream, or -1 in case of error, in\n   particular if the file is opened for writing and the new starting position\n   would be before the current position.\n*/\n\nZEXTERN int ZEXPORT    gzrewind OF((gzFile file));\n/*\n     Rewinds the given file. This function is supported only for reading.\n\n     gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET)\n*/\n\n/*\nZEXTERN z_off_t ZEXPORT    gztell OF((gzFile file));\n\n     Returns the starting position for the next gzread or gzwrite on the given\n   compressed file.  This position represents a number of bytes in the\n   uncompressed data stream, and is zero when starting, even if appending or\n   reading a gzip stream from the middle of a file using gzdopen().\n\n     gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR)\n*/\n\n/*\nZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile file));\n\n     Returns the current offset in the file being read or written.  This offset\n   includes the count of bytes that precede the gzip stream, for example when\n   appending or when using gzdopen() for reading.  When reading, the offset\n   does not include as yet unused buffered input.  This information can be used\n   for a progress indicator.  On error, gzoffset() returns -1.\n*/\n\nZEXTERN int ZEXPORT gzeof OF((gzFile file));\n/*\n     Returns true (1) if the end-of-file indicator has been set while reading,\n   false (0) otherwise.  Note that the end-of-file indicator is set only if the\n   read tried to go past the end of the input, but came up short.  Therefore,\n   just like feof(), gzeof() may return false even if there is no more data to\n   read, in the event that the last read request was for the exact number of\n   bytes remaining in the input file.  This will happen if the input file size\n   is an exact multiple of the buffer size.\n\n     If gzeof() returns true, then the read functions will return no more data,\n   unless the end-of-file indicator is reset by gzclearerr() and the input file\n   has grown since the previous end of file was detected.\n*/\n\nZEXTERN int ZEXPORT gzdirect OF((gzFile file));\n/*\n     Returns true (1) if file is being copied directly while reading, or false\n   (0) if file is a gzip stream being decompressed.  This state can change from\n   false to true while reading the input file if the end of a gzip stream is\n   reached, but is followed by data that is not another gzip stream.\n\n     If the input file is empty, gzdirect() will return true, since the input\n   does not contain a gzip stream.\n\n     If gzdirect() is used immediately after gzopen() or gzdopen() it will\n   cause buffers to be allocated to allow reading the file to determine if it\n   is a gzip file.  Therefore if gzbuffer() is used, it should be called before\n   gzdirect().\n*/\n\nZEXTERN int ZEXPORT    gzclose OF((gzFile file));\n/*\n     Flushes all pending output if necessary, closes the compressed file and\n   deallocates the (de)compression state.  Note that once file is closed, you\n   cannot call gzerror with file, since its structures have been deallocated.\n   gzclose must not be called more than once on the same file, just as free\n   must not be called more than once on the same allocation.\n\n     gzclose will return Z_STREAM_ERROR if file is not valid, Z_ERRNO on a\n   file operation error, or Z_OK on success.\n*/\n\nZEXTERN int ZEXPORT gzclose_r OF((gzFile file));\nZEXTERN int ZEXPORT gzclose_w OF((gzFile file));\n/*\n     Same as gzclose(), but gzclose_r() is only for use when reading, and\n   gzclose_w() is only for use when writing or appending.  The advantage to\n   using these instead of gzclose() is that they avoid linking in zlib\n   compression or decompression code that is not used when only reading or only\n   writing respectively.  If gzclose() is used, then both compression and\n   decompression code will be included the application when linking to a static\n   zlib library.\n*/\n\nZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum));\n/*\n     Returns the error message for the last error which occurred on the given\n   compressed file.  errnum is set to zlib error number.  If an error occurred\n   in the file system and not in the compression library, errnum is set to\n   Z_ERRNO and the application may consult errno to get the exact error code.\n\n     The application must not modify the returned string.  Future calls to\n   this function may invalidate the previously returned string.  If file is\n   closed, then the string previously returned by gzerror will no longer be\n   available.\n\n     gzerror() should be used to distinguish errors from end-of-file for those\n   functions above that do not distinguish those cases in their return values.\n*/\n\nZEXTERN void ZEXPORT gzclearerr OF((gzFile file));\n/*\n     Clears the error and end-of-file flags for file.  This is analogous to the\n   clearerr() function in stdio.  This is useful for continuing to read a gzip\n   file that is being written concurrently.\n*/\n\n\n                        /* checksum functions */\n\n/*\n     These functions are not related to compression but are exported\n   anyway because they might be useful in applications using the compression\n   library.\n*/\n\nZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len));\n/*\n     Update a running Adler-32 checksum with the bytes buf[0..len-1] and\n   return the updated checksum.  If buf is Z_NULL, this function returns the\n   required initial value for the checksum.\n\n     An Adler-32 checksum is almost as reliable as a CRC32 but can be computed\n   much faster.\n\n   Usage example:\n\n     uLong adler = adler32(0L, Z_NULL, 0);\n\n     while (read_buffer(buffer, length) != EOF) {\n       adler = adler32(adler, buffer, length);\n     }\n     if (adler != original_adler) error();\n*/\n\n/*\nZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2,\n                                          z_off_t len2));\n\n     Combine two Adler-32 checksums into one.  For two sequences of bytes, seq1\n   and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for\n   each, adler1 and adler2.  adler32_combine() returns the Adler-32 checksum of\n   seq1 and seq2 concatenated, requiring only adler1, adler2, and len2.\n*/\n\nZEXTERN uLong ZEXPORT crc32   OF((uLong crc, const Bytef *buf, uInt len));\n/*\n     Update a running CRC-32 with the bytes buf[0..len-1] and return the\n   updated CRC-32.  If buf is Z_NULL, this function returns the required\n   initial value for the for the crc.  Pre- and post-conditioning (one's\n   complement) is performed within this function so it shouldn't be done by the\n   application.\n\n   Usage example:\n\n     uLong crc = crc32(0L, Z_NULL, 0);\n\n     while (read_buffer(buffer, length) != EOF) {\n       crc = crc32(crc, buffer, length);\n     }\n     if (crc != original_crc) error();\n*/\n\n/*\nZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2));\n\n     Combine two CRC-32 check values into one.  For two sequences of bytes,\n   seq1 and seq2 with lengths len1 and len2, CRC-32 check values were\n   calculated for each, crc1 and crc2.  crc32_combine() returns the CRC-32\n   check value of seq1 and seq2 concatenated, requiring only crc1, crc2, and\n   len2.\n*/\n\n\n                        /* various hacks, don't look :) */\n\n/* deflateInit and inflateInit are macros to allow checking the zlib version\n * and the compiler's view of z_stream:\n */\nZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level,\n                                     const char *version, int stream_size));\nZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm,\n                                     const char *version, int stream_size));\nZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int  level, int  method,\n                                      int windowBits, int memLevel,\n                                      int strategy, const char *version,\n                                      int stream_size));\nZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int  windowBits,\n                                      const char *version, int stream_size));\nZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits,\n                                         unsigned char FAR *window,\n                                         const char *version,\n                                         int stream_size));\n#define deflateInit(strm, level) \\\n        deflateInit_((strm), (level),       ZLIB_VERSION, sizeof(z_stream))\n#define inflateInit(strm) \\\n        inflateInit_((strm),                ZLIB_VERSION, sizeof(z_stream))\n#define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \\\n        deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\\\n                      (strategy),           ZLIB_VERSION, sizeof(z_stream))\n#define inflateInit2(strm, windowBits) \\\n        inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream))\n#define inflateBackInit(strm, windowBits, window) \\\n        inflateBackInit_((strm), (windowBits), (window), \\\n                                            ZLIB_VERSION, sizeof(z_stream))\n\n/* provide 64-bit offset functions if _LARGEFILE64_SOURCE defined, and/or\n * change the regular functions to 64 bits if _FILE_OFFSET_BITS is 64 (if\n * both are true, the application gets the *64 functions, and the regular\n * functions are changed to 64 bits) -- in case these are set on systems\n * without large file support, _LFS64_LARGEFILE must also be true\n */\n#if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0\n   ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *));\n   ZEXTERN z_off64_t ZEXPORT gzseek64 OF((gzFile, z_off64_t, int));\n   ZEXTERN z_off64_t ZEXPORT gztell64 OF((gzFile));\n   ZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile));\n   ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off64_t));\n   ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off64_t));\n#endif\n\n#if !defined(ZLIB_INTERNAL) && _FILE_OFFSET_BITS-0 == 64 && _LFS64_LARGEFILE-0\n#  define gzopen gzopen64\n#  define gzseek gzseek64\n#  define gztell gztell64\n#  define gzoffset gzoffset64\n#  define adler32_combine adler32_combine64\n#  define crc32_combine crc32_combine64\n#  ifdef _LARGEFILE64_SOURCE\n     ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *));\n     ZEXTERN z_off_t ZEXPORT gzseek64 OF((gzFile, z_off_t, int));\n     ZEXTERN z_off_t ZEXPORT gztell64 OF((gzFile));\n     ZEXTERN z_off_t ZEXPORT gzoffset64 OF((gzFile));\n     ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t));\n     ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t));\n#  endif\n#else\n   ZEXTERN gzFile ZEXPORT gzopen OF((const char *, const char *));\n   ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile, z_off_t, int));\n   ZEXTERN z_off_t ZEXPORT gztell OF((gzFile));\n   ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile));\n   ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t));\n   ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t));\n#endif\n\n/* hack for buggy compilers */\n#if !defined(ZUTIL_H) && !defined(NO_DUMMY_DECL)\n    struct internal_state {int dummy;};\n#endif\n\n/* undocumented functions */\nZEXTERN const char   * ZEXPORT zError           OF((int));\nZEXTERN int            ZEXPORT inflateSyncPoint OF((z_streamp));\nZEXTERN const uLongf * ZEXPORT get_crc_table    OF((void));\nZEXTERN int            ZEXPORT inflateUndermine OF((z_streamp, int));\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* ZLIB_H */\n"
  },
  {
    "path": "Libraries/Core/iOS/Headers/Reachability/CSReachability.h",
    "content": "/*\n     File: Reachability.h\n Abstract: Basic demonstration of how to use the SystemConfiguration Reachablity APIs.\n  Version: 3.5\n \n Disclaimer: IMPORTANT:  This Apple software is supplied to you by Apple\n Inc. (\"Apple\") in consideration of your agreement to the following\n terms, and your use, installation, modification or redistribution of\n this Apple software constitutes acceptance of these terms.  If you do\n not agree with these terms, please do not use, install, modify or\n redistribute this Apple software.\n \n In consideration of your agreement to abide by the following terms, and\n subject to these terms, Apple grants you a personal, non-exclusive\n license, under Apple's copyrights in this original Apple software (the\n \"Apple Software\"), to use, reproduce, modify and redistribute the Apple\n Software, with or without modifications, in source and/or binary forms;\n provided that if you redistribute the Apple Software in its entirety and\n without modifications, you must retain this notice and the following\n text and disclaimers in all such redistributions of the Apple Software.\n Neither the name, trademarks, service marks or logos of Apple Inc. may\n be used to endorse or promote products derived from the Apple Software\n without specific prior written permission from Apple.  Except as\n expressly stated in this notice, no other rights or licenses, express or\n implied, are granted by Apple herein, including but not limited to any\n patent rights that may be infringed by your derivative works or by other\n works in which the Apple Software may be incorporated.\n \n The Apple Software is provided by Apple on an \"AS IS\" basis.  APPLE\n MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION\n THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS\n FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND\n OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.\n \n IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL\n OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\n INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION,\n MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED\n AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),\n STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE\n POSSIBILITY OF SUCH DAMAGE.\n \n Copyright (C) 2014 Apple Inc. All Rights Reserved.\n \n */\n\n#import <Foundation/Foundation.h>\n#import <SystemConfiguration/SystemConfiguration.h>\n#import <netinet/in.h>\n\n\ntypedef enum : NSInteger {\n\tNotReachable = 0,\n\tReachableViaWiFi,\n\tReachableViaWWAN\n} NetworkStatus;\n\n\nextern NSString *kReachabilityChangedNotification;\n\n\n@interface CSReachability : NSObject\n\n/*!\n * Use to check the reachability of a given host name.\n */\n+ (instancetype)reachabilityWithHostName:(NSString *)hostName;\n\n/*!\n * Use to check the reachability of a given IP address.\n */\n+ (instancetype)reachabilityWithAddress:(const struct sockaddr_in *)hostAddress;\n\n/*!\n * Checks whether the default route is available. Should be used by applications that do not connect to a particular host.\n */\n+ (instancetype)reachabilityForInternetConnection;\n\n/*!\n * Checks whether a local WiFi connection is available.\n */\n+ (instancetype)reachabilityForLocalWiFi;\n\n/*!\n * Start listening for reachability notifications on the current run loop.\n */\n- (BOOL)startNotifier;\n- (void)stopNotifier;\n\n- (NetworkStatus)currentReachabilityStatus;\n\n/*!\n * WWAN may be available, but not active until a connection has been established. WiFi may require a connection for VPN on Demand.\n */\n- (BOOL)connectionRequired;\n\n@end\n\n\n"
  },
  {
    "path": "Libraries/Core/iOS/Headers/SHA1/HMAC_SHA1.h",
    "content": "/*\r\n\t100% free public domain implementation of the HMAC-SHA1 algorithm\r\n\tby Chien-Chung, Chung (Jim Chung) <jimchung1221@gmail.com>\r\n*/\r\n\r\n\r\n#ifndef __HMAC_SHA1_H__\r\n#define __HMAC_SHA1_H__\r\n\r\n#include \"SHA1.h\"\r\n\r\ntypedef unsigned char BYTE ;\r\n\r\nclass CHMAC_SHA1 : public CSHA1\r\n{\r\n    private:\r\n\t\tBYTE m_ipad[64];\r\n        BYTE m_opad[64];\r\n\r\n\t\tchar * szReport ;\r\n\t\tchar * SHA1_Key ;\r\n\t\tchar * AppendBuf1 ;\r\n\t\tchar * AppendBuf2 ;\r\n\r\n\r\n\tpublic:\r\n\t\t\r\n\t\tenum {\r\n\t\t\tSHA1_DIGEST_LENGTH\t= 20,\r\n\t\t\tSHA1_BLOCK_SIZE\t\t= 64,\r\n\t\t\tHMAC_BUF_LEN\t\t= 4096\r\n\t\t} ;\r\n\r\n\t\tCHMAC_SHA1()\r\n\t\t\t:szReport(new char[HMAC_BUF_LEN]),\r\n             AppendBuf1(new char[HMAC_BUF_LEN]),\r\n             AppendBuf2(new char[HMAC_BUF_LEN]),\r\n             SHA1_Key(new char[HMAC_BUF_LEN])\r\n\t\t{}\r\n\r\n        ~CHMAC_SHA1()\r\n        {\r\n            delete[] szReport ;\r\n            delete[] AppendBuf1 ;\r\n            delete[] AppendBuf2 ;\r\n            delete[] SHA1_Key ;\r\n        }\r\n\r\n        void HMAC_SHA1(BYTE *text, int text_len, BYTE *key, int key_len, BYTE *digest);\r\n};\r\n\r\n\r\n#endif /* __HMAC_SHA1_H__ */\r\n"
  },
  {
    "path": "Libraries/Core/iOS/Headers/SHA1/SHA1.h",
    "content": "/*\r\n  100% free public domain implementation of the SHA-1 algorithm\r\n  by Dominik Reichl <dominik.reichl@t-online.de>\r\n  Web: http://www.dominik-reichl.de/\r\n\r\n  Version 2.1 - 2012-06-19\r\n  - Deconstructor (resetting internal variables) is now only\r\n    implemented if SHA1_WIPE_VARIABLES is defined (which is the\r\n    default).\r\n  - Renamed inclusion guard to contain a GUID.\r\n  - Demo application is now using C++/STL objects and functions.\r\n  - Unicode build of the demo application now outputs the hashes of both\r\n    the ANSI and Unicode representations of strings.\r\n  - Various other demo application improvements.\r\n\r\n  Version 2.0 - 2012-06-14\r\n  - Added 'limits.h' include.\r\n  - Renamed inclusion guard and macros for compliancy (names beginning\r\n    with an underscore are reserved).\r\n\r\n  Version 1.9 - 2011-11-10\r\n  - Added Unicode test vectors.\r\n  - Improved support for hashing files using the HashFile method that\r\n    are larger than 4 GB.\r\n  - Improved file hashing performance (by using a larger buffer).\r\n  - Disabled unnecessary compiler warnings.\r\n  - Internal variables are now private.\r\n\r\n  Version 1.8 - 2009-03-16\r\n  - Converted project files to Visual Studio 2008 format.\r\n  - Added Unicode support for HashFile utility method.\r\n  - Added support for hashing files using the HashFile method that are\r\n    larger than 2 GB.\r\n  - HashFile now returns an error code instead of copying an error\r\n    message into the output buffer.\r\n  - GetHash now returns an error code and validates the input parameter.\r\n  - Added ReportHashStl STL utility method.\r\n  - Added REPORT_HEX_SHORT reporting mode.\r\n  - Improved Linux compatibility of test program.\r\n\r\n  Version 1.7 - 2006-12-21\r\n  - Fixed buffer underrun warning that appeared when compiling with\r\n    Borland C Builder (thanks to Rex Bloom and Tim Gallagher for the\r\n    patch).\r\n  - Breaking change: ReportHash writes the final hash to the start\r\n    of the buffer, i.e. it's not appending it to the string anymore.\r\n  - Made some function parameters const.\r\n  - Added Visual Studio 2005 project files to demo project.\r\n\r\n  Version 1.6 - 2005-02-07 (thanks to Howard Kapustein for patches)\r\n  - You can set the endianness in your files, no need to modify the\r\n    header file of the CSHA1 class anymore.\r\n  - Aligned data support.\r\n  - Made support/compilation of the utility functions (ReportHash and\r\n    HashFile) optional (useful when bytes count, for example in embedded\r\n    environments).\r\n\r\n  Version 1.5 - 2005-01-01\r\n  - 64-bit compiler compatibility added.\r\n  - Made variable wiping optional (define SHA1_WIPE_VARIABLES).\r\n  - Removed unnecessary variable initializations.\r\n  - ROL32 improvement for the Microsoft compiler (using _rotl).\r\n\r\n  Version 1.4 - 2004-07-22\r\n  - CSHA1 now compiles fine with GCC 3.3 under Mac OS X (thanks to Larry\r\n    Hastings).\r\n\r\n  Version 1.3 - 2003-08-17\r\n  - Fixed a small memory bug and made a buffer array a class member to\r\n    ensure correct working when using multiple CSHA1 class instances at\r\n    one time.\r\n\r\n  Version 1.2 - 2002-11-16\r\n  - Borlands C++ compiler seems to have problems with string addition\r\n    using sprintf. Fixed the bug which caused the digest report function\r\n    not to work properly. CSHA1 is now Borland compatible.\r\n\r\n  Version 1.1 - 2002-10-11\r\n  - Removed two unnecessary header file includes and changed BOOL to\r\n    bool. Fixed some minor bugs in the web page contents.\r\n\r\n  Version 1.0 - 2002-06-20\r\n  - First official release.\r\n\r\n  ================ Test Vectors ================\r\n\r\n  SHA1(\"abc\" in ANSI) =\r\n    A9993E36 4706816A BA3E2571 7850C26C 9CD0D89D\r\n  SHA1(\"abc\" in Unicode LE) =\r\n    9F04F41A 84851416 2050E3D6 8C1A7ABB 441DC2B5\r\n\r\n  SHA1(\"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq\"\r\n    in ANSI) =\r\n    84983E44 1C3BD26E BAAE4AA1 F95129E5 E54670F1\r\n  SHA1(\"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq\"\r\n    in Unicode LE) =\r\n    51D7D876 9AC72C40 9C5B0E3F 69C60ADC 9A039014\r\n\r\n  SHA1(A million repetitions of \"a\" in ANSI) =\r\n    34AA973C D4C4DAA4 F61EEB2B DBAD2731 6534016F\r\n  SHA1(A million repetitions of \"a\" in Unicode LE) =\r\n    C4609560 A108A0C6 26AA7F2B 38A65566 739353C5\r\n*/\r\n\r\n#ifndef SHA1_H_A545E61D43E9404E8D736869AB3CBFE7\r\n#define SHA1_H_A545E61D43E9404E8D736869AB3CBFE7\r\n\r\n#if !defined(SHA1_UTILITY_FUNCTIONS) && !defined(SHA1_NO_UTILITY_FUNCTIONS)\r\n#define SHA1_UTILITY_FUNCTIONS\r\n#endif\r\n\r\n#if !defined(SHA1_STL_FUNCTIONS) && !defined(SHA1_NO_STL_FUNCTIONS)\r\n#define SHA1_STL_FUNCTIONS\r\n#if !defined(SHA1_UTILITY_FUNCTIONS)\r\n#error STL functions require SHA1_UTILITY_FUNCTIONS.\r\n#endif\r\n#endif\r\n\r\n#include <memory.h>\r\n#include <limits.h>\r\n\r\n#ifdef SHA1_UTILITY_FUNCTIONS\r\n#include <stdio.h>\r\n#include <string.h>\r\n#endif\r\n\r\n#ifdef SHA1_STL_FUNCTIONS\r\n#include <string>\r\n#endif\r\n\r\n#ifdef _MSC_VER\r\n#include <stdlib.h>\r\n#endif\r\n\r\n// You can define the endian mode in your files without modifying the SHA-1\r\n// source files. Just #define SHA1_LITTLE_ENDIAN or #define SHA1_BIG_ENDIAN\r\n// in your files, before including the SHA1.h header file. If you don't\r\n// define anything, the class defaults to little endian.\r\n#if !defined(SHA1_LITTLE_ENDIAN) && !defined(SHA1_BIG_ENDIAN)\r\n#define SHA1_LITTLE_ENDIAN\r\n#endif\r\n\r\n// If you want variable wiping, #define SHA1_WIPE_VARIABLES, if not,\r\n// #define SHA1_NO_WIPE_VARIABLES. If you don't define anything, it\r\n// defaults to wiping.\r\n#if !defined(SHA1_WIPE_VARIABLES) && !defined(SHA1_NO_WIPE_VARIABLES)\r\n#define SHA1_WIPE_VARIABLES\r\n#endif\r\n\r\n#if defined(SHA1_HAS_TCHAR)\r\n#include <tchar.h>\r\n#else\r\n#ifdef _MSC_VER\r\n#include <tchar.h>\r\n#else\r\n#ifndef TCHAR\r\n#define TCHAR char\r\n#endif\r\n#ifndef _T\r\n#define _T(__x) (__x)\r\n#define _tmain main\r\n#define _tprintf printf\r\n#define _getts gets\r\n#define _tcslen strlen\r\n#define _tfopen fopen\r\n#define _tcscpy strcpy\r\n#define _tcscat strcat\r\n#define _sntprintf snprintf\r\n#endif\r\n#endif\r\n#endif\r\n\r\n///////////////////////////////////////////////////////////////////////////\r\n// Define variable types\r\n\r\n#ifndef UINT_8\r\n#ifdef _MSC_VER // Compiling with Microsoft compiler\r\n#define UINT_8 unsigned __int8\r\n#else // !_MSC_VER\r\n#define UINT_8 unsigned char\r\n#endif // _MSC_VER\r\n#endif\r\n\r\n#ifndef UINT_32\r\n#ifdef _MSC_VER // Compiling with Microsoft compiler\r\n#define UINT_32 unsigned __int32\r\n#else // !_MSC_VER\r\n#if (ULONG_MAX == 0xFFFFFFFFUL)\r\n#define UINT_32 unsigned long\r\n#else\r\n#define UINT_32 unsigned int\r\n#endif\r\n#endif // _MSC_VER\r\n#endif // UINT_32\r\n\r\n#ifndef INT_64\r\n#ifdef _MSC_VER // Compiling with Microsoft compiler\r\n#define INT_64 __int64\r\n#else // !_MSC_VER\r\n#define INT_64 long long\r\n#endif // _MSC_VER\r\n#endif // INT_64\r\n\r\n#ifndef UINT_64\r\n#ifdef _MSC_VER // Compiling with Microsoft compiler\r\n#define UINT_64 unsigned __int64\r\n#else // !_MSC_VER\r\n#define UINT_64 unsigned long long\r\n#endif // _MSC_VER\r\n#endif // UINT_64\r\n\r\n///////////////////////////////////////////////////////////////////////////\r\n// Declare SHA-1 workspace\r\n\r\ntypedef union\r\n{\r\n\tUINT_8 c[64];\r\n\tUINT_32 l[16];\r\n} SHA1_WORKSPACE_BLOCK;\r\n\r\nclass CSHA1\r\n{\r\npublic:\r\n#ifdef SHA1_UTILITY_FUNCTIONS\r\n\t// Different formats for ReportHash(Stl)\r\n\tenum REPORT_TYPE\r\n\t{\r\n\t\tREPORT_HEX = 0,\r\n\t\tREPORT_DIGIT = 1,\r\n\t\tREPORT_HEX_SHORT = 2\r\n\t};\r\n#endif\r\n\r\n\t// Constructor and destructor\r\n\tCSHA1();\r\n\r\n#ifdef SHA1_WIPE_VARIABLES\r\n\t~CSHA1();\r\n#endif\r\n\r\n\tvoid Reset();\r\n\r\n\t// Hash in binary data and strings\r\n\tvoid Update(const UINT_8* pbData, UINT_32 uLen);\r\n\r\n#ifdef SHA1_UTILITY_FUNCTIONS\r\n\t// Hash in file contents\r\n\tbool HashFile(const TCHAR* tszFileName);\r\n#endif\r\n\r\n\t// Finalize hash; call it before using ReportHash(Stl)\r\n\tvoid Final();\r\n\r\n#ifdef SHA1_UTILITY_FUNCTIONS\r\n\tbool ReportHash(TCHAR* tszReport, REPORT_TYPE rtReportType = REPORT_HEX) const;\r\n#endif\r\n\r\n#ifdef SHA1_STL_FUNCTIONS\r\n\tbool ReportHashStl(std::basic_string<TCHAR>& strOut, REPORT_TYPE rtReportType =\r\n\t\tREPORT_HEX) const;\r\n#endif\r\n\r\n\t// Get the raw message digest (20 bytes)\r\n\tbool GetHash(UINT_8* pbDest20) const;\r\n\r\nprivate:\r\n\t// Private SHA-1 transformation\r\n\tvoid Transform(UINT_32* pState, const UINT_8* pBuffer);\r\n\r\n\t// Member variables\r\n\tUINT_32 m_state[5];\r\n\tUINT_32 m_count[2];\r\n\tUINT_32 m_reserved0[1]; // Memory alignment padding\r\n\tUINT_8 m_buffer[64];\r\n\tUINT_8 m_digest[20];\r\n\tUINT_32 m_reserved1[3]; // Memory alignment padding\r\n\r\n\tUINT_8 m_workspace[64];\r\n\tSHA1_WORKSPACE_BLOCK* m_block; // SHA1 pointer to the byte array above\r\n};\r\n\r\n#endif // SHA1_H_A545E61D43E9404E8D736869AB3CBFE7\r\n"
  },
  {
    "path": "Libraries/Core/iOS/Headers/SHA256/sha256.h",
    "content": "// //////////////////////////////////////////////////////////\n// sha256.h\n// Copyright (c) 2014,2015 Stephan Brumme. All rights reserved.\n// see http://create.stephan-brumme.com/disclaimer.html\n//\n\n#pragma once\n\n//#include \"hash.h\"\n#include <string>\n\n// define fixed size integer types\n#ifdef _MSC_VER\n// Windows\ntypedef unsigned __int8  uint8_t;\ntypedef unsigned __int32 uint32_t;\ntypedef unsigned __int64 uint64_t;\n#else\n// GCC\n#include <stdint.h>\n#endif\n\n\n/// compute SHA256 hash\n/** Usage:\n    SHA256 sha256;\n    std::string myHash  = sha256(\"Hello World\");     // std::string\n    std::string myHash2 = sha256(\"How are you\", 11); // arbitrary data, 11 bytes\n\n    // or in a streaming fashion:\n\n    SHA256 sha256;\n    while (more data available)\n      sha256.add(pointer to fresh data, number of new bytes);\n    std::string myHash3 = sha256.getHash();\n  */\nclass SHA256 //: public Hash\n{\npublic:\n  /// split into 64 byte blocks (=> 512 bits), hash is 32 bytes long\n  enum { BlockSize = 512 / 8, HashBytes = 32 };\n\n  /// same as reset()\n  SHA256();\n\n  /// compute SHA256 of a memory block\n  std::string operator()(const void* data, size_t numBytes);\n  /// compute SHA256 of a string, excluding final zero\n  std::string operator()(const std::string& text);\n\n  /// add arbitrary number of bytes\n  void add(const void* data, size_t numBytes);\n\n  /// return latest hash as 64 hex characters\n  std::string getHash();\n  /// return latest hash as bytes\n  void        getHash(unsigned char buffer[HashBytes]);\n\n  /// restart\n  void reset();\n\nprivate:\n  /// process 64 bytes\n  void processBlock(const void* data);\n  /// process everything left in the internal buffer\n  void processBuffer();\n\n  /// size of processed data in bytes\n  uint64_t m_numBytes;\n  /// valid bytes in m_buffer\n  size_t   m_bufferSize;\n  /// bytes not processed yet\n  uint8_t  m_buffer[BlockSize];\n\n  enum { HashValues = HashBytes / 4 };\n  /// hash, stored as integers\n  uint32_t m_hash[HashValues];\n};\n"
  },
  {
    "path": "Libraries/Core/iOS/Headers/aes/aes.h",
    "content": "/* The MIT License\n\n   Copyright (C) 2011 Zilong Tan (labytan@gmail.com)\n\n   Permission is hereby granted, free of charge, to any person obtaining\n   a copy of this software and associated documentation files (the\n   \"Software\"), to deal in the Software without restriction, including\n   without limitation the rights to use, copy, modify, merge, publish,\n   distribute, sublicense, and/or sell copies of the Software, and to\n   permit persons to whom the Software is furnished to do so, subject to\n   the following conditions:\n\n   The above copyright notice and this permission notice shall be\n   included in all copies or substantial portions of the Software.\n\n   THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n   NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS\n   BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\n   ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\n   CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n   SOFTWARE.\n*/\n\n/*\n * aes.h\n *\n * @version 3.0 (December 2000)\n *\n * Optimised ANSI C code for the Rijndael cipher (now AES)\n *\n * @author Vincent Rijmen <vincent.rijmen@esat.kuleuven.ac.be>\n * @author Antoon Bosselaers <antoon.bosselaers@esat.kuleuven.ac.be>\n * @author Paulo Barreto <paulo.barreto@terra.com.br>\n *\n * This code is hereby placed in the public domain.\n *\n * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ''AS IS'' AND ANY EXPRESS\n * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE\n * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,\n * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\n#ifndef __ULIB_AES_H\n#define __ULIB_AES_H\n\n#include <stdint.h>\n\n#define AES_MAXNR 14\n#define AES_BLOCK_SIZE 16\n\nstruct aes_key_st {\n        uint32_t rd_key[4 *(AES_MAXNR + 1)];\n        int rounds;\n};\n\ntypedef struct aes_key_st AES_KEY;\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n        /* bits can be 128, 192 or 256 */\n        int  AES_set_encrypt_key(const unsigned char *userKey, const int bits,\n                                AES_KEY *key);\n        int  AES_set_decrypt_key(const unsigned char *userKey, const int bits,\n                                AES_KEY *key);\n\n        /* in/out can be the same for ECB encryption/decryption */\n        void AES_encrypt(const unsigned char *in, unsigned char *out,\n                         const AES_KEY *key);\n        void AES_decrypt(const unsigned char *in, unsigned char *out,\n                         const AES_KEY *key);\n\n        /* in/out can be the same */\n        void AES_cbc_encrypt(const unsigned char *in, unsigned char *out, unsigned char *ivec,\n                             unsigned long nblock, const AES_KEY *key);\n\n        /* in/out MUST be DIFFERENT */\n        void AES_cbc_decrypt(const unsigned char *in, unsigned char *out, unsigned char *ivec,\n                             unsigned long nblock, const AES_KEY *key);\n\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "Libraries/Core/iOS/Headers/base64/base64.h",
    "content": "#include <string>\n\nstd::string base64_encode(unsigned char const* , unsigned int len);\nstd::string base64_decode(std::string const& s);\n"
  },
  {
    "path": "Libraries/Core/iOS/Headers/json/assertions.h",
    "content": "// Copyright 2007-2010 Baptiste Lepilleur\n// Distributed under MIT license, or public domain if desired and\n// recognized in your jurisdiction.\n// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE\n\n#ifndef CPPTL_JSON_ASSERTIONS_H_INCLUDED\n#define CPPTL_JSON_ASSERTIONS_H_INCLUDED\n\n#include <stdlib.h>\n\n#if !defined(JSON_IS_AMALGAMATION)\n#include \"config.h\"\n#endif // if !defined(JSON_IS_AMALGAMATION)\n\n#if JSON_USE_EXCEPTION\n#include <stdexcept>\n#define JSON_ASSERT(condition)                                                 \\\n  assert(condition); // @todo <= change this into an exception throw\n#define JSON_FAIL_MESSAGE(message) throw std::runtime_error(message);\n#else // JSON_USE_EXCEPTION\n#define JSON_ASSERT(condition) assert(condition);\n\n// The call to assert() will show the failure message in debug builds. In\n// release bugs we write to invalid memory in order to crash hard, so that a\n// debugger or crash reporter gets the chance to take over. We still call exit()\n// afterward in order to tell the compiler that this macro doesn't return.\n#define JSON_FAIL_MESSAGE(message)                                             \\\n  {                                                                            \\\n    assert(false &&message);                                                   \\\n    strcpy(reinterpret_cast<char *>(666), message);                            \\\n    exit(123);                                                                 \\\n  }\n\n#endif\n\n#define JSON_ASSERT_MESSAGE(condition, message)                                \\\n  if (!(condition)) {                                                          \\\n    JSON_FAIL_MESSAGE(message)                                                 \\\n  }\n\n#endif // CPPTL_JSON_ASSERTIONS_H_INCLUDED\n"
  },
  {
    "path": "Libraries/Core/iOS/Headers/json/autolink.h",
    "content": "// Copyright 2007-2010 Baptiste Lepilleur\n// Distributed under MIT license, or public domain if desired and\n// recognized in your jurisdiction.\n// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE\n\n#ifndef JSON_AUTOLINK_H_INCLUDED\n#define JSON_AUTOLINK_H_INCLUDED\n\n#include \"config.h\"\n\n#ifdef JSON_IN_CPPTL\n#include <cpptl/cpptl_autolink.h>\n#endif\n\n#if !defined(JSON_NO_AUTOLINK) && !defined(JSON_DLL_BUILD) &&                  \\\n    !defined(JSON_IN_CPPTL)\n#define CPPTL_AUTOLINK_NAME \"json\"\n#undef CPPTL_AUTOLINK_DLL\n#ifdef JSON_DLL\n#define CPPTL_AUTOLINK_DLL\n#endif\n#include \"autolink.h\"\n#endif\n\n#endif // JSON_AUTOLINK_H_INCLUDED\n"
  },
  {
    "path": "Libraries/Core/iOS/Headers/json/config.h",
    "content": "// Copyright 2007-2010 Baptiste Lepilleur\n// Distributed under MIT license, or public domain if desired and\n// recognized in your jurisdiction.\n// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE\n\n#ifndef JSON_CONFIG_H_INCLUDED\n#define JSON_CONFIG_H_INCLUDED\n\n/// If defined, indicates that json library is embedded in CppTL library.\n//# define JSON_IN_CPPTL 1\n\n/// If defined, indicates that json may leverage CppTL library\n//#  define JSON_USE_CPPTL 1\n/// If defined, indicates that cpptl vector based map should be used instead of\n/// std::map\n/// as Value container.\n//#  define JSON_USE_CPPTL_SMALLMAP 1\n/// If defined, indicates that Json specific container should be used\n/// (hash table & simple deque container with customizable allocator).\n/// THIS FEATURE IS STILL EXPERIMENTAL! There is know bugs: See #3177332\n//#  define JSON_VALUE_USE_INTERNAL_MAP 1\n/// Force usage of standard new/malloc based allocator instead of memory pool\n/// based allocator.\n/// The memory pools allocator used optimization (initializing Value and\n/// ValueInternalLink\n/// as if it was a POD) that may cause some validation tool to report errors.\n/// Only has effects if JSON_VALUE_USE_INTERNAL_MAP is defined.\n//#  define JSON_USE_SIMPLE_INTERNAL_ALLOCATOR 1\n\n// If non-zero, the library uses exceptions to report bad input instead of C\n// assertion macros. The default is to use exceptions.\n#ifndef JSON_USE_EXCEPTION\n#define JSON_USE_EXCEPTION 1\n#endif\n\n/// If defined, indicates that the source file is amalgated\n/// to prevent private header inclusion.\n/// Remarks: it is automatically defined in the generated amalgated header.\n// #define JSON_IS_AMALGAMATION\n\n#ifdef JSON_IN_CPPTL\n#include <cpptl/config.h>\n#ifndef JSON_USE_CPPTL\n#define JSON_USE_CPPTL 1\n#endif\n#endif\n\n#ifdef JSON_IN_CPPTL\n#define JSON_API CPPTL_API\n#elif defined(JSON_DLL_BUILD)\n#if defined(_MSC_VER)\n#define JSON_API __declspec(dllexport)\n#define JSONCPP_DISABLE_DLL_INTERFACE_WARNING\n#endif // if defined(_MSC_VER)\n#elif defined(JSON_DLL)\n#if defined(_MSC_VER)\n#define JSON_API __declspec(dllimport)\n#define JSONCPP_DISABLE_DLL_INTERFACE_WARNING\n#endif // if defined(_MSC_VER)\n#endif // ifdef JSON_IN_CPPTL\n#if !defined(JSON_API)\n#define JSON_API\n#endif\n\n// If JSON_NO_INT64 is defined, then Json only support C++ \"int\" type for\n// integer\n// Storages, and 64 bits integer support is disabled.\n// #define JSON_NO_INT64 1\n\n#if defined(_MSC_VER) && _MSC_VER <= 1200 // MSVC 6\n// Microsoft Visual Studio 6 only support conversion from __int64 to double\n// (no conversion from unsigned __int64).\n#define JSON_USE_INT64_DOUBLE_CONVERSION 1\n// Disable warning 4786 for VS6 caused by STL (identifier was truncated to '255'\n// characters in the debug information)\n// All projects I've ever seen with VS6 were using this globally (not bothering\n// with pragma push/pop).\n#pragma warning(disable : 4786)\n#endif // if defined(_MSC_VER)  &&  _MSC_VER < 1200 // MSVC 6\n\n#if defined(_MSC_VER) && _MSC_VER >= 1500 // MSVC 2008\n/// Indicates that the following function is deprecated.\n#define JSONCPP_DEPRECATED(message) __declspec(deprecated(message))\n#endif\n\n#if !defined(JSONCPP_DEPRECATED)\n#define JSONCPP_DEPRECATED(message)\n#endif // if !defined(JSONCPP_DEPRECATED)\n\nnamespace Json {\ntypedef int Int;\ntypedef unsigned int UInt;\n#if defined(JSON_NO_INT64)\ntypedef int LargestInt;\ntypedef unsigned int LargestUInt;\n#undef JSON_HAS_INT64\n#else                 // if defined(JSON_NO_INT64)\n// For Microsoft Visual use specific types as long long is not supported\n#if defined(_MSC_VER) // Microsoft Visual Studio\ntypedef __int64 Int64;\ntypedef unsigned __int64 UInt64;\n#else                 // if defined(_MSC_VER) // Other platforms, use long long\ntypedef long long int Int64;\ntypedef unsigned long long int UInt64;\n#endif // if defined(_MSC_VER)\ntypedef Int64 LargestInt;\ntypedef UInt64 LargestUInt;\n#define JSON_HAS_INT64\n#endif // if defined(JSON_NO_INT64)\n} // end namespace Json\n\n#endif // JSON_CONFIG_H_INCLUDED\n"
  },
  {
    "path": "Libraries/Core/iOS/Headers/json/features.h",
    "content": "// Copyright 2007-2010 Baptiste Lepilleur\n// Distributed under MIT license, or public domain if desired and\n// recognized in your jurisdiction.\n// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE\n\n#ifndef CPPTL_JSON_FEATURES_H_INCLUDED\n#define CPPTL_JSON_FEATURES_H_INCLUDED\n\n#if !defined(JSON_IS_AMALGAMATION)\n#include \"forwards.h\"\n#endif // if !defined(JSON_IS_AMALGAMATION)\n\nnamespace Json {\n\n/** \\brief Configuration passed to reader and writer.\n * This configuration object can be used to force the Reader or Writer\n * to behave in a standard conforming way.\n */\nclass JSON_API Features {\npublic:\n  /** \\brief A configuration that allows all features and assumes all strings\n   * are UTF-8.\n   * - C & C++ comments are allowed\n   * - Root object can be any JSON value\n   * - Assumes Value strings are encoded in UTF-8\n   */\n  static Features all();\n\n  /** \\brief A configuration that is strictly compatible with the JSON\n   * specification.\n   * - Comments are forbidden.\n   * - Root object must be either an array or an object value.\n   * - Assumes Value strings are encoded in UTF-8\n   */\n  static Features strictMode();\n\n  /** \\brief Initialize the configuration like JsonConfig::allFeatures;\n   */\n  Features();\n\n  /// \\c true if comments are allowed. Default: \\c true.\n  bool allowComments_;\n\n  /// \\c true if root must be either an array or an object value. Default: \\c\n  /// false.\n  bool strictRoot_;\n\n  /// \\c true if dropped null placeholders are allowed. Default: \\c false.\n  bool allowDroppedNullPlaceholders_;\n\n  /// \\c true if numeric object key are allowed. Default: \\c false.\n  bool allowNumericKeys_;\n};\n\n} // namespace Json\n\n#endif // CPPTL_JSON_FEATURES_H_INCLUDED\n"
  },
  {
    "path": "Libraries/Core/iOS/Headers/json/forwards.h",
    "content": "// Copyright 2007-2010 Baptiste Lepilleur\n// Distributed under MIT license, or public domain if desired and\n// recognized in your jurisdiction.\n// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE\n\n#ifndef JSON_FORWARDS_H_INCLUDED\n#define JSON_FORWARDS_H_INCLUDED\n\n#if !defined(JSON_IS_AMALGAMATION)\n#include \"config.h\"\n#endif // if !defined(JSON_IS_AMALGAMATION)\n\nnamespace Json {\n\n// writer.h\nclass FastWriter;\nclass StyledWriter;\n\n// reader.h\nclass Reader;\n\n// features.h\nclass Features;\n\n// value.h\ntypedef unsigned int ArrayIndex;\nclass StaticString;\nclass Path;\nclass PathArgument;\nclass Value;\nclass ValueIteratorBase;\nclass ValueIterator;\nclass ValueConstIterator;\n#ifdef JSON_VALUE_USE_INTERNAL_MAP\nclass ValueMapAllocator;\nclass ValueInternalLink;\nclass ValueInternalArray;\nclass ValueInternalMap;\n#endif // #ifdef JSON_VALUE_USE_INTERNAL_MAP\n\n} // namespace Json\n\n#endif // JSON_FORWARDS_H_INCLUDED\n"
  },
  {
    "path": "Libraries/Core/iOS/Headers/json/json.h",
    "content": "// Copyright 2007-2010 Baptiste Lepilleur\n// Distributed under MIT license, or public domain if desired and\n// recognized in your jurisdiction.\n// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE\n\n#ifndef JSON_JSON_H_INCLUDED\n#define JSON_JSON_H_INCLUDED\n\n#include \"autolink.h\"\n#include \"value.h\"\n#include \"reader.h\"\n#include \"writer.h\"\n#include \"features.h\"\n\n#endif // JSON_JSON_H_INCLUDED\n"
  },
  {
    "path": "Libraries/Core/iOS/Headers/json/json_batchallocator.h",
    "content": "// Copyright 2007-2010 Baptiste Lepilleur\n// Distributed under MIT license, or public domain if desired and\n// recognized in your jurisdiction.\n// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE\n\n#ifndef JSONCPP_BATCHALLOCATOR_H_INCLUDED\n#define JSONCPP_BATCHALLOCATOR_H_INCLUDED\n\n#include <stdlib.h>\n#include <assert.h>\n\n#ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION\n\nnamespace Json {\n\n/* Fast memory allocator.\n *\n * This memory allocator allocates memory for a batch of object (specified by\n * the page size, the number of object in each page).\n *\n * It does not allow the destruction of a single object. All the allocated\n * objects can be destroyed at once. The memory can be either released or reused\n * for future allocation.\n *\n * The in-place new operator must be used to construct the object using the\n * pointer returned by allocate.\n */\ntemplate <typename AllocatedType, const unsigned int objectPerAllocation>\nclass BatchAllocator {\npublic:\n  BatchAllocator(unsigned int objectsPerPage = 255)\n      : freeHead_(0), objectsPerPage_(objectsPerPage) {\n    //      printf( \"Size: %d => %s\\n\", sizeof(AllocatedType),\n    // typeid(AllocatedType).name() );\n    assert(sizeof(AllocatedType) * objectPerAllocation >=\n           sizeof(AllocatedType *)); // We must be able to store a slist in the\n                                     // object free space.\n    assert(objectsPerPage >= 16);\n    batches_ = allocateBatch(0); // allocated a dummy page\n    currentBatch_ = batches_;\n  }\n\n  ~BatchAllocator() {\n    for (BatchInfo *batch = batches_; batch;) {\n      BatchInfo *nextBatch = batch->next_;\n      free(batch);\n      batch = nextBatch;\n    }\n  }\n\n  /// allocate space for an array of objectPerAllocation object.\n  /// @warning it is the responsability of the caller to call objects\n  /// constructors.\n  AllocatedType *allocate() {\n    if (freeHead_) // returns node from free list.\n    {\n      AllocatedType *object = freeHead_;\n      freeHead_ = *(AllocatedType **)object;\n      return object;\n    }\n    if (currentBatch_->used_ == currentBatch_->end_) {\n      currentBatch_ = currentBatch_->next_;\n      while (currentBatch_ && currentBatch_->used_ == currentBatch_->end_)\n        currentBatch_ = currentBatch_->next_;\n\n      if (!currentBatch_) // no free batch found, allocate a new one\n      {\n        currentBatch_ = allocateBatch(objectsPerPage_);\n        currentBatch_->next_ = batches_; // insert at the head of the list\n        batches_ = currentBatch_;\n      }\n    }\n    AllocatedType *allocated = currentBatch_->used_;\n    currentBatch_->used_ += objectPerAllocation;\n    return allocated;\n  }\n\n  /// Release the object.\n  /// @warning it is the responsability of the caller to actually destruct the\n  /// object.\n  void release(AllocatedType *object) {\n    assert(object != 0);\n    *(AllocatedType **)object = freeHead_;\n    freeHead_ = object;\n  }\n\nprivate:\n  struct BatchInfo {\n    BatchInfo *next_;\n    AllocatedType *used_;\n    AllocatedType *end_;\n    AllocatedType buffer_[objectPerAllocation];\n  };\n\n  // disabled copy constructor and assignement operator.\n  BatchAllocator(const BatchAllocator &);\n  void operator=(const BatchAllocator &);\n\n  static BatchInfo *allocateBatch(unsigned int objectsPerPage) {\n    const unsigned int mallocSize =\n        sizeof(BatchInfo) - sizeof(AllocatedType) * objectPerAllocation +\n        sizeof(AllocatedType) * objectPerAllocation * objectsPerPage;\n    BatchInfo *batch = static_cast<BatchInfo *>(malloc(mallocSize));\n    batch->next_ = 0;\n    batch->used_ = batch->buffer_;\n    batch->end_ = batch->buffer_ + objectsPerPage;\n    return batch;\n  }\n\n  BatchInfo *batches_;\n  BatchInfo *currentBatch_;\n  /// Head of a single linked list within the allocated space of freeed object\n  AllocatedType *freeHead_;\n  unsigned int objectsPerPage_;\n};\n\n} // namespace Json\n\n#endif // ifndef JSONCPP_DOC_INCLUDE_IMPLEMENTATION\n\n#endif // JSONCPP_BATCHALLOCATOR_H_INCLUDED\n// vim: et ts=2 sts=2 sw=2 tw=0\n"
  },
  {
    "path": "Libraries/Core/iOS/Headers/json/json_internalarray.inl",
    "content": "// Copyright 2007-2010 Baptiste Lepilleur\n// Distributed under MIT license, or public domain if desired and\n// recognized in your jurisdiction.\n// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE\n\n// included by json_value.cpp\n\nnamespace Json {\n\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// class ValueInternalArray\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n\nValueArrayAllocator::~ValueArrayAllocator()\n{\n}\n\n// //////////////////////////////////////////////////////////////////\n// class DefaultValueArrayAllocator\n// //////////////////////////////////////////////////////////////////\n#ifdef JSON_USE_SIMPLE_INTERNAL_ALLOCATOR\nclass DefaultValueArrayAllocator : public ValueArrayAllocator\n{\npublic: // overridden from ValueArrayAllocator\n   virtual ~DefaultValueArrayAllocator()\n   {\n   }\n\n   virtual ValueInternalArray *newArray()\n   {\n      return new ValueInternalArray();\n   }\n\n   virtual ValueInternalArray *newArrayCopy( const ValueInternalArray &other )\n   {\n      return new ValueInternalArray( other );\n   }\n\n   virtual void destructArray( ValueInternalArray *array )\n   {\n      delete array;\n   }\n\n   virtual void reallocateArrayPageIndex( Value **&indexes, \n                                          ValueInternalArray::PageIndex &indexCount,\n                                          ValueInternalArray::PageIndex minNewIndexCount )\n   {\n      ValueInternalArray::PageIndex newIndexCount = (indexCount*3)/2 + 1;\n      if ( minNewIndexCount > newIndexCount )\n         newIndexCount = minNewIndexCount;\n      void *newIndexes = realloc( indexes, sizeof(Value*) * newIndexCount );\n      JSON_ASSERT_MESSAGE(newIndexes, \"Couldn't realloc.\");\n      indexCount = newIndexCount;\n      indexes = static_cast<Value **>( newIndexes );\n   }\n   virtual void releaseArrayPageIndex( Value **indexes, \n                                       ValueInternalArray::PageIndex indexCount )\n   {\n      if ( indexes )\n         free( indexes );\n   }\n\n   virtual Value *allocateArrayPage()\n   {\n      return static_cast<Value *>( malloc( sizeof(Value) * ValueInternalArray::itemsPerPage ) );\n   }\n\n   virtual void releaseArrayPage( Value *value )\n   {\n      if ( value )\n         free( value );\n   }\n};\n\n#else // #ifdef JSON_USE_SIMPLE_INTERNAL_ALLOCATOR\n/// @todo make this thread-safe (lock when accessign batch allocator)\nclass DefaultValueArrayAllocator : public ValueArrayAllocator\n{\npublic: // overridden from ValueArrayAllocator\n   virtual ~DefaultValueArrayAllocator()\n   {\n   }\n\n   virtual ValueInternalArray *newArray()\n   {\n      ValueInternalArray *array = arraysAllocator_.allocate();\n      new (array) ValueInternalArray(); // placement new\n      return array;\n   }\n\n   virtual ValueInternalArray *newArrayCopy( const ValueInternalArray &other )\n   {\n      ValueInternalArray *array = arraysAllocator_.allocate();\n      new (array) ValueInternalArray( other ); // placement new\n      return array;\n   }\n\n   virtual void destructArray( ValueInternalArray *array )\n   {\n      if ( array )\n      {\n         array->~ValueInternalArray();\n         arraysAllocator_.release( array );\n      }\n   }\n\n   virtual void reallocateArrayPageIndex( Value **&indexes, \n                                          ValueInternalArray::PageIndex &indexCount,\n                                          ValueInternalArray::PageIndex minNewIndexCount )\n   {\n      ValueInternalArray::PageIndex newIndexCount = (indexCount*3)/2 + 1;\n      if ( minNewIndexCount > newIndexCount )\n         newIndexCount = minNewIndexCount;\n      void *newIndexes = realloc( indexes, sizeof(Value*) * newIndexCount );\n      JSON_ASSERT_MESSAGE(newIndexes, \"Couldn't realloc.\");\n      indexCount = newIndexCount;\n      indexes = static_cast<Value **>( newIndexes );\n   }\n   virtual void releaseArrayPageIndex( Value **indexes, \n                                       ValueInternalArray::PageIndex indexCount )\n   {\n      if ( indexes )\n         free( indexes );\n   }\n\n   virtual Value *allocateArrayPage()\n   {\n      return static_cast<Value *>( pagesAllocator_.allocate() );\n   }\n\n   virtual void releaseArrayPage( Value *value )\n   {\n      if ( value )\n         pagesAllocator_.release( value );\n   }\nprivate:\n   BatchAllocator<ValueInternalArray,1> arraysAllocator_;\n   BatchAllocator<Value,ValueInternalArray::itemsPerPage> pagesAllocator_;\n};\n#endif // #ifdef JSON_USE_SIMPLE_INTERNAL_ALLOCATOR\n\nstatic ValueArrayAllocator *&arrayAllocator()\n{\n   static DefaultValueArrayAllocator defaultAllocator;\n   static ValueArrayAllocator *arrayAllocator = &defaultAllocator;\n   return arrayAllocator;\n}\n\nstatic struct DummyArrayAllocatorInitializer {\n   DummyArrayAllocatorInitializer() \n   {\n      arrayAllocator();      // ensure arrayAllocator() statics are initialized before main().\n   }\n} dummyArrayAllocatorInitializer;\n\n// //////////////////////////////////////////////////////////////////\n// class ValueInternalArray\n// //////////////////////////////////////////////////////////////////\nbool \nValueInternalArray::equals( const IteratorState &x, \n                            const IteratorState &other )\n{\n   return x.array_ == other.array_  \n          &&  x.currentItemIndex_ == other.currentItemIndex_  \n          &&  x.currentPageIndex_ == other.currentPageIndex_;\n}\n\n\nvoid \nValueInternalArray::increment( IteratorState &it )\n{\n   JSON_ASSERT_MESSAGE( it.array_  &&\n      (it.currentPageIndex_ - it.array_->pages_)*itemsPerPage + it.currentItemIndex_\n      != it.array_->size_,\n      \"ValueInternalArray::increment(): moving iterator beyond end\" );\n   ++(it.currentItemIndex_);\n   if ( it.currentItemIndex_ == itemsPerPage )\n   {\n      it.currentItemIndex_ = 0;\n      ++(it.currentPageIndex_);\n   }\n}\n\n\nvoid \nValueInternalArray::decrement( IteratorState &it )\n{\n   JSON_ASSERT_MESSAGE( it.array_  &&  it.currentPageIndex_ == it.array_->pages_ \n                        &&  it.currentItemIndex_ == 0,\n      \"ValueInternalArray::decrement(): moving iterator beyond end\" );\n   if ( it.currentItemIndex_ == 0 )\n   {\n      it.currentItemIndex_ = itemsPerPage-1;\n      --(it.currentPageIndex_);\n   }\n   else\n   {\n      --(it.currentItemIndex_);\n   }\n}\n\n\nValue &\nValueInternalArray::unsafeDereference( const IteratorState &it )\n{\n   return (*(it.currentPageIndex_))[it.currentItemIndex_];\n}\n\n\nValue &\nValueInternalArray::dereference( const IteratorState &it )\n{\n   JSON_ASSERT_MESSAGE( it.array_  &&\n      (it.currentPageIndex_ - it.array_->pages_)*itemsPerPage + it.currentItemIndex_\n      < it.array_->size_,\n      \"ValueInternalArray::dereference(): dereferencing invalid iterator\" );\n   return unsafeDereference( it );\n}\n\nvoid \nValueInternalArray::makeBeginIterator( IteratorState &it ) const\n{\n   it.array_ = const_cast<ValueInternalArray *>( this );\n   it.currentItemIndex_ = 0;\n   it.currentPageIndex_ = pages_;\n}\n\n\nvoid \nValueInternalArray::makeIterator( IteratorState &it, ArrayIndex index ) const\n{\n   it.array_ = const_cast<ValueInternalArray *>( this );\n   it.currentItemIndex_ = index % itemsPerPage;\n   it.currentPageIndex_ = pages_ + index / itemsPerPage;\n}\n\n\nvoid \nValueInternalArray::makeEndIterator( IteratorState &it ) const\n{\n   makeIterator( it, size_ );\n}\n\n\nValueInternalArray::ValueInternalArray()\n   : pages_( 0 )\n   , size_( 0 )\n   , pageCount_( 0 )\n{\n}\n\n\nValueInternalArray::ValueInternalArray( const ValueInternalArray &other )\n   : pages_( 0 )\n   , size_( other.size_ )\n   , pageCount_( 0 )\n{\n   PageIndex minNewPages = other.size_ / itemsPerPage;\n   arrayAllocator()->reallocateArrayPageIndex( pages_, pageCount_, minNewPages );\n   JSON_ASSERT_MESSAGE( pageCount_ >= minNewPages, \n                        \"ValueInternalArray::reserve(): bad reallocation\" );\n   IteratorState itOther;\n   other.makeBeginIterator( itOther );\n   Value *value;\n   for ( ArrayIndex index = 0; index < size_; ++index, increment(itOther) )\n   {\n      if ( index % itemsPerPage == 0 )\n      {\n         PageIndex pageIndex = index / itemsPerPage;\n         value = arrayAllocator()->allocateArrayPage();\n         pages_[pageIndex] = value;\n      }\n      new (value) Value( dereference( itOther ) );\n   }\n}\n\n\nValueInternalArray &\nValueInternalArray::operator=(ValueInternalArray other)\n{\n   swap(other);\n   return *this;\n}\n\n\nValueInternalArray::~ValueInternalArray()\n{\n   // destroy all constructed items\n   IteratorState it;\n   IteratorState itEnd;\n   makeBeginIterator( it);\n   makeEndIterator( itEnd );\n   for ( ; !equals(it,itEnd); increment(it) )\n   {\n      Value *value = &dereference(it);\n      value->~Value();\n   }\n   // release all pages\n   PageIndex lastPageIndex = size_ / itemsPerPage;\n   for ( PageIndex pageIndex = 0; pageIndex < lastPageIndex; ++pageIndex )\n      arrayAllocator()->releaseArrayPage( pages_[pageIndex] );\n   // release pages index\n   arrayAllocator()->releaseArrayPageIndex( pages_, pageCount_ );\n}\n\n\nvoid \nValueInternalArray::swap( ValueInternalArray &other )\n{\n   Value **tempPages = pages_;\n   pages_ = other.pages_;\n   other.pages_ = tempPages;\n   ArrayIndex tempSize = size_;\n   size_ = other.size_;\n   other.size_ = tempSize;\n   PageIndex tempPageCount = pageCount_;\n   pageCount_ = other.pageCount_;\n   other.pageCount_ = tempPageCount;\n}\n\nvoid \nValueInternalArray::clear()\n{\n   ValueInternalArray dummy;\n   swap( dummy );\n}\n\n\nvoid \nValueInternalArray::resize( ArrayIndex newSize )\n{\n   if ( newSize == 0 )\n      clear();\n   else if ( newSize < size_ )\n   {\n      IteratorState it;\n      IteratorState itEnd;\n      makeIterator( it, newSize );\n      makeIterator( itEnd, size_ );\n      for ( ; !equals(it,itEnd); increment(it) )\n      {\n         Value *value = &dereference(it);\n         value->~Value();\n      }\n      PageIndex pageIndex = (newSize + itemsPerPage - 1) / itemsPerPage;\n      PageIndex lastPageIndex = size_ / itemsPerPage;\n      for ( ; pageIndex < lastPageIndex; ++pageIndex )\n         arrayAllocator()->releaseArrayPage( pages_[pageIndex] );\n      size_ = newSize;\n   }\n   else if ( newSize > size_ )\n      resolveReference( newSize );\n}\n\n\nvoid \nValueInternalArray::makeIndexValid( ArrayIndex index )\n{\n   // Need to enlarge page index ?\n   if ( index >= pageCount_ * itemsPerPage )\n   {\n      PageIndex minNewPages = (index + 1) / itemsPerPage;\n      arrayAllocator()->reallocateArrayPageIndex( pages_, pageCount_, minNewPages );\n      JSON_ASSERT_MESSAGE( pageCount_ >= minNewPages, \"ValueInternalArray::reserve(): bad reallocation\" );\n   }\n\n   // Need to allocate new pages ?\n   ArrayIndex nextPageIndex = \n      (size_ % itemsPerPage) != 0 ? size_ - (size_%itemsPerPage) + itemsPerPage\n                                  : size_;\n   if ( nextPageIndex <= index )\n   {\n      PageIndex pageIndex = nextPageIndex / itemsPerPage;\n      PageIndex pageToAllocate = (index - nextPageIndex) / itemsPerPage + 1;\n      for ( ; pageToAllocate-- > 0; ++pageIndex )\n         pages_[pageIndex] = arrayAllocator()->allocateArrayPage();\n   }\n\n   // Initialize all new entries\n   IteratorState it;\n   IteratorState itEnd;\n   makeIterator( it, size_ );\n   size_ = index + 1;\n   makeIterator( itEnd, size_ );\n   for ( ; !equals(it,itEnd); increment(it) )\n   {\n      Value *value = &dereference(it);\n      new (value) Value(); // Construct a default value using placement new\n   }\n}\n\nValue &\nValueInternalArray::resolveReference( ArrayIndex index )\n{\n   if ( index >= size_ )\n      makeIndexValid( index );\n   return pages_[index/itemsPerPage][index%itemsPerPage];\n}\n\nValue *\nValueInternalArray::find( ArrayIndex index ) const\n{\n   if ( index >= size_ )\n      return 0;\n   return &(pages_[index/itemsPerPage][index%itemsPerPage]);\n}\n\nValueInternalArray::ArrayIndex \nValueInternalArray::size() const\n{\n   return size_;\n}\n\nint \nValueInternalArray::distance( const IteratorState &x, const IteratorState &y )\n{\n   return indexOf(y) - indexOf(x);\n}\n\n\nValueInternalArray::ArrayIndex \nValueInternalArray::indexOf( const IteratorState &iterator )\n{\n   if ( !iterator.array_ )\n      return ArrayIndex(-1);\n   return ArrayIndex(\n      (iterator.currentPageIndex_ - iterator.array_->pages_) * itemsPerPage \n      + iterator.currentItemIndex_ );\n}\n\n\nint \nValueInternalArray::compare( const ValueInternalArray &other ) const\n{\n   int sizeDiff( size_ - other.size_ );\n   if ( sizeDiff != 0 )\n      return sizeDiff;\n   \n   for ( ArrayIndex index =0; index < size_; ++index )\n   {\n      int diff = pages_[index/itemsPerPage][index%itemsPerPage].compare( \n         other.pages_[index/itemsPerPage][index%itemsPerPage] );\n      if ( diff != 0 )\n         return diff;\n   }\n   return 0;\n}\n\n} // namespace Json\n// vim: et ts=3 sts=3 sw=3 tw=0\n"
  },
  {
    "path": "Libraries/Core/iOS/Headers/json/json_internalmap.inl",
    "content": "// Copyright 2007-2010 Baptiste Lepilleur\n// Distributed under MIT license, or public domain if desired and\n// recognized in your jurisdiction.\n// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE\n\n// included by json_value.cpp\n\nnamespace Json {\n\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// class ValueInternalMap\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n\n/** \\internal MUST be safely initialized using memset( this, 0, sizeof(ValueInternalLink) );\n   * This optimization is used by the fast allocator.\n   */\nValueInternalLink::ValueInternalLink()\n   : previous_( 0 )\n   , next_( 0 )\n{\n}\n\nValueInternalLink::~ValueInternalLink()\n{ \n   for ( int index =0; index < itemPerLink; ++index )\n   {\n      if ( !items_[index].isItemAvailable() )\n      {\n         if ( !items_[index].isMemberNameStatic() )\n            free( keys_[index] );\n      }\n      else\n         break;\n   }\n}\n\n\n\nValueMapAllocator::~ValueMapAllocator()\n{\n}\n\n#ifdef JSON_USE_SIMPLE_INTERNAL_ALLOCATOR\nclass DefaultValueMapAllocator : public ValueMapAllocator\n{\npublic: // overridden from ValueMapAllocator\n   virtual ValueInternalMap *newMap()\n   {\n      return new ValueInternalMap();\n   }\n\n   virtual ValueInternalMap *newMapCopy( const ValueInternalMap &other )\n   {\n      return new ValueInternalMap( other );\n   }\n\n   virtual void destructMap( ValueInternalMap *map )\n   {\n      delete map;\n   }\n\n   virtual ValueInternalLink *allocateMapBuckets( unsigned int size )\n   {\n      return new ValueInternalLink[size];\n   }\n\n   virtual void releaseMapBuckets( ValueInternalLink *links )\n   {\n      delete [] links;\n   }\n\n   virtual ValueInternalLink *allocateMapLink()\n   {\n      return new ValueInternalLink();\n   }\n\n   virtual void releaseMapLink( ValueInternalLink *link )\n   {\n      delete link;\n   }\n};\n#else\n/// @todo make this thread-safe (lock when accessign batch allocator)\nclass DefaultValueMapAllocator : public ValueMapAllocator\n{\npublic: // overridden from ValueMapAllocator\n   virtual ValueInternalMap *newMap()\n   {\n      ValueInternalMap *map = mapsAllocator_.allocate();\n      new (map) ValueInternalMap(); // placement new\n      return map;\n   }\n\n   virtual ValueInternalMap *newMapCopy( const ValueInternalMap &other )\n   {\n      ValueInternalMap *map = mapsAllocator_.allocate();\n      new (map) ValueInternalMap( other ); // placement new\n      return map;\n   }\n\n   virtual void destructMap( ValueInternalMap *map )\n   {\n      if ( map )\n      {\n         map->~ValueInternalMap();\n         mapsAllocator_.release( map );\n      }\n   }\n\n   virtual ValueInternalLink *allocateMapBuckets( unsigned int size )\n   {\n      return new ValueInternalLink[size];\n   }\n\n   virtual void releaseMapBuckets( ValueInternalLink *links )\n   {\n      delete [] links;\n   }\n\n   virtual ValueInternalLink *allocateMapLink()\n   {\n      ValueInternalLink *link = linksAllocator_.allocate();\n      memset( link, 0, sizeof(ValueInternalLink) );\n      return link;\n   }\n\n   virtual void releaseMapLink( ValueInternalLink *link )\n   {\n      link->~ValueInternalLink();\n      linksAllocator_.release( link );\n   }\nprivate:\n   BatchAllocator<ValueInternalMap,1> mapsAllocator_;\n   BatchAllocator<ValueInternalLink,1> linksAllocator_;\n};\n#endif\n\nstatic ValueMapAllocator *&mapAllocator()\n{\n   static DefaultValueMapAllocator defaultAllocator;\n   static ValueMapAllocator *mapAllocator = &defaultAllocator;\n   return mapAllocator;\n}\n\nstatic struct DummyMapAllocatorInitializer {\n   DummyMapAllocatorInitializer() \n   {\n      mapAllocator();      // ensure mapAllocator() statics are initialized before main().\n   }\n} dummyMapAllocatorInitializer;\n\n\n\n// h(K) = value * K >> w ; with w = 32 & K prime w.r.t. 2^32.\n\n/*\nuse linked list hash map. \nbuckets array is a container.\nlinked list element contains 6 key/values. (memory = (16+4) * 6 + 4 = 124)\nvalue have extra state: valid, available, deleted\n*/\n\n\nValueInternalMap::ValueInternalMap()\n   : buckets_( 0 )\n   , tailLink_( 0 )\n   , bucketsSize_( 0 )\n   , itemCount_( 0 )\n{\n}\n\n\nValueInternalMap::ValueInternalMap( const ValueInternalMap &other )\n   : buckets_( 0 )\n   , tailLink_( 0 )\n   , bucketsSize_( 0 )\n   , itemCount_( 0 )\n{\n   reserve( other.itemCount_ );\n   IteratorState it;\n   IteratorState itEnd;\n   other.makeBeginIterator( it );\n   other.makeEndIterator( itEnd );\n   for ( ; !equals(it,itEnd); increment(it) )\n   {\n      bool isStatic;\n      const char *memberName = key( it, isStatic );\n      const Value &aValue = value( it );\n      resolveReference(memberName, isStatic) = aValue;\n   }\n}\n\n\nValueInternalMap &\nValueInternalMap::operator=(ValueInternalMap other)\n{\n   swap(other);\n   return *this;\n}\n\n\nValueInternalMap::~ValueInternalMap()\n{\n   if ( buckets_ )\n   {\n      for ( BucketIndex bucketIndex =0; bucketIndex < bucketsSize_; ++bucketIndex )\n      {\n         ValueInternalLink *link = buckets_[bucketIndex].next_;\n         while ( link )\n         {\n            ValueInternalLink *linkToRelease = link;\n            link = link->next_;\n            mapAllocator()->releaseMapLink( linkToRelease );\n         }\n      }\n      mapAllocator()->releaseMapBuckets( buckets_ );\n   }\n}\n\n\nvoid \nValueInternalMap::swap( ValueInternalMap &other )\n{\n   ValueInternalLink *tempBuckets = buckets_;\n   buckets_ = other.buckets_;\n   other.buckets_ = tempBuckets;\n   ValueInternalLink *tempTailLink = tailLink_;\n   tailLink_ = other.tailLink_;\n   other.tailLink_ = tempTailLink;\n   BucketIndex tempBucketsSize = bucketsSize_;\n   bucketsSize_ = other.bucketsSize_;\n   other.bucketsSize_ = tempBucketsSize;\n   BucketIndex tempItemCount = itemCount_;\n   itemCount_ = other.itemCount_;\n   other.itemCount_ = tempItemCount;\n}\n\n\nvoid \nValueInternalMap::clear()\n{\n   ValueInternalMap dummy;\n   swap( dummy );\n}\n\n\nValueInternalMap::BucketIndex \nValueInternalMap::size() const\n{\n   return itemCount_;\n}\n\nbool \nValueInternalMap::reserveDelta( BucketIndex growth )\n{\n   return reserve( itemCount_ + growth );\n}\n\nbool \nValueInternalMap::reserve( BucketIndex newItemCount )\n{\n   if ( !buckets_  &&  newItemCount > 0 )\n   {\n      buckets_ = mapAllocator()->allocateMapBuckets( 1 );\n      bucketsSize_ = 1;\n      tailLink_ = &buckets_[0];\n   }\n//   BucketIndex idealBucketCount = (newItemCount + ValueInternalLink::itemPerLink) / ValueInternalLink::itemPerLink;\n   return true;\n}\n\n\nconst Value *\nValueInternalMap::find( const char *key ) const\n{\n   if ( !bucketsSize_ )\n      return 0;\n   HashKey hashedKey = hash( key );\n   BucketIndex bucketIndex = hashedKey % bucketsSize_;\n   for ( const ValueInternalLink *current = &buckets_[bucketIndex]; \n         current != 0; \n         current = current->next_ )\n   {\n      for ( BucketIndex index=0; index < ValueInternalLink::itemPerLink; ++index )\n      {\n         if ( current->items_[index].isItemAvailable() )\n            return 0;\n         if ( strcmp( key, current->keys_[index] ) == 0 )\n            return &current->items_[index];\n      }\n   }\n   return 0;\n}\n\n\nValue *\nValueInternalMap::find( const char *key )\n{\n   const ValueInternalMap *constThis = this;\n   return const_cast<Value *>( constThis->find( key ) );\n}\n\n\nValue &\nValueInternalMap::resolveReference( const char *key,\n                                    bool isStatic )\n{\n   HashKey hashedKey = hash( key );\n   if ( bucketsSize_ )\n   {\n      BucketIndex bucketIndex = hashedKey % bucketsSize_;\n      ValueInternalLink **previous = 0;\n      BucketIndex index;\n      for ( ValueInternalLink *current = &buckets_[bucketIndex]; \n            current != 0; \n            previous = &current->next_, current = current->next_ )\n      {\n         for ( index=0; index < ValueInternalLink::itemPerLink; ++index )\n         {\n            if ( current->items_[index].isItemAvailable() )\n               return setNewItem( key, isStatic, current, index );\n            if ( strcmp( key, current->keys_[index] ) == 0 )\n               return current->items_[index];\n         }\n      }\n   }\n\n   reserveDelta( 1 );\n   return unsafeAdd( key, isStatic, hashedKey );\n}\n\n\nvoid \nValueInternalMap::remove( const char *key )\n{\n   HashKey hashedKey = hash( key );\n   if ( !bucketsSize_ )\n      return;\n   BucketIndex bucketIndex = hashedKey % bucketsSize_;\n   for ( ValueInternalLink *link = &buckets_[bucketIndex]; \n         link != 0; \n         link = link->next_ )\n   {\n      BucketIndex index;\n      for ( index =0; index < ValueInternalLink::itemPerLink; ++index )\n      {\n         if ( link->items_[index].isItemAvailable() )\n            return;\n         if ( strcmp( key, link->keys_[index] ) == 0 )\n         {\n            doActualRemove( link, index, bucketIndex );\n            return;\n         }\n      }\n   }\n}\n\nvoid \nValueInternalMap::doActualRemove( ValueInternalLink *link, \n                                  BucketIndex index,\n                                  BucketIndex bucketIndex )\n{\n   // find last item of the bucket and swap it with the 'removed' one.\n   // set removed items flags to 'available'.\n   // if last page only contains 'available' items, then desallocate it (it's empty)\n   ValueInternalLink *&lastLink = getLastLinkInBucket( index );\n   BucketIndex lastItemIndex = 1; // a link can never be empty, so start at 1\n   for ( ;   \n         lastItemIndex < ValueInternalLink::itemPerLink; \n         ++lastItemIndex ) // may be optimized with dicotomic search\n   {\n      if ( lastLink->items_[lastItemIndex].isItemAvailable() )\n         break;\n   }\n   \n   BucketIndex lastUsedIndex = lastItemIndex - 1;\n   Value *valueToDelete = &link->items_[index];\n   Value *valueToPreserve = &lastLink->items_[lastUsedIndex];\n   if ( valueToDelete != valueToPreserve )\n      valueToDelete->swap( *valueToPreserve );\n   if ( lastUsedIndex == 0 )  // page is now empty\n   {  // remove it from bucket linked list and delete it.\n      ValueInternalLink *linkPreviousToLast = lastLink->previous_;\n      if ( linkPreviousToLast != 0 )   // can not deleted bucket link.\n      {\n         mapAllocator()->releaseMapLink( lastLink );\n         linkPreviousToLast->next_ = 0;\n         lastLink = linkPreviousToLast;\n      }\n   }\n   else\n   {\n      Value dummy;\n      valueToPreserve->swap( dummy ); // restore deleted to default Value.\n      valueToPreserve->setItemUsed( false );\n   }\n   --itemCount_;\n}\n\n\nValueInternalLink *&\nValueInternalMap::getLastLinkInBucket( BucketIndex bucketIndex )\n{\n   if ( bucketIndex == bucketsSize_ - 1 )\n      return tailLink_;\n   ValueInternalLink *&previous = buckets_[bucketIndex+1].previous_;\n   if ( !previous )\n      previous = &buckets_[bucketIndex];\n   return previous;\n}\n\n\nValue &\nValueInternalMap::setNewItem( const char *key, \n                              bool isStatic,\n                              ValueInternalLink *link, \n                              BucketIndex index )\n{\n   char *duplicatedKey = makeMemberName( key );\n   ++itemCount_;\n   link->keys_[index] = duplicatedKey;\n   link->items_[index].setItemUsed();\n   link->items_[index].setMemberNameIsStatic( isStatic );\n   return link->items_[index]; // items already default constructed.\n}\n\n\nValue &\nValueInternalMap::unsafeAdd( const char *key, \n                             bool isStatic, \n                             HashKey hashedKey )\n{\n   JSON_ASSERT_MESSAGE( bucketsSize_ > 0, \"ValueInternalMap::unsafeAdd(): internal logic error.\" );\n   BucketIndex bucketIndex = hashedKey % bucketsSize_;\n   ValueInternalLink *&previousLink = getLastLinkInBucket( bucketIndex );\n   ValueInternalLink *link = previousLink;\n   BucketIndex index;\n   for ( index =0; index < ValueInternalLink::itemPerLink; ++index )\n   {\n      if ( link->items_[index].isItemAvailable() )\n         break;\n   }\n   if ( index == ValueInternalLink::itemPerLink ) // need to add a new page\n   {\n      ValueInternalLink *newLink = mapAllocator()->allocateMapLink();\n      index = 0;\n      link->next_ = newLink;\n      previousLink = newLink;\n      link = newLink;\n   }\n   return setNewItem( key, isStatic, link, index );\n}\n\n\nValueInternalMap::HashKey \nValueInternalMap::hash( const char *key ) const\n{\n   HashKey hash = 0;\n   while ( *key )\n      hash += *key++ * 37;\n   return hash;\n}\n\n\nint \nValueInternalMap::compare( const ValueInternalMap &other ) const\n{\n   int sizeDiff( itemCount_ - other.itemCount_ );\n   if ( sizeDiff != 0 )\n      return sizeDiff;\n   // Strict order guaranty is required. Compare all keys FIRST, then compare values.\n   IteratorState it;\n   IteratorState itEnd;\n   makeBeginIterator( it );\n   makeEndIterator( itEnd );\n   for ( ; !equals(it,itEnd); increment(it) )\n   {\n      if ( !other.find( key( it ) ) )\n         return 1;\n   }\n\n   // All keys are equals, let's compare values\n   makeBeginIterator( it );\n   for ( ; !equals(it,itEnd); increment(it) )\n   {\n      const Value *otherValue = other.find( key( it ) );\n      int valueDiff = value(it).compare( *otherValue );\n      if ( valueDiff != 0 )\n         return valueDiff;\n   }\n   return 0;\n}\n\n\nvoid \nValueInternalMap::makeBeginIterator( IteratorState &it ) const\n{\n   it.map_ = const_cast<ValueInternalMap *>( this );\n   it.bucketIndex_ = 0;\n   it.itemIndex_ = 0;\n   it.link_ = buckets_;\n}\n\n\nvoid \nValueInternalMap::makeEndIterator( IteratorState &it ) const\n{\n   it.map_ = const_cast<ValueInternalMap *>( this );\n   it.bucketIndex_ = bucketsSize_;\n   it.itemIndex_ = 0;\n   it.link_ = 0;\n}\n\n\nbool \nValueInternalMap::equals( const IteratorState &x, const IteratorState &other )\n{\n   return x.map_ == other.map_  \n          &&  x.bucketIndex_ == other.bucketIndex_  \n          &&  x.link_ == other.link_\n          &&  x.itemIndex_ == other.itemIndex_;\n}\n\n\nvoid \nValueInternalMap::incrementBucket( IteratorState &iterator )\n{\n   ++iterator.bucketIndex_;\n   JSON_ASSERT_MESSAGE( iterator.bucketIndex_ <= iterator.map_->bucketsSize_,\n      \"ValueInternalMap::increment(): attempting to iterate beyond end.\" );\n   if ( iterator.bucketIndex_ == iterator.map_->bucketsSize_ )\n      iterator.link_ = 0;\n   else\n      iterator.link_ = &(iterator.map_->buckets_[iterator.bucketIndex_]);\n   iterator.itemIndex_ = 0;\n}\n\n\nvoid \nValueInternalMap::increment( IteratorState &iterator )\n{\n   JSON_ASSERT_MESSAGE( iterator.map_, \"Attempting to iterator using invalid iterator.\" );\n   ++iterator.itemIndex_;\n   if ( iterator.itemIndex_ == ValueInternalLink::itemPerLink )\n   {\n      JSON_ASSERT_MESSAGE( iterator.link_ != 0,\n         \"ValueInternalMap::increment(): attempting to iterate beyond end.\" );\n      iterator.link_ = iterator.link_->next_;\n      if ( iterator.link_ == 0 )\n         incrementBucket( iterator );\n   }\n   else if ( iterator.link_->items_[iterator.itemIndex_].isItemAvailable() )\n   {\n      incrementBucket( iterator );\n   }\n}\n\n\nvoid \nValueInternalMap::decrement( IteratorState &iterator )\n{\n   if ( iterator.itemIndex_ == 0 )\n   {\n      JSON_ASSERT_MESSAGE( iterator.map_, \"Attempting to iterate using invalid iterator.\" );\n      if ( iterator.link_ == &iterator.map_->buckets_[iterator.bucketIndex_] )\n      {\n         JSON_ASSERT_MESSAGE( iterator.bucketIndex_ > 0, \"Attempting to iterate beyond beginning.\" );\n         --(iterator.bucketIndex_);\n      }\n      iterator.link_ = iterator.link_->previous_;\n      iterator.itemIndex_ = ValueInternalLink::itemPerLink - 1;\n   }\n}\n\n\nconst char *\nValueInternalMap::key( const IteratorState &iterator )\n{\n   JSON_ASSERT_MESSAGE( iterator.link_, \"Attempting to iterate using invalid iterator.\" );\n   return iterator.link_->keys_[iterator.itemIndex_];\n}\n\nconst char *\nValueInternalMap::key( const IteratorState &iterator, bool &isStatic )\n{\n   JSON_ASSERT_MESSAGE( iterator.link_, \"Attempting to iterate using invalid iterator.\" );\n   isStatic = iterator.link_->items_[iterator.itemIndex_].isMemberNameStatic();\n   return iterator.link_->keys_[iterator.itemIndex_];\n}\n\n\nValue &\nValueInternalMap::value( const IteratorState &iterator )\n{\n   JSON_ASSERT_MESSAGE( iterator.link_, \"Attempting to iterate using invalid iterator.\" );\n   return iterator.link_->items_[iterator.itemIndex_];\n}\n\n\nint \nValueInternalMap::distance( const IteratorState &x, const IteratorState &y )\n{\n   int offset = 0;\n   IteratorState it = x;\n   while ( !equals( it, y ) )\n      increment( it );\n   return offset;\n}\n\n} // namespace Json\n// vim: et ts=3 sts=3 sw=3 tw=0\n"
  },
  {
    "path": "Libraries/Core/iOS/Headers/json/json_tool.h",
    "content": "// Copyright 2007-2010 Baptiste Lepilleur\n// Distributed under MIT license, or public domain if desired and\n// recognized in your jurisdiction.\n// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE\n\n#ifndef LIB_JSONCPP_JSON_TOOL_H_INCLUDED\n#define LIB_JSONCPP_JSON_TOOL_H_INCLUDED\n\n/* This header provides common string manipulation support, such as UTF-8,\n * portable conversion from/to string...\n *\n * It is an internal header that must not be exposed.\n */\n\nnamespace Json {\n\n/// Converts a unicode code-point to UTF-8.\nstatic inline std::string codePointToUTF8(unsigned int cp) {\n  std::string result;\n\n  // based on description from http://en.wikipedia.org/wiki/UTF-8\n\n  if (cp <= 0x7f) {\n    result.resize(1);\n    result[0] = static_cast<char>(cp);\n  } else if (cp <= 0x7FF) {\n    result.resize(2);\n    result[1] = static_cast<char>(0x80 | (0x3f & cp));\n    result[0] = static_cast<char>(0xC0 | (0x1f & (cp >> 6)));\n  } else if (cp <= 0xFFFF) {\n    result.resize(3);\n    result[2] = static_cast<char>(0x80 | (0x3f & cp));\n    result[1] = 0x80 | static_cast<char>((0x3f & (cp >> 6)));\n    result[0] = 0xE0 | static_cast<char>((0xf & (cp >> 12)));\n  } else if (cp <= 0x10FFFF) {\n    result.resize(4);\n    result[3] = static_cast<char>(0x80 | (0x3f & cp));\n    result[2] = static_cast<char>(0x80 | (0x3f & (cp >> 6)));\n    result[1] = static_cast<char>(0x80 | (0x3f & (cp >> 12)));\n    result[0] = static_cast<char>(0xF0 | (0x7 & (cp >> 18)));\n  }\n\n  return result;\n}\n\n/// Returns true if ch is a control character (in range [0,32[).\nstatic inline bool isControlCharacter(char ch) { return ch > 0 && ch <= 0x1F; }\n\nenum {\n  /// Constant that specify the size of the buffer that must be passed to\n  /// uintToString.\n  uintToStringBufferSize = 3 * sizeof(LargestUInt) + 1\n};\n\n// Defines a char buffer for use with uintToString().\ntypedef char UIntToStringBuffer[uintToStringBufferSize];\n\n/** Converts an unsigned integer to string.\n * @param value Unsigned interger to convert to string\n * @param current Input/Output string buffer.\n *        Must have at least uintToStringBufferSize chars free.\n */\nstatic inline void uintToString(LargestUInt value, char *&current) {\n  *--current = 0;\n  do {\n    *--current = char(value % 10) + '0';\n    value /= 10;\n  } while (value != 0);\n}\n\n/** Change ',' to '.' everywhere in buffer.\n *\n * We had a sophisticated way, but it did not work in WinCE.\n * @see https://github.com/open-source-parsers/jsoncpp/pull/9\n */\nstatic inline void fixNumericLocale(char* begin, char* end) {\n  while (begin < end) {\n    if (*begin == ',') {\n      *begin = '.';\n    }\n    ++begin;\n  }\n}\n\n} // namespace Json {\n\n#endif // LIB_JSONCPP_JSON_TOOL_H_INCLUDED\n// vim: et ts=2 sts=2 sw=2 tw=0\n"
  },
  {
    "path": "Libraries/Core/iOS/Headers/json/json_valueiterator.inl",
    "content": "// Copyright 2007-2010 Baptiste Lepilleur\n// Distributed under MIT license, or public domain if desired and\n// recognized in your jurisdiction.\n// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE\n\n// included by json_value.cpp\n\nnamespace Json {\n\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// class ValueIteratorBase\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n\nValueIteratorBase::ValueIteratorBase()\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\n   : current_()\n   , isNull_( true )\n{\n}\n#else\n   : isArray_( true )\n   , isNull_( true )\n{\n   iterator_.array_ = ValueInternalArray::IteratorState();\n}\n#endif\n\n\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\nValueIteratorBase::ValueIteratorBase( const Value::ObjectValues::iterator &current )\n   : current_( current )\n   , isNull_( false )\n{\n}\n#else\nValueIteratorBase::ValueIteratorBase( const ValueInternalArray::IteratorState &state )\n   : isArray_( true )\n{\n   iterator_.array_ = state;\n}\n\n\nValueIteratorBase::ValueIteratorBase( const ValueInternalMap::IteratorState &state )\n   : isArray_( false )\n{\n   iterator_.map_ = state;\n}\n#endif\n\nValue &\nValueIteratorBase::deref() const\n{\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\n   return current_->second;\n#else\n   if ( isArray_ )\n      return ValueInternalArray::dereference( iterator_.array_ );\n   return ValueInternalMap::value( iterator_.map_ );\n#endif\n}\n\n\nvoid \nValueIteratorBase::increment()\n{\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\n   ++current_;\n#else\n   if ( isArray_ )\n      ValueInternalArray::increment( iterator_.array_ );\n   ValueInternalMap::increment( iterator_.map_ );\n#endif\n}\n\n\nvoid \nValueIteratorBase::decrement()\n{\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\n   --current_;\n#else\n   if ( isArray_ )\n      ValueInternalArray::decrement( iterator_.array_ );\n   ValueInternalMap::decrement( iterator_.map_ );\n#endif\n}\n\n\nValueIteratorBase::difference_type \nValueIteratorBase::computeDistance( const SelfType &other ) const\n{\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\n# ifdef JSON_USE_CPPTL_SMALLMAP\n   return current_ - other.current_;\n# else\n   // Iterator for null value are initialized using the default\n   // constructor, which initialize current_ to the default\n   // std::map::iterator. As begin() and end() are two instance \n   // of the default std::map::iterator, they can not be compared.\n   // To allow this, we handle this comparison specifically.\n   if ( isNull_  &&  other.isNull_ )\n   {\n      return 0;\n   }\n\n\n   // Usage of std::distance is not portable (does not compile with Sun Studio 12 RogueWave STL,\n   // which is the one used by default).\n   // Using a portable hand-made version for non random iterator instead:\n   //   return difference_type( std::distance( current_, other.current_ ) );\n   difference_type myDistance = 0;\n   for ( Value::ObjectValues::iterator it = current_; it != other.current_; ++it )\n   {\n      ++myDistance;\n   }\n   return myDistance;\n# endif\n#else\n   if ( isArray_ )\n      return ValueInternalArray::distance( iterator_.array_, other.iterator_.array_ );\n   return ValueInternalMap::distance( iterator_.map_, other.iterator_.map_ );\n#endif\n}\n\n\nbool \nValueIteratorBase::isEqual( const SelfType &other ) const\n{\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\n   if ( isNull_ )\n   {\n      return other.isNull_;\n   }\n   return current_ == other.current_;\n#else\n   if ( isArray_ )\n      return ValueInternalArray::equals( iterator_.array_, other.iterator_.array_ );\n   return ValueInternalMap::equals( iterator_.map_, other.iterator_.map_ );\n#endif\n}\n\n\nvoid \nValueIteratorBase::copy( const SelfType &other )\n{\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\n   current_ = other.current_;\n   isNull_ = other.isNull_;\n#else\n   if ( isArray_ )\n      iterator_.array_ = other.iterator_.array_;\n   iterator_.map_ = other.iterator_.map_;\n#endif\n}\n\n\nValue \nValueIteratorBase::key() const\n{\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\n   const Value::CZString czstring = (*current_).first;\n   if ( czstring.c_str() )\n   {\n      if ( czstring.isStaticString() )\n         return Value( StaticString( czstring.c_str() ) );\n      return Value( czstring.c_str() );\n   }\n   return Value( czstring.index() );\n#else\n   if ( isArray_ )\n      return Value( ValueInternalArray::indexOf( iterator_.array_ ) );\n   bool isStatic;\n   const char *memberName = ValueInternalMap::key( iterator_.map_, isStatic );\n   if ( isStatic )\n      return Value( StaticString( memberName ) );\n   return Value( memberName );\n#endif\n}\n\n\nUInt \nValueIteratorBase::index() const\n{\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\n   const Value::CZString czstring = (*current_).first;\n   if ( !czstring.c_str() )\n      return czstring.index();\n   return Value::UInt( -1 );\n#else\n   if ( isArray_ )\n      return Value::UInt( ValueInternalArray::indexOf( iterator_.array_ ) );\n   return Value::UInt( -1 );\n#endif\n}\n\n\nconst char *\nValueIteratorBase::memberName() const\n{\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\n   const char *name = (*current_).first.c_str();\n   return name ? name : \"\";\n#else\n   if ( !isArray_ )\n      return ValueInternalMap::key( iterator_.map_ );\n   return \"\";\n#endif\n}\n\n\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// class ValueConstIterator\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n\nValueConstIterator::ValueConstIterator()\n{\n}\n\n\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\nValueConstIterator::ValueConstIterator( const Value::ObjectValues::iterator &current )\n   : ValueIteratorBase( current )\n{\n}\n#else\nValueConstIterator::ValueConstIterator( const ValueInternalArray::IteratorState &state )\n   : ValueIteratorBase( state )\n{\n}\n\nValueConstIterator::ValueConstIterator( const ValueInternalMap::IteratorState &state )\n   : ValueIteratorBase( state )\n{\n}\n#endif\n\nValueConstIterator &\nValueConstIterator::operator =( const ValueIteratorBase &other )\n{\n   copy( other );\n   return *this;\n}\n\n\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// class ValueIterator\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n\nValueIterator::ValueIterator()\n{\n}\n\n\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\nValueIterator::ValueIterator( const Value::ObjectValues::iterator &current )\n   : ValueIteratorBase( current )\n{\n}\n#else\nValueIterator::ValueIterator( const ValueInternalArray::IteratorState &state )\n   : ValueIteratorBase( state )\n{\n}\n\nValueIterator::ValueIterator( const ValueInternalMap::IteratorState &state )\n   : ValueIteratorBase( state )\n{\n}\n#endif\n\nValueIterator::ValueIterator( const ValueConstIterator &other )\n   : ValueIteratorBase( other )\n{\n}\n\nValueIterator::ValueIterator( const ValueIterator &other )\n   : ValueIteratorBase( other )\n{\n}\n\nValueIterator &\nValueIterator::operator =( const SelfType &other )\n{\n   copy( other );\n   return *this;\n}\n\n} // namespace Json\n// vim: et ts=3 sts=3 sw=3 tw=0\n"
  },
  {
    "path": "Libraries/Core/iOS/Headers/json/reader.h",
    "content": "// Copyright 2007-2010 Baptiste Lepilleur\n// Distributed under MIT license, or public domain if desired and\n// recognized in your jurisdiction.\n// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE\n\n#ifndef CPPTL_JSON_READER_H_INCLUDED\n#define CPPTL_JSON_READER_H_INCLUDED\n\n#if !defined(JSON_IS_AMALGAMATION)\n#include \"features.h\"\n#include \"value.h\"\n#endif // if !defined(JSON_IS_AMALGAMATION)\n#include <deque>\n#include <iosfwd>\n#include <stack>\n#include <string>\n\n// Disable warning C4251: <data member>: <type> needs to have dll-interface to\n// be used by...\n#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)\n#pragma warning(push)\n#pragma warning(disable : 4251)\n#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)\n\nnamespace Json {\n\n/** \\brief Unserialize a <a HREF=\"http://www.json.org\">JSON</a> document into a\n *Value.\n *\n */\nclass JSON_API Reader {\npublic:\n  typedef char Char;\n  typedef const Char *Location;\n\n  /** \\brief An error tagged with where in the JSON text it was encountered.\n   *\n   * The offsets give the [start, limit) range of bytes within the text. Note\n   * that this is bytes, not codepoints.\n   *\n   */\n  struct StructuredError {\n    size_t offset_start;\n    size_t offset_limit;\n    std::string message;\n  };\n\n  /** \\brief Constructs a Reader allowing all features\n   * for parsing.\n   */\n  Reader();\n\n  /** \\brief Constructs a Reader allowing the specified feature set\n   * for parsing.\n   */\n  Reader(const Features &features);\n\n  /** \\brief Read a Value from a <a HREF=\"http://www.json.org\">JSON</a>\n   * document.\n   * \\param document UTF-8 encoded string containing the document to read.\n   * \\param root [out] Contains the root value of the document if it was\n   *             successfully parsed.\n   * \\param collectComments \\c true to collect comment and allow writing them\n   * back during\n   *                        serialization, \\c false to discard comments.\n   *                        This parameter is ignored if\n   * Features::allowComments_\n   *                        is \\c false.\n   * \\return \\c true if the document was successfully parsed, \\c false if an\n   * error occurred.\n   */\n  bool\n  parse(const std::string &document, Value &root, bool collectComments = true);\n\n  /** \\brief Read a Value from a <a HREF=\"http://www.json.org\">JSON</a>\n   document.\n   * \\param beginDoc Pointer on the beginning of the UTF-8 encoded string of the\n   document to read.\n   * \\param endDoc Pointer on the end of the UTF-8 encoded string of the\n   document to read.\n   \\               Must be >= beginDoc.\n   * \\param root [out] Contains the root value of the document if it was\n   *             successfully parsed.\n   * \\param collectComments \\c true to collect comment and allow writing them\n   back during\n   *                        serialization, \\c false to discard comments.\n   *                        This parameter is ignored if\n   Features::allowComments_\n   *                        is \\c false.\n   * \\return \\c true if the document was successfully parsed, \\c false if an\n   error occurred.\n   */\n  bool parse(const char *beginDoc,\n             const char *endDoc,\n             Value &root,\n             bool collectComments = true);\n\n  /// \\brief Parse from input stream.\n  /// \\see Json::operator>>(std::istream&, Json::Value&).\n  bool parse(std::istream &is, Value &root, bool collectComments = true);\n\n  /** \\brief Returns a user friendly string that list errors in the parsed\n   * document.\n   * \\return Formatted error message with the list of errors with their location\n   * in\n   *         the parsed document. An empty string is returned if no error\n   * occurred\n   *         during parsing.\n   * \\deprecated Use getFormattedErrorMessages() instead (typo fix).\n   */\n  JSONCPP_DEPRECATED(\"Use getFormattedErrorMessages instead\")\n  std::string getFormatedErrorMessages() const;\n\n  /** \\brief Returns a user friendly string that list errors in the parsed\n   * document.\n   * \\return Formatted error message with the list of errors with their location\n   * in\n   *         the parsed document. An empty string is returned if no error\n   * occurred\n   *         during parsing.\n   */\n  std::string getFormattedErrorMessages() const;\n\n  /** \\brief Returns a vector of structured erros encounted while parsing.\n   * \\return A (possibly empty) vector of StructuredError objects. Currently\n   *         only one error can be returned, but the caller should tolerate\n   * multiple\n   *         errors.  This can occur if the parser recovers from a non-fatal\n   *         parse error and then encounters additional errors.\n   */\n  std::vector<StructuredError> getStructuredErrors() const;\n\nprivate:\n  enum TokenType {\n    tokenEndOfStream = 0,\n    tokenObjectBegin,\n    tokenObjectEnd,\n    tokenArrayBegin,\n    tokenArrayEnd,\n    tokenString,\n    tokenNumber,\n    tokenTrue,\n    tokenFalse,\n    tokenNull,\n    tokenArraySeparator,\n    tokenMemberSeparator,\n    tokenComment,\n    tokenError\n  };\n\n  class Token {\n  public:\n    TokenType type_;\n    Location start_;\n    Location end_;\n  };\n\n  class ErrorInfo {\n  public:\n    Token token_;\n    std::string message_;\n    Location extra_;\n  };\n\n  typedef std::deque<ErrorInfo> Errors;\n\n  bool expectToken(TokenType type, Token &token, const char *message);\n  bool readToken(Token &token);\n  void skipSpaces();\n  bool match(Location pattern, int patternLength);\n  bool readComment();\n  bool readCStyleComment();\n  bool readCppStyleComment();\n  bool readString();\n  void readNumber();\n  bool readValue();\n  bool readObject(Token &token);\n  bool readArray(Token &token);\n  bool decodeNumber(Token &token);\n  bool decodeNumber(Token &token, Value &decoded);\n  bool decodeString(Token &token);\n  bool decodeString(Token &token, std::string &decoded);\n  bool decodeDouble(Token &token);\n  bool decodeDouble(Token &token, Value &decoded);\n  bool decodeUnicodeCodePoint(Token &token,\n                              Location &current,\n                              Location end,\n                              unsigned int &unicode);\n  bool decodeUnicodeEscapeSequence(Token &token,\n                                   Location &current,\n                                   Location end,\n                                   unsigned int &unicode);\n  bool addError(const std::string &message, Token &token, Location extra = 0);\n  bool recoverFromError(TokenType skipUntilToken);\n  bool addErrorAndRecover(const std::string &message,\n                          Token &token,\n                          TokenType skipUntilToken);\n  void skipUntilSpace();\n  Value &currentValue();\n  Char getNextChar();\n  void\n  getLocationLineAndColumn(Location location, int &line, int &column) const;\n  std::string getLocationLineAndColumn(Location location) const;\n  void addComment(Location begin, Location end, CommentPlacement placement);\n  void skipCommentTokens(Token &token);\n\n  typedef std::stack<Value *> Nodes;\n  Nodes nodes_;\n  Errors errors_;\n  std::string document_;\n  Location begin_;\n  Location end_;\n  Location current_;\n  Location lastValueEnd_;\n  Value *lastValue_;\n  std::string commentsBefore_;\n  Features features_;\n  bool collectComments_;\n};\n\n/** \\brief Read from 'sin' into 'root'.\n\n Always keep comments from the input JSON.\n\n This can be used to read a file into a particular sub-object.\n For example:\n \\code\n Json::Value root;\n cin >> root[\"dir\"][\"file\"];\n cout << root;\n \\endcode\n Result:\n \\verbatim\n {\n \"dir\": {\n     \"file\": {\n     // The input stream JSON would be nested here.\n     }\n }\n }\n \\endverbatim\n \\throw std::exception on parse error.\n \\see Json::operator<<()\n*/\nJSON_API std::istream &operator>>(std::istream &, Value &);\n\n} // namespace Json\n\n#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)\n#pragma warning(pop)\n#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)\n\n#endif // CPPTL_JSON_READER_H_INCLUDED\n"
  },
  {
    "path": "Libraries/Core/iOS/Headers/json/value.h",
    "content": "// Copyright 2007-2010 Baptiste Lepilleur\n// Distributed under MIT license, or public domain if desired and\n// recognized in your jurisdiction.\n// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE\n\n#ifndef CPPTL_JSON_H_INCLUDED\n#define CPPTL_JSON_H_INCLUDED\n\n#if !defined(JSON_IS_AMALGAMATION)\n#include \"forwards.h\"\n#endif // if !defined(JSON_IS_AMALGAMATION)\n#include <string>\n#include <vector>\n\n#ifndef JSON_USE_CPPTL_SMALLMAP\n#include <map>\n#else\n#include <cpptl/smallmap.h>\n#endif\n#ifdef JSON_USE_CPPTL\n#include <cpptl/forwards.h>\n#endif\n\n// Disable warning C4251: <data member>: <type> needs to have dll-interface to\n// be used by...\n#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)\n#pragma warning(push)\n#pragma warning(disable : 4251)\n#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)\n\n/** \\brief JSON (JavaScript Object Notation).\n */\nnamespace Json {\n\n/** \\brief Type of the value held by a Value object.\n */\nenum ValueType {\n  nullValue = 0, ///< 'null' value\n  intValue,      ///< signed integer value\n  uintValue,     ///< unsigned integer value\n  realValue,     ///< double value\n  stringValue,   ///< UTF-8 string value\n  booleanValue,  ///< bool value\n  arrayValue,    ///< array value (ordered list)\n  objectValue    ///< object value (collection of name/value pairs).\n};\n\nenum CommentPlacement {\n  commentBefore = 0,      ///< a comment placed on the line before a value\n  commentAfterOnSameLine, ///< a comment just after a value on the same line\n  commentAfter, ///< a comment on the line after a value (only make sense for\n  /// root value)\n  numberOfCommentPlacement\n};\n\n//# ifdef JSON_USE_CPPTL\n//   typedef CppTL::AnyEnumerator<const char *> EnumMemberNames;\n//   typedef CppTL::AnyEnumerator<const Value &> EnumValues;\n//# endif\n\n/** \\brief Lightweight wrapper to tag static string.\n *\n * Value constructor and objectValue member assignement takes advantage of the\n * StaticString and avoid the cost of string duplication when storing the\n * string or the member name.\n *\n * Example of usage:\n * \\code\n * Json::Value aValue( StaticString(\"some text\") );\n * Json::Value object;\n * static const StaticString code(\"code\");\n * object[code] = 1234;\n * \\endcode\n */\nclass JSON_API StaticString {\npublic:\n  explicit StaticString(const char *czstring) : str_(czstring) {}\n\n  operator const char *() const { return str_; }\n\n  const char *c_str() const { return str_; }\n\nprivate:\n  const char *str_;\n};\n\n/** \\brief Represents a <a HREF=\"http://www.json.org\">JSON</a> value.\n *\n * This class is a discriminated union wrapper that can represents a:\n * - signed integer [range: Value::minInt - Value::maxInt]\n * - unsigned integer (range: 0 - Value::maxUInt)\n * - double\n * - UTF-8 string\n * - boolean\n * - 'null'\n * - an ordered list of Value\n * - collection of name/value pairs (javascript object)\n *\n * The type of the held value is represented by a #ValueType and\n * can be obtained using type().\n *\n * values of an #objectValue or #arrayValue can be accessed using operator[]()\n *methods.\n * Non const methods will automatically create the a #nullValue element\n * if it does not exist.\n * The sequence of an #arrayValue will be automatically resize and initialized\n * with #nullValue. resize() can be used to enlarge or truncate an #arrayValue.\n *\n * The get() methods can be used to obtanis default value in the case the\n *required element\n * does not exist.\n *\n * It is possible to iterate over the list of a #objectValue values using\n * the getMemberNames() method.\n */\nclass JSON_API Value {\n  friend class ValueIteratorBase;\n#ifdef JSON_VALUE_USE_INTERNAL_MAP\n  friend class ValueInternalLink;\n  friend class ValueInternalMap;\n#endif\npublic:\n  typedef std::vector<std::string> Members;\n  typedef ValueIterator iterator;\n  typedef ValueConstIterator const_iterator;\n  typedef Json::UInt UInt;\n  typedef Json::Int Int;\n#if defined(JSON_HAS_INT64)\n  typedef Json::UInt64 UInt64;\n  typedef Json::Int64 Int64;\n#endif // defined(JSON_HAS_INT64)\n  typedef Json::LargestInt LargestInt;\n  typedef Json::LargestUInt LargestUInt;\n  typedef Json::ArrayIndex ArrayIndex;\n\n  static const Value& null;\n  /// Minimum signed integer value that can be stored in a Json::Value.\n  static const LargestInt minLargestInt;\n  /// Maximum signed integer value that can be stored in a Json::Value.\n  static const LargestInt maxLargestInt;\n  /// Maximum unsigned integer value that can be stored in a Json::Value.\n  static const LargestUInt maxLargestUInt;\n\n  /// Minimum signed int value that can be stored in a Json::Value.\n  static const Int minInt;\n  /// Maximum signed int value that can be stored in a Json::Value.\n  static const Int maxInt;\n  /// Maximum unsigned int value that can be stored in a Json::Value.\n  static const UInt maxUInt;\n\n#if defined(JSON_HAS_INT64)\n  /// Minimum signed 64 bits int value that can be stored in a Json::Value.\n  static const Int64 minInt64;\n  /// Maximum signed 64 bits int value that can be stored in a Json::Value.\n  static const Int64 maxInt64;\n  /// Maximum unsigned 64 bits int value that can be stored in a Json::Value.\n  static const UInt64 maxUInt64;\n#endif // defined(JSON_HAS_INT64)\n\nprivate:\n#ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\n  class CZString {\n  public:\n    enum DuplicationPolicy {\n      noDuplication = 0,\n      duplicate,\n      duplicateOnCopy\n    };\n    CZString(ArrayIndex index);\n    CZString(const char *cstr, DuplicationPolicy allocate);\n    CZString(const CZString &other);\n    ~CZString();\n    CZString &operator=(CZString other);\n    bool operator<(const CZString &other) const;\n    bool operator==(const CZString &other) const;\n    ArrayIndex index() const;\n    const char *c_str() const;\n    bool isStaticString() const;\n\n  private:\n    void swap(CZString &other);\n    const char *cstr_;\n    ArrayIndex index_;\n  };\n\npublic:\n#ifndef JSON_USE_CPPTL_SMALLMAP\n  typedef std::map<CZString, Value> ObjectValues;\n#else\n  typedef CppTL::SmallMap<CZString, Value> ObjectValues;\n#endif // ifndef JSON_USE_CPPTL_SMALLMAP\n#endif // ifndef JSON_VALUE_USE_INTERNAL_MAP\n#endif // ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION\n\npublic:\n  /** \\brief Create a default Value of the given type.\n\n    This is a very useful constructor.\n    To create an empty array, pass arrayValue.\n    To create an empty object, pass objectValue.\n    Another Value can then be set to this one by assignment.\nThis is useful since clear() and resize() will not alter types.\n\n    Examples:\n\\code\nJson::Value null_value; // null\nJson::Value arr_value(Json::arrayValue); // []\nJson::Value obj_value(Json::objectValue); // {}\n\\endcode\n  */\n  Value(ValueType type = nullValue);\n  Value(Int value);\n  Value(UInt value);\n#if defined(JSON_HAS_INT64)\n  Value(Int64 value);\n  Value(UInt64 value);\n#endif // if defined(JSON_HAS_INT64)\n  Value(double value);\n  Value(const char *value);\n  Value(const char *beginValue, const char *endValue);\n  /** \\brief Constructs a value from a static string.\n\n   * Like other value string constructor but do not duplicate the string for\n   * internal storage. The given string must remain alive after the call to this\n   * constructor.\n   * Example of usage:\n   * \\code\n   * Json::Value aValue( StaticString(\"some text\") );\n   * \\endcode\n   */\n  Value(const StaticString &value);\n  Value(const std::string &value);\n#ifdef JSON_USE_CPPTL\n  Value(const CppTL::ConstString &value);\n#endif\n  Value(bool value);\n  Value(const Value &other);\n  ~Value();\n\n  Value &operator=(Value other);\n  /// Swap values.\n  /// \\note Currently, comments are intentionally not swapped, for\n  /// both logic and efficiency.\n  void swap(Value &other);\n\n  ValueType type() const;\n\n  bool operator<(const Value &other) const;\n  bool operator<=(const Value &other) const;\n  bool operator>=(const Value &other) const;\n  bool operator>(const Value &other) const;\n\n  bool operator==(const Value &other) const;\n  bool operator!=(const Value &other) const;\n\n  int compare(const Value &other) const;\n\n  const char *asCString() const;\n  std::string asString() const;\n#ifdef JSON_USE_CPPTL\n  CppTL::ConstString asConstString() const;\n#endif\n  Int asInt() const;\n  UInt asUInt() const;\n#if defined(JSON_HAS_INT64)\n  Int64 asInt64() const;\n  UInt64 asUInt64() const;\n#endif // if defined(JSON_HAS_INT64)\n  LargestInt asLargestInt() const;\n  LargestUInt asLargestUInt() const;\n  float asFloat() const;\n  double asDouble() const;\n  bool asBool() const;\n\n  bool isNull() const;\n  bool isBool() const;\n  bool isInt() const;\n  bool isInt64() const;\n  bool isUInt() const;\n  bool isUInt64() const;\n  bool isIntegral() const;\n  bool isDouble() const;\n  bool isNumeric() const;\n  bool isString() const;\n  bool isArray() const;\n  bool isObject() const;\n\n  bool isConvertibleTo(ValueType other) const;\n\n  /// Number of values in array or object\n  ArrayIndex size() const;\n\n  /// \\brief Return true if empty array, empty object, or null;\n  /// otherwise, false.\n  bool empty() const;\n\n  /// Return isNull()\n  bool operator!() const;\n\n  /// Remove all object members and array elements.\n  /// \\pre type() is arrayValue, objectValue, or nullValue\n  /// \\post type() is unchanged\n  void clear();\n\n  /// Resize the array to size elements.\n  /// New elements are initialized to null.\n  /// May only be called on nullValue or arrayValue.\n  /// \\pre type() is arrayValue or nullValue\n  /// \\post type() is arrayValue\n  void resize(ArrayIndex size);\n\n  /// Access an array element (zero based index ).\n  /// If the array contains less than index element, then null value are\n  /// inserted\n  /// in the array so that its size is index+1.\n  /// (You may need to say 'value[0u]' to get your compiler to distinguish\n  ///  this from the operator[] which takes a string.)\n  Value &operator[](ArrayIndex index);\n\n  /// Access an array element (zero based index ).\n  /// If the array contains less than index element, then null value are\n  /// inserted\n  /// in the array so that its size is index+1.\n  /// (You may need to say 'value[0u]' to get your compiler to distinguish\n  ///  this from the operator[] which takes a string.)\n  Value &operator[](int index);\n\n  /// Access an array element (zero based index )\n  /// (You may need to say 'value[0u]' to get your compiler to distinguish\n  ///  this from the operator[] which takes a string.)\n  const Value &operator[](ArrayIndex index) const;\n\n  /// Access an array element (zero based index )\n  /// (You may need to say 'value[0u]' to get your compiler to distinguish\n  ///  this from the operator[] which takes a string.)\n  const Value &operator[](int index) const;\n\n  /// If the array contains at least index+1 elements, returns the element\n  /// value,\n  /// otherwise returns defaultValue.\n  Value get(ArrayIndex index, const Value &defaultValue) const;\n  /// Return true if index < size().\n  bool isValidIndex(ArrayIndex index) const;\n  /// \\brief Append value to array at the end.\n  ///\n  /// Equivalent to jsonvalue[jsonvalue.size()] = value;\n  Value &append(const Value &value);\n\n  /// Access an object value by name, create a null member if it does not exist.\n  Value &operator[](const char *key);\n  /// Access an object value by name, returns null if there is no member with\n  /// that name.\n  const Value &operator[](const char *key) const;\n  /// Access an object value by name, create a null member if it does not exist.\n  Value &operator[](const std::string &key);\n  /// Access an object value by name, returns null if there is no member with\n  /// that name.\n  const Value &operator[](const std::string &key) const;\n  /** \\brief Access an object value by name, create a null member if it does not\n   exist.\n\n   * If the object as no entry for that name, then the member name used to store\n   * the new entry is not duplicated.\n   * Example of use:\n   * \\code\n   * Json::Value object;\n   * static const StaticString code(\"code\");\n   * object[code] = 1234;\n   * \\endcode\n   */\n  Value &operator[](const StaticString &key);\n#ifdef JSON_USE_CPPTL\n  /// Access an object value by name, create a null member if it does not exist.\n  Value &operator[](const CppTL::ConstString &key);\n  /// Access an object value by name, returns null if there is no member with\n  /// that name.\n  const Value &operator[](const CppTL::ConstString &key) const;\n#endif\n  /// Return the member named key if it exist, defaultValue otherwise.\n  Value get(const char *key, const Value &defaultValue) const;\n  /// Return the member named key if it exist, defaultValue otherwise.\n  Value get(const std::string &key, const Value &defaultValue) const;\n#ifdef JSON_USE_CPPTL\n  /// Return the member named key if it exist, defaultValue otherwise.\n  Value get(const CppTL::ConstString &key, const Value &defaultValue) const;\n#endif\n  /// \\brief Remove and return the named member.\n  ///\n  /// Do nothing if it did not exist.\n  /// \\return the removed Value, or null.\n  /// \\pre type() is objectValue or nullValue\n  /// \\post type() is unchanged\n  Value removeMember(const char *key);\n  /// Same as removeMember(const char*)\n  Value removeMember(const std::string &key);\n\n  /// Return true if the object has a member named key.\n  bool isMember(const char *key) const;\n  /// Return true if the object has a member named key.\n  bool isMember(const std::string &key) const;\n#ifdef JSON_USE_CPPTL\n  /// Return true if the object has a member named key.\n  bool isMember(const CppTL::ConstString &key) const;\n#endif\n\n  /// \\brief Return a list of the member names.\n  ///\n  /// If null, return an empty list.\n  /// \\pre type() is objectValue or nullValue\n  /// \\post if type() was nullValue, it remains nullValue\n  Members getMemberNames() const;\n\n  //# ifdef JSON_USE_CPPTL\n  //      EnumMemberNames enumMemberNames() const;\n  //      EnumValues enumValues() const;\n  //# endif\n\n  /// Comments must be //... or /* ... */\n  void setComment(const char *comment, CommentPlacement placement);\n  /// Comments must be //... or /* ... */\n  void setComment(const std::string &comment, CommentPlacement placement);\n  bool hasComment(CommentPlacement placement) const;\n  /// Include delimiters and embedded newlines.\n  std::string getComment(CommentPlacement placement) const;\n\n  std::string toStyledString() const;\n\n  const_iterator begin() const;\n  const_iterator end() const;\n\n  iterator begin();\n  iterator end();\n\n  // Accessors for the [start, limit) range of bytes within the JSON text from\n  // which this value was parsed, if any.\n  void setOffsetStart(size_t start);\n  void setOffsetLimit(size_t limit);\n  size_t getOffsetStart() const;\n  size_t getOffsetLimit() const;\n\nprivate:\n  Value &resolveReference(const char *key, bool isStatic);\n\n#ifdef JSON_VALUE_USE_INTERNAL_MAP\n  inline bool isItemAvailable() const { return itemIsUsed_ == 0; }\n\n  inline void setItemUsed(bool isUsed = true) { itemIsUsed_ = isUsed ? 1 : 0; }\n\n  inline bool isMemberNameStatic() const { return memberNameIsStatic_ == 0; }\n\n  inline void setMemberNameIsStatic(bool isStatic) {\n    memberNameIsStatic_ = isStatic ? 1 : 0;\n  }\n#endif // # ifdef JSON_VALUE_USE_INTERNAL_MAP\n\nprivate:\n  struct CommentInfo {\n    CommentInfo();\n    ~CommentInfo();\n\n    void setComment(const char *text);\n\n    char *comment_;\n  };\n\n  // struct MemberNamesTransform\n  //{\n  //   typedef const char *result_type;\n  //   const char *operator()( const CZString &name ) const\n  //   {\n  //      return name.c_str();\n  //   }\n  //};\n\n  union ValueHolder {\n    LargestInt int_;\n    LargestUInt uint_;\n    double real_;\n    bool bool_;\n    char *string_;\n#ifdef JSON_VALUE_USE_INTERNAL_MAP\n    ValueInternalArray *array_;\n    ValueInternalMap *map_;\n#else\n    ObjectValues *map_;\n#endif\n  } value_;\n  ValueType type_ : 8;\n  int allocated_ : 1; // Notes: if declared as bool, bitfield is useless.\n#ifdef JSON_VALUE_USE_INTERNAL_MAP\n  unsigned int itemIsUsed_ : 1; // used by the ValueInternalMap container.\n  int memberNameIsStatic_ : 1;  // used by the ValueInternalMap container.\n#endif\n  CommentInfo *comments_;\n\n  // [start, limit) byte offsets in the source JSON text from which this Value\n  // was extracted.\n  size_t start_;\n  size_t limit_;\n};\n\n/** \\brief Experimental and untested: represents an element of the \"path\" to\n * access a node.\n */\nclass JSON_API PathArgument {\npublic:\n  friend class Path;\n\n  PathArgument();\n  PathArgument(ArrayIndex index);\n  PathArgument(const char *key);\n  PathArgument(const std::string &key);\n\nprivate:\n  enum Kind {\n    kindNone = 0,\n    kindIndex,\n    kindKey\n  };\n  std::string key_;\n  ArrayIndex index_;\n  Kind kind_;\n};\n\n/** \\brief Experimental and untested: represents a \"path\" to access a node.\n *\n * Syntax:\n * - \".\" => root node\n * - \".[n]\" => elements at index 'n' of root node (an array value)\n * - \".name\" => member named 'name' of root node (an object value)\n * - \".name1.name2.name3\"\n * - \".[0][1][2].name1[3]\"\n * - \".%\" => member name is provided as parameter\n * - \".[%]\" => index is provied as parameter\n */\nclass JSON_API Path {\npublic:\n  Path(const std::string &path,\n       const PathArgument &a1 = PathArgument(),\n       const PathArgument &a2 = PathArgument(),\n       const PathArgument &a3 = PathArgument(),\n       const PathArgument &a4 = PathArgument(),\n       const PathArgument &a5 = PathArgument());\n\n  const Value &resolve(const Value &root) const;\n  Value resolve(const Value &root, const Value &defaultValue) const;\n  /// Creates the \"path\" to access the specified node and returns a reference on\n  /// the node.\n  Value &make(Value &root) const;\n\nprivate:\n  typedef std::vector<const PathArgument *> InArgs;\n  typedef std::vector<PathArgument> Args;\n\n  void makePath(const std::string &path, const InArgs &in);\n  void addPathInArg(const std::string &path,\n                    const InArgs &in,\n                    InArgs::const_iterator &itInArg,\n                    PathArgument::Kind kind);\n  void invalidPath(const std::string &path, int location);\n\n  Args args_;\n};\n\n#ifdef JSON_VALUE_USE_INTERNAL_MAP\n/** \\brief Allocator to customize Value internal map.\n * Below is an example of a simple implementation (default implementation\n actually\n * use memory pool for speed).\n * \\code\n   class DefaultValueMapAllocator : public ValueMapAllocator\n   {\n   public: // overridden from ValueMapAllocator\n      virtual ValueInternalMap *newMap()\n      {\n         return new ValueInternalMap();\n      }\n\n      virtual ValueInternalMap *newMapCopy( const ValueInternalMap &other )\n      {\n         return new ValueInternalMap( other );\n      }\n\n      virtual void destructMap( ValueInternalMap *map )\n      {\n         delete map;\n      }\n\n      virtual ValueInternalLink *allocateMapBuckets( unsigned int size )\n      {\n         return new ValueInternalLink[size];\n      }\n\n      virtual void releaseMapBuckets( ValueInternalLink *links )\n      {\n         delete [] links;\n      }\n\n      virtual ValueInternalLink *allocateMapLink()\n      {\n         return new ValueInternalLink();\n      }\n\n      virtual void releaseMapLink( ValueInternalLink *link )\n      {\n         delete link;\n      }\n   };\n * \\endcode\n */\nclass JSON_API ValueMapAllocator {\npublic:\n  virtual ~ValueMapAllocator();\n  virtual ValueInternalMap *newMap() = 0;\n  virtual ValueInternalMap *newMapCopy(const ValueInternalMap &other) = 0;\n  virtual void destructMap(ValueInternalMap *map) = 0;\n  virtual ValueInternalLink *allocateMapBuckets(unsigned int size) = 0;\n  virtual void releaseMapBuckets(ValueInternalLink *links) = 0;\n  virtual ValueInternalLink *allocateMapLink() = 0;\n  virtual void releaseMapLink(ValueInternalLink *link) = 0;\n};\n\n/** \\brief ValueInternalMap hash-map bucket chain link (for internal use only).\n * \\internal previous_ & next_ allows for bidirectional traversal.\n */\nclass JSON_API ValueInternalLink {\npublic:\n  enum {\n    itemPerLink = 6\n  }; // sizeof(ValueInternalLink) = 128 on 32 bits architecture.\n  enum InternalFlags {\n    flagAvailable = 0,\n    flagUsed = 1\n  };\n\n  ValueInternalLink();\n\n  ~ValueInternalLink();\n\n  Value items_[itemPerLink];\n  char *keys_[itemPerLink];\n  ValueInternalLink *previous_;\n  ValueInternalLink *next_;\n};\n\n/** \\brief A linked page based hash-table implementation used internally by\n *Value.\n * \\internal ValueInternalMap is a tradional bucket based hash-table, with a\n *linked\n * list in each bucket to handle collision. There is an addional twist in that\n * each node of the collision linked list is a page containing a fixed amount of\n * value. This provides a better compromise between memory usage and speed.\n *\n * Each bucket is made up of a chained list of ValueInternalLink. The last\n * link of a given bucket can be found in the 'previous_' field of the following\n *bucket.\n * The last link of the last bucket is stored in tailLink_ as it has no\n *following bucket.\n * Only the last link of a bucket may contains 'available' item. The last link\n *always\n * contains at least one element unless is it the bucket one very first link.\n */\nclass JSON_API ValueInternalMap {\n  friend class ValueIteratorBase;\n  friend class Value;\n\npublic:\n  typedef unsigned int HashKey;\n  typedef unsigned int BucketIndex;\n\n#ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION\n  struct IteratorState {\n    IteratorState() : map_(0), link_(0), itemIndex_(0), bucketIndex_(0) {}\n    ValueInternalMap *map_;\n    ValueInternalLink *link_;\n    BucketIndex itemIndex_;\n    BucketIndex bucketIndex_;\n  };\n#endif // ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION\n\n  ValueInternalMap();\n  ValueInternalMap(const ValueInternalMap &other);\n  ValueInternalMap &operator=(ValueInternalMap other);\n  ~ValueInternalMap();\n\n  void swap(ValueInternalMap &other);\n\n  BucketIndex size() const;\n\n  void clear();\n\n  bool reserveDelta(BucketIndex growth);\n\n  bool reserve(BucketIndex newItemCount);\n\n  const Value *find(const char *key) const;\n\n  Value *find(const char *key);\n\n  Value &resolveReference(const char *key, bool isStatic);\n\n  void remove(const char *key);\n\n  void doActualRemove(ValueInternalLink *link,\n                      BucketIndex index,\n                      BucketIndex bucketIndex);\n\n  ValueInternalLink *&getLastLinkInBucket(BucketIndex bucketIndex);\n\n  Value &setNewItem(const char *key,\n                    bool isStatic,\n                    ValueInternalLink *link,\n                    BucketIndex index);\n\n  Value &unsafeAdd(const char *key, bool isStatic, HashKey hashedKey);\n\n  HashKey hash(const char *key) const;\n\n  int compare(const ValueInternalMap &other) const;\n\nprivate:\n  void makeBeginIterator(IteratorState &it) const;\n  void makeEndIterator(IteratorState &it) const;\n  static bool equals(const IteratorState &x, const IteratorState &other);\n  static void increment(IteratorState &iterator);\n  static void incrementBucket(IteratorState &iterator);\n  static void decrement(IteratorState &iterator);\n  static const char *key(const IteratorState &iterator);\n  static const char *key(const IteratorState &iterator, bool &isStatic);\n  static Value &value(const IteratorState &iterator);\n  static int distance(const IteratorState &x, const IteratorState &y);\n\nprivate:\n  ValueInternalLink *buckets_;\n  ValueInternalLink *tailLink_;\n  BucketIndex bucketsSize_;\n  BucketIndex itemCount_;\n};\n\n/** \\brief A simplified deque implementation used internally by Value.\n* \\internal\n* It is based on a list of fixed \"page\", each page contains a fixed number of\n*items.\n* Instead of using a linked-list, a array of pointer is used for fast item\n*look-up.\n* Look-up for an element is as follow:\n* - compute page index: pageIndex = itemIndex / itemsPerPage\n* - look-up item in page: pages_[pageIndex][itemIndex % itemsPerPage]\n*\n* Insertion is amortized constant time (only the array containing the index of\n*pointers\n* need to be reallocated when items are appended).\n*/\nclass JSON_API ValueInternalArray {\n  friend class Value;\n  friend class ValueIteratorBase;\n\npublic:\n  enum {\n    itemsPerPage = 8\n  }; // should be a power of 2 for fast divide and modulo.\n  typedef Value::ArrayIndex ArrayIndex;\n  typedef unsigned int PageIndex;\n\n#ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION\n  struct IteratorState // Must be a POD\n      {\n    IteratorState() : array_(0), currentPageIndex_(0), currentItemIndex_(0) {}\n    ValueInternalArray *array_;\n    Value **currentPageIndex_;\n    unsigned int currentItemIndex_;\n  };\n#endif // ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION\n\n  ValueInternalArray();\n  ValueInternalArray(const ValueInternalArray &other);\n  ValueInternalArray &operator=(ValueInternalArray other);\n  ~ValueInternalArray();\n  void swap(ValueInternalArray &other);\n\n  void clear();\n  void resize(ArrayIndex newSize);\n\n  Value &resolveReference(ArrayIndex index);\n\n  Value *find(ArrayIndex index) const;\n\n  ArrayIndex size() const;\n\n  int compare(const ValueInternalArray &other) const;\n\nprivate:\n  static bool equals(const IteratorState &x, const IteratorState &other);\n  static void increment(IteratorState &iterator);\n  static void decrement(IteratorState &iterator);\n  static Value &dereference(const IteratorState &iterator);\n  static Value &unsafeDereference(const IteratorState &iterator);\n  static int distance(const IteratorState &x, const IteratorState &y);\n  static ArrayIndex indexOf(const IteratorState &iterator);\n  void makeBeginIterator(IteratorState &it) const;\n  void makeEndIterator(IteratorState &it) const;\n  void makeIterator(IteratorState &it, ArrayIndex index) const;\n\n  void makeIndexValid(ArrayIndex index);\n\n  Value **pages_;\n  ArrayIndex size_;\n  PageIndex pageCount_;\n};\n\n/** \\brief Experimental: do not use. Allocator to customize Value internal\narray.\n * Below is an example of a simple implementation (actual implementation use\n * memory pool).\n   \\code\nclass DefaultValueArrayAllocator : public ValueArrayAllocator\n{\npublic: // overridden from ValueArrayAllocator\nvirtual ~DefaultValueArrayAllocator()\n{\n}\n\nvirtual ValueInternalArray *newArray()\n{\n   return new ValueInternalArray();\n}\n\nvirtual ValueInternalArray *newArrayCopy( const ValueInternalArray &other )\n{\n   return new ValueInternalArray( other );\n}\n\nvirtual void destruct( ValueInternalArray *array )\n{\n   delete array;\n}\n\nvirtual void reallocateArrayPageIndex( Value **&indexes,\n                                       ValueInternalArray::PageIndex\n&indexCount,\n                                       ValueInternalArray::PageIndex\nminNewIndexCount )\n{\n   ValueInternalArray::PageIndex newIndexCount = (indexCount*3)/2 + 1;\n   if ( minNewIndexCount > newIndexCount )\n      newIndexCount = minNewIndexCount;\n   void *newIndexes = realloc( indexes, sizeof(Value*) * newIndexCount );\n   if ( !newIndexes )\n      throw std::bad_alloc();\n   indexCount = newIndexCount;\n   indexes = static_cast<Value **>( newIndexes );\n}\nvirtual void releaseArrayPageIndex( Value **indexes,\n                                    ValueInternalArray::PageIndex indexCount )\n{\n   if ( indexes )\n      free( indexes );\n}\n\nvirtual Value *allocateArrayPage()\n{\n   return static_cast<Value *>( malloc( sizeof(Value) *\nValueInternalArray::itemsPerPage ) );\n}\n\nvirtual void releaseArrayPage( Value *value )\n{\n   if ( value )\n      free( value );\n}\n};\n   \\endcode\n */\nclass JSON_API ValueArrayAllocator {\npublic:\n  virtual ~ValueArrayAllocator();\n  virtual ValueInternalArray *newArray() = 0;\n  virtual ValueInternalArray *newArrayCopy(const ValueInternalArray &other) = 0;\n  virtual void destructArray(ValueInternalArray *array) = 0;\n  /** \\brief Reallocate array page index.\n   * Reallocates an array of pointer on each page.\n   * \\param indexes [input] pointer on the current index. May be \\c NULL.\n   *                [output] pointer on the new index of at least\n   *                         \\a minNewIndexCount pages.\n   * \\param indexCount [input] current number of pages in the index.\n   *                   [output] number of page the reallocated index can handle.\n   *                            \\b MUST be >= \\a minNewIndexCount.\n   * \\param minNewIndexCount Minimum number of page the new index must be able\n   * to\n   *                         handle.\n   */\n  virtual void\n  reallocateArrayPageIndex(Value **&indexes,\n                           ValueInternalArray::PageIndex &indexCount,\n                           ValueInternalArray::PageIndex minNewIndexCount) = 0;\n  virtual void\n  releaseArrayPageIndex(Value **indexes,\n                        ValueInternalArray::PageIndex indexCount) = 0;\n  virtual Value *allocateArrayPage() = 0;\n  virtual void releaseArrayPage(Value *value) = 0;\n};\n#endif // #ifdef JSON_VALUE_USE_INTERNAL_MAP\n\n/** \\brief base class for Value iterators.\n *\n */\nclass JSON_API ValueIteratorBase {\npublic:\n  typedef std::bidirectional_iterator_tag iterator_category;\n  typedef unsigned int size_t;\n  typedef int difference_type;\n  typedef ValueIteratorBase SelfType;\n\n  ValueIteratorBase();\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\n  explicit ValueIteratorBase(const Value::ObjectValues::iterator &current);\n#else\n  ValueIteratorBase(const ValueInternalArray::IteratorState &state);\n  ValueIteratorBase(const ValueInternalMap::IteratorState &state);\n#endif\n\n  bool operator==(const SelfType &other) const { return isEqual(other); }\n\n  bool operator!=(const SelfType &other) const { return !isEqual(other); }\n\n  difference_type operator-(const SelfType &other) const {\n    return computeDistance(other);\n  }\n\n  /// Return either the index or the member name of the referenced value as a\n  /// Value.\n  Value key() const;\n\n  /// Return the index of the referenced Value. -1 if it is not an arrayValue.\n  UInt index() const;\n\n  /// Return the member name of the referenced Value. \"\" if it is not an\n  /// objectValue.\n  const char *memberName() const;\n\nprotected:\n  Value &deref() const;\n\n  void increment();\n\n  void decrement();\n\n  difference_type computeDistance(const SelfType &other) const;\n\n  bool isEqual(const SelfType &other) const;\n\n  void copy(const SelfType &other);\n\nprivate:\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\n  Value::ObjectValues::iterator current_;\n  // Indicates that iterator is for a null value.\n  bool isNull_;\n#else\n  union {\n    ValueInternalArray::IteratorState array_;\n    ValueInternalMap::IteratorState map_;\n  } iterator_;\n  bool isArray_;\n#endif\n};\n\n/** \\brief const iterator for object and array value.\n *\n */\nclass JSON_API ValueConstIterator : public ValueIteratorBase {\n  friend class Value;\n\npublic:\n  typedef const Value value_type;\n  typedef unsigned int size_t;\n  typedef int difference_type;\n  typedef const Value &reference;\n  typedef const Value *pointer;\n  typedef ValueConstIterator SelfType;\n\n  ValueConstIterator();\n\nprivate:\n/*! \\internal Use by Value to create an iterator.\n */\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\n  explicit ValueConstIterator(const Value::ObjectValues::iterator &current);\n#else\n  ValueConstIterator(const ValueInternalArray::IteratorState &state);\n  ValueConstIterator(const ValueInternalMap::IteratorState &state);\n#endif\npublic:\n  SelfType &operator=(const ValueIteratorBase &other);\n\n  SelfType operator++(int) {\n    SelfType temp(*this);\n    ++*this;\n    return temp;\n  }\n\n  SelfType operator--(int) {\n    SelfType temp(*this);\n    --*this;\n    return temp;\n  }\n\n  SelfType &operator--() {\n    decrement();\n    return *this;\n  }\n\n  SelfType &operator++() {\n    increment();\n    return *this;\n  }\n\n  reference operator*() const { return deref(); }\n};\n\n/** \\brief Iterator for object and array value.\n */\nclass JSON_API ValueIterator : public ValueIteratorBase {\n  friend class Value;\n\npublic:\n  typedef Value value_type;\n  typedef unsigned int size_t;\n  typedef int difference_type;\n  typedef Value &reference;\n  typedef Value *pointer;\n  typedef ValueIterator SelfType;\n\n  ValueIterator();\n  ValueIterator(const ValueConstIterator &other);\n  ValueIterator(const ValueIterator &other);\n\nprivate:\n/*! \\internal Use by Value to create an iterator.\n */\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\n  explicit ValueIterator(const Value::ObjectValues::iterator &current);\n#else\n  ValueIterator(const ValueInternalArray::IteratorState &state);\n  ValueIterator(const ValueInternalMap::IteratorState &state);\n#endif\npublic:\n  SelfType &operator=(const SelfType &other);\n\n  SelfType operator++(int) {\n    SelfType temp(*this);\n    ++*this;\n    return temp;\n  }\n\n  SelfType operator--(int) {\n    SelfType temp(*this);\n    --*this;\n    return temp;\n  }\n\n  SelfType &operator--() {\n    decrement();\n    return *this;\n  }\n\n  SelfType &operator++() {\n    increment();\n    return *this;\n  }\n\n  reference operator*() const { return deref(); }\n};\n\n} // namespace Json\n\n#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)\n#pragma warning(pop)\n#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)\n\n#endif // CPPTL_JSON_H_INCLUDED\n"
  },
  {
    "path": "Libraries/Core/iOS/Headers/json/writer.h",
    "content": "// Copyright 2007-2010 Baptiste Lepilleur\n// Distributed under MIT license, or public domain if desired and\n// recognized in your jurisdiction.\n// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE\n\n#ifndef JSON_WRITER_H_INCLUDED\n#define JSON_WRITER_H_INCLUDED\n\n#if !defined(JSON_IS_AMALGAMATION)\n#include \"value.h\"\n#endif // if !defined(JSON_IS_AMALGAMATION)\n#include <vector>\n#include <string>\n\n// Disable warning C4251: <data member>: <type> needs to have dll-interface to\n// be used by...\n#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)\n#pragma warning(push)\n#pragma warning(disable : 4251)\n#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)\n\nnamespace Json {\n\nclass Value;\n\n/** \\brief Abstract class for writers.\n */\nclass JSON_API Writer {\npublic:\n  virtual ~Writer();\n\n  virtual std::string write(const Value &root) = 0;\n};\n\n/** \\brief Outputs a Value in <a HREF=\"http://www.json.org\">JSON</a> format\n *without formatting (not human friendly).\n *\n * The JSON document is written in a single line. It is not intended for 'human'\n *consumption,\n * but may be usefull to support feature such as RPC where bandwith is limited.\n * \\sa Reader, Value\n */\nclass JSON_API FastWriter : public Writer {\npublic:\n  FastWriter();\n  virtual ~FastWriter() {}\n\n  void enableYAMLCompatibility();\n\n  /** \\brief Drop the \"null\" string from the writer's output for nullValues.\n   * Strictly speaking, this is not valid JSON. But when the output is being\n   * fed to a browser's Javascript, it makes for smaller output and the\n   * browser can handle the output just fine.\n   */\n  void dropNullPlaceholders();\n\n  void omitEndingLineFeed();\n\npublic: // overridden from Writer\n  virtual std::string write(const Value &root);\n\nprivate:\n  void writeValue(const Value &value);\n\n  std::string document_;\n  bool yamlCompatiblityEnabled_;\n  bool dropNullPlaceholders_;\n  bool omitEndingLineFeed_;\n};\n\n/** \\brief Writes a Value in <a HREF=\"http://www.json.org\">JSON</a> format in a\n *human friendly way.\n *\n * The rules for line break and indent are as follow:\n * - Object value:\n *     - if empty then print {} without indent and line break\n *     - if not empty the print '{', line break & indent, print one value per\n *line\n *       and then unindent and line break and print '}'.\n * - Array value:\n *     - if empty then print [] without indent and line break\n *     - if the array contains no object value, empty array or some other value\n *types,\n *       and all the values fit on one lines, then print the array on a single\n *line.\n *     - otherwise, it the values do not fit on one line, or the array contains\n *       object or non empty array, then print one value per line.\n *\n * If the Value have comments then they are outputed according to their\n *#CommentPlacement.\n *\n * \\sa Reader, Value, Value::setComment()\n */\nclass JSON_API StyledWriter : public Writer {\npublic:\n  StyledWriter();\n  virtual ~StyledWriter() {}\n\npublic: // overridden from Writer\n  /** \\brief Serialize a Value in <a HREF=\"http://www.json.org\">JSON</a> format.\n   * \\param root Value to serialize.\n   * \\return String containing the JSON document that represents the root value.\n   */\n  virtual std::string write(const Value &root);\n\nprivate:\n  void writeValue(const Value &value);\n  void writeArrayValue(const Value &value);\n  bool isMultineArray(const Value &value);\n  void pushValue(const std::string &value);\n  void writeIndent();\n  void writeWithIndent(const std::string &value);\n  void indent();\n  void unindent();\n  void writeCommentBeforeValue(const Value &root);\n  void writeCommentAfterValueOnSameLine(const Value &root);\n  bool hasCommentForValue(const Value &value);\n  static std::string normalizeEOL(const std::string &text);\n\n  typedef std::vector<std::string> ChildValues;\n\n  ChildValues childValues_;\n  std::string document_;\n  std::string indentString_;\n  int rightMargin_;\n  int indentSize_;\n  bool addChildValues_;\n};\n\n/** \\brief Writes a Value in <a HREF=\"http://www.json.org\">JSON</a> format in a\n human friendly way,\n     to a stream rather than to a string.\n *\n * The rules for line break and indent are as follow:\n * - Object value:\n *     - if empty then print {} without indent and line break\n *     - if not empty the print '{', line break & indent, print one value per\n line\n *       and then unindent and line break and print '}'.\n * - Array value:\n *     - if empty then print [] without indent and line break\n *     - if the array contains no object value, empty array or some other value\n types,\n *       and all the values fit on one lines, then print the array on a single\n line.\n *     - otherwise, it the values do not fit on one line, or the array contains\n *       object or non empty array, then print one value per line.\n *\n * If the Value have comments then they are outputed according to their\n #CommentPlacement.\n *\n * \\param indentation Each level will be indented by this amount extra.\n * \\sa Reader, Value, Value::setComment()\n */\nclass JSON_API StyledStreamWriter {\npublic:\n  StyledStreamWriter(std::string indentation = \"\\t\");\n  ~StyledStreamWriter() {}\n\npublic:\n  /** \\brief Serialize a Value in <a HREF=\"http://www.json.org\">JSON</a> format.\n   * \\param out Stream to write to. (Can be ostringstream, e.g.)\n   * \\param root Value to serialize.\n   * \\note There is no point in deriving from Writer, since write() should not\n   * return a value.\n   */\n  void write(std::ostream &out, const Value &root);\n\nprivate:\n  void writeValue(const Value &value);\n  void writeArrayValue(const Value &value);\n  bool isMultineArray(const Value &value);\n  void pushValue(const std::string &value);\n  void writeIndent();\n  void writeWithIndent(const std::string &value);\n  void indent();\n  void unindent();\n  void writeCommentBeforeValue(const Value &root);\n  void writeCommentAfterValueOnSameLine(const Value &root);\n  bool hasCommentForValue(const Value &value);\n  static std::string normalizeEOL(const std::string &text);\n\n  typedef std::vector<std::string> ChildValues;\n\n  ChildValues childValues_;\n  std::ostream *document_;\n  std::string indentString_;\n  int rightMargin_;\n  std::string indentation_;\n  bool addChildValues_;\n};\n\n#if defined(JSON_HAS_INT64)\nstd::string JSON_API valueToString(Int value);\nstd::string JSON_API valueToString(UInt value);\n#endif // if defined(JSON_HAS_INT64)\nstd::string JSON_API valueToString(LargestInt value);\nstd::string JSON_API valueToString(LargestUInt value);\nstd::string JSON_API valueToString(double value);\nstd::string JSON_API valueToString(bool value);\nstd::string JSON_API valueToQuotedString(const char *value);\n\n/// \\brief Output using the StyledStreamWriter.\n/// \\see Json::operator>>()\nJSON_API std::ostream &operator<<(std::ostream &, const Value &root);\n\n} // namespace Json\n\n#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)\n#pragma warning(pop)\n#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)\n\n#endif // JSON_WRITER_H_INCLUDED\n"
  },
  {
    "path": "Libraries/Core/iOS/Headers/md5/md5.h",
    "content": "/* MD5\n converted to C++ class by Frank Thilo (thilo@unix-ag.org)\n for bzflag (http://www.bzflag.org)\n\n   based on:\n\n   md5.h and md5.c\n   reference implementation of RFC 1321\n\n   Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All\nrights reserved.\n\nLicense to copy and use this software is granted provided that it\nis identified as the \"RSA Data Security, Inc. MD5 Message-Digest\nAlgorithm\" in all material mentioning or referencing this software\nor this function.\n\nLicense is also granted to make and use derivative works provided\nthat such works are identified as \"derived from the RSA Data\nSecurity, Inc. MD5 Message-Digest Algorithm\" in all material\nmentioning or referencing the derived work.\n\nRSA Data Security, Inc. makes no representations concerning either\nthe merchantability of this software or the suitability of this\nsoftware for any particular purpose. It is provided \"as is\"\nwithout express or implied warranty of any kind.\n\nThese notices must be retained in any copies of any part of this\ndocumentation and/or software.\n\n*/\n\n#ifndef BZF_MD5_H\n#define BZF_MD5_H\n\n#include <cstring>\n#include <iostream>\n\n\n// a small class for calculating MD5 hashes of strings or byte arrays\n// it is not meant to be fast or secure\n//\n// usage: 1) feed it blocks of uchars with update()\n//      2) finalize()\n//      3) get hexdigest() string\n//      or\n//      MD5(std::string).hexdigest()\n//\n// assumes that char is 8 bit and int is 32 bit\nclass MD5\n{\npublic:\n  typedef unsigned int size_type; // must be 32bit\n\n  MD5();\n  MD5(const std::string& text);\n  void update(const unsigned char *buf, size_type length);\n  void update(const char *buf, size_type length);\n  MD5& finalize();\n  std::string hexdigest() const;\n  friend std::ostream& operator<<(std::ostream&, MD5 md5);\n  std::string binarydigest() const {return std::string(reinterpret_cast<const char*>(digest), 16);} //Ian Copland, 09/06/2014: added accessor for the raw digest.\n    \nprivate:\n  void init();\n  typedef unsigned char uint1; //  8bit\n  typedef unsigned int uint4;  // 32bit\n  enum {blocksize = 64}; // VC6 won't eat a const static int here\n\n  void transform(const uint1 block[blocksize]);\n  static void decode(uint4 output[], const uint1 input[], size_type len);\n  static void encode(uint1 output[], const uint4 input[], size_type len);\n\n  bool finalized;\n  uint1 buffer[blocksize]; // bytes that didn't fit in last 64 byte chunk\n  uint4 count[2];   // 64bit counter for number of bits (lo, hi)\n  uint4 state[4];   // digest so far\n  uint1 digest[16]; // the result\n\n  // low level logic operations\n  static inline uint4 F(uint4 x, uint4 y, uint4 z);\n  static inline uint4 G(uint4 x, uint4 y, uint4 z);\n  static inline uint4 H(uint4 x, uint4 y, uint4 z);\n  static inline uint4 I(uint4 x, uint4 y, uint4 z);\n  static inline uint4 rotate_left(uint4 x, int n);\n  static inline void FF(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac);\n  static inline void GG(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac);\n  static inline void HH(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac);\n  static inline void II(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac);\n};\n\nstd::string md5(const std::string str);\n\n#endif\n"
  },
  {
    "path": "Libraries/Core/iOS/Headers/minizip/crypt.h",
    "content": "/* crypt.h -- base code for crypt/uncrypt ZIPfile\n\n\n   Version 1.01e, February 12th, 2005\n\n   Copyright (C) 1998-2005 Gilles Vollant\n\n   This code is a modified version of crypting code in Infozip distribution\n\n   The encryption/decryption parts of this source code (as opposed to the\n   non-echoing password parts) were originally written in Europe.  The\n   whole source package can be freely distributed, including from the USA.\n   (Prior to January 2000, re-export from the US was a violation of US law.)\n\n   This encryption code is a direct transcription of the algorithm from\n   Roger Schlafly, described by Phil Katz in the file appnote.txt.  This\n   file (appnote.txt) is distributed with the PKZIP program (even in the\n   version without encryption capabilities).\n\n   If you don't need crypting in your application, just define symbols\n   NOCRYPT and NOUNCRYPT.\n\n   This code support the \"Traditional PKWARE Encryption\".\n\n   The new AES encryption added on Zip format by Winzip (see the page\n   http://www.winzip.com/aes_info.htm ) and PKWare PKZip 5.x Strong\n   Encryption is not supported.\n*/\n\n#define CRC32(c, b) ((*(pcrc_32_tab+(((int)(c) ^ (b)) & 0xff))) ^ ((c) >> 8))\n\n/***********************************************************************\n * Return the next byte in the pseudo-random sequence\n */\nstatic int decrypt_byte(unsigned long* pkeys, const unsigned long* pcrc_32_tab)\n{\n    unsigned temp;  /* POTENTIAL BUG:  temp*(temp^1) may overflow in an\n                     * unpredictable manner on 16-bit systems; not a problem\n                     * with any known compiler so far, though */\n\n    temp = ((unsigned)(*(pkeys+2)) & 0xffff) | 2;\n    return (int)(((temp * (temp ^ 1)) >> 8) & 0xff);\n}\n\n/***********************************************************************\n * Update the encryption keys with the next byte of plain text\n */\nstatic int update_keys(unsigned long* pkeys,const unsigned long* pcrc_32_tab,int c)\n{\n    (*(pkeys+0)) = CRC32((*(pkeys+0)), c);\n    (*(pkeys+1)) += (*(pkeys+0)) & 0xff;\n    (*(pkeys+1)) = (*(pkeys+1)) * 134775813L + 1;\n    {\n      register int keyshift = (int)((*(pkeys+1)) >> 24);\n      (*(pkeys+2)) = CRC32((*(pkeys+2)), keyshift);\n    }\n    return c;\n}\n\n\n/***********************************************************************\n * Initialize the encryption keys and the random header according to\n * the given password.\n */\nstatic void init_keys(const char* passwd,unsigned long* pkeys,const unsigned long* pcrc_32_tab)\n{\n    *(pkeys+0) = 305419896L;\n    *(pkeys+1) = 591751049L;\n    *(pkeys+2) = 878082192L;\n    while (*passwd != '\\0') {\n        update_keys(pkeys,pcrc_32_tab,(int)*passwd);\n        passwd++;\n    }\n}\n\n#define zdecode(pkeys,pcrc_32_tab,c) \\\n    (update_keys(pkeys,pcrc_32_tab,c ^= decrypt_byte(pkeys,pcrc_32_tab)))\n\n#define zencode(pkeys,pcrc_32_tab,c,t) \\\n    (t=decrypt_byte(pkeys,pcrc_32_tab), update_keys(pkeys,pcrc_32_tab,c), t^(c))\n\n#ifdef INCLUDECRYPTINGCODE_IFCRYPTALLOWED\n\n#define RAND_HEAD_LEN  12\n   /* \"last resort\" source for second part of crypt seed pattern */\n#  ifndef ZCR_SEED2\n#    define ZCR_SEED2 3141592654UL     /* use PI as default pattern */\n#  endif\n\nstatic int crypthead(const char* passwd,      /* password string */\n                     unsigned char* buf,      /* where to write header */\n                     int bufSize,\n                     unsigned long* pkeys,\n                     const unsigned long* pcrc_32_tab,\n                     unsigned long crcForCrypting)\n{\n    int n;                       /* index in random header */\n    int t;                       /* temporary */\n    int c;                       /* random byte */\n    unsigned char header[RAND_HEAD_LEN-2]; /* random header */\n    static unsigned calls = 0;   /* ensure different random header each time */\n\n    if (bufSize<RAND_HEAD_LEN)\n      return 0;\n\n    /* First generate RAND_HEAD_LEN-2 random bytes. We encrypt the\n     * output of rand() to get less predictability, since rand() is\n     * often poorly implemented.\n     */\n    if (++calls == 1)\n    {\n        srand((unsigned)(time(NULL) ^ ZCR_SEED2));\n    }\n    init_keys(passwd, pkeys, pcrc_32_tab);\n    for (n = 0; n < RAND_HEAD_LEN-2; n++)\n    {\n        c = (rand() >> 7) & 0xff;\n        header[n] = (unsigned char)zencode(pkeys, pcrc_32_tab, c, t);\n    }\n    /* Encrypt random header (last two bytes is high word of crc) */\n    init_keys(passwd, pkeys, pcrc_32_tab);\n    for (n = 0; n < RAND_HEAD_LEN-2; n++)\n    {\n        buf[n] = (unsigned char)zencode(pkeys, pcrc_32_tab, header[n], t);\n    }\n    buf[n++] = (unsigned char)zencode(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 16) & 0xff, t);\n    buf[n++] = (unsigned char)zencode(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 24) & 0xff, t);\n    return n;\n}\n\n#endif\n"
  },
  {
    "path": "Libraries/Core/iOS/Headers/minizip/ioapi.h",
    "content": "/* ioapi.h -- IO base function header for compress/uncompress .zip\n   part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )\n\n         Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html )\n\n         Modifications for Zip64 support\n         Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )\n\n         For more info read MiniZip_info.txt\n\n         Changes\n\n    Oct-2009 - Defined ZPOS64_T to fpos_t on windows and u_int64_t on linux. (might need to find a better why for this)\n    Oct-2009 - Change to fseeko64, ftello64 and fopen64 so large files would work on linux.\n               More if/def section may be needed to support other platforms\n    Oct-2009 - Defined fxxxx64 calls to normal fopen/ftell/fseek so they would compile on windows.\n                          (but you should use iowin32.c for windows instead)\n\n*/\n\n#ifndef _ZLIBIOAPI64_H\n#define _ZLIBIOAPI64_H\n\n#if (!defined(_WIN32)) && (!defined(WIN32))\n\n  // Linux needs this to support file operation on files larger then 4+GB\n  // But might need better if/def to select just the platforms that needs them.\n\n        #ifndef __USE_FILE_OFFSET64\n                #define __USE_FILE_OFFSET64\n        #endif\n        #ifndef __USE_LARGEFILE64\n                #define __USE_LARGEFILE64\n        #endif\n        #ifndef _LARGEFILE64_SOURCE\n                #define _LARGEFILE64_SOURCE\n        #endif\n        #ifndef _FILE_OFFSET_BIT\n                #define _FILE_OFFSET_BIT 64\n        #endif\n#endif\n\n#include <stdio.h>\n#include <stdlib.h>\n#include \"zlib.h\"\n\n#if defined(USE_FILE32API)\n#define fopen64 fopen\n#define ftello64 ftell\n#define fseeko64 fseek\n#else\n#ifdef _MSC_VER\n #define fopen64 fopen\n #if (_MSC_VER >= 1400) && (!(defined(NO_MSCVER_FILE64_FUNC)))\n  #define ftello64 _ftelli64\n  #define fseeko64 _fseeki64\n #else // old MSC\n  #define ftello64 ftell\n  #define fseeko64 fseek\n #endif\n#endif\n#endif\n\n/*\n#ifndef ZPOS64_T\n  #ifdef _WIN32\n                #define ZPOS64_T fpos_t\n  #else\n    #include <stdint.h>\n    #define ZPOS64_T uint64_t\n  #endif\n#endif\n*/\n\n#ifdef HAVE_MINIZIP64_CONF_H\n#include \"mz64conf.h\"\n#endif\n\n/* a type choosen by DEFINE */\n#ifdef HAVE_64BIT_INT_CUSTOM\ntypedef  64BIT_INT_CUSTOM_TYPE ZPOS64_T;\n#else\n#ifdef HAS_STDINT_H\n#include \"stdint.h\"\ntypedef uint64_t ZPOS64_T;\n#else\n\n\n#if defined(_MSC_VER) || defined(__BORLANDC__)\ntypedef unsigned __int64 ZPOS64_T;\n#else\ntypedef unsigned long long int ZPOS64_T;\n#endif\n#endif\n#endif\n\n\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n\n#define ZLIB_FILEFUNC_SEEK_CUR (1)\n#define ZLIB_FILEFUNC_SEEK_END (2)\n#define ZLIB_FILEFUNC_SEEK_SET (0)\n\n#define ZLIB_FILEFUNC_MODE_READ      (1)\n#define ZLIB_FILEFUNC_MODE_WRITE     (2)\n#define ZLIB_FILEFUNC_MODE_READWRITEFILTER (3)\n\n#define ZLIB_FILEFUNC_MODE_EXISTING (4)\n#define ZLIB_FILEFUNC_MODE_CREATE   (8)\n\n\n#ifndef ZCALLBACK\n #if (defined(WIN32) || defined(_WIN32) || defined (WINDOWS) || defined (_WINDOWS)) && defined(CALLBACK) && defined (USEWINDOWS_CALLBACK)\n   #define ZCALLBACK CALLBACK\n #else\n   #define ZCALLBACK\n #endif\n#endif\n\n\n\n\ntypedef voidpf   (ZCALLBACK *open_file_func)      OF((voidpf opaque, const char* filename, int mode));\ntypedef uLong    (ZCALLBACK *read_file_func)      OF((voidpf opaque, voidpf stream, void* buf, uLong size));\ntypedef uLong    (ZCALLBACK *write_file_func)     OF((voidpf opaque, voidpf stream, const void* buf, uLong size));\ntypedef int      (ZCALLBACK *close_file_func)     OF((voidpf opaque, voidpf stream));\ntypedef int      (ZCALLBACK *testerror_file_func) OF((voidpf opaque, voidpf stream));\n\ntypedef long     (ZCALLBACK *tell_file_func)      OF((voidpf opaque, voidpf stream));\ntypedef long     (ZCALLBACK *seek_file_func)      OF((voidpf opaque, voidpf stream, uLong offset, int origin));\n\n\n/* here is the \"old\" 32 bits structure structure */\ntypedef struct zlib_filefunc_def_s\n{\n    open_file_func      zopen_file;\n    read_file_func      zread_file;\n    write_file_func     zwrite_file;\n    tell_file_func      ztell_file;\n    seek_file_func      zseek_file;\n    close_file_func     zclose_file;\n    testerror_file_func zerror_file;\n    voidpf              opaque;\n} zlib_filefunc_def;\n\ntypedef ZPOS64_T (ZCALLBACK *tell64_file_func)    OF((voidpf opaque, voidpf stream));\ntypedef long     (ZCALLBACK *seek64_file_func)    OF((voidpf opaque, voidpf stream, ZPOS64_T offset, int origin));\ntypedef voidpf   (ZCALLBACK *open64_file_func)    OF((voidpf opaque, const void* filename, int mode));\n\ntypedef struct zlib_filefunc64_def_s\n{\n    open64_file_func    zopen64_file;\n    read_file_func      zread_file;\n    write_file_func     zwrite_file;\n    tell64_file_func    ztell64_file;\n    seek64_file_func    zseek64_file;\n    close_file_func     zclose_file;\n    testerror_file_func zerror_file;\n    voidpf              opaque;\n} zlib_filefunc64_def;\n\nvoid fill_fopen64_filefunc OF((zlib_filefunc64_def* pzlib_filefunc_def));\nvoid fill_fopen_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def));\n\n/* now internal definition, only for zip.c and unzip.h */\ntypedef struct zlib_filefunc64_32_def_s\n{\n    zlib_filefunc64_def zfile_func64;\n    open_file_func      zopen32_file;\n    tell_file_func      ztell32_file;\n    seek_file_func      zseek32_file;\n} zlib_filefunc64_32_def;\n\n\n#define ZREAD64(filefunc,filestream,buf,size)     ((*((filefunc).zfile_func64.zread_file))   ((filefunc).zfile_func64.opaque,filestream,buf,size))\n#define ZWRITE64(filefunc,filestream,buf,size)    ((*((filefunc).zfile_func64.zwrite_file))  ((filefunc).zfile_func64.opaque,filestream,buf,size))\n//#define ZTELL64(filefunc,filestream)            ((*((filefunc).ztell64_file)) ((filefunc).opaque,filestream))\n//#define ZSEEK64(filefunc,filestream,pos,mode)   ((*((filefunc).zseek64_file)) ((filefunc).opaque,filestream,pos,mode))\n#define ZCLOSE64(filefunc,filestream)             ((*((filefunc).zfile_func64.zclose_file))  ((filefunc).zfile_func64.opaque,filestream))\n#define ZERROR64(filefunc,filestream)             ((*((filefunc).zfile_func64.zerror_file))  ((filefunc).zfile_func64.opaque,filestream))\n\nvoidpf call_zopen64 OF((const zlib_filefunc64_32_def* pfilefunc,const void*filename,int mode));\nlong    call_zseek64 OF((const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZPOS64_T offset, int origin));\nZPOS64_T call_ztell64 OF((const zlib_filefunc64_32_def* pfilefunc,voidpf filestream));\n\nvoid    fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filefunc64_32,const zlib_filefunc_def* p_filefunc32);\n\n#define ZOPEN64(filefunc,filename,mode)         (call_zopen64((&(filefunc)),(filename),(mode)))\n#define ZTELL64(filefunc,filestream)            (call_ztell64((&(filefunc)),(filestream)))\n#define ZSEEK64(filefunc,filestream,pos,mode)   (call_zseek64((&(filefunc)),(filestream),(pos),(mode)))\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "Libraries/Core/iOS/Headers/minizip/mztools.h",
    "content": "/*\n  Additional tools for Minizip\n  Code: Xavier Roche '2004\n  License: Same as ZLIB (www.gzip.org)\n*/\n\n#ifndef _zip_tools_H\n#define _zip_tools_H\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#ifndef _ZLIB_H\n#include \"zlib.h\"\n#endif\n\n#include \"unzip.h\"\n\n/* Repair a ZIP file (missing central directory)\n   file: file to recover\n   fileOut: output file after recovery\n   fileOutTmp: temporary file name used for recovery\n*/\nextern int ZEXPORT unzRepair(const char* file,\n                             const char* fileOut,\n                             const char* fileOutTmp,\n                             uLong* nRecovered,\n                             uLong* bytesRecovered);\n\n#endif\n"
  },
  {
    "path": "Libraries/Core/iOS/Headers/minizip/unzip.h",
    "content": "/* unzip.h -- IO for uncompress .zip files using zlib\n   Version 1.1, February 14h, 2010\n   part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )\n\n         Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html )\n\n         Modifications of Unzip for Zip64\n         Copyright (C) 2007-2008 Even Rouault\n\n         Modifications for Zip64 support on both zip and unzip\n         Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )\n\n         For more info read MiniZip_info.txt\n\n         ---------------------------------------------------------------------------------\n\n        Condition of use and distribution are the same than zlib :\n\n  This software is provided 'as-is', without any express or implied\n  warranty.  In no event will the authors be held liable for any damages\n  arising from the use of this software.\n\n  Permission is granted to anyone to use this software for any purpose,\n  including commercial applications, and to alter it and redistribute it\n  freely, subject to the following restrictions:\n\n  1. The origin of this software must not be misrepresented; you must not\n     claim that you wrote the original software. If you use this software\n     in a product, an acknowledgment in the product documentation would be\n     appreciated but is not required.\n  2. Altered source versions must be plainly marked as such, and must not be\n     misrepresented as being the original software.\n  3. This notice may not be removed or altered from any source distribution.\n\n  ---------------------------------------------------------------------------------\n\n        Changes\n\n        See header of unzip64.c\n\n*/\n\n#ifndef _unz64_H\n#define _unz64_H\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#ifndef _ZLIB_H\n#include \"zlib.h\"\n#endif\n\n#ifndef  _ZLIBIOAPI_H\n#include \"ioapi.h\"\n#endif\n\n#ifdef HAVE_BZIP2\n#include \"bzlib.h\"\n#endif\n\n#define Z_BZIP2ED 12\n\n#if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP)\n/* like the STRICT of WIN32, we define a pointer that cannot be converted\n    from (void*) without cast */\ntypedef struct TagunzFile__ { int unused; } unzFile__;\ntypedef unzFile__ *unzFile;\n#else\ntypedef voidp unzFile;\n#endif\n\n\n#define UNZ_OK                          (0)\n#define UNZ_END_OF_LIST_OF_FILE         (-100)\n#define UNZ_ERRNO                       (Z_ERRNO)\n#define UNZ_EOF                         (0)\n#define UNZ_PARAMERROR                  (-102)\n#define UNZ_BADZIPFILE                  (-103)\n#define UNZ_INTERNALERROR               (-104)\n#define UNZ_CRCERROR                    (-105)\n\n/* tm_unz contain date/time info */\ntypedef struct tm_unz_s\n{\n    uInt tm_sec;            /* seconds after the minute - [0,59] */\n    uInt tm_min;            /* minutes after the hour - [0,59] */\n    uInt tm_hour;           /* hours since midnight - [0,23] */\n    uInt tm_mday;           /* day of the month - [1,31] */\n    uInt tm_mon;            /* months since January - [0,11] */\n    uInt tm_year;           /* years - [1980..2044] */\n} tm_unz;\n\n/* unz_global_info structure contain global data about the ZIPfile\n   These data comes from the end of central dir */\ntypedef struct unz_global_info64_s\n{\n    ZPOS64_T number_entry;         /* total number of entries in\n                                     the central dir on this disk */\n    uLong size_comment;         /* size of the global comment of the zipfile */\n} unz_global_info64;\n\ntypedef struct unz_global_info_s\n{\n    uLong number_entry;         /* total number of entries in\n                                     the central dir on this disk */\n    uLong size_comment;         /* size of the global comment of the zipfile */\n} unz_global_info;\n\n/* unz_file_info contain information about a file in the zipfile */\ntypedef struct unz_file_info64_s\n{\n    uLong version;              /* version made by                 2 bytes */\n    uLong version_needed;       /* version needed to extract       2 bytes */\n    uLong flag;                 /* general purpose bit flag        2 bytes */\n    uLong compression_method;   /* compression method              2 bytes */\n    uLong dosDate;              /* last mod file date in Dos fmt   4 bytes */\n    uLong crc;                  /* crc-32                          4 bytes */\n    ZPOS64_T compressed_size;   /* compressed size                 8 bytes */\n    ZPOS64_T uncompressed_size; /* uncompressed size               8 bytes */\n    uLong size_filename;        /* filename length                 2 bytes */\n    uLong size_file_extra;      /* extra field length              2 bytes */\n    uLong size_file_comment;    /* file comment length             2 bytes */\n\n    uLong disk_num_start;       /* disk number start               2 bytes */\n    uLong internal_fa;          /* internal file attributes        2 bytes */\n    uLong external_fa;          /* external file attributes        4 bytes */\n\n    tm_unz tmu_date;\n} unz_file_info64;\n\ntypedef struct unz_file_info_s\n{\n    uLong version;              /* version made by                 2 bytes */\n    uLong version_needed;       /* version needed to extract       2 bytes */\n    uLong flag;                 /* general purpose bit flag        2 bytes */\n    uLong compression_method;   /* compression method              2 bytes */\n    uLong dosDate;              /* last mod file date in Dos fmt   4 bytes */\n    uLong crc;                  /* crc-32                          4 bytes */\n    uLong compressed_size;      /* compressed size                 4 bytes */\n    uLong uncompressed_size;    /* uncompressed size               4 bytes */\n    uLong size_filename;        /* filename length                 2 bytes */\n    uLong size_file_extra;      /* extra field length              2 bytes */\n    uLong size_file_comment;    /* file comment length             2 bytes */\n\n    uLong disk_num_start;       /* disk number start               2 bytes */\n    uLong internal_fa;          /* internal file attributes        2 bytes */\n    uLong external_fa;          /* external file attributes        4 bytes */\n\n    tm_unz tmu_date;\n} unz_file_info;\n\nextern int ZEXPORT unzStringFileNameCompare OF ((const char* fileName1,\n                                                 const char* fileName2,\n                                                 int iCaseSensitivity));\n/*\n   Compare two filename (fileName1,fileName2).\n   If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp)\n   If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi\n                                or strcasecmp)\n   If iCaseSenisivity = 0, case sensitivity is defaut of your operating system\n    (like 1 on Unix, 2 on Windows)\n*/\n\n\nextern unzFile ZEXPORT unzOpen OF((const char *path));\nextern unzFile ZEXPORT unzOpen64 OF((const void *path));\n/*\n  Open a Zip file. path contain the full pathname (by example,\n     on a Windows XP computer \"c:\\\\zlib\\\\zlib113.zip\" or on an Unix computer\n     \"zlib/zlib113.zip\".\n     If the zipfile cannot be opened (file don't exist or in not valid), the\n       return value is NULL.\n     Else, the return value is a unzFile Handle, usable with other function\n       of this unzip package.\n     the \"64\" function take a const void* pointer, because the path is just the\n       value passed to the open64_file_func callback.\n     Under Windows, if UNICODE is defined, using fill_fopen64_filefunc, the path\n       is a pointer to a wide unicode string (LPCTSTR is LPCWSTR), so const char*\n       does not describe the reality\n*/\n\n\nextern unzFile ZEXPORT unzOpen2 OF((const char *path,\n                                    zlib_filefunc_def* pzlib_filefunc_def));\n/*\n   Open a Zip file, like unzOpen, but provide a set of file low level API\n      for read/write the zip file (see ioapi.h)\n*/\n\nextern unzFile ZEXPORT unzOpen2_64 OF((const void *path,\n                                    zlib_filefunc64_def* pzlib_filefunc_def));\n/*\n   Open a Zip file, like unz64Open, but provide a set of file low level API\n      for read/write the zip file (see ioapi.h)\n*/\n\nextern int ZEXPORT unzClose OF((unzFile file));\n/*\n  Close a ZipFile opened with unzipOpen.\n  If there is files inside the .Zip opened with unzOpenCurrentFile (see later),\n    these files MUST be closed with unzipCloseCurrentFile before call unzipClose.\n  return UNZ_OK if there is no problem. */\n\nextern int ZEXPORT unzGetGlobalInfo OF((unzFile file,\n                                        unz_global_info *pglobal_info));\n\nextern int ZEXPORT unzGetGlobalInfo64 OF((unzFile file,\n                                        unz_global_info64 *pglobal_info));\n/*\n  Write info about the ZipFile in the *pglobal_info structure.\n  No preparation of the structure is needed\n  return UNZ_OK if there is no problem. */\n\n\nextern int ZEXPORT unzGetGlobalComment OF((unzFile file,\n                                           char *szComment,\n                                           uLong uSizeBuf));\n/*\n  Get the global comment string of the ZipFile, in the szComment buffer.\n  uSizeBuf is the size of the szComment buffer.\n  return the number of byte copied or an error code <0\n*/\n\n\n/***************************************************************************/\n/* Unzip package allow you browse the directory of the zipfile */\n\nextern int ZEXPORT unzGoToFirstFile OF((unzFile file));\n/*\n  Set the current file of the zipfile to the first file.\n  return UNZ_OK if there is no problem\n*/\n\nextern int ZEXPORT unzGoToNextFile OF((unzFile file));\n/*\n  Set the current file of the zipfile to the next file.\n  return UNZ_OK if there is no problem\n  return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest.\n*/\n\nextern int ZEXPORT unzLocateFile OF((unzFile file,\n                     const char *szFileName,\n                     int iCaseSensitivity));\n/*\n  Try locate the file szFileName in the zipfile.\n  For the iCaseSensitivity signification, see unzStringFileNameCompare\n\n  return value :\n  UNZ_OK if the file is found. It becomes the current file.\n  UNZ_END_OF_LIST_OF_FILE if the file is not found\n*/\n\n\n/* ****************************************** */\n/* Ryan supplied functions */\n/* unz_file_info contain information about a file in the zipfile */\ntypedef struct unz_file_pos_s\n{\n    uLong pos_in_zip_directory;   /* offset in zip file directory */\n    uLong num_of_file;            /* # of file */\n} unz_file_pos;\n\nextern int ZEXPORT unzGetFilePos(\n    unzFile file,\n    unz_file_pos* file_pos);\n\nextern int ZEXPORT unzGoToFilePos(\n    unzFile file,\n    unz_file_pos* file_pos);\n\ntypedef struct unz64_file_pos_s\n{\n    ZPOS64_T pos_in_zip_directory;   /* offset in zip file directory */\n    ZPOS64_T num_of_file;            /* # of file */\n} unz64_file_pos;\n\nextern int ZEXPORT unzGetFilePos64(\n    unzFile file,\n    unz64_file_pos* file_pos);\n\nextern int ZEXPORT unzGoToFilePos64(\n    unzFile file,\n    const unz64_file_pos* file_pos);\n\n/* ****************************************** */\n\nextern int ZEXPORT unzGetCurrentFileInfo64 OF((unzFile file,\n                         unz_file_info64 *pfile_info,\n                         char *szFileName,\n                         uLong fileNameBufferSize,\n                         void *extraField,\n                         uLong extraFieldBufferSize,\n                         char *szComment,\n                         uLong commentBufferSize));\n\nextern int ZEXPORT unzGetCurrentFileInfo OF((unzFile file,\n                         unz_file_info *pfile_info,\n                         char *szFileName,\n                         uLong fileNameBufferSize,\n                         void *extraField,\n                         uLong extraFieldBufferSize,\n                         char *szComment,\n                         uLong commentBufferSize));\n/*\n  Get Info about the current file\n  if pfile_info!=NULL, the *pfile_info structure will contain somes info about\n        the current file\n  if szFileName!=NULL, the filemane string will be copied in szFileName\n            (fileNameBufferSize is the size of the buffer)\n  if extraField!=NULL, the extra field information will be copied in extraField\n            (extraFieldBufferSize is the size of the buffer).\n            This is the Central-header version of the extra field\n  if szComment!=NULL, the comment string of the file will be copied in szComment\n            (commentBufferSize is the size of the buffer)\n*/\n\n\n/** Addition for GDAL : START */\n\nextern ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64 OF((unzFile file));\n\n/** Addition for GDAL : END */\n\n\n/***************************************************************************/\n/* for reading the content of the current zipfile, you can open it, read data\n   from it, and close it (you can close it before reading all the file)\n   */\n\nextern int ZEXPORT unzOpenCurrentFile OF((unzFile file));\n/*\n  Open for reading data the current file in the zipfile.\n  If there is no error, the return value is UNZ_OK.\n*/\n\nextern int ZEXPORT unzOpenCurrentFilePassword OF((unzFile file,\n                                                  const char* password));\n/*\n  Open for reading data the current file in the zipfile.\n  password is a crypting password\n  If there is no error, the return value is UNZ_OK.\n*/\n\nextern int ZEXPORT unzOpenCurrentFile2 OF((unzFile file,\n                                           int* method,\n                                           int* level,\n                                           int raw));\n/*\n  Same than unzOpenCurrentFile, but open for read raw the file (not uncompress)\n    if raw==1\n  *method will receive method of compression, *level will receive level of\n     compression\n  note : you can set level parameter as NULL (if you did not want known level,\n         but you CANNOT set method parameter as NULL\n*/\n\nextern int ZEXPORT unzOpenCurrentFile3 OF((unzFile file,\n                                           int* method,\n                                           int* level,\n                                           int raw,\n                                           const char* password));\n/*\n  Same than unzOpenCurrentFile, but open for read raw the file (not uncompress)\n    if raw==1\n  *method will receive method of compression, *level will receive level of\n     compression\n  note : you can set level parameter as NULL (if you did not want known level,\n         but you CANNOT set method parameter as NULL\n*/\n\n\nextern int ZEXPORT unzCloseCurrentFile OF((unzFile file));\n/*\n  Close the file in zip opened with unzOpenCurrentFile\n  Return UNZ_CRCERROR if all the file was read but the CRC is not good\n*/\n\nextern int ZEXPORT unzReadCurrentFile OF((unzFile file,\n                      voidp buf,\n                      unsigned len));\n/*\n  Read bytes from the current file (opened by unzOpenCurrentFile)\n  buf contain buffer where data must be copied\n  len the size of buf.\n\n  return the number of byte copied if somes bytes are copied\n  return 0 if the end of file was reached\n  return <0 with error code if there is an error\n    (UNZ_ERRNO for IO error, or zLib error for uncompress error)\n*/\n\nextern z_off_t ZEXPORT unztell OF((unzFile file));\n\nextern ZPOS64_T ZEXPORT unztell64 OF((unzFile file));\n/*\n  Give the current position in uncompressed data\n*/\n\nextern int ZEXPORT unzeof OF((unzFile file));\n/*\n  return 1 if the end of file was reached, 0 elsewhere\n*/\n\nextern int ZEXPORT unzGetLocalExtrafield OF((unzFile file,\n                                             voidp buf,\n                                             unsigned len));\n/*\n  Read extra field from the current file (opened by unzOpenCurrentFile)\n  This is the local-header version of the extra field (sometimes, there is\n    more info in the local-header version than in the central-header)\n\n  if buf==NULL, it return the size of the local extra field\n\n  if buf!=NULL, len is the size of the buffer, the extra header is copied in\n    buf.\n  the return value is the number of bytes copied in buf, or (if <0)\n    the error code\n*/\n\n/***************************************************************************/\n\n/* Get the current file offset */\nextern ZPOS64_T ZEXPORT unzGetOffset64 (unzFile file);\nextern uLong ZEXPORT unzGetOffset (unzFile file);\n\n/* Set the current file offset */\nextern int ZEXPORT unzSetOffset64 (unzFile file, ZPOS64_T pos);\nextern int ZEXPORT unzSetOffset (unzFile file, uLong pos);\n\n\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* _unz64_H */\n"
  },
  {
    "path": "Libraries/Core/iOS/Headers/minizip/zip.h",
    "content": "/* zip.h -- IO on .zip files using zlib\n   Version 1.1, February 14h, 2010\n   part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )\n\n         Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html )\n\n         Modifications for Zip64 support\n         Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )\n\n         For more info read MiniZip_info.txt\n\n         ---------------------------------------------------------------------------\n\n   Condition of use and distribution are the same than zlib :\n\n  This software is provided 'as-is', without any express or implied\n  warranty.  In no event will the authors be held liable for any damages\n  arising from the use of this software.\n\n  Permission is granted to anyone to use this software for any purpose,\n  including commercial applications, and to alter it and redistribute it\n  freely, subject to the following restrictions:\n\n  1. The origin of this software must not be misrepresented; you must not\n     claim that you wrote the original software. If you use this software\n     in a product, an acknowledgment in the product documentation would be\n     appreciated but is not required.\n  2. Altered source versions must be plainly marked as such, and must not be\n     misrepresented as being the original software.\n  3. This notice may not be removed or altered from any source distribution.\n\n        ---------------------------------------------------------------------------\n\n        Changes\n\n        See header of zip.h\n\n*/\n\n#ifndef _zip12_H\n#define _zip12_H\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n//#define HAVE_BZIP2\n\n#ifndef _ZLIB_H\n#include \"zlib.h\"\n#endif\n\n#ifndef _ZLIBIOAPI_H\n#include \"ioapi.h\"\n#endif\n\n#ifdef HAVE_BZIP2\n#include \"bzlib.h\"\n#endif\n\n#define Z_BZIP2ED 12\n\n#if defined(STRICTZIP) || defined(STRICTZIPUNZIP)\n/* like the STRICT of WIN32, we define a pointer that cannot be converted\n    from (void*) without cast */\ntypedef struct TagzipFile__ { int unused; } zipFile__;\ntypedef zipFile__ *zipFile;\n#else\ntypedef voidp zipFile;\n#endif\n\n#define ZIP_OK                          (0)\n#define ZIP_EOF                         (0)\n#define ZIP_ERRNO                       (Z_ERRNO)\n#define ZIP_PARAMERROR                  (-102)\n#define ZIP_BADZIPFILE                  (-103)\n#define ZIP_INTERNALERROR               (-104)\n\n#ifndef DEF_MEM_LEVEL\n#  if MAX_MEM_LEVEL >= 8\n#    define DEF_MEM_LEVEL 8\n#  else\n#    define DEF_MEM_LEVEL  MAX_MEM_LEVEL\n#  endif\n#endif\n/* default memLevel */\n\n/* tm_zip contain date/time info */\ntypedef struct tm_zip_s\n{\n    uInt tm_sec;            /* seconds after the minute - [0,59] */\n    uInt tm_min;            /* minutes after the hour - [0,59] */\n    uInt tm_hour;           /* hours since midnight - [0,23] */\n    uInt tm_mday;           /* day of the month - [1,31] */\n    uInt tm_mon;            /* months since January - [0,11] */\n    uInt tm_year;           /* years - [1980..2044] */\n} tm_zip;\n\ntypedef struct\n{\n    tm_zip      tmz_date;       /* date in understandable format           */\n    uLong       dosDate;       /* if dos_date == 0, tmu_date is used      */\n/*    uLong       flag;        */   /* general purpose bit flag        2 bytes */\n\n    uLong       internal_fa;    /* internal file attributes        2 bytes */\n    uLong       external_fa;    /* external file attributes        4 bytes */\n} zip_fileinfo;\n\ntypedef const char* zipcharpc;\n\n\n#define APPEND_STATUS_CREATE        (0)\n#define APPEND_STATUS_CREATEAFTER   (1)\n#define APPEND_STATUS_ADDINZIP      (2)\n\nextern zipFile ZEXPORT zipOpen OF((const char *pathname, int append));\nextern zipFile ZEXPORT zipOpen64 OF((const void *pathname, int append));\n/*\n  Create a zipfile.\n     pathname contain on Windows XP a filename like \"c:\\\\zlib\\\\zlib113.zip\" or on\n       an Unix computer \"zlib/zlib113.zip\".\n     if the file pathname exist and append==APPEND_STATUS_CREATEAFTER, the zip\n       will be created at the end of the file.\n         (useful if the file contain a self extractor code)\n     if the file pathname exist and append==APPEND_STATUS_ADDINZIP, we will\n       add files in existing zip (be sure you don't add file that doesn't exist)\n     If the zipfile cannot be opened, the return value is NULL.\n     Else, the return value is a zipFile Handle, usable with other function\n       of this zip package.\n*/\n\n/* Note : there is no delete function into a zipfile.\n   If you want delete file into a zipfile, you must open a zipfile, and create another\n   Of couse, you can use RAW reading and writing to copy the file you did not want delte\n*/\n\nextern zipFile ZEXPORT zipOpen2 OF((const char *pathname,\n                                   int append,\n                                   zipcharpc* globalcomment,\n                                   zlib_filefunc_def* pzlib_filefunc_def));\n\nextern zipFile ZEXPORT zipOpen2_64 OF((const void *pathname,\n                                   int append,\n                                   zipcharpc* globalcomment,\n                                   zlib_filefunc64_def* pzlib_filefunc_def));\n\nextern int ZEXPORT zipOpenNewFileInZip OF((zipFile file,\n                       const char* filename,\n                       const zip_fileinfo* zipfi,\n                       const void* extrafield_local,\n                       uInt size_extrafield_local,\n                       const void* extrafield_global,\n                       uInt size_extrafield_global,\n                       const char* comment,\n                       int method,\n                       int level));\n\nextern int ZEXPORT zipOpenNewFileInZip64 OF((zipFile file,\n                       const char* filename,\n                       const zip_fileinfo* zipfi,\n                       const void* extrafield_local,\n                       uInt size_extrafield_local,\n                       const void* extrafield_global,\n                       uInt size_extrafield_global,\n                       const char* comment,\n                       int method,\n                       int level,\n                       int zip64));\n\n/*\n  Open a file in the ZIP for writing.\n  filename : the filename in zip (if NULL, '-' without quote will be used\n  *zipfi contain supplemental information\n  if extrafield_local!=NULL and size_extrafield_local>0, extrafield_local\n    contains the extrafield data the the local header\n  if extrafield_global!=NULL and size_extrafield_global>0, extrafield_global\n    contains the extrafield data the the local header\n  if comment != NULL, comment contain the comment string\n  method contain the compression method (0 for store, Z_DEFLATED for deflate)\n  level contain the level of compression (can be Z_DEFAULT_COMPRESSION)\n  zip64 is set to 1 if a zip64 extended information block should be added to the local file header.\n                    this MUST be '1' if the uncompressed size is >= 0xffffffff.\n\n*/\n\n\nextern int ZEXPORT zipOpenNewFileInZip2 OF((zipFile file,\n                                            const char* filename,\n                                            const zip_fileinfo* zipfi,\n                                            const void* extrafield_local,\n                                            uInt size_extrafield_local,\n                                            const void* extrafield_global,\n                                            uInt size_extrafield_global,\n                                            const char* comment,\n                                            int method,\n                                            int level,\n                                            int raw));\n\n\nextern int ZEXPORT zipOpenNewFileInZip2_64 OF((zipFile file,\n                                            const char* filename,\n                                            const zip_fileinfo* zipfi,\n                                            const void* extrafield_local,\n                                            uInt size_extrafield_local,\n                                            const void* extrafield_global,\n                                            uInt size_extrafield_global,\n                                            const char* comment,\n                                            int method,\n                                            int level,\n                                            int raw,\n                                            int zip64));\n/*\n  Same than zipOpenNewFileInZip, except if raw=1, we write raw file\n */\n\nextern int ZEXPORT zipOpenNewFileInZip3 OF((zipFile file,\n                                            const char* filename,\n                                            const zip_fileinfo* zipfi,\n                                            const void* extrafield_local,\n                                            uInt size_extrafield_local,\n                                            const void* extrafield_global,\n                                            uInt size_extrafield_global,\n                                            const char* comment,\n                                            int method,\n                                            int level,\n                                            int raw,\n                                            int windowBits,\n                                            int memLevel,\n                                            int strategy,\n                                            const char* password,\n                                            uLong crcForCrypting));\n\nextern int ZEXPORT zipOpenNewFileInZip3_64 OF((zipFile file,\n                                            const char* filename,\n                                            const zip_fileinfo* zipfi,\n                                            const void* extrafield_local,\n                                            uInt size_extrafield_local,\n                                            const void* extrafield_global,\n                                            uInt size_extrafield_global,\n                                            const char* comment,\n                                            int method,\n                                            int level,\n                                            int raw,\n                                            int windowBits,\n                                            int memLevel,\n                                            int strategy,\n                                            const char* password,\n                                            uLong crcForCrypting,\n                                            int zip64\n                                            ));\n\n/*\n  Same than zipOpenNewFileInZip2, except\n    windowBits,memLevel,,strategy : see parameter strategy in deflateInit2\n    password : crypting password (NULL for no crypting)\n    crcForCrypting : crc of file to compress (needed for crypting)\n */\n\nextern int ZEXPORT zipOpenNewFileInZip4 OF((zipFile file,\n                                            const char* filename,\n                                            const zip_fileinfo* zipfi,\n                                            const void* extrafield_local,\n                                            uInt size_extrafield_local,\n                                            const void* extrafield_global,\n                                            uInt size_extrafield_global,\n                                            const char* comment,\n                                            int method,\n                                            int level,\n                                            int raw,\n                                            int windowBits,\n                                            int memLevel,\n                                            int strategy,\n                                            const char* password,\n                                            uLong crcForCrypting,\n                                            uLong versionMadeBy,\n                                            uLong flagBase\n                                            ));\n\n\nextern int ZEXPORT zipOpenNewFileInZip4_64 OF((zipFile file,\n                                            const char* filename,\n                                            const zip_fileinfo* zipfi,\n                                            const void* extrafield_local,\n                                            uInt size_extrafield_local,\n                                            const void* extrafield_global,\n                                            uInt size_extrafield_global,\n                                            const char* comment,\n                                            int method,\n                                            int level,\n                                            int raw,\n                                            int windowBits,\n                                            int memLevel,\n                                            int strategy,\n                                            const char* password,\n                                            uLong crcForCrypting,\n                                            uLong versionMadeBy,\n                                            uLong flagBase,\n                                            int zip64\n                                            ));\n/*\n  Same than zipOpenNewFileInZip4, except\n    versionMadeBy : value for Version made by field\n    flag : value for flag field (compression level info will be added)\n */\n\n\nextern int ZEXPORT zipWriteInFileInZip OF((zipFile file,\n                       const void* buf,\n                       unsigned len));\n/*\n  Write data in the zipfile\n*/\n\nextern int ZEXPORT zipCloseFileInZip OF((zipFile file));\n/*\n  Close the current file in the zipfile\n*/\n\nextern int ZEXPORT zipCloseFileInZipRaw OF((zipFile file,\n                                            uLong uncompressed_size,\n                                            uLong crc32));\n\nextern int ZEXPORT zipCloseFileInZipRaw64 OF((zipFile file,\n                                            ZPOS64_T uncompressed_size,\n                                            uLong crc32));\n\n/*\n  Close the current file in the zipfile, for file opened with\n    parameter raw=1 in zipOpenNewFileInZip2\n  uncompressed_size and crc32 are value for the uncompressed size\n*/\n\nextern int ZEXPORT zipClose OF((zipFile file,\n                const char* global_comment));\n/*\n  Close the zipfile\n*/\n\n\nextern int ZEXPORT zipRemoveExtraInfoBlock OF((char* pData, int* dataLen, short sHeader));\n/*\n  zipRemoveExtraInfoBlock -  Added by Mathias Svensson\n\n  Remove extra information block from a extra information data for the local file header or central directory header\n\n  It is needed to remove ZIP64 extra information blocks when before data is written if using RAW mode.\n\n  0x0001 is the signature header for the ZIP64 extra information blocks\n\n  usage.\n                        Remove ZIP64 Extra information from a central director extra field data\n              zipRemoveExtraInfoBlock(pCenDirExtraFieldData, &nCenDirExtraFieldDataLen, 0x0001);\n\n                        Remove ZIP64 Extra information from a Local File Header extra field data\n        zipRemoveExtraInfoBlock(pLocalHeaderExtraFieldData, &nLocalHeaderExtraFieldDataLen, 0x0001);\n*/\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* _zip64_H */\n"
  },
  {
    "path": "Libraries/Core/iOS/Headers/png/png.h",
    "content": "\n/* png.h - header file for PNG reference library\n *\n * libpng version 1.6.10 - March 6, 2014\n * Copyright (c) 1998-2014 Glenn Randers-Pehrson\n * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)\n * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)\n *\n * This code is released under the libpng license (See LICENSE, below)\n *\n * Authors and maintainers:\n *   libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat\n *   libpng versions 0.89c, June 1996, through 0.96, May 1997: Andreas Dilger\n *   libpng versions 0.97, January 1998, through 1.6.10 - March 6, 2014: Glenn\n *   See also \"Contributing Authors\", below.\n *\n * Note about libpng version numbers:\n *\n *   Due to various miscommunications, unforeseen code incompatibilities\n *   and occasional factors outside the authors' control, version numbering\n *   on the library has not always been consistent and straightforward.\n *   The following table summarizes matters since version 0.89c, which was\n *   the first widely used release:\n *\n *    source                 png.h  png.h  shared-lib\n *    version                string   int  version\n *    -------                ------ -----  ----------\n *    0.89c \"1.0 beta 3\"     0.89      89  1.0.89\n *    0.90  \"1.0 beta 4\"     0.90      90  0.90  [should have been 2.0.90]\n *    0.95  \"1.0 beta 5\"     0.95      95  0.95  [should have been 2.0.95]\n *    0.96  \"1.0 beta 6\"     0.96      96  0.96  [should have been 2.0.96]\n *    0.97b \"1.00.97 beta 7\" 1.00.97   97  1.0.1 [should have been 2.0.97]\n *    0.97c                  0.97      97  2.0.97\n *    0.98                   0.98      98  2.0.98\n *    0.99                   0.99      98  2.0.99\n *    0.99a-m                0.99      99  2.0.99\n *    1.00                   1.00     100  2.1.0 [100 should be 10000]\n *    1.0.0      (from here on, the   100  2.1.0 [100 should be 10000]\n *    1.0.1       png.h string is   10001  2.1.0\n *    1.0.1a-e    identical to the  10002  from here on, the shared library\n *    1.0.2       source version)   10002  is 2.V where V is the source code\n *    1.0.2a-b                      10003  version, except as noted.\n *    1.0.3                         10003\n *    1.0.3a-d                      10004\n *    1.0.4                         10004\n *    1.0.4a-f                      10005\n *    1.0.5 (+ 2 patches)           10005\n *    1.0.5a-d                      10006\n *    1.0.5e-r                      10100 (not source compatible)\n *    1.0.5s-v                      10006 (not binary compatible)\n *    1.0.6 (+ 3 patches)           10006 (still binary incompatible)\n *    1.0.6d-f                      10007 (still binary incompatible)\n *    1.0.6g                        10007\n *    1.0.6h                        10007  10.6h (testing xy.z so-numbering)\n *    1.0.6i                        10007  10.6i\n *    1.0.6j                        10007  2.1.0.6j (incompatible with 1.0.0)\n *    1.0.7beta11-14        DLLNUM  10007  2.1.0.7beta11-14 (binary compatible)\n *    1.0.7beta15-18           1    10007  2.1.0.7beta15-18 (binary compatible)\n *    1.0.7rc1-2               1    10007  2.1.0.7rc1-2 (binary compatible)\n *    1.0.7                    1    10007  (still compatible)\n *    1.0.8beta1-4             1    10008  2.1.0.8beta1-4\n *    1.0.8rc1                 1    10008  2.1.0.8rc1\n *    1.0.8                    1    10008  2.1.0.8\n *    1.0.9beta1-6             1    10009  2.1.0.9beta1-6\n *    1.0.9rc1                 1    10009  2.1.0.9rc1\n *    1.0.9beta7-10            1    10009  2.1.0.9beta7-10\n *    1.0.9rc2                 1    10009  2.1.0.9rc2\n *    1.0.9                    1    10009  2.1.0.9\n *    1.0.10beta1              1    10010  2.1.0.10beta1\n *    1.0.10rc1                1    10010  2.1.0.10rc1\n *    1.0.10                   1    10010  2.1.0.10\n *    1.0.11beta1-3            1    10011  2.1.0.11beta1-3\n *    1.0.11rc1                1    10011  2.1.0.11rc1\n *    1.0.11                   1    10011  2.1.0.11\n *    1.0.12beta1-2            2    10012  2.1.0.12beta1-2\n *    1.0.12rc1                2    10012  2.1.0.12rc1\n *    1.0.12                   2    10012  2.1.0.12\n *    1.1.0a-f                 -    10100  2.1.1.0a-f (branch abandoned)\n *    1.2.0beta1-2             2    10200  2.1.2.0beta1-2\n *    1.2.0beta3-5             3    10200  3.1.2.0beta3-5\n *    1.2.0rc1                 3    10200  3.1.2.0rc1\n *    1.2.0                    3    10200  3.1.2.0\n *    1.2.1beta1-4             3    10201  3.1.2.1beta1-4\n *    1.2.1rc1-2               3    10201  3.1.2.1rc1-2\n *    1.2.1                    3    10201  3.1.2.1\n *    1.2.2beta1-6            12    10202  12.so.0.1.2.2beta1-6\n *    1.0.13beta1             10    10013  10.so.0.1.0.13beta1\n *    1.0.13rc1               10    10013  10.so.0.1.0.13rc1\n *    1.2.2rc1                12    10202  12.so.0.1.2.2rc1\n *    1.0.13                  10    10013  10.so.0.1.0.13\n *    1.2.2                   12    10202  12.so.0.1.2.2\n *    1.2.3rc1-6              12    10203  12.so.0.1.2.3rc1-6\n *    1.2.3                   12    10203  12.so.0.1.2.3\n *    1.2.4beta1-3            13    10204  12.so.0.1.2.4beta1-3\n *    1.0.14rc1               13    10014  10.so.0.1.0.14rc1\n *    1.2.4rc1                13    10204  12.so.0.1.2.4rc1\n *    1.0.14                  10    10014  10.so.0.1.0.14\n *    1.2.4                   13    10204  12.so.0.1.2.4\n *    1.2.5beta1-2            13    10205  12.so.0.1.2.5beta1-2\n *    1.0.15rc1-3             10    10015  10.so.0.1.0.15rc1-3\n *    1.2.5rc1-3              13    10205  12.so.0.1.2.5rc1-3\n *    1.0.15                  10    10015  10.so.0.1.0.15\n *    1.2.5                   13    10205  12.so.0.1.2.5\n *    1.2.6beta1-4            13    10206  12.so.0.1.2.6beta1-4\n *    1.0.16                  10    10016  10.so.0.1.0.16\n *    1.2.6                   13    10206  12.so.0.1.2.6\n *    1.2.7beta1-2            13    10207  12.so.0.1.2.7beta1-2\n *    1.0.17rc1               10    10017  12.so.0.1.0.17rc1\n *    1.2.7rc1                13    10207  12.so.0.1.2.7rc1\n *    1.0.17                  10    10017  12.so.0.1.0.17\n *    1.2.7                   13    10207  12.so.0.1.2.7\n *    1.2.8beta1-5            13    10208  12.so.0.1.2.8beta1-5\n *    1.0.18rc1-5             10    10018  12.so.0.1.0.18rc1-5\n *    1.2.8rc1-5              13    10208  12.so.0.1.2.8rc1-5\n *    1.0.18                  10    10018  12.so.0.1.0.18\n *    1.2.8                   13    10208  12.so.0.1.2.8\n *    1.2.9beta1-3            13    10209  12.so.0.1.2.9beta1-3\n *    1.2.9beta4-11           13    10209  12.so.0.9[.0]\n *    1.2.9rc1                13    10209  12.so.0.9[.0]\n *    1.2.9                   13    10209  12.so.0.9[.0]\n *    1.2.10beta1-7           13    10210  12.so.0.10[.0]\n *    1.2.10rc1-2             13    10210  12.so.0.10[.0]\n *    1.2.10                  13    10210  12.so.0.10[.0]\n *    1.4.0beta1-5            14    10400  14.so.0.0[.0]\n *    1.2.11beta1-4           13    10211  12.so.0.11[.0]\n *    1.4.0beta7-8            14    10400  14.so.0.0[.0]\n *    1.2.11                  13    10211  12.so.0.11[.0]\n *    1.2.12                  13    10212  12.so.0.12[.0]\n *    1.4.0beta9-14           14    10400  14.so.0.0[.0]\n *    1.2.13                  13    10213  12.so.0.13[.0]\n *    1.4.0beta15-36          14    10400  14.so.0.0[.0]\n *    1.4.0beta37-87          14    10400  14.so.14.0[.0]\n *    1.4.0rc01               14    10400  14.so.14.0[.0]\n *    1.4.0beta88-109         14    10400  14.so.14.0[.0]\n *    1.4.0rc02-08            14    10400  14.so.14.0[.0]\n *    1.4.0                   14    10400  14.so.14.0[.0]\n *    1.4.1beta01-03          14    10401  14.so.14.1[.0]\n *    1.4.1rc01               14    10401  14.so.14.1[.0]\n *    1.4.1beta04-12          14    10401  14.so.14.1[.0]\n *    1.4.1                   14    10401  14.so.14.1[.0]\n *    1.4.2                   14    10402  14.so.14.2[.0]\n *    1.4.3                   14    10403  14.so.14.3[.0]\n *    1.4.4                   14    10404  14.so.14.4[.0]\n *    1.5.0beta01-58          15    10500  15.so.15.0[.0]\n *    1.5.0rc01-07            15    10500  15.so.15.0[.0]\n *    1.5.0                   15    10500  15.so.15.0[.0]\n *    1.5.1beta01-11          15    10501  15.so.15.1[.0]\n *    1.5.1rc01-02            15    10501  15.so.15.1[.0]\n *    1.5.1                   15    10501  15.so.15.1[.0]\n *    1.5.2beta01-03          15    10502  15.so.15.2[.0]\n *    1.5.2rc01-03            15    10502  15.so.15.2[.0]\n *    1.5.2                   15    10502  15.so.15.2[.0]\n *    1.5.3beta01-10          15    10503  15.so.15.3[.0]\n *    1.5.3rc01-02            15    10503  15.so.15.3[.0]\n *    1.5.3beta11             15    10503  15.so.15.3[.0]\n *    1.5.3 [omitted]\n *    1.5.4beta01-08          15    10504  15.so.15.4[.0]\n *    1.5.4rc01               15    10504  15.so.15.4[.0]\n *    1.5.4                   15    10504  15.so.15.4[.0]\n *    1.5.5beta01-08          15    10505  15.so.15.5[.0]\n *    1.5.5rc01               15    10505  15.so.15.5[.0]\n *    1.5.5                   15    10505  15.so.15.5[.0]\n *    1.5.6beta01-07          15    10506  15.so.15.6[.0]\n *    1.5.6rc01-03            15    10506  15.so.15.6[.0]\n *    1.5.6                   15    10506  15.so.15.6[.0]\n *    1.5.7beta01-05          15    10507  15.so.15.7[.0]\n *    1.5.7rc01-03            15    10507  15.so.15.7[.0]\n *    1.5.7                   15    10507  15.so.15.7[.0]\n *    1.6.0beta01-40          16    10600  16.so.16.0[.0]\n *    1.6.0rc01-08            16    10600  16.so.16.0[.0]\n *    1.6.0                   16    10600  16.so.16.0[.0]\n *    1.6.1beta01-09          16    10601  16.so.16.1[.0]\n *    1.6.1rc01               16    10601  16.so.16.1[.0]\n *    1.6.1                   16    10601  16.so.16.1[.0]\n *    1.6.2beta01             16    10602  16.so.16.2[.0]\n *    1.6.2rc01-06            16    10602  16.so.16.2[.0]\n *    1.6.2                   16    10602  16.so.16.2[.0]\n *    1.6.3beta01-11          16    10603  16.so.16.3[.0]\n *    1.6.3rc01               16    10603  16.so.16.3[.0]\n *    1.6.3                   16    10603  16.so.16.3[.0]\n *    1.6.4beta01-02          16    10604  16.so.16.4[.0]\n *    1.6.4rc01               16    10604  16.so.16.4[.0]\n *    1.6.4                   16    10604  16.so.16.4[.0]\n *    1.6.5                   16    10605  16.so.16.5[.0]\n *    1.6.6                   16    10606  16.so.16.6[.0]\n *    1.6.7beta01-04          16    10607  16.so.16.7[.0]\n *    1.6.7rc01-03            16    10607  16.so.16.7[.0]\n *    1.6.7                   16    10607  16.so.16.7[.0]\n *    1.6.8beta01-02          16    10608  16.so.16.8[.0]\n *    1.6.8rc01-02            16    10608  16.so.16.8[.0]\n *    1.6.8                   16    10608  16.so.16.8[.0]\n *    1.6.9beta01-04          16    10609  16.so.16.9[.0]\n *    1.6.9rc01-02            16    10609  16.so.16.9[.0]\n *    1.6.9                   16    10609  16.so.16.9[.0]\n *    1.6.10beta01-03         16    10610  16.so.16.10[.0]\n *    1.6.10betarc01-04       16    10610  16.so.16.10[.0]\n *    1.6.10beta              16    10610  16.so.16.10[.0]\n *\n *   Henceforth the source version will match the shared-library major\n *   and minor numbers; the shared-library major version number will be\n *   used for changes in backward compatibility, as it is intended.  The\n *   PNG_LIBPNG_VER macro, which is not used within libpng but is available\n *   for applications, is an unsigned integer of the form xyyzz corresponding\n *   to the source version x.y.z (leading zeros in y and z).  Beta versions\n *   were given the previous public release number plus a letter, until\n *   version 1.0.6j; from then on they were given the upcoming public\n *   release number plus \"betaNN\" or \"rcNN\".\n *\n *   Binary incompatibility exists only when applications make direct access\n *   to the info_ptr or png_ptr members through png.h, and the compiled\n *   application is loaded with a different version of the library.\n *\n *   DLLNUM will change each time there are forward or backward changes\n *   in binary compatibility (e.g., when a new feature is added).\n *\n * See libpng-manual.txt or libpng.3 for more information.  The PNG\n * specification is available as a W3C Recommendation and as an ISO\n * Specification, <http://www.w3.org/TR/2003/REC-PNG-20031110/\n */\n\n/*\n * COPYRIGHT NOTICE, DISCLAIMER, and LICENSE:\n *\n * If you modify libpng you may insert additional notices immediately following\n * this sentence.\n *\n * This code is released under the libpng license.\n *\n * libpng versions 1.2.6, August 15, 2004, through 1.6.10, March 6, 2014, are\n * Copyright (c) 2004, 2006-2013 Glenn Randers-Pehrson, and are\n * distributed according to the same disclaimer and license as libpng-1.2.5\n * with the following individual added to the list of Contributing Authors:\n *\n *    Cosmin Truta\n *\n * libpng versions 1.0.7, July 1, 2000, through 1.2.5, October 3, 2002, are\n * Copyright (c) 2000-2002 Glenn Randers-Pehrson, and are\n * distributed according to the same disclaimer and license as libpng-1.0.6\n * with the following individuals added to the list of Contributing Authors:\n *\n *    Simon-Pierre Cadieux\n *    Eric S. Raymond\n *    Gilles Vollant\n *\n * and with the following additions to the disclaimer:\n *\n *    There is no warranty against interference with your enjoyment of the\n *    library or against infringement.  There is no warranty that our\n *    efforts or the library will fulfill any of your particular purposes\n *    or needs.  This library is provided with all faults, and the entire\n *    risk of satisfactory quality, performance, accuracy, and effort is with\n *    the user.\n *\n * libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are\n * Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson, and are\n * distributed according to the same disclaimer and license as libpng-0.96,\n * with the following individuals added to the list of Contributing Authors:\n *\n *    Tom Lane\n *    Glenn Randers-Pehrson\n *    Willem van Schaik\n *\n * libpng versions 0.89, June 1996, through 0.96, May 1997, are\n * Copyright (c) 1996, 1997 Andreas Dilger\n * Distributed according to the same disclaimer and license as libpng-0.88,\n * with the following individuals added to the list of Contributing Authors:\n *\n *    John Bowler\n *    Kevin Bracey\n *    Sam Bushell\n *    Magnus Holmgren\n *    Greg Roelofs\n *    Tom Tanner\n *\n * libpng versions 0.5, May 1995, through 0.88, January 1996, are\n * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.\n *\n * For the purposes of this copyright and license, \"Contributing Authors\"\n * is defined as the following set of individuals:\n *\n *    Andreas Dilger\n *    Dave Martindale\n *    Guy Eric Schalnat\n *    Paul Schmidt\n *    Tim Wegner\n *\n * The PNG Reference Library is supplied \"AS IS\".  The Contributing Authors\n * and Group 42, Inc. disclaim all warranties, expressed or implied,\n * including, without limitation, the warranties of merchantability and of\n * fitness for any purpose.  The Contributing Authors and Group 42, Inc.\n * assume no liability for direct, indirect, incidental, special, exemplary,\n * or consequential damages, which may result from the use of the PNG\n * Reference Library, even if advised of the possibility of such damage.\n *\n * Permission is hereby granted to use, copy, modify, and distribute this\n * source code, or portions hereof, for any purpose, without fee, subject\n * to the following restrictions:\n *\n *   1. The origin of this source code must not be misrepresented.\n *\n *   2. Altered versions must be plainly marked as such and must not\n *      be misrepresented as being the original source.\n *\n *   3. This Copyright notice may not be removed or altered from\n *      any source or altered source distribution.\n *\n * The Contributing Authors and Group 42, Inc. specifically permit, without\n * fee, and encourage the use of this source code as a component to\n * supporting the PNG file format in commercial products.  If you use this\n * source code in a product, acknowledgment is not required but would be\n * appreciated.\n */\n\n/*\n * A \"png_get_copyright\" function is available, for convenient use in \"about\"\n * boxes and the like:\n *\n *     printf(\"%s\", png_get_copyright(NULL));\n *\n * Also, the PNG logo (in PNG format, of course) is supplied in the\n * files \"pngbar.png\" and \"pngbar.jpg (88x31) and \"pngnow.png\" (98x31).\n */\n\n/*\n * Libpng is OSI Certified Open Source Software.  OSI Certified is a\n * certification mark of the Open Source Initiative.\n */\n\n/*\n * The contributing authors would like to thank all those who helped\n * with testing, bug fixes, and patience.  This wouldn't have been\n * possible without all of you.\n *\n * Thanks to Frank J. T. Wojcik for helping with the documentation.\n */\n\n/*\n * Y2K compliance in libpng:\n * =========================\n *\n *    March 6, 2014\n *\n *    Since the PNG Development group is an ad-hoc body, we can't make\n *    an official declaration.\n *\n *    This is your unofficial assurance that libpng from version 0.71 and\n *    upward through 1.6.10 are Y2K compliant.  It is my belief that\n *    earlier versions were also Y2K compliant.\n *\n *    Libpng only has two year fields.  One is a 2-byte unsigned integer\n *    that will hold years up to 65535.  The other, which is deprecated,\n *    holds the date in text format, and will hold years up to 9999.\n *\n *    The integer is\n *        \"png_uint_16 year\" in png_time_struct.\n *\n *    The string is\n *        \"char time_buffer[29]\" in png_struct.  This is no longer used\n *    in libpng-1.6.x and will be removed from libpng-1.7.0.\n *\n *    There are seven time-related functions:\n *        png.c: png_convert_to_rfc_1123_buffer() in png.c\n *          (formerly png_convert_to_rfc_1123() prior to libpng-1.5.x and\n *          png_convert_to_rfc_1152() in error prior to libpng-0.98)\n *        png_convert_from_struct_tm() in pngwrite.c, called in pngwrite.c\n *        png_convert_from_time_t() in pngwrite.c\n *        png_get_tIME() in pngget.c\n *        png_handle_tIME() in pngrutil.c, called in pngread.c\n *        png_set_tIME() in pngset.c\n *        png_write_tIME() in pngwutil.c, called in pngwrite.c\n *\n *    All handle dates properly in a Y2K environment.  The\n *    png_convert_from_time_t() function calls gmtime() to convert from system\n *    clock time, which returns (year - 1900), which we properly convert to\n *    the full 4-digit year.  There is a possibility that libpng applications\n *    are not passing 4-digit years into the png_convert_to_rfc_1123_buffer()\n *    function, or that they are incorrectly passing only a 2-digit year\n *    instead of \"year - 1900\" into the png_convert_from_struct_tm() function,\n *    but this is not under our control.  The libpng documentation has always\n *    stated that it works with 4-digit years, and the APIs have been\n *    documented as such.\n *\n *    The tIME chunk itself is also Y2K compliant.  It uses a 2-byte unsigned\n *    integer to hold the year, and can hold years as large as 65535.\n *\n *    zlib, upon which libpng depends, is also Y2K compliant.  It contains\n *    no date-related code.\n *\n *       Glenn Randers-Pehrson\n *       libpng maintainer\n *       PNG Development Group\n */\n\n#ifndef PNG_H\n#define PNG_H\n\n/* This is not the place to learn how to use libpng. The file libpng-manual.txt\n * describes how to use libpng, and the file example.c summarizes it\n * with some code on which to build.  This file is useful for looking\n * at the actual function definitions and structure components.\n *\n * If you just need to read a PNG file and don't want to read the documentation\n * skip to the end of this file and read the section entitled 'simplified API'.\n */\n\n/* Version information for png.h - this should match the version in png.c */\n#define PNG_LIBPNG_VER_STRING \"1.6.10\"\n#define PNG_HEADER_VERSION_STRING \\\n     \" libpng version 1.6.10 - March 6, 2014\\n\"\n\n#define PNG_LIBPNG_VER_SONUM   16\n#define PNG_LIBPNG_VER_DLLNUM  16\n\n/* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */\n#define PNG_LIBPNG_VER_MAJOR   1\n#define PNG_LIBPNG_VER_MINOR   6\n#define PNG_LIBPNG_VER_RELEASE 10\n\n/* This should match the numeric part of the final component of\n * PNG_LIBPNG_VER_STRING, omitting any leading zero:\n */\n\n#define PNG_LIBPNG_VER_BUILD  0\n\n/* Release Status */\n#define PNG_LIBPNG_BUILD_ALPHA    1\n#define PNG_LIBPNG_BUILD_BETA     2\n#define PNG_LIBPNG_BUILD_RC       3\n#define PNG_LIBPNG_BUILD_STABLE   4\n#define PNG_LIBPNG_BUILD_RELEASE_STATUS_MASK 7\n\n/* Release-Specific Flags */\n#define PNG_LIBPNG_BUILD_PATCH    8 /* Can be OR'ed with\n                                       PNG_LIBPNG_BUILD_STABLE only */\n#define PNG_LIBPNG_BUILD_PRIVATE 16 /* Cannot be OR'ed with\n                                       PNG_LIBPNG_BUILD_SPECIAL */\n#define PNG_LIBPNG_BUILD_SPECIAL 32 /* Cannot be OR'ed with\n                                       PNG_LIBPNG_BUILD_PRIVATE */\n\n#define PNG_LIBPNG_BUILD_BASE_TYPE PNG_LIBPNG_BUILD_STABLE\n\n/* Careful here.  At one time, Guy wanted to use 082, but that would be octal.\n * We must not include leading zeros.\n * Versions 0.7 through 1.0.0 were in the range 0 to 100 here (only\n * version 1.0.0 was mis-numbered 100 instead of 10000).  From\n * version 1.0.1 it's    xxyyzz, where x=major, y=minor, z=release\n */\n#define PNG_LIBPNG_VER 10610 /* 1.6.10 */\n\n/* Library configuration: these options cannot be changed after\n * the library has been built.\n */\n#ifndef PNGLCONF_H\n    /* If pnglibconf.h is missing, you can\n     * copy scripts/pnglibconf.h.prebuilt to pnglibconf.h\n     */\n#   include \"pnglibconf.h\"\n#endif\n\n#ifndef PNG_VERSION_INFO_ONLY\n   /* Machine specific configuration. */\n#  include \"pngconf.h\"\n#endif\n\n/*\n * Added at libpng-1.2.8\n *\n * Ref MSDN: Private as priority over Special\n * VS_FF_PRIVATEBUILD File *was not* built using standard release\n * procedures. If this value is given, the StringFileInfo block must\n * contain a PrivateBuild string.\n *\n * VS_FF_SPECIALBUILD File *was* built by the original company using\n * standard release procedures but is a variation of the standard\n * file of the same version number. If this value is given, the\n * StringFileInfo block must contain a SpecialBuild string.\n */\n\n#ifdef PNG_USER_PRIVATEBUILD /* From pnglibconf.h */\n#  define PNG_LIBPNG_BUILD_TYPE \\\n       (PNG_LIBPNG_BUILD_BASE_TYPE | PNG_LIBPNG_BUILD_PRIVATE)\n#else\n#  ifdef PNG_LIBPNG_SPECIALBUILD\n#    define PNG_LIBPNG_BUILD_TYPE \\\n         (PNG_LIBPNG_BUILD_BASE_TYPE | PNG_LIBPNG_BUILD_SPECIAL)\n#  else\n#    define PNG_LIBPNG_BUILD_TYPE (PNG_LIBPNG_BUILD_BASE_TYPE)\n#  endif\n#endif\n\n#ifndef PNG_VERSION_INFO_ONLY\n\n/* Inhibit C++ name-mangling for libpng functions but not for system calls. */\n#ifdef __cplusplus\nextern \"C\" {\n#endif /* __cplusplus */\n\n/* Version information for C files, stored in png.c.  This had better match\n * the version above.\n */\n#define png_libpng_ver png_get_header_ver(NULL)\n\n/* This file is arranged in several sections:\n *\n * 1. Any configuration options that can be specified by for the application\n *    code when it is built.  (Build time configuration is in pnglibconf.h)\n * 2. Type definitions (base types are defined in pngconf.h), structure\n *    definitions.\n * 3. Exported library functions.\n * 4. Simplified API.\n *\n * The library source code has additional files (principally pngpriv.h) that\n * allow configuration of the library.\n */\n/* Section 1: run time configuration\n * See pnglibconf.h for build time configuration\n *\n * Run time configuration allows the application to choose between\n * implementations of certain arithmetic APIs.  The default is set\n * at build time and recorded in pnglibconf.h, but it is safe to\n * override these (and only these) settings.  Note that this won't\n * change what the library does, only application code, and the\n * settings can (and probably should) be made on a per-file basis\n * by setting the #defines before including png.h\n *\n * Use macros to read integers from PNG data or use the exported\n * functions?\n *   PNG_USE_READ_MACROS: use the macros (see below)  Note that\n *     the macros evaluate their argument multiple times.\n *   PNG_NO_USE_READ_MACROS: call the relevant library function.\n *\n * Use the alternative algorithm for compositing alpha samples that\n * does not use division?\n *   PNG_READ_COMPOSITE_NODIV_SUPPORTED: use the 'no division'\n *      algorithm.\n *   PNG_NO_READ_COMPOSITE_NODIV: use the 'division' algorithm.\n *\n * How to handle benign errors if PNG_ALLOW_BENIGN_ERRORS is\n * false?\n *   PNG_ALLOW_BENIGN_ERRORS: map calls to the benign error\n *      APIs to png_warning.\n * Otherwise the calls are mapped to png_error.\n */\n\n/* Section 2: type definitions, including structures and compile time\n * constants.\n * See pngconf.h for base types that vary by machine/system\n */\n\n/* This triggers a compiler error in png.c, if png.c and png.h\n * do not agree upon the version number.\n */\ntypedef char* png_libpng_version_1_6_10;\n\n/* Basic control structions.  Read libpng-manual.txt or libpng.3 for more info.\n *\n * png_struct is the cache of information used while reading or writing a single\n * PNG file.  One of these is always required, although the simplified API\n * (below) hides the creation and destruction of it.\n */\ntypedef struct png_struct_def png_struct;\ntypedef const png_struct * png_const_structp;\ntypedef png_struct * png_structp;\ntypedef png_struct * * png_structpp;\n\n/* png_info contains information read from or to be written to a PNG file.  One\n * or more of these must exist while reading or creating a PNG file.  The\n * information is not used by libpng during read but is used to control what\n * gets written when a PNG file is created.  \"png_get_\" function calls read\n * information during read and \"png_set_\" functions calls write information\n * when creating a PNG.\n * been moved into a separate header file that is not accessible to\n * applications.  Read libpng-manual.txt or libpng.3 for more info.\n */\ntypedef struct png_info_def png_info;\ntypedef png_info * png_infop;\ntypedef const png_info * png_const_infop;\ntypedef png_info * * png_infopp;\n\n/* Types with names ending 'p' are pointer types.  The corresponding types with\n * names ending 'rp' are identical pointer types except that the pointer is\n * marked 'restrict', which means that it is the only pointer to the object\n * passed to the function.  Applications should not use the 'restrict' types;\n * it is always valid to pass 'p' to a pointer with a function argument of the\n * corresponding 'rp' type.  Different compilers have different rules with\n * regard to type matching in the presence of 'restrict'.  For backward\n * compatibility libpng callbacks never have 'restrict' in their parameters and,\n * consequentially, writing portable application code is extremely difficult if\n * an attempt is made to use 'restrict'.\n */\ntypedef png_struct * PNG_RESTRICT png_structrp;\ntypedef const png_struct * PNG_RESTRICT png_const_structrp;\ntypedef png_info * PNG_RESTRICT png_inforp;\ntypedef const png_info * PNG_RESTRICT png_const_inforp;\n\n/* Three color definitions.  The order of the red, green, and blue, (and the\n * exact size) is not important, although the size of the fields need to\n * be png_byte or png_uint_16 (as defined below).\n */\ntypedef struct png_color_struct\n{\n   png_byte red;\n   png_byte green;\n   png_byte blue;\n} png_color;\ntypedef png_color * png_colorp;\ntypedef const png_color * png_const_colorp;\ntypedef png_color * * png_colorpp;\n\ntypedef struct png_color_16_struct\n{\n   png_byte index;    /* used for palette files */\n   png_uint_16 red;   /* for use in red green blue files */\n   png_uint_16 green;\n   png_uint_16 blue;\n   png_uint_16 gray;  /* for use in grayscale files */\n} png_color_16;\ntypedef png_color_16 * png_color_16p;\ntypedef const png_color_16 * png_const_color_16p;\ntypedef png_color_16 * * png_color_16pp;\n\ntypedef struct png_color_8_struct\n{\n   png_byte red;   /* for use in red green blue files */\n   png_byte green;\n   png_byte blue;\n   png_byte gray;  /* for use in grayscale files */\n   png_byte alpha; /* for alpha channel files */\n} png_color_8;\ntypedef png_color_8 * png_color_8p;\ntypedef const png_color_8 * png_const_color_8p;\ntypedef png_color_8 * * png_color_8pp;\n\n/*\n * The following two structures are used for the in-core representation\n * of sPLT chunks.\n */\ntypedef struct png_sPLT_entry_struct\n{\n   png_uint_16 red;\n   png_uint_16 green;\n   png_uint_16 blue;\n   png_uint_16 alpha;\n   png_uint_16 frequency;\n} png_sPLT_entry;\ntypedef png_sPLT_entry * png_sPLT_entryp;\ntypedef const png_sPLT_entry * png_const_sPLT_entryp;\ntypedef png_sPLT_entry * * png_sPLT_entrypp;\n\n/*  When the depth of the sPLT palette is 8 bits, the color and alpha samples\n *  occupy the LSB of their respective members, and the MSB of each member\n *  is zero-filled.  The frequency member always occupies the full 16 bits.\n */\n\ntypedef struct png_sPLT_struct\n{\n   png_charp name;           /* palette name */\n   png_byte depth;           /* depth of palette samples */\n   png_sPLT_entryp entries;  /* palette entries */\n   png_int_32 nentries;      /* number of palette entries */\n} png_sPLT_t;\ntypedef png_sPLT_t * png_sPLT_tp;\ntypedef const png_sPLT_t * png_const_sPLT_tp;\ntypedef png_sPLT_t * * png_sPLT_tpp;\n\n#ifdef PNG_TEXT_SUPPORTED\n/* png_text holds the contents of a text/ztxt/itxt chunk in a PNG file,\n * and whether that contents is compressed or not.  The \"key\" field\n * points to a regular zero-terminated C string.  The \"text\" fields can be a\n * regular C string, an empty string, or a NULL pointer.\n * However, the structure returned by png_get_text() will always contain\n * the \"text\" field as a regular zero-terminated C string (possibly\n * empty), never a NULL pointer, so it can be safely used in printf() and\n * other string-handling functions.  Note that the \"itxt_length\", \"lang\", and\n * \"lang_key\" members of the structure only exist when the library is built\n * with iTXt chunk support.  Prior to libpng-1.4.0 the library was built by\n * default without iTXt support. Also note that when iTXt *is* supported,\n * the \"lang\" and \"lang_key\" fields contain NULL pointers when the\n * \"compression\" field contains * PNG_TEXT_COMPRESSION_NONE or\n * PNG_TEXT_COMPRESSION_zTXt. Note that the \"compression value\" is not the\n * same as what appears in the PNG tEXt/zTXt/iTXt chunk's \"compression flag\"\n * which is always 0 or 1, or its \"compression method\" which is always 0.\n */\ntypedef struct png_text_struct\n{\n   int  compression;       /* compression value:\n                             -1: tEXt, none\n                              0: zTXt, deflate\n                              1: iTXt, none\n                              2: iTXt, deflate  */\n   png_charp key;          /* keyword, 1-79 character description of \"text\" */\n   png_charp text;         /* comment, may be an empty string (ie \"\")\n                              or a NULL pointer */\n   png_size_t text_length; /* length of the text string */\n   png_size_t itxt_length; /* length of the itxt string */\n   png_charp lang;         /* language code, 0-79 characters\n                              or a NULL pointer */\n   png_charp lang_key;     /* keyword translated UTF-8 string, 0 or more\n                              chars or a NULL pointer */\n} png_text;\ntypedef png_text * png_textp;\ntypedef const png_text * png_const_textp;\ntypedef png_text * * png_textpp;\n#endif\n\n/* Supported compression types for text in PNG files (tEXt, and zTXt).\n * The values of the PNG_TEXT_COMPRESSION_ defines should NOT be changed. */\n#define PNG_TEXT_COMPRESSION_NONE_WR -3\n#define PNG_TEXT_COMPRESSION_zTXt_WR -2\n#define PNG_TEXT_COMPRESSION_NONE    -1\n#define PNG_TEXT_COMPRESSION_zTXt     0\n#define PNG_ITXT_COMPRESSION_NONE     1\n#define PNG_ITXT_COMPRESSION_zTXt     2\n#define PNG_TEXT_COMPRESSION_LAST     3  /* Not a valid value */\n\n/* png_time is a way to hold the time in an machine independent way.\n * Two conversions are provided, both from time_t and struct tm.  There\n * is no portable way to convert to either of these structures, as far\n * as I know.  If you know of a portable way, send it to me.  As a side\n * note - PNG has always been Year 2000 compliant!\n */\ntypedef struct png_time_struct\n{\n   png_uint_16 year; /* full year, as in, 1995 */\n   png_byte month;   /* month of year, 1 - 12 */\n   png_byte day;     /* day of month, 1 - 31 */\n   png_byte hour;    /* hour of day, 0 - 23 */\n   png_byte minute;  /* minute of hour, 0 - 59 */\n   png_byte second;  /* second of minute, 0 - 60 (for leap seconds) */\n} png_time;\ntypedef png_time * png_timep;\ntypedef const png_time * png_const_timep;\ntypedef png_time * * png_timepp;\n\n#if defined(PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED) ||\\\n   defined(PNG_USER_CHUNKS_SUPPORTED)\n/* png_unknown_chunk is a structure to hold queued chunks for which there is\n * no specific support.  The idea is that we can use this to queue\n * up private chunks for output even though the library doesn't actually\n * know about their semantics.\n *\n * The data in the structure is set by libpng on read and used on write.\n */\ntypedef struct png_unknown_chunk_t\n{\n    png_byte name[5]; /* Textual chunk name with '\\0' terminator */\n    png_byte *data;   /* Data, should not be modified on read! */\n    png_size_t size;\n\n    /* On write 'location' must be set using the flag values listed below.\n     * Notice that on read it is set by libpng however the values stored have\n     * more bits set than are listed below.  Always treat the value as a\n     * bitmask.  On write set only one bit - setting multiple bits may cause the\n     * chunk to be written in multiple places.\n     */\n    png_byte location; /* mode of operation at read time */\n}\npng_unknown_chunk;\n\ntypedef png_unknown_chunk * png_unknown_chunkp;\ntypedef const png_unknown_chunk * png_const_unknown_chunkp;\ntypedef png_unknown_chunk * * png_unknown_chunkpp;\n#endif\n\n/* Flag values for the unknown chunk location byte. */\n#define PNG_HAVE_IHDR  0x01\n#define PNG_HAVE_PLTE  0x02\n#define PNG_AFTER_IDAT 0x08\n\n/* Maximum positive integer used in PNG is (2^31)-1 */\n#define PNG_UINT_31_MAX ((png_uint_32)0x7fffffffL)\n#define PNG_UINT_32_MAX ((png_uint_32)(-1))\n#define PNG_SIZE_MAX ((png_size_t)(-1))\n\n/* These are constants for fixed point values encoded in the\n * PNG specification manner (x100000)\n */\n#define PNG_FP_1    100000\n#define PNG_FP_HALF  50000\n#define PNG_FP_MAX  ((png_fixed_point)0x7fffffffL)\n#define PNG_FP_MIN  (-PNG_FP_MAX)\n\n/* These describe the color_type field in png_info. */\n/* color type masks */\n#define PNG_COLOR_MASK_PALETTE    1\n#define PNG_COLOR_MASK_COLOR      2\n#define PNG_COLOR_MASK_ALPHA      4\n\n/* color types.  Note that not all combinations are legal */\n#define PNG_COLOR_TYPE_GRAY 0\n#define PNG_COLOR_TYPE_PALETTE  (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_PALETTE)\n#define PNG_COLOR_TYPE_RGB        (PNG_COLOR_MASK_COLOR)\n#define PNG_COLOR_TYPE_RGB_ALPHA  (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_ALPHA)\n#define PNG_COLOR_TYPE_GRAY_ALPHA (PNG_COLOR_MASK_ALPHA)\n/* aliases */\n#define PNG_COLOR_TYPE_RGBA  PNG_COLOR_TYPE_RGB_ALPHA\n#define PNG_COLOR_TYPE_GA  PNG_COLOR_TYPE_GRAY_ALPHA\n\n/* This is for compression type. PNG 1.0-1.2 only define the single type. */\n#define PNG_COMPRESSION_TYPE_BASE 0 /* Deflate method 8, 32K window */\n#define PNG_COMPRESSION_TYPE_DEFAULT PNG_COMPRESSION_TYPE_BASE\n\n/* This is for filter type. PNG 1.0-1.2 only define the single type. */\n#define PNG_FILTER_TYPE_BASE      0 /* Single row per-byte filtering */\n#define PNG_INTRAPIXEL_DIFFERENCING 64 /* Used only in MNG datastreams */\n#define PNG_FILTER_TYPE_DEFAULT   PNG_FILTER_TYPE_BASE\n\n/* These are for the interlacing type.  These values should NOT be changed. */\n#define PNG_INTERLACE_NONE        0 /* Non-interlaced image */\n#define PNG_INTERLACE_ADAM7       1 /* Adam7 interlacing */\n#define PNG_INTERLACE_LAST        2 /* Not a valid value */\n\n/* These are for the oFFs chunk.  These values should NOT be changed. */\n#define PNG_OFFSET_PIXEL          0 /* Offset in pixels */\n#define PNG_OFFSET_MICROMETER     1 /* Offset in micrometers (1/10^6 meter) */\n#define PNG_OFFSET_LAST           2 /* Not a valid value */\n\n/* These are for the pCAL chunk.  These values should NOT be changed. */\n#define PNG_EQUATION_LINEAR       0 /* Linear transformation */\n#define PNG_EQUATION_BASE_E       1 /* Exponential base e transform */\n#define PNG_EQUATION_ARBITRARY    2 /* Arbitrary base exponential transform */\n#define PNG_EQUATION_HYPERBOLIC   3 /* Hyperbolic sine transformation */\n#define PNG_EQUATION_LAST         4 /* Not a valid value */\n\n/* These are for the sCAL chunk.  These values should NOT be changed. */\n#define PNG_SCALE_UNKNOWN         0 /* unknown unit (image scale) */\n#define PNG_SCALE_METER           1 /* meters per pixel */\n#define PNG_SCALE_RADIAN          2 /* radians per pixel */\n#define PNG_SCALE_LAST            3 /* Not a valid value */\n\n/* These are for the pHYs chunk.  These values should NOT be changed. */\n#define PNG_RESOLUTION_UNKNOWN    0 /* pixels/unknown unit (aspect ratio) */\n#define PNG_RESOLUTION_METER      1 /* pixels/meter */\n#define PNG_RESOLUTION_LAST       2 /* Not a valid value */\n\n/* These are for the sRGB chunk.  These values should NOT be changed. */\n#define PNG_sRGB_INTENT_PERCEPTUAL 0\n#define PNG_sRGB_INTENT_RELATIVE   1\n#define PNG_sRGB_INTENT_SATURATION 2\n#define PNG_sRGB_INTENT_ABSOLUTE   3\n#define PNG_sRGB_INTENT_LAST       4 /* Not a valid value */\n\n/* This is for text chunks */\n#define PNG_KEYWORD_MAX_LENGTH     79\n\n/* Maximum number of entries in PLTE/sPLT/tRNS arrays */\n#define PNG_MAX_PALETTE_LENGTH    256\n\n/* These determine if an ancillary chunk's data has been successfully read\n * from the PNG header, or if the application has filled in the corresponding\n * data in the info_struct to be written into the output file.  The values\n * of the PNG_INFO_<chunk> defines should NOT be changed.\n */\n#define PNG_INFO_gAMA 0x0001\n#define PNG_INFO_sBIT 0x0002\n#define PNG_INFO_cHRM 0x0004\n#define PNG_INFO_PLTE 0x0008\n#define PNG_INFO_tRNS 0x0010\n#define PNG_INFO_bKGD 0x0020\n#define PNG_INFO_hIST 0x0040\n#define PNG_INFO_pHYs 0x0080\n#define PNG_INFO_oFFs 0x0100\n#define PNG_INFO_tIME 0x0200\n#define PNG_INFO_pCAL 0x0400\n#define PNG_INFO_sRGB 0x0800   /* GR-P, 0.96a */\n#define PNG_INFO_iCCP 0x1000   /* ESR, 1.0.6 */\n#define PNG_INFO_sPLT 0x2000   /* ESR, 1.0.6 */\n#define PNG_INFO_sCAL 0x4000   /* ESR, 1.0.6 */\n#define PNG_INFO_IDAT 0x8000   /* ESR, 1.0.6 */\n\n/* This is used for the transformation routines, as some of them\n * change these values for the row.  It also should enable using\n * the routines for other purposes.\n */\ntypedef struct png_row_info_struct\n{\n   png_uint_32 width;    /* width of row */\n   png_size_t rowbytes;  /* number of bytes in row */\n   png_byte color_type;  /* color type of row */\n   png_byte bit_depth;   /* bit depth of row */\n   png_byte channels;    /* number of channels (1, 2, 3, or 4) */\n   png_byte pixel_depth; /* bits per pixel (depth * channels) */\n} png_row_info;\n\ntypedef png_row_info * png_row_infop;\ntypedef png_row_info * * png_row_infopp;\n\n/* These are the function types for the I/O functions and for the functions\n * that allow the user to override the default I/O functions with his or her\n * own.  The png_error_ptr type should match that of user-supplied warning\n * and error functions, while the png_rw_ptr type should match that of the\n * user read/write data functions.  Note that the 'write' function must not\n * modify the buffer it is passed. The 'read' function, on the other hand, is\n * expected to return the read data in the buffer.\n */\ntypedef PNG_CALLBACK(void, *png_error_ptr, (png_structp, png_const_charp));\ntypedef PNG_CALLBACK(void, *png_rw_ptr, (png_structp, png_bytep, png_size_t));\ntypedef PNG_CALLBACK(void, *png_flush_ptr, (png_structp));\ntypedef PNG_CALLBACK(void, *png_read_status_ptr, (png_structp, png_uint_32,\n    int));\ntypedef PNG_CALLBACK(void, *png_write_status_ptr, (png_structp, png_uint_32,\n    int));\n\n#ifdef PNG_PROGRESSIVE_READ_SUPPORTED\ntypedef PNG_CALLBACK(void, *png_progressive_info_ptr, (png_structp, png_infop));\ntypedef PNG_CALLBACK(void, *png_progressive_end_ptr, (png_structp, png_infop));\n\n/* The following callback receives png_uint_32 row_number, int pass for the\n * png_bytep data of the row.  When transforming an interlaced image the\n * row number is the row number within the sub-image of the interlace pass, so\n * the value will increase to the height of the sub-image (not the full image)\n * then reset to 0 for the next pass.\n *\n * Use PNG_ROW_FROM_PASS_ROW(row, pass) and PNG_COL_FROM_PASS_COL(col, pass) to\n * find the output pixel (x,y) given an interlaced sub-image pixel\n * (row,col,pass).  (See below for these macros.)\n */\ntypedef PNG_CALLBACK(void, *png_progressive_row_ptr, (png_structp, png_bytep,\n    png_uint_32, int));\n#endif\n\n#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \\\n    defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)\ntypedef PNG_CALLBACK(void, *png_user_transform_ptr, (png_structp, png_row_infop,\n    png_bytep));\n#endif\n\n#ifdef PNG_USER_CHUNKS_SUPPORTED\ntypedef PNG_CALLBACK(int, *png_user_chunk_ptr, (png_structp,\n    png_unknown_chunkp));\n#endif\n#ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED\n/* not used anywhere */\n/* typedef PNG_CALLBACK(void, *png_unknown_chunk_ptr, (png_structp)); */\n#endif\n\n#ifdef PNG_SETJMP_SUPPORTED\n/* This must match the function definition in <setjmp.h>, and the application\n * must include this before png.h to obtain the definition of jmp_buf.  The\n * function is required to be PNG_NORETURN, but this is not checked.  If the\n * function does return the application will crash via an abort() or similar\n * system level call.\n *\n * If you get a warning here while building the library you may need to make\n * changes to ensure that pnglibconf.h records the calling convention used by\n * your compiler.  This may be very difficult - try using a different compiler\n * to build the library!\n */\nPNG_FUNCTION(void, (PNGCAPI *png_longjmp_ptr), PNGARG((jmp_buf, int)), typedef);\n#endif\n\n/* Transform masks for the high-level interface */\n#define PNG_TRANSFORM_IDENTITY       0x0000    /* read and write */\n#define PNG_TRANSFORM_STRIP_16       0x0001    /* read only */\n#define PNG_TRANSFORM_STRIP_ALPHA    0x0002    /* read only */\n#define PNG_TRANSFORM_PACKING        0x0004    /* read and write */\n#define PNG_TRANSFORM_PACKSWAP       0x0008    /* read and write */\n#define PNG_TRANSFORM_EXPAND         0x0010    /* read only */\n#define PNG_TRANSFORM_INVERT_MONO    0x0020    /* read and write */\n#define PNG_TRANSFORM_SHIFT          0x0040    /* read and write */\n#define PNG_TRANSFORM_BGR            0x0080    /* read and write */\n#define PNG_TRANSFORM_SWAP_ALPHA     0x0100    /* read and write */\n#define PNG_TRANSFORM_SWAP_ENDIAN    0x0200    /* read and write */\n#define PNG_TRANSFORM_INVERT_ALPHA   0x0400    /* read and write */\n#define PNG_TRANSFORM_STRIP_FILLER   0x0800    /* write only */\n/* Added to libpng-1.2.34 */\n#define PNG_TRANSFORM_STRIP_FILLER_BEFORE PNG_TRANSFORM_STRIP_FILLER\n#define PNG_TRANSFORM_STRIP_FILLER_AFTER 0x1000 /* write only */\n/* Added to libpng-1.4.0 */\n#define PNG_TRANSFORM_GRAY_TO_RGB   0x2000      /* read only */\n/* Added to libpng-1.5.4 */\n#define PNG_TRANSFORM_EXPAND_16     0x4000      /* read only */\n#define PNG_TRANSFORM_SCALE_16      0x8000      /* read only */\n\n/* Flags for MNG supported features */\n#define PNG_FLAG_MNG_EMPTY_PLTE     0x01\n#define PNG_FLAG_MNG_FILTER_64      0x04\n#define PNG_ALL_MNG_FEATURES        0x05\n\n/* NOTE: prior to 1.5 these functions had no 'API' style declaration,\n * this allowed the zlib default functions to be used on Windows\n * platforms.  In 1.5 the zlib default malloc (which just calls malloc and\n * ignores the first argument) should be completely compatible with the\n * following.\n */\ntypedef PNG_CALLBACK(png_voidp, *png_malloc_ptr, (png_structp,\n    png_alloc_size_t));\ntypedef PNG_CALLBACK(void, *png_free_ptr, (png_structp, png_voidp));\n\n/* Section 3: exported functions\n * Here are the function definitions most commonly used.  This is not\n * the place to find out how to use libpng.  See libpng-manual.txt for the\n * full explanation, see example.c for the summary.  This just provides\n * a simple one line description of the use of each function.\n *\n * The PNG_EXPORT() and PNG_EXPORTA() macros used below are defined in\n * pngconf.h and in the *.dfn files in the scripts directory.\n *\n *   PNG_EXPORT(ordinal, type, name, (args));\n *\n *       ordinal:    ordinal that is used while building\n *                   *.def files. The ordinal value is only\n *                   relevant when preprocessing png.h with\n *                   the *.dfn files for building symbol table\n *                   entries, and are removed by pngconf.h.\n *       type:       return type of the function\n *       name:       function name\n *       args:       function arguments, with types\n *\n * When we wish to append attributes to a function prototype we use\n * the PNG_EXPORTA() macro instead.\n *\n *   PNG_EXPORTA(ordinal, type, name, (args), attributes);\n *\n *       ordinal, type, name, and args: same as in PNG_EXPORT().\n *       attributes: function attributes\n */\n\n/* Returns the version number of the library */\nPNG_EXPORT(1, png_uint_32, png_access_version_number, (void));\n\n/* Tell lib we have already handled the first <num_bytes> magic bytes.\n * Handling more than 8 bytes from the beginning of the file is an error.\n */\nPNG_EXPORT(2, void, png_set_sig_bytes, (png_structrp png_ptr, int num_bytes));\n\n/* Check sig[start] through sig[start + num_to_check - 1] to see if it's a\n * PNG file.  Returns zero if the supplied bytes match the 8-byte PNG\n * signature, and non-zero otherwise.  Having num_to_check == 0 or\n * start > 7 will always fail (ie return non-zero).\n */\nPNG_EXPORT(3, int, png_sig_cmp, (png_const_bytep sig, png_size_t start,\n    png_size_t num_to_check));\n\n/* Simple signature checking function.  This is the same as calling\n * png_check_sig(sig, n) := !png_sig_cmp(sig, 0, n).\n */\n#define png_check_sig(sig, n) !png_sig_cmp((sig), 0, (n))\n\n/* Allocate and initialize png_ptr struct for reading, and any other memory. */\nPNG_EXPORTA(4, png_structp, png_create_read_struct,\n    (png_const_charp user_png_ver, png_voidp error_ptr,\n    png_error_ptr error_fn, png_error_ptr warn_fn),\n    PNG_ALLOCATED);\n\n/* Allocate and initialize png_ptr struct for writing, and any other memory */\nPNG_EXPORTA(5, png_structp, png_create_write_struct,\n    (png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn,\n    png_error_ptr warn_fn),\n    PNG_ALLOCATED);\n\nPNG_EXPORT(6, png_size_t, png_get_compression_buffer_size,\n    (png_const_structrp png_ptr));\n\nPNG_EXPORT(7, void, png_set_compression_buffer_size, (png_structrp png_ptr,\n    png_size_t size));\n\n/* Moved from pngconf.h in 1.4.0 and modified to ensure setjmp/longjmp\n * match up.\n */\n#ifdef PNG_SETJMP_SUPPORTED\n/* This function returns the jmp_buf built in to *png_ptr.  It must be\n * supplied with an appropriate 'longjmp' function to use on that jmp_buf\n * unless the default error function is overridden in which case NULL is\n * acceptable.  The size of the jmp_buf is checked against the actual size\n * allocated by the library - the call will return NULL on a mismatch\n * indicating an ABI mismatch.\n */\nPNG_EXPORT(8, jmp_buf*, png_set_longjmp_fn, (png_structrp png_ptr,\n    png_longjmp_ptr longjmp_fn, size_t jmp_buf_size));\n#  define png_jmpbuf(png_ptr) \\\n      (*png_set_longjmp_fn((png_ptr), longjmp, (sizeof (jmp_buf))))\n#else\n#  define png_jmpbuf(png_ptr) \\\n      (LIBPNG_WAS_COMPILED_WITH__PNG_NO_SETJMP)\n#endif\n/* This function should be used by libpng applications in place of\n * longjmp(png_ptr->jmpbuf, val).  If longjmp_fn() has been set, it\n * will use it; otherwise it will call PNG_ABORT().  This function was\n * added in libpng-1.5.0.\n */\nPNG_EXPORTA(9, void, png_longjmp, (png_const_structrp png_ptr, int val),\n    PNG_NORETURN);\n\n#ifdef PNG_READ_SUPPORTED\n/* Reset the compression stream */\nPNG_EXPORTA(10, int, png_reset_zstream, (png_structrp png_ptr), PNG_DEPRECATED);\n#endif\n\n/* New functions added in libpng-1.0.2 (not enabled by default until 1.2.0) */\n#ifdef PNG_USER_MEM_SUPPORTED\nPNG_EXPORTA(11, png_structp, png_create_read_struct_2,\n    (png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn,\n    png_error_ptr warn_fn,\n    png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn),\n    PNG_ALLOCATED);\nPNG_EXPORTA(12, png_structp, png_create_write_struct_2,\n    (png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn,\n    png_error_ptr warn_fn,\n    png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn),\n    PNG_ALLOCATED);\n#endif\n\n/* Write the PNG file signature. */\nPNG_EXPORT(13, void, png_write_sig, (png_structrp png_ptr));\n\n/* Write a PNG chunk - size, type, (optional) data, CRC. */\nPNG_EXPORT(14, void, png_write_chunk, (png_structrp png_ptr, png_const_bytep\n    chunk_name, png_const_bytep data, png_size_t length));\n\n/* Write the start of a PNG chunk - length and chunk name. */\nPNG_EXPORT(15, void, png_write_chunk_start, (png_structrp png_ptr,\n    png_const_bytep chunk_name, png_uint_32 length));\n\n/* Write the data of a PNG chunk started with png_write_chunk_start(). */\nPNG_EXPORT(16, void, png_write_chunk_data, (png_structrp png_ptr,\n    png_const_bytep data, png_size_t length));\n\n/* Finish a chunk started with png_write_chunk_start() (includes CRC). */\nPNG_EXPORT(17, void, png_write_chunk_end, (png_structrp png_ptr));\n\n/* Allocate and initialize the info structure */\nPNG_EXPORTA(18, png_infop, png_create_info_struct, (png_const_structrp png_ptr),\n    PNG_ALLOCATED);\n\n/* DEPRECATED: this function allowed init structures to be created using the\n * default allocation method (typically malloc).  Use is deprecated in 1.6.0 and\n * the API will be removed in the future.\n */\nPNG_EXPORTA(19, void, png_info_init_3, (png_infopp info_ptr,\n    png_size_t png_info_struct_size), PNG_DEPRECATED);\n\n/* Writes all the PNG information before the image. */\nPNG_EXPORT(20, void, png_write_info_before_PLTE,\n    (png_structrp png_ptr, png_const_inforp info_ptr));\nPNG_EXPORT(21, void, png_write_info,\n    (png_structrp png_ptr, png_const_inforp info_ptr));\n\n#ifdef PNG_SEQUENTIAL_READ_SUPPORTED\n/* Read the information before the actual image data. */\nPNG_EXPORT(22, void, png_read_info,\n    (png_structrp png_ptr, png_inforp info_ptr));\n#endif\n\n#ifdef PNG_TIME_RFC1123_SUPPORTED\n   /* Convert to a US string format: there is no localization support in this\n    * routine.  The original implementation used a 29 character buffer in\n    * png_struct, this will be removed in future versions.\n    */\n#if PNG_LIBPNG_VER < 10700\n/* To do: remove this from libpng17 (and from libpng17/png.c and pngstruct.h) */\nPNG_EXPORTA(23, png_const_charp, png_convert_to_rfc1123, (png_structrp png_ptr,\n    png_const_timep ptime),PNG_DEPRECATED);\n#endif\nPNG_EXPORT(241, int, png_convert_to_rfc1123_buffer, (char out[29],\n    png_const_timep ptime));\n#endif\n\n#ifdef PNG_CONVERT_tIME_SUPPORTED\n/* Convert from a struct tm to png_time */\nPNG_EXPORT(24, void, png_convert_from_struct_tm, (png_timep ptime,\n    const struct tm * ttime));\n\n/* Convert from time_t to png_time.  Uses gmtime() */\nPNG_EXPORT(25, void, png_convert_from_time_t, (png_timep ptime, time_t ttime));\n#endif /* PNG_CONVERT_tIME_SUPPORTED */\n\n#ifdef PNG_READ_EXPAND_SUPPORTED\n/* Expand data to 24-bit RGB, or 8-bit grayscale, with alpha if available. */\nPNG_EXPORT(26, void, png_set_expand, (png_structrp png_ptr));\nPNG_EXPORT(27, void, png_set_expand_gray_1_2_4_to_8, (png_structrp png_ptr));\nPNG_EXPORT(28, void, png_set_palette_to_rgb, (png_structrp png_ptr));\nPNG_EXPORT(29, void, png_set_tRNS_to_alpha, (png_structrp png_ptr));\n#endif\n\n#ifdef PNG_READ_EXPAND_16_SUPPORTED\n/* Expand to 16-bit channels, forces conversion of palette to RGB and expansion\n * of a tRNS chunk if present.\n */\nPNG_EXPORT(221, void, png_set_expand_16, (png_structrp png_ptr));\n#endif\n\n#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED)\n/* Use blue, green, red order for pixels. */\nPNG_EXPORT(30, void, png_set_bgr, (png_structrp png_ptr));\n#endif\n\n#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED\n/* Expand the grayscale to 24-bit RGB if necessary. */\nPNG_EXPORT(31, void, png_set_gray_to_rgb, (png_structrp png_ptr));\n#endif\n\n#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED\n/* Reduce RGB to grayscale. */\n#define PNG_ERROR_ACTION_NONE  1\n#define PNG_ERROR_ACTION_WARN  2\n#define PNG_ERROR_ACTION_ERROR 3\n#define PNG_RGB_TO_GRAY_DEFAULT (-1)/*for red/green coefficients*/\n\nPNG_FP_EXPORT(32, void, png_set_rgb_to_gray, (png_structrp png_ptr,\n    int error_action, double red, double green))\nPNG_FIXED_EXPORT(33, void, png_set_rgb_to_gray_fixed, (png_structrp png_ptr,\n    int error_action, png_fixed_point red, png_fixed_point green))\n\nPNG_EXPORT(34, png_byte, png_get_rgb_to_gray_status, (png_const_structrp\n    png_ptr));\n#endif\n\n#ifdef PNG_BUILD_GRAYSCALE_PALETTE_SUPPORTED\nPNG_EXPORT(35, void, png_build_grayscale_palette, (int bit_depth,\n    png_colorp palette));\n#endif\n\n#ifdef PNG_READ_ALPHA_MODE_SUPPORTED\n/* How the alpha channel is interpreted - this affects how the color channels\n * of a PNG file are returned to the calling application when an alpha channel,\n * or a tRNS chunk in a palette file, is present.\n *\n * This has no effect on the way pixels are written into a PNG output\n * datastream. The color samples in a PNG datastream are never premultiplied\n * with the alpha samples.\n *\n * The default is to return data according to the PNG specification: the alpha\n * channel is a linear measure of the contribution of the pixel to the\n * corresponding composited pixel, and the color channels are unassociated\n * (not premultiplied).  The gamma encoded color channels must be scaled\n * according to the contribution and to do this it is necessary to undo\n * the encoding, scale the color values, perform the composition and reencode\n * the values.  This is the 'PNG' mode.\n *\n * The alternative is to 'associate' the alpha with the color information by\n * storing color channel values that have been scaled by the alpha.\n * image.  These are the 'STANDARD', 'ASSOCIATED' or 'PREMULTIPLIED' modes\n * (the latter being the two common names for associated alpha color channels).\n *\n * For the 'OPTIMIZED' mode, a pixel is treated as opaque only if the alpha\n * value is equal to the maximum value.\n *\n * The final choice is to gamma encode the alpha channel as well.  This is\n * broken because, in practice, no implementation that uses this choice\n * correctly undoes the encoding before handling alpha composition.  Use this\n * choice only if other serious errors in the software or hardware you use\n * mandate it; the typical serious error is for dark halos to appear around\n * opaque areas of the composited PNG image because of arithmetic overflow.\n *\n * The API function png_set_alpha_mode specifies which of these choices to use\n * with an enumerated 'mode' value and the gamma of the required output:\n */\n#define PNG_ALPHA_PNG           0 /* according to the PNG standard */\n#define PNG_ALPHA_STANDARD      1 /* according to Porter/Duff */\n#define PNG_ALPHA_ASSOCIATED    1 /* as above; this is the normal practice */\n#define PNG_ALPHA_PREMULTIPLIED 1 /* as above */\n#define PNG_ALPHA_OPTIMIZED     2 /* 'PNG' for opaque pixels, else 'STANDARD' */\n#define PNG_ALPHA_BROKEN        3 /* the alpha channel is gamma encoded */\n\nPNG_FP_EXPORT(227, void, png_set_alpha_mode, (png_structrp png_ptr, int mode,\n    double output_gamma))\nPNG_FIXED_EXPORT(228, void, png_set_alpha_mode_fixed, (png_structrp png_ptr,\n    int mode, png_fixed_point output_gamma))\n#endif\n\n#if defined(PNG_GAMMA_SUPPORTED) || defined(PNG_READ_ALPHA_MODE_SUPPORTED)\n/* The output_gamma value is a screen gamma in libpng terminology: it expresses\n * how to decode the output values, not how they are encoded.\n */\n#define PNG_DEFAULT_sRGB -1       /* sRGB gamma and color space */\n#define PNG_GAMMA_MAC_18 -2       /* Old Mac '1.8' gamma and color space */\n#define PNG_GAMMA_sRGB   220000   /* Television standards--matches sRGB gamma */\n#define PNG_GAMMA_LINEAR PNG_FP_1 /* Linear */\n#endif\n\n/* The following are examples of calls to png_set_alpha_mode to achieve the\n * required overall gamma correction and, where necessary, alpha\n * premultiplication.\n *\n * png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_DEFAULT_sRGB);\n *    This is the default libpng handling of the alpha channel - it is not\n *    pre-multiplied into the color components.  In addition the call states\n *    that the output is for a sRGB system and causes all PNG files without gAMA\n *    chunks to be assumed to be encoded using sRGB.\n *\n * png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_GAMMA_MAC);\n *    In this case the output is assumed to be something like an sRGB conformant\n *    display preceeded by a power-law lookup table of power 1.45.  This is how\n *    early Mac systems behaved.\n *\n * png_set_alpha_mode(pp, PNG_ALPHA_STANDARD, PNG_GAMMA_LINEAR);\n *    This is the classic Jim Blinn approach and will work in academic\n *    environments where everything is done by the book.  It has the shortcoming\n *    of assuming that input PNG data with no gamma information is linear - this\n *    is unlikely to be correct unless the PNG files where generated locally.\n *    Most of the time the output precision will be so low as to show\n *    significant banding in dark areas of the image.\n *\n * png_set_expand_16(pp);\n * png_set_alpha_mode(pp, PNG_ALPHA_STANDARD, PNG_DEFAULT_sRGB);\n *    This is a somewhat more realistic Jim Blinn inspired approach.  PNG files\n *    are assumed to have the sRGB encoding if not marked with a gamma value and\n *    the output is always 16 bits per component.  This permits accurate scaling\n *    and processing of the data.  If you know that your input PNG files were\n *    generated locally you might need to replace PNG_DEFAULT_sRGB with the\n *    correct value for your system.\n *\n * png_set_alpha_mode(pp, PNG_ALPHA_OPTIMIZED, PNG_DEFAULT_sRGB);\n *    If you just need to composite the PNG image onto an existing background\n *    and if you control the code that does this you can use the optimization\n *    setting.  In this case you just copy completely opaque pixels to the\n *    output.  For pixels that are not completely transparent (you just skip\n *    those) you do the composition math using png_composite or png_composite_16\n *    below then encode the resultant 8-bit or 16-bit values to match the output\n *    encoding.\n *\n * Other cases\n *    If neither the PNG nor the standard linear encoding work for you because\n *    of the software or hardware you use then you have a big problem.  The PNG\n *    case will probably result in halos around the image.  The linear encoding\n *    will probably result in a washed out, too bright, image (it's actually too\n *    contrasty.)  Try the ALPHA_OPTIMIZED mode above - this will probably\n *    substantially reduce the halos.  Alternatively try:\n *\n * png_set_alpha_mode(pp, PNG_ALPHA_BROKEN, PNG_DEFAULT_sRGB);\n *    This option will also reduce the halos, but there will be slight dark\n *    halos round the opaque parts of the image where the background is light.\n *    In the OPTIMIZED mode the halos will be light halos where the background\n *    is dark.  Take your pick - the halos are unavoidable unless you can get\n *    your hardware/software fixed!  (The OPTIMIZED approach is slightly\n *    faster.)\n *\n * When the default gamma of PNG files doesn't match the output gamma.\n *    If you have PNG files with no gamma information png_set_alpha_mode allows\n *    you to provide a default gamma, but it also sets the ouput gamma to the\n *    matching value.  If you know your PNG files have a gamma that doesn't\n *    match the output you can take advantage of the fact that\n *    png_set_alpha_mode always sets the output gamma but only sets the PNG\n *    default if it is not already set:\n *\n * png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_DEFAULT_sRGB);\n * png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_GAMMA_MAC);\n *    The first call sets both the default and the output gamma values, the\n *    second call overrides the output gamma without changing the default.  This\n *    is easier than achieving the same effect with png_set_gamma.  You must use\n *    PNG_ALPHA_PNG for the first call - internal checking in png_set_alpha will\n *    fire if more than one call to png_set_alpha_mode and png_set_background is\n *    made in the same read operation, however multiple calls with PNG_ALPHA_PNG\n *    are ignored.\n */\n\n#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED\nPNG_EXPORT(36, void, png_set_strip_alpha, (png_structrp png_ptr));\n#endif\n\n#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) || \\\n    defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED)\nPNG_EXPORT(37, void, png_set_swap_alpha, (png_structrp png_ptr));\n#endif\n\n#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) || \\\n    defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED)\nPNG_EXPORT(38, void, png_set_invert_alpha, (png_structrp png_ptr));\n#endif\n\n#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED)\n/* Add a filler byte to 8-bit Gray or 24-bit RGB images. */\nPNG_EXPORT(39, void, png_set_filler, (png_structrp png_ptr, png_uint_32 filler,\n    int flags));\n/* The values of the PNG_FILLER_ defines should NOT be changed */\n#  define PNG_FILLER_BEFORE 0\n#  define PNG_FILLER_AFTER 1\n/* Add an alpha byte to 8-bit Gray or 24-bit RGB images. */\nPNG_EXPORT(40, void, png_set_add_alpha, (png_structrp png_ptr,\n    png_uint_32 filler, int flags));\n#endif /* PNG_READ_FILLER_SUPPORTED || PNG_WRITE_FILLER_SUPPORTED */\n\n#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED)\n/* Swap bytes in 16-bit depth files. */\nPNG_EXPORT(41, void, png_set_swap, (png_structrp png_ptr));\n#endif\n\n#if defined(PNG_READ_PACK_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED)\n/* Use 1 byte per pixel in 1, 2, or 4-bit depth files. */\nPNG_EXPORT(42, void, png_set_packing, (png_structrp png_ptr));\n#endif\n\n#if defined(PNG_READ_PACKSWAP_SUPPORTED) || \\\n    defined(PNG_WRITE_PACKSWAP_SUPPORTED)\n/* Swap packing order of pixels in bytes. */\nPNG_EXPORT(43, void, png_set_packswap, (png_structrp png_ptr));\n#endif\n\n#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED)\n/* Converts files to legal bit depths. */\nPNG_EXPORT(44, void, png_set_shift, (png_structrp png_ptr, png_const_color_8p\n    true_bits));\n#endif\n\n#if defined(PNG_READ_INTERLACING_SUPPORTED) || \\\n    defined(PNG_WRITE_INTERLACING_SUPPORTED)\n/* Have the code handle the interlacing.  Returns the number of passes.\n * MUST be called before png_read_update_info or png_start_read_image,\n * otherwise it will not have the desired effect.  Note that it is still\n * necessary to call png_read_row or png_read_rows png_get_image_height\n * times for each pass.\n*/\nPNG_EXPORT(45, int, png_set_interlace_handling, (png_structrp png_ptr));\n#endif\n\n#if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED)\n/* Invert monochrome files */\nPNG_EXPORT(46, void, png_set_invert_mono, (png_structrp png_ptr));\n#endif\n\n#ifdef PNG_READ_BACKGROUND_SUPPORTED\n/* Handle alpha and tRNS by replacing with a background color.  Prior to\n * libpng-1.5.4 this API must not be called before the PNG file header has been\n * read.  Doing so will result in unexpected behavior and possible warnings or\n * errors if the PNG file contains a bKGD chunk.\n */\nPNG_FP_EXPORT(47, void, png_set_background, (png_structrp png_ptr,\n    png_const_color_16p background_color, int background_gamma_code,\n    int need_expand, double background_gamma))\nPNG_FIXED_EXPORT(215, void, png_set_background_fixed, (png_structrp png_ptr,\n    png_const_color_16p background_color, int background_gamma_code,\n    int need_expand, png_fixed_point background_gamma))\n#endif\n#ifdef PNG_READ_BACKGROUND_SUPPORTED\n#  define PNG_BACKGROUND_GAMMA_UNKNOWN 0\n#  define PNG_BACKGROUND_GAMMA_SCREEN  1\n#  define PNG_BACKGROUND_GAMMA_FILE    2\n#  define PNG_BACKGROUND_GAMMA_UNIQUE  3\n#endif\n\n#ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED\n/* Scale a 16-bit depth file down to 8-bit, accurately. */\nPNG_EXPORT(229, void, png_set_scale_16, (png_structrp png_ptr));\n#endif\n\n#ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED\n#define PNG_READ_16_TO_8 SUPPORTED /* Name prior to 1.5.4 */\n/* Strip the second byte of information from a 16-bit depth file. */\nPNG_EXPORT(48, void, png_set_strip_16, (png_structrp png_ptr));\n#endif\n\n#ifdef PNG_READ_QUANTIZE_SUPPORTED\n/* Turn on quantizing, and reduce the palette to the number of colors\n * available.\n */\nPNG_EXPORT(49, void, png_set_quantize, (png_structrp png_ptr,\n    png_colorp palette, int num_palette, int maximum_colors,\n    png_const_uint_16p histogram, int full_quantize));\n#endif\n\n#ifdef PNG_READ_GAMMA_SUPPORTED\n/* The threshold on gamma processing is configurable but hard-wired into the\n * library.  The following is the floating point variant.\n */\n#define PNG_GAMMA_THRESHOLD (PNG_GAMMA_THRESHOLD_FIXED*.00001)\n\n/* Handle gamma correction. Screen_gamma=(display_exponent).\n * NOTE: this API simply sets the screen and file gamma values. It will\n * therefore override the value for gamma in a PNG file if it is called after\n * the file header has been read - use with care  - call before reading the PNG\n * file for best results!\n *\n * These routines accept the same gamma values as png_set_alpha_mode (described\n * above).  The PNG_GAMMA_ defines and PNG_DEFAULT_sRGB can be passed to either\n * API (floating point or fixed.)  Notice, however, that the 'file_gamma' value\n * is the inverse of a 'screen gamma' value.\n */\nPNG_FP_EXPORT(50, void, png_set_gamma, (png_structrp png_ptr,\n    double screen_gamma, double override_file_gamma))\nPNG_FIXED_EXPORT(208, void, png_set_gamma_fixed, (png_structrp png_ptr,\n    png_fixed_point screen_gamma, png_fixed_point override_file_gamma))\n#endif\n\n#ifdef PNG_WRITE_FLUSH_SUPPORTED\n/* Set how many lines between output flushes - 0 for no flushing */\nPNG_EXPORT(51, void, png_set_flush, (png_structrp png_ptr, int nrows));\n/* Flush the current PNG output buffer */\nPNG_EXPORT(52, void, png_write_flush, (png_structrp png_ptr));\n#endif\n\n/* Optional update palette with requested transformations */\nPNG_EXPORT(53, void, png_start_read_image, (png_structrp png_ptr));\n\n/* Optional call to update the users info structure */\nPNG_EXPORT(54, void, png_read_update_info, (png_structrp png_ptr,\n    png_inforp info_ptr));\n\n#ifdef PNG_SEQUENTIAL_READ_SUPPORTED\n/* Read one or more rows of image data. */\nPNG_EXPORT(55, void, png_read_rows, (png_structrp png_ptr, png_bytepp row,\n    png_bytepp display_row, png_uint_32 num_rows));\n#endif\n\n#ifdef PNG_SEQUENTIAL_READ_SUPPORTED\n/* Read a row of data. */\nPNG_EXPORT(56, void, png_read_row, (png_structrp png_ptr, png_bytep row,\n    png_bytep display_row));\n#endif\n\n#ifdef PNG_SEQUENTIAL_READ_SUPPORTED\n/* Read the whole image into memory at once. */\nPNG_EXPORT(57, void, png_read_image, (png_structrp png_ptr, png_bytepp image));\n#endif\n\n/* Write a row of image data */\nPNG_EXPORT(58, void, png_write_row, (png_structrp png_ptr,\n    png_const_bytep row));\n\n/* Write a few rows of image data: (*row) is not written; however, the type\n * is declared as writeable to maintain compatibility with previous versions\n * of libpng and to allow the 'display_row' array from read_rows to be passed\n * unchanged to write_rows.\n */\nPNG_EXPORT(59, void, png_write_rows, (png_structrp png_ptr, png_bytepp row,\n    png_uint_32 num_rows));\n\n/* Write the image data */\nPNG_EXPORT(60, void, png_write_image, (png_structrp png_ptr, png_bytepp image));\n\n/* Write the end of the PNG file. */\nPNG_EXPORT(61, void, png_write_end, (png_structrp png_ptr,\n    png_inforp info_ptr));\n\n#ifdef PNG_SEQUENTIAL_READ_SUPPORTED\n/* Read the end of the PNG file. */\nPNG_EXPORT(62, void, png_read_end, (png_structrp png_ptr, png_inforp info_ptr));\n#endif\n\n/* Free any memory associated with the png_info_struct */\nPNG_EXPORT(63, void, png_destroy_info_struct, (png_const_structrp png_ptr,\n    png_infopp info_ptr_ptr));\n\n/* Free any memory associated with the png_struct and the png_info_structs */\nPNG_EXPORT(64, void, png_destroy_read_struct, (png_structpp png_ptr_ptr,\n    png_infopp info_ptr_ptr, png_infopp end_info_ptr_ptr));\n\n/* Free any memory associated with the png_struct and the png_info_structs */\nPNG_EXPORT(65, void, png_destroy_write_struct, (png_structpp png_ptr_ptr,\n    png_infopp info_ptr_ptr));\n\n/* Set the libpng method of handling chunk CRC errors */\nPNG_EXPORT(66, void, png_set_crc_action, (png_structrp png_ptr, int crit_action,\n    int ancil_action));\n\n/* Values for png_set_crc_action() say how to handle CRC errors in\n * ancillary and critical chunks, and whether to use the data contained\n * therein.  Note that it is impossible to \"discard\" data in a critical\n * chunk.  For versions prior to 0.90, the action was always error/quit,\n * whereas in version 0.90 and later, the action for CRC errors in ancillary\n * chunks is warn/discard.  These values should NOT be changed.\n *\n *      value                       action:critical     action:ancillary\n */\n#define PNG_CRC_DEFAULT       0  /* error/quit          warn/discard data */\n#define PNG_CRC_ERROR_QUIT    1  /* error/quit          error/quit        */\n#define PNG_CRC_WARN_DISCARD  2  /* (INVALID)           warn/discard data */\n#define PNG_CRC_WARN_USE      3  /* warn/use data       warn/use data     */\n#define PNG_CRC_QUIET_USE     4  /* quiet/use data      quiet/use data    */\n#define PNG_CRC_NO_CHANGE     5  /* use current value   use current value */\n\n/* These functions give the user control over the scan-line filtering in\n * libpng and the compression methods used by zlib.  These functions are\n * mainly useful for testing, as the defaults should work with most users.\n * Those users who are tight on memory or want faster performance at the\n * expense of compression can modify them.  See the compression library\n * header file (zlib.h) for an explination of the compression functions.\n */\n\n/* Set the filtering method(s) used by libpng.  Currently, the only valid\n * value for \"method\" is 0.\n */\nPNG_EXPORT(67, void, png_set_filter, (png_structrp png_ptr, int method,\n    int filters));\n\n/* Flags for png_set_filter() to say which filters to use.  The flags\n * are chosen so that they don't conflict with real filter types\n * below, in case they are supplied instead of the #defined constants.\n * These values should NOT be changed.\n */\n#define PNG_NO_FILTERS     0x00\n#define PNG_FILTER_NONE    0x08\n#define PNG_FILTER_SUB     0x10\n#define PNG_FILTER_UP      0x20\n#define PNG_FILTER_AVG     0x40\n#define PNG_FILTER_PAETH   0x80\n#define PNG_ALL_FILTERS (PNG_FILTER_NONE | PNG_FILTER_SUB | PNG_FILTER_UP | \\\n                         PNG_FILTER_AVG | PNG_FILTER_PAETH)\n\n/* Filter values (not flags) - used in pngwrite.c, pngwutil.c for now.\n * These defines should NOT be changed.\n */\n#define PNG_FILTER_VALUE_NONE  0\n#define PNG_FILTER_VALUE_SUB   1\n#define PNG_FILTER_VALUE_UP    2\n#define PNG_FILTER_VALUE_AVG   3\n#define PNG_FILTER_VALUE_PAETH 4\n#define PNG_FILTER_VALUE_LAST  5\n\n#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED /* EXPERIMENTAL */\n/* The \"heuristic_method\" is given by one of the PNG_FILTER_HEURISTIC_\n * defines, either the default (minimum-sum-of-absolute-differences), or\n * the experimental method (weighted-minimum-sum-of-absolute-differences).\n *\n * Weights are factors >= 1.0, indicating how important it is to keep the\n * filter type consistent between rows.  Larger numbers mean the current\n * filter is that many times as likely to be the same as the \"num_weights\"\n * previous filters.  This is cumulative for each previous row with a weight.\n * There needs to be \"num_weights\" values in \"filter_weights\", or it can be\n * NULL if the weights aren't being specified.  Weights have no influence on\n * the selection of the first row filter.  Well chosen weights can (in theory)\n * improve the compression for a given image.\n *\n * Costs are factors >= 1.0 indicating the relative decoding costs of a\n * filter type.  Higher costs indicate more decoding expense, and are\n * therefore less likely to be selected over a filter with lower computational\n * costs.  There needs to be a value in \"filter_costs\" for each valid filter\n * type (given by PNG_FILTER_VALUE_LAST), or it can be NULL if you aren't\n * setting the costs.  Costs try to improve the speed of decompression without\n * unduly increasing the compressed image size.\n *\n * A negative weight or cost indicates the default value is to be used, and\n * values in the range [0.0, 1.0) indicate the value is to remain unchanged.\n * The default values for both weights and costs are currently 1.0, but may\n * change if good general weighting/cost heuristics can be found.  If both\n * the weights and costs are set to 1.0, this degenerates the WEIGHTED method\n * to the UNWEIGHTED method, but with added encoding time/computation.\n */\nPNG_FP_EXPORT(68, void, png_set_filter_heuristics, (png_structrp png_ptr,\n    int heuristic_method, int num_weights, png_const_doublep filter_weights,\n    png_const_doublep filter_costs))\nPNG_FIXED_EXPORT(209, void, png_set_filter_heuristics_fixed,\n    (png_structrp png_ptr, int heuristic_method, int num_weights,\n    png_const_fixed_point_p filter_weights,\n    png_const_fixed_point_p filter_costs))\n#endif /*  PNG_WRITE_WEIGHTED_FILTER_SUPPORTED */\n\n/* Heuristic used for row filter selection.  These defines should NOT be\n * changed.\n */\n#define PNG_FILTER_HEURISTIC_DEFAULT    0  /* Currently \"UNWEIGHTED\" */\n#define PNG_FILTER_HEURISTIC_UNWEIGHTED 1  /* Used by libpng < 0.95 */\n#define PNG_FILTER_HEURISTIC_WEIGHTED   2  /* Experimental feature */\n#define PNG_FILTER_HEURISTIC_LAST       3  /* Not a valid value */\n\n#ifdef PNG_WRITE_SUPPORTED\n/* Set the library compression level.  Currently, valid values range from\n * 0 - 9, corresponding directly to the zlib compression levels 0 - 9\n * (0 - no compression, 9 - \"maximal\" compression).  Note that tests have\n * shown that zlib compression levels 3-6 usually perform as well as level 9\n * for PNG images, and do considerably fewer caclulations.  In the future,\n * these values may not correspond directly to the zlib compression levels.\n */\nPNG_EXPORT(69, void, png_set_compression_level, (png_structrp png_ptr,\n    int level));\n\nPNG_EXPORT(70, void, png_set_compression_mem_level, (png_structrp png_ptr,\n    int mem_level));\n\nPNG_EXPORT(71, void, png_set_compression_strategy, (png_structrp png_ptr,\n    int strategy));\n\n/* If PNG_WRITE_OPTIMIZE_CMF_SUPPORTED is defined, libpng will use a\n * smaller value of window_bits if it can do so safely.\n */\nPNG_EXPORT(72, void, png_set_compression_window_bits, (png_structrp png_ptr,\n    int window_bits));\n\nPNG_EXPORT(73, void, png_set_compression_method, (png_structrp png_ptr,\n    int method));\n#endif\n\n#ifdef PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED\n/* Also set zlib parameters for compressing non-IDAT chunks */\nPNG_EXPORT(222, void, png_set_text_compression_level, (png_structrp png_ptr,\n    int level));\n\nPNG_EXPORT(223, void, png_set_text_compression_mem_level, (png_structrp png_ptr,\n    int mem_level));\n\nPNG_EXPORT(224, void, png_set_text_compression_strategy, (png_structrp png_ptr,\n    int strategy));\n\n/* If PNG_WRITE_OPTIMIZE_CMF_SUPPORTED is defined, libpng will use a\n * smaller value of window_bits if it can do so safely.\n */\nPNG_EXPORT(225, void, png_set_text_compression_window_bits,\n    (png_structrp png_ptr, int window_bits));\n\nPNG_EXPORT(226, void, png_set_text_compression_method, (png_structrp png_ptr,\n    int method));\n#endif /* PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED */\n\n/* These next functions are called for input/output, memory, and error\n * handling.  They are in the file pngrio.c, pngwio.c, and pngerror.c,\n * and call standard C I/O routines such as fread(), fwrite(), and\n * fprintf().  These functions can be made to use other I/O routines\n * at run time for those applications that need to handle I/O in a\n * different manner by calling png_set_???_fn().  See libpng-manual.txt for\n * more information.\n */\n\n#ifdef PNG_STDIO_SUPPORTED\n/* Initialize the input/output for the PNG file to the default functions. */\nPNG_EXPORT(74, void, png_init_io, (png_structrp png_ptr, png_FILE_p fp));\n#endif\n\n/* Replace the (error and abort), and warning functions with user\n * supplied functions.  If no messages are to be printed you must still\n * write and use replacement functions. The replacement error_fn should\n * still do a longjmp to the last setjmp location if you are using this\n * method of error handling.  If error_fn or warning_fn is NULL, the\n * default function will be used.\n */\n\nPNG_EXPORT(75, void, png_set_error_fn, (png_structrp png_ptr,\n    png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warning_fn));\n\n/* Return the user pointer associated with the error functions */\nPNG_EXPORT(76, png_voidp, png_get_error_ptr, (png_const_structrp png_ptr));\n\n/* Replace the default data output functions with a user supplied one(s).\n * If buffered output is not used, then output_flush_fn can be set to NULL.\n * If PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng compile time\n * output_flush_fn will be ignored (and thus can be NULL).\n * It is probably a mistake to use NULL for output_flush_fn if\n * write_data_fn is not also NULL unless you have built libpng with\n * PNG_WRITE_FLUSH_SUPPORTED undefined, because in this case libpng's\n * default flush function, which uses the standard *FILE structure, will\n * be used.\n */\nPNG_EXPORT(77, void, png_set_write_fn, (png_structrp png_ptr, png_voidp io_ptr,\n    png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn));\n\n/* Replace the default data input function with a user supplied one. */\nPNG_EXPORT(78, void, png_set_read_fn, (png_structrp png_ptr, png_voidp io_ptr,\n    png_rw_ptr read_data_fn));\n\n/* Return the user pointer associated with the I/O functions */\nPNG_EXPORT(79, png_voidp, png_get_io_ptr, (png_const_structrp png_ptr));\n\nPNG_EXPORT(80, void, png_set_read_status_fn, (png_structrp png_ptr,\n    png_read_status_ptr read_row_fn));\n\nPNG_EXPORT(81, void, png_set_write_status_fn, (png_structrp png_ptr,\n    png_write_status_ptr write_row_fn));\n\n#ifdef PNG_USER_MEM_SUPPORTED\n/* Replace the default memory allocation functions with user supplied one(s). */\nPNG_EXPORT(82, void, png_set_mem_fn, (png_structrp png_ptr, png_voidp mem_ptr,\n    png_malloc_ptr malloc_fn, png_free_ptr free_fn));\n/* Return the user pointer associated with the memory functions */\nPNG_EXPORT(83, png_voidp, png_get_mem_ptr, (png_const_structrp png_ptr));\n#endif\n\n#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED\nPNG_EXPORT(84, void, png_set_read_user_transform_fn, (png_structrp png_ptr,\n    png_user_transform_ptr read_user_transform_fn));\n#endif\n\n#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED\nPNG_EXPORT(85, void, png_set_write_user_transform_fn, (png_structrp png_ptr,\n    png_user_transform_ptr write_user_transform_fn));\n#endif\n\n#ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED\nPNG_EXPORT(86, void, png_set_user_transform_info, (png_structrp png_ptr,\n    png_voidp user_transform_ptr, int user_transform_depth,\n    int user_transform_channels));\n/* Return the user pointer associated with the user transform functions */\nPNG_EXPORT(87, png_voidp, png_get_user_transform_ptr,\n    (png_const_structrp png_ptr));\n#endif\n\n#ifdef PNG_USER_TRANSFORM_INFO_SUPPORTED\n/* Return information about the row currently being processed.  Note that these\n * APIs do not fail but will return unexpected results if called outside a user\n * transform callback.  Also note that when transforming an interlaced image the\n * row number is the row number within the sub-image of the interlace pass, so\n * the value will increase to the height of the sub-image (not the full image)\n * then reset to 0 for the next pass.\n *\n * Use PNG_ROW_FROM_PASS_ROW(row, pass) and PNG_COL_FROM_PASS_COL(col, pass) to\n * find the output pixel (x,y) given an interlaced sub-image pixel\n * (row,col,pass).  (See below for these macros.)\n */\nPNG_EXPORT(217, png_uint_32, png_get_current_row_number, (png_const_structrp));\nPNG_EXPORT(218, png_byte, png_get_current_pass_number, (png_const_structrp));\n#endif\n\n#ifdef PNG_READ_USER_CHUNKS_SUPPORTED\n/* This callback is called only for *unknown* chunks.  If\n * PNG_HANDLE_AS_UNKNOWN_SUPPORTED is set then it is possible to set known\n * chunks to be treated as unknown, however in this case the callback must do\n * any processing required by the chunk (e.g. by calling the appropriate\n * png_set_ APIs.)\n *\n * There is no write support - on write, by default, all the chunks in the\n * 'unknown' list are written in the specified position.\n *\n * The integer return from the callback function is interpreted thus:\n *\n * negative: An error occured, png_chunk_error will be called.\n *     zero: The chunk was not handled, the chunk will be saved. A critical\n *           chunk will cause an error at this point unless it is to be saved.\n * positive: The chunk was handled, libpng will ignore/discard it.\n *\n * See \"INTERACTION WTIH USER CHUNK CALLBACKS\" below for important notes about\n * how this behavior will change in libpng 1.7\n */\nPNG_EXPORT(88, void, png_set_read_user_chunk_fn, (png_structrp png_ptr,\n    png_voidp user_chunk_ptr, png_user_chunk_ptr read_user_chunk_fn));\n#endif\n\n#ifdef PNG_USER_CHUNKS_SUPPORTED\nPNG_EXPORT(89, png_voidp, png_get_user_chunk_ptr, (png_const_structrp png_ptr));\n#endif\n\n#ifdef PNG_PROGRESSIVE_READ_SUPPORTED\n/* Sets the function callbacks for the push reader, and a pointer to a\n * user-defined structure available to the callback functions.\n */\nPNG_EXPORT(90, void, png_set_progressive_read_fn, (png_structrp png_ptr,\n    png_voidp progressive_ptr, png_progressive_info_ptr info_fn,\n    png_progressive_row_ptr row_fn, png_progressive_end_ptr end_fn));\n\n/* Returns the user pointer associated with the push read functions */\nPNG_EXPORT(91, png_voidp, png_get_progressive_ptr,\n    (png_const_structrp png_ptr));\n\n/* Function to be called when data becomes available */\nPNG_EXPORT(92, void, png_process_data, (png_structrp png_ptr,\n    png_inforp info_ptr, png_bytep buffer, png_size_t buffer_size));\n\n/* A function which may be called *only* within png_process_data to stop the\n * processing of any more data.  The function returns the number of bytes\n * remaining, excluding any that libpng has cached internally.  A subsequent\n * call to png_process_data must supply these bytes again.  If the argument\n * 'save' is set to true the routine will first save all the pending data and\n * will always return 0.\n */\nPNG_EXPORT(219, png_size_t, png_process_data_pause, (png_structrp, int save));\n\n/* A function which may be called *only* outside (after) a call to\n * png_process_data.  It returns the number of bytes of data to skip in the\n * input.  Normally it will return 0, but if it returns a non-zero value the\n * application must skip than number of bytes of input data and pass the\n * following data to the next call to png_process_data.\n */\nPNG_EXPORT(220, png_uint_32, png_process_data_skip, (png_structrp));\n\n#ifdef PNG_READ_INTERLACING_SUPPORTED\n/* Function that combines rows.  'new_row' is a flag that should come from\n * the callback and be non-NULL if anything needs to be done; the library\n * stores its own version of the new data internally and ignores the passed\n * in value.\n */\nPNG_EXPORT(93, void, png_progressive_combine_row, (png_const_structrp png_ptr,\n    png_bytep old_row, png_const_bytep new_row));\n#endif /* PNG_READ_INTERLACING_SUPPORTED */\n#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */\n\nPNG_EXPORTA(94, png_voidp, png_malloc, (png_const_structrp png_ptr,\n    png_alloc_size_t size), PNG_ALLOCATED);\n/* Added at libpng version 1.4.0 */\nPNG_EXPORTA(95, png_voidp, png_calloc, (png_const_structrp png_ptr,\n    png_alloc_size_t size), PNG_ALLOCATED);\n\n/* Added at libpng version 1.2.4 */\nPNG_EXPORTA(96, png_voidp, png_malloc_warn, (png_const_structrp png_ptr,\n    png_alloc_size_t size), PNG_ALLOCATED);\n\n/* Frees a pointer allocated by png_malloc() */\nPNG_EXPORT(97, void, png_free, (png_const_structrp png_ptr, png_voidp ptr));\n\n/* Free data that was allocated internally */\nPNG_EXPORT(98, void, png_free_data, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 free_me, int num));\n\n/* Reassign responsibility for freeing existing data, whether allocated\n * by libpng or by the application; this works on the png_info structure passed\n * in, it does not change the state for other png_info structures.\n *\n * It is unlikely that this function works correctly as of 1.6.0 and using it\n * may result either in memory leaks or double free of allocated data.\n */\nPNG_EXPORT(99, void, png_data_freer, (png_const_structrp png_ptr,\n    png_inforp info_ptr, int freer, png_uint_32 mask));\n\n/* Assignments for png_data_freer */\n#define PNG_DESTROY_WILL_FREE_DATA 1\n#define PNG_SET_WILL_FREE_DATA 1\n#define PNG_USER_WILL_FREE_DATA 2\n/* Flags for png_ptr->free_me and info_ptr->free_me */\n#define PNG_FREE_HIST 0x0008\n#define PNG_FREE_ICCP 0x0010\n#define PNG_FREE_SPLT 0x0020\n#define PNG_FREE_ROWS 0x0040\n#define PNG_FREE_PCAL 0x0080\n#define PNG_FREE_SCAL 0x0100\n#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED\n#  define PNG_FREE_UNKN 0x0200\n#endif\n/*      PNG_FREE_LIST 0x0400    removed in 1.6.0 because it is ignored */\n#define PNG_FREE_PLTE 0x1000\n#define PNG_FREE_TRNS 0x2000\n#define PNG_FREE_TEXT 0x4000\n#define PNG_FREE_ALL  0x7fff\n#define PNG_FREE_MUL  0x4220 /* PNG_FREE_SPLT|PNG_FREE_TEXT|PNG_FREE_UNKN */\n\n#ifdef PNG_USER_MEM_SUPPORTED\nPNG_EXPORTA(100, png_voidp, png_malloc_default, (png_const_structrp png_ptr,\n    png_alloc_size_t size), PNG_ALLOCATED PNG_DEPRECATED);\nPNG_EXPORTA(101, void, png_free_default, (png_const_structrp png_ptr,\n    png_voidp ptr), PNG_DEPRECATED);\n#endif\n\n#ifdef PNG_ERROR_TEXT_SUPPORTED\n/* Fatal error in PNG image of libpng - can't continue */\nPNG_EXPORTA(102, void, png_error, (png_const_structrp png_ptr,\n    png_const_charp error_message), PNG_NORETURN);\n\n/* The same, but the chunk name is prepended to the error string. */\nPNG_EXPORTA(103, void, png_chunk_error, (png_const_structrp png_ptr,\n    png_const_charp error_message), PNG_NORETURN);\n\n#else\n/* Fatal error in PNG image of libpng - can't continue */\nPNG_EXPORTA(104, void, png_err, (png_const_structrp png_ptr), PNG_NORETURN);\n#  define png_error(s1,s2) png_err(s1)\n#  define png_chunk_error(s1,s2) png_err(s1)\n#endif\n\n#ifdef PNG_WARNINGS_SUPPORTED\n/* Non-fatal error in libpng.  Can continue, but may have a problem. */\nPNG_EXPORT(105, void, png_warning, (png_const_structrp png_ptr,\n    png_const_charp warning_message));\n\n/* Non-fatal error in libpng, chunk name is prepended to message. */\nPNG_EXPORT(106, void, png_chunk_warning, (png_const_structrp png_ptr,\n    png_const_charp warning_message));\n#else\n#  define png_warning(s1,s2) ((void)(s1))\n#  define png_chunk_warning(s1,s2) ((void)(s1))\n#endif\n\n#ifdef PNG_BENIGN_ERRORS_SUPPORTED\n/* Benign error in libpng.  Can continue, but may have a problem.\n * User can choose whether to handle as a fatal error or as a warning. */\nPNG_EXPORT(107, void, png_benign_error, (png_const_structrp png_ptr,\n    png_const_charp warning_message));\n\n#ifdef PNG_READ_SUPPORTED\n/* Same, chunk name is prepended to message (only during read) */\nPNG_EXPORT(108, void, png_chunk_benign_error, (png_const_structrp png_ptr,\n    png_const_charp warning_message));\n#endif\n\nPNG_EXPORT(109, void, png_set_benign_errors,\n    (png_structrp png_ptr, int allowed));\n#else\n#  ifdef PNG_ALLOW_BENIGN_ERRORS\n#    define png_benign_error png_warning\n#    define png_chunk_benign_error png_chunk_warning\n#  else\n#    define png_benign_error png_error\n#    define png_chunk_benign_error png_chunk_error\n#  endif\n#endif\n\n/* The png_set_<chunk> functions are for storing values in the png_info_struct.\n * Similarly, the png_get_<chunk> calls are used to read values from the\n * png_info_struct, either storing the parameters in the passed variables, or\n * setting pointers into the png_info_struct where the data is stored.  The\n * png_get_<chunk> functions return a non-zero value if the data was available\n * in info_ptr, or return zero and do not change any of the parameters if the\n * data was not available.\n *\n * These functions should be used instead of directly accessing png_info\n * to avoid problems with future changes in the size and internal layout of\n * png_info_struct.\n */\n/* Returns \"flag\" if chunk data is valid in info_ptr. */\nPNG_EXPORT(110, png_uint_32, png_get_valid, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr, png_uint_32 flag));\n\n/* Returns number of bytes needed to hold a transformed row. */\nPNG_EXPORT(111, png_size_t, png_get_rowbytes, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr));\n\n#ifdef PNG_INFO_IMAGE_SUPPORTED\n/* Returns row_pointers, which is an array of pointers to scanlines that was\n * returned from png_read_png().\n */\nPNG_EXPORT(112, png_bytepp, png_get_rows, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr));\n\n/* Set row_pointers, which is an array of pointers to scanlines for use\n * by png_write_png().\n */\nPNG_EXPORT(113, void, png_set_rows, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_bytepp row_pointers));\n#endif\n\n/* Returns number of color channels in image. */\nPNG_EXPORT(114, png_byte, png_get_channels, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr));\n\n#ifdef PNG_EASY_ACCESS_SUPPORTED\n/* Returns image width in pixels. */\nPNG_EXPORT(115, png_uint_32, png_get_image_width, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr));\n\n/* Returns image height in pixels. */\nPNG_EXPORT(116, png_uint_32, png_get_image_height, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr));\n\n/* Returns image bit_depth. */\nPNG_EXPORT(117, png_byte, png_get_bit_depth, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr));\n\n/* Returns image color_type. */\nPNG_EXPORT(118, png_byte, png_get_color_type, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr));\n\n/* Returns image filter_type. */\nPNG_EXPORT(119, png_byte, png_get_filter_type, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr));\n\n/* Returns image interlace_type. */\nPNG_EXPORT(120, png_byte, png_get_interlace_type, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr));\n\n/* Returns image compression_type. */\nPNG_EXPORT(121, png_byte, png_get_compression_type, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr));\n\n/* Returns image resolution in pixels per meter, from pHYs chunk data. */\nPNG_EXPORT(122, png_uint_32, png_get_pixels_per_meter,\n    (png_const_structrp png_ptr, png_const_inforp info_ptr));\nPNG_EXPORT(123, png_uint_32, png_get_x_pixels_per_meter,\n    (png_const_structrp png_ptr, png_const_inforp info_ptr));\nPNG_EXPORT(124, png_uint_32, png_get_y_pixels_per_meter,\n    (png_const_structrp png_ptr, png_const_inforp info_ptr));\n\n/* Returns pixel aspect ratio, computed from pHYs chunk data.  */\nPNG_FP_EXPORT(125, float, png_get_pixel_aspect_ratio,\n    (png_const_structrp png_ptr, png_const_inforp info_ptr))\nPNG_FIXED_EXPORT(210, png_fixed_point, png_get_pixel_aspect_ratio_fixed,\n    (png_const_structrp png_ptr, png_const_inforp info_ptr))\n\n/* Returns image x, y offset in pixels or microns, from oFFs chunk data. */\nPNG_EXPORT(126, png_int_32, png_get_x_offset_pixels,\n    (png_const_structrp png_ptr, png_const_inforp info_ptr));\nPNG_EXPORT(127, png_int_32, png_get_y_offset_pixels,\n    (png_const_structrp png_ptr, png_const_inforp info_ptr));\nPNG_EXPORT(128, png_int_32, png_get_x_offset_microns,\n    (png_const_structrp png_ptr, png_const_inforp info_ptr));\nPNG_EXPORT(129, png_int_32, png_get_y_offset_microns,\n    (png_const_structrp png_ptr, png_const_inforp info_ptr));\n\n#endif /* PNG_EASY_ACCESS_SUPPORTED */\n\n#ifdef PNG_READ_SUPPORTED\n/* Returns pointer to signature string read from PNG header */\nPNG_EXPORT(130, png_const_bytep, png_get_signature, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr));\n#endif\n\n#ifdef PNG_bKGD_SUPPORTED\nPNG_EXPORT(131, png_uint_32, png_get_bKGD, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_color_16p *background));\n#endif\n\n#ifdef PNG_bKGD_SUPPORTED\nPNG_EXPORT(132, void, png_set_bKGD, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_const_color_16p background));\n#endif\n\n#ifdef PNG_cHRM_SUPPORTED\nPNG_FP_EXPORT(133, png_uint_32, png_get_cHRM, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr, double *white_x, double *white_y, double *red_x,\n    double *red_y, double *green_x, double *green_y, double *blue_x,\n    double *blue_y))\nPNG_FP_EXPORT(230, png_uint_32, png_get_cHRM_XYZ, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr, double *red_X, double *red_Y, double *red_Z,\n    double *green_X, double *green_Y, double *green_Z, double *blue_X,\n    double *blue_Y, double *blue_Z))\nPNG_FIXED_EXPORT(134, png_uint_32, png_get_cHRM_fixed,\n    (png_const_structrp png_ptr, png_const_inforp info_ptr,\n    png_fixed_point *int_white_x, png_fixed_point *int_white_y,\n    png_fixed_point *int_red_x, png_fixed_point *int_red_y,\n    png_fixed_point *int_green_x, png_fixed_point *int_green_y,\n    png_fixed_point *int_blue_x, png_fixed_point *int_blue_y))\nPNG_FIXED_EXPORT(231, png_uint_32, png_get_cHRM_XYZ_fixed,\n    (png_const_structrp png_ptr, png_const_inforp info_ptr,\n    png_fixed_point *int_red_X, png_fixed_point *int_red_Y,\n    png_fixed_point *int_red_Z, png_fixed_point *int_green_X,\n    png_fixed_point *int_green_Y, png_fixed_point *int_green_Z,\n    png_fixed_point *int_blue_X, png_fixed_point *int_blue_Y,\n    png_fixed_point *int_blue_Z))\n#endif\n\n#ifdef PNG_cHRM_SUPPORTED\nPNG_FP_EXPORT(135, void, png_set_cHRM, (png_const_structrp png_ptr,\n    png_inforp info_ptr,\n    double white_x, double white_y, double red_x, double red_y, double green_x,\n    double green_y, double blue_x, double blue_y))\nPNG_FP_EXPORT(232, void, png_set_cHRM_XYZ, (png_const_structrp png_ptr,\n    png_inforp info_ptr, double red_X, double red_Y, double red_Z,\n    double green_X, double green_Y, double green_Z, double blue_X,\n    double blue_Y, double blue_Z))\nPNG_FIXED_EXPORT(136, void, png_set_cHRM_fixed, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_fixed_point int_white_x,\n    png_fixed_point int_white_y, png_fixed_point int_red_x,\n    png_fixed_point int_red_y, png_fixed_point int_green_x,\n    png_fixed_point int_green_y, png_fixed_point int_blue_x,\n    png_fixed_point int_blue_y))\nPNG_FIXED_EXPORT(233, void, png_set_cHRM_XYZ_fixed, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_fixed_point int_red_X, png_fixed_point int_red_Y,\n    png_fixed_point int_red_Z, png_fixed_point int_green_X,\n    png_fixed_point int_green_Y, png_fixed_point int_green_Z,\n    png_fixed_point int_blue_X, png_fixed_point int_blue_Y,\n    png_fixed_point int_blue_Z))\n#endif\n\n#ifdef PNG_gAMA_SUPPORTED\nPNG_FP_EXPORT(137, png_uint_32, png_get_gAMA, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr, double *file_gamma))\nPNG_FIXED_EXPORT(138, png_uint_32, png_get_gAMA_fixed,\n    (png_const_structrp png_ptr, png_const_inforp info_ptr,\n    png_fixed_point *int_file_gamma))\n#endif\n\n#ifdef PNG_gAMA_SUPPORTED\nPNG_FP_EXPORT(139, void, png_set_gAMA, (png_const_structrp png_ptr,\n    png_inforp info_ptr, double file_gamma))\nPNG_FIXED_EXPORT(140, void, png_set_gAMA_fixed, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_fixed_point int_file_gamma))\n#endif\n\n#ifdef PNG_hIST_SUPPORTED\nPNG_EXPORT(141, png_uint_32, png_get_hIST, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_uint_16p *hist));\n#endif\n\n#ifdef PNG_hIST_SUPPORTED\nPNG_EXPORT(142, void, png_set_hIST, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_const_uint_16p hist));\n#endif\n\nPNG_EXPORT(143, png_uint_32, png_get_IHDR, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr, png_uint_32 *width, png_uint_32 *height,\n    int *bit_depth, int *color_type, int *interlace_method,\n    int *compression_method, int *filter_method));\n\nPNG_EXPORT(144, void, png_set_IHDR, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 width, png_uint_32 height, int bit_depth,\n    int color_type, int interlace_method, int compression_method,\n    int filter_method));\n\n#ifdef PNG_oFFs_SUPPORTED\nPNG_EXPORT(145, png_uint_32, png_get_oFFs, (png_const_structrp png_ptr,\n   png_const_inforp info_ptr, png_int_32 *offset_x, png_int_32 *offset_y,\n   int *unit_type));\n#endif\n\n#ifdef PNG_oFFs_SUPPORTED\nPNG_EXPORT(146, void, png_set_oFFs, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_int_32 offset_x, png_int_32 offset_y,\n    int unit_type));\n#endif\n\n#ifdef PNG_pCAL_SUPPORTED\nPNG_EXPORT(147, png_uint_32, png_get_pCAL, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_charp *purpose, png_int_32 *X0,\n    png_int_32 *X1, int *type, int *nparams, png_charp *units,\n    png_charpp *params));\n#endif\n\n#ifdef PNG_pCAL_SUPPORTED\nPNG_EXPORT(148, void, png_set_pCAL, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_const_charp purpose, png_int_32 X0, png_int_32 X1,\n    int type, int nparams, png_const_charp units, png_charpp params));\n#endif\n\n#ifdef PNG_pHYs_SUPPORTED\nPNG_EXPORT(149, png_uint_32, png_get_pHYs, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr, png_uint_32 *res_x, png_uint_32 *res_y,\n    int *unit_type));\n#endif\n\n#ifdef PNG_pHYs_SUPPORTED\nPNG_EXPORT(150, void, png_set_pHYs, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 res_x, png_uint_32 res_y, int unit_type));\n#endif\n\nPNG_EXPORT(151, png_uint_32, png_get_PLTE, (png_const_structrp png_ptr,\n   png_inforp info_ptr, png_colorp *palette, int *num_palette));\n\nPNG_EXPORT(152, void, png_set_PLTE, (png_structrp png_ptr,\n    png_inforp info_ptr, png_const_colorp palette, int num_palette));\n\n#ifdef PNG_sBIT_SUPPORTED\nPNG_EXPORT(153, png_uint_32, png_get_sBIT, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_color_8p *sig_bit));\n#endif\n\n#ifdef PNG_sBIT_SUPPORTED\nPNG_EXPORT(154, void, png_set_sBIT, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_const_color_8p sig_bit));\n#endif\n\n#ifdef PNG_sRGB_SUPPORTED\nPNG_EXPORT(155, png_uint_32, png_get_sRGB, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr, int *file_srgb_intent));\n#endif\n\n#ifdef PNG_sRGB_SUPPORTED\nPNG_EXPORT(156, void, png_set_sRGB, (png_const_structrp png_ptr,\n    png_inforp info_ptr, int srgb_intent));\nPNG_EXPORT(157, void, png_set_sRGB_gAMA_and_cHRM, (png_const_structrp png_ptr,\n    png_inforp info_ptr, int srgb_intent));\n#endif\n\n#ifdef PNG_iCCP_SUPPORTED\nPNG_EXPORT(158, png_uint_32, png_get_iCCP, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_charpp name, int *compression_type,\n    png_bytepp profile, png_uint_32 *proflen));\n#endif\n\n#ifdef PNG_iCCP_SUPPORTED\nPNG_EXPORT(159, void, png_set_iCCP, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_const_charp name, int compression_type,\n    png_const_bytep profile, png_uint_32 proflen));\n#endif\n\n#ifdef PNG_sPLT_SUPPORTED\nPNG_EXPORT(160, int, png_get_sPLT, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_sPLT_tpp entries));\n#endif\n\n#ifdef PNG_sPLT_SUPPORTED\nPNG_EXPORT(161, void, png_set_sPLT, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_const_sPLT_tp entries, int nentries));\n#endif\n\n#ifdef PNG_TEXT_SUPPORTED\n/* png_get_text also returns the number of text chunks in *num_text */\nPNG_EXPORT(162, int, png_get_text, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_textp *text_ptr, int *num_text));\n#endif\n\n/* Note while png_set_text() will accept a structure whose text,\n * language, and  translated keywords are NULL pointers, the structure\n * returned by png_get_text will always contain regular\n * zero-terminated C strings.  They might be empty strings but\n * they will never be NULL pointers.\n */\n\n#ifdef PNG_TEXT_SUPPORTED\nPNG_EXPORT(163, void, png_set_text, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_const_textp text_ptr, int num_text));\n#endif\n\n#ifdef PNG_tIME_SUPPORTED\nPNG_EXPORT(164, png_uint_32, png_get_tIME, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_timep *mod_time));\n#endif\n\n#ifdef PNG_tIME_SUPPORTED\nPNG_EXPORT(165, void, png_set_tIME, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_const_timep mod_time));\n#endif\n\n#ifdef PNG_tRNS_SUPPORTED\nPNG_EXPORT(166, png_uint_32, png_get_tRNS, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_bytep *trans_alpha, int *num_trans,\n    png_color_16p *trans_color));\n#endif\n\n#ifdef PNG_tRNS_SUPPORTED\nPNG_EXPORT(167, void, png_set_tRNS, (png_structrp png_ptr,\n    png_inforp info_ptr, png_const_bytep trans_alpha, int num_trans,\n    png_const_color_16p trans_color));\n#endif\n\n#ifdef PNG_sCAL_SUPPORTED\nPNG_FP_EXPORT(168, png_uint_32, png_get_sCAL, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr, int *unit, double *width, double *height))\n#if defined(PNG_FLOATING_ARITHMETIC_SUPPORTED) || \\\n   defined(PNG_FLOATING_POINT_SUPPORTED)\n/* NOTE: this API is currently implemented using floating point arithmetic,\n * consequently it can only be used on systems with floating point support.\n * In any case the range of values supported by png_fixed_point is small and it\n * is highly recommended that png_get_sCAL_s be used instead.\n */\nPNG_FIXED_EXPORT(214, png_uint_32, png_get_sCAL_fixed,\n    (png_const_structrp png_ptr, png_const_inforp info_ptr, int *unit,\n    png_fixed_point *width, png_fixed_point *height))\n#endif\nPNG_EXPORT(169, png_uint_32, png_get_sCAL_s,\n    (png_const_structrp png_ptr, png_const_inforp info_ptr, int *unit,\n    png_charpp swidth, png_charpp sheight));\n\nPNG_FP_EXPORT(170, void, png_set_sCAL, (png_const_structrp png_ptr,\n    png_inforp info_ptr, int unit, double width, double height))\nPNG_FIXED_EXPORT(213, void, png_set_sCAL_fixed, (png_const_structrp png_ptr,\n   png_inforp info_ptr, int unit, png_fixed_point width,\n   png_fixed_point height))\nPNG_EXPORT(171, void, png_set_sCAL_s, (png_const_structrp png_ptr,\n    png_inforp info_ptr, int unit,\n    png_const_charp swidth, png_const_charp sheight));\n#endif /* PNG_sCAL_SUPPORTED */\n\n#ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED\n/* Provide the default handling for all unknown chunks or, optionally, for\n * specific unknown chunks.\n *\n * NOTE: prior to 1.6.0 the handling specified for particular chunks on read was\n * ignored and the default was used, the per-chunk setting only had an effect on\n * write.  If you wish to have chunk-specific handling on read in code that must\n * work on earlier versions you must use a user chunk callback to specify the\n * desired handling (keep or discard.)\n *\n * The 'keep' parameter is a PNG_HANDLE_CHUNK_ value as listed below.  The\n * parameter is interpreted as follows:\n *\n * READ:\n *    PNG_HANDLE_CHUNK_AS_DEFAULT:\n *       Known chunks: do normal libpng processing, do not keep the chunk (but\n *          see the comments below about PNG_HANDLE_AS_UNKNOWN_SUPPORTED)\n *       Unknown chunks: for a specific chunk use the global default, when used\n *          as the default discard the chunk data.\n *    PNG_HANDLE_CHUNK_NEVER:\n *       Discard the chunk data.\n *    PNG_HANDLE_CHUNK_IF_SAFE:\n *       Keep the chunk data if the chunk is not critical else raise a chunk\n *       error.\n *    PNG_HANDLE_CHUNK_ALWAYS:\n *       Keep the chunk data.\n *\n * If the chunk data is saved it can be retrieved using png_get_unknown_chunks,\n * below.  Notice that specifying \"AS_DEFAULT\" as a global default is equivalent\n * to specifying \"NEVER\", however when \"AS_DEFAULT\" is used for specific chunks\n * it simply resets the behavior to the libpng default.\n *\n * INTERACTION WTIH USER CHUNK CALLBACKS:\n * The per-chunk handling is always used when there is a png_user_chunk_ptr\n * callback and the callback returns 0; the chunk is then always stored *unless*\n * it is critical and the per-chunk setting is other than ALWAYS.  Notice that\n * the global default is *not* used in this case.  (In effect the per-chunk\n * value is incremented to at least IF_SAFE.)\n *\n * IMPORTANT NOTE: this behavior will change in libpng 1.7 - the global and\n * per-chunk defaults will be honored.  If you want to preserve the current\n * behavior when your callback returns 0 you must set PNG_HANDLE_CHUNK_IF_SAFE\n * as the default - if you don't do this libpng 1.6 will issue a warning.\n *\n * If you want unhandled unknown chunks to be discarded in libpng 1.6 and\n * earlier simply return '1' (handled).\n *\n * PNG_HANDLE_AS_UNKNOWN_SUPPORTED:\n *    If this is *not* set known chunks will always be handled by libpng and\n *    will never be stored in the unknown chunk list.  Known chunks listed to\n *    png_set_keep_unknown_chunks will have no effect.  If it is set then known\n *    chunks listed with a keep other than AS_DEFAULT will *never* be processed\n *    by libpng, in addition critical chunks must either be processed by the\n *    callback or saved.\n *\n *    The IHDR and IEND chunks must not be listed.  Because this turns off the\n *    default handling for chunks that would otherwise be recognized the\n *    behavior of libpng transformations may well become incorrect!\n *\n * WRITE:\n *    When writing chunks the options only apply to the chunks specified by\n *    png_set_unknown_chunks (below), libpng will *always* write known chunks\n *    required by png_set_ calls and will always write the core critical chunks\n *    (as required for PLTE).\n *\n *    Each chunk in the png_set_unknown_chunks list is looked up in the\n *    png_set_keep_unknown_chunks list to find the keep setting, this is then\n *    interpreted as follows:\n *\n *    PNG_HANDLE_CHUNK_AS_DEFAULT:\n *       Write safe-to-copy chunks and write other chunks if the global\n *       default is set to _ALWAYS, otherwise don't write this chunk.\n *    PNG_HANDLE_CHUNK_NEVER:\n *       Do not write the chunk.\n *    PNG_HANDLE_CHUNK_IF_SAFE:\n *       Write the chunk if it is safe-to-copy, otherwise do not write it.\n *    PNG_HANDLE_CHUNK_ALWAYS:\n *       Write the chunk.\n *\n * Note that the default behavior is effectively the opposite of the read case -\n * in read unknown chunks are not stored by default, in write they are written\n * by default.  Also the behavior of PNG_HANDLE_CHUNK_IF_SAFE is very different\n * - on write the safe-to-copy bit is checked, on read the critical bit is\n * checked and on read if the chunk is critical an error will be raised.\n *\n * num_chunks:\n * ===========\n *    If num_chunks is positive, then the \"keep\" parameter specifies the manner\n *    for handling only those chunks appearing in the chunk_list array,\n *    otherwise the chunk list array is ignored.\n *\n *    If num_chunks is 0 the \"keep\" parameter specifies the default behavior for\n *    unknown chunks, as described above.\n *\n *    If num_chunks is negative, then the \"keep\" parameter specifies the manner\n *    for handling all unknown chunks plus all chunks recognized by libpng\n *    except for the IHDR, PLTE, tRNS, IDAT, and IEND chunks (which continue to\n *    be processed by libpng.\n */\nPNG_EXPORT(172, void, png_set_keep_unknown_chunks, (png_structrp png_ptr,\n    int keep, png_const_bytep chunk_list, int num_chunks));\n\n/* The \"keep\" PNG_HANDLE_CHUNK_ parameter for the specified chunk is returned;\n * the result is therefore true (non-zero) if special handling is required,\n * false for the default handling.\n */\nPNG_EXPORT(173, int, png_handle_as_unknown, (png_const_structrp png_ptr,\n    png_const_bytep chunk_name));\n#endif\n\n#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED\nPNG_EXPORT(174, void, png_set_unknown_chunks, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_const_unknown_chunkp unknowns,\n    int num_unknowns));\n   /* NOTE: prior to 1.6.0 this routine set the 'location' field of the added\n    * unknowns to the location currently stored in the png_struct.  This is\n    * invariably the wrong value on write.  To fix this call the following API\n    * for each chunk in the list with the correct location.  If you know your\n    * code won't be compiled on earlier versions you can rely on\n    * png_set_unknown_chunks(write-ptr, png_get_unknown_chunks(read-ptr)) doing\n    * the correct thing.\n    */\n\nPNG_EXPORT(175, void, png_set_unknown_chunk_location,\n    (png_const_structrp png_ptr, png_inforp info_ptr, int chunk, int location));\n\nPNG_EXPORT(176, int, png_get_unknown_chunks, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_unknown_chunkpp entries));\n#endif\n\n/* Png_free_data() will turn off the \"valid\" flag for anything it frees.\n * If you need to turn it off for a chunk that your application has freed,\n * you can use png_set_invalid(png_ptr, info_ptr, PNG_INFO_CHNK);\n */\nPNG_EXPORT(177, void, png_set_invalid, (png_const_structrp png_ptr,\n    png_inforp info_ptr, int mask));\n\n#ifdef PNG_INFO_IMAGE_SUPPORTED\n/* The \"params\" pointer is currently not used and is for future expansion. */\n#ifdef PNG_SEQUENTIAL_READ_SUPPORTED\nPNG_EXPORT(178, void, png_read_png, (png_structrp png_ptr, png_inforp info_ptr,\n    int transforms, png_voidp params));\n#endif\n#ifdef PNG_WRITE_SUPPORTED\nPNG_EXPORT(179, void, png_write_png, (png_structrp png_ptr, png_inforp info_ptr,\n    int transforms, png_voidp params));\n#endif\n#endif\n\nPNG_EXPORT(180, png_const_charp, png_get_copyright,\n    (png_const_structrp png_ptr));\nPNG_EXPORT(181, png_const_charp, png_get_header_ver,\n    (png_const_structrp png_ptr));\nPNG_EXPORT(182, png_const_charp, png_get_header_version,\n    (png_const_structrp png_ptr));\nPNG_EXPORT(183, png_const_charp, png_get_libpng_ver,\n    (png_const_structrp png_ptr));\n\n#ifdef PNG_MNG_FEATURES_SUPPORTED\nPNG_EXPORT(184, png_uint_32, png_permit_mng_features, (png_structrp png_ptr,\n    png_uint_32 mng_features_permitted));\n#endif\n\n/* For use in png_set_keep_unknown, added to version 1.2.6 */\n#define PNG_HANDLE_CHUNK_AS_DEFAULT   0\n#define PNG_HANDLE_CHUNK_NEVER        1\n#define PNG_HANDLE_CHUNK_IF_SAFE      2\n#define PNG_HANDLE_CHUNK_ALWAYS       3\n#define PNG_HANDLE_CHUNK_LAST         4\n\n/* Strip the prepended error numbers (\"#nnn \") from error and warning\n * messages before passing them to the error or warning handler.\n */\n#ifdef PNG_ERROR_NUMBERS_SUPPORTED\nPNG_EXPORT(185, void, png_set_strip_error_numbers, (png_structrp png_ptr,\n    png_uint_32 strip_mode));\n#endif\n\n/* Added in libpng-1.2.6 */\n#ifdef PNG_SET_USER_LIMITS_SUPPORTED\nPNG_EXPORT(186, void, png_set_user_limits, (png_structrp png_ptr,\n    png_uint_32 user_width_max, png_uint_32 user_height_max));\nPNG_EXPORT(187, png_uint_32, png_get_user_width_max,\n    (png_const_structrp png_ptr));\nPNG_EXPORT(188, png_uint_32, png_get_user_height_max,\n    (png_const_structrp png_ptr));\n/* Added in libpng-1.4.0 */\nPNG_EXPORT(189, void, png_set_chunk_cache_max, (png_structrp png_ptr,\n    png_uint_32 user_chunk_cache_max));\nPNG_EXPORT(190, png_uint_32, png_get_chunk_cache_max,\n    (png_const_structrp png_ptr));\n/* Added in libpng-1.4.1 */\nPNG_EXPORT(191, void, png_set_chunk_malloc_max, (png_structrp png_ptr,\n    png_alloc_size_t user_chunk_cache_max));\nPNG_EXPORT(192, png_alloc_size_t, png_get_chunk_malloc_max,\n    (png_const_structrp png_ptr));\n#endif\n\n#if defined(PNG_INCH_CONVERSIONS_SUPPORTED)\nPNG_EXPORT(193, png_uint_32, png_get_pixels_per_inch,\n    (png_const_structrp png_ptr, png_const_inforp info_ptr));\n\nPNG_EXPORT(194, png_uint_32, png_get_x_pixels_per_inch,\n    (png_const_structrp png_ptr, png_const_inforp info_ptr));\n\nPNG_EXPORT(195, png_uint_32, png_get_y_pixels_per_inch,\n    (png_const_structrp png_ptr, png_const_inforp info_ptr));\n\nPNG_FP_EXPORT(196, float, png_get_x_offset_inches,\n    (png_const_structrp png_ptr, png_const_inforp info_ptr))\n#ifdef PNG_FIXED_POINT_SUPPORTED /* otherwise not implemented. */\nPNG_FIXED_EXPORT(211, png_fixed_point, png_get_x_offset_inches_fixed,\n    (png_const_structrp png_ptr, png_const_inforp info_ptr))\n#endif\n\nPNG_FP_EXPORT(197, float, png_get_y_offset_inches, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr))\n#ifdef PNG_FIXED_POINT_SUPPORTED /* otherwise not implemented. */\nPNG_FIXED_EXPORT(212, png_fixed_point, png_get_y_offset_inches_fixed,\n    (png_const_structrp png_ptr, png_const_inforp info_ptr))\n#endif\n\n#  ifdef PNG_pHYs_SUPPORTED\nPNG_EXPORT(198, png_uint_32, png_get_pHYs_dpi, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr, png_uint_32 *res_x, png_uint_32 *res_y,\n    int *unit_type));\n#  endif /* PNG_pHYs_SUPPORTED */\n#endif  /* PNG_INCH_CONVERSIONS_SUPPORTED */\n\n/* Added in libpng-1.4.0 */\n#ifdef PNG_IO_STATE_SUPPORTED\nPNG_EXPORT(199, png_uint_32, png_get_io_state, (png_const_structrp png_ptr));\n\n/* Removed from libpng 1.6; use png_get_io_chunk_type. */\nPNG_REMOVED(200, png_const_bytep, png_get_io_chunk_name, (png_structrp png_ptr),\n    PNG_DEPRECATED)\n\nPNG_EXPORT(216, png_uint_32, png_get_io_chunk_type,\n    (png_const_structrp png_ptr));\n\n/* The flags returned by png_get_io_state() are the following: */\n#  define PNG_IO_NONE        0x0000   /* no I/O at this moment */\n#  define PNG_IO_READING     0x0001   /* currently reading */\n#  define PNG_IO_WRITING     0x0002   /* currently writing */\n#  define PNG_IO_SIGNATURE   0x0010   /* currently at the file signature */\n#  define PNG_IO_CHUNK_HDR   0x0020   /* currently at the chunk header */\n#  define PNG_IO_CHUNK_DATA  0x0040   /* currently at the chunk data */\n#  define PNG_IO_CHUNK_CRC   0x0080   /* currently at the chunk crc */\n#  define PNG_IO_MASK_OP     0x000f   /* current operation: reading/writing */\n#  define PNG_IO_MASK_LOC    0x00f0   /* current location: sig/hdr/data/crc */\n#endif /* ?PNG_IO_STATE_SUPPORTED */\n\n/* Interlace support.  The following macros are always defined so that if\n * libpng interlace handling is turned off the macros may be used to handle\n * interlaced images within the application.\n */\n#define PNG_INTERLACE_ADAM7_PASSES 7\n\n/* Two macros to return the first row and first column of the original,\n * full, image which appears in a given pass.  'pass' is in the range 0\n * to 6 and the result is in the range 0 to 7.\n */\n#define PNG_PASS_START_ROW(pass) (((1&~(pass))<<(3-((pass)>>1)))&7)\n#define PNG_PASS_START_COL(pass) (((1& (pass))<<(3-(((pass)+1)>>1)))&7)\n\n/* A macro to return the offset between pixels in the output row for a pair of\n * pixels in the input - effectively the inverse of the 'COL_SHIFT' macro that\n * follows.  Note that ROW_OFFSET is the offset from one row to the next whereas\n * COL_OFFSET is from one column to the next, within a row.\n */\n#define PNG_PASS_ROW_OFFSET(pass) ((pass)>2?(8>>(((pass)-1)>>1)):8)\n#define PNG_PASS_COL_OFFSET(pass) (1<<((7-(pass))>>1))\n\n/* Two macros to help evaluate the number of rows or columns in each\n * pass.  This is expressed as a shift - effectively log2 of the number or\n * rows or columns in each 8x8 tile of the original image.\n */\n#define PNG_PASS_ROW_SHIFT(pass) ((pass)>2?(8-(pass))>>1:3)\n#define PNG_PASS_COL_SHIFT(pass) ((pass)>1?(7-(pass))>>1:3)\n\n/* Hence two macros to determine the number of rows or columns in a given\n * pass of an image given its height or width.  In fact these macros may\n * return non-zero even though the sub-image is empty, because the other\n * dimension may be empty for a small image.\n */\n#define PNG_PASS_ROWS(height, pass) (((height)+(((1<<PNG_PASS_ROW_SHIFT(pass))\\\n   -1)-PNG_PASS_START_ROW(pass)))>>PNG_PASS_ROW_SHIFT(pass))\n#define PNG_PASS_COLS(width, pass) (((width)+(((1<<PNG_PASS_COL_SHIFT(pass))\\\n   -1)-PNG_PASS_START_COL(pass)))>>PNG_PASS_COL_SHIFT(pass))\n\n/* For the reader row callbacks (both progressive and sequential) it is\n * necessary to find the row in the output image given a row in an interlaced\n * image, so two more macros:\n */\n#define PNG_ROW_FROM_PASS_ROW(y_in, pass) \\\n   (((y_in)<<PNG_PASS_ROW_SHIFT(pass))+PNG_PASS_START_ROW(pass))\n#define PNG_COL_FROM_PASS_COL(x_in, pass) \\\n   (((x_in)<<PNG_PASS_COL_SHIFT(pass))+PNG_PASS_START_COL(pass))\n\n/* Two macros which return a boolean (0 or 1) saying whether the given row\n * or column is in a particular pass.  These use a common utility macro that\n * returns a mask for a given pass - the offset 'off' selects the row or\n * column version.  The mask has the appropriate bit set for each column in\n * the tile.\n */\n#define PNG_PASS_MASK(pass,off) ( \\\n   ((0x110145AF>>(((7-(off))-(pass))<<2)) & 0xF) | \\\n   ((0x01145AF0>>(((7-(off))-(pass))<<2)) & 0xF0))\n\n#define PNG_ROW_IN_INTERLACE_PASS(y, pass) \\\n   ((PNG_PASS_MASK(pass,0) >> ((y)&7)) & 1)\n#define PNG_COL_IN_INTERLACE_PASS(x, pass) \\\n   ((PNG_PASS_MASK(pass,1) >> ((x)&7)) & 1)\n\n#ifdef PNG_READ_COMPOSITE_NODIV_SUPPORTED\n/* With these routines we avoid an integer divide, which will be slower on\n * most machines.  However, it does take more operations than the corresponding\n * divide method, so it may be slower on a few RISC systems.  There are two\n * shifts (by 8 or 16 bits) and an addition, versus a single integer divide.\n *\n * Note that the rounding factors are NOT supposed to be the same!  128 and\n * 32768 are correct for the NODIV code; 127 and 32767 are correct for the\n * standard method.\n *\n * [Optimized code by Greg Roelofs and Mark Adler...blame us for bugs. :-) ]\n */\n\n /* fg and bg should be in `gamma 1.0' space; alpha is the opacity */\n\n#  define png_composite(composite, fg, alpha, bg)         \\\n     { png_uint_16 temp = (png_uint_16)((png_uint_16)(fg) \\\n           * (png_uint_16)(alpha)                         \\\n           + (png_uint_16)(bg)*(png_uint_16)(255          \\\n           - (png_uint_16)(alpha)) + 128);                \\\n       (composite) = (png_byte)((temp + (temp >> 8)) >> 8); }\n\n#  define png_composite_16(composite, fg, alpha, bg)       \\\n     { png_uint_32 temp = (png_uint_32)((png_uint_32)(fg)  \\\n           * (png_uint_32)(alpha)                          \\\n           + (png_uint_32)(bg)*(65535                      \\\n           - (png_uint_32)(alpha)) + 32768);               \\\n       (composite) = (png_uint_16)((temp + (temp >> 16)) >> 16); }\n\n#else  /* Standard method using integer division */\n\n#  define png_composite(composite, fg, alpha, bg)                          \\\n     (composite) = (png_byte)(((png_uint_16)(fg) * (png_uint_16)(alpha) +  \\\n     (png_uint_16)(bg) * (png_uint_16)(255 - (png_uint_16)(alpha)) +       \\\n     127) / 255)\n\n#  define png_composite_16(composite, fg, alpha, bg)                         \\\n     (composite) = (png_uint_16)(((png_uint_32)(fg) * (png_uint_32)(alpha) + \\\n     (png_uint_32)(bg)*(png_uint_32)(65535 - (png_uint_32)(alpha)) +         \\\n     32767) / 65535)\n#endif /* PNG_READ_COMPOSITE_NODIV_SUPPORTED */\n\n#ifdef PNG_READ_INT_FUNCTIONS_SUPPORTED\nPNG_EXPORT(201, png_uint_32, png_get_uint_32, (png_const_bytep buf));\nPNG_EXPORT(202, png_uint_16, png_get_uint_16, (png_const_bytep buf));\nPNG_EXPORT(203, png_int_32, png_get_int_32, (png_const_bytep buf));\n#endif\n\nPNG_EXPORT(204, png_uint_32, png_get_uint_31, (png_const_structrp png_ptr,\n    png_const_bytep buf));\n/* No png_get_int_16 -- may be added if there's a real need for it. */\n\n/* Place a 32-bit number into a buffer in PNG byte order (big-endian). */\n#ifdef PNG_WRITE_INT_FUNCTIONS_SUPPORTED\nPNG_EXPORT(205, void, png_save_uint_32, (png_bytep buf, png_uint_32 i));\n#endif\n#ifdef PNG_SAVE_INT_32_SUPPORTED\nPNG_EXPORT(206, void, png_save_int_32, (png_bytep buf, png_int_32 i));\n#endif\n\n/* Place a 16-bit number into a buffer in PNG byte order.\n * The parameter is declared unsigned int, not png_uint_16,\n * just to avoid potential problems on pre-ANSI C compilers.\n */\n#ifdef PNG_WRITE_INT_FUNCTIONS_SUPPORTED\nPNG_EXPORT(207, void, png_save_uint_16, (png_bytep buf, unsigned int i));\n/* No png_save_int_16 -- may be added if there's a real need for it. */\n#endif\n\n#ifdef PNG_USE_READ_MACROS\n/* Inline macros to do direct reads of bytes from the input buffer.\n * The png_get_int_32() routine assumes we are using two's complement\n * format for negative values, which is almost certainly true.\n */\n#  define PNG_get_uint_32(buf) \\\n     (((png_uint_32)(*(buf)) << 24) + \\\n      ((png_uint_32)(*((buf) + 1)) << 16) + \\\n      ((png_uint_32)(*((buf) + 2)) << 8) + \\\n      ((png_uint_32)(*((buf) + 3))))\n\n   /* From libpng-1.4.0 until 1.4.4, the png_get_uint_16 macro (but not the\n    * function) incorrectly returned a value of type png_uint_32.\n    */\n#  define PNG_get_uint_16(buf) \\\n     ((png_uint_16) \\\n      (((unsigned int)(*(buf)) << 8) + \\\n       ((unsigned int)(*((buf) + 1)))))\n\n#  define PNG_get_int_32(buf) \\\n     ((png_int_32)((*(buf) & 0x80) \\\n      ? -((png_int_32)((png_get_uint_32(buf) ^ 0xffffffffL) + 1)) \\\n      : (png_int_32)png_get_uint_32(buf)))\n\n   /* If PNG_PREFIX is defined the same thing as below happens in pnglibconf.h,\n    * but defining a macro name prefixed with PNG_PREFIX.\n    */\n#  ifndef PNG_PREFIX\n#     define png_get_uint_32(buf) PNG_get_uint_32(buf)\n#     define png_get_uint_16(buf) PNG_get_uint_16(buf)\n#     define png_get_int_32(buf)  PNG_get_int_32(buf)\n#  endif\n#else\n#  ifdef PNG_PREFIX\n      /* No macros; revert to the (redefined) function */\n#     define PNG_get_uint_32 (png_get_uint_32)\n#     define PNG_get_uint_16 (png_get_uint_16)\n#     define PNG_get_int_32  (png_get_int_32)\n#  endif\n#endif\n\n/*******************************************************************************\n *  SIMPLIFIED API\n *******************************************************************************\n *\n * Please read the documentation in libpng-manual.txt (TODO: write said\n * documentation) if you don't understand what follows.\n *\n * The simplified API hides the details of both libpng and the PNG file format\n * itself.  It allows PNG files to be read into a very limited number of\n * in-memory bitmap formats or to be written from the same formats.  If these\n * formats do not accomodate your needs then you can, and should, use the more\n * sophisticated APIs above - these support a wide variety of in-memory formats\n * and a wide variety of sophisticated transformations to those formats as well\n * as a wide variety of APIs to manipulate ancillary information.\n *\n * To read a PNG file using the simplified API:\n *\n * 1) Declare a 'png_image' structure (see below) on the stack and set the\n *    version field to PNG_IMAGE_VERSION.\n * 2) Call the appropriate png_image_begin_read... function.\n * 3) Set the png_image 'format' member to the required sample format.\n * 4) Allocate a buffer for the image and, if required, the color-map.\n * 5) Call png_image_finish_read to read the image and, if required, the\n *    color-map into your buffers.\n *\n * There are no restrictions on the format of the PNG input itself; all valid\n * color types, bit depths, and interlace methods are acceptable, and the\n * input image is transformed as necessary to the requested in-memory format\n * during the png_image_finish_read() step.  The only caveat is that if you\n * request a color-mapped image from a PNG that is full-color or makes\n * complex use of an alpha channel the transformation is extremely lossy and the\n * result may look terrible.\n *\n * To write a PNG file using the simplified API:\n *\n * 1) Declare a 'png_image' structure on the stack and memset() it to all zero.\n * 2) Initialize the members of the structure that describe the image, setting\n *    the 'format' member to the format of the image samples.\n * 3) Call the appropriate png_image_write... function with a pointer to the\n *    image and, if necessary, the color-map to write the PNG data.\n *\n * png_image is a structure that describes the in-memory format of an image\n * when it is being read or defines the in-memory format of an image that you\n * need to write:\n */\n#define PNG_IMAGE_VERSION 1\n\ntypedef struct png_control *png_controlp;\ntypedef struct\n{\n   png_controlp opaque;    /* Initialize to NULL, free with png_image_free */\n   png_uint_32  version;   /* Set to PNG_IMAGE_VERSION */\n   png_uint_32  width;     /* Image width in pixels (columns) */\n   png_uint_32  height;    /* Image height in pixels (rows) */\n   png_uint_32  format;    /* Image format as defined below */\n   png_uint_32  flags;     /* A bit mask containing informational flags */\n   png_uint_32  colormap_entries;\n                           /* Number of entries in the color-map */\n\n   /* In the event of an error or warning the following field will be set to a\n    * non-zero value and the 'message' field will contain a '\\0' terminated\n    * string with the libpng error or warning message.  If both warnings and\n    * an error were encountered, only the error is recorded.  If there\n    * are multiple warnings, only the first one is recorded.\n    *\n    * The upper 30 bits of this value are reserved, the low two bits contain\n    * a value as follows:\n    */\n#  define PNG_IMAGE_WARNING 1\n#  define PNG_IMAGE_ERROR 2\n   /*\n    * The result is a two bit code such that a value more than 1 indicates\n    * a failure in the API just called:\n    *\n    *    0 - no warning or error\n    *    1 - warning\n    *    2 - error\n    *    3 - error preceded by warning\n    */\n#  define PNG_IMAGE_FAILED(png_cntrl) ((((png_cntrl).warning_or_error)&0x03)>1)\n\n   png_uint_32  warning_or_error;\n\n   char         message[64];\n} png_image, *png_imagep;\n\n/* The samples of the image have one to four channels whose components have\n * original values in the range 0 to 1.0:\n *\n * 1: A single gray or luminance channel (G).\n * 2: A gray/luminance channel and an alpha channel (GA).\n * 3: Three red, green, blue color channels (RGB).\n * 4: Three color channels and an alpha channel (RGBA).\n *\n * The components are encoded in one of two ways:\n *\n * a) As a small integer, value 0..255, contained in a single byte.  For the\n * alpha channel the original value is simply value/255.  For the color or\n * luminance channels the value is encoded according to the sRGB specification\n * and matches the 8-bit format expected by typical display devices.\n *\n * The color/gray channels are not scaled (pre-multiplied) by the alpha\n * channel and are suitable for passing to color management software.\n *\n * b) As a value in the range 0..65535, contained in a 2-byte integer.  All\n * channels can be converted to the original value by dividing by 65535; all\n * channels are linear.  Color channels use the RGB encoding (RGB end-points) of\n * the sRGB specification.  This encoding is identified by the\n * PNG_FORMAT_FLAG_LINEAR flag below.\n *\n * When the simplified API needs to convert between sRGB and linear colorspaces,\n * the actual sRGB transfer curve defined in the sRGB specification (see the\n * article at http://en.wikipedia.org/wiki/SRGB) is used, not the gamma=1/2.2\n * approximation used elsewhere in libpng.\n *\n * When an alpha channel is present it is expected to denote pixel coverage\n * of the color or luminance channels and is returned as an associated alpha\n * channel: the color/gray channels are scaled (pre-multiplied) by the alpha\n * value.\n *\n * The samples are either contained directly in the image data, between 1 and 8\n * bytes per pixel according to the encoding, or are held in a color-map indexed\n * by bytes in the image data.  In the case of a color-map the color-map entries\n * are individual samples, encoded as above, and the image data has one byte per\n * pixel to select the relevant sample from the color-map.\n */\n\n/* PNG_FORMAT_*\n *\n * #defines to be used in png_image::format.  Each #define identifies a\n * particular layout of sample data and, if present, alpha values.  There are\n * separate defines for each of the two component encodings.\n *\n * A format is built up using single bit flag values.  All combinations are\n * valid.  Formats can be built up from the flag values or you can use one of\n * the predefined values below.  When testing formats always use the FORMAT_FLAG\n * macros to test for individual features - future versions of the library may\n * add new flags.\n *\n * When reading or writing color-mapped images the format should be set to the\n * format of the entries in the color-map then png_image_{read,write}_colormap\n * called to read or write the color-map and set the format correctly for the\n * image data.  Do not set the PNG_FORMAT_FLAG_COLORMAP bit directly!\n *\n * NOTE: libpng can be built with particular features disabled, if you see\n * compiler errors because the definition of one of the following flags has been\n * compiled out it is because libpng does not have the required support.  It is\n * possible, however, for the libpng configuration to enable the format on just\n * read or just write; in that case you may see an error at run time.  You can\n * guard against this by checking for the definition of the appropriate\n * \"_SUPPORTED\" macro, one of:\n *\n *    PNG_SIMPLIFIED_{READ,WRITE}_{BGR,AFIRST}_SUPPORTED\n */\n#define PNG_FORMAT_FLAG_ALPHA    0x01U /* format with an alpha channel */\n#define PNG_FORMAT_FLAG_COLOR    0x02U /* color format: otherwise grayscale */\n#define PNG_FORMAT_FLAG_LINEAR   0x04U /* 2 byte channels else 1 byte */\n#define PNG_FORMAT_FLAG_COLORMAP 0x08U /* image data is color-mapped */\n\n#ifdef PNG_FORMAT_BGR_SUPPORTED\n#  define PNG_FORMAT_FLAG_BGR    0x10U /* BGR colors, else order is RGB */\n#endif\n\n#ifdef PNG_FORMAT_AFIRST_SUPPORTED\n#  define PNG_FORMAT_FLAG_AFIRST 0x20U /* alpha channel comes first */\n#endif\n\n/* Commonly used formats have predefined macros.\n *\n * First the single byte (sRGB) formats:\n */\n#define PNG_FORMAT_GRAY 0\n#define PNG_FORMAT_GA   PNG_FORMAT_FLAG_ALPHA\n#define PNG_FORMAT_AG   (PNG_FORMAT_GA|PNG_FORMAT_FLAG_AFIRST)\n#define PNG_FORMAT_RGB  PNG_FORMAT_FLAG_COLOR\n#define PNG_FORMAT_BGR  (PNG_FORMAT_FLAG_COLOR|PNG_FORMAT_FLAG_BGR)\n#define PNG_FORMAT_RGBA (PNG_FORMAT_RGB|PNG_FORMAT_FLAG_ALPHA)\n#define PNG_FORMAT_ARGB (PNG_FORMAT_RGBA|PNG_FORMAT_FLAG_AFIRST)\n#define PNG_FORMAT_BGRA (PNG_FORMAT_BGR|PNG_FORMAT_FLAG_ALPHA)\n#define PNG_FORMAT_ABGR (PNG_FORMAT_BGRA|PNG_FORMAT_FLAG_AFIRST)\n\n/* Then the linear 2-byte formats.  When naming these \"Y\" is used to\n * indicate a luminance (gray) channel.\n */\n#define PNG_FORMAT_LINEAR_Y PNG_FORMAT_FLAG_LINEAR\n#define PNG_FORMAT_LINEAR_Y_ALPHA (PNG_FORMAT_FLAG_LINEAR|PNG_FORMAT_FLAG_ALPHA)\n#define PNG_FORMAT_LINEAR_RGB (PNG_FORMAT_FLAG_LINEAR|PNG_FORMAT_FLAG_COLOR)\n#define PNG_FORMAT_LINEAR_RGB_ALPHA \\\n   (PNG_FORMAT_FLAG_LINEAR|PNG_FORMAT_FLAG_COLOR|PNG_FORMAT_FLAG_ALPHA)\n\n/* With color-mapped formats the image data is one byte for each pixel, the byte\n * is an index into the color-map which is formatted as above.  To obtain a\n * color-mapped format it is sufficient just to add the PNG_FOMAT_FLAG_COLORMAP\n * to one of the above definitions, or you can use one of the definitions below.\n */\n#define PNG_FORMAT_RGB_COLORMAP  (PNG_FORMAT_RGB|PNG_FORMAT_FLAG_COLORMAP)\n#define PNG_FORMAT_BGR_COLORMAP  (PNG_FORMAT_BGR|PNG_FORMAT_FLAG_COLORMAP)\n#define PNG_FORMAT_RGBA_COLORMAP (PNG_FORMAT_RGBA|PNG_FORMAT_FLAG_COLORMAP)\n#define PNG_FORMAT_ARGB_COLORMAP (PNG_FORMAT_ARGB|PNG_FORMAT_FLAG_COLORMAP)\n#define PNG_FORMAT_BGRA_COLORMAP (PNG_FORMAT_BGRA|PNG_FORMAT_FLAG_COLORMAP)\n#define PNG_FORMAT_ABGR_COLORMAP (PNG_FORMAT_ABGR|PNG_FORMAT_FLAG_COLORMAP)\n\n/* PNG_IMAGE macros\n *\n * These are convenience macros to derive information from a png_image\n * structure.  The PNG_IMAGE_SAMPLE_ macros return values appropriate to the\n * actual image sample values - either the entries in the color-map or the\n * pixels in the image.  The PNG_IMAGE_PIXEL_ macros return corresponding values\n * for the pixels and will always return 1 for color-mapped formats.  The\n * remaining macros return information about the rows in the image and the\n * complete image.\n *\n * NOTE: All the macros that take a png_image::format parameter are compile time\n * constants if the format parameter is, itself, a constant.  Therefore these\n * macros can be used in array declarations and case labels where required.\n * Similarly the macros are also pre-processor constants (sizeof is not used) so\n * they can be used in #if tests.\n *\n * First the information about the samples.\n */\n#define PNG_IMAGE_SAMPLE_CHANNELS(fmt)\\\n   (((fmt)&(PNG_FORMAT_FLAG_COLOR|PNG_FORMAT_FLAG_ALPHA))+1)\n   /* Return the total number of channels in a given format: 1..4 */\n\n#define PNG_IMAGE_SAMPLE_COMPONENT_SIZE(fmt)\\\n   ((((fmt) & PNG_FORMAT_FLAG_LINEAR) >> 2)+1)\n   /* Return the size in bytes of a single component of a pixel or color-map\n    * entry (as appropriate) in the image: 1 or 2.\n    */\n\n#define PNG_IMAGE_SAMPLE_SIZE(fmt)\\\n   (PNG_IMAGE_SAMPLE_CHANNELS(fmt) * PNG_IMAGE_SAMPLE_COMPONENT_SIZE(fmt))\n   /* This is the size of the sample data for one sample.  If the image is\n    * color-mapped it is the size of one color-map entry (and image pixels are\n    * one byte in size), otherwise it is the size of one image pixel.\n    */\n\n#define PNG_IMAGE_MAXIMUM_COLORMAP_COMPONENTS(fmt)\\\n   (PNG_IMAGE_SAMPLE_CHANNELS(fmt) * 256)\n   /* The maximum size of the color-map required by the format expressed in a\n    * count of components.  This can be used to compile-time allocate a\n    * color-map:\n    *\n    * png_uint_16 colormap[PNG_IMAGE_MAXIMUM_COLORMAP_COMPONENTS(linear_fmt)];\n    *\n    * png_byte colormap[PNG_IMAGE_MAXIMUM_COLORMAP_COMPONENTS(sRGB_fmt)];\n    *\n    * Alternatively use the PNG_IMAGE_COLORMAP_SIZE macro below to use the\n    * information from one of the png_image_begin_read_ APIs and dynamically\n    * allocate the required memory.\n    */\n\n/* Corresponding information about the pixels */\n#define PNG_IMAGE_PIXEL_(test,fmt)\\\n   (((fmt)&PNG_FORMAT_FLAG_COLORMAP)?1:test(fmt))\n\n#define PNG_IMAGE_PIXEL_CHANNELS(fmt)\\\n   PNG_IMAGE_PIXEL_(PNG_IMAGE_SAMPLE_CHANNELS,fmt)\n   /* The number of separate channels (components) in a pixel; 1 for a\n    * color-mapped image.\n    */\n\n#define PNG_IMAGE_PIXEL_COMPONENT_SIZE(fmt)\\\n   PNG_IMAGE_PIXEL_(PNG_IMAGE_SAMPLE_COMPONENT_SIZE,fmt)\n   /* The size, in bytes, of each component in a pixel; 1 for a color-mapped\n    * image.\n    */\n\n#define PNG_IMAGE_PIXEL_SIZE(fmt) PNG_IMAGE_PIXEL_(PNG_IMAGE_SAMPLE_SIZE,fmt)\n   /* The size, in bytes, of a complete pixel; 1 for a color-mapped image. */\n\n/* Information about the whole row, or whole image */\n#define PNG_IMAGE_ROW_STRIDE(image)\\\n   (PNG_IMAGE_PIXEL_CHANNELS((image).format) * (image).width)\n   /* Return the total number of components in a single row of the image; this\n    * is the minimum 'row stride', the minimum count of components between each\n    * row.  For a color-mapped image this is the minimum number of bytes in a\n    * row.\n    */\n\n#define PNG_IMAGE_BUFFER_SIZE(image, row_stride)\\\n   (PNG_IMAGE_PIXEL_COMPONENT_SIZE((image).format)*(image).height*(row_stride))\n   /* Return the size, in bytes, of an image buffer given a png_image and a row\n    * stride - the number of components to leave space for in each row.\n    */\n\n#define PNG_IMAGE_SIZE(image)\\\n   PNG_IMAGE_BUFFER_SIZE(image, PNG_IMAGE_ROW_STRIDE(image))\n   /* Return the size, in bytes, of the image in memory given just a png_image;\n    * the row stride is the minimum stride required for the image.\n    */\n\n#define PNG_IMAGE_COLORMAP_SIZE(image)\\\n   (PNG_IMAGE_SAMPLE_SIZE((image).format) * (image).colormap_entries)\n   /* Return the size, in bytes, of the color-map of this image.  If the image\n    * format is not a color-map format this will return a size sufficient for\n    * 256 entries in the given format; check PNG_FORMAT_FLAG_COLORMAP if\n    * you don't want to allocate a color-map in this case.\n    */\n\n/* PNG_IMAGE_FLAG_*\n *\n * Flags containing additional information about the image are held in the\n * 'flags' field of png_image.\n */\n#define PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB 0x01\n   /* This indicates the the RGB values of the in-memory bitmap do not\n    * correspond to the red, green and blue end-points defined by sRGB.\n    */\n\n#define PNG_IMAGE_FLAG_FAST 0x02\n   /* On write emphasise speed over compression; the resultant PNG file will be\n    * larger but will be produced significantly faster, particular for large\n    * images.  Do not use this option for images which will be distributed, only\n    * used it when producing intermediate files that will be read back in\n    * repeatedly.  For a typical 24-bit image the option will double the read\n    * speed at the cost of increasing the image size by 25%, however for many\n    * more compressible images the PNG file can be 10 times larger with only a\n    * slight speed gain.\n    */\n\n#define PNG_IMAGE_FLAG_16BIT_sRGB 0x04\n   /* On read if the image is a 16-bit per component image and there is no gAMA\n    * or sRGB chunk assume that the components are sRGB encoded.  Notice that\n    * images output by the simplified API always have gamma information; setting\n    * this flag only affects the interpretation of 16-bit images from an\n    * external source.  It is recommended that the application expose this flag\n    * to the user; the user can normally easily recognize the difference between\n    * linear and sRGB encoding.  This flag has no effect on write - the data\n    * passed to the write APIs must have the correct encoding (as defined\n    * above.)\n    *\n    * If the flag is not set (the default) input 16-bit per component data is\n    * assumed to be linear.\n    *\n    * NOTE: the flag can only be set after the png_image_begin_read_ call,\n    * because that call initializes the 'flags' field.\n    */\n\n#ifdef PNG_SIMPLIFIED_READ_SUPPORTED\n/* READ APIs\n * ---------\n *\n * The png_image passed to the read APIs must have been initialized by setting\n * the png_controlp field 'opaque' to NULL (or, safer, memset the whole thing.)\n */\n#ifdef PNG_STDIO_SUPPORTED\nPNG_EXPORT(234, int, png_image_begin_read_from_file, (png_imagep image,\n   const char *file_name));\n   /* The named file is opened for read and the image header is filled in\n    * from the PNG header in the file.\n    */\n\nPNG_EXPORT(235, int, png_image_begin_read_from_stdio, (png_imagep image,\n   FILE* file));\n   /* The PNG header is read from the stdio FILE object. */\n#endif /* PNG_STDIO_SUPPORTED */\n\nPNG_EXPORT(236, int, png_image_begin_read_from_memory, (png_imagep image,\n   png_const_voidp memory, png_size_t size));\n   /* The PNG header is read from the given memory buffer. */\n\nPNG_EXPORT(237, int, png_image_finish_read, (png_imagep image,\n   png_const_colorp background, void *buffer, png_int_32 row_stride,\n   void *colormap));\n   /* Finish reading the image into the supplied buffer and clean up the\n    * png_image structure.\n    *\n    * row_stride is the step, in byte or 2-byte units as appropriate,\n    * between adjacent rows.  A positive stride indicates that the top-most row\n    * is first in the buffer - the normal top-down arrangement.  A negative\n    * stride indicates that the bottom-most row is first in the buffer.\n    *\n    * background need only be supplied if an alpha channel must be removed from\n    * a png_byte format and the removal is to be done by compositing on a solid\n    * color; otherwise it may be NULL and any composition will be done directly\n    * onto the buffer.  The value is an sRGB color to use for the background,\n    * for grayscale output the green channel is used.\n    *\n    * background must be supplied when an alpha channel must be removed from a\n    * single byte color-mapped output format, in other words if:\n    *\n    * 1) The original format from png_image_begin_read_from_* had\n    *    PNG_FORMAT_FLAG_ALPHA set.\n    * 2) The format set by the application does not.\n    * 3) The format set by the application has PNG_FORMAT_FLAG_COLORMAP set and\n    *    PNG_FORMAT_FLAG_LINEAR *not* set.\n    *\n    * For linear output removing the alpha channel is always done by compositing\n    * on black and background is ignored.\n    *\n    * colormap must be supplied when PNG_FORMAT_FLAG_COLORMAP is set.  It must\n    * be at least the size (in bytes) returned by PNG_IMAGE_COLORMAP_SIZE.\n    * image->colormap_entries will be updated to the actual number of entries\n    * written to the colormap; this may be less than the original value.\n    */\n\nPNG_EXPORT(238, void, png_image_free, (png_imagep image));\n   /* Free any data allocated by libpng in image->opaque, setting the pointer to\n    * NULL.  May be called at any time after the structure is initialized.\n    */\n#endif /* PNG_SIMPLIFIED_READ_SUPPORTED */\n\n#ifdef PNG_SIMPLIFIED_WRITE_SUPPORTED\n#ifdef PNG_STDIO_SUPPORTED\n/* WRITE APIS\n * ----------\n * For write you must initialize a png_image structure to describe the image to\n * be written.  To do this use memset to set the whole structure to 0 then\n * initialize fields describing your image.\n *\n * version: must be set to PNG_IMAGE_VERSION\n * opaque: must be initialized to NULL\n * width: image width in pixels\n * height: image height in rows\n * format: the format of the data (image and color-map) you wish to write\n * flags: set to 0 unless one of the defined flags applies; set\n *    PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB for color format images where the RGB\n *    values do not correspond to the colors in sRGB.\n * colormap_entries: set to the number of entries in the color-map (0 to 256)\n */\nPNG_EXPORT(239, int, png_image_write_to_file, (png_imagep image,\n   const char *file, int convert_to_8bit, const void *buffer,\n   png_int_32 row_stride, const void *colormap));\n   /* Write the image to the named file. */\n\nPNG_EXPORT(240, int, png_image_write_to_stdio, (png_imagep image, FILE *file,\n   int convert_to_8_bit, const void *buffer, png_int_32 row_stride,\n   const void *colormap));\n   /* Write the image to the given (FILE*). */\n\n/* With both write APIs if image is in one of the linear formats with 16-bit\n * data then setting convert_to_8_bit will cause the output to be an 8-bit PNG\n * gamma encoded according to the sRGB specification, otherwise a 16-bit linear\n * encoded PNG file is written.\n *\n * With color-mapped data formats the colormap parameter point to a color-map\n * with at least image->colormap_entries encoded in the specified format.  If\n * the format is linear the written PNG color-map will be converted to sRGB\n * regardless of the convert_to_8_bit flag.\n *\n * With all APIs row_stride is handled as in the read APIs - it is the spacing\n * from one row to the next in component sized units (1 or 2 bytes) and if\n * negative indicates a bottom-up row layout in the buffer.\n *\n * Note that the write API does not support interlacing or sub-8-bit pixels.\n */\n#endif /* PNG_STDIO_SUPPORTED */\n#endif /* PNG_SIMPLIFIED_WRITE_SUPPORTED */\n/*******************************************************************************\n *  END OF SIMPLIFIED API\n ******************************************************************************/\n\n#ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED\nPNG_EXPORT(242, void, png_set_check_for_invalid_index,\n    (png_structrp png_ptr, int allowed));\n#  ifdef PNG_GET_PALETTE_MAX_SUPPORTED\nPNG_EXPORT(243, int, png_get_palette_max, (png_const_structp png_ptr,\n    png_const_infop info_ptr));\n#  endif\n#endif /* CHECK_FOR_INVALID_INDEX */\n\n/*******************************************************************************\n *  IMPLEMENTATION OPTIONS\n *******************************************************************************\n *\n * Support for arbitrary implementation-specific optimizations.  The API allows\n * particular options to be turned on or off.  'Option' is the number of the\n * option and 'onoff' is 0 (off) or non-0 (on).  The value returned is given\n * by the PNG_OPTION_ defines below.\n *\n * HARDWARE: normally hardware capabilites, such as the Intel SSE instructions,\n *           are detected at run time, however sometimes it may be impossible\n *           to do this in user mode, in which case it is necessary to discover\n *           the capabilities in an OS specific way.  Such capabilities are\n *           listed here when libpng has support for them and must be turned\n *           ON by the application if present.\n *\n * SOFTWARE: sometimes software optimizations actually result in performance\n *           decrease on some architectures or systems, or with some sets of\n *           PNG images.  'Software' options allow such optimizations to be\n *           selected at run time.\n */\n#ifdef PNG_SET_OPTION_SUPPORTED\n#ifdef PNG_ARM_NEON_API_SUPPORTED\n#  define PNG_ARM_NEON   0 /* HARDWARE: ARM Neon SIMD instructions supported */\n#endif\n#define PNG_MAXIMUM_INFLATE_WINDOW 2 /* SOFTWARE: force maximum window */\n#define PNG_OPTION_NEXT  4 /* Next option - numbers must be even */\n\n/* Return values: NOTE: there are four values and 'off' is *not* zero */\n#define PNG_OPTION_UNSET   0 /* Unset - defaults to off */\n#define PNG_OPTION_INVALID 1 /* Option number out of range */\n#define PNG_OPTION_OFF     2\n#define PNG_OPTION_ON      3\n\nPNG_EXPORT(244, int, png_set_option, (png_structrp png_ptr, int option,\n   int onoff));\n#endif\n\n/*******************************************************************************\n *  END OF HARDWARE OPTIONS\n ******************************************************************************/\n\n/* Maintainer: Put new public prototypes here ^, in libpng.3, and project\n * defs, scripts/pnglibconf.h, and scripts/pnglibconf.h.prebuilt\n */\n\n/* The last ordinal number (this is the *last* one already used; the next\n * one to use is one more than this.)  Maintainer, remember to add an entry to\n * scripts/symbols.def as well.\n */\n#ifdef PNG_EXPORT_LAST_ORDINAL\n  PNG_EXPORT_LAST_ORDINAL(244);\n#endif\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* PNG_VERSION_INFO_ONLY */\n/* Do not put anything past this line */\n#endif /* PNG_H */\n"
  },
  {
    "path": "Libraries/Core/iOS/Headers/png/pngconf.h",
    "content": "\n/* pngconf.h - machine configurable file for libpng\n *\n * libpng version 1.6.10 - March 6, 2014\n *\n * Copyright (c) 1998-2013 Glenn Randers-Pehrson\n * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)\n * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)\n *\n * This code is released under the libpng license.\n * For conditions of distribution and use, see the disclaimer\n * and license in png.h\n *\n */\n\n/* Any machine specific code is near the front of this file, so if you\n * are configuring libpng for a machine, you may want to read the section\n * starting here down to where it starts to typedef png_color, png_text,\n * and png_info.\n */\n\n#ifndef PNGCONF_H\n#define PNGCONF_H\n\n/* To do: Do all of this in scripts/pnglibconf.dfa */\n#ifdef PNG_SAFE_LIMITS_SUPPORTED\n#  ifdef PNG_USER_WIDTH_MAX\n#    undef PNG_USER_WIDTH_MAX\n#    define PNG_USER_WIDTH_MAX 1000000L\n#  endif\n#  ifdef PNG_USER_HEIGHT_MAX\n#    undef PNG_USER_HEIGHT_MAX\n#    define PNG_USER_HEIGHT_MAX 1000000L\n#  endif\n#  ifdef PNG_USER_CHUNK_MALLOC_MAX\n#    undef PNG_USER_CHUNK_MALLOC_MAX\n#    define PNG_USER_CHUNK_MALLOC_MAX 4000000L\n#  endif\n#  ifdef PNG_USER_CHUNK_CACHE_MAX\n#    undef PNG_USER_CHUNK_CACHE_MAX\n#    define PNG_USER_CHUNK_CACHE_MAX 128\n#  endif\n#endif\n\n#ifndef PNG_BUILDING_SYMBOL_TABLE /* else includes may cause problems */\n\n/* From libpng 1.6.0 libpng requires an ANSI X3.159-1989 (\"ISOC90\") compliant C\n * compiler for correct compilation.  The following header files are required by\n * the standard.  If your compiler doesn't provide these header files, or they\n * do not match the standard, you will need to provide/improve them.\n */\n#include <limits.h>\n#include <stddef.h>\n\n/* Library header files.  These header files are all defined by ISOC90; libpng\n * expects conformant implementations, however, an ISOC90 conformant system need\n * not provide these header files if the functionality cannot be implemented.\n * In this case it will be necessary to disable the relevant parts of libpng in\n * the build of pnglibconf.h.\n *\n * Prior to 1.6.0 string.h was included here; the API changes in 1.6.0 to not\n * include this unnecessary header file.\n */\n\n#ifdef PNG_STDIO_SUPPORTED\n   /* Required for the definition of FILE: */\n#  include <stdio.h>\n#endif\n\n#ifdef PNG_SETJMP_SUPPORTED\n   /* Required for the definition of jmp_buf and the declaration of longjmp: */\n#  include <setjmp.h>\n#endif\n\n#ifdef PNG_CONVERT_tIME_SUPPORTED\n   /* Required for struct tm: */\n#  include <time.h>\n#endif\n\n#endif /* PNG_BUILDING_SYMBOL_TABLE */\n\n/* Prior to 1.6.0 it was possible to turn off 'const' in declarations using\n * PNG_NO_CONST; this is no longer supported except for data declarations which\n * apparently still cause problems in 2011 on some compilers.\n */\n#define PNG_CONST const /* backward compatibility only */\n\n/* This controls optimization of the reading of 16 and 32 bit values\n * from PNG files.  It can be set on a per-app-file basis - it\n * just changes whether a macro is used when the function is called.\n * The library builder sets the default; if read functions are not\n * built into the library the macro implementation is forced on.\n */\n#ifndef PNG_READ_INT_FUNCTIONS_SUPPORTED\n#  define PNG_USE_READ_MACROS\n#endif\n#if !defined(PNG_NO_USE_READ_MACROS) && !defined(PNG_USE_READ_MACROS)\n#  if PNG_DEFAULT_READ_MACROS\n#    define PNG_USE_READ_MACROS\n#  endif\n#endif\n\n/* COMPILER SPECIFIC OPTIONS.\n *\n * These options are provided so that a variety of difficult compilers\n * can be used.  Some are fixed at build time (e.g. PNG_API_RULE\n * below) but still have compiler specific implementations, others\n * may be changed on a per-file basis when compiling against libpng.\n */\n\n/* The PNGARG macro was used in versions of libpng prior to 1.6.0 to protect\n * against legacy (pre ISOC90) compilers that did not understand function\n * prototypes.  It is not required for modern C compilers.\n */\n#ifndef PNGARG\n#  define PNGARG(arglist) arglist\n#endif\n\n/* Function calling conventions.\n * =============================\n * Normally it is not necessary to specify to the compiler how to call\n * a function - it just does it - however on x86 systems derived from\n * Microsoft and Borland C compilers ('IBM PC', 'DOS', 'Windows' systems\n * and some others) there are multiple ways to call a function and the\n * default can be changed on the compiler command line.  For this reason\n * libpng specifies the calling convention of every exported function and\n * every function called via a user supplied function pointer.  This is\n * done in this file by defining the following macros:\n *\n * PNGAPI    Calling convention for exported functions.\n * PNGCBAPI  Calling convention for user provided (callback) functions.\n * PNGCAPI   Calling convention used by the ANSI-C library (required\n *           for longjmp callbacks and sometimes used internally to\n *           specify the calling convention for zlib).\n *\n * These macros should never be overridden.  If it is necessary to\n * change calling convention in a private build this can be done\n * by setting PNG_API_RULE (which defaults to 0) to one of the values\n * below to select the correct 'API' variants.\n *\n * PNG_API_RULE=0 Use PNGCAPI - the 'C' calling convention - throughout.\n *                This is correct in every known environment.\n * PNG_API_RULE=1 Use the operating system convention for PNGAPI and\n *                the 'C' calling convention (from PNGCAPI) for\n *                callbacks (PNGCBAPI).  This is no longer required\n *                in any known environment - if it has to be used\n *                please post an explanation of the problem to the\n *                libpng mailing list.\n *\n * These cases only differ if the operating system does not use the C\n * calling convention, at present this just means the above cases\n * (x86 DOS/Windows sytems) and, even then, this does not apply to\n * Cygwin running on those systems.\n *\n * Note that the value must be defined in pnglibconf.h so that what\n * the application uses to call the library matches the conventions\n * set when building the library.\n */\n\n/* Symbol export\n * =============\n * When building a shared library it is almost always necessary to tell\n * the compiler which symbols to export.  The png.h macro 'PNG_EXPORT'\n * is used to mark the symbols.  On some systems these symbols can be\n * extracted at link time and need no special processing by the compiler,\n * on other systems the symbols are flagged by the compiler and just\n * the declaration requires a special tag applied (unfortunately) in a\n * compiler dependent way.  Some systems can do either.\n *\n * A small number of older systems also require a symbol from a DLL to\n * be flagged to the program that calls it.  This is a problem because\n * we do not know in the header file included by application code that\n * the symbol will come from a shared library, as opposed to a statically\n * linked one.  For this reason the application must tell us by setting\n * the magic flag PNG_USE_DLL to turn on the special processing before\n * it includes png.h.\n *\n * Four additional macros are used to make this happen:\n *\n * PNG_IMPEXP The magic (if any) to cause a symbol to be exported from\n *            the build or imported if PNG_USE_DLL is set - compiler\n *            and system specific.\n *\n * PNG_EXPORT_TYPE(type) A macro that pre or appends PNG_IMPEXP to\n *                       'type', compiler specific.\n *\n * PNG_DLL_EXPORT Set to the magic to use during a libpng build to\n *                make a symbol exported from the DLL.  Not used in the\n *                public header files; see pngpriv.h for how it is used\n *                in the libpng build.\n *\n * PNG_DLL_IMPORT Set to the magic to force the libpng symbols to come\n *                from a DLL - used to define PNG_IMPEXP when\n *                PNG_USE_DLL is set.\n */\n\n/* System specific discovery.\n * ==========================\n * This code is used at build time to find PNG_IMPEXP, the API settings\n * and PNG_EXPORT_TYPE(), it may also set a macro to indicate the DLL\n * import processing is possible.  On Windows systems it also sets\n * compiler-specific macros to the values required to change the calling\n * conventions of the various functions.\n */\n#if defined(_Windows) || defined(_WINDOWS) || defined(WIN32) ||\\\n    defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)\n  /* Windows system (DOS doesn't support DLLs).  Includes builds under Cygwin or\n   * MinGW on any architecture currently supported by Windows.  Also includes\n   * Watcom builds but these need special treatment because they are not\n   * compatible with GCC or Visual C because of different calling conventions.\n   */\n#  if PNG_API_RULE == 2\n    /* If this line results in an error, either because __watcall is not\n     * understood or because of a redefine just below you cannot use *this*\n     * build of the library with the compiler you are using.  *This* build was\n     * build using Watcom and applications must also be built using Watcom!\n     */\n#    define PNGCAPI __watcall\n#  endif\n\n#  if defined(__GNUC__) || (defined(_MSC_VER) && (_MSC_VER >= 800))\n#    define PNGCAPI __cdecl\n#    if PNG_API_RULE == 1\n       /* If this line results in an error __stdcall is not understood and\n        * PNG_API_RULE should not have been set to '1'.\n        */\n#      define PNGAPI __stdcall\n#    endif\n#  else\n    /* An older compiler, or one not detected (erroneously) above,\n     * if necessary override on the command line to get the correct\n     * variants for the compiler.\n     */\n#    ifndef PNGCAPI\n#      define PNGCAPI _cdecl\n#    endif\n#    if PNG_API_RULE == 1 && !defined(PNGAPI)\n#      define PNGAPI _stdcall\n#    endif\n#  endif /* compiler/api */\n\n  /* NOTE: PNGCBAPI always defaults to PNGCAPI. */\n\n#  if defined(PNGAPI) && !defined(PNG_USER_PRIVATEBUILD)\n#     error \"PNG_USER_PRIVATEBUILD must be defined if PNGAPI is changed\"\n#  endif\n\n#  if (defined(_MSC_VER) && _MSC_VER < 800) ||\\\n      (defined(__BORLANDC__) && __BORLANDC__ < 0x500)\n    /* older Borland and MSC\n     * compilers used '__export' and required this to be after\n     * the type.\n     */\n#    ifndef PNG_EXPORT_TYPE\n#      define PNG_EXPORT_TYPE(type) type PNG_IMPEXP\n#    endif\n#    define PNG_DLL_EXPORT __export\n#  else /* newer compiler */\n#    define PNG_DLL_EXPORT __declspec(dllexport)\n#    ifndef PNG_DLL_IMPORT\n#      define PNG_DLL_IMPORT __declspec(dllimport)\n#    endif\n#  endif /* compiler */\n\n#else /* !Windows */\n#  if (defined(__IBMC__) || defined(__IBMCPP__)) && defined(__OS2__)\n#    define PNGAPI _System\n#  else /* !Windows/x86 && !OS/2 */\n    /* Use the defaults, or define PNG*API on the command line (but\n     * this will have to be done for every compile!)\n     */\n#  endif /* other system, !OS/2 */\n#endif /* !Windows/x86 */\n\n/* Now do all the defaulting . */\n#ifndef PNGCAPI\n#  define PNGCAPI\n#endif\n#ifndef PNGCBAPI\n#  define PNGCBAPI PNGCAPI\n#endif\n#ifndef PNGAPI\n#  define PNGAPI PNGCAPI\n#endif\n\n/* PNG_IMPEXP may be set on the compilation system command line or (if not set)\n * then in an internal header file when building the library, otherwise (when\n * using the library) it is set here.\n */\n#ifndef PNG_IMPEXP\n#  if defined(PNG_USE_DLL) && defined(PNG_DLL_IMPORT)\n     /* This forces use of a DLL, disallowing static linking */\n#    define PNG_IMPEXP PNG_DLL_IMPORT\n#  endif\n\n#  ifndef PNG_IMPEXP\n#    define PNG_IMPEXP\n#  endif\n#endif\n\n/* In 1.5.2 the definition of PNG_FUNCTION has been changed to always treat\n * 'attributes' as a storage class - the attributes go at the start of the\n * function definition, and attributes are always appended regardless of the\n * compiler.  This considerably simplifies these macros but may cause problems\n * if any compilers both need function attributes and fail to handle them as\n * a storage class (this is unlikely.)\n */\n#ifndef PNG_FUNCTION\n#  define PNG_FUNCTION(type, name, args, attributes) attributes type name args\n#endif\n\n#ifndef PNG_EXPORT_TYPE\n#  define PNG_EXPORT_TYPE(type) PNG_IMPEXP type\n#endif\n\n   /* The ordinal value is only relevant when preprocessing png.h for symbol\n    * table entries, so we discard it here.  See the .dfn files in the\n    * scripts directory.\n    */\n#ifndef PNG_EXPORTA\n\n#  define PNG_EXPORTA(ordinal, type, name, args, attributes)\\\n      PNG_FUNCTION(PNG_EXPORT_TYPE(type),(PNGAPI name),PNGARG(args), \\\n        extern attributes)\n#endif\n\n/* ANSI-C (C90) does not permit a macro to be invoked with an empty argument,\n * so make something non-empty to satisfy the requirement:\n */\n#define PNG_EMPTY /*empty list*/\n\n#define PNG_EXPORT(ordinal, type, name, args)\\\n   PNG_EXPORTA(ordinal, type, name, args, PNG_EMPTY)\n\n/* Use PNG_REMOVED to comment out a removed interface. */\n#ifndef PNG_REMOVED\n#  define PNG_REMOVED(ordinal, type, name, args, attributes)\n#endif\n\n#ifndef PNG_CALLBACK\n#  define PNG_CALLBACK(type, name, args) type (PNGCBAPI name) PNGARG(args)\n#endif\n\n/* Support for compiler specific function attributes.  These are used\n * so that where compiler support is available incorrect use of API\n * functions in png.h will generate compiler warnings.\n *\n * Added at libpng-1.2.41.\n */\n\n#ifndef PNG_NO_PEDANTIC_WARNINGS\n#  ifndef PNG_PEDANTIC_WARNINGS_SUPPORTED\n#    define PNG_PEDANTIC_WARNINGS_SUPPORTED\n#  endif\n#endif\n\n#ifdef PNG_PEDANTIC_WARNINGS_SUPPORTED\n  /* Support for compiler specific function attributes.  These are used\n   * so that where compiler support is available, incorrect use of API\n   * functions in png.h will generate compiler warnings.  Added at libpng\n   * version 1.2.41.  Disabling these removes the warnings but may also produce\n   * less efficient code.\n   */\n#  if defined(__clang__)\n     /* Clang defines both __clang__ and __GNUC__. Check __clang__ first. */\n#    if !defined(PNG_USE_RESULT) && __has_attribute(__warn_unused_result__)\n#      define PNG_USE_RESULT __attribute__((__warn_unused_result__))\n#    endif\n#    if !defined(PNG_NORETURN) && __has_attribute(__noreturn__)\n#      define PNG_NORETURN __attribute__((__noreturn__))\n#    endif\n#    if !defined(PNG_ALLOCATED) && __has_attribute(__malloc__)\n#      define PNG_ALLOCATED __attribute__((__malloc__))\n#    endif\n#    if !defined(PNG_DEPRECATED) && __has_attribute(__deprecated__)\n#      define PNG_DEPRECATED __attribute__((__deprecated__))\n#    endif\n#    if !defined(PNG_PRIVATE)\n#      ifdef __has_extension\n#        if __has_extension(attribute_unavailable_with_message)\n#          define PNG_PRIVATE __attribute__((__unavailable__(\\\n             \"This function is not exported by libpng.\")))\n#        endif\n#      endif\n#    endif\n#    ifndef PNG_RESTRICT\n#      define PNG_RESTRICT __restrict\n#    endif\n\n#  elif defined(__GNUC__)\n#    ifndef PNG_USE_RESULT\n#      define PNG_USE_RESULT __attribute__((__warn_unused_result__))\n#    endif\n#    ifndef PNG_NORETURN\n#      define PNG_NORETURN   __attribute__((__noreturn__))\n#    endif\n#    if __GNUC__ >= 3\n#      ifndef PNG_ALLOCATED\n#        define PNG_ALLOCATED  __attribute__((__malloc__))\n#      endif\n#      ifndef PNG_DEPRECATED\n#        define PNG_DEPRECATED __attribute__((__deprecated__))\n#      endif\n#      ifndef PNG_PRIVATE\n#        if 0 /* Doesn't work so we use deprecated instead*/\n#          define PNG_PRIVATE \\\n            __attribute__((warning(\"This function is not exported by libpng.\")))\n#        else\n#          define PNG_PRIVATE \\\n            __attribute__((__deprecated__))\n#        endif\n#      endif\n#      if ((__GNUC__ > 3) || !defined(__GNUC_MINOR__) || (__GNUC_MINOR__ >= 1))\n#        ifndef PNG_RESTRICT\n#          define PNG_RESTRICT __restrict\n#        endif\n#      endif /* __GNUC__.__GNUC_MINOR__ > 3.0 */\n#    endif /* __GNUC__ >= 3 */\n\n#  elif defined(_MSC_VER)  && (_MSC_VER >= 1300)\n#    ifndef PNG_USE_RESULT\n#      define PNG_USE_RESULT /* not supported */\n#    endif\n#    ifndef PNG_NORETURN\n#      define PNG_NORETURN   __declspec(noreturn)\n#    endif\n#    ifndef PNG_ALLOCATED\n#      if (_MSC_VER >= 1400)\n#        define PNG_ALLOCATED __declspec(restrict)\n#      endif\n#    endif\n#    ifndef PNG_DEPRECATED\n#      define PNG_DEPRECATED __declspec(deprecated)\n#    endif\n#    ifndef PNG_PRIVATE\n#      define PNG_PRIVATE __declspec(deprecated)\n#    endif\n#    ifndef PNG_RESTRICT\n#      if (_MSC_VER >= 1400)\n#        define PNG_RESTRICT __restrict\n#      endif\n#    endif\n\n#  elif defined(__WATCOMC__)\n#    ifndef PNG_RESTRICT\n#      define PNG_RESTRICT __restrict\n#    endif\n#  endif\n#endif /* PNG_PEDANTIC_WARNINGS */\n\n#ifndef PNG_DEPRECATED\n#  define PNG_DEPRECATED  /* Use of this function is deprecated */\n#endif\n#ifndef PNG_USE_RESULT\n#  define PNG_USE_RESULT  /* The result of this function must be checked */\n#endif\n#ifndef PNG_NORETURN\n#  define PNG_NORETURN    /* This function does not return */\n#endif\n#ifndef PNG_ALLOCATED\n#  define PNG_ALLOCATED   /* The result of the function is new memory */\n#endif\n#ifndef PNG_PRIVATE\n#  define PNG_PRIVATE     /* This is a private libpng function */\n#endif\n#ifndef PNG_RESTRICT\n#  define PNG_RESTRICT    /* The C99 \"restrict\" feature */\n#endif\n\n#ifndef PNG_FP_EXPORT     /* A floating point API. */\n#  ifdef PNG_FLOATING_POINT_SUPPORTED\n#     define PNG_FP_EXPORT(ordinal, type, name, args)\\\n         PNG_EXPORT(ordinal, type, name, args);\n#  else                   /* No floating point APIs */\n#     define PNG_FP_EXPORT(ordinal, type, name, args)\n#  endif\n#endif\n#ifndef PNG_FIXED_EXPORT  /* A fixed point API. */\n#  ifdef PNG_FIXED_POINT_SUPPORTED\n#     define PNG_FIXED_EXPORT(ordinal, type, name, args)\\\n         PNG_EXPORT(ordinal, type, name, args);\n#  else                   /* No fixed point APIs */\n#     define PNG_FIXED_EXPORT(ordinal, type, name, args)\n#  endif\n#endif\n\n#ifndef PNG_BUILDING_SYMBOL_TABLE\n/* Some typedefs to get us started.  These should be safe on most of the common\n * platforms.\n *\n * png_uint_32 and png_int_32 may, currently, be larger than required to hold a\n * 32-bit value however this is not normally advisable.\n *\n * png_uint_16 and png_int_16 should always be two bytes in size - this is\n * verified at library build time.\n *\n * png_byte must always be one byte in size.\n *\n * The checks below use constants from limits.h, as defined by the ISOC90\n * standard.\n */\n#if CHAR_BIT == 8 && UCHAR_MAX == 255\n   typedef unsigned char png_byte;\n#else\n#  error \"libpng requires 8 bit bytes\"\n#endif\n\n#if INT_MIN == -32768 && INT_MAX == 32767\n   typedef int png_int_16;\n#elif SHRT_MIN == -32768 && SHRT_MAX == 32767\n   typedef short png_int_16;\n#else\n#  error \"libpng requires a signed 16 bit type\"\n#endif\n\n#if UINT_MAX == 65535\n   typedef unsigned int png_uint_16;\n#elif USHRT_MAX == 65535\n   typedef unsigned short png_uint_16;\n#else\n#  error \"libpng requires an unsigned 16 bit type\"\n#endif\n\n#if INT_MIN < -2147483646 && INT_MAX > 2147483646\n   typedef int png_int_32;\n#elif LONG_MIN < -2147483646 && LONG_MAX > 2147483646\n   typedef long int png_int_32;\n#else\n#  error \"libpng requires a signed 32 bit (or more) type\"\n#endif\n\n#if UINT_MAX > 4294967294\n   typedef unsigned int png_uint_32;\n#elif ULONG_MAX > 4294967294\n   typedef unsigned long int png_uint_32;\n#else\n#  error \"libpng requires an unsigned 32 bit (or more) type\"\n#endif\n\n/* Prior to 1.6.0 it was possible to disable the use of size_t, 1.6.0, however,\n * requires an ISOC90 compiler and relies on consistent behavior of sizeof.\n */\ntypedef size_t png_size_t;\ntypedef ptrdiff_t png_ptrdiff_t;\n\n/* libpng needs to know the maximum value of 'size_t' and this controls the\n * definition of png_alloc_size_t, below.  This maximum value of size_t limits\n * but does not control the maximum allocations the library makes - there is\n * direct application control of this through png_set_user_limits().\n */\n#ifndef PNG_SMALL_SIZE_T\n   /* Compiler specific tests for systems where size_t is known to be less than\n    * 32 bits (some of these systems may no longer work because of the lack of\n    * 'far' support; see above.)\n    */\n#  if (defined(__TURBOC__) && !defined(__FLAT__)) ||\\\n   (defined(_MSC_VER) && defined(MAXSEG_64K))\n#     define PNG_SMALL_SIZE_T\n#  endif\n#endif\n\n/* png_alloc_size_t is guaranteed to be no smaller than png_size_t, and no\n * smaller than png_uint_32.  Casts from png_size_t or png_uint_32 to\n * png_alloc_size_t are not necessary; in fact, it is recommended not to use\n * them at all so that the compiler can complain when something turns out to be\n * problematic.\n *\n * Casts in the other direction (from png_alloc_size_t to png_size_t or\n * png_uint_32) should be explicitly applied; however, we do not expect to\n * encounter practical situations that require such conversions.\n *\n * PNG_SMALL_SIZE_T must be defined if the maximum value of size_t is less than\n * 4294967295 - i.e. less than the maximum value of png_uint_32.\n */\n#ifdef PNG_SMALL_SIZE_T\n   typedef png_uint_32 png_alloc_size_t;\n#else\n   typedef png_size_t png_alloc_size_t;\n#endif\n\n/* Prior to 1.6.0 libpng offered limited support for Microsoft C compiler\n * implementations of Intel CPU specific support of user-mode segmented address\n * spaces, where 16-bit pointers address more than 65536 bytes of memory using\n * separate 'segment' registers.  The implementation requires two different\n * types of pointer (only one of which includes the segment value.)\n *\n * If required this support is available in version 1.2 of libpng and may be\n * available in versions through 1.5, although the correctness of the code has\n * not been verified recently.\n */\n\n/* Typedef for floating-point numbers that are converted to fixed-point with a\n * multiple of 100,000, e.g., gamma\n */\ntypedef png_int_32 png_fixed_point;\n\n/* Add typedefs for pointers */\ntypedef void                  * png_voidp;\ntypedef const void            * png_const_voidp;\ntypedef png_byte              * png_bytep;\ntypedef const png_byte        * png_const_bytep;\ntypedef png_uint_32           * png_uint_32p;\ntypedef const png_uint_32     * png_const_uint_32p;\ntypedef png_int_32            * png_int_32p;\ntypedef const png_int_32      * png_const_int_32p;\ntypedef png_uint_16           * png_uint_16p;\ntypedef const png_uint_16     * png_const_uint_16p;\ntypedef png_int_16            * png_int_16p;\ntypedef const png_int_16      * png_const_int_16p;\ntypedef char                  * png_charp;\ntypedef const char            * png_const_charp;\ntypedef png_fixed_point       * png_fixed_point_p;\ntypedef const png_fixed_point * png_const_fixed_point_p;\ntypedef png_size_t            * png_size_tp;\ntypedef const png_size_t      * png_const_size_tp;\n\n#ifdef PNG_STDIO_SUPPORTED\ntypedef FILE            * png_FILE_p;\n#endif\n\n#ifdef PNG_FLOATING_POINT_SUPPORTED\ntypedef double       * png_doublep;\ntypedef const double * png_const_doublep;\n#endif\n\n/* Pointers to pointers; i.e. arrays */\ntypedef png_byte        * * png_bytepp;\ntypedef png_uint_32     * * png_uint_32pp;\ntypedef png_int_32      * * png_int_32pp;\ntypedef png_uint_16     * * png_uint_16pp;\ntypedef png_int_16      * * png_int_16pp;\ntypedef const char      * * png_const_charpp;\ntypedef char            * * png_charpp;\ntypedef png_fixed_point * * png_fixed_point_pp;\n#ifdef PNG_FLOATING_POINT_SUPPORTED\ntypedef double          * * png_doublepp;\n#endif\n\n/* Pointers to pointers to pointers; i.e., pointer to array */\ntypedef char            * * * png_charppp;\n\n#endif /* PNG_BUILDING_SYMBOL_TABLE */\n\n#endif /* PNGCONF_H */\n"
  },
  {
    "path": "Libraries/Core/iOS/Headers/png/pngdebug.h",
    "content": "\n/* pngdebug.h - Debugging macros for libpng, also used in pngtest.c\n *\n * Copyright (c) 1998-2013 Glenn Randers-Pehrson\n * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)\n * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)\n *\n * Last changed in libpng 1.6.8 [December 19, 2013]\n *\n * This code is released under the libpng license.\n * For conditions of distribution and use, see the disclaimer\n * and license in png.h\n */\n\n/* Define PNG_DEBUG at compile time for debugging information.  Higher\n * numbers for PNG_DEBUG mean more debugging information.  This has\n * only been added since version 0.95 so it is not implemented throughout\n * libpng yet, but more support will be added as needed.\n *\n * png_debug[1-2]?(level, message ,arg{0-2})\n *   Expands to a statement (either a simple expression or a compound\n *   do..while(0) statement) that outputs a message with parameter\n *   substitution if PNG_DEBUG is defined to 2 or more.  If PNG_DEBUG\n *   is undefined, 0 or 1 every png_debug expands to a simple expression\n *   (actually ((void)0)).\n *\n *   level: level of detail of message, starting at 0.  A level 'n'\n *          message is preceded by 'n' 3-space indentations (not implemented\n *          on Microsoft compilers unless PNG_DEBUG_FILE is also\n *          defined, to allow debug DLL compilation with no standard IO).\n *   message: a printf(3) style text string.  A trailing '\\n' is added\n *            to the message.\n *   arg: 0 to 2 arguments for printf(3) style substitution in message.\n */\n#ifndef PNGDEBUG_H\n#define PNGDEBUG_H\n/* These settings control the formatting of messages in png.c and pngerror.c */\n/* Moved to pngdebug.h at 1.5.0 */\n#  ifndef PNG_LITERAL_SHARP\n#    define PNG_LITERAL_SHARP 0x23\n#  endif\n#  ifndef PNG_LITERAL_LEFT_SQUARE_BRACKET\n#    define PNG_LITERAL_LEFT_SQUARE_BRACKET 0x5b\n#  endif\n#  ifndef PNG_LITERAL_RIGHT_SQUARE_BRACKET\n#    define PNG_LITERAL_RIGHT_SQUARE_BRACKET 0x5d\n#  endif\n#  ifndef PNG_STRING_NEWLINE\n#    define PNG_STRING_NEWLINE \"\\n\"\n#  endif\n\n#ifdef PNG_DEBUG\n#  if (PNG_DEBUG > 0)\n#    if !defined(PNG_DEBUG_FILE) && defined(_MSC_VER)\n#      include <crtdbg.h>\n#      if (PNG_DEBUG > 1)\n#        ifndef _DEBUG\n#          define _DEBUG\n#        endif\n#        ifndef png_debug\n#          define png_debug(l,m)  _RPT0(_CRT_WARN,m PNG_STRING_NEWLINE)\n#        endif\n#        ifndef png_debug1\n#          define png_debug1(l,m,p1)  _RPT1(_CRT_WARN,m PNG_STRING_NEWLINE,p1)\n#        endif\n#        ifndef png_debug2\n#          define png_debug2(l,m,p1,p2) \\\n             _RPT2(_CRT_WARN,m PNG_STRING_NEWLINE,p1,p2)\n#        endif\n#      endif\n#    else /* PNG_DEBUG_FILE || !_MSC_VER */\n#      ifndef PNG_STDIO_SUPPORTED\n#        include <stdio.h> /* not included yet */\n#      endif\n#      ifndef PNG_DEBUG_FILE\n#        define PNG_DEBUG_FILE stderr\n#      endif /* PNG_DEBUG_FILE */\n\n#      if (PNG_DEBUG > 1)\n#        ifdef __STDC__\n#          ifndef png_debug\n#            define png_debug(l,m) \\\n       do { \\\n       int num_tabs=l; \\\n       fprintf(PNG_DEBUG_FILE,\"%s\" m PNG_STRING_NEWLINE,(num_tabs==1 ? \"   \" : \\\n         (num_tabs==2 ? \"      \" : (num_tabs>2 ? \"         \" : \"\")))); \\\n       } while (0)\n#          endif\n#          ifndef png_debug1\n#            define png_debug1(l,m,p1) \\\n       do { \\\n       int num_tabs=l; \\\n       fprintf(PNG_DEBUG_FILE,\"%s\" m PNG_STRING_NEWLINE,(num_tabs==1 ? \"   \" : \\\n         (num_tabs==2 ? \"      \" : (num_tabs>2 ? \"         \" : \"\"))),p1); \\\n       } while (0)\n#          endif\n#          ifndef png_debug2\n#            define png_debug2(l,m,p1,p2) \\\n       do { \\\n       int num_tabs=l; \\\n       fprintf(PNG_DEBUG_FILE,\"%s\" m PNG_STRING_NEWLINE,(num_tabs==1 ? \"   \" : \\\n         (num_tabs==2 ? \"      \" : (num_tabs>2 ? \"         \" : \"\"))),p1,p2);\\\n       } while (0)\n#          endif\n#        else /* __STDC __ */\n#          ifndef png_debug\n#            define png_debug(l,m) \\\n       do { \\\n       int num_tabs=l; \\\n       char format[256]; \\\n       snprintf(format,256,\"%s%s%s\",(num_tabs==1 ? \"\\t\" : \\\n         (num_tabs==2 ? \"\\t\\t\":(num_tabs>2 ? \"\\t\\t\\t\":\"\"))), \\\n         m,PNG_STRING_NEWLINE); \\\n       fprintf(PNG_DEBUG_FILE,format); \\\n       } while (0)\n#          endif\n#          ifndef png_debug1\n#            define png_debug1(l,m,p1) \\\n       do { \\\n       int num_tabs=l; \\\n       char format[256]; \\\n       snprintf(format,256,\"%s%s%s\",(num_tabs==1 ? \"\\t\" : \\\n         (num_tabs==2 ? \"\\t\\t\":(num_tabs>2 ? \"\\t\\t\\t\":\"\"))), \\\n         m,PNG_STRING_NEWLINE); \\\n       fprintf(PNG_DEBUG_FILE,format,p1); \\\n       } while (0)\n#          endif\n#          ifndef png_debug2\n#            define png_debug2(l,m,p1,p2) \\\n       do { \\\n       int num_tabs=l; \\\n       char format[256]; \\\n       snprintf(format,256,\"%s%s%s\",(num_tabs==1 ? \"\\t\" : \\\n         (num_tabs==2 ? \"\\t\\t\":(num_tabs>2 ? \"\\t\\t\\t\":\"\"))), \\\n         m,PNG_STRING_NEWLINE); \\\n       fprintf(PNG_DEBUG_FILE,format,p1,p2); \\\n       } while (0)\n#          endif\n#        endif /* __STDC __ */\n#      endif /* (PNG_DEBUG > 1) */\n\n#    endif /* _MSC_VER */\n#  endif /* (PNG_DEBUG > 0) */\n#endif /* PNG_DEBUG */\n#ifndef png_debug\n#  define png_debug(l, m) ((void)0)\n#endif\n#ifndef png_debug1\n#  define png_debug1(l, m, p1) ((void)0)\n#endif\n#ifndef png_debug2\n#  define png_debug2(l, m, p1, p2) ((void)0)\n#endif\n#endif /* PNGDEBUG_H */\n"
  },
  {
    "path": "Libraries/Core/iOS/Headers/png/pnginfo.h",
    "content": "\n/* pnginfo.h - header file for PNG reference library\n *\n * Copyright (c) 1998-2013 Glenn Randers-Pehrson\n * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)\n * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)\n *\n * Last changed in libpng 1.6.1 [March 28, 2013]\n *\n * This code is released under the libpng license.\n * For conditions of distribution and use, see the disclaimer\n * and license in png.h\n */\n\n /* png_info is a structure that holds the information in a PNG file so\n * that the application can find out the characteristics of the image.\n * If you are reading the file, this structure will tell you what is\n * in the PNG file.  If you are writing the file, fill in the information\n * you want to put into the PNG file, using png_set_*() functions, then\n * call png_write_info().\n *\n * The names chosen should be very close to the PNG specification, so\n * consult that document for information about the meaning of each field.\n *\n * With libpng < 0.95, it was only possible to directly set and read the\n * the values in the png_info_struct, which meant that the contents and\n * order of the values had to remain fixed.  With libpng 0.95 and later,\n * however, there are now functions that abstract the contents of\n * png_info_struct from the application, so this makes it easier to use\n * libpng with dynamic libraries, and even makes it possible to use\n * libraries that don't have all of the libpng ancillary chunk-handing\n * functionality.  In libpng-1.5.0 this was moved into a separate private\n * file that is not visible to applications.\n *\n * The following members may have allocated storage attached that should be\n * cleaned up before the structure is discarded: palette, trans, text,\n * pcal_purpose, pcal_units, pcal_params, hist, iccp_name, iccp_profile,\n * splt_palettes, scal_unit, row_pointers, and unknowns.   By default, these\n * are automatically freed when the info structure is deallocated, if they were\n * allocated internally by libpng.  This behavior can be changed by means\n * of the png_data_freer() function.\n *\n * More allocation details: all the chunk-reading functions that\n * change these members go through the corresponding png_set_*\n * functions.  A function to clear these members is available: see\n * png_free_data().  The png_set_* functions do not depend on being\n * able to point info structure members to any of the storage they are\n * passed (they make their own copies), EXCEPT that the png_set_text\n * functions use the same storage passed to them in the text_ptr or\n * itxt_ptr structure argument, and the png_set_rows and png_set_unknowns\n * functions do not make their own copies.\n */\n#ifndef PNGINFO_H\n#define PNGINFO_H\n\nstruct png_info_def\n{\n   /* The following are necessary for every PNG file */\n   png_uint_32 width;  /* width of image in pixels (from IHDR) */\n   png_uint_32 height; /* height of image in pixels (from IHDR) */\n   png_uint_32 valid;  /* valid chunk data (see PNG_INFO_ below) */\n   png_size_t rowbytes; /* bytes needed to hold an untransformed row */\n   png_colorp palette;      /* array of color values (valid & PNG_INFO_PLTE) */\n   png_uint_16 num_palette; /* number of color entries in \"palette\" (PLTE) */\n   png_uint_16 num_trans;   /* number of transparent palette color (tRNS) */\n   png_byte bit_depth;      /* 1, 2, 4, 8, or 16 bits/channel (from IHDR) */\n   png_byte color_type;     /* see PNG_COLOR_TYPE_ below (from IHDR) */\n   /* The following three should have been named *_method not *_type */\n   png_byte compression_type; /* must be PNG_COMPRESSION_TYPE_BASE (IHDR) */\n   png_byte filter_type;    /* must be PNG_FILTER_TYPE_BASE (from IHDR) */\n   png_byte interlace_type; /* One of PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */\n\n   /* The following are set by png_set_IHDR, called from the application on\n    * write, but the are never actually used by the write code.\n    */\n   png_byte channels;       /* number of data channels per pixel (1, 2, 3, 4) */\n   png_byte pixel_depth;    /* number of bits per pixel */\n   png_byte spare_byte;     /* to align the data, and for future use */\n\n#ifdef PNG_READ_SUPPORTED\n   /* This is never set during write */\n   png_byte signature[8];   /* magic bytes read by libpng from start of file */\n#endif\n\n   /* The rest of the data is optional.  If you are reading, check the\n    * valid field to see if the information in these are valid.  If you\n    * are writing, set the valid field to those chunks you want written,\n    * and initialize the appropriate fields below.\n    */\n\n#if defined(PNG_COLORSPACE_SUPPORTED) || defined(PNG_GAMMA_SUPPORTED)\n   /* png_colorspace only contains 'flags' if neither GAMMA or COLORSPACE are\n    * defined.  When COLORSPACE is switched on all the colorspace-defining\n    * chunks should be enabled, when GAMMA is switched on all the gamma-defining\n    * chunks should be enabled.  If this is not done it becomes possible to read\n    * inconsistent PNG files and assign a probably incorrect interpretation to\n    * the information.  (In other words, by carefully choosing which chunks to\n    * recognize the system configuration can select an interpretation for PNG\n    * files containing ambiguous data and this will result in inconsistent\n    * behavior between different libpng builds!)\n    */\n   png_colorspace colorspace;\n#endif\n\n#ifdef PNG_iCCP_SUPPORTED\n   /* iCCP chunk data. */\n   png_charp iccp_name;     /* profile name */\n   png_bytep iccp_profile;  /* International Color Consortium profile data */\n   png_uint_32 iccp_proflen;  /* ICC profile data length */\n#endif\n\n#ifdef PNG_TEXT_SUPPORTED\n   /* The tEXt, and zTXt chunks contain human-readable textual data in\n    * uncompressed, compressed, and optionally compressed forms, respectively.\n    * The data in \"text\" is an array of pointers to uncompressed,\n    * null-terminated C strings. Each chunk has a keyword that describes the\n    * textual data contained in that chunk.  Keywords are not required to be\n    * unique, and the text string may be empty.  Any number of text chunks may\n    * be in an image.\n    */\n   int num_text; /* number of comments read or comments to write */\n   int max_text; /* current size of text array */\n   png_textp text; /* array of comments read or comments to write */\n#endif /* PNG_TEXT_SUPPORTED */\n\n#ifdef PNG_tIME_SUPPORTED\n   /* The tIME chunk holds the last time the displayed image data was\n    * modified.  See the png_time struct for the contents of this struct.\n    */\n   png_time mod_time;\n#endif\n\n#ifdef PNG_sBIT_SUPPORTED\n   /* The sBIT chunk specifies the number of significant high-order bits\n    * in the pixel data.  Values are in the range [1, bit_depth], and are\n    * only specified for the channels in the pixel data.  The contents of\n    * the low-order bits is not specified.  Data is valid if\n    * (valid & PNG_INFO_sBIT) is non-zero.\n    */\n   png_color_8 sig_bit; /* significant bits in color channels */\n#endif\n\n#if defined(PNG_tRNS_SUPPORTED) || defined(PNG_READ_EXPAND_SUPPORTED) || \\\ndefined(PNG_READ_BACKGROUND_SUPPORTED)\n   /* The tRNS chunk supplies transparency data for paletted images and\n    * other image types that don't need a full alpha channel.  There are\n    * \"num_trans\" transparency values for a paletted image, stored in the\n    * same order as the palette colors, starting from index 0.  Values\n    * for the data are in the range [0, 255], ranging from fully transparent\n    * to fully opaque, respectively.  For non-paletted images, there is a\n    * single color specified that should be treated as fully transparent.\n    * Data is valid if (valid & PNG_INFO_tRNS) is non-zero.\n    */\n   png_bytep trans_alpha;    /* alpha values for paletted image */\n   png_color_16 trans_color; /* transparent color for non-palette image */\n#endif\n\n#if defined(PNG_bKGD_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)\n   /* The bKGD chunk gives the suggested image background color if the\n    * display program does not have its own background color and the image\n    * is needs to composited onto a background before display.  The colors\n    * in \"background\" are normally in the same color space/depth as the\n    * pixel data.  Data is valid if (valid & PNG_INFO_bKGD) is non-zero.\n    */\n   png_color_16 background;\n#endif\n\n#ifdef PNG_oFFs_SUPPORTED\n   /* The oFFs chunk gives the offset in \"offset_unit_type\" units rightwards\n    * and downwards from the top-left corner of the display, page, or other\n    * application-specific co-ordinate space.  See the PNG_OFFSET_ defines\n    * below for the unit types.  Valid if (valid & PNG_INFO_oFFs) non-zero.\n    */\n   png_int_32 x_offset; /* x offset on page */\n   png_int_32 y_offset; /* y offset on page */\n   png_byte offset_unit_type; /* offset units type */\n#endif\n\n#ifdef PNG_pHYs_SUPPORTED\n   /* The pHYs chunk gives the physical pixel density of the image for\n    * display or printing in \"phys_unit_type\" units (see PNG_RESOLUTION_\n    * defines below).  Data is valid if (valid & PNG_INFO_pHYs) is non-zero.\n    */\n   png_uint_32 x_pixels_per_unit; /* horizontal pixel density */\n   png_uint_32 y_pixels_per_unit; /* vertical pixel density */\n   png_byte phys_unit_type; /* resolution type (see PNG_RESOLUTION_ below) */\n#endif\n\n#ifdef PNG_hIST_SUPPORTED\n   /* The hIST chunk contains the relative frequency or importance of the\n    * various palette entries, so that a viewer can intelligently select a\n    * reduced-color palette, if required.  Data is an array of \"num_palette\"\n    * values in the range [0,65535]. Data valid if (valid & PNG_INFO_hIST)\n    * is non-zero.\n    */\n   png_uint_16p hist;\n#endif\n\n#ifdef PNG_pCAL_SUPPORTED\n   /* The pCAL chunk describes a transformation between the stored pixel\n    * values and original physical data values used to create the image.\n    * The integer range [0, 2^bit_depth - 1] maps to the floating-point\n    * range given by [pcal_X0, pcal_X1], and are further transformed by a\n    * (possibly non-linear) transformation function given by \"pcal_type\"\n    * and \"pcal_params\" into \"pcal_units\".  Please see the PNG_EQUATION_\n    * defines below, and the PNG-Group's PNG extensions document for a\n    * complete description of the transformations and how they should be\n    * implemented, and for a description of the ASCII parameter strings.\n    * Data values are valid if (valid & PNG_INFO_pCAL) non-zero.\n    */\n   png_charp pcal_purpose;  /* pCAL chunk description string */\n   png_int_32 pcal_X0;      /* minimum value */\n   png_int_32 pcal_X1;      /* maximum value */\n   png_charp pcal_units;    /* Latin-1 string giving physical units */\n   png_charpp pcal_params;  /* ASCII strings containing parameter values */\n   png_byte pcal_type;      /* equation type (see PNG_EQUATION_ below) */\n   png_byte pcal_nparams;   /* number of parameters given in pcal_params */\n#endif\n\n/* New members added in libpng-1.0.6 */\n   png_uint_32 free_me;     /* flags items libpng is responsible for freeing */\n\n#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED\n   /* Storage for unknown chunks that the library doesn't recognize. */\n   png_unknown_chunkp unknown_chunks;\n\n   /* The type of this field is limited by the type of \n    * png_struct::user_chunk_cache_max, else overflow can occur.\n    */\n   int                unknown_chunks_num;\n#endif\n\n#ifdef PNG_sPLT_SUPPORTED\n   /* Data on sPLT chunks (there may be more than one). */\n   png_sPLT_tp splt_palettes;\n   int         splt_palettes_num; /* Match type returned by png_get API */\n#endif\n\n#ifdef PNG_sCAL_SUPPORTED\n   /* The sCAL chunk describes the actual physical dimensions of the\n    * subject matter of the graphic.  The chunk contains a unit specification\n    * a byte value, and two ASCII strings representing floating-point\n    * values.  The values are width and height corresponsing to one pixel\n    * in the image.  Data values are valid if (valid & PNG_INFO_sCAL) is\n    * non-zero.\n    */\n   png_byte scal_unit;         /* unit of physical scale */\n   png_charp scal_s_width;     /* string containing height */\n   png_charp scal_s_height;    /* string containing width */\n#endif\n\n#ifdef PNG_INFO_IMAGE_SUPPORTED\n   /* Memory has been allocated if (valid & PNG_ALLOCATED_INFO_ROWS)\n      non-zero */\n   /* Data valid if (valid & PNG_INFO_IDAT) non-zero */\n   png_bytepp row_pointers;        /* the image bits */\n#endif\n\n};\n#endif /* PNGINFO_H */\n"
  },
  {
    "path": "Libraries/Core/iOS/Headers/png/pnglibconf.h",
    "content": "/* libpng 1.6.10 STANDARD API DEFINITION */\n\n/* pnglibconf.h - library build configuration */\n\n/* Libpng version 1.6.10 - March 6, 2014 */\n\n/* Copyright (c) 1998-2013 Glenn Randers-Pehrson */\n\n/* This code is released under the libpng license. */\n/* For conditions of distribution and use, see the disclaimer */\n/* and license in png.h */\n\n/* pnglibconf.h */\n/* Machine generated file: DO NOT EDIT */\n/* Derived from: scripts/pnglibconf.dfa */\n#ifndef PNGLCONF_H\n#define PNGLCONF_H\n/* options */\n#define PNG_16BIT_SUPPORTED\n#define PNG_ALIGNED_MEMORY_SUPPORTED\n/*#undef PNG_ARM_NEON_API_SUPPORTED*/\n/*#undef PNG_ARM_NEON_CHECK_SUPPORTED*/\n#define PNG_BENIGN_ERRORS_SUPPORTED\n#define PNG_BENIGN_READ_ERRORS_SUPPORTED\n/*#undef PNG_BENIGN_WRITE_ERRORS_SUPPORTED*/\n#define PNG_BUILD_GRAYSCALE_PALETTE_SUPPORTED\n#define PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED\n#define PNG_COLORSPACE_SUPPORTED\n#define PNG_CONSOLE_IO_SUPPORTED\n#define PNG_CONVERT_tIME_SUPPORTED\n#define PNG_EASY_ACCESS_SUPPORTED\n/*#undef PNG_ERROR_NUMBERS_SUPPORTED*/\n#define PNG_ERROR_TEXT_SUPPORTED\n#define PNG_FIXED_POINT_SUPPORTED\n#define PNG_FLOATING_ARITHMETIC_SUPPORTED\n#define PNG_FLOATING_POINT_SUPPORTED\n#define PNG_FORMAT_AFIRST_SUPPORTED\n#define PNG_FORMAT_BGR_SUPPORTED\n#define PNG_GAMMA_SUPPORTED\n#define PNG_GET_PALETTE_MAX_SUPPORTED\n#define PNG_HANDLE_AS_UNKNOWN_SUPPORTED\n#define PNG_INCH_CONVERSIONS_SUPPORTED\n#define PNG_INFO_IMAGE_SUPPORTED\n#define PNG_IO_STATE_SUPPORTED\n#define PNG_MNG_FEATURES_SUPPORTED\n#define PNG_POINTER_INDEXING_SUPPORTED\n#define PNG_PROGRESSIVE_READ_SUPPORTED\n#define PNG_READ_16BIT_SUPPORTED\n#define PNG_READ_ALPHA_MODE_SUPPORTED\n#define PNG_READ_ANCILLARY_CHUNKS_SUPPORTED\n#define PNG_READ_BACKGROUND_SUPPORTED\n#define PNG_READ_BGR_SUPPORTED\n#define PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED\n#define PNG_READ_COMPOSITE_NODIV_SUPPORTED\n#define PNG_READ_COMPRESSED_TEXT_SUPPORTED\n#define PNG_READ_EXPAND_16_SUPPORTED\n#define PNG_READ_EXPAND_SUPPORTED\n#define PNG_READ_FILLER_SUPPORTED\n#define PNG_READ_GAMMA_SUPPORTED\n#define PNG_READ_GET_PALETTE_MAX_SUPPORTED\n#define PNG_READ_GRAY_TO_RGB_SUPPORTED\n#define PNG_READ_INTERLACING_SUPPORTED\n#define PNG_READ_INT_FUNCTIONS_SUPPORTED\n#define PNG_READ_INVERT_ALPHA_SUPPORTED\n#define PNG_READ_INVERT_SUPPORTED\n#define PNG_READ_OPT_PLTE_SUPPORTED\n#define PNG_READ_PACKSWAP_SUPPORTED\n#define PNG_READ_PACK_SUPPORTED\n#define PNG_READ_QUANTIZE_SUPPORTED\n#define PNG_READ_RGB_TO_GRAY_SUPPORTED\n#define PNG_READ_SCALE_16_TO_8_SUPPORTED\n#define PNG_READ_SHIFT_SUPPORTED\n#define PNG_READ_STRIP_16_TO_8_SUPPORTED\n#define PNG_READ_STRIP_ALPHA_SUPPORTED\n#define PNG_READ_SUPPORTED\n#define PNG_READ_SWAP_ALPHA_SUPPORTED\n#define PNG_READ_SWAP_SUPPORTED\n#define PNG_READ_TEXT_SUPPORTED\n#define PNG_READ_TRANSFORMS_SUPPORTED\n#define PNG_READ_UNKNOWN_CHUNKS_SUPPORTED\n#define PNG_READ_USER_CHUNKS_SUPPORTED\n#define PNG_READ_USER_TRANSFORM_SUPPORTED\n#define PNG_READ_bKGD_SUPPORTED\n#define PNG_READ_cHRM_SUPPORTED\n#define PNG_READ_gAMA_SUPPORTED\n#define PNG_READ_hIST_SUPPORTED\n#define PNG_READ_iCCP_SUPPORTED\n#define PNG_READ_iTXt_SUPPORTED\n#define PNG_READ_oFFs_SUPPORTED\n#define PNG_READ_pCAL_SUPPORTED\n#define PNG_READ_pHYs_SUPPORTED\n#define PNG_READ_sBIT_SUPPORTED\n#define PNG_READ_sCAL_SUPPORTED\n#define PNG_READ_sPLT_SUPPORTED\n#define PNG_READ_sRGB_SUPPORTED\n#define PNG_READ_tEXt_SUPPORTED\n#define PNG_READ_tIME_SUPPORTED\n#define PNG_READ_tRNS_SUPPORTED\n#define PNG_READ_zTXt_SUPPORTED\n/*#undef PNG_SAFE_LIMITS_SUPPORTED*/\n#define PNG_SAVE_INT_32_SUPPORTED\n#define PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED\n#define PNG_SEQUENTIAL_READ_SUPPORTED\n#define PNG_SETJMP_SUPPORTED\n#define PNG_SET_CHUNK_CACHE_LIMIT_SUPPORTED\n#define PNG_SET_CHUNK_MALLOC_LIMIT_SUPPORTED\n#define PNG_SET_OPTION_SUPPORTED\n#define PNG_SET_UNKNOWN_CHUNKS_SUPPORTED\n#define PNG_SET_USER_LIMITS_SUPPORTED\n#define PNG_SIMPLIFIED_READ_AFIRST_SUPPORTED\n#define PNG_SIMPLIFIED_READ_BGR_SUPPORTED\n#define PNG_SIMPLIFIED_READ_SUPPORTED\n#define PNG_SIMPLIFIED_WRITE_AFIRST_SUPPORTED\n#define PNG_SIMPLIFIED_WRITE_BGR_SUPPORTED\n#define PNG_SIMPLIFIED_WRITE_SUPPORTED\n#define PNG_STDIO_SUPPORTED\n#define PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED\n#define PNG_TEXT_SUPPORTED\n#define PNG_TIME_RFC1123_SUPPORTED\n#define PNG_UNKNOWN_CHUNKS_SUPPORTED\n#define PNG_USER_CHUNKS_SUPPORTED\n#define PNG_USER_LIMITS_SUPPORTED\n#define PNG_USER_MEM_SUPPORTED\n#define PNG_USER_TRANSFORM_INFO_SUPPORTED\n#define PNG_USER_TRANSFORM_PTR_SUPPORTED\n#define PNG_WARNINGS_SUPPORTED\n#define PNG_WRITE_16BIT_SUPPORTED\n#define PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED\n#define PNG_WRITE_BGR_SUPPORTED\n#define PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED\n#define PNG_WRITE_COMPRESSED_TEXT_SUPPORTED\n#define PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED\n#define PNG_WRITE_FILLER_SUPPORTED\n#define PNG_WRITE_FILTER_SUPPORTED\n#define PNG_WRITE_FLUSH_SUPPORTED\n#define PNG_WRITE_GET_PALETTE_MAX_SUPPORTED\n#define PNG_WRITE_INTERLACING_SUPPORTED\n#define PNG_WRITE_INT_FUNCTIONS_SUPPORTED\n#define PNG_WRITE_INVERT_ALPHA_SUPPORTED\n#define PNG_WRITE_INVERT_SUPPORTED\n#define PNG_WRITE_OPTIMIZE_CMF_SUPPORTED\n#define PNG_WRITE_PACKSWAP_SUPPORTED\n#define PNG_WRITE_PACK_SUPPORTED\n#define PNG_WRITE_SHIFT_SUPPORTED\n#define PNG_WRITE_SUPPORTED\n#define PNG_WRITE_SWAP_ALPHA_SUPPORTED\n#define PNG_WRITE_SWAP_SUPPORTED\n#define PNG_WRITE_TEXT_SUPPORTED\n#define PNG_WRITE_TRANSFORMS_SUPPORTED\n#define PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED\n#define PNG_WRITE_USER_TRANSFORM_SUPPORTED\n#define PNG_WRITE_WEIGHTED_FILTER_SUPPORTED\n#define PNG_WRITE_bKGD_SUPPORTED\n#define PNG_WRITE_cHRM_SUPPORTED\n#define PNG_WRITE_gAMA_SUPPORTED\n#define PNG_WRITE_hIST_SUPPORTED\n#define PNG_WRITE_iCCP_SUPPORTED\n#define PNG_WRITE_iTXt_SUPPORTED\n#define PNG_WRITE_oFFs_SUPPORTED\n#define PNG_WRITE_pCAL_SUPPORTED\n#define PNG_WRITE_pHYs_SUPPORTED\n#define PNG_WRITE_sBIT_SUPPORTED\n#define PNG_WRITE_sCAL_SUPPORTED\n#define PNG_WRITE_sPLT_SUPPORTED\n#define PNG_WRITE_sRGB_SUPPORTED\n#define PNG_WRITE_tEXt_SUPPORTED\n#define PNG_WRITE_tIME_SUPPORTED\n#define PNG_WRITE_tRNS_SUPPORTED\n#define PNG_WRITE_zTXt_SUPPORTED\n#define PNG_bKGD_SUPPORTED\n#define PNG_cHRM_SUPPORTED\n#define PNG_gAMA_SUPPORTED\n#define PNG_hIST_SUPPORTED\n#define PNG_iCCP_SUPPORTED\n#define PNG_iTXt_SUPPORTED\n#define PNG_oFFs_SUPPORTED\n#define PNG_pCAL_SUPPORTED\n#define PNG_pHYs_SUPPORTED\n#define PNG_sBIT_SUPPORTED\n#define PNG_sCAL_SUPPORTED\n#define PNG_sPLT_SUPPORTED\n#define PNG_sRGB_SUPPORTED\n#define PNG_tEXt_SUPPORTED\n#define PNG_tIME_SUPPORTED\n#define PNG_tRNS_SUPPORTED\n#define PNG_zTXt_SUPPORTED\n/* end of options */\n/* settings */\n#define PNG_API_RULE 0\n#define PNG_CALLOC_SUPPORTED\n#define PNG_COST_SHIFT 3\n#define PNG_DEFAULT_READ_MACROS 1\n#define PNG_GAMMA_THRESHOLD_FIXED 5000\n#define PNG_IDAT_READ_SIZE PNG_ZBUF_SIZE\n#define PNG_INFLATE_BUF_SIZE 1024\n#define PNG_MAX_GAMMA_8 11\n#define PNG_QUANTIZE_BLUE_BITS 5\n#define PNG_QUANTIZE_GREEN_BITS 5\n#define PNG_QUANTIZE_RED_BITS 5\n#define PNG_TEXT_Z_DEFAULT_COMPRESSION (-1)\n#define PNG_TEXT_Z_DEFAULT_STRATEGY 0\n#define PNG_WEIGHT_SHIFT 8\n#define PNG_ZBUF_SIZE 8192\n#define PNG_ZLIB_VERNUM 0 /* unknown */\n#define PNG_Z_DEFAULT_COMPRESSION (-1)\n#define PNG_Z_DEFAULT_NOFILTER_STRATEGY 0\n#define PNG_Z_DEFAULT_STRATEGY 1\n#define PNG_sCAL_PRECISION 5\n#define PNG_sRGB_PROFILE_CHECKS 2\n/* end of settings */\n#endif /* PNGLCONF_H */\n"
  },
  {
    "path": "Libraries/Core/iOS/Headers/png/pngpriv.h",
    "content": "\n/* pngpriv.h - private declarations for use inside libpng\n *\n * For conditions of distribution and use, see copyright notice in png.h\n * Copyright (c) 1998-2014 Glenn Randers-Pehrson\n * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)\n * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)\n *\n * Last changed in libpng 1.6.10 [March 6, 2014]\n *\n * This code is released under the libpng license.\n * For conditions of distribution and use, see the disclaimer\n * and license in png.h\n */\n\n/* The symbols declared in this file (including the functions declared\n * as extern) are PRIVATE.  They are not part of the libpng public\n * interface, and are not recommended for use by regular applications.\n * Some of them may become public in the future; others may stay private,\n * change in an incompatible way, or even disappear.\n * Although the libpng users are not forbidden to include this header,\n * they should be well aware of the issues that may arise from doing so.\n */\n\n#ifndef PNGPRIV_H\n#define PNGPRIV_H\n\n/* Feature Test Macros.  The following are defined here to ensure that correctly\n * implemented libraries reveal the APIs libpng needs to build and hide those\n * that are not needed and potentially damaging to the compilation.\n *\n * Feature Test Macros must be defined before any system header is included (see\n * POSIX 1003.1 2.8.2 \"POSIX Symbols.\"\n *\n * These macros only have an effect if the operating system supports either\n * POSIX 1003.1 or C99, or both.  On other operating systems (particularly\n * Windows/Visual Studio) there is no effect; the OS specific tests below are\n * still required (as of 2011-05-02.)\n */\n#define _POSIX_SOURCE 1 /* Just the POSIX 1003.1 and C89 APIs */\n\n#ifndef PNG_VERSION_INFO_ONLY\n/* Standard library headers not required by png.h: */\n#  include <stdlib.h>\n#  include <string.h>\n#endif\n\n#define PNGLIB_BUILD /*libpng is being built, not used*/\n\n/* If HAVE_CONFIG_H is defined during the build then the build system must\n * provide an appropriate \"config.h\" file on the include path.  The header file\n * must provide definitions as required below (search for \"HAVE_CONFIG_H\");\n * see configure.ac for more details of the requirements.  The macro\n * \"PNG_NO_CONFIG_H\" is provided for maintainers to test for dependencies on\n * 'configure'; define this macro to prevent the configure build including the\n * configure generated config.h.  Libpng is expected to compile without *any*\n * special build system support on a reasonably ANSI-C compliant system.\n */\n#if defined(HAVE_CONFIG_H) && !defined(PNG_NO_CONFIG_H)\n#  include <config.h>\n\n   /* Pick up the definition of 'restrict' from config.h if it was read: */\n#  define PNG_RESTRICT restrict\n#endif\n\n/* To support symbol prefixing it is necessary to know *before* including png.h\n * whether the fixed point (and maybe other) APIs are exported, because if they\n * are not internal definitions may be required.  This is handled below just\n * before png.h is included, but load the configuration now if it is available.\n */\n#ifndef PNGLCONF_H\n#  include \"pnglibconf.h\"\n#endif\n\n/* Local renames may change non-exported API functions from png.h */\n#if defined(PNG_PREFIX) && !defined(PNGPREFIX_H)\n#  include \"pngprefix.h\"\n#endif\n\n#ifdef PNG_USER_CONFIG\n#  include \"pngusr.h\"\n   /* These should have been defined in pngusr.h */\n#  ifndef PNG_USER_PRIVATEBUILD\n#    define PNG_USER_PRIVATEBUILD \"Custom libpng build\"\n#  endif\n#  ifndef PNG_USER_DLLFNAME_POSTFIX\n#    define PNG_USER_DLLFNAME_POSTFIX \"Cb\"\n#  endif\n#endif\n\n/* Compile time options.\n * =====================\n * In a multi-arch build the compiler may compile the code several times for the\n * same object module, producing different binaries for different architectures.\n * When this happens configure-time setting of the target host options cannot be\n * done and this interferes with the handling of the ARM NEON optimizations, and\n * possibly other similar optimizations.  Put additional tests here; in general\n * this is needed when the same option can be changed at both compile time and\n * run time depending on the target OS (i.e. iOS vs Android.)\n *\n * NOTE: symbol prefixing does not pass $(CFLAGS) to the preprocessor, because\n * this is not possible with certain compilers (Oracle SUN OS CC), as a result\n * it is necessary to ensure that all extern functions that *might* be used\n * regardless of $(CFLAGS) get declared in this file.  The test on __ARM_NEON__\n * below is one example of this behavior because it is controlled by the\n * presence or not of -mfpu=neon on the GCC command line, it is possible to do\n * this in $(CC), e.g. \"CC=gcc -mfpu=neon\", but people who build libpng rarely\n * do this.\n */\n#ifndef PNG_ARM_NEON_OPT\n   /* ARM NEON optimizations are being controlled by the compiler settings,\n    * typically the target FPU.  If the FPU has been set to NEON (-mfpu=neon\n    * with GCC) then the compiler will define __ARM_NEON__ and we can rely\n    * unconditionally on NEON instructions not crashing, otherwise we must\n    * disable use of NEON instructions.\n    *\n    * NOTE: at present these optimizations depend on 'ALIGNED_MEMORY', so they\n    * can only be turned on automatically if that is supported too.  If\n    * PNG_ARM_NEON_OPT is set in CPPFLAGS (to >0) then arm/arm_init.c will fail\n    * to compile with an appropriate #error if ALIGNED_MEMORY has been turned\n    * off.\n    */\n#  if defined(__ARM_NEON__) && defined(PNG_ALIGNED_MEMORY_SUPPORTED)\n#     define PNG_ARM_NEON_OPT 2\n#  else\n#     define PNG_ARM_NEON_OPT 0\n#  endif\n#endif\n\n#if PNG_ARM_NEON_OPT > 0\n   /* NEON optimizations are to be at least considered by libpng, so enable the\n    * callbacks to do this.\n    */\n#  define PNG_FILTER_OPTIMIZATIONS png_init_filter_functions_neon\n\n   /* By default the 'intrinsics' code in arm/filter_neon_intrinsics.c is used\n    * if possible - if __ARM_NEON__ is set and the compiler version is not known\n    * to be broken.  This is controlled by PNG_ARM_NEON_IMPLEMENTATION which can\n    * be:\n    *\n    *    1  The intrinsics code (the default with __ARM_NEON__)\n    *    2  The hand coded assembler (the default without __ARM_NEON__)\n    *\n    * It is possible to set PNG_ARM_NEON_IMPLEMENTATION in CPPFLAGS, however\n    * this is *NOT* supported and may cease to work even after a minor revision\n    * to libpng.  It *is* valid to do this for testing purposes, e.g. speed\n    * testing or a new compiler, but the results should be communicated to the\n    * libpng implementation list for incorporation in the next minor release.\n    */\n#  ifndef PNG_ARM_NEON_IMPLEMENTATION\n#     ifdef __ARM_NEON__\n#        if defined(__clang__)\n            /* At present it is unknown by the libpng developers which versions\n             * of clang support the intrinsics, however some or perhaps all\n             * versions do not work with the assembler so this may be\n             * irrelevant, so just use the default (do nothing here.)\n             */\n#        elif defined(__GNUC__)\n            /* GCC 4.5.4 NEON support is known to be broken.  4.6.3 is known to\n             * work, so if this *is* GCC, or G++, look for a version >4.5\n             */\n#           if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 6)\n#              define PNG_ARM_NEON_IMPLEMENTATION 2\n#           endif /* no GNUC support */\n#        endif /* __GNUC__ */\n#     else /* !defined __ARM_NEON__ */\n         /* The 'intrinsics' code simply won't compile without this -mfpu=neon:\n          */\n#        define PNG_ARM_NEON_IMPLEMENTATION 2\n#     endif /* __ARM_NEON__ */\n#  endif /* !defined PNG_ARM_NEON_IMPLEMENTATION */\n\n#  ifndef PNG_ARM_NEON_IMPLEMENTATION\n      /* Use the intrinsics code by default. */\n#     define PNG_ARM_NEON_IMPLEMENTATION 1\n#  endif\n#endif /* PNG_ARM_NEON_OPT > 0 */\n\n/* Is this a build of a DLL where compilation of the object modules requires\n * different preprocessor settings to those required for a simple library?  If\n * so PNG_BUILD_DLL must be set.\n *\n * If libpng is used inside a DLL but that DLL does not export the libpng APIs\n * PNG_BUILD_DLL must not be set.  To avoid the code below kicking in build a\n * static library of libpng then link the DLL against that.\n */\n#ifndef PNG_BUILD_DLL\n#  ifdef DLL_EXPORT\n      /* This is set by libtool when files are compiled for a DLL; libtool\n       * always compiles twice, even on systems where it isn't necessary.  Set\n       * PNG_BUILD_DLL in case it is necessary:\n       */\n#     define PNG_BUILD_DLL\n#  else\n#     ifdef _WINDLL\n         /* This is set by the Microsoft Visual Studio IDE in projects that\n          * build a DLL.  It can't easily be removed from those projects (it\n          * isn't visible in the Visual Studio UI) so it is a fairly reliable\n          * indication that PNG_IMPEXP needs to be set to the DLL export\n          * attributes.\n          */\n#        define PNG_BUILD_DLL\n#     else\n#        ifdef __DLL__\n            /* This is set by the Borland C system when compiling for a DLL\n             * (as above.)\n             */\n#           define PNG_BUILD_DLL\n#        else\n            /* Add additional compiler cases here. */\n#        endif\n#     endif\n#  endif\n#endif /* Setting PNG_BUILD_DLL if required */\n\n/* See pngconf.h for more details: the builder of the library may set this on\n * the command line to the right thing for the specific compilation system or it\n * may be automagically set above (at present we know of no system where it does\n * need to be set on the command line.)\n *\n * PNG_IMPEXP must be set here when building the library to prevent pngconf.h\n * setting it to the \"import\" setting for a DLL build.\n */\n#ifndef PNG_IMPEXP\n#  ifdef PNG_BUILD_DLL\n#     define PNG_IMPEXP PNG_DLL_EXPORT\n#  else\n      /* Not building a DLL, or the DLL doesn't require specific export\n       * definitions.\n       */\n#     define PNG_IMPEXP\n#  endif\n#endif\n\n/* No warnings for private or deprecated functions in the build: */\n#ifndef PNG_DEPRECATED\n#  define PNG_DEPRECATED\n#endif\n#ifndef PNG_PRIVATE\n#  define PNG_PRIVATE\n#endif\n\n/* Symbol preprocessing support.\n *\n * To enable listing global, but internal, symbols the following macros should\n * always be used to declare an extern data or function object in this file.\n */\n#ifndef PNG_INTERNAL_DATA\n#  define PNG_INTERNAL_DATA(type, name, array) extern type name array\n#endif\n\n#ifndef PNG_INTERNAL_FUNCTION\n#  define PNG_INTERNAL_FUNCTION(type, name, args, attributes)\\\n      extern PNG_FUNCTION(type, name, args, PNG_EMPTY attributes)\n#endif\n\n#ifndef PNG_INTERNAL_CALLBACK\n#  define PNG_INTERNAL_CALLBACK(type, name, args, attributes)\\\n      extern PNG_FUNCTION(type, (PNGCBAPI name), args, PNG_EMPTY attributes)\n#endif\n\n/* If floating or fixed point APIs are disabled they may still be compiled\n * internally.  To handle this make sure they are declared as the appropriate\n * internal extern function (otherwise the symbol prefixing stuff won't work and\n * the functions will be used without definitions.)\n *\n * NOTE: although all the API functions are declared here they are not all\n * actually built!  Because the declarations are still made it is necessary to\n * fake out types that they depend on.\n */\n#ifndef PNG_FP_EXPORT\n#  ifndef PNG_FLOATING_POINT_SUPPORTED\n#     define PNG_FP_EXPORT(ordinal, type, name, args)\\\n         PNG_INTERNAL_FUNCTION(type, name, args, PNG_EMPTY);\n#     ifndef PNG_VERSION_INFO_ONLY\n         typedef struct png_incomplete png_double;\n         typedef png_double*           png_doublep;\n         typedef const png_double*     png_const_doublep;\n         typedef png_double**          png_doublepp;\n#     endif\n#  endif\n#endif\n#ifndef PNG_FIXED_EXPORT\n#  ifndef PNG_FIXED_POINT_SUPPORTED\n#     define PNG_FIXED_EXPORT(ordinal, type, name, args)\\\n         PNG_INTERNAL_FUNCTION(type, name, args, PNG_EMPTY);\n#  endif\n#endif\n\n#include \"png.h\"\n\n/* pngconf.h does not set PNG_DLL_EXPORT unless it is required, so: */\n#ifndef PNG_DLL_EXPORT\n#  define PNG_DLL_EXPORT\n#endif\n\n/* SECURITY and SAFETY:\n *\n * By default libpng is built without any internal limits on image size,\n * individual heap (png_malloc) allocations or the total amount of memory used.\n * If PNG_SAFE_LIMITS_SUPPORTED is defined, however, the limits below are used\n * (unless individually overridden).  These limits are believed to be fairly\n * safe, but builders of secure systems should verify the values against the\n * real system capabilities.\n */\n#ifdef PNG_SAFE_LIMITS_SUPPORTED\n   /* 'safe' limits */\n#  ifndef PNG_USER_WIDTH_MAX\n#     define PNG_USER_WIDTH_MAX 1000000\n#  endif\n#  ifndef PNG_USER_HEIGHT_MAX\n#     define PNG_USER_HEIGHT_MAX 1000000\n#  endif\n#  ifndef PNG_USER_CHUNK_CACHE_MAX\n#     define PNG_USER_CHUNK_CACHE_MAX 128\n#  endif\n#  ifndef PNG_USER_CHUNK_MALLOC_MAX\n#     define PNG_USER_CHUNK_MALLOC_MAX 8000000\n#  endif\n#else\n   /* values for no limits */\n#  ifndef PNG_USER_WIDTH_MAX\n#     define PNG_USER_WIDTH_MAX 0x7fffffff\n#  endif\n#  ifndef PNG_USER_HEIGHT_MAX\n#     define PNG_USER_HEIGHT_MAX 0x7fffffff\n#  endif\n#  ifndef PNG_USER_CHUNK_CACHE_MAX\n#     define PNG_USER_CHUNK_CACHE_MAX 0\n#  endif\n#  ifndef PNG_USER_CHUNK_MALLOC_MAX\n#     define PNG_USER_CHUNK_MALLOC_MAX 0\n#  endif\n#endif\n\n/* Moved to pngpriv.h at libpng-1.5.0 */\n/* NOTE: some of these may have been used in external applications as\n * these definitions were exposed in pngconf.h prior to 1.5.\n */\n\n/* If you are running on a machine where you cannot allocate more\n * than 64K of memory at once, uncomment this.  While libpng will not\n * normally need that much memory in a chunk (unless you load up a very\n * large file), zlib needs to know how big of a chunk it can use, and\n * libpng thus makes sure to check any memory allocation to verify it\n * will fit into memory.\n *\n * zlib provides 'MAXSEG_64K' which, if defined, indicates the\n * same limit and pngconf.h (already included) sets the limit\n * if certain operating systems are detected.\n */\n#if defined(MAXSEG_64K) && !defined(PNG_MAX_MALLOC_64K)\n#  define PNG_MAX_MALLOC_64K\n#endif\n\n#ifndef PNG_UNUSED\n/* Unused formal parameter warnings are silenced using the following macro\n * which is expected to have no bad effects on performance (optimizing\n * compilers will probably remove it entirely).  Note that if you replace\n * it with something other than whitespace, you must include the terminating\n * semicolon.\n */\n#  define PNG_UNUSED(param) (void)param;\n#endif\n\n/* Just a little check that someone hasn't tried to define something\n * contradictory.\n */\n#if (PNG_ZBUF_SIZE > 65536L) && defined(PNG_MAX_MALLOC_64K)\n#  undef PNG_ZBUF_SIZE\n#  define PNG_ZBUF_SIZE 65536L\n#endif\n\n/* If warnings or errors are turned off the code is disabled or redirected here.\n * From 1.5.4 functions have been added to allow very limited formatting of\n * error and warning messages - this code will also be disabled here.\n */\n#ifdef PNG_WARNINGS_SUPPORTED\n#  define PNG_WARNING_PARAMETERS(p) png_warning_parameters p;\n#else\n#  define png_warning_parameter(p,number,string) ((void)0)\n#  define png_warning_parameter_unsigned(p,number,format,value) ((void)0)\n#  define png_warning_parameter_signed(p,number,format,value) ((void)0)\n#  define png_formatted_warning(pp,p,message) ((void)(pp))\n#  define PNG_WARNING_PARAMETERS(p)\n#endif\n#ifndef PNG_ERROR_TEXT_SUPPORTED\n#  define png_fixed_error(s1,s2) png_err(s1)\n#endif\n\n/* C allows up-casts from (void*) to any pointer and (const void*) to any\n * pointer to a const object.  C++ regards this as a type error and requires an\n * explicit, static, cast and provides the static_cast<> rune to ensure that\n * const is not cast away.\n */\n#ifdef __cplusplus\n#  define png_voidcast(type, value) static_cast<type>(value)\n#  define png_constcast(type, value) const_cast<type>(value)\n#  define png_aligncast(type, value) \\\n   static_cast<type>(static_cast<void*>(value))\n#  define png_aligncastconst(type, value) \\\n   static_cast<type>(static_cast<const void*>(value))\n#else\n#  define png_voidcast(type, value) (value)\n#  define png_constcast(type, value) ((type)(value))\n#  define png_aligncast(type, value) ((void*)(value))\n#  define png_aligncastconst(type, value) ((const void*)(value))\n#endif /* __cplusplus */\n\n/* Some fixed point APIs are still required even if not exported because\n * they get used by the corresponding floating point APIs.  This magic\n * deals with this:\n */\n#ifdef PNG_FIXED_POINT_SUPPORTED\n#  define PNGFAPI PNGAPI\n#else\n#  define PNGFAPI /* PRIVATE */\n#endif\n\n#ifndef PNG_VERSION_INFO_ONLY\n/* Other defines specific to compilers can go here.  Try to keep\n * them inside an appropriate ifdef/endif pair for portability.\n */\n#if defined(PNG_FLOATING_POINT_SUPPORTED) ||\\\n    defined(PNG_FLOATING_ARITHMETIC_SUPPORTED)\n   /* png.c requires the following ANSI-C constants if the conversion of\n    * floating point to ASCII is implemented therein:\n    *\n    *  DBL_DIG  Maximum number of decimal digits (can be set to any constant)\n    *  DBL_MIN  Smallest normalized fp number (can be set to an arbitrary value)\n    *  DBL_MAX  Maximum floating point number (can be set to an arbitrary value)\n    */\n#  include <float.h>\n\n#  if (defined(__MWERKS__) && defined(macintosh)) || defined(applec) || \\\n    defined(THINK_C) || defined(__SC__) || defined(TARGET_OS_MAC)\n     /* We need to check that <math.h> hasn't already been included earlier\n      * as it seems it doesn't agree with <fp.h>, yet we should really use\n      * <fp.h> if possible.\n      */\n#    if !defined(__MATH_H__) && !defined(__MATH_H) && !defined(__cmath__)\n#      include <fp.h>\n#    endif\n#  else\n#    include <math.h>\n#  endif\n#  if defined(_AMIGA) && defined(__SASC) && defined(_M68881)\n     /* Amiga SAS/C: We must include builtin FPU functions when compiling using\n      * MATH=68881\n      */\n#    include <m68881.h>\n#  endif\n#endif\n\n/* This provides the non-ANSI (far) memory allocation routines. */\n#if defined(__TURBOC__) && defined(__MSDOS__)\n#  include <mem.h>\n#  include <alloc.h>\n#endif\n\n#if defined(WIN32) || defined(_Windows) || defined(_WINDOWS) || \\\n    defined(_WIN32) || defined(__WIN32__)\n#  include <windows.h>  /* defines _WINDOWS_ macro */\n#endif\n#endif /* PNG_VERSION_INFO_ONLY */\n\n/* Moved here around 1.5.0beta36 from pngconf.h */\n/* Users may want to use these so they are not private.  Any library\n * functions that are passed far data must be model-independent.\n */\n\n/* Memory model/platform independent fns */\n#ifndef PNG_ABORT\n#  ifdef _WINDOWS_\n#    define PNG_ABORT() ExitProcess(0)\n#  else\n#    define PNG_ABORT() abort()\n#  endif\n#endif\n\n/* These macros may need to be architecture dependent. */\n#define PNG_ALIGN_NONE   0 /* do not use data alignment */\n#define PNG_ALIGN_ALWAYS 1 /* assume unaligned accesses are OK */\n#ifdef offsetof\n#  define PNG_ALIGN_OFFSET 2 /* use offsetof to determine alignment */\n#else\n#  define PNG_ALIGN_OFFSET -1 /* prevent the use of this */\n#endif\n#define PNG_ALIGN_SIZE   3 /* use sizeof to determine alignment */\n\n#ifndef PNG_ALIGN_TYPE\n   /* Default to using aligned access optimizations and requiring alignment to a\n    * multiple of the data type size.  Override in a compiler specific fashion\n    * if necessary by inserting tests here:\n    */\n#  define PNG_ALIGN_TYPE PNG_ALIGN_SIZE\n#endif\n\n#if PNG_ALIGN_TYPE == PNG_ALIGN_SIZE\n   /* This is used because in some compiler implementations non-aligned\n    * structure members are supported, so the offsetof approach below fails.\n    * Set PNG_ALIGN_SIZE=0 for compiler combinations where unaligned access\n    * is good for performance.  Do not do this unless you have tested the result\n    * and understand it.\n    */\n#  define png_alignof(type) (sizeof (type))\n#else\n#  if PNG_ALIGN_TYPE == PNG_ALIGN_OFFSET\n#     define png_alignof(type) offsetof(struct{char c; type t;}, t)\n#  else\n#     if PNG_ALIGN_TYPE == PNG_ALIGN_ALWAYS\n#        define png_alignof(type) (1)\n#     endif\n      /* Else leave png_alignof undefined to prevent use thereof */\n#  endif\n#endif\n\n/* This implicitly assumes alignment is always to a power of 2. */\n#ifdef png_alignof\n#  define png_isaligned(ptr, type)\\\n   ((((const char*)ptr-(const char*)0) & (png_alignof(type)-1)) == 0)\n#else\n#  define png_isaligned(ptr, type) 0\n#endif\n\n/* End of memory model/platform independent support */\n/* End of 1.5.0beta36 move from pngconf.h */\n\n/* CONSTANTS and UTILITY MACROS\n * These are used internally by libpng and not exposed in the API\n */\n\n/* Various modes of operation.  Note that after an init, mode is set to\n * zero automatically when the structure is created.  Three of these\n * are defined in png.h because they need to be visible to applications\n * that call png_set_unknown_chunk().\n */\n/* #define PNG_HAVE_IHDR            0x01 (defined in png.h) */\n/* #define PNG_HAVE_PLTE            0x02 (defined in png.h) */\n#define PNG_HAVE_IDAT               0x04\n/* #define PNG_AFTER_IDAT           0x08 (defined in png.h) */\n#define PNG_HAVE_IEND               0x10\n                   /*               0x20 (unused) */\n                   /*               0x40 (unused) */\n                   /*               0x80 (unused) */\n#define PNG_HAVE_CHUNK_HEADER      0x100\n#define PNG_WROTE_tIME             0x200\n#define PNG_WROTE_INFO_BEFORE_PLTE 0x400\n#define PNG_BACKGROUND_IS_GRAY     0x800\n#define PNG_HAVE_PNG_SIGNATURE    0x1000\n#define PNG_HAVE_CHUNK_AFTER_IDAT 0x2000 /* Have another chunk after IDAT */\n                   /*             0x4000 (unused) */\n#define PNG_IS_READ_STRUCT        0x8000 /* Else is a write struct */\n\n/* Flags for the transformations the PNG library does on the image data */\n#define PNG_BGR                 0x0001\n#define PNG_INTERLACE           0x0002\n#define PNG_PACK                0x0004\n#define PNG_SHIFT               0x0008\n#define PNG_SWAP_BYTES          0x0010\n#define PNG_INVERT_MONO         0x0020\n#define PNG_QUANTIZE            0x0040\n#define PNG_COMPOSE             0x0080     /* Was PNG_BACKGROUND */\n#define PNG_BACKGROUND_EXPAND   0x0100\n#define PNG_EXPAND_16           0x0200     /* Added to libpng 1.5.2 */\n#define PNG_16_TO_8             0x0400     /* Becomes 'chop' in 1.5.4 */\n#define PNG_RGBA                0x0800\n#define PNG_EXPAND              0x1000\n#define PNG_GAMMA               0x2000\n#define PNG_GRAY_TO_RGB         0x4000\n#define PNG_FILLER              0x8000\n#define PNG_PACKSWAP           0x10000\n#define PNG_SWAP_ALPHA         0x20000\n#define PNG_STRIP_ALPHA        0x40000\n#define PNG_INVERT_ALPHA       0x80000\n#define PNG_USER_TRANSFORM    0x100000\n#define PNG_RGB_TO_GRAY_ERR   0x200000\n#define PNG_RGB_TO_GRAY_WARN  0x400000\n#define PNG_RGB_TO_GRAY       0x600000 /* two bits, RGB_TO_GRAY_ERR|WARN */\n#define PNG_ENCODE_ALPHA      0x800000 /* Added to libpng-1.5.4 */\n#define PNG_ADD_ALPHA         0x1000000 /* Added to libpng-1.2.7 */\n#define PNG_EXPAND_tRNS       0x2000000 /* Added to libpng-1.2.9 */\n#define PNG_SCALE_16_TO_8     0x4000000 /* Added to libpng-1.5.4 */\n                       /*   0x8000000 unused */\n                       /*  0x10000000 unused */\n                       /*  0x20000000 unused */\n                       /*  0x40000000 unused */\n/* Flags for png_create_struct */\n#define PNG_STRUCT_PNG   0x0001\n#define PNG_STRUCT_INFO  0x0002\n\n/* Scaling factor for filter heuristic weighting calculations */\n#define PNG_WEIGHT_FACTOR (1<<(PNG_WEIGHT_SHIFT))\n#define PNG_COST_FACTOR (1<<(PNG_COST_SHIFT))\n\n/* Flags for the png_ptr->flags rather than declaring a byte for each one */\n#define PNG_FLAG_ZLIB_CUSTOM_STRATEGY     0x0001\n#define PNG_FLAG_ZSTREAM_INITIALIZED      0x0002 /* Added to libpng-1.6.0 */\n                                  /*      0x0004    unused */\n#define PNG_FLAG_ZSTREAM_ENDED            0x0008 /* Added to libpng-1.6.0 */\n                                  /*      0x0010    unused */\n                                  /*      0x0020    unused */\n#define PNG_FLAG_ROW_INIT                 0x0040\n#define PNG_FLAG_FILLER_AFTER             0x0080\n#define PNG_FLAG_CRC_ANCILLARY_USE        0x0100\n#define PNG_FLAG_CRC_ANCILLARY_NOWARN     0x0200\n#define PNG_FLAG_CRC_CRITICAL_USE         0x0400\n#define PNG_FLAG_CRC_CRITICAL_IGNORE      0x0800\n#define PNG_FLAG_ASSUME_sRGB              0x1000 /* Added to libpng-1.5.4 */\n#define PNG_FLAG_OPTIMIZE_ALPHA           0x2000 /* Added to libpng-1.5.4 */\n#define PNG_FLAG_DETECT_UNINITIALIZED     0x4000 /* Added to libpng-1.5.4 */\n/* #define PNG_FLAG_KEEP_UNKNOWN_CHUNKS      0x8000 */\n/* #define PNG_FLAG_KEEP_UNSAFE_CHUNKS      0x10000 */\n#define PNG_FLAG_LIBRARY_MISMATCH        0x20000\n#define PNG_FLAG_STRIP_ERROR_NUMBERS     0x40000\n#define PNG_FLAG_STRIP_ERROR_TEXT        0x80000\n#define PNG_FLAG_BENIGN_ERRORS_WARN     0x100000 /* Added to libpng-1.4.0 */\n#define PNG_FLAG_APP_WARNINGS_WARN      0x200000 /* Added to libpng-1.6.0 */\n#define PNG_FLAG_APP_ERRORS_WARN        0x400000 /* Added to libpng-1.6.0 */\n                                  /*    0x800000    unused */\n                                  /*   0x1000000    unused */\n                                  /*   0x2000000    unused */\n                                  /*   0x4000000    unused */\n                                  /*   0x8000000    unused */\n                                  /*  0x10000000    unused */\n                                  /*  0x20000000    unused */\n                                  /*  0x40000000    unused */\n\n#define PNG_FLAG_CRC_ANCILLARY_MASK (PNG_FLAG_CRC_ANCILLARY_USE | \\\n                                     PNG_FLAG_CRC_ANCILLARY_NOWARN)\n\n#define PNG_FLAG_CRC_CRITICAL_MASK  (PNG_FLAG_CRC_CRITICAL_USE | \\\n                                     PNG_FLAG_CRC_CRITICAL_IGNORE)\n\n#define PNG_FLAG_CRC_MASK           (PNG_FLAG_CRC_ANCILLARY_MASK | \\\n                                     PNG_FLAG_CRC_CRITICAL_MASK)\n\n/* Save typing and make code easier to understand */\n\n#define PNG_COLOR_DIST(c1, c2) (abs((int)((c1).red) - (int)((c2).red)) + \\\n   abs((int)((c1).green) - (int)((c2).green)) + \\\n   abs((int)((c1).blue) - (int)((c2).blue)))\n\n/* Added to libpng-1.6.0: scale a 16-bit value in the range 0..65535 to 0..255\n * by dividing by 257 *with rounding*.  This macro is exact for the given range.\n * See the discourse in pngrtran.c png_do_scale_16_to_8.  The values in the\n * macro were established by experiment (modifying the added value).  The macro\n * has a second variant that takes a value already scaled by 255 and divides by\n * 65535 - this has a maximum error of .502.  Over the range 0..65535*65535 it\n * only gives off-by-one errors and only for 0.5% (1 in 200) of the values.\n */\n#define PNG_DIV65535(v24) (((v24) + 32895) >> 16)\n#define PNG_DIV257(v16) PNG_DIV65535((png_uint_32)(v16) * 255)\n\n/* Added to libpng-1.2.6 JB */\n#define PNG_ROWBYTES(pixel_bits, width) \\\n    ((pixel_bits) >= 8 ? \\\n    ((png_size_t)(width) * (((png_size_t)(pixel_bits)) >> 3)) : \\\n    (( ((png_size_t)(width) * ((png_size_t)(pixel_bits))) + 7) >> 3) )\n\n/* PNG_OUT_OF_RANGE returns true if value is outside the range\n * ideal-delta..ideal+delta.  Each argument is evaluated twice.\n * \"ideal\" and \"delta\" should be constants, normally simple\n * integers, \"value\" a variable. Added to libpng-1.2.6 JB\n */\n#define PNG_OUT_OF_RANGE(value, ideal, delta) \\\n   ( (value) < (ideal)-(delta) || (value) > (ideal)+(delta) )\n\n/* Conversions between fixed and floating point, only defined if\n * required (to make sure the code doesn't accidentally use float\n * when it is supposedly disabled.)\n */\n#ifdef PNG_FLOATING_POINT_SUPPORTED\n/* The floating point conversion can't overflow, though it can and\n * does lose accuracy relative to the original fixed point value.\n * In practice this doesn't matter because png_fixed_point only\n * stores numbers with very low precision.  The png_ptr and s\n * arguments are unused by default but are there in case error\n * checking becomes a requirement.\n */\n#define png_float(png_ptr, fixed, s) (.00001 * (fixed))\n\n/* The fixed point conversion performs range checking and evaluates\n * its argument multiple times, so must be used with care.  The\n * range checking uses the PNG specification values for a signed\n * 32 bit fixed point value except that the values are deliberately\n * rounded-to-zero to an integral value - 21474 (21474.83 is roughly\n * (2^31-1) * 100000). 's' is a string that describes the value being\n * converted.\n *\n * NOTE: this macro will raise a png_error if the range check fails,\n * therefore it is normally only appropriate to use this on values\n * that come from API calls or other sources where an out of range\n * error indicates a programming error, not a data error!\n *\n * NOTE: by default this is off - the macro is not used - because the\n * function call saves a lot of code.\n */\n#ifdef PNG_FIXED_POINT_MACRO_SUPPORTED\n#define png_fixed(png_ptr, fp, s) ((fp) <= 21474 && (fp) >= -21474 ?\\\n    ((png_fixed_point)(100000 * (fp))) : (png_fixed_error(png_ptr, s),0))\n#endif\n/* else the corresponding function is defined below, inside the scope of the\n * cplusplus test.\n */\n#endif\n\n/* Constants for known chunk types.  If you need to add a chunk, define the name\n * here.  For historical reasons these constants have the form png_<name>; i.e.\n * the prefix is lower case.  Please use decimal values as the parameters to\n * match the ISO PNG specification and to avoid relying on the C locale\n * interpretation of character values.\n *\n * Prior to 1.5.6 these constants were strings, as of 1.5.6 png_uint_32 values\n * are computed and a new macro (PNG_STRING_FROM_CHUNK) added to allow a string\n * to be generated if required.\n *\n * PNG_32b correctly produces a value shifted by up to 24 bits, even on\n * architectures where (int) is only 16 bits.\n */\n#define PNG_32b(b,s) ((png_uint_32)(b) << (s))\n#define PNG_U32(b1,b2,b3,b4) \\\n   (PNG_32b(b1,24) | PNG_32b(b2,16) | PNG_32b(b3,8) | PNG_32b(b4,0))\n\n/* Constants for known chunk types.\n *\n * MAINTAINERS: If you need to add a chunk, define the name here.\n * For historical reasons these constants have the form png_<name>; i.e.\n * the prefix is lower case.  Please use decimal values as the parameters to\n * match the ISO PNG specification and to avoid relying on the C locale\n * interpretation of character values.  Please keep the list sorted.\n *\n * Notice that PNG_U32 is used to define a 32-bit value for the 4 byte chunk\n * type.  In fact the specification does not express chunk types this way,\n * however using a 32-bit value means that the chunk type can be read from the\n * stream using exactly the same code as used for a 32-bit unsigned value and\n * can be examined far more efficiently (using one arithmetic compare).\n *\n * Prior to 1.5.6 the chunk type constants were expressed as C strings.  The\n * libpng API still uses strings for 'unknown' chunks and a macro,\n * PNG_STRING_FROM_CHUNK, allows a string to be generated if required.  Notice\n * that for portable code numeric values must still be used; the string \"IHDR\"\n * is not portable and neither is PNG_U32('I', 'H', 'D', 'R').\n *\n * In 1.7.0 the definitions will be made public in png.h to avoid having to\n * duplicate the same definitions in application code.\n */\n#define png_IDAT PNG_U32( 73,  68,  65,  84)\n#define png_IEND PNG_U32( 73,  69,  78,  68)\n#define png_IHDR PNG_U32( 73,  72,  68,  82)\n#define png_PLTE PNG_U32( 80,  76,  84,  69)\n#define png_bKGD PNG_U32( 98,  75,  71,  68)\n#define png_cHRM PNG_U32( 99,  72,  82,  77)\n#define png_fRAc PNG_U32(102,  82,  65,  99) /* registered, not defined */\n#define png_gAMA PNG_U32(103,  65,  77,  65)\n#define png_gIFg PNG_U32(103,  73,  70, 103)\n#define png_gIFt PNG_U32(103,  73,  70, 116) /* deprecated */\n#define png_gIFx PNG_U32(103,  73,  70, 120)\n#define png_hIST PNG_U32(104,  73,  83,  84)\n#define png_iCCP PNG_U32(105,  67,  67,  80)\n#define png_iTXt PNG_U32(105,  84,  88, 116)\n#define png_oFFs PNG_U32(111,  70,  70, 115)\n#define png_pCAL PNG_U32(112,  67,  65,  76)\n#define png_pHYs PNG_U32(112,  72,  89, 115)\n#define png_sBIT PNG_U32(115,  66,  73,  84)\n#define png_sCAL PNG_U32(115,  67,  65,  76)\n#define png_sPLT PNG_U32(115,  80,  76,  84)\n#define png_sRGB PNG_U32(115,  82,  71,  66)\n#define png_sTER PNG_U32(115,  84,  69,  82)\n#define png_tEXt PNG_U32(116,  69,  88, 116)\n#define png_tIME PNG_U32(116,  73,  77,  69)\n#define png_tRNS PNG_U32(116,  82,  78,  83)\n#define png_zTXt PNG_U32(122,  84,  88, 116)\n\n/* The following will work on (signed char*) strings, whereas the get_uint_32\n * macro will fail on top-bit-set values because of the sign extension.\n */\n#define PNG_CHUNK_FROM_STRING(s)\\\n   PNG_U32(0xff&(s)[0], 0xff&(s)[1], 0xff&(s)[2], 0xff&(s)[3])\n\n/* This uses (char), not (png_byte) to avoid warnings on systems where (char) is\n * signed and the argument is a (char[])  This macro will fail miserably on\n * systems where (char) is more than 8 bits.\n */\n#define PNG_STRING_FROM_CHUNK(s,c)\\\n   (void)(((char*)(s))[0]=(char)((c)>>24), ((char*)(s))[1]=(char)((c)>>16),\\\n   ((char*)(s))[2]=(char)((c)>>8), ((char*)(s))[3]=(char)((c)))\n\n/* Do the same but terminate with a null character. */\n#define PNG_CSTRING_FROM_CHUNK(s,c)\\\n   (void)(PNG_STRING_FROM_CHUNK(s,c), ((char*)(s))[4] = 0)\n\n/* Test on flag values as defined in the spec (section 5.4): */\n#define PNG_CHUNK_ANCILLARY(c)   (1 & ((c) >> 29))\n#define PNG_CHUNK_CRITICAL(c)     (!PNG_CHUNK_ANCILLARY(c))\n#define PNG_CHUNK_PRIVATE(c)      (1 & ((c) >> 21))\n#define PNG_CHUNK_RESERVED(c)     (1 & ((c) >> 13))\n#define PNG_CHUNK_SAFE_TO_COPY(c) (1 & ((c) >>  5))\n\n/* Gamma values (new at libpng-1.5.4): */\n#define PNG_GAMMA_MAC_OLD 151724  /* Assume '1.8' is really 2.2/1.45! */\n#define PNG_GAMMA_MAC_INVERSE 65909\n#define PNG_GAMMA_sRGB_INVERSE 45455\n\n/* Almost everything below is C specific; the #defines above can be used in\n * non-C code (so long as it is C-preprocessed) the rest of this stuff cannot.\n */\n#ifndef PNG_VERSION_INFO_ONLY\n\n#include \"pngstruct.h\"\n#include \"pnginfo.h\"\n\n/* Validate the include paths - the include path used to generate pnglibconf.h\n * must match that used in the build, or we must be using pnglibconf.h.prebuilt:\n */\n#if PNG_ZLIB_VERNUM != 0 && PNG_ZLIB_VERNUM != ZLIB_VERNUM\n#  error ZLIB_VERNUM != PNG_ZLIB_VERNUM \\\n      \"-I (include path) error: see the notes in pngpriv.h\"\n   /* This means that when pnglibconf.h was built the copy of zlib.h that it\n    * used is not the same as the one being used here.  Because the build of\n    * libpng makes decisions to use inflateInit2 and inflateReset2 based on the\n    * zlib version number and because this affects handling of certain broken\n    * PNG files the -I directives must match.\n    *\n    * The most likely explanation is that you passed a -I in CFLAGS, this will\n    * not work; all the preprocessor directories and in particular all the -I\n    * directives must be in CPPFLAGS.\n    */\n#endif\n\n/* This is used for 16 bit gamma tables -- only the top level pointers are\n * const; this could be changed:\n */\ntypedef const png_uint_16p * png_const_uint_16pp;\n\n/* Added to libpng-1.5.7: sRGB conversion tables */\n#if defined(PNG_SIMPLIFIED_READ_SUPPORTED) ||\\\n   defined(PNG_SIMPLIFIED_WRITE_SUPPORTED)\n#ifdef PNG_SIMPLIFIED_READ_SUPPORTED\nPNG_INTERNAL_DATA(const png_uint_16, png_sRGB_table, [256]);\n   /* Convert from an sRGB encoded value 0..255 to a 16-bit linear value,\n    * 0..65535.  This table gives the closest 16-bit answers (no errors).\n    */\n#endif\n\nPNG_INTERNAL_DATA(const png_uint_16, png_sRGB_base, [512]);\nPNG_INTERNAL_DATA(const png_byte, png_sRGB_delta, [512]);\n\n#define PNG_sRGB_FROM_LINEAR(linear) ((png_byte)((png_sRGB_base[(linear)>>15] +\\\n   ((((linear)&0x7fff)*png_sRGB_delta[(linear)>>15])>>12)) >> 8))\n   /* Given a value 'linear' in the range 0..255*65535 calculate the 8-bit sRGB\n    * encoded value with maximum error 0.646365.  Note that the input is not a\n    * 16-bit value; it has been multiplied by 255! */\n#endif /* PNG_SIMPLIFIED_READ/WRITE */\n\n\n/* Inhibit C++ name-mangling for libpng functions but not for system calls. */\n#ifdef __cplusplus\nextern \"C\" {\n#endif /* __cplusplus */\n\n/* Internal functions; these are not exported from a DLL however because they\n * are used within several of the C source files they have to be C extern.\n *\n * All of these functions must be declared with PNG_INTERNAL_FUNCTION.\n */\n\n/* Zlib support */\n#define PNG_UNEXPECTED_ZLIB_RETURN (-7)\nPNG_INTERNAL_FUNCTION(void, png_zstream_error,(png_structrp png_ptr, int ret),\n   PNG_EMPTY);\n   /* Used by the zlib handling functions to ensure that z_stream::msg is always\n    * set before they return.\n    */\n\n#ifdef PNG_WRITE_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_free_buffer_list,(png_structrp png_ptr,\n   png_compression_bufferp *list),PNG_EMPTY);\n   /* Free the buffer list used by the compressed write code. */\n#endif\n\n#if defined(PNG_FLOATING_POINT_SUPPORTED) && \\\n   !defined(PNG_FIXED_POINT_MACRO_SUPPORTED) && \\\n   (defined(PNG_gAMA_SUPPORTED) || defined(PNG_cHRM_SUPPORTED) || \\\n   defined(PNG_sCAL_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) || \\\n   defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)) || \\\n   (defined(PNG_sCAL_SUPPORTED) && \\\n   defined(PNG_FLOATING_ARITHMETIC_SUPPORTED))\nPNG_INTERNAL_FUNCTION(png_fixed_point,png_fixed,(png_const_structrp png_ptr,\n   double fp, png_const_charp text),PNG_EMPTY);\n#endif\n\n/* Check the user version string for compatibility, returns false if the version\n * numbers aren't compatible.\n */\nPNG_INTERNAL_FUNCTION(int,png_user_version_check,(png_structrp png_ptr,\n   png_const_charp user_png_ver),PNG_EMPTY);\n\n/* Internal base allocator - no messages, NULL on failure to allocate.  This\n * does, however, call the application provided allocator and that could call\n * png_error (although that would be a bug in the application implementation.)\n */\nPNG_INTERNAL_FUNCTION(png_voidp,png_malloc_base,(png_const_structrp png_ptr,\n   png_alloc_size_t size),PNG_ALLOCATED);\n\n#if defined(PNG_TEXT_SUPPORTED) || defined(PNG_sPLT_SUPPORTED) ||\\\n   defined(PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED)\n/* Internal array allocator, outputs no error or warning messages on failure,\n * just returns NULL.  \n */\nPNG_INTERNAL_FUNCTION(png_voidp,png_malloc_array,(png_const_structrp png_ptr,\n   int nelements, size_t element_size),PNG_ALLOCATED);\n\n/* The same but an existing array is extended by add_elements.  This function\n * also memsets the new elements to 0 and copies the old elements.  The old\n * array is not freed or altered.\n */\nPNG_INTERNAL_FUNCTION(png_voidp,png_realloc_array,(png_const_structrp png_ptr,\n   png_const_voidp array, int old_elements, int add_elements,\n   size_t element_size),PNG_ALLOCATED);\n#endif /* text, sPLT or unknown chunks */\n\n/* Magic to create a struct when there is no struct to call the user supplied\n * memory allocators.  Because error handling has not been set up the memory\n * handlers can't safely call png_error, but this is an obscure and undocumented\n * restriction so libpng has to assume that the 'free' handler, at least, might\n * call png_error.\n */\nPNG_INTERNAL_FUNCTION(png_structp,png_create_png_struct,\n   (png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn,\n    png_error_ptr warn_fn, png_voidp mem_ptr, png_malloc_ptr malloc_fn,\n    png_free_ptr free_fn),PNG_ALLOCATED);\n\n/* Free memory from internal libpng struct */\nPNG_INTERNAL_FUNCTION(void,png_destroy_png_struct,(png_structrp png_ptr),\n   PNG_EMPTY);\n\n/* Free an allocated jmp_buf (always succeeds) */\nPNG_INTERNAL_FUNCTION(void,png_free_jmpbuf,(png_structrp png_ptr),PNG_EMPTY);\n\n/* Function to allocate memory for zlib.  PNGAPI is disallowed. */\nPNG_INTERNAL_FUNCTION(voidpf,png_zalloc,(voidpf png_ptr, uInt items, uInt size),\n   PNG_ALLOCATED);\n\n/* Function to free memory for zlib.  PNGAPI is disallowed. */\nPNG_INTERNAL_FUNCTION(void,png_zfree,(voidpf png_ptr, voidpf ptr),PNG_EMPTY);\n\n/* Next four functions are used internally as callbacks.  PNGCBAPI is required\n * but not PNG_EXPORT.  PNGAPI added at libpng version 1.2.3, changed to\n * PNGCBAPI at 1.5.0\n */\n\nPNG_INTERNAL_FUNCTION(void PNGCBAPI,png_default_read_data,(png_structp png_ptr,\n    png_bytep data, png_size_t length),PNG_EMPTY);\n\n#ifdef PNG_PROGRESSIVE_READ_SUPPORTED\nPNG_INTERNAL_FUNCTION(void PNGCBAPI,png_push_fill_buffer,(png_structp png_ptr,\n    png_bytep buffer, png_size_t length),PNG_EMPTY);\n#endif\n\nPNG_INTERNAL_FUNCTION(void PNGCBAPI,png_default_write_data,(png_structp png_ptr,\n    png_bytep data, png_size_t length),PNG_EMPTY);\n\n#ifdef PNG_WRITE_FLUSH_SUPPORTED\n#  ifdef PNG_STDIO_SUPPORTED\nPNG_INTERNAL_FUNCTION(void PNGCBAPI,png_default_flush,(png_structp png_ptr),\n   PNG_EMPTY);\n#  endif\n#endif\n\n/* Reset the CRC variable */\nPNG_INTERNAL_FUNCTION(void,png_reset_crc,(png_structrp png_ptr),PNG_EMPTY);\n\n/* Write the \"data\" buffer to whatever output you are using */\nPNG_INTERNAL_FUNCTION(void,png_write_data,(png_structrp png_ptr,\n    png_const_bytep data, png_size_t length),PNG_EMPTY);\n\n/* Read and check the PNG file signature */\nPNG_INTERNAL_FUNCTION(void,png_read_sig,(png_structrp png_ptr,\n   png_inforp info_ptr),PNG_EMPTY);\n\n/* Read the chunk header (length + type name) */\nPNG_INTERNAL_FUNCTION(png_uint_32,png_read_chunk_header,(png_structrp png_ptr),\n   PNG_EMPTY);\n\n/* Read data from whatever input you are using into the \"data\" buffer */\nPNG_INTERNAL_FUNCTION(void,png_read_data,(png_structrp png_ptr, png_bytep data,\n    png_size_t length),PNG_EMPTY);\n\n/* Read bytes into buf, and update png_ptr->crc */\nPNG_INTERNAL_FUNCTION(void,png_crc_read,(png_structrp png_ptr, png_bytep buf,\n    png_uint_32 length),PNG_EMPTY);\n\n/* Read \"skip\" bytes, read the file crc, and (optionally) verify png_ptr->crc */\nPNG_INTERNAL_FUNCTION(int,png_crc_finish,(png_structrp png_ptr,\n   png_uint_32 skip),PNG_EMPTY);\n\n/* Read the CRC from the file and compare it to the libpng calculated CRC */\nPNG_INTERNAL_FUNCTION(int,png_crc_error,(png_structrp png_ptr),PNG_EMPTY);\n\n/* Calculate the CRC over a section of data.  Note that we are only\n * passing a maximum of 64K on systems that have this as a memory limit,\n * since this is the maximum buffer size we can specify.\n */\nPNG_INTERNAL_FUNCTION(void,png_calculate_crc,(png_structrp png_ptr,\n   png_const_bytep ptr, png_size_t length),PNG_EMPTY);\n\n#ifdef PNG_WRITE_FLUSH_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_flush,(png_structrp png_ptr),PNG_EMPTY);\n#endif\n\n/* Write various chunks */\n\n/* Write the IHDR chunk, and update the png_struct with the necessary\n * information.\n */\nPNG_INTERNAL_FUNCTION(void,png_write_IHDR,(png_structrp png_ptr,\n   png_uint_32 width, png_uint_32 height, int bit_depth, int color_type,\n   int compression_method, int filter_method, int interlace_method),PNG_EMPTY);\n\nPNG_INTERNAL_FUNCTION(void,png_write_PLTE,(png_structrp png_ptr,\n   png_const_colorp palette, png_uint_32 num_pal),PNG_EMPTY);\n\nPNG_INTERNAL_FUNCTION(void,png_compress_IDAT,(png_structrp png_ptr,\n   png_const_bytep row_data, png_alloc_size_t row_data_length, int flush),\n   PNG_EMPTY);\n\nPNG_INTERNAL_FUNCTION(void,png_write_IEND,(png_structrp png_ptr),PNG_EMPTY);\n\n#ifdef PNG_WRITE_gAMA_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_write_gAMA_fixed,(png_structrp png_ptr,\n    png_fixed_point file_gamma),PNG_EMPTY);\n#endif\n\n#ifdef PNG_WRITE_sBIT_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_write_sBIT,(png_structrp png_ptr,\n    png_const_color_8p sbit, int color_type),PNG_EMPTY);\n#endif\n\n#ifdef PNG_WRITE_cHRM_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_write_cHRM_fixed,(png_structrp png_ptr,\n    const png_xy *xy), PNG_EMPTY);\n    /* The xy value must have been previously validated */\n#endif\n\n#ifdef PNG_WRITE_sRGB_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_write_sRGB,(png_structrp png_ptr,\n    int intent),PNG_EMPTY);\n#endif\n\n#ifdef PNG_WRITE_iCCP_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_write_iCCP,(png_structrp png_ptr,\n   png_const_charp name, png_const_bytep profile), PNG_EMPTY);\n   /* The profile must have been previously validated for correctness, the\n    * length comes from the first four bytes.  Only the base, deflate,\n    * compression is supported.\n    */\n#endif\n\n#ifdef PNG_WRITE_sPLT_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_write_sPLT,(png_structrp png_ptr,\n    png_const_sPLT_tp palette),PNG_EMPTY);\n#endif\n\n#ifdef PNG_WRITE_tRNS_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_write_tRNS,(png_structrp png_ptr,\n    png_const_bytep trans, png_const_color_16p values, int number,\n    int color_type),PNG_EMPTY);\n#endif\n\n#ifdef PNG_WRITE_bKGD_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_write_bKGD,(png_structrp png_ptr,\n    png_const_color_16p values, int color_type),PNG_EMPTY);\n#endif\n\n#ifdef PNG_WRITE_hIST_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_write_hIST,(png_structrp png_ptr,\n    png_const_uint_16p hist, int num_hist),PNG_EMPTY);\n#endif\n\n/* Chunks that have keywords */\n#ifdef PNG_WRITE_tEXt_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_write_tEXt,(png_structrp png_ptr,\n   png_const_charp key, png_const_charp text, png_size_t text_len),PNG_EMPTY);\n#endif\n\n#ifdef PNG_WRITE_zTXt_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_write_zTXt,(png_structrp png_ptr, png_const_charp\n    key, png_const_charp text, png_size_t text_len, int compression),PNG_EMPTY);\n#endif\n\n#ifdef PNG_WRITE_iTXt_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_write_iTXt,(png_structrp png_ptr,\n    int compression, png_const_charp key, png_const_charp lang,\n    png_const_charp lang_key, png_const_charp text),PNG_EMPTY);\n#endif\n\n#ifdef PNG_TEXT_SUPPORTED  /* Added at version 1.0.14 and 1.2.4 */\nPNG_INTERNAL_FUNCTION(int,png_set_text_2,(png_const_structrp png_ptr,\n    png_inforp info_ptr, png_const_textp text_ptr, int num_text),PNG_EMPTY);\n#endif\n\n#ifdef PNG_WRITE_oFFs_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_write_oFFs,(png_structrp png_ptr,\n    png_int_32 x_offset, png_int_32 y_offset, int unit_type),PNG_EMPTY);\n#endif\n\n#ifdef PNG_WRITE_pCAL_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_write_pCAL,(png_structrp png_ptr,\n    png_charp purpose, png_int_32 X0, png_int_32 X1, int type, int nparams,\n    png_const_charp units, png_charpp params),PNG_EMPTY);\n#endif\n\n#ifdef PNG_WRITE_pHYs_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_write_pHYs,(png_structrp png_ptr,\n    png_uint_32 x_pixels_per_unit, png_uint_32 y_pixels_per_unit,\n    int unit_type),PNG_EMPTY);\n#endif\n\n#ifdef PNG_WRITE_tIME_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_write_tIME,(png_structrp png_ptr,\n    png_const_timep mod_time),PNG_EMPTY);\n#endif\n\n#ifdef PNG_WRITE_sCAL_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_write_sCAL_s,(png_structrp png_ptr,\n    int unit, png_const_charp width, png_const_charp height),PNG_EMPTY);\n#endif\n\n/* Called when finished processing a row of data */\nPNG_INTERNAL_FUNCTION(void,png_write_finish_row,(png_structrp png_ptr),\n    PNG_EMPTY);\n\n/* Internal use only.   Called before first row of data */\nPNG_INTERNAL_FUNCTION(void,png_write_start_row,(png_structrp png_ptr),\n    PNG_EMPTY);\n\n/* Combine a row of data, dealing with alpha, etc. if requested.  'row' is an\n * array of png_ptr->width pixels.  If the image is not interlaced or this\n * is the final pass this just does a memcpy, otherwise the \"display\" flag\n * is used to determine whether to copy pixels that are not in the current pass.\n *\n * Because 'png_do_read_interlace' (below) replicates pixels this allows this\n * function to achieve the documented 'blocky' appearance during interlaced read\n * if display is 1 and the 'sparkle' appearance, where existing pixels in 'row'\n * are not changed if they are not in the current pass, when display is 0.\n *\n * 'display' must be 0 or 1, otherwise the memcpy will be done regardless.\n *\n * The API always reads from the png_struct row buffer and always assumes that\n * it is full width (png_do_read_interlace has already been called.)\n *\n * This function is only ever used to write to row buffers provided by the\n * caller of the relevant libpng API and the row must have already been\n * transformed by the read transformations.\n *\n * The PNG_USE_COMPILE_TIME_MASKS option causes generation of pre-computed\n * bitmasks for use within the code, otherwise runtime generated masks are used.\n * The default is compile time masks.\n */\n#ifndef PNG_USE_COMPILE_TIME_MASKS\n#  define PNG_USE_COMPILE_TIME_MASKS 1\n#endif\nPNG_INTERNAL_FUNCTION(void,png_combine_row,(png_const_structrp png_ptr,\n    png_bytep row, int display),PNG_EMPTY);\n\n#ifdef PNG_READ_INTERLACING_SUPPORTED\n/* Expand an interlaced row: the 'row_info' describes the pass data that has\n * been read in and must correspond to the pixels in 'row', the pixels are\n * expanded (moved apart) in 'row' to match the final layout, when doing this\n * the pixels are *replicated* to the intervening space.  This is essential for\n * the correct operation of png_combine_row, above.\n */\nPNG_INTERNAL_FUNCTION(void,png_do_read_interlace,(png_row_infop row_info,\n    png_bytep row, int pass, png_uint_32 transformations),PNG_EMPTY);\n#endif\n\n/* GRR TO DO (2.0 or whenever):  simplify other internal calling interfaces */\n\n#ifdef PNG_WRITE_INTERLACING_SUPPORTED\n/* Grab pixels out of a row for an interlaced pass */\nPNG_INTERNAL_FUNCTION(void,png_do_write_interlace,(png_row_infop row_info,\n    png_bytep row, int pass),PNG_EMPTY);\n#endif\n\n/* Unfilter a row: check the filter value before calling this, there is no point\n * calling it for PNG_FILTER_VALUE_NONE.\n */\nPNG_INTERNAL_FUNCTION(void,png_read_filter_row,(png_structrp pp, png_row_infop\n    row_info, png_bytep row, png_const_bytep prev_row, int filter),PNG_EMPTY);\n\nPNG_INTERNAL_FUNCTION(void,png_read_filter_row_up_neon,(png_row_infop row_info,\n    png_bytep row, png_const_bytep prev_row),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub3_neon,(png_row_infop\n    row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub4_neon,(png_row_infop\n    row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_read_filter_row_avg3_neon,(png_row_infop\n    row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_read_filter_row_avg4_neon,(png_row_infop\n    row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth3_neon,(png_row_infop\n    row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth4_neon,(png_row_infop\n    row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);\n\n/* Choose the best filter to use and filter the row data */\nPNG_INTERNAL_FUNCTION(void,png_write_find_filter,(png_structrp png_ptr,\n    png_row_infop row_info),PNG_EMPTY);\n\n#ifdef PNG_SEQUENTIAL_READ_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_read_IDAT_data,(png_structrp png_ptr,\n   png_bytep output, png_alloc_size_t avail_out),PNG_EMPTY);\n   /* Read 'avail_out' bytes of data from the IDAT stream.  If the output buffer\n    * is NULL the function checks, instead, for the end of the stream.  In this\n    * case a benign error will be issued if the stream end is not found or if\n    * extra data has to be consumed.\n    */\nPNG_INTERNAL_FUNCTION(void,png_read_finish_IDAT,(png_structrp png_ptr),\n   PNG_EMPTY);\n   /* This cleans up when the IDAT LZ stream does not end when the last image\n    * byte is read; there is still some pending input.\n    */\n\nPNG_INTERNAL_FUNCTION(void,png_read_finish_row,(png_structrp png_ptr),\n   PNG_EMPTY);\n   /* Finish a row while reading, dealing with interlacing passes, etc. */\n#endif /* PNG_SEQUENTIAL_READ_SUPPORTED */\n\n/* Initialize the row buffers, etc. */\nPNG_INTERNAL_FUNCTION(void,png_read_start_row,(png_structrp png_ptr),PNG_EMPTY);\n\n#ifdef PNG_READ_TRANSFORMS_SUPPORTED\n/* Optional call to update the users info structure */\nPNG_INTERNAL_FUNCTION(void,png_read_transform_info,(png_structrp png_ptr,\n    png_inforp info_ptr),PNG_EMPTY);\n#endif\n\n/* Shared transform functions, defined in pngtran.c */\n#if defined(PNG_WRITE_FILLER_SUPPORTED) || \\\n    defined(PNG_READ_STRIP_ALPHA_SUPPORTED)\nPNG_INTERNAL_FUNCTION(void,png_do_strip_channel,(png_row_infop row_info,\n    png_bytep row, int at_start),PNG_EMPTY);\n#endif\n\n#ifdef PNG_16BIT_SUPPORTED\n#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED)\nPNG_INTERNAL_FUNCTION(void,png_do_swap,(png_row_infop row_info,\n    png_bytep row),PNG_EMPTY);\n#endif\n#endif\n\n#if defined(PNG_READ_PACKSWAP_SUPPORTED) || \\\n    defined(PNG_WRITE_PACKSWAP_SUPPORTED)\nPNG_INTERNAL_FUNCTION(void,png_do_packswap,(png_row_infop row_info,\n    png_bytep row),PNG_EMPTY);\n#endif\n\n#if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED)\nPNG_INTERNAL_FUNCTION(void,png_do_invert,(png_row_infop row_info,\n    png_bytep row),PNG_EMPTY);\n#endif\n\n#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED)\nPNG_INTERNAL_FUNCTION(void,png_do_bgr,(png_row_infop row_info,\n    png_bytep row),PNG_EMPTY);\n#endif\n\n/* The following decodes the appropriate chunks, and does error correction,\n * then calls the appropriate callback for the chunk if it is valid.\n */\n\n/* Decode the IHDR chunk */\nPNG_INTERNAL_FUNCTION(void,png_handle_IHDR,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_handle_PLTE,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_handle_IEND,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\n\n#ifdef PNG_READ_bKGD_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_handle_bKGD,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\n#endif\n\n#ifdef PNG_READ_cHRM_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_handle_cHRM,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\n#endif\n\n#ifdef PNG_READ_gAMA_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_handle_gAMA,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\n#endif\n\n#ifdef PNG_READ_hIST_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_handle_hIST,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\n#endif\n\n#ifdef PNG_READ_iCCP_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_handle_iCCP,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\n#endif /* PNG_READ_iCCP_SUPPORTED */\n\n#ifdef PNG_READ_iTXt_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_handle_iTXt,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\n#endif\n\n#ifdef PNG_READ_oFFs_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_handle_oFFs,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\n#endif\n\n#ifdef PNG_READ_pCAL_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_handle_pCAL,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\n#endif\n\n#ifdef PNG_READ_pHYs_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_handle_pHYs,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\n#endif\n\n#ifdef PNG_READ_sBIT_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_handle_sBIT,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\n#endif\n\n#ifdef PNG_READ_sCAL_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_handle_sCAL,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\n#endif\n\n#ifdef PNG_READ_sPLT_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_handle_sPLT,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\n#endif /* PNG_READ_sPLT_SUPPORTED */\n\n#ifdef PNG_READ_sRGB_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_handle_sRGB,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\n#endif\n\n#ifdef PNG_READ_tEXt_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_handle_tEXt,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\n#endif\n\n#ifdef PNG_READ_tIME_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_handle_tIME,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\n#endif\n\n#ifdef PNG_READ_tRNS_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_handle_tRNS,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\n#endif\n\n#ifdef PNG_READ_zTXt_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_handle_zTXt,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\n#endif\n\nPNG_INTERNAL_FUNCTION(void,png_check_chunk_name,(png_structrp png_ptr,\n    png_uint_32 chunk_name),PNG_EMPTY);\n\nPNG_INTERNAL_FUNCTION(void,png_handle_unknown,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length, int keep),PNG_EMPTY);\n   /* This is the function that gets called for unknown chunks.  The 'keep'\n    * argument is either non-zero for a known chunk that has been set to be\n    * handled as unknown or zero for an unknown chunk.  By default the function\n    * just skips the chunk or errors out if it is critical.\n    */\n\n#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) ||\\\n    defined(PNG_HANDLE_AS_UNKNOWN_SUPPORTED)\nPNG_INTERNAL_FUNCTION(int,png_chunk_unknown_handling,\n    (png_const_structrp png_ptr, png_uint_32 chunk_name),PNG_EMPTY);\n   /* Exactly as the API png_handle_as_unknown() except that the argument is a\n    * 32-bit chunk name, not a string.\n    */\n#endif /* READ_UNKNOWN_CHUNKS || HANDLE_AS_UNKNOWN */\n\n/* Handle the transformations for reading and writing */\n#ifdef PNG_READ_TRANSFORMS_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_do_read_transformations,(png_structrp png_ptr,\n   png_row_infop row_info),PNG_EMPTY);\n#endif\n#ifdef PNG_WRITE_TRANSFORMS_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_do_write_transformations,(png_structrp png_ptr,\n   png_row_infop row_info),PNG_EMPTY);\n#endif\n\n#ifdef PNG_READ_TRANSFORMS_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_init_read_transformations,(png_structrp png_ptr),\n    PNG_EMPTY);\n#endif\n\n#ifdef PNG_PROGRESSIVE_READ_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_push_read_chunk,(png_structrp png_ptr,\n    png_inforp info_ptr),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_push_read_sig,(png_structrp png_ptr,\n    png_inforp info_ptr),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_push_check_crc,(png_structrp png_ptr),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_push_crc_skip,(png_structrp png_ptr,\n    png_uint_32 length),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_push_crc_finish,(png_structrp png_ptr),\n    PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_push_save_buffer,(png_structrp png_ptr),\n    PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_push_restore_buffer,(png_structrp png_ptr,\n    png_bytep buffer, png_size_t buffer_length),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_push_read_IDAT,(png_structrp png_ptr),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_process_IDAT_data,(png_structrp png_ptr,\n    png_bytep buffer, png_size_t buffer_length),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_push_process_row,(png_structrp png_ptr),\n    PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_push_handle_unknown,(png_structrp png_ptr,\n   png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_push_have_info,(png_structrp png_ptr,\n   png_inforp info_ptr),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_push_have_end,(png_structrp png_ptr,\n   png_inforp info_ptr),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_push_have_row,(png_structrp png_ptr,\n     png_bytep row),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_push_read_end,(png_structrp png_ptr,\n    png_inforp info_ptr),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_process_some_data,(png_structrp png_ptr,\n    png_inforp info_ptr),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_read_push_finish_row,(png_structrp png_ptr),\n    PNG_EMPTY);\n#  ifdef PNG_READ_tEXt_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_push_handle_tEXt,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_push_read_tEXt,(png_structrp png_ptr,\n    png_inforp info_ptr),PNG_EMPTY);\n#  endif\n#  ifdef PNG_READ_zTXt_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_push_handle_zTXt,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_push_read_zTXt,(png_structrp png_ptr,\n    png_inforp info_ptr),PNG_EMPTY);\n#  endif\n#  ifdef PNG_READ_iTXt_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_push_handle_iTXt,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_push_read_iTXt,(png_structrp png_ptr,\n    png_inforp info_ptr),PNG_EMPTY);\n#  endif\n\n#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */\n\n/* Added at libpng version 1.6.0 */\n#ifdef PNG_GAMMA_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_colorspace_set_gamma,(png_const_structrp png_ptr,\n    png_colorspacerp colorspace, png_fixed_point gAMA), PNG_EMPTY);\n   /* Set the colorspace gamma with a value provided by the application or by\n    * the gAMA chunk on read.  The value will override anything set by an ICC\n    * profile.\n    */\n\nPNG_INTERNAL_FUNCTION(void,png_colorspace_sync_info,(png_const_structrp png_ptr,\n    png_inforp info_ptr), PNG_EMPTY);\n    /* Synchronize the info 'valid' flags with the colorspace */\n\nPNG_INTERNAL_FUNCTION(void,png_colorspace_sync,(png_const_structrp png_ptr,\n    png_inforp info_ptr), PNG_EMPTY);\n    /* Copy the png_struct colorspace to the info_struct and call the above to\n     * synchronize the flags.  Checks for NULL info_ptr and does nothing.\n     */\n#endif\n\n/* Added at libpng version 1.4.0 */\n#ifdef PNG_COLORSPACE_SUPPORTED\n/* These internal functions are for maintaining the colorspace structure within\n * a png_info or png_struct (or, indeed, both).\n */\nPNG_INTERNAL_FUNCTION(int,png_colorspace_set_chromaticities,\n   (png_const_structrp png_ptr, png_colorspacerp colorspace, const png_xy *xy,\n    int preferred), PNG_EMPTY);\n\nPNG_INTERNAL_FUNCTION(int,png_colorspace_set_endpoints,\n   (png_const_structrp png_ptr, png_colorspacerp colorspace, const png_XYZ *XYZ,\n    int preferred), PNG_EMPTY);\n\n#ifdef PNG_sRGB_SUPPORTED\nPNG_INTERNAL_FUNCTION(int,png_colorspace_set_sRGB,(png_const_structrp png_ptr,\n   png_colorspacerp colorspace, int intent), PNG_EMPTY);\n   /* This does set the colorspace gAMA and cHRM values too, but doesn't set the\n    * flags to write them, if it returns false there was a problem and an error\n    * message has already been output (but the colorspace may still need to be\n    * synced to record the invalid flag).\n    */\n#endif /* sRGB */\n\n#ifdef PNG_iCCP_SUPPORTED\nPNG_INTERNAL_FUNCTION(int,png_colorspace_set_ICC,(png_const_structrp png_ptr,\n   png_colorspacerp colorspace, png_const_charp name,\n   png_uint_32 profile_length, png_const_bytep profile, int color_type),\n   PNG_EMPTY);\n   /* The 'name' is used for information only */\n\n/* Routines for checking parts of an ICC profile. */\nPNG_INTERNAL_FUNCTION(int,png_icc_check_length,(png_const_structrp png_ptr,\n   png_colorspacerp colorspace, png_const_charp name,\n   png_uint_32 profile_length), PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(int,png_icc_check_header,(png_const_structrp png_ptr,\n   png_colorspacerp colorspace, png_const_charp name,\n   png_uint_32 profile_length,\n   png_const_bytep profile /* first 132 bytes only */, int color_type),\n   PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(int,png_icc_check_tag_table,(png_const_structrp png_ptr,\n   png_colorspacerp colorspace, png_const_charp name,\n   png_uint_32 profile_length,\n   png_const_bytep profile /* header plus whole tag table */), PNG_EMPTY);\n#ifdef PNG_sRGB_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_icc_set_sRGB,(\n   png_const_structrp png_ptr, png_colorspacerp colorspace,\n   png_const_bytep profile, uLong adler), PNG_EMPTY);\n   /* 'adler' is the Adler32 checksum of the uncompressed profile data. It may\n    * be zero to indicate that it is not available.  It is used, if provided,\n    * as a fast check on the profile when checking to see if it is sRGB.\n    */\n#endif\n#endif /* iCCP */\n\n#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_colorspace_set_rgb_coefficients,\n   (png_structrp png_ptr), PNG_EMPTY);\n   /* Set the rgb_to_gray coefficients from the colorspace Y values */\n#endif /* READ_RGB_TO_GRAY */\n#endif /* COLORSPACE */\n\n/* Added at libpng version 1.4.0 */\nPNG_INTERNAL_FUNCTION(void,png_check_IHDR,(png_const_structrp png_ptr,\n    png_uint_32 width, png_uint_32 height, int bit_depth,\n    int color_type, int interlace_type, int compression_type,\n    int filter_type),PNG_EMPTY);\n\n/* Added at libpng version 1.5.10 */\n#if defined(PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED) || \\\n    defined(PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED)\nPNG_INTERNAL_FUNCTION(void,png_do_check_palette_indexes,\n   (png_structrp png_ptr, png_row_infop row_info),PNG_EMPTY);\n#endif\n\n#if defined(PNG_FLOATING_POINT_SUPPORTED) && defined(PNG_ERROR_TEXT_SUPPORTED)\nPNG_INTERNAL_FUNCTION(void,png_fixed_error,(png_const_structrp png_ptr,\n   png_const_charp name),PNG_NORETURN);\n#endif\n\n/* Puts 'string' into 'buffer' at buffer[pos], taking care never to overwrite\n * the end.  Always leaves the buffer nul terminated.  Never errors out (and\n * there is no error code.)\n */\nPNG_INTERNAL_FUNCTION(size_t,png_safecat,(png_charp buffer, size_t bufsize,\n   size_t pos, png_const_charp string),PNG_EMPTY);\n\n/* Various internal functions to handle formatted warning messages, currently\n * only implemented for warnings.\n */\n#if defined(PNG_WARNINGS_SUPPORTED) || defined(PNG_TIME_RFC1123_SUPPORTED)\n/* Utility to dump an unsigned value into a buffer, given a start pointer and\n * and end pointer (which should point just *beyond* the end of the buffer!)\n * Returns the pointer to the start of the formatted string.  This utility only\n * does unsigned values.\n */\nPNG_INTERNAL_FUNCTION(png_charp,png_format_number,(png_const_charp start,\n   png_charp end, int format, png_alloc_size_t number),PNG_EMPTY);\n\n/* Convenience macro that takes an array: */\n#define PNG_FORMAT_NUMBER(buffer,format,number) \\\n   png_format_number(buffer, buffer + (sizeof buffer), format, number)\n\n/* Suggested size for a number buffer (enough for 64 bits and a sign!) */\n#define PNG_NUMBER_BUFFER_SIZE 24\n\n/* These are the integer formats currently supported, the name is formed from\n * the standard printf(3) format string.\n */\n#define PNG_NUMBER_FORMAT_u     1 /* chose unsigned API! */\n#define PNG_NUMBER_FORMAT_02u   2\n#define PNG_NUMBER_FORMAT_d     1 /* chose signed API! */\n#define PNG_NUMBER_FORMAT_02d   2\n#define PNG_NUMBER_FORMAT_x     3\n#define PNG_NUMBER_FORMAT_02x   4\n#define PNG_NUMBER_FORMAT_fixed 5 /* choose the signed API */\n#endif\n\n#ifdef PNG_WARNINGS_SUPPORTED\n/* New defines and members adding in libpng-1.5.4 */\n#  define PNG_WARNING_PARAMETER_SIZE 32\n#  define PNG_WARNING_PARAMETER_COUNT 8 /* Maximum 9; see pngerror.c */\n\n/* An l-value of this type has to be passed to the APIs below to cache the\n * values of the parameters to a formatted warning message.\n */\ntypedef char png_warning_parameters[PNG_WARNING_PARAMETER_COUNT][\n   PNG_WARNING_PARAMETER_SIZE];\n\nPNG_INTERNAL_FUNCTION(void,png_warning_parameter,(png_warning_parameters p,\n   int number, png_const_charp string),PNG_EMPTY);\n   /* Parameters are limited in size to PNG_WARNING_PARAMETER_SIZE characters,\n    * including the trailing '\\0'.\n    */\nPNG_INTERNAL_FUNCTION(void,png_warning_parameter_unsigned,\n   (png_warning_parameters p, int number, int format, png_alloc_size_t value),\n   PNG_EMPTY);\n   /* Use png_alloc_size_t because it is an unsigned type as big as any we\n    * need to output.  Use the following for a signed value.\n    */\nPNG_INTERNAL_FUNCTION(void,png_warning_parameter_signed,\n   (png_warning_parameters p, int number, int format, png_int_32 value),\n   PNG_EMPTY);\n\nPNG_INTERNAL_FUNCTION(void,png_formatted_warning,(png_const_structrp png_ptr,\n   png_warning_parameters p, png_const_charp message),PNG_EMPTY);\n   /* 'message' follows the X/Open approach of using @1, @2 to insert\n    * parameters previously supplied using the above functions.  Errors in\n    * specifying the parameters will simply result in garbage substitutions.\n    */\n#endif\n\n#ifdef PNG_BENIGN_ERRORS_SUPPORTED\n/* Application errors (new in 1.6); use these functions (declared below) for\n * errors in the parameters or order of API function calls on read.  The\n * 'warning' should be used for an error that can be handled completely; the\n * 'error' for one which can be handled safely but which may lose application\n * information or settings.\n *\n * By default these both result in a png_error call prior to release, while in a\n * released version the 'warning' is just a warning.  However if the application\n * explicitly disables benign errors (explicitly permitting the code to lose\n * information) they both turn into warnings.\n *\n * If benign errors aren't supported they end up as the corresponding base call\n * (png_warning or png_error.)\n */\nPNG_INTERNAL_FUNCTION(void,png_app_warning,(png_const_structrp png_ptr,\n   png_const_charp message),PNG_EMPTY);\n   /* The application provided invalid parameters to an API function or called\n    * an API function at the wrong time, libpng can completely recover.\n    */\n\nPNG_INTERNAL_FUNCTION(void,png_app_error,(png_const_structrp png_ptr,\n   png_const_charp message),PNG_EMPTY);\n   /* As above but libpng will ignore the call, or attempt some other partial\n    * recovery from the error.\n    */\n#else\n#  define png_app_warning(pp,s) png_warning(pp,s)\n#  define png_app_error(pp,s) png_error(pp,s)\n#endif\n\nPNG_INTERNAL_FUNCTION(void,png_chunk_report,(png_const_structrp png_ptr,\n   png_const_charp message, int error),PNG_EMPTY);\n   /* Report a recoverable issue in chunk data.  On read this is used to report\n    * a problem found while reading a particular chunk and the\n    * png_chunk_benign_error or png_chunk_warning function is used as\n    * appropriate.  On write this is used to report an error that comes from\n    * data set via an application call to a png_set_ API and png_app_error or\n    * png_app_warning is used as appropriate.\n    *\n    * The 'error' parameter must have one of the following values:\n    */\n#define PNG_CHUNK_WARNING     0 /* never an error */\n#define PNG_CHUNK_WRITE_ERROR 1 /* an error only on write */\n#define PNG_CHUNK_ERROR       2 /* always an error */\n\n/* ASCII to FP interfaces, currently only implemented if sCAL\n * support is required.\n */\n#if defined(PNG_sCAL_SUPPORTED)\n/* MAX_DIGITS is actually the maximum number of characters in an sCAL\n * width or height, derived from the precision (number of significant\n * digits - a build time settable option) and assumptions about the\n * maximum ridiculous exponent.\n */\n#define PNG_sCAL_MAX_DIGITS (PNG_sCAL_PRECISION+1/*.*/+1/*E*/+10/*exponent*/)\n\n#ifdef PNG_FLOATING_POINT_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_ascii_from_fp,(png_const_structrp png_ptr,\n   png_charp ascii, png_size_t size, double fp, unsigned int precision),\n   PNG_EMPTY);\n#endif /* FLOATING_POINT */\n\n#ifdef PNG_FIXED_POINT_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_ascii_from_fixed,(png_const_structrp png_ptr,\n   png_charp ascii, png_size_t size, png_fixed_point fp),PNG_EMPTY);\n#endif /* FIXED_POINT */\n#endif /* sCAL */\n\n#if defined(PNG_sCAL_SUPPORTED) || defined(PNG_pCAL_SUPPORTED)\n/* An internal API to validate the format of a floating point number.\n * The result is the index of the next character.  If the number is\n * not valid it will be the index of a character in the supposed number.\n *\n * The format of a number is defined in the PNG extensions specification\n * and this API is strictly conformant to that spec, not anyone elses!\n *\n * The format as a regular expression is:\n *\n * [+-]?[0-9]+.?([Ee][+-]?[0-9]+)?\n *\n * or:\n *\n * [+-]?.[0-9]+(.[0-9]+)?([Ee][+-]?[0-9]+)?\n *\n * The complexity is that either integer or fraction must be present and the\n * fraction is permitted to have no digits only if the integer is present.\n *\n * NOTE: The dangling E problem.\n *   There is a PNG valid floating point number in the following:\n *\n *       PNG floating point numbers are not greedy.\n *\n *   Working this out requires *TWO* character lookahead (because of the\n *   sign), the parser does not do this - it will fail at the 'r' - this\n *   doesn't matter for PNG sCAL chunk values, but it requires more care\n *   if the value were ever to be embedded in something more complex.  Use\n *   ANSI-C strtod if you need the lookahead.\n */\n/* State table for the parser. */\n#define PNG_FP_INTEGER    0  /* before or in integer */\n#define PNG_FP_FRACTION   1  /* before or in fraction */\n#define PNG_FP_EXPONENT   2  /* before or in exponent */\n#define PNG_FP_STATE      3  /* mask for the above */\n#define PNG_FP_SAW_SIGN   4  /* Saw +/- in current state */\n#define PNG_FP_SAW_DIGIT  8  /* Saw a digit in current state */\n#define PNG_FP_SAW_DOT   16  /* Saw a dot in current state */\n#define PNG_FP_SAW_E     32  /* Saw an E (or e) in current state */\n#define PNG_FP_SAW_ANY   60  /* Saw any of the above 4 */\n\n/* These three values don't affect the parser.  They are set but not used.\n */\n#define PNG_FP_WAS_VALID 64  /* Preceding substring is a valid fp number */\n#define PNG_FP_NEGATIVE 128  /* A negative number, including \"-0\" */\n#define PNG_FP_NONZERO  256  /* A non-zero value */\n#define PNG_FP_STICKY   448  /* The above three flags */\n\n/* This is available for the caller to store in 'state' if required.  Do not\n * call the parser after setting it (the parser sometimes clears it.)\n */\n#define PNG_FP_INVALID  512  /* Available for callers as a distinct value */\n\n/* Result codes for the parser (boolean - true meants ok, false means\n * not ok yet.)\n */\n#define PNG_FP_MAYBE      0  /* The number may be valid in the future */\n#define PNG_FP_OK         1  /* The number is valid */\n\n/* Tests on the sticky non-zero and negative flags.  To pass these checks\n * the state must also indicate that the whole number is valid - this is\n * achieved by testing PNG_FP_SAW_DIGIT (see the implementation for why this\n * is equivalent to PNG_FP_OK above.)\n */\n#define PNG_FP_NZ_MASK (PNG_FP_SAW_DIGIT | PNG_FP_NEGATIVE | PNG_FP_NONZERO)\n   /* NZ_MASK: the string is valid and a non-zero negative value */\n#define PNG_FP_Z_MASK (PNG_FP_SAW_DIGIT | PNG_FP_NONZERO)\n   /* Z MASK: the string is valid and a non-zero value. */\n   /* PNG_FP_SAW_DIGIT: the string is valid. */\n#define PNG_FP_IS_ZERO(state) (((state) & PNG_FP_Z_MASK) == PNG_FP_SAW_DIGIT)\n#define PNG_FP_IS_POSITIVE(state) (((state) & PNG_FP_NZ_MASK) == PNG_FP_Z_MASK)\n#define PNG_FP_IS_NEGATIVE(state) (((state) & PNG_FP_NZ_MASK) == PNG_FP_NZ_MASK)\n\n/* The actual parser.  This can be called repeatedly. It updates\n * the index into the string and the state variable (which must\n * be initialized to 0).  It returns a result code, as above.  There\n * is no point calling the parser any more if it fails to advance to\n * the end of the string - it is stuck on an invalid character (or\n * terminated by '\\0').\n *\n * Note that the pointer will consume an E or even an E+ and then leave\n * a 'maybe' state even though a preceding integer.fraction is valid.\n * The PNG_FP_WAS_VALID flag indicates that a preceding substring was\n * a valid number.  It's possible to recover from this by calling\n * the parser again (from the start, with state 0) but with a string\n * that omits the last character (i.e. set the size to the index of\n * the problem character.)  This has not been tested within libpng.\n */\nPNG_INTERNAL_FUNCTION(int,png_check_fp_number,(png_const_charp string,\n   png_size_t size, int *statep, png_size_tp whereami),PNG_EMPTY);\n\n/* This is the same but it checks a complete string and returns true\n * only if it just contains a floating point number.  As of 1.5.4 this\n * function also returns the state at the end of parsing the number if\n * it was valid (otherwise it returns 0.)  This can be used for testing\n * for negative or zero values using the sticky flag.\n */\nPNG_INTERNAL_FUNCTION(int,png_check_fp_string,(png_const_charp string,\n   png_size_t size),PNG_EMPTY);\n#endif /* pCAL || sCAL */\n\n#if defined(PNG_GAMMA_SUPPORTED) ||\\\n    defined(PNG_INCH_CONVERSIONS_SUPPORTED) || defined(PNG_READ_pHYs_SUPPORTED)\n/* Added at libpng version 1.5.0 */\n/* This is a utility to provide a*times/div (rounded) and indicate\n * if there is an overflow.  The result is a boolean - false (0)\n * for overflow, true (1) if no overflow, in which case *res\n * holds the result.\n */\nPNG_INTERNAL_FUNCTION(int,png_muldiv,(png_fixed_point_p res, png_fixed_point a,\n   png_int_32 multiplied_by, png_int_32 divided_by),PNG_EMPTY);\n#endif\n\n#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_INCH_CONVERSIONS_SUPPORTED)\n/* Same deal, but issue a warning on overflow and return 0. */\nPNG_INTERNAL_FUNCTION(png_fixed_point,png_muldiv_warn,\n   (png_const_structrp png_ptr, png_fixed_point a, png_int_32 multiplied_by,\n   png_int_32 divided_by),PNG_EMPTY);\n#endif\n\n#ifdef PNG_GAMMA_SUPPORTED\n/* Calculate a reciprocal - used for gamma values.  This returns\n * 0 if the argument is 0 in order to maintain an undefined value;\n * there are no warnings.\n */\nPNG_INTERNAL_FUNCTION(png_fixed_point,png_reciprocal,(png_fixed_point a),\n   PNG_EMPTY);\n\n#ifdef PNG_READ_GAMMA_SUPPORTED\n/* The same but gives a reciprocal of the product of two fixed point\n * values.  Accuracy is suitable for gamma calculations but this is\n * not exact - use png_muldiv for that.  Only required at present on read.\n */\nPNG_INTERNAL_FUNCTION(png_fixed_point,png_reciprocal2,(png_fixed_point a,\n   png_fixed_point b),PNG_EMPTY);\n#endif\n\n/* Return true if the gamma value is significantly different from 1.0 */\nPNG_INTERNAL_FUNCTION(int,png_gamma_significant,(png_fixed_point gamma_value),\n   PNG_EMPTY);\n#endif\n\n#ifdef PNG_READ_GAMMA_SUPPORTED\n/* Internal fixed point gamma correction.  These APIs are called as\n * required to convert single values - they don't need to be fast,\n * they are not used when processing image pixel values.\n *\n * While the input is an 'unsigned' value it must actually be the\n * correct bit value - 0..255 or 0..65535 as required.\n */\nPNG_INTERNAL_FUNCTION(png_uint_16,png_gamma_correct,(png_structrp png_ptr,\n   unsigned int value, png_fixed_point gamma_value),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(png_uint_16,png_gamma_16bit_correct,(unsigned int value,\n   png_fixed_point gamma_value),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(png_byte,png_gamma_8bit_correct,(unsigned int value,\n   png_fixed_point gamma_value),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_destroy_gamma_table,(png_structrp png_ptr),\n   PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_build_gamma_table,(png_structrp png_ptr,\n   int bit_depth),PNG_EMPTY);\n#endif\n\n/* SIMPLIFIED READ/WRITE SUPPORT */\n#if defined(PNG_SIMPLIFIED_READ_SUPPORTED) ||\\\n   defined(PNG_SIMPLIFIED_WRITE_SUPPORTED)\n/* The internal structure that png_image::opaque points to. */\ntypedef struct png_control\n{\n   png_structp png_ptr;\n   png_infop   info_ptr;\n   png_voidp   error_buf;           /* Always a jmp_buf at present. */\n\n   png_const_bytep memory;          /* Memory buffer. */\n   png_size_t      size;            /* Size of the memory buffer. */\n\n   unsigned int for_write       :1; /* Otherwise it is a read structure */\n   unsigned int owned_file      :1; /* We own the file in io_ptr */\n} png_control;\n\n/* Return the pointer to the jmp_buf from a png_control: necessary because C\n * does not reveal the type of the elements of jmp_buf.\n */\n#ifdef __cplusplus\n#  define png_control_jmp_buf(pc) (((jmp_buf*)((pc)->error_buf))[0])\n#else\n#  define png_control_jmp_buf(pc) ((pc)->error_buf)\n#endif\n\n/* Utility to safely execute a piece of libpng code catching and logging any\n * errors that might occur.  Returns true on success, false on failure (either\n * of the function or as a result of a png_error.)\n */\nPNG_INTERNAL_CALLBACK(void,png_safe_error,(png_structp png_ptr,\n   png_const_charp error_message),PNG_NORETURN);\n\n#ifdef PNG_WARNINGS_SUPPORTED\nPNG_INTERNAL_CALLBACK(void,png_safe_warning,(png_structp png_ptr,\n   png_const_charp warning_message),PNG_EMPTY);\n#else\n#  define png_safe_warning 0/*dummy argument*/\n#endif\n\nPNG_INTERNAL_FUNCTION(int,png_safe_execute,(png_imagep image,\n   int (*function)(png_voidp), png_voidp arg),PNG_EMPTY);\n\n/* Utility to log an error; this also cleans up the png_image; the function\n * always returns 0 (false).\n */\nPNG_INTERNAL_FUNCTION(int,png_image_error,(png_imagep image,\n   png_const_charp error_message),PNG_EMPTY);\n\n#ifndef PNG_SIMPLIFIED_READ_SUPPORTED\n/* png_image_free is used by the write code but not exported */\nPNG_INTERNAL_FUNCTION(void, png_image_free, (png_imagep image), PNG_EMPTY);\n#endif /* !SIMPLIFIED_READ */\n\n#endif /* SIMPLIFIED READ/WRITE */\n\n/* These are initialization functions for hardware specific PNG filter\n * optimizations; list these here then select the appropriate one at compile\n * time using the macro PNG_FILTER_OPTIMIZATIONS.  If the macro is not defined\n * the generic code is used.\n */\n#ifdef PNG_FILTER_OPTIMIZATIONS\nPNG_INTERNAL_FUNCTION(void, PNG_FILTER_OPTIMIZATIONS, (png_structp png_ptr,\n   unsigned int bpp), PNG_EMPTY);\n   /* Just declare the optimization that will be used */\n#else\n   /* List *all* the possible optimizations here - this branch is required if\n    * the builder of libpng passes the definition of PNG_FILTER_OPTIMIZATIONS in\n    * CFLAGS in place of CPPFLAGS *and* uses symbol prefixing.\n    */\nPNG_INTERNAL_FUNCTION(void, png_init_filter_functions_neon,\n   (png_structp png_ptr, unsigned int bpp), PNG_EMPTY);\n#endif\n\n/* Maintainer: Put new private prototypes here ^ */\n\n#include \"pngdebug.h\"\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* PNG_VERSION_INFO_ONLY */\n#endif /* PNGPRIV_H */\n"
  },
  {
    "path": "Libraries/Core/iOS/Headers/png/pngstruct.h",
    "content": "\n/* pngstruct.h - header file for PNG reference library\n *\n * Copyright (c) 1998-2013 Glenn Randers-Pehrson\n * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)\n * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)\n *\n * Last changed in libpng 1.6.1 [March 28, 2013]\n *\n * This code is released under the libpng license.\n * For conditions of distribution and use, see the disclaimer\n * and license in png.h\n */\n\n/* The structure that holds the information to read and write PNG files.\n * The only people who need to care about what is inside of this are the\n * people who will be modifying the library for their own special needs.\n * It should NOT be accessed directly by an application.\n */\n\n#ifndef PNGSTRUCT_H\n#define PNGSTRUCT_H\n/* zlib.h defines the structure z_stream, an instance of which is included\n * in this structure and is required for decompressing the LZ compressed\n * data in PNG files.\n */\n#ifndef ZLIB_CONST\n   /* We must ensure that zlib uses 'const' in declarations. */\n#  define ZLIB_CONST\n#endif\n#include \"zlib.h\"\n#ifdef const\n   /* zlib.h sometimes #defines const to nothing, undo this. */\n#  undef const\n#endif\n\n/* zlib.h has mediocre z_const use before 1.2.6, this stuff is for compatibility\n * with older builds.\n */\n#if ZLIB_VERNUM < 0x1260\n#  define PNGZ_MSG_CAST(s) png_constcast(char*,s)\n#  define PNGZ_INPUT_CAST(b) png_constcast(png_bytep,b)\n#else\n#  define PNGZ_MSG_CAST(s) (s)\n#  define PNGZ_INPUT_CAST(b) (b)\n#endif\n\n/* zlib.h declares a magic type 'uInt' that limits the amount of data that zlib\n * can handle at once.  This type need be no larger than 16 bits (so maximum of\n * 65535), this define allows us to discover how big it is, but limited by the\n * maximuum for png_size_t.  The value can be overriden in a library build\n * (pngusr.h, or set it in CPPFLAGS) and it works to set it to a considerably\n * lower value (e.g. 255 works).  A lower value may help memory usage (slightly)\n * and may even improve performance on some systems (and degrade it on others.)\n */\n#ifndef ZLIB_IO_MAX\n#  define ZLIB_IO_MAX ((uInt)-1)\n#endif\n\n#ifdef PNG_WRITE_SUPPORTED\n/* The type of a compression buffer list used by the write code. */\ntypedef struct png_compression_buffer\n{\n   struct png_compression_buffer *next;\n   png_byte                       output[1]; /* actually zbuf_size */\n} png_compression_buffer, *png_compression_bufferp;\n\n#define PNG_COMPRESSION_BUFFER_SIZE(pp)\\\n   (offsetof(png_compression_buffer, output) + (pp)->zbuffer_size)\n#endif\n\n/* Colorspace support; structures used in png_struct, png_info and in internal\n * functions to hold and communicate information about the color space.\n *\n * PNG_COLORSPACE_SUPPORTED is only required if the application will perform\n * colorspace corrections, otherwise all the colorspace information can be\n * skipped and the size of libpng can be reduced (significantly) by compiling\n * out the colorspace support.\n */\n#ifdef PNG_COLORSPACE_SUPPORTED\n/* The chromaticities of the red, green and blue colorants and the chromaticity\n * of the corresponding white point (i.e. of rgb(1.0,1.0,1.0)).\n */\ntypedef struct png_xy\n{\n   png_fixed_point redx, redy;\n   png_fixed_point greenx, greeny;\n   png_fixed_point bluex, bluey;\n   png_fixed_point whitex, whitey;\n} png_xy;\n\n/* The same data as above but encoded as CIE XYZ values.  When this data comes\n * from chromaticities the sum of the Y values is assumed to be 1.0\n */\ntypedef struct png_XYZ\n{\n   png_fixed_point red_X, red_Y, red_Z;\n   png_fixed_point green_X, green_Y, green_Z;\n   png_fixed_point blue_X, blue_Y, blue_Z;\n} png_XYZ;\n#endif /* COLORSPACE */\n\n#if defined(PNG_COLORSPACE_SUPPORTED) || defined(PNG_GAMMA_SUPPORTED)\n/* A colorspace is all the above plus, potentially, profile information,\n * however at present libpng does not use the profile internally so it is only\n * stored in the png_info struct (if iCCP is supported.)  The rendering intent\n * is retained here and is checked.\n *\n * The file gamma encoding information is also stored here and gamma correction\n * is done by libpng, whereas color correction must currently be done by the\n * application.\n */\ntypedef struct png_colorspace\n{\n#ifdef PNG_GAMMA_SUPPORTED\n   png_fixed_point gamma;        /* File gamma */\n#endif\n\n#ifdef PNG_COLORSPACE_SUPPORTED\n   png_xy      end_points_xy;    /* End points as chromaticities */\n   png_XYZ     end_points_XYZ;   /* End points as CIE XYZ colorant values */\n   png_uint_16 rendering_intent; /* Rendering intent of a profile */\n#endif\n\n   /* Flags are always defined to simplify the code. */\n   png_uint_16 flags;            /* As defined below */\n} png_colorspace, * PNG_RESTRICT png_colorspacerp;\n\ntypedef const png_colorspace * PNG_RESTRICT png_const_colorspacerp;\n\n/* General flags for the 'flags' field */\n#define PNG_COLORSPACE_HAVE_GAMMA           0x0001\n#define PNG_COLORSPACE_HAVE_ENDPOINTS       0x0002\n#define PNG_COLORSPACE_HAVE_INTENT          0x0004\n#define PNG_COLORSPACE_FROM_gAMA            0x0008\n#define PNG_COLORSPACE_FROM_cHRM            0x0010\n#define PNG_COLORSPACE_FROM_sRGB            0x0020\n#define PNG_COLORSPACE_ENDPOINTS_MATCH_sRGB 0x0040\n#define PNG_COLORSPACE_MATCHES_sRGB         0x0080 /* exact match on profile */\n#define PNG_COLORSPACE_INVALID              0x8000\n#define PNG_COLORSPACE_CANCEL(flags)        (0xffff ^ (flags))\n#endif /* COLORSPACE || GAMMA */\n\nstruct png_struct_def\n{\n#ifdef PNG_SETJMP_SUPPORTED\n   jmp_buf jmp_buf_local;     /* New name in 1.6.0 for jmp_buf in png_struct */\n   png_longjmp_ptr longjmp_fn;/* setjmp non-local goto function. */\n   jmp_buf *jmp_buf_ptr;      /* passed to longjmp_fn */\n   size_t jmp_buf_size;       /* size of the above, if allocated */\n#endif\n   png_error_ptr error_fn;    /* function for printing errors and aborting */\n#ifdef PNG_WARNINGS_SUPPORTED\n   png_error_ptr warning_fn;  /* function for printing warnings */\n#endif\n   png_voidp error_ptr;       /* user supplied struct for error functions */\n   png_rw_ptr write_data_fn;  /* function for writing output data */\n   png_rw_ptr read_data_fn;   /* function for reading input data */\n   png_voidp io_ptr;          /* ptr to application struct for I/O functions */\n\n#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED\n   png_user_transform_ptr read_user_transform_fn; /* user read transform */\n#endif\n\n#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED\n   png_user_transform_ptr write_user_transform_fn; /* user write transform */\n#endif\n\n/* These were added in libpng-1.0.2 */\n#ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED\n#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \\\n    defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)\n   png_voidp user_transform_ptr; /* user supplied struct for user transform */\n   png_byte user_transform_depth;    /* bit depth of user transformed pixels */\n   png_byte user_transform_channels; /* channels in user transformed pixels */\n#endif\n#endif\n\n   png_uint_32 mode;          /* tells us where we are in the PNG file */\n   png_uint_32 flags;         /* flags indicating various things to libpng */\n   png_uint_32 transformations; /* which transformations to perform */\n\n   png_uint_32 zowner;        /* ID (chunk type) of zstream owner, 0 if none */\n   z_stream    zstream;       /* decompression structure */\n\n#ifdef PNG_WRITE_SUPPORTED\n   png_compression_bufferp zbuffer_list; /* Created on demand during write */\n   uInt                    zbuffer_size; /* size of the actual buffer */\n\n   int zlib_level;            /* holds zlib compression level */\n   int zlib_method;           /* holds zlib compression method */\n   int zlib_window_bits;      /* holds zlib compression window bits */\n   int zlib_mem_level;        /* holds zlib compression memory level */\n   int zlib_strategy;         /* holds zlib compression strategy */\n#endif\n/* Added at libpng 1.5.4 */\n#ifdef PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED\n   int zlib_text_level;            /* holds zlib compression level */\n   int zlib_text_method;           /* holds zlib compression method */\n   int zlib_text_window_bits;      /* holds zlib compression window bits */\n   int zlib_text_mem_level;        /* holds zlib compression memory level */\n   int zlib_text_strategy;         /* holds zlib compression strategy */\n#endif\n/* End of material added at libpng 1.5.4 */\n/* Added at libpng 1.6.0 */\n#ifdef PNG_WRITE_SUPPORTED\n   int zlib_set_level;        /* Actual values set into the zstream on write */\n   int zlib_set_method;\n   int zlib_set_window_bits;\n   int zlib_set_mem_level;\n   int zlib_set_strategy;\n#endif\n\n   png_uint_32 width;         /* width of image in pixels */\n   png_uint_32 height;        /* height of image in pixels */\n   png_uint_32 num_rows;      /* number of rows in current pass */\n   png_uint_32 usr_width;     /* width of row at start of write */\n   png_size_t rowbytes;       /* size of row in bytes */\n   png_uint_32 iwidth;        /* width of current interlaced row in pixels */\n   png_uint_32 row_number;    /* current row in interlace pass */\n   png_uint_32 chunk_name;    /* PNG_CHUNK() id of current chunk */\n   png_bytep prev_row;        /* buffer to save previous (unfiltered) row.\n                               * This is a pointer into big_prev_row\n                               */\n   png_bytep row_buf;         /* buffer to save current (unfiltered) row.\n                               * This is a pointer into big_row_buf\n                               */\n#ifdef PNG_WRITE_SUPPORTED\n   png_bytep sub_row;         /* buffer to save \"sub\" row when filtering */\n   png_bytep up_row;          /* buffer to save \"up\" row when filtering */\n   png_bytep avg_row;         /* buffer to save \"avg\" row when filtering */\n   png_bytep paeth_row;       /* buffer to save \"Paeth\" row when filtering */\n#endif\n   png_size_t info_rowbytes;  /* Added in 1.5.4: cache of updated row bytes */\n\n   png_uint_32 idat_size;     /* current IDAT size for read */\n   png_uint_32 crc;           /* current chunk CRC value */\n   png_colorp palette;        /* palette from the input file */\n   png_uint_16 num_palette;   /* number of color entries in palette */\n\n/* Added at libpng-1.5.10 */\n#ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED\n   int num_palette_max;       /* maximum palette index found in IDAT */\n#endif\n\n   png_uint_16 num_trans;     /* number of transparency values */\n   png_byte compression;      /* file compression type (always 0) */\n   png_byte filter;           /* file filter type (always 0) */\n   png_byte interlaced;       /* PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */\n   png_byte pass;             /* current interlace pass (0 - 6) */\n   png_byte do_filter;        /* row filter flags (see PNG_FILTER_ below ) */\n   png_byte color_type;       /* color type of file */\n   png_byte bit_depth;        /* bit depth of file */\n   png_byte usr_bit_depth;    /* bit depth of users row: write only */\n   png_byte pixel_depth;      /* number of bits per pixel */\n   png_byte channels;         /* number of channels in file */\n#ifdef PNG_WRITE_SUPPORTED\n   png_byte usr_channels;     /* channels at start of write: write only */\n#endif\n   png_byte sig_bytes;        /* magic bytes read/written from start of file */\n   png_byte maximum_pixel_depth;\n                              /* pixel depth used for the row buffers */\n   png_byte transformed_pixel_depth;\n                              /* pixel depth after read/write transforms */\n#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED)\n   png_uint_16 filler;           /* filler bytes for pixel expansion */\n#endif\n\n#if defined(PNG_bKGD_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) ||\\\n   defined(PNG_READ_ALPHA_MODE_SUPPORTED)\n   png_byte background_gamma_type;\n   png_fixed_point background_gamma;\n   png_color_16 background;   /* background color in screen gamma space */\n#ifdef PNG_READ_GAMMA_SUPPORTED\n   png_color_16 background_1; /* background normalized to gamma 1.0 */\n#endif\n#endif /* PNG_bKGD_SUPPORTED */\n\n#ifdef PNG_WRITE_FLUSH_SUPPORTED\n   png_flush_ptr output_flush_fn; /* Function for flushing output */\n   png_uint_32 flush_dist;    /* how many rows apart to flush, 0 - no flush */\n   png_uint_32 flush_rows;    /* number of rows written since last flush */\n#endif\n\n#ifdef PNG_READ_GAMMA_SUPPORTED\n   int gamma_shift;      /* number of \"insignificant\" bits in 16-bit gamma */\n   png_fixed_point screen_gamma; /* screen gamma value (display_exponent) */\n\n   png_bytep gamma_table;     /* gamma table for 8-bit depth files */\n   png_uint_16pp gamma_16_table; /* gamma table for 16-bit depth files */\n#if defined(PNG_READ_BACKGROUND_SUPPORTED) || \\\n   defined(PNG_READ_ALPHA_MODE_SUPPORTED) || \\\n   defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)\n   png_bytep gamma_from_1;    /* converts from 1.0 to screen */\n   png_bytep gamma_to_1;      /* converts from file to 1.0 */\n   png_uint_16pp gamma_16_from_1; /* converts from 1.0 to screen */\n   png_uint_16pp gamma_16_to_1; /* converts from file to 1.0 */\n#endif /* READ_BACKGROUND || READ_ALPHA_MODE || RGB_TO_GRAY */\n#endif\n\n#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_sBIT_SUPPORTED)\n   png_color_8 sig_bit;       /* significant bits in each available channel */\n#endif\n\n#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED)\n   png_color_8 shift;         /* shift for significant bit tranformation */\n#endif\n\n#if defined(PNG_tRNS_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) \\\n || defined(PNG_READ_EXPAND_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)\n   png_bytep trans_alpha;           /* alpha values for paletted files */\n   png_color_16 trans_color;  /* transparent color for non-paletted files */\n#endif\n\n   png_read_status_ptr read_row_fn;   /* called after each row is decoded */\n   png_write_status_ptr write_row_fn; /* called after each row is encoded */\n#ifdef PNG_PROGRESSIVE_READ_SUPPORTED\n   png_progressive_info_ptr info_fn; /* called after header data fully read */\n   png_progressive_row_ptr row_fn;   /* called after a prog. row is decoded */\n   png_progressive_end_ptr end_fn;   /* called after image is complete */\n   png_bytep save_buffer_ptr;        /* current location in save_buffer */\n   png_bytep save_buffer;            /* buffer for previously read data */\n   png_bytep current_buffer_ptr;     /* current location in current_buffer */\n   png_bytep current_buffer;         /* buffer for recently used data */\n   png_uint_32 push_length;          /* size of current input chunk */\n   png_uint_32 skip_length;          /* bytes to skip in input data */\n   png_size_t save_buffer_size;      /* amount of data now in save_buffer */\n   png_size_t save_buffer_max;       /* total size of save_buffer */\n   png_size_t buffer_size;           /* total amount of available input data */\n   png_size_t current_buffer_size;   /* amount of data now in current_buffer */\n   int process_mode;                 /* what push library is currently doing */\n   int cur_palette;                  /* current push library palette index */\n\n#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */\n\n#if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__)\n/* For the Borland special 64K segment handler */\n   png_bytepp offset_table_ptr;\n   png_bytep offset_table;\n   png_uint_16 offset_table_number;\n   png_uint_16 offset_table_count;\n   png_uint_16 offset_table_count_free;\n#endif\n\n#ifdef PNG_READ_QUANTIZE_SUPPORTED\n   png_bytep palette_lookup; /* lookup table for quantizing */\n   png_bytep quantize_index; /* index translation for palette files */\n#endif\n\n#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED\n   png_byte heuristic_method;        /* heuristic for row filter selection */\n   png_byte num_prev_filters;        /* number of weights for previous rows */\n   png_bytep prev_filters;           /* filter type(s) of previous row(s) */\n   png_uint_16p filter_weights;      /* weight(s) for previous line(s) */\n   png_uint_16p inv_filter_weights;  /* 1/weight(s) for previous line(s) */\n   png_uint_16p filter_costs;        /* relative filter calculation cost */\n   png_uint_16p inv_filter_costs;    /* 1/relative filter calculation cost */\n#endif\n\n   /* Options */\n#ifdef PNG_SET_OPTION_SUPPORTED\n   png_byte options;           /* On/off state (up to 4 options) */\n#endif\n\n#if PNG_LIBPNG_VER < 10700\n/* To do: remove this from libpng-1.7 */\n#ifdef PNG_TIME_RFC1123_SUPPORTED\n   char time_buffer[29]; /* String to hold RFC 1123 time text */\n#endif\n#endif\n\n/* New members added in libpng-1.0.6 */\n\n   png_uint_32 free_me;    /* flags items libpng is responsible for freeing */\n\n#ifdef PNG_USER_CHUNKS_SUPPORTED\n   png_voidp user_chunk_ptr;\n#ifdef PNG_READ_USER_CHUNKS_SUPPORTED\n   png_user_chunk_ptr read_user_chunk_fn; /* user read chunk handler */\n#endif\n#endif\n\n#ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED\n   int          unknown_default; /* As PNG_HANDLE_* */\n   unsigned int num_chunk_list;  /* Number of entries in the list */\n   png_bytep    chunk_list;      /* List of png_byte[5]; the textual chunk name\n                                  * followed by a PNG_HANDLE_* byte */\n#endif\n\n/* New members added in libpng-1.0.3 */\n#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED\n   png_byte rgb_to_gray_status;\n   /* Added in libpng 1.5.5 to record setting of coefficients: */\n   png_byte rgb_to_gray_coefficients_set;\n   /* These were changed from png_byte in libpng-1.0.6 */\n   png_uint_16 rgb_to_gray_red_coeff;\n   png_uint_16 rgb_to_gray_green_coeff;\n   /* deleted in 1.5.5: rgb_to_gray_blue_coeff; */\n#endif\n\n/* New member added in libpng-1.0.4 (renamed in 1.0.9) */\n#if defined(PNG_MNG_FEATURES_SUPPORTED)\n/* Changed from png_byte to png_uint_32 at version 1.2.0 */\n   png_uint_32 mng_features_permitted;\n#endif\n\n/* New member added in libpng-1.0.9, ifdef'ed out in 1.0.12, enabled in 1.2.0 */\n#ifdef PNG_MNG_FEATURES_SUPPORTED\n   png_byte filter_type;\n#endif\n\n/* New members added in libpng-1.2.0 */\n\n/* New members added in libpng-1.0.2 but first enabled by default in 1.2.0 */\n#ifdef PNG_USER_MEM_SUPPORTED\n   png_voidp mem_ptr;             /* user supplied struct for mem functions */\n   png_malloc_ptr malloc_fn;      /* function for allocating memory */\n   png_free_ptr free_fn;          /* function for freeing memory */\n#endif\n\n/* New member added in libpng-1.0.13 and 1.2.0 */\n   png_bytep big_row_buf;         /* buffer to save current (unfiltered) row */\n\n#ifdef PNG_READ_QUANTIZE_SUPPORTED\n/* The following three members were added at version 1.0.14 and 1.2.4 */\n   png_bytep quantize_sort;          /* working sort array */\n   png_bytep index_to_palette;       /* where the original index currently is\n                                        in the palette */\n   png_bytep palette_to_index;       /* which original index points to this\n                                         palette color */\n#endif\n\n/* New members added in libpng-1.0.16 and 1.2.6 */\n   png_byte compression_type;\n\n#ifdef PNG_USER_LIMITS_SUPPORTED\n   png_uint_32 user_width_max;\n   png_uint_32 user_height_max;\n\n   /* Added in libpng-1.4.0: Total number of sPLT, text, and unknown\n    * chunks that can be stored (0 means unlimited).\n    */\n   png_uint_32 user_chunk_cache_max;\n\n   /* Total memory that a zTXt, sPLT, iTXt, iCCP, or unknown chunk\n    * can occupy when decompressed.  0 means unlimited.\n    */\n   png_alloc_size_t user_chunk_malloc_max;\n#endif\n\n/* New member added in libpng-1.0.25 and 1.2.17 */\n#ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED\n   /* Temporary storage for unknown chunk that the library doesn't recognize,\n    * used while reading the chunk.\n    */\n   png_unknown_chunk unknown_chunk;\n#endif\n\n/* New member added in libpng-1.2.26 */\n  png_size_t old_big_row_buf_size;\n\n#ifdef PNG_READ_SUPPORTED\n/* New member added in libpng-1.2.30 */\n  png_bytep        read_buffer;      /* buffer for reading chunk data */\n  png_alloc_size_t read_buffer_size; /* current size of the buffer */\n#endif\n#ifdef PNG_SEQUENTIAL_READ_SUPPORTED\n  uInt             IDAT_read_size;   /* limit on read buffer size for IDAT */\n#endif\n\n#ifdef PNG_IO_STATE_SUPPORTED\n/* New member added in libpng-1.4.0 */\n   png_uint_32 io_state;\n#endif\n\n/* New member added in libpng-1.5.6 */\n   png_bytep big_prev_row;\n\n/* New member added in libpng-1.5.7 */\n   void (*read_filter[PNG_FILTER_VALUE_LAST-1])(png_row_infop row_info,\n      png_bytep row, png_const_bytep prev_row);\n\n#ifdef PNG_READ_SUPPORTED\n#if defined(PNG_COLORSPACE_SUPPORTED) || defined(PNG_GAMMA_SUPPORTED)\n   png_colorspace   colorspace;\n#endif\n#endif\n};\n#endif /* PNGSTRUCT_H */\n"
  },
  {
    "path": "Libraries/Core/iOS/Headers/rapidxml/rapidxml.hpp",
    "content": "#ifndef RAPIDXML_HPP_INCLUDED\r\n#define RAPIDXML_HPP_INCLUDED\r\n\r\n// Copyright (C) 2006, 2009 Marcin Kalicinski\r\n// Version 1.13\r\n// Revision $DateTime: 2009/05/13 01:46:17 $\r\n//! \\file rapidxml.hpp This file contains rapidxml parser and DOM implementation\r\n\r\n// If standard library is disabled, user must provide implementations of required functions and typedefs\r\n#if !defined(RAPIDXML_NO_STDLIB)\r\n    #include <cstdlib>      // For std::size_t\r\n    #include <cassert>      // For assert\r\n    #include <new>          // For placement new\r\n#endif\r\n\r\n// On MSVC, disable \"conditional expression is constant\" warning (level 4). \r\n// This warning is almost impossible to avoid with certain types of templated code\r\n#ifdef _MSC_VER\r\n    #pragma warning(push)\r\n    #pragma warning(disable:4127)   // Conditional expression is constant\r\n#endif\r\n\r\n///////////////////////////////////////////////////////////////////////////\r\n// RAPIDXML_PARSE_ERROR\r\n    \r\n#if defined(RAPIDXML_NO_EXCEPTIONS)\r\n\r\n#define RAPIDXML_PARSE_ERROR(what, where) { parse_error_handler(what, where); assert(0); }\r\n\r\nnamespace rapidxml\r\n{\r\n    //! When exceptions are disabled by defining RAPIDXML_NO_EXCEPTIONS, \r\n    //! this function is called to notify user about the error.\r\n    //! It must be defined by the user.\r\n    //! <br><br>\r\n    //! This function cannot return. If it does, the results are undefined.\r\n    //! <br><br>\r\n    //! A very simple definition might look like that:\r\n    //! <pre>\r\n    //! void %rapidxml::%parse_error_handler(const char *what, void *where)\r\n    //! {\r\n    //!     std::cout << \"Parse error: \" << what << \"\\n\";\r\n    //!     std::abort();\r\n    //! }\r\n    //! </pre>\r\n    //! \\param what Human readable description of the error.\r\n    //! \\param where Pointer to character data where error was detected.\r\n    void parse_error_handler(const char *what, void *where);\r\n}\r\n\r\n#else\r\n    \r\n#include <exception>    // For std::exception\r\n\r\n#define RAPIDXML_PARSE_ERROR(what, where) throw parse_error(what, where)\r\n\r\nnamespace rapidxml\r\n{\r\n\r\n    //! Parse error exception. \r\n    //! This exception is thrown by the parser when an error occurs. \r\n    //! Use what() function to get human-readable error message. \r\n    //! Use where() function to get a pointer to position within source text where error was detected.\r\n    //! <br><br>\r\n    //! If throwing exceptions by the parser is undesirable, \r\n    //! it can be disabled by defining RAPIDXML_NO_EXCEPTIONS macro before rapidxml.hpp is included.\r\n    //! This will cause the parser to call rapidxml::parse_error_handler() function instead of throwing an exception.\r\n    //! This function must be defined by the user.\r\n    //! <br><br>\r\n    //! This class derives from <code>std::exception</code> class.\r\n    class parse_error: public std::exception\r\n    {\r\n    \r\n    public:\r\n    \r\n        //! Constructs parse error\r\n        parse_error(const char *what, void *where)\r\n            : m_what(what)\r\n            , m_where(where)\r\n        {\r\n        }\r\n\r\n        //! Gets human readable description of error.\r\n        //! \\return Pointer to null terminated description of the error.\r\n        virtual const char *what() const throw()\r\n        {\r\n            return m_what;\r\n        }\r\n\r\n        //! Gets pointer to character data where error happened.\r\n        //! Ch should be the same as char type of xml_document that produced the error.\r\n        //! \\return Pointer to location within the parsed string where error occured.\r\n        template<class Ch>\r\n        Ch *where() const\r\n        {\r\n            return reinterpret_cast<Ch *>(m_where);\r\n        }\r\n\r\n    private:  \r\n\r\n        const char *m_what;\r\n        void *m_where;\r\n\r\n    };\r\n}\r\n\r\n#endif\r\n\r\n///////////////////////////////////////////////////////////////////////////\r\n// Pool sizes\r\n\r\n#ifndef RAPIDXML_STATIC_POOL_SIZE\r\n    // Size of static memory block of memory_pool.\r\n    // Define RAPIDXML_STATIC_POOL_SIZE before including rapidxml.hpp if you want to override the default value.\r\n    // No dynamic memory allocations are performed by memory_pool until static memory is exhausted.\r\n    #define RAPIDXML_STATIC_POOL_SIZE (64 * 1024)\r\n#endif\r\n\r\n#ifndef RAPIDXML_DYNAMIC_POOL_SIZE\r\n    // Size of dynamic memory block of memory_pool.\r\n    // Define RAPIDXML_DYNAMIC_POOL_SIZE before including rapidxml.hpp if you want to override the default value.\r\n    // After the static block is exhausted, dynamic blocks with approximately this size are allocated by memory_pool.\r\n    #define RAPIDXML_DYNAMIC_POOL_SIZE (64 * 1024)\r\n#endif\r\n\r\n#ifndef RAPIDXML_ALIGNMENT\r\n    // Memory allocation alignment.\r\n    // Define RAPIDXML_ALIGNMENT before including rapidxml.hpp if you want to override the default value, which is the size of pointer.\r\n    // All memory allocations for nodes, attributes and strings will be aligned to this value.\r\n    // This must be a power of 2 and at least 1, otherwise memory_pool will not work.\r\n    #define RAPIDXML_ALIGNMENT sizeof(void *)\r\n#endif\r\n\r\nnamespace rapidxml\r\n{\r\n    // Forward declarations\r\n    template<class Ch> class xml_node;\r\n    template<class Ch> class xml_attribute;\r\n    template<class Ch> class xml_document;\r\n    \r\n    //! Enumeration listing all node types produced by the parser.\r\n    //! Use xml_node::type() function to query node type.\r\n    enum node_type\r\n    {\r\n        node_document,      //!< A document node. Name and value are empty.\r\n        node_element,       //!< An element node. Name contains element name. Value contains text of first data node.\r\n        node_data,          //!< A data node. Name is empty. Value contains data text.\r\n        node_cdata,         //!< A CDATA node. Name is empty. Value contains data text.\r\n        node_comment,       //!< A comment node. Name is empty. Value contains comment text.\r\n        node_declaration,   //!< A declaration node. Name and value are empty. Declaration parameters (version, encoding and standalone) are in node attributes.\r\n        node_doctype,       //!< A DOCTYPE node. Name is empty. Value contains DOCTYPE text.\r\n        node_pi             //!< A PI node. Name contains target. Value contains instructions.\r\n    };\r\n\r\n    ///////////////////////////////////////////////////////////////////////\r\n    // Parsing flags\r\n\r\n    //! Parse flag instructing the parser to not create data nodes. \r\n    //! Text of first data node will still be placed in value of parent element, unless rapidxml::parse_no_element_values flag is also specified.\r\n    //! Can be combined with other flags by use of | operator.\r\n    //! <br><br>\r\n    //! See xml_document::parse() function.\r\n    const int parse_no_data_nodes = 0x1;            \r\n\r\n    //! Parse flag instructing the parser to not use text of first data node as a value of parent element.\r\n    //! Can be combined with other flags by use of | operator.\r\n    //! Note that child data nodes of element node take precendence over its value when printing. \r\n    //! That is, if element has one or more child data nodes <em>and</em> a value, the value will be ignored.\r\n    //! Use rapidxml::parse_no_data_nodes flag to prevent creation of data nodes if you want to manipulate data using values of elements.\r\n    //! <br><br>\r\n    //! See xml_document::parse() function.\r\n    const int parse_no_element_values = 0x2;\r\n    \r\n    //! Parse flag instructing the parser to not place zero terminators after strings in the source text.\r\n    //! By default zero terminators are placed, modifying source text.\r\n    //! Can be combined with other flags by use of | operator.\r\n    //! <br><br>\r\n    //! See xml_document::parse() function.\r\n    const int parse_no_string_terminators = 0x4;\r\n    \r\n    //! Parse flag instructing the parser to not translate entities in the source text.\r\n    //! By default entities are translated, modifying source text.\r\n    //! Can be combined with other flags by use of | operator.\r\n    //! <br><br>\r\n    //! See xml_document::parse() function.\r\n    const int parse_no_entity_translation = 0x8;\r\n    \r\n    //! Parse flag instructing the parser to disable UTF-8 handling and assume plain 8 bit characters.\r\n    //! By default, UTF-8 handling is enabled.\r\n    //! Can be combined with other flags by use of | operator.\r\n    //! <br><br>\r\n    //! See xml_document::parse() function.\r\n    const int parse_no_utf8 = 0x10;\r\n    \r\n    //! Parse flag instructing the parser to create XML declaration node.\r\n    //! By default, declaration node is not created.\r\n    //! Can be combined with other flags by use of | operator.\r\n    //! <br><br>\r\n    //! See xml_document::parse() function.\r\n    const int parse_declaration_node = 0x20;\r\n    \r\n    //! Parse flag instructing the parser to create comments nodes.\r\n    //! By default, comment nodes are not created.\r\n    //! Can be combined with other flags by use of | operator.\r\n    //! <br><br>\r\n    //! See xml_document::parse() function.\r\n    const int parse_comment_nodes = 0x40;\r\n    \r\n    //! Parse flag instructing the parser to create DOCTYPE node.\r\n    //! By default, doctype node is not created.\r\n    //! Although W3C specification allows at most one DOCTYPE node, RapidXml will silently accept documents with more than one.\r\n    //! Can be combined with other flags by use of | operator.\r\n    //! <br><br>\r\n    //! See xml_document::parse() function.\r\n    const int parse_doctype_node = 0x80;\r\n    \r\n    //! Parse flag instructing the parser to create PI nodes.\r\n    //! By default, PI nodes are not created.\r\n    //! Can be combined with other flags by use of | operator.\r\n    //! <br><br>\r\n    //! See xml_document::parse() function.\r\n    const int parse_pi_nodes = 0x100;\r\n    \r\n    //! Parse flag instructing the parser to validate closing tag names. \r\n    //! If not set, name inside closing tag is irrelevant to the parser.\r\n    //! By default, closing tags are not validated.\r\n    //! Can be combined with other flags by use of | operator.\r\n    //! <br><br>\r\n    //! See xml_document::parse() function.\r\n    const int parse_validate_closing_tags = 0x200;\r\n    \r\n    //! Parse flag instructing the parser to trim all leading and trailing whitespace of data nodes.\r\n    //! By default, whitespace is not trimmed. \r\n    //! This flag does not cause the parser to modify source text.\r\n    //! Can be combined with other flags by use of | operator.\r\n    //! <br><br>\r\n    //! See xml_document::parse() function.\r\n    const int parse_trim_whitespace = 0x400;\r\n\r\n    //! Parse flag instructing the parser to condense all whitespace runs of data nodes to a single space character.\r\n    //! Trimming of leading and trailing whitespace of data is controlled by rapidxml::parse_trim_whitespace flag.\r\n    //! By default, whitespace is not normalized. \r\n    //! If this flag is specified, source text will be modified.\r\n    //! Can be combined with other flags by use of | operator.\r\n    //! <br><br>\r\n    //! See xml_document::parse() function.\r\n    const int parse_normalize_whitespace = 0x800;\r\n\r\n    // Compound flags\r\n    \r\n    //! Parse flags which represent default behaviour of the parser. \r\n    //! This is always equal to 0, so that all other flags can be simply ored together.\r\n    //! Normally there is no need to inconveniently disable flags by anding with their negated (~) values.\r\n    //! This also means that meaning of each flag is a <i>negation</i> of the default setting. \r\n    //! For example, if flag name is rapidxml::parse_no_utf8, it means that utf-8 is <i>enabled</i> by default,\r\n    //! and using the flag will disable it.\r\n    //! <br><br>\r\n    //! See xml_document::parse() function.\r\n    const int parse_default = 0;\r\n    \r\n    //! A combination of parse flags that forbids any modifications of the source text. \r\n    //! This also results in faster parsing. However, note that the following will occur:\r\n    //! <ul>\r\n    //! <li>names and values of nodes will not be zero terminated, you have to use xml_base::name_size() and xml_base::value_size() functions to determine where name and value ends</li>\r\n    //! <li>entities will not be translated</li>\r\n    //! <li>whitespace will not be normalized</li>\r\n    //! </ul>\r\n    //! See xml_document::parse() function.\r\n    const int parse_non_destructive = parse_no_string_terminators | parse_no_entity_translation;\r\n    \r\n    //! A combination of parse flags resulting in fastest possible parsing, without sacrificing important data.\r\n    //! <br><br>\r\n    //! See xml_document::parse() function.\r\n    const int parse_fastest = parse_non_destructive | parse_no_data_nodes;\r\n    \r\n    //! A combination of parse flags resulting in largest amount of data being extracted. \r\n    //! This usually results in slowest parsing.\r\n    //! <br><br>\r\n    //! See xml_document::parse() function.\r\n    const int parse_full = parse_declaration_node | parse_comment_nodes | parse_doctype_node | parse_pi_nodes | parse_validate_closing_tags;\r\n\r\n    ///////////////////////////////////////////////////////////////////////\r\n    // Internals\r\n\r\n    //! \\cond internal\r\n    namespace internal\r\n    {\r\n\r\n        // Struct that contains lookup tables for the parser\r\n        // It must be a template to allow correct linking (because it has static data members, which are defined in a header file).\r\n        template<int Dummy>\r\n        struct lookup_tables\r\n        {\r\n            static const unsigned char lookup_whitespace[256];              // Whitespace table\r\n            static const unsigned char lookup_node_name[256];               // Node name table\r\n            static const unsigned char lookup_text[256];                    // Text table\r\n            static const unsigned char lookup_text_pure_no_ws[256];         // Text table\r\n            static const unsigned char lookup_text_pure_with_ws[256];       // Text table\r\n            static const unsigned char lookup_attribute_name[256];          // Attribute name table\r\n            static const unsigned char lookup_attribute_data_1[256];        // Attribute data table with single quote\r\n            static const unsigned char lookup_attribute_data_1_pure[256];   // Attribute data table with single quote\r\n            static const unsigned char lookup_attribute_data_2[256];        // Attribute data table with double quotes\r\n            static const unsigned char lookup_attribute_data_2_pure[256];   // Attribute data table with double quotes\r\n            static const unsigned char lookup_digits[256];                  // Digits\r\n            static const unsigned char lookup_upcase[256];                  // To uppercase conversion table for ASCII characters\r\n        };\r\n\r\n        // Find length of the string\r\n        template<class Ch>\r\n        inline std::size_t measure(const Ch *p)\r\n        {\r\n            const Ch *tmp = p;\r\n            while (*tmp) \r\n                ++tmp;\r\n            return tmp - p;\r\n        }\r\n\r\n        // Compare strings for equality\r\n        template<class Ch>\r\n        inline bool compare(const Ch *p1, std::size_t size1, const Ch *p2, std::size_t size2, bool case_sensitive)\r\n        {\r\n            if (size1 != size2)\r\n                return false;\r\n            if (case_sensitive)\r\n            {\r\n                for (const Ch *end = p1 + size1; p1 < end; ++p1, ++p2)\r\n                    if (*p1 != *p2)\r\n                        return false;\r\n            }\r\n            else\r\n            {\r\n                for (const Ch *end = p1 + size1; p1 < end; ++p1, ++p2)\r\n                    if (lookup_tables<0>::lookup_upcase[static_cast<unsigned char>(*p1)] != lookup_tables<0>::lookup_upcase[static_cast<unsigned char>(*p2)])\r\n                        return false;\r\n            }\r\n            return true;\r\n        }\r\n    }\r\n    //! \\endcond\r\n\r\n    ///////////////////////////////////////////////////////////////////////\r\n    // Memory pool\r\n    \r\n    //! This class is used by the parser to create new nodes and attributes, without overheads of dynamic memory allocation.\r\n    //! In most cases, you will not need to use this class directly. \r\n    //! However, if you need to create nodes manually or modify names/values of nodes, \r\n    //! you are encouraged to use memory_pool of relevant xml_document to allocate the memory. \r\n    //! Not only is this faster than allocating them by using <code>new</code> operator, \r\n    //! but also their lifetime will be tied to the lifetime of document, \r\n    //! possibly simplyfing memory management. \r\n    //! <br><br>\r\n    //! Call allocate_node() or allocate_attribute() functions to obtain new nodes or attributes from the pool. \r\n    //! You can also call allocate_string() function to allocate strings.\r\n    //! Such strings can then be used as names or values of nodes without worrying about their lifetime.\r\n    //! Note that there is no <code>free()</code> function -- all allocations are freed at once when clear() function is called, \r\n    //! or when the pool is destroyed.\r\n    //! <br><br>\r\n    //! It is also possible to create a standalone memory_pool, and use it \r\n    //! to allocate nodes, whose lifetime will not be tied to any document.\r\n    //! <br><br>\r\n    //! Pool maintains <code>RAPIDXML_STATIC_POOL_SIZE</code> bytes of statically allocated memory. \r\n    //! Until static memory is exhausted, no dynamic memory allocations are done.\r\n    //! When static memory is exhausted, pool allocates additional blocks of memory of size <code>RAPIDXML_DYNAMIC_POOL_SIZE</code> each,\r\n    //! by using global <code>new[]</code> and <code>delete[]</code> operators. \r\n    //! This behaviour can be changed by setting custom allocation routines. \r\n    //! Use set_allocator() function to set them.\r\n    //! <br><br>\r\n    //! Allocations for nodes, attributes and strings are aligned at <code>RAPIDXML_ALIGNMENT</code> bytes.\r\n    //! This value defaults to the size of pointer on target architecture.\r\n    //! <br><br>\r\n    //! To obtain absolutely top performance from the parser,\r\n    //! it is important that all nodes are allocated from a single, contiguous block of memory.\r\n    //! Otherwise, cache misses when jumping between two (or more) disjoint blocks of memory can slow down parsing quite considerably.\r\n    //! If required, you can tweak <code>RAPIDXML_STATIC_POOL_SIZE</code>, <code>RAPIDXML_DYNAMIC_POOL_SIZE</code> and <code>RAPIDXML_ALIGNMENT</code> \r\n    //! to obtain best wasted memory to performance compromise.\r\n    //! To do it, define their values before rapidxml.hpp file is included.\r\n    //! \\param Ch Character type of created nodes. \r\n    template<class Ch = char>\r\n    class memory_pool\r\n    {\r\n        \r\n    public:\r\n\r\n        //! \\cond internal\r\n        typedef void *(rapidxml_alloc_func)(std::size_t);       // Type of user-defined function used to allocate memory\r\n        typedef void (free_func)(void *);              // Type of user-defined function used to free memory\r\n        //! \\endcond\r\n        \r\n        //! Constructs empty pool with default allocator functions.\r\n        memory_pool()\r\n            : m_rapidxml_alloc_func(0)\r\n            , m_free_func(0)\r\n        {\r\n            init();\r\n        }\r\n\r\n        //! Destroys pool and frees all the memory. \r\n        //! This causes memory occupied by nodes allocated by the pool to be freed.\r\n        //! Nodes allocated from the pool are no longer valid.\r\n        ~memory_pool()\r\n        {\r\n            clear();\r\n        }\r\n\r\n        //! Allocates a new node from the pool, and optionally assigns name and value to it. \r\n        //! If the allocation request cannot be accomodated, this function will throw <code>std::bad_alloc</code>.\r\n        //! If exceptions are disabled by defining RAPIDXML_NO_EXCEPTIONS, this function\r\n        //! will call rapidxml::parse_error_handler() function.\r\n        //! \\param type Type of node to create.\r\n        //! \\param name Name to assign to the node, or 0 to assign no name.\r\n        //! \\param value Value to assign to the node, or 0 to assign no value.\r\n        //! \\param name_size Size of name to assign, or 0 to automatically calculate size from name string.\r\n        //! \\param value_size Size of value to assign, or 0 to automatically calculate size from value string.\r\n        //! \\return Pointer to allocated node. This pointer will never be NULL.\r\n        xml_node<Ch> *allocate_node(node_type type, \r\n                                    const Ch *name = 0, const Ch *value = 0, \r\n                                    std::size_t name_size = 0, std::size_t value_size = 0)\r\n        {\r\n            void *memory = allocate_aligned(sizeof(xml_node<Ch>));\r\n            xml_node<Ch> *node = new(memory) xml_node<Ch>(type);\r\n            if (name)\r\n            {\r\n                if (name_size > 0)\r\n                    node->name(name, name_size);\r\n                else\r\n                    node->name(name);\r\n            }\r\n            if (value)\r\n            {\r\n                if (value_size > 0)\r\n                    node->value(value, value_size);\r\n                else\r\n                    node->value(value);\r\n            }\r\n            return node;\r\n        }\r\n\r\n        //! Allocates a new attribute from the pool, and optionally assigns name and value to it.\r\n        //! If the allocation request cannot be accomodated, this function will throw <code>std::bad_alloc</code>.\r\n        //! If exceptions are disabled by defining RAPIDXML_NO_EXCEPTIONS, this function\r\n        //! will call rapidxml::parse_error_handler() function.\r\n        //! \\param name Name to assign to the attribute, or 0 to assign no name.\r\n        //! \\param value Value to assign to the attribute, or 0 to assign no value.\r\n        //! \\param name_size Size of name to assign, or 0 to automatically calculate size from name string.\r\n        //! \\param value_size Size of value to assign, or 0 to automatically calculate size from value string.\r\n        //! \\return Pointer to allocated attribute. This pointer will never be NULL.\r\n        xml_attribute<Ch> *allocate_attribute(const Ch *name = 0, const Ch *value = 0, \r\n                                              std::size_t name_size = 0, std::size_t value_size = 0)\r\n        {\r\n            void *memory = allocate_aligned(sizeof(xml_attribute<Ch>));\r\n            xml_attribute<Ch> *attribute = new(memory) xml_attribute<Ch>;\r\n            if (name)\r\n            {\r\n                if (name_size > 0)\r\n                    attribute->name(name, name_size);\r\n                else\r\n                    attribute->name(name);\r\n            }\r\n            if (value)\r\n            {\r\n                if (value_size > 0)\r\n                    attribute->value(value, value_size);\r\n                else\r\n                    attribute->value(value);\r\n            }\r\n            return attribute;\r\n        }\r\n\r\n        //! Allocates a char array of given size from the pool, and optionally copies a given string to it.\r\n        //! If the allocation request cannot be accomodated, this function will throw <code>std::bad_alloc</code>.\r\n        //! If exceptions are disabled by defining RAPIDXML_NO_EXCEPTIONS, this function\r\n        //! will call rapidxml::parse_error_handler() function.\r\n        //! \\param source String to initialize the allocated memory with, or 0 to not initialize it.\r\n        //! \\param size Number of characters to allocate, or zero to calculate it automatically from source string length; if size is 0, source string must be specified and null terminated.\r\n        //! \\return Pointer to allocated char array. This pointer will never be NULL.\r\n        Ch *allocate_string(const Ch *source = 0, std::size_t size = 0)\r\n        {\r\n            assert(source || size);     // Either source or size (or both) must be specified\r\n            if (size == 0)\r\n                size = internal::measure(source) + 1;\r\n            Ch *result = static_cast<Ch *>(allocate_aligned(size * sizeof(Ch)));\r\n            if (source)\r\n                for (std::size_t i = 0; i < size; ++i)\r\n                    result[i] = source[i];\r\n            return result;\r\n        }\r\n\r\n        //! Clones an xml_node and its hierarchy of child nodes and attributes.\r\n        //! Nodes and attributes are allocated from this memory pool.\r\n        //! Names and values are not cloned, they are shared between the clone and the source.\r\n        //! Result node can be optionally specified as a second parameter, \r\n        //! in which case its contents will be replaced with cloned source node.\r\n        //! This is useful when you want to clone entire document.\r\n        //! \\param source Node to clone.\r\n        //! \\param result Node to put results in, or 0 to automatically allocate result node\r\n        //! \\return Pointer to cloned node. This pointer will never be NULL.\r\n        xml_node<Ch> *clone_node(const xml_node<Ch> *source, xml_node<Ch> *result = 0)\r\n        {\r\n            // Prepare result node\r\n            if (result)\r\n            {\r\n                result->remove_all_attributes();\r\n                result->remove_all_nodes();\r\n                result->type(source->type());\r\n            }\r\n            else\r\n                result = allocate_node(source->type());\r\n\r\n            // Clone name and value\r\n            result->name(source->name(), source->name_size());\r\n            result->value(source->value(), source->value_size());\r\n\r\n            // Clone child nodes and attributes\r\n            for (xml_node<Ch> *child = source->first_node(); child; child = child->next_sibling())\r\n                result->append_node(clone_node(child));\r\n            for (xml_attribute<Ch> *attr = source->first_attribute(); attr; attr = attr->next_attribute())\r\n                result->append_attribute(allocate_attribute(attr->name(), attr->value(), attr->name_size(), attr->value_size()));\r\n\r\n            return result;\r\n        }\r\n\r\n        //! Clears the pool. \r\n        //! This causes memory occupied by nodes allocated by the pool to be freed.\r\n        //! Any nodes or strings allocated from the pool will no longer be valid.\r\n        void clear()\r\n        {\r\n            while (m_begin != m_static_memory)\r\n            {\r\n                char *previous_begin = reinterpret_cast<header *>(align(m_begin))->previous_begin;\r\n                if (m_free_func)\r\n                    m_free_func(m_begin);\r\n                else\r\n                    delete[] m_begin;\r\n                m_begin = previous_begin;\r\n            }\r\n            init();\r\n        }\r\n\r\n        //! Sets or resets the user-defined memory allocation functions for the pool.\r\n        //! This can only be called when no memory is allocated from the pool yet, otherwise results are undefined.\r\n        //! Allocation function must not return invalid pointer on failure. It should either throw,\r\n        //! stop the program, or use <code>longjmp()</code> function to pass control to other place of program. \r\n        //! If it returns invalid pointer, results are undefined.\r\n        //! <br><br>\r\n        //! User defined allocation functions must have the following forms:\r\n        //! <br><code>\r\n        //! <br>void *allocate(std::size_t size);\r\n        //! <br>void free(void *pointer);\r\n        //! </code><br>\r\n        //! \\param af Allocation function, or 0 to restore default function\r\n        //! \\param ff Free function, or 0 to restore default function\r\n        void set_allocator(rapidxml_alloc_func *af, free_func *ff)\r\n        {\r\n            assert(m_begin == m_static_memory && m_ptr == align(m_begin));    // Verify that no memory is allocated yet\r\n            m_rapidxml_alloc_func = af;\r\n            m_free_func = ff;\r\n        }\r\n\r\n    private:\r\n\r\n        struct header\r\n        {\r\n            char *previous_begin;\r\n        };\r\n\r\n        void init()\r\n        {\r\n            m_begin = m_static_memory;\r\n            m_ptr = align(m_begin);\r\n            m_end = m_static_memory + sizeof(m_static_memory);\r\n        }\r\n        \r\n        char *align(char *ptr)\r\n        {\r\n            std::size_t alignment = ((RAPIDXML_ALIGNMENT - (std::size_t(ptr) & (RAPIDXML_ALIGNMENT - 1))) & (RAPIDXML_ALIGNMENT - 1));\r\n            return ptr + alignment;\r\n        }\r\n        \r\n        char *allocate_raw(std::size_t size)\r\n        {\r\n            // Allocate\r\n            void *memory;   \r\n            if (m_rapidxml_alloc_func)   // Allocate memory using either user-specified allocation function or global operator new[]\r\n            {\r\n                memory = m_rapidxml_alloc_func(size);\r\n                assert(memory); // Allocator is not allowed to return 0, on failure it must either throw, stop the program or use longjmp\r\n            }\r\n            else\r\n            {\r\n                memory = new char[size];\r\n#ifdef RAPIDXML_NO_EXCEPTIONS\r\n                if (!memory)            // If exceptions are disabled, verify memory allocation, because new will not be able to throw bad_alloc\r\n                    RAPIDXML_PARSE_ERROR(\"out of memory\", 0);\r\n#endif\r\n            }\r\n            return static_cast<char *>(memory);\r\n        }\r\n        \r\n        void *allocate_aligned(std::size_t size)\r\n        {\r\n            // Calculate aligned pointer\r\n            char *result = align(m_ptr);\r\n\r\n            // If not enough memory left in current pool, allocate a new pool\r\n            if (result + size > m_end)\r\n            {\r\n                // Calculate required pool size (may be bigger than RAPIDXML_DYNAMIC_POOL_SIZE)\r\n                std::size_t pool_size = RAPIDXML_DYNAMIC_POOL_SIZE;\r\n                if (pool_size < size)\r\n                    pool_size = size;\r\n                \r\n                // Allocate\r\n                std::size_t alloc_size = sizeof(header) + (2 * RAPIDXML_ALIGNMENT - 2) + pool_size;     // 2 alignments required in worst case: one for header, one for actual allocation\r\n                char *raw_memory = allocate_raw(alloc_size);\r\n                    \r\n                // Setup new pool in allocated memory\r\n                char *pool = align(raw_memory);\r\n                header *new_header = reinterpret_cast<header *>(pool);\r\n                new_header->previous_begin = m_begin;\r\n                m_begin = raw_memory;\r\n                m_ptr = pool + sizeof(header);\r\n                m_end = raw_memory + alloc_size;\r\n\r\n                // Calculate aligned pointer again using new pool\r\n                result = align(m_ptr);\r\n            }\r\n\r\n            // Update pool and return aligned pointer\r\n            m_ptr = result + size;\r\n            return result;\r\n        }\r\n\r\n        char *m_begin;                                      // Start of raw memory making up current pool\r\n        char *m_ptr;                                        // First free byte in current pool\r\n        char *m_end;                                        // One past last available byte in current pool\r\n        char m_static_memory[RAPIDXML_STATIC_POOL_SIZE];    // Static raw memory\r\n        rapidxml_alloc_func *m_rapidxml_alloc_func;                           // Allocator function, or 0 if default is to be used\r\n        free_func *m_free_func;                             // Free function, or 0 if default is to be used\r\n    };\r\n\r\n    ///////////////////////////////////////////////////////////////////////////\r\n    // XML base\r\n\r\n    //! Base class for xml_node and xml_attribute implementing common functions: \r\n    //! name(), name_size(), value(), value_size() and parent().\r\n    //! \\param Ch Character type to use\r\n    template<class Ch = char>\r\n    class xml_base\r\n    {\r\n\r\n    public:\r\n        \r\n        ///////////////////////////////////////////////////////////////////////////\r\n        // Construction & destruction\r\n    \r\n        // Construct a base with empty name, value and parent\r\n        xml_base()\r\n            : m_name(0)\r\n            , m_value(0)\r\n            , m_parent(0)\r\n        {\r\n        }\r\n\r\n        ///////////////////////////////////////////////////////////////////////////\r\n        // Node data access\r\n    \r\n        //! Gets name of the node. \r\n        //! Interpretation of name depends on type of node.\r\n        //! Note that name will not be zero-terminated if rapidxml::parse_no_string_terminators option was selected during parse.\r\n        //! <br><br>\r\n        //! Use name_size() function to determine length of the name.\r\n        //! \\return Name of node, or empty string if node has no name.\r\n        Ch *name() const\r\n        {\r\n            return m_name ? m_name : nullstr();\r\n        }\r\n\r\n        //! Gets size of node name, not including terminator character.\r\n        //! This function works correctly irrespective of whether name is or is not zero terminated.\r\n        //! \\return Size of node name, in characters.\r\n        std::size_t name_size() const\r\n        {\r\n            return m_name ? m_name_size : 0;\r\n        }\r\n\r\n        //! Gets value of node. \r\n        //! Interpretation of value depends on type of node.\r\n        //! Note that value will not be zero-terminated if rapidxml::parse_no_string_terminators option was selected during parse.\r\n        //! <br><br>\r\n        //! Use value_size() function to determine length of the value.\r\n        //! \\return Value of node, or empty string if node has no value.\r\n        Ch *value() const\r\n        {\r\n            return m_value ? m_value : nullstr();\r\n        }\r\n\r\n        //! Gets size of node value, not including terminator character.\r\n        //! This function works correctly irrespective of whether value is or is not zero terminated.\r\n        //! \\return Size of node value, in characters.\r\n        std::size_t value_size() const\r\n        {\r\n            return m_value ? m_value_size : 0;\r\n        }\r\n\r\n        ///////////////////////////////////////////////////////////////////////////\r\n        // Node modification\r\n    \r\n        //! Sets name of node to a non zero-terminated string.\r\n        //! See \\ref ownership_of_strings.\r\n        //! <br><br>\r\n        //! Note that node does not own its name or value, it only stores a pointer to it. \r\n        //! It will not delete or otherwise free the pointer on destruction.\r\n        //! It is reponsibility of the user to properly manage lifetime of the string.\r\n        //! The easiest way to achieve it is to use memory_pool of the document to allocate the string -\r\n        //! on destruction of the document the string will be automatically freed.\r\n        //! <br><br>\r\n        //! Size of name must be specified separately, because name does not have to be zero terminated.\r\n        //! Use name(const Ch *) function to have the length automatically calculated (string must be zero terminated).\r\n        //! \\param name Name of node to set. Does not have to be zero terminated.\r\n        //! \\param size Size of name, in characters. This does not include zero terminator, if one is present.\r\n        void name(const Ch *name, std::size_t size)\r\n        {\r\n            m_name = const_cast<Ch *>(name);\r\n            m_name_size = size;\r\n        }\r\n\r\n        //! Sets name of node to a zero-terminated string.\r\n        //! See also \\ref ownership_of_strings and xml_node::name(const Ch *, std::size_t).\r\n        //! \\param name Name of node to set. Must be zero terminated.\r\n        void name(const Ch *name)\r\n        {\r\n            this->name(name, internal::measure(name));\r\n        }\r\n\r\n        //! Sets value of node to a non zero-terminated string.\r\n        //! See \\ref ownership_of_strings.\r\n        //! <br><br>\r\n        //! Note that node does not own its name or value, it only stores a pointer to it. \r\n        //! It will not delete or otherwise free the pointer on destruction.\r\n        //! It is reponsibility of the user to properly manage lifetime of the string.\r\n        //! The easiest way to achieve it is to use memory_pool of the document to allocate the string -\r\n        //! on destruction of the document the string will be automatically freed.\r\n        //! <br><br>\r\n        //! Size of value must be specified separately, because it does not have to be zero terminated.\r\n        //! Use value(const Ch *) function to have the length automatically calculated (string must be zero terminated).\r\n        //! <br><br>\r\n        //! If an element has a child node of type node_data, it will take precedence over element value when printing.\r\n        //! If you want to manipulate data of elements using values, use parser flag rapidxml::parse_no_data_nodes to prevent creation of data nodes by the parser.\r\n        //! \\param value value of node to set. Does not have to be zero terminated.\r\n        //! \\param size Size of value, in characters. This does not include zero terminator, if one is present.\r\n        void value(const Ch *value, std::size_t size)\r\n        {\r\n            m_value = const_cast<Ch *>(value);\r\n            m_value_size = size;\r\n        }\r\n\r\n        //! Sets value of node to a zero-terminated string.\r\n        //! See also \\ref ownership_of_strings and xml_node::value(const Ch *, std::size_t).\r\n        //! \\param value Vame of node to set. Must be zero terminated.\r\n        void value(const Ch *value)\r\n        {\r\n            this->value(value, internal::measure(value));\r\n        }\r\n\r\n        ///////////////////////////////////////////////////////////////////////////\r\n        // Related nodes access\r\n    \r\n        //! Gets node parent.\r\n        //! \\return Pointer to parent node, or 0 if there is no parent.\r\n        xml_node<Ch> *parent() const\r\n        {\r\n            return m_parent;\r\n        }\r\n\r\n    protected:\r\n\r\n        // Return empty string\r\n        static Ch *nullstr()\r\n        {\r\n            static Ch zero = Ch('\\0');\r\n            return &zero;\r\n        }\r\n\r\n        Ch *m_name;                         // Name of node, or 0 if no name\r\n        Ch *m_value;                        // Value of node, or 0 if no value\r\n        std::size_t m_name_size;            // Length of node name, or undefined of no name\r\n        std::size_t m_value_size;           // Length of node value, or undefined if no value\r\n        xml_node<Ch> *m_parent;             // Pointer to parent node, or 0 if none\r\n\r\n    };\r\n\r\n    //! Class representing attribute node of XML document. \r\n    //! Each attribute has name and value strings, which are available through name() and value() functions (inherited from xml_base).\r\n    //! Note that after parse, both name and value of attribute will point to interior of source text used for parsing. \r\n    //! Thus, this text must persist in memory for the lifetime of attribute.\r\n    //! \\param Ch Character type to use.\r\n    template<class Ch = char>\r\n    class xml_attribute: public xml_base<Ch>\r\n    {\r\n\r\n        friend class xml_node<Ch>;\r\n    \r\n    public:\r\n\r\n        ///////////////////////////////////////////////////////////////////////////\r\n        // Construction & destruction\r\n    \r\n        //! Constructs an empty attribute with the specified type. \r\n        //! Consider using memory_pool of appropriate xml_document if allocating attributes manually.\r\n        xml_attribute()\r\n        {\r\n        }\r\n\r\n        ///////////////////////////////////////////////////////////////////////////\r\n        // Related nodes access\r\n    \r\n        //! Gets document of which attribute is a child.\r\n        //! \\return Pointer to document that contains this attribute, or 0 if there is no parent document.\r\n        xml_document<Ch> *document() const\r\n        {\r\n            if (xml_node<Ch> *node = this->parent())\r\n            {\r\n                while (node->parent())\r\n                    node = node->parent();\r\n                return node->type() == node_document ? static_cast<xml_document<Ch> *>(node) : 0;\r\n            }\r\n            else\r\n                return 0;\r\n        }\r\n\r\n        //! Gets previous attribute, optionally matching attribute name. \r\n        //! \\param name Name of attribute to find, or 0 to return previous attribute regardless of its name; this string doesn't have to be zero-terminated if name_size is non-zero\r\n        //! \\param name_size Size of name, in characters, or 0 to have size calculated automatically from string\r\n        //! \\param case_sensitive Should name comparison be case-sensitive; non case-sensitive comparison works properly only for ASCII characters\r\n        //! \\return Pointer to found attribute, or 0 if not found.\r\n        xml_attribute<Ch> *previous_attribute(const Ch *name = 0, std::size_t name_size = 0, bool case_sensitive = true) const\r\n        {\r\n            if (name)\r\n            {\r\n                if (name_size == 0)\r\n                    name_size = internal::measure(name);\r\n                for (xml_attribute<Ch> *attribute = m_prev_attribute; attribute; attribute = attribute->m_prev_attribute)\r\n                    if (internal::compare(attribute->name(), attribute->name_size(), name, name_size, case_sensitive))\r\n                        return attribute;\r\n                return 0;\r\n            }\r\n            else\r\n                return this->m_parent ? m_prev_attribute : 0;\r\n        }\r\n\r\n        //! Gets next attribute, optionally matching attribute name. \r\n        //! \\param name Name of attribute to find, or 0 to return next attribute regardless of its name; this string doesn't have to be zero-terminated if name_size is non-zero\r\n        //! \\param name_size Size of name, in characters, or 0 to have size calculated automatically from string\r\n        //! \\param case_sensitive Should name comparison be case-sensitive; non case-sensitive comparison works properly only for ASCII characters\r\n        //! \\return Pointer to found attribute, or 0 if not found.\r\n        xml_attribute<Ch> *next_attribute(const Ch *name = 0, std::size_t name_size = 0, bool case_sensitive = true) const\r\n        {\r\n            if (name)\r\n            {\r\n                if (name_size == 0)\r\n                    name_size = internal::measure(name);\r\n                for (xml_attribute<Ch> *attribute = m_next_attribute; attribute; attribute = attribute->m_next_attribute)\r\n                    if (internal::compare(attribute->name(), attribute->name_size(), name, name_size, case_sensitive))\r\n                        return attribute;\r\n                return 0;\r\n            }\r\n            else\r\n                return this->m_parent ? m_next_attribute : 0;\r\n        }\r\n\r\n    private:\r\n\r\n        xml_attribute<Ch> *m_prev_attribute;        // Pointer to previous sibling of attribute, or 0 if none; only valid if parent is non-zero\r\n        xml_attribute<Ch> *m_next_attribute;        // Pointer to next sibling of attribute, or 0 if none; only valid if parent is non-zero\r\n    \r\n    };\r\n\r\n    ///////////////////////////////////////////////////////////////////////////\r\n    // XML node\r\n\r\n    //! Class representing a node of XML document. \r\n    //! Each node may have associated name and value strings, which are available through name() and value() functions. \r\n    //! Interpretation of name and value depends on type of the node.\r\n    //! Type of node can be determined by using type() function.\r\n    //! <br><br>\r\n    //! Note that after parse, both name and value of node, if any, will point interior of source text used for parsing. \r\n    //! Thus, this text must persist in the memory for the lifetime of node.\r\n    //! \\param Ch Character type to use.\r\n    template<class Ch = char>\r\n    class xml_node: public xml_base<Ch>\r\n    {\r\n\r\n    public:\r\n\r\n        ///////////////////////////////////////////////////////////////////////////\r\n        // Construction & destruction\r\n    \r\n        //! Constructs an empty node with the specified type. \r\n        //! Consider using memory_pool of appropriate document to allocate nodes manually.\r\n        //! \\param type Type of node to construct.\r\n        xml_node(node_type type)\r\n            : m_type(type)\r\n            , m_first_node(0)\r\n            , m_first_attribute(0)\r\n        {\r\n        }\r\n\r\n        ///////////////////////////////////////////////////////////////////////////\r\n        // Node data access\r\n    \r\n        //! Gets type of node.\r\n        //! \\return Type of node.\r\n        node_type type() const\r\n        {\r\n            return m_type;\r\n        }\r\n\r\n        ///////////////////////////////////////////////////////////////////////////\r\n        // Related nodes access\r\n    \r\n        //! Gets document of which node is a child.\r\n        //! \\return Pointer to document that contains this node, or 0 if there is no parent document.\r\n        xml_document<Ch> *document() const\r\n        {\r\n            xml_node<Ch> *node = const_cast<xml_node<Ch> *>(this);\r\n            while (node->parent())\r\n                node = node->parent();\r\n            return node->type() == node_document ? static_cast<xml_document<Ch> *>(node) : 0;\r\n        }\r\n\r\n        //! Gets first child node, optionally matching node name.\r\n        //! \\param name Name of child to find, or 0 to return first child regardless of its name; this string doesn't have to be zero-terminated if name_size is non-zero\r\n        //! \\param name_size Size of name, in characters, or 0 to have size calculated automatically from string\r\n        //! \\param case_sensitive Should name comparison be case-sensitive; non case-sensitive comparison works properly only for ASCII characters\r\n        //! \\return Pointer to found child, or 0 if not found.\r\n        xml_node<Ch> *first_node(const Ch *name = 0, std::size_t name_size = 0, bool case_sensitive = true) const\r\n        {\r\n            if (name)\r\n            {\r\n                if (name_size == 0)\r\n                    name_size = internal::measure(name);\r\n                for (xml_node<Ch> *child = m_first_node; child; child = child->next_sibling())\r\n                    if (internal::compare(child->name(), child->name_size(), name, name_size, case_sensitive))\r\n                        return child;\r\n                return 0;\r\n            }\r\n            else\r\n                return m_first_node;\r\n        }\r\n\r\n        //! Gets last child node, optionally matching node name. \r\n        //! Behaviour is undefined if node has no children.\r\n        //! Use first_node() to test if node has children.\r\n        //! \\param name Name of child to find, or 0 to return last child regardless of its name; this string doesn't have to be zero-terminated if name_size is non-zero\r\n        //! \\param name_size Size of name, in characters, or 0 to have size calculated automatically from string\r\n        //! \\param case_sensitive Should name comparison be case-sensitive; non case-sensitive comparison works properly only for ASCII characters\r\n        //! \\return Pointer to found child, or 0 if not found.\r\n        xml_node<Ch> *last_node(const Ch *name = 0, std::size_t name_size = 0, bool case_sensitive = true) const\r\n        {\r\n            assert(m_first_node);  // Cannot query for last child if node has no children\r\n            if (name)\r\n            {\r\n                if (name_size == 0)\r\n                    name_size = internal::measure(name);\r\n                for (xml_node<Ch> *child = m_last_node; child; child = child->previous_sibling())\r\n                    if (internal::compare(child->name(), child->name_size(), name, name_size, case_sensitive))\r\n                        return child;\r\n                return 0;\r\n            }\r\n            else\r\n                return m_last_node;\r\n        }\r\n\r\n        //! Gets previous sibling node, optionally matching node name. \r\n        //! Behaviour is undefined if node has no parent.\r\n        //! Use parent() to test if node has a parent.\r\n        //! \\param name Name of sibling to find, or 0 to return previous sibling regardless of its name; this string doesn't have to be zero-terminated if name_size is non-zero\r\n        //! \\param name_size Size of name, in characters, or 0 to have size calculated automatically from string\r\n        //! \\param case_sensitive Should name comparison be case-sensitive; non case-sensitive comparison works properly only for ASCII characters\r\n        //! \\return Pointer to found sibling, or 0 if not found.\r\n        xml_node<Ch> *previous_sibling(const Ch *name = 0, std::size_t name_size = 0, bool case_sensitive = true) const\r\n        {\r\n            assert(this->m_parent);     // Cannot query for siblings if node has no parent\r\n            if (name)\r\n            {\r\n                if (name_size == 0)\r\n                    name_size = internal::measure(name);\r\n                for (xml_node<Ch> *sibling = m_prev_sibling; sibling; sibling = sibling->m_prev_sibling)\r\n                    if (internal::compare(sibling->name(), sibling->name_size(), name, name_size, case_sensitive))\r\n                        return sibling;\r\n                return 0;\r\n            }\r\n            else\r\n                return m_prev_sibling;\r\n        }\r\n\r\n        //! Gets next sibling node, optionally matching node name. \r\n        //! Behaviour is undefined if node has no parent.\r\n        //! Use parent() to test if node has a parent.\r\n        //! \\param name Name of sibling to find, or 0 to return next sibling regardless of its name; this string doesn't have to be zero-terminated if name_size is non-zero\r\n        //! \\param name_size Size of name, in characters, or 0 to have size calculated automatically from string\r\n        //! \\param case_sensitive Should name comparison be case-sensitive; non case-sensitive comparison works properly only for ASCII characters\r\n        //! \\return Pointer to found sibling, or 0 if not found.\r\n        xml_node<Ch> *next_sibling(const Ch *name = 0, std::size_t name_size = 0, bool case_sensitive = true) const\r\n        {\r\n            assert(this->m_parent);     // Cannot query for siblings if node has no parent\r\n            if (name)\r\n            {\r\n                if (name_size == 0)\r\n                    name_size = internal::measure(name);\r\n                for (xml_node<Ch> *sibling = m_next_sibling; sibling; sibling = sibling->m_next_sibling)\r\n                    if (internal::compare(sibling->name(), sibling->name_size(), name, name_size, case_sensitive))\r\n                        return sibling;\r\n                return 0;\r\n            }\r\n            else\r\n                return m_next_sibling;\r\n        }\r\n\r\n        //! Gets first attribute of node, optionally matching attribute name.\r\n        //! \\param name Name of attribute to find, or 0 to return first attribute regardless of its name; this string doesn't have to be zero-terminated if name_size is non-zero\r\n        //! \\param name_size Size of name, in characters, or 0 to have size calculated automatically from string\r\n        //! \\param case_sensitive Should name comparison be case-sensitive; non case-sensitive comparison works properly only for ASCII characters\r\n        //! \\return Pointer to found attribute, or 0 if not found.\r\n        xml_attribute<Ch> *first_attribute(const Ch *name = 0, std::size_t name_size = 0, bool case_sensitive = true) const\r\n        {\r\n            if (name)\r\n            {\r\n                if (name_size == 0)\r\n                    name_size = internal::measure(name);\r\n                for (xml_attribute<Ch> *attribute = m_first_attribute; attribute; attribute = attribute->m_next_attribute)\r\n                    if (internal::compare(attribute->name(), attribute->name_size(), name, name_size, case_sensitive))\r\n                        return attribute;\r\n                return 0;\r\n            }\r\n            else\r\n                return m_first_attribute;\r\n        }\r\n\r\n        //! Gets last attribute of node, optionally matching attribute name.\r\n        //! \\param name Name of attribute to find, or 0 to return last attribute regardless of its name; this string doesn't have to be zero-terminated if name_size is non-zero\r\n        //! \\param name_size Size of name, in characters, or 0 to have size calculated automatically from string\r\n        //! \\param case_sensitive Should name comparison be case-sensitive; non case-sensitive comparison works properly only for ASCII characters\r\n        //! \\return Pointer to found attribute, or 0 if not found.\r\n        xml_attribute<Ch> *last_attribute(const Ch *name = 0, std::size_t name_size = 0, bool case_sensitive = true) const\r\n        {\r\n            if (name)\r\n            {\r\n                if (name_size == 0)\r\n                    name_size = internal::measure(name);\r\n                for (xml_attribute<Ch> *attribute = m_last_attribute; attribute; attribute = attribute->m_prev_attribute)\r\n                    if (internal::compare(attribute->name(), attribute->name_size(), name, name_size, case_sensitive))\r\n                        return attribute;\r\n                return 0;\r\n            }\r\n            else\r\n                return m_first_attribute ? m_last_attribute : 0;\r\n        }\r\n\r\n        ///////////////////////////////////////////////////////////////////////////\r\n        // Node modification\r\n    \r\n        //! Sets type of node.\r\n        //! \\param type Type of node to set.\r\n        void type(node_type type)\r\n        {\r\n            m_type = type;\r\n        }\r\n\r\n        ///////////////////////////////////////////////////////////////////////////\r\n        // Node manipulation\r\n\r\n        //! Prepends a new child node.\r\n        //! The prepended child becomes the first child, and all existing children are moved one position back.\r\n        //! \\param child Node to prepend.\r\n        void prepend_node(xml_node<Ch> *child)\r\n        {\r\n            assert(child && !child->parent() && child->type() != node_document);\r\n            if (first_node())\r\n            {\r\n                child->m_next_sibling = m_first_node;\r\n                m_first_node->m_prev_sibling = child;\r\n            }\r\n            else\r\n            {\r\n                child->m_next_sibling = 0;\r\n                m_last_node = child;\r\n            }\r\n            m_first_node = child;\r\n            child->m_parent = this;\r\n            child->m_prev_sibling = 0;\r\n        }\r\n\r\n        //! Appends a new child node. \r\n        //! The appended child becomes the last child.\r\n        //! \\param child Node to append.\r\n        void append_node(xml_node<Ch> *child)\r\n        {\r\n            assert(child && !child->parent() && child->type() != node_document);\r\n            if (first_node())\r\n            {\r\n                child->m_prev_sibling = m_last_node;\r\n                m_last_node->m_next_sibling = child;\r\n            }\r\n            else\r\n            {\r\n                child->m_prev_sibling = 0;\r\n                m_first_node = child;\r\n            }\r\n            m_last_node = child;\r\n            child->m_parent = this;\r\n            child->m_next_sibling = 0;\r\n        }\r\n\r\n        //! Inserts a new child node at specified place inside the node. \r\n        //! All children after and including the specified node are moved one position back.\r\n        //! \\param where Place where to insert the child, or 0 to insert at the back.\r\n        //! \\param child Node to insert.\r\n        void insert_node(xml_node<Ch> *where, xml_node<Ch> *child)\r\n        {\r\n            assert(!where || where->parent() == this);\r\n            assert(child && !child->parent() && child->type() != node_document);\r\n            if (where == m_first_node)\r\n                prepend_node(child);\r\n            else if (where == 0)\r\n                append_node(child);\r\n            else\r\n            {\r\n                child->m_prev_sibling = where->m_prev_sibling;\r\n                child->m_next_sibling = where;\r\n                where->m_prev_sibling->m_next_sibling = child;\r\n                where->m_prev_sibling = child;\r\n                child->m_parent = this;\r\n            }\r\n        }\r\n\r\n        //! Removes first child node. \r\n        //! If node has no children, behaviour is undefined.\r\n        //! Use first_node() to test if node has children.\r\n        void remove_first_node()\r\n        {\r\n            assert(first_node());\r\n            xml_node<Ch> *child = m_first_node;\r\n            m_first_node = child->m_next_sibling;\r\n            if (child->m_next_sibling)\r\n                child->m_next_sibling->m_prev_sibling = 0;\r\n            else\r\n                m_last_node = 0;\r\n            child->m_parent = 0;\r\n        }\r\n\r\n        //! Removes last child of the node. \r\n        //! If node has no children, behaviour is undefined.\r\n        //! Use first_node() to test if node has children.\r\n        void remove_last_node()\r\n        {\r\n            assert(first_node());\r\n            xml_node<Ch> *child = m_last_node;\r\n            if (child->m_prev_sibling)\r\n            {\r\n                m_last_node = child->m_prev_sibling;\r\n                child->m_prev_sibling->m_next_sibling = 0;\r\n            }\r\n            else\r\n                m_first_node = 0;\r\n            child->m_parent = 0;\r\n        }\r\n\r\n        //! Removes specified child from the node\r\n        // \\param where Pointer to child to be removed.\r\n        void remove_node(xml_node<Ch> *where)\r\n        {\r\n            assert(where && where->parent() == this);\r\n            assert(first_node());\r\n            if (where == m_first_node)\r\n                remove_first_node();\r\n            else if (where == m_last_node)\r\n                remove_last_node();\r\n            else\r\n            {\r\n                where->m_prev_sibling->m_next_sibling = where->m_next_sibling;\r\n                where->m_next_sibling->m_prev_sibling = where->m_prev_sibling;\r\n                where->m_parent = 0;\r\n            }\r\n        }\r\n\r\n        //! Removes all child nodes (but not attributes).\r\n        void remove_all_nodes()\r\n        {\r\n            for (xml_node<Ch> *node = first_node(); node; node = node->m_next_sibling)\r\n                node->m_parent = 0;\r\n            m_first_node = 0;\r\n        }\r\n\r\n        //! Prepends a new attribute to the node.\r\n        //! \\param attribute Attribute to prepend.\r\n        void prepend_attribute(xml_attribute<Ch> *attribute)\r\n        {\r\n            assert(attribute && !attribute->parent());\r\n            if (first_attribute())\r\n            {\r\n                attribute->m_next_attribute = m_first_attribute;\r\n                m_first_attribute->m_prev_attribute = attribute;\r\n            }\r\n            else\r\n            {\r\n                attribute->m_next_attribute = 0;\r\n                m_last_attribute = attribute;\r\n            }\r\n            m_first_attribute = attribute;\r\n            attribute->m_parent = this;\r\n            attribute->m_prev_attribute = 0;\r\n        }\r\n\r\n        //! Appends a new attribute to the node.\r\n        //! \\param attribute Attribute to append.\r\n        void append_attribute(xml_attribute<Ch> *attribute)\r\n        {\r\n            assert(attribute && !attribute->parent());\r\n            if (first_attribute())\r\n            {\r\n                attribute->m_prev_attribute = m_last_attribute;\r\n                m_last_attribute->m_next_attribute = attribute;\r\n            }\r\n            else\r\n            {\r\n                attribute->m_prev_attribute = 0;\r\n                m_first_attribute = attribute;\r\n            }\r\n            m_last_attribute = attribute;\r\n            attribute->m_parent = this;\r\n            attribute->m_next_attribute = 0;\r\n        }\r\n\r\n        //! Inserts a new attribute at specified place inside the node. \r\n        //! All attributes after and including the specified attribute are moved one position back.\r\n        //! \\param where Place where to insert the attribute, or 0 to insert at the back.\r\n        //! \\param attribute Attribute to insert.\r\n        void insert_attribute(xml_attribute<Ch> *where, xml_attribute<Ch> *attribute)\r\n        {\r\n            assert(!where || where->parent() == this);\r\n            assert(attribute && !attribute->parent());\r\n            if (where == m_first_attribute)\r\n                prepend_attribute(attribute);\r\n            else if (where == 0)\r\n                append_attribute(attribute);\r\n            else\r\n            {\r\n                attribute->m_prev_attribute = where->m_prev_attribute;\r\n                attribute->m_next_attribute = where;\r\n                where->m_prev_attribute->m_next_attribute = attribute;\r\n                where->m_prev_attribute = attribute;\r\n                attribute->m_parent = this;\r\n            }\r\n        }\r\n\r\n        //! Removes first attribute of the node. \r\n        //! If node has no attributes, behaviour is undefined.\r\n        //! Use first_attribute() to test if node has attributes.\r\n        void remove_first_attribute()\r\n        {\r\n            assert(first_attribute());\r\n            xml_attribute<Ch> *attribute = m_first_attribute;\r\n            if (attribute->m_next_attribute)\r\n            {\r\n                attribute->m_next_attribute->m_prev_attribute = 0;\r\n            }\r\n            else\r\n                m_last_attribute = 0;\r\n            attribute->m_parent = 0;\r\n            m_first_attribute = attribute->m_next_attribute;\r\n        }\r\n\r\n        //! Removes last attribute of the node. \r\n        //! If node has no attributes, behaviour is undefined.\r\n        //! Use first_attribute() to test if node has attributes.\r\n        void remove_last_attribute()\r\n        {\r\n            assert(first_attribute());\r\n            xml_attribute<Ch> *attribute = m_last_attribute;\r\n            if (attribute->m_prev_attribute)\r\n            {\r\n                attribute->m_prev_attribute->m_next_attribute = 0;\r\n                m_last_attribute = attribute->m_prev_attribute;\r\n            }\r\n            else\r\n                m_first_attribute = 0;\r\n            attribute->m_parent = 0;\r\n        }\r\n\r\n        //! Removes specified attribute from node.\r\n        //! \\param where Pointer to attribute to be removed.\r\n        void remove_attribute(xml_attribute<Ch> *where)\r\n        {\r\n            assert(first_attribute() && where->parent() == this);\r\n            if (where == m_first_attribute)\r\n                remove_first_attribute();\r\n            else if (where == m_last_attribute)\r\n                remove_last_attribute();\r\n            else\r\n            {\r\n                where->m_prev_attribute->m_next_attribute = where->m_next_attribute;\r\n                where->m_next_attribute->m_prev_attribute = where->m_prev_attribute;\r\n                where->m_parent = 0;\r\n            }\r\n        }\r\n\r\n        //! Removes all attributes of node.\r\n        void remove_all_attributes()\r\n        {\r\n            for (xml_attribute<Ch> *attribute = first_attribute(); attribute; attribute = attribute->m_next_attribute)\r\n                attribute->m_parent = 0;\r\n            m_first_attribute = 0;\r\n        }\r\n        \r\n    private:\r\n\r\n        ///////////////////////////////////////////////////////////////////////////\r\n        // Restrictions\r\n\r\n        // No copying\r\n        xml_node(const xml_node &);\r\n        void operator =(const xml_node &);\r\n    \r\n        ///////////////////////////////////////////////////////////////////////////\r\n        // Data members\r\n    \r\n        // Note that some of the pointers below have UNDEFINED values if certain other pointers are 0.\r\n        // This is required for maximum performance, as it allows the parser to omit initialization of \r\n        // unneded/redundant values.\r\n        //\r\n        // The rules are as follows:\r\n        // 1. first_node and first_attribute contain valid pointers, or 0 if node has no children/attributes respectively\r\n        // 2. last_node and last_attribute are valid only if node has at least one child/attribute respectively, otherwise they contain garbage\r\n        // 3. prev_sibling and next_sibling are valid only if node has a parent, otherwise they contain garbage\r\n\r\n        node_type m_type;                       // Type of node; always valid\r\n        xml_node<Ch> *m_first_node;             // Pointer to first child node, or 0 if none; always valid\r\n        xml_node<Ch> *m_last_node;              // Pointer to last child node, or 0 if none; this value is only valid if m_first_node is non-zero\r\n        xml_attribute<Ch> *m_first_attribute;   // Pointer to first attribute of node, or 0 if none; always valid\r\n        xml_attribute<Ch> *m_last_attribute;    // Pointer to last attribute of node, or 0 if none; this value is only valid if m_first_attribute is non-zero\r\n        xml_node<Ch> *m_prev_sibling;           // Pointer to previous sibling of node, or 0 if none; this value is only valid if m_parent is non-zero\r\n        xml_node<Ch> *m_next_sibling;           // Pointer to next sibling of node, or 0 if none; this value is only valid if m_parent is non-zero\r\n\r\n    };\r\n\r\n    ///////////////////////////////////////////////////////////////////////////\r\n    // XML document\r\n    \r\n    //! This class represents root of the DOM hierarchy. \r\n    //! It is also an xml_node and a memory_pool through public inheritance.\r\n    //! Use parse() function to build a DOM tree from a zero-terminated XML text string.\r\n    //! parse() function allocates memory for nodes and attributes by using functions of xml_document, \r\n    //! which are inherited from memory_pool.\r\n    //! To access root node of the document, use the document itself, as if it was an xml_node.\r\n    //! \\param Ch Character type to use.\r\n    template<class Ch = char>\r\n    class xml_document: public xml_node<Ch>, public memory_pool<Ch>\r\n    {\r\n    \r\n    public:\r\n\r\n        //! Constructs empty XML document\r\n        xml_document()\r\n            : xml_node<Ch>(node_document)\r\n        {\r\n        }\r\n\r\n        //! Parses zero-terminated XML string according to given flags.\r\n        //! Passed string will be modified by the parser, unless rapidxml::parse_non_destructive flag is used.\r\n        //! The string must persist for the lifetime of the document.\r\n        //! In case of error, rapidxml::parse_error exception will be thrown.\r\n        //! <br><br>\r\n        //! If you want to parse contents of a file, you must first load the file into the memory, and pass pointer to its beginning.\r\n        //! Make sure that data is zero-terminated.\r\n        //! <br><br>\r\n        //! Document can be parsed into multiple times. \r\n        //! Each new call to parse removes previous nodes and attributes (if any), but does not clear memory pool.\r\n        //! \\param text XML data to parse; pointer is non-const to denote fact that this data may be modified by the parser.\r\n        template<int Flags>\r\n        void parse(Ch *text)\r\n        {\r\n            assert(text);\r\n            \r\n            // Remove current contents\r\n            this->remove_all_nodes();\r\n            this->remove_all_attributes();\r\n            \r\n            // Parse BOM, if any\r\n            parse_bom<Flags>(text);\r\n            \r\n            // Parse children\r\n            while (1)\r\n            {\r\n                // Skip whitespace before node\r\n                skip<whitespace_pred, Flags>(text);\r\n                if (*text == 0)\r\n                    break;\r\n\r\n                // Parse and append new child\r\n                if (*text == Ch('<'))\r\n                {\r\n                    ++text;     // Skip '<'\r\n                    if (xml_node<Ch> *node = parse_node<Flags>(text))\r\n                        this->append_node(node);\r\n                }\r\n                else\r\n                    RAPIDXML_PARSE_ERROR(\"expected <\", text);\r\n            }\r\n\r\n        }\r\n\r\n        //! Clears the document by deleting all nodes and clearing the memory pool.\r\n        //! All nodes owned by document pool are destroyed.\r\n        void clear()\r\n        {\r\n            this->remove_all_nodes();\r\n            this->remove_all_attributes();\r\n            memory_pool<Ch>::clear();\r\n        }\r\n        \r\n    private:\r\n\r\n        ///////////////////////////////////////////////////////////////////////\r\n        // Internal character utility functions\r\n        \r\n        // Detect whitespace character\r\n        struct whitespace_pred\r\n        {\r\n            static unsigned char test(Ch ch)\r\n            {\r\n                return internal::lookup_tables<0>::lookup_whitespace[static_cast<unsigned char>(ch)];\r\n            }\r\n        };\r\n\r\n        // Detect node name character\r\n        struct node_name_pred\r\n        {\r\n            static unsigned char test(Ch ch)\r\n            {\r\n                return internal::lookup_tables<0>::lookup_node_name[static_cast<unsigned char>(ch)];\r\n            }\r\n        };\r\n\r\n        // Detect attribute name character\r\n        struct attribute_name_pred\r\n        {\r\n            static unsigned char test(Ch ch)\r\n            {\r\n                return internal::lookup_tables<0>::lookup_attribute_name[static_cast<unsigned char>(ch)];\r\n            }\r\n        };\r\n\r\n        // Detect text character (PCDATA)\r\n        struct text_pred\r\n        {\r\n            static unsigned char test(Ch ch)\r\n            {\r\n                return internal::lookup_tables<0>::lookup_text[static_cast<unsigned char>(ch)];\r\n            }\r\n        };\r\n\r\n        // Detect text character (PCDATA) that does not require processing\r\n        struct text_pure_no_ws_pred\r\n        {\r\n            static unsigned char test(Ch ch)\r\n            {\r\n                return internal::lookup_tables<0>::lookup_text_pure_no_ws[static_cast<unsigned char>(ch)];\r\n            }\r\n        };\r\n\r\n        // Detect text character (PCDATA) that does not require processing\r\n        struct text_pure_with_ws_pred\r\n        {\r\n            static unsigned char test(Ch ch)\r\n            {\r\n                return internal::lookup_tables<0>::lookup_text_pure_with_ws[static_cast<unsigned char>(ch)];\r\n            }\r\n        };\r\n\r\n        // Detect attribute value character\r\n        template<Ch Quote>\r\n        struct attribute_value_pred\r\n        {\r\n            static unsigned char test(Ch ch)\r\n            {\r\n                if (Quote == Ch('\\''))\r\n                    return internal::lookup_tables<0>::lookup_attribute_data_1[static_cast<unsigned char>(ch)];\r\n                if (Quote == Ch('\\\"'))\r\n                    return internal::lookup_tables<0>::lookup_attribute_data_2[static_cast<unsigned char>(ch)];\r\n                return 0;       // Should never be executed, to avoid warnings on Comeau\r\n            }\r\n        };\r\n\r\n        // Detect attribute value character\r\n        template<Ch Quote>\r\n        struct attribute_value_pure_pred\r\n        {\r\n            static unsigned char test(Ch ch)\r\n            {\r\n                if (Quote == Ch('\\''))\r\n                    return internal::lookup_tables<0>::lookup_attribute_data_1_pure[static_cast<unsigned char>(ch)];\r\n                if (Quote == Ch('\\\"'))\r\n                    return internal::lookup_tables<0>::lookup_attribute_data_2_pure[static_cast<unsigned char>(ch)];\r\n                return 0;       // Should never be executed, to avoid warnings on Comeau\r\n            }\r\n        };\r\n\r\n        // Insert coded character, using UTF8 or 8-bit ASCII\r\n        template<int Flags>\r\n        static void insert_coded_character(Ch *&text, unsigned long code)\r\n        {\r\n            if (Flags & parse_no_utf8)\r\n            {\r\n                // Insert 8-bit ASCII character\r\n                // Todo: possibly verify that code is less than 256 and use replacement char otherwise?\r\n                text[0] = static_cast<unsigned char>(code);\r\n                text += 1;\r\n            }\r\n            else\r\n            {\r\n                // Insert UTF8 sequence\r\n                if (code < 0x80)    // 1 byte sequence\r\n                {\r\n\t                text[0] = static_cast<unsigned char>(code);\r\n                    text += 1;\r\n                }\r\n                else if (code < 0x800)  // 2 byte sequence\r\n                {\r\n\t                text[1] = static_cast<unsigned char>((code | 0x80) & 0xBF); code >>= 6;\r\n\t                text[0] = static_cast<unsigned char>(code | 0xC0);\r\n                    text += 2;\r\n                }\r\n\t            else if (code < 0x10000)    // 3 byte sequence\r\n                {\r\n\t                text[2] = static_cast<unsigned char>((code | 0x80) & 0xBF); code >>= 6;\r\n\t                text[1] = static_cast<unsigned char>((code | 0x80) & 0xBF); code >>= 6;\r\n\t                text[0] = static_cast<unsigned char>(code | 0xE0);\r\n                    text += 3;\r\n                }\r\n\t            else if (code < 0x110000)   // 4 byte sequence\r\n                {\r\n\t                text[3] = static_cast<unsigned char>((code | 0x80) & 0xBF); code >>= 6;\r\n\t                text[2] = static_cast<unsigned char>((code | 0x80) & 0xBF); code >>= 6;\r\n\t                text[1] = static_cast<unsigned char>((code | 0x80) & 0xBF); code >>= 6;\r\n\t                text[0] = static_cast<unsigned char>(code | 0xF0);\r\n                    text += 4;\r\n                }\r\n                else    // Invalid, only codes up to 0x10FFFF are allowed in Unicode\r\n                {\r\n                    RAPIDXML_PARSE_ERROR(\"invalid numeric character entity\", text);\r\n                }\r\n            }\r\n        }\r\n\r\n        // Skip characters until predicate evaluates to true\r\n        template<class StopPred, int Flags>\r\n        static void skip(Ch *&text)\r\n        {\r\n            Ch *tmp = text;\r\n            while (StopPred::test(*tmp))\r\n                ++tmp;\r\n            text = tmp;\r\n        }\r\n\r\n        // Skip characters until predicate evaluates to true while doing the following:\r\n        // - replacing XML character entity references with proper characters (&apos; &amp; &quot; &lt; &gt; &#...;)\r\n        // - condensing whitespace sequences to single space character\r\n        template<class StopPred, class StopPredPure, int Flags>\r\n        static Ch *skip_and_expand_character_refs(Ch *&text)\r\n        {\r\n            // If entity translation, whitespace condense and whitespace trimming is disabled, use plain skip\r\n            if (Flags & parse_no_entity_translation && \r\n                !(Flags & parse_normalize_whitespace) &&\r\n                !(Flags & parse_trim_whitespace))\r\n            {\r\n                skip<StopPred, Flags>(text);\r\n                return text;\r\n            }\r\n            \r\n            // Use simple skip until first modification is detected\r\n            skip<StopPredPure, Flags>(text);\r\n\r\n            // Use translation skip\r\n            Ch *src = text;\r\n            Ch *dest = src;\r\n            while (StopPred::test(*src))\r\n            {\r\n                // If entity translation is enabled    \r\n                if (!(Flags & parse_no_entity_translation))\r\n                {\r\n                    // Test if replacement is needed\r\n                    if (src[0] == Ch('&'))\r\n                    {\r\n                        switch (src[1])\r\n                        {\r\n\r\n                        // &amp; &apos;\r\n                        case Ch('a'): \r\n                            if (src[2] == Ch('m') && src[3] == Ch('p') && src[4] == Ch(';'))\r\n                            {\r\n                                *dest = Ch('&');\r\n                                ++dest;\r\n                                src += 5;\r\n                                continue;\r\n                            }\r\n                            if (src[2] == Ch('p') && src[3] == Ch('o') && src[4] == Ch('s') && src[5] == Ch(';'))\r\n                            {\r\n                                *dest = Ch('\\'');\r\n                                ++dest;\r\n                                src += 6;\r\n                                continue;\r\n                            }\r\n                            break;\r\n\r\n                        // &quot;\r\n                        case Ch('q'): \r\n                            if (src[2] == Ch('u') && src[3] == Ch('o') && src[4] == Ch('t') && src[5] == Ch(';'))\r\n                            {\r\n                                *dest = Ch('\"');\r\n                                ++dest;\r\n                                src += 6;\r\n                                continue;\r\n                            }\r\n                            break;\r\n\r\n                        // &gt;\r\n                        case Ch('g'): \r\n                            if (src[2] == Ch('t') && src[3] == Ch(';'))\r\n                            {\r\n                                *dest = Ch('>');\r\n                                ++dest;\r\n                                src += 4;\r\n                                continue;\r\n                            }\r\n                            break;\r\n\r\n                        // &lt;\r\n                        case Ch('l'): \r\n                            if (src[2] == Ch('t') && src[3] == Ch(';'))\r\n                            {\r\n                                *dest = Ch('<');\r\n                                ++dest;\r\n                                src += 4;\r\n                                continue;\r\n                            }\r\n                            break;\r\n\r\n                        // &#...; - assumes ASCII\r\n                        case Ch('#'): \r\n                            if (src[2] == Ch('x'))\r\n                            {\r\n                                unsigned long code = 0;\r\n                                src += 3;   // Skip &#x\r\n                                while (1)\r\n                                {\r\n                                    unsigned char digit = internal::lookup_tables<0>::lookup_digits[static_cast<unsigned char>(*src)];\r\n                                    if (digit == 0xFF)\r\n                                        break;\r\n                                    code = code * 16 + digit;\r\n                                    ++src;\r\n                                }\r\n                                insert_coded_character<Flags>(dest, code);    // Put character in output\r\n                            }\r\n                            else\r\n                            {\r\n                                unsigned long code = 0;\r\n                                src += 2;   // Skip &#\r\n                                while (1)\r\n                                {\r\n                                    unsigned char digit = internal::lookup_tables<0>::lookup_digits[static_cast<unsigned char>(*src)];\r\n                                    if (digit == 0xFF)\r\n                                        break;\r\n                                    code = code * 10 + digit;\r\n                                    ++src;\r\n                                }\r\n                                insert_coded_character<Flags>(dest, code);    // Put character in output\r\n                            }\r\n                            if (*src == Ch(';'))\r\n                                ++src;\r\n                            else\r\n                                RAPIDXML_PARSE_ERROR(\"expected ;\", src);\r\n                            continue;\r\n\r\n                        // Something else\r\n                        default:\r\n                            // Ignore, just copy '&' verbatim\r\n                            break;\r\n\r\n                        }\r\n                    }\r\n                }\r\n                \r\n                // If whitespace condensing is enabled\r\n                if (Flags & parse_normalize_whitespace)\r\n                {\r\n                    // Test if condensing is needed                 \r\n                    if (whitespace_pred::test(*src))\r\n                    {\r\n                        *dest = Ch(' '); ++dest;    // Put single space in dest\r\n                        ++src;                      // Skip first whitespace char\r\n                        // Skip remaining whitespace chars\r\n                        while (whitespace_pred::test(*src))\r\n                            ++src;\r\n                        continue;\r\n                    }\r\n                }\r\n\r\n                // No replacement, only copy character\r\n                *dest++ = *src++;\r\n\r\n            }\r\n\r\n            // Return new end\r\n            text = src;\r\n            return dest;\r\n\r\n        }\r\n\r\n        ///////////////////////////////////////////////////////////////////////\r\n        // Internal parsing functions\r\n        \r\n        // Parse BOM, if any\r\n        template<int Flags>\r\n        void parse_bom(Ch *&text)\r\n        {\r\n            // UTF-8?\r\n            if (static_cast<unsigned char>(text[0]) == 0xEF && \r\n                static_cast<unsigned char>(text[1]) == 0xBB && \r\n                static_cast<unsigned char>(text[2]) == 0xBF)\r\n            {\r\n                text += 3;      // Skup utf-8 bom\r\n            }\r\n        }\r\n\r\n        // Parse XML declaration (<?xml...)\r\n        template<int Flags>\r\n        xml_node<Ch> *parse_xml_declaration(Ch *&text)\r\n        {\r\n            // If parsing of declaration is disabled\r\n            if (!(Flags & parse_declaration_node))\r\n            {\r\n                // Skip until end of declaration\r\n                while (text[0] != Ch('?') || text[1] != Ch('>'))\r\n                {\r\n                    if (!text[0])\r\n                        RAPIDXML_PARSE_ERROR(\"unexpected end of data\", text);\r\n                    ++text;\r\n                }\r\n                text += 2;    // Skip '?>'\r\n                return 0;\r\n            }\r\n\r\n            // Create declaration\r\n            xml_node<Ch> *declaration = this->allocate_node(node_declaration);\r\n\r\n            // Skip whitespace before attributes or ?>\r\n            skip<whitespace_pred, Flags>(text);\r\n\r\n            // Parse declaration attributes\r\n            parse_node_attributes<Flags>(text, declaration);\r\n            \r\n            // Skip ?>\r\n            if (text[0] != Ch('?') || text[1] != Ch('>'))\r\n                RAPIDXML_PARSE_ERROR(\"expected ?>\", text);\r\n            text += 2;\r\n            \r\n            return declaration;\r\n        }\r\n\r\n        // Parse XML comment (<!--...)\r\n        template<int Flags>\r\n        xml_node<Ch> *parse_comment(Ch *&text)\r\n        {\r\n            // If parsing of comments is disabled\r\n            if (!(Flags & parse_comment_nodes))\r\n            {\r\n                // Skip until end of comment\r\n                while (text[0] != Ch('-') || text[1] != Ch('-') || text[2] != Ch('>'))\r\n                {\r\n                    if (!text[0])\r\n                        RAPIDXML_PARSE_ERROR(\"unexpected end of data\", text);\r\n                    ++text;\r\n                }\r\n                text += 3;     // Skip '-->'\r\n                return 0;      // Do not produce comment node\r\n            }\r\n\r\n            // Remember value start\r\n            Ch *value = text;\r\n\r\n            // Skip until end of comment\r\n            while (text[0] != Ch('-') || text[1] != Ch('-') || text[2] != Ch('>'))\r\n            {\r\n                if (!text[0])\r\n                    RAPIDXML_PARSE_ERROR(\"unexpected end of data\", text);\r\n                ++text;\r\n            }\r\n\r\n            // Create comment node\r\n            xml_node<Ch> *comment = this->allocate_node(node_comment);\r\n            comment->value(value, text - value);\r\n            \r\n            // Place zero terminator after comment value\r\n            if (!(Flags & parse_no_string_terminators))\r\n                *text = Ch('\\0');\r\n            \r\n            text += 3;     // Skip '-->'\r\n            return comment;\r\n        }\r\n\r\n        // Parse DOCTYPE\r\n        template<int Flags>\r\n        xml_node<Ch> *parse_doctype(Ch *&text)\r\n        {\r\n            // Remember value start\r\n            Ch *value = text;\r\n\r\n            // Skip to >\r\n            while (*text != Ch('>'))\r\n            {\r\n                // Determine character type\r\n                switch (*text)\r\n                {\r\n                \r\n                // If '[' encountered, scan for matching ending ']' using naive algorithm with depth\r\n                // This works for all W3C test files except for 2 most wicked\r\n                case Ch('['):\r\n                {\r\n                    ++text;     // Skip '['\r\n                    int depth = 1;\r\n                    while (depth > 0)\r\n                    {\r\n                        switch (*text)\r\n                        {\r\n                            case Ch('['): ++depth; break;\r\n                            case Ch(']'): --depth; break;\r\n                            case 0: RAPIDXML_PARSE_ERROR(\"unexpected end of data\", text);\r\n                        }\r\n                        ++text;\r\n                    }\r\n                    break;\r\n                }\r\n                \r\n                // Error on end of text\r\n                case Ch('\\0'):\r\n                    RAPIDXML_PARSE_ERROR(\"unexpected end of data\", text);\r\n                \r\n                // Other character, skip it\r\n                default:\r\n                    ++text;\r\n\r\n                }\r\n            }\r\n            \r\n            // If DOCTYPE nodes enabled\r\n            if (Flags & parse_doctype_node)\r\n            {\r\n                // Create a new doctype node\r\n                xml_node<Ch> *doctype = this->allocate_node(node_doctype);\r\n                doctype->value(value, text - value);\r\n                \r\n                // Place zero terminator after value\r\n                if (!(Flags & parse_no_string_terminators))\r\n                    *text = Ch('\\0');\r\n\r\n                text += 1;      // skip '>'\r\n                return doctype;\r\n            }\r\n            else\r\n            {\r\n                text += 1;      // skip '>'\r\n                return 0;\r\n            }\r\n\r\n        }\r\n\r\n        // Parse PI\r\n        template<int Flags>\r\n        xml_node<Ch> *parse_pi(Ch *&text)\r\n        {\r\n            // If creation of PI nodes is enabled\r\n            if (Flags & parse_pi_nodes)\r\n            {\r\n                // Create pi node\r\n                xml_node<Ch> *pi = this->allocate_node(node_pi);\r\n\r\n                // Extract PI target name\r\n                Ch *name = text;\r\n                skip<node_name_pred, Flags>(text);\r\n                if (text == name)\r\n                    RAPIDXML_PARSE_ERROR(\"expected PI target\", text);\r\n                pi->name(name, text - name);\r\n                \r\n                // Skip whitespace between pi target and pi\r\n                skip<whitespace_pred, Flags>(text);\r\n\r\n                // Remember start of pi\r\n                Ch *value = text;\r\n                \r\n                // Skip to '?>'\r\n                while (text[0] != Ch('?') || text[1] != Ch('>'))\r\n                {\r\n                    if (*text == Ch('\\0'))\r\n                        RAPIDXML_PARSE_ERROR(\"unexpected end of data\", text);\r\n                    ++text;\r\n                }\r\n\r\n                // Set pi value (verbatim, no entity expansion or whitespace normalization)\r\n                pi->value(value, text - value);     \r\n                \r\n                // Place zero terminator after name and value\r\n                if (!(Flags & parse_no_string_terminators))\r\n                {\r\n                    pi->name()[pi->name_size()] = Ch('\\0');\r\n                    pi->value()[pi->value_size()] = Ch('\\0');\r\n                }\r\n                \r\n                text += 2;                          // Skip '?>'\r\n                return pi;\r\n            }\r\n            else\r\n            {\r\n                // Skip to '?>'\r\n                while (text[0] != Ch('?') || text[1] != Ch('>'))\r\n                {\r\n                    if (*text == Ch('\\0'))\r\n                        RAPIDXML_PARSE_ERROR(\"unexpected end of data\", text);\r\n                    ++text;\r\n                }\r\n                text += 2;    // Skip '?>'\r\n                return 0;\r\n            }\r\n        }\r\n\r\n        // Parse and append data\r\n        // Return character that ends data.\r\n        // This is necessary because this character might have been overwritten by a terminating 0\r\n        template<int Flags>\r\n        Ch parse_and_append_data(xml_node<Ch> *node, Ch *&text, Ch *contents_start)\r\n        {\r\n            // Backup to contents start if whitespace trimming is disabled\r\n            if (!(Flags & parse_trim_whitespace))\r\n                text = contents_start;     \r\n            \r\n            // Skip until end of data\r\n            Ch *value = text, *end;\r\n            if (Flags & parse_normalize_whitespace)\r\n                end = skip_and_expand_character_refs<text_pred, text_pure_with_ws_pred, Flags>(text);   \r\n            else\r\n                end = skip_and_expand_character_refs<text_pred, text_pure_no_ws_pred, Flags>(text);\r\n\r\n            // Trim trailing whitespace if flag is set; leading was already trimmed by whitespace skip after >\r\n            if (Flags & parse_trim_whitespace)\r\n            {\r\n                if (Flags & parse_normalize_whitespace)\r\n                {\r\n                    // Whitespace is already condensed to single space characters by skipping function, so just trim 1 char off the end\r\n                    if (*(end - 1) == Ch(' '))\r\n                        --end;\r\n                }\r\n                else\r\n                {\r\n                    // Backup until non-whitespace character is found\r\n                    while (whitespace_pred::test(*(end - 1)))\r\n                        --end;\r\n                }\r\n            }\r\n            \r\n            // If characters are still left between end and value (this test is only necessary if normalization is enabled)\r\n            // Create new data node\r\n            if (!(Flags & parse_no_data_nodes))\r\n            {\r\n                xml_node<Ch> *data = this->allocate_node(node_data);\r\n                data->value(value, end - value);\r\n                node->append_node(data);\r\n            }\r\n\r\n            // Add data to parent node if no data exists yet\r\n            if (!(Flags & parse_no_element_values)) \r\n                if (*node->value() == Ch('\\0'))\r\n                    node->value(value, end - value);\r\n\r\n            // Place zero terminator after value\r\n            if (!(Flags & parse_no_string_terminators))\r\n            {\r\n                Ch ch = *text;\r\n                *end = Ch('\\0');\r\n                return ch;      // Return character that ends data; this is required because zero terminator overwritten it\r\n            }\r\n\r\n            // Return character that ends data\r\n            return *text;\r\n        }\r\n\r\n        // Parse CDATA\r\n        template<int Flags>\r\n        xml_node<Ch> *parse_cdata(Ch *&text)\r\n        {\r\n            // If CDATA is disabled\r\n            if (Flags & parse_no_data_nodes)\r\n            {\r\n                // Skip until end of cdata\r\n                while (text[0] != Ch(']') || text[1] != Ch(']') || text[2] != Ch('>'))\r\n                {\r\n                    if (!text[0])\r\n                        RAPIDXML_PARSE_ERROR(\"unexpected end of data\", text);\r\n                    ++text;\r\n                }\r\n                text += 3;      // Skip ]]>\r\n                return 0;       // Do not produce CDATA node\r\n            }\r\n\r\n            // Skip until end of cdata\r\n            Ch *value = text;\r\n            while (text[0] != Ch(']') || text[1] != Ch(']') || text[2] != Ch('>'))\r\n            {\r\n                if (!text[0])\r\n                    RAPIDXML_PARSE_ERROR(\"unexpected end of data\", text);\r\n                ++text;\r\n            }\r\n\r\n            // Create new cdata node\r\n            xml_node<Ch> *cdata = this->allocate_node(node_cdata);\r\n            cdata->value(value, text - value);\r\n\r\n            // Place zero terminator after value\r\n            if (!(Flags & parse_no_string_terminators))\r\n                *text = Ch('\\0');\r\n\r\n            text += 3;      // Skip ]]>\r\n            return cdata;\r\n        }\r\n        \r\n        // Parse element node\r\n        template<int Flags>\r\n        xml_node<Ch> *parse_element(Ch *&text)\r\n        {\r\n            // Create element node\r\n            xml_node<Ch> *element = this->allocate_node(node_element);\r\n\r\n            // Extract element name\r\n            Ch *name = text;\r\n            skip<node_name_pred, Flags>(text);\r\n            if (text == name)\r\n                RAPIDXML_PARSE_ERROR(\"expected element name\", text);\r\n            element->name(name, text - name);\r\n            \r\n            // Skip whitespace between element name and attributes or >\r\n            skip<whitespace_pred, Flags>(text);\r\n\r\n            // Parse attributes, if any\r\n            parse_node_attributes<Flags>(text, element);\r\n\r\n            // Determine ending type\r\n            if (*text == Ch('>'))\r\n            {\r\n                ++text;\r\n                parse_node_contents<Flags>(text, element);\r\n            }\r\n            else if (*text == Ch('/'))\r\n            {\r\n                ++text;\r\n                if (*text != Ch('>'))\r\n                    RAPIDXML_PARSE_ERROR(\"expected >\", text);\r\n                ++text;\r\n            }\r\n            else\r\n                RAPIDXML_PARSE_ERROR(\"expected >\", text);\r\n\r\n            // Place zero terminator after name\r\n            if (!(Flags & parse_no_string_terminators))\r\n                element->name()[element->name_size()] = Ch('\\0');\r\n\r\n            // Return parsed element\r\n            return element;\r\n        }\r\n\r\n        // Determine node type, and parse it\r\n        template<int Flags>\r\n        xml_node<Ch> *parse_node(Ch *&text)\r\n        {\r\n            // Parse proper node type\r\n            switch (text[0])\r\n            {\r\n\r\n            // <...\r\n            default: \r\n                // Parse and append element node\r\n                return parse_element<Flags>(text);\r\n\r\n            // <?...\r\n            case Ch('?'): \r\n                ++text;     // Skip ?\r\n                if ((text[0] == Ch('x') || text[0] == Ch('X')) &&\r\n                    (text[1] == Ch('m') || text[1] == Ch('M')) && \r\n                    (text[2] == Ch('l') || text[2] == Ch('L')) &&\r\n                    whitespace_pred::test(text[3]))\r\n                {\r\n                    // '<?xml ' - xml declaration\r\n                    text += 4;      // Skip 'xml '\r\n                    return parse_xml_declaration<Flags>(text);\r\n                }\r\n                else\r\n                {\r\n                    // Parse PI\r\n                    return parse_pi<Flags>(text);\r\n                }\r\n            \r\n            // <!...\r\n            case Ch('!'): \r\n\r\n                // Parse proper subset of <! node\r\n                switch (text[1])    \r\n                {\r\n                \r\n                // <!-\r\n                case Ch('-'):\r\n                    if (text[2] == Ch('-'))\r\n                    {\r\n                        // '<!--' - xml comment\r\n                        text += 3;     // Skip '!--'\r\n                        return parse_comment<Flags>(text);\r\n                    }\r\n                    break;\r\n\r\n                // <![\r\n                case Ch('['):\r\n                    if (text[2] == Ch('C') && text[3] == Ch('D') && text[4] == Ch('A') && \r\n                        text[5] == Ch('T') && text[6] == Ch('A') && text[7] == Ch('['))\r\n                    {\r\n                        // '<![CDATA[' - cdata\r\n                        text += 8;     // Skip '![CDATA['\r\n                        return parse_cdata<Flags>(text);\r\n                    }\r\n                    break;\r\n\r\n                // <!D\r\n                case Ch('D'):\r\n                    if (text[2] == Ch('O') && text[3] == Ch('C') && text[4] == Ch('T') && \r\n                        text[5] == Ch('Y') && text[6] == Ch('P') && text[7] == Ch('E') && \r\n                        whitespace_pred::test(text[8]))\r\n                    {\r\n                        // '<!DOCTYPE ' - doctype\r\n                        text += 9;      // skip '!DOCTYPE '\r\n                        return parse_doctype<Flags>(text);\r\n                    }\r\n\r\n                }   // switch\r\n\r\n                // Attempt to skip other, unrecognized node types starting with <!\r\n                ++text;     // Skip !\r\n                while (*text != Ch('>'))\r\n                {\r\n                    if (*text == 0)\r\n                        RAPIDXML_PARSE_ERROR(\"unexpected end of data\", text);\r\n                    ++text;\r\n                }\r\n                ++text;     // Skip '>'\r\n                return 0;   // No node recognized\r\n\r\n            }\r\n        }\r\n\r\n        // Parse contents of the node - children, data etc.\r\n        template<int Flags>\r\n        void parse_node_contents(Ch *&text, xml_node<Ch> *node)\r\n        {\r\n            // For all children and text\r\n            while (1)\r\n            {\r\n                // Skip whitespace between > and node contents\r\n                Ch *contents_start = text;      // Store start of node contents before whitespace is skipped\r\n                skip<whitespace_pred, Flags>(text);\r\n                Ch next_char = *text;\r\n\r\n            // After data nodes, instead of continuing the loop, control jumps here.\r\n            // This is because zero termination inside parse_and_append_data() function\r\n            // would wreak havoc with the above code.\r\n            // Also, skipping whitespace after data nodes is unnecessary.\r\n            after_data_node:    \r\n                \r\n                // Determine what comes next: node closing, child node, data node, or 0?\r\n                switch (next_char)\r\n                {\r\n                \r\n                // Node closing or child node\r\n                case Ch('<'):\r\n                    if (text[1] == Ch('/'))\r\n                    {\r\n                        // Node closing\r\n                        text += 2;      // Skip '</'\r\n                        if (Flags & parse_validate_closing_tags)\r\n                        {\r\n                            // Skip and validate closing tag name\r\n                            Ch *closing_name = text;\r\n                            skip<node_name_pred, Flags>(text);\r\n                            if (!internal::compare(node->name(), node->name_size(), closing_name, text - closing_name, true))\r\n                                RAPIDXML_PARSE_ERROR(\"invalid closing tag name\", text);\r\n                        }\r\n                        else\r\n                        {\r\n                            // No validation, just skip name\r\n                            skip<node_name_pred, Flags>(text);\r\n                        }\r\n                        // Skip remaining whitespace after node name\r\n                        skip<whitespace_pred, Flags>(text);\r\n                        if (*text != Ch('>'))\r\n                            RAPIDXML_PARSE_ERROR(\"expected >\", text);\r\n                        ++text;     // Skip '>'\r\n                        return;     // Node closed, finished parsing contents\r\n                    }\r\n                    else\r\n                    {\r\n                        // Child node\r\n                        ++text;     // Skip '<'\r\n                        if (xml_node<Ch> *child = parse_node<Flags>(text))\r\n                            node->append_node(child);\r\n                    }\r\n                    break;\r\n\r\n                // End of data - error\r\n                case Ch('\\0'):\r\n                    RAPIDXML_PARSE_ERROR(\"unexpected end of data\", text);\r\n\r\n                // Data node\r\n                default:\r\n                    next_char = parse_and_append_data<Flags>(node, text, contents_start);\r\n                    goto after_data_node;   // Bypass regular processing after data nodes\r\n\r\n                }\r\n            }\r\n        }\r\n        \r\n        // Parse XML attributes of the node\r\n        template<int Flags>\r\n        void parse_node_attributes(Ch *&text, xml_node<Ch> *node)\r\n        {\r\n            // For all attributes \r\n            while (attribute_name_pred::test(*text))\r\n            {\r\n                // Extract attribute name\r\n                Ch *name = text;\r\n                ++text;     // Skip first character of attribute name\r\n                skip<attribute_name_pred, Flags>(text);\r\n                if (text == name)\r\n                    RAPIDXML_PARSE_ERROR(\"expected attribute name\", name);\r\n\r\n                // Create new attribute\r\n                xml_attribute<Ch> *attribute = this->allocate_attribute();\r\n                attribute->name(name, text - name);\r\n                node->append_attribute(attribute);\r\n\r\n                // Skip whitespace after attribute name\r\n                skip<whitespace_pred, Flags>(text);\r\n\r\n                // Skip =\r\n                if (*text != Ch('='))\r\n                    RAPIDXML_PARSE_ERROR(\"expected =\", text);\r\n                ++text;\r\n\r\n                // Add terminating zero after name\r\n                if (!(Flags & parse_no_string_terminators))\r\n                    attribute->name()[attribute->name_size()] = 0;\r\n\r\n                // Skip whitespace after =\r\n                skip<whitespace_pred, Flags>(text);\r\n\r\n                // Skip quote and remember if it was ' or \"\r\n                Ch quote = *text;\r\n                if (quote != Ch('\\'') && quote != Ch('\"'))\r\n                    RAPIDXML_PARSE_ERROR(\"expected ' or \\\"\", text);\r\n                ++text;\r\n\r\n                // Extract attribute value and expand char refs in it\r\n                Ch *value = text, *end;\r\n                const int AttFlags = Flags & ~parse_normalize_whitespace;   // No whitespace normalization in attributes\r\n                if (quote == Ch('\\''))\r\n                    end = skip_and_expand_character_refs<attribute_value_pred<Ch('\\'')>, attribute_value_pure_pred<Ch('\\'')>, AttFlags>(text);\r\n                else\r\n                    end = skip_and_expand_character_refs<attribute_value_pred<Ch('\"')>, attribute_value_pure_pred<Ch('\"')>, AttFlags>(text);\r\n                \r\n                // Set attribute value\r\n                attribute->value(value, end - value);\r\n                \r\n                // Make sure that end quote is present\r\n                if (*text != quote)\r\n                    RAPIDXML_PARSE_ERROR(\"expected ' or \\\"\", text);\r\n                ++text;     // Skip quote\r\n\r\n                // Add terminating zero after value\r\n                if (!(Flags & parse_no_string_terminators))\r\n                    attribute->value()[attribute->value_size()] = 0;\r\n\r\n                // Skip whitespace after attribute value\r\n                skip<whitespace_pred, Flags>(text);\r\n            }\r\n        }\r\n\r\n    };\r\n\r\n    //! \\cond internal\r\n    namespace internal\r\n    {\r\n\r\n        // Whitespace (space \\n \\r \\t)\r\n        template<int Dummy>\r\n        const unsigned char lookup_tables<Dummy>::lookup_whitespace[256] = \r\n        {\r\n          // 0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F\r\n             0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  1,  0,  0,  1,  0,  0,  // 0\r\n             0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  // 1\r\n             1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  // 2\r\n             0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  // 3\r\n             0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  // 4\r\n             0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  // 5\r\n             0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  // 6\r\n             0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  // 7\r\n             0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  // 8\r\n             0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  // 9\r\n             0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  // A\r\n             0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  // B\r\n             0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  // C\r\n             0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  // D\r\n             0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  // E\r\n             0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0   // F\r\n        };\r\n\r\n        // Node name (anything but space \\n \\r \\t / > ? \\0)\r\n        template<int Dummy>\r\n        const unsigned char lookup_tables<Dummy>::lookup_node_name[256] = \r\n        {\r\n          // 0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F\r\n             0,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  1,  1,  0,  1,  1,  // 0\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 1\r\n             0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  // 2\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  // 3\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 4\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 5\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 6\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 7\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 8\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 9\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // A\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // B\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // C\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // D\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // E\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1   // F\r\n        };\r\n\r\n        // Text (i.e. PCDATA) (anything but < \\0)\r\n        template<int Dummy>\r\n        const unsigned char lookup_tables<Dummy>::lookup_text[256] = \r\n        {\r\n          // 0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F\r\n             0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 0\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 1\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 2\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  1,  1,  1,  // 3\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 4\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 5\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 6\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 7\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 8\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 9\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // A\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // B\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // C\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // D\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // E\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1   // F\r\n        };\r\n\r\n        // Text (i.e. PCDATA) that does not require processing when ws normalization is disabled \r\n        // (anything but < \\0 &)\r\n        template<int Dummy>\r\n        const unsigned char lookup_tables<Dummy>::lookup_text_pure_no_ws[256] = \r\n        {\r\n          // 0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F\r\n             0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 0\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 1\r\n             1,  1,  1,  1,  1,  1,  0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 2\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  1,  1,  1,  // 3\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 4\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 5\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 6\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 7\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 8\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 9\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // A\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // B\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // C\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // D\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // E\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1   // F\r\n        };\r\n\r\n        // Text (i.e. PCDATA) that does not require processing when ws normalizationis is enabled\r\n        // (anything but < \\0 & space \\n \\r \\t)\r\n        template<int Dummy>\r\n        const unsigned char lookup_tables<Dummy>::lookup_text_pure_with_ws[256] = \r\n        {\r\n          // 0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F\r\n             0,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  1,  1,  0,  1,  1,  // 0\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 1\r\n             0,  1,  1,  1,  1,  1,  0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 2\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  1,  1,  1,  // 3\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 4\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 5\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 6\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 7\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 8\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 9\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // A\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // B\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // C\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // D\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // E\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1   // F\r\n        };\r\n\r\n        // Attribute name (anything but space \\n \\r \\t / < > = ? ! \\0)\r\n        template<int Dummy>\r\n        const unsigned char lookup_tables<Dummy>::lookup_attribute_name[256] = \r\n        {\r\n          // 0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F\r\n             0,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  1,  1,  0,  1,  1,  // 0\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 1\r\n             0,  0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  // 2\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  // 3\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 4\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 5\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 6\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 7\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 8\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 9\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // A\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // B\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // C\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // D\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // E\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1   // F\r\n        };\r\n\r\n        // Attribute data with single quote (anything but ' \\0)\r\n        template<int Dummy>\r\n        const unsigned char lookup_tables<Dummy>::lookup_attribute_data_1[256] = \r\n        {\r\n          // 0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F\r\n             0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 0\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 1\r\n             1,  1,  1,  1,  1,  1,  1,  0,  1,  1,  1,  1,  1,  1,  1,  1,  // 2\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 3\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 4\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 5\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 6\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 7\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 8\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 9\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // A\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // B\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // C\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // D\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // E\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1   // F\r\n        };\r\n\r\n        // Attribute data with single quote that does not require processing (anything but ' \\0 &)\r\n        template<int Dummy>\r\n        const unsigned char lookup_tables<Dummy>::lookup_attribute_data_1_pure[256] = \r\n        {\r\n          // 0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F\r\n             0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 0\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 1\r\n             1,  1,  1,  1,  1,  1,  0,  0,  1,  1,  1,  1,  1,  1,  1,  1,  // 2\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 3\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 4\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 5\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 6\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 7\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 8\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 9\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // A\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // B\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // C\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // D\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // E\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1   // F\r\n        };\r\n\r\n        // Attribute data with double quote (anything but \" \\0)\r\n        template<int Dummy>\r\n        const unsigned char lookup_tables<Dummy>::lookup_attribute_data_2[256] = \r\n        {\r\n          // 0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F\r\n             0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 0\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 1\r\n             1,  1,  0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 2\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 3\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 4\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 5\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 6\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 7\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 8\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 9\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // A\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // B\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // C\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // D\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // E\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1   // F\r\n        };\r\n\r\n        // Attribute data with double quote that does not require processing (anything but \" \\0 &)\r\n        template<int Dummy>\r\n        const unsigned char lookup_tables<Dummy>::lookup_attribute_data_2_pure[256] = \r\n        {\r\n          // 0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F\r\n             0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 0\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 1\r\n             1,  1,  0,  1,  1,  1,  0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 2\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 3\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 4\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 5\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 6\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 7\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 8\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 9\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // A\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // B\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // C\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // D\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // E\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1   // F\r\n        };\r\n\r\n        // Digits (dec and hex, 255 denotes end of numeric character reference)\r\n        template<int Dummy>\r\n        const unsigned char lookup_tables<Dummy>::lookup_digits[256] = \r\n        {\r\n          // 0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F\r\n           255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  // 0\r\n           255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  // 1\r\n           255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  // 2\r\n             0,  1,  2,  3,  4,  5,  6,  7,  8,  9,255,255,255,255,255,255,  // 3\r\n           255, 10, 11, 12, 13, 14, 15,255,255,255,255,255,255,255,255,255,  // 4\r\n           255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  // 5\r\n           255, 10, 11, 12, 13, 14, 15,255,255,255,255,255,255,255,255,255,  // 6\r\n           255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  // 7\r\n           255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  // 8\r\n           255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  // 9\r\n           255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  // A\r\n           255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  // B\r\n           255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  // C\r\n           255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  // D\r\n           255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  // E\r\n           255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255   // F\r\n        };\r\n    \r\n        // Upper case conversion\r\n        template<int Dummy>\r\n        const unsigned char lookup_tables<Dummy>::lookup_upcase[256] = \r\n        {\r\n          // 0,  1,  2,  3,  4,  5,  6,  7,  8,  9,  A   B   C   D   E   F\r\n           0,  1,  2,  3,  4,  5,  6,  7,  8,  9,  10, 11, 12, 13, 14, 15,   // 0\r\n           16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,   // 1\r\n           32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,   // 2\r\n           48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,   // 3\r\n           64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,   // 4\r\n           80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,   // 5\r\n           96, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,   // 6\r\n           80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 123,124,125,126,127,  // 7\r\n           128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,  // 8\r\n           144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,  // 9\r\n           160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,  // A\r\n           176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,  // B\r\n           192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,  // C\r\n           208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,  // D\r\n           224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,  // E\r\n           240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255   // F\r\n        };\r\n    }\r\n    //! \\endcond\r\n\r\n}\r\n\r\n// Undefine internal macros\r\n#undef RAPIDXML_PARSE_ERROR\r\n\r\n// On MSVC, restore warnings state\r\n#ifdef _MSC_VER\r\n    #pragma warning(pop)\r\n#endif\r\n\r\n#endif\r\n"
  },
  {
    "path": "Libraries/Core/iOS/Headers/rapidxml/rapidxml_iterators.hpp",
    "content": "#ifndef RAPIDXML_ITERATORS_HPP_INCLUDED\r\n#define RAPIDXML_ITERATORS_HPP_INCLUDED\r\n\r\n// Copyright (C) 2006, 2009 Marcin Kalicinski\r\n// Version 1.13\r\n// Revision $DateTime: 2009/05/13 01:46:17 $\r\n//! \\file rapidxml_iterators.hpp This file contains rapidxml iterators\r\n\r\n#include \"rapidxml.hpp\"\r\n\r\nnamespace rapidxml\r\n{\r\n\r\n    //! Iterator of child nodes of xml_node\r\n    template<class Ch>\r\n    class node_iterator\r\n    {\r\n    \r\n    public:\r\n\r\n        typedef typename xml_node<Ch> value_type;\r\n        typedef typename xml_node<Ch> &reference;\r\n        typedef typename xml_node<Ch> *pointer;\r\n        typedef std::ptrdiff_t difference_type;\r\n        typedef std::bidirectional_iterator_tag iterator_category;\r\n        \r\n        node_iterator()\r\n            : m_node(0)\r\n        {\r\n        }\r\n\r\n        node_iterator(xml_node<Ch> *node)\r\n            : m_node(node->first_node())\r\n        {\r\n        }\r\n        \r\n        reference operator *() const\r\n        {\r\n            assert(m_node);\r\n            return *m_node;\r\n        }\r\n\r\n        pointer operator->() const\r\n        {\r\n            assert(m_node);\r\n            return m_node;\r\n        }\r\n\r\n        node_iterator& operator++()\r\n        {\r\n            assert(m_node);\r\n            m_node = m_node->next_sibling();\r\n            return *this;\r\n        }\r\n\r\n        node_iterator operator++(int)\r\n        {\r\n            node_iterator tmp = *this;\r\n            ++this;\r\n            return tmp;\r\n        }\r\n\r\n        node_iterator& operator--()\r\n        {\r\n            assert(m_node && m_node->previous_sibling());\r\n            m_node = m_node->previous_sibling();\r\n            return *this;\r\n        }\r\n\r\n        node_iterator operator--(int)\r\n        {\r\n            node_iterator tmp = *this;\r\n            ++this;\r\n            return tmp;\r\n        }\r\n\r\n        bool operator ==(const node_iterator<Ch> &rhs)\r\n        {\r\n            return m_node == rhs.m_node;\r\n        }\r\n\r\n        bool operator !=(const node_iterator<Ch> &rhs)\r\n        {\r\n            return m_node != rhs.m_node;\r\n        }\r\n\r\n    private:\r\n\r\n        xml_node<Ch> *m_node;\r\n\r\n    };\r\n\r\n    //! Iterator of child attributes of xml_node\r\n    template<class Ch>\r\n    class attribute_iterator\r\n    {\r\n    \r\n    public:\r\n\r\n        typedef typename xml_attribute<Ch> value_type;\r\n        typedef typename xml_attribute<Ch> &reference;\r\n        typedef typename xml_attribute<Ch> *pointer;\r\n        typedef std::ptrdiff_t difference_type;\r\n        typedef std::bidirectional_iterator_tag iterator_category;\r\n        \r\n        attribute_iterator()\r\n            : m_attribute(0)\r\n        {\r\n        }\r\n\r\n        attribute_iterator(xml_node<Ch> *node)\r\n            : m_attribute(node->first_attribute())\r\n        {\r\n        }\r\n        \r\n        reference operator *() const\r\n        {\r\n            assert(m_attribute);\r\n            return *m_attribute;\r\n        }\r\n\r\n        pointer operator->() const\r\n        {\r\n            assert(m_attribute);\r\n            return m_attribute;\r\n        }\r\n\r\n        attribute_iterator& operator++()\r\n        {\r\n            assert(m_attribute);\r\n            m_attribute = m_attribute->next_attribute();\r\n            return *this;\r\n        }\r\n\r\n        attribute_iterator operator++(int)\r\n        {\r\n            attribute_iterator tmp = *this;\r\n            ++this;\r\n            return tmp;\r\n        }\r\n\r\n        attribute_iterator& operator--()\r\n        {\r\n            assert(m_attribute && m_attribute->previous_attribute());\r\n            m_attribute = m_attribute->previous_attribute();\r\n            return *this;\r\n        }\r\n\r\n        attribute_iterator operator--(int)\r\n        {\r\n            attribute_iterator tmp = *this;\r\n            ++this;\r\n            return tmp;\r\n        }\r\n\r\n        bool operator ==(const attribute_iterator<Ch> &rhs)\r\n        {\r\n            return m_attribute == rhs.m_attribute;\r\n        }\r\n\r\n        bool operator !=(const attribute_iterator<Ch> &rhs)\r\n        {\r\n            return m_attribute != rhs.m_attribute;\r\n        }\r\n\r\n    private:\r\n\r\n        xml_attribute<Ch> *m_attribute;\r\n\r\n    };\r\n\r\n}\r\n\r\n#endif\r\n"
  },
  {
    "path": "Libraries/Core/iOS/Headers/rapidxml/rapidxml_print.hpp",
    "content": "#ifndef RAPIDXML_PRINT_HPP_INCLUDED\r\n#define RAPIDXML_PRINT_HPP_INCLUDED\r\n\r\n// Copyright (C) 2006, 2009 Marcin Kalicinski\r\n// Version 1.13\r\n// Revision $DateTime: 2009/05/13 01:46:17 $\r\n//! \\file rapidxml_print.hpp This file contains rapidxml printer implementation\r\n\r\n#include \"rapidxml.hpp\"\r\n\r\n// Only include streams if not disabled\r\n#ifndef RAPIDXML_NO_STREAMS\r\n    #include <ostream>\r\n    #include <iterator>\r\n#endif\r\n\r\nnamespace rapidxml\r\n{\r\n\r\n    ///////////////////////////////////////////////////////////////////////\r\n    // Printing flags\r\n\r\n    const int print_no_indenting = 0x1;   //!< Printer flag instructing the printer to suppress indenting of XML. See print() function.\r\n\r\n    ///////////////////////////////////////////////////////////////////////\r\n    // Internal\r\n\r\n    //! \\cond internal\r\n    namespace internal\r\n    {\r\n        ///////////////////////////////////////////////////////////////////////////\r\n        // Function declarations\r\n        \r\n        template<class OutIt, class Ch>\r\n        inline OutIt copy_chars(const Ch *begin, const Ch *end, OutIt out);\r\n        \r\n        template<class OutIt, class Ch>\r\n        inline OutIt copy_and_expand_chars(const Ch *begin, const Ch *end, Ch noexpand, OutIt out);\r\n        \r\n        template<class OutIt, class Ch>\r\n        inline OutIt fill_chars(OutIt out, int n, Ch ch);\r\n        \r\n        template<class Ch, Ch ch>\r\n        inline bool find_char(const Ch *begin, const Ch *end);\r\n        \r\n        template<class OutIt, class Ch>\r\n        inline OutIt print_node(OutIt out, const xml_node<Ch> *node, int flags, int indent);\r\n        \r\n        template<class OutIt, class Ch>\r\n        inline OutIt print_children(OutIt out, const xml_node<Ch> *node, int flags, int indent);\r\n        \r\n        template<class OutIt, class Ch>\r\n        inline OutIt print_attributes(OutIt out, const xml_node<Ch> *node, int flags);\r\n        \r\n        template<class OutIt, class Ch>\r\n        inline OutIt print_data_node(OutIt out, const xml_node<Ch> *node, int flags, int indent);\r\n        \r\n        template<class OutIt, class Ch>\r\n        inline OutIt print_cdata_node(OutIt out, const xml_node<Ch> *node, int flags, int indent);\r\n        \r\n        template<class OutIt, class Ch>\r\n        inline OutIt print_element_node(OutIt out, const xml_node<Ch> *node, int flags, int indent);\r\n        \r\n        template<class OutIt, class Ch>\r\n        inline OutIt print_declaration_node(OutIt out, const xml_node<Ch> *node, int flags, int indent);\r\n        \r\n        template<class OutIt, class Ch>\r\n        inline OutIt print_comment_node(OutIt out, const xml_node<Ch> *node, int flags, int indent);\r\n        \r\n        template<class OutIt, class Ch>\r\n        inline OutIt print_doctype_node(OutIt out, const xml_node<Ch> *node, int flags, int indent);\r\n        \r\n        template<class OutIt, class Ch>\r\n        inline OutIt print_pi_node(OutIt out, const xml_node<Ch> *node, int flags, int indent);\r\n        \r\n        ///////////////////////////////////////////////////////////////////////////\r\n        // Internal character operations\r\n    \r\n        // Copy characters from given range to given output iterator\r\n        template<class OutIt, class Ch>\r\n        inline OutIt copy_chars(const Ch *begin, const Ch *end, OutIt out)\r\n        {\r\n            while (begin != end)\r\n                *out++ = *begin++;\r\n            return out;\r\n        }\r\n        \r\n        // Copy characters from given range to given output iterator and expand\r\n        // characters into references (&lt; &gt; &apos; &quot; &amp;)\r\n        template<class OutIt, class Ch>\r\n        inline OutIt copy_and_expand_chars(const Ch *begin, const Ch *end, Ch noexpand, OutIt out)\r\n        {\r\n            while (begin != end)\r\n            {\r\n                if (*begin == noexpand)\r\n                {\r\n                    *out++ = *begin;    // No expansion, copy character\r\n                }\r\n                else\r\n                {\r\n                    switch (*begin)\r\n                    {\r\n                    case Ch('<'):\r\n                        *out++ = Ch('&'); *out++ = Ch('l'); *out++ = Ch('t'); *out++ = Ch(';');\r\n                        break;\r\n                    case Ch('>'): \r\n                        *out++ = Ch('&'); *out++ = Ch('g'); *out++ = Ch('t'); *out++ = Ch(';');\r\n                        break;\r\n                    case Ch('\\''): \r\n                        *out++ = Ch('&'); *out++ = Ch('a'); *out++ = Ch('p'); *out++ = Ch('o'); *out++ = Ch('s'); *out++ = Ch(';');\r\n                        break;\r\n                    case Ch('\"'): \r\n                        *out++ = Ch('&'); *out++ = Ch('q'); *out++ = Ch('u'); *out++ = Ch('o'); *out++ = Ch('t'); *out++ = Ch(';');\r\n                        break;\r\n                    case Ch('&'): \r\n                        *out++ = Ch('&'); *out++ = Ch('a'); *out++ = Ch('m'); *out++ = Ch('p'); *out++ = Ch(';'); \r\n                        break;\r\n                    default:\r\n                        *out++ = *begin;    // No expansion, copy character\r\n                    }\r\n                }\r\n                ++begin;    // Step to next character\r\n            }\r\n            return out;\r\n        }\r\n\r\n        // Fill given output iterator with repetitions of the same character\r\n        template<class OutIt, class Ch>\r\n        inline OutIt fill_chars(OutIt out, int n, Ch ch)\r\n        {\r\n            for (int i = 0; i < n; ++i)\r\n                *out++ = ch;\r\n            return out;\r\n        }\r\n\r\n        // Find character\r\n        template<class Ch, Ch ch>\r\n        inline bool find_char(const Ch *begin, const Ch *end)\r\n        {\r\n            while (begin != end)\r\n                if (*begin++ == ch)\r\n                    return true;\r\n            return false;\r\n        }\r\n\r\n        ///////////////////////////////////////////////////////////////////////////\r\n        // Internal printing operations\r\n    \r\n        // Print node\r\n        template<class OutIt, class Ch>\r\n        inline OutIt print_node(OutIt out, const xml_node<Ch> *node, int flags, int indent)\r\n        {\r\n            // Print proper node type\r\n            switch (node->type())\r\n            {\r\n\r\n            // Document\r\n            case node_document:\r\n                out = print_children(out, node, flags, indent);\r\n                break;\r\n\r\n            // Element\r\n            case node_element:\r\n                out = print_element_node(out, node, flags, indent);\r\n                break;\r\n            \r\n            // Data\r\n            case node_data:\r\n                out = print_data_node(out, node, flags, indent);\r\n                break;\r\n            \r\n            // CDATA\r\n            case node_cdata:\r\n                out = print_cdata_node(out, node, flags, indent);\r\n                break;\r\n\r\n            // Declaration\r\n            case node_declaration:\r\n                out = print_declaration_node(out, node, flags, indent);\r\n                break;\r\n\r\n            // Comment\r\n            case node_comment:\r\n                out = print_comment_node(out, node, flags, indent);\r\n                break;\r\n            \r\n            // Doctype\r\n            case node_doctype:\r\n                out = print_doctype_node(out, node, flags, indent);\r\n                break;\r\n\r\n            // Pi\r\n            case node_pi:\r\n                out = print_pi_node(out, node, flags, indent);\r\n                break;\r\n\r\n                // Unknown\r\n            default:\r\n                assert(0);\r\n                break;\r\n            }\r\n            \r\n            // If indenting not disabled, add line break after node\r\n            if (!(flags & print_no_indenting))\r\n                *out = Ch('\\n'), ++out;\r\n\r\n            // Return modified iterator\r\n            return out;\r\n        }\r\n        \r\n        // Print children of the node                               \r\n        template<class OutIt, class Ch>\r\n        inline OutIt print_children(OutIt out, const xml_node<Ch> *node, int flags, int indent)\r\n        {\r\n            for (xml_node<Ch> *child = node->first_node(); child; child = child->next_sibling())\r\n                out = print_node(out, child, flags, indent);\r\n            return out;\r\n        }\r\n\r\n        // Print attributes of the node\r\n        template<class OutIt, class Ch>\r\n        inline OutIt print_attributes(OutIt out, const xml_node<Ch> *node, int flags)\r\n        {\r\n            for (xml_attribute<Ch> *attribute = node->first_attribute(); attribute; attribute = attribute->next_attribute())\r\n            {\r\n                if (attribute->name() && attribute->value())\r\n                {\r\n                    // Print attribute name\r\n                    *out = Ch(' '), ++out;\r\n                    out = copy_chars(attribute->name(), attribute->name() + attribute->name_size(), out);\r\n                    *out = Ch('='), ++out;\r\n                    // Print attribute value using appropriate quote type\r\n                    if (find_char<Ch, Ch('\"')>(attribute->value(), attribute->value() + attribute->value_size()))\r\n                    {\r\n                        *out = Ch('\\''), ++out;\r\n                        out = copy_and_expand_chars(attribute->value(), attribute->value() + attribute->value_size(), Ch('\"'), out);\r\n                        *out = Ch('\\''), ++out;\r\n                    }\r\n                    else\r\n                    {\r\n                        *out = Ch('\"'), ++out;\r\n                        out = copy_and_expand_chars(attribute->value(), attribute->value() + attribute->value_size(), Ch('\\''), out);\r\n                        *out = Ch('\"'), ++out;\r\n                    }\r\n                }\r\n            }\r\n            return out;\r\n        }\r\n\r\n        // Print data node\r\n        template<class OutIt, class Ch>\r\n        inline OutIt print_data_node(OutIt out, const xml_node<Ch> *node, int flags, int indent)\r\n        {\r\n            assert(node->type() == node_data);\r\n            if (!(flags & print_no_indenting))\r\n                out = fill_chars(out, indent, Ch('\\t'));\r\n            out = copy_and_expand_chars(node->value(), node->value() + node->value_size(), Ch(0), out);\r\n            return out;\r\n        }\r\n\r\n        // Print data node\r\n        template<class OutIt, class Ch>\r\n        inline OutIt print_cdata_node(OutIt out, const xml_node<Ch> *node, int flags, int indent)\r\n        {\r\n            assert(node->type() == node_cdata);\r\n            if (!(flags & print_no_indenting))\r\n                out = fill_chars(out, indent, Ch('\\t'));\r\n            *out = Ch('<'); ++out;\r\n            *out = Ch('!'); ++out;\r\n            *out = Ch('['); ++out;\r\n            *out = Ch('C'); ++out;\r\n            *out = Ch('D'); ++out;\r\n            *out = Ch('A'); ++out;\r\n            *out = Ch('T'); ++out;\r\n            *out = Ch('A'); ++out;\r\n            *out = Ch('['); ++out;\r\n            out = copy_chars(node->value(), node->value() + node->value_size(), out);\r\n            *out = Ch(']'); ++out;\r\n            *out = Ch(']'); ++out;\r\n            *out = Ch('>'); ++out;\r\n            return out;\r\n        }\r\n\r\n        // Print element node\r\n        template<class OutIt, class Ch>\r\n        inline OutIt print_element_node(OutIt out, const xml_node<Ch> *node, int flags, int indent)\r\n        {\r\n            assert(node->type() == node_element);\r\n\r\n            // Print element name and attributes, if any\r\n            if (!(flags & print_no_indenting))\r\n                out = fill_chars(out, indent, Ch('\\t'));\r\n            *out = Ch('<'), ++out;\r\n            out = copy_chars(node->name(), node->name() + node->name_size(), out);\r\n            out = print_attributes(out, node, flags);\r\n            \r\n            // If node is childless\r\n            if (node->value_size() == 0 && !node->first_node())\r\n            {\r\n                // Print childless node tag ending\r\n                *out = Ch('/'), ++out;\r\n                *out = Ch('>'), ++out;\r\n            }\r\n            else\r\n            {\r\n                // Print normal node tag ending\r\n                *out = Ch('>'), ++out;\r\n\r\n                // Test if node contains a single data node only (and no other nodes)\r\n                xml_node<Ch> *child = node->first_node();\r\n                if (!child)\r\n                {\r\n                    // If node has no children, only print its value without indenting\r\n                    out = copy_and_expand_chars(node->value(), node->value() + node->value_size(), Ch(0), out);\r\n                }\r\n                else if (child->next_sibling() == 0 && child->type() == node_data)\r\n                {\r\n                    // If node has a sole data child, only print its value without indenting\r\n                    out = copy_and_expand_chars(child->value(), child->value() + child->value_size(), Ch(0), out);\r\n                }\r\n                else\r\n                {\r\n                    // Print all children with full indenting\r\n                    if (!(flags & print_no_indenting))\r\n                        *out = Ch('\\n'), ++out;\r\n                    out = print_children(out, node, flags, indent + 1);\r\n                    if (!(flags & print_no_indenting))\r\n                        out = fill_chars(out, indent, Ch('\\t'));\r\n                }\r\n\r\n                // Print node end\r\n                *out = Ch('<'), ++out;\r\n                *out = Ch('/'), ++out;\r\n                out = copy_chars(node->name(), node->name() + node->name_size(), out);\r\n                *out = Ch('>'), ++out;\r\n            }\r\n            return out;\r\n        }\r\n\r\n        // Print declaration node\r\n        template<class OutIt, class Ch>\r\n        inline OutIt print_declaration_node(OutIt out, const xml_node<Ch> *node, int flags, int indent)\r\n        {\r\n            // Print declaration start\r\n            if (!(flags & print_no_indenting))\r\n                out = fill_chars(out, indent, Ch('\\t'));\r\n            *out = Ch('<'), ++out;\r\n            *out = Ch('?'), ++out;\r\n            *out = Ch('x'), ++out;\r\n            *out = Ch('m'), ++out;\r\n            *out = Ch('l'), ++out;\r\n\r\n            // Print attributes\r\n            out = print_attributes(out, node, flags);\r\n            \r\n            // Print declaration end\r\n            *out = Ch('?'), ++out;\r\n            *out = Ch('>'), ++out;\r\n            \r\n            return out;\r\n        }\r\n\r\n        // Print comment node\r\n        template<class OutIt, class Ch>\r\n        inline OutIt print_comment_node(OutIt out, const xml_node<Ch> *node, int flags, int indent)\r\n        {\r\n            assert(node->type() == node_comment);\r\n            if (!(flags & print_no_indenting))\r\n                out = fill_chars(out, indent, Ch('\\t'));\r\n            *out = Ch('<'), ++out;\r\n            *out = Ch('!'), ++out;\r\n            *out = Ch('-'), ++out;\r\n            *out = Ch('-'), ++out;\r\n            out = copy_chars(node->value(), node->value() + node->value_size(), out);\r\n            *out = Ch('-'), ++out;\r\n            *out = Ch('-'), ++out;\r\n            *out = Ch('>'), ++out;\r\n            return out;\r\n        }\r\n\r\n        // Print doctype node\r\n        template<class OutIt, class Ch>\r\n        inline OutIt print_doctype_node(OutIt out, const xml_node<Ch> *node, int flags, int indent)\r\n        {\r\n            assert(node->type() == node_doctype);\r\n            if (!(flags & print_no_indenting))\r\n                out = fill_chars(out, indent, Ch('\\t'));\r\n            *out = Ch('<'), ++out;\r\n            *out = Ch('!'), ++out;\r\n            *out = Ch('D'), ++out;\r\n            *out = Ch('O'), ++out;\r\n            *out = Ch('C'), ++out;\r\n            *out = Ch('T'), ++out;\r\n            *out = Ch('Y'), ++out;\r\n            *out = Ch('P'), ++out;\r\n            *out = Ch('E'), ++out;\r\n            *out = Ch(' '), ++out;\r\n            out = copy_chars(node->value(), node->value() + node->value_size(), out);\r\n            *out = Ch('>'), ++out;\r\n            return out;\r\n        }\r\n\r\n        // Print pi node\r\n        template<class OutIt, class Ch>\r\n        inline OutIt print_pi_node(OutIt out, const xml_node<Ch> *node, int flags, int indent)\r\n        {\r\n            assert(node->type() == node_pi);\r\n            if (!(flags & print_no_indenting))\r\n                out = fill_chars(out, indent, Ch('\\t'));\r\n            *out = Ch('<'), ++out;\r\n            *out = Ch('?'), ++out;\r\n            out = copy_chars(node->name(), node->name() + node->name_size(), out);\r\n            *out = Ch(' '), ++out;\r\n            out = copy_chars(node->value(), node->value() + node->value_size(), out);\r\n            *out = Ch('?'), ++out;\r\n            *out = Ch('>'), ++out;\r\n            return out;\r\n        }\r\n\r\n    }\r\n    //! \\endcond\r\n\r\n    ///////////////////////////////////////////////////////////////////////////\r\n    // Printing\r\n\r\n    //! Prints XML to given output iterator.\r\n    //! \\param out Output iterator to print to.\r\n    //! \\param node Node to be printed. Pass xml_document to print entire document.\r\n    //! \\param flags Flags controlling how XML is printed.\r\n    //! \\return Output iterator pointing to position immediately after last character of printed text.\r\n    template<class OutIt, class Ch> \r\n    inline OutIt print(OutIt out, const xml_node<Ch> &node, int flags = 0)\r\n    {\r\n        return internal::print_node(out, &node, flags, 0);\r\n    }\r\n\r\n#ifndef RAPIDXML_NO_STREAMS\r\n\r\n    //! Prints XML to given output stream.\r\n    //! \\param out Output stream to print to.\r\n    //! \\param node Node to be printed. Pass xml_document to print entire document.\r\n    //! \\param flags Flags controlling how XML is printed.\r\n    //! \\return Output stream.\r\n    template<class Ch> \r\n    inline std::basic_ostream<Ch> &print(std::basic_ostream<Ch> &out, const xml_node<Ch> &node, int flags = 0)\r\n    {\r\n        print(std::ostream_iterator<Ch>(out), node, flags);\r\n        return out;\r\n    }\r\n\r\n    //! Prints formatted XML to given output stream. Uses default printing flags. Use print() function to customize printing process.\r\n    //! \\param out Output stream to print to.\r\n    //! \\param node Node to be printed.\r\n    //! \\return Output stream.\r\n    template<class Ch> \r\n    inline std::basic_ostream<Ch> &operator <<(std::basic_ostream<Ch> &out, const xml_node<Ch> &node)\r\n    {\r\n        return print(out, node);\r\n    }\r\n\r\n#endif\r\n\r\n}\r\n\r\n#endif\r\n"
  },
  {
    "path": "Libraries/Core/iOS/Headers/rapidxml/rapidxml_utils.hpp",
    "content": "#ifndef RAPIDXML_UTILS_HPP_INCLUDED\r\n#define RAPIDXML_UTILS_HPP_INCLUDED\r\n\r\n// Copyright (C) 2006, 2009 Marcin Kalicinski\r\n// Version 1.13\r\n// Revision $DateTime: 2009/05/13 01:46:17 $\r\n//! \\file rapidxml_utils.hpp This file contains high-level rapidxml utilities that can be useful\r\n//! in certain simple scenarios. They should probably not be used if maximizing performance is the main objective.\r\n\r\n#include \"rapidxml.hpp\"\r\n#include <vector>\r\n#include <string>\r\n#include <fstream>\r\n#include <stdexcept>\r\n\r\nnamespace rapidxml\r\n{\r\n\r\n    //! Represents data loaded from a file\r\n    template<class Ch = char>\r\n    class file\r\n    {\r\n        \r\n    public:\r\n        \r\n        //! Loads file into the memory. Data will be automatically destroyed by the destructor.\r\n        //! \\param filename Filename to load.\r\n        file(const char *filename)\r\n        {\r\n            using namespace std;\r\n\r\n            // Open stream\r\n            basic_ifstream<Ch> stream(filename, ios::binary);\r\n            if (!stream)\r\n                throw runtime_error(string(\"cannot open file \") + filename);\r\n            stream.unsetf(ios::skipws);\r\n            \r\n            // Determine stream size\r\n            stream.seekg(0, ios::end);\r\n            size_t size = stream.tellg();\r\n            stream.seekg(0);   \r\n            \r\n            // Load data and add terminating 0\r\n            m_data.resize(size + 1);\r\n            stream.read(&m_data.front(), static_cast<streamsize>(size));\r\n            m_data[size] = 0;\r\n        }\r\n\r\n        //! Loads file into the memory. Data will be automatically destroyed by the destructor\r\n        //! \\param stream Stream to load from\r\n        file(std::basic_istream<Ch> &stream)\r\n        {\r\n            using namespace std;\r\n\r\n            // Load data and add terminating 0\r\n            stream.unsetf(ios::skipws);\r\n            m_data.assign(istreambuf_iterator<Ch>(stream), istreambuf_iterator<Ch>());\r\n            if (stream.fail() || stream.bad())\r\n                throw runtime_error(\"error reading stream\");\r\n            m_data.push_back(0);\r\n        }\r\n        \r\n        //! Gets file data.\r\n        //! \\return Pointer to data of file.\r\n        Ch *data()\r\n        {\r\n            return &m_data.front();\r\n        }\r\n\r\n        //! Gets file data.\r\n        //! \\return Pointer to data of file.\r\n        const Ch *data() const\r\n        {\r\n            return &m_data.front();\r\n        }\r\n\r\n        //! Gets file data size.\r\n        //! \\return Size of file data, in characters.\r\n        std::size_t size() const\r\n        {\r\n            return m_data.size();\r\n        }\r\n\r\n    private:\r\n\r\n        std::vector<Ch> m_data;   // File data\r\n\r\n    };\r\n\r\n    //! Counts children of node. Time complexity is O(n).\r\n    //! \\return Number of children of node\r\n    template<class Ch>\r\n    inline std::size_t count_children(xml_node<Ch> *node)\r\n    {\r\n        xml_node<Ch> *child = node->first_node();\r\n        std::size_t count = 0;\r\n        while (child)\r\n        {\r\n            ++count;\r\n            child = child->next_sibling();\r\n        }\r\n        return count;\r\n    }\r\n\r\n    //! Counts attributes of node. Time complexity is O(n).\r\n    //! \\return Number of attributes of node\r\n    template<class Ch>\r\n    inline std::size_t count_attributes(xml_node<Ch> *node)\r\n    {\r\n        xml_attribute<Ch> *attr = node->first_attribute();\r\n        std::size_t count = 0;\r\n        while (attr)\r\n        {\r\n            ++count;\r\n            attr = attr->next_attribute();\r\n        }\r\n        return count;\r\n    }\r\n\r\n}\r\n\r\n#endif\r\n"
  },
  {
    "path": "Libraries/CricketAudio/Android/Headers/ck/attenuationmode.h",
    "content": "// Copyright 2016 Cricket Technology\n// www.crickettechnology.com\n/** @file */\n/** @defgroup CkAttenuationMode CkAttenuationMode */\n/** @{ */\n\n#pragma once\n#include \"ck/platform.h\"\n\n\n/** Indicates how volume on 3D sounds is attenuated with distance. */\ntypedef enum \n{\n\n    /** No attenuation; volume is 1.0 when closer than the far distance, and far volume outside of that. */\n    kCkAttenuationMode_None = 0,\n\n    /** Linear attenuation of volume between near distance and far distance. */\n    kCkAttenuationMode_Linear,\n\n    /** Attenuation proportional to the reciprocal of the distance. */\n    kCkAttenuationMode_InvDistance,\n\n    /** Attenuation proportional to the square of the reciprocal of the distance. \n     This is a good choice for realistically simulating point sound sources. */\n    kCkAttenuationMode_InvDistanceSquared,\n\n} CkAttenuationMode;\n\n/** @} */\n\n"
  },
  {
    "path": "Libraries/CricketAudio/Android/Headers/ck/bank.h",
    "content": "// Copyright 2016 Cricket Technology\n// www.crickettechnology.com\n/** @file */\n/** @defgroup CkBank CkBank */\n/** @{ */\n\n#pragma once\n#include \"ck/platform.h\"\n#include \"ck/pathtype.h\"\n\n\n/** A bank of memory-resident sounds. */\n\nclass CkBank\n{\npublic:\n    /** Returns true when an asynchronously loaded bank has finished loading. */\n    virtual bool isLoaded() const = 0;\n\n    /** Returns true if an asynchronously loaded bank had an error during loading. */\n    virtual bool isFailed() const = 0;\n\n    /** Returns the name of the bank. */\n    virtual const char* getName() const = 0;\n\n    /** Returns the number of sounds in the bank. */\n    virtual int getNumSounds() const = 0;\n\n    /** Returns the name of a sound in this bank.\n      The name will be 31 characters or less. */\n    virtual const char* getSoundName(int index) const = 0;\n\n\n    ////////////////////////////////////////\n\n    /** Loads a bank. \n\n      This will return NULL if the bank cannot be loaded.\n\n      If the bank file is embedded in a larger file, specify the offset and \n      length of the embedded data; otherwise, leave them both as 0.\n     */\n    static CkBank* newBank(const char* path, CkPathType = kCkPathType_Default, int offset = 0, int length = 0);\n\n    /** Loads a bank asynchronously. \n\n      This will return NULL if the bank cannot be loaded.\n      When loading a bank asynchronously, you should also check isFailed()\n      after loading to make sure no errors occurred.\n\n      If the bank file is embedded in a larger file, specify the offset and \n      length of the embedded data; otherwise, leave them both as 0.\n      */\n    static CkBank* newBankAsync(const char* path, CkPathType = kCkPathType_Default, int offset = 0, int length = 0);\n\n    /** Loads a bank from a memory buffer. \n\n      The buffer should contain entire bank file; you are responsible for\n      freeing the memory after the bank is deleted. \n\n      This will return NULL if the bank cannot be loaded.\n      */\n    static CkBank* newBankFromMemory(void*, int bytes);\n\n\n    /** Finds a loaded bank by name; returns NULL if not found. */\n    static CkBank* find(const char* bankName);\n\n    /** Destroys the bank. */\n    virtual void destroy() = 0;\n\nprotected:\n    CkBank() {}\n    virtual ~CkBank() {}\n\nprivate:\n    CkBank(const CkBank&);\n    CkBank& operator=(const CkBank&);\n};\n\n/** @} */\n"
  },
  {
    "path": "Libraries/CricketAudio/Android/Headers/ck/ck.h",
    "content": "// Copyright 2016 Cricket Technology\n// www.crickettechnology.com\n/** @file */\n/** @defgroup Ck Ck */\n/** @{ */\n\n#pragma once\n#include \"ck/config.h\"\n#include \"ck/pathtype.h\"\n\n#ifdef __cplusplus\nextern \"C\"\n{\n#endif\n\n/** Initializes Cricket Audio. Returns nonzero if successful. */\nint CkInit(CkConfig*);\n\n/** Updates Cricket Audio.\n  Should be called once per frame. */\nvoid CkUpdate();\n\n/** Shuts down Cricket Audio. */\nvoid CkShutdown();\n\n/** Suspends Cricket Audio; typically used when an app is made inactive. */\nvoid CkSuspend();\n\n/** Resumes Cricket Audio; typically used when an app is made active after having been inactive. */\nvoid CkResume();\n\n\n/** Returns a rough estimate of the load on the audio processing thread.\n  This is the fraction of the interval between audio callbacks that was actually spent\n  rendering audio; it will range between 0 and 1. */\nfloat CkGetRenderLoad();\n\n\n/** Returns the value of the clip flag.\n  The clip flag is set to true whenever the final audio output \"clips\", i.e. \n  exceeds the maximum value. */\nbool CkGetClipFlag();\n\n/** Resets the value of the clip flag to false.  \n  The clip flag is set to true whenever the final audio output \"clips\", i.e. \n  exceeds the maximum value. */\nvoid CkResetClipFlag();\n\n\n/** Sets the maximum rate at which volumes change on playing sounds, in ms per full volume scale. \n  Default value is 40 ms. */\nvoid CkSetVolumeRampTime(float ms);\n\n/** Gets the maximum rate at which volumes change on playing sounds, in ms per full volume scale. */\nfloat CkGetVolumeRampTime();\n\n/** Default value of volume ramp time. */\nextern const float Ck_volumeRampTimeMsDefault;\n\n\n/** Lock the audio processing thread to prevent it from processing any API calls.\n  The lock should be held only for a short time.  This is useful to ensure that\n  certain calls are processed together.  For example, if you want to play multiple\n  sounds together exactly in sync, call CkLockAudio(), call play() on each sound,\n  then call CkUnlockAudio(). */\nvoid CkLockAudio();\n\n/** Unlock the audio processing thread after a call to CkLockAudio(). */\nvoid CkUnlockAudio();\n\n\n/** Start capturing the final audio output to a file.  The filename must end with \".wav\" \n  (for a Microsoft WAVE file) or \".raw\" (for a headerless file containing 32-bit floating-point \n  interleaved stereo samples). */\nvoid CkStartCapture(const char* path, CkPathType pathType);\n\n/** Stop capturing audio output. */\nvoid CkStopCapture();\n\n\n#ifdef __cplusplus\n} // extern \"C\"\n#endif\n\n/** @} */\n"
  },
  {
    "path": "Libraries/CricketAudio/Android/Headers/ck/config.h",
    "content": "// Copyright 2016 Cricket Technology\n// www.crickettechnology.com\n/** @file */\n/** @defgroup CkConfig CkConfig */\n/** @{ */\n\n#pragma once\n#include \"ck/platform.h\"\n\n#if CK_PLATFORM_ANDROID\n#  include <jni.h>\n#endif\n\n////////////////////////////////////////\n\n/** Memory allocation function */\ntypedef void* (*CkAllocFunc)(int bytes);\n/** Memory deallocation function */\ntypedef void (*CkFreeFunc)(void*);\n\n\n/** Log message types */\ntypedef enum \n{\n    /** Flag to enable INFO log messages */\n    kCkLog_Info =  (1 << 0),\n\n    /** Flag to enable WARNING log messages */\n    kCkLog_Warning = (1 << 1),\n\n    /** Flag to enable ERROR log messages */\n    kCkLog_Error = (1 << 2),\n\n    /** Flag to disable all log messages */\n    kCkLog_None = 0,\n\n    /** Flag to enable all log messages */\n    kCkLog_All = (kCkLog_Info | kCkLog_Warning | kCkLog_Error)\n\n} CkLogType;\n\n\n/** Log message function */\ntypedef void (*CkLogFunc)(CkLogType, const char* msg);\n\n\n/** Sample types used for internal DSP pipeline */\ntypedef enum\n{\n    /** Force floating-point samples */\n    kCkSampleType_Float,\n\n    /** Force fixed-point samples */\n    kCkSampleType_Fixed,\n    \n    /** Use the default, based on the processor type */\n    kCkSampleType_Default\n\n} CkSampleType;\n\n\n////////////////////////////////////////\n\n/** Configuration options */\nstruct _CkConfig\n{\n#ifdef __cplusplus\n#  if CK_PLATFORM_ANDROID\n    /** Constructor to be used from JNI functions.\n      @param env      A JNI environment pointer\n      @param context  An android.content.Context object from Java (typically an\n                       android.app.Activity or android.app.Service)\n     */\n    _CkConfig(JNIEnv* env, jobject context);\n\n    /** This constructor should be used when there is no valid JNIEnv* pointer; for\n      example, from android_main() in a native activity using the android_native_app_glue\n      library.  See the code in src/samples/hellocricket/android-ndk-native for an example.\n      @param vm       A Java VM pointer\n      @param context  An android.content.Context object from Java (typically an\n                       android.app.Activity or android.app.Service)\n     */\n    _CkConfig(JavaVM* vm, jobject context);\n#  else\n    _CkConfig();\n#  endif\n#endif // __cplusplus\n\n#if CK_PLATFORM_ANDROID\n    /** The JNIEnv pointer.\n      @par Only available on Android. */\n    JNIEnv* jni;\n\n    /** The JavaVM pointer.\n      @par Only available on Android. */\n    JavaVM* vm;\n\n    /** A Java reference to your app's Context object (typically an Activity or Service).\n      @par Only available on Android. */\n    jobject context;\n\n    /** If true, always use Java AudioTrack for output of final mix, instead of OpenSL ES.\n      This should usually be set to false, unless you are debugging specific issues\n      related to low-level audio output.\n      Default is false (use Java AudioTrack only when OpenSL ES is not available, i.e. Android versions prior to 2.3). \n      @par Only available on Android. */\n    bool useJavaAudio;\n\n    /** If true, software support for Ogg Vorbis stream sounds is enabled.\n      If false, stream sounds will use the native Android decoder, which will not\n      support all of the features available to sounds decoded in software.\n      Default is true (Ogg Vorbis streams are decoded in software).\n      @par Only available on Android. */\n    bool enableOggVorbis;\n#endif\n\n#if CK_PLATFORM_IOS || CK_PLATFORM_TVOS\n    /** If true, hardware-assisted decoding is enabled for decoding compressed streams\n      when available.  See Apple's \"Multimedia Programming Guide\" for a list of codecs\n      for which hardware support is available.  Note that streams that use the hardware\n      decoder take slightly longer (~300ms) to initialize, and our tests have shown\n      a negligible effect on CPU usage, so the default value is false.\n      @par Only available on iOS. */\n    bool enableHardwareDecoding;\n#endif\n\n    /** Memory allocation function.\n      Default is NULL (system new will be used). \n      The allocator must be thread-safe. */\n    CkAllocFunc allocFunc;\n\n    /** Memory deallocation function.\n      Default is NULL (system delete will be used). \n      The allocator must be thread-safe. */\n    CkFreeFunc freeFunc;\n\n\n    /** Bitmask for which types of messages are logged. \n      Default is kCkLog_All (all messages logged). */\n    unsigned int logMask;\n\n    /** Function to handle log messages.\n      Default is NULL (printf or equivalent will be used). */\n    CkLogFunc logFunc;\n\n\n    /** Audio processing frame duration, in ms.\n      Shorter times result in lower latency, but require more CPU.\n      Default is 5 ms. */\n    float audioUpdateMs;\n\n    /** Size of buffer for stream sounds, in ms.\n      Larger buffers require more memory, but are less likely\n      to skip due to slow file reads.\n      Default is 500 ms. */\n    float streamBufferMs;\n\n    /** Interval between file reads for stream sounds, in ms.\n      Shorter times will allow for smaller stream buffer sizes, but require more CPU.\n      This value should be set to significantly less than streamBufferMs, or your buffers will always underrun!\n      Default is 100 ms. */\n    float streamFileUpdateMs;\n\n    /** Initial size of the audio task buffer.  If you see a \"Reallocating\n      audio task buffer\" warning, consider increasing this from its default value\n      of 500 to avoid additional memory allocations at runtime. */\n    int maxAudioTasks;\n\n    /** Maximum render load. When the value of CkGetRenderLoad() exceeds this value,\n      some sounds will not be rendered, to keep the CPU usage down.\n      Default is 0.8. */\n    float maxRenderLoad;\n\n    /** Sample type to be used internally for processing.  The default is \n      kCkSampleType_Default, which means that fixed-point samples are used on Android \n      armv5 and armv6 devices, which may lack hardware support for floating-point \n      operations, and that floating-point samples are used on all other devices. */\n    CkSampleType sampleType;\n};\n\ntypedef struct _CkConfig CkConfig;\n\n/** Default value of CkConfig.audioUpdateMs */\nextern const float CkConfig_audioUpdateMsDefault;\n\n/** Default value of CkConfig.streamBufferMs */\nextern const float CkConfig_streamBufferMsDefault;\n\n/** Default value of CkConfig.streamFileUpdateMs */\nextern const float CkConfig_streamFileUpdateMsDefault;\n\n/** Default value of CkConfig.maxAudioTasks */\nextern const int CkConfig_maxAudioTasksDefault;\n\n/** Default value of CkConfig.maxRenderLoad */\nextern const float CkConfig_maxRenderLoadDefault;\n\n////////////////////////////////////////\n\n#ifdef __OBJC__\n\n/** If you are using Objective-C, call CkConfigInit() to initialize the CkConfig\n  struct to its default values.\n  (If you are using C++, the CkConfig struct is initialized by its constructor.) */\n\n#ifdef __cplusplus\nextern \"C\"\n#endif\nvoid CkConfigInit(CkConfig*);\n\n#endif\n\n/** @} */\n"
  },
  {
    "path": "Libraries/CricketAudio/Android/Headers/ck/customfile.h",
    "content": "// Copyright 2016 Cricket Technology\n// www.crickettechnology.com\n/** @file */\n/** @defgroup CkCustomFile CkCustomFile */\n/** @{ */\n\n#pragma once\n#include \"ck/platform.h\"\n#include \"ck/pathtype.h\"\n\n\n/** Custom file base class.  \n  \n  If you want to override the low-level details of how \n  files are read (for example, to read files over a network, or to decrypt encrypted\n  files as they are read), create a subclass and register a handler with \n  CkSetCustomFileHandler().\n\n  This will work for bank files, and for .cks and Ogg Vorbis streams, but not for\n  other stream types such as MP3, AAC, etc. */\n\nclass CkCustomFile\n{\npublic:\n    virtual ~CkCustomFile() {}\n\n    /** Returns true if the file was successfully opened. */\n    virtual bool isValid() const = 0;\n\n    /** Read from the file.  Returns number of bytes actually read. */\n    virtual int read(void* buf, int bytes) = 0;\n\n    /** Returns the size of the file. */\n    virtual int getSize() const = 0;\n\n    /** Sets the read position in the file. */\n    virtual void setPos(int pos) = 0;\n\n    /** Returns the read position in the file. */\n    virtual int getPos() const = 0;\n};\n\n\n/** Factory function for opening files using a CkCustomFile instance.\n  The function should return CkCustomFile instance, or NULL to open \n  the file with the default handler. */\ntypedef CkCustomFile* (*CkCustomFileFunc)(const char* path, void* data);\n\n/** Set the file handler. \n  Set it to NULL to use the default handler. */\nvoid CkSetCustomFileHandler(CkCustomFileFunc, void* data);\n\n\n/** @} */\n\n\n"
  },
  {
    "path": "Libraries/CricketAudio/Android/Headers/ck/customstream.h",
    "content": "// Copyright 2016 Cricket Technology\n// www.crickettechnology.com\n/** @file */\n/** @defgroup CkCustomStream CkCustomStream */\n/** @{ */\n\n#pragma once\n#include \"ck/platform.h\"\n\n\n/** Base class for custom streams.\n  To create a custom stream sound (for example, for playing back audio in\n  a proprietary file format), create a subclass, then register a factory\n  function with CkSound::setCustomStreamHandler(). */\n\nclass CkCustomStream\n{\npublic:\n    virtual ~CkCustomStream() {}\n\n    /** Initializes the stream (open data files, read file headers, etc).\n    This is called from the file streaming thread, not the main thread,\n    so synchronous file reading calls will not block audio or application logic. */\n    virtual void init() = 0;\n\n    /** Returns whether the stream has failed in a way that renders it\n      unusable; for example, if an audio file could not be found. */\n    virtual bool isFailed() const = 0;\n\n    /** Returns the number of channels; should be either 1 or 2. */\n    virtual int getChannels() const = 0;\n\n    /** Returns the sample rate of the audio. */\n    virtual int getSampleRate() const = 0;\n\n    /** Returns the total duration of the sound, in sample frames. */\n    virtual int getLength() const = 0;\n\n    /** Reads audio into the buffer; returns the number of sample frames\n      actually read. The audio data should be 16-bit signed PCM. */\n    virtual int read(short* buf, int frames) = 0;\n\n    /** Sets the current play position, in sample frames. */\n    virtual void setPlayPosition(int frame) = 0;\n\n    /** Returns the current play position, in sample frames. */\n    virtual int getPlayPosition() const = 0;\n\n};\n\n\n/** @} */\n\n"
  },
  {
    "path": "Libraries/CricketAudio/Android/Headers/ck/effect.h",
    "content": "// Copyright 2016 Cricket Technology\n// www.crickettechnology.com\n/** @file */\n/** @defgroup CkEffect CkEffect */\n/** @{ */\n\n#pragma once\n#include \"ck/platform.h\"\n#include \"ck/effecttype.h\"\n#include <stddef.h>\n\nclass CkEffectProcessor;\n\n\n/** An audio effect. */\nclass CkEffect\n{\npublic:\n    /** Set an effect parameter. \n      Parameter IDs are found in ck/effectparam.h. */\n    virtual void setParam(int paramId, float value) = 0;\n\n\n    /** Reset the state of this effect. */\n    virtual void reset() = 0;\n\n\n    /** Set whether this effect is bypassed.\n      A bypassed effect is not applied to the audio. */\n    virtual void setBypassed(bool) = 0;\n\n    /** Gets whether this effect is bypassed.\n      A bypassed effect is not applied to the audio. */\n    virtual bool isBypassed() const = 0;\n\n\n    /** Sets the wet/dry ratio for this effect\n      The ratio can range from 0 to 1.\n      A value of 0 means the audio is left completely \"dry\", that is, with no\n      effects applied; it is equivalent to bypassing the ffect.\n      A value of 1 means the audio is completely \"wet\", that is, the original\n      \"dry\" signal is not mixed back into the processed audio. */\n    virtual void setWetDryRatio(float) = 0;\n\n    /** Gets the wet/dry ratio for this effect.\n      The ratio can range from 0 to 1.\n      A value of 0 means the audio is left completely \"dry\", that is, with no\n      effects applied; it is equivalent to bypassing the effect.\n      A value of 1 means the audio is completely \"wet\", that is, the original\n      \"dry\" signal is not mixed back into the processed audio. */\n    virtual float getWetDryRatio() const = 0;\n\n\n    /** Create a built-in effect. \n      Effect types are found in ck/effecttype.h. */\n    static CkEffect* newEffect(CkEffectType);\n\n\n    /** Factory function for creating effect processors for custom effects. */\n    typedef CkEffectProcessor* (*CustomEffectFunc)(void* arg);\n\n    /** Register a custom effect. \n     To unregister an effect, pass in NULL for the CustomEffectFunc. */\n    static void registerCustomEffect(int id, CustomEffectFunc);\n\n    /** Create a custom effect.\n      A factory function must have been previously registered with the given id,\n      or this will return NULL. */\n    static CkEffect* newCustomEffect(int id, void* arg = NULL);\n\n\n    /** Destroy the effect. */\n    virtual void destroy() = 0;\n\nprotected:\n    CkEffect() {}\n    virtual ~CkEffect() {}\n\nprivate:\n    CkEffect(const CkEffect&);\n    CkEffect& operator=(const CkEffect&);\n};\n\n\n/** @} */\n"
  },
  {
    "path": "Libraries/CricketAudio/Android/Headers/ck/effectbus.h",
    "content": "// Copyright 2016 Cricket Technology\n// www.crickettechnology.com\n/** @file */\n/** @defgroup CkEffectBus CkEffectBus */\n/** @{ */\n\n#pragma once\n#include \"ck/platform.h\"\n\n\nclass CkEffect;\n\n/** Manages a set of audio effects applied to sounds. */\nclass CkEffectBus\n{\npublic:\n\n    /** Add an effect to this bus.\n      An effect can only be on one bus at a time. */\n    virtual void addEffect(CkEffect*) = 0;\n\n    /** Remove an effect from this bus. */\n    virtual void removeEffect(CkEffect*) = 0;\n\n    /** Remove all effects from this bus. */\n    virtual void removeAllEffects() = 0;\n\n\n    /** Set the bus to which this bus's output is sent.\n      If NULL (the default), the audio from this bus is mixed into the final output. */\n    virtual void setOutputBus(CkEffectBus*) = 0;\n\n    /** Get the bus to which this bus's output is sent.\n      If NULL (the default), the audio from this bus is mixed into the final output. */\n    virtual CkEffectBus* getOutputBus() = 0;\n\n\n    /** Reset the state of all the effects on this bus. */\n    virtual void reset() = 0;\n\n\n    /** Set whether this bus is bypassed.\n      A bypassed effect is not applied to the audio. */\n    virtual void setBypassed(bool) = 0;\n\n    /** Gets whether this bus is bypassed.\n      Effects in a bypassed bus are not applied to the audio. */\n    virtual bool isBypassed() const = 0;\n\n\n    /** Sets the wet/dry ratio for this bus.\n      The ratio can range from 0 to 1.\n      A value of 0 means the audio is left completely \"dry\", that is, with no\n      effects applied; it is equivalent to bypassing the bus.\n      A value of 1 means the audio is completely \"wet\", that is, the original\n      \"dry\" signal is not mixed back into the processed audio. */\n    virtual void setWetDryRatio(float) = 0;\n\n    /** Gets the wet/dry ratio for this bus.\n      The ratio can range from 0 to 1.\n      A value of 0 means the audio is left completely \"dry\", that is, with no\n      effects applied; it is equivalent to bypassing the bus.\n      A value of 1 means the audio is completely \"wet\", that is, the original\n      \"dry\" signal is not mixed back into the processed audio. */\n    virtual float getWetDryRatio() const = 0;\n\n    ////////////////////////////////////////\n\n    /** Create a new effect bus. */\n    static CkEffectBus* newEffectBus();\n\n    /** Get the global effect bus.\n      Effects on this bus are applied to the final audio before it is output. */\n    static CkEffectBus* getGlobalEffectBus();\n\n    /** Destroy this effect bus. */\n    virtual void destroy() = 0;\n\nprotected:\n    CkEffectBus() {}\n    virtual ~CkEffectBus() {}\n\nprivate:\n    CkEffectBus(const CkEffectBus&);\n    CkEffectBus& operator=(const CkEffectBus&);\n\n};\n\n/** @} */\n\n"
  },
  {
    "path": "Libraries/CricketAudio/Android/Headers/ck/effectparam.h",
    "content": "// Copyright 2016 Cricket Technology\n// www.crickettechnology.com\n/** @file */\n/** @defgroup CkEffectParam CkEffectParam */\n/** @{ */\n\n#pragma once\n#include \"ck/platform.h\"\n\n/** Parameters for the Biquad Filter effect */\nenum\n{\n    /** Type of filter; should be one of the kCkBiquadFilterParam_FilterType values. */\n    kCkBiquadFilterParam_FilterType,\n\n    /** Center frequency of the filter. */\n    kCkBiquadFilterParam_Freq,\n\n    /** Q of the filter. */\n    kCkBiquadFilterParam_Q,\n\n    /** Gain in dB (for Peak, LowShelf, and HighShelf filter types) */\n    kCkBiquadFilterParam_Gain,\n};\n\n\n/** Filter types, used for the kCkBiquadFilterParam_FilterType param. */\nenum\n{\n    /** Low pass filter blocks high frequencies. */\n    kCkBiquadFilterParam_FilterType_LowPass,\n\n    /** High pass filter blocks low frequencies. */\n    kCkBiquadFilterParam_FilterType_HighPass,\n    \n    /** Band pass filter blocks frequencies above and below the center frequency. */\n    kCkBiquadFilterParam_FilterType_BandPass,\n\n    /** Notch filter blocks a narrow band of frequencies. */\n    kCkBiquadFilterParam_FilterType_Notch,\n\n    /** Peak filter boosts a narrow band of frequencies. */\n    kCkBiquadFilterParam_FilterType_Peak,\n\n    /** Low shelf filter boosts low frequencies. */\n    kCkBiquadFilterParam_FilterType_LowShelf,\n\n    /** High shelf filter boosts high frequencies. */\n    kCkBiquadFilterParam_FilterType_HighShelf\n};\n\n\n////////////////////////////////////////\n\n\n/** Parameters for the Bit Crusher effect */\nenum\n{\n    /** Number of bits of resolution to keep in the input samples, in [1..24]. */\n    kCkBitCrusherParam_BitResolution,\n\n    /** Milliseconds to hold each sample value.  Higher values result in more\n      reduction in the effective sample rate.  Values around 1 ms provide a reasonable effect. */\n    kCkBitCrusherParam_HoldMs,\n};\n\n\n////////////////////////////////////////\n\n\n/** Parameters for the Ring Mod effect */\nenum\n{\n    /** Frequency (Hz) of the modulating signal. Values around 500 Hz are typical. */\n    kCkRingModParam_Freq,\n};\n\n////////////////////////////////////////\n\n\n/** Parameters for the Distortion effect */\nenum\n{\n    /** Scale factor for input; larger values cause a more pronounced effect. */\n    kCkDistortionParam_Drive,\n\n    /** Offset for input. */\n    kCkDistortionParam_Offset,\n};\n\n\n\n\n/** @} */\n\n\n"
  },
  {
    "path": "Libraries/CricketAudio/Android/Headers/ck/effectprocessor.h",
    "content": "// Copyright 2016 Cricket Technology\n// www.crickettechnology.com\n/** @file */\n/** @defgroup CkEffectProcessor CkEffectProcessor */\n/** @{ */\n\n#pragma once\n#include \"ck/platform.h\"\n\n/** Performs audio processing for effects.\n\n  To implement your own custom audio effects, create a subclass, then register a factory\n  function that creates an instance of it with CkEffect::registerCustomEffect(). */\n\nclass CkEffectProcessor\n{\npublic:\n    virtual ~CkEffectProcessor() {}\n\n    /** Set an effect parameter.\n      Note that this should not be called directly; it is called by CkEffect::setParam(). */\n    virtual void setParam(int paramId, float value) = 0;\n\n    /** Reset this effect's state. */\n    virtual void reset() = 0;\n\n    /** If true, the effect is processed in-place; the input and output will be the\n      same buffer.  If false, input and output will be separate buffers. */\n    virtual bool isInPlace() const = 0;\n\n    /** Process audio.\n      The buffer contains interleaved stereo data; each sample is a signed 8.24 fixed-point value.\n      If isInPlace() returns true, inBuf and outBuf will be pointers to the same buffer. \n      It is OK to modify the data in inBuf, even if the effect is not in-place.\n      (Remember that because the data is stereo, the number of samples is 2*frames.) \n\n      @par This will only be called on older Android armv5 or armv6 devices, or if CkConfig.sampleType is set to kCkSampleType_Fixed.\n      If you are not supporting those devices, you may leave this with its default implementation, which passes the audio \n      through unchanged. */\n    virtual void process(int* inBuf, int* outBuf, int frames);\n\n    /** Process audio.\n      The buffer contains interleaved stereo data; each sample is a 32-bit floating-point value.\n      If isInPlace() returns true, inBuf and outBuf will be pointers to the same buffer. \n      It is OK to modify the data in inBuf, even if the effect is not in-place.\n      (Remember that because the data is stereo, the number of samples is 2*frames.) */\n    virtual void process(float* inBuf, float* outBuf, int frames) = 0;\n\n    /** Get the sample rate of the audio data.  This value may be different on different\n      devices, but will not change during app execution. */\n    static int getSampleRate();\n};\n\n\n/** @} */\n\n"
  },
  {
    "path": "Libraries/CricketAudio/Android/Headers/ck/effecttype.h",
    "content": "// Copyright 2016 Cricket Technology\n// www.crickettechnology.com\n/** @file */\n/** @defgroup CkEffectType CkEffectType */\n/** @{ */\n\n#pragma once\n#include \"ck/platform.h\"\n\n/** Types of built-in effects available */\ntypedef enum \n{\n    /** Biquadratic filter. \n      See kCkBiquadFilterParam values for parameter IDs. */\n    kCkEffectType_BiquadFilter,\n\n    /** Bit Crusher effect reduces bit resolution and/or bit rate, producing a retro\n      low-fi 8-bit sound.\n      See kCkBitCrusherParam values for parameter IDs. */\n    kCkEffectType_BitCrusher,\n\n    /** Ring Mod effect modulates the audio by a sine wave. \n      See kCkRingModParam values for parameter IDs. */\n    kCkEffectType_RingMod,\n\n    /** Distortion effect.\n      See kCkDistortionParam values for parameter IDs. */\n    kCkEffectType_Distortion,\n\n} CkEffectType;\n\n\n/** @} */\n"
  },
  {
    "path": "Libraries/CricketAudio/Android/Headers/ck/mixer.h",
    "content": "// Copyright 2016 Cricket Technology\n// www.crickettechnology.com\n/** @file */\n/** @defgroup CkMixer CkMixer */\n/** @{ */\n\n#pragma once\n#include \"ck/platform.h\"\n#include <stddef.h>\n\n\n/** A mixer represents a hierarchical grouping of sounds for controlling volumes. */\n\nclass CkMixer\n{\npublic:\n    /** Set the name of the mixer.\n      The name should be 31 characters or less. */\n    virtual void setName(const char*) = 0;\n\n    /** Get the name of the mixer. */\n    virtual const char* getName() const = 0;\n\n\n    /** Set the volume of this mixer.\n      (The actual volume used during mixing will also depend on ancestors.) */\n    virtual void setVolume(float) = 0;\n\n    /** Get the volume of this mixer.\n      (The actual volume used during mixing will also depend on ancestors.) */\n    virtual float getVolume() const = 0;\n\n\n    /** Get the volume used for mixing (affected by ancestors). */\n    virtual float getMixedVolume() const = 0;\n\n\n    /** Set whether this mixer is paused.\n      A sound will be paused if the sound, its mixer, or any of its mixer's ancestors\n      are paused. */\n    virtual void setPaused(bool) = 0;\n\n    /** Get whether this mixer is paused.\n      A sound will be paused if the sound, its mixer, or any of its mixer's ancestors\n      are paused. */\n    virtual bool isPaused() const = 0;\n\n\n    /** Returns true if this mixer, or any of its ancestors, is paused. */\n    virtual bool getMixedPauseState() const = 0;\n\n\n    /** Set the parent of the mixer.\n      Setting to NULL sets the master mixer as the parent. */\n    virtual void setParent(CkMixer*) = 0;\n\n    /** Get the parent of the mixer. */\n    virtual CkMixer* getParent() = 0;\n\n\n    /** Returns the master mixer, which is the root of the mixer hierarchy. */\n    static CkMixer* getMaster();\n\n    /** Creates a new mixer. */\n    static CkMixer* newMixer(const char* name, CkMixer* parent = NULL);\n\n    /** Finds a mixer by name; returns NULL if not found. */\n    static CkMixer* find(const char* name);\n\n\n    /** Destroys the mixer. */\n    virtual void destroy() = 0;\n\nprotected:\n    CkMixer() {}\n    virtual ~CkMixer() {}\n\nprivate:\n    CkMixer(const CkMixer&);\n    CkMixer& operator=(const CkMixer&);\n};\n\n/** @} */\n"
  },
  {
    "path": "Libraries/CricketAudio/Android/Headers/ck/pathtype.h",
    "content": "// Copyright 2016 Cricket Technology\n// www.crickettechnology.com\n/** @file */\n/** @defgroup CkPathType CkPathType */\n/** @{ */\n\n#pragma once\n#include \"ck/platform.h\"\n\n\n/** Indicates how a file path should be interpreted. */\ntypedef enum \n{\n    /** A full path to a file on the file system. */\n    kCkPathType_FileSystem = 0,\n\n#if CK_PLATFORM_ANDROID\n    /** A path to an asset in the .apk. \n      Assets are read-only.\n     @par Only available on Android. */\n    kCkPathType_Asset,\n\n    /** A path relative to the private files directory.\n     @par Only available on Android. */\n    kCkPathType_PrivateFiles,\n\n    /** A path relative to the external storage directory.\n     @par Only available on Android. */\n    kCkPathType_ExternalStorage,\n#endif\n\n#if CK_PLATFORM_IOS || CK_PLATFORM_OSX || CK_PLATFORM_TVOS\n    /** A path relative to the application's resource directory.\n      On iOS, the resource directory is the application bundle, and is read-only.\n      On OS X, the resource directory is the directory containing the executable.\n     @par Only available on iOS and OS X. */\n    kCkPathType_Resource,\n#endif\n\n#if CK_PLATFORM_WP8\n    /** A path relative to the local app data store.\n     @par Only available on Windows Phone 8. */\n    kCkPathType_LocalDir,\n\n    /** A path relative to the folder containing your app's package files.\n      Files in your Visual Studio project with the \"Content\" property set to true will be installed here.\n      This folder is read-only.\n     @par Only available on Windows Phone 8. */\n    kCkPathType_InstallationDir,\n#endif\n\n#if CK_PLATFORM_IOS || CK_PLATFORM_OSX || CK_PLATFORM_TVOS || CK_PLATFORM_WIN || CK_PLATFORM_LINUX\n    /** A path relative to the directory used for temporary files.\n     @par Only available on iOS, OS X, Windows, and Linux. */\n    kCkPathType_Temp,\n#endif\n\n#if CK_PLATFORM_IOS || CK_PLATFORM_OSX || CK_PLATFORM_WIN || CK_PLATFORM_LINUX\n    /** A path relative to the application's documents directory.\n      On iOS, this is the app's Documents directory.\n      On OS X and Windows, this is the user's Documents directory.\n      On Linux, this is the user's home directory.\n     @par Only available on iOS, OS X, Windows, and Linux. */\n    kCkPathType_Documents,\n#endif\n\n#if CK_PLATFORM_WIN || CK_PLATFORM_LINUX || CK_PLATFORM_OSX\n    /** A path relative to the executable's directory. \n     (On OS X, this is the same as kCkPathType_Resource.) \n     @par Only available on Windows, Linux, and OS X.  */\n    kCkPathType_ExeDir,\n#endif\n\n    /** The default path type for reading files. */\n#if CK_PLATFORM_ANDROID\n    kCkPathType_ReadDefault = kCkPathType_Asset,\n#elif CK_PLATFORM_IOS || CK_PLATFORM_OSX || CK_PLATFORM_TVOS\n    kCkPathType_ReadDefault = kCkPathType_Resource,\n#elif CK_PLATFORM_WIN || CK_PLATFORM_LINUX\n    kCkPathType_ReadDefault = kCkPathType_ExeDir,\n#elif CK_PLATFORM_WP8\n    kCkPathType_ReadDefault = kCkPathType_InstallationDir,\n#endif\n\n    /** The default path type for writing files. */\n#if CK_PLATFORM_ANDROID\n    kCkPathType_WriteDefault = kCkPathType_PrivateFiles,\n#elif CK_PLATFORM_IOS || CK_PLATFORM_OSX \n    kCkPathType_WriteDefault = kCkPathType_Documents,\n#elif CK_PLATFORM_TVOS\n    kCkPathType_WriteDefault = kCkPathType_Temp,\n#elif CK_PLATFORM_WIN || CK_PLATFORM_LINUX\n    kCkPathType_WriteDefault = kCkPathType_ExeDir,\n#elif CK_PLATFORM_WP8\n    kCkPathType_WriteDefault = kCkPathType_LocalDir,\n#endif\n\n    /** The default path type. */\n    kCkPathType_Default = kCkPathType_ReadDefault\n\n} CkPathType;\n\n/** @} */\n"
  },
  {
    "path": "Libraries/CricketAudio/Android/Headers/ck/platform.h",
    "content": "// Copyright 2016 Cricket Technology\n// www.crickettechnology.com\n/** @file */\n\n#pragma once\n\n// software platform\n#undef CK_PLATFORM_IOS\n#undef CK_PLATFORM_TVOS\n#undef CK_PLATFORM_ANDROID\n#undef CK_PLATFORM_OSX\n#undef CK_PLATFORM_WIN\n#undef CK_PLATFORM_WP8\n#undef CK_PLATFORM_LINUX\n\n#ifdef __APPLE__\n#  include <TargetConditionals.h>\n#  if TARGET_OS_IPHONE\n#    if TARGET_OS_IOS\n#      define CK_PLATFORM_IOS 1\n#    elif TARGET_OS_TV\n#      define CK_PLATFORM_TVOS 1\n#    endif\n#  else\n#    define CK_PLATFORM_OSX 1\n#  endif\n#elif defined(__ANDROID__)\n#  define CK_PLATFORM_ANDROID 1\n#elif defined(__linux__)\n#  define CK_PLATFORM_LINUX 1\n#elif defined(_WIN64) || defined(_WIN32)\n#  if defined(WINAPI_FAMILY) && WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP\n#     define CK_PLATFORM_WP8 1\n#  else\n#     define CK_PLATFORM_WIN 1\n#  endif\n#endif\n\n#if CK_PLATFORM_OSX && (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1060)\n#  error \"OS X 10.6 required!\"\n#endif\n\n#if !CK_PLATFORM_IOS && !CK_PLATFORM_ANDROID && !CK_PLATFORM_OSX && !CK_PLATFORM_WIN && !CK_PLATFORM_WP8 && !CK_PLATFORM_LINUX && !CK_PLATFORM_TVOS\n#  error \"Unsupported platform!\"\n#endif\n"
  },
  {
    "path": "Libraries/CricketAudio/Android/Headers/ck/sound.h",
    "content": "// Copyright 2016 Cricket Technology\n// www.crickettechnology.com\n/** @file */\n/** @defgroup CkSound CkSound */\n/** @{ */\n\n#pragma once\n#include \"ck/platform.h\"\n#include \"ck/pathtype.h\"\n#include \"ck/attenuationmode.h\"\n#include <stddef.h>\n\n\nclass CkBank;\nclass CkMixer;\nclass CkEffectBus;\nclass CkCustomStream;\n\n/** A sound (either memory-resident or streamed). */\n\nclass CkSound \n{\npublic:\n    /** Sets the mixer to which this sound is assigned.\n      Setting NULL will assign it to the master mixer. */\n    virtual void setMixer(CkMixer*) = 0;\n\n    /** Gets the mixer to which this sound is assigned. */\n    virtual CkMixer* getMixer() = 0;\n\n\n    /** Returns true if the sound is ready.\n      Bank sounds are ready immediately after creation; stream sounds may not be. */\n    virtual bool isReady() const = 0;\n\n\n    /** Returns true if an error occurred while creating the sound. */\n    virtual bool isFailed() const = 0;\n\n\n    /** Play the sound. */\n    virtual void play() = 0;\n\n    /** Stop the sound. */\n    virtual void stop() = 0;\n\n    /** Gets whether the sound is playing. */\n    virtual bool isPlaying() const = 0; \n\n\n    /** Sets whether the sound is paused. \n     Note that even if false, the sound will be paused if its mixer or any of its \n     mixer's ancestors are paused.*/\n    virtual void setPaused(bool) = 0;\n\n    /** Gets whether the sound is paused.\n     Note that even if false, the sound will be paused if its mixer or any of its \n     mixer's ancestors are paused.*/\n    virtual bool isPaused() const = 0;\n\n    /** Returns true if the sound is pauses, its mixer is paused, or any of its\n      mixer's ancestors are paused. */\n    virtual bool getMixedPauseState() const = 0;\n\n\n    /** Set the loop start and end.\n      Default is to loop over all sample frames. \n      EndFrame is defined as one frame after the last frame of the loop.\n      Setting endFrame = -1 is equivalent to setting it to getLength(). \n     @par Android note: \n      This has no effect for streams in formats other than .cks or Ogg Vorbis. */\n    virtual void setLoop(int startFrame, int endFrame) = 0;\n\n    /** Get the loop start and end.\n      Default is to loop over all sample frames. \n      EndFrame is defined as one frame after the last frame of the loop.\n      Setting endFrame = -1 is equivalent to setting it to getLength(). \n     @par Android note: \n      This has no effect for streams in formats other than .cks or Ogg Vorbis. */\n    virtual void getLoop(int& startFrame, int& endFrame) const = 0;\n\n    /** Sets the number of times the sound should loop.  \n      0 means no looping (play once and then stop).\n      1 means it will play twice; 2 means it will play 3 times; etc. \n      -1 means it will loop indefinitely until the sound is stopped or releaseLoop() is called. */\n    virtual void setLoopCount(int) = 0;\n\n    /** Gets the number of times the sound should loop.  \n      0 means no looping (play once and then stop).\n      1 means it will play twice; 2 means it will play 3 times; etc. \n      -1 means it will loop indefinitely until the sound is stopped or releaseLoop() is called. */\n    virtual int getLoopCount() const = 0;\n\n    /** Gets the number of the current loop.\n      For example, returns 0 if this is the first time playing through this sample;\n      returns 1 if it is on its second loop through the sample; etc. */\n    virtual int getCurrentLoop() const = 0;\n\n    /** Makes the current loop the last.\n      This is useful when you don't know in advance how many times you will\n      want to loop; set the loop count to -1, and call releaseLoop() when\n      you want it to stop looping and play to the end. */\n    virtual void releaseLoop() = 0;\n\n    /** Returns true if releaseLoop() has been called after the last call to play(). */\n    virtual bool isLoopReleased() const = 0;\n\n\n    /** Set the play position in the sound, in sample frames.\n      This can be called before playing, to start from an offset into\n      the sound; or during playback, to jump to a new location. */\n    virtual void setPlayPosition(int) = 0;\n\n    /** Set the play position in the sound, in milliseconds.\n      This can be called before playing, to start from an offset into\n      the sound; or during playback, to jump to a new location. */\n    virtual void setPlayPositionMs(float) = 0;\n\n    /** Get the current play position in the sound, in sample frames. */\n    virtual int getPlayPosition() const = 0;\n\n    /** Get the current play position in the sound, in milliseconds. */\n    virtual float getPlayPositionMs() const = 0;\n\n\n    /** Sets the volume of this sound.\n      The volume can range from 0 to 1. The default value is 1. \n      Note that the actual volume used for mixing will also depend on the volume of the\n      mixer to which this sound is assigned. */\n    virtual void setVolume(float) = 0;\n\n    /** Gets the volume of this sound.\n      The volume can range from 0 to 1. The default value is 1. \n      Note that the actual volume used for mixing will also depend on the volume of the \n      mixer to which this sound is assigned. */\n    virtual float getVolume() const = 0;\n\n\n    /** Gets the volume value used for mixing. \n      This is the product of the volume set with setVolume() and the mixed\n      volume value of the mixer to which the sound is assigned. */\n    virtual float getMixedVolume() const = 0;\n\n\n    /** Sets the pan.\n      The pan can range from -1 (left) to +1 (right). The default is 0 (center). */\n    virtual void setPan(float) = 0;\n\n    /** Gets the pan.\n      The pan can range from -1 (left) to +1 (right). The default is 0 (center). */\n    virtual float getPan() const = 0;\n\n    /** Sets the pan matrix explicitly.  \n      The pan matrix determines how the left and right channels of an input are weighted during mixing.\n      Usually it is set by setPan(), but you can use setPanMatrix() if you need more control.\n      For a mono input, the left channel of the output is the input scaled by ll, and the right channel of the output is the input scaled by rr.  The off-diagonal lr and rl terms are ignored.\n      For a stereo input, the left channel of the output is the left channel of the input scaled by ll plus the right channel of the input scaled by lr.  The right channel of the output is the left channel of the input scaled by rl plus the right channel of the input scaled by rr.\n      */\n    virtual void setPanMatrix(float ll, float lr, float rl, float rr) = 0;\n\n    /** Gets the pan matrix.\n      The pan matrix determines how the left and right channels of an input are weighted during mixing.\n      Usually it is set by setPan(), but you can use setPanMatrix() if you need more control.\n      For a mono input, the left channel of the output is the input scaled by ll, and the right channel of the output is the input scaled by rr.  The off-diagonal lr and rl terms are ignored.\n      For a stereo input, the left channel of the output is the left channel of the input scaled by ll plus the right channel of the input scaled by lr.  The right channel of the output is the left channel of the input scaled by rl plus the right channel of the input scaled by rr.\n      */\n    virtual void getPanMatrix(float& ll, float& lr, float& rl, float& rr) const = 0;\n\n\n    /** Sets the pitch shift value, in half-steps.\n      This also changes the playback speed of the sound.  \n      Positive values mean higher pitch (and faster playback); lower values mean lower pitch \n      (and slower playback).  The default value is 0. \n     @par Android note: \n      This does not work for streams in formats other than .cks or Ogg Vorbis. */\n    virtual void setPitchShift(float halfSteps) = 0;\n\n    /** Gets the pitch shift value, in half-steps.\n      Positive values mean higher pitch (and faster playback); lower values mean lower pitch \n      (and slower playback).  The default value is 0. \n     @par Android note: \n      This does not work for streams in formats other than .cks or Ogg Vorbis. */\n    virtual float getPitchShift() const = 0;\n\n\n    /** Sets the playback speed.\n      Values greater than 1 mean faster playback; values less than 1 mean\n      slower playback.  The default value is 1.\n     @par Android note: \n      This does not work for streams in formats other than .cks or Ogg Vorbis. */\n    virtual void setSpeed(float) = 0;\n\n    /** Gets the playback speed.\n      Values greater than 1 mean faster playback; values less than 1 mean\n      slower playback.  The default value is 1. \n     @par Android note: \n      This does not work for streams in formats other than .cks or Ogg Vorbis. */\n    virtual float getSpeed() const = 0;\n\n\n    /** Sets the sound to be played when this sound finishes playing.\n      The next sound will play immediately, with no gaps. \n     @par Android note:\n      This does not work for streams in formats other than .cks or Ogg Vorbis. */\n    virtual void setNextSound(CkSound*) = 0;\n\n    /** Gets the sound to be played when this sound finishes playing.\n      The next sound will play immediately, with no gaps.\n     @par Android note:\n      This does not work for streams in formats other than .cks or Ogg Vorbis. */\n    virtual CkSound* getNextSound() const = 0;\n\n\n    /** Gets the total duration of the sound, in sample frames.\n      Stream sounds will return -1 if they are not ready or if the length is unknown. */\n    virtual int getLength() const = 0;\n\n    /** Gets the total duration of the sound, in milliseconds.\n      Stream sounds will return -1 if they are not ready or if the length is unknown. */\n    virtual float getLengthMs() const = 0;\n\n    /** Gets the sample rate of the sound, in Hz.\n      Stream sounds will return -1 if they are not ready. */\n    virtual int getSampleRate() const = 0;\n\n    /** Gets the number of channels in the sound (1 for mono, 2 for stereo).\n      Stream sounds will return -1 if they are not ready. */\n    virtual int getChannels() const = 0;\n\n\n    /** Sets the effect bus to which this sound's audio is sent to be processed, or\n      NULL for dry output (no effects).\n     @par Android note: \n      Effects cannot be applied to streams in formats other than .cks or Ogg Vorbis. */\n    virtual void setEffectBus(CkEffectBus*) = 0;\n\n    /** Gets the effect bus to which this sound's audio is sent to be processed, or\n      NULL for dry output (no effects).\n     @par Android note: \n      Effects cannot be applied to streams in formats other than .cks or Ogg Vorbis. */\n    virtual CkEffectBus* getEffectBus() = 0;\n\n\n    /** Sets whether 3D positioning is enabled.\n      If enabled, pan will be determined by the sound and listener positions,\n      ignoring the value set by setPan().  Volume will be attenuated based\n      on the sound and listener positions and the attenuation settings. */\n    virtual void set3dEnabled(bool) = 0;\n\n    /** Gets whether 3D positioning is enabled. \n      If enabled, pan will be determined by the sound and listener positions,\n      ignoring the value set by setPan().  Volume will be attenuated based\n      on the sound and listener positions and the attenuation settings. */\n    virtual bool is3dEnabled() const = 0;\n\n    /** Gets whether a 3D sound is virtual.\n      If, due to distance attenuation, a 3D sound's volume becomes near enough to 0\n      to be inaudible, it becomes \"virtual\".  A virtual sound is effectively paused\n      and is not processed until it would become audible again; this reduces the \n      amount of audio processing required. */\n    virtual bool isVirtual() const = 0;\n\n    /** Sets the position of the sound emitter in 3D space.\n      This is used for pan and volume calculations when 3D positioning is enabled. */\n    virtual void set3dPosition(float x, float y, float z) = 0;\n\n    /** Gets the position of the sound emitter in 3D space.\n      This is used for pan and volume calculations when 3D positioning is enabled. */\n    virtual void get3dPosition(float& x, float& y, float& z) const = 0;\n\n    /** Sets the velocity of the sound emitter in 3D space.\n      This is used for doppler shift calculations when 3D positioning is enabled.\n      The units should be the same as those used for set3dSoundSpeed(). */\n    virtual void set3dVelocity(float vx, float vy, float vz) = 0;\n\n    /** Gets the velocity of the sound emitter in 3D space.\n      This is used for doppler shift calculations when 3D positioning is enabled.\n      The units should be the same as those used for set3dSoundSpeed(). */\n    virtual void get3dVelocity(float& vx, float& vy, float& vz) const = 0;\n\n    /** Sets the listener position and rotation in 3D space. \n      This is used for pan and volume calculations when 3D positioning is enabled.\n      @param eyeX,eyeY,eyeZ           The listener's position\n      @param lookAtX,lookAtY,lookAtZ  The listener's look-at point\n      @param upX,upY,upZ              The listener's up vector\n      */\n    static void set3dListenerPosition(float eyeX, float eyeY, float eyeZ,\n                                      float lookAtX, float lookAtY, float lookAtZ,\n                                      float upX, float upY, float upZ);\n\n    /** Gets the listener position and rotation in 3D space. \n      This is used for pan and volume calculations when 3D positioning is enabled.\n      @param eyeX,eyeY,eyeZ           The listener's position\n      @param lookAtX,lookAtY,lookAtZ  The listener's look-at point\n      @param upX,upY,upZ              The listener's up vector\n      */\n    static void get3dListenerPosition(float& eyeX, float& eyeY, float& eyeZ,\n                                      float& lookAtX, float& lookAtY, float& lookAtZ,\n                                      float& upX, float& upY, float& upZ);\n\n    /** Sets the listener velocity in 3D space.\n      This is used for doppler shift calculations when 3D positioning is enabled. \n      The units should be the same as those used for set3dSoundSpeed(). */\n    static void set3dListenerVelocity(float vx, float vy, float vz);\n\n    /** Gets the listener velocity in 3D space.\n      This is used for doppler shift calculations when 3D positioning is enabled.\n      The units should be the same as those used for set3dSoundSpeed(). */\n    static void get3dListenerVelocity(float& vx, float& vy, float& vz);\n\n    /** Sets parameters used for 3D volume attenuation. \n      @param mode      The attenuation mode (default is kCkAttenuationMode_InvDistanceSquared)\n      @param nearDist  The near distance; sounds closer than this distance will not be attenuated (default is 1.0)\n      @param farDist   The far distance; sounds further than this will be at the far volume (default is 100.0)\n      @param farVol    The far volume; sounds further than farDist will be at this volume (default is 0.0)\n      */\n    static void set3dAttenuation(CkAttenuationMode mode, float nearDist, float farDist, float farVol);\n\n    /** Gets parameters used for 3D volume attenuation. \n      @param mode      The attenuation mode\n      @param nearDist  The near distance; sounds closer than this distance will not be attenuated.\n      @param farDist   The far distance; sounds further than this will be at the far volume.\n      @param farVol    The far volume; sounds further than farDist will be at this volume.\n      */\n    static void get3dAttenuation(CkAttenuationMode& mode, float& nearDist, float& farDist, float& farVol);\n\n    /** Sets the speed of sound.\n      This is used for doppler shift calculations when 3D positioning is enabled.  If no doppler\n      shift is desired, this can be set to 0 (which is the default value).\n      You may want to use the predefined constants for the speed of sound (such as \n      k_soundSpeed_MetersPerSecond); use the constant that corresponds to\n      the unit system you are using for your velocity and position values.\n      You can also exaggerate the doppler effect by using a smaller value. */\n    static void set3dSoundSpeed(float);\n\n    /** Gets the speed of sound.\n      This is used for doppler shift calculations when 3D positioning is enabled.  */\n    static float get3dSoundSpeed();\n\n    /** The speed of sound in dry air at 20 degrees C, in centimeters per second.\n      This value is provided as a convenience for CkSound::set3dSoundSpeed(). */\n    static const float k_soundSpeed_CentimetersPerSecond;\n\n    /** The speed of sound in dry air at 20 degrees C, in meters per second.\n      This value is provided as a convenience for CkSound::set3dSoundSpeed(). */\n    static const float k_soundSpeed_MetersPerSecond;\n\n    /** The speed of sound in dry air at 20 degrees C, in inches per second.\n      This value is provided as a convenience for CkSound::set3dSoundSpeed(). */\n    static const float k_soundSpeed_InchesPerSecond;\n\n    /** The speed of sound in dry air at 20 degrees C, in feet per second.\n      This value is provided as a convenience for CkSound::set3dSoundSpeed(). */\n    static const float k_soundSpeed_FeetPerSecond;\n\n    ////////////////////////////////////////\n    // bank sounds\n\n    /** Creates a sound from a bank by index. \n      This will return NULL if the index is invalid. */\n    static CkSound* newBankSound(CkBank*, int index);\n\n    /** Creates a sound from a bank by name. \n      If bank is NULL, all loaded banks are searched for the first matching sound. \n      This will return NULL if no sound with that name can be found. */\n    static CkSound* newBankSound(CkBank*, const char* name);\n\n\n    ////////////////////////////////////////\n    // streams\n\n    /** Creates a stream from a file path. \n      This will return NULL if the file could not be opened.  If a non-NULL value\n      is returned, you should also check isFailed() to find out if any errors occurred\n      during initialization.\n\n      If the stream file is embedded in a larger file, specify the offset and length of \n      the embedded data in bytes, and provide a string ending with a file extension that indicates\n      the file format of the embedded file (for example, \".mp3\" or \"music.mp3\").\n      Otherwise, leave the offset, length, and extension as 0.\n     */\n    static CkSound* newStreamSound(const char* path, CkPathType = kCkPathType_Default, int offset = 0, int length = 0, const char* extension = NULL);\n\n\n    /** Factory function for creating custom streams. \n     The function should return a CkCustomStream instance, or NULL to create a stream\n     with the default handler. */\n    typedef CkCustomStream* (*CustomStreamFunc)(const char* path, void* data);\n\n    /** Set the stream handler.\n      Set it to NULL to use the default handler. */\n    static void setCustomStreamHandler(CustomStreamFunc, void* data);\n\n\n\n#if CK_PLATFORM_IOS\n    /** Creates a stream from a URL for an asset in the iTunes library. \n      The URL should be determined using an MPMediaQuery object; see the\n      \"iPod Library Access Programming Guide\" document in the iOS Developer Library.\n      Note that this will only work for music files without DRM; for files with DRM, the URL will be returned as nil.\n      @par Only available on iOS version 4.3 or later; will return NULL on earlier iOS versions.\n     */\n    static CkSound* newAssetStreamSound(const char* url);\n#endif\n\n\n    /** Destroys the sound. */\n    virtual void destroy() = 0;\n\nprotected:\n    CkSound() {}\n    virtual ~CkSound() {}\n\nprivate:\n    CkSound(const CkSound&);\n    CkSound& operator=(const CkSound&);\n};\n\n\n/** @} */\n"
  },
  {
    "path": "Libraries/CricketAudio/RPi/Headers/ck/attenuationmode.h",
    "content": "// Copyright 2016 Cricket Technology\n// www.crickettechnology.com\n/** @file */\n/** @defgroup CkAttenuationMode CkAttenuationMode */\n/** @{ */\n\n#pragma once\n#include \"ck/platform.h\"\n\n\n/** Indicates how volume on 3D sounds is attenuated with distance. */\ntypedef enum \n{\n\n    /** No attenuation; volume is 1.0 when closer than the far distance, and far volume outside of that. */\n    kCkAttenuationMode_None = 0,\n\n    /** Linear attenuation of volume between near distance and far distance. */\n    kCkAttenuationMode_Linear,\n\n    /** Attenuation proportional to the reciprocal of the distance. */\n    kCkAttenuationMode_InvDistance,\n\n    /** Attenuation proportional to the square of the reciprocal of the distance. \n     This is a good choice for realistically simulating point sound sources. */\n    kCkAttenuationMode_InvDistanceSquared,\n\n} CkAttenuationMode;\n\n/** @} */\n\n"
  },
  {
    "path": "Libraries/CricketAudio/RPi/Headers/ck/bank.h",
    "content": "// Copyright 2016 Cricket Technology\n// www.crickettechnology.com\n/** @file */\n/** @defgroup CkBank CkBank */\n/** @{ */\n\n#pragma once\n#include \"ck/platform.h\"\n#include \"ck/pathtype.h\"\n\n\n/** A bank of memory-resident sounds. */\n\nclass CkBank\n{\npublic:\n    /** Returns true when an asynchronously loaded bank has finished loading. */\n    virtual bool isLoaded() const = 0;\n\n    /** Returns true if an asynchronously loaded bank had an error during loading. */\n    virtual bool isFailed() const = 0;\n\n    /** Returns the name of the bank. */\n    virtual const char* getName() const = 0;\n\n    /** Returns the number of sounds in the bank. */\n    virtual int getNumSounds() const = 0;\n\n    /** Returns the name of a sound in this bank.\n      The name will be 31 characters or less. */\n    virtual const char* getSoundName(int index) const = 0;\n\n\n    ////////////////////////////////////////\n\n    /** Loads a bank. \n\n      This will return NULL if the bank cannot be loaded.\n\n      If the bank file is embedded in a larger file, specify the offset and \n      length of the embedded data; otherwise, leave them both as 0.\n     */\n    static CkBank* newBank(const char* path, CkPathType = kCkPathType_Default, int offset = 0, int length = 0);\n\n    /** Loads a bank asynchronously. \n\n      This will return NULL if the bank cannot be loaded.\n      When loading a bank asynchronously, you should also check isFailed()\n      after loading to make sure no errors occurred.\n\n      If the bank file is embedded in a larger file, specify the offset and \n      length of the embedded data; otherwise, leave them both as 0.\n      */\n    static CkBank* newBankAsync(const char* path, CkPathType = kCkPathType_Default, int offset = 0, int length = 0);\n\n    /** Loads a bank from a memory buffer. \n\n      The buffer should contain entire bank file; you are responsible for\n      freeing the memory after the bank is deleted. \n\n      This will return NULL if the bank cannot be loaded.\n      */\n    static CkBank* newBankFromMemory(void*, int bytes);\n\n\n    /** Finds a loaded bank by name; returns NULL if not found. */\n    static CkBank* find(const char* bankName);\n\n    /** Destroys the bank. */\n    virtual void destroy() = 0;\n\nprotected:\n    CkBank() {}\n    virtual ~CkBank() {}\n\nprivate:\n    CkBank(const CkBank&);\n    CkBank& operator=(const CkBank&);\n};\n\n/** @} */\n"
  },
  {
    "path": "Libraries/CricketAudio/RPi/Headers/ck/ck.h",
    "content": "// Copyright 2016 Cricket Technology\n// www.crickettechnology.com\n/** @file */\n/** @defgroup Ck Ck */\n/** @{ */\n\n#pragma once\n#include \"ck/config.h\"\n#include \"ck/pathtype.h\"\n\n#ifdef __cplusplus\nextern \"C\"\n{\n#endif\n\n/** Initializes Cricket Audio. Returns nonzero if successful. */\nint CkInit(CkConfig*);\n\n/** Updates Cricket Audio.\n  Should be called once per frame. */\nvoid CkUpdate();\n\n/** Shuts down Cricket Audio. */\nvoid CkShutdown();\n\n/** Suspends Cricket Audio; typically used when an app is made inactive. */\nvoid CkSuspend();\n\n/** Resumes Cricket Audio; typically used when an app is made active after having been inactive. */\nvoid CkResume();\n\n\n/** Returns a rough estimate of the load on the audio processing thread.\n  This is the fraction of the interval between audio callbacks that was actually spent\n  rendering audio; it will range between 0 and 1. */\nfloat CkGetRenderLoad();\n\n\n/** Returns the value of the clip flag.\n  The clip flag is set to true whenever the final audio output \"clips\", i.e. \n  exceeds the maximum value. */\nbool CkGetClipFlag();\n\n/** Resets the value of the clip flag to false.  \n  The clip flag is set to true whenever the final audio output \"clips\", i.e. \n  exceeds the maximum value. */\nvoid CkResetClipFlag();\n\n\n/** Sets the maximum rate at which volumes change on playing sounds, in ms per full volume scale. \n  Default value is 40 ms. */\nvoid CkSetVolumeRampTime(float ms);\n\n/** Gets the maximum rate at which volumes change on playing sounds, in ms per full volume scale. */\nfloat CkGetVolumeRampTime();\n\n/** Default value of volume ramp time. */\nextern const float Ck_volumeRampTimeMsDefault;\n\n\n/** Lock the audio processing thread to prevent it from processing any API calls.\n  The lock should be held only for a short time.  This is useful to ensure that\n  certain calls are processed together.  For example, if you want to play multiple\n  sounds together exactly in sync, call CkLockAudio(), call play() on each sound,\n  then call CkUnlockAudio(). */\nvoid CkLockAudio();\n\n/** Unlock the audio processing thread after a call to CkLockAudio(). */\nvoid CkUnlockAudio();\n\n\n/** Start capturing the final audio output to a file.  The filename must end with \".wav\" \n  (for a Microsoft WAVE file) or \".raw\" (for a headerless file containing 32-bit floating-point \n  interleaved stereo samples). */\nvoid CkStartCapture(const char* path, CkPathType pathType);\n\n/** Stop capturing audio output. */\nvoid CkStopCapture();\n\n\n#ifdef __cplusplus\n} // extern \"C\"\n#endif\n\n/** @} */\n"
  },
  {
    "path": "Libraries/CricketAudio/RPi/Headers/ck/config.h",
    "content": "// Copyright 2016 Cricket Technology\n// www.crickettechnology.com\n/** @file */\n/** @defgroup CkConfig CkConfig */\n/** @{ */\n\n#pragma once\n#include \"ck/platform.h\"\n\n#if CK_PLATFORM_ANDROID\n#  include <jni.h>\n#endif\n\n////////////////////////////////////////\n\n/** Memory allocation function */\ntypedef void* (*CkAllocFunc)(int bytes);\n/** Memory deallocation function */\ntypedef void (*CkFreeFunc)(void*);\n\n\n/** Log message types */\ntypedef enum \n{\n    /** Flag to enable INFO log messages */\n    kCkLog_Info =  (1 << 0),\n\n    /** Flag to enable WARNING log messages */\n    kCkLog_Warning = (1 << 1),\n\n    /** Flag to enable ERROR log messages */\n    kCkLog_Error = (1 << 2),\n\n    /** Flag to disable all log messages */\n    kCkLog_None = 0,\n\n    /** Flag to enable all log messages */\n    kCkLog_All = (kCkLog_Info | kCkLog_Warning | kCkLog_Error)\n\n} CkLogType;\n\n\n/** Log message function */\ntypedef void (*CkLogFunc)(CkLogType, const char* msg);\n\n\n/** Sample types used for internal DSP pipeline */\ntypedef enum\n{\n    /** Force floating-point samples */\n    kCkSampleType_Float,\n\n    /** Force fixed-point samples */\n    kCkSampleType_Fixed,\n    \n    /** Use the default, based on the processor type */\n    kCkSampleType_Default\n\n} CkSampleType;\n\n\n////////////////////////////////////////\n\n/** Configuration options */\nstruct _CkConfig\n{\n#ifdef __cplusplus\n#  if CK_PLATFORM_ANDROID\n    /** Constructor to be used from JNI functions.\n      @param env      A JNI environment pointer\n      @param context  An android.content.Context object from Java (typically an\n                       android.app.Activity or android.app.Service)\n     */\n    _CkConfig(JNIEnv* env, jobject context);\n\n    /** This constructor should be used when there is no valid JNIEnv* pointer; for\n      example, from android_main() in a native activity using the android_native_app_glue\n      library.  See the code in src/samples/hellocricket/android-ndk-native for an example.\n      @param vm       A Java VM pointer\n      @param context  An android.content.Context object from Java (typically an\n                       android.app.Activity or android.app.Service)\n     */\n    _CkConfig(JavaVM* vm, jobject context);\n#  else\n    _CkConfig();\n#  endif\n#endif // __cplusplus\n\n#if CK_PLATFORM_ANDROID\n    /** The JNIEnv pointer.\n      @par Only available on Android. */\n    JNIEnv* jni;\n\n    /** The JavaVM pointer.\n      @par Only available on Android. */\n    JavaVM* vm;\n\n    /** A Java reference to your app's Context object (typically an Activity or Service).\n      @par Only available on Android. */\n    jobject context;\n\n    /** If true, always use Java AudioTrack for output of final mix, instead of OpenSL ES.\n      This should usually be set to false, unless you are debugging specific issues\n      related to low-level audio output.\n      Default is false (use Java AudioTrack only when OpenSL ES is not available, i.e. Android versions prior to 2.3). \n      @par Only available on Android. */\n    bool useJavaAudio;\n\n    /** If true, software support for Ogg Vorbis stream sounds is enabled.\n      If false, stream sounds will use the native Android decoder, which will not\n      support all of the features available to sounds decoded in software.\n      Default is true (Ogg Vorbis streams are decoded in software).\n      @par Only available on Android. */\n    bool enableOggVorbis;\n#endif\n\n#if CK_PLATFORM_IOS || CK_PLATFORM_TVOS\n    /** If true, hardware-assisted decoding is enabled for decoding compressed streams\n      when available.  See Apple's \"Multimedia Programming Guide\" for a list of codecs\n      for which hardware support is available.  Note that streams that use the hardware\n      decoder take slightly longer (~300ms) to initialize, and our tests have shown\n      a negligible effect on CPU usage, so the default value is false.\n      @par Only available on iOS. */\n    bool enableHardwareDecoding;\n#endif\n\n    /** Memory allocation function.\n      Default is NULL (system new will be used). \n      The allocator must be thread-safe. */\n    CkAllocFunc allocFunc;\n\n    /** Memory deallocation function.\n      Default is NULL (system delete will be used). \n      The allocator must be thread-safe. */\n    CkFreeFunc freeFunc;\n\n\n    /** Bitmask for which types of messages are logged. \n      Default is kCkLog_All (all messages logged). */\n    unsigned int logMask;\n\n    /** Function to handle log messages.\n      Default is NULL (printf or equivalent will be used). */\n    CkLogFunc logFunc;\n\n\n    /** Audio processing frame duration, in ms.\n      Shorter times result in lower latency, but require more CPU.\n      Default is 5 ms. */\n    float audioUpdateMs;\n\n    /** Size of buffer for stream sounds, in ms.\n      Larger buffers require more memory, but are less likely\n      to skip due to slow file reads.\n      Default is 500 ms. */\n    float streamBufferMs;\n\n    /** Interval between file reads for stream sounds, in ms.\n      Shorter times will allow for smaller stream buffer sizes, but require more CPU.\n      This value should be set to significantly less than streamBufferMs, or your buffers will always underrun!\n      Default is 100 ms. */\n    float streamFileUpdateMs;\n\n    /** Initial size of the audio task buffer.  If you see a \"Reallocating\n      audio task buffer\" warning, consider increasing this from its default value\n      of 500 to avoid additional memory allocations at runtime. */\n    int maxAudioTasks;\n\n    /** Maximum render load. When the value of CkGetRenderLoad() exceeds this value,\n      some sounds will not be rendered, to keep the CPU usage down.\n      Default is 0.8. */\n    float maxRenderLoad;\n\n    /** Sample type to be used internally for processing.  The default is \n      kCkSampleType_Default, which means that fixed-point samples are used on Android \n      armv5 and armv6 devices, which may lack hardware support for floating-point \n      operations, and that floating-point samples are used on all other devices. */\n    CkSampleType sampleType;\n};\n\ntypedef struct _CkConfig CkConfig;\n\n/** Default value of CkConfig.audioUpdateMs */\nextern const float CkConfig_audioUpdateMsDefault;\n\n/** Default value of CkConfig.streamBufferMs */\nextern const float CkConfig_streamBufferMsDefault;\n\n/** Default value of CkConfig.streamFileUpdateMs */\nextern const float CkConfig_streamFileUpdateMsDefault;\n\n/** Default value of CkConfig.maxAudioTasks */\nextern const int CkConfig_maxAudioTasksDefault;\n\n/** Default value of CkConfig.maxRenderLoad */\nextern const float CkConfig_maxRenderLoadDefault;\n\n////////////////////////////////////////\n\n#ifdef __OBJC__\n\n/** If you are using Objective-C, call CkConfigInit() to initialize the CkConfig\n  struct to its default values.\n  (If you are using C++, the CkConfig struct is initialized by its constructor.) */\n\n#ifdef __cplusplus\nextern \"C\"\n#endif\nvoid CkConfigInit(CkConfig*);\n\n#endif\n\n/** @} */\n"
  },
  {
    "path": "Libraries/CricketAudio/RPi/Headers/ck/customfile.h",
    "content": "// Copyright 2016 Cricket Technology\n// www.crickettechnology.com\n/** @file */\n/** @defgroup CkCustomFile CkCustomFile */\n/** @{ */\n\n#pragma once\n#include \"ck/platform.h\"\n#include \"ck/pathtype.h\"\n\n\n/** Custom file base class.  \n  \n  If you want to override the low-level details of how \n  files are read (for example, to read files over a network, or to decrypt encrypted\n  files as they are read), create a subclass and register a handler with \n  CkSetCustomFileHandler().\n\n  This will work for bank files, and for .cks and Ogg Vorbis streams, but not for\n  other stream types such as MP3, AAC, etc. */\n\nclass CkCustomFile\n{\npublic:\n    virtual ~CkCustomFile() {}\n\n    /** Returns true if the file was successfully opened. */\n    virtual bool isValid() const = 0;\n\n    /** Read from the file.  Returns number of bytes actually read. */\n    virtual int read(void* buf, int bytes) = 0;\n\n    /** Returns the size of the file. */\n    virtual int getSize() const = 0;\n\n    /** Sets the read position in the file. */\n    virtual void setPos(int pos) = 0;\n\n    /** Returns the read position in the file. */\n    virtual int getPos() const = 0;\n};\n\n\n/** Factory function for opening files using a CkCustomFile instance.\n  The function should return CkCustomFile instance, or NULL to open \n  the file with the default handler. */\ntypedef CkCustomFile* (*CkCustomFileFunc)(const char* path, void* data);\n\n/** Set the file handler. \n  Set it to NULL to use the default handler. */\nvoid CkSetCustomFileHandler(CkCustomFileFunc, void* data);\n\n\n/** @} */\n\n\n"
  },
  {
    "path": "Libraries/CricketAudio/RPi/Headers/ck/customstream.h",
    "content": "// Copyright 2016 Cricket Technology\n// www.crickettechnology.com\n/** @file */\n/** @defgroup CkCustomStream CkCustomStream */\n/** @{ */\n\n#pragma once\n#include \"ck/platform.h\"\n\n\n/** Base class for custom streams.\n  To create a custom stream sound (for example, for playing back audio in\n  a proprietary file format), create a subclass, then register a factory\n  function with CkSound::setCustomStreamHandler(). */\n\nclass CkCustomStream\n{\npublic:\n    virtual ~CkCustomStream() {}\n\n    /** Initializes the stream (open data files, read file headers, etc).\n    This is called from the file streaming thread, not the main thread,\n    so synchronous file reading calls will not block audio or application logic. */\n    virtual void init() = 0;\n\n    /** Returns whether the stream has failed in a way that renders it\n      unusable; for example, if an audio file could not be found. */\n    virtual bool isFailed() const = 0;\n\n    /** Returns the number of channels; should be either 1 or 2. */\n    virtual int getChannels() const = 0;\n\n    /** Returns the sample rate of the audio. */\n    virtual int getSampleRate() const = 0;\n\n    /** Returns the total duration of the sound, in sample frames. */\n    virtual int getLength() const = 0;\n\n    /** Reads audio into the buffer; returns the number of sample frames\n      actually read. The audio data should be 16-bit signed PCM. */\n    virtual int read(short* buf, int frames) = 0;\n\n    /** Sets the current play position, in sample frames. */\n    virtual void setPlayPosition(int frame) = 0;\n\n    /** Returns the current play position, in sample frames. */\n    virtual int getPlayPosition() const = 0;\n\n};\n\n\n/** @} */\n\n"
  },
  {
    "path": "Libraries/CricketAudio/RPi/Headers/ck/effect.h",
    "content": "// Copyright 2016 Cricket Technology\n// www.crickettechnology.com\n/** @file */\n/** @defgroup CkEffect CkEffect */\n/** @{ */\n\n#pragma once\n#include \"ck/platform.h\"\n#include \"ck/effecttype.h\"\n#include <stddef.h>\n\nclass CkEffectProcessor;\n\n\n/** An audio effect. */\nclass CkEffect\n{\npublic:\n    /** Set an effect parameter. \n      Parameter IDs are found in ck/effectparam.h. */\n    virtual void setParam(int paramId, float value) = 0;\n\n\n    /** Reset the state of this effect. */\n    virtual void reset() = 0;\n\n\n    /** Set whether this effect is bypassed.\n      A bypassed effect is not applied to the audio. */\n    virtual void setBypassed(bool) = 0;\n\n    /** Gets whether this effect is bypassed.\n      A bypassed effect is not applied to the audio. */\n    virtual bool isBypassed() const = 0;\n\n\n    /** Sets the wet/dry ratio for this effect\n      The ratio can range from 0 to 1.\n      A value of 0 means the audio is left completely \"dry\", that is, with no\n      effects applied; it is equivalent to bypassing the ffect.\n      A value of 1 means the audio is completely \"wet\", that is, the original\n      \"dry\" signal is not mixed back into the processed audio. */\n    virtual void setWetDryRatio(float) = 0;\n\n    /** Gets the wet/dry ratio for this effect.\n      The ratio can range from 0 to 1.\n      A value of 0 means the audio is left completely \"dry\", that is, with no\n      effects applied; it is equivalent to bypassing the effect.\n      A value of 1 means the audio is completely \"wet\", that is, the original\n      \"dry\" signal is not mixed back into the processed audio. */\n    virtual float getWetDryRatio() const = 0;\n\n\n    /** Create a built-in effect. \n      Effect types are found in ck/effecttype.h. */\n    static CkEffect* newEffect(CkEffectType);\n\n\n    /** Factory function for creating effect processors for custom effects. */\n    typedef CkEffectProcessor* (*CustomEffectFunc)(void* arg);\n\n    /** Register a custom effect. \n     To unregister an effect, pass in NULL for the CustomEffectFunc. */\n    static void registerCustomEffect(int id, CustomEffectFunc);\n\n    /** Create a custom effect.\n      A factory function must have been previously registered with the given id,\n      or this will return NULL. */\n    static CkEffect* newCustomEffect(int id, void* arg = NULL);\n\n\n    /** Destroy the effect. */\n    virtual void destroy() = 0;\n\nprotected:\n    CkEffect() {}\n    virtual ~CkEffect() {}\n\nprivate:\n    CkEffect(const CkEffect&);\n    CkEffect& operator=(const CkEffect&);\n};\n\n\n/** @} */\n"
  },
  {
    "path": "Libraries/CricketAudio/RPi/Headers/ck/effectbus.h",
    "content": "// Copyright 2016 Cricket Technology\n// www.crickettechnology.com\n/** @file */\n/** @defgroup CkEffectBus CkEffectBus */\n/** @{ */\n\n#pragma once\n#include \"ck/platform.h\"\n\n\nclass CkEffect;\n\n/** Manages a set of audio effects applied to sounds. */\nclass CkEffectBus\n{\npublic:\n\n    /** Add an effect to this bus.\n      An effect can only be on one bus at a time. */\n    virtual void addEffect(CkEffect*) = 0;\n\n    /** Remove an effect from this bus. */\n    virtual void removeEffect(CkEffect*) = 0;\n\n    /** Remove all effects from this bus. */\n    virtual void removeAllEffects() = 0;\n\n\n    /** Set the bus to which this bus's output is sent.\n      If NULL (the default), the audio from this bus is mixed into the final output. */\n    virtual void setOutputBus(CkEffectBus*) = 0;\n\n    /** Get the bus to which this bus's output is sent.\n      If NULL (the default), the audio from this bus is mixed into the final output. */\n    virtual CkEffectBus* getOutputBus() = 0;\n\n\n    /** Reset the state of all the effects on this bus. */\n    virtual void reset() = 0;\n\n\n    /** Set whether this bus is bypassed.\n      A bypassed effect is not applied to the audio. */\n    virtual void setBypassed(bool) = 0;\n\n    /** Gets whether this bus is bypassed.\n      Effects in a bypassed bus are not applied to the audio. */\n    virtual bool isBypassed() const = 0;\n\n\n    /** Sets the wet/dry ratio for this bus.\n      The ratio can range from 0 to 1.\n      A value of 0 means the audio is left completely \"dry\", that is, with no\n      effects applied; it is equivalent to bypassing the bus.\n      A value of 1 means the audio is completely \"wet\", that is, the original\n      \"dry\" signal is not mixed back into the processed audio. */\n    virtual void setWetDryRatio(float) = 0;\n\n    /** Gets the wet/dry ratio for this bus.\n      The ratio can range from 0 to 1.\n      A value of 0 means the audio is left completely \"dry\", that is, with no\n      effects applied; it is equivalent to bypassing the bus.\n      A value of 1 means the audio is completely \"wet\", that is, the original\n      \"dry\" signal is not mixed back into the processed audio. */\n    virtual float getWetDryRatio() const = 0;\n\n    ////////////////////////////////////////\n\n    /** Create a new effect bus. */\n    static CkEffectBus* newEffectBus();\n\n    /** Get the global effect bus.\n      Effects on this bus are applied to the final audio before it is output. */\n    static CkEffectBus* getGlobalEffectBus();\n\n    /** Destroy this effect bus. */\n    virtual void destroy() = 0;\n\nprotected:\n    CkEffectBus() {}\n    virtual ~CkEffectBus() {}\n\nprivate:\n    CkEffectBus(const CkEffectBus&);\n    CkEffectBus& operator=(const CkEffectBus&);\n\n};\n\n/** @} */\n\n"
  },
  {
    "path": "Libraries/CricketAudio/RPi/Headers/ck/effectparam.h",
    "content": "// Copyright 2016 Cricket Technology\n// www.crickettechnology.com\n/** @file */\n/** @defgroup CkEffectParam CkEffectParam */\n/** @{ */\n\n#pragma once\n#include \"ck/platform.h\"\n\n/** Parameters for the Biquad Filter effect */\nenum\n{\n    /** Type of filter; should be one of the kCkBiquadFilterParam_FilterType values. */\n    kCkBiquadFilterParam_FilterType,\n\n    /** Center frequency of the filter. */\n    kCkBiquadFilterParam_Freq,\n\n    /** Q of the filter. */\n    kCkBiquadFilterParam_Q,\n\n    /** Gain in dB (for Peak, LowShelf, and HighShelf filter types) */\n    kCkBiquadFilterParam_Gain,\n};\n\n\n/** Filter types, used for the kCkBiquadFilterParam_FilterType param. */\nenum\n{\n    /** Low pass filter blocks high frequencies. */\n    kCkBiquadFilterParam_FilterType_LowPass,\n\n    /** High pass filter blocks low frequencies. */\n    kCkBiquadFilterParam_FilterType_HighPass,\n    \n    /** Band pass filter blocks frequencies above and below the center frequency. */\n    kCkBiquadFilterParam_FilterType_BandPass,\n\n    /** Notch filter blocks a narrow band of frequencies. */\n    kCkBiquadFilterParam_FilterType_Notch,\n\n    /** Peak filter boosts a narrow band of frequencies. */\n    kCkBiquadFilterParam_FilterType_Peak,\n\n    /** Low shelf filter boosts low frequencies. */\n    kCkBiquadFilterParam_FilterType_LowShelf,\n\n    /** High shelf filter boosts high frequencies. */\n    kCkBiquadFilterParam_FilterType_HighShelf\n};\n\n\n////////////////////////////////////////\n\n\n/** Parameters for the Bit Crusher effect */\nenum\n{\n    /** Number of bits of resolution to keep in the input samples, in [1..24]. */\n    kCkBitCrusherParam_BitResolution,\n\n    /** Milliseconds to hold each sample value.  Higher values result in more\n      reduction in the effective sample rate.  Values around 1 ms provide a reasonable effect. */\n    kCkBitCrusherParam_HoldMs,\n};\n\n\n////////////////////////////////////////\n\n\n/** Parameters for the Ring Mod effect */\nenum\n{\n    /** Frequency (Hz) of the modulating signal. Values around 500 Hz are typical. */\n    kCkRingModParam_Freq,\n};\n\n////////////////////////////////////////\n\n\n/** Parameters for the Distortion effect */\nenum\n{\n    /** Scale factor for input; larger values cause a more pronounced effect. */\n    kCkDistortionParam_Drive,\n\n    /** Offset for input. */\n    kCkDistortionParam_Offset,\n};\n\n\n\n\n/** @} */\n\n\n"
  },
  {
    "path": "Libraries/CricketAudio/RPi/Headers/ck/effectprocessor.h",
    "content": "// Copyright 2016 Cricket Technology\n// www.crickettechnology.com\n/** @file */\n/** @defgroup CkEffectProcessor CkEffectProcessor */\n/** @{ */\n\n#pragma once\n#include \"ck/platform.h\"\n\n/** Performs audio processing for effects.\n\n  To implement your own custom audio effects, create a subclass, then register a factory\n  function that creates an instance of it with CkEffect::registerCustomEffect(). */\n\nclass CkEffectProcessor\n{\npublic:\n    virtual ~CkEffectProcessor() {}\n\n    /** Set an effect parameter.\n      Note that this should not be called directly; it is called by CkEffect::setParam(). */\n    virtual void setParam(int paramId, float value) = 0;\n\n    /** Reset this effect's state. */\n    virtual void reset() = 0;\n\n    /** If true, the effect is processed in-place; the input and output will be the\n      same buffer.  If false, input and output will be separate buffers. */\n    virtual bool isInPlace() const = 0;\n\n    /** Process audio.\n      The buffer contains interleaved stereo data; each sample is a signed 8.24 fixed-point value.\n      If isInPlace() returns true, inBuf and outBuf will be pointers to the same buffer. \n      It is OK to modify the data in inBuf, even if the effect is not in-place.\n      (Remember that because the data is stereo, the number of samples is 2*frames.) \n\n      @par This will only be called on older Android armv5 or armv6 devices, or if CkConfig.sampleType is set to kCkSampleType_Fixed.\n      If you are not supporting those devices, you may leave this with its default implementation, which passes the audio \n      through unchanged. */\n    virtual void process(int* inBuf, int* outBuf, int frames);\n\n    /** Process audio.\n      The buffer contains interleaved stereo data; each sample is a 32-bit floating-point value.\n      If isInPlace() returns true, inBuf and outBuf will be pointers to the same buffer. \n      It is OK to modify the data in inBuf, even if the effect is not in-place.\n      (Remember that because the data is stereo, the number of samples is 2*frames.) */\n    virtual void process(float* inBuf, float* outBuf, int frames) = 0;\n\n    /** Get the sample rate of the audio data.  This value may be different on different\n      devices, but will not change during app execution. */\n    static int getSampleRate();\n};\n\n\n/** @} */\n\n"
  },
  {
    "path": "Libraries/CricketAudio/RPi/Headers/ck/effecttype.h",
    "content": "// Copyright 2016 Cricket Technology\n// www.crickettechnology.com\n/** @file */\n/** @defgroup CkEffectType CkEffectType */\n/** @{ */\n\n#pragma once\n#include \"ck/platform.h\"\n\n/** Types of built-in effects available */\ntypedef enum \n{\n    /** Biquadratic filter. \n      See kCkBiquadFilterParam values for parameter IDs. */\n    kCkEffectType_BiquadFilter,\n\n    /** Bit Crusher effect reduces bit resolution and/or bit rate, producing a retro\n      low-fi 8-bit sound.\n      See kCkBitCrusherParam values for parameter IDs. */\n    kCkEffectType_BitCrusher,\n\n    /** Ring Mod effect modulates the audio by a sine wave. \n      See kCkRingModParam values for parameter IDs. */\n    kCkEffectType_RingMod,\n\n    /** Distortion effect.\n      See kCkDistortionParam values for parameter IDs. */\n    kCkEffectType_Distortion,\n\n} CkEffectType;\n\n\n/** @} */\n"
  },
  {
    "path": "Libraries/CricketAudio/RPi/Headers/ck/mixer.h",
    "content": "// Copyright 2016 Cricket Technology\n// www.crickettechnology.com\n/** @file */\n/** @defgroup CkMixer CkMixer */\n/** @{ */\n\n#pragma once\n#include \"ck/platform.h\"\n#include <stddef.h>\n\n\n/** A mixer represents a hierarchical grouping of sounds for controlling volumes. */\n\nclass CkMixer\n{\npublic:\n    /** Set the name of the mixer.\n      The name should be 31 characters or less. */\n    virtual void setName(const char*) = 0;\n\n    /** Get the name of the mixer. */\n    virtual const char* getName() const = 0;\n\n\n    /** Set the volume of this mixer.\n      (The actual volume used during mixing will also depend on ancestors.) */\n    virtual void setVolume(float) = 0;\n\n    /** Get the volume of this mixer.\n      (The actual volume used during mixing will also depend on ancestors.) */\n    virtual float getVolume() const = 0;\n\n\n    /** Get the volume used for mixing (affected by ancestors). */\n    virtual float getMixedVolume() const = 0;\n\n\n    /** Set whether this mixer is paused.\n      A sound will be paused if the sound, its mixer, or any of its mixer's ancestors\n      are paused. */\n    virtual void setPaused(bool) = 0;\n\n    /** Get whether this mixer is paused.\n      A sound will be paused if the sound, its mixer, or any of its mixer's ancestors\n      are paused. */\n    virtual bool isPaused() const = 0;\n\n\n    /** Returns true if this mixer, or any of its ancestors, is paused. */\n    virtual bool getMixedPauseState() const = 0;\n\n\n    /** Set the parent of the mixer.\n      Setting to NULL sets the master mixer as the parent. */\n    virtual void setParent(CkMixer*) = 0;\n\n    /** Get the parent of the mixer. */\n    virtual CkMixer* getParent() = 0;\n\n\n    /** Returns the master mixer, which is the root of the mixer hierarchy. */\n    static CkMixer* getMaster();\n\n    /** Creates a new mixer. */\n    static CkMixer* newMixer(const char* name, CkMixer* parent = NULL);\n\n    /** Finds a mixer by name; returns NULL if not found. */\n    static CkMixer* find(const char* name);\n\n\n    /** Destroys the mixer. */\n    virtual void destroy() = 0;\n\nprotected:\n    CkMixer() {}\n    virtual ~CkMixer() {}\n\nprivate:\n    CkMixer(const CkMixer&);\n    CkMixer& operator=(const CkMixer&);\n};\n\n/** @} */\n"
  },
  {
    "path": "Libraries/CricketAudio/RPi/Headers/ck/pathtype.h",
    "content": "// Copyright 2016 Cricket Technology\n// www.crickettechnology.com\n/** @file */\n/** @defgroup CkPathType CkPathType */\n/** @{ */\n\n#pragma once\n#include \"ck/platform.h\"\n\n\n/** Indicates how a file path should be interpreted. */\ntypedef enum \n{\n    /** A full path to a file on the file system. */\n    kCkPathType_FileSystem = 0,\n\n#if CK_PLATFORM_ANDROID\n    /** A path to an asset in the .apk. \n      Assets are read-only.\n     @par Only available on Android. */\n    kCkPathType_Asset,\n\n    /** A path relative to the private files directory.\n     @par Only available on Android. */\n    kCkPathType_PrivateFiles,\n\n    /** A path relative to the external storage directory.\n     @par Only available on Android. */\n    kCkPathType_ExternalStorage,\n#endif\n\n#if CK_PLATFORM_IOS || CK_PLATFORM_OSX || CK_PLATFORM_TVOS\n    /** A path relative to the application's resource directory.\n      On iOS, the resource directory is the application bundle, and is read-only.\n      On OS X, the resource directory is the directory containing the executable.\n     @par Only available on iOS and OS X. */\n    kCkPathType_Resource,\n#endif\n\n#if CK_PLATFORM_WP8\n    /** A path relative to the local app data store.\n     @par Only available on Windows Phone 8. */\n    kCkPathType_LocalDir,\n\n    /** A path relative to the folder containing your app's package files.\n      Files in your Visual Studio project with the \"Content\" property set to true will be installed here.\n      This folder is read-only.\n     @par Only available on Windows Phone 8. */\n    kCkPathType_InstallationDir,\n#endif\n\n#if CK_PLATFORM_IOS || CK_PLATFORM_OSX || CK_PLATFORM_TVOS || CK_PLATFORM_WIN || CK_PLATFORM_LINUX\n    /** A path relative to the directory used for temporary files.\n     @par Only available on iOS, OS X, Windows, and Linux. */\n    kCkPathType_Temp,\n#endif\n\n#if CK_PLATFORM_IOS || CK_PLATFORM_OSX || CK_PLATFORM_WIN || CK_PLATFORM_LINUX\n    /** A path relative to the application's documents directory.\n      On iOS, this is the app's Documents directory.\n      On OS X and Windows, this is the user's Documents directory.\n      On Linux, this is the user's home directory.\n     @par Only available on iOS, OS X, Windows, and Linux. */\n    kCkPathType_Documents,\n#endif\n\n#if CK_PLATFORM_WIN || CK_PLATFORM_LINUX || CK_PLATFORM_OSX\n    /** A path relative to the executable's directory. \n     (On OS X, this is the same as kCkPathType_Resource.) \n     @par Only available on Windows, Linux, and OS X.  */\n    kCkPathType_ExeDir,\n#endif\n\n    /** The default path type for reading files. */\n#if CK_PLATFORM_ANDROID\n    kCkPathType_ReadDefault = kCkPathType_Asset,\n#elif CK_PLATFORM_IOS || CK_PLATFORM_OSX || CK_PLATFORM_TVOS\n    kCkPathType_ReadDefault = kCkPathType_Resource,\n#elif CK_PLATFORM_WIN || CK_PLATFORM_LINUX\n    kCkPathType_ReadDefault = kCkPathType_ExeDir,\n#elif CK_PLATFORM_WP8\n    kCkPathType_ReadDefault = kCkPathType_InstallationDir,\n#endif\n\n    /** The default path type for writing files. */\n#if CK_PLATFORM_ANDROID\n    kCkPathType_WriteDefault = kCkPathType_PrivateFiles,\n#elif CK_PLATFORM_IOS || CK_PLATFORM_OSX \n    kCkPathType_WriteDefault = kCkPathType_Documents,\n#elif CK_PLATFORM_TVOS\n    kCkPathType_WriteDefault = kCkPathType_Temp,\n#elif CK_PLATFORM_WIN || CK_PLATFORM_LINUX\n    kCkPathType_WriteDefault = kCkPathType_ExeDir,\n#elif CK_PLATFORM_WP8\n    kCkPathType_WriteDefault = kCkPathType_LocalDir,\n#endif\n\n    /** The default path type. */\n    kCkPathType_Default = kCkPathType_ReadDefault\n\n} CkPathType;\n\n/** @} */\n"
  },
  {
    "path": "Libraries/CricketAudio/RPi/Headers/ck/platform.h",
    "content": "// Copyright 2016 Cricket Technology\n// www.crickettechnology.com\n/** @file */\n\n#pragma once\n\n// software platform\n#undef CK_PLATFORM_IOS\n#undef CK_PLATFORM_TVOS\n#undef CK_PLATFORM_ANDROID\n#undef CK_PLATFORM_OSX\n#undef CK_PLATFORM_WIN\n#undef CK_PLATFORM_WP8\n#undef CK_PLATFORM_LINUX\n\n#ifdef __APPLE__\n#  include <TargetConditionals.h>\n#  if TARGET_OS_IPHONE\n#    if TARGET_OS_IOS\n#      define CK_PLATFORM_IOS 1\n#    elif TARGET_OS_TV\n#      define CK_PLATFORM_TVOS 1\n#    endif\n#  else\n#    define CK_PLATFORM_OSX 1\n#  endif\n#elif defined(__ANDROID__)\n#  define CK_PLATFORM_ANDROID 1\n#elif defined(__linux__)\n#  define CK_PLATFORM_LINUX 1\n#elif defined(_WIN64) || defined(_WIN32)\n#  if defined(WINAPI_FAMILY) && WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP\n#     define CK_PLATFORM_WP8 1\n#  else\n#     define CK_PLATFORM_WIN 1\n#  endif\n#endif\n\n#if CK_PLATFORM_OSX && (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1060)\n#  error \"OS X 10.6 required!\"\n#endif\n\n#if !CK_PLATFORM_IOS && !CK_PLATFORM_ANDROID && !CK_PLATFORM_OSX && !CK_PLATFORM_WIN && !CK_PLATFORM_WP8 && !CK_PLATFORM_LINUX && !CK_PLATFORM_TVOS\n#  error \"Unsupported platform!\"\n#endif\n"
  },
  {
    "path": "Libraries/CricketAudio/RPi/Headers/ck/sound.h",
    "content": "// Copyright 2016 Cricket Technology\n// www.crickettechnology.com\n/** @file */\n/** @defgroup CkSound CkSound */\n/** @{ */\n\n#pragma once\n#include \"ck/platform.h\"\n#include \"ck/pathtype.h\"\n#include \"ck/attenuationmode.h\"\n#include <stddef.h>\n\n\nclass CkBank;\nclass CkMixer;\nclass CkEffectBus;\nclass CkCustomStream;\n\n/** A sound (either memory-resident or streamed). */\n\nclass CkSound \n{\npublic:\n    /** Sets the mixer to which this sound is assigned.\n      Setting NULL will assign it to the master mixer. */\n    virtual void setMixer(CkMixer*) = 0;\n\n    /** Gets the mixer to which this sound is assigned. */\n    virtual CkMixer* getMixer() = 0;\n\n\n    /** Returns true if the sound is ready.\n      Bank sounds are ready immediately after creation; stream sounds may not be. */\n    virtual bool isReady() const = 0;\n\n\n    /** Returns true if an error occurred while creating the sound. */\n    virtual bool isFailed() const = 0;\n\n\n    /** Play the sound. */\n    virtual void play() = 0;\n\n    /** Stop the sound. */\n    virtual void stop() = 0;\n\n    /** Gets whether the sound is playing. */\n    virtual bool isPlaying() const = 0; \n\n\n    /** Sets whether the sound is paused. \n     Note that even if false, the sound will be paused if its mixer or any of its \n     mixer's ancestors are paused.*/\n    virtual void setPaused(bool) = 0;\n\n    /** Gets whether the sound is paused.\n     Note that even if false, the sound will be paused if its mixer or any of its \n     mixer's ancestors are paused.*/\n    virtual bool isPaused() const = 0;\n\n    /** Returns true if the sound is pauses, its mixer is paused, or any of its\n      mixer's ancestors are paused. */\n    virtual bool getMixedPauseState() const = 0;\n\n\n    /** Set the loop start and end.\n      Default is to loop over all sample frames. \n      EndFrame is defined as one frame after the last frame of the loop.\n      Setting endFrame = -1 is equivalent to setting it to getLength(). \n     @par Android note: \n      This has no effect for streams in formats other than .cks or Ogg Vorbis. */\n    virtual void setLoop(int startFrame, int endFrame) = 0;\n\n    /** Get the loop start and end.\n      Default is to loop over all sample frames. \n      EndFrame is defined as one frame after the last frame of the loop.\n      Setting endFrame = -1 is equivalent to setting it to getLength(). \n     @par Android note: \n      This has no effect for streams in formats other than .cks or Ogg Vorbis. */\n    virtual void getLoop(int& startFrame, int& endFrame) const = 0;\n\n    /** Sets the number of times the sound should loop.  \n      0 means no looping (play once and then stop).\n      1 means it will play twice; 2 means it will play 3 times; etc. \n      -1 means it will loop indefinitely until the sound is stopped or releaseLoop() is called. */\n    virtual void setLoopCount(int) = 0;\n\n    /** Gets the number of times the sound should loop.  \n      0 means no looping (play once and then stop).\n      1 means it will play twice; 2 means it will play 3 times; etc. \n      -1 means it will loop indefinitely until the sound is stopped or releaseLoop() is called. */\n    virtual int getLoopCount() const = 0;\n\n    /** Gets the number of the current loop.\n      For example, returns 0 if this is the first time playing through this sample;\n      returns 1 if it is on its second loop through the sample; etc. */\n    virtual int getCurrentLoop() const = 0;\n\n    /** Makes the current loop the last.\n      This is useful when you don't know in advance how many times you will\n      want to loop; set the loop count to -1, and call releaseLoop() when\n      you want it to stop looping and play to the end. */\n    virtual void releaseLoop() = 0;\n\n    /** Returns true if releaseLoop() has been called after the last call to play(). */\n    virtual bool isLoopReleased() const = 0;\n\n\n    /** Set the play position in the sound, in sample frames.\n      This can be called before playing, to start from an offset into\n      the sound; or during playback, to jump to a new location. */\n    virtual void setPlayPosition(int) = 0;\n\n    /** Set the play position in the sound, in milliseconds.\n      This can be called before playing, to start from an offset into\n      the sound; or during playback, to jump to a new location. */\n    virtual void setPlayPositionMs(float) = 0;\n\n    /** Get the current play position in the sound, in sample frames. */\n    virtual int getPlayPosition() const = 0;\n\n    /** Get the current play position in the sound, in milliseconds. */\n    virtual float getPlayPositionMs() const = 0;\n\n\n    /** Sets the volume of this sound.\n      The volume can range from 0 to 1. The default value is 1. \n      Note that the actual volume used for mixing will also depend on the volume of the\n      mixer to which this sound is assigned. */\n    virtual void setVolume(float) = 0;\n\n    /** Gets the volume of this sound.\n      The volume can range from 0 to 1. The default value is 1. \n      Note that the actual volume used for mixing will also depend on the volume of the \n      mixer to which this sound is assigned. */\n    virtual float getVolume() const = 0;\n\n\n    /** Gets the volume value used for mixing. \n      This is the product of the volume set with setVolume() and the mixed\n      volume value of the mixer to which the sound is assigned. */\n    virtual float getMixedVolume() const = 0;\n\n\n    /** Sets the pan.\n      The pan can range from -1 (left) to +1 (right). The default is 0 (center). */\n    virtual void setPan(float) = 0;\n\n    /** Gets the pan.\n      The pan can range from -1 (left) to +1 (right). The default is 0 (center). */\n    virtual float getPan() const = 0;\n\n    /** Sets the pan matrix explicitly.  \n      The pan matrix determines how the left and right channels of an input are weighted during mixing.\n      Usually it is set by setPan(), but you can use setPanMatrix() if you need more control.\n      For a mono input, the left channel of the output is the input scaled by ll, and the right channel of the output is the input scaled by rr.  The off-diagonal lr and rl terms are ignored.\n      For a stereo input, the left channel of the output is the left channel of the input scaled by ll plus the right channel of the input scaled by lr.  The right channel of the output is the left channel of the input scaled by rl plus the right channel of the input scaled by rr.\n      */\n    virtual void setPanMatrix(float ll, float lr, float rl, float rr) = 0;\n\n    /** Gets the pan matrix.\n      The pan matrix determines how the left and right channels of an input are weighted during mixing.\n      Usually it is set by setPan(), but you can use setPanMatrix() if you need more control.\n      For a mono input, the left channel of the output is the input scaled by ll, and the right channel of the output is the input scaled by rr.  The off-diagonal lr and rl terms are ignored.\n      For a stereo input, the left channel of the output is the left channel of the input scaled by ll plus the right channel of the input scaled by lr.  The right channel of the output is the left channel of the input scaled by rl plus the right channel of the input scaled by rr.\n      */\n    virtual void getPanMatrix(float& ll, float& lr, float& rl, float& rr) const = 0;\n\n\n    /** Sets the pitch shift value, in half-steps.\n      This also changes the playback speed of the sound.  \n      Positive values mean higher pitch (and faster playback); lower values mean lower pitch \n      (and slower playback).  The default value is 0. \n     @par Android note: \n      This does not work for streams in formats other than .cks or Ogg Vorbis. */\n    virtual void setPitchShift(float halfSteps) = 0;\n\n    /** Gets the pitch shift value, in half-steps.\n      Positive values mean higher pitch (and faster playback); lower values mean lower pitch \n      (and slower playback).  The default value is 0. \n     @par Android note: \n      This does not work for streams in formats other than .cks or Ogg Vorbis. */\n    virtual float getPitchShift() const = 0;\n\n\n    /** Sets the playback speed.\n      Values greater than 1 mean faster playback; values less than 1 mean\n      slower playback.  The default value is 1.\n     @par Android note: \n      This does not work for streams in formats other than .cks or Ogg Vorbis. */\n    virtual void setSpeed(float) = 0;\n\n    /** Gets the playback speed.\n      Values greater than 1 mean faster playback; values less than 1 mean\n      slower playback.  The default value is 1. \n     @par Android note: \n      This does not work for streams in formats other than .cks or Ogg Vorbis. */\n    virtual float getSpeed() const = 0;\n\n\n    /** Sets the sound to be played when this sound finishes playing.\n      The next sound will play immediately, with no gaps. \n     @par Android note:\n      This does not work for streams in formats other than .cks or Ogg Vorbis. */\n    virtual void setNextSound(CkSound*) = 0;\n\n    /** Gets the sound to be played when this sound finishes playing.\n      The next sound will play immediately, with no gaps.\n     @par Android note:\n      This does not work for streams in formats other than .cks or Ogg Vorbis. */\n    virtual CkSound* getNextSound() const = 0;\n\n\n    /** Gets the total duration of the sound, in sample frames.\n      Stream sounds will return -1 if they are not ready or if the length is unknown. */\n    virtual int getLength() const = 0;\n\n    /** Gets the total duration of the sound, in milliseconds.\n      Stream sounds will return -1 if they are not ready or if the length is unknown. */\n    virtual float getLengthMs() const = 0;\n\n    /** Gets the sample rate of the sound, in Hz.\n      Stream sounds will return -1 if they are not ready. */\n    virtual int getSampleRate() const = 0;\n\n    /** Gets the number of channels in the sound (1 for mono, 2 for stereo).\n      Stream sounds will return -1 if they are not ready. */\n    virtual int getChannels() const = 0;\n\n\n    /** Sets the effect bus to which this sound's audio is sent to be processed, or\n      NULL for dry output (no effects).\n     @par Android note: \n      Effects cannot be applied to streams in formats other than .cks or Ogg Vorbis. */\n    virtual void setEffectBus(CkEffectBus*) = 0;\n\n    /** Gets the effect bus to which this sound's audio is sent to be processed, or\n      NULL for dry output (no effects).\n     @par Android note: \n      Effects cannot be applied to streams in formats other than .cks or Ogg Vorbis. */\n    virtual CkEffectBus* getEffectBus() = 0;\n\n\n    /** Sets whether 3D positioning is enabled.\n      If enabled, pan will be determined by the sound and listener positions,\n      ignoring the value set by setPan().  Volume will be attenuated based\n      on the sound and listener positions and the attenuation settings. */\n    virtual void set3dEnabled(bool) = 0;\n\n    /** Gets whether 3D positioning is enabled. \n      If enabled, pan will be determined by the sound and listener positions,\n      ignoring the value set by setPan().  Volume will be attenuated based\n      on the sound and listener positions and the attenuation settings. */\n    virtual bool is3dEnabled() const = 0;\n\n    /** Gets whether a 3D sound is virtual.\n      If, due to distance attenuation, a 3D sound's volume becomes near enough to 0\n      to be inaudible, it becomes \"virtual\".  A virtual sound is effectively paused\n      and is not processed until it would become audible again; this reduces the \n      amount of audio processing required. */\n    virtual bool isVirtual() const = 0;\n\n    /** Sets the position of the sound emitter in 3D space.\n      This is used for pan and volume calculations when 3D positioning is enabled. */\n    virtual void set3dPosition(float x, float y, float z) = 0;\n\n    /** Gets the position of the sound emitter in 3D space.\n      This is used for pan and volume calculations when 3D positioning is enabled. */\n    virtual void get3dPosition(float& x, float& y, float& z) const = 0;\n\n    /** Sets the velocity of the sound emitter in 3D space.\n      This is used for doppler shift calculations when 3D positioning is enabled.\n      The units should be the same as those used for set3dSoundSpeed(). */\n    virtual void set3dVelocity(float vx, float vy, float vz) = 0;\n\n    /** Gets the velocity of the sound emitter in 3D space.\n      This is used for doppler shift calculations when 3D positioning is enabled.\n      The units should be the same as those used for set3dSoundSpeed(). */\n    virtual void get3dVelocity(float& vx, float& vy, float& vz) const = 0;\n\n    /** Sets the listener position and rotation in 3D space. \n      This is used for pan and volume calculations when 3D positioning is enabled.\n      @param eyeX,eyeY,eyeZ           The listener's position\n      @param lookAtX,lookAtY,lookAtZ  The listener's look-at point\n      @param upX,upY,upZ              The listener's up vector\n      */\n    static void set3dListenerPosition(float eyeX, float eyeY, float eyeZ,\n                                      float lookAtX, float lookAtY, float lookAtZ,\n                                      float upX, float upY, float upZ);\n\n    /** Gets the listener position and rotation in 3D space. \n      This is used for pan and volume calculations when 3D positioning is enabled.\n      @param eyeX,eyeY,eyeZ           The listener's position\n      @param lookAtX,lookAtY,lookAtZ  The listener's look-at point\n      @param upX,upY,upZ              The listener's up vector\n      */\n    static void get3dListenerPosition(float& eyeX, float& eyeY, float& eyeZ,\n                                      float& lookAtX, float& lookAtY, float& lookAtZ,\n                                      float& upX, float& upY, float& upZ);\n\n    /** Sets the listener velocity in 3D space.\n      This is used for doppler shift calculations when 3D positioning is enabled. \n      The units should be the same as those used for set3dSoundSpeed(). */\n    static void set3dListenerVelocity(float vx, float vy, float vz);\n\n    /** Gets the listener velocity in 3D space.\n      This is used for doppler shift calculations when 3D positioning is enabled.\n      The units should be the same as those used for set3dSoundSpeed(). */\n    static void get3dListenerVelocity(float& vx, float& vy, float& vz);\n\n    /** Sets parameters used for 3D volume attenuation. \n      @param mode      The attenuation mode (default is kCkAttenuationMode_InvDistanceSquared)\n      @param nearDist  The near distance; sounds closer than this distance will not be attenuated (default is 1.0)\n      @param farDist   The far distance; sounds further than this will be at the far volume (default is 100.0)\n      @param farVol    The far volume; sounds further than farDist will be at this volume (default is 0.0)\n      */\n    static void set3dAttenuation(CkAttenuationMode mode, float nearDist, float farDist, float farVol);\n\n    /** Gets parameters used for 3D volume attenuation. \n      @param mode      The attenuation mode\n      @param nearDist  The near distance; sounds closer than this distance will not be attenuated.\n      @param farDist   The far distance; sounds further than this will be at the far volume.\n      @param farVol    The far volume; sounds further than farDist will be at this volume.\n      */\n    static void get3dAttenuation(CkAttenuationMode& mode, float& nearDist, float& farDist, float& farVol);\n\n    /** Sets the speed of sound.\n      This is used for doppler shift calculations when 3D positioning is enabled.  If no doppler\n      shift is desired, this can be set to 0 (which is the default value).\n      You may want to use the predefined constants for the speed of sound (such as \n      k_soundSpeed_MetersPerSecond); use the constant that corresponds to\n      the unit system you are using for your velocity and position values.\n      You can also exaggerate the doppler effect by using a smaller value. */\n    static void set3dSoundSpeed(float);\n\n    /** Gets the speed of sound.\n      This is used for doppler shift calculations when 3D positioning is enabled.  */\n    static float get3dSoundSpeed();\n\n    /** The speed of sound in dry air at 20 degrees C, in centimeters per second.\n      This value is provided as a convenience for CkSound::set3dSoundSpeed(). */\n    static const float k_soundSpeed_CentimetersPerSecond;\n\n    /** The speed of sound in dry air at 20 degrees C, in meters per second.\n      This value is provided as a convenience for CkSound::set3dSoundSpeed(). */\n    static const float k_soundSpeed_MetersPerSecond;\n\n    /** The speed of sound in dry air at 20 degrees C, in inches per second.\n      This value is provided as a convenience for CkSound::set3dSoundSpeed(). */\n    static const float k_soundSpeed_InchesPerSecond;\n\n    /** The speed of sound in dry air at 20 degrees C, in feet per second.\n      This value is provided as a convenience for CkSound::set3dSoundSpeed(). */\n    static const float k_soundSpeed_FeetPerSecond;\n\n    ////////////////////////////////////////\n    // bank sounds\n\n    /** Creates a sound from a bank by index. \n      This will return NULL if the index is invalid. */\n    static CkSound* newBankSound(CkBank*, int index);\n\n    /** Creates a sound from a bank by name. \n      If bank is NULL, all loaded banks are searched for the first matching sound. \n      This will return NULL if no sound with that name can be found. */\n    static CkSound* newBankSound(CkBank*, const char* name);\n\n\n    ////////////////////////////////////////\n    // streams\n\n    /** Creates a stream from a file path. \n      This will return NULL if the file could not be opened.  If a non-NULL value\n      is returned, you should also check isFailed() to find out if any errors occurred\n      during initialization.\n\n      If the stream file is embedded in a larger file, specify the offset and length of \n      the embedded data in bytes, and provide a string ending with a file extension that indicates\n      the file format of the embedded file (for example, \".mp3\" or \"music.mp3\").\n      Otherwise, leave the offset, length, and extension as 0.\n     */\n    static CkSound* newStreamSound(const char* path, CkPathType = kCkPathType_Default, int offset = 0, int length = 0, const char* extension = NULL);\n\n\n    /** Factory function for creating custom streams. \n     The function should return a CkCustomStream instance, or NULL to create a stream\n     with the default handler. */\n    typedef CkCustomStream* (*CustomStreamFunc)(const char* path, void* data);\n\n    /** Set the stream handler.\n      Set it to NULL to use the default handler. */\n    static void setCustomStreamHandler(CustomStreamFunc, void* data);\n\n\n\n#if CK_PLATFORM_IOS\n    /** Creates a stream from a URL for an asset in the iTunes library. \n      The URL should be determined using an MPMediaQuery object; see the\n      \"iPod Library Access Programming Guide\" document in the iOS Developer Library.\n      Note that this will only work for music files without DRM; for files with DRM, the URL will be returned as nil.\n      @par Only available on iOS version 4.3 or later; will return NULL on earlier iOS versions.\n     */\n    static CkSound* newAssetStreamSound(const char* url);\n#endif\n\n\n    /** Destroys the sound. */\n    virtual void destroy() = 0;\n\nprotected:\n    CkSound() {}\n    virtual ~CkSound() {}\n\nprivate:\n    CkSound(const CkSound&);\n    CkSound& operator=(const CkSound&);\n};\n\n\n/** @} */\n"
  },
  {
    "path": "Libraries/CricketAudio/Windows/Headers/ck/attenuationmode.h",
    "content": "// Copyright 2016 Cricket Technology\n// www.crickettechnology.com\n/** @file */\n/** @defgroup CkAttenuationMode CkAttenuationMode */\n/** @{ */\n\n#pragma once\n#include \"ck/platform.h\"\n\n\n/** Indicates how volume on 3D sounds is attenuated with distance. */\ntypedef enum \n{\n\n    /** No attenuation; volume is 1.0 when closer than the far distance, and far volume outside of that. */\n    kCkAttenuationMode_None = 0,\n\n    /** Linear attenuation of volume between near distance and far distance. */\n    kCkAttenuationMode_Linear,\n\n    /** Attenuation proportional to the reciprocal of the distance. */\n    kCkAttenuationMode_InvDistance,\n\n    /** Attenuation proportional to the square of the reciprocal of the distance. \n     This is a good choice for realistically simulating point sound sources. */\n    kCkAttenuationMode_InvDistanceSquared,\n\n} CkAttenuationMode;\n\n/** @} */\n\n"
  },
  {
    "path": "Libraries/CricketAudio/Windows/Headers/ck/bank.h",
    "content": "// Copyright 2016 Cricket Technology\n// www.crickettechnology.com\n/** @file */\n/** @defgroup CkBank CkBank */\n/** @{ */\n\n#pragma once\n#include \"ck/platform.h\"\n#include \"ck/pathtype.h\"\n\n\n/** A bank of memory-resident sounds. */\n\nclass CkBank\n{\npublic:\n    /** Returns true when an asynchronously loaded bank has finished loading. */\n    virtual bool isLoaded() const = 0;\n\n    /** Returns true if an asynchronously loaded bank had an error during loading. */\n    virtual bool isFailed() const = 0;\n\n    /** Returns the name of the bank. */\n    virtual const char* getName() const = 0;\n\n    /** Returns the number of sounds in the bank. */\n    virtual int getNumSounds() const = 0;\n\n    /** Returns the name of a sound in this bank.\n      The name will be 31 characters or less. */\n    virtual const char* getSoundName(int index) const = 0;\n\n\n    ////////////////////////////////////////\n\n    /** Loads a bank. \n\n      This will return NULL if the bank cannot be loaded.\n\n      If the bank file is embedded in a larger file, specify the offset and \n      length of the embedded data; otherwise, leave them both as 0.\n     */\n    static CkBank* newBank(const char* path, CkPathType = kCkPathType_Default, int offset = 0, int length = 0);\n\n    /** Loads a bank asynchronously. \n\n      This will return NULL if the bank cannot be loaded.\n      When loading a bank asynchronously, you should also check isFailed()\n      after loading to make sure no errors occurred.\n\n      If the bank file is embedded in a larger file, specify the offset and \n      length of the embedded data; otherwise, leave them both as 0.\n      */\n    static CkBank* newBankAsync(const char* path, CkPathType = kCkPathType_Default, int offset = 0, int length = 0);\n\n    /** Loads a bank from a memory buffer. \n\n      The buffer should contain entire bank file; you are responsible for\n      freeing the memory after the bank is deleted. \n\n      This will return NULL if the bank cannot be loaded.\n      */\n    static CkBank* newBankFromMemory(void*, int bytes);\n\n\n    /** Finds a loaded bank by name; returns NULL if not found. */\n    static CkBank* find(const char* bankName);\n\n    /** Destroys the bank. */\n    virtual void destroy() = 0;\n\nprotected:\n    CkBank() {}\n    virtual ~CkBank() {}\n\nprivate:\n    CkBank(const CkBank&);\n    CkBank& operator=(const CkBank&);\n};\n\n/** @} */\n"
  },
  {
    "path": "Libraries/CricketAudio/Windows/Headers/ck/ck.h",
    "content": "// Copyright 2016 Cricket Technology\n// www.crickettechnology.com\n/** @file */\n/** @defgroup Ck Ck */\n/** @{ */\n\n#pragma once\n#include \"ck/config.h\"\n#include \"ck/pathtype.h\"\n\n#ifdef __cplusplus\nextern \"C\"\n{\n#endif\n\n/** Initializes Cricket Audio. Returns nonzero if successful. */\nint CkInit(CkConfig*);\n\n/** Updates Cricket Audio.\n  Should be called once per frame. */\nvoid CkUpdate();\n\n/** Shuts down Cricket Audio. */\nvoid CkShutdown();\n\n/** Suspends Cricket Audio; typically used when an app is made inactive. */\nvoid CkSuspend();\n\n/** Resumes Cricket Audio; typically used when an app is made active after having been inactive. */\nvoid CkResume();\n\n\n/** Returns a rough estimate of the load on the audio processing thread.\n  This is the fraction of the interval between audio callbacks that was actually spent\n  rendering audio; it will range between 0 and 1. */\nfloat CkGetRenderLoad();\n\n\n/** Returns the value of the clip flag.\n  The clip flag is set to true whenever the final audio output \"clips\", i.e. \n  exceeds the maximum value. */\nbool CkGetClipFlag();\n\n/** Resets the value of the clip flag to false.  \n  The clip flag is set to true whenever the final audio output \"clips\", i.e. \n  exceeds the maximum value. */\nvoid CkResetClipFlag();\n\n\n/** Sets the maximum rate at which volumes change on playing sounds, in ms per full volume scale. \n  Default value is 40 ms. */\nvoid CkSetVolumeRampTime(float ms);\n\n/** Gets the maximum rate at which volumes change on playing sounds, in ms per full volume scale. */\nfloat CkGetVolumeRampTime();\n\n/** Default value of volume ramp time. */\nextern const float Ck_volumeRampTimeMsDefault;\n\n\n/** Lock the audio processing thread to prevent it from processing any API calls.\n  The lock should be held only for a short time.  This is useful to ensure that\n  certain calls are processed together.  For example, if you want to play multiple\n  sounds together exactly in sync, call CkLockAudio(), call play() on each sound,\n  then call CkUnlockAudio(). */\nvoid CkLockAudio();\n\n/** Unlock the audio processing thread after a call to CkLockAudio(). */\nvoid CkUnlockAudio();\n\n\n/** Start capturing the final audio output to a file.  The filename must end with \".wav\" \n  (for a Microsoft WAVE file) or \".raw\" (for a headerless file containing 32-bit floating-point \n  interleaved stereo samples). */\nvoid CkStartCapture(const char* path, CkPathType pathType);\n\n/** Stop capturing audio output. */\nvoid CkStopCapture();\n\n\n#ifdef __cplusplus\n} // extern \"C\"\n#endif\n\n/** @} */\n"
  },
  {
    "path": "Libraries/CricketAudio/Windows/Headers/ck/config.h",
    "content": "// Copyright 2016 Cricket Technology\n// www.crickettechnology.com\n/** @file */\n/** @defgroup CkConfig CkConfig */\n/** @{ */\n\n#pragma once\n#include \"ck/platform.h\"\n\n#if CK_PLATFORM_ANDROID\n#  include <jni.h>\n#endif\n\n////////////////////////////////////////\n\n/** Memory allocation function */\ntypedef void* (*CkAllocFunc)(int bytes);\n/** Memory deallocation function */\ntypedef void (*CkFreeFunc)(void*);\n\n\n/** Log message types */\ntypedef enum \n{\n    /** Flag to enable INFO log messages */\n    kCkLog_Info =  (1 << 0),\n\n    /** Flag to enable WARNING log messages */\n    kCkLog_Warning = (1 << 1),\n\n    /** Flag to enable ERROR log messages */\n    kCkLog_Error = (1 << 2),\n\n    /** Flag to disable all log messages */\n    kCkLog_None = 0,\n\n    /** Flag to enable all log messages */\n    kCkLog_All = (kCkLog_Info | kCkLog_Warning | kCkLog_Error)\n\n} CkLogType;\n\n\n/** Log message function */\ntypedef void (*CkLogFunc)(CkLogType, const char* msg);\n\n\n/** Sample types used for internal DSP pipeline */\ntypedef enum\n{\n    /** Force floating-point samples */\n    kCkSampleType_Float,\n\n    /** Force fixed-point samples */\n    kCkSampleType_Fixed,\n    \n    /** Use the default, based on the processor type */\n    kCkSampleType_Default\n\n} CkSampleType;\n\n\n////////////////////////////////////////\n\n/** Configuration options */\nstruct _CkConfig\n{\n#ifdef __cplusplus\n#  if CK_PLATFORM_ANDROID\n    /** Constructor to be used from JNI functions.\n      @param env      A JNI environment pointer\n      @param context  An android.content.Context object from Java (typically an\n                       android.app.Activity or android.app.Service)\n     */\n    _CkConfig(JNIEnv* env, jobject context);\n\n    /** This constructor should be used when there is no valid JNIEnv* pointer; for\n      example, from android_main() in a native activity using the android_native_app_glue\n      library.  See the code in src/samples/hellocricket/android-ndk-native for an example.\n      @param vm       A Java VM pointer\n      @param context  An android.content.Context object from Java (typically an\n                       android.app.Activity or android.app.Service)\n     */\n    _CkConfig(JavaVM* vm, jobject context);\n#  else\n    _CkConfig();\n#  endif\n#endif // __cplusplus\n\n#if CK_PLATFORM_ANDROID\n    /** The JNIEnv pointer.\n      @par Only available on Android. */\n    JNIEnv* jni;\n\n    /** The JavaVM pointer.\n      @par Only available on Android. */\n    JavaVM* vm;\n\n    /** A Java reference to your app's Context object (typically an Activity or Service).\n      @par Only available on Android. */\n    jobject context;\n\n    /** If true, always use Java AudioTrack for output of final mix, instead of OpenSL ES.\n      This should usually be set to false, unless you are debugging specific issues\n      related to low-level audio output.\n      Default is false (use Java AudioTrack only when OpenSL ES is not available, i.e. Android versions prior to 2.3). \n      @par Only available on Android. */\n    bool useJavaAudio;\n\n    /** If true, software support for Ogg Vorbis stream sounds is enabled.\n      If false, stream sounds will use the native Android decoder, which will not\n      support all of the features available to sounds decoded in software.\n      Default is true (Ogg Vorbis streams are decoded in software).\n      @par Only available on Android. */\n    bool enableOggVorbis;\n#endif\n\n#if CK_PLATFORM_IOS || CK_PLATFORM_TVOS\n    /** If true, hardware-assisted decoding is enabled for decoding compressed streams\n      when available.  See Apple's \"Multimedia Programming Guide\" for a list of codecs\n      for which hardware support is available.  Note that streams that use the hardware\n      decoder take slightly longer (~300ms) to initialize, and our tests have shown\n      a negligible effect on CPU usage, so the default value is false.\n      @par Only available on iOS. */\n    bool enableHardwareDecoding;\n#endif\n\n    /** Memory allocation function.\n      Default is NULL (system new will be used). \n      The allocator must be thread-safe. */\n    CkAllocFunc allocFunc;\n\n    /** Memory deallocation function.\n      Default is NULL (system delete will be used). \n      The allocator must be thread-safe. */\n    CkFreeFunc freeFunc;\n\n\n    /** Bitmask for which types of messages are logged. \n      Default is kCkLog_All (all messages logged). */\n    unsigned int logMask;\n\n    /** Function to handle log messages.\n      Default is NULL (printf or equivalent will be used). */\n    CkLogFunc logFunc;\n\n\n    /** Audio processing frame duration, in ms.\n      Shorter times result in lower latency, but require more CPU.\n      Default is 5 ms. */\n    float audioUpdateMs;\n\n    /** Size of buffer for stream sounds, in ms.\n      Larger buffers require more memory, but are less likely\n      to skip due to slow file reads.\n      Default is 500 ms. */\n    float streamBufferMs;\n\n    /** Interval between file reads for stream sounds, in ms.\n      Shorter times will allow for smaller stream buffer sizes, but require more CPU.\n      This value should be set to significantly less than streamBufferMs, or your buffers will always underrun!\n      Default is 100 ms. */\n    float streamFileUpdateMs;\n\n    /** Initial size of the audio task buffer.  If you see a \"Reallocating\n      audio task buffer\" warning, consider increasing this from its default value\n      of 500 to avoid additional memory allocations at runtime. */\n    int maxAudioTasks;\n\n    /** Maximum render load. When the value of CkGetRenderLoad() exceeds this value,\n      some sounds will not be rendered, to keep the CPU usage down.\n      Default is 0.8. */\n    float maxRenderLoad;\n\n    /** Sample type to be used internally for processing.  The default is \n      kCkSampleType_Default, which means that fixed-point samples are used on Android \n      armv5 and armv6 devices, which may lack hardware support for floating-point \n      operations, and that floating-point samples are used on all other devices. */\n    CkSampleType sampleType;\n};\n\ntypedef struct _CkConfig CkConfig;\n\n/** Default value of CkConfig.audioUpdateMs */\nextern const float CkConfig_audioUpdateMsDefault;\n\n/** Default value of CkConfig.streamBufferMs */\nextern const float CkConfig_streamBufferMsDefault;\n\n/** Default value of CkConfig.streamFileUpdateMs */\nextern const float CkConfig_streamFileUpdateMsDefault;\n\n/** Default value of CkConfig.maxAudioTasks */\nextern const int CkConfig_maxAudioTasksDefault;\n\n/** Default value of CkConfig.maxRenderLoad */\nextern const float CkConfig_maxRenderLoadDefault;\n\n////////////////////////////////////////\n\n#ifdef __OBJC__\n\n/** If you are using Objective-C, call CkConfigInit() to initialize the CkConfig\n  struct to its default values.\n  (If you are using C++, the CkConfig struct is initialized by its constructor.) */\n\n#ifdef __cplusplus\nextern \"C\"\n#endif\nvoid CkConfigInit(CkConfig*);\n\n#endif\n\n/** @} */\n"
  },
  {
    "path": "Libraries/CricketAudio/Windows/Headers/ck/customfile.h",
    "content": "// Copyright 2016 Cricket Technology\n// www.crickettechnology.com\n/** @file */\n/** @defgroup CkCustomFile CkCustomFile */\n/** @{ */\n\n#pragma once\n#include \"ck/platform.h\"\n#include \"ck/pathtype.h\"\n\n\n/** Custom file base class.  \n  \n  If you want to override the low-level details of how \n  files are read (for example, to read files over a network, or to decrypt encrypted\n  files as they are read), create a subclass and register a handler with \n  CkSetCustomFileHandler().\n\n  This will work for bank files, and for .cks and Ogg Vorbis streams, but not for\n  other stream types such as MP3, AAC, etc. */\n\nclass CkCustomFile\n{\npublic:\n    virtual ~CkCustomFile() {}\n\n    /** Returns true if the file was successfully opened. */\n    virtual bool isValid() const = 0;\n\n    /** Read from the file.  Returns number of bytes actually read. */\n    virtual int read(void* buf, int bytes) = 0;\n\n    /** Returns the size of the file. */\n    virtual int getSize() const = 0;\n\n    /** Sets the read position in the file. */\n    virtual void setPos(int pos) = 0;\n\n    /** Returns the read position in the file. */\n    virtual int getPos() const = 0;\n};\n\n\n/** Factory function for opening files using a CkCustomFile instance.\n  The function should return CkCustomFile instance, or NULL to open \n  the file with the default handler. */\ntypedef CkCustomFile* (*CkCustomFileFunc)(const char* path, void* data);\n\n/** Set the file handler. \n  Set it to NULL to use the default handler. */\nvoid CkSetCustomFileHandler(CkCustomFileFunc, void* data);\n\n\n/** @} */\n\n\n"
  },
  {
    "path": "Libraries/CricketAudio/Windows/Headers/ck/customstream.h",
    "content": "// Copyright 2016 Cricket Technology\n// www.crickettechnology.com\n/** @file */\n/** @defgroup CkCustomStream CkCustomStream */\n/** @{ */\n\n#pragma once\n#include \"ck/platform.h\"\n\n\n/** Base class for custom streams.\n  To create a custom stream sound (for example, for playing back audio in\n  a proprietary file format), create a subclass, then register a factory\n  function with CkSound::setCustomStreamHandler(). */\n\nclass CkCustomStream\n{\npublic:\n    virtual ~CkCustomStream() {}\n\n    /** Initializes the stream (open data files, read file headers, etc).\n    This is called from the file streaming thread, not the main thread,\n    so synchronous file reading calls will not block audio or application logic. */\n    virtual void init() = 0;\n\n    /** Returns whether the stream has failed in a way that renders it\n      unusable; for example, if an audio file could not be found. */\n    virtual bool isFailed() const = 0;\n\n    /** Returns the number of channels; should be either 1 or 2. */\n    virtual int getChannels() const = 0;\n\n    /** Returns the sample rate of the audio. */\n    virtual int getSampleRate() const = 0;\n\n    /** Returns the total duration of the sound, in sample frames. */\n    virtual int getLength() const = 0;\n\n    /** Reads audio into the buffer; returns the number of sample frames\n      actually read. The audio data should be 16-bit signed PCM. */\n    virtual int read(short* buf, int frames) = 0;\n\n    /** Sets the current play position, in sample frames. */\n    virtual void setPlayPosition(int frame) = 0;\n\n    /** Returns the current play position, in sample frames. */\n    virtual int getPlayPosition() const = 0;\n\n};\n\n\n/** @} */\n\n"
  },
  {
    "path": "Libraries/CricketAudio/Windows/Headers/ck/effect.h",
    "content": "// Copyright 2016 Cricket Technology\n// www.crickettechnology.com\n/** @file */\n/** @defgroup CkEffect CkEffect */\n/** @{ */\n\n#pragma once\n#include \"ck/platform.h\"\n#include \"ck/effecttype.h\"\n#include <stddef.h>\n\nclass CkEffectProcessor;\n\n\n/** An audio effect. */\nclass CkEffect\n{\npublic:\n    /** Set an effect parameter. \n      Parameter IDs are found in ck/effectparam.h. */\n    virtual void setParam(int paramId, float value) = 0;\n\n\n    /** Reset the state of this effect. */\n    virtual void reset() = 0;\n\n\n    /** Set whether this effect is bypassed.\n      A bypassed effect is not applied to the audio. */\n    virtual void setBypassed(bool) = 0;\n\n    /** Gets whether this effect is bypassed.\n      A bypassed effect is not applied to the audio. */\n    virtual bool isBypassed() const = 0;\n\n\n    /** Sets the wet/dry ratio for this effect\n      The ratio can range from 0 to 1.\n      A value of 0 means the audio is left completely \"dry\", that is, with no\n      effects applied; it is equivalent to bypassing the ffect.\n      A value of 1 means the audio is completely \"wet\", that is, the original\n      \"dry\" signal is not mixed back into the processed audio. */\n    virtual void setWetDryRatio(float) = 0;\n\n    /** Gets the wet/dry ratio for this effect.\n      The ratio can range from 0 to 1.\n      A value of 0 means the audio is left completely \"dry\", that is, with no\n      effects applied; it is equivalent to bypassing the effect.\n      A value of 1 means the audio is completely \"wet\", that is, the original\n      \"dry\" signal is not mixed back into the processed audio. */\n    virtual float getWetDryRatio() const = 0;\n\n\n    /** Create a built-in effect. \n      Effect types are found in ck/effecttype.h. */\n    static CkEffect* newEffect(CkEffectType);\n\n\n    /** Factory function for creating effect processors for custom effects. */\n    typedef CkEffectProcessor* (*CustomEffectFunc)(void* arg);\n\n    /** Register a custom effect. \n     To unregister an effect, pass in NULL for the CustomEffectFunc. */\n    static void registerCustomEffect(int id, CustomEffectFunc);\n\n    /** Create a custom effect.\n      A factory function must have been previously registered with the given id,\n      or this will return NULL. */\n    static CkEffect* newCustomEffect(int id, void* arg = NULL);\n\n\n    /** Destroy the effect. */\n    virtual void destroy() = 0;\n\nprotected:\n    CkEffect() {}\n    virtual ~CkEffect() {}\n\nprivate:\n    CkEffect(const CkEffect&);\n    CkEffect& operator=(const CkEffect&);\n};\n\n\n/** @} */\n"
  },
  {
    "path": "Libraries/CricketAudio/Windows/Headers/ck/effectbus.h",
    "content": "// Copyright 2016 Cricket Technology\n// www.crickettechnology.com\n/** @file */\n/** @defgroup CkEffectBus CkEffectBus */\n/** @{ */\n\n#pragma once\n#include \"ck/platform.h\"\n\n\nclass CkEffect;\n\n/** Manages a set of audio effects applied to sounds. */\nclass CkEffectBus\n{\npublic:\n\n    /** Add an effect to this bus.\n      An effect can only be on one bus at a time. */\n    virtual void addEffect(CkEffect*) = 0;\n\n    /** Remove an effect from this bus. */\n    virtual void removeEffect(CkEffect*) = 0;\n\n    /** Remove all effects from this bus. */\n    virtual void removeAllEffects() = 0;\n\n\n    /** Set the bus to which this bus's output is sent.\n      If NULL (the default), the audio from this bus is mixed into the final output. */\n    virtual void setOutputBus(CkEffectBus*) = 0;\n\n    /** Get the bus to which this bus's output is sent.\n      If NULL (the default), the audio from this bus is mixed into the final output. */\n    virtual CkEffectBus* getOutputBus() = 0;\n\n\n    /** Reset the state of all the effects on this bus. */\n    virtual void reset() = 0;\n\n\n    /** Set whether this bus is bypassed.\n      A bypassed effect is not applied to the audio. */\n    virtual void setBypassed(bool) = 0;\n\n    /** Gets whether this bus is bypassed.\n      Effects in a bypassed bus are not applied to the audio. */\n    virtual bool isBypassed() const = 0;\n\n\n    /** Sets the wet/dry ratio for this bus.\n      The ratio can range from 0 to 1.\n      A value of 0 means the audio is left completely \"dry\", that is, with no\n      effects applied; it is equivalent to bypassing the bus.\n      A value of 1 means the audio is completely \"wet\", that is, the original\n      \"dry\" signal is not mixed back into the processed audio. */\n    virtual void setWetDryRatio(float) = 0;\n\n    /** Gets the wet/dry ratio for this bus.\n      The ratio can range from 0 to 1.\n      A value of 0 means the audio is left completely \"dry\", that is, with no\n      effects applied; it is equivalent to bypassing the bus.\n      A value of 1 means the audio is completely \"wet\", that is, the original\n      \"dry\" signal is not mixed back into the processed audio. */\n    virtual float getWetDryRatio() const = 0;\n\n    ////////////////////////////////////////\n\n    /** Create a new effect bus. */\n    static CkEffectBus* newEffectBus();\n\n    /** Get the global effect bus.\n      Effects on this bus are applied to the final audio before it is output. */\n    static CkEffectBus* getGlobalEffectBus();\n\n    /** Destroy this effect bus. */\n    virtual void destroy() = 0;\n\nprotected:\n    CkEffectBus() {}\n    virtual ~CkEffectBus() {}\n\nprivate:\n    CkEffectBus(const CkEffectBus&);\n    CkEffectBus& operator=(const CkEffectBus&);\n\n};\n\n/** @} */\n\n"
  },
  {
    "path": "Libraries/CricketAudio/Windows/Headers/ck/effectparam.h",
    "content": "// Copyright 2016 Cricket Technology\n// www.crickettechnology.com\n/** @file */\n/** @defgroup CkEffectParam CkEffectParam */\n/** @{ */\n\n#pragma once\n#include \"ck/platform.h\"\n\n/** Parameters for the Biquad Filter effect */\nenum\n{\n    /** Type of filter; should be one of the kCkBiquadFilterParam_FilterType values. */\n    kCkBiquadFilterParam_FilterType,\n\n    /** Center frequency of the filter. */\n    kCkBiquadFilterParam_Freq,\n\n    /** Q of the filter. */\n    kCkBiquadFilterParam_Q,\n\n    /** Gain in dB (for Peak, LowShelf, and HighShelf filter types) */\n    kCkBiquadFilterParam_Gain,\n};\n\n\n/** Filter types, used for the kCkBiquadFilterParam_FilterType param. */\nenum\n{\n    /** Low pass filter blocks high frequencies. */\n    kCkBiquadFilterParam_FilterType_LowPass,\n\n    /** High pass filter blocks low frequencies. */\n    kCkBiquadFilterParam_FilterType_HighPass,\n    \n    /** Band pass filter blocks frequencies above and below the center frequency. */\n    kCkBiquadFilterParam_FilterType_BandPass,\n\n    /** Notch filter blocks a narrow band of frequencies. */\n    kCkBiquadFilterParam_FilterType_Notch,\n\n    /** Peak filter boosts a narrow band of frequencies. */\n    kCkBiquadFilterParam_FilterType_Peak,\n\n    /** Low shelf filter boosts low frequencies. */\n    kCkBiquadFilterParam_FilterType_LowShelf,\n\n    /** High shelf filter boosts high frequencies. */\n    kCkBiquadFilterParam_FilterType_HighShelf\n};\n\n\n////////////////////////////////////////\n\n\n/** Parameters for the Bit Crusher effect */\nenum\n{\n    /** Number of bits of resolution to keep in the input samples, in [1..24]. */\n    kCkBitCrusherParam_BitResolution,\n\n    /** Milliseconds to hold each sample value.  Higher values result in more\n      reduction in the effective sample rate.  Values around 1 ms provide a reasonable effect. */\n    kCkBitCrusherParam_HoldMs,\n};\n\n\n////////////////////////////////////////\n\n\n/** Parameters for the Ring Mod effect */\nenum\n{\n    /** Frequency (Hz) of the modulating signal. Values around 500 Hz are typical. */\n    kCkRingModParam_Freq,\n};\n\n////////////////////////////////////////\n\n\n/** Parameters for the Distortion effect */\nenum\n{\n    /** Scale factor for input; larger values cause a more pronounced effect. */\n    kCkDistortionParam_Drive,\n\n    /** Offset for input. */\n    kCkDistortionParam_Offset,\n};\n\n\n\n\n/** @} */\n\n\n"
  },
  {
    "path": "Libraries/CricketAudio/Windows/Headers/ck/effectprocessor.h",
    "content": "// Copyright 2016 Cricket Technology\n// www.crickettechnology.com\n/** @file */\n/** @defgroup CkEffectProcessor CkEffectProcessor */\n/** @{ */\n\n#pragma once\n#include \"ck/platform.h\"\n\n/** Performs audio processing for effects.\n\n  To implement your own custom audio effects, create a subclass, then register a factory\n  function that creates an instance of it with CkEffect::registerCustomEffect(). */\n\nclass CkEffectProcessor\n{\npublic:\n    virtual ~CkEffectProcessor() {}\n\n    /** Set an effect parameter.\n      Note that this should not be called directly; it is called by CkEffect::setParam(). */\n    virtual void setParam(int paramId, float value) = 0;\n\n    /** Reset this effect's state. */\n    virtual void reset() = 0;\n\n    /** If true, the effect is processed in-place; the input and output will be the\n      same buffer.  If false, input and output will be separate buffers. */\n    virtual bool isInPlace() const = 0;\n\n    /** Process audio.\n      The buffer contains interleaved stereo data; each sample is a signed 8.24 fixed-point value.\n      If isInPlace() returns true, inBuf and outBuf will be pointers to the same buffer. \n      It is OK to modify the data in inBuf, even if the effect is not in-place.\n      (Remember that because the data is stereo, the number of samples is 2*frames.) \n\n      @par This will only be called on older Android armv5 or armv6 devices, or if CkConfig.sampleType is set to kCkSampleType_Fixed.\n      If you are not supporting those devices, you may leave this with its default implementation, which passes the audio \n      through unchanged. */\n    virtual void process(int* inBuf, int* outBuf, int frames);\n\n    /** Process audio.\n      The buffer contains interleaved stereo data; each sample is a 32-bit floating-point value.\n      If isInPlace() returns true, inBuf and outBuf will be pointers to the same buffer. \n      It is OK to modify the data in inBuf, even if the effect is not in-place.\n      (Remember that because the data is stereo, the number of samples is 2*frames.) */\n    virtual void process(float* inBuf, float* outBuf, int frames) = 0;\n\n    /** Get the sample rate of the audio data.  This value may be different on different\n      devices, but will not change during app execution. */\n    static int getSampleRate();\n};\n\n\n/** @} */\n\n"
  },
  {
    "path": "Libraries/CricketAudio/Windows/Headers/ck/effecttype.h",
    "content": "// Copyright 2016 Cricket Technology\n// www.crickettechnology.com\n/** @file */\n/** @defgroup CkEffectType CkEffectType */\n/** @{ */\n\n#pragma once\n#include \"ck/platform.h\"\n\n/** Types of built-in effects available */\ntypedef enum \n{\n    /** Biquadratic filter. \n      See kCkBiquadFilterParam values for parameter IDs. */\n    kCkEffectType_BiquadFilter,\n\n    /** Bit Crusher effect reduces bit resolution and/or bit rate, producing a retro\n      low-fi 8-bit sound.\n      See kCkBitCrusherParam values for parameter IDs. */\n    kCkEffectType_BitCrusher,\n\n    /** Ring Mod effect modulates the audio by a sine wave. \n      See kCkRingModParam values for parameter IDs. */\n    kCkEffectType_RingMod,\n\n    /** Distortion effect.\n      See kCkDistortionParam values for parameter IDs. */\n    kCkEffectType_Distortion,\n\n} CkEffectType;\n\n\n/** @} */\n"
  },
  {
    "path": "Libraries/CricketAudio/Windows/Headers/ck/mixer.h",
    "content": "// Copyright 2016 Cricket Technology\n// www.crickettechnology.com\n/** @file */\n/** @defgroup CkMixer CkMixer */\n/** @{ */\n\n#pragma once\n#include \"ck/platform.h\"\n#include <stddef.h>\n\n\n/** A mixer represents a hierarchical grouping of sounds for controlling volumes. */\n\nclass CkMixer\n{\npublic:\n    /** Set the name of the mixer.\n      The name should be 31 characters or less. */\n    virtual void setName(const char*) = 0;\n\n    /** Get the name of the mixer. */\n    virtual const char* getName() const = 0;\n\n\n    /** Set the volume of this mixer.\n      (The actual volume used during mixing will also depend on ancestors.) */\n    virtual void setVolume(float) = 0;\n\n    /** Get the volume of this mixer.\n      (The actual volume used during mixing will also depend on ancestors.) */\n    virtual float getVolume() const = 0;\n\n\n    /** Get the volume used for mixing (affected by ancestors). */\n    virtual float getMixedVolume() const = 0;\n\n\n    /** Set whether this mixer is paused.\n      A sound will be paused if the sound, its mixer, or any of its mixer's ancestors\n      are paused. */\n    virtual void setPaused(bool) = 0;\n\n    /** Get whether this mixer is paused.\n      A sound will be paused if the sound, its mixer, or any of its mixer's ancestors\n      are paused. */\n    virtual bool isPaused() const = 0;\n\n\n    /** Returns true if this mixer, or any of its ancestors, is paused. */\n    virtual bool getMixedPauseState() const = 0;\n\n\n    /** Set the parent of the mixer.\n      Setting to NULL sets the master mixer as the parent. */\n    virtual void setParent(CkMixer*) = 0;\n\n    /** Get the parent of the mixer. */\n    virtual CkMixer* getParent() = 0;\n\n\n    /** Returns the master mixer, which is the root of the mixer hierarchy. */\n    static CkMixer* getMaster();\n\n    /** Creates a new mixer. */\n    static CkMixer* newMixer(const char* name, CkMixer* parent = NULL);\n\n    /** Finds a mixer by name; returns NULL if not found. */\n    static CkMixer* find(const char* name);\n\n\n    /** Destroys the mixer. */\n    virtual void destroy() = 0;\n\nprotected:\n    CkMixer() {}\n    virtual ~CkMixer() {}\n\nprivate:\n    CkMixer(const CkMixer&);\n    CkMixer& operator=(const CkMixer&);\n};\n\n/** @} */\n"
  },
  {
    "path": "Libraries/CricketAudio/Windows/Headers/ck/pathtype.h",
    "content": "// Copyright 2016 Cricket Technology\n// www.crickettechnology.com\n/** @file */\n/** @defgroup CkPathType CkPathType */\n/** @{ */\n\n#pragma once\n#include \"ck/platform.h\"\n\n\n/** Indicates how a file path should be interpreted. */\ntypedef enum \n{\n    /** A full path to a file on the file system. */\n    kCkPathType_FileSystem = 0,\n\n#if CK_PLATFORM_ANDROID\n    /** A path to an asset in the .apk. \n      Assets are read-only.\n     @par Only available on Android. */\n    kCkPathType_Asset,\n\n    /** A path relative to the private files directory.\n     @par Only available on Android. */\n    kCkPathType_PrivateFiles,\n\n    /** A path relative to the external storage directory.\n     @par Only available on Android. */\n    kCkPathType_ExternalStorage,\n#endif\n\n#if CK_PLATFORM_IOS || CK_PLATFORM_OSX || CK_PLATFORM_TVOS\n    /** A path relative to the application's resource directory.\n      On iOS, the resource directory is the application bundle, and is read-only.\n      On OS X, the resource directory is the directory containing the executable.\n     @par Only available on iOS and OS X. */\n    kCkPathType_Resource,\n#endif\n\n#if CK_PLATFORM_WP8\n    /** A path relative to the local app data store.\n     @par Only available on Windows Phone 8. */\n    kCkPathType_LocalDir,\n\n    /** A path relative to the folder containing your app's package files.\n      Files in your Visual Studio project with the \"Content\" property set to true will be installed here.\n      This folder is read-only.\n     @par Only available on Windows Phone 8. */\n    kCkPathType_InstallationDir,\n#endif\n\n#if CK_PLATFORM_IOS || CK_PLATFORM_OSX || CK_PLATFORM_TVOS || CK_PLATFORM_WIN || CK_PLATFORM_LINUX\n    /** A path relative to the directory used for temporary files.\n     @par Only available on iOS, OS X, Windows, and Linux. */\n    kCkPathType_Temp,\n#endif\n\n#if CK_PLATFORM_IOS || CK_PLATFORM_OSX || CK_PLATFORM_WIN || CK_PLATFORM_LINUX\n    /** A path relative to the application's documents directory.\n      On iOS, this is the app's Documents directory.\n      On OS X and Windows, this is the user's Documents directory.\n      On Linux, this is the user's home directory.\n     @par Only available on iOS, OS X, Windows, and Linux. */\n    kCkPathType_Documents,\n#endif\n\n#if CK_PLATFORM_WIN || CK_PLATFORM_LINUX || CK_PLATFORM_OSX\n    /** A path relative to the executable's directory. \n     (On OS X, this is the same as kCkPathType_Resource.) \n     @par Only available on Windows, Linux, and OS X.  */\n    kCkPathType_ExeDir,\n#endif\n\n    /** The default path type for reading files. */\n#if CK_PLATFORM_ANDROID\n    kCkPathType_ReadDefault = kCkPathType_Asset,\n#elif CK_PLATFORM_IOS || CK_PLATFORM_OSX || CK_PLATFORM_TVOS\n    kCkPathType_ReadDefault = kCkPathType_Resource,\n#elif CK_PLATFORM_WIN || CK_PLATFORM_LINUX\n    kCkPathType_ReadDefault = kCkPathType_ExeDir,\n#elif CK_PLATFORM_WP8\n    kCkPathType_ReadDefault = kCkPathType_InstallationDir,\n#endif\n\n    /** The default path type for writing files. */\n#if CK_PLATFORM_ANDROID\n    kCkPathType_WriteDefault = kCkPathType_PrivateFiles,\n#elif CK_PLATFORM_IOS || CK_PLATFORM_OSX \n    kCkPathType_WriteDefault = kCkPathType_Documents,\n#elif CK_PLATFORM_TVOS\n    kCkPathType_WriteDefault = kCkPathType_Temp,\n#elif CK_PLATFORM_WIN || CK_PLATFORM_LINUX\n    kCkPathType_WriteDefault = kCkPathType_ExeDir,\n#elif CK_PLATFORM_WP8\n    kCkPathType_WriteDefault = kCkPathType_LocalDir,\n#endif\n\n    /** The default path type. */\n    kCkPathType_Default = kCkPathType_ReadDefault\n\n} CkPathType;\n\n/** @} */\n"
  },
  {
    "path": "Libraries/CricketAudio/Windows/Headers/ck/platform.h",
    "content": "// Copyright 2016 Cricket Technology\n// www.crickettechnology.com\n/** @file */\n\n#pragma once\n\n// software platform\n#undef CK_PLATFORM_IOS\n#undef CK_PLATFORM_TVOS\n#undef CK_PLATFORM_ANDROID\n#undef CK_PLATFORM_OSX\n#undef CK_PLATFORM_WIN\n#undef CK_PLATFORM_WP8\n#undef CK_PLATFORM_LINUX\n\n#ifdef __APPLE__\n#  include <TargetConditionals.h>\n#  if TARGET_OS_IPHONE\n#    if TARGET_OS_IOS\n#      define CK_PLATFORM_IOS 1\n#    elif TARGET_OS_TV\n#      define CK_PLATFORM_TVOS 1\n#    endif\n#  else\n#    define CK_PLATFORM_OSX 1\n#  endif\n#elif defined(__ANDROID__)\n#  define CK_PLATFORM_ANDROID 1\n#elif defined(__linux__)\n#  define CK_PLATFORM_LINUX 1\n#elif defined(_WIN64) || defined(_WIN32)\n#  if defined(WINAPI_FAMILY) && WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP\n#     define CK_PLATFORM_WP8 1\n#  else\n#     define CK_PLATFORM_WIN 1\n#  endif\n#endif\n\n#if CK_PLATFORM_OSX && (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1060)\n#  error \"OS X 10.6 required!\"\n#endif\n\n#if !CK_PLATFORM_IOS && !CK_PLATFORM_ANDROID && !CK_PLATFORM_OSX && !CK_PLATFORM_WIN && !CK_PLATFORM_WP8 && !CK_PLATFORM_LINUX && !CK_PLATFORM_TVOS\n#  error \"Unsupported platform!\"\n#endif\n"
  },
  {
    "path": "Libraries/CricketAudio/Windows/Headers/ck/sound.h",
    "content": "// Copyright 2016 Cricket Technology\n// www.crickettechnology.com\n/** @file */\n/** @defgroup CkSound CkSound */\n/** @{ */\n\n#pragma once\n#include \"ck/platform.h\"\n#include \"ck/pathtype.h\"\n#include \"ck/attenuationmode.h\"\n#include <stddef.h>\n\n\nclass CkBank;\nclass CkMixer;\nclass CkEffectBus;\nclass CkCustomStream;\n\n/** A sound (either memory-resident or streamed). */\n\nclass CkSound \n{\npublic:\n    /** Sets the mixer to which this sound is assigned.\n      Setting NULL will assign it to the master mixer. */\n    virtual void setMixer(CkMixer*) = 0;\n\n    /** Gets the mixer to which this sound is assigned. */\n    virtual CkMixer* getMixer() = 0;\n\n\n    /** Returns true if the sound is ready.\n      Bank sounds are ready immediately after creation; stream sounds may not be. */\n    virtual bool isReady() const = 0;\n\n\n    /** Returns true if an error occurred while creating the sound. */\n    virtual bool isFailed() const = 0;\n\n\n    /** Play the sound. */\n    virtual void play() = 0;\n\n    /** Stop the sound. */\n    virtual void stop() = 0;\n\n    /** Gets whether the sound is playing. */\n    virtual bool isPlaying() const = 0; \n\n\n    /** Sets whether the sound is paused. \n     Note that even if false, the sound will be paused if its mixer or any of its \n     mixer's ancestors are paused.*/\n    virtual void setPaused(bool) = 0;\n\n    /** Gets whether the sound is paused.\n     Note that even if false, the sound will be paused if its mixer or any of its \n     mixer's ancestors are paused.*/\n    virtual bool isPaused() const = 0;\n\n    /** Returns true if the sound is pauses, its mixer is paused, or any of its\n      mixer's ancestors are paused. */\n    virtual bool getMixedPauseState() const = 0;\n\n\n    /** Set the loop start and end.\n      Default is to loop over all sample frames. \n      EndFrame is defined as one frame after the last frame of the loop.\n      Setting endFrame = -1 is equivalent to setting it to getLength(). \n     @par Android note: \n      This has no effect for streams in formats other than .cks or Ogg Vorbis. */\n    virtual void setLoop(int startFrame, int endFrame) = 0;\n\n    /** Get the loop start and end.\n      Default is to loop over all sample frames. \n      EndFrame is defined as one frame after the last frame of the loop.\n      Setting endFrame = -1 is equivalent to setting it to getLength(). \n     @par Android note: \n      This has no effect for streams in formats other than .cks or Ogg Vorbis. */\n    virtual void getLoop(int& startFrame, int& endFrame) const = 0;\n\n    /** Sets the number of times the sound should loop.  \n      0 means no looping (play once and then stop).\n      1 means it will play twice; 2 means it will play 3 times; etc. \n      -1 means it will loop indefinitely until the sound is stopped or releaseLoop() is called. */\n    virtual void setLoopCount(int) = 0;\n\n    /** Gets the number of times the sound should loop.  \n      0 means no looping (play once and then stop).\n      1 means it will play twice; 2 means it will play 3 times; etc. \n      -1 means it will loop indefinitely until the sound is stopped or releaseLoop() is called. */\n    virtual int getLoopCount() const = 0;\n\n    /** Gets the number of the current loop.\n      For example, returns 0 if this is the first time playing through this sample;\n      returns 1 if it is on its second loop through the sample; etc. */\n    virtual int getCurrentLoop() const = 0;\n\n    /** Makes the current loop the last.\n      This is useful when you don't know in advance how many times you will\n      want to loop; set the loop count to -1, and call releaseLoop() when\n      you want it to stop looping and play to the end. */\n    virtual void releaseLoop() = 0;\n\n    /** Returns true if releaseLoop() has been called after the last call to play(). */\n    virtual bool isLoopReleased() const = 0;\n\n\n    /** Set the play position in the sound, in sample frames.\n      This can be called before playing, to start from an offset into\n      the sound; or during playback, to jump to a new location. */\n    virtual void setPlayPosition(int) = 0;\n\n    /** Set the play position in the sound, in milliseconds.\n      This can be called before playing, to start from an offset into\n      the sound; or during playback, to jump to a new location. */\n    virtual void setPlayPositionMs(float) = 0;\n\n    /** Get the current play position in the sound, in sample frames. */\n    virtual int getPlayPosition() const = 0;\n\n    /** Get the current play position in the sound, in milliseconds. */\n    virtual float getPlayPositionMs() const = 0;\n\n\n    /** Sets the volume of this sound.\n      The volume can range from 0 to 1. The default value is 1. \n      Note that the actual volume used for mixing will also depend on the volume of the\n      mixer to which this sound is assigned. */\n    virtual void setVolume(float) = 0;\n\n    /** Gets the volume of this sound.\n      The volume can range from 0 to 1. The default value is 1. \n      Note that the actual volume used for mixing will also depend on the volume of the \n      mixer to which this sound is assigned. */\n    virtual float getVolume() const = 0;\n\n\n    /** Gets the volume value used for mixing. \n      This is the product of the volume set with setVolume() and the mixed\n      volume value of the mixer to which the sound is assigned. */\n    virtual float getMixedVolume() const = 0;\n\n\n    /** Sets the pan.\n      The pan can range from -1 (left) to +1 (right). The default is 0 (center). */\n    virtual void setPan(float) = 0;\n\n    /** Gets the pan.\n      The pan can range from -1 (left) to +1 (right). The default is 0 (center). */\n    virtual float getPan() const = 0;\n\n    /** Sets the pan matrix explicitly.  \n      The pan matrix determines how the left and right channels of an input are weighted during mixing.\n      Usually it is set by setPan(), but you can use setPanMatrix() if you need more control.\n      For a mono input, the left channel of the output is the input scaled by ll, and the right channel of the output is the input scaled by rr.  The off-diagonal lr and rl terms are ignored.\n      For a stereo input, the left channel of the output is the left channel of the input scaled by ll plus the right channel of the input scaled by lr.  The right channel of the output is the left channel of the input scaled by rl plus the right channel of the input scaled by rr.\n      */\n    virtual void setPanMatrix(float ll, float lr, float rl, float rr) = 0;\n\n    /** Gets the pan matrix.\n      The pan matrix determines how the left and right channels of an input are weighted during mixing.\n      Usually it is set by setPan(), but you can use setPanMatrix() if you need more control.\n      For a mono input, the left channel of the output is the input scaled by ll, and the right channel of the output is the input scaled by rr.  The off-diagonal lr and rl terms are ignored.\n      For a stereo input, the left channel of the output is the left channel of the input scaled by ll plus the right channel of the input scaled by lr.  The right channel of the output is the left channel of the input scaled by rl plus the right channel of the input scaled by rr.\n      */\n    virtual void getPanMatrix(float& ll, float& lr, float& rl, float& rr) const = 0;\n\n\n    /** Sets the pitch shift value, in half-steps.\n      This also changes the playback speed of the sound.  \n      Positive values mean higher pitch (and faster playback); lower values mean lower pitch \n      (and slower playback).  The default value is 0. \n     @par Android note: \n      This does not work for streams in formats other than .cks or Ogg Vorbis. */\n    virtual void setPitchShift(float halfSteps) = 0;\n\n    /** Gets the pitch shift value, in half-steps.\n      Positive values mean higher pitch (and faster playback); lower values mean lower pitch \n      (and slower playback).  The default value is 0. \n     @par Android note: \n      This does not work for streams in formats other than .cks or Ogg Vorbis. */\n    virtual float getPitchShift() const = 0;\n\n\n    /** Sets the playback speed.\n      Values greater than 1 mean faster playback; values less than 1 mean\n      slower playback.  The default value is 1.\n     @par Android note: \n      This does not work for streams in formats other than .cks or Ogg Vorbis. */\n    virtual void setSpeed(float) = 0;\n\n    /** Gets the playback speed.\n      Values greater than 1 mean faster playback; values less than 1 mean\n      slower playback.  The default value is 1. \n     @par Android note: \n      This does not work for streams in formats other than .cks or Ogg Vorbis. */\n    virtual float getSpeed() const = 0;\n\n\n    /** Sets the sound to be played when this sound finishes playing.\n      The next sound will play immediately, with no gaps. \n     @par Android note:\n      This does not work for streams in formats other than .cks or Ogg Vorbis. */\n    virtual void setNextSound(CkSound*) = 0;\n\n    /** Gets the sound to be played when this sound finishes playing.\n      The next sound will play immediately, with no gaps.\n     @par Android note:\n      This does not work for streams in formats other than .cks or Ogg Vorbis. */\n    virtual CkSound* getNextSound() const = 0;\n\n\n    /** Gets the total duration of the sound, in sample frames.\n      Stream sounds will return -1 if they are not ready or if the length is unknown. */\n    virtual int getLength() const = 0;\n\n    /** Gets the total duration of the sound, in milliseconds.\n      Stream sounds will return -1 if they are not ready or if the length is unknown. */\n    virtual float getLengthMs() const = 0;\n\n    /** Gets the sample rate of the sound, in Hz.\n      Stream sounds will return -1 if they are not ready. */\n    virtual int getSampleRate() const = 0;\n\n    /** Gets the number of channels in the sound (1 for mono, 2 for stereo).\n      Stream sounds will return -1 if they are not ready. */\n    virtual int getChannels() const = 0;\n\n\n    /** Sets the effect bus to which this sound's audio is sent to be processed, or\n      NULL for dry output (no effects).\n     @par Android note: \n      Effects cannot be applied to streams in formats other than .cks or Ogg Vorbis. */\n    virtual void setEffectBus(CkEffectBus*) = 0;\n\n    /** Gets the effect bus to which this sound's audio is sent to be processed, or\n      NULL for dry output (no effects).\n     @par Android note: \n      Effects cannot be applied to streams in formats other than .cks or Ogg Vorbis. */\n    virtual CkEffectBus* getEffectBus() = 0;\n\n\n    /** Sets whether 3D positioning is enabled.\n      If enabled, pan will be determined by the sound and listener positions,\n      ignoring the value set by setPan().  Volume will be attenuated based\n      on the sound and listener positions and the attenuation settings. */\n    virtual void set3dEnabled(bool) = 0;\n\n    /** Gets whether 3D positioning is enabled. \n      If enabled, pan will be determined by the sound and listener positions,\n      ignoring the value set by setPan().  Volume will be attenuated based\n      on the sound and listener positions and the attenuation settings. */\n    virtual bool is3dEnabled() const = 0;\n\n    /** Gets whether a 3D sound is virtual.\n      If, due to distance attenuation, a 3D sound's volume becomes near enough to 0\n      to be inaudible, it becomes \"virtual\".  A virtual sound is effectively paused\n      and is not processed until it would become audible again; this reduces the \n      amount of audio processing required. */\n    virtual bool isVirtual() const = 0;\n\n    /** Sets the position of the sound emitter in 3D space.\n      This is used for pan and volume calculations when 3D positioning is enabled. */\n    virtual void set3dPosition(float x, float y, float z) = 0;\n\n    /** Gets the position of the sound emitter in 3D space.\n      This is used for pan and volume calculations when 3D positioning is enabled. */\n    virtual void get3dPosition(float& x, float& y, float& z) const = 0;\n\n    /** Sets the velocity of the sound emitter in 3D space.\n      This is used for doppler shift calculations when 3D positioning is enabled.\n      The units should be the same as those used for set3dSoundSpeed(). */\n    virtual void set3dVelocity(float vx, float vy, float vz) = 0;\n\n    /** Gets the velocity of the sound emitter in 3D space.\n      This is used for doppler shift calculations when 3D positioning is enabled.\n      The units should be the same as those used for set3dSoundSpeed(). */\n    virtual void get3dVelocity(float& vx, float& vy, float& vz) const = 0;\n\n    /** Sets the listener position and rotation in 3D space. \n      This is used for pan and volume calculations when 3D positioning is enabled.\n      @param eyeX,eyeY,eyeZ           The listener's position\n      @param lookAtX,lookAtY,lookAtZ  The listener's look-at point\n      @param upX,upY,upZ              The listener's up vector\n      */\n    static void set3dListenerPosition(float eyeX, float eyeY, float eyeZ,\n                                      float lookAtX, float lookAtY, float lookAtZ,\n                                      float upX, float upY, float upZ);\n\n    /** Gets the listener position and rotation in 3D space. \n      This is used for pan and volume calculations when 3D positioning is enabled.\n      @param eyeX,eyeY,eyeZ           The listener's position\n      @param lookAtX,lookAtY,lookAtZ  The listener's look-at point\n      @param upX,upY,upZ              The listener's up vector\n      */\n    static void get3dListenerPosition(float& eyeX, float& eyeY, float& eyeZ,\n                                      float& lookAtX, float& lookAtY, float& lookAtZ,\n                                      float& upX, float& upY, float& upZ);\n\n    /** Sets the listener velocity in 3D space.\n      This is used for doppler shift calculations when 3D positioning is enabled. \n      The units should be the same as those used for set3dSoundSpeed(). */\n    static void set3dListenerVelocity(float vx, float vy, float vz);\n\n    /** Gets the listener velocity in 3D space.\n      This is used for doppler shift calculations when 3D positioning is enabled.\n      The units should be the same as those used for set3dSoundSpeed(). */\n    static void get3dListenerVelocity(float& vx, float& vy, float& vz);\n\n    /** Sets parameters used for 3D volume attenuation. \n      @param mode      The attenuation mode (default is kCkAttenuationMode_InvDistanceSquared)\n      @param nearDist  The near distance; sounds closer than this distance will not be attenuated (default is 1.0)\n      @param farDist   The far distance; sounds further than this will be at the far volume (default is 100.0)\n      @param farVol    The far volume; sounds further than farDist will be at this volume (default is 0.0)\n      */\n    static void set3dAttenuation(CkAttenuationMode mode, float nearDist, float farDist, float farVol);\n\n    /** Gets parameters used for 3D volume attenuation. \n      @param mode      The attenuation mode\n      @param nearDist  The near distance; sounds closer than this distance will not be attenuated.\n      @param farDist   The far distance; sounds further than this will be at the far volume.\n      @param farVol    The far volume; sounds further than farDist will be at this volume.\n      */\n    static void get3dAttenuation(CkAttenuationMode& mode, float& nearDist, float& farDist, float& farVol);\n\n    /** Sets the speed of sound.\n      This is used for doppler shift calculations when 3D positioning is enabled.  If no doppler\n      shift is desired, this can be set to 0 (which is the default value).\n      You may want to use the predefined constants for the speed of sound (such as \n      k_soundSpeed_MetersPerSecond); use the constant that corresponds to\n      the unit system you are using for your velocity and position values.\n      You can also exaggerate the doppler effect by using a smaller value. */\n    static void set3dSoundSpeed(float);\n\n    /** Gets the speed of sound.\n      This is used for doppler shift calculations when 3D positioning is enabled.  */\n    static float get3dSoundSpeed();\n\n    /** The speed of sound in dry air at 20 degrees C, in centimeters per second.\n      This value is provided as a convenience for CkSound::set3dSoundSpeed(). */\n    static const float k_soundSpeed_CentimetersPerSecond;\n\n    /** The speed of sound in dry air at 20 degrees C, in meters per second.\n      This value is provided as a convenience for CkSound::set3dSoundSpeed(). */\n    static const float k_soundSpeed_MetersPerSecond;\n\n    /** The speed of sound in dry air at 20 degrees C, in inches per second.\n      This value is provided as a convenience for CkSound::set3dSoundSpeed(). */\n    static const float k_soundSpeed_InchesPerSecond;\n\n    /** The speed of sound in dry air at 20 degrees C, in feet per second.\n      This value is provided as a convenience for CkSound::set3dSoundSpeed(). */\n    static const float k_soundSpeed_FeetPerSecond;\n\n    ////////////////////////////////////////\n    // bank sounds\n\n    /** Creates a sound from a bank by index. \n      This will return NULL if the index is invalid. */\n    static CkSound* newBankSound(CkBank*, int index);\n\n    /** Creates a sound from a bank by name. \n      If bank is NULL, all loaded banks are searched for the first matching sound. \n      This will return NULL if no sound with that name can be found. */\n    static CkSound* newBankSound(CkBank*, const char* name);\n\n\n    ////////////////////////////////////////\n    // streams\n\n    /** Creates a stream from a file path. \n      This will return NULL if the file could not be opened.  If a non-NULL value\n      is returned, you should also check isFailed() to find out if any errors occurred\n      during initialization.\n\n      If the stream file is embedded in a larger file, specify the offset and length of \n      the embedded data in bytes, and provide a string ending with a file extension that indicates\n      the file format of the embedded file (for example, \".mp3\" or \"music.mp3\").\n      Otherwise, leave the offset, length, and extension as 0.\n     */\n    static CkSound* newStreamSound(const char* path, CkPathType = kCkPathType_Default, int offset = 0, int length = 0, const char* extension = NULL);\n\n\n    /** Factory function for creating custom streams. \n     The function should return a CkCustomStream instance, or NULL to create a stream\n     with the default handler. */\n    typedef CkCustomStream* (*CustomStreamFunc)(const char* path, void* data);\n\n    /** Set the stream handler.\n      Set it to NULL to use the default handler. */\n    static void setCustomStreamHandler(CustomStreamFunc, void* data);\n\n\n\n#if CK_PLATFORM_IOS\n    /** Creates a stream from a URL for an asset in the iTunes library. \n      The URL should be determined using an MPMediaQuery object; see the\n      \"iPod Library Access Programming Guide\" document in the iOS Developer Library.\n      Note that this will only work for music files without DRM; for files with DRM, the URL will be returned as nil.\n      @par Only available on iOS version 4.3 or later; will return NULL on earlier iOS versions.\n     */\n    static CkSound* newAssetStreamSound(const char* url);\n#endif\n\n\n    /** Destroys the sound. */\n    virtual void destroy() = 0;\n\nprotected:\n    CkSound() {}\n    virtual ~CkSound() {}\n\nprivate:\n    CkSound(const CkSound&);\n    CkSound& operator=(const CkSound&);\n};\n\n\n/** @} */\n"
  },
  {
    "path": "Libraries/CricketAudio/iOS/Headers/ck/attenuationmode.h",
    "content": "// Copyright 2016 Cricket Technology\n// www.crickettechnology.com\n/** @file */\n/** @defgroup CkAttenuationMode CkAttenuationMode */\n/** @{ */\n\n#pragma once\n#include \"ck/platform.h\"\n\n\n/** Indicates how volume on 3D sounds is attenuated with distance. */\ntypedef enum \n{\n\n    /** No attenuation; volume is 1.0 when closer than the far distance, and far volume outside of that. */\n    kCkAttenuationMode_None = 0,\n\n    /** Linear attenuation of volume between near distance and far distance. */\n    kCkAttenuationMode_Linear,\n\n    /** Attenuation proportional to the reciprocal of the distance. */\n    kCkAttenuationMode_InvDistance,\n\n    /** Attenuation proportional to the square of the reciprocal of the distance. \n     This is a good choice for realistically simulating point sound sources. */\n    kCkAttenuationMode_InvDistanceSquared,\n\n} CkAttenuationMode;\n\n/** @} */\n\n"
  },
  {
    "path": "Libraries/CricketAudio/iOS/Headers/ck/bank.h",
    "content": "// Copyright 2016 Cricket Technology\n// www.crickettechnology.com\n/** @file */\n/** @defgroup CkBank CkBank */\n/** @{ */\n\n#pragma once\n#include \"ck/platform.h\"\n#include \"ck/pathtype.h\"\n\n\n/** A bank of memory-resident sounds. */\n\nclass CkBank\n{\npublic:\n    /** Returns true when an asynchronously loaded bank has finished loading. */\n    virtual bool isLoaded() const = 0;\n\n    /** Returns true if an asynchronously loaded bank had an error during loading. */\n    virtual bool isFailed() const = 0;\n\n    /** Returns the name of the bank. */\n    virtual const char* getName() const = 0;\n\n    /** Returns the number of sounds in the bank. */\n    virtual int getNumSounds() const = 0;\n\n    /** Returns the name of a sound in this bank.\n      The name will be 31 characters or less. */\n    virtual const char* getSoundName(int index) const = 0;\n\n\n    ////////////////////////////////////////\n\n    /** Loads a bank. \n\n      This will return NULL if the bank cannot be loaded.\n\n      If the bank file is embedded in a larger file, specify the offset and \n      length of the embedded data; otherwise, leave them both as 0.\n     */\n    static CkBank* newBank(const char* path, CkPathType = kCkPathType_Default, int offset = 0, int length = 0);\n\n    /** Loads a bank asynchronously. \n\n      This will return NULL if the bank cannot be loaded.\n      When loading a bank asynchronously, you should also check isFailed()\n      after loading to make sure no errors occurred.\n\n      If the bank file is embedded in a larger file, specify the offset and \n      length of the embedded data; otherwise, leave them both as 0.\n      */\n    static CkBank* newBankAsync(const char* path, CkPathType = kCkPathType_Default, int offset = 0, int length = 0);\n\n    /** Loads a bank from a memory buffer. \n\n      The buffer should contain entire bank file; you are responsible for\n      freeing the memory after the bank is deleted. \n\n      This will return NULL if the bank cannot be loaded.\n      */\n    static CkBank* newBankFromMemory(void*, int bytes);\n\n\n    /** Finds a loaded bank by name; returns NULL if not found. */\n    static CkBank* find(const char* bankName);\n\n    /** Destroys the bank. */\n    virtual void destroy() = 0;\n\nprotected:\n    CkBank() {}\n    virtual ~CkBank() {}\n\nprivate:\n    CkBank(const CkBank&);\n    CkBank& operator=(const CkBank&);\n};\n\n/** @} */\n"
  },
  {
    "path": "Libraries/CricketAudio/iOS/Headers/ck/ck.h",
    "content": "// Copyright 2016 Cricket Technology\n// www.crickettechnology.com\n/** @file */\n/** @defgroup Ck Ck */\n/** @{ */\n\n#pragma once\n#include \"ck/config.h\"\n#include \"ck/pathtype.h\"\n\n#ifdef __cplusplus\nextern \"C\"\n{\n#endif\n\n/** Initializes Cricket Audio. Returns nonzero if successful. */\nint CkInit(CkConfig*);\n\n/** Updates Cricket Audio.\n  Should be called once per frame. */\nvoid CkUpdate();\n\n/** Shuts down Cricket Audio. */\nvoid CkShutdown();\n\n/** Suspends Cricket Audio; typically used when an app is made inactive. */\nvoid CkSuspend();\n\n/** Resumes Cricket Audio; typically used when an app is made active after having been inactive. */\nvoid CkResume();\n\n\n/** Returns a rough estimate of the load on the audio processing thread.\n  This is the fraction of the interval between audio callbacks that was actually spent\n  rendering audio; it will range between 0 and 1. */\nfloat CkGetRenderLoad();\n\n\n/** Returns the value of the clip flag.\n  The clip flag is set to true whenever the final audio output \"clips\", i.e. \n  exceeds the maximum value. */\nbool CkGetClipFlag();\n\n/** Resets the value of the clip flag to false.  \n  The clip flag is set to true whenever the final audio output \"clips\", i.e. \n  exceeds the maximum value. */\nvoid CkResetClipFlag();\n\n\n/** Sets the maximum rate at which volumes change on playing sounds, in ms per full volume scale. \n  Default value is 40 ms. */\nvoid CkSetVolumeRampTime(float ms);\n\n/** Gets the maximum rate at which volumes change on playing sounds, in ms per full volume scale. */\nfloat CkGetVolumeRampTime();\n\n/** Default value of volume ramp time. */\nextern const float Ck_volumeRampTimeMsDefault;\n\n\n/** Lock the audio processing thread to prevent it from processing any API calls.\n  The lock should be held only for a short time.  This is useful to ensure that\n  certain calls are processed together.  For example, if you want to play multiple\n  sounds together exactly in sync, call CkLockAudio(), call play() on each sound,\n  then call CkUnlockAudio(). */\nvoid CkLockAudio();\n\n/** Unlock the audio processing thread after a call to CkLockAudio(). */\nvoid CkUnlockAudio();\n\n\n/** Start capturing the final audio output to a file.  The filename must end with \".wav\" \n  (for a Microsoft WAVE file) or \".raw\" (for a headerless file containing 32-bit floating-point \n  interleaved stereo samples). */\nvoid CkStartCapture(const char* path, CkPathType pathType);\n\n/** Stop capturing audio output. */\nvoid CkStopCapture();\n\n\n#ifdef __cplusplus\n} // extern \"C\"\n#endif\n\n/** @} */\n"
  },
  {
    "path": "Libraries/CricketAudio/iOS/Headers/ck/config.h",
    "content": "// Copyright 2016 Cricket Technology\n// www.crickettechnology.com\n/** @file */\n/** @defgroup CkConfig CkConfig */\n/** @{ */\n\n#pragma once\n#include \"ck/platform.h\"\n\n#if CK_PLATFORM_ANDROID\n#  include <jni.h>\n#endif\n\n////////////////////////////////////////\n\n/** Memory allocation function */\ntypedef void* (*CkAllocFunc)(int bytes);\n/** Memory deallocation function */\ntypedef void (*CkFreeFunc)(void*);\n\n\n/** Log message types */\ntypedef enum \n{\n    /** Flag to enable INFO log messages */\n    kCkLog_Info =  (1 << 0),\n\n    /** Flag to enable WARNING log messages */\n    kCkLog_Warning = (1 << 1),\n\n    /** Flag to enable ERROR log messages */\n    kCkLog_Error = (1 << 2),\n\n    /** Flag to disable all log messages */\n    kCkLog_None = 0,\n\n    /** Flag to enable all log messages */\n    kCkLog_All = (kCkLog_Info | kCkLog_Warning | kCkLog_Error)\n\n} CkLogType;\n\n\n/** Log message function */\ntypedef void (*CkLogFunc)(CkLogType, const char* msg);\n\n\n/** Sample types used for internal DSP pipeline */\ntypedef enum\n{\n    /** Force floating-point samples */\n    kCkSampleType_Float,\n\n    /** Force fixed-point samples */\n    kCkSampleType_Fixed,\n    \n    /** Use the default, based on the processor type */\n    kCkSampleType_Default\n\n} CkSampleType;\n\n\n////////////////////////////////////////\n\n/** Configuration options */\nstruct _CkConfig\n{\n#ifdef __cplusplus\n#  if CK_PLATFORM_ANDROID\n    /** Constructor to be used from JNI functions.\n      @param env      A JNI environment pointer\n      @param context  An android.content.Context object from Java (typically an\n                       android.app.Activity or android.app.Service)\n     */\n    _CkConfig(JNIEnv* env, jobject context);\n\n    /** This constructor should be used when there is no valid JNIEnv* pointer; for\n      example, from android_main() in a native activity using the android_native_app_glue\n      library.  See the code in src/samples/hellocricket/android-ndk-native for an example.\n      @param vm       A Java VM pointer\n      @param context  An android.content.Context object from Java (typically an\n                       android.app.Activity or android.app.Service)\n     */\n    _CkConfig(JavaVM* vm, jobject context);\n#  else\n    _CkConfig();\n#  endif\n#endif // __cplusplus\n\n#if CK_PLATFORM_ANDROID\n    /** The JNIEnv pointer.\n      @par Only available on Android. */\n    JNIEnv* jni;\n\n    /** The JavaVM pointer.\n      @par Only available on Android. */\n    JavaVM* vm;\n\n    /** A Java reference to your app's Context object (typically an Activity or Service).\n      @par Only available on Android. */\n    jobject context;\n\n    /** If true, always use Java AudioTrack for output of final mix, instead of OpenSL ES.\n      This should usually be set to false, unless you are debugging specific issues\n      related to low-level audio output.\n      Default is false (use Java AudioTrack only when OpenSL ES is not available, i.e. Android versions prior to 2.3). \n      @par Only available on Android. */\n    bool useJavaAudio;\n\n    /** If true, software support for Ogg Vorbis stream sounds is enabled.\n      If false, stream sounds will use the native Android decoder, which will not\n      support all of the features available to sounds decoded in software.\n      Default is true (Ogg Vorbis streams are decoded in software).\n      @par Only available on Android. */\n    bool enableOggVorbis;\n#endif\n\n#if CK_PLATFORM_IOS || CK_PLATFORM_TVOS\n    /** If true, hardware-assisted decoding is enabled for decoding compressed streams\n      when available.  See Apple's \"Multimedia Programming Guide\" for a list of codecs\n      for which hardware support is available.  Note that streams that use the hardware\n      decoder take slightly longer (~300ms) to initialize, and our tests have shown\n      a negligible effect on CPU usage, so the default value is false.\n      @par Only available on iOS. */\n    bool enableHardwareDecoding;\n#endif\n\n    /** Memory allocation function.\n      Default is NULL (system new will be used). \n      The allocator must be thread-safe. */\n    CkAllocFunc allocFunc;\n\n    /** Memory deallocation function.\n      Default is NULL (system delete will be used). \n      The allocator must be thread-safe. */\n    CkFreeFunc freeFunc;\n\n\n    /** Bitmask for which types of messages are logged. \n      Default is kCkLog_All (all messages logged). */\n    unsigned int logMask;\n\n    /** Function to handle log messages.\n      Default is NULL (printf or equivalent will be used). */\n    CkLogFunc logFunc;\n\n\n    /** Audio processing frame duration, in ms.\n      Shorter times result in lower latency, but require more CPU.\n      Default is 5 ms. */\n    float audioUpdateMs;\n\n    /** Size of buffer for stream sounds, in ms.\n      Larger buffers require more memory, but are less likely\n      to skip due to slow file reads.\n      Default is 500 ms. */\n    float streamBufferMs;\n\n    /** Interval between file reads for stream sounds, in ms.\n      Shorter times will allow for smaller stream buffer sizes, but require more CPU.\n      This value should be set to significantly less than streamBufferMs, or your buffers will always underrun!\n      Default is 100 ms. */\n    float streamFileUpdateMs;\n\n    /** Initial size of the audio task buffer.  If you see a \"Reallocating\n      audio task buffer\" warning, consider increasing this from its default value\n      of 500 to avoid additional memory allocations at runtime. */\n    int maxAudioTasks;\n\n    /** Maximum render load. When the value of CkGetRenderLoad() exceeds this value,\n      some sounds will not be rendered, to keep the CPU usage down.\n      Default is 0.8. */\n    float maxRenderLoad;\n\n    /** Sample type to be used internally for processing.  The default is \n      kCkSampleType_Default, which means that fixed-point samples are used on Android \n      armv5 and armv6 devices, which may lack hardware support for floating-point \n      operations, and that floating-point samples are used on all other devices. */\n    CkSampleType sampleType;\n};\n\ntypedef struct _CkConfig CkConfig;\n\n/** Default value of CkConfig.audioUpdateMs */\nextern const float CkConfig_audioUpdateMsDefault;\n\n/** Default value of CkConfig.streamBufferMs */\nextern const float CkConfig_streamBufferMsDefault;\n\n/** Default value of CkConfig.streamFileUpdateMs */\nextern const float CkConfig_streamFileUpdateMsDefault;\n\n/** Default value of CkConfig.maxAudioTasks */\nextern const int CkConfig_maxAudioTasksDefault;\n\n/** Default value of CkConfig.maxRenderLoad */\nextern const float CkConfig_maxRenderLoadDefault;\n\n////////////////////////////////////////\n\n#ifdef __OBJC__\n\n/** If you are using Objective-C, call CkConfigInit() to initialize the CkConfig\n  struct to its default values.\n  (If you are using C++, the CkConfig struct is initialized by its constructor.) */\n\n#ifdef __cplusplus\nextern \"C\"\n#endif\nvoid CkConfigInit(CkConfig*);\n\n#endif\n\n/** @} */\n"
  },
  {
    "path": "Libraries/CricketAudio/iOS/Headers/ck/customfile.h",
    "content": "// Copyright 2016 Cricket Technology\n// www.crickettechnology.com\n/** @file */\n/** @defgroup CkCustomFile CkCustomFile */\n/** @{ */\n\n#pragma once\n#include \"ck/platform.h\"\n#include \"ck/pathtype.h\"\n\n\n/** Custom file base class.  \n  \n  If you want to override the low-level details of how \n  files are read (for example, to read files over a network, or to decrypt encrypted\n  files as they are read), create a subclass and register a handler with \n  CkSetCustomFileHandler().\n\n  This will work for bank files, and for .cks and Ogg Vorbis streams, but not for\n  other stream types such as MP3, AAC, etc. */\n\nclass CkCustomFile\n{\npublic:\n    virtual ~CkCustomFile() {}\n\n    /** Returns true if the file was successfully opened. */\n    virtual bool isValid() const = 0;\n\n    /** Read from the file.  Returns number of bytes actually read. */\n    virtual int read(void* buf, int bytes) = 0;\n\n    /** Returns the size of the file. */\n    virtual int getSize() const = 0;\n\n    /** Sets the read position in the file. */\n    virtual void setPos(int pos) = 0;\n\n    /** Returns the read position in the file. */\n    virtual int getPos() const = 0;\n};\n\n\n/** Factory function for opening files using a CkCustomFile instance.\n  The function should return CkCustomFile instance, or NULL to open \n  the file with the default handler. */\ntypedef CkCustomFile* (*CkCustomFileFunc)(const char* path, void* data);\n\n/** Set the file handler. \n  Set it to NULL to use the default handler. */\nvoid CkSetCustomFileHandler(CkCustomFileFunc, void* data);\n\n\n/** @} */\n\n\n"
  },
  {
    "path": "Libraries/CricketAudio/iOS/Headers/ck/customstream.h",
    "content": "// Copyright 2016 Cricket Technology\n// www.crickettechnology.com\n/** @file */\n/** @defgroup CkCustomStream CkCustomStream */\n/** @{ */\n\n#pragma once\n#include \"ck/platform.h\"\n\n\n/** Base class for custom streams.\n  To create a custom stream sound (for example, for playing back audio in\n  a proprietary file format), create a subclass, then register a factory\n  function with CkSound::setCustomStreamHandler(). */\n\nclass CkCustomStream\n{\npublic:\n    virtual ~CkCustomStream() {}\n\n    /** Initializes the stream (open data files, read file headers, etc).\n    This is called from the file streaming thread, not the main thread,\n    so synchronous file reading calls will not block audio or application logic. */\n    virtual void init() = 0;\n\n    /** Returns whether the stream has failed in a way that renders it\n      unusable; for example, if an audio file could not be found. */\n    virtual bool isFailed() const = 0;\n\n    /** Returns the number of channels; should be either 1 or 2. */\n    virtual int getChannels() const = 0;\n\n    /** Returns the sample rate of the audio. */\n    virtual int getSampleRate() const = 0;\n\n    /** Returns the total duration of the sound, in sample frames. */\n    virtual int getLength() const = 0;\n\n    /** Reads audio into the buffer; returns the number of sample frames\n      actually read. The audio data should be 16-bit signed PCM. */\n    virtual int read(short* buf, int frames) = 0;\n\n    /** Sets the current play position, in sample frames. */\n    virtual void setPlayPosition(int frame) = 0;\n\n    /** Returns the current play position, in sample frames. */\n    virtual int getPlayPosition() const = 0;\n\n};\n\n\n/** @} */\n\n"
  },
  {
    "path": "Libraries/CricketAudio/iOS/Headers/ck/effect.h",
    "content": "// Copyright 2016 Cricket Technology\n// www.crickettechnology.com\n/** @file */\n/** @defgroup CkEffect CkEffect */\n/** @{ */\n\n#pragma once\n#include \"ck/platform.h\"\n#include \"ck/effecttype.h\"\n#include <stddef.h>\n\nclass CkEffectProcessor;\n\n\n/** An audio effect. */\nclass CkEffect\n{\npublic:\n    /** Set an effect parameter. \n      Parameter IDs are found in ck/effectparam.h. */\n    virtual void setParam(int paramId, float value) = 0;\n\n\n    /** Reset the state of this effect. */\n    virtual void reset() = 0;\n\n\n    /** Set whether this effect is bypassed.\n      A bypassed effect is not applied to the audio. */\n    virtual void setBypassed(bool) = 0;\n\n    /** Gets whether this effect is bypassed.\n      A bypassed effect is not applied to the audio. */\n    virtual bool isBypassed() const = 0;\n\n\n    /** Sets the wet/dry ratio for this effect\n      The ratio can range from 0 to 1.\n      A value of 0 means the audio is left completely \"dry\", that is, with no\n      effects applied; it is equivalent to bypassing the ffect.\n      A value of 1 means the audio is completely \"wet\", that is, the original\n      \"dry\" signal is not mixed back into the processed audio. */\n    virtual void setWetDryRatio(float) = 0;\n\n    /** Gets the wet/dry ratio for this effect.\n      The ratio can range from 0 to 1.\n      A value of 0 means the audio is left completely \"dry\", that is, with no\n      effects applied; it is equivalent to bypassing the effect.\n      A value of 1 means the audio is completely \"wet\", that is, the original\n      \"dry\" signal is not mixed back into the processed audio. */\n    virtual float getWetDryRatio() const = 0;\n\n\n    /** Create a built-in effect. \n      Effect types are found in ck/effecttype.h. */\n    static CkEffect* newEffect(CkEffectType);\n\n\n    /** Factory function for creating effect processors for custom effects. */\n    typedef CkEffectProcessor* (*CustomEffectFunc)(void* arg);\n\n    /** Register a custom effect. \n     To unregister an effect, pass in NULL for the CustomEffectFunc. */\n    static void registerCustomEffect(int id, CustomEffectFunc);\n\n    /** Create a custom effect.\n      A factory function must have been previously registered with the given id,\n      or this will return NULL. */\n    static CkEffect* newCustomEffect(int id, void* arg = NULL);\n\n\n    /** Destroy the effect. */\n    virtual void destroy() = 0;\n\nprotected:\n    CkEffect() {}\n    virtual ~CkEffect() {}\n\nprivate:\n    CkEffect(const CkEffect&);\n    CkEffect& operator=(const CkEffect&);\n};\n\n\n/** @} */\n"
  },
  {
    "path": "Libraries/CricketAudio/iOS/Headers/ck/effectbus.h",
    "content": "// Copyright 2016 Cricket Technology\n// www.crickettechnology.com\n/** @file */\n/** @defgroup CkEffectBus CkEffectBus */\n/** @{ */\n\n#pragma once\n#include \"ck/platform.h\"\n\n\nclass CkEffect;\n\n/** Manages a set of audio effects applied to sounds. */\nclass CkEffectBus\n{\npublic:\n\n    /** Add an effect to this bus.\n      An effect can only be on one bus at a time. */\n    virtual void addEffect(CkEffect*) = 0;\n\n    /** Remove an effect from this bus. */\n    virtual void removeEffect(CkEffect*) = 0;\n\n    /** Remove all effects from this bus. */\n    virtual void removeAllEffects() = 0;\n\n\n    /** Set the bus to which this bus's output is sent.\n      If NULL (the default), the audio from this bus is mixed into the final output. */\n    virtual void setOutputBus(CkEffectBus*) = 0;\n\n    /** Get the bus to which this bus's output is sent.\n      If NULL (the default), the audio from this bus is mixed into the final output. */\n    virtual CkEffectBus* getOutputBus() = 0;\n\n\n    /** Reset the state of all the effects on this bus. */\n    virtual void reset() = 0;\n\n\n    /** Set whether this bus is bypassed.\n      A bypassed effect is not applied to the audio. */\n    virtual void setBypassed(bool) = 0;\n\n    /** Gets whether this bus is bypassed.\n      Effects in a bypassed bus are not applied to the audio. */\n    virtual bool isBypassed() const = 0;\n\n\n    /** Sets the wet/dry ratio for this bus.\n      The ratio can range from 0 to 1.\n      A value of 0 means the audio is left completely \"dry\", that is, with no\n      effects applied; it is equivalent to bypassing the bus.\n      A value of 1 means the audio is completely \"wet\", that is, the original\n      \"dry\" signal is not mixed back into the processed audio. */\n    virtual void setWetDryRatio(float) = 0;\n\n    /** Gets the wet/dry ratio for this bus.\n      The ratio can range from 0 to 1.\n      A value of 0 means the audio is left completely \"dry\", that is, with no\n      effects applied; it is equivalent to bypassing the bus.\n      A value of 1 means the audio is completely \"wet\", that is, the original\n      \"dry\" signal is not mixed back into the processed audio. */\n    virtual float getWetDryRatio() const = 0;\n\n    ////////////////////////////////////////\n\n    /** Create a new effect bus. */\n    static CkEffectBus* newEffectBus();\n\n    /** Get the global effect bus.\n      Effects on this bus are applied to the final audio before it is output. */\n    static CkEffectBus* getGlobalEffectBus();\n\n    /** Destroy this effect bus. */\n    virtual void destroy() = 0;\n\nprotected:\n    CkEffectBus() {}\n    virtual ~CkEffectBus() {}\n\nprivate:\n    CkEffectBus(const CkEffectBus&);\n    CkEffectBus& operator=(const CkEffectBus&);\n\n};\n\n/** @} */\n\n"
  },
  {
    "path": "Libraries/CricketAudio/iOS/Headers/ck/effectparam.h",
    "content": "// Copyright 2016 Cricket Technology\n// www.crickettechnology.com\n/** @file */\n/** @defgroup CkEffectParam CkEffectParam */\n/** @{ */\n\n#pragma once\n#include \"ck/platform.h\"\n\n/** Parameters for the Biquad Filter effect */\nenum\n{\n    /** Type of filter; should be one of the kCkBiquadFilterParam_FilterType values. */\n    kCkBiquadFilterParam_FilterType,\n\n    /** Center frequency of the filter. */\n    kCkBiquadFilterParam_Freq,\n\n    /** Q of the filter. */\n    kCkBiquadFilterParam_Q,\n\n    /** Gain in dB (for Peak, LowShelf, and HighShelf filter types) */\n    kCkBiquadFilterParam_Gain,\n};\n\n\n/** Filter types, used for the kCkBiquadFilterParam_FilterType param. */\nenum\n{\n    /** Low pass filter blocks high frequencies. */\n    kCkBiquadFilterParam_FilterType_LowPass,\n\n    /** High pass filter blocks low frequencies. */\n    kCkBiquadFilterParam_FilterType_HighPass,\n    \n    /** Band pass filter blocks frequencies above and below the center frequency. */\n    kCkBiquadFilterParam_FilterType_BandPass,\n\n    /** Notch filter blocks a narrow band of frequencies. */\n    kCkBiquadFilterParam_FilterType_Notch,\n\n    /** Peak filter boosts a narrow band of frequencies. */\n    kCkBiquadFilterParam_FilterType_Peak,\n\n    /** Low shelf filter boosts low frequencies. */\n    kCkBiquadFilterParam_FilterType_LowShelf,\n\n    /** High shelf filter boosts high frequencies. */\n    kCkBiquadFilterParam_FilterType_HighShelf\n};\n\n\n////////////////////////////////////////\n\n\n/** Parameters for the Bit Crusher effect */\nenum\n{\n    /** Number of bits of resolution to keep in the input samples, in [1..24]. */\n    kCkBitCrusherParam_BitResolution,\n\n    /** Milliseconds to hold each sample value.  Higher values result in more\n      reduction in the effective sample rate.  Values around 1 ms provide a reasonable effect. */\n    kCkBitCrusherParam_HoldMs,\n};\n\n\n////////////////////////////////////////\n\n\n/** Parameters for the Ring Mod effect */\nenum\n{\n    /** Frequency (Hz) of the modulating signal. Values around 500 Hz are typical. */\n    kCkRingModParam_Freq,\n};\n\n////////////////////////////////////////\n\n\n/** Parameters for the Distortion effect */\nenum\n{\n    /** Scale factor for input; larger values cause a more pronounced effect. */\n    kCkDistortionParam_Drive,\n\n    /** Offset for input. */\n    kCkDistortionParam_Offset,\n};\n\n\n\n\n/** @} */\n\n\n"
  },
  {
    "path": "Libraries/CricketAudio/iOS/Headers/ck/effectprocessor.h",
    "content": "// Copyright 2016 Cricket Technology\n// www.crickettechnology.com\n/** @file */\n/** @defgroup CkEffectProcessor CkEffectProcessor */\n/** @{ */\n\n#pragma once\n#include \"ck/platform.h\"\n\n/** Performs audio processing for effects.\n\n  To implement your own custom audio effects, create a subclass, then register a factory\n  function that creates an instance of it with CkEffect::registerCustomEffect(). */\n\nclass CkEffectProcessor\n{\npublic:\n    virtual ~CkEffectProcessor() {}\n\n    /** Set an effect parameter.\n      Note that this should not be called directly; it is called by CkEffect::setParam(). */\n    virtual void setParam(int paramId, float value) = 0;\n\n    /** Reset this effect's state. */\n    virtual void reset() = 0;\n\n    /** If true, the effect is processed in-place; the input and output will be the\n      same buffer.  If false, input and output will be separate buffers. */\n    virtual bool isInPlace() const = 0;\n\n    /** Process audio.\n      The buffer contains interleaved stereo data; each sample is a signed 8.24 fixed-point value.\n      If isInPlace() returns true, inBuf and outBuf will be pointers to the same buffer. \n      It is OK to modify the data in inBuf, even if the effect is not in-place.\n      (Remember that because the data is stereo, the number of samples is 2*frames.) \n\n      @par This will only be called on older Android armv5 or armv6 devices, or if CkConfig.sampleType is set to kCkSampleType_Fixed.\n      If you are not supporting those devices, you may leave this with its default implementation, which passes the audio \n      through unchanged. */\n    virtual void process(int* inBuf, int* outBuf, int frames);\n\n    /** Process audio.\n      The buffer contains interleaved stereo data; each sample is a 32-bit floating-point value.\n      If isInPlace() returns true, inBuf and outBuf will be pointers to the same buffer. \n      It is OK to modify the data in inBuf, even if the effect is not in-place.\n      (Remember that because the data is stereo, the number of samples is 2*frames.) */\n    virtual void process(float* inBuf, float* outBuf, int frames) = 0;\n\n    /** Get the sample rate of the audio data.  This value may be different on different\n      devices, but will not change during app execution. */\n    static int getSampleRate();\n};\n\n\n/** @} */\n\n"
  },
  {
    "path": "Libraries/CricketAudio/iOS/Headers/ck/effecttype.h",
    "content": "// Copyright 2016 Cricket Technology\n// www.crickettechnology.com\n/** @file */\n/** @defgroup CkEffectType CkEffectType */\n/** @{ */\n\n#pragma once\n#include \"ck/platform.h\"\n\n/** Types of built-in effects available */\ntypedef enum \n{\n    /** Biquadratic filter. \n      See kCkBiquadFilterParam values for parameter IDs. */\n    kCkEffectType_BiquadFilter,\n\n    /** Bit Crusher effect reduces bit resolution and/or bit rate, producing a retro\n      low-fi 8-bit sound.\n      See kCkBitCrusherParam values for parameter IDs. */\n    kCkEffectType_BitCrusher,\n\n    /** Ring Mod effect modulates the audio by a sine wave. \n      See kCkRingModParam values for parameter IDs. */\n    kCkEffectType_RingMod,\n\n    /** Distortion effect.\n      See kCkDistortionParam values for parameter IDs. */\n    kCkEffectType_Distortion,\n\n} CkEffectType;\n\n\n/** @} */\n"
  },
  {
    "path": "Libraries/CricketAudio/iOS/Headers/ck/mixer.h",
    "content": "// Copyright 2016 Cricket Technology\n// www.crickettechnology.com\n/** @file */\n/** @defgroup CkMixer CkMixer */\n/** @{ */\n\n#pragma once\n#include \"ck/platform.h\"\n#include <stddef.h>\n\n\n/** A mixer represents a hierarchical grouping of sounds for controlling volumes. */\n\nclass CkMixer\n{\npublic:\n    /** Set the name of the mixer.\n      The name should be 31 characters or less. */\n    virtual void setName(const char*) = 0;\n\n    /** Get the name of the mixer. */\n    virtual const char* getName() const = 0;\n\n\n    /** Set the volume of this mixer.\n      (The actual volume used during mixing will also depend on ancestors.) */\n    virtual void setVolume(float) = 0;\n\n    /** Get the volume of this mixer.\n      (The actual volume used during mixing will also depend on ancestors.) */\n    virtual float getVolume() const = 0;\n\n\n    /** Get the volume used for mixing (affected by ancestors). */\n    virtual float getMixedVolume() const = 0;\n\n\n    /** Set whether this mixer is paused.\n      A sound will be paused if the sound, its mixer, or any of its mixer's ancestors\n      are paused. */\n    virtual void setPaused(bool) = 0;\n\n    /** Get whether this mixer is paused.\n      A sound will be paused if the sound, its mixer, or any of its mixer's ancestors\n      are paused. */\n    virtual bool isPaused() const = 0;\n\n\n    /** Returns true if this mixer, or any of its ancestors, is paused. */\n    virtual bool getMixedPauseState() const = 0;\n\n\n    /** Set the parent of the mixer.\n      Setting to NULL sets the master mixer as the parent. */\n    virtual void setParent(CkMixer*) = 0;\n\n    /** Get the parent of the mixer. */\n    virtual CkMixer* getParent() = 0;\n\n\n    /** Returns the master mixer, which is the root of the mixer hierarchy. */\n    static CkMixer* getMaster();\n\n    /** Creates a new mixer. */\n    static CkMixer* newMixer(const char* name, CkMixer* parent = NULL);\n\n    /** Finds a mixer by name; returns NULL if not found. */\n    static CkMixer* find(const char* name);\n\n\n    /** Destroys the mixer. */\n    virtual void destroy() = 0;\n\nprotected:\n    CkMixer() {}\n    virtual ~CkMixer() {}\n\nprivate:\n    CkMixer(const CkMixer&);\n    CkMixer& operator=(const CkMixer&);\n};\n\n/** @} */\n"
  },
  {
    "path": "Libraries/CricketAudio/iOS/Headers/ck/objc/attenuationmode.h",
    "content": "// Copyright 2016 Cricket Technology\n// www.crickettechnology.com\n\n#import \"ck/attenuationmode.h\"\n\n\n"
  },
  {
    "path": "Libraries/CricketAudio/iOS/Headers/ck/objc/bank.h",
    "content": "// Copyright 2016 Cricket Technology\n// www.crickettechnology.com\n\n#import <Foundation/Foundation.h>\n#import \"ck/objc/pathtype.h\"\n\n\n/** Objective-C interface for CkBank.\n  See ck/bank.h for method documentation. */\n@interface CkoBank : NSObject\n\n@property(nonatomic, readonly) BOOL loaded;\n@property(nonatomic, readonly) BOOL failed;\n@property(nonatomic, readonly, nonnull) NSString* name;\n@property(nonatomic, readonly) int numSounds;\n\n- (nonnull NSString*) soundName:(int)index;\n\n+ (nullable CkoBank*) newBank:(nonnull NSString*)path;\n+ (nullable CkoBank*) newBank:(nonnull NSString*)path pathType:(CkPathType)pathType;\n+ (nullable CkoBank*) newBank:(nonnull NSString*)path pathType:(CkPathType)pathType offset:(int)offset length:(int)length;\n+ (nullable CkoBank*) newBankAsync:(nonnull NSString*)path;\n+ (nullable CkoBank*) newBankAsync:(nonnull NSString*)path pathType:(CkPathType)pathType;\n+ (nullable CkoBank*) newBankAsync:(nonnull NSString*)path pathType:(CkPathType)pathType offset:(int)offset length:(int)length;\n+ (nullable CkoBank*) newBankFromMemory:(nonnull void*)buf bytes:(int)bytes;\n\n+ (nullable CkoBank*) find:(nonnull NSString*)name;\n\n@end\n\n\n\n\n"
  },
  {
    "path": "Libraries/CricketAudio/iOS/Headers/ck/objc/ck.h",
    "content": "// Copyright 2016 Cricket Technology\n// www.crickettechnology.com\n\n#import \"ck/ck.h\"\n"
  },
  {
    "path": "Libraries/CricketAudio/iOS/Headers/ck/objc/config.h",
    "content": "// Copyright 2016 Cricket Technology\n// www.crickettechnology.com\n\n#import \"ck/config.h\"\n"
  },
  {
    "path": "Libraries/CricketAudio/iOS/Headers/ck/objc/effect.h",
    "content": "// Copyright 2016 Cricket Technology\n// www.crickettechnology.com\n\n#import <Foundation/Foundation.h>\n#import \"ck/effecttype.h\"\n\n\n/** Objective-C interface for CkEffect.\n  See ck/effect.h for method documentation. */\n@interface CkoEffect : NSObject\n\n@property(nonatomic, assign) BOOL bypassed;\n@property(nonatomic, assign) float wetDryRatio;\n\n- (void) setParam:(int)paramId value:(float)value;\n\n- (void) reset;\n\n+ (nullable CkoEffect*) newEffect:(CkEffectType)type;\n+ (nullable CkoEffect*) newCustomEffect:(int)id;\n\n@end\n\n\n\n\n"
  },
  {
    "path": "Libraries/CricketAudio/iOS/Headers/ck/objc/effectbus.h",
    "content": "// Copyright 2016 Cricket Technology\n// www.crickettechnology.com\n\n#import <Foundation/Foundation.h>\n\n@class CkoEffect;\n\n/** Objective-C interface for CkEffectBus.\n  See ck/effectbus.h for method documentation. */\n@interface CkoEffectBus : NSObject\n\n@property(nonatomic, assign) BOOL bypassed;\n@property(nonatomic, assign) float wetDryRatio;\n@property(nonatomic, assign, nullable) CkoEffectBus* outputBus;\n\n- (void) addEffect:(nonnull CkoEffect*)effect;\n- (void) removeEffect:(nonnull CkoEffect*)effect;\n- (void) removeAllEffects;\n\n- (void) reset;\n\n+ (nullable CkoEffectBus*) newEffectBus;\n+ (nonnull CkoEffectBus*) globalEffectBus;\n\n@end\n\n\n\n\n\n"
  },
  {
    "path": "Libraries/CricketAudio/iOS/Headers/ck/objc/effectparam.h",
    "content": "// Copyright 2016 Cricket Technology\n// www.crickettechnology.com\n\n#import \"ck/effectparam.h\"\n\n\n\n"
  },
  {
    "path": "Libraries/CricketAudio/iOS/Headers/ck/objc/effecttype.h",
    "content": "// Copyright 2016 Cricket Technology\n// www.crickettechnology.com\n\n#import \"ck/effecttype.h\"\n\n\n"
  },
  {
    "path": "Libraries/CricketAudio/iOS/Headers/ck/objc/mixer.h",
    "content": "// Copyright 2016 Cricket Technology\n// www.crickettechnology.com\n\n#import <Foundation/Foundation.h>\n\n\n/** Objective-C interface for CkMixer.\n  See ck/mixer.h for method documentation. */\n@interface CkoMixer : NSObject\n\n@property(nonatomic, copy, nonnull) NSString* name;\n@property(nonatomic, assign) float volume;\n@property(nonatomic, readonly) float mixedVolume;\n@property(nonatomic, assign) BOOL paused;\n@property(nonatomic, readonly) BOOL mixedPauseState;\n@property(nonatomic, assign, nullable) CkoMixer* parent;\n\n+ (nonnull CkoMixer*) master;\n\n+ (nullable CkoMixer*) find:(nonnull NSString*)name;\n\n+ (nullable CkoMixer*) newMixer:(nonnull NSString*)name;\n+ (nullable CkoMixer*) newMixer:(nonnull NSString*)name parent:(nullable CkoMixer*)parent;\n\n@end\n\n\n\n"
  },
  {
    "path": "Libraries/CricketAudio/iOS/Headers/ck/objc/pathtype.h",
    "content": "// Copyright 2016 Cricket Technology\n// www.crickettechnology.com\n\n#import \"ck/pathtype.h\"\n\n"
  },
  {
    "path": "Libraries/CricketAudio/iOS/Headers/ck/objc/platform.h",
    "content": "// Copyright 2016 Cricket Technology\n// www.crickettechnology.com\n\n#import \"ck/platform.h\"\n\n"
  },
  {
    "path": "Libraries/CricketAudio/iOS/Headers/ck/objc/sound.h",
    "content": "// Copyright 2016 Cricket Technology\n// www.crickettechnology.com\n\n#import \"ck/objc/pathtype.h\"\n#import \"ck/objc/attenuationmode.h\"\n\n@class CkoBank;\n@class CkoMixer;\n@class CkoEffectBus;\n\n/** Objective-C interface for CkSound.\n  See ck/sound.h for method documentation. */\n@interface CkoSound : NSObject\n\n@property(nonatomic, assign, null_resettable) CkoMixer* mixer;\n@property(nonatomic, readonly) BOOL ready;\n@property(nonatomic, readonly) BOOL failed;\n@property(nonatomic, readonly) BOOL playing;\n@property(nonatomic, assign) BOOL paused;\n@property(nonatomic, assign) int loopCount;\n@property(nonatomic, readonly) int loopStart;\n@property(nonatomic, readonly) int loopEnd;\n@property(nonatomic, readonly) int currentLoop;\n@property(nonatomic, readonly) BOOL loopReleased;\n@property(nonatomic, assign) float volume;\n@property(nonatomic, assign) int playPosition;\n@property(nonatomic, assign) float playPositionMs;\n@property(nonatomic, readonly) float mixedVolume;\n@property(nonatomic, assign) float pan;\n@property(nonatomic, assign) float pitchShift;\n@property(nonatomic, assign) float speed;\n@property(nonatomic, assign, nullable) CkoSound* nextSound;\n@property(nonatomic, readonly) int length;\n@property(nonatomic, readonly) float lengthMs;\n@property(nonatomic, readonly) int sampleRate;\n@property(nonatomic, readonly) int channels;\n@property(nonatomic, assign, nullable) CkoEffectBus* effectBus;\n@property(nonatomic, assign) BOOL threeDEnabled;\n@property(nonatomic, readonly) BOOL isVirtual;\n\n- (void) play;\n- (void) stop;\n\n- (void) setLoop:(int)startFrame endFrame:(int)endFrame;\n- (void) releaseLoop;\n\n- (void) setPanMatrixLL:(float)ll LR:(float)lr RL:(float)rl RR:(float)rr;\n- (void) getPanMatrixLL:(nonnull float*)ll LR:(nonnull float*)lr RL:(nonnull float*)rl RR:(nonnull float*)rr;\n\n- (void) set3dPositionX:(float)x y:(float)y z:(float)z;\n- (void) get3dPositionX:(nonnull float*)x y:(nonnull float*)y z:(nonnull float*)z;\n- (void) set3dVelocityX:(float)x y:(float)y z:(float)z;\n- (void) get3dVelocityX:(nonnull float*)x y:(nonnull float*)y z:(nonnull float*)z;\n\n+ (void) set3dListenerPositionEyeX:(float)eyeX eyeY:(float)eyeY eyeZ:(float)eyeZ\n           lookAtX:(float)lookAtX lookAtY:(float)lookAtY lookAtZ:(float)lookAtZ\n           upX:(float)upX upY:(float)upY upZ:(float)upZ;\n+ (void) get3dListenerPositionEyeX:(nonnull float*)eyeX eyeY:(nonnull float*)eyeY eyeZ:(nonnull float*)eyeZ\n           lookAtX:(nonnull float*)lookAtX lookAtY:(nonnull float*)lookAtY lookAtZ:(nonnull float*)lookAtZ\n           upX:(nonnull float*)upX upY:(nonnull float*)upY upZ:(nonnull float*)upZ;\n+ (void) set3dListenerVelocityX:(float)x y:(float)y z:(float)z;\n+ (void) get3dListenerVelocityX:(nonnull float*)x y:(nonnull float*)y z:(nonnull float*)z;\n\n+ (void) set3dAttenuationMode:(CkAttenuationMode)mode nearDist:(float)nearDist farDist:(float)farDist farVol:(float)farVol;\n+ (void) get3dAttenuationMode:(nonnull CkAttenuationMode*)mode nearDist:(nonnull float*)nearDist farDist:(nonnull float*)farDist farVol:(nonnull float*)farVol;\n\n+ (void) set3dSoundSpeed:(float)speed;\n+ (float) get3dSoundSpeed;\n\n+ (float) getSoundSpeedCentimetersPerSecond;\n+ (float) getSoundSpeedMetersPerSecond;\n+ (float) getSoundSpeedInchesPerSecond;\n+ (float) getSoundSpeedFeetPerSecond;\n\n+ (nullable CkoSound*) newBankSound:(nullable CkoBank*)bank index:(int)index;\n+ (nullable CkoSound*) newBankSound:(nullable CkoBank*)bank name:(nonnull NSString*)name;\n+ (nullable CkoSound*) newStreamSound:(nonnull NSString*)path; \n+ (nullable CkoSound*) newStreamSound:(nonnull NSString*)path pathType:(CkPathType)pathType;\n+ (nullable CkoSound*) newStreamSound:(nonnull NSString*)path pathType:(CkPathType)pathType offset:(int)offset length:(int)length extension:(nonnull NSString*)extension;\n#if CK_PLATFORM_IOS\n+ (nullable CkoSound*) newAssetStreamSound:(nonnull NSURL*)url; \n#endif\n\n@end\n\n\n"
  },
  {
    "path": "Libraries/CricketAudio/iOS/Headers/ck/pathtype.h",
    "content": "// Copyright 2016 Cricket Technology\n// www.crickettechnology.com\n/** @file */\n/** @defgroup CkPathType CkPathType */\n/** @{ */\n\n#pragma once\n#include \"ck/platform.h\"\n\n\n/** Indicates how a file path should be interpreted. */\ntypedef enum \n{\n    /** A full path to a file on the file system. */\n    kCkPathType_FileSystem = 0,\n\n#if CK_PLATFORM_ANDROID\n    /** A path to an asset in the .apk. \n      Assets are read-only.\n     @par Only available on Android. */\n    kCkPathType_Asset,\n\n    /** A path relative to the private files directory.\n     @par Only available on Android. */\n    kCkPathType_PrivateFiles,\n\n    /** A path relative to the external storage directory.\n     @par Only available on Android. */\n    kCkPathType_ExternalStorage,\n#endif\n\n#if CK_PLATFORM_IOS || CK_PLATFORM_OSX || CK_PLATFORM_TVOS\n    /** A path relative to the application's resource directory.\n      On iOS, the resource directory is the application bundle, and is read-only.\n      On OS X, the resource directory is the directory containing the executable.\n     @par Only available on iOS and OS X. */\n    kCkPathType_Resource,\n#endif\n\n#if CK_PLATFORM_WP8\n    /** A path relative to the local app data store.\n     @par Only available on Windows Phone 8. */\n    kCkPathType_LocalDir,\n\n    /** A path relative to the folder containing your app's package files.\n      Files in your Visual Studio project with the \"Content\" property set to true will be installed here.\n      This folder is read-only.\n     @par Only available on Windows Phone 8. */\n    kCkPathType_InstallationDir,\n#endif\n\n#if CK_PLATFORM_IOS || CK_PLATFORM_OSX || CK_PLATFORM_TVOS || CK_PLATFORM_WIN || CK_PLATFORM_LINUX\n    /** A path relative to the directory used for temporary files.\n     @par Only available on iOS, OS X, Windows, and Linux. */\n    kCkPathType_Temp,\n#endif\n\n#if CK_PLATFORM_IOS || CK_PLATFORM_OSX || CK_PLATFORM_WIN || CK_PLATFORM_LINUX\n    /** A path relative to the application's documents directory.\n      On iOS, this is the app's Documents directory.\n      On OS X and Windows, this is the user's Documents directory.\n      On Linux, this is the user's home directory.\n     @par Only available on iOS, OS X, Windows, and Linux. */\n    kCkPathType_Documents,\n#endif\n\n#if CK_PLATFORM_WIN || CK_PLATFORM_LINUX || CK_PLATFORM_OSX\n    /** A path relative to the executable's directory. \n     (On OS X, this is the same as kCkPathType_Resource.) \n     @par Only available on Windows, Linux, and OS X.  */\n    kCkPathType_ExeDir,\n#endif\n\n    /** The default path type for reading files. */\n#if CK_PLATFORM_ANDROID\n    kCkPathType_ReadDefault = kCkPathType_Asset,\n#elif CK_PLATFORM_IOS || CK_PLATFORM_OSX || CK_PLATFORM_TVOS\n    kCkPathType_ReadDefault = kCkPathType_Resource,\n#elif CK_PLATFORM_WIN || CK_PLATFORM_LINUX\n    kCkPathType_ReadDefault = kCkPathType_ExeDir,\n#elif CK_PLATFORM_WP8\n    kCkPathType_ReadDefault = kCkPathType_InstallationDir,\n#endif\n\n    /** The default path type for writing files. */\n#if CK_PLATFORM_ANDROID\n    kCkPathType_WriteDefault = kCkPathType_PrivateFiles,\n#elif CK_PLATFORM_IOS || CK_PLATFORM_OSX \n    kCkPathType_WriteDefault = kCkPathType_Documents,\n#elif CK_PLATFORM_TVOS\n    kCkPathType_WriteDefault = kCkPathType_Temp,\n#elif CK_PLATFORM_WIN || CK_PLATFORM_LINUX\n    kCkPathType_WriteDefault = kCkPathType_ExeDir,\n#elif CK_PLATFORM_WP8\n    kCkPathType_WriteDefault = kCkPathType_LocalDir,\n#endif\n\n    /** The default path type. */\n    kCkPathType_Default = kCkPathType_ReadDefault\n\n} CkPathType;\n\n/** @} */\n"
  },
  {
    "path": "Libraries/CricketAudio/iOS/Headers/ck/platform.h",
    "content": "// Copyright 2016 Cricket Technology\n// www.crickettechnology.com\n/** @file */\n\n#pragma once\n\n// software platform\n#undef CK_PLATFORM_IOS\n#undef CK_PLATFORM_TVOS\n#undef CK_PLATFORM_ANDROID\n#undef CK_PLATFORM_OSX\n#undef CK_PLATFORM_WIN\n#undef CK_PLATFORM_WP8\n#undef CK_PLATFORM_LINUX\n\n#ifdef __APPLE__\n#  include <TargetConditionals.h>\n#  if TARGET_OS_IPHONE\n#    if TARGET_OS_IOS\n#      define CK_PLATFORM_IOS 1\n#    elif TARGET_OS_TV\n#      define CK_PLATFORM_TVOS 1\n#    endif\n#  else\n#    define CK_PLATFORM_OSX 1\n#  endif\n#elif defined(__ANDROID__)\n#  define CK_PLATFORM_ANDROID 1\n#elif defined(__linux__)\n#  define CK_PLATFORM_LINUX 1\n#elif defined(_WIN64) || defined(_WIN32)\n#  if defined(WINAPI_FAMILY) && WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP\n#     define CK_PLATFORM_WP8 1\n#  else\n#     define CK_PLATFORM_WIN 1\n#  endif\n#endif\n\n#if CK_PLATFORM_OSX && (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1060)\n#  error \"OS X 10.6 required!\"\n#endif\n\n#if !CK_PLATFORM_IOS && !CK_PLATFORM_ANDROID && !CK_PLATFORM_OSX && !CK_PLATFORM_WIN && !CK_PLATFORM_WP8 && !CK_PLATFORM_LINUX && !CK_PLATFORM_TVOS\n#  error \"Unsupported platform!\"\n#endif\n"
  },
  {
    "path": "Libraries/CricketAudio/iOS/Headers/ck/sound.h",
    "content": "// Copyright 2016 Cricket Technology\n// www.crickettechnology.com\n/** @file */\n/** @defgroup CkSound CkSound */\n/** @{ */\n\n#pragma once\n#include \"ck/platform.h\"\n#include \"ck/pathtype.h\"\n#include \"ck/attenuationmode.h\"\n#include <stddef.h>\n\n\nclass CkBank;\nclass CkMixer;\nclass CkEffectBus;\nclass CkCustomStream;\n\n/** A sound (either memory-resident or streamed). */\n\nclass CkSound \n{\npublic:\n    /** Sets the mixer to which this sound is assigned.\n      Setting NULL will assign it to the master mixer. */\n    virtual void setMixer(CkMixer*) = 0;\n\n    /** Gets the mixer to which this sound is assigned. */\n    virtual CkMixer* getMixer() = 0;\n\n\n    /** Returns true if the sound is ready.\n      Bank sounds are ready immediately after creation; stream sounds may not be. */\n    virtual bool isReady() const = 0;\n\n\n    /** Returns true if an error occurred while creating the sound. */\n    virtual bool isFailed() const = 0;\n\n\n    /** Play the sound. */\n    virtual void play() = 0;\n\n    /** Stop the sound. */\n    virtual void stop() = 0;\n\n    /** Gets whether the sound is playing. */\n    virtual bool isPlaying() const = 0; \n\n\n    /** Sets whether the sound is paused. \n     Note that even if false, the sound will be paused if its mixer or any of its \n     mixer's ancestors are paused.*/\n    virtual void setPaused(bool) = 0;\n\n    /** Gets whether the sound is paused.\n     Note that even if false, the sound will be paused if its mixer or any of its \n     mixer's ancestors are paused.*/\n    virtual bool isPaused() const = 0;\n\n    /** Returns true if the sound is pauses, its mixer is paused, or any of its\n      mixer's ancestors are paused. */\n    virtual bool getMixedPauseState() const = 0;\n\n\n    /** Set the loop start and end.\n      Default is to loop over all sample frames. \n      EndFrame is defined as one frame after the last frame of the loop.\n      Setting endFrame = -1 is equivalent to setting it to getLength(). \n     @par Android note: \n      This has no effect for streams in formats other than .cks or Ogg Vorbis. */\n    virtual void setLoop(int startFrame, int endFrame) = 0;\n\n    /** Get the loop start and end.\n      Default is to loop over all sample frames. \n      EndFrame is defined as one frame after the last frame of the loop.\n      Setting endFrame = -1 is equivalent to setting it to getLength(). \n     @par Android note: \n      This has no effect for streams in formats other than .cks or Ogg Vorbis. */\n    virtual void getLoop(int& startFrame, int& endFrame) const = 0;\n\n    /** Sets the number of times the sound should loop.  \n      0 means no looping (play once and then stop).\n      1 means it will play twice; 2 means it will play 3 times; etc. \n      -1 means it will loop indefinitely until the sound is stopped or releaseLoop() is called. */\n    virtual void setLoopCount(int) = 0;\n\n    /** Gets the number of times the sound should loop.  \n      0 means no looping (play once and then stop).\n      1 means it will play twice; 2 means it will play 3 times; etc. \n      -1 means it will loop indefinitely until the sound is stopped or releaseLoop() is called. */\n    virtual int getLoopCount() const = 0;\n\n    /** Gets the number of the current loop.\n      For example, returns 0 if this is the first time playing through this sample;\n      returns 1 if it is on its second loop through the sample; etc. */\n    virtual int getCurrentLoop() const = 0;\n\n    /** Makes the current loop the last.\n      This is useful when you don't know in advance how many times you will\n      want to loop; set the loop count to -1, and call releaseLoop() when\n      you want it to stop looping and play to the end. */\n    virtual void releaseLoop() = 0;\n\n    /** Returns true if releaseLoop() has been called after the last call to play(). */\n    virtual bool isLoopReleased() const = 0;\n\n\n    /** Set the play position in the sound, in sample frames.\n      This can be called before playing, to start from an offset into\n      the sound; or during playback, to jump to a new location. */\n    virtual void setPlayPosition(int) = 0;\n\n    /** Set the play position in the sound, in milliseconds.\n      This can be called before playing, to start from an offset into\n      the sound; or during playback, to jump to a new location. */\n    virtual void setPlayPositionMs(float) = 0;\n\n    /** Get the current play position in the sound, in sample frames. */\n    virtual int getPlayPosition() const = 0;\n\n    /** Get the current play position in the sound, in milliseconds. */\n    virtual float getPlayPositionMs() const = 0;\n\n\n    /** Sets the volume of this sound.\n      The volume can range from 0 to 1. The default value is 1. \n      Note that the actual volume used for mixing will also depend on the volume of the\n      mixer to which this sound is assigned. */\n    virtual void setVolume(float) = 0;\n\n    /** Gets the volume of this sound.\n      The volume can range from 0 to 1. The default value is 1. \n      Note that the actual volume used for mixing will also depend on the volume of the \n      mixer to which this sound is assigned. */\n    virtual float getVolume() const = 0;\n\n\n    /** Gets the volume value used for mixing. \n      This is the product of the volume set with setVolume() and the mixed\n      volume value of the mixer to which the sound is assigned. */\n    virtual float getMixedVolume() const = 0;\n\n\n    /** Sets the pan.\n      The pan can range from -1 (left) to +1 (right). The default is 0 (center). */\n    virtual void setPan(float) = 0;\n\n    /** Gets the pan.\n      The pan can range from -1 (left) to +1 (right). The default is 0 (center). */\n    virtual float getPan() const = 0;\n\n    /** Sets the pan matrix explicitly.  \n      The pan matrix determines how the left and right channels of an input are weighted during mixing.\n      Usually it is set by setPan(), but you can use setPanMatrix() if you need more control.\n      For a mono input, the left channel of the output is the input scaled by ll, and the right channel of the output is the input scaled by rr.  The off-diagonal lr and rl terms are ignored.\n      For a stereo input, the left channel of the output is the left channel of the input scaled by ll plus the right channel of the input scaled by lr.  The right channel of the output is the left channel of the input scaled by rl plus the right channel of the input scaled by rr.\n      */\n    virtual void setPanMatrix(float ll, float lr, float rl, float rr) = 0;\n\n    /** Gets the pan matrix.\n      The pan matrix determines how the left and right channels of an input are weighted during mixing.\n      Usually it is set by setPan(), but you can use setPanMatrix() if you need more control.\n      For a mono input, the left channel of the output is the input scaled by ll, and the right channel of the output is the input scaled by rr.  The off-diagonal lr and rl terms are ignored.\n      For a stereo input, the left channel of the output is the left channel of the input scaled by ll plus the right channel of the input scaled by lr.  The right channel of the output is the left channel of the input scaled by rl plus the right channel of the input scaled by rr.\n      */\n    virtual void getPanMatrix(float& ll, float& lr, float& rl, float& rr) const = 0;\n\n\n    /** Sets the pitch shift value, in half-steps.\n      This also changes the playback speed of the sound.  \n      Positive values mean higher pitch (and faster playback); lower values mean lower pitch \n      (and slower playback).  The default value is 0. \n     @par Android note: \n      This does not work for streams in formats other than .cks or Ogg Vorbis. */\n    virtual void setPitchShift(float halfSteps) = 0;\n\n    /** Gets the pitch shift value, in half-steps.\n      Positive values mean higher pitch (and faster playback); lower values mean lower pitch \n      (and slower playback).  The default value is 0. \n     @par Android note: \n      This does not work for streams in formats other than .cks or Ogg Vorbis. */\n    virtual float getPitchShift() const = 0;\n\n\n    /** Sets the playback speed.\n      Values greater than 1 mean faster playback; values less than 1 mean\n      slower playback.  The default value is 1.\n     @par Android note: \n      This does not work for streams in formats other than .cks or Ogg Vorbis. */\n    virtual void setSpeed(float) = 0;\n\n    /** Gets the playback speed.\n      Values greater than 1 mean faster playback; values less than 1 mean\n      slower playback.  The default value is 1. \n     @par Android note: \n      This does not work for streams in formats other than .cks or Ogg Vorbis. */\n    virtual float getSpeed() const = 0;\n\n\n    /** Sets the sound to be played when this sound finishes playing.\n      The next sound will play immediately, with no gaps. \n     @par Android note:\n      This does not work for streams in formats other than .cks or Ogg Vorbis. */\n    virtual void setNextSound(CkSound*) = 0;\n\n    /** Gets the sound to be played when this sound finishes playing.\n      The next sound will play immediately, with no gaps.\n     @par Android note:\n      This does not work for streams in formats other than .cks or Ogg Vorbis. */\n    virtual CkSound* getNextSound() const = 0;\n\n\n    /** Gets the total duration of the sound, in sample frames.\n      Stream sounds will return -1 if they are not ready or if the length is unknown. */\n    virtual int getLength() const = 0;\n\n    /** Gets the total duration of the sound, in milliseconds.\n      Stream sounds will return -1 if they are not ready or if the length is unknown. */\n    virtual float getLengthMs() const = 0;\n\n    /** Gets the sample rate of the sound, in Hz.\n      Stream sounds will return -1 if they are not ready. */\n    virtual int getSampleRate() const = 0;\n\n    /** Gets the number of channels in the sound (1 for mono, 2 for stereo).\n      Stream sounds will return -1 if they are not ready. */\n    virtual int getChannels() const = 0;\n\n\n    /** Sets the effect bus to which this sound's audio is sent to be processed, or\n      NULL for dry output (no effects).\n     @par Android note: \n      Effects cannot be applied to streams in formats other than .cks or Ogg Vorbis. */\n    virtual void setEffectBus(CkEffectBus*) = 0;\n\n    /** Gets the effect bus to which this sound's audio is sent to be processed, or\n      NULL for dry output (no effects).\n     @par Android note: \n      Effects cannot be applied to streams in formats other than .cks or Ogg Vorbis. */\n    virtual CkEffectBus* getEffectBus() = 0;\n\n\n    /** Sets whether 3D positioning is enabled.\n      If enabled, pan will be determined by the sound and listener positions,\n      ignoring the value set by setPan().  Volume will be attenuated based\n      on the sound and listener positions and the attenuation settings. */\n    virtual void set3dEnabled(bool) = 0;\n\n    /** Gets whether 3D positioning is enabled. \n      If enabled, pan will be determined by the sound and listener positions,\n      ignoring the value set by setPan().  Volume will be attenuated based\n      on the sound and listener positions and the attenuation settings. */\n    virtual bool is3dEnabled() const = 0;\n\n    /** Gets whether a 3D sound is virtual.\n      If, due to distance attenuation, a 3D sound's volume becomes near enough to 0\n      to be inaudible, it becomes \"virtual\".  A virtual sound is effectively paused\n      and is not processed until it would become audible again; this reduces the \n      amount of audio processing required. */\n    virtual bool isVirtual() const = 0;\n\n    /** Sets the position of the sound emitter in 3D space.\n      This is used for pan and volume calculations when 3D positioning is enabled. */\n    virtual void set3dPosition(float x, float y, float z) = 0;\n\n    /** Gets the position of the sound emitter in 3D space.\n      This is used for pan and volume calculations when 3D positioning is enabled. */\n    virtual void get3dPosition(float& x, float& y, float& z) const = 0;\n\n    /** Sets the velocity of the sound emitter in 3D space.\n      This is used for doppler shift calculations when 3D positioning is enabled.\n      The units should be the same as those used for set3dSoundSpeed(). */\n    virtual void set3dVelocity(float vx, float vy, float vz) = 0;\n\n    /** Gets the velocity of the sound emitter in 3D space.\n      This is used for doppler shift calculations when 3D positioning is enabled.\n      The units should be the same as those used for set3dSoundSpeed(). */\n    virtual void get3dVelocity(float& vx, float& vy, float& vz) const = 0;\n\n    /** Sets the listener position and rotation in 3D space. \n      This is used for pan and volume calculations when 3D positioning is enabled.\n      @param eyeX,eyeY,eyeZ           The listener's position\n      @param lookAtX,lookAtY,lookAtZ  The listener's look-at point\n      @param upX,upY,upZ              The listener's up vector\n      */\n    static void set3dListenerPosition(float eyeX, float eyeY, float eyeZ,\n                                      float lookAtX, float lookAtY, float lookAtZ,\n                                      float upX, float upY, float upZ);\n\n    /** Gets the listener position and rotation in 3D space. \n      This is used for pan and volume calculations when 3D positioning is enabled.\n      @param eyeX,eyeY,eyeZ           The listener's position\n      @param lookAtX,lookAtY,lookAtZ  The listener's look-at point\n      @param upX,upY,upZ              The listener's up vector\n      */\n    static void get3dListenerPosition(float& eyeX, float& eyeY, float& eyeZ,\n                                      float& lookAtX, float& lookAtY, float& lookAtZ,\n                                      float& upX, float& upY, float& upZ);\n\n    /** Sets the listener velocity in 3D space.\n      This is used for doppler shift calculations when 3D positioning is enabled. \n      The units should be the same as those used for set3dSoundSpeed(). */\n    static void set3dListenerVelocity(float vx, float vy, float vz);\n\n    /** Gets the listener velocity in 3D space.\n      This is used for doppler shift calculations when 3D positioning is enabled.\n      The units should be the same as those used for set3dSoundSpeed(). */\n    static void get3dListenerVelocity(float& vx, float& vy, float& vz);\n\n    /** Sets parameters used for 3D volume attenuation. \n      @param mode      The attenuation mode (default is kCkAttenuationMode_InvDistanceSquared)\n      @param nearDist  The near distance; sounds closer than this distance will not be attenuated (default is 1.0)\n      @param farDist   The far distance; sounds further than this will be at the far volume (default is 100.0)\n      @param farVol    The far volume; sounds further than farDist will be at this volume (default is 0.0)\n      */\n    static void set3dAttenuation(CkAttenuationMode mode, float nearDist, float farDist, float farVol);\n\n    /** Gets parameters used for 3D volume attenuation. \n      @param mode      The attenuation mode\n      @param nearDist  The near distance; sounds closer than this distance will not be attenuated.\n      @param farDist   The far distance; sounds further than this will be at the far volume.\n      @param farVol    The far volume; sounds further than farDist will be at this volume.\n      */\n    static void get3dAttenuation(CkAttenuationMode& mode, float& nearDist, float& farDist, float& farVol);\n\n    /** Sets the speed of sound.\n      This is used for doppler shift calculations when 3D positioning is enabled.  If no doppler\n      shift is desired, this can be set to 0 (which is the default value).\n      You may want to use the predefined constants for the speed of sound (such as \n      k_soundSpeed_MetersPerSecond); use the constant that corresponds to\n      the unit system you are using for your velocity and position values.\n      You can also exaggerate the doppler effect by using a smaller value. */\n    static void set3dSoundSpeed(float);\n\n    /** Gets the speed of sound.\n      This is used for doppler shift calculations when 3D positioning is enabled.  */\n    static float get3dSoundSpeed();\n\n    /** The speed of sound in dry air at 20 degrees C, in centimeters per second.\n      This value is provided as a convenience for CkSound::set3dSoundSpeed(). */\n    static const float k_soundSpeed_CentimetersPerSecond;\n\n    /** The speed of sound in dry air at 20 degrees C, in meters per second.\n      This value is provided as a convenience for CkSound::set3dSoundSpeed(). */\n    static const float k_soundSpeed_MetersPerSecond;\n\n    /** The speed of sound in dry air at 20 degrees C, in inches per second.\n      This value is provided as a convenience for CkSound::set3dSoundSpeed(). */\n    static const float k_soundSpeed_InchesPerSecond;\n\n    /** The speed of sound in dry air at 20 degrees C, in feet per second.\n      This value is provided as a convenience for CkSound::set3dSoundSpeed(). */\n    static const float k_soundSpeed_FeetPerSecond;\n\n    ////////////////////////////////////////\n    // bank sounds\n\n    /** Creates a sound from a bank by index. \n      This will return NULL if the index is invalid. */\n    static CkSound* newBankSound(CkBank*, int index);\n\n    /** Creates a sound from a bank by name. \n      If bank is NULL, all loaded banks are searched for the first matching sound. \n      This will return NULL if no sound with that name can be found. */\n    static CkSound* newBankSound(CkBank*, const char* name);\n\n\n    ////////////////////////////////////////\n    // streams\n\n    /** Creates a stream from a file path. \n      This will return NULL if the file could not be opened.  If a non-NULL value\n      is returned, you should also check isFailed() to find out if any errors occurred\n      during initialization.\n\n      If the stream file is embedded in a larger file, specify the offset and length of \n      the embedded data in bytes, and provide a string ending with a file extension that indicates\n      the file format of the embedded file (for example, \".mp3\" or \"music.mp3\").\n      Otherwise, leave the offset, length, and extension as 0.\n     */\n    static CkSound* newStreamSound(const char* path, CkPathType = kCkPathType_Default, int offset = 0, int length = 0, const char* extension = NULL);\n\n\n    /** Factory function for creating custom streams. \n     The function should return a CkCustomStream instance, or NULL to create a stream\n     with the default handler. */\n    typedef CkCustomStream* (*CustomStreamFunc)(const char* path, void* data);\n\n    /** Set the stream handler.\n      Set it to NULL to use the default handler. */\n    static void setCustomStreamHandler(CustomStreamFunc, void* data);\n\n\n\n#if CK_PLATFORM_IOS\n    /** Creates a stream from a URL for an asset in the iTunes library. \n      The URL should be determined using an MPMediaQuery object; see the\n      \"iPod Library Access Programming Guide\" document in the iOS Developer Library.\n      Note that this will only work for music files without DRM; for files with DRM, the URL will be returned as nil.\n      @par Only available on iOS version 4.3 or later; will return NULL on earlier iOS versions.\n     */\n    static CkSound* newAssetStreamSound(const char* url);\n#endif\n\n\n    /** Destroys the sound. */\n    virtual void destroy() = 0;\n\nprotected:\n    CkSound() {}\n    virtual ~CkSound() {}\n\nprivate:\n    CkSound(const CkSound&);\n    CkSound& operator=(const CkSound&);\n};\n\n\n/** @} */\n"
  },
  {
    "path": "Projects/Android/chillisource/build.gradle",
    "content": "//\n//  build.gradle\n//  ChilliSource\n//  Created by Ian Copland on 12/03/2015.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2015 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\napply plugin: 'com.android.library'\napply from: '../../../Tools/Scripts/android-build.gradle'\n\nandroid {\n    publishNonDefault true\n    compileSdkVersion 22\n    buildToolsVersion \"22.0.1\"\n\n    defaultConfig {\n        minSdkVersion 9\n        targetSdkVersion 22\n        versionCode 1\n        versionName \"1.0\"\n    }\n\n    sourceSets {\n        main {\n            java.srcDir '../../../Source/CSBackend/Platform/Android/Main/Java/'\n            jni.srcDir '../../../Source/'\n            jniLibs.srcDir 'src/main/libs'\n        }\n        googlePlay {\n            java.srcDir '../../../Source/CSBackend/Platform/Android/GooglePlay/Java/'\n        }\n        amazon {\n            java.srcDir '../../../Source/CSBackend/Platform/Android/Amazon/Java/'\n        }\n    }\n\n    buildTypes {\n        release {\n        }\n        debug {\n            debuggable true\n        }\n    }\n\n    flavorDimensions \"sku\", \"abi\"\n    productFlavors {\n        googlePlay {\n            dimension \"sku\"\n        }\n        amazon {\n            dimension \"sku\"\n        }\n        arm {\n            dimension \"abi\"\n            ndk {\n                abiFilter \"armeabi\"\n            }\n        }\n        armv7 {\n            dimension \"abi\"\n            ndk {\n                abiFilter \"armeabi-v7a\"\n            }\n        }\n        arm64 {\n            dimension \"abi\"\n            ndk {\n                abiFilter \"arm64-v8a\"\n            }\n        }\n        x86 {\n            dimension \"abi\"\n            ndk {\n                abiFilter \"x86\"\n            }\n        }\n        x64 {\n            dimension \"abi\"\n            ndk {\n                abiFilter \"x86_64\"\n            }\n        }\n    }\n\n    csInitLibrary tasks, \"ChilliSource\"\n}\n\ndependencies {\n    compile fileTree(dir: 'libs', include: ['*.jar'])\n    googlePlayCompile fileTree(dir: 'src/googlePlay/libs', include: ['*.jar'])\n    amazonCompile fileTree(dir: 'src/amazon/libs', include: ['*.jar'])\n    csAddDefaultDependencies dependencies\n}\n"
  },
  {
    "path": "Projects/Android/chillisource/chillisource.iml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<module external.linked.project.id=\":chillisource\" external.linked.project.path=\"$MODULE_DIR$\" external.root.project.path=\"$MODULE_DIR$/../../../../Projects/Android/cstest\" external.system.id=\"GRADLE\" external.system.module.group=\"cstest\" external.system.module.version=\"unspecified\" type=\"JAVA_MODULE\" version=\"4\">\n  <component name=\"FacetManager\">\n    <facet type=\"android-gradle\" name=\"Android-Gradle\">\n      <configuration>\n        <option name=\"GRADLE_PROJECT_PATH\" value=\":chillisource\" />\n      </configuration>\n    </facet>\n    <facet type=\"android\" name=\"Android\">\n      <configuration>\n        <option name=\"SELECTED_BUILD_VARIANT\" value=\"googlePlayArmv7Debug\" />\n        <option name=\"SELECTED_TEST_ARTIFACT\" value=\"_android_test_\" />\n        <option name=\"ASSEMBLE_TASK_NAME\" value=\"assembleGooglePlayArmv7Debug\" />\n        <option name=\"COMPILE_JAVA_TASK_NAME\" value=\"compileGooglePlayArmv7DebugSources\" />\n        <afterSyncTasks>\n          <task>generateGooglePlayArmv7DebugSources</task>\n        </afterSyncTasks>\n        <option name=\"ALLOW_USER_CONFIGURATION\" value=\"false\" />\n        <option name=\"MANIFEST_FILE_RELATIVE_PATH\" value=\"/src/main/AndroidManifest.xml\" />\n        <option name=\"RES_FOLDER_RELATIVE_PATH\" value=\"/src/main/res\" />\n        <option name=\"RES_FOLDERS_RELATIVE_PATH\" value=\"file://$MODULE_DIR$/src/main/res\" />\n        <option name=\"ASSETS_FOLDER_RELATIVE_PATH\" value=\"/src/main/assets\" />\n        <option name=\"LIBRARY_PROJECT\" value=\"true\" />\n      </configuration>\n    </facet>\n  </component>\n  <component name=\"NewModuleRootManager\" LANGUAGE_LEVEL=\"JDK_1_7\" inherit-compiler-output=\"false\">\n    <output url=\"file://$MODULE_DIR$/build/intermediates/classes/googlePlayarmv7/debug\" />\n    <output-test url=\"file://$MODULE_DIR$/build/intermediates/classes/test/googlePlayarmv7/debug\" />\n    <exclude-output />\n    <content url=\"file://$MODULE_DIR$\">\n      <sourceFolder url=\"file://$MODULE_DIR$/build/generated/source/r/googlePlayarmv7/debug\" isTestSource=\"false\" generated=\"true\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/build/generated/source/aidl/googlePlayarmv7/debug\" isTestSource=\"false\" generated=\"true\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/build/generated/source/buildConfig/googlePlayarmv7/debug\" isTestSource=\"false\" generated=\"true\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/build/generated/source/rs/googlePlayarmv7/debug\" isTestSource=\"false\" generated=\"true\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/build/generated/res/rs/googlePlayarmv7/debug\" type=\"java-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/build/generated/res/generated/googlePlayarmv7/debug\" type=\"java-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/googlePlayArmv7Debug/res\" type=\"java-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/googlePlayArmv7Debug/resources\" type=\"java-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/googlePlayArmv7Debug/assets\" type=\"java-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/googlePlayArmv7Debug/aidl\" isTestSource=\"false\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/googlePlayArmv7Debug/java\" isTestSource=\"false\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/googlePlayArmv7Debug/jni\" isTestSource=\"false\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/googlePlayArmv7Debug/rs\" isTestSource=\"false\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/googlePlayArmv7/res\" type=\"java-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/googlePlayArmv7/resources\" type=\"java-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/googlePlayArmv7/assets\" type=\"java-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/googlePlayArmv7/aidl\" isTestSource=\"false\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/googlePlayArmv7/java\" isTestSource=\"false\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/googlePlayArmv7/jni\" isTestSource=\"false\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/googlePlayArmv7/rs\" isTestSource=\"false\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/build/generated/source/r/androidTest/googlePlayarmv7/debug\" isTestSource=\"true\" generated=\"true\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/build/generated/source/aidl/androidTest/googlePlayarmv7/debug\" isTestSource=\"true\" generated=\"true\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/build/generated/source/buildConfig/androidTest/googlePlayarmv7/debug\" isTestSource=\"true\" generated=\"true\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/build/generated/source/rs/androidTest/googlePlayarmv7/debug\" isTestSource=\"true\" generated=\"true\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/build/generated/res/rs/androidTest/googlePlayarmv7/debug\" type=\"java-test-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/build/generated/res/generated/androidTest/googlePlayarmv7/debug\" type=\"java-test-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/googlePlay/res\" type=\"java-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/googlePlay/resources\" type=\"java-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/googlePlay/assets\" type=\"java-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/googlePlay/aidl\" isTestSource=\"false\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/googlePlay/java\" isTestSource=\"false\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/googlePlay/jni\" isTestSource=\"false\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/googlePlay/rs\" isTestSource=\"false\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/androidTestGooglePlay/res\" type=\"java-test-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/androidTestGooglePlay/resources\" type=\"java-test-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/androidTestGooglePlay/assets\" type=\"java-test-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/androidTestGooglePlay/aidl\" isTestSource=\"true\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/androidTestGooglePlay/java\" isTestSource=\"true\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/androidTestGooglePlay/jni\" isTestSource=\"true\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/androidTestGooglePlay/rs\" isTestSource=\"true\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/testGooglePlay/res\" type=\"java-test-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/testGooglePlay/resources\" type=\"java-test-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/testGooglePlay/assets\" type=\"java-test-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/testGooglePlay/aidl\" isTestSource=\"true\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/testGooglePlay/java\" isTestSource=\"true\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/testGooglePlay/jni\" isTestSource=\"true\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/testGooglePlay/rs\" isTestSource=\"true\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/armv7/res\" type=\"java-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/armv7/resources\" type=\"java-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/armv7/assets\" type=\"java-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/armv7/aidl\" isTestSource=\"false\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/armv7/java\" isTestSource=\"false\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/armv7/jni\" isTestSource=\"false\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/armv7/rs\" isTestSource=\"false\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/androidTestArmv7/res\" type=\"java-test-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/androidTestArmv7/resources\" type=\"java-test-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/androidTestArmv7/assets\" type=\"java-test-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/androidTestArmv7/aidl\" isTestSource=\"true\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/androidTestArmv7/java\" isTestSource=\"true\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/androidTestArmv7/jni\" isTestSource=\"true\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/androidTestArmv7/rs\" isTestSource=\"true\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/testArmv7/res\" type=\"java-test-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/testArmv7/resources\" type=\"java-test-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/testArmv7/assets\" type=\"java-test-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/testArmv7/aidl\" isTestSource=\"true\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/testArmv7/java\" isTestSource=\"true\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/testArmv7/jni\" isTestSource=\"true\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/testArmv7/rs\" isTestSource=\"true\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/debug/res\" type=\"java-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/debug/resources\" type=\"java-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/debug/assets\" type=\"java-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/debug/aidl\" isTestSource=\"false\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/debug/java\" isTestSource=\"false\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/debug/jni\" isTestSource=\"false\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/debug/rs\" isTestSource=\"false\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/testDebug/res\" type=\"java-test-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/testDebug/resources\" type=\"java-test-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/testDebug/assets\" type=\"java-test-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/testDebug/aidl\" isTestSource=\"true\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/testDebug/java\" isTestSource=\"true\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/testDebug/jni\" isTestSource=\"true\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/testDebug/rs\" isTestSource=\"true\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/main/res\" type=\"java-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/main/resources\" type=\"java-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/main/assets\" type=\"java-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/main/aidl\" isTestSource=\"false\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/main/java\" isTestSource=\"false\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/main/jni\" isTestSource=\"false\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/main/rs\" isTestSource=\"false\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/androidTest/res\" type=\"java-test-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/androidTest/resources\" type=\"java-test-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/androidTest/assets\" type=\"java-test-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/androidTest/aidl\" isTestSource=\"true\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/androidTest/java\" isTestSource=\"true\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/androidTest/jni\" isTestSource=\"true\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/androidTest/rs\" isTestSource=\"true\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/test/res\" type=\"java-test-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/test/resources\" type=\"java-test-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/test/assets\" type=\"java-test-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/test/aidl\" isTestSource=\"true\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/test/java\" isTestSource=\"true\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/test/jni\" isTestSource=\"true\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/test/rs\" isTestSource=\"true\" />\n      <excludeFolder url=\"file://$MODULE_DIR$/build/intermediates/annotations\" />\n      <excludeFolder url=\"file://$MODULE_DIR$/build/intermediates/assets\" />\n      <excludeFolder url=\"file://$MODULE_DIR$/build/intermediates/bundles\" />\n      <excludeFolder url=\"file://$MODULE_DIR$/build/intermediates/classes\" />\n      <excludeFolder url=\"file://$MODULE_DIR$/build/intermediates/dependency-cache\" />\n      <excludeFolder url=\"file://$MODULE_DIR$/build/intermediates/incremental\" />\n      <excludeFolder url=\"file://$MODULE_DIR$/build/intermediates/lint\" />\n      <excludeFolder url=\"file://$MODULE_DIR$/build/intermediates/manifests\" />\n      <excludeFolder url=\"file://$MODULE_DIR$/build/intermediates/mockable-android-22.jar\" />\n      <excludeFolder url=\"file://$MODULE_DIR$/build/intermediates/res\" />\n      <excludeFolder url=\"file://$MODULE_DIR$/build/intermediates/resources\" />\n      <excludeFolder url=\"file://$MODULE_DIR$/build/intermediates/rs\" />\n      <excludeFolder url=\"file://$MODULE_DIR$/build/intermediates/symbols\" />\n      <excludeFolder url=\"file://$MODULE_DIR$/build/outputs\" />\n      <excludeFolder url=\"file://$MODULE_DIR$/build/tmp\" />\n    </content>\n    <content url=\"file://$MODULE_DIR$/../../../Source\">\n      <sourceFolder url=\"file://$MODULE_DIR$/../../../Source\" isTestSource=\"false\" />\n    </content>\n    <content url=\"file://$MODULE_DIR$/../../../Source/CSBackend/Platform/Android/GooglePlay/Java\">\n      <sourceFolder url=\"file://$MODULE_DIR$/../../../Source/CSBackend/Platform/Android/GooglePlay/Java\" isTestSource=\"false\" />\n    </content>\n    <content url=\"file://$MODULE_DIR$/../../../Source/CSBackend/Platform/Android/Main/Java\">\n      <sourceFolder url=\"file://$MODULE_DIR$/../../../Source/CSBackend/Platform/Android/Main/Java\" isTestSource=\"false\" />\n    </content>\n    <orderEntry type=\"jdk\" jdkName=\"Android API 22 Platform (1)\" jdkType=\"Android SDK\" />\n    <orderEntry type=\"sourceFolder\" forTests=\"false\" />\n    <orderEntry type=\"library\" exported=\"\" scope=\"TEST\" name=\"mockable-android-22\" level=\"project\" />\n    <orderEntry type=\"library\" exported=\"\" name=\"play-services-wallet-7.5.0\" level=\"project\" />\n    <orderEntry type=\"library\" exported=\"\" name=\"play-services-cast-7.5.0\" level=\"project\" />\n    <orderEntry type=\"library\" exported=\"\" name=\"mediarouter-v7-22.0.0\" level=\"project\" />\n    <orderEntry type=\"library\" exported=\"\" name=\"play-services-drive-7.5.0\" level=\"project\" />\n    <orderEntry type=\"library\" exported=\"\" name=\"support-annotations-22.2.0\" level=\"project\" />\n    <orderEntry type=\"library\" exported=\"\" name=\"play-services-analytics-7.5.0\" level=\"project\" />\n    <orderEntry type=\"library\" exported=\"\" name=\"play-services-panorama-7.5.0\" level=\"project\" />\n    <orderEntry type=\"library\" exported=\"\" name=\"appcompat-v7-22.2.0\" level=\"project\" />\n    <orderEntry type=\"library\" exported=\"\" name=\"play-services-appindexing-7.5.0\" level=\"project\" />\n    <orderEntry type=\"library\" exported=\"\" name=\"play-services-location-7.5.0\" level=\"project\" />\n    <orderEntry type=\"library\" exported=\"\" name=\"play-services-ads-7.5.0\" level=\"project\" />\n    <orderEntry type=\"library\" exported=\"\" name=\"play-services-safetynet-7.5.0\" level=\"project\" />\n    <orderEntry type=\"library\" exported=\"\" name=\"play-services-base-7.5.0\" level=\"project\" />\n    <orderEntry type=\"library\" exported=\"\" name=\"play-services-7.5.0\" level=\"project\" />\n    <orderEntry type=\"library\" exported=\"\" name=\"play-services-gcm-7.5.0\" level=\"project\" />\n    <orderEntry type=\"library\" exported=\"\" name=\"play-services-appinvite-7.5.0\" level=\"project\" />\n    <orderEntry type=\"library\" exported=\"\" name=\"support-v4-22.2.0\" level=\"project\" />\n    <orderEntry type=\"library\" exported=\"\" name=\"play-services-fitness-7.5.0\" level=\"project\" />\n    <orderEntry type=\"library\" exported=\"\" name=\"play-services-nearby-7.5.0\" level=\"project\" />\n    <orderEntry type=\"library\" exported=\"\" name=\"play-services-plus-7.5.0\" level=\"project\" />\n    <orderEntry type=\"library\" exported=\"\" name=\"play-services-wearable-7.5.0\" level=\"project\" />\n    <orderEntry type=\"library\" exported=\"\" name=\"play-services-appstate-7.5.0\" level=\"project\" />\n    <orderEntry type=\"library\" exported=\"\" name=\"play-services-games-7.5.0\" level=\"project\" />\n    <orderEntry type=\"library\" exported=\"\" name=\"play-services-identity-7.5.0\" level=\"project\" />\n    <orderEntry type=\"library\" exported=\"\" name=\"play-services-maps-7.5.0\" level=\"project\" />\n    <orderEntry type=\"module\" module-name=\"playlicensing\" exported=\"\" />\n    <orderEntry type=\"module\" module-name=\"playapkexpansion\" exported=\"\" />\n  </component>\n</module>"
  },
  {
    "path": "Projects/Android/chillisource/src/googlePlay/aidl/com/android/vending/billing/IInAppBillingService.aidl",
    "content": "/*\n * Copyright (C) 2012 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.android.vending.billing;\n\nimport android.os.Bundle;\n\n/**\n * InAppBillingService is the service that provides in-app billing version 3 and beyond.\n * This service provides the following features:\n * 1. Provides a new API to get details of in-app items published for the app including\n *    price, type, title and description.\n * 2. The purchase flow is synchronous and purchase information is available immediately\n *    after it completes.\n * 3. Purchase information of in-app purchases is maintained within the Google Play system\n *    till the purchase is consumed.\n * 4. An API to consume a purchase of an inapp item. All purchases of one-time\n *    in-app items are consumable and thereafter can be purchased again.\n * 5. An API to get current purchases of the user immediately. This will not contain any\n *    consumed purchases.\n *\n * All calls will give a response code with the following possible values\n * RESULT_OK = 0 - success\n * RESULT_USER_CANCELED = 1 - user pressed back or canceled a dialog\n * RESULT_BILLING_UNAVAILABLE = 3 - this billing API version is not supported for the type requested\n * RESULT_ITEM_UNAVAILABLE = 4 - requested SKU is not available for purchase\n * RESULT_DEVELOPER_ERROR = 5 - invalid arguments provided to the API\n * RESULT_ERROR = 6 - Fatal error during the API action\n * RESULT_ITEM_ALREADY_OWNED = 7 - Failure to purchase since item is already owned\n * RESULT_ITEM_NOT_OWNED = 8 - Failure to consume since item is not owned\n */\ninterface IInAppBillingService {\n    /**\n     * Checks support for the requested billing API version, package and in-app type.\n     * Minimum API version supported by this interface is 3.\n     * @param apiVersion the billing version which the app is using\n     * @param packageName the package name of the calling app\n     * @param type type of the in-app item being purchased \"inapp\" for one-time purchases\n     *        and \"subs\" for subscription.\n     * @return RESULT_OK(0) on success, corresponding result code on failures\n     */\n    int isBillingSupported(int apiVersion, String packageName, String type);\n\n    /**\n     * Provides details of a list of SKUs\n     * Given a list of SKUs of a valid type in the skusBundle, this returns a bundle\n     * with a list JSON strings containing the productId, price, title and description.\n     * This API can be called with a maximum of 20 SKUs.\n     * @param apiVersion billing API version that the Third-party is using\n     * @param packageName the package name of the calling app\n     * @param skusBundle bundle containing a StringArrayList of SKUs with key \"ITEM_ID_LIST\"\n     * @return Bundle containing the following key-value pairs\n     *         \"RESPONSE_CODE\" with int value, RESULT_OK(0) if success, other response codes on\n     *              failure as listed above.\n     *         \"DETAILS_LIST\" with a StringArrayList containing purchase information\n     *              in JSON format similar to:\n     *              '{ \"productId\" : \"exampleSku\", \"type\" : \"inapp\", \"price\" : \"$5.00\",\n     *                 \"title : \"Example Title\", \"description\" : \"This is an example description\" }'\n     */\n    Bundle getSkuDetails(int apiVersion, String packageName, String type, in Bundle skusBundle);\n\n    /**\n     * Returns a pending intent to launch the purchase flow for an in-app item by providing a SKU,\n     * the type, a unique purchase token and an optional developer payload.\n     * @param apiVersion billing API version that the app is using\n     * @param packageName package name of the calling app\n     * @param sku the SKU of the in-app item as published in the developer console\n     * @param type the type of the in-app item (\"inapp\" for one-time purchases\n     *        and \"subs\" for subscription).\n     * @param developerPayload optional argument to be sent back with the purchase information\n     * @return Bundle containing the following key-value pairs\n     *         \"RESPONSE_CODE\" with int value, RESULT_OK(0) if success, other response codes on\n     *              failure as listed above.\n     *         \"BUY_INTENT\" - PendingIntent to start the purchase flow\n     *\n     * The Pending intent should be launched with startIntentSenderForResult. When purchase flow\n     * has completed, the onActivityResult() will give a resultCode of OK or CANCELED.\n     * If the purchase is successful, the result data will contain the following key-value pairs\n     *         \"RESPONSE_CODE\" with int value, RESULT_OK(0) if success, other response codes on\n     *              failure as listed above.\n     *         \"INAPP_PURCHASE_DATA\" - String in JSON format similar to\n     *              '{\"orderId\":\"12999763169054705758.1371079406387615\",\n     *                \"packageName\":\"com.example.app\",\n     *                \"productId\":\"exampleSku\",\n     *                \"purchaseTime\":1345678900000,\n     *                \"purchaseToken\" : \"122333444455555\",\n     *                \"developerPayload\":\"example developer payload\" }'\n     *         \"INAPP_DATA_SIGNATURE\" - String containing the signature of the purchase data that\n     *                                  was signed with the private key of the developer\n     *                                  TODO: change this to app-specific keys.\n     */\n    Bundle getBuyIntent(int apiVersion, String packageName, String sku, String type,\n        String developerPayload);\n\n    /**\n     * Returns the current SKUs owned by the user of the type and package name specified along with\n     * purchase information and a signature of the data to be validated.\n     * This will return all SKUs that have been purchased in V3 and managed items purchased using\n     * V1 and V2 that have not been consumed.\n     * @param apiVersion billing API version that the app is using\n     * @param packageName package name of the calling app\n     * @param type the type of the in-app items being requested\n     *        (\"inapp\" for one-time purchases and \"subs\" for subscription).\n     * @param continuationToken to be set as null for the first call, if the number of owned\n     *        skus are too many, a continuationToken is returned in the response bundle.\n     *        This method can be called again with the continuation token to get the next set of\n     *        owned skus.\n     * @return Bundle containing the following key-value pairs\n     *         \"RESPONSE_CODE\" with int value, RESULT_OK(0) if success, other response codes on\n     *              failure as listed above.\n     *         \"INAPP_PURCHASE_ITEM_LIST\" - StringArrayList containing the list of SKUs\n     *         \"INAPP_PURCHASE_DATA_LIST\" - StringArrayList containing the purchase information\n     *         \"INAPP_DATA_SIGNATURE_LIST\"- StringArrayList containing the signatures\n     *                                      of the purchase information\n     *         \"INAPP_CONTINUATION_TOKEN\" - String containing a continuation token for the\n     *                                      next set of in-app purchases. Only set if the\n     *                                      user has more owned skus than the current list.\n     */\n    Bundle getPurchases(int apiVersion, String packageName, String type, String continuationToken);\n\n    /**\n     * Consume the last purchase of the given SKU. This will result in this item being removed\n     * from all subsequent responses to getPurchases() and allow re-purchase of this item.\n     * @param apiVersion billing API version that the app is using\n     * @param packageName package name of the calling app\n     * @param purchaseToken token in the purchase information JSON that identifies the purchase\n     *        to be consumed\n     * @return 0 if consumption succeeded. Appropriate error values for failures.\n     */\n    int consumePurchase(int apiVersion, String packageName, String purchaseToken);\n}\n"
  },
  {
    "path": "Projects/Android/chillisource/src/main/AndroidManifest.xml",
    "content": "<!--  \nAndroidManifest.xml\nChilliSource\nCreated by Ian Copland on 13/03/2015.\n\nThe MIT License (MIT)\n\nCopyright (c) 2015 Tag Games Limited\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE. \n-->\n\n<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\" package=\"com.chilliworks.chillisource\">\n\n    <application>\n\n    </application>\n\n</manifest>\n"
  },
  {
    "path": "Projects/Android/chillisource/src/main/jni/Android.mk",
    "content": "#\n#  Android.mk\n#  ChilliSource\n#  Created by Ian Copland on 12/03/2015\n#\n#  The MIT License (MIT)\n#\n#  Copyright (c) 2015 Tag Games Limited\n#\n#  Permission is hereby granted, free of charge, to any person obtaining a copy\n#  of this software and associated documentation files (the \"Software\"), to deal\n#  in the Software without restriction, including without limitation the rights\n#  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n#  copies of the Software, and to permit persons to whom the Software is\n#  furnished to do so, subject to the following conditions:\n#\n#  The above copyright notice and this permission notice shall be included in\n#  all copies or substantial portions of the Software.\n#\n#  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n#  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n#  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n#  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n#  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n#  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n#  THE SOFTWARE.\n#\n\n#prepare the ChilliSource libraries\nCS_PROJECT_ROOT=../../../../../../..\ninclude $(CS_PROJECT_ROOT)/ChilliSource/Tools/Scripts/AndroidBuildConfig.mk\n\n#gather all files in the engine that should be built\nCS_SOURCEFILES_CHILLISOURCE := $(shell 'python' '$(CS_SCRIPT_GETFILESWITHEXTENSIONS)' '--directory' '$(CS_PROJECT_ROOT)/ChilliSource/Source/ChilliSource/' '--extensions' 'cpp,c,cc')\nCS_SOURCEFILES_PLATFORM := $(shell 'python' '$(CS_SCRIPT_GETFILESWITHEXTENSIONS)' '--directory' '$(CS_PROJECT_ROOT)/ChilliSource/Source/CSBackend/Platform/Android/Main/JNI/' '--extensions' 'cpp,c,cc')\nCS_SOURCEFILES_RENDERING := $(shell 'python' '$(CS_SCRIPT_GETFILESWITHEXTENSIONS)' '--directory' '$(CS_PROJECT_ROOT)/ChilliSource/Source/CSBackend/Rendering/OpenGL/' '--extensions' 'cpp,c,cc')\n\n#add files for appropriate android skus\nifeq ($(CS_FLAVOUR_SKU), googleplay)\nCS_SOURCEFILES_PLATFORM +=$(shell 'python' '$(CS_SCRIPT_GETFILESWITHEXTENSIONS)' '--directory' '$(CS_PROJECT_ROOT)/ChilliSource/Source/CSBackend/Platform/Android/GooglePlay/JNI/' '--extensions' 'cpp,c,cc')\nelse ifeq ($(CS_FLAVOUR_SKU), amazon)\nCS_SOURCEFILES_PLATFORM +=$(shell 'python' '$(CS_SCRIPT_GETFILESWITHEXTENSIONS)' '--directory' '$(CS_PROJECT_ROOT)/ChilliSource/Source/CSBackend/Platform/Android/Amazon/JNI/' '--extensions' 'cpp,c,cc')\nendif\n\n#build the ChilliSource static library\ninclude $(CLEAR_VARS)\nLOCAL_MODULE := ChilliSource\nLOCAL_CXXFLAGS := $(CS_CXXFLAGS)\nLOCAL_SRC_FILES := $(CS_SOURCEFILES_CHILLISOURCE) $(CS_SOURCEFILES_PLATFORM) $(CS_SOURCEFILES_RENDERING)\nLOCAL_C_INCLUDES := $(CS_C_INCLUDES)\nLOCAL_SHORT_COMMANDS := true\ninclude $(BUILD_STATIC_LIBRARY)\n"
  },
  {
    "path": "Projects/Android/chillisource/src/main/jni/Application.mk",
    "content": "#\n#  Application.mk\n#  ChilliSource\n#  Created by Ian Copland on 12/03/2015\n#\n#  The MIT License (MIT)\n#\n#  Copyright (c) 2015 Tag Games Limited\n#\n#  Permission is hereby granted, free of charge, to any person obtaining a copy\n#  of this software and associated documentation files (the \"Software\"), to deal\n#  in the Software without restriction, including without limitation the rights\n#  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n#  copies of the Software, and to permit persons to whom the Software is\n#  furnished to do so, subject to the following conditions:\n#\n#  The above copyright notice and this permission notice shall be included in\n#  all copies or substantial portions of the Software.\n#\n#  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n#  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n#  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n#  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n#  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n#  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n#  THE SOFTWARE.\n#\n\nCS_PROJECT_ROOT=../../../../../../..\ninclude $(CS_PROJECT_ROOT)/ChilliSource/Tools/Scripts/AndroidApplicationConfig.mk\n\nNDK_TOOLCHAIN_VERSION := $(CS_NDK_TOOLCHAIN_VERSION)\nAPP_STL := $(CS_APP_STL)\nLOCAL_CPP_FEATURES += $(CS_LOCAL_CPP_FEATURES)\nAPP_PLATFORM := $(CS_APP_PLATFORM)\n"
  },
  {
    "path": "Projects/Android/chillisource/src/main/res/values/strings.xml",
    "content": "<resources>\n    <string name=\"cs_chillisource\">ChilliSource</string>\n</resources>\n"
  },
  {
    "path": "Projects/Android/playapkexpansion/build.gradle",
    "content": "apply plugin: 'com.android.library'\n\nandroid {\n    compileSdkVersion 22\n    buildToolsVersion \"22.0.1\"\n\n    defaultConfig {\n        minSdkVersion 4\n        targetSdkVersion 22\n        versionCode 1\n        versionName \"1.0\"\n    }\n    buildTypes {\n        release {\n            minifyEnabled false\n        }\n    }\n}\n\ndependencies {\n    compile fileTree(dir: 'libs', include: ['*.jar'])\n    compile project(\":playlicensing\")\n}\n"
  },
  {
    "path": "Projects/Android/playapkexpansion/playapkexpansion.iml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<module external.linked.project.id=\":playapkexpansion\" external.linked.project.path=\"$MODULE_DIR$\" external.root.project.path=\"$MODULE_DIR$/../../../../Projects/Android/cstest\" external.system.id=\"GRADLE\" external.system.module.group=\"cstest\" external.system.module.version=\"unspecified\" type=\"JAVA_MODULE\" version=\"4\">\n  <component name=\"FacetManager\">\n    <facet type=\"android-gradle\" name=\"Android-Gradle\">\n      <configuration>\n        <option name=\"GRADLE_PROJECT_PATH\" value=\":playapkexpansion\" />\n      </configuration>\n    </facet>\n    <facet type=\"android\" name=\"Android\">\n      <configuration>\n        <option name=\"SELECTED_BUILD_VARIANT\" value=\"debug\" />\n        <option name=\"SELECTED_TEST_ARTIFACT\" value=\"_android_test_\" />\n        <option name=\"ASSEMBLE_TASK_NAME\" value=\"assembleDebug\" />\n        <option name=\"COMPILE_JAVA_TASK_NAME\" value=\"compileDebugSources\" />\n        <afterSyncTasks>\n          <task>generateDebugSources</task>\n        </afterSyncTasks>\n        <option name=\"ALLOW_USER_CONFIGURATION\" value=\"false\" />\n        <option name=\"MANIFEST_FILE_RELATIVE_PATH\" value=\"/src/main/AndroidManifest.xml\" />\n        <option name=\"RES_FOLDER_RELATIVE_PATH\" value=\"/src/main/res\" />\n        <option name=\"RES_FOLDERS_RELATIVE_PATH\" value=\"file://$MODULE_DIR$/src/main/res\" />\n        <option name=\"ASSETS_FOLDER_RELATIVE_PATH\" value=\"/src/main/assets\" />\n        <option name=\"LIBRARY_PROJECT\" value=\"true\" />\n      </configuration>\n    </facet>\n  </component>\n  <component name=\"NewModuleRootManager\" LANGUAGE_LEVEL=\"JDK_1_7\" inherit-compiler-output=\"false\">\n    <output url=\"file://$MODULE_DIR$/build/intermediates/classes/debug\" />\n    <output-test url=\"file://$MODULE_DIR$/build/intermediates/classes/test/debug\" />\n    <exclude-output />\n    <content url=\"file://$MODULE_DIR$\">\n      <sourceFolder url=\"file://$MODULE_DIR$/build/generated/source/r/debug\" isTestSource=\"false\" generated=\"true\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/build/generated/source/aidl/debug\" isTestSource=\"false\" generated=\"true\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/build/generated/source/buildConfig/debug\" isTestSource=\"false\" generated=\"true\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/build/generated/source/rs/debug\" isTestSource=\"false\" generated=\"true\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/build/generated/res/rs/debug\" type=\"java-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/build/generated/res/generated/debug\" type=\"java-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/build/generated/source/r/androidTest/debug\" isTestSource=\"true\" generated=\"true\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/build/generated/source/aidl/androidTest/debug\" isTestSource=\"true\" generated=\"true\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/build/generated/source/buildConfig/androidTest/debug\" isTestSource=\"true\" generated=\"true\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/build/generated/source/rs/androidTest/debug\" isTestSource=\"true\" generated=\"true\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/build/generated/res/rs/androidTest/debug\" type=\"java-test-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/build/generated/res/generated/androidTest/debug\" type=\"java-test-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/debug/res\" type=\"java-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/debug/resources\" type=\"java-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/debug/assets\" type=\"java-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/debug/aidl\" isTestSource=\"false\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/debug/java\" isTestSource=\"false\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/debug/jni\" isTestSource=\"false\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/debug/rs\" isTestSource=\"false\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/testDebug/res\" type=\"java-test-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/testDebug/resources\" type=\"java-test-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/testDebug/assets\" type=\"java-test-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/testDebug/aidl\" isTestSource=\"true\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/testDebug/java\" isTestSource=\"true\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/testDebug/jni\" isTestSource=\"true\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/testDebug/rs\" isTestSource=\"true\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/main/res\" type=\"java-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/main/resources\" type=\"java-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/main/assets\" type=\"java-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/main/aidl\" isTestSource=\"false\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/main/java\" isTestSource=\"false\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/main/jni\" isTestSource=\"false\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/main/rs\" isTestSource=\"false\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/test/res\" type=\"java-test-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/test/resources\" type=\"java-test-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/test/assets\" type=\"java-test-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/test/aidl\" isTestSource=\"true\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/test/java\" isTestSource=\"true\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/test/jni\" isTestSource=\"true\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/test/rs\" isTestSource=\"true\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/androidTest/res\" type=\"java-test-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/androidTest/resources\" type=\"java-test-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/androidTest/assets\" type=\"java-test-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/androidTest/aidl\" isTestSource=\"true\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/androidTest/java\" isTestSource=\"true\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/androidTest/jni\" isTestSource=\"true\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/androidTest/rs\" isTestSource=\"true\" />\n      <excludeFolder url=\"file://$MODULE_DIR$/build/intermediates/assets\" />\n      <excludeFolder url=\"file://$MODULE_DIR$/build/intermediates/bundles\" />\n      <excludeFolder url=\"file://$MODULE_DIR$/build/intermediates/classes\" />\n      <excludeFolder url=\"file://$MODULE_DIR$/build/intermediates/dependency-cache\" />\n      <excludeFolder url=\"file://$MODULE_DIR$/build/intermediates/incremental\" />\n      <excludeFolder url=\"file://$MODULE_DIR$/build/intermediates/lint\" />\n      <excludeFolder url=\"file://$MODULE_DIR$/build/intermediates/manifests\" />\n      <excludeFolder url=\"file://$MODULE_DIR$/build/intermediates/mockable-android-22.jar\" />\n      <excludeFolder url=\"file://$MODULE_DIR$/build/intermediates/res\" />\n      <excludeFolder url=\"file://$MODULE_DIR$/build/intermediates/resources\" />\n      <excludeFolder url=\"file://$MODULE_DIR$/build/intermediates/rs\" />\n      <excludeFolder url=\"file://$MODULE_DIR$/build/intermediates/symbols\" />\n      <excludeFolder url=\"file://$MODULE_DIR$/build/outputs\" />\n      <excludeFolder url=\"file://$MODULE_DIR$/build/tmp\" />\n    </content>\n    <orderEntry type=\"jdk\" jdkName=\"Android API 22 Platform (1)\" jdkType=\"Android SDK\" />\n    <orderEntry type=\"sourceFolder\" forTests=\"false\" />\n    <orderEntry type=\"library\" exported=\"\" scope=\"TEST\" name=\"mockable-android-22\" level=\"project\" />\n    <orderEntry type=\"module\" module-name=\"playlicensing\" exported=\"\" />\n  </component>\n</module>"
  },
  {
    "path": "Projects/Android/playapkexpansion/src/main/AndroidManifest.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\" package=\"com.android.vending.expansion.downloader\" >\n\n</manifest>"
  },
  {
    "path": "Projects/Android/playapkexpansion/src/main/java/com/google/android/vending/expansion/downloader/Constants.java",
    "content": "/*\n * Copyright (C) 2012 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.google.android.vending.expansion.downloader;\n\nimport java.io.File;\n\n\n/**\n * Contains the internal constants that are used in the download manager.\n * As a general rule, modifying these constants should be done with care.\n */\npublic class Constants {    \n    /** Tag used for debugging/logging */\n    public static final String TAG = \"LVLDL\";\n\n    /**\n     * Expansion path where we store obb files\n     */\n    public static final String EXP_PATH = File.separator + \"Android\"\n            + File.separator + \"obb\" + File.separator;\n    \n    /** The intent that gets sent when the service must wake up for a retry */\n    public static final String ACTION_RETRY = \"android.intent.action.DOWNLOAD_WAKEUP\";\n\n    /** the intent that gets sent when clicking a successful download */\n    public static final String ACTION_OPEN = \"android.intent.action.DOWNLOAD_OPEN\";\n\n    /** the intent that gets sent when clicking an incomplete/failed download  */\n    public static final String ACTION_LIST = \"android.intent.action.DOWNLOAD_LIST\";\n\n    /** the intent that gets sent when deleting the notification of a completed download */\n    public static final String ACTION_HIDE = \"android.intent.action.DOWNLOAD_HIDE\";\n\n    /**\n     * When a number has to be appended to the filename, this string is used to separate the\n     * base filename from the sequence number\n     */\n    public static final String FILENAME_SEQUENCE_SEPARATOR = \"-\";\n\n    /** The default user agent used for downloads */\n    public static final String DEFAULT_USER_AGENT = \"Android.LVLDM\";\n\n    /** The buffer size used to stream the data */\n    public static final int BUFFER_SIZE = 4096;\n\n    /** The minimum amount of progress that has to be done before the progress bar gets updated */\n    public static final int MIN_PROGRESS_STEP = 4096;\n\n    /** The minimum amount of time that has to elapse before the progress bar gets updated, in ms */\n    public static final long MIN_PROGRESS_TIME = 1000;\n\n    /** The maximum number of rows in the database (FIFO) */\n    public static final int MAX_DOWNLOADS = 1000;\n\n    /**\n     * The number of times that the download manager will retry its network\n     * operations when no progress is happening before it gives up.\n     */\n    public static final int MAX_RETRIES = 5;\n\n    /**\n     * The minimum amount of time that the download manager accepts for\n     * a Retry-After response header with a parameter in delta-seconds.\n     */\n    public static final int MIN_RETRY_AFTER = 30; // 30s\n\n    /**\n     * The maximum amount of time that the download manager accepts for\n     * a Retry-After response header with a parameter in delta-seconds.\n     */\n    public static final int MAX_RETRY_AFTER = 24 * 60 * 60; // 24h\n\n    /**\n     * The maximum number of redirects.\n     */\n    public static final int MAX_REDIRECTS = 5; // can't be more than 7.\n\n    /**\n     * The time between a failure and the first retry after an IOException.\n     * Each subsequent retry grows exponentially, doubling each time.\n     * The time is in seconds.\n     */\n    public static final int RETRY_FIRST_DELAY = 30;\n\n    /** Enable separate connectivity logging */\n    public static final boolean LOGX = true;\n\n    /** Enable verbose logging */\n    public static final boolean LOGV = false;\n    \n    /** Enable super-verbose logging */\n    private static final boolean LOCAL_LOGVV = false;\n    public static final boolean LOGVV = LOCAL_LOGVV && LOGV;\n    \n    /**\n     * This download has successfully completed.\n     * Warning: there might be other status values that indicate success\n     * in the future.\n     * Use isSucccess() to capture the entire category.\n     */\n    public static final int STATUS_SUCCESS = 200;\n\n    /**\n     * This request couldn't be parsed. This is also used when processing\n     * requests with unknown/unsupported URI schemes.\n     */\n    public static final int STATUS_BAD_REQUEST = 400;\n\n    /**\n     * This download can't be performed because the content type cannot be\n     * handled.\n     */\n    public static final int STATUS_NOT_ACCEPTABLE = 406;\n\n    /**\n     * This download cannot be performed because the length cannot be\n     * determined accurately. This is the code for the HTTP error \"Length\n     * Required\", which is typically used when making requests that require\n     * a content length but don't have one, and it is also used in the\n     * client when a response is received whose length cannot be determined\n     * accurately (therefore making it impossible to know when a download\n     * completes).\n     */\n    public static final int STATUS_LENGTH_REQUIRED = 411;\n\n    /**\n     * This download was interrupted and cannot be resumed.\n     * This is the code for the HTTP error \"Precondition Failed\", and it is\n     * also used in situations where the client doesn't have an ETag at all.\n     */\n    public static final int STATUS_PRECONDITION_FAILED = 412;\n\n    /**\n     * The lowest-valued error status that is not an actual HTTP status code.\n     */\n    public static final int MIN_ARTIFICIAL_ERROR_STATUS = 488;\n\n    /**\n     * The requested destination file already exists.\n     */\n    public static final int STATUS_FILE_ALREADY_EXISTS_ERROR = 488;\n\n    /**\n     * Some possibly transient error occurred, but we can't resume the download.\n     */\n    public static final int STATUS_CANNOT_RESUME = 489;\n\n    /**\n     * This download was canceled\n     */\n    public static final int STATUS_CANCELED = 490;\n\n    /**\n     * This download has completed with an error.\n     * Warning: there will be other status values that indicate errors in\n     * the future. Use isStatusError() to capture the entire category.\n     */\n    public static final int STATUS_UNKNOWN_ERROR = 491;\n\n    /**\n     * This download couldn't be completed because of a storage issue.\n     * Typically, that's because the filesystem is missing or full.\n     * Use the more specific {@link #STATUS_INSUFFICIENT_SPACE_ERROR}\n     * and {@link #STATUS_DEVICE_NOT_FOUND_ERROR} when appropriate.\n     */\n    public static final int STATUS_FILE_ERROR = 492;\n\n    /**\n     * This download couldn't be completed because of an HTTP\n     * redirect response that the download manager couldn't\n     * handle.\n     */\n    public static final int STATUS_UNHANDLED_REDIRECT = 493;\n\n    /**\n     * This download couldn't be completed because of an\n     * unspecified unhandled HTTP code.\n     */\n    public static final int STATUS_UNHANDLED_HTTP_CODE = 494;\n\n    /**\n     * This download couldn't be completed because of an\n     * error receiving or processing data at the HTTP level.\n     */\n    public static final int STATUS_HTTP_DATA_ERROR = 495;\n\n    /**\n     * This download couldn't be completed because of an\n     * HttpException while setting up the request.\n     */\n    public static final int STATUS_HTTP_EXCEPTION = 496;\n\n    /**\n     * This download couldn't be completed because there were\n     * too many redirects.\n     */\n    public static final int STATUS_TOO_MANY_REDIRECTS = 497;\n\n    /**\n     * This download couldn't be completed due to insufficient storage\n     * space.  Typically, this is because the SD card is full.\n     */\n    public static final int STATUS_INSUFFICIENT_SPACE_ERROR = 498;\n\n    /**\n     * This download couldn't be completed because no external storage\n     * device was found.  Typically, this is because the SD card is not\n     * mounted.\n     */\n    public static final int STATUS_DEVICE_NOT_FOUND_ERROR = 499;\n\n    /**\n     * The wake duration to check to see if a download is possible.\n     */\n    public static final long WATCHDOG_WAKE_TIMER = 60*1000;    \n\n    /**\n     * The wake duration to check to see if the process was killed.\n     */\n    public static final long ACTIVE_THREAD_WATCHDOG = 5*1000;    \n\n}"
  },
  {
    "path": "Projects/Android/playapkexpansion/src/main/java/com/google/android/vending/expansion/downloader/DownloadProgressInfo.java",
    "content": "/*\n * Copyright (C) 2012 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.google.android.vending.expansion.downloader;\n\nimport android.os.Parcel;\nimport android.os.Parcelable;\n\n\n/**\n * This class contains progress information about the active download(s).\n *\n * When you build the Activity that initiates a download and tracks the\n * progress by implementing the {@link IDownloaderClient} interface, you'll\n * receive a DownloadProgressInfo object in each call to the {@link\n * IDownloaderClient#onDownloadProgress} method. This allows you to update\n * your activity's UI with information about the download progress, such\n * as the progress so far, time remaining and current speed.\n */\npublic class DownloadProgressInfo implements Parcelable {\n    public long mOverallTotal;\n    public long mOverallProgress;\n    public long mTimeRemaining; // time remaining\n    public float mCurrentSpeed; // speed in KB/S\n\n    @Override\n    public int describeContents() {\n        return 0;\n    }\n\n    @Override\n    public void writeToParcel(Parcel p, int i) {\n        p.writeLong(mOverallTotal);\n        p.writeLong(mOverallProgress);\n        p.writeLong(mTimeRemaining);\n        p.writeFloat(mCurrentSpeed);\n    }\n\n    public DownloadProgressInfo(Parcel p) {\n        mOverallTotal = p.readLong();\n        mOverallProgress = p.readLong();\n        mTimeRemaining = p.readLong();\n        mCurrentSpeed = p.readFloat();\n    }\n\n    public DownloadProgressInfo(long overallTotal, long overallProgress,\n            long timeRemaining,\n            float currentSpeed) {\n        this.mOverallTotal = overallTotal;\n        this.mOverallProgress = overallProgress;\n        this.mTimeRemaining = timeRemaining;\n        this.mCurrentSpeed = currentSpeed;\n    }\n\n    public static final Creator<DownloadProgressInfo> CREATOR = new Creator<DownloadProgressInfo>() {\n        @Override\n        public DownloadProgressInfo createFromParcel(Parcel parcel) {\n            return new DownloadProgressInfo(parcel);\n        }\n\n        @Override\n        public DownloadProgressInfo[] newArray(int i) {\n            return new DownloadProgressInfo[i];\n        }\n    };\n\n}\n"
  },
  {
    "path": "Projects/Android/playapkexpansion/src/main/java/com/google/android/vending/expansion/downloader/DownloaderClientMarshaller.java",
    "content": "/*\n * Copyright (C) 2012 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.google.android.vending.expansion.downloader;\n\nimport com.google.android.vending.expansion.downloader.impl.DownloaderService;\n\nimport android.app.PendingIntent;\nimport android.content.ComponentName;\nimport android.content.Context;\nimport android.content.Intent;\nimport android.content.ServiceConnection;\nimport android.content.pm.PackageManager.NameNotFoundException;\nimport android.os.Bundle;\nimport android.os.Handler;\nimport android.os.IBinder;\nimport android.os.Message;\nimport android.os.Messenger;\nimport android.os.RemoteException;\nimport android.util.Log;\n\n\n\n/**\n * This class binds the service API to your application client.  It contains the IDownloaderClient proxy,\n * which is used to call functions in your client as well as the Stub, which is used to call functions\n * in the client implementation of IDownloaderClient.\n * \n * <p>The IPC is implemented using an Android Messenger and a service Binder.  The connect method\n * should be called whenever the client wants to bind to the service.  It opens up a service connection\n * that ends up calling the onServiceConnected client API that passes the service messenger\n * in.  If the client wants to be notified by the service, it is responsible for then passing its\n * messenger to the service in a separate call.\n *\n * <p>Critical methods are {@link #startDownloadServiceIfRequired} and {@link #CreateStub}.\n *\n * <p>When your application first starts, you should first check whether your app's expansion files are\n * already on the device. If not, you should then call {@link #startDownloadServiceIfRequired}, which\n * starts your {@link impl.DownloaderService} to download the expansion files if necessary. The method\n * returns a value indicating whether download is required or not.\n *\n * <p>If a download is required, {@link #startDownloadServiceIfRequired} begins the download through\n * the specified service and you should then call {@link #CreateStub} to instantiate a member {@link\n * IStub} object that you need in order to receive calls through your {@link IDownloaderClient}\n * interface.\n */\npublic class DownloaderClientMarshaller {\n    public static final int MSG_ONDOWNLOADSTATE_CHANGED = 10;\n    public static final int MSG_ONDOWNLOADPROGRESS = 11;\n    public static final int MSG_ONSERVICECONNECTED = 12;\n\n    public static final String PARAM_NEW_STATE = \"newState\";\n    public static final String PARAM_PROGRESS = \"progress\";\n    public static final String PARAM_MESSENGER = DownloaderService.EXTRA_MESSAGE_HANDLER;\n\n    public static final int NO_DOWNLOAD_REQUIRED = DownloaderService.NO_DOWNLOAD_REQUIRED;\n    public static final int LVL_CHECK_REQUIRED = DownloaderService.LVL_CHECK_REQUIRED;\n    public static final int DOWNLOAD_REQUIRED = DownloaderService.DOWNLOAD_REQUIRED;\n\n    private static class Proxy implements IDownloaderClient {\n        private Messenger mServiceMessenger;\n\n        @Override\n        public void onDownloadStateChanged(int newState) {\n            Bundle params = new Bundle(1);\n            params.putInt(PARAM_NEW_STATE, newState);\n            send(MSG_ONDOWNLOADSTATE_CHANGED, params);\n        }\n\n        @Override\n        public void onDownloadProgress(DownloadProgressInfo progress) {\n            Bundle params = new Bundle(1);\n            params.putParcelable(PARAM_PROGRESS, progress);\n            send(MSG_ONDOWNLOADPROGRESS, params);\n        }\n\n        private void send(int method, Bundle params) {\n            Message m = Message.obtain(null, method);\n            m.setData(params);\n            try {\n                mServiceMessenger.send(m);\n            } catch (RemoteException e) {\n                e.printStackTrace();\n            }\n        }\n        \n        public Proxy(Messenger msg) {\n            mServiceMessenger = msg;\n        }\n\n        @Override\n        public void onServiceConnected(Messenger m) {\n            /**\n             * This is never called through the proxy.\n             */\n        }\n    }\n\n    private static class Stub implements IStub {\n        private IDownloaderClient mItf = null;\n        private Class<?> mDownloaderServiceClass;\n        private boolean mBound;\n        private Messenger mServiceMessenger;\n        private Context mContext;\n        /**\n         * Target we publish for clients to send messages to IncomingHandler.\n         */\n        final Messenger mMessenger = new Messenger(new Handler() {\n            @Override\n            public void handleMessage(Message msg) {\n                switch (msg.what) {\n                    case MSG_ONDOWNLOADPROGRESS:                        \n                        Bundle bun = msg.getData();\n                        if ( null != mContext ) {\n                            bun.setClassLoader(mContext.getClassLoader());\n                            DownloadProgressInfo dpi = (DownloadProgressInfo) msg.getData()\n                                    .getParcelable(PARAM_PROGRESS);\n                            mItf.onDownloadProgress(dpi);\n                        }\n                        break;\n                    case MSG_ONDOWNLOADSTATE_CHANGED:\n                        mItf.onDownloadStateChanged(msg.getData().getInt(PARAM_NEW_STATE));\n                        break;\n                    case MSG_ONSERVICECONNECTED:\n                        mItf.onServiceConnected(\n                                (Messenger) msg.getData().getParcelable(PARAM_MESSENGER));\n                        break;\n                }\n            }\n        });\n\n        public Stub(IDownloaderClient itf, Class<?> downloaderService) {\n            mItf = itf;\n            mDownloaderServiceClass = downloaderService;\n        }\n\n        /**\n         * Class for interacting with the main interface of the service.\n         */\n        private ServiceConnection mConnection = new ServiceConnection() {\n            public void onServiceConnected(ComponentName className, IBinder service) {\n                // This is called when the connection with the service has been\n                // established, giving us the object we can use to\n                // interact with the service. We are communicating with the\n                // service using a Messenger, so here we get a client-side\n                // representation of that from the raw IBinder object.\n                mServiceMessenger = new Messenger(service);\n                mItf.onServiceConnected(\n                        mServiceMessenger);\n            }\n\n            public void onServiceDisconnected(ComponentName className) {\n                // This is called when the connection with the service has been\n                // unexpectedly disconnected -- that is, its process crashed.\n                mServiceMessenger = null;\n            }\n        };\n\n        @Override\n        public void connect(Context c) {\n            mContext = c;\n            Intent bindIntent = new Intent(c, mDownloaderServiceClass);\n            bindIntent.putExtra(PARAM_MESSENGER, mMessenger);\n            if ( !c.bindService(bindIntent, mConnection, Context.BIND_DEBUG_UNBIND) ) {\n                if ( Constants.LOGVV ) {\n                    Log.d(Constants.TAG, \"Service Unbound\");\n                }\n            } else {\n                mBound = true;\n            }\n                \n        }\n\n        @Override\n        public void disconnect(Context c) {\n            if (mBound) {\n                c.unbindService(mConnection);\n                mBound = false;\n            }\n            mContext = null;\n        }\n\n        @Override\n        public Messenger getMessenger() {\n            return mMessenger;\n        }\n    }\n\n    /**\n     * Returns a proxy that will marshal calls to IDownloaderClient methods\n     * \n     * @param msg\n     * @return\n     */\n    public static IDownloaderClient CreateProxy(Messenger msg) {\n        return new Proxy(msg);\n    }\n\n    /**\n     * Returns a stub object that, when connected, will listen for marshaled\n     * {@link IDownloaderClient} methods and translate them into calls to the supplied\n     * interface.\n     * \n     * @param itf An implementation of IDownloaderClient that will be called\n     *            when remote method calls are unmarshaled.\n     * @param downloaderService The class for your implementation of {@link\n     * impl.DownloaderService}.\n     * @return The {@link IStub} that allows you to connect to the service such that\n     * your {@link IDownloaderClient} receives status updates.\n     */\n    public static IStub CreateStub(IDownloaderClient itf, Class<?> downloaderService) {\n        return new Stub(itf, downloaderService);\n    }\n    \n    /**\n     * Starts the download if necessary. This function starts a flow that does `\n     * many things. 1) Checks to see if the APK version has been checked and\n     * the metadata database updated 2) If the APK version does not match,\n     * checks the new LVL status to see if a new download is required 3) If the\n     * APK version does match, then checks to see if the download(s) have been\n     * completed 4) If the downloads have been completed, returns\n     * NO_DOWNLOAD_REQUIRED The idea is that this can be called during the\n     * startup of an application to quickly ascertain if the application needs\n     * to wait to hear about any updated APK expansion files. Note that this does\n     * mean that the application MUST be run for the first time with a network\n     * connection, even if Market delivers all of the files.\n     * \n     * @param context Your application Context.\n     * @param notificationClient A PendingIntent to start the Activity in your application\n     * that shows the download progress and which will also start the application when download\n     * completes.\n     * @param serviceClass the class of your {@link imp.DownloaderService} implementation\n     * @return whether the service was started and the reason for starting the service.\n     * Either {@link #NO_DOWNLOAD_REQUIRED}, {@link #LVL_CHECK_REQUIRED}, or {@link\n     * #DOWNLOAD_REQUIRED}.\n     * @throws NameNotFoundException\n     */\n    public static int startDownloadServiceIfRequired(Context context, PendingIntent notificationClient, \n            Class<?> serviceClass)\n            throws NameNotFoundException {\n        return DownloaderService.startDownloadServiceIfRequired(context, notificationClient,\n                serviceClass);\n    }\n    \n    /**\n     * This version assumes that the intent contains the pending intent as a parameter. This\n     * is used for responding to alarms.\n     * <p>The pending intent must be in an extra with the key {@link \n     * impl.DownloaderService#EXTRA_PENDING_INTENT}.\n     * \n     * @param context\n     * @param notificationClient\n     * @param serviceClass the class of the service to start\n     * @return\n     * @throws NameNotFoundException\n     */\n    public static int startDownloadServiceIfRequired(Context context, Intent notificationClient, \n            Class<?> serviceClass)\n            throws NameNotFoundException {\n        return DownloaderService.startDownloadServiceIfRequired(context, notificationClient,\n                serviceClass);\n    }    \n\n}\n"
  },
  {
    "path": "Projects/Android/playapkexpansion/src/main/java/com/google/android/vending/expansion/downloader/DownloaderServiceMarshaller.java",
    "content": "/*\n * Copyright (C) 2012 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.google.android.vending.expansion.downloader;\n\nimport com.google.android.vending.expansion.downloader.impl.DownloaderService;\n\nimport android.content.Context;\nimport android.os.Bundle;\nimport android.os.Handler;\nimport android.os.Message;\nimport android.os.Messenger;\nimport android.os.RemoteException;\n\n\n\n/**\n * This class is used by the client activity to proxy requests to the Downloader\n * Service.\n *\n * Most importantly, you must call {@link #CreateProxy} during the {@link\n * IDownloaderClient#onServiceConnected} callback in your activity in order to instantiate\n * an {@link IDownloaderService} object that you can then use to issue commands to the {@link\n * DownloaderService} (such as to pause and resume downloads).\n */\npublic class DownloaderServiceMarshaller {\n\n    public static final int MSG_REQUEST_ABORT_DOWNLOAD =\n            1;\n    public static final int MSG_REQUEST_PAUSE_DOWNLOAD =\n            2;\n    public static final int MSG_SET_DOWNLOAD_FLAGS =\n            3;\n    public static final int MSG_REQUEST_CONTINUE_DOWNLOAD =\n            4;\n    public static final int MSG_REQUEST_DOWNLOAD_STATE =\n            5;\n    public static final int MSG_REQUEST_CLIENT_UPDATE =\n            6;\n\n    public static final String PARAMS_FLAGS = \"flags\";\n    public static final String PARAM_MESSENGER = DownloaderService.EXTRA_MESSAGE_HANDLER;\n\n    private static class Proxy implements IDownloaderService {\n        private Messenger mMsg;\n\n        private void send(int method, Bundle params) {\n            Message m = Message.obtain(null, method);\n            m.setData(params);\n            try {\n                mMsg.send(m);\n            } catch (RemoteException e) {\n                e.printStackTrace();\n            }\n        }\n\n        public Proxy(Messenger msg) {\n            mMsg = msg;\n        }\n\n        @Override\n        public void requestAbortDownload() {\n            send(MSG_REQUEST_ABORT_DOWNLOAD, new Bundle());\n        }\n\n        @Override\n        public void requestPauseDownload() {\n            send(MSG_REQUEST_PAUSE_DOWNLOAD, new Bundle());\n        }\n\n        @Override\n        public void setDownloadFlags(int flags) {\n            Bundle params = new Bundle();\n            params.putInt(PARAMS_FLAGS, flags);\n            send(MSG_SET_DOWNLOAD_FLAGS, params);\n        }\n\n        @Override\n        public void requestContinueDownload() {\n            send(MSG_REQUEST_CONTINUE_DOWNLOAD, new Bundle());\n        }\n\n        @Override\n        public void requestDownloadStatus() {\n            send(MSG_REQUEST_DOWNLOAD_STATE, new Bundle());\n        }\n\n        @Override\n        public void onClientUpdated(Messenger clientMessenger) {\n            Bundle bundle = new Bundle(1);\n            bundle.putParcelable(PARAM_MESSENGER, clientMessenger);\n            send(MSG_REQUEST_CLIENT_UPDATE, bundle);\n        }\n    }\n\n    private static class Stub implements IStub {\n        private IDownloaderService mItf = null;\n        final Messenger mMessenger = new Messenger(new Handler() {\n            @Override\n            public void handleMessage(Message msg) {\n                switch (msg.what) {\n                    case MSG_REQUEST_ABORT_DOWNLOAD:\n                        mItf.requestAbortDownload();\n                        break;\n                    case MSG_REQUEST_CONTINUE_DOWNLOAD:\n                        mItf.requestContinueDownload();\n                        break;\n                    case MSG_REQUEST_PAUSE_DOWNLOAD:\n                        mItf.requestPauseDownload();\n                        break;\n                    case MSG_SET_DOWNLOAD_FLAGS:\n                        mItf.setDownloadFlags(msg.getData().getInt(PARAMS_FLAGS));\n                        break;\n                    case MSG_REQUEST_DOWNLOAD_STATE:\n                        mItf.requestDownloadStatus();\n                        break;\n                    case MSG_REQUEST_CLIENT_UPDATE:\n                        mItf.onClientUpdated((Messenger) msg.getData().getParcelable(\n                                PARAM_MESSENGER));\n                        break;\n                }\n            }\n        });\n\n        public Stub(IDownloaderService itf) {\n            mItf = itf;\n        }\n\n        @Override\n        public Messenger getMessenger() {\n            return mMessenger;\n        }\n\n        @Override\n        public void connect(Context c) {\n\n        }\n\n        @Override\n        public void disconnect(Context c) {\n\n        }\n    }\n\n    /**\n     * Returns a proxy that will marshall calls to IDownloaderService methods\n     * \n     * @param ctx\n     * @return\n     */\n    public static IDownloaderService CreateProxy(Messenger msg) {\n        return new Proxy(msg);\n    }\n\n    /**\n     * Returns a stub object that, when connected, will listen for marshalled\n     * IDownloaderService methods and translate them into calls to the supplied\n     * interface.\n     * \n     * @param itf An implementation of IDownloaderService that will be called\n     *            when remote method calls are unmarshalled.\n     * @return\n     */\n    public static IStub CreateStub(IDownloaderService itf) {\n        return new Stub(itf);\n    }\n\n}\n"
  },
  {
    "path": "Projects/Android/playapkexpansion/src/main/java/com/google/android/vending/expansion/downloader/Helpers.java",
    "content": "/*\n * Copyright (C) 2012 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.google.android.vending.expansion.downloader;\n\nimport com.android.vending.expansion.downloader.R;\n\nimport android.content.Context;\nimport android.os.Environment;\nimport android.os.StatFs;\nimport android.os.SystemClock;\nimport android.util.Log;\n\nimport java.io.File;\nimport java.text.SimpleDateFormat;\nimport java.util.Date;\nimport java.util.Locale;\nimport java.util.Random;\nimport java.util.TimeZone;\nimport java.util.regex.Matcher;\nimport java.util.regex.Pattern;\n\n/**\n * Some helper functions for the download manager\n */\npublic class Helpers {\n\n    public static Random sRandom = new Random(SystemClock.uptimeMillis());\n\n    /** Regex used to parse content-disposition headers */\n    private static final Pattern CONTENT_DISPOSITION_PATTERN = Pattern\n            .compile(\"attachment;\\\\s*filename\\\\s*=\\\\s*\\\"([^\\\"]*)\\\"\");\n\n    private Helpers() {\n    }\n\n    /*\n     * Parse the Content-Disposition HTTP Header. The format of the header is\n     * defined here: http://www.w3.org/Protocols/rfc2616/rfc2616-sec19.html This\n     * header provides a filename for content that is going to be downloaded to\n     * the file system. We only support the attachment type.\n     */\n    static String parseContentDisposition(String contentDisposition) {\n        try {\n            Matcher m = CONTENT_DISPOSITION_PATTERN.matcher(contentDisposition);\n            if (m.find()) {\n                return m.group(1);\n            }\n        } catch (IllegalStateException ex) {\n            // This function is defined as returning null when it can't parse\n            // the header\n        }\n        return null;\n    }\n\n    /**\n     * @return the root of the filesystem containing the given path\n     */\n    public static File getFilesystemRoot(String path) {\n        File cache = Environment.getDownloadCacheDirectory();\n        if (path.startsWith(cache.getPath())) {\n            return cache;\n        }\n        File external = Environment.getExternalStorageDirectory();\n        if (path.startsWith(external.getPath())) {\n            return external;\n        }\n        throw new IllegalArgumentException(\n                \"Cannot determine filesystem root for \" + path);\n    }\n\n    public static boolean isExternalMediaMounted() {\n        if (!Environment.getExternalStorageState().equals(\n                Environment.MEDIA_MOUNTED)) {\n            // No SD card found.\n            if ( Constants.LOGVV ) {\n                Log.d(Constants.TAG, \"no external storage\");\n            }\n            return false;\n        }\n        return true;\n    }\n\n    /**\n     * @return the number of bytes available on the filesystem rooted at the\n     *         given File\n     */\n    public static long getAvailableBytes(File root) {\n        StatFs stat = new StatFs(root.getPath());\n        // put a bit of margin (in case creating the file grows the system by a\n        // few blocks)\n        long availableBlocks = (long) stat.getAvailableBlocks() - 4;\n        return stat.getBlockSize() * availableBlocks;\n    }\n\n    /**\n     * Checks whether the filename looks legitimate\n     */\n    public static boolean isFilenameValid(String filename) {\n        filename = filename.replaceFirst(\"/+\", \"/\"); // normalize leading\n                                                     // slashes\n        return filename.startsWith(Environment.getDownloadCacheDirectory().toString())\n                || filename.startsWith(Environment.getExternalStorageDirectory().toString());\n    }\n\n    /*\n     * Delete the given file from device\n     */\n    /* package */static void deleteFile(String path) {\n        try {\n            File file = new File(path);\n            file.delete();\n        } catch (Exception e) {\n            Log.w(Constants.TAG, \"file: '\" + path + \"' couldn't be deleted\", e);\n        }\n    }\n\n    /**\n     * Showing progress in MB here. It would be nice to choose the unit (KB, MB,\n     * GB) based on total file size, but given what we know about the expected\n     * ranges of file sizes for APK expansion files, it's probably not necessary.\n     * \n     * @param overallProgress\n     * @param overallTotal\n     * @return\n     */\n\n    static public String getDownloadProgressString(long overallProgress, long overallTotal) {\n        if (overallTotal == 0) {\n            if ( Constants.LOGVV ) {\n                Log.e(Constants.TAG, \"Notification called when total is zero\");\n            }\n            return \"\";\n        }\n        return String.format(\"%.2f\",\n                (float) overallProgress / (1024.0f * 1024.0f))\n                + \"MB /\" +\n                String.format(\"%.2f\", (float) overallTotal /\n                        (1024.0f * 1024.0f)) + \"MB\";\n    }\n\n    /**\n     * Adds a percentile to getDownloadProgressString.\n     * \n     * @param overallProgress\n     * @param overallTotal\n     * @return\n     */\n    static public String getDownloadProgressStringNotification(long overallProgress,\n            long overallTotal) {\n        if (overallTotal == 0) {\n            if ( Constants.LOGVV ) {\n                Log.e(Constants.TAG, \"Notification called when total is zero\");\n            }\n            return \"\";\n        }\n        return getDownloadProgressString(overallProgress, overallTotal) + \" (\" +\n                getDownloadProgressPercent(overallProgress, overallTotal) + \")\";\n    }\n\n    public static String getDownloadProgressPercent(long overallProgress, long overallTotal) {\n        if (overallTotal == 0) {\n            if ( Constants.LOGVV ) {\n                Log.e(Constants.TAG, \"Notification called when total is zero\");\n            }\n            return \"\";\n        }\n        return Long.toString(overallProgress * 100 / overallTotal) + \"%\";\n    }\n\n    public static String getSpeedString(float bytesPerMillisecond) {\n        return String.format(\"%.2f\", bytesPerMillisecond * 1000 / 1024);\n    }\n\n    public static String getTimeRemaining(long durationInMilliseconds) {\n        SimpleDateFormat sdf;\n        if (durationInMilliseconds > 1000 * 60 * 60) {\n            sdf = new SimpleDateFormat(\"HH:mm\", Locale.getDefault());\n        } else {\n            sdf = new SimpleDateFormat(\"mm:ss\", Locale.getDefault());\n        }\n        return sdf.format(new Date(durationInMilliseconds - TimeZone.getDefault().getRawOffset()));\n    }\n\n    /**\n     * Returns the file name (without full path) for an Expansion APK file from\n     * the given context.\n     * \n     * @param c the context\n     * @param mainFile true for main file, false for patch file\n     * @param versionCode the version of the file\n     * @return String the file name of the expansion file\n     */\n    public static String getExpansionAPKFileName(Context c, boolean mainFile, int versionCode) {\n        return (mainFile ? \"main.\" : \"patch.\") + versionCode + \".\" + c.getPackageName() + \".obb\";\n    }\n\n    /**\n     * Returns the filename (where the file should be saved) from info about a\n     * download\n     */\n    static public String generateSaveFileName(Context c, String fileName) {\n        String path = getSaveFilePath(c)\n                + File.separator + fileName;\n        return path;\n    }\n\n    static public String getSaveFilePath(Context c) {\n        File root = Environment.getExternalStorageDirectory();\n        String path = root.toString() + Constants.EXP_PATH + c.getPackageName();\n        return path;\n    }\n\n    /**\n     * Helper function to ascertain the existence of a file and return\n     * true/false appropriately\n     * \n     * @param c the app/activity/service context\n     * @param fileName the name (sans path) of the file to query\n     * @param fileSize the size that the file must match\n     * @param deleteFileOnMismatch if the file sizes do not match, delete the\n     *            file\n     * @return true if it does exist, false otherwise\n     */\n    static public boolean doesFileExist(Context c, String fileName, long fileSize,\n            boolean deleteFileOnMismatch) {\n        // the file may have been delivered by Market --- let's make sure\n        // it's the size we expect\n        File fileForNewFile = new File(Helpers.generateSaveFileName(c, fileName));\n        if (fileForNewFile.exists()) {\n            if (fileForNewFile.length() == fileSize) {\n                return true;\n            }\n            if (deleteFileOnMismatch) {\n                // delete the file --- we won't be able to resume\n                // because we cannot confirm the integrity of the file\n                fileForNewFile.delete();\n            }\n        }\n        return false;\n    }\n\n    /**\n     * Converts download states that are returned by the {@link \n     * IDownloaderClient#onDownloadStateChanged} callback into usable strings.\n     * This is useful if using the state strings built into the library to display user messages.\n     * @param state One of the STATE_* constants from {@link IDownloaderClient}.\n     * @return string resource ID for the corresponding string.\n     */\n    static public int getDownloaderStringResourceIDFromState(int state) {\n        switch (state) {\n            case IDownloaderClient.STATE_IDLE:\n                return R.string.state_idle;\n            case IDownloaderClient.STATE_FETCHING_URL:\n                return R.string.state_fetching_url;\n            case IDownloaderClient.STATE_CONNECTING:\n                return R.string.state_connecting;\n            case IDownloaderClient.STATE_DOWNLOADING:\n                return R.string.state_downloading;\n            case IDownloaderClient.STATE_COMPLETED:\n                return R.string.state_completed;\n            case IDownloaderClient.STATE_PAUSED_NETWORK_UNAVAILABLE:\n                return R.string.state_paused_network_unavailable;\n            case IDownloaderClient.STATE_PAUSED_BY_REQUEST:\n                return R.string.state_paused_by_request;\n            case IDownloaderClient.STATE_PAUSED_WIFI_DISABLED_NEED_CELLULAR_PERMISSION:\n                return R.string.state_paused_wifi_disabled;\n            case IDownloaderClient.STATE_PAUSED_NEED_CELLULAR_PERMISSION:\n                return R.string.state_paused_wifi_unavailable;\n            case IDownloaderClient.STATE_PAUSED_WIFI_DISABLED:\n                return R.string.state_paused_wifi_disabled;\n            case IDownloaderClient.STATE_PAUSED_NEED_WIFI:\n                return R.string.state_paused_wifi_unavailable;\n            case IDownloaderClient.STATE_PAUSED_ROAMING:\n                return R.string.state_paused_roaming;\n            case IDownloaderClient.STATE_PAUSED_NETWORK_SETUP_FAILURE:\n                return R.string.state_paused_network_setup_failure;\n            case IDownloaderClient.STATE_PAUSED_SDCARD_UNAVAILABLE:\n                return R.string.state_paused_sdcard_unavailable;\n            case IDownloaderClient.STATE_FAILED_UNLICENSED:\n                return R.string.state_failed_unlicensed;\n            case IDownloaderClient.STATE_FAILED_FETCHING_URL:\n                return R.string.state_failed_fetching_url;\n            case IDownloaderClient.STATE_FAILED_SDCARD_FULL:\n                return R.string.state_failed_sdcard_full;\n            case IDownloaderClient.STATE_FAILED_CANCELED:\n                return R.string.state_failed_cancelled;\n            default:\n                return R.string.state_unknown;\n        }\n    }\n\n}\n"
  },
  {
    "path": "Projects/Android/playapkexpansion/src/main/java/com/google/android/vending/expansion/downloader/IDownloaderClient.java",
    "content": "/*\n * Copyright (C) 2012 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.google.android.vending.expansion.downloader;\n\nimport android.os.Messenger;\n\n/**\n * This interface should be implemented by the client activity for the\n * downloader. It is used to pass status from the service to the client.\n */\npublic interface IDownloaderClient {\n    static final int STATE_IDLE = 1;\n    static final int STATE_FETCHING_URL = 2;\n    static final int STATE_CONNECTING = 3;\n    static final int STATE_DOWNLOADING = 4;\n    static final int STATE_COMPLETED = 5;\n\n    static final int STATE_PAUSED_NETWORK_UNAVAILABLE = 6;\n    static final int STATE_PAUSED_BY_REQUEST = 7;\n\n    /**\n     * Both STATE_PAUSED_WIFI_DISABLED_NEED_CELLULAR_PERMISSION and\n     * STATE_PAUSED_NEED_CELLULAR_PERMISSION imply that Wi-Fi is unavailable and\n     * cellular permission will restart the service. Wi-Fi disabled means that\n     * the Wi-Fi manager is returning that Wi-Fi is not enabled, while in the\n     * other case Wi-Fi is enabled but not available.\n     */\n    static final int STATE_PAUSED_WIFI_DISABLED_NEED_CELLULAR_PERMISSION = 8;\n    static final int STATE_PAUSED_NEED_CELLULAR_PERMISSION = 9;\n\n    /**\n     * Both STATE_PAUSED_WIFI_DISABLED and STATE_PAUSED_NEED_WIFI imply that\n     * Wi-Fi is unavailable and cellular permission will NOT restart the\n     * service. Wi-Fi disabled means that the Wi-Fi manager is returning that\n     * Wi-Fi is not enabled, while in the other case Wi-Fi is enabled but not\n     * available.\n     * <p>\n     * The service does not return these values. We recommend that app\n     * developers with very large payloads do not allow these payloads to be\n     * downloaded over cellular connections.\n     */\n    static final int STATE_PAUSED_WIFI_DISABLED = 10;\n    static final int STATE_PAUSED_NEED_WIFI = 11;\n\n    static final int STATE_PAUSED_ROAMING = 12;\n\n    /**\n     * Scary case. We were on a network that redirected us to another website\n     * that delivered us the wrong file.\n     */\n    static final int STATE_PAUSED_NETWORK_SETUP_FAILURE = 13;\n\n    static final int STATE_PAUSED_SDCARD_UNAVAILABLE = 14;\n\n    static final int STATE_FAILED_UNLICENSED = 15;\n    static final int STATE_FAILED_FETCHING_URL = 16;\n    static final int STATE_FAILED_SDCARD_FULL = 17;\n    static final int STATE_FAILED_CANCELED = 18;\n\n    static final int STATE_FAILED = 19;\n\n    /**\n     * Called internally by the stub when the service is bound to the client.\n     * <p>\n     * Critical implementation detail. In onServiceConnected we create the\n     * remote service and marshaler. This is how we pass the client information\n     * back to the service so the client can be properly notified of changes. We\n     * must do this every time we reconnect to the service.\n     * <p>\n     * That is, when you receive this callback, you should call\n     * {@link DownloaderServiceMarshaller#CreateProxy} to instantiate a member\n     * instance of {@link IDownloaderService}, then call\n     * {@link IDownloaderService#onClientUpdated} with the Messenger retrieved\n     * from your {@link IStub} proxy object.\n     * \n     * @param m the service Messenger. This Messenger is used to call the\n     *            service API from the client.\n     */\n    void onServiceConnected(Messenger m);\n\n    /**\n     * Called when the download state changes. Depending on the state, there may\n     * be user requests. The service is free to change the download state in the\n     * middle of a user request, so the client should be able to handle this.\n     * <p>\n     * The Downloader Library includes a collection of string resources that\n     * correspond to each of the states, which you can use to provide users a\n     * useful message based on the state provided in this callback. To fetch the\n     * appropriate string for a state, call\n     * {@link Helpers#getDownloaderStringResourceIDFromState}.\n     * <p>\n     * What this means to the developer: The application has gotten a message\n     * that the download has paused due to lack of WiFi. The developer should\n     * then show UI asking the user if they want to enable downloading over\n     * cellular connections with appropriate warnings. If the application\n     * suddenly starts downloading, the application should revert to showing the\n     * progress again, rather than leaving up the download over cellular UI up.\n     * \n     * @param newState one of the STATE_* values defined in IDownloaderClient\n     */\n    void onDownloadStateChanged(int newState);\n\n    /**\n     * Shows the download progress. This is intended to be used to fill out a\n     * client UI. This progress should only be shown in a few states such as\n     * STATE_DOWNLOADING.\n     * \n     * @param progress the DownloadProgressInfo object containing the current\n     *            progress of all downloads.\n     */\n    void onDownloadProgress(DownloadProgressInfo progress);\n}\n"
  },
  {
    "path": "Projects/Android/playapkexpansion/src/main/java/com/google/android/vending/expansion/downloader/IDownloaderService.java",
    "content": "/*\n * Copyright (C) 2012 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.google.android.vending.expansion.downloader;\n\nimport com.google.android.vending.expansion.downloader.impl.DownloaderService;\nimport android.os.Messenger;\n\n/**\n * This interface is implemented by the DownloaderService and by the\n * DownloaderServiceMarshaller. It contains functions to control the service.\n * When a client binds to the service, it must call the onClientUpdated\n * function.\n * <p>\n * You can acquire a proxy that implements this interface for your service by\n * calling {@link DownloaderServiceMarshaller#CreateProxy} during the\n * {@link IDownloaderClient#onServiceConnected} callback. At which point, you\n * should immediately call {@link #onClientUpdated}.\n */\npublic interface IDownloaderService {\n    /**\n     * Set this flag in response to the\n     * IDownloaderClient.STATE_PAUSED_NEED_CELLULAR_PERMISSION state and then\n     * call RequestContinueDownload to resume a download\n     */\n    public static final int FLAGS_DOWNLOAD_OVER_CELLULAR = 1;\n\n    /**\n     * Request that the service abort the current download. The service should\n     * respond by changing the state to {@link IDownloaderClient.STATE_ABORTED}.\n     */\n    void requestAbortDownload();\n\n    /**\n     * Request that the service pause the current download. The service should\n     * respond by changing the state to\n     * {@link IDownloaderClient.STATE_PAUSED_BY_REQUEST}.\n     */\n    void requestPauseDownload();\n\n    /**\n     * Request that the service continue a paused download, when in any paused\n     * or failed state, including\n     * {@link IDownloaderClient.STATE_PAUSED_BY_REQUEST}.\n     */\n    void requestContinueDownload();\n\n    /**\n     * Set the flags for this download (e.g.\n     * {@link DownloaderService.FLAGS_DOWNLOAD_OVER_CELLULAR}).\n     * \n     * @param flags\n     */\n    void setDownloadFlags(int flags);\n\n    /**\n     * Requests that the download status be sent to the client.\n     */\n    void requestDownloadStatus();\n\n    /**\n     * Call this when you get {@link\n     * IDownloaderClient.onServiceConnected(Messenger m)} from the\n     * DownloaderClient to register the client with the service. It will\n     * automatically send the current status to the client.\n     * \n     * @param clientMessenger\n     */\n    void onClientUpdated(Messenger clientMessenger);\n}\n"
  },
  {
    "path": "Projects/Android/playapkexpansion/src/main/java/com/google/android/vending/expansion/downloader/IStub.java",
    "content": "/*\n * Copyright (C) 2012 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.google.android.vending.expansion.downloader;\n\nimport android.content.Context;\nimport android.os.Messenger;\n\n/**\n * This is the interface that is used to connect/disconnect from the downloader\n * service.\n * <p>\n * You should get a proxy object that implements this interface by calling\n * {@link DownloaderClientMarshaller#CreateStub} in your activity when the\n * downloader service starts. Then, call {@link #connect} during your activity's\n * onResume() and call {@link #disconnect} during onStop().\n * <p>\n * Then during the {@link IDownloaderClient#onServiceConnected} callback, you\n * should call {@link #getMessenger} to pass the stub's Messenger object to\n * {@link IDownloaderService#onClientUpdated}.\n */\npublic interface IStub {\n    Messenger getMessenger();\n\n    void connect(Context c);\n\n    void disconnect(Context c);\n}\n"
  },
  {
    "path": "Projects/Android/playapkexpansion/src/main/java/com/google/android/vending/expansion/downloader/SystemFacade.java",
    "content": "/*\n * Copyright (C) 2012 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.google.android.vending.expansion.downloader;\n\nimport android.app.Notification;\nimport android.app.NotificationManager;\nimport android.content.Context;\nimport android.content.Intent;\nimport android.content.pm.PackageManager.NameNotFoundException;\nimport android.net.ConnectivityManager;\nimport android.net.NetworkInfo;\nimport android.telephony.TelephonyManager;\nimport android.util.Log;\n\n/**\n * Contains useful helper functions, typically tied to the application context.\n */\nclass SystemFacade {\n    private Context mContext;\n    private NotificationManager mNotificationManager;\n\n    public SystemFacade(Context context) {\n        mContext = context;\n        mNotificationManager = (NotificationManager)\n                mContext.getSystemService(Context.NOTIFICATION_SERVICE);\n    }\n\n    public long currentTimeMillis() {\n        return System.currentTimeMillis();\n    }\n\n    public Integer getActiveNetworkType() {\n        ConnectivityManager connectivity =\n                (ConnectivityManager) mContext.getSystemService(Context.CONNECTIVITY_SERVICE);\n        if (connectivity == null) {\n            Log.w(Constants.TAG, \"couldn't get connectivity manager\");\n            return null;\n        }\n\n        NetworkInfo activeInfo = connectivity.getActiveNetworkInfo();\n        if (activeInfo == null) {\n            if (Constants.LOGVV) {\n                Log.v(Constants.TAG, \"network is not available\");\n            }\n            return null;\n        }\n        return activeInfo.getType();\n    }\n\n    public boolean isNetworkRoaming() {\n        ConnectivityManager connectivity =\n                (ConnectivityManager) mContext.getSystemService(Context.CONNECTIVITY_SERVICE);\n        if (connectivity == null) {\n            Log.w(Constants.TAG, \"couldn't get connectivity manager\");\n            return false;\n        }\n\n        NetworkInfo info = connectivity.getActiveNetworkInfo();\n        boolean isMobile = (info != null && info.getType() == ConnectivityManager.TYPE_MOBILE);\n        TelephonyManager tm = (TelephonyManager) mContext\n                .getSystemService(Context.TELEPHONY_SERVICE);\n        if (null == tm) {\n            Log.w(Constants.TAG, \"couldn't get telephony manager\");\n            return false;\n        }\n        boolean isRoaming = isMobile && tm.isNetworkRoaming();\n        if (Constants.LOGVV && isRoaming) {\n            Log.v(Constants.TAG, \"network is roaming\");\n        }\n        return isRoaming;\n    }\n\n    public Long getMaxBytesOverMobile() {\n        return (long) Integer.MAX_VALUE;\n    }\n\n    public Long getRecommendedMaxBytesOverMobile() {\n        return 2097152L;\n    }\n\n    public void sendBroadcast(Intent intent) {\n        mContext.sendBroadcast(intent);\n    }\n\n    public boolean userOwnsPackage(int uid, String packageName) throws NameNotFoundException {\n        return mContext.getPackageManager().getApplicationInfo(packageName, 0).uid == uid;\n    }\n\n    public void postNotification(long id, Notification notification) {\n        /**\n         * TODO: The system notification manager takes ints, not longs, as IDs,\n         * but the download manager uses IDs take straight from the database,\n         * which are longs. This will have to be dealt with at some point.\n         */\n        mNotificationManager.notify((int) id, notification);\n    }\n\n    public void cancelNotification(long id) {\n        mNotificationManager.cancel((int) id);\n    }\n\n    public void cancelAllNotifications() {\n        mNotificationManager.cancelAll();\n    }\n\n    public void startThread(Thread thread) {\n        thread.start();\n    }\n}\n"
  },
  {
    "path": "Projects/Android/playapkexpansion/src/main/java/com/google/android/vending/expansion/downloader/impl/AndroidHttpClient.java",
    "content": "/*\n * Copyright (C) 2012 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/*\n * This is a port of AndroidHttpClient to pre-Froyo devices, that takes advantage of\n * the SSLSessionCache added Froyo devices using reflection.\n */\n\npackage com.google.android.vending.expansion.downloader.impl;\nimport java.io.ByteArrayOutputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.OutputStream;\nimport java.lang.reflect.Constructor;\nimport java.lang.reflect.InvocationTargetException;\nimport java.lang.reflect.Method;\nimport java.net.URI;\nimport java.util.zip.GZIPInputStream;\nimport java.util.zip.GZIPOutputStream;\n\nimport org.apache.http.Header;\nimport org.apache.http.HttpEntity;\nimport org.apache.http.HttpEntityEnclosingRequest;\nimport org.apache.http.HttpException;\nimport org.apache.http.HttpHost;\nimport org.apache.http.HttpRequest;\nimport org.apache.http.HttpRequestInterceptor;\nimport org.apache.http.HttpResponse;\nimport org.apache.http.client.ClientProtocolException;\nimport org.apache.http.client.HttpClient;\nimport org.apache.http.client.ResponseHandler;\nimport org.apache.http.client.methods.HttpUriRequest;\nimport org.apache.http.client.params.HttpClientParams;\nimport org.apache.http.client.protocol.ClientContext;\nimport org.apache.http.conn.ClientConnectionManager;\nimport org.apache.http.conn.scheme.PlainSocketFactory;\nimport org.apache.http.conn.scheme.Scheme;\nimport org.apache.http.conn.scheme.SchemeRegistry;\nimport org.apache.http.conn.scheme.SocketFactory;\nimport org.apache.http.conn.ssl.SSLSocketFactory;\nimport org.apache.http.entity.AbstractHttpEntity;\nimport org.apache.http.entity.ByteArrayEntity;\nimport org.apache.http.impl.client.DefaultHttpClient;\nimport org.apache.http.impl.client.RequestWrapper;\nimport org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;\nimport org.apache.http.params.BasicHttpParams;\nimport org.apache.http.params.HttpConnectionParams;\nimport org.apache.http.params.HttpParams;\nimport org.apache.http.params.HttpProtocolParams;\nimport org.apache.http.protocol.BasicHttpContext;\nimport org.apache.http.protocol.BasicHttpProcessor;\nimport org.apache.http.protocol.HttpContext;\n\nimport android.content.ContentResolver;\nimport android.content.Context;\nimport android.net.SSLCertificateSocketFactory;\nimport android.os.Looper;\nimport android.util.Log;\n\n/**\n * Subclass of the Apache {@link DefaultHttpClient} that is configured with\n * reasonable default settings and registered schemes for Android, and\n * also lets the user add {@link HttpRequestInterceptor} classes.\n * Don't create this directly, use the {@link #newInstance} factory method.\n *\n * <p>This client processes cookies but does not retain them by default.\n * To retain cookies, simply add a cookie store to the HttpContext:</p>\n *\n * <pre>context.setAttribute(ClientContext.COOKIE_STORE, cookieStore);</pre>\n */\npublic final class AndroidHttpClient implements HttpClient {\n\n\tstatic Class<?> sSslSessionCacheClass;\n\tstatic {\n\t\t// if we are on Froyo+ devices, we can take advantage of the SSLSessionCache\n\t\ttry {\n\t\t\tsSslSessionCacheClass = Class.forName(\"android.net.SSLSessionCache\");\n\t\t} catch (Exception e) {\n\t\t\t\n\t\t}\n\t}\n\t\n    // Gzip of data shorter than this probably won't be worthwhile\n    public static long DEFAULT_SYNC_MIN_GZIP_BYTES = 256;\n\n    // Default connection and socket timeout of 60 seconds.  Tweak to taste.\n    private static final int SOCKET_OPERATION_TIMEOUT = 60 * 1000;\n\n    private static final String TAG = \"AndroidHttpClient\";\n\n\n    /** Interceptor throws an exception if the executing thread is blocked */\n    private static final HttpRequestInterceptor sThreadCheckInterceptor =\n            new HttpRequestInterceptor() {\n        public void process(HttpRequest request, HttpContext context) {\n            // Prevent the HttpRequest from being sent on the main thread\n            if (Looper.myLooper() != null && Looper.myLooper() == Looper.getMainLooper() ) {\n                throw new RuntimeException(\"This thread forbids HTTP requests\");\n            }\n        }\n    };\n\n    /**\n     * Create a new HttpClient with reasonable defaults (which you can update).\n     *\n     * @param userAgent to report in your HTTP requests\n     * @param context to use for caching SSL sessions (may be null for no caching)\n     * @return AndroidHttpClient for you to use for all your requests.\n     */\n    public static AndroidHttpClient newInstance(String userAgent, Context context) {\n        HttpParams params = new BasicHttpParams();\n\n        // Turn off stale checking.  Our connections break all the time anyway,\n        // and it's not worth it to pay the penalty of checking every time.\n        HttpConnectionParams.setStaleCheckingEnabled(params, false);\n\n        HttpConnectionParams.setConnectionTimeout(params, SOCKET_OPERATION_TIMEOUT);\n        HttpConnectionParams.setSoTimeout(params, SOCKET_OPERATION_TIMEOUT);\n        HttpConnectionParams.setSocketBufferSize(params, 8192);\n\n        // Don't handle redirects -- return them to the caller.  Our code\n        // often wants to re-POST after a redirect, which we must do ourselves.\n        HttpClientParams.setRedirecting(params, false);\n\n        Object sessionCache = null;\n        // Use a session cache for SSL sockets -- Froyo only\n        if ( null != context && null != sSslSessionCacheClass ) {\n             Constructor<?> ct;\n\t\t\ttry {\n\t\t\t\tct = sSslSessionCacheClass.getConstructor(Context.class);\n\t\t\t\tsessionCache = ct.newInstance(context);             \n\t\t\t} catch (SecurityException e) {\n\t\t\t\t// TODO Auto-generated catch block\n\t\t\t\te.printStackTrace();\n\t\t\t} catch (NoSuchMethodException e) {\n\t\t\t\t// TODO Auto-generated catch block\n\t\t\t\te.printStackTrace();\n\t\t\t} catch (IllegalArgumentException e) {\n\t\t\t\t// TODO Auto-generated catch block\n\t\t\t\te.printStackTrace();\n\t\t\t} catch (InstantiationException e) {\n\t\t\t\t// TODO Auto-generated catch block\n\t\t\t\te.printStackTrace();\n\t\t\t} catch (IllegalAccessException e) {\n\t\t\t\t// TODO Auto-generated catch block\n\t\t\t\te.printStackTrace();\n\t\t\t} catch (InvocationTargetException e) {\n\t\t\t\t// TODO Auto-generated catch block\n\t\t\t\te.printStackTrace();\n\t\t\t}\n        }\n\n        // Set the specified user agent and register standard protocols.\n        HttpProtocolParams.setUserAgent(params, userAgent);\n        SchemeRegistry schemeRegistry = new SchemeRegistry();\n        schemeRegistry.register(new Scheme(\"http\",\n                PlainSocketFactory.getSocketFactory(), 80));\n        SocketFactory sslCertificateSocketFactory = null;\n        if ( null != sessionCache ) {\n        \tMethod getHttpSocketFactoryMethod;\n\t\t\ttry {\n\t\t\t\tgetHttpSocketFactoryMethod = SSLCertificateSocketFactory.class.getDeclaredMethod(\"getHttpSocketFactory\",Integer.TYPE, sSslSessionCacheClass);\n\t        \tsslCertificateSocketFactory = (SocketFactory)getHttpSocketFactoryMethod.invoke(null, SOCKET_OPERATION_TIMEOUT, sessionCache);\n\t\t\t} catch (SecurityException e) {\n\t\t\t\t// TODO Auto-generated catch block\n\t\t\t\te.printStackTrace();\n\t\t\t} catch (NoSuchMethodException e) {\n\t\t\t\t// TODO Auto-generated catch block\n\t\t\t\te.printStackTrace();\n\t\t\t} catch (IllegalArgumentException e) {\n\t\t\t\t// TODO Auto-generated catch block\n\t\t\t\te.printStackTrace();\n\t\t\t} catch (IllegalAccessException e) {\n\t\t\t\t// TODO Auto-generated catch block\n\t\t\t\te.printStackTrace();\n\t\t\t} catch (InvocationTargetException e) {\n\t\t\t\t// TODO Auto-generated catch block\n\t\t\t\te.printStackTrace();\n\t\t\t}\n        }\n        if ( null == sslCertificateSocketFactory ) {\n        \tsslCertificateSocketFactory = SSLSocketFactory.getSocketFactory();\n        }\n        schemeRegistry.register(new Scheme(\"https\",\n                sslCertificateSocketFactory, 443));\n\n        ClientConnectionManager manager =\n                new ThreadSafeClientConnManager(params, schemeRegistry);\n\n        // We use a factory method to modify superclass initialization\n        // parameters without the funny call-a-static-method dance.\n        return new AndroidHttpClient(manager, params);\n    }\n\n    /**\n     * Create a new HttpClient with reasonable defaults (which you can update).\n     * @param userAgent to report in your HTTP requests.\n     * @return AndroidHttpClient for you to use for all your requests.\n     */\n    public static AndroidHttpClient newInstance(String userAgent) {\n        return newInstance(userAgent, null /* session cache */);\n    }\n\n    private final HttpClient delegate;\n\n    private RuntimeException mLeakedException = new IllegalStateException(\n            \"AndroidHttpClient created and never closed\");\n\n    private AndroidHttpClient(ClientConnectionManager ccm, HttpParams params) {\n        this.delegate = new DefaultHttpClient(ccm, params) {\n            @Override\n            protected BasicHttpProcessor createHttpProcessor() {\n                // Add interceptor to prevent making requests from main thread.\n                BasicHttpProcessor processor = super.createHttpProcessor();\n                processor.addRequestInterceptor(sThreadCheckInterceptor);\n                processor.addRequestInterceptor(new CurlLogger());\n\n                return processor;\n            }\n\n            @Override\n            protected HttpContext createHttpContext() {\n                // Same as DefaultHttpClient.createHttpContext() minus the\n                // cookie store.\n                HttpContext context = new BasicHttpContext();\n                context.setAttribute(\n                        ClientContext.AUTHSCHEME_REGISTRY,\n                        getAuthSchemes());\n                context.setAttribute(\n                        ClientContext.COOKIESPEC_REGISTRY,\n                        getCookieSpecs());\n                context.setAttribute(\n                        ClientContext.CREDS_PROVIDER,\n                        getCredentialsProvider());\n                return context;\n            }\n        };\n    }\n\n    @Override\n    protected void finalize() throws Throwable {\n        super.finalize();\n        if (mLeakedException != null) {\n            Log.e(TAG, \"Leak found\", mLeakedException);\n            mLeakedException = null;\n        }\n    }\n\n    /**\n     * Modifies a request to indicate to the server that we would like a\n     * gzipped response.  (Uses the \"Accept-Encoding\" HTTP header.)\n     * @param request the request to modify\n     * @see #getUngzippedContent\n     */\n    public static void modifyRequestToAcceptGzipResponse(HttpRequest request) {\n        request.addHeader(\"Accept-Encoding\", \"gzip\");\n    }\n\n    /**\n     * Gets the input stream from a response entity.  If the entity is gzipped\n     * then this will get a stream over the uncompressed data.\n     *\n     * @param entity the entity whose content should be read\n     * @return the input stream to read from\n     * @throws IOException\n     */\n    public static InputStream getUngzippedContent(HttpEntity entity)\n            throws IOException {\n        InputStream responseStream = entity.getContent();\n        if (responseStream == null) return responseStream;\n        Header header = entity.getContentEncoding();\n        if (header == null) return responseStream;\n        String contentEncoding = header.getValue();\n        if (contentEncoding == null) return responseStream;\n        if (contentEncoding.contains(\"gzip\")) responseStream\n                = new GZIPInputStream(responseStream);\n        return responseStream;\n    }\n\n    /**\n     * Release resources associated with this client.  You must call this,\n     * or significant resources (sockets and memory) may be leaked.\n     */\n    public void close() {\n        if (mLeakedException != null) {\n            getConnectionManager().shutdown();\n            mLeakedException = null;\n        }\n    }\n\n    public HttpParams getParams() {\n        return delegate.getParams();\n    }\n\n    public ClientConnectionManager getConnectionManager() {\n        return delegate.getConnectionManager();\n    }\n\n    public HttpResponse execute(HttpUriRequest request) throws IOException {\n        return delegate.execute(request);\n    }\n\n    public HttpResponse execute(HttpUriRequest request, HttpContext context)\n            throws IOException {\n        return delegate.execute(request, context);\n    }\n\n    public HttpResponse execute(HttpHost target, HttpRequest request)\n            throws IOException {\n        return delegate.execute(target, request);\n    }\n\n    public HttpResponse execute(HttpHost target, HttpRequest request,\n            HttpContext context) throws IOException {\n        return delegate.execute(target, request, context);\n    }\n\n    public <T> T execute(HttpUriRequest request,\n            ResponseHandler<? extends T> responseHandler)\n            throws IOException, ClientProtocolException {\n        return delegate.execute(request, responseHandler);\n    }\n\n    public <T> T execute(HttpUriRequest request,\n            ResponseHandler<? extends T> responseHandler, HttpContext context)\n            throws IOException, ClientProtocolException {\n        return delegate.execute(request, responseHandler, context);\n    }\n\n    public <T> T execute(HttpHost target, HttpRequest request,\n            ResponseHandler<? extends T> responseHandler) throws IOException,\n            ClientProtocolException {\n        return delegate.execute(target, request, responseHandler);\n    }\n\n    public <T> T execute(HttpHost target, HttpRequest request,\n            ResponseHandler<? extends T> responseHandler, HttpContext context)\n            throws IOException, ClientProtocolException {\n        return delegate.execute(target, request, responseHandler, context);\n    }\n\n    /**\n     * Compress data to send to server.\n     * Creates a Http Entity holding the gzipped data.\n     * The data will not be compressed if it is too short.\n     * @param data The bytes to compress\n     * @return Entity holding the data\n     */\n    public static AbstractHttpEntity getCompressedEntity(byte data[], ContentResolver resolver)\n            throws IOException {\n        AbstractHttpEntity entity;\n        if (data.length < getMinGzipSize(resolver)) {\n            entity = new ByteArrayEntity(data);\n        } else {\n            ByteArrayOutputStream arr = new ByteArrayOutputStream();\n            OutputStream zipper = new GZIPOutputStream(arr);\n            zipper.write(data);\n            zipper.close();\n            entity = new ByteArrayEntity(arr.toByteArray());\n            entity.setContentEncoding(\"gzip\");\n        }\n        return entity;\n    }\n\n    /**\n     * Retrieves the minimum size for compressing data.\n     * Shorter data will not be compressed.\n     */\n    public static long getMinGzipSize(ContentResolver resolver) {\n        return DEFAULT_SYNC_MIN_GZIP_BYTES;  // For now, this is just a constant.\n    }\n\n    /* cURL logging support. */\n\n    /**\n     * Logging tag and level.\n     */\n    private static class LoggingConfiguration {\n\n        private final String tag;\n        private final int level;\n\n        private LoggingConfiguration(String tag, int level) {\n            this.tag = tag;\n            this.level = level;\n        }\n\n        /**\n         * Returns true if logging is turned on for this configuration.\n         */\n        private boolean isLoggable() {\n            return Log.isLoggable(tag, level);\n        }\n\n        /**\n         * Prints a message using this configuration.\n         */\n        private void println(String message) {\n            Log.println(level, tag, message);\n        }\n    }\n\n    /** cURL logging configuration. */\n    private volatile LoggingConfiguration curlConfiguration;\n\n    /**\n     * Enables cURL request logging for this client.\n     *\n     * @param name to log messages with\n     * @param level at which to log messages (see {@link android.util.Log})\n     */\n    public void enableCurlLogging(String name, int level) {\n        if (name == null) {\n            throw new NullPointerException(\"name\");\n        }\n        if (level < Log.VERBOSE || level > Log.ASSERT) {\n            throw new IllegalArgumentException(\"Level is out of range [\"\n                + Log.VERBOSE + \"..\" + Log.ASSERT + \"]\");\n        }\n\n        curlConfiguration = new LoggingConfiguration(name, level);\n    }\n\n    /**\n     * Disables cURL logging for this client.\n     */\n    public void disableCurlLogging() {\n        curlConfiguration = null;\n    }\n\n    /**\n     * Logs cURL commands equivalent to requests.\n     */\n    private class CurlLogger implements HttpRequestInterceptor {\n        public void process(HttpRequest request, HttpContext context)\n                throws HttpException, IOException {\n            LoggingConfiguration configuration = curlConfiguration;\n            if (configuration != null\n                    && configuration.isLoggable()\n                    && request instanceof HttpUriRequest) {\n                // Never print auth token -- we used to check ro.secure=0 to\n                // enable that, but can't do that in unbundled code.\n                configuration.println(toCurl((HttpUriRequest) request, false));\n            }\n        }\n    }\n\n    /**\n     * Generates a cURL command equivalent to the given request.\n     */\n    private static String toCurl(HttpUriRequest request, boolean logAuthToken) throws IOException {\n        StringBuilder builder = new StringBuilder();\n\n        builder.append(\"curl \");\n\n        for (Header header: request.getAllHeaders()) {\n            if (!logAuthToken\n                    && (header.getName().equals(\"Authorization\") ||\n                        header.getName().equals(\"Cookie\"))) {\n                continue;\n            }\n            builder.append(\"--header \\\"\");\n            builder.append(header.toString().trim());\n            builder.append(\"\\\" \");\n        }\n\n        URI uri = request.getURI();\n\n        // If this is a wrapped request, use the URI from the original\n        // request instead. getURI() on the wrapper seems to return a\n        // relative URI. We want an absolute URI.\n        if (request instanceof RequestWrapper) {\n            HttpRequest original = ((RequestWrapper) request).getOriginal();\n            if (original instanceof HttpUriRequest) {\n                uri = ((HttpUriRequest) original).getURI();\n            }\n        }\n\n        builder.append(\"\\\"\");\n        builder.append(uri);\n        builder.append(\"\\\"\");\n\n        if (request instanceof HttpEntityEnclosingRequest) {\n            HttpEntityEnclosingRequest entityRequest =\n                    (HttpEntityEnclosingRequest) request;\n            HttpEntity entity = entityRequest.getEntity();\n            if (entity != null && entity.isRepeatable()) {\n                if (entity.getContentLength() < 1024) {\n                    ByteArrayOutputStream stream = new ByteArrayOutputStream();\n                    entity.writeTo(stream);\n                    String entityString = stream.toString();\n\n                    // TODO: Check the content type, too.\n                    builder.append(\" --data-ascii \\\"\")\n                            .append(entityString)\n                            .append(\"\\\"\");\n                } else {\n                    builder.append(\" [TOO MUCH DATA TO INCLUDE]\");\n                }\n            }\n        }\n\n        return builder.toString();\n    }\n\n    /**\n     * Returns the date of the given HTTP date string. This method can identify\n     * and parse the date formats emitted by common HTTP servers, such as\n     * <a href=\"http://www.ietf.org/rfc/rfc0822.txt\">RFC 822</a>,\n     * <a href=\"http://www.ietf.org/rfc/rfc0850.txt\">RFC 850</a>,\n     * <a href=\"http://www.ietf.org/rfc/rfc1036.txt\">RFC 1036</a>,\n     * <a href=\"http://www.ietf.org/rfc/rfc1123.txt\">RFC 1123</a> and\n     * <a href=\"http://www.opengroup.org/onlinepubs/007908799/xsh/asctime.html\">ANSI\n     * C's asctime()</a>.\n     *\n     * @return the number of milliseconds since Jan. 1, 1970, midnight GMT.\n     * @throws IllegalArgumentException if {@code dateString} is not a date or\n     *     of an unsupported format.\n     */\n    public static long parseDate(String dateString) {\n        return HttpDateTime.parse(dateString);\n    }\n}"
  },
  {
    "path": "Projects/Android/playapkexpansion/src/main/java/com/google/android/vending/expansion/downloader/impl/CustomIntentService.java",
    "content": "/*\n * Copyright (C) 2012 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.google.android.vending.expansion.downloader.impl;\n\nimport android.app.Service;\nimport android.content.Intent;\nimport android.os.Handler;\nimport android.os.HandlerThread;\nimport android.os.IBinder;\nimport android.os.Looper;\nimport android.os.Message;\nimport android.util.Log;\n\n/**\n * This service differs from IntentService in a few minor ways/ It will not\n * auto-stop itself after the intent is handled unless the target returns \"true\"\n * in should stop. Since the goal of this service is to handle a single kind of\n * intent, it does not queue up batches of intents of the same type.\n */\npublic abstract class CustomIntentService extends Service {\n    private String mName;\n    private boolean mRedelivery;\n    private volatile ServiceHandler mServiceHandler;\n    private volatile Looper mServiceLooper;\n    private static final String LOG_TAG = \"CancellableIntentService\";\n    private static final int WHAT_MESSAGE = -10;\n\n    public CustomIntentService(String paramString) {\n        this.mName = paramString;\n    }\n\n    @Override\n    public IBinder onBind(Intent paramIntent) {\n        return null;\n    }\n\n    @Override\n    public void onCreate() {\n        super.onCreate();\n        HandlerThread localHandlerThread = new HandlerThread(\"IntentService[\"\n                + this.mName + \"]\");\n        localHandlerThread.start();\n        this.mServiceLooper = localHandlerThread.getLooper();\n        this.mServiceHandler = new ServiceHandler(this.mServiceLooper);\n    }\n\n    @Override\n    public void onDestroy() {\n        Thread localThread = this.mServiceLooper.getThread();\n        if ((localThread != null) && (localThread.isAlive())) {\n            localThread.interrupt();\n        }\n        this.mServiceLooper.quit();\n        Log.d(LOG_TAG, \"onDestroy\");\n    }\n\n    protected abstract void onHandleIntent(Intent paramIntent);\n\n    protected abstract boolean shouldStop();\n\n    @Override\n    public void onStart(Intent paramIntent, int startId) {\n        if (!this.mServiceHandler.hasMessages(WHAT_MESSAGE)) {\n            Message localMessage = this.mServiceHandler.obtainMessage();\n            localMessage.arg1 = startId;\n            localMessage.obj = paramIntent;\n            localMessage.what = WHAT_MESSAGE;\n            this.mServiceHandler.sendMessage(localMessage);\n        }\n    }\n\n    @Override\n    public int onStartCommand(Intent paramIntent, int flags, int startId) {\n        onStart(paramIntent, startId);\n        return mRedelivery ? START_REDELIVER_INTENT : START_NOT_STICKY;\n    }\n\n    public void setIntentRedelivery(boolean enabled) {\n        this.mRedelivery = enabled;\n    }\n\n    private final class ServiceHandler extends Handler {\n        public ServiceHandler(Looper looper) {\n            super(looper);\n        }\n\n        @Override\n        public void handleMessage(Message paramMessage) {\n            CustomIntentService.this\n                    .onHandleIntent((Intent) paramMessage.obj);\n            if (shouldStop()) {\n                Log.d(LOG_TAG, \"stopSelf\");\n                CustomIntentService.this.stopSelf(paramMessage.arg1);\n                Log.d(LOG_TAG, \"afterStopSelf\");\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "Projects/Android/playapkexpansion/src/main/java/com/google/android/vending/expansion/downloader/impl/CustomNotificationFactory.java",
    "content": "/*\n * Copyright (C) 2012 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.google.android.vending.expansion.downloader.impl;\n\n/**\n * Uses the class-loader model to utilize the updated notification builders in\n * Honeycomb while maintaining a compatible version for older devices.\n */\npublic class CustomNotificationFactory {\n    static public DownloadNotification.ICustomNotification createCustomNotification() {\n        if (android.os.Build.VERSION.SDK_INT > 13)\n            return new V14CustomNotification();\n        else\n            return new V3CustomNotification();\n    }\n}\n"
  },
  {
    "path": "Projects/Android/playapkexpansion/src/main/java/com/google/android/vending/expansion/downloader/impl/DownloadInfo.java",
    "content": "/*\n * Copyright (C) 2012 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.google.android.vending.expansion.downloader.impl;\n\nimport com.google.android.vending.expansion.downloader.Constants;\nimport com.google.android.vending.expansion.downloader.Helpers;\n\nimport android.util.Log;\n\n/**\n * Representation of information about an individual download from the database.\n */\npublic class DownloadInfo {\n    public String mUri;\n    public final int mIndex;\n    public final String mFileName;\n    public String mETag;\n    public long mTotalBytes;\n    public long mCurrentBytes;\n    public long mLastMod;\n    public int mStatus;\n    public int mControl;\n    public int mNumFailed;\n    public int mRetryAfter;\n    public int mRedirectCount;\n\n    boolean mInitialized;\n\n    public int mFuzz;\n\n    public DownloadInfo(int index, String fileName, String pkg) {\n        mFuzz = Helpers.sRandom.nextInt(1001);\n        mFileName = fileName;\n        mIndex = index;\n    }\n\n    public void resetDownload() {\n        mCurrentBytes = 0;\n        mETag = \"\";\n        mLastMod = 0;\n        mStatus = 0;\n        mControl = 0;\n        mNumFailed = 0;\n        mRetryAfter = 0;\n        mRedirectCount = 0;\n    }\n\n    /**\n     * Returns the time when a download should be restarted.\n     */\n    public long restartTime(long now) {\n        if (mNumFailed == 0) {\n            return now;\n        }\n        if (mRetryAfter > 0) {\n            return mLastMod + mRetryAfter;\n        }\n        return mLastMod +\n                Constants.RETRY_FIRST_DELAY *\n                (1000 + mFuzz) * (1 << (mNumFailed - 1));\n    }\n\n    public void logVerboseInfo() {\n        Log.v(Constants.TAG, \"Service adding new entry\");\n        Log.v(Constants.TAG, \"FILENAME: \" + mFileName);\n        Log.v(Constants.TAG, \"URI     : \" + mUri);\n        Log.v(Constants.TAG, \"FILENAME: \" + mFileName);\n        Log.v(Constants.TAG, \"CONTROL : \" + mControl);\n        Log.v(Constants.TAG, \"STATUS  : \" + mStatus);\n        Log.v(Constants.TAG, \"FAILED_C: \" + mNumFailed);\n        Log.v(Constants.TAG, \"RETRY_AF: \" + mRetryAfter);\n        Log.v(Constants.TAG, \"REDIRECT: \" + mRedirectCount);\n        Log.v(Constants.TAG, \"LAST_MOD: \" + mLastMod);\n        Log.v(Constants.TAG, \"TOTAL   : \" + mTotalBytes);\n        Log.v(Constants.TAG, \"CURRENT : \" + mCurrentBytes);\n        Log.v(Constants.TAG, \"ETAG    : \" + mETag);\n    }\n}\n"
  },
  {
    "path": "Projects/Android/playapkexpansion/src/main/java/com/google/android/vending/expansion/downloader/impl/DownloadNotification.java",
    "content": "/*\n * Copyright (C) 2012 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.google.android.vending.expansion.downloader.impl;\n\nimport com.android.vending.expansion.downloader.R;\nimport com.google.android.vending.expansion.downloader.DownloadProgressInfo;\nimport com.google.android.vending.expansion.downloader.DownloaderClientMarshaller;\nimport com.google.android.vending.expansion.downloader.Helpers;\nimport com.google.android.vending.expansion.downloader.IDownloaderClient;\n\nimport android.app.Notification;\nimport android.app.NotificationManager;\nimport android.app.PendingIntent;\nimport android.content.Context;\nimport android.os.Messenger;\n\n/**\n * This class handles displaying the notification associated with the download\n * queue going on in the download manager. It handles multiple status types;\n * Some require user interaction and some do not. Some of the user interactions\n * may be transient. (for example: the user is queried to continue the download\n * on 3G when it started on WiFi, but then the phone locks onto WiFi again so\n * the prompt automatically goes away)\n * <p/>\n * The application interface for the downloader also needs to understand and\n * handle these transient states.\n */\npublic class DownloadNotification implements IDownloaderClient {\n\n    private int mState;\n    private final Context mContext;\n    private final NotificationManager mNotificationManager;\n    private String mCurrentTitle;\n\n    private IDownloaderClient mClientProxy;\n    final ICustomNotification mCustomNotification;\n    private Notification mNotification;\n    private Notification mCurrentNotification;\n    private CharSequence mLabel;\n    private String mCurrentText;\n    private PendingIntent mContentIntent;\n    private DownloadProgressInfo mProgressInfo;\n\n    static final String LOGTAG = \"DownloadNotification\";\n    static final int NOTIFICATION_ID = LOGTAG.hashCode();\n\n    public PendingIntent getClientIntent() {\n        return mContentIntent;\n    }\n\n    public void setClientIntent(PendingIntent mClientIntent) {\n        this.mContentIntent = mClientIntent;\n    }\n\n    public void resendState() {\n        if (null != mClientProxy) {\n            mClientProxy.onDownloadStateChanged(mState);\n        }\n    }\n\n    @Override\n    public void onDownloadStateChanged(int newState) {\n        if (null != mClientProxy) {\n            mClientProxy.onDownloadStateChanged(newState);\n        }\n        if (newState != mState) {\n            mState = newState;\n            if (newState == IDownloaderClient.STATE_IDLE || null == mContentIntent) {\n                return;\n            }\n            int stringDownloadID;\n            int iconResource;\n            boolean ongoingEvent;\n\n            // get the new title string and paused text\n            switch (newState) {\n                case 0:\n                    iconResource = android.R.drawable.stat_sys_warning;\n                    stringDownloadID = R.string.state_unknown;\n                    ongoingEvent = false;\n                    break;\n\n                case IDownloaderClient.STATE_DOWNLOADING:\n                    iconResource = android.R.drawable.stat_sys_download;\n                    stringDownloadID = Helpers.getDownloaderStringResourceIDFromState(newState);\n                    ongoingEvent = true;\n                    break;\n\n                case IDownloaderClient.STATE_FETCHING_URL:\n                case IDownloaderClient.STATE_CONNECTING:\n                    iconResource = android.R.drawable.stat_sys_download_done;\n                    stringDownloadID = Helpers.getDownloaderStringResourceIDFromState(newState);\n                    ongoingEvent = true;\n                    break;\n\n                case IDownloaderClient.STATE_COMPLETED:\n                case IDownloaderClient.STATE_PAUSED_BY_REQUEST:\n                    iconResource = android.R.drawable.stat_sys_download_done;\n                    stringDownloadID = Helpers.getDownloaderStringResourceIDFromState(newState);\n                    ongoingEvent = false;\n                    break;\n\n                case IDownloaderClient.STATE_FAILED:\n                case IDownloaderClient.STATE_FAILED_CANCELED:\n                case IDownloaderClient.STATE_FAILED_FETCHING_URL:\n                case IDownloaderClient.STATE_FAILED_SDCARD_FULL:\n                case IDownloaderClient.STATE_FAILED_UNLICENSED:\n                    iconResource = android.R.drawable.stat_sys_warning;\n                    stringDownloadID = Helpers.getDownloaderStringResourceIDFromState(newState);\n                    ongoingEvent = false;\n                    break;\n\n                default:\n                    iconResource = android.R.drawable.stat_sys_warning;\n                    stringDownloadID = Helpers.getDownloaderStringResourceIDFromState(newState);\n                    ongoingEvent = true;\n                    break;\n            }\n            mCurrentText = mContext.getString(stringDownloadID);\n            mCurrentTitle = mLabel.toString();\n            mCurrentNotification.tickerText = mLabel + \": \" + mCurrentText;\n            mCurrentNotification.icon = iconResource;\n            mCurrentNotification.setLatestEventInfo(mContext, mCurrentTitle, mCurrentText,\n                    mContentIntent);\n            if (ongoingEvent) {\n                mCurrentNotification.flags |= Notification.FLAG_ONGOING_EVENT;\n            } else {\n                mCurrentNotification.flags &= ~Notification.FLAG_ONGOING_EVENT;\n                mCurrentNotification.flags |= Notification.FLAG_AUTO_CANCEL;\n            }\n            mNotificationManager.notify(NOTIFICATION_ID, mCurrentNotification);\n        }\n    }\n\n    @Override\n    public void onDownloadProgress(DownloadProgressInfo progress) {\n        mProgressInfo = progress;\n        if (null != mClientProxy) {\n            mClientProxy.onDownloadProgress(progress);\n        }\n        if (progress.mOverallTotal <= 0) {\n            // we just show the text\n            mNotification.tickerText = mCurrentTitle;\n            mNotification.icon = android.R.drawable.stat_sys_download;\n            mNotification.setLatestEventInfo(mContext, mLabel, mCurrentText, mContentIntent);\n            mCurrentNotification = mNotification;\n        } else {\n            mCustomNotification.setCurrentBytes(progress.mOverallProgress);\n            mCustomNotification.setTotalBytes(progress.mOverallTotal);\n            mCustomNotification.setIcon(android.R.drawable.stat_sys_download);\n            mCustomNotification.setPendingIntent(mContentIntent);\n            mCustomNotification.setTicker(mLabel + \": \" + mCurrentText);\n            mCustomNotification.setTitle(mLabel);\n            mCustomNotification.setTimeRemaining(progress.mTimeRemaining);\n            mCurrentNotification = mCustomNotification.updateNotification(mContext);\n        }\n        mNotificationManager.notify(NOTIFICATION_ID, mCurrentNotification);\n    }\n\n    public interface ICustomNotification {\n        void setTitle(CharSequence title);\n\n        void setTicker(CharSequence ticker);\n\n        void setPendingIntent(PendingIntent mContentIntent);\n\n        void setTotalBytes(long totalBytes);\n\n        void setCurrentBytes(long currentBytes);\n\n        void setIcon(int iconResource);\n\n        void setTimeRemaining(long timeRemaining);\n\n        Notification updateNotification(Context c);\n    }\n\n    /**\n     * Called in response to onClientUpdated. Creates a new proxy and notifies\n     * it of the current state.\n     * \n     * @param msg the client Messenger to notify\n     */\n    public void setMessenger(Messenger msg) {\n        mClientProxy = DownloaderClientMarshaller.CreateProxy(msg);\n        if (null != mProgressInfo) {\n            mClientProxy.onDownloadProgress(mProgressInfo);\n        }\n        if (mState != -1) {\n            mClientProxy.onDownloadStateChanged(mState);\n        }\n    }\n\n    /**\n     * Constructor\n     * \n     * @param ctx The context to use to obtain access to the Notification\n     *            Service\n     */\n    DownloadNotification(Context ctx, CharSequence applicationLabel) {\n        mState = -1;\n        mContext = ctx;\n        mLabel = applicationLabel;\n        mNotificationManager = (NotificationManager)\n                mContext.getSystemService(Context.NOTIFICATION_SERVICE);\n        mCustomNotification = CustomNotificationFactory\n                .createCustomNotification();\n        mNotification = new Notification();\n        mCurrentNotification = mNotification;\n\n    }\n\n    @Override\n    public void onServiceConnected(Messenger m) {\n    }\n\n}\n"
  },
  {
    "path": "Projects/Android/playapkexpansion/src/main/java/com/google/android/vending/expansion/downloader/impl/DownloadThread.java",
    "content": "/*\n * Copyright (C) 2012 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.google.android.vending.expansion.downloader.impl;\n\nimport com.google.android.vending.expansion.downloader.Constants;\nimport com.google.android.vending.expansion.downloader.Helpers;\nimport com.google.android.vending.expansion.downloader.IDownloaderClient;\n\nimport org.apache.http.Header;\nimport org.apache.http.HttpHost;\nimport org.apache.http.HttpResponse;\nimport org.apache.http.client.methods.HttpGet;\nimport org.apache.http.conn.params.ConnRouteParams;\n\nimport android.content.Context;\nimport android.net.Proxy;\nimport android.os.PowerManager;\nimport android.os.Process;\nimport android.util.Log;\n\nimport java.io.File;\nimport java.io.FileNotFoundException;\nimport java.io.FileOutputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.SyncFailedException;\nimport java.net.URI;\nimport java.net.URISyntaxException;\nimport java.util.Locale;\n\n/**\n * Runs an actual download\n */\npublic class DownloadThread {\n\n    private Context mContext;\n    private DownloadInfo mInfo;\n    private DownloaderService mService;\n    private final DownloadsDB mDB;\n    private final DownloadNotification mNotification;\n    private String mUserAgent;\n\n    public DownloadThread(DownloadInfo info, DownloaderService service,\n            DownloadNotification notification) {\n        mContext = service;\n        mInfo = info;\n        mService = service;\n        mNotification = notification;\n        mDB = DownloadsDB.getDB(service);\n        mUserAgent = \"APKXDL (Linux; U; Android \" + android.os.Build.VERSION.RELEASE + \";\"\n                + Locale.getDefault().toString() + \"; \" + android.os.Build.DEVICE + \"/\"\n                + android.os.Build.ID + \")\" +\n                service.getPackageName();\n    }\n\n    /**\n     * Returns the default user agent\n     */\n    private String userAgent() {\n        return mUserAgent;\n    }\n\n    /**\n     * State for the entire run() method.\n     */\n    private static class State {\n        public String mFilename;\n        public FileOutputStream mStream;\n        public boolean mCountRetry = false;\n        public int mRetryAfter = 0;\n        public int mRedirectCount = 0;\n        public String mNewUri;\n        public boolean mGotData = false;\n        public String mRequestUri;\n\n        public State(DownloadInfo info, DownloaderService service) {\n            mRedirectCount = info.mRedirectCount;\n            mRequestUri = info.mUri;\n            mFilename = service.generateTempSaveFileName(info.mFileName);\n        }\n    }\n\n    /**\n     * State within executeDownload()\n     */\n    private static class InnerState {\n        public int mBytesSoFar = 0;\n        public int mBytesThisSession = 0;\n        public String mHeaderETag;\n        public boolean mContinuingDownload = false;\n        public String mHeaderContentLength;\n        public String mHeaderContentDisposition;\n        public String mHeaderContentLocation;\n        public int mBytesNotified = 0;\n        public long mTimeLastNotification = 0;\n    }\n\n    /**\n     * Raised from methods called by run() to indicate that the current request\n     * should be stopped immediately. Note the message passed to this exception\n     * will be logged and therefore must be guaranteed not to contain any PII,\n     * meaning it generally can't include any information about the request URI,\n     * headers, or destination filename.\n     */\n    private class StopRequest extends Throwable {\n        /**\n\t\t * \n\t\t */\n        private static final long serialVersionUID = 6338592678988347973L;\n        public int mFinalStatus;\n\n        public StopRequest(int finalStatus, String message) {\n            super(message);\n            mFinalStatus = finalStatus;\n        }\n\n        public StopRequest(int finalStatus, String message, Throwable throwable) {\n            super(message, throwable);\n            mFinalStatus = finalStatus;\n        }\n    }\n\n    /**\n     * Raised from methods called by executeDownload() to indicate that the\n     * download should be retried immediately.\n     */\n    private class RetryDownload extends Throwable {\n\n        /**\n\t\t * \n\t\t */\n        private static final long serialVersionUID = 6196036036517540229L;\n    }\n\n    /**\n     * Returns the preferred proxy to be used by clients. This is a wrapper\n     * around {@link android.net.Proxy#getHost()}. Currently no proxy will be\n     * returned for localhost or if the active network is Wi-Fi.\n     * \n     * @param context the context which will be passed to\n     *            {@link android.net.Proxy#getHost()}\n     * @param url the target URL for the request\n     * @note Calling this method requires permission\n     *       android.permission.ACCESS_NETWORK_STATE\n     * @return The preferred proxy to be used by clients, or null if there is no\n     *         proxy.\n     */\n    public HttpHost getPreferredHttpHost(Context context,\n            String url) {\n        if (!isLocalHost(url) && !mService.isWiFi()) {\n            final String proxyHost = Proxy.getHost(context);\n            if (proxyHost != null) {\n                return new HttpHost(proxyHost, Proxy.getPort(context), \"http\");\n            }\n        }\n\n        return null;\n    }\n\n    static final private boolean isLocalHost(String url) {\n        if (url == null) {\n            return false;\n        }\n\n        try {\n            final URI uri = URI.create(url);\n            final String host = uri.getHost();\n            if (host != null) {\n                // TODO: InetAddress.isLoopbackAddress should be used to check\n                // for localhost. However no public factory methods exist which\n                // can be used without triggering DNS lookup if host is not\n                // localhost.\n                if (host.equalsIgnoreCase(\"localhost\") ||\n                        host.equals(\"127.0.0.1\") ||\n                        host.equals(\"[::1]\")) {\n                    return true;\n                }\n            }\n        } catch (IllegalArgumentException iex) {\n            // Ignore (URI.create)\n        }\n\n        return false;\n    }\n\n    /**\n     * Executes the download in a separate thread\n     */\n    public void run() {\n        Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);\n\n        State state = new State(mInfo, mService);\n        AndroidHttpClient client = null;\n        PowerManager.WakeLock wakeLock = null;\n        int finalStatus = DownloaderService.STATUS_UNKNOWN_ERROR;\n\n        try {\n            PowerManager pm = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);\n            wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, Constants.TAG);\n            wakeLock.acquire();\n\n            if (Constants.LOGV) {\n                Log.v(Constants.TAG, \"initiating download for \" + mInfo.mFileName);\n                Log.v(Constants.TAG, \"  at \" + mInfo.mUri);\n            }\n\n            client = AndroidHttpClient.newInstance(userAgent(), mContext);\n\n            boolean finished = false;\n            while (!finished) {\n                if (Constants.LOGV) {\n                    Log.v(Constants.TAG, \"initiating download for \" + mInfo.mFileName);\n                    Log.v(Constants.TAG, \"  at \" + mInfo.mUri);\n                }\n                // Set or unset proxy, which may have changed since last GET\n                // request.\n                // setDefaultProxy() supports null as proxy parameter.\n                ConnRouteParams.setDefaultProxy(client.getParams(),\n                        getPreferredHttpHost(mContext, state.mRequestUri));\n                HttpGet request = new HttpGet(state.mRequestUri);\n                try {\n                    executeDownload(state, client, request);\n                    finished = true;\n                } catch (RetryDownload exc) {\n                    // fall through\n                } finally {\n                    request.abort();\n                    request = null;\n                }\n            }\n\n            if (Constants.LOGV) {\n                Log.v(Constants.TAG, \"download completed for \" + mInfo.mFileName);\n                Log.v(Constants.TAG, \"  at \" + mInfo.mUri);\n            }\n            finalizeDestinationFile(state);\n            finalStatus = DownloaderService.STATUS_SUCCESS;\n        } catch (StopRequest error) {\n            // remove the cause before printing, in case it contains PII\n            Log.w(Constants.TAG,\n                    \"Aborting request for download \" + mInfo.mFileName + \": \" + error.getMessage());\n            error.printStackTrace();\n            finalStatus = error.mFinalStatus;\n            // fall through to finally block\n        } catch (Throwable ex) { // sometimes the socket code throws unchecked\n                                 // exceptions\n            Log.w(Constants.TAG, \"Exception for \" + mInfo.mFileName + \": \" + ex);\n            finalStatus = DownloaderService.STATUS_UNKNOWN_ERROR;\n            // falls through to the code that reports an error\n        } finally {\n            if (wakeLock != null) {\n                wakeLock.release();\n                wakeLock = null;\n            }\n            if (client != null) {\n                client.close();\n                client = null;\n            }\n            cleanupDestination(state, finalStatus);\n            notifyDownloadCompleted(finalStatus, state.mCountRetry, state.mRetryAfter,\n                    state.mRedirectCount, state.mGotData, state.mFilename);\n        }\n    }\n\n    /**\n     * Fully execute a single download request - setup and send the request,\n     * handle the response, and transfer the data to the destination file.\n     */\n    private void executeDownload(State state, AndroidHttpClient client, HttpGet request)\n            throws StopRequest, RetryDownload {\n        InnerState innerState = new InnerState();\n        byte data[] = new byte[Constants.BUFFER_SIZE];\n\n        checkPausedOrCanceled(state);\n\n        setupDestinationFile(state, innerState);\n        addRequestHeaders(innerState, request);\n\n        // check just before sending the request to avoid using an invalid\n        // connection at all\n        checkConnectivity(state);\n\n        mNotification.onDownloadStateChanged(IDownloaderClient.STATE_CONNECTING);\n        HttpResponse response = sendRequest(state, client, request);\n        handleExceptionalStatus(state, innerState, response);\n\n        if (Constants.LOGV) {\n            Log.v(Constants.TAG, \"received response for \" + mInfo.mUri);\n        }\n\n        processResponseHeaders(state, innerState, response);\n        InputStream entityStream = openResponseEntity(state, response);\n        mNotification.onDownloadStateChanged(IDownloaderClient.STATE_DOWNLOADING);\n        transferData(state, innerState, data, entityStream);\n    }\n\n    /**\n     * Check if current connectivity is valid for this request.\n     */\n    private void checkConnectivity(State state) throws StopRequest {\n        switch (mService.getNetworkAvailabilityState(mDB)) {\n            case DownloaderService.NETWORK_OK:\n                return;\n            case DownloaderService.NETWORK_NO_CONNECTION:\n                throw new StopRequest(DownloaderService.STATUS_WAITING_FOR_NETWORK,\n                        \"waiting for network to return\");\n            case DownloaderService.NETWORK_TYPE_DISALLOWED_BY_REQUESTOR:\n                throw new StopRequest(\n                        DownloaderService.STATUS_QUEUED_FOR_WIFI_OR_CELLULAR_PERMISSION,\n                        \"waiting for wifi or for download over cellular to be authorized\");\n            case DownloaderService.NETWORK_CANNOT_USE_ROAMING:\n                throw new StopRequest(DownloaderService.STATUS_WAITING_FOR_NETWORK,\n                        \"roaming is not allowed\");\n            case DownloaderService.NETWORK_UNUSABLE_DUE_TO_SIZE:\n                throw new StopRequest(DownloaderService.STATUS_QUEUED_FOR_WIFI, \"waiting for wifi\");\n        }\n    }\n\n    /**\n     * Transfer as much data as possible from the HTTP response to the\n     * destination file.\n     * \n     * @param data buffer to use to read data\n     * @param entityStream stream for reading the HTTP response entity\n     */\n    private void transferData(State state, InnerState innerState, byte[] data,\n            InputStream entityStream) throws StopRequest {\n        for (;;) {\n            int bytesRead = readFromResponse(state, innerState, data, entityStream);\n            if (bytesRead == -1) { // success, end of stream already reached\n                handleEndOfStream(state, innerState);\n                return;\n            }\n\n            state.mGotData = true;\n            writeDataToDestination(state, data, bytesRead);\n            innerState.mBytesSoFar += bytesRead;\n            innerState.mBytesThisSession += bytesRead;\n            reportProgress(state, innerState);\n\n            checkPausedOrCanceled(state);\n        }\n    }\n\n    /**\n     * Called after a successful completion to take any necessary action on the\n     * downloaded file.\n     */\n    private void finalizeDestinationFile(State state) throws StopRequest {\n        syncDestination(state);\n        String tempFilename = state.mFilename;\n        String finalFilename = Helpers.generateSaveFileName(mService, mInfo.mFileName);\n        if (!state.mFilename.equals(finalFilename)) {\n            File startFile = new File(tempFilename);\n            File destFile = new File(finalFilename);\n            if (mInfo.mTotalBytes != -1 && mInfo.mCurrentBytes == mInfo.mTotalBytes) {\n                if (!startFile.renameTo(destFile)) {\n                    throw new StopRequest(DownloaderService.STATUS_FILE_ERROR,\n                            \"unable to finalize destination file\");\n                }\n            } else {\n                throw new StopRequest(DownloaderService.STATUS_FILE_DELIVERED_INCORRECTLY,\n                        \"file delivered with incorrect size. probably due to network not browser configured\");\n            }\n        }\n    }\n\n    /**\n     * Called just before the thread finishes, regardless of status, to take any\n     * necessary action on the downloaded file.\n     */\n    private void cleanupDestination(State state, int finalStatus) {\n        closeDestination(state);\n        if (state.mFilename != null && DownloaderService.isStatusError(finalStatus)) {\n            new File(state.mFilename).delete();\n            state.mFilename = null;\n        }\n    }\n\n    /**\n     * Sync the destination file to storage.\n     */\n    private void syncDestination(State state) {\n        FileOutputStream downloadedFileStream = null;\n        try {\n            downloadedFileStream = new FileOutputStream(state.mFilename, true);\n            downloadedFileStream.getFD().sync();\n        } catch (FileNotFoundException ex) {\n            Log.w(Constants.TAG, \"file \" + state.mFilename + \" not found: \" + ex);\n        } catch (SyncFailedException ex) {\n            Log.w(Constants.TAG, \"file \" + state.mFilename + \" sync failed: \" + ex);\n        } catch (IOException ex) {\n            Log.w(Constants.TAG, \"IOException trying to sync \" + state.mFilename + \": \" + ex);\n        } catch (RuntimeException ex) {\n            Log.w(Constants.TAG, \"exception while syncing file: \", ex);\n        } finally {\n            if (downloadedFileStream != null) {\n                try {\n                    downloadedFileStream.close();\n                } catch (IOException ex) {\n                    Log.w(Constants.TAG, \"IOException while closing synced file: \", ex);\n                } catch (RuntimeException ex) {\n                    Log.w(Constants.TAG, \"exception while closing file: \", ex);\n                }\n            }\n        }\n    }\n\n    /**\n     * Close the destination output stream.\n     */\n    private void closeDestination(State state) {\n        try {\n            // close the file\n            if (state.mStream != null) {\n                state.mStream.close();\n                state.mStream = null;\n            }\n        } catch (IOException ex) {\n            if (Constants.LOGV) {\n                Log.v(Constants.TAG, \"exception when closing the file after download : \" + ex);\n            }\n            // nothing can really be done if the file can't be closed\n        }\n    }\n\n    /**\n     * Check if the download has been paused or canceled, stopping the request\n     * appropriately if it has been.\n     */\n    private void checkPausedOrCanceled(State state) throws StopRequest {\n        if (mService.getControl() == DownloaderService.CONTROL_PAUSED) {\n            int status = mService.getStatus();\n            switch (status) {\n                case DownloaderService.STATUS_PAUSED_BY_APP:\n                    throw new StopRequest(mService.getStatus(),\n                            \"download paused\");\n            }\n        }\n    }\n\n    /**\n     * Report download progress through the database if necessary.\n     */\n    private void reportProgress(State state, InnerState innerState) {\n        long now = System.currentTimeMillis();\n        if (innerState.mBytesSoFar - innerState.mBytesNotified\n                > Constants.MIN_PROGRESS_STEP\n                && now - innerState.mTimeLastNotification\n                > Constants.MIN_PROGRESS_TIME) {\n            // we store progress updates to the database here\n            mInfo.mCurrentBytes = innerState.mBytesSoFar;\n            mDB.updateDownloadCurrentBytes(mInfo);\n\n            innerState.mBytesNotified = innerState.mBytesSoFar;\n            innerState.mTimeLastNotification = now;\n\n            long totalBytesSoFar = innerState.mBytesThisSession + mService.mBytesSoFar;\n\n            if (Constants.LOGVV) {\n                Log.v(Constants.TAG, \"downloaded \" + mInfo.mCurrentBytes + \" out of \"\n                        + mInfo.mTotalBytes);\n                Log.v(Constants.TAG, \"     total \" + totalBytesSoFar + \" out of \"\n                        + mService.mTotalLength);\n            }\n\n            mService.notifyUpdateBytes(totalBytesSoFar);\n        }\n    }\n\n    /**\n     * Write a data buffer to the destination file.\n     * \n     * @param data buffer containing the data to write\n     * @param bytesRead how many bytes to write from the buffer\n     */\n    private void writeDataToDestination(State state, byte[] data, int bytesRead)\n            throws StopRequest {\n        for (;;) {\n            try {\n                if (state.mStream == null) {\n                    state.mStream = new FileOutputStream(state.mFilename, true);\n                }\n                state.mStream.write(data, 0, bytesRead);\n                // we close after every write --- this may be too inefficient\n                closeDestination(state);\n                return;\n            } catch (IOException ex) {\n                if (!Helpers.isExternalMediaMounted()) {\n                    throw new StopRequest(DownloaderService.STATUS_DEVICE_NOT_FOUND_ERROR,\n                            \"external media not mounted while writing destination file\");\n                }\n\n                long availableBytes =\n                        Helpers.getAvailableBytes(Helpers.getFilesystemRoot(state.mFilename));\n                if (availableBytes < bytesRead) {\n                    throw new StopRequest(DownloaderService.STATUS_INSUFFICIENT_SPACE_ERROR,\n                            \"insufficient space while writing destination file\", ex);\n                }\n                throw new StopRequest(DownloaderService.STATUS_FILE_ERROR,\n                        \"while writing destination file: \" + ex.toString(), ex);\n            }\n        }\n    }\n\n    /**\n     * Called when we've reached the end of the HTTP response stream, to update\n     * the database and check for consistency.\n     */\n    private void handleEndOfStream(State state, InnerState innerState) throws StopRequest {\n        mInfo.mCurrentBytes = innerState.mBytesSoFar;\n        // this should always be set from the market\n        // if ( innerState.mHeaderContentLength == null ) {\n        // mInfo.mTotalBytes = innerState.mBytesSoFar;\n        // }\n        mDB.updateDownload(mInfo);\n\n        boolean lengthMismatched = (innerState.mHeaderContentLength != null)\n                && (innerState.mBytesSoFar != Integer.parseInt(innerState.mHeaderContentLength));\n        if (lengthMismatched) {\n            if (cannotResume(innerState)) {\n                throw new StopRequest(DownloaderService.STATUS_CANNOT_RESUME,\n                        \"mismatched content length\");\n            } else {\n                throw new StopRequest(getFinalStatusForHttpError(state),\n                        \"closed socket before end of file\");\n            }\n        }\n    }\n\n    private boolean cannotResume(InnerState innerState) {\n        return innerState.mBytesSoFar > 0 && innerState.mHeaderETag == null;\n    }\n\n    /**\n     * Read some data from the HTTP response stream, handling I/O errors.\n     * \n     * @param data buffer to use to read data\n     * @param entityStream stream for reading the HTTP response entity\n     * @return the number of bytes actually read or -1 if the end of the stream\n     *         has been reached\n     */\n    private int readFromResponse(State state, InnerState innerState, byte[] data,\n            InputStream entityStream) throws StopRequest {\n        try {\n            return entityStream.read(data);\n        } catch (IOException ex) {\n            logNetworkState();\n            mInfo.mCurrentBytes = innerState.mBytesSoFar;\n            mDB.updateDownload(mInfo);\n            if (cannotResume(innerState)) {\n                String message = \"while reading response: \" + ex.toString()\n                        + \", can't resume interrupted download with no ETag\";\n                throw new StopRequest(DownloaderService.STATUS_CANNOT_RESUME,\n                        message, ex);\n            } else {\n                throw new StopRequest(getFinalStatusForHttpError(state),\n                        \"while reading response: \" + ex.toString(), ex);\n            }\n        }\n    }\n\n    /**\n     * Open a stream for the HTTP response entity, handling I/O errors.\n     * \n     * @return an InputStream to read the response entity\n     */\n    private InputStream openResponseEntity(State state, HttpResponse response)\n            throws StopRequest {\n        try {\n            return response.getEntity().getContent();\n        } catch (IOException ex) {\n            logNetworkState();\n            throw new StopRequest(getFinalStatusForHttpError(state),\n                    \"while getting entity: \" + ex.toString(), ex);\n        }\n    }\n\n    private void logNetworkState() {\n        if (Constants.LOGX) {\n            Log.i(Constants.TAG,\n                    \"Net \"\n                            + (mService.getNetworkAvailabilityState(mDB) == DownloaderService.NETWORK_OK ? \"Up\"\n                                    : \"Down\"));\n        }\n    }\n\n    /**\n     * Read HTTP response headers and take appropriate action, including setting\n     * up the destination file and updating the database.\n     */\n    private void processResponseHeaders(State state, InnerState innerState, HttpResponse response)\n            throws StopRequest {\n        if (innerState.mContinuingDownload) {\n            // ignore response headers on resume requests\n            return;\n        }\n\n        readResponseHeaders(state, innerState, response);\n\n        try {\n            state.mFilename = mService.generateSaveFile(mInfo.mFileName, mInfo.mTotalBytes);\n        } catch (DownloaderService.GenerateSaveFileError exc) {\n            throw new StopRequest(exc.mStatus, exc.mMessage);\n        }\n        try {\n            state.mStream = new FileOutputStream(state.mFilename);\n        } catch (FileNotFoundException exc) {\n            // make sure the directory exists\n            File pathFile = new File(Helpers.getSaveFilePath(mService));\n            try {\n                if (pathFile.mkdirs()) {\n                    state.mStream = new FileOutputStream(state.mFilename);\n                }\n            } catch (Exception ex) {\n                throw new StopRequest(DownloaderService.STATUS_FILE_ERROR,\n                        \"while opening destination file: \" + exc.toString(), exc);\n            }\n        }\n        if (Constants.LOGV) {\n            Log.v(Constants.TAG, \"writing \" + mInfo.mUri + \" to \" + state.mFilename);\n        }\n\n        updateDatabaseFromHeaders(state, innerState);\n        // check connectivity again now that we know the total size\n        checkConnectivity(state);\n    }\n\n    /**\n     * Update necessary database fields based on values of HTTP response headers\n     * that have been read.\n     */\n    private void updateDatabaseFromHeaders(State state, InnerState innerState) {\n        mInfo.mETag = innerState.mHeaderETag;\n        mDB.updateDownload(mInfo);\n    }\n\n    /**\n     * Read headers from the HTTP response and store them into local state.\n     */\n    private void readResponseHeaders(State state, InnerState innerState, HttpResponse response)\n            throws StopRequest {\n        Header header = response.getFirstHeader(\"Content-Disposition\");\n        if (header != null) {\n            innerState.mHeaderContentDisposition = header.getValue();\n        }\n        header = response.getFirstHeader(\"Content-Location\");\n        if (header != null) {\n            innerState.mHeaderContentLocation = header.getValue();\n        }\n        header = response.getFirstHeader(\"ETag\");\n        if (header != null) {\n            innerState.mHeaderETag = header.getValue();\n        }\n        String headerTransferEncoding = null;\n        header = response.getFirstHeader(\"Transfer-Encoding\");\n        if (header != null) {\n            headerTransferEncoding = header.getValue();\n        }\n        String headerContentType = null;\n        header = response.getFirstHeader(\"Content-Type\");\n        if (header != null) {\n            headerContentType = header.getValue();\n            if (!headerContentType.equals(\"application/vnd.android.obb\")) {\n                throw new StopRequest(DownloaderService.STATUS_FILE_DELIVERED_INCORRECTLY,\n                        \"file delivered with incorrect Mime type\");\n            }\n        }\n\n        if (headerTransferEncoding == null) {\n            header = response.getFirstHeader(\"Content-Length\");\n            if (header != null) {\n                innerState.mHeaderContentLength = header.getValue();\n                // this is always set from Market\n                long contentLength = Long.parseLong(innerState.mHeaderContentLength);\n                if (contentLength != -1 && contentLength != mInfo.mTotalBytes) {\n                    // we're most likely on a bad wifi connection -- we should\n                    // probably\n                    // also look at the mime type --- but the size mismatch is\n                    // enough\n                    // to tell us that something is wrong here\n                    Log.e(Constants.TAG, \"Incorrect file size delivered.\");\n                }\n            }\n        } else {\n            // Ignore content-length with transfer-encoding - 2616 4.4 3\n            if (Constants.LOGVV) {\n                Log.v(Constants.TAG,\n                        \"ignoring content-length because of xfer-encoding\");\n            }\n        }\n        if (Constants.LOGVV) {\n            Log.v(Constants.TAG, \"Content-Disposition: \" +\n                    innerState.mHeaderContentDisposition);\n            Log.v(Constants.TAG, \"Content-Length: \" + innerState.mHeaderContentLength);\n            Log.v(Constants.TAG, \"Content-Location: \" + innerState.mHeaderContentLocation);\n            Log.v(Constants.TAG, \"ETag: \" + innerState.mHeaderETag);\n            Log.v(Constants.TAG, \"Transfer-Encoding: \" + headerTransferEncoding);\n        }\n\n        boolean noSizeInfo = innerState.mHeaderContentLength == null\n                && (headerTransferEncoding == null\n                || !headerTransferEncoding.equalsIgnoreCase(\"chunked\"));\n        if (noSizeInfo) {\n            throw new StopRequest(DownloaderService.STATUS_HTTP_DATA_ERROR,\n                    \"can't know size of download, giving up\");\n        }\n    }\n\n    /**\n     * Check the HTTP response status and handle anything unusual (e.g. not\n     * 200/206).\n     */\n    private void handleExceptionalStatus(State state, InnerState innerState, HttpResponse response)\n            throws StopRequest, RetryDownload {\n        int statusCode = response.getStatusLine().getStatusCode();\n        if (statusCode == 503 && mInfo.mNumFailed < Constants.MAX_RETRIES) {\n            handleServiceUnavailable(state, response);\n        }\n        if (statusCode == 301 || statusCode == 302 || statusCode == 303 || statusCode == 307) {\n            handleRedirect(state, response, statusCode);\n        }\n\n        int expectedStatus = innerState.mContinuingDownload ? 206\n                : DownloaderService.STATUS_SUCCESS;\n        if (statusCode != expectedStatus) {\n            handleOtherStatus(state, innerState, statusCode);\n        } else {\n            // no longer redirected\n            state.mRedirectCount = 0;\n        }\n    }\n\n    /**\n     * Handle a status that we don't know how to deal with properly.\n     */\n    private void handleOtherStatus(State state, InnerState innerState, int statusCode)\n            throws StopRequest {\n        int finalStatus;\n        if (DownloaderService.isStatusError(statusCode)) {\n            finalStatus = statusCode;\n        } else if (statusCode >= 300 && statusCode < 400) {\n            finalStatus = DownloaderService.STATUS_UNHANDLED_REDIRECT;\n        } else if (innerState.mContinuingDownload && statusCode == DownloaderService.STATUS_SUCCESS) {\n            finalStatus = DownloaderService.STATUS_CANNOT_RESUME;\n        } else {\n            finalStatus = DownloaderService.STATUS_UNHANDLED_HTTP_CODE;\n        }\n        throw new StopRequest(finalStatus, \"http error \" + statusCode);\n    }\n\n    /**\n     * Handle a 3xx redirect status.\n     */\n    private void handleRedirect(State state, HttpResponse response, int statusCode)\n            throws StopRequest, RetryDownload {\n        if (Constants.LOGVV) {\n            Log.v(Constants.TAG, \"got HTTP redirect \" + statusCode);\n        }\n        if (state.mRedirectCount >= Constants.MAX_REDIRECTS) {\n            throw new StopRequest(DownloaderService.STATUS_TOO_MANY_REDIRECTS, \"too many redirects\");\n        }\n        Header header = response.getFirstHeader(\"Location\");\n        if (header == null) {\n            return;\n        }\n        if (Constants.LOGVV) {\n            Log.v(Constants.TAG, \"Location :\" + header.getValue());\n        }\n\n        String newUri;\n        try {\n            newUri = new URI(mInfo.mUri).resolve(new URI(header.getValue())).toString();\n        } catch (URISyntaxException ex) {\n            if (Constants.LOGV) {\n                Log.d(Constants.TAG, \"Couldn't resolve redirect URI \" + header.getValue()\n                        + \" for \" + mInfo.mUri);\n            }\n            throw new StopRequest(DownloaderService.STATUS_HTTP_DATA_ERROR,\n                    \"Couldn't resolve redirect URI\");\n        }\n        ++state.mRedirectCount;\n        state.mRequestUri = newUri;\n        if (statusCode == 301 || statusCode == 303) {\n            // use the new URI for all future requests (should a retry/resume be\n            // necessary)\n            state.mNewUri = newUri;\n        }\n        throw new RetryDownload();\n    }\n\n    /**\n     * Add headers for this download to the HTTP request to allow for resume.\n     */\n    private void addRequestHeaders(InnerState innerState, HttpGet request) {\n        if (innerState.mContinuingDownload) {\n            if (innerState.mHeaderETag != null) {\n                request.addHeader(\"If-Match\", innerState.mHeaderETag);\n            }\n            request.addHeader(\"Range\", \"bytes=\" + innerState.mBytesSoFar + \"-\");\n        }\n    }\n\n    /**\n     * Handle a 503 Service Unavailable status by processing the Retry-After\n     * header.\n     */\n    private void handleServiceUnavailable(State state, HttpResponse response) throws StopRequest {\n        if (Constants.LOGVV) {\n            Log.v(Constants.TAG, \"got HTTP response code 503\");\n        }\n        state.mCountRetry = true;\n        Header header = response.getFirstHeader(\"Retry-After\");\n        if (header != null) {\n            try {\n                if (Constants.LOGVV) {\n                    Log.v(Constants.TAG, \"Retry-After :\" + header.getValue());\n                }\n                state.mRetryAfter = Integer.parseInt(header.getValue());\n                if (state.mRetryAfter < 0) {\n                    state.mRetryAfter = 0;\n                } else {\n                    if (state.mRetryAfter < Constants.MIN_RETRY_AFTER) {\n                        state.mRetryAfter = Constants.MIN_RETRY_AFTER;\n                    } else if (state.mRetryAfter > Constants.MAX_RETRY_AFTER) {\n                        state.mRetryAfter = Constants.MAX_RETRY_AFTER;\n                    }\n                    state.mRetryAfter += Helpers.sRandom.nextInt(Constants.MIN_RETRY_AFTER + 1);\n                    state.mRetryAfter *= 1000;\n                }\n            } catch (NumberFormatException ex) {\n                // ignored - retryAfter stays 0 in this case.\n            }\n        }\n        throw new StopRequest(DownloaderService.STATUS_WAITING_TO_RETRY,\n                \"got 503 Service Unavailable, will retry later\");\n    }\n\n    /**\n     * Send the request to the server, handling any I/O exceptions.\n     */\n    private HttpResponse sendRequest(State state, AndroidHttpClient client, HttpGet request)\n            throws StopRequest {\n        try {\n            return client.execute(request);\n        } catch (IllegalArgumentException ex) {\n            throw new StopRequest(DownloaderService.STATUS_HTTP_DATA_ERROR,\n                    \"while trying to execute request: \" + ex.toString(), ex);\n        } catch (IOException ex) {\n            logNetworkState();\n            throw new StopRequest(getFinalStatusForHttpError(state),\n                    \"while trying to execute request: \" + ex.toString(), ex);\n        }\n    }\n\n    private int getFinalStatusForHttpError(State state) {\n        if (mService.getNetworkAvailabilityState(mDB) != DownloaderService.NETWORK_OK) {\n            return DownloaderService.STATUS_WAITING_FOR_NETWORK;\n        } else if (mInfo.mNumFailed < Constants.MAX_RETRIES) {\n            state.mCountRetry = true;\n            return DownloaderService.STATUS_WAITING_TO_RETRY;\n        } else {\n            Log.w(Constants.TAG, \"reached max retries for \" + mInfo.mNumFailed);\n            return DownloaderService.STATUS_HTTP_DATA_ERROR;\n        }\n    }\n\n    /**\n     * Prepare the destination file to receive data. If the file already exists,\n     * we'll set up appropriately for resumption.\n     */\n    private void setupDestinationFile(State state, InnerState innerState)\n            throws StopRequest {\n        if (state.mFilename != null) { // only true if we've already run a\n                                       // thread for this download\n            if (!Helpers.isFilenameValid(state.mFilename)) {\n                // this should never happen\n                throw new StopRequest(DownloaderService.STATUS_FILE_ERROR,\n                        \"found invalid internal destination filename\");\n            }\n            // We're resuming a download that got interrupted\n            File f = new File(state.mFilename);\n            if (f.exists()) {\n                long fileLength = f.length();\n                if (fileLength == 0) {\n                    // The download hadn't actually started, we can restart from\n                    // scratch\n                    f.delete();\n                    state.mFilename = null;\n                } else if (mInfo.mETag == null) {\n                    // This should've been caught upon failure\n                    f.delete();\n                    throw new StopRequest(DownloaderService.STATUS_CANNOT_RESUME,\n                            \"Trying to resume a download that can't be resumed\");\n                } else {\n                    // All right, we'll be able to resume this download\n                    try {\n                        state.mStream = new FileOutputStream(state.mFilename, true);\n                    } catch (FileNotFoundException exc) {\n                        throw new StopRequest(DownloaderService.STATUS_FILE_ERROR,\n                                \"while opening destination for resuming: \" + exc.toString(), exc);\n                    }\n                    innerState.mBytesSoFar = (int) fileLength;\n                    if (mInfo.mTotalBytes != -1) {\n                        innerState.mHeaderContentLength = Long.toString(mInfo.mTotalBytes);\n                    }\n                    innerState.mHeaderETag = mInfo.mETag;\n                    innerState.mContinuingDownload = true;\n                }\n            }\n        }\n\n        if (state.mStream != null) {\n            closeDestination(state);\n        }\n    }\n\n    /**\n     * Stores information about the completed download, and notifies the\n     * initiating application.\n     */\n    private void notifyDownloadCompleted(\n            int status, boolean countRetry, int retryAfter, int redirectCount, boolean gotData,\n            String filename) {\n        updateDownloadDatabase(\n                status, countRetry, retryAfter, redirectCount, gotData, filename);\n        if (DownloaderService.isStatusCompleted(status)) {\n            // TBD: send status update?\n        }\n    }\n\n    private void updateDownloadDatabase(\n            int status, boolean countRetry, int retryAfter, int redirectCount, boolean gotData,\n            String filename) {\n        mInfo.mStatus = status;\n        mInfo.mRetryAfter = retryAfter;\n        mInfo.mRedirectCount = redirectCount;\n        mInfo.mLastMod = System.currentTimeMillis();\n        if (!countRetry) {\n            mInfo.mNumFailed = 0;\n        } else if (gotData) {\n            mInfo.mNumFailed = 1;\n        } else {\n            mInfo.mNumFailed++;\n        }\n        mDB.updateDownload(mInfo);\n    }\n\n}\n"
  },
  {
    "path": "Projects/Android/playapkexpansion/src/main/java/com/google/android/vending/expansion/downloader/impl/DownloaderService.java",
    "content": "/*\n * Copyright (C) 2012 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.google.android.vending.expansion.downloader.impl;\n\nimport com.google.android.vending.expansion.downloader.Constants;\nimport com.google.android.vending.expansion.downloader.DownloadProgressInfo;\nimport com.google.android.vending.expansion.downloader.DownloaderServiceMarshaller;\nimport com.google.android.vending.expansion.downloader.Helpers;\nimport com.google.android.vending.expansion.downloader.IDownloaderClient;\nimport com.google.android.vending.expansion.downloader.IDownloaderService;\nimport com.google.android.vending.expansion.downloader.IStub;\nimport com.google.android.vending.licensing.AESObfuscator;\nimport com.google.android.vending.licensing.APKExpansionPolicy;\nimport com.google.android.vending.licensing.LicenseChecker;\nimport com.google.android.vending.licensing.LicenseCheckerCallback;\nimport com.google.android.vending.licensing.Policy;\n\nimport android.app.AlarmManager;\nimport android.app.PendingIntent;\nimport android.app.Service;\nimport android.content.BroadcastReceiver;\nimport android.content.Context;\nimport android.content.Intent;\nimport android.content.IntentFilter;\nimport android.content.pm.ApplicationInfo;\nimport android.content.pm.PackageInfo;\nimport android.content.pm.PackageManager.NameNotFoundException;\nimport android.net.ConnectivityManager;\nimport android.net.NetworkInfo;\nimport android.net.wifi.WifiManager;\nimport android.os.Handler;\nimport android.os.IBinder;\nimport android.os.Messenger;\nimport android.os.SystemClock;\nimport android.provider.Settings.Secure;\nimport android.telephony.TelephonyManager;\nimport android.util.Log;\n\nimport java.io.File;\n\n/**\n * Performs the background downloads requested by applications that use the\n * Downloads provider. This service does not run as a foreground task, so\n * Android may kill it off at will, but it will try to restart itself if it can.\n * Note that Android by default will kill off any process that has an open file\n * handle on the shared (SD Card) partition if the partition is unmounted.\n */\npublic abstract class DownloaderService extends CustomIntentService implements IDownloaderService {\n\n    public DownloaderService() {\n        super(\"LVLDownloadService\");\n    }\n\n    private static final String LOG_TAG = \"LVLDL\";\n\n    // the following NETWORK_* constants are used to indicates specific reasons\n    // for disallowing a\n    // download from using a network, since specific causes can require special\n    // handling\n\n    /**\n     * The network is usable for the given download.\n     */\n    public static final int NETWORK_OK = 1;\n\n    /**\n     * There is no network connectivity.\n     */\n    public static final int NETWORK_NO_CONNECTION = 2;\n\n    /**\n     * The download exceeds the maximum size for this network.\n     */\n    public static final int NETWORK_UNUSABLE_DUE_TO_SIZE = 3;\n\n    /**\n     * The download exceeds the recommended maximum size for this network, the\n     * user must confirm for this download to proceed without WiFi.\n     */\n    public static final int NETWORK_RECOMMENDED_UNUSABLE_DUE_TO_SIZE = 4;\n\n    /**\n     * The current connection is roaming, and the download can't proceed over a\n     * roaming connection.\n     */\n    public static final int NETWORK_CANNOT_USE_ROAMING = 5;\n\n    /**\n     * The app requesting the download specific that it can't use the current\n     * network connection.\n     */\n    public static final int NETWORK_TYPE_DISALLOWED_BY_REQUESTOR = 6;\n\n    /**\n     * For intents used to notify the user that a download exceeds a size\n     * threshold, if this extra is true, WiFi is required for this download\n     * size; otherwise, it is only recommended.\n     */\n    public static final String EXTRA_IS_WIFI_REQUIRED = \"isWifiRequired\";\n    public static final String EXTRA_FILE_NAME = \"downloadId\";\n\n    /**\n     * Used with DOWNLOAD_STATUS\n     */\n    public static final String EXTRA_STATUS_STATE = \"ESS\";\n    public static final String EXTRA_STATUS_TOTAL_SIZE = \"ETS\";\n    public static final String EXTRA_STATUS_CURRENT_FILE_SIZE = \"CFS\";\n    public static final String EXTRA_STATUS_TOTAL_PROGRESS = \"TFP\";\n    public static final String EXTRA_STATUS_CURRENT_PROGRESS = \"CFP\";\n\n    public static final String ACTION_DOWNLOADS_CHANGED = \"downloadsChanged\";\n\n    /**\n     * Broadcast intent action sent by the download manager when a download\n     * completes.\n     */\n    public final static String ACTION_DOWNLOAD_COMPLETE = \"lvldownloader.intent.action.DOWNLOAD_COMPLETE\";\n\n    /**\n     * Broadcast intent action sent by the download manager when download status\n     * changes.\n     */\n    public final static String ACTION_DOWNLOAD_STATUS = \"lvldownloader.intent.action.DOWNLOAD_STATUS\";\n\n    /*\n     * Lists the states that the download manager can set on a download to\n     * notify applications of the download progress. The codes follow the HTTP\n     * families:<br> 1xx: informational<br> 2xx: success<br> 3xx: redirects (not\n     * used by the download manager)<br> 4xx: client errors<br> 5xx: server\n     * errors\n     */\n\n    /**\n     * Returns whether the status is informational (i.e. 1xx).\n     */\n    public static boolean isStatusInformational(int status) {\n        return (status >= 100 && status < 200);\n    }\n\n    /**\n     * Returns whether the status is a success (i.e. 2xx).\n     */\n    public static boolean isStatusSuccess(int status) {\n        return (status >= 200 && status < 300);\n    }\n\n    /**\n     * Returns whether the status is an error (i.e. 4xx or 5xx).\n     */\n    public static boolean isStatusError(int status) {\n        return (status >= 400 && status < 600);\n    }\n\n    /**\n     * Returns whether the status is a client error (i.e. 4xx).\n     */\n    public static boolean isStatusClientError(int status) {\n        return (status >= 400 && status < 500);\n    }\n\n    /**\n     * Returns whether the status is a server error (i.e. 5xx).\n     */\n    public static boolean isStatusServerError(int status) {\n        return (status >= 500 && status < 600);\n    }\n\n    /**\n     * Returns whether the download has completed (either with success or\n     * error).\n     */\n    public static boolean isStatusCompleted(int status) {\n        return (status >= 200 && status < 300)\n                || (status >= 400 && status < 600);\n    }\n\n    /**\n     * This download hasn't stated yet\n     */\n    public static final int STATUS_PENDING = 190;\n\n    /**\n     * This download has started\n     */\n    public static final int STATUS_RUNNING = 192;\n\n    /**\n     * This download has been paused by the owning app.\n     */\n    public static final int STATUS_PAUSED_BY_APP = 193;\n\n    /**\n     * This download encountered some network error and is waiting before\n     * retrying the request.\n     */\n    public static final int STATUS_WAITING_TO_RETRY = 194;\n\n    /**\n     * This download is waiting for network connectivity to proceed.\n     */\n    public static final int STATUS_WAITING_FOR_NETWORK = 195;\n\n    /**\n     * This download is waiting for a Wi-Fi connection to proceed or for\n     * permission to download over cellular.\n     */\n    public static final int STATUS_QUEUED_FOR_WIFI_OR_CELLULAR_PERMISSION = 196;\n\n    /**\n     * This download is waiting for a Wi-Fi connection to proceed.\n     */\n    public static final int STATUS_QUEUED_FOR_WIFI = 197;\n\n    /**\n     * This download has successfully completed. Warning: there might be other\n     * status values that indicate success in the future. Use isSucccess() to\n     * capture the entire category.\n     * \n     * @hide\n     */\n    public static final int STATUS_SUCCESS = 200;\n\n    /**\n     * The requested URL is no longer available\n     */\n    public static final int STATUS_FORBIDDEN = 403;\n\n    /**\n     * The file was delivered incorrectly\n     */\n    public static final int STATUS_FILE_DELIVERED_INCORRECTLY = 487;\n\n    /**\n     * The requested destination file already exists.\n     */\n    public static final int STATUS_FILE_ALREADY_EXISTS_ERROR = 488;\n\n    /**\n     * Some possibly transient error occurred, but we can't resume the download.\n     */\n    public static final int STATUS_CANNOT_RESUME = 489;\n\n    /**\n     * This download was canceled\n     * \n     * @hide\n     */\n    public static final int STATUS_CANCELED = 490;\n\n    /**\n     * This download has completed with an error. Warning: there will be other\n     * status values that indicate errors in the future. Use isStatusError() to\n     * capture the entire category.\n     */\n    public static final int STATUS_UNKNOWN_ERROR = 491;\n\n    /**\n     * This download couldn't be completed because of a storage issue.\n     * Typically, that's because the filesystem is missing or full. Use the more\n     * specific {@link #STATUS_INSUFFICIENT_SPACE_ERROR} and\n     * {@link #STATUS_DEVICE_NOT_FOUND_ERROR} when appropriate.\n     * \n     * @hide\n     */\n    public static final int STATUS_FILE_ERROR = 492;\n\n    /**\n     * This download couldn't be completed because of an HTTP redirect response\n     * that the download manager couldn't handle.\n     * \n     * @hide\n     */\n    public static final int STATUS_UNHANDLED_REDIRECT = 493;\n\n    /**\n     * This download couldn't be completed because of an unspecified unhandled\n     * HTTP code.\n     * \n     * @hide\n     */\n    public static final int STATUS_UNHANDLED_HTTP_CODE = 494;\n\n    /**\n     * This download couldn't be completed because of an error receiving or\n     * processing data at the HTTP level.\n     * \n     * @hide\n     */\n    public static final int STATUS_HTTP_DATA_ERROR = 495;\n\n    /**\n     * This download couldn't be completed because of an HttpException while\n     * setting up the request.\n     * \n     * @hide\n     */\n    public static final int STATUS_HTTP_EXCEPTION = 496;\n\n    /**\n     * This download couldn't be completed because there were too many\n     * redirects.\n     * \n     * @hide\n     */\n    public static final int STATUS_TOO_MANY_REDIRECTS = 497;\n\n    /**\n     * This download couldn't be completed due to insufficient storage space.\n     * Typically, this is because the SD card is full.\n     * \n     * @hide\n     */\n    public static final int STATUS_INSUFFICIENT_SPACE_ERROR = 498;\n\n    /**\n     * This download couldn't be completed because no external storage device\n     * was found. Typically, this is because the SD card is not mounted.\n     * \n     * @hide\n     */\n    public static final int STATUS_DEVICE_NOT_FOUND_ERROR = 499;\n\n    /**\n     * This download is allowed to run.\n     * \n     * @hide\n     */\n    public static final int CONTROL_RUN = 0;\n\n    /**\n     * This download must pause at the first opportunity.\n     * \n     * @hide\n     */\n    public static final int CONTROL_PAUSED = 1;\n\n    /**\n     * This download is visible but only shows in the notifications while it's\n     * in progress.\n     * \n     * @hide\n     */\n    public static final int VISIBILITY_VISIBLE = 0;\n\n    /**\n     * This download is visible and shows in the notifications while in progress\n     * and after completion.\n     * \n     * @hide\n     */\n    public static final int VISIBILITY_VISIBLE_NOTIFY_COMPLETED = 1;\n\n    /**\n     * This download doesn't show in the UI or in the notifications.\n     * \n     * @hide\n     */\n    public static final int VISIBILITY_HIDDEN = 2;\n\n    /**\n     * Bit flag for {@link #setAllowedNetworkTypes} corresponding to\n     * {@link ConnectivityManager#TYPE_MOBILE}.\n     */\n    public static final int NETWORK_MOBILE = 1 << 0;\n\n    /**\n     * Bit flag for {@link #setAllowedNetworkTypes} corresponding to\n     * {@link ConnectivityManager#TYPE_WIFI}.\n     */\n    public static final int NETWORK_WIFI = 1 << 1;\n\n    private final static String TEMP_EXT = \".tmp\";\n\n    /**\n     * Service thread status\n     */\n    private static boolean sIsRunning;\n\n    @Override\n    public IBinder onBind(Intent paramIntent) {\n        Log.d(Constants.TAG, \"Service Bound\");\n        return this.mServiceMessenger.getBinder();\n    }\n\n    /**\n     * Network state.\n     */\n    private boolean mIsConnected;\n    private boolean mIsFailover;\n    private boolean mIsCellularConnection;\n    private boolean mIsRoaming;\n    private boolean mIsAtLeast3G;\n    private boolean mIsAtLeast4G;\n    private boolean mStateChanged;\n\n    /**\n     * Download state\n     */\n    private int mControl;\n    private int mStatus;\n\n    public boolean isWiFi() {\n        return mIsConnected && !mIsCellularConnection;\n    }\n\n    /**\n     * Bindings to important services\n     */\n    private ConnectivityManager mConnectivityManager;\n    private WifiManager mWifiManager;\n\n    /**\n     * Package we are downloading for (defaults to package of application)\n     */\n    private PackageInfo mPackageInfo;\n\n    /**\n     * Byte counts\n     */\n    long mBytesSoFar;\n    long mTotalLength;\n    int mFileCount;\n\n    /**\n     * Used for calculating time remaining and speed\n     */\n    long mBytesAtSample;\n    long mMillisecondsAtSample;\n    float mAverageDownloadSpeed;\n\n    /**\n     * Our binding to the network state broadcasts\n     */\n    private BroadcastReceiver mConnReceiver;\n    final private IStub mServiceStub = DownloaderServiceMarshaller.CreateStub(this);\n    final private Messenger mServiceMessenger = mServiceStub.getMessenger();\n    private Messenger mClientMessenger;\n    private DownloadNotification mNotification;\n    private PendingIntent mPendingIntent;\n    private PendingIntent mAlarmIntent;\n\n    /**\n     * Updates the network type based upon the type and subtype returned from\n     * the connectivity manager. Subtype is only used for cellular signals.\n     * \n     * @param type\n     * @param subType\n     */\n    private void updateNetworkType(int type, int subType) {\n        switch (type) {\n            case ConnectivityManager.TYPE_WIFI:\n            case ConnectivityManager.TYPE_ETHERNET:\n            case ConnectivityManager.TYPE_BLUETOOTH:\n                mIsCellularConnection = false;\n                mIsAtLeast3G = false;\n                mIsAtLeast4G = false;\n                break;\n            case ConnectivityManager.TYPE_WIMAX:\n                mIsCellularConnection = true;\n                mIsAtLeast3G = true;\n                mIsAtLeast4G = true;\n                break;\n            case ConnectivityManager.TYPE_MOBILE:\n                mIsCellularConnection = true;\n                switch (subType) {\n                    case TelephonyManager.NETWORK_TYPE_1xRTT:\n                    case TelephonyManager.NETWORK_TYPE_CDMA:\n                    case TelephonyManager.NETWORK_TYPE_EDGE:\n                    case TelephonyManager.NETWORK_TYPE_GPRS:\n                    case TelephonyManager.NETWORK_TYPE_IDEN:\n                        mIsAtLeast3G = false;\n                        mIsAtLeast4G = false;\n                        break;\n                    case TelephonyManager.NETWORK_TYPE_HSDPA:\n                    case TelephonyManager.NETWORK_TYPE_HSUPA:\n                    case TelephonyManager.NETWORK_TYPE_HSPA:\n                    case TelephonyManager.NETWORK_TYPE_EVDO_0:\n                    case TelephonyManager.NETWORK_TYPE_EVDO_A:\n                    case TelephonyManager.NETWORK_TYPE_UMTS:\n                        mIsAtLeast3G = true;\n                        mIsAtLeast4G = false;\n                        break;\n                    case TelephonyManager.NETWORK_TYPE_LTE: // 4G\n                    case TelephonyManager.NETWORK_TYPE_EHRPD: // 3G ++ interop\n                                                              // with 4G\n                    case TelephonyManager.NETWORK_TYPE_HSPAP: // 3G ++ but\n                                                              // marketed as\n                                                              // 4G\n                        mIsAtLeast3G = true;\n                        mIsAtLeast4G = true;\n                        break;\n                    default:\n                        mIsCellularConnection = false;\n                        mIsAtLeast3G = false;\n                        mIsAtLeast4G = false;\n                }\n        }\n    }\n\n    private void updateNetworkState(NetworkInfo info) {\n        boolean isConnected = mIsConnected;\n        boolean isFailover = mIsFailover;\n        boolean isCellularConnection = mIsCellularConnection;\n        boolean isRoaming = mIsRoaming;\n        boolean isAtLeast3G = mIsAtLeast3G;\n        if (null != info) {\n            mIsRoaming = info.isRoaming();\n            mIsFailover = info.isFailover();\n            mIsConnected = info.isConnected();\n            updateNetworkType(info.getType(), info.getSubtype());\n        } else {\n            mIsRoaming = false;\n            mIsFailover = false;\n            mIsConnected = false;\n            updateNetworkType(-1, -1);\n        }\n        mStateChanged = (mStateChanged || isConnected != mIsConnected\n                || isFailover != mIsFailover\n                || isCellularConnection != mIsCellularConnection\n                || isRoaming != mIsRoaming || isAtLeast3G != mIsAtLeast3G);\n        if (Constants.LOGVV) {\n            if (mStateChanged) {\n                Log.v(LOG_TAG, \"Network state changed: \");\n                Log.v(LOG_TAG, \"Starting State: \" +\n                        (isConnected ? \"Connected \" : \"Not Connected \") +\n                        (isCellularConnection ? \"Cellular \" : \"WiFi \") +\n                        (isRoaming ? \"Roaming \" : \"Local \") +\n                        (isAtLeast3G ? \"3G+ \" : \"<3G \"));\n                Log.v(LOG_TAG, \"Ending State: \" +\n                        (mIsConnected ? \"Connected \" : \"Not Connected \") +\n                        (mIsCellularConnection ? \"Cellular \" : \"WiFi \") +\n                        (mIsRoaming ? \"Roaming \" : \"Local \") +\n                        (mIsAtLeast3G ? \"3G+ \" : \"<3G \"));\n\n                if (isServiceRunning()) {\n                    if (mIsRoaming) {\n                        mStatus = STATUS_WAITING_FOR_NETWORK;\n                        mControl = CONTROL_PAUSED;\n                    } else if (mIsCellularConnection) {\n                        DownloadsDB db = DownloadsDB.getDB(this);\n                        int flags = db.getFlags();\n                        if (0 == (flags & FLAGS_DOWNLOAD_OVER_CELLULAR)) {\n                            mStatus = STATUS_QUEUED_FOR_WIFI;\n                            mControl = CONTROL_PAUSED;\n                        }\n                    }\n                }\n\n            }\n        }\n    }\n\n    /**\n     * Polls the network state, setting the flags appropriately.\n     */\n    void pollNetworkState() {\n        if (null == mConnectivityManager) {\n            mConnectivityManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);\n        }\n        if (null == mWifiManager) {\n            mWifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);\n        }\n        if (mConnectivityManager == null) {\n            Log.w(Constants.TAG,\n                    \"couldn't get connectivity manager to poll network state\");\n        } else {\n            NetworkInfo activeInfo = mConnectivityManager\n                    .getActiveNetworkInfo();\n            updateNetworkState(activeInfo);\n        }\n    }\n\n    public static final int NO_DOWNLOAD_REQUIRED = 0;\n    public static final int LVL_CHECK_REQUIRED = 1;\n    public static final int DOWNLOAD_REQUIRED = 2;\n\n    public static final String EXTRA_PACKAGE_NAME = \"EPN\";\n    public static final String EXTRA_PENDING_INTENT = \"EPI\";\n    public static final String EXTRA_MESSAGE_HANDLER = \"EMH\";\n\n    /**\n     * Returns true if the LVL check is required\n     * \n     * @param db a downloads DB synchronized with the latest state\n     * @param pi the package info for the project\n     * @return returns true if the filenames need to be returned\n     */\n    private static boolean isLVLCheckRequired(DownloadsDB db, PackageInfo pi) {\n        // we need to update the LVL check and get a successful status to\n        // proceed\n        if (db.mVersionCode != pi.versionCode) {\n            return true;\n        }\n        return false;\n    }\n\n    /**\n     * Careful! Only use this internally.\n     * \n     * @return whether we think the service is running\n     */\n    private static synchronized boolean isServiceRunning() {\n        return sIsRunning;\n    }\n\n    private static synchronized void setServiceRunning(boolean isRunning) {\n        sIsRunning = isRunning;\n    }\n\n    public static int startDownloadServiceIfRequired(Context context,\n            Intent intent, Class<?> serviceClass) throws NameNotFoundException {\n        final PendingIntent pendingIntent = (PendingIntent) intent\n                .getParcelableExtra(EXTRA_PENDING_INTENT);\n        return startDownloadServiceIfRequired(context, pendingIntent,\n                serviceClass);\n    }\n\n    public static int startDownloadServiceIfRequired(Context context,\n            PendingIntent pendingIntent, Class<?> serviceClass)\n            throws NameNotFoundException\n    {\n        String packageName = context.getPackageName();\n        String className = serviceClass.getName();\n\n        return startDownloadServiceIfRequired(context, pendingIntent,\n                packageName, className);\n    }\n\n    /**\n     * Starts the download if necessary. This function starts a flow that does `\n     * many things. 1) Checks to see if the APK version has been checked and the\n     * metadata database updated 2) If the APK version does not match, checks\n     * the new LVL status to see if a new download is required 3) If the APK\n     * version does match, then checks to see if the download(s) have been\n     * completed 4) If the downloads have been completed, returns\n     * NO_DOWNLOAD_REQUIRED The idea is that this can be called during the\n     * startup of an application to quickly ascertain if the application needs\n     * to wait to hear about any updated APK expansion files. Note that this\n     * does mean that the application MUST be run for the first time with a\n     * network connection, even if Market delivers all of the files.\n     * \n     * @param context\n     * @param thisIntent\n     * @return true if the app should wait for more guidance from the\n     *         downloader, false if the app can continue\n     * @throws NameNotFoundException\n     */\n    public static int startDownloadServiceIfRequired(Context context,\n            PendingIntent pendingIntent, String classPackage, String className)\n            throws NameNotFoundException {\n        // first: do we need to do an LVL update?\n        // we begin by getting our APK version from the package manager\n        final PackageInfo pi = context.getPackageManager().getPackageInfo(\n                context.getPackageName(), 0);\n\n        int status = NO_DOWNLOAD_REQUIRED;\n\n        // the database automatically reads the metadata for version code\n        // and download status when the instance is created\n        DownloadsDB db = DownloadsDB.getDB(context);\n\n        // we need to update the LVL check and get a successful status to\n        // proceed\n        if (isLVLCheckRequired(db, pi)) {\n            status = LVL_CHECK_REQUIRED;\n        }\n        // we don't have to update LVL. do we still have a download to start?\n        if (db.mStatus == 0) {\n            DownloadInfo[] infos = db.getDownloads();\n            if (null != infos) {\n                for (DownloadInfo info : infos) {\n                    if (!Helpers.doesFileExist(context, info.mFileName, info.mTotalBytes, true)) {\n                        status = DOWNLOAD_REQUIRED;\n                        db.updateStatus(-1);\n                        break;\n                    }\n                }\n            }\n        } else {\n            status = DOWNLOAD_REQUIRED;\n        }\n        switch (status) {\n            case DOWNLOAD_REQUIRED:\n            case LVL_CHECK_REQUIRED:\n                Intent fileIntent = new Intent();\n                fileIntent.setClassName(classPackage, className);\n                fileIntent.putExtra(EXTRA_PENDING_INTENT, pendingIntent);\n                context.startService(fileIntent);\n                break;\n        }\n        return status;\n    }\n\n    @Override\n    public void requestAbortDownload() {\n        mControl = CONTROL_PAUSED;\n        mStatus = STATUS_CANCELED;\n    }\n\n    @Override\n    public void requestPauseDownload() {\n        mControl = CONTROL_PAUSED;\n        mStatus = STATUS_PAUSED_BY_APP;\n    }\n\n    @Override\n    public void setDownloadFlags(int flags) {\n        DownloadsDB.getDB(this).updateFlags(flags);\n    }\n\n    @Override\n    public void requestContinueDownload() {\n        if (mControl == CONTROL_PAUSED) {\n            mControl = CONTROL_RUN;\n        }\n        Intent fileIntent = new Intent(this, this.getClass());\n        fileIntent.putExtra(EXTRA_PENDING_INTENT, mPendingIntent);\n        this.startService(fileIntent);\n    }\n\n    public abstract String getPublicKey();\n\n    public abstract byte[] getSALT();\n\n    public abstract String getAlarmReceiverClassName();\n\n    private class LVLRunnable implements Runnable {\n        LVLRunnable(Context context, PendingIntent intent) {\n            mContext = context;\n            mPendingIntent = intent;\n        }\n\n        final Context mContext;\n\n        @Override\n        public void run() {\n            setServiceRunning(true);\n            mNotification.onDownloadStateChanged(IDownloaderClient.STATE_FETCHING_URL);\n            String deviceId = Secure.getString(mContext.getContentResolver(),\n                    Secure.ANDROID_ID);\n\n            final APKExpansionPolicy aep = new APKExpansionPolicy(mContext,\n                    new AESObfuscator(getSALT(), mContext.getPackageName(), deviceId));\n\n            // reset our policy back to the start of the world to force a\n            // re-check\n            aep.resetPolicy();\n\n            // let's try and get the OBB file from LVL first\n            // Construct the LicenseChecker with a Policy.\n            final LicenseChecker checker = new LicenseChecker(mContext, aep,\n                    getPublicKey() // Your public licensing key.\n            );\n            checker.checkAccess(new LicenseCheckerCallback() {\n\n                @Override\n                public void allow(int reason) {\n                    try {\n                        int count = aep.getExpansionURLCount();\n                        DownloadsDB db = DownloadsDB.getDB(mContext);\n                        int status = 0;\n                        if (count != 0) {\n                            for (int i = 0; i < count; i++) {\n                                String currentFileName = aep\n                                        .getExpansionFileName(i);\n                                if (null != currentFileName) {\n                                    DownloadInfo di = new DownloadInfo(i,\n                                            currentFileName, mContext.getPackageName());\n\n                                    long fileSize = aep.getExpansionFileSize(i);\n                                    if (handleFileUpdated(db, i, currentFileName,\n                                            fileSize)) {\n                                        status |= -1;\n                                        di.resetDownload();\n                                        di.mUri = aep.getExpansionURL(i);\n                                        di.mTotalBytes = fileSize;\n                                        di.mStatus = status;\n                                        db.updateDownload(di);\n                                    } else {\n                                        // we need to read the download\n                                        // information\n                                        // from\n                                        // the database\n                                        DownloadInfo dbdi = db\n                                                .getDownloadInfoByFileName(di.mFileName);\n                                        if (null == dbdi) {\n                                            // the file exists already and is\n                                            // the\n                                            // correct size\n                                            // was delivered by Market or\n                                            // through\n                                            // another mechanism\n                                            Log.d(LOG_TAG, \"file \" + di.mFileName\n                                                    + \" found. Not downloading.\");\n                                            di.mStatus = STATUS_SUCCESS;\n                                            di.mTotalBytes = fileSize;\n                                            di.mCurrentBytes = fileSize;\n                                            di.mUri = aep.getExpansionURL(i);\n                                            db.updateDownload(di);\n                                        } else if (dbdi.mStatus != STATUS_SUCCESS) {\n                                            // we just update the URL\n                                            dbdi.mUri = aep.getExpansionURL(i);\n                                            db.updateDownload(dbdi);\n                                            status |= -1;\n                                        }\n                                    }\n                                }\n                            }\n                        }\n                        // first: do we need to do an LVL update?\n                        // we begin by getting our APK version from the package\n                        // manager\n                        PackageInfo pi;\n                        try {\n                            pi = mContext.getPackageManager().getPackageInfo(\n                                    mContext.getPackageName(), 0);\n                            db.updateMetadata(pi.versionCode, status);\n                            Class<?> serviceClass = DownloaderService.this.getClass();\n                            switch (startDownloadServiceIfRequired(mContext, mPendingIntent,\n                                    serviceClass)) {\n                                case NO_DOWNLOAD_REQUIRED:\n                                    mNotification\n                                            .onDownloadStateChanged(IDownloaderClient.STATE_COMPLETED);\n                                    break;\n                                case LVL_CHECK_REQUIRED:\n                                    // DANGER WILL ROBINSON!\n                                    Log.e(LOG_TAG, \"In LVL checking loop!\");\n                                    mNotification\n                                            .onDownloadStateChanged(IDownloaderClient.STATE_FAILED_UNLICENSED);\n                                    throw new RuntimeException(\n                                            \"Error with LVL checking and database integrity\");\n                                case DOWNLOAD_REQUIRED:\n                                    // do nothing. the download will notify the\n                                    // application\n                                    // when things are done\n                                    break;\n                            }\n                        } catch (NameNotFoundException e1) {\n                            e1.printStackTrace();\n                            throw new RuntimeException(\n                                    \"Error with getting information from package name\");\n                        }\n                    } finally {\n                        setServiceRunning(false);\n                    }\n                }\n\n                @Override\n                public void dontAllow(int reason) {\n                    try\n                    {\n                        switch (reason) {\n                            case Policy.NOT_LICENSED:\n                                mNotification\n                                        .onDownloadStateChanged(IDownloaderClient.STATE_FAILED_UNLICENSED);\n                                break;\n                            case Policy.RETRY:\n                                mNotification\n                                        .onDownloadStateChanged(IDownloaderClient.STATE_FAILED_FETCHING_URL);\n                                break;\n                        }\n                    } finally {\n                        setServiceRunning(false);\n                    }\n\n                }\n\n                @Override\n                public void applicationError(int errorCode) {\n                    try {\n                        mNotification\n                                .onDownloadStateChanged(IDownloaderClient.STATE_FAILED_FETCHING_URL);\n                    } finally {\n                        setServiceRunning(false);\n                    }\n                }\n\n            });\n\n        }\n\n    };\n\n    /**\n     * Updates the LVL information from the server.\n     * \n     * @param context\n     */\n    public void updateLVL(final Context context) {\n        Context c = context.getApplicationContext();\n        Handler h = new Handler(c.getMainLooper());\n        h.post(new LVLRunnable(c, mPendingIntent));\n    }\n\n    /**\n     * The APK has been updated and a filename has been sent down from the\n     * Market call. If the file has the same name as the previous file, we do\n     * nothing as the file is guaranteed to be the same. If the file does not\n     * have the same name, we download it if it hasn't already been delivered by\n     * Market.\n     * \n     * @param index the index of the file from market (0 = main, 1 = patch)\n     * @param filename the name of the new file\n     * @param fileSize the size of the new file\n     * @return\n     */\n    public boolean handleFileUpdated(DownloadsDB db, int index,\n            String filename, long fileSize) {\n        DownloadInfo di = db.getDownloadInfoByFileName(filename);\n        if (null != di) {\n            String oldFile = di.mFileName;\n            // cleanup\n            if (null != oldFile) {\n                if (filename.equals(oldFile)) {\n                    return false;\n                }\n\n                // remove partially downloaded file if it is there\n                String deleteFile = Helpers.generateSaveFileName(this, oldFile);\n                File f = new File(deleteFile);\n                if (f.exists())\n                    f.delete();\n            }\n        }\n        return !Helpers.doesFileExist(this, filename, fileSize, true);\n    }\n\n    private void scheduleAlarm(long wakeUp) {\n        AlarmManager alarms = (AlarmManager) getSystemService(Context.ALARM_SERVICE);\n        if (alarms == null) {\n            Log.e(Constants.TAG, \"couldn't get alarm manager\");\n            return;\n        }\n\n        if (Constants.LOGV) {\n            Log.v(Constants.TAG, \"scheduling retry in \" + wakeUp + \"ms\");\n        }\n\n        String className = getAlarmReceiverClassName();\n        Intent intent = new Intent(Constants.ACTION_RETRY);\n        intent.putExtra(EXTRA_PENDING_INTENT, mPendingIntent);\n        intent.setClassName(this.getPackageName(),\n                className);\n        mAlarmIntent = PendingIntent.getBroadcast(this, 0, intent,\n                PendingIntent.FLAG_ONE_SHOT);\n        alarms.set(\n                AlarmManager.RTC_WAKEUP,\n                System.currentTimeMillis() + wakeUp, mAlarmIntent\n                );\n    }\n\n    private void cancelAlarms() {\n        if (null != mAlarmIntent) {\n            AlarmManager alarms = (AlarmManager) getSystemService(Context.ALARM_SERVICE);\n            if (alarms == null) {\n                Log.e(Constants.TAG, \"couldn't get alarm manager\");\n                return;\n            }\n            alarms.cancel(mAlarmIntent);\n            mAlarmIntent = null;\n        }\n    }\n\n    /**\n     * We use this to track network state, such as when WiFi, Cellular, etc. is\n     * enabled when downloads are paused or in progress.\n     */\n    private class InnerBroadcastReceiver extends BroadcastReceiver {\n        final Service mService;\n\n        InnerBroadcastReceiver(Service service) {\n            mService = service;\n        }\n\n        @Override\n        public void onReceive(Context context, Intent intent) {\n            pollNetworkState();\n            if (mStateChanged\n                    && !isServiceRunning()) {\n                Log.d(Constants.TAG, \"InnerBroadcastReceiver Called\");\n                Intent fileIntent = new Intent(context, mService.getClass());\n                fileIntent.putExtra(EXTRA_PENDING_INTENT, mPendingIntent);\n                // send a new intent to the service\n                context.startService(fileIntent);\n            }\n        }\n    };\n\n    /**\n     * This is the main thread for the Downloader. This thread is responsible\n     * for queuing up downloads and other goodness.\n     */\n    @Override\n    protected void onHandleIntent(Intent intent) {\n        setServiceRunning(true);\n        try {\n            // the database automatically reads the metadata for version code\n            // and download status when the instance is created\n            DownloadsDB db = DownloadsDB.getDB(this);\n            final PendingIntent pendingIntent = (PendingIntent) intent\n                    .getParcelableExtra(EXTRA_PENDING_INTENT);\n\n            if (null != pendingIntent)\n            {\n                mNotification.setClientIntent(pendingIntent);\n                mPendingIntent = pendingIntent;\n            } else if (null != mPendingIntent) {\n                mNotification.setClientIntent(mPendingIntent);\n            } else {\n                Log.e(LOG_TAG, \"Downloader started in bad state without notification intent.\");\n                return;\n            }\n\n            // when the LVL check completes, a successful response will update\n            // the service\n            if (isLVLCheckRequired(db, mPackageInfo)) {\n                updateLVL(this);\n                return;\n            }\n\n            // get each download\n            DownloadInfo[] infos = db.getDownloads();\n            mBytesSoFar = 0;\n            mTotalLength = 0;\n            mFileCount = infos.length;\n            for (DownloadInfo info : infos) {\n                // We do an (simple) integrity check on each file, just to make\n                // sure\n                if (info.mStatus == STATUS_SUCCESS) {\n                    // verify that the file matches the state\n                    if (!Helpers.doesFileExist(this, info.mFileName, info.mTotalBytes, true)) {\n                        info.mStatus = 0;\n                        info.mCurrentBytes = 0;\n                    }\n                }\n                // get aggregate data\n                mTotalLength += info.mTotalBytes;\n                mBytesSoFar += info.mCurrentBytes;\n            }\n\n            // loop through all downloads and fetch them\n            pollNetworkState();\n            if (null == mConnReceiver) {\n\n                /**\n                 * We use this to track network state, such as when WiFi,\n                 * Cellular, etc. is enabled when downloads are paused or in\n                 * progress.\n                 */\n                mConnReceiver = new InnerBroadcastReceiver(this);\n                IntentFilter intentFilter = new IntentFilter(\n                        ConnectivityManager.CONNECTIVITY_ACTION);\n                intentFilter.addAction(WifiManager.WIFI_STATE_CHANGED_ACTION);\n                registerReceiver(mConnReceiver, intentFilter);\n            }\n\n            for (DownloadInfo info : infos) {\n                long startingCount = info.mCurrentBytes;\n\n                if (info.mStatus != STATUS_SUCCESS) {\n                    DownloadThread dt = new DownloadThread(info, this, mNotification);\n                    cancelAlarms();\n                    scheduleAlarm(Constants.ACTIVE_THREAD_WATCHDOG);\n                    dt.run();\n                    cancelAlarms();\n                }\n                db.updateFromDb(info);\n                boolean setWakeWatchdog = false;\n                int notifyStatus;\n                switch (info.mStatus) {\n                    case STATUS_FORBIDDEN:\n                        // the URL is out of date\n                        updateLVL(this);\n                        return;\n                    case STATUS_SUCCESS:\n                        mBytesSoFar += info.mCurrentBytes - startingCount;\n                        db.updateMetadata(mPackageInfo.versionCode, 0);\n                        continue;\n                    case STATUS_FILE_DELIVERED_INCORRECTLY:\n                        // we may be on a network that is returning us a web\n                        // page on redirect\n                        notifyStatus = IDownloaderClient.STATE_PAUSED_NETWORK_SETUP_FAILURE;\n                        info.mCurrentBytes = 0;\n                        db.updateDownload(info);\n                        setWakeWatchdog = true;\n                        break;\n                    case STATUS_PAUSED_BY_APP:\n                        notifyStatus = IDownloaderClient.STATE_PAUSED_BY_REQUEST;\n                        break;\n                    case STATUS_WAITING_FOR_NETWORK:\n                    case STATUS_WAITING_TO_RETRY:\n                        notifyStatus = IDownloaderClient.STATE_PAUSED_NETWORK_UNAVAILABLE;\n                        setWakeWatchdog = true;\n                        break;\n                    case STATUS_QUEUED_FOR_WIFI_OR_CELLULAR_PERMISSION:\n                    case STATUS_QUEUED_FOR_WIFI:\n                        // look for more detail here\n                        if (null != mWifiManager) {\n                            if (!mWifiManager.isWifiEnabled()) {\n                                notifyStatus = IDownloaderClient.STATE_PAUSED_WIFI_DISABLED_NEED_CELLULAR_PERMISSION;\n                                setWakeWatchdog = true;\n                                break;\n                            }\n                        }\n                        notifyStatus = IDownloaderClient.STATE_PAUSED_NEED_CELLULAR_PERMISSION;\n                        setWakeWatchdog = true;\n                        break;\n                    case STATUS_CANCELED:\n                        notifyStatus = IDownloaderClient.STATE_FAILED_CANCELED;\n                        setWakeWatchdog = true;\n                        break;\n\n                    case STATUS_INSUFFICIENT_SPACE_ERROR:\n                        notifyStatus = IDownloaderClient.STATE_FAILED_SDCARD_FULL;\n                        setWakeWatchdog = true;\n                        break;\n\n                    case STATUS_DEVICE_NOT_FOUND_ERROR:\n                        notifyStatus = IDownloaderClient.STATE_PAUSED_SDCARD_UNAVAILABLE;\n                        setWakeWatchdog = true;\n                        break;\n\n                    default:\n                        notifyStatus = IDownloaderClient.STATE_FAILED;\n                        break;\n                }\n                if (setWakeWatchdog) {\n                    scheduleAlarm(Constants.WATCHDOG_WAKE_TIMER);\n                } else {\n                    cancelAlarms();\n                }\n                // failure or pause state\n                mNotification.onDownloadStateChanged(notifyStatus);\n                return;\n            }\n\n            // all downloads complete\n            mNotification.onDownloadStateChanged(IDownloaderClient.STATE_COMPLETED);\n        } finally {\n            setServiceRunning(false);\n        }\n    }\n\n    @Override\n    public void onDestroy() {\n        if (null != mConnReceiver) {\n            unregisterReceiver(mConnReceiver);\n            mConnReceiver = null;\n        }\n        mServiceStub.disconnect(this);\n        super.onDestroy();\n    }\n\n    public int getNetworkAvailabilityState(DownloadsDB db) {\n        if (mIsConnected) {\n            if (!mIsCellularConnection)\n                return NETWORK_OK;\n            int flags = db.mFlags;\n            if (mIsRoaming)\n                return NETWORK_CANNOT_USE_ROAMING;\n            if (0 != (flags & FLAGS_DOWNLOAD_OVER_CELLULAR)) {\n                return NETWORK_OK;\n            } else {\n                return NETWORK_TYPE_DISALLOWED_BY_REQUESTOR;\n            }\n        }\n        return NETWORK_NO_CONNECTION;\n    }\n\n    @Override\n    public void onCreate() {\n        super.onCreate();\n        try {\n            mPackageInfo = getPackageManager().getPackageInfo(\n                    getPackageName(), 0);\n            ApplicationInfo ai = getApplicationInfo();\n            CharSequence applicationLabel = getPackageManager().getApplicationLabel(ai);\n            mNotification = new DownloadNotification(this, applicationLabel);\n\n        } catch (NameNotFoundException e) {\n            e.printStackTrace();\n        }\n    }\n\n    /**\n     * Exception thrown from methods called by generateSaveFile() for any fatal\n     * error.\n     */\n    public static class GenerateSaveFileError extends Exception {\n        private static final long serialVersionUID = 3465966015408936540L;\n        int mStatus;\n        String mMessage;\n\n        public GenerateSaveFileError(int status, String message) {\n            mStatus = status;\n            mMessage = message;\n        }\n    }\n\n    /**\n     * Returns the filename (where the file should be saved) from info about a\n     * download\n     */\n    public String generateTempSaveFileName(String fileName) {\n        String path = Helpers.getSaveFilePath(this)\n                + File.separator + fileName + TEMP_EXT;\n        return path;\n    }\n\n    /**\n     * Creates a filename (where the file should be saved) from info about a\n     * download.\n     */\n    public String generateSaveFile(String filename, long filesize)\n            throws GenerateSaveFileError {\n        String path = generateTempSaveFileName(filename);\n        File expPath = new File(path);\n        if (!Helpers.isExternalMediaMounted()) {\n            Log.d(Constants.TAG, \"External media not mounted: \" + path);\n            throw new GenerateSaveFileError(STATUS_DEVICE_NOT_FOUND_ERROR,\n                    \"external media is not yet mounted\");\n\n        }\n        if (expPath.exists()) {\n            Log.d(Constants.TAG, \"File already exists: \" + path);\n            throw new GenerateSaveFileError(STATUS_FILE_ALREADY_EXISTS_ERROR,\n                    \"requested destination file already exists\");\n        }\n        if (Helpers.getAvailableBytes(Helpers.getFilesystemRoot(path)) < filesize) {\n            throw new GenerateSaveFileError(STATUS_INSUFFICIENT_SPACE_ERROR,\n                    \"insufficient space on external storage\");\n        }\n        return path;\n    }\n\n    /**\n     * @return a non-localized string appropriate for logging corresponding to\n     *         one of the NETWORK_* constants.\n     */\n    public String getLogMessageForNetworkError(int networkError) {\n        switch (networkError) {\n            case NETWORK_RECOMMENDED_UNUSABLE_DUE_TO_SIZE:\n                return \"download size exceeds recommended limit for mobile network\";\n\n            case NETWORK_UNUSABLE_DUE_TO_SIZE:\n                return \"download size exceeds limit for mobile network\";\n\n            case NETWORK_NO_CONNECTION:\n                return \"no network connection available\";\n\n            case NETWORK_CANNOT_USE_ROAMING:\n                return \"download cannot use the current network connection because it is roaming\";\n\n            case NETWORK_TYPE_DISALLOWED_BY_REQUESTOR:\n                return \"download was requested to not use the current network type\";\n\n            default:\n                return \"unknown error with network connectivity\";\n        }\n    }\n\n    public int getControl() {\n        return mControl;\n    }\n\n    public int getStatus() {\n        return mStatus;\n    }\n\n    /**\n     * Calculating a moving average for the speed so we don't get jumpy\n     * calculations for time etc.\n     */\n    static private final float SMOOTHING_FACTOR = 0.005f;\n\n    public void notifyUpdateBytes(long totalBytesSoFar) {\n        long timeRemaining;\n        long currentTime = SystemClock.uptimeMillis();\n        if (0 != mMillisecondsAtSample) {\n            // we have a sample.\n            long timePassed = currentTime - mMillisecondsAtSample;\n            long bytesInSample = totalBytesSoFar - mBytesAtSample;\n            float currentSpeedSample = (float) bytesInSample / (float) timePassed;\n            if (0 != mAverageDownloadSpeed) {\n                mAverageDownloadSpeed = SMOOTHING_FACTOR * currentSpeedSample\n                        + (1 - SMOOTHING_FACTOR) * mAverageDownloadSpeed;\n            } else {\n                mAverageDownloadSpeed = currentSpeedSample;\n            }\n            timeRemaining = (long) ((mTotalLength - totalBytesSoFar) / mAverageDownloadSpeed);\n        } else {\n            timeRemaining = -1;\n        }\n        mMillisecondsAtSample = currentTime;\n        mBytesAtSample = totalBytesSoFar;\n        mNotification.onDownloadProgress(\n                new DownloadProgressInfo(mTotalLength,\n                        totalBytesSoFar,\n                        timeRemaining,\n                        mAverageDownloadSpeed)\n                );\n\n    }\n\n    @Override\n    protected boolean shouldStop() {\n        // the database automatically reads the metadata for version code\n        // and download status when the instance is created\n        DownloadsDB db = DownloadsDB.getDB(this);\n        if (db.mStatus == 0) {\n            return true;\n        }\n        return false;\n    }\n\n    @Override\n    public void requestDownloadStatus() {\n        mNotification.resendState();\n    }\n\n    @Override\n    public void onClientUpdated(Messenger clientMessenger) {\n        this.mClientMessenger = clientMessenger;\n        mNotification.setMessenger(mClientMessenger);\n    }\n\n}\n"
  },
  {
    "path": "Projects/Android/playapkexpansion/src/main/java/com/google/android/vending/expansion/downloader/impl/DownloadsDB.java",
    "content": "/*\n * Copyright (C) 2012 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.google.android.vending.expansion.downloader.impl;\n\nimport android.content.ContentValues;\nimport android.content.Context;\nimport android.database.Cursor;\nimport android.database.sqlite.SQLiteDatabase;\nimport android.database.sqlite.SQLiteDoneException;\nimport android.database.sqlite.SQLiteOpenHelper;\nimport android.database.sqlite.SQLiteStatement;\nimport android.provider.BaseColumns;\nimport android.util.Log;\n\npublic class DownloadsDB {\n    private static final String DATABASE_NAME = \"DownloadsDB\";\n    private static final int DATABASE_VERSION = 7;\n    public static final String LOG_TAG = DownloadsDB.class.getName();\n    final SQLiteOpenHelper mHelper;\n    SQLiteStatement mGetDownloadByIndex;\n    SQLiteStatement mUpdateCurrentBytes;\n    private static DownloadsDB mDownloadsDB;\n    long mMetadataRowID = -1;\n    int mVersionCode = -1;\n    int mStatus = -1;\n    int mFlags;\n\n    static public synchronized DownloadsDB getDB(Context paramContext) {\n        if (null == mDownloadsDB) {\n            return new DownloadsDB(paramContext);\n        }\n        return mDownloadsDB;\n    }\n\n    private SQLiteStatement getDownloadByIndexStatement() {\n        if (null == mGetDownloadByIndex) {\n            mGetDownloadByIndex = mHelper.getReadableDatabase().compileStatement(\n                    \"SELECT \" + BaseColumns._ID + \" FROM \"\n                            + DownloadColumns.TABLE_NAME + \" WHERE \"\n                            + DownloadColumns.INDEX + \" = ?\");\n        }\n        return mGetDownloadByIndex;\n    }\n\n    private SQLiteStatement getUpdateCurrentBytesStatement() {\n        if (null == mUpdateCurrentBytes) {\n            mUpdateCurrentBytes = mHelper.getReadableDatabase().compileStatement(\n                    \"UPDATE \" + DownloadColumns.TABLE_NAME + \" SET \" + DownloadColumns.CURRENTBYTES\n                            + \" = ?\" +\n                            \" WHERE \" + DownloadColumns.INDEX + \" = ?\");\n        }\n        return mUpdateCurrentBytes;\n    }\n\n    private DownloadsDB(Context paramContext) {\n        this.mHelper = new DownloadsContentDBHelper(paramContext);\n        final SQLiteDatabase sqldb = mHelper.getReadableDatabase();\n        // Query for the version code, the row ID of the metadata (for future\n        // updating) the status and the flags\n        Cursor cur = sqldb.rawQuery(\"SELECT \" +\n                MetadataColumns.APKVERSION + \",\" +\n                BaseColumns._ID + \",\" +\n                MetadataColumns.DOWNLOAD_STATUS + \",\" +\n                MetadataColumns.FLAGS +\n                \" FROM \"\n                + MetadataColumns.TABLE_NAME + \" LIMIT 1\", null);\n        if (null != cur && cur.moveToFirst()) {\n            mVersionCode = cur.getInt(0);\n            mMetadataRowID = cur.getLong(1);\n            mStatus = cur.getInt(2);\n            mFlags = cur.getInt(3);\n            cur.close();\n        }\n        mDownloadsDB = this;\n    }\n\n    protected DownloadInfo getDownloadInfoByFileName(String fileName) {\n        final SQLiteDatabase sqldb = mHelper.getReadableDatabase();\n        Cursor itemcur = null;\n        try {\n            itemcur = sqldb.query(DownloadColumns.TABLE_NAME, DC_PROJECTION,\n                    DownloadColumns.FILENAME + \" = ?\",\n                    new String[] {\n                        fileName\n                    }, null, null, null);\n            if (null != itemcur && itemcur.moveToFirst()) {\n                return getDownloadInfoFromCursor(itemcur);\n            }\n        } finally {\n            if (null != itemcur)\n                itemcur.close();\n        }\n        return null;\n    }\n\n    public long getIDForDownloadInfo(final DownloadInfo di) {\n        return getIDByIndex(di.mIndex);\n    }\n\n    public long getIDByIndex(int index) {\n        SQLiteStatement downloadByIndex = getDownloadByIndexStatement();\n        downloadByIndex.clearBindings();\n        downloadByIndex.bindLong(1, index);\n        try {\n            return downloadByIndex.simpleQueryForLong();\n        } catch (SQLiteDoneException e) {\n            return -1;\n        }\n    }\n\n    public void updateDownloadCurrentBytes(final DownloadInfo di) {\n        SQLiteStatement downloadCurrentBytes = getUpdateCurrentBytesStatement();\n        downloadCurrentBytes.clearBindings();\n        downloadCurrentBytes.bindLong(1, di.mCurrentBytes);\n        downloadCurrentBytes.bindLong(2, di.mIndex);\n        downloadCurrentBytes.execute();\n    }\n\n    public void close() {\n        this.mHelper.close();\n    }\n\n    protected static class DownloadsContentDBHelper extends SQLiteOpenHelper {\n        DownloadsContentDBHelper(Context paramContext) {\n            super(paramContext, DATABASE_NAME, null, DATABASE_VERSION);\n        }\n\n        private String createTableQueryFromArray(String paramString,\n                String[][] paramArrayOfString) {\n            StringBuilder localStringBuilder = new StringBuilder();\n            localStringBuilder.append(\"CREATE TABLE \");\n            localStringBuilder.append(paramString);\n            localStringBuilder.append(\" (\");\n            int i = paramArrayOfString.length;\n            for (int j = 0;; j++) {\n                if (j >= i) {\n                    localStringBuilder\n                            .setLength(localStringBuilder.length() - 1);\n                    localStringBuilder.append(\");\");\n                    return localStringBuilder.toString();\n                }\n                String[] arrayOfString = paramArrayOfString[j];\n                localStringBuilder.append(' ');\n                localStringBuilder.append(arrayOfString[0]);\n                localStringBuilder.append(' ');\n                localStringBuilder.append(arrayOfString[1]);\n                localStringBuilder.append(',');\n            }\n        }\n\n        /**\n         * These two arrays must match and have the same order. For every Schema\n         * there must be a corresponding table name.\n         */\n        static final private String[][][] sSchemas = {\n                DownloadColumns.SCHEMA, MetadataColumns.SCHEMA\n        };\n\n        static final private String[] sTables = {\n                DownloadColumns.TABLE_NAME, MetadataColumns.TABLE_NAME\n        };\n\n        /**\n         * Goes through all of the tables in sTables and drops each table if it\n         * exists. Altered to no longer make use of reflection.\n         */\n        private void dropTables(SQLiteDatabase paramSQLiteDatabase) {\n            for (String table : sTables) {\n                try {\n                    paramSQLiteDatabase.execSQL(\"DROP TABLE IF EXISTS \" + table);\n                } catch (Exception localException) {\n                    localException.printStackTrace();\n                }\n            }\n        }\n\n        /**\n         * Goes through all of the tables in sTables and creates a database with\n         * the corresponding schema described in sSchemas. Altered to no longer\n         * make use of reflection.\n         */\n        public void onCreate(SQLiteDatabase paramSQLiteDatabase) {\n            int numSchemas = sSchemas.length;\n            for (int i = 0; i < numSchemas; i++) {\n                try {\n                    String[][] schema = (String[][]) sSchemas[i];\n                    paramSQLiteDatabase.execSQL(createTableQueryFromArray(\n                            sTables[i], schema));\n                } catch (Exception localException) {\n                    while (true)\n                        localException.printStackTrace();\n                }\n            }\n        }\n\n        public void onUpgrade(SQLiteDatabase paramSQLiteDatabase,\n                int paramInt1, int paramInt2) {\n            Log.w(DownloadsContentDBHelper.class.getName(),\n                    \"Upgrading database from version \" + paramInt1 + \" to \"\n                            + paramInt2 + \", which will destroy all old data\");\n            dropTables(paramSQLiteDatabase);\n            onCreate(paramSQLiteDatabase);\n        }\n    }\n\n    public static class MetadataColumns implements BaseColumns {\n        public static final String APKVERSION = \"APKVERSION\";\n        public static final String DOWNLOAD_STATUS = \"DOWNLOADSTATUS\";\n        public static final String FLAGS = \"DOWNLOADFLAGS\";\n\n        public static final String[][] SCHEMA = {\n                {\n                        BaseColumns._ID, \"INTEGER PRIMARY KEY\"\n                },\n                {\n                        APKVERSION, \"INTEGER\"\n                }, {\n                        DOWNLOAD_STATUS, \"INTEGER\"\n                },\n                {\n                        FLAGS, \"INTEGER\"\n                }\n        };\n        public static final String TABLE_NAME = \"MetadataColumns\";\n        public static final String _ID = \"MetadataColumns._id\";\n    }\n\n    public static class DownloadColumns implements BaseColumns {\n        public static final String INDEX = \"FILEIDX\";\n        public static final String URI = \"URI\";\n        public static final String FILENAME = \"FN\";\n        public static final String ETAG = \"ETAG\";\n\n        public static final String TOTALBYTES = \"TOTALBYTES\";\n        public static final String CURRENTBYTES = \"CURRENTBYTES\";\n        public static final String LASTMOD = \"LASTMOD\";\n\n        public static final String STATUS = \"STATUS\";\n        public static final String CONTROL = \"CONTROL\";\n        public static final String NUM_FAILED = \"FAILCOUNT\";\n        public static final String RETRY_AFTER = \"RETRYAFTER\";\n        public static final String REDIRECT_COUNT = \"REDIRECTCOUNT\";\n\n        public static final String[][] SCHEMA = {\n                {\n                        BaseColumns._ID, \"INTEGER PRIMARY KEY\"\n                },\n                {\n                        INDEX, \"INTEGER UNIQUE\"\n                }, {\n                        URI, \"TEXT\"\n                },\n                {\n                        FILENAME, \"TEXT UNIQUE\"\n                }, {\n                        ETAG, \"TEXT\"\n                },\n                {\n                        TOTALBYTES, \"INTEGER\"\n                }, {\n                        CURRENTBYTES, \"INTEGER\"\n                },\n                {\n                        LASTMOD, \"INTEGER\"\n                }, {\n                        STATUS, \"INTEGER\"\n                },\n                {\n                        CONTROL, \"INTEGER\"\n                }, {\n                        NUM_FAILED, \"INTEGER\"\n                },\n                {\n                        RETRY_AFTER, \"INTEGER\"\n                }, {\n                        REDIRECT_COUNT, \"INTEGER\"\n                }\n        };\n        public static final String TABLE_NAME = \"DownloadColumns\";\n        public static final String _ID = \"DownloadColumns._id\";\n    }\n\n    private static final String[] DC_PROJECTION = {\n            DownloadColumns.FILENAME,\n            DownloadColumns.URI, DownloadColumns.ETAG,\n            DownloadColumns.TOTALBYTES, DownloadColumns.CURRENTBYTES,\n            DownloadColumns.LASTMOD, DownloadColumns.STATUS,\n            DownloadColumns.CONTROL, DownloadColumns.NUM_FAILED,\n            DownloadColumns.RETRY_AFTER, DownloadColumns.REDIRECT_COUNT,\n            DownloadColumns.INDEX\n    };\n\n    private static final int FILENAME_IDX = 0;\n    private static final int URI_IDX = 1;\n    private static final int ETAG_IDX = 2;\n    private static final int TOTALBYTES_IDX = 3;\n    private static final int CURRENTBYTES_IDX = 4;\n    private static final int LASTMOD_IDX = 5;\n    private static final int STATUS_IDX = 6;\n    private static final int CONTROL_IDX = 7;\n    private static final int NUM_FAILED_IDX = 8;\n    private static final int RETRY_AFTER_IDX = 9;\n    private static final int REDIRECT_COUNT_IDX = 10;\n    private static final int INDEX_IDX = 11;\n\n    /**\n     * This function will add a new file to the database if it does not exist.\n     * \n     * @param di DownloadInfo that we wish to store\n     * @return the row id of the record to be updated/inserted, or -1\n     */\n    public boolean updateDownload(DownloadInfo di) {\n        ContentValues cv = new ContentValues();\n        cv.put(DownloadColumns.INDEX, di.mIndex);\n        cv.put(DownloadColumns.FILENAME, di.mFileName);\n        cv.put(DownloadColumns.URI, di.mUri);\n        cv.put(DownloadColumns.ETAG, di.mETag);\n        cv.put(DownloadColumns.TOTALBYTES, di.mTotalBytes);\n        cv.put(DownloadColumns.CURRENTBYTES, di.mCurrentBytes);\n        cv.put(DownloadColumns.LASTMOD, di.mLastMod);\n        cv.put(DownloadColumns.STATUS, di.mStatus);\n        cv.put(DownloadColumns.CONTROL, di.mControl);\n        cv.put(DownloadColumns.NUM_FAILED, di.mNumFailed);\n        cv.put(DownloadColumns.RETRY_AFTER, di.mRetryAfter);\n        cv.put(DownloadColumns.REDIRECT_COUNT, di.mRedirectCount);\n        return updateDownload(di, cv);\n    }\n\n    public boolean updateDownload(DownloadInfo di, ContentValues cv) {\n        long id = di == null ? -1 : getIDForDownloadInfo(di);\n        try {\n            final SQLiteDatabase sqldb = mHelper.getWritableDatabase();\n            if (id != -1) {\n                if (1 != sqldb.update(DownloadColumns.TABLE_NAME,\n                        cv, DownloadColumns._ID + \" = \" + id, null)) {\n                    return false;\n                }\n            } else {\n                return -1 != sqldb.insert(DownloadColumns.TABLE_NAME,\n                        DownloadColumns.URI, cv);\n            }\n        } catch (android.database.sqlite.SQLiteException ex) {\n            ex.printStackTrace();\n        }\n        return false;\n    }\n\n    public int getLastCheckedVersionCode() {\n        return mVersionCode;\n    }\n\n    public boolean isDownloadRequired() {\n        final SQLiteDatabase sqldb = mHelper.getReadableDatabase();\n        Cursor cur = sqldb.rawQuery(\"SELECT Count(*) FROM \"\n                + DownloadColumns.TABLE_NAME + \" WHERE \"\n                + DownloadColumns.STATUS + \" <> 0\", null);\n        try {\n            if (null != cur && cur.moveToFirst()) {\n                return 0 == cur.getInt(0);\n            }\n        } finally {\n            if (null != cur)\n                cur.close();\n        }\n        return true;\n    }\n\n    public int getFlags() {\n        return mFlags;\n    }\n\n    public boolean updateFlags(int flags) {\n        if (mFlags != flags) {\n            ContentValues cv = new ContentValues();\n            cv.put(MetadataColumns.FLAGS, flags);\n            if (updateMetadata(cv)) {\n                mFlags = flags;\n                return true;\n            } else {\n                return false;\n            }\n        } else {\n            return true;\n        }\n    };\n\n    public boolean updateStatus(int status) {\n        if (mStatus != status) {\n            ContentValues cv = new ContentValues();\n            cv.put(MetadataColumns.DOWNLOAD_STATUS, status);\n            if (updateMetadata(cv)) {\n                mStatus = status;\n                return true;\n            } else {\n                return false;\n            }\n        } else {\n            return true;\n        }\n    };\n\n    public boolean updateMetadata(ContentValues cv) {\n        final SQLiteDatabase sqldb = mHelper.getWritableDatabase();\n        if (-1 == this.mMetadataRowID) {\n            long newID = sqldb.insert(MetadataColumns.TABLE_NAME,\n                    MetadataColumns.APKVERSION, cv);\n            if (-1 == newID)\n                return false;\n            mMetadataRowID = newID;\n        } else {\n            if (0 == sqldb.update(MetadataColumns.TABLE_NAME, cv,\n                    BaseColumns._ID + \" = \" + mMetadataRowID, null))\n                return false;\n        }\n        return true;\n    }\n\n    public boolean updateMetadata(int apkVersion, int downloadStatus) {\n        ContentValues cv = new ContentValues();\n        cv.put(MetadataColumns.APKVERSION, apkVersion);\n        cv.put(MetadataColumns.DOWNLOAD_STATUS, downloadStatus);\n        if (updateMetadata(cv)) {\n            mVersionCode = apkVersion;\n            mStatus = downloadStatus;\n            return true;\n        } else {\n            return false;\n        }\n    };\n\n    public boolean updateFromDb(DownloadInfo di) {\n        final SQLiteDatabase sqldb = mHelper.getReadableDatabase();\n        Cursor cur = null;\n        try {\n            cur = sqldb.query(DownloadColumns.TABLE_NAME, DC_PROJECTION,\n                    DownloadColumns.FILENAME + \"= ?\",\n                    new String[] {\n                        di.mFileName\n                    }, null, null, null);\n            if (null != cur && cur.moveToFirst()) {\n                setDownloadInfoFromCursor(di, cur);\n                return true;\n            }\n            return false;\n        } finally {\n            if (null != cur) {\n                cur.close();\n            }\n        }\n    }\n\n    public void setDownloadInfoFromCursor(DownloadInfo di, Cursor cur) {\n        di.mUri = cur.getString(URI_IDX);\n        di.mETag = cur.getString(ETAG_IDX);\n        di.mTotalBytes = cur.getLong(TOTALBYTES_IDX);\n        di.mCurrentBytes = cur.getLong(CURRENTBYTES_IDX);\n        di.mLastMod = cur.getLong(LASTMOD_IDX);\n        di.mStatus = cur.getInt(STATUS_IDX);\n        di.mControl = cur.getInt(CONTROL_IDX);\n        di.mNumFailed = cur.getInt(NUM_FAILED_IDX);\n        di.mRetryAfter = cur.getInt(RETRY_AFTER_IDX);\n        di.mRedirectCount = cur.getInt(REDIRECT_COUNT_IDX);\n    }\n\n    public DownloadInfo getDownloadInfoFromCursor(Cursor cur) {\n        DownloadInfo di = new DownloadInfo(cur.getInt(INDEX_IDX),\n                cur.getString(FILENAME_IDX), this.getClass().getPackage()\n                        .getName());\n        setDownloadInfoFromCursor(di, cur);\n        return di;\n    }\n\n    public DownloadInfo[] getDownloads() {\n        final SQLiteDatabase sqldb = mHelper.getReadableDatabase();\n        Cursor cur = null;\n        try {\n            cur = sqldb.query(DownloadColumns.TABLE_NAME, DC_PROJECTION, null,\n                    null, null, null, null);\n            if (null != cur && cur.moveToFirst()) {\n                DownloadInfo[] retInfos = new DownloadInfo[cur.getCount()];\n                int idx = 0;\n                do {\n                    DownloadInfo di = getDownloadInfoFromCursor(cur);\n                    retInfos[idx++] = di;\n                } while (cur.moveToNext());\n                return retInfos;\n            }\n            return null;\n        } finally {\n            if (null != cur) {\n                cur.close();\n            }\n        }\n    }\n\n}\n"
  },
  {
    "path": "Projects/Android/playapkexpansion/src/main/java/com/google/android/vending/expansion/downloader/impl/HttpDateTime.java",
    "content": "/*\n * Copyright (C) 2012 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.google.android.vending.expansion.downloader.impl;\n\nimport android.text.format.Time;\n\nimport java.util.Calendar;\nimport java.util.regex.Matcher;\nimport java.util.regex.Pattern;\n\n/**\n * Helper for parsing an HTTP date.\n */\npublic final class HttpDateTime {\n\n    /*\n     * Regular expression for parsing HTTP-date. Wdy, DD Mon YYYY HH:MM:SS GMT\n     * RFC 822, updated by RFC 1123 Weekday, DD-Mon-YY HH:MM:SS GMT RFC 850,\n     * obsoleted by RFC 1036 Wdy Mon DD HH:MM:SS YYYY ANSI C's asctime() format\n     * with following variations Wdy, DD-Mon-YYYY HH:MM:SS GMT Wdy, (SP)D Mon\n     * YYYY HH:MM:SS GMT Wdy,DD Mon YYYY HH:MM:SS GMT Wdy, DD-Mon-YY HH:MM:SS\n     * GMT Wdy, DD Mon YYYY HH:MM:SS -HHMM Wdy, DD Mon YYYY HH:MM:SS Wdy Mon\n     * (SP)D HH:MM:SS YYYY Wdy Mon DD HH:MM:SS YYYY GMT HH can be H if the first\n     * digit is zero. Mon can be the full name of the month.\n     */\n    private static final String HTTP_DATE_RFC_REGEXP =\n            \"([0-9]{1,2})[- ]([A-Za-z]{3,9})[- ]([0-9]{2,4})[ ]\"\n                    + \"([0-9]{1,2}:[0-9][0-9]:[0-9][0-9])\";\n\n    private static final String HTTP_DATE_ANSIC_REGEXP =\n            \"[ ]([A-Za-z]{3,9})[ ]+([0-9]{1,2})[ ]\"\n                    + \"([0-9]{1,2}:[0-9][0-9]:[0-9][0-9])[ ]([0-9]{2,4})\";\n\n    /**\n     * The compiled version of the HTTP-date regular expressions.\n     */\n    private static final Pattern HTTP_DATE_RFC_PATTERN =\n            Pattern.compile(HTTP_DATE_RFC_REGEXP);\n    private static final Pattern HTTP_DATE_ANSIC_PATTERN =\n            Pattern.compile(HTTP_DATE_ANSIC_REGEXP);\n\n    private static class TimeOfDay {\n        TimeOfDay(int h, int m, int s) {\n            this.hour = h;\n            this.minute = m;\n            this.second = s;\n        }\n\n        int hour;\n        int minute;\n        int second;\n    }\n\n    public static long parse(String timeString)\n            throws IllegalArgumentException {\n\n        int date = 1;\n        int month = Calendar.JANUARY;\n        int year = 1970;\n        TimeOfDay timeOfDay;\n\n        Matcher rfcMatcher = HTTP_DATE_RFC_PATTERN.matcher(timeString);\n        if (rfcMatcher.find()) {\n            date = getDate(rfcMatcher.group(1));\n            month = getMonth(rfcMatcher.group(2));\n            year = getYear(rfcMatcher.group(3));\n            timeOfDay = getTime(rfcMatcher.group(4));\n        } else {\n            Matcher ansicMatcher = HTTP_DATE_ANSIC_PATTERN.matcher(timeString);\n            if (ansicMatcher.find()) {\n                month = getMonth(ansicMatcher.group(1));\n                date = getDate(ansicMatcher.group(2));\n                timeOfDay = getTime(ansicMatcher.group(3));\n                year = getYear(ansicMatcher.group(4));\n            } else {\n                throw new IllegalArgumentException();\n            }\n        }\n\n        // FIXME: Y2038 BUG!\n        if (year >= 2038) {\n            year = 2038;\n            month = Calendar.JANUARY;\n            date = 1;\n        }\n\n        Time time = new Time(Time.TIMEZONE_UTC);\n        time.set(timeOfDay.second, timeOfDay.minute, timeOfDay.hour, date,\n                month, year);\n        return time.toMillis(false /* use isDst */);\n    }\n\n    private static int getDate(String dateString) {\n        if (dateString.length() == 2) {\n            return (dateString.charAt(0) - '0') * 10\n                    + (dateString.charAt(1) - '0');\n        } else {\n            return (dateString.charAt(0) - '0');\n        }\n    }\n\n    /*\n     * jan = 9 + 0 + 13 = 22 feb = 5 + 4 + 1 = 10 mar = 12 + 0 + 17 = 29 apr = 0\n     * + 15 + 17 = 32 may = 12 + 0 + 24 = 36 jun = 9 + 20 + 13 = 42 jul = 9 + 20\n     * + 11 = 40 aug = 0 + 20 + 6 = 26 sep = 18 + 4 + 15 = 37 oct = 14 + 2 + 19\n     * = 35 nov = 13 + 14 + 21 = 48 dec = 3 + 4 + 2 = 9\n     */\n    private static int getMonth(String monthString) {\n        int hash = Character.toLowerCase(monthString.charAt(0)) +\n                Character.toLowerCase(monthString.charAt(1)) +\n                Character.toLowerCase(monthString.charAt(2)) - 3 * 'a';\n        switch (hash) {\n            case 22:\n                return Calendar.JANUARY;\n            case 10:\n                return Calendar.FEBRUARY;\n            case 29:\n                return Calendar.MARCH;\n            case 32:\n                return Calendar.APRIL;\n            case 36:\n                return Calendar.MAY;\n            case 42:\n                return Calendar.JUNE;\n            case 40:\n                return Calendar.JULY;\n            case 26:\n                return Calendar.AUGUST;\n            case 37:\n                return Calendar.SEPTEMBER;\n            case 35:\n                return Calendar.OCTOBER;\n            case 48:\n                return Calendar.NOVEMBER;\n            case 9:\n                return Calendar.DECEMBER;\n            default:\n                throw new IllegalArgumentException();\n        }\n    }\n\n    private static int getYear(String yearString) {\n        if (yearString.length() == 2) {\n            int year = (yearString.charAt(0) - '0') * 10\n                    + (yearString.charAt(1) - '0');\n            if (year >= 70) {\n                return year + 1900;\n            } else {\n                return year + 2000;\n            }\n        } else if (yearString.length() == 3) {\n            // According to RFC 2822, three digit years should be added to 1900.\n            int year = (yearString.charAt(0) - '0') * 100\n                    + (yearString.charAt(1) - '0') * 10\n                    + (yearString.charAt(2) - '0');\n            return year + 1900;\n        } else if (yearString.length() == 4) {\n            return (yearString.charAt(0) - '0') * 1000\n                    + (yearString.charAt(1) - '0') * 100\n                    + (yearString.charAt(2) - '0') * 10\n                    + (yearString.charAt(3) - '0');\n        } else {\n            return 1970;\n        }\n    }\n\n    private static TimeOfDay getTime(String timeString) {\n        // HH might be H\n        int i = 0;\n        int hour = timeString.charAt(i++) - '0';\n        if (timeString.charAt(i) != ':')\n            hour = hour * 10 + (timeString.charAt(i++) - '0');\n        // Skip ':'\n        i++;\n\n        int minute = (timeString.charAt(i++) - '0') * 10\n                + (timeString.charAt(i++) - '0');\n        // Skip ':'\n        i++;\n\n        int second = (timeString.charAt(i++) - '0') * 10\n                + (timeString.charAt(i++) - '0');\n\n        return new TimeOfDay(hour, minute, second);\n    }\n}\n"
  },
  {
    "path": "Projects/Android/playapkexpansion/src/main/java/com/google/android/vending/expansion/downloader/impl/V14CustomNotification.java",
    "content": "/*\n * Copyright (C) 2012 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.google.android.vending.expansion.downloader.impl;\n\nimport com.android.vending.expansion.downloader.R;\nimport com.google.android.vending.expansion.downloader.Helpers;\n\nimport android.app.Notification;\nimport android.app.PendingIntent;\nimport android.content.Context;\n\npublic class V14CustomNotification implements DownloadNotification.ICustomNotification {\n\n    CharSequence mTitle;\n    CharSequence mTicker;\n    int mIcon;\n    long mTotalKB = -1;\n    long mCurrentKB = -1;\n    long mTimeRemaining;\n    PendingIntent mPendingIntent;\n\n    @Override\n    public void setIcon(int icon) {\n        mIcon = icon;\n    }\n\n    @Override\n    public void setTitle(CharSequence title) {\n        mTitle = title;\n    }\n\n    @Override\n    public void setTotalBytes(long totalBytes) {\n        mTotalKB = totalBytes;\n    }\n\n    @Override\n    public void setCurrentBytes(long currentBytes) {\n        mCurrentKB = currentBytes;\n    }\n\n    void setProgress(Notification.Builder builder) {\n\n    }\n\n    @Override\n    public Notification updateNotification(Context c) {\n        Notification.Builder builder = new Notification.Builder(c);\n        builder.setContentTitle(mTitle);\n        if (mTotalKB > 0 && -1 != mCurrentKB) {\n            builder.setProgress((int) (mTotalKB >> 8), (int) (mCurrentKB >> 8), false);\n        } else {\n            builder.setProgress(0, 0, true);\n        }\n        builder.setContentText(Helpers.getDownloadProgressString(mCurrentKB, mTotalKB));\n        builder.setContentInfo(c.getString(R.string.time_remaining_notification,\n                Helpers.getTimeRemaining(mTimeRemaining)));\n        if (mIcon != 0) {\n            builder.setSmallIcon(mIcon);\n        } else {\n            int iconResource = android.R.drawable.stat_sys_download;\n            builder.setSmallIcon(iconResource);\n        }\n        builder.setOngoing(true);\n        builder.setTicker(mTicker);\n        builder.setContentIntent(mPendingIntent);\n        builder.setOnlyAlertOnce(true);\n\n        return builder.getNotification();\n    }\n\n    @Override\n    public void setPendingIntent(PendingIntent contentIntent) {\n        mPendingIntent = contentIntent;\n    }\n\n    @Override\n    public void setTicker(CharSequence ticker) {\n        mTicker = ticker;\n    }\n\n    @Override\n    public void setTimeRemaining(long timeRemaining) {\n        mTimeRemaining = timeRemaining;\n    }\n\n}\n"
  },
  {
    "path": "Projects/Android/playapkexpansion/src/main/java/com/google/android/vending/expansion/downloader/impl/V3CustomNotification.java",
    "content": "/*\n * Copyright (C) 2012 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.google.android.vending.expansion.downloader.impl;\n\nimport com.android.vending.expansion.downloader.R;\nimport com.google.android.vending.expansion.downloader.Helpers;\n\nimport android.app.Notification;\nimport android.app.PendingIntent;\nimport android.content.Context;\nimport android.graphics.BitmapFactory;\nimport android.view.View;\nimport android.widget.RemoteViews;\n\npublic class V3CustomNotification implements DownloadNotification.ICustomNotification {\n\n    CharSequence mTitle;\n    CharSequence mTicker;\n    int mIcon;\n    long mTotalBytes = -1;\n    long mCurrentBytes = -1;\n    long mTimeRemaining;\n    PendingIntent mPendingIntent;\n    Notification mNotification = new Notification();\n\n    @Override\n    public void setIcon(int icon) {\n        mIcon = icon;\n    }\n\n    @Override\n    public void setTitle(CharSequence title) {\n        mTitle = title;\n    }\n\n    @Override\n    public void setTotalBytes(long totalBytes) {\n        mTotalBytes = totalBytes;\n    }\n\n    @Override\n    public void setCurrentBytes(long currentBytes) {\n        mCurrentBytes = currentBytes;\n    }\n\n    @Override\n    public Notification updateNotification(Context c) {\n        Notification n = mNotification;\n\n        n.icon = mIcon;\n\n        n.flags |= Notification.FLAG_ONGOING_EVENT;\n\n        if (android.os.Build.VERSION.SDK_INT > 10) {\n            n.flags |= Notification.FLAG_ONLY_ALERT_ONCE; // only matters for\n                                                          // Honeycomb\n        }\n\n        // Build the RemoteView object\n        RemoteViews expandedView = new RemoteViews(\n                c.getPackageName(),\n                R.layout.status_bar_ongoing_event_progress_bar);\n\n        expandedView.setTextViewText(R.id.title, mTitle);\n        // look at strings\n        expandedView.setViewVisibility(R.id.description, View.VISIBLE);\n        expandedView.setTextViewText(R.id.description,\n                Helpers.getDownloadProgressString(mCurrentBytes, mTotalBytes));\n        expandedView.setViewVisibility(R.id.progress_bar_frame, View.VISIBLE);\n        expandedView.setProgressBar(R.id.progress_bar,\n                (int) (mTotalBytes >> 8),\n                (int) (mCurrentBytes >> 8),\n                mTotalBytes <= 0);\n        expandedView.setViewVisibility(R.id.time_remaining, View.VISIBLE);\n        expandedView.setTextViewText(\n                R.id.time_remaining,\n                c.getString(R.string.time_remaining_notification,\n                        Helpers.getTimeRemaining(mTimeRemaining)));\n        expandedView.setTextViewText(R.id.progress_text,\n                Helpers.getDownloadProgressPercent(mCurrentBytes, mTotalBytes));\n        expandedView.setImageViewResource(R.id.appIcon, mIcon);\n        n.contentView = expandedView;\n        n.contentIntent = mPendingIntent;\n        return n;\n    }\n\n    @Override\n    public void setPendingIntent(PendingIntent contentIntent) {\n        mPendingIntent = contentIntent;\n    }\n\n    @Override\n    public void setTicker(CharSequence ticker) {\n        mTicker = ticker;\n    }\n\n    @Override\n    public void setTimeRemaining(long timeRemaining) {\n        mTimeRemaining = timeRemaining;\n    }\n\n}\n"
  },
  {
    "path": "Projects/Android/playapkexpansion/src/main/res/layout/status_bar_ongoing_event_progress_bar.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n/*\n** Copyright 2008, The Android Open Source Project\n**\n** Licensed under the Apache License, Version 2.0 (the \"License\");\n** you may not use this file except in compliance with the License.\n** You may obtain a copy of the License at\n**\n**     http://www.apache.org/licenses/LICENSE-2.0\n**\n** Unless required by applicable law or agreed to in writing, software\n** distributed under the License is distributed on an \"AS IS\" BASIS,\n** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n** See the License for the specific language governing permissions and\n** limitations under the License.\n*/\n-->\n\n<LinearLayout android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\"\n    android:baselineAligned=\"false\"\n    android:orientation=\"horizontal\" android:id=\"@+id/notificationLayout\" xmlns:android=\"http://schemas.android.com/apk/res/android\">\n\n    <RelativeLayout\n        android:layout_width=\"35dp\"\n        android:layout_height=\"fill_parent\"\n        android:paddingTop=\"10dp\"\n        android:paddingBottom=\"8dp\" >\n\n        <ImageView\n            android:id=\"@+id/appIcon\"\n            android:layout_width=\"fill_parent\"\n            android:layout_height=\"25dp\"\n            android:scaleType=\"centerInside\"            \n            android:layout_alignParentLeft=\"true\"\n            android:layout_alignParentTop=\"true\"            \n            android:src=\"@android:drawable/stat_sys_download\" />\n\n        <TextView\n            android:id=\"@+id/progress_text\"\n            style=\"@style/NotificationText\"\n            android:layout_width=\"fill_parent\"\n            android:layout_height=\"wrap_content\"\n            android:layout_alignParentLeft=\"true\"\n            android:layout_alignParentBottom=\"true\"\n            android:layout_gravity=\"center_horizontal\"\n            android:singleLine=\"true\"\n            android:gravity=\"center\" />\n    </RelativeLayout>\n\n    <RelativeLayout\n        android:layout_width=\"0dip\"\n        android:layout_height=\"match_parent\"\n        android:layout_weight=\"1.0\"\n        android:clickable=\"true\"\n        android:focusable=\"true\"\n        android:paddingTop=\"10dp\"\n        android:paddingRight=\"8dp\"\n        android:paddingBottom=\"8dp\" >\n\n        <TextView\n            android:id=\"@+id/title\"\n            style=\"@style/NotificationTitle\"\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            android:layout_alignParentLeft=\"true\"\n            android:singleLine=\"true\"/>\n\n        <TextView\n            android:id=\"@+id/time_remaining\"\n            style=\"@style/NotificationText\"\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            android:layout_alignParentRight=\"true\"\n            android:singleLine=\"true\"/>\n        <!-- Only one of progress_bar and paused_text will be visible. -->\n\n        <FrameLayout\n            android:id=\"@+id/progress_bar_frame\"\n            android:layout_width=\"fill_parent\"\n            android:layout_height=\"wrap_content\"\n            android:layout_alignParentBottom=\"true\" >\n\n            <ProgressBar\n                android:id=\"@+id/progress_bar\"\n                style=\"?android:attr/progressBarStyleHorizontal\"\n                android:layout_width=\"fill_parent\"\n                android:layout_height=\"wrap_content\"\n                android:paddingRight=\"25dp\" />\n\n            <TextView\n                android:id=\"@+id/description\"\n                style=\"@style/NotificationTextShadow\"\n                android:layout_width=\"wrap_content\"\n                android:layout_height=\"wrap_content\"\n                android:layout_gravity=\"center\"\n                android:paddingRight=\"25dp\"\n                android:singleLine=\"true\" />\n        </FrameLayout>\n\n    </RelativeLayout>\n\n</LinearLayout>"
  },
  {
    "path": "Projects/Android/playapkexpansion/src/main/res/values/strings.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n\n    <!-- When a download completes, a notification is displayed, and this\n        string is used to indicate that the download successfully completed.\n        Note that such a download could have been initiated by a variety of\n        applications, including (but not limited to) the browser, an email\n        application, a content marketplace. -->\n    <string name=\"notification_download_complete\">Download complete</string>\n\n    <!-- When a download completes, a notification is displayed, and this\n        string is used to indicate that the download failed.\n        Note that such a download could have been initiated by a variety of\n        applications, including (but not limited to) the browser, an email\n        application, a content marketplace. -->\n    <string name=\"notification_download_failed\">Download unsuccessful</string>\n\n\n    <string name=\"state_unknown\">Starting...\"</string>\n    <string name=\"state_idle\">Waiting for download to start</string>\n    <string name=\"state_fetching_url\">Looking for resources to download</string>\n    <string name=\"state_connecting\">Connecting to the download server</string>\n    <string name=\"state_downloading\">Downloading resources</string>\n    <string name=\"state_completed\">Download finished</string>\n    <string name=\"state_paused_network_unavailable\">Download paused because no network is available</string>\n    <string name=\"state_paused_network_setup_failure\">Download paused. Test a website in browser</string>\n    <string name=\"state_paused_by_request\">Download paused</string>\n    <string name=\"state_paused_wifi_unavailable\">Download paused because wifi is unavailable</string>\n    <string name=\"state_paused_wifi_disabled\">Download paused because wifi is disabled</string>\n    <string name=\"state_paused_roaming\">Download paused because you are roaming</string>\n    <string name=\"state_paused_sdcard_unavailable\">Download paused because the external storage is unavailable</string>\n    <string name=\"state_failed_unlicensed\">Download failed because you may not have purchased this app</string>\n    <string name=\"state_failed_fetching_url\">Download failed because the resources could not be found</string>\n    <string name=\"state_failed_sdcard_full\">Download failed because the external storage is full</string>\n    <string name=\"state_failed_cancelled\">Download cancelled</string>\n    <string name=\"state_failed\">Download failed</string>\n\n    <string name=\"kilobytes_per_second\">%1$s KB/s</string>\n    <string name=\"time_remaining\">Time remaining: %1$s</string>\n    <string name=\"time_remaining_notification\">%1$s left</string>\n</resources>"
  },
  {
    "path": "Projects/Android/playapkexpansion/src/main/res/values/styles.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n\n    <style name=\"NotificationText\">\n        <item name=\"android:textColor\">?android:attr/textColorPrimary</item>\n    </style>\n\n    <style name=\"NotificationTextShadow\" parent=\"NotificationText\">\n        <item name=\"android:textColor\">?android:attr/textColorPrimary</item>\n        <item name=\"android:shadowColor\">@android:color/background_dark</item>\n        <item name=\"android:shadowDx\">1.0</item>\n        <item name=\"android:shadowDy\">1.0</item>\n        <item name=\"android:shadowRadius\">1</item>\n    </style>\n\n    <style name=\"NotificationTitle\">\n        <item name=\"android:textColor\">?android:attr/textColorPrimary</item>\n        <item name=\"android:textStyle\">bold</item>\n    </style>\n\n    <style name=\"ButtonBackground\">\n        <item name=\"android:background\">@android:color/background_dark</item>\n    </style>\n\n</resources>"
  },
  {
    "path": "Projects/Android/playapkexpansion/src/main/res/values-v11/styles.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n    <style name=\"NotificationTextSecondary\" parent=\"NotificationText\">\n        <item name=\"android:textSize\">12sp</item>\n    </style>\n</resources>"
  },
  {
    "path": "Projects/Android/playapkexpansion/src/main/res/values-v9/styles.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n    <style name=\"NotificationText\" parent=\"android:TextAppearance.StatusBar.EventContent\" />\n    <style name=\"NotificationTitle\" parent=\"android:TextAppearance.StatusBar.EventContent.Title\" />\n</resources>"
  },
  {
    "path": "Projects/Android/playlicensing/build.gradle",
    "content": "apply plugin: 'com.android.library'\n\nandroid {\n    compileSdkVersion 22\n    buildToolsVersion \"22.0.1\"\n\n    defaultConfig {\n        minSdkVersion 3\n        targetSdkVersion 22\n        versionCode 1\n        versionName \"1.0\"\n    }\n    buildTypes {\n        release {\n            minifyEnabled false\n        }\n    }\n}\n\ndependencies {\n    compile fileTree(dir: 'libs', include: ['*.jar'])\n}\n"
  },
  {
    "path": "Projects/Android/playlicensing/playlicensing.iml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<module external.linked.project.id=\":playlicensing\" external.linked.project.path=\"$MODULE_DIR$\" external.root.project.path=\"$MODULE_DIR$/../../../../Projects/Android/cstest\" external.system.id=\"GRADLE\" external.system.module.group=\"cstest\" external.system.module.version=\"unspecified\" type=\"JAVA_MODULE\" version=\"4\">\n  <component name=\"FacetManager\">\n    <facet type=\"android-gradle\" name=\"Android-Gradle\">\n      <configuration>\n        <option name=\"GRADLE_PROJECT_PATH\" value=\":playlicensing\" />\n      </configuration>\n    </facet>\n    <facet type=\"android\" name=\"Android\">\n      <configuration>\n        <option name=\"SELECTED_BUILD_VARIANT\" value=\"debug\" />\n        <option name=\"SELECTED_TEST_ARTIFACT\" value=\"_android_test_\" />\n        <option name=\"ASSEMBLE_TASK_NAME\" value=\"assembleDebug\" />\n        <option name=\"COMPILE_JAVA_TASK_NAME\" value=\"compileDebugSources\" />\n        <afterSyncTasks>\n          <task>generateDebugSources</task>\n        </afterSyncTasks>\n        <option name=\"ALLOW_USER_CONFIGURATION\" value=\"false\" />\n        <option name=\"MANIFEST_FILE_RELATIVE_PATH\" value=\"/src/main/AndroidManifest.xml\" />\n        <option name=\"RES_FOLDER_RELATIVE_PATH\" value=\"/src/main/res\" />\n        <option name=\"RES_FOLDERS_RELATIVE_PATH\" value=\"\" />\n        <option name=\"ASSETS_FOLDER_RELATIVE_PATH\" value=\"/src/main/assets\" />\n        <option name=\"LIBRARY_PROJECT\" value=\"true\" />\n      </configuration>\n    </facet>\n  </component>\n  <component name=\"NewModuleRootManager\" LANGUAGE_LEVEL=\"JDK_1_7\" inherit-compiler-output=\"false\">\n    <output url=\"file://$MODULE_DIR$/build/intermediates/classes/debug\" />\n    <output-test url=\"file://$MODULE_DIR$/build/intermediates/classes/test/debug\" />\n    <exclude-output />\n    <content url=\"file://$MODULE_DIR$\">\n      <sourceFolder url=\"file://$MODULE_DIR$/build/generated/source/r/debug\" isTestSource=\"false\" generated=\"true\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/build/generated/source/aidl/debug\" isTestSource=\"false\" generated=\"true\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/build/generated/source/buildConfig/debug\" isTestSource=\"false\" generated=\"true\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/build/generated/source/rs/debug\" isTestSource=\"false\" generated=\"true\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/build/generated/res/rs/debug\" type=\"java-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/build/generated/res/generated/debug\" type=\"java-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/build/generated/source/r/androidTest/debug\" isTestSource=\"true\" generated=\"true\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/build/generated/source/aidl/androidTest/debug\" isTestSource=\"true\" generated=\"true\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/build/generated/source/buildConfig/androidTest/debug\" isTestSource=\"true\" generated=\"true\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/build/generated/source/rs/androidTest/debug\" isTestSource=\"true\" generated=\"true\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/build/generated/res/rs/androidTest/debug\" type=\"java-test-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/build/generated/res/generated/androidTest/debug\" type=\"java-test-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/debug/res\" type=\"java-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/debug/resources\" type=\"java-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/debug/assets\" type=\"java-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/debug/aidl\" isTestSource=\"false\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/debug/java\" isTestSource=\"false\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/debug/jni\" isTestSource=\"false\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/debug/rs\" isTestSource=\"false\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/testDebug/res\" type=\"java-test-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/testDebug/resources\" type=\"java-test-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/testDebug/assets\" type=\"java-test-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/testDebug/aidl\" isTestSource=\"true\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/testDebug/java\" isTestSource=\"true\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/testDebug/jni\" isTestSource=\"true\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/testDebug/rs\" isTestSource=\"true\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/main/res\" type=\"java-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/main/resources\" type=\"java-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/main/assets\" type=\"java-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/main/aidl\" isTestSource=\"false\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/main/java\" isTestSource=\"false\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/main/jni\" isTestSource=\"false\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/main/rs\" isTestSource=\"false\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/test/res\" type=\"java-test-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/test/resources\" type=\"java-test-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/test/assets\" type=\"java-test-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/test/aidl\" isTestSource=\"true\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/test/java\" isTestSource=\"true\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/test/jni\" isTestSource=\"true\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/test/rs\" isTestSource=\"true\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/androidTest/res\" type=\"java-test-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/androidTest/resources\" type=\"java-test-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/androidTest/assets\" type=\"java-test-resource\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/androidTest/aidl\" isTestSource=\"true\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/androidTest/java\" isTestSource=\"true\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/androidTest/jni\" isTestSource=\"true\" />\n      <sourceFolder url=\"file://$MODULE_DIR$/src/androidTest/rs\" isTestSource=\"true\" />\n      <excludeFolder url=\"file://$MODULE_DIR$/build/intermediates/assets\" />\n      <excludeFolder url=\"file://$MODULE_DIR$/build/intermediates/bundles\" />\n      <excludeFolder url=\"file://$MODULE_DIR$/build/intermediates/classes\" />\n      <excludeFolder url=\"file://$MODULE_DIR$/build/intermediates/dependency-cache\" />\n      <excludeFolder url=\"file://$MODULE_DIR$/build/intermediates/incremental\" />\n      <excludeFolder url=\"file://$MODULE_DIR$/build/intermediates/lint\" />\n      <excludeFolder url=\"file://$MODULE_DIR$/build/intermediates/manifests\" />\n      <excludeFolder url=\"file://$MODULE_DIR$/build/intermediates/mockable-android-22.jar\" />\n      <excludeFolder url=\"file://$MODULE_DIR$/build/intermediates/res\" />\n      <excludeFolder url=\"file://$MODULE_DIR$/build/intermediates/resources\" />\n      <excludeFolder url=\"file://$MODULE_DIR$/build/intermediates/rs\" />\n      <excludeFolder url=\"file://$MODULE_DIR$/build/intermediates/symbols\" />\n      <excludeFolder url=\"file://$MODULE_DIR$/build/outputs\" />\n      <excludeFolder url=\"file://$MODULE_DIR$/build/tmp\" />\n    </content>\n    <orderEntry type=\"jdk\" jdkName=\"Android API 22 Platform (1)\" jdkType=\"Android SDK\" />\n    <orderEntry type=\"sourceFolder\" forTests=\"false\" />\n    <orderEntry type=\"library\" exported=\"\" scope=\"TEST\" name=\"mockable-android-22\" level=\"project\" />\n  </component>\n</module>"
  },
  {
    "path": "Projects/Android/playlicensing/src/main/AndroidManifest.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!-- Copyright (C) 2010 The Android Open Source Project\n\n     Licensed under the Apache License, Version 2.0 (the \"License\");\n     you may not use this file except in compliance with the License.\n     You may obtain a copy of the License at\n\n          http://www.apache.org/licenses/LICENSE-2.0\n\n     Unless required by applicable law or agreed to in writing, software\n     distributed under the License is distributed on an \"AS IS\" BASIS,\n     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n     See the License for the specific language governing permissions and\n     limitations under the License.\n-->\n<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\" package=\"com.google.android.vending.licensing\" >\n    \n    <!-- Required permission to check licensing. -->\n    <uses-permission android:name=\"com.android.vending.CHECK_LICENSE\" />\n</manifest>\n"
  },
  {
    "path": "Projects/Android/playlicensing/src/main/aidl/com/android/vending/licensing/ILicenseResultListener.aidl",
    "content": "/*\n * Copyright (C) 2010 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.android.vending.licensing;\n\n// Android library projects do not yet support AIDL, so this has been\n// precompiled into the src directory.\noneway interface ILicenseResultListener {\n  void verifyLicense(int responseCode, String signedData, String signature);\n}\n"
  },
  {
    "path": "Projects/Android/playlicensing/src/main/aidl/com/android/vending/licensing/ILicensingService.aidl",
    "content": "/*\n * Copyright (C) 2010 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.android.vending.licensing;\n\nimport com.android.vending.licensing.ILicenseResultListener;\n\n// Android library projects do not yet support AIDL, so this has been\n// precompiled into the src directory.\noneway interface ILicensingService {\n  void checkLicense(long nonce, String packageName, in ILicenseResultListener listener);\n}\n"
  },
  {
    "path": "Projects/Android/playlicensing/src/main/java/com/google/android/vending/licensing/AESObfuscator.java",
    "content": "/*\n * Copyright (C) 2010 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.google.android.vending.licensing;\n\nimport com.google.android.vending.licensing.util.Base64;\nimport com.google.android.vending.licensing.util.Base64DecoderException;\n\nimport java.io.UnsupportedEncodingException;\nimport java.security.GeneralSecurityException;\nimport java.security.spec.KeySpec;\n\nimport javax.crypto.BadPaddingException;\nimport javax.crypto.Cipher;\nimport javax.crypto.IllegalBlockSizeException;\nimport javax.crypto.SecretKey;\nimport javax.crypto.SecretKeyFactory;\nimport javax.crypto.spec.IvParameterSpec;\nimport javax.crypto.spec.PBEKeySpec;\nimport javax.crypto.spec.SecretKeySpec;\n\n/**\n * An Obfuscator that uses AES to encrypt data.\n */\npublic class AESObfuscator implements Obfuscator {\n    private static final String UTF8 = \"UTF-8\";\n    private static final String KEYGEN_ALGORITHM = \"PBEWITHSHAAND256BITAES-CBC-BC\";\n    private static final String CIPHER_ALGORITHM = \"AES/CBC/PKCS5Padding\";\n    private static final byte[] IV =\n        { 16, 74, 71, -80, 32, 101, -47, 72, 117, -14, 0, -29, 70, 65, -12, 74 };\n    private static final String header = \"com.android.vending.licensing.AESObfuscator-1|\";\n\n    private Cipher mEncryptor;\n    private Cipher mDecryptor;\n\n    /**\n     * @param salt an array of random bytes to use for each (un)obfuscation\n     * @param applicationId application identifier, e.g. the package name\n     * @param deviceId device identifier. Use as many sources as possible to\n     *    create this unique identifier.\n     */\n    public AESObfuscator(byte[] salt, String applicationId, String deviceId) {\n        try {\n            SecretKeyFactory factory = SecretKeyFactory.getInstance(KEYGEN_ALGORITHM);\n            KeySpec keySpec =   \n                new PBEKeySpec((applicationId + deviceId).toCharArray(), salt, 1024, 256);\n            SecretKey tmp = factory.generateSecret(keySpec);\n            SecretKey secret = new SecretKeySpec(tmp.getEncoded(), \"AES\");\n            mEncryptor = Cipher.getInstance(CIPHER_ALGORITHM);\n            mEncryptor.init(Cipher.ENCRYPT_MODE, secret, new IvParameterSpec(IV));\n            mDecryptor = Cipher.getInstance(CIPHER_ALGORITHM);\n            mDecryptor.init(Cipher.DECRYPT_MODE, secret, new IvParameterSpec(IV));\n        } catch (GeneralSecurityException e) {\n            // This can't happen on a compatible Android device.\n            throw new RuntimeException(\"Invalid environment\", e);\n        }\n    }\n\n    public String obfuscate(String original, String key) {\n        if (original == null) {\n            return null;\n        }\n        try {\n            // Header is appended as an integrity check\n            return Base64.encode(mEncryptor.doFinal((header + key + original).getBytes(UTF8)));\n        } catch (UnsupportedEncodingException e) {\n            throw new RuntimeException(\"Invalid environment\", e);\n        } catch (GeneralSecurityException e) {\n            throw new RuntimeException(\"Invalid environment\", e);\n        }\n    }\n\n    public String unobfuscate(String obfuscated, String key) throws ValidationException {\n        if (obfuscated == null) {\n            return null;\n        }\n        try {\n            String result = new String(mDecryptor.doFinal(Base64.decode(obfuscated)), UTF8);\n            // Check for presence of header. This serves as a final integrity check, for cases\n            // where the block size is correct during decryption.\n            int headerIndex = result.indexOf(header+key);\n            if (headerIndex != 0) {\n                throw new ValidationException(\"Header not found (invalid data or key)\" + \":\" +\n                        obfuscated);\n            }\n            return result.substring(header.length()+key.length(), result.length());\n        } catch (Base64DecoderException e) {\n            throw new ValidationException(e.getMessage() + \":\" + obfuscated);\n        } catch (IllegalBlockSizeException e) {\n            throw new ValidationException(e.getMessage() + \":\" + obfuscated);\n        } catch (BadPaddingException e) {\n            throw new ValidationException(e.getMessage() + \":\" + obfuscated);\n        } catch (UnsupportedEncodingException e) {\n            throw new RuntimeException(\"Invalid environment\", e);\n        }\n    }\n}\n"
  },
  {
    "path": "Projects/Android/playlicensing/src/main/java/com/google/android/vending/licensing/APKExpansionPolicy.java",
    "content": "\npackage com.google.android.vending.licensing;\n\n/*\n * Copyright (C) 2012 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport org.apache.http.NameValuePair;\nimport org.apache.http.client.utils.URLEncodedUtils;\n\nimport android.content.Context;\nimport android.content.SharedPreferences;\nimport android.util.Log;\n\nimport java.net.URI;\nimport java.net.URISyntaxException;\nimport java.util.HashMap;\nimport java.util.List;\nimport java.util.Map;\nimport java.util.Set;\nimport java.util.Vector;\n\n/**\n * Default policy. All policy decisions are based off of response data received\n * from the licensing service. Specifically, the licensing server sends the\n * following information: response validity period, error retry period, and\n * error retry count.\n * <p>\n * These values will vary based on the the way the application is configured in\n * the Android Market publishing console, such as whether the application is\n * marked as free or is within its refund period, as well as how often an\n * application is checking with the licensing service.\n * <p>\n * Developers who need more fine grained control over their application's\n * licensing policy should implement a custom Policy.\n */\npublic class APKExpansionPolicy implements Policy {\n\n    private static final String TAG = \"APKExpansionPolicy\";\n    private static final String PREFS_FILE = \"com.android.vending.licensing.APKExpansionPolicy\";\n    private static final String PREF_LAST_RESPONSE = \"lastResponse\";\n    private static final String PREF_VALIDITY_TIMESTAMP = \"validityTimestamp\";\n    private static final String PREF_RETRY_UNTIL = \"retryUntil\";\n    private static final String PREF_MAX_RETRIES = \"maxRetries\";\n    private static final String PREF_RETRY_COUNT = \"retryCount\";\n    private static final String DEFAULT_VALIDITY_TIMESTAMP = \"0\";\n    private static final String DEFAULT_RETRY_UNTIL = \"0\";\n    private static final String DEFAULT_MAX_RETRIES = \"0\";\n    private static final String DEFAULT_RETRY_COUNT = \"0\";\n\n    private static final long MILLIS_PER_MINUTE = 60 * 1000;\n\n    private long mValidityTimestamp;\n    private long mRetryUntil;\n    private long mMaxRetries;\n    private long mRetryCount;\n    private long mLastResponseTime = 0;\n    private int mLastResponse;\n    private PreferenceObfuscator mPreferences;\n    private Vector<String> mExpansionURLs = new Vector<String>();\n    private Vector<String> mExpansionFileNames = new Vector<String>();\n    private Vector<Long> mExpansionFileSizes = new Vector<Long>();\n\n    /**\n     * The design of the protocol supports n files. Currently the market can\n     * only deliver two files. To accommodate this, we have these two constants,\n     * but the order is the only relevant thing here.\n     */\n    public static final int MAIN_FILE_URL_INDEX = 0;\n    public static final int PATCH_FILE_URL_INDEX = 1;\n\n    /**\n     * @param context The context for the current application\n     * @param obfuscator An obfuscator to be used with preferences.\n     */\n    public APKExpansionPolicy(Context context, Obfuscator obfuscator) {\n        // Import old values\n        SharedPreferences sp = context.getSharedPreferences(PREFS_FILE, Context.MODE_PRIVATE);\n        mPreferences = new PreferenceObfuscator(sp, obfuscator);\n        mLastResponse = Integer.parseInt(\n                mPreferences.getString(PREF_LAST_RESPONSE, Integer.toString(Policy.RETRY)));\n        mValidityTimestamp = Long.parseLong(mPreferences.getString(PREF_VALIDITY_TIMESTAMP,\n                DEFAULT_VALIDITY_TIMESTAMP));\n        mRetryUntil = Long.parseLong(mPreferences.getString(PREF_RETRY_UNTIL, DEFAULT_RETRY_UNTIL));\n        mMaxRetries = Long.parseLong(mPreferences.getString(PREF_MAX_RETRIES, DEFAULT_MAX_RETRIES));\n        mRetryCount = Long.parseLong(mPreferences.getString(PREF_RETRY_COUNT, DEFAULT_RETRY_COUNT));\n    }\n\n    /**\n     * We call this to guarantee that we fetch a fresh policy from the server.\n     * This is to be used if the URL is invalid.\n     */\n    public void resetPolicy() {\n        mPreferences.putString(PREF_LAST_RESPONSE, Integer.toString(Policy.RETRY));\n        setRetryUntil(DEFAULT_RETRY_UNTIL);\n        setMaxRetries(DEFAULT_MAX_RETRIES);\n        setRetryCount(Long.parseLong(DEFAULT_RETRY_COUNT));\n        setValidityTimestamp(DEFAULT_VALIDITY_TIMESTAMP);\n        mPreferences.commit();\n    }\n\n    /**\n     * Process a new response from the license server.\n     * <p>\n     * This data will be used for computing future policy decisions. The\n     * following parameters are processed:\n     * <ul>\n     * <li>VT: the timestamp that the client should consider the response valid\n     * until\n     * <li>GT: the timestamp that the client should ignore retry errors until\n     * <li>GR: the number of retry errors that the client should ignore\n     * </ul>\n     * \n     * @param response the result from validating the server response\n     * @param rawData the raw server response data\n     */\n    public void processServerResponse(int response,\n            com.google.android.vending.licensing.ResponseData rawData) {\n\n        // Update retry counter\n        if (response != Policy.RETRY) {\n            setRetryCount(0);\n        } else {\n            setRetryCount(mRetryCount + 1);\n        }\n\n        if (response == Policy.LICENSED) {\n            // Update server policy data\n            Map<String, String> extras = decodeExtras(rawData.extra);\n            mLastResponse = response;\n            setValidityTimestamp(Long.toString(System.currentTimeMillis() + MILLIS_PER_MINUTE));\n            Set<String> keys = extras.keySet();\n            for (String key : keys) {\n                if (key.equals(\"VT\")) {\n                    setValidityTimestamp(extras.get(key));\n                } else if (key.equals(\"GT\")) {\n                    setRetryUntil(extras.get(key));\n                } else if (key.equals(\"GR\")) {\n                    setMaxRetries(extras.get(key));\n                } else if (key.startsWith(\"FILE_URL\")) {\n                    int index = Integer.parseInt(key.substring(\"FILE_URL\".length())) - 1;\n                    setExpansionURL(index, extras.get(key));\n                } else if (key.startsWith(\"FILE_NAME\")) {\n                    int index = Integer.parseInt(key.substring(\"FILE_NAME\".length())) - 1;\n                    setExpansionFileName(index, extras.get(key));\n                } else if (key.startsWith(\"FILE_SIZE\")) {\n                    int index = Integer.parseInt(key.substring(\"FILE_SIZE\".length())) - 1;\n                    setExpansionFileSize(index, Long.parseLong(extras.get(key)));\n                }\n            }\n        } else if (response == Policy.NOT_LICENSED) {\n            // Clear out stale policy data\n            setValidityTimestamp(DEFAULT_VALIDITY_TIMESTAMP);\n            setRetryUntil(DEFAULT_RETRY_UNTIL);\n            setMaxRetries(DEFAULT_MAX_RETRIES);\n        }\n\n        setLastResponse(response);\n        mPreferences.commit();\n    }\n\n    /**\n     * Set the last license response received from the server and add to\n     * preferences. You must manually call PreferenceObfuscator.commit() to\n     * commit these changes to disk.\n     * \n     * @param l the response\n     */\n    private void setLastResponse(int l) {\n        mLastResponseTime = System.currentTimeMillis();\n        mLastResponse = l;\n        mPreferences.putString(PREF_LAST_RESPONSE, Integer.toString(l));\n    }\n\n    /**\n     * Set the current retry count and add to preferences. You must manually\n     * call PreferenceObfuscator.commit() to commit these changes to disk.\n     * \n     * @param c the new retry count\n     */\n    private void setRetryCount(long c) {\n        mRetryCount = c;\n        mPreferences.putString(PREF_RETRY_COUNT, Long.toString(c));\n    }\n\n    public long getRetryCount() {\n        return mRetryCount;\n    }\n\n    /**\n     * Set the last validity timestamp (VT) received from the server and add to\n     * preferences. You must manually call PreferenceObfuscator.commit() to\n     * commit these changes to disk.\n     * \n     * @param validityTimestamp the VT string received\n     */\n    private void setValidityTimestamp(String validityTimestamp) {\n        Long lValidityTimestamp;\n        try {\n            lValidityTimestamp = Long.parseLong(validityTimestamp);\n        } catch (NumberFormatException e) {\n            // No response or not parseable, expire in one minute.\n            Log.w(TAG, \"License validity timestamp (VT) missing, caching for a minute\");\n            lValidityTimestamp = System.currentTimeMillis() + MILLIS_PER_MINUTE;\n            validityTimestamp = Long.toString(lValidityTimestamp);\n        }\n\n        mValidityTimestamp = lValidityTimestamp;\n        mPreferences.putString(PREF_VALIDITY_TIMESTAMP, validityTimestamp);\n    }\n\n    public long getValidityTimestamp() {\n        return mValidityTimestamp;\n    }\n\n    /**\n     * Set the retry until timestamp (GT) received from the server and add to\n     * preferences. You must manually call PreferenceObfuscator.commit() to\n     * commit these changes to disk.\n     * \n     * @param retryUntil the GT string received\n     */\n    private void setRetryUntil(String retryUntil) {\n        Long lRetryUntil;\n        try {\n            lRetryUntil = Long.parseLong(retryUntil);\n        } catch (NumberFormatException e) {\n            // No response or not parseable, expire immediately\n            Log.w(TAG, \"License retry timestamp (GT) missing, grace period disabled\");\n            retryUntil = \"0\";\n            lRetryUntil = 0l;\n        }\n\n        mRetryUntil = lRetryUntil;\n        mPreferences.putString(PREF_RETRY_UNTIL, retryUntil);\n    }\n\n    public long getRetryUntil() {\n        return mRetryUntil;\n    }\n\n    /**\n     * Set the max retries value (GR) as received from the server and add to\n     * preferences. You must manually call PreferenceObfuscator.commit() to\n     * commit these changes to disk.\n     * \n     * @param maxRetries the GR string received\n     */\n    private void setMaxRetries(String maxRetries) {\n        Long lMaxRetries;\n        try {\n            lMaxRetries = Long.parseLong(maxRetries);\n        } catch (NumberFormatException e) {\n            // No response or not parseable, expire immediately\n            Log.w(TAG, \"Licence retry count (GR) missing, grace period disabled\");\n            maxRetries = \"0\";\n            lMaxRetries = 0l;\n        }\n\n        mMaxRetries = lMaxRetries;\n        mPreferences.putString(PREF_MAX_RETRIES, maxRetries);\n    }\n\n    public long getMaxRetries() {\n        return mMaxRetries;\n    }\n\n    /**\n     * Gets the count of expansion URLs. Since expansionURLs are not committed\n     * to preferences, this will return zero if there has been no LVL fetch\n     * in the current session.\n     * \n     * @return the number of expansion URLs. (0,1,2)\n     */\n    public int getExpansionURLCount() {\n        return mExpansionURLs.size();\n    }\n\n    /**\n     * Gets the expansion URL. Since these URLs are not committed to\n     * preferences, this will always return null if there has not been an LVL\n     * fetch in the current session.\n     * \n     * @param index the index of the URL to fetch. This value will be either\n     *            MAIN_FILE_URL_INDEX or PATCH_FILE_URL_INDEX\n     * @param URL the URL to set\n     */\n    public String getExpansionURL(int index) {\n        if (index < mExpansionURLs.size()) {\n            return mExpansionURLs.elementAt(index);\n        }\n        return null;\n    }\n\n    /**\n     * Sets the expansion URL. Expansion URL's are not committed to preferences,\n     * but are instead intended to be stored when the license response is\n     * processed by the front-end.\n     * \n     * @param index the index of the expansion URL. This value will be either\n     *            MAIN_FILE_URL_INDEX or PATCH_FILE_URL_INDEX\n     * @param URL the URL to set\n     */\n    public void setExpansionURL(int index, String URL) {\n        if (index >= mExpansionURLs.size()) {\n            mExpansionURLs.setSize(index + 1);\n        }\n        mExpansionURLs.set(index, URL);\n    }\n\n    public String getExpansionFileName(int index) {\n        if (index < mExpansionFileNames.size()) {\n            return mExpansionFileNames.elementAt(index);\n        }\n        return null;\n    }\n\n    public void setExpansionFileName(int index, String name) {\n        if (index >= mExpansionFileNames.size()) {\n            mExpansionFileNames.setSize(index + 1);\n        }\n        mExpansionFileNames.set(index, name);\n    }\n\n    public long getExpansionFileSize(int index) {\n        if (index < mExpansionFileSizes.size()) {\n            return mExpansionFileSizes.elementAt(index);\n        }\n        return -1;\n    }\n\n    public void setExpansionFileSize(int index, long size) {\n        if (index >= mExpansionFileSizes.size()) {\n            mExpansionFileSizes.setSize(index + 1);\n        }\n        mExpansionFileSizes.set(index, size);\n    }\n\n    /**\n     * {@inheritDoc} This implementation allows access if either:<br>\n     * <ol>\n     * <li>a LICENSED response was received within the validity period\n     * <li>a RETRY response was received in the last minute, and we are under\n     * the RETRY count or in the RETRY period.\n     * </ol>\n     */\n    public boolean allowAccess() {\n        long ts = System.currentTimeMillis();\n        if (mLastResponse == Policy.LICENSED) {\n            // Check if the LICENSED response occurred within the validity\n            // timeout.\n            if (ts <= mValidityTimestamp) {\n                // Cached LICENSED response is still valid.\n                return true;\n            }\n        } else if (mLastResponse == Policy.RETRY &&\n                ts < mLastResponseTime + MILLIS_PER_MINUTE) {\n            // Only allow access if we are within the retry period or we haven't\n            // used up our\n            // max retries.\n            return (ts <= mRetryUntil || mRetryCount <= mMaxRetries);\n        }\n        return false;\n    }\n\n    private Map<String, String> decodeExtras(String extras) {\n        Map<String, String> results = new HashMap<String, String>();\n        try {\n            URI rawExtras = new URI(\"?\" + extras);\n            List<NameValuePair> extraList = URLEncodedUtils.parse(rawExtras, \"UTF-8\");\n            for (NameValuePair item : extraList) {\n                String name = item.getName();\n                int i = 0;\n                while (results.containsKey(name)) {\n                    name = item.getName() + ++i;\n                }\n                results.put(name, item.getValue());\n            }\n        } catch (URISyntaxException e) {\n            Log.w(TAG, \"Invalid syntax error while decoding extras data from server.\");\n        }\n        return results;\n    }\n\n}\n"
  },
  {
    "path": "Projects/Android/playlicensing/src/main/java/com/google/android/vending/licensing/DeviceLimiter.java",
    "content": "/*\n * Copyright (C) 2010 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.google.android.vending.licensing;\n\n/**\n * Allows the developer to limit the number of devices using a single license.\n * <p>\n * The LICENSED response from the server contains a user identifier unique to\n * the &lt;application, user&gt; pair. The developer can send this identifier\n * to their own server along with some device identifier (a random number\n * generated and stored once per application installation,\n * {@link android.telephony.TelephonyManager#getDeviceId getDeviceId},\n * {@link android.provider.Settings.Secure#ANDROID_ID ANDROID_ID}, etc).\n * The more sources used to identify the device, the harder it will be for an\n * attacker to spoof.\n * <p>\n * The server can look at the &lt;application, user, device id&gt; tuple and\n * restrict a user's application license to run on at most 10 different devices\n * in a week (for example). We recommend not being too restrictive because a\n * user might legitimately have multiple devices or be in the process of\n * changing phones. This will catch egregious violations of multiple people\n * sharing one license.\n */\npublic interface DeviceLimiter {\n\n    /**\n     * Checks if this device is allowed to use the given user's license.\n     *\n     * @param userId the user whose license the server responded with\n     * @return LICENSED if the device is allowed, NOT_LICENSED if not, RETRY if an error occurs\n     */\n    int isDeviceAllowed(String userId);\n}\n"
  },
  {
    "path": "Projects/Android/playlicensing/src/main/java/com/google/android/vending/licensing/ILicenseResultListener.java",
    "content": "/*\n * This file is auto-generated.  DO NOT MODIFY.\n * Original file: aidl/ILicenseResultListener.aidl\n */\npackage com.google.android.vending.licensing;\nimport java.lang.String;\nimport android.os.RemoteException;\nimport android.os.IBinder;\nimport android.os.IInterface;\nimport android.os.Binder;\nimport android.os.Parcel;\npublic interface ILicenseResultListener extends android.os.IInterface\n{\n/** Local-side IPC implementation stub class. */\npublic static abstract class Stub extends android.os.Binder implements com.google.android.vending.licensing.ILicenseResultListener\n{\nprivate static final java.lang.String DESCRIPTOR = \"com.android.vending.licensing.ILicenseResultListener\";\n/** Construct the stub at attach it to the interface. */\npublic Stub()\n{\nthis.attachInterface(this, DESCRIPTOR);\n}\n/**\n * Cast an IBinder object into an ILicenseResultListener interface,\n * generating a proxy if needed.\n */\npublic static com.google.android.vending.licensing.ILicenseResultListener asInterface(android.os.IBinder obj)\n{\nif ((obj==null)) {\nreturn null;\n}\nandroid.os.IInterface iin = (android.os.IInterface)obj.queryLocalInterface(DESCRIPTOR);\nif (((iin!=null)&&(iin instanceof com.google.android.vending.licensing.ILicenseResultListener))) {\nreturn ((com.google.android.vending.licensing.ILicenseResultListener)iin);\n}\nreturn new com.google.android.vending.licensing.ILicenseResultListener.Stub.Proxy(obj);\n}\npublic android.os.IBinder asBinder()\n{\nreturn this;\n}\npublic boolean onTransact(int code, android.os.Parcel data, android.os.Parcel reply, int flags) throws android.os.RemoteException\n{\nswitch (code)\n{\ncase INTERFACE_TRANSACTION:\n{\nreply.writeString(DESCRIPTOR);\nreturn true;\n}\ncase TRANSACTION_verifyLicense:\n{\ndata.enforceInterface(DESCRIPTOR);\nint _arg0;\n_arg0 = data.readInt();\njava.lang.String _arg1;\n_arg1 = data.readString();\njava.lang.String _arg2;\n_arg2 = data.readString();\nthis.verifyLicense(_arg0, _arg1, _arg2);\nreturn true;\n}\n}\nreturn super.onTransact(code, data, reply, flags);\n}\nprivate static class Proxy implements com.google.android.vending.licensing.ILicenseResultListener\n{\nprivate android.os.IBinder mRemote;\nProxy(android.os.IBinder remote)\n{\nmRemote = remote;\n}\npublic android.os.IBinder asBinder()\n{\nreturn mRemote;\n}\npublic java.lang.String getInterfaceDescriptor()\n{\nreturn DESCRIPTOR;\n}\npublic void verifyLicense(int responseCode, java.lang.String signedData, java.lang.String signature) throws android.os.RemoteException\n{\nandroid.os.Parcel _data = android.os.Parcel.obtain();\ntry {\n_data.writeInterfaceToken(DESCRIPTOR);\n_data.writeInt(responseCode);\n_data.writeString(signedData);\n_data.writeString(signature);\nmRemote.transact(Stub.TRANSACTION_verifyLicense, _data, null, IBinder.FLAG_ONEWAY);\n}\nfinally {\n_data.recycle();\n}\n}\n}\nstatic final int TRANSACTION_verifyLicense = (IBinder.FIRST_CALL_TRANSACTION + 0);\n}\npublic void verifyLicense(int responseCode, java.lang.String signedData, java.lang.String signature) throws android.os.RemoteException;\n}\n"
  },
  {
    "path": "Projects/Android/playlicensing/src/main/java/com/google/android/vending/licensing/ILicensingService.java",
    "content": "/*\n * This file is auto-generated.  DO NOT MODIFY.\n * Original file: aidl/ILicensingService.aidl\n */\npackage com.google.android.vending.licensing;\nimport java.lang.String;\nimport android.os.RemoteException;\nimport android.os.IBinder;\nimport android.os.IInterface;\nimport android.os.Binder;\nimport android.os.Parcel;\npublic interface ILicensingService extends android.os.IInterface\n{\n/** Local-side IPC implementation stub class. */\npublic static abstract class Stub extends android.os.Binder implements com.google.android.vending.licensing.ILicensingService\n{\nprivate static final java.lang.String DESCRIPTOR = \"com.android.vending.licensing.ILicensingService\";\n/** Construct the stub at attach it to the interface. */\npublic Stub()\n{\nthis.attachInterface(this, DESCRIPTOR);\n}\n/**\n * Cast an IBinder object into an ILicensingService interface,\n * generating a proxy if needed.\n */\npublic static com.google.android.vending.licensing.ILicensingService asInterface(android.os.IBinder obj)\n{\nif ((obj==null)) {\nreturn null;\n}\nandroid.os.IInterface iin = (android.os.IInterface)obj.queryLocalInterface(DESCRIPTOR);\nif (((iin!=null)&&(iin instanceof com.google.android.vending.licensing.ILicensingService))) {\nreturn ((com.google.android.vending.licensing.ILicensingService)iin);\n}\nreturn new com.google.android.vending.licensing.ILicensingService.Stub.Proxy(obj);\n}\npublic android.os.IBinder asBinder()\n{\nreturn this;\n}\npublic boolean onTransact(int code, android.os.Parcel data, android.os.Parcel reply, int flags) throws android.os.RemoteException\n{\nswitch (code)\n{\ncase INTERFACE_TRANSACTION:\n{\nreply.writeString(DESCRIPTOR);\nreturn true;\n}\ncase TRANSACTION_checkLicense:\n{\ndata.enforceInterface(DESCRIPTOR);\nlong _arg0;\n_arg0 = data.readLong();\njava.lang.String _arg1;\n_arg1 = data.readString();\ncom.google.android.vending.licensing.ILicenseResultListener _arg2;\n_arg2 = com.google.android.vending.licensing.ILicenseResultListener.Stub.asInterface(data.readStrongBinder());\nthis.checkLicense(_arg0, _arg1, _arg2);\nreturn true;\n}\n}\nreturn super.onTransact(code, data, reply, flags);\n}\nprivate static class Proxy implements com.google.android.vending.licensing.ILicensingService\n{\nprivate android.os.IBinder mRemote;\nProxy(android.os.IBinder remote)\n{\nmRemote = remote;\n}\npublic android.os.IBinder asBinder()\n{\nreturn mRemote;\n}\npublic java.lang.String getInterfaceDescriptor()\n{\nreturn DESCRIPTOR;\n}\npublic void checkLicense(long nonce, java.lang.String packageName, com.google.android.vending.licensing.ILicenseResultListener listener) throws android.os.RemoteException\n{\nandroid.os.Parcel _data = android.os.Parcel.obtain();\ntry {\n_data.writeInterfaceToken(DESCRIPTOR);\n_data.writeLong(nonce);\n_data.writeString(packageName);\n_data.writeStrongBinder((((listener!=null))?(listener.asBinder()):(null)));\nmRemote.transact(Stub.TRANSACTION_checkLicense, _data, null, IBinder.FLAG_ONEWAY);\n}\nfinally {\n_data.recycle();\n}\n}\n}\nstatic final int TRANSACTION_checkLicense = (IBinder.FIRST_CALL_TRANSACTION + 0);\n}\npublic void checkLicense(long nonce, java.lang.String packageName, com.google.android.vending.licensing.ILicenseResultListener listener) throws android.os.RemoteException;\n}\n"
  },
  {
    "path": "Projects/Android/playlicensing/src/main/java/com/google/android/vending/licensing/LicenseChecker.java",
    "content": "/*\n * Copyright (C) 2010 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.google.android.vending.licensing;\n\nimport com.google.android.vending.licensing.util.Base64;\nimport com.google.android.vending.licensing.util.Base64DecoderException;\n\nimport android.content.ComponentName;\nimport android.content.Context;\nimport android.content.Intent;\nimport android.content.ServiceConnection;\nimport android.content.pm.PackageManager.NameNotFoundException;\nimport android.os.Handler;\nimport android.os.HandlerThread;\nimport android.os.IBinder;\nimport android.os.RemoteException;\nimport android.provider.Settings.Secure;\nimport android.util.Log;\n\nimport java.security.KeyFactory;\nimport java.security.NoSuchAlgorithmException;\nimport java.security.PublicKey;\nimport java.security.SecureRandom;\nimport java.security.spec.InvalidKeySpecException;\nimport java.security.spec.X509EncodedKeySpec;\nimport java.util.Date;\nimport java.util.HashSet;\nimport java.util.LinkedList;\nimport java.util.Queue;\nimport java.util.Set;\n\n/**\n * Client library for Android Market license verifications.\n * <p>\n * The LicenseChecker is configured via a {@link Policy} which contains the\n * logic to determine whether a user should have access to the application. For\n * example, the Policy can define a threshold for allowable number of server or\n * client failures before the library reports the user as not having access.\n * <p>\n * Must also provide the Base64-encoded RSA public key associated with your\n * developer account. The public key is obtainable from the publisher site.\n */\npublic class LicenseChecker implements ServiceConnection {\n    private static final String TAG = \"LicenseChecker\";\n\n    private static final String KEY_FACTORY_ALGORITHM = \"RSA\";\n\n    // Timeout value (in milliseconds) for calls to service.\n    private static final int TIMEOUT_MS = 10 * 1000;\n\n    private static final SecureRandom RANDOM = new SecureRandom();\n    private static final boolean DEBUG_LICENSE_ERROR = false;\n\n    private ILicensingService mService;\n\n    private PublicKey mPublicKey;\n    private final Context mContext;\n    private final Policy mPolicy;\n    /**\n     * A handler for running tasks on a background thread. We don't want license\n     * processing to block the UI thread.\n     */\n    private Handler mHandler;\n    private final String mPackageName;\n    private final String mVersionCode;\n    private final Set<LicenseValidator> mChecksInProgress = new HashSet<LicenseValidator>();\n    private final Queue<LicenseValidator> mPendingChecks = new LinkedList<LicenseValidator>();\n\n    /**\n     * @param context a Context\n     * @param policy implementation of Policy\n     * @param encodedPublicKey Base64-encoded RSA public key\n     * @throws IllegalArgumentException if encodedPublicKey is invalid\n     */\n    public LicenseChecker(Context context, Policy policy, String encodedPublicKey) {\n        mContext = context;\n        mPolicy = policy;\n        mPublicKey = generatePublicKey(encodedPublicKey);\n        mPackageName = mContext.getPackageName();\n        mVersionCode = getVersionCode(context, mPackageName);\n        HandlerThread handlerThread = new HandlerThread(\"background thread\");\n        handlerThread.start();\n        mHandler = new Handler(handlerThread.getLooper());\n    }\n\n    /**\n     * Generates a PublicKey instance from a string containing the\n     * Base64-encoded public key.\n     * \n     * @param encodedPublicKey Base64-encoded public key\n     * @throws IllegalArgumentException if encodedPublicKey is invalid\n     */\n    private static PublicKey generatePublicKey(String encodedPublicKey) {\n        try {\n            byte[] decodedKey = Base64.decode(encodedPublicKey);\n            KeyFactory keyFactory = KeyFactory.getInstance(KEY_FACTORY_ALGORITHM);\n\n            return keyFactory.generatePublic(new X509EncodedKeySpec(decodedKey));\n        } catch (NoSuchAlgorithmException e) {\n            // This won't happen in an Android-compatible environment.\n            throw new RuntimeException(e);\n        } catch (Base64DecoderException e) {\n            Log.e(TAG, \"Could not decode from Base64.\");\n            throw new IllegalArgumentException(e);\n        } catch (InvalidKeySpecException e) {\n            Log.e(TAG, \"Invalid key specification.\");\n            throw new IllegalArgumentException(e);\n        }\n    }\n\n    /**\n     * Checks if the user should have access to the app.  Binds the service if necessary.\n     * <p>\n     * NOTE: This call uses a trivially obfuscated string (base64-encoded).  For best security,\n     * we recommend obfuscating the string that is passed into bindService using another method\n     * of your own devising.\n     * <p>\n     * source string: \"com.android.vending.licensing.ILicensingService\"\n     * <p>\n     * @param callback\n     */\n    public synchronized void checkAccess(LicenseCheckerCallback callback) {\n        // If we have a valid recent LICENSED response, we can skip asking\n        // Market.\n        if (mPolicy.allowAccess()) {\n            Log.i(TAG, \"Using cached license response\");\n            callback.allow(Policy.LICENSED);\n        } else {\n            LicenseValidator validator = new LicenseValidator(mPolicy, new NullDeviceLimiter(),\n                    callback, generateNonce(), mPackageName, mVersionCode);\n\n            if (mService == null) {\n                Log.i(TAG, \"Binding to licensing service.\");\n                try {\n                    Intent serviceIntent = new Intent(new String(Base64.decode(\"Y29tLmFuZHJvaWQudmVuZGluZy5saWNlbnNpbmcuSUxpY2Vuc2luZ1NlcnZpY2U=\")));\n                    serviceIntent.setPackage(\"com.android.vending\");\n\n                    boolean bindResult = mContext\n                            .bindService(\n                                    serviceIntent,\n                                    this, // ServiceConnection.\n                                    Context.BIND_AUTO_CREATE);\n\n                    if (bindResult) {\n                        mPendingChecks.offer(validator);\n                    } else {\n                        Log.e(TAG, \"Could not bind to service.\");\n                        handleServiceConnectionError(validator);\n                    }\n                } catch (SecurityException e) {\n                    callback.applicationError(LicenseCheckerCallback.ERROR_MISSING_PERMISSION);\n                } catch (Base64DecoderException e) {\n                    e.printStackTrace();\n                }\n            } else {\n                mPendingChecks.offer(validator);\n                runChecks();\n            }\n        }\n    }\n\n    private void runChecks() {\n        LicenseValidator validator;\n        while ((validator = mPendingChecks.poll()) != null) {\n            try {\n                Log.i(TAG, \"Calling checkLicense on service for \" + validator.getPackageName());\n                mService.checkLicense(\n                        validator.getNonce(), validator.getPackageName(),\n                        new ResultListener(validator));\n                mChecksInProgress.add(validator);\n            } catch (RemoteException e) {\n                Log.w(TAG, \"RemoteException in checkLicense call.\", e);\n                handleServiceConnectionError(validator);\n            }\n        }\n    }\n\n    private synchronized void finishCheck(LicenseValidator validator) {\n        mChecksInProgress.remove(validator);\n        if (mChecksInProgress.isEmpty()) {\n            cleanupService();\n        }\n    }\n\n    private class ResultListener extends ILicenseResultListener.Stub {\n        private final LicenseValidator mValidator;\n        private Runnable mOnTimeout;\n\n        public ResultListener(LicenseValidator validator) {\n            mValidator = validator;\n            mOnTimeout = new Runnable() {\n                public void run() {\n                    Log.i(TAG, \"Check timed out.\");\n                    handleServiceConnectionError(mValidator);\n                    finishCheck(mValidator);\n                }\n            };\n            startTimeout();\n        }\n\n        private static final int ERROR_CONTACTING_SERVER = 0x101;\n        private static final int ERROR_INVALID_PACKAGE_NAME = 0x102;\n        private static final int ERROR_NON_MATCHING_UID = 0x103;\n\n        // Runs in IPC thread pool. Post it to the Handler, so we can guarantee\n        // either this or the timeout runs.\n        public void verifyLicense(final int responseCode, final String signedData,\n                final String signature) {\n            mHandler.post(new Runnable() {\n                public void run() {\n                    Log.i(TAG, \"Received response.\");\n                    // Make sure it hasn't already timed out.\n                    if (mChecksInProgress.contains(mValidator)) {\n                        clearTimeout();\n                        mValidator.verify(mPublicKey, responseCode, signedData, signature);\n                        finishCheck(mValidator);\n                    }\n                    if (DEBUG_LICENSE_ERROR) {\n                        boolean logResponse;\n                        String stringError = null;\n                        switch (responseCode) {\n                            case ERROR_CONTACTING_SERVER:\n                                logResponse = true;\n                                stringError = \"ERROR_CONTACTING_SERVER\";\n                                break;\n                            case ERROR_INVALID_PACKAGE_NAME:\n                                logResponse = true;\n                                stringError = \"ERROR_INVALID_PACKAGE_NAME\";\n                                break;\n                            case ERROR_NON_MATCHING_UID:\n                                logResponse = true;\n                                stringError = \"ERROR_NON_MATCHING_UID\";\n                                break;\n                            default:\n                                logResponse = false;\n                        }\n\n                        if (logResponse) {\n                            String android_id = Secure.getString(mContext.getContentResolver(),\n                                    Secure.ANDROID_ID);\n                            Date date = new Date();\n                            Log.d(TAG, \"Server Failure: \" + stringError);\n                            Log.d(TAG, \"Android ID: \" + android_id);\n                            Log.d(TAG, \"Time: \" + date.toGMTString());\n                        }\n                    }\n\n                }\n            });\n        }\n\n        private void startTimeout() {\n            Log.i(TAG, \"Start monitoring timeout.\");\n            mHandler.postDelayed(mOnTimeout, TIMEOUT_MS);\n        }\n\n        private void clearTimeout() {\n            Log.i(TAG, \"Clearing timeout.\");\n            mHandler.removeCallbacks(mOnTimeout);\n        }\n    }\n\n    public synchronized void onServiceConnected(ComponentName name, IBinder service) {\n        mService = ILicensingService.Stub.asInterface(service);\n        runChecks();\n    }\n\n    public synchronized void onServiceDisconnected(ComponentName name) {\n        // Called when the connection with the service has been\n        // unexpectedly disconnected. That is, Market crashed.\n        // If there are any checks in progress, the timeouts will handle them.\n        Log.w(TAG, \"Service unexpectedly disconnected.\");\n        mService = null;\n    }\n\n    /**\n     * Generates policy response for service connection errors, as a result of\n     * disconnections or timeouts.\n     */\n    private synchronized void handleServiceConnectionError(LicenseValidator validator) {\n        mPolicy.processServerResponse(Policy.RETRY, null);\n\n        if (mPolicy.allowAccess()) {\n            validator.getCallback().allow(Policy.RETRY);\n        } else {\n            validator.getCallback().dontAllow(Policy.RETRY);\n        }\n    }\n\n    /** Unbinds service if necessary and removes reference to it. */\n    private void cleanupService() {\n        if (mService != null) {\n            try {\n                mContext.unbindService(this);\n            } catch (IllegalArgumentException e) {\n                // Somehow we've already been unbound. This is a non-fatal\n                // error.\n                Log.e(TAG, \"Unable to unbind from licensing service (already unbound)\");\n            }\n            mService = null;\n        }\n    }\n\n    /**\n     * Inform the library that the context is about to be destroyed, so that any\n     * open connections can be cleaned up.\n     * <p>\n     * Failure to call this method can result in a crash under certain\n     * circumstances, such as during screen rotation if an Activity requests the\n     * license check or when the user exits the application.\n     */\n    public synchronized void onDestroy() {\n        cleanupService();\n        mHandler.getLooper().quit();\n    }\n\n    /** Generates a nonce (number used once). */\n    private int generateNonce() {\n        return RANDOM.nextInt();\n    }\n\n    /**\n     * Get version code for the application package name.\n     * \n     * @param context\n     * @param packageName application package name\n     * @return the version code or empty string if package not found\n     */\n    private static String getVersionCode(Context context, String packageName) {\n        try {\n            return String.valueOf(context.getPackageManager().getPackageInfo(packageName, 0).\n                    versionCode);\n        } catch (NameNotFoundException e) {\n            Log.e(TAG, \"Package not found. could not get version code.\");\n            return \"\";\n        }\n    }\n}\n"
  },
  {
    "path": "Projects/Android/playlicensing/src/main/java/com/google/android/vending/licensing/LicenseCheckerCallback.java",
    "content": "/*\n * Copyright (C) 2010 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.google.android.vending.licensing;\n\n/**\n * Callback for the license checker library.\n * <p>\n * Upon checking with the Market server and conferring with the {@link Policy},\n * the library calls the appropriate callback method to communicate the result.\n * <p>\n * <b>The callback does not occur in the original checking thread.</b> Your\n * application should post to the appropriate handling thread or lock\n * accordingly.\n * <p>\n * The reason that is passed back with allow/dontAllow is the base status handed\n * to the policy for allowed/disallowing the license. Policy.RETRY will call\n * allow or dontAllow depending on other statistics associated with the policy,\n * while in most cases Policy.NOT_LICENSED will call dontAllow and\n * Policy.LICENSED will Allow.\n */\npublic interface LicenseCheckerCallback {\n\n    /**\n     * Allow use. App should proceed as normal.\n     * \n     * @param reason Policy.LICENSED or Policy.RETRY typically. (although in\n     *            theory the policy can return Policy.NOT_LICENSED here as well)\n     */\n    public void allow(int reason);\n\n    /**\n     * Don't allow use. App should inform user and take appropriate action.\n     * \n     * @param reason Policy.NOT_LICENSED or Policy.RETRY. (although in theory\n     *            the policy can return Policy.LICENSED here as well ---\n     *            perhaps the call to the LVL took too long, for example)\n     */\n    public void dontAllow(int reason);\n\n    /** Application error codes. */\n    public static final int ERROR_INVALID_PACKAGE_NAME = 1;\n    public static final int ERROR_NON_MATCHING_UID = 2;\n    public static final int ERROR_NOT_MARKET_MANAGED = 3;\n    public static final int ERROR_CHECK_IN_PROGRESS = 4;\n    public static final int ERROR_INVALID_PUBLIC_KEY = 5;\n    public static final int ERROR_MISSING_PERMISSION = 6;\n\n    /**\n     * Error in application code. Caller did not call or set up license checker\n     * correctly. Should be considered fatal.\n     */\n    public void applicationError(int errorCode);\n}\n"
  },
  {
    "path": "Projects/Android/playlicensing/src/main/java/com/google/android/vending/licensing/LicenseValidator.java",
    "content": "/*\n * Copyright (C) 2010 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.google.android.vending.licensing;\n\nimport com.google.android.vending.licensing.util.Base64;\nimport com.google.android.vending.licensing.util.Base64DecoderException;\n\nimport android.text.TextUtils;\nimport android.util.Log;\n\nimport java.security.InvalidKeyException;\nimport java.security.NoSuchAlgorithmException;\nimport java.security.PublicKey;\nimport java.security.Signature;\nimport java.security.SignatureException;\n\n/**\n * Contains data related to a licensing request and methods to verify\n * and process the response.\n */\nclass LicenseValidator {\n    private static final String TAG = \"LicenseValidator\";\n\n    // Server response codes.\n    private static final int LICENSED = 0x0;\n    private static final int NOT_LICENSED = 0x1;\n    private static final int LICENSED_OLD_KEY = 0x2;\n    private static final int ERROR_NOT_MARKET_MANAGED = 0x3;\n    private static final int ERROR_SERVER_FAILURE = 0x4;\n    private static final int ERROR_OVER_QUOTA = 0x5;\n\n    private static final int ERROR_CONTACTING_SERVER = 0x101;\n    private static final int ERROR_INVALID_PACKAGE_NAME = 0x102;\n    private static final int ERROR_NON_MATCHING_UID = 0x103;\n\n    private final Policy mPolicy;\n    private final LicenseCheckerCallback mCallback;\n    private final int mNonce;\n    private final String mPackageName;\n    private final String mVersionCode;\n    private final DeviceLimiter mDeviceLimiter;\n\n    LicenseValidator(Policy policy, DeviceLimiter deviceLimiter, LicenseCheckerCallback callback,\n             int nonce, String packageName, String versionCode) {\n        mPolicy = policy;\n        mDeviceLimiter = deviceLimiter;\n        mCallback = callback;\n        mNonce = nonce;\n        mPackageName = packageName;\n        mVersionCode = versionCode;\n    }\n\n    public LicenseCheckerCallback getCallback() {\n        return mCallback;\n    }\n\n    public int getNonce() {\n        return mNonce;\n    }\n\n    public String getPackageName() {\n        return mPackageName;\n    }\n\n    private static final String SIGNATURE_ALGORITHM = \"SHA1withRSA\";\n\n    /**\n     * Verifies the response from server and calls appropriate callback method.\n     *\n     * @param publicKey public key associated with the developer account\n     * @param responseCode server response code\n     * @param signedData signed data from server\n     * @param signature server signature\n     */\n    public void verify(PublicKey publicKey, int responseCode, String signedData, String signature) {\n        String userId = null;\n        // Skip signature check for unsuccessful requests\n        ResponseData data = null;\n        if (responseCode == LICENSED || responseCode == NOT_LICENSED ||\n                responseCode == LICENSED_OLD_KEY) {\n            // Verify signature.\n            try {\n                Signature sig = Signature.getInstance(SIGNATURE_ALGORITHM);\n                sig.initVerify(publicKey);\n                sig.update(signedData.getBytes());\n\n                if (!sig.verify(Base64.decode(signature))) {\n                    Log.e(TAG, \"Signature verification failed.\");\n                    handleInvalidResponse();\n                    return;\n                }\n            } catch (NoSuchAlgorithmException e) {\n                // This can't happen on an Android compatible device.\n                throw new RuntimeException(e);\n            } catch (InvalidKeyException e) {\n                handleApplicationError(LicenseCheckerCallback.ERROR_INVALID_PUBLIC_KEY);\n                return;\n            } catch (SignatureException e) {\n                throw new RuntimeException(e);\n            } catch (Base64DecoderException e) {\n                Log.e(TAG, \"Could not Base64-decode signature.\");\n                handleInvalidResponse();\n                return;\n            }\n\n            // Parse and validate response.\n            try {\n                data = ResponseData.parse(signedData);\n            } catch (IllegalArgumentException e) {\n                Log.e(TAG, \"Could not parse response.\");\n                handleInvalidResponse();\n                return;\n            }\n\n            if (data.responseCode != responseCode) {\n                Log.e(TAG, \"Response codes don't match.\");\n                handleInvalidResponse();\n                return;\n            }\n\n            if (data.nonce != mNonce) {\n                Log.e(TAG, \"Nonce doesn't match.\");\n                handleInvalidResponse();\n                return;\n            }\n\n            if (!data.packageName.equals(mPackageName)) {\n                Log.e(TAG, \"Package name doesn't match.\");\n                handleInvalidResponse();\n                return;\n            }\n\n            if (!data.versionCode.equals(mVersionCode)) {\n                Log.e(TAG, \"Version codes don't match.\");\n                handleInvalidResponse();\n                return;\n            }\n\n            // Application-specific user identifier.\n            userId = data.userId;\n            if (TextUtils.isEmpty(userId)) {\n                Log.e(TAG, \"User identifier is empty.\");\n                handleInvalidResponse();\n                return;\n            }\n        }\n\n        switch (responseCode) {\n            case LICENSED:\n            case LICENSED_OLD_KEY:\n                int limiterResponse = mDeviceLimiter.isDeviceAllowed(userId);\n                handleResponse(limiterResponse, data);\n                break;\n            case NOT_LICENSED:\n                handleResponse(Policy.NOT_LICENSED, data);\n                break;\n            case ERROR_CONTACTING_SERVER:\n                Log.w(TAG, \"Error contacting licensing server.\");\n                handleResponse(Policy.RETRY, data);\n                break;\n            case ERROR_SERVER_FAILURE:\n                Log.w(TAG, \"An error has occurred on the licensing server.\");\n                handleResponse(Policy.RETRY, data);\n                break;\n            case ERROR_OVER_QUOTA:\n                Log.w(TAG, \"Licensing server is refusing to talk to this device, over quota.\");\n                handleResponse(Policy.RETRY, data);\n                break;\n            case ERROR_INVALID_PACKAGE_NAME:\n                handleApplicationError(LicenseCheckerCallback.ERROR_INVALID_PACKAGE_NAME);\n                break;\n            case ERROR_NON_MATCHING_UID:\n                handleApplicationError(LicenseCheckerCallback.ERROR_NON_MATCHING_UID);\n                break;\n            case ERROR_NOT_MARKET_MANAGED:\n                handleApplicationError(LicenseCheckerCallback.ERROR_NOT_MARKET_MANAGED);\n                break;\n            default:\n                Log.e(TAG, \"Unknown response code for license check.\");\n                handleInvalidResponse();\n        }\n    }\n\n    /**\n     * Confers with policy and calls appropriate callback method.\n     *\n     * @param response\n     * @param rawData\n     */\n    private void handleResponse(int response, ResponseData rawData) {\n        // Update policy data and increment retry counter (if needed)\n        mPolicy.processServerResponse(response, rawData);\n\n        // Given everything we know, including cached data, ask the policy if we should grant\n        // access.\n        if (mPolicy.allowAccess()) {\n            mCallback.allow(response);\n        } else {\n            mCallback.dontAllow(response);\n        }\n    }\n\n    private void handleApplicationError(int code) {\n        mCallback.applicationError(code);\n    }\n\n    private void handleInvalidResponse() {\n        mCallback.dontAllow(Policy.NOT_LICENSED);\n    }\n}\n"
  },
  {
    "path": "Projects/Android/playlicensing/src/main/java/com/google/android/vending/licensing/NullDeviceLimiter.java",
    "content": "/*\n * Copyright (C) 2010 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.google.android.vending.licensing;\n\n/**\n * A DeviceLimiter that doesn't limit the number of devices that can use a\n * given user's license.\n * <p>\n * Unless you have reason to believe that your application is being pirated\n * by multiple users using the same license (signing in to Market as the same\n * user), we recommend you use this implementation.\n */\npublic class NullDeviceLimiter implements DeviceLimiter {\n\n    public int isDeviceAllowed(String userId) {\n        return Policy.LICENSED;\n    }\n}\n"
  },
  {
    "path": "Projects/Android/playlicensing/src/main/java/com/google/android/vending/licensing/Obfuscator.java",
    "content": "/*\n * Copyright (C) 2010 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.google.android.vending.licensing;\n\n/**\n * Interface used as part of a {@link Policy} to allow application authors to obfuscate\n * licensing data that will be stored into a SharedPreferences file.\n * <p>\n * Any transformation scheme must be reversable. Implementing classes may optionally implement an\n * integrity check to further prevent modification to preference data. Implementing classes\n * should use device-specific information as a key in the obfuscation algorithm to prevent\n * obfuscated preferences from being shared among devices.\n */\npublic interface Obfuscator {\n\n    /**\n     * Obfuscate a string that is being stored into shared preferences.\n     *\n     * @param original The data that is to be obfuscated.\n     * @param key The key for the data that is to be obfuscated.\n     * @return A transformed version of the original data.\n     */\n    String obfuscate(String original, String key);\n\n    /**\n     * Undo the transformation applied to data by the obfuscate() method.\n     *\n     * @param original The data that is to be obfuscated.\n     * @param key The key for the data that is to be obfuscated.\n     * @return A transformed version of the original data.\n     * @throws ValidationException Optionally thrown if a data integrity check fails.\n     */\n    String unobfuscate(String obfuscated, String key) throws ValidationException;\n}\n"
  },
  {
    "path": "Projects/Android/playlicensing/src/main/java/com/google/android/vending/licensing/Policy.java",
    "content": "/*\n * Copyright (C) 2010 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.google.android.vending.licensing;\n\n/**\n * Policy used by {@link LicenseChecker} to determine whether a user should have\n * access to the application.\n */\npublic interface Policy {\n\n    /**\n     * Change these values to make it more difficult for tools to automatically\n     * strip LVL protection from your APK.\n     */\n\n    /**\n     * LICENSED means that the server returned back a valid license response\n     */\n    public static final int LICENSED = 0x0100;\n    /**\n     * NOT_LICENSED means that the server returned back a valid license response\n     * that indicated that the user definitively is not licensed\n     */\n    public static final int NOT_LICENSED = 0x0231;\n    /**\n     * RETRY means that the license response was unable to be determined ---\n     * perhaps as a result of faulty networking\n     */\n    public static final int RETRY = 0x0123;\n\n    /**\n     * Provide results from contact with the license server. Retry counts are\n     * incremented if the current value of response is RETRY. Results will be\n     * used for any future policy decisions.\n     * \n     * @param response the result from validating the server response\n     * @param rawData the raw server response data, can be null for RETRY\n     */\n    void processServerResponse(int response, ResponseData rawData);\n\n    /**\n     * Check if the user should be allowed access to the application.\n     */\n    boolean allowAccess();\n}\n"
  },
  {
    "path": "Projects/Android/playlicensing/src/main/java/com/google/android/vending/licensing/PreferenceObfuscator.java",
    "content": "/*\n * Copyright (C) 2010 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.google.android.vending.licensing;\n\nimport android.content.SharedPreferences;\nimport android.util.Log;\n\n/**\n * An wrapper for SharedPreferences that transparently performs data obfuscation.\n */\npublic class PreferenceObfuscator {\n\n    private static final String TAG = \"PreferenceObfuscator\";\n\n    private final SharedPreferences mPreferences;\n    private final Obfuscator mObfuscator;\n    private SharedPreferences.Editor mEditor;\n\n    /**\n     * Constructor.\n     *\n     * @param sp A SharedPreferences instance provided by the system.\n     * @param o The Obfuscator to use when reading or writing data.\n     */\n    public PreferenceObfuscator(SharedPreferences sp, Obfuscator o) {\n        mPreferences = sp;\n        mObfuscator = o;\n        mEditor = null;\n    }\n\n    public void putString(String key, String value) {\n        if (mEditor == null) {\n            mEditor = mPreferences.edit();\n        }\n        String obfuscatedValue = mObfuscator.obfuscate(value, key);\n        mEditor.putString(key, obfuscatedValue);\n    }\n\n    public String getString(String key, String defValue) {\n        String result;\n        String value = mPreferences.getString(key, null);\n        if (value != null) {\n            try {\n                result = mObfuscator.unobfuscate(value, key);\n            } catch (ValidationException e) {\n                // Unable to unobfuscate, data corrupt or tampered\n                Log.w(TAG, \"Validation error while reading preference: \" + key);\n                result = defValue;\n            }\n        } else {\n            // Preference not found\n            result = defValue;\n        }\n        return result;\n    }\n\n    public void commit() {\n        if (mEditor != null) {\n            mEditor.commit();\n            mEditor = null;\n        }\n    }\n}\n"
  },
  {
    "path": "Projects/Android/playlicensing/src/main/java/com/google/android/vending/licensing/ResponseData.java",
    "content": "/*\n * Copyright (C) 2010 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.google.android.vending.licensing;\n\nimport java.util.regex.Pattern;\n\nimport android.text.TextUtils;\n\n/**\n * ResponseData from licensing server.\n */\npublic class ResponseData {\n\n    public int responseCode;\n    public int nonce;\n    public String packageName;\n    public String versionCode;\n    public String userId;\n    public long timestamp;\n    /** Response-specific data. */\n    public String extra;\n\n    /**\n     * Parses response string into ResponseData.\n     *\n     * @param responseData response data string\n     * @throws IllegalArgumentException upon parsing error\n     * @return ResponseData object\n     */\n    public static ResponseData parse(String responseData) {\n        // Must parse out main response data and response-specific data.\n    \tint index = responseData.indexOf(':');\n    \tString mainData, extraData;\n    \tif ( -1 == index ) {\n    \t\tmainData = responseData;\n    \t\textraData = \"\";\n    \t} else {\n    \t\tmainData = responseData.substring(0, index);\n    \t\textraData = index >= responseData.length() ? \"\" : responseData.substring(index+1);\n    \t}\n\n        String [] fields = TextUtils.split(mainData, Pattern.quote(\"|\"));\n        if (fields.length < 6) {\n            throw new IllegalArgumentException(\"Wrong number of fields.\");\n        }\n\n        ResponseData data = new ResponseData();\n        data.extra = extraData;\n        data.responseCode = Integer.parseInt(fields[0]);\n        data.nonce = Integer.parseInt(fields[1]);\n        data.packageName = fields[2];\n        data.versionCode = fields[3];\n        // Application-specific user identifier.\n        data.userId = fields[4];\n        data.timestamp = Long.parseLong(fields[5]);\n\n        return data;\n    }\n\n    @Override\n    public String toString() {\n        return TextUtils.join(\"|\", new Object [] { responseCode, nonce, packageName, versionCode,\n            userId, timestamp });\n    }\n}\n"
  },
  {
    "path": "Projects/Android/playlicensing/src/main/java/com/google/android/vending/licensing/ServerManagedPolicy.java",
    "content": "/*\n * Copyright (C) 2010 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.google.android.vending.licensing;\n\nimport org.apache.http.NameValuePair;\nimport org.apache.http.client.utils.URLEncodedUtils;\n\nimport java.net.URI;\nimport java.net.URISyntaxException;\nimport java.util.HashMap;\nimport java.util.List;\nimport java.util.Map;\n\nimport android.content.Context;\nimport android.content.SharedPreferences;\nimport android.util.Log;\n\n/**\n * Default policy. All policy decisions are based off of response data received\n * from the licensing service. Specifically, the licensing server sends the\n * following information: response validity period, error retry period, and\n * error retry count.\n * <p>\n * These values will vary based on the the way the application is configured in\n * the Android Market publishing console, such as whether the application is\n * marked as free or is within its refund period, as well as how often an\n * application is checking with the licensing service.\n * <p>\n * Developers who need more fine grained control over their application's\n * licensing policy should implement a custom Policy.\n */\npublic class ServerManagedPolicy implements Policy {\n\n    private static final String TAG = \"ServerManagedPolicy\";\n    private static final String PREFS_FILE = \"com.android.vending.licensing.ServerManagedPolicy\";\n    private static final String PREF_LAST_RESPONSE = \"lastResponse\";\n    private static final String PREF_VALIDITY_TIMESTAMP = \"validityTimestamp\";\n    private static final String PREF_RETRY_UNTIL = \"retryUntil\";\n    private static final String PREF_MAX_RETRIES = \"maxRetries\";\n    private static final String PREF_RETRY_COUNT = \"retryCount\";\n    private static final String DEFAULT_VALIDITY_TIMESTAMP = \"0\";\n    private static final String DEFAULT_RETRY_UNTIL = \"0\";\n    private static final String DEFAULT_MAX_RETRIES = \"0\";\n    private static final String DEFAULT_RETRY_COUNT = \"0\";\n\n    private static final long MILLIS_PER_MINUTE = 60 * 1000;\n\n    private long mValidityTimestamp;\n    private long mRetryUntil;\n    private long mMaxRetries;\n    private long mRetryCount;\n    private long mLastResponseTime = 0;\n    private int mLastResponse;\n    private PreferenceObfuscator mPreferences;\n\n    /**\n     * @param context The context for the current application\n     * @param obfuscator An obfuscator to be used with preferences.\n     */\n    public ServerManagedPolicy(Context context, Obfuscator obfuscator) {\n        // Import old values\n        SharedPreferences sp = context.getSharedPreferences(PREFS_FILE, Context.MODE_PRIVATE);\n        mPreferences = new PreferenceObfuscator(sp, obfuscator);\n        mLastResponse = Integer.parseInt(\n            mPreferences.getString(PREF_LAST_RESPONSE, Integer.toString(Policy.RETRY)));\n        mValidityTimestamp = Long.parseLong(mPreferences.getString(PREF_VALIDITY_TIMESTAMP,\n                DEFAULT_VALIDITY_TIMESTAMP));\n        mRetryUntil = Long.parseLong(mPreferences.getString(PREF_RETRY_UNTIL, DEFAULT_RETRY_UNTIL));\n        mMaxRetries = Long.parseLong(mPreferences.getString(PREF_MAX_RETRIES, DEFAULT_MAX_RETRIES));\n        mRetryCount = Long.parseLong(mPreferences.getString(PREF_RETRY_COUNT, DEFAULT_RETRY_COUNT));\n    }\n\n    /**\n     * Process a new response from the license server.\n     * <p>\n     * This data will be used for computing future policy decisions. The\n     * following parameters are processed:\n     * <ul>\n     * <li>VT: the timestamp that the client should consider the response\n     *   valid until\n     * <li>GT: the timestamp that the client should ignore retry errors until\n     * <li>GR: the number of retry errors that the client should ignore\n     * </ul>\n     *\n     * @param response the result from validating the server response\n     * @param rawData the raw server response data\n     */\n    public void processServerResponse(int response, ResponseData rawData) {\n\n        // Update retry counter\n        if (response != Policy.RETRY) {\n            setRetryCount(0);\n        } else {\n            setRetryCount(mRetryCount + 1);\n        }\n\n        if (response == Policy.LICENSED) {\n            // Update server policy data\n            Map<String, String> extras = decodeExtras(rawData.extra);\n            mLastResponse = response;\n            setValidityTimestamp(extras.get(\"VT\"));\n            setRetryUntil(extras.get(\"GT\"));\n            setMaxRetries(extras.get(\"GR\"));\n        } else if (response == Policy.NOT_LICENSED) {\n            // Clear out stale policy data\n            setValidityTimestamp(DEFAULT_VALIDITY_TIMESTAMP);\n            setRetryUntil(DEFAULT_RETRY_UNTIL);\n            setMaxRetries(DEFAULT_MAX_RETRIES);\n        }\n\n        setLastResponse(response);\n        mPreferences.commit();\n    }\n\n    /**\n     * Set the last license response received from the server and add to\n     * preferences. You must manually call PreferenceObfuscator.commit() to\n     * commit these changes to disk.\n     *\n     * @param l the response\n     */\n    private void setLastResponse(int l) {\n        mLastResponseTime = System.currentTimeMillis();\n        mLastResponse = l;\n        mPreferences.putString(PREF_LAST_RESPONSE, Integer.toString(l));\n    }\n\n    /**\n     * Set the current retry count and add to preferences. You must manually\n     * call PreferenceObfuscator.commit() to commit these changes to disk.\n     *\n     * @param c the new retry count\n     */\n    private void setRetryCount(long c) {\n        mRetryCount = c;\n        mPreferences.putString(PREF_RETRY_COUNT, Long.toString(c));\n    }\n\n    public long getRetryCount() {\n        return mRetryCount;\n    }\n\n    /**\n     * Set the last validity timestamp (VT) received from the server and add to\n     * preferences. You must manually call PreferenceObfuscator.commit() to\n     * commit these changes to disk.\n     *\n     * @param validityTimestamp the VT string received\n     */\n    private void setValidityTimestamp(String validityTimestamp) {\n        Long lValidityTimestamp;\n        try {\n            lValidityTimestamp = Long.parseLong(validityTimestamp);\n        } catch (NumberFormatException e) {\n            // No response or not parsable, expire in one minute.\n            Log.w(TAG, \"License validity timestamp (VT) missing, caching for a minute\");\n            lValidityTimestamp = System.currentTimeMillis() + MILLIS_PER_MINUTE;\n            validityTimestamp = Long.toString(lValidityTimestamp);\n        }\n\n        mValidityTimestamp = lValidityTimestamp;\n        mPreferences.putString(PREF_VALIDITY_TIMESTAMP, validityTimestamp);\n    }\n\n    public long getValidityTimestamp() {\n        return mValidityTimestamp;\n    }\n\n    /**\n     * Set the retry until timestamp (GT) received from the server and add to\n     * preferences. You must manually call PreferenceObfuscator.commit() to\n     * commit these changes to disk.\n     *\n     * @param retryUntil the GT string received\n     */\n    private void setRetryUntil(String retryUntil) {\n        Long lRetryUntil;\n        try {\n            lRetryUntil = Long.parseLong(retryUntil);\n        } catch (NumberFormatException e) {\n            // No response or not parsable, expire immediately\n            Log.w(TAG, \"License retry timestamp (GT) missing, grace period disabled\");\n            retryUntil = \"0\";\n            lRetryUntil = 0l;\n        }\n\n        mRetryUntil = lRetryUntil;\n        mPreferences.putString(PREF_RETRY_UNTIL, retryUntil);\n    }\n\n    public long getRetryUntil() {\n      return mRetryUntil;\n    }\n\n    /**\n     * Set the max retries value (GR) as received from the server and add to\n     * preferences. You must manually call PreferenceObfuscator.commit() to\n     * commit these changes to disk.\n     *\n     * @param maxRetries the GR string received\n     */\n    private void setMaxRetries(String maxRetries) {\n        Long lMaxRetries;\n        try {\n            lMaxRetries = Long.parseLong(maxRetries);\n        } catch (NumberFormatException e) {\n            // No response or not parsable, expire immediately\n            Log.w(TAG, \"Licence retry count (GR) missing, grace period disabled\");\n            maxRetries = \"0\";\n            lMaxRetries = 0l;\n        }\n\n        mMaxRetries = lMaxRetries;\n        mPreferences.putString(PREF_MAX_RETRIES, maxRetries);\n    }\n\n    public long getMaxRetries() {\n        return mMaxRetries;\n    }\n\n    /**\n     * {@inheritDoc}\n     *\n     * This implementation allows access if either:<br>\n     * <ol>\n     * <li>a LICENSED response was received within the validity period\n     * <li>a RETRY response was received in the last minute, and we are under\n     * the RETRY count or in the RETRY period.\n     * </ol>\n     */\n    public boolean allowAccess() {\n        long ts = System.currentTimeMillis();\n        if (mLastResponse == Policy.LICENSED) {\n            // Check if the LICENSED response occurred within the validity timeout.\n            if (ts <= mValidityTimestamp) {\n                // Cached LICENSED response is still valid.\n                return true;\n            }\n        } else if (mLastResponse == Policy.RETRY &&\n                   ts < mLastResponseTime + MILLIS_PER_MINUTE) {\n            // Only allow access if we are within the retry period or we haven't used up our\n            // max retries.\n            return (ts <= mRetryUntil || mRetryCount <= mMaxRetries);\n        }\n        return false;\n    }\n\n    private Map<String, String> decodeExtras(String extras) {\n        Map<String, String> results = new HashMap<String, String>();\n        try {\n            URI rawExtras = new URI(\"?\" + extras);\n            List<NameValuePair> extraList = URLEncodedUtils.parse(rawExtras, \"UTF-8\");\n            for (NameValuePair item : extraList) {\n                results.put(item.getName(), item.getValue());\n            }\n        } catch (URISyntaxException e) {\n          Log.w(TAG, \"Invalid syntax error while decoding extras data from server.\");\n        }\n        return results;\n    }\n\n}\n"
  },
  {
    "path": "Projects/Android/playlicensing/src/main/java/com/google/android/vending/licensing/StrictPolicy.java",
    "content": "/*\n * Copyright (C) 2010 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.google.android.vending.licensing;\n\n/**\n * Non-caching policy. All requests will be sent to the licensing service,\n * and no local caching is performed.\n * <p>\n * Using a non-caching policy ensures that there is no local preference data\n * for malicious users to tamper with. As a side effect, applications\n * will not be permitted to run while offline. Developers should carefully\n * weigh the risks of using this Policy over one which implements caching,\n * such as ServerManagedPolicy.\n * <p>\n * Access to the application is only allowed if a LICESNED response is.\n * received. All other responses (including RETRY) will deny access.\n */\npublic class StrictPolicy implements Policy {\n\n    private int mLastResponse;\n\n    public StrictPolicy() {\n        // Set default policy. This will force the application to check the policy on launch.\n        mLastResponse = Policy.RETRY;\n    }\n\n    /**\n     * Process a new response from the license server. Since we aren't\n     * performing any caching, this equates to reading the LicenseResponse.\n     * Any ResponseData provided is ignored.\n     *\n     * @param response the result from validating the server response\n     * @param rawData the raw server response data\n     */\n    public void processServerResponse(int response, ResponseData rawData) {\n        mLastResponse = response;\n    }\n\n    /**\n     * {@inheritDoc}\n     *\n     * This implementation allows access if and only if a LICENSED response\n     * was received the last time the server was contacted.\n     */\n    public boolean allowAccess() {\n        return (mLastResponse == Policy.LICENSED);\n    }\n\n}\n"
  },
  {
    "path": "Projects/Android/playlicensing/src/main/java/com/google/android/vending/licensing/ValidationException.java",
    "content": "/*\n * Copyright (C) 2010 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.google.android.vending.licensing;\n\n/**\n * Indicates that an error occurred while validating the integrity of data managed by an\n * {@link Obfuscator}.}\n */\npublic class ValidationException extends Exception {\n    public ValidationException() {\n      super();\n    }\n\n    public ValidationException(String s) {\n      super(s);\n    }\n\n    private static final long serialVersionUID = 1L;\n}\n"
  },
  {
    "path": "Projects/Android/playlicensing/src/main/java/com/google/android/vending/licensing/util/Base64.java",
    "content": "// Portions copyright 2002, Google, Inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n//     http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\npackage com.google.android.vending.licensing.util;\n\n// This code was converted from code at http://iharder.sourceforge.net/base64/\n// Lots of extraneous features were removed.\n/* The original code said:\n * <p>\n * I am placing this code in the Public Domain. Do with it as you will.\n * This software comes with no guarantees or warranties but with\n * plenty of well-wishing instead!\n * Please visit\n * <a href=\"http://iharder.net/xmlizable\">http://iharder.net/xmlizable</a>\n * periodically to check for updates or to contribute improvements.\n * </p>\n *\n * @author Robert Harder\n * @author rharder@usa.net\n * @version 1.3\n */\n\n/**\n * Base64 converter class. This code is not a full-blown MIME encoder;\n * it simply converts binary data to base64 data and back.\n *\n * <p>Note {@link CharBase64} is a GWT-compatible implementation of this\n * class.\n */\npublic class Base64 {\n  /** Specify encoding (value is {@code true}). */\n  public final static boolean ENCODE = true;\n\n  /** Specify decoding (value is {@code false}). */\n  public final static boolean DECODE = false;\n\n  /** The equals sign (=) as a byte. */\n  private final static byte EQUALS_SIGN = (byte) '=';\n\n  /** The new line character (\\n) as a byte. */\n  private final static byte NEW_LINE = (byte) '\\n';\n\n  /**\n   * The 64 valid Base64 values.\n   */\n  private final static byte[] ALPHABET =\n      {(byte) 'A', (byte) 'B', (byte) 'C', (byte) 'D', (byte) 'E', (byte) 'F',\n          (byte) 'G', (byte) 'H', (byte) 'I', (byte) 'J', (byte) 'K',\n          (byte) 'L', (byte) 'M', (byte) 'N', (byte) 'O', (byte) 'P',\n          (byte) 'Q', (byte) 'R', (byte) 'S', (byte) 'T', (byte) 'U',\n          (byte) 'V', (byte) 'W', (byte) 'X', (byte) 'Y', (byte) 'Z',\n          (byte) 'a', (byte) 'b', (byte) 'c', (byte) 'd', (byte) 'e',\n          (byte) 'f', (byte) 'g', (byte) 'h', (byte) 'i', (byte) 'j',\n          (byte) 'k', (byte) 'l', (byte) 'm', (byte) 'n', (byte) 'o',\n          (byte) 'p', (byte) 'q', (byte) 'r', (byte) 's', (byte) 't',\n          (byte) 'u', (byte) 'v', (byte) 'w', (byte) 'x', (byte) 'y',\n          (byte) 'z', (byte) '0', (byte) '1', (byte) '2', (byte) '3',\n          (byte) '4', (byte) '5', (byte) '6', (byte) '7', (byte) '8',\n          (byte) '9', (byte) '+', (byte) '/'};\n\n  /**\n   * The 64 valid web safe Base64 values.\n   */\n  private final static byte[] WEBSAFE_ALPHABET =\n      {(byte) 'A', (byte) 'B', (byte) 'C', (byte) 'D', (byte) 'E', (byte) 'F',\n          (byte) 'G', (byte) 'H', (byte) 'I', (byte) 'J', (byte) 'K',\n          (byte) 'L', (byte) 'M', (byte) 'N', (byte) 'O', (byte) 'P',\n          (byte) 'Q', (byte) 'R', (byte) 'S', (byte) 'T', (byte) 'U',\n          (byte) 'V', (byte) 'W', (byte) 'X', (byte) 'Y', (byte) 'Z',\n          (byte) 'a', (byte) 'b', (byte) 'c', (byte) 'd', (byte) 'e',\n          (byte) 'f', (byte) 'g', (byte) 'h', (byte) 'i', (byte) 'j',\n          (byte) 'k', (byte) 'l', (byte) 'm', (byte) 'n', (byte) 'o',\n          (byte) 'p', (byte) 'q', (byte) 'r', (byte) 's', (byte) 't',\n          (byte) 'u', (byte) 'v', (byte) 'w', (byte) 'x', (byte) 'y',\n          (byte) 'z', (byte) '0', (byte) '1', (byte) '2', (byte) '3',\n          (byte) '4', (byte) '5', (byte) '6', (byte) '7', (byte) '8',\n          (byte) '9', (byte) '-', (byte) '_'};\n\n  /**\n   * Translates a Base64 value to either its 6-bit reconstruction value\n   * or a negative number indicating some other meaning.\n   **/\n  private final static byte[] DECODABET = {-9, -9, -9, -9, -9, -9, -9, -9, -9, // Decimal  0 -  8\n      -5, -5, // Whitespace: Tab and Linefeed\n      -9, -9, // Decimal 11 - 12\n      -5, // Whitespace: Carriage Return\n      -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, // Decimal 14 - 26\n      -9, -9, -9, -9, -9, // Decimal 27 - 31\n      -5, // Whitespace: Space\n      -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, // Decimal 33 - 42\n      62, // Plus sign at decimal 43\n      -9, -9, -9, // Decimal 44 - 46\n      63, // Slash at decimal 47\n      52, 53, 54, 55, 56, 57, 58, 59, 60, 61, // Numbers zero through nine\n      -9, -9, -9, // Decimal 58 - 60\n      -1, // Equals sign at decimal 61\n      -9, -9, -9, // Decimal 62 - 64\n      0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, // Letters 'A' through 'N'\n      14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, // Letters 'O' through 'Z'\n      -9, -9, -9, -9, -9, -9, // Decimal 91 - 96\n      26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, // Letters 'a' through 'm'\n      39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, // Letters 'n' through 'z'\n      -9, -9, -9, -9, -9 // Decimal 123 - 127\n      /*  ,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,     // Decimal 128 - 139\n        -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,     // Decimal 140 - 152\n        -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,     // Decimal 153 - 165\n        -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,     // Decimal 166 - 178\n        -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,     // Decimal 179 - 191\n        -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,     // Decimal 192 - 204\n        -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,     // Decimal 205 - 217\n        -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,     // Decimal 218 - 230\n        -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,     // Decimal 231 - 243\n        -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9         // Decimal 244 - 255 */\n      };\n\n  /** The web safe decodabet */\n  private final static byte[] WEBSAFE_DECODABET =\n      {-9, -9, -9, -9, -9, -9, -9, -9, -9, // Decimal  0 -  8\n          -5, -5, // Whitespace: Tab and Linefeed\n          -9, -9, // Decimal 11 - 12\n          -5, // Whitespace: Carriage Return\n          -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, // Decimal 14 - 26\n          -9, -9, -9, -9, -9, // Decimal 27 - 31\n          -5, // Whitespace: Space\n          -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, // Decimal 33 - 44\n          62, // Dash '-' sign at decimal 45\n          -9, -9, // Decimal 46-47\n          52, 53, 54, 55, 56, 57, 58, 59, 60, 61, // Numbers zero through nine\n          -9, -9, -9, // Decimal 58 - 60\n          -1, // Equals sign at decimal 61\n          -9, -9, -9, // Decimal 62 - 64\n          0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, // Letters 'A' through 'N'\n          14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, // Letters 'O' through 'Z'\n          -9, -9, -9, -9, // Decimal 91-94\n          63, // Underscore '_' at decimal 95\n          -9, // Decimal 96\n          26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, // Letters 'a' through 'm'\n          39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, // Letters 'n' through 'z'\n          -9, -9, -9, -9, -9 // Decimal 123 - 127\n      /*  ,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,     // Decimal 128 - 139\n        -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,     // Decimal 140 - 152\n        -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,     // Decimal 153 - 165\n        -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,     // Decimal 166 - 178\n        -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,     // Decimal 179 - 191\n        -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,     // Decimal 192 - 204\n        -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,     // Decimal 205 - 217\n        -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,     // Decimal 218 - 230\n        -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,     // Decimal 231 - 243\n        -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9         // Decimal 244 - 255 */\n      };\n\n  // Indicates white space in encoding\n  private final static byte WHITE_SPACE_ENC = -5;\n  // Indicates equals sign in encoding\n  private final static byte EQUALS_SIGN_ENC = -1;\n\n  /** Defeats instantiation. */\n  private Base64() {\n  }\n\n  /* ********  E N C O D I N G   M E T H O D S  ******** */\n\n  /**\n   * Encodes up to three bytes of the array <var>source</var>\n   * and writes the resulting four Base64 bytes to <var>destination</var>.\n   * The source and destination arrays can be manipulated\n   * anywhere along their length by specifying\n   * <var>srcOffset</var> and <var>destOffset</var>.\n   * This method does not check to make sure your arrays\n   * are large enough to accommodate <var>srcOffset</var> + 3 for\n   * the <var>source</var> array or <var>destOffset</var> + 4 for\n   * the <var>destination</var> array.\n   * The actual number of significant bytes in your array is\n   * given by <var>numSigBytes</var>.\n   *\n   * @param source the array to convert\n   * @param srcOffset the index where conversion begins\n   * @param numSigBytes the number of significant bytes in your array\n   * @param destination the array to hold the conversion\n   * @param destOffset the index where output will be put\n   * @param alphabet is the encoding alphabet\n   * @return the <var>destination</var> array\n   * @since 1.3\n   */\n  private static byte[] encode3to4(byte[] source, int srcOffset,\n      int numSigBytes, byte[] destination, int destOffset, byte[] alphabet) {\n    //           1         2         3\n    // 01234567890123456789012345678901 Bit position\n    // --------000000001111111122222222 Array position from threeBytes\n    // --------|    ||    ||    ||    | Six bit groups to index alphabet\n    //          >>18  >>12  >> 6  >> 0  Right shift necessary\n    //                0x3f  0x3f  0x3f  Additional AND\n\n    // Create buffer with zero-padding if there are only one or two\n    // significant bytes passed in the array.\n    // We have to shift left 24 in order to flush out the 1's that appear\n    // when Java treats a value as negative that is cast from a byte to an int.\n    int inBuff =\n        (numSigBytes > 0 ? ((source[srcOffset] << 24) >>> 8) : 0)\n            | (numSigBytes > 1 ? ((source[srcOffset + 1] << 24) >>> 16) : 0)\n            | (numSigBytes > 2 ? ((source[srcOffset + 2] << 24) >>> 24) : 0);\n\n    switch (numSigBytes) {\n      case 3:\n        destination[destOffset] = alphabet[(inBuff >>> 18)];\n        destination[destOffset + 1] = alphabet[(inBuff >>> 12) & 0x3f];\n        destination[destOffset + 2] = alphabet[(inBuff >>> 6) & 0x3f];\n        destination[destOffset + 3] = alphabet[(inBuff) & 0x3f];\n        return destination;\n      case 2:\n        destination[destOffset] = alphabet[(inBuff >>> 18)];\n        destination[destOffset + 1] = alphabet[(inBuff >>> 12) & 0x3f];\n        destination[destOffset + 2] = alphabet[(inBuff >>> 6) & 0x3f];\n        destination[destOffset + 3] = EQUALS_SIGN;\n        return destination;\n      case 1:\n        destination[destOffset] = alphabet[(inBuff >>> 18)];\n        destination[destOffset + 1] = alphabet[(inBuff >>> 12) & 0x3f];\n        destination[destOffset + 2] = EQUALS_SIGN;\n        destination[destOffset + 3] = EQUALS_SIGN;\n        return destination;\n      default:\n        return destination;\n    } // end switch\n  } // end encode3to4\n\n  /**\n   * Encodes a byte array into Base64 notation.\n   * Equivalent to calling\n   * {@code encodeBytes(source, 0, source.length)}\n   *\n   * @param source The data to convert\n   * @since 1.4\n   */\n  public static String encode(byte[] source) {\n    return encode(source, 0, source.length, ALPHABET, true);\n  }\n\n  /**\n   * Encodes a byte array into web safe Base64 notation.\n   *\n   * @param source The data to convert\n   * @param doPadding is {@code true} to pad result with '=' chars\n   *        if it does not fall on 3 byte boundaries\n   */\n  public static String encodeWebSafe(byte[] source, boolean doPadding) {\n    return encode(source, 0, source.length, WEBSAFE_ALPHABET, doPadding);\n  }\n\n  /**\n   * Encodes a byte array into Base64 notation.\n   *\n   * @param source The data to convert\n   * @param off Offset in array where conversion should begin\n   * @param len Length of data to convert\n   * @param alphabet is the encoding alphabet\n   * @param doPadding is {@code true} to pad result with '=' chars\n   *        if it does not fall on 3 byte boundaries\n   * @since 1.4\n   */\n  public static String encode(byte[] source, int off, int len, byte[] alphabet,\n      boolean doPadding) {\n    byte[] outBuff = encode(source, off, len, alphabet, Integer.MAX_VALUE);\n    int outLen = outBuff.length;\n\n    // If doPadding is false, set length to truncate '='\n    // padding characters\n    while (doPadding == false && outLen > 0) {\n      if (outBuff[outLen - 1] != '=') {\n        break;\n      }\n      outLen -= 1;\n    }\n\n    return new String(outBuff, 0, outLen);\n  }\n\n  /**\n   * Encodes a byte array into Base64 notation.\n   *\n   * @param source The data to convert\n   * @param off Offset in array where conversion should begin\n   * @param len Length of data to convert\n   * @param alphabet is the encoding alphabet\n   * @param maxLineLength maximum length of one line.\n   * @return the BASE64-encoded byte array\n   */\n  public static byte[] encode(byte[] source, int off, int len, byte[] alphabet,\n      int maxLineLength) {\n    int lenDiv3 = (len + 2) / 3; // ceil(len / 3)\n    int len43 = lenDiv3 * 4;\n    byte[] outBuff = new byte[len43 // Main 4:3\n        + (len43 / maxLineLength)]; // New lines\n\n    int d = 0;\n    int e = 0;\n    int len2 = len - 2;\n    int lineLength = 0;\n    for (; d < len2; d += 3, e += 4) {\n\n      // The following block of code is the same as\n      // encode3to4( source, d + off, 3, outBuff, e, alphabet );\n      // but inlined for faster encoding (~20% improvement)\n      int inBuff =\n          ((source[d + off] << 24) >>> 8)\n              | ((source[d + 1 + off] << 24) >>> 16)\n              | ((source[d + 2 + off] << 24) >>> 24);\n      outBuff[e] = alphabet[(inBuff >>> 18)];\n      outBuff[e + 1] = alphabet[(inBuff >>> 12) & 0x3f];\n      outBuff[e + 2] = alphabet[(inBuff >>> 6) & 0x3f];\n      outBuff[e + 3] = alphabet[(inBuff) & 0x3f];\n\n      lineLength += 4;\n      if (lineLength == maxLineLength) {\n        outBuff[e + 4] = NEW_LINE;\n        e++;\n        lineLength = 0;\n      } // end if: end of line\n    } // end for: each piece of array\n\n    if (d < len) {\n      encode3to4(source, d + off, len - d, outBuff, e, alphabet);\n\n      lineLength += 4;\n      if (lineLength == maxLineLength) {\n        // Add a last newline\n        outBuff[e + 4] = NEW_LINE;\n        e++;\n      }\n      e += 4;\n    }\n\n    assert (e == outBuff.length);\n    return outBuff;\n  }\n\n\n  /* ********  D E C O D I N G   M E T H O D S  ******** */\n\n\n  /**\n   * Decodes four bytes from array <var>source</var>\n   * and writes the resulting bytes (up to three of them)\n   * to <var>destination</var>.\n   * The source and destination arrays can be manipulated\n   * anywhere along their length by specifying\n   * <var>srcOffset</var> and <var>destOffset</var>.\n   * This method does not check to make sure your arrays\n   * are large enough to accommodate <var>srcOffset</var> + 4 for\n   * the <var>source</var> array or <var>destOffset</var> + 3 for\n   * the <var>destination</var> array.\n   * This method returns the actual number of bytes that\n   * were converted from the Base64 encoding.\n   *\n   *\n   * @param source the array to convert\n   * @param srcOffset the index where conversion begins\n   * @param destination the array to hold the conversion\n   * @param destOffset the index where output will be put\n   * @param decodabet the decodabet for decoding Base64 content\n   * @return the number of decoded bytes converted\n   * @since 1.3\n   */\n  private static int decode4to3(byte[] source, int srcOffset,\n      byte[] destination, int destOffset, byte[] decodabet) {\n    // Example: Dk==\n    if (source[srcOffset + 2] == EQUALS_SIGN) {\n      int outBuff =\n          ((decodabet[source[srcOffset]] << 24) >>> 6)\n              | ((decodabet[source[srcOffset + 1]] << 24) >>> 12);\n\n      destination[destOffset] = (byte) (outBuff >>> 16);\n      return 1;\n    } else if (source[srcOffset + 3] == EQUALS_SIGN) {\n      // Example: DkL=\n      int outBuff =\n          ((decodabet[source[srcOffset]] << 24) >>> 6)\n              | ((decodabet[source[srcOffset + 1]] << 24) >>> 12)\n              | ((decodabet[source[srcOffset + 2]] << 24) >>> 18);\n\n      destination[destOffset] = (byte) (outBuff >>> 16);\n      destination[destOffset + 1] = (byte) (outBuff >>> 8);\n      return 2;\n    } else {\n      // Example: DkLE\n      int outBuff =\n          ((decodabet[source[srcOffset]] << 24) >>> 6)\n              | ((decodabet[source[srcOffset + 1]] << 24) >>> 12)\n              | ((decodabet[source[srcOffset + 2]] << 24) >>> 18)\n              | ((decodabet[source[srcOffset + 3]] << 24) >>> 24);\n\n      destination[destOffset] = (byte) (outBuff >> 16);\n      destination[destOffset + 1] = (byte) (outBuff >> 8);\n      destination[destOffset + 2] = (byte) (outBuff);\n      return 3;\n    }\n  } // end decodeToBytes\n\n\n  /**\n   * Decodes data from Base64 notation.\n   *\n   * @param s the string to decode (decoded in default encoding)\n   * @return the decoded data\n   * @since 1.4\n   */\n  public static byte[] decode(String s) throws Base64DecoderException {\n    byte[] bytes = s.getBytes();\n    return decode(bytes, 0, bytes.length);\n  }\n\n  /**\n   * Decodes data from web safe Base64 notation.\n   * Web safe encoding uses '-' instead of '+', '_' instead of '/'\n   *\n   * @param s the string to decode (decoded in default encoding)\n   * @return the decoded data\n   */\n  public static byte[] decodeWebSafe(String s) throws Base64DecoderException {\n    byte[] bytes = s.getBytes();\n    return decodeWebSafe(bytes, 0, bytes.length);\n  }\n\n  /**\n   * Decodes Base64 content in byte array format and returns\n   * the decoded byte array.\n   *\n   * @param source The Base64 encoded data\n   * @return decoded data\n   * @since 1.3\n   * @throws Base64DecoderException\n   */\n  public static byte[] decode(byte[] source) throws Base64DecoderException {\n    return decode(source, 0, source.length);\n  }\n\n  /**\n   * Decodes web safe Base64 content in byte array format and returns\n   * the decoded data.\n   * Web safe encoding uses '-' instead of '+', '_' instead of '/'\n   *\n   * @param source the string to decode (decoded in default encoding)\n   * @return the decoded data\n   */\n  public static byte[] decodeWebSafe(byte[] source)\n      throws Base64DecoderException {\n    return decodeWebSafe(source, 0, source.length);\n  }\n\n  /**\n   * Decodes Base64 content in byte array format and returns\n   * the decoded byte array.\n   *\n   * @param source The Base64 encoded data\n   * @param off    The offset of where to begin decoding\n   * @param len    The length of characters to decode\n   * @return decoded data\n   * @since 1.3\n   * @throws Base64DecoderException\n   */\n  public static byte[] decode(byte[] source, int off, int len)\n      throws Base64DecoderException {\n    return decode(source, off, len, DECODABET);\n  }\n\n  /**\n   * Decodes web safe Base64 content in byte array format and returns\n   * the decoded byte array.\n   * Web safe encoding uses '-' instead of '+', '_' instead of '/'\n   *\n   * @param source The Base64 encoded data\n   * @param off    The offset of where to begin decoding\n   * @param len    The length of characters to decode\n   * @return decoded data\n   */\n  public static byte[] decodeWebSafe(byte[] source, int off, int len)\n      throws Base64DecoderException {\n    return decode(source, off, len, WEBSAFE_DECODABET);\n  }\n\n  /**\n   * Decodes Base64 content using the supplied decodabet and returns\n   * the decoded byte array.\n   *\n   * @param source    The Base64 encoded data\n   * @param off       The offset of where to begin decoding\n   * @param len       The length of characters to decode\n   * @param decodabet the decodabet for decoding Base64 content\n   * @return decoded data\n   */\n  public static byte[] decode(byte[] source, int off, int len, byte[] decodabet)\n      throws Base64DecoderException {\n    int len34 = len * 3 / 4;\n    byte[] outBuff = new byte[2 + len34]; // Upper limit on size of output\n    int outBuffPosn = 0;\n\n    byte[] b4 = new byte[4];\n    int b4Posn = 0;\n    int i = 0;\n    byte sbiCrop = 0;\n    byte sbiDecode = 0;\n    for (i = 0; i < len; i++) {\n      sbiCrop = (byte) (source[i + off] & 0x7f); // Only the low seven bits\n      sbiDecode = decodabet[sbiCrop];\n\n      if (sbiDecode >= WHITE_SPACE_ENC) { // White space Equals sign or better\n        if (sbiDecode >= EQUALS_SIGN_ENC) {\n          // An equals sign (for padding) must not occur at position 0 or 1\n          // and must be the last byte[s] in the encoded value\n          if (sbiCrop == EQUALS_SIGN) {\n            int bytesLeft = len - i;\n            byte lastByte = (byte) (source[len - 1 + off] & 0x7f);\n            if (b4Posn == 0 || b4Posn == 1) {\n              throw new Base64DecoderException(\n                  \"invalid padding byte '=' at byte offset \" + i);\n            } else if ((b4Posn == 3 && bytesLeft > 2)\n                || (b4Posn == 4 && bytesLeft > 1)) {\n              throw new Base64DecoderException(\n                  \"padding byte '=' falsely signals end of encoded value \"\n                      + \"at offset \" + i);\n            } else if (lastByte != EQUALS_SIGN && lastByte != NEW_LINE) {\n              throw new Base64DecoderException(\n                  \"encoded value has invalid trailing byte\");\n            }\n            break;\n          }\n\n          b4[b4Posn++] = sbiCrop;\n          if (b4Posn == 4) {\n            outBuffPosn += decode4to3(b4, 0, outBuff, outBuffPosn, decodabet);\n            b4Posn = 0;\n          }\n        }\n      } else {\n        throw new Base64DecoderException(\"Bad Base64 input character at \" + i\n            + \": \" + source[i + off] + \"(decimal)\");\n      }\n    }\n\n    // Because web safe encoding allows non padding base64 encodes, we\n    // need to pad the rest of the b4 buffer with equal signs when\n    // b4Posn != 0.  There can be at most 2 equal signs at the end of\n    // four characters, so the b4 buffer must have two or three\n    // characters.  This also catches the case where the input is\n    // padded with EQUALS_SIGN\n    if (b4Posn != 0) {\n      if (b4Posn == 1) {\n        throw new Base64DecoderException(\"single trailing character at offset \"\n            + (len - 1));\n      }\n      b4[b4Posn++] = EQUALS_SIGN;\n      outBuffPosn += decode4to3(b4, 0, outBuff, outBuffPosn, decodabet);\n    }\n\n    byte[] out = new byte[outBuffPosn];\n    System.arraycopy(outBuff, 0, out, 0, outBuffPosn);\n    return out;\n  }\n}\n"
  },
  {
    "path": "Projects/Android/playlicensing/src/main/java/com/google/android/vending/licensing/util/Base64DecoderException.java",
    "content": "// Copyright 2002, Google, Inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n//     http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\npackage com.google.android.vending.licensing.util;\n\n/**\n * Exception thrown when encountering an invalid Base64 input character.\n *\n * @author nelson\n */\npublic class Base64DecoderException extends Exception {\n  public Base64DecoderException() {\n    super();\n  }\n\n  public Base64DecoderException(String s) {\n    super(s);\n  }\n\n  private static final long serialVersionUID = 1L;\n}\n"
  },
  {
    "path": "Projects/Libraries/CSBase/AndroidManifest.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n      package=\"com.fakepackage\"\n      android:versionCode=\"1\"\n      android:versionName=\"1.0\">\n    <uses-sdk android:minSdkVersion=\"7\"/>\n\n    <application android:icon=\"FakeIcon.png\" android:label=\"FakeLabel\" android:debuggable=\"false\">\n        <activity android:name=\"com.FakeActivity\"\n                  android:label=\"FakeLabel\">\n            <intent-filter>\n                <action android:name=\"android.intent.action.MAIN\" />\n                <category android:name=\"android.intent.category.LAUNCHER\" />\n            </intent-filter>\n        </activity>\n\n    </application>\n</manifest>"
  },
  {
    "path": "Projects/Libraries/CSBase/CSBase.sln",
    "content": "﻿\r\nMicrosoft Visual Studio Solution File, Format Version 12.00\r\n# Visual Studio 14\r\nVisualStudioVersion = 14.0.24720.0\r\nMinimumVisualStudioVersion = 10.0.40219.1\r\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"CSBase\", \"CSBase.vcxproj\", \"{370D06B2-59BF-4BAC-BCEC-8BFAF6DB6B8F}\"\r\nEndProject\r\nGlobal\r\n\tGlobalSection(SolutionConfigurationPlatforms) = preSolution\r\n\t\tDebug|x64 = Debug|x64\r\n\t\tDebug|x86 = Debug|x86\r\n\t\tRelease|x64 = Release|x64\r\n\t\tRelease|x86 = Release|x86\r\n\tEndGlobalSection\r\n\tGlobalSection(ProjectConfigurationPlatforms) = postSolution\r\n\t\t{370D06B2-59BF-4BAC-BCEC-8BFAF6DB6B8F}.Debug|x64.ActiveCfg = Debug|x64\r\n\t\t{370D06B2-59BF-4BAC-BCEC-8BFAF6DB6B8F}.Debug|x64.Build.0 = Debug|x64\r\n\t\t{370D06B2-59BF-4BAC-BCEC-8BFAF6DB6B8F}.Debug|x86.ActiveCfg = Debug|Win32\r\n\t\t{370D06B2-59BF-4BAC-BCEC-8BFAF6DB6B8F}.Debug|x86.Build.0 = Debug|Win32\r\n\t\t{370D06B2-59BF-4BAC-BCEC-8BFAF6DB6B8F}.Release|x64.ActiveCfg = Release|x64\r\n\t\t{370D06B2-59BF-4BAC-BCEC-8BFAF6DB6B8F}.Release|x64.Build.0 = Release|x64\r\n\t\t{370D06B2-59BF-4BAC-BCEC-8BFAF6DB6B8F}.Release|x86.ActiveCfg = Release|Win32\r\n\t\t{370D06B2-59BF-4BAC-BCEC-8BFAF6DB6B8F}.Release|x86.Build.0 = Release|Win32\r\n\tEndGlobalSection\r\n\tGlobalSection(SolutionProperties) = preSolution\r\n\t\tHideSolutionNode = FALSE\r\n\tEndGlobalSection\r\nEndGlobal\r\n"
  },
  {
    "path": "Projects/Libraries/CSBase/CSBase.vcxproj",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Project DefaultTargets=\"Build\" ToolsVersion=\"14.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\r\n  <ItemGroup Label=\"ProjectConfigurations\">\r\n    <ProjectConfiguration Include=\"Debug|Win32\">\r\n      <Configuration>Debug</Configuration>\r\n      <Platform>Win32</Platform>\r\n    </ProjectConfiguration>\r\n    <ProjectConfiguration Include=\"Release|Win32\">\r\n      <Configuration>Release</Configuration>\r\n      <Platform>Win32</Platform>\r\n    </ProjectConfiguration>\r\n    <ProjectConfiguration Include=\"Debug|x64\">\r\n      <Configuration>Debug</Configuration>\r\n      <Platform>x64</Platform>\r\n    </ProjectConfiguration>\r\n    <ProjectConfiguration Include=\"Release|x64\">\r\n      <Configuration>Release</Configuration>\r\n      <Platform>x64</Platform>\r\n    </ProjectConfiguration>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <ClInclude Include=\"PlatformSource\\Windows\\zconf.h\" />\r\n    <ClInclude Include=\"PlatformSource\\Windows\\zlib.h\" />\r\n    <ClInclude Include=\"Source\\aes\\aes.h\" />\r\n    <ClInclude Include=\"Source\\base64\\base64.h\" />\r\n    <ClInclude Include=\"Source\\json\\assertions.h\" />\r\n    <ClInclude Include=\"Source\\json\\autolink.h\" />\r\n    <ClInclude Include=\"Source\\json\\config.h\" />\r\n    <ClInclude Include=\"Source\\json\\features.h\" />\r\n    <ClInclude Include=\"Source\\json\\forwards.h\" />\r\n    <ClInclude Include=\"Source\\json\\json.h\" />\r\n    <ClInclude Include=\"Source\\json\\json_batchallocator.h\" />\r\n    <ClInclude Include=\"Source\\json\\json_tool.h\" />\r\n    <ClInclude Include=\"Source\\json\\reader.h\" />\r\n    <ClInclude Include=\"Source\\json\\value.h\" />\r\n    <ClInclude Include=\"Source\\json\\writer.h\" />\r\n    <ClInclude Include=\"Source\\md5\\md5.h\" />\r\n    <ClInclude Include=\"Source\\minizip\\crypt.h\" />\r\n    <ClInclude Include=\"Source\\minizip\\ioapi.h\" />\r\n    <ClInclude Include=\"Source\\minizip\\mztools.h\" />\r\n    <ClInclude Include=\"Source\\minizip\\unzip.h\" />\r\n    <ClInclude Include=\"Source\\minizip\\zip.h\" />\r\n    <ClInclude Include=\"Source\\png\\png.h\" />\r\n    <ClInclude Include=\"Source\\png\\pngconf.h\" />\r\n    <ClInclude Include=\"Source\\png\\pngdebug.h\" />\r\n    <ClInclude Include=\"Source\\png\\pnginfo.h\" />\r\n    <ClInclude Include=\"Source\\png\\pnglibconf.h\" />\r\n    <ClInclude Include=\"Source\\png\\pngpriv.h\" />\r\n    <ClInclude Include=\"Source\\png\\pngstruct.h\" />\r\n    <ClInclude Include=\"Source\\rapidxml\\rapidxml.hpp\" />\r\n    <ClInclude Include=\"Source\\rapidxml\\rapidxml_iterators.hpp\" />\r\n    <ClInclude Include=\"Source\\rapidxml\\rapidxml_print.hpp\" />\r\n    <ClInclude Include=\"Source\\rapidxml\\rapidxml_utils.hpp\" />\r\n    <ClInclude Include=\"Source\\SHA1\\HMAC_SHA1.h\" />\r\n    <ClInclude Include=\"Source\\SHA1\\SHA1.h\" />\r\n    <ClInclude Include=\"Source\\SHA256\\sha256.h\" />\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <ClCompile Include=\"Source\\aes\\aes.c\" />\r\n    <ClCompile Include=\"Source\\base64\\base64.cpp\" />\r\n    <ClCompile Include=\"Source\\json\\json_reader.cpp\" />\r\n    <ClCompile Include=\"Source\\json\\json_value.cpp\" />\r\n    <ClCompile Include=\"Source\\json\\json_writer.cpp\" />\r\n    <ClCompile Include=\"Source\\md5\\md5.cpp\" />\r\n    <ClCompile Include=\"Source\\minizip\\ioapi.c\" />\r\n    <ClCompile Include=\"Source\\minizip\\mztools.c\" />\r\n    <ClCompile Include=\"Source\\minizip\\unzip.c\" />\r\n    <ClCompile Include=\"Source\\minizip\\zip.c\" />\r\n    <ClCompile Include=\"Source\\png\\png.c\" />\r\n    <ClCompile Include=\"Source\\png\\pngerror.c\" />\r\n    <ClCompile Include=\"Source\\png\\pngget.c\" />\r\n    <ClCompile Include=\"Source\\png\\pngmem.c\" />\r\n    <ClCompile Include=\"Source\\png\\pngpread.c\" />\r\n    <ClCompile Include=\"Source\\png\\pngread.c\" />\r\n    <ClCompile Include=\"Source\\png\\pngrio.c\" />\r\n    <ClCompile Include=\"Source\\png\\pngrtran.c\" />\r\n    <ClCompile Include=\"Source\\png\\pngrutil.c\" />\r\n    <ClCompile Include=\"Source\\png\\pngset.c\" />\r\n    <ClCompile Include=\"Source\\png\\pngtest.c\" />\r\n    <ClCompile Include=\"Source\\png\\pngtrans.c\" />\r\n    <ClCompile Include=\"Source\\png\\pngwio.c\" />\r\n    <ClCompile Include=\"Source\\png\\pngwrite.c\" />\r\n    <ClCompile Include=\"Source\\png\\pngwtran.c\" />\r\n    <ClCompile Include=\"Source\\png\\pngwutil.c\" />\r\n    <ClCompile Include=\"Source\\SHA1\\HMAC_SHA1.cpp\" />\r\n    <ClCompile Include=\"Source\\SHA1\\SHA1.cpp\" />\r\n    <ClCompile Include=\"Source\\SHA256\\sha256.cpp\" />\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <None Include=\"Source\\json\\json_internalarray.inl\" />\r\n    <None Include=\"Source\\json\\json_internalmap.inl\" />\r\n    <None Include=\"Source\\json\\json_valueiterator.inl\" />\r\n    <None Include=\"Source\\json\\version.h.in\" />\r\n  </ItemGroup>\r\n  <PropertyGroup Label=\"Globals\">\r\n    <ProjectGuid>{370D06B2-59BF-4BAC-BCEC-8BFAF6DB6B8F}</ProjectGuid>\r\n    <Keyword>Win32Proj</Keyword>\r\n    <RootNamespace>CSBase</RootNamespace>\r\n    <WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>\r\n  </PropertyGroup>\r\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.Default.props\" />\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\" Label=\"Configuration\">\r\n    <ConfigurationType>StaticLibrary</ConfigurationType>\r\n    <UseDebugLibraries>true</UseDebugLibraries>\r\n    <PlatformToolset>v140</PlatformToolset>\r\n    <CharacterSet>Unicode</CharacterSet>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\" Label=\"Configuration\">\r\n    <ConfigurationType>StaticLibrary</ConfigurationType>\r\n    <UseDebugLibraries>false</UseDebugLibraries>\r\n    <PlatformToolset>v140</PlatformToolset>\r\n    <WholeProgramOptimization>true</WholeProgramOptimization>\r\n    <CharacterSet>Unicode</CharacterSet>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\" Label=\"Configuration\">\r\n    <ConfigurationType>StaticLibrary</ConfigurationType>\r\n    <UseDebugLibraries>true</UseDebugLibraries>\r\n    <PlatformToolset>v140</PlatformToolset>\r\n    <CharacterSet>Unicode</CharacterSet>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\" Label=\"Configuration\">\r\n    <ConfigurationType>StaticLibrary</ConfigurationType>\r\n    <UseDebugLibraries>false</UseDebugLibraries>\r\n    <PlatformToolset>v140</PlatformToolset>\r\n    <WholeProgramOptimization>true</WholeProgramOptimization>\r\n    <CharacterSet>Unicode</CharacterSet>\r\n  </PropertyGroup>\r\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.props\" />\r\n  <ImportGroup Label=\"ExtensionSettings\">\r\n  </ImportGroup>\r\n  <ImportGroup Label=\"Shared\">\r\n  </ImportGroup>\r\n  <ImportGroup Label=\"PropertySheets\" Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n  </ImportGroup>\r\n  <ImportGroup Label=\"PropertySheets\" Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n  </ImportGroup>\r\n  <ImportGroup Label=\"PropertySheets\" Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n  </ImportGroup>\r\n  <ImportGroup Label=\"PropertySheets\" Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n  </ImportGroup>\r\n  <PropertyGroup Label=\"UserMacros\" />\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">\r\n    <OutDir>$(SolutionDir)Build\\Output\\$(Platform)\\$(Configuration)\\</OutDir>\r\n    <IntDir>$(SolutionDir)Build\\Intermediate\\$(Platform)\\$(Configuration)\\</IntDir>\r\n    <IncludePath>$(ProjectDir)Source;$(ProjectDir)PlatformSource\\Windows;$(IncludePath)</IncludePath>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">\r\n    <OutDir>$(SolutionDir)Build\\Output\\$(Platform)\\$(Configuration)\\</OutDir>\r\n    <IntDir>$(SolutionDir)Build\\Intermediate\\$(Platform)\\$(Configuration)\\</IntDir>\r\n    <IncludePath>$(ProjectDir)Source;$(ProjectDir)PlatformSource\\Windows;$(IncludePath)</IncludePath>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n    <OutDir>$(SolutionDir)Build\\Output\\$(Platform)\\$(Configuration)\\</OutDir>\r\n    <IntDir>$(SolutionDir)Build\\Intermediate\\$(Platform)\\$(Configuration)\\</IntDir>\r\n    <IncludePath>$(ProjectDir)Source;$(ProjectDir)PlatformSource\\Windows;$(IncludePath)</IncludePath>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n    <OutDir>$(SolutionDir)Build\\Output\\$(Platform)\\$(Configuration)\\</OutDir>\r\n    <IntDir>$(SolutionDir)Build\\Intermediate\\$(Platform)\\$(Configuration)\\</IntDir>\r\n    <IncludePath>$(ProjectDir)Source;$(ProjectDir)PlatformSource\\Windows;$(IncludePath)</IncludePath>\r\n  </PropertyGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">\r\n    <ClCompile>\r\n      <PrecompiledHeader>\r\n      </PrecompiledHeader>\r\n      <WarningLevel>Level3</WarningLevel>\r\n      <Optimization>Disabled</Optimization>\r\n      <PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <SDLCheck>false</SDLCheck>\r\n      <ObjectFileName>$(IntDir)%(RelativeDir)</ObjectFileName>\r\n    </ClCompile>\r\n    <Link>\r\n      <SubSystem>Windows</SubSystem>\r\n    </Link>\r\n    <PostBuildEvent>\r\n      <Command>python ..\\..\\..\\Tools\\Scripts\\extract_headers.py -i \"$(ProjectDir)Source\\\\\" -o \"$(TargetDir)Headers\\\\\"</Command>\r\n    </PostBuildEvent>\r\n  </ItemDefinitionGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n    <ClCompile>\r\n      <PrecompiledHeader>\r\n      </PrecompiledHeader>\r\n      <WarningLevel>Level3</WarningLevel>\r\n      <Optimization>Disabled</Optimization>\r\n      <PreprocessorDefinitions>_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <SDLCheck>false</SDLCheck>\r\n      <ObjectFileName>$(IntDir)%(RelativeDir)</ObjectFileName>\r\n    </ClCompile>\r\n    <Link>\r\n      <SubSystem>Windows</SubSystem>\r\n    </Link>\r\n    <PostBuildEvent>\r\n      <Command>python ..\\..\\..\\Tools\\Scripts\\extract_headers.py -i \"$(ProjectDir)Source\\\\\" -o \"$(TargetDir)Headers\\\\\"</Command>\r\n    </PostBuildEvent>\r\n  </ItemDefinitionGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">\r\n    <ClCompile>\r\n      <WarningLevel>Level3</WarningLevel>\r\n      <PrecompiledHeader>\r\n      </PrecompiledHeader>\r\n      <Optimization>MaxSpeed</Optimization>\r\n      <FunctionLevelLinking>true</FunctionLevelLinking>\r\n      <IntrinsicFunctions>true</IntrinsicFunctions>\r\n      <PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <SDLCheck>false</SDLCheck>\r\n      <ObjectFileName>$(IntDir)%(RelativeDir)</ObjectFileName>\r\n    </ClCompile>\r\n    <Link>\r\n      <SubSystem>Windows</SubSystem>\r\n      <EnableCOMDATFolding>true</EnableCOMDATFolding>\r\n      <OptimizeReferences>true</OptimizeReferences>\r\n    </Link>\r\n    <PostBuildEvent>\r\n      <Command>python ..\\..\\..\\Tools\\Scripts\\extract_headers.py -i \"$(ProjectDir)Source\\\\\" -o \"$(TargetDir)Headers\\\\\"</Command>\r\n    </PostBuildEvent>\r\n  </ItemDefinitionGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n    <ClCompile>\r\n      <WarningLevel>Level3</WarningLevel>\r\n      <PrecompiledHeader>\r\n      </PrecompiledHeader>\r\n      <Optimization>MaxSpeed</Optimization>\r\n      <FunctionLevelLinking>true</FunctionLevelLinking>\r\n      <IntrinsicFunctions>true</IntrinsicFunctions>\r\n      <PreprocessorDefinitions>NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <SDLCheck>false</SDLCheck>\r\n      <ObjectFileName>$(IntDir)%(RelativeDir)</ObjectFileName>\r\n    </ClCompile>\r\n    <Link>\r\n      <SubSystem>Windows</SubSystem>\r\n      <EnableCOMDATFolding>true</EnableCOMDATFolding>\r\n      <OptimizeReferences>true</OptimizeReferences>\r\n    </Link>\r\n    <PostBuildEvent>\r\n      <Command>python ..\\..\\..\\Tools\\Scripts\\extract_headers.py -i \"$(ProjectDir)Source\\\\\" -o \"$(TargetDir)Headers\\\\\"</Command>\r\n    </PostBuildEvent>\r\n  </ItemDefinitionGroup>\r\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.targets\" />\r\n  <ImportGroup Label=\"ExtensionTargets\">\r\n  </ImportGroup>\r\n</Project>"
  },
  {
    "path": "Projects/Libraries/CSBase/CSBase.vcxproj.filters",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Project ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\r\n  <ItemGroup>\r\n    <Filter Include=\"Source\">\r\n      <UniqueIdentifier>{ac1d99d0-3d76-49ea-85c8-a15c3843528b}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"PlatformSource\">\r\n      <UniqueIdentifier>{40da9152-5ecc-4e4b-b64b-3edc1f17bfca}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"PlatformSource\\Windows\">\r\n      <UniqueIdentifier>{d2fa60bc-3054-4d32-b437-c26c1ab89da3}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source\\aes\">\r\n      <UniqueIdentifier>{9b0c143b-fdbf-4321-86ca-aacaedb9d22c}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source\\base64\">\r\n      <UniqueIdentifier>{380b3210-80ea-47fa-bc55-ab3188a878af}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source\\json\">\r\n      <UniqueIdentifier>{02467a67-6788-4bc6-8c7a-c1f0a10899a8}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source\\md5\">\r\n      <UniqueIdentifier>{f20002fd-d60c-4dcb-a19c-d54d3167287e}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source\\minizip\">\r\n      <UniqueIdentifier>{9389dca9-e5fc-4d6d-84b8-313072e3b62c}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source\\png\">\r\n      <UniqueIdentifier>{7c802d6c-a0bb-4c71-b791-eba69af27e2a}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source\\rapidxml\">\r\n      <UniqueIdentifier>{6cd42858-2c1f-4966-957d-87828dde6e0f}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source\\SHA1\">\r\n      <UniqueIdentifier>{3cca65dd-355a-41a8-be6a-65324630b025}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"Source\\SHA256\">\r\n      <UniqueIdentifier>{bf21d1dc-30e5-4757-9e51-7d10929a831b}</UniqueIdentifier>\r\n    </Filter>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <ClInclude Include=\"PlatformSource\\Windows\\zconf.h\">\r\n      <Filter>PlatformSource\\Windows</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"PlatformSource\\Windows\\zlib.h\">\r\n      <Filter>PlatformSource\\Windows</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Source\\aes\\aes.h\">\r\n      <Filter>Source\\aes</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Source\\base64\\base64.h\">\r\n      <Filter>Source\\base64</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Source\\json\\assertions.h\">\r\n      <Filter>Source\\json</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Source\\json\\autolink.h\">\r\n      <Filter>Source\\json</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Source\\json\\config.h\">\r\n      <Filter>Source\\json</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Source\\json\\features.h\">\r\n      <Filter>Source\\json</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Source\\json\\forwards.h\">\r\n      <Filter>Source\\json</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Source\\json\\json.h\">\r\n      <Filter>Source\\json</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Source\\json\\json_batchallocator.h\">\r\n      <Filter>Source\\json</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Source\\json\\json_tool.h\">\r\n      <Filter>Source\\json</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Source\\json\\reader.h\">\r\n      <Filter>Source\\json</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Source\\json\\value.h\">\r\n      <Filter>Source\\json</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Source\\json\\writer.h\">\r\n      <Filter>Source\\json</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Source\\md5\\md5.h\">\r\n      <Filter>Source\\md5</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Source\\SHA1\\HMAC_SHA1.h\">\r\n      <Filter>Source\\SHA1</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Source\\SHA1\\SHA1.h\">\r\n      <Filter>Source\\SHA1</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Source\\rapidxml\\rapidxml.hpp\">\r\n      <Filter>Source\\rapidxml</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Source\\rapidxml\\rapidxml_iterators.hpp\">\r\n      <Filter>Source\\rapidxml</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Source\\rapidxml\\rapidxml_print.hpp\">\r\n      <Filter>Source\\rapidxml</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Source\\rapidxml\\rapidxml_utils.hpp\">\r\n      <Filter>Source\\rapidxml</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Source\\png\\png.h\">\r\n      <Filter>Source\\png</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Source\\png\\pngconf.h\">\r\n      <Filter>Source\\png</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Source\\png\\pngdebug.h\">\r\n      <Filter>Source\\png</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Source\\png\\pnginfo.h\">\r\n      <Filter>Source\\png</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Source\\png\\pnglibconf.h\">\r\n      <Filter>Source\\png</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Source\\png\\pngpriv.h\">\r\n      <Filter>Source\\png</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Source\\png\\pngstruct.h\">\r\n      <Filter>Source\\png</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Source\\minizip\\crypt.h\">\r\n      <Filter>Source\\minizip</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Source\\minizip\\ioapi.h\">\r\n      <Filter>Source\\minizip</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Source\\minizip\\mztools.h\">\r\n      <Filter>Source\\minizip</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Source\\minizip\\unzip.h\">\r\n      <Filter>Source\\minizip</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Source\\minizip\\zip.h\">\r\n      <Filter>Source\\minizip</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"Source\\SHA256\\sha256.h\">\r\n      <Filter>Source\\SHA256</Filter>\r\n    </ClInclude>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <ClCompile Include=\"Source\\aes\\aes.c\">\r\n      <Filter>Source\\aes</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Source\\base64\\base64.cpp\">\r\n      <Filter>Source\\base64</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Source\\json\\json_reader.cpp\">\r\n      <Filter>Source\\json</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Source\\json\\json_value.cpp\">\r\n      <Filter>Source\\json</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Source\\json\\json_writer.cpp\">\r\n      <Filter>Source\\json</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Source\\md5\\md5.cpp\">\r\n      <Filter>Source\\md5</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Source\\SHA1\\HMAC_SHA1.cpp\">\r\n      <Filter>Source\\SHA1</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Source\\SHA1\\SHA1.cpp\">\r\n      <Filter>Source\\SHA1</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Source\\png\\png.c\">\r\n      <Filter>Source\\png</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Source\\png\\pngerror.c\">\r\n      <Filter>Source\\png</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Source\\png\\pngget.c\">\r\n      <Filter>Source\\png</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Source\\png\\pngmem.c\">\r\n      <Filter>Source\\png</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Source\\png\\pngpread.c\">\r\n      <Filter>Source\\png</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Source\\png\\pngread.c\">\r\n      <Filter>Source\\png</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Source\\png\\pngrio.c\">\r\n      <Filter>Source\\png</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Source\\png\\pngrtran.c\">\r\n      <Filter>Source\\png</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Source\\png\\pngrutil.c\">\r\n      <Filter>Source\\png</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Source\\png\\pngset.c\">\r\n      <Filter>Source\\png</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Source\\png\\pngtest.c\">\r\n      <Filter>Source\\png</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Source\\png\\pngtrans.c\">\r\n      <Filter>Source\\png</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Source\\png\\pngwio.c\">\r\n      <Filter>Source\\png</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Source\\png\\pngwrite.c\">\r\n      <Filter>Source\\png</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Source\\png\\pngwtran.c\">\r\n      <Filter>Source\\png</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Source\\png\\pngwutil.c\">\r\n      <Filter>Source\\png</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Source\\minizip\\ioapi.c\">\r\n      <Filter>Source\\minizip</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Source\\minizip\\mztools.c\">\r\n      <Filter>Source\\minizip</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Source\\minizip\\unzip.c\">\r\n      <Filter>Source\\minizip</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Source\\minizip\\zip.c\">\r\n      <Filter>Source\\minizip</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"Source\\SHA256\\sha256.cpp\">\r\n      <Filter>Source\\SHA256</Filter>\r\n    </ClCompile>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <None Include=\"Source\\json\\json_internalarray.inl\">\r\n      <Filter>Source\\json</Filter>\r\n    </None>\r\n    <None Include=\"Source\\json\\json_internalmap.inl\">\r\n      <Filter>Source\\json</Filter>\r\n    </None>\r\n    <None Include=\"Source\\json\\json_valueiterator.inl\">\r\n      <Filter>Source\\json</Filter>\r\n    </None>\r\n    <None Include=\"Source\\json\\version.h.in\">\r\n      <Filter>Source\\json</Filter>\r\n    </None>\r\n  </ItemGroup>\r\n</Project>"
  },
  {
    "path": "Projects/Libraries/CSBase/CSBase.xcodeproj/project.pbxproj",
    "content": "// !$*UTF8*$!\n{\n\tarchiveVersion = 1;\n\tclasses = {\n\t};\n\tobjectVersion = 46;\n\tobjects = {\n\n/* Begin PBXAggregateTarget section */\n\t\t81C7FE0D1C89D8D800D306F9 /* UniversalLib */ = {\n\t\t\tisa = PBXAggregateTarget;\n\t\t\tbuildConfigurationList = 81C7FE0E1C89D8D800D306F9 /* Build configuration list for PBXAggregateTarget \"UniversalLib\" */;\n\t\t\tbuildPhases = (\n\t\t\t\t81C7FE111C89D8E000D306F9 /* ShellScript */,\n\t\t\t);\n\t\t\tdependencies = (\n\t\t\t);\n\t\t\tname = UniversalLib;\n\t\t\tproductName = UniversalLib;\n\t\t};\n/* End PBXAggregateTarget section */\n\n/* Begin PBXBuildFile section */\n\t\t27B425981E60724300E17750 /* sha256.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 27B425961E605D1300E17750 /* sha256.cpp */; };\n\t\t814B94B01CAD7425002831E4 /* ioapi.c in Sources */ = {isa = PBXBuildFile; fileRef = 814B94A61CAD7425002831E4 /* ioapi.c */; };\n\t\t814B94B21CAD7425002831E4 /* mztools.c in Sources */ = {isa = PBXBuildFile; fileRef = 814B94AA1CAD7425002831E4 /* mztools.c */; };\n\t\t814B94B31CAD7425002831E4 /* unzip.c in Sources */ = {isa = PBXBuildFile; fileRef = 814B94AC1CAD7425002831E4 /* unzip.c */; };\n\t\t814B94B41CAD7425002831E4 /* zip.c in Sources */ = {isa = PBXBuildFile; fileRef = 814B94AE1CAD7425002831E4 /* zip.c */; };\n\t\t81C7FDED1C89D79B00D306F9 /* CSReachability.m in Sources */ = {isa = PBXBuildFile; fileRef = 81C7FD9E1C89D79B00D306F9 /* CSReachability.m */; };\n\t\t81C7FDEE1C89D79B00D306F9 /* aes.c in Sources */ = {isa = PBXBuildFile; fileRef = 81C7FDA41C89D79B00D306F9 /* aes.c */; };\n\t\t81C7FDEF1C89D79B00D306F9 /* base64.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81C7FDA71C89D79B00D306F9 /* base64.cpp */; };\n\t\t81C7FDF01C89D79B00D306F9 /* json_reader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81C7FDB31C89D79B00D306F9 /* json_reader.cpp */; };\n\t\t81C7FDF11C89D79B00D306F9 /* json_value.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81C7FDB51C89D79B00D306F9 /* json_value.cpp */; };\n\t\t81C7FDF21C89D79B00D306F9 /* json_writer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81C7FDB71C89D79B00D306F9 /* json_writer.cpp */; };\n\t\t81C7FDF31C89D79B00D306F9 /* md5.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81C7FDBD1C89D79B00D306F9 /* md5.cpp */; };\n\t\t81C7FDF81C89D79B00D306F9 /* png.c in Sources */ = {isa = PBXBuildFile; fileRef = 81C7FDCC1C89D79B00D306F9 /* png.c */; };\n\t\t81C7FDF91C89D79B00D306F9 /* pngerror.c in Sources */ = {isa = PBXBuildFile; fileRef = 81C7FDD01C89D79B00D306F9 /* pngerror.c */; };\n\t\t81C7FDFA1C89D79B00D306F9 /* pngget.c in Sources */ = {isa = PBXBuildFile; fileRef = 81C7FDD11C89D79B00D306F9 /* pngget.c */; };\n\t\t81C7FDFB1C89D79B00D306F9 /* pngmem.c in Sources */ = {isa = PBXBuildFile; fileRef = 81C7FDD41C89D79B00D306F9 /* pngmem.c */; };\n\t\t81C7FDFC1C89D79B00D306F9 /* pngpread.c in Sources */ = {isa = PBXBuildFile; fileRef = 81C7FDD51C89D79B00D306F9 /* pngpread.c */; };\n\t\t81C7FDFD1C89D79B00D306F9 /* pngread.c in Sources */ = {isa = PBXBuildFile; fileRef = 81C7FDD71C89D79B00D306F9 /* pngread.c */; };\n\t\t81C7FDFE1C89D79B00D306F9 /* pngrio.c in Sources */ = {isa = PBXBuildFile; fileRef = 81C7FDD81C89D79B00D306F9 /* pngrio.c */; };\n\t\t81C7FDFF1C89D79B00D306F9 /* pngrtran.c in Sources */ = {isa = PBXBuildFile; fileRef = 81C7FDD91C89D79B00D306F9 /* pngrtran.c */; };\n\t\t81C7FE001C89D79B00D306F9 /* pngrutil.c in Sources */ = {isa = PBXBuildFile; fileRef = 81C7FDDA1C89D79B00D306F9 /* pngrutil.c */; };\n\t\t81C7FE011C89D79B00D306F9 /* pngset.c in Sources */ = {isa = PBXBuildFile; fileRef = 81C7FDDB1C89D79B00D306F9 /* pngset.c */; };\n\t\t81C7FE021C89D79B00D306F9 /* pngtest.c in Sources */ = {isa = PBXBuildFile; fileRef = 81C7FDDD1C89D79B00D306F9 /* pngtest.c */; };\n\t\t81C7FE031C89D79B00D306F9 /* pngtrans.c in Sources */ = {isa = PBXBuildFile; fileRef = 81C7FDDE1C89D79B00D306F9 /* pngtrans.c */; };\n\t\t81C7FE041C89D79B00D306F9 /* pngwio.c in Sources */ = {isa = PBXBuildFile; fileRef = 81C7FDDF1C89D79B00D306F9 /* pngwio.c */; };\n\t\t81C7FE051C89D79B00D306F9 /* pngwrite.c in Sources */ = {isa = PBXBuildFile; fileRef = 81C7FDE01C89D79B00D306F9 /* pngwrite.c */; };\n\t\t81C7FE061C89D79B00D306F9 /* pngwtran.c in Sources */ = {isa = PBXBuildFile; fileRef = 81C7FDE11C89D79B00D306F9 /* pngwtran.c */; };\n\t\t81C7FE071C89D79B00D306F9 /* pngwutil.c in Sources */ = {isa = PBXBuildFile; fileRef = 81C7FDE21C89D79B00D306F9 /* pngwutil.c */; };\n\t\t81C7FE081C89D79B00D306F9 /* HMAC_SHA1.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81C7FDE91C89D79B00D306F9 /* HMAC_SHA1.cpp */; };\n\t\t81C7FE091C89D79B00D306F9 /* SHA1.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81C7FDEB1C89D79B00D306F9 /* SHA1.cpp */; };\n\t\t81C7FE0B1C89D84400D306F9 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 81C7FE0A1C89D84400D306F9 /* Foundation.framework */; };\n/* End PBXBuildFile section */\n\n/* Begin PBXCopyFilesBuildPhase section */\n\t\t81C7FD8C1C89D73E00D306F9 /* CopyFiles */ = {\n\t\t\tisa = PBXCopyFilesBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tdstPath = \"include/$(PRODUCT_NAME)\";\n\t\t\tdstSubfolderSpec = 16;\n\t\t\tfiles = (\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n/* End PBXCopyFilesBuildPhase section */\n\n/* Begin PBXFileReference section */\n\t\t27B425961E605D1300E17750 /* sha256.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = sha256.cpp; sourceTree = \"<group>\"; };\n\t\t27B425971E605D1300E17750 /* sha256.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = sha256.h; sourceTree = \"<group>\"; };\n\t\t814B94A51CAD7425002831E4 /* crypt.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = crypt.h; sourceTree = \"<group>\"; };\n\t\t814B94A61CAD7425002831E4 /* ioapi.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ioapi.c; sourceTree = \"<group>\"; };\n\t\t814B94A71CAD7425002831E4 /* ioapi.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ioapi.h; sourceTree = \"<group>\"; };\n\t\t814B94AA1CAD7425002831E4 /* mztools.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = mztools.c; sourceTree = \"<group>\"; };\n\t\t814B94AB1CAD7425002831E4 /* mztools.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mztools.h; sourceTree = \"<group>\"; };\n\t\t814B94AC1CAD7425002831E4 /* unzip.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = unzip.c; sourceTree = \"<group>\"; };\n\t\t814B94AD1CAD7425002831E4 /* unzip.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = unzip.h; sourceTree = \"<group>\"; };\n\t\t814B94AE1CAD7425002831E4 /* zip.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = zip.c; sourceTree = \"<group>\"; };\n\t\t814B94AF1CAD7425002831E4 /* zip.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = zip.h; sourceTree = \"<group>\"; };\n\t\t81C7FD8E1C89D73E00D306F9 /* libCSBase.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libCSBase.a; sourceTree = BUILT_PRODUCTS_DIR; };\n\t\t81C7FD9D1C89D79B00D306F9 /* CSReachability.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSReachability.h; sourceTree = \"<group>\"; };\n\t\t81C7FD9E1C89D79B00D306F9 /* CSReachability.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CSReachability.m; sourceTree = \"<group>\"; };\n\t\t81C7FDA41C89D79B00D306F9 /* aes.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = aes.c; sourceTree = \"<group>\"; };\n\t\t81C7FDA51C89D79B00D306F9 /* aes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = aes.h; sourceTree = \"<group>\"; };\n\t\t81C7FDA71C89D79B00D306F9 /* base64.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = base64.cpp; sourceTree = \"<group>\"; };\n\t\t81C7FDA81C89D79B00D306F9 /* base64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = base64.h; sourceTree = \"<group>\"; };\n\t\t81C7FDAA1C89D79B00D306F9 /* assertions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = assertions.h; sourceTree = \"<group>\"; };\n\t\t81C7FDAB1C89D79B00D306F9 /* autolink.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = autolink.h; sourceTree = \"<group>\"; };\n\t\t81C7FDAC1C89D79B00D306F9 /* config.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = config.h; sourceTree = \"<group>\"; };\n\t\t81C7FDAD1C89D79B00D306F9 /* features.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = features.h; sourceTree = \"<group>\"; };\n\t\t81C7FDAE1C89D79B00D306F9 /* forwards.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = forwards.h; sourceTree = \"<group>\"; };\n\t\t81C7FDAF1C89D79B00D306F9 /* json.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = json.h; sourceTree = \"<group>\"; };\n\t\t81C7FDB01C89D79B00D306F9 /* json_batchallocator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = json_batchallocator.h; sourceTree = \"<group>\"; };\n\t\t81C7FDB11C89D79B00D306F9 /* json_internalarray.inl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = json_internalarray.inl; sourceTree = \"<group>\"; };\n\t\t81C7FDB21C89D79B00D306F9 /* json_internalmap.inl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = json_internalmap.inl; sourceTree = \"<group>\"; };\n\t\t81C7FDB31C89D79B00D306F9 /* json_reader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = json_reader.cpp; sourceTree = \"<group>\"; };\n\t\t81C7FDB41C89D79B00D306F9 /* json_tool.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = json_tool.h; sourceTree = \"<group>\"; };\n\t\t81C7FDB51C89D79B00D306F9 /* json_value.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = json_value.cpp; sourceTree = \"<group>\"; };\n\t\t81C7FDB61C89D79B00D306F9 /* json_valueiterator.inl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = json_valueiterator.inl; sourceTree = \"<group>\"; };\n\t\t81C7FDB71C89D79B00D306F9 /* json_writer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = json_writer.cpp; sourceTree = \"<group>\"; };\n\t\t81C7FDB81C89D79B00D306F9 /* reader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = reader.h; sourceTree = \"<group>\"; };\n\t\t81C7FDB91C89D79B00D306F9 /* value.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = value.h; sourceTree = \"<group>\"; };\n\t\t81C7FDBA1C89D79B00D306F9 /* version.h.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = version.h.in; sourceTree = \"<group>\"; };\n\t\t81C7FDBB1C89D79B00D306F9 /* writer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = writer.h; sourceTree = \"<group>\"; };\n\t\t81C7FDBD1C89D79B00D306F9 /* md5.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = md5.cpp; sourceTree = \"<group>\"; };\n\t\t81C7FDBE1C89D79B00D306F9 /* md5.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = md5.h; sourceTree = \"<group>\"; };\n\t\t81C7FDCC1C89D79B00D306F9 /* png.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = png.c; sourceTree = \"<group>\"; };\n\t\t81C7FDCD1C89D79B00D306F9 /* png.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = png.h; sourceTree = \"<group>\"; };\n\t\t81C7FDCE1C89D79B00D306F9 /* pngconf.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pngconf.h; sourceTree = \"<group>\"; };\n\t\t81C7FDCF1C89D79B00D306F9 /* pngdebug.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pngdebug.h; sourceTree = \"<group>\"; };\n\t\t81C7FDD01C89D79B00D306F9 /* pngerror.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = pngerror.c; sourceTree = \"<group>\"; };\n\t\t81C7FDD11C89D79B00D306F9 /* pngget.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = pngget.c; sourceTree = \"<group>\"; };\n\t\t81C7FDD21C89D79B00D306F9 /* pnginfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pnginfo.h; sourceTree = \"<group>\"; };\n\t\t81C7FDD31C89D79B00D306F9 /* pnglibconf.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pnglibconf.h; sourceTree = \"<group>\"; };\n\t\t81C7FDD41C89D79B00D306F9 /* pngmem.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = pngmem.c; sourceTree = \"<group>\"; };\n\t\t81C7FDD51C89D79B00D306F9 /* pngpread.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = pngpread.c; sourceTree = \"<group>\"; };\n\t\t81C7FDD61C89D79B00D306F9 /* pngpriv.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pngpriv.h; sourceTree = \"<group>\"; };\n\t\t81C7FDD71C89D79B00D306F9 /* pngread.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = pngread.c; sourceTree = \"<group>\"; };\n\t\t81C7FDD81C89D79B00D306F9 /* pngrio.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = pngrio.c; sourceTree = \"<group>\"; };\n\t\t81C7FDD91C89D79B00D306F9 /* pngrtran.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = pngrtran.c; sourceTree = \"<group>\"; };\n\t\t81C7FDDA1C89D79B00D306F9 /* pngrutil.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = pngrutil.c; sourceTree = \"<group>\"; };\n\t\t81C7FDDB1C89D79B00D306F9 /* pngset.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = pngset.c; sourceTree = \"<group>\"; };\n\t\t81C7FDDC1C89D79B00D306F9 /* pngstruct.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pngstruct.h; sourceTree = \"<group>\"; };\n\t\t81C7FDDD1C89D79B00D306F9 /* pngtest.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = pngtest.c; sourceTree = \"<group>\"; };\n\t\t81C7FDDE1C89D79B00D306F9 /* pngtrans.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = pngtrans.c; sourceTree = \"<group>\"; };\n\t\t81C7FDDF1C89D79B00D306F9 /* pngwio.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = pngwio.c; sourceTree = \"<group>\"; };\n\t\t81C7FDE01C89D79B00D306F9 /* pngwrite.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = pngwrite.c; sourceTree = \"<group>\"; };\n\t\t81C7FDE11C89D79B00D306F9 /* pngwtran.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = pngwtran.c; sourceTree = \"<group>\"; };\n\t\t81C7FDE21C89D79B00D306F9 /* pngwutil.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = pngwutil.c; sourceTree = \"<group>\"; };\n\t\t81C7FDE41C89D79B00D306F9 /* rapidxml.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = rapidxml.hpp; sourceTree = \"<group>\"; };\n\t\t81C7FDE51C89D79B00D306F9 /* rapidxml_iterators.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = rapidxml_iterators.hpp; sourceTree = \"<group>\"; };\n\t\t81C7FDE61C89D79B00D306F9 /* rapidxml_print.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = rapidxml_print.hpp; sourceTree = \"<group>\"; };\n\t\t81C7FDE71C89D79B00D306F9 /* rapidxml_utils.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = rapidxml_utils.hpp; sourceTree = \"<group>\"; };\n\t\t81C7FDE91C89D79B00D306F9 /* HMAC_SHA1.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HMAC_SHA1.cpp; sourceTree = \"<group>\"; };\n\t\t81C7FDEA1C89D79B00D306F9 /* HMAC_SHA1.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HMAC_SHA1.h; sourceTree = \"<group>\"; };\n\t\t81C7FDEB1C89D79B00D306F9 /* SHA1.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SHA1.cpp; sourceTree = \"<group>\"; };\n\t\t81C7FDEC1C89D79B00D306F9 /* SHA1.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SHA1.h; sourceTree = \"<group>\"; };\n\t\t81C7FE0A1C89D84400D306F9 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };\n/* End PBXFileReference section */\n\n/* Begin PBXFrameworksBuildPhase section */\n\t\t81C7FD8B1C89D73E00D306F9 /* Frameworks */ = {\n\t\t\tisa = PBXFrameworksBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t81C7FE0B1C89D84400D306F9 /* Foundation.framework in Frameworks */,\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n/* End PBXFrameworksBuildPhase section */\n\n/* Begin PBXGroup section */\n\t\t27B425951E605D1300E17750 /* SHA256 */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t27B425961E605D1300E17750 /* sha256.cpp */,\n\t\t\t\t27B425971E605D1300E17750 /* sha256.h */,\n\t\t\t);\n\t\t\tpath = SHA256;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t814B94A41CAD7425002831E4 /* minizip */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t814B94A51CAD7425002831E4 /* crypt.h */,\n\t\t\t\t814B94A61CAD7425002831E4 /* ioapi.c */,\n\t\t\t\t814B94A71CAD7425002831E4 /* ioapi.h */,\n\t\t\t\t814B94AA1CAD7425002831E4 /* mztools.c */,\n\t\t\t\t814B94AB1CAD7425002831E4 /* mztools.h */,\n\t\t\t\t814B94AC1CAD7425002831E4 /* unzip.c */,\n\t\t\t\t814B94AD1CAD7425002831E4 /* unzip.h */,\n\t\t\t\t814B94AE1CAD7425002831E4 /* zip.c */,\n\t\t\t\t814B94AF1CAD7425002831E4 /* zip.h */,\n\t\t\t);\n\t\t\tpath = minizip;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t81C7FD851C89D73E00D306F9 = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t81C7FE0C1C89D86900D306F9 /* Frameworks */,\n\t\t\t\t81C7FD9A1C89D79B00D306F9 /* PlatformSource */,\n\t\t\t\t81C7FD8F1C89D73E00D306F9 /* Products */,\n\t\t\t\t81C7FDA21C89D79B00D306F9 /* Source */,\n\t\t\t);\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t81C7FD8F1C89D73E00D306F9 /* Products */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t81C7FD8E1C89D73E00D306F9 /* libCSBase.a */,\n\t\t\t);\n\t\t\tname = Products;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t81C7FD9A1C89D79B00D306F9 /* PlatformSource */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t81C7FD9B1C89D79B00D306F9 /* iOS */,\n\t\t\t);\n\t\t\tpath = PlatformSource;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t81C7FD9B1C89D79B00D306F9 /* iOS */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t81C7FD9C1C89D79B00D306F9 /* Reachability */,\n\t\t\t);\n\t\t\tpath = iOS;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t81C7FD9C1C89D79B00D306F9 /* Reachability */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t81C7FD9D1C89D79B00D306F9 /* CSReachability.h */,\n\t\t\t\t81C7FD9E1C89D79B00D306F9 /* CSReachability.m */,\n\t\t\t);\n\t\t\tpath = Reachability;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t81C7FDA21C89D79B00D306F9 /* Source */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t27B425951E605D1300E17750 /* SHA256 */,\n\t\t\t\t81C7FDA31C89D79B00D306F9 /* aes */,\n\t\t\t\t81C7FDA61C89D79B00D306F9 /* base64 */,\n\t\t\t\t81C7FDA91C89D79B00D306F9 /* json */,\n\t\t\t\t81C7FDBC1C89D79B00D306F9 /* md5 */,\n\t\t\t\t814B94A41CAD7425002831E4 /* minizip */,\n\t\t\t\t81C7FDCB1C89D79B00D306F9 /* png */,\n\t\t\t\t81C7FDE31C89D79B00D306F9 /* rapidxml */,\n\t\t\t\t81C7FDE81C89D79B00D306F9 /* SHA1 */,\n\t\t\t);\n\t\t\tpath = Source;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t81C7FDA31C89D79B00D306F9 /* aes */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t81C7FDA41C89D79B00D306F9 /* aes.c */,\n\t\t\t\t81C7FDA51C89D79B00D306F9 /* aes.h */,\n\t\t\t);\n\t\t\tpath = aes;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t81C7FDA61C89D79B00D306F9 /* base64 */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t81C7FDA71C89D79B00D306F9 /* base64.cpp */,\n\t\t\t\t81C7FDA81C89D79B00D306F9 /* base64.h */,\n\t\t\t);\n\t\t\tpath = base64;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t81C7FDA91C89D79B00D306F9 /* json */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t81C7FDAA1C89D79B00D306F9 /* assertions.h */,\n\t\t\t\t81C7FDAB1C89D79B00D306F9 /* autolink.h */,\n\t\t\t\t81C7FDAC1C89D79B00D306F9 /* config.h */,\n\t\t\t\t81C7FDAD1C89D79B00D306F9 /* features.h */,\n\t\t\t\t81C7FDAE1C89D79B00D306F9 /* forwards.h */,\n\t\t\t\t81C7FDAF1C89D79B00D306F9 /* json.h */,\n\t\t\t\t81C7FDB01C89D79B00D306F9 /* json_batchallocator.h */,\n\t\t\t\t81C7FDB11C89D79B00D306F9 /* json_internalarray.inl */,\n\t\t\t\t81C7FDB21C89D79B00D306F9 /* json_internalmap.inl */,\n\t\t\t\t81C7FDB31C89D79B00D306F9 /* json_reader.cpp */,\n\t\t\t\t81C7FDB41C89D79B00D306F9 /* json_tool.h */,\n\t\t\t\t81C7FDB51C89D79B00D306F9 /* json_value.cpp */,\n\t\t\t\t81C7FDB61C89D79B00D306F9 /* json_valueiterator.inl */,\n\t\t\t\t81C7FDB71C89D79B00D306F9 /* json_writer.cpp */,\n\t\t\t\t81C7FDB81C89D79B00D306F9 /* reader.h */,\n\t\t\t\t81C7FDB91C89D79B00D306F9 /* value.h */,\n\t\t\t\t81C7FDBA1C89D79B00D306F9 /* version.h.in */,\n\t\t\t\t81C7FDBB1C89D79B00D306F9 /* writer.h */,\n\t\t\t);\n\t\t\tpath = json;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t81C7FDBC1C89D79B00D306F9 /* md5 */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t81C7FDBD1C89D79B00D306F9 /* md5.cpp */,\n\t\t\t\t81C7FDBE1C89D79B00D306F9 /* md5.h */,\n\t\t\t);\n\t\t\tpath = md5;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t81C7FDCB1C89D79B00D306F9 /* png */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t81C7FDCC1C89D79B00D306F9 /* png.c */,\n\t\t\t\t81C7FDCD1C89D79B00D306F9 /* png.h */,\n\t\t\t\t81C7FDCE1C89D79B00D306F9 /* pngconf.h */,\n\t\t\t\t81C7FDCF1C89D79B00D306F9 /* pngdebug.h */,\n\t\t\t\t81C7FDD01C89D79B00D306F9 /* pngerror.c */,\n\t\t\t\t81C7FDD11C89D79B00D306F9 /* pngget.c */,\n\t\t\t\t81C7FDD21C89D79B00D306F9 /* pnginfo.h */,\n\t\t\t\t81C7FDD31C89D79B00D306F9 /* pnglibconf.h */,\n\t\t\t\t81C7FDD41C89D79B00D306F9 /* pngmem.c */,\n\t\t\t\t81C7FDD51C89D79B00D306F9 /* pngpread.c */,\n\t\t\t\t81C7FDD61C89D79B00D306F9 /* pngpriv.h */,\n\t\t\t\t81C7FDD71C89D79B00D306F9 /* pngread.c */,\n\t\t\t\t81C7FDD81C89D79B00D306F9 /* pngrio.c */,\n\t\t\t\t81C7FDD91C89D79B00D306F9 /* pngrtran.c */,\n\t\t\t\t81C7FDDA1C89D79B00D306F9 /* pngrutil.c */,\n\t\t\t\t81C7FDDB1C89D79B00D306F9 /* pngset.c */,\n\t\t\t\t81C7FDDC1C89D79B00D306F9 /* pngstruct.h */,\n\t\t\t\t81C7FDDD1C89D79B00D306F9 /* pngtest.c */,\n\t\t\t\t81C7FDDE1C89D79B00D306F9 /* pngtrans.c */,\n\t\t\t\t81C7FDDF1C89D79B00D306F9 /* pngwio.c */,\n\t\t\t\t81C7FDE01C89D79B00D306F9 /* pngwrite.c */,\n\t\t\t\t81C7FDE11C89D79B00D306F9 /* pngwtran.c */,\n\t\t\t\t81C7FDE21C89D79B00D306F9 /* pngwutil.c */,\n\t\t\t);\n\t\t\tpath = png;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t81C7FDE31C89D79B00D306F9 /* rapidxml */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t81C7FDE41C89D79B00D306F9 /* rapidxml.hpp */,\n\t\t\t\t81C7FDE51C89D79B00D306F9 /* rapidxml_iterators.hpp */,\n\t\t\t\t81C7FDE61C89D79B00D306F9 /* rapidxml_print.hpp */,\n\t\t\t\t81C7FDE71C89D79B00D306F9 /* rapidxml_utils.hpp */,\n\t\t\t);\n\t\t\tpath = rapidxml;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t81C7FDE81C89D79B00D306F9 /* SHA1 */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t81C7FDE91C89D79B00D306F9 /* HMAC_SHA1.cpp */,\n\t\t\t\t81C7FDEA1C89D79B00D306F9 /* HMAC_SHA1.h */,\n\t\t\t\t81C7FDEB1C89D79B00D306F9 /* SHA1.cpp */,\n\t\t\t\t81C7FDEC1C89D79B00D306F9 /* SHA1.h */,\n\t\t\t);\n\t\t\tpath = SHA1;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t81C7FE0C1C89D86900D306F9 /* Frameworks */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t81C7FE0A1C89D84400D306F9 /* Foundation.framework */,\n\t\t\t);\n\t\t\tname = Frameworks;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n/* End PBXGroup section */\n\n/* Begin PBXNativeTarget section */\n\t\t81C7FD8D1C89D73E00D306F9 /* CSBase */ = {\n\t\t\tisa = PBXNativeTarget;\n\t\t\tbuildConfigurationList = 81C7FD971C89D73E00D306F9 /* Build configuration list for PBXNativeTarget \"CSBase\" */;\n\t\t\tbuildPhases = (\n\t\t\t\t81C7FD8A1C89D73E00D306F9 /* Sources */,\n\t\t\t\t81C7FD8B1C89D73E00D306F9 /* Frameworks */,\n\t\t\t\t81C7FD8C1C89D73E00D306F9 /* CopyFiles */,\n\t\t\t);\n\t\t\tbuildRules = (\n\t\t\t);\n\t\t\tdependencies = (\n\t\t\t);\n\t\t\tname = CSBase;\n\t\t\tproductName = CSBase;\n\t\t\tproductReference = 81C7FD8E1C89D73E00D306F9 /* libCSBase.a */;\n\t\t\tproductType = \"com.apple.product-type.library.static\";\n\t\t};\n/* End PBXNativeTarget section */\n\n/* Begin PBXProject section */\n\t\t81C7FD861C89D73E00D306F9 /* Project object */ = {\n\t\t\tisa = PBXProject;\n\t\t\tattributes = {\n\t\t\t\tLastUpgradeCheck = 0720;\n\t\t\t\tORGANIZATIONNAME = \"Tag Games\";\n\t\t\t\tTargetAttributes = {\n\t\t\t\t\t81C7FD8D1C89D73E00D306F9 = {\n\t\t\t\t\t\tCreatedOnToolsVersion = 7.2.1;\n\t\t\t\t\t};\n\t\t\t\t\t81C7FE0D1C89D8D800D306F9 = {\n\t\t\t\t\t\tCreatedOnToolsVersion = 7.2.1;\n\t\t\t\t\t};\n\t\t\t\t};\n\t\t\t};\n\t\t\tbuildConfigurationList = 81C7FD891C89D73E00D306F9 /* Build configuration list for PBXProject \"CSBase\" */;\n\t\t\tcompatibilityVersion = \"Xcode 3.2\";\n\t\t\tdevelopmentRegion = English;\n\t\t\thasScannedForEncodings = 0;\n\t\t\tknownRegions = (\n\t\t\t\ten,\n\t\t\t);\n\t\t\tmainGroup = 81C7FD851C89D73E00D306F9;\n\t\t\tproductRefGroup = 81C7FD8F1C89D73E00D306F9 /* Products */;\n\t\t\tprojectDirPath = \"\";\n\t\t\tprojectRoot = \"\";\n\t\t\ttargets = (\n\t\t\t\t81C7FD8D1C89D73E00D306F9 /* CSBase */,\n\t\t\t\t81C7FE0D1C89D8D800D306F9 /* UniversalLib */,\n\t\t\t);\n\t\t};\n/* End PBXProject section */\n\n/* Begin PBXShellScriptBuildPhase section */\n\t\t81C7FE111C89D8E000D306F9 /* ShellScript */ = {\n\t\t\tisa = PBXShellScriptBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t);\n\t\t\tinputPaths = (\n\t\t\t);\n\t\t\toutputPaths = (\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t\tshellPath = /bin/sh;\n\t\t\tshellScript = \"# define output folder environment variable\\nUNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/${CONFIGURATION}-universal\\n\\n# Step 1. Build Device and Simulator versions\\nxcodebuild -target CSBase ONLY_ACTIVE_ARCH=NO -configuration ${CONFIGURATION} -sdk iphoneos BUILD_DIR=\\\"${BUILD_DIR}\\\" BUILD_ROOT=\\\"${BUILD_ROOT}\\\"\\nxcodebuild -target CSBase ONLY_ACTIVE_ARCH=NO -configuration ${CONFIGURATION} -sdk iphonesimulator BUILD_DIR=\\\"${BUILD_DIR}\\\" BUILD_ROOT=\\\"${BUILD_ROOT}\\\"\\n\\n# make sure the output directory exists\\nmkdir -p \\\"${UNIVERSAL_OUTPUTFOLDER}\\\"\\n\\n# Step 2. Create universal binary file using lipo\\nUNIVERSAL_OUTOUT_FILE_PATH=\\\"${UNIVERSAL_OUTPUTFOLDER}/lib${PROJECT_NAME}.a\\\"\\nlipo -create -output \\\"${UNIVERSAL_OUTOUT_FILE_PATH}\\\" \\\"${BUILD_DIR}/${CONFIGURATION}-iphoneos/lib${PROJECT_NAME}.a\\\" \\\"${BUILD_DIR}/${CONFIGURATION}-iphonesimulator/lib${PROJECT_NAME}.a\\\"\\n\\n#copy headers\\npython ../../../Tools/Scripts/extract_headers.py -i \\\"Source/\\\" -o \\\"${UNIVERSAL_OUTPUTFOLDER}/Headers/\\\"\\npython ../../../Tools/Scripts/extract_headers.py -i \\\"PlatformSource/iOS/\\\" -o \\\"${UNIVERSAL_OUTPUTFOLDER}/iOSHeaders/\\\"\";\n\t\t};\n/* End PBXShellScriptBuildPhase section */\n\n/* Begin PBXSourcesBuildPhase section */\n\t\t81C7FD8A1C89D73E00D306F9 /* Sources */ = {\n\t\t\tisa = PBXSourcesBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t27B425981E60724300E17750 /* sha256.cpp in Sources */,\n\t\t\t\t81C7FDF01C89D79B00D306F9 /* json_reader.cpp in Sources */,\n\t\t\t\t81C7FDED1C89D79B00D306F9 /* CSReachability.m in Sources */,\n\t\t\t\t814B94B31CAD7425002831E4 /* unzip.c in Sources */,\n\t\t\t\t814B94B41CAD7425002831E4 /* zip.c in Sources */,\n\t\t\t\t81C7FDFB1C89D79B00D306F9 /* pngmem.c in Sources */,\n\t\t\t\t81C7FE061C89D79B00D306F9 /* pngwtran.c in Sources */,\n\t\t\t\t81C7FDF81C89D79B00D306F9 /* png.c in Sources */,\n\t\t\t\t81C7FE041C89D79B00D306F9 /* pngwio.c in Sources */,\n\t\t\t\t81C7FE031C89D79B00D306F9 /* pngtrans.c in Sources */,\n\t\t\t\t81C7FDFF1C89D79B00D306F9 /* pngrtran.c in Sources */,\n\t\t\t\t81C7FDF11C89D79B00D306F9 /* json_value.cpp in Sources */,\n\t\t\t\t81C7FE001C89D79B00D306F9 /* pngrutil.c in Sources */,\n\t\t\t\t81C7FDEE1C89D79B00D306F9 /* aes.c in Sources */,\n\t\t\t\t81C7FDFA1C89D79B00D306F9 /* pngget.c in Sources */,\n\t\t\t\t81C7FDF91C89D79B00D306F9 /* pngerror.c in Sources */,\n\t\t\t\t81C7FE071C89D79B00D306F9 /* pngwutil.c in Sources */,\n\t\t\t\t814B94B01CAD7425002831E4 /* ioapi.c in Sources */,\n\t\t\t\t81C7FE011C89D79B00D306F9 /* pngset.c in Sources */,\n\t\t\t\t81C7FE091C89D79B00D306F9 /* SHA1.cpp in Sources */,\n\t\t\t\t814B94B21CAD7425002831E4 /* mztools.c in Sources */,\n\t\t\t\t81C7FE021C89D79B00D306F9 /* pngtest.c in Sources */,\n\t\t\t\t81C7FE051C89D79B00D306F9 /* pngwrite.c in Sources */,\n\t\t\t\t81C7FDFC1C89D79B00D306F9 /* pngpread.c in Sources */,\n\t\t\t\t81C7FDF21C89D79B00D306F9 /* json_writer.cpp in Sources */,\n\t\t\t\t81C7FDFE1C89D79B00D306F9 /* pngrio.c in Sources */,\n\t\t\t\t81C7FDFD1C89D79B00D306F9 /* pngread.c in Sources */,\n\t\t\t\t81C7FDF31C89D79B00D306F9 /* md5.cpp in Sources */,\n\t\t\t\t81C7FDEF1C89D79B00D306F9 /* base64.cpp in Sources */,\n\t\t\t\t81C7FE081C89D79B00D306F9 /* HMAC_SHA1.cpp in Sources */,\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n/* End PBXSourcesBuildPhase section */\n\n/* Begin XCBuildConfiguration section */\n\t\t81C7FD951C89D73E00D306F9 /* Debug */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tALWAYS_SEARCH_USER_PATHS = NO;\n\t\t\t\tCLANG_CXX_LANGUAGE_STANDARD = \"gnu++0x\";\n\t\t\t\tCLANG_CXX_LIBRARY = \"libc++\";\n\t\t\t\tCLANG_ENABLE_MODULES = YES;\n\t\t\t\tCLANG_ENABLE_OBJC_ARC = YES;\n\t\t\t\tCLANG_WARN_BOOL_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_CONSTANT_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;\n\t\t\t\tCLANG_WARN_EMPTY_BODY = YES;\n\t\t\t\tCLANG_WARN_ENUM_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_INT_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;\n\t\t\t\tCLANG_WARN_UNREACHABLE_CODE = YES;\n\t\t\t\tCLANG_WARN__DUPLICATE_METHOD_MATCH = YES;\n\t\t\t\t\"CODE_SIGN_IDENTITY[sdk=iphoneos*]\" = \"iPhone Developer\";\n\t\t\t\tCOPY_PHASE_STRIP = NO;\n\t\t\t\tDEBUG_INFORMATION_FORMAT = dwarf;\n\t\t\t\tENABLE_STRICT_OBJC_MSGSEND = YES;\n\t\t\t\tENABLE_TESTABILITY = YES;\n\t\t\t\tGCC_C_LANGUAGE_STANDARD = gnu99;\n\t\t\t\tGCC_DYNAMIC_NO_PIC = NO;\n\t\t\t\tGCC_NO_COMMON_BLOCKS = YES;\n\t\t\t\tGCC_OPTIMIZATION_LEVEL = 0;\n\t\t\t\tGCC_PREPROCESSOR_DEFINITIONS = (\n\t\t\t\t\t\"DEBUG=1\",\n\t\t\t\t\tUSE_FILE32API,\n\t\t\t\t\t\"$(inherited)\",\n\t\t\t\t);\n\t\t\t\tGCC_WARN_64_TO_32_BIT_CONVERSION = YES;\n\t\t\t\tGCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;\n\t\t\t\tGCC_WARN_UNDECLARED_SELECTOR = YES;\n\t\t\t\tGCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;\n\t\t\t\tGCC_WARN_UNUSED_FUNCTION = YES;\n\t\t\t\tGCC_WARN_UNUSED_VARIABLE = YES;\n\t\t\t\tHEADER_SEARCH_PATHS = (\n\t\t\t\t\t\"$(SRCROOT)/Source\",\n\t\t\t\t\t\"$(SRCROOT)/Platform/Source\",\n\t\t\t\t);\n\t\t\t\tIPHONEOS_DEPLOYMENT_TARGET = 8.0;\n\t\t\t\tMTL_ENABLE_DEBUG_INFO = YES;\n\t\t\t\tONLY_ACTIVE_ARCH = YES;\n\t\t\t\tSDKROOT = iphoneos;\n\t\t\t};\n\t\t\tname = Debug;\n\t\t};\n\t\t81C7FD961C89D73E00D306F9 /* Release */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tALWAYS_SEARCH_USER_PATHS = NO;\n\t\t\t\tCLANG_CXX_LANGUAGE_STANDARD = \"gnu++0x\";\n\t\t\t\tCLANG_CXX_LIBRARY = \"libc++\";\n\t\t\t\tCLANG_ENABLE_MODULES = YES;\n\t\t\t\tCLANG_ENABLE_OBJC_ARC = YES;\n\t\t\t\tCLANG_WARN_BOOL_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_CONSTANT_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;\n\t\t\t\tCLANG_WARN_EMPTY_BODY = YES;\n\t\t\t\tCLANG_WARN_ENUM_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_INT_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;\n\t\t\t\tCLANG_WARN_UNREACHABLE_CODE = YES;\n\t\t\t\tCLANG_WARN__DUPLICATE_METHOD_MATCH = YES;\n\t\t\t\t\"CODE_SIGN_IDENTITY[sdk=iphoneos*]\" = \"iPhone Developer\";\n\t\t\t\tCOPY_PHASE_STRIP = NO;\n\t\t\t\tDEBUG_INFORMATION_FORMAT = \"dwarf-with-dsym\";\n\t\t\t\tENABLE_NS_ASSERTIONS = NO;\n\t\t\t\tENABLE_STRICT_OBJC_MSGSEND = YES;\n\t\t\t\tGCC_C_LANGUAGE_STANDARD = gnu99;\n\t\t\t\tGCC_NO_COMMON_BLOCKS = YES;\n\t\t\t\tGCC_PREPROCESSOR_DEFINITIONS = USE_FILE32API;\n\t\t\t\tGCC_WARN_64_TO_32_BIT_CONVERSION = YES;\n\t\t\t\tGCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;\n\t\t\t\tGCC_WARN_UNDECLARED_SELECTOR = YES;\n\t\t\t\tGCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;\n\t\t\t\tGCC_WARN_UNUSED_FUNCTION = YES;\n\t\t\t\tGCC_WARN_UNUSED_VARIABLE = YES;\n\t\t\t\tHEADER_SEARCH_PATHS = (\n\t\t\t\t\t\"$(SRCROOT)/Source\",\n\t\t\t\t\t\"$(SRCROOT)/Platform/Source\",\n\t\t\t\t);\n\t\t\t\tIPHONEOS_DEPLOYMENT_TARGET = 8.0;\n\t\t\t\tMTL_ENABLE_DEBUG_INFO = NO;\n\t\t\t\tSDKROOT = iphoneos;\n\t\t\t\tVALIDATE_PRODUCT = YES;\n\t\t\t};\n\t\t\tname = Release;\n\t\t};\n\t\t81C7FD981C89D73E00D306F9 /* Debug */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tOTHER_LDFLAGS = \"-ObjC\";\n\t\t\t\tPRODUCT_NAME = \"$(TARGET_NAME)\";\n\t\t\t\tSKIP_INSTALL = YES;\n\t\t\t};\n\t\t\tname = Debug;\n\t\t};\n\t\t81C7FD991C89D73E00D306F9 /* Release */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tOTHER_LDFLAGS = \"-ObjC\";\n\t\t\t\tPRODUCT_NAME = \"$(TARGET_NAME)\";\n\t\t\t\tSKIP_INSTALL = YES;\n\t\t\t};\n\t\t\tname = Release;\n\t\t};\n\t\t81C7FE0F1C89D8D800D306F9 /* Debug */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tPRODUCT_NAME = \"$(TARGET_NAME)\";\n\t\t\t};\n\t\t\tname = Debug;\n\t\t};\n\t\t81C7FE101C89D8D800D306F9 /* Release */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tPRODUCT_NAME = \"$(TARGET_NAME)\";\n\t\t\t};\n\t\t\tname = Release;\n\t\t};\n/* End XCBuildConfiguration section */\n\n/* Begin XCConfigurationList section */\n\t\t81C7FD891C89D73E00D306F9 /* Build configuration list for PBXProject \"CSBase\" */ = {\n\t\t\tisa = XCConfigurationList;\n\t\t\tbuildConfigurations = (\n\t\t\t\t81C7FD951C89D73E00D306F9 /* Debug */,\n\t\t\t\t81C7FD961C89D73E00D306F9 /* Release */,\n\t\t\t);\n\t\t\tdefaultConfigurationIsVisible = 0;\n\t\t\tdefaultConfigurationName = Release;\n\t\t};\n\t\t81C7FD971C89D73E00D306F9 /* Build configuration list for PBXNativeTarget \"CSBase\" */ = {\n\t\t\tisa = XCConfigurationList;\n\t\t\tbuildConfigurations = (\n\t\t\t\t81C7FD981C89D73E00D306F9 /* Debug */,\n\t\t\t\t81C7FD991C89D73E00D306F9 /* Release */,\n\t\t\t);\n\t\t\tdefaultConfigurationIsVisible = 0;\n\t\t\tdefaultConfigurationName = Release;\n\t\t};\n\t\t81C7FE0E1C89D8D800D306F9 /* Build configuration list for PBXAggregateTarget \"UniversalLib\" */ = {\n\t\t\tisa = XCConfigurationList;\n\t\t\tbuildConfigurations = (\n\t\t\t\t81C7FE0F1C89D8D800D306F9 /* Debug */,\n\t\t\t\t81C7FE101C89D8D800D306F9 /* Release */,\n\t\t\t);\n\t\t\tdefaultConfigurationIsVisible = 0;\n\t\t\tdefaultConfigurationName = Release;\n\t\t};\n/* End XCConfigurationList section */\n\t};\n\trootObject = 81C7FD861C89D73E00D306F9 /* Project object */;\n}\n"
  },
  {
    "path": "Projects/Libraries/CSBase/CSBase.xcodeproj/project.xcworkspace/contents.xcworkspacedata",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Workspace\n   version = \"1.0\">\n   <FileRef\n      location = \"self:\">\n   </FileRef>\n</Workspace>\n"
  },
  {
    "path": "Projects/Libraries/CSBase/CSBase.xcodeproj/xcshareddata/xcschemes/CSBase.xcscheme",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Scheme\n   LastUpgradeVersion = \"0730\"\n   version = \"1.3\">\n   <BuildAction\n      parallelizeBuildables = \"YES\"\n      buildImplicitDependencies = \"YES\">\n      <BuildActionEntries>\n         <BuildActionEntry\n            buildForTesting = \"YES\"\n            buildForRunning = \"YES\"\n            buildForProfiling = \"YES\"\n            buildForArchiving = \"YES\"\n            buildForAnalyzing = \"YES\">\n            <BuildableReference\n               BuildableIdentifier = \"primary\"\n               BlueprintIdentifier = \"81C7FD8D1C89D73E00D306F9\"\n               BuildableName = \"libCSBase.a\"\n               BlueprintName = \"CSBase\"\n               ReferencedContainer = \"container:CSBase.xcodeproj\">\n            </BuildableReference>\n         </BuildActionEntry>\n      </BuildActionEntries>\n   </BuildAction>\n   <TestAction\n      buildConfiguration = \"Debug\"\n      selectedDebuggerIdentifier = \"Xcode.DebuggerFoundation.Debugger.LLDB\"\n      selectedLauncherIdentifier = \"Xcode.DebuggerFoundation.Launcher.LLDB\"\n      shouldUseLaunchSchemeArgsEnv = \"YES\">\n      <Testables>\n      </Testables>\n      <AdditionalOptions>\n      </AdditionalOptions>\n   </TestAction>\n   <LaunchAction\n      buildConfiguration = \"Debug\"\n      selectedDebuggerIdentifier = \"Xcode.DebuggerFoundation.Debugger.LLDB\"\n      selectedLauncherIdentifier = \"Xcode.DebuggerFoundation.Launcher.LLDB\"\n      launchStyle = \"0\"\n      useCustomWorkingDirectory = \"NO\"\n      ignoresPersistentStateOnLaunch = \"NO\"\n      debugDocumentVersioning = \"YES\"\n      debugServiceExtension = \"internal\"\n      allowLocationSimulation = \"YES\">\n      <MacroExpansion>\n         <BuildableReference\n            BuildableIdentifier = \"primary\"\n            BlueprintIdentifier = \"81C7FD8D1C89D73E00D306F9\"\n            BuildableName = \"libCSBase.a\"\n            BlueprintName = \"CSBase\"\n            ReferencedContainer = \"container:CSBase.xcodeproj\">\n         </BuildableReference>\n      </MacroExpansion>\n      <AdditionalOptions>\n      </AdditionalOptions>\n   </LaunchAction>\n   <ProfileAction\n      buildConfiguration = \"Release\"\n      shouldUseLaunchSchemeArgsEnv = \"YES\"\n      savedToolIdentifier = \"\"\n      useCustomWorkingDirectory = \"NO\"\n      debugDocumentVersioning = \"YES\">\n      <MacroExpansion>\n         <BuildableReference\n            BuildableIdentifier = \"primary\"\n            BlueprintIdentifier = \"81C7FD8D1C89D73E00D306F9\"\n            BuildableName = \"libCSBase.a\"\n            BlueprintName = \"CSBase\"\n            ReferencedContainer = \"container:CSBase.xcodeproj\">\n         </BuildableReference>\n      </MacroExpansion>\n   </ProfileAction>\n   <AnalyzeAction\n      buildConfiguration = \"Debug\">\n   </AnalyzeAction>\n   <ArchiveAction\n      buildConfiguration = \"Release\"\n      revealArchiveInOrganizer = \"YES\">\n   </ArchiveAction>\n</Scheme>\n"
  },
  {
    "path": "Projects/Libraries/CSBase/CSBase.xcodeproj/xcshareddata/xcschemes/UniversalLib.xcscheme",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Scheme\n   LastUpgradeVersion = \"0730\"\n   version = \"1.3\">\n   <BuildAction\n      parallelizeBuildables = \"YES\"\n      buildImplicitDependencies = \"YES\">\n      <BuildActionEntries>\n         <BuildActionEntry\n            buildForTesting = \"YES\"\n            buildForRunning = \"YES\"\n            buildForProfiling = \"YES\"\n            buildForArchiving = \"YES\"\n            buildForAnalyzing = \"YES\">\n            <BuildableReference\n               BuildableIdentifier = \"primary\"\n               BlueprintIdentifier = \"81C7FE0D1C89D8D800D306F9\"\n               BuildableName = \"UniversalLib\"\n               BlueprintName = \"UniversalLib\"\n               ReferencedContainer = \"container:CSBase.xcodeproj\">\n            </BuildableReference>\n         </BuildActionEntry>\n      </BuildActionEntries>\n   </BuildAction>\n   <TestAction\n      buildConfiguration = \"Debug\"\n      selectedDebuggerIdentifier = \"Xcode.DebuggerFoundation.Debugger.LLDB\"\n      selectedLauncherIdentifier = \"Xcode.DebuggerFoundation.Launcher.LLDB\"\n      shouldUseLaunchSchemeArgsEnv = \"YES\">\n      <Testables>\n      </Testables>\n      <AdditionalOptions>\n      </AdditionalOptions>\n   </TestAction>\n   <LaunchAction\n      buildConfiguration = \"Debug\"\n      selectedDebuggerIdentifier = \"Xcode.DebuggerFoundation.Debugger.LLDB\"\n      selectedLauncherIdentifier = \"Xcode.DebuggerFoundation.Launcher.LLDB\"\n      launchStyle = \"0\"\n      useCustomWorkingDirectory = \"NO\"\n      ignoresPersistentStateOnLaunch = \"NO\"\n      debugDocumentVersioning = \"YES\"\n      debugServiceExtension = \"internal\"\n      allowLocationSimulation = \"YES\">\n      <MacroExpansion>\n         <BuildableReference\n            BuildableIdentifier = \"primary\"\n            BlueprintIdentifier = \"81C7FE0D1C89D8D800D306F9\"\n            BuildableName = \"UniversalLib\"\n            BlueprintName = \"UniversalLib\"\n            ReferencedContainer = \"container:CSBase.xcodeproj\">\n         </BuildableReference>\n      </MacroExpansion>\n      <AdditionalOptions>\n      </AdditionalOptions>\n   </LaunchAction>\n   <ProfileAction\n      buildConfiguration = \"Release\"\n      shouldUseLaunchSchemeArgsEnv = \"YES\"\n      savedToolIdentifier = \"\"\n      useCustomWorkingDirectory = \"NO\"\n      debugDocumentVersioning = \"YES\">\n      <MacroExpansion>\n         <BuildableReference\n            BuildableIdentifier = \"primary\"\n            BlueprintIdentifier = \"81C7FE0D1C89D8D800D306F9\"\n            BuildableName = \"UniversalLib\"\n            BlueprintName = \"UniversalLib\"\n            ReferencedContainer = \"container:CSBase.xcodeproj\">\n         </BuildableReference>\n      </MacroExpansion>\n   </ProfileAction>\n   <AnalyzeAction\n      buildConfiguration = \"Debug\">\n   </AnalyzeAction>\n   <ArchiveAction\n      buildConfiguration = \"Release\"\n      revealArchiveInOrganizer = \"YES\">\n   </ArchiveAction>\n</Scheme>\n"
  },
  {
    "path": "Projects/Libraries/CSBase/PlatformSource/RPi/zconf.h",
    "content": "/* zconf.h -- configuration of the zlib compression library\n * Copyright (C) 1995-2010 Jean-loup Gailly.\n * For conditions of distribution and use, see copyright notice in zlib.h\n */\n\n/* @(#) $Id$ */\n\n#ifndef ZCONF_H\n#define ZCONF_H\n\n/*\n * If you *really* need a unique prefix for all types and library functions,\n * compile with -DZ_PREFIX. The \"standard\" zlib should be compiled without it.\n * Even better than compiling with -DZ_PREFIX would be to use configure to set\n * this permanently in zconf.h using \"./configure --zprefix\".\n */\n#ifdef Z_PREFIX     /* may be set to #if 1 by ./configure */\n\n/* all linked symbols */\n#  define _dist_code            z__dist_code\n#  define _length_code          z__length_code\n#  define _tr_align             z__tr_align\n#  define _tr_flush_block       z__tr_flush_block\n#  define _tr_init              z__tr_init\n#  define _tr_stored_block      z__tr_stored_block\n#  define _tr_tally             z__tr_tally\n#  define adler32               z_adler32\n#  define adler32_combine       z_adler32_combine\n#  define adler32_combine64     z_adler32_combine64\n#  define compress              z_compress\n#  define compress2             z_compress2\n#  define compressBound         z_compressBound\n#  define crc32                 z_crc32\n#  define crc32_combine         z_crc32_combine\n#  define crc32_combine64       z_crc32_combine64\n#  define deflate               z_deflate\n#  define deflateBound          z_deflateBound\n#  define deflateCopy           z_deflateCopy\n#  define deflateEnd            z_deflateEnd\n#  define deflateInit2_         z_deflateInit2_\n#  define deflateInit_          z_deflateInit_\n#  define deflateParams         z_deflateParams\n#  define deflatePrime          z_deflatePrime\n#  define deflateReset          z_deflateReset\n#  define deflateSetDictionary  z_deflateSetDictionary\n#  define deflateSetHeader      z_deflateSetHeader\n#  define deflateTune           z_deflateTune\n#  define deflate_copyright     z_deflate_copyright\n#  define get_crc_table         z_get_crc_table\n#  define gz_error              z_gz_error\n#  define gz_intmax             z_gz_intmax\n#  define gz_strwinerror        z_gz_strwinerror\n#  define gzbuffer              z_gzbuffer\n#  define gzclearerr            z_gzclearerr\n#  define gzclose               z_gzclose\n#  define gzclose_r             z_gzclose_r\n#  define gzclose_w             z_gzclose_w\n#  define gzdirect              z_gzdirect\n#  define gzdopen               z_gzdopen\n#  define gzeof                 z_gzeof\n#  define gzerror               z_gzerror\n#  define gzflush               z_gzflush\n#  define gzgetc                z_gzgetc\n#  define gzgets                z_gzgets\n#  define gzoffset              z_gzoffset\n#  define gzoffset64            z_gzoffset64\n#  define gzopen                z_gzopen\n#  define gzopen64              z_gzopen64\n#  define gzprintf              z_gzprintf\n#  define gzputc                z_gzputc\n#  define gzputs                z_gzputs\n#  define gzread                z_gzread\n#  define gzrewind              z_gzrewind\n#  define gzseek                z_gzseek\n#  define gzseek64              z_gzseek64\n#  define gzsetparams           z_gzsetparams\n#  define gztell                z_gztell\n#  define gztell64              z_gztell64\n#  define gzungetc              z_gzungetc\n#  define gzwrite               z_gzwrite\n#  define inflate               z_inflate\n#  define inflateBack           z_inflateBack\n#  define inflateBackEnd        z_inflateBackEnd\n#  define inflateBackInit_      z_inflateBackInit_\n#  define inflateCopy           z_inflateCopy\n#  define inflateEnd            z_inflateEnd\n#  define inflateGetHeader      z_inflateGetHeader\n#  define inflateInit2_         z_inflateInit2_\n#  define inflateInit_          z_inflateInit_\n#  define inflateMark           z_inflateMark\n#  define inflatePrime          z_inflatePrime\n#  define inflateReset          z_inflateReset\n#  define inflateReset2         z_inflateReset2\n#  define inflateSetDictionary  z_inflateSetDictionary\n#  define inflateSync           z_inflateSync\n#  define inflateSyncPoint      z_inflateSyncPoint\n#  define inflateUndermine      z_inflateUndermine\n#  define inflate_copyright     z_inflate_copyright\n#  define inflate_fast          z_inflate_fast\n#  define inflate_table         z_inflate_table\n#  define uncompress            z_uncompress\n#  define zError                z_zError\n#  define zcalloc               z_zcalloc\n#  define zcfree                z_zcfree\n#  define zlibCompileFlags      z_zlibCompileFlags\n#  define zlibVersion           z_zlibVersion\n\n/* all zlib typedefs in zlib.h and zconf.h */\n#  define Byte                  z_Byte\n#  define Bytef                 z_Bytef\n#  define alloc_func            z_alloc_func\n#  define charf                 z_charf\n#  define free_func             z_free_func\n#  define gzFile                z_gzFile\n#  define gz_header             z_gz_header\n#  define gz_headerp            z_gz_headerp\n#  define in_func               z_in_func\n#  define intf                  z_intf\n#  define out_func              z_out_func\n#  define uInt                  z_uInt\n#  define uIntf                 z_uIntf\n#  define uLong                 z_uLong\n#  define uLongf                z_uLongf\n#  define voidp                 z_voidp\n#  define voidpc                z_voidpc\n#  define voidpf                z_voidpf\n\n/* all zlib structs in zlib.h and zconf.h */\n#  define gz_header_s           z_gz_header_s\n#  define internal_state        z_internal_state\n\n#endif\n\n#if defined(__MSDOS__) && !defined(MSDOS)\n#  define MSDOS\n#endif\n#if (defined(OS_2) || defined(__OS2__)) && !defined(OS2)\n#  define OS2\n#endif\n#if defined(_WINDOWS) && !defined(WINDOWS)\n#  define WINDOWS\n#endif\n#if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__)\n#  ifndef WIN32\n#    define WIN32\n#  endif\n#endif\n#if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32)\n#  if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__)\n#    ifndef SYS16BIT\n#      define SYS16BIT\n#    endif\n#  endif\n#endif\n\n/*\n * Compile with -DMAXSEG_64K if the alloc function cannot allocate more\n * than 64k bytes at a time (needed on systems with 16-bit int).\n */\n#ifdef SYS16BIT\n#  define MAXSEG_64K\n#endif\n#ifdef MSDOS\n#  define UNALIGNED_OK\n#endif\n\n#ifdef __STDC_VERSION__\n#  ifndef STDC\n#    define STDC\n#  endif\n#  if __STDC_VERSION__ >= 199901L\n#    ifndef STDC99\n#      define STDC99\n#    endif\n#  endif\n#endif\n#if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus))\n#  define STDC\n#endif\n#if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__))\n#  define STDC\n#endif\n#if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32))\n#  define STDC\n#endif\n#if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__))\n#  define STDC\n#endif\n\n#if defined(__OS400__) && !defined(STDC)    /* iSeries (formerly AS/400). */\n#  define STDC\n#endif\n\n#ifndef STDC\n#  ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */\n#    define const       /* note: need a more gentle solution here */\n#  endif\n#endif\n\n/* Some Mac compilers merge all .h files incorrectly: */\n#if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__)\n#  define NO_DUMMY_DECL\n#endif\n\n/* Maximum value for memLevel in deflateInit2 */\n#ifndef MAX_MEM_LEVEL\n#  ifdef MAXSEG_64K\n#    define MAX_MEM_LEVEL 8\n#  else\n#    define MAX_MEM_LEVEL 9\n#  endif\n#endif\n\n/* Maximum value for windowBits in deflateInit2 and inflateInit2.\n * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files\n * created by gzip. (Files created by minigzip can still be extracted by\n * gzip.)\n */\n#ifndef MAX_WBITS\n#  define MAX_WBITS   15 /* 32K LZ77 window */\n#endif\n\n/* The memory requirements for deflate are (in bytes):\n            (1 << (windowBits+2)) +  (1 << (memLevel+9))\n that is: 128K for windowBits=15  +  128K for memLevel = 8  (default values)\n plus a few kilobytes for small objects. For example, if you want to reduce\n the default memory requirements from 256K to 128K, compile with\n     make CFLAGS=\"-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7\"\n Of course this will generally degrade compression (there's no free lunch).\n\n   The memory requirements for inflate are (in bytes) 1 << windowBits\n that is, 32K for windowBits=15 (default value) plus a few kilobytes\n for small objects.\n*/\n\n                        /* Type declarations */\n\n#ifndef OF /* function prototypes */\n#  ifdef STDC\n#    define OF(args)  args\n#  else\n#    define OF(args)  ()\n#  endif\n#endif\n\n/* The following definitions for FAR are needed only for MSDOS mixed\n * model programming (small or medium model with some far allocations).\n * This was tested only with MSC; for other MSDOS compilers you may have\n * to define NO_MEMCPY in zutil.h.  If you don't need the mixed model,\n * just define FAR to be empty.\n */\n#ifdef SYS16BIT\n#  if defined(M_I86SM) || defined(M_I86MM)\n     /* MSC small or medium model */\n#    define SMALL_MEDIUM\n#    ifdef _MSC_VER\n#      define FAR _far\n#    else\n#      define FAR far\n#    endif\n#  endif\n#  if (defined(__SMALL__) || defined(__MEDIUM__))\n     /* Turbo C small or medium model */\n#    define SMALL_MEDIUM\n#    ifdef __BORLANDC__\n#      define FAR _far\n#    else\n#      define FAR far\n#    endif\n#  endif\n#endif\n\n#if defined(WINDOWS) || defined(WIN32)\n   /* If building or using zlib as a DLL, define ZLIB_DLL.\n    * This is not mandatory, but it offers a little performance increase.\n    */\n#  ifdef ZLIB_DLL\n#    if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500))\n#      ifdef ZLIB_INTERNAL\n#        define ZEXTERN extern __declspec(dllexport)\n#      else\n#        define ZEXTERN extern __declspec(dllimport)\n#      endif\n#    endif\n#  endif  /* ZLIB_DLL */\n   /* If building or using zlib with the WINAPI/WINAPIV calling convention,\n    * define ZLIB_WINAPI.\n    * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI.\n    */\n#  ifdef ZLIB_WINAPI\n#    ifdef FAR\n#      undef FAR\n#    endif\n#    include <windows.h>\n     /* No need for _export, use ZLIB.DEF instead. */\n     /* For complete Windows compatibility, use WINAPI, not __stdcall. */\n#    define ZEXPORT WINAPI\n#    ifdef WIN32\n#      define ZEXPORTVA WINAPIV\n#    else\n#      define ZEXPORTVA FAR CDECL\n#    endif\n#  endif\n#endif\n\n#if defined (__BEOS__)\n#  ifdef ZLIB_DLL\n#    ifdef ZLIB_INTERNAL\n#      define ZEXPORT   __declspec(dllexport)\n#      define ZEXPORTVA __declspec(dllexport)\n#    else\n#      define ZEXPORT   __declspec(dllimport)\n#      define ZEXPORTVA __declspec(dllimport)\n#    endif\n#  endif\n#endif\n\n#ifndef ZEXTERN\n#  define ZEXTERN extern\n#endif\n#ifndef ZEXPORT\n#  define ZEXPORT\n#endif\n#ifndef ZEXPORTVA\n#  define ZEXPORTVA\n#endif\n\n#ifndef FAR\n#  define FAR\n#endif\n\n#if !defined(__MACTYPES__)\ntypedef unsigned char  Byte;  /* 8 bits */\n#endif\ntypedef unsigned int   uInt;  /* 16 bits or more */\ntypedef unsigned long  uLong; /* 32 bits or more */\n\n#ifdef SMALL_MEDIUM\n   /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */\n#  define Bytef Byte FAR\n#else\n   typedef Byte  FAR Bytef;\n#endif\ntypedef char  FAR charf;\ntypedef int   FAR intf;\ntypedef uInt  FAR uIntf;\ntypedef uLong FAR uLongf;\n\n#ifdef STDC\n   typedef void const *voidpc;\n   typedef void FAR   *voidpf;\n   typedef void       *voidp;\n#else\n   typedef Byte const *voidpc;\n   typedef Byte FAR   *voidpf;\n   typedef Byte       *voidp;\n#endif\n\n#ifdef HAVE_UNISTD_H    /* may be set to #if 1 by ./configure */\n#  define Z_HAVE_UNISTD_H\n#endif\n\n#ifdef STDC\n#  include <sys/types.h>    /* for off_t */\n#endif\n\n/* a little trick to accommodate both \"#define _LARGEFILE64_SOURCE\" and\n * \"#define _LARGEFILE64_SOURCE 1\" as requesting 64-bit operations, (even\n * though the former does not conform to the LFS document), but considering\n * both \"#undef _LARGEFILE64_SOURCE\" and \"#define _LARGEFILE64_SOURCE 0\" as\n * equivalently requesting no 64-bit operations\n */\n#if -_LARGEFILE64_SOURCE - -1 == 1\n#  undef _LARGEFILE64_SOURCE\n#endif\n\n#if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE)\n#  include <unistd.h>       /* for SEEK_* and off_t */\n#  ifdef VMS\n#    include <unixio.h>     /* for off_t */\n#  endif\n#  ifndef z_off_t\n#    define z_off_t off_t\n#  endif\n#endif\n\n#ifndef SEEK_SET\n#  define SEEK_SET        0       /* Seek from beginning of file.  */\n#  define SEEK_CUR        1       /* Seek from current position.  */\n#  define SEEK_END        2       /* Set file pointer to EOF plus \"offset\" */\n#endif\n\n#ifndef z_off_t\n#  define z_off_t long\n#endif\n\n#if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0\n#  define z_off64_t off64_t\n#else\n#  define z_off64_t z_off_t\n#endif\n\n#if defined(__OS400__)\n#  define NO_vsnprintf\n#endif\n\n#if defined(__MVS__)\n#  define NO_vsnprintf\n#endif\n\n/* MVS linker does not support external names larger than 8 bytes */\n#if defined(__MVS__)\n  #pragma map(deflateInit_,\"DEIN\")\n  #pragma map(deflateInit2_,\"DEIN2\")\n  #pragma map(deflateEnd,\"DEEND\")\n  #pragma map(deflateBound,\"DEBND\")\n  #pragma map(inflateInit_,\"ININ\")\n  #pragma map(inflateInit2_,\"ININ2\")\n  #pragma map(inflateEnd,\"INEND\")\n  #pragma map(inflateSync,\"INSY\")\n  #pragma map(inflateSetDictionary,\"INSEDI\")\n  #pragma map(compressBound,\"CMBND\")\n  #pragma map(inflate_table,\"INTABL\")\n  #pragma map(inflate_fast,\"INFA\")\n  #pragma map(inflate_copyright,\"INCOPY\")\n#endif\n\n#endif /* ZCONF_H */\n"
  },
  {
    "path": "Projects/Libraries/CSBase/PlatformSource/RPi/zlib.h",
    "content": "/* zlib.h -- interface of the 'zlib' general purpose compression library\n  version 1.2.5, April 19th, 2010\n\n  Copyright (C) 1995-2010 Jean-loup Gailly and Mark Adler\n\n  This software is provided 'as-is', without any express or implied\n  warranty.  In no event will the authors be held liable for any damages\n  arising from the use of this software.\n\n  Permission is granted to anyone to use this software for any purpose,\n  including commercial applications, and to alter it and redistribute it\n  freely, subject to the following restrictions:\n\n  1. The origin of this software must not be misrepresented; you must not\n     claim that you wrote the original software. If you use this software\n     in a product, an acknowledgment in the product documentation would be\n     appreciated but is not required.\n  2. Altered source versions must be plainly marked as such, and must not be\n     misrepresented as being the original software.\n  3. This notice may not be removed or altered from any source distribution.\n\n  Jean-loup Gailly        Mark Adler\n  jloup@gzip.org          madler@alumni.caltech.edu\n\n\n  The data format used by the zlib library is described by RFCs (Request for\n  Comments) 1950 to 1952 in the files http://www.ietf.org/rfc/rfc1950.txt\n  (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format).\n*/\n\n#ifndef ZLIB_H\n#define ZLIB_H\n\n#include \"zconf.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#define ZLIB_VERSION \"1.2.5\"\n#define ZLIB_VERNUM 0x1250\n#define ZLIB_VER_MAJOR 1\n#define ZLIB_VER_MINOR 2\n#define ZLIB_VER_REVISION 5\n#define ZLIB_VER_SUBREVISION 0\n\n/*\n    The 'zlib' compression library provides in-memory compression and\n  decompression functions, including integrity checks of the uncompressed data.\n  This version of the library supports only one compression method (deflation)\n  but other algorithms will be added later and will have the same stream\n  interface.\n\n    Compression can be done in a single step if the buffers are large enough,\n  or can be done by repeated calls of the compression function.  In the latter\n  case, the application must provide more input and/or consume the output\n  (providing more output space) before each call.\n\n    The compressed data format used by default by the in-memory functions is\n  the zlib format, which is a zlib wrapper documented in RFC 1950, wrapped\n  around a deflate stream, which is itself documented in RFC 1951.\n\n    The library also supports reading and writing files in gzip (.gz) format\n  with an interface similar to that of stdio using the functions that start\n  with \"gz\".  The gzip format is different from the zlib format.  gzip is a\n  gzip wrapper, documented in RFC 1952, wrapped around a deflate stream.\n\n    This library can optionally read and write gzip streams in memory as well.\n\n    The zlib format was designed to be compact and fast for use in memory\n  and on communications channels.  The gzip format was designed for single-\n  file compression on file systems, has a larger header than zlib to maintain\n  directory information, and uses a different, slower check method than zlib.\n\n    The library does not install any signal handler.  The decoder checks\n  the consistency of the compressed data, so the library should never crash\n  even in case of corrupted input.\n*/\n\ntypedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size));\ntypedef void   (*free_func)  OF((voidpf opaque, voidpf address));\n\nstruct internal_state;\n\ntypedef struct z_stream_s {\n    Bytef    *next_in;  /* next input byte */\n    uInt     avail_in;  /* number of bytes available at next_in */\n    uLong    total_in;  /* total nb of input bytes read so far */\n\n    Bytef    *next_out; /* next output byte should be put there */\n    uInt     avail_out; /* remaining free space at next_out */\n    uLong    total_out; /* total nb of bytes output so far */\n\n    char     *msg;      /* last error message, NULL if no error */\n    struct internal_state FAR *state; /* not visible by applications */\n\n    alloc_func zalloc;  /* used to allocate the internal state */\n    free_func  zfree;   /* used to free the internal state */\n    voidpf     opaque;  /* private data object passed to zalloc and zfree */\n\n    int     data_type;  /* best guess about the data type: binary or text */\n    uLong   adler;      /* adler32 value of the uncompressed data */\n    uLong   reserved;   /* reserved for future use */\n} z_stream;\n\ntypedef z_stream FAR *z_streamp;\n\n/*\n     gzip header information passed to and from zlib routines.  See RFC 1952\n  for more details on the meanings of these fields.\n*/\ntypedef struct gz_header_s {\n    int     text;       /* true if compressed data believed to be text */\n    uLong   time;       /* modification time */\n    int     xflags;     /* extra flags (not used when writing a gzip file) */\n    int     os;         /* operating system */\n    Bytef   *extra;     /* pointer to extra field or Z_NULL if none */\n    uInt    extra_len;  /* extra field length (valid if extra != Z_NULL) */\n    uInt    extra_max;  /* space at extra (only when reading header) */\n    Bytef   *name;      /* pointer to zero-terminated file name or Z_NULL */\n    uInt    name_max;   /* space at name (only when reading header) */\n    Bytef   *comment;   /* pointer to zero-terminated comment or Z_NULL */\n    uInt    comm_max;   /* space at comment (only when reading header) */\n    int     hcrc;       /* true if there was or will be a header crc */\n    int     done;       /* true when done reading gzip header (not used\n                           when writing a gzip file) */\n} gz_header;\n\ntypedef gz_header FAR *gz_headerp;\n\n/*\n     The application must update next_in and avail_in when avail_in has dropped\n   to zero.  It must update next_out and avail_out when avail_out has dropped\n   to zero.  The application must initialize zalloc, zfree and opaque before\n   calling the init function.  All other fields are set by the compression\n   library and must not be updated by the application.\n\n     The opaque value provided by the application will be passed as the first\n   parameter for calls of zalloc and zfree.  This can be useful for custom\n   memory management.  The compression library attaches no meaning to the\n   opaque value.\n\n     zalloc must return Z_NULL if there is not enough memory for the object.\n   If zlib is used in a multi-threaded application, zalloc and zfree must be\n   thread safe.\n\n     On 16-bit systems, the functions zalloc and zfree must be able to allocate\n   exactly 65536 bytes, but will not be required to allocate more than this if\n   the symbol MAXSEG_64K is defined (see zconf.h).  WARNING: On MSDOS, pointers\n   returned by zalloc for objects of exactly 65536 bytes *must* have their\n   offset normalized to zero.  The default allocation function provided by this\n   library ensures this (see zutil.c).  To reduce memory requirements and avoid\n   any allocation of 64K objects, at the expense of compression ratio, compile\n   the library with -DMAX_WBITS=14 (see zconf.h).\n\n     The fields total_in and total_out can be used for statistics or progress\n   reports.  After compression, total_in holds the total size of the\n   uncompressed data and may be saved for use in the decompressor (particularly\n   if the decompressor wants to decompress everything in a single step).\n*/\n\n                        /* constants */\n\n#define Z_NO_FLUSH      0\n#define Z_PARTIAL_FLUSH 1\n#define Z_SYNC_FLUSH    2\n#define Z_FULL_FLUSH    3\n#define Z_FINISH        4\n#define Z_BLOCK         5\n#define Z_TREES         6\n/* Allowed flush values; see deflate() and inflate() below for details */\n\n#define Z_OK            0\n#define Z_STREAM_END    1\n#define Z_NEED_DICT     2\n#define Z_ERRNO        (-1)\n#define Z_STREAM_ERROR (-2)\n#define Z_DATA_ERROR   (-3)\n#define Z_MEM_ERROR    (-4)\n#define Z_BUF_ERROR    (-5)\n#define Z_VERSION_ERROR (-6)\n/* Return codes for the compression/decompression functions. Negative values\n * are errors, positive values are used for special but normal events.\n */\n\n#define Z_NO_COMPRESSION         0\n#define Z_BEST_SPEED             1\n#define Z_BEST_COMPRESSION       9\n#define Z_DEFAULT_COMPRESSION  (-1)\n/* compression levels */\n\n#define Z_FILTERED            1\n#define Z_HUFFMAN_ONLY        2\n#define Z_RLE                 3\n#define Z_FIXED               4\n#define Z_DEFAULT_STRATEGY    0\n/* compression strategy; see deflateInit2() below for details */\n\n#define Z_BINARY   0\n#define Z_TEXT     1\n#define Z_ASCII    Z_TEXT   /* for compatibility with 1.2.2 and earlier */\n#define Z_UNKNOWN  2\n/* Possible values of the data_type field (though see inflate()) */\n\n#define Z_DEFLATED   8\n/* The deflate compression method (the only one supported in this version) */\n\n#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */\n\n#define zlib_version zlibVersion()\n/* for compatibility with versions < 1.0.2 */\n\n\n                        /* basic functions */\n\nZEXTERN const char * ZEXPORT zlibVersion OF((void));\n/* The application can compare zlibVersion and ZLIB_VERSION for consistency.\n   If the first character differs, the library code actually used is not\n   compatible with the zlib.h header file used by the application.  This check\n   is automatically made by deflateInit and inflateInit.\n */\n\n/*\nZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level));\n\n     Initializes the internal stream state for compression.  The fields\n   zalloc, zfree and opaque must be initialized before by the caller.  If\n   zalloc and zfree are set to Z_NULL, deflateInit updates them to use default\n   allocation functions.\n\n     The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9:\n   1 gives best speed, 9 gives best compression, 0 gives no compression at all\n   (the input data is simply copied a block at a time).  Z_DEFAULT_COMPRESSION\n   requests a default compromise between speed and compression (currently\n   equivalent to level 6).\n\n     deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough\n   memory, Z_STREAM_ERROR if level is not a valid compression level, or\n   Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible\n   with the version assumed by the caller (ZLIB_VERSION).  msg is set to null\n   if there is no error message.  deflateInit does not perform any compression:\n   this will be done by deflate().\n*/\n\n\nZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush));\n/*\n    deflate compresses as much data as possible, and stops when the input\n  buffer becomes empty or the output buffer becomes full.  It may introduce\n  some output latency (reading input without producing any output) except when\n  forced to flush.\n\n    The detailed semantics are as follows.  deflate performs one or both of the\n  following actions:\n\n  - Compress more input starting at next_in and update next_in and avail_in\n    accordingly.  If not all input can be processed (because there is not\n    enough room in the output buffer), next_in and avail_in are updated and\n    processing will resume at this point for the next call of deflate().\n\n  - Provide more output starting at next_out and update next_out and avail_out\n    accordingly.  This action is forced if the parameter flush is non zero.\n    Forcing flush frequently degrades the compression ratio, so this parameter\n    should be set only when necessary (in interactive applications).  Some\n    output may be provided even if flush is not set.\n\n    Before the call of deflate(), the application should ensure that at least\n  one of the actions is possible, by providing more input and/or consuming more\n  output, and updating avail_in or avail_out accordingly; avail_out should\n  never be zero before the call.  The application can consume the compressed\n  output when it wants, for example when the output buffer is full (avail_out\n  == 0), or after each call of deflate().  If deflate returns Z_OK and with\n  zero avail_out, it must be called again after making room in the output\n  buffer because there might be more output pending.\n\n    Normally the parameter flush is set to Z_NO_FLUSH, which allows deflate to\n  decide how much data to accumulate before producing output, in order to\n  maximize compression.\n\n    If the parameter flush is set to Z_SYNC_FLUSH, all pending output is\n  flushed to the output buffer and the output is aligned on a byte boundary, so\n  that the decompressor can get all input data available so far.  (In\n  particular avail_in is zero after the call if enough output space has been\n  provided before the call.) Flushing may degrade compression for some\n  compression algorithms and so it should be used only when necessary.  This\n  completes the current deflate block and follows it with an empty stored block\n  that is three bits plus filler bits to the next byte, followed by four bytes\n  (00 00 ff ff).\n\n    If flush is set to Z_PARTIAL_FLUSH, all pending output is flushed to the\n  output buffer, but the output is not aligned to a byte boundary.  All of the\n  input data so far will be available to the decompressor, as for Z_SYNC_FLUSH.\n  This completes the current deflate block and follows it with an empty fixed\n  codes block that is 10 bits long.  This assures that enough bytes are output\n  in order for the decompressor to finish the block before the empty fixed code\n  block.\n\n    If flush is set to Z_BLOCK, a deflate block is completed and emitted, as\n  for Z_SYNC_FLUSH, but the output is not aligned on a byte boundary, and up to\n  seven bits of the current block are held to be written as the next byte after\n  the next deflate block is completed.  In this case, the decompressor may not\n  be provided enough bits at this point in order to complete decompression of\n  the data provided so far to the compressor.  It may need to wait for the next\n  block to be emitted.  This is for advanced applications that need to control\n  the emission of deflate blocks.\n\n    If flush is set to Z_FULL_FLUSH, all output is flushed as with\n  Z_SYNC_FLUSH, and the compression state is reset so that decompression can\n  restart from this point if previous compressed data has been damaged or if\n  random access is desired.  Using Z_FULL_FLUSH too often can seriously degrade\n  compression.\n\n    If deflate returns with avail_out == 0, this function must be called again\n  with the same value of the flush parameter and more output space (updated\n  avail_out), until the flush is complete (deflate returns with non-zero\n  avail_out).  In the case of a Z_FULL_FLUSH or Z_SYNC_FLUSH, make sure that\n  avail_out is greater than six to avoid repeated flush markers due to\n  avail_out == 0 on return.\n\n    If the parameter flush is set to Z_FINISH, pending input is processed,\n  pending output is flushed and deflate returns with Z_STREAM_END if there was\n  enough output space; if deflate returns with Z_OK, this function must be\n  called again with Z_FINISH and more output space (updated avail_out) but no\n  more input data, until it returns with Z_STREAM_END or an error.  After\n  deflate has returned Z_STREAM_END, the only possible operations on the stream\n  are deflateReset or deflateEnd.\n\n    Z_FINISH can be used immediately after deflateInit if all the compression\n  is to be done in a single step.  In this case, avail_out must be at least the\n  value returned by deflateBound (see below).  If deflate does not return\n  Z_STREAM_END, then it must be called again as described above.\n\n    deflate() sets strm->adler to the adler32 checksum of all input read\n  so far (that is, total_in bytes).\n\n    deflate() may update strm->data_type if it can make a good guess about\n  the input data type (Z_BINARY or Z_TEXT).  In doubt, the data is considered\n  binary.  This field is only for information purposes and does not affect the\n  compression algorithm in any manner.\n\n    deflate() returns Z_OK if some progress has been made (more input\n  processed or more output produced), Z_STREAM_END if all input has been\n  consumed and all output has been produced (only when flush is set to\n  Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example\n  if next_in or next_out was Z_NULL), Z_BUF_ERROR if no progress is possible\n  (for example avail_in or avail_out was zero).  Note that Z_BUF_ERROR is not\n  fatal, and deflate() can be called again with more input and more output\n  space to continue compressing.\n*/\n\n\nZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm));\n/*\n     All dynamically allocated data structures for this stream are freed.\n   This function discards any unprocessed input and does not flush any pending\n   output.\n\n     deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the\n   stream state was inconsistent, Z_DATA_ERROR if the stream was freed\n   prematurely (some input or output was discarded).  In the error case, msg\n   may be set but then points to a static string (which must not be\n   deallocated).\n*/\n\n\n/*\nZEXTERN int ZEXPORT inflateInit OF((z_streamp strm));\n\n     Initializes the internal stream state for decompression.  The fields\n   next_in, avail_in, zalloc, zfree and opaque must be initialized before by\n   the caller.  If next_in is not Z_NULL and avail_in is large enough (the\n   exact value depends on the compression method), inflateInit determines the\n   compression method from the zlib header and allocates all data structures\n   accordingly; otherwise the allocation will be deferred to the first call of\n   inflate.  If zalloc and zfree are set to Z_NULL, inflateInit updates them to\n   use default allocation functions.\n\n     inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough\n   memory, Z_VERSION_ERROR if the zlib library version is incompatible with the\n   version assumed by the caller, or Z_STREAM_ERROR if the parameters are\n   invalid, such as a null pointer to the structure.  msg is set to null if\n   there is no error message.  inflateInit does not perform any decompression\n   apart from possibly reading the zlib header if present: actual decompression\n   will be done by inflate().  (So next_in and avail_in may be modified, but\n   next_out and avail_out are unused and unchanged.) The current implementation\n   of inflateInit() does not process any header information -- that is deferred\n   until inflate() is called.\n*/\n\n\nZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush));\n/*\n    inflate decompresses as much data as possible, and stops when the input\n  buffer becomes empty or the output buffer becomes full.  It may introduce\n  some output latency (reading input without producing any output) except when\n  forced to flush.\n\n  The detailed semantics are as follows.  inflate performs one or both of the\n  following actions:\n\n  - Decompress more input starting at next_in and update next_in and avail_in\n    accordingly.  If not all input can be processed (because there is not\n    enough room in the output buffer), next_in is updated and processing will\n    resume at this point for the next call of inflate().\n\n  - Provide more output starting at next_out and update next_out and avail_out\n    accordingly.  inflate() provides as much output as possible, until there is\n    no more input data or no more space in the output buffer (see below about\n    the flush parameter).\n\n    Before the call of inflate(), the application should ensure that at least\n  one of the actions is possible, by providing more input and/or consuming more\n  output, and updating the next_* and avail_* values accordingly.  The\n  application can consume the uncompressed output when it wants, for example\n  when the output buffer is full (avail_out == 0), or after each call of\n  inflate().  If inflate returns Z_OK and with zero avail_out, it must be\n  called again after making room in the output buffer because there might be\n  more output pending.\n\n    The flush parameter of inflate() can be Z_NO_FLUSH, Z_SYNC_FLUSH, Z_FINISH,\n  Z_BLOCK, or Z_TREES.  Z_SYNC_FLUSH requests that inflate() flush as much\n  output as possible to the output buffer.  Z_BLOCK requests that inflate()\n  stop if and when it gets to the next deflate block boundary.  When decoding\n  the zlib or gzip format, this will cause inflate() to return immediately\n  after the header and before the first block.  When doing a raw inflate,\n  inflate() will go ahead and process the first block, and will return when it\n  gets to the end of that block, or when it runs out of data.\n\n    The Z_BLOCK option assists in appending to or combining deflate streams.\n  Also to assist in this, on return inflate() will set strm->data_type to the\n  number of unused bits in the last byte taken from strm->next_in, plus 64 if\n  inflate() is currently decoding the last block in the deflate stream, plus\n  128 if inflate() returned immediately after decoding an end-of-block code or\n  decoding the complete header up to just before the first byte of the deflate\n  stream.  The end-of-block will not be indicated until all of the uncompressed\n  data from that block has been written to strm->next_out.  The number of\n  unused bits may in general be greater than seven, except when bit 7 of\n  data_type is set, in which case the number of unused bits will be less than\n  eight.  data_type is set as noted here every time inflate() returns for all\n  flush options, and so can be used to determine the amount of currently\n  consumed input in bits.\n\n    The Z_TREES option behaves as Z_BLOCK does, but it also returns when the\n  end of each deflate block header is reached, before any actual data in that\n  block is decoded.  This allows the caller to determine the length of the\n  deflate block header for later use in random access within a deflate block.\n  256 is added to the value of strm->data_type when inflate() returns\n  immediately after reaching the end of the deflate block header.\n\n    inflate() should normally be called until it returns Z_STREAM_END or an\n  error.  However if all decompression is to be performed in a single step (a\n  single call of inflate), the parameter flush should be set to Z_FINISH.  In\n  this case all pending input is processed and all pending output is flushed;\n  avail_out must be large enough to hold all the uncompressed data.  (The size\n  of the uncompressed data may have been saved by the compressor for this\n  purpose.) The next operation on this stream must be inflateEnd to deallocate\n  the decompression state.  The use of Z_FINISH is never required, but can be\n  used to inform inflate that a faster approach may be used for the single\n  inflate() call.\n\n     In this implementation, inflate() always flushes as much output as\n  possible to the output buffer, and always uses the faster approach on the\n  first call.  So the only effect of the flush parameter in this implementation\n  is on the return value of inflate(), as noted below, or when it returns early\n  because Z_BLOCK or Z_TREES is used.\n\n     If a preset dictionary is needed after this call (see inflateSetDictionary\n  below), inflate sets strm->adler to the adler32 checksum of the dictionary\n  chosen by the compressor and returns Z_NEED_DICT; otherwise it sets\n  strm->adler to the adler32 checksum of all output produced so far (that is,\n  total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as described\n  below.  At the end of the stream, inflate() checks that its computed adler32\n  checksum is equal to that saved by the compressor and returns Z_STREAM_END\n  only if the checksum is correct.\n\n    inflate() can decompress and check either zlib-wrapped or gzip-wrapped\n  deflate data.  The header type is detected automatically, if requested when\n  initializing with inflateInit2().  Any information contained in the gzip\n  header is not retained, so applications that need that information should\n  instead use raw inflate, see inflateInit2() below, or inflateBack() and\n  perform their own processing of the gzip header and trailer.\n\n    inflate() returns Z_OK if some progress has been made (more input processed\n  or more output produced), Z_STREAM_END if the end of the compressed data has\n  been reached and all uncompressed output has been produced, Z_NEED_DICT if a\n  preset dictionary is needed at this point, Z_DATA_ERROR if the input data was\n  corrupted (input stream not conforming to the zlib format or incorrect check\n  value), Z_STREAM_ERROR if the stream structure was inconsistent (for example\n  next_in or next_out was Z_NULL), Z_MEM_ERROR if there was not enough memory,\n  Z_BUF_ERROR if no progress is possible or if there was not enough room in the\n  output buffer when Z_FINISH is used.  Note that Z_BUF_ERROR is not fatal, and\n  inflate() can be called again with more input and more output space to\n  continue decompressing.  If Z_DATA_ERROR is returned, the application may\n  then call inflateSync() to look for a good compression block if a partial\n  recovery of the data is desired.\n*/\n\n\nZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm));\n/*\n     All dynamically allocated data structures for this stream are freed.\n   This function discards any unprocessed input and does not flush any pending\n   output.\n\n     inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state\n   was inconsistent.  In the error case, msg may be set but then points to a\n   static string (which must not be deallocated).\n*/\n\n\n                        /* Advanced functions */\n\n/*\n    The following functions are needed only in some special applications.\n*/\n\n/*\nZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm,\n                                     int  level,\n                                     int  method,\n                                     int  windowBits,\n                                     int  memLevel,\n                                     int  strategy));\n\n     This is another version of deflateInit with more compression options.  The\n   fields next_in, zalloc, zfree and opaque must be initialized before by the\n   caller.\n\n     The method parameter is the compression method.  It must be Z_DEFLATED in\n   this version of the library.\n\n     The windowBits parameter is the base two logarithm of the window size\n   (the size of the history buffer).  It should be in the range 8..15 for this\n   version of the library.  Larger values of this parameter result in better\n   compression at the expense of memory usage.  The default value is 15 if\n   deflateInit is used instead.\n\n     windowBits can also be -8..-15 for raw deflate.  In this case, -windowBits\n   determines the window size.  deflate() will then generate raw deflate data\n   with no zlib header or trailer, and will not compute an adler32 check value.\n\n     windowBits can also be greater than 15 for optional gzip encoding.  Add\n   16 to windowBits to write a simple gzip header and trailer around the\n   compressed data instead of a zlib wrapper.  The gzip header will have no\n   file name, no extra data, no comment, no modification time (set to zero), no\n   header crc, and the operating system will be set to 255 (unknown).  If a\n   gzip stream is being written, strm->adler is a crc32 instead of an adler32.\n\n     The memLevel parameter specifies how much memory should be allocated\n   for the internal compression state.  memLevel=1 uses minimum memory but is\n   slow and reduces compression ratio; memLevel=9 uses maximum memory for\n   optimal speed.  The default value is 8.  See zconf.h for total memory usage\n   as a function of windowBits and memLevel.\n\n     The strategy parameter is used to tune the compression algorithm.  Use the\n   value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a\n   filter (or predictor), Z_HUFFMAN_ONLY to force Huffman encoding only (no\n   string match), or Z_RLE to limit match distances to one (run-length\n   encoding).  Filtered data consists mostly of small values with a somewhat\n   random distribution.  In this case, the compression algorithm is tuned to\n   compress them better.  The effect of Z_FILTERED is to force more Huffman\n   coding and less string matching; it is somewhat intermediate between\n   Z_DEFAULT_STRATEGY and Z_HUFFMAN_ONLY.  Z_RLE is designed to be almost as\n   fast as Z_HUFFMAN_ONLY, but give better compression for PNG image data.  The\n   strategy parameter only affects the compression ratio but not the\n   correctness of the compressed output even if it is not set appropriately.\n   Z_FIXED prevents the use of dynamic Huffman codes, allowing for a simpler\n   decoder for special applications.\n\n     deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough\n   memory, Z_STREAM_ERROR if any parameter is invalid (such as an invalid\n   method), or Z_VERSION_ERROR if the zlib library version (zlib_version) is\n   incompatible with the version assumed by the caller (ZLIB_VERSION).  msg is\n   set to null if there is no error message.  deflateInit2 does not perform any\n   compression: this will be done by deflate().\n*/\n\nZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm,\n                                             const Bytef *dictionary,\n                                             uInt  dictLength));\n/*\n     Initializes the compression dictionary from the given byte sequence\n   without producing any compressed output.  This function must be called\n   immediately after deflateInit, deflateInit2 or deflateReset, before any call\n   of deflate.  The compressor and decompressor must use exactly the same\n   dictionary (see inflateSetDictionary).\n\n     The dictionary should consist of strings (byte sequences) that are likely\n   to be encountered later in the data to be compressed, with the most commonly\n   used strings preferably put towards the end of the dictionary.  Using a\n   dictionary is most useful when the data to be compressed is short and can be\n   predicted with good accuracy; the data can then be compressed better than\n   with the default empty dictionary.\n\n     Depending on the size of the compression data structures selected by\n   deflateInit or deflateInit2, a part of the dictionary may in effect be\n   discarded, for example if the dictionary is larger than the window size\n   provided in deflateInit or deflateInit2.  Thus the strings most likely to be\n   useful should be put at the end of the dictionary, not at the front.  In\n   addition, the current implementation of deflate will use at most the window\n   size minus 262 bytes of the provided dictionary.\n\n     Upon return of this function, strm->adler is set to the adler32 value\n   of the dictionary; the decompressor may later use this value to determine\n   which dictionary has been used by the compressor.  (The adler32 value\n   applies to the whole dictionary even if only a subset of the dictionary is\n   actually used by the compressor.) If a raw deflate was requested, then the\n   adler32 value is not computed and strm->adler is not set.\n\n     deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a\n   parameter is invalid (e.g.  dictionary being Z_NULL) or the stream state is\n   inconsistent (for example if deflate has already been called for this stream\n   or if the compression method is bsort).  deflateSetDictionary does not\n   perform any compression: this will be done by deflate().\n*/\n\nZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest,\n                                    z_streamp source));\n/*\n     Sets the destination stream as a complete copy of the source stream.\n\n     This function can be useful when several compression strategies will be\n   tried, for example when there are several ways of pre-processing the input\n   data with a filter.  The streams that will be discarded should then be freed\n   by calling deflateEnd.  Note that deflateCopy duplicates the internal\n   compression state which can be quite large, so this strategy is slow and can\n   consume lots of memory.\n\n     deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not\n   enough memory, Z_STREAM_ERROR if the source stream state was inconsistent\n   (such as zalloc being Z_NULL).  msg is left unchanged in both source and\n   destination.\n*/\n\nZEXTERN int ZEXPORT deflateReset OF((z_streamp strm));\n/*\n     This function is equivalent to deflateEnd followed by deflateInit,\n   but does not free and reallocate all the internal compression state.  The\n   stream will keep the same compression level and any other attributes that\n   may have been set by deflateInit2.\n\n     deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source\n   stream state was inconsistent (such as zalloc or state being Z_NULL).\n*/\n\nZEXTERN int ZEXPORT deflateParams OF((z_streamp strm,\n                                      int level,\n                                      int strategy));\n/*\n     Dynamically update the compression level and compression strategy.  The\n   interpretation of level and strategy is as in deflateInit2.  This can be\n   used to switch between compression and straight copy of the input data, or\n   to switch to a different kind of input data requiring a different strategy.\n   If the compression level is changed, the input available so far is\n   compressed with the old level (and may be flushed); the new level will take\n   effect only at the next call of deflate().\n\n     Before the call of deflateParams, the stream state must be set as for\n   a call of deflate(), since the currently available input may have to be\n   compressed and flushed.  In particular, strm->avail_out must be non-zero.\n\n     deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source\n   stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR if\n   strm->avail_out was zero.\n*/\n\nZEXTERN int ZEXPORT deflateTune OF((z_streamp strm,\n                                    int good_length,\n                                    int max_lazy,\n                                    int nice_length,\n                                    int max_chain));\n/*\n     Fine tune deflate's internal compression parameters.  This should only be\n   used by someone who understands the algorithm used by zlib's deflate for\n   searching for the best matching string, and even then only by the most\n   fanatic optimizer trying to squeeze out the last compressed bit for their\n   specific input data.  Read the deflate.c source code for the meaning of the\n   max_lazy, good_length, nice_length, and max_chain parameters.\n\n     deflateTune() can be called after deflateInit() or deflateInit2(), and\n   returns Z_OK on success, or Z_STREAM_ERROR for an invalid deflate stream.\n */\n\nZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm,\n                                       uLong sourceLen));\n/*\n     deflateBound() returns an upper bound on the compressed size after\n   deflation of sourceLen bytes.  It must be called after deflateInit() or\n   deflateInit2(), and after deflateSetHeader(), if used.  This would be used\n   to allocate an output buffer for deflation in a single pass, and so would be\n   called before deflate().\n*/\n\nZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm,\n                                     int bits,\n                                     int value));\n/*\n     deflatePrime() inserts bits in the deflate output stream.  The intent\n   is that this function is used to start off the deflate output with the bits\n   leftover from a previous deflate stream when appending to it.  As such, this\n   function can only be used for raw deflate, and must be used before the first\n   deflate() call after a deflateInit2() or deflateReset().  bits must be less\n   than or equal to 16, and that many of the least significant bits of value\n   will be inserted in the output.\n\n     deflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source\n   stream state was inconsistent.\n*/\n\nZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm,\n                                         gz_headerp head));\n/*\n     deflateSetHeader() provides gzip header information for when a gzip\n   stream is requested by deflateInit2().  deflateSetHeader() may be called\n   after deflateInit2() or deflateReset() and before the first call of\n   deflate().  The text, time, os, extra field, name, and comment information\n   in the provided gz_header structure are written to the gzip header (xflag is\n   ignored -- the extra flags are set according to the compression level).  The\n   caller must assure that, if not Z_NULL, name and comment are terminated with\n   a zero byte, and that if extra is not Z_NULL, that extra_len bytes are\n   available there.  If hcrc is true, a gzip header crc is included.  Note that\n   the current versions of the command-line version of gzip (up through version\n   1.3.x) do not support header crc's, and will report that it is a \"multi-part\n   gzip file\" and give up.\n\n     If deflateSetHeader is not used, the default gzip header has text false,\n   the time set to zero, and os set to 255, with no extra, name, or comment\n   fields.  The gzip header is returned to the default state by deflateReset().\n\n     deflateSetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source\n   stream state was inconsistent.\n*/\n\n/*\nZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm,\n                                     int  windowBits));\n\n     This is another version of inflateInit with an extra parameter.  The\n   fields next_in, avail_in, zalloc, zfree and opaque must be initialized\n   before by the caller.\n\n     The windowBits parameter is the base two logarithm of the maximum window\n   size (the size of the history buffer).  It should be in the range 8..15 for\n   this version of the library.  The default value is 15 if inflateInit is used\n   instead.  windowBits must be greater than or equal to the windowBits value\n   provided to deflateInit2() while compressing, or it must be equal to 15 if\n   deflateInit2() was not used.  If a compressed stream with a larger window\n   size is given as input, inflate() will return with the error code\n   Z_DATA_ERROR instead of trying to allocate a larger window.\n\n     windowBits can also be zero to request that inflate use the window size in\n   the zlib header of the compressed stream.\n\n     windowBits can also be -8..-15 for raw inflate.  In this case, -windowBits\n   determines the window size.  inflate() will then process raw deflate data,\n   not looking for a zlib or gzip header, not generating a check value, and not\n   looking for any check values for comparison at the end of the stream.  This\n   is for use with other formats that use the deflate compressed data format\n   such as zip.  Those formats provide their own check values.  If a custom\n   format is developed using the raw deflate format for compressed data, it is\n   recommended that a check value such as an adler32 or a crc32 be applied to\n   the uncompressed data as is done in the zlib, gzip, and zip formats.  For\n   most applications, the zlib format should be used as is.  Note that comments\n   above on the use in deflateInit2() applies to the magnitude of windowBits.\n\n     windowBits can also be greater than 15 for optional gzip decoding.  Add\n   32 to windowBits to enable zlib and gzip decoding with automatic header\n   detection, or add 16 to decode only the gzip format (the zlib format will\n   return a Z_DATA_ERROR).  If a gzip stream is being decoded, strm->adler is a\n   crc32 instead of an adler32.\n\n     inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough\n   memory, Z_VERSION_ERROR if the zlib library version is incompatible with the\n   version assumed by the caller, or Z_STREAM_ERROR if the parameters are\n   invalid, such as a null pointer to the structure.  msg is set to null if\n   there is no error message.  inflateInit2 does not perform any decompression\n   apart from possibly reading the zlib header if present: actual decompression\n   will be done by inflate().  (So next_in and avail_in may be modified, but\n   next_out and avail_out are unused and unchanged.) The current implementation\n   of inflateInit2() does not process any header information -- that is\n   deferred until inflate() is called.\n*/\n\nZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm,\n                                             const Bytef *dictionary,\n                                             uInt  dictLength));\n/*\n     Initializes the decompression dictionary from the given uncompressed byte\n   sequence.  This function must be called immediately after a call of inflate,\n   if that call returned Z_NEED_DICT.  The dictionary chosen by the compressor\n   can be determined from the adler32 value returned by that call of inflate.\n   The compressor and decompressor must use exactly the same dictionary (see\n   deflateSetDictionary).  For raw inflate, this function can be called\n   immediately after inflateInit2() or inflateReset() and before any call of\n   inflate() to set the dictionary.  The application must insure that the\n   dictionary that was used for compression is provided.\n\n     inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a\n   parameter is invalid (e.g.  dictionary being Z_NULL) or the stream state is\n   inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the\n   expected one (incorrect adler32 value).  inflateSetDictionary does not\n   perform any decompression: this will be done by subsequent calls of\n   inflate().\n*/\n\nZEXTERN int ZEXPORT inflateSync OF((z_streamp strm));\n/*\n     Skips invalid compressed data until a full flush point (see above the\n   description of deflate with Z_FULL_FLUSH) can be found, or until all\n   available input is skipped.  No output is provided.\n\n     inflateSync returns Z_OK if a full flush point has been found, Z_BUF_ERROR\n   if no more input was provided, Z_DATA_ERROR if no flush point has been\n   found, or Z_STREAM_ERROR if the stream structure was inconsistent.  In the\n   success case, the application may save the current current value of total_in\n   which indicates where valid compressed data was found.  In the error case,\n   the application may repeatedly call inflateSync, providing more input each\n   time, until success or end of the input data.\n*/\n\nZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest,\n                                    z_streamp source));\n/*\n     Sets the destination stream as a complete copy of the source stream.\n\n     This function can be useful when randomly accessing a large stream.  The\n   first pass through the stream can periodically record the inflate state,\n   allowing restarting inflate at those points when randomly accessing the\n   stream.\n\n     inflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not\n   enough memory, Z_STREAM_ERROR if the source stream state was inconsistent\n   (such as zalloc being Z_NULL).  msg is left unchanged in both source and\n   destination.\n*/\n\nZEXTERN int ZEXPORT inflateReset OF((z_streamp strm));\n/*\n     This function is equivalent to inflateEnd followed by inflateInit,\n   but does not free and reallocate all the internal decompression state.  The\n   stream will keep attributes that may have been set by inflateInit2.\n\n     inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source\n   stream state was inconsistent (such as zalloc or state being Z_NULL).\n*/\n\nZEXTERN int ZEXPORT inflateReset2 OF((z_streamp strm,\n                                      int windowBits));\n/*\n     This function is the same as inflateReset, but it also permits changing\n   the wrap and window size requests.  The windowBits parameter is interpreted\n   the same as it is for inflateInit2.\n\n     inflateReset2 returns Z_OK if success, or Z_STREAM_ERROR if the source\n   stream state was inconsistent (such as zalloc or state being Z_NULL), or if\n   the windowBits parameter is invalid.\n*/\n\nZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm,\n                                     int bits,\n                                     int value));\n/*\n     This function inserts bits in the inflate input stream.  The intent is\n   that this function is used to start inflating at a bit position in the\n   middle of a byte.  The provided bits will be used before any bytes are used\n   from next_in.  This function should only be used with raw inflate, and\n   should be used before the first inflate() call after inflateInit2() or\n   inflateReset().  bits must be less than or equal to 16, and that many of the\n   least significant bits of value will be inserted in the input.\n\n     If bits is negative, then the input stream bit buffer is emptied.  Then\n   inflatePrime() can be called again to put bits in the buffer.  This is used\n   to clear out bits leftover after feeding inflate a block description prior\n   to feeding inflate codes.\n\n     inflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source\n   stream state was inconsistent.\n*/\n\nZEXTERN long ZEXPORT inflateMark OF((z_streamp strm));\n/*\n     This function returns two values, one in the lower 16 bits of the return\n   value, and the other in the remaining upper bits, obtained by shifting the\n   return value down 16 bits.  If the upper value is -1 and the lower value is\n   zero, then inflate() is currently decoding information outside of a block.\n   If the upper value is -1 and the lower value is non-zero, then inflate is in\n   the middle of a stored block, with the lower value equaling the number of\n   bytes from the input remaining to copy.  If the upper value is not -1, then\n   it is the number of bits back from the current bit position in the input of\n   the code (literal or length/distance pair) currently being processed.  In\n   that case the lower value is the number of bytes already emitted for that\n   code.\n\n     A code is being processed if inflate is waiting for more input to complete\n   decoding of the code, or if it has completed decoding but is waiting for\n   more output space to write the literal or match data.\n\n     inflateMark() is used to mark locations in the input data for random\n   access, which may be at bit positions, and to note those cases where the\n   output of a code may span boundaries of random access blocks.  The current\n   location in the input stream can be determined from avail_in and data_type\n   as noted in the description for the Z_BLOCK flush parameter for inflate.\n\n     inflateMark returns the value noted above or -1 << 16 if the provided\n   source stream state was inconsistent.\n*/\n\nZEXTERN int ZEXPORT inflateGetHeader OF((z_streamp strm,\n                                         gz_headerp head));\n/*\n     inflateGetHeader() requests that gzip header information be stored in the\n   provided gz_header structure.  inflateGetHeader() may be called after\n   inflateInit2() or inflateReset(), and before the first call of inflate().\n   As inflate() processes the gzip stream, head->done is zero until the header\n   is completed, at which time head->done is set to one.  If a zlib stream is\n   being decoded, then head->done is set to -1 to indicate that there will be\n   no gzip header information forthcoming.  Note that Z_BLOCK or Z_TREES can be\n   used to force inflate() to return immediately after header processing is\n   complete and before any actual data is decompressed.\n\n     The text, time, xflags, and os fields are filled in with the gzip header\n   contents.  hcrc is set to true if there is a header CRC.  (The header CRC\n   was valid if done is set to one.) If extra is not Z_NULL, then extra_max\n   contains the maximum number of bytes to write to extra.  Once done is true,\n   extra_len contains the actual extra field length, and extra contains the\n   extra field, or that field truncated if extra_max is less than extra_len.\n   If name is not Z_NULL, then up to name_max characters are written there,\n   terminated with a zero unless the length is greater than name_max.  If\n   comment is not Z_NULL, then up to comm_max characters are written there,\n   terminated with a zero unless the length is greater than comm_max.  When any\n   of extra, name, or comment are not Z_NULL and the respective field is not\n   present in the header, then that field is set to Z_NULL to signal its\n   absence.  This allows the use of deflateSetHeader() with the returned\n   structure to duplicate the header.  However if those fields are set to\n   allocated memory, then the application will need to save those pointers\n   elsewhere so that they can be eventually freed.\n\n     If inflateGetHeader is not used, then the header information is simply\n   discarded.  The header is always checked for validity, including the header\n   CRC if present.  inflateReset() will reset the process to discard the header\n   information.  The application would need to call inflateGetHeader() again to\n   retrieve the header from the next gzip stream.\n\n     inflateGetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source\n   stream state was inconsistent.\n*/\n\n/*\nZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits,\n                                        unsigned char FAR *window));\n\n     Initialize the internal stream state for decompression using inflateBack()\n   calls.  The fields zalloc, zfree and opaque in strm must be initialized\n   before the call.  If zalloc and zfree are Z_NULL, then the default library-\n   derived memory allocation routines are used.  windowBits is the base two\n   logarithm of the window size, in the range 8..15.  window is a caller\n   supplied buffer of that size.  Except for special applications where it is\n   assured that deflate was used with small window sizes, windowBits must be 15\n   and a 32K byte window must be supplied to be able to decompress general\n   deflate streams.\n\n     See inflateBack() for the usage of these routines.\n\n     inflateBackInit will return Z_OK on success, Z_STREAM_ERROR if any of\n   the paramaters are invalid, Z_MEM_ERROR if the internal state could not be\n   allocated, or Z_VERSION_ERROR if the version of the library does not match\n   the version of the header file.\n*/\n\ntypedef unsigned (*in_func) OF((void FAR *, unsigned char FAR * FAR *));\ntypedef int (*out_func) OF((void FAR *, unsigned char FAR *, unsigned));\n\nZEXTERN int ZEXPORT inflateBack OF((z_streamp strm,\n                                    in_func in, void FAR *in_desc,\n                                    out_func out, void FAR *out_desc));\n/*\n     inflateBack() does a raw inflate with a single call using a call-back\n   interface for input and output.  This is more efficient than inflate() for\n   file i/o applications in that it avoids copying between the output and the\n   sliding window by simply making the window itself the output buffer.  This\n   function trusts the application to not change the output buffer passed by\n   the output function, at least until inflateBack() returns.\n\n     inflateBackInit() must be called first to allocate the internal state\n   and to initialize the state with the user-provided window buffer.\n   inflateBack() may then be used multiple times to inflate a complete, raw\n   deflate stream with each call.  inflateBackEnd() is then called to free the\n   allocated state.\n\n     A raw deflate stream is one with no zlib or gzip header or trailer.\n   This routine would normally be used in a utility that reads zip or gzip\n   files and writes out uncompressed files.  The utility would decode the\n   header and process the trailer on its own, hence this routine expects only\n   the raw deflate stream to decompress.  This is different from the normal\n   behavior of inflate(), which expects either a zlib or gzip header and\n   trailer around the deflate stream.\n\n     inflateBack() uses two subroutines supplied by the caller that are then\n   called by inflateBack() for input and output.  inflateBack() calls those\n   routines until it reads a complete deflate stream and writes out all of the\n   uncompressed data, or until it encounters an error.  The function's\n   parameters and return types are defined above in the in_func and out_func\n   typedefs.  inflateBack() will call in(in_desc, &buf) which should return the\n   number of bytes of provided input, and a pointer to that input in buf.  If\n   there is no input available, in() must return zero--buf is ignored in that\n   case--and inflateBack() will return a buffer error.  inflateBack() will call\n   out(out_desc, buf, len) to write the uncompressed data buf[0..len-1].  out()\n   should return zero on success, or non-zero on failure.  If out() returns\n   non-zero, inflateBack() will return with an error.  Neither in() nor out()\n   are permitted to change the contents of the window provided to\n   inflateBackInit(), which is also the buffer that out() uses to write from.\n   The length written by out() will be at most the window size.  Any non-zero\n   amount of input may be provided by in().\n\n     For convenience, inflateBack() can be provided input on the first call by\n   setting strm->next_in and strm->avail_in.  If that input is exhausted, then\n   in() will be called.  Therefore strm->next_in must be initialized before\n   calling inflateBack().  If strm->next_in is Z_NULL, then in() will be called\n   immediately for input.  If strm->next_in is not Z_NULL, then strm->avail_in\n   must also be initialized, and then if strm->avail_in is not zero, input will\n   initially be taken from strm->next_in[0 ..  strm->avail_in - 1].\n\n     The in_desc and out_desc parameters of inflateBack() is passed as the\n   first parameter of in() and out() respectively when they are called.  These\n   descriptors can be optionally used to pass any information that the caller-\n   supplied in() and out() functions need to do their job.\n\n     On return, inflateBack() will set strm->next_in and strm->avail_in to\n   pass back any unused input that was provided by the last in() call.  The\n   return values of inflateBack() can be Z_STREAM_END on success, Z_BUF_ERROR\n   if in() or out() returned an error, Z_DATA_ERROR if there was a format error\n   in the deflate stream (in which case strm->msg is set to indicate the nature\n   of the error), or Z_STREAM_ERROR if the stream was not properly initialized.\n   In the case of Z_BUF_ERROR, an input or output error can be distinguished\n   using strm->next_in which will be Z_NULL only if in() returned an error.  If\n   strm->next_in is not Z_NULL, then the Z_BUF_ERROR was due to out() returning\n   non-zero.  (in() will always be called before out(), so strm->next_in is\n   assured to be defined if out() returns non-zero.) Note that inflateBack()\n   cannot return Z_OK.\n*/\n\nZEXTERN int ZEXPORT inflateBackEnd OF((z_streamp strm));\n/*\n     All memory allocated by inflateBackInit() is freed.\n\n     inflateBackEnd() returns Z_OK on success, or Z_STREAM_ERROR if the stream\n   state was inconsistent.\n*/\n\nZEXTERN uLong ZEXPORT zlibCompileFlags OF((void));\n/* Return flags indicating compile-time options.\n\n    Type sizes, two bits each, 00 = 16 bits, 01 = 32, 10 = 64, 11 = other:\n     1.0: size of uInt\n     3.2: size of uLong\n     5.4: size of voidpf (pointer)\n     7.6: size of z_off_t\n\n    Compiler, assembler, and debug options:\n     8: DEBUG\n     9: ASMV or ASMINF -- use ASM code\n     10: ZLIB_WINAPI -- exported functions use the WINAPI calling convention\n     11: 0 (reserved)\n\n    One-time table building (smaller code, but not thread-safe if true):\n     12: BUILDFIXED -- build static block decoding tables when needed\n     13: DYNAMIC_CRC_TABLE -- build CRC calculation tables when needed\n     14,15: 0 (reserved)\n\n    Library content (indicates missing functionality):\n     16: NO_GZCOMPRESS -- gz* functions cannot compress (to avoid linking\n                          deflate code when not needed)\n     17: NO_GZIP -- deflate can't write gzip streams, and inflate can't detect\n                    and decode gzip streams (to avoid linking crc code)\n     18-19: 0 (reserved)\n\n    Operation variations (changes in library functionality):\n     20: PKZIP_BUG_WORKAROUND -- slightly more permissive inflate\n     21: FASTEST -- deflate algorithm with only one, lowest compression level\n     22,23: 0 (reserved)\n\n    The sprintf variant used by gzprintf (zero is best):\n     24: 0 = vs*, 1 = s* -- 1 means limited to 20 arguments after the format\n     25: 0 = *nprintf, 1 = *printf -- 1 means gzprintf() not secure!\n     26: 0 = returns value, 1 = void -- 1 means inferred string length returned\n\n    Remainder:\n     27-31: 0 (reserved)\n */\n\n\n                        /* utility functions */\n\n/*\n     The following utility functions are implemented on top of the basic\n   stream-oriented functions.  To simplify the interface, some default options\n   are assumed (compression level and memory usage, standard memory allocation\n   functions).  The source code of these utility functions can be modified if\n   you need special options.\n*/\n\nZEXTERN int ZEXPORT compress OF((Bytef *dest,   uLongf *destLen,\n                                 const Bytef *source, uLong sourceLen));\n/*\n     Compresses the source buffer into the destination buffer.  sourceLen is\n   the byte length of the source buffer.  Upon entry, destLen is the total size\n   of the destination buffer, which must be at least the value returned by\n   compressBound(sourceLen).  Upon exit, destLen is the actual size of the\n   compressed buffer.\n\n     compress returns Z_OK if success, Z_MEM_ERROR if there was not\n   enough memory, Z_BUF_ERROR if there was not enough room in the output\n   buffer.\n*/\n\nZEXTERN int ZEXPORT compress2 OF((Bytef *dest,   uLongf *destLen,\n                                  const Bytef *source, uLong sourceLen,\n                                  int level));\n/*\n     Compresses the source buffer into the destination buffer.  The level\n   parameter has the same meaning as in deflateInit.  sourceLen is the byte\n   length of the source buffer.  Upon entry, destLen is the total size of the\n   destination buffer, which must be at least the value returned by\n   compressBound(sourceLen).  Upon exit, destLen is the actual size of the\n   compressed buffer.\n\n     compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough\n   memory, Z_BUF_ERROR if there was not enough room in the output buffer,\n   Z_STREAM_ERROR if the level parameter is invalid.\n*/\n\nZEXTERN uLong ZEXPORT compressBound OF((uLong sourceLen));\n/*\n     compressBound() returns an upper bound on the compressed size after\n   compress() or compress2() on sourceLen bytes.  It would be used before a\n   compress() or compress2() call to allocate the destination buffer.\n*/\n\nZEXTERN int ZEXPORT uncompress OF((Bytef *dest,   uLongf *destLen,\n                                   const Bytef *source, uLong sourceLen));\n/*\n     Decompresses the source buffer into the destination buffer.  sourceLen is\n   the byte length of the source buffer.  Upon entry, destLen is the total size\n   of the destination buffer, which must be large enough to hold the entire\n   uncompressed data.  (The size of the uncompressed data must have been saved\n   previously by the compressor and transmitted to the decompressor by some\n   mechanism outside the scope of this compression library.) Upon exit, destLen\n   is the actual size of the uncompressed buffer.\n\n     uncompress returns Z_OK if success, Z_MEM_ERROR if there was not\n   enough memory, Z_BUF_ERROR if there was not enough room in the output\n   buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete.\n*/\n\n\n                        /* gzip file access functions */\n\n/*\n     This library supports reading and writing files in gzip (.gz) format with\n   an interface similar to that of stdio, using the functions that start with\n   \"gz\".  The gzip format is different from the zlib format.  gzip is a gzip\n   wrapper, documented in RFC 1952, wrapped around a deflate stream.\n*/\n\ntypedef voidp gzFile;       /* opaque gzip file descriptor */\n\n/*\nZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode));\n\n     Opens a gzip (.gz) file for reading or writing.  The mode parameter is as\n   in fopen (\"rb\" or \"wb\") but can also include a compression level (\"wb9\") or\n   a strategy: 'f' for filtered data as in \"wb6f\", 'h' for Huffman-only\n   compression as in \"wb1h\", 'R' for run-length encoding as in \"wb1R\", or 'F'\n   for fixed code compression as in \"wb9F\".  (See the description of\n   deflateInit2 for more information about the strategy parameter.) Also \"a\"\n   can be used instead of \"w\" to request that the gzip stream that will be\n   written be appended to the file.  \"+\" will result in an error, since reading\n   and writing to the same gzip file is not supported.\n\n     gzopen can be used to read a file which is not in gzip format; in this\n   case gzread will directly read from the file without decompression.\n\n     gzopen returns NULL if the file could not be opened, if there was\n   insufficient memory to allocate the gzFile state, or if an invalid mode was\n   specified (an 'r', 'w', or 'a' was not provided, or '+' was provided).\n   errno can be checked to determine if the reason gzopen failed was that the\n   file could not be opened.\n*/\n\nZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode));\n/*\n     gzdopen associates a gzFile with the file descriptor fd.  File descriptors\n   are obtained from calls like open, dup, creat, pipe or fileno (if the file\n   has been previously opened with fopen).  The mode parameter is as in gzopen.\n\n     The next call of gzclose on the returned gzFile will also close the file\n   descriptor fd, just like fclose(fdopen(fd, mode)) closes the file descriptor\n   fd.  If you want to keep fd open, use fd = dup(fd_keep); gz = gzdopen(fd,\n   mode);.  The duplicated descriptor should be saved to avoid a leak, since\n   gzdopen does not close fd if it fails.\n\n     gzdopen returns NULL if there was insufficient memory to allocate the\n   gzFile state, if an invalid mode was specified (an 'r', 'w', or 'a' was not\n   provided, or '+' was provided), or if fd is -1.  The file descriptor is not\n   used until the next gz* read, write, seek, or close operation, so gzdopen\n   will not detect if fd is invalid (unless fd is -1).\n*/\n\nZEXTERN int ZEXPORT gzbuffer OF((gzFile file, unsigned size));\n/*\n     Set the internal buffer size used by this library's functions.  The\n   default buffer size is 8192 bytes.  This function must be called after\n   gzopen() or gzdopen(), and before any other calls that read or write the\n   file.  The buffer memory allocation is always deferred to the first read or\n   write.  Two buffers are allocated, either both of the specified size when\n   writing, or one of the specified size and the other twice that size when\n   reading.  A larger buffer size of, for example, 64K or 128K bytes will\n   noticeably increase the speed of decompression (reading).\n\n     The new buffer size also affects the maximum length for gzprintf().\n\n     gzbuffer() returns 0 on success, or -1 on failure, such as being called\n   too late.\n*/\n\nZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy));\n/*\n     Dynamically update the compression level or strategy.  See the description\n   of deflateInit2 for the meaning of these parameters.\n\n     gzsetparams returns Z_OK if success, or Z_STREAM_ERROR if the file was not\n   opened for writing.\n*/\n\nZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len));\n/*\n     Reads the given number of uncompressed bytes from the compressed file.  If\n   the input file was not in gzip format, gzread copies the given number of\n   bytes into the buffer.\n\n     After reaching the end of a gzip stream in the input, gzread will continue\n   to read, looking for another gzip stream, or failing that, reading the rest\n   of the input file directly without decompression.  The entire input file\n   will be read if gzread is called until it returns less than the requested\n   len.\n\n     gzread returns the number of uncompressed bytes actually read, less than\n   len for end of file, or -1 for error.\n*/\n\nZEXTERN int ZEXPORT gzwrite OF((gzFile file,\n                                voidpc buf, unsigned len));\n/*\n     Writes the given number of uncompressed bytes into the compressed file.\n   gzwrite returns the number of uncompressed bytes written or 0 in case of\n   error.\n*/\n\nZEXTERN int ZEXPORTVA gzprintf OF((gzFile file, const char *format, ...));\n/*\n     Converts, formats, and writes the arguments to the compressed file under\n   control of the format string, as in fprintf.  gzprintf returns the number of\n   uncompressed bytes actually written, or 0 in case of error.  The number of\n   uncompressed bytes written is limited to 8191, or one less than the buffer\n   size given to gzbuffer().  The caller should assure that this limit is not\n   exceeded.  If it is exceeded, then gzprintf() will return an error (0) with\n   nothing written.  In this case, there may also be a buffer overflow with\n   unpredictable consequences, which is possible only if zlib was compiled with\n   the insecure functions sprintf() or vsprintf() because the secure snprintf()\n   or vsnprintf() functions were not available.  This can be determined using\n   zlibCompileFlags().\n*/\n\nZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s));\n/*\n     Writes the given null-terminated string to the compressed file, excluding\n   the terminating null character.\n\n     gzputs returns the number of characters written, or -1 in case of error.\n*/\n\nZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len));\n/*\n     Reads bytes from the compressed file until len-1 characters are read, or a\n   newline character is read and transferred to buf, or an end-of-file\n   condition is encountered.  If any characters are read or if len == 1, the\n   string is terminated with a null character.  If no characters are read due\n   to an end-of-file or len < 1, then the buffer is left untouched.\n\n     gzgets returns buf which is a null-terminated string, or it returns NULL\n   for end-of-file or in case of error.  If there was an error, the contents at\n   buf are indeterminate.\n*/\n\nZEXTERN int ZEXPORT gzputc OF((gzFile file, int c));\n/*\n     Writes c, converted to an unsigned char, into the compressed file.  gzputc\n   returns the value that was written, or -1 in case of error.\n*/\n\nZEXTERN int ZEXPORT gzgetc OF((gzFile file));\n/*\n     Reads one byte from the compressed file.  gzgetc returns this byte or -1\n   in case of end of file or error.\n*/\n\nZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file));\n/*\n     Push one character back onto the stream to be read as the first character\n   on the next read.  At least one character of push-back is allowed.\n   gzungetc() returns the character pushed, or -1 on failure.  gzungetc() will\n   fail if c is -1, and may fail if a character has been pushed but not read\n   yet.  If gzungetc is used immediately after gzopen or gzdopen, at least the\n   output buffer size of pushed characters is allowed.  (See gzbuffer above.)\n   The pushed character will be discarded if the stream is repositioned with\n   gzseek() or gzrewind().\n*/\n\nZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush));\n/*\n     Flushes all pending output into the compressed file.  The parameter flush\n   is as in the deflate() function.  The return value is the zlib error number\n   (see function gzerror below).  gzflush is only permitted when writing.\n\n     If the flush parameter is Z_FINISH, the remaining data is written and the\n   gzip stream is completed in the output.  If gzwrite() is called again, a new\n   gzip stream will be started in the output.  gzread() is able to read such\n   concatented gzip streams.\n\n     gzflush should be called only when strictly necessary because it will\n   degrade compression if called too often.\n*/\n\n/*\nZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file,\n                                   z_off_t offset, int whence));\n\n     Sets the starting position for the next gzread or gzwrite on the given\n   compressed file.  The offset represents a number of bytes in the\n   uncompressed data stream.  The whence parameter is defined as in lseek(2);\n   the value SEEK_END is not supported.\n\n     If the file is opened for reading, this function is emulated but can be\n   extremely slow.  If the file is opened for writing, only forward seeks are\n   supported; gzseek then compresses a sequence of zeroes up to the new\n   starting position.\n\n     gzseek returns the resulting offset location as measured in bytes from\n   the beginning of the uncompressed stream, or -1 in case of error, in\n   particular if the file is opened for writing and the new starting position\n   would be before the current position.\n*/\n\nZEXTERN int ZEXPORT    gzrewind OF((gzFile file));\n/*\n     Rewinds the given file. This function is supported only for reading.\n\n     gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET)\n*/\n\n/*\nZEXTERN z_off_t ZEXPORT    gztell OF((gzFile file));\n\n     Returns the starting position for the next gzread or gzwrite on the given\n   compressed file.  This position represents a number of bytes in the\n   uncompressed data stream, and is zero when starting, even if appending or\n   reading a gzip stream from the middle of a file using gzdopen().\n\n     gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR)\n*/\n\n/*\nZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile file));\n\n     Returns the current offset in the file being read or written.  This offset\n   includes the count of bytes that precede the gzip stream, for example when\n   appending or when using gzdopen() for reading.  When reading, the offset\n   does not include as yet unused buffered input.  This information can be used\n   for a progress indicator.  On error, gzoffset() returns -1.\n*/\n\nZEXTERN int ZEXPORT gzeof OF((gzFile file));\n/*\n     Returns true (1) if the end-of-file indicator has been set while reading,\n   false (0) otherwise.  Note that the end-of-file indicator is set only if the\n   read tried to go past the end of the input, but came up short.  Therefore,\n   just like feof(), gzeof() may return false even if there is no more data to\n   read, in the event that the last read request was for the exact number of\n   bytes remaining in the input file.  This will happen if the input file size\n   is an exact multiple of the buffer size.\n\n     If gzeof() returns true, then the read functions will return no more data,\n   unless the end-of-file indicator is reset by gzclearerr() and the input file\n   has grown since the previous end of file was detected.\n*/\n\nZEXTERN int ZEXPORT gzdirect OF((gzFile file));\n/*\n     Returns true (1) if file is being copied directly while reading, or false\n   (0) if file is a gzip stream being decompressed.  This state can change from\n   false to true while reading the input file if the end of a gzip stream is\n   reached, but is followed by data that is not another gzip stream.\n\n     If the input file is empty, gzdirect() will return true, since the input\n   does not contain a gzip stream.\n\n     If gzdirect() is used immediately after gzopen() or gzdopen() it will\n   cause buffers to be allocated to allow reading the file to determine if it\n   is a gzip file.  Therefore if gzbuffer() is used, it should be called before\n   gzdirect().\n*/\n\nZEXTERN int ZEXPORT    gzclose OF((gzFile file));\n/*\n     Flushes all pending output if necessary, closes the compressed file and\n   deallocates the (de)compression state.  Note that once file is closed, you\n   cannot call gzerror with file, since its structures have been deallocated.\n   gzclose must not be called more than once on the same file, just as free\n   must not be called more than once on the same allocation.\n\n     gzclose will return Z_STREAM_ERROR if file is not valid, Z_ERRNO on a\n   file operation error, or Z_OK on success.\n*/\n\nZEXTERN int ZEXPORT gzclose_r OF((gzFile file));\nZEXTERN int ZEXPORT gzclose_w OF((gzFile file));\n/*\n     Same as gzclose(), but gzclose_r() is only for use when reading, and\n   gzclose_w() is only for use when writing or appending.  The advantage to\n   using these instead of gzclose() is that they avoid linking in zlib\n   compression or decompression code that is not used when only reading or only\n   writing respectively.  If gzclose() is used, then both compression and\n   decompression code will be included the application when linking to a static\n   zlib library.\n*/\n\nZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum));\n/*\n     Returns the error message for the last error which occurred on the given\n   compressed file.  errnum is set to zlib error number.  If an error occurred\n   in the file system and not in the compression library, errnum is set to\n   Z_ERRNO and the application may consult errno to get the exact error code.\n\n     The application must not modify the returned string.  Future calls to\n   this function may invalidate the previously returned string.  If file is\n   closed, then the string previously returned by gzerror will no longer be\n   available.\n\n     gzerror() should be used to distinguish errors from end-of-file for those\n   functions above that do not distinguish those cases in their return values.\n*/\n\nZEXTERN void ZEXPORT gzclearerr OF((gzFile file));\n/*\n     Clears the error and end-of-file flags for file.  This is analogous to the\n   clearerr() function in stdio.  This is useful for continuing to read a gzip\n   file that is being written concurrently.\n*/\n\n\n                        /* checksum functions */\n\n/*\n     These functions are not related to compression but are exported\n   anyway because they might be useful in applications using the compression\n   library.\n*/\n\nZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len));\n/*\n     Update a running Adler-32 checksum with the bytes buf[0..len-1] and\n   return the updated checksum.  If buf is Z_NULL, this function returns the\n   required initial value for the checksum.\n\n     An Adler-32 checksum is almost as reliable as a CRC32 but can be computed\n   much faster.\n\n   Usage example:\n\n     uLong adler = adler32(0L, Z_NULL, 0);\n\n     while (read_buffer(buffer, length) != EOF) {\n       adler = adler32(adler, buffer, length);\n     }\n     if (adler != original_adler) error();\n*/\n\n/*\nZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2,\n                                          z_off_t len2));\n\n     Combine two Adler-32 checksums into one.  For two sequences of bytes, seq1\n   and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for\n   each, adler1 and adler2.  adler32_combine() returns the Adler-32 checksum of\n   seq1 and seq2 concatenated, requiring only adler1, adler2, and len2.\n*/\n\nZEXTERN uLong ZEXPORT crc32   OF((uLong crc, const Bytef *buf, uInt len));\n/*\n     Update a running CRC-32 with the bytes buf[0..len-1] and return the\n   updated CRC-32.  If buf is Z_NULL, this function returns the required\n   initial value for the for the crc.  Pre- and post-conditioning (one's\n   complement) is performed within this function so it shouldn't be done by the\n   application.\n\n   Usage example:\n\n     uLong crc = crc32(0L, Z_NULL, 0);\n\n     while (read_buffer(buffer, length) != EOF) {\n       crc = crc32(crc, buffer, length);\n     }\n     if (crc != original_crc) error();\n*/\n\n/*\nZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2));\n\n     Combine two CRC-32 check values into one.  For two sequences of bytes,\n   seq1 and seq2 with lengths len1 and len2, CRC-32 check values were\n   calculated for each, crc1 and crc2.  crc32_combine() returns the CRC-32\n   check value of seq1 and seq2 concatenated, requiring only crc1, crc2, and\n   len2.\n*/\n\n\n                        /* various hacks, don't look :) */\n\n/* deflateInit and inflateInit are macros to allow checking the zlib version\n * and the compiler's view of z_stream:\n */\nZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level,\n                                     const char *version, int stream_size));\nZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm,\n                                     const char *version, int stream_size));\nZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int  level, int  method,\n                                      int windowBits, int memLevel,\n                                      int strategy, const char *version,\n                                      int stream_size));\nZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int  windowBits,\n                                      const char *version, int stream_size));\nZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits,\n                                         unsigned char FAR *window,\n                                         const char *version,\n                                         int stream_size));\n#define deflateInit(strm, level) \\\n        deflateInit_((strm), (level),       ZLIB_VERSION, sizeof(z_stream))\n#define inflateInit(strm) \\\n        inflateInit_((strm),                ZLIB_VERSION, sizeof(z_stream))\n#define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \\\n        deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\\\n                      (strategy),           ZLIB_VERSION, sizeof(z_stream))\n#define inflateInit2(strm, windowBits) \\\n        inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream))\n#define inflateBackInit(strm, windowBits, window) \\\n        inflateBackInit_((strm), (windowBits), (window), \\\n                                            ZLIB_VERSION, sizeof(z_stream))\n\n/* provide 64-bit offset functions if _LARGEFILE64_SOURCE defined, and/or\n * change the regular functions to 64 bits if _FILE_OFFSET_BITS is 64 (if\n * both are true, the application gets the *64 functions, and the regular\n * functions are changed to 64 bits) -- in case these are set on systems\n * without large file support, _LFS64_LARGEFILE must also be true\n */\n#if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0\n   ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *));\n   ZEXTERN z_off64_t ZEXPORT gzseek64 OF((gzFile, z_off64_t, int));\n   ZEXTERN z_off64_t ZEXPORT gztell64 OF((gzFile));\n   ZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile));\n   ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off64_t));\n   ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off64_t));\n#endif\n\n#if !defined(ZLIB_INTERNAL) && _FILE_OFFSET_BITS-0 == 64 && _LFS64_LARGEFILE-0\n#  define gzopen gzopen64\n#  define gzseek gzseek64\n#  define gztell gztell64\n#  define gzoffset gzoffset64\n#  define adler32_combine adler32_combine64\n#  define crc32_combine crc32_combine64\n#  ifdef _LARGEFILE64_SOURCE\n     ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *));\n     ZEXTERN z_off_t ZEXPORT gzseek64 OF((gzFile, z_off_t, int));\n     ZEXTERN z_off_t ZEXPORT gztell64 OF((gzFile));\n     ZEXTERN z_off_t ZEXPORT gzoffset64 OF((gzFile));\n     ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t));\n     ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t));\n#  endif\n#else\n   ZEXTERN gzFile ZEXPORT gzopen OF((const char *, const char *));\n   ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile, z_off_t, int));\n   ZEXTERN z_off_t ZEXPORT gztell OF((gzFile));\n   ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile));\n   ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t));\n   ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t));\n#endif\n\n/* hack for buggy compilers */\n#if !defined(ZUTIL_H) && !defined(NO_DUMMY_DECL)\n    struct internal_state {int dummy;};\n#endif\n\n/* undocumented functions */\nZEXTERN const char   * ZEXPORT zError           OF((int));\nZEXTERN int            ZEXPORT inflateSyncPoint OF((z_streamp));\nZEXTERN const uLongf * ZEXPORT get_crc_table    OF((void));\nZEXTERN int            ZEXPORT inflateUndermine OF((z_streamp, int));\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* ZLIB_H */\n"
  },
  {
    "path": "Projects/Libraries/CSBase/PlatformSource/Windows/zconf.h",
    "content": "/* zconf.h -- configuration of the zlib compression library\n * Copyright (C) 1995-2010 Jean-loup Gailly.\n * For conditions of distribution and use, see copyright notice in zlib.h\n */\n\n/* @(#) $Id$ */\n\n#ifndef ZCONF_H\n#define ZCONF_H\n\n/*\n * If you *really* need a unique prefix for all types and library functions,\n * compile with -DZ_PREFIX. The \"standard\" zlib should be compiled without it.\n * Even better than compiling with -DZ_PREFIX would be to use configure to set\n * this permanently in zconf.h using \"./configure --zprefix\".\n */\n#ifdef Z_PREFIX     /* may be set to #if 1 by ./configure */\n\n/* all linked symbols */\n#  define _dist_code            z__dist_code\n#  define _length_code          z__length_code\n#  define _tr_align             z__tr_align\n#  define _tr_flush_block       z__tr_flush_block\n#  define _tr_init              z__tr_init\n#  define _tr_stored_block      z__tr_stored_block\n#  define _tr_tally             z__tr_tally\n#  define adler32               z_adler32\n#  define adler32_combine       z_adler32_combine\n#  define adler32_combine64     z_adler32_combine64\n#  define compress              z_compress\n#  define compress2             z_compress2\n#  define compressBound         z_compressBound\n#  define crc32                 z_crc32\n#  define crc32_combine         z_crc32_combine\n#  define crc32_combine64       z_crc32_combine64\n#  define deflate               z_deflate\n#  define deflateBound          z_deflateBound\n#  define deflateCopy           z_deflateCopy\n#  define deflateEnd            z_deflateEnd\n#  define deflateInit2_         z_deflateInit2_\n#  define deflateInit_          z_deflateInit_\n#  define deflateParams         z_deflateParams\n#  define deflatePrime          z_deflatePrime\n#  define deflateReset          z_deflateReset\n#  define deflateSetDictionary  z_deflateSetDictionary\n#  define deflateSetHeader      z_deflateSetHeader\n#  define deflateTune           z_deflateTune\n#  define deflate_copyright     z_deflate_copyright\n#  define get_crc_table         z_get_crc_table\n#  define gz_error              z_gz_error\n#  define gz_intmax             z_gz_intmax\n#  define gz_strwinerror        z_gz_strwinerror\n#  define gzbuffer              z_gzbuffer\n#  define gzclearerr            z_gzclearerr\n#  define gzclose               z_gzclose\n#  define gzclose_r             z_gzclose_r\n#  define gzclose_w             z_gzclose_w\n#  define gzdirect              z_gzdirect\n#  define gzdopen               z_gzdopen\n#  define gzeof                 z_gzeof\n#  define gzerror               z_gzerror\n#  define gzflush               z_gzflush\n#  define gzgetc                z_gzgetc\n#  define gzgets                z_gzgets\n#  define gzoffset              z_gzoffset\n#  define gzoffset64            z_gzoffset64\n#  define gzopen                z_gzopen\n#  define gzopen64              z_gzopen64\n#  define gzprintf              z_gzprintf\n#  define gzputc                z_gzputc\n#  define gzputs                z_gzputs\n#  define gzread                z_gzread\n#  define gzrewind              z_gzrewind\n#  define gzseek                z_gzseek\n#  define gzseek64              z_gzseek64\n#  define gzsetparams           z_gzsetparams\n#  define gztell                z_gztell\n#  define gztell64              z_gztell64\n#  define gzungetc              z_gzungetc\n#  define gzwrite               z_gzwrite\n#  define inflate               z_inflate\n#  define inflateBack           z_inflateBack\n#  define inflateBackEnd        z_inflateBackEnd\n#  define inflateBackInit_      z_inflateBackInit_\n#  define inflateCopy           z_inflateCopy\n#  define inflateEnd            z_inflateEnd\n#  define inflateGetHeader      z_inflateGetHeader\n#  define inflateInit2_         z_inflateInit2_\n#  define inflateInit_          z_inflateInit_\n#  define inflateMark           z_inflateMark\n#  define inflatePrime          z_inflatePrime\n#  define inflateReset          z_inflateReset\n#  define inflateReset2         z_inflateReset2\n#  define inflateSetDictionary  z_inflateSetDictionary\n#  define inflateSync           z_inflateSync\n#  define inflateSyncPoint      z_inflateSyncPoint\n#  define inflateUndermine      z_inflateUndermine\n#  define inflate_copyright     z_inflate_copyright\n#  define inflate_fast          z_inflate_fast\n#  define inflate_table         z_inflate_table\n#  define uncompress            z_uncompress\n#  define zError                z_zError\n#  define zcalloc               z_zcalloc\n#  define zcfree                z_zcfree\n#  define zlibCompileFlags      z_zlibCompileFlags\n#  define zlibVersion           z_zlibVersion\n\n/* all zlib typedefs in zlib.h and zconf.h */\n#  define Byte                  z_Byte\n#  define Bytef                 z_Bytef\n#  define alloc_func            z_alloc_func\n#  define charf                 z_charf\n#  define free_func             z_free_func\n#  define gzFile                z_gzFile\n#  define gz_header             z_gz_header\n#  define gz_headerp            z_gz_headerp\n#  define in_func               z_in_func\n#  define intf                  z_intf\n#  define out_func              z_out_func\n#  define uInt                  z_uInt\n#  define uIntf                 z_uIntf\n#  define uLong                 z_uLong\n#  define uLongf                z_uLongf\n#  define voidp                 z_voidp\n#  define voidpc                z_voidpc\n#  define voidpf                z_voidpf\n\n/* all zlib structs in zlib.h and zconf.h */\n#  define gz_header_s           z_gz_header_s\n#  define internal_state        z_internal_state\n\n#endif\n\n#if defined(__MSDOS__) && !defined(MSDOS)\n#  define MSDOS\n#endif\n#if (defined(OS_2) || defined(__OS2__)) && !defined(OS2)\n#  define OS2\n#endif\n#if defined(_WINDOWS) && !defined(WINDOWS)\n#  define WINDOWS\n#endif\n#if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__)\n#  ifndef WIN32\n#    define WIN32\n#  endif\n#endif\n#if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32)\n#  if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__)\n#    ifndef SYS16BIT\n#      define SYS16BIT\n#    endif\n#  endif\n#endif\n\n/*\n * Compile with -DMAXSEG_64K if the alloc function cannot allocate more\n * than 64k bytes at a time (needed on systems with 16-bit int).\n */\n#ifdef SYS16BIT\n#  define MAXSEG_64K\n#endif\n#ifdef MSDOS\n#  define UNALIGNED_OK\n#endif\n\n#ifdef __STDC_VERSION__\n#  ifndef STDC\n#    define STDC\n#  endif\n#  if __STDC_VERSION__ >= 199901L\n#    ifndef STDC99\n#      define STDC99\n#    endif\n#  endif\n#endif\n#if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus))\n#  define STDC\n#endif\n#if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__))\n#  define STDC\n#endif\n#if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32))\n#  define STDC\n#endif\n#if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__))\n#  define STDC\n#endif\n\n#if defined(__OS400__) && !defined(STDC)    /* iSeries (formerly AS/400). */\n#  define STDC\n#endif\n\n#ifndef STDC\n#  ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */\n#    define const       /* note: need a more gentle solution here */\n#  endif\n#endif\n\n/* Some Mac compilers merge all .h files incorrectly: */\n#if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__)\n#  define NO_DUMMY_DECL\n#endif\n\n/* Maximum value for memLevel in deflateInit2 */\n#ifndef MAX_MEM_LEVEL\n#  ifdef MAXSEG_64K\n#    define MAX_MEM_LEVEL 8\n#  else\n#    define MAX_MEM_LEVEL 9\n#  endif\n#endif\n\n/* Maximum value for windowBits in deflateInit2 and inflateInit2.\n * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files\n * created by gzip. (Files created by minigzip can still be extracted by\n * gzip.)\n */\n#ifndef MAX_WBITS\n#  define MAX_WBITS   15 /* 32K LZ77 window */\n#endif\n\n/* The memory requirements for deflate are (in bytes):\n            (1 << (windowBits+2)) +  (1 << (memLevel+9))\n that is: 128K for windowBits=15  +  128K for memLevel = 8  (default values)\n plus a few kilobytes for small objects. For example, if you want to reduce\n the default memory requirements from 256K to 128K, compile with\n     make CFLAGS=\"-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7\"\n Of course this will generally degrade compression (there's no free lunch).\n\n   The memory requirements for inflate are (in bytes) 1 << windowBits\n that is, 32K for windowBits=15 (default value) plus a few kilobytes\n for small objects.\n*/\n\n                        /* Type declarations */\n\n#ifndef OF /* function prototypes */\n#  ifdef STDC\n#    define OF(args)  args\n#  else\n#    define OF(args)  ()\n#  endif\n#endif\n\n/* The following definitions for FAR are needed only for MSDOS mixed\n * model programming (small or medium model with some far allocations).\n * This was tested only with MSC; for other MSDOS compilers you may have\n * to define NO_MEMCPY in zutil.h.  If you don't need the mixed model,\n * just define FAR to be empty.\n */\n#ifdef SYS16BIT\n#  if defined(M_I86SM) || defined(M_I86MM)\n     /* MSC small or medium model */\n#    define SMALL_MEDIUM\n#    ifdef _MSC_VER\n#      define FAR _far\n#    else\n#      define FAR far\n#    endif\n#  endif\n#  if (defined(__SMALL__) || defined(__MEDIUM__))\n     /* Turbo C small or medium model */\n#    define SMALL_MEDIUM\n#    ifdef __BORLANDC__\n#      define FAR _far\n#    else\n#      define FAR far\n#    endif\n#  endif\n#endif\n\n#if defined(WINDOWS) || defined(WIN32)\n   /* If building or using zlib as a DLL, define ZLIB_DLL.\n    * This is not mandatory, but it offers a little performance increase.\n    */\n#  ifdef ZLIB_DLL\n#    if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500))\n#      ifdef ZLIB_INTERNAL\n#        define ZEXTERN extern __declspec(dllexport)\n#      else\n#        define ZEXTERN extern __declspec(dllimport)\n#      endif\n#    endif\n#  endif  /* ZLIB_DLL */\n   /* If building or using zlib with the WINAPI/WINAPIV calling convention,\n    * define ZLIB_WINAPI.\n    * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI.\n    */\n#  ifdef ZLIB_WINAPI\n#    ifdef FAR\n#      undef FAR\n#    endif\n#    include <windows.h>\n     /* No need for _export, use ZLIB.DEF instead. */\n     /* For complete Windows compatibility, use WINAPI, not __stdcall. */\n#    define ZEXPORT WINAPI\n#    ifdef WIN32\n#      define ZEXPORTVA WINAPIV\n#    else\n#      define ZEXPORTVA FAR CDECL\n#    endif\n#  endif\n#endif\n\n#if defined (__BEOS__)\n#  ifdef ZLIB_DLL\n#    ifdef ZLIB_INTERNAL\n#      define ZEXPORT   __declspec(dllexport)\n#      define ZEXPORTVA __declspec(dllexport)\n#    else\n#      define ZEXPORT   __declspec(dllimport)\n#      define ZEXPORTVA __declspec(dllimport)\n#    endif\n#  endif\n#endif\n\n#ifndef ZEXTERN\n#  define ZEXTERN extern\n#endif\n#ifndef ZEXPORT\n#  define ZEXPORT\n#endif\n#ifndef ZEXPORTVA\n#  define ZEXPORTVA\n#endif\n\n#ifndef FAR\n#  define FAR\n#endif\n\n#if !defined(__MACTYPES__)\ntypedef unsigned char  Byte;  /* 8 bits */\n#endif\ntypedef unsigned int   uInt;  /* 16 bits or more */\ntypedef unsigned long  uLong; /* 32 bits or more */\n\n#ifdef SMALL_MEDIUM\n   /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */\n#  define Bytef Byte FAR\n#else\n   typedef Byte  FAR Bytef;\n#endif\ntypedef char  FAR charf;\ntypedef int   FAR intf;\ntypedef uInt  FAR uIntf;\ntypedef uLong FAR uLongf;\n\n#ifdef STDC\n   typedef void const *voidpc;\n   typedef void FAR   *voidpf;\n   typedef void       *voidp;\n#else\n   typedef Byte const *voidpc;\n   typedef Byte FAR   *voidpf;\n   typedef Byte       *voidp;\n#endif\n\n#ifdef HAVE_UNISTD_H    /* may be set to #if 1 by ./configure */\n#  define Z_HAVE_UNISTD_H\n#endif\n\n#ifdef STDC\n#  include <sys/types.h>    /* for off_t */\n#endif\n\n/* a little trick to accommodate both \"#define _LARGEFILE64_SOURCE\" and\n * \"#define _LARGEFILE64_SOURCE 1\" as requesting 64-bit operations, (even\n * though the former does not conform to the LFS document), but considering\n * both \"#undef _LARGEFILE64_SOURCE\" and \"#define _LARGEFILE64_SOURCE 0\" as\n * equivalently requesting no 64-bit operations\n */\n#if -_LARGEFILE64_SOURCE - -1 == 1\n#  undef _LARGEFILE64_SOURCE\n#endif\n\n#if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE)\n#  include <unistd.h>       /* for SEEK_* and off_t */\n#  ifdef VMS\n#    include <unixio.h>     /* for off_t */\n#  endif\n#  ifndef z_off_t\n#    define z_off_t off_t\n#  endif\n#endif\n\n#ifndef SEEK_SET\n#  define SEEK_SET        0       /* Seek from beginning of file.  */\n#  define SEEK_CUR        1       /* Seek from current position.  */\n#  define SEEK_END        2       /* Set file pointer to EOF plus \"offset\" */\n#endif\n\n#ifndef z_off_t\n#  define z_off_t long\n#endif\n\n#if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0\n#  define z_off64_t off64_t\n#else\n#  define z_off64_t z_off_t\n#endif\n\n#if defined(__OS400__)\n#  define NO_vsnprintf\n#endif\n\n#if defined(__MVS__)\n#  define NO_vsnprintf\n#endif\n\n/* MVS linker does not support external names larger than 8 bytes */\n#if defined(__MVS__)\n  #pragma map(deflateInit_,\"DEIN\")\n  #pragma map(deflateInit2_,\"DEIN2\")\n  #pragma map(deflateEnd,\"DEEND\")\n  #pragma map(deflateBound,\"DEBND\")\n  #pragma map(inflateInit_,\"ININ\")\n  #pragma map(inflateInit2_,\"ININ2\")\n  #pragma map(inflateEnd,\"INEND\")\n  #pragma map(inflateSync,\"INSY\")\n  #pragma map(inflateSetDictionary,\"INSEDI\")\n  #pragma map(compressBound,\"CMBND\")\n  #pragma map(inflate_table,\"INTABL\")\n  #pragma map(inflate_fast,\"INFA\")\n  #pragma map(inflate_copyright,\"INCOPY\")\n#endif\n\n#endif /* ZCONF_H */\n"
  },
  {
    "path": "Projects/Libraries/CSBase/PlatformSource/Windows/zlib.h",
    "content": "/* zlib.h -- interface of the 'zlib' general purpose compression library\n  version 1.2.5, April 19th, 2010\n\n  Copyright (C) 1995-2010 Jean-loup Gailly and Mark Adler\n\n  This software is provided 'as-is', without any express or implied\n  warranty.  In no event will the authors be held liable for any damages\n  arising from the use of this software.\n\n  Permission is granted to anyone to use this software for any purpose,\n  including commercial applications, and to alter it and redistribute it\n  freely, subject to the following restrictions:\n\n  1. The origin of this software must not be misrepresented; you must not\n     claim that you wrote the original software. If you use this software\n     in a product, an acknowledgment in the product documentation would be\n     appreciated but is not required.\n  2. Altered source versions must be plainly marked as such, and must not be\n     misrepresented as being the original software.\n  3. This notice may not be removed or altered from any source distribution.\n\n  Jean-loup Gailly        Mark Adler\n  jloup@gzip.org          madler@alumni.caltech.edu\n\n\n  The data format used by the zlib library is described by RFCs (Request for\n  Comments) 1950 to 1952 in the files http://www.ietf.org/rfc/rfc1950.txt\n  (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format).\n*/\n\n#ifndef ZLIB_H\n#define ZLIB_H\n\n#include \"zconf.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#define ZLIB_VERSION \"1.2.5\"\n#define ZLIB_VERNUM 0x1250\n#define ZLIB_VER_MAJOR 1\n#define ZLIB_VER_MINOR 2\n#define ZLIB_VER_REVISION 5\n#define ZLIB_VER_SUBREVISION 0\n\n/*\n    The 'zlib' compression library provides in-memory compression and\n  decompression functions, including integrity checks of the uncompressed data.\n  This version of the library supports only one compression method (deflation)\n  but other algorithms will be added later and will have the same stream\n  interface.\n\n    Compression can be done in a single step if the buffers are large enough,\n  or can be done by repeated calls of the compression function.  In the latter\n  case, the application must provide more input and/or consume the output\n  (providing more output space) before each call.\n\n    The compressed data format used by default by the in-memory functions is\n  the zlib format, which is a zlib wrapper documented in RFC 1950, wrapped\n  around a deflate stream, which is itself documented in RFC 1951.\n\n    The library also supports reading and writing files in gzip (.gz) format\n  with an interface similar to that of stdio using the functions that start\n  with \"gz\".  The gzip format is different from the zlib format.  gzip is a\n  gzip wrapper, documented in RFC 1952, wrapped around a deflate stream.\n\n    This library can optionally read and write gzip streams in memory as well.\n\n    The zlib format was designed to be compact and fast for use in memory\n  and on communications channels.  The gzip format was designed for single-\n  file compression on file systems, has a larger header than zlib to maintain\n  directory information, and uses a different, slower check method than zlib.\n\n    The library does not install any signal handler.  The decoder checks\n  the consistency of the compressed data, so the library should never crash\n  even in case of corrupted input.\n*/\n\ntypedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size));\ntypedef void   (*free_func)  OF((voidpf opaque, voidpf address));\n\nstruct internal_state;\n\ntypedef struct z_stream_s {\n    Bytef    *next_in;  /* next input byte */\n    uInt     avail_in;  /* number of bytes available at next_in */\n    uLong    total_in;  /* total nb of input bytes read so far */\n\n    Bytef    *next_out; /* next output byte should be put there */\n    uInt     avail_out; /* remaining free space at next_out */\n    uLong    total_out; /* total nb of bytes output so far */\n\n    char     *msg;      /* last error message, NULL if no error */\n    struct internal_state FAR *state; /* not visible by applications */\n\n    alloc_func zalloc;  /* used to allocate the internal state */\n    free_func  zfree;   /* used to free the internal state */\n    voidpf     opaque;  /* private data object passed to zalloc and zfree */\n\n    int     data_type;  /* best guess about the data type: binary or text */\n    uLong   adler;      /* adler32 value of the uncompressed data */\n    uLong   reserved;   /* reserved for future use */\n} z_stream;\n\ntypedef z_stream FAR *z_streamp;\n\n/*\n     gzip header information passed to and from zlib routines.  See RFC 1952\n  for more details on the meanings of these fields.\n*/\ntypedef struct gz_header_s {\n    int     text;       /* true if compressed data believed to be text */\n    uLong   time;       /* modification time */\n    int     xflags;     /* extra flags (not used when writing a gzip file) */\n    int     os;         /* operating system */\n    Bytef   *extra;     /* pointer to extra field or Z_NULL if none */\n    uInt    extra_len;  /* extra field length (valid if extra != Z_NULL) */\n    uInt    extra_max;  /* space at extra (only when reading header) */\n    Bytef   *name;      /* pointer to zero-terminated file name or Z_NULL */\n    uInt    name_max;   /* space at name (only when reading header) */\n    Bytef   *comment;   /* pointer to zero-terminated comment or Z_NULL */\n    uInt    comm_max;   /* space at comment (only when reading header) */\n    int     hcrc;       /* true if there was or will be a header crc */\n    int     done;       /* true when done reading gzip header (not used\n                           when writing a gzip file) */\n} gz_header;\n\ntypedef gz_header FAR *gz_headerp;\n\n/*\n     The application must update next_in and avail_in when avail_in has dropped\n   to zero.  It must update next_out and avail_out when avail_out has dropped\n   to zero.  The application must initialize zalloc, zfree and opaque before\n   calling the init function.  All other fields are set by the compression\n   library and must not be updated by the application.\n\n     The opaque value provided by the application will be passed as the first\n   parameter for calls of zalloc and zfree.  This can be useful for custom\n   memory management.  The compression library attaches no meaning to the\n   opaque value.\n\n     zalloc must return Z_NULL if there is not enough memory for the object.\n   If zlib is used in a multi-threaded application, zalloc and zfree must be\n   thread safe.\n\n     On 16-bit systems, the functions zalloc and zfree must be able to allocate\n   exactly 65536 bytes, but will not be required to allocate more than this if\n   the symbol MAXSEG_64K is defined (see zconf.h).  WARNING: On MSDOS, pointers\n   returned by zalloc for objects of exactly 65536 bytes *must* have their\n   offset normalized to zero.  The default allocation function provided by this\n   library ensures this (see zutil.c).  To reduce memory requirements and avoid\n   any allocation of 64K objects, at the expense of compression ratio, compile\n   the library with -DMAX_WBITS=14 (see zconf.h).\n\n     The fields total_in and total_out can be used for statistics or progress\n   reports.  After compression, total_in holds the total size of the\n   uncompressed data and may be saved for use in the decompressor (particularly\n   if the decompressor wants to decompress everything in a single step).\n*/\n\n                        /* constants */\n\n#define Z_NO_FLUSH      0\n#define Z_PARTIAL_FLUSH 1\n#define Z_SYNC_FLUSH    2\n#define Z_FULL_FLUSH    3\n#define Z_FINISH        4\n#define Z_BLOCK         5\n#define Z_TREES         6\n/* Allowed flush values; see deflate() and inflate() below for details */\n\n#define Z_OK            0\n#define Z_STREAM_END    1\n#define Z_NEED_DICT     2\n#define Z_ERRNO        (-1)\n#define Z_STREAM_ERROR (-2)\n#define Z_DATA_ERROR   (-3)\n#define Z_MEM_ERROR    (-4)\n#define Z_BUF_ERROR    (-5)\n#define Z_VERSION_ERROR (-6)\n/* Return codes for the compression/decompression functions. Negative values\n * are errors, positive values are used for special but normal events.\n */\n\n#define Z_NO_COMPRESSION         0\n#define Z_BEST_SPEED             1\n#define Z_BEST_COMPRESSION       9\n#define Z_DEFAULT_COMPRESSION  (-1)\n/* compression levels */\n\n#define Z_FILTERED            1\n#define Z_HUFFMAN_ONLY        2\n#define Z_RLE                 3\n#define Z_FIXED               4\n#define Z_DEFAULT_STRATEGY    0\n/* compression strategy; see deflateInit2() below for details */\n\n#define Z_BINARY   0\n#define Z_TEXT     1\n#define Z_ASCII    Z_TEXT   /* for compatibility with 1.2.2 and earlier */\n#define Z_UNKNOWN  2\n/* Possible values of the data_type field (though see inflate()) */\n\n#define Z_DEFLATED   8\n/* The deflate compression method (the only one supported in this version) */\n\n#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */\n\n#define zlib_version zlibVersion()\n/* for compatibility with versions < 1.0.2 */\n\n\n                        /* basic functions */\n\nZEXTERN const char * ZEXPORT zlibVersion OF((void));\n/* The application can compare zlibVersion and ZLIB_VERSION for consistency.\n   If the first character differs, the library code actually used is not\n   compatible with the zlib.h header file used by the application.  This check\n   is automatically made by deflateInit and inflateInit.\n */\n\n/*\nZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level));\n\n     Initializes the internal stream state for compression.  The fields\n   zalloc, zfree and opaque must be initialized before by the caller.  If\n   zalloc and zfree are set to Z_NULL, deflateInit updates them to use default\n   allocation functions.\n\n     The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9:\n   1 gives best speed, 9 gives best compression, 0 gives no compression at all\n   (the input data is simply copied a block at a time).  Z_DEFAULT_COMPRESSION\n   requests a default compromise between speed and compression (currently\n   equivalent to level 6).\n\n     deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough\n   memory, Z_STREAM_ERROR if level is not a valid compression level, or\n   Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible\n   with the version assumed by the caller (ZLIB_VERSION).  msg is set to null\n   if there is no error message.  deflateInit does not perform any compression:\n   this will be done by deflate().\n*/\n\n\nZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush));\n/*\n    deflate compresses as much data as possible, and stops when the input\n  buffer becomes empty or the output buffer becomes full.  It may introduce\n  some output latency (reading input without producing any output) except when\n  forced to flush.\n\n    The detailed semantics are as follows.  deflate performs one or both of the\n  following actions:\n\n  - Compress more input starting at next_in and update next_in and avail_in\n    accordingly.  If not all input can be processed (because there is not\n    enough room in the output buffer), next_in and avail_in are updated and\n    processing will resume at this point for the next call of deflate().\n\n  - Provide more output starting at next_out and update next_out and avail_out\n    accordingly.  This action is forced if the parameter flush is non zero.\n    Forcing flush frequently degrades the compression ratio, so this parameter\n    should be set only when necessary (in interactive applications).  Some\n    output may be provided even if flush is not set.\n\n    Before the call of deflate(), the application should ensure that at least\n  one of the actions is possible, by providing more input and/or consuming more\n  output, and updating avail_in or avail_out accordingly; avail_out should\n  never be zero before the call.  The application can consume the compressed\n  output when it wants, for example when the output buffer is full (avail_out\n  == 0), or after each call of deflate().  If deflate returns Z_OK and with\n  zero avail_out, it must be called again after making room in the output\n  buffer because there might be more output pending.\n\n    Normally the parameter flush is set to Z_NO_FLUSH, which allows deflate to\n  decide how much data to accumulate before producing output, in order to\n  maximize compression.\n\n    If the parameter flush is set to Z_SYNC_FLUSH, all pending output is\n  flushed to the output buffer and the output is aligned on a byte boundary, so\n  that the decompressor can get all input data available so far.  (In\n  particular avail_in is zero after the call if enough output space has been\n  provided before the call.) Flushing may degrade compression for some\n  compression algorithms and so it should be used only when necessary.  This\n  completes the current deflate block and follows it with an empty stored block\n  that is three bits plus filler bits to the next byte, followed by four bytes\n  (00 00 ff ff).\n\n    If flush is set to Z_PARTIAL_FLUSH, all pending output is flushed to the\n  output buffer, but the output is not aligned to a byte boundary.  All of the\n  input data so far will be available to the decompressor, as for Z_SYNC_FLUSH.\n  This completes the current deflate block and follows it with an empty fixed\n  codes block that is 10 bits long.  This assures that enough bytes are output\n  in order for the decompressor to finish the block before the empty fixed code\n  block.\n\n    If flush is set to Z_BLOCK, a deflate block is completed and emitted, as\n  for Z_SYNC_FLUSH, but the output is not aligned on a byte boundary, and up to\n  seven bits of the current block are held to be written as the next byte after\n  the next deflate block is completed.  In this case, the decompressor may not\n  be provided enough bits at this point in order to complete decompression of\n  the data provided so far to the compressor.  It may need to wait for the next\n  block to be emitted.  This is for advanced applications that need to control\n  the emission of deflate blocks.\n\n    If flush is set to Z_FULL_FLUSH, all output is flushed as with\n  Z_SYNC_FLUSH, and the compression state is reset so that decompression can\n  restart from this point if previous compressed data has been damaged or if\n  random access is desired.  Using Z_FULL_FLUSH too often can seriously degrade\n  compression.\n\n    If deflate returns with avail_out == 0, this function must be called again\n  with the same value of the flush parameter and more output space (updated\n  avail_out), until the flush is complete (deflate returns with non-zero\n  avail_out).  In the case of a Z_FULL_FLUSH or Z_SYNC_FLUSH, make sure that\n  avail_out is greater than six to avoid repeated flush markers due to\n  avail_out == 0 on return.\n\n    If the parameter flush is set to Z_FINISH, pending input is processed,\n  pending output is flushed and deflate returns with Z_STREAM_END if there was\n  enough output space; if deflate returns with Z_OK, this function must be\n  called again with Z_FINISH and more output space (updated avail_out) but no\n  more input data, until it returns with Z_STREAM_END or an error.  After\n  deflate has returned Z_STREAM_END, the only possible operations on the stream\n  are deflateReset or deflateEnd.\n\n    Z_FINISH can be used immediately after deflateInit if all the compression\n  is to be done in a single step.  In this case, avail_out must be at least the\n  value returned by deflateBound (see below).  If deflate does not return\n  Z_STREAM_END, then it must be called again as described above.\n\n    deflate() sets strm->adler to the adler32 checksum of all input read\n  so far (that is, total_in bytes).\n\n    deflate() may update strm->data_type if it can make a good guess about\n  the input data type (Z_BINARY or Z_TEXT).  In doubt, the data is considered\n  binary.  This field is only for information purposes and does not affect the\n  compression algorithm in any manner.\n\n    deflate() returns Z_OK if some progress has been made (more input\n  processed or more output produced), Z_STREAM_END if all input has been\n  consumed and all output has been produced (only when flush is set to\n  Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example\n  if next_in or next_out was Z_NULL), Z_BUF_ERROR if no progress is possible\n  (for example avail_in or avail_out was zero).  Note that Z_BUF_ERROR is not\n  fatal, and deflate() can be called again with more input and more output\n  space to continue compressing.\n*/\n\n\nZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm));\n/*\n     All dynamically allocated data structures for this stream are freed.\n   This function discards any unprocessed input and does not flush any pending\n   output.\n\n     deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the\n   stream state was inconsistent, Z_DATA_ERROR if the stream was freed\n   prematurely (some input or output was discarded).  In the error case, msg\n   may be set but then points to a static string (which must not be\n   deallocated).\n*/\n\n\n/*\nZEXTERN int ZEXPORT inflateInit OF((z_streamp strm));\n\n     Initializes the internal stream state for decompression.  The fields\n   next_in, avail_in, zalloc, zfree and opaque must be initialized before by\n   the caller.  If next_in is not Z_NULL and avail_in is large enough (the\n   exact value depends on the compression method), inflateInit determines the\n   compression method from the zlib header and allocates all data structures\n   accordingly; otherwise the allocation will be deferred to the first call of\n   inflate.  If zalloc and zfree are set to Z_NULL, inflateInit updates them to\n   use default allocation functions.\n\n     inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough\n   memory, Z_VERSION_ERROR if the zlib library version is incompatible with the\n   version assumed by the caller, or Z_STREAM_ERROR if the parameters are\n   invalid, such as a null pointer to the structure.  msg is set to null if\n   there is no error message.  inflateInit does not perform any decompression\n   apart from possibly reading the zlib header if present: actual decompression\n   will be done by inflate().  (So next_in and avail_in may be modified, but\n   next_out and avail_out are unused and unchanged.) The current implementation\n   of inflateInit() does not process any header information -- that is deferred\n   until inflate() is called.\n*/\n\n\nZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush));\n/*\n    inflate decompresses as much data as possible, and stops when the input\n  buffer becomes empty or the output buffer becomes full.  It may introduce\n  some output latency (reading input without producing any output) except when\n  forced to flush.\n\n  The detailed semantics are as follows.  inflate performs one or both of the\n  following actions:\n\n  - Decompress more input starting at next_in and update next_in and avail_in\n    accordingly.  If not all input can be processed (because there is not\n    enough room in the output buffer), next_in is updated and processing will\n    resume at this point for the next call of inflate().\n\n  - Provide more output starting at next_out and update next_out and avail_out\n    accordingly.  inflate() provides as much output as possible, until there is\n    no more input data or no more space in the output buffer (see below about\n    the flush parameter).\n\n    Before the call of inflate(), the application should ensure that at least\n  one of the actions is possible, by providing more input and/or consuming more\n  output, and updating the next_* and avail_* values accordingly.  The\n  application can consume the uncompressed output when it wants, for example\n  when the output buffer is full (avail_out == 0), or after each call of\n  inflate().  If inflate returns Z_OK and with zero avail_out, it must be\n  called again after making room in the output buffer because there might be\n  more output pending.\n\n    The flush parameter of inflate() can be Z_NO_FLUSH, Z_SYNC_FLUSH, Z_FINISH,\n  Z_BLOCK, or Z_TREES.  Z_SYNC_FLUSH requests that inflate() flush as much\n  output as possible to the output buffer.  Z_BLOCK requests that inflate()\n  stop if and when it gets to the next deflate block boundary.  When decoding\n  the zlib or gzip format, this will cause inflate() to return immediately\n  after the header and before the first block.  When doing a raw inflate,\n  inflate() will go ahead and process the first block, and will return when it\n  gets to the end of that block, or when it runs out of data.\n\n    The Z_BLOCK option assists in appending to or combining deflate streams.\n  Also to assist in this, on return inflate() will set strm->data_type to the\n  number of unused bits in the last byte taken from strm->next_in, plus 64 if\n  inflate() is currently decoding the last block in the deflate stream, plus\n  128 if inflate() returned immediately after decoding an end-of-block code or\n  decoding the complete header up to just before the first byte of the deflate\n  stream.  The end-of-block will not be indicated until all of the uncompressed\n  data from that block has been written to strm->next_out.  The number of\n  unused bits may in general be greater than seven, except when bit 7 of\n  data_type is set, in which case the number of unused bits will be less than\n  eight.  data_type is set as noted here every time inflate() returns for all\n  flush options, and so can be used to determine the amount of currently\n  consumed input in bits.\n\n    The Z_TREES option behaves as Z_BLOCK does, but it also returns when the\n  end of each deflate block header is reached, before any actual data in that\n  block is decoded.  This allows the caller to determine the length of the\n  deflate block header for later use in random access within a deflate block.\n  256 is added to the value of strm->data_type when inflate() returns\n  immediately after reaching the end of the deflate block header.\n\n    inflate() should normally be called until it returns Z_STREAM_END or an\n  error.  However if all decompression is to be performed in a single step (a\n  single call of inflate), the parameter flush should be set to Z_FINISH.  In\n  this case all pending input is processed and all pending output is flushed;\n  avail_out must be large enough to hold all the uncompressed data.  (The size\n  of the uncompressed data may have been saved by the compressor for this\n  purpose.) The next operation on this stream must be inflateEnd to deallocate\n  the decompression state.  The use of Z_FINISH is never required, but can be\n  used to inform inflate that a faster approach may be used for the single\n  inflate() call.\n\n     In this implementation, inflate() always flushes as much output as\n  possible to the output buffer, and always uses the faster approach on the\n  first call.  So the only effect of the flush parameter in this implementation\n  is on the return value of inflate(), as noted below, or when it returns early\n  because Z_BLOCK or Z_TREES is used.\n\n     If a preset dictionary is needed after this call (see inflateSetDictionary\n  below), inflate sets strm->adler to the adler32 checksum of the dictionary\n  chosen by the compressor and returns Z_NEED_DICT; otherwise it sets\n  strm->adler to the adler32 checksum of all output produced so far (that is,\n  total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as described\n  below.  At the end of the stream, inflate() checks that its computed adler32\n  checksum is equal to that saved by the compressor and returns Z_STREAM_END\n  only if the checksum is correct.\n\n    inflate() can decompress and check either zlib-wrapped or gzip-wrapped\n  deflate data.  The header type is detected automatically, if requested when\n  initializing with inflateInit2().  Any information contained in the gzip\n  header is not retained, so applications that need that information should\n  instead use raw inflate, see inflateInit2() below, or inflateBack() and\n  perform their own processing of the gzip header and trailer.\n\n    inflate() returns Z_OK if some progress has been made (more input processed\n  or more output produced), Z_STREAM_END if the end of the compressed data has\n  been reached and all uncompressed output has been produced, Z_NEED_DICT if a\n  preset dictionary is needed at this point, Z_DATA_ERROR if the input data was\n  corrupted (input stream not conforming to the zlib format or incorrect check\n  value), Z_STREAM_ERROR if the stream structure was inconsistent (for example\n  next_in or next_out was Z_NULL), Z_MEM_ERROR if there was not enough memory,\n  Z_BUF_ERROR if no progress is possible or if there was not enough room in the\n  output buffer when Z_FINISH is used.  Note that Z_BUF_ERROR is not fatal, and\n  inflate() can be called again with more input and more output space to\n  continue decompressing.  If Z_DATA_ERROR is returned, the application may\n  then call inflateSync() to look for a good compression block if a partial\n  recovery of the data is desired.\n*/\n\n\nZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm));\n/*\n     All dynamically allocated data structures for this stream are freed.\n   This function discards any unprocessed input and does not flush any pending\n   output.\n\n     inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state\n   was inconsistent.  In the error case, msg may be set but then points to a\n   static string (which must not be deallocated).\n*/\n\n\n                        /* Advanced functions */\n\n/*\n    The following functions are needed only in some special applications.\n*/\n\n/*\nZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm,\n                                     int  level,\n                                     int  method,\n                                     int  windowBits,\n                                     int  memLevel,\n                                     int  strategy));\n\n     This is another version of deflateInit with more compression options.  The\n   fields next_in, zalloc, zfree and opaque must be initialized before by the\n   caller.\n\n     The method parameter is the compression method.  It must be Z_DEFLATED in\n   this version of the library.\n\n     The windowBits parameter is the base two logarithm of the window size\n   (the size of the history buffer).  It should be in the range 8..15 for this\n   version of the library.  Larger values of this parameter result in better\n   compression at the expense of memory usage.  The default value is 15 if\n   deflateInit is used instead.\n\n     windowBits can also be -8..-15 for raw deflate.  In this case, -windowBits\n   determines the window size.  deflate() will then generate raw deflate data\n   with no zlib header or trailer, and will not compute an adler32 check value.\n\n     windowBits can also be greater than 15 for optional gzip encoding.  Add\n   16 to windowBits to write a simple gzip header and trailer around the\n   compressed data instead of a zlib wrapper.  The gzip header will have no\n   file name, no extra data, no comment, no modification time (set to zero), no\n   header crc, and the operating system will be set to 255 (unknown).  If a\n   gzip stream is being written, strm->adler is a crc32 instead of an adler32.\n\n     The memLevel parameter specifies how much memory should be allocated\n   for the internal compression state.  memLevel=1 uses minimum memory but is\n   slow and reduces compression ratio; memLevel=9 uses maximum memory for\n   optimal speed.  The default value is 8.  See zconf.h for total memory usage\n   as a function of windowBits and memLevel.\n\n     The strategy parameter is used to tune the compression algorithm.  Use the\n   value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a\n   filter (or predictor), Z_HUFFMAN_ONLY to force Huffman encoding only (no\n   string match), or Z_RLE to limit match distances to one (run-length\n   encoding).  Filtered data consists mostly of small values with a somewhat\n   random distribution.  In this case, the compression algorithm is tuned to\n   compress them better.  The effect of Z_FILTERED is to force more Huffman\n   coding and less string matching; it is somewhat intermediate between\n   Z_DEFAULT_STRATEGY and Z_HUFFMAN_ONLY.  Z_RLE is designed to be almost as\n   fast as Z_HUFFMAN_ONLY, but give better compression for PNG image data.  The\n   strategy parameter only affects the compression ratio but not the\n   correctness of the compressed output even if it is not set appropriately.\n   Z_FIXED prevents the use of dynamic Huffman codes, allowing for a simpler\n   decoder for special applications.\n\n     deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough\n   memory, Z_STREAM_ERROR if any parameter is invalid (such as an invalid\n   method), or Z_VERSION_ERROR if the zlib library version (zlib_version) is\n   incompatible with the version assumed by the caller (ZLIB_VERSION).  msg is\n   set to null if there is no error message.  deflateInit2 does not perform any\n   compression: this will be done by deflate().\n*/\n\nZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm,\n                                             const Bytef *dictionary,\n                                             uInt  dictLength));\n/*\n     Initializes the compression dictionary from the given byte sequence\n   without producing any compressed output.  This function must be called\n   immediately after deflateInit, deflateInit2 or deflateReset, before any call\n   of deflate.  The compressor and decompressor must use exactly the same\n   dictionary (see inflateSetDictionary).\n\n     The dictionary should consist of strings (byte sequences) that are likely\n   to be encountered later in the data to be compressed, with the most commonly\n   used strings preferably put towards the end of the dictionary.  Using a\n   dictionary is most useful when the data to be compressed is short and can be\n   predicted with good accuracy; the data can then be compressed better than\n   with the default empty dictionary.\n\n     Depending on the size of the compression data structures selected by\n   deflateInit or deflateInit2, a part of the dictionary may in effect be\n   discarded, for example if the dictionary is larger than the window size\n   provided in deflateInit or deflateInit2.  Thus the strings most likely to be\n   useful should be put at the end of the dictionary, not at the front.  In\n   addition, the current implementation of deflate will use at most the window\n   size minus 262 bytes of the provided dictionary.\n\n     Upon return of this function, strm->adler is set to the adler32 value\n   of the dictionary; the decompressor may later use this value to determine\n   which dictionary has been used by the compressor.  (The adler32 value\n   applies to the whole dictionary even if only a subset of the dictionary is\n   actually used by the compressor.) If a raw deflate was requested, then the\n   adler32 value is not computed and strm->adler is not set.\n\n     deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a\n   parameter is invalid (e.g.  dictionary being Z_NULL) or the stream state is\n   inconsistent (for example if deflate has already been called for this stream\n   or if the compression method is bsort).  deflateSetDictionary does not\n   perform any compression: this will be done by deflate().\n*/\n\nZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest,\n                                    z_streamp source));\n/*\n     Sets the destination stream as a complete copy of the source stream.\n\n     This function can be useful when several compression strategies will be\n   tried, for example when there are several ways of pre-processing the input\n   data with a filter.  The streams that will be discarded should then be freed\n   by calling deflateEnd.  Note that deflateCopy duplicates the internal\n   compression state which can be quite large, so this strategy is slow and can\n   consume lots of memory.\n\n     deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not\n   enough memory, Z_STREAM_ERROR if the source stream state was inconsistent\n   (such as zalloc being Z_NULL).  msg is left unchanged in both source and\n   destination.\n*/\n\nZEXTERN int ZEXPORT deflateReset OF((z_streamp strm));\n/*\n     This function is equivalent to deflateEnd followed by deflateInit,\n   but does not free and reallocate all the internal compression state.  The\n   stream will keep the same compression level and any other attributes that\n   may have been set by deflateInit2.\n\n     deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source\n   stream state was inconsistent (such as zalloc or state being Z_NULL).\n*/\n\nZEXTERN int ZEXPORT deflateParams OF((z_streamp strm,\n                                      int level,\n                                      int strategy));\n/*\n     Dynamically update the compression level and compression strategy.  The\n   interpretation of level and strategy is as in deflateInit2.  This can be\n   used to switch between compression and straight copy of the input data, or\n   to switch to a different kind of input data requiring a different strategy.\n   If the compression level is changed, the input available so far is\n   compressed with the old level (and may be flushed); the new level will take\n   effect only at the next call of deflate().\n\n     Before the call of deflateParams, the stream state must be set as for\n   a call of deflate(), since the currently available input may have to be\n   compressed and flushed.  In particular, strm->avail_out must be non-zero.\n\n     deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source\n   stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR if\n   strm->avail_out was zero.\n*/\n\nZEXTERN int ZEXPORT deflateTune OF((z_streamp strm,\n                                    int good_length,\n                                    int max_lazy,\n                                    int nice_length,\n                                    int max_chain));\n/*\n     Fine tune deflate's internal compression parameters.  This should only be\n   used by someone who understands the algorithm used by zlib's deflate for\n   searching for the best matching string, and even then only by the most\n   fanatic optimizer trying to squeeze out the last compressed bit for their\n   specific input data.  Read the deflate.c source code for the meaning of the\n   max_lazy, good_length, nice_length, and max_chain parameters.\n\n     deflateTune() can be called after deflateInit() or deflateInit2(), and\n   returns Z_OK on success, or Z_STREAM_ERROR for an invalid deflate stream.\n */\n\nZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm,\n                                       uLong sourceLen));\n/*\n     deflateBound() returns an upper bound on the compressed size after\n   deflation of sourceLen bytes.  It must be called after deflateInit() or\n   deflateInit2(), and after deflateSetHeader(), if used.  This would be used\n   to allocate an output buffer for deflation in a single pass, and so would be\n   called before deflate().\n*/\n\nZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm,\n                                     int bits,\n                                     int value));\n/*\n     deflatePrime() inserts bits in the deflate output stream.  The intent\n   is that this function is used to start off the deflate output with the bits\n   leftover from a previous deflate stream when appending to it.  As such, this\n   function can only be used for raw deflate, and must be used before the first\n   deflate() call after a deflateInit2() or deflateReset().  bits must be less\n   than or equal to 16, and that many of the least significant bits of value\n   will be inserted in the output.\n\n     deflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source\n   stream state was inconsistent.\n*/\n\nZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm,\n                                         gz_headerp head));\n/*\n     deflateSetHeader() provides gzip header information for when a gzip\n   stream is requested by deflateInit2().  deflateSetHeader() may be called\n   after deflateInit2() or deflateReset() and before the first call of\n   deflate().  The text, time, os, extra field, name, and comment information\n   in the provided gz_header structure are written to the gzip header (xflag is\n   ignored -- the extra flags are set according to the compression level).  The\n   caller must assure that, if not Z_NULL, name and comment are terminated with\n   a zero byte, and that if extra is not Z_NULL, that extra_len bytes are\n   available there.  If hcrc is true, a gzip header crc is included.  Note that\n   the current versions of the command-line version of gzip (up through version\n   1.3.x) do not support header crc's, and will report that it is a \"multi-part\n   gzip file\" and give up.\n\n     If deflateSetHeader is not used, the default gzip header has text false,\n   the time set to zero, and os set to 255, with no extra, name, or comment\n   fields.  The gzip header is returned to the default state by deflateReset().\n\n     deflateSetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source\n   stream state was inconsistent.\n*/\n\n/*\nZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm,\n                                     int  windowBits));\n\n     This is another version of inflateInit with an extra parameter.  The\n   fields next_in, avail_in, zalloc, zfree and opaque must be initialized\n   before by the caller.\n\n     The windowBits parameter is the base two logarithm of the maximum window\n   size (the size of the history buffer).  It should be in the range 8..15 for\n   this version of the library.  The default value is 15 if inflateInit is used\n   instead.  windowBits must be greater than or equal to the windowBits value\n   provided to deflateInit2() while compressing, or it must be equal to 15 if\n   deflateInit2() was not used.  If a compressed stream with a larger window\n   size is given as input, inflate() will return with the error code\n   Z_DATA_ERROR instead of trying to allocate a larger window.\n\n     windowBits can also be zero to request that inflate use the window size in\n   the zlib header of the compressed stream.\n\n     windowBits can also be -8..-15 for raw inflate.  In this case, -windowBits\n   determines the window size.  inflate() will then process raw deflate data,\n   not looking for a zlib or gzip header, not generating a check value, and not\n   looking for any check values for comparison at the end of the stream.  This\n   is for use with other formats that use the deflate compressed data format\n   such as zip.  Those formats provide their own check values.  If a custom\n   format is developed using the raw deflate format for compressed data, it is\n   recommended that a check value such as an adler32 or a crc32 be applied to\n   the uncompressed data as is done in the zlib, gzip, and zip formats.  For\n   most applications, the zlib format should be used as is.  Note that comments\n   above on the use in deflateInit2() applies to the magnitude of windowBits.\n\n     windowBits can also be greater than 15 for optional gzip decoding.  Add\n   32 to windowBits to enable zlib and gzip decoding with automatic header\n   detection, or add 16 to decode only the gzip format (the zlib format will\n   return a Z_DATA_ERROR).  If a gzip stream is being decoded, strm->adler is a\n   crc32 instead of an adler32.\n\n     inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough\n   memory, Z_VERSION_ERROR if the zlib library version is incompatible with the\n   version assumed by the caller, or Z_STREAM_ERROR if the parameters are\n   invalid, such as a null pointer to the structure.  msg is set to null if\n   there is no error message.  inflateInit2 does not perform any decompression\n   apart from possibly reading the zlib header if present: actual decompression\n   will be done by inflate().  (So next_in and avail_in may be modified, but\n   next_out and avail_out are unused and unchanged.) The current implementation\n   of inflateInit2() does not process any header information -- that is\n   deferred until inflate() is called.\n*/\n\nZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm,\n                                             const Bytef *dictionary,\n                                             uInt  dictLength));\n/*\n     Initializes the decompression dictionary from the given uncompressed byte\n   sequence.  This function must be called immediately after a call of inflate,\n   if that call returned Z_NEED_DICT.  The dictionary chosen by the compressor\n   can be determined from the adler32 value returned by that call of inflate.\n   The compressor and decompressor must use exactly the same dictionary (see\n   deflateSetDictionary).  For raw inflate, this function can be called\n   immediately after inflateInit2() or inflateReset() and before any call of\n   inflate() to set the dictionary.  The application must insure that the\n   dictionary that was used for compression is provided.\n\n     inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a\n   parameter is invalid (e.g.  dictionary being Z_NULL) or the stream state is\n   inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the\n   expected one (incorrect adler32 value).  inflateSetDictionary does not\n   perform any decompression: this will be done by subsequent calls of\n   inflate().\n*/\n\nZEXTERN int ZEXPORT inflateSync OF((z_streamp strm));\n/*\n     Skips invalid compressed data until a full flush point (see above the\n   description of deflate with Z_FULL_FLUSH) can be found, or until all\n   available input is skipped.  No output is provided.\n\n     inflateSync returns Z_OK if a full flush point has been found, Z_BUF_ERROR\n   if no more input was provided, Z_DATA_ERROR if no flush point has been\n   found, or Z_STREAM_ERROR if the stream structure was inconsistent.  In the\n   success case, the application may save the current current value of total_in\n   which indicates where valid compressed data was found.  In the error case,\n   the application may repeatedly call inflateSync, providing more input each\n   time, until success or end of the input data.\n*/\n\nZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest,\n                                    z_streamp source));\n/*\n     Sets the destination stream as a complete copy of the source stream.\n\n     This function can be useful when randomly accessing a large stream.  The\n   first pass through the stream can periodically record the inflate state,\n   allowing restarting inflate at those points when randomly accessing the\n   stream.\n\n     inflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not\n   enough memory, Z_STREAM_ERROR if the source stream state was inconsistent\n   (such as zalloc being Z_NULL).  msg is left unchanged in both source and\n   destination.\n*/\n\nZEXTERN int ZEXPORT inflateReset OF((z_streamp strm));\n/*\n     This function is equivalent to inflateEnd followed by inflateInit,\n   but does not free and reallocate all the internal decompression state.  The\n   stream will keep attributes that may have been set by inflateInit2.\n\n     inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source\n   stream state was inconsistent (such as zalloc or state being Z_NULL).\n*/\n\nZEXTERN int ZEXPORT inflateReset2 OF((z_streamp strm,\n                                      int windowBits));\n/*\n     This function is the same as inflateReset, but it also permits changing\n   the wrap and window size requests.  The windowBits parameter is interpreted\n   the same as it is for inflateInit2.\n\n     inflateReset2 returns Z_OK if success, or Z_STREAM_ERROR if the source\n   stream state was inconsistent (such as zalloc or state being Z_NULL), or if\n   the windowBits parameter is invalid.\n*/\n\nZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm,\n                                     int bits,\n                                     int value));\n/*\n     This function inserts bits in the inflate input stream.  The intent is\n   that this function is used to start inflating at a bit position in the\n   middle of a byte.  The provided bits will be used before any bytes are used\n   from next_in.  This function should only be used with raw inflate, and\n   should be used before the first inflate() call after inflateInit2() or\n   inflateReset().  bits must be less than or equal to 16, and that many of the\n   least significant bits of value will be inserted in the input.\n\n     If bits is negative, then the input stream bit buffer is emptied.  Then\n   inflatePrime() can be called again to put bits in the buffer.  This is used\n   to clear out bits leftover after feeding inflate a block description prior\n   to feeding inflate codes.\n\n     inflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source\n   stream state was inconsistent.\n*/\n\nZEXTERN long ZEXPORT inflateMark OF((z_streamp strm));\n/*\n     This function returns two values, one in the lower 16 bits of the return\n   value, and the other in the remaining upper bits, obtained by shifting the\n   return value down 16 bits.  If the upper value is -1 and the lower value is\n   zero, then inflate() is currently decoding information outside of a block.\n   If the upper value is -1 and the lower value is non-zero, then inflate is in\n   the middle of a stored block, with the lower value equaling the number of\n   bytes from the input remaining to copy.  If the upper value is not -1, then\n   it is the number of bits back from the current bit position in the input of\n   the code (literal or length/distance pair) currently being processed.  In\n   that case the lower value is the number of bytes already emitted for that\n   code.\n\n     A code is being processed if inflate is waiting for more input to complete\n   decoding of the code, or if it has completed decoding but is waiting for\n   more output space to write the literal or match data.\n\n     inflateMark() is used to mark locations in the input data for random\n   access, which may be at bit positions, and to note those cases where the\n   output of a code may span boundaries of random access blocks.  The current\n   location in the input stream can be determined from avail_in and data_type\n   as noted in the description for the Z_BLOCK flush parameter for inflate.\n\n     inflateMark returns the value noted above or -1 << 16 if the provided\n   source stream state was inconsistent.\n*/\n\nZEXTERN int ZEXPORT inflateGetHeader OF((z_streamp strm,\n                                         gz_headerp head));\n/*\n     inflateGetHeader() requests that gzip header information be stored in the\n   provided gz_header structure.  inflateGetHeader() may be called after\n   inflateInit2() or inflateReset(), and before the first call of inflate().\n   As inflate() processes the gzip stream, head->done is zero until the header\n   is completed, at which time head->done is set to one.  If a zlib stream is\n   being decoded, then head->done is set to -1 to indicate that there will be\n   no gzip header information forthcoming.  Note that Z_BLOCK or Z_TREES can be\n   used to force inflate() to return immediately after header processing is\n   complete and before any actual data is decompressed.\n\n     The text, time, xflags, and os fields are filled in with the gzip header\n   contents.  hcrc is set to true if there is a header CRC.  (The header CRC\n   was valid if done is set to one.) If extra is not Z_NULL, then extra_max\n   contains the maximum number of bytes to write to extra.  Once done is true,\n   extra_len contains the actual extra field length, and extra contains the\n   extra field, or that field truncated if extra_max is less than extra_len.\n   If name is not Z_NULL, then up to name_max characters are written there,\n   terminated with a zero unless the length is greater than name_max.  If\n   comment is not Z_NULL, then up to comm_max characters are written there,\n   terminated with a zero unless the length is greater than comm_max.  When any\n   of extra, name, or comment are not Z_NULL and the respective field is not\n   present in the header, then that field is set to Z_NULL to signal its\n   absence.  This allows the use of deflateSetHeader() with the returned\n   structure to duplicate the header.  However if those fields are set to\n   allocated memory, then the application will need to save those pointers\n   elsewhere so that they can be eventually freed.\n\n     If inflateGetHeader is not used, then the header information is simply\n   discarded.  The header is always checked for validity, including the header\n   CRC if present.  inflateReset() will reset the process to discard the header\n   information.  The application would need to call inflateGetHeader() again to\n   retrieve the header from the next gzip stream.\n\n     inflateGetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source\n   stream state was inconsistent.\n*/\n\n/*\nZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits,\n                                        unsigned char FAR *window));\n\n     Initialize the internal stream state for decompression using inflateBack()\n   calls.  The fields zalloc, zfree and opaque in strm must be initialized\n   before the call.  If zalloc and zfree are Z_NULL, then the default library-\n   derived memory allocation routines are used.  windowBits is the base two\n   logarithm of the window size, in the range 8..15.  window is a caller\n   supplied buffer of that size.  Except for special applications where it is\n   assured that deflate was used with small window sizes, windowBits must be 15\n   and a 32K byte window must be supplied to be able to decompress general\n   deflate streams.\n\n     See inflateBack() for the usage of these routines.\n\n     inflateBackInit will return Z_OK on success, Z_STREAM_ERROR if any of\n   the paramaters are invalid, Z_MEM_ERROR if the internal state could not be\n   allocated, or Z_VERSION_ERROR if the version of the library does not match\n   the version of the header file.\n*/\n\ntypedef unsigned (*in_func) OF((void FAR *, unsigned char FAR * FAR *));\ntypedef int (*out_func) OF((void FAR *, unsigned char FAR *, unsigned));\n\nZEXTERN int ZEXPORT inflateBack OF((z_streamp strm,\n                                    in_func in, void FAR *in_desc,\n                                    out_func out, void FAR *out_desc));\n/*\n     inflateBack() does a raw inflate with a single call using a call-back\n   interface for input and output.  This is more efficient than inflate() for\n   file i/o applications in that it avoids copying between the output and the\n   sliding window by simply making the window itself the output buffer.  This\n   function trusts the application to not change the output buffer passed by\n   the output function, at least until inflateBack() returns.\n\n     inflateBackInit() must be called first to allocate the internal state\n   and to initialize the state with the user-provided window buffer.\n   inflateBack() may then be used multiple times to inflate a complete, raw\n   deflate stream with each call.  inflateBackEnd() is then called to free the\n   allocated state.\n\n     A raw deflate stream is one with no zlib or gzip header or trailer.\n   This routine would normally be used in a utility that reads zip or gzip\n   files and writes out uncompressed files.  The utility would decode the\n   header and process the trailer on its own, hence this routine expects only\n   the raw deflate stream to decompress.  This is different from the normal\n   behavior of inflate(), which expects either a zlib or gzip header and\n   trailer around the deflate stream.\n\n     inflateBack() uses two subroutines supplied by the caller that are then\n   called by inflateBack() for input and output.  inflateBack() calls those\n   routines until it reads a complete deflate stream and writes out all of the\n   uncompressed data, or until it encounters an error.  The function's\n   parameters and return types are defined above in the in_func and out_func\n   typedefs.  inflateBack() will call in(in_desc, &buf) which should return the\n   number of bytes of provided input, and a pointer to that input in buf.  If\n   there is no input available, in() must return zero--buf is ignored in that\n   case--and inflateBack() will return a buffer error.  inflateBack() will call\n   out(out_desc, buf, len) to write the uncompressed data buf[0..len-1].  out()\n   should return zero on success, or non-zero on failure.  If out() returns\n   non-zero, inflateBack() will return with an error.  Neither in() nor out()\n   are permitted to change the contents of the window provided to\n   inflateBackInit(), which is also the buffer that out() uses to write from.\n   The length written by out() will be at most the window size.  Any non-zero\n   amount of input may be provided by in().\n\n     For convenience, inflateBack() can be provided input on the first call by\n   setting strm->next_in and strm->avail_in.  If that input is exhausted, then\n   in() will be called.  Therefore strm->next_in must be initialized before\n   calling inflateBack().  If strm->next_in is Z_NULL, then in() will be called\n   immediately for input.  If strm->next_in is not Z_NULL, then strm->avail_in\n   must also be initialized, and then if strm->avail_in is not zero, input will\n   initially be taken from strm->next_in[0 ..  strm->avail_in - 1].\n\n     The in_desc and out_desc parameters of inflateBack() is passed as the\n   first parameter of in() and out() respectively when they are called.  These\n   descriptors can be optionally used to pass any information that the caller-\n   supplied in() and out() functions need to do their job.\n\n     On return, inflateBack() will set strm->next_in and strm->avail_in to\n   pass back any unused input that was provided by the last in() call.  The\n   return values of inflateBack() can be Z_STREAM_END on success, Z_BUF_ERROR\n   if in() or out() returned an error, Z_DATA_ERROR if there was a format error\n   in the deflate stream (in which case strm->msg is set to indicate the nature\n   of the error), or Z_STREAM_ERROR if the stream was not properly initialized.\n   In the case of Z_BUF_ERROR, an input or output error can be distinguished\n   using strm->next_in which will be Z_NULL only if in() returned an error.  If\n   strm->next_in is not Z_NULL, then the Z_BUF_ERROR was due to out() returning\n   non-zero.  (in() will always be called before out(), so strm->next_in is\n   assured to be defined if out() returns non-zero.) Note that inflateBack()\n   cannot return Z_OK.\n*/\n\nZEXTERN int ZEXPORT inflateBackEnd OF((z_streamp strm));\n/*\n     All memory allocated by inflateBackInit() is freed.\n\n     inflateBackEnd() returns Z_OK on success, or Z_STREAM_ERROR if the stream\n   state was inconsistent.\n*/\n\nZEXTERN uLong ZEXPORT zlibCompileFlags OF((void));\n/* Return flags indicating compile-time options.\n\n    Type sizes, two bits each, 00 = 16 bits, 01 = 32, 10 = 64, 11 = other:\n     1.0: size of uInt\n     3.2: size of uLong\n     5.4: size of voidpf (pointer)\n     7.6: size of z_off_t\n\n    Compiler, assembler, and debug options:\n     8: DEBUG\n     9: ASMV or ASMINF -- use ASM code\n     10: ZLIB_WINAPI -- exported functions use the WINAPI calling convention\n     11: 0 (reserved)\n\n    One-time table building (smaller code, but not thread-safe if true):\n     12: BUILDFIXED -- build static block decoding tables when needed\n     13: DYNAMIC_CRC_TABLE -- build CRC calculation tables when needed\n     14,15: 0 (reserved)\n\n    Library content (indicates missing functionality):\n     16: NO_GZCOMPRESS -- gz* functions cannot compress (to avoid linking\n                          deflate code when not needed)\n     17: NO_GZIP -- deflate can't write gzip streams, and inflate can't detect\n                    and decode gzip streams (to avoid linking crc code)\n     18-19: 0 (reserved)\n\n    Operation variations (changes in library functionality):\n     20: PKZIP_BUG_WORKAROUND -- slightly more permissive inflate\n     21: FASTEST -- deflate algorithm with only one, lowest compression level\n     22,23: 0 (reserved)\n\n    The sprintf variant used by gzprintf (zero is best):\n     24: 0 = vs*, 1 = s* -- 1 means limited to 20 arguments after the format\n     25: 0 = *nprintf, 1 = *printf -- 1 means gzprintf() not secure!\n     26: 0 = returns value, 1 = void -- 1 means inferred string length returned\n\n    Remainder:\n     27-31: 0 (reserved)\n */\n\n\n                        /* utility functions */\n\n/*\n     The following utility functions are implemented on top of the basic\n   stream-oriented functions.  To simplify the interface, some default options\n   are assumed (compression level and memory usage, standard memory allocation\n   functions).  The source code of these utility functions can be modified if\n   you need special options.\n*/\n\nZEXTERN int ZEXPORT compress OF((Bytef *dest,   uLongf *destLen,\n                                 const Bytef *source, uLong sourceLen));\n/*\n     Compresses the source buffer into the destination buffer.  sourceLen is\n   the byte length of the source buffer.  Upon entry, destLen is the total size\n   of the destination buffer, which must be at least the value returned by\n   compressBound(sourceLen).  Upon exit, destLen is the actual size of the\n   compressed buffer.\n\n     compress returns Z_OK if success, Z_MEM_ERROR if there was not\n   enough memory, Z_BUF_ERROR if there was not enough room in the output\n   buffer.\n*/\n\nZEXTERN int ZEXPORT compress2 OF((Bytef *dest,   uLongf *destLen,\n                                  const Bytef *source, uLong sourceLen,\n                                  int level));\n/*\n     Compresses the source buffer into the destination buffer.  The level\n   parameter has the same meaning as in deflateInit.  sourceLen is the byte\n   length of the source buffer.  Upon entry, destLen is the total size of the\n   destination buffer, which must be at least the value returned by\n   compressBound(sourceLen).  Upon exit, destLen is the actual size of the\n   compressed buffer.\n\n     compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough\n   memory, Z_BUF_ERROR if there was not enough room in the output buffer,\n   Z_STREAM_ERROR if the level parameter is invalid.\n*/\n\nZEXTERN uLong ZEXPORT compressBound OF((uLong sourceLen));\n/*\n     compressBound() returns an upper bound on the compressed size after\n   compress() or compress2() on sourceLen bytes.  It would be used before a\n   compress() or compress2() call to allocate the destination buffer.\n*/\n\nZEXTERN int ZEXPORT uncompress OF((Bytef *dest,   uLongf *destLen,\n                                   const Bytef *source, uLong sourceLen));\n/*\n     Decompresses the source buffer into the destination buffer.  sourceLen is\n   the byte length of the source buffer.  Upon entry, destLen is the total size\n   of the destination buffer, which must be large enough to hold the entire\n   uncompressed data.  (The size of the uncompressed data must have been saved\n   previously by the compressor and transmitted to the decompressor by some\n   mechanism outside the scope of this compression library.) Upon exit, destLen\n   is the actual size of the uncompressed buffer.\n\n     uncompress returns Z_OK if success, Z_MEM_ERROR if there was not\n   enough memory, Z_BUF_ERROR if there was not enough room in the output\n   buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete.\n*/\n\n\n                        /* gzip file access functions */\n\n/*\n     This library supports reading and writing files in gzip (.gz) format with\n   an interface similar to that of stdio, using the functions that start with\n   \"gz\".  The gzip format is different from the zlib format.  gzip is a gzip\n   wrapper, documented in RFC 1952, wrapped around a deflate stream.\n*/\n\ntypedef voidp gzFile;       /* opaque gzip file descriptor */\n\n/*\nZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode));\n\n     Opens a gzip (.gz) file for reading or writing.  The mode parameter is as\n   in fopen (\"rb\" or \"wb\") but can also include a compression level (\"wb9\") or\n   a strategy: 'f' for filtered data as in \"wb6f\", 'h' for Huffman-only\n   compression as in \"wb1h\", 'R' for run-length encoding as in \"wb1R\", or 'F'\n   for fixed code compression as in \"wb9F\".  (See the description of\n   deflateInit2 for more information about the strategy parameter.) Also \"a\"\n   can be used instead of \"w\" to request that the gzip stream that will be\n   written be appended to the file.  \"+\" will result in an error, since reading\n   and writing to the same gzip file is not supported.\n\n     gzopen can be used to read a file which is not in gzip format; in this\n   case gzread will directly read from the file without decompression.\n\n     gzopen returns NULL if the file could not be opened, if there was\n   insufficient memory to allocate the gzFile state, or if an invalid mode was\n   specified (an 'r', 'w', or 'a' was not provided, or '+' was provided).\n   errno can be checked to determine if the reason gzopen failed was that the\n   file could not be opened.\n*/\n\nZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode));\n/*\n     gzdopen associates a gzFile with the file descriptor fd.  File descriptors\n   are obtained from calls like open, dup, creat, pipe or fileno (if the file\n   has been previously opened with fopen).  The mode parameter is as in gzopen.\n\n     The next call of gzclose on the returned gzFile will also close the file\n   descriptor fd, just like fclose(fdopen(fd, mode)) closes the file descriptor\n   fd.  If you want to keep fd open, use fd = dup(fd_keep); gz = gzdopen(fd,\n   mode);.  The duplicated descriptor should be saved to avoid a leak, since\n   gzdopen does not close fd if it fails.\n\n     gzdopen returns NULL if there was insufficient memory to allocate the\n   gzFile state, if an invalid mode was specified (an 'r', 'w', or 'a' was not\n   provided, or '+' was provided), or if fd is -1.  The file descriptor is not\n   used until the next gz* read, write, seek, or close operation, so gzdopen\n   will not detect if fd is invalid (unless fd is -1).\n*/\n\nZEXTERN int ZEXPORT gzbuffer OF((gzFile file, unsigned size));\n/*\n     Set the internal buffer size used by this library's functions.  The\n   default buffer size is 8192 bytes.  This function must be called after\n   gzopen() or gzdopen(), and before any other calls that read or write the\n   file.  The buffer memory allocation is always deferred to the first read or\n   write.  Two buffers are allocated, either both of the specified size when\n   writing, or one of the specified size and the other twice that size when\n   reading.  A larger buffer size of, for example, 64K or 128K bytes will\n   noticeably increase the speed of decompression (reading).\n\n     The new buffer size also affects the maximum length for gzprintf().\n\n     gzbuffer() returns 0 on success, or -1 on failure, such as being called\n   too late.\n*/\n\nZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy));\n/*\n     Dynamically update the compression level or strategy.  See the description\n   of deflateInit2 for the meaning of these parameters.\n\n     gzsetparams returns Z_OK if success, or Z_STREAM_ERROR if the file was not\n   opened for writing.\n*/\n\nZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len));\n/*\n     Reads the given number of uncompressed bytes from the compressed file.  If\n   the input file was not in gzip format, gzread copies the given number of\n   bytes into the buffer.\n\n     After reaching the end of a gzip stream in the input, gzread will continue\n   to read, looking for another gzip stream, or failing that, reading the rest\n   of the input file directly without decompression.  The entire input file\n   will be read if gzread is called until it returns less than the requested\n   len.\n\n     gzread returns the number of uncompressed bytes actually read, less than\n   len for end of file, or -1 for error.\n*/\n\nZEXTERN int ZEXPORT gzwrite OF((gzFile file,\n                                voidpc buf, unsigned len));\n/*\n     Writes the given number of uncompressed bytes into the compressed file.\n   gzwrite returns the number of uncompressed bytes written or 0 in case of\n   error.\n*/\n\nZEXTERN int ZEXPORTVA gzprintf OF((gzFile file, const char *format, ...));\n/*\n     Converts, formats, and writes the arguments to the compressed file under\n   control of the format string, as in fprintf.  gzprintf returns the number of\n   uncompressed bytes actually written, or 0 in case of error.  The number of\n   uncompressed bytes written is limited to 8191, or one less than the buffer\n   size given to gzbuffer().  The caller should assure that this limit is not\n   exceeded.  If it is exceeded, then gzprintf() will return an error (0) with\n   nothing written.  In this case, there may also be a buffer overflow with\n   unpredictable consequences, which is possible only if zlib was compiled with\n   the insecure functions sprintf() or vsprintf() because the secure snprintf()\n   or vsnprintf() functions were not available.  This can be determined using\n   zlibCompileFlags().\n*/\n\nZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s));\n/*\n     Writes the given null-terminated string to the compressed file, excluding\n   the terminating null character.\n\n     gzputs returns the number of characters written, or -1 in case of error.\n*/\n\nZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len));\n/*\n     Reads bytes from the compressed file until len-1 characters are read, or a\n   newline character is read and transferred to buf, or an end-of-file\n   condition is encountered.  If any characters are read or if len == 1, the\n   string is terminated with a null character.  If no characters are read due\n   to an end-of-file or len < 1, then the buffer is left untouched.\n\n     gzgets returns buf which is a null-terminated string, or it returns NULL\n   for end-of-file or in case of error.  If there was an error, the contents at\n   buf are indeterminate.\n*/\n\nZEXTERN int ZEXPORT gzputc OF((gzFile file, int c));\n/*\n     Writes c, converted to an unsigned char, into the compressed file.  gzputc\n   returns the value that was written, or -1 in case of error.\n*/\n\nZEXTERN int ZEXPORT gzgetc OF((gzFile file));\n/*\n     Reads one byte from the compressed file.  gzgetc returns this byte or -1\n   in case of end of file or error.\n*/\n\nZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file));\n/*\n     Push one character back onto the stream to be read as the first character\n   on the next read.  At least one character of push-back is allowed.\n   gzungetc() returns the character pushed, or -1 on failure.  gzungetc() will\n   fail if c is -1, and may fail if a character has been pushed but not read\n   yet.  If gzungetc is used immediately after gzopen or gzdopen, at least the\n   output buffer size of pushed characters is allowed.  (See gzbuffer above.)\n   The pushed character will be discarded if the stream is repositioned with\n   gzseek() or gzrewind().\n*/\n\nZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush));\n/*\n     Flushes all pending output into the compressed file.  The parameter flush\n   is as in the deflate() function.  The return value is the zlib error number\n   (see function gzerror below).  gzflush is only permitted when writing.\n\n     If the flush parameter is Z_FINISH, the remaining data is written and the\n   gzip stream is completed in the output.  If gzwrite() is called again, a new\n   gzip stream will be started in the output.  gzread() is able to read such\n   concatented gzip streams.\n\n     gzflush should be called only when strictly necessary because it will\n   degrade compression if called too often.\n*/\n\n/*\nZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file,\n                                   z_off_t offset, int whence));\n\n     Sets the starting position for the next gzread or gzwrite on the given\n   compressed file.  The offset represents a number of bytes in the\n   uncompressed data stream.  The whence parameter is defined as in lseek(2);\n   the value SEEK_END is not supported.\n\n     If the file is opened for reading, this function is emulated but can be\n   extremely slow.  If the file is opened for writing, only forward seeks are\n   supported; gzseek then compresses a sequence of zeroes up to the new\n   starting position.\n\n     gzseek returns the resulting offset location as measured in bytes from\n   the beginning of the uncompressed stream, or -1 in case of error, in\n   particular if the file is opened for writing and the new starting position\n   would be before the current position.\n*/\n\nZEXTERN int ZEXPORT    gzrewind OF((gzFile file));\n/*\n     Rewinds the given file. This function is supported only for reading.\n\n     gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET)\n*/\n\n/*\nZEXTERN z_off_t ZEXPORT    gztell OF((gzFile file));\n\n     Returns the starting position for the next gzread or gzwrite on the given\n   compressed file.  This position represents a number of bytes in the\n   uncompressed data stream, and is zero when starting, even if appending or\n   reading a gzip stream from the middle of a file using gzdopen().\n\n     gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR)\n*/\n\n/*\nZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile file));\n\n     Returns the current offset in the file being read or written.  This offset\n   includes the count of bytes that precede the gzip stream, for example when\n   appending or when using gzdopen() for reading.  When reading, the offset\n   does not include as yet unused buffered input.  This information can be used\n   for a progress indicator.  On error, gzoffset() returns -1.\n*/\n\nZEXTERN int ZEXPORT gzeof OF((gzFile file));\n/*\n     Returns true (1) if the end-of-file indicator has been set while reading,\n   false (0) otherwise.  Note that the end-of-file indicator is set only if the\n   read tried to go past the end of the input, but came up short.  Therefore,\n   just like feof(), gzeof() may return false even if there is no more data to\n   read, in the event that the last read request was for the exact number of\n   bytes remaining in the input file.  This will happen if the input file size\n   is an exact multiple of the buffer size.\n\n     If gzeof() returns true, then the read functions will return no more data,\n   unless the end-of-file indicator is reset by gzclearerr() and the input file\n   has grown since the previous end of file was detected.\n*/\n\nZEXTERN int ZEXPORT gzdirect OF((gzFile file));\n/*\n     Returns true (1) if file is being copied directly while reading, or false\n   (0) if file is a gzip stream being decompressed.  This state can change from\n   false to true while reading the input file if the end of a gzip stream is\n   reached, but is followed by data that is not another gzip stream.\n\n     If the input file is empty, gzdirect() will return true, since the input\n   does not contain a gzip stream.\n\n     If gzdirect() is used immediately after gzopen() or gzdopen() it will\n   cause buffers to be allocated to allow reading the file to determine if it\n   is a gzip file.  Therefore if gzbuffer() is used, it should be called before\n   gzdirect().\n*/\n\nZEXTERN int ZEXPORT    gzclose OF((gzFile file));\n/*\n     Flushes all pending output if necessary, closes the compressed file and\n   deallocates the (de)compression state.  Note that once file is closed, you\n   cannot call gzerror with file, since its structures have been deallocated.\n   gzclose must not be called more than once on the same file, just as free\n   must not be called more than once on the same allocation.\n\n     gzclose will return Z_STREAM_ERROR if file is not valid, Z_ERRNO on a\n   file operation error, or Z_OK on success.\n*/\n\nZEXTERN int ZEXPORT gzclose_r OF((gzFile file));\nZEXTERN int ZEXPORT gzclose_w OF((gzFile file));\n/*\n     Same as gzclose(), but gzclose_r() is only for use when reading, and\n   gzclose_w() is only for use when writing or appending.  The advantage to\n   using these instead of gzclose() is that they avoid linking in zlib\n   compression or decompression code that is not used when only reading or only\n   writing respectively.  If gzclose() is used, then both compression and\n   decompression code will be included the application when linking to a static\n   zlib library.\n*/\n\nZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum));\n/*\n     Returns the error message for the last error which occurred on the given\n   compressed file.  errnum is set to zlib error number.  If an error occurred\n   in the file system and not in the compression library, errnum is set to\n   Z_ERRNO and the application may consult errno to get the exact error code.\n\n     The application must not modify the returned string.  Future calls to\n   this function may invalidate the previously returned string.  If file is\n   closed, then the string previously returned by gzerror will no longer be\n   available.\n\n     gzerror() should be used to distinguish errors from end-of-file for those\n   functions above that do not distinguish those cases in their return values.\n*/\n\nZEXTERN void ZEXPORT gzclearerr OF((gzFile file));\n/*\n     Clears the error and end-of-file flags for file.  This is analogous to the\n   clearerr() function in stdio.  This is useful for continuing to read a gzip\n   file that is being written concurrently.\n*/\n\n\n                        /* checksum functions */\n\n/*\n     These functions are not related to compression but are exported\n   anyway because they might be useful in applications using the compression\n   library.\n*/\n\nZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len));\n/*\n     Update a running Adler-32 checksum with the bytes buf[0..len-1] and\n   return the updated checksum.  If buf is Z_NULL, this function returns the\n   required initial value for the checksum.\n\n     An Adler-32 checksum is almost as reliable as a CRC32 but can be computed\n   much faster.\n\n   Usage example:\n\n     uLong adler = adler32(0L, Z_NULL, 0);\n\n     while (read_buffer(buffer, length) != EOF) {\n       adler = adler32(adler, buffer, length);\n     }\n     if (adler != original_adler) error();\n*/\n\n/*\nZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2,\n                                          z_off_t len2));\n\n     Combine two Adler-32 checksums into one.  For two sequences of bytes, seq1\n   and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for\n   each, adler1 and adler2.  adler32_combine() returns the Adler-32 checksum of\n   seq1 and seq2 concatenated, requiring only adler1, adler2, and len2.\n*/\n\nZEXTERN uLong ZEXPORT crc32   OF((uLong crc, const Bytef *buf, uInt len));\n/*\n     Update a running CRC-32 with the bytes buf[0..len-1] and return the\n   updated CRC-32.  If buf is Z_NULL, this function returns the required\n   initial value for the for the crc.  Pre- and post-conditioning (one's\n   complement) is performed within this function so it shouldn't be done by the\n   application.\n\n   Usage example:\n\n     uLong crc = crc32(0L, Z_NULL, 0);\n\n     while (read_buffer(buffer, length) != EOF) {\n       crc = crc32(crc, buffer, length);\n     }\n     if (crc != original_crc) error();\n*/\n\n/*\nZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2));\n\n     Combine two CRC-32 check values into one.  For two sequences of bytes,\n   seq1 and seq2 with lengths len1 and len2, CRC-32 check values were\n   calculated for each, crc1 and crc2.  crc32_combine() returns the CRC-32\n   check value of seq1 and seq2 concatenated, requiring only crc1, crc2, and\n   len2.\n*/\n\n\n                        /* various hacks, don't look :) */\n\n/* deflateInit and inflateInit are macros to allow checking the zlib version\n * and the compiler's view of z_stream:\n */\nZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level,\n                                     const char *version, int stream_size));\nZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm,\n                                     const char *version, int stream_size));\nZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int  level, int  method,\n                                      int windowBits, int memLevel,\n                                      int strategy, const char *version,\n                                      int stream_size));\nZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int  windowBits,\n                                      const char *version, int stream_size));\nZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits,\n                                         unsigned char FAR *window,\n                                         const char *version,\n                                         int stream_size));\n#define deflateInit(strm, level) \\\n        deflateInit_((strm), (level),       ZLIB_VERSION, sizeof(z_stream))\n#define inflateInit(strm) \\\n        inflateInit_((strm),                ZLIB_VERSION, sizeof(z_stream))\n#define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \\\n        deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\\\n                      (strategy),           ZLIB_VERSION, sizeof(z_stream))\n#define inflateInit2(strm, windowBits) \\\n        inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream))\n#define inflateBackInit(strm, windowBits, window) \\\n        inflateBackInit_((strm), (windowBits), (window), \\\n                                            ZLIB_VERSION, sizeof(z_stream))\n\n/* provide 64-bit offset functions if _LARGEFILE64_SOURCE defined, and/or\n * change the regular functions to 64 bits if _FILE_OFFSET_BITS is 64 (if\n * both are true, the application gets the *64 functions, and the regular\n * functions are changed to 64 bits) -- in case these are set on systems\n * without large file support, _LFS64_LARGEFILE must also be true\n */\n#if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0\n   ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *));\n   ZEXTERN z_off64_t ZEXPORT gzseek64 OF((gzFile, z_off64_t, int));\n   ZEXTERN z_off64_t ZEXPORT gztell64 OF((gzFile));\n   ZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile));\n   ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off64_t));\n   ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off64_t));\n#endif\n\n#if !defined(ZLIB_INTERNAL) && _FILE_OFFSET_BITS-0 == 64 && _LFS64_LARGEFILE-0\n#  define gzopen gzopen64\n#  define gzseek gzseek64\n#  define gztell gztell64\n#  define gzoffset gzoffset64\n#  define adler32_combine adler32_combine64\n#  define crc32_combine crc32_combine64\n#  ifdef _LARGEFILE64_SOURCE\n     ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *));\n     ZEXTERN z_off_t ZEXPORT gzseek64 OF((gzFile, z_off_t, int));\n     ZEXTERN z_off_t ZEXPORT gztell64 OF((gzFile));\n     ZEXTERN z_off_t ZEXPORT gzoffset64 OF((gzFile));\n     ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t));\n     ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t));\n#  endif\n#else\n   ZEXTERN gzFile ZEXPORT gzopen OF((const char *, const char *));\n   ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile, z_off_t, int));\n   ZEXTERN z_off_t ZEXPORT gztell OF((gzFile));\n   ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile));\n   ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t));\n   ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t));\n#endif\n\n/* hack for buggy compilers */\n#if !defined(ZUTIL_H) && !defined(NO_DUMMY_DECL)\n    struct internal_state {int dummy;};\n#endif\n\n/* undocumented functions */\nZEXTERN const char   * ZEXPORT zError           OF((int));\nZEXTERN int            ZEXPORT inflateSyncPoint OF((z_streamp));\nZEXTERN const uLongf * ZEXPORT get_crc_table    OF((void));\nZEXTERN int            ZEXPORT inflateUndermine OF((z_streamp, int));\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* ZLIB_H */\n"
  },
  {
    "path": "Projects/Libraries/CSBase/PlatformSource/iOS/Reachability/CSReachability.h",
    "content": "/*\n     File: Reachability.h\n Abstract: Basic demonstration of how to use the SystemConfiguration Reachablity APIs.\n  Version: 3.5\n \n Disclaimer: IMPORTANT:  This Apple software is supplied to you by Apple\n Inc. (\"Apple\") in consideration of your agreement to the following\n terms, and your use, installation, modification or redistribution of\n this Apple software constitutes acceptance of these terms.  If you do\n not agree with these terms, please do not use, install, modify or\n redistribute this Apple software.\n \n In consideration of your agreement to abide by the following terms, and\n subject to these terms, Apple grants you a personal, non-exclusive\n license, under Apple's copyrights in this original Apple software (the\n \"Apple Software\"), to use, reproduce, modify and redistribute the Apple\n Software, with or without modifications, in source and/or binary forms;\n provided that if you redistribute the Apple Software in its entirety and\n without modifications, you must retain this notice and the following\n text and disclaimers in all such redistributions of the Apple Software.\n Neither the name, trademarks, service marks or logos of Apple Inc. may\n be used to endorse or promote products derived from the Apple Software\n without specific prior written permission from Apple.  Except as\n expressly stated in this notice, no other rights or licenses, express or\n implied, are granted by Apple herein, including but not limited to any\n patent rights that may be infringed by your derivative works or by other\n works in which the Apple Software may be incorporated.\n \n The Apple Software is provided by Apple on an \"AS IS\" basis.  APPLE\n MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION\n THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS\n FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND\n OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.\n \n IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL\n OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\n INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION,\n MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED\n AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),\n STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE\n POSSIBILITY OF SUCH DAMAGE.\n \n Copyright (C) 2014 Apple Inc. All Rights Reserved.\n \n */\n\n#import <Foundation/Foundation.h>\n#import <SystemConfiguration/SystemConfiguration.h>\n#import <netinet/in.h>\n\n\ntypedef enum : NSInteger {\n\tNotReachable = 0,\n\tReachableViaWiFi,\n\tReachableViaWWAN\n} NetworkStatus;\n\n\nextern NSString *kReachabilityChangedNotification;\n\n\n@interface CSReachability : NSObject\n\n/*!\n * Use to check the reachability of a given host name.\n */\n+ (instancetype)reachabilityWithHostName:(NSString *)hostName;\n\n/*!\n * Use to check the reachability of a given IP address.\n */\n+ (instancetype)reachabilityWithAddress:(const struct sockaddr_in *)hostAddress;\n\n/*!\n * Checks whether the default route is available. Should be used by applications that do not connect to a particular host.\n */\n+ (instancetype)reachabilityForInternetConnection;\n\n/*!\n * Checks whether a local WiFi connection is available.\n */\n+ (instancetype)reachabilityForLocalWiFi;\n\n/*!\n * Start listening for reachability notifications on the current run loop.\n */\n- (BOOL)startNotifier;\n- (void)stopNotifier;\n\n- (NetworkStatus)currentReachabilityStatus;\n\n/*!\n * WWAN may be available, but not active until a connection has been established. WiFi may require a connection for VPN on Demand.\n */\n- (BOOL)connectionRequired;\n\n@end\n\n\n"
  },
  {
    "path": "Projects/Libraries/CSBase/PlatformSource/iOS/Reachability/CSReachability.m",
    "content": "/*\n     File: Reachability.m\n Abstract: Basic demonstration of how to use the SystemConfiguration Reachablity APIs.\n  Version: 3.5\n \n Disclaimer: IMPORTANT:  This Apple software is supplied to you by Apple\n Inc. (\"Apple\") in consideration of your agreement to the following\n terms, and your use, installation, modification or redistribution of\n this Apple software constitutes acceptance of these terms.  If you do\n not agree with these terms, please do not use, install, modify or\n redistribute this Apple software.\n \n In consideration of your agreement to abide by the following terms, and\n subject to these terms, Apple grants you a personal, non-exclusive\n license, under Apple's copyrights in this original Apple software (the\n \"Apple Software\"), to use, reproduce, modify and redistribute the Apple\n Software, with or without modifications, in source and/or binary forms;\n provided that if you redistribute the Apple Software in its entirety and\n without modifications, you must retain this notice and the following\n text and disclaimers in all such redistributions of the Apple Software.\n Neither the name, trademarks, service marks or logos of Apple Inc. may\n be used to endorse or promote products derived from the Apple Software\n without specific prior written permission from Apple.  Except as\n expressly stated in this notice, no other rights or licenses, express or\n implied, are granted by Apple herein, including but not limited to any\n patent rights that may be infringed by your derivative works or by other\n works in which the Apple Software may be incorporated.\n \n The Apple Software is provided by Apple on an \"AS IS\" basis.  APPLE\n MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION\n THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS\n FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND\n OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.\n \n IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL\n OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\n INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION,\n MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED\n AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),\n STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE\n POSSIBILITY OF SUCH DAMAGE.\n \n Copyright (C) 2014 Apple Inc. All Rights Reserved.\n \n */\n\n#import <arpa/inet.h>\n#import <ifaddrs.h>\n#import <netdb.h>\n#import <sys/socket.h>\n\n#import <CoreFoundation/CoreFoundation.h>\n\n#import \"CSReachability.h\"\n\n\nNSString *kReachabilityChangedNotification = @\"kNetworkReachabilityChangedNotification\";\n\n\n#pragma mark - Supporting functions\n\n#define kShouldPrintReachabilityFlags 1\n\nstatic void PrintReachabilityFlags(SCNetworkReachabilityFlags flags, const char* comment)\n{\n#if kShouldPrintReachabilityFlags\n\n    NSLog(@\"Reachability Flag Status: %c%c %c%c%c%c%c%c%c %s\\n\",\n          (flags & kSCNetworkReachabilityFlagsIsWWAN)\t\t\t\t? 'W' : '-',\n          (flags & kSCNetworkReachabilityFlagsReachable)            ? 'R' : '-',\n\n          (flags & kSCNetworkReachabilityFlagsTransientConnection)  ? 't' : '-',\n          (flags & kSCNetworkReachabilityFlagsConnectionRequired)   ? 'c' : '-',\n          (flags & kSCNetworkReachabilityFlagsConnectionOnTraffic)  ? 'C' : '-',\n          (flags & kSCNetworkReachabilityFlagsInterventionRequired) ? 'i' : '-',\n          (flags & kSCNetworkReachabilityFlagsConnectionOnDemand)   ? 'D' : '-',\n          (flags & kSCNetworkReachabilityFlagsIsLocalAddress)       ? 'l' : '-',\n          (flags & kSCNetworkReachabilityFlagsIsDirect)             ? 'd' : '-',\n          comment\n          );\n#endif\n}\n\n\nstatic void ReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkReachabilityFlags flags, void* info)\n{\n#pragma unused (target, flags)\n\tNSCAssert(info != NULL, @\"info was NULL in ReachabilityCallback\");\n\tNSCAssert([(__bridge NSObject*) info isKindOfClass: [CSReachability class]], @\"info was wrong class in ReachabilityCallback\");\n\n    CSReachability* noteObject = (__bridge CSReachability *)info;\n    // Post a notification to notify the client that the network reachability changed.\n    [[NSNotificationCenter defaultCenter] postNotificationName: kReachabilityChangedNotification object: noteObject];\n}\n\n\n#pragma mark - Reachability implementation\n\n@implementation CSReachability\n{\n\tBOOL _alwaysReturnLocalWiFiStatus; //default is NO\n\tSCNetworkReachabilityRef _reachabilityRef;\n}\n\n+ (instancetype)reachabilityWithHostName:(NSString *)hostName\n{\n\tCSReachability* returnValue = NULL;\n\tSCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithName(NULL, [hostName UTF8String]);\n\tif (reachability != NULL)\n\t{\n\t\treturnValue= [[self alloc] init];\n\t\tif (returnValue != NULL)\n\t\t{\n\t\t\treturnValue->_reachabilityRef = reachability;\n\t\t\treturnValue->_alwaysReturnLocalWiFiStatus = NO;\n\t\t}\n\t}\n\treturn returnValue;\n}\n\n\n+ (instancetype)reachabilityWithAddress:(const struct sockaddr_in *)hostAddress\n{\n\tSCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithAddress(kCFAllocatorDefault, (const struct sockaddr *)hostAddress);\n\n\tCSReachability* returnValue = NULL;\n\n\tif (reachability != NULL)\n\t{\n\t\treturnValue = [[self alloc] init];\n\t\tif (returnValue != NULL)\n\t\t{\n\t\t\treturnValue->_reachabilityRef = reachability;\n\t\t\treturnValue->_alwaysReturnLocalWiFiStatus = NO;\n\t\t}\n\t}\n\treturn returnValue;\n}\n\n\n\n+ (instancetype)reachabilityForInternetConnection\n{\n\tstruct sockaddr_in zeroAddress;\n\tbzero(&zeroAddress, sizeof(zeroAddress));\n\tzeroAddress.sin_len = sizeof(zeroAddress);\n\tzeroAddress.sin_family = AF_INET;\n    \n\treturn [self reachabilityWithAddress:&zeroAddress];\n}\n\n\n+ (instancetype)reachabilityForLocalWiFi\n{\n\tstruct sockaddr_in localWifiAddress;\n\tbzero(&localWifiAddress, sizeof(localWifiAddress));\n\tlocalWifiAddress.sin_len = sizeof(localWifiAddress);\n\tlocalWifiAddress.sin_family = AF_INET;\n\n\t// IN_LINKLOCALNETNUM is defined in <netinet/in.h> as 169.254.0.0.\n\tlocalWifiAddress.sin_addr.s_addr = htonl(IN_LINKLOCALNETNUM);\n\n\tCSReachability* returnValue = [self reachabilityWithAddress: &localWifiAddress];\n\tif (returnValue != NULL)\n\t{\n\t\treturnValue->_alwaysReturnLocalWiFiStatus = YES;\n\t}\n    \n\treturn returnValue;\n}\n\n\n#pragma mark - Start and stop notifier\n\n- (BOOL)startNotifier\n{\n\tBOOL returnValue = NO;\n\tSCNetworkReachabilityContext context = {0, (__bridge void *)(self), NULL, NULL, NULL};\n\n\tif (SCNetworkReachabilitySetCallback(_reachabilityRef, ReachabilityCallback, &context))\n\t{\n\t\tif (SCNetworkReachabilityScheduleWithRunLoop(_reachabilityRef, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode))\n\t\t{\n\t\t\treturnValue = YES;\n\t\t}\n\t}\n    \n\treturn returnValue;\n}\n\n\n- (void)stopNotifier\n{\n\tif (_reachabilityRef != NULL)\n\t{\n\t\tSCNetworkReachabilityUnscheduleFromRunLoop(_reachabilityRef, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);\n\t}\n}\n\n\n- (void)dealloc\n{\n\t[self stopNotifier];\n\tif (_reachabilityRef != NULL)\n\t{\n\t\tCFRelease(_reachabilityRef);\n\t}\n}\n\n\n#pragma mark - Network Flag Handling\n\n- (NetworkStatus)localWiFiStatusForFlags:(SCNetworkReachabilityFlags)flags\n{\n\tPrintReachabilityFlags(flags, \"localWiFiStatusForFlags\");\n\tNetworkStatus returnValue = NotReachable;\n\n\tif ((flags & kSCNetworkReachabilityFlagsReachable) && (flags & kSCNetworkReachabilityFlagsIsDirect))\n\t{\n\t\treturnValue = ReachableViaWiFi;\n\t}\n    \n\treturn returnValue;\n}\n\n\n- (NetworkStatus)networkStatusForFlags:(SCNetworkReachabilityFlags)flags\n{\n\tPrintReachabilityFlags(flags, \"networkStatusForFlags\");\n\tif ((flags & kSCNetworkReachabilityFlagsReachable) == 0)\n\t{\n\t\t// The target host is not reachable.\n\t\treturn NotReachable;\n\t}\n\n    NetworkStatus returnValue = NotReachable;\n\n\tif ((flags & kSCNetworkReachabilityFlagsConnectionRequired) == 0)\n\t{\n\t\t/*\n         If the target host is reachable and no connection is required then we'll assume (for now) that you're on Wi-Fi...\n         */\n\t\treturnValue = ReachableViaWiFi;\n\t}\n\n\tif ((((flags & kSCNetworkReachabilityFlagsConnectionOnDemand ) != 0) ||\n        (flags & kSCNetworkReachabilityFlagsConnectionOnTraffic) != 0))\n\t{\n        /*\n         ... and the connection is on-demand (or on-traffic) if the calling application is using the CFSocketStream or higher APIs...\n         */\n\n        if ((flags & kSCNetworkReachabilityFlagsInterventionRequired) == 0)\n        {\n            /*\n             ... and no [user] intervention is needed...\n             */\n            returnValue = ReachableViaWiFi;\n        }\n    }\n\n\tif ((flags & kSCNetworkReachabilityFlagsIsWWAN) == kSCNetworkReachabilityFlagsIsWWAN)\n\t{\n\t\t/*\n         ... but WWAN connections are OK if the calling application is using the CFNetwork APIs.\n         */\n\t\treturnValue = ReachableViaWWAN;\n\t}\n    \n\treturn returnValue;\n}\n\n\n- (BOOL)connectionRequired\n{\n\tNSAssert(_reachabilityRef != NULL, @\"connectionRequired called with NULL reachabilityRef\");\n\tSCNetworkReachabilityFlags flags;\n\n\tif (SCNetworkReachabilityGetFlags(_reachabilityRef, &flags))\n\t{\n\t\treturn (flags & kSCNetworkReachabilityFlagsConnectionRequired);\n\t}\n\n    return NO;\n}\n\n\n- (NetworkStatus)currentReachabilityStatus\n{\n\tNSAssert(_reachabilityRef != NULL, @\"currentNetworkStatus called with NULL SCNetworkReachabilityRef\");\n\tNetworkStatus returnValue = NotReachable;\n\tSCNetworkReachabilityFlags flags;\n    \n\tif (SCNetworkReachabilityGetFlags(_reachabilityRef, &flags))\n\t{\n\t\tif (_alwaysReturnLocalWiFiStatus)\n\t\t{\n\t\t\treturnValue = [self localWiFiStatusForFlags:flags];\n\t\t}\n\t\telse\n\t\t{\n\t\t\treturnValue = [self networkStatusForFlags:flags];\n\t\t}\n\t}\n    \n\treturn returnValue;\n}\n\n\n@end\n"
  },
  {
    "path": "Projects/Libraries/CSBase/Source/SHA1/HMAC_SHA1.cpp",
    "content": "//******************************************************************************\r\n//* HMAC_SHA1.cpp : Implementation of HMAC SHA1 algorithm\r\n//*                 Comfort to RFC 2104\r\n//*\r\n//******************************************************************************\r\n#include <iostream>\r\n#include <memory>\r\n#include \"HMAC_SHA1.h\"\r\n\r\n\r\nvoid CHMAC_SHA1::HMAC_SHA1(BYTE *text, int text_len, BYTE *key, int key_len, BYTE *digest)\r\n{\r\n\tmemset(SHA1_Key, 0, SHA1_BLOCK_SIZE);\r\n\r\n\t/* repeated 64 times for values in ipad and opad */\r\n\tmemset(m_ipad, 0x36, sizeof(m_ipad));\r\n\tmemset(m_opad, 0x5c, sizeof(m_opad));\r\n\r\n\t/* STEP 1 */\r\n\tif (key_len > SHA1_BLOCK_SIZE)\r\n\t{\r\n\t\tCSHA1::Reset();\r\n\t\tCSHA1::Update((UINT_8 *)key, key_len);\r\n\t\tCSHA1::Final();\r\n\r\n\t\tCSHA1::GetHash((UINT_8 *)SHA1_Key);\r\n\t}\r\n\telse\r\n\t\tmemcpy(SHA1_Key, key, key_len);\r\n\r\n\t/* STEP 2 */\r\n\tfor (int i=0; i<sizeof(m_ipad); i++)\r\n\t{\r\n\t\tm_ipad[i] ^= SHA1_Key[i];\t\t\r\n\t}\r\n\r\n\t/* STEP 3 */\r\n\tmemcpy(AppendBuf1, m_ipad, sizeof(m_ipad));\r\n\tmemcpy(AppendBuf1 + sizeof(m_ipad), text, text_len);\r\n\r\n\t/* STEP 4 */\r\n\tCSHA1::Reset();\r\n\tCSHA1::Update((UINT_8 *)AppendBuf1, sizeof(m_ipad) + text_len);\r\n\tCSHA1::Final();\r\n\r\n\tCSHA1::GetHash((UINT_8 *)szReport);\r\n\r\n\t/* STEP 5 */\r\n\tfor (int j=0; j<sizeof(m_opad); j++)\r\n\t{\r\n\t\tm_opad[j] ^= SHA1_Key[j];\r\n\t}\r\n\r\n\t/* STEP 6 */\r\n\tmemcpy(AppendBuf2, m_opad, sizeof(m_opad));\r\n\tmemcpy(AppendBuf2 + sizeof(m_opad), szReport, SHA1_DIGEST_LENGTH);\r\n\r\n\t/*STEP 7 */\r\n\tCSHA1::Reset();\r\n\tCSHA1::Update((UINT_8 *)AppendBuf2, sizeof(m_opad) + SHA1_DIGEST_LENGTH);\r\n\tCSHA1::Final();\r\n\r\n\tCSHA1::GetHash((UINT_8 *)digest);\r\n}\r\n"
  },
  {
    "path": "Projects/Libraries/CSBase/Source/SHA1/HMAC_SHA1.h",
    "content": "/*\r\n\t100% free public domain implementation of the HMAC-SHA1 algorithm\r\n\tby Chien-Chung, Chung (Jim Chung) <jimchung1221@gmail.com>\r\n*/\r\n\r\n\r\n#ifndef __HMAC_SHA1_H__\r\n#define __HMAC_SHA1_H__\r\n\r\n#include \"SHA1.h\"\r\n\r\ntypedef unsigned char BYTE ;\r\n\r\nclass CHMAC_SHA1 : public CSHA1\r\n{\r\n    private:\r\n\t\tBYTE m_ipad[64];\r\n        BYTE m_opad[64];\r\n\r\n\t\tchar * szReport ;\r\n\t\tchar * SHA1_Key ;\r\n\t\tchar * AppendBuf1 ;\r\n\t\tchar * AppendBuf2 ;\r\n\r\n\r\n\tpublic:\r\n\t\t\r\n\t\tenum {\r\n\t\t\tSHA1_DIGEST_LENGTH\t= 20,\r\n\t\t\tSHA1_BLOCK_SIZE\t\t= 64,\r\n\t\t\tHMAC_BUF_LEN\t\t= 4096\r\n\t\t} ;\r\n\r\n\t\tCHMAC_SHA1()\r\n\t\t\t:szReport(new char[HMAC_BUF_LEN]),\r\n             AppendBuf1(new char[HMAC_BUF_LEN]),\r\n             AppendBuf2(new char[HMAC_BUF_LEN]),\r\n             SHA1_Key(new char[HMAC_BUF_LEN])\r\n\t\t{}\r\n\r\n        ~CHMAC_SHA1()\r\n        {\r\n            delete[] szReport ;\r\n            delete[] AppendBuf1 ;\r\n            delete[] AppendBuf2 ;\r\n            delete[] SHA1_Key ;\r\n        }\r\n\r\n        void HMAC_SHA1(BYTE *text, int text_len, BYTE *key, int key_len, BYTE *digest);\r\n};\r\n\r\n\r\n#endif /* __HMAC_SHA1_H__ */\r\n"
  },
  {
    "path": "Projects/Libraries/CSBase/Source/SHA1/SHA1.cpp",
    "content": "/*\r\n  100% free public domain implementation of the SHA-1 algorithm\r\n  by Dominik Reichl <dominik.reichl@t-online.de>\r\n  Web: http://www.dominik-reichl.de/\r\n\r\n  See header file for version history and test vectors.\r\n*/\r\n\r\n// If compiling with MFC, you might want to add #include \"StdAfx.h\"\r\n\r\n#define _CRT_SECURE_NO_WARNINGS\r\n#include \"SHA1.h\"\r\n\r\n#define SHA1_MAX_FILE_BUFFER (32 * 20 * 820)\r\n\r\n// Rotate p_val32 by p_nBits bits to the left\r\n#ifndef ROL32\r\n#ifdef _MSC_VER\r\n#define ROL32(p_val32,p_nBits) _rotl(p_val32,p_nBits)\r\n#else\r\n#define ROL32(p_val32,p_nBits) (((p_val32)<<(p_nBits))|((p_val32)>>(32-(p_nBits))))\r\n#endif\r\n#endif\r\n\r\n#ifdef SHA1_LITTLE_ENDIAN\r\n#define SHABLK0(i) (m_block->l[i] = \\\r\n\t(ROL32(m_block->l[i],24) & 0xFF00FF00) | (ROL32(m_block->l[i],8) & 0x00FF00FF))\r\n#else\r\n#define SHABLK0(i) (m_block->l[i])\r\n#endif\r\n\r\n#define SHABLK(i) (m_block->l[i&15] = ROL32(m_block->l[(i+13)&15] ^ \\\r\n\tm_block->l[(i+8)&15] ^ m_block->l[(i+2)&15] ^ m_block->l[i&15],1))\r\n\r\n// SHA-1 rounds\r\n#define S_R0(v,w,x,y,z,i) {z+=((w&(x^y))^y)+SHABLK0(i)+0x5A827999+ROL32(v,5);w=ROL32(w,30);}\r\n#define S_R1(v,w,x,y,z,i) {z+=((w&(x^y))^y)+SHABLK(i)+0x5A827999+ROL32(v,5);w=ROL32(w,30);}\r\n#define S_R2(v,w,x,y,z,i) {z+=(w^x^y)+SHABLK(i)+0x6ED9EBA1+ROL32(v,5);w=ROL32(w,30);}\r\n#define S_R3(v,w,x,y,z,i) {z+=(((w|x)&y)|(w&x))+SHABLK(i)+0x8F1BBCDC+ROL32(v,5);w=ROL32(w,30);}\r\n#define S_R4(v,w,x,y,z,i) {z+=(w^x^y)+SHABLK(i)+0xCA62C1D6+ROL32(v,5);w=ROL32(w,30);}\r\n\r\n#pragma warning(push)\r\n// Disable compiler warning 'Conditional expression is constant'\r\n#pragma warning(disable: 4127)\r\n\r\nCSHA1::CSHA1()\r\n{\r\n\tm_block = (SHA1_WORKSPACE_BLOCK*)m_workspace;\r\n\r\n\tReset();\r\n}\r\n\r\n#ifdef SHA1_WIPE_VARIABLES\r\nCSHA1::~CSHA1()\r\n{\r\n\tReset();\r\n}\r\n#endif\r\n\r\nvoid CSHA1::Reset()\r\n{\r\n\t// SHA1 initialization constants\r\n\tm_state[0] = 0x67452301;\r\n\tm_state[1] = 0xEFCDAB89;\r\n\tm_state[2] = 0x98BADCFE;\r\n\tm_state[3] = 0x10325476;\r\n\tm_state[4] = 0xC3D2E1F0;\r\n\r\n\tm_count[0] = 0;\r\n\tm_count[1] = 0;\r\n}\r\n\r\nvoid CSHA1::Transform(UINT_32* pState, const UINT_8* pBuffer)\r\n{\r\n\tUINT_32 a = pState[0], b = pState[1], c = pState[2], d = pState[3], e = pState[4];\r\n\r\n\tmemcpy(m_block, pBuffer, 64);\r\n\r\n\t// 4 rounds of 20 operations each, loop unrolled\r\n\tS_R0(a,b,c,d,e, 0); S_R0(e,a,b,c,d, 1); S_R0(d,e,a,b,c, 2); S_R0(c,d,e,a,b, 3);\r\n\tS_R0(b,c,d,e,a, 4); S_R0(a,b,c,d,e, 5); S_R0(e,a,b,c,d, 6); S_R0(d,e,a,b,c, 7);\r\n\tS_R0(c,d,e,a,b, 8); S_R0(b,c,d,e,a, 9); S_R0(a,b,c,d,e,10); S_R0(e,a,b,c,d,11);\r\n\tS_R0(d,e,a,b,c,12); S_R0(c,d,e,a,b,13); S_R0(b,c,d,e,a,14); S_R0(a,b,c,d,e,15);\r\n\tS_R1(e,a,b,c,d,16); S_R1(d,e,a,b,c,17); S_R1(c,d,e,a,b,18); S_R1(b,c,d,e,a,19);\r\n\tS_R2(a,b,c,d,e,20); S_R2(e,a,b,c,d,21); S_R2(d,e,a,b,c,22); S_R2(c,d,e,a,b,23);\r\n\tS_R2(b,c,d,e,a,24); S_R2(a,b,c,d,e,25); S_R2(e,a,b,c,d,26); S_R2(d,e,a,b,c,27);\r\n\tS_R2(c,d,e,a,b,28); S_R2(b,c,d,e,a,29); S_R2(a,b,c,d,e,30); S_R2(e,a,b,c,d,31);\r\n\tS_R2(d,e,a,b,c,32); S_R2(c,d,e,a,b,33); S_R2(b,c,d,e,a,34); S_R2(a,b,c,d,e,35);\r\n\tS_R2(e,a,b,c,d,36); S_R2(d,e,a,b,c,37); S_R2(c,d,e,a,b,38); S_R2(b,c,d,e,a,39);\r\n\tS_R3(a,b,c,d,e,40); S_R3(e,a,b,c,d,41); S_R3(d,e,a,b,c,42); S_R3(c,d,e,a,b,43);\r\n\tS_R3(b,c,d,e,a,44); S_R3(a,b,c,d,e,45); S_R3(e,a,b,c,d,46); S_R3(d,e,a,b,c,47);\r\n\tS_R3(c,d,e,a,b,48); S_R3(b,c,d,e,a,49); S_R3(a,b,c,d,e,50); S_R3(e,a,b,c,d,51);\r\n\tS_R3(d,e,a,b,c,52); S_R3(c,d,e,a,b,53); S_R3(b,c,d,e,a,54); S_R3(a,b,c,d,e,55);\r\n\tS_R3(e,a,b,c,d,56); S_R3(d,e,a,b,c,57); S_R3(c,d,e,a,b,58); S_R3(b,c,d,e,a,59);\r\n\tS_R4(a,b,c,d,e,60); S_R4(e,a,b,c,d,61); S_R4(d,e,a,b,c,62); S_R4(c,d,e,a,b,63);\r\n\tS_R4(b,c,d,e,a,64); S_R4(a,b,c,d,e,65); S_R4(e,a,b,c,d,66); S_R4(d,e,a,b,c,67);\r\n\tS_R4(c,d,e,a,b,68); S_R4(b,c,d,e,a,69); S_R4(a,b,c,d,e,70); S_R4(e,a,b,c,d,71);\r\n\tS_R4(d,e,a,b,c,72); S_R4(c,d,e,a,b,73); S_R4(b,c,d,e,a,74); S_R4(a,b,c,d,e,75);\r\n\tS_R4(e,a,b,c,d,76); S_R4(d,e,a,b,c,77); S_R4(c,d,e,a,b,78); S_R4(b,c,d,e,a,79);\r\n\r\n\t// Add the working vars back into state\r\n\tpState[0] += a;\r\n\tpState[1] += b;\r\n\tpState[2] += c;\r\n\tpState[3] += d;\r\n\tpState[4] += e;\r\n\r\n\t// Wipe variables\r\n#ifdef SHA1_WIPE_VARIABLES\r\n\ta = b = c = d = e = 0;\r\n#endif\r\n}\r\n\r\nvoid CSHA1::Update(const UINT_8* pbData, UINT_32 uLen)\r\n{\r\n\tUINT_32 j = ((m_count[0] >> 3) & 0x3F);\r\n\r\n\tif((m_count[0] += (uLen << 3)) < (uLen << 3))\r\n\t\t++m_count[1]; // Overflow\r\n\r\n\tm_count[1] += (uLen >> 29);\r\n\r\n\tUINT_32 i;\r\n\tif((j + uLen) > 63)\r\n\t{\r\n\t\ti = 64 - j;\r\n\t\tmemcpy(&m_buffer[j], pbData, i);\r\n\t\tTransform(m_state, m_buffer);\r\n\r\n\t\tfor( ; (i + 63) < uLen; i += 64)\r\n\t\t\tTransform(m_state, &pbData[i]);\r\n\r\n\t\tj = 0;\r\n\t}\r\n\telse i = 0;\r\n\r\n\tif((uLen - i) != 0)\r\n\t\tmemcpy(&m_buffer[j], &pbData[i], uLen - i);\r\n}\r\n\r\n#ifdef SHA1_UTILITY_FUNCTIONS\r\nbool CSHA1::HashFile(const TCHAR* tszFileName)\r\n{\r\n\tif(tszFileName == NULL) return false;\r\n\r\n\tFILE* fpIn = _tfopen(tszFileName, _T(\"rb\"));\r\n\tif(fpIn == NULL) return false;\r\n\r\n\tUINT_8* pbData = new UINT_8[SHA1_MAX_FILE_BUFFER];\r\n\tif(pbData == NULL) { fclose(fpIn); return false; }\r\n\r\n\tbool bSuccess = true;\r\n\twhile(true)\r\n\t{\r\n\t\tconst size_t uRead = fread(pbData, 1, SHA1_MAX_FILE_BUFFER, fpIn);\r\n\r\n\t\tif(uRead > 0)\r\n\t\t\tUpdate(pbData, static_cast<UINT_32>(uRead));\r\n\r\n\t\tif(uRead < SHA1_MAX_FILE_BUFFER)\r\n\t\t{\r\n\t\t\tif(feof(fpIn) == 0) bSuccess = false;\r\n\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\r\n\tfclose(fpIn);\r\n\tdelete[] pbData;\r\n\treturn bSuccess;\r\n}\r\n#endif\r\n\r\nvoid CSHA1::Final()\r\n{\r\n\tUINT_32 i;\r\n\r\n\tUINT_8 pbFinalCount[8];\r\n\tfor(i = 0; i < 8; ++i)\r\n\t\tpbFinalCount[i] = static_cast<UINT_8>((m_count[((i >= 4) ? 0 : 1)] >>\r\n\t\t\t((3 - (i & 3)) * 8) ) & 0xFF); // Endian independent\r\n\r\n\tUpdate((UINT_8*)\"\\200\", 1);\r\n\r\n\twhile((m_count[0] & 504) != 448)\r\n\t\tUpdate((UINT_8*)\"\\0\", 1);\r\n\r\n\tUpdate(pbFinalCount, 8); // Cause a Transform()\r\n\r\n\tfor(i = 0; i < 20; ++i)\r\n\t\tm_digest[i] = static_cast<UINT_8>((m_state[i >> 2] >> ((3 -\r\n\t\t\t(i & 3)) * 8)) & 0xFF);\r\n\r\n\t// Wipe variables for security reasons\r\n#ifdef SHA1_WIPE_VARIABLES\r\n\tmemset(m_buffer, 0, 64);\r\n\tmemset(m_state, 0, 20);\r\n\tmemset(m_count, 0, 8);\r\n\tmemset(pbFinalCount, 0, 8);\r\n\tTransform(m_state, m_buffer);\r\n#endif\r\n}\r\n\r\n#ifdef SHA1_UTILITY_FUNCTIONS\r\nbool CSHA1::ReportHash(TCHAR* tszReport, REPORT_TYPE rtReportType) const\r\n{\r\n\tif(tszReport == NULL) return false;\r\n\r\n\tTCHAR tszTemp[16];\r\n\r\n\tif((rtReportType == REPORT_HEX) || (rtReportType == REPORT_HEX_SHORT))\r\n\t{\r\n\t\t_sntprintf(tszTemp, 15, _T(\"%02X\"), m_digest[0]);\r\n\t\t_tcscpy(tszReport, tszTemp);\r\n\r\n\t\tconst TCHAR* lpFmt = ((rtReportType == REPORT_HEX) ? _T(\" %02X\") : _T(\"%02X\"));\r\n\t\tfor(size_t i = 1; i < 20; ++i)\r\n\t\t{\r\n\t\t\t_sntprintf(tszTemp, 15, lpFmt, m_digest[i]);\r\n\t\t\t_tcscat(tszReport, tszTemp);\r\n\t\t}\r\n\t}\r\n\telse if(rtReportType == REPORT_DIGIT)\r\n\t{\r\n\t\t_sntprintf(tszTemp, 15, _T(\"%u\"), m_digest[0]);\r\n\t\t_tcscpy(tszReport, tszTemp);\r\n\r\n\t\tfor(size_t i = 1; i < 20; ++i)\r\n\t\t{\r\n\t\t\t_sntprintf(tszTemp, 15, _T(\" %u\"), m_digest[i]);\r\n\t\t\t_tcscat(tszReport, tszTemp);\r\n\t\t}\r\n\t}\r\n\telse return false;\r\n\r\n\treturn true;\r\n}\r\n#endif\r\n\r\n#ifdef SHA1_STL_FUNCTIONS\r\nbool CSHA1::ReportHashStl(std::basic_string<TCHAR>& strOut, REPORT_TYPE rtReportType) const\r\n{\r\n\tTCHAR tszOut[84];\r\n\tconst bool bResult = ReportHash(tszOut, rtReportType);\r\n\tif(bResult) strOut = tszOut;\r\n\treturn bResult;\r\n}\r\n#endif\r\n\r\nbool CSHA1::GetHash(UINT_8* pbDest20) const\r\n{\r\n\tif(pbDest20 == NULL) return false;\r\n\tmemcpy(pbDest20, m_digest, 20);\r\n\treturn true;\r\n}\r\n\r\n#pragma warning(pop)\r\n"
  },
  {
    "path": "Projects/Libraries/CSBase/Source/SHA1/SHA1.h",
    "content": "/*\r\n  100% free public domain implementation of the SHA-1 algorithm\r\n  by Dominik Reichl <dominik.reichl@t-online.de>\r\n  Web: http://www.dominik-reichl.de/\r\n\r\n  Version 2.1 - 2012-06-19\r\n  - Deconstructor (resetting internal variables) is now only\r\n    implemented if SHA1_WIPE_VARIABLES is defined (which is the\r\n    default).\r\n  - Renamed inclusion guard to contain a GUID.\r\n  - Demo application is now using C++/STL objects and functions.\r\n  - Unicode build of the demo application now outputs the hashes of both\r\n    the ANSI and Unicode representations of strings.\r\n  - Various other demo application improvements.\r\n\r\n  Version 2.0 - 2012-06-14\r\n  - Added 'limits.h' include.\r\n  - Renamed inclusion guard and macros for compliancy (names beginning\r\n    with an underscore are reserved).\r\n\r\n  Version 1.9 - 2011-11-10\r\n  - Added Unicode test vectors.\r\n  - Improved support for hashing files using the HashFile method that\r\n    are larger than 4 GB.\r\n  - Improved file hashing performance (by using a larger buffer).\r\n  - Disabled unnecessary compiler warnings.\r\n  - Internal variables are now private.\r\n\r\n  Version 1.8 - 2009-03-16\r\n  - Converted project files to Visual Studio 2008 format.\r\n  - Added Unicode support for HashFile utility method.\r\n  - Added support for hashing files using the HashFile method that are\r\n    larger than 2 GB.\r\n  - HashFile now returns an error code instead of copying an error\r\n    message into the output buffer.\r\n  - GetHash now returns an error code and validates the input parameter.\r\n  - Added ReportHashStl STL utility method.\r\n  - Added REPORT_HEX_SHORT reporting mode.\r\n  - Improved Linux compatibility of test program.\r\n\r\n  Version 1.7 - 2006-12-21\r\n  - Fixed buffer underrun warning that appeared when compiling with\r\n    Borland C Builder (thanks to Rex Bloom and Tim Gallagher for the\r\n    patch).\r\n  - Breaking change: ReportHash writes the final hash to the start\r\n    of the buffer, i.e. it's not appending it to the string anymore.\r\n  - Made some function parameters const.\r\n  - Added Visual Studio 2005 project files to demo project.\r\n\r\n  Version 1.6 - 2005-02-07 (thanks to Howard Kapustein for patches)\r\n  - You can set the endianness in your files, no need to modify the\r\n    header file of the CSHA1 class anymore.\r\n  - Aligned data support.\r\n  - Made support/compilation of the utility functions (ReportHash and\r\n    HashFile) optional (useful when bytes count, for example in embedded\r\n    environments).\r\n\r\n  Version 1.5 - 2005-01-01\r\n  - 64-bit compiler compatibility added.\r\n  - Made variable wiping optional (define SHA1_WIPE_VARIABLES).\r\n  - Removed unnecessary variable initializations.\r\n  - ROL32 improvement for the Microsoft compiler (using _rotl).\r\n\r\n  Version 1.4 - 2004-07-22\r\n  - CSHA1 now compiles fine with GCC 3.3 under Mac OS X (thanks to Larry\r\n    Hastings).\r\n\r\n  Version 1.3 - 2003-08-17\r\n  - Fixed a small memory bug and made a buffer array a class member to\r\n    ensure correct working when using multiple CSHA1 class instances at\r\n    one time.\r\n\r\n  Version 1.2 - 2002-11-16\r\n  - Borlands C++ compiler seems to have problems with string addition\r\n    using sprintf. Fixed the bug which caused the digest report function\r\n    not to work properly. CSHA1 is now Borland compatible.\r\n\r\n  Version 1.1 - 2002-10-11\r\n  - Removed two unnecessary header file includes and changed BOOL to\r\n    bool. Fixed some minor bugs in the web page contents.\r\n\r\n  Version 1.0 - 2002-06-20\r\n  - First official release.\r\n\r\n  ================ Test Vectors ================\r\n\r\n  SHA1(\"abc\" in ANSI) =\r\n    A9993E36 4706816A BA3E2571 7850C26C 9CD0D89D\r\n  SHA1(\"abc\" in Unicode LE) =\r\n    9F04F41A 84851416 2050E3D6 8C1A7ABB 441DC2B5\r\n\r\n  SHA1(\"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq\"\r\n    in ANSI) =\r\n    84983E44 1C3BD26E BAAE4AA1 F95129E5 E54670F1\r\n  SHA1(\"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq\"\r\n    in Unicode LE) =\r\n    51D7D876 9AC72C40 9C5B0E3F 69C60ADC 9A039014\r\n\r\n  SHA1(A million repetitions of \"a\" in ANSI) =\r\n    34AA973C D4C4DAA4 F61EEB2B DBAD2731 6534016F\r\n  SHA1(A million repetitions of \"a\" in Unicode LE) =\r\n    C4609560 A108A0C6 26AA7F2B 38A65566 739353C5\r\n*/\r\n\r\n#ifndef SHA1_H_A545E61D43E9404E8D736869AB3CBFE7\r\n#define SHA1_H_A545E61D43E9404E8D736869AB3CBFE7\r\n\r\n#if !defined(SHA1_UTILITY_FUNCTIONS) && !defined(SHA1_NO_UTILITY_FUNCTIONS)\r\n#define SHA1_UTILITY_FUNCTIONS\r\n#endif\r\n\r\n#if !defined(SHA1_STL_FUNCTIONS) && !defined(SHA1_NO_STL_FUNCTIONS)\r\n#define SHA1_STL_FUNCTIONS\r\n#if !defined(SHA1_UTILITY_FUNCTIONS)\r\n#error STL functions require SHA1_UTILITY_FUNCTIONS.\r\n#endif\r\n#endif\r\n\r\n#include <memory.h>\r\n#include <limits.h>\r\n\r\n#ifdef SHA1_UTILITY_FUNCTIONS\r\n#include <stdio.h>\r\n#include <string.h>\r\n#endif\r\n\r\n#ifdef SHA1_STL_FUNCTIONS\r\n#include <string>\r\n#endif\r\n\r\n#ifdef _MSC_VER\r\n#include <stdlib.h>\r\n#endif\r\n\r\n// You can define the endian mode in your files without modifying the SHA-1\r\n// source files. Just #define SHA1_LITTLE_ENDIAN or #define SHA1_BIG_ENDIAN\r\n// in your files, before including the SHA1.h header file. If you don't\r\n// define anything, the class defaults to little endian.\r\n#if !defined(SHA1_LITTLE_ENDIAN) && !defined(SHA1_BIG_ENDIAN)\r\n#define SHA1_LITTLE_ENDIAN\r\n#endif\r\n\r\n// If you want variable wiping, #define SHA1_WIPE_VARIABLES, if not,\r\n// #define SHA1_NO_WIPE_VARIABLES. If you don't define anything, it\r\n// defaults to wiping.\r\n#if !defined(SHA1_WIPE_VARIABLES) && !defined(SHA1_NO_WIPE_VARIABLES)\r\n#define SHA1_WIPE_VARIABLES\r\n#endif\r\n\r\n#if defined(SHA1_HAS_TCHAR)\r\n#include <tchar.h>\r\n#else\r\n#ifdef _MSC_VER\r\n#include <tchar.h>\r\n#else\r\n#ifndef TCHAR\r\n#define TCHAR char\r\n#endif\r\n#ifndef _T\r\n#define _T(__x) (__x)\r\n#define _tmain main\r\n#define _tprintf printf\r\n#define _getts gets\r\n#define _tcslen strlen\r\n#define _tfopen fopen\r\n#define _tcscpy strcpy\r\n#define _tcscat strcat\r\n#define _sntprintf snprintf\r\n#endif\r\n#endif\r\n#endif\r\n\r\n///////////////////////////////////////////////////////////////////////////\r\n// Define variable types\r\n\r\n#ifndef UINT_8\r\n#ifdef _MSC_VER // Compiling with Microsoft compiler\r\n#define UINT_8 unsigned __int8\r\n#else // !_MSC_VER\r\n#define UINT_8 unsigned char\r\n#endif // _MSC_VER\r\n#endif\r\n\r\n#ifndef UINT_32\r\n#ifdef _MSC_VER // Compiling with Microsoft compiler\r\n#define UINT_32 unsigned __int32\r\n#else // !_MSC_VER\r\n#if (ULONG_MAX == 0xFFFFFFFFUL)\r\n#define UINT_32 unsigned long\r\n#else\r\n#define UINT_32 unsigned int\r\n#endif\r\n#endif // _MSC_VER\r\n#endif // UINT_32\r\n\r\n#ifndef INT_64\r\n#ifdef _MSC_VER // Compiling with Microsoft compiler\r\n#define INT_64 __int64\r\n#else // !_MSC_VER\r\n#define INT_64 long long\r\n#endif // _MSC_VER\r\n#endif // INT_64\r\n\r\n#ifndef UINT_64\r\n#ifdef _MSC_VER // Compiling with Microsoft compiler\r\n#define UINT_64 unsigned __int64\r\n#else // !_MSC_VER\r\n#define UINT_64 unsigned long long\r\n#endif // _MSC_VER\r\n#endif // UINT_64\r\n\r\n///////////////////////////////////////////////////////////////////////////\r\n// Declare SHA-1 workspace\r\n\r\ntypedef union\r\n{\r\n\tUINT_8 c[64];\r\n\tUINT_32 l[16];\r\n} SHA1_WORKSPACE_BLOCK;\r\n\r\nclass CSHA1\r\n{\r\npublic:\r\n#ifdef SHA1_UTILITY_FUNCTIONS\r\n\t// Different formats for ReportHash(Stl)\r\n\tenum REPORT_TYPE\r\n\t{\r\n\t\tREPORT_HEX = 0,\r\n\t\tREPORT_DIGIT = 1,\r\n\t\tREPORT_HEX_SHORT = 2\r\n\t};\r\n#endif\r\n\r\n\t// Constructor and destructor\r\n\tCSHA1();\r\n\r\n#ifdef SHA1_WIPE_VARIABLES\r\n\t~CSHA1();\r\n#endif\r\n\r\n\tvoid Reset();\r\n\r\n\t// Hash in binary data and strings\r\n\tvoid Update(const UINT_8* pbData, UINT_32 uLen);\r\n\r\n#ifdef SHA1_UTILITY_FUNCTIONS\r\n\t// Hash in file contents\r\n\tbool HashFile(const TCHAR* tszFileName);\r\n#endif\r\n\r\n\t// Finalize hash; call it before using ReportHash(Stl)\r\n\tvoid Final();\r\n\r\n#ifdef SHA1_UTILITY_FUNCTIONS\r\n\tbool ReportHash(TCHAR* tszReport, REPORT_TYPE rtReportType = REPORT_HEX) const;\r\n#endif\r\n\r\n#ifdef SHA1_STL_FUNCTIONS\r\n\tbool ReportHashStl(std::basic_string<TCHAR>& strOut, REPORT_TYPE rtReportType =\r\n\t\tREPORT_HEX) const;\r\n#endif\r\n\r\n\t// Get the raw message digest (20 bytes)\r\n\tbool GetHash(UINT_8* pbDest20) const;\r\n\r\nprivate:\r\n\t// Private SHA-1 transformation\r\n\tvoid Transform(UINT_32* pState, const UINT_8* pBuffer);\r\n\r\n\t// Member variables\r\n\tUINT_32 m_state[5];\r\n\tUINT_32 m_count[2];\r\n\tUINT_32 m_reserved0[1]; // Memory alignment padding\r\n\tUINT_8 m_buffer[64];\r\n\tUINT_8 m_digest[20];\r\n\tUINT_32 m_reserved1[3]; // Memory alignment padding\r\n\r\n\tUINT_8 m_workspace[64];\r\n\tSHA1_WORKSPACE_BLOCK* m_block; // SHA1 pointer to the byte array above\r\n};\r\n\r\n#endif // SHA1_H_A545E61D43E9404E8D736869AB3CBFE7\r\n"
  },
  {
    "path": "Projects/Libraries/CSBase/Source/SHA256/sha256.cpp",
    "content": "// //////////////////////////////////////////////////////////\n// sha256.cpp\n// Copyright (c) 2014,2015 Stephan Brumme. All rights reserved.\n// see http://create.stephan-brumme.com/disclaimer.html\n//\n\n#include \"sha256.h\"\n\n// big endian architectures need #define __BYTE_ORDER __BIG_ENDIAN\n#ifndef _MSC_VER\n#include <endian.h>\n#endif\n\n\n/// same as reset()\nSHA256::SHA256()\n{\n  reset();\n}\n\n\n/// restart\nvoid SHA256::reset()\n{\n  m_numBytes   = 0;\n  m_bufferSize = 0;\n\n  // according to RFC 1321\n  m_hash[0] = 0x6a09e667;\n  m_hash[1] = 0xbb67ae85;\n  m_hash[2] = 0x3c6ef372;\n  m_hash[3] = 0xa54ff53a;\n  m_hash[4] = 0x510e527f;\n  m_hash[5] = 0x9b05688c;\n  m_hash[6] = 0x1f83d9ab;\n  m_hash[7] = 0x5be0cd19;\n}\n\n\nnamespace\n{\n  inline uint32_t rotate(uint32_t a, uint32_t c)\n  {\n    return (a >> c) | (a << (32 - c));\n  }\n\n  inline uint32_t swap(uint32_t x)\n  {\n#if defined(__GNUC__) || defined(__clang__)\n    return __builtin_bswap32(x);\n#endif\n#ifdef MSC_VER\n    return _byteswap_ulong(x);\n#endif\n\n    return (x >> 24) |\n          ((x >>  8) & 0x0000FF00) |\n          ((x <<  8) & 0x00FF0000) |\n           (x << 24);\n  }\n\n  // mix functions for processBlock()\n  inline uint32_t f1(uint32_t e, uint32_t f, uint32_t g)\n  {\n    uint32_t term1 = rotate(e, 6) ^ rotate(e, 11) ^ rotate(e, 25);\n    uint32_t term2 = (e & f) ^ (~e & g); //(g ^ (e & (f ^ g)))\n    return term1 + term2;\n  }\n\n  inline uint32_t f2(uint32_t a, uint32_t b, uint32_t c)\n  {\n    uint32_t term1 = rotate(a, 2) ^ rotate(a, 13) ^ rotate(a, 22);\n    uint32_t term2 = ((a | b) & c) | (a & b); //(a & (b ^ c)) ^ (b & c);\n    return term1 + term2;\n  }\n}\n\n\n/// process 64 bytes\nvoid SHA256::processBlock(const void* data)\n{\n  // get last hash\n  uint32_t a = m_hash[0];\n  uint32_t b = m_hash[1];\n  uint32_t c = m_hash[2];\n  uint32_t d = m_hash[3];\n  uint32_t e = m_hash[4];\n  uint32_t f = m_hash[5];\n  uint32_t g = m_hash[6];\n  uint32_t h = m_hash[7];\n\n  // data represented as 16x 32-bit words\n  const uint32_t* input = (uint32_t*) data;\n  // convert to big endian\n  uint32_t words[64];\n  int i;\n  for (i = 0; i < 16; i++)\n#if defined(__BYTE_ORDER) && (__BYTE_ORDER != 0) && (__BYTE_ORDER == __BIG_ENDIAN)\n    words[i] =      input[i];\n#else\n    words[i] = swap(input[i]);\n#endif\n\n  uint32_t x,y; // temporaries\n\n  // first round\n  x = h + f1(e,f,g) + 0x428a2f98 + words[ 0]; y = f2(a,b,c); d += x; h = x + y;\n  x = g + f1(d,e,f) + 0x71374491 + words[ 1]; y = f2(h,a,b); c += x; g = x + y;\n  x = f + f1(c,d,e) + 0xb5c0fbcf + words[ 2]; y = f2(g,h,a); b += x; f = x + y;\n  x = e + f1(b,c,d) + 0xe9b5dba5 + words[ 3]; y = f2(f,g,h); a += x; e = x + y;\n  x = d + f1(a,b,c) + 0x3956c25b + words[ 4]; y = f2(e,f,g); h += x; d = x + y;\n  x = c + f1(h,a,b) + 0x59f111f1 + words[ 5]; y = f2(d,e,f); g += x; c = x + y;\n  x = b + f1(g,h,a) + 0x923f82a4 + words[ 6]; y = f2(c,d,e); f += x; b = x + y;\n  x = a + f1(f,g,h) + 0xab1c5ed5 + words[ 7]; y = f2(b,c,d); e += x; a = x + y;\n\n  // secound round\n  x = h + f1(e,f,g) + 0xd807aa98 + words[ 8]; y = f2(a,b,c); d += x; h = x + y;\n  x = g + f1(d,e,f) + 0x12835b01 + words[ 9]; y = f2(h,a,b); c += x; g = x + y;\n  x = f + f1(c,d,e) + 0x243185be + words[10]; y = f2(g,h,a); b += x; f = x + y;\n  x = e + f1(b,c,d) + 0x550c7dc3 + words[11]; y = f2(f,g,h); a += x; e = x + y;\n  x = d + f1(a,b,c) + 0x72be5d74 + words[12]; y = f2(e,f,g); h += x; d = x + y;\n  x = c + f1(h,a,b) + 0x80deb1fe + words[13]; y = f2(d,e,f); g += x; c = x + y;\n  x = b + f1(g,h,a) + 0x9bdc06a7 + words[14]; y = f2(c,d,e); f += x; b = x + y;\n  x = a + f1(f,g,h) + 0xc19bf174 + words[15]; y = f2(b,c,d); e += x; a = x + y;\n\n  // extend to 24 words\n  for (; i < 24; i++)\n    words[i] = words[i-16] +\n               (rotate(words[i-15],  7) ^ rotate(words[i-15], 18) ^ (words[i-15] >>  3)) +\n               words[i-7] +\n               (rotate(words[i- 2], 17) ^ rotate(words[i- 2], 19) ^ (words[i- 2] >> 10));\n\n  // third round\n  x = h + f1(e,f,g) + 0xe49b69c1 + words[16]; y = f2(a,b,c); d += x; h = x + y;\n  x = g + f1(d,e,f) + 0xefbe4786 + words[17]; y = f2(h,a,b); c += x; g = x + y;\n  x = f + f1(c,d,e) + 0x0fc19dc6 + words[18]; y = f2(g,h,a); b += x; f = x + y;\n  x = e + f1(b,c,d) + 0x240ca1cc + words[19]; y = f2(f,g,h); a += x; e = x + y;\n  x = d + f1(a,b,c) + 0x2de92c6f + words[20]; y = f2(e,f,g); h += x; d = x + y;\n  x = c + f1(h,a,b) + 0x4a7484aa + words[21]; y = f2(d,e,f); g += x; c = x + y;\n  x = b + f1(g,h,a) + 0x5cb0a9dc + words[22]; y = f2(c,d,e); f += x; b = x + y;\n  x = a + f1(f,g,h) + 0x76f988da + words[23]; y = f2(b,c,d); e += x; a = x + y;\n\n  // extend to 32 words\n  for (; i < 32; i++)\n    words[i] = words[i-16] +\n               (rotate(words[i-15],  7) ^ rotate(words[i-15], 18) ^ (words[i-15] >>  3)) +\n               words[i-7] +\n               (rotate(words[i- 2], 17) ^ rotate(words[i- 2], 19) ^ (words[i- 2] >> 10));\n\n  // fourth round\n  x = h + f1(e,f,g) + 0x983e5152 + words[24]; y = f2(a,b,c); d += x; h = x + y;\n  x = g + f1(d,e,f) + 0xa831c66d + words[25]; y = f2(h,a,b); c += x; g = x + y;\n  x = f + f1(c,d,e) + 0xb00327c8 + words[26]; y = f2(g,h,a); b += x; f = x + y;\n  x = e + f1(b,c,d) + 0xbf597fc7 + words[27]; y = f2(f,g,h); a += x; e = x + y;\n  x = d + f1(a,b,c) + 0xc6e00bf3 + words[28]; y = f2(e,f,g); h += x; d = x + y;\n  x = c + f1(h,a,b) + 0xd5a79147 + words[29]; y = f2(d,e,f); g += x; c = x + y;\n  x = b + f1(g,h,a) + 0x06ca6351 + words[30]; y = f2(c,d,e); f += x; b = x + y;\n  x = a + f1(f,g,h) + 0x14292967 + words[31]; y = f2(b,c,d); e += x; a = x + y;\n\n  // extend to 40 words\n  for (; i < 40; i++)\n    words[i] = words[i-16] +\n               (rotate(words[i-15],  7) ^ rotate(words[i-15], 18) ^ (words[i-15] >>  3)) +\n               words[i-7] +\n               (rotate(words[i- 2], 17) ^ rotate(words[i- 2], 19) ^ (words[i- 2] >> 10));\n\n  // fifth round\n  x = h + f1(e,f,g) + 0x27b70a85 + words[32]; y = f2(a,b,c); d += x; h = x + y;\n  x = g + f1(d,e,f) + 0x2e1b2138 + words[33]; y = f2(h,a,b); c += x; g = x + y;\n  x = f + f1(c,d,e) + 0x4d2c6dfc + words[34]; y = f2(g,h,a); b += x; f = x + y;\n  x = e + f1(b,c,d) + 0x53380d13 + words[35]; y = f2(f,g,h); a += x; e = x + y;\n  x = d + f1(a,b,c) + 0x650a7354 + words[36]; y = f2(e,f,g); h += x; d = x + y;\n  x = c + f1(h,a,b) + 0x766a0abb + words[37]; y = f2(d,e,f); g += x; c = x + y;\n  x = b + f1(g,h,a) + 0x81c2c92e + words[38]; y = f2(c,d,e); f += x; b = x + y;\n  x = a + f1(f,g,h) + 0x92722c85 + words[39]; y = f2(b,c,d); e += x; a = x + y;\n\n  // extend to 48 words\n  for (; i < 48; i++)\n    words[i] = words[i-16] +\n               (rotate(words[i-15],  7) ^ rotate(words[i-15], 18) ^ (words[i-15] >>  3)) +\n               words[i-7] +\n               (rotate(words[i- 2], 17) ^ rotate(words[i- 2], 19) ^ (words[i- 2] >> 10));\n\n  // sixth round\n  x = h + f1(e,f,g) + 0xa2bfe8a1 + words[40]; y = f2(a,b,c); d += x; h = x + y;\n  x = g + f1(d,e,f) + 0xa81a664b + words[41]; y = f2(h,a,b); c += x; g = x + y;\n  x = f + f1(c,d,e) + 0xc24b8b70 + words[42]; y = f2(g,h,a); b += x; f = x + y;\n  x = e + f1(b,c,d) + 0xc76c51a3 + words[43]; y = f2(f,g,h); a += x; e = x + y;\n  x = d + f1(a,b,c) + 0xd192e819 + words[44]; y = f2(e,f,g); h += x; d = x + y;\n  x = c + f1(h,a,b) + 0xd6990624 + words[45]; y = f2(d,e,f); g += x; c = x + y;\n  x = b + f1(g,h,a) + 0xf40e3585 + words[46]; y = f2(c,d,e); f += x; b = x + y;\n  x = a + f1(f,g,h) + 0x106aa070 + words[47]; y = f2(b,c,d); e += x; a = x + y;\n\n  // extend to 56 words\n  for (; i < 56; i++)\n    words[i] = words[i-16] +\n               (rotate(words[i-15],  7) ^ rotate(words[i-15], 18) ^ (words[i-15] >>  3)) +\n               words[i-7] +\n               (rotate(words[i- 2], 17) ^ rotate(words[i- 2], 19) ^ (words[i- 2] >> 10));\n\n  // seventh round\n  x = h + f1(e,f,g) + 0x19a4c116 + words[48]; y = f2(a,b,c); d += x; h = x + y;\n  x = g + f1(d,e,f) + 0x1e376c08 + words[49]; y = f2(h,a,b); c += x; g = x + y;\n  x = f + f1(c,d,e) + 0x2748774c + words[50]; y = f2(g,h,a); b += x; f = x + y;\n  x = e + f1(b,c,d) + 0x34b0bcb5 + words[51]; y = f2(f,g,h); a += x; e = x + y;\n  x = d + f1(a,b,c) + 0x391c0cb3 + words[52]; y = f2(e,f,g); h += x; d = x + y;\n  x = c + f1(h,a,b) + 0x4ed8aa4a + words[53]; y = f2(d,e,f); g += x; c = x + y;\n  x = b + f1(g,h,a) + 0x5b9cca4f + words[54]; y = f2(c,d,e); f += x; b = x + y;\n  x = a + f1(f,g,h) + 0x682e6ff3 + words[55]; y = f2(b,c,d); e += x; a = x + y;\n\n  // extend to 64 words\n  for (; i < 64; i++)\n    words[i] = words[i-16] +\n               (rotate(words[i-15],  7) ^ rotate(words[i-15], 18) ^ (words[i-15] >>  3)) +\n               words[i-7] +\n               (rotate(words[i- 2], 17) ^ rotate(words[i- 2], 19) ^ (words[i- 2] >> 10));\n\n  // eigth round\n  x = h + f1(e,f,g) + 0x748f82ee + words[56]; y = f2(a,b,c); d += x; h = x + y;\n  x = g + f1(d,e,f) + 0x78a5636f + words[57]; y = f2(h,a,b); c += x; g = x + y;\n  x = f + f1(c,d,e) + 0x84c87814 + words[58]; y = f2(g,h,a); b += x; f = x + y;\n  x = e + f1(b,c,d) + 0x8cc70208 + words[59]; y = f2(f,g,h); a += x; e = x + y;\n  x = d + f1(a,b,c) + 0x90befffa + words[60]; y = f2(e,f,g); h += x; d = x + y;\n  x = c + f1(h,a,b) + 0xa4506ceb + words[61]; y = f2(d,e,f); g += x; c = x + y;\n  x = b + f1(g,h,a) + 0xbef9a3f7 + words[62]; y = f2(c,d,e); f += x; b = x + y;\n  x = a + f1(f,g,h) + 0xc67178f2 + words[63]; y = f2(b,c,d); e += x; a = x + y;\n\n  // update hash\n  m_hash[0] += a;\n  m_hash[1] += b;\n  m_hash[2] += c;\n  m_hash[3] += d;\n  m_hash[4] += e;\n  m_hash[5] += f;\n  m_hash[6] += g;\n  m_hash[7] += h;\n}\n\n\n/// add arbitrary number of bytes\nvoid SHA256::add(const void* data, size_t numBytes)\n{\n  const uint8_t* current = (const uint8_t*) data;\n\n  if (m_bufferSize > 0)\n  {\n    while (numBytes > 0 && m_bufferSize < BlockSize)\n    {\n      m_buffer[m_bufferSize++] = *current++;\n      numBytes--;\n    }\n  }\n\n  // full buffer\n  if (m_bufferSize == BlockSize)\n  {\n    processBlock(m_buffer);\n    m_numBytes  += BlockSize;\n    m_bufferSize = 0;\n  }\n\n  // no more data ?\n  if (numBytes == 0)\n    return;\n\n  // process full blocks\n  while (numBytes >= BlockSize)\n  {\n    processBlock(current);\n    current    += BlockSize;\n    m_numBytes += BlockSize;\n    numBytes   -= BlockSize;\n  }\n\n  // keep remaining bytes in buffer\n  while (numBytes > 0)\n  {\n    m_buffer[m_bufferSize++] = *current++;\n    numBytes--;\n  }\n}\n\n\n/// process final block, less than 64 bytes\nvoid SHA256::processBuffer()\n{\n  // the input bytes are considered as bits strings, where the first bit is the most significant bit of the byte\n\n  // - append \"1\" bit to message\n  // - append \"0\" bits until message length in bit mod 512 is 448\n  // - append length as 64 bit integer\n\n  // number of bits\n  size_t paddedLength = m_bufferSize * 8;\n\n  // plus one bit set to 1 (always appended)\n  paddedLength++;\n\n  // number of bits must be (numBits % 512) = 448\n  size_t lower11Bits = paddedLength & 511;\n  if (lower11Bits <= 448)\n    paddedLength +=       448 - lower11Bits;\n  else\n    paddedLength += 512 + 448 - lower11Bits;\n  // convert from bits to bytes\n  paddedLength /= 8;\n\n  // only needed if additional data flows over into a second block\n  unsigned char extra[BlockSize];\n\n  // append a \"1\" bit, 128 => binary 10000000\n  if (m_bufferSize < BlockSize)\n    m_buffer[m_bufferSize] = 128;\n  else\n    extra[0] = 128;\n\n  size_t i;\n  for (i = m_bufferSize + 1; i < BlockSize; i++)\n    m_buffer[i] = 0;\n  for (; i < paddedLength; i++)\n    extra[i - BlockSize] = 0;\n\n  // add message length in bits as 64 bit number\n  uint64_t msgBits = 8 * (m_numBytes + m_bufferSize);\n  // find right position\n  unsigned char* addLength;\n  if (paddedLength < BlockSize)\n    addLength = m_buffer + paddedLength;\n  else\n    addLength = extra + paddedLength - BlockSize;\n\n  // must be big endian\n  *addLength++ = (unsigned char)((msgBits >> 56) & 0xFF);\n  *addLength++ = (unsigned char)((msgBits >> 48) & 0xFF);\n  *addLength++ = (unsigned char)((msgBits >> 40) & 0xFF);\n  *addLength++ = (unsigned char)((msgBits >> 32) & 0xFF);\n  *addLength++ = (unsigned char)((msgBits >> 24) & 0xFF);\n  *addLength++ = (unsigned char)((msgBits >> 16) & 0xFF);\n  *addLength++ = (unsigned char)((msgBits >>  8) & 0xFF);\n  *addLength   = (unsigned char)( msgBits        & 0xFF);\n\n  // process blocks\n  processBlock(m_buffer);\n  // flowed over into a second block ?\n  if (paddedLength > BlockSize)\n    processBlock(extra);\n}\n\n\n/// return latest hash as 64 hex characters\nstd::string SHA256::getHash()\n{\n  // compute hash (as raw bytes)\n  unsigned char rawHash[HashBytes];\n  getHash(rawHash);\n\n  // convert to hex string\n  std::string result;\n  result.reserve(2 * HashBytes);\n  for (int i = 0; i < HashBytes; i++)\n  {\n    static const char dec2hex[16+1] = \"0123456789abcdef\";\n    result += dec2hex[(rawHash[i] >> 4) & 15];\n    result += dec2hex[ rawHash[i]       & 15];\n  }\n\n  return result;\n}\n\n\n/// return latest hash as bytes\nvoid SHA256::getHash(unsigned char buffer[SHA256::HashBytes])\n{\n  // save old hash if buffer is partially filled\n  uint32_t oldHash[HashValues];\n  for (int i = 0; i < HashValues; i++)\n    oldHash[i] = m_hash[i];\n\n  // process remaining bytes\n  processBuffer();\n\n  unsigned char* current = buffer;\n  for (int i = 0; i < HashValues; i++)\n  {\n    *current++ = (m_hash[i] >> 24) & 0xFF;\n    *current++ = (m_hash[i] >> 16) & 0xFF;\n    *current++ = (m_hash[i] >>  8) & 0xFF;\n    *current++ =  m_hash[i]        & 0xFF;\n\n    // restore old hash\n    m_hash[i] = oldHash[i];\n  }\n}\n\n\n/// compute SHA256 of a memory block\nstd::string SHA256::operator()(const void* data, size_t numBytes)\n{\n  reset();\n  add(data, numBytes);\n  return getHash();\n}\n\n\n/// compute SHA256 of a string, excluding final zero\nstd::string SHA256::operator()(const std::string& text)\n{\n  reset();\n  add(text.c_str(), text.size());\n  return getHash();\n}\n"
  },
  {
    "path": "Projects/Libraries/CSBase/Source/SHA256/sha256.h",
    "content": "// //////////////////////////////////////////////////////////\n// sha256.h\n// Copyright (c) 2014,2015 Stephan Brumme. All rights reserved.\n// see http://create.stephan-brumme.com/disclaimer.html\n//\n\n#pragma once\n\n//#include \"hash.h\"\n#include <string>\n\n// define fixed size integer types\n#ifdef _MSC_VER\n// Windows\ntypedef unsigned __int8  uint8_t;\ntypedef unsigned __int32 uint32_t;\ntypedef unsigned __int64 uint64_t;\n#else\n// GCC\n#include <stdint.h>\n#endif\n\n\n/// compute SHA256 hash\n/** Usage:\n    SHA256 sha256;\n    std::string myHash  = sha256(\"Hello World\");     // std::string\n    std::string myHash2 = sha256(\"How are you\", 11); // arbitrary data, 11 bytes\n\n    // or in a streaming fashion:\n\n    SHA256 sha256;\n    while (more data available)\n      sha256.add(pointer to fresh data, number of new bytes);\n    std::string myHash3 = sha256.getHash();\n  */\nclass SHA256 //: public Hash\n{\npublic:\n  /// split into 64 byte blocks (=> 512 bits), hash is 32 bytes long\n  enum { BlockSize = 512 / 8, HashBytes = 32 };\n\n  /// same as reset()\n  SHA256();\n\n  /// compute SHA256 of a memory block\n  std::string operator()(const void* data, size_t numBytes);\n  /// compute SHA256 of a string, excluding final zero\n  std::string operator()(const std::string& text);\n\n  /// add arbitrary number of bytes\n  void add(const void* data, size_t numBytes);\n\n  /// return latest hash as 64 hex characters\n  std::string getHash();\n  /// return latest hash as bytes\n  void        getHash(unsigned char buffer[HashBytes]);\n\n  /// restart\n  void reset();\n\nprivate:\n  /// process 64 bytes\n  void processBlock(const void* data);\n  /// process everything left in the internal buffer\n  void processBuffer();\n\n  /// size of processed data in bytes\n  uint64_t m_numBytes;\n  /// valid bytes in m_buffer\n  size_t   m_bufferSize;\n  /// bytes not processed yet\n  uint8_t  m_buffer[BlockSize];\n\n  enum { HashValues = HashBytes / 4 };\n  /// hash, stored as integers\n  uint32_t m_hash[HashValues];\n};\n"
  },
  {
    "path": "Projects/Libraries/CSBase/Source/aes/aes.c",
    "content": "/* The MIT License\n\n   Copyright (C) 2011 Zilong Tan (labytan@gmail.com)\n\n   Permission is hereby granted, free of charge, to any person obtaining\n   a copy of this software and associated documentation files (the\n   \"Software\"), to deal in the Software without restriction, including\n   without limitation the rights to use, copy, modify, merge, publish,\n   distribute, sublicense, and/or sell copies of the Software, and to\n   permit persons to whom the Software is furnished to do so, subject to\n   the following conditions:\n\n   The above copyright notice and this permission notice shall be\n   included in all copies or substantial portions of the Software.\n\n   THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n   NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS\n   BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\n   ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\n   CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n   SOFTWARE.\n*/\n\n/*\n * aes.c\n *\n * @version 3.0 (December 2000)\n *\n * Optimised ANSI C code for the Rijndael cipher (now AES)\n *\n * @author Vincent Rijmen <vincent.rijmen@esat.kuleuven.ac.be>\n * @author Antoon Bosselaers <antoon.bosselaers@esat.kuleuven.ac.be>\n * @author Paulo Barreto <paulo.barreto@terra.com.br>\n *\n * This code is hereby placed in the public domain.\n *\n * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ''AS IS'' AND ANY EXPRESS\n * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE\n * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,\n * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\n#include <string.h>\n#include \"aes.h\"\n\ntypedef uint32_t u32;\ntypedef uint16_t u16;\ntypedef uint8_t  u8;\n\n#define MAXKC   (256/32)\n#define MAXKB   (256/8)\n#define MAXNR   14\n\n/* This controls loop-unrolling in aes_core.c */\n#undef FULL_UNROLL\n# define GETU32(pt) (((u32)(pt)[0] << 24) ^ ((u32)(pt)[1] << 16) ^ ((u32)(pt)[2] <<  8) ^ ((u32)(pt)[3]))\n# define PUTU32(ct, st) { (ct)[0] = (u8)((st) >> 24); (ct)[1] = (u8)((st) >> 16); (ct)[2] = (u8)((st) >>  8); (ct)[3] = (u8)(st); }\n\n/*\n  Te0[x] = S [x].[02, 01, 01, 03];\n  Te1[x] = S [x].[03, 02, 01, 01];\n  Te2[x] = S [x].[01, 03, 02, 01];\n  Te3[x] = S [x].[01, 01, 03, 02];\n  Te4[x] = S [x].[01, 01, 01, 01];\n\n  Td0[x] = Si[x].[0e, 09, 0d, 0b];\n  Td1[x] = Si[x].[0b, 0e, 09, 0d];\n  Td2[x] = Si[x].[0d, 0b, 0e, 09];\n  Td3[x] = Si[x].[09, 0d, 0b, 0e];\n  Td4[x] = Si[x].[01, 01, 01, 01];\n*/\n\nstatic const u32 Te0[256] = {\n        0xc66363a5U, 0xf87c7c84U, 0xee777799U, 0xf67b7b8dU,\n        0xfff2f20dU, 0xd66b6bbdU, 0xde6f6fb1U, 0x91c5c554U,\n        0x60303050U, 0x02010103U, 0xce6767a9U, 0x562b2b7dU,\n        0xe7fefe19U, 0xb5d7d762U, 0x4dababe6U, 0xec76769aU,\n        0x8fcaca45U, 0x1f82829dU, 0x89c9c940U, 0xfa7d7d87U,\n        0xeffafa15U, 0xb25959ebU, 0x8e4747c9U, 0xfbf0f00bU,\n        0x41adadecU, 0xb3d4d467U, 0x5fa2a2fdU, 0x45afafeaU,\n        0x239c9cbfU, 0x53a4a4f7U, 0xe4727296U, 0x9bc0c05bU,\n        0x75b7b7c2U, 0xe1fdfd1cU, 0x3d9393aeU, 0x4c26266aU,\n        0x6c36365aU, 0x7e3f3f41U, 0xf5f7f702U, 0x83cccc4fU,\n        0x6834345cU, 0x51a5a5f4U, 0xd1e5e534U, 0xf9f1f108U,\n        0xe2717193U, 0xabd8d873U, 0x62313153U, 0x2a15153fU,\n        0x0804040cU, 0x95c7c752U, 0x46232365U, 0x9dc3c35eU,\n        0x30181828U, 0x379696a1U, 0x0a05050fU, 0x2f9a9ab5U,\n        0x0e070709U, 0x24121236U, 0x1b80809bU, 0xdfe2e23dU,\n        0xcdebeb26U, 0x4e272769U, 0x7fb2b2cdU, 0xea75759fU,\n        0x1209091bU, 0x1d83839eU, 0x582c2c74U, 0x341a1a2eU,\n        0x361b1b2dU, 0xdc6e6eb2U, 0xb45a5aeeU, 0x5ba0a0fbU,\n        0xa45252f6U, 0x763b3b4dU, 0xb7d6d661U, 0x7db3b3ceU,\n        0x5229297bU, 0xdde3e33eU, 0x5e2f2f71U, 0x13848497U,\n        0xa65353f5U, 0xb9d1d168U, 0x00000000U, 0xc1eded2cU,\n        0x40202060U, 0xe3fcfc1fU, 0x79b1b1c8U, 0xb65b5bedU,\n        0xd46a6abeU, 0x8dcbcb46U, 0x67bebed9U, 0x7239394bU,\n        0x944a4adeU, 0x984c4cd4U, 0xb05858e8U, 0x85cfcf4aU,\n        0xbbd0d06bU, 0xc5efef2aU, 0x4faaaae5U, 0xedfbfb16U,\n        0x864343c5U, 0x9a4d4dd7U, 0x66333355U, 0x11858594U,\n        0x8a4545cfU, 0xe9f9f910U, 0x04020206U, 0xfe7f7f81U,\n        0xa05050f0U, 0x783c3c44U, 0x259f9fbaU, 0x4ba8a8e3U,\n        0xa25151f3U, 0x5da3a3feU, 0x804040c0U, 0x058f8f8aU,\n        0x3f9292adU, 0x219d9dbcU, 0x70383848U, 0xf1f5f504U,\n        0x63bcbcdfU, 0x77b6b6c1U, 0xafdada75U, 0x42212163U,\n        0x20101030U, 0xe5ffff1aU, 0xfdf3f30eU, 0xbfd2d26dU,\n        0x81cdcd4cU, 0x180c0c14U, 0x26131335U, 0xc3ecec2fU,\n        0xbe5f5fe1U, 0x359797a2U, 0x884444ccU, 0x2e171739U,\n        0x93c4c457U, 0x55a7a7f2U, 0xfc7e7e82U, 0x7a3d3d47U,\n        0xc86464acU, 0xba5d5de7U, 0x3219192bU, 0xe6737395U,\n        0xc06060a0U, 0x19818198U, 0x9e4f4fd1U, 0xa3dcdc7fU,\n        0x44222266U, 0x542a2a7eU, 0x3b9090abU, 0x0b888883U,\n        0x8c4646caU, 0xc7eeee29U, 0x6bb8b8d3U, 0x2814143cU,\n        0xa7dede79U, 0xbc5e5ee2U, 0x160b0b1dU, 0xaddbdb76U,\n        0xdbe0e03bU, 0x64323256U, 0x743a3a4eU, 0x140a0a1eU,\n        0x924949dbU, 0x0c06060aU, 0x4824246cU, 0xb85c5ce4U,\n        0x9fc2c25dU, 0xbdd3d36eU, 0x43acacefU, 0xc46262a6U,\n        0x399191a8U, 0x319595a4U, 0xd3e4e437U, 0xf279798bU,\n        0xd5e7e732U, 0x8bc8c843U, 0x6e373759U, 0xda6d6db7U,\n        0x018d8d8cU, 0xb1d5d564U, 0x9c4e4ed2U, 0x49a9a9e0U,\n        0xd86c6cb4U, 0xac5656faU, 0xf3f4f407U, 0xcfeaea25U,\n        0xca6565afU, 0xf47a7a8eU, 0x47aeaee9U, 0x10080818U,\n        0x6fbabad5U, 0xf0787888U, 0x4a25256fU, 0x5c2e2e72U,\n        0x381c1c24U, 0x57a6a6f1U, 0x73b4b4c7U, 0x97c6c651U,\n        0xcbe8e823U, 0xa1dddd7cU, 0xe874749cU, 0x3e1f1f21U,\n        0x964b4bddU, 0x61bdbddcU, 0x0d8b8b86U, 0x0f8a8a85U,\n        0xe0707090U, 0x7c3e3e42U, 0x71b5b5c4U, 0xcc6666aaU,\n        0x904848d8U, 0x06030305U, 0xf7f6f601U, 0x1c0e0e12U,\n        0xc26161a3U, 0x6a35355fU, 0xae5757f9U, 0x69b9b9d0U,\n        0x17868691U, 0x99c1c158U, 0x3a1d1d27U, 0x279e9eb9U,\n        0xd9e1e138U, 0xebf8f813U, 0x2b9898b3U, 0x22111133U,\n        0xd26969bbU, 0xa9d9d970U, 0x078e8e89U, 0x339494a7U,\n        0x2d9b9bb6U, 0x3c1e1e22U, 0x15878792U, 0xc9e9e920U,\n        0x87cece49U, 0xaa5555ffU, 0x50282878U, 0xa5dfdf7aU,\n        0x038c8c8fU, 0x59a1a1f8U, 0x09898980U, 0x1a0d0d17U,\n        0x65bfbfdaU, 0xd7e6e631U, 0x844242c6U, 0xd06868b8U,\n        0x824141c3U, 0x299999b0U, 0x5a2d2d77U, 0x1e0f0f11U,\n        0x7bb0b0cbU, 0xa85454fcU, 0x6dbbbbd6U, 0x2c16163aU,\n};\nstatic const u32 Te1[256] = {\n        0xa5c66363U, 0x84f87c7cU, 0x99ee7777U, 0x8df67b7bU,\n        0x0dfff2f2U, 0xbdd66b6bU, 0xb1de6f6fU, 0x5491c5c5U,\n        0x50603030U, 0x03020101U, 0xa9ce6767U, 0x7d562b2bU,\n        0x19e7fefeU, 0x62b5d7d7U, 0xe64dababU, 0x9aec7676U,\n        0x458fcacaU, 0x9d1f8282U, 0x4089c9c9U, 0x87fa7d7dU,\n        0x15effafaU, 0xebb25959U, 0xc98e4747U, 0x0bfbf0f0U,\n        0xec41adadU, 0x67b3d4d4U, 0xfd5fa2a2U, 0xea45afafU,\n        0xbf239c9cU, 0xf753a4a4U, 0x96e47272U, 0x5b9bc0c0U,\n        0xc275b7b7U, 0x1ce1fdfdU, 0xae3d9393U, 0x6a4c2626U,\n        0x5a6c3636U, 0x417e3f3fU, 0x02f5f7f7U, 0x4f83ccccU,\n        0x5c683434U, 0xf451a5a5U, 0x34d1e5e5U, 0x08f9f1f1U,\n        0x93e27171U, 0x73abd8d8U, 0x53623131U, 0x3f2a1515U,\n        0x0c080404U, 0x5295c7c7U, 0x65462323U, 0x5e9dc3c3U,\n        0x28301818U, 0xa1379696U, 0x0f0a0505U, 0xb52f9a9aU,\n        0x090e0707U, 0x36241212U, 0x9b1b8080U, 0x3ddfe2e2U,\n        0x26cdebebU, 0x694e2727U, 0xcd7fb2b2U, 0x9fea7575U,\n        0x1b120909U, 0x9e1d8383U, 0x74582c2cU, 0x2e341a1aU,\n        0x2d361b1bU, 0xb2dc6e6eU, 0xeeb45a5aU, 0xfb5ba0a0U,\n        0xf6a45252U, 0x4d763b3bU, 0x61b7d6d6U, 0xce7db3b3U,\n        0x7b522929U, 0x3edde3e3U, 0x715e2f2fU, 0x97138484U,\n        0xf5a65353U, 0x68b9d1d1U, 0x00000000U, 0x2cc1ededU,\n        0x60402020U, 0x1fe3fcfcU, 0xc879b1b1U, 0xedb65b5bU,\n        0xbed46a6aU, 0x468dcbcbU, 0xd967bebeU, 0x4b723939U,\n        0xde944a4aU, 0xd4984c4cU, 0xe8b05858U, 0x4a85cfcfU,\n        0x6bbbd0d0U, 0x2ac5efefU, 0xe54faaaaU, 0x16edfbfbU,\n        0xc5864343U, 0xd79a4d4dU, 0x55663333U, 0x94118585U,\n        0xcf8a4545U, 0x10e9f9f9U, 0x06040202U, 0x81fe7f7fU,\n        0xf0a05050U, 0x44783c3cU, 0xba259f9fU, 0xe34ba8a8U,\n        0xf3a25151U, 0xfe5da3a3U, 0xc0804040U, 0x8a058f8fU,\n        0xad3f9292U, 0xbc219d9dU, 0x48703838U, 0x04f1f5f5U,\n        0xdf63bcbcU, 0xc177b6b6U, 0x75afdadaU, 0x63422121U,\n        0x30201010U, 0x1ae5ffffU, 0x0efdf3f3U, 0x6dbfd2d2U,\n        0x4c81cdcdU, 0x14180c0cU, 0x35261313U, 0x2fc3ececU,\n        0xe1be5f5fU, 0xa2359797U, 0xcc884444U, 0x392e1717U,\n        0x5793c4c4U, 0xf255a7a7U, 0x82fc7e7eU, 0x477a3d3dU,\n        0xacc86464U, 0xe7ba5d5dU, 0x2b321919U, 0x95e67373U,\n        0xa0c06060U, 0x98198181U, 0xd19e4f4fU, 0x7fa3dcdcU,\n        0x66442222U, 0x7e542a2aU, 0xab3b9090U, 0x830b8888U,\n        0xca8c4646U, 0x29c7eeeeU, 0xd36bb8b8U, 0x3c281414U,\n        0x79a7dedeU, 0xe2bc5e5eU, 0x1d160b0bU, 0x76addbdbU,\n        0x3bdbe0e0U, 0x56643232U, 0x4e743a3aU, 0x1e140a0aU,\n        0xdb924949U, 0x0a0c0606U, 0x6c482424U, 0xe4b85c5cU,\n        0x5d9fc2c2U, 0x6ebdd3d3U, 0xef43acacU, 0xa6c46262U,\n        0xa8399191U, 0xa4319595U, 0x37d3e4e4U, 0x8bf27979U,\n        0x32d5e7e7U, 0x438bc8c8U, 0x596e3737U, 0xb7da6d6dU,\n        0x8c018d8dU, 0x64b1d5d5U, 0xd29c4e4eU, 0xe049a9a9U,\n        0xb4d86c6cU, 0xfaac5656U, 0x07f3f4f4U, 0x25cfeaeaU,\n        0xafca6565U, 0x8ef47a7aU, 0xe947aeaeU, 0x18100808U,\n        0xd56fbabaU, 0x88f07878U, 0x6f4a2525U, 0x725c2e2eU,\n        0x24381c1cU, 0xf157a6a6U, 0xc773b4b4U, 0x5197c6c6U,\n        0x23cbe8e8U, 0x7ca1ddddU, 0x9ce87474U, 0x213e1f1fU,\n        0xdd964b4bU, 0xdc61bdbdU, 0x860d8b8bU, 0x850f8a8aU,\n        0x90e07070U, 0x427c3e3eU, 0xc471b5b5U, 0xaacc6666U,\n        0xd8904848U, 0x05060303U, 0x01f7f6f6U, 0x121c0e0eU,\n        0xa3c26161U, 0x5f6a3535U, 0xf9ae5757U, 0xd069b9b9U,\n        0x91178686U, 0x5899c1c1U, 0x273a1d1dU, 0xb9279e9eU,\n        0x38d9e1e1U, 0x13ebf8f8U, 0xb32b9898U, 0x33221111U,\n        0xbbd26969U, 0x70a9d9d9U, 0x89078e8eU, 0xa7339494U,\n        0xb62d9b9bU, 0x223c1e1eU, 0x92158787U, 0x20c9e9e9U,\n        0x4987ceceU, 0xffaa5555U, 0x78502828U, 0x7aa5dfdfU,\n        0x8f038c8cU, 0xf859a1a1U, 0x80098989U, 0x171a0d0dU,\n        0xda65bfbfU, 0x31d7e6e6U, 0xc6844242U, 0xb8d06868U,\n        0xc3824141U, 0xb0299999U, 0x775a2d2dU, 0x111e0f0fU,\n        0xcb7bb0b0U, 0xfca85454U, 0xd66dbbbbU, 0x3a2c1616U,\n};\nstatic const u32 Te2[256] = {\n        0x63a5c663U, 0x7c84f87cU, 0x7799ee77U, 0x7b8df67bU,\n        0xf20dfff2U, 0x6bbdd66bU, 0x6fb1de6fU, 0xc55491c5U,\n        0x30506030U, 0x01030201U, 0x67a9ce67U, 0x2b7d562bU,\n        0xfe19e7feU, 0xd762b5d7U, 0xabe64dabU, 0x769aec76U,\n        0xca458fcaU, 0x829d1f82U, 0xc94089c9U, 0x7d87fa7dU,\n        0xfa15effaU, 0x59ebb259U, 0x47c98e47U, 0xf00bfbf0U,\n        0xadec41adU, 0xd467b3d4U, 0xa2fd5fa2U, 0xafea45afU,\n        0x9cbf239cU, 0xa4f753a4U, 0x7296e472U, 0xc05b9bc0U,\n        0xb7c275b7U, 0xfd1ce1fdU, 0x93ae3d93U, 0x266a4c26U,\n        0x365a6c36U, 0x3f417e3fU, 0xf702f5f7U, 0xcc4f83ccU,\n        0x345c6834U, 0xa5f451a5U, 0xe534d1e5U, 0xf108f9f1U,\n        0x7193e271U, 0xd873abd8U, 0x31536231U, 0x153f2a15U,\n        0x040c0804U, 0xc75295c7U, 0x23654623U, 0xc35e9dc3U,\n        0x18283018U, 0x96a13796U, 0x050f0a05U, 0x9ab52f9aU,\n        0x07090e07U, 0x12362412U, 0x809b1b80U, 0xe23ddfe2U,\n        0xeb26cdebU, 0x27694e27U, 0xb2cd7fb2U, 0x759fea75U,\n        0x091b1209U, 0x839e1d83U, 0x2c74582cU, 0x1a2e341aU,\n        0x1b2d361bU, 0x6eb2dc6eU, 0x5aeeb45aU, 0xa0fb5ba0U,\n        0x52f6a452U, 0x3b4d763bU, 0xd661b7d6U, 0xb3ce7db3U,\n        0x297b5229U, 0xe33edde3U, 0x2f715e2fU, 0x84971384U,\n        0x53f5a653U, 0xd168b9d1U, 0x00000000U, 0xed2cc1edU,\n        0x20604020U, 0xfc1fe3fcU, 0xb1c879b1U, 0x5bedb65bU,\n        0x6abed46aU, 0xcb468dcbU, 0xbed967beU, 0x394b7239U,\n        0x4ade944aU, 0x4cd4984cU, 0x58e8b058U, 0xcf4a85cfU,\n        0xd06bbbd0U, 0xef2ac5efU, 0xaae54faaU, 0xfb16edfbU,\n        0x43c58643U, 0x4dd79a4dU, 0x33556633U, 0x85941185U,\n        0x45cf8a45U, 0xf910e9f9U, 0x02060402U, 0x7f81fe7fU,\n        0x50f0a050U, 0x3c44783cU, 0x9fba259fU, 0xa8e34ba8U,\n        0x51f3a251U, 0xa3fe5da3U, 0x40c08040U, 0x8f8a058fU,\n        0x92ad3f92U, 0x9dbc219dU, 0x38487038U, 0xf504f1f5U,\n        0xbcdf63bcU, 0xb6c177b6U, 0xda75afdaU, 0x21634221U,\n        0x10302010U, 0xff1ae5ffU, 0xf30efdf3U, 0xd26dbfd2U,\n        0xcd4c81cdU, 0x0c14180cU, 0x13352613U, 0xec2fc3ecU,\n        0x5fe1be5fU, 0x97a23597U, 0x44cc8844U, 0x17392e17U,\n        0xc45793c4U, 0xa7f255a7U, 0x7e82fc7eU, 0x3d477a3dU,\n        0x64acc864U, 0x5de7ba5dU, 0x192b3219U, 0x7395e673U,\n        0x60a0c060U, 0x81981981U, 0x4fd19e4fU, 0xdc7fa3dcU,\n        0x22664422U, 0x2a7e542aU, 0x90ab3b90U, 0x88830b88U,\n        0x46ca8c46U, 0xee29c7eeU, 0xb8d36bb8U, 0x143c2814U,\n        0xde79a7deU, 0x5ee2bc5eU, 0x0b1d160bU, 0xdb76addbU,\n        0xe03bdbe0U, 0x32566432U, 0x3a4e743aU, 0x0a1e140aU,\n        0x49db9249U, 0x060a0c06U, 0x246c4824U, 0x5ce4b85cU,\n        0xc25d9fc2U, 0xd36ebdd3U, 0xacef43acU, 0x62a6c462U,\n        0x91a83991U, 0x95a43195U, 0xe437d3e4U, 0x798bf279U,\n        0xe732d5e7U, 0xc8438bc8U, 0x37596e37U, 0x6db7da6dU,\n        0x8d8c018dU, 0xd564b1d5U, 0x4ed29c4eU, 0xa9e049a9U,\n        0x6cb4d86cU, 0x56faac56U, 0xf407f3f4U, 0xea25cfeaU,\n        0x65afca65U, 0x7a8ef47aU, 0xaee947aeU, 0x08181008U,\n        0xbad56fbaU, 0x7888f078U, 0x256f4a25U, 0x2e725c2eU,\n        0x1c24381cU, 0xa6f157a6U, 0xb4c773b4U, 0xc65197c6U,\n        0xe823cbe8U, 0xdd7ca1ddU, 0x749ce874U, 0x1f213e1fU,\n        0x4bdd964bU, 0xbddc61bdU, 0x8b860d8bU, 0x8a850f8aU,\n        0x7090e070U, 0x3e427c3eU, 0xb5c471b5U, 0x66aacc66U,\n        0x48d89048U, 0x03050603U, 0xf601f7f6U, 0x0e121c0eU,\n        0x61a3c261U, 0x355f6a35U, 0x57f9ae57U, 0xb9d069b9U,\n        0x86911786U, 0xc15899c1U, 0x1d273a1dU, 0x9eb9279eU,\n        0xe138d9e1U, 0xf813ebf8U, 0x98b32b98U, 0x11332211U,\n        0x69bbd269U, 0xd970a9d9U, 0x8e89078eU, 0x94a73394U,\n        0x9bb62d9bU, 0x1e223c1eU, 0x87921587U, 0xe920c9e9U,\n        0xce4987ceU, 0x55ffaa55U, 0x28785028U, 0xdf7aa5dfU,\n        0x8c8f038cU, 0xa1f859a1U, 0x89800989U, 0x0d171a0dU,\n        0xbfda65bfU, 0xe631d7e6U, 0x42c68442U, 0x68b8d068U,\n        0x41c38241U, 0x99b02999U, 0x2d775a2dU, 0x0f111e0fU,\n        0xb0cb7bb0U, 0x54fca854U, 0xbbd66dbbU, 0x163a2c16U,\n};\nstatic const u32 Te3[256] = {\n\n        0x6363a5c6U, 0x7c7c84f8U, 0x777799eeU, 0x7b7b8df6U,\n        0xf2f20dffU, 0x6b6bbdd6U, 0x6f6fb1deU, 0xc5c55491U,\n        0x30305060U, 0x01010302U, 0x6767a9ceU, 0x2b2b7d56U,\n        0xfefe19e7U, 0xd7d762b5U, 0xababe64dU, 0x76769aecU,\n        0xcaca458fU, 0x82829d1fU, 0xc9c94089U, 0x7d7d87faU,\n        0xfafa15efU, 0x5959ebb2U, 0x4747c98eU, 0xf0f00bfbU,\n        0xadadec41U, 0xd4d467b3U, 0xa2a2fd5fU, 0xafafea45U,\n        0x9c9cbf23U, 0xa4a4f753U, 0x727296e4U, 0xc0c05b9bU,\n        0xb7b7c275U, 0xfdfd1ce1U, 0x9393ae3dU, 0x26266a4cU,\n        0x36365a6cU, 0x3f3f417eU, 0xf7f702f5U, 0xcccc4f83U,\n        0x34345c68U, 0xa5a5f451U, 0xe5e534d1U, 0xf1f108f9U,\n        0x717193e2U, 0xd8d873abU, 0x31315362U, 0x15153f2aU,\n        0x04040c08U, 0xc7c75295U, 0x23236546U, 0xc3c35e9dU,\n        0x18182830U, 0x9696a137U, 0x05050f0aU, 0x9a9ab52fU,\n        0x0707090eU, 0x12123624U, 0x80809b1bU, 0xe2e23ddfU,\n        0xebeb26cdU, 0x2727694eU, 0xb2b2cd7fU, 0x75759feaU,\n        0x09091b12U, 0x83839e1dU, 0x2c2c7458U, 0x1a1a2e34U,\n        0x1b1b2d36U, 0x6e6eb2dcU, 0x5a5aeeb4U, 0xa0a0fb5bU,\n        0x5252f6a4U, 0x3b3b4d76U, 0xd6d661b7U, 0xb3b3ce7dU,\n        0x29297b52U, 0xe3e33eddU, 0x2f2f715eU, 0x84849713U,\n        0x5353f5a6U, 0xd1d168b9U, 0x00000000U, 0xeded2cc1U,\n        0x20206040U, 0xfcfc1fe3U, 0xb1b1c879U, 0x5b5bedb6U,\n        0x6a6abed4U, 0xcbcb468dU, 0xbebed967U, 0x39394b72U,\n        0x4a4ade94U, 0x4c4cd498U, 0x5858e8b0U, 0xcfcf4a85U,\n        0xd0d06bbbU, 0xefef2ac5U, 0xaaaae54fU, 0xfbfb16edU,\n        0x4343c586U, 0x4d4dd79aU, 0x33335566U, 0x85859411U,\n        0x4545cf8aU, 0xf9f910e9U, 0x02020604U, 0x7f7f81feU,\n        0x5050f0a0U, 0x3c3c4478U, 0x9f9fba25U, 0xa8a8e34bU,\n        0x5151f3a2U, 0xa3a3fe5dU, 0x4040c080U, 0x8f8f8a05U,\n        0x9292ad3fU, 0x9d9dbc21U, 0x38384870U, 0xf5f504f1U,\n        0xbcbcdf63U, 0xb6b6c177U, 0xdada75afU, 0x21216342U,\n        0x10103020U, 0xffff1ae5U, 0xf3f30efdU, 0xd2d26dbfU,\n        0xcdcd4c81U, 0x0c0c1418U, 0x13133526U, 0xecec2fc3U,\n        0x5f5fe1beU, 0x9797a235U, 0x4444cc88U, 0x1717392eU,\n        0xc4c45793U, 0xa7a7f255U, 0x7e7e82fcU, 0x3d3d477aU,\n        0x6464acc8U, 0x5d5de7baU, 0x19192b32U, 0x737395e6U,\n        0x6060a0c0U, 0x81819819U, 0x4f4fd19eU, 0xdcdc7fa3U,\n        0x22226644U, 0x2a2a7e54U, 0x9090ab3bU, 0x8888830bU,\n        0x4646ca8cU, 0xeeee29c7U, 0xb8b8d36bU, 0x14143c28U,\n        0xdede79a7U, 0x5e5ee2bcU, 0x0b0b1d16U, 0xdbdb76adU,\n        0xe0e03bdbU, 0x32325664U, 0x3a3a4e74U, 0x0a0a1e14U,\n        0x4949db92U, 0x06060a0cU, 0x24246c48U, 0x5c5ce4b8U,\n        0xc2c25d9fU, 0xd3d36ebdU, 0xacacef43U, 0x6262a6c4U,\n        0x9191a839U, 0x9595a431U, 0xe4e437d3U, 0x79798bf2U,\n        0xe7e732d5U, 0xc8c8438bU, 0x3737596eU, 0x6d6db7daU,\n        0x8d8d8c01U, 0xd5d564b1U, 0x4e4ed29cU, 0xa9a9e049U,\n        0x6c6cb4d8U, 0x5656faacU, 0xf4f407f3U, 0xeaea25cfU,\n        0x6565afcaU, 0x7a7a8ef4U, 0xaeaee947U, 0x08081810U,\n        0xbabad56fU, 0x787888f0U, 0x25256f4aU, 0x2e2e725cU,\n        0x1c1c2438U, 0xa6a6f157U, 0xb4b4c773U, 0xc6c65197U,\n        0xe8e823cbU, 0xdddd7ca1U, 0x74749ce8U, 0x1f1f213eU,\n        0x4b4bdd96U, 0xbdbddc61U, 0x8b8b860dU, 0x8a8a850fU,\n        0x707090e0U, 0x3e3e427cU, 0xb5b5c471U, 0x6666aaccU,\n        0x4848d890U, 0x03030506U, 0xf6f601f7U, 0x0e0e121cU,\n        0x6161a3c2U, 0x35355f6aU, 0x5757f9aeU, 0xb9b9d069U,\n        0x86869117U, 0xc1c15899U, 0x1d1d273aU, 0x9e9eb927U,\n        0xe1e138d9U, 0xf8f813ebU, 0x9898b32bU, 0x11113322U,\n        0x6969bbd2U, 0xd9d970a9U, 0x8e8e8907U, 0x9494a733U,\n        0x9b9bb62dU, 0x1e1e223cU, 0x87879215U, 0xe9e920c9U,\n        0xcece4987U, 0x5555ffaaU, 0x28287850U, 0xdfdf7aa5U,\n        0x8c8c8f03U, 0xa1a1f859U, 0x89898009U, 0x0d0d171aU,\n        0xbfbfda65U, 0xe6e631d7U, 0x4242c684U, 0x6868b8d0U,\n        0x4141c382U, 0x9999b029U, 0x2d2d775aU, 0x0f0f111eU,\n        0xb0b0cb7bU, 0x5454fca8U, 0xbbbbd66dU, 0x16163a2cU,\n};\nstatic const u32 Te4[256] = {\n        0x63636363U, 0x7c7c7c7cU, 0x77777777U, 0x7b7b7b7bU,\n        0xf2f2f2f2U, 0x6b6b6b6bU, 0x6f6f6f6fU, 0xc5c5c5c5U,\n        0x30303030U, 0x01010101U, 0x67676767U, 0x2b2b2b2bU,\n        0xfefefefeU, 0xd7d7d7d7U, 0xababababU, 0x76767676U,\n        0xcacacacaU, 0x82828282U, 0xc9c9c9c9U, 0x7d7d7d7dU,\n        0xfafafafaU, 0x59595959U, 0x47474747U, 0xf0f0f0f0U,\n        0xadadadadU, 0xd4d4d4d4U, 0xa2a2a2a2U, 0xafafafafU,\n        0x9c9c9c9cU, 0xa4a4a4a4U, 0x72727272U, 0xc0c0c0c0U,\n        0xb7b7b7b7U, 0xfdfdfdfdU, 0x93939393U, 0x26262626U,\n        0x36363636U, 0x3f3f3f3fU, 0xf7f7f7f7U, 0xccccccccU,\n        0x34343434U, 0xa5a5a5a5U, 0xe5e5e5e5U, 0xf1f1f1f1U,\n        0x71717171U, 0xd8d8d8d8U, 0x31313131U, 0x15151515U,\n        0x04040404U, 0xc7c7c7c7U, 0x23232323U, 0xc3c3c3c3U,\n        0x18181818U, 0x96969696U, 0x05050505U, 0x9a9a9a9aU,\n        0x07070707U, 0x12121212U, 0x80808080U, 0xe2e2e2e2U,\n        0xebebebebU, 0x27272727U, 0xb2b2b2b2U, 0x75757575U,\n        0x09090909U, 0x83838383U, 0x2c2c2c2cU, 0x1a1a1a1aU,\n        0x1b1b1b1bU, 0x6e6e6e6eU, 0x5a5a5a5aU, 0xa0a0a0a0U,\n        0x52525252U, 0x3b3b3b3bU, 0xd6d6d6d6U, 0xb3b3b3b3U,\n        0x29292929U, 0xe3e3e3e3U, 0x2f2f2f2fU, 0x84848484U,\n        0x53535353U, 0xd1d1d1d1U, 0x00000000U, 0xededededU,\n        0x20202020U, 0xfcfcfcfcU, 0xb1b1b1b1U, 0x5b5b5b5bU,\n        0x6a6a6a6aU, 0xcbcbcbcbU, 0xbebebebeU, 0x39393939U,\n        0x4a4a4a4aU, 0x4c4c4c4cU, 0x58585858U, 0xcfcfcfcfU,\n        0xd0d0d0d0U, 0xefefefefU, 0xaaaaaaaaU, 0xfbfbfbfbU,\n        0x43434343U, 0x4d4d4d4dU, 0x33333333U, 0x85858585U,\n        0x45454545U, 0xf9f9f9f9U, 0x02020202U, 0x7f7f7f7fU,\n        0x50505050U, 0x3c3c3c3cU, 0x9f9f9f9fU, 0xa8a8a8a8U,\n        0x51515151U, 0xa3a3a3a3U, 0x40404040U, 0x8f8f8f8fU,\n        0x92929292U, 0x9d9d9d9dU, 0x38383838U, 0xf5f5f5f5U,\n        0xbcbcbcbcU, 0xb6b6b6b6U, 0xdadadadaU, 0x21212121U,\n        0x10101010U, 0xffffffffU, 0xf3f3f3f3U, 0xd2d2d2d2U,\n        0xcdcdcdcdU, 0x0c0c0c0cU, 0x13131313U, 0xececececU,\n        0x5f5f5f5fU, 0x97979797U, 0x44444444U, 0x17171717U,\n        0xc4c4c4c4U, 0xa7a7a7a7U, 0x7e7e7e7eU, 0x3d3d3d3dU,\n        0x64646464U, 0x5d5d5d5dU, 0x19191919U, 0x73737373U,\n        0x60606060U, 0x81818181U, 0x4f4f4f4fU, 0xdcdcdcdcU,\n        0x22222222U, 0x2a2a2a2aU, 0x90909090U, 0x88888888U,\n        0x46464646U, 0xeeeeeeeeU, 0xb8b8b8b8U, 0x14141414U,\n        0xdedededeU, 0x5e5e5e5eU, 0x0b0b0b0bU, 0xdbdbdbdbU,\n        0xe0e0e0e0U, 0x32323232U, 0x3a3a3a3aU, 0x0a0a0a0aU,\n        0x49494949U, 0x06060606U, 0x24242424U, 0x5c5c5c5cU,\n        0xc2c2c2c2U, 0xd3d3d3d3U, 0xacacacacU, 0x62626262U,\n        0x91919191U, 0x95959595U, 0xe4e4e4e4U, 0x79797979U,\n        0xe7e7e7e7U, 0xc8c8c8c8U, 0x37373737U, 0x6d6d6d6dU,\n        0x8d8d8d8dU, 0xd5d5d5d5U, 0x4e4e4e4eU, 0xa9a9a9a9U,\n        0x6c6c6c6cU, 0x56565656U, 0xf4f4f4f4U, 0xeaeaeaeaU,\n        0x65656565U, 0x7a7a7a7aU, 0xaeaeaeaeU, 0x08080808U,\n        0xbabababaU, 0x78787878U, 0x25252525U, 0x2e2e2e2eU,\n        0x1c1c1c1cU, 0xa6a6a6a6U, 0xb4b4b4b4U, 0xc6c6c6c6U,\n        0xe8e8e8e8U, 0xddddddddU, 0x74747474U, 0x1f1f1f1fU,\n        0x4b4b4b4bU, 0xbdbdbdbdU, 0x8b8b8b8bU, 0x8a8a8a8aU,\n        0x70707070U, 0x3e3e3e3eU, 0xb5b5b5b5U, 0x66666666U,\n        0x48484848U, 0x03030303U, 0xf6f6f6f6U, 0x0e0e0e0eU,\n        0x61616161U, 0x35353535U, 0x57575757U, 0xb9b9b9b9U,\n        0x86868686U, 0xc1c1c1c1U, 0x1d1d1d1dU, 0x9e9e9e9eU,\n        0xe1e1e1e1U, 0xf8f8f8f8U, 0x98989898U, 0x11111111U,\n        0x69696969U, 0xd9d9d9d9U, 0x8e8e8e8eU, 0x94949494U,\n        0x9b9b9b9bU, 0x1e1e1e1eU, 0x87878787U, 0xe9e9e9e9U,\n        0xcecececeU, 0x55555555U, 0x28282828U, 0xdfdfdfdfU,\n        0x8c8c8c8cU, 0xa1a1a1a1U, 0x89898989U, 0x0d0d0d0dU,\n        0xbfbfbfbfU, 0xe6e6e6e6U, 0x42424242U, 0x68686868U,\n        0x41414141U, 0x99999999U, 0x2d2d2d2dU, 0x0f0f0f0fU,\n        0xb0b0b0b0U, 0x54545454U, 0xbbbbbbbbU, 0x16161616U,\n};\nstatic const u32 Td0[256] = {\n        0x51f4a750U, 0x7e416553U, 0x1a17a4c3U, 0x3a275e96U,\n        0x3bab6bcbU, 0x1f9d45f1U, 0xacfa58abU, 0x4be30393U,\n        0x2030fa55U, 0xad766df6U, 0x88cc7691U, 0xf5024c25U,\n        0x4fe5d7fcU, 0xc52acbd7U, 0x26354480U, 0xb562a38fU,\n        0xdeb15a49U, 0x25ba1b67U, 0x45ea0e98U, 0x5dfec0e1U,\n        0xc32f7502U, 0x814cf012U, 0x8d4697a3U, 0x6bd3f9c6U,\n        0x038f5fe7U, 0x15929c95U, 0xbf6d7aebU, 0x955259daU,\n        0xd4be832dU, 0x587421d3U, 0x49e06929U, 0x8ec9c844U,\n        0x75c2896aU, 0xf48e7978U, 0x99583e6bU, 0x27b971ddU,\n        0xbee14fb6U, 0xf088ad17U, 0xc920ac66U, 0x7dce3ab4U,\n        0x63df4a18U, 0xe51a3182U, 0x97513360U, 0x62537f45U,\n        0xb16477e0U, 0xbb6bae84U, 0xfe81a01cU, 0xf9082b94U,\n        0x70486858U, 0x8f45fd19U, 0x94de6c87U, 0x527bf8b7U,\n        0xab73d323U, 0x724b02e2U, 0xe31f8f57U, 0x6655ab2aU,\n        0xb2eb2807U, 0x2fb5c203U, 0x86c57b9aU, 0xd33708a5U,\n        0x302887f2U, 0x23bfa5b2U, 0x02036abaU, 0xed16825cU,\n        0x8acf1c2bU, 0xa779b492U, 0xf307f2f0U, 0x4e69e2a1U,\n        0x65daf4cdU, 0x0605bed5U, 0xd134621fU, 0xc4a6fe8aU,\n        0x342e539dU, 0xa2f355a0U, 0x058ae132U, 0xa4f6eb75U,\n        0x0b83ec39U, 0x4060efaaU, 0x5e719f06U, 0xbd6e1051U,\n        0x3e218af9U, 0x96dd063dU, 0xdd3e05aeU, 0x4de6bd46U,\n        0x91548db5U, 0x71c45d05U, 0x0406d46fU, 0x605015ffU,\n        0x1998fb24U, 0xd6bde997U, 0x894043ccU, 0x67d99e77U,\n        0xb0e842bdU, 0x07898b88U, 0xe7195b38U, 0x79c8eedbU,\n        0xa17c0a47U, 0x7c420fe9U, 0xf8841ec9U, 0x00000000U,\n        0x09808683U, 0x322bed48U, 0x1e1170acU, 0x6c5a724eU,\n        0xfd0efffbU, 0x0f853856U, 0x3daed51eU, 0x362d3927U,\n        0x0a0fd964U, 0x685ca621U, 0x9b5b54d1U, 0x24362e3aU,\n        0x0c0a67b1U, 0x9357e70fU, 0xb4ee96d2U, 0x1b9b919eU,\n        0x80c0c54fU, 0x61dc20a2U, 0x5a774b69U, 0x1c121a16U,\n        0xe293ba0aU, 0xc0a02ae5U, 0x3c22e043U, 0x121b171dU,\n        0x0e090d0bU, 0xf28bc7adU, 0x2db6a8b9U, 0x141ea9c8U,\n        0x57f11985U, 0xaf75074cU, 0xee99ddbbU, 0xa37f60fdU,\n        0xf701269fU, 0x5c72f5bcU, 0x44663bc5U, 0x5bfb7e34U,\n        0x8b432976U, 0xcb23c6dcU, 0xb6edfc68U, 0xb8e4f163U,\n        0xd731dccaU, 0x42638510U, 0x13972240U, 0x84c61120U,\n        0x854a247dU, 0xd2bb3df8U, 0xaef93211U, 0xc729a16dU,\n        0x1d9e2f4bU, 0xdcb230f3U, 0x0d8652ecU, 0x77c1e3d0U,\n        0x2bb3166cU, 0xa970b999U, 0x119448faU, 0x47e96422U,\n        0xa8fc8cc4U, 0xa0f03f1aU, 0x567d2cd8U, 0x223390efU,\n        0x87494ec7U, 0xd938d1c1U, 0x8ccaa2feU, 0x98d40b36U,\n        0xa6f581cfU, 0xa57ade28U, 0xdab78e26U, 0x3fadbfa4U,\n        0x2c3a9de4U, 0x5078920dU, 0x6a5fcc9bU, 0x547e4662U,\n        0xf68d13c2U, 0x90d8b8e8U, 0x2e39f75eU, 0x82c3aff5U,\n        0x9f5d80beU, 0x69d0937cU, 0x6fd52da9U, 0xcf2512b3U,\n        0xc8ac993bU, 0x10187da7U, 0xe89c636eU, 0xdb3bbb7bU,\n        0xcd267809U, 0x6e5918f4U, 0xec9ab701U, 0x834f9aa8U,\n        0xe6956e65U, 0xaaffe67eU, 0x21bccf08U, 0xef15e8e6U,\n        0xbae79bd9U, 0x4a6f36ceU, 0xea9f09d4U, 0x29b07cd6U,\n        0x31a4b2afU, 0x2a3f2331U, 0xc6a59430U, 0x35a266c0U,\n        0x744ebc37U, 0xfc82caa6U, 0xe090d0b0U, 0x33a7d815U,\n        0xf104984aU, 0x41ecdaf7U, 0x7fcd500eU, 0x1791f62fU,\n        0x764dd68dU, 0x43efb04dU, 0xccaa4d54U, 0xe49604dfU,\n        0x9ed1b5e3U, 0x4c6a881bU, 0xc12c1fb8U, 0x4665517fU,\n        0x9d5eea04U, 0x018c355dU, 0xfa877473U, 0xfb0b412eU,\n        0xb3671d5aU, 0x92dbd252U, 0xe9105633U, 0x6dd64713U,\n        0x9ad7618cU, 0x37a10c7aU, 0x59f8148eU, 0xeb133c89U,\n        0xcea927eeU, 0xb761c935U, 0xe11ce5edU, 0x7a47b13cU,\n        0x9cd2df59U, 0x55f2733fU, 0x1814ce79U, 0x73c737bfU,\n        0x53f7cdeaU, 0x5ffdaa5bU, 0xdf3d6f14U, 0x7844db86U,\n        0xcaaff381U, 0xb968c43eU, 0x3824342cU, 0xc2a3405fU,\n        0x161dc372U, 0xbce2250cU, 0x283c498bU, 0xff0d9541U,\n        0x39a80171U, 0x080cb3deU, 0xd8b4e49cU, 0x6456c190U,\n        0x7bcb8461U, 0xd532b670U, 0x486c5c74U, 0xd0b85742U,\n};\nstatic const u32 Td1[256] = {\n        0x5051f4a7U, 0x537e4165U, 0xc31a17a4U, 0x963a275eU,\n        0xcb3bab6bU, 0xf11f9d45U, 0xabacfa58U, 0x934be303U,\n        0x552030faU, 0xf6ad766dU, 0x9188cc76U, 0x25f5024cU,\n        0xfc4fe5d7U, 0xd7c52acbU, 0x80263544U, 0x8fb562a3U,\n        0x49deb15aU, 0x6725ba1bU, 0x9845ea0eU, 0xe15dfec0U,\n        0x02c32f75U, 0x12814cf0U, 0xa38d4697U, 0xc66bd3f9U,\n        0xe7038f5fU, 0x9515929cU, 0xebbf6d7aU, 0xda955259U,\n        0x2dd4be83U, 0xd3587421U, 0x2949e069U, 0x448ec9c8U,\n        0x6a75c289U, 0x78f48e79U, 0x6b99583eU, 0xdd27b971U,\n        0xb6bee14fU, 0x17f088adU, 0x66c920acU, 0xb47dce3aU,\n        0x1863df4aU, 0x82e51a31U, 0x60975133U, 0x4562537fU,\n        0xe0b16477U, 0x84bb6baeU, 0x1cfe81a0U, 0x94f9082bU,\n        0x58704868U, 0x198f45fdU, 0x8794de6cU, 0xb7527bf8U,\n        0x23ab73d3U, 0xe2724b02U, 0x57e31f8fU, 0x2a6655abU,\n        0x07b2eb28U, 0x032fb5c2U, 0x9a86c57bU, 0xa5d33708U,\n        0xf2302887U, 0xb223bfa5U, 0xba02036aU, 0x5ced1682U,\n        0x2b8acf1cU, 0x92a779b4U, 0xf0f307f2U, 0xa14e69e2U,\n        0xcd65daf4U, 0xd50605beU, 0x1fd13462U, 0x8ac4a6feU,\n        0x9d342e53U, 0xa0a2f355U, 0x32058ae1U, 0x75a4f6ebU,\n        0x390b83ecU, 0xaa4060efU, 0x065e719fU, 0x51bd6e10U,\n        0xf93e218aU, 0x3d96dd06U, 0xaedd3e05U, 0x464de6bdU,\n        0xb591548dU, 0x0571c45dU, 0x6f0406d4U, 0xff605015U,\n        0x241998fbU, 0x97d6bde9U, 0xcc894043U, 0x7767d99eU,\n        0xbdb0e842U, 0x8807898bU, 0x38e7195bU, 0xdb79c8eeU,\n        0x47a17c0aU, 0xe97c420fU, 0xc9f8841eU, 0x00000000U,\n        0x83098086U, 0x48322bedU, 0xac1e1170U, 0x4e6c5a72U,\n        0xfbfd0effU, 0x560f8538U, 0x1e3daed5U, 0x27362d39U,\n        0x640a0fd9U, 0x21685ca6U, 0xd19b5b54U, 0x3a24362eU,\n        0xb10c0a67U, 0x0f9357e7U, 0xd2b4ee96U, 0x9e1b9b91U,\n        0x4f80c0c5U, 0xa261dc20U, 0x695a774bU, 0x161c121aU,\n        0x0ae293baU, 0xe5c0a02aU, 0x433c22e0U, 0x1d121b17U,\n        0x0b0e090dU, 0xadf28bc7U, 0xb92db6a8U, 0xc8141ea9U,\n        0x8557f119U, 0x4caf7507U, 0xbbee99ddU, 0xfda37f60U,\n        0x9ff70126U, 0xbc5c72f5U, 0xc544663bU, 0x345bfb7eU,\n        0x768b4329U, 0xdccb23c6U, 0x68b6edfcU, 0x63b8e4f1U,\n        0xcad731dcU, 0x10426385U, 0x40139722U, 0x2084c611U,\n        0x7d854a24U, 0xf8d2bb3dU, 0x11aef932U, 0x6dc729a1U,\n        0x4b1d9e2fU, 0xf3dcb230U, 0xec0d8652U, 0xd077c1e3U,\n        0x6c2bb316U, 0x99a970b9U, 0xfa119448U, 0x2247e964U,\n        0xc4a8fc8cU, 0x1aa0f03fU, 0xd8567d2cU, 0xef223390U,\n        0xc787494eU, 0xc1d938d1U, 0xfe8ccaa2U, 0x3698d40bU,\n        0xcfa6f581U, 0x28a57adeU, 0x26dab78eU, 0xa43fadbfU,\n        0xe42c3a9dU, 0x0d507892U, 0x9b6a5fccU, 0x62547e46U,\n        0xc2f68d13U, 0xe890d8b8U, 0x5e2e39f7U, 0xf582c3afU,\n        0xbe9f5d80U, 0x7c69d093U, 0xa96fd52dU, 0xb3cf2512U,\n        0x3bc8ac99U, 0xa710187dU, 0x6ee89c63U, 0x7bdb3bbbU,\n        0x09cd2678U, 0xf46e5918U, 0x01ec9ab7U, 0xa8834f9aU,\n        0x65e6956eU, 0x7eaaffe6U, 0x0821bccfU, 0xe6ef15e8U,\n        0xd9bae79bU, 0xce4a6f36U, 0xd4ea9f09U, 0xd629b07cU,\n        0xaf31a4b2U, 0x312a3f23U, 0x30c6a594U, 0xc035a266U,\n        0x37744ebcU, 0xa6fc82caU, 0xb0e090d0U, 0x1533a7d8U,\n        0x4af10498U, 0xf741ecdaU, 0x0e7fcd50U, 0x2f1791f6U,\n        0x8d764dd6U, 0x4d43efb0U, 0x54ccaa4dU, 0xdfe49604U,\n        0xe39ed1b5U, 0x1b4c6a88U, 0xb8c12c1fU, 0x7f466551U,\n        0x049d5eeaU, 0x5d018c35U, 0x73fa8774U, 0x2efb0b41U,\n        0x5ab3671dU, 0x5292dbd2U, 0x33e91056U, 0x136dd647U,\n        0x8c9ad761U, 0x7a37a10cU, 0x8e59f814U, 0x89eb133cU,\n        0xeecea927U, 0x35b761c9U, 0xede11ce5U, 0x3c7a47b1U,\n        0x599cd2dfU, 0x3f55f273U, 0x791814ceU, 0xbf73c737U,\n        0xea53f7cdU, 0x5b5ffdaaU, 0x14df3d6fU, 0x867844dbU,\n        0x81caaff3U, 0x3eb968c4U, 0x2c382434U, 0x5fc2a340U,\n        0x72161dc3U, 0x0cbce225U, 0x8b283c49U, 0x41ff0d95U,\n        0x7139a801U, 0xde080cb3U, 0x9cd8b4e4U, 0x906456c1U,\n        0x617bcb84U, 0x70d532b6U, 0x74486c5cU, 0x42d0b857U,\n};\nstatic const u32 Td2[256] = {\n        0xa75051f4U, 0x65537e41U, 0xa4c31a17U, 0x5e963a27U,\n        0x6bcb3babU, 0x45f11f9dU, 0x58abacfaU, 0x03934be3U,\n        0xfa552030U, 0x6df6ad76U, 0x769188ccU, 0x4c25f502U,\n        0xd7fc4fe5U, 0xcbd7c52aU, 0x44802635U, 0xa38fb562U,\n        0x5a49deb1U, 0x1b6725baU, 0x0e9845eaU, 0xc0e15dfeU,\n        0x7502c32fU, 0xf012814cU, 0x97a38d46U, 0xf9c66bd3U,\n        0x5fe7038fU, 0x9c951592U, 0x7aebbf6dU, 0x59da9552U,\n        0x832dd4beU, 0x21d35874U, 0x692949e0U, 0xc8448ec9U,\n        0x896a75c2U, 0x7978f48eU, 0x3e6b9958U, 0x71dd27b9U,\n        0x4fb6bee1U, 0xad17f088U, 0xac66c920U, 0x3ab47dceU,\n        0x4a1863dfU, 0x3182e51aU, 0x33609751U, 0x7f456253U,\n        0x77e0b164U, 0xae84bb6bU, 0xa01cfe81U, 0x2b94f908U,\n        0x68587048U, 0xfd198f45U, 0x6c8794deU, 0xf8b7527bU,\n        0xd323ab73U, 0x02e2724bU, 0x8f57e31fU, 0xab2a6655U,\n        0x2807b2ebU, 0xc2032fb5U, 0x7b9a86c5U, 0x08a5d337U,\n        0x87f23028U, 0xa5b223bfU, 0x6aba0203U, 0x825ced16U,\n        0x1c2b8acfU, 0xb492a779U, 0xf2f0f307U, 0xe2a14e69U,\n        0xf4cd65daU, 0xbed50605U, 0x621fd134U, 0xfe8ac4a6U,\n        0x539d342eU, 0x55a0a2f3U, 0xe132058aU, 0xeb75a4f6U,\n        0xec390b83U, 0xefaa4060U, 0x9f065e71U, 0x1051bd6eU,\n\n        0x8af93e21U, 0x063d96ddU, 0x05aedd3eU, 0xbd464de6U,\n        0x8db59154U, 0x5d0571c4U, 0xd46f0406U, 0x15ff6050U,\n        0xfb241998U, 0xe997d6bdU, 0x43cc8940U, 0x9e7767d9U,\n        0x42bdb0e8U, 0x8b880789U, 0x5b38e719U, 0xeedb79c8U,\n        0x0a47a17cU, 0x0fe97c42U, 0x1ec9f884U, 0x00000000U,\n        0x86830980U, 0xed48322bU, 0x70ac1e11U, 0x724e6c5aU,\n        0xfffbfd0eU, 0x38560f85U, 0xd51e3daeU, 0x3927362dU,\n        0xd9640a0fU, 0xa621685cU, 0x54d19b5bU, 0x2e3a2436U,\n        0x67b10c0aU, 0xe70f9357U, 0x96d2b4eeU, 0x919e1b9bU,\n        0xc54f80c0U, 0x20a261dcU, 0x4b695a77U, 0x1a161c12U,\n        0xba0ae293U, 0x2ae5c0a0U, 0xe0433c22U, 0x171d121bU,\n        0x0d0b0e09U, 0xc7adf28bU, 0xa8b92db6U, 0xa9c8141eU,\n        0x198557f1U, 0x074caf75U, 0xddbbee99U, 0x60fda37fU,\n        0x269ff701U, 0xf5bc5c72U, 0x3bc54466U, 0x7e345bfbU,\n        0x29768b43U, 0xc6dccb23U, 0xfc68b6edU, 0xf163b8e4U,\n        0xdccad731U, 0x85104263U, 0x22401397U, 0x112084c6U,\n        0x247d854aU, 0x3df8d2bbU, 0x3211aef9U, 0xa16dc729U,\n        0x2f4b1d9eU, 0x30f3dcb2U, 0x52ec0d86U, 0xe3d077c1U,\n        0x166c2bb3U, 0xb999a970U, 0x48fa1194U, 0x642247e9U,\n        0x8cc4a8fcU, 0x3f1aa0f0U, 0x2cd8567dU, 0x90ef2233U,\n        0x4ec78749U, 0xd1c1d938U, 0xa2fe8ccaU, 0x0b3698d4U,\n        0x81cfa6f5U, 0xde28a57aU, 0x8e26dab7U, 0xbfa43fadU,\n        0x9de42c3aU, 0x920d5078U, 0xcc9b6a5fU, 0x4662547eU,\n        0x13c2f68dU, 0xb8e890d8U, 0xf75e2e39U, 0xaff582c3U,\n        0x80be9f5dU, 0x937c69d0U, 0x2da96fd5U, 0x12b3cf25U,\n        0x993bc8acU, 0x7da71018U, 0x636ee89cU, 0xbb7bdb3bU,\n        0x7809cd26U, 0x18f46e59U, 0xb701ec9aU, 0x9aa8834fU,\n        0x6e65e695U, 0xe67eaaffU, 0xcf0821bcU, 0xe8e6ef15U,\n        0x9bd9bae7U, 0x36ce4a6fU, 0x09d4ea9fU, 0x7cd629b0U,\n        0xb2af31a4U, 0x23312a3fU, 0x9430c6a5U, 0x66c035a2U,\n        0xbc37744eU, 0xcaa6fc82U, 0xd0b0e090U, 0xd81533a7U,\n        0x984af104U, 0xdaf741ecU, 0x500e7fcdU, 0xf62f1791U,\n        0xd68d764dU, 0xb04d43efU, 0x4d54ccaaU, 0x04dfe496U,\n        0xb5e39ed1U, 0x881b4c6aU, 0x1fb8c12cU, 0x517f4665U,\n        0xea049d5eU, 0x355d018cU, 0x7473fa87U, 0x412efb0bU,\n        0x1d5ab367U, 0xd25292dbU, 0x5633e910U, 0x47136dd6U,\n        0x618c9ad7U, 0x0c7a37a1U, 0x148e59f8U, 0x3c89eb13U,\n        0x27eecea9U, 0xc935b761U, 0xe5ede11cU, 0xb13c7a47U,\n        0xdf599cd2U, 0x733f55f2U, 0xce791814U, 0x37bf73c7U,\n        0xcdea53f7U, 0xaa5b5ffdU, 0x6f14df3dU, 0xdb867844U,\n        0xf381caafU, 0xc43eb968U, 0x342c3824U, 0x405fc2a3U,\n        0xc372161dU, 0x250cbce2U, 0x498b283cU, 0x9541ff0dU,\n        0x017139a8U, 0xb3de080cU, 0xe49cd8b4U, 0xc1906456U,\n        0x84617bcbU, 0xb670d532U, 0x5c74486cU, 0x5742d0b8U,\n};\nstatic const u32 Td3[256] = {\n        0xf4a75051U, 0x4165537eU, 0x17a4c31aU, 0x275e963aU,\n        0xab6bcb3bU, 0x9d45f11fU, 0xfa58abacU, 0xe303934bU,\n        0x30fa5520U, 0x766df6adU, 0xcc769188U, 0x024c25f5U,\n        0xe5d7fc4fU, 0x2acbd7c5U, 0x35448026U, 0x62a38fb5U,\n        0xb15a49deU, 0xba1b6725U, 0xea0e9845U, 0xfec0e15dU,\n        0x2f7502c3U, 0x4cf01281U, 0x4697a38dU, 0xd3f9c66bU,\n        0x8f5fe703U, 0x929c9515U, 0x6d7aebbfU, 0x5259da95U,\n        0xbe832dd4U, 0x7421d358U, 0xe0692949U, 0xc9c8448eU,\n        0xc2896a75U, 0x8e7978f4U, 0x583e6b99U, 0xb971dd27U,\n        0xe14fb6beU, 0x88ad17f0U, 0x20ac66c9U, 0xce3ab47dU,\n        0xdf4a1863U, 0x1a3182e5U, 0x51336097U, 0x537f4562U,\n        0x6477e0b1U, 0x6bae84bbU, 0x81a01cfeU, 0x082b94f9U,\n        0x48685870U, 0x45fd198fU, 0xde6c8794U, 0x7bf8b752U,\n        0x73d323abU, 0x4b02e272U, 0x1f8f57e3U, 0x55ab2a66U,\n        0xeb2807b2U, 0xb5c2032fU, 0xc57b9a86U, 0x3708a5d3U,\n        0x2887f230U, 0xbfa5b223U, 0x036aba02U, 0x16825cedU,\n        0xcf1c2b8aU, 0x79b492a7U, 0x07f2f0f3U, 0x69e2a14eU,\n        0xdaf4cd65U, 0x05bed506U, 0x34621fd1U, 0xa6fe8ac4U,\n        0x2e539d34U, 0xf355a0a2U, 0x8ae13205U, 0xf6eb75a4U,\n        0x83ec390bU, 0x60efaa40U, 0x719f065eU, 0x6e1051bdU,\n        0x218af93eU, 0xdd063d96U, 0x3e05aeddU, 0xe6bd464dU,\n        0x548db591U, 0xc45d0571U, 0x06d46f04U, 0x5015ff60U,\n        0x98fb2419U, 0xbde997d6U, 0x4043cc89U, 0xd99e7767U,\n        0xe842bdb0U, 0x898b8807U, 0x195b38e7U, 0xc8eedb79U,\n        0x7c0a47a1U, 0x420fe97cU, 0x841ec9f8U, 0x00000000U,\n        0x80868309U, 0x2bed4832U, 0x1170ac1eU, 0x5a724e6cU,\n        0x0efffbfdU, 0x8538560fU, 0xaed51e3dU, 0x2d392736U,\n        0x0fd9640aU, 0x5ca62168U, 0x5b54d19bU, 0x362e3a24U,\n        0x0a67b10cU, 0x57e70f93U, 0xee96d2b4U, 0x9b919e1bU,\n        0xc0c54f80U, 0xdc20a261U, 0x774b695aU, 0x121a161cU,\n        0x93ba0ae2U, 0xa02ae5c0U, 0x22e0433cU, 0x1b171d12U,\n        0x090d0b0eU, 0x8bc7adf2U, 0xb6a8b92dU, 0x1ea9c814U,\n        0xf1198557U, 0x75074cafU, 0x99ddbbeeU, 0x7f60fda3U,\n        0x01269ff7U, 0x72f5bc5cU, 0x663bc544U, 0xfb7e345bU,\n        0x4329768bU, 0x23c6dccbU, 0xedfc68b6U, 0xe4f163b8U,\n        0x31dccad7U, 0x63851042U, 0x97224013U, 0xc6112084U,\n        0x4a247d85U, 0xbb3df8d2U, 0xf93211aeU, 0x29a16dc7U,\n        0x9e2f4b1dU, 0xb230f3dcU, 0x8652ec0dU, 0xc1e3d077U,\n        0xb3166c2bU, 0x70b999a9U, 0x9448fa11U, 0xe9642247U,\n        0xfc8cc4a8U, 0xf03f1aa0U, 0x7d2cd856U, 0x3390ef22U,\n        0x494ec787U, 0x38d1c1d9U, 0xcaa2fe8cU, 0xd40b3698U,\n        0xf581cfa6U, 0x7ade28a5U, 0xb78e26daU, 0xadbfa43fU,\n        0x3a9de42cU, 0x78920d50U, 0x5fcc9b6aU, 0x7e466254U,\n        0x8d13c2f6U, 0xd8b8e890U, 0x39f75e2eU, 0xc3aff582U,\n        0x5d80be9fU, 0xd0937c69U, 0xd52da96fU, 0x2512b3cfU,\n        0xac993bc8U, 0x187da710U, 0x9c636ee8U, 0x3bbb7bdbU,\n        0x267809cdU, 0x5918f46eU, 0x9ab701ecU, 0x4f9aa883U,\n        0x956e65e6U, 0xffe67eaaU, 0xbccf0821U, 0x15e8e6efU,\n        0xe79bd9baU, 0x6f36ce4aU, 0x9f09d4eaU, 0xb07cd629U,\n        0xa4b2af31U, 0x3f23312aU, 0xa59430c6U, 0xa266c035U,\n        0x4ebc3774U, 0x82caa6fcU, 0x90d0b0e0U, 0xa7d81533U,\n        0x04984af1U, 0xecdaf741U, 0xcd500e7fU, 0x91f62f17U,\n        0x4dd68d76U, 0xefb04d43U, 0xaa4d54ccU, 0x9604dfe4U,\n        0xd1b5e39eU, 0x6a881b4cU, 0x2c1fb8c1U, 0x65517f46U,\n        0x5eea049dU, 0x8c355d01U, 0x877473faU, 0x0b412efbU,\n        0x671d5ab3U, 0xdbd25292U, 0x105633e9U, 0xd647136dU,\n        0xd7618c9aU, 0xa10c7a37U, 0xf8148e59U, 0x133c89ebU,\n        0xa927eeceU, 0x61c935b7U, 0x1ce5ede1U, 0x47b13c7aU,\n        0xd2df599cU, 0xf2733f55U, 0x14ce7918U, 0xc737bf73U,\n        0xf7cdea53U, 0xfdaa5b5fU, 0x3d6f14dfU, 0x44db8678U,\n        0xaff381caU, 0x68c43eb9U, 0x24342c38U, 0xa3405fc2U,\n        0x1dc37216U, 0xe2250cbcU, 0x3c498b28U, 0x0d9541ffU,\n        0xa8017139U, 0x0cb3de08U, 0xb4e49cd8U, 0x56c19064U,\n        0xcb84617bU, 0x32b670d5U, 0x6c5c7448U, 0xb85742d0U,\n};\nstatic const u32 Td4[256] = {\n        0x52525252U, 0x09090909U, 0x6a6a6a6aU, 0xd5d5d5d5U,\n        0x30303030U, 0x36363636U, 0xa5a5a5a5U, 0x38383838U,\n        0xbfbfbfbfU, 0x40404040U, 0xa3a3a3a3U, 0x9e9e9e9eU,\n        0x81818181U, 0xf3f3f3f3U, 0xd7d7d7d7U, 0xfbfbfbfbU,\n        0x7c7c7c7cU, 0xe3e3e3e3U, 0x39393939U, 0x82828282U,\n        0x9b9b9b9bU, 0x2f2f2f2fU, 0xffffffffU, 0x87878787U,\n        0x34343434U, 0x8e8e8e8eU, 0x43434343U, 0x44444444U,\n        0xc4c4c4c4U, 0xdedededeU, 0xe9e9e9e9U, 0xcbcbcbcbU,\n        0x54545454U, 0x7b7b7b7bU, 0x94949494U, 0x32323232U,\n        0xa6a6a6a6U, 0xc2c2c2c2U, 0x23232323U, 0x3d3d3d3dU,\n        0xeeeeeeeeU, 0x4c4c4c4cU, 0x95959595U, 0x0b0b0b0bU,\n        0x42424242U, 0xfafafafaU, 0xc3c3c3c3U, 0x4e4e4e4eU,\n        0x08080808U, 0x2e2e2e2eU, 0xa1a1a1a1U, 0x66666666U,\n        0x28282828U, 0xd9d9d9d9U, 0x24242424U, 0xb2b2b2b2U,\n        0x76767676U, 0x5b5b5b5bU, 0xa2a2a2a2U, 0x49494949U,\n        0x6d6d6d6dU, 0x8b8b8b8bU, 0xd1d1d1d1U, 0x25252525U,\n        0x72727272U, 0xf8f8f8f8U, 0xf6f6f6f6U, 0x64646464U,\n        0x86868686U, 0x68686868U, 0x98989898U, 0x16161616U,\n        0xd4d4d4d4U, 0xa4a4a4a4U, 0x5c5c5c5cU, 0xccccccccU,\n        0x5d5d5d5dU, 0x65656565U, 0xb6b6b6b6U, 0x92929292U,\n        0x6c6c6c6cU, 0x70707070U, 0x48484848U, 0x50505050U,\n        0xfdfdfdfdU, 0xededededU, 0xb9b9b9b9U, 0xdadadadaU,\n        0x5e5e5e5eU, 0x15151515U, 0x46464646U, 0x57575757U,\n        0xa7a7a7a7U, 0x8d8d8d8dU, 0x9d9d9d9dU, 0x84848484U,\n        0x90909090U, 0xd8d8d8d8U, 0xababababU, 0x00000000U,\n        0x8c8c8c8cU, 0xbcbcbcbcU, 0xd3d3d3d3U, 0x0a0a0a0aU,\n        0xf7f7f7f7U, 0xe4e4e4e4U, 0x58585858U, 0x05050505U,\n        0xb8b8b8b8U, 0xb3b3b3b3U, 0x45454545U, 0x06060606U,\n        0xd0d0d0d0U, 0x2c2c2c2cU, 0x1e1e1e1eU, 0x8f8f8f8fU,\n        0xcacacacaU, 0x3f3f3f3fU, 0x0f0f0f0fU, 0x02020202U,\n        0xc1c1c1c1U, 0xafafafafU, 0xbdbdbdbdU, 0x03030303U,\n        0x01010101U, 0x13131313U, 0x8a8a8a8aU, 0x6b6b6b6bU,\n        0x3a3a3a3aU, 0x91919191U, 0x11111111U, 0x41414141U,\n        0x4f4f4f4fU, 0x67676767U, 0xdcdcdcdcU, 0xeaeaeaeaU,\n        0x97979797U, 0xf2f2f2f2U, 0xcfcfcfcfU, 0xcecececeU,\n        0xf0f0f0f0U, 0xb4b4b4b4U, 0xe6e6e6e6U, 0x73737373U,\n        0x96969696U, 0xacacacacU, 0x74747474U, 0x22222222U,\n        0xe7e7e7e7U, 0xadadadadU, 0x35353535U, 0x85858585U,\n        0xe2e2e2e2U, 0xf9f9f9f9U, 0x37373737U, 0xe8e8e8e8U,\n        0x1c1c1c1cU, 0x75757575U, 0xdfdfdfdfU, 0x6e6e6e6eU,\n        0x47474747U, 0xf1f1f1f1U, 0x1a1a1a1aU, 0x71717171U,\n        0x1d1d1d1dU, 0x29292929U, 0xc5c5c5c5U, 0x89898989U,\n        0x6f6f6f6fU, 0xb7b7b7b7U, 0x62626262U, 0x0e0e0e0eU,\n        0xaaaaaaaaU, 0x18181818U, 0xbebebebeU, 0x1b1b1b1bU,\n        0xfcfcfcfcU, 0x56565656U, 0x3e3e3e3eU, 0x4b4b4b4bU,\n        0xc6c6c6c6U, 0xd2d2d2d2U, 0x79797979U, 0x20202020U,\n        0x9a9a9a9aU, 0xdbdbdbdbU, 0xc0c0c0c0U, 0xfefefefeU,\n        0x78787878U, 0xcdcdcdcdU, 0x5a5a5a5aU, 0xf4f4f4f4U,\n        0x1f1f1f1fU, 0xddddddddU, 0xa8a8a8a8U, 0x33333333U,\n        0x88888888U, 0x07070707U, 0xc7c7c7c7U, 0x31313131U,\n        0xb1b1b1b1U, 0x12121212U, 0x10101010U, 0x59595959U,\n        0x27272727U, 0x80808080U, 0xececececU, 0x5f5f5f5fU,\n        0x60606060U, 0x51515151U, 0x7f7f7f7fU, 0xa9a9a9a9U,\n        0x19191919U, 0xb5b5b5b5U, 0x4a4a4a4aU, 0x0d0d0d0dU,\n        0x2d2d2d2dU, 0xe5e5e5e5U, 0x7a7a7a7aU, 0x9f9f9f9fU,\n        0x93939393U, 0xc9c9c9c9U, 0x9c9c9c9cU, 0xefefefefU,\n        0xa0a0a0a0U, 0xe0e0e0e0U, 0x3b3b3b3bU, 0x4d4d4d4dU,\n        0xaeaeaeaeU, 0x2a2a2a2aU, 0xf5f5f5f5U, 0xb0b0b0b0U,\n        0xc8c8c8c8U, 0xebebebebU, 0xbbbbbbbbU, 0x3c3c3c3cU,\n        0x83838383U, 0x53535353U, 0x99999999U, 0x61616161U,\n        0x17171717U, 0x2b2b2b2bU, 0x04040404U, 0x7e7e7e7eU,\n        0xbabababaU, 0x77777777U, 0xd6d6d6d6U, 0x26262626U,\n        0xe1e1e1e1U, 0x69696969U, 0x14141414U, 0x63636363U,\n        0x55555555U, 0x21212121U, 0x0c0c0c0cU, 0x7d7d7d7dU,\n};\nstatic const u32 rcon[] = {\n        0x01000000, 0x02000000, 0x04000000, 0x08000000,\n        0x10000000, 0x20000000, 0x40000000, 0x80000000,\n        0x1B000000, 0x36000000, /* for 128-bit blocks, Rijndael never uses more than 10 rcon values */\n};\n\n/**\n * Expand the cipher key into the encryption key schedule.\n */\nint AES_set_encrypt_key(const unsigned char *userKey, const int bits,\n                        AES_KEY *key) {\n\n        u32 *rk;\n        int i = 0;\n        u32 temp;\n\n        if (!userKey || !key)\n                return -1;\n        if (bits != 128 && bits != 192 && bits != 256)\n                return -2;\n\n        rk = key->rd_key;\n\n        if (bits==128)\n                key->rounds = 10;\n        else if (bits==192)\n                key->rounds = 12;\n        else\n                key->rounds = 14;\n\n        rk[0] = GETU32(userKey     );\n        rk[1] = GETU32(userKey +  4);\n        rk[2] = GETU32(userKey +  8);\n        rk[3] = GETU32(userKey + 12);\n        if (bits == 128) {\n                while (1) {\n                        temp  = rk[3];\n                        rk[4] = rk[0] ^\n                                (Te4[(temp >> 16) & 0xff] & 0xff000000) ^\n                                (Te4[(temp >>  8) & 0xff] & 0x00ff0000) ^\n                                (Te4[(temp      ) & 0xff] & 0x0000ff00) ^\n                                (Te4[(temp >> 24)       ] & 0x000000ff) ^\n                                rcon[i];\n                        rk[5] = rk[1] ^ rk[4];\n                        rk[6] = rk[2] ^ rk[5];\n                        rk[7] = rk[3] ^ rk[6];\n                        if (++i == 10) {\n                                return 0;\n                        }\n                        rk += 4;\n                }\n        }\n        rk[4] = GETU32(userKey + 16);\n        rk[5] = GETU32(userKey + 20);\n        if (bits == 192) {\n                while (1) {\n                        temp = rk[ 5];\n                        rk[ 6] = rk[ 0] ^\n                                (Te4[(temp >> 16) & 0xff] & 0xff000000) ^\n                                (Te4[(temp >>  8) & 0xff] & 0x00ff0000) ^\n                                (Te4[(temp      ) & 0xff] & 0x0000ff00) ^\n                                (Te4[(temp >> 24)       ] & 0x000000ff) ^\n                                rcon[i];\n                        rk[ 7] = rk[ 1] ^ rk[ 6];\n                        rk[ 8] = rk[ 2] ^ rk[ 7];\n                        rk[ 9] = rk[ 3] ^ rk[ 8];\n                        if (++i == 8) {\n                                return 0;\n                        }\n                        rk[10] = rk[ 4] ^ rk[ 9];\n                        rk[11] = rk[ 5] ^ rk[10];\n                        rk += 6;\n                }\n        }\n        rk[6] = GETU32(userKey + 24);\n        rk[7] = GETU32(userKey + 28);\n        if (bits == 256) {\n                while (1) {\n                        temp = rk[ 7];\n                        rk[ 8] = rk[ 0] ^\n                                (Te4[(temp >> 16) & 0xff] & 0xff000000) ^\n                                (Te4[(temp >>  8) & 0xff] & 0x00ff0000) ^\n                                (Te4[(temp      ) & 0xff] & 0x0000ff00) ^\n                                (Te4[(temp >> 24)       ] & 0x000000ff) ^\n                                rcon[i];\n                        rk[ 9] = rk[ 1] ^ rk[ 8];\n                        rk[10] = rk[ 2] ^ rk[ 9];\n                        rk[11] = rk[ 3] ^ rk[10];\n                        if (++i == 7) {\n                                return 0;\n                        }\n                        temp = rk[11];\n                        rk[12] = rk[ 4] ^\n                                (Te4[(temp >> 24)       ] & 0xff000000) ^\n                                (Te4[(temp >> 16) & 0xff] & 0x00ff0000) ^\n                                (Te4[(temp >>  8) & 0xff] & 0x0000ff00) ^\n                                (Te4[(temp      ) & 0xff] & 0x000000ff);\n                        rk[13] = rk[ 5] ^ rk[12];\n                        rk[14] = rk[ 6] ^ rk[13];\n                        rk[15] = rk[ 7] ^ rk[14];\n\n                        rk += 8;\n                }\n        }\n        return 0;\n}\n\n/**\n * Expand the cipher key into the decryption key schedule.\n */\nint AES_set_decrypt_key(const unsigned char *userKey, const int bits,\n                        AES_KEY *key) {\n\n        u32 *rk;\n        int i, j, status;\n        u32 temp;\n\n        /* first, start with an encryption schedule */\n        status = AES_set_encrypt_key(userKey, bits, key);\n        if (status < 0)\n                return status;\n\n        rk = key->rd_key;\n\n        /* invert the order of the round keys: */\n        for (i = 0, j = 4*(key->rounds); i < j; i += 4, j -= 4) {\n                temp = rk[i    ]; rk[i    ] = rk[j    ]; rk[j    ] = temp;\n                temp = rk[i + 1]; rk[i + 1] = rk[j + 1]; rk[j + 1] = temp;\n                temp = rk[i + 2]; rk[i + 2] = rk[j + 2]; rk[j + 2] = temp;\n                temp = rk[i + 3]; rk[i + 3] = rk[j + 3]; rk[j + 3] = temp;\n        }\n        /* apply the inverse MixColumn transform to all round keys but the first and the last: */\n        for (i = 1; i < (key->rounds); i++) {\n                rk += 4;\n                rk[0] =\n                        Td0[Te4[(rk[0] >> 24)       ] & 0xff] ^\n                        Td1[Te4[(rk[0] >> 16) & 0xff] & 0xff] ^\n                        Td2[Te4[(rk[0] >>  8) & 0xff] & 0xff] ^\n                        Td3[Te4[(rk[0]      ) & 0xff] & 0xff];\n                rk[1] =\n                        Td0[Te4[(rk[1] >> 24)       ] & 0xff] ^\n                        Td1[Te4[(rk[1] >> 16) & 0xff] & 0xff] ^\n                        Td2[Te4[(rk[1] >>  8) & 0xff] & 0xff] ^\n                        Td3[Te4[(rk[1]      ) & 0xff] & 0xff];\n                rk[2] =\n                        Td0[Te4[(rk[2] >> 24)       ] & 0xff] ^\n                        Td1[Te4[(rk[2] >> 16) & 0xff] & 0xff] ^\n                        Td2[Te4[(rk[2] >>  8) & 0xff] & 0xff] ^\n                        Td3[Te4[(rk[2]      ) & 0xff] & 0xff];\n                rk[3] =\n                        Td0[Te4[(rk[3] >> 24)       ] & 0xff] ^\n                        Td1[Te4[(rk[3] >> 16) & 0xff] & 0xff] ^\n                        Td2[Te4[(rk[3] >>  8) & 0xff] & 0xff] ^\n                        Td3[Te4[(rk[3]      ) & 0xff] & 0xff];\n        }\n        return 0;\n}\n\n/*\n * Encrypt a single block\n * in and out can overlap\n */\nvoid AES_encrypt(const unsigned char *in, unsigned char *out,\n                 const AES_KEY *key) {\n\n        const u32 *rk;\n        u32 s0, s1, s2, s3, t0, t1, t2, t3;\n#ifndef FULL_UNROLL\n        int r;\n#endif /* ?FULL_UNROLL */\n\n        rk = key->rd_key;\n\n        /*\n         * map byte array block to cipher state\n         * and add initial round key:\n         */\n        s0 = GETU32(in     ) ^ rk[0];\n        s1 = GETU32(in +  4) ^ rk[1];\n        s2 = GETU32(in +  8) ^ rk[2];\n        s3 = GETU32(in + 12) ^ rk[3];\n#ifdef FULL_UNROLL\n        /* round 1: */\n        t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >>  8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[ 4];\n        t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >>  8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[ 5];\n        t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >>  8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[ 6];\n        t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >>  8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[ 7];\n        /* round 2: */\n        s0 = Te0[t0 >> 24] ^ Te1[(t1 >> 16) & 0xff] ^ Te2[(t2 >>  8) & 0xff] ^ Te3[t3 & 0xff] ^ rk[ 8];\n        s1 = Te0[t1 >> 24] ^ Te1[(t2 >> 16) & 0xff] ^ Te2[(t3 >>  8) & 0xff] ^ Te3[t0 & 0xff] ^ rk[ 9];\n        s2 = Te0[t2 >> 24] ^ Te1[(t3 >> 16) & 0xff] ^ Te2[(t0 >>  8) & 0xff] ^ Te3[t1 & 0xff] ^ rk[10];\n        s3 = Te0[t3 >> 24] ^ Te1[(t0 >> 16) & 0xff] ^ Te2[(t1 >>  8) & 0xff] ^ Te3[t2 & 0xff] ^ rk[11];\n        /* round 3: */\n        t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >>  8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[12];\n        t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >>  8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[13];\n        t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >>  8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[14];\n        t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >>  8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[15];\n        /* round 4: */\n        s0 = Te0[t0 >> 24] ^ Te1[(t1 >> 16) & 0xff] ^ Te2[(t2 >>  8) & 0xff] ^ Te3[t3 & 0xff] ^ rk[16];\n        s1 = Te0[t1 >> 24] ^ Te1[(t2 >> 16) & 0xff] ^ Te2[(t3 >>  8) & 0xff] ^ Te3[t0 & 0xff] ^ rk[17];\n        s2 = Te0[t2 >> 24] ^ Te1[(t3 >> 16) & 0xff] ^ Te2[(t0 >>  8) & 0xff] ^ Te3[t1 & 0xff] ^ rk[18];\n        s3 = Te0[t3 >> 24] ^ Te1[(t0 >> 16) & 0xff] ^ Te2[(t1 >>  8) & 0xff] ^ Te3[t2 & 0xff] ^ rk[19];\n        /* round 5: */\n        t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >>  8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[20];\n        t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >>  8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[21];\n        t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >>  8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[22];\n        t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >>  8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[23];\n        /* round 6: */\n        s0 = Te0[t0 >> 24] ^ Te1[(t1 >> 16) & 0xff] ^ Te2[(t2 >>  8) & 0xff] ^ Te3[t3 & 0xff] ^ rk[24];\n        s1 = Te0[t1 >> 24] ^ Te1[(t2 >> 16) & 0xff] ^ Te2[(t3 >>  8) & 0xff] ^ Te3[t0 & 0xff] ^ rk[25];\n        s2 = Te0[t2 >> 24] ^ Te1[(t3 >> 16) & 0xff] ^ Te2[(t0 >>  8) & 0xff] ^ Te3[t1 & 0xff] ^ rk[26];\n        s3 = Te0[t3 >> 24] ^ Te1[(t0 >> 16) & 0xff] ^ Te2[(t1 >>  8) & 0xff] ^ Te3[t2 & 0xff] ^ rk[27];\n        /* round 7: */\n        t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >>  8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[28];\n        t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >>  8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[29];\n        t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >>  8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[30];\n        t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >>  8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[31];\n        /* round 8: */\n        s0 = Te0[t0 >> 24] ^ Te1[(t1 >> 16) & 0xff] ^ Te2[(t2 >>  8) & 0xff] ^ Te3[t3 & 0xff] ^ rk[32];\n        s1 = Te0[t1 >> 24] ^ Te1[(t2 >> 16) & 0xff] ^ Te2[(t3 >>  8) & 0xff] ^ Te3[t0 & 0xff] ^ rk[33];\n        s2 = Te0[t2 >> 24] ^ Te1[(t3 >> 16) & 0xff] ^ Te2[(t0 >>  8) & 0xff] ^ Te3[t1 & 0xff] ^ rk[34];\n        s3 = Te0[t3 >> 24] ^ Te1[(t0 >> 16) & 0xff] ^ Te2[(t1 >>  8) & 0xff] ^ Te3[t2 & 0xff] ^ rk[35];\n        /* round 9: */\n        t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >>  8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[36];\n        t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >>  8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[37];\n        t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >>  8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[38];\n        t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >>  8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[39];\n        if (key->rounds > 10) {\n                /* round 10: */\n                s0 = Te0[t0 >> 24] ^ Te1[(t1 >> 16) & 0xff] ^ Te2[(t2 >>  8) & 0xff] ^ Te3[t3 & 0xff] ^ rk[40];\n                s1 = Te0[t1 >> 24] ^ Te1[(t2 >> 16) & 0xff] ^ Te2[(t3 >>  8) & 0xff] ^ Te3[t0 & 0xff] ^ rk[41];\n                s2 = Te0[t2 >> 24] ^ Te1[(t3 >> 16) & 0xff] ^ Te2[(t0 >>  8) & 0xff] ^ Te3[t1 & 0xff] ^ rk[42];\n                s3 = Te0[t3 >> 24] ^ Te1[(t0 >> 16) & 0xff] ^ Te2[(t1 >>  8) & 0xff] ^ Te3[t2 & 0xff] ^ rk[43];\n                /* round 11: */\n                t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >>  8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[44];\n                t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >>  8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[45];\n                t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >>  8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[46];\n                t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >>  8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[47];\n                if (key->rounds > 12) {\n                        /* round 12: */\n                        s0 = Te0[t0 >> 24] ^ Te1[(t1 >> 16) & 0xff] ^ Te2[(t2 >>  8) & 0xff] ^ Te3[t3 & 0xff] ^ rk[48];\n                        s1 = Te0[t1 >> 24] ^ Te1[(t2 >> 16) & 0xff] ^ Te2[(t3 >>  8) & 0xff] ^ Te3[t0 & 0xff] ^ rk[49];\n                        s2 = Te0[t2 >> 24] ^ Te1[(t3 >> 16) & 0xff] ^ Te2[(t0 >>  8) & 0xff] ^ Te3[t1 & 0xff] ^ rk[50];\n                        s3 = Te0[t3 >> 24] ^ Te1[(t0 >> 16) & 0xff] ^ Te2[(t1 >>  8) & 0xff] ^ Te3[t2 & 0xff] ^ rk[51];\n                        /* round 13: */\n                        t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >>  8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[52];\n                        t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >>  8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[53];\n                        t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >>  8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[54];\n                        t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >>  8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[55];\n                }\n        }\n        rk += key->rounds << 2;\n#else  /* !FULL_UNROLL */\n        /*\n         * Nr - 1 full rounds:\n         */\n        r = key->rounds >> 1;\n        for (;;) {\n                t0 =\n                        Te0[(s0 >> 24)       ] ^\n                        Te1[(s1 >> 16) & 0xff] ^\n                        Te2[(s2 >>  8) & 0xff] ^\n                        Te3[(s3      ) & 0xff] ^\n                        rk[4];\n                t1 =\n                        Te0[(s1 >> 24)       ] ^\n                        Te1[(s2 >> 16) & 0xff] ^\n                        Te2[(s3 >>  8) & 0xff] ^\n                        Te3[(s0      ) & 0xff] ^\n                        rk[5];\n                t2 =\n                        Te0[(s2 >> 24)       ] ^\n                        Te1[(s3 >> 16) & 0xff] ^\n                        Te2[(s0 >>  8) & 0xff] ^\n                        Te3[(s1      ) & 0xff] ^\n                        rk[6];\n                t3 =\n                        Te0[(s3 >> 24)       ] ^\n                        Te1[(s0 >> 16) & 0xff] ^\n                        Te2[(s1 >>  8) & 0xff] ^\n                        Te3[(s2      ) & 0xff] ^\n                        rk[7];\n\n                rk += 8;\n                if (--r == 0) {\n                        break;\n                }\n\n                s0 =\n                        Te0[(t0 >> 24)       ] ^\n                        Te1[(t1 >> 16) & 0xff] ^\n                        Te2[(t2 >>  8) & 0xff] ^\n                        Te3[(t3      ) & 0xff] ^\n                        rk[0];\n                s1 =\n                        Te0[(t1 >> 24)       ] ^\n                        Te1[(t2 >> 16) & 0xff] ^\n                        Te2[(t3 >>  8) & 0xff] ^\n                        Te3[(t0      ) & 0xff] ^\n                        rk[1];\n                s2 =\n                        Te0[(t2 >> 24)       ] ^\n                        Te1[(t3 >> 16) & 0xff] ^\n                        Te2[(t0 >>  8) & 0xff] ^\n                        Te3[(t1      ) & 0xff] ^\n                        rk[2];\n                s3 =\n                        Te0[(t3 >> 24)       ] ^\n                        Te1[(t0 >> 16) & 0xff] ^\n                        Te2[(t1 >>  8) & 0xff] ^\n                        Te3[(t2      ) & 0xff] ^\n                        rk[3];\n        }\n#endif /* ?FULL_UNROLL */\n        /*\n         * apply last round and\n         * map cipher state to byte array block:\n         */\n        s0 =\n                (Te4[(t0 >> 24)       ] & 0xff000000) ^\n                (Te4[(t1 >> 16) & 0xff] & 0x00ff0000) ^\n                (Te4[(t2 >>  8) & 0xff] & 0x0000ff00) ^\n                (Te4[(t3      ) & 0xff] & 0x000000ff) ^\n                rk[0];\n        PUTU32(out     , s0);\n        s1 =\n                (Te4[(t1 >> 24)       ] & 0xff000000) ^\n                (Te4[(t2 >> 16) & 0xff] & 0x00ff0000) ^\n                (Te4[(t3 >>  8) & 0xff] & 0x0000ff00) ^\n                (Te4[(t0      ) & 0xff] & 0x000000ff) ^\n                rk[1];\n        PUTU32(out +  4, s1);\n        s2 =\n                (Te4[(t2 >> 24)       ] & 0xff000000) ^\n                (Te4[(t3 >> 16) & 0xff] & 0x00ff0000) ^\n                (Te4[(t0 >>  8) & 0xff] & 0x0000ff00) ^\n                (Te4[(t1      ) & 0xff] & 0x000000ff) ^\n                rk[2];\n        PUTU32(out +  8, s2);\n        s3 =\n                (Te4[(t3 >> 24)       ] & 0xff000000) ^\n                (Te4[(t0 >> 16) & 0xff] & 0x00ff0000) ^\n                (Te4[(t1 >>  8) & 0xff] & 0x0000ff00) ^\n                (Te4[(t2      ) & 0xff] & 0x000000ff) ^\n                rk[3];\n        PUTU32(out + 12, s3);\n}\n\n/*\n * Decrypt a single block\n * in and out can overlap\n */\nvoid AES_decrypt(const unsigned char *in, unsigned char *out,\n                 const AES_KEY *key) {\n\n        const u32 *rk;\n        u32 s0, s1, s2, s3, t0, t1, t2, t3;\n#ifndef FULL_UNROLL\n        int r;\n#endif /* ?FULL_UNROLL */\n\n        rk = key->rd_key;\n\n        /*\n         * map byte array block to cipher state\n         * and add initial round key:\n         */\n        s0 = GETU32(in     ) ^ rk[0];\n        s1 = GETU32(in +  4) ^ rk[1];\n        s2 = GETU32(in +  8) ^ rk[2];\n        s3 = GETU32(in + 12) ^ rk[3];\n#ifdef FULL_UNROLL\n        /* round 1: */\n        t0 = Td0[s0 >> 24] ^ Td1[(s3 >> 16) & 0xff] ^ Td2[(s2 >>  8) & 0xff] ^ Td3[s1 & 0xff] ^ rk[ 4];\n        t1 = Td0[s1 >> 24] ^ Td1[(s0 >> 16) & 0xff] ^ Td2[(s3 >>  8) & 0xff] ^ Td3[s2 & 0xff] ^ rk[ 5];\n        t2 = Td0[s2 >> 24] ^ Td1[(s1 >> 16) & 0xff] ^ Td2[(s0 >>  8) & 0xff] ^ Td3[s3 & 0xff] ^ rk[ 6];\n        t3 = Td0[s3 >> 24] ^ Td1[(s2 >> 16) & 0xff] ^ Td2[(s1 >>  8) & 0xff] ^ Td3[s0 & 0xff] ^ rk[ 7];\n        /* round 2: */\n        s0 = Td0[t0 >> 24] ^ Td1[(t3 >> 16) & 0xff] ^ Td2[(t2 >>  8) & 0xff] ^ Td3[t1 & 0xff] ^ rk[ 8];\n        s1 = Td0[t1 >> 24] ^ Td1[(t0 >> 16) & 0xff] ^ Td2[(t3 >>  8) & 0xff] ^ Td3[t2 & 0xff] ^ rk[ 9];\n        s2 = Td0[t2 >> 24] ^ Td1[(t1 >> 16) & 0xff] ^ Td2[(t0 >>  8) & 0xff] ^ Td3[t3 & 0xff] ^ rk[10];\n        s3 = Td0[t3 >> 24] ^ Td1[(t2 >> 16) & 0xff] ^ Td2[(t1 >>  8) & 0xff] ^ Td3[t0 & 0xff] ^ rk[11];\n        /* round 3: */\n        t0 = Td0[s0 >> 24] ^ Td1[(s3 >> 16) & 0xff] ^ Td2[(s2 >>  8) & 0xff] ^ Td3[s1 & 0xff] ^ rk[12];\n        t1 = Td0[s1 >> 24] ^ Td1[(s0 >> 16) & 0xff] ^ Td2[(s3 >>  8) & 0xff] ^ Td3[s2 & 0xff] ^ rk[13];\n        t2 = Td0[s2 >> 24] ^ Td1[(s1 >> 16) & 0xff] ^ Td2[(s0 >>  8) & 0xff] ^ Td3[s3 & 0xff] ^ rk[14];\n        t3 = Td0[s3 >> 24] ^ Td1[(s2 >> 16) & 0xff] ^ Td2[(s1 >>  8) & 0xff] ^ Td3[s0 & 0xff] ^ rk[15];\n        /* round 4: */\n        s0 = Td0[t0 >> 24] ^ Td1[(t3 >> 16) & 0xff] ^ Td2[(t2 >>  8) & 0xff] ^ Td3[t1 & 0xff] ^ rk[16];\n        s1 = Td0[t1 >> 24] ^ Td1[(t0 >> 16) & 0xff] ^ Td2[(t3 >>  8) & 0xff] ^ Td3[t2 & 0xff] ^ rk[17];\n        s2 = Td0[t2 >> 24] ^ Td1[(t1 >> 16) & 0xff] ^ Td2[(t0 >>  8) & 0xff] ^ Td3[t3 & 0xff] ^ rk[18];\n        s3 = Td0[t3 >> 24] ^ Td1[(t2 >> 16) & 0xff] ^ Td2[(t1 >>  8) & 0xff] ^ Td3[t0 & 0xff] ^ rk[19];\n        /* round 5: */\n        t0 = Td0[s0 >> 24] ^ Td1[(s3 >> 16) & 0xff] ^ Td2[(s2 >>  8) & 0xff] ^ Td3[s1 & 0xff] ^ rk[20];\n        t1 = Td0[s1 >> 24] ^ Td1[(s0 >> 16) & 0xff] ^ Td2[(s3 >>  8) & 0xff] ^ Td3[s2 & 0xff] ^ rk[21];\n        t2 = Td0[s2 >> 24] ^ Td1[(s1 >> 16) & 0xff] ^ Td2[(s0 >>  8) & 0xff] ^ Td3[s3 & 0xff] ^ rk[22];\n        t3 = Td0[s3 >> 24] ^ Td1[(s2 >> 16) & 0xff] ^ Td2[(s1 >>  8) & 0xff] ^ Td3[s0 & 0xff] ^ rk[23];\n        /* round 6: */\n        s0 = Td0[t0 >> 24] ^ Td1[(t3 >> 16) & 0xff] ^ Td2[(t2 >>  8) & 0xff] ^ Td3[t1 & 0xff] ^ rk[24];\n        s1 = Td0[t1 >> 24] ^ Td1[(t0 >> 16) & 0xff] ^ Td2[(t3 >>  8) & 0xff] ^ Td3[t2 & 0xff] ^ rk[25];\n        s2 = Td0[t2 >> 24] ^ Td1[(t1 >> 16) & 0xff] ^ Td2[(t0 >>  8) & 0xff] ^ Td3[t3 & 0xff] ^ rk[26];\n        s3 = Td0[t3 >> 24] ^ Td1[(t2 >> 16) & 0xff] ^ Td2[(t1 >>  8) & 0xff] ^ Td3[t0 & 0xff] ^ rk[27];\n        /* round 7: */\n        t0 = Td0[s0 >> 24] ^ Td1[(s3 >> 16) & 0xff] ^ Td2[(s2 >>  8) & 0xff] ^ Td3[s1 & 0xff] ^ rk[28];\n        t1 = Td0[s1 >> 24] ^ Td1[(s0 >> 16) & 0xff] ^ Td2[(s3 >>  8) & 0xff] ^ Td3[s2 & 0xff] ^ rk[29];\n        t2 = Td0[s2 >> 24] ^ Td1[(s1 >> 16) & 0xff] ^ Td2[(s0 >>  8) & 0xff] ^ Td3[s3 & 0xff] ^ rk[30];\n        t3 = Td0[s3 >> 24] ^ Td1[(s2 >> 16) & 0xff] ^ Td2[(s1 >>  8) & 0xff] ^ Td3[s0 & 0xff] ^ rk[31];\n        /* round 8: */\n        s0 = Td0[t0 >> 24] ^ Td1[(t3 >> 16) & 0xff] ^ Td2[(t2 >>  8) & 0xff] ^ Td3[t1 & 0xff] ^ rk[32];\n        s1 = Td0[t1 >> 24] ^ Td1[(t0 >> 16) & 0xff] ^ Td2[(t3 >>  8) & 0xff] ^ Td3[t2 & 0xff] ^ rk[33];\n        s2 = Td0[t2 >> 24] ^ Td1[(t1 >> 16) & 0xff] ^ Td2[(t0 >>  8) & 0xff] ^ Td3[t3 & 0xff] ^ rk[34];\n        s3 = Td0[t3 >> 24] ^ Td1[(t2 >> 16) & 0xff] ^ Td2[(t1 >>  8) & 0xff] ^ Td3[t0 & 0xff] ^ rk[35];\n        /* round 9: */\n        t0 = Td0[s0 >> 24] ^ Td1[(s3 >> 16) & 0xff] ^ Td2[(s2 >>  8) & 0xff] ^ Td3[s1 & 0xff] ^ rk[36];\n        t1 = Td0[s1 >> 24] ^ Td1[(s0 >> 16) & 0xff] ^ Td2[(s3 >>  8) & 0xff] ^ Td3[s2 & 0xff] ^ rk[37];\n        t2 = Td0[s2 >> 24] ^ Td1[(s1 >> 16) & 0xff] ^ Td2[(s0 >>  8) & 0xff] ^ Td3[s3 & 0xff] ^ rk[38];\n        t3 = Td0[s3 >> 24] ^ Td1[(s2 >> 16) & 0xff] ^ Td2[(s1 >>  8) & 0xff] ^ Td3[s0 & 0xff] ^ rk[39];\n        if (key->rounds > 10) {\n                /* round 10: */\n                s0 = Td0[t0 >> 24] ^ Td1[(t3 >> 16) & 0xff] ^ Td2[(t2 >>  8) & 0xff] ^ Td3[t1 & 0xff] ^ rk[40];\n                s1 = Td0[t1 >> 24] ^ Td1[(t0 >> 16) & 0xff] ^ Td2[(t3 >>  8) & 0xff] ^ Td3[t2 & 0xff] ^ rk[41];\n                s2 = Td0[t2 >> 24] ^ Td1[(t1 >> 16) & 0xff] ^ Td2[(t0 >>  8) & 0xff] ^ Td3[t3 & 0xff] ^ rk[42];\n                s3 = Td0[t3 >> 24] ^ Td1[(t2 >> 16) & 0xff] ^ Td2[(t1 >>  8) & 0xff] ^ Td3[t0 & 0xff] ^ rk[43];\n                /* round 11: */\n                t0 = Td0[s0 >> 24] ^ Td1[(s3 >> 16) & 0xff] ^ Td2[(s2 >>  8) & 0xff] ^ Td3[s1 & 0xff] ^ rk[44];\n                t1 = Td0[s1 >> 24] ^ Td1[(s0 >> 16) & 0xff] ^ Td2[(s3 >>  8) & 0xff] ^ Td3[s2 & 0xff] ^ rk[45];\n                t2 = Td0[s2 >> 24] ^ Td1[(s1 >> 16) & 0xff] ^ Td2[(s0 >>  8) & 0xff] ^ Td3[s3 & 0xff] ^ rk[46];\n                t3 = Td0[s3 >> 24] ^ Td1[(s2 >> 16) & 0xff] ^ Td2[(s1 >>  8) & 0xff] ^ Td3[s0 & 0xff] ^ rk[47];\n                if (key->rounds > 12) {\n                        /* round 12: */\n                        s0 = Td0[t0 >> 24] ^ Td1[(t3 >> 16) & 0xff] ^ Td2[(t2 >>  8) & 0xff] ^ Td3[t1 & 0xff] ^ rk[48];\n                        s1 = Td0[t1 >> 24] ^ Td1[(t0 >> 16) & 0xff] ^ Td2[(t3 >>  8) & 0xff] ^ Td3[t2 & 0xff] ^ rk[49];\n                        s2 = Td0[t2 >> 24] ^ Td1[(t1 >> 16) & 0xff] ^ Td2[(t0 >>  8) & 0xff] ^ Td3[t3 & 0xff] ^ rk[50];\n                        s3 = Td0[t3 >> 24] ^ Td1[(t2 >> 16) & 0xff] ^ Td2[(t1 >>  8) & 0xff] ^ Td3[t0 & 0xff] ^ rk[51];\n                        /* round 13: */\n                        t0 = Td0[s0 >> 24] ^ Td1[(s3 >> 16) & 0xff] ^ Td2[(s2 >>  8) & 0xff] ^ Td3[s1 & 0xff] ^ rk[52];\n                        t1 = Td0[s1 >> 24] ^ Td1[(s0 >> 16) & 0xff] ^ Td2[(s3 >>  8) & 0xff] ^ Td3[s2 & 0xff] ^ rk[53];\n                        t2 = Td0[s2 >> 24] ^ Td1[(s1 >> 16) & 0xff] ^ Td2[(s0 >>  8) & 0xff] ^ Td3[s3 & 0xff] ^ rk[54];\n                        t3 = Td0[s3 >> 24] ^ Td1[(s2 >> 16) & 0xff] ^ Td2[(s1 >>  8) & 0xff] ^ Td3[s0 & 0xff] ^ rk[55];\n                }\n        }\n        rk += key->rounds << 2;\n#else  /* !FULL_UNROLL */\n        /*\n         * Nr - 1 full rounds:\n         */\n        r = key->rounds >> 1;\n        for (;;) {\n                t0 =\n                        Td0[(s0 >> 24)       ] ^\n                        Td1[(s3 >> 16) & 0xff] ^\n                        Td2[(s2 >>  8) & 0xff] ^\n                        Td3[(s1      ) & 0xff] ^\n                        rk[4];\n                t1 =\n                        Td0[(s1 >> 24)       ] ^\n                        Td1[(s0 >> 16) & 0xff] ^\n                        Td2[(s3 >>  8) & 0xff] ^\n                        Td3[(s2      ) & 0xff] ^\n                        rk[5];\n                t2 =\n                        Td0[(s2 >> 24)       ] ^\n                        Td1[(s1 >> 16) & 0xff] ^\n                        Td2[(s0 >>  8) & 0xff] ^\n                        Td3[(s3      ) & 0xff] ^\n                        rk[6];\n                t3 =\n                        Td0[(s3 >> 24)       ] ^\n                        Td1[(s2 >> 16) & 0xff] ^\n                        Td2[(s1 >>  8) & 0xff] ^\n                        Td3[(s0      ) & 0xff] ^\n                        rk[7];\n\n                rk += 8;\n                if (--r == 0) {\n                        break;\n                }\n\n                s0 =\n                        Td0[(t0 >> 24)       ] ^\n                        Td1[(t3 >> 16) & 0xff] ^\n                        Td2[(t2 >>  8) & 0xff] ^\n                        Td3[(t1      ) & 0xff] ^\n                        rk[0];\n                s1 =\n                        Td0[(t1 >> 24)       ] ^\n                        Td1[(t0 >> 16) & 0xff] ^\n                        Td2[(t3 >>  8) & 0xff] ^\n                        Td3[(t2      ) & 0xff] ^\n                        rk[1];\n                s2 =\n                        Td0[(t2 >> 24)       ] ^\n                        Td1[(t1 >> 16) & 0xff] ^\n                        Td2[(t0 >>  8) & 0xff] ^\n                        Td3[(t3      ) & 0xff] ^\n                        rk[2];\n                s3 =\n                        Td0[(t3 >> 24)       ] ^\n                        Td1[(t2 >> 16) & 0xff] ^\n                        Td2[(t1 >>  8) & 0xff] ^\n                        Td3[(t0      ) & 0xff] ^\n                        rk[3];\n        }\n#endif /* ?FULL_UNROLL */\n        /*\n         * apply last round and\n         * map cipher state to byte array block:\n         */\n        s0 =\n                (Td4[(t0 >> 24)       ] & 0xff000000) ^\n                (Td4[(t3 >> 16) & 0xff] & 0x00ff0000) ^\n                (Td4[(t2 >>  8) & 0xff] & 0x0000ff00) ^\n                (Td4[(t1      ) & 0xff] & 0x000000ff) ^\n                rk[0];\n        PUTU32(out     , s0);\n        s1 =\n                (Td4[(t1 >> 24)       ] & 0xff000000) ^\n                (Td4[(t0 >> 16) & 0xff] & 0x00ff0000) ^\n                (Td4[(t3 >>  8) & 0xff] & 0x0000ff00) ^\n                (Td4[(t2      ) & 0xff] & 0x000000ff) ^\n                rk[1];\n        PUTU32(out +  4, s1);\n        s2 =\n                (Td4[(t2 >> 24)       ] & 0xff000000) ^\n                (Td4[(t1 >> 16) & 0xff] & 0x00ff0000) ^\n                (Td4[(t0 >>  8) & 0xff] & 0x0000ff00) ^\n                (Td4[(t3      ) & 0xff] & 0x000000ff) ^\n                rk[2];\n        PUTU32(out +  8, s2);\n        s3 =\n                (Td4[(t3 >> 24)       ] & 0xff000000) ^\n                (Td4[(t2 >> 16) & 0xff] & 0x00ff0000) ^\n                (Td4[(t1 >>  8) & 0xff] & 0x0000ff00) ^\n                (Td4[(t0      ) & 0xff] & 0x000000ff) ^\n                rk[3];\n        PUTU32(out + 12, s3);\n}\n\n#define AES_BLOCK_OP64(dst, src, op) do {                       \\\n                uint64_t *_dst = (uint64_t *)(dst);             \\\n                uint64_t *_src = (uint64_t *)(src);             \\\n                *_dst++ op *_src++;                             \\\n                *_dst   op *_src;                               \\\n        } while (0)\n\n#define AES_BLOCK_OP32(dst, src, op) do {                       \\\n                uint32_t *_dst = (uint32_t *)(dst);             \\\n                uint32_t *_src = (uint32_t *)(src);             \\\n                *_dst++ op *_src++;                             \\\n                *_dst++ op *_src++;                             \\\n                *_dst++ op *_src++;                             \\\n                *_dst   op *_src;                               \\\n        } while (0)\n\n#if defined __x86_64__\n#define AES_BLOCK_OP(dst, src, op) AES_BLOCK_OP64(dst, src, op)\n#else\n#define AES_BLOCK_OP(dst, src, op) AES_BLOCK_OP32(dst, src, op)\n#endif\n\nvoid AES_cbc_encrypt(const unsigned char *in, unsigned char *out, unsigned char *ivec,\n                     unsigned long nblock, const AES_KEY *key)\n{\n        const unsigned char *vec = ivec;\n\n        while (nblock--) {\n                AES_BLOCK_OP(out, in,   =);\n                AES_BLOCK_OP(out, vec, ^=);\n                AES_encrypt(out, out, key);\n                vec  = out;\n                in  += AES_BLOCK_SIZE;\n                out += AES_BLOCK_SIZE;\n        }\n\n        memcpy(ivec, vec, AES_BLOCK_SIZE);\n}\n\nvoid AES_cbc_decrypt(const unsigned char *in, unsigned char *out, unsigned char *ivec,\n                     unsigned long nblock, const AES_KEY *key)\n{\n        const unsigned char *vec = ivec;\n\n        while (nblock--) {\n                AES_BLOCK_OP(out, in,   =);\n                AES_decrypt(out, out, key);\n                AES_BLOCK_OP(out, vec, ^=);\n                vec  = in;\n                in  += AES_BLOCK_SIZE;\n                out += AES_BLOCK_SIZE;\n        }\n\n        memcpy(ivec, vec, AES_BLOCK_SIZE);\n}\n"
  },
  {
    "path": "Projects/Libraries/CSBase/Source/aes/aes.h",
    "content": "/* The MIT License\n\n   Copyright (C) 2011 Zilong Tan (labytan@gmail.com)\n\n   Permission is hereby granted, free of charge, to any person obtaining\n   a copy of this software and associated documentation files (the\n   \"Software\"), to deal in the Software without restriction, including\n   without limitation the rights to use, copy, modify, merge, publish,\n   distribute, sublicense, and/or sell copies of the Software, and to\n   permit persons to whom the Software is furnished to do so, subject to\n   the following conditions:\n\n   The above copyright notice and this permission notice shall be\n   included in all copies or substantial portions of the Software.\n\n   THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n   NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS\n   BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\n   ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\n   CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n   SOFTWARE.\n*/\n\n/*\n * aes.h\n *\n * @version 3.0 (December 2000)\n *\n * Optimised ANSI C code for the Rijndael cipher (now AES)\n *\n * @author Vincent Rijmen <vincent.rijmen@esat.kuleuven.ac.be>\n * @author Antoon Bosselaers <antoon.bosselaers@esat.kuleuven.ac.be>\n * @author Paulo Barreto <paulo.barreto@terra.com.br>\n *\n * This code is hereby placed in the public domain.\n *\n * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ''AS IS'' AND ANY EXPRESS\n * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE\n * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,\n * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\n#ifndef __ULIB_AES_H\n#define __ULIB_AES_H\n\n#include <stdint.h>\n\n#define AES_MAXNR 14\n#define AES_BLOCK_SIZE 16\n\nstruct aes_key_st {\n        uint32_t rd_key[4 *(AES_MAXNR + 1)];\n        int rounds;\n};\n\ntypedef struct aes_key_st AES_KEY;\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n        /* bits can be 128, 192 or 256 */\n        int  AES_set_encrypt_key(const unsigned char *userKey, const int bits,\n                                AES_KEY *key);\n        int  AES_set_decrypt_key(const unsigned char *userKey, const int bits,\n                                AES_KEY *key);\n\n        /* in/out can be the same for ECB encryption/decryption */\n        void AES_encrypt(const unsigned char *in, unsigned char *out,\n                         const AES_KEY *key);\n        void AES_decrypt(const unsigned char *in, unsigned char *out,\n                         const AES_KEY *key);\n\n        /* in/out can be the same */\n        void AES_cbc_encrypt(const unsigned char *in, unsigned char *out, unsigned char *ivec,\n                             unsigned long nblock, const AES_KEY *key);\n\n        /* in/out MUST be DIFFERENT */\n        void AES_cbc_decrypt(const unsigned char *in, unsigned char *out, unsigned char *ivec,\n                             unsigned long nblock, const AES_KEY *key);\n\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "Projects/Libraries/CSBase/Source/base64/base64.cpp",
    "content": "/*\n   base64.cpp and base64.h\n\n   Copyright (C) 2004-2008 René Nyffenegger\n\n   This source code is provided 'as-is', without any express or implied\n   warranty. In no event will the author be held liable for any damages\n   arising from the use of this software.\n\n   Permission is granted to anyone to use this software for any purpose,\n   including commercial applications, and to alter it and redistribute it\n   freely, subject to the following restrictions:\n\n   1. The origin of this source code must not be misrepresented; you must not\n      claim that you wrote the original source code. If you use this source code\n      in a product, an acknowledgment in the product documentation would be\n      appreciated but is not required.\n\n   2. Altered source versions must be plainly marked as such, and must not be\n      misrepresented as being the original source code.\n\n   3. This notice may not be removed or altered from any source distribution.\n\n   René Nyffenegger rene.nyffenegger@adp-gmbh.ch\n\n*/\n\n#include \"base64.h\"\n#include <iostream>\n\nstatic const std::string base64_chars =\n             \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\n             \"abcdefghijklmnopqrstuvwxyz\"\n             \"0123456789+/\";\n\n\nstatic inline bool is_base64(unsigned char c) {\n  return (isalnum(c) || (c == '+') || (c == '/'));\n}\n\nstd::string base64_encode(unsigned char const* bytes_to_encode, unsigned int in_len) {\n  std::string ret;\n  int i = 0;\n  int j = 0;\n  unsigned char char_array_3[3];\n  unsigned char char_array_4[4];\n\n  while (in_len--) {\n    char_array_3[i++] = *(bytes_to_encode++);\n    if (i == 3) {\n      char_array_4[0] = (char_array_3[0] & 0xfc) >> 2;\n      char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4);\n      char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6);\n      char_array_4[3] = char_array_3[2] & 0x3f;\n\n      for(i = 0; (i <4) ; i++)\n        ret += base64_chars[char_array_4[i]];\n      i = 0;\n    }\n  }\n\n  if (i)\n  {\n    for(j = i; j < 3; j++)\n      char_array_3[j] = '\\0';\n\n    char_array_4[0] = (char_array_3[0] & 0xfc) >> 2;\n    char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4);\n    char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6);\n    char_array_4[3] = char_array_3[2] & 0x3f;\n\n    for (j = 0; (j < i + 1); j++)\n      ret += base64_chars[char_array_4[j]];\n\n    while((i++ < 3))\n      ret += '=';\n\n  }\n\n  return ret;\n\n}\n\nstd::string base64_decode(std::string const& encoded_string) {\n  int in_len = encoded_string.size();\n  int i = 0;\n  int j = 0;\n  int in_ = 0;\n  unsigned char char_array_4[4], char_array_3[3];\n  std::string ret;\n\n  while (in_len-- && ( encoded_string[in_] != '=') && is_base64(encoded_string[in_])) {\n    char_array_4[i++] = encoded_string[in_]; in_++;\n    if (i ==4) {\n      for (i = 0; i <4; i++)\n        char_array_4[i] = base64_chars.find(char_array_4[i]);\n\n      char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4);\n      char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);\n      char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3];\n\n      for (i = 0; (i < 3); i++)\n        ret += char_array_3[i];\n      i = 0;\n    }\n  }\n\n  if (i) {\n    for (j = i; j <4; j++)\n      char_array_4[j] = 0;\n\n    for (j = 0; j <4; j++)\n      char_array_4[j] = base64_chars.find(char_array_4[j]);\n\n    char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4);\n    char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);\n    char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3];\n\n    for (j = 0; (j < i - 1); j++) ret += char_array_3[j];\n  }\n\n  return ret;\n}\n"
  },
  {
    "path": "Projects/Libraries/CSBase/Source/base64/base64.h",
    "content": "#include <string>\n\nstd::string base64_encode(unsigned char const* , unsigned int len);\nstd::string base64_decode(std::string const& s);\n"
  },
  {
    "path": "Projects/Libraries/CSBase/Source/json/assertions.h",
    "content": "// Copyright 2007-2010 Baptiste Lepilleur\n// Distributed under MIT license, or public domain if desired and\n// recognized in your jurisdiction.\n// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE\n\n#ifndef CPPTL_JSON_ASSERTIONS_H_INCLUDED\n#define CPPTL_JSON_ASSERTIONS_H_INCLUDED\n\n#include <stdlib.h>\n\n#if !defined(JSON_IS_AMALGAMATION)\n#include \"config.h\"\n#endif // if !defined(JSON_IS_AMALGAMATION)\n\n#if JSON_USE_EXCEPTION\n#include <stdexcept>\n#define JSON_ASSERT(condition)                                                 \\\n  assert(condition); // @todo <= change this into an exception throw\n#define JSON_FAIL_MESSAGE(message) throw std::runtime_error(message);\n#else // JSON_USE_EXCEPTION\n#define JSON_ASSERT(condition) assert(condition);\n\n// The call to assert() will show the failure message in debug builds. In\n// release bugs we write to invalid memory in order to crash hard, so that a\n// debugger or crash reporter gets the chance to take over. We still call exit()\n// afterward in order to tell the compiler that this macro doesn't return.\n#define JSON_FAIL_MESSAGE(message)                                             \\\n  {                                                                            \\\n    assert(false &&message);                                                   \\\n    strcpy(reinterpret_cast<char *>(666), message);                            \\\n    exit(123);                                                                 \\\n  }\n\n#endif\n\n#define JSON_ASSERT_MESSAGE(condition, message)                                \\\n  if (!(condition)) {                                                          \\\n    JSON_FAIL_MESSAGE(message)                                                 \\\n  }\n\n#endif // CPPTL_JSON_ASSERTIONS_H_INCLUDED\n"
  },
  {
    "path": "Projects/Libraries/CSBase/Source/json/autolink.h",
    "content": "// Copyright 2007-2010 Baptiste Lepilleur\n// Distributed under MIT license, or public domain if desired and\n// recognized in your jurisdiction.\n// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE\n\n#ifndef JSON_AUTOLINK_H_INCLUDED\n#define JSON_AUTOLINK_H_INCLUDED\n\n#include \"config.h\"\n\n#ifdef JSON_IN_CPPTL\n#include <cpptl/cpptl_autolink.h>\n#endif\n\n#if !defined(JSON_NO_AUTOLINK) && !defined(JSON_DLL_BUILD) &&                  \\\n    !defined(JSON_IN_CPPTL)\n#define CPPTL_AUTOLINK_NAME \"json\"\n#undef CPPTL_AUTOLINK_DLL\n#ifdef JSON_DLL\n#define CPPTL_AUTOLINK_DLL\n#endif\n#include \"autolink.h\"\n#endif\n\n#endif // JSON_AUTOLINK_H_INCLUDED\n"
  },
  {
    "path": "Projects/Libraries/CSBase/Source/json/config.h",
    "content": "// Copyright 2007-2010 Baptiste Lepilleur\n// Distributed under MIT license, or public domain if desired and\n// recognized in your jurisdiction.\n// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE\n\n#ifndef JSON_CONFIG_H_INCLUDED\n#define JSON_CONFIG_H_INCLUDED\n\n/// If defined, indicates that json library is embedded in CppTL library.\n//# define JSON_IN_CPPTL 1\n\n/// If defined, indicates that json may leverage CppTL library\n//#  define JSON_USE_CPPTL 1\n/// If defined, indicates that cpptl vector based map should be used instead of\n/// std::map\n/// as Value container.\n//#  define JSON_USE_CPPTL_SMALLMAP 1\n/// If defined, indicates that Json specific container should be used\n/// (hash table & simple deque container with customizable allocator).\n/// THIS FEATURE IS STILL EXPERIMENTAL! There is know bugs: See #3177332\n//#  define JSON_VALUE_USE_INTERNAL_MAP 1\n/// Force usage of standard new/malloc based allocator instead of memory pool\n/// based allocator.\n/// The memory pools allocator used optimization (initializing Value and\n/// ValueInternalLink\n/// as if it was a POD) that may cause some validation tool to report errors.\n/// Only has effects if JSON_VALUE_USE_INTERNAL_MAP is defined.\n//#  define JSON_USE_SIMPLE_INTERNAL_ALLOCATOR 1\n\n// If non-zero, the library uses exceptions to report bad input instead of C\n// assertion macros. The default is to use exceptions.\n#ifndef JSON_USE_EXCEPTION\n#define JSON_USE_EXCEPTION 1\n#endif\n\n/// If defined, indicates that the source file is amalgated\n/// to prevent private header inclusion.\n/// Remarks: it is automatically defined in the generated amalgated header.\n// #define JSON_IS_AMALGAMATION\n\n#ifdef JSON_IN_CPPTL\n#include <cpptl/config.h>\n#ifndef JSON_USE_CPPTL\n#define JSON_USE_CPPTL 1\n#endif\n#endif\n\n#ifdef JSON_IN_CPPTL\n#define JSON_API CPPTL_API\n#elif defined(JSON_DLL_BUILD)\n#if defined(_MSC_VER)\n#define JSON_API __declspec(dllexport)\n#define JSONCPP_DISABLE_DLL_INTERFACE_WARNING\n#endif // if defined(_MSC_VER)\n#elif defined(JSON_DLL)\n#if defined(_MSC_VER)\n#define JSON_API __declspec(dllimport)\n#define JSONCPP_DISABLE_DLL_INTERFACE_WARNING\n#endif // if defined(_MSC_VER)\n#endif // ifdef JSON_IN_CPPTL\n#if !defined(JSON_API)\n#define JSON_API\n#endif\n\n// If JSON_NO_INT64 is defined, then Json only support C++ \"int\" type for\n// integer\n// Storages, and 64 bits integer support is disabled.\n// #define JSON_NO_INT64 1\n\n#if defined(_MSC_VER) && _MSC_VER <= 1200 // MSVC 6\n// Microsoft Visual Studio 6 only support conversion from __int64 to double\n// (no conversion from unsigned __int64).\n#define JSON_USE_INT64_DOUBLE_CONVERSION 1\n// Disable warning 4786 for VS6 caused by STL (identifier was truncated to '255'\n// characters in the debug information)\n// All projects I've ever seen with VS6 were using this globally (not bothering\n// with pragma push/pop).\n#pragma warning(disable : 4786)\n#endif // if defined(_MSC_VER)  &&  _MSC_VER < 1200 // MSVC 6\n\n#if defined(_MSC_VER) && _MSC_VER >= 1500 // MSVC 2008\n/// Indicates that the following function is deprecated.\n#define JSONCPP_DEPRECATED(message) __declspec(deprecated(message))\n#endif\n\n#if !defined(JSONCPP_DEPRECATED)\n#define JSONCPP_DEPRECATED(message)\n#endif // if !defined(JSONCPP_DEPRECATED)\n\nnamespace Json {\ntypedef int Int;\ntypedef unsigned int UInt;\n#if defined(JSON_NO_INT64)\ntypedef int LargestInt;\ntypedef unsigned int LargestUInt;\n#undef JSON_HAS_INT64\n#else                 // if defined(JSON_NO_INT64)\n// For Microsoft Visual use specific types as long long is not supported\n#if defined(_MSC_VER) // Microsoft Visual Studio\ntypedef __int64 Int64;\ntypedef unsigned __int64 UInt64;\n#else                 // if defined(_MSC_VER) // Other platforms, use long long\ntypedef long long int Int64;\ntypedef unsigned long long int UInt64;\n#endif // if defined(_MSC_VER)\ntypedef Int64 LargestInt;\ntypedef UInt64 LargestUInt;\n#define JSON_HAS_INT64\n#endif // if defined(JSON_NO_INT64)\n} // end namespace Json\n\n#endif // JSON_CONFIG_H_INCLUDED\n"
  },
  {
    "path": "Projects/Libraries/CSBase/Source/json/features.h",
    "content": "// Copyright 2007-2010 Baptiste Lepilleur\n// Distributed under MIT license, or public domain if desired and\n// recognized in your jurisdiction.\n// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE\n\n#ifndef CPPTL_JSON_FEATURES_H_INCLUDED\n#define CPPTL_JSON_FEATURES_H_INCLUDED\n\n#if !defined(JSON_IS_AMALGAMATION)\n#include \"forwards.h\"\n#endif // if !defined(JSON_IS_AMALGAMATION)\n\nnamespace Json {\n\n/** \\brief Configuration passed to reader and writer.\n * This configuration object can be used to force the Reader or Writer\n * to behave in a standard conforming way.\n */\nclass JSON_API Features {\npublic:\n  /** \\brief A configuration that allows all features and assumes all strings\n   * are UTF-8.\n   * - C & C++ comments are allowed\n   * - Root object can be any JSON value\n   * - Assumes Value strings are encoded in UTF-8\n   */\n  static Features all();\n\n  /** \\brief A configuration that is strictly compatible with the JSON\n   * specification.\n   * - Comments are forbidden.\n   * - Root object must be either an array or an object value.\n   * - Assumes Value strings are encoded in UTF-8\n   */\n  static Features strictMode();\n\n  /** \\brief Initialize the configuration like JsonConfig::allFeatures;\n   */\n  Features();\n\n  /// \\c true if comments are allowed. Default: \\c true.\n  bool allowComments_;\n\n  /// \\c true if root must be either an array or an object value. Default: \\c\n  /// false.\n  bool strictRoot_;\n\n  /// \\c true if dropped null placeholders are allowed. Default: \\c false.\n  bool allowDroppedNullPlaceholders_;\n\n  /// \\c true if numeric object key are allowed. Default: \\c false.\n  bool allowNumericKeys_;\n};\n\n} // namespace Json\n\n#endif // CPPTL_JSON_FEATURES_H_INCLUDED\n"
  },
  {
    "path": "Projects/Libraries/CSBase/Source/json/forwards.h",
    "content": "// Copyright 2007-2010 Baptiste Lepilleur\n// Distributed under MIT license, or public domain if desired and\n// recognized in your jurisdiction.\n// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE\n\n#ifndef JSON_FORWARDS_H_INCLUDED\n#define JSON_FORWARDS_H_INCLUDED\n\n#if !defined(JSON_IS_AMALGAMATION)\n#include \"config.h\"\n#endif // if !defined(JSON_IS_AMALGAMATION)\n\nnamespace Json {\n\n// writer.h\nclass FastWriter;\nclass StyledWriter;\n\n// reader.h\nclass Reader;\n\n// features.h\nclass Features;\n\n// value.h\ntypedef unsigned int ArrayIndex;\nclass StaticString;\nclass Path;\nclass PathArgument;\nclass Value;\nclass ValueIteratorBase;\nclass ValueIterator;\nclass ValueConstIterator;\n#ifdef JSON_VALUE_USE_INTERNAL_MAP\nclass ValueMapAllocator;\nclass ValueInternalLink;\nclass ValueInternalArray;\nclass ValueInternalMap;\n#endif // #ifdef JSON_VALUE_USE_INTERNAL_MAP\n\n} // namespace Json\n\n#endif // JSON_FORWARDS_H_INCLUDED\n"
  },
  {
    "path": "Projects/Libraries/CSBase/Source/json/json.h",
    "content": "// Copyright 2007-2010 Baptiste Lepilleur\n// Distributed under MIT license, or public domain if desired and\n// recognized in your jurisdiction.\n// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE\n\n#ifndef JSON_JSON_H_INCLUDED\n#define JSON_JSON_H_INCLUDED\n\n#include \"autolink.h\"\n#include \"value.h\"\n#include \"reader.h\"\n#include \"writer.h\"\n#include \"features.h\"\n\n#endif // JSON_JSON_H_INCLUDED\n"
  },
  {
    "path": "Projects/Libraries/CSBase/Source/json/json_batchallocator.h",
    "content": "// Copyright 2007-2010 Baptiste Lepilleur\n// Distributed under MIT license, or public domain if desired and\n// recognized in your jurisdiction.\n// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE\n\n#ifndef JSONCPP_BATCHALLOCATOR_H_INCLUDED\n#define JSONCPP_BATCHALLOCATOR_H_INCLUDED\n\n#include <stdlib.h>\n#include <assert.h>\n\n#ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION\n\nnamespace Json {\n\n/* Fast memory allocator.\n *\n * This memory allocator allocates memory for a batch of object (specified by\n * the page size, the number of object in each page).\n *\n * It does not allow the destruction of a single object. All the allocated\n * objects can be destroyed at once. The memory can be either released or reused\n * for future allocation.\n *\n * The in-place new operator must be used to construct the object using the\n * pointer returned by allocate.\n */\ntemplate <typename AllocatedType, const unsigned int objectPerAllocation>\nclass BatchAllocator {\npublic:\n  BatchAllocator(unsigned int objectsPerPage = 255)\n      : freeHead_(0), objectsPerPage_(objectsPerPage) {\n    //      printf( \"Size: %d => %s\\n\", sizeof(AllocatedType),\n    // typeid(AllocatedType).name() );\n    assert(sizeof(AllocatedType) * objectPerAllocation >=\n           sizeof(AllocatedType *)); // We must be able to store a slist in the\n                                     // object free space.\n    assert(objectsPerPage >= 16);\n    batches_ = allocateBatch(0); // allocated a dummy page\n    currentBatch_ = batches_;\n  }\n\n  ~BatchAllocator() {\n    for (BatchInfo *batch = batches_; batch;) {\n      BatchInfo *nextBatch = batch->next_;\n      free(batch);\n      batch = nextBatch;\n    }\n  }\n\n  /// allocate space for an array of objectPerAllocation object.\n  /// @warning it is the responsability of the caller to call objects\n  /// constructors.\n  AllocatedType *allocate() {\n    if (freeHead_) // returns node from free list.\n    {\n      AllocatedType *object = freeHead_;\n      freeHead_ = *(AllocatedType **)object;\n      return object;\n    }\n    if (currentBatch_->used_ == currentBatch_->end_) {\n      currentBatch_ = currentBatch_->next_;\n      while (currentBatch_ && currentBatch_->used_ == currentBatch_->end_)\n        currentBatch_ = currentBatch_->next_;\n\n      if (!currentBatch_) // no free batch found, allocate a new one\n      {\n        currentBatch_ = allocateBatch(objectsPerPage_);\n        currentBatch_->next_ = batches_; // insert at the head of the list\n        batches_ = currentBatch_;\n      }\n    }\n    AllocatedType *allocated = currentBatch_->used_;\n    currentBatch_->used_ += objectPerAllocation;\n    return allocated;\n  }\n\n  /// Release the object.\n  /// @warning it is the responsability of the caller to actually destruct the\n  /// object.\n  void release(AllocatedType *object) {\n    assert(object != 0);\n    *(AllocatedType **)object = freeHead_;\n    freeHead_ = object;\n  }\n\nprivate:\n  struct BatchInfo {\n    BatchInfo *next_;\n    AllocatedType *used_;\n    AllocatedType *end_;\n    AllocatedType buffer_[objectPerAllocation];\n  };\n\n  // disabled copy constructor and assignement operator.\n  BatchAllocator(const BatchAllocator &);\n  void operator=(const BatchAllocator &);\n\n  static BatchInfo *allocateBatch(unsigned int objectsPerPage) {\n    const unsigned int mallocSize =\n        sizeof(BatchInfo) - sizeof(AllocatedType) * objectPerAllocation +\n        sizeof(AllocatedType) * objectPerAllocation * objectsPerPage;\n    BatchInfo *batch = static_cast<BatchInfo *>(malloc(mallocSize));\n    batch->next_ = 0;\n    batch->used_ = batch->buffer_;\n    batch->end_ = batch->buffer_ + objectsPerPage;\n    return batch;\n  }\n\n  BatchInfo *batches_;\n  BatchInfo *currentBatch_;\n  /// Head of a single linked list within the allocated space of freeed object\n  AllocatedType *freeHead_;\n  unsigned int objectsPerPage_;\n};\n\n} // namespace Json\n\n#endif // ifndef JSONCPP_DOC_INCLUDE_IMPLEMENTATION\n\n#endif // JSONCPP_BATCHALLOCATOR_H_INCLUDED\n// vim: et ts=2 sts=2 sw=2 tw=0\n"
  },
  {
    "path": "Projects/Libraries/CSBase/Source/json/json_internalarray.inl",
    "content": "// Copyright 2007-2010 Baptiste Lepilleur\n// Distributed under MIT license, or public domain if desired and\n// recognized in your jurisdiction.\n// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE\n\n// included by json_value.cpp\n\nnamespace Json {\n\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// class ValueInternalArray\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n\nValueArrayAllocator::~ValueArrayAllocator()\n{\n}\n\n// //////////////////////////////////////////////////////////////////\n// class DefaultValueArrayAllocator\n// //////////////////////////////////////////////////////////////////\n#ifdef JSON_USE_SIMPLE_INTERNAL_ALLOCATOR\nclass DefaultValueArrayAllocator : public ValueArrayAllocator\n{\npublic: // overridden from ValueArrayAllocator\n   virtual ~DefaultValueArrayAllocator()\n   {\n   }\n\n   virtual ValueInternalArray *newArray()\n   {\n      return new ValueInternalArray();\n   }\n\n   virtual ValueInternalArray *newArrayCopy( const ValueInternalArray &other )\n   {\n      return new ValueInternalArray( other );\n   }\n\n   virtual void destructArray( ValueInternalArray *array )\n   {\n      delete array;\n   }\n\n   virtual void reallocateArrayPageIndex( Value **&indexes, \n                                          ValueInternalArray::PageIndex &indexCount,\n                                          ValueInternalArray::PageIndex minNewIndexCount )\n   {\n      ValueInternalArray::PageIndex newIndexCount = (indexCount*3)/2 + 1;\n      if ( minNewIndexCount > newIndexCount )\n         newIndexCount = minNewIndexCount;\n      void *newIndexes = realloc( indexes, sizeof(Value*) * newIndexCount );\n      JSON_ASSERT_MESSAGE(newIndexes, \"Couldn't realloc.\");\n      indexCount = newIndexCount;\n      indexes = static_cast<Value **>( newIndexes );\n   }\n   virtual void releaseArrayPageIndex( Value **indexes, \n                                       ValueInternalArray::PageIndex indexCount )\n   {\n      if ( indexes )\n         free( indexes );\n   }\n\n   virtual Value *allocateArrayPage()\n   {\n      return static_cast<Value *>( malloc( sizeof(Value) * ValueInternalArray::itemsPerPage ) );\n   }\n\n   virtual void releaseArrayPage( Value *value )\n   {\n      if ( value )\n         free( value );\n   }\n};\n\n#else // #ifdef JSON_USE_SIMPLE_INTERNAL_ALLOCATOR\n/// @todo make this thread-safe (lock when accessign batch allocator)\nclass DefaultValueArrayAllocator : public ValueArrayAllocator\n{\npublic: // overridden from ValueArrayAllocator\n   virtual ~DefaultValueArrayAllocator()\n   {\n   }\n\n   virtual ValueInternalArray *newArray()\n   {\n      ValueInternalArray *array = arraysAllocator_.allocate();\n      new (array) ValueInternalArray(); // placement new\n      return array;\n   }\n\n   virtual ValueInternalArray *newArrayCopy( const ValueInternalArray &other )\n   {\n      ValueInternalArray *array = arraysAllocator_.allocate();\n      new (array) ValueInternalArray( other ); // placement new\n      return array;\n   }\n\n   virtual void destructArray( ValueInternalArray *array )\n   {\n      if ( array )\n      {\n         array->~ValueInternalArray();\n         arraysAllocator_.release( array );\n      }\n   }\n\n   virtual void reallocateArrayPageIndex( Value **&indexes, \n                                          ValueInternalArray::PageIndex &indexCount,\n                                          ValueInternalArray::PageIndex minNewIndexCount )\n   {\n      ValueInternalArray::PageIndex newIndexCount = (indexCount*3)/2 + 1;\n      if ( minNewIndexCount > newIndexCount )\n         newIndexCount = minNewIndexCount;\n      void *newIndexes = realloc( indexes, sizeof(Value*) * newIndexCount );\n      JSON_ASSERT_MESSAGE(newIndexes, \"Couldn't realloc.\");\n      indexCount = newIndexCount;\n      indexes = static_cast<Value **>( newIndexes );\n   }\n   virtual void releaseArrayPageIndex( Value **indexes, \n                                       ValueInternalArray::PageIndex indexCount )\n   {\n      if ( indexes )\n         free( indexes );\n   }\n\n   virtual Value *allocateArrayPage()\n   {\n      return static_cast<Value *>( pagesAllocator_.allocate() );\n   }\n\n   virtual void releaseArrayPage( Value *value )\n   {\n      if ( value )\n         pagesAllocator_.release( value );\n   }\nprivate:\n   BatchAllocator<ValueInternalArray,1> arraysAllocator_;\n   BatchAllocator<Value,ValueInternalArray::itemsPerPage> pagesAllocator_;\n};\n#endif // #ifdef JSON_USE_SIMPLE_INTERNAL_ALLOCATOR\n\nstatic ValueArrayAllocator *&arrayAllocator()\n{\n   static DefaultValueArrayAllocator defaultAllocator;\n   static ValueArrayAllocator *arrayAllocator = &defaultAllocator;\n   return arrayAllocator;\n}\n\nstatic struct DummyArrayAllocatorInitializer {\n   DummyArrayAllocatorInitializer() \n   {\n      arrayAllocator();      // ensure arrayAllocator() statics are initialized before main().\n   }\n} dummyArrayAllocatorInitializer;\n\n// //////////////////////////////////////////////////////////////////\n// class ValueInternalArray\n// //////////////////////////////////////////////////////////////////\nbool \nValueInternalArray::equals( const IteratorState &x, \n                            const IteratorState &other )\n{\n   return x.array_ == other.array_  \n          &&  x.currentItemIndex_ == other.currentItemIndex_  \n          &&  x.currentPageIndex_ == other.currentPageIndex_;\n}\n\n\nvoid \nValueInternalArray::increment( IteratorState &it )\n{\n   JSON_ASSERT_MESSAGE( it.array_  &&\n      (it.currentPageIndex_ - it.array_->pages_)*itemsPerPage + it.currentItemIndex_\n      != it.array_->size_,\n      \"ValueInternalArray::increment(): moving iterator beyond end\" );\n   ++(it.currentItemIndex_);\n   if ( it.currentItemIndex_ == itemsPerPage )\n   {\n      it.currentItemIndex_ = 0;\n      ++(it.currentPageIndex_);\n   }\n}\n\n\nvoid \nValueInternalArray::decrement( IteratorState &it )\n{\n   JSON_ASSERT_MESSAGE( it.array_  &&  it.currentPageIndex_ == it.array_->pages_ \n                        &&  it.currentItemIndex_ == 0,\n      \"ValueInternalArray::decrement(): moving iterator beyond end\" );\n   if ( it.currentItemIndex_ == 0 )\n   {\n      it.currentItemIndex_ = itemsPerPage-1;\n      --(it.currentPageIndex_);\n   }\n   else\n   {\n      --(it.currentItemIndex_);\n   }\n}\n\n\nValue &\nValueInternalArray::unsafeDereference( const IteratorState &it )\n{\n   return (*(it.currentPageIndex_))[it.currentItemIndex_];\n}\n\n\nValue &\nValueInternalArray::dereference( const IteratorState &it )\n{\n   JSON_ASSERT_MESSAGE( it.array_  &&\n      (it.currentPageIndex_ - it.array_->pages_)*itemsPerPage + it.currentItemIndex_\n      < it.array_->size_,\n      \"ValueInternalArray::dereference(): dereferencing invalid iterator\" );\n   return unsafeDereference( it );\n}\n\nvoid \nValueInternalArray::makeBeginIterator( IteratorState &it ) const\n{\n   it.array_ = const_cast<ValueInternalArray *>( this );\n   it.currentItemIndex_ = 0;\n   it.currentPageIndex_ = pages_;\n}\n\n\nvoid \nValueInternalArray::makeIterator( IteratorState &it, ArrayIndex index ) const\n{\n   it.array_ = const_cast<ValueInternalArray *>( this );\n   it.currentItemIndex_ = index % itemsPerPage;\n   it.currentPageIndex_ = pages_ + index / itemsPerPage;\n}\n\n\nvoid \nValueInternalArray::makeEndIterator( IteratorState &it ) const\n{\n   makeIterator( it, size_ );\n}\n\n\nValueInternalArray::ValueInternalArray()\n   : pages_( 0 )\n   , size_( 0 )\n   , pageCount_( 0 )\n{\n}\n\n\nValueInternalArray::ValueInternalArray( const ValueInternalArray &other )\n   : pages_( 0 )\n   , size_( other.size_ )\n   , pageCount_( 0 )\n{\n   PageIndex minNewPages = other.size_ / itemsPerPage;\n   arrayAllocator()->reallocateArrayPageIndex( pages_, pageCount_, minNewPages );\n   JSON_ASSERT_MESSAGE( pageCount_ >= minNewPages, \n                        \"ValueInternalArray::reserve(): bad reallocation\" );\n   IteratorState itOther;\n   other.makeBeginIterator( itOther );\n   Value *value;\n   for ( ArrayIndex index = 0; index < size_; ++index, increment(itOther) )\n   {\n      if ( index % itemsPerPage == 0 )\n      {\n         PageIndex pageIndex = index / itemsPerPage;\n         value = arrayAllocator()->allocateArrayPage();\n         pages_[pageIndex] = value;\n      }\n      new (value) Value( dereference( itOther ) );\n   }\n}\n\n\nValueInternalArray &\nValueInternalArray::operator=(ValueInternalArray other)\n{\n   swap(other);\n   return *this;\n}\n\n\nValueInternalArray::~ValueInternalArray()\n{\n   // destroy all constructed items\n   IteratorState it;\n   IteratorState itEnd;\n   makeBeginIterator( it);\n   makeEndIterator( itEnd );\n   for ( ; !equals(it,itEnd); increment(it) )\n   {\n      Value *value = &dereference(it);\n      value->~Value();\n   }\n   // release all pages\n   PageIndex lastPageIndex = size_ / itemsPerPage;\n   for ( PageIndex pageIndex = 0; pageIndex < lastPageIndex; ++pageIndex )\n      arrayAllocator()->releaseArrayPage( pages_[pageIndex] );\n   // release pages index\n   arrayAllocator()->releaseArrayPageIndex( pages_, pageCount_ );\n}\n\n\nvoid \nValueInternalArray::swap( ValueInternalArray &other )\n{\n   Value **tempPages = pages_;\n   pages_ = other.pages_;\n   other.pages_ = tempPages;\n   ArrayIndex tempSize = size_;\n   size_ = other.size_;\n   other.size_ = tempSize;\n   PageIndex tempPageCount = pageCount_;\n   pageCount_ = other.pageCount_;\n   other.pageCount_ = tempPageCount;\n}\n\nvoid \nValueInternalArray::clear()\n{\n   ValueInternalArray dummy;\n   swap( dummy );\n}\n\n\nvoid \nValueInternalArray::resize( ArrayIndex newSize )\n{\n   if ( newSize == 0 )\n      clear();\n   else if ( newSize < size_ )\n   {\n      IteratorState it;\n      IteratorState itEnd;\n      makeIterator( it, newSize );\n      makeIterator( itEnd, size_ );\n      for ( ; !equals(it,itEnd); increment(it) )\n      {\n         Value *value = &dereference(it);\n         value->~Value();\n      }\n      PageIndex pageIndex = (newSize + itemsPerPage - 1) / itemsPerPage;\n      PageIndex lastPageIndex = size_ / itemsPerPage;\n      for ( ; pageIndex < lastPageIndex; ++pageIndex )\n         arrayAllocator()->releaseArrayPage( pages_[pageIndex] );\n      size_ = newSize;\n   }\n   else if ( newSize > size_ )\n      resolveReference( newSize );\n}\n\n\nvoid \nValueInternalArray::makeIndexValid( ArrayIndex index )\n{\n   // Need to enlarge page index ?\n   if ( index >= pageCount_ * itemsPerPage )\n   {\n      PageIndex minNewPages = (index + 1) / itemsPerPage;\n      arrayAllocator()->reallocateArrayPageIndex( pages_, pageCount_, minNewPages );\n      JSON_ASSERT_MESSAGE( pageCount_ >= minNewPages, \"ValueInternalArray::reserve(): bad reallocation\" );\n   }\n\n   // Need to allocate new pages ?\n   ArrayIndex nextPageIndex = \n      (size_ % itemsPerPage) != 0 ? size_ - (size_%itemsPerPage) + itemsPerPage\n                                  : size_;\n   if ( nextPageIndex <= index )\n   {\n      PageIndex pageIndex = nextPageIndex / itemsPerPage;\n      PageIndex pageToAllocate = (index - nextPageIndex) / itemsPerPage + 1;\n      for ( ; pageToAllocate-- > 0; ++pageIndex )\n         pages_[pageIndex] = arrayAllocator()->allocateArrayPage();\n   }\n\n   // Initialize all new entries\n   IteratorState it;\n   IteratorState itEnd;\n   makeIterator( it, size_ );\n   size_ = index + 1;\n   makeIterator( itEnd, size_ );\n   for ( ; !equals(it,itEnd); increment(it) )\n   {\n      Value *value = &dereference(it);\n      new (value) Value(); // Construct a default value using placement new\n   }\n}\n\nValue &\nValueInternalArray::resolveReference( ArrayIndex index )\n{\n   if ( index >= size_ )\n      makeIndexValid( index );\n   return pages_[index/itemsPerPage][index%itemsPerPage];\n}\n\nValue *\nValueInternalArray::find( ArrayIndex index ) const\n{\n   if ( index >= size_ )\n      return 0;\n   return &(pages_[index/itemsPerPage][index%itemsPerPage]);\n}\n\nValueInternalArray::ArrayIndex \nValueInternalArray::size() const\n{\n   return size_;\n}\n\nint \nValueInternalArray::distance( const IteratorState &x, const IteratorState &y )\n{\n   return indexOf(y) - indexOf(x);\n}\n\n\nValueInternalArray::ArrayIndex \nValueInternalArray::indexOf( const IteratorState &iterator )\n{\n   if ( !iterator.array_ )\n      return ArrayIndex(-1);\n   return ArrayIndex(\n      (iterator.currentPageIndex_ - iterator.array_->pages_) * itemsPerPage \n      + iterator.currentItemIndex_ );\n}\n\n\nint \nValueInternalArray::compare( const ValueInternalArray &other ) const\n{\n   int sizeDiff( size_ - other.size_ );\n   if ( sizeDiff != 0 )\n      return sizeDiff;\n   \n   for ( ArrayIndex index =0; index < size_; ++index )\n   {\n      int diff = pages_[index/itemsPerPage][index%itemsPerPage].compare( \n         other.pages_[index/itemsPerPage][index%itemsPerPage] );\n      if ( diff != 0 )\n         return diff;\n   }\n   return 0;\n}\n\n} // namespace Json\n// vim: et ts=3 sts=3 sw=3 tw=0\n"
  },
  {
    "path": "Projects/Libraries/CSBase/Source/json/json_internalmap.inl",
    "content": "// Copyright 2007-2010 Baptiste Lepilleur\n// Distributed under MIT license, or public domain if desired and\n// recognized in your jurisdiction.\n// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE\n\n// included by json_value.cpp\n\nnamespace Json {\n\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// class ValueInternalMap\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n\n/** \\internal MUST be safely initialized using memset( this, 0, sizeof(ValueInternalLink) );\n   * This optimization is used by the fast allocator.\n   */\nValueInternalLink::ValueInternalLink()\n   : previous_( 0 )\n   , next_( 0 )\n{\n}\n\nValueInternalLink::~ValueInternalLink()\n{ \n   for ( int index =0; index < itemPerLink; ++index )\n   {\n      if ( !items_[index].isItemAvailable() )\n      {\n         if ( !items_[index].isMemberNameStatic() )\n            free( keys_[index] );\n      }\n      else\n         break;\n   }\n}\n\n\n\nValueMapAllocator::~ValueMapAllocator()\n{\n}\n\n#ifdef JSON_USE_SIMPLE_INTERNAL_ALLOCATOR\nclass DefaultValueMapAllocator : public ValueMapAllocator\n{\npublic: // overridden from ValueMapAllocator\n   virtual ValueInternalMap *newMap()\n   {\n      return new ValueInternalMap();\n   }\n\n   virtual ValueInternalMap *newMapCopy( const ValueInternalMap &other )\n   {\n      return new ValueInternalMap( other );\n   }\n\n   virtual void destructMap( ValueInternalMap *map )\n   {\n      delete map;\n   }\n\n   virtual ValueInternalLink *allocateMapBuckets( unsigned int size )\n   {\n      return new ValueInternalLink[size];\n   }\n\n   virtual void releaseMapBuckets( ValueInternalLink *links )\n   {\n      delete [] links;\n   }\n\n   virtual ValueInternalLink *allocateMapLink()\n   {\n      return new ValueInternalLink();\n   }\n\n   virtual void releaseMapLink( ValueInternalLink *link )\n   {\n      delete link;\n   }\n};\n#else\n/// @todo make this thread-safe (lock when accessign batch allocator)\nclass DefaultValueMapAllocator : public ValueMapAllocator\n{\npublic: // overridden from ValueMapAllocator\n   virtual ValueInternalMap *newMap()\n   {\n      ValueInternalMap *map = mapsAllocator_.allocate();\n      new (map) ValueInternalMap(); // placement new\n      return map;\n   }\n\n   virtual ValueInternalMap *newMapCopy( const ValueInternalMap &other )\n   {\n      ValueInternalMap *map = mapsAllocator_.allocate();\n      new (map) ValueInternalMap( other ); // placement new\n      return map;\n   }\n\n   virtual void destructMap( ValueInternalMap *map )\n   {\n      if ( map )\n      {\n         map->~ValueInternalMap();\n         mapsAllocator_.release( map );\n      }\n   }\n\n   virtual ValueInternalLink *allocateMapBuckets( unsigned int size )\n   {\n      return new ValueInternalLink[size];\n   }\n\n   virtual void releaseMapBuckets( ValueInternalLink *links )\n   {\n      delete [] links;\n   }\n\n   virtual ValueInternalLink *allocateMapLink()\n   {\n      ValueInternalLink *link = linksAllocator_.allocate();\n      memset( link, 0, sizeof(ValueInternalLink) );\n      return link;\n   }\n\n   virtual void releaseMapLink( ValueInternalLink *link )\n   {\n      link->~ValueInternalLink();\n      linksAllocator_.release( link );\n   }\nprivate:\n   BatchAllocator<ValueInternalMap,1> mapsAllocator_;\n   BatchAllocator<ValueInternalLink,1> linksAllocator_;\n};\n#endif\n\nstatic ValueMapAllocator *&mapAllocator()\n{\n   static DefaultValueMapAllocator defaultAllocator;\n   static ValueMapAllocator *mapAllocator = &defaultAllocator;\n   return mapAllocator;\n}\n\nstatic struct DummyMapAllocatorInitializer {\n   DummyMapAllocatorInitializer() \n   {\n      mapAllocator();      // ensure mapAllocator() statics are initialized before main().\n   }\n} dummyMapAllocatorInitializer;\n\n\n\n// h(K) = value * K >> w ; with w = 32 & K prime w.r.t. 2^32.\n\n/*\nuse linked list hash map. \nbuckets array is a container.\nlinked list element contains 6 key/values. (memory = (16+4) * 6 + 4 = 124)\nvalue have extra state: valid, available, deleted\n*/\n\n\nValueInternalMap::ValueInternalMap()\n   : buckets_( 0 )\n   , tailLink_( 0 )\n   , bucketsSize_( 0 )\n   , itemCount_( 0 )\n{\n}\n\n\nValueInternalMap::ValueInternalMap( const ValueInternalMap &other )\n   : buckets_( 0 )\n   , tailLink_( 0 )\n   , bucketsSize_( 0 )\n   , itemCount_( 0 )\n{\n   reserve( other.itemCount_ );\n   IteratorState it;\n   IteratorState itEnd;\n   other.makeBeginIterator( it );\n   other.makeEndIterator( itEnd );\n   for ( ; !equals(it,itEnd); increment(it) )\n   {\n      bool isStatic;\n      const char *memberName = key( it, isStatic );\n      const Value &aValue = value( it );\n      resolveReference(memberName, isStatic) = aValue;\n   }\n}\n\n\nValueInternalMap &\nValueInternalMap::operator=(ValueInternalMap other)\n{\n   swap(other);\n   return *this;\n}\n\n\nValueInternalMap::~ValueInternalMap()\n{\n   if ( buckets_ )\n   {\n      for ( BucketIndex bucketIndex =0; bucketIndex < bucketsSize_; ++bucketIndex )\n      {\n         ValueInternalLink *link = buckets_[bucketIndex].next_;\n         while ( link )\n         {\n            ValueInternalLink *linkToRelease = link;\n            link = link->next_;\n            mapAllocator()->releaseMapLink( linkToRelease );\n         }\n      }\n      mapAllocator()->releaseMapBuckets( buckets_ );\n   }\n}\n\n\nvoid \nValueInternalMap::swap( ValueInternalMap &other )\n{\n   ValueInternalLink *tempBuckets = buckets_;\n   buckets_ = other.buckets_;\n   other.buckets_ = tempBuckets;\n   ValueInternalLink *tempTailLink = tailLink_;\n   tailLink_ = other.tailLink_;\n   other.tailLink_ = tempTailLink;\n   BucketIndex tempBucketsSize = bucketsSize_;\n   bucketsSize_ = other.bucketsSize_;\n   other.bucketsSize_ = tempBucketsSize;\n   BucketIndex tempItemCount = itemCount_;\n   itemCount_ = other.itemCount_;\n   other.itemCount_ = tempItemCount;\n}\n\n\nvoid \nValueInternalMap::clear()\n{\n   ValueInternalMap dummy;\n   swap( dummy );\n}\n\n\nValueInternalMap::BucketIndex \nValueInternalMap::size() const\n{\n   return itemCount_;\n}\n\nbool \nValueInternalMap::reserveDelta( BucketIndex growth )\n{\n   return reserve( itemCount_ + growth );\n}\n\nbool \nValueInternalMap::reserve( BucketIndex newItemCount )\n{\n   if ( !buckets_  &&  newItemCount > 0 )\n   {\n      buckets_ = mapAllocator()->allocateMapBuckets( 1 );\n      bucketsSize_ = 1;\n      tailLink_ = &buckets_[0];\n   }\n//   BucketIndex idealBucketCount = (newItemCount + ValueInternalLink::itemPerLink) / ValueInternalLink::itemPerLink;\n   return true;\n}\n\n\nconst Value *\nValueInternalMap::find( const char *key ) const\n{\n   if ( !bucketsSize_ )\n      return 0;\n   HashKey hashedKey = hash( key );\n   BucketIndex bucketIndex = hashedKey % bucketsSize_;\n   for ( const ValueInternalLink *current = &buckets_[bucketIndex]; \n         current != 0; \n         current = current->next_ )\n   {\n      for ( BucketIndex index=0; index < ValueInternalLink::itemPerLink; ++index )\n      {\n         if ( current->items_[index].isItemAvailable() )\n            return 0;\n         if ( strcmp( key, current->keys_[index] ) == 0 )\n            return &current->items_[index];\n      }\n   }\n   return 0;\n}\n\n\nValue *\nValueInternalMap::find( const char *key )\n{\n   const ValueInternalMap *constThis = this;\n   return const_cast<Value *>( constThis->find( key ) );\n}\n\n\nValue &\nValueInternalMap::resolveReference( const char *key,\n                                    bool isStatic )\n{\n   HashKey hashedKey = hash( key );\n   if ( bucketsSize_ )\n   {\n      BucketIndex bucketIndex = hashedKey % bucketsSize_;\n      ValueInternalLink **previous = 0;\n      BucketIndex index;\n      for ( ValueInternalLink *current = &buckets_[bucketIndex]; \n            current != 0; \n            previous = &current->next_, current = current->next_ )\n      {\n         for ( index=0; index < ValueInternalLink::itemPerLink; ++index )\n         {\n            if ( current->items_[index].isItemAvailable() )\n               return setNewItem( key, isStatic, current, index );\n            if ( strcmp( key, current->keys_[index] ) == 0 )\n               return current->items_[index];\n         }\n      }\n   }\n\n   reserveDelta( 1 );\n   return unsafeAdd( key, isStatic, hashedKey );\n}\n\n\nvoid \nValueInternalMap::remove( const char *key )\n{\n   HashKey hashedKey = hash( key );\n   if ( !bucketsSize_ )\n      return;\n   BucketIndex bucketIndex = hashedKey % bucketsSize_;\n   for ( ValueInternalLink *link = &buckets_[bucketIndex]; \n         link != 0; \n         link = link->next_ )\n   {\n      BucketIndex index;\n      for ( index =0; index < ValueInternalLink::itemPerLink; ++index )\n      {\n         if ( link->items_[index].isItemAvailable() )\n            return;\n         if ( strcmp( key, link->keys_[index] ) == 0 )\n         {\n            doActualRemove( link, index, bucketIndex );\n            return;\n         }\n      }\n   }\n}\n\nvoid \nValueInternalMap::doActualRemove( ValueInternalLink *link, \n                                  BucketIndex index,\n                                  BucketIndex bucketIndex )\n{\n   // find last item of the bucket and swap it with the 'removed' one.\n   // set removed items flags to 'available'.\n   // if last page only contains 'available' items, then desallocate it (it's empty)\n   ValueInternalLink *&lastLink = getLastLinkInBucket( index );\n   BucketIndex lastItemIndex = 1; // a link can never be empty, so start at 1\n   for ( ;   \n         lastItemIndex < ValueInternalLink::itemPerLink; \n         ++lastItemIndex ) // may be optimized with dicotomic search\n   {\n      if ( lastLink->items_[lastItemIndex].isItemAvailable() )\n         break;\n   }\n   \n   BucketIndex lastUsedIndex = lastItemIndex - 1;\n   Value *valueToDelete = &link->items_[index];\n   Value *valueToPreserve = &lastLink->items_[lastUsedIndex];\n   if ( valueToDelete != valueToPreserve )\n      valueToDelete->swap( *valueToPreserve );\n   if ( lastUsedIndex == 0 )  // page is now empty\n   {  // remove it from bucket linked list and delete it.\n      ValueInternalLink *linkPreviousToLast = lastLink->previous_;\n      if ( linkPreviousToLast != 0 )   // can not deleted bucket link.\n      {\n         mapAllocator()->releaseMapLink( lastLink );\n         linkPreviousToLast->next_ = 0;\n         lastLink = linkPreviousToLast;\n      }\n   }\n   else\n   {\n      Value dummy;\n      valueToPreserve->swap( dummy ); // restore deleted to default Value.\n      valueToPreserve->setItemUsed( false );\n   }\n   --itemCount_;\n}\n\n\nValueInternalLink *&\nValueInternalMap::getLastLinkInBucket( BucketIndex bucketIndex )\n{\n   if ( bucketIndex == bucketsSize_ - 1 )\n      return tailLink_;\n   ValueInternalLink *&previous = buckets_[bucketIndex+1].previous_;\n   if ( !previous )\n      previous = &buckets_[bucketIndex];\n   return previous;\n}\n\n\nValue &\nValueInternalMap::setNewItem( const char *key, \n                              bool isStatic,\n                              ValueInternalLink *link, \n                              BucketIndex index )\n{\n   char *duplicatedKey = makeMemberName( key );\n   ++itemCount_;\n   link->keys_[index] = duplicatedKey;\n   link->items_[index].setItemUsed();\n   link->items_[index].setMemberNameIsStatic( isStatic );\n   return link->items_[index]; // items already default constructed.\n}\n\n\nValue &\nValueInternalMap::unsafeAdd( const char *key, \n                             bool isStatic, \n                             HashKey hashedKey )\n{\n   JSON_ASSERT_MESSAGE( bucketsSize_ > 0, \"ValueInternalMap::unsafeAdd(): internal logic error.\" );\n   BucketIndex bucketIndex = hashedKey % bucketsSize_;\n   ValueInternalLink *&previousLink = getLastLinkInBucket( bucketIndex );\n   ValueInternalLink *link = previousLink;\n   BucketIndex index;\n   for ( index =0; index < ValueInternalLink::itemPerLink; ++index )\n   {\n      if ( link->items_[index].isItemAvailable() )\n         break;\n   }\n   if ( index == ValueInternalLink::itemPerLink ) // need to add a new page\n   {\n      ValueInternalLink *newLink = mapAllocator()->allocateMapLink();\n      index = 0;\n      link->next_ = newLink;\n      previousLink = newLink;\n      link = newLink;\n   }\n   return setNewItem( key, isStatic, link, index );\n}\n\n\nValueInternalMap::HashKey \nValueInternalMap::hash( const char *key ) const\n{\n   HashKey hash = 0;\n   while ( *key )\n      hash += *key++ * 37;\n   return hash;\n}\n\n\nint \nValueInternalMap::compare( const ValueInternalMap &other ) const\n{\n   int sizeDiff( itemCount_ - other.itemCount_ );\n   if ( sizeDiff != 0 )\n      return sizeDiff;\n   // Strict order guaranty is required. Compare all keys FIRST, then compare values.\n   IteratorState it;\n   IteratorState itEnd;\n   makeBeginIterator( it );\n   makeEndIterator( itEnd );\n   for ( ; !equals(it,itEnd); increment(it) )\n   {\n      if ( !other.find( key( it ) ) )\n         return 1;\n   }\n\n   // All keys are equals, let's compare values\n   makeBeginIterator( it );\n   for ( ; !equals(it,itEnd); increment(it) )\n   {\n      const Value *otherValue = other.find( key( it ) );\n      int valueDiff = value(it).compare( *otherValue );\n      if ( valueDiff != 0 )\n         return valueDiff;\n   }\n   return 0;\n}\n\n\nvoid \nValueInternalMap::makeBeginIterator( IteratorState &it ) const\n{\n   it.map_ = const_cast<ValueInternalMap *>( this );\n   it.bucketIndex_ = 0;\n   it.itemIndex_ = 0;\n   it.link_ = buckets_;\n}\n\n\nvoid \nValueInternalMap::makeEndIterator( IteratorState &it ) const\n{\n   it.map_ = const_cast<ValueInternalMap *>( this );\n   it.bucketIndex_ = bucketsSize_;\n   it.itemIndex_ = 0;\n   it.link_ = 0;\n}\n\n\nbool \nValueInternalMap::equals( const IteratorState &x, const IteratorState &other )\n{\n   return x.map_ == other.map_  \n          &&  x.bucketIndex_ == other.bucketIndex_  \n          &&  x.link_ == other.link_\n          &&  x.itemIndex_ == other.itemIndex_;\n}\n\n\nvoid \nValueInternalMap::incrementBucket( IteratorState &iterator )\n{\n   ++iterator.bucketIndex_;\n   JSON_ASSERT_MESSAGE( iterator.bucketIndex_ <= iterator.map_->bucketsSize_,\n      \"ValueInternalMap::increment(): attempting to iterate beyond end.\" );\n   if ( iterator.bucketIndex_ == iterator.map_->bucketsSize_ )\n      iterator.link_ = 0;\n   else\n      iterator.link_ = &(iterator.map_->buckets_[iterator.bucketIndex_]);\n   iterator.itemIndex_ = 0;\n}\n\n\nvoid \nValueInternalMap::increment( IteratorState &iterator )\n{\n   JSON_ASSERT_MESSAGE( iterator.map_, \"Attempting to iterator using invalid iterator.\" );\n   ++iterator.itemIndex_;\n   if ( iterator.itemIndex_ == ValueInternalLink::itemPerLink )\n   {\n      JSON_ASSERT_MESSAGE( iterator.link_ != 0,\n         \"ValueInternalMap::increment(): attempting to iterate beyond end.\" );\n      iterator.link_ = iterator.link_->next_;\n      if ( iterator.link_ == 0 )\n         incrementBucket( iterator );\n   }\n   else if ( iterator.link_->items_[iterator.itemIndex_].isItemAvailable() )\n   {\n      incrementBucket( iterator );\n   }\n}\n\n\nvoid \nValueInternalMap::decrement( IteratorState &iterator )\n{\n   if ( iterator.itemIndex_ == 0 )\n   {\n      JSON_ASSERT_MESSAGE( iterator.map_, \"Attempting to iterate using invalid iterator.\" );\n      if ( iterator.link_ == &iterator.map_->buckets_[iterator.bucketIndex_] )\n      {\n         JSON_ASSERT_MESSAGE( iterator.bucketIndex_ > 0, \"Attempting to iterate beyond beginning.\" );\n         --(iterator.bucketIndex_);\n      }\n      iterator.link_ = iterator.link_->previous_;\n      iterator.itemIndex_ = ValueInternalLink::itemPerLink - 1;\n   }\n}\n\n\nconst char *\nValueInternalMap::key( const IteratorState &iterator )\n{\n   JSON_ASSERT_MESSAGE( iterator.link_, \"Attempting to iterate using invalid iterator.\" );\n   return iterator.link_->keys_[iterator.itemIndex_];\n}\n\nconst char *\nValueInternalMap::key( const IteratorState &iterator, bool &isStatic )\n{\n   JSON_ASSERT_MESSAGE( iterator.link_, \"Attempting to iterate using invalid iterator.\" );\n   isStatic = iterator.link_->items_[iterator.itemIndex_].isMemberNameStatic();\n   return iterator.link_->keys_[iterator.itemIndex_];\n}\n\n\nValue &\nValueInternalMap::value( const IteratorState &iterator )\n{\n   JSON_ASSERT_MESSAGE( iterator.link_, \"Attempting to iterate using invalid iterator.\" );\n   return iterator.link_->items_[iterator.itemIndex_];\n}\n\n\nint \nValueInternalMap::distance( const IteratorState &x, const IteratorState &y )\n{\n   int offset = 0;\n   IteratorState it = x;\n   while ( !equals( it, y ) )\n      increment( it );\n   return offset;\n}\n\n} // namespace Json\n// vim: et ts=3 sts=3 sw=3 tw=0\n"
  },
  {
    "path": "Projects/Libraries/CSBase/Source/json/json_reader.cpp",
    "content": "// Copyright 2007-2011 Baptiste Lepilleur\n// Distributed under MIT license, or public domain if desired and\n// recognized in your jurisdiction.\n// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE\n\n#if !defined(JSON_IS_AMALGAMATION)\n#include <json/assertions.h>\n#include <json/reader.h>\n#include <json/value.h>\n#include \"json_tool.h\"\n#endif // if !defined(JSON_IS_AMALGAMATION)\n#include <utility>\n#include <cstdio>\n#include <cassert>\n#include <cstring>\n#include <istream>\n\n#if defined(_MSC_VER) && _MSC_VER >= 1400 // VC++ 8.0\n// Disable warning about strdup being deprecated.\n#pragma warning(disable : 4996)\n#endif\n\nnamespace Json {\n\n// Implementation of class Features\n// ////////////////////////////////\n\nFeatures::Features()\n    : allowComments_(true), strictRoot_(false),\n      allowDroppedNullPlaceholders_(false), allowNumericKeys_(false) {}\n\nFeatures Features::all() { return Features(); }\n\nFeatures Features::strictMode() {\n  Features features;\n  features.allowComments_ = false;\n  features.strictRoot_ = true;\n  features.allowDroppedNullPlaceholders_ = false;\n  features.allowNumericKeys_ = false;\n  return features;\n}\n\n// Implementation of class Reader\n// ////////////////////////////////\n\nstatic inline bool in(Reader::Char c,\n                      Reader::Char c1,\n                      Reader::Char c2,\n                      Reader::Char c3,\n                      Reader::Char c4) {\n  return c == c1 || c == c2 || c == c3 || c == c4;\n}\n\nstatic inline bool in(Reader::Char c,\n                      Reader::Char c1,\n                      Reader::Char c2,\n                      Reader::Char c3,\n                      Reader::Char c4,\n                      Reader::Char c5) {\n  return c == c1 || c == c2 || c == c3 || c == c4 || c == c5;\n}\n\nstatic bool containsNewLine(Reader::Location begin, Reader::Location end) {\n  for (; begin < end; ++begin)\n    if (*begin == '\\n' || *begin == '\\r')\n      return true;\n  return false;\n}\n\n// Class Reader\n// //////////////////////////////////////////////////////////////////\n\nReader::Reader()\n    : errors_(), document_(), begin_(), end_(), current_(), lastValueEnd_(),\n      lastValue_(), commentsBefore_(), features_(Features::all()),\n      collectComments_() {}\n\nReader::Reader(const Features &features)\n    : errors_(), document_(), begin_(), end_(), current_(), lastValueEnd_(),\n      lastValue_(), commentsBefore_(), features_(features), collectComments_() {\n}\n\nbool\nReader::parse(const std::string &document, Value &root, bool collectComments) {\n  document_ = document;\n  const char *begin = document_.c_str();\n  const char *end = begin + document_.length();\n  return parse(begin, end, root, collectComments);\n}\n\nbool Reader::parse(std::istream &sin, Value &root, bool collectComments) {\n  // std::istream_iterator<char> begin(sin);\n  // std::istream_iterator<char> end;\n  // Those would allow streamed input from a file, if parse() were a\n  // template function.\n\n  // Since std::string is reference-counted, this at least does not\n  // create an extra copy.\n  std::string doc;\n  std::getline(sin, doc, (char)EOF);\n  return parse(doc, root, collectComments);\n}\n\nbool Reader::parse(const char *beginDoc,\n                   const char *endDoc,\n                   Value &root,\n                   bool collectComments) {\n  if (!features_.allowComments_) {\n    collectComments = false;\n  }\n\n  begin_ = beginDoc;\n  end_ = endDoc;\n  collectComments_ = collectComments;\n  current_ = begin_;\n  lastValueEnd_ = 0;\n  lastValue_ = 0;\n  commentsBefore_ = \"\";\n  errors_.clear();\n  while (!nodes_.empty())\n    nodes_.pop();\n  nodes_.push(&root);\n\n  bool successful = readValue();\n  Token token;\n  skipCommentTokens(token);\n  if (collectComments_ && !commentsBefore_.empty())\n    root.setComment(commentsBefore_, commentAfter);\n  if (features_.strictRoot_) {\n    if (!root.isArray() && !root.isObject()) {\n      // Set error location to start of doc, ideally should be first token found\n      // in doc\n      token.type_ = tokenError;\n      token.start_ = beginDoc;\n      token.end_ = endDoc;\n      addError(\n          \"A valid JSON document must be either an array or an object value.\",\n          token);\n      return false;\n    }\n  }\n  return successful;\n}\n\nbool Reader::readValue() {\n  Token token;\n  skipCommentTokens(token);\n  bool successful = true;\n\n  if (collectComments_ && !commentsBefore_.empty()) {\n    // Remove newline characters at the end of the comments\n    size_t lastNonNewline = commentsBefore_.find_last_not_of(\"\\r\\n\");\n    if (lastNonNewline != std::string::npos) {\n      commentsBefore_.erase(lastNonNewline + 1);\n    } else {\n      commentsBefore_.clear();\n    }\n\n    currentValue().setComment(commentsBefore_, commentBefore);\n    commentsBefore_ = \"\";\n  }\n\n  switch (token.type_) {\n  case tokenObjectBegin:\n    successful = readObject(token);\n    currentValue().setOffsetLimit(current_ - begin_);\n    break;\n  case tokenArrayBegin:\n    successful = readArray(token);\n    currentValue().setOffsetLimit(current_ - begin_);\n    break;\n  case tokenNumber:\n    successful = decodeNumber(token);\n    break;\n  case tokenString:\n    successful = decodeString(token);\n    break;\n  case tokenTrue:\n    currentValue() = true;\n    currentValue().setOffsetStart(token.start_ - begin_);\n    currentValue().setOffsetLimit(token.end_ - begin_);\n    break;\n  case tokenFalse:\n    currentValue() = false;\n    currentValue().setOffsetStart(token.start_ - begin_);\n    currentValue().setOffsetLimit(token.end_ - begin_);\n    break;\n  case tokenNull:\n    currentValue() = Value();\n    currentValue().setOffsetStart(token.start_ - begin_);\n    currentValue().setOffsetLimit(token.end_ - begin_);\n    break;\n  case tokenArraySeparator:\n    if (features_.allowDroppedNullPlaceholders_) {\n      // \"Un-read\" the current token and mark the current value as a null\n      // token.\n      current_--;\n      currentValue() = Value();\n      currentValue().setOffsetStart(current_ - begin_ - 1);\n      currentValue().setOffsetLimit(current_ - begin_);\n      break;\n    }\n  // Else, fall through...\n  default:\n    currentValue().setOffsetStart(token.start_ - begin_);\n    currentValue().setOffsetLimit(token.end_ - begin_);\n    return addError(\"Syntax error: value, object or array expected.\", token);\n  }\n\n  if (collectComments_) {\n    lastValueEnd_ = current_;\n    lastValue_ = &currentValue();\n  }\n\n  return successful;\n}\n\nvoid Reader::skipCommentTokens(Token &token) {\n  if (features_.allowComments_) {\n    do {\n      readToken(token);\n    } while (token.type_ == tokenComment);\n  } else {\n    readToken(token);\n  }\n}\n\nbool Reader::expectToken(TokenType type, Token &token, const char *message) {\n  readToken(token);\n  if (token.type_ != type)\n    return addError(message, token);\n  return true;\n}\n\nbool Reader::readToken(Token &token) {\n  skipSpaces();\n  token.start_ = current_;\n  Char c = getNextChar();\n  bool ok = true;\n  switch (c) {\n  case '{':\n    token.type_ = tokenObjectBegin;\n    break;\n  case '}':\n    token.type_ = tokenObjectEnd;\n    break;\n  case '[':\n    token.type_ = tokenArrayBegin;\n    break;\n  case ']':\n    token.type_ = tokenArrayEnd;\n    break;\n  case '\"':\n    token.type_ = tokenString;\n    ok = readString();\n    break;\n  case '/':\n    token.type_ = tokenComment;\n    ok = readComment();\n    break;\n  case '0':\n  case '1':\n  case '2':\n  case '3':\n  case '4':\n  case '5':\n  case '6':\n  case '7':\n  case '8':\n  case '9':\n  case '-':\n    token.type_ = tokenNumber;\n    readNumber();\n    break;\n  case 't':\n    token.type_ = tokenTrue;\n    ok = match(\"rue\", 3);\n    break;\n  case 'f':\n    token.type_ = tokenFalse;\n    ok = match(\"alse\", 4);\n    break;\n  case 'n':\n    token.type_ = tokenNull;\n    ok = match(\"ull\", 3);\n    break;\n  case ',':\n    token.type_ = tokenArraySeparator;\n    break;\n  case ':':\n    token.type_ = tokenMemberSeparator;\n    break;\n  case 0:\n    token.type_ = tokenEndOfStream;\n    break;\n  default:\n    ok = false;\n    break;\n  }\n  if (!ok)\n    token.type_ = tokenError;\n  token.end_ = current_;\n  return true;\n}\n\nvoid Reader::skipSpaces() {\n  while (current_ != end_) {\n    Char c = *current_;\n    if (c == ' ' || c == '\\t' || c == '\\r' || c == '\\n')\n      ++current_;\n    else\n      break;\n  }\n}\n\nbool Reader::match(Location pattern, int patternLength) {\n  if (end_ - current_ < patternLength)\n    return false;\n  int index = patternLength;\n  while (index--)\n    if (current_[index] != pattern[index])\n      return false;\n  current_ += patternLength;\n  return true;\n}\n\nbool Reader::readComment() {\n  Location commentBegin = current_ - 1;\n  Char c = getNextChar();\n  bool successful = false;\n  if (c == '*')\n    successful = readCStyleComment();\n  else if (c == '/')\n    successful = readCppStyleComment();\n  if (!successful)\n    return false;\n\n  if (collectComments_) {\n    CommentPlacement placement = commentBefore;\n    if (lastValueEnd_ && !containsNewLine(lastValueEnd_, commentBegin)) {\n      if (c != '*' || !containsNewLine(commentBegin, current_))\n        placement = commentAfterOnSameLine;\n    }\n\n    addComment(commentBegin, current_, placement);\n  }\n  return true;\n}\n\nvoid\nReader::addComment(Location begin, Location end, CommentPlacement placement) {\n  assert(collectComments_);\n  if (placement == commentAfterOnSameLine) {\n    assert(lastValue_ != 0);\n    lastValue_->setComment(std::string(begin, end), placement);\n  } else {\n    if (!commentsBefore_.empty())\n      commentsBefore_ += \"\\n\";\n    commentsBefore_ += std::string(begin, end);\n  }\n}\n\nbool Reader::readCStyleComment() {\n  while (current_ != end_) {\n    Char c = getNextChar();\n    if (c == '*' && *current_ == '/')\n      break;\n  }\n  return getNextChar() == '/';\n}\n\nbool Reader::readCppStyleComment() {\n  while (current_ != end_) {\n    Char c = getNextChar();\n    if (c == '\\r' || c == '\\n')\n      break;\n  }\n  return true;\n}\n\nvoid Reader::readNumber() {\n  while (current_ != end_) {\n    if (!(*current_ >= '0' && *current_ <= '9') &&\n        !in(*current_, '.', 'e', 'E', '+', '-'))\n      break;\n    ++current_;\n  }\n}\n\nbool Reader::readString() {\n  Char c = 0;\n  while (current_ != end_) {\n    c = getNextChar();\n    if (c == '\\\\')\n      getNextChar();\n    else if (c == '\"')\n      break;\n  }\n  return c == '\"';\n}\n\nbool Reader::readObject(Token &tokenStart) {\n  Token tokenName;\n  std::string name;\n  currentValue() = Value(objectValue);\n  currentValue().setOffsetStart(tokenStart.start_ - begin_);\n  while (readToken(tokenName)) {\n    bool initialTokenOk = true;\n    while (tokenName.type_ == tokenComment && initialTokenOk)\n      initialTokenOk = readToken(tokenName);\n    if (!initialTokenOk)\n      break;\n    if (tokenName.type_ == tokenObjectEnd && name.empty()) // empty object\n      return true;\n    name = \"\";\n    if (tokenName.type_ == tokenString) {\n      if (!decodeString(tokenName, name))\n        return recoverFromError(tokenObjectEnd);\n    } else if (tokenName.type_ == tokenNumber && features_.allowNumericKeys_) {\n      Value numberName;\n      if (!decodeNumber(tokenName, numberName))\n        return recoverFromError(tokenObjectEnd);\n      name = numberName.asString();\n    } else {\n      break;\n    }\n\n    Token colon;\n    if (!readToken(colon) || colon.type_ != tokenMemberSeparator) {\n      return addErrorAndRecover(\n          \"Missing ':' after object member name\", colon, tokenObjectEnd);\n    }\n    Value &value = currentValue()[name];\n    nodes_.push(&value);\n    bool ok = readValue();\n    nodes_.pop();\n    if (!ok) // error already set\n      return recoverFromError(tokenObjectEnd);\n\n    Token comma;\n    if (!readToken(comma) ||\n        (comma.type_ != tokenObjectEnd && comma.type_ != tokenArraySeparator &&\n         comma.type_ != tokenComment)) {\n      return addErrorAndRecover(\n          \"Missing ',' or '}' in object declaration\", comma, tokenObjectEnd);\n    }\n    bool finalizeTokenOk = true;\n    while (comma.type_ == tokenComment && finalizeTokenOk)\n      finalizeTokenOk = readToken(comma);\n    if (comma.type_ == tokenObjectEnd)\n      return true;\n  }\n  return addErrorAndRecover(\n      \"Missing '}' or object member name\", tokenName, tokenObjectEnd);\n}\n\nbool Reader::readArray(Token &tokenStart) {\n  currentValue() = Value(arrayValue);\n  currentValue().setOffsetStart(tokenStart.start_ - begin_);\n  skipSpaces();\n  if (*current_ == ']') // empty array\n  {\n    Token endArray;\n    readToken(endArray);\n    return true;\n  }\n  int index = 0;\n  for (;;) {\n    Value &value = currentValue()[index++];\n    nodes_.push(&value);\n    bool ok = readValue();\n    nodes_.pop();\n    if (!ok) // error already set\n      return recoverFromError(tokenArrayEnd);\n\n    Token token;\n    // Accept Comment after last item in the array.\n    ok = readToken(token);\n    while (token.type_ == tokenComment && ok) {\n      ok = readToken(token);\n    }\n    bool badTokenType =\n        (token.type_ != tokenArraySeparator && token.type_ != tokenArrayEnd);\n    if (!ok || badTokenType) {\n      return addErrorAndRecover(\n          \"Missing ',' or ']' in array declaration\", token, tokenArrayEnd);\n    }\n    if (token.type_ == tokenArrayEnd)\n      break;\n  }\n  return true;\n}\n\nbool Reader::decodeNumber(Token &token) {\n  Value decoded;\n  if (!decodeNumber(token, decoded))\n    return false;\n  currentValue() = decoded;\n  currentValue().setOffsetStart(token.start_ - begin_);\n  currentValue().setOffsetLimit(token.end_ - begin_);\n  return true;\n}\n\nbool Reader::decodeNumber(Token &token, Value &decoded) {\n  bool isDouble = false;\n  for (Location inspect = token.start_; inspect != token.end_; ++inspect) {\n    isDouble = isDouble || in(*inspect, '.', 'e', 'E', '+') ||\n               (*inspect == '-' && inspect != token.start_);\n  }\n  if (isDouble)\n    return decodeDouble(token, decoded);\n  // Attempts to parse the number as an integer. If the number is\n  // larger than the maximum supported value of an integer then\n  // we decode the number as a double.\n  Location current = token.start_;\n  bool isNegative = *current == '-';\n  if (isNegative)\n    ++current;\n  Value::LargestUInt maxIntegerValue =\n      isNegative ? Value::LargestUInt(-Value::minLargestInt)\n                 : Value::maxLargestUInt;\n  Value::LargestUInt threshold = maxIntegerValue / 10;\n  Value::LargestUInt value = 0;\n  while (current < token.end_) {\n    Char c = *current++;\n    if (c < '0' || c > '9')\n      return addError(\"'\" + std::string(token.start_, token.end_) +\n                          \"' is not a number.\",\n                      token);\n    Value::UInt digit(c - '0');\n    if (value >= threshold) {\n      // We've hit or exceeded the max value divided by 10 (rounded down). If\n      // a) we've only just touched the limit, b) this is the last digit, and\n      // c) it's small enough to fit in that rounding delta, we're okay.\n      // Otherwise treat this number as a double to avoid overflow.\n      if (value > threshold || current != token.end_ ||\n          digit > maxIntegerValue % 10) {\n        return decodeDouble(token, decoded);\n      }\n    }\n    value = value * 10 + digit;\n  }\n  if (isNegative)\n    decoded = -Value::LargestInt(value);\n  else if (value <= Value::LargestUInt(Value::maxInt))\n    decoded = Value::LargestInt(value);\n  else\n    decoded = value;\n  return true;\n}\n\nbool Reader::decodeDouble(Token &token) {\n  Value decoded;\n  if (!decodeDouble(token, decoded))\n    return false;\n  currentValue() = decoded;\n  currentValue().setOffsetStart(token.start_ - begin_);\n  currentValue().setOffsetLimit(token.end_ - begin_);\n  return true;\n}\n\nbool Reader::decodeDouble(Token &token, Value &decoded) {\n  double value = 0;\n  const int bufferSize = 32;\n  int count;\n  int length = int(token.end_ - token.start_);\n\n  // Sanity check to avoid buffer overflow exploits.\n  if (length < 0) {\n    return addError(\"Unable to parse token length\", token);\n  }\n\n  // Avoid using a string constant for the format control string given to\n  // sscanf, as this can cause hard to debug crashes on OS X. See here for more\n  // info:\n  //\n  //     http://developer.apple.com/library/mac/#DOCUMENTATION/DeveloperTools/gcc-4.0.1/gcc/Incompatibilities.html\n  char format[] = \"%lf\";\n\n  if (length <= bufferSize) {\n    Char buffer[bufferSize + 1];\n    memcpy(buffer, token.start_, length);\n    buffer[length] = 0;\n    count = sscanf(buffer, format, &value);\n  } else {\n    std::string buffer(token.start_, token.end_);\n    count = sscanf(buffer.c_str(), format, &value);\n  }\n\n  if (count != 1)\n    return addError(\"'\" + std::string(token.start_, token.end_) +\n                        \"' is not a number.\",\n                    token);\n  decoded = value;\n  return true;\n}\n\nbool Reader::decodeString(Token &token) {\n  std::string decoded;\n  if (!decodeString(token, decoded))\n    return false;\n  currentValue() = decoded;\n  currentValue().setOffsetStart(token.start_ - begin_);\n  currentValue().setOffsetLimit(token.end_ - begin_);\n  return true;\n}\n\nbool Reader::decodeString(Token &token, std::string &decoded) {\n  decoded.reserve(token.end_ - token.start_ - 2);\n  Location current = token.start_ + 1; // skip '\"'\n  Location end = token.end_ - 1;       // do not include '\"'\n  while (current != end) {\n    Char c = *current++;\n    if (c == '\"')\n      break;\n    else if (c == '\\\\') {\n      if (current == end)\n        return addError(\"Empty escape sequence in string\", token, current);\n      Char escape = *current++;\n      switch (escape) {\n      case '\"':\n        decoded += '\"';\n        break;\n      case '/':\n        decoded += '/';\n        break;\n      case '\\\\':\n        decoded += '\\\\';\n        break;\n      case 'b':\n        decoded += '\\b';\n        break;\n      case 'f':\n        decoded += '\\f';\n        break;\n      case 'n':\n        decoded += '\\n';\n        break;\n      case 'r':\n        decoded += '\\r';\n        break;\n      case 't':\n        decoded += '\\t';\n        break;\n      case 'u': {\n        unsigned int unicode;\n        if (!decodeUnicodeCodePoint(token, current, end, unicode))\n          return false;\n        decoded += codePointToUTF8(unicode);\n      } break;\n      default:\n        return addError(\"Bad escape sequence in string\", token, current);\n      }\n    } else {\n      decoded += c;\n    }\n  }\n  return true;\n}\n\nbool Reader::decodeUnicodeCodePoint(Token &token,\n                                    Location &current,\n                                    Location end,\n                                    unsigned int &unicode) {\n\n  if (!decodeUnicodeEscapeSequence(token, current, end, unicode))\n    return false;\n  if (unicode >= 0xD800 && unicode <= 0xDBFF) {\n    // surrogate pairs\n    if (end - current < 6)\n      return addError(\n          \"additional six characters expected to parse unicode surrogate pair.\",\n          token,\n          current);\n    unsigned int surrogatePair;\n    if (*(current++) == '\\\\' && *(current++) == 'u') {\n      if (decodeUnicodeEscapeSequence(token, current, end, surrogatePair)) {\n        unicode = 0x10000 + ((unicode & 0x3FF) << 10) + (surrogatePair & 0x3FF);\n      } else\n        return false;\n    } else\n      return addError(\"expecting another \\\\u token to begin the second half of \"\n                      \"a unicode surrogate pair\",\n                      token,\n                      current);\n  }\n  return true;\n}\n\nbool Reader::decodeUnicodeEscapeSequence(Token &token,\n                                         Location &current,\n                                         Location end,\n                                         unsigned int &unicode) {\n  if (end - current < 4)\n    return addError(\n        \"Bad unicode escape sequence in string: four digits expected.\",\n        token,\n        current);\n  unicode = 0;\n  for (int index = 0; index < 4; ++index) {\n    Char c = *current++;\n    unicode *= 16;\n    if (c >= '0' && c <= '9')\n      unicode += c - '0';\n    else if (c >= 'a' && c <= 'f')\n      unicode += c - 'a' + 10;\n    else if (c >= 'A' && c <= 'F')\n      unicode += c - 'A' + 10;\n    else\n      return addError(\n          \"Bad unicode escape sequence in string: hexadecimal digit expected.\",\n          token,\n          current);\n  }\n  return true;\n}\n\nbool\nReader::addError(const std::string &message, Token &token, Location extra) {\n  ErrorInfo info;\n  info.token_ = token;\n  info.message_ = message;\n  info.extra_ = extra;\n  errors_.push_back(info);\n  return false;\n}\n\nbool Reader::recoverFromError(TokenType skipUntilToken) {\n  int errorCount = int(errors_.size());\n  Token skip;\n  for (;;) {\n    if (!readToken(skip))\n      errors_.resize(errorCount); // discard errors caused by recovery\n    if (skip.type_ == skipUntilToken || skip.type_ == tokenEndOfStream)\n      break;\n  }\n  errors_.resize(errorCount);\n  return false;\n}\n\nbool Reader::addErrorAndRecover(const std::string &message,\n                                Token &token,\n                                TokenType skipUntilToken) {\n  addError(message, token);\n  return recoverFromError(skipUntilToken);\n}\n\nValue &Reader::currentValue() { return *(nodes_.top()); }\n\nReader::Char Reader::getNextChar() {\n  if (current_ == end_)\n    return 0;\n  return *current_++;\n}\n\nvoid Reader::getLocationLineAndColumn(Location location,\n                                      int &line,\n                                      int &column) const {\n  Location current = begin_;\n  Location lastLineStart = current;\n  line = 0;\n  while (current < location && current != end_) {\n    Char c = *current++;\n    if (c == '\\r') {\n      if (*current == '\\n')\n        ++current;\n      lastLineStart = current;\n      ++line;\n    } else if (c == '\\n') {\n      lastLineStart = current;\n      ++line;\n    }\n  }\n  // column & line start at 1\n  column = int(location - lastLineStart) + 1;\n  ++line;\n}\n\nstd::string Reader::getLocationLineAndColumn(Location location) const {\n  int line, column;\n  getLocationLineAndColumn(location, line, column);\n  char buffer[18 + 16 + 16 + 1];\n#if defined(_MSC_VER) && defined(__STDC_SECURE_LIB__)\n  #if defined(WINCE)\n  _snprintf(buffer, sizeof(buffer), \"Line %d, Column %d\", line, column);\n  #else\n  sprintf_s(buffer, sizeof(buffer), \"Line %d, Column %d\", line, column);\n  #endif\n#else\n  snprintf(buffer, sizeof(buffer), \"Line %d, Column %d\", line, column);\n#endif\n  return buffer;\n}\n\n// Deprecated. Preserved for backward compatibility\nstd::string Reader::getFormatedErrorMessages() const {\n  return getFormattedErrorMessages();\n}\n\nstd::string Reader::getFormattedErrorMessages() const {\n  std::string formattedMessage;\n  for (Errors::const_iterator itError = errors_.begin();\n       itError != errors_.end();\n       ++itError) {\n    const ErrorInfo &error = *itError;\n    formattedMessage +=\n        \"* \" + getLocationLineAndColumn(error.token_.start_) + \"\\n\";\n    formattedMessage += \"  \" + error.message_ + \"\\n\";\n    if (error.extra_)\n      formattedMessage +=\n          \"See \" + getLocationLineAndColumn(error.extra_) + \" for detail.\\n\";\n  }\n  return formattedMessage;\n}\n\nstd::vector<Reader::StructuredError> Reader::getStructuredErrors() const {\n  std::vector<Reader::StructuredError> allErrors;\n  for (Errors::const_iterator itError = errors_.begin();\n       itError != errors_.end();\n       ++itError) {\n    const ErrorInfo &error = *itError;\n    Reader::StructuredError structured;\n    structured.offset_start = error.token_.start_ - begin_;\n    structured.offset_limit = error.token_.end_ - begin_;\n    structured.message = error.message_;\n    allErrors.push_back(structured);\n  }\n  return allErrors;\n}\n\nstd::istream &operator>>(std::istream &sin, Value &root) {\n  Json::Reader reader;\n  bool ok = reader.parse(sin, root, true);\n  if (!ok) {\n    fprintf(stderr,\n            \"Error from reader: %s\",\n            reader.getFormattedErrorMessages().c_str());\n\n    JSON_FAIL_MESSAGE(\"reader error\");\n  }\n  return sin;\n}\n\n} // namespace Json\n// vim: et ts=2 sts=2 sw=2 tw=0\n"
  },
  {
    "path": "Projects/Libraries/CSBase/Source/json/json_tool.h",
    "content": "// Copyright 2007-2010 Baptiste Lepilleur\n// Distributed under MIT license, or public domain if desired and\n// recognized in your jurisdiction.\n// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE\n\n#ifndef LIB_JSONCPP_JSON_TOOL_H_INCLUDED\n#define LIB_JSONCPP_JSON_TOOL_H_INCLUDED\n\n/* This header provides common string manipulation support, such as UTF-8,\n * portable conversion from/to string...\n *\n * It is an internal header that must not be exposed.\n */\n\nnamespace Json {\n\n/// Converts a unicode code-point to UTF-8.\nstatic inline std::string codePointToUTF8(unsigned int cp) {\n  std::string result;\n\n  // based on description from http://en.wikipedia.org/wiki/UTF-8\n\n  if (cp <= 0x7f) {\n    result.resize(1);\n    result[0] = static_cast<char>(cp);\n  } else if (cp <= 0x7FF) {\n    result.resize(2);\n    result[1] = static_cast<char>(0x80 | (0x3f & cp));\n    result[0] = static_cast<char>(0xC0 | (0x1f & (cp >> 6)));\n  } else if (cp <= 0xFFFF) {\n    result.resize(3);\n    result[2] = static_cast<char>(0x80 | (0x3f & cp));\n    result[1] = 0x80 | static_cast<char>((0x3f & (cp >> 6)));\n    result[0] = 0xE0 | static_cast<char>((0xf & (cp >> 12)));\n  } else if (cp <= 0x10FFFF) {\n    result.resize(4);\n    result[3] = static_cast<char>(0x80 | (0x3f & cp));\n    result[2] = static_cast<char>(0x80 | (0x3f & (cp >> 6)));\n    result[1] = static_cast<char>(0x80 | (0x3f & (cp >> 12)));\n    result[0] = static_cast<char>(0xF0 | (0x7 & (cp >> 18)));\n  }\n\n  return result;\n}\n\n/// Returns true if ch is a control character (in range [0,32[).\nstatic inline bool isControlCharacter(char ch) { return ch > 0 && ch <= 0x1F; }\n\nenum {\n  /// Constant that specify the size of the buffer that must be passed to\n  /// uintToString.\n  uintToStringBufferSize = 3 * sizeof(LargestUInt) + 1\n};\n\n// Defines a char buffer for use with uintToString().\ntypedef char UIntToStringBuffer[uintToStringBufferSize];\n\n/** Converts an unsigned integer to string.\n * @param value Unsigned interger to convert to string\n * @param current Input/Output string buffer.\n *        Must have at least uintToStringBufferSize chars free.\n */\nstatic inline void uintToString(LargestUInt value, char *&current) {\n  *--current = 0;\n  do {\n    *--current = char(value % 10) + '0';\n    value /= 10;\n  } while (value != 0);\n}\n\n/** Change ',' to '.' everywhere in buffer.\n *\n * We had a sophisticated way, but it did not work in WinCE.\n * @see https://github.com/open-source-parsers/jsoncpp/pull/9\n */\nstatic inline void fixNumericLocale(char* begin, char* end) {\n  while (begin < end) {\n    if (*begin == ',') {\n      *begin = '.';\n    }\n    ++begin;\n  }\n}\n\n} // namespace Json {\n\n#endif // LIB_JSONCPP_JSON_TOOL_H_INCLUDED\n// vim: et ts=2 sts=2 sw=2 tw=0\n"
  },
  {
    "path": "Projects/Libraries/CSBase/Source/json/json_value.cpp",
    "content": "// Copyright 2011 Baptiste Lepilleur\n// Distributed under MIT license, or public domain if desired and\n// recognized in your jurisdiction.\n// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE\n\n#if !defined(JSON_IS_AMALGAMATION)\n#include <json/assertions.h>\n#include <json/value.h>\n#include <json/writer.h>\n#ifndef JSON_USE_SIMPLE_INTERNAL_ALLOCATOR\n#include \"json_batchallocator.h\"\n#endif // #ifndef JSON_USE_SIMPLE_INTERNAL_ALLOCATOR\n#endif // if !defined(JSON_IS_AMALGAMATION)\n#include <math.h>\n#include <sstream>\n#include <utility>\n#include <cstring>\n#include <cassert>\n#ifdef JSON_USE_CPPTL\n#include <cpptl/conststring.h>\n#endif\n#include <cstddef> // size_t\n\n#define JSON_ASSERT_UNREACHABLE assert(false)\n\nnamespace Json {\n\n// This is a walkaround to avoid the static initialization of Value::null.\n// kNull must be word-aligned to avoid crashing on ARM.  We use an alignment of\n// 8 (instead of 4) as a bit of future-proofing.\n#if defined(__ARMEL__)\n#define ALIGNAS(byte_alignment) __attribute__((aligned(byte_alignment)))\n#else\n#define ALIGNAS(byte_alignment)\n#endif\nstatic const unsigned char ALIGNAS(8) kNull[sizeof(Value)] = {0};\nconst unsigned char& kNullRef = kNull[0];\nconst Value& Value::null = reinterpret_cast<const Value&>(kNullRef);\n\nconst Int Value::minInt = Int(~(UInt(-1) / 2));\nconst Int Value::maxInt = Int(UInt(-1) / 2);\nconst UInt Value::maxUInt = UInt(-1);\n#if defined(JSON_HAS_INT64)\nconst Int64 Value::minInt64 = Int64(~(UInt64(-1) / 2));\nconst Int64 Value::maxInt64 = Int64(UInt64(-1) / 2);\nconst UInt64 Value::maxUInt64 = UInt64(-1);\n// The constant is hard-coded because some compiler have trouble\n// converting Value::maxUInt64 to a double correctly (AIX/xlC).\n// Assumes that UInt64 is a 64 bits integer.\nstatic const double maxUInt64AsDouble = 18446744073709551615.0;\n#endif // defined(JSON_HAS_INT64)\nconst LargestInt Value::minLargestInt = LargestInt(~(LargestUInt(-1) / 2));\nconst LargestInt Value::maxLargestInt = LargestInt(LargestUInt(-1) / 2);\nconst LargestUInt Value::maxLargestUInt = LargestUInt(-1);\n\n/// Unknown size marker\nstatic const unsigned int unknown = (unsigned)-1;\n\n#if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)\ntemplate <typename T, typename U>\nstatic inline bool InRange(double d, T min, U max) {\n  return d >= min && d <= max;\n}\n#else  // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)\nstatic inline double integerToDouble(Json::UInt64 value) {\n  return static_cast<double>(Int64(value / 2)) * 2.0 + Int64(value & 1);\n}\n\ntemplate <typename T> static inline double integerToDouble(T value) {\n  return static_cast<double>(value);\n}\n\ntemplate <typename T, typename U>\nstatic inline bool InRange(double d, T min, U max) {\n  return d >= integerToDouble(min) && d <= integerToDouble(max);\n}\n#endif // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)\n\n/** Duplicates the specified string value.\n * @param value Pointer to the string to duplicate. Must be zero-terminated if\n *              length is \"unknown\".\n * @param length Length of the value. if equals to unknown, then it will be\n *               computed using strlen(value).\n * @return Pointer on the duplicate instance of string.\n */\nstatic inline char *duplicateStringValue(const char *value,\n                                         unsigned int length = unknown) {\n  if (length == unknown)\n    length = (unsigned int)strlen(value);\n\n  // Avoid an integer overflow in the call to malloc below by limiting length\n  // to a sane value.\n  if (length >= (unsigned)Value::maxInt)\n    length = Value::maxInt - 1;\n\n  char *newString = static_cast<char *>(malloc(length + 1));\n  JSON_ASSERT_MESSAGE(newString != 0,\n                      \"in Json::Value::duplicateStringValue(): \"\n                      \"Failed to allocate string value buffer\");\n  memcpy(newString, value, length);\n  newString[length] = 0;\n  return newString;\n}\n\n/** Free the string duplicated by duplicateStringValue().\n */\nstatic inline void releaseStringValue(char *value) {\n  free(value);\n}\n\n} // namespace Json\n\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// ValueInternals...\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n#if !defined(JSON_IS_AMALGAMATION)\n#ifdef JSON_VALUE_USE_INTERNAL_MAP\n#include \"json_internalarray.inl\"\n#include \"json_internalmap.inl\"\n#endif // JSON_VALUE_USE_INTERNAL_MAP\n\n#include \"json_valueiterator.inl\"\n#endif // if !defined(JSON_IS_AMALGAMATION)\n\nnamespace Json {\n\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// class Value::CommentInfo\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n\nValue::CommentInfo::CommentInfo() : comment_(0) {}\n\nValue::CommentInfo::~CommentInfo() {\n  if (comment_)\n    releaseStringValue(comment_);\n}\n\nvoid Value::CommentInfo::setComment(const char *text) {\n  if (comment_)\n    releaseStringValue(comment_);\n  JSON_ASSERT(text != 0);\n  JSON_ASSERT_MESSAGE(\n      text[0] == '\\0' || text[0] == '/',\n      \"in Json::Value::setComment(): Comments must start with /\");\n  // It seems that /**/ style comments are acceptable as well.\n  comment_ = duplicateStringValue(text);\n}\n\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// class Value::CZString\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\n\n// Notes: index_ indicates if the string was allocated when\n// a string is stored.\n\nValue::CZString::CZString(ArrayIndex index) : cstr_(0), index_(index) {}\n\nValue::CZString::CZString(const char *cstr, DuplicationPolicy allocate)\n    : cstr_(allocate == duplicate ? duplicateStringValue(cstr) : cstr),\n      index_(allocate) {}\n\nValue::CZString::CZString(const CZString &other)\n    : cstr_(other.index_ != noDuplication && other.cstr_ != 0\n                ? duplicateStringValue(other.cstr_)\n                : other.cstr_),\n      index_(other.cstr_\n                 ? (other.index_ == noDuplication ? noDuplication : duplicate)\n                 : other.index_) {}\n\nValue::CZString::~CZString() {\n  if (cstr_ && index_ == duplicate)\n    releaseStringValue(const_cast<char *>(cstr_));\n}\n\nvoid Value::CZString::swap(CZString &other) {\n  std::swap(cstr_, other.cstr_);\n  std::swap(index_, other.index_);\n}\n\nValue::CZString &Value::CZString::operator=(CZString other) {\n  swap(other);\n  return *this;\n}\n\nbool Value::CZString::operator<(const CZString &other) const {\n  if (cstr_)\n    return strcmp(cstr_, other.cstr_) < 0;\n  return index_ < other.index_;\n}\n\nbool Value::CZString::operator==(const CZString &other) const {\n  if (cstr_)\n    return strcmp(cstr_, other.cstr_) == 0;\n  return index_ == other.index_;\n}\n\nArrayIndex Value::CZString::index() const { return index_; }\n\nconst char *Value::CZString::c_str() const { return cstr_; }\n\nbool Value::CZString::isStaticString() const { return index_ == noDuplication; }\n\n#endif // ifndef JSON_VALUE_USE_INTERNAL_MAP\n\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// class Value::Value\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n\n/*! \\internal Default constructor initialization must be equivalent to:\n * memset( this, 0, sizeof(Value) )\n * This optimization is used in ValueInternalMap fast allocator.\n */\nValue::Value(ValueType type)\n    : type_(type), allocated_(false)\n#ifdef JSON_VALUE_USE_INTERNAL_MAP\n      ,\n      itemIsUsed_(0)\n#endif\n      ,\n      comments_(0), start_(0), limit_(0) {\n  switch (type) {\n  case nullValue:\n    break;\n  case intValue:\n  case uintValue:\n    value_.int_ = 0;\n    break;\n  case realValue:\n    value_.real_ = 0.0;\n    break;\n  case stringValue:\n    value_.string_ = 0;\n    break;\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\n  case arrayValue:\n  case objectValue:\n    value_.map_ = new ObjectValues();\n    break;\n#else\n  case arrayValue:\n    value_.array_ = arrayAllocator()->newArray();\n    break;\n  case objectValue:\n    value_.map_ = mapAllocator()->newMap();\n    break;\n#endif\n  case booleanValue:\n    value_.bool_ = false;\n    break;\n  default:\n    JSON_ASSERT_UNREACHABLE;\n  }\n}\n\nValue::Value(UInt value)\n    : type_(uintValue), allocated_(false)\n#ifdef JSON_VALUE_USE_INTERNAL_MAP\n      ,\n      itemIsUsed_(0)\n#endif\n      ,\n      comments_(0), start_(0), limit_(0) {\n  value_.uint_ = value;\n}\n\nValue::Value(Int value)\n    : type_(intValue), allocated_(false)\n#ifdef JSON_VALUE_USE_INTERNAL_MAP\n      ,\n      itemIsUsed_(0)\n#endif\n      ,\n      comments_(0), start_(0), limit_(0) {\n  value_.int_ = value;\n}\n\n#if defined(JSON_HAS_INT64)\nValue::Value(Int64 value)\n    : type_(intValue), allocated_(false)\n#ifdef JSON_VALUE_USE_INTERNAL_MAP\n      ,\n      itemIsUsed_(0)\n#endif\n      ,\n      comments_(0), start_(0), limit_(0) {\n  value_.int_ = value;\n}\n\nValue::Value(UInt64 value)\n    : type_(uintValue), allocated_(false)\n#ifdef JSON_VALUE_USE_INTERNAL_MAP\n      ,\n      itemIsUsed_(0)\n#endif\n      ,\n      comments_(0), start_(0), limit_(0) {\n  value_.uint_ = value;\n}\n#endif // defined(JSON_HAS_INT64)\n\nValue::Value(double value)\n    : type_(realValue), allocated_(false)\n#ifdef JSON_VALUE_USE_INTERNAL_MAP\n      ,\n      itemIsUsed_(0)\n#endif\n      ,\n      comments_(0), start_(0), limit_(0) {\n  value_.real_ = value;\n}\n\nValue::Value(const char *value)\n    : type_(stringValue), allocated_(true)\n#ifdef JSON_VALUE_USE_INTERNAL_MAP\n      ,\n      itemIsUsed_(0)\n#endif\n      ,\n      comments_(0), start_(0), limit_(0) {\n  value_.string_ = duplicateStringValue(value);\n}\n\nValue::Value(const char *beginValue, const char *endValue)\n    : type_(stringValue), allocated_(true)\n#ifdef JSON_VALUE_USE_INTERNAL_MAP\n      ,\n      itemIsUsed_(0)\n#endif\n      ,\n      comments_(0), start_(0), limit_(0) {\n  value_.string_ =\n      duplicateStringValue(beginValue, (unsigned int)(endValue - beginValue));\n}\n\nValue::Value(const std::string &value)\n    : type_(stringValue), allocated_(true)\n#ifdef JSON_VALUE_USE_INTERNAL_MAP\n      ,\n      itemIsUsed_(0)\n#endif\n      ,\n      comments_(0), start_(0), limit_(0) {\n  value_.string_ =\n      duplicateStringValue(value.c_str(), (unsigned int)value.length());\n}\n\nValue::Value(const StaticString &value)\n    : type_(stringValue), allocated_(false)\n#ifdef JSON_VALUE_USE_INTERNAL_MAP\n      ,\n      itemIsUsed_(0)\n#endif\n      ,\n      comments_(0), start_(0), limit_(0) {\n  value_.string_ = const_cast<char *>(value.c_str());\n}\n\n#ifdef JSON_USE_CPPTL\nValue::Value(const CppTL::ConstString &value)\n    : type_(stringValue), allocated_(true)\n#ifdef JSON_VALUE_USE_INTERNAL_MAP\n      ,\n      itemIsUsed_(0)\n#endif\n      ,\n      comments_(0), start_(0), limit_(0) {\n  value_.string_ = duplicateStringValue(value, value.length());\n}\n#endif\n\nValue::Value(bool value)\n    : type_(booleanValue), allocated_(false)\n#ifdef JSON_VALUE_USE_INTERNAL_MAP\n      ,\n      itemIsUsed_(0)\n#endif\n      ,\n      comments_(0), start_(0), limit_(0) {\n  value_.bool_ = value;\n}\n\nValue::Value(const Value &other)\n    : type_(other.type_), allocated_(false)\n#ifdef JSON_VALUE_USE_INTERNAL_MAP\n      ,\n      itemIsUsed_(0)\n#endif\n      ,\n      comments_(0), start_(other.start_), limit_(other.limit_) {\n  switch (type_) {\n  case nullValue:\n  case intValue:\n  case uintValue:\n  case realValue:\n  case booleanValue:\n    value_ = other.value_;\n    break;\n  case stringValue:\n    if (other.value_.string_) {\n      value_.string_ = duplicateStringValue(other.value_.string_);\n      allocated_ = true;\n    } else {\n      value_.string_ = 0;\n      allocated_ = false;\n    }\n    break;\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\n  case arrayValue:\n  case objectValue:\n    value_.map_ = new ObjectValues(*other.value_.map_);\n    break;\n#else\n  case arrayValue:\n    value_.array_ = arrayAllocator()->newArrayCopy(*other.value_.array_);\n    break;\n  case objectValue:\n    value_.map_ = mapAllocator()->newMapCopy(*other.value_.map_);\n    break;\n#endif\n  default:\n    JSON_ASSERT_UNREACHABLE;\n  }\n  if (other.comments_) {\n    comments_ = new CommentInfo[numberOfCommentPlacement];\n    for (int comment = 0; comment < numberOfCommentPlacement; ++comment) {\n      const CommentInfo &otherComment = other.comments_[comment];\n      if (otherComment.comment_)\n        comments_[comment].setComment(otherComment.comment_);\n    }\n  }\n}\n\nValue::~Value() {\n  switch (type_) {\n  case nullValue:\n  case intValue:\n  case uintValue:\n  case realValue:\n  case booleanValue:\n    break;\n  case stringValue:\n    if (allocated_)\n      releaseStringValue(value_.string_);\n    break;\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\n  case arrayValue:\n  case objectValue:\n    delete value_.map_;\n    break;\n#else\n  case arrayValue:\n    arrayAllocator()->destructArray(value_.array_);\n    break;\n  case objectValue:\n    mapAllocator()->destructMap(value_.map_);\n    break;\n#endif\n  default:\n    JSON_ASSERT_UNREACHABLE;\n  }\n\n  if (comments_)\n    delete[] comments_;\n}\n\nValue &Value::operator=(Value other) {\n  swap(other);\n  return *this;\n}\n\nvoid Value::swap(Value &other) {\n  ValueType temp = type_;\n  type_ = other.type_;\n  other.type_ = temp;\n  std::swap(value_, other.value_);\n  int temp2 = allocated_;\n  allocated_ = other.allocated_;\n  other.allocated_ = temp2;\n  std::swap(start_, other.start_);\n  std::swap(limit_, other.limit_);\n}\n\nValueType Value::type() const { return type_; }\n\nint Value::compare(const Value &other) const {\n  if (*this < other)\n    return -1;\n  if (*this > other)\n    return 1;\n  return 0;\n}\n\nbool Value::operator<(const Value &other) const {\n  int typeDelta = type_ - other.type_;\n  if (typeDelta)\n    return typeDelta < 0 ? true : false;\n  switch (type_) {\n  case nullValue:\n    return false;\n  case intValue:\n    return value_.int_ < other.value_.int_;\n  case uintValue:\n    return value_.uint_ < other.value_.uint_;\n  case realValue:\n    return value_.real_ < other.value_.real_;\n  case booleanValue:\n    return value_.bool_ < other.value_.bool_;\n  case stringValue:\n    return (value_.string_ == 0 && other.value_.string_) ||\n           (other.value_.string_ && value_.string_ &&\n            strcmp(value_.string_, other.value_.string_) < 0);\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\n  case arrayValue:\n  case objectValue: {\n    int delta = int(value_.map_->size() - other.value_.map_->size());\n    if (delta)\n      return delta < 0;\n    return (*value_.map_) < (*other.value_.map_);\n  }\n#else\n  case arrayValue:\n    return value_.array_->compare(*(other.value_.array_)) < 0;\n  case objectValue:\n    return value_.map_->compare(*(other.value_.map_)) < 0;\n#endif\n  default:\n    JSON_ASSERT_UNREACHABLE;\n  }\n  return false; // unreachable\n}\n\nbool Value::operator<=(const Value &other) const { return !(other < *this); }\n\nbool Value::operator>=(const Value &other) const { return !(*this < other); }\n\nbool Value::operator>(const Value &other) const { return other < *this; }\n\nbool Value::operator==(const Value &other) const {\n  // if ( type_ != other.type_ )\n  // GCC 2.95.3 says:\n  // attempt to take address of bit-field structure member `Json::Value::type_'\n  // Beats me, but a temp solves the problem.\n  int temp = other.type_;\n  if (type_ != temp)\n    return false;\n  switch (type_) {\n  case nullValue:\n    return true;\n  case intValue:\n    return value_.int_ == other.value_.int_;\n  case uintValue:\n    return value_.uint_ == other.value_.uint_;\n  case realValue:\n    return value_.real_ == other.value_.real_;\n  case booleanValue:\n    return value_.bool_ == other.value_.bool_;\n  case stringValue:\n    return (value_.string_ == other.value_.string_) ||\n           (other.value_.string_ && value_.string_ &&\n            strcmp(value_.string_, other.value_.string_) == 0);\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\n  case arrayValue:\n  case objectValue:\n    return value_.map_->size() == other.value_.map_->size() &&\n           (*value_.map_) == (*other.value_.map_);\n#else\n  case arrayValue:\n    return value_.array_->compare(*(other.value_.array_)) == 0;\n  case objectValue:\n    return value_.map_->compare(*(other.value_.map_)) == 0;\n#endif\n  default:\n    JSON_ASSERT_UNREACHABLE;\n  }\n  return false; // unreachable\n}\n\nbool Value::operator!=(const Value &other) const { return !(*this == other); }\n\nconst char *Value::asCString() const {\n  JSON_ASSERT_MESSAGE(type_ == stringValue,\n                      \"in Json::Value::asCString(): requires stringValue\");\n  return value_.string_;\n}\n\nstd::string Value::asString() const {\n  switch (type_) {\n  case nullValue:\n    return \"\";\n  case stringValue:\n    return value_.string_ ? value_.string_ : \"\";\n  case booleanValue:\n    return value_.bool_ ? \"true\" : \"false\";\n  case intValue:\n    return valueToString(value_.int_);\n  case uintValue:\n    return valueToString(value_.uint_);\n  case realValue:\n    return valueToString(value_.real_);\n  default:\n    JSON_FAIL_MESSAGE(\"Type is not convertible to string\");\n  }\n}\n\n#ifdef JSON_USE_CPPTL\nCppTL::ConstString Value::asConstString() const {\n  return CppTL::ConstString(asString().c_str());\n}\n#endif\n\nValue::Int Value::asInt() const {\n  switch (type_) {\n  case intValue:\n    JSON_ASSERT_MESSAGE(isInt(), \"LargestInt out of Int range\");\n    return Int(value_.int_);\n  case uintValue:\n    JSON_ASSERT_MESSAGE(isInt(), \"LargestUInt out of Int range\");\n    return Int(value_.uint_);\n  case realValue:\n    JSON_ASSERT_MESSAGE(InRange(value_.real_, minInt, maxInt),\n                        \"double out of Int range\");\n    return Int(value_.real_);\n  case nullValue:\n    return 0;\n  case booleanValue:\n    return value_.bool_ ? 1 : 0;\n  default:\n    break;\n  }\n  JSON_FAIL_MESSAGE(\"Value is not convertible to Int.\");\n}\n\nValue::UInt Value::asUInt() const {\n  switch (type_) {\n  case intValue:\n    JSON_ASSERT_MESSAGE(isUInt(), \"LargestInt out of UInt range\");\n    return UInt(value_.int_);\n  case uintValue:\n    JSON_ASSERT_MESSAGE(isUInt(), \"LargestUInt out of UInt range\");\n    return UInt(value_.uint_);\n  case realValue:\n    JSON_ASSERT_MESSAGE(InRange(value_.real_, 0, maxUInt),\n                        \"double out of UInt range\");\n    return UInt(value_.real_);\n  case nullValue:\n    return 0;\n  case booleanValue:\n    return value_.bool_ ? 1 : 0;\n  default:\n    break;\n  }\n  JSON_FAIL_MESSAGE(\"Value is not convertible to UInt.\");\n}\n\n#if defined(JSON_HAS_INT64)\n\nValue::Int64 Value::asInt64() const {\n  switch (type_) {\n  case intValue:\n    return Int64(value_.int_);\n  case uintValue:\n    JSON_ASSERT_MESSAGE(isInt64(), \"LargestUInt out of Int64 range\");\n    return Int64(value_.uint_);\n  case realValue:\n    JSON_ASSERT_MESSAGE(InRange(value_.real_, minInt64, maxInt64),\n                        \"double out of Int64 range\");\n    return Int64(value_.real_);\n  case nullValue:\n    return 0;\n  case booleanValue:\n    return value_.bool_ ? 1 : 0;\n  default:\n    break;\n  }\n  JSON_FAIL_MESSAGE(\"Value is not convertible to Int64.\");\n}\n\nValue::UInt64 Value::asUInt64() const {\n  switch (type_) {\n  case intValue:\n    JSON_ASSERT_MESSAGE(isUInt64(), \"LargestInt out of UInt64 range\");\n    return UInt64(value_.int_);\n  case uintValue:\n    return UInt64(value_.uint_);\n  case realValue:\n    JSON_ASSERT_MESSAGE(InRange(value_.real_, 0, maxUInt64),\n                        \"double out of UInt64 range\");\n    return UInt64(value_.real_);\n  case nullValue:\n    return 0;\n  case booleanValue:\n    return value_.bool_ ? 1 : 0;\n  default:\n    break;\n  }\n  JSON_FAIL_MESSAGE(\"Value is not convertible to UInt64.\");\n}\n#endif // if defined(JSON_HAS_INT64)\n\nLargestInt Value::asLargestInt() const {\n#if defined(JSON_NO_INT64)\n  return asInt();\n#else\n  return asInt64();\n#endif\n}\n\nLargestUInt Value::asLargestUInt() const {\n#if defined(JSON_NO_INT64)\n  return asUInt();\n#else\n  return asUInt64();\n#endif\n}\n\ndouble Value::asDouble() const {\n  switch (type_) {\n  case intValue:\n    return static_cast<double>(value_.int_);\n  case uintValue:\n#if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)\n    return static_cast<double>(value_.uint_);\n#else  // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)\n    return integerToDouble(value_.uint_);\n#endif // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)\n  case realValue:\n    return value_.real_;\n  case nullValue:\n    return 0.0;\n  case booleanValue:\n    return value_.bool_ ? 1.0 : 0.0;\n  default:\n    break;\n  }\n  JSON_FAIL_MESSAGE(\"Value is not convertible to double.\");\n}\n\nfloat Value::asFloat() const {\n  switch (type_) {\n  case intValue:\n    return static_cast<float>(value_.int_);\n  case uintValue:\n#if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)\n    return static_cast<float>(value_.uint_);\n#else  // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)\n    return integerToDouble(value_.uint_);\n#endif // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)\n  case realValue:\n    return static_cast<float>(value_.real_);\n  case nullValue:\n    return 0.0;\n  case booleanValue:\n    return value_.bool_ ? 1.0f : 0.0f;\n  default:\n    break;\n  }\n  JSON_FAIL_MESSAGE(\"Value is not convertible to float.\");\n}\n\nbool Value::asBool() const {\n  switch (type_) {\n  case booleanValue:\n    return value_.bool_;\n  case nullValue:\n    return false;\n  case intValue:\n    return value_.int_ ? true : false;\n  case uintValue:\n    return value_.uint_ ? true : false;\n  case realValue:\n    return value_.real_ ? true : false;\n  default:\n    break;\n  }\n  JSON_FAIL_MESSAGE(\"Value is not convertible to bool.\");\n}\n\nbool Value::isConvertibleTo(ValueType other) const {\n  switch (other) {\n  case nullValue:\n    return (isNumeric() && asDouble() == 0.0) ||\n           (type_ == booleanValue && value_.bool_ == false) ||\n           (type_ == stringValue && asString() == \"\") ||\n           (type_ == arrayValue && value_.map_->size() == 0) ||\n           (type_ == objectValue && value_.map_->size() == 0) ||\n           type_ == nullValue;\n  case intValue:\n    return isInt() ||\n           (type_ == realValue && InRange(value_.real_, minInt, maxInt)) ||\n           type_ == booleanValue || type_ == nullValue;\n  case uintValue:\n    return isUInt() ||\n           (type_ == realValue && InRange(value_.real_, 0, maxUInt)) ||\n           type_ == booleanValue || type_ == nullValue;\n  case realValue:\n    return isNumeric() || type_ == booleanValue || type_ == nullValue;\n  case booleanValue:\n    return isNumeric() || type_ == booleanValue || type_ == nullValue;\n  case stringValue:\n    return isNumeric() || type_ == booleanValue || type_ == stringValue ||\n           type_ == nullValue;\n  case arrayValue:\n    return type_ == arrayValue || type_ == nullValue;\n  case objectValue:\n    return type_ == objectValue || type_ == nullValue;\n  }\n  JSON_ASSERT_UNREACHABLE;\n  return false;\n}\n\n/// Number of values in array or object\nArrayIndex Value::size() const {\n  switch (type_) {\n  case nullValue:\n  case intValue:\n  case uintValue:\n  case realValue:\n  case booleanValue:\n  case stringValue:\n    return 0;\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\n  case arrayValue: // size of the array is highest index + 1\n    if (!value_.map_->empty()) {\n      ObjectValues::const_iterator itLast = value_.map_->end();\n      --itLast;\n      return (*itLast).first.index() + 1;\n    }\n    return 0;\n  case objectValue:\n    return ArrayIndex(value_.map_->size());\n#else\n  case arrayValue:\n    return Int(value_.array_->size());\n  case objectValue:\n    return Int(value_.map_->size());\n#endif\n  }\n  JSON_ASSERT_UNREACHABLE;\n  return 0; // unreachable;\n}\n\nbool Value::empty() const {\n  if (isNull() || isArray() || isObject())\n    return size() == 0u;\n  else\n    return false;\n}\n\nbool Value::operator!() const { return isNull(); }\n\nvoid Value::clear() {\n  JSON_ASSERT_MESSAGE(type_ == nullValue || type_ == arrayValue ||\n                          type_ == objectValue,\n                      \"in Json::Value::clear(): requires complex value\");\n  start_ = 0;\n  limit_ = 0;\n  switch (type_) {\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\n  case arrayValue:\n  case objectValue:\n    value_.map_->clear();\n    break;\n#else\n  case arrayValue:\n    value_.array_->clear();\n    break;\n  case objectValue:\n    value_.map_->clear();\n    break;\n#endif\n  default:\n    break;\n  }\n}\n\nvoid Value::resize(ArrayIndex newSize) {\n  JSON_ASSERT_MESSAGE(type_ == nullValue || type_ == arrayValue,\n                      \"in Json::Value::resize(): requires arrayValue\");\n  if (type_ == nullValue)\n    *this = Value(arrayValue);\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\n  ArrayIndex oldSize = size();\n  if (newSize == 0)\n    clear();\n  else if (newSize > oldSize)\n    (*this)[newSize - 1];\n  else {\n    for (ArrayIndex index = newSize; index < oldSize; ++index) {\n      value_.map_->erase(index);\n    }\n    assert(size() == newSize);\n  }\n#else\n  value_.array_->resize(newSize);\n#endif\n}\n\nValue &Value::operator[](ArrayIndex index) {\n  JSON_ASSERT_MESSAGE(\n      type_ == nullValue || type_ == arrayValue,\n      \"in Json::Value::operator[](ArrayIndex): requires arrayValue\");\n  if (type_ == nullValue)\n    *this = Value(arrayValue);\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\n  CZString key(index);\n  ObjectValues::iterator it = value_.map_->lower_bound(key);\n  if (it != value_.map_->end() && (*it).first == key)\n    return (*it).second;\n\n  ObjectValues::value_type defaultValue(key, null);\n  it = value_.map_->insert(it, defaultValue);\n  return (*it).second;\n#else\n  return value_.array_->resolveReference(index);\n#endif\n}\n\nValue &Value::operator[](int index) {\n  JSON_ASSERT_MESSAGE(\n      index >= 0,\n      \"in Json::Value::operator[](int index): index cannot be negative\");\n  return (*this)[ArrayIndex(index)];\n}\n\nconst Value &Value::operator[](ArrayIndex index) const {\n  JSON_ASSERT_MESSAGE(\n      type_ == nullValue || type_ == arrayValue,\n      \"in Json::Value::operator[](ArrayIndex)const: requires arrayValue\");\n  if (type_ == nullValue)\n    return null;\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\n  CZString key(index);\n  ObjectValues::const_iterator it = value_.map_->find(key);\n  if (it == value_.map_->end())\n    return null;\n  return (*it).second;\n#else\n  Value *value = value_.array_->find(index);\n  return value ? *value : null;\n#endif\n}\n\nconst Value &Value::operator[](int index) const {\n  JSON_ASSERT_MESSAGE(\n      index >= 0,\n      \"in Json::Value::operator[](int index) const: index cannot be negative\");\n  return (*this)[ArrayIndex(index)];\n}\n\nValue &Value::operator[](const char *key) {\n  return resolveReference(key, false);\n}\n\nValue &Value::resolveReference(const char *key, bool isStatic) {\n  JSON_ASSERT_MESSAGE(\n      type_ == nullValue || type_ == objectValue,\n      \"in Json::Value::resolveReference(): requires objectValue\");\n  if (type_ == nullValue)\n    *this = Value(objectValue);\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\n  CZString actualKey(\n      key, isStatic ? CZString::noDuplication : CZString::duplicateOnCopy);\n  ObjectValues::iterator it = value_.map_->lower_bound(actualKey);\n  if (it != value_.map_->end() && (*it).first == actualKey)\n    return (*it).second;\n\n  ObjectValues::value_type defaultValue(actualKey, null);\n  it = value_.map_->insert(it, defaultValue);\n  Value &value = (*it).second;\n  return value;\n#else\n  return value_.map_->resolveReference(key, isStatic);\n#endif\n}\n\nValue Value::get(ArrayIndex index, const Value &defaultValue) const {\n  const Value *value = &((*this)[index]);\n  return value == &null ? defaultValue : *value;\n}\n\nbool Value::isValidIndex(ArrayIndex index) const { return index < size(); }\n\nconst Value &Value::operator[](const char *key) const {\n  JSON_ASSERT_MESSAGE(\n      type_ == nullValue || type_ == objectValue,\n      \"in Json::Value::operator[](char const*)const: requires objectValue\");\n  if (type_ == nullValue)\n    return null;\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\n  CZString actualKey(key, CZString::noDuplication);\n  ObjectValues::const_iterator it = value_.map_->find(actualKey);\n  if (it == value_.map_->end())\n    return null;\n  return (*it).second;\n#else\n  const Value *value = value_.map_->find(key);\n  return value ? *value : null;\n#endif\n}\n\nValue &Value::operator[](const std::string &key) {\n  return (*this)[key.c_str()];\n}\n\nconst Value &Value::operator[](const std::string &key) const {\n  return (*this)[key.c_str()];\n}\n\nValue &Value::operator[](const StaticString &key) {\n  return resolveReference(key, true);\n}\n\n#ifdef JSON_USE_CPPTL\nValue &Value::operator[](const CppTL::ConstString &key) {\n  return (*this)[key.c_str()];\n}\n\nconst Value &Value::operator[](const CppTL::ConstString &key) const {\n  return (*this)[key.c_str()];\n}\n#endif\n\nValue &Value::append(const Value &value) { return (*this)[size()] = value; }\n\nValue Value::get(const char *key, const Value &defaultValue) const {\n  const Value *value = &((*this)[key]);\n  return value == &null ? defaultValue : *value;\n}\n\nValue Value::get(const std::string &key, const Value &defaultValue) const {\n  return get(key.c_str(), defaultValue);\n}\n\nValue Value::removeMember(const char *key) {\n  JSON_ASSERT_MESSAGE(type_ == nullValue || type_ == objectValue,\n                      \"in Json::Value::removeMember(): requires objectValue\");\n  if (type_ == nullValue)\n    return null;\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\n  CZString actualKey(key, CZString::noDuplication);\n  ObjectValues::iterator it = value_.map_->find(actualKey);\n  if (it == value_.map_->end())\n    return null;\n  Value old(it->second);\n  value_.map_->erase(it);\n  return old;\n#else\n  Value *value = value_.map_->find(key);\n  if (value) {\n    Value old(*value);\n    value_.map_.remove(key);\n    return old;\n  } else {\n    return null;\n  }\n#endif\n}\n\nValue Value::removeMember(const std::string &key) {\n  return removeMember(key.c_str());\n}\n\n#ifdef JSON_USE_CPPTL\nValue Value::get(const CppTL::ConstString &key,\n                 const Value &defaultValue) const {\n  return get(key.c_str(), defaultValue);\n}\n#endif\n\nbool Value::isMember(const char *key) const {\n  const Value *value = &((*this)[key]);\n  return value != &null;\n}\n\nbool Value::isMember(const std::string &key) const {\n  return isMember(key.c_str());\n}\n\n#ifdef JSON_USE_CPPTL\nbool Value::isMember(const CppTL::ConstString &key) const {\n  return isMember(key.c_str());\n}\n#endif\n\nValue::Members Value::getMemberNames() const {\n  JSON_ASSERT_MESSAGE(\n      type_ == nullValue || type_ == objectValue,\n      \"in Json::Value::getMemberNames(), value must be objectValue\");\n  if (type_ == nullValue)\n    return Value::Members();\n  Members members;\n  members.reserve(value_.map_->size());\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\n  ObjectValues::const_iterator it = value_.map_->begin();\n  ObjectValues::const_iterator itEnd = value_.map_->end();\n  for (; it != itEnd; ++it)\n    members.push_back(std::string((*it).first.c_str()));\n#else\n  ValueInternalMap::IteratorState it;\n  ValueInternalMap::IteratorState itEnd;\n  value_.map_->makeBeginIterator(it);\n  value_.map_->makeEndIterator(itEnd);\n  for (; !ValueInternalMap::equals(it, itEnd); ValueInternalMap::increment(it))\n    members.push_back(std::string(ValueInternalMap::key(it)));\n#endif\n  return members;\n}\n//\n//# ifdef JSON_USE_CPPTL\n// EnumMemberNames\n// Value::enumMemberNames() const\n//{\n//   if ( type_ == objectValue )\n//   {\n//      return CppTL::Enum::any(  CppTL::Enum::transform(\n//         CppTL::Enum::keys( *(value_.map_), CppTL::Type<const CZString &>() ),\n//         MemberNamesTransform() ) );\n//   }\n//   return EnumMemberNames();\n//}\n//\n//\n// EnumValues\n// Value::enumValues() const\n//{\n//   if ( type_ == objectValue  ||  type_ == arrayValue )\n//      return CppTL::Enum::anyValues( *(value_.map_),\n//                                     CppTL::Type<const Value &>() );\n//   return EnumValues();\n//}\n//\n//# endif\n\nstatic bool IsIntegral(double d) {\n  double integral_part;\n  return modf(d, &integral_part) == 0.0;\n}\n\nbool Value::isNull() const { return type_ == nullValue; }\n\nbool Value::isBool() const { return type_ == booleanValue; }\n\nbool Value::isInt() const {\n  switch (type_) {\n  case intValue:\n    return value_.int_ >= minInt && value_.int_ <= maxInt;\n  case uintValue:\n    return value_.uint_ <= UInt(maxInt);\n  case realValue:\n    return value_.real_ >= minInt && value_.real_ <= maxInt &&\n           IsIntegral(value_.real_);\n  default:\n    break;\n  }\n  return false;\n}\n\nbool Value::isUInt() const {\n  switch (type_) {\n  case intValue:\n    return value_.int_ >= 0 && LargestUInt(value_.int_) <= LargestUInt(maxUInt);\n  case uintValue:\n    return value_.uint_ <= maxUInt;\n  case realValue:\n    return value_.real_ >= 0 && value_.real_ <= maxUInt &&\n           IsIntegral(value_.real_);\n  default:\n    break;\n  }\n  return false;\n}\n\nbool Value::isInt64() const {\n#if defined(JSON_HAS_INT64)\n  switch (type_) {\n  case intValue:\n    return true;\n  case uintValue:\n    return value_.uint_ <= UInt64(maxInt64);\n  case realValue:\n    // Note that maxInt64 (= 2^63 - 1) is not exactly representable as a\n    // double, so double(maxInt64) will be rounded up to 2^63. Therefore we\n    // require the value to be strictly less than the limit.\n    return value_.real_ >= double(minInt64) &&\n           value_.real_ < double(maxInt64) && IsIntegral(value_.real_);\n  default:\n    break;\n  }\n#endif // JSON_HAS_INT64\n  return false;\n}\n\nbool Value::isUInt64() const {\n#if defined(JSON_HAS_INT64)\n  switch (type_) {\n  case intValue:\n    return value_.int_ >= 0;\n  case uintValue:\n    return true;\n  case realValue:\n    // Note that maxUInt64 (= 2^64 - 1) is not exactly representable as a\n    // double, so double(maxUInt64) will be rounded up to 2^64. Therefore we\n    // require the value to be strictly less than the limit.\n    return value_.real_ >= 0 && value_.real_ < maxUInt64AsDouble &&\n           IsIntegral(value_.real_);\n  default:\n    break;\n  }\n#endif // JSON_HAS_INT64\n  return false;\n}\n\nbool Value::isIntegral() const {\n#if defined(JSON_HAS_INT64)\n  return isInt64() || isUInt64();\n#else\n  return isInt() || isUInt();\n#endif\n}\n\nbool Value::isDouble() const { return type_ == realValue || isIntegral(); }\n\nbool Value::isNumeric() const { return isIntegral() || isDouble(); }\n\nbool Value::isString() const { return type_ == stringValue; }\n\nbool Value::isArray() const { return type_ == arrayValue; }\n\nbool Value::isObject() const { return type_ == objectValue; }\n\nvoid Value::setComment(const char *comment, CommentPlacement placement) {\n  if (!comments_)\n    comments_ = new CommentInfo[numberOfCommentPlacement];\n  comments_[placement].setComment(comment);\n}\n\nvoid Value::setComment(const std::string &comment, CommentPlacement placement) {\n  setComment(comment.c_str(), placement);\n}\n\nbool Value::hasComment(CommentPlacement placement) const {\n  return comments_ != 0 && comments_[placement].comment_ != 0;\n}\n\nstd::string Value::getComment(CommentPlacement placement) const {\n  if (hasComment(placement))\n    return comments_[placement].comment_;\n  return \"\";\n}\n\nvoid Value::setOffsetStart(size_t start) { start_ = start; }\n\nvoid Value::setOffsetLimit(size_t limit) { limit_ = limit; }\n\nsize_t Value::getOffsetStart() const { return start_; }\n\nsize_t Value::getOffsetLimit() const { return limit_; }\n\nstd::string Value::toStyledString() const {\n  StyledWriter writer;\n  return writer.write(*this);\n}\n\nValue::const_iterator Value::begin() const {\n  switch (type_) {\n#ifdef JSON_VALUE_USE_INTERNAL_MAP\n  case arrayValue:\n    if (value_.array_) {\n      ValueInternalArray::IteratorState it;\n      value_.array_->makeBeginIterator(it);\n      return const_iterator(it);\n    }\n    break;\n  case objectValue:\n    if (value_.map_) {\n      ValueInternalMap::IteratorState it;\n      value_.map_->makeBeginIterator(it);\n      return const_iterator(it);\n    }\n    break;\n#else\n  case arrayValue:\n  case objectValue:\n    if (value_.map_)\n      return const_iterator(value_.map_->begin());\n    break;\n#endif\n  default:\n    break;\n  }\n  return const_iterator();\n}\n\nValue::const_iterator Value::end() const {\n  switch (type_) {\n#ifdef JSON_VALUE_USE_INTERNAL_MAP\n  case arrayValue:\n    if (value_.array_) {\n      ValueInternalArray::IteratorState it;\n      value_.array_->makeEndIterator(it);\n      return const_iterator(it);\n    }\n    break;\n  case objectValue:\n    if (value_.map_) {\n      ValueInternalMap::IteratorState it;\n      value_.map_->makeEndIterator(it);\n      return const_iterator(it);\n    }\n    break;\n#else\n  case arrayValue:\n  case objectValue:\n    if (value_.map_)\n      return const_iterator(value_.map_->end());\n    break;\n#endif\n  default:\n    break;\n  }\n  return const_iterator();\n}\n\nValue::iterator Value::begin() {\n  switch (type_) {\n#ifdef JSON_VALUE_USE_INTERNAL_MAP\n  case arrayValue:\n    if (value_.array_) {\n      ValueInternalArray::IteratorState it;\n      value_.array_->makeBeginIterator(it);\n      return iterator(it);\n    }\n    break;\n  case objectValue:\n    if (value_.map_) {\n      ValueInternalMap::IteratorState it;\n      value_.map_->makeBeginIterator(it);\n      return iterator(it);\n    }\n    break;\n#else\n  case arrayValue:\n  case objectValue:\n    if (value_.map_)\n      return iterator(value_.map_->begin());\n    break;\n#endif\n  default:\n    break;\n  }\n  return iterator();\n}\n\nValue::iterator Value::end() {\n  switch (type_) {\n#ifdef JSON_VALUE_USE_INTERNAL_MAP\n  case arrayValue:\n    if (value_.array_) {\n      ValueInternalArray::IteratorState it;\n      value_.array_->makeEndIterator(it);\n      return iterator(it);\n    }\n    break;\n  case objectValue:\n    if (value_.map_) {\n      ValueInternalMap::IteratorState it;\n      value_.map_->makeEndIterator(it);\n      return iterator(it);\n    }\n    break;\n#else\n  case arrayValue:\n  case objectValue:\n    if (value_.map_)\n      return iterator(value_.map_->end());\n    break;\n#endif\n  default:\n    break;\n  }\n  return iterator();\n}\n\n// class PathArgument\n// //////////////////////////////////////////////////////////////////\n\nPathArgument::PathArgument() : key_(), index_(), kind_(kindNone) {}\n\nPathArgument::PathArgument(ArrayIndex index)\n    : key_(), index_(index), kind_(kindIndex) {}\n\nPathArgument::PathArgument(const char *key)\n    : key_(key), index_(), kind_(kindKey) {}\n\nPathArgument::PathArgument(const std::string &key)\n    : key_(key.c_str()), index_(), kind_(kindKey) {}\n\n// class Path\n// //////////////////////////////////////////////////////////////////\n\nPath::Path(const std::string &path,\n           const PathArgument &a1,\n           const PathArgument &a2,\n           const PathArgument &a3,\n           const PathArgument &a4,\n           const PathArgument &a5) {\n  InArgs in;\n  in.push_back(&a1);\n  in.push_back(&a2);\n  in.push_back(&a3);\n  in.push_back(&a4);\n  in.push_back(&a5);\n  makePath(path, in);\n}\n\nvoid Path::makePath(const std::string &path, const InArgs &in) {\n  const char *current = path.c_str();\n  const char *end = current + path.length();\n  InArgs::const_iterator itInArg = in.begin();\n  while (current != end) {\n    if (*current == '[') {\n      ++current;\n      if (*current == '%')\n        addPathInArg(path, in, itInArg, PathArgument::kindIndex);\n      else {\n        ArrayIndex index = 0;\n        for (; current != end && *current >= '0' && *current <= '9'; ++current)\n          index = index * 10 + ArrayIndex(*current - '0');\n        args_.push_back(index);\n      }\n      if (current == end || *current++ != ']')\n        invalidPath(path, int(current - path.c_str()));\n    } else if (*current == '%') {\n      addPathInArg(path, in, itInArg, PathArgument::kindKey);\n      ++current;\n    } else if (*current == '.') {\n      ++current;\n    } else {\n      const char *beginName = current;\n      while (current != end && !strchr(\"[.\", *current))\n        ++current;\n      args_.push_back(std::string(beginName, current));\n    }\n  }\n}\n\nvoid Path::addPathInArg(const std::string & /*path*/,\n                        const InArgs &in,\n                        InArgs::const_iterator &itInArg,\n                        PathArgument::Kind kind) {\n  if (itInArg == in.end()) {\n    // Error: missing argument %d\n  } else if ((*itInArg)->kind_ != kind) {\n    // Error: bad argument type\n  } else {\n    args_.push_back(**itInArg);\n  }\n}\n\nvoid Path::invalidPath(const std::string & /*path*/, int /*location*/) {\n  // Error: invalid path.\n}\n\nconst Value &Path::resolve(const Value &root) const {\n  const Value *node = &root;\n  for (Args::const_iterator it = args_.begin(); it != args_.end(); ++it) {\n    const PathArgument &arg = *it;\n    if (arg.kind_ == PathArgument::kindIndex) {\n      if (!node->isArray() || !node->isValidIndex(arg.index_)) {\n        // Error: unable to resolve path (array value expected at position...\n      }\n      node = &((*node)[arg.index_]);\n    } else if (arg.kind_ == PathArgument::kindKey) {\n      if (!node->isObject()) {\n        // Error: unable to resolve path (object value expected at position...)\n      }\n      node = &((*node)[arg.key_]);\n      if (node == &Value::null) {\n        // Error: unable to resolve path (object has no member named '' at\n        // position...)\n      }\n    }\n  }\n  return *node;\n}\n\nValue Path::resolve(const Value &root, const Value &defaultValue) const {\n  const Value *node = &root;\n  for (Args::const_iterator it = args_.begin(); it != args_.end(); ++it) {\n    const PathArgument &arg = *it;\n    if (arg.kind_ == PathArgument::kindIndex) {\n      if (!node->isArray() || !node->isValidIndex(arg.index_))\n        return defaultValue;\n      node = &((*node)[arg.index_]);\n    } else if (arg.kind_ == PathArgument::kindKey) {\n      if (!node->isObject())\n        return defaultValue;\n      node = &((*node)[arg.key_]);\n      if (node == &Value::null)\n        return defaultValue;\n    }\n  }\n  return *node;\n}\n\nValue &Path::make(Value &root) const {\n  Value *node = &root;\n  for (Args::const_iterator it = args_.begin(); it != args_.end(); ++it) {\n    const PathArgument &arg = *it;\n    if (arg.kind_ == PathArgument::kindIndex) {\n      if (!node->isArray()) {\n        // Error: node is not an array at position ...\n      }\n      node = &((*node)[arg.index_]);\n    } else if (arg.kind_ == PathArgument::kindKey) {\n      if (!node->isObject()) {\n        // Error: node is not an object at position...\n      }\n      node = &((*node)[arg.key_]);\n    }\n  }\n  return *node;\n}\n\n} // namespace Json\n// vim: et ts=2 sts=2 sw=2 tw=0\n"
  },
  {
    "path": "Projects/Libraries/CSBase/Source/json/json_valueiterator.inl",
    "content": "// Copyright 2007-2010 Baptiste Lepilleur\n// Distributed under MIT license, or public domain if desired and\n// recognized in your jurisdiction.\n// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE\n\n// included by json_value.cpp\n\nnamespace Json {\n\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// class ValueIteratorBase\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n\nValueIteratorBase::ValueIteratorBase()\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\n   : current_()\n   , isNull_( true )\n{\n}\n#else\n   : isArray_( true )\n   , isNull_( true )\n{\n   iterator_.array_ = ValueInternalArray::IteratorState();\n}\n#endif\n\n\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\nValueIteratorBase::ValueIteratorBase( const Value::ObjectValues::iterator &current )\n   : current_( current )\n   , isNull_( false )\n{\n}\n#else\nValueIteratorBase::ValueIteratorBase( const ValueInternalArray::IteratorState &state )\n   : isArray_( true )\n{\n   iterator_.array_ = state;\n}\n\n\nValueIteratorBase::ValueIteratorBase( const ValueInternalMap::IteratorState &state )\n   : isArray_( false )\n{\n   iterator_.map_ = state;\n}\n#endif\n\nValue &\nValueIteratorBase::deref() const\n{\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\n   return current_->second;\n#else\n   if ( isArray_ )\n      return ValueInternalArray::dereference( iterator_.array_ );\n   return ValueInternalMap::value( iterator_.map_ );\n#endif\n}\n\n\nvoid \nValueIteratorBase::increment()\n{\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\n   ++current_;\n#else\n   if ( isArray_ )\n      ValueInternalArray::increment( iterator_.array_ );\n   ValueInternalMap::increment( iterator_.map_ );\n#endif\n}\n\n\nvoid \nValueIteratorBase::decrement()\n{\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\n   --current_;\n#else\n   if ( isArray_ )\n      ValueInternalArray::decrement( iterator_.array_ );\n   ValueInternalMap::decrement( iterator_.map_ );\n#endif\n}\n\n\nValueIteratorBase::difference_type \nValueIteratorBase::computeDistance( const SelfType &other ) const\n{\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\n# ifdef JSON_USE_CPPTL_SMALLMAP\n   return current_ - other.current_;\n# else\n   // Iterator for null value are initialized using the default\n   // constructor, which initialize current_ to the default\n   // std::map::iterator. As begin() and end() are two instance \n   // of the default std::map::iterator, they can not be compared.\n   // To allow this, we handle this comparison specifically.\n   if ( isNull_  &&  other.isNull_ )\n   {\n      return 0;\n   }\n\n\n   // Usage of std::distance is not portable (does not compile with Sun Studio 12 RogueWave STL,\n   // which is the one used by default).\n   // Using a portable hand-made version for non random iterator instead:\n   //   return difference_type( std::distance( current_, other.current_ ) );\n   difference_type myDistance = 0;\n   for ( Value::ObjectValues::iterator it = current_; it != other.current_; ++it )\n   {\n      ++myDistance;\n   }\n   return myDistance;\n# endif\n#else\n   if ( isArray_ )\n      return ValueInternalArray::distance( iterator_.array_, other.iterator_.array_ );\n   return ValueInternalMap::distance( iterator_.map_, other.iterator_.map_ );\n#endif\n}\n\n\nbool \nValueIteratorBase::isEqual( const SelfType &other ) const\n{\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\n   if ( isNull_ )\n   {\n      return other.isNull_;\n   }\n   return current_ == other.current_;\n#else\n   if ( isArray_ )\n      return ValueInternalArray::equals( iterator_.array_, other.iterator_.array_ );\n   return ValueInternalMap::equals( iterator_.map_, other.iterator_.map_ );\n#endif\n}\n\n\nvoid \nValueIteratorBase::copy( const SelfType &other )\n{\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\n   current_ = other.current_;\n   isNull_ = other.isNull_;\n#else\n   if ( isArray_ )\n      iterator_.array_ = other.iterator_.array_;\n   iterator_.map_ = other.iterator_.map_;\n#endif\n}\n\n\nValue \nValueIteratorBase::key() const\n{\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\n   const Value::CZString czstring = (*current_).first;\n   if ( czstring.c_str() )\n   {\n      if ( czstring.isStaticString() )\n         return Value( StaticString( czstring.c_str() ) );\n      return Value( czstring.c_str() );\n   }\n   return Value( czstring.index() );\n#else\n   if ( isArray_ )\n      return Value( ValueInternalArray::indexOf( iterator_.array_ ) );\n   bool isStatic;\n   const char *memberName = ValueInternalMap::key( iterator_.map_, isStatic );\n   if ( isStatic )\n      return Value( StaticString( memberName ) );\n   return Value( memberName );\n#endif\n}\n\n\nUInt \nValueIteratorBase::index() const\n{\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\n   const Value::CZString czstring = (*current_).first;\n   if ( !czstring.c_str() )\n      return czstring.index();\n   return Value::UInt( -1 );\n#else\n   if ( isArray_ )\n      return Value::UInt( ValueInternalArray::indexOf( iterator_.array_ ) );\n   return Value::UInt( -1 );\n#endif\n}\n\n\nconst char *\nValueIteratorBase::memberName() const\n{\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\n   const char *name = (*current_).first.c_str();\n   return name ? name : \"\";\n#else\n   if ( !isArray_ )\n      return ValueInternalMap::key( iterator_.map_ );\n   return \"\";\n#endif\n}\n\n\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// class ValueConstIterator\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n\nValueConstIterator::ValueConstIterator()\n{\n}\n\n\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\nValueConstIterator::ValueConstIterator( const Value::ObjectValues::iterator &current )\n   : ValueIteratorBase( current )\n{\n}\n#else\nValueConstIterator::ValueConstIterator( const ValueInternalArray::IteratorState &state )\n   : ValueIteratorBase( state )\n{\n}\n\nValueConstIterator::ValueConstIterator( const ValueInternalMap::IteratorState &state )\n   : ValueIteratorBase( state )\n{\n}\n#endif\n\nValueConstIterator &\nValueConstIterator::operator =( const ValueIteratorBase &other )\n{\n   copy( other );\n   return *this;\n}\n\n\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// class ValueIterator\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n\nValueIterator::ValueIterator()\n{\n}\n\n\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\nValueIterator::ValueIterator( const Value::ObjectValues::iterator &current )\n   : ValueIteratorBase( current )\n{\n}\n#else\nValueIterator::ValueIterator( const ValueInternalArray::IteratorState &state )\n   : ValueIteratorBase( state )\n{\n}\n\nValueIterator::ValueIterator( const ValueInternalMap::IteratorState &state )\n   : ValueIteratorBase( state )\n{\n}\n#endif\n\nValueIterator::ValueIterator( const ValueConstIterator &other )\n   : ValueIteratorBase( other )\n{\n}\n\nValueIterator::ValueIterator( const ValueIterator &other )\n   : ValueIteratorBase( other )\n{\n}\n\nValueIterator &\nValueIterator::operator =( const SelfType &other )\n{\n   copy( other );\n   return *this;\n}\n\n} // namespace Json\n// vim: et ts=3 sts=3 sw=3 tw=0\n"
  },
  {
    "path": "Projects/Libraries/CSBase/Source/json/json_writer.cpp",
    "content": "// Copyright 2011 Baptiste Lepilleur\n// Distributed under MIT license, or public domain if desired and\n// recognized in your jurisdiction.\n// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE\n\n#if !defined(JSON_IS_AMALGAMATION)\n#include <json/writer.h>\n#include \"json_tool.h\"\n#endif // if !defined(JSON_IS_AMALGAMATION)\n#include <utility>\n#include <assert.h>\n#include <stdio.h>\n#include <string.h>\n#include <sstream>\n#include <iomanip>\n#include <math.h>\n\n#if defined(_MSC_VER) && _MSC_VER >= 1400 // VC++ 8.0\n// Disable warning about strdup being deprecated.\n#pragma warning(disable : 4996)\n#endif\n\nnamespace Json {\n\nstatic bool containsControlCharacter(const char *str) {\n  while (*str) {\n    if (isControlCharacter(*(str++)))\n      return true;\n  }\n  return false;\n}\n\nstd::string valueToString(LargestInt value) {\n  UIntToStringBuffer buffer;\n  char *current = buffer + sizeof(buffer);\n  bool isNegative = value < 0;\n  if (isNegative)\n    value = -value;\n  uintToString(LargestUInt(value), current);\n  if (isNegative)\n    *--current = '-';\n  assert(current >= buffer);\n  return current;\n}\n\nstd::string valueToString(LargestUInt value) {\n  UIntToStringBuffer buffer;\n  char *current = buffer + sizeof(buffer);\n  uintToString(value, current);\n  assert(current >= buffer);\n  return current;\n}\n\n#if defined(JSON_HAS_INT64)\n\nstd::string valueToString(Int value) {\n  return valueToString(LargestInt(value));\n}\n\nstd::string valueToString(UInt value) {\n  return valueToString(LargestUInt(value));\n}\n\n#endif // # if defined(JSON_HAS_INT64)\n\nstd::string valueToString(double value) {\n  // Allocate a buffer that is more than large enough to store the 16 digits of\n  // precision requested below.\n  char buffer[32];\n  int len = -1;\n\n// Print into the buffer. We need not request the alternative representation\n// that always has a decimal point because JSON doesn't distingish the\n// concepts of reals and integers.\n#if defined(_MSC_VER) && defined(__STDC_SECURE_LIB__) // Use secure version with\n                                                      // visual studio 2005 to\n                                                      // avoid warning.\n  #if defined(WINCE)\n  len = _snprintf(buffer, sizeof(buffer), \"%.16g\", value);\n  #else\n  len = sprintf_s(buffer, sizeof(buffer), \"%.16g\", value);\n  #endif\n#else\n  if (isfinite( value )) {\n    len = snprintf(buffer, sizeof(buffer), \"%.16g\", value);\n  } else {\n     // IEEE standard states that NaN values will not compare to themselves\n     if ( value != value) {\n        len = snprintf(buffer, sizeof(buffer), \"null\");\n     } else if ( value < 0) {\n        len = snprintf(buffer, sizeof(buffer), \"-1e+9999\");\n     } else {\n        len = snprintf(buffer, sizeof(buffer), \"1e+9999\");\n     }\n     // For those, we do not need to call fixNumLoc, but it is fast.\n  }\n#endif\n  assert(len>=0);\n  fixNumericLocale(buffer, buffer + len);\n  return buffer;\n}\n\nstd::string valueToString(bool value) { return value ? \"true\" : \"false\"; }\n\nstd::string valueToQuotedString(const char *value) {\n  if (value == NULL)\n    return \"\";\n  // Not sure how to handle unicode...\n  if (strpbrk(value, \"\\\"\\\\\\b\\f\\n\\r\\t\") == NULL &&\n      !containsControlCharacter(value))\n    return std::string(\"\\\"\") + value + \"\\\"\";\n  // We have to walk value and escape any special characters.\n  // Appending to std::string is not efficient, but this should be rare.\n  // (Note: forward slashes are *not* rare, but I am not escaping them.)\n  std::string::size_type maxsize =\n      strlen(value) * 2 + 3; // allescaped+quotes+NULL\n  std::string result;\n  result.reserve(maxsize); // to avoid lots of mallocs\n  result += \"\\\"\";\n  for (const char *c = value; *c != 0; ++c) {\n    switch (*c) {\n    case '\\\"':\n      result += \"\\\\\\\"\";\n      break;\n    case '\\\\':\n      result += \"\\\\\\\\\";\n      break;\n    case '\\b':\n      result += \"\\\\b\";\n      break;\n    case '\\f':\n      result += \"\\\\f\";\n      break;\n    case '\\n':\n      result += \"\\\\n\";\n      break;\n    case '\\r':\n      result += \"\\\\r\";\n      break;\n    case '\\t':\n      result += \"\\\\t\";\n      break;\n    // case '/':\n    // Even though \\/ is considered a legal escape in JSON, a bare\n    // slash is also legal, so I see no reason to escape it.\n    // (I hope I am not misunderstanding something.\n    // blep notes: actually escaping \\/ may be useful in javascript to avoid </\n    // sequence.\n    // Should add a flag to allow this compatibility mode and prevent this\n    // sequence from occurring.\n    default:\n      if (isControlCharacter(*c)) {\n        std::ostringstream oss;\n        oss << \"\\\\u\" << std::hex << std::uppercase << std::setfill('0')\n            << std::setw(4) << static_cast<int>(*c);\n        result += oss.str();\n      } else {\n        result += *c;\n      }\n      break;\n    }\n  }\n  result += \"\\\"\";\n  return result;\n}\n\n// Class Writer\n// //////////////////////////////////////////////////////////////////\nWriter::~Writer() {}\n\n// Class FastWriter\n// //////////////////////////////////////////////////////////////////\n\nFastWriter::FastWriter()\n    : yamlCompatiblityEnabled_(false), dropNullPlaceholders_(false), omitEndingLineFeed_(false) {}\n\nvoid FastWriter::enableYAMLCompatibility() { yamlCompatiblityEnabled_ = true; }\n\nvoid FastWriter::dropNullPlaceholders() { dropNullPlaceholders_ = true; }\n\nvoid FastWriter::omitEndingLineFeed() { omitEndingLineFeed_ = true; }\n\nstd::string FastWriter::write(const Value &root) {\n  document_ = \"\";\n  writeValue(root);\n  if (!omitEndingLineFeed_)\n    document_ += \"\\n\";\n  return document_;\n}\n\nvoid FastWriter::writeValue(const Value &value) {\n  switch (value.type()) {\n  case nullValue:\n    if (!dropNullPlaceholders_)\n      document_ += \"null\";\n    break;\n  case intValue:\n    document_ += valueToString(value.asLargestInt());\n    break;\n  case uintValue:\n    document_ += valueToString(value.asLargestUInt());\n    break;\n  case realValue:\n    document_ += valueToString(value.asDouble());\n    break;\n  case stringValue:\n    document_ += valueToQuotedString(value.asCString());\n    break;\n  case booleanValue:\n    document_ += valueToString(value.asBool());\n    break;\n  case arrayValue: {\n    document_ += \"[\";\n    int size = value.size();\n    for (int index = 0; index < size; ++index) {\n      if (index > 0)\n        document_ += \",\";\n      writeValue(value[index]);\n    }\n    document_ += \"]\";\n  } break;\n  case objectValue: {\n    Value::Members members(value.getMemberNames());\n    document_ += \"{\";\n    for (Value::Members::iterator it = members.begin(); it != members.end();\n         ++it) {\n      const std::string &name = *it;\n      if (it != members.begin())\n        document_ += \",\";\n      document_ += valueToQuotedString(name.c_str());\n      document_ += yamlCompatiblityEnabled_ ? \": \" : \":\";\n      writeValue(value[name]);\n    }\n    document_ += \"}\";\n  } break;\n  }\n}\n\n// Class StyledWriter\n// //////////////////////////////////////////////////////////////////\n\nStyledWriter::StyledWriter()\n    : rightMargin_(74), indentSize_(3), addChildValues_() {}\n\nstd::string StyledWriter::write(const Value &root) {\n  document_ = \"\";\n  addChildValues_ = false;\n  indentString_ = \"\";\n  writeCommentBeforeValue(root);\n  writeValue(root);\n  writeCommentAfterValueOnSameLine(root);\n  document_ += \"\\n\";\n  return document_;\n}\n\nvoid StyledWriter::writeValue(const Value &value) {\n  switch (value.type()) {\n  case nullValue:\n    pushValue(\"null\");\n    break;\n  case intValue:\n    pushValue(valueToString(value.asLargestInt()));\n    break;\n  case uintValue:\n    pushValue(valueToString(value.asLargestUInt()));\n    break;\n  case realValue:\n    pushValue(valueToString(value.asDouble()));\n    break;\n  case stringValue:\n    pushValue(valueToQuotedString(value.asCString()));\n    break;\n  case booleanValue:\n    pushValue(valueToString(value.asBool()));\n    break;\n  case arrayValue:\n    writeArrayValue(value);\n    break;\n  case objectValue: {\n    Value::Members members(value.getMemberNames());\n    if (members.empty())\n      pushValue(\"{}\");\n    else {\n      writeWithIndent(\"{\");\n      indent();\n      Value::Members::iterator it = members.begin();\n      for (;;) {\n        const std::string &name = *it;\n        const Value &childValue = value[name];\n        writeCommentBeforeValue(childValue);\n        writeWithIndent(valueToQuotedString(name.c_str()));\n        document_ += \" : \";\n        writeValue(childValue);\n        if (++it == members.end()) {\n          writeCommentAfterValueOnSameLine(childValue);\n          break;\n        }\n        document_ += \",\";\n        writeCommentAfterValueOnSameLine(childValue);\n      }\n      unindent();\n      writeWithIndent(\"}\");\n    }\n  } break;\n  }\n}\n\nvoid StyledWriter::writeArrayValue(const Value &value) {\n  unsigned size = value.size();\n  if (size == 0)\n    pushValue(\"[]\");\n  else {\n    bool isArrayMultiLine = isMultineArray(value);\n    if (isArrayMultiLine) {\n      writeWithIndent(\"[\");\n      indent();\n      bool hasChildValue = !childValues_.empty();\n      unsigned index = 0;\n      for (;;) {\n        const Value &childValue = value[index];\n        writeCommentBeforeValue(childValue);\n        if (hasChildValue)\n          writeWithIndent(childValues_[index]);\n        else {\n          writeIndent();\n          writeValue(childValue);\n        }\n        if (++index == size) {\n          writeCommentAfterValueOnSameLine(childValue);\n          break;\n        }\n        document_ += \",\";\n        writeCommentAfterValueOnSameLine(childValue);\n      }\n      unindent();\n      writeWithIndent(\"]\");\n    } else // output on a single line\n    {\n      assert(childValues_.size() == size);\n      document_ += \"[ \";\n      for (unsigned index = 0; index < size; ++index) {\n        if (index > 0)\n          document_ += \", \";\n        document_ += childValues_[index];\n      }\n      document_ += \" ]\";\n    }\n  }\n}\n\nbool StyledWriter::isMultineArray(const Value &value) {\n  int size = value.size();\n  bool isMultiLine = size * 3 >= rightMargin_;\n  childValues_.clear();\n  for (int index = 0; index < size && !isMultiLine; ++index) {\n    const Value &childValue = value[index];\n    isMultiLine =\n        isMultiLine || ((childValue.isArray() || childValue.isObject()) &&\n                        childValue.size() > 0);\n  }\n  if (!isMultiLine) // check if line length > max line length\n  {\n    childValues_.reserve(size);\n    addChildValues_ = true;\n    int lineLength = 4 + (size - 1) * 2; // '[ ' + ', '*n + ' ]'\n    for (int index = 0; index < size; ++index) {\n      writeValue(value[index]);\n      lineLength += int(childValues_[index].length());\n    }\n    addChildValues_ = false;\n    isMultiLine = isMultiLine || lineLength >= rightMargin_;\n  }\n  return isMultiLine;\n}\n\nvoid StyledWriter::pushValue(const std::string &value) {\n  if (addChildValues_)\n    childValues_.push_back(value);\n  else\n    document_ += value;\n}\n\nvoid StyledWriter::writeIndent() {\n  if (!document_.empty()) {\n    char last = document_[document_.length() - 1];\n    if (last == ' ') // already indented\n      return;\n    if (last != '\\n') // Comments may add new-line\n      document_ += '\\n';\n  }\n  document_ += indentString_;\n}\n\nvoid StyledWriter::writeWithIndent(const std::string &value) {\n  writeIndent();\n  document_ += value;\n}\n\nvoid StyledWriter::indent() { indentString_ += std::string(indentSize_, ' '); }\n\nvoid StyledWriter::unindent() {\n  assert(int(indentString_.size()) >= indentSize_);\n  indentString_.resize(indentString_.size() - indentSize_);\n}\n\nvoid StyledWriter::writeCommentBeforeValue(const Value &root) {\n  if (!root.hasComment(commentBefore))\n    return;\n\n  document_ += \"\\n\";\n  writeIndent();\n  std::string normalizedComment = normalizeEOL(root.getComment(commentBefore));\n  std::string::const_iterator iter = normalizedComment.begin();\n  while (iter != normalizedComment.end()) {\n    document_ += *iter;\n    if (*iter == '\\n' && *(iter + 1) == '/')\n      writeIndent();\n    ++iter;\n  }\n\n  // Comments are stripped of newlines, so add one here\n  document_ += \"\\n\";\n}\n\nvoid StyledWriter::writeCommentAfterValueOnSameLine(const Value &root) {\n  if (root.hasComment(commentAfterOnSameLine))\n    document_ += \" \" + normalizeEOL(root.getComment(commentAfterOnSameLine));\n\n  if (root.hasComment(commentAfter)) {\n    document_ += \"\\n\";\n    document_ += normalizeEOL(root.getComment(commentAfter));\n    document_ += \"\\n\";\n  }\n}\n\nbool StyledWriter::hasCommentForValue(const Value &value) {\n  return value.hasComment(commentBefore) ||\n         value.hasComment(commentAfterOnSameLine) ||\n         value.hasComment(commentAfter);\n}\n\nstd::string StyledWriter::normalizeEOL(const std::string &text) {\n  std::string normalized;\n  normalized.reserve(text.length());\n  const char *begin = text.c_str();\n  const char *end = begin + text.length();\n  const char *current = begin;\n  while (current != end) {\n    char c = *current++;\n    if (c == '\\r') // mac or dos EOL\n    {\n      if (*current == '\\n') // convert dos EOL\n        ++current;\n      normalized += '\\n';\n    } else // handle unix EOL & other char\n      normalized += c;\n  }\n  return normalized;\n}\n\n// Class StyledStreamWriter\n// //////////////////////////////////////////////////////////////////\n\nStyledStreamWriter::StyledStreamWriter(std::string indentation)\n    : document_(NULL), rightMargin_(74), indentation_(indentation),\n      addChildValues_() {}\n\nvoid StyledStreamWriter::write(std::ostream &out, const Value &root) {\n  document_ = &out;\n  addChildValues_ = false;\n  indentString_ = \"\";\n  writeCommentBeforeValue(root);\n  writeValue(root);\n  writeCommentAfterValueOnSameLine(root);\n  *document_ << \"\\n\";\n  document_ = NULL; // Forget the stream, for safety.\n}\n\nvoid StyledStreamWriter::writeValue(const Value &value) {\n  switch (value.type()) {\n  case nullValue:\n    pushValue(\"null\");\n    break;\n  case intValue:\n    pushValue(valueToString(value.asLargestInt()));\n    break;\n  case uintValue:\n    pushValue(valueToString(value.asLargestUInt()));\n    break;\n  case realValue:\n    pushValue(valueToString(value.asDouble()));\n    break;\n  case stringValue:\n    pushValue(valueToQuotedString(value.asCString()));\n    break;\n  case booleanValue:\n    pushValue(valueToString(value.asBool()));\n    break;\n  case arrayValue:\n    writeArrayValue(value);\n    break;\n  case objectValue: {\n    Value::Members members(value.getMemberNames());\n    if (members.empty())\n      pushValue(\"{}\");\n    else {\n      writeWithIndent(\"{\");\n      indent();\n      Value::Members::iterator it = members.begin();\n      for (;;) {\n        const std::string &name = *it;\n        const Value &childValue = value[name];\n        writeCommentBeforeValue(childValue);\n        writeWithIndent(valueToQuotedString(name.c_str()));\n        *document_ << \" : \";\n        writeValue(childValue);\n        if (++it == members.end()) {\n          writeCommentAfterValueOnSameLine(childValue);\n          break;\n        }\n        *document_ << \",\";\n        writeCommentAfterValueOnSameLine(childValue);\n      }\n      unindent();\n      writeWithIndent(\"}\");\n    }\n  } break;\n  }\n}\n\nvoid StyledStreamWriter::writeArrayValue(const Value &value) {\n  unsigned size = value.size();\n  if (size == 0)\n    pushValue(\"[]\");\n  else {\n    bool isArrayMultiLine = isMultineArray(value);\n    if (isArrayMultiLine) {\n      writeWithIndent(\"[\");\n      indent();\n      bool hasChildValue = !childValues_.empty();\n      unsigned index = 0;\n      for (;;) {\n        const Value &childValue = value[index];\n        writeCommentBeforeValue(childValue);\n        if (hasChildValue)\n          writeWithIndent(childValues_[index]);\n        else {\n          writeIndent();\n          writeValue(childValue);\n        }\n        if (++index == size) {\n          writeCommentAfterValueOnSameLine(childValue);\n          break;\n        }\n        *document_ << \",\";\n        writeCommentAfterValueOnSameLine(childValue);\n      }\n      unindent();\n      writeWithIndent(\"]\");\n    } else // output on a single line\n    {\n      assert(childValues_.size() == size);\n      *document_ << \"[ \";\n      for (unsigned index = 0; index < size; ++index) {\n        if (index > 0)\n          *document_ << \", \";\n        *document_ << childValues_[index];\n      }\n      *document_ << \" ]\";\n    }\n  }\n}\n\nbool StyledStreamWriter::isMultineArray(const Value &value) {\n  int size = value.size();\n  bool isMultiLine = size * 3 >= rightMargin_;\n  childValues_.clear();\n  for (int index = 0; index < size && !isMultiLine; ++index) {\n    const Value &childValue = value[index];\n    isMultiLine =\n        isMultiLine || ((childValue.isArray() || childValue.isObject()) &&\n                        childValue.size() > 0);\n  }\n  if (!isMultiLine) // check if line length > max line length\n  {\n    childValues_.reserve(size);\n    addChildValues_ = true;\n    int lineLength = 4 + (size - 1) * 2; // '[ ' + ', '*n + ' ]'\n    for (int index = 0; index < size; ++index) {\n      writeValue(value[index]);\n      lineLength += int(childValues_[index].length());\n    }\n    addChildValues_ = false;\n    isMultiLine = isMultiLine || lineLength >= rightMargin_;\n  }\n  return isMultiLine;\n}\n\nvoid StyledStreamWriter::pushValue(const std::string &value) {\n  if (addChildValues_)\n    childValues_.push_back(value);\n  else\n    *document_ << value;\n}\n\nvoid StyledStreamWriter::writeIndent() {\n  /*\n    Some comments in this method would have been nice. ;-)\n\n   if ( !document_.empty() )\n   {\n      char last = document_[document_.length()-1];\n      if ( last == ' ' )     // already indented\n         return;\n      if ( last != '\\n' )    // Comments may add new-line\n         *document_ << '\\n';\n   }\n  */\n  *document_ << '\\n' << indentString_;\n}\n\nvoid StyledStreamWriter::writeWithIndent(const std::string &value) {\n  writeIndent();\n  *document_ << value;\n}\n\nvoid StyledStreamWriter::indent() { indentString_ += indentation_; }\n\nvoid StyledStreamWriter::unindent() {\n  assert(indentString_.size() >= indentation_.size());\n  indentString_.resize(indentString_.size() - indentation_.size());\n}\n\nvoid StyledStreamWriter::writeCommentBeforeValue(const Value &root) {\n  if (!root.hasComment(commentBefore))\n    return;\n  *document_ << normalizeEOL(root.getComment(commentBefore));\n  *document_ << \"\\n\";\n}\n\nvoid StyledStreamWriter::writeCommentAfterValueOnSameLine(const Value &root) {\n  if (root.hasComment(commentAfterOnSameLine))\n    *document_ << \" \" + normalizeEOL(root.getComment(commentAfterOnSameLine));\n\n  if (root.hasComment(commentAfter)) {\n    *document_ << \"\\n\";\n    *document_ << normalizeEOL(root.getComment(commentAfter));\n    *document_ << \"\\n\";\n  }\n}\n\nbool StyledStreamWriter::hasCommentForValue(const Value &value) {\n  return value.hasComment(commentBefore) ||\n         value.hasComment(commentAfterOnSameLine) ||\n         value.hasComment(commentAfter);\n}\n\nstd::string StyledStreamWriter::normalizeEOL(const std::string &text) {\n  std::string normalized;\n  normalized.reserve(text.length());\n  const char *begin = text.c_str();\n  const char *end = begin + text.length();\n  const char *current = begin;\n  while (current != end) {\n    char c = *current++;\n    if (c == '\\r') // mac or dos EOL\n    {\n      if (*current == '\\n') // convert dos EOL\n        ++current;\n      normalized += '\\n';\n    } else // handle unix EOL & other char\n      normalized += c;\n  }\n  return normalized;\n}\n\nstd::ostream &operator<<(std::ostream &sout, const Value &root) {\n  Json::StyledStreamWriter writer;\n  writer.write(sout, root);\n  return sout;\n}\n\n} // namespace Json\n// vim: et ts=2 sts=2 sw=2 tw=0\n"
  },
  {
    "path": "Projects/Libraries/CSBase/Source/json/reader.h",
    "content": "// Copyright 2007-2010 Baptiste Lepilleur\n// Distributed under MIT license, or public domain if desired and\n// recognized in your jurisdiction.\n// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE\n\n#ifndef CPPTL_JSON_READER_H_INCLUDED\n#define CPPTL_JSON_READER_H_INCLUDED\n\n#if !defined(JSON_IS_AMALGAMATION)\n#include \"features.h\"\n#include \"value.h\"\n#endif // if !defined(JSON_IS_AMALGAMATION)\n#include <deque>\n#include <iosfwd>\n#include <stack>\n#include <string>\n\n// Disable warning C4251: <data member>: <type> needs to have dll-interface to\n// be used by...\n#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)\n#pragma warning(push)\n#pragma warning(disable : 4251)\n#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)\n\nnamespace Json {\n\n/** \\brief Unserialize a <a HREF=\"http://www.json.org\">JSON</a> document into a\n *Value.\n *\n */\nclass JSON_API Reader {\npublic:\n  typedef char Char;\n  typedef const Char *Location;\n\n  /** \\brief An error tagged with where in the JSON text it was encountered.\n   *\n   * The offsets give the [start, limit) range of bytes within the text. Note\n   * that this is bytes, not codepoints.\n   *\n   */\n  struct StructuredError {\n    size_t offset_start;\n    size_t offset_limit;\n    std::string message;\n  };\n\n  /** \\brief Constructs a Reader allowing all features\n   * for parsing.\n   */\n  Reader();\n\n  /** \\brief Constructs a Reader allowing the specified feature set\n   * for parsing.\n   */\n  Reader(const Features &features);\n\n  /** \\brief Read a Value from a <a HREF=\"http://www.json.org\">JSON</a>\n   * document.\n   * \\param document UTF-8 encoded string containing the document to read.\n   * \\param root [out] Contains the root value of the document if it was\n   *             successfully parsed.\n   * \\param collectComments \\c true to collect comment and allow writing them\n   * back during\n   *                        serialization, \\c false to discard comments.\n   *                        This parameter is ignored if\n   * Features::allowComments_\n   *                        is \\c false.\n   * \\return \\c true if the document was successfully parsed, \\c false if an\n   * error occurred.\n   */\n  bool\n  parse(const std::string &document, Value &root, bool collectComments = true);\n\n  /** \\brief Read a Value from a <a HREF=\"http://www.json.org\">JSON</a>\n   document.\n   * \\param beginDoc Pointer on the beginning of the UTF-8 encoded string of the\n   document to read.\n   * \\param endDoc Pointer on the end of the UTF-8 encoded string of the\n   document to read.\n   \\               Must be >= beginDoc.\n   * \\param root [out] Contains the root value of the document if it was\n   *             successfully parsed.\n   * \\param collectComments \\c true to collect comment and allow writing them\n   back during\n   *                        serialization, \\c false to discard comments.\n   *                        This parameter is ignored if\n   Features::allowComments_\n   *                        is \\c false.\n   * \\return \\c true if the document was successfully parsed, \\c false if an\n   error occurred.\n   */\n  bool parse(const char *beginDoc,\n             const char *endDoc,\n             Value &root,\n             bool collectComments = true);\n\n  /// \\brief Parse from input stream.\n  /// \\see Json::operator>>(std::istream&, Json::Value&).\n  bool parse(std::istream &is, Value &root, bool collectComments = true);\n\n  /** \\brief Returns a user friendly string that list errors in the parsed\n   * document.\n   * \\return Formatted error message with the list of errors with their location\n   * in\n   *         the parsed document. An empty string is returned if no error\n   * occurred\n   *         during parsing.\n   * \\deprecated Use getFormattedErrorMessages() instead (typo fix).\n   */\n  JSONCPP_DEPRECATED(\"Use getFormattedErrorMessages instead\")\n  std::string getFormatedErrorMessages() const;\n\n  /** \\brief Returns a user friendly string that list errors in the parsed\n   * document.\n   * \\return Formatted error message with the list of errors with their location\n   * in\n   *         the parsed document. An empty string is returned if no error\n   * occurred\n   *         during parsing.\n   */\n  std::string getFormattedErrorMessages() const;\n\n  /** \\brief Returns a vector of structured erros encounted while parsing.\n   * \\return A (possibly empty) vector of StructuredError objects. Currently\n   *         only one error can be returned, but the caller should tolerate\n   * multiple\n   *         errors.  This can occur if the parser recovers from a non-fatal\n   *         parse error and then encounters additional errors.\n   */\n  std::vector<StructuredError> getStructuredErrors() const;\n\nprivate:\n  enum TokenType {\n    tokenEndOfStream = 0,\n    tokenObjectBegin,\n    tokenObjectEnd,\n    tokenArrayBegin,\n    tokenArrayEnd,\n    tokenString,\n    tokenNumber,\n    tokenTrue,\n    tokenFalse,\n    tokenNull,\n    tokenArraySeparator,\n    tokenMemberSeparator,\n    tokenComment,\n    tokenError\n  };\n\n  class Token {\n  public:\n    TokenType type_;\n    Location start_;\n    Location end_;\n  };\n\n  class ErrorInfo {\n  public:\n    Token token_;\n    std::string message_;\n    Location extra_;\n  };\n\n  typedef std::deque<ErrorInfo> Errors;\n\n  bool expectToken(TokenType type, Token &token, const char *message);\n  bool readToken(Token &token);\n  void skipSpaces();\n  bool match(Location pattern, int patternLength);\n  bool readComment();\n  bool readCStyleComment();\n  bool readCppStyleComment();\n  bool readString();\n  void readNumber();\n  bool readValue();\n  bool readObject(Token &token);\n  bool readArray(Token &token);\n  bool decodeNumber(Token &token);\n  bool decodeNumber(Token &token, Value &decoded);\n  bool decodeString(Token &token);\n  bool decodeString(Token &token, std::string &decoded);\n  bool decodeDouble(Token &token);\n  bool decodeDouble(Token &token, Value &decoded);\n  bool decodeUnicodeCodePoint(Token &token,\n                              Location &current,\n                              Location end,\n                              unsigned int &unicode);\n  bool decodeUnicodeEscapeSequence(Token &token,\n                                   Location &current,\n                                   Location end,\n                                   unsigned int &unicode);\n  bool addError(const std::string &message, Token &token, Location extra = 0);\n  bool recoverFromError(TokenType skipUntilToken);\n  bool addErrorAndRecover(const std::string &message,\n                          Token &token,\n                          TokenType skipUntilToken);\n  void skipUntilSpace();\n  Value &currentValue();\n  Char getNextChar();\n  void\n  getLocationLineAndColumn(Location location, int &line, int &column) const;\n  std::string getLocationLineAndColumn(Location location) const;\n  void addComment(Location begin, Location end, CommentPlacement placement);\n  void skipCommentTokens(Token &token);\n\n  typedef std::stack<Value *> Nodes;\n  Nodes nodes_;\n  Errors errors_;\n  std::string document_;\n  Location begin_;\n  Location end_;\n  Location current_;\n  Location lastValueEnd_;\n  Value *lastValue_;\n  std::string commentsBefore_;\n  Features features_;\n  bool collectComments_;\n};\n\n/** \\brief Read from 'sin' into 'root'.\n\n Always keep comments from the input JSON.\n\n This can be used to read a file into a particular sub-object.\n For example:\n \\code\n Json::Value root;\n cin >> root[\"dir\"][\"file\"];\n cout << root;\n \\endcode\n Result:\n \\verbatim\n {\n \"dir\": {\n     \"file\": {\n     // The input stream JSON would be nested here.\n     }\n }\n }\n \\endverbatim\n \\throw std::exception on parse error.\n \\see Json::operator<<()\n*/\nJSON_API std::istream &operator>>(std::istream &, Value &);\n\n} // namespace Json\n\n#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)\n#pragma warning(pop)\n#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)\n\n#endif // CPPTL_JSON_READER_H_INCLUDED\n"
  },
  {
    "path": "Projects/Libraries/CSBase/Source/json/value.h",
    "content": "// Copyright 2007-2010 Baptiste Lepilleur\n// Distributed under MIT license, or public domain if desired and\n// recognized in your jurisdiction.\n// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE\n\n#ifndef CPPTL_JSON_H_INCLUDED\n#define CPPTL_JSON_H_INCLUDED\n\n#if !defined(JSON_IS_AMALGAMATION)\n#include \"forwards.h\"\n#endif // if !defined(JSON_IS_AMALGAMATION)\n#include <string>\n#include <vector>\n\n#ifndef JSON_USE_CPPTL_SMALLMAP\n#include <map>\n#else\n#include <cpptl/smallmap.h>\n#endif\n#ifdef JSON_USE_CPPTL\n#include <cpptl/forwards.h>\n#endif\n\n// Disable warning C4251: <data member>: <type> needs to have dll-interface to\n// be used by...\n#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)\n#pragma warning(push)\n#pragma warning(disable : 4251)\n#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)\n\n/** \\brief JSON (JavaScript Object Notation).\n */\nnamespace Json {\n\n/** \\brief Type of the value held by a Value object.\n */\nenum ValueType {\n  nullValue = 0, ///< 'null' value\n  intValue,      ///< signed integer value\n  uintValue,     ///< unsigned integer value\n  realValue,     ///< double value\n  stringValue,   ///< UTF-8 string value\n  booleanValue,  ///< bool value\n  arrayValue,    ///< array value (ordered list)\n  objectValue    ///< object value (collection of name/value pairs).\n};\n\nenum CommentPlacement {\n  commentBefore = 0,      ///< a comment placed on the line before a value\n  commentAfterOnSameLine, ///< a comment just after a value on the same line\n  commentAfter, ///< a comment on the line after a value (only make sense for\n  /// root value)\n  numberOfCommentPlacement\n};\n\n//# ifdef JSON_USE_CPPTL\n//   typedef CppTL::AnyEnumerator<const char *> EnumMemberNames;\n//   typedef CppTL::AnyEnumerator<const Value &> EnumValues;\n//# endif\n\n/** \\brief Lightweight wrapper to tag static string.\n *\n * Value constructor and objectValue member assignement takes advantage of the\n * StaticString and avoid the cost of string duplication when storing the\n * string or the member name.\n *\n * Example of usage:\n * \\code\n * Json::Value aValue( StaticString(\"some text\") );\n * Json::Value object;\n * static const StaticString code(\"code\");\n * object[code] = 1234;\n * \\endcode\n */\nclass JSON_API StaticString {\npublic:\n  explicit StaticString(const char *czstring) : str_(czstring) {}\n\n  operator const char *() const { return str_; }\n\n  const char *c_str() const { return str_; }\n\nprivate:\n  const char *str_;\n};\n\n/** \\brief Represents a <a HREF=\"http://www.json.org\">JSON</a> value.\n *\n * This class is a discriminated union wrapper that can represents a:\n * - signed integer [range: Value::minInt - Value::maxInt]\n * - unsigned integer (range: 0 - Value::maxUInt)\n * - double\n * - UTF-8 string\n * - boolean\n * - 'null'\n * - an ordered list of Value\n * - collection of name/value pairs (javascript object)\n *\n * The type of the held value is represented by a #ValueType and\n * can be obtained using type().\n *\n * values of an #objectValue or #arrayValue can be accessed using operator[]()\n *methods.\n * Non const methods will automatically create the a #nullValue element\n * if it does not exist.\n * The sequence of an #arrayValue will be automatically resize and initialized\n * with #nullValue. resize() can be used to enlarge or truncate an #arrayValue.\n *\n * The get() methods can be used to obtanis default value in the case the\n *required element\n * does not exist.\n *\n * It is possible to iterate over the list of a #objectValue values using\n * the getMemberNames() method.\n */\nclass JSON_API Value {\n  friend class ValueIteratorBase;\n#ifdef JSON_VALUE_USE_INTERNAL_MAP\n  friend class ValueInternalLink;\n  friend class ValueInternalMap;\n#endif\npublic:\n  typedef std::vector<std::string> Members;\n  typedef ValueIterator iterator;\n  typedef ValueConstIterator const_iterator;\n  typedef Json::UInt UInt;\n  typedef Json::Int Int;\n#if defined(JSON_HAS_INT64)\n  typedef Json::UInt64 UInt64;\n  typedef Json::Int64 Int64;\n#endif // defined(JSON_HAS_INT64)\n  typedef Json::LargestInt LargestInt;\n  typedef Json::LargestUInt LargestUInt;\n  typedef Json::ArrayIndex ArrayIndex;\n\n  static const Value& null;\n  /// Minimum signed integer value that can be stored in a Json::Value.\n  static const LargestInt minLargestInt;\n  /// Maximum signed integer value that can be stored in a Json::Value.\n  static const LargestInt maxLargestInt;\n  /// Maximum unsigned integer value that can be stored in a Json::Value.\n  static const LargestUInt maxLargestUInt;\n\n  /// Minimum signed int value that can be stored in a Json::Value.\n  static const Int minInt;\n  /// Maximum signed int value that can be stored in a Json::Value.\n  static const Int maxInt;\n  /// Maximum unsigned int value that can be stored in a Json::Value.\n  static const UInt maxUInt;\n\n#if defined(JSON_HAS_INT64)\n  /// Minimum signed 64 bits int value that can be stored in a Json::Value.\n  static const Int64 minInt64;\n  /// Maximum signed 64 bits int value that can be stored in a Json::Value.\n  static const Int64 maxInt64;\n  /// Maximum unsigned 64 bits int value that can be stored in a Json::Value.\n  static const UInt64 maxUInt64;\n#endif // defined(JSON_HAS_INT64)\n\nprivate:\n#ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\n  class CZString {\n  public:\n    enum DuplicationPolicy {\n      noDuplication = 0,\n      duplicate,\n      duplicateOnCopy\n    };\n    CZString(ArrayIndex index);\n    CZString(const char *cstr, DuplicationPolicy allocate);\n    CZString(const CZString &other);\n    ~CZString();\n    CZString &operator=(CZString other);\n    bool operator<(const CZString &other) const;\n    bool operator==(const CZString &other) const;\n    ArrayIndex index() const;\n    const char *c_str() const;\n    bool isStaticString() const;\n\n  private:\n    void swap(CZString &other);\n    const char *cstr_;\n    ArrayIndex index_;\n  };\n\npublic:\n#ifndef JSON_USE_CPPTL_SMALLMAP\n  typedef std::map<CZString, Value> ObjectValues;\n#else\n  typedef CppTL::SmallMap<CZString, Value> ObjectValues;\n#endif // ifndef JSON_USE_CPPTL_SMALLMAP\n#endif // ifndef JSON_VALUE_USE_INTERNAL_MAP\n#endif // ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION\n\npublic:\n  /** \\brief Create a default Value of the given type.\n\n    This is a very useful constructor.\n    To create an empty array, pass arrayValue.\n    To create an empty object, pass objectValue.\n    Another Value can then be set to this one by assignment.\nThis is useful since clear() and resize() will not alter types.\n\n    Examples:\n\\code\nJson::Value null_value; // null\nJson::Value arr_value(Json::arrayValue); // []\nJson::Value obj_value(Json::objectValue); // {}\n\\endcode\n  */\n  Value(ValueType type = nullValue);\n  Value(Int value);\n  Value(UInt value);\n#if defined(JSON_HAS_INT64)\n  Value(Int64 value);\n  Value(UInt64 value);\n#endif // if defined(JSON_HAS_INT64)\n  Value(double value);\n  Value(const char *value);\n  Value(const char *beginValue, const char *endValue);\n  /** \\brief Constructs a value from a static string.\n\n   * Like other value string constructor but do not duplicate the string for\n   * internal storage. The given string must remain alive after the call to this\n   * constructor.\n   * Example of usage:\n   * \\code\n   * Json::Value aValue( StaticString(\"some text\") );\n   * \\endcode\n   */\n  Value(const StaticString &value);\n  Value(const std::string &value);\n#ifdef JSON_USE_CPPTL\n  Value(const CppTL::ConstString &value);\n#endif\n  Value(bool value);\n  Value(const Value &other);\n  ~Value();\n\n  Value &operator=(Value other);\n  /// Swap values.\n  /// \\note Currently, comments are intentionally not swapped, for\n  /// both logic and efficiency.\n  void swap(Value &other);\n\n  ValueType type() const;\n\n  bool operator<(const Value &other) const;\n  bool operator<=(const Value &other) const;\n  bool operator>=(const Value &other) const;\n  bool operator>(const Value &other) const;\n\n  bool operator==(const Value &other) const;\n  bool operator!=(const Value &other) const;\n\n  int compare(const Value &other) const;\n\n  const char *asCString() const;\n  std::string asString() const;\n#ifdef JSON_USE_CPPTL\n  CppTL::ConstString asConstString() const;\n#endif\n  Int asInt() const;\n  UInt asUInt() const;\n#if defined(JSON_HAS_INT64)\n  Int64 asInt64() const;\n  UInt64 asUInt64() const;\n#endif // if defined(JSON_HAS_INT64)\n  LargestInt asLargestInt() const;\n  LargestUInt asLargestUInt() const;\n  float asFloat() const;\n  double asDouble() const;\n  bool asBool() const;\n\n  bool isNull() const;\n  bool isBool() const;\n  bool isInt() const;\n  bool isInt64() const;\n  bool isUInt() const;\n  bool isUInt64() const;\n  bool isIntegral() const;\n  bool isDouble() const;\n  bool isNumeric() const;\n  bool isString() const;\n  bool isArray() const;\n  bool isObject() const;\n\n  bool isConvertibleTo(ValueType other) const;\n\n  /// Number of values in array or object\n  ArrayIndex size() const;\n\n  /// \\brief Return true if empty array, empty object, or null;\n  /// otherwise, false.\n  bool empty() const;\n\n  /// Return isNull()\n  bool operator!() const;\n\n  /// Remove all object members and array elements.\n  /// \\pre type() is arrayValue, objectValue, or nullValue\n  /// \\post type() is unchanged\n  void clear();\n\n  /// Resize the array to size elements.\n  /// New elements are initialized to null.\n  /// May only be called on nullValue or arrayValue.\n  /// \\pre type() is arrayValue or nullValue\n  /// \\post type() is arrayValue\n  void resize(ArrayIndex size);\n\n  /// Access an array element (zero based index ).\n  /// If the array contains less than index element, then null value are\n  /// inserted\n  /// in the array so that its size is index+1.\n  /// (You may need to say 'value[0u]' to get your compiler to distinguish\n  ///  this from the operator[] which takes a string.)\n  Value &operator[](ArrayIndex index);\n\n  /// Access an array element (zero based index ).\n  /// If the array contains less than index element, then null value are\n  /// inserted\n  /// in the array so that its size is index+1.\n  /// (You may need to say 'value[0u]' to get your compiler to distinguish\n  ///  this from the operator[] which takes a string.)\n  Value &operator[](int index);\n\n  /// Access an array element (zero based index )\n  /// (You may need to say 'value[0u]' to get your compiler to distinguish\n  ///  this from the operator[] which takes a string.)\n  const Value &operator[](ArrayIndex index) const;\n\n  /// Access an array element (zero based index )\n  /// (You may need to say 'value[0u]' to get your compiler to distinguish\n  ///  this from the operator[] which takes a string.)\n  const Value &operator[](int index) const;\n\n  /// If the array contains at least index+1 elements, returns the element\n  /// value,\n  /// otherwise returns defaultValue.\n  Value get(ArrayIndex index, const Value &defaultValue) const;\n  /// Return true if index < size().\n  bool isValidIndex(ArrayIndex index) const;\n  /// \\brief Append value to array at the end.\n  ///\n  /// Equivalent to jsonvalue[jsonvalue.size()] = value;\n  Value &append(const Value &value);\n\n  /// Access an object value by name, create a null member if it does not exist.\n  Value &operator[](const char *key);\n  /// Access an object value by name, returns null if there is no member with\n  /// that name.\n  const Value &operator[](const char *key) const;\n  /// Access an object value by name, create a null member if it does not exist.\n  Value &operator[](const std::string &key);\n  /// Access an object value by name, returns null if there is no member with\n  /// that name.\n  const Value &operator[](const std::string &key) const;\n  /** \\brief Access an object value by name, create a null member if it does not\n   exist.\n\n   * If the object as no entry for that name, then the member name used to store\n   * the new entry is not duplicated.\n   * Example of use:\n   * \\code\n   * Json::Value object;\n   * static const StaticString code(\"code\");\n   * object[code] = 1234;\n   * \\endcode\n   */\n  Value &operator[](const StaticString &key);\n#ifdef JSON_USE_CPPTL\n  /// Access an object value by name, create a null member if it does not exist.\n  Value &operator[](const CppTL::ConstString &key);\n  /// Access an object value by name, returns null if there is no member with\n  /// that name.\n  const Value &operator[](const CppTL::ConstString &key) const;\n#endif\n  /// Return the member named key if it exist, defaultValue otherwise.\n  Value get(const char *key, const Value &defaultValue) const;\n  /// Return the member named key if it exist, defaultValue otherwise.\n  Value get(const std::string &key, const Value &defaultValue) const;\n#ifdef JSON_USE_CPPTL\n  /// Return the member named key if it exist, defaultValue otherwise.\n  Value get(const CppTL::ConstString &key, const Value &defaultValue) const;\n#endif\n  /// \\brief Remove and return the named member.\n  ///\n  /// Do nothing if it did not exist.\n  /// \\return the removed Value, or null.\n  /// \\pre type() is objectValue or nullValue\n  /// \\post type() is unchanged\n  Value removeMember(const char *key);\n  /// Same as removeMember(const char*)\n  Value removeMember(const std::string &key);\n\n  /// Return true if the object has a member named key.\n  bool isMember(const char *key) const;\n  /// Return true if the object has a member named key.\n  bool isMember(const std::string &key) const;\n#ifdef JSON_USE_CPPTL\n  /// Return true if the object has a member named key.\n  bool isMember(const CppTL::ConstString &key) const;\n#endif\n\n  /// \\brief Return a list of the member names.\n  ///\n  /// If null, return an empty list.\n  /// \\pre type() is objectValue or nullValue\n  /// \\post if type() was nullValue, it remains nullValue\n  Members getMemberNames() const;\n\n  //# ifdef JSON_USE_CPPTL\n  //      EnumMemberNames enumMemberNames() const;\n  //      EnumValues enumValues() const;\n  //# endif\n\n  /// Comments must be //... or /* ... */\n  void setComment(const char *comment, CommentPlacement placement);\n  /// Comments must be //... or /* ... */\n  void setComment(const std::string &comment, CommentPlacement placement);\n  bool hasComment(CommentPlacement placement) const;\n  /// Include delimiters and embedded newlines.\n  std::string getComment(CommentPlacement placement) const;\n\n  std::string toStyledString() const;\n\n  const_iterator begin() const;\n  const_iterator end() const;\n\n  iterator begin();\n  iterator end();\n\n  // Accessors for the [start, limit) range of bytes within the JSON text from\n  // which this value was parsed, if any.\n  void setOffsetStart(size_t start);\n  void setOffsetLimit(size_t limit);\n  size_t getOffsetStart() const;\n  size_t getOffsetLimit() const;\n\nprivate:\n  Value &resolveReference(const char *key, bool isStatic);\n\n#ifdef JSON_VALUE_USE_INTERNAL_MAP\n  inline bool isItemAvailable() const { return itemIsUsed_ == 0; }\n\n  inline void setItemUsed(bool isUsed = true) { itemIsUsed_ = isUsed ? 1 : 0; }\n\n  inline bool isMemberNameStatic() const { return memberNameIsStatic_ == 0; }\n\n  inline void setMemberNameIsStatic(bool isStatic) {\n    memberNameIsStatic_ = isStatic ? 1 : 0;\n  }\n#endif // # ifdef JSON_VALUE_USE_INTERNAL_MAP\n\nprivate:\n  struct CommentInfo {\n    CommentInfo();\n    ~CommentInfo();\n\n    void setComment(const char *text);\n\n    char *comment_;\n  };\n\n  // struct MemberNamesTransform\n  //{\n  //   typedef const char *result_type;\n  //   const char *operator()( const CZString &name ) const\n  //   {\n  //      return name.c_str();\n  //   }\n  //};\n\n  union ValueHolder {\n    LargestInt int_;\n    LargestUInt uint_;\n    double real_;\n    bool bool_;\n    char *string_;\n#ifdef JSON_VALUE_USE_INTERNAL_MAP\n    ValueInternalArray *array_;\n    ValueInternalMap *map_;\n#else\n    ObjectValues *map_;\n#endif\n  } value_;\n  ValueType type_ : 8;\n  int allocated_ : 1; // Notes: if declared as bool, bitfield is useless.\n#ifdef JSON_VALUE_USE_INTERNAL_MAP\n  unsigned int itemIsUsed_ : 1; // used by the ValueInternalMap container.\n  int memberNameIsStatic_ : 1;  // used by the ValueInternalMap container.\n#endif\n  CommentInfo *comments_;\n\n  // [start, limit) byte offsets in the source JSON text from which this Value\n  // was extracted.\n  size_t start_;\n  size_t limit_;\n};\n\n/** \\brief Experimental and untested: represents an element of the \"path\" to\n * access a node.\n */\nclass JSON_API PathArgument {\npublic:\n  friend class Path;\n\n  PathArgument();\n  PathArgument(ArrayIndex index);\n  PathArgument(const char *key);\n  PathArgument(const std::string &key);\n\nprivate:\n  enum Kind {\n    kindNone = 0,\n    kindIndex,\n    kindKey\n  };\n  std::string key_;\n  ArrayIndex index_;\n  Kind kind_;\n};\n\n/** \\brief Experimental and untested: represents a \"path\" to access a node.\n *\n * Syntax:\n * - \".\" => root node\n * - \".[n]\" => elements at index 'n' of root node (an array value)\n * - \".name\" => member named 'name' of root node (an object value)\n * - \".name1.name2.name3\"\n * - \".[0][1][2].name1[3]\"\n * - \".%\" => member name is provided as parameter\n * - \".[%]\" => index is provied as parameter\n */\nclass JSON_API Path {\npublic:\n  Path(const std::string &path,\n       const PathArgument &a1 = PathArgument(),\n       const PathArgument &a2 = PathArgument(),\n       const PathArgument &a3 = PathArgument(),\n       const PathArgument &a4 = PathArgument(),\n       const PathArgument &a5 = PathArgument());\n\n  const Value &resolve(const Value &root) const;\n  Value resolve(const Value &root, const Value &defaultValue) const;\n  /// Creates the \"path\" to access the specified node and returns a reference on\n  /// the node.\n  Value &make(Value &root) const;\n\nprivate:\n  typedef std::vector<const PathArgument *> InArgs;\n  typedef std::vector<PathArgument> Args;\n\n  void makePath(const std::string &path, const InArgs &in);\n  void addPathInArg(const std::string &path,\n                    const InArgs &in,\n                    InArgs::const_iterator &itInArg,\n                    PathArgument::Kind kind);\n  void invalidPath(const std::string &path, int location);\n\n  Args args_;\n};\n\n#ifdef JSON_VALUE_USE_INTERNAL_MAP\n/** \\brief Allocator to customize Value internal map.\n * Below is an example of a simple implementation (default implementation\n actually\n * use memory pool for speed).\n * \\code\n   class DefaultValueMapAllocator : public ValueMapAllocator\n   {\n   public: // overridden from ValueMapAllocator\n      virtual ValueInternalMap *newMap()\n      {\n         return new ValueInternalMap();\n      }\n\n      virtual ValueInternalMap *newMapCopy( const ValueInternalMap &other )\n      {\n         return new ValueInternalMap( other );\n      }\n\n      virtual void destructMap( ValueInternalMap *map )\n      {\n         delete map;\n      }\n\n      virtual ValueInternalLink *allocateMapBuckets( unsigned int size )\n      {\n         return new ValueInternalLink[size];\n      }\n\n      virtual void releaseMapBuckets( ValueInternalLink *links )\n      {\n         delete [] links;\n      }\n\n      virtual ValueInternalLink *allocateMapLink()\n      {\n         return new ValueInternalLink();\n      }\n\n      virtual void releaseMapLink( ValueInternalLink *link )\n      {\n         delete link;\n      }\n   };\n * \\endcode\n */\nclass JSON_API ValueMapAllocator {\npublic:\n  virtual ~ValueMapAllocator();\n  virtual ValueInternalMap *newMap() = 0;\n  virtual ValueInternalMap *newMapCopy(const ValueInternalMap &other) = 0;\n  virtual void destructMap(ValueInternalMap *map) = 0;\n  virtual ValueInternalLink *allocateMapBuckets(unsigned int size) = 0;\n  virtual void releaseMapBuckets(ValueInternalLink *links) = 0;\n  virtual ValueInternalLink *allocateMapLink() = 0;\n  virtual void releaseMapLink(ValueInternalLink *link) = 0;\n};\n\n/** \\brief ValueInternalMap hash-map bucket chain link (for internal use only).\n * \\internal previous_ & next_ allows for bidirectional traversal.\n */\nclass JSON_API ValueInternalLink {\npublic:\n  enum {\n    itemPerLink = 6\n  }; // sizeof(ValueInternalLink) = 128 on 32 bits architecture.\n  enum InternalFlags {\n    flagAvailable = 0,\n    flagUsed = 1\n  };\n\n  ValueInternalLink();\n\n  ~ValueInternalLink();\n\n  Value items_[itemPerLink];\n  char *keys_[itemPerLink];\n  ValueInternalLink *previous_;\n  ValueInternalLink *next_;\n};\n\n/** \\brief A linked page based hash-table implementation used internally by\n *Value.\n * \\internal ValueInternalMap is a tradional bucket based hash-table, with a\n *linked\n * list in each bucket to handle collision. There is an addional twist in that\n * each node of the collision linked list is a page containing a fixed amount of\n * value. This provides a better compromise between memory usage and speed.\n *\n * Each bucket is made up of a chained list of ValueInternalLink. The last\n * link of a given bucket can be found in the 'previous_' field of the following\n *bucket.\n * The last link of the last bucket is stored in tailLink_ as it has no\n *following bucket.\n * Only the last link of a bucket may contains 'available' item. The last link\n *always\n * contains at least one element unless is it the bucket one very first link.\n */\nclass JSON_API ValueInternalMap {\n  friend class ValueIteratorBase;\n  friend class Value;\n\npublic:\n  typedef unsigned int HashKey;\n  typedef unsigned int BucketIndex;\n\n#ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION\n  struct IteratorState {\n    IteratorState() : map_(0), link_(0), itemIndex_(0), bucketIndex_(0) {}\n    ValueInternalMap *map_;\n    ValueInternalLink *link_;\n    BucketIndex itemIndex_;\n    BucketIndex bucketIndex_;\n  };\n#endif // ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION\n\n  ValueInternalMap();\n  ValueInternalMap(const ValueInternalMap &other);\n  ValueInternalMap &operator=(ValueInternalMap other);\n  ~ValueInternalMap();\n\n  void swap(ValueInternalMap &other);\n\n  BucketIndex size() const;\n\n  void clear();\n\n  bool reserveDelta(BucketIndex growth);\n\n  bool reserve(BucketIndex newItemCount);\n\n  const Value *find(const char *key) const;\n\n  Value *find(const char *key);\n\n  Value &resolveReference(const char *key, bool isStatic);\n\n  void remove(const char *key);\n\n  void doActualRemove(ValueInternalLink *link,\n                      BucketIndex index,\n                      BucketIndex bucketIndex);\n\n  ValueInternalLink *&getLastLinkInBucket(BucketIndex bucketIndex);\n\n  Value &setNewItem(const char *key,\n                    bool isStatic,\n                    ValueInternalLink *link,\n                    BucketIndex index);\n\n  Value &unsafeAdd(const char *key, bool isStatic, HashKey hashedKey);\n\n  HashKey hash(const char *key) const;\n\n  int compare(const ValueInternalMap &other) const;\n\nprivate:\n  void makeBeginIterator(IteratorState &it) const;\n  void makeEndIterator(IteratorState &it) const;\n  static bool equals(const IteratorState &x, const IteratorState &other);\n  static void increment(IteratorState &iterator);\n  static void incrementBucket(IteratorState &iterator);\n  static void decrement(IteratorState &iterator);\n  static const char *key(const IteratorState &iterator);\n  static const char *key(const IteratorState &iterator, bool &isStatic);\n  static Value &value(const IteratorState &iterator);\n  static int distance(const IteratorState &x, const IteratorState &y);\n\nprivate:\n  ValueInternalLink *buckets_;\n  ValueInternalLink *tailLink_;\n  BucketIndex bucketsSize_;\n  BucketIndex itemCount_;\n};\n\n/** \\brief A simplified deque implementation used internally by Value.\n* \\internal\n* It is based on a list of fixed \"page\", each page contains a fixed number of\n*items.\n* Instead of using a linked-list, a array of pointer is used for fast item\n*look-up.\n* Look-up for an element is as follow:\n* - compute page index: pageIndex = itemIndex / itemsPerPage\n* - look-up item in page: pages_[pageIndex][itemIndex % itemsPerPage]\n*\n* Insertion is amortized constant time (only the array containing the index of\n*pointers\n* need to be reallocated when items are appended).\n*/\nclass JSON_API ValueInternalArray {\n  friend class Value;\n  friend class ValueIteratorBase;\n\npublic:\n  enum {\n    itemsPerPage = 8\n  }; // should be a power of 2 for fast divide and modulo.\n  typedef Value::ArrayIndex ArrayIndex;\n  typedef unsigned int PageIndex;\n\n#ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION\n  struct IteratorState // Must be a POD\n      {\n    IteratorState() : array_(0), currentPageIndex_(0), currentItemIndex_(0) {}\n    ValueInternalArray *array_;\n    Value **currentPageIndex_;\n    unsigned int currentItemIndex_;\n  };\n#endif // ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION\n\n  ValueInternalArray();\n  ValueInternalArray(const ValueInternalArray &other);\n  ValueInternalArray &operator=(ValueInternalArray other);\n  ~ValueInternalArray();\n  void swap(ValueInternalArray &other);\n\n  void clear();\n  void resize(ArrayIndex newSize);\n\n  Value &resolveReference(ArrayIndex index);\n\n  Value *find(ArrayIndex index) const;\n\n  ArrayIndex size() const;\n\n  int compare(const ValueInternalArray &other) const;\n\nprivate:\n  static bool equals(const IteratorState &x, const IteratorState &other);\n  static void increment(IteratorState &iterator);\n  static void decrement(IteratorState &iterator);\n  static Value &dereference(const IteratorState &iterator);\n  static Value &unsafeDereference(const IteratorState &iterator);\n  static int distance(const IteratorState &x, const IteratorState &y);\n  static ArrayIndex indexOf(const IteratorState &iterator);\n  void makeBeginIterator(IteratorState &it) const;\n  void makeEndIterator(IteratorState &it) const;\n  void makeIterator(IteratorState &it, ArrayIndex index) const;\n\n  void makeIndexValid(ArrayIndex index);\n\n  Value **pages_;\n  ArrayIndex size_;\n  PageIndex pageCount_;\n};\n\n/** \\brief Experimental: do not use. Allocator to customize Value internal\narray.\n * Below is an example of a simple implementation (actual implementation use\n * memory pool).\n   \\code\nclass DefaultValueArrayAllocator : public ValueArrayAllocator\n{\npublic: // overridden from ValueArrayAllocator\nvirtual ~DefaultValueArrayAllocator()\n{\n}\n\nvirtual ValueInternalArray *newArray()\n{\n   return new ValueInternalArray();\n}\n\nvirtual ValueInternalArray *newArrayCopy( const ValueInternalArray &other )\n{\n   return new ValueInternalArray( other );\n}\n\nvirtual void destruct( ValueInternalArray *array )\n{\n   delete array;\n}\n\nvirtual void reallocateArrayPageIndex( Value **&indexes,\n                                       ValueInternalArray::PageIndex\n&indexCount,\n                                       ValueInternalArray::PageIndex\nminNewIndexCount )\n{\n   ValueInternalArray::PageIndex newIndexCount = (indexCount*3)/2 + 1;\n   if ( minNewIndexCount > newIndexCount )\n      newIndexCount = minNewIndexCount;\n   void *newIndexes = realloc( indexes, sizeof(Value*) * newIndexCount );\n   if ( !newIndexes )\n      throw std::bad_alloc();\n   indexCount = newIndexCount;\n   indexes = static_cast<Value **>( newIndexes );\n}\nvirtual void releaseArrayPageIndex( Value **indexes,\n                                    ValueInternalArray::PageIndex indexCount )\n{\n   if ( indexes )\n      free( indexes );\n}\n\nvirtual Value *allocateArrayPage()\n{\n   return static_cast<Value *>( malloc( sizeof(Value) *\nValueInternalArray::itemsPerPage ) );\n}\n\nvirtual void releaseArrayPage( Value *value )\n{\n   if ( value )\n      free( value );\n}\n};\n   \\endcode\n */\nclass JSON_API ValueArrayAllocator {\npublic:\n  virtual ~ValueArrayAllocator();\n  virtual ValueInternalArray *newArray() = 0;\n  virtual ValueInternalArray *newArrayCopy(const ValueInternalArray &other) = 0;\n  virtual void destructArray(ValueInternalArray *array) = 0;\n  /** \\brief Reallocate array page index.\n   * Reallocates an array of pointer on each page.\n   * \\param indexes [input] pointer on the current index. May be \\c NULL.\n   *                [output] pointer on the new index of at least\n   *                         \\a minNewIndexCount pages.\n   * \\param indexCount [input] current number of pages in the index.\n   *                   [output] number of page the reallocated index can handle.\n   *                            \\b MUST be >= \\a minNewIndexCount.\n   * \\param minNewIndexCount Minimum number of page the new index must be able\n   * to\n   *                         handle.\n   */\n  virtual void\n  reallocateArrayPageIndex(Value **&indexes,\n                           ValueInternalArray::PageIndex &indexCount,\n                           ValueInternalArray::PageIndex minNewIndexCount) = 0;\n  virtual void\n  releaseArrayPageIndex(Value **indexes,\n                        ValueInternalArray::PageIndex indexCount) = 0;\n  virtual Value *allocateArrayPage() = 0;\n  virtual void releaseArrayPage(Value *value) = 0;\n};\n#endif // #ifdef JSON_VALUE_USE_INTERNAL_MAP\n\n/** \\brief base class for Value iterators.\n *\n */\nclass JSON_API ValueIteratorBase {\npublic:\n  typedef std::bidirectional_iterator_tag iterator_category;\n  typedef unsigned int size_t;\n  typedef int difference_type;\n  typedef ValueIteratorBase SelfType;\n\n  ValueIteratorBase();\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\n  explicit ValueIteratorBase(const Value::ObjectValues::iterator &current);\n#else\n  ValueIteratorBase(const ValueInternalArray::IteratorState &state);\n  ValueIteratorBase(const ValueInternalMap::IteratorState &state);\n#endif\n\n  bool operator==(const SelfType &other) const { return isEqual(other); }\n\n  bool operator!=(const SelfType &other) const { return !isEqual(other); }\n\n  difference_type operator-(const SelfType &other) const {\n    return computeDistance(other);\n  }\n\n  /// Return either the index or the member name of the referenced value as a\n  /// Value.\n  Value key() const;\n\n  /// Return the index of the referenced Value. -1 if it is not an arrayValue.\n  UInt index() const;\n\n  /// Return the member name of the referenced Value. \"\" if it is not an\n  /// objectValue.\n  const char *memberName() const;\n\nprotected:\n  Value &deref() const;\n\n  void increment();\n\n  void decrement();\n\n  difference_type computeDistance(const SelfType &other) const;\n\n  bool isEqual(const SelfType &other) const;\n\n  void copy(const SelfType &other);\n\nprivate:\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\n  Value::ObjectValues::iterator current_;\n  // Indicates that iterator is for a null value.\n  bool isNull_;\n#else\n  union {\n    ValueInternalArray::IteratorState array_;\n    ValueInternalMap::IteratorState map_;\n  } iterator_;\n  bool isArray_;\n#endif\n};\n\n/** \\brief const iterator for object and array value.\n *\n */\nclass JSON_API ValueConstIterator : public ValueIteratorBase {\n  friend class Value;\n\npublic:\n  typedef const Value value_type;\n  typedef unsigned int size_t;\n  typedef int difference_type;\n  typedef const Value &reference;\n  typedef const Value *pointer;\n  typedef ValueConstIterator SelfType;\n\n  ValueConstIterator();\n\nprivate:\n/*! \\internal Use by Value to create an iterator.\n */\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\n  explicit ValueConstIterator(const Value::ObjectValues::iterator &current);\n#else\n  ValueConstIterator(const ValueInternalArray::IteratorState &state);\n  ValueConstIterator(const ValueInternalMap::IteratorState &state);\n#endif\npublic:\n  SelfType &operator=(const ValueIteratorBase &other);\n\n  SelfType operator++(int) {\n    SelfType temp(*this);\n    ++*this;\n    return temp;\n  }\n\n  SelfType operator--(int) {\n    SelfType temp(*this);\n    --*this;\n    return temp;\n  }\n\n  SelfType &operator--() {\n    decrement();\n    return *this;\n  }\n\n  SelfType &operator++() {\n    increment();\n    return *this;\n  }\n\n  reference operator*() const { return deref(); }\n};\n\n/** \\brief Iterator for object and array value.\n */\nclass JSON_API ValueIterator : public ValueIteratorBase {\n  friend class Value;\n\npublic:\n  typedef Value value_type;\n  typedef unsigned int size_t;\n  typedef int difference_type;\n  typedef Value &reference;\n  typedef Value *pointer;\n  typedef ValueIterator SelfType;\n\n  ValueIterator();\n  ValueIterator(const ValueConstIterator &other);\n  ValueIterator(const ValueIterator &other);\n\nprivate:\n/*! \\internal Use by Value to create an iterator.\n */\n#ifndef JSON_VALUE_USE_INTERNAL_MAP\n  explicit ValueIterator(const Value::ObjectValues::iterator &current);\n#else\n  ValueIterator(const ValueInternalArray::IteratorState &state);\n  ValueIterator(const ValueInternalMap::IteratorState &state);\n#endif\npublic:\n  SelfType &operator=(const SelfType &other);\n\n  SelfType operator++(int) {\n    SelfType temp(*this);\n    ++*this;\n    return temp;\n  }\n\n  SelfType operator--(int) {\n    SelfType temp(*this);\n    --*this;\n    return temp;\n  }\n\n  SelfType &operator--() {\n    decrement();\n    return *this;\n  }\n\n  SelfType &operator++() {\n    increment();\n    return *this;\n  }\n\n  reference operator*() const { return deref(); }\n};\n\n} // namespace Json\n\n#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)\n#pragma warning(pop)\n#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)\n\n#endif // CPPTL_JSON_H_INCLUDED\n"
  },
  {
    "path": "Projects/Libraries/CSBase/Source/json/version.h.in",
    "content": "// DO NOT EDIT. This file is generated by CMake from  \"version\" \n// and \"version.h.in\" files.\n// Run CMake configure step to update it.\n#ifndef JSON_VERSION_H_INCLUDED\n# define JSON_VERSION_H_INCLUDED\n\n# define JSONCPP_VERSION_STRING \"@JSONCPP_VERSION@\"\n# define JSONCPP_VERSION_MAJOR @JSONCPP_VERSION_MAJOR@\n# define JSONCPP_VERSION_MINOR @JSONCPP_VERSION_MINOR@\n# define JSONCPP_VERSION_PATCH @JSONCPP_VERSION_PATCH@\n# define JSONCPP_VERSION_QUALIFIER @JSONCPP_VERSION_QUALIFIER@\n# define JSONCPP_VERSION_HEXA ((JSONCPP_VERSION_MAJOR << 24) | (JSONCPP_VERSION_MINOR << 16) | (JSONCPP_VERSION_PATCH << 8))\n\n#endif // JSON_VERSION_H_INCLUDED\n"
  },
  {
    "path": "Projects/Libraries/CSBase/Source/json/writer.h",
    "content": "// Copyright 2007-2010 Baptiste Lepilleur\n// Distributed under MIT license, or public domain if desired and\n// recognized in your jurisdiction.\n// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE\n\n#ifndef JSON_WRITER_H_INCLUDED\n#define JSON_WRITER_H_INCLUDED\n\n#if !defined(JSON_IS_AMALGAMATION)\n#include \"value.h\"\n#endif // if !defined(JSON_IS_AMALGAMATION)\n#include <vector>\n#include <string>\n\n// Disable warning C4251: <data member>: <type> needs to have dll-interface to\n// be used by...\n#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)\n#pragma warning(push)\n#pragma warning(disable : 4251)\n#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)\n\nnamespace Json {\n\nclass Value;\n\n/** \\brief Abstract class for writers.\n */\nclass JSON_API Writer {\npublic:\n  virtual ~Writer();\n\n  virtual std::string write(const Value &root) = 0;\n};\n\n/** \\brief Outputs a Value in <a HREF=\"http://www.json.org\">JSON</a> format\n *without formatting (not human friendly).\n *\n * The JSON document is written in a single line. It is not intended for 'human'\n *consumption,\n * but may be usefull to support feature such as RPC where bandwith is limited.\n * \\sa Reader, Value\n */\nclass JSON_API FastWriter : public Writer {\npublic:\n  FastWriter();\n  virtual ~FastWriter() {}\n\n  void enableYAMLCompatibility();\n\n  /** \\brief Drop the \"null\" string from the writer's output for nullValues.\n   * Strictly speaking, this is not valid JSON. But when the output is being\n   * fed to a browser's Javascript, it makes for smaller output and the\n   * browser can handle the output just fine.\n   */\n  void dropNullPlaceholders();\n\n  void omitEndingLineFeed();\n\npublic: // overridden from Writer\n  virtual std::string write(const Value &root);\n\nprivate:\n  void writeValue(const Value &value);\n\n  std::string document_;\n  bool yamlCompatiblityEnabled_;\n  bool dropNullPlaceholders_;\n  bool omitEndingLineFeed_;\n};\n\n/** \\brief Writes a Value in <a HREF=\"http://www.json.org\">JSON</a> format in a\n *human friendly way.\n *\n * The rules for line break and indent are as follow:\n * - Object value:\n *     - if empty then print {} without indent and line break\n *     - if not empty the print '{', line break & indent, print one value per\n *line\n *       and then unindent and line break and print '}'.\n * - Array value:\n *     - if empty then print [] without indent and line break\n *     - if the array contains no object value, empty array or some other value\n *types,\n *       and all the values fit on one lines, then print the array on a single\n *line.\n *     - otherwise, it the values do not fit on one line, or the array contains\n *       object or non empty array, then print one value per line.\n *\n * If the Value have comments then they are outputed according to their\n *#CommentPlacement.\n *\n * \\sa Reader, Value, Value::setComment()\n */\nclass JSON_API StyledWriter : public Writer {\npublic:\n  StyledWriter();\n  virtual ~StyledWriter() {}\n\npublic: // overridden from Writer\n  /** \\brief Serialize a Value in <a HREF=\"http://www.json.org\">JSON</a> format.\n   * \\param root Value to serialize.\n   * \\return String containing the JSON document that represents the root value.\n   */\n  virtual std::string write(const Value &root);\n\nprivate:\n  void writeValue(const Value &value);\n  void writeArrayValue(const Value &value);\n  bool isMultineArray(const Value &value);\n  void pushValue(const std::string &value);\n  void writeIndent();\n  void writeWithIndent(const std::string &value);\n  void indent();\n  void unindent();\n  void writeCommentBeforeValue(const Value &root);\n  void writeCommentAfterValueOnSameLine(const Value &root);\n  bool hasCommentForValue(const Value &value);\n  static std::string normalizeEOL(const std::string &text);\n\n  typedef std::vector<std::string> ChildValues;\n\n  ChildValues childValues_;\n  std::string document_;\n  std::string indentString_;\n  int rightMargin_;\n  int indentSize_;\n  bool addChildValues_;\n};\n\n/** \\brief Writes a Value in <a HREF=\"http://www.json.org\">JSON</a> format in a\n human friendly way,\n     to a stream rather than to a string.\n *\n * The rules for line break and indent are as follow:\n * - Object value:\n *     - if empty then print {} without indent and line break\n *     - if not empty the print '{', line break & indent, print one value per\n line\n *       and then unindent and line break and print '}'.\n * - Array value:\n *     - if empty then print [] without indent and line break\n *     - if the array contains no object value, empty array or some other value\n types,\n *       and all the values fit on one lines, then print the array on a single\n line.\n *     - otherwise, it the values do not fit on one line, or the array contains\n *       object or non empty array, then print one value per line.\n *\n * If the Value have comments then they are outputed according to their\n #CommentPlacement.\n *\n * \\param indentation Each level will be indented by this amount extra.\n * \\sa Reader, Value, Value::setComment()\n */\nclass JSON_API StyledStreamWriter {\npublic:\n  StyledStreamWriter(std::string indentation = \"\\t\");\n  ~StyledStreamWriter() {}\n\npublic:\n  /** \\brief Serialize a Value in <a HREF=\"http://www.json.org\">JSON</a> format.\n   * \\param out Stream to write to. (Can be ostringstream, e.g.)\n   * \\param root Value to serialize.\n   * \\note There is no point in deriving from Writer, since write() should not\n   * return a value.\n   */\n  void write(std::ostream &out, const Value &root);\n\nprivate:\n  void writeValue(const Value &value);\n  void writeArrayValue(const Value &value);\n  bool isMultineArray(const Value &value);\n  void pushValue(const std::string &value);\n  void writeIndent();\n  void writeWithIndent(const std::string &value);\n  void indent();\n  void unindent();\n  void writeCommentBeforeValue(const Value &root);\n  void writeCommentAfterValueOnSameLine(const Value &root);\n  bool hasCommentForValue(const Value &value);\n  static std::string normalizeEOL(const std::string &text);\n\n  typedef std::vector<std::string> ChildValues;\n\n  ChildValues childValues_;\n  std::ostream *document_;\n  std::string indentString_;\n  int rightMargin_;\n  std::string indentation_;\n  bool addChildValues_;\n};\n\n#if defined(JSON_HAS_INT64)\nstd::string JSON_API valueToString(Int value);\nstd::string JSON_API valueToString(UInt value);\n#endif // if defined(JSON_HAS_INT64)\nstd::string JSON_API valueToString(LargestInt value);\nstd::string JSON_API valueToString(LargestUInt value);\nstd::string JSON_API valueToString(double value);\nstd::string JSON_API valueToString(bool value);\nstd::string JSON_API valueToQuotedString(const char *value);\n\n/// \\brief Output using the StyledStreamWriter.\n/// \\see Json::operator>>()\nJSON_API std::ostream &operator<<(std::ostream &, const Value &root);\n\n} // namespace Json\n\n#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)\n#pragma warning(pop)\n#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)\n\n#endif // JSON_WRITER_H_INCLUDED\n"
  },
  {
    "path": "Projects/Libraries/CSBase/Source/md5/md5.cpp",
    "content": "/* MD5\n converted to C++ class by Frank Thilo (thilo@unix-ag.org)\n for bzflag (http://www.bzflag.org)\n\n   based on:\n\n   md5.h and md5.c\n   reference implemantion of RFC 1321\n\n   Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All\nrights reserved.\n\nLicense to copy and use this software is granted provided that it\nis identified as the \"RSA Data Security, Inc. MD5 Message-Digest\nAlgorithm\" in all material mentioning or referencing this software\nor this function.\n\nLicense is also granted to make and use derivative works provided\nthat such works are identified as \"derived from the RSA Data\nSecurity, Inc. MD5 Message-Digest Algorithm\" in all material\nmentioning or referencing the derived work.\n\nRSA Data Security, Inc. makes no representations concerning either\nthe merchantability of this software or the suitability of this\nsoftware for any particular purpose. It is provided \"as is\"\nwithout express or implied warranty of any kind.\n\nThese notices must be retained in any copies of any part of this\ndocumentation and/or software.\n\n*/\n\n/* interface header */\n#include \"md5.h\"\n\n/* system implementation headers */\n#include <cstdio>\n\n\n// Constants for MD5Transform routine.\n#define S11 7\n#define S12 12\n#define S13 17\n#define S14 22\n#define S21 5\n#define S22 9\n#define S23 14\n#define S24 20\n#define S31 4\n#define S32 11\n#define S33 16\n#define S34 23\n#define S41 6\n#define S42 10\n#define S43 15\n#define S44 21\n\n///////////////////////////////////////////////\n\n// F, G, H and I are basic MD5 functions.\ninline MD5::uint4 MD5::F(uint4 x, uint4 y, uint4 z) {\n  return x&y | ~x&z;\n}\n\ninline MD5::uint4 MD5::G(uint4 x, uint4 y, uint4 z) {\n  return x&z | y&~z;\n}\n\ninline MD5::uint4 MD5::H(uint4 x, uint4 y, uint4 z) {\n  return x^y^z;\n}\n\ninline MD5::uint4 MD5::I(uint4 x, uint4 y, uint4 z) {\n  return y ^ (x | ~z);\n}\n\n// rotate_left rotates x left n bits.\ninline MD5::uint4 MD5::rotate_left(uint4 x, int n) {\n  return (x << n) | (x >> (32-n));\n}\n\n// FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4.\n// Rotation is separate from addition to prevent recomputation.\ninline void MD5::FF(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac) {\n  a = rotate_left(a+ F(b,c,d) + x + ac, s) + b;\n}\n\ninline void MD5::GG(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac) {\n  a = rotate_left(a + G(b,c,d) + x + ac, s) + b;\n}\n\ninline void MD5::HH(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac) {\n  a = rotate_left(a + H(b,c,d) + x + ac, s) + b;\n}\n\ninline void MD5::II(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac) {\n  a = rotate_left(a + I(b,c,d) + x + ac, s) + b;\n}\n\n//////////////////////////////////////////////\n\n// default ctor, just initailize\nMD5::MD5()\n{\n  init();\n}\n\n//////////////////////////////////////////////\n\n// nifty shortcut ctor, compute MD5 for string and finalize it right away\nMD5::MD5(const std::string &text)\n{\n  init();\n  update(text.c_str(), text.length());\n  finalize();\n}\n\n//////////////////////////////\n\nvoid MD5::init()\n{\n  finalized=false;\n\n  count[0] = 0;\n  count[1] = 0;\n\n  // load magic initialization constants.\n  state[0] = 0x67452301;\n  state[1] = 0xefcdab89;\n  state[2] = 0x98badcfe;\n  state[3] = 0x10325476;\n}\n\n//////////////////////////////\n\n// decodes input (unsigned char) into output (uint4). Assumes len is a multiple of 4.\nvoid MD5::decode(uint4 output[], const uint1 input[], size_type len)\n{\n  for (unsigned int i = 0, j = 0; j < len; i++, j += 4)\n    output[i] = ((uint4)input[j]) | (((uint4)input[j+1]) << 8) |\n      (((uint4)input[j+2]) << 16) | (((uint4)input[j+3]) << 24);\n}\n\n//////////////////////////////\n\n// encodes input (uint4) into output (unsigned char). Assumes len is\n// a multiple of 4.\nvoid MD5::encode(uint1 output[], const uint4 input[], size_type len)\n{\n  for (size_type i = 0, j = 0; j < len; i++, j += 4) {\n    output[j] = input[i] & 0xff;\n    output[j+1] = (input[i] >> 8) & 0xff;\n    output[j+2] = (input[i] >> 16) & 0xff;\n    output[j+3] = (input[i] >> 24) & 0xff;\n  }\n}\n\n//////////////////////////////\n\n// apply MD5 algo on a block\nvoid MD5::transform(const uint1 block[blocksize])\n{\n  uint4 a = state[0], b = state[1], c = state[2], d = state[3], x[16];\n  decode (x, block, blocksize);\n\n  /* Round 1 */\n  FF (a, b, c, d, x[ 0], S11, 0xd76aa478); /* 1 */\n  FF (d, a, b, c, x[ 1], S12, 0xe8c7b756); /* 2 */\n  FF (c, d, a, b, x[ 2], S13, 0x242070db); /* 3 */\n  FF (b, c, d, a, x[ 3], S14, 0xc1bdceee); /* 4 */\n  FF (a, b, c, d, x[ 4], S11, 0xf57c0faf); /* 5 */\n  FF (d, a, b, c, x[ 5], S12, 0x4787c62a); /* 6 */\n  FF (c, d, a, b, x[ 6], S13, 0xa8304613); /* 7 */\n  FF (b, c, d, a, x[ 7], S14, 0xfd469501); /* 8 */\n  FF (a, b, c, d, x[ 8], S11, 0x698098d8); /* 9 */\n  FF (d, a, b, c, x[ 9], S12, 0x8b44f7af); /* 10 */\n  FF (c, d, a, b, x[10], S13, 0xffff5bb1); /* 11 */\n  FF (b, c, d, a, x[11], S14, 0x895cd7be); /* 12 */\n  FF (a, b, c, d, x[12], S11, 0x6b901122); /* 13 */\n  FF (d, a, b, c, x[13], S12, 0xfd987193); /* 14 */\n  FF (c, d, a, b, x[14], S13, 0xa679438e); /* 15 */\n  FF (b, c, d, a, x[15], S14, 0x49b40821); /* 16 */\n\n  /* Round 2 */\n  GG (a, b, c, d, x[ 1], S21, 0xf61e2562); /* 17 */\n  GG (d, a, b, c, x[ 6], S22, 0xc040b340); /* 18 */\n  GG (c, d, a, b, x[11], S23, 0x265e5a51); /* 19 */\n  GG (b, c, d, a, x[ 0], S24, 0xe9b6c7aa); /* 20 */\n  GG (a, b, c, d, x[ 5], S21, 0xd62f105d); /* 21 */\n  GG (d, a, b, c, x[10], S22,  0x2441453); /* 22 */\n  GG (c, d, a, b, x[15], S23, 0xd8a1e681); /* 23 */\n  GG (b, c, d, a, x[ 4], S24, 0xe7d3fbc8); /* 24 */\n  GG (a, b, c, d, x[ 9], S21, 0x21e1cde6); /* 25 */\n  GG (d, a, b, c, x[14], S22, 0xc33707d6); /* 26 */\n  GG (c, d, a, b, x[ 3], S23, 0xf4d50d87); /* 27 */\n  GG (b, c, d, a, x[ 8], S24, 0x455a14ed); /* 28 */\n  GG (a, b, c, d, x[13], S21, 0xa9e3e905); /* 29 */\n  GG (d, a, b, c, x[ 2], S22, 0xfcefa3f8); /* 30 */\n  GG (c, d, a, b, x[ 7], S23, 0x676f02d9); /* 31 */\n  GG (b, c, d, a, x[12], S24, 0x8d2a4c8a); /* 32 */\n\n  /* Round 3 */\n  HH (a, b, c, d, x[ 5], S31, 0xfffa3942); /* 33 */\n  HH (d, a, b, c, x[ 8], S32, 0x8771f681); /* 34 */\n  HH (c, d, a, b, x[11], S33, 0x6d9d6122); /* 35 */\n  HH (b, c, d, a, x[14], S34, 0xfde5380c); /* 36 */\n  HH (a, b, c, d, x[ 1], S31, 0xa4beea44); /* 37 */\n  HH (d, a, b, c, x[ 4], S32, 0x4bdecfa9); /* 38 */\n  HH (c, d, a, b, x[ 7], S33, 0xf6bb4b60); /* 39 */\n  HH (b, c, d, a, x[10], S34, 0xbebfbc70); /* 40 */\n  HH (a, b, c, d, x[13], S31, 0x289b7ec6); /* 41 */\n  HH (d, a, b, c, x[ 0], S32, 0xeaa127fa); /* 42 */\n  HH (c, d, a, b, x[ 3], S33, 0xd4ef3085); /* 43 */\n  HH (b, c, d, a, x[ 6], S34,  0x4881d05); /* 44 */\n  HH (a, b, c, d, x[ 9], S31, 0xd9d4d039); /* 45 */\n  HH (d, a, b, c, x[12], S32, 0xe6db99e5); /* 46 */\n  HH (c, d, a, b, x[15], S33, 0x1fa27cf8); /* 47 */\n  HH (b, c, d, a, x[ 2], S34, 0xc4ac5665); /* 48 */\n\n  /* Round 4 */\n  II (a, b, c, d, x[ 0], S41, 0xf4292244); /* 49 */\n  II (d, a, b, c, x[ 7], S42, 0x432aff97); /* 50 */\n  II (c, d, a, b, x[14], S43, 0xab9423a7); /* 51 */\n  II (b, c, d, a, x[ 5], S44, 0xfc93a039); /* 52 */\n  II (a, b, c, d, x[12], S41, 0x655b59c3); /* 53 */\n  II (d, a, b, c, x[ 3], S42, 0x8f0ccc92); /* 54 */\n  II (c, d, a, b, x[10], S43, 0xffeff47d); /* 55 */\n  II (b, c, d, a, x[ 1], S44, 0x85845dd1); /* 56 */\n  II (a, b, c, d, x[ 8], S41, 0x6fa87e4f); /* 57 */\n  II (d, a, b, c, x[15], S42, 0xfe2ce6e0); /* 58 */\n  II (c, d, a, b, x[ 6], S43, 0xa3014314); /* 59 */\n  II (b, c, d, a, x[13], S44, 0x4e0811a1); /* 60 */\n  II (a, b, c, d, x[ 4], S41, 0xf7537e82); /* 61 */\n  II (d, a, b, c, x[11], S42, 0xbd3af235); /* 62 */\n  II (c, d, a, b, x[ 2], S43, 0x2ad7d2bb); /* 63 */\n  II (b, c, d, a, x[ 9], S44, 0xeb86d391); /* 64 */\n\n  state[0] += a;\n  state[1] += b;\n  state[2] += c;\n  state[3] += d;\n\n  // Zeroize sensitive information.\n  memset(x, 0, sizeof x);\n}\n\n//////////////////////////////\n\n// MD5 block update operation. Continues an MD5 message-digest\n// operation, processing another message block\nvoid MD5::update(const unsigned char input[], size_type length)\n{\n  // compute number of bytes mod 64\n  size_type index = count[0] / 8 % blocksize;\n\n  // Update number of bits\n  if ((count[0] += (length << 3)) < (length << 3))\n    count[1]++;\n  count[1] += (length >> 29);\n\n  // number of bytes we need to fill in buffer\n  size_type firstpart = 64 - index;\n\n  size_type i;\n\n  // transform as many times as possible.\n  if (length >= firstpart)\n  {\n    // fill buffer first, transform\n    memcpy(&buffer[index], input, firstpart);\n    transform(buffer);\n\n    // transform chunks of blocksize (64 bytes)\n    for (i = firstpart; i + blocksize <= length; i += blocksize)\n      transform(&input[i]);\n\n    index = 0;\n  }\n  else\n    i = 0;\n\n  // buffer remaining input\n  memcpy(&buffer[index], &input[i], length-i);\n}\n\n//////////////////////////////\n\n// for convenience provide a verson with signed char\nvoid MD5::update(const char input[], size_type length)\n{\n  update((const unsigned char*)input, length);\n}\n\n//////////////////////////////\n\n// MD5 finalization. Ends an MD5 message-digest operation, writing the\n// the message digest and zeroizing the context.\nMD5& MD5::finalize()\n{\n  static unsigned char padding[64] = {\n    0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0\n  };\n\n  if (!finalized) {\n    // Save number of bits\n    unsigned char bits[8];\n    encode(bits, count, 8);\n\n    // pad out to 56 mod 64.\n    size_type index = count[0] / 8 % 64;\n    size_type padLen = (index < 56) ? (56 - index) : (120 - index);\n    update(padding, padLen);\n\n    // Append length (before padding)\n    update(bits, 8);\n\n    // Store state in digest\n    encode(digest, state, 16);\n\n    // Zeroize sensitive information.\n    memset(buffer, 0, sizeof buffer);\n    memset(count, 0, sizeof count);\n\n    finalized=true;\n  }\n\n  return *this;\n}\n\n//////////////////////////////\n\n// return hex representation of digest as string\nstd::string MD5::hexdigest() const\n{\n  if (!finalized)\n    return \"\";\n\n  char buf[33];\n  for (int i=0; i<16; i++)\n    sprintf(buf+i*2, \"%02x\", digest[i]);\n  buf[32]=0;\n\n  return std::string(buf);\n}\n\n//////////////////////////////\n\nstd::ostream& operator<<(std::ostream& out, MD5 md5)\n{\n  return out << md5.hexdigest();\n}\n\n//////////////////////////////\n\nstd::string md5(const std::string str)\n{\n    MD5 md5 = MD5(str);\n\n    return md5.hexdigest();\n}\n"
  },
  {
    "path": "Projects/Libraries/CSBase/Source/md5/md5.h",
    "content": "/* MD5\n converted to C++ class by Frank Thilo (thilo@unix-ag.org)\n for bzflag (http://www.bzflag.org)\n\n   based on:\n\n   md5.h and md5.c\n   reference implementation of RFC 1321\n\n   Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All\nrights reserved.\n\nLicense to copy and use this software is granted provided that it\nis identified as the \"RSA Data Security, Inc. MD5 Message-Digest\nAlgorithm\" in all material mentioning or referencing this software\nor this function.\n\nLicense is also granted to make and use derivative works provided\nthat such works are identified as \"derived from the RSA Data\nSecurity, Inc. MD5 Message-Digest Algorithm\" in all material\nmentioning or referencing the derived work.\n\nRSA Data Security, Inc. makes no representations concerning either\nthe merchantability of this software or the suitability of this\nsoftware for any particular purpose. It is provided \"as is\"\nwithout express or implied warranty of any kind.\n\nThese notices must be retained in any copies of any part of this\ndocumentation and/or software.\n\n*/\n\n#ifndef BZF_MD5_H\n#define BZF_MD5_H\n\n#include <cstring>\n#include <iostream>\n\n\n// a small class for calculating MD5 hashes of strings or byte arrays\n// it is not meant to be fast or secure\n//\n// usage: 1) feed it blocks of uchars with update()\n//      2) finalize()\n//      3) get hexdigest() string\n//      or\n//      MD5(std::string).hexdigest()\n//\n// assumes that char is 8 bit and int is 32 bit\nclass MD5\n{\npublic:\n  typedef unsigned int size_type; // must be 32bit\n\n  MD5();\n  MD5(const std::string& text);\n  void update(const unsigned char *buf, size_type length);\n  void update(const char *buf, size_type length);\n  MD5& finalize();\n  std::string hexdigest() const;\n  friend std::ostream& operator<<(std::ostream&, MD5 md5);\n  std::string binarydigest() const {return std::string(reinterpret_cast<const char*>(digest), 16);} //Ian Copland, 09/06/2014: added accessor for the raw digest.\n    \nprivate:\n  void init();\n  typedef unsigned char uint1; //  8bit\n  typedef unsigned int uint4;  // 32bit\n  enum {blocksize = 64}; // VC6 won't eat a const static int here\n\n  void transform(const uint1 block[blocksize]);\n  static void decode(uint4 output[], const uint1 input[], size_type len);\n  static void encode(uint1 output[], const uint4 input[], size_type len);\n\n  bool finalized;\n  uint1 buffer[blocksize]; // bytes that didn't fit in last 64 byte chunk\n  uint4 count[2];   // 64bit counter for number of bits (lo, hi)\n  uint4 state[4];   // digest so far\n  uint1 digest[16]; // the result\n\n  // low level logic operations\n  static inline uint4 F(uint4 x, uint4 y, uint4 z);\n  static inline uint4 G(uint4 x, uint4 y, uint4 z);\n  static inline uint4 H(uint4 x, uint4 y, uint4 z);\n  static inline uint4 I(uint4 x, uint4 y, uint4 z);\n  static inline uint4 rotate_left(uint4 x, int n);\n  static inline void FF(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac);\n  static inline void GG(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac);\n  static inline void HH(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac);\n  static inline void II(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac);\n};\n\nstd::string md5(const std::string str);\n\n#endif\n"
  },
  {
    "path": "Projects/Libraries/CSBase/Source/minizip/crypt.h",
    "content": "/* crypt.h -- base code for crypt/uncrypt ZIPfile\n\n\n   Version 1.01e, February 12th, 2005\n\n   Copyright (C) 1998-2005 Gilles Vollant\n\n   This code is a modified version of crypting code in Infozip distribution\n\n   The encryption/decryption parts of this source code (as opposed to the\n   non-echoing password parts) were originally written in Europe.  The\n   whole source package can be freely distributed, including from the USA.\n   (Prior to January 2000, re-export from the US was a violation of US law.)\n\n   This encryption code is a direct transcription of the algorithm from\n   Roger Schlafly, described by Phil Katz in the file appnote.txt.  This\n   file (appnote.txt) is distributed with the PKZIP program (even in the\n   version without encryption capabilities).\n\n   If you don't need crypting in your application, just define symbols\n   NOCRYPT and NOUNCRYPT.\n\n   This code support the \"Traditional PKWARE Encryption\".\n\n   The new AES encryption added on Zip format by Winzip (see the page\n   http://www.winzip.com/aes_info.htm ) and PKWare PKZip 5.x Strong\n   Encryption is not supported.\n*/\n\n#define CRC32(c, b) ((*(pcrc_32_tab+(((int)(c) ^ (b)) & 0xff))) ^ ((c) >> 8))\n\n/***********************************************************************\n * Return the next byte in the pseudo-random sequence\n */\nstatic int decrypt_byte(unsigned long* pkeys, const unsigned long* pcrc_32_tab)\n{\n    unsigned temp;  /* POTENTIAL BUG:  temp*(temp^1) may overflow in an\n                     * unpredictable manner on 16-bit systems; not a problem\n                     * with any known compiler so far, though */\n\n    temp = ((unsigned)(*(pkeys+2)) & 0xffff) | 2;\n    return (int)(((temp * (temp ^ 1)) >> 8) & 0xff);\n}\n\n/***********************************************************************\n * Update the encryption keys with the next byte of plain text\n */\nstatic int update_keys(unsigned long* pkeys,const unsigned long* pcrc_32_tab,int c)\n{\n    (*(pkeys+0)) = CRC32((*(pkeys+0)), c);\n    (*(pkeys+1)) += (*(pkeys+0)) & 0xff;\n    (*(pkeys+1)) = (*(pkeys+1)) * 134775813L + 1;\n    {\n      register int keyshift = (int)((*(pkeys+1)) >> 24);\n      (*(pkeys+2)) = CRC32((*(pkeys+2)), keyshift);\n    }\n    return c;\n}\n\n\n/***********************************************************************\n * Initialize the encryption keys and the random header according to\n * the given password.\n */\nstatic void init_keys(const char* passwd,unsigned long* pkeys,const unsigned long* pcrc_32_tab)\n{\n    *(pkeys+0) = 305419896L;\n    *(pkeys+1) = 591751049L;\n    *(pkeys+2) = 878082192L;\n    while (*passwd != '\\0') {\n        update_keys(pkeys,pcrc_32_tab,(int)*passwd);\n        passwd++;\n    }\n}\n\n#define zdecode(pkeys,pcrc_32_tab,c) \\\n    (update_keys(pkeys,pcrc_32_tab,c ^= decrypt_byte(pkeys,pcrc_32_tab)))\n\n#define zencode(pkeys,pcrc_32_tab,c,t) \\\n    (t=decrypt_byte(pkeys,pcrc_32_tab), update_keys(pkeys,pcrc_32_tab,c), t^(c))\n\n#ifdef INCLUDECRYPTINGCODE_IFCRYPTALLOWED\n\n#define RAND_HEAD_LEN  12\n   /* \"last resort\" source for second part of crypt seed pattern */\n#  ifndef ZCR_SEED2\n#    define ZCR_SEED2 3141592654UL     /* use PI as default pattern */\n#  endif\n\nstatic int crypthead(const char* passwd,      /* password string */\n                     unsigned char* buf,      /* where to write header */\n                     int bufSize,\n                     unsigned long* pkeys,\n                     const unsigned long* pcrc_32_tab,\n                     unsigned long crcForCrypting)\n{\n    int n;                       /* index in random header */\n    int t;                       /* temporary */\n    int c;                       /* random byte */\n    unsigned char header[RAND_HEAD_LEN-2]; /* random header */\n    static unsigned calls = 0;   /* ensure different random header each time */\n\n    if (bufSize<RAND_HEAD_LEN)\n      return 0;\n\n    /* First generate RAND_HEAD_LEN-2 random bytes. We encrypt the\n     * output of rand() to get less predictability, since rand() is\n     * often poorly implemented.\n     */\n    if (++calls == 1)\n    {\n        srand((unsigned)(time(NULL) ^ ZCR_SEED2));\n    }\n    init_keys(passwd, pkeys, pcrc_32_tab);\n    for (n = 0; n < RAND_HEAD_LEN-2; n++)\n    {\n        c = (rand() >> 7) & 0xff;\n        header[n] = (unsigned char)zencode(pkeys, pcrc_32_tab, c, t);\n    }\n    /* Encrypt random header (last two bytes is high word of crc) */\n    init_keys(passwd, pkeys, pcrc_32_tab);\n    for (n = 0; n < RAND_HEAD_LEN-2; n++)\n    {\n        buf[n] = (unsigned char)zencode(pkeys, pcrc_32_tab, header[n], t);\n    }\n    buf[n++] = (unsigned char)zencode(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 16) & 0xff, t);\n    buf[n++] = (unsigned char)zencode(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 24) & 0xff, t);\n    return n;\n}\n\n#endif\n"
  },
  {
    "path": "Projects/Libraries/CSBase/Source/minizip/ioapi.c",
    "content": "/* ioapi.h -- IO base function header for compress/uncompress .zip\n   part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )\n\n         Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html )\n\n         Modifications for Zip64 support\n         Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )\n\n         For more info read MiniZip_info.txt\n\n*/\n\n#if (defined(_WIN32))\n        #define _CRT_SECURE_NO_WARNINGS\n#endif\n\n#include \"ioapi.h\"\n\nvoidpf call_zopen64 (const zlib_filefunc64_32_def* pfilefunc,const void*filename,int mode)\n{\n    if (pfilefunc->zfile_func64.zopen64_file != NULL)\n        return (*(pfilefunc->zfile_func64.zopen64_file)) (pfilefunc->zfile_func64.opaque,filename,mode);\n    else\n    {\n        return (*(pfilefunc->zopen32_file))(pfilefunc->zfile_func64.opaque,(const char*)filename,mode);\n    }\n}\n\nlong call_zseek64 (const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZPOS64_T offset, int origin)\n{\n    if (pfilefunc->zfile_func64.zseek64_file != NULL)\n        return (*(pfilefunc->zfile_func64.zseek64_file)) (pfilefunc->zfile_func64.opaque,filestream,offset,origin);\n    else\n    {\n        uLong offsetTruncated = (uLong)offset;\n        if (offsetTruncated != offset)\n            return -1;\n        else\n            return (*(pfilefunc->zseek32_file))(pfilefunc->zfile_func64.opaque,filestream,offsetTruncated,origin);\n    }\n}\n\nZPOS64_T call_ztell64 (const zlib_filefunc64_32_def* pfilefunc,voidpf filestream)\n{\n    if (pfilefunc->zfile_func64.zseek64_file != NULL)\n        return (*(pfilefunc->zfile_func64.ztell64_file)) (pfilefunc->zfile_func64.opaque,filestream);\n    else\n    {\n        uLong tell_uLong = (*(pfilefunc->ztell32_file))(pfilefunc->zfile_func64.opaque,filestream);\n        if ((tell_uLong) == ((uLong)-1))\n            return (ZPOS64_T)-1;\n        else\n            return tell_uLong;\n    }\n}\n\nvoid fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filefunc64_32,const zlib_filefunc_def* p_filefunc32)\n{\n    p_filefunc64_32->zfile_func64.zopen64_file = NULL;\n    p_filefunc64_32->zopen32_file = p_filefunc32->zopen_file;\n    p_filefunc64_32->zfile_func64.zerror_file = p_filefunc32->zerror_file;\n    p_filefunc64_32->zfile_func64.zread_file = p_filefunc32->zread_file;\n    p_filefunc64_32->zfile_func64.zwrite_file = p_filefunc32->zwrite_file;\n    p_filefunc64_32->zfile_func64.ztell64_file = NULL;\n    p_filefunc64_32->zfile_func64.zseek64_file = NULL;\n    p_filefunc64_32->zfile_func64.zclose_file = p_filefunc32->zclose_file;\n    p_filefunc64_32->zfile_func64.zerror_file = p_filefunc32->zerror_file;\n    p_filefunc64_32->zfile_func64.opaque = p_filefunc32->opaque;\n    p_filefunc64_32->zseek32_file = p_filefunc32->zseek_file;\n    p_filefunc64_32->ztell32_file = p_filefunc32->ztell_file;\n}\n\n\n\nstatic voidpf  ZCALLBACK fopen_file_func OF((voidpf opaque, const char* filename, int mode));\nstatic uLong   ZCALLBACK fread_file_func OF((voidpf opaque, voidpf stream, void* buf, uLong size));\nstatic uLong   ZCALLBACK fwrite_file_func OF((voidpf opaque, voidpf stream, const void* buf,uLong size));\nstatic ZPOS64_T ZCALLBACK ftell64_file_func OF((voidpf opaque, voidpf stream));\nstatic long    ZCALLBACK fseek64_file_func OF((voidpf opaque, voidpf stream, ZPOS64_T offset, int origin));\nstatic int     ZCALLBACK fclose_file_func OF((voidpf opaque, voidpf stream));\nstatic int     ZCALLBACK ferror_file_func OF((voidpf opaque, voidpf stream));\n\nstatic voidpf ZCALLBACK fopen_file_func (voidpf opaque, const char* filename, int mode)\n{\n    FILE* file = NULL;\n    const char* mode_fopen = NULL;\n    if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ)\n        mode_fopen = \"rb\";\n    else\n    if (mode & ZLIB_FILEFUNC_MODE_EXISTING)\n        mode_fopen = \"r+b\";\n    else\n    if (mode & ZLIB_FILEFUNC_MODE_CREATE)\n        mode_fopen = \"wb\";\n\n    if ((filename!=NULL) && (mode_fopen != NULL))\n        file = fopen(filename, mode_fopen);\n    return file;\n}\n\nstatic voidpf ZCALLBACK fopen64_file_func (voidpf opaque, const void* filename, int mode)\n{\n    FILE* file = NULL;\n    const char* mode_fopen = NULL;\n    if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ)\n        mode_fopen = \"rb\";\n    else\n    if (mode & ZLIB_FILEFUNC_MODE_EXISTING)\n        mode_fopen = \"r+b\";\n    else\n    if (mode & ZLIB_FILEFUNC_MODE_CREATE)\n        mode_fopen = \"wb\";\n\n    if ((filename!=NULL) && (mode_fopen != NULL))\n        file = fopen64((const char*)filename, mode_fopen);\n    return file;\n}\n\n\nstatic uLong ZCALLBACK fread_file_func (voidpf opaque, voidpf stream, void* buf, uLong size)\n{\n    uLong ret;\n    ret = (uLong)fread(buf, 1, (size_t)size, (FILE *)stream);\n    return ret;\n}\n\nstatic uLong ZCALLBACK fwrite_file_func (voidpf opaque, voidpf stream, const void* buf, uLong size)\n{\n    uLong ret;\n    ret = (uLong)fwrite(buf, 1, (size_t)size, (FILE *)stream);\n    return ret;\n}\n\nstatic long ZCALLBACK ftell_file_func (voidpf opaque, voidpf stream)\n{\n    long ret;\n    ret = ftell((FILE *)stream);\n    return ret;\n}\n\n\nstatic ZPOS64_T ZCALLBACK ftell64_file_func (voidpf opaque, voidpf stream)\n{\n    ZPOS64_T ret;\n    ret = ftello64((FILE *)stream);\n    return ret;\n}\n\nstatic long ZCALLBACK fseek_file_func (voidpf  opaque, voidpf stream, uLong offset, int origin)\n{\n    int fseek_origin=0;\n    long ret;\n    switch (origin)\n    {\n    case ZLIB_FILEFUNC_SEEK_CUR :\n        fseek_origin = SEEK_CUR;\n        break;\n    case ZLIB_FILEFUNC_SEEK_END :\n        fseek_origin = SEEK_END;\n        break;\n    case ZLIB_FILEFUNC_SEEK_SET :\n        fseek_origin = SEEK_SET;\n        break;\n    default: return -1;\n    }\n    ret = 0;\n    if (fseek((FILE *)stream, offset, fseek_origin) != 0)\n        ret = -1;\n    return ret;\n}\n\nstatic long ZCALLBACK fseek64_file_func (voidpf  opaque, voidpf stream, ZPOS64_T offset, int origin)\n{\n    int fseek_origin=0;\n    long ret;\n    switch (origin)\n    {\n    case ZLIB_FILEFUNC_SEEK_CUR :\n        fseek_origin = SEEK_CUR;\n        break;\n    case ZLIB_FILEFUNC_SEEK_END :\n        fseek_origin = SEEK_END;\n        break;\n    case ZLIB_FILEFUNC_SEEK_SET :\n        fseek_origin = SEEK_SET;\n        break;\n    default: return -1;\n    }\n    ret = 0;\n\n    if(fseeko64((FILE *)stream, offset, fseek_origin) != 0)\n                        ret = -1;\n\n    return ret;\n}\n\n\nstatic int ZCALLBACK fclose_file_func (voidpf opaque, voidpf stream)\n{\n    int ret;\n    ret = fclose((FILE *)stream);\n    return ret;\n}\n\nstatic int ZCALLBACK ferror_file_func (voidpf opaque, voidpf stream)\n{\n    int ret;\n    ret = ferror((FILE *)stream);\n    return ret;\n}\n\nvoid fill_fopen_filefunc (pzlib_filefunc_def)\n  zlib_filefunc_def* pzlib_filefunc_def;\n{\n    pzlib_filefunc_def->zopen_file = fopen_file_func;\n    pzlib_filefunc_def->zread_file = fread_file_func;\n    pzlib_filefunc_def->zwrite_file = fwrite_file_func;\n    pzlib_filefunc_def->ztell_file = ftell_file_func;\n    pzlib_filefunc_def->zseek_file = fseek_file_func;\n    pzlib_filefunc_def->zclose_file = fclose_file_func;\n    pzlib_filefunc_def->zerror_file = ferror_file_func;\n    pzlib_filefunc_def->opaque = NULL;\n}\n\nvoid fill_fopen64_filefunc (zlib_filefunc64_def*  pzlib_filefunc_def)\n{\n    pzlib_filefunc_def->zopen64_file = fopen64_file_func;\n    pzlib_filefunc_def->zread_file = fread_file_func;\n    pzlib_filefunc_def->zwrite_file = fwrite_file_func;\n    pzlib_filefunc_def->ztell64_file = ftell64_file_func;\n    pzlib_filefunc_def->zseek64_file = fseek64_file_func;\n    pzlib_filefunc_def->zclose_file = fclose_file_func;\n    pzlib_filefunc_def->zerror_file = ferror_file_func;\n    pzlib_filefunc_def->opaque = NULL;\n}\n"
  },
  {
    "path": "Projects/Libraries/CSBase/Source/minizip/ioapi.h",
    "content": "/* ioapi.h -- IO base function header for compress/uncompress .zip\n   part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )\n\n         Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html )\n\n         Modifications for Zip64 support\n         Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )\n\n         For more info read MiniZip_info.txt\n\n         Changes\n\n    Oct-2009 - Defined ZPOS64_T to fpos_t on windows and u_int64_t on linux. (might need to find a better why for this)\n    Oct-2009 - Change to fseeko64, ftello64 and fopen64 so large files would work on linux.\n               More if/def section may be needed to support other platforms\n    Oct-2009 - Defined fxxxx64 calls to normal fopen/ftell/fseek so they would compile on windows.\n                          (but you should use iowin32.c for windows instead)\n\n*/\n\n#ifndef _ZLIBIOAPI64_H\n#define _ZLIBIOAPI64_H\n\n#if (!defined(_WIN32)) && (!defined(WIN32))\n\n  // Linux needs this to support file operation on files larger then 4+GB\n  // But might need better if/def to select just the platforms that needs them.\n\n        #ifndef __USE_FILE_OFFSET64\n                #define __USE_FILE_OFFSET64\n        #endif\n        #ifndef __USE_LARGEFILE64\n                #define __USE_LARGEFILE64\n        #endif\n        #ifndef _LARGEFILE64_SOURCE\n                #define _LARGEFILE64_SOURCE\n        #endif\n        #ifndef _FILE_OFFSET_BIT\n                #define _FILE_OFFSET_BIT 64\n        #endif\n#endif\n\n#include <stdio.h>\n#include <stdlib.h>\n#include \"zlib.h\"\n\n#if defined(USE_FILE32API)\n#define fopen64 fopen\n#define ftello64 ftell\n#define fseeko64 fseek\n#else\n#ifdef _MSC_VER\n #define fopen64 fopen\n #if (_MSC_VER >= 1400) && (!(defined(NO_MSCVER_FILE64_FUNC)))\n  #define ftello64 _ftelli64\n  #define fseeko64 _fseeki64\n #else // old MSC\n  #define ftello64 ftell\n  #define fseeko64 fseek\n #endif\n#endif\n#endif\n\n/*\n#ifndef ZPOS64_T\n  #ifdef _WIN32\n                #define ZPOS64_T fpos_t\n  #else\n    #include <stdint.h>\n    #define ZPOS64_T uint64_t\n  #endif\n#endif\n*/\n\n#ifdef HAVE_MINIZIP64_CONF_H\n#include \"mz64conf.h\"\n#endif\n\n/* a type choosen by DEFINE */\n#ifdef HAVE_64BIT_INT_CUSTOM\ntypedef  64BIT_INT_CUSTOM_TYPE ZPOS64_T;\n#else\n#ifdef HAS_STDINT_H\n#include \"stdint.h\"\ntypedef uint64_t ZPOS64_T;\n#else\n\n\n#if defined(_MSC_VER) || defined(__BORLANDC__)\ntypedef unsigned __int64 ZPOS64_T;\n#else\ntypedef unsigned long long int ZPOS64_T;\n#endif\n#endif\n#endif\n\n\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n\n#define ZLIB_FILEFUNC_SEEK_CUR (1)\n#define ZLIB_FILEFUNC_SEEK_END (2)\n#define ZLIB_FILEFUNC_SEEK_SET (0)\n\n#define ZLIB_FILEFUNC_MODE_READ      (1)\n#define ZLIB_FILEFUNC_MODE_WRITE     (2)\n#define ZLIB_FILEFUNC_MODE_READWRITEFILTER (3)\n\n#define ZLIB_FILEFUNC_MODE_EXISTING (4)\n#define ZLIB_FILEFUNC_MODE_CREATE   (8)\n\n\n#ifndef ZCALLBACK\n #if (defined(WIN32) || defined(_WIN32) || defined (WINDOWS) || defined (_WINDOWS)) && defined(CALLBACK) && defined (USEWINDOWS_CALLBACK)\n   #define ZCALLBACK CALLBACK\n #else\n   #define ZCALLBACK\n #endif\n#endif\n\n\n\n\ntypedef voidpf   (ZCALLBACK *open_file_func)      OF((voidpf opaque, const char* filename, int mode));\ntypedef uLong    (ZCALLBACK *read_file_func)      OF((voidpf opaque, voidpf stream, void* buf, uLong size));\ntypedef uLong    (ZCALLBACK *write_file_func)     OF((voidpf opaque, voidpf stream, const void* buf, uLong size));\ntypedef int      (ZCALLBACK *close_file_func)     OF((voidpf opaque, voidpf stream));\ntypedef int      (ZCALLBACK *testerror_file_func) OF((voidpf opaque, voidpf stream));\n\ntypedef long     (ZCALLBACK *tell_file_func)      OF((voidpf opaque, voidpf stream));\ntypedef long     (ZCALLBACK *seek_file_func)      OF((voidpf opaque, voidpf stream, uLong offset, int origin));\n\n\n/* here is the \"old\" 32 bits structure structure */\ntypedef struct zlib_filefunc_def_s\n{\n    open_file_func      zopen_file;\n    read_file_func      zread_file;\n    write_file_func     zwrite_file;\n    tell_file_func      ztell_file;\n    seek_file_func      zseek_file;\n    close_file_func     zclose_file;\n    testerror_file_func zerror_file;\n    voidpf              opaque;\n} zlib_filefunc_def;\n\ntypedef ZPOS64_T (ZCALLBACK *tell64_file_func)    OF((voidpf opaque, voidpf stream));\ntypedef long     (ZCALLBACK *seek64_file_func)    OF((voidpf opaque, voidpf stream, ZPOS64_T offset, int origin));\ntypedef voidpf   (ZCALLBACK *open64_file_func)    OF((voidpf opaque, const void* filename, int mode));\n\ntypedef struct zlib_filefunc64_def_s\n{\n    open64_file_func    zopen64_file;\n    read_file_func      zread_file;\n    write_file_func     zwrite_file;\n    tell64_file_func    ztell64_file;\n    seek64_file_func    zseek64_file;\n    close_file_func     zclose_file;\n    testerror_file_func zerror_file;\n    voidpf              opaque;\n} zlib_filefunc64_def;\n\nvoid fill_fopen64_filefunc OF((zlib_filefunc64_def* pzlib_filefunc_def));\nvoid fill_fopen_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def));\n\n/* now internal definition, only for zip.c and unzip.h */\ntypedef struct zlib_filefunc64_32_def_s\n{\n    zlib_filefunc64_def zfile_func64;\n    open_file_func      zopen32_file;\n    tell_file_func      ztell32_file;\n    seek_file_func      zseek32_file;\n} zlib_filefunc64_32_def;\n\n\n#define ZREAD64(filefunc,filestream,buf,size)     ((*((filefunc).zfile_func64.zread_file))   ((filefunc).zfile_func64.opaque,filestream,buf,size))\n#define ZWRITE64(filefunc,filestream,buf,size)    ((*((filefunc).zfile_func64.zwrite_file))  ((filefunc).zfile_func64.opaque,filestream,buf,size))\n//#define ZTELL64(filefunc,filestream)            ((*((filefunc).ztell64_file)) ((filefunc).opaque,filestream))\n//#define ZSEEK64(filefunc,filestream,pos,mode)   ((*((filefunc).zseek64_file)) ((filefunc).opaque,filestream,pos,mode))\n#define ZCLOSE64(filefunc,filestream)             ((*((filefunc).zfile_func64.zclose_file))  ((filefunc).zfile_func64.opaque,filestream))\n#define ZERROR64(filefunc,filestream)             ((*((filefunc).zfile_func64.zerror_file))  ((filefunc).zfile_func64.opaque,filestream))\n\nvoidpf call_zopen64 OF((const zlib_filefunc64_32_def* pfilefunc,const void*filename,int mode));\nlong    call_zseek64 OF((const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZPOS64_T offset, int origin));\nZPOS64_T call_ztell64 OF((const zlib_filefunc64_32_def* pfilefunc,voidpf filestream));\n\nvoid    fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filefunc64_32,const zlib_filefunc_def* p_filefunc32);\n\n#define ZOPEN64(filefunc,filename,mode)         (call_zopen64((&(filefunc)),(filename),(mode)))\n#define ZTELL64(filefunc,filestream)            (call_ztell64((&(filefunc)),(filestream)))\n#define ZSEEK64(filefunc,filestream,pos,mode)   (call_zseek64((&(filefunc)),(filestream),(pos),(mode)))\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "Projects/Libraries/CSBase/Source/minizip/mztools.c",
    "content": "/*\n  Additional tools for Minizip\n  Code: Xavier Roche '2004\n  License: Same as ZLIB (www.gzip.org)\n*/\n\n/* Code */\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include \"zlib.h\"\n#include \"unzip.h\"\n\n#define READ_8(adr)  ((unsigned char)*(adr))\n#define READ_16(adr) ( READ_8(adr) | (READ_8(adr+1) << 8) )\n#define READ_32(adr) ( READ_16(adr) | (READ_16((adr)+2) << 16) )\n\n#define WRITE_8(buff, n) do { \\\n  *((unsigned char*)(buff)) = (unsigned char) ((n) & 0xff); \\\n} while(0)\n#define WRITE_16(buff, n) do { \\\n  WRITE_8((unsigned char*)(buff), n); \\\n  WRITE_8(((unsigned char*)(buff)) + 1, (n) >> 8); \\\n} while(0)\n#define WRITE_32(buff, n) do { \\\n  WRITE_16((unsigned char*)(buff), (n) & 0xffff); \\\n  WRITE_16((unsigned char*)(buff) + 2, (n) >> 16); \\\n} while(0)\n\nextern int ZEXPORT unzRepair(file, fileOut, fileOutTmp, nRecovered, bytesRecovered)\nconst char* file;\nconst char* fileOut;\nconst char* fileOutTmp;\nuLong* nRecovered;\nuLong* bytesRecovered;\n{\n  int err = Z_OK;\n  FILE* fpZip = fopen(file, \"rb\");\n  FILE* fpOut = fopen(fileOut, \"wb\");\n  FILE* fpOutCD = fopen(fileOutTmp, \"wb\");\n  if (fpZip != NULL &&  fpOut != NULL) {\n    int entries = 0;\n    uLong totalBytes = 0;\n    char header[30];\n    char filename[256];\n    char extra[1024];\n    int offset = 0;\n    int offsetCD = 0;\n    while ( fread(header, 1, 30, fpZip) == 30 ) {\n      int currentOffset = offset;\n\n      /* File entry */\n      if (READ_32(header) == 0x04034b50) {\n        unsigned int version = READ_16(header + 4);\n        unsigned int gpflag = READ_16(header + 6);\n        unsigned int method = READ_16(header + 8);\n        unsigned int filetime = READ_16(header + 10);\n        unsigned int filedate = READ_16(header + 12);\n        unsigned int crc = READ_32(header + 14); /* crc */\n        unsigned int cpsize = READ_32(header + 18); /* compressed size */\n        unsigned int uncpsize = READ_32(header + 22); /* uncompressed sz */\n        unsigned int fnsize = READ_16(header + 26); /* file name length */\n        unsigned int extsize = READ_16(header + 28); /* extra field length */\n        filename[0] = extra[0] = '\\0';\n\n        /* Header */\n        if (fwrite(header, 1, 30, fpOut) == 30) {\n          offset += 30;\n        } else {\n          err = Z_ERRNO;\n          break;\n        }\n\n        /* Filename */\n        if (fnsize > 0) {\n          if (fread(filename, 1, fnsize, fpZip) == fnsize) {\n            if (fwrite(filename, 1, fnsize, fpOut) == fnsize) {\n              offset += fnsize;\n            } else {\n              err = Z_ERRNO;\n              break;\n            }\n          } else {\n            err = Z_ERRNO;\n            break;\n          }\n        } else {\n          err = Z_STREAM_ERROR;\n          break;\n        }\n\n        /* Extra field */\n        if (extsize > 0) {\n          if (fread(extra, 1, extsize, fpZip) == extsize) {\n            if (fwrite(extra, 1, extsize, fpOut) == extsize) {\n              offset += extsize;\n            } else {\n              err = Z_ERRNO;\n              break;\n            }\n          } else {\n            err = Z_ERRNO;\n            break;\n          }\n        }\n\n        /* Data */\n        {\n          int dataSize = cpsize;\n          if (dataSize == 0) {\n            dataSize = uncpsize;\n          }\n          if (dataSize > 0) {\n            char* data = malloc(dataSize);\n            if (data != NULL) {\n              if ((int)fread(data, 1, dataSize, fpZip) == dataSize) {\n                if ((int)fwrite(data, 1, dataSize, fpOut) == dataSize) {\n                  offset += dataSize;\n                  totalBytes += dataSize;\n                } else {\n                  err = Z_ERRNO;\n                }\n              } else {\n                err = Z_ERRNO;\n              }\n              free(data);\n              if (err != Z_OK) {\n                break;\n              }\n            } else {\n              err = Z_MEM_ERROR;\n              break;\n            }\n          }\n        }\n\n        /* Central directory entry */\n        {\n          char header[46];\n          char* comment = \"\";\n          int comsize = (int) strlen(comment);\n          WRITE_32(header, 0x02014b50);\n          WRITE_16(header + 4, version);\n          WRITE_16(header + 6, version);\n          WRITE_16(header + 8, gpflag);\n          WRITE_16(header + 10, method);\n          WRITE_16(header + 12, filetime);\n          WRITE_16(header + 14, filedate);\n          WRITE_32(header + 16, crc);\n          WRITE_32(header + 20, cpsize);\n          WRITE_32(header + 24, uncpsize);\n          WRITE_16(header + 28, fnsize);\n          WRITE_16(header + 30, extsize);\n          WRITE_16(header + 32, comsize);\n          WRITE_16(header + 34, 0);     /* disk # */\n          WRITE_16(header + 36, 0);     /* int attrb */\n          WRITE_32(header + 38, 0);     /* ext attrb */\n          WRITE_32(header + 42, currentOffset);\n          /* Header */\n          if (fwrite(header, 1, 46, fpOutCD) == 46) {\n            offsetCD += 46;\n\n            /* Filename */\n            if (fnsize > 0) {\n              if (fwrite(filename, 1, fnsize, fpOutCD) == fnsize) {\n                offsetCD += fnsize;\n              } else {\n                err = Z_ERRNO;\n                break;\n              }\n            } else {\n              err = Z_STREAM_ERROR;\n              break;\n            }\n\n            /* Extra field */\n            if (extsize > 0) {\n              if (fwrite(extra, 1, extsize, fpOutCD) == extsize) {\n                offsetCD += extsize;\n              } else {\n                err = Z_ERRNO;\n                break;\n              }\n            }\n\n            /* Comment field */\n            if (comsize > 0) {\n              if ((int)fwrite(comment, 1, comsize, fpOutCD) == comsize) {\n                offsetCD += comsize;\n              } else {\n                err = Z_ERRNO;\n                break;\n              }\n            }\n\n\n          } else {\n            err = Z_ERRNO;\n            break;\n          }\n        }\n\n        /* Success */\n        entries++;\n\n      } else {\n        break;\n      }\n    }\n\n    /* Final central directory  */\n    {\n      int entriesZip = entries;\n      char header[22];\n      char* comment = \"\"; // \"ZIP File recovered by zlib/minizip/mztools\";\n      int comsize = (int) strlen(comment);\n      if (entriesZip > 0xffff) {\n        entriesZip = 0xffff;\n      }\n      WRITE_32(header, 0x06054b50);\n      WRITE_16(header + 4, 0);    /* disk # */\n      WRITE_16(header + 6, 0);    /* disk # */\n      WRITE_16(header + 8, entriesZip);   /* hack */\n      WRITE_16(header + 10, entriesZip);  /* hack */\n      WRITE_32(header + 12, offsetCD);    /* size of CD */\n      WRITE_32(header + 16, offset);      /* offset to CD */\n      WRITE_16(header + 20, comsize);     /* comment */\n\n      /* Header */\n      if (fwrite(header, 1, 22, fpOutCD) == 22) {\n\n        /* Comment field */\n        if (comsize > 0) {\n          if ((int)fwrite(comment, 1, comsize, fpOutCD) != comsize) {\n            err = Z_ERRNO;\n          }\n        }\n\n      } else {\n        err = Z_ERRNO;\n      }\n    }\n\n    /* Final merge (file + central directory) */\n    fclose(fpOutCD);\n    if (err == Z_OK) {\n      fpOutCD = fopen(fileOutTmp, \"rb\");\n      if (fpOutCD != NULL) {\n        int nRead;\n        char buffer[8192];\n        while ( (nRead = (int)fread(buffer, 1, sizeof(buffer), fpOutCD)) > 0) {\n          if ((int)fwrite(buffer, 1, nRead, fpOut) != nRead) {\n            err = Z_ERRNO;\n            break;\n          }\n        }\n        fclose(fpOutCD);\n      }\n    }\n\n    /* Close */\n    fclose(fpZip);\n    fclose(fpOut);\n\n    /* Wipe temporary file */\n    (void)remove(fileOutTmp);\n\n    /* Number of recovered entries */\n    if (err == Z_OK) {\n      if (nRecovered != NULL) {\n        *nRecovered = entries;\n      }\n      if (bytesRecovered != NULL) {\n        *bytesRecovered = totalBytes;\n      }\n    }\n  } else {\n    err = Z_STREAM_ERROR;\n  }\n  return err;\n}\n"
  },
  {
    "path": "Projects/Libraries/CSBase/Source/minizip/mztools.h",
    "content": "/*\n  Additional tools for Minizip\n  Code: Xavier Roche '2004\n  License: Same as ZLIB (www.gzip.org)\n*/\n\n#ifndef _zip_tools_H\n#define _zip_tools_H\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#ifndef _ZLIB_H\n#include \"zlib.h\"\n#endif\n\n#include \"unzip.h\"\n\n/* Repair a ZIP file (missing central directory)\n   file: file to recover\n   fileOut: output file after recovery\n   fileOutTmp: temporary file name used for recovery\n*/\nextern int ZEXPORT unzRepair(const char* file,\n                             const char* fileOut,\n                             const char* fileOutTmp,\n                             uLong* nRecovered,\n                             uLong* bytesRecovered);\n\n#endif\n"
  },
  {
    "path": "Projects/Libraries/CSBase/Source/minizip/unzip.c",
    "content": "/* unzip.c -- IO for uncompress .zip files using zlib\n   Version 1.1, February 14h, 2010\n   part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )\n\n         Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html )\n\n         Modifications of Unzip for Zip64\n         Copyright (C) 2007-2008 Even Rouault\n\n         Modifications for Zip64 support on both zip and unzip\n         Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )\n\n         For more info read MiniZip_info.txt\n\n\n  ------------------------------------------------------------------------------------\n  Decryption code comes from crypt.c by Info-ZIP but has been greatly reduced in terms of\n  compatibility with older software. The following is from the original crypt.c.\n  Code woven in by Terry Thorsen 1/2003.\n\n  Copyright (c) 1990-2000 Info-ZIP.  All rights reserved.\n\n  See the accompanying file LICENSE, version 2000-Apr-09 or later\n  (the contents of which are also included in zip.h) for terms of use.\n  If, for some reason, all these files are missing, the Info-ZIP license\n  also may be found at:  ftp://ftp.info-zip.org/pub/infozip/license.html\n\n        crypt.c (full version) by Info-ZIP.      Last revised:  [see crypt.h]\n\n  The encryption/decryption parts of this source code (as opposed to the\n  non-echoing password parts) were originally written in Europe.  The\n  whole source package can be freely distributed, including from the USA.\n  (Prior to January 2000, re-export from the US was a violation of US law.)\n\n        This encryption code is a direct transcription of the algorithm from\n  Roger Schlafly, described by Phil Katz in the file appnote.txt.  This\n  file (appnote.txt) is distributed with the PKZIP program (even in the\n  version without encryption capabilities).\n\n        ------------------------------------------------------------------------------------\n\n        Changes in unzip.c\n\n        2007-2008 - Even Rouault - Addition of cpl_unzGetCurrentFileZStreamPos\n  2007-2008 - Even Rouault - Decoration of symbol names unz* -> cpl_unz*\n  2007-2008 - Even Rouault - Remove old C style function prototypes\n  2007-2008 - Even Rouault - Add unzip support for ZIP64\n\n        Copyright (C) 2007-2008 Even Rouault\n\n\n        Oct-2009 - Mathias Svensson - Removed cpl_* from symbol names (Even Rouault added them but since this is now moved to a new project (minizip64) I renamed them again).\n  Oct-2009 - Mathias Svensson - Fixed problem if uncompressed size was > 4G and compressed size was <4G\n                                should only read the compressed/uncompressed size from the Zip64 format if\n                                the size from normal header was 0xFFFFFFFF\n  Oct-2009 - Mathias Svensson - Applied some bug fixes from paches recived from Gilles Vollant\n        Oct-2009 - Mathias Svensson - Applied support to unzip files with compression mathod BZIP2 (bzip2 lib is required)\n                                Patch created by Daniel Borca\n\n  Jan-2010 - back to unzip and minizip 1.0 name scheme, with compatibility layer\n\n  Copyright (C) 1998 - 2010 Gilles Vollant, Even Rouault, Mathias Svensson\n\n*/\n\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n\n#ifndef NOUNCRYPT\n        #define NOUNCRYPT\n#endif\n\n#include \"zlib.h\"\n#include \"unzip.h\"\n\n#ifdef STDC\n#  include <stddef.h>\n#  include <string.h>\n#  include <stdlib.h>\n#endif\n#ifdef NO_ERRNO_H\n    extern int errno;\n#else\n#   include <errno.h>\n#endif\n\n\n#ifndef local\n#  define local static\n#endif\n/* compile with -Dlocal if your debugger can't find static symbols */\n\n\n#ifndef CASESENSITIVITYDEFAULT_NO\n#  if !defined(unix) && !defined(CASESENSITIVITYDEFAULT_YES)\n#    define CASESENSITIVITYDEFAULT_NO\n#  endif\n#endif\n\n\n#ifndef UNZ_BUFSIZE\n#define UNZ_BUFSIZE (16384)\n#endif\n\n#ifndef UNZ_MAXFILENAMEINZIP\n#define UNZ_MAXFILENAMEINZIP (256)\n#endif\n\n#ifndef ALLOC\n# define ALLOC(size) (malloc(size))\n#endif\n#ifndef TRYFREE\n# define TRYFREE(p) {if (p) free(p);}\n#endif\n\n#define SIZECENTRALDIRITEM (0x2e)\n#define SIZEZIPLOCALHEADER (0x1e)\n\n\nconst char unz_copyright[] =\n   \" unzip 1.01 Copyright 1998-2004 Gilles Vollant - http://www.winimage.com/zLibDll\";\n\n/* unz_file_info_interntal contain internal info about a file in zipfile*/\ntypedef struct unz_file_info64_internal_s\n{\n    ZPOS64_T offset_curfile;/* relative offset of local header 8 bytes */\n} unz_file_info64_internal;\n\n\n/* file_in_zip_read_info_s contain internal information about a file in zipfile,\n    when reading and decompress it */\ntypedef struct\n{\n    char  *read_buffer;         /* internal buffer for compressed data */\n    z_stream stream;            /* zLib stream structure for inflate */\n\n#ifdef HAVE_BZIP2\n    bz_stream bstream;          /* bzLib stream structure for bziped */\n#endif\n\n    ZPOS64_T pos_in_zipfile;       /* position in byte on the zipfile, for fseek*/\n    uLong stream_initialised;   /* flag set if stream structure is initialised*/\n\n    ZPOS64_T offset_local_extrafield;/* offset of the local extra field */\n    uInt  size_local_extrafield;/* size of the local extra field */\n    ZPOS64_T pos_local_extrafield;   /* position in the local extra field in read*/\n    ZPOS64_T total_out_64;\n\n    uLong crc32;                /* crc32 of all data uncompressed */\n    uLong crc32_wait;           /* crc32 we must obtain after decompress all */\n    ZPOS64_T rest_read_compressed; /* number of byte to be decompressed */\n    ZPOS64_T rest_read_uncompressed;/*number of byte to be obtained after decomp*/\n    zlib_filefunc64_32_def z_filefunc;\n    voidpf filestream;        /* io structore of the zipfile */\n    uLong compression_method;   /* compression method (0==store) */\n    ZPOS64_T byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/\n    int   raw;\n} file_in_zip64_read_info_s;\n\n\n/* unz64_s contain internal information about the zipfile\n*/\ntypedef struct\n{\n    zlib_filefunc64_32_def z_filefunc;\n    int is64bitOpenFunction;\n    voidpf filestream;        /* io structore of the zipfile */\n    unz_global_info64 gi;       /* public global information */\n    ZPOS64_T byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/\n    ZPOS64_T num_file;             /* number of the current file in the zipfile*/\n    ZPOS64_T pos_in_central_dir;   /* pos of the current file in the central dir*/\n    ZPOS64_T current_file_ok;      /* flag about the usability of the current file*/\n    ZPOS64_T central_pos;          /* position of the beginning of the central dir*/\n\n    ZPOS64_T size_central_dir;     /* size of the central directory  */\n    ZPOS64_T offset_central_dir;   /* offset of start of central directory with\n                                   respect to the starting disk number */\n\n    unz_file_info64 cur_file_info; /* public info about the current file in zip*/\n    unz_file_info64_internal cur_file_info_internal; /* private info about it*/\n    file_in_zip64_read_info_s* pfile_in_zip_read; /* structure about the current\n                                        file if we are decompressing it */\n    int encrypted;\n\n    int isZip64;\n\n#    ifndef NOUNCRYPT\n    unsigned long keys[3];     /* keys defining the pseudo-random sequence */\n    const unsigned long* pcrc_32_tab;\n#    endif\n} unz64_s;\n\n\n#ifndef NOUNCRYPT\n#include \"crypt.h\"\n#endif\n\n/* ===========================================================================\n     Read a byte from a gz_stream; update next_in and avail_in. Return EOF\n   for end of file.\n   IN assertion: the stream s has been sucessfully opened for reading.\n*/\n\n\nlocal int unz64local_getByte OF((\n    const zlib_filefunc64_32_def* pzlib_filefunc_def,\n    voidpf filestream,\n    int *pi));\n\nlocal int unz64local_getByte(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, int *pi)\n{\n    unsigned char c;\n    int err = (int)ZREAD64(*pzlib_filefunc_def,filestream,&c,1);\n    if (err==1)\n    {\n        *pi = (int)c;\n        return UNZ_OK;\n    }\n    else\n    {\n        if (ZERROR64(*pzlib_filefunc_def,filestream))\n            return UNZ_ERRNO;\n        else\n            return UNZ_EOF;\n    }\n}\n\n\n/* ===========================================================================\n   Reads a long in LSB order from the given gz_stream. Sets\n*/\nlocal int unz64local_getShort OF((\n    const zlib_filefunc64_32_def* pzlib_filefunc_def,\n    voidpf filestream,\n    uLong *pX));\n\nlocal int unz64local_getShort (const zlib_filefunc64_32_def* pzlib_filefunc_def,\n                             voidpf filestream,\n                             uLong *pX)\n{\n    uLong x ;\n    int i = 0;\n    int err;\n\n    err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);\n    x = (uLong)i;\n\n    if (err==UNZ_OK)\n        err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);\n    x |= ((uLong)i)<<8;\n\n    if (err==UNZ_OK)\n        *pX = x;\n    else\n        *pX = 0;\n    return err;\n}\n\nlocal int unz64local_getLong OF((\n    const zlib_filefunc64_32_def* pzlib_filefunc_def,\n    voidpf filestream,\n    uLong *pX));\n\nlocal int unz64local_getLong (const zlib_filefunc64_32_def* pzlib_filefunc_def,\n                            voidpf filestream,\n                            uLong *pX)\n{\n    uLong x ;\n    int i = 0;\n    int err;\n\n    err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);\n    x = (uLong)i;\n\n    if (err==UNZ_OK)\n        err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);\n    x |= ((uLong)i)<<8;\n\n    if (err==UNZ_OK)\n        err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);\n    x |= ((uLong)i)<<16;\n\n    if (err==UNZ_OK)\n        err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);\n    x += ((uLong)i)<<24;\n\n    if (err==UNZ_OK)\n        *pX = x;\n    else\n        *pX = 0;\n    return err;\n}\n\nlocal int unz64local_getLong64 OF((\n    const zlib_filefunc64_32_def* pzlib_filefunc_def,\n    voidpf filestream,\n    ZPOS64_T *pX));\n\n\nlocal int unz64local_getLong64 (const zlib_filefunc64_32_def* pzlib_filefunc_def,\n                            voidpf filestream,\n                            ZPOS64_T *pX)\n{\n    ZPOS64_T x ;\n    int i = 0;\n    int err;\n\n    err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);\n    x = (ZPOS64_T)i;\n\n    if (err==UNZ_OK)\n        err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);\n    x |= ((ZPOS64_T)i)<<8;\n\n    if (err==UNZ_OK)\n        err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);\n    x |= ((ZPOS64_T)i)<<16;\n\n    if (err==UNZ_OK)\n        err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);\n    x |= ((ZPOS64_T)i)<<24;\n\n    if (err==UNZ_OK)\n        err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);\n    x |= ((ZPOS64_T)i)<<32;\n\n    if (err==UNZ_OK)\n        err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);\n    x |= ((ZPOS64_T)i)<<40;\n\n    if (err==UNZ_OK)\n        err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);\n    x |= ((ZPOS64_T)i)<<48;\n\n    if (err==UNZ_OK)\n        err = unz64local_getByte(pzlib_filefunc_def,filestream,&i);\n    x |= ((ZPOS64_T)i)<<56;\n\n    if (err==UNZ_OK)\n        *pX = x;\n    else\n        *pX = 0;\n    return err;\n}\n\n/* My own strcmpi / strcasecmp */\nlocal int strcmpcasenosensitive_internal (const char* fileName1, const char* fileName2)\n{\n    for (;;)\n    {\n        char c1=*(fileName1++);\n        char c2=*(fileName2++);\n        if ((c1>='a') && (c1<='z'))\n            c1 -= 0x20;\n        if ((c2>='a') && (c2<='z'))\n            c2 -= 0x20;\n        if (c1=='\\0')\n            return ((c2=='\\0') ? 0 : -1);\n        if (c2=='\\0')\n            return 1;\n        if (c1<c2)\n            return -1;\n        if (c1>c2)\n            return 1;\n    }\n}\n\n\n#ifdef  CASESENSITIVITYDEFAULT_NO\n#define CASESENSITIVITYDEFAULTVALUE 2\n#else\n#define CASESENSITIVITYDEFAULTVALUE 1\n#endif\n\n#ifndef STRCMPCASENOSENTIVEFUNCTION\n#define STRCMPCASENOSENTIVEFUNCTION strcmpcasenosensitive_internal\n#endif\n\n/*\n   Compare two filename (fileName1,fileName2).\n   If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp)\n   If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi\n                                                                or strcasecmp)\n   If iCaseSenisivity = 0, case sensitivity is defaut of your operating system\n        (like 1 on Unix, 2 on Windows)\n\n*/\nextern int ZEXPORT unzStringFileNameCompare (const char*  fileName1,\n                                                 const char*  fileName2,\n                                                 int iCaseSensitivity)\n\n{\n    if (iCaseSensitivity==0)\n        iCaseSensitivity=CASESENSITIVITYDEFAULTVALUE;\n\n    if (iCaseSensitivity==1)\n        return strcmp(fileName1,fileName2);\n\n    return STRCMPCASENOSENTIVEFUNCTION(fileName1,fileName2);\n}\n\n#ifndef BUFREADCOMMENT\n#define BUFREADCOMMENT (0x400)\n#endif\n\n/*\n  Locate the Central directory of a zipfile (at the end, just before\n    the global comment)\n*/\nlocal ZPOS64_T unz64local_SearchCentralDir OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream));\nlocal ZPOS64_T unz64local_SearchCentralDir(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream)\n{\n    unsigned char* buf;\n    ZPOS64_T uSizeFile;\n    ZPOS64_T uBackRead;\n    ZPOS64_T uMaxBack=0xffff; /* maximum size of global comment */\n    ZPOS64_T uPosFound=0;\n\n    if (ZSEEK64(*pzlib_filefunc_def,filestream,0,ZLIB_FILEFUNC_SEEK_END) != 0)\n        return 0;\n\n\n    uSizeFile = ZTELL64(*pzlib_filefunc_def,filestream);\n\n    if (uMaxBack>uSizeFile)\n        uMaxBack = uSizeFile;\n\n    buf = (unsigned char*)ALLOC(BUFREADCOMMENT+4);\n    if (buf==NULL)\n        return 0;\n\n    uBackRead = 4;\n    while (uBackRead<uMaxBack)\n    {\n        uLong uReadSize;\n        ZPOS64_T uReadPos ;\n        int i;\n        if (uBackRead+BUFREADCOMMENT>uMaxBack)\n            uBackRead = uMaxBack;\n        else\n            uBackRead+=BUFREADCOMMENT;\n        uReadPos = uSizeFile-uBackRead ;\n\n        uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ?\n                     (BUFREADCOMMENT+4) : (uLong)(uSizeFile-uReadPos);\n        if (ZSEEK64(*pzlib_filefunc_def,filestream,uReadPos,ZLIB_FILEFUNC_SEEK_SET)!=0)\n            break;\n\n        if (ZREAD64(*pzlib_filefunc_def,filestream,buf,uReadSize)!=uReadSize)\n            break;\n\n        for (i=(int)uReadSize-3; (i--)>0;)\n            if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) &&\n                ((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06))\n            {\n                uPosFound = uReadPos+i;\n                break;\n            }\n\n        if (uPosFound!=0)\n            break;\n    }\n    TRYFREE(buf);\n    return uPosFound;\n}\n\n\n/*\n  Locate the Central directory 64 of a zipfile (at the end, just before\n    the global comment)\n*/\nlocal ZPOS64_T unz64local_SearchCentralDir64 OF((\n    const zlib_filefunc64_32_def* pzlib_filefunc_def,\n    voidpf filestream));\n\nlocal ZPOS64_T unz64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib_filefunc_def,\n                                      voidpf filestream)\n{\n    unsigned char* buf;\n    ZPOS64_T uSizeFile;\n    ZPOS64_T uBackRead;\n    ZPOS64_T uMaxBack=0xffff; /* maximum size of global comment */\n    ZPOS64_T uPosFound=0;\n    uLong uL;\n                ZPOS64_T relativeOffset;\n\n    if (ZSEEK64(*pzlib_filefunc_def,filestream,0,ZLIB_FILEFUNC_SEEK_END) != 0)\n        return 0;\n\n\n    uSizeFile = ZTELL64(*pzlib_filefunc_def,filestream);\n\n    if (uMaxBack>uSizeFile)\n        uMaxBack = uSizeFile;\n\n    buf = (unsigned char*)ALLOC(BUFREADCOMMENT+4);\n    if (buf==NULL)\n        return 0;\n\n    uBackRead = 4;\n    while (uBackRead<uMaxBack)\n    {\n        uLong uReadSize;\n        ZPOS64_T uReadPos;\n        int i;\n        if (uBackRead+BUFREADCOMMENT>uMaxBack)\n            uBackRead = uMaxBack;\n        else\n            uBackRead+=BUFREADCOMMENT;\n        uReadPos = uSizeFile-uBackRead ;\n\n        uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ?\n                     (BUFREADCOMMENT+4) : (uLong)(uSizeFile-uReadPos);\n        if (ZSEEK64(*pzlib_filefunc_def,filestream,uReadPos,ZLIB_FILEFUNC_SEEK_SET)!=0)\n            break;\n\n        if (ZREAD64(*pzlib_filefunc_def,filestream,buf,uReadSize)!=uReadSize)\n            break;\n\n        for (i=(int)uReadSize-3; (i--)>0;)\n            if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) &&\n                ((*(buf+i+2))==0x06) && ((*(buf+i+3))==0x07))\n            {\n                uPosFound = uReadPos+i;\n                break;\n            }\n\n        if (uPosFound!=0)\n            break;\n    }\n    TRYFREE(buf);\n    if (uPosFound == 0)\n        return 0;\n\n    /* Zip64 end of central directory locator */\n    if (ZSEEK64(*pzlib_filefunc_def,filestream, uPosFound,ZLIB_FILEFUNC_SEEK_SET)!=0)\n        return 0;\n\n    /* the signature, already checked */\n    if (unz64local_getLong(pzlib_filefunc_def,filestream,&uL)!=UNZ_OK)\n        return 0;\n\n    /* number of the disk with the start of the zip64 end of  central directory */\n    if (unz64local_getLong(pzlib_filefunc_def,filestream,&uL)!=UNZ_OK)\n        return 0;\n    if (uL != 0)\n        return 0;\n\n    /* relative offset of the zip64 end of central directory record */\n    if (unz64local_getLong64(pzlib_filefunc_def,filestream,&relativeOffset)!=UNZ_OK)\n        return 0;\n\n    /* total number of disks */\n    if (unz64local_getLong(pzlib_filefunc_def,filestream,&uL)!=UNZ_OK)\n        return 0;\n    if (uL != 1)\n        return 0;\n\n    /* Goto end of central directory record */\n    if (ZSEEK64(*pzlib_filefunc_def,filestream, relativeOffset,ZLIB_FILEFUNC_SEEK_SET)!=0)\n        return 0;\n\n     /* the signature */\n    if (unz64local_getLong(pzlib_filefunc_def,filestream,&uL)!=UNZ_OK)\n        return 0;\n\n    if (uL != 0x06064b50)\n        return 0;\n\n    return relativeOffset;\n}\n\n/*\n  Open a Zip file. path contain the full pathname (by example,\n     on a Windows NT computer \"c:\\\\test\\\\zlib114.zip\" or on an Unix computer\n     \"zlib/zlib114.zip\".\n     If the zipfile cannot be opened (file doesn't exist or in not valid), the\n       return value is NULL.\n     Else, the return value is a unzFile Handle, usable with other function\n       of this unzip package.\n*/\nlocal unzFile unzOpenInternal (const void *path,\n                               zlib_filefunc64_32_def* pzlib_filefunc64_32_def,\n                               int is64bitOpenFunction)\n{\n    unz64_s us;\n    unz64_s *s;\n    ZPOS64_T central_pos;\n    uLong   uL;\n\n    uLong number_disk;          /* number of the current dist, used for\n                                   spaning ZIP, unsupported, always 0*/\n    uLong number_disk_with_CD;  /* number the the disk with central dir, used\n                                   for spaning ZIP, unsupported, always 0*/\n    ZPOS64_T number_entry_CD;      /* total number of entries in\n                                   the central dir\n                                   (same than number_entry on nospan) */\n\n    int err=UNZ_OK;\n\n    if (unz_copyright[0]!=' ')\n        return NULL;\n\n    us.z_filefunc.zseek32_file = NULL;\n    us.z_filefunc.ztell32_file = NULL;\n    if (pzlib_filefunc64_32_def==NULL)\n        fill_fopen64_filefunc(&us.z_filefunc.zfile_func64);\n    else\n        us.z_filefunc = *pzlib_filefunc64_32_def;\n    us.is64bitOpenFunction = is64bitOpenFunction;\n\n\n\n    us.filestream = ZOPEN64(us.z_filefunc,\n                                                 path,\n                                                 ZLIB_FILEFUNC_MODE_READ |\n                                                 ZLIB_FILEFUNC_MODE_EXISTING);\n    if (us.filestream==NULL)\n        return NULL;\n\n    central_pos = unz64local_SearchCentralDir64(&us.z_filefunc,us.filestream);\n    if (central_pos)\n    {\n        uLong uS;\n        ZPOS64_T uL64;\n\n        us.isZip64 = 1;\n\n        if (ZSEEK64(us.z_filefunc, us.filestream,\n                                      central_pos,ZLIB_FILEFUNC_SEEK_SET)!=0)\n        err=UNZ_ERRNO;\n\n        /* the signature, already checked */\n        if (unz64local_getLong(&us.z_filefunc, us.filestream,&uL)!=UNZ_OK)\n            err=UNZ_ERRNO;\n\n        /* size of zip64 end of central directory record */\n        if (unz64local_getLong64(&us.z_filefunc, us.filestream,&uL64)!=UNZ_OK)\n            err=UNZ_ERRNO;\n\n        /* version made by */\n        if (unz64local_getShort(&us.z_filefunc, us.filestream,&uS)!=UNZ_OK)\n            err=UNZ_ERRNO;\n\n        /* version needed to extract */\n        if (unz64local_getShort(&us.z_filefunc, us.filestream,&uS)!=UNZ_OK)\n            err=UNZ_ERRNO;\n\n        /* number of this disk */\n        if (unz64local_getLong(&us.z_filefunc, us.filestream,&number_disk)!=UNZ_OK)\n            err=UNZ_ERRNO;\n\n        /* number of the disk with the start of the central directory */\n        if (unz64local_getLong(&us.z_filefunc, us.filestream,&number_disk_with_CD)!=UNZ_OK)\n            err=UNZ_ERRNO;\n\n        /* total number of entries in the central directory on this disk */\n        if (unz64local_getLong64(&us.z_filefunc, us.filestream,&us.gi.number_entry)!=UNZ_OK)\n            err=UNZ_ERRNO;\n\n        /* total number of entries in the central directory */\n        if (unz64local_getLong64(&us.z_filefunc, us.filestream,&number_entry_CD)!=UNZ_OK)\n            err=UNZ_ERRNO;\n\n        if ((number_entry_CD!=us.gi.number_entry) ||\n            (number_disk_with_CD!=0) ||\n            (number_disk!=0))\n            err=UNZ_BADZIPFILE;\n\n        /* size of the central directory */\n        if (unz64local_getLong64(&us.z_filefunc, us.filestream,&us.size_central_dir)!=UNZ_OK)\n            err=UNZ_ERRNO;\n\n        /* offset of start of central directory with respect to the\n          starting disk number */\n        if (unz64local_getLong64(&us.z_filefunc, us.filestream,&us.offset_central_dir)!=UNZ_OK)\n            err=UNZ_ERRNO;\n\n        us.gi.size_comment = 0;\n    }\n    else\n    {\n        central_pos = unz64local_SearchCentralDir(&us.z_filefunc,us.filestream);\n        if (central_pos==0)\n            err=UNZ_ERRNO;\n\n        us.isZip64 = 0;\n\n        if (ZSEEK64(us.z_filefunc, us.filestream,\n                                        central_pos,ZLIB_FILEFUNC_SEEK_SET)!=0)\n            err=UNZ_ERRNO;\n\n        /* the signature, already checked */\n        if (unz64local_getLong(&us.z_filefunc, us.filestream,&uL)!=UNZ_OK)\n            err=UNZ_ERRNO;\n\n        /* number of this disk */\n        if (unz64local_getShort(&us.z_filefunc, us.filestream,&number_disk)!=UNZ_OK)\n            err=UNZ_ERRNO;\n\n        /* number of the disk with the start of the central directory */\n        if (unz64local_getShort(&us.z_filefunc, us.filestream,&number_disk_with_CD)!=UNZ_OK)\n            err=UNZ_ERRNO;\n\n        /* total number of entries in the central dir on this disk */\n        if (unz64local_getShort(&us.z_filefunc, us.filestream,&uL)!=UNZ_OK)\n            err=UNZ_ERRNO;\n        us.gi.number_entry = uL;\n\n        /* total number of entries in the central dir */\n        if (unz64local_getShort(&us.z_filefunc, us.filestream,&uL)!=UNZ_OK)\n            err=UNZ_ERRNO;\n        number_entry_CD = uL;\n\n        if ((number_entry_CD!=us.gi.number_entry) ||\n            (number_disk_with_CD!=0) ||\n            (number_disk!=0))\n            err=UNZ_BADZIPFILE;\n\n        /* size of the central directory */\n        if (unz64local_getLong(&us.z_filefunc, us.filestream,&uL)!=UNZ_OK)\n            err=UNZ_ERRNO;\n        us.size_central_dir = uL;\n\n        /* offset of start of central directory with respect to the\n            starting disk number */\n        if (unz64local_getLong(&us.z_filefunc, us.filestream,&uL)!=UNZ_OK)\n            err=UNZ_ERRNO;\n        us.offset_central_dir = uL;\n\n        /* zipfile comment length */\n        if (unz64local_getShort(&us.z_filefunc, us.filestream,&us.gi.size_comment)!=UNZ_OK)\n            err=UNZ_ERRNO;\n    }\n\n    if ((central_pos<us.offset_central_dir+us.size_central_dir) &&\n        (err==UNZ_OK))\n        err=UNZ_BADZIPFILE;\n\n    if (err!=UNZ_OK)\n    {\n        ZCLOSE64(us.z_filefunc, us.filestream);\n        return NULL;\n    }\n\n    us.byte_before_the_zipfile = central_pos -\n                            (us.offset_central_dir+us.size_central_dir);\n    us.central_pos = central_pos;\n    us.pfile_in_zip_read = NULL;\n    us.encrypted = 0;\n\n\n    s=(unz64_s*)ALLOC(sizeof(unz64_s));\n    if( s != NULL)\n    {\n        *s=us;\n        unzGoToFirstFile((unzFile)s);\n    }\n    return (unzFile)s;\n}\n\n\nextern unzFile ZEXPORT unzOpen2 (const char *path,\n                                        zlib_filefunc_def* pzlib_filefunc32_def)\n{\n    if (pzlib_filefunc32_def != NULL)\n    {\n        zlib_filefunc64_32_def zlib_filefunc64_32_def_fill;\n        fill_zlib_filefunc64_32_def_from_filefunc32(&zlib_filefunc64_32_def_fill,pzlib_filefunc32_def);\n        return unzOpenInternal(path, &zlib_filefunc64_32_def_fill, 0);\n    }\n    else\n        return unzOpenInternal(path, NULL, 0);\n}\n\nextern unzFile ZEXPORT unzOpen2_64 (const void *path,\n                                     zlib_filefunc64_def* pzlib_filefunc_def)\n{\n    if (pzlib_filefunc_def != NULL)\n    {\n        zlib_filefunc64_32_def zlib_filefunc64_32_def_fill;\n        zlib_filefunc64_32_def_fill.zfile_func64 = *pzlib_filefunc_def;\n        zlib_filefunc64_32_def_fill.ztell32_file = NULL;\n        zlib_filefunc64_32_def_fill.zseek32_file = NULL;\n        return unzOpenInternal(path, &zlib_filefunc64_32_def_fill, 1);\n    }\n    else\n        return unzOpenInternal(path, NULL, 1);\n}\n\nextern unzFile ZEXPORT unzOpen (const char *path)\n{\n    return unzOpenInternal(path, NULL, 0);\n}\n\nextern unzFile ZEXPORT unzOpen64 (const void *path)\n{\n    return unzOpenInternal(path, NULL, 1);\n}\n\n/*\n  Close a ZipFile opened with unzipOpen.\n  If there is files inside the .Zip opened with unzipOpenCurrentFile (see later),\n    these files MUST be closed with unzipCloseCurrentFile before call unzipClose.\n  return UNZ_OK if there is no problem. */\nextern int ZEXPORT unzClose (unzFile file)\n{\n    unz64_s* s;\n    if (file==NULL)\n        return UNZ_PARAMERROR;\n    s=(unz64_s*)file;\n\n    if (s->pfile_in_zip_read!=NULL)\n        unzCloseCurrentFile(file);\n\n    ZCLOSE64(s->z_filefunc, s->filestream);\n    TRYFREE(s);\n    return UNZ_OK;\n}\n\n\n/*\n  Write info about the ZipFile in the *pglobal_info structure.\n  No preparation of the structure is needed\n  return UNZ_OK if there is no problem. */\nextern int ZEXPORT unzGetGlobalInfo64 (unzFile file, unz_global_info64* pglobal_info)\n{\n    unz64_s* s;\n    if (file==NULL)\n        return UNZ_PARAMERROR;\n    s=(unz64_s*)file;\n    *pglobal_info=s->gi;\n    return UNZ_OK;\n}\n\nextern int ZEXPORT unzGetGlobalInfo (unzFile file, unz_global_info* pglobal_info32)\n{\n    unz64_s* s;\n    if (file==NULL)\n        return UNZ_PARAMERROR;\n    s=(unz64_s*)file;\n    /* to do : check if number_entry is not truncated */\n    pglobal_info32->number_entry = (uLong)s->gi.number_entry;\n    pglobal_info32->size_comment = s->gi.size_comment;\n    return UNZ_OK;\n}\n/*\n   Translate date/time from Dos format to tm_unz (readable more easilty)\n*/\nlocal void unz64local_DosDateToTmuDate (ZPOS64_T ulDosDate, tm_unz* ptm)\n{\n    ZPOS64_T uDate;\n    uDate = (ZPOS64_T)(ulDosDate>>16);\n    ptm->tm_mday = (uInt)(uDate&0x1f) ;\n    ptm->tm_mon =  (uInt)((((uDate)&0x1E0)/0x20)-1) ;\n    ptm->tm_year = (uInt)(((uDate&0x0FE00)/0x0200)+1980) ;\n\n    ptm->tm_hour = (uInt) ((ulDosDate &0xF800)/0x800);\n    ptm->tm_min =  (uInt) ((ulDosDate&0x7E0)/0x20) ;\n    ptm->tm_sec =  (uInt) (2*(ulDosDate&0x1f)) ;\n}\n\n/*\n  Get Info about the current file in the zipfile, with internal only info\n*/\nlocal int unz64local_GetCurrentFileInfoInternal OF((unzFile file,\n                                                  unz_file_info64 *pfile_info,\n                                                  unz_file_info64_internal\n                                                  *pfile_info_internal,\n                                                  char *szFileName,\n                                                  uLong fileNameBufferSize,\n                                                  void *extraField,\n                                                  uLong extraFieldBufferSize,\n                                                  char *szComment,\n                                                  uLong commentBufferSize));\n\nlocal int unz64local_GetCurrentFileInfoInternal (unzFile file,\n                                                  unz_file_info64 *pfile_info,\n                                                  unz_file_info64_internal\n                                                  *pfile_info_internal,\n                                                  char *szFileName,\n                                                  uLong fileNameBufferSize,\n                                                  void *extraField,\n                                                  uLong extraFieldBufferSize,\n                                                  char *szComment,\n                                                  uLong commentBufferSize)\n{\n    unz64_s* s;\n    unz_file_info64 file_info;\n    unz_file_info64_internal file_info_internal;\n    int err=UNZ_OK;\n    uLong uMagic;\n    long lSeek=0;\n    uLong uL;\n\n    if (file==NULL)\n        return UNZ_PARAMERROR;\n    s=(unz64_s*)file;\n    if (ZSEEK64(s->z_filefunc, s->filestream,\n              s->pos_in_central_dir+s->byte_before_the_zipfile,\n              ZLIB_FILEFUNC_SEEK_SET)!=0)\n        err=UNZ_ERRNO;\n\n\n    /* we check the magic */\n    if (err==UNZ_OK)\n    {\n        if (unz64local_getLong(&s->z_filefunc, s->filestream,&uMagic) != UNZ_OK)\n            err=UNZ_ERRNO;\n        else if (uMagic!=0x02014b50)\n            err=UNZ_BADZIPFILE;\n    }\n\n    if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.version) != UNZ_OK)\n        err=UNZ_ERRNO;\n\n    if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.version_needed) != UNZ_OK)\n        err=UNZ_ERRNO;\n\n    if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.flag) != UNZ_OK)\n        err=UNZ_ERRNO;\n\n    if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.compression_method) != UNZ_OK)\n        err=UNZ_ERRNO;\n\n    if (unz64local_getLong(&s->z_filefunc, s->filestream,&file_info.dosDate) != UNZ_OK)\n        err=UNZ_ERRNO;\n\n    unz64local_DosDateToTmuDate(file_info.dosDate,&file_info.tmu_date);\n\n    if (unz64local_getLong(&s->z_filefunc, s->filestream,&file_info.crc) != UNZ_OK)\n        err=UNZ_ERRNO;\n\n    if (unz64local_getLong(&s->z_filefunc, s->filestream,&uL) != UNZ_OK)\n        err=UNZ_ERRNO;\n    file_info.compressed_size = uL;\n\n    if (unz64local_getLong(&s->z_filefunc, s->filestream,&uL) != UNZ_OK)\n        err=UNZ_ERRNO;\n    file_info.uncompressed_size = uL;\n\n    if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.size_filename) != UNZ_OK)\n        err=UNZ_ERRNO;\n\n    if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.size_file_extra) != UNZ_OK)\n        err=UNZ_ERRNO;\n\n    if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.size_file_comment) != UNZ_OK)\n        err=UNZ_ERRNO;\n\n    if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.disk_num_start) != UNZ_OK)\n        err=UNZ_ERRNO;\n\n    if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.internal_fa) != UNZ_OK)\n        err=UNZ_ERRNO;\n\n    if (unz64local_getLong(&s->z_filefunc, s->filestream,&file_info.external_fa) != UNZ_OK)\n        err=UNZ_ERRNO;\n\n                // relative offset of local header\n    if (unz64local_getLong(&s->z_filefunc, s->filestream,&uL) != UNZ_OK)\n        err=UNZ_ERRNO;\n    file_info_internal.offset_curfile = uL;\n\n    lSeek+=file_info.size_filename;\n    if ((err==UNZ_OK) && (szFileName!=NULL))\n    {\n        uLong uSizeRead ;\n        if (file_info.size_filename<fileNameBufferSize)\n        {\n            *(szFileName+file_info.size_filename)='\\0';\n            uSizeRead = file_info.size_filename;\n        }\n        else\n            uSizeRead = fileNameBufferSize;\n\n        if ((file_info.size_filename>0) && (fileNameBufferSize>0))\n            if (ZREAD64(s->z_filefunc, s->filestream,szFileName,uSizeRead)!=uSizeRead)\n                err=UNZ_ERRNO;\n        lSeek -= uSizeRead;\n    }\n\n    // Read extrafield\n    if ((err==UNZ_OK) && (extraField!=NULL))\n    {\n        ZPOS64_T uSizeRead ;\n        if (file_info.size_file_extra<extraFieldBufferSize)\n            uSizeRead = file_info.size_file_extra;\n        else\n            uSizeRead = extraFieldBufferSize;\n\n        if (lSeek!=0)\n        {\n            if (ZSEEK64(s->z_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0)\n                lSeek=0;\n            else\n                err=UNZ_ERRNO;\n        }\n\n        if ((file_info.size_file_extra>0) && (extraFieldBufferSize>0))\n            if (ZREAD64(s->z_filefunc, s->filestream,extraField,(uLong)uSizeRead)!=uSizeRead)\n                err=UNZ_ERRNO;\n\n        lSeek += file_info.size_file_extra - (uLong)uSizeRead;\n    }\n    else\n        lSeek += file_info.size_file_extra;\n\n\n    if ((err==UNZ_OK) && (file_info.size_file_extra != 0))\n    {\n                                uLong acc = 0;\n\n        // since lSeek now points to after the extra field we need to move back\n        lSeek -= file_info.size_file_extra;\n\n        if (lSeek!=0)\n        {\n            if (ZSEEK64(s->z_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0)\n                lSeek=0;\n            else\n                err=UNZ_ERRNO;\n        }\n\n        while(acc < file_info.size_file_extra)\n        {\n            uLong headerId;\n                                                uLong dataSize;\n\n            if (unz64local_getShort(&s->z_filefunc, s->filestream,&headerId) != UNZ_OK)\n                err=UNZ_ERRNO;\n\n            if (unz64local_getShort(&s->z_filefunc, s->filestream,&dataSize) != UNZ_OK)\n                err=UNZ_ERRNO;\n\n            /* ZIP64 extra fields */\n            if (headerId == 0x0001)\n            {\n                                                        uLong uL;\n\n                                                                if(file_info.uncompressed_size == (ZPOS64_T)(unsigned long)-1)\n                                                                {\n                                                                        if (unz64local_getLong64(&s->z_filefunc, s->filestream,&file_info.uncompressed_size) != UNZ_OK)\n                                                                                        err=UNZ_ERRNO;\n                                                                }\n\n                                                                if(file_info.compressed_size == (ZPOS64_T)(unsigned long)-1)\n                                                                {\n                                                                        if (unz64local_getLong64(&s->z_filefunc, s->filestream,&file_info.compressed_size) != UNZ_OK)\n                                                                                  err=UNZ_ERRNO;\n                                                                }\n\n                                                                if(file_info_internal.offset_curfile == (ZPOS64_T)(unsigned long)-1)\n                                                                {\n                                                                        /* Relative Header offset */\n                                                                        if (unz64local_getLong64(&s->z_filefunc, s->filestream,&file_info_internal.offset_curfile) != UNZ_OK)\n                                                                                err=UNZ_ERRNO;\n                                                                }\n\n                                                                if(file_info.disk_num_start == (unsigned long)-1)\n                                                                {\n                                                                        /* Disk Start Number */\n                                                                        if (unz64local_getLong(&s->z_filefunc, s->filestream,&uL) != UNZ_OK)\n                                                                                err=UNZ_ERRNO;\n                                                                }\n\n            }\n            else\n            {\n                if (ZSEEK64(s->z_filefunc, s->filestream,dataSize,ZLIB_FILEFUNC_SEEK_CUR)!=0)\n                    err=UNZ_ERRNO;\n            }\n\n            acc += 2 + 2 + dataSize;\n        }\n    }\n\n    if ((err==UNZ_OK) && (szComment!=NULL))\n    {\n        uLong uSizeRead ;\n        if (file_info.size_file_comment<commentBufferSize)\n        {\n            *(szComment+file_info.size_file_comment)='\\0';\n            uSizeRead = file_info.size_file_comment;\n        }\n        else\n            uSizeRead = commentBufferSize;\n\n        if (lSeek!=0)\n        {\n            if (ZSEEK64(s->z_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0)\n                lSeek=0;\n            else\n                err=UNZ_ERRNO;\n        }\n\n        if ((file_info.size_file_comment>0) && (commentBufferSize>0))\n            if (ZREAD64(s->z_filefunc, s->filestream,szComment,uSizeRead)!=uSizeRead)\n                err=UNZ_ERRNO;\n        lSeek+=file_info.size_file_comment - uSizeRead;\n    }\n    else\n        lSeek+=file_info.size_file_comment;\n\n\n    if ((err==UNZ_OK) && (pfile_info!=NULL))\n        *pfile_info=file_info;\n\n    if ((err==UNZ_OK) && (pfile_info_internal!=NULL))\n        *pfile_info_internal=file_info_internal;\n\n    return err;\n}\n\n\n\n/*\n  Write info about the ZipFile in the *pglobal_info structure.\n  No preparation of the structure is needed\n  return UNZ_OK if there is no problem.\n*/\nextern int ZEXPORT unzGetCurrentFileInfo64 (unzFile file,\n                                          unz_file_info64 * pfile_info,\n                                          char * szFileName, uLong fileNameBufferSize,\n                                          void *extraField, uLong extraFieldBufferSize,\n                                          char* szComment,  uLong commentBufferSize)\n{\n    return unz64local_GetCurrentFileInfoInternal(file,pfile_info,NULL,\n                                                szFileName,fileNameBufferSize,\n                                                extraField,extraFieldBufferSize,\n                                                szComment,commentBufferSize);\n}\n\nextern int ZEXPORT unzGetCurrentFileInfo (unzFile file,\n                                          unz_file_info * pfile_info,\n                                          char * szFileName, uLong fileNameBufferSize,\n                                          void *extraField, uLong extraFieldBufferSize,\n                                          char* szComment,  uLong commentBufferSize)\n{\n    int err;\n    unz_file_info64 file_info64;\n    err = unz64local_GetCurrentFileInfoInternal(file,&file_info64,NULL,\n                                                szFileName,fileNameBufferSize,\n                                                extraField,extraFieldBufferSize,\n                                                szComment,commentBufferSize);\n    if (err==UNZ_OK)\n    {\n        pfile_info->version = file_info64.version;\n        pfile_info->version_needed = file_info64.version_needed;\n        pfile_info->flag = file_info64.flag;\n        pfile_info->compression_method = file_info64.compression_method;\n        pfile_info->dosDate = file_info64.dosDate;\n        pfile_info->crc = file_info64.crc;\n\n        pfile_info->size_filename = file_info64.size_filename;\n        pfile_info->size_file_extra = file_info64.size_file_extra;\n        pfile_info->size_file_comment = file_info64.size_file_comment;\n\n        pfile_info->disk_num_start = file_info64.disk_num_start;\n        pfile_info->internal_fa = file_info64.internal_fa;\n        pfile_info->external_fa = file_info64.external_fa;\n\n        pfile_info->tmu_date = file_info64.tmu_date,\n\n\n        pfile_info->compressed_size = (uLong)file_info64.compressed_size;\n        pfile_info->uncompressed_size = (uLong)file_info64.uncompressed_size;\n\n    }\n    return err;\n}\n/*\n  Set the current file of the zipfile to the first file.\n  return UNZ_OK if there is no problem\n*/\nextern int ZEXPORT unzGoToFirstFile (unzFile file)\n{\n    int err=UNZ_OK;\n    unz64_s* s;\n    if (file==NULL)\n        return UNZ_PARAMERROR;\n    s=(unz64_s*)file;\n    s->pos_in_central_dir=s->offset_central_dir;\n    s->num_file=0;\n    err=unz64local_GetCurrentFileInfoInternal(file,&s->cur_file_info,\n                                             &s->cur_file_info_internal,\n                                             NULL,0,NULL,0,NULL,0);\n    s->current_file_ok = (err == UNZ_OK);\n    return err;\n}\n\n/*\n  Set the current file of the zipfile to the next file.\n  return UNZ_OK if there is no problem\n  return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest.\n*/\nextern int ZEXPORT unzGoToNextFile (unzFile  file)\n{\n    unz64_s* s;\n    int err;\n\n    if (file==NULL)\n        return UNZ_PARAMERROR;\n    s=(unz64_s*)file;\n    if (!s->current_file_ok)\n        return UNZ_END_OF_LIST_OF_FILE;\n    if (s->gi.number_entry != 0xffff)    /* 2^16 files overflow hack */\n      if (s->num_file+1==s->gi.number_entry)\n        return UNZ_END_OF_LIST_OF_FILE;\n\n    s->pos_in_central_dir += SIZECENTRALDIRITEM + s->cur_file_info.size_filename +\n            s->cur_file_info.size_file_extra + s->cur_file_info.size_file_comment ;\n    s->num_file++;\n    err = unz64local_GetCurrentFileInfoInternal(file,&s->cur_file_info,\n                                               &s->cur_file_info_internal,\n                                               NULL,0,NULL,0,NULL,0);\n    s->current_file_ok = (err == UNZ_OK);\n    return err;\n}\n\n\n/*\n  Try locate the file szFileName in the zipfile.\n  For the iCaseSensitivity signification, see unzipStringFileNameCompare\n\n  return value :\n  UNZ_OK if the file is found. It becomes the current file.\n  UNZ_END_OF_LIST_OF_FILE if the file is not found\n*/\nextern int ZEXPORT unzLocateFile (unzFile file, const char *szFileName, int iCaseSensitivity)\n{\n    unz64_s* s;\n    int err;\n\n    /* We remember the 'current' position in the file so that we can jump\n     * back there if we fail.\n     */\n    unz_file_info64 cur_file_infoSaved;\n    unz_file_info64_internal cur_file_info_internalSaved;\n    ZPOS64_T num_fileSaved;\n    ZPOS64_T pos_in_central_dirSaved;\n\n\n    if (file==NULL)\n        return UNZ_PARAMERROR;\n\n    if (strlen(szFileName)>=UNZ_MAXFILENAMEINZIP)\n        return UNZ_PARAMERROR;\n\n    s=(unz64_s*)file;\n    if (!s->current_file_ok)\n        return UNZ_END_OF_LIST_OF_FILE;\n\n    /* Save the current state */\n    num_fileSaved = s->num_file;\n    pos_in_central_dirSaved = s->pos_in_central_dir;\n    cur_file_infoSaved = s->cur_file_info;\n    cur_file_info_internalSaved = s->cur_file_info_internal;\n\n    err = unzGoToFirstFile(file);\n\n    while (err == UNZ_OK)\n    {\n        char szCurrentFileName[UNZ_MAXFILENAMEINZIP+1];\n        err = unzGetCurrentFileInfo64(file,NULL,\n                                    szCurrentFileName,sizeof(szCurrentFileName)-1,\n                                    NULL,0,NULL,0);\n        if (err == UNZ_OK)\n        {\n            if (unzStringFileNameCompare(szCurrentFileName,\n                                            szFileName,iCaseSensitivity)==0)\n                return UNZ_OK;\n            err = unzGoToNextFile(file);\n        }\n    }\n\n    /* We failed, so restore the state of the 'current file' to where we\n     * were.\n     */\n    s->num_file = num_fileSaved ;\n    s->pos_in_central_dir = pos_in_central_dirSaved ;\n    s->cur_file_info = cur_file_infoSaved;\n    s->cur_file_info_internal = cur_file_info_internalSaved;\n    return err;\n}\n\n\n/*\n///////////////////////////////////////////\n// Contributed by Ryan Haksi (mailto://cryogen@infoserve.net)\n// I need random access\n//\n// Further optimization could be realized by adding an ability\n// to cache the directory in memory. The goal being a single\n// comprehensive file read to put the file I need in a memory.\n*/\n\n/*\ntypedef struct unz_file_pos_s\n{\n    ZPOS64_T pos_in_zip_directory;   // offset in file\n    ZPOS64_T num_of_file;            // # of file\n} unz_file_pos;\n*/\n\nextern int ZEXPORT unzGetFilePos64(unzFile file, unz64_file_pos*  file_pos)\n{\n    unz64_s* s;\n\n    if (file==NULL || file_pos==NULL)\n        return UNZ_PARAMERROR;\n    s=(unz64_s*)file;\n    if (!s->current_file_ok)\n        return UNZ_END_OF_LIST_OF_FILE;\n\n    file_pos->pos_in_zip_directory  = s->pos_in_central_dir;\n    file_pos->num_of_file           = s->num_file;\n\n    return UNZ_OK;\n}\n\nextern int ZEXPORT unzGetFilePos(\n    unzFile file,\n    unz_file_pos* file_pos)\n{\n    unz64_file_pos file_pos64;\n    int err = unzGetFilePos64(file,&file_pos64);\n    if (err==UNZ_OK)\n    {\n        file_pos->pos_in_zip_directory = (uLong)file_pos64.pos_in_zip_directory;\n        file_pos->num_of_file = (uLong)file_pos64.num_of_file;\n    }\n    return err;\n}\n\nextern int ZEXPORT unzGoToFilePos64(unzFile file, const unz64_file_pos* file_pos)\n{\n    unz64_s* s;\n    int err;\n\n    if (file==NULL || file_pos==NULL)\n        return UNZ_PARAMERROR;\n    s=(unz64_s*)file;\n\n    /* jump to the right spot */\n    s->pos_in_central_dir = file_pos->pos_in_zip_directory;\n    s->num_file           = file_pos->num_of_file;\n\n    /* set the current file */\n    err = unz64local_GetCurrentFileInfoInternal(file,&s->cur_file_info,\n                                               &s->cur_file_info_internal,\n                                               NULL,0,NULL,0,NULL,0);\n    /* return results */\n    s->current_file_ok = (err == UNZ_OK);\n    return err;\n}\n\nextern int ZEXPORT unzGoToFilePos(\n    unzFile file,\n    unz_file_pos* file_pos)\n{\n    unz64_file_pos file_pos64;\n    if (file_pos == NULL)\n        return UNZ_PARAMERROR;\n\n    file_pos64.pos_in_zip_directory = file_pos->pos_in_zip_directory;\n    file_pos64.num_of_file = file_pos->num_of_file;\n    return unzGoToFilePos64(file,&file_pos64);\n}\n\n/*\n// Unzip Helper Functions - should be here?\n///////////////////////////////////////////\n*/\n\n/*\n  Read the local header of the current zipfile\n  Check the coherency of the local header and info in the end of central\n        directory about this file\n  store in *piSizeVar the size of extra info in local header\n        (filename and size of extra field data)\n*/\nlocal int unz64local_CheckCurrentFileCoherencyHeader (unz64_s* s, uInt* piSizeVar,\n                                                    ZPOS64_T * poffset_local_extrafield,\n                                                    uInt  * psize_local_extrafield)\n{\n    uLong uMagic,uData,uFlags;\n    uLong size_filename;\n    uLong size_extra_field;\n    int err=UNZ_OK;\n\n    *piSizeVar = 0;\n    *poffset_local_extrafield = 0;\n    *psize_local_extrafield = 0;\n\n    if (ZSEEK64(s->z_filefunc, s->filestream,s->cur_file_info_internal.offset_curfile +\n                                s->byte_before_the_zipfile,ZLIB_FILEFUNC_SEEK_SET)!=0)\n        return UNZ_ERRNO;\n\n\n    if (err==UNZ_OK)\n    {\n        if (unz64local_getLong(&s->z_filefunc, s->filestream,&uMagic) != UNZ_OK)\n            err=UNZ_ERRNO;\n        else if (uMagic!=0x04034b50)\n            err=UNZ_BADZIPFILE;\n    }\n\n    if (unz64local_getShort(&s->z_filefunc, s->filestream,&uData) != UNZ_OK)\n        err=UNZ_ERRNO;\n/*\n    else if ((err==UNZ_OK) && (uData!=s->cur_file_info.wVersion))\n        err=UNZ_BADZIPFILE;\n*/\n    if (unz64local_getShort(&s->z_filefunc, s->filestream,&uFlags) != UNZ_OK)\n        err=UNZ_ERRNO;\n\n    if (unz64local_getShort(&s->z_filefunc, s->filestream,&uData) != UNZ_OK)\n        err=UNZ_ERRNO;\n    else if ((err==UNZ_OK) && (uData!=s->cur_file_info.compression_method))\n        err=UNZ_BADZIPFILE;\n\n    if ((err==UNZ_OK) && (s->cur_file_info.compression_method!=0) &&\n/* #ifdef HAVE_BZIP2 */\n                         (s->cur_file_info.compression_method!=Z_BZIP2ED) &&\n/* #endif */\n                         (s->cur_file_info.compression_method!=Z_DEFLATED))\n        err=UNZ_BADZIPFILE;\n\n    if (unz64local_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* date/time */\n        err=UNZ_ERRNO;\n\n    if (unz64local_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* crc */\n        err=UNZ_ERRNO;\n    else if ((err==UNZ_OK) && (uData!=s->cur_file_info.crc) && ((uFlags & 8)==0))\n        err=UNZ_BADZIPFILE;\n\n    if (unz64local_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* size compr */\n        err=UNZ_ERRNO;\n    else if (uData != 0xFFFFFFFF && (err==UNZ_OK) && (uData!=s->cur_file_info.compressed_size) && ((uFlags & 8)==0))\n        err=UNZ_BADZIPFILE;\n\n    if (unz64local_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* size uncompr */\n        err=UNZ_ERRNO;\n    else if (uData != 0xFFFFFFFF && (err==UNZ_OK) && (uData!=s->cur_file_info.uncompressed_size) && ((uFlags & 8)==0))\n        err=UNZ_BADZIPFILE;\n\n    if (unz64local_getShort(&s->z_filefunc, s->filestream,&size_filename) != UNZ_OK)\n        err=UNZ_ERRNO;\n    else if ((err==UNZ_OK) && (size_filename!=s->cur_file_info.size_filename))\n        err=UNZ_BADZIPFILE;\n\n    *piSizeVar += (uInt)size_filename;\n\n    if (unz64local_getShort(&s->z_filefunc, s->filestream,&size_extra_field) != UNZ_OK)\n        err=UNZ_ERRNO;\n    *poffset_local_extrafield= s->cur_file_info_internal.offset_curfile +\n                                    SIZEZIPLOCALHEADER + size_filename;\n    *psize_local_extrafield = (uInt)size_extra_field;\n\n    *piSizeVar += (uInt)size_extra_field;\n\n    return err;\n}\n\n/*\n  Open for reading data the current file in the zipfile.\n  If there is no error and the file is opened, the return value is UNZ_OK.\n*/\nextern int ZEXPORT unzOpenCurrentFile3 (unzFile file, int* method,\n                                            int* level, int raw, const char* password)\n{\n    int err=UNZ_OK;\n    uInt iSizeVar;\n    unz64_s* s;\n    file_in_zip64_read_info_s* pfile_in_zip_read_info;\n    ZPOS64_T offset_local_extrafield;  /* offset of the local extra field */\n    uInt  size_local_extrafield;    /* size of the local extra field */\n#    ifndef NOUNCRYPT\n    char source[12];\n#    else\n    if (password != NULL)\n        return UNZ_PARAMERROR;\n#    endif\n\n    if (file==NULL)\n        return UNZ_PARAMERROR;\n    s=(unz64_s*)file;\n    if (!s->current_file_ok)\n        return UNZ_PARAMERROR;\n\n    if (s->pfile_in_zip_read != NULL)\n        unzCloseCurrentFile(file);\n\n    if (unz64local_CheckCurrentFileCoherencyHeader(s,&iSizeVar, &offset_local_extrafield,&size_local_extrafield)!=UNZ_OK)\n        return UNZ_BADZIPFILE;\n\n    pfile_in_zip_read_info = (file_in_zip64_read_info_s*)ALLOC(sizeof(file_in_zip64_read_info_s));\n    if (pfile_in_zip_read_info==NULL)\n        return UNZ_INTERNALERROR;\n\n    pfile_in_zip_read_info->read_buffer=(char*)ALLOC(UNZ_BUFSIZE);\n    pfile_in_zip_read_info->offset_local_extrafield = offset_local_extrafield;\n    pfile_in_zip_read_info->size_local_extrafield = size_local_extrafield;\n    pfile_in_zip_read_info->pos_local_extrafield=0;\n    pfile_in_zip_read_info->raw=raw;\n\n    if (pfile_in_zip_read_info->read_buffer==NULL)\n    {\n        TRYFREE(pfile_in_zip_read_info);\n        return UNZ_INTERNALERROR;\n    }\n\n    pfile_in_zip_read_info->stream_initialised=0;\n\n    if (method!=NULL)\n        *method = (int)s->cur_file_info.compression_method;\n\n    if (level!=NULL)\n    {\n        *level = 6;\n        switch (s->cur_file_info.flag & 0x06)\n        {\n          case 6 : *level = 1; break;\n          case 4 : *level = 2; break;\n          case 2 : *level = 9; break;\n        }\n    }\n\n    if ((s->cur_file_info.compression_method!=0) &&\n/* #ifdef HAVE_BZIP2 */\n        (s->cur_file_info.compression_method!=Z_BZIP2ED) &&\n/* #endif */\n        (s->cur_file_info.compression_method!=Z_DEFLATED))\n\n        err=UNZ_BADZIPFILE;\n\n    pfile_in_zip_read_info->crc32_wait=s->cur_file_info.crc;\n    pfile_in_zip_read_info->crc32=0;\n    pfile_in_zip_read_info->total_out_64=0;\n    pfile_in_zip_read_info->compression_method = s->cur_file_info.compression_method;\n    pfile_in_zip_read_info->filestream=s->filestream;\n    pfile_in_zip_read_info->z_filefunc=s->z_filefunc;\n    pfile_in_zip_read_info->byte_before_the_zipfile=s->byte_before_the_zipfile;\n\n    pfile_in_zip_read_info->stream.total_out = 0;\n\n    if ((s->cur_file_info.compression_method==Z_BZIP2ED) && (!raw))\n    {\n#ifdef HAVE_BZIP2\n      pfile_in_zip_read_info->bstream.bzalloc = (void *(*) (void *, int, int))0;\n      pfile_in_zip_read_info->bstream.bzfree = (free_func)0;\n      pfile_in_zip_read_info->bstream.opaque = (voidpf)0;\n      pfile_in_zip_read_info->bstream.state = (voidpf)0;\n\n      pfile_in_zip_read_info->stream.zalloc = (alloc_func)0;\n      pfile_in_zip_read_info->stream.zfree = (free_func)0;\n      pfile_in_zip_read_info->stream.opaque = (voidpf)0;\n      pfile_in_zip_read_info->stream.next_in = (voidpf)0;\n      pfile_in_zip_read_info->stream.avail_in = 0;\n\n      err=BZ2_bzDecompressInit(&pfile_in_zip_read_info->bstream, 0, 0);\n      if (err == Z_OK)\n        pfile_in_zip_read_info->stream_initialised=Z_BZIP2ED;\n      else\n      {\n        TRYFREE(pfile_in_zip_read_info);\n        return err;\n      }\n#else\n      pfile_in_zip_read_info->raw=1;\n#endif\n    }\n    else if ((s->cur_file_info.compression_method==Z_DEFLATED) && (!raw))\n    {\n      pfile_in_zip_read_info->stream.zalloc = (alloc_func)0;\n      pfile_in_zip_read_info->stream.zfree = (free_func)0;\n      pfile_in_zip_read_info->stream.opaque = (voidpf)0;\n      pfile_in_zip_read_info->stream.next_in = 0;\n      pfile_in_zip_read_info->stream.avail_in = 0;\n\n      err=inflateInit2(&pfile_in_zip_read_info->stream, -MAX_WBITS);\n      if (err == Z_OK)\n        pfile_in_zip_read_info->stream_initialised=Z_DEFLATED;\n      else\n      {\n        TRYFREE(pfile_in_zip_read_info);\n        return err;\n      }\n        /* windowBits is passed < 0 to tell that there is no zlib header.\n         * Note that in this case inflate *requires* an extra \"dummy\" byte\n         * after the compressed stream in order to complete decompression and\n         * return Z_STREAM_END.\n         * In unzip, i don't wait absolutely Z_STREAM_END because I known the\n         * size of both compressed and uncompressed data\n         */\n    }\n    pfile_in_zip_read_info->rest_read_compressed =\n            s->cur_file_info.compressed_size ;\n    pfile_in_zip_read_info->rest_read_uncompressed =\n            s->cur_file_info.uncompressed_size ;\n\n\n    pfile_in_zip_read_info->pos_in_zipfile =\n            s->cur_file_info_internal.offset_curfile + SIZEZIPLOCALHEADER +\n              iSizeVar;\n\n    pfile_in_zip_read_info->stream.avail_in = (uInt)0;\n\n    s->pfile_in_zip_read = pfile_in_zip_read_info;\n                s->encrypted = 0;\n\n#    ifndef NOUNCRYPT\n    if (password != NULL)\n    {\n        int i;\n        s->pcrc_32_tab = get_crc_table();\n        init_keys(password,s->keys,s->pcrc_32_tab);\n        if (ZSEEK64(s->z_filefunc, s->filestream,\n                  s->pfile_in_zip_read->pos_in_zipfile +\n                     s->pfile_in_zip_read->byte_before_the_zipfile,\n                  SEEK_SET)!=0)\n            return UNZ_INTERNALERROR;\n        if(ZREAD64(s->z_filefunc, s->filestream,source, 12)<12)\n            return UNZ_INTERNALERROR;\n\n        for (i = 0; i<12; i++)\n            zdecode(s->keys,s->pcrc_32_tab,source[i]);\n\n        s->pfile_in_zip_read->pos_in_zipfile+=12;\n        s->encrypted=1;\n    }\n#    endif\n\n\n    return UNZ_OK;\n}\n\nextern int ZEXPORT unzOpenCurrentFile (unzFile file)\n{\n    return unzOpenCurrentFile3(file, NULL, NULL, 0, NULL);\n}\n\nextern int ZEXPORT unzOpenCurrentFilePassword (unzFile file, const char*  password)\n{\n    return unzOpenCurrentFile3(file, NULL, NULL, 0, password);\n}\n\nextern int ZEXPORT unzOpenCurrentFile2 (unzFile file, int* method, int* level, int raw)\n{\n    return unzOpenCurrentFile3(file, method, level, raw, NULL);\n}\n\n/** Addition for GDAL : START */\n\nextern ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64( unzFile file)\n{\n    unz64_s* s;\n    file_in_zip64_read_info_s* pfile_in_zip_read_info;\n    s=(unz64_s*)file;\n    if (file==NULL)\n        return 0; //UNZ_PARAMERROR;\n    pfile_in_zip_read_info=s->pfile_in_zip_read;\n    if (pfile_in_zip_read_info==NULL)\n        return 0; //UNZ_PARAMERROR;\n    return pfile_in_zip_read_info->pos_in_zipfile +\n                         pfile_in_zip_read_info->byte_before_the_zipfile;\n}\n\n/** Addition for GDAL : END */\n\n/*\n  Read bytes from the current file.\n  buf contain buffer where data must be copied\n  len the size of buf.\n\n  return the number of byte copied if somes bytes are copied\n  return 0 if the end of file was reached\n  return <0 with error code if there is an error\n    (UNZ_ERRNO for IO error, or zLib error for uncompress error)\n*/\nextern int ZEXPORT unzReadCurrentFile  (unzFile file, voidp buf, unsigned len)\n{\n    int err=UNZ_OK;\n    uInt iRead = 0;\n    unz64_s* s;\n    file_in_zip64_read_info_s* pfile_in_zip_read_info;\n    if (file==NULL)\n        return UNZ_PARAMERROR;\n    s=(unz64_s*)file;\n    pfile_in_zip_read_info=s->pfile_in_zip_read;\n\n    if (pfile_in_zip_read_info==NULL)\n        return UNZ_PARAMERROR;\n\n\n    if ((pfile_in_zip_read_info->read_buffer == NULL))\n        return UNZ_END_OF_LIST_OF_FILE;\n    if (len==0)\n        return 0;\n\n    pfile_in_zip_read_info->stream.next_out = (Bytef*)buf;\n\n    pfile_in_zip_read_info->stream.avail_out = (uInt)len;\n\n    if ((len>pfile_in_zip_read_info->rest_read_uncompressed) &&\n        (!(pfile_in_zip_read_info->raw)))\n        pfile_in_zip_read_info->stream.avail_out =\n            (uInt)pfile_in_zip_read_info->rest_read_uncompressed;\n\n    if ((len>pfile_in_zip_read_info->rest_read_compressed+\n           pfile_in_zip_read_info->stream.avail_in) &&\n         (pfile_in_zip_read_info->raw))\n        pfile_in_zip_read_info->stream.avail_out =\n            (uInt)pfile_in_zip_read_info->rest_read_compressed+\n            pfile_in_zip_read_info->stream.avail_in;\n\n    while (pfile_in_zip_read_info->stream.avail_out>0)\n    {\n        if ((pfile_in_zip_read_info->stream.avail_in==0) &&\n            (pfile_in_zip_read_info->rest_read_compressed>0))\n        {\n            uInt uReadThis = UNZ_BUFSIZE;\n            if (pfile_in_zip_read_info->rest_read_compressed<uReadThis)\n                uReadThis = (uInt)pfile_in_zip_read_info->rest_read_compressed;\n            if (uReadThis == 0)\n                return UNZ_EOF;\n            if (ZSEEK64(pfile_in_zip_read_info->z_filefunc,\n                      pfile_in_zip_read_info->filestream,\n                      pfile_in_zip_read_info->pos_in_zipfile +\n                         pfile_in_zip_read_info->byte_before_the_zipfile,\n                         ZLIB_FILEFUNC_SEEK_SET)!=0)\n                return UNZ_ERRNO;\n            if (ZREAD64(pfile_in_zip_read_info->z_filefunc,\n                      pfile_in_zip_read_info->filestream,\n                      pfile_in_zip_read_info->read_buffer,\n                      uReadThis)!=uReadThis)\n                return UNZ_ERRNO;\n\n\n#            ifndef NOUNCRYPT\n            if(s->encrypted)\n            {\n                uInt i;\n                for(i=0;i<uReadThis;i++)\n                  pfile_in_zip_read_info->read_buffer[i] =\n                      zdecode(s->keys,s->pcrc_32_tab,\n                              pfile_in_zip_read_info->read_buffer[i]);\n            }\n#            endif\n\n\n            pfile_in_zip_read_info->pos_in_zipfile += uReadThis;\n\n            pfile_in_zip_read_info->rest_read_compressed-=uReadThis;\n\n            pfile_in_zip_read_info->stream.next_in =\n                (Bytef*)pfile_in_zip_read_info->read_buffer;\n            pfile_in_zip_read_info->stream.avail_in = (uInt)uReadThis;\n        }\n\n        if ((pfile_in_zip_read_info->compression_method==0) || (pfile_in_zip_read_info->raw))\n        {\n            uInt uDoCopy,i ;\n\n            if ((pfile_in_zip_read_info->stream.avail_in == 0) &&\n                (pfile_in_zip_read_info->rest_read_compressed == 0))\n                return (iRead==0) ? UNZ_EOF : iRead;\n\n            if (pfile_in_zip_read_info->stream.avail_out <\n                            pfile_in_zip_read_info->stream.avail_in)\n                uDoCopy = pfile_in_zip_read_info->stream.avail_out ;\n            else\n                uDoCopy = pfile_in_zip_read_info->stream.avail_in ;\n\n            for (i=0;i<uDoCopy;i++)\n                *(pfile_in_zip_read_info->stream.next_out+i) =\n                        *(pfile_in_zip_read_info->stream.next_in+i);\n\n            pfile_in_zip_read_info->total_out_64 = pfile_in_zip_read_info->total_out_64 + uDoCopy;\n\n            pfile_in_zip_read_info->crc32 = crc32(pfile_in_zip_read_info->crc32,\n                                pfile_in_zip_read_info->stream.next_out,\n                                uDoCopy);\n            pfile_in_zip_read_info->rest_read_uncompressed-=uDoCopy;\n            pfile_in_zip_read_info->stream.avail_in -= uDoCopy;\n            pfile_in_zip_read_info->stream.avail_out -= uDoCopy;\n            pfile_in_zip_read_info->stream.next_out += uDoCopy;\n            pfile_in_zip_read_info->stream.next_in += uDoCopy;\n            pfile_in_zip_read_info->stream.total_out += uDoCopy;\n            iRead += uDoCopy;\n        }\n        else if (pfile_in_zip_read_info->compression_method==Z_BZIP2ED)\n        {\n#ifdef HAVE_BZIP2\n            uLong uTotalOutBefore,uTotalOutAfter;\n            const Bytef *bufBefore;\n            uLong uOutThis;\n\n            pfile_in_zip_read_info->bstream.next_in        = (char*)pfile_in_zip_read_info->stream.next_in;\n            pfile_in_zip_read_info->bstream.avail_in       = pfile_in_zip_read_info->stream.avail_in;\n            pfile_in_zip_read_info->bstream.total_in_lo32  = pfile_in_zip_read_info->stream.total_in;\n            pfile_in_zip_read_info->bstream.total_in_hi32  = 0;\n            pfile_in_zip_read_info->bstream.next_out       = (char*)pfile_in_zip_read_info->stream.next_out;\n            pfile_in_zip_read_info->bstream.avail_out      = pfile_in_zip_read_info->stream.avail_out;\n            pfile_in_zip_read_info->bstream.total_out_lo32 = pfile_in_zip_read_info->stream.total_out;\n            pfile_in_zip_read_info->bstream.total_out_hi32 = 0;\n\n            uTotalOutBefore = pfile_in_zip_read_info->bstream.total_out_lo32;\n            bufBefore = (const Bytef *)pfile_in_zip_read_info->bstream.next_out;\n\n            err=BZ2_bzDecompress(&pfile_in_zip_read_info->bstream);\n\n            uTotalOutAfter = pfile_in_zip_read_info->bstream.total_out_lo32;\n            uOutThis = uTotalOutAfter-uTotalOutBefore;\n\n            pfile_in_zip_read_info->total_out_64 = pfile_in_zip_read_info->total_out_64 + uOutThis;\n\n            pfile_in_zip_read_info->crc32 = crc32(pfile_in_zip_read_info->crc32,bufBefore, (uInt)(uOutThis));\n            pfile_in_zip_read_info->rest_read_uncompressed -= uOutThis;\n            iRead += (uInt)(uTotalOutAfter - uTotalOutBefore);\n\n            pfile_in_zip_read_info->stream.next_in   = (Bytef*)pfile_in_zip_read_info->bstream.next_in;\n            pfile_in_zip_read_info->stream.avail_in  = pfile_in_zip_read_info->bstream.avail_in;\n            pfile_in_zip_read_info->stream.total_in  = pfile_in_zip_read_info->bstream.total_in_lo32;\n            pfile_in_zip_read_info->stream.next_out  = (Bytef*)pfile_in_zip_read_info->bstream.next_out;\n            pfile_in_zip_read_info->stream.avail_out = pfile_in_zip_read_info->bstream.avail_out;\n            pfile_in_zip_read_info->stream.total_out = pfile_in_zip_read_info->bstream.total_out_lo32;\n\n            if (err==BZ_STREAM_END)\n              return (iRead==0) ? UNZ_EOF : iRead;\n            if (err!=BZ_OK)\n              break;\n#endif\n        } // end Z_BZIP2ED\n        else\n        {\n            ZPOS64_T uTotalOutBefore,uTotalOutAfter;\n            const Bytef *bufBefore;\n            ZPOS64_T uOutThis;\n            int flush=Z_SYNC_FLUSH;\n\n            uTotalOutBefore = pfile_in_zip_read_info->stream.total_out;\n            bufBefore = pfile_in_zip_read_info->stream.next_out;\n\n            /*\n            if ((pfile_in_zip_read_info->rest_read_uncompressed ==\n                     pfile_in_zip_read_info->stream.avail_out) &&\n                (pfile_in_zip_read_info->rest_read_compressed == 0))\n                flush = Z_FINISH;\n            */\n            err=inflate(&pfile_in_zip_read_info->stream,flush);\n\n            if ((err>=0) && (pfile_in_zip_read_info->stream.msg!=NULL))\n              err = Z_DATA_ERROR;\n\n            uTotalOutAfter = pfile_in_zip_read_info->stream.total_out;\n            uOutThis = uTotalOutAfter-uTotalOutBefore;\n\n            pfile_in_zip_read_info->total_out_64 = pfile_in_zip_read_info->total_out_64 + uOutThis;\n\n            pfile_in_zip_read_info->crc32 =\n                crc32(pfile_in_zip_read_info->crc32,bufBefore,\n                        (uInt)(uOutThis));\n\n            pfile_in_zip_read_info->rest_read_uncompressed -=\n                uOutThis;\n\n            iRead += (uInt)(uTotalOutAfter - uTotalOutBefore);\n\n            if (err==Z_STREAM_END)\n                return (iRead==0) ? UNZ_EOF : iRead;\n            if (err!=Z_OK)\n                break;\n        }\n    }\n\n    if (err==Z_OK)\n        return iRead;\n    return err;\n}\n\n\n/*\n  Give the current position in uncompressed data\n*/\nextern z_off_t ZEXPORT unztell (unzFile file)\n{\n    unz64_s* s;\n    file_in_zip64_read_info_s* pfile_in_zip_read_info;\n    if (file==NULL)\n        return UNZ_PARAMERROR;\n    s=(unz64_s*)file;\n    pfile_in_zip_read_info=s->pfile_in_zip_read;\n\n    if (pfile_in_zip_read_info==NULL)\n        return UNZ_PARAMERROR;\n\n    return (z_off_t)pfile_in_zip_read_info->stream.total_out;\n}\n\nextern ZPOS64_T ZEXPORT unztell64 (unzFile file)\n{\n\n    unz64_s* s;\n    file_in_zip64_read_info_s* pfile_in_zip_read_info;\n    if (file==NULL)\n        return (ZPOS64_T)-1;\n    s=(unz64_s*)file;\n    pfile_in_zip_read_info=s->pfile_in_zip_read;\n\n    if (pfile_in_zip_read_info==NULL)\n        return (ZPOS64_T)-1;\n\n    return pfile_in_zip_read_info->total_out_64;\n}\n\n\n/*\n  return 1 if the end of file was reached, 0 elsewhere\n*/\nextern int ZEXPORT unzeof (unzFile file)\n{\n    unz64_s* s;\n    file_in_zip64_read_info_s* pfile_in_zip_read_info;\n    if (file==NULL)\n        return UNZ_PARAMERROR;\n    s=(unz64_s*)file;\n    pfile_in_zip_read_info=s->pfile_in_zip_read;\n\n    if (pfile_in_zip_read_info==NULL)\n        return UNZ_PARAMERROR;\n\n    if (pfile_in_zip_read_info->rest_read_uncompressed == 0)\n        return 1;\n    else\n        return 0;\n}\n\n\n\n/*\nRead extra field from the current file (opened by unzOpenCurrentFile)\nThis is the local-header version of the extra field (sometimes, there is\nmore info in the local-header version than in the central-header)\n\n  if buf==NULL, it return the size of the local extra field that can be read\n\n  if buf!=NULL, len is the size of the buffer, the extra header is copied in\n    buf.\n  the return value is the number of bytes copied in buf, or (if <0)\n    the error code\n*/\nextern int ZEXPORT unzGetLocalExtrafield (unzFile file, voidp buf, unsigned len)\n{\n    unz64_s* s;\n    file_in_zip64_read_info_s* pfile_in_zip_read_info;\n    uInt read_now;\n    ZPOS64_T size_to_read;\n\n    if (file==NULL)\n        return UNZ_PARAMERROR;\n    s=(unz64_s*)file;\n    pfile_in_zip_read_info=s->pfile_in_zip_read;\n\n    if (pfile_in_zip_read_info==NULL)\n        return UNZ_PARAMERROR;\n\n    size_to_read = (pfile_in_zip_read_info->size_local_extrafield -\n                pfile_in_zip_read_info->pos_local_extrafield);\n\n    if (buf==NULL)\n        return (int)size_to_read;\n\n    if (len>size_to_read)\n        read_now = (uInt)size_to_read;\n    else\n        read_now = (uInt)len ;\n\n    if (read_now==0)\n        return 0;\n\n    if (ZSEEK64(pfile_in_zip_read_info->z_filefunc,\n              pfile_in_zip_read_info->filestream,\n              pfile_in_zip_read_info->offset_local_extrafield +\n              pfile_in_zip_read_info->pos_local_extrafield,\n              ZLIB_FILEFUNC_SEEK_SET)!=0)\n        return UNZ_ERRNO;\n\n    if (ZREAD64(pfile_in_zip_read_info->z_filefunc,\n              pfile_in_zip_read_info->filestream,\n              buf,read_now)!=read_now)\n        return UNZ_ERRNO;\n\n    return (int)read_now;\n}\n\n/*\n  Close the file in zip opened with unzipOpenCurrentFile\n  Return UNZ_CRCERROR if all the file was read but the CRC is not good\n*/\nextern int ZEXPORT unzCloseCurrentFile (unzFile file)\n{\n    int err=UNZ_OK;\n\n    unz64_s* s;\n    file_in_zip64_read_info_s* pfile_in_zip_read_info;\n    if (file==NULL)\n        return UNZ_PARAMERROR;\n    s=(unz64_s*)file;\n    pfile_in_zip_read_info=s->pfile_in_zip_read;\n\n    if (pfile_in_zip_read_info==NULL)\n        return UNZ_PARAMERROR;\n\n\n    if ((pfile_in_zip_read_info->rest_read_uncompressed == 0) &&\n        (!pfile_in_zip_read_info->raw))\n    {\n        if (pfile_in_zip_read_info->crc32 != pfile_in_zip_read_info->crc32_wait)\n            err=UNZ_CRCERROR;\n    }\n\n\n    TRYFREE(pfile_in_zip_read_info->read_buffer);\n    pfile_in_zip_read_info->read_buffer = NULL;\n    if (pfile_in_zip_read_info->stream_initialised == Z_DEFLATED)\n        inflateEnd(&pfile_in_zip_read_info->stream);\n#ifdef HAVE_BZIP2\n    else if (pfile_in_zip_read_info->stream_initialised == Z_BZIP2ED)\n        BZ2_bzDecompressEnd(&pfile_in_zip_read_info->bstream);\n#endif\n\n\n    pfile_in_zip_read_info->stream_initialised = 0;\n    TRYFREE(pfile_in_zip_read_info);\n\n    s->pfile_in_zip_read=NULL;\n\n    return err;\n}\n\n\n/*\n  Get the global comment string of the ZipFile, in the szComment buffer.\n  uSizeBuf is the size of the szComment buffer.\n  return the number of byte copied or an error code <0\n*/\nextern int ZEXPORT unzGetGlobalComment (unzFile file, char * szComment, uLong uSizeBuf)\n{\n    unz64_s* s;\n    uLong uReadThis ;\n    if (file==NULL)\n        return (int)UNZ_PARAMERROR;\n    s=(unz64_s*)file;\n\n    uReadThis = uSizeBuf;\n    if (uReadThis>s->gi.size_comment)\n        uReadThis = s->gi.size_comment;\n\n    if (ZSEEK64(s->z_filefunc,s->filestream,s->central_pos+22,ZLIB_FILEFUNC_SEEK_SET)!=0)\n        return UNZ_ERRNO;\n\n    if (uReadThis>0)\n    {\n      *szComment='\\0';\n      if (ZREAD64(s->z_filefunc,s->filestream,szComment,uReadThis)!=uReadThis)\n        return UNZ_ERRNO;\n    }\n\n    if ((szComment != NULL) && (uSizeBuf > s->gi.size_comment))\n        *(szComment+s->gi.size_comment)='\\0';\n    return (int)uReadThis;\n}\n\n/* Additions by RX '2004 */\nextern ZPOS64_T ZEXPORT unzGetOffset64(unzFile file)\n{\n    unz64_s* s;\n\n    if (file==NULL)\n          return 0; //UNZ_PARAMERROR;\n    s=(unz64_s*)file;\n    if (!s->current_file_ok)\n      return 0;\n    if (s->gi.number_entry != 0 && s->gi.number_entry != 0xffff)\n      if (s->num_file==s->gi.number_entry)\n         return 0;\n    return s->pos_in_central_dir;\n}\n\nextern uLong ZEXPORT unzGetOffset (unzFile file)\n{\n    ZPOS64_T offset64;\n\n    if (file==NULL)\n          return 0; //UNZ_PARAMERROR;\n    offset64 = unzGetOffset64(file);\n    return (uLong)offset64;\n}\n\nextern int ZEXPORT unzSetOffset64(unzFile file, ZPOS64_T pos)\n{\n    unz64_s* s;\n    int err;\n\n    if (file==NULL)\n        return UNZ_PARAMERROR;\n    s=(unz64_s*)file;\n\n    s->pos_in_central_dir = pos;\n    s->num_file = s->gi.number_entry;      /* hack */\n    err = unz64local_GetCurrentFileInfoInternal(file,&s->cur_file_info,\n                                              &s->cur_file_info_internal,\n                                              NULL,0,NULL,0,NULL,0);\n    s->current_file_ok = (err == UNZ_OK);\n    return err;\n}\n\nextern int ZEXPORT unzSetOffset (unzFile file, uLong pos)\n{\n    return unzSetOffset64(file,pos);\n}\n"
  },
  {
    "path": "Projects/Libraries/CSBase/Source/minizip/unzip.h",
    "content": "/* unzip.h -- IO for uncompress .zip files using zlib\n   Version 1.1, February 14h, 2010\n   part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )\n\n         Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html )\n\n         Modifications of Unzip for Zip64\n         Copyright (C) 2007-2008 Even Rouault\n\n         Modifications for Zip64 support on both zip and unzip\n         Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )\n\n         For more info read MiniZip_info.txt\n\n         ---------------------------------------------------------------------------------\n\n        Condition of use and distribution are the same than zlib :\n\n  This software is provided 'as-is', without any express or implied\n  warranty.  In no event will the authors be held liable for any damages\n  arising from the use of this software.\n\n  Permission is granted to anyone to use this software for any purpose,\n  including commercial applications, and to alter it and redistribute it\n  freely, subject to the following restrictions:\n\n  1. The origin of this software must not be misrepresented; you must not\n     claim that you wrote the original software. If you use this software\n     in a product, an acknowledgment in the product documentation would be\n     appreciated but is not required.\n  2. Altered source versions must be plainly marked as such, and must not be\n     misrepresented as being the original software.\n  3. This notice may not be removed or altered from any source distribution.\n\n  ---------------------------------------------------------------------------------\n\n        Changes\n\n        See header of unzip64.c\n\n*/\n\n#ifndef _unz64_H\n#define _unz64_H\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#ifndef _ZLIB_H\n#include \"zlib.h\"\n#endif\n\n#ifndef  _ZLIBIOAPI_H\n#include \"ioapi.h\"\n#endif\n\n#ifdef HAVE_BZIP2\n#include \"bzlib.h\"\n#endif\n\n#define Z_BZIP2ED 12\n\n#if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP)\n/* like the STRICT of WIN32, we define a pointer that cannot be converted\n    from (void*) without cast */\ntypedef struct TagunzFile__ { int unused; } unzFile__;\ntypedef unzFile__ *unzFile;\n#else\ntypedef voidp unzFile;\n#endif\n\n\n#define UNZ_OK                          (0)\n#define UNZ_END_OF_LIST_OF_FILE         (-100)\n#define UNZ_ERRNO                       (Z_ERRNO)\n#define UNZ_EOF                         (0)\n#define UNZ_PARAMERROR                  (-102)\n#define UNZ_BADZIPFILE                  (-103)\n#define UNZ_INTERNALERROR               (-104)\n#define UNZ_CRCERROR                    (-105)\n\n/* tm_unz contain date/time info */\ntypedef struct tm_unz_s\n{\n    uInt tm_sec;            /* seconds after the minute - [0,59] */\n    uInt tm_min;            /* minutes after the hour - [0,59] */\n    uInt tm_hour;           /* hours since midnight - [0,23] */\n    uInt tm_mday;           /* day of the month - [1,31] */\n    uInt tm_mon;            /* months since January - [0,11] */\n    uInt tm_year;           /* years - [1980..2044] */\n} tm_unz;\n\n/* unz_global_info structure contain global data about the ZIPfile\n   These data comes from the end of central dir */\ntypedef struct unz_global_info64_s\n{\n    ZPOS64_T number_entry;         /* total number of entries in\n                                     the central dir on this disk */\n    uLong size_comment;         /* size of the global comment of the zipfile */\n} unz_global_info64;\n\ntypedef struct unz_global_info_s\n{\n    uLong number_entry;         /* total number of entries in\n                                     the central dir on this disk */\n    uLong size_comment;         /* size of the global comment of the zipfile */\n} unz_global_info;\n\n/* unz_file_info contain information about a file in the zipfile */\ntypedef struct unz_file_info64_s\n{\n    uLong version;              /* version made by                 2 bytes */\n    uLong version_needed;       /* version needed to extract       2 bytes */\n    uLong flag;                 /* general purpose bit flag        2 bytes */\n    uLong compression_method;   /* compression method              2 bytes */\n    uLong dosDate;              /* last mod file date in Dos fmt   4 bytes */\n    uLong crc;                  /* crc-32                          4 bytes */\n    ZPOS64_T compressed_size;   /* compressed size                 8 bytes */\n    ZPOS64_T uncompressed_size; /* uncompressed size               8 bytes */\n    uLong size_filename;        /* filename length                 2 bytes */\n    uLong size_file_extra;      /* extra field length              2 bytes */\n    uLong size_file_comment;    /* file comment length             2 bytes */\n\n    uLong disk_num_start;       /* disk number start               2 bytes */\n    uLong internal_fa;          /* internal file attributes        2 bytes */\n    uLong external_fa;          /* external file attributes        4 bytes */\n\n    tm_unz tmu_date;\n} unz_file_info64;\n\ntypedef struct unz_file_info_s\n{\n    uLong version;              /* version made by                 2 bytes */\n    uLong version_needed;       /* version needed to extract       2 bytes */\n    uLong flag;                 /* general purpose bit flag        2 bytes */\n    uLong compression_method;   /* compression method              2 bytes */\n    uLong dosDate;              /* last mod file date in Dos fmt   4 bytes */\n    uLong crc;                  /* crc-32                          4 bytes */\n    uLong compressed_size;      /* compressed size                 4 bytes */\n    uLong uncompressed_size;    /* uncompressed size               4 bytes */\n    uLong size_filename;        /* filename length                 2 bytes */\n    uLong size_file_extra;      /* extra field length              2 bytes */\n    uLong size_file_comment;    /* file comment length             2 bytes */\n\n    uLong disk_num_start;       /* disk number start               2 bytes */\n    uLong internal_fa;          /* internal file attributes        2 bytes */\n    uLong external_fa;          /* external file attributes        4 bytes */\n\n    tm_unz tmu_date;\n} unz_file_info;\n\nextern int ZEXPORT unzStringFileNameCompare OF ((const char* fileName1,\n                                                 const char* fileName2,\n                                                 int iCaseSensitivity));\n/*\n   Compare two filename (fileName1,fileName2).\n   If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp)\n   If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi\n                                or strcasecmp)\n   If iCaseSenisivity = 0, case sensitivity is defaut of your operating system\n    (like 1 on Unix, 2 on Windows)\n*/\n\n\nextern unzFile ZEXPORT unzOpen OF((const char *path));\nextern unzFile ZEXPORT unzOpen64 OF((const void *path));\n/*\n  Open a Zip file. path contain the full pathname (by example,\n     on a Windows XP computer \"c:\\\\zlib\\\\zlib113.zip\" or on an Unix computer\n     \"zlib/zlib113.zip\".\n     If the zipfile cannot be opened (file don't exist or in not valid), the\n       return value is NULL.\n     Else, the return value is a unzFile Handle, usable with other function\n       of this unzip package.\n     the \"64\" function take a const void* pointer, because the path is just the\n       value passed to the open64_file_func callback.\n     Under Windows, if UNICODE is defined, using fill_fopen64_filefunc, the path\n       is a pointer to a wide unicode string (LPCTSTR is LPCWSTR), so const char*\n       does not describe the reality\n*/\n\n\nextern unzFile ZEXPORT unzOpen2 OF((const char *path,\n                                    zlib_filefunc_def* pzlib_filefunc_def));\n/*\n   Open a Zip file, like unzOpen, but provide a set of file low level API\n      for read/write the zip file (see ioapi.h)\n*/\n\nextern unzFile ZEXPORT unzOpen2_64 OF((const void *path,\n                                    zlib_filefunc64_def* pzlib_filefunc_def));\n/*\n   Open a Zip file, like unz64Open, but provide a set of file low level API\n      for read/write the zip file (see ioapi.h)\n*/\n\nextern int ZEXPORT unzClose OF((unzFile file));\n/*\n  Close a ZipFile opened with unzipOpen.\n  If there is files inside the .Zip opened with unzOpenCurrentFile (see later),\n    these files MUST be closed with unzipCloseCurrentFile before call unzipClose.\n  return UNZ_OK if there is no problem. */\n\nextern int ZEXPORT unzGetGlobalInfo OF((unzFile file,\n                                        unz_global_info *pglobal_info));\n\nextern int ZEXPORT unzGetGlobalInfo64 OF((unzFile file,\n                                        unz_global_info64 *pglobal_info));\n/*\n  Write info about the ZipFile in the *pglobal_info structure.\n  No preparation of the structure is needed\n  return UNZ_OK if there is no problem. */\n\n\nextern int ZEXPORT unzGetGlobalComment OF((unzFile file,\n                                           char *szComment,\n                                           uLong uSizeBuf));\n/*\n  Get the global comment string of the ZipFile, in the szComment buffer.\n  uSizeBuf is the size of the szComment buffer.\n  return the number of byte copied or an error code <0\n*/\n\n\n/***************************************************************************/\n/* Unzip package allow you browse the directory of the zipfile */\n\nextern int ZEXPORT unzGoToFirstFile OF((unzFile file));\n/*\n  Set the current file of the zipfile to the first file.\n  return UNZ_OK if there is no problem\n*/\n\nextern int ZEXPORT unzGoToNextFile OF((unzFile file));\n/*\n  Set the current file of the zipfile to the next file.\n  return UNZ_OK if there is no problem\n  return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest.\n*/\n\nextern int ZEXPORT unzLocateFile OF((unzFile file,\n                     const char *szFileName,\n                     int iCaseSensitivity));\n/*\n  Try locate the file szFileName in the zipfile.\n  For the iCaseSensitivity signification, see unzStringFileNameCompare\n\n  return value :\n  UNZ_OK if the file is found. It becomes the current file.\n  UNZ_END_OF_LIST_OF_FILE if the file is not found\n*/\n\n\n/* ****************************************** */\n/* Ryan supplied functions */\n/* unz_file_info contain information about a file in the zipfile */\ntypedef struct unz_file_pos_s\n{\n    uLong pos_in_zip_directory;   /* offset in zip file directory */\n    uLong num_of_file;            /* # of file */\n} unz_file_pos;\n\nextern int ZEXPORT unzGetFilePos(\n    unzFile file,\n    unz_file_pos* file_pos);\n\nextern int ZEXPORT unzGoToFilePos(\n    unzFile file,\n    unz_file_pos* file_pos);\n\ntypedef struct unz64_file_pos_s\n{\n    ZPOS64_T pos_in_zip_directory;   /* offset in zip file directory */\n    ZPOS64_T num_of_file;            /* # of file */\n} unz64_file_pos;\n\nextern int ZEXPORT unzGetFilePos64(\n    unzFile file,\n    unz64_file_pos* file_pos);\n\nextern int ZEXPORT unzGoToFilePos64(\n    unzFile file,\n    const unz64_file_pos* file_pos);\n\n/* ****************************************** */\n\nextern int ZEXPORT unzGetCurrentFileInfo64 OF((unzFile file,\n                         unz_file_info64 *pfile_info,\n                         char *szFileName,\n                         uLong fileNameBufferSize,\n                         void *extraField,\n                         uLong extraFieldBufferSize,\n                         char *szComment,\n                         uLong commentBufferSize));\n\nextern int ZEXPORT unzGetCurrentFileInfo OF((unzFile file,\n                         unz_file_info *pfile_info,\n                         char *szFileName,\n                         uLong fileNameBufferSize,\n                         void *extraField,\n                         uLong extraFieldBufferSize,\n                         char *szComment,\n                         uLong commentBufferSize));\n/*\n  Get Info about the current file\n  if pfile_info!=NULL, the *pfile_info structure will contain somes info about\n        the current file\n  if szFileName!=NULL, the filemane string will be copied in szFileName\n            (fileNameBufferSize is the size of the buffer)\n  if extraField!=NULL, the extra field information will be copied in extraField\n            (extraFieldBufferSize is the size of the buffer).\n            This is the Central-header version of the extra field\n  if szComment!=NULL, the comment string of the file will be copied in szComment\n            (commentBufferSize is the size of the buffer)\n*/\n\n\n/** Addition for GDAL : START */\n\nextern ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64 OF((unzFile file));\n\n/** Addition for GDAL : END */\n\n\n/***************************************************************************/\n/* for reading the content of the current zipfile, you can open it, read data\n   from it, and close it (you can close it before reading all the file)\n   */\n\nextern int ZEXPORT unzOpenCurrentFile OF((unzFile file));\n/*\n  Open for reading data the current file in the zipfile.\n  If there is no error, the return value is UNZ_OK.\n*/\n\nextern int ZEXPORT unzOpenCurrentFilePassword OF((unzFile file,\n                                                  const char* password));\n/*\n  Open for reading data the current file in the zipfile.\n  password is a crypting password\n  If there is no error, the return value is UNZ_OK.\n*/\n\nextern int ZEXPORT unzOpenCurrentFile2 OF((unzFile file,\n                                           int* method,\n                                           int* level,\n                                           int raw));\n/*\n  Same than unzOpenCurrentFile, but open for read raw the file (not uncompress)\n    if raw==1\n  *method will receive method of compression, *level will receive level of\n     compression\n  note : you can set level parameter as NULL (if you did not want known level,\n         but you CANNOT set method parameter as NULL\n*/\n\nextern int ZEXPORT unzOpenCurrentFile3 OF((unzFile file,\n                                           int* method,\n                                           int* level,\n                                           int raw,\n                                           const char* password));\n/*\n  Same than unzOpenCurrentFile, but open for read raw the file (not uncompress)\n    if raw==1\n  *method will receive method of compression, *level will receive level of\n     compression\n  note : you can set level parameter as NULL (if you did not want known level,\n         but you CANNOT set method parameter as NULL\n*/\n\n\nextern int ZEXPORT unzCloseCurrentFile OF((unzFile file));\n/*\n  Close the file in zip opened with unzOpenCurrentFile\n  Return UNZ_CRCERROR if all the file was read but the CRC is not good\n*/\n\nextern int ZEXPORT unzReadCurrentFile OF((unzFile file,\n                      voidp buf,\n                      unsigned len));\n/*\n  Read bytes from the current file (opened by unzOpenCurrentFile)\n  buf contain buffer where data must be copied\n  len the size of buf.\n\n  return the number of byte copied if somes bytes are copied\n  return 0 if the end of file was reached\n  return <0 with error code if there is an error\n    (UNZ_ERRNO for IO error, or zLib error for uncompress error)\n*/\n\nextern z_off_t ZEXPORT unztell OF((unzFile file));\n\nextern ZPOS64_T ZEXPORT unztell64 OF((unzFile file));\n/*\n  Give the current position in uncompressed data\n*/\n\nextern int ZEXPORT unzeof OF((unzFile file));\n/*\n  return 1 if the end of file was reached, 0 elsewhere\n*/\n\nextern int ZEXPORT unzGetLocalExtrafield OF((unzFile file,\n                                             voidp buf,\n                                             unsigned len));\n/*\n  Read extra field from the current file (opened by unzOpenCurrentFile)\n  This is the local-header version of the extra field (sometimes, there is\n    more info in the local-header version than in the central-header)\n\n  if buf==NULL, it return the size of the local extra field\n\n  if buf!=NULL, len is the size of the buffer, the extra header is copied in\n    buf.\n  the return value is the number of bytes copied in buf, or (if <0)\n    the error code\n*/\n\n/***************************************************************************/\n\n/* Get the current file offset */\nextern ZPOS64_T ZEXPORT unzGetOffset64 (unzFile file);\nextern uLong ZEXPORT unzGetOffset (unzFile file);\n\n/* Set the current file offset */\nextern int ZEXPORT unzSetOffset64 (unzFile file, ZPOS64_T pos);\nextern int ZEXPORT unzSetOffset (unzFile file, uLong pos);\n\n\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* _unz64_H */\n"
  },
  {
    "path": "Projects/Libraries/CSBase/Source/minizip/zip.c",
    "content": "/* zip.c -- IO on .zip files using zlib\n   Version 1.1, February 14h, 2010\n   part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )\n\n         Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html )\n\n         Modifications for Zip64 support\n         Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )\n\n         For more info read MiniZip_info.txt\n\n         Changes\n   Oct-2009 - Mathias Svensson - Remove old C style function prototypes\n   Oct-2009 - Mathias Svensson - Added Zip64 Support when creating new file archives\n   Oct-2009 - Mathias Svensson - Did some code cleanup and refactoring to get better overview of some functions.\n   Oct-2009 - Mathias Svensson - Added zipRemoveExtraInfoBlock to strip extra field data from its ZIP64 data\n                                 It is used when recreting zip archive with RAW when deleting items from a zip.\n                                 ZIP64 data is automaticly added to items that needs it, and existing ZIP64 data need to be removed.\n   Oct-2009 - Mathias Svensson - Added support for BZIP2 as compression mode (bzip2 lib is required)\n   Jan-2010 - back to unzip and minizip 1.0 name scheme, with compatibility layer\n\n*/\n\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <time.h>\n#include \"zlib.h\"\n#include \"zip.h\"\n\n#ifdef STDC\n#  include <stddef.h>\n#  include <string.h>\n#  include <stdlib.h>\n#endif\n#ifdef NO_ERRNO_H\n    extern int errno;\n#else\n#   include <errno.h>\n#endif\n\n\n#ifndef local\n#  define local static\n#endif\n/* compile with -Dlocal if your debugger can't find static symbols */\n\n#ifndef VERSIONMADEBY\n# define VERSIONMADEBY   (0x0) /* platform depedent */\n#endif\n\n#ifndef Z_BUFSIZE\n#define Z_BUFSIZE (64*1024) //(16384)\n#endif\n\n#ifndef Z_MAXFILENAMEINZIP\n#define Z_MAXFILENAMEINZIP (256)\n#endif\n\n#ifndef ALLOC\n# define ALLOC(size) (malloc(size))\n#endif\n#ifndef TRYFREE\n# define TRYFREE(p) {if (p) free(p);}\n#endif\n\n/*\n#define SIZECENTRALDIRITEM (0x2e)\n#define SIZEZIPLOCALHEADER (0x1e)\n*/\n\n/* I've found an old Unix (a SunOS 4.1.3_U1) without all SEEK_* defined.... */\n\n\n// NOT sure that this work on ALL platform\n#define MAKEULONG64(a, b) ((ZPOS64_T)(((unsigned long)(a)) | ((ZPOS64_T)((unsigned long)(b))) << 32))\n\n#ifndef SEEK_CUR\n#define SEEK_CUR    1\n#endif\n\n#ifndef SEEK_END\n#define SEEK_END    2\n#endif\n\n#ifndef SEEK_SET\n#define SEEK_SET    0\n#endif\n\n#ifndef DEF_MEM_LEVEL\n#if MAX_MEM_LEVEL >= 8\n#  define DEF_MEM_LEVEL 8\n#else\n#  define DEF_MEM_LEVEL  MAX_MEM_LEVEL\n#endif\n#endif\nconst char zip_copyright[] =\" zip 1.01 Copyright 1998-2004 Gilles Vollant - http://www.winimage.com/zLibDll\";\n\n\n#define SIZEDATA_INDATABLOCK (4096-(4*4))\n\n#define LOCALHEADERMAGIC    (0x04034b50)\n#define CENTRALHEADERMAGIC  (0x02014b50)\n#define ENDHEADERMAGIC      (0x06054b50)\n#define ZIP64ENDHEADERMAGIC      (0x6064b50)\n#define ZIP64ENDLOCHEADERMAGIC   (0x7064b50)\n\n#define FLAG_LOCALHEADER_OFFSET (0x06)\n#define CRC_LOCALHEADER_OFFSET  (0x0e)\n\n#define SIZECENTRALHEADER (0x2e) /* 46 */\n\ntypedef struct linkedlist_datablock_internal_s\n{\n  struct linkedlist_datablock_internal_s* next_datablock;\n  uLong  avail_in_this_block;\n  uLong  filled_in_this_block;\n  uLong  unused; /* for future use and alignement */\n  unsigned char data[SIZEDATA_INDATABLOCK];\n} linkedlist_datablock_internal;\n\ntypedef struct linkedlist_data_s\n{\n    linkedlist_datablock_internal* first_block;\n    linkedlist_datablock_internal* last_block;\n} linkedlist_data;\n\n\ntypedef struct\n{\n    z_stream stream;            /* zLib stream structure for inflate */\n#ifdef HAVE_BZIP2\n    bz_stream bstream;          /* bzLib stream structure for bziped */\n#endif\n\n    int  stream_initialised;    /* 1 is stream is initialised */\n    uInt pos_in_buffered_data;  /* last written byte in buffered_data */\n\n    ZPOS64_T pos_local_header;     /* offset of the local header of the file\n                                     currenty writing */\n    char* central_header;       /* central header data for the current file */\n    uLong size_centralExtra;\n    uLong size_centralheader;   /* size of the central header for cur file */\n    uLong size_centralExtraFree; /* Extra bytes allocated to the centralheader but that are not used */\n    uLong flag;                 /* flag of the file currently writing */\n\n    int  method;                /* compression method of file currenty wr.*/\n    int  raw;                   /* 1 for directly writing raw data */\n    Byte buffered_data[Z_BUFSIZE];/* buffer contain compressed data to be writ*/\n    uLong dosDate;\n    uLong crc32;\n    int  encrypt;\n    int  zip64;               /* Add ZIP64 extened information in the extra field */\n    ZPOS64_T pos_zip64extrainfo;\n    ZPOS64_T totalCompressedData;\n    ZPOS64_T totalUncompressedData;\n#ifndef NOCRYPT\n    unsigned long keys[3];     /* keys defining the pseudo-random sequence */\n    const unsigned long* pcrc_32_tab;\n    int crypt_header_size;\n#endif\n} curfile64_info;\n\ntypedef struct\n{\n    zlib_filefunc64_32_def z_filefunc;\n    voidpf filestream;        /* io structore of the zipfile */\n    linkedlist_data central_dir;/* datablock with central dir in construction*/\n    int  in_opened_file_inzip;  /* 1 if a file in the zip is currently writ.*/\n    curfile64_info ci;            /* info on the file curretly writing */\n\n    ZPOS64_T begin_pos;            /* position of the beginning of the zipfile */\n    ZPOS64_T add_position_when_writting_offset;\n    ZPOS64_T number_entry;\n\n#ifndef NO_ADDFILEINEXISTINGZIP\n    char *globalcomment;\n#endif\n\n} zip64_internal;\n\n\n#ifndef NOCRYPT\n#define INCLUDECRYPTINGCODE_IFCRYPTALLOWED\n#include \"crypt.h\"\n#endif\n\nlocal linkedlist_datablock_internal* allocate_new_datablock()\n{\n    linkedlist_datablock_internal* ldi;\n    ldi = (linkedlist_datablock_internal*)\n                 ALLOC(sizeof(linkedlist_datablock_internal));\n    if (ldi!=NULL)\n    {\n        ldi->next_datablock = NULL ;\n        ldi->filled_in_this_block = 0 ;\n        ldi->avail_in_this_block = SIZEDATA_INDATABLOCK ;\n    }\n    return ldi;\n}\n\nlocal void free_datablock(linkedlist_datablock_internal* ldi)\n{\n    while (ldi!=NULL)\n    {\n        linkedlist_datablock_internal* ldinext = ldi->next_datablock;\n        TRYFREE(ldi);\n        ldi = ldinext;\n    }\n}\n\nlocal void init_linkedlist(linkedlist_data* ll)\n{\n    ll->first_block = ll->last_block = NULL;\n}\n\nlocal void free_linkedlist(linkedlist_data* ll)\n{\n    free_datablock(ll->first_block);\n    ll->first_block = ll->last_block = NULL;\n}\n\n\nlocal int add_data_in_datablock(linkedlist_data* ll, const void* buf, uLong len)\n{\n    linkedlist_datablock_internal* ldi;\n    const unsigned char* from_copy;\n\n    if (ll==NULL)\n        return ZIP_INTERNALERROR;\n\n    if (ll->last_block == NULL)\n    {\n        ll->first_block = ll->last_block = allocate_new_datablock();\n        if (ll->first_block == NULL)\n            return ZIP_INTERNALERROR;\n    }\n\n    ldi = ll->last_block;\n    from_copy = (unsigned char*)buf;\n\n    while (len>0)\n    {\n        uInt copy_this;\n        uInt i;\n        unsigned char* to_copy;\n\n        if (ldi->avail_in_this_block==0)\n        {\n            ldi->next_datablock = allocate_new_datablock();\n            if (ldi->next_datablock == NULL)\n                return ZIP_INTERNALERROR;\n            ldi = ldi->next_datablock ;\n            ll->last_block = ldi;\n        }\n\n        if (ldi->avail_in_this_block < len)\n            copy_this = (uInt)ldi->avail_in_this_block;\n        else\n            copy_this = (uInt)len;\n\n        to_copy = &(ldi->data[ldi->filled_in_this_block]);\n\n        for (i=0;i<copy_this;i++)\n            *(to_copy+i)=*(from_copy+i);\n\n        ldi->filled_in_this_block += copy_this;\n        ldi->avail_in_this_block -= copy_this;\n        from_copy += copy_this ;\n        len -= copy_this;\n    }\n    return ZIP_OK;\n}\n\n\n\n/****************************************************************************/\n\n#ifndef NO_ADDFILEINEXISTINGZIP\n/* ===========================================================================\n   Inputs a long in LSB order to the given file\n   nbByte == 1, 2 ,4 or 8 (byte, short or long, ZPOS64_T)\n*/\n\nlocal int zip64local_putValue OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, ZPOS64_T x, int nbByte));\nlocal int zip64local_putValue (const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, ZPOS64_T x, int nbByte)\n{\n    unsigned char buf[8];\n    int n;\n    for (n = 0; n < nbByte; n++)\n    {\n        buf[n] = (unsigned char)(x & 0xff);\n        x >>= 8;\n    }\n    if (x != 0)\n      {     /* data overflow - hack for ZIP64 (X Roche) */\n      for (n = 0; n < nbByte; n++)\n        {\n          buf[n] = 0xff;\n        }\n      }\n\n    if (ZWRITE64(*pzlib_filefunc_def,filestream,buf,nbByte)!=(uLong)nbByte)\n        return ZIP_ERRNO;\n    else\n        return ZIP_OK;\n}\n\nlocal void zip64local_putValue_inmemory OF((void* dest, ZPOS64_T x, int nbByte));\nlocal void zip64local_putValue_inmemory (void* dest, ZPOS64_T x, int nbByte)\n{\n    unsigned char* buf=(unsigned char*)dest;\n    int n;\n    for (n = 0; n < nbByte; n++) {\n        buf[n] = (unsigned char)(x & 0xff);\n        x >>= 8;\n    }\n\n    if (x != 0)\n    {     /* data overflow - hack for ZIP64 */\n       for (n = 0; n < nbByte; n++)\n       {\n          buf[n] = 0xff;\n       }\n    }\n}\n\n/****************************************************************************/\n\n\nlocal uLong zip64local_TmzDateToDosDate(const tm_zip* ptm)\n{\n    uLong year = (uLong)ptm->tm_year;\n    if (year>=1980)\n        year-=1980;\n    else if (year>=80)\n        year-=80;\n    return\n      (uLong) (((ptm->tm_mday) + (32 * (ptm->tm_mon+1)) + (512 * year)) << 16) |\n        ((ptm->tm_sec/2) + (32* ptm->tm_min) + (2048 * (uLong)ptm->tm_hour));\n}\n\n\n/****************************************************************************/\n\nlocal int zip64local_getByte OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, int *pi));\n\nlocal int zip64local_getByte(const zlib_filefunc64_32_def* pzlib_filefunc_def,voidpf filestream,int* pi)\n{\n    unsigned char c;\n    int err = (int)ZREAD64(*pzlib_filefunc_def,filestream,&c,1);\n    if (err==1)\n    {\n        *pi = (int)c;\n        return ZIP_OK;\n    }\n    else\n    {\n        if (ZERROR64(*pzlib_filefunc_def,filestream))\n            return ZIP_ERRNO;\n        else\n            return ZIP_EOF;\n    }\n}\n\n\n/* ===========================================================================\n   Reads a long in LSB order from the given gz_stream. Sets\n*/\nlocal int zip64local_getShort OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, uLong *pX));\n\nlocal int zip64local_getShort (const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, uLong* pX)\n{\n    uLong x ;\n    int i = 0;\n    int err;\n\n    err = zip64local_getByte(pzlib_filefunc_def,filestream,&i);\n    x = (uLong)i;\n\n    if (err==ZIP_OK)\n        err = zip64local_getByte(pzlib_filefunc_def,filestream,&i);\n    x += ((uLong)i)<<8;\n\n    if (err==ZIP_OK)\n        *pX = x;\n    else\n        *pX = 0;\n    return err;\n}\n\nlocal int zip64local_getLong OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, uLong *pX));\n\nlocal int zip64local_getLong (const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, uLong* pX)\n{\n    uLong x ;\n    int i = 0;\n    int err;\n\n    err = zip64local_getByte(pzlib_filefunc_def,filestream,&i);\n    x = (uLong)i;\n\n    if (err==ZIP_OK)\n        err = zip64local_getByte(pzlib_filefunc_def,filestream,&i);\n    x += ((uLong)i)<<8;\n\n    if (err==ZIP_OK)\n        err = zip64local_getByte(pzlib_filefunc_def,filestream,&i);\n    x += ((uLong)i)<<16;\n\n    if (err==ZIP_OK)\n        err = zip64local_getByte(pzlib_filefunc_def,filestream,&i);\n    x += ((uLong)i)<<24;\n\n    if (err==ZIP_OK)\n        *pX = x;\n    else\n        *pX = 0;\n    return err;\n}\n\nlocal int zip64local_getLong64 OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, ZPOS64_T *pX));\n\n\nlocal int zip64local_getLong64 (const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, ZPOS64_T *pX)\n{\n  ZPOS64_T x;\n  int i = 0;\n  int err;\n\n  err = zip64local_getByte(pzlib_filefunc_def,filestream,&i);\n  x = (ZPOS64_T)i;\n\n  if (err==ZIP_OK)\n    err = zip64local_getByte(pzlib_filefunc_def,filestream,&i);\n  x += ((ZPOS64_T)i)<<8;\n\n  if (err==ZIP_OK)\n    err = zip64local_getByte(pzlib_filefunc_def,filestream,&i);\n  x += ((ZPOS64_T)i)<<16;\n\n  if (err==ZIP_OK)\n    err = zip64local_getByte(pzlib_filefunc_def,filestream,&i);\n  x += ((ZPOS64_T)i)<<24;\n\n  if (err==ZIP_OK)\n    err = zip64local_getByte(pzlib_filefunc_def,filestream,&i);\n  x += ((ZPOS64_T)i)<<32;\n\n  if (err==ZIP_OK)\n    err = zip64local_getByte(pzlib_filefunc_def,filestream,&i);\n  x += ((ZPOS64_T)i)<<40;\n\n  if (err==ZIP_OK)\n    err = zip64local_getByte(pzlib_filefunc_def,filestream,&i);\n  x += ((ZPOS64_T)i)<<48;\n\n  if (err==ZIP_OK)\n    err = zip64local_getByte(pzlib_filefunc_def,filestream,&i);\n  x += ((ZPOS64_T)i)<<56;\n\n  if (err==ZIP_OK)\n    *pX = x;\n  else\n    *pX = 0;\n\n  return err;\n}\n\n#ifndef BUFREADCOMMENT\n#define BUFREADCOMMENT (0x400)\n#endif\n/*\n  Locate the Central directory of a zipfile (at the end, just before\n    the global comment)\n*/\nlocal ZPOS64_T zip64local_SearchCentralDir OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream));\n\nlocal ZPOS64_T zip64local_SearchCentralDir(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream)\n{\n  unsigned char* buf;\n  ZPOS64_T uSizeFile;\n  ZPOS64_T uBackRead;\n  ZPOS64_T uMaxBack=0xffff; /* maximum size of global comment */\n  ZPOS64_T uPosFound=0;\n\n  if (ZSEEK64(*pzlib_filefunc_def,filestream,0,ZLIB_FILEFUNC_SEEK_END) != 0)\n    return 0;\n\n\n  uSizeFile = ZTELL64(*pzlib_filefunc_def,filestream);\n\n  if (uMaxBack>uSizeFile)\n    uMaxBack = uSizeFile;\n\n  buf = (unsigned char*)ALLOC(BUFREADCOMMENT+4);\n  if (buf==NULL)\n    return 0;\n\n  uBackRead = 4;\n  while (uBackRead<uMaxBack)\n  {\n    uLong uReadSize;\n    ZPOS64_T uReadPos ;\n    int i;\n    if (uBackRead+BUFREADCOMMENT>uMaxBack)\n      uBackRead = uMaxBack;\n    else\n      uBackRead+=BUFREADCOMMENT;\n    uReadPos = uSizeFile-uBackRead ;\n\n    uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ?\n      (BUFREADCOMMENT+4) : (uLong)(uSizeFile-uReadPos);\n    if (ZSEEK64(*pzlib_filefunc_def,filestream,uReadPos,ZLIB_FILEFUNC_SEEK_SET)!=0)\n      break;\n\n    if (ZREAD64(*pzlib_filefunc_def,filestream,buf,uReadSize)!=uReadSize)\n      break;\n\n    for (i=(int)uReadSize-3; (i--)>0;)\n      if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) &&\n        ((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06))\n      {\n        uPosFound = uReadPos+i;\n        break;\n      }\n\n      if (uPosFound!=0)\n        break;\n  }\n  TRYFREE(buf);\n  return uPosFound;\n}\n\n/*\nLocate the End of Zip64 Central directory locator and from there find the CD of a zipfile (at the end, just before\nthe global comment)\n*/\nlocal ZPOS64_T zip64local_SearchCentralDir64 OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream));\n\nlocal ZPOS64_T zip64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream)\n{\n  unsigned char* buf;\n  ZPOS64_T uSizeFile;\n  ZPOS64_T uBackRead;\n  ZPOS64_T uMaxBack=0xffff; /* maximum size of global comment */\n  ZPOS64_T uPosFound=0;\n  uLong uL;\n  ZPOS64_T relativeOffset;\n\n  if (ZSEEK64(*pzlib_filefunc_def,filestream,0,ZLIB_FILEFUNC_SEEK_END) != 0)\n    return 0;\n\n  uSizeFile = ZTELL64(*pzlib_filefunc_def,filestream);\n\n  if (uMaxBack>uSizeFile)\n    uMaxBack = uSizeFile;\n\n  buf = (unsigned char*)ALLOC(BUFREADCOMMENT+4);\n  if (buf==NULL)\n    return 0;\n\n  uBackRead = 4;\n  while (uBackRead<uMaxBack)\n  {\n    uLong uReadSize;\n    ZPOS64_T uReadPos;\n    int i;\n    if (uBackRead+BUFREADCOMMENT>uMaxBack)\n      uBackRead = uMaxBack;\n    else\n      uBackRead+=BUFREADCOMMENT;\n    uReadPos = uSizeFile-uBackRead ;\n\n    uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ?\n      (BUFREADCOMMENT+4) : (uLong)(uSizeFile-uReadPos);\n    if (ZSEEK64(*pzlib_filefunc_def,filestream,uReadPos,ZLIB_FILEFUNC_SEEK_SET)!=0)\n      break;\n\n    if (ZREAD64(*pzlib_filefunc_def,filestream,buf,uReadSize)!=uReadSize)\n      break;\n\n    for (i=(int)uReadSize-3; (i--)>0;)\n    {\n      // Signature \"0x07064b50\" Zip64 end of central directory locater\n      if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) && ((*(buf+i+2))==0x06) && ((*(buf+i+3))==0x07))\n      {\n        uPosFound = uReadPos+i;\n        break;\n      }\n    }\n\n      if (uPosFound!=0)\n        break;\n  }\n\n  TRYFREE(buf);\n  if (uPosFound == 0)\n    return 0;\n\n  /* Zip64 end of central directory locator */\n  if (ZSEEK64(*pzlib_filefunc_def,filestream, uPosFound,ZLIB_FILEFUNC_SEEK_SET)!=0)\n    return 0;\n\n  /* the signature, already checked */\n  if (zip64local_getLong(pzlib_filefunc_def,filestream,&uL)!=ZIP_OK)\n    return 0;\n\n  /* number of the disk with the start of the zip64 end of  central directory */\n  if (zip64local_getLong(pzlib_filefunc_def,filestream,&uL)!=ZIP_OK)\n    return 0;\n  if (uL != 0)\n    return 0;\n\n  /* relative offset of the zip64 end of central directory record */\n  if (zip64local_getLong64(pzlib_filefunc_def,filestream,&relativeOffset)!=ZIP_OK)\n    return 0;\n\n  /* total number of disks */\n  if (zip64local_getLong(pzlib_filefunc_def,filestream,&uL)!=ZIP_OK)\n    return 0;\n  if (uL != 1)\n    return 0;\n\n  /* Goto Zip64 end of central directory record */\n  if (ZSEEK64(*pzlib_filefunc_def,filestream, relativeOffset,ZLIB_FILEFUNC_SEEK_SET)!=0)\n    return 0;\n\n  /* the signature */\n  if (zip64local_getLong(pzlib_filefunc_def,filestream,&uL)!=ZIP_OK)\n    return 0;\n\n  if (uL != 0x06064b50) // signature of 'Zip64 end of central directory'\n    return 0;\n\n  return relativeOffset;\n}\n\nint LoadCentralDirectoryRecord(zip64_internal* pziinit)\n{\n  int err=ZIP_OK;\n  ZPOS64_T byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/\n\n  ZPOS64_T size_central_dir;     /* size of the central directory  */\n  ZPOS64_T offset_central_dir;   /* offset of start of central directory */\n  ZPOS64_T central_pos;\n  uLong uL;\n\n  uLong number_disk;          /* number of the current dist, used for\n                              spaning ZIP, unsupported, always 0*/\n  uLong number_disk_with_CD;  /* number the the disk with central dir, used\n                              for spaning ZIP, unsupported, always 0*/\n  ZPOS64_T number_entry;\n  ZPOS64_T number_entry_CD;      /* total number of entries in\n                                the central dir\n                                (same than number_entry on nospan) */\n  uLong VersionMadeBy;\n  uLong VersionNeeded;\n  uLong size_comment;\n\n  int hasZIP64Record = 0;\n\n  // check first if we find a ZIP64 record\n  central_pos = zip64local_SearchCentralDir64(&pziinit->z_filefunc,pziinit->filestream);\n  if(central_pos > 0)\n  {\n    hasZIP64Record = 1;\n  }\n  else if(central_pos == 0)\n  {\n    central_pos = zip64local_SearchCentralDir(&pziinit->z_filefunc,pziinit->filestream);\n  }\n\n/* disable to allow appending to empty ZIP archive\n        if (central_pos==0)\n            err=ZIP_ERRNO;\n*/\n\n  if(hasZIP64Record)\n  {\n    ZPOS64_T sizeEndOfCentralDirectory;\n    if (ZSEEK64(pziinit->z_filefunc, pziinit->filestream, central_pos, ZLIB_FILEFUNC_SEEK_SET) != 0)\n      err=ZIP_ERRNO;\n\n    /* the signature, already checked */\n    if (zip64local_getLong(&pziinit->z_filefunc, pziinit->filestream,&uL)!=ZIP_OK)\n      err=ZIP_ERRNO;\n\n    /* size of zip64 end of central directory record */\n    if (zip64local_getLong64(&pziinit->z_filefunc, pziinit->filestream, &sizeEndOfCentralDirectory)!=ZIP_OK)\n      err=ZIP_ERRNO;\n\n    /* version made by */\n    if (zip64local_getShort(&pziinit->z_filefunc, pziinit->filestream, &VersionMadeBy)!=ZIP_OK)\n      err=ZIP_ERRNO;\n\n    /* version needed to extract */\n    if (zip64local_getShort(&pziinit->z_filefunc, pziinit->filestream, &VersionNeeded)!=ZIP_OK)\n      err=ZIP_ERRNO;\n\n    /* number of this disk */\n    if (zip64local_getLong(&pziinit->z_filefunc, pziinit->filestream,&number_disk)!=ZIP_OK)\n      err=ZIP_ERRNO;\n\n    /* number of the disk with the start of the central directory */\n    if (zip64local_getLong(&pziinit->z_filefunc, pziinit->filestream,&number_disk_with_CD)!=ZIP_OK)\n      err=ZIP_ERRNO;\n\n    /* total number of entries in the central directory on this disk */\n    if (zip64local_getLong64(&pziinit->z_filefunc, pziinit->filestream, &number_entry)!=ZIP_OK)\n      err=ZIP_ERRNO;\n\n    /* total number of entries in the central directory */\n    if (zip64local_getLong64(&pziinit->z_filefunc, pziinit->filestream,&number_entry_CD)!=ZIP_OK)\n      err=ZIP_ERRNO;\n\n    if ((number_entry_CD!=number_entry) || (number_disk_with_CD!=0) || (number_disk!=0))\n      err=ZIP_BADZIPFILE;\n\n    /* size of the central directory */\n    if (zip64local_getLong64(&pziinit->z_filefunc, pziinit->filestream,&size_central_dir)!=ZIP_OK)\n      err=ZIP_ERRNO;\n\n    /* offset of start of central directory with respect to the\n    starting disk number */\n    if (zip64local_getLong64(&pziinit->z_filefunc, pziinit->filestream,&offset_central_dir)!=ZIP_OK)\n      err=ZIP_ERRNO;\n\n    // TODO..\n    // read the comment from the standard central header.\n    size_comment = 0;\n  }\n  else\n  {\n    // Read End of central Directory info\n    if (ZSEEK64(pziinit->z_filefunc, pziinit->filestream, central_pos,ZLIB_FILEFUNC_SEEK_SET)!=0)\n      err=ZIP_ERRNO;\n\n    /* the signature, already checked */\n    if (zip64local_getLong(&pziinit->z_filefunc, pziinit->filestream,&uL)!=ZIP_OK)\n      err=ZIP_ERRNO;\n\n    /* number of this disk */\n    if (zip64local_getShort(&pziinit->z_filefunc, pziinit->filestream,&number_disk)!=ZIP_OK)\n      err=ZIP_ERRNO;\n\n    /* number of the disk with the start of the central directory */\n    if (zip64local_getShort(&pziinit->z_filefunc, pziinit->filestream,&number_disk_with_CD)!=ZIP_OK)\n      err=ZIP_ERRNO;\n\n    /* total number of entries in the central dir on this disk */\n    number_entry = 0;\n    if (zip64local_getShort(&pziinit->z_filefunc, pziinit->filestream, &uL)!=ZIP_OK)\n      err=ZIP_ERRNO;\n    else\n      number_entry = uL;\n\n    /* total number of entries in the central dir */\n    number_entry_CD = 0;\n    if (zip64local_getShort(&pziinit->z_filefunc, pziinit->filestream, &uL)!=ZIP_OK)\n      err=ZIP_ERRNO;\n    else\n      number_entry_CD = uL;\n\n    if ((number_entry_CD!=number_entry) || (number_disk_with_CD!=0) || (number_disk!=0))\n      err=ZIP_BADZIPFILE;\n\n    /* size of the central directory */\n    size_central_dir = 0;\n    if (zip64local_getLong(&pziinit->z_filefunc, pziinit->filestream, &uL)!=ZIP_OK)\n      err=ZIP_ERRNO;\n    else\n      size_central_dir = uL;\n\n    /* offset of start of central directory with respect to the starting disk number */\n    offset_central_dir = 0;\n    if (zip64local_getLong(&pziinit->z_filefunc, pziinit->filestream, &uL)!=ZIP_OK)\n      err=ZIP_ERRNO;\n    else\n      offset_central_dir = uL;\n\n\n    /* zipfile global comment length */\n    if (zip64local_getShort(&pziinit->z_filefunc, pziinit->filestream, &size_comment)!=ZIP_OK)\n      err=ZIP_ERRNO;\n  }\n\n  if ((central_pos<offset_central_dir+size_central_dir) &&\n    (err==ZIP_OK))\n    err=ZIP_BADZIPFILE;\n\n  if (err!=ZIP_OK)\n  {\n    ZCLOSE64(pziinit->z_filefunc, pziinit->filestream);\n    return ZIP_ERRNO;\n  }\n\n  if (size_comment>0)\n  {\n    pziinit->globalcomment = (char*)ALLOC(size_comment+1);\n    if (pziinit->globalcomment)\n    {\n      size_comment = ZREAD64(pziinit->z_filefunc, pziinit->filestream, pziinit->globalcomment,size_comment);\n      pziinit->globalcomment[size_comment]=0;\n    }\n  }\n\n  byte_before_the_zipfile = central_pos - (offset_central_dir+size_central_dir);\n  pziinit->add_position_when_writting_offset = byte_before_the_zipfile;\n\n  {\n    ZPOS64_T size_central_dir_to_read = size_central_dir;\n    size_t buf_size = SIZEDATA_INDATABLOCK;\n    void* buf_read = (void*)ALLOC(buf_size);\n    if (ZSEEK64(pziinit->z_filefunc, pziinit->filestream, offset_central_dir + byte_before_the_zipfile, ZLIB_FILEFUNC_SEEK_SET) != 0)\n      err=ZIP_ERRNO;\n\n    while ((size_central_dir_to_read>0) && (err==ZIP_OK))\n    {\n      ZPOS64_T read_this = SIZEDATA_INDATABLOCK;\n      if (read_this > size_central_dir_to_read)\n        read_this = size_central_dir_to_read;\n\n      if (ZREAD64(pziinit->z_filefunc, pziinit->filestream,buf_read,(uLong)read_this) != read_this)\n        err=ZIP_ERRNO;\n\n      if (err==ZIP_OK)\n        err = add_data_in_datablock(&pziinit->central_dir,buf_read, (uLong)read_this);\n\n      size_central_dir_to_read-=read_this;\n    }\n    TRYFREE(buf_read);\n  }\n  pziinit->begin_pos = byte_before_the_zipfile;\n  pziinit->number_entry = number_entry_CD;\n\n  if (ZSEEK64(pziinit->z_filefunc, pziinit->filestream, offset_central_dir+byte_before_the_zipfile,ZLIB_FILEFUNC_SEEK_SET) != 0)\n    err=ZIP_ERRNO;\n\n  return err;\n}\n\n\n#endif /* !NO_ADDFILEINEXISTINGZIP*/\n\n\n/************************************************************/\nextern zipFile ZEXPORT zipOpen3 (const void *pathname, int append, zipcharpc* globalcomment, zlib_filefunc64_32_def* pzlib_filefunc64_32_def)\n{\n    zip64_internal ziinit;\n    zip64_internal* zi;\n    int err=ZIP_OK;\n\n    ziinit.z_filefunc.zseek32_file = NULL;\n    ziinit.z_filefunc.ztell32_file = NULL;\n    if (pzlib_filefunc64_32_def==NULL)\n        fill_fopen64_filefunc(&ziinit.z_filefunc.zfile_func64);\n    else\n        ziinit.z_filefunc = *pzlib_filefunc64_32_def;\n\n    ziinit.filestream = ZOPEN64(ziinit.z_filefunc,\n                  pathname,\n                  (append == APPEND_STATUS_CREATE) ?\n                  (ZLIB_FILEFUNC_MODE_READ | ZLIB_FILEFUNC_MODE_WRITE | ZLIB_FILEFUNC_MODE_CREATE) :\n                    (ZLIB_FILEFUNC_MODE_READ | ZLIB_FILEFUNC_MODE_WRITE | ZLIB_FILEFUNC_MODE_EXISTING));\n\n    if (ziinit.filestream == NULL)\n        return NULL;\n\n    if (append == APPEND_STATUS_CREATEAFTER)\n        ZSEEK64(ziinit.z_filefunc,ziinit.filestream,0,SEEK_END);\n\n    ziinit.begin_pos = ZTELL64(ziinit.z_filefunc,ziinit.filestream);\n    ziinit.in_opened_file_inzip = 0;\n    ziinit.ci.stream_initialised = 0;\n    ziinit.number_entry = 0;\n    ziinit.add_position_when_writting_offset = 0;\n    init_linkedlist(&(ziinit.central_dir));\n\n\n\n    zi = (zip64_internal*)ALLOC(sizeof(zip64_internal));\n    if (zi==NULL)\n    {\n        ZCLOSE64(ziinit.z_filefunc,ziinit.filestream);\n        return NULL;\n    }\n\n    /* now we add file in a zipfile */\n#    ifndef NO_ADDFILEINEXISTINGZIP\n    ziinit.globalcomment = NULL;\n    if (append == APPEND_STATUS_ADDINZIP)\n    {\n      // Read and Cache Central Directory Records\n      err = LoadCentralDirectoryRecord(&ziinit);\n    }\n\n    if (globalcomment)\n    {\n      *globalcomment = ziinit.globalcomment;\n    }\n#    endif /* !NO_ADDFILEINEXISTINGZIP*/\n\n    if (err != ZIP_OK)\n    {\n#    ifndef NO_ADDFILEINEXISTINGZIP\n        TRYFREE(ziinit.globalcomment);\n#    endif /* !NO_ADDFILEINEXISTINGZIP*/\n        TRYFREE(zi);\n        return NULL;\n    }\n    else\n    {\n        *zi = ziinit;\n        return (zipFile)zi;\n    }\n}\n\nextern zipFile ZEXPORT zipOpen2 (const char *pathname, int append, zipcharpc* globalcomment, zlib_filefunc_def* pzlib_filefunc32_def)\n{\n    if (pzlib_filefunc32_def != NULL)\n    {\n        zlib_filefunc64_32_def zlib_filefunc64_32_def_fill;\n        fill_zlib_filefunc64_32_def_from_filefunc32(&zlib_filefunc64_32_def_fill,pzlib_filefunc32_def);\n        return zipOpen3(pathname, append, globalcomment, &zlib_filefunc64_32_def_fill);\n    }\n    else\n        return zipOpen3(pathname, append, globalcomment, NULL);\n}\n\nextern zipFile ZEXPORT zipOpen2_64 (const void *pathname, int append, zipcharpc* globalcomment, zlib_filefunc64_def* pzlib_filefunc_def)\n{\n    if (pzlib_filefunc_def != NULL)\n    {\n        zlib_filefunc64_32_def zlib_filefunc64_32_def_fill;\n        zlib_filefunc64_32_def_fill.zfile_func64 = *pzlib_filefunc_def;\n        zlib_filefunc64_32_def_fill.ztell32_file = NULL;\n        zlib_filefunc64_32_def_fill.zseek32_file = NULL;\n        return zipOpen3(pathname, append, globalcomment, &zlib_filefunc64_32_def_fill);\n    }\n    else\n        return zipOpen3(pathname, append, globalcomment, NULL);\n}\n\n\n\nextern zipFile ZEXPORT zipOpen (const char* pathname, int append)\n{\n    return zipOpen3((const void*)pathname,append,NULL,NULL);\n}\n\nextern zipFile ZEXPORT zipOpen64 (const void* pathname, int append)\n{\n    return zipOpen3(pathname,append,NULL,NULL);\n}\n\nint Write_LocalFileHeader(zip64_internal* zi, const char* filename, uInt size_extrafield_local, const void* extrafield_local)\n{\n  /* write the local header */\n  int err;\n  uInt size_filename = (uInt)strlen(filename);\n  uInt size_extrafield = size_extrafield_local;\n\n  err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)LOCALHEADERMAGIC, 4);\n\n  if (err==ZIP_OK)\n  {\n    if(zi->ci.zip64)\n      err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)45,2);/* version needed to extract */\n    else\n      err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)20,2);/* version needed to extract */\n  }\n\n  if (err==ZIP_OK)\n    err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->ci.flag,2);\n\n  if (err==ZIP_OK)\n    err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->ci.method,2);\n\n  if (err==ZIP_OK)\n    err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->ci.dosDate,4);\n\n  // CRC / Compressed size / Uncompressed size will be filled in later and rewritten later\n  if (err==ZIP_OK)\n    err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,4); /* crc 32, unknown */\n  if (err==ZIP_OK)\n  {\n    if(zi->ci.zip64)\n      err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0xFFFFFFFF,4); /* compressed size, unknown */\n    else\n      err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,4); /* compressed size, unknown */\n  }\n  if (err==ZIP_OK)\n  {\n    if(zi->ci.zip64)\n      err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0xFFFFFFFF,4); /* uncompressed size, unknown */\n    else\n      err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,4); /* uncompressed size, unknown */\n  }\n\n  if (err==ZIP_OK)\n    err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)size_filename,2);\n\n  if(zi->ci.zip64)\n  {\n    size_extrafield += 20;\n  }\n\n  if (err==ZIP_OK)\n    err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)size_extrafield,2);\n\n  if ((err==ZIP_OK) && (size_filename > 0))\n  {\n    if (ZWRITE64(zi->z_filefunc,zi->filestream,filename,size_filename)!=size_filename)\n      err = ZIP_ERRNO;\n  }\n\n  if ((err==ZIP_OK) && (size_extrafield_local > 0))\n  {\n    if (ZWRITE64(zi->z_filefunc, zi->filestream, extrafield_local, size_extrafield_local) != size_extrafield_local)\n      err = ZIP_ERRNO;\n  }\n\n\n  if ((err==ZIP_OK) && (zi->ci.zip64))\n  {\n      // write the Zip64 extended info\n      short HeaderID = 1;\n      short DataSize = 16;\n      ZPOS64_T CompressedSize = 0;\n      ZPOS64_T UncompressedSize = 0;\n\n      // Remember position of Zip64 extended info for the local file header. (needed when we update size after done with file)\n      zi->ci.pos_zip64extrainfo = ZTELL64(zi->z_filefunc,zi->filestream);\n\n      err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (short)HeaderID,2);\n      err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (short)DataSize,2);\n\n      err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (ZPOS64_T)UncompressedSize,8);\n      err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (ZPOS64_T)CompressedSize,8);\n  }\n\n  return err;\n}\n\n/*\n NOTE.\n When writing RAW the ZIP64 extended information in extrafield_local and extrafield_global needs to be stripped\n before calling this function it can be done with zipRemoveExtraInfoBlock\n\n It is not done here because then we need to realloc a new buffer since parameters are 'const' and I want to minimize\n unnecessary allocations.\n */\nextern int ZEXPORT zipOpenNewFileInZip4_64 (zipFile file, const char* filename, const zip_fileinfo* zipfi,\n                                         const void* extrafield_local, uInt size_extrafield_local,\n                                         const void* extrafield_global, uInt size_extrafield_global,\n                                         const char* comment, int method, int level, int raw,\n                                         int windowBits,int memLevel, int strategy,\n                                         const char* password, uLong crcForCrypting,\n                                         uLong versionMadeBy, uLong flagBase, int zip64)\n{\n    zip64_internal* zi;\n    uInt size_filename;\n    uInt size_comment;\n    uInt i;\n    int err = ZIP_OK;\n\n#    ifdef NOCRYPT\n    if (password != NULL)\n        return ZIP_PARAMERROR;\n#    endif\n\n    if (file == NULL)\n        return ZIP_PARAMERROR;\n\n#ifdef HAVE_BZIP2\n    if ((method!=0) && (method!=Z_DEFLATED) && (method!=Z_BZIP2ED))\n      return ZIP_PARAMERROR;\n#else\n    if ((method!=0) && (method!=Z_DEFLATED))\n      return ZIP_PARAMERROR;\n#endif\n\n    zi = (zip64_internal*)file;\n\n    if (zi->in_opened_file_inzip == 1)\n    {\n        err = zipCloseFileInZip (file);\n        if (err != ZIP_OK)\n            return err;\n    }\n\n    if (filename==NULL)\n        filename=\"-\";\n\n    if (comment==NULL)\n        size_comment = 0;\n    else\n        size_comment = (uInt)strlen(comment);\n\n    size_filename = (uInt)strlen(filename);\n\n    if (zipfi == NULL)\n        zi->ci.dosDate = 0;\n    else\n    {\n        if (zipfi->dosDate != 0)\n            zi->ci.dosDate = zipfi->dosDate;\n        else\n          zi->ci.dosDate = zip64local_TmzDateToDosDate(&zipfi->tmz_date);\n    }\n\n    zi->ci.flag = flagBase;\n    if ((level==8) || (level==9))\n      zi->ci.flag |= 2;\n    if ((level==2))\n      zi->ci.flag |= 4;\n    if ((level==1))\n      zi->ci.flag |= 6;\n    if (password != NULL)\n      zi->ci.flag |= 1;\n\n    zi->ci.crc32 = 0;\n    zi->ci.method = method;\n    zi->ci.encrypt = 0;\n    zi->ci.stream_initialised = 0;\n    zi->ci.pos_in_buffered_data = 0;\n    zi->ci.raw = raw;\n    zi->ci.pos_local_header = ZTELL64(zi->z_filefunc,zi->filestream);\n\n    zi->ci.size_centralheader = SIZECENTRALHEADER + size_filename + size_extrafield_global + size_comment;\n    zi->ci.size_centralExtraFree = 32; // Extra space we have reserved in case we need to add ZIP64 extra info data\n\n    zi->ci.central_header = (char*)ALLOC((uInt)zi->ci.size_centralheader + zi->ci.size_centralExtraFree);\n\n    zi->ci.size_centralExtra = size_extrafield_global;\n    zip64local_putValue_inmemory(zi->ci.central_header,(uLong)CENTRALHEADERMAGIC,4);\n    /* version info */\n    zip64local_putValue_inmemory(zi->ci.central_header+4,(uLong)versionMadeBy,2);\n    zip64local_putValue_inmemory(zi->ci.central_header+6,(uLong)20,2);\n    zip64local_putValue_inmemory(zi->ci.central_header+8,(uLong)zi->ci.flag,2);\n    zip64local_putValue_inmemory(zi->ci.central_header+10,(uLong)zi->ci.method,2);\n    zip64local_putValue_inmemory(zi->ci.central_header+12,(uLong)zi->ci.dosDate,4);\n    zip64local_putValue_inmemory(zi->ci.central_header+16,(uLong)0,4); /*crc*/\n    zip64local_putValue_inmemory(zi->ci.central_header+20,(uLong)0,4); /*compr size*/\n    zip64local_putValue_inmemory(zi->ci.central_header+24,(uLong)0,4); /*uncompr size*/\n    zip64local_putValue_inmemory(zi->ci.central_header+28,(uLong)size_filename,2);\n    zip64local_putValue_inmemory(zi->ci.central_header+30,(uLong)size_extrafield_global,2);\n    zip64local_putValue_inmemory(zi->ci.central_header+32,(uLong)size_comment,2);\n    zip64local_putValue_inmemory(zi->ci.central_header+34,(uLong)0,2); /*disk nm start*/\n\n    if (zipfi==NULL)\n        zip64local_putValue_inmemory(zi->ci.central_header+36,(uLong)0,2);\n    else\n        zip64local_putValue_inmemory(zi->ci.central_header+36,(uLong)zipfi->internal_fa,2);\n\n    if (zipfi==NULL)\n        zip64local_putValue_inmemory(zi->ci.central_header+38,(uLong)0,4);\n    else\n        zip64local_putValue_inmemory(zi->ci.central_header+38,(uLong)zipfi->external_fa,4);\n\n    if(zi->ci.pos_local_header >= 0xffffffff)\n      zip64local_putValue_inmemory(zi->ci.central_header+42,(uLong)0xffffffff,4);\n    else\n      zip64local_putValue_inmemory(zi->ci.central_header+42,(uLong)zi->ci.pos_local_header - zi->add_position_when_writting_offset,4);\n\n    for (i=0;i<size_filename;i++)\n        *(zi->ci.central_header+SIZECENTRALHEADER+i) = *(filename+i);\n\n    for (i=0;i<size_extrafield_global;i++)\n        *(zi->ci.central_header+SIZECENTRALHEADER+size_filename+i) =\n              *(((const char*)extrafield_global)+i);\n\n    for (i=0;i<size_comment;i++)\n        *(zi->ci.central_header+SIZECENTRALHEADER+size_filename+\n              size_extrafield_global+i) = *(comment+i);\n    if (zi->ci.central_header == NULL)\n        return ZIP_INTERNALERROR;\n\n    zi->ci.zip64 = zip64;\n    zi->ci.totalCompressedData = 0;\n    zi->ci.totalUncompressedData = 0;\n    zi->ci.pos_zip64extrainfo = 0;\n\n    err = Write_LocalFileHeader(zi, filename, size_extrafield_local, extrafield_local);\n\n#ifdef HAVE_BZIP2\n    zi->ci.bstream.avail_in = (uInt)0;\n    zi->ci.bstream.avail_out = (uInt)Z_BUFSIZE;\n    zi->ci.bstream.next_out = (char*)zi->ci.buffered_data;\n    zi->ci.bstream.total_in_hi32 = 0;\n    zi->ci.bstream.total_in_lo32 = 0;\n    zi->ci.bstream.total_out_hi32 = 0;\n    zi->ci.bstream.total_out_lo32 = 0;\n#endif\n\n    zi->ci.stream.avail_in = (uInt)0;\n    zi->ci.stream.avail_out = (uInt)Z_BUFSIZE;\n    zi->ci.stream.next_out = zi->ci.buffered_data;\n    zi->ci.stream.total_in = 0;\n    zi->ci.stream.total_out = 0;\n    zi->ci.stream.data_type = Z_BINARY;\n\n#ifdef HAVE_BZIP2\n    if ((err==ZIP_OK) && (zi->ci.method == Z_DEFLATED || zi->ci.method == Z_BZIP2ED) && (!zi->ci.raw))\n#else\n    if ((err==ZIP_OK) && (zi->ci.method == Z_DEFLATED) && (!zi->ci.raw))\n#endif\n    {\n        if(zi->ci.method == Z_DEFLATED)\n        {\n          zi->ci.stream.zalloc = (alloc_func)0;\n          zi->ci.stream.zfree = (free_func)0;\n          zi->ci.stream.opaque = (voidpf)0;\n\n          if (windowBits>0)\n              windowBits = -windowBits;\n\n          err = deflateInit2(&zi->ci.stream, level, Z_DEFLATED, windowBits, memLevel, strategy);\n\n          if (err==Z_OK)\n              zi->ci.stream_initialised = Z_DEFLATED;\n        }\n        else if(zi->ci.method == Z_BZIP2ED)\n        {\n#ifdef HAVE_BZIP2\n            // Init BZip stuff here\n          zi->ci.bstream.bzalloc = 0;\n          zi->ci.bstream.bzfree = 0;\n          zi->ci.bstream.opaque = (voidpf)0;\n\n          err = BZ2_bzCompressInit(&zi->ci.bstream, level, 0,35);\n          if(err == BZ_OK)\n            zi->ci.stream_initialised = Z_BZIP2ED;\n#endif\n        }\n\n    }\n\n#    ifndef NOCRYPT\n    zi->ci.crypt_header_size = 0;\n    if ((err==Z_OK) && (password != NULL))\n    {\n        unsigned char bufHead[RAND_HEAD_LEN];\n        unsigned int sizeHead;\n        zi->ci.encrypt = 1;\n        zi->ci.pcrc_32_tab = get_crc_table();\n        /*init_keys(password,zi->ci.keys,zi->ci.pcrc_32_tab);*/\n\n        sizeHead=crypthead(password,bufHead,RAND_HEAD_LEN,zi->ci.keys,zi->ci.pcrc_32_tab,crcForCrypting);\n        zi->ci.crypt_header_size = sizeHead;\n\n        if (ZWRITE64(zi->z_filefunc,zi->filestream,bufHead,sizeHead) != sizeHead)\n                err = ZIP_ERRNO;\n    }\n#    endif\n\n    if (err==Z_OK)\n        zi->in_opened_file_inzip = 1;\n    return err;\n}\n\nextern int ZEXPORT zipOpenNewFileInZip4 (zipFile file, const char* filename, const zip_fileinfo* zipfi,\n                                         const void* extrafield_local, uInt size_extrafield_local,\n                                         const void* extrafield_global, uInt size_extrafield_global,\n                                         const char* comment, int method, int level, int raw,\n                                         int windowBits,int memLevel, int strategy,\n                                         const char* password, uLong crcForCrypting,\n                                         uLong versionMadeBy, uLong flagBase)\n{\n    return zipOpenNewFileInZip4_64 (file, filename, zipfi,\n                                 extrafield_local, size_extrafield_local,\n                                 extrafield_global, size_extrafield_global,\n                                 comment, method, level, raw,\n                                 windowBits, memLevel, strategy,\n                                 password, crcForCrypting, versionMadeBy, flagBase, 0);\n}\n\nextern int ZEXPORT zipOpenNewFileInZip3 (zipFile file, const char* filename, const zip_fileinfo* zipfi,\n                                         const void* extrafield_local, uInt size_extrafield_local,\n                                         const void* extrafield_global, uInt size_extrafield_global,\n                                         const char* comment, int method, int level, int raw,\n                                         int windowBits,int memLevel, int strategy,\n                                         const char* password, uLong crcForCrypting)\n{\n    return zipOpenNewFileInZip4_64 (file, filename, zipfi,\n                                 extrafield_local, size_extrafield_local,\n                                 extrafield_global, size_extrafield_global,\n                                 comment, method, level, raw,\n                                 windowBits, memLevel, strategy,\n                                 password, crcForCrypting, VERSIONMADEBY, 0, 0);\n}\n\nextern int ZEXPORT zipOpenNewFileInZip3_64(zipFile file, const char* filename, const zip_fileinfo* zipfi,\n                                         const void* extrafield_local, uInt size_extrafield_local,\n                                         const void* extrafield_global, uInt size_extrafield_global,\n                                         const char* comment, int method, int level, int raw,\n                                         int windowBits,int memLevel, int strategy,\n                                         const char* password, uLong crcForCrypting, int zip64)\n{\n    return zipOpenNewFileInZip4_64 (file, filename, zipfi,\n                                 extrafield_local, size_extrafield_local,\n                                 extrafield_global, size_extrafield_global,\n                                 comment, method, level, raw,\n                                 windowBits, memLevel, strategy,\n                                 password, crcForCrypting, VERSIONMADEBY, 0, zip64);\n}\n\nextern int ZEXPORT zipOpenNewFileInZip2(zipFile file, const char* filename, const zip_fileinfo* zipfi,\n                                        const void* extrafield_local, uInt size_extrafield_local,\n                                        const void* extrafield_global, uInt size_extrafield_global,\n                                        const char* comment, int method, int level, int raw)\n{\n    return zipOpenNewFileInZip4_64 (file, filename, zipfi,\n                                 extrafield_local, size_extrafield_local,\n                                 extrafield_global, size_extrafield_global,\n                                 comment, method, level, raw,\n                                 -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY,\n                                 NULL, 0, VERSIONMADEBY, 0, 0);\n}\n\nextern int ZEXPORT zipOpenNewFileInZip2_64(zipFile file, const char* filename, const zip_fileinfo* zipfi,\n                                        const void* extrafield_local, uInt size_extrafield_local,\n                                        const void* extrafield_global, uInt size_extrafield_global,\n                                        const char* comment, int method, int level, int raw, int zip64)\n{\n    return zipOpenNewFileInZip4_64 (file, filename, zipfi,\n                                 extrafield_local, size_extrafield_local,\n                                 extrafield_global, size_extrafield_global,\n                                 comment, method, level, raw,\n                                 -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY,\n                                 NULL, 0, VERSIONMADEBY, 0, zip64);\n}\n\nextern int ZEXPORT zipOpenNewFileInZip64 (zipFile file, const char* filename, const zip_fileinfo* zipfi,\n                                        const void* extrafield_local, uInt size_extrafield_local,\n                                        const void*extrafield_global, uInt size_extrafield_global,\n                                        const char* comment, int method, int level, int zip64)\n{\n    return zipOpenNewFileInZip4_64 (file, filename, zipfi,\n                                 extrafield_local, size_extrafield_local,\n                                 extrafield_global, size_extrafield_global,\n                                 comment, method, level, 0,\n                                 -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY,\n                                 NULL, 0, VERSIONMADEBY, 0, zip64);\n}\n\nextern int ZEXPORT zipOpenNewFileInZip (zipFile file, const char* filename, const zip_fileinfo* zipfi,\n                                        const void* extrafield_local, uInt size_extrafield_local,\n                                        const void*extrafield_global, uInt size_extrafield_global,\n                                        const char* comment, int method, int level)\n{\n    return zipOpenNewFileInZip4_64 (file, filename, zipfi,\n                                 extrafield_local, size_extrafield_local,\n                                 extrafield_global, size_extrafield_global,\n                                 comment, method, level, 0,\n                                 -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY,\n                                 NULL, 0, VERSIONMADEBY, 0, 0);\n}\n\nlocal int zip64FlushWriteBuffer(zip64_internal* zi)\n{\n    int err=ZIP_OK;\n\n    if (zi->ci.encrypt != 0)\n    {\n#ifndef NOCRYPT\n        uInt i;\n        int t;\n        for (i=0;i<zi->ci.pos_in_buffered_data;i++)\n            zi->ci.buffered_data[i] = zencode(zi->ci.keys, zi->ci.pcrc_32_tab, zi->ci.buffered_data[i],t);\n#endif\n    }\n\n    if (ZWRITE64(zi->z_filefunc,zi->filestream,zi->ci.buffered_data,zi->ci.pos_in_buffered_data) != zi->ci.pos_in_buffered_data)\n      err = ZIP_ERRNO;\n\n    zi->ci.totalCompressedData += zi->ci.pos_in_buffered_data;\n\n#ifdef HAVE_BZIP2\n    if(zi->ci.method == Z_BZIP2ED)\n    {\n      zi->ci.totalUncompressedData += zi->ci.bstream.total_in_lo32;\n      zi->ci.bstream.total_in_lo32 = 0;\n      zi->ci.bstream.total_in_hi32 = 0;\n    }\n    else\n#endif\n    {\n      zi->ci.totalUncompressedData += zi->ci.stream.total_in;\n      zi->ci.stream.total_in = 0;\n    }\n\n\n    zi->ci.pos_in_buffered_data = 0;\n\n    return err;\n}\n\nextern int ZEXPORT zipWriteInFileInZip (zipFile file,const void* buf,unsigned int len)\n{\n    zip64_internal* zi;\n    int err=ZIP_OK;\n\n    if (file == NULL)\n        return ZIP_PARAMERROR;\n    zi = (zip64_internal*)file;\n\n    if (zi->in_opened_file_inzip == 0)\n        return ZIP_PARAMERROR;\n\n    zi->ci.crc32 = crc32(zi->ci.crc32,buf,(uInt)len);\n\n#ifdef HAVE_BZIP2\n    if(zi->ci.method == Z_BZIP2ED && (!zi->ci.raw))\n    {\n      zi->ci.bstream.next_in = (void*)buf;\n      zi->ci.bstream.avail_in = len;\n      err = BZ_RUN_OK;\n\n      while ((err==BZ_RUN_OK) && (zi->ci.bstream.avail_in>0))\n      {\n        if (zi->ci.bstream.avail_out == 0)\n        {\n          if (zip64FlushWriteBuffer(zi) == ZIP_ERRNO)\n            err = ZIP_ERRNO;\n          zi->ci.bstream.avail_out = (uInt)Z_BUFSIZE;\n          zi->ci.bstream.next_out = (char*)zi->ci.buffered_data;\n        }\n\n\n        if(err != BZ_RUN_OK)\n          break;\n\n        if ((zi->ci.method == Z_BZIP2ED) && (!zi->ci.raw))\n        {\n          uLong uTotalOutBefore_lo = zi->ci.bstream.total_out_lo32;\n//          uLong uTotalOutBefore_hi = zi->ci.bstream.total_out_hi32;\n          err=BZ2_bzCompress(&zi->ci.bstream,  BZ_RUN);\n\n          zi->ci.pos_in_buffered_data += (uInt)(zi->ci.bstream.total_out_lo32 - uTotalOutBefore_lo) ;\n        }\n      }\n\n      if(err == BZ_RUN_OK)\n        err = ZIP_OK;\n    }\n    else\n#endif\n    {\n      zi->ci.stream.next_in = (Bytef*)buf;\n      zi->ci.stream.avail_in = len;\n\n      while ((err==ZIP_OK) && (zi->ci.stream.avail_in>0))\n      {\n          if (zi->ci.stream.avail_out == 0)\n          {\n              if (zip64FlushWriteBuffer(zi) == ZIP_ERRNO)\n                  err = ZIP_ERRNO;\n              zi->ci.stream.avail_out = (uInt)Z_BUFSIZE;\n              zi->ci.stream.next_out = zi->ci.buffered_data;\n          }\n\n\n          if(err != ZIP_OK)\n              break;\n\n          if ((zi->ci.method == Z_DEFLATED) && (!zi->ci.raw))\n          {\n              uLong uTotalOutBefore = zi->ci.stream.total_out;\n              err=deflate(&zi->ci.stream,  Z_NO_FLUSH);\n              if(uTotalOutBefore > zi->ci.stream.total_out)\n              {\n                int bBreak = 0;\n                bBreak++;\n              }\n\n              zi->ci.pos_in_buffered_data += (uInt)(zi->ci.stream.total_out - uTotalOutBefore) ;\n          }\n          else\n          {\n              uInt copy_this,i;\n              if (zi->ci.stream.avail_in < zi->ci.stream.avail_out)\n                  copy_this = zi->ci.stream.avail_in;\n              else\n                  copy_this = zi->ci.stream.avail_out;\n\n              for (i = 0; i < copy_this; i++)\n                  *(((char*)zi->ci.stream.next_out)+i) =\n                      *(((const char*)zi->ci.stream.next_in)+i);\n              {\n                  zi->ci.stream.avail_in -= copy_this;\n                  zi->ci.stream.avail_out-= copy_this;\n                  zi->ci.stream.next_in+= copy_this;\n                  zi->ci.stream.next_out+= copy_this;\n                  zi->ci.stream.total_in+= copy_this;\n                  zi->ci.stream.total_out+= copy_this;\n                  zi->ci.pos_in_buffered_data += copy_this;\n              }\n          }\n      }// while(...)\n    }\n\n    return err;\n}\n\nextern int ZEXPORT zipCloseFileInZipRaw (zipFile file, uLong uncompressed_size, uLong crc32)\n{\n    return zipCloseFileInZipRaw64 (file, uncompressed_size, crc32);\n}\n\nextern int ZEXPORT zipCloseFileInZipRaw64 (zipFile file, ZPOS64_T uncompressed_size, uLong crc32)\n{\n    zip64_internal* zi;\n    ZPOS64_T compressed_size;\n    uLong invalidValue = 0xffffffff;\n    short datasize = 0;\n    int err=ZIP_OK;\n\n    if (file == NULL)\n        return ZIP_PARAMERROR;\n    zi = (zip64_internal*)file;\n\n    if (zi->in_opened_file_inzip == 0)\n        return ZIP_PARAMERROR;\n    zi->ci.stream.avail_in = 0;\n\n    if ((zi->ci.method == Z_DEFLATED) && (!zi->ci.raw))\n                {\n                        while (err==ZIP_OK)\n                        {\n                                uLong uTotalOutBefore;\n                                if (zi->ci.stream.avail_out == 0)\n                                {\n                                        if (zip64FlushWriteBuffer(zi) == ZIP_ERRNO)\n                                                err = ZIP_ERRNO;\n                                        zi->ci.stream.avail_out = (uInt)Z_BUFSIZE;\n                                        zi->ci.stream.next_out = zi->ci.buffered_data;\n                                }\n                                uTotalOutBefore = zi->ci.stream.total_out;\n                                err=deflate(&zi->ci.stream,  Z_FINISH);\n                                zi->ci.pos_in_buffered_data += (uInt)(zi->ci.stream.total_out - uTotalOutBefore) ;\n                        }\n                }\n    else if ((zi->ci.method == Z_BZIP2ED) && (!zi->ci.raw))\n    {\n#ifdef HAVE_BZIP2\n      err = BZ_FINISH_OK;\n      while (err==BZ_FINISH_OK)\n      {\n        uLong uTotalOutBefore;\n        if (zi->ci.bstream.avail_out == 0)\n        {\n          if (zip64FlushWriteBuffer(zi) == ZIP_ERRNO)\n            err = ZIP_ERRNO;\n          zi->ci.bstream.avail_out = (uInt)Z_BUFSIZE;\n          zi->ci.bstream.next_out = (char*)zi->ci.buffered_data;\n        }\n        uTotalOutBefore = zi->ci.bstream.total_out_lo32;\n        err=BZ2_bzCompress(&zi->ci.bstream,  BZ_FINISH);\n        if(err == BZ_STREAM_END)\n          err = Z_STREAM_END;\n\n        zi->ci.pos_in_buffered_data += (uInt)(zi->ci.bstream.total_out_lo32 - uTotalOutBefore);\n      }\n\n      if(err == BZ_FINISH_OK)\n        err = ZIP_OK;\n#endif\n    }\n\n    if (err==Z_STREAM_END)\n        err=ZIP_OK; /* this is normal */\n\n    if ((zi->ci.pos_in_buffered_data>0) && (err==ZIP_OK))\n                {\n        if (zip64FlushWriteBuffer(zi)==ZIP_ERRNO)\n            err = ZIP_ERRNO;\n                }\n\n    if ((zi->ci.method == Z_DEFLATED) && (!zi->ci.raw))\n    {\n        int tmp_err = deflateEnd(&zi->ci.stream);\n        if (err == ZIP_OK)\n            err = tmp_err;\n        zi->ci.stream_initialised = 0;\n    }\n#ifdef HAVE_BZIP2\n    else if((zi->ci.method == Z_BZIP2ED) && (!zi->ci.raw))\n    {\n      int tmperr = BZ2_bzCompressEnd(&zi->ci.bstream);\n                        if (err==ZIP_OK)\n                                err = tmperr;\n                        zi->ci.stream_initialised = 0;\n    }\n#endif\n\n    if (!zi->ci.raw)\n    {\n        crc32 = (uLong)zi->ci.crc32;\n        uncompressed_size = zi->ci.totalUncompressedData;\n    }\n    compressed_size = zi->ci.totalCompressedData;\n\n#    ifndef NOCRYPT\n    compressed_size += zi->ci.crypt_header_size;\n#    endif\n\n    // update Current Item crc and sizes,\n    if(compressed_size >= 0xffffffff || uncompressed_size >= 0xffffffff || zi->ci.pos_local_header >= 0xffffffff)\n    {\n      /*version Made by*/\n      zip64local_putValue_inmemory(zi->ci.central_header+4,(uLong)45,2);\n      /*version needed*/\n      zip64local_putValue_inmemory(zi->ci.central_header+6,(uLong)45,2);\n\n    }\n\n    zip64local_putValue_inmemory(zi->ci.central_header+16,crc32,4); /*crc*/\n\n\n    if(compressed_size >= 0xffffffff)\n      zip64local_putValue_inmemory(zi->ci.central_header+20, invalidValue,4); /*compr size*/\n    else\n      zip64local_putValue_inmemory(zi->ci.central_header+20, compressed_size,4); /*compr size*/\n\n    /// set internal file attributes field\n    if (zi->ci.stream.data_type == Z_ASCII)\n        zip64local_putValue_inmemory(zi->ci.central_header+36,(uLong)Z_ASCII,2);\n\n    if(uncompressed_size >= 0xffffffff)\n      zip64local_putValue_inmemory(zi->ci.central_header+24, invalidValue,4); /*uncompr size*/\n    else\n      zip64local_putValue_inmemory(zi->ci.central_header+24, uncompressed_size,4); /*uncompr size*/\n\n    // Add ZIP64 extra info field for uncompressed size\n    if(uncompressed_size >= 0xffffffff)\n      datasize += 8;\n\n    // Add ZIP64 extra info field for compressed size\n    if(compressed_size >= 0xffffffff)\n      datasize += 8;\n\n    // Add ZIP64 extra info field for relative offset to local file header of current file\n    if(zi->ci.pos_local_header >= 0xffffffff)\n      datasize += 8;\n\n    if(datasize > 0)\n    {\n      char* p = NULL;\n\n      if((uLong)(datasize + 4) > zi->ci.size_centralExtraFree)\n      {\n        // we can not write more data to the buffer that we have room for.\n        return ZIP_BADZIPFILE;\n      }\n\n      p = zi->ci.central_header + zi->ci.size_centralheader;\n\n      // Add Extra Information Header for 'ZIP64 information'\n      zip64local_putValue_inmemory(p, 0x0001, 2); // HeaderID\n      p += 2;\n      zip64local_putValue_inmemory(p, datasize, 2); // DataSize\n      p += 2;\n\n      if(uncompressed_size >= 0xffffffff)\n      {\n        zip64local_putValue_inmemory(p, uncompressed_size, 8);\n        p += 8;\n      }\n\n      if(compressed_size >= 0xffffffff)\n      {\n        zip64local_putValue_inmemory(p, compressed_size, 8);\n        p += 8;\n      }\n\n      if(zi->ci.pos_local_header >= 0xffffffff)\n      {\n        zip64local_putValue_inmemory(p, zi->ci.pos_local_header, 8);\n        p += 8;\n      }\n\n      // Update how much extra free space we got in the memory buffer\n      // and increase the centralheader size so the new ZIP64 fields are included\n      // ( 4 below is the size of HeaderID and DataSize field )\n      zi->ci.size_centralExtraFree -= datasize + 4;\n      zi->ci.size_centralheader += datasize + 4;\n\n      // Update the extra info size field\n      zi->ci.size_centralExtra += datasize + 4;\n      zip64local_putValue_inmemory(zi->ci.central_header+30,(uLong)zi->ci.size_centralExtra,2);\n    }\n\n    if (err==ZIP_OK)\n        err = add_data_in_datablock(&zi->central_dir, zi->ci.central_header, (uLong)zi->ci.size_centralheader);\n\n    free(zi->ci.central_header);\n\n    if (err==ZIP_OK)\n    {\n        // Update the LocalFileHeader with the new values.\n\n        ZPOS64_T cur_pos_inzip = ZTELL64(zi->z_filefunc,zi->filestream);\n\n        if (ZSEEK64(zi->z_filefunc,zi->filestream, zi->ci.pos_local_header + 14,ZLIB_FILEFUNC_SEEK_SET)!=0)\n            err = ZIP_ERRNO;\n\n        if (err==ZIP_OK)\n            err = zip64local_putValue(&zi->z_filefunc,zi->filestream,crc32,4); /* crc 32, unknown */\n\n        if(uncompressed_size >= 0xffffffff)\n        {\n          if(zi->ci.pos_zip64extrainfo > 0)\n          {\n            // Update the size in the ZIP64 extended field.\n            if (ZSEEK64(zi->z_filefunc,zi->filestream, zi->ci.pos_zip64extrainfo + 4,ZLIB_FILEFUNC_SEEK_SET)!=0)\n              err = ZIP_ERRNO;\n\n            if (err==ZIP_OK) /* compressed size, unknown */\n              err = zip64local_putValue(&zi->z_filefunc, zi->filestream, uncompressed_size, 8);\n\n            if (err==ZIP_OK) /* uncompressed size, unknown */\n              err = zip64local_putValue(&zi->z_filefunc, zi->filestream, compressed_size, 8);\n          }\n        }\n        else\n        {\n          if (err==ZIP_OK) /* compressed size, unknown */\n              err = zip64local_putValue(&zi->z_filefunc,zi->filestream,compressed_size,4);\n\n          if (err==ZIP_OK) /* uncompressed size, unknown */\n              err = zip64local_putValue(&zi->z_filefunc,zi->filestream,uncompressed_size,4);\n        }\n\n        if (ZSEEK64(zi->z_filefunc,zi->filestream, cur_pos_inzip,ZLIB_FILEFUNC_SEEK_SET)!=0)\n            err = ZIP_ERRNO;\n    }\n\n    zi->number_entry ++;\n    zi->in_opened_file_inzip = 0;\n\n    return err;\n}\n\nextern int ZEXPORT zipCloseFileInZip (zipFile file)\n{\n    return zipCloseFileInZipRaw (file,0,0);\n}\n\nint Write_Zip64EndOfCentralDirectoryLocator(zip64_internal* zi, ZPOS64_T zip64eocd_pos_inzip)\n{\n  int err = ZIP_OK;\n  ZPOS64_T pos = zip64eocd_pos_inzip - zi->add_position_when_writting_offset;\n\n  err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)ZIP64ENDLOCHEADERMAGIC,4);\n\n  /*num disks*/\n    if (err==ZIP_OK) /* number of the disk with the start of the central directory */\n      err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,4);\n\n  /*relative offset*/\n    if (err==ZIP_OK) /* Relative offset to the Zip64EndOfCentralDirectory */\n      err = zip64local_putValue(&zi->z_filefunc,zi->filestream, pos,8);\n\n  /*total disks*/ /* Do not support spawning of disk so always say 1 here*/\n    if (err==ZIP_OK) /* number of the disk with the start of the central directory */\n      err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)1,4);\n\n    return err;\n}\n\nint Write_Zip64EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_centraldir, ZPOS64_T centraldir_pos_inzip)\n{\n  int err = ZIP_OK;\n\n  uLong Zip64DataSize = 44;\n\n  err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)ZIP64ENDHEADERMAGIC,4);\n\n  if (err==ZIP_OK) /* size of this 'zip64 end of central directory' */\n    err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(ZPOS64_T)Zip64DataSize,8); // why ZPOS64_T of this ?\n\n  if (err==ZIP_OK) /* version made by */\n    err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)45,2);\n\n  if (err==ZIP_OK) /* version needed */\n    err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)45,2);\n\n  if (err==ZIP_OK) /* number of this disk */\n    err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,4);\n\n  if (err==ZIP_OK) /* number of the disk with the start of the central directory */\n    err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,4);\n\n  if (err==ZIP_OK) /* total number of entries in the central dir on this disk */\n    err = zip64local_putValue(&zi->z_filefunc, zi->filestream, zi->number_entry, 8);\n\n  if (err==ZIP_OK) /* total number of entries in the central dir */\n    err = zip64local_putValue(&zi->z_filefunc, zi->filestream, zi->number_entry, 8);\n\n  if (err==ZIP_OK) /* size of the central directory */\n    err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(ZPOS64_T)size_centraldir,8);\n\n  if (err==ZIP_OK) /* offset of start of central directory with respect to the starting disk number */\n  {\n    ZPOS64_T pos = centraldir_pos_inzip - zi->add_position_when_writting_offset;\n    err = zip64local_putValue(&zi->z_filefunc,zi->filestream, (ZPOS64_T)pos,8);\n  }\n  return err;\n}\nint Write_EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_centraldir, ZPOS64_T centraldir_pos_inzip)\n{\n  int err = ZIP_OK;\n\n  /*signature*/\n  err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)ENDHEADERMAGIC,4);\n\n  if (err==ZIP_OK) /* number of this disk */\n    err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,2);\n\n  if (err==ZIP_OK) /* number of the disk with the start of the central directory */\n    err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,2);\n\n  if (err==ZIP_OK) /* total number of entries in the central dir on this disk */\n  {\n    {\n      if(zi->number_entry >= 0xFFFF)\n        err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0xffff,2); // use value in ZIP64 record\n      else\n        err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->number_entry,2);\n    }\n  }\n\n  if (err==ZIP_OK) /* total number of entries in the central dir */\n  {\n    if(zi->number_entry >= 0xFFFF)\n      err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0xffff,2); // use value in ZIP64 record\n    else\n      err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->number_entry,2);\n  }\n\n  if (err==ZIP_OK) /* size of the central directory */\n    err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)size_centraldir,4);\n\n  if (err==ZIP_OK) /* offset of start of central directory with respect to the starting disk number */\n  {\n    ZPOS64_T pos = centraldir_pos_inzip - zi->add_position_when_writting_offset;\n    if(pos >= 0xffffffff)\n    {\n      err = zip64local_putValue(&zi->z_filefunc,zi->filestream, (uLong)0xffffffff,4);\n    }\n    else\n                  err = zip64local_putValue(&zi->z_filefunc,zi->filestream, (uLong)(centraldir_pos_inzip - zi->add_position_when_writting_offset),4);\n  }\n\n   return err;\n}\n\nint Write_GlobalComment(zip64_internal* zi, const char* global_comment)\n{\n  int err = ZIP_OK;\n  uInt size_global_comment = 0;\n\n  if(global_comment != NULL)\n    size_global_comment = (uInt)strlen(global_comment);\n\n  err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)size_global_comment,2);\n\n  if (err == ZIP_OK && size_global_comment > 0)\n  {\n    if (ZWRITE64(zi->z_filefunc,zi->filestream, global_comment, size_global_comment) != size_global_comment)\n      err = ZIP_ERRNO;\n  }\n  return err;\n}\n\nextern int ZEXPORT zipClose (zipFile file, const char* global_comment)\n{\n    zip64_internal* zi;\n    int err = 0;\n    uLong size_centraldir = 0;\n    ZPOS64_T centraldir_pos_inzip;\n    ZPOS64_T pos;\n\n    if (file == NULL)\n        return ZIP_PARAMERROR;\n\n    zi = (zip64_internal*)file;\n\n    if (zi->in_opened_file_inzip == 1)\n    {\n        err = zipCloseFileInZip (file);\n    }\n\n#ifndef NO_ADDFILEINEXISTINGZIP\n    if (global_comment==NULL)\n        global_comment = zi->globalcomment;\n#endif\n\n    centraldir_pos_inzip = ZTELL64(zi->z_filefunc,zi->filestream);\n\n    if (err==ZIP_OK)\n    {\n        linkedlist_datablock_internal* ldi = zi->central_dir.first_block;\n        while (ldi!=NULL)\n        {\n            if ((err==ZIP_OK) && (ldi->filled_in_this_block>0))\n            {\n                if (ZWRITE64(zi->z_filefunc,zi->filestream, ldi->data, ldi->filled_in_this_block) != ldi->filled_in_this_block)\n                    err = ZIP_ERRNO;\n            }\n\n            size_centraldir += ldi->filled_in_this_block;\n            ldi = ldi->next_datablock;\n        }\n    }\n    free_linkedlist(&(zi->central_dir));\n\n    pos = centraldir_pos_inzip - zi->add_position_when_writting_offset;\n    if(pos >= 0xffffffff)\n    {\n      ZPOS64_T Zip64EOCDpos = ZTELL64(zi->z_filefunc,zi->filestream);\n      Write_Zip64EndOfCentralDirectoryRecord(zi, size_centraldir, centraldir_pos_inzip);\n\n      Write_Zip64EndOfCentralDirectoryLocator(zi, Zip64EOCDpos);\n    }\n\n    if (err==ZIP_OK)\n      err = Write_EndOfCentralDirectoryRecord(zi, size_centraldir, centraldir_pos_inzip);\n\n    if(err == ZIP_OK)\n      err = Write_GlobalComment(zi, global_comment);\n\n    if (ZCLOSE64(zi->z_filefunc,zi->filestream) != 0)\n        if (err == ZIP_OK)\n            err = ZIP_ERRNO;\n\n#ifndef NO_ADDFILEINEXISTINGZIP\n    TRYFREE(zi->globalcomment);\n#endif\n    TRYFREE(zi);\n\n    return err;\n}\n\nextern int ZEXPORT zipRemoveExtraInfoBlock (char* pData, int* dataLen, short sHeader)\n{\n  char* p = pData;\n  int size = 0;\n  char* pNewHeader;\n  char* pTmp;\n  short header;\n  short dataSize;\n\n  int retVal = ZIP_OK;\n\n  if(pData == NULL || *dataLen < 4)\n    return ZIP_PARAMERROR;\n\n  pNewHeader = (char*)ALLOC(*dataLen);\n  pTmp = pNewHeader;\n\n  while(p < (pData + *dataLen))\n  {\n    header = *(short*)p;\n    dataSize = *(((short*)p)+1);\n\n    if( header == sHeader ) // Header found.\n    {\n      p += dataSize + 4; // skip it. do not copy to temp buffer\n    }\n    else\n    {\n      // Extra Info block should not be removed, So copy it to the temp buffer.\n      memcpy(pTmp, p, dataSize + 4);\n      p += dataSize + 4;\n      size += dataSize + 4;\n    }\n\n  }\n\n  if(size < *dataLen)\n  {\n    // clean old extra info block.\n    memset(pData,0, *dataLen);\n\n    // copy the new extra info block over the old\n    if(size > 0)\n      memcpy(pData, pNewHeader, size);\n\n    // set the new extra info size\n    *dataLen = size;\n\n    retVal = ZIP_OK;\n  }\n  else\n    retVal = ZIP_ERRNO;\n\n  TRYFREE(pNewHeader);\n\n  return retVal;\n}\n"
  },
  {
    "path": "Projects/Libraries/CSBase/Source/minizip/zip.h",
    "content": "/* zip.h -- IO on .zip files using zlib\n   Version 1.1, February 14h, 2010\n   part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )\n\n         Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html )\n\n         Modifications for Zip64 support\n         Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )\n\n         For more info read MiniZip_info.txt\n\n         ---------------------------------------------------------------------------\n\n   Condition of use and distribution are the same than zlib :\n\n  This software is provided 'as-is', without any express or implied\n  warranty.  In no event will the authors be held liable for any damages\n  arising from the use of this software.\n\n  Permission is granted to anyone to use this software for any purpose,\n  including commercial applications, and to alter it and redistribute it\n  freely, subject to the following restrictions:\n\n  1. The origin of this software must not be misrepresented; you must not\n     claim that you wrote the original software. If you use this software\n     in a product, an acknowledgment in the product documentation would be\n     appreciated but is not required.\n  2. Altered source versions must be plainly marked as such, and must not be\n     misrepresented as being the original software.\n  3. This notice may not be removed or altered from any source distribution.\n\n        ---------------------------------------------------------------------------\n\n        Changes\n\n        See header of zip.h\n\n*/\n\n#ifndef _zip12_H\n#define _zip12_H\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n//#define HAVE_BZIP2\n\n#ifndef _ZLIB_H\n#include \"zlib.h\"\n#endif\n\n#ifndef _ZLIBIOAPI_H\n#include \"ioapi.h\"\n#endif\n\n#ifdef HAVE_BZIP2\n#include \"bzlib.h\"\n#endif\n\n#define Z_BZIP2ED 12\n\n#if defined(STRICTZIP) || defined(STRICTZIPUNZIP)\n/* like the STRICT of WIN32, we define a pointer that cannot be converted\n    from (void*) without cast */\ntypedef struct TagzipFile__ { int unused; } zipFile__;\ntypedef zipFile__ *zipFile;\n#else\ntypedef voidp zipFile;\n#endif\n\n#define ZIP_OK                          (0)\n#define ZIP_EOF                         (0)\n#define ZIP_ERRNO                       (Z_ERRNO)\n#define ZIP_PARAMERROR                  (-102)\n#define ZIP_BADZIPFILE                  (-103)\n#define ZIP_INTERNALERROR               (-104)\n\n#ifndef DEF_MEM_LEVEL\n#  if MAX_MEM_LEVEL >= 8\n#    define DEF_MEM_LEVEL 8\n#  else\n#    define DEF_MEM_LEVEL  MAX_MEM_LEVEL\n#  endif\n#endif\n/* default memLevel */\n\n/* tm_zip contain date/time info */\ntypedef struct tm_zip_s\n{\n    uInt tm_sec;            /* seconds after the minute - [0,59] */\n    uInt tm_min;            /* minutes after the hour - [0,59] */\n    uInt tm_hour;           /* hours since midnight - [0,23] */\n    uInt tm_mday;           /* day of the month - [1,31] */\n    uInt tm_mon;            /* months since January - [0,11] */\n    uInt tm_year;           /* years - [1980..2044] */\n} tm_zip;\n\ntypedef struct\n{\n    tm_zip      tmz_date;       /* date in understandable format           */\n    uLong       dosDate;       /* if dos_date == 0, tmu_date is used      */\n/*    uLong       flag;        */   /* general purpose bit flag        2 bytes */\n\n    uLong       internal_fa;    /* internal file attributes        2 bytes */\n    uLong       external_fa;    /* external file attributes        4 bytes */\n} zip_fileinfo;\n\ntypedef const char* zipcharpc;\n\n\n#define APPEND_STATUS_CREATE        (0)\n#define APPEND_STATUS_CREATEAFTER   (1)\n#define APPEND_STATUS_ADDINZIP      (2)\n\nextern zipFile ZEXPORT zipOpen OF((const char *pathname, int append));\nextern zipFile ZEXPORT zipOpen64 OF((const void *pathname, int append));\n/*\n  Create a zipfile.\n     pathname contain on Windows XP a filename like \"c:\\\\zlib\\\\zlib113.zip\" or on\n       an Unix computer \"zlib/zlib113.zip\".\n     if the file pathname exist and append==APPEND_STATUS_CREATEAFTER, the zip\n       will be created at the end of the file.\n         (useful if the file contain a self extractor code)\n     if the file pathname exist and append==APPEND_STATUS_ADDINZIP, we will\n       add files in existing zip (be sure you don't add file that doesn't exist)\n     If the zipfile cannot be opened, the return value is NULL.\n     Else, the return value is a zipFile Handle, usable with other function\n       of this zip package.\n*/\n\n/* Note : there is no delete function into a zipfile.\n   If you want delete file into a zipfile, you must open a zipfile, and create another\n   Of couse, you can use RAW reading and writing to copy the file you did not want delte\n*/\n\nextern zipFile ZEXPORT zipOpen2 OF((const char *pathname,\n                                   int append,\n                                   zipcharpc* globalcomment,\n                                   zlib_filefunc_def* pzlib_filefunc_def));\n\nextern zipFile ZEXPORT zipOpen2_64 OF((const void *pathname,\n                                   int append,\n                                   zipcharpc* globalcomment,\n                                   zlib_filefunc64_def* pzlib_filefunc_def));\n\nextern int ZEXPORT zipOpenNewFileInZip OF((zipFile file,\n                       const char* filename,\n                       const zip_fileinfo* zipfi,\n                       const void* extrafield_local,\n                       uInt size_extrafield_local,\n                       const void* extrafield_global,\n                       uInt size_extrafield_global,\n                       const char* comment,\n                       int method,\n                       int level));\n\nextern int ZEXPORT zipOpenNewFileInZip64 OF((zipFile file,\n                       const char* filename,\n                       const zip_fileinfo* zipfi,\n                       const void* extrafield_local,\n                       uInt size_extrafield_local,\n                       const void* extrafield_global,\n                       uInt size_extrafield_global,\n                       const char* comment,\n                       int method,\n                       int level,\n                       int zip64));\n\n/*\n  Open a file in the ZIP for writing.\n  filename : the filename in zip (if NULL, '-' without quote will be used\n  *zipfi contain supplemental information\n  if extrafield_local!=NULL and size_extrafield_local>0, extrafield_local\n    contains the extrafield data the the local header\n  if extrafield_global!=NULL and size_extrafield_global>0, extrafield_global\n    contains the extrafield data the the local header\n  if comment != NULL, comment contain the comment string\n  method contain the compression method (0 for store, Z_DEFLATED for deflate)\n  level contain the level of compression (can be Z_DEFAULT_COMPRESSION)\n  zip64 is set to 1 if a zip64 extended information block should be added to the local file header.\n                    this MUST be '1' if the uncompressed size is >= 0xffffffff.\n\n*/\n\n\nextern int ZEXPORT zipOpenNewFileInZip2 OF((zipFile file,\n                                            const char* filename,\n                                            const zip_fileinfo* zipfi,\n                                            const void* extrafield_local,\n                                            uInt size_extrafield_local,\n                                            const void* extrafield_global,\n                                            uInt size_extrafield_global,\n                                            const char* comment,\n                                            int method,\n                                            int level,\n                                            int raw));\n\n\nextern int ZEXPORT zipOpenNewFileInZip2_64 OF((zipFile file,\n                                            const char* filename,\n                                            const zip_fileinfo* zipfi,\n                                            const void* extrafield_local,\n                                            uInt size_extrafield_local,\n                                            const void* extrafield_global,\n                                            uInt size_extrafield_global,\n                                            const char* comment,\n                                            int method,\n                                            int level,\n                                            int raw,\n                                            int zip64));\n/*\n  Same than zipOpenNewFileInZip, except if raw=1, we write raw file\n */\n\nextern int ZEXPORT zipOpenNewFileInZip3 OF((zipFile file,\n                                            const char* filename,\n                                            const zip_fileinfo* zipfi,\n                                            const void* extrafield_local,\n                                            uInt size_extrafield_local,\n                                            const void* extrafield_global,\n                                            uInt size_extrafield_global,\n                                            const char* comment,\n                                            int method,\n                                            int level,\n                                            int raw,\n                                            int windowBits,\n                                            int memLevel,\n                                            int strategy,\n                                            const char* password,\n                                            uLong crcForCrypting));\n\nextern int ZEXPORT zipOpenNewFileInZip3_64 OF((zipFile file,\n                                            const char* filename,\n                                            const zip_fileinfo* zipfi,\n                                            const void* extrafield_local,\n                                            uInt size_extrafield_local,\n                                            const void* extrafield_global,\n                                            uInt size_extrafield_global,\n                                            const char* comment,\n                                            int method,\n                                            int level,\n                                            int raw,\n                                            int windowBits,\n                                            int memLevel,\n                                            int strategy,\n                                            const char* password,\n                                            uLong crcForCrypting,\n                                            int zip64\n                                            ));\n\n/*\n  Same than zipOpenNewFileInZip2, except\n    windowBits,memLevel,,strategy : see parameter strategy in deflateInit2\n    password : crypting password (NULL for no crypting)\n    crcForCrypting : crc of file to compress (needed for crypting)\n */\n\nextern int ZEXPORT zipOpenNewFileInZip4 OF((zipFile file,\n                                            const char* filename,\n                                            const zip_fileinfo* zipfi,\n                                            const void* extrafield_local,\n                                            uInt size_extrafield_local,\n                                            const void* extrafield_global,\n                                            uInt size_extrafield_global,\n                                            const char* comment,\n                                            int method,\n                                            int level,\n                                            int raw,\n                                            int windowBits,\n                                            int memLevel,\n                                            int strategy,\n                                            const char* password,\n                                            uLong crcForCrypting,\n                                            uLong versionMadeBy,\n                                            uLong flagBase\n                                            ));\n\n\nextern int ZEXPORT zipOpenNewFileInZip4_64 OF((zipFile file,\n                                            const char* filename,\n                                            const zip_fileinfo* zipfi,\n                                            const void* extrafield_local,\n                                            uInt size_extrafield_local,\n                                            const void* extrafield_global,\n                                            uInt size_extrafield_global,\n                                            const char* comment,\n                                            int method,\n                                            int level,\n                                            int raw,\n                                            int windowBits,\n                                            int memLevel,\n                                            int strategy,\n                                            const char* password,\n                                            uLong crcForCrypting,\n                                            uLong versionMadeBy,\n                                            uLong flagBase,\n                                            int zip64\n                                            ));\n/*\n  Same than zipOpenNewFileInZip4, except\n    versionMadeBy : value for Version made by field\n    flag : value for flag field (compression level info will be added)\n */\n\n\nextern int ZEXPORT zipWriteInFileInZip OF((zipFile file,\n                       const void* buf,\n                       unsigned len));\n/*\n  Write data in the zipfile\n*/\n\nextern int ZEXPORT zipCloseFileInZip OF((zipFile file));\n/*\n  Close the current file in the zipfile\n*/\n\nextern int ZEXPORT zipCloseFileInZipRaw OF((zipFile file,\n                                            uLong uncompressed_size,\n                                            uLong crc32));\n\nextern int ZEXPORT zipCloseFileInZipRaw64 OF((zipFile file,\n                                            ZPOS64_T uncompressed_size,\n                                            uLong crc32));\n\n/*\n  Close the current file in the zipfile, for file opened with\n    parameter raw=1 in zipOpenNewFileInZip2\n  uncompressed_size and crc32 are value for the uncompressed size\n*/\n\nextern int ZEXPORT zipClose OF((zipFile file,\n                const char* global_comment));\n/*\n  Close the zipfile\n*/\n\n\nextern int ZEXPORT zipRemoveExtraInfoBlock OF((char* pData, int* dataLen, short sHeader));\n/*\n  zipRemoveExtraInfoBlock -  Added by Mathias Svensson\n\n  Remove extra information block from a extra information data for the local file header or central directory header\n\n  It is needed to remove ZIP64 extra information blocks when before data is written if using RAW mode.\n\n  0x0001 is the signature header for the ZIP64 extra information blocks\n\n  usage.\n                        Remove ZIP64 Extra information from a central director extra field data\n              zipRemoveExtraInfoBlock(pCenDirExtraFieldData, &nCenDirExtraFieldDataLen, 0x0001);\n\n                        Remove ZIP64 Extra information from a Local File Header extra field data\n        zipRemoveExtraInfoBlock(pLocalHeaderExtraFieldData, &nLocalHeaderExtraFieldDataLen, 0x0001);\n*/\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* _zip64_H */\n"
  },
  {
    "path": "Projects/Libraries/CSBase/Source/png/png.c",
    "content": "\n/* png.c - location for general purpose libpng functions\n *\n * Last changed in libpng 1.6.9 [February 6, 2014]\n * Copyright (c) 1998-2014 Glenn Randers-Pehrson\n * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)\n * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)\n *\n * This code is released under the libpng license.\n * For conditions of distribution and use, see the disclaimer\n * and license in png.h\n */\n\n#include \"pngpriv.h\"\n\n/* Generate a compiler error if there is an old png.h in the search path. */\ntypedef png_libpng_version_1_6_10 Your_png_h_is_not_version_1_6_10;\n\n/* Tells libpng that we have already handled the first \"num_bytes\" bytes\n * of the PNG file signature.  If the PNG data is embedded into another\n * stream we can set num_bytes = 8 so that libpng will not attempt to read\n * or write any of the magic bytes before it starts on the IHDR.\n */\n\n#ifdef PNG_READ_SUPPORTED\nvoid PNGAPI\npng_set_sig_bytes(png_structrp png_ptr, int num_bytes)\n{\n   png_debug(1, \"in png_set_sig_bytes\");\n\n   if (png_ptr == NULL)\n      return;\n\n   if (num_bytes > 8)\n      png_error(png_ptr, \"Too many bytes for PNG signature\");\n\n   png_ptr->sig_bytes = (png_byte)(num_bytes < 0 ? 0 : num_bytes);\n}\n\n/* Checks whether the supplied bytes match the PNG signature.  We allow\n * checking less than the full 8-byte signature so that those apps that\n * already read the first few bytes of a file to determine the file type\n * can simply check the remaining bytes for extra assurance.  Returns\n * an integer less than, equal to, or greater than zero if sig is found,\n * respectively, to be less than, to match, or be greater than the correct\n * PNG signature (this is the same behavior as strcmp, memcmp, etc).\n */\nint PNGAPI\npng_sig_cmp(png_const_bytep sig, png_size_t start, png_size_t num_to_check)\n{\n   png_byte png_signature[8] = {137, 80, 78, 71, 13, 10, 26, 10};\n\n   if (num_to_check > 8)\n      num_to_check = 8;\n\n   else if (num_to_check < 1)\n      return (-1);\n\n   if (start > 7)\n      return (-1);\n\n   if (start + num_to_check > 8)\n      num_to_check = 8 - start;\n\n   return ((int)(memcmp(&sig[start], &png_signature[start], num_to_check)));\n}\n\n#endif /* PNG_READ_SUPPORTED */\n\n#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)\n/* Function to allocate memory for zlib */\nPNG_FUNCTION(voidpf /* PRIVATE */,\npng_zalloc,(voidpf png_ptr, uInt items, uInt size),PNG_ALLOCATED)\n{\n   png_alloc_size_t num_bytes = size;\n\n   if (png_ptr == NULL)\n      return NULL;\n\n   if (items >= (~(png_alloc_size_t)0)/size)\n   {\n      png_warning (png_voidcast(png_structrp, png_ptr),\n         \"Potential overflow in png_zalloc()\");\n      return NULL;\n   }\n\n   num_bytes *= items;\n   return png_malloc_warn(png_voidcast(png_structrp, png_ptr), num_bytes);\n}\n\n/* Function to free memory for zlib */\nvoid /* PRIVATE */\npng_zfree(voidpf png_ptr, voidpf ptr)\n{\n   png_free(png_voidcast(png_const_structrp,png_ptr), ptr);\n}\n\n/* Reset the CRC variable to 32 bits of 1's.  Care must be taken\n * in case CRC is > 32 bits to leave the top bits 0.\n */\nvoid /* PRIVATE */\npng_reset_crc(png_structrp png_ptr)\n{\n   /* The cast is safe because the crc is a 32 bit value. */\n   png_ptr->crc = (png_uint_32)crc32(0, Z_NULL, 0);\n}\n\n/* Calculate the CRC over a section of data.  We can only pass as\n * much data to this routine as the largest single buffer size.  We\n * also check that this data will actually be used before going to the\n * trouble of calculating it.\n */\nvoid /* PRIVATE */\npng_calculate_crc(png_structrp png_ptr, png_const_bytep ptr, png_size_t length)\n{\n   int need_crc = 1;\n\n   if (PNG_CHUNK_ANCILLARY(png_ptr->chunk_name))\n   {\n      if ((png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_MASK) ==\n          (PNG_FLAG_CRC_ANCILLARY_USE | PNG_FLAG_CRC_ANCILLARY_NOWARN))\n         need_crc = 0;\n   }\n\n   else /* critical */\n   {\n      if (png_ptr->flags & PNG_FLAG_CRC_CRITICAL_IGNORE)\n         need_crc = 0;\n   }\n\n   /* 'uLong' is defined in zlib.h as unsigned long; this means that on some\n    * systems it is a 64 bit value.  crc32, however, returns 32 bits so the\n    * following cast is safe.  'uInt' may be no more than 16 bits, so it is\n    * necessary to perform a loop here.\n    */\n   if (need_crc && length > 0)\n   {\n      uLong crc = png_ptr->crc; /* Should never issue a warning */\n\n      do\n      {\n         uInt safe_length = (uInt)length;\n         if (safe_length == 0)\n            safe_length = (uInt)-1; /* evil, but safe */\n\n         crc = crc32(crc, ptr, safe_length);\n\n         /* The following should never issue compiler warnings; if they do the\n          * target system has characteristics that will probably violate other\n          * assumptions within the libpng code.\n          */\n         ptr += safe_length;\n         length -= safe_length;\n      }\n      while (length > 0);\n\n      /* And the following is always safe because the crc is only 32 bits. */\n      png_ptr->crc = (png_uint_32)crc;\n   }\n}\n\n/* Check a user supplied version number, called from both read and write\n * functions that create a png_struct.\n */\nint\npng_user_version_check(png_structrp png_ptr, png_const_charp user_png_ver)\n{\n   if (user_png_ver)\n   {\n      int i = 0;\n\n      do\n      {\n         if (user_png_ver[i] != png_libpng_ver[i])\n            png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH;\n      } while (png_libpng_ver[i++]);\n   }\n\n   else\n      png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH;\n\n   if (png_ptr->flags & PNG_FLAG_LIBRARY_MISMATCH)\n   {\n     /* Libpng 0.90 and later are binary incompatible with libpng 0.89, so\n      * we must recompile any applications that use any older library version.\n      * For versions after libpng 1.0, we will be compatible, so we need\n      * only check the first and third digits (note that when we reach version\n      * 1.10 we will need to check the fourth symbol, namely user_png_ver[3]).\n      */\n      if (user_png_ver == NULL || user_png_ver[0] != png_libpng_ver[0] ||\n          (user_png_ver[0] == '1' && (user_png_ver[2] != png_libpng_ver[2] ||\n          user_png_ver[3] != png_libpng_ver[3])) ||\n          (user_png_ver[0] == '0' && user_png_ver[2] < '9'))\n      {\n#ifdef PNG_WARNINGS_SUPPORTED\n         size_t pos = 0;\n         char m[128];\n\n         pos = png_safecat(m, (sizeof m), pos,\n             \"Application built with libpng-\");\n         pos = png_safecat(m, (sizeof m), pos, user_png_ver);\n         pos = png_safecat(m, (sizeof m), pos, \" but running with \");\n         pos = png_safecat(m, (sizeof m), pos, png_libpng_ver);\n         PNG_UNUSED(pos)\n\n         png_warning(png_ptr, m);\n#endif\n\n#ifdef PNG_ERROR_NUMBERS_SUPPORTED\n         png_ptr->flags = 0;\n#endif\n\n         return 0;\n      }\n   }\n\n   /* Success return. */\n   return 1;\n}\n\n/* Generic function to create a png_struct for either read or write - this\n * contains the common initialization.\n */\nPNG_FUNCTION(png_structp /* PRIVATE */,\npng_create_png_struct,(png_const_charp user_png_ver, png_voidp error_ptr,\n    png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr,\n    png_malloc_ptr malloc_fn, png_free_ptr free_fn),PNG_ALLOCATED)\n{\n   png_struct create_struct;\n#  ifdef PNG_SETJMP_SUPPORTED\n      jmp_buf create_jmp_buf;\n#  endif\n\n   /* This temporary stack-allocated structure is used to provide a place to\n    * build enough context to allow the user provided memory allocator (if any)\n    * to be called.\n    */\n   memset(&create_struct, 0, (sizeof create_struct));\n\n   /* Added at libpng-1.2.6 */\n#  ifdef PNG_USER_LIMITS_SUPPORTED\n      create_struct.user_width_max = PNG_USER_WIDTH_MAX;\n      create_struct.user_height_max = PNG_USER_HEIGHT_MAX;\n\n#     ifdef PNG_USER_CHUNK_CACHE_MAX\n         /* Added at libpng-1.2.43 and 1.4.0 */\n         create_struct.user_chunk_cache_max = PNG_USER_CHUNK_CACHE_MAX;\n#     endif\n\n#     ifdef PNG_USER_CHUNK_MALLOC_MAX\n         /* Added at libpng-1.2.43 and 1.4.1, required only for read but exists\n          * in png_struct regardless.\n          */\n         create_struct.user_chunk_malloc_max = PNG_USER_CHUNK_MALLOC_MAX;\n#     endif\n#  endif\n\n   /* The following two API calls simply set fields in png_struct, so it is safe\n    * to do them now even though error handling is not yet set up.\n    */\n#  ifdef PNG_USER_MEM_SUPPORTED\n      png_set_mem_fn(&create_struct, mem_ptr, malloc_fn, free_fn);\n#  else\n      PNG_UNUSED(mem_ptr)\n      PNG_UNUSED(malloc_fn)\n      PNG_UNUSED(free_fn)\n#  endif\n\n   /* (*error_fn) can return control to the caller after the error_ptr is set,\n    * this will result in a memory leak unless the error_fn does something\n    * extremely sophisticated.  The design lacks merit but is implicit in the\n    * API.\n    */\n   png_set_error_fn(&create_struct, error_ptr, error_fn, warn_fn);\n\n#  ifdef PNG_SETJMP_SUPPORTED\n      if (!setjmp(create_jmp_buf))\n      {\n         /* Temporarily fake out the longjmp information until we have\n          * successfully completed this function.  This only works if we have\n          * setjmp() support compiled in, but it is safe - this stuff should\n          * never happen.\n          */\n         create_struct.jmp_buf_ptr = &create_jmp_buf;\n         create_struct.jmp_buf_size = 0; /*stack allocation*/\n         create_struct.longjmp_fn = longjmp;\n#  else\n      {\n#  endif\n         /* Call the general version checker (shared with read and write code):\n          */\n         if (png_user_version_check(&create_struct, user_png_ver))\n         {\n            png_structrp png_ptr = png_voidcast(png_structrp,\n               png_malloc_warn(&create_struct, (sizeof *png_ptr)));\n\n            if (png_ptr != NULL)\n            {\n               /* png_ptr->zstream holds a back-pointer to the png_struct, so\n                * this can only be done now:\n                */\n               create_struct.zstream.zalloc = png_zalloc;\n               create_struct.zstream.zfree = png_zfree;\n               create_struct.zstream.opaque = png_ptr;\n\n#              ifdef PNG_SETJMP_SUPPORTED\n                  /* Eliminate the local error handling: */\n                  create_struct.jmp_buf_ptr = NULL;\n                  create_struct.jmp_buf_size = 0;\n                  create_struct.longjmp_fn = 0;\n#              endif\n\n               *png_ptr = create_struct;\n\n               /* This is the successful return point */\n               return png_ptr;\n            }\n         }\n      }\n\n   /* A longjmp because of a bug in the application storage allocator or a\n    * simple failure to allocate the png_struct.\n    */\n   return NULL;\n}\n\n/* Allocate the memory for an info_struct for the application. */\nPNG_FUNCTION(png_infop,PNGAPI\npng_create_info_struct,(png_const_structrp png_ptr),PNG_ALLOCATED)\n{\n   png_inforp info_ptr;\n\n   png_debug(1, \"in png_create_info_struct\");\n\n   if (png_ptr == NULL)\n      return NULL;\n\n   /* Use the internal API that does not (or at least should not) error out, so\n    * that this call always returns ok.  The application typically sets up the\n    * error handling *after* creating the info_struct because this is the way it\n    * has always been done in 'example.c'.\n    */\n   info_ptr = png_voidcast(png_inforp, png_malloc_base(png_ptr,\n      (sizeof *info_ptr)));\n\n   if (info_ptr != NULL)\n      memset(info_ptr, 0, (sizeof *info_ptr));\n\n   return info_ptr;\n}\n\n/* This function frees the memory associated with a single info struct.\n * Normally, one would use either png_destroy_read_struct() or\n * png_destroy_write_struct() to free an info struct, but this may be\n * useful for some applications.  From libpng 1.6.0 this function is also used\n * internally to implement the png_info release part of the 'struct' destroy\n * APIs.  This ensures that all possible approaches free the same data (all of\n * it).\n */\nvoid PNGAPI\npng_destroy_info_struct(png_const_structrp png_ptr, png_infopp info_ptr_ptr)\n{\n   png_inforp info_ptr = NULL;\n\n   png_debug(1, \"in png_destroy_info_struct\");\n\n   if (png_ptr == NULL)\n      return;\n\n   if (info_ptr_ptr != NULL)\n      info_ptr = *info_ptr_ptr;\n\n   if (info_ptr != NULL)\n   {\n      /* Do this first in case of an error below; if the app implements its own\n       * memory management this can lead to png_free calling png_error, which\n       * will abort this routine and return control to the app error handler.\n       * An infinite loop may result if it then tries to free the same info\n       * ptr.\n       */\n      *info_ptr_ptr = NULL;\n\n      png_free_data(png_ptr, info_ptr, PNG_FREE_ALL, -1);\n      memset(info_ptr, 0, (sizeof *info_ptr));\n      png_free(png_ptr, info_ptr);\n   }\n}\n\n/* Initialize the info structure.  This is now an internal function (0.89)\n * and applications using it are urged to use png_create_info_struct()\n * instead.  Use deprecated in 1.6.0, internal use removed (used internally it\n * is just a memset).\n *\n * NOTE: it is almost inconceivable that this API is used because it bypasses\n * the user-memory mechanism and the user error handling/warning mechanisms in\n * those cases where it does anything other than a memset.\n */\nPNG_FUNCTION(void,PNGAPI\npng_info_init_3,(png_infopp ptr_ptr, png_size_t png_info_struct_size),\n   PNG_DEPRECATED)\n{\n   png_inforp info_ptr = *ptr_ptr;\n\n   png_debug(1, \"in png_info_init_3\");\n\n   if (info_ptr == NULL)\n      return;\n\n   if ((sizeof (png_info)) > png_info_struct_size)\n   {\n      *ptr_ptr = NULL;\n      /* The following line is why this API should not be used: */\n      free(info_ptr);\n      info_ptr = png_voidcast(png_inforp, png_malloc_base(NULL,\n         (sizeof *info_ptr)));\n      *ptr_ptr = info_ptr;\n   }\n\n   /* Set everything to 0 */\n   memset(info_ptr, 0, (sizeof *info_ptr));\n}\n\n/* The following API is not called internally */\nvoid PNGAPI\npng_data_freer(png_const_structrp png_ptr, png_inforp info_ptr,\n   int freer, png_uint_32 mask)\n{\n   png_debug(1, \"in png_data_freer\");\n\n   if (png_ptr == NULL || info_ptr == NULL)\n      return;\n\n   if (freer == PNG_DESTROY_WILL_FREE_DATA)\n      info_ptr->free_me |= mask;\n\n   else if (freer == PNG_USER_WILL_FREE_DATA)\n      info_ptr->free_me &= ~mask;\n\n   else\n      png_error(png_ptr, \"Unknown freer parameter in png_data_freer\");\n}\n\nvoid PNGAPI\npng_free_data(png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 mask,\n   int num)\n{\n   png_debug(1, \"in png_free_data\");\n\n   if (png_ptr == NULL || info_ptr == NULL)\n      return;\n\n#ifdef PNG_TEXT_SUPPORTED\n   /* Free text item num or (if num == -1) all text items */\n   if ((mask & PNG_FREE_TEXT) & info_ptr->free_me)\n   {\n      if (num != -1)\n      {\n         if (info_ptr->text && info_ptr->text[num].key)\n         {\n            png_free(png_ptr, info_ptr->text[num].key);\n            info_ptr->text[num].key = NULL;\n         }\n      }\n\n      else\n      {\n         int i;\n         for (i = 0; i < info_ptr->num_text; i++)\n             png_free_data(png_ptr, info_ptr, PNG_FREE_TEXT, i);\n         png_free(png_ptr, info_ptr->text);\n         info_ptr->text = NULL;\n         info_ptr->num_text=0;\n      }\n   }\n#endif\n\n#ifdef PNG_tRNS_SUPPORTED\n   /* Free any tRNS entry */\n   if ((mask & PNG_FREE_TRNS) & info_ptr->free_me)\n   {\n      png_free(png_ptr, info_ptr->trans_alpha);\n      info_ptr->trans_alpha = NULL;\n      info_ptr->valid &= ~PNG_INFO_tRNS;\n   }\n#endif\n\n#ifdef PNG_sCAL_SUPPORTED\n   /* Free any sCAL entry */\n   if ((mask & PNG_FREE_SCAL) & info_ptr->free_me)\n   {\n      png_free(png_ptr, info_ptr->scal_s_width);\n      png_free(png_ptr, info_ptr->scal_s_height);\n      info_ptr->scal_s_width = NULL;\n      info_ptr->scal_s_height = NULL;\n      info_ptr->valid &= ~PNG_INFO_sCAL;\n   }\n#endif\n\n#ifdef PNG_pCAL_SUPPORTED\n   /* Free any pCAL entry */\n   if ((mask & PNG_FREE_PCAL) & info_ptr->free_me)\n   {\n      png_free(png_ptr, info_ptr->pcal_purpose);\n      png_free(png_ptr, info_ptr->pcal_units);\n      info_ptr->pcal_purpose = NULL;\n      info_ptr->pcal_units = NULL;\n      if (info_ptr->pcal_params != NULL)\n         {\n            unsigned int i;\n            for (i = 0; i < info_ptr->pcal_nparams; i++)\n            {\n               png_free(png_ptr, info_ptr->pcal_params[i]);\n               info_ptr->pcal_params[i] = NULL;\n            }\n            png_free(png_ptr, info_ptr->pcal_params);\n            info_ptr->pcal_params = NULL;\n         }\n      info_ptr->valid &= ~PNG_INFO_pCAL;\n   }\n#endif\n\n#ifdef PNG_iCCP_SUPPORTED\n   /* Free any profile entry */\n   if ((mask & PNG_FREE_ICCP) & info_ptr->free_me)\n   {\n      png_free(png_ptr, info_ptr->iccp_name);\n      png_free(png_ptr, info_ptr->iccp_profile);\n      info_ptr->iccp_name = NULL;\n      info_ptr->iccp_profile = NULL;\n      info_ptr->valid &= ~PNG_INFO_iCCP;\n   }\n#endif\n\n#ifdef PNG_sPLT_SUPPORTED\n   /* Free a given sPLT entry, or (if num == -1) all sPLT entries */\n   if ((mask & PNG_FREE_SPLT) & info_ptr->free_me)\n   {\n      if (num != -1)\n      {\n         if (info_ptr->splt_palettes)\n         {\n            png_free(png_ptr, info_ptr->splt_palettes[num].name);\n            png_free(png_ptr, info_ptr->splt_palettes[num].entries);\n            info_ptr->splt_palettes[num].name = NULL;\n            info_ptr->splt_palettes[num].entries = NULL;\n         }\n      }\n\n      else\n      {\n         if (info_ptr->splt_palettes_num)\n         {\n            int i;\n            for (i = 0; i < info_ptr->splt_palettes_num; i++)\n               png_free_data(png_ptr, info_ptr, PNG_FREE_SPLT, (int)i);\n\n            png_free(png_ptr, info_ptr->splt_palettes);\n            info_ptr->splt_palettes = NULL;\n            info_ptr->splt_palettes_num = 0;\n         }\n         info_ptr->valid &= ~PNG_INFO_sPLT;\n      }\n   }\n#endif\n\n#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED\n   if ((mask & PNG_FREE_UNKN) & info_ptr->free_me)\n   {\n      if (num != -1)\n      {\n          if (info_ptr->unknown_chunks)\n          {\n             png_free(png_ptr, info_ptr->unknown_chunks[num].data);\n             info_ptr->unknown_chunks[num].data = NULL;\n          }\n      }\n\n      else\n      {\n         int i;\n\n         if (info_ptr->unknown_chunks_num)\n         {\n            for (i = 0; i < info_ptr->unknown_chunks_num; i++)\n               png_free_data(png_ptr, info_ptr, PNG_FREE_UNKN, (int)i);\n\n            png_free(png_ptr, info_ptr->unknown_chunks);\n            info_ptr->unknown_chunks = NULL;\n            info_ptr->unknown_chunks_num = 0;\n         }\n      }\n   }\n#endif\n\n#ifdef PNG_hIST_SUPPORTED\n   /* Free any hIST entry */\n   if ((mask & PNG_FREE_HIST)  & info_ptr->free_me)\n   {\n      png_free(png_ptr, info_ptr->hist);\n      info_ptr->hist = NULL;\n      info_ptr->valid &= ~PNG_INFO_hIST;\n   }\n#endif\n\n   /* Free any PLTE entry that was internally allocated */\n   if ((mask & PNG_FREE_PLTE) & info_ptr->free_me)\n   {\n      png_free(png_ptr, info_ptr->palette);\n      info_ptr->palette = NULL;\n      info_ptr->valid &= ~PNG_INFO_PLTE;\n      info_ptr->num_palette = 0;\n   }\n\n#ifdef PNG_INFO_IMAGE_SUPPORTED\n   /* Free any image bits attached to the info structure */\n   if ((mask & PNG_FREE_ROWS) & info_ptr->free_me)\n   {\n      if (info_ptr->row_pointers)\n      {\n         png_uint_32 row;\n         for (row = 0; row < info_ptr->height; row++)\n         {\n            png_free(png_ptr, info_ptr->row_pointers[row]);\n            info_ptr->row_pointers[row] = NULL;\n         }\n         png_free(png_ptr, info_ptr->row_pointers);\n         info_ptr->row_pointers = NULL;\n      }\n      info_ptr->valid &= ~PNG_INFO_IDAT;\n   }\n#endif\n\n   if (num != -1)\n      mask &= ~PNG_FREE_MUL;\n\n   info_ptr->free_me &= ~mask;\n}\n#endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */\n\n/* This function returns a pointer to the io_ptr associated with the user\n * functions.  The application should free any memory associated with this\n * pointer before png_write_destroy() or png_read_destroy() are called.\n */\npng_voidp PNGAPI\npng_get_io_ptr(png_const_structrp png_ptr)\n{\n   if (png_ptr == NULL)\n      return (NULL);\n\n   return (png_ptr->io_ptr);\n}\n\n#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)\n#  ifdef PNG_STDIO_SUPPORTED\n/* Initialize the default input/output functions for the PNG file.  If you\n * use your own read or write routines, you can call either png_set_read_fn()\n * or png_set_write_fn() instead of png_init_io().  If you have defined\n * PNG_NO_STDIO or otherwise disabled PNG_STDIO_SUPPORTED, you must use a\n * function of your own because \"FILE *\" isn't necessarily available.\n */\nvoid PNGAPI\npng_init_io(png_structrp png_ptr, png_FILE_p fp)\n{\n   png_debug(1, \"in png_init_io\");\n\n   if (png_ptr == NULL)\n      return;\n\n   png_ptr->io_ptr = (png_voidp)fp;\n}\n#  endif\n\n#ifdef PNG_SAVE_INT_32_SUPPORTED\n/* The png_save_int_32 function assumes integers are stored in two's\n * complement format.  If this isn't the case, then this routine needs to\n * be modified to write data in two's complement format.  Note that,\n * the following works correctly even if png_int_32 has more than 32 bits\n * (compare the more complex code required on read for sign extension.)\n */\nvoid PNGAPI\npng_save_int_32(png_bytep buf, png_int_32 i)\n{\n   buf[0] = (png_byte)((i >> 24) & 0xff);\n   buf[1] = (png_byte)((i >> 16) & 0xff);\n   buf[2] = (png_byte)((i >> 8) & 0xff);\n   buf[3] = (png_byte)(i & 0xff);\n}\n#endif\n\n#  ifdef PNG_TIME_RFC1123_SUPPORTED\n/* Convert the supplied time into an RFC 1123 string suitable for use in\n * a \"Creation Time\" or other text-based time string.\n */\nint PNGAPI\npng_convert_to_rfc1123_buffer(char out[29], png_const_timep ptime)\n{\n   static PNG_CONST char short_months[12][4] =\n        {\"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\",\n         \"Jul\", \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\"};\n\n   if (out == NULL)\n      return 0;\n\n   if (ptime->year > 9999 /* RFC1123 limitation */ ||\n       ptime->month == 0    ||  ptime->month > 12  ||\n       ptime->day   == 0    ||  ptime->day   > 31  ||\n       ptime->hour  > 23    ||  ptime->minute > 59 ||\n       ptime->second > 60)\n      return 0;\n\n   {\n      size_t pos = 0;\n      char number_buf[5]; /* enough for a four-digit year */\n\n#     define APPEND_STRING(string) pos = png_safecat(out, 29, pos, (string))\n#     define APPEND_NUMBER(format, value)\\\n         APPEND_STRING(PNG_FORMAT_NUMBER(number_buf, format, (value)))\n#     define APPEND(ch) if (pos < 28) out[pos++] = (ch)\n\n      APPEND_NUMBER(PNG_NUMBER_FORMAT_u, (unsigned)ptime->day);\n      APPEND(' ');\n      APPEND_STRING(short_months[(ptime->month - 1)]);\n      APPEND(' ');\n      APPEND_NUMBER(PNG_NUMBER_FORMAT_u, ptime->year);\n      APPEND(' ');\n      APPEND_NUMBER(PNG_NUMBER_FORMAT_02u, (unsigned)ptime->hour);\n      APPEND(':');\n      APPEND_NUMBER(PNG_NUMBER_FORMAT_02u, (unsigned)ptime->minute);\n      APPEND(':');\n      APPEND_NUMBER(PNG_NUMBER_FORMAT_02u, (unsigned)ptime->second);\n      APPEND_STRING(\" +0000\"); /* This reliably terminates the buffer */\n\n#     undef APPEND\n#     undef APPEND_NUMBER\n#     undef APPEND_STRING\n   }\n\n   return 1;\n}\n\n#     if PNG_LIBPNG_VER < 10700\n/* To do: remove the following from libpng-1.7 */\n/* Original API that uses a private buffer in png_struct.\n * Deprecated because it causes png_struct to carry a spurious temporary\n * buffer (png_struct::time_buffer), better to have the caller pass this in.\n */\npng_const_charp PNGAPI\npng_convert_to_rfc1123(png_structrp png_ptr, png_const_timep ptime)\n{\n   if (png_ptr != NULL)\n   {\n      /* The only failure above if png_ptr != NULL is from an invalid ptime */\n      if (!png_convert_to_rfc1123_buffer(png_ptr->time_buffer, ptime))\n         png_warning(png_ptr, \"Ignoring invalid time value\");\n\n      else\n         return png_ptr->time_buffer;\n   }\n\n   return NULL;\n}\n#     endif\n#  endif /* PNG_TIME_RFC1123_SUPPORTED */\n\n#endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */\n\npng_const_charp PNGAPI\npng_get_copyright(png_const_structrp png_ptr)\n{\n   PNG_UNUSED(png_ptr)  /* Silence compiler warning about unused png_ptr */\n#ifdef PNG_STRING_COPYRIGHT\n   return PNG_STRING_COPYRIGHT\n#else\n#  ifdef __STDC__\n   return PNG_STRING_NEWLINE \\\n     \"libpng version 1.6.10 - March 6, 2014\" PNG_STRING_NEWLINE \\\n     \"Copyright (c) 1998-2014 Glenn Randers-Pehrson\" PNG_STRING_NEWLINE \\\n     \"Copyright (c) 1996-1997 Andreas Dilger\" PNG_STRING_NEWLINE \\\n     \"Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.\" \\\n     PNG_STRING_NEWLINE;\n#  else\n      return \"libpng version 1.6.10 - March 6, 2014\\\n      Copyright (c) 1998-2014 Glenn Randers-Pehrson\\\n      Copyright (c) 1996-1997 Andreas Dilger\\\n      Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.\";\n#  endif\n#endif\n}\n\n/* The following return the library version as a short string in the\n * format 1.0.0 through 99.99.99zz.  To get the version of *.h files\n * used with your application, print out PNG_LIBPNG_VER_STRING, which\n * is defined in png.h.\n * Note: now there is no difference between png_get_libpng_ver() and\n * png_get_header_ver().  Due to the version_nn_nn_nn typedef guard,\n * it is guaranteed that png.c uses the correct version of png.h.\n */\npng_const_charp PNGAPI\npng_get_libpng_ver(png_const_structrp png_ptr)\n{\n   /* Version of *.c files used when building libpng */\n   return png_get_header_ver(png_ptr);\n}\n\npng_const_charp PNGAPI\npng_get_header_ver(png_const_structrp png_ptr)\n{\n   /* Version of *.h files used when building libpng */\n   PNG_UNUSED(png_ptr)  /* Silence compiler warning about unused png_ptr */\n   return PNG_LIBPNG_VER_STRING;\n}\n\npng_const_charp PNGAPI\npng_get_header_version(png_const_structrp png_ptr)\n{\n   /* Returns longer string containing both version and date */\n   PNG_UNUSED(png_ptr)  /* Silence compiler warning about unused png_ptr */\n#ifdef __STDC__\n   return PNG_HEADER_VERSION_STRING\n#  ifndef PNG_READ_SUPPORTED\n   \"     (NO READ SUPPORT)\"\n#  endif\n   PNG_STRING_NEWLINE;\n#else\n   return PNG_HEADER_VERSION_STRING;\n#endif\n}\n\n#ifdef PNG_BUILD_GRAYSCALE_PALETTE_SUPPORTED\n/* NOTE: this routine is not used internally! */\n/* Build a grayscale palette.  Palette is assumed to be 1 << bit_depth\n * large of png_color.  This lets grayscale images be treated as\n * paletted.  Most useful for gamma correction and simplification\n * of code.  This API is not used internally.\n */\nvoid PNGAPI\npng_build_grayscale_palette(int bit_depth, png_colorp palette)\n{\n   int num_palette;\n   int color_inc;\n   int i;\n   int v;\n\n   png_debug(1, \"in png_do_build_grayscale_palette\");\n\n   if (palette == NULL)\n      return;\n\n   switch (bit_depth)\n   {\n      case 1:\n         num_palette = 2;\n         color_inc = 0xff;\n         break;\n\n      case 2:\n         num_palette = 4;\n         color_inc = 0x55;\n         break;\n\n      case 4:\n         num_palette = 16;\n         color_inc = 0x11;\n         break;\n\n      case 8:\n         num_palette = 256;\n         color_inc = 1;\n         break;\n\n      default:\n         num_palette = 0;\n         color_inc = 0;\n         break;\n   }\n\n   for (i = 0, v = 0; i < num_palette; i++, v += color_inc)\n   {\n      palette[i].red = (png_byte)v;\n      palette[i].green = (png_byte)v;\n      palette[i].blue = (png_byte)v;\n   }\n}\n#endif\n\n#ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED\nint PNGAPI\npng_handle_as_unknown(png_const_structrp png_ptr, png_const_bytep chunk_name)\n{\n   /* Check chunk_name and return \"keep\" value if it's on the list, else 0 */\n   png_const_bytep p, p_end;\n\n   if (png_ptr == NULL || chunk_name == NULL || png_ptr->num_chunk_list == 0)\n      return PNG_HANDLE_CHUNK_AS_DEFAULT;\n\n   p_end = png_ptr->chunk_list;\n   p = p_end + png_ptr->num_chunk_list*5; /* beyond end */\n\n   /* The code is the fifth byte after each four byte string.  Historically this\n    * code was always searched from the end of the list, this is no longer\n    * necessary because the 'set' routine handles duplicate entries correcty.\n    */\n   do /* num_chunk_list > 0, so at least one */\n   {\n      p -= 5;\n\n      if (!memcmp(chunk_name, p, 4))\n         return p[4];\n   }\n   while (p > p_end);\n\n   /* This means that known chunks should be processed and unknown chunks should\n    * be handled according to the value of png_ptr->unknown_default; this can be\n    * confusing because, as a result, there are two levels of defaulting for\n    * unknown chunks.\n    */\n   return PNG_HANDLE_CHUNK_AS_DEFAULT;\n}\n\n#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) ||\\\n   defined(PNG_HANDLE_AS_UNKNOWN_SUPPORTED)\nint /* PRIVATE */\npng_chunk_unknown_handling(png_const_structrp png_ptr, png_uint_32 chunk_name)\n{\n   png_byte chunk_string[5];\n\n   PNG_CSTRING_FROM_CHUNK(chunk_string, chunk_name);\n   return png_handle_as_unknown(png_ptr, chunk_string);\n}\n#endif /* READ_UNKNOWN_CHUNKS || HANDLE_AS_UNKNOWN */\n#endif /* SET_UNKNOWN_CHUNKS */\n\n#ifdef PNG_READ_SUPPORTED\n/* This function, added to libpng-1.0.6g, is untested. */\nint PNGAPI\npng_reset_zstream(png_structrp png_ptr)\n{\n   if (png_ptr == NULL)\n      return Z_STREAM_ERROR;\n\n   /* WARNING: this resets the window bits to the maximum! */\n   return (inflateReset(&png_ptr->zstream));\n}\n#endif /* PNG_READ_SUPPORTED */\n\n/* This function was added to libpng-1.0.7 */\npng_uint_32 PNGAPI\npng_access_version_number(void)\n{\n   /* Version of *.c files used when building libpng */\n   return((png_uint_32)PNG_LIBPNG_VER);\n}\n\n\n\n#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)\n/* Ensure that png_ptr->zstream.msg holds some appropriate error message string.\n * If it doesn't 'ret' is used to set it to something appropriate, even in cases\n * like Z_OK or Z_STREAM_END where the error code is apparently a success code.\n */\nvoid /* PRIVATE */\npng_zstream_error(png_structrp png_ptr, int ret)\n{\n   /* Translate 'ret' into an appropriate error string, priority is given to the\n    * one in zstream if set.  This always returns a string, even in cases like\n    * Z_OK or Z_STREAM_END where the error code is a success code.\n    */\n   if (png_ptr->zstream.msg == NULL) switch (ret)\n   {\n      default:\n      case Z_OK:\n         png_ptr->zstream.msg = PNGZ_MSG_CAST(\"unexpected zlib return code\");\n         break;\n\n      case Z_STREAM_END:\n         /* Normal exit */\n         png_ptr->zstream.msg = PNGZ_MSG_CAST(\"unexpected end of LZ stream\");\n         break;\n\n      case Z_NEED_DICT:\n         /* This means the deflate stream did not have a dictionary; this\n          * indicates a bogus PNG.\n          */\n         png_ptr->zstream.msg = PNGZ_MSG_CAST(\"missing LZ dictionary\");\n         break;\n\n      case Z_ERRNO:\n         /* gz APIs only: should not happen */\n         png_ptr->zstream.msg = PNGZ_MSG_CAST(\"zlib IO error\");\n         break;\n\n      case Z_STREAM_ERROR:\n         /* internal libpng error */\n         png_ptr->zstream.msg = PNGZ_MSG_CAST(\"bad parameters to zlib\");\n         break;\n\n      case Z_DATA_ERROR:\n         png_ptr->zstream.msg = PNGZ_MSG_CAST(\"damaged LZ stream\");\n         break;\n\n      case Z_MEM_ERROR:\n         png_ptr->zstream.msg = PNGZ_MSG_CAST(\"insufficient memory\");\n         break;\n\n      case Z_BUF_ERROR:\n         /* End of input or output; not a problem if the caller is doing\n          * incremental read or write.\n          */\n         png_ptr->zstream.msg = PNGZ_MSG_CAST(\"truncated\");\n         break;\n\n      case Z_VERSION_ERROR:\n         png_ptr->zstream.msg = PNGZ_MSG_CAST(\"unsupported zlib version\");\n         break;\n\n      case PNG_UNEXPECTED_ZLIB_RETURN:\n         /* Compile errors here mean that zlib now uses the value co-opted in\n          * pngpriv.h for PNG_UNEXPECTED_ZLIB_RETURN; update the switch above\n          * and change pngpriv.h.  Note that this message is \"... return\",\n          * whereas the default/Z_OK one is \"... return code\".\n          */\n         png_ptr->zstream.msg = PNGZ_MSG_CAST(\"unexpected zlib return\");\n         break;\n   }\n}\n\n/* png_convert_size: a PNGAPI but no longer in png.h, so deleted\n * at libpng 1.5.5!\n */\n\n/* Added at libpng version 1.2.34 and 1.4.0 (moved from pngset.c) */\n#ifdef PNG_GAMMA_SUPPORTED /* always set if COLORSPACE */\nstatic int\npng_colorspace_check_gamma(png_const_structrp png_ptr,\n   png_colorspacerp colorspace, png_fixed_point gAMA, int from)\n   /* This is called to check a new gamma value against an existing one.  The\n    * routine returns false if the new gamma value should not be written.\n    *\n    * 'from' says where the new gamma value comes from:\n    *\n    *    0: the new gamma value is the libpng estimate for an ICC profile\n    *    1: the new gamma value comes from a gAMA chunk\n    *    2: the new gamma value comes from an sRGB chunk\n    */\n{\n   png_fixed_point gtest;\n\n   if ((colorspace->flags & PNG_COLORSPACE_HAVE_GAMMA) != 0 &&\n      (!png_muldiv(&gtest, colorspace->gamma, PNG_FP_1, gAMA) ||\n      png_gamma_significant(gtest)))\n   {\n      /* Either this is an sRGB image, in which case the calculated gamma\n       * approximation should match, or this is an image with a profile and the\n       * value libpng calculates for the gamma of the profile does not match the\n       * value recorded in the file.  The former, sRGB, case is an error, the\n       * latter is just a warning.\n       */\n      if ((colorspace->flags & PNG_COLORSPACE_FROM_sRGB) != 0 || from == 2)\n      {\n         png_chunk_report(png_ptr, \"gamma value does not match sRGB\",\n            PNG_CHUNK_ERROR);\n         /* Do not overwrite an sRGB value */\n         return from == 2;\n      }\n\n      else /* sRGB tag not involved */\n      {\n         png_chunk_report(png_ptr, \"gamma value does not match libpng estimate\",\n            PNG_CHUNK_WARNING);\n         return from == 1;\n      }\n   }\n\n   return 1;\n}\n\nvoid /* PRIVATE */\npng_colorspace_set_gamma(png_const_structrp png_ptr,\n   png_colorspacerp colorspace, png_fixed_point gAMA)\n{\n   /* Changed in libpng-1.5.4 to limit the values to ensure overflow can't\n    * occur.  Since the fixed point representation is assymetrical it is\n    * possible for 1/gamma to overflow the limit of 21474 and this means the\n    * gamma value must be at least 5/100000 and hence at most 20000.0.  For\n    * safety the limits here are a little narrower.  The values are 0.00016 to\n    * 6250.0, which are truly ridiculous gamma values (and will produce\n    * displays that are all black or all white.)\n    *\n    * In 1.6.0 this test replaces the ones in pngrutil.c, in the gAMA chunk\n    * handling code, which only required the value to be >0.\n    */\n   png_const_charp errmsg;\n\n   if (gAMA < 16 || gAMA > 625000000)\n      errmsg = \"gamma value out of range\";\n\n#  ifdef PNG_READ_gAMA_SUPPORTED\n      /* Allow the application to set the gamma value more than once */\n      else if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0 &&\n         (colorspace->flags & PNG_COLORSPACE_FROM_gAMA) != 0)\n         errmsg = \"duplicate\";\n#  endif\n\n   /* Do nothing if the colorspace is already invalid */\n   else if (colorspace->flags & PNG_COLORSPACE_INVALID)\n      return;\n\n   else\n   {\n      if (png_colorspace_check_gamma(png_ptr, colorspace, gAMA, 1/*from gAMA*/))\n      {\n         /* Store this gamma value. */\n         colorspace->gamma = gAMA;\n         colorspace->flags |=\n            (PNG_COLORSPACE_HAVE_GAMMA | PNG_COLORSPACE_FROM_gAMA);\n      }\n\n      /* At present if the check_gamma test fails the gamma of the colorspace is\n       * not updated however the colorspace is not invalidated.  This\n       * corresponds to the case where the existing gamma comes from an sRGB\n       * chunk or profile.  An error message has already been output.\n       */\n      return;\n   }\n\n   /* Error exit - errmsg has been set. */\n   colorspace->flags |= PNG_COLORSPACE_INVALID;\n   png_chunk_report(png_ptr, errmsg, PNG_CHUNK_WRITE_ERROR);\n}\n\nvoid /* PRIVATE */\npng_colorspace_sync_info(png_const_structrp png_ptr, png_inforp info_ptr)\n{\n   if (info_ptr->colorspace.flags & PNG_COLORSPACE_INVALID)\n   {\n      /* Everything is invalid */\n      info_ptr->valid &= ~(PNG_INFO_gAMA|PNG_INFO_cHRM|PNG_INFO_sRGB|\n         PNG_INFO_iCCP);\n\n#     ifdef PNG_COLORSPACE_SUPPORTED\n         /* Clean up the iCCP profile now if it won't be used. */\n         png_free_data(png_ptr, info_ptr, PNG_FREE_ICCP, -1/*not used*/);\n#     else\n         PNG_UNUSED(png_ptr)\n#     endif\n   }\n\n   else\n   {\n#     ifdef PNG_COLORSPACE_SUPPORTED\n         /* Leave the INFO_iCCP flag set if the pngset.c code has already set\n          * it; this allows a PNG to contain a profile which matches sRGB and\n          * yet still have that profile retrievable by the application.\n          */\n         if (info_ptr->colorspace.flags & PNG_COLORSPACE_MATCHES_sRGB)\n            info_ptr->valid |= PNG_INFO_sRGB;\n\n         else\n            info_ptr->valid &= ~PNG_INFO_sRGB;\n\n         if (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS)\n            info_ptr->valid |= PNG_INFO_cHRM;\n\n         else\n            info_ptr->valid &= ~PNG_INFO_cHRM;\n#     endif\n\n      if (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_GAMMA)\n         info_ptr->valid |= PNG_INFO_gAMA;\n\n      else\n         info_ptr->valid &= ~PNG_INFO_gAMA;\n   }\n}\n\n#ifdef PNG_READ_SUPPORTED\nvoid /* PRIVATE */\npng_colorspace_sync(png_const_structrp png_ptr, png_inforp info_ptr)\n{\n   if (info_ptr == NULL) /* reduce code size; check here not in the caller */\n      return;\n\n   info_ptr->colorspace = png_ptr->colorspace;\n   png_colorspace_sync_info(png_ptr, info_ptr);\n}\n#endif\n#endif\n\n#ifdef PNG_COLORSPACE_SUPPORTED\n/* Added at libpng-1.5.5 to support read and write of true CIEXYZ values for\n * cHRM, as opposed to using chromaticities.  These internal APIs return\n * non-zero on a parameter error.  The X, Y and Z values are required to be\n * positive and less than 1.0.\n */\nstatic int\npng_xy_from_XYZ(png_xy *xy, const png_XYZ *XYZ)\n{\n   png_int_32 d, dwhite, whiteX, whiteY;\n\n   d = XYZ->red_X + XYZ->red_Y + XYZ->red_Z;\n   if (!png_muldiv(&xy->redx, XYZ->red_X, PNG_FP_1, d)) return 1;\n   if (!png_muldiv(&xy->redy, XYZ->red_Y, PNG_FP_1, d)) return 1;\n   dwhite = d;\n   whiteX = XYZ->red_X;\n   whiteY = XYZ->red_Y;\n\n   d = XYZ->green_X + XYZ->green_Y + XYZ->green_Z;\n   if (!png_muldiv(&xy->greenx, XYZ->green_X, PNG_FP_1, d)) return 1;\n   if (!png_muldiv(&xy->greeny, XYZ->green_Y, PNG_FP_1, d)) return 1;\n   dwhite += d;\n   whiteX += XYZ->green_X;\n   whiteY += XYZ->green_Y;\n\n   d = XYZ->blue_X + XYZ->blue_Y + XYZ->blue_Z;\n   if (!png_muldiv(&xy->bluex, XYZ->blue_X, PNG_FP_1, d)) return 1;\n   if (!png_muldiv(&xy->bluey, XYZ->blue_Y, PNG_FP_1, d)) return 1;\n   dwhite += d;\n   whiteX += XYZ->blue_X;\n   whiteY += XYZ->blue_Y;\n\n   /* The reference white is simply the sum of the end-point (X,Y,Z) vectors,\n    * thus:\n    */\n   if (!png_muldiv(&xy->whitex, whiteX, PNG_FP_1, dwhite)) return 1;\n   if (!png_muldiv(&xy->whitey, whiteY, PNG_FP_1, dwhite)) return 1;\n\n   return 0;\n}\n\nstatic int\npng_XYZ_from_xy(png_XYZ *XYZ, const png_xy *xy)\n{\n   png_fixed_point red_inverse, green_inverse, blue_scale;\n   png_fixed_point left, right, denominator;\n\n   /* Check xy and, implicitly, z.  Note that wide gamut color spaces typically\n    * have end points with 0 tristimulus values (these are impossible end\n    * points, but they are used to cover the possible colors.)\n    */\n   if (xy->redx < 0 || xy->redx > PNG_FP_1) return 1;\n   if (xy->redy < 0 || xy->redy > PNG_FP_1-xy->redx) return 1;\n   if (xy->greenx < 0 || xy->greenx > PNG_FP_1) return 1;\n   if (xy->greeny < 0 || xy->greeny > PNG_FP_1-xy->greenx) return 1;\n   if (xy->bluex < 0 || xy->bluex > PNG_FP_1) return 1;\n   if (xy->bluey < 0 || xy->bluey > PNG_FP_1-xy->bluex) return 1;\n   if (xy->whitex < 0 || xy->whitex > PNG_FP_1) return 1;\n   if (xy->whitey < 0 || xy->whitey > PNG_FP_1-xy->whitex) return 1;\n\n   /* The reverse calculation is more difficult because the original tristimulus\n    * value had 9 independent values (red,green,blue)x(X,Y,Z) however only 8\n    * derived values were recorded in the cHRM chunk;\n    * (red,green,blue,white)x(x,y).  This loses one degree of freedom and\n    * therefore an arbitrary ninth value has to be introduced to undo the\n    * original transformations.\n    *\n    * Think of the original end-points as points in (X,Y,Z) space.  The\n    * chromaticity values (c) have the property:\n    *\n    *           C\n    *   c = ---------\n    *       X + Y + Z\n    *\n    * For each c (x,y,z) from the corresponding original C (X,Y,Z).  Thus the\n    * three chromaticity values (x,y,z) for each end-point obey the\n    * relationship:\n    *\n    *   x + y + z = 1\n    *\n    * This describes the plane in (X,Y,Z) space that intersects each axis at the\n    * value 1.0; call this the chromaticity plane.  Thus the chromaticity\n    * calculation has scaled each end-point so that it is on the x+y+z=1 plane\n    * and chromaticity is the intersection of the vector from the origin to the\n    * (X,Y,Z) value with the chromaticity plane.\n    *\n    * To fully invert the chromaticity calculation we would need the three\n    * end-point scale factors, (red-scale, green-scale, blue-scale), but these\n    * were not recorded.  Instead we calculated the reference white (X,Y,Z) and\n    * recorded the chromaticity of this.  The reference white (X,Y,Z) would have\n    * given all three of the scale factors since:\n    *\n    *    color-C = color-c * color-scale\n    *    white-C = red-C + green-C + blue-C\n    *            = red-c*red-scale + green-c*green-scale + blue-c*blue-scale\n    *\n    * But cHRM records only white-x and white-y, so we have lost the white scale\n    * factor:\n    *\n    *    white-C = white-c*white-scale\n    *\n    * To handle this the inverse transformation makes an arbitrary assumption\n    * about white-scale:\n    *\n    *    Assume: white-Y = 1.0\n    *    Hence:  white-scale = 1/white-y\n    *    Or:     red-Y + green-Y + blue-Y = 1.0\n    *\n    * Notice the last statement of the assumption gives an equation in three of\n    * the nine values we want to calculate.  8 more equations come from the\n    * above routine as summarised at the top above (the chromaticity\n    * calculation):\n    *\n    *    Given: color-x = color-X / (color-X + color-Y + color-Z)\n    *    Hence: (color-x - 1)*color-X + color.x*color-Y + color.x*color-Z = 0\n    *\n    * This is 9 simultaneous equations in the 9 variables \"color-C\" and can be\n    * solved by Cramer's rule.  Cramer's rule requires calculating 10 9x9 matrix\n    * determinants, however this is not as bad as it seems because only 28 of\n    * the total of 90 terms in the various matrices are non-zero.  Nevertheless\n    * Cramer's rule is notoriously numerically unstable because the determinant\n    * calculation involves the difference of large, but similar, numbers.  It is\n    * difficult to be sure that the calculation is stable for real world values\n    * and it is certain that it becomes unstable where the end points are close\n    * together.\n    *\n    * So this code uses the perhaps slightly less optimal but more\n    * understandable and totally obvious approach of calculating color-scale.\n    *\n    * This algorithm depends on the precision in white-scale and that is\n    * (1/white-y), so we can immediately see that as white-y approaches 0 the\n    * accuracy inherent in the cHRM chunk drops off substantially.\n    *\n    * libpng arithmetic: a simple invertion of the above equations\n    * ------------------------------------------------------------\n    *\n    *    white_scale = 1/white-y\n    *    white-X = white-x * white-scale\n    *    white-Y = 1.0\n    *    white-Z = (1 - white-x - white-y) * white_scale\n    *\n    *    white-C = red-C + green-C + blue-C\n    *            = red-c*red-scale + green-c*green-scale + blue-c*blue-scale\n    *\n    * This gives us three equations in (red-scale,green-scale,blue-scale) where\n    * all the coefficients are now known:\n    *\n    *    red-x*red-scale + green-x*green-scale + blue-x*blue-scale\n    *       = white-x/white-y\n    *    red-y*red-scale + green-y*green-scale + blue-y*blue-scale = 1\n    *    red-z*red-scale + green-z*green-scale + blue-z*blue-scale\n    *       = (1 - white-x - white-y)/white-y\n    *\n    * In the last equation color-z is (1 - color-x - color-y) so we can add all\n    * three equations together to get an alternative third:\n    *\n    *    red-scale + green-scale + blue-scale = 1/white-y = white-scale\n    *\n    * So now we have a Cramer's rule solution where the determinants are just\n    * 3x3 - far more tractible.  Unfortunately 3x3 determinants still involve\n    * multiplication of three coefficients so we can't guarantee to avoid\n    * overflow in the libpng fixed point representation.  Using Cramer's rule in\n    * floating point is probably a good choice here, but it's not an option for\n    * fixed point.  Instead proceed to simplify the first two equations by\n    * eliminating what is likely to be the largest value, blue-scale:\n    *\n    *    blue-scale = white-scale - red-scale - green-scale\n    *\n    * Hence:\n    *\n    *    (red-x - blue-x)*red-scale + (green-x - blue-x)*green-scale =\n    *                (white-x - blue-x)*white-scale\n    *\n    *    (red-y - blue-y)*red-scale + (green-y - blue-y)*green-scale =\n    *                1 - blue-y*white-scale\n    *\n    * And now we can trivially solve for (red-scale,green-scale):\n    *\n    *    green-scale =\n    *                (white-x - blue-x)*white-scale - (red-x - blue-x)*red-scale\n    *                -----------------------------------------------------------\n    *                                  green-x - blue-x\n    *\n    *    red-scale =\n    *                1 - blue-y*white-scale - (green-y - blue-y) * green-scale\n    *                ---------------------------------------------------------\n    *                                  red-y - blue-y\n    *\n    * Hence:\n    *\n    *    red-scale =\n    *          ( (green-x - blue-x) * (white-y - blue-y) -\n    *            (green-y - blue-y) * (white-x - blue-x) ) / white-y\n    * -------------------------------------------------------------------------\n    *  (green-x - blue-x)*(red-y - blue-y)-(green-y - blue-y)*(red-x - blue-x)\n    *\n    *    green-scale =\n    *          ( (red-y - blue-y) * (white-x - blue-x) -\n    *            (red-x - blue-x) * (white-y - blue-y) ) / white-y\n    * -------------------------------------------------------------------------\n    *  (green-x - blue-x)*(red-y - blue-y)-(green-y - blue-y)*(red-x - blue-x)\n    *\n    * Accuracy:\n    * The input values have 5 decimal digits of accuracy.  The values are all in\n    * the range 0 < value < 1, so simple products are in the same range but may\n    * need up to 10 decimal digits to preserve the original precision and avoid\n    * underflow.  Because we are using a 32-bit signed representation we cannot\n    * match this; the best is a little over 9 decimal digits, less than 10.\n    *\n    * The approach used here is to preserve the maximum precision within the\n    * signed representation.  Because the red-scale calculation above uses the\n    * difference between two products of values that must be in the range -1..+1\n    * it is sufficient to divide the product by 7; ceil(100,000/32767*2).  The\n    * factor is irrelevant in the calculation because it is applied to both\n    * numerator and denominator.\n    *\n    * Note that the values of the differences of the products of the\n    * chromaticities in the above equations tend to be small, for example for\n    * the sRGB chromaticities they are:\n    *\n    * red numerator:    -0.04751\n    * green numerator:  -0.08788\n    * denominator:      -0.2241 (without white-y multiplication)\n    *\n    *  The resultant Y coefficients from the chromaticities of some widely used\n    *  color space definitions are (to 15 decimal places):\n    *\n    *  sRGB\n    *    0.212639005871510 0.715168678767756 0.072192315360734\n    *  Kodak ProPhoto\n    *    0.288071128229293 0.711843217810102 0.000085653960605\n    *  Adobe RGB\n    *    0.297344975250536 0.627363566255466 0.075291458493998\n    *  Adobe Wide Gamut RGB\n    *    0.258728243040113 0.724682314948566 0.016589442011321\n    */\n   /* By the argument, above overflow should be impossible here. The return\n    * value of 2 indicates an internal error to the caller.\n    */\n   if (!png_muldiv(&left, xy->greenx-xy->bluex, xy->redy - xy->bluey, 7))\n      return 2;\n   if (!png_muldiv(&right, xy->greeny-xy->bluey, xy->redx - xy->bluex, 7))\n      return 2;\n   denominator = left - right;\n\n   /* Now find the red numerator. */\n   if (!png_muldiv(&left, xy->greenx-xy->bluex, xy->whitey-xy->bluey, 7))\n      return 2;\n   if (!png_muldiv(&right, xy->greeny-xy->bluey, xy->whitex-xy->bluex, 7))\n      return 2;\n\n   /* Overflow is possible here and it indicates an extreme set of PNG cHRM\n    * chunk values.  This calculation actually returns the reciprocal of the\n    * scale value because this allows us to delay the multiplication of white-y\n    * into the denominator, which tends to produce a small number.\n    */\n   if (!png_muldiv(&red_inverse, xy->whitey, denominator, left-right) ||\n       red_inverse <= xy->whitey /* r+g+b scales = white scale */)\n      return 1;\n\n   /* Similarly for green_inverse: */\n   if (!png_muldiv(&left, xy->redy-xy->bluey, xy->whitex-xy->bluex, 7))\n      return 2;\n   if (!png_muldiv(&right, xy->redx-xy->bluex, xy->whitey-xy->bluey, 7))\n      return 2;\n   if (!png_muldiv(&green_inverse, xy->whitey, denominator, left-right) ||\n       green_inverse <= xy->whitey)\n      return 1;\n\n   /* And the blue scale, the checks above guarantee this can't overflow but it\n    * can still produce 0 for extreme cHRM values.\n    */\n   blue_scale = png_reciprocal(xy->whitey) - png_reciprocal(red_inverse) -\n      png_reciprocal(green_inverse);\n   if (blue_scale <= 0) return 1;\n\n\n   /* And fill in the png_XYZ: */\n   if (!png_muldiv(&XYZ->red_X, xy->redx, PNG_FP_1, red_inverse)) return 1;\n   if (!png_muldiv(&XYZ->red_Y, xy->redy, PNG_FP_1, red_inverse)) return 1;\n   if (!png_muldiv(&XYZ->red_Z, PNG_FP_1 - xy->redx - xy->redy, PNG_FP_1,\n      red_inverse))\n      return 1;\n\n   if (!png_muldiv(&XYZ->green_X, xy->greenx, PNG_FP_1, green_inverse))\n      return 1;\n   if (!png_muldiv(&XYZ->green_Y, xy->greeny, PNG_FP_1, green_inverse))\n      return 1;\n   if (!png_muldiv(&XYZ->green_Z, PNG_FP_1 - xy->greenx - xy->greeny, PNG_FP_1,\n      green_inverse))\n      return 1;\n\n   if (!png_muldiv(&XYZ->blue_X, xy->bluex, blue_scale, PNG_FP_1)) return 1;\n   if (!png_muldiv(&XYZ->blue_Y, xy->bluey, blue_scale, PNG_FP_1)) return 1;\n   if (!png_muldiv(&XYZ->blue_Z, PNG_FP_1 - xy->bluex - xy->bluey, blue_scale,\n      PNG_FP_1))\n      return 1;\n\n   return 0; /*success*/\n}\n\nstatic int\npng_XYZ_normalize(png_XYZ *XYZ)\n{\n   png_int_32 Y;\n\n   if (XYZ->red_Y < 0 || XYZ->green_Y < 0 || XYZ->blue_Y < 0 ||\n      XYZ->red_X < 0 || XYZ->green_X < 0 || XYZ->blue_X < 0 ||\n      XYZ->red_Z < 0 || XYZ->green_Z < 0 || XYZ->blue_Z < 0)\n      return 1;\n\n   /* Normalize by scaling so the sum of the end-point Y values is PNG_FP_1.\n    * IMPLEMENTATION NOTE: ANSI requires signed overflow not to occur, therefore\n    * relying on addition of two positive values producing a negative one is not\n    * safe.\n    */\n   Y = XYZ->red_Y;\n   if (0x7fffffff - Y < XYZ->green_X) return 1;\n   Y += XYZ->green_Y;\n   if (0x7fffffff - Y < XYZ->blue_X) return 1;\n   Y += XYZ->blue_Y;\n\n   if (Y != PNG_FP_1)\n   {\n      if (!png_muldiv(&XYZ->red_X, XYZ->red_X, PNG_FP_1, Y)) return 1;\n      if (!png_muldiv(&XYZ->red_Y, XYZ->red_Y, PNG_FP_1, Y)) return 1;\n      if (!png_muldiv(&XYZ->red_Z, XYZ->red_Z, PNG_FP_1, Y)) return 1;\n\n      if (!png_muldiv(&XYZ->green_X, XYZ->green_X, PNG_FP_1, Y)) return 1;\n      if (!png_muldiv(&XYZ->green_Y, XYZ->green_Y, PNG_FP_1, Y)) return 1;\n      if (!png_muldiv(&XYZ->green_Z, XYZ->green_Z, PNG_FP_1, Y)) return 1;\n\n      if (!png_muldiv(&XYZ->blue_X, XYZ->blue_X, PNG_FP_1, Y)) return 1;\n      if (!png_muldiv(&XYZ->blue_Y, XYZ->blue_Y, PNG_FP_1, Y)) return 1;\n      if (!png_muldiv(&XYZ->blue_Z, XYZ->blue_Z, PNG_FP_1, Y)) return 1;\n   }\n\n   return 0;\n}\n\nstatic int\npng_colorspace_endpoints_match(const png_xy *xy1, const png_xy *xy2, int delta)\n{\n   /* Allow an error of +/-0.01 (absolute value) on each chromaticity */\n   return !(PNG_OUT_OF_RANGE(xy1->whitex, xy2->whitex,delta) ||\n      PNG_OUT_OF_RANGE(xy1->whitey, xy2->whitey,delta) ||\n      PNG_OUT_OF_RANGE(xy1->redx,   xy2->redx,  delta) ||\n      PNG_OUT_OF_RANGE(xy1->redy,   xy2->redy,  delta) ||\n      PNG_OUT_OF_RANGE(xy1->greenx, xy2->greenx,delta) ||\n      PNG_OUT_OF_RANGE(xy1->greeny, xy2->greeny,delta) ||\n      PNG_OUT_OF_RANGE(xy1->bluex,  xy2->bluex, delta) ||\n      PNG_OUT_OF_RANGE(xy1->bluey,  xy2->bluey, delta));\n}\n\n/* Added in libpng-1.6.0, a different check for the validity of a set of cHRM\n * chunk chromaticities.  Earlier checks used to simply look for the overflow\n * condition (where the determinant of the matrix to solve for XYZ ends up zero\n * because the chromaticity values are not all distinct.)  Despite this it is\n * theoretically possible to produce chromaticities that are apparently valid\n * but that rapidly degrade to invalid, potentially crashing, sets because of\n * arithmetic inaccuracies when calculations are performed on them.  The new\n * check is to round-trip xy -> XYZ -> xy and then check that the result is\n * within a small percentage of the original.\n */\nstatic int\npng_colorspace_check_xy(png_XYZ *XYZ, const png_xy *xy)\n{\n   int result;\n   png_xy xy_test;\n\n   /* As a side-effect this routine also returns the XYZ endpoints. */\n   result = png_XYZ_from_xy(XYZ, xy);\n   if (result) return result;\n\n   result = png_xy_from_XYZ(&xy_test, XYZ);\n   if (result) return result;\n\n   if (png_colorspace_endpoints_match(xy, &xy_test,\n      5/*actually, the math is pretty accurate*/))\n      return 0;\n\n   /* Too much slip */\n   return 1;\n}\n\n/* This is the check going the other way.  The XYZ is modified to normalize it\n * (another side-effect) and the xy chromaticities are returned.\n */\nstatic int\npng_colorspace_check_XYZ(png_xy *xy, png_XYZ *XYZ)\n{\n   int result;\n   png_XYZ XYZtemp;\n\n   result = png_XYZ_normalize(XYZ);\n   if (result) return result;\n\n   result = png_xy_from_XYZ(xy, XYZ);\n   if (result) return result;\n\n   XYZtemp = *XYZ;\n   return png_colorspace_check_xy(&XYZtemp, xy);\n}\n\n/* Used to check for an endpoint match against sRGB */\nstatic const png_xy sRGB_xy = /* From ITU-R BT.709-3 */\n{\n   /* color      x       y */\n   /* red   */ 64000, 33000,\n   /* green */ 30000, 60000,\n   /* blue  */ 15000,  6000,\n   /* white */ 31270, 32900\n};\n\nstatic int\npng_colorspace_set_xy_and_XYZ(png_const_structrp png_ptr,\n   png_colorspacerp colorspace, const png_xy *xy, const png_XYZ *XYZ,\n   int preferred)\n{\n   if (colorspace->flags & PNG_COLORSPACE_INVALID)\n      return 0;\n\n   /* The consistency check is performed on the chromaticities; this factors out\n    * variations because of the normalization (or not) of the end point Y\n    * values.\n    */\n   if (preferred < 2 && (colorspace->flags & PNG_COLORSPACE_HAVE_ENDPOINTS))\n   {\n      /* The end points must be reasonably close to any we already have.  The\n       * following allows an error of up to +/-.001\n       */\n      if (!png_colorspace_endpoints_match(xy, &colorspace->end_points_xy, 100))\n      {\n         colorspace->flags |= PNG_COLORSPACE_INVALID;\n         png_benign_error(png_ptr, \"inconsistent chromaticities\");\n         return 0; /* failed */\n      }\n\n      /* Only overwrite with preferred values */\n      if (!preferred)\n         return 1; /* ok, but no change */\n   }\n\n   colorspace->end_points_xy = *xy;\n   colorspace->end_points_XYZ = *XYZ;\n   colorspace->flags |= PNG_COLORSPACE_HAVE_ENDPOINTS;\n\n   /* The end points are normally quoted to two decimal digits, so allow +/-0.01\n    * on this test.\n    */\n   if (png_colorspace_endpoints_match(xy, &sRGB_xy, 1000))\n      colorspace->flags |= PNG_COLORSPACE_ENDPOINTS_MATCH_sRGB;\n\n   else\n      colorspace->flags &= PNG_COLORSPACE_CANCEL(\n         PNG_COLORSPACE_ENDPOINTS_MATCH_sRGB);\n\n   return 2; /* ok and changed */\n}\n\nint /* PRIVATE */\npng_colorspace_set_chromaticities(png_const_structrp png_ptr,\n   png_colorspacerp colorspace, const png_xy *xy, int preferred)\n{\n   /* We must check the end points to ensure they are reasonable - in the past\n    * color management systems have crashed as a result of getting bogus\n    * colorant values, while this isn't the fault of libpng it is the\n    * responsibility of libpng because PNG carries the bomb and libpng is in a\n    * position to protect against it.\n    */\n   png_XYZ XYZ;\n\n   switch (png_colorspace_check_xy(&XYZ, xy))\n   {\n      case 0: /* success */\n         return png_colorspace_set_xy_and_XYZ(png_ptr, colorspace, xy, &XYZ,\n            preferred);\n\n      case 1:\n         /* We can't invert the chromaticities so we can't produce value XYZ\n          * values.  Likely as not a color management system will fail too.\n          */\n         colorspace->flags |= PNG_COLORSPACE_INVALID;\n         png_benign_error(png_ptr, \"invalid chromaticities\");\n         break;\n\n      default:\n         /* libpng is broken; this should be a warning but if it happens we\n          * want error reports so for the moment it is an error.\n          */\n         colorspace->flags |= PNG_COLORSPACE_INVALID;\n         png_error(png_ptr, \"internal error checking chromaticities\");\n         break;\n   }\n\n   return 0; /* failed */\n}\n\nint /* PRIVATE */\npng_colorspace_set_endpoints(png_const_structrp png_ptr,\n   png_colorspacerp colorspace, const png_XYZ *XYZ_in, int preferred)\n{\n   png_XYZ XYZ = *XYZ_in;\n   png_xy xy;\n\n   switch (png_colorspace_check_XYZ(&xy, &XYZ))\n   {\n      case 0:\n         return png_colorspace_set_xy_and_XYZ(png_ptr, colorspace, &xy, &XYZ,\n            preferred);\n\n      case 1:\n         /* End points are invalid. */\n         colorspace->flags |= PNG_COLORSPACE_INVALID;\n         png_benign_error(png_ptr, \"invalid end points\");\n         break;\n\n      default:\n         colorspace->flags |= PNG_COLORSPACE_INVALID;\n         png_error(png_ptr, \"internal error checking chromaticities\");\n         break;\n   }\n\n   return 0; /* failed */\n}\n\n#if defined(PNG_sRGB_SUPPORTED) || defined(PNG_iCCP_SUPPORTED)\n/* Error message generation */\nstatic char\npng_icc_tag_char(png_uint_32 byte)\n{\n   byte &= 0xff;\n   if (byte >= 32 && byte <= 126)\n      return (char)byte;\n   else\n      return '?';\n}\n\nstatic void\npng_icc_tag_name(char *name, png_uint_32 tag)\n{\n   name[0] = '\\'';\n   name[1] = png_icc_tag_char(tag >> 24);\n   name[2] = png_icc_tag_char(tag >> 16);\n   name[3] = png_icc_tag_char(tag >>  8);\n   name[4] = png_icc_tag_char(tag      );\n   name[5] = '\\'';\n}\n\nstatic int\nis_ICC_signature_char(png_alloc_size_t it)\n{\n   return it == 32 || (it >= 48 && it <= 57) || (it >= 65 && it <= 90) ||\n      (it >= 97 && it <= 122);\n}\n\nstatic int\nis_ICC_signature(png_alloc_size_t it)\n{\n   return is_ICC_signature_char(it >> 24) /* checks all the top bits */ &&\n      is_ICC_signature_char((it >> 16) & 0xff) &&\n      is_ICC_signature_char((it >> 8) & 0xff) &&\n      is_ICC_signature_char(it & 0xff);\n}\n\nstatic int\npng_icc_profile_error(png_const_structrp png_ptr, png_colorspacerp colorspace,\n   png_const_charp name, png_alloc_size_t value, png_const_charp reason)\n{\n   size_t pos;\n   char message[196]; /* see below for calculation */\n\n   if (colorspace != NULL)\n      colorspace->flags |= PNG_COLORSPACE_INVALID;\n\n   pos = png_safecat(message, (sizeof message), 0, \"profile '\"); /* 9 chars */\n   pos = png_safecat(message, pos+79, pos, name); /* Truncate to 79 chars */\n   pos = png_safecat(message, (sizeof message), pos, \"': \"); /* +2 = 90 */\n   if (is_ICC_signature(value))\n   {\n      /* So 'value' is at most 4 bytes and the following cast is safe */\n      png_icc_tag_name(message+pos, (png_uint_32)value);\n      pos += 6; /* total +8; less than the else clause */\n      message[pos++] = ':';\n      message[pos++] = ' ';\n   }\n#  ifdef PNG_WARNINGS_SUPPORTED\n   else\n      {\n         char number[PNG_NUMBER_BUFFER_SIZE]; /* +24 = 114*/\n\n         pos = png_safecat(message, (sizeof message), pos,\n            png_format_number(number, number+(sizeof number),\n               PNG_NUMBER_FORMAT_x, value));\n         pos = png_safecat(message, (sizeof message), pos, \"h: \"); /*+2 = 116*/\n      }\n#  endif\n   /* The 'reason' is an arbitrary message, allow +79 maximum 195 */\n   pos = png_safecat(message, (sizeof message), pos, reason);\n   PNG_UNUSED(pos)\n\n   /* This is recoverable, but make it unconditionally an app_error on write to\n    * avoid writing invalid ICC profiles into PNG files.  (I.e.  we handle them\n    * on read, with a warning, but on write unless the app turns off\n    * application errors the PNG won't be written.)\n    */\n   png_chunk_report(png_ptr, message,\n      (colorspace != NULL) ? PNG_CHUNK_ERROR : PNG_CHUNK_WRITE_ERROR);\n\n   return 0;\n}\n#endif /* sRGB || iCCP */\n\n#ifdef PNG_sRGB_SUPPORTED\nint /* PRIVATE */\npng_colorspace_set_sRGB(png_const_structrp png_ptr, png_colorspacerp colorspace,\n   int intent)\n{\n   /* sRGB sets known gamma, end points and (from the chunk) intent. */\n   /* IMPORTANT: these are not necessarily the values found in an ICC profile\n    * because ICC profiles store values adapted to a D50 environment; it is\n    * expected that the ICC profile mediaWhitePointTag will be D50, see the\n    * checks and code elsewhere to understand this better.\n    *\n    * These XYZ values, which are accurate to 5dp, produce rgb to gray\n    * coefficients of (6968,23435,2366), which are reduced (because they add up\n    * to 32769 not 32768) to (6968,23434,2366).  These are the values that\n    * libpng has traditionally used (and are the best values given the 15bit\n    * algorithm used by the rgb to gray code.)\n    */\n   static const png_XYZ sRGB_XYZ = /* D65 XYZ (*not* the D50 adapted values!) */\n   {\n      /* color      X      Y      Z */\n      /* red   */ 41239, 21264,  1933,\n      /* green */ 35758, 71517, 11919,\n      /* blue  */ 18048,  7219, 95053\n   };\n\n   /* Do nothing if the colorspace is already invalidated. */\n   if (colorspace->flags & PNG_COLORSPACE_INVALID)\n      return 0;\n\n   /* Check the intent, then check for existing settings.  It is valid for the\n    * PNG file to have cHRM or gAMA chunks along with sRGB, but the values must\n    * be consistent with the correct values.  If, however, this function is\n    * called below because an iCCP chunk matches sRGB then it is quite\n    * conceivable that an older app recorded incorrect gAMA and cHRM because of\n    * an incorrect calculation based on the values in the profile - this does\n    * *not* invalidate the profile (though it still produces an error, which can\n    * be ignored.)\n    */\n   if (intent < 0 || intent >= PNG_sRGB_INTENT_LAST)\n      return png_icc_profile_error(png_ptr, colorspace, \"sRGB\",\n         (unsigned)intent, \"invalid sRGB rendering intent\");\n\n   if ((colorspace->flags & PNG_COLORSPACE_HAVE_INTENT) != 0 &&\n      colorspace->rendering_intent != intent)\n      return png_icc_profile_error(png_ptr, colorspace, \"sRGB\",\n         (unsigned)intent, \"inconsistent rendering intents\");\n\n   if ((colorspace->flags & PNG_COLORSPACE_FROM_sRGB) != 0)\n   {\n      png_benign_error(png_ptr, \"duplicate sRGB information ignored\");\n      return 0;\n   }\n\n   /* If the standard sRGB cHRM chunk does not match the one from the PNG file\n    * warn but overwrite the value with the correct one.\n    */\n   if ((colorspace->flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0 &&\n      !png_colorspace_endpoints_match(&sRGB_xy, &colorspace->end_points_xy,\n         100))\n      png_chunk_report(png_ptr, \"cHRM chunk does not match sRGB\",\n         PNG_CHUNK_ERROR);\n\n   /* This check is just done for the error reporting - the routine always\n    * returns true when the 'from' argument corresponds to sRGB (2).\n    */\n   (void)png_colorspace_check_gamma(png_ptr, colorspace, PNG_GAMMA_sRGB_INVERSE,\n      2/*from sRGB*/);\n\n   /* intent: bugs in GCC force 'int' to be used as the parameter type. */\n   colorspace->rendering_intent = (png_uint_16)intent;\n   colorspace->flags |= PNG_COLORSPACE_HAVE_INTENT;\n\n   /* endpoints */\n   colorspace->end_points_xy = sRGB_xy;\n   colorspace->end_points_XYZ = sRGB_XYZ;\n   colorspace->flags |=\n      (PNG_COLORSPACE_HAVE_ENDPOINTS|PNG_COLORSPACE_ENDPOINTS_MATCH_sRGB);\n\n   /* gamma */\n   colorspace->gamma = PNG_GAMMA_sRGB_INVERSE;\n   colorspace->flags |= PNG_COLORSPACE_HAVE_GAMMA;\n\n   /* Finally record that we have an sRGB profile */\n   colorspace->flags |=\n      (PNG_COLORSPACE_MATCHES_sRGB|PNG_COLORSPACE_FROM_sRGB);\n\n   return 1; /* set */\n}\n#endif /* sRGB */\n\n#ifdef PNG_iCCP_SUPPORTED\n/* Encoded value of D50 as an ICC XYZNumber.  From the ICC 2010 spec the value\n * is XYZ(0.9642,1.0,0.8249), which scales to:\n *\n *    (63189.8112, 65536, 54060.6464)\n */\nstatic const png_byte D50_nCIEXYZ[12] =\n   { 0x00, 0x00, 0xf6, 0xd6, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0xd3, 0x2d };\n\nint /* PRIVATE */\npng_icc_check_length(png_const_structrp png_ptr, png_colorspacerp colorspace,\n   png_const_charp name, png_uint_32 profile_length)\n{\n   if (profile_length < 132)\n      return png_icc_profile_error(png_ptr, colorspace, name, profile_length,\n         \"too short\");\n\n   if (profile_length & 3)\n      return png_icc_profile_error(png_ptr, colorspace, name, profile_length,\n         \"invalid length\");\n\n   return 1;\n}\n\nint /* PRIVATE */\npng_icc_check_header(png_const_structrp png_ptr, png_colorspacerp colorspace,\n   png_const_charp name, png_uint_32 profile_length,\n   png_const_bytep profile/* first 132 bytes only */, int color_type)\n{\n   png_uint_32 temp;\n\n   /* Length check; this cannot be ignored in this code because profile_length\n    * is used later to check the tag table, so even if the profile seems over\n    * long profile_length from the caller must be correct.  The caller can fix\n    * this up on read or write by just passing in the profile header length.\n    */\n   temp = png_get_uint_32(profile);\n   if (temp != profile_length)\n      return png_icc_profile_error(png_ptr, colorspace, name, temp,\n         \"length does not match profile\");\n\n   temp = png_get_uint_32(profile+128); /* tag count: 12 bytes/tag */\n   if (temp > 357913930 || /* (2^32-4-132)/12: maximum possible tag count */\n      profile_length < 132+12*temp) /* truncated tag table */\n      return png_icc_profile_error(png_ptr, colorspace, name, temp,\n         \"tag count too large\");\n\n   /* The 'intent' must be valid or we can't store it, ICC limits the intent to\n    * 16 bits.\n    */\n   temp = png_get_uint_32(profile+64);\n   if (temp >= 0xffff) /* The ICC limit */\n      return png_icc_profile_error(png_ptr, colorspace, name, temp,\n         \"invalid rendering intent\");\n\n   /* This is just a warning because the profile may be valid in future\n    * versions.\n    */\n   if (temp >= PNG_sRGB_INTENT_LAST)\n      (void)png_icc_profile_error(png_ptr, NULL, name, temp,\n         \"intent outside defined range\");\n\n   /* At this point the tag table can't be checked because it hasn't necessarily\n    * been loaded; however, various header fields can be checked.  These checks\n    * are for values permitted by the PNG spec in an ICC profile; the PNG spec\n    * restricts the profiles that can be passed in an iCCP chunk (they must be\n    * appropriate to processing PNG data!)\n    */\n\n   /* Data checks (could be skipped).  These checks must be independent of the\n    * version number; however, the version number doesn't accomodate changes in\n    * the header fields (just the known tags and the interpretation of the\n    * data.)\n    */\n   temp = png_get_uint_32(profile+36); /* signature 'ascp' */\n   if (temp != 0x61637370)\n      return png_icc_profile_error(png_ptr, colorspace, name, temp,\n         \"invalid signature\");\n\n   /* Currently the PCS illuminant/adopted white point (the computational\n    * white point) are required to be D50,\n    * however the profile contains a record of the illuminant so perhaps ICC\n    * expects to be able to change this in the future (despite the rationale in\n    * the introduction for using a fixed PCS adopted white.)  Consequently the\n    * following is just a warning.\n    */\n   if (memcmp(profile+68, D50_nCIEXYZ, 12) != 0)\n      (void)png_icc_profile_error(png_ptr, NULL, name, 0/*no tag value*/,\n         \"PCS illuminant is not D50\");\n\n   /* The PNG spec requires this:\n    * \"If the iCCP chunk is present, the image samples conform to the colour\n    * space represented by the embedded ICC profile as defined by the\n    * International Color Consortium [ICC]. The colour space of the ICC profile\n    * shall be an RGB colour space for colour images (PNG colour types 2, 3, and\n    * 6), or a greyscale colour space for greyscale images (PNG colour types 0\n    * and 4).\"\n    *\n    * This checking code ensures the embedded profile (on either read or write)\n    * conforms to the specification requirements.  Notice that an ICC 'gray'\n    * color-space profile contains the information to transform the monochrome\n    * data to XYZ or L*a*b (according to which PCS the profile uses) and this\n    * should be used in preference to the standard libpng K channel replication\n    * into R, G and B channels.\n    *\n    * Previously it was suggested that an RGB profile on grayscale data could be\n    * handled.  However it it is clear that using an RGB profile in this context\n    * must be an error - there is no specification of what it means.  Thus it is\n    * almost certainly more correct to ignore the profile.\n    */\n   temp = png_get_uint_32(profile+16); /* data colour space field */\n   switch (temp)\n   {\n      case 0x52474220: /* 'RGB ' */\n         if (!(color_type & PNG_COLOR_MASK_COLOR))\n            return png_icc_profile_error(png_ptr, colorspace, name, temp,\n               \"RGB color space not permitted on grayscale PNG\");\n         break;\n\n      case 0x47524159: /* 'GRAY' */\n         if (color_type & PNG_COLOR_MASK_COLOR)\n            return png_icc_profile_error(png_ptr, colorspace, name, temp,\n               \"Gray color space not permitted on RGB PNG\");\n         break;\n\n      default:\n         return png_icc_profile_error(png_ptr, colorspace, name, temp,\n            \"invalid ICC profile color space\");\n   }\n\n   /* It is up to the application to check that the profile class matches the\n    * application requirements; the spec provides no guidance, but it's pretty\n    * weird if the profile is not scanner ('scnr'), monitor ('mntr'), printer\n    * ('prtr') or 'spac' (for generic color spaces).  Issue a warning in these\n    * cases.  Issue an error for device link or abstract profiles - these don't\n    * contain the records necessary to transform the color-space to anything\n    * other than the target device (and not even that for an abstract profile).\n    * Profiles of these classes may not be embedded in images.\n    */\n   temp = png_get_uint_32(profile+12); /* profile/device class */\n   switch (temp)\n   {\n      case 0x73636E72: /* 'scnr' */\n      case 0x6D6E7472: /* 'mntr' */\n      case 0x70727472: /* 'prtr' */\n      case 0x73706163: /* 'spac' */\n         /* All supported */\n         break;\n\n      case 0x61627374: /* 'abst' */\n         /* May not be embedded in an image */\n         return png_icc_profile_error(png_ptr, colorspace, name, temp,\n            \"invalid embedded Abstract ICC profile\");\n\n      case 0x6C696E6B: /* 'link' */\n         /* DeviceLink profiles cannnot be interpreted in a non-device specific\n          * fashion, if an app uses the AToB0Tag in the profile the results are\n          * undefined unless the result is sent to the intended device,\n          * therefore a DeviceLink profile should not be found embedded in a\n          * PNG.\n          */\n         return png_icc_profile_error(png_ptr, colorspace, name, temp,\n            \"unexpected DeviceLink ICC profile class\");\n\n      case 0x6E6D636C: /* 'nmcl' */\n         /* A NamedColor profile is also device specific, however it doesn't\n          * contain an AToB0 tag that is open to misintrepretation.  Almost\n          * certainly it will fail the tests below.\n          */\n         (void)png_icc_profile_error(png_ptr, NULL, name, temp,\n            \"unexpected NamedColor ICC profile class\");\n         break;\n\n      default:\n         /* To allow for future enhancements to the profile accept unrecognized\n          * profile classes with a warning, these then hit the test below on the\n          * tag content to ensure they are backward compatible with one of the\n          * understood profiles.\n          */\n         (void)png_icc_profile_error(png_ptr, NULL, name, temp,\n            \"unrecognized ICC profile class\");\n         break;\n   }\n\n   /* For any profile other than a device link one the PCS must be encoded\n    * either in XYZ or Lab.\n    */\n   temp = png_get_uint_32(profile+20);\n   switch (temp)\n   {\n      case 0x58595A20: /* 'XYZ ' */\n      case 0x4C616220: /* 'Lab ' */\n         break;\n\n      default:\n         return png_icc_profile_error(png_ptr, colorspace, name, temp,\n            \"unexpected ICC PCS encoding\");\n   }\n\n   return 1;\n}\n\nint /* PRIVATE */\npng_icc_check_tag_table(png_const_structrp png_ptr, png_colorspacerp colorspace,\n   png_const_charp name, png_uint_32 profile_length,\n   png_const_bytep profile /* header plus whole tag table */)\n{\n   png_uint_32 tag_count = png_get_uint_32(profile+128);\n   png_uint_32 itag;\n   png_const_bytep tag = profile+132; /* The first tag */\n\n   /* First scan all the tags in the table and add bits to the icc_info value\n    * (temporarily in 'tags').\n    */\n   for (itag=0; itag < tag_count; ++itag, tag += 12)\n   {\n      png_uint_32 tag_id = png_get_uint_32(tag+0);\n      png_uint_32 tag_start = png_get_uint_32(tag+4); /* must be aligned */\n      png_uint_32 tag_length = png_get_uint_32(tag+8);/* not padded */\n\n      /* The ICC specification does not exclude zero length tags, therefore the\n       * start might actually be anywhere if there is no data, but this would be\n       * a clear abuse of the intent of the standard so the start is checked for\n       * being in range.  All defined tag types have an 8 byte header - a 4 byte\n       * type signature then 0.\n       */\n      if ((tag_start & 3) != 0)\n      {\n         /* CNHP730S.icc shipped with Microsoft Windows 64 violates this, it is\n          * only a warning here because libpng does not care about the\n          * alignment.\n          */\n         (void)png_icc_profile_error(png_ptr, NULL, name, tag_id,\n            \"ICC profile tag start not a multiple of 4\");\n      }\n\n      /* This is a hard error; potentially it can cause read outside the\n       * profile.\n       */\n      if (tag_start > profile_length || tag_length > profile_length - tag_start)\n         return png_icc_profile_error(png_ptr, colorspace, name, tag_id,\n            \"ICC profile tag outside profile\");\n   }\n\n   return 1; /* success, maybe with warnings */\n}\n\n#ifdef PNG_sRGB_SUPPORTED\n/* Information about the known ICC sRGB profiles */\nstatic const struct\n{\n   png_uint_32 adler, crc, length;\n   png_uint_32 md5[4];\n   png_byte    have_md5;\n   png_byte    is_broken;\n   png_uint_16 intent;\n\n#  define PNG_MD5(a,b,c,d) { a, b, c, d }, (a!=0)||(b!=0)||(c!=0)||(d!=0)\n#  define PNG_ICC_CHECKSUM(adler, crc, md5, intent, broke, date, length, fname)\\\n      { adler, crc, length, md5, broke, intent },\n\n} png_sRGB_checks[] =\n{\n   /* This data comes from contrib/tools/checksum-icc run on downloads of\n    * all four ICC sRGB profiles from www.color.org.\n    */\n   /* adler32, crc32, MD5[4], intent, date, length, file-name */\n   PNG_ICC_CHECKSUM(0x0a3fd9f6, 0x3b8772b9,\n      PNG_MD5(0x29f83dde, 0xaff255ae, 0x7842fae4, 0xca83390d), 0, 0,\n      \"2009/03/27 21:36:31\", 3048, \"sRGB_IEC61966-2-1_black_scaled.icc\")\n\n   /* ICC sRGB v2 perceptual no black-compensation: */\n   PNG_ICC_CHECKSUM(0x4909e5e1, 0x427ebb21,\n      PNG_MD5(0xc95bd637, 0xe95d8a3b, 0x0df38f99, 0xc1320389), 1, 0,\n      \"2009/03/27 21:37:45\", 3052, \"sRGB_IEC61966-2-1_no_black_scaling.icc\")\n\n   PNG_ICC_CHECKSUM(0xfd2144a1, 0x306fd8ae,\n      PNG_MD5(0xfc663378, 0x37e2886b, 0xfd72e983, 0x8228f1b8), 0, 0,\n      \"2009/08/10 17:28:01\", 60988, \"sRGB_v4_ICC_preference_displayclass.icc\")\n\n   /* ICC sRGB v4 perceptual */\n   PNG_ICC_CHECKSUM(0x209c35d2, 0xbbef7812,\n      PNG_MD5(0x34562abf, 0x994ccd06, 0x6d2c5721, 0xd0d68c5d), 0, 0,\n      \"2007/07/25 00:05:37\", 60960, \"sRGB_v4_ICC_preference.icc\")\n\n   /* The following profiles have no known MD5 checksum. If there is a match\n    * on the (empty) MD5 the other fields are used to attempt a match and\n    * a warning is produced.  The first two of these profiles have a 'cprt' tag\n    * which suggests that they were also made by Hewlett Packard.\n    */\n   PNG_ICC_CHECKSUM(0xa054d762, 0x5d5129ce,\n      PNG_MD5(0x00000000, 0x00000000, 0x00000000, 0x00000000), 1, 0,\n      \"2004/07/21 18:57:42\", 3024, \"sRGB_IEC61966-2-1_noBPC.icc\")\n\n   /* This is a 'mntr' (display) profile with a mediaWhitePointTag that does not\n    * match the D50 PCS illuminant in the header (it is in fact the D65 values,\n    * so the white point is recorded as the un-adapted value.)  The profiles\n    * below only differ in one byte - the intent - and are basically the same as\n    * the previous profile except for the mediaWhitePointTag error and a missing\n    * chromaticAdaptationTag.\n    */\n   PNG_ICC_CHECKSUM(0xf784f3fb, 0x182ea552,\n      PNG_MD5(0x00000000, 0x00000000, 0x00000000, 0x00000000), 0, 1/*broken*/,\n      \"1998/02/09 06:49:00\", 3144, \"HP-Microsoft sRGB v2 perceptual\")\n\n   PNG_ICC_CHECKSUM(0x0398f3fc, 0xf29e526d,\n      PNG_MD5(0x00000000, 0x00000000, 0x00000000, 0x00000000), 1, 1/*broken*/,\n      \"1998/02/09 06:49:00\", 3144, \"HP-Microsoft sRGB v2 media-relative\")\n};\n\nstatic int\npng_compare_ICC_profile_with_sRGB(png_const_structrp png_ptr,\n   png_const_bytep profile, uLong adler)\n{\n   /* The quick check is to verify just the MD5 signature and trust the\n    * rest of the data.  Because the profile has already been verified for\n    * correctness this is safe.  png_colorspace_set_sRGB will check the 'intent'\n    * field too, so if the profile has been edited with an intent not defined\n    * by sRGB (but maybe defined by a later ICC specification) the read of\n    * the profile will fail at that point.\n    */\n   png_uint_32 length = 0;\n   png_uint_32 intent = 0x10000; /* invalid */\n#if PNG_sRGB_PROFILE_CHECKS > 1\n   uLong crc = 0; /* the value for 0 length data */\n#endif\n   unsigned int i;\n\n   for (i=0; i < (sizeof png_sRGB_checks) / (sizeof png_sRGB_checks[0]); ++i)\n   {\n      if (png_get_uint_32(profile+84) == png_sRGB_checks[i].md5[0] &&\n         png_get_uint_32(profile+88) == png_sRGB_checks[i].md5[1] &&\n         png_get_uint_32(profile+92) == png_sRGB_checks[i].md5[2] &&\n         png_get_uint_32(profile+96) == png_sRGB_checks[i].md5[3])\n      {\n         /* This may be one of the old HP profiles without an MD5, in that\n          * case we can only use the length and Adler32 (note that these\n          * are not used by default if there is an MD5!)\n          */\n#        if PNG_sRGB_PROFILE_CHECKS == 0\n            if (png_sRGB_checks[i].have_md5)\n               return 1+png_sRGB_checks[i].is_broken;\n#        endif\n\n         /* Profile is unsigned or more checks have been configured in. */\n         if (length == 0)\n         {\n            length = png_get_uint_32(profile);\n            intent = png_get_uint_32(profile+64);\n         }\n\n         /* Length *and* intent must match */\n         if (length == png_sRGB_checks[i].length &&\n            intent == png_sRGB_checks[i].intent)\n         {\n            /* Now calculate the adler32 if not done already. */\n            if (adler == 0)\n            {\n               adler = adler32(0, NULL, 0);\n               adler = adler32(adler, profile, length);\n            }\n\n            if (adler == png_sRGB_checks[i].adler)\n            {\n               /* These basic checks suggest that the data has not been\n                * modified, but if the check level is more than 1 perform\n                * our own crc32 checksum on the data.\n                */\n#              if PNG_sRGB_PROFILE_CHECKS > 1\n                  if (crc == 0)\n                  {\n                     crc = crc32(0, NULL, 0);\n                     crc = crc32(crc, profile, length);\n                  }\n\n                  /* So this check must pass for the 'return' below to happen.\n                   */\n                  if (crc == png_sRGB_checks[i].crc)\n#              endif\n               {\n                  if (png_sRGB_checks[i].is_broken)\n                  {\n                     /* These profiles are known to have bad data that may cause\n                      * problems if they are used, therefore attempt to\n                      * discourage their use, skip the 'have_md5' warning below,\n                      * which is made irrelevant by this error.\n                      */\n                     png_chunk_report(png_ptr, \"known incorrect sRGB profile\",\n                        PNG_CHUNK_ERROR);\n                  }\n\n                  /* Warn that this being done; this isn't even an error since\n                   * the profile is perfectly valid, but it would be nice if\n                   * people used the up-to-date ones.\n                   */\n                  else if (!png_sRGB_checks[i].have_md5)\n                  {\n                     png_chunk_report(png_ptr,\n                        \"out-of-date sRGB profile with no signature\",\n                        PNG_CHUNK_WARNING);\n                  }\n\n                  return 1+png_sRGB_checks[i].is_broken;\n               }\n            }\n         }\n\n# if PNG_sRGB_PROFILE_CHECKS > 0\n         /* The signature matched, but the profile had been changed in some\n          * way.  This probably indicates a data error or uninformed hacking.\n          * Fall through to \"no match\".\n          */\n         png_chunk_report(png_ptr,\n             \"Not recognizing known sRGB profile that has been edited\", \n             PNG_CHUNK_WARNING);\n         break;\n# endif\n      }\n   }\n\n   return 0; /* no match */\n}\n#endif\n\n#ifdef PNG_sRGB_SUPPORTED\nvoid /* PRIVATE */\npng_icc_set_sRGB(png_const_structrp png_ptr,\n   png_colorspacerp colorspace, png_const_bytep profile, uLong adler)\n{\n   /* Is this profile one of the known ICC sRGB profiles?  If it is, just set\n    * the sRGB information.\n    */\n   if (png_compare_ICC_profile_with_sRGB(png_ptr, profile, adler))\n      (void)png_colorspace_set_sRGB(png_ptr, colorspace,\n         (int)/*already checked*/png_get_uint_32(profile+64));\n}\n#endif /* PNG_READ_sRGB_SUPPORTED */\n\nint /* PRIVATE */\npng_colorspace_set_ICC(png_const_structrp png_ptr, png_colorspacerp colorspace,\n   png_const_charp name, png_uint_32 profile_length, png_const_bytep profile,\n   int color_type)\n{\n   if (colorspace->flags & PNG_COLORSPACE_INVALID)\n      return 0;\n\n   if (png_icc_check_length(png_ptr, colorspace, name, profile_length) &&\n      png_icc_check_header(png_ptr, colorspace, name, profile_length, profile,\n         color_type) &&\n      png_icc_check_tag_table(png_ptr, colorspace, name, profile_length,\n         profile))\n   {\n#     ifdef PNG_sRGB_SUPPORTED\n         /* If no sRGB support, don't try storing sRGB information */\n         png_icc_set_sRGB(png_ptr, colorspace, profile, 0);\n#     endif\n      return 1;\n   }\n\n   /* Failure case */\n   return 0;\n}\n#endif /* iCCP */\n\n#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED\nvoid /* PRIVATE */\npng_colorspace_set_rgb_coefficients(png_structrp png_ptr)\n{\n   /* Set the rgb_to_gray coefficients from the colorspace. */\n   if (!png_ptr->rgb_to_gray_coefficients_set &&\n      (png_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0)\n   {\n      /* png_set_background has not been called, get the coefficients from the Y\n       * values of the colorspace colorants.\n       */\n      png_fixed_point r = png_ptr->colorspace.end_points_XYZ.red_Y;\n      png_fixed_point g = png_ptr->colorspace.end_points_XYZ.green_Y;\n      png_fixed_point b = png_ptr->colorspace.end_points_XYZ.blue_Y;\n      png_fixed_point total = r+g+b;\n\n      if (total > 0 &&\n         r >= 0 && png_muldiv(&r, r, 32768, total) && r >= 0 && r <= 32768 &&\n         g >= 0 && png_muldiv(&g, g, 32768, total) && g >= 0 && g <= 32768 &&\n         b >= 0 && png_muldiv(&b, b, 32768, total) && b >= 0 && b <= 32768 &&\n         r+g+b <= 32769)\n      {\n         /* We allow 0 coefficients here.  r+g+b may be 32769 if two or\n          * all of the coefficients were rounded up.  Handle this by\n          * reducing the *largest* coefficient by 1; this matches the\n          * approach used for the default coefficients in pngrtran.c\n          */\n         int add = 0;\n\n         if (r+g+b > 32768)\n            add = -1;\n         else if (r+g+b < 32768)\n            add = 1;\n\n         if (add != 0)\n         {\n            if (g >= r && g >= b)\n               g += add;\n            else if (r >= g && r >= b)\n               r += add;\n            else\n               b += add;\n         }\n\n         /* Check for an internal error. */\n         if (r+g+b != 32768)\n            png_error(png_ptr,\n               \"internal error handling cHRM coefficients\");\n\n         else\n         {\n            png_ptr->rgb_to_gray_red_coeff   = (png_uint_16)r;\n            png_ptr->rgb_to_gray_green_coeff = (png_uint_16)g;\n         }\n      }\n\n      /* This is a png_error at present even though it could be ignored -\n       * it should never happen, but it is important that if it does, the\n       * bug is fixed.\n       */\n      else\n         png_error(png_ptr, \"internal error handling cHRM->XYZ\");\n   }\n}\n#endif\n\n#endif /* COLORSPACE */\n\nvoid /* PRIVATE */\npng_check_IHDR(png_const_structrp png_ptr,\n   png_uint_32 width, png_uint_32 height, int bit_depth,\n   int color_type, int interlace_type, int compression_type,\n   int filter_type)\n{\n   int error = 0;\n\n   /* Check for width and height valid values */\n   if (width == 0)\n   {\n      png_warning(png_ptr, \"Image width is zero in IHDR\");\n      error = 1;\n   }\n\n   if (height == 0)\n   {\n      png_warning(png_ptr, \"Image height is zero in IHDR\");\n      error = 1;\n   }\n\n#  ifdef PNG_SET_USER_LIMITS_SUPPORTED\n   if (width > png_ptr->user_width_max)\n\n#  else\n   if (width > PNG_USER_WIDTH_MAX)\n#  endif\n   {\n      png_warning(png_ptr, \"Image width exceeds user limit in IHDR\");\n      error = 1;\n   }\n\n#  ifdef PNG_SET_USER_LIMITS_SUPPORTED\n   if (height > png_ptr->user_height_max)\n#  else\n   if (height > PNG_USER_HEIGHT_MAX)\n#  endif\n   {\n      png_warning(png_ptr, \"Image height exceeds user limit in IHDR\");\n      error = 1;\n   }\n\n   if (width > PNG_UINT_31_MAX)\n   {\n      png_warning(png_ptr, \"Invalid image width in IHDR\");\n      error = 1;\n   }\n\n   if (height > PNG_UINT_31_MAX)\n   {\n      png_warning(png_ptr, \"Invalid image height in IHDR\");\n      error = 1;\n   }\n\n   /* Check other values */\n   if (bit_depth != 1 && bit_depth != 2 && bit_depth != 4 &&\n       bit_depth != 8 && bit_depth != 16)\n   {\n      png_warning(png_ptr, \"Invalid bit depth in IHDR\");\n      error = 1;\n   }\n\n   if (color_type < 0 || color_type == 1 ||\n       color_type == 5 || color_type > 6)\n   {\n      png_warning(png_ptr, \"Invalid color type in IHDR\");\n      error = 1;\n   }\n\n   if (((color_type == PNG_COLOR_TYPE_PALETTE) && bit_depth > 8) ||\n       ((color_type == PNG_COLOR_TYPE_RGB ||\n         color_type == PNG_COLOR_TYPE_GRAY_ALPHA ||\n         color_type == PNG_COLOR_TYPE_RGB_ALPHA) && bit_depth < 8))\n   {\n      png_warning(png_ptr, \"Invalid color type/bit depth combination in IHDR\");\n      error = 1;\n   }\n\n   if (interlace_type >= PNG_INTERLACE_LAST)\n   {\n      png_warning(png_ptr, \"Unknown interlace method in IHDR\");\n      error = 1;\n   }\n\n   if (compression_type != PNG_COMPRESSION_TYPE_BASE)\n   {\n      png_warning(png_ptr, \"Unknown compression method in IHDR\");\n      error = 1;\n   }\n\n#  ifdef PNG_MNG_FEATURES_SUPPORTED\n   /* Accept filter_method 64 (intrapixel differencing) only if\n    * 1. Libpng was compiled with PNG_MNG_FEATURES_SUPPORTED and\n    * 2. Libpng did not read a PNG signature (this filter_method is only\n    *    used in PNG datastreams that are embedded in MNG datastreams) and\n    * 3. The application called png_permit_mng_features with a mask that\n    *    included PNG_FLAG_MNG_FILTER_64 and\n    * 4. The filter_method is 64 and\n    * 5. The color_type is RGB or RGBA\n    */\n   if ((png_ptr->mode & PNG_HAVE_PNG_SIGNATURE) &&\n       png_ptr->mng_features_permitted)\n      png_warning(png_ptr, \"MNG features are not allowed in a PNG datastream\");\n\n   if (filter_type != PNG_FILTER_TYPE_BASE)\n   {\n      if (!((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) &&\n          (filter_type == PNG_INTRAPIXEL_DIFFERENCING) &&\n          ((png_ptr->mode & PNG_HAVE_PNG_SIGNATURE) == 0) &&\n          (color_type == PNG_COLOR_TYPE_RGB ||\n          color_type == PNG_COLOR_TYPE_RGB_ALPHA)))\n      {\n         png_warning(png_ptr, \"Unknown filter method in IHDR\");\n         error = 1;\n      }\n\n      if (png_ptr->mode & PNG_HAVE_PNG_SIGNATURE)\n      {\n         png_warning(png_ptr, \"Invalid filter method in IHDR\");\n         error = 1;\n      }\n   }\n\n#  else\n   if (filter_type != PNG_FILTER_TYPE_BASE)\n   {\n      png_warning(png_ptr, \"Unknown filter method in IHDR\");\n      error = 1;\n   }\n#  endif\n\n   if (error == 1)\n      png_error(png_ptr, \"Invalid IHDR data\");\n}\n\n#if defined(PNG_sCAL_SUPPORTED) || defined(PNG_pCAL_SUPPORTED)\n/* ASCII to fp functions */\n/* Check an ASCII formated floating point value, see the more detailed\n * comments in pngpriv.h\n */\n/* The following is used internally to preserve the sticky flags */\n#define png_fp_add(state, flags) ((state) |= (flags))\n#define png_fp_set(state, value) ((state) = (value) | ((state) & PNG_FP_STICKY))\n\nint /* PRIVATE */\npng_check_fp_number(png_const_charp string, png_size_t size, int *statep,\n   png_size_tp whereami)\n{\n   int state = *statep;\n   png_size_t i = *whereami;\n\n   while (i < size)\n   {\n      int type;\n      /* First find the type of the next character */\n      switch (string[i])\n      {\n      case 43:  type = PNG_FP_SAW_SIGN;                   break;\n      case 45:  type = PNG_FP_SAW_SIGN + PNG_FP_NEGATIVE; break;\n      case 46:  type = PNG_FP_SAW_DOT;                    break;\n      case 48:  type = PNG_FP_SAW_DIGIT;                  break;\n      case 49: case 50: case 51: case 52:\n      case 53: case 54: case 55: case 56:\n      case 57:  type = PNG_FP_SAW_DIGIT + PNG_FP_NONZERO; break;\n      case 69:\n      case 101: type = PNG_FP_SAW_E;                      break;\n      default:  goto PNG_FP_End;\n      }\n\n      /* Now deal with this type according to the current\n       * state, the type is arranged to not overlap the\n       * bits of the PNG_FP_STATE.\n       */\n      switch ((state & PNG_FP_STATE) + (type & PNG_FP_SAW_ANY))\n      {\n      case PNG_FP_INTEGER + PNG_FP_SAW_SIGN:\n         if (state & PNG_FP_SAW_ANY)\n            goto PNG_FP_End; /* not a part of the number */\n\n         png_fp_add(state, type);\n         break;\n\n      case PNG_FP_INTEGER + PNG_FP_SAW_DOT:\n         /* Ok as trailer, ok as lead of fraction. */\n         if (state & PNG_FP_SAW_DOT) /* two dots */\n            goto PNG_FP_End;\n\n         else if (state & PNG_FP_SAW_DIGIT) /* trailing dot? */\n            png_fp_add(state, type);\n\n         else\n            png_fp_set(state, PNG_FP_FRACTION | type);\n\n         break;\n\n      case PNG_FP_INTEGER + PNG_FP_SAW_DIGIT:\n         if (state & PNG_FP_SAW_DOT) /* delayed fraction */\n            png_fp_set(state, PNG_FP_FRACTION | PNG_FP_SAW_DOT);\n\n         png_fp_add(state, type | PNG_FP_WAS_VALID);\n\n         break;\n\n      case PNG_FP_INTEGER + PNG_FP_SAW_E:\n         if ((state & PNG_FP_SAW_DIGIT) == 0)\n            goto PNG_FP_End;\n\n         png_fp_set(state, PNG_FP_EXPONENT);\n\n         break;\n\n   /* case PNG_FP_FRACTION + PNG_FP_SAW_SIGN:\n         goto PNG_FP_End; ** no sign in fraction */\n\n   /* case PNG_FP_FRACTION + PNG_FP_SAW_DOT:\n         goto PNG_FP_End; ** Because SAW_DOT is always set */\n\n      case PNG_FP_FRACTION + PNG_FP_SAW_DIGIT:\n         png_fp_add(state, type | PNG_FP_WAS_VALID);\n         break;\n\n      case PNG_FP_FRACTION + PNG_FP_SAW_E:\n         /* This is correct because the trailing '.' on an\n          * integer is handled above - so we can only get here\n          * with the sequence \".E\" (with no preceding digits).\n          */\n         if ((state & PNG_FP_SAW_DIGIT) == 0)\n            goto PNG_FP_End;\n\n         png_fp_set(state, PNG_FP_EXPONENT);\n\n         break;\n\n      case PNG_FP_EXPONENT + PNG_FP_SAW_SIGN:\n         if (state & PNG_FP_SAW_ANY)\n            goto PNG_FP_End; /* not a part of the number */\n\n         png_fp_add(state, PNG_FP_SAW_SIGN);\n\n         break;\n\n   /* case PNG_FP_EXPONENT + PNG_FP_SAW_DOT:\n         goto PNG_FP_End; */\n\n      case PNG_FP_EXPONENT + PNG_FP_SAW_DIGIT:\n         png_fp_add(state, PNG_FP_SAW_DIGIT | PNG_FP_WAS_VALID);\n\n         break;\n\n   /* case PNG_FP_EXPONEXT + PNG_FP_SAW_E:\n         goto PNG_FP_End; */\n\n      default: goto PNG_FP_End; /* I.e. break 2 */\n      }\n\n      /* The character seems ok, continue. */\n      ++i;\n   }\n\nPNG_FP_End:\n   /* Here at the end, update the state and return the correct\n    * return code.\n    */\n   *statep = state;\n   *whereami = i;\n\n   return (state & PNG_FP_SAW_DIGIT) != 0;\n}\n\n\n/* The same but for a complete string. */\nint\npng_check_fp_string(png_const_charp string, png_size_t size)\n{\n   int        state=0;\n   png_size_t char_index=0;\n\n   if (png_check_fp_number(string, size, &state, &char_index) &&\n      (char_index == size || string[char_index] == 0))\n      return state /* must be non-zero - see above */;\n\n   return 0; /* i.e. fail */\n}\n#endif /* pCAL or sCAL */\n\n#ifdef PNG_sCAL_SUPPORTED\n#  ifdef PNG_FLOATING_POINT_SUPPORTED\n/* Utility used below - a simple accurate power of ten from an integral\n * exponent.\n */\nstatic double\npng_pow10(int power)\n{\n   int recip = 0;\n   double d = 1;\n\n   /* Handle negative exponent with a reciprocal at the end because\n    * 10 is exact whereas .1 is inexact in base 2\n    */\n   if (power < 0)\n   {\n      if (power < DBL_MIN_10_EXP) return 0;\n      recip = 1, power = -power;\n   }\n\n   if (power > 0)\n   {\n      /* Decompose power bitwise. */\n      double mult = 10;\n      do\n      {\n         if (power & 1) d *= mult;\n         mult *= mult;\n         power >>= 1;\n      }\n      while (power > 0);\n\n      if (recip) d = 1/d;\n   }\n   /* else power is 0 and d is 1 */\n\n   return d;\n}\n\n/* Function to format a floating point value in ASCII with a given\n * precision.\n */\nvoid /* PRIVATE */\npng_ascii_from_fp(png_const_structrp png_ptr, png_charp ascii, png_size_t size,\n    double fp, unsigned int precision)\n{\n   /* We use standard functions from math.h, but not printf because\n    * that would require stdio.  The caller must supply a buffer of\n    * sufficient size or we will png_error.  The tests on size and\n    * the space in ascii[] consumed are indicated below.\n    */\n   if (precision < 1)\n      precision = DBL_DIG;\n\n   /* Enforce the limit of the implementation precision too. */\n   if (precision > DBL_DIG+1)\n      precision = DBL_DIG+1;\n\n   /* Basic sanity checks */\n   if (size >= precision+5) /* See the requirements below. */\n   {\n      if (fp < 0)\n      {\n         fp = -fp;\n         *ascii++ = 45; /* '-'  PLUS 1 TOTAL 1 */\n         --size;\n      }\n\n      if (fp >= DBL_MIN && fp <= DBL_MAX)\n      {\n         int exp_b10;       /* A base 10 exponent */\n         double base;   /* 10^exp_b10 */\n\n         /* First extract a base 10 exponent of the number,\n          * the calculation below rounds down when converting\n          * from base 2 to base 10 (multiply by log10(2) -\n          * 0.3010, but 77/256 is 0.3008, so exp_b10 needs to\n          * be increased.  Note that the arithmetic shift\n          * performs a floor() unlike C arithmetic - using a\n          * C multiply would break the following for negative\n          * exponents.\n          */\n         (void)frexp(fp, &exp_b10); /* exponent to base 2 */\n\n         exp_b10 = (exp_b10 * 77) >> 8; /* <= exponent to base 10 */\n\n         /* Avoid underflow here. */\n         base = png_pow10(exp_b10); /* May underflow */\n\n         while (base < DBL_MIN || base < fp)\n         {\n            /* And this may overflow. */\n            double test = png_pow10(exp_b10+1);\n\n            if (test <= DBL_MAX)\n               ++exp_b10, base = test;\n\n            else\n               break;\n         }\n\n         /* Normalize fp and correct exp_b10, after this fp is in the\n          * range [.1,1) and exp_b10 is both the exponent and the digit\n          * *before* which the decimal point should be inserted\n          * (starting with 0 for the first digit).  Note that this\n          * works even if 10^exp_b10 is out of range because of the\n          * test on DBL_MAX above.\n          */\n         fp /= base;\n         while (fp >= 1) fp /= 10, ++exp_b10;\n\n         /* Because of the code above fp may, at this point, be\n          * less than .1, this is ok because the code below can\n          * handle the leading zeros this generates, so no attempt\n          * is made to correct that here.\n          */\n\n         {\n            int czero, clead, cdigits;\n            char exponent[10];\n\n            /* Allow up to two leading zeros - this will not lengthen\n             * the number compared to using E-n.\n             */\n            if (exp_b10 < 0 && exp_b10 > -3) /* PLUS 3 TOTAL 4 */\n            {\n               czero = -exp_b10; /* PLUS 2 digits: TOTAL 3 */\n               exp_b10 = 0;      /* Dot added below before first output. */\n            }\n            else\n               czero = 0;    /* No zeros to add */\n\n            /* Generate the digit list, stripping trailing zeros and\n             * inserting a '.' before a digit if the exponent is 0.\n             */\n            clead = czero; /* Count of leading zeros */\n            cdigits = 0;   /* Count of digits in list. */\n\n            do\n            {\n               double d;\n\n               fp *= 10;\n               /* Use modf here, not floor and subtract, so that\n                * the separation is done in one step.  At the end\n                * of the loop don't break the number into parts so\n                * that the final digit is rounded.\n                */\n               if (cdigits+czero-clead+1 < (int)precision)\n                  fp = modf(fp, &d);\n\n               else\n               {\n                  d = floor(fp + .5);\n\n                  if (d > 9)\n                  {\n                     /* Rounding up to 10, handle that here. */\n                     if (czero > 0)\n                     {\n                        --czero, d = 1;\n                        if (cdigits == 0) --clead;\n                     }\n                     else\n                     {\n                        while (cdigits > 0 && d > 9)\n                        {\n                           int ch = *--ascii;\n\n                           if (exp_b10 != (-1))\n                              ++exp_b10;\n\n                           else if (ch == 46)\n                           {\n                              ch = *--ascii, ++size;\n                              /* Advance exp_b10 to '1', so that the\n                               * decimal point happens after the\n                               * previous digit.\n                               */\n                              exp_b10 = 1;\n                           }\n\n                           --cdigits;\n                           d = ch - 47;  /* I.e. 1+(ch-48) */\n                        }\n\n                        /* Did we reach the beginning? If so adjust the\n                         * exponent but take into account the leading\n                         * decimal point.\n                         */\n                        if (d > 9)  /* cdigits == 0 */\n                        {\n                           if (exp_b10 == (-1))\n                           {\n                              /* Leading decimal point (plus zeros?), if\n                               * we lose the decimal point here it must\n                               * be reentered below.\n                               */\n                              int ch = *--ascii;\n\n                              if (ch == 46)\n                                 ++size, exp_b10 = 1;\n\n                              /* Else lost a leading zero, so 'exp_b10' is\n                               * still ok at (-1)\n                               */\n                           }\n                           else\n                              ++exp_b10;\n\n                           /* In all cases we output a '1' */\n                           d = 1;\n                        }\n                     }\n                  }\n                  fp = 0; /* Guarantees termination below. */\n               }\n\n               if (d == 0)\n               {\n                  ++czero;\n                  if (cdigits == 0) ++clead;\n               }\n               else\n               {\n                  /* Included embedded zeros in the digit count. */\n                  cdigits += czero - clead;\n                  clead = 0;\n\n                  while (czero > 0)\n                  {\n                     /* exp_b10 == (-1) means we just output the decimal\n                      * place - after the DP don't adjust 'exp_b10' any\n                      * more!\n                      */\n                     if (exp_b10 != (-1))\n                     {\n                        if (exp_b10 == 0) *ascii++ = 46, --size;\n                        /* PLUS 1: TOTAL 4 */\n                        --exp_b10;\n                     }\n                     *ascii++ = 48, --czero;\n                  }\n\n                  if (exp_b10 != (-1))\n                  {\n                     if (exp_b10 == 0) *ascii++ = 46, --size; /* counted\n                                                                 above */\n                     --exp_b10;\n                  }\n                  *ascii++ = (char)(48 + (int)d), ++cdigits;\n               }\n            }\n            while (cdigits+czero-clead < (int)precision && fp > DBL_MIN);\n\n            /* The total output count (max) is now 4+precision */\n\n            /* Check for an exponent, if we don't need one we are\n             * done and just need to terminate the string.  At\n             * this point exp_b10==(-1) is effectively if flag - it got\n             * to '-1' because of the decrement after outputing\n             * the decimal point above (the exponent required is\n             * *not* -1!)\n             */\n            if (exp_b10 >= (-1) && exp_b10 <= 2)\n            {\n               /* The following only happens if we didn't output the\n                * leading zeros above for negative exponent, so this\n                * doest add to the digit requirement.  Note that the\n                * two zeros here can only be output if the two leading\n                * zeros were *not* output, so this doesn't increase\n                * the output count.\n                */\n               while (--exp_b10 >= 0) *ascii++ = 48;\n\n               *ascii = 0;\n\n               /* Total buffer requirement (including the '\\0') is\n                * 5+precision - see check at the start.\n                */\n               return;\n            }\n\n            /* Here if an exponent is required, adjust size for\n             * the digits we output but did not count.  The total\n             * digit output here so far is at most 1+precision - no\n             * decimal point and no leading or trailing zeros have\n             * been output.\n             */\n            size -= cdigits;\n\n            *ascii++ = 69, --size;    /* 'E': PLUS 1 TOTAL 2+precision */\n\n            /* The following use of an unsigned temporary avoids ambiguities in\n             * the signed arithmetic on exp_b10 and permits GCC at least to do\n             * better optimization.\n             */\n            {\n               unsigned int uexp_b10;\n\n               if (exp_b10 < 0)\n               {\n                  *ascii++ = 45, --size; /* '-': PLUS 1 TOTAL 3+precision */\n                  uexp_b10 = -exp_b10;\n               }\n\n               else\n                  uexp_b10 = exp_b10;\n\n               cdigits = 0;\n\n               while (uexp_b10 > 0)\n               {\n                  exponent[cdigits++] = (char)(48 + uexp_b10 % 10);\n                  uexp_b10 /= 10;\n               }\n            }\n\n            /* Need another size check here for the exponent digits, so\n             * this need not be considered above.\n             */\n            if ((int)size > cdigits)\n            {\n               while (cdigits > 0) *ascii++ = exponent[--cdigits];\n\n               *ascii = 0;\n\n               return;\n            }\n         }\n      }\n      else if (!(fp >= DBL_MIN))\n      {\n         *ascii++ = 48; /* '0' */\n         *ascii = 0;\n         return;\n      }\n      else\n      {\n         *ascii++ = 105; /* 'i' */\n         *ascii++ = 110; /* 'n' */\n         *ascii++ = 102; /* 'f' */\n         *ascii = 0;\n         return;\n      }\n   }\n\n   /* Here on buffer too small. */\n   png_error(png_ptr, \"ASCII conversion buffer too small\");\n}\n\n#  endif /* FLOATING_POINT */\n\n#  ifdef PNG_FIXED_POINT_SUPPORTED\n/* Function to format a fixed point value in ASCII.\n */\nvoid /* PRIVATE */\npng_ascii_from_fixed(png_const_structrp png_ptr, png_charp ascii,\n    png_size_t size, png_fixed_point fp)\n{\n   /* Require space for 10 decimal digits, a decimal point, a minus sign and a\n    * trailing \\0, 13 characters:\n    */\n   if (size > 12)\n   {\n      png_uint_32 num;\n\n      /* Avoid overflow here on the minimum integer. */\n      if (fp < 0)\n         *ascii++ = 45, --size, num = -fp;\n      else\n         num = fp;\n\n      if (num <= 0x80000000) /* else overflowed */\n      {\n         unsigned int ndigits = 0, first = 16 /* flag value */;\n         char digits[10];\n\n         while (num)\n         {\n            /* Split the low digit off num: */\n            unsigned int tmp = num/10;\n            num -= tmp*10;\n            digits[ndigits++] = (char)(48 + num);\n            /* Record the first non-zero digit, note that this is a number\n             * starting at 1, it's not actually the array index.\n             */\n            if (first == 16 && num > 0)\n               first = ndigits;\n            num = tmp;\n         }\n\n         if (ndigits > 0)\n         {\n            while (ndigits > 5) *ascii++ = digits[--ndigits];\n            /* The remaining digits are fractional digits, ndigits is '5' or\n             * smaller at this point.  It is certainly not zero.  Check for a\n             * non-zero fractional digit:\n             */\n            if (first <= 5)\n            {\n               unsigned int i;\n               *ascii++ = 46; /* decimal point */\n               /* ndigits may be <5 for small numbers, output leading zeros\n                * then ndigits digits to first:\n                */\n               i = 5;\n               while (ndigits < i) *ascii++ = 48, --i;\n               while (ndigits >= first) *ascii++ = digits[--ndigits];\n               /* Don't output the trailing zeros! */\n            }\n         }\n         else\n            *ascii++ = 48;\n\n         /* And null terminate the string: */\n         *ascii = 0;\n         return;\n      }\n   }\n\n   /* Here on buffer too small. */\n   png_error(png_ptr, \"ASCII conversion buffer too small\");\n}\n#   endif /* FIXED_POINT */\n#endif /* READ_SCAL */\n\n#if defined(PNG_FLOATING_POINT_SUPPORTED) && \\\n   !defined(PNG_FIXED_POINT_MACRO_SUPPORTED) && \\\n   (defined(PNG_gAMA_SUPPORTED) || defined(PNG_cHRM_SUPPORTED) || \\\n   defined(PNG_sCAL_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) || \\\n   defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)) || \\\n   (defined(PNG_sCAL_SUPPORTED) && \\\n   defined(PNG_FLOATING_ARITHMETIC_SUPPORTED))\npng_fixed_point\npng_fixed(png_const_structrp png_ptr, double fp, png_const_charp text)\n{\n   double r = floor(100000 * fp + .5);\n\n   if (r > 2147483647. || r < -2147483648.)\n      png_fixed_error(png_ptr, text);\n\n#  ifndef PNG_ERROR_TEXT_SUPPORTED\n      PNG_UNUSED(text)\n#  endif\n\n   return (png_fixed_point)r;\n}\n#endif\n\n#if defined(PNG_GAMMA_SUPPORTED) || defined(PNG_COLORSPACE_SUPPORTED) ||\\\n    defined(PNG_INCH_CONVERSIONS_SUPPORTED) || defined(PNG_READ_pHYs_SUPPORTED)\n/* muldiv functions */\n/* This API takes signed arguments and rounds the result to the nearest\n * integer (or, for a fixed point number - the standard argument - to\n * the nearest .00001).  Overflow and divide by zero are signalled in\n * the result, a boolean - true on success, false on overflow.\n */\nint\npng_muldiv(png_fixed_point_p res, png_fixed_point a, png_int_32 times,\n    png_int_32 divisor)\n{\n   /* Return a * times / divisor, rounded. */\n   if (divisor != 0)\n   {\n      if (a == 0 || times == 0)\n      {\n         *res = 0;\n         return 1;\n      }\n      else\n      {\n#ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED\n         double r = a;\n         r *= times;\n         r /= divisor;\n         r = floor(r+.5);\n\n         /* A png_fixed_point is a 32-bit integer. */\n         if (r <= 2147483647. && r >= -2147483648.)\n         {\n            *res = (png_fixed_point)r;\n            return 1;\n         }\n#else\n         int negative = 0;\n         png_uint_32 A, T, D;\n         png_uint_32 s16, s32, s00;\n\n         if (a < 0)\n            negative = 1, A = -a;\n         else\n            A = a;\n\n         if (times < 0)\n            negative = !negative, T = -times;\n         else\n            T = times;\n\n         if (divisor < 0)\n            negative = !negative, D = -divisor;\n         else\n            D = divisor;\n\n         /* Following can't overflow because the arguments only\n          * have 31 bits each, however the result may be 32 bits.\n          */\n         s16 = (A >> 16) * (T & 0xffff) +\n                           (A & 0xffff) * (T >> 16);\n         /* Can't overflow because the a*times bit is only 30\n          * bits at most.\n          */\n         s32 = (A >> 16) * (T >> 16) + (s16 >> 16);\n         s00 = (A & 0xffff) * (T & 0xffff);\n\n         s16 = (s16 & 0xffff) << 16;\n         s00 += s16;\n\n         if (s00 < s16)\n            ++s32; /* carry */\n\n         if (s32 < D) /* else overflow */\n         {\n            /* s32.s00 is now the 64-bit product, do a standard\n             * division, we know that s32 < D, so the maximum\n             * required shift is 31.\n             */\n            int bitshift = 32;\n            png_fixed_point result = 0; /* NOTE: signed */\n\n            while (--bitshift >= 0)\n            {\n               png_uint_32 d32, d00;\n\n               if (bitshift > 0)\n                  d32 = D >> (32-bitshift), d00 = D << bitshift;\n\n               else\n                  d32 = 0, d00 = D;\n\n               if (s32 > d32)\n               {\n                  if (s00 < d00) --s32; /* carry */\n                  s32 -= d32, s00 -= d00, result += 1<<bitshift;\n               }\n\n               else\n                  if (s32 == d32 && s00 >= d00)\n                     s32 = 0, s00 -= d00, result += 1<<bitshift;\n            }\n\n            /* Handle the rounding. */\n            if (s00 >= (D >> 1))\n               ++result;\n\n            if (negative)\n               result = -result;\n\n            /* Check for overflow. */\n            if ((negative && result <= 0) || (!negative && result >= 0))\n            {\n               *res = result;\n               return 1;\n            }\n         }\n#endif\n      }\n   }\n\n   return 0;\n}\n#endif /* READ_GAMMA || INCH_CONVERSIONS */\n\n#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_INCH_CONVERSIONS_SUPPORTED)\n/* The following is for when the caller doesn't much care about the\n * result.\n */\npng_fixed_point\npng_muldiv_warn(png_const_structrp png_ptr, png_fixed_point a, png_int_32 times,\n    png_int_32 divisor)\n{\n   png_fixed_point result;\n\n   if (png_muldiv(&result, a, times, divisor))\n      return result;\n\n   png_warning(png_ptr, \"fixed point overflow ignored\");\n   return 0;\n}\n#endif\n\n#ifdef PNG_GAMMA_SUPPORTED /* more fixed point functions for gamma */\n/* Calculate a reciprocal, return 0 on div-by-zero or overflow. */\npng_fixed_point\npng_reciprocal(png_fixed_point a)\n{\n#ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED\n   double r = floor(1E10/a+.5);\n\n   if (r <= 2147483647. && r >= -2147483648.)\n      return (png_fixed_point)r;\n#else\n   png_fixed_point res;\n\n   if (png_muldiv(&res, 100000, 100000, a))\n      return res;\n#endif\n\n   return 0; /* error/overflow */\n}\n\n/* This is the shared test on whether a gamma value is 'significant' - whether\n * it is worth doing gamma correction.\n */\nint /* PRIVATE */\npng_gamma_significant(png_fixed_point gamma_val)\n{\n   return gamma_val < PNG_FP_1 - PNG_GAMMA_THRESHOLD_FIXED ||\n       gamma_val > PNG_FP_1 + PNG_GAMMA_THRESHOLD_FIXED;\n}\n#endif\n\n#ifdef PNG_READ_GAMMA_SUPPORTED\n#  ifdef PNG_16BIT_SUPPORTED\n/* A local convenience routine. */\nstatic png_fixed_point\npng_product2(png_fixed_point a, png_fixed_point b)\n{\n   /* The required result is 1/a * 1/b; the following preserves accuracy. */\n#    ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED\n   double r = a * 1E-5;\n   r *= b;\n   r = floor(r+.5);\n\n   if (r <= 2147483647. && r >= -2147483648.)\n      return (png_fixed_point)r;\n#    else\n   png_fixed_point res;\n\n   if (png_muldiv(&res, a, b, 100000))\n      return res;\n#    endif\n\n   return 0; /* overflow */\n}\n#  endif /* 16BIT */\n\n/* The inverse of the above. */\npng_fixed_point\npng_reciprocal2(png_fixed_point a, png_fixed_point b)\n{\n   /* The required result is 1/a * 1/b; the following preserves accuracy. */\n#ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED\n   double r = 1E15/a;\n   r /= b;\n   r = floor(r+.5);\n\n   if (r <= 2147483647. && r >= -2147483648.)\n      return (png_fixed_point)r;\n#else\n   /* This may overflow because the range of png_fixed_point isn't symmetric,\n    * but this API is only used for the product of file and screen gamma so it\n    * doesn't matter that the smallest number it can produce is 1/21474, not\n    * 1/100000\n    */\n   png_fixed_point res = png_product2(a, b);\n\n   if (res != 0)\n      return png_reciprocal(res);\n#endif\n\n   return 0; /* overflow */\n}\n#endif /* READ_GAMMA */\n\n#ifdef PNG_READ_GAMMA_SUPPORTED /* gamma table code */\n#ifndef PNG_FLOATING_ARITHMETIC_SUPPORTED\n/* Fixed point gamma.\n *\n * The code to calculate the tables used below can be found in the shell script\n * contrib/tools/intgamma.sh\n *\n * To calculate gamma this code implements fast log() and exp() calls using only\n * fixed point arithmetic.  This code has sufficient precision for either 8-bit\n * or 16-bit sample values.\n *\n * The tables used here were calculated using simple 'bc' programs, but C double\n * precision floating point arithmetic would work fine.\n *\n * 8-bit log table\n *   This is a table of -log(value/255)/log(2) for 'value' in the range 128 to\n *   255, so it's the base 2 logarithm of a normalized 8-bit floating point\n *   mantissa.  The numbers are 32-bit fractions.\n */\nstatic const png_uint_32\npng_8bit_l2[128] =\n{\n   4270715492U, 4222494797U, 4174646467U, 4127164793U, 4080044201U, 4033279239U,\n   3986864580U, 3940795015U, 3895065449U, 3849670902U, 3804606499U, 3759867474U,\n   3715449162U, 3671346997U, 3627556511U, 3584073329U, 3540893168U, 3498011834U,\n   3455425220U, 3413129301U, 3371120137U, 3329393864U, 3287946700U, 3246774933U,\n   3205874930U, 3165243125U, 3124876025U, 3084770202U, 3044922296U, 3005329011U,\n   2965987113U, 2926893432U, 2888044853U, 2849438323U, 2811070844U, 2772939474U,\n   2735041326U, 2697373562U, 2659933400U, 2622718104U, 2585724991U, 2548951424U,\n   2512394810U, 2476052606U, 2439922311U, 2404001468U, 2368287663U, 2332778523U,\n   2297471715U, 2262364947U, 2227455964U, 2192742551U, 2158222529U, 2123893754U,\n   2089754119U, 2055801552U, 2022034013U, 1988449497U, 1955046031U, 1921821672U,\n   1888774511U, 1855902668U, 1823204291U, 1790677560U, 1758320682U, 1726131893U,\n   1694109454U, 1662251657U, 1630556815U, 1599023271U, 1567649391U, 1536433567U,\n   1505374214U, 1474469770U, 1443718700U, 1413119487U, 1382670639U, 1352370686U,\n   1322218179U, 1292211689U, 1262349810U, 1232631153U, 1203054352U, 1173618059U,\n   1144320946U, 1115161701U, 1086139034U, 1057251672U, 1028498358U, 999877854U,\n   971388940U, 943030410U, 914801076U, 886699767U, 858725327U, 830876614U,\n   803152505U, 775551890U, 748073672U, 720716771U, 693480120U, 666362667U,\n   639363374U, 612481215U, 585715177U, 559064263U, 532527486U, 506103872U,\n   479792461U, 453592303U, 427502463U, 401522014U, 375650043U, 349885648U,\n   324227938U, 298676034U, 273229066U, 247886176U, 222646516U, 197509248U,\n   172473545U, 147538590U, 122703574U, 97967701U, 73330182U, 48790236U,\n   24347096U, 0U\n\n#if 0\n   /* The following are the values for 16-bit tables - these work fine for the\n    * 8-bit conversions but produce very slightly larger errors in the 16-bit\n    * log (about 1.2 as opposed to 0.7 absolute error in the final value).  To\n    * use these all the shifts below must be adjusted appropriately.\n    */\n   65166, 64430, 63700, 62976, 62257, 61543, 60835, 60132, 59434, 58741, 58054,\n   57371, 56693, 56020, 55352, 54689, 54030, 53375, 52726, 52080, 51439, 50803,\n   50170, 49542, 48918, 48298, 47682, 47070, 46462, 45858, 45257, 44661, 44068,\n   43479, 42894, 42312, 41733, 41159, 40587, 40020, 39455, 38894, 38336, 37782,\n   37230, 36682, 36137, 35595, 35057, 34521, 33988, 33459, 32932, 32408, 31887,\n   31369, 30854, 30341, 29832, 29325, 28820, 28319, 27820, 27324, 26830, 26339,\n   25850, 25364, 24880, 24399, 23920, 23444, 22970, 22499, 22029, 21562, 21098,\n   20636, 20175, 19718, 19262, 18808, 18357, 17908, 17461, 17016, 16573, 16132,\n   15694, 15257, 14822, 14390, 13959, 13530, 13103, 12678, 12255, 11834, 11415,\n   10997, 10582, 10168, 9756, 9346, 8937, 8531, 8126, 7723, 7321, 6921, 6523,\n   6127, 5732, 5339, 4947, 4557, 4169, 3782, 3397, 3014, 2632, 2251, 1872, 1495,\n   1119, 744, 372\n#endif\n};\n\nstatic png_int_32\npng_log8bit(unsigned int x)\n{\n   unsigned int lg2 = 0;\n   /* Each time 'x' is multiplied by 2, 1 must be subtracted off the final log,\n    * because the log is actually negate that means adding 1.  The final\n    * returned value thus has the range 0 (for 255 input) to 7.994 (for 1\n    * input), return -1 for the overflow (log 0) case, - so the result is\n    * always at most 19 bits.\n    */\n   if ((x &= 0xff) == 0)\n      return -1;\n\n   if ((x & 0xf0) == 0)\n      lg2  = 4, x <<= 4;\n\n   if ((x & 0xc0) == 0)\n      lg2 += 2, x <<= 2;\n\n   if ((x & 0x80) == 0)\n      lg2 += 1, x <<= 1;\n\n   /* result is at most 19 bits, so this cast is safe: */\n   return (png_int_32)((lg2 << 16) + ((png_8bit_l2[x-128]+32768)>>16));\n}\n\n/* The above gives exact (to 16 binary places) log2 values for 8-bit images,\n * for 16-bit images we use the most significant 8 bits of the 16-bit value to\n * get an approximation then multiply the approximation by a correction factor\n * determined by the remaining up to 8 bits.  This requires an additional step\n * in the 16-bit case.\n *\n * We want log2(value/65535), we have log2(v'/255), where:\n *\n *    value = v' * 256 + v''\n *          = v' * f\n *\n * So f is value/v', which is equal to (256+v''/v') since v' is in the range 128\n * to 255 and v'' is in the range 0 to 255 f will be in the range 256 to less\n * than 258.  The final factor also needs to correct for the fact that our 8-bit\n * value is scaled by 255, whereas the 16-bit values must be scaled by 65535.\n *\n * This gives a final formula using a calculated value 'x' which is value/v' and\n * scaling by 65536 to match the above table:\n *\n *   log2(x/257) * 65536\n *\n * Since these numbers are so close to '1' we can use simple linear\n * interpolation between the two end values 256/257 (result -368.61) and 258/257\n * (result 367.179).  The values used below are scaled by a further 64 to give\n * 16-bit precision in the interpolation:\n *\n * Start (256): -23591\n * Zero  (257):      0\n * End   (258):  23499\n */\nstatic png_int_32\npng_log16bit(png_uint_32 x)\n{\n   unsigned int lg2 = 0;\n\n   /* As above, but now the input has 16 bits. */\n   if ((x &= 0xffff) == 0)\n      return -1;\n\n   if ((x & 0xff00) == 0)\n      lg2  = 8, x <<= 8;\n\n   if ((x & 0xf000) == 0)\n      lg2 += 4, x <<= 4;\n\n   if ((x & 0xc000) == 0)\n      lg2 += 2, x <<= 2;\n\n   if ((x & 0x8000) == 0)\n      lg2 += 1, x <<= 1;\n\n   /* Calculate the base logarithm from the top 8 bits as a 28-bit fractional\n    * value.\n    */\n   lg2 <<= 28;\n   lg2 += (png_8bit_l2[(x>>8)-128]+8) >> 4;\n\n   /* Now we need to interpolate the factor, this requires a division by the top\n    * 8 bits.  Do this with maximum precision.\n    */\n   x = ((x << 16) + (x >> 9)) / (x >> 8);\n\n   /* Since we divided by the top 8 bits of 'x' there will be a '1' at 1<<24,\n    * the value at 1<<16 (ignoring this) will be 0 or 1; this gives us exactly\n    * 16 bits to interpolate to get the low bits of the result.  Round the\n    * answer.  Note that the end point values are scaled by 64 to retain overall\n    * precision and that 'lg2' is current scaled by an extra 12 bits, so adjust\n    * the overall scaling by 6-12.  Round at every step.\n    */\n   x -= 1U << 24;\n\n   if (x <= 65536U) /* <= '257' */\n      lg2 += ((23591U * (65536U-x)) + (1U << (16+6-12-1))) >> (16+6-12);\n\n   else\n      lg2 -= ((23499U * (x-65536U)) + (1U << (16+6-12-1))) >> (16+6-12);\n\n   /* Safe, because the result can't have more than 20 bits: */\n   return (png_int_32)((lg2 + 2048) >> 12);\n}\n\n/* The 'exp()' case must invert the above, taking a 20-bit fixed point\n * logarithmic value and returning a 16 or 8-bit number as appropriate.  In\n * each case only the low 16 bits are relevant - the fraction - since the\n * integer bits (the top 4) simply determine a shift.\n *\n * The worst case is the 16-bit distinction between 65535 and 65534, this\n * requires perhaps spurious accuracty in the decoding of the logarithm to\n * distinguish log2(65535/65534.5) - 10^-5 or 17 bits.  There is little chance\n * of getting this accuracy in practice.\n *\n * To deal with this the following exp() function works out the exponent of the\n * frational part of the logarithm by using an accurate 32-bit value from the\n * top four fractional bits then multiplying in the remaining bits.\n */\nstatic const png_uint_32\npng_32bit_exp[16] =\n{\n   /* NOTE: the first entry is deliberately set to the maximum 32-bit value. */\n   4294967295U, 4112874773U, 3938502376U, 3771522796U, 3611622603U, 3458501653U,\n   3311872529U, 3171459999U, 3037000500U, 2908241642U, 2784941738U, 2666869345U,\n   2553802834U, 2445529972U, 2341847524U, 2242560872U\n};\n\n/* Adjustment table; provided to explain the numbers in the code below. */\n#if 0\nfor (i=11;i>=0;--i){ print i, \" \", (1 - e(-(2^i)/65536*l(2))) * 2^(32-i), \"\\n\"}\n   11 44937.64284865548751208448\n   10 45180.98734845585101160448\n    9 45303.31936980687359311872\n    8 45364.65110595323018870784\n    7 45395.35850361789624614912\n    6 45410.72259715102037508096\n    5 45418.40724413220722311168\n    4 45422.25021786898173001728\n    3 45424.17186732298419044352\n    2 45425.13273269940811464704\n    1 45425.61317555035558641664\n    0 45425.85339951654943850496\n#endif\n\nstatic png_uint_32\npng_exp(png_fixed_point x)\n{\n   if (x > 0 && x <= 0xfffff) /* Else overflow or zero (underflow) */\n   {\n      /* Obtain a 4-bit approximation */\n      png_uint_32 e = png_32bit_exp[(x >> 12) & 0xf];\n\n      /* Incorporate the low 12 bits - these decrease the returned value by\n       * multiplying by a number less than 1 if the bit is set.  The multiplier\n       * is determined by the above table and the shift. Notice that the values\n       * converge on 45426 and this is used to allow linear interpolation of the\n       * low bits.\n       */\n      if (x & 0x800)\n         e -= (((e >> 16) * 44938U) +  16U) >> 5;\n\n      if (x & 0x400)\n         e -= (((e >> 16) * 45181U) +  32U) >> 6;\n\n      if (x & 0x200)\n         e -= (((e >> 16) * 45303U) +  64U) >> 7;\n\n      if (x & 0x100)\n         e -= (((e >> 16) * 45365U) + 128U) >> 8;\n\n      if (x & 0x080)\n         e -= (((e >> 16) * 45395U) + 256U) >> 9;\n\n      if (x & 0x040)\n         e -= (((e >> 16) * 45410U) + 512U) >> 10;\n\n      /* And handle the low 6 bits in a single block. */\n      e -= (((e >> 16) * 355U * (x & 0x3fU)) + 256U) >> 9;\n\n      /* Handle the upper bits of x. */\n      e >>= x >> 16;\n      return e;\n   }\n\n   /* Check for overflow */\n   if (x <= 0)\n      return png_32bit_exp[0];\n\n   /* Else underflow */\n   return 0;\n}\n\nstatic png_byte\npng_exp8bit(png_fixed_point lg2)\n{\n   /* Get a 32-bit value: */\n   png_uint_32 x = png_exp(lg2);\n\n   /* Convert the 32-bit value to 0..255 by multiplying by 256-1, note that the\n    * second, rounding, step can't overflow because of the first, subtraction,\n    * step.\n    */\n   x -= x >> 8;\n   return (png_byte)((x + 0x7fffffU) >> 24);\n}\n\n#ifdef PNG_16BIT_SUPPORTED\nstatic png_uint_16\npng_exp16bit(png_fixed_point lg2)\n{\n   /* Get a 32-bit value: */\n   png_uint_32 x = png_exp(lg2);\n\n   /* Convert the 32-bit value to 0..65535 by multiplying by 65536-1: */\n   x -= x >> 16;\n   return (png_uint_16)((x + 32767U) >> 16);\n}\n#endif /* 16BIT */\n#endif /* FLOATING_ARITHMETIC */\n\npng_byte\npng_gamma_8bit_correct(unsigned int value, png_fixed_point gamma_val)\n{\n   if (value > 0 && value < 255)\n   {\n#     ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED\n         double r = floor(255*pow(value/255.,gamma_val*.00001)+.5);\n         return (png_byte)r;\n#     else\n         png_int_32 lg2 = png_log8bit(value);\n         png_fixed_point res;\n\n         if (png_muldiv(&res, gamma_val, lg2, PNG_FP_1))\n            return png_exp8bit(res);\n\n         /* Overflow. */\n         value = 0;\n#     endif\n   }\n\n   return (png_byte)value;\n}\n\n#ifdef PNG_16BIT_SUPPORTED\npng_uint_16\npng_gamma_16bit_correct(unsigned int value, png_fixed_point gamma_val)\n{\n   if (value > 0 && value < 65535)\n   {\n#     ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED\n         double r = floor(65535*pow(value/65535.,gamma_val*.00001)+.5);\n         return (png_uint_16)r;\n#     else\n         png_int_32 lg2 = png_log16bit(value);\n         png_fixed_point res;\n\n         if (png_muldiv(&res, gamma_val, lg2, PNG_FP_1))\n            return png_exp16bit(res);\n\n         /* Overflow. */\n         value = 0;\n#     endif\n   }\n\n   return (png_uint_16)value;\n}\n#endif /* 16BIT */\n\n/* This does the right thing based on the bit_depth field of the\n * png_struct, interpreting values as 8-bit or 16-bit.  While the result\n * is nominally a 16-bit value if bit depth is 8 then the result is\n * 8-bit (as are the arguments.)\n */\npng_uint_16 /* PRIVATE */\npng_gamma_correct(png_structrp png_ptr, unsigned int value,\n    png_fixed_point gamma_val)\n{\n   if (png_ptr->bit_depth == 8)\n      return png_gamma_8bit_correct(value, gamma_val);\n\n#ifdef PNG_16BIT_SUPPORTED\n   else\n      return png_gamma_16bit_correct(value, gamma_val);\n#else\n      /* should not reach this */\n      return 0;\n#endif /* 16BIT */\n}\n\n#ifdef PNG_16BIT_SUPPORTED\n/* Internal function to build a single 16-bit table - the table consists of\n * 'num' 256 entry subtables, where 'num' is determined by 'shift' - the amount\n * to shift the input values right (or 16-number_of_signifiant_bits).\n *\n * The caller is responsible for ensuring that the table gets cleaned up on\n * png_error (i.e. if one of the mallocs below fails) - i.e. the *table argument\n * should be somewhere that will be cleaned.\n */\nstatic void\npng_build_16bit_table(png_structrp png_ptr, png_uint_16pp *ptable,\n   PNG_CONST unsigned int shift, PNG_CONST png_fixed_point gamma_val)\n{\n   /* Various values derived from 'shift': */\n   PNG_CONST unsigned int num = 1U << (8U - shift);\n   PNG_CONST unsigned int max = (1U << (16U - shift))-1U;\n   PNG_CONST unsigned int max_by_2 = 1U << (15U-shift);\n   unsigned int i;\n\n   png_uint_16pp table = *ptable =\n       (png_uint_16pp)png_calloc(png_ptr, num * (sizeof (png_uint_16p)));\n\n   for (i = 0; i < num; i++)\n   {\n      png_uint_16p sub_table = table[i] =\n          (png_uint_16p)png_malloc(png_ptr, 256 * (sizeof (png_uint_16)));\n\n      /* The 'threshold' test is repeated here because it can arise for one of\n       * the 16-bit tables even if the others don't hit it.\n       */\n      if (png_gamma_significant(gamma_val))\n      {\n         /* The old code would overflow at the end and this would cause the\n          * 'pow' function to return a result >1, resulting in an\n          * arithmetic error.  This code follows the spec exactly; ig is\n          * the recovered input sample, it always has 8-16 bits.\n          *\n          * We want input * 65535/max, rounded, the arithmetic fits in 32\n          * bits (unsigned) so long as max <= 32767.\n          */\n         unsigned int j;\n         for (j = 0; j < 256; j++)\n         {\n            png_uint_32 ig = (j << (8-shift)) + i;\n#           ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED\n               /* Inline the 'max' scaling operation: */\n               double d = floor(65535*pow(ig/(double)max, gamma_val*.00001)+.5);\n               sub_table[j] = (png_uint_16)d;\n#           else\n               if (shift)\n                  ig = (ig * 65535U + max_by_2)/max;\n\n               sub_table[j] = png_gamma_16bit_correct(ig, gamma_val);\n#           endif\n         }\n      }\n      else\n      {\n         /* We must still build a table, but do it the fast way. */\n         unsigned int j;\n\n         for (j = 0; j < 256; j++)\n         {\n            png_uint_32 ig = (j << (8-shift)) + i;\n\n            if (shift)\n               ig = (ig * 65535U + max_by_2)/max;\n\n            sub_table[j] = (png_uint_16)ig;\n         }\n      }\n   }\n}\n\n/* NOTE: this function expects the *inverse* of the overall gamma transformation\n * required.\n */\nstatic void\npng_build_16to8_table(png_structrp png_ptr, png_uint_16pp *ptable,\n   PNG_CONST unsigned int shift, PNG_CONST png_fixed_point gamma_val)\n{\n   PNG_CONST unsigned int num = 1U << (8U - shift);\n   PNG_CONST unsigned int max = (1U << (16U - shift))-1U;\n   unsigned int i;\n   png_uint_32 last;\n\n   png_uint_16pp table = *ptable =\n       (png_uint_16pp)png_calloc(png_ptr, num * (sizeof (png_uint_16p)));\n\n   /* 'num' is the number of tables and also the number of low bits of low\n    * bits of the input 16-bit value used to select a table.  Each table is\n    * itself index by the high 8 bits of the value.\n    */\n   for (i = 0; i < num; i++)\n      table[i] = (png_uint_16p)png_malloc(png_ptr,\n          256 * (sizeof (png_uint_16)));\n\n   /* 'gamma_val' is set to the reciprocal of the value calculated above, so\n    * pow(out,g) is an *input* value.  'last' is the last input value set.\n    *\n    * In the loop 'i' is used to find output values.  Since the output is\n    * 8-bit there are only 256 possible values.  The tables are set up to\n    * select the closest possible output value for each input by finding\n    * the input value at the boundary between each pair of output values\n    * and filling the table up to that boundary with the lower output\n    * value.\n    *\n    * The boundary values are 0.5,1.5..253.5,254.5.  Since these are 9-bit\n    * values the code below uses a 16-bit value in i; the values start at\n    * 128.5 (for 0.5) and step by 257, for a total of 254 values (the last\n    * entries are filled with 255).  Start i at 128 and fill all 'last'\n    * table entries <= 'max'\n    */\n   last = 0;\n   for (i = 0; i < 255; ++i) /* 8-bit output value */\n   {\n      /* Find the corresponding maximum input value */\n      png_uint_16 out = (png_uint_16)(i * 257U); /* 16-bit output value */\n\n      /* Find the boundary value in 16 bits: */\n      png_uint_32 bound = png_gamma_16bit_correct(out+128U, gamma_val);\n\n      /* Adjust (round) to (16-shift) bits: */\n      bound = (bound * max + 32768U)/65535U + 1U;\n\n      while (last < bound)\n      {\n         table[last & (0xffU >> shift)][last >> (8U - shift)] = out;\n         last++;\n      }\n   }\n\n   /* And fill in the final entries. */\n   while (last < (num << 8))\n   {\n      table[last & (0xff >> shift)][last >> (8U - shift)] = 65535U;\n      last++;\n   }\n}\n#endif /* 16BIT */\n\n/* Build a single 8-bit table: same as the 16-bit case but much simpler (and\n * typically much faster).  Note that libpng currently does no sBIT processing\n * (apparently contrary to the spec) so a 256 entry table is always generated.\n */\nstatic void\npng_build_8bit_table(png_structrp png_ptr, png_bytepp ptable,\n   PNG_CONST png_fixed_point gamma_val)\n{\n   unsigned int i;\n   png_bytep table = *ptable = (png_bytep)png_malloc(png_ptr, 256);\n\n   if (png_gamma_significant(gamma_val)) for (i=0; i<256; i++)\n      table[i] = png_gamma_8bit_correct(i, gamma_val);\n\n   else for (i=0; i<256; ++i)\n      table[i] = (png_byte)i;\n}\n\n/* Used from png_read_destroy and below to release the memory used by the gamma\n * tables.\n */\nvoid /* PRIVATE */\npng_destroy_gamma_table(png_structrp png_ptr)\n{\n   png_free(png_ptr, png_ptr->gamma_table);\n   png_ptr->gamma_table = NULL;\n\n#ifdef PNG_16BIT_SUPPORTED\n   if (png_ptr->gamma_16_table != NULL)\n   {\n      int i;\n      int istop = (1 << (8 - png_ptr->gamma_shift));\n      for (i = 0; i < istop; i++)\n      {\n         png_free(png_ptr, png_ptr->gamma_16_table[i]);\n      }\n   png_free(png_ptr, png_ptr->gamma_16_table);\n   png_ptr->gamma_16_table = NULL;\n   }\n#endif /* 16BIT */\n\n#if defined(PNG_READ_BACKGROUND_SUPPORTED) || \\\n   defined(PNG_READ_ALPHA_MODE_SUPPORTED) || \\\n   defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)\n   png_free(png_ptr, png_ptr->gamma_from_1);\n   png_ptr->gamma_from_1 = NULL;\n   png_free(png_ptr, png_ptr->gamma_to_1);\n   png_ptr->gamma_to_1 = NULL;\n\n#ifdef PNG_16BIT_SUPPORTED\n   if (png_ptr->gamma_16_from_1 != NULL)\n   {\n      int i;\n      int istop = (1 << (8 - png_ptr->gamma_shift));\n      for (i = 0; i < istop; i++)\n      {\n         png_free(png_ptr, png_ptr->gamma_16_from_1[i]);\n      }\n   png_free(png_ptr, png_ptr->gamma_16_from_1);\n   png_ptr->gamma_16_from_1 = NULL;\n   }\n   if (png_ptr->gamma_16_to_1 != NULL)\n   {\n      int i;\n      int istop = (1 << (8 - png_ptr->gamma_shift));\n      for (i = 0; i < istop; i++)\n      {\n         png_free(png_ptr, png_ptr->gamma_16_to_1[i]);\n      }\n   png_free(png_ptr, png_ptr->gamma_16_to_1);\n   png_ptr->gamma_16_to_1 = NULL;\n   }\n#endif /* 16BIT */\n#endif /* READ_BACKGROUND || READ_ALPHA_MODE || RGB_TO_GRAY */\n}\n\n/* We build the 8- or 16-bit gamma tables here.  Note that for 16-bit\n * tables, we don't make a full table if we are reducing to 8-bit in\n * the future.  Note also how the gamma_16 tables are segmented so that\n * we don't need to allocate > 64K chunks for a full 16-bit table.\n */\nvoid /* PRIVATE */\npng_build_gamma_table(png_structrp png_ptr, int bit_depth)\n{\n  png_debug(1, \"in png_build_gamma_table\");\n\n  /* Remove any existing table; this copes with multiple calls to\n   * png_read_update_info.  The warning is because building the gamma tables\n   * multiple times is a performance hit - it's harmless but the ability to call\n   * png_read_update_info() multiple times is new in 1.5.6 so it seems sensible\n   * to warn if the app introduces such a hit.\n   */\n  if (png_ptr->gamma_table != NULL || png_ptr->gamma_16_table != NULL)\n  {\n    png_warning(png_ptr, \"gamma table being rebuilt\");\n    png_destroy_gamma_table(png_ptr);\n  }\n\n  if (bit_depth <= 8)\n  {\n     png_build_8bit_table(png_ptr, &png_ptr->gamma_table,\n         png_ptr->screen_gamma > 0 ?  png_reciprocal2(png_ptr->colorspace.gamma,\n         png_ptr->screen_gamma) : PNG_FP_1);\n\n#if defined(PNG_READ_BACKGROUND_SUPPORTED) || \\\n   defined(PNG_READ_ALPHA_MODE_SUPPORTED) || \\\n   defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)\n     if (png_ptr->transformations & (PNG_COMPOSE | PNG_RGB_TO_GRAY))\n     {\n        png_build_8bit_table(png_ptr, &png_ptr->gamma_to_1,\n            png_reciprocal(png_ptr->colorspace.gamma));\n\n        png_build_8bit_table(png_ptr, &png_ptr->gamma_from_1,\n            png_ptr->screen_gamma > 0 ?  png_reciprocal(png_ptr->screen_gamma) :\n            png_ptr->colorspace.gamma/* Probably doing rgb_to_gray */);\n     }\n#endif /* READ_BACKGROUND || READ_ALPHA_MODE || RGB_TO_GRAY */\n  }\n#ifdef PNG_16BIT_SUPPORTED\n  else\n  {\n     png_byte shift, sig_bit;\n\n     if (png_ptr->color_type & PNG_COLOR_MASK_COLOR)\n     {\n        sig_bit = png_ptr->sig_bit.red;\n\n        if (png_ptr->sig_bit.green > sig_bit)\n           sig_bit = png_ptr->sig_bit.green;\n\n        if (png_ptr->sig_bit.blue > sig_bit)\n           sig_bit = png_ptr->sig_bit.blue;\n     }\n     else\n        sig_bit = png_ptr->sig_bit.gray;\n\n     /* 16-bit gamma code uses this equation:\n      *\n      *   ov = table[(iv & 0xff) >> gamma_shift][iv >> 8]\n      *\n      * Where 'iv' is the input color value and 'ov' is the output value -\n      * pow(iv, gamma).\n      *\n      * Thus the gamma table consists of up to 256 256 entry tables.  The table\n      * is selected by the (8-gamma_shift) most significant of the low 8 bits of\n      * the color value then indexed by the upper 8 bits:\n      *\n      *   table[low bits][high 8 bits]\n      *\n      * So the table 'n' corresponds to all those 'iv' of:\n      *\n      *   <all high 8-bit values><n << gamma_shift>..<(n+1 << gamma_shift)-1>\n      *\n      */\n     if (sig_bit > 0 && sig_bit < 16U)\n        shift = (png_byte)(16U - sig_bit); /* shift == insignificant bits */\n\n     else\n        shift = 0; /* keep all 16 bits */\n\n     if (png_ptr->transformations & (PNG_16_TO_8 | PNG_SCALE_16_TO_8))\n     {\n        /* PNG_MAX_GAMMA_8 is the number of bits to keep - effectively\n         * the significant bits in the *input* when the output will\n         * eventually be 8 bits.  By default it is 11.\n         */\n        if (shift < (16U - PNG_MAX_GAMMA_8))\n           shift = (16U - PNG_MAX_GAMMA_8);\n     }\n\n     if (shift > 8U)\n        shift = 8U; /* Guarantees at least one table! */\n\n     png_ptr->gamma_shift = shift;\n\n     /* NOTE: prior to 1.5.4 this test used to include PNG_BACKGROUND (now\n      * PNG_COMPOSE).  This effectively smashed the background calculation for\n      * 16-bit output because the 8-bit table assumes the result will be reduced\n      * to 8 bits.\n      */\n     if (png_ptr->transformations & (PNG_16_TO_8 | PNG_SCALE_16_TO_8))\n         png_build_16to8_table(png_ptr, &png_ptr->gamma_16_table, shift,\n         png_ptr->screen_gamma > 0 ? png_product2(png_ptr->colorspace.gamma,\n         png_ptr->screen_gamma) : PNG_FP_1);\n\n     else\n         png_build_16bit_table(png_ptr, &png_ptr->gamma_16_table, shift,\n         png_ptr->screen_gamma > 0 ? png_reciprocal2(png_ptr->colorspace.gamma,\n         png_ptr->screen_gamma) : PNG_FP_1);\n\n#if defined(PNG_READ_BACKGROUND_SUPPORTED) || \\\n   defined(PNG_READ_ALPHA_MODE_SUPPORTED) || \\\n   defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)\n     if (png_ptr->transformations & (PNG_COMPOSE | PNG_RGB_TO_GRAY))\n     {\n        png_build_16bit_table(png_ptr, &png_ptr->gamma_16_to_1, shift,\n            png_reciprocal(png_ptr->colorspace.gamma));\n\n        /* Notice that the '16 from 1' table should be full precision, however\n         * the lookup on this table still uses gamma_shift, so it can't be.\n         * TODO: fix this.\n         */\n        png_build_16bit_table(png_ptr, &png_ptr->gamma_16_from_1, shift,\n            png_ptr->screen_gamma > 0 ? png_reciprocal(png_ptr->screen_gamma) :\n            png_ptr->colorspace.gamma/* Probably doing rgb_to_gray */);\n     }\n#endif /* READ_BACKGROUND || READ_ALPHA_MODE || RGB_TO_GRAY */\n  }\n#endif /* 16BIT */\n}\n#endif /* READ_GAMMA */\n\n/* HARDWARE OPTION SUPPORT */\n#ifdef PNG_SET_OPTION_SUPPORTED\nint PNGAPI\npng_set_option(png_structrp png_ptr, int option, int onoff)\n{\n   if (png_ptr != NULL && option >= 0 && option < PNG_OPTION_NEXT &&\n      (option & 1) == 0)\n   {\n      int mask = 3 << option;\n      int setting = (2 + (onoff != 0)) << option;\n      int current = png_ptr->options;\n\n      png_ptr->options = (png_byte)((current & ~mask) | setting);\n\n      return (current & mask) >> option;\n   }\n\n   return PNG_OPTION_INVALID;\n}\n#endif\n\n/* sRGB support */\n#if defined(PNG_SIMPLIFIED_READ_SUPPORTED) ||\\\n   defined(PNG_SIMPLIFIED_WRITE_SUPPORTED)\n/* sRGB conversion tables; these are machine generated with the code in\n * contrib/tools/makesRGB.c.  The actual sRGB transfer curve defined in the\n * specification (see the article at http://en.wikipedia.org/wiki/SRGB)\n * is used, not the gamma=1/2.2 approximation use elsewhere in libpng.\n * The sRGB to linear table is exact (to the nearest 16 bit linear fraction).\n * The inverse (linear to sRGB) table has accuracies as follows:\n *\n * For all possible (255*65535+1) input values:\n *\n *    error: -0.515566 - 0.625971, 79441 (0.475369%) of readings inexact\n *\n * For the input values corresponding to the 65536 16-bit values:\n *\n *    error: -0.513727 - 0.607759, 308 (0.469978%) of readings inexact\n *\n * In all cases the inexact readings are off by one.\n */\n\n#ifdef PNG_SIMPLIFIED_READ_SUPPORTED\n/* The convert-to-sRGB table is only currently required for read. */\nconst png_uint_16 png_sRGB_table[256] =\n{\n   0,20,40,60,80,99,119,139,\n   159,179,199,219,241,264,288,313,\n   340,367,396,427,458,491,526,562,\n   599,637,677,718,761,805,851,898,\n   947,997,1048,1101,1156,1212,1270,1330,\n   1391,1453,1517,1583,1651,1720,1790,1863,\n   1937,2013,2090,2170,2250,2333,2418,2504,\n   2592,2681,2773,2866,2961,3058,3157,3258,\n   3360,3464,3570,3678,3788,3900,4014,4129,\n   4247,4366,4488,4611,4736,4864,4993,5124,\n   5257,5392,5530,5669,5810,5953,6099,6246,\n   6395,6547,6700,6856,7014,7174,7335,7500,\n   7666,7834,8004,8177,8352,8528,8708,8889,\n   9072,9258,9445,9635,9828,10022,10219,10417,\n   10619,10822,11028,11235,11446,11658,11873,12090,\n   12309,12530,12754,12980,13209,13440,13673,13909,\n   14146,14387,14629,14874,15122,15371,15623,15878,\n   16135,16394,16656,16920,17187,17456,17727,18001,\n   18277,18556,18837,19121,19407,19696,19987,20281,\n   20577,20876,21177,21481,21787,22096,22407,22721,\n   23038,23357,23678,24002,24329,24658,24990,25325,\n   25662,26001,26344,26688,27036,27386,27739,28094,\n   28452,28813,29176,29542,29911,30282,30656,31033,\n   31412,31794,32179,32567,32957,33350,33745,34143,\n   34544,34948,35355,35764,36176,36591,37008,37429,\n   37852,38278,38706,39138,39572,40009,40449,40891,\n   41337,41785,42236,42690,43147,43606,44069,44534,\n   45002,45473,45947,46423,46903,47385,47871,48359,\n   48850,49344,49841,50341,50844,51349,51858,52369,\n   52884,53401,53921,54445,54971,55500,56032,56567,\n   57105,57646,58190,58737,59287,59840,60396,60955,\n   61517,62082,62650,63221,63795,64372,64952,65535\n};\n\n#endif /* simplified read only */\n\n/* The base/delta tables are required for both read and write (but currently\n * only the simplified versions.)\n */\nconst png_uint_16 png_sRGB_base[512] =\n{\n   128,1782,3383,4644,5675,6564,7357,8074,\n   8732,9346,9921,10463,10977,11466,11935,12384,\n   12816,13233,13634,14024,14402,14769,15125,15473,\n   15812,16142,16466,16781,17090,17393,17690,17981,\n   18266,18546,18822,19093,19359,19621,19879,20133,\n   20383,20630,20873,21113,21349,21583,21813,22041,\n   22265,22487,22707,22923,23138,23350,23559,23767,\n   23972,24175,24376,24575,24772,24967,25160,25352,\n   25542,25730,25916,26101,26284,26465,26645,26823,\n   27000,27176,27350,27523,27695,27865,28034,28201,\n   28368,28533,28697,28860,29021,29182,29341,29500,\n   29657,29813,29969,30123,30276,30429,30580,30730,\n   30880,31028,31176,31323,31469,31614,31758,31902,\n   32045,32186,32327,32468,32607,32746,32884,33021,\n   33158,33294,33429,33564,33697,33831,33963,34095,\n   34226,34357,34486,34616,34744,34873,35000,35127,\n   35253,35379,35504,35629,35753,35876,35999,36122,\n   36244,36365,36486,36606,36726,36845,36964,37083,\n   37201,37318,37435,37551,37668,37783,37898,38013,\n   38127,38241,38354,38467,38580,38692,38803,38915,\n   39026,39136,39246,39356,39465,39574,39682,39790,\n   39898,40005,40112,40219,40325,40431,40537,40642,\n   40747,40851,40955,41059,41163,41266,41369,41471,\n   41573,41675,41777,41878,41979,42079,42179,42279,\n   42379,42478,42577,42676,42775,42873,42971,43068,\n   43165,43262,43359,43456,43552,43648,43743,43839,\n   43934,44028,44123,44217,44311,44405,44499,44592,\n   44685,44778,44870,44962,45054,45146,45238,45329,\n   45420,45511,45601,45692,45782,45872,45961,46051,\n   46140,46229,46318,46406,46494,46583,46670,46758,\n   46846,46933,47020,47107,47193,47280,47366,47452,\n   47538,47623,47709,47794,47879,47964,48048,48133,\n   48217,48301,48385,48468,48552,48635,48718,48801,\n   48884,48966,49048,49131,49213,49294,49376,49458,\n   49539,49620,49701,49782,49862,49943,50023,50103,\n   50183,50263,50342,50422,50501,50580,50659,50738,\n   50816,50895,50973,51051,51129,51207,51285,51362,\n   51439,51517,51594,51671,51747,51824,51900,51977,\n   52053,52129,52205,52280,52356,52432,52507,52582,\n   52657,52732,52807,52881,52956,53030,53104,53178,\n   53252,53326,53400,53473,53546,53620,53693,53766,\n   53839,53911,53984,54056,54129,54201,54273,54345,\n   54417,54489,54560,54632,54703,54774,54845,54916,\n   54987,55058,55129,55199,55269,55340,55410,55480,\n   55550,55620,55689,55759,55828,55898,55967,56036,\n   56105,56174,56243,56311,56380,56448,56517,56585,\n   56653,56721,56789,56857,56924,56992,57059,57127,\n   57194,57261,57328,57395,57462,57529,57595,57662,\n   57728,57795,57861,57927,57993,58059,58125,58191,\n   58256,58322,58387,58453,58518,58583,58648,58713,\n   58778,58843,58908,58972,59037,59101,59165,59230,\n   59294,59358,59422,59486,59549,59613,59677,59740,\n   59804,59867,59930,59993,60056,60119,60182,60245,\n   60308,60370,60433,60495,60558,60620,60682,60744,\n   60806,60868,60930,60992,61054,61115,61177,61238,\n   61300,61361,61422,61483,61544,61605,61666,61727,\n   61788,61848,61909,61969,62030,62090,62150,62211,\n   62271,62331,62391,62450,62510,62570,62630,62689,\n   62749,62808,62867,62927,62986,63045,63104,63163,\n   63222,63281,63340,63398,63457,63515,63574,63632,\n   63691,63749,63807,63865,63923,63981,64039,64097,\n   64155,64212,64270,64328,64385,64443,64500,64557,\n   64614,64672,64729,64786,64843,64900,64956,65013,\n   65070,65126,65183,65239,65296,65352,65409,65465\n};\n\nconst png_byte png_sRGB_delta[512] =\n{\n   207,201,158,129,113,100,90,82,77,72,68,64,61,59,56,54,\n   52,50,49,47,46,45,43,42,41,40,39,39,38,37,36,36,\n   35,34,34,33,33,32,32,31,31,30,30,30,29,29,28,28,\n   28,27,27,27,27,26,26,26,25,25,25,25,24,24,24,24,\n   23,23,23,23,23,22,22,22,22,22,22,21,21,21,21,21,\n   21,20,20,20,20,20,20,20,20,19,19,19,19,19,19,19,\n   19,18,18,18,18,18,18,18,18,18,18,17,17,17,17,17,\n   17,17,17,17,17,17,16,16,16,16,16,16,16,16,16,16,\n   16,16,16,16,15,15,15,15,15,15,15,15,15,15,15,15,\n   15,15,15,15,14,14,14,14,14,14,14,14,14,14,14,14,\n   14,14,14,14,14,14,14,13,13,13,13,13,13,13,13,13,\n   13,13,13,13,13,13,13,13,13,13,13,13,13,13,12,12,\n   12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,\n   12,12,12,12,12,12,12,12,12,12,12,12,11,11,11,11,\n   11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,\n   11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,\n   11,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,\n   10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,\n   10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,\n   10,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,\n   9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,\n   9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,\n   9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,\n   9,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,\n   8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,\n   8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,\n   8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,\n   8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,\n   8,8,8,8,8,8,8,8,8,7,7,7,7,7,7,7,\n   7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,\n   7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,\n   7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7\n};\n#endif /* SIMPLIFIED READ/WRITE sRGB support */\n\n/* SIMPLIFIED READ/WRITE SUPPORT */\n#if defined(PNG_SIMPLIFIED_READ_SUPPORTED) ||\\\n   defined(PNG_SIMPLIFIED_WRITE_SUPPORTED)\nstatic int\npng_image_free_function(png_voidp argument)\n{\n   png_imagep image = png_voidcast(png_imagep, argument);\n   png_controlp cp = image->opaque;\n   png_control c;\n\n   /* Double check that we have a png_ptr - it should be impossible to get here\n    * without one.\n    */\n   if (cp->png_ptr == NULL)\n      return 0;\n\n   /* First free any data held in the control structure. */\n#  ifdef PNG_STDIO_SUPPORTED\n      if (cp->owned_file)\n      {\n         FILE *fp = png_voidcast(FILE*, cp->png_ptr->io_ptr);\n         cp->owned_file = 0;\n\n         /* Ignore errors here. */\n         if (fp != NULL)\n         {\n            cp->png_ptr->io_ptr = NULL;\n            (void)fclose(fp);\n         }\n      }\n#  endif\n\n   /* Copy the control structure so that the original, allocated, version can be\n    * safely freed.  Notice that a png_error here stops the remainder of the\n    * cleanup, but this is probably fine because that would indicate bad memory\n    * problems anyway.\n    */\n   c = *cp;\n   image->opaque = &c;\n   png_free(c.png_ptr, cp);\n\n   /* Then the structures, calling the correct API. */\n   if (c.for_write)\n   {\n#     ifdef PNG_SIMPLIFIED_WRITE_SUPPORTED\n         png_destroy_write_struct(&c.png_ptr, &c.info_ptr);\n#     else\n         png_error(c.png_ptr, \"simplified write not supported\");\n#     endif\n   }\n   else\n   {\n#     ifdef PNG_SIMPLIFIED_READ_SUPPORTED\n         png_destroy_read_struct(&c.png_ptr, &c.info_ptr, NULL);\n#     else\n         png_error(c.png_ptr, \"simplified read not supported\");\n#     endif\n   }\n\n   /* Success. */\n   return 1;\n}\n\nvoid PNGAPI\npng_image_free(png_imagep image)\n{\n   /* Safely call the real function, but only if doing so is safe at this point\n    * (if not inside an error handling context).  Otherwise assume\n    * png_safe_execute will call this API after the return.\n    */\n   if (image != NULL && image->opaque != NULL &&\n      image->opaque->error_buf == NULL)\n   {\n      /* Ignore errors here: */\n      (void)png_safe_execute(image, png_image_free_function, image);\n      image->opaque = NULL;\n   }\n}\n\nint /* PRIVATE */\npng_image_error(png_imagep image, png_const_charp error_message)\n{\n   /* Utility to log an error. */\n   png_safecat(image->message, (sizeof image->message), 0, error_message);\n   image->warning_or_error |= PNG_IMAGE_ERROR;\n   png_image_free(image);\n   return 0;\n}\n\n#endif /* SIMPLIFIED READ/WRITE */\n#endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */\n"
  },
  {
    "path": "Projects/Libraries/CSBase/Source/png/png.h",
    "content": "\n/* png.h - header file for PNG reference library\n *\n * libpng version 1.6.10 - March 6, 2014\n * Copyright (c) 1998-2014 Glenn Randers-Pehrson\n * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)\n * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)\n *\n * This code is released under the libpng license (See LICENSE, below)\n *\n * Authors and maintainers:\n *   libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat\n *   libpng versions 0.89c, June 1996, through 0.96, May 1997: Andreas Dilger\n *   libpng versions 0.97, January 1998, through 1.6.10 - March 6, 2014: Glenn\n *   See also \"Contributing Authors\", below.\n *\n * Note about libpng version numbers:\n *\n *   Due to various miscommunications, unforeseen code incompatibilities\n *   and occasional factors outside the authors' control, version numbering\n *   on the library has not always been consistent and straightforward.\n *   The following table summarizes matters since version 0.89c, which was\n *   the first widely used release:\n *\n *    source                 png.h  png.h  shared-lib\n *    version                string   int  version\n *    -------                ------ -----  ----------\n *    0.89c \"1.0 beta 3\"     0.89      89  1.0.89\n *    0.90  \"1.0 beta 4\"     0.90      90  0.90  [should have been 2.0.90]\n *    0.95  \"1.0 beta 5\"     0.95      95  0.95  [should have been 2.0.95]\n *    0.96  \"1.0 beta 6\"     0.96      96  0.96  [should have been 2.0.96]\n *    0.97b \"1.00.97 beta 7\" 1.00.97   97  1.0.1 [should have been 2.0.97]\n *    0.97c                  0.97      97  2.0.97\n *    0.98                   0.98      98  2.0.98\n *    0.99                   0.99      98  2.0.99\n *    0.99a-m                0.99      99  2.0.99\n *    1.00                   1.00     100  2.1.0 [100 should be 10000]\n *    1.0.0      (from here on, the   100  2.1.0 [100 should be 10000]\n *    1.0.1       png.h string is   10001  2.1.0\n *    1.0.1a-e    identical to the  10002  from here on, the shared library\n *    1.0.2       source version)   10002  is 2.V where V is the source code\n *    1.0.2a-b                      10003  version, except as noted.\n *    1.0.3                         10003\n *    1.0.3a-d                      10004\n *    1.0.4                         10004\n *    1.0.4a-f                      10005\n *    1.0.5 (+ 2 patches)           10005\n *    1.0.5a-d                      10006\n *    1.0.5e-r                      10100 (not source compatible)\n *    1.0.5s-v                      10006 (not binary compatible)\n *    1.0.6 (+ 3 patches)           10006 (still binary incompatible)\n *    1.0.6d-f                      10007 (still binary incompatible)\n *    1.0.6g                        10007\n *    1.0.6h                        10007  10.6h (testing xy.z so-numbering)\n *    1.0.6i                        10007  10.6i\n *    1.0.6j                        10007  2.1.0.6j (incompatible with 1.0.0)\n *    1.0.7beta11-14        DLLNUM  10007  2.1.0.7beta11-14 (binary compatible)\n *    1.0.7beta15-18           1    10007  2.1.0.7beta15-18 (binary compatible)\n *    1.0.7rc1-2               1    10007  2.1.0.7rc1-2 (binary compatible)\n *    1.0.7                    1    10007  (still compatible)\n *    1.0.8beta1-4             1    10008  2.1.0.8beta1-4\n *    1.0.8rc1                 1    10008  2.1.0.8rc1\n *    1.0.8                    1    10008  2.1.0.8\n *    1.0.9beta1-6             1    10009  2.1.0.9beta1-6\n *    1.0.9rc1                 1    10009  2.1.0.9rc1\n *    1.0.9beta7-10            1    10009  2.1.0.9beta7-10\n *    1.0.9rc2                 1    10009  2.1.0.9rc2\n *    1.0.9                    1    10009  2.1.0.9\n *    1.0.10beta1              1    10010  2.1.0.10beta1\n *    1.0.10rc1                1    10010  2.1.0.10rc1\n *    1.0.10                   1    10010  2.1.0.10\n *    1.0.11beta1-3            1    10011  2.1.0.11beta1-3\n *    1.0.11rc1                1    10011  2.1.0.11rc1\n *    1.0.11                   1    10011  2.1.0.11\n *    1.0.12beta1-2            2    10012  2.1.0.12beta1-2\n *    1.0.12rc1                2    10012  2.1.0.12rc1\n *    1.0.12                   2    10012  2.1.0.12\n *    1.1.0a-f                 -    10100  2.1.1.0a-f (branch abandoned)\n *    1.2.0beta1-2             2    10200  2.1.2.0beta1-2\n *    1.2.0beta3-5             3    10200  3.1.2.0beta3-5\n *    1.2.0rc1                 3    10200  3.1.2.0rc1\n *    1.2.0                    3    10200  3.1.2.0\n *    1.2.1beta1-4             3    10201  3.1.2.1beta1-4\n *    1.2.1rc1-2               3    10201  3.1.2.1rc1-2\n *    1.2.1                    3    10201  3.1.2.1\n *    1.2.2beta1-6            12    10202  12.so.0.1.2.2beta1-6\n *    1.0.13beta1             10    10013  10.so.0.1.0.13beta1\n *    1.0.13rc1               10    10013  10.so.0.1.0.13rc1\n *    1.2.2rc1                12    10202  12.so.0.1.2.2rc1\n *    1.0.13                  10    10013  10.so.0.1.0.13\n *    1.2.2                   12    10202  12.so.0.1.2.2\n *    1.2.3rc1-6              12    10203  12.so.0.1.2.3rc1-6\n *    1.2.3                   12    10203  12.so.0.1.2.3\n *    1.2.4beta1-3            13    10204  12.so.0.1.2.4beta1-3\n *    1.0.14rc1               13    10014  10.so.0.1.0.14rc1\n *    1.2.4rc1                13    10204  12.so.0.1.2.4rc1\n *    1.0.14                  10    10014  10.so.0.1.0.14\n *    1.2.4                   13    10204  12.so.0.1.2.4\n *    1.2.5beta1-2            13    10205  12.so.0.1.2.5beta1-2\n *    1.0.15rc1-3             10    10015  10.so.0.1.0.15rc1-3\n *    1.2.5rc1-3              13    10205  12.so.0.1.2.5rc1-3\n *    1.0.15                  10    10015  10.so.0.1.0.15\n *    1.2.5                   13    10205  12.so.0.1.2.5\n *    1.2.6beta1-4            13    10206  12.so.0.1.2.6beta1-4\n *    1.0.16                  10    10016  10.so.0.1.0.16\n *    1.2.6                   13    10206  12.so.0.1.2.6\n *    1.2.7beta1-2            13    10207  12.so.0.1.2.7beta1-2\n *    1.0.17rc1               10    10017  12.so.0.1.0.17rc1\n *    1.2.7rc1                13    10207  12.so.0.1.2.7rc1\n *    1.0.17                  10    10017  12.so.0.1.0.17\n *    1.2.7                   13    10207  12.so.0.1.2.7\n *    1.2.8beta1-5            13    10208  12.so.0.1.2.8beta1-5\n *    1.0.18rc1-5             10    10018  12.so.0.1.0.18rc1-5\n *    1.2.8rc1-5              13    10208  12.so.0.1.2.8rc1-5\n *    1.0.18                  10    10018  12.so.0.1.0.18\n *    1.2.8                   13    10208  12.so.0.1.2.8\n *    1.2.9beta1-3            13    10209  12.so.0.1.2.9beta1-3\n *    1.2.9beta4-11           13    10209  12.so.0.9[.0]\n *    1.2.9rc1                13    10209  12.so.0.9[.0]\n *    1.2.9                   13    10209  12.so.0.9[.0]\n *    1.2.10beta1-7           13    10210  12.so.0.10[.0]\n *    1.2.10rc1-2             13    10210  12.so.0.10[.0]\n *    1.2.10                  13    10210  12.so.0.10[.0]\n *    1.4.0beta1-5            14    10400  14.so.0.0[.0]\n *    1.2.11beta1-4           13    10211  12.so.0.11[.0]\n *    1.4.0beta7-8            14    10400  14.so.0.0[.0]\n *    1.2.11                  13    10211  12.so.0.11[.0]\n *    1.2.12                  13    10212  12.so.0.12[.0]\n *    1.4.0beta9-14           14    10400  14.so.0.0[.0]\n *    1.2.13                  13    10213  12.so.0.13[.0]\n *    1.4.0beta15-36          14    10400  14.so.0.0[.0]\n *    1.4.0beta37-87          14    10400  14.so.14.0[.0]\n *    1.4.0rc01               14    10400  14.so.14.0[.0]\n *    1.4.0beta88-109         14    10400  14.so.14.0[.0]\n *    1.4.0rc02-08            14    10400  14.so.14.0[.0]\n *    1.4.0                   14    10400  14.so.14.0[.0]\n *    1.4.1beta01-03          14    10401  14.so.14.1[.0]\n *    1.4.1rc01               14    10401  14.so.14.1[.0]\n *    1.4.1beta04-12          14    10401  14.so.14.1[.0]\n *    1.4.1                   14    10401  14.so.14.1[.0]\n *    1.4.2                   14    10402  14.so.14.2[.0]\n *    1.4.3                   14    10403  14.so.14.3[.0]\n *    1.4.4                   14    10404  14.so.14.4[.0]\n *    1.5.0beta01-58          15    10500  15.so.15.0[.0]\n *    1.5.0rc01-07            15    10500  15.so.15.0[.0]\n *    1.5.0                   15    10500  15.so.15.0[.0]\n *    1.5.1beta01-11          15    10501  15.so.15.1[.0]\n *    1.5.1rc01-02            15    10501  15.so.15.1[.0]\n *    1.5.1                   15    10501  15.so.15.1[.0]\n *    1.5.2beta01-03          15    10502  15.so.15.2[.0]\n *    1.5.2rc01-03            15    10502  15.so.15.2[.0]\n *    1.5.2                   15    10502  15.so.15.2[.0]\n *    1.5.3beta01-10          15    10503  15.so.15.3[.0]\n *    1.5.3rc01-02            15    10503  15.so.15.3[.0]\n *    1.5.3beta11             15    10503  15.so.15.3[.0]\n *    1.5.3 [omitted]\n *    1.5.4beta01-08          15    10504  15.so.15.4[.0]\n *    1.5.4rc01               15    10504  15.so.15.4[.0]\n *    1.5.4                   15    10504  15.so.15.4[.0]\n *    1.5.5beta01-08          15    10505  15.so.15.5[.0]\n *    1.5.5rc01               15    10505  15.so.15.5[.0]\n *    1.5.5                   15    10505  15.so.15.5[.0]\n *    1.5.6beta01-07          15    10506  15.so.15.6[.0]\n *    1.5.6rc01-03            15    10506  15.so.15.6[.0]\n *    1.5.6                   15    10506  15.so.15.6[.0]\n *    1.5.7beta01-05          15    10507  15.so.15.7[.0]\n *    1.5.7rc01-03            15    10507  15.so.15.7[.0]\n *    1.5.7                   15    10507  15.so.15.7[.0]\n *    1.6.0beta01-40          16    10600  16.so.16.0[.0]\n *    1.6.0rc01-08            16    10600  16.so.16.0[.0]\n *    1.6.0                   16    10600  16.so.16.0[.0]\n *    1.6.1beta01-09          16    10601  16.so.16.1[.0]\n *    1.6.1rc01               16    10601  16.so.16.1[.0]\n *    1.6.1                   16    10601  16.so.16.1[.0]\n *    1.6.2beta01             16    10602  16.so.16.2[.0]\n *    1.6.2rc01-06            16    10602  16.so.16.2[.0]\n *    1.6.2                   16    10602  16.so.16.2[.0]\n *    1.6.3beta01-11          16    10603  16.so.16.3[.0]\n *    1.6.3rc01               16    10603  16.so.16.3[.0]\n *    1.6.3                   16    10603  16.so.16.3[.0]\n *    1.6.4beta01-02          16    10604  16.so.16.4[.0]\n *    1.6.4rc01               16    10604  16.so.16.4[.0]\n *    1.6.4                   16    10604  16.so.16.4[.0]\n *    1.6.5                   16    10605  16.so.16.5[.0]\n *    1.6.6                   16    10606  16.so.16.6[.0]\n *    1.6.7beta01-04          16    10607  16.so.16.7[.0]\n *    1.6.7rc01-03            16    10607  16.so.16.7[.0]\n *    1.6.7                   16    10607  16.so.16.7[.0]\n *    1.6.8beta01-02          16    10608  16.so.16.8[.0]\n *    1.6.8rc01-02            16    10608  16.so.16.8[.0]\n *    1.6.8                   16    10608  16.so.16.8[.0]\n *    1.6.9beta01-04          16    10609  16.so.16.9[.0]\n *    1.6.9rc01-02            16    10609  16.so.16.9[.0]\n *    1.6.9                   16    10609  16.so.16.9[.0]\n *    1.6.10beta01-03         16    10610  16.so.16.10[.0]\n *    1.6.10betarc01-04       16    10610  16.so.16.10[.0]\n *    1.6.10beta              16    10610  16.so.16.10[.0]\n *\n *   Henceforth the source version will match the shared-library major\n *   and minor numbers; the shared-library major version number will be\n *   used for changes in backward compatibility, as it is intended.  The\n *   PNG_LIBPNG_VER macro, which is not used within libpng but is available\n *   for applications, is an unsigned integer of the form xyyzz corresponding\n *   to the source version x.y.z (leading zeros in y and z).  Beta versions\n *   were given the previous public release number plus a letter, until\n *   version 1.0.6j; from then on they were given the upcoming public\n *   release number plus \"betaNN\" or \"rcNN\".\n *\n *   Binary incompatibility exists only when applications make direct access\n *   to the info_ptr or png_ptr members through png.h, and the compiled\n *   application is loaded with a different version of the library.\n *\n *   DLLNUM will change each time there are forward or backward changes\n *   in binary compatibility (e.g., when a new feature is added).\n *\n * See libpng-manual.txt or libpng.3 for more information.  The PNG\n * specification is available as a W3C Recommendation and as an ISO\n * Specification, <http://www.w3.org/TR/2003/REC-PNG-20031110/\n */\n\n/*\n * COPYRIGHT NOTICE, DISCLAIMER, and LICENSE:\n *\n * If you modify libpng you may insert additional notices immediately following\n * this sentence.\n *\n * This code is released under the libpng license.\n *\n * libpng versions 1.2.6, August 15, 2004, through 1.6.10, March 6, 2014, are\n * Copyright (c) 2004, 2006-2013 Glenn Randers-Pehrson, and are\n * distributed according to the same disclaimer and license as libpng-1.2.5\n * with the following individual added to the list of Contributing Authors:\n *\n *    Cosmin Truta\n *\n * libpng versions 1.0.7, July 1, 2000, through 1.2.5, October 3, 2002, are\n * Copyright (c) 2000-2002 Glenn Randers-Pehrson, and are\n * distributed according to the same disclaimer and license as libpng-1.0.6\n * with the following individuals added to the list of Contributing Authors:\n *\n *    Simon-Pierre Cadieux\n *    Eric S. Raymond\n *    Gilles Vollant\n *\n * and with the following additions to the disclaimer:\n *\n *    There is no warranty against interference with your enjoyment of the\n *    library or against infringement.  There is no warranty that our\n *    efforts or the library will fulfill any of your particular purposes\n *    or needs.  This library is provided with all faults, and the entire\n *    risk of satisfactory quality, performance, accuracy, and effort is with\n *    the user.\n *\n * libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are\n * Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson, and are\n * distributed according to the same disclaimer and license as libpng-0.96,\n * with the following individuals added to the list of Contributing Authors:\n *\n *    Tom Lane\n *    Glenn Randers-Pehrson\n *    Willem van Schaik\n *\n * libpng versions 0.89, June 1996, through 0.96, May 1997, are\n * Copyright (c) 1996, 1997 Andreas Dilger\n * Distributed according to the same disclaimer and license as libpng-0.88,\n * with the following individuals added to the list of Contributing Authors:\n *\n *    John Bowler\n *    Kevin Bracey\n *    Sam Bushell\n *    Magnus Holmgren\n *    Greg Roelofs\n *    Tom Tanner\n *\n * libpng versions 0.5, May 1995, through 0.88, January 1996, are\n * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.\n *\n * For the purposes of this copyright and license, \"Contributing Authors\"\n * is defined as the following set of individuals:\n *\n *    Andreas Dilger\n *    Dave Martindale\n *    Guy Eric Schalnat\n *    Paul Schmidt\n *    Tim Wegner\n *\n * The PNG Reference Library is supplied \"AS IS\".  The Contributing Authors\n * and Group 42, Inc. disclaim all warranties, expressed or implied,\n * including, without limitation, the warranties of merchantability and of\n * fitness for any purpose.  The Contributing Authors and Group 42, Inc.\n * assume no liability for direct, indirect, incidental, special, exemplary,\n * or consequential damages, which may result from the use of the PNG\n * Reference Library, even if advised of the possibility of such damage.\n *\n * Permission is hereby granted to use, copy, modify, and distribute this\n * source code, or portions hereof, for any purpose, without fee, subject\n * to the following restrictions:\n *\n *   1. The origin of this source code must not be misrepresented.\n *\n *   2. Altered versions must be plainly marked as such and must not\n *      be misrepresented as being the original source.\n *\n *   3. This Copyright notice may not be removed or altered from\n *      any source or altered source distribution.\n *\n * The Contributing Authors and Group 42, Inc. specifically permit, without\n * fee, and encourage the use of this source code as a component to\n * supporting the PNG file format in commercial products.  If you use this\n * source code in a product, acknowledgment is not required but would be\n * appreciated.\n */\n\n/*\n * A \"png_get_copyright\" function is available, for convenient use in \"about\"\n * boxes and the like:\n *\n *     printf(\"%s\", png_get_copyright(NULL));\n *\n * Also, the PNG logo (in PNG format, of course) is supplied in the\n * files \"pngbar.png\" and \"pngbar.jpg (88x31) and \"pngnow.png\" (98x31).\n */\n\n/*\n * Libpng is OSI Certified Open Source Software.  OSI Certified is a\n * certification mark of the Open Source Initiative.\n */\n\n/*\n * The contributing authors would like to thank all those who helped\n * with testing, bug fixes, and patience.  This wouldn't have been\n * possible without all of you.\n *\n * Thanks to Frank J. T. Wojcik for helping with the documentation.\n */\n\n/*\n * Y2K compliance in libpng:\n * =========================\n *\n *    March 6, 2014\n *\n *    Since the PNG Development group is an ad-hoc body, we can't make\n *    an official declaration.\n *\n *    This is your unofficial assurance that libpng from version 0.71 and\n *    upward through 1.6.10 are Y2K compliant.  It is my belief that\n *    earlier versions were also Y2K compliant.\n *\n *    Libpng only has two year fields.  One is a 2-byte unsigned integer\n *    that will hold years up to 65535.  The other, which is deprecated,\n *    holds the date in text format, and will hold years up to 9999.\n *\n *    The integer is\n *        \"png_uint_16 year\" in png_time_struct.\n *\n *    The string is\n *        \"char time_buffer[29]\" in png_struct.  This is no longer used\n *    in libpng-1.6.x and will be removed from libpng-1.7.0.\n *\n *    There are seven time-related functions:\n *        png.c: png_convert_to_rfc_1123_buffer() in png.c\n *          (formerly png_convert_to_rfc_1123() prior to libpng-1.5.x and\n *          png_convert_to_rfc_1152() in error prior to libpng-0.98)\n *        png_convert_from_struct_tm() in pngwrite.c, called in pngwrite.c\n *        png_convert_from_time_t() in pngwrite.c\n *        png_get_tIME() in pngget.c\n *        png_handle_tIME() in pngrutil.c, called in pngread.c\n *        png_set_tIME() in pngset.c\n *        png_write_tIME() in pngwutil.c, called in pngwrite.c\n *\n *    All handle dates properly in a Y2K environment.  The\n *    png_convert_from_time_t() function calls gmtime() to convert from system\n *    clock time, which returns (year - 1900), which we properly convert to\n *    the full 4-digit year.  There is a possibility that libpng applications\n *    are not passing 4-digit years into the png_convert_to_rfc_1123_buffer()\n *    function, or that they are incorrectly passing only a 2-digit year\n *    instead of \"year - 1900\" into the png_convert_from_struct_tm() function,\n *    but this is not under our control.  The libpng documentation has always\n *    stated that it works with 4-digit years, and the APIs have been\n *    documented as such.\n *\n *    The tIME chunk itself is also Y2K compliant.  It uses a 2-byte unsigned\n *    integer to hold the year, and can hold years as large as 65535.\n *\n *    zlib, upon which libpng depends, is also Y2K compliant.  It contains\n *    no date-related code.\n *\n *       Glenn Randers-Pehrson\n *       libpng maintainer\n *       PNG Development Group\n */\n\n#ifndef PNG_H\n#define PNG_H\n\n/* This is not the place to learn how to use libpng. The file libpng-manual.txt\n * describes how to use libpng, and the file example.c summarizes it\n * with some code on which to build.  This file is useful for looking\n * at the actual function definitions and structure components.\n *\n * If you just need to read a PNG file and don't want to read the documentation\n * skip to the end of this file and read the section entitled 'simplified API'.\n */\n\n/* Version information for png.h - this should match the version in png.c */\n#define PNG_LIBPNG_VER_STRING \"1.6.10\"\n#define PNG_HEADER_VERSION_STRING \\\n     \" libpng version 1.6.10 - March 6, 2014\\n\"\n\n#define PNG_LIBPNG_VER_SONUM   16\n#define PNG_LIBPNG_VER_DLLNUM  16\n\n/* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */\n#define PNG_LIBPNG_VER_MAJOR   1\n#define PNG_LIBPNG_VER_MINOR   6\n#define PNG_LIBPNG_VER_RELEASE 10\n\n/* This should match the numeric part of the final component of\n * PNG_LIBPNG_VER_STRING, omitting any leading zero:\n */\n\n#define PNG_LIBPNG_VER_BUILD  0\n\n/* Release Status */\n#define PNG_LIBPNG_BUILD_ALPHA    1\n#define PNG_LIBPNG_BUILD_BETA     2\n#define PNG_LIBPNG_BUILD_RC       3\n#define PNG_LIBPNG_BUILD_STABLE   4\n#define PNG_LIBPNG_BUILD_RELEASE_STATUS_MASK 7\n\n/* Release-Specific Flags */\n#define PNG_LIBPNG_BUILD_PATCH    8 /* Can be OR'ed with\n                                       PNG_LIBPNG_BUILD_STABLE only */\n#define PNG_LIBPNG_BUILD_PRIVATE 16 /* Cannot be OR'ed with\n                                       PNG_LIBPNG_BUILD_SPECIAL */\n#define PNG_LIBPNG_BUILD_SPECIAL 32 /* Cannot be OR'ed with\n                                       PNG_LIBPNG_BUILD_PRIVATE */\n\n#define PNG_LIBPNG_BUILD_BASE_TYPE PNG_LIBPNG_BUILD_STABLE\n\n/* Careful here.  At one time, Guy wanted to use 082, but that would be octal.\n * We must not include leading zeros.\n * Versions 0.7 through 1.0.0 were in the range 0 to 100 here (only\n * version 1.0.0 was mis-numbered 100 instead of 10000).  From\n * version 1.0.1 it's    xxyyzz, where x=major, y=minor, z=release\n */\n#define PNG_LIBPNG_VER 10610 /* 1.6.10 */\n\n/* Library configuration: these options cannot be changed after\n * the library has been built.\n */\n#ifndef PNGLCONF_H\n    /* If pnglibconf.h is missing, you can\n     * copy scripts/pnglibconf.h.prebuilt to pnglibconf.h\n     */\n#   include \"pnglibconf.h\"\n#endif\n\n#ifndef PNG_VERSION_INFO_ONLY\n   /* Machine specific configuration. */\n#  include \"pngconf.h\"\n#endif\n\n/*\n * Added at libpng-1.2.8\n *\n * Ref MSDN: Private as priority over Special\n * VS_FF_PRIVATEBUILD File *was not* built using standard release\n * procedures. If this value is given, the StringFileInfo block must\n * contain a PrivateBuild string.\n *\n * VS_FF_SPECIALBUILD File *was* built by the original company using\n * standard release procedures but is a variation of the standard\n * file of the same version number. If this value is given, the\n * StringFileInfo block must contain a SpecialBuild string.\n */\n\n#ifdef PNG_USER_PRIVATEBUILD /* From pnglibconf.h */\n#  define PNG_LIBPNG_BUILD_TYPE \\\n       (PNG_LIBPNG_BUILD_BASE_TYPE | PNG_LIBPNG_BUILD_PRIVATE)\n#else\n#  ifdef PNG_LIBPNG_SPECIALBUILD\n#    define PNG_LIBPNG_BUILD_TYPE \\\n         (PNG_LIBPNG_BUILD_BASE_TYPE | PNG_LIBPNG_BUILD_SPECIAL)\n#  else\n#    define PNG_LIBPNG_BUILD_TYPE (PNG_LIBPNG_BUILD_BASE_TYPE)\n#  endif\n#endif\n\n#ifndef PNG_VERSION_INFO_ONLY\n\n/* Inhibit C++ name-mangling for libpng functions but not for system calls. */\n#ifdef __cplusplus\nextern \"C\" {\n#endif /* __cplusplus */\n\n/* Version information for C files, stored in png.c.  This had better match\n * the version above.\n */\n#define png_libpng_ver png_get_header_ver(NULL)\n\n/* This file is arranged in several sections:\n *\n * 1. Any configuration options that can be specified by for the application\n *    code when it is built.  (Build time configuration is in pnglibconf.h)\n * 2. Type definitions (base types are defined in pngconf.h), structure\n *    definitions.\n * 3. Exported library functions.\n * 4. Simplified API.\n *\n * The library source code has additional files (principally pngpriv.h) that\n * allow configuration of the library.\n */\n/* Section 1: run time configuration\n * See pnglibconf.h for build time configuration\n *\n * Run time configuration allows the application to choose between\n * implementations of certain arithmetic APIs.  The default is set\n * at build time and recorded in pnglibconf.h, but it is safe to\n * override these (and only these) settings.  Note that this won't\n * change what the library does, only application code, and the\n * settings can (and probably should) be made on a per-file basis\n * by setting the #defines before including png.h\n *\n * Use macros to read integers from PNG data or use the exported\n * functions?\n *   PNG_USE_READ_MACROS: use the macros (see below)  Note that\n *     the macros evaluate their argument multiple times.\n *   PNG_NO_USE_READ_MACROS: call the relevant library function.\n *\n * Use the alternative algorithm for compositing alpha samples that\n * does not use division?\n *   PNG_READ_COMPOSITE_NODIV_SUPPORTED: use the 'no division'\n *      algorithm.\n *   PNG_NO_READ_COMPOSITE_NODIV: use the 'division' algorithm.\n *\n * How to handle benign errors if PNG_ALLOW_BENIGN_ERRORS is\n * false?\n *   PNG_ALLOW_BENIGN_ERRORS: map calls to the benign error\n *      APIs to png_warning.\n * Otherwise the calls are mapped to png_error.\n */\n\n/* Section 2: type definitions, including structures and compile time\n * constants.\n * See pngconf.h for base types that vary by machine/system\n */\n\n/* This triggers a compiler error in png.c, if png.c and png.h\n * do not agree upon the version number.\n */\ntypedef char* png_libpng_version_1_6_10;\n\n/* Basic control structions.  Read libpng-manual.txt or libpng.3 for more info.\n *\n * png_struct is the cache of information used while reading or writing a single\n * PNG file.  One of these is always required, although the simplified API\n * (below) hides the creation and destruction of it.\n */\ntypedef struct png_struct_def png_struct;\ntypedef const png_struct * png_const_structp;\ntypedef png_struct * png_structp;\ntypedef png_struct * * png_structpp;\n\n/* png_info contains information read from or to be written to a PNG file.  One\n * or more of these must exist while reading or creating a PNG file.  The\n * information is not used by libpng during read but is used to control what\n * gets written when a PNG file is created.  \"png_get_\" function calls read\n * information during read and \"png_set_\" functions calls write information\n * when creating a PNG.\n * been moved into a separate header file that is not accessible to\n * applications.  Read libpng-manual.txt or libpng.3 for more info.\n */\ntypedef struct png_info_def png_info;\ntypedef png_info * png_infop;\ntypedef const png_info * png_const_infop;\ntypedef png_info * * png_infopp;\n\n/* Types with names ending 'p' are pointer types.  The corresponding types with\n * names ending 'rp' are identical pointer types except that the pointer is\n * marked 'restrict', which means that it is the only pointer to the object\n * passed to the function.  Applications should not use the 'restrict' types;\n * it is always valid to pass 'p' to a pointer with a function argument of the\n * corresponding 'rp' type.  Different compilers have different rules with\n * regard to type matching in the presence of 'restrict'.  For backward\n * compatibility libpng callbacks never have 'restrict' in their parameters and,\n * consequentially, writing portable application code is extremely difficult if\n * an attempt is made to use 'restrict'.\n */\ntypedef png_struct * PNG_RESTRICT png_structrp;\ntypedef const png_struct * PNG_RESTRICT png_const_structrp;\ntypedef png_info * PNG_RESTRICT png_inforp;\ntypedef const png_info * PNG_RESTRICT png_const_inforp;\n\n/* Three color definitions.  The order of the red, green, and blue, (and the\n * exact size) is not important, although the size of the fields need to\n * be png_byte or png_uint_16 (as defined below).\n */\ntypedef struct png_color_struct\n{\n   png_byte red;\n   png_byte green;\n   png_byte blue;\n} png_color;\ntypedef png_color * png_colorp;\ntypedef const png_color * png_const_colorp;\ntypedef png_color * * png_colorpp;\n\ntypedef struct png_color_16_struct\n{\n   png_byte index;    /* used for palette files */\n   png_uint_16 red;   /* for use in red green blue files */\n   png_uint_16 green;\n   png_uint_16 blue;\n   png_uint_16 gray;  /* for use in grayscale files */\n} png_color_16;\ntypedef png_color_16 * png_color_16p;\ntypedef const png_color_16 * png_const_color_16p;\ntypedef png_color_16 * * png_color_16pp;\n\ntypedef struct png_color_8_struct\n{\n   png_byte red;   /* for use in red green blue files */\n   png_byte green;\n   png_byte blue;\n   png_byte gray;  /* for use in grayscale files */\n   png_byte alpha; /* for alpha channel files */\n} png_color_8;\ntypedef png_color_8 * png_color_8p;\ntypedef const png_color_8 * png_const_color_8p;\ntypedef png_color_8 * * png_color_8pp;\n\n/*\n * The following two structures are used for the in-core representation\n * of sPLT chunks.\n */\ntypedef struct png_sPLT_entry_struct\n{\n   png_uint_16 red;\n   png_uint_16 green;\n   png_uint_16 blue;\n   png_uint_16 alpha;\n   png_uint_16 frequency;\n} png_sPLT_entry;\ntypedef png_sPLT_entry * png_sPLT_entryp;\ntypedef const png_sPLT_entry * png_const_sPLT_entryp;\ntypedef png_sPLT_entry * * png_sPLT_entrypp;\n\n/*  When the depth of the sPLT palette is 8 bits, the color and alpha samples\n *  occupy the LSB of their respective members, and the MSB of each member\n *  is zero-filled.  The frequency member always occupies the full 16 bits.\n */\n\ntypedef struct png_sPLT_struct\n{\n   png_charp name;           /* palette name */\n   png_byte depth;           /* depth of palette samples */\n   png_sPLT_entryp entries;  /* palette entries */\n   png_int_32 nentries;      /* number of palette entries */\n} png_sPLT_t;\ntypedef png_sPLT_t * png_sPLT_tp;\ntypedef const png_sPLT_t * png_const_sPLT_tp;\ntypedef png_sPLT_t * * png_sPLT_tpp;\n\n#ifdef PNG_TEXT_SUPPORTED\n/* png_text holds the contents of a text/ztxt/itxt chunk in a PNG file,\n * and whether that contents is compressed or not.  The \"key\" field\n * points to a regular zero-terminated C string.  The \"text\" fields can be a\n * regular C string, an empty string, or a NULL pointer.\n * However, the structure returned by png_get_text() will always contain\n * the \"text\" field as a regular zero-terminated C string (possibly\n * empty), never a NULL pointer, so it can be safely used in printf() and\n * other string-handling functions.  Note that the \"itxt_length\", \"lang\", and\n * \"lang_key\" members of the structure only exist when the library is built\n * with iTXt chunk support.  Prior to libpng-1.4.0 the library was built by\n * default without iTXt support. Also note that when iTXt *is* supported,\n * the \"lang\" and \"lang_key\" fields contain NULL pointers when the\n * \"compression\" field contains * PNG_TEXT_COMPRESSION_NONE or\n * PNG_TEXT_COMPRESSION_zTXt. Note that the \"compression value\" is not the\n * same as what appears in the PNG tEXt/zTXt/iTXt chunk's \"compression flag\"\n * which is always 0 or 1, or its \"compression method\" which is always 0.\n */\ntypedef struct png_text_struct\n{\n   int  compression;       /* compression value:\n                             -1: tEXt, none\n                              0: zTXt, deflate\n                              1: iTXt, none\n                              2: iTXt, deflate  */\n   png_charp key;          /* keyword, 1-79 character description of \"text\" */\n   png_charp text;         /* comment, may be an empty string (ie \"\")\n                              or a NULL pointer */\n   png_size_t text_length; /* length of the text string */\n   png_size_t itxt_length; /* length of the itxt string */\n   png_charp lang;         /* language code, 0-79 characters\n                              or a NULL pointer */\n   png_charp lang_key;     /* keyword translated UTF-8 string, 0 or more\n                              chars or a NULL pointer */\n} png_text;\ntypedef png_text * png_textp;\ntypedef const png_text * png_const_textp;\ntypedef png_text * * png_textpp;\n#endif\n\n/* Supported compression types for text in PNG files (tEXt, and zTXt).\n * The values of the PNG_TEXT_COMPRESSION_ defines should NOT be changed. */\n#define PNG_TEXT_COMPRESSION_NONE_WR -3\n#define PNG_TEXT_COMPRESSION_zTXt_WR -2\n#define PNG_TEXT_COMPRESSION_NONE    -1\n#define PNG_TEXT_COMPRESSION_zTXt     0\n#define PNG_ITXT_COMPRESSION_NONE     1\n#define PNG_ITXT_COMPRESSION_zTXt     2\n#define PNG_TEXT_COMPRESSION_LAST     3  /* Not a valid value */\n\n/* png_time is a way to hold the time in an machine independent way.\n * Two conversions are provided, both from time_t and struct tm.  There\n * is no portable way to convert to either of these structures, as far\n * as I know.  If you know of a portable way, send it to me.  As a side\n * note - PNG has always been Year 2000 compliant!\n */\ntypedef struct png_time_struct\n{\n   png_uint_16 year; /* full year, as in, 1995 */\n   png_byte month;   /* month of year, 1 - 12 */\n   png_byte day;     /* day of month, 1 - 31 */\n   png_byte hour;    /* hour of day, 0 - 23 */\n   png_byte minute;  /* minute of hour, 0 - 59 */\n   png_byte second;  /* second of minute, 0 - 60 (for leap seconds) */\n} png_time;\ntypedef png_time * png_timep;\ntypedef const png_time * png_const_timep;\ntypedef png_time * * png_timepp;\n\n#if defined(PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED) ||\\\n   defined(PNG_USER_CHUNKS_SUPPORTED)\n/* png_unknown_chunk is a structure to hold queued chunks for which there is\n * no specific support.  The idea is that we can use this to queue\n * up private chunks for output even though the library doesn't actually\n * know about their semantics.\n *\n * The data in the structure is set by libpng on read and used on write.\n */\ntypedef struct png_unknown_chunk_t\n{\n    png_byte name[5]; /* Textual chunk name with '\\0' terminator */\n    png_byte *data;   /* Data, should not be modified on read! */\n    png_size_t size;\n\n    /* On write 'location' must be set using the flag values listed below.\n     * Notice that on read it is set by libpng however the values stored have\n     * more bits set than are listed below.  Always treat the value as a\n     * bitmask.  On write set only one bit - setting multiple bits may cause the\n     * chunk to be written in multiple places.\n     */\n    png_byte location; /* mode of operation at read time */\n}\npng_unknown_chunk;\n\ntypedef png_unknown_chunk * png_unknown_chunkp;\ntypedef const png_unknown_chunk * png_const_unknown_chunkp;\ntypedef png_unknown_chunk * * png_unknown_chunkpp;\n#endif\n\n/* Flag values for the unknown chunk location byte. */\n#define PNG_HAVE_IHDR  0x01\n#define PNG_HAVE_PLTE  0x02\n#define PNG_AFTER_IDAT 0x08\n\n/* Maximum positive integer used in PNG is (2^31)-1 */\n#define PNG_UINT_31_MAX ((png_uint_32)0x7fffffffL)\n#define PNG_UINT_32_MAX ((png_uint_32)(-1))\n#define PNG_SIZE_MAX ((png_size_t)(-1))\n\n/* These are constants for fixed point values encoded in the\n * PNG specification manner (x100000)\n */\n#define PNG_FP_1    100000\n#define PNG_FP_HALF  50000\n#define PNG_FP_MAX  ((png_fixed_point)0x7fffffffL)\n#define PNG_FP_MIN  (-PNG_FP_MAX)\n\n/* These describe the color_type field in png_info. */\n/* color type masks */\n#define PNG_COLOR_MASK_PALETTE    1\n#define PNG_COLOR_MASK_COLOR      2\n#define PNG_COLOR_MASK_ALPHA      4\n\n/* color types.  Note that not all combinations are legal */\n#define PNG_COLOR_TYPE_GRAY 0\n#define PNG_COLOR_TYPE_PALETTE  (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_PALETTE)\n#define PNG_COLOR_TYPE_RGB        (PNG_COLOR_MASK_COLOR)\n#define PNG_COLOR_TYPE_RGB_ALPHA  (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_ALPHA)\n#define PNG_COLOR_TYPE_GRAY_ALPHA (PNG_COLOR_MASK_ALPHA)\n/* aliases */\n#define PNG_COLOR_TYPE_RGBA  PNG_COLOR_TYPE_RGB_ALPHA\n#define PNG_COLOR_TYPE_GA  PNG_COLOR_TYPE_GRAY_ALPHA\n\n/* This is for compression type. PNG 1.0-1.2 only define the single type. */\n#define PNG_COMPRESSION_TYPE_BASE 0 /* Deflate method 8, 32K window */\n#define PNG_COMPRESSION_TYPE_DEFAULT PNG_COMPRESSION_TYPE_BASE\n\n/* This is for filter type. PNG 1.0-1.2 only define the single type. */\n#define PNG_FILTER_TYPE_BASE      0 /* Single row per-byte filtering */\n#define PNG_INTRAPIXEL_DIFFERENCING 64 /* Used only in MNG datastreams */\n#define PNG_FILTER_TYPE_DEFAULT   PNG_FILTER_TYPE_BASE\n\n/* These are for the interlacing type.  These values should NOT be changed. */\n#define PNG_INTERLACE_NONE        0 /* Non-interlaced image */\n#define PNG_INTERLACE_ADAM7       1 /* Adam7 interlacing */\n#define PNG_INTERLACE_LAST        2 /* Not a valid value */\n\n/* These are for the oFFs chunk.  These values should NOT be changed. */\n#define PNG_OFFSET_PIXEL          0 /* Offset in pixels */\n#define PNG_OFFSET_MICROMETER     1 /* Offset in micrometers (1/10^6 meter) */\n#define PNG_OFFSET_LAST           2 /* Not a valid value */\n\n/* These are for the pCAL chunk.  These values should NOT be changed. */\n#define PNG_EQUATION_LINEAR       0 /* Linear transformation */\n#define PNG_EQUATION_BASE_E       1 /* Exponential base e transform */\n#define PNG_EQUATION_ARBITRARY    2 /* Arbitrary base exponential transform */\n#define PNG_EQUATION_HYPERBOLIC   3 /* Hyperbolic sine transformation */\n#define PNG_EQUATION_LAST         4 /* Not a valid value */\n\n/* These are for the sCAL chunk.  These values should NOT be changed. */\n#define PNG_SCALE_UNKNOWN         0 /* unknown unit (image scale) */\n#define PNG_SCALE_METER           1 /* meters per pixel */\n#define PNG_SCALE_RADIAN          2 /* radians per pixel */\n#define PNG_SCALE_LAST            3 /* Not a valid value */\n\n/* These are for the pHYs chunk.  These values should NOT be changed. */\n#define PNG_RESOLUTION_UNKNOWN    0 /* pixels/unknown unit (aspect ratio) */\n#define PNG_RESOLUTION_METER      1 /* pixels/meter */\n#define PNG_RESOLUTION_LAST       2 /* Not a valid value */\n\n/* These are for the sRGB chunk.  These values should NOT be changed. */\n#define PNG_sRGB_INTENT_PERCEPTUAL 0\n#define PNG_sRGB_INTENT_RELATIVE   1\n#define PNG_sRGB_INTENT_SATURATION 2\n#define PNG_sRGB_INTENT_ABSOLUTE   3\n#define PNG_sRGB_INTENT_LAST       4 /* Not a valid value */\n\n/* This is for text chunks */\n#define PNG_KEYWORD_MAX_LENGTH     79\n\n/* Maximum number of entries in PLTE/sPLT/tRNS arrays */\n#define PNG_MAX_PALETTE_LENGTH    256\n\n/* These determine if an ancillary chunk's data has been successfully read\n * from the PNG header, or if the application has filled in the corresponding\n * data in the info_struct to be written into the output file.  The values\n * of the PNG_INFO_<chunk> defines should NOT be changed.\n */\n#define PNG_INFO_gAMA 0x0001\n#define PNG_INFO_sBIT 0x0002\n#define PNG_INFO_cHRM 0x0004\n#define PNG_INFO_PLTE 0x0008\n#define PNG_INFO_tRNS 0x0010\n#define PNG_INFO_bKGD 0x0020\n#define PNG_INFO_hIST 0x0040\n#define PNG_INFO_pHYs 0x0080\n#define PNG_INFO_oFFs 0x0100\n#define PNG_INFO_tIME 0x0200\n#define PNG_INFO_pCAL 0x0400\n#define PNG_INFO_sRGB 0x0800   /* GR-P, 0.96a */\n#define PNG_INFO_iCCP 0x1000   /* ESR, 1.0.6 */\n#define PNG_INFO_sPLT 0x2000   /* ESR, 1.0.6 */\n#define PNG_INFO_sCAL 0x4000   /* ESR, 1.0.6 */\n#define PNG_INFO_IDAT 0x8000   /* ESR, 1.0.6 */\n\n/* This is used for the transformation routines, as some of them\n * change these values for the row.  It also should enable using\n * the routines for other purposes.\n */\ntypedef struct png_row_info_struct\n{\n   png_uint_32 width;    /* width of row */\n   png_size_t rowbytes;  /* number of bytes in row */\n   png_byte color_type;  /* color type of row */\n   png_byte bit_depth;   /* bit depth of row */\n   png_byte channels;    /* number of channels (1, 2, 3, or 4) */\n   png_byte pixel_depth; /* bits per pixel (depth * channels) */\n} png_row_info;\n\ntypedef png_row_info * png_row_infop;\ntypedef png_row_info * * png_row_infopp;\n\n/* These are the function types for the I/O functions and for the functions\n * that allow the user to override the default I/O functions with his or her\n * own.  The png_error_ptr type should match that of user-supplied warning\n * and error functions, while the png_rw_ptr type should match that of the\n * user read/write data functions.  Note that the 'write' function must not\n * modify the buffer it is passed. The 'read' function, on the other hand, is\n * expected to return the read data in the buffer.\n */\ntypedef PNG_CALLBACK(void, *png_error_ptr, (png_structp, png_const_charp));\ntypedef PNG_CALLBACK(void, *png_rw_ptr, (png_structp, png_bytep, png_size_t));\ntypedef PNG_CALLBACK(void, *png_flush_ptr, (png_structp));\ntypedef PNG_CALLBACK(void, *png_read_status_ptr, (png_structp, png_uint_32,\n    int));\ntypedef PNG_CALLBACK(void, *png_write_status_ptr, (png_structp, png_uint_32,\n    int));\n\n#ifdef PNG_PROGRESSIVE_READ_SUPPORTED\ntypedef PNG_CALLBACK(void, *png_progressive_info_ptr, (png_structp, png_infop));\ntypedef PNG_CALLBACK(void, *png_progressive_end_ptr, (png_structp, png_infop));\n\n/* The following callback receives png_uint_32 row_number, int pass for the\n * png_bytep data of the row.  When transforming an interlaced image the\n * row number is the row number within the sub-image of the interlace pass, so\n * the value will increase to the height of the sub-image (not the full image)\n * then reset to 0 for the next pass.\n *\n * Use PNG_ROW_FROM_PASS_ROW(row, pass) and PNG_COL_FROM_PASS_COL(col, pass) to\n * find the output pixel (x,y) given an interlaced sub-image pixel\n * (row,col,pass).  (See below for these macros.)\n */\ntypedef PNG_CALLBACK(void, *png_progressive_row_ptr, (png_structp, png_bytep,\n    png_uint_32, int));\n#endif\n\n#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \\\n    defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)\ntypedef PNG_CALLBACK(void, *png_user_transform_ptr, (png_structp, png_row_infop,\n    png_bytep));\n#endif\n\n#ifdef PNG_USER_CHUNKS_SUPPORTED\ntypedef PNG_CALLBACK(int, *png_user_chunk_ptr, (png_structp,\n    png_unknown_chunkp));\n#endif\n#ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED\n/* not used anywhere */\n/* typedef PNG_CALLBACK(void, *png_unknown_chunk_ptr, (png_structp)); */\n#endif\n\n#ifdef PNG_SETJMP_SUPPORTED\n/* This must match the function definition in <setjmp.h>, and the application\n * must include this before png.h to obtain the definition of jmp_buf.  The\n * function is required to be PNG_NORETURN, but this is not checked.  If the\n * function does return the application will crash via an abort() or similar\n * system level call.\n *\n * If you get a warning here while building the library you may need to make\n * changes to ensure that pnglibconf.h records the calling convention used by\n * your compiler.  This may be very difficult - try using a different compiler\n * to build the library!\n */\nPNG_FUNCTION(void, (PNGCAPI *png_longjmp_ptr), PNGARG((jmp_buf, int)), typedef);\n#endif\n\n/* Transform masks for the high-level interface */\n#define PNG_TRANSFORM_IDENTITY       0x0000    /* read and write */\n#define PNG_TRANSFORM_STRIP_16       0x0001    /* read only */\n#define PNG_TRANSFORM_STRIP_ALPHA    0x0002    /* read only */\n#define PNG_TRANSFORM_PACKING        0x0004    /* read and write */\n#define PNG_TRANSFORM_PACKSWAP       0x0008    /* read and write */\n#define PNG_TRANSFORM_EXPAND         0x0010    /* read only */\n#define PNG_TRANSFORM_INVERT_MONO    0x0020    /* read and write */\n#define PNG_TRANSFORM_SHIFT          0x0040    /* read and write */\n#define PNG_TRANSFORM_BGR            0x0080    /* read and write */\n#define PNG_TRANSFORM_SWAP_ALPHA     0x0100    /* read and write */\n#define PNG_TRANSFORM_SWAP_ENDIAN    0x0200    /* read and write */\n#define PNG_TRANSFORM_INVERT_ALPHA   0x0400    /* read and write */\n#define PNG_TRANSFORM_STRIP_FILLER   0x0800    /* write only */\n/* Added to libpng-1.2.34 */\n#define PNG_TRANSFORM_STRIP_FILLER_BEFORE PNG_TRANSFORM_STRIP_FILLER\n#define PNG_TRANSFORM_STRIP_FILLER_AFTER 0x1000 /* write only */\n/* Added to libpng-1.4.0 */\n#define PNG_TRANSFORM_GRAY_TO_RGB   0x2000      /* read only */\n/* Added to libpng-1.5.4 */\n#define PNG_TRANSFORM_EXPAND_16     0x4000      /* read only */\n#define PNG_TRANSFORM_SCALE_16      0x8000      /* read only */\n\n/* Flags for MNG supported features */\n#define PNG_FLAG_MNG_EMPTY_PLTE     0x01\n#define PNG_FLAG_MNG_FILTER_64      0x04\n#define PNG_ALL_MNG_FEATURES        0x05\n\n/* NOTE: prior to 1.5 these functions had no 'API' style declaration,\n * this allowed the zlib default functions to be used on Windows\n * platforms.  In 1.5 the zlib default malloc (which just calls malloc and\n * ignores the first argument) should be completely compatible with the\n * following.\n */\ntypedef PNG_CALLBACK(png_voidp, *png_malloc_ptr, (png_structp,\n    png_alloc_size_t));\ntypedef PNG_CALLBACK(void, *png_free_ptr, (png_structp, png_voidp));\n\n/* Section 3: exported functions\n * Here are the function definitions most commonly used.  This is not\n * the place to find out how to use libpng.  See libpng-manual.txt for the\n * full explanation, see example.c for the summary.  This just provides\n * a simple one line description of the use of each function.\n *\n * The PNG_EXPORT() and PNG_EXPORTA() macros used below are defined in\n * pngconf.h and in the *.dfn files in the scripts directory.\n *\n *   PNG_EXPORT(ordinal, type, name, (args));\n *\n *       ordinal:    ordinal that is used while building\n *                   *.def files. The ordinal value is only\n *                   relevant when preprocessing png.h with\n *                   the *.dfn files for building symbol table\n *                   entries, and are removed by pngconf.h.\n *       type:       return type of the function\n *       name:       function name\n *       args:       function arguments, with types\n *\n * When we wish to append attributes to a function prototype we use\n * the PNG_EXPORTA() macro instead.\n *\n *   PNG_EXPORTA(ordinal, type, name, (args), attributes);\n *\n *       ordinal, type, name, and args: same as in PNG_EXPORT().\n *       attributes: function attributes\n */\n\n/* Returns the version number of the library */\nPNG_EXPORT(1, png_uint_32, png_access_version_number, (void));\n\n/* Tell lib we have already handled the first <num_bytes> magic bytes.\n * Handling more than 8 bytes from the beginning of the file is an error.\n */\nPNG_EXPORT(2, void, png_set_sig_bytes, (png_structrp png_ptr, int num_bytes));\n\n/* Check sig[start] through sig[start + num_to_check - 1] to see if it's a\n * PNG file.  Returns zero if the supplied bytes match the 8-byte PNG\n * signature, and non-zero otherwise.  Having num_to_check == 0 or\n * start > 7 will always fail (ie return non-zero).\n */\nPNG_EXPORT(3, int, png_sig_cmp, (png_const_bytep sig, png_size_t start,\n    png_size_t num_to_check));\n\n/* Simple signature checking function.  This is the same as calling\n * png_check_sig(sig, n) := !png_sig_cmp(sig, 0, n).\n */\n#define png_check_sig(sig, n) !png_sig_cmp((sig), 0, (n))\n\n/* Allocate and initialize png_ptr struct for reading, and any other memory. */\nPNG_EXPORTA(4, png_structp, png_create_read_struct,\n    (png_const_charp user_png_ver, png_voidp error_ptr,\n    png_error_ptr error_fn, png_error_ptr warn_fn),\n    PNG_ALLOCATED);\n\n/* Allocate and initialize png_ptr struct for writing, and any other memory */\nPNG_EXPORTA(5, png_structp, png_create_write_struct,\n    (png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn,\n    png_error_ptr warn_fn),\n    PNG_ALLOCATED);\n\nPNG_EXPORT(6, png_size_t, png_get_compression_buffer_size,\n    (png_const_structrp png_ptr));\n\nPNG_EXPORT(7, void, png_set_compression_buffer_size, (png_structrp png_ptr,\n    png_size_t size));\n\n/* Moved from pngconf.h in 1.4.0 and modified to ensure setjmp/longjmp\n * match up.\n */\n#ifdef PNG_SETJMP_SUPPORTED\n/* This function returns the jmp_buf built in to *png_ptr.  It must be\n * supplied with an appropriate 'longjmp' function to use on that jmp_buf\n * unless the default error function is overridden in which case NULL is\n * acceptable.  The size of the jmp_buf is checked against the actual size\n * allocated by the library - the call will return NULL on a mismatch\n * indicating an ABI mismatch.\n */\nPNG_EXPORT(8, jmp_buf*, png_set_longjmp_fn, (png_structrp png_ptr,\n    png_longjmp_ptr longjmp_fn, size_t jmp_buf_size));\n#  define png_jmpbuf(png_ptr) \\\n      (*png_set_longjmp_fn((png_ptr), longjmp, (sizeof (jmp_buf))))\n#else\n#  define png_jmpbuf(png_ptr) \\\n      (LIBPNG_WAS_COMPILED_WITH__PNG_NO_SETJMP)\n#endif\n/* This function should be used by libpng applications in place of\n * longjmp(png_ptr->jmpbuf, val).  If longjmp_fn() has been set, it\n * will use it; otherwise it will call PNG_ABORT().  This function was\n * added in libpng-1.5.0.\n */\nPNG_EXPORTA(9, void, png_longjmp, (png_const_structrp png_ptr, int val),\n    PNG_NORETURN);\n\n#ifdef PNG_READ_SUPPORTED\n/* Reset the compression stream */\nPNG_EXPORTA(10, int, png_reset_zstream, (png_structrp png_ptr), PNG_DEPRECATED);\n#endif\n\n/* New functions added in libpng-1.0.2 (not enabled by default until 1.2.0) */\n#ifdef PNG_USER_MEM_SUPPORTED\nPNG_EXPORTA(11, png_structp, png_create_read_struct_2,\n    (png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn,\n    png_error_ptr warn_fn,\n    png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn),\n    PNG_ALLOCATED);\nPNG_EXPORTA(12, png_structp, png_create_write_struct_2,\n    (png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn,\n    png_error_ptr warn_fn,\n    png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn),\n    PNG_ALLOCATED);\n#endif\n\n/* Write the PNG file signature. */\nPNG_EXPORT(13, void, png_write_sig, (png_structrp png_ptr));\n\n/* Write a PNG chunk - size, type, (optional) data, CRC. */\nPNG_EXPORT(14, void, png_write_chunk, (png_structrp png_ptr, png_const_bytep\n    chunk_name, png_const_bytep data, png_size_t length));\n\n/* Write the start of a PNG chunk - length and chunk name. */\nPNG_EXPORT(15, void, png_write_chunk_start, (png_structrp png_ptr,\n    png_const_bytep chunk_name, png_uint_32 length));\n\n/* Write the data of a PNG chunk started with png_write_chunk_start(). */\nPNG_EXPORT(16, void, png_write_chunk_data, (png_structrp png_ptr,\n    png_const_bytep data, png_size_t length));\n\n/* Finish a chunk started with png_write_chunk_start() (includes CRC). */\nPNG_EXPORT(17, void, png_write_chunk_end, (png_structrp png_ptr));\n\n/* Allocate and initialize the info structure */\nPNG_EXPORTA(18, png_infop, png_create_info_struct, (png_const_structrp png_ptr),\n    PNG_ALLOCATED);\n\n/* DEPRECATED: this function allowed init structures to be created using the\n * default allocation method (typically malloc).  Use is deprecated in 1.6.0 and\n * the API will be removed in the future.\n */\nPNG_EXPORTA(19, void, png_info_init_3, (png_infopp info_ptr,\n    png_size_t png_info_struct_size), PNG_DEPRECATED);\n\n/* Writes all the PNG information before the image. */\nPNG_EXPORT(20, void, png_write_info_before_PLTE,\n    (png_structrp png_ptr, png_const_inforp info_ptr));\nPNG_EXPORT(21, void, png_write_info,\n    (png_structrp png_ptr, png_const_inforp info_ptr));\n\n#ifdef PNG_SEQUENTIAL_READ_SUPPORTED\n/* Read the information before the actual image data. */\nPNG_EXPORT(22, void, png_read_info,\n    (png_structrp png_ptr, png_inforp info_ptr));\n#endif\n\n#ifdef PNG_TIME_RFC1123_SUPPORTED\n   /* Convert to a US string format: there is no localization support in this\n    * routine.  The original implementation used a 29 character buffer in\n    * png_struct, this will be removed in future versions.\n    */\n#if PNG_LIBPNG_VER < 10700\n/* To do: remove this from libpng17 (and from libpng17/png.c and pngstruct.h) */\nPNG_EXPORTA(23, png_const_charp, png_convert_to_rfc1123, (png_structrp png_ptr,\n    png_const_timep ptime),PNG_DEPRECATED);\n#endif\nPNG_EXPORT(241, int, png_convert_to_rfc1123_buffer, (char out[29],\n    png_const_timep ptime));\n#endif\n\n#ifdef PNG_CONVERT_tIME_SUPPORTED\n/* Convert from a struct tm to png_time */\nPNG_EXPORT(24, void, png_convert_from_struct_tm, (png_timep ptime,\n    const struct tm * ttime));\n\n/* Convert from time_t to png_time.  Uses gmtime() */\nPNG_EXPORT(25, void, png_convert_from_time_t, (png_timep ptime, time_t ttime));\n#endif /* PNG_CONVERT_tIME_SUPPORTED */\n\n#ifdef PNG_READ_EXPAND_SUPPORTED\n/* Expand data to 24-bit RGB, or 8-bit grayscale, with alpha if available. */\nPNG_EXPORT(26, void, png_set_expand, (png_structrp png_ptr));\nPNG_EXPORT(27, void, png_set_expand_gray_1_2_4_to_8, (png_structrp png_ptr));\nPNG_EXPORT(28, void, png_set_palette_to_rgb, (png_structrp png_ptr));\nPNG_EXPORT(29, void, png_set_tRNS_to_alpha, (png_structrp png_ptr));\n#endif\n\n#ifdef PNG_READ_EXPAND_16_SUPPORTED\n/* Expand to 16-bit channels, forces conversion of palette to RGB and expansion\n * of a tRNS chunk if present.\n */\nPNG_EXPORT(221, void, png_set_expand_16, (png_structrp png_ptr));\n#endif\n\n#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED)\n/* Use blue, green, red order for pixels. */\nPNG_EXPORT(30, void, png_set_bgr, (png_structrp png_ptr));\n#endif\n\n#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED\n/* Expand the grayscale to 24-bit RGB if necessary. */\nPNG_EXPORT(31, void, png_set_gray_to_rgb, (png_structrp png_ptr));\n#endif\n\n#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED\n/* Reduce RGB to grayscale. */\n#define PNG_ERROR_ACTION_NONE  1\n#define PNG_ERROR_ACTION_WARN  2\n#define PNG_ERROR_ACTION_ERROR 3\n#define PNG_RGB_TO_GRAY_DEFAULT (-1)/*for red/green coefficients*/\n\nPNG_FP_EXPORT(32, void, png_set_rgb_to_gray, (png_structrp png_ptr,\n    int error_action, double red, double green))\nPNG_FIXED_EXPORT(33, void, png_set_rgb_to_gray_fixed, (png_structrp png_ptr,\n    int error_action, png_fixed_point red, png_fixed_point green))\n\nPNG_EXPORT(34, png_byte, png_get_rgb_to_gray_status, (png_const_structrp\n    png_ptr));\n#endif\n\n#ifdef PNG_BUILD_GRAYSCALE_PALETTE_SUPPORTED\nPNG_EXPORT(35, void, png_build_grayscale_palette, (int bit_depth,\n    png_colorp palette));\n#endif\n\n#ifdef PNG_READ_ALPHA_MODE_SUPPORTED\n/* How the alpha channel is interpreted - this affects how the color channels\n * of a PNG file are returned to the calling application when an alpha channel,\n * or a tRNS chunk in a palette file, is present.\n *\n * This has no effect on the way pixels are written into a PNG output\n * datastream. The color samples in a PNG datastream are never premultiplied\n * with the alpha samples.\n *\n * The default is to return data according to the PNG specification: the alpha\n * channel is a linear measure of the contribution of the pixel to the\n * corresponding composited pixel, and the color channels are unassociated\n * (not premultiplied).  The gamma encoded color channels must be scaled\n * according to the contribution and to do this it is necessary to undo\n * the encoding, scale the color values, perform the composition and reencode\n * the values.  This is the 'PNG' mode.\n *\n * The alternative is to 'associate' the alpha with the color information by\n * storing color channel values that have been scaled by the alpha.\n * image.  These are the 'STANDARD', 'ASSOCIATED' or 'PREMULTIPLIED' modes\n * (the latter being the two common names for associated alpha color channels).\n *\n * For the 'OPTIMIZED' mode, a pixel is treated as opaque only if the alpha\n * value is equal to the maximum value.\n *\n * The final choice is to gamma encode the alpha channel as well.  This is\n * broken because, in practice, no implementation that uses this choice\n * correctly undoes the encoding before handling alpha composition.  Use this\n * choice only if other serious errors in the software or hardware you use\n * mandate it; the typical serious error is for dark halos to appear around\n * opaque areas of the composited PNG image because of arithmetic overflow.\n *\n * The API function png_set_alpha_mode specifies which of these choices to use\n * with an enumerated 'mode' value and the gamma of the required output:\n */\n#define PNG_ALPHA_PNG           0 /* according to the PNG standard */\n#define PNG_ALPHA_STANDARD      1 /* according to Porter/Duff */\n#define PNG_ALPHA_ASSOCIATED    1 /* as above; this is the normal practice */\n#define PNG_ALPHA_PREMULTIPLIED 1 /* as above */\n#define PNG_ALPHA_OPTIMIZED     2 /* 'PNG' for opaque pixels, else 'STANDARD' */\n#define PNG_ALPHA_BROKEN        3 /* the alpha channel is gamma encoded */\n\nPNG_FP_EXPORT(227, void, png_set_alpha_mode, (png_structrp png_ptr, int mode,\n    double output_gamma))\nPNG_FIXED_EXPORT(228, void, png_set_alpha_mode_fixed, (png_structrp png_ptr,\n    int mode, png_fixed_point output_gamma))\n#endif\n\n#if defined(PNG_GAMMA_SUPPORTED) || defined(PNG_READ_ALPHA_MODE_SUPPORTED)\n/* The output_gamma value is a screen gamma in libpng terminology: it expresses\n * how to decode the output values, not how they are encoded.\n */\n#define PNG_DEFAULT_sRGB -1       /* sRGB gamma and color space */\n#define PNG_GAMMA_MAC_18 -2       /* Old Mac '1.8' gamma and color space */\n#define PNG_GAMMA_sRGB   220000   /* Television standards--matches sRGB gamma */\n#define PNG_GAMMA_LINEAR PNG_FP_1 /* Linear */\n#endif\n\n/* The following are examples of calls to png_set_alpha_mode to achieve the\n * required overall gamma correction and, where necessary, alpha\n * premultiplication.\n *\n * png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_DEFAULT_sRGB);\n *    This is the default libpng handling of the alpha channel - it is not\n *    pre-multiplied into the color components.  In addition the call states\n *    that the output is for a sRGB system and causes all PNG files without gAMA\n *    chunks to be assumed to be encoded using sRGB.\n *\n * png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_GAMMA_MAC);\n *    In this case the output is assumed to be something like an sRGB conformant\n *    display preceeded by a power-law lookup table of power 1.45.  This is how\n *    early Mac systems behaved.\n *\n * png_set_alpha_mode(pp, PNG_ALPHA_STANDARD, PNG_GAMMA_LINEAR);\n *    This is the classic Jim Blinn approach and will work in academic\n *    environments where everything is done by the book.  It has the shortcoming\n *    of assuming that input PNG data with no gamma information is linear - this\n *    is unlikely to be correct unless the PNG files where generated locally.\n *    Most of the time the output precision will be so low as to show\n *    significant banding in dark areas of the image.\n *\n * png_set_expand_16(pp);\n * png_set_alpha_mode(pp, PNG_ALPHA_STANDARD, PNG_DEFAULT_sRGB);\n *    This is a somewhat more realistic Jim Blinn inspired approach.  PNG files\n *    are assumed to have the sRGB encoding if not marked with a gamma value and\n *    the output is always 16 bits per component.  This permits accurate scaling\n *    and processing of the data.  If you know that your input PNG files were\n *    generated locally you might need to replace PNG_DEFAULT_sRGB with the\n *    correct value for your system.\n *\n * png_set_alpha_mode(pp, PNG_ALPHA_OPTIMIZED, PNG_DEFAULT_sRGB);\n *    If you just need to composite the PNG image onto an existing background\n *    and if you control the code that does this you can use the optimization\n *    setting.  In this case you just copy completely opaque pixels to the\n *    output.  For pixels that are not completely transparent (you just skip\n *    those) you do the composition math using png_composite or png_composite_16\n *    below then encode the resultant 8-bit or 16-bit values to match the output\n *    encoding.\n *\n * Other cases\n *    If neither the PNG nor the standard linear encoding work for you because\n *    of the software or hardware you use then you have a big problem.  The PNG\n *    case will probably result in halos around the image.  The linear encoding\n *    will probably result in a washed out, too bright, image (it's actually too\n *    contrasty.)  Try the ALPHA_OPTIMIZED mode above - this will probably\n *    substantially reduce the halos.  Alternatively try:\n *\n * png_set_alpha_mode(pp, PNG_ALPHA_BROKEN, PNG_DEFAULT_sRGB);\n *    This option will also reduce the halos, but there will be slight dark\n *    halos round the opaque parts of the image where the background is light.\n *    In the OPTIMIZED mode the halos will be light halos where the background\n *    is dark.  Take your pick - the halos are unavoidable unless you can get\n *    your hardware/software fixed!  (The OPTIMIZED approach is slightly\n *    faster.)\n *\n * When the default gamma of PNG files doesn't match the output gamma.\n *    If you have PNG files with no gamma information png_set_alpha_mode allows\n *    you to provide a default gamma, but it also sets the ouput gamma to the\n *    matching value.  If you know your PNG files have a gamma that doesn't\n *    match the output you can take advantage of the fact that\n *    png_set_alpha_mode always sets the output gamma but only sets the PNG\n *    default if it is not already set:\n *\n * png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_DEFAULT_sRGB);\n * png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_GAMMA_MAC);\n *    The first call sets both the default and the output gamma values, the\n *    second call overrides the output gamma without changing the default.  This\n *    is easier than achieving the same effect with png_set_gamma.  You must use\n *    PNG_ALPHA_PNG for the first call - internal checking in png_set_alpha will\n *    fire if more than one call to png_set_alpha_mode and png_set_background is\n *    made in the same read operation, however multiple calls with PNG_ALPHA_PNG\n *    are ignored.\n */\n\n#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED\nPNG_EXPORT(36, void, png_set_strip_alpha, (png_structrp png_ptr));\n#endif\n\n#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) || \\\n    defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED)\nPNG_EXPORT(37, void, png_set_swap_alpha, (png_structrp png_ptr));\n#endif\n\n#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) || \\\n    defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED)\nPNG_EXPORT(38, void, png_set_invert_alpha, (png_structrp png_ptr));\n#endif\n\n#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED)\n/* Add a filler byte to 8-bit Gray or 24-bit RGB images. */\nPNG_EXPORT(39, void, png_set_filler, (png_structrp png_ptr, png_uint_32 filler,\n    int flags));\n/* The values of the PNG_FILLER_ defines should NOT be changed */\n#  define PNG_FILLER_BEFORE 0\n#  define PNG_FILLER_AFTER 1\n/* Add an alpha byte to 8-bit Gray or 24-bit RGB images. */\nPNG_EXPORT(40, void, png_set_add_alpha, (png_structrp png_ptr,\n    png_uint_32 filler, int flags));\n#endif /* PNG_READ_FILLER_SUPPORTED || PNG_WRITE_FILLER_SUPPORTED */\n\n#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED)\n/* Swap bytes in 16-bit depth files. */\nPNG_EXPORT(41, void, png_set_swap, (png_structrp png_ptr));\n#endif\n\n#if defined(PNG_READ_PACK_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED)\n/* Use 1 byte per pixel in 1, 2, or 4-bit depth files. */\nPNG_EXPORT(42, void, png_set_packing, (png_structrp png_ptr));\n#endif\n\n#if defined(PNG_READ_PACKSWAP_SUPPORTED) || \\\n    defined(PNG_WRITE_PACKSWAP_SUPPORTED)\n/* Swap packing order of pixels in bytes. */\nPNG_EXPORT(43, void, png_set_packswap, (png_structrp png_ptr));\n#endif\n\n#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED)\n/* Converts files to legal bit depths. */\nPNG_EXPORT(44, void, png_set_shift, (png_structrp png_ptr, png_const_color_8p\n    true_bits));\n#endif\n\n#if defined(PNG_READ_INTERLACING_SUPPORTED) || \\\n    defined(PNG_WRITE_INTERLACING_SUPPORTED)\n/* Have the code handle the interlacing.  Returns the number of passes.\n * MUST be called before png_read_update_info or png_start_read_image,\n * otherwise it will not have the desired effect.  Note that it is still\n * necessary to call png_read_row or png_read_rows png_get_image_height\n * times for each pass.\n*/\nPNG_EXPORT(45, int, png_set_interlace_handling, (png_structrp png_ptr));\n#endif\n\n#if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED)\n/* Invert monochrome files */\nPNG_EXPORT(46, void, png_set_invert_mono, (png_structrp png_ptr));\n#endif\n\n#ifdef PNG_READ_BACKGROUND_SUPPORTED\n/* Handle alpha and tRNS by replacing with a background color.  Prior to\n * libpng-1.5.4 this API must not be called before the PNG file header has been\n * read.  Doing so will result in unexpected behavior and possible warnings or\n * errors if the PNG file contains a bKGD chunk.\n */\nPNG_FP_EXPORT(47, void, png_set_background, (png_structrp png_ptr,\n    png_const_color_16p background_color, int background_gamma_code,\n    int need_expand, double background_gamma))\nPNG_FIXED_EXPORT(215, void, png_set_background_fixed, (png_structrp png_ptr,\n    png_const_color_16p background_color, int background_gamma_code,\n    int need_expand, png_fixed_point background_gamma))\n#endif\n#ifdef PNG_READ_BACKGROUND_SUPPORTED\n#  define PNG_BACKGROUND_GAMMA_UNKNOWN 0\n#  define PNG_BACKGROUND_GAMMA_SCREEN  1\n#  define PNG_BACKGROUND_GAMMA_FILE    2\n#  define PNG_BACKGROUND_GAMMA_UNIQUE  3\n#endif\n\n#ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED\n/* Scale a 16-bit depth file down to 8-bit, accurately. */\nPNG_EXPORT(229, void, png_set_scale_16, (png_structrp png_ptr));\n#endif\n\n#ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED\n#define PNG_READ_16_TO_8 SUPPORTED /* Name prior to 1.5.4 */\n/* Strip the second byte of information from a 16-bit depth file. */\nPNG_EXPORT(48, void, png_set_strip_16, (png_structrp png_ptr));\n#endif\n\n#ifdef PNG_READ_QUANTIZE_SUPPORTED\n/* Turn on quantizing, and reduce the palette to the number of colors\n * available.\n */\nPNG_EXPORT(49, void, png_set_quantize, (png_structrp png_ptr,\n    png_colorp palette, int num_palette, int maximum_colors,\n    png_const_uint_16p histogram, int full_quantize));\n#endif\n\n#ifdef PNG_READ_GAMMA_SUPPORTED\n/* The threshold on gamma processing is configurable but hard-wired into the\n * library.  The following is the floating point variant.\n */\n#define PNG_GAMMA_THRESHOLD (PNG_GAMMA_THRESHOLD_FIXED*.00001)\n\n/* Handle gamma correction. Screen_gamma=(display_exponent).\n * NOTE: this API simply sets the screen and file gamma values. It will\n * therefore override the value for gamma in a PNG file if it is called after\n * the file header has been read - use with care  - call before reading the PNG\n * file for best results!\n *\n * These routines accept the same gamma values as png_set_alpha_mode (described\n * above).  The PNG_GAMMA_ defines and PNG_DEFAULT_sRGB can be passed to either\n * API (floating point or fixed.)  Notice, however, that the 'file_gamma' value\n * is the inverse of a 'screen gamma' value.\n */\nPNG_FP_EXPORT(50, void, png_set_gamma, (png_structrp png_ptr,\n    double screen_gamma, double override_file_gamma))\nPNG_FIXED_EXPORT(208, void, png_set_gamma_fixed, (png_structrp png_ptr,\n    png_fixed_point screen_gamma, png_fixed_point override_file_gamma))\n#endif\n\n#ifdef PNG_WRITE_FLUSH_SUPPORTED\n/* Set how many lines between output flushes - 0 for no flushing */\nPNG_EXPORT(51, void, png_set_flush, (png_structrp png_ptr, int nrows));\n/* Flush the current PNG output buffer */\nPNG_EXPORT(52, void, png_write_flush, (png_structrp png_ptr));\n#endif\n\n/* Optional update palette with requested transformations */\nPNG_EXPORT(53, void, png_start_read_image, (png_structrp png_ptr));\n\n/* Optional call to update the users info structure */\nPNG_EXPORT(54, void, png_read_update_info, (png_structrp png_ptr,\n    png_inforp info_ptr));\n\n#ifdef PNG_SEQUENTIAL_READ_SUPPORTED\n/* Read one or more rows of image data. */\nPNG_EXPORT(55, void, png_read_rows, (png_structrp png_ptr, png_bytepp row,\n    png_bytepp display_row, png_uint_32 num_rows));\n#endif\n\n#ifdef PNG_SEQUENTIAL_READ_SUPPORTED\n/* Read a row of data. */\nPNG_EXPORT(56, void, png_read_row, (png_structrp png_ptr, png_bytep row,\n    png_bytep display_row));\n#endif\n\n#ifdef PNG_SEQUENTIAL_READ_SUPPORTED\n/* Read the whole image into memory at once. */\nPNG_EXPORT(57, void, png_read_image, (png_structrp png_ptr, png_bytepp image));\n#endif\n\n/* Write a row of image data */\nPNG_EXPORT(58, void, png_write_row, (png_structrp png_ptr,\n    png_const_bytep row));\n\n/* Write a few rows of image data: (*row) is not written; however, the type\n * is declared as writeable to maintain compatibility with previous versions\n * of libpng and to allow the 'display_row' array from read_rows to be passed\n * unchanged to write_rows.\n */\nPNG_EXPORT(59, void, png_write_rows, (png_structrp png_ptr, png_bytepp row,\n    png_uint_32 num_rows));\n\n/* Write the image data */\nPNG_EXPORT(60, void, png_write_image, (png_structrp png_ptr, png_bytepp image));\n\n/* Write the end of the PNG file. */\nPNG_EXPORT(61, void, png_write_end, (png_structrp png_ptr,\n    png_inforp info_ptr));\n\n#ifdef PNG_SEQUENTIAL_READ_SUPPORTED\n/* Read the end of the PNG file. */\nPNG_EXPORT(62, void, png_read_end, (png_structrp png_ptr, png_inforp info_ptr));\n#endif\n\n/* Free any memory associated with the png_info_struct */\nPNG_EXPORT(63, void, png_destroy_info_struct, (png_const_structrp png_ptr,\n    png_infopp info_ptr_ptr));\n\n/* Free any memory associated with the png_struct and the png_info_structs */\nPNG_EXPORT(64, void, png_destroy_read_struct, (png_structpp png_ptr_ptr,\n    png_infopp info_ptr_ptr, png_infopp end_info_ptr_ptr));\n\n/* Free any memory associated with the png_struct and the png_info_structs */\nPNG_EXPORT(65, void, png_destroy_write_struct, (png_structpp png_ptr_ptr,\n    png_infopp info_ptr_ptr));\n\n/* Set the libpng method of handling chunk CRC errors */\nPNG_EXPORT(66, void, png_set_crc_action, (png_structrp png_ptr, int crit_action,\n    int ancil_action));\n\n/* Values for png_set_crc_action() say how to handle CRC errors in\n * ancillary and critical chunks, and whether to use the data contained\n * therein.  Note that it is impossible to \"discard\" data in a critical\n * chunk.  For versions prior to 0.90, the action was always error/quit,\n * whereas in version 0.90 and later, the action for CRC errors in ancillary\n * chunks is warn/discard.  These values should NOT be changed.\n *\n *      value                       action:critical     action:ancillary\n */\n#define PNG_CRC_DEFAULT       0  /* error/quit          warn/discard data */\n#define PNG_CRC_ERROR_QUIT    1  /* error/quit          error/quit        */\n#define PNG_CRC_WARN_DISCARD  2  /* (INVALID)           warn/discard data */\n#define PNG_CRC_WARN_USE      3  /* warn/use data       warn/use data     */\n#define PNG_CRC_QUIET_USE     4  /* quiet/use data      quiet/use data    */\n#define PNG_CRC_NO_CHANGE     5  /* use current value   use current value */\n\n/* These functions give the user control over the scan-line filtering in\n * libpng and the compression methods used by zlib.  These functions are\n * mainly useful for testing, as the defaults should work with most users.\n * Those users who are tight on memory or want faster performance at the\n * expense of compression can modify them.  See the compression library\n * header file (zlib.h) for an explination of the compression functions.\n */\n\n/* Set the filtering method(s) used by libpng.  Currently, the only valid\n * value for \"method\" is 0.\n */\nPNG_EXPORT(67, void, png_set_filter, (png_structrp png_ptr, int method,\n    int filters));\n\n/* Flags for png_set_filter() to say which filters to use.  The flags\n * are chosen so that they don't conflict with real filter types\n * below, in case they are supplied instead of the #defined constants.\n * These values should NOT be changed.\n */\n#define PNG_NO_FILTERS     0x00\n#define PNG_FILTER_NONE    0x08\n#define PNG_FILTER_SUB     0x10\n#define PNG_FILTER_UP      0x20\n#define PNG_FILTER_AVG     0x40\n#define PNG_FILTER_PAETH   0x80\n#define PNG_ALL_FILTERS (PNG_FILTER_NONE | PNG_FILTER_SUB | PNG_FILTER_UP | \\\n                         PNG_FILTER_AVG | PNG_FILTER_PAETH)\n\n/* Filter values (not flags) - used in pngwrite.c, pngwutil.c for now.\n * These defines should NOT be changed.\n */\n#define PNG_FILTER_VALUE_NONE  0\n#define PNG_FILTER_VALUE_SUB   1\n#define PNG_FILTER_VALUE_UP    2\n#define PNG_FILTER_VALUE_AVG   3\n#define PNG_FILTER_VALUE_PAETH 4\n#define PNG_FILTER_VALUE_LAST  5\n\n#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED /* EXPERIMENTAL */\n/* The \"heuristic_method\" is given by one of the PNG_FILTER_HEURISTIC_\n * defines, either the default (minimum-sum-of-absolute-differences), or\n * the experimental method (weighted-minimum-sum-of-absolute-differences).\n *\n * Weights are factors >= 1.0, indicating how important it is to keep the\n * filter type consistent between rows.  Larger numbers mean the current\n * filter is that many times as likely to be the same as the \"num_weights\"\n * previous filters.  This is cumulative for each previous row with a weight.\n * There needs to be \"num_weights\" values in \"filter_weights\", or it can be\n * NULL if the weights aren't being specified.  Weights have no influence on\n * the selection of the first row filter.  Well chosen weights can (in theory)\n * improve the compression for a given image.\n *\n * Costs are factors >= 1.0 indicating the relative decoding costs of a\n * filter type.  Higher costs indicate more decoding expense, and are\n * therefore less likely to be selected over a filter with lower computational\n * costs.  There needs to be a value in \"filter_costs\" for each valid filter\n * type (given by PNG_FILTER_VALUE_LAST), or it can be NULL if you aren't\n * setting the costs.  Costs try to improve the speed of decompression without\n * unduly increasing the compressed image size.\n *\n * A negative weight or cost indicates the default value is to be used, and\n * values in the range [0.0, 1.0) indicate the value is to remain unchanged.\n * The default values for both weights and costs are currently 1.0, but may\n * change if good general weighting/cost heuristics can be found.  If both\n * the weights and costs are set to 1.0, this degenerates the WEIGHTED method\n * to the UNWEIGHTED method, but with added encoding time/computation.\n */\nPNG_FP_EXPORT(68, void, png_set_filter_heuristics, (png_structrp png_ptr,\n    int heuristic_method, int num_weights, png_const_doublep filter_weights,\n    png_const_doublep filter_costs))\nPNG_FIXED_EXPORT(209, void, png_set_filter_heuristics_fixed,\n    (png_structrp png_ptr, int heuristic_method, int num_weights,\n    png_const_fixed_point_p filter_weights,\n    png_const_fixed_point_p filter_costs))\n#endif /*  PNG_WRITE_WEIGHTED_FILTER_SUPPORTED */\n\n/* Heuristic used for row filter selection.  These defines should NOT be\n * changed.\n */\n#define PNG_FILTER_HEURISTIC_DEFAULT    0  /* Currently \"UNWEIGHTED\" */\n#define PNG_FILTER_HEURISTIC_UNWEIGHTED 1  /* Used by libpng < 0.95 */\n#define PNG_FILTER_HEURISTIC_WEIGHTED   2  /* Experimental feature */\n#define PNG_FILTER_HEURISTIC_LAST       3  /* Not a valid value */\n\n#ifdef PNG_WRITE_SUPPORTED\n/* Set the library compression level.  Currently, valid values range from\n * 0 - 9, corresponding directly to the zlib compression levels 0 - 9\n * (0 - no compression, 9 - \"maximal\" compression).  Note that tests have\n * shown that zlib compression levels 3-6 usually perform as well as level 9\n * for PNG images, and do considerably fewer caclulations.  In the future,\n * these values may not correspond directly to the zlib compression levels.\n */\nPNG_EXPORT(69, void, png_set_compression_level, (png_structrp png_ptr,\n    int level));\n\nPNG_EXPORT(70, void, png_set_compression_mem_level, (png_structrp png_ptr,\n    int mem_level));\n\nPNG_EXPORT(71, void, png_set_compression_strategy, (png_structrp png_ptr,\n    int strategy));\n\n/* If PNG_WRITE_OPTIMIZE_CMF_SUPPORTED is defined, libpng will use a\n * smaller value of window_bits if it can do so safely.\n */\nPNG_EXPORT(72, void, png_set_compression_window_bits, (png_structrp png_ptr,\n    int window_bits));\n\nPNG_EXPORT(73, void, png_set_compression_method, (png_structrp png_ptr,\n    int method));\n#endif\n\n#ifdef PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED\n/* Also set zlib parameters for compressing non-IDAT chunks */\nPNG_EXPORT(222, void, png_set_text_compression_level, (png_structrp png_ptr,\n    int level));\n\nPNG_EXPORT(223, void, png_set_text_compression_mem_level, (png_structrp png_ptr,\n    int mem_level));\n\nPNG_EXPORT(224, void, png_set_text_compression_strategy, (png_structrp png_ptr,\n    int strategy));\n\n/* If PNG_WRITE_OPTIMIZE_CMF_SUPPORTED is defined, libpng will use a\n * smaller value of window_bits if it can do so safely.\n */\nPNG_EXPORT(225, void, png_set_text_compression_window_bits,\n    (png_structrp png_ptr, int window_bits));\n\nPNG_EXPORT(226, void, png_set_text_compression_method, (png_structrp png_ptr,\n    int method));\n#endif /* PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED */\n\n/* These next functions are called for input/output, memory, and error\n * handling.  They are in the file pngrio.c, pngwio.c, and pngerror.c,\n * and call standard C I/O routines such as fread(), fwrite(), and\n * fprintf().  These functions can be made to use other I/O routines\n * at run time for those applications that need to handle I/O in a\n * different manner by calling png_set_???_fn().  See libpng-manual.txt for\n * more information.\n */\n\n#ifdef PNG_STDIO_SUPPORTED\n/* Initialize the input/output for the PNG file to the default functions. */\nPNG_EXPORT(74, void, png_init_io, (png_structrp png_ptr, png_FILE_p fp));\n#endif\n\n/* Replace the (error and abort), and warning functions with user\n * supplied functions.  If no messages are to be printed you must still\n * write and use replacement functions. The replacement error_fn should\n * still do a longjmp to the last setjmp location if you are using this\n * method of error handling.  If error_fn or warning_fn is NULL, the\n * default function will be used.\n */\n\nPNG_EXPORT(75, void, png_set_error_fn, (png_structrp png_ptr,\n    png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warning_fn));\n\n/* Return the user pointer associated with the error functions */\nPNG_EXPORT(76, png_voidp, png_get_error_ptr, (png_const_structrp png_ptr));\n\n/* Replace the default data output functions with a user supplied one(s).\n * If buffered output is not used, then output_flush_fn can be set to NULL.\n * If PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng compile time\n * output_flush_fn will be ignored (and thus can be NULL).\n * It is probably a mistake to use NULL for output_flush_fn if\n * write_data_fn is not also NULL unless you have built libpng with\n * PNG_WRITE_FLUSH_SUPPORTED undefined, because in this case libpng's\n * default flush function, which uses the standard *FILE structure, will\n * be used.\n */\nPNG_EXPORT(77, void, png_set_write_fn, (png_structrp png_ptr, png_voidp io_ptr,\n    png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn));\n\n/* Replace the default data input function with a user supplied one. */\nPNG_EXPORT(78, void, png_set_read_fn, (png_structrp png_ptr, png_voidp io_ptr,\n    png_rw_ptr read_data_fn));\n\n/* Return the user pointer associated with the I/O functions */\nPNG_EXPORT(79, png_voidp, png_get_io_ptr, (png_const_structrp png_ptr));\n\nPNG_EXPORT(80, void, png_set_read_status_fn, (png_structrp png_ptr,\n    png_read_status_ptr read_row_fn));\n\nPNG_EXPORT(81, void, png_set_write_status_fn, (png_structrp png_ptr,\n    png_write_status_ptr write_row_fn));\n\n#ifdef PNG_USER_MEM_SUPPORTED\n/* Replace the default memory allocation functions with user supplied one(s). */\nPNG_EXPORT(82, void, png_set_mem_fn, (png_structrp png_ptr, png_voidp mem_ptr,\n    png_malloc_ptr malloc_fn, png_free_ptr free_fn));\n/* Return the user pointer associated with the memory functions */\nPNG_EXPORT(83, png_voidp, png_get_mem_ptr, (png_const_structrp png_ptr));\n#endif\n\n#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED\nPNG_EXPORT(84, void, png_set_read_user_transform_fn, (png_structrp png_ptr,\n    png_user_transform_ptr read_user_transform_fn));\n#endif\n\n#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED\nPNG_EXPORT(85, void, png_set_write_user_transform_fn, (png_structrp png_ptr,\n    png_user_transform_ptr write_user_transform_fn));\n#endif\n\n#ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED\nPNG_EXPORT(86, void, png_set_user_transform_info, (png_structrp png_ptr,\n    png_voidp user_transform_ptr, int user_transform_depth,\n    int user_transform_channels));\n/* Return the user pointer associated with the user transform functions */\nPNG_EXPORT(87, png_voidp, png_get_user_transform_ptr,\n    (png_const_structrp png_ptr));\n#endif\n\n#ifdef PNG_USER_TRANSFORM_INFO_SUPPORTED\n/* Return information about the row currently being processed.  Note that these\n * APIs do not fail but will return unexpected results if called outside a user\n * transform callback.  Also note that when transforming an interlaced image the\n * row number is the row number within the sub-image of the interlace pass, so\n * the value will increase to the height of the sub-image (not the full image)\n * then reset to 0 for the next pass.\n *\n * Use PNG_ROW_FROM_PASS_ROW(row, pass) and PNG_COL_FROM_PASS_COL(col, pass) to\n * find the output pixel (x,y) given an interlaced sub-image pixel\n * (row,col,pass).  (See below for these macros.)\n */\nPNG_EXPORT(217, png_uint_32, png_get_current_row_number, (png_const_structrp));\nPNG_EXPORT(218, png_byte, png_get_current_pass_number, (png_const_structrp));\n#endif\n\n#ifdef PNG_READ_USER_CHUNKS_SUPPORTED\n/* This callback is called only for *unknown* chunks.  If\n * PNG_HANDLE_AS_UNKNOWN_SUPPORTED is set then it is possible to set known\n * chunks to be treated as unknown, however in this case the callback must do\n * any processing required by the chunk (e.g. by calling the appropriate\n * png_set_ APIs.)\n *\n * There is no write support - on write, by default, all the chunks in the\n * 'unknown' list are written in the specified position.\n *\n * The integer return from the callback function is interpreted thus:\n *\n * negative: An error occured, png_chunk_error will be called.\n *     zero: The chunk was not handled, the chunk will be saved. A critical\n *           chunk will cause an error at this point unless it is to be saved.\n * positive: The chunk was handled, libpng will ignore/discard it.\n *\n * See \"INTERACTION WTIH USER CHUNK CALLBACKS\" below for important notes about\n * how this behavior will change in libpng 1.7\n */\nPNG_EXPORT(88, void, png_set_read_user_chunk_fn, (png_structrp png_ptr,\n    png_voidp user_chunk_ptr, png_user_chunk_ptr read_user_chunk_fn));\n#endif\n\n#ifdef PNG_USER_CHUNKS_SUPPORTED\nPNG_EXPORT(89, png_voidp, png_get_user_chunk_ptr, (png_const_structrp png_ptr));\n#endif\n\n#ifdef PNG_PROGRESSIVE_READ_SUPPORTED\n/* Sets the function callbacks for the push reader, and a pointer to a\n * user-defined structure available to the callback functions.\n */\nPNG_EXPORT(90, void, png_set_progressive_read_fn, (png_structrp png_ptr,\n    png_voidp progressive_ptr, png_progressive_info_ptr info_fn,\n    png_progressive_row_ptr row_fn, png_progressive_end_ptr end_fn));\n\n/* Returns the user pointer associated with the push read functions */\nPNG_EXPORT(91, png_voidp, png_get_progressive_ptr,\n    (png_const_structrp png_ptr));\n\n/* Function to be called when data becomes available */\nPNG_EXPORT(92, void, png_process_data, (png_structrp png_ptr,\n    png_inforp info_ptr, png_bytep buffer, png_size_t buffer_size));\n\n/* A function which may be called *only* within png_process_data to stop the\n * processing of any more data.  The function returns the number of bytes\n * remaining, excluding any that libpng has cached internally.  A subsequent\n * call to png_process_data must supply these bytes again.  If the argument\n * 'save' is set to true the routine will first save all the pending data and\n * will always return 0.\n */\nPNG_EXPORT(219, png_size_t, png_process_data_pause, (png_structrp, int save));\n\n/* A function which may be called *only* outside (after) a call to\n * png_process_data.  It returns the number of bytes of data to skip in the\n * input.  Normally it will return 0, but if it returns a non-zero value the\n * application must skip than number of bytes of input data and pass the\n * following data to the next call to png_process_data.\n */\nPNG_EXPORT(220, png_uint_32, png_process_data_skip, (png_structrp));\n\n#ifdef PNG_READ_INTERLACING_SUPPORTED\n/* Function that combines rows.  'new_row' is a flag that should come from\n * the callback and be non-NULL if anything needs to be done; the library\n * stores its own version of the new data internally and ignores the passed\n * in value.\n */\nPNG_EXPORT(93, void, png_progressive_combine_row, (png_const_structrp png_ptr,\n    png_bytep old_row, png_const_bytep new_row));\n#endif /* PNG_READ_INTERLACING_SUPPORTED */\n#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */\n\nPNG_EXPORTA(94, png_voidp, png_malloc, (png_const_structrp png_ptr,\n    png_alloc_size_t size), PNG_ALLOCATED);\n/* Added at libpng version 1.4.0 */\nPNG_EXPORTA(95, png_voidp, png_calloc, (png_const_structrp png_ptr,\n    png_alloc_size_t size), PNG_ALLOCATED);\n\n/* Added at libpng version 1.2.4 */\nPNG_EXPORTA(96, png_voidp, png_malloc_warn, (png_const_structrp png_ptr,\n    png_alloc_size_t size), PNG_ALLOCATED);\n\n/* Frees a pointer allocated by png_malloc() */\nPNG_EXPORT(97, void, png_free, (png_const_structrp png_ptr, png_voidp ptr));\n\n/* Free data that was allocated internally */\nPNG_EXPORT(98, void, png_free_data, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 free_me, int num));\n\n/* Reassign responsibility for freeing existing data, whether allocated\n * by libpng or by the application; this works on the png_info structure passed\n * in, it does not change the state for other png_info structures.\n *\n * It is unlikely that this function works correctly as of 1.6.0 and using it\n * may result either in memory leaks or double free of allocated data.\n */\nPNG_EXPORT(99, void, png_data_freer, (png_const_structrp png_ptr,\n    png_inforp info_ptr, int freer, png_uint_32 mask));\n\n/* Assignments for png_data_freer */\n#define PNG_DESTROY_WILL_FREE_DATA 1\n#define PNG_SET_WILL_FREE_DATA 1\n#define PNG_USER_WILL_FREE_DATA 2\n/* Flags for png_ptr->free_me and info_ptr->free_me */\n#define PNG_FREE_HIST 0x0008\n#define PNG_FREE_ICCP 0x0010\n#define PNG_FREE_SPLT 0x0020\n#define PNG_FREE_ROWS 0x0040\n#define PNG_FREE_PCAL 0x0080\n#define PNG_FREE_SCAL 0x0100\n#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED\n#  define PNG_FREE_UNKN 0x0200\n#endif\n/*      PNG_FREE_LIST 0x0400    removed in 1.6.0 because it is ignored */\n#define PNG_FREE_PLTE 0x1000\n#define PNG_FREE_TRNS 0x2000\n#define PNG_FREE_TEXT 0x4000\n#define PNG_FREE_ALL  0x7fff\n#define PNG_FREE_MUL  0x4220 /* PNG_FREE_SPLT|PNG_FREE_TEXT|PNG_FREE_UNKN */\n\n#ifdef PNG_USER_MEM_SUPPORTED\nPNG_EXPORTA(100, png_voidp, png_malloc_default, (png_const_structrp png_ptr,\n    png_alloc_size_t size), PNG_ALLOCATED PNG_DEPRECATED);\nPNG_EXPORTA(101, void, png_free_default, (png_const_structrp png_ptr,\n    png_voidp ptr), PNG_DEPRECATED);\n#endif\n\n#ifdef PNG_ERROR_TEXT_SUPPORTED\n/* Fatal error in PNG image of libpng - can't continue */\nPNG_EXPORTA(102, void, png_error, (png_const_structrp png_ptr,\n    png_const_charp error_message), PNG_NORETURN);\n\n/* The same, but the chunk name is prepended to the error string. */\nPNG_EXPORTA(103, void, png_chunk_error, (png_const_structrp png_ptr,\n    png_const_charp error_message), PNG_NORETURN);\n\n#else\n/* Fatal error in PNG image of libpng - can't continue */\nPNG_EXPORTA(104, void, png_err, (png_const_structrp png_ptr), PNG_NORETURN);\n#  define png_error(s1,s2) png_err(s1)\n#  define png_chunk_error(s1,s2) png_err(s1)\n#endif\n\n#ifdef PNG_WARNINGS_SUPPORTED\n/* Non-fatal error in libpng.  Can continue, but may have a problem. */\nPNG_EXPORT(105, void, png_warning, (png_const_structrp png_ptr,\n    png_const_charp warning_message));\n\n/* Non-fatal error in libpng, chunk name is prepended to message. */\nPNG_EXPORT(106, void, png_chunk_warning, (png_const_structrp png_ptr,\n    png_const_charp warning_message));\n#else\n#  define png_warning(s1,s2) ((void)(s1))\n#  define png_chunk_warning(s1,s2) ((void)(s1))\n#endif\n\n#ifdef PNG_BENIGN_ERRORS_SUPPORTED\n/* Benign error in libpng.  Can continue, but may have a problem.\n * User can choose whether to handle as a fatal error or as a warning. */\nPNG_EXPORT(107, void, png_benign_error, (png_const_structrp png_ptr,\n    png_const_charp warning_message));\n\n#ifdef PNG_READ_SUPPORTED\n/* Same, chunk name is prepended to message (only during read) */\nPNG_EXPORT(108, void, png_chunk_benign_error, (png_const_structrp png_ptr,\n    png_const_charp warning_message));\n#endif\n\nPNG_EXPORT(109, void, png_set_benign_errors,\n    (png_structrp png_ptr, int allowed));\n#else\n#  ifdef PNG_ALLOW_BENIGN_ERRORS\n#    define png_benign_error png_warning\n#    define png_chunk_benign_error png_chunk_warning\n#  else\n#    define png_benign_error png_error\n#    define png_chunk_benign_error png_chunk_error\n#  endif\n#endif\n\n/* The png_set_<chunk> functions are for storing values in the png_info_struct.\n * Similarly, the png_get_<chunk> calls are used to read values from the\n * png_info_struct, either storing the parameters in the passed variables, or\n * setting pointers into the png_info_struct where the data is stored.  The\n * png_get_<chunk> functions return a non-zero value if the data was available\n * in info_ptr, or return zero and do not change any of the parameters if the\n * data was not available.\n *\n * These functions should be used instead of directly accessing png_info\n * to avoid problems with future changes in the size and internal layout of\n * png_info_struct.\n */\n/* Returns \"flag\" if chunk data is valid in info_ptr. */\nPNG_EXPORT(110, png_uint_32, png_get_valid, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr, png_uint_32 flag));\n\n/* Returns number of bytes needed to hold a transformed row. */\nPNG_EXPORT(111, png_size_t, png_get_rowbytes, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr));\n\n#ifdef PNG_INFO_IMAGE_SUPPORTED\n/* Returns row_pointers, which is an array of pointers to scanlines that was\n * returned from png_read_png().\n */\nPNG_EXPORT(112, png_bytepp, png_get_rows, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr));\n\n/* Set row_pointers, which is an array of pointers to scanlines for use\n * by png_write_png().\n */\nPNG_EXPORT(113, void, png_set_rows, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_bytepp row_pointers));\n#endif\n\n/* Returns number of color channels in image. */\nPNG_EXPORT(114, png_byte, png_get_channels, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr));\n\n#ifdef PNG_EASY_ACCESS_SUPPORTED\n/* Returns image width in pixels. */\nPNG_EXPORT(115, png_uint_32, png_get_image_width, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr));\n\n/* Returns image height in pixels. */\nPNG_EXPORT(116, png_uint_32, png_get_image_height, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr));\n\n/* Returns image bit_depth. */\nPNG_EXPORT(117, png_byte, png_get_bit_depth, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr));\n\n/* Returns image color_type. */\nPNG_EXPORT(118, png_byte, png_get_color_type, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr));\n\n/* Returns image filter_type. */\nPNG_EXPORT(119, png_byte, png_get_filter_type, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr));\n\n/* Returns image interlace_type. */\nPNG_EXPORT(120, png_byte, png_get_interlace_type, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr));\n\n/* Returns image compression_type. */\nPNG_EXPORT(121, png_byte, png_get_compression_type, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr));\n\n/* Returns image resolution in pixels per meter, from pHYs chunk data. */\nPNG_EXPORT(122, png_uint_32, png_get_pixels_per_meter,\n    (png_const_structrp png_ptr, png_const_inforp info_ptr));\nPNG_EXPORT(123, png_uint_32, png_get_x_pixels_per_meter,\n    (png_const_structrp png_ptr, png_const_inforp info_ptr));\nPNG_EXPORT(124, png_uint_32, png_get_y_pixels_per_meter,\n    (png_const_structrp png_ptr, png_const_inforp info_ptr));\n\n/* Returns pixel aspect ratio, computed from pHYs chunk data.  */\nPNG_FP_EXPORT(125, float, png_get_pixel_aspect_ratio,\n    (png_const_structrp png_ptr, png_const_inforp info_ptr))\nPNG_FIXED_EXPORT(210, png_fixed_point, png_get_pixel_aspect_ratio_fixed,\n    (png_const_structrp png_ptr, png_const_inforp info_ptr))\n\n/* Returns image x, y offset in pixels or microns, from oFFs chunk data. */\nPNG_EXPORT(126, png_int_32, png_get_x_offset_pixels,\n    (png_const_structrp png_ptr, png_const_inforp info_ptr));\nPNG_EXPORT(127, png_int_32, png_get_y_offset_pixels,\n    (png_const_structrp png_ptr, png_const_inforp info_ptr));\nPNG_EXPORT(128, png_int_32, png_get_x_offset_microns,\n    (png_const_structrp png_ptr, png_const_inforp info_ptr));\nPNG_EXPORT(129, png_int_32, png_get_y_offset_microns,\n    (png_const_structrp png_ptr, png_const_inforp info_ptr));\n\n#endif /* PNG_EASY_ACCESS_SUPPORTED */\n\n#ifdef PNG_READ_SUPPORTED\n/* Returns pointer to signature string read from PNG header */\nPNG_EXPORT(130, png_const_bytep, png_get_signature, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr));\n#endif\n\n#ifdef PNG_bKGD_SUPPORTED\nPNG_EXPORT(131, png_uint_32, png_get_bKGD, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_color_16p *background));\n#endif\n\n#ifdef PNG_bKGD_SUPPORTED\nPNG_EXPORT(132, void, png_set_bKGD, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_const_color_16p background));\n#endif\n\n#ifdef PNG_cHRM_SUPPORTED\nPNG_FP_EXPORT(133, png_uint_32, png_get_cHRM, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr, double *white_x, double *white_y, double *red_x,\n    double *red_y, double *green_x, double *green_y, double *blue_x,\n    double *blue_y))\nPNG_FP_EXPORT(230, png_uint_32, png_get_cHRM_XYZ, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr, double *red_X, double *red_Y, double *red_Z,\n    double *green_X, double *green_Y, double *green_Z, double *blue_X,\n    double *blue_Y, double *blue_Z))\nPNG_FIXED_EXPORT(134, png_uint_32, png_get_cHRM_fixed,\n    (png_const_structrp png_ptr, png_const_inforp info_ptr,\n    png_fixed_point *int_white_x, png_fixed_point *int_white_y,\n    png_fixed_point *int_red_x, png_fixed_point *int_red_y,\n    png_fixed_point *int_green_x, png_fixed_point *int_green_y,\n    png_fixed_point *int_blue_x, png_fixed_point *int_blue_y))\nPNG_FIXED_EXPORT(231, png_uint_32, png_get_cHRM_XYZ_fixed,\n    (png_const_structrp png_ptr, png_const_inforp info_ptr,\n    png_fixed_point *int_red_X, png_fixed_point *int_red_Y,\n    png_fixed_point *int_red_Z, png_fixed_point *int_green_X,\n    png_fixed_point *int_green_Y, png_fixed_point *int_green_Z,\n    png_fixed_point *int_blue_X, png_fixed_point *int_blue_Y,\n    png_fixed_point *int_blue_Z))\n#endif\n\n#ifdef PNG_cHRM_SUPPORTED\nPNG_FP_EXPORT(135, void, png_set_cHRM, (png_const_structrp png_ptr,\n    png_inforp info_ptr,\n    double white_x, double white_y, double red_x, double red_y, double green_x,\n    double green_y, double blue_x, double blue_y))\nPNG_FP_EXPORT(232, void, png_set_cHRM_XYZ, (png_const_structrp png_ptr,\n    png_inforp info_ptr, double red_X, double red_Y, double red_Z,\n    double green_X, double green_Y, double green_Z, double blue_X,\n    double blue_Y, double blue_Z))\nPNG_FIXED_EXPORT(136, void, png_set_cHRM_fixed, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_fixed_point int_white_x,\n    png_fixed_point int_white_y, png_fixed_point int_red_x,\n    png_fixed_point int_red_y, png_fixed_point int_green_x,\n    png_fixed_point int_green_y, png_fixed_point int_blue_x,\n    png_fixed_point int_blue_y))\nPNG_FIXED_EXPORT(233, void, png_set_cHRM_XYZ_fixed, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_fixed_point int_red_X, png_fixed_point int_red_Y,\n    png_fixed_point int_red_Z, png_fixed_point int_green_X,\n    png_fixed_point int_green_Y, png_fixed_point int_green_Z,\n    png_fixed_point int_blue_X, png_fixed_point int_blue_Y,\n    png_fixed_point int_blue_Z))\n#endif\n\n#ifdef PNG_gAMA_SUPPORTED\nPNG_FP_EXPORT(137, png_uint_32, png_get_gAMA, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr, double *file_gamma))\nPNG_FIXED_EXPORT(138, png_uint_32, png_get_gAMA_fixed,\n    (png_const_structrp png_ptr, png_const_inforp info_ptr,\n    png_fixed_point *int_file_gamma))\n#endif\n\n#ifdef PNG_gAMA_SUPPORTED\nPNG_FP_EXPORT(139, void, png_set_gAMA, (png_const_structrp png_ptr,\n    png_inforp info_ptr, double file_gamma))\nPNG_FIXED_EXPORT(140, void, png_set_gAMA_fixed, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_fixed_point int_file_gamma))\n#endif\n\n#ifdef PNG_hIST_SUPPORTED\nPNG_EXPORT(141, png_uint_32, png_get_hIST, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_uint_16p *hist));\n#endif\n\n#ifdef PNG_hIST_SUPPORTED\nPNG_EXPORT(142, void, png_set_hIST, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_const_uint_16p hist));\n#endif\n\nPNG_EXPORT(143, png_uint_32, png_get_IHDR, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr, png_uint_32 *width, png_uint_32 *height,\n    int *bit_depth, int *color_type, int *interlace_method,\n    int *compression_method, int *filter_method));\n\nPNG_EXPORT(144, void, png_set_IHDR, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 width, png_uint_32 height, int bit_depth,\n    int color_type, int interlace_method, int compression_method,\n    int filter_method));\n\n#ifdef PNG_oFFs_SUPPORTED\nPNG_EXPORT(145, png_uint_32, png_get_oFFs, (png_const_structrp png_ptr,\n   png_const_inforp info_ptr, png_int_32 *offset_x, png_int_32 *offset_y,\n   int *unit_type));\n#endif\n\n#ifdef PNG_oFFs_SUPPORTED\nPNG_EXPORT(146, void, png_set_oFFs, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_int_32 offset_x, png_int_32 offset_y,\n    int unit_type));\n#endif\n\n#ifdef PNG_pCAL_SUPPORTED\nPNG_EXPORT(147, png_uint_32, png_get_pCAL, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_charp *purpose, png_int_32 *X0,\n    png_int_32 *X1, int *type, int *nparams, png_charp *units,\n    png_charpp *params));\n#endif\n\n#ifdef PNG_pCAL_SUPPORTED\nPNG_EXPORT(148, void, png_set_pCAL, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_const_charp purpose, png_int_32 X0, png_int_32 X1,\n    int type, int nparams, png_const_charp units, png_charpp params));\n#endif\n\n#ifdef PNG_pHYs_SUPPORTED\nPNG_EXPORT(149, png_uint_32, png_get_pHYs, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr, png_uint_32 *res_x, png_uint_32 *res_y,\n    int *unit_type));\n#endif\n\n#ifdef PNG_pHYs_SUPPORTED\nPNG_EXPORT(150, void, png_set_pHYs, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 res_x, png_uint_32 res_y, int unit_type));\n#endif\n\nPNG_EXPORT(151, png_uint_32, png_get_PLTE, (png_const_structrp png_ptr,\n   png_inforp info_ptr, png_colorp *palette, int *num_palette));\n\nPNG_EXPORT(152, void, png_set_PLTE, (png_structrp png_ptr,\n    png_inforp info_ptr, png_const_colorp palette, int num_palette));\n\n#ifdef PNG_sBIT_SUPPORTED\nPNG_EXPORT(153, png_uint_32, png_get_sBIT, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_color_8p *sig_bit));\n#endif\n\n#ifdef PNG_sBIT_SUPPORTED\nPNG_EXPORT(154, void, png_set_sBIT, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_const_color_8p sig_bit));\n#endif\n\n#ifdef PNG_sRGB_SUPPORTED\nPNG_EXPORT(155, png_uint_32, png_get_sRGB, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr, int *file_srgb_intent));\n#endif\n\n#ifdef PNG_sRGB_SUPPORTED\nPNG_EXPORT(156, void, png_set_sRGB, (png_const_structrp png_ptr,\n    png_inforp info_ptr, int srgb_intent));\nPNG_EXPORT(157, void, png_set_sRGB_gAMA_and_cHRM, (png_const_structrp png_ptr,\n    png_inforp info_ptr, int srgb_intent));\n#endif\n\n#ifdef PNG_iCCP_SUPPORTED\nPNG_EXPORT(158, png_uint_32, png_get_iCCP, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_charpp name, int *compression_type,\n    png_bytepp profile, png_uint_32 *proflen));\n#endif\n\n#ifdef PNG_iCCP_SUPPORTED\nPNG_EXPORT(159, void, png_set_iCCP, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_const_charp name, int compression_type,\n    png_const_bytep profile, png_uint_32 proflen));\n#endif\n\n#ifdef PNG_sPLT_SUPPORTED\nPNG_EXPORT(160, int, png_get_sPLT, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_sPLT_tpp entries));\n#endif\n\n#ifdef PNG_sPLT_SUPPORTED\nPNG_EXPORT(161, void, png_set_sPLT, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_const_sPLT_tp entries, int nentries));\n#endif\n\n#ifdef PNG_TEXT_SUPPORTED\n/* png_get_text also returns the number of text chunks in *num_text */\nPNG_EXPORT(162, int, png_get_text, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_textp *text_ptr, int *num_text));\n#endif\n\n/* Note while png_set_text() will accept a structure whose text,\n * language, and  translated keywords are NULL pointers, the structure\n * returned by png_get_text will always contain regular\n * zero-terminated C strings.  They might be empty strings but\n * they will never be NULL pointers.\n */\n\n#ifdef PNG_TEXT_SUPPORTED\nPNG_EXPORT(163, void, png_set_text, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_const_textp text_ptr, int num_text));\n#endif\n\n#ifdef PNG_tIME_SUPPORTED\nPNG_EXPORT(164, png_uint_32, png_get_tIME, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_timep *mod_time));\n#endif\n\n#ifdef PNG_tIME_SUPPORTED\nPNG_EXPORT(165, void, png_set_tIME, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_const_timep mod_time));\n#endif\n\n#ifdef PNG_tRNS_SUPPORTED\nPNG_EXPORT(166, png_uint_32, png_get_tRNS, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_bytep *trans_alpha, int *num_trans,\n    png_color_16p *trans_color));\n#endif\n\n#ifdef PNG_tRNS_SUPPORTED\nPNG_EXPORT(167, void, png_set_tRNS, (png_structrp png_ptr,\n    png_inforp info_ptr, png_const_bytep trans_alpha, int num_trans,\n    png_const_color_16p trans_color));\n#endif\n\n#ifdef PNG_sCAL_SUPPORTED\nPNG_FP_EXPORT(168, png_uint_32, png_get_sCAL, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr, int *unit, double *width, double *height))\n#if defined(PNG_FLOATING_ARITHMETIC_SUPPORTED) || \\\n   defined(PNG_FLOATING_POINT_SUPPORTED)\n/* NOTE: this API is currently implemented using floating point arithmetic,\n * consequently it can only be used on systems with floating point support.\n * In any case the range of values supported by png_fixed_point is small and it\n * is highly recommended that png_get_sCAL_s be used instead.\n */\nPNG_FIXED_EXPORT(214, png_uint_32, png_get_sCAL_fixed,\n    (png_const_structrp png_ptr, png_const_inforp info_ptr, int *unit,\n    png_fixed_point *width, png_fixed_point *height))\n#endif\nPNG_EXPORT(169, png_uint_32, png_get_sCAL_s,\n    (png_const_structrp png_ptr, png_const_inforp info_ptr, int *unit,\n    png_charpp swidth, png_charpp sheight));\n\nPNG_FP_EXPORT(170, void, png_set_sCAL, (png_const_structrp png_ptr,\n    png_inforp info_ptr, int unit, double width, double height))\nPNG_FIXED_EXPORT(213, void, png_set_sCAL_fixed, (png_const_structrp png_ptr,\n   png_inforp info_ptr, int unit, png_fixed_point width,\n   png_fixed_point height))\nPNG_EXPORT(171, void, png_set_sCAL_s, (png_const_structrp png_ptr,\n    png_inforp info_ptr, int unit,\n    png_const_charp swidth, png_const_charp sheight));\n#endif /* PNG_sCAL_SUPPORTED */\n\n#ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED\n/* Provide the default handling for all unknown chunks or, optionally, for\n * specific unknown chunks.\n *\n * NOTE: prior to 1.6.0 the handling specified for particular chunks on read was\n * ignored and the default was used, the per-chunk setting only had an effect on\n * write.  If you wish to have chunk-specific handling on read in code that must\n * work on earlier versions you must use a user chunk callback to specify the\n * desired handling (keep or discard.)\n *\n * The 'keep' parameter is a PNG_HANDLE_CHUNK_ value as listed below.  The\n * parameter is interpreted as follows:\n *\n * READ:\n *    PNG_HANDLE_CHUNK_AS_DEFAULT:\n *       Known chunks: do normal libpng processing, do not keep the chunk (but\n *          see the comments below about PNG_HANDLE_AS_UNKNOWN_SUPPORTED)\n *       Unknown chunks: for a specific chunk use the global default, when used\n *          as the default discard the chunk data.\n *    PNG_HANDLE_CHUNK_NEVER:\n *       Discard the chunk data.\n *    PNG_HANDLE_CHUNK_IF_SAFE:\n *       Keep the chunk data if the chunk is not critical else raise a chunk\n *       error.\n *    PNG_HANDLE_CHUNK_ALWAYS:\n *       Keep the chunk data.\n *\n * If the chunk data is saved it can be retrieved using png_get_unknown_chunks,\n * below.  Notice that specifying \"AS_DEFAULT\" as a global default is equivalent\n * to specifying \"NEVER\", however when \"AS_DEFAULT\" is used for specific chunks\n * it simply resets the behavior to the libpng default.\n *\n * INTERACTION WTIH USER CHUNK CALLBACKS:\n * The per-chunk handling is always used when there is a png_user_chunk_ptr\n * callback and the callback returns 0; the chunk is then always stored *unless*\n * it is critical and the per-chunk setting is other than ALWAYS.  Notice that\n * the global default is *not* used in this case.  (In effect the per-chunk\n * value is incremented to at least IF_SAFE.)\n *\n * IMPORTANT NOTE: this behavior will change in libpng 1.7 - the global and\n * per-chunk defaults will be honored.  If you want to preserve the current\n * behavior when your callback returns 0 you must set PNG_HANDLE_CHUNK_IF_SAFE\n * as the default - if you don't do this libpng 1.6 will issue a warning.\n *\n * If you want unhandled unknown chunks to be discarded in libpng 1.6 and\n * earlier simply return '1' (handled).\n *\n * PNG_HANDLE_AS_UNKNOWN_SUPPORTED:\n *    If this is *not* set known chunks will always be handled by libpng and\n *    will never be stored in the unknown chunk list.  Known chunks listed to\n *    png_set_keep_unknown_chunks will have no effect.  If it is set then known\n *    chunks listed with a keep other than AS_DEFAULT will *never* be processed\n *    by libpng, in addition critical chunks must either be processed by the\n *    callback or saved.\n *\n *    The IHDR and IEND chunks must not be listed.  Because this turns off the\n *    default handling for chunks that would otherwise be recognized the\n *    behavior of libpng transformations may well become incorrect!\n *\n * WRITE:\n *    When writing chunks the options only apply to the chunks specified by\n *    png_set_unknown_chunks (below), libpng will *always* write known chunks\n *    required by png_set_ calls and will always write the core critical chunks\n *    (as required for PLTE).\n *\n *    Each chunk in the png_set_unknown_chunks list is looked up in the\n *    png_set_keep_unknown_chunks list to find the keep setting, this is then\n *    interpreted as follows:\n *\n *    PNG_HANDLE_CHUNK_AS_DEFAULT:\n *       Write safe-to-copy chunks and write other chunks if the global\n *       default is set to _ALWAYS, otherwise don't write this chunk.\n *    PNG_HANDLE_CHUNK_NEVER:\n *       Do not write the chunk.\n *    PNG_HANDLE_CHUNK_IF_SAFE:\n *       Write the chunk if it is safe-to-copy, otherwise do not write it.\n *    PNG_HANDLE_CHUNK_ALWAYS:\n *       Write the chunk.\n *\n * Note that the default behavior is effectively the opposite of the read case -\n * in read unknown chunks are not stored by default, in write they are written\n * by default.  Also the behavior of PNG_HANDLE_CHUNK_IF_SAFE is very different\n * - on write the safe-to-copy bit is checked, on read the critical bit is\n * checked and on read if the chunk is critical an error will be raised.\n *\n * num_chunks:\n * ===========\n *    If num_chunks is positive, then the \"keep\" parameter specifies the manner\n *    for handling only those chunks appearing in the chunk_list array,\n *    otherwise the chunk list array is ignored.\n *\n *    If num_chunks is 0 the \"keep\" parameter specifies the default behavior for\n *    unknown chunks, as described above.\n *\n *    If num_chunks is negative, then the \"keep\" parameter specifies the manner\n *    for handling all unknown chunks plus all chunks recognized by libpng\n *    except for the IHDR, PLTE, tRNS, IDAT, and IEND chunks (which continue to\n *    be processed by libpng.\n */\nPNG_EXPORT(172, void, png_set_keep_unknown_chunks, (png_structrp png_ptr,\n    int keep, png_const_bytep chunk_list, int num_chunks));\n\n/* The \"keep\" PNG_HANDLE_CHUNK_ parameter for the specified chunk is returned;\n * the result is therefore true (non-zero) if special handling is required,\n * false for the default handling.\n */\nPNG_EXPORT(173, int, png_handle_as_unknown, (png_const_structrp png_ptr,\n    png_const_bytep chunk_name));\n#endif\n\n#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED\nPNG_EXPORT(174, void, png_set_unknown_chunks, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_const_unknown_chunkp unknowns,\n    int num_unknowns));\n   /* NOTE: prior to 1.6.0 this routine set the 'location' field of the added\n    * unknowns to the location currently stored in the png_struct.  This is\n    * invariably the wrong value on write.  To fix this call the following API\n    * for each chunk in the list with the correct location.  If you know your\n    * code won't be compiled on earlier versions you can rely on\n    * png_set_unknown_chunks(write-ptr, png_get_unknown_chunks(read-ptr)) doing\n    * the correct thing.\n    */\n\nPNG_EXPORT(175, void, png_set_unknown_chunk_location,\n    (png_const_structrp png_ptr, png_inforp info_ptr, int chunk, int location));\n\nPNG_EXPORT(176, int, png_get_unknown_chunks, (png_const_structrp png_ptr,\n    png_inforp info_ptr, png_unknown_chunkpp entries));\n#endif\n\n/* Png_free_data() will turn off the \"valid\" flag for anything it frees.\n * If you need to turn it off for a chunk that your application has freed,\n * you can use png_set_invalid(png_ptr, info_ptr, PNG_INFO_CHNK);\n */\nPNG_EXPORT(177, void, png_set_invalid, (png_const_structrp png_ptr,\n    png_inforp info_ptr, int mask));\n\n#ifdef PNG_INFO_IMAGE_SUPPORTED\n/* The \"params\" pointer is currently not used and is for future expansion. */\n#ifdef PNG_SEQUENTIAL_READ_SUPPORTED\nPNG_EXPORT(178, void, png_read_png, (png_structrp png_ptr, png_inforp info_ptr,\n    int transforms, png_voidp params));\n#endif\n#ifdef PNG_WRITE_SUPPORTED\nPNG_EXPORT(179, void, png_write_png, (png_structrp png_ptr, png_inforp info_ptr,\n    int transforms, png_voidp params));\n#endif\n#endif\n\nPNG_EXPORT(180, png_const_charp, png_get_copyright,\n    (png_const_structrp png_ptr));\nPNG_EXPORT(181, png_const_charp, png_get_header_ver,\n    (png_const_structrp png_ptr));\nPNG_EXPORT(182, png_const_charp, png_get_header_version,\n    (png_const_structrp png_ptr));\nPNG_EXPORT(183, png_const_charp, png_get_libpng_ver,\n    (png_const_structrp png_ptr));\n\n#ifdef PNG_MNG_FEATURES_SUPPORTED\nPNG_EXPORT(184, png_uint_32, png_permit_mng_features, (png_structrp png_ptr,\n    png_uint_32 mng_features_permitted));\n#endif\n\n/* For use in png_set_keep_unknown, added to version 1.2.6 */\n#define PNG_HANDLE_CHUNK_AS_DEFAULT   0\n#define PNG_HANDLE_CHUNK_NEVER        1\n#define PNG_HANDLE_CHUNK_IF_SAFE      2\n#define PNG_HANDLE_CHUNK_ALWAYS       3\n#define PNG_HANDLE_CHUNK_LAST         4\n\n/* Strip the prepended error numbers (\"#nnn \") from error and warning\n * messages before passing them to the error or warning handler.\n */\n#ifdef PNG_ERROR_NUMBERS_SUPPORTED\nPNG_EXPORT(185, void, png_set_strip_error_numbers, (png_structrp png_ptr,\n    png_uint_32 strip_mode));\n#endif\n\n/* Added in libpng-1.2.6 */\n#ifdef PNG_SET_USER_LIMITS_SUPPORTED\nPNG_EXPORT(186, void, png_set_user_limits, (png_structrp png_ptr,\n    png_uint_32 user_width_max, png_uint_32 user_height_max));\nPNG_EXPORT(187, png_uint_32, png_get_user_width_max,\n    (png_const_structrp png_ptr));\nPNG_EXPORT(188, png_uint_32, png_get_user_height_max,\n    (png_const_structrp png_ptr));\n/* Added in libpng-1.4.0 */\nPNG_EXPORT(189, void, png_set_chunk_cache_max, (png_structrp png_ptr,\n    png_uint_32 user_chunk_cache_max));\nPNG_EXPORT(190, png_uint_32, png_get_chunk_cache_max,\n    (png_const_structrp png_ptr));\n/* Added in libpng-1.4.1 */\nPNG_EXPORT(191, void, png_set_chunk_malloc_max, (png_structrp png_ptr,\n    png_alloc_size_t user_chunk_cache_max));\nPNG_EXPORT(192, png_alloc_size_t, png_get_chunk_malloc_max,\n    (png_const_structrp png_ptr));\n#endif\n\n#if defined(PNG_INCH_CONVERSIONS_SUPPORTED)\nPNG_EXPORT(193, png_uint_32, png_get_pixels_per_inch,\n    (png_const_structrp png_ptr, png_const_inforp info_ptr));\n\nPNG_EXPORT(194, png_uint_32, png_get_x_pixels_per_inch,\n    (png_const_structrp png_ptr, png_const_inforp info_ptr));\n\nPNG_EXPORT(195, png_uint_32, png_get_y_pixels_per_inch,\n    (png_const_structrp png_ptr, png_const_inforp info_ptr));\n\nPNG_FP_EXPORT(196, float, png_get_x_offset_inches,\n    (png_const_structrp png_ptr, png_const_inforp info_ptr))\n#ifdef PNG_FIXED_POINT_SUPPORTED /* otherwise not implemented. */\nPNG_FIXED_EXPORT(211, png_fixed_point, png_get_x_offset_inches_fixed,\n    (png_const_structrp png_ptr, png_const_inforp info_ptr))\n#endif\n\nPNG_FP_EXPORT(197, float, png_get_y_offset_inches, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr))\n#ifdef PNG_FIXED_POINT_SUPPORTED /* otherwise not implemented. */\nPNG_FIXED_EXPORT(212, png_fixed_point, png_get_y_offset_inches_fixed,\n    (png_const_structrp png_ptr, png_const_inforp info_ptr))\n#endif\n\n#  ifdef PNG_pHYs_SUPPORTED\nPNG_EXPORT(198, png_uint_32, png_get_pHYs_dpi, (png_const_structrp png_ptr,\n    png_const_inforp info_ptr, png_uint_32 *res_x, png_uint_32 *res_y,\n    int *unit_type));\n#  endif /* PNG_pHYs_SUPPORTED */\n#endif  /* PNG_INCH_CONVERSIONS_SUPPORTED */\n\n/* Added in libpng-1.4.0 */\n#ifdef PNG_IO_STATE_SUPPORTED\nPNG_EXPORT(199, png_uint_32, png_get_io_state, (png_const_structrp png_ptr));\n\n/* Removed from libpng 1.6; use png_get_io_chunk_type. */\nPNG_REMOVED(200, png_const_bytep, png_get_io_chunk_name, (png_structrp png_ptr),\n    PNG_DEPRECATED)\n\nPNG_EXPORT(216, png_uint_32, png_get_io_chunk_type,\n    (png_const_structrp png_ptr));\n\n/* The flags returned by png_get_io_state() are the following: */\n#  define PNG_IO_NONE        0x0000   /* no I/O at this moment */\n#  define PNG_IO_READING     0x0001   /* currently reading */\n#  define PNG_IO_WRITING     0x0002   /* currently writing */\n#  define PNG_IO_SIGNATURE   0x0010   /* currently at the file signature */\n#  define PNG_IO_CHUNK_HDR   0x0020   /* currently at the chunk header */\n#  define PNG_IO_CHUNK_DATA  0x0040   /* currently at the chunk data */\n#  define PNG_IO_CHUNK_CRC   0x0080   /* currently at the chunk crc */\n#  define PNG_IO_MASK_OP     0x000f   /* current operation: reading/writing */\n#  define PNG_IO_MASK_LOC    0x00f0   /* current location: sig/hdr/data/crc */\n#endif /* ?PNG_IO_STATE_SUPPORTED */\n\n/* Interlace support.  The following macros are always defined so that if\n * libpng interlace handling is turned off the macros may be used to handle\n * interlaced images within the application.\n */\n#define PNG_INTERLACE_ADAM7_PASSES 7\n\n/* Two macros to return the first row and first column of the original,\n * full, image which appears in a given pass.  'pass' is in the range 0\n * to 6 and the result is in the range 0 to 7.\n */\n#define PNG_PASS_START_ROW(pass) (((1&~(pass))<<(3-((pass)>>1)))&7)\n#define PNG_PASS_START_COL(pass) (((1& (pass))<<(3-(((pass)+1)>>1)))&7)\n\n/* A macro to return the offset between pixels in the output row for a pair of\n * pixels in the input - effectively the inverse of the 'COL_SHIFT' macro that\n * follows.  Note that ROW_OFFSET is the offset from one row to the next whereas\n * COL_OFFSET is from one column to the next, within a row.\n */\n#define PNG_PASS_ROW_OFFSET(pass) ((pass)>2?(8>>(((pass)-1)>>1)):8)\n#define PNG_PASS_COL_OFFSET(pass) (1<<((7-(pass))>>1))\n\n/* Two macros to help evaluate the number of rows or columns in each\n * pass.  This is expressed as a shift - effectively log2 of the number or\n * rows or columns in each 8x8 tile of the original image.\n */\n#define PNG_PASS_ROW_SHIFT(pass) ((pass)>2?(8-(pass))>>1:3)\n#define PNG_PASS_COL_SHIFT(pass) ((pass)>1?(7-(pass))>>1:3)\n\n/* Hence two macros to determine the number of rows or columns in a given\n * pass of an image given its height or width.  In fact these macros may\n * return non-zero even though the sub-image is empty, because the other\n * dimension may be empty for a small image.\n */\n#define PNG_PASS_ROWS(height, pass) (((height)+(((1<<PNG_PASS_ROW_SHIFT(pass))\\\n   -1)-PNG_PASS_START_ROW(pass)))>>PNG_PASS_ROW_SHIFT(pass))\n#define PNG_PASS_COLS(width, pass) (((width)+(((1<<PNG_PASS_COL_SHIFT(pass))\\\n   -1)-PNG_PASS_START_COL(pass)))>>PNG_PASS_COL_SHIFT(pass))\n\n/* For the reader row callbacks (both progressive and sequential) it is\n * necessary to find the row in the output image given a row in an interlaced\n * image, so two more macros:\n */\n#define PNG_ROW_FROM_PASS_ROW(y_in, pass) \\\n   (((y_in)<<PNG_PASS_ROW_SHIFT(pass))+PNG_PASS_START_ROW(pass))\n#define PNG_COL_FROM_PASS_COL(x_in, pass) \\\n   (((x_in)<<PNG_PASS_COL_SHIFT(pass))+PNG_PASS_START_COL(pass))\n\n/* Two macros which return a boolean (0 or 1) saying whether the given row\n * or column is in a particular pass.  These use a common utility macro that\n * returns a mask for a given pass - the offset 'off' selects the row or\n * column version.  The mask has the appropriate bit set for each column in\n * the tile.\n */\n#define PNG_PASS_MASK(pass,off) ( \\\n   ((0x110145AF>>(((7-(off))-(pass))<<2)) & 0xF) | \\\n   ((0x01145AF0>>(((7-(off))-(pass))<<2)) & 0xF0))\n\n#define PNG_ROW_IN_INTERLACE_PASS(y, pass) \\\n   ((PNG_PASS_MASK(pass,0) >> ((y)&7)) & 1)\n#define PNG_COL_IN_INTERLACE_PASS(x, pass) \\\n   ((PNG_PASS_MASK(pass,1) >> ((x)&7)) & 1)\n\n#ifdef PNG_READ_COMPOSITE_NODIV_SUPPORTED\n/* With these routines we avoid an integer divide, which will be slower on\n * most machines.  However, it does take more operations than the corresponding\n * divide method, so it may be slower on a few RISC systems.  There are two\n * shifts (by 8 or 16 bits) and an addition, versus a single integer divide.\n *\n * Note that the rounding factors are NOT supposed to be the same!  128 and\n * 32768 are correct for the NODIV code; 127 and 32767 are correct for the\n * standard method.\n *\n * [Optimized code by Greg Roelofs and Mark Adler...blame us for bugs. :-) ]\n */\n\n /* fg and bg should be in `gamma 1.0' space; alpha is the opacity */\n\n#  define png_composite(composite, fg, alpha, bg)         \\\n     { png_uint_16 temp = (png_uint_16)((png_uint_16)(fg) \\\n           * (png_uint_16)(alpha)                         \\\n           + (png_uint_16)(bg)*(png_uint_16)(255          \\\n           - (png_uint_16)(alpha)) + 128);                \\\n       (composite) = (png_byte)((temp + (temp >> 8)) >> 8); }\n\n#  define png_composite_16(composite, fg, alpha, bg)       \\\n     { png_uint_32 temp = (png_uint_32)((png_uint_32)(fg)  \\\n           * (png_uint_32)(alpha)                          \\\n           + (png_uint_32)(bg)*(65535                      \\\n           - (png_uint_32)(alpha)) + 32768);               \\\n       (composite) = (png_uint_16)((temp + (temp >> 16)) >> 16); }\n\n#else  /* Standard method using integer division */\n\n#  define png_composite(composite, fg, alpha, bg)                          \\\n     (composite) = (png_byte)(((png_uint_16)(fg) * (png_uint_16)(alpha) +  \\\n     (png_uint_16)(bg) * (png_uint_16)(255 - (png_uint_16)(alpha)) +       \\\n     127) / 255)\n\n#  define png_composite_16(composite, fg, alpha, bg)                         \\\n     (composite) = (png_uint_16)(((png_uint_32)(fg) * (png_uint_32)(alpha) + \\\n     (png_uint_32)(bg)*(png_uint_32)(65535 - (png_uint_32)(alpha)) +         \\\n     32767) / 65535)\n#endif /* PNG_READ_COMPOSITE_NODIV_SUPPORTED */\n\n#ifdef PNG_READ_INT_FUNCTIONS_SUPPORTED\nPNG_EXPORT(201, png_uint_32, png_get_uint_32, (png_const_bytep buf));\nPNG_EXPORT(202, png_uint_16, png_get_uint_16, (png_const_bytep buf));\nPNG_EXPORT(203, png_int_32, png_get_int_32, (png_const_bytep buf));\n#endif\n\nPNG_EXPORT(204, png_uint_32, png_get_uint_31, (png_const_structrp png_ptr,\n    png_const_bytep buf));\n/* No png_get_int_16 -- may be added if there's a real need for it. */\n\n/* Place a 32-bit number into a buffer in PNG byte order (big-endian). */\n#ifdef PNG_WRITE_INT_FUNCTIONS_SUPPORTED\nPNG_EXPORT(205, void, png_save_uint_32, (png_bytep buf, png_uint_32 i));\n#endif\n#ifdef PNG_SAVE_INT_32_SUPPORTED\nPNG_EXPORT(206, void, png_save_int_32, (png_bytep buf, png_int_32 i));\n#endif\n\n/* Place a 16-bit number into a buffer in PNG byte order.\n * The parameter is declared unsigned int, not png_uint_16,\n * just to avoid potential problems on pre-ANSI C compilers.\n */\n#ifdef PNG_WRITE_INT_FUNCTIONS_SUPPORTED\nPNG_EXPORT(207, void, png_save_uint_16, (png_bytep buf, unsigned int i));\n/* No png_save_int_16 -- may be added if there's a real need for it. */\n#endif\n\n#ifdef PNG_USE_READ_MACROS\n/* Inline macros to do direct reads of bytes from the input buffer.\n * The png_get_int_32() routine assumes we are using two's complement\n * format for negative values, which is almost certainly true.\n */\n#  define PNG_get_uint_32(buf) \\\n     (((png_uint_32)(*(buf)) << 24) + \\\n      ((png_uint_32)(*((buf) + 1)) << 16) + \\\n      ((png_uint_32)(*((buf) + 2)) << 8) + \\\n      ((png_uint_32)(*((buf) + 3))))\n\n   /* From libpng-1.4.0 until 1.4.4, the png_get_uint_16 macro (but not the\n    * function) incorrectly returned a value of type png_uint_32.\n    */\n#  define PNG_get_uint_16(buf) \\\n     ((png_uint_16) \\\n      (((unsigned int)(*(buf)) << 8) + \\\n       ((unsigned int)(*((buf) + 1)))))\n\n#  define PNG_get_int_32(buf) \\\n     ((png_int_32)((*(buf) & 0x80) \\\n      ? -((png_int_32)((png_get_uint_32(buf) ^ 0xffffffffL) + 1)) \\\n      : (png_int_32)png_get_uint_32(buf)))\n\n   /* If PNG_PREFIX is defined the same thing as below happens in pnglibconf.h,\n    * but defining a macro name prefixed with PNG_PREFIX.\n    */\n#  ifndef PNG_PREFIX\n#     define png_get_uint_32(buf) PNG_get_uint_32(buf)\n#     define png_get_uint_16(buf) PNG_get_uint_16(buf)\n#     define png_get_int_32(buf)  PNG_get_int_32(buf)\n#  endif\n#else\n#  ifdef PNG_PREFIX\n      /* No macros; revert to the (redefined) function */\n#     define PNG_get_uint_32 (png_get_uint_32)\n#     define PNG_get_uint_16 (png_get_uint_16)\n#     define PNG_get_int_32  (png_get_int_32)\n#  endif\n#endif\n\n/*******************************************************************************\n *  SIMPLIFIED API\n *******************************************************************************\n *\n * Please read the documentation in libpng-manual.txt (TODO: write said\n * documentation) if you don't understand what follows.\n *\n * The simplified API hides the details of both libpng and the PNG file format\n * itself.  It allows PNG files to be read into a very limited number of\n * in-memory bitmap formats or to be written from the same formats.  If these\n * formats do not accomodate your needs then you can, and should, use the more\n * sophisticated APIs above - these support a wide variety of in-memory formats\n * and a wide variety of sophisticated transformations to those formats as well\n * as a wide variety of APIs to manipulate ancillary information.\n *\n * To read a PNG file using the simplified API:\n *\n * 1) Declare a 'png_image' structure (see below) on the stack and set the\n *    version field to PNG_IMAGE_VERSION.\n * 2) Call the appropriate png_image_begin_read... function.\n * 3) Set the png_image 'format' member to the required sample format.\n * 4) Allocate a buffer for the image and, if required, the color-map.\n * 5) Call png_image_finish_read to read the image and, if required, the\n *    color-map into your buffers.\n *\n * There are no restrictions on the format of the PNG input itself; all valid\n * color types, bit depths, and interlace methods are acceptable, and the\n * input image is transformed as necessary to the requested in-memory format\n * during the png_image_finish_read() step.  The only caveat is that if you\n * request a color-mapped image from a PNG that is full-color or makes\n * complex use of an alpha channel the transformation is extremely lossy and the\n * result may look terrible.\n *\n * To write a PNG file using the simplified API:\n *\n * 1) Declare a 'png_image' structure on the stack and memset() it to all zero.\n * 2) Initialize the members of the structure that describe the image, setting\n *    the 'format' member to the format of the image samples.\n * 3) Call the appropriate png_image_write... function with a pointer to the\n *    image and, if necessary, the color-map to write the PNG data.\n *\n * png_image is a structure that describes the in-memory format of an image\n * when it is being read or defines the in-memory format of an image that you\n * need to write:\n */\n#define PNG_IMAGE_VERSION 1\n\ntypedef struct png_control *png_controlp;\ntypedef struct\n{\n   png_controlp opaque;    /* Initialize to NULL, free with png_image_free */\n   png_uint_32  version;   /* Set to PNG_IMAGE_VERSION */\n   png_uint_32  width;     /* Image width in pixels (columns) */\n   png_uint_32  height;    /* Image height in pixels (rows) */\n   png_uint_32  format;    /* Image format as defined below */\n   png_uint_32  flags;     /* A bit mask containing informational flags */\n   png_uint_32  colormap_entries;\n                           /* Number of entries in the color-map */\n\n   /* In the event of an error or warning the following field will be set to a\n    * non-zero value and the 'message' field will contain a '\\0' terminated\n    * string with the libpng error or warning message.  If both warnings and\n    * an error were encountered, only the error is recorded.  If there\n    * are multiple warnings, only the first one is recorded.\n    *\n    * The upper 30 bits of this value are reserved, the low two bits contain\n    * a value as follows:\n    */\n#  define PNG_IMAGE_WARNING 1\n#  define PNG_IMAGE_ERROR 2\n   /*\n    * The result is a two bit code such that a value more than 1 indicates\n    * a failure in the API just called:\n    *\n    *    0 - no warning or error\n    *    1 - warning\n    *    2 - error\n    *    3 - error preceded by warning\n    */\n#  define PNG_IMAGE_FAILED(png_cntrl) ((((png_cntrl).warning_or_error)&0x03)>1)\n\n   png_uint_32  warning_or_error;\n\n   char         message[64];\n} png_image, *png_imagep;\n\n/* The samples of the image have one to four channels whose components have\n * original values in the range 0 to 1.0:\n *\n * 1: A single gray or luminance channel (G).\n * 2: A gray/luminance channel and an alpha channel (GA).\n * 3: Three red, green, blue color channels (RGB).\n * 4: Three color channels and an alpha channel (RGBA).\n *\n * The components are encoded in one of two ways:\n *\n * a) As a small integer, value 0..255, contained in a single byte.  For the\n * alpha channel the original value is simply value/255.  For the color or\n * luminance channels the value is encoded according to the sRGB specification\n * and matches the 8-bit format expected by typical display devices.\n *\n * The color/gray channels are not scaled (pre-multiplied) by the alpha\n * channel and are suitable for passing to color management software.\n *\n * b) As a value in the range 0..65535, contained in a 2-byte integer.  All\n * channels can be converted to the original value by dividing by 65535; all\n * channels are linear.  Color channels use the RGB encoding (RGB end-points) of\n * the sRGB specification.  This encoding is identified by the\n * PNG_FORMAT_FLAG_LINEAR flag below.\n *\n * When the simplified API needs to convert between sRGB and linear colorspaces,\n * the actual sRGB transfer curve defined in the sRGB specification (see the\n * article at http://en.wikipedia.org/wiki/SRGB) is used, not the gamma=1/2.2\n * approximation used elsewhere in libpng.\n *\n * When an alpha channel is present it is expected to denote pixel coverage\n * of the color or luminance channels and is returned as an associated alpha\n * channel: the color/gray channels are scaled (pre-multiplied) by the alpha\n * value.\n *\n * The samples are either contained directly in the image data, between 1 and 8\n * bytes per pixel according to the encoding, or are held in a color-map indexed\n * by bytes in the image data.  In the case of a color-map the color-map entries\n * are individual samples, encoded as above, and the image data has one byte per\n * pixel to select the relevant sample from the color-map.\n */\n\n/* PNG_FORMAT_*\n *\n * #defines to be used in png_image::format.  Each #define identifies a\n * particular layout of sample data and, if present, alpha values.  There are\n * separate defines for each of the two component encodings.\n *\n * A format is built up using single bit flag values.  All combinations are\n * valid.  Formats can be built up from the flag values or you can use one of\n * the predefined values below.  When testing formats always use the FORMAT_FLAG\n * macros to test for individual features - future versions of the library may\n * add new flags.\n *\n * When reading or writing color-mapped images the format should be set to the\n * format of the entries in the color-map then png_image_{read,write}_colormap\n * called to read or write the color-map and set the format correctly for the\n * image data.  Do not set the PNG_FORMAT_FLAG_COLORMAP bit directly!\n *\n * NOTE: libpng can be built with particular features disabled, if you see\n * compiler errors because the definition of one of the following flags has been\n * compiled out it is because libpng does not have the required support.  It is\n * possible, however, for the libpng configuration to enable the format on just\n * read or just write; in that case you may see an error at run time.  You can\n * guard against this by checking for the definition of the appropriate\n * \"_SUPPORTED\" macro, one of:\n *\n *    PNG_SIMPLIFIED_{READ,WRITE}_{BGR,AFIRST}_SUPPORTED\n */\n#define PNG_FORMAT_FLAG_ALPHA    0x01U /* format with an alpha channel */\n#define PNG_FORMAT_FLAG_COLOR    0x02U /* color format: otherwise grayscale */\n#define PNG_FORMAT_FLAG_LINEAR   0x04U /* 2 byte channels else 1 byte */\n#define PNG_FORMAT_FLAG_COLORMAP 0x08U /* image data is color-mapped */\n\n#ifdef PNG_FORMAT_BGR_SUPPORTED\n#  define PNG_FORMAT_FLAG_BGR    0x10U /* BGR colors, else order is RGB */\n#endif\n\n#ifdef PNG_FORMAT_AFIRST_SUPPORTED\n#  define PNG_FORMAT_FLAG_AFIRST 0x20U /* alpha channel comes first */\n#endif\n\n/* Commonly used formats have predefined macros.\n *\n * First the single byte (sRGB) formats:\n */\n#define PNG_FORMAT_GRAY 0\n#define PNG_FORMAT_GA   PNG_FORMAT_FLAG_ALPHA\n#define PNG_FORMAT_AG   (PNG_FORMAT_GA|PNG_FORMAT_FLAG_AFIRST)\n#define PNG_FORMAT_RGB  PNG_FORMAT_FLAG_COLOR\n#define PNG_FORMAT_BGR  (PNG_FORMAT_FLAG_COLOR|PNG_FORMAT_FLAG_BGR)\n#define PNG_FORMAT_RGBA (PNG_FORMAT_RGB|PNG_FORMAT_FLAG_ALPHA)\n#define PNG_FORMAT_ARGB (PNG_FORMAT_RGBA|PNG_FORMAT_FLAG_AFIRST)\n#define PNG_FORMAT_BGRA (PNG_FORMAT_BGR|PNG_FORMAT_FLAG_ALPHA)\n#define PNG_FORMAT_ABGR (PNG_FORMAT_BGRA|PNG_FORMAT_FLAG_AFIRST)\n\n/* Then the linear 2-byte formats.  When naming these \"Y\" is used to\n * indicate a luminance (gray) channel.\n */\n#define PNG_FORMAT_LINEAR_Y PNG_FORMAT_FLAG_LINEAR\n#define PNG_FORMAT_LINEAR_Y_ALPHA (PNG_FORMAT_FLAG_LINEAR|PNG_FORMAT_FLAG_ALPHA)\n#define PNG_FORMAT_LINEAR_RGB (PNG_FORMAT_FLAG_LINEAR|PNG_FORMAT_FLAG_COLOR)\n#define PNG_FORMAT_LINEAR_RGB_ALPHA \\\n   (PNG_FORMAT_FLAG_LINEAR|PNG_FORMAT_FLAG_COLOR|PNG_FORMAT_FLAG_ALPHA)\n\n/* With color-mapped formats the image data is one byte for each pixel, the byte\n * is an index into the color-map which is formatted as above.  To obtain a\n * color-mapped format it is sufficient just to add the PNG_FOMAT_FLAG_COLORMAP\n * to one of the above definitions, or you can use one of the definitions below.\n */\n#define PNG_FORMAT_RGB_COLORMAP  (PNG_FORMAT_RGB|PNG_FORMAT_FLAG_COLORMAP)\n#define PNG_FORMAT_BGR_COLORMAP  (PNG_FORMAT_BGR|PNG_FORMAT_FLAG_COLORMAP)\n#define PNG_FORMAT_RGBA_COLORMAP (PNG_FORMAT_RGBA|PNG_FORMAT_FLAG_COLORMAP)\n#define PNG_FORMAT_ARGB_COLORMAP (PNG_FORMAT_ARGB|PNG_FORMAT_FLAG_COLORMAP)\n#define PNG_FORMAT_BGRA_COLORMAP (PNG_FORMAT_BGRA|PNG_FORMAT_FLAG_COLORMAP)\n#define PNG_FORMAT_ABGR_COLORMAP (PNG_FORMAT_ABGR|PNG_FORMAT_FLAG_COLORMAP)\n\n/* PNG_IMAGE macros\n *\n * These are convenience macros to derive information from a png_image\n * structure.  The PNG_IMAGE_SAMPLE_ macros return values appropriate to the\n * actual image sample values - either the entries in the color-map or the\n * pixels in the image.  The PNG_IMAGE_PIXEL_ macros return corresponding values\n * for the pixels and will always return 1 for color-mapped formats.  The\n * remaining macros return information about the rows in the image and the\n * complete image.\n *\n * NOTE: All the macros that take a png_image::format parameter are compile time\n * constants if the format parameter is, itself, a constant.  Therefore these\n * macros can be used in array declarations and case labels where required.\n * Similarly the macros are also pre-processor constants (sizeof is not used) so\n * they can be used in #if tests.\n *\n * First the information about the samples.\n */\n#define PNG_IMAGE_SAMPLE_CHANNELS(fmt)\\\n   (((fmt)&(PNG_FORMAT_FLAG_COLOR|PNG_FORMAT_FLAG_ALPHA))+1)\n   /* Return the total number of channels in a given format: 1..4 */\n\n#define PNG_IMAGE_SAMPLE_COMPONENT_SIZE(fmt)\\\n   ((((fmt) & PNG_FORMAT_FLAG_LINEAR) >> 2)+1)\n   /* Return the size in bytes of a single component of a pixel or color-map\n    * entry (as appropriate) in the image: 1 or 2.\n    */\n\n#define PNG_IMAGE_SAMPLE_SIZE(fmt)\\\n   (PNG_IMAGE_SAMPLE_CHANNELS(fmt) * PNG_IMAGE_SAMPLE_COMPONENT_SIZE(fmt))\n   /* This is the size of the sample data for one sample.  If the image is\n    * color-mapped it is the size of one color-map entry (and image pixels are\n    * one byte in size), otherwise it is the size of one image pixel.\n    */\n\n#define PNG_IMAGE_MAXIMUM_COLORMAP_COMPONENTS(fmt)\\\n   (PNG_IMAGE_SAMPLE_CHANNELS(fmt) * 256)\n   /* The maximum size of the color-map required by the format expressed in a\n    * count of components.  This can be used to compile-time allocate a\n    * color-map:\n    *\n    * png_uint_16 colormap[PNG_IMAGE_MAXIMUM_COLORMAP_COMPONENTS(linear_fmt)];\n    *\n    * png_byte colormap[PNG_IMAGE_MAXIMUM_COLORMAP_COMPONENTS(sRGB_fmt)];\n    *\n    * Alternatively use the PNG_IMAGE_COLORMAP_SIZE macro below to use the\n    * information from one of the png_image_begin_read_ APIs and dynamically\n    * allocate the required memory.\n    */\n\n/* Corresponding information about the pixels */\n#define PNG_IMAGE_PIXEL_(test,fmt)\\\n   (((fmt)&PNG_FORMAT_FLAG_COLORMAP)?1:test(fmt))\n\n#define PNG_IMAGE_PIXEL_CHANNELS(fmt)\\\n   PNG_IMAGE_PIXEL_(PNG_IMAGE_SAMPLE_CHANNELS,fmt)\n   /* The number of separate channels (components) in a pixel; 1 for a\n    * color-mapped image.\n    */\n\n#define PNG_IMAGE_PIXEL_COMPONENT_SIZE(fmt)\\\n   PNG_IMAGE_PIXEL_(PNG_IMAGE_SAMPLE_COMPONENT_SIZE,fmt)\n   /* The size, in bytes, of each component in a pixel; 1 for a color-mapped\n    * image.\n    */\n\n#define PNG_IMAGE_PIXEL_SIZE(fmt) PNG_IMAGE_PIXEL_(PNG_IMAGE_SAMPLE_SIZE,fmt)\n   /* The size, in bytes, of a complete pixel; 1 for a color-mapped image. */\n\n/* Information about the whole row, or whole image */\n#define PNG_IMAGE_ROW_STRIDE(image)\\\n   (PNG_IMAGE_PIXEL_CHANNELS((image).format) * (image).width)\n   /* Return the total number of components in a single row of the image; this\n    * is the minimum 'row stride', the minimum count of components between each\n    * row.  For a color-mapped image this is the minimum number of bytes in a\n    * row.\n    */\n\n#define PNG_IMAGE_BUFFER_SIZE(image, row_stride)\\\n   (PNG_IMAGE_PIXEL_COMPONENT_SIZE((image).format)*(image).height*(row_stride))\n   /* Return the size, in bytes, of an image buffer given a png_image and a row\n    * stride - the number of components to leave space for in each row.\n    */\n\n#define PNG_IMAGE_SIZE(image)\\\n   PNG_IMAGE_BUFFER_SIZE(image, PNG_IMAGE_ROW_STRIDE(image))\n   /* Return the size, in bytes, of the image in memory given just a png_image;\n    * the row stride is the minimum stride required for the image.\n    */\n\n#define PNG_IMAGE_COLORMAP_SIZE(image)\\\n   (PNG_IMAGE_SAMPLE_SIZE((image).format) * (image).colormap_entries)\n   /* Return the size, in bytes, of the color-map of this image.  If the image\n    * format is not a color-map format this will return a size sufficient for\n    * 256 entries in the given format; check PNG_FORMAT_FLAG_COLORMAP if\n    * you don't want to allocate a color-map in this case.\n    */\n\n/* PNG_IMAGE_FLAG_*\n *\n * Flags containing additional information about the image are held in the\n * 'flags' field of png_image.\n */\n#define PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB 0x01\n   /* This indicates the the RGB values of the in-memory bitmap do not\n    * correspond to the red, green and blue end-points defined by sRGB.\n    */\n\n#define PNG_IMAGE_FLAG_FAST 0x02\n   /* On write emphasise speed over compression; the resultant PNG file will be\n    * larger but will be produced significantly faster, particular for large\n    * images.  Do not use this option for images which will be distributed, only\n    * used it when producing intermediate files that will be read back in\n    * repeatedly.  For a typical 24-bit image the option will double the read\n    * speed at the cost of increasing the image size by 25%, however for many\n    * more compressible images the PNG file can be 10 times larger with only a\n    * slight speed gain.\n    */\n\n#define PNG_IMAGE_FLAG_16BIT_sRGB 0x04\n   /* On read if the image is a 16-bit per component image and there is no gAMA\n    * or sRGB chunk assume that the components are sRGB encoded.  Notice that\n    * images output by the simplified API always have gamma information; setting\n    * this flag only affects the interpretation of 16-bit images from an\n    * external source.  It is recommended that the application expose this flag\n    * to the user; the user can normally easily recognize the difference between\n    * linear and sRGB encoding.  This flag has no effect on write - the data\n    * passed to the write APIs must have the correct encoding (as defined\n    * above.)\n    *\n    * If the flag is not set (the default) input 16-bit per component data is\n    * assumed to be linear.\n    *\n    * NOTE: the flag can only be set after the png_image_begin_read_ call,\n    * because that call initializes the 'flags' field.\n    */\n\n#ifdef PNG_SIMPLIFIED_READ_SUPPORTED\n/* READ APIs\n * ---------\n *\n * The png_image passed to the read APIs must have been initialized by setting\n * the png_controlp field 'opaque' to NULL (or, safer, memset the whole thing.)\n */\n#ifdef PNG_STDIO_SUPPORTED\nPNG_EXPORT(234, int, png_image_begin_read_from_file, (png_imagep image,\n   const char *file_name));\n   /* The named file is opened for read and the image header is filled in\n    * from the PNG header in the file.\n    */\n\nPNG_EXPORT(235, int, png_image_begin_read_from_stdio, (png_imagep image,\n   FILE* file));\n   /* The PNG header is read from the stdio FILE object. */\n#endif /* PNG_STDIO_SUPPORTED */\n\nPNG_EXPORT(236, int, png_image_begin_read_from_memory, (png_imagep image,\n   png_const_voidp memory, png_size_t size));\n   /* The PNG header is read from the given memory buffer. */\n\nPNG_EXPORT(237, int, png_image_finish_read, (png_imagep image,\n   png_const_colorp background, void *buffer, png_int_32 row_stride,\n   void *colormap));\n   /* Finish reading the image into the supplied buffer and clean up the\n    * png_image structure.\n    *\n    * row_stride is the step, in byte or 2-byte units as appropriate,\n    * between adjacent rows.  A positive stride indicates that the top-most row\n    * is first in the buffer - the normal top-down arrangement.  A negative\n    * stride indicates that the bottom-most row is first in the buffer.\n    *\n    * background need only be supplied if an alpha channel must be removed from\n    * a png_byte format and the removal is to be done by compositing on a solid\n    * color; otherwise it may be NULL and any composition will be done directly\n    * onto the buffer.  The value is an sRGB color to use for the background,\n    * for grayscale output the green channel is used.\n    *\n    * background must be supplied when an alpha channel must be removed from a\n    * single byte color-mapped output format, in other words if:\n    *\n    * 1) The original format from png_image_begin_read_from_* had\n    *    PNG_FORMAT_FLAG_ALPHA set.\n    * 2) The format set by the application does not.\n    * 3) The format set by the application has PNG_FORMAT_FLAG_COLORMAP set and\n    *    PNG_FORMAT_FLAG_LINEAR *not* set.\n    *\n    * For linear output removing the alpha channel is always done by compositing\n    * on black and background is ignored.\n    *\n    * colormap must be supplied when PNG_FORMAT_FLAG_COLORMAP is set.  It must\n    * be at least the size (in bytes) returned by PNG_IMAGE_COLORMAP_SIZE.\n    * image->colormap_entries will be updated to the actual number of entries\n    * written to the colormap; this may be less than the original value.\n    */\n\nPNG_EXPORT(238, void, png_image_free, (png_imagep image));\n   /* Free any data allocated by libpng in image->opaque, setting the pointer to\n    * NULL.  May be called at any time after the structure is initialized.\n    */\n#endif /* PNG_SIMPLIFIED_READ_SUPPORTED */\n\n#ifdef PNG_SIMPLIFIED_WRITE_SUPPORTED\n#ifdef PNG_STDIO_SUPPORTED\n/* WRITE APIS\n * ----------\n * For write you must initialize a png_image structure to describe the image to\n * be written.  To do this use memset to set the whole structure to 0 then\n * initialize fields describing your image.\n *\n * version: must be set to PNG_IMAGE_VERSION\n * opaque: must be initialized to NULL\n * width: image width in pixels\n * height: image height in rows\n * format: the format of the data (image and color-map) you wish to write\n * flags: set to 0 unless one of the defined flags applies; set\n *    PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB for color format images where the RGB\n *    values do not correspond to the colors in sRGB.\n * colormap_entries: set to the number of entries in the color-map (0 to 256)\n */\nPNG_EXPORT(239, int, png_image_write_to_file, (png_imagep image,\n   const char *file, int convert_to_8bit, const void *buffer,\n   png_int_32 row_stride, const void *colormap));\n   /* Write the image to the named file. */\n\nPNG_EXPORT(240, int, png_image_write_to_stdio, (png_imagep image, FILE *file,\n   int convert_to_8_bit, const void *buffer, png_int_32 row_stride,\n   const void *colormap));\n   /* Write the image to the given (FILE*). */\n\n/* With both write APIs if image is in one of the linear formats with 16-bit\n * data then setting convert_to_8_bit will cause the output to be an 8-bit PNG\n * gamma encoded according to the sRGB specification, otherwise a 16-bit linear\n * encoded PNG file is written.\n *\n * With color-mapped data formats the colormap parameter point to a color-map\n * with at least image->colormap_entries encoded in the specified format.  If\n * the format is linear the written PNG color-map will be converted to sRGB\n * regardless of the convert_to_8_bit flag.\n *\n * With all APIs row_stride is handled as in the read APIs - it is the spacing\n * from one row to the next in component sized units (1 or 2 bytes) and if\n * negative indicates a bottom-up row layout in the buffer.\n *\n * Note that the write API does not support interlacing or sub-8-bit pixels.\n */\n#endif /* PNG_STDIO_SUPPORTED */\n#endif /* PNG_SIMPLIFIED_WRITE_SUPPORTED */\n/*******************************************************************************\n *  END OF SIMPLIFIED API\n ******************************************************************************/\n\n#ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED\nPNG_EXPORT(242, void, png_set_check_for_invalid_index,\n    (png_structrp png_ptr, int allowed));\n#  ifdef PNG_GET_PALETTE_MAX_SUPPORTED\nPNG_EXPORT(243, int, png_get_palette_max, (png_const_structp png_ptr,\n    png_const_infop info_ptr));\n#  endif\n#endif /* CHECK_FOR_INVALID_INDEX */\n\n/*******************************************************************************\n *  IMPLEMENTATION OPTIONS\n *******************************************************************************\n *\n * Support for arbitrary implementation-specific optimizations.  The API allows\n * particular options to be turned on or off.  'Option' is the number of the\n * option and 'onoff' is 0 (off) or non-0 (on).  The value returned is given\n * by the PNG_OPTION_ defines below.\n *\n * HARDWARE: normally hardware capabilites, such as the Intel SSE instructions,\n *           are detected at run time, however sometimes it may be impossible\n *           to do this in user mode, in which case it is necessary to discover\n *           the capabilities in an OS specific way.  Such capabilities are\n *           listed here when libpng has support for them and must be turned\n *           ON by the application if present.\n *\n * SOFTWARE: sometimes software optimizations actually result in performance\n *           decrease on some architectures or systems, or with some sets of\n *           PNG images.  'Software' options allow such optimizations to be\n *           selected at run time.\n */\n#ifdef PNG_SET_OPTION_SUPPORTED\n#ifdef PNG_ARM_NEON_API_SUPPORTED\n#  define PNG_ARM_NEON   0 /* HARDWARE: ARM Neon SIMD instructions supported */\n#endif\n#define PNG_MAXIMUM_INFLATE_WINDOW 2 /* SOFTWARE: force maximum window */\n#define PNG_OPTION_NEXT  4 /* Next option - numbers must be even */\n\n/* Return values: NOTE: there are four values and 'off' is *not* zero */\n#define PNG_OPTION_UNSET   0 /* Unset - defaults to off */\n#define PNG_OPTION_INVALID 1 /* Option number out of range */\n#define PNG_OPTION_OFF     2\n#define PNG_OPTION_ON      3\n\nPNG_EXPORT(244, int, png_set_option, (png_structrp png_ptr, int option,\n   int onoff));\n#endif\n\n/*******************************************************************************\n *  END OF HARDWARE OPTIONS\n ******************************************************************************/\n\n/* Maintainer: Put new public prototypes here ^, in libpng.3, and project\n * defs, scripts/pnglibconf.h, and scripts/pnglibconf.h.prebuilt\n */\n\n/* The last ordinal number (this is the *last* one already used; the next\n * one to use is one more than this.)  Maintainer, remember to add an entry to\n * scripts/symbols.def as well.\n */\n#ifdef PNG_EXPORT_LAST_ORDINAL\n  PNG_EXPORT_LAST_ORDINAL(244);\n#endif\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* PNG_VERSION_INFO_ONLY */\n/* Do not put anything past this line */\n#endif /* PNG_H */\n"
  },
  {
    "path": "Projects/Libraries/CSBase/Source/png/pngconf.h",
    "content": "\n/* pngconf.h - machine configurable file for libpng\n *\n * libpng version 1.6.10 - March 6, 2014\n *\n * Copyright (c) 1998-2013 Glenn Randers-Pehrson\n * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)\n * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)\n *\n * This code is released under the libpng license.\n * For conditions of distribution and use, see the disclaimer\n * and license in png.h\n *\n */\n\n/* Any machine specific code is near the front of this file, so if you\n * are configuring libpng for a machine, you may want to read the section\n * starting here down to where it starts to typedef png_color, png_text,\n * and png_info.\n */\n\n#ifndef PNGCONF_H\n#define PNGCONF_H\n\n/* To do: Do all of this in scripts/pnglibconf.dfa */\n#ifdef PNG_SAFE_LIMITS_SUPPORTED\n#  ifdef PNG_USER_WIDTH_MAX\n#    undef PNG_USER_WIDTH_MAX\n#    define PNG_USER_WIDTH_MAX 1000000L\n#  endif\n#  ifdef PNG_USER_HEIGHT_MAX\n#    undef PNG_USER_HEIGHT_MAX\n#    define PNG_USER_HEIGHT_MAX 1000000L\n#  endif\n#  ifdef PNG_USER_CHUNK_MALLOC_MAX\n#    undef PNG_USER_CHUNK_MALLOC_MAX\n#    define PNG_USER_CHUNK_MALLOC_MAX 4000000L\n#  endif\n#  ifdef PNG_USER_CHUNK_CACHE_MAX\n#    undef PNG_USER_CHUNK_CACHE_MAX\n#    define PNG_USER_CHUNK_CACHE_MAX 128\n#  endif\n#endif\n\n#ifndef PNG_BUILDING_SYMBOL_TABLE /* else includes may cause problems */\n\n/* From libpng 1.6.0 libpng requires an ANSI X3.159-1989 (\"ISOC90\") compliant C\n * compiler for correct compilation.  The following header files are required by\n * the standard.  If your compiler doesn't provide these header files, or they\n * do not match the standard, you will need to provide/improve them.\n */\n#include <limits.h>\n#include <stddef.h>\n\n/* Library header files.  These header files are all defined by ISOC90; libpng\n * expects conformant implementations, however, an ISOC90 conformant system need\n * not provide these header files if the functionality cannot be implemented.\n * In this case it will be necessary to disable the relevant parts of libpng in\n * the build of pnglibconf.h.\n *\n * Prior to 1.6.0 string.h was included here; the API changes in 1.6.0 to not\n * include this unnecessary header file.\n */\n\n#ifdef PNG_STDIO_SUPPORTED\n   /* Required for the definition of FILE: */\n#  include <stdio.h>\n#endif\n\n#ifdef PNG_SETJMP_SUPPORTED\n   /* Required for the definition of jmp_buf and the declaration of longjmp: */\n#  include <setjmp.h>\n#endif\n\n#ifdef PNG_CONVERT_tIME_SUPPORTED\n   /* Required for struct tm: */\n#  include <time.h>\n#endif\n\n#endif /* PNG_BUILDING_SYMBOL_TABLE */\n\n/* Prior to 1.6.0 it was possible to turn off 'const' in declarations using\n * PNG_NO_CONST; this is no longer supported except for data declarations which\n * apparently still cause problems in 2011 on some compilers.\n */\n#define PNG_CONST const /* backward compatibility only */\n\n/* This controls optimization of the reading of 16 and 32 bit values\n * from PNG files.  It can be set on a per-app-file basis - it\n * just changes whether a macro is used when the function is called.\n * The library builder sets the default; if read functions are not\n * built into the library the macro implementation is forced on.\n */\n#ifndef PNG_READ_INT_FUNCTIONS_SUPPORTED\n#  define PNG_USE_READ_MACROS\n#endif\n#if !defined(PNG_NO_USE_READ_MACROS) && !defined(PNG_USE_READ_MACROS)\n#  if PNG_DEFAULT_READ_MACROS\n#    define PNG_USE_READ_MACROS\n#  endif\n#endif\n\n/* COMPILER SPECIFIC OPTIONS.\n *\n * These options are provided so that a variety of difficult compilers\n * can be used.  Some are fixed at build time (e.g. PNG_API_RULE\n * below) but still have compiler specific implementations, others\n * may be changed on a per-file basis when compiling against libpng.\n */\n\n/* The PNGARG macro was used in versions of libpng prior to 1.6.0 to protect\n * against legacy (pre ISOC90) compilers that did not understand function\n * prototypes.  It is not required for modern C compilers.\n */\n#ifndef PNGARG\n#  define PNGARG(arglist) arglist\n#endif\n\n/* Function calling conventions.\n * =============================\n * Normally it is not necessary to specify to the compiler how to call\n * a function - it just does it - however on x86 systems derived from\n * Microsoft and Borland C compilers ('IBM PC', 'DOS', 'Windows' systems\n * and some others) there are multiple ways to call a function and the\n * default can be changed on the compiler command line.  For this reason\n * libpng specifies the calling convention of every exported function and\n * every function called via a user supplied function pointer.  This is\n * done in this file by defining the following macros:\n *\n * PNGAPI    Calling convention for exported functions.\n * PNGCBAPI  Calling convention for user provided (callback) functions.\n * PNGCAPI   Calling convention used by the ANSI-C library (required\n *           for longjmp callbacks and sometimes used internally to\n *           specify the calling convention for zlib).\n *\n * These macros should never be overridden.  If it is necessary to\n * change calling convention in a private build this can be done\n * by setting PNG_API_RULE (which defaults to 0) to one of the values\n * below to select the correct 'API' variants.\n *\n * PNG_API_RULE=0 Use PNGCAPI - the 'C' calling convention - throughout.\n *                This is correct in every known environment.\n * PNG_API_RULE=1 Use the operating system convention for PNGAPI and\n *                the 'C' calling convention (from PNGCAPI) for\n *                callbacks (PNGCBAPI).  This is no longer required\n *                in any known environment - if it has to be used\n *                please post an explanation of the problem to the\n *                libpng mailing list.\n *\n * These cases only differ if the operating system does not use the C\n * calling convention, at present this just means the above cases\n * (x86 DOS/Windows sytems) and, even then, this does not apply to\n * Cygwin running on those systems.\n *\n * Note that the value must be defined in pnglibconf.h so that what\n * the application uses to call the library matches the conventions\n * set when building the library.\n */\n\n/* Symbol export\n * =============\n * When building a shared library it is almost always necessary to tell\n * the compiler which symbols to export.  The png.h macro 'PNG_EXPORT'\n * is used to mark the symbols.  On some systems these symbols can be\n * extracted at link time and need no special processing by the compiler,\n * on other systems the symbols are flagged by the compiler and just\n * the declaration requires a special tag applied (unfortunately) in a\n * compiler dependent way.  Some systems can do either.\n *\n * A small number of older systems also require a symbol from a DLL to\n * be flagged to the program that calls it.  This is a problem because\n * we do not know in the header file included by application code that\n * the symbol will come from a shared library, as opposed to a statically\n * linked one.  For this reason the application must tell us by setting\n * the magic flag PNG_USE_DLL to turn on the special processing before\n * it includes png.h.\n *\n * Four additional macros are used to make this happen:\n *\n * PNG_IMPEXP The magic (if any) to cause a symbol to be exported from\n *            the build or imported if PNG_USE_DLL is set - compiler\n *            and system specific.\n *\n * PNG_EXPORT_TYPE(type) A macro that pre or appends PNG_IMPEXP to\n *                       'type', compiler specific.\n *\n * PNG_DLL_EXPORT Set to the magic to use during a libpng build to\n *                make a symbol exported from the DLL.  Not used in the\n *                public header files; see pngpriv.h for how it is used\n *                in the libpng build.\n *\n * PNG_DLL_IMPORT Set to the magic to force the libpng symbols to come\n *                from a DLL - used to define PNG_IMPEXP when\n *                PNG_USE_DLL is set.\n */\n\n/* System specific discovery.\n * ==========================\n * This code is used at build time to find PNG_IMPEXP, the API settings\n * and PNG_EXPORT_TYPE(), it may also set a macro to indicate the DLL\n * import processing is possible.  On Windows systems it also sets\n * compiler-specific macros to the values required to change the calling\n * conventions of the various functions.\n */\n#if defined(_Windows) || defined(_WINDOWS) || defined(WIN32) ||\\\n    defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)\n  /* Windows system (DOS doesn't support DLLs).  Includes builds under Cygwin or\n   * MinGW on any architecture currently supported by Windows.  Also includes\n   * Watcom builds but these need special treatment because they are not\n   * compatible with GCC or Visual C because of different calling conventions.\n   */\n#  if PNG_API_RULE == 2\n    /* If this line results in an error, either because __watcall is not\n     * understood or because of a redefine just below you cannot use *this*\n     * build of the library with the compiler you are using.  *This* build was\n     * build using Watcom and applications must also be built using Watcom!\n     */\n#    define PNGCAPI __watcall\n#  endif\n\n#  if defined(__GNUC__) || (defined(_MSC_VER) && (_MSC_VER >= 800))\n#    define PNGCAPI __cdecl\n#    if PNG_API_RULE == 1\n       /* If this line results in an error __stdcall is not understood and\n        * PNG_API_RULE should not have been set to '1'.\n        */\n#      define PNGAPI __stdcall\n#    endif\n#  else\n    /* An older compiler, or one not detected (erroneously) above,\n     * if necessary override on the command line to get the correct\n     * variants for the compiler.\n     */\n#    ifndef PNGCAPI\n#      define PNGCAPI _cdecl\n#    endif\n#    if PNG_API_RULE == 1 && !defined(PNGAPI)\n#      define PNGAPI _stdcall\n#    endif\n#  endif /* compiler/api */\n\n  /* NOTE: PNGCBAPI always defaults to PNGCAPI. */\n\n#  if defined(PNGAPI) && !defined(PNG_USER_PRIVATEBUILD)\n#     error \"PNG_USER_PRIVATEBUILD must be defined if PNGAPI is changed\"\n#  endif\n\n#  if (defined(_MSC_VER) && _MSC_VER < 800) ||\\\n      (defined(__BORLANDC__) && __BORLANDC__ < 0x500)\n    /* older Borland and MSC\n     * compilers used '__export' and required this to be after\n     * the type.\n     */\n#    ifndef PNG_EXPORT_TYPE\n#      define PNG_EXPORT_TYPE(type) type PNG_IMPEXP\n#    endif\n#    define PNG_DLL_EXPORT __export\n#  else /* newer compiler */\n#    define PNG_DLL_EXPORT __declspec(dllexport)\n#    ifndef PNG_DLL_IMPORT\n#      define PNG_DLL_IMPORT __declspec(dllimport)\n#    endif\n#  endif /* compiler */\n\n#else /* !Windows */\n#  if (defined(__IBMC__) || defined(__IBMCPP__)) && defined(__OS2__)\n#    define PNGAPI _System\n#  else /* !Windows/x86 && !OS/2 */\n    /* Use the defaults, or define PNG*API on the command line (but\n     * this will have to be done for every compile!)\n     */\n#  endif /* other system, !OS/2 */\n#endif /* !Windows/x86 */\n\n/* Now do all the defaulting . */\n#ifndef PNGCAPI\n#  define PNGCAPI\n#endif\n#ifndef PNGCBAPI\n#  define PNGCBAPI PNGCAPI\n#endif\n#ifndef PNGAPI\n#  define PNGAPI PNGCAPI\n#endif\n\n/* PNG_IMPEXP may be set on the compilation system command line or (if not set)\n * then in an internal header file when building the library, otherwise (when\n * using the library) it is set here.\n */\n#ifndef PNG_IMPEXP\n#  if defined(PNG_USE_DLL) && defined(PNG_DLL_IMPORT)\n     /* This forces use of a DLL, disallowing static linking */\n#    define PNG_IMPEXP PNG_DLL_IMPORT\n#  endif\n\n#  ifndef PNG_IMPEXP\n#    define PNG_IMPEXP\n#  endif\n#endif\n\n/* In 1.5.2 the definition of PNG_FUNCTION has been changed to always treat\n * 'attributes' as a storage class - the attributes go at the start of the\n * function definition, and attributes are always appended regardless of the\n * compiler.  This considerably simplifies these macros but may cause problems\n * if any compilers both need function attributes and fail to handle them as\n * a storage class (this is unlikely.)\n */\n#ifndef PNG_FUNCTION\n#  define PNG_FUNCTION(type, name, args, attributes) attributes type name args\n#endif\n\n#ifndef PNG_EXPORT_TYPE\n#  define PNG_EXPORT_TYPE(type) PNG_IMPEXP type\n#endif\n\n   /* The ordinal value is only relevant when preprocessing png.h for symbol\n    * table entries, so we discard it here.  See the .dfn files in the\n    * scripts directory.\n    */\n#ifndef PNG_EXPORTA\n\n#  define PNG_EXPORTA(ordinal, type, name, args, attributes)\\\n      PNG_FUNCTION(PNG_EXPORT_TYPE(type),(PNGAPI name),PNGARG(args), \\\n        extern attributes)\n#endif\n\n/* ANSI-C (C90) does not permit a macro to be invoked with an empty argument,\n * so make something non-empty to satisfy the requirement:\n */\n#define PNG_EMPTY /*empty list*/\n\n#define PNG_EXPORT(ordinal, type, name, args)\\\n   PNG_EXPORTA(ordinal, type, name, args, PNG_EMPTY)\n\n/* Use PNG_REMOVED to comment out a removed interface. */\n#ifndef PNG_REMOVED\n#  define PNG_REMOVED(ordinal, type, name, args, attributes)\n#endif\n\n#ifndef PNG_CALLBACK\n#  define PNG_CALLBACK(type, name, args) type (PNGCBAPI name) PNGARG(args)\n#endif\n\n/* Support for compiler specific function attributes.  These are used\n * so that where compiler support is available incorrect use of API\n * functions in png.h will generate compiler warnings.\n *\n * Added at libpng-1.2.41.\n */\n\n#ifndef PNG_NO_PEDANTIC_WARNINGS\n#  ifndef PNG_PEDANTIC_WARNINGS_SUPPORTED\n#    define PNG_PEDANTIC_WARNINGS_SUPPORTED\n#  endif\n#endif\n\n#ifdef PNG_PEDANTIC_WARNINGS_SUPPORTED\n  /* Support for compiler specific function attributes.  These are used\n   * so that where compiler support is available, incorrect use of API\n   * functions in png.h will generate compiler warnings.  Added at libpng\n   * version 1.2.41.  Disabling these removes the warnings but may also produce\n   * less efficient code.\n   */\n#  if defined(__clang__)\n     /* Clang defines both __clang__ and __GNUC__. Check __clang__ first. */\n#    if !defined(PNG_USE_RESULT) && __has_attribute(__warn_unused_result__)\n#      define PNG_USE_RESULT __attribute__((__warn_unused_result__))\n#    endif\n#    if !defined(PNG_NORETURN) && __has_attribute(__noreturn__)\n#      define PNG_NORETURN __attribute__((__noreturn__))\n#    endif\n#    if !defined(PNG_ALLOCATED) && __has_attribute(__malloc__)\n#      define PNG_ALLOCATED __attribute__((__malloc__))\n#    endif\n#    if !defined(PNG_DEPRECATED) && __has_attribute(__deprecated__)\n#      define PNG_DEPRECATED __attribute__((__deprecated__))\n#    endif\n#    if !defined(PNG_PRIVATE)\n#      ifdef __has_extension\n#        if __has_extension(attribute_unavailable_with_message)\n#          define PNG_PRIVATE __attribute__((__unavailable__(\\\n             \"This function is not exported by libpng.\")))\n#        endif\n#      endif\n#    endif\n#    ifndef PNG_RESTRICT\n#      define PNG_RESTRICT __restrict\n#    endif\n\n#  elif defined(__GNUC__)\n#    ifndef PNG_USE_RESULT\n#      define PNG_USE_RESULT __attribute__((__warn_unused_result__))\n#    endif\n#    ifndef PNG_NORETURN\n#      define PNG_NORETURN   __attribute__((__noreturn__))\n#    endif\n#    if __GNUC__ >= 3\n#      ifndef PNG_ALLOCATED\n#        define PNG_ALLOCATED  __attribute__((__malloc__))\n#      endif\n#      ifndef PNG_DEPRECATED\n#        define PNG_DEPRECATED __attribute__((__deprecated__))\n#      endif\n#      ifndef PNG_PRIVATE\n#        if 0 /* Doesn't work so we use deprecated instead*/\n#          define PNG_PRIVATE \\\n            __attribute__((warning(\"This function is not exported by libpng.\")))\n#        else\n#          define PNG_PRIVATE \\\n            __attribute__((__deprecated__))\n#        endif\n#      endif\n#      if ((__GNUC__ > 3) || !defined(__GNUC_MINOR__) || (__GNUC_MINOR__ >= 1))\n#        ifndef PNG_RESTRICT\n#          define PNG_RESTRICT __restrict\n#        endif\n#      endif /* __GNUC__.__GNUC_MINOR__ > 3.0 */\n#    endif /* __GNUC__ >= 3 */\n\n#  elif defined(_MSC_VER)  && (_MSC_VER >= 1300)\n#    ifndef PNG_USE_RESULT\n#      define PNG_USE_RESULT /* not supported */\n#    endif\n#    ifndef PNG_NORETURN\n#      define PNG_NORETURN   __declspec(noreturn)\n#    endif\n#    ifndef PNG_ALLOCATED\n#      if (_MSC_VER >= 1400)\n#        define PNG_ALLOCATED __declspec(restrict)\n#      endif\n#    endif\n#    ifndef PNG_DEPRECATED\n#      define PNG_DEPRECATED __declspec(deprecated)\n#    endif\n#    ifndef PNG_PRIVATE\n#      define PNG_PRIVATE __declspec(deprecated)\n#    endif\n#    ifndef PNG_RESTRICT\n#      if (_MSC_VER >= 1400)\n#        define PNG_RESTRICT __restrict\n#      endif\n#    endif\n\n#  elif defined(__WATCOMC__)\n#    ifndef PNG_RESTRICT\n#      define PNG_RESTRICT __restrict\n#    endif\n#  endif\n#endif /* PNG_PEDANTIC_WARNINGS */\n\n#ifndef PNG_DEPRECATED\n#  define PNG_DEPRECATED  /* Use of this function is deprecated */\n#endif\n#ifndef PNG_USE_RESULT\n#  define PNG_USE_RESULT  /* The result of this function must be checked */\n#endif\n#ifndef PNG_NORETURN\n#  define PNG_NORETURN    /* This function does not return */\n#endif\n#ifndef PNG_ALLOCATED\n#  define PNG_ALLOCATED   /* The result of the function is new memory */\n#endif\n#ifndef PNG_PRIVATE\n#  define PNG_PRIVATE     /* This is a private libpng function */\n#endif\n#ifndef PNG_RESTRICT\n#  define PNG_RESTRICT    /* The C99 \"restrict\" feature */\n#endif\n\n#ifndef PNG_FP_EXPORT     /* A floating point API. */\n#  ifdef PNG_FLOATING_POINT_SUPPORTED\n#     define PNG_FP_EXPORT(ordinal, type, name, args)\\\n         PNG_EXPORT(ordinal, type, name, args);\n#  else                   /* No floating point APIs */\n#     define PNG_FP_EXPORT(ordinal, type, name, args)\n#  endif\n#endif\n#ifndef PNG_FIXED_EXPORT  /* A fixed point API. */\n#  ifdef PNG_FIXED_POINT_SUPPORTED\n#     define PNG_FIXED_EXPORT(ordinal, type, name, args)\\\n         PNG_EXPORT(ordinal, type, name, args);\n#  else                   /* No fixed point APIs */\n#     define PNG_FIXED_EXPORT(ordinal, type, name, args)\n#  endif\n#endif\n\n#ifndef PNG_BUILDING_SYMBOL_TABLE\n/* Some typedefs to get us started.  These should be safe on most of the common\n * platforms.\n *\n * png_uint_32 and png_int_32 may, currently, be larger than required to hold a\n * 32-bit value however this is not normally advisable.\n *\n * png_uint_16 and png_int_16 should always be two bytes in size - this is\n * verified at library build time.\n *\n * png_byte must always be one byte in size.\n *\n * The checks below use constants from limits.h, as defined by the ISOC90\n * standard.\n */\n#if CHAR_BIT == 8 && UCHAR_MAX == 255\n   typedef unsigned char png_byte;\n#else\n#  error \"libpng requires 8 bit bytes\"\n#endif\n\n#if INT_MIN == -32768 && INT_MAX == 32767\n   typedef int png_int_16;\n#elif SHRT_MIN == -32768 && SHRT_MAX == 32767\n   typedef short png_int_16;\n#else\n#  error \"libpng requires a signed 16 bit type\"\n#endif\n\n#if UINT_MAX == 65535\n   typedef unsigned int png_uint_16;\n#elif USHRT_MAX == 65535\n   typedef unsigned short png_uint_16;\n#else\n#  error \"libpng requires an unsigned 16 bit type\"\n#endif\n\n#if INT_MIN < -2147483646 && INT_MAX > 2147483646\n   typedef int png_int_32;\n#elif LONG_MIN < -2147483646 && LONG_MAX > 2147483646\n   typedef long int png_int_32;\n#else\n#  error \"libpng requires a signed 32 bit (or more) type\"\n#endif\n\n#if UINT_MAX > 4294967294\n   typedef unsigned int png_uint_32;\n#elif ULONG_MAX > 4294967294\n   typedef unsigned long int png_uint_32;\n#else\n#  error \"libpng requires an unsigned 32 bit (or more) type\"\n#endif\n\n/* Prior to 1.6.0 it was possible to disable the use of size_t, 1.6.0, however,\n * requires an ISOC90 compiler and relies on consistent behavior of sizeof.\n */\ntypedef size_t png_size_t;\ntypedef ptrdiff_t png_ptrdiff_t;\n\n/* libpng needs to know the maximum value of 'size_t' and this controls the\n * definition of png_alloc_size_t, below.  This maximum value of size_t limits\n * but does not control the maximum allocations the library makes - there is\n * direct application control of this through png_set_user_limits().\n */\n#ifndef PNG_SMALL_SIZE_T\n   /* Compiler specific tests for systems where size_t is known to be less than\n    * 32 bits (some of these systems may no longer work because of the lack of\n    * 'far' support; see above.)\n    */\n#  if (defined(__TURBOC__) && !defined(__FLAT__)) ||\\\n   (defined(_MSC_VER) && defined(MAXSEG_64K))\n#     define PNG_SMALL_SIZE_T\n#  endif\n#endif\n\n/* png_alloc_size_t is guaranteed to be no smaller than png_size_t, and no\n * smaller than png_uint_32.  Casts from png_size_t or png_uint_32 to\n * png_alloc_size_t are not necessary; in fact, it is recommended not to use\n * them at all so that the compiler can complain when something turns out to be\n * problematic.\n *\n * Casts in the other direction (from png_alloc_size_t to png_size_t or\n * png_uint_32) should be explicitly applied; however, we do not expect to\n * encounter practical situations that require such conversions.\n *\n * PNG_SMALL_SIZE_T must be defined if the maximum value of size_t is less than\n * 4294967295 - i.e. less than the maximum value of png_uint_32.\n */\n#ifdef PNG_SMALL_SIZE_T\n   typedef png_uint_32 png_alloc_size_t;\n#else\n   typedef png_size_t png_alloc_size_t;\n#endif\n\n/* Prior to 1.6.0 libpng offered limited support for Microsoft C compiler\n * implementations of Intel CPU specific support of user-mode segmented address\n * spaces, where 16-bit pointers address more than 65536 bytes of memory using\n * separate 'segment' registers.  The implementation requires two different\n * types of pointer (only one of which includes the segment value.)\n *\n * If required this support is available in version 1.2 of libpng and may be\n * available in versions through 1.5, although the correctness of the code has\n * not been verified recently.\n */\n\n/* Typedef for floating-point numbers that are converted to fixed-point with a\n * multiple of 100,000, e.g., gamma\n */\ntypedef png_int_32 png_fixed_point;\n\n/* Add typedefs for pointers */\ntypedef void                  * png_voidp;\ntypedef const void            * png_const_voidp;\ntypedef png_byte              * png_bytep;\ntypedef const png_byte        * png_const_bytep;\ntypedef png_uint_32           * png_uint_32p;\ntypedef const png_uint_32     * png_const_uint_32p;\ntypedef png_int_32            * png_int_32p;\ntypedef const png_int_32      * png_const_int_32p;\ntypedef png_uint_16           * png_uint_16p;\ntypedef const png_uint_16     * png_const_uint_16p;\ntypedef png_int_16            * png_int_16p;\ntypedef const png_int_16      * png_const_int_16p;\ntypedef char                  * png_charp;\ntypedef const char            * png_const_charp;\ntypedef png_fixed_point       * png_fixed_point_p;\ntypedef const png_fixed_point * png_const_fixed_point_p;\ntypedef png_size_t            * png_size_tp;\ntypedef const png_size_t      * png_const_size_tp;\n\n#ifdef PNG_STDIO_SUPPORTED\ntypedef FILE            * png_FILE_p;\n#endif\n\n#ifdef PNG_FLOATING_POINT_SUPPORTED\ntypedef double       * png_doublep;\ntypedef const double * png_const_doublep;\n#endif\n\n/* Pointers to pointers; i.e. arrays */\ntypedef png_byte        * * png_bytepp;\ntypedef png_uint_32     * * png_uint_32pp;\ntypedef png_int_32      * * png_int_32pp;\ntypedef png_uint_16     * * png_uint_16pp;\ntypedef png_int_16      * * png_int_16pp;\ntypedef const char      * * png_const_charpp;\ntypedef char            * * png_charpp;\ntypedef png_fixed_point * * png_fixed_point_pp;\n#ifdef PNG_FLOATING_POINT_SUPPORTED\ntypedef double          * * png_doublepp;\n#endif\n\n/* Pointers to pointers to pointers; i.e., pointer to array */\ntypedef char            * * * png_charppp;\n\n#endif /* PNG_BUILDING_SYMBOL_TABLE */\n\n#endif /* PNGCONF_H */\n"
  },
  {
    "path": "Projects/Libraries/CSBase/Source/png/pngdebug.h",
    "content": "\n/* pngdebug.h - Debugging macros for libpng, also used in pngtest.c\n *\n * Copyright (c) 1998-2013 Glenn Randers-Pehrson\n * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)\n * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)\n *\n * Last changed in libpng 1.6.8 [December 19, 2013]\n *\n * This code is released under the libpng license.\n * For conditions of distribution and use, see the disclaimer\n * and license in png.h\n */\n\n/* Define PNG_DEBUG at compile time for debugging information.  Higher\n * numbers for PNG_DEBUG mean more debugging information.  This has\n * only been added since version 0.95 so it is not implemented throughout\n * libpng yet, but more support will be added as needed.\n *\n * png_debug[1-2]?(level, message ,arg{0-2})\n *   Expands to a statement (either a simple expression or a compound\n *   do..while(0) statement) that outputs a message with parameter\n *   substitution if PNG_DEBUG is defined to 2 or more.  If PNG_DEBUG\n *   is undefined, 0 or 1 every png_debug expands to a simple expression\n *   (actually ((void)0)).\n *\n *   level: level of detail of message, starting at 0.  A level 'n'\n *          message is preceded by 'n' 3-space indentations (not implemented\n *          on Microsoft compilers unless PNG_DEBUG_FILE is also\n *          defined, to allow debug DLL compilation with no standard IO).\n *   message: a printf(3) style text string.  A trailing '\\n' is added\n *            to the message.\n *   arg: 0 to 2 arguments for printf(3) style substitution in message.\n */\n#ifndef PNGDEBUG_H\n#define PNGDEBUG_H\n/* These settings control the formatting of messages in png.c and pngerror.c */\n/* Moved to pngdebug.h at 1.5.0 */\n#  ifndef PNG_LITERAL_SHARP\n#    define PNG_LITERAL_SHARP 0x23\n#  endif\n#  ifndef PNG_LITERAL_LEFT_SQUARE_BRACKET\n#    define PNG_LITERAL_LEFT_SQUARE_BRACKET 0x5b\n#  endif\n#  ifndef PNG_LITERAL_RIGHT_SQUARE_BRACKET\n#    define PNG_LITERAL_RIGHT_SQUARE_BRACKET 0x5d\n#  endif\n#  ifndef PNG_STRING_NEWLINE\n#    define PNG_STRING_NEWLINE \"\\n\"\n#  endif\n\n#ifdef PNG_DEBUG\n#  if (PNG_DEBUG > 0)\n#    if !defined(PNG_DEBUG_FILE) && defined(_MSC_VER)\n#      include <crtdbg.h>\n#      if (PNG_DEBUG > 1)\n#        ifndef _DEBUG\n#          define _DEBUG\n#        endif\n#        ifndef png_debug\n#          define png_debug(l,m)  _RPT0(_CRT_WARN,m PNG_STRING_NEWLINE)\n#        endif\n#        ifndef png_debug1\n#          define png_debug1(l,m,p1)  _RPT1(_CRT_WARN,m PNG_STRING_NEWLINE,p1)\n#        endif\n#        ifndef png_debug2\n#          define png_debug2(l,m,p1,p2) \\\n             _RPT2(_CRT_WARN,m PNG_STRING_NEWLINE,p1,p2)\n#        endif\n#      endif\n#    else /* PNG_DEBUG_FILE || !_MSC_VER */\n#      ifndef PNG_STDIO_SUPPORTED\n#        include <stdio.h> /* not included yet */\n#      endif\n#      ifndef PNG_DEBUG_FILE\n#        define PNG_DEBUG_FILE stderr\n#      endif /* PNG_DEBUG_FILE */\n\n#      if (PNG_DEBUG > 1)\n#        ifdef __STDC__\n#          ifndef png_debug\n#            define png_debug(l,m) \\\n       do { \\\n       int num_tabs=l; \\\n       fprintf(PNG_DEBUG_FILE,\"%s\" m PNG_STRING_NEWLINE,(num_tabs==1 ? \"   \" : \\\n         (num_tabs==2 ? \"      \" : (num_tabs>2 ? \"         \" : \"\")))); \\\n       } while (0)\n#          endif\n#          ifndef png_debug1\n#            define png_debug1(l,m,p1) \\\n       do { \\\n       int num_tabs=l; \\\n       fprintf(PNG_DEBUG_FILE,\"%s\" m PNG_STRING_NEWLINE,(num_tabs==1 ? \"   \" : \\\n         (num_tabs==2 ? \"      \" : (num_tabs>2 ? \"         \" : \"\"))),p1); \\\n       } while (0)\n#          endif\n#          ifndef png_debug2\n#            define png_debug2(l,m,p1,p2) \\\n       do { \\\n       int num_tabs=l; \\\n       fprintf(PNG_DEBUG_FILE,\"%s\" m PNG_STRING_NEWLINE,(num_tabs==1 ? \"   \" : \\\n         (num_tabs==2 ? \"      \" : (num_tabs>2 ? \"         \" : \"\"))),p1,p2);\\\n       } while (0)\n#          endif\n#        else /* __STDC __ */\n#          ifndef png_debug\n#            define png_debug(l,m) \\\n       do { \\\n       int num_tabs=l; \\\n       char format[256]; \\\n       snprintf(format,256,\"%s%s%s\",(num_tabs==1 ? \"\\t\" : \\\n         (num_tabs==2 ? \"\\t\\t\":(num_tabs>2 ? \"\\t\\t\\t\":\"\"))), \\\n         m,PNG_STRING_NEWLINE); \\\n       fprintf(PNG_DEBUG_FILE,format); \\\n       } while (0)\n#          endif\n#          ifndef png_debug1\n#            define png_debug1(l,m,p1) \\\n       do { \\\n       int num_tabs=l; \\\n       char format[256]; \\\n       snprintf(format,256,\"%s%s%s\",(num_tabs==1 ? \"\\t\" : \\\n         (num_tabs==2 ? \"\\t\\t\":(num_tabs>2 ? \"\\t\\t\\t\":\"\"))), \\\n         m,PNG_STRING_NEWLINE); \\\n       fprintf(PNG_DEBUG_FILE,format,p1); \\\n       } while (0)\n#          endif\n#          ifndef png_debug2\n#            define png_debug2(l,m,p1,p2) \\\n       do { \\\n       int num_tabs=l; \\\n       char format[256]; \\\n       snprintf(format,256,\"%s%s%s\",(num_tabs==1 ? \"\\t\" : \\\n         (num_tabs==2 ? \"\\t\\t\":(num_tabs>2 ? \"\\t\\t\\t\":\"\"))), \\\n         m,PNG_STRING_NEWLINE); \\\n       fprintf(PNG_DEBUG_FILE,format,p1,p2); \\\n       } while (0)\n#          endif\n#        endif /* __STDC __ */\n#      endif /* (PNG_DEBUG > 1) */\n\n#    endif /* _MSC_VER */\n#  endif /* (PNG_DEBUG > 0) */\n#endif /* PNG_DEBUG */\n#ifndef png_debug\n#  define png_debug(l, m) ((void)0)\n#endif\n#ifndef png_debug1\n#  define png_debug1(l, m, p1) ((void)0)\n#endif\n#ifndef png_debug2\n#  define png_debug2(l, m, p1, p2) ((void)0)\n#endif\n#endif /* PNGDEBUG_H */\n"
  },
  {
    "path": "Projects/Libraries/CSBase/Source/png/pngerror.c",
    "content": "\n/* pngerror.c - stub functions for i/o and memory allocation\n *\n * Last changed in libpng 1.6.10 [March 6, 2014]\n * Copyright (c) 1998-2014 Glenn Randers-Pehrson\n * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)\n * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)\n *\n * This code is released under the libpng license.\n * For conditions of distribution and use, see the disclaimer\n * and license in png.h\n *\n * This file provides a location for all error handling.  Users who\n * need special error handling are expected to write replacement functions\n * and use png_set_error_fn() to use those functions.  See the instructions\n * at each function.\n */\n\n#include \"pngpriv.h\"\n\n#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)\n\nstatic PNG_FUNCTION(void, png_default_error,PNGARG((png_const_structrp png_ptr,\n    png_const_charp error_message)),PNG_NORETURN);\n\n#ifdef PNG_WARNINGS_SUPPORTED\nstatic void /* PRIVATE */\npng_default_warning PNGARG((png_const_structrp png_ptr,\n   png_const_charp warning_message));\n#endif /* PNG_WARNINGS_SUPPORTED */\n\n/* This function is called whenever there is a fatal error.  This function\n * should not be changed.  If there is a need to handle errors differently,\n * you should supply a replacement error function and use png_set_error_fn()\n * to replace the error function at run-time.\n */\n#ifdef PNG_ERROR_TEXT_SUPPORTED\nPNG_FUNCTION(void,PNGAPI\npng_error,(png_const_structrp png_ptr, png_const_charp error_message),\n   PNG_NORETURN)\n{\n#ifdef PNG_ERROR_NUMBERS_SUPPORTED\n   char msg[16];\n   if (png_ptr != NULL)\n   {\n      if (png_ptr->flags&\n         (PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT))\n      {\n         if (*error_message == PNG_LITERAL_SHARP)\n         {\n            /* Strip \"#nnnn \" from beginning of error message. */\n            int offset;\n            for (offset = 1; offset<15; offset++)\n               if (error_message[offset] == ' ')\n                  break;\n\n            if (png_ptr->flags&PNG_FLAG_STRIP_ERROR_TEXT)\n            {\n               int i;\n               for (i = 0; i < offset - 1; i++)\n                  msg[i] = error_message[i + 1];\n               msg[i - 1] = '\\0';\n               error_message = msg;\n            }\n\n            else\n               error_message += offset;\n      }\n\n      else\n      {\n         if (png_ptr->flags&PNG_FLAG_STRIP_ERROR_TEXT)\n         {\n            msg[0] = '0';\n            msg[1] = '\\0';\n            error_message = msg;\n         }\n       }\n     }\n   }\n#endif\n   if (png_ptr != NULL && png_ptr->error_fn != NULL)\n      (*(png_ptr->error_fn))(png_constcast(png_structrp,png_ptr),\n          error_message);\n\n   /* If the custom handler doesn't exist, or if it returns,\n      use the default handler, which will not return. */\n   png_default_error(png_ptr, error_message);\n}\n#else\nPNG_FUNCTION(void,PNGAPI\npng_err,(png_const_structrp png_ptr),PNG_NORETURN)\n{\n   /* Prior to 1.5.2 the error_fn received a NULL pointer, expressed\n    * erroneously as '\\0', instead of the empty string \"\".  This was\n    * apparently an error, introduced in libpng-1.2.20, and png_default_error\n    * will crash in this case.\n    */\n   if (png_ptr != NULL && png_ptr->error_fn != NULL)\n      (*(png_ptr->error_fn))(png_constcast(png_structrp,png_ptr), \"\");\n\n   /* If the custom handler doesn't exist, or if it returns,\n      use the default handler, which will not return. */\n   png_default_error(png_ptr, \"\");\n}\n#endif /* PNG_ERROR_TEXT_SUPPORTED */\n\n/* Utility to safely appends strings to a buffer.  This never errors out so\n * error checking is not required in the caller.\n */\nsize_t\npng_safecat(png_charp buffer, size_t bufsize, size_t pos,\n   png_const_charp string)\n{\n   if (buffer != NULL && pos < bufsize)\n   {\n      if (string != NULL)\n         while (*string != '\\0' && pos < bufsize-1)\n           buffer[pos++] = *string++;\n\n      buffer[pos] = '\\0';\n   }\n\n   return pos;\n}\n\n#if defined(PNG_WARNINGS_SUPPORTED) || defined(PNG_TIME_RFC1123_SUPPORTED)\n/* Utility to dump an unsigned value into a buffer, given a start pointer and\n * and end pointer (which should point just *beyond* the end of the buffer!)\n * Returns the pointer to the start of the formatted string.\n */\npng_charp\npng_format_number(png_const_charp start, png_charp end, int format,\n   png_alloc_size_t number)\n{\n   int count = 0;    /* number of digits output */\n   int mincount = 1; /* minimum number required */\n   int output = 0;   /* digit output (for the fixed point format) */\n\n   *--end = '\\0';\n\n   /* This is written so that the loop always runs at least once, even with\n    * number zero.\n    */\n   while (end > start && (number != 0 || count < mincount))\n   {\n\n      static const char digits[] = \"0123456789ABCDEF\";\n\n      switch (format)\n      {\n         case PNG_NUMBER_FORMAT_fixed:\n            /* Needs five digits (the fraction) */\n            mincount = 5;\n            if (output || number % 10 != 0)\n            {\n               *--end = digits[number % 10];\n               output = 1;\n            }\n            number /= 10;\n            break;\n\n         case PNG_NUMBER_FORMAT_02u:\n            /* Expects at least 2 digits. */\n            mincount = 2;\n            /* FALL THROUGH */\n\n         case PNG_NUMBER_FORMAT_u:\n            *--end = digits[number % 10];\n            number /= 10;\n            break;\n\n         case PNG_NUMBER_FORMAT_02x:\n            /* This format expects at least two digits */\n            mincount = 2;\n            /* FALL THROUGH */\n\n         case PNG_NUMBER_FORMAT_x:\n            *--end = digits[number & 0xf];\n            number >>= 4;\n            break;\n\n         default: /* an error */\n            number = 0;\n            break;\n      }\n\n      /* Keep track of the number of digits added */\n      ++count;\n\n      /* Float a fixed number here: */\n      if (format == PNG_NUMBER_FORMAT_fixed) if (count == 5) if (end > start)\n      {\n         /* End of the fraction, but maybe nothing was output?  In that case\n          * drop the decimal point.  If the number is a true zero handle that\n          * here.\n          */\n         if (output)\n            *--end = '.';\n         else if (number == 0) /* and !output */\n            *--end = '0';\n      }\n   }\n\n   return end;\n}\n#endif\n\n#ifdef PNG_WARNINGS_SUPPORTED\n/* This function is called whenever there is a non-fatal error.  This function\n * should not be changed.  If there is a need to handle warnings differently,\n * you should supply a replacement warning function and use\n * png_set_error_fn() to replace the warning function at run-time.\n */\nvoid PNGAPI\npng_warning(png_const_structrp png_ptr, png_const_charp warning_message)\n{\n   int offset = 0;\n   if (png_ptr != NULL)\n   {\n#ifdef PNG_ERROR_NUMBERS_SUPPORTED\n   if (png_ptr->flags&\n       (PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT))\n#endif\n      {\n         if (*warning_message == PNG_LITERAL_SHARP)\n         {\n            for (offset = 1; offset < 15; offset++)\n               if (warning_message[offset] == ' ')\n                  break;\n         }\n      }\n   }\n   if (png_ptr != NULL && png_ptr->warning_fn != NULL)\n      (*(png_ptr->warning_fn))(png_constcast(png_structrp,png_ptr),\n         warning_message + offset);\n   else\n      png_default_warning(png_ptr, warning_message + offset);\n}\n\n/* These functions support 'formatted' warning messages with up to\n * PNG_WARNING_PARAMETER_COUNT parameters.  In the format string the parameter\n * is introduced by @<number>, where 'number' starts at 1.  This follows the\n * standard established by X/Open for internationalizable error messages.\n */\nvoid\npng_warning_parameter(png_warning_parameters p, int number,\n   png_const_charp string)\n{\n   if (number > 0 && number <= PNG_WARNING_PARAMETER_COUNT)\n      (void)png_safecat(p[number-1], (sizeof p[number-1]), 0, string);\n}\n\nvoid\npng_warning_parameter_unsigned(png_warning_parameters p, int number, int format,\n   png_alloc_size_t value)\n{\n   char buffer[PNG_NUMBER_BUFFER_SIZE];\n   png_warning_parameter(p, number, PNG_FORMAT_NUMBER(buffer, format, value));\n}\n\nvoid\npng_warning_parameter_signed(png_warning_parameters p, int number, int format,\n   png_int_32 value)\n{\n   png_alloc_size_t u;\n   png_charp str;\n   char buffer[PNG_NUMBER_BUFFER_SIZE];\n\n   /* Avoid overflow by doing the negate in a png_alloc_size_t: */\n   u = (png_alloc_size_t)value;\n   if (value < 0)\n      u = ~u + 1;\n\n   str = PNG_FORMAT_NUMBER(buffer, format, u);\n\n   if (value < 0 && str > buffer)\n      *--str = '-';\n\n   png_warning_parameter(p, number, str);\n}\n\nvoid\npng_formatted_warning(png_const_structrp png_ptr, png_warning_parameters p,\n   png_const_charp message)\n{\n   /* The internal buffer is just 192 bytes - enough for all our messages,\n    * overflow doesn't happen because this code checks!  If someone figures\n    * out how to send us a message longer than 192 bytes, all that will\n    * happen is that the message will be truncated appropriately.\n    */\n   size_t i = 0; /* Index in the msg[] buffer: */\n   char msg[192];\n\n   /* Each iteration through the following loop writes at most one character\n    * to msg[i++] then returns here to validate that there is still space for\n    * the trailing '\\0'.  It may (in the case of a parameter) read more than\n    * one character from message[]; it must check for '\\0' and continue to the\n    * test if it finds the end of string.\n    */\n   while (i<(sizeof msg)-1 && *message != '\\0')\n   {\n      /* '@' at end of string is now just printed (previously it was skipped);\n       * it is an error in the calling code to terminate the string with @.\n       */\n      if (p != NULL && *message == '@' && message[1] != '\\0')\n      {\n         int parameter_char = *++message; /* Consume the '@' */\n         static const char valid_parameters[] = \"123456789\";\n         int parameter = 0;\n\n         /* Search for the parameter digit, the index in the string is the\n          * parameter to use.\n          */\n         while (valid_parameters[parameter] != parameter_char &&\n            valid_parameters[parameter] != '\\0')\n            ++parameter;\n\n         /* If the parameter digit is out of range it will just get printed. */\n         if (parameter < PNG_WARNING_PARAMETER_COUNT)\n         {\n            /* Append this parameter */\n            png_const_charp parm = p[parameter];\n            png_const_charp pend = p[parameter] + (sizeof p[parameter]);\n\n            /* No need to copy the trailing '\\0' here, but there is no guarantee\n             * that parm[] has been initialized, so there is no guarantee of a\n             * trailing '\\0':\n             */\n            while (i<(sizeof msg)-1 && *parm != '\\0' && parm < pend)\n               msg[i++] = *parm++;\n\n            /* Consume the parameter digit too: */\n            ++message;\n            continue;\n         }\n\n         /* else not a parameter and there is a character after the @ sign; just\n          * copy that.  This is known not to be '\\0' because of the test above.\n          */\n      }\n\n      /* At this point *message can't be '\\0', even in the bad parameter case\n       * above where there is a lone '@' at the end of the message string.\n       */\n      msg[i++] = *message++;\n   }\n\n   /* i is always less than (sizeof msg), so: */\n   msg[i] = '\\0';\n\n   /* And this is the formatted message. It may be larger than\n    * PNG_MAX_ERROR_TEXT, but that is only used for 'chunk' errors and these\n    * are not (currently) formatted.\n    */\n   png_warning(png_ptr, msg);\n}\n#endif /* PNG_WARNINGS_SUPPORTED */\n\n#ifdef PNG_BENIGN_ERRORS_SUPPORTED\nvoid PNGAPI\npng_benign_error(png_const_structrp png_ptr, png_const_charp error_message)\n{\n   if (png_ptr->flags & PNG_FLAG_BENIGN_ERRORS_WARN)\n   {\n#     ifdef PNG_READ_SUPPORTED\n         if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0 &&\n            png_ptr->chunk_name != 0)\n            png_chunk_warning(png_ptr, error_message);\n         else\n#     endif\n      png_warning(png_ptr, error_message);\n   }\n\n   else\n   {\n#     ifdef PNG_READ_SUPPORTED\n         if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0 &&\n            png_ptr->chunk_name != 0)\n            png_chunk_error(png_ptr, error_message);\n         else\n#     endif\n      png_error(png_ptr, error_message);\n   }\n\n#  ifndef PNG_ERROR_TEXT_SUPPORTED\n      PNG_UNUSED(error_message)\n#  endif\n}\n\nvoid /* PRIVATE */\npng_app_warning(png_const_structrp png_ptr, png_const_charp error_message)\n{\n  if (png_ptr->flags & PNG_FLAG_APP_WARNINGS_WARN)\n     png_warning(png_ptr, error_message);\n  else\n     png_error(png_ptr, error_message);\n\n#  ifndef PNG_ERROR_TEXT_SUPPORTED\n      PNG_UNUSED(error_message)\n#  endif\n}\n\nvoid /* PRIVATE */\npng_app_error(png_const_structrp png_ptr, png_const_charp error_message)\n{\n  if (png_ptr->flags & PNG_FLAG_APP_ERRORS_WARN)\n     png_warning(png_ptr, error_message);\n  else\n     png_error(png_ptr, error_message);\n\n#  ifndef PNG_ERROR_TEXT_SUPPORTED\n      PNG_UNUSED(error_message)\n#  endif\n}\n#endif /* BENIGN_ERRORS */\n\n/* These utilities are used internally to build an error message that relates\n * to the current chunk.  The chunk name comes from png_ptr->chunk_name,\n * this is used to prefix the message.  The message is limited in length\n * to 63 bytes, the name characters are output as hex digits wrapped in []\n * if the character is invalid.\n */\n#define isnonalpha(c) ((c) < 65 || (c) > 122 || ((c) > 90 && (c) < 97))\nstatic PNG_CONST char png_digit[16] = {\n   '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',\n   'A', 'B', 'C', 'D', 'E', 'F'\n};\n\n#define PNG_MAX_ERROR_TEXT 196 /* Currently limited be profile_error in png.c */\n#if defined(PNG_WARNINGS_SUPPORTED) || \\\n   (defined(PNG_READ_SUPPORTED) && defined(PNG_ERROR_TEXT_SUPPORTED))\nstatic void /* PRIVATE */\npng_format_buffer(png_const_structrp png_ptr, png_charp buffer, png_const_charp\n    error_message)\n{\n   png_uint_32 chunk_name = png_ptr->chunk_name;\n   int iout = 0, ishift = 24;\n\n   while (ishift >= 0)\n   {\n      int c = (int)(chunk_name >> ishift) & 0xff;\n\n      ishift -= 8;\n      if (isnonalpha(c))\n      {\n         buffer[iout++] = PNG_LITERAL_LEFT_SQUARE_BRACKET;\n         buffer[iout++] = png_digit[(c & 0xf0) >> 4];\n         buffer[iout++] = png_digit[c & 0x0f];\n         buffer[iout++] = PNG_LITERAL_RIGHT_SQUARE_BRACKET;\n      }\n\n      else\n      {\n         buffer[iout++] = (char)c;\n      }\n   }\n\n   if (error_message == NULL)\n      buffer[iout] = '\\0';\n\n   else\n   {\n      int iin = 0;\n\n      buffer[iout++] = ':';\n      buffer[iout++] = ' ';\n\n      while (iin < PNG_MAX_ERROR_TEXT-1 && error_message[iin] != '\\0')\n         buffer[iout++] = error_message[iin++];\n\n      /* iin < PNG_MAX_ERROR_TEXT, so the following is safe: */\n      buffer[iout] = '\\0';\n   }\n}\n#endif /* PNG_WARNINGS_SUPPORTED || PNG_ERROR_TEXT_SUPPORTED */\n\n#if defined(PNG_READ_SUPPORTED) && defined(PNG_ERROR_TEXT_SUPPORTED)\nPNG_FUNCTION(void,PNGAPI\npng_chunk_error,(png_const_structrp png_ptr, png_const_charp error_message),\n   PNG_NORETURN)\n{\n   char msg[18+PNG_MAX_ERROR_TEXT];\n   if (png_ptr == NULL)\n      png_error(png_ptr, error_message);\n\n   else\n   {\n      png_format_buffer(png_ptr, msg, error_message);\n      png_error(png_ptr, msg);\n   }\n}\n#endif /* PNG_READ_SUPPORTED && PNG_ERROR_TEXT_SUPPORTED */\n\n#ifdef PNG_WARNINGS_SUPPORTED\nvoid PNGAPI\npng_chunk_warning(png_const_structrp png_ptr, png_const_charp warning_message)\n{\n   char msg[18+PNG_MAX_ERROR_TEXT];\n   if (png_ptr == NULL)\n      png_warning(png_ptr, warning_message);\n\n   else\n   {\n      png_format_buffer(png_ptr, msg, warning_message);\n      png_warning(png_ptr, msg);\n   }\n}\n#endif /* PNG_WARNINGS_SUPPORTED */\n\n#ifdef PNG_READ_SUPPORTED\n#ifdef PNG_BENIGN_ERRORS_SUPPORTED\nvoid PNGAPI\npng_chunk_benign_error(png_const_structrp png_ptr, png_const_charp\n    error_message)\n{\n   if (png_ptr->flags & PNG_FLAG_BENIGN_ERRORS_WARN)\n      png_chunk_warning(png_ptr, error_message);\n\n   else\n      png_chunk_error(png_ptr, error_message);\n\n#  ifndef PNG_ERROR_TEXT_SUPPORTED\n      PNG_UNUSED(error_message)\n#  endif\n}\n#endif\n#endif /* PNG_READ_SUPPORTED */\n\nvoid /* PRIVATE */\npng_chunk_report(png_const_structrp png_ptr, png_const_charp message, int error)\n{\n#  ifndef PNG_WARNINGS_SUPPORTED\n      PNG_UNUSED(message)\n#  endif\n\n   /* This is always supported, but for just read or just write it\n    * unconditionally does the right thing.\n    */\n#  if defined(PNG_READ_SUPPORTED) && defined(PNG_WRITE_SUPPORTED)\n      if (png_ptr->mode & PNG_IS_READ_STRUCT)\n#  endif\n\n#  ifdef PNG_READ_SUPPORTED\n      {\n         if (error < PNG_CHUNK_ERROR)\n            png_chunk_warning(png_ptr, message);\n\n         else\n            png_chunk_benign_error(png_ptr, message);\n      }\n#  endif\n\n#  if defined(PNG_READ_SUPPORTED) && defined(PNG_WRITE_SUPPORTED)\n      else if (!(png_ptr->mode & PNG_IS_READ_STRUCT))\n#  endif\n\n#  ifdef PNG_WRITE_SUPPORTED\n      {\n         if (error < PNG_CHUNK_WRITE_ERROR)\n            png_app_warning(png_ptr, message);\n\n         else\n            png_app_error(png_ptr, message);\n      }\n#  endif\n}\n\n#ifdef PNG_ERROR_TEXT_SUPPORTED\n#ifdef PNG_FLOATING_POINT_SUPPORTED\nPNG_FUNCTION(void,\npng_fixed_error,(png_const_structrp png_ptr, png_const_charp name),PNG_NORETURN)\n{\n#  define fixed_message \"fixed point overflow in \"\n#  define fixed_message_ln ((sizeof fixed_message)-1)\n   int  iin;\n   char msg[fixed_message_ln+PNG_MAX_ERROR_TEXT];\n   memcpy(msg, fixed_message, fixed_message_ln);\n   iin = 0;\n   if (name != NULL) while (iin < (PNG_MAX_ERROR_TEXT-1) && name[iin] != 0)\n   {\n      msg[fixed_message_ln + iin] = name[iin];\n      ++iin;\n   }\n   msg[fixed_message_ln + iin] = 0;\n   png_error(png_ptr, msg);\n}\n#endif\n#endif\n\n#ifdef PNG_SETJMP_SUPPORTED\n/* This API only exists if ANSI-C style error handling is used,\n * otherwise it is necessary for png_default_error to be overridden.\n */\njmp_buf* PNGAPI\npng_set_longjmp_fn(png_structrp png_ptr, png_longjmp_ptr longjmp_fn,\n    size_t jmp_buf_size)\n{\n   /* From libpng 1.6.0 the app gets one chance to set a 'jmpbuf_size' value\n    * and it must not change after that.  Libpng doesn't care how big the\n    * buffer is, just that it doesn't change.\n    *\n    * If the buffer size is no *larger* than the size of jmp_buf when libpng is\n    * compiled a built in jmp_buf is returned; this preserves the pre-1.6.0\n    * semantics that this call will not fail.  If the size is larger, however,\n    * the buffer is allocated and this may fail, causing the function to return\n    * NULL.\n    */\n   if (png_ptr == NULL)\n      return NULL;\n\n   if (png_ptr->jmp_buf_ptr == NULL)\n   {\n      png_ptr->jmp_buf_size = 0; /* not allocated */\n\n      if (jmp_buf_size <= (sizeof png_ptr->jmp_buf_local))\n         png_ptr->jmp_buf_ptr = &png_ptr->jmp_buf_local;\n\n      else\n      {\n         png_ptr->jmp_buf_ptr = png_voidcast(jmp_buf *,\n            png_malloc_warn(png_ptr, jmp_buf_size));\n\n         if (png_ptr->jmp_buf_ptr == NULL)\n            return NULL; /* new NULL return on OOM */\n\n         png_ptr->jmp_buf_size = jmp_buf_size;\n      }\n   }\n\n   else /* Already allocated: check the size */\n   {\n      size_t size = png_ptr->jmp_buf_size;\n\n      if (size == 0)\n      {\n         size = (sizeof png_ptr->jmp_buf_local);\n         if (png_ptr->jmp_buf_ptr != &png_ptr->jmp_buf_local)\n         {\n            /* This is an internal error in libpng: somehow we have been left\n             * with a stack allocated jmp_buf when the application regained\n             * control.  It's always possible to fix this up, but for the moment\n             * this is a png_error because that makes it easy to detect.\n             */\n            png_error(png_ptr, \"Libpng jmp_buf still allocated\");\n            /* png_ptr->jmp_buf_ptr = &png_ptr->jmp_buf_local; */\n         }\n      }\n\n      if (size != jmp_buf_size)\n      {\n         png_warning(png_ptr, \"Application jmp_buf size changed\");\n         return NULL; /* caller will probably crash: no choice here */\n      }\n   }\n\n   /* Finally fill in the function, now we have a satisfactory buffer. It is\n    * valid to change the function on every call.\n    */\n   png_ptr->longjmp_fn = longjmp_fn;\n   return png_ptr->jmp_buf_ptr;\n}\n\nvoid /* PRIVATE */\npng_free_jmpbuf(png_structrp png_ptr)\n{\n   if (png_ptr != NULL)\n   {\n      jmp_buf *jb = png_ptr->jmp_buf_ptr;\n\n      /* A size of 0 is used to indicate a local, stack, allocation of the\n       * pointer; used here and in png.c\n       */\n      if (jb != NULL && png_ptr->jmp_buf_size > 0)\n      {\n\n         /* This stuff is so that a failure to free the error control structure\n          * does not leave libpng in a state with no valid error handling: the\n          * free always succeeds, if there is an error it gets ignored.\n          */\n         if (jb != &png_ptr->jmp_buf_local)\n         {\n            /* Make an internal, libpng, jmp_buf to return here */\n            jmp_buf free_jmp_buf;\n\n            if (!setjmp(free_jmp_buf))\n            {\n               png_ptr->jmp_buf_ptr = &free_jmp_buf; /* come back here */\n               png_ptr->jmp_buf_size = 0; /* stack allocation */\n               png_ptr->longjmp_fn = longjmp;\n               png_free(png_ptr, jb); /* Return to setjmp on error */\n            }\n         }\n      }\n\n      /* *Always* cancel everything out: */\n      png_ptr->jmp_buf_size = 0;\n      png_ptr->jmp_buf_ptr = NULL;\n      png_ptr->longjmp_fn = 0;\n   }\n}\n#endif\n\n/* This is the default error handling function.  Note that replacements for\n * this function MUST NOT RETURN, or the program will likely crash.  This\n * function is used by default, or if the program supplies NULL for the\n * error function pointer in png_set_error_fn().\n */\nstatic PNG_FUNCTION(void /* PRIVATE */,\npng_default_error,(png_const_structrp png_ptr, png_const_charp error_message),\n   PNG_NORETURN)\n{\n#ifdef PNG_CONSOLE_IO_SUPPORTED\n#ifdef PNG_ERROR_NUMBERS_SUPPORTED\n   /* Check on NULL only added in 1.5.4 */\n   if (error_message != NULL && *error_message == PNG_LITERAL_SHARP)\n   {\n      /* Strip \"#nnnn \" from beginning of error message. */\n      int offset;\n      char error_number[16];\n      for (offset = 0; offset<15; offset++)\n      {\n         error_number[offset] = error_message[offset + 1];\n         if (error_message[offset] == ' ')\n            break;\n      }\n\n      if ((offset > 1) && (offset < 15))\n      {\n         error_number[offset - 1] = '\\0';\n         fprintf(stderr, \"libpng error no. %s: %s\",\n             error_number, error_message + offset + 1);\n         fprintf(stderr, PNG_STRING_NEWLINE);\n      }\n\n      else\n      {\n         fprintf(stderr, \"libpng error: %s, offset=%d\",\n             error_message, offset);\n         fprintf(stderr, PNG_STRING_NEWLINE);\n      }\n   }\n   else\n#endif\n   {\n      fprintf(stderr, \"libpng error: %s\", error_message ? error_message :\n         \"undefined\");\n      fprintf(stderr, PNG_STRING_NEWLINE);\n   }\n#else\n   PNG_UNUSED(error_message) /* Make compiler happy */\n#endif\n   png_longjmp(png_ptr, 1);\n}\n\nPNG_FUNCTION(void,PNGAPI\npng_longjmp,(png_const_structrp png_ptr, int val),PNG_NORETURN)\n{\n#ifdef PNG_SETJMP_SUPPORTED\n   if (png_ptr && png_ptr->longjmp_fn && png_ptr->jmp_buf_ptr)\n      png_ptr->longjmp_fn(*png_ptr->jmp_buf_ptr, val);\n#endif\n\n   /* If control reaches this point, png_longjmp() must not return. The only\n    * choice is to terminate the whole process (or maybe the thread); to do\n    * this the ANSI-C abort() function is used unless a different method is \n    * implemented by overriding the default configuration setting for\n    * PNG_ABORT().\n    */\n   PNG_ABORT();\n}\n\n#ifdef PNG_WARNINGS_SUPPORTED\n/* This function is called when there is a warning, but the library thinks\n * it can continue anyway.  Replacement functions don't have to do anything\n * here if you don't want them to.  In the default configuration, png_ptr is\n * not used, but it is passed in case it may be useful.\n */\nstatic void /* PRIVATE */\npng_default_warning(png_const_structrp png_ptr, png_const_charp warning_message)\n{\n#ifdef PNG_CONSOLE_IO_SUPPORTED\n#  ifdef PNG_ERROR_NUMBERS_SUPPORTED\n   if (*warning_message == PNG_LITERAL_SHARP)\n   {\n      int offset;\n      char warning_number[16];\n      for (offset = 0; offset < 15; offset++)\n      {\n         warning_number[offset] = warning_message[offset + 1];\n         if (warning_message[offset] == ' ')\n            break;\n      }\n\n      if ((offset > 1) && (offset < 15))\n      {\n         warning_number[offset + 1] = '\\0';\n         fprintf(stderr, \"libpng warning no. %s: %s\",\n             warning_number, warning_message + offset);\n         fprintf(stderr, PNG_STRING_NEWLINE);\n      }\n\n      else\n      {\n         fprintf(stderr, \"libpng warning: %s\",\n             warning_message);\n         fprintf(stderr, PNG_STRING_NEWLINE);\n      }\n   }\n   else\n#  endif\n\n   {\n      fprintf(stderr, \"libpng warning: %s\", warning_message);\n      fprintf(stderr, PNG_STRING_NEWLINE);\n   }\n#else\n   PNG_UNUSED(warning_message) /* Make compiler happy */\n#endif\n   PNG_UNUSED(png_ptr) /* Make compiler happy */\n}\n#endif /* PNG_WARNINGS_SUPPORTED */\n\n/* This function is called when the application wants to use another method\n * of handling errors and warnings.  Note that the error function MUST NOT\n * return to the calling routine or serious problems will occur.  The return\n * method used in the default routine calls longjmp(png_ptr->jmp_buf_ptr, 1)\n */\nvoid PNGAPI\npng_set_error_fn(png_structrp png_ptr, png_voidp error_ptr,\n    png_error_ptr error_fn, png_error_ptr warning_fn)\n{\n   if (png_ptr == NULL)\n      return;\n\n   png_ptr->error_ptr = error_ptr;\n   png_ptr->error_fn = error_fn;\n#ifdef PNG_WARNINGS_SUPPORTED\n   png_ptr->warning_fn = warning_fn;\n#else\n   PNG_UNUSED(warning_fn)\n#endif\n}\n\n\n/* This function returns a pointer to the error_ptr associated with the user\n * functions.  The application should free any memory associated with this\n * pointer before png_write_destroy and png_read_destroy are called.\n */\npng_voidp PNGAPI\npng_get_error_ptr(png_const_structrp png_ptr)\n{\n   if (png_ptr == NULL)\n      return NULL;\n\n   return ((png_voidp)png_ptr->error_ptr);\n}\n\n\n#ifdef PNG_ERROR_NUMBERS_SUPPORTED\nvoid PNGAPI\npng_set_strip_error_numbers(png_structrp png_ptr, png_uint_32 strip_mode)\n{\n   if (png_ptr != NULL)\n   {\n      png_ptr->flags &=\n         ((~(PNG_FLAG_STRIP_ERROR_NUMBERS |\n         PNG_FLAG_STRIP_ERROR_TEXT))&strip_mode);\n   }\n}\n#endif\n\n#if defined(PNG_SIMPLIFIED_READ_SUPPORTED) ||\\\n   defined(PNG_SIMPLIFIED_WRITE_SUPPORTED)\n   /* Currently the above both depend on SETJMP_SUPPORTED, however it would be\n    * possible to implement without setjmp support just so long as there is some\n    * way to handle the error return here:\n    */\nPNG_FUNCTION(void /* PRIVATE */, (PNGCBAPI\npng_safe_error),(png_structp png_nonconst_ptr, png_const_charp error_message),\n   PNG_NORETURN)\n{\n   const png_const_structrp png_ptr = png_nonconst_ptr;\n   png_imagep image = png_voidcast(png_imagep, png_ptr->error_ptr);\n\n   /* An error is always logged here, overwriting anything (typically a warning)\n    * that is already there:\n    */\n   if (image != NULL)\n   {\n      png_safecat(image->message, (sizeof image->message), 0, error_message);\n      image->warning_or_error |= PNG_IMAGE_ERROR;\n\n      /* Retrieve the jmp_buf from within the png_control, making this work for\n       * C++ compilation too is pretty tricky: C++ wants a pointer to the first\n       * element of a jmp_buf, but C doesn't tell us the type of that.\n       */\n      if (image->opaque != NULL && image->opaque->error_buf != NULL)\n         longjmp(png_control_jmp_buf(image->opaque), 1);\n\n      /* Missing longjmp buffer, the following is to help debugging: */\n      {\n         size_t pos = png_safecat(image->message, (sizeof image->message), 0,\n            \"bad longjmp: \");\n         png_safecat(image->message, (sizeof image->message), pos,\n             error_message);\n      }\n   }\n\n   /* Here on an internal programming error. */\n   abort();\n}\n\n#ifdef PNG_WARNINGS_SUPPORTED\nvoid /* PRIVATE */ PNGCBAPI\npng_safe_warning(png_structp png_nonconst_ptr, png_const_charp warning_message)\n{\n   const png_const_structrp png_ptr = png_nonconst_ptr;\n   png_imagep image = png_voidcast(png_imagep, png_ptr->error_ptr);\n\n   /* A warning is only logged if there is no prior warning or error. */\n   if (image->warning_or_error == 0)\n   {\n      png_safecat(image->message, (sizeof image->message), 0, warning_message);\n      image->warning_or_error |= PNG_IMAGE_WARNING;\n   }\n}\n#endif\n\nint /* PRIVATE */\npng_safe_execute(png_imagep image_in, int (*function)(png_voidp), png_voidp arg)\n{\n   volatile png_imagep image = image_in;\n   volatile int result;\n   volatile png_voidp saved_error_buf;\n   jmp_buf safe_jmpbuf;\n\n   /* Safely execute function(arg) with png_error returning to this function. */\n   saved_error_buf = image->opaque->error_buf;\n   result = setjmp(safe_jmpbuf) == 0;\n\n   if (result)\n   {\n\n      image->opaque->error_buf = safe_jmpbuf;\n      result = function(arg);\n   }\n\n   image->opaque->error_buf = saved_error_buf;\n\n   /* And do the cleanup prior to any failure return. */\n   if (!result)\n      png_image_free(image);\n\n   return result;\n}\n#endif /* SIMPLIFIED READ/WRITE */\n#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */\n"
  },
  {
    "path": "Projects/Libraries/CSBase/Source/png/pngget.c",
    "content": "\n/* pngget.c - retrieval of values from info struct\n *\n * Last changed in libpng 1.6.1 [March 28, 2013]\n * Copyright (c) 1998-2013 Glenn Randers-Pehrson\n * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)\n * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)\n *\n * This code is released under the libpng license.\n * For conditions of distribution and use, see the disclaimer\n * and license in png.h\n *\n */\n\n#include \"pngpriv.h\"\n\n#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)\n\npng_uint_32 PNGAPI\npng_get_valid(png_const_structrp png_ptr, png_const_inforp info_ptr,\n    png_uint_32 flag)\n{\n   if (png_ptr != NULL && info_ptr != NULL)\n      return(info_ptr->valid & flag);\n\n   return(0);\n}\n\npng_size_t PNGAPI\npng_get_rowbytes(png_const_structrp png_ptr, png_const_inforp info_ptr)\n{\n   if (png_ptr != NULL && info_ptr != NULL)\n      return(info_ptr->rowbytes);\n\n   return(0);\n}\n\n#ifdef PNG_INFO_IMAGE_SUPPORTED\npng_bytepp PNGAPI\npng_get_rows(png_const_structrp png_ptr, png_const_inforp info_ptr)\n{\n   if (png_ptr != NULL && info_ptr != NULL)\n      return(info_ptr->row_pointers);\n\n   return(0);\n}\n#endif\n\n#ifdef PNG_EASY_ACCESS_SUPPORTED\n/* Easy access to info, added in libpng-0.99 */\npng_uint_32 PNGAPI\npng_get_image_width(png_const_structrp png_ptr, png_const_inforp info_ptr)\n{\n   if (png_ptr != NULL && info_ptr != NULL)\n      return info_ptr->width;\n\n   return (0);\n}\n\npng_uint_32 PNGAPI\npng_get_image_height(png_const_structrp png_ptr, png_const_inforp info_ptr)\n{\n   if (png_ptr != NULL && info_ptr != NULL)\n      return info_ptr->height;\n\n   return (0);\n}\n\npng_byte PNGAPI\npng_get_bit_depth(png_const_structrp png_ptr, png_const_inforp info_ptr)\n{\n   if (png_ptr != NULL && info_ptr != NULL)\n      return info_ptr->bit_depth;\n\n   return (0);\n}\n\npng_byte PNGAPI\npng_get_color_type(png_const_structrp png_ptr, png_const_inforp info_ptr)\n{\n   if (png_ptr != NULL && info_ptr != NULL)\n      return info_ptr->color_type;\n\n   return (0);\n}\n\npng_byte PNGAPI\npng_get_filter_type(png_const_structrp png_ptr, png_const_inforp info_ptr)\n{\n   if (png_ptr != NULL && info_ptr != NULL)\n      return info_ptr->filter_type;\n\n   return (0);\n}\n\npng_byte PNGAPI\npng_get_interlace_type(png_const_structrp png_ptr, png_const_inforp info_ptr)\n{\n   if (png_ptr != NULL && info_ptr != NULL)\n      return info_ptr->interlace_type;\n\n   return (0);\n}\n\npng_byte PNGAPI\npng_get_compression_type(png_const_structrp png_ptr, png_const_inforp info_ptr)\n{\n   if (png_ptr != NULL && info_ptr != NULL)\n      return info_ptr->compression_type;\n\n   return (0);\n}\n\npng_uint_32 PNGAPI\npng_get_x_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp\n   info_ptr)\n{\n#ifdef PNG_pHYs_SUPPORTED\n   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))\n      {\n         png_debug1(1, \"in %s retrieval function\",\n             \"png_get_x_pixels_per_meter\");\n\n         if (info_ptr->phys_unit_type == PNG_RESOLUTION_METER)\n            return (info_ptr->x_pixels_per_unit);\n      }\n#endif\n\n   return (0);\n}\n\npng_uint_32 PNGAPI\npng_get_y_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp\n    info_ptr)\n{\n#ifdef PNG_pHYs_SUPPORTED\n   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))\n   {\n      png_debug1(1, \"in %s retrieval function\",\n          \"png_get_y_pixels_per_meter\");\n\n      if (info_ptr->phys_unit_type == PNG_RESOLUTION_METER)\n         return (info_ptr->y_pixels_per_unit);\n   }\n#endif\n\n   return (0);\n}\n\npng_uint_32 PNGAPI\npng_get_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp info_ptr)\n{\n#ifdef PNG_pHYs_SUPPORTED\n   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))\n   {\n      png_debug1(1, \"in %s retrieval function\", \"png_get_pixels_per_meter\");\n\n      if (info_ptr->phys_unit_type == PNG_RESOLUTION_METER &&\n          info_ptr->x_pixels_per_unit == info_ptr->y_pixels_per_unit)\n         return (info_ptr->x_pixels_per_unit);\n   }\n#endif\n\n   return (0);\n}\n\n#ifdef PNG_FLOATING_POINT_SUPPORTED\nfloat PNGAPI\npng_get_pixel_aspect_ratio(png_const_structrp png_ptr, png_const_inforp\n   info_ptr)\n{\n#ifdef PNG_READ_pHYs_SUPPORTED\n   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))\n   {\n      png_debug1(1, \"in %s retrieval function\", \"png_get_aspect_ratio\");\n\n      if (info_ptr->x_pixels_per_unit != 0)\n         return ((float)((float)info_ptr->y_pixels_per_unit\n             /(float)info_ptr->x_pixels_per_unit));\n   }\n#else\n   PNG_UNUSED(png_ptr)\n   PNG_UNUSED(info_ptr)\n#endif\n\n   return ((float)0.0);\n}\n#endif\n\n#ifdef PNG_FIXED_POINT_SUPPORTED\npng_fixed_point PNGAPI\npng_get_pixel_aspect_ratio_fixed(png_const_structrp png_ptr,\n    png_const_inforp info_ptr)\n{\n#ifdef PNG_READ_pHYs_SUPPORTED\n   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs)\n       && info_ptr->x_pixels_per_unit > 0 && info_ptr->y_pixels_per_unit > 0\n       && info_ptr->x_pixels_per_unit <= PNG_UINT_31_MAX\n       && info_ptr->y_pixels_per_unit <= PNG_UINT_31_MAX)\n   {\n      png_fixed_point res;\n\n      png_debug1(1, \"in %s retrieval function\", \"png_get_aspect_ratio_fixed\");\n\n      /* The following casts work because a PNG 4 byte integer only has a valid\n       * range of 0..2^31-1; otherwise the cast might overflow.\n       */\n      if (png_muldiv(&res, (png_int_32)info_ptr->y_pixels_per_unit, PNG_FP_1,\n          (png_int_32)info_ptr->x_pixels_per_unit))\n         return res;\n   }\n#else\n   PNG_UNUSED(png_ptr)\n   PNG_UNUSED(info_ptr)\n#endif\n\n   return 0;\n}\n#endif\n\npng_int_32 PNGAPI\npng_get_x_offset_microns(png_const_structrp png_ptr, png_const_inforp info_ptr)\n{\n#ifdef PNG_oFFs_SUPPORTED\n   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs))\n   {\n      png_debug1(1, \"in %s retrieval function\", \"png_get_x_offset_microns\");\n\n      if (info_ptr->offset_unit_type == PNG_OFFSET_MICROMETER)\n         return (info_ptr->x_offset);\n   }\n#endif\n\n   return (0);\n}\n\npng_int_32 PNGAPI\npng_get_y_offset_microns(png_const_structrp png_ptr, png_const_inforp info_ptr)\n{\n#ifdef PNG_oFFs_SUPPORTED\n   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs))\n   {\n      png_debug1(1, \"in %s retrieval function\", \"png_get_y_offset_microns\");\n\n      if (info_ptr->offset_unit_type == PNG_OFFSET_MICROMETER)\n         return (info_ptr->y_offset);\n   }\n#endif\n\n   return (0);\n}\n\npng_int_32 PNGAPI\npng_get_x_offset_pixels(png_const_structrp png_ptr, png_const_inforp info_ptr)\n{\n#ifdef PNG_oFFs_SUPPORTED\n   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs))\n   {\n      png_debug1(1, \"in %s retrieval function\", \"png_get_x_offset_pixels\");\n\n      if (info_ptr->offset_unit_type == PNG_OFFSET_PIXEL)\n         return (info_ptr->x_offset);\n   }\n#endif\n\n   return (0);\n}\n\npng_int_32 PNGAPI\npng_get_y_offset_pixels(png_const_structrp png_ptr, png_const_inforp info_ptr)\n{\n#ifdef PNG_oFFs_SUPPORTED\n   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs))\n   {\n      png_debug1(1, \"in %s retrieval function\", \"png_get_y_offset_pixels\");\n\n      if (info_ptr->offset_unit_type == PNG_OFFSET_PIXEL)\n         return (info_ptr->y_offset);\n   }\n#endif\n\n   return (0);\n}\n\n#ifdef PNG_INCH_CONVERSIONS_SUPPORTED\nstatic png_uint_32\nppi_from_ppm(png_uint_32 ppm)\n{\n#if 0\n   /* The conversion is *(2.54/100), in binary (32 digits):\n    * .00000110100000001001110101001001\n    */\n   png_uint_32 t1001, t1101;\n   ppm >>= 1;                  /* .1 */\n   t1001 = ppm + (ppm >> 3);   /* .1001 */\n   t1101 = t1001 + (ppm >> 1); /* .1101 */\n   ppm >>= 20;                 /* .000000000000000000001 */\n   t1101 += t1101 >> 15;       /* .1101000000000001101 */\n   t1001 >>= 11;               /* .000000000001001 */\n   t1001 += t1001 >> 12;       /* .000000000001001000000001001 */\n   ppm += t1001;               /* .000000000001001000001001001 */\n   ppm += t1101;               /* .110100000001001110101001001 */\n   return (ppm + 16) >> 5;/* .00000110100000001001110101001001 */\n#else\n   /* The argument is a PNG unsigned integer, so it is not permitted\n    * to be bigger than 2^31.\n    */\n   png_fixed_point result;\n   if (ppm <= PNG_UINT_31_MAX && png_muldiv(&result, (png_int_32)ppm, 127,\n       5000))\n      return result;\n\n   /* Overflow. */\n   return 0;\n#endif\n}\n\npng_uint_32 PNGAPI\npng_get_pixels_per_inch(png_const_structrp png_ptr, png_const_inforp info_ptr)\n{\n   return ppi_from_ppm(png_get_pixels_per_meter(png_ptr, info_ptr));\n}\n\npng_uint_32 PNGAPI\npng_get_x_pixels_per_inch(png_const_structrp png_ptr, png_const_inforp info_ptr)\n{\n   return ppi_from_ppm(png_get_x_pixels_per_meter(png_ptr, info_ptr));\n}\n\npng_uint_32 PNGAPI\npng_get_y_pixels_per_inch(png_const_structrp png_ptr, png_const_inforp info_ptr)\n{\n   return ppi_from_ppm(png_get_y_pixels_per_meter(png_ptr, info_ptr));\n}\n\n#ifdef PNG_FIXED_POINT_SUPPORTED\nstatic png_fixed_point\npng_fixed_inches_from_microns(png_const_structrp png_ptr, png_int_32 microns)\n{\n   /* Convert from metres * 1,000,000 to inches * 100,000, meters to\n    * inches is simply *(100/2.54), so we want *(10/2.54) == 500/127.\n    * Notice that this can overflow - a warning is output and 0 is\n    * returned.\n    */\n   return png_muldiv_warn(png_ptr, microns, 500, 127);\n}\n\npng_fixed_point PNGAPI\npng_get_x_offset_inches_fixed(png_const_structrp png_ptr,\n    png_const_inforp info_ptr)\n{\n   return png_fixed_inches_from_microns(png_ptr,\n       png_get_x_offset_microns(png_ptr, info_ptr));\n}\n#endif\n\n#ifdef PNG_FIXED_POINT_SUPPORTED\npng_fixed_point PNGAPI\npng_get_y_offset_inches_fixed(png_const_structrp png_ptr,\n    png_const_inforp info_ptr)\n{\n   return png_fixed_inches_from_microns(png_ptr,\n       png_get_y_offset_microns(png_ptr, info_ptr));\n}\n#endif\n\n#ifdef PNG_FLOATING_POINT_SUPPORTED\nfloat PNGAPI\npng_get_x_offset_inches(png_const_structrp png_ptr, png_const_inforp info_ptr)\n{\n   /* To avoid the overflow do the conversion directly in floating\n    * point.\n    */\n   return (float)(png_get_x_offset_microns(png_ptr, info_ptr) * .00003937);\n}\n#endif\n\n#ifdef PNG_FLOATING_POINT_SUPPORTED\nfloat PNGAPI\npng_get_y_offset_inches(png_const_structrp png_ptr, png_const_inforp info_ptr)\n{\n   /* To avoid the overflow do the conversion directly in floating\n    * point.\n    */\n   return (float)(png_get_y_offset_microns(png_ptr, info_ptr) * .00003937);\n}\n#endif\n\n#ifdef PNG_pHYs_SUPPORTED\npng_uint_32 PNGAPI\npng_get_pHYs_dpi(png_const_structrp png_ptr, png_const_inforp info_ptr,\n    png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)\n{\n   png_uint_32 retval = 0;\n\n   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))\n   {\n      png_debug1(1, \"in %s retrieval function\", \"pHYs\");\n\n      if (res_x != NULL)\n      {\n         *res_x = info_ptr->x_pixels_per_unit;\n         retval |= PNG_INFO_pHYs;\n      }\n\n      if (res_y != NULL)\n      {\n         *res_y = info_ptr->y_pixels_per_unit;\n         retval |= PNG_INFO_pHYs;\n      }\n\n      if (unit_type != NULL)\n      {\n         *unit_type = (int)info_ptr->phys_unit_type;\n         retval |= PNG_INFO_pHYs;\n\n         if (*unit_type == 1)\n         {\n            if (res_x != NULL) *res_x = (png_uint_32)(*res_x * .0254 + .50);\n            if (res_y != NULL) *res_y = (png_uint_32)(*res_y * .0254 + .50);\n         }\n      }\n   }\n\n   return (retval);\n}\n#endif /* PNG_pHYs_SUPPORTED */\n#endif  /* PNG_INCH_CONVERSIONS_SUPPORTED */\n\n/* png_get_channels really belongs in here, too, but it's been around longer */\n\n#endif  /* PNG_EASY_ACCESS_SUPPORTED */\n\n\npng_byte PNGAPI\npng_get_channels(png_const_structrp png_ptr, png_const_inforp info_ptr)\n{\n   if (png_ptr != NULL && info_ptr != NULL)\n      return(info_ptr->channels);\n\n   return (0);\n}\n\n#ifdef PNG_READ_SUPPORTED\npng_const_bytep PNGAPI\npng_get_signature(png_const_structrp png_ptr, png_const_inforp info_ptr)\n{\n   if (png_ptr != NULL && info_ptr != NULL)\n      return(info_ptr->signature);\n\n   return (NULL);\n}\n#endif\n\n#ifdef PNG_bKGD_SUPPORTED\npng_uint_32 PNGAPI\npng_get_bKGD(png_const_structrp png_ptr, png_inforp info_ptr,\n   png_color_16p *background)\n{\n   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_bKGD)\n       && background != NULL)\n   {\n      png_debug1(1, \"in %s retrieval function\", \"bKGD\");\n\n      *background = &(info_ptr->background);\n      return (PNG_INFO_bKGD);\n   }\n\n   return (0);\n}\n#endif\n\n#ifdef PNG_cHRM_SUPPORTED\n/* The XYZ APIs were added in 1.5.5 to take advantage of the code added at the\n * same time to correct the rgb grayscale coefficient defaults obtained from the\n * cHRM chunk in 1.5.4\n */\n#  ifdef PNG_FLOATING_POINT_SUPPORTED\npng_uint_32 PNGAPI\npng_get_cHRM(png_const_structrp png_ptr, png_const_inforp info_ptr,\n    double *white_x, double *white_y, double *red_x, double *red_y,\n    double *green_x, double *green_y, double *blue_x, double *blue_y)\n{\n   /* Quiet API change: this code used to only return the end points if a cHRM\n    * chunk was present, but the end points can also come from iCCP or sRGB\n    * chunks, so in 1.6.0 the png_get_ APIs return the end points regardless and\n    * the png_set_ APIs merely check that set end points are mutually\n    * consistent.\n    */\n   if (png_ptr != NULL && info_ptr != NULL &&\n      (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS))\n   {\n      png_debug1(1, \"in %s retrieval function\", \"cHRM\");\n\n      if (white_x != NULL)\n         *white_x = png_float(png_ptr,\n            info_ptr->colorspace.end_points_xy.whitex, \"cHRM white X\");\n      if (white_y != NULL)\n         *white_y = png_float(png_ptr,\n            info_ptr->colorspace.end_points_xy.whitey, \"cHRM white Y\");\n      if (red_x != NULL)\n         *red_x = png_float(png_ptr, info_ptr->colorspace.end_points_xy.redx,\n            \"cHRM red X\");\n      if (red_y != NULL)\n         *red_y = png_float(png_ptr, info_ptr->colorspace.end_points_xy.redy,\n            \"cHRM red Y\");\n      if (green_x != NULL)\n         *green_x = png_float(png_ptr,\n            info_ptr->colorspace.end_points_xy.greenx, \"cHRM green X\");\n      if (green_y != NULL)\n         *green_y = png_float(png_ptr,\n            info_ptr->colorspace.end_points_xy.greeny, \"cHRM green Y\");\n      if (blue_x != NULL)\n         *blue_x = png_float(png_ptr, info_ptr->colorspace.end_points_xy.bluex,\n            \"cHRM blue X\");\n      if (blue_y != NULL)\n         *blue_y = png_float(png_ptr, info_ptr->colorspace.end_points_xy.bluey,\n            \"cHRM blue Y\");\n      return (PNG_INFO_cHRM);\n   }\n\n   return (0);\n}\n\npng_uint_32 PNGAPI\npng_get_cHRM_XYZ(png_const_structrp png_ptr, png_const_inforp info_ptr,\n   double *red_X, double *red_Y, double *red_Z, double *green_X,\n   double *green_Y, double *green_Z, double *blue_X, double *blue_Y,\n   double *blue_Z)\n{\n   if (png_ptr != NULL && info_ptr != NULL &&\n      (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS))\n   {\n      png_debug1(1, \"in %s retrieval function\", \"cHRM_XYZ(float)\");\n\n      if (red_X != NULL)\n         *red_X = png_float(png_ptr, info_ptr->colorspace.end_points_XYZ.red_X,\n            \"cHRM red X\");\n      if (red_Y != NULL)\n         *red_Y = png_float(png_ptr, info_ptr->colorspace.end_points_XYZ.red_Y,\n            \"cHRM red Y\");\n      if (red_Z != NULL)\n         *red_Z = png_float(png_ptr, info_ptr->colorspace.end_points_XYZ.red_Z,\n            \"cHRM red Z\");\n      if (green_X != NULL)\n         *green_X = png_float(png_ptr,\n            info_ptr->colorspace.end_points_XYZ.green_X, \"cHRM green X\");\n      if (green_Y != NULL)\n         *green_Y = png_float(png_ptr,\n            info_ptr->colorspace.end_points_XYZ.green_Y, \"cHRM green Y\");\n      if (green_Z != NULL)\n         *green_Z = png_float(png_ptr,\n            info_ptr->colorspace.end_points_XYZ.green_Z, \"cHRM green Z\");\n      if (blue_X != NULL)\n         *blue_X = png_float(png_ptr,\n            info_ptr->colorspace.end_points_XYZ.blue_X, \"cHRM blue X\");\n      if (blue_Y != NULL)\n         *blue_Y = png_float(png_ptr,\n            info_ptr->colorspace.end_points_XYZ.blue_Y, \"cHRM blue Y\");\n      if (blue_Z != NULL)\n         *blue_Z = png_float(png_ptr,\n            info_ptr->colorspace.end_points_XYZ.blue_Z, \"cHRM blue Z\");\n      return (PNG_INFO_cHRM);\n   }\n\n   return (0);\n}\n#  endif\n\n#  ifdef PNG_FIXED_POINT_SUPPORTED\npng_uint_32 PNGAPI\npng_get_cHRM_XYZ_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,\n    png_fixed_point *int_red_X, png_fixed_point *int_red_Y,\n    png_fixed_point *int_red_Z, png_fixed_point *int_green_X,\n    png_fixed_point *int_green_Y, png_fixed_point *int_green_Z,\n    png_fixed_point *int_blue_X, png_fixed_point *int_blue_Y,\n    png_fixed_point *int_blue_Z)\n{\n   if (png_ptr != NULL && info_ptr != NULL &&\n      (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS))\n   {\n      png_debug1(1, \"in %s retrieval function\", \"cHRM_XYZ\");\n\n      if (int_red_X != NULL)\n         *int_red_X = info_ptr->colorspace.end_points_XYZ.red_X;\n      if (int_red_Y != NULL)\n         *int_red_Y = info_ptr->colorspace.end_points_XYZ.red_Y;\n      if (int_red_Z != NULL)\n         *int_red_Z = info_ptr->colorspace.end_points_XYZ.red_Z;\n      if (int_green_X != NULL)\n         *int_green_X = info_ptr->colorspace.end_points_XYZ.green_X;\n      if (int_green_Y != NULL)\n         *int_green_Y = info_ptr->colorspace.end_points_XYZ.green_Y;\n      if (int_green_Z != NULL)\n         *int_green_Z = info_ptr->colorspace.end_points_XYZ.green_Z;\n      if (int_blue_X != NULL)\n         *int_blue_X = info_ptr->colorspace.end_points_XYZ.blue_X;\n      if (int_blue_Y != NULL)\n         *int_blue_Y = info_ptr->colorspace.end_points_XYZ.blue_Y;\n      if (int_blue_Z != NULL)\n         *int_blue_Z = info_ptr->colorspace.end_points_XYZ.blue_Z;\n      return (PNG_INFO_cHRM);\n   }\n\n   return (0);\n}\n\npng_uint_32 PNGAPI\npng_get_cHRM_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,\n    png_fixed_point *white_x, png_fixed_point *white_y, png_fixed_point *red_x,\n    png_fixed_point *red_y, png_fixed_point *green_x, png_fixed_point *green_y,\n    png_fixed_point *blue_x, png_fixed_point *blue_y)\n{\n   png_debug1(1, \"in %s retrieval function\", \"cHRM\");\n\n   if (png_ptr != NULL && info_ptr != NULL &&\n      (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS))\n   {\n      if (white_x != NULL)\n         *white_x = info_ptr->colorspace.end_points_xy.whitex;\n      if (white_y != NULL)\n         *white_y = info_ptr->colorspace.end_points_xy.whitey;\n      if (red_x != NULL)\n         *red_x = info_ptr->colorspace.end_points_xy.redx;\n      if (red_y != NULL)\n         *red_y = info_ptr->colorspace.end_points_xy.redy;\n      if (green_x != NULL)\n         *green_x = info_ptr->colorspace.end_points_xy.greenx;\n      if (green_y != NULL)\n         *green_y = info_ptr->colorspace.end_points_xy.greeny;\n      if (blue_x != NULL)\n         *blue_x = info_ptr->colorspace.end_points_xy.bluex;\n      if (blue_y != NULL)\n         *blue_y = info_ptr->colorspace.end_points_xy.bluey;\n      return (PNG_INFO_cHRM);\n   }\n\n   return (0);\n}\n#  endif\n#endif\n\n#ifdef PNG_gAMA_SUPPORTED\n#  ifdef PNG_FIXED_POINT_SUPPORTED\npng_uint_32 PNGAPI\npng_get_gAMA_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,\n    png_fixed_point *file_gamma)\n{\n   png_debug1(1, \"in %s retrieval function\", \"gAMA\");\n\n   if (png_ptr != NULL && info_ptr != NULL &&\n      (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_GAMMA) &&\n      file_gamma != NULL)\n   {\n      *file_gamma = info_ptr->colorspace.gamma;\n      return (PNG_INFO_gAMA);\n   }\n\n   return (0);\n}\n#  endif\n\n#  ifdef PNG_FLOATING_POINT_SUPPORTED\npng_uint_32 PNGAPI\npng_get_gAMA(png_const_structrp png_ptr, png_const_inforp info_ptr,\n    double *file_gamma)\n{\n   png_debug1(1, \"in %s retrieval function\", \"gAMA(float)\");\n\n   if (png_ptr != NULL && info_ptr != NULL &&\n      (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_GAMMA) &&\n      file_gamma != NULL)\n   {\n      *file_gamma = png_float(png_ptr, info_ptr->colorspace.gamma,\n         \"png_get_gAMA\");\n      return (PNG_INFO_gAMA);\n   }\n\n   return (0);\n}\n#  endif\n#endif\n\n#ifdef PNG_sRGB_SUPPORTED\npng_uint_32 PNGAPI\npng_get_sRGB(png_const_structrp png_ptr, png_const_inforp info_ptr,\n    int *file_srgb_intent)\n{\n   png_debug1(1, \"in %s retrieval function\", \"sRGB\");\n\n   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sRGB)\n       && file_srgb_intent != NULL)\n   {\n      *file_srgb_intent = info_ptr->colorspace.rendering_intent;\n      return (PNG_INFO_sRGB);\n   }\n\n   return (0);\n}\n#endif\n\n#ifdef PNG_iCCP_SUPPORTED\npng_uint_32 PNGAPI\npng_get_iCCP(png_const_structrp png_ptr, png_inforp info_ptr,\n    png_charpp name, int *compression_type,\n    png_bytepp profile, png_uint_32 *proflen)\n{\n   png_debug1(1, \"in %s retrieval function\", \"iCCP\");\n\n   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_iCCP)\n       && name != NULL && compression_type != NULL && profile != NULL &&\n\t\t proflen != NULL)\n   {\n      *name = info_ptr->iccp_name;\n      *profile = info_ptr->iccp_profile;\n      *proflen = png_get_uint_32(info_ptr->iccp_profile);\n      /* This is somewhat irrelevant since the profile data returned has\n       * actually been uncompressed.\n       */\n      *compression_type = PNG_COMPRESSION_TYPE_BASE;\n      return (PNG_INFO_iCCP);\n   }\n\n   return (0);\n}\n#endif\n\n#ifdef PNG_sPLT_SUPPORTED\nint PNGAPI\npng_get_sPLT(png_const_structrp png_ptr, png_inforp info_ptr,\n    png_sPLT_tpp spalettes)\n{\n   if (png_ptr != NULL && info_ptr != NULL && spalettes != NULL)\n   {\n      *spalettes = info_ptr->splt_palettes;\n      return info_ptr->splt_palettes_num;\n   }\n\n   return (0);\n}\n#endif\n\n#ifdef PNG_hIST_SUPPORTED\npng_uint_32 PNGAPI\npng_get_hIST(png_const_structrp png_ptr, png_inforp info_ptr,\n    png_uint_16p *hist)\n{\n   png_debug1(1, \"in %s retrieval function\", \"hIST\");\n\n   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_hIST)\n       && hist != NULL)\n   {\n      *hist = info_ptr->hist;\n      return (PNG_INFO_hIST);\n   }\n\n   return (0);\n}\n#endif\n\npng_uint_32 PNGAPI\npng_get_IHDR(png_const_structrp png_ptr, png_const_inforp info_ptr,\n    png_uint_32 *width, png_uint_32 *height, int *bit_depth,\n    int *color_type, int *interlace_type, int *compression_type,\n    int *filter_type)\n{\n   png_debug1(1, \"in %s retrieval function\", \"IHDR\");\n\n   if (png_ptr == NULL || info_ptr == NULL || width == NULL ||\n       height == NULL || bit_depth == NULL || color_type == NULL)\n      return (0);\n\n   *width = info_ptr->width;\n   *height = info_ptr->height;\n   *bit_depth = info_ptr->bit_depth;\n   *color_type = info_ptr->color_type;\n\n   if (compression_type != NULL)\n      *compression_type = info_ptr->compression_type;\n\n   if (filter_type != NULL)\n      *filter_type = info_ptr->filter_type;\n\n   if (interlace_type != NULL)\n      *interlace_type = info_ptr->interlace_type;\n\n   /* This is redundant if we can be sure that the info_ptr values were all\n    * assigned in png_set_IHDR().  We do the check anyhow in case an\n    * application has ignored our advice not to mess with the members\n    * of info_ptr directly.\n    */\n   png_check_IHDR(png_ptr, info_ptr->width, info_ptr->height,\n       info_ptr->bit_depth, info_ptr->color_type, info_ptr->interlace_type,\n       info_ptr->compression_type, info_ptr->filter_type);\n\n   return (1);\n}\n\n#ifdef PNG_oFFs_SUPPORTED\npng_uint_32 PNGAPI\npng_get_oFFs(png_const_structrp png_ptr, png_const_inforp info_ptr,\n    png_int_32 *offset_x, png_int_32 *offset_y, int *unit_type)\n{\n   png_debug1(1, \"in %s retrieval function\", \"oFFs\");\n\n   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs)\n       && offset_x != NULL && offset_y != NULL && unit_type != NULL)\n   {\n      *offset_x = info_ptr->x_offset;\n      *offset_y = info_ptr->y_offset;\n      *unit_type = (int)info_ptr->offset_unit_type;\n      return (PNG_INFO_oFFs);\n   }\n\n   return (0);\n}\n#endif\n\n#ifdef PNG_pCAL_SUPPORTED\npng_uint_32 PNGAPI\npng_get_pCAL(png_const_structrp png_ptr, png_inforp info_ptr,\n    png_charp *purpose, png_int_32 *X0, png_int_32 *X1, int *type, int *nparams,\n    png_charp *units, png_charpp *params)\n{\n   png_debug1(1, \"in %s retrieval function\", \"pCAL\");\n\n   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pCAL)\n       && purpose != NULL && X0 != NULL && X1 != NULL && type != NULL &&\n       nparams != NULL && units != NULL && params != NULL)\n   {\n      *purpose = info_ptr->pcal_purpose;\n      *X0 = info_ptr->pcal_X0;\n      *X1 = info_ptr->pcal_X1;\n      *type = (int)info_ptr->pcal_type;\n      *nparams = (int)info_ptr->pcal_nparams;\n      *units = info_ptr->pcal_units;\n      *params = info_ptr->pcal_params;\n      return (PNG_INFO_pCAL);\n   }\n\n   return (0);\n}\n#endif\n\n#ifdef PNG_sCAL_SUPPORTED\n#  ifdef PNG_FIXED_POINT_SUPPORTED\n#    if defined(PNG_FLOATING_ARITHMETIC_SUPPORTED) || \\\n         defined(PNG_FLOATING_POINT_SUPPORTED)\npng_uint_32 PNGAPI\npng_get_sCAL_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,\n    int *unit, png_fixed_point *width, png_fixed_point *height)\n{\n   if (png_ptr != NULL && info_ptr != NULL &&\n       (info_ptr->valid & PNG_INFO_sCAL))\n   {\n      *unit = info_ptr->scal_unit;\n      /*TODO: make this work without FP support; the API is currently eliminated\n       * if neither floating point APIs nor internal floating point arithmetic\n       * are enabled.\n       */\n      *width = png_fixed(png_ptr, atof(info_ptr->scal_s_width), \"sCAL width\");\n      *height = png_fixed(png_ptr, atof(info_ptr->scal_s_height),\n         \"sCAL height\");\n      return (PNG_INFO_sCAL);\n   }\n\n   return(0);\n}\n#    endif /* FLOATING_ARITHMETIC */\n#  endif /* FIXED_POINT */\n#  ifdef PNG_FLOATING_POINT_SUPPORTED\npng_uint_32 PNGAPI\npng_get_sCAL(png_const_structrp png_ptr, png_const_inforp info_ptr,\n    int *unit, double *width, double *height)\n{\n   if (png_ptr != NULL && info_ptr != NULL &&\n       (info_ptr->valid & PNG_INFO_sCAL))\n   {\n      *unit = info_ptr->scal_unit;\n      *width = atof(info_ptr->scal_s_width);\n      *height = atof(info_ptr->scal_s_height);\n      return (PNG_INFO_sCAL);\n   }\n\n   return(0);\n}\n#  endif /* FLOATING POINT */\npng_uint_32 PNGAPI\npng_get_sCAL_s(png_const_structrp png_ptr, png_const_inforp info_ptr,\n    int *unit, png_charpp width, png_charpp height)\n{\n   if (png_ptr != NULL && info_ptr != NULL &&\n       (info_ptr->valid & PNG_INFO_sCAL))\n   {\n      *unit = info_ptr->scal_unit;\n      *width = info_ptr->scal_s_width;\n      *height = info_ptr->scal_s_height;\n      return (PNG_INFO_sCAL);\n   }\n\n   return(0);\n}\n#endif /* sCAL */\n\n#ifdef PNG_pHYs_SUPPORTED\npng_uint_32 PNGAPI\npng_get_pHYs(png_const_structrp png_ptr, png_const_inforp info_ptr,\n    png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)\n{\n   png_uint_32 retval = 0;\n\n   png_debug1(1, \"in %s retrieval function\", \"pHYs\");\n\n   if (png_ptr != NULL && info_ptr != NULL &&\n       (info_ptr->valid & PNG_INFO_pHYs))\n   {\n      if (res_x != NULL)\n      {\n         *res_x = info_ptr->x_pixels_per_unit;\n         retval |= PNG_INFO_pHYs;\n      }\n\n      if (res_y != NULL)\n      {\n         *res_y = info_ptr->y_pixels_per_unit;\n         retval |= PNG_INFO_pHYs;\n      }\n\n      if (unit_type != NULL)\n      {\n         *unit_type = (int)info_ptr->phys_unit_type;\n         retval |= PNG_INFO_pHYs;\n      }\n   }\n\n   return (retval);\n}\n#endif /* pHYs */\n\npng_uint_32 PNGAPI\npng_get_PLTE(png_const_structrp png_ptr, png_inforp info_ptr,\n    png_colorp *palette, int *num_palette)\n{\n   png_debug1(1, \"in %s retrieval function\", \"PLTE\");\n\n   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_PLTE)\n       && palette != NULL)\n   {\n      *palette = info_ptr->palette;\n      *num_palette = info_ptr->num_palette;\n      png_debug1(3, \"num_palette = %d\", *num_palette);\n      return (PNG_INFO_PLTE);\n   }\n\n   return (0);\n}\n\n#ifdef PNG_sBIT_SUPPORTED\npng_uint_32 PNGAPI\npng_get_sBIT(png_const_structrp png_ptr, png_inforp info_ptr,\n    png_color_8p *sig_bit)\n{\n   png_debug1(1, \"in %s retrieval function\", \"sBIT\");\n\n   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sBIT)\n       && sig_bit != NULL)\n   {\n      *sig_bit = &(info_ptr->sig_bit);\n      return (PNG_INFO_sBIT);\n   }\n\n   return (0);\n}\n#endif\n\n#ifdef PNG_TEXT_SUPPORTED\nint PNGAPI\npng_get_text(png_const_structrp png_ptr, png_inforp info_ptr,\n    png_textp *text_ptr, int *num_text)\n{\n   if (png_ptr != NULL && info_ptr != NULL && info_ptr->num_text > 0)\n   {\n      png_debug1(1, \"in 0x%lx retrieval function\",\n         (unsigned long)png_ptr->chunk_name);\n\n      if (text_ptr != NULL)\n         *text_ptr = info_ptr->text;\n\n      if (num_text != NULL)\n         *num_text = info_ptr->num_text;\n\n      return info_ptr->num_text;\n   }\n\n   if (num_text != NULL)\n      *num_text = 0;\n\n   return(0);\n}\n#endif\n\n#ifdef PNG_tIME_SUPPORTED\npng_uint_32 PNGAPI\npng_get_tIME(png_const_structrp png_ptr, png_inforp info_ptr,\n    png_timep *mod_time)\n{\n   png_debug1(1, \"in %s retrieval function\", \"tIME\");\n\n   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tIME)\n       && mod_time != NULL)\n   {\n      *mod_time = &(info_ptr->mod_time);\n      return (PNG_INFO_tIME);\n   }\n\n   return (0);\n}\n#endif\n\n#ifdef PNG_tRNS_SUPPORTED\npng_uint_32 PNGAPI\npng_get_tRNS(png_const_structrp png_ptr, png_inforp info_ptr,\n    png_bytep *trans_alpha, int *num_trans, png_color_16p *trans_color)\n{\n   png_uint_32 retval = 0;\n   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS))\n   {\n      png_debug1(1, \"in %s retrieval function\", \"tRNS\");\n\n      if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)\n      {\n         if (trans_alpha != NULL)\n         {\n            *trans_alpha = info_ptr->trans_alpha;\n            retval |= PNG_INFO_tRNS;\n         }\n\n         if (trans_color != NULL)\n            *trans_color = &(info_ptr->trans_color);\n      }\n\n      else /* if (info_ptr->color_type != PNG_COLOR_TYPE_PALETTE) */\n      {\n         if (trans_color != NULL)\n         {\n            *trans_color = &(info_ptr->trans_color);\n            retval |= PNG_INFO_tRNS;\n         }\n\n         if (trans_alpha != NULL)\n            *trans_alpha = NULL;\n      }\n\n      if (num_trans != NULL)\n      {\n         *num_trans = info_ptr->num_trans;\n         retval |= PNG_INFO_tRNS;\n      }\n   }\n\n   return (retval);\n}\n#endif\n\n#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED\nint PNGAPI\npng_get_unknown_chunks(png_const_structrp png_ptr, png_inforp info_ptr,\n    png_unknown_chunkpp unknowns)\n{\n   if (png_ptr != NULL && info_ptr != NULL && unknowns != NULL)\n   {\n      *unknowns = info_ptr->unknown_chunks;\n      return info_ptr->unknown_chunks_num;\n   }\n\n   return (0);\n}\n#endif\n\n#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED\npng_byte PNGAPI\npng_get_rgb_to_gray_status (png_const_structrp png_ptr)\n{\n   return (png_byte)(png_ptr ? png_ptr->rgb_to_gray_status : 0);\n}\n#endif\n\n#ifdef PNG_USER_CHUNKS_SUPPORTED\npng_voidp PNGAPI\npng_get_user_chunk_ptr(png_const_structrp png_ptr)\n{\n   return (png_ptr ? png_ptr->user_chunk_ptr : NULL);\n}\n#endif\n\npng_size_t PNGAPI\npng_get_compression_buffer_size(png_const_structrp png_ptr)\n{\n   if (png_ptr == NULL)\n      return 0;\n\n#  ifdef PNG_WRITE_SUPPORTED\n      if (png_ptr->mode & PNG_IS_READ_STRUCT)\n#  endif\n   {\n#     ifdef PNG_SEQUENTIAL_READ_SUPPORTED\n         return png_ptr->IDAT_read_size;\n#     else\n         return PNG_IDAT_READ_SIZE;\n#     endif\n   }\n\n#  ifdef PNG_WRITE_SUPPORTED\n      else\n         return png_ptr->zbuffer_size;\n#  endif\n}\n\n#ifdef PNG_SET_USER_LIMITS_SUPPORTED\n/* These functions were added to libpng 1.2.6 and were enabled\n * by default in libpng-1.4.0 */\npng_uint_32 PNGAPI\npng_get_user_width_max (png_const_structrp png_ptr)\n{\n   return (png_ptr ? png_ptr->user_width_max : 0);\n}\n\npng_uint_32 PNGAPI\npng_get_user_height_max (png_const_structrp png_ptr)\n{\n   return (png_ptr ? png_ptr->user_height_max : 0);\n}\n\n/* This function was added to libpng 1.4.0 */\npng_uint_32 PNGAPI\npng_get_chunk_cache_max (png_const_structrp png_ptr)\n{\n   return (png_ptr ? png_ptr->user_chunk_cache_max : 0);\n}\n\n/* This function was added to libpng 1.4.1 */\npng_alloc_size_t PNGAPI\npng_get_chunk_malloc_max (png_const_structrp png_ptr)\n{\n   return (png_ptr ? png_ptr->user_chunk_malloc_max : 0);\n}\n#endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */\n\n/* These functions were added to libpng 1.4.0 */\n#ifdef PNG_IO_STATE_SUPPORTED\npng_uint_32 PNGAPI\npng_get_io_state (png_const_structrp png_ptr)\n{\n   return png_ptr->io_state;\n}\n\npng_uint_32 PNGAPI\npng_get_io_chunk_type (png_const_structrp png_ptr)\n{\n   return png_ptr->chunk_name;\n}\n#endif /* ?PNG_IO_STATE_SUPPORTED */\n\n#ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED\n#  ifdef PNG_GET_PALETTE_MAX_SUPPORTED\nint PNGAPI\npng_get_palette_max(png_const_structp png_ptr, png_const_infop info_ptr)\n{\n   if (png_ptr != NULL && info_ptr != NULL)\n      return png_ptr->num_palette_max;\n\n   return (-1);\n}\n#  endif\n#endif\n\n#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */\n"
  },
  {
    "path": "Projects/Libraries/CSBase/Source/png/pnginfo.h",
    "content": "\n/* pnginfo.h - header file for PNG reference library\n *\n * Copyright (c) 1998-2013 Glenn Randers-Pehrson\n * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)\n * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)\n *\n * Last changed in libpng 1.6.1 [March 28, 2013]\n *\n * This code is released under the libpng license.\n * For conditions of distribution and use, see the disclaimer\n * and license in png.h\n */\n\n /* png_info is a structure that holds the information in a PNG file so\n * that the application can find out the characteristics of the image.\n * If you are reading the file, this structure will tell you what is\n * in the PNG file.  If you are writing the file, fill in the information\n * you want to put into the PNG file, using png_set_*() functions, then\n * call png_write_info().\n *\n * The names chosen should be very close to the PNG specification, so\n * consult that document for information about the meaning of each field.\n *\n * With libpng < 0.95, it was only possible to directly set and read the\n * the values in the png_info_struct, which meant that the contents and\n * order of the values had to remain fixed.  With libpng 0.95 and later,\n * however, there are now functions that abstract the contents of\n * png_info_struct from the application, so this makes it easier to use\n * libpng with dynamic libraries, and even makes it possible to use\n * libraries that don't have all of the libpng ancillary chunk-handing\n * functionality.  In libpng-1.5.0 this was moved into a separate private\n * file that is not visible to applications.\n *\n * The following members may have allocated storage attached that should be\n * cleaned up before the structure is discarded: palette, trans, text,\n * pcal_purpose, pcal_units, pcal_params, hist, iccp_name, iccp_profile,\n * splt_palettes, scal_unit, row_pointers, and unknowns.   By default, these\n * are automatically freed when the info structure is deallocated, if they were\n * allocated internally by libpng.  This behavior can be changed by means\n * of the png_data_freer() function.\n *\n * More allocation details: all the chunk-reading functions that\n * change these members go through the corresponding png_set_*\n * functions.  A function to clear these members is available: see\n * png_free_data().  The png_set_* functions do not depend on being\n * able to point info structure members to any of the storage they are\n * passed (they make their own copies), EXCEPT that the png_set_text\n * functions use the same storage passed to them in the text_ptr or\n * itxt_ptr structure argument, and the png_set_rows and png_set_unknowns\n * functions do not make their own copies.\n */\n#ifndef PNGINFO_H\n#define PNGINFO_H\n\nstruct png_info_def\n{\n   /* The following are necessary for every PNG file */\n   png_uint_32 width;  /* width of image in pixels (from IHDR) */\n   png_uint_32 height; /* height of image in pixels (from IHDR) */\n   png_uint_32 valid;  /* valid chunk data (see PNG_INFO_ below) */\n   png_size_t rowbytes; /* bytes needed to hold an untransformed row */\n   png_colorp palette;      /* array of color values (valid & PNG_INFO_PLTE) */\n   png_uint_16 num_palette; /* number of color entries in \"palette\" (PLTE) */\n   png_uint_16 num_trans;   /* number of transparent palette color (tRNS) */\n   png_byte bit_depth;      /* 1, 2, 4, 8, or 16 bits/channel (from IHDR) */\n   png_byte color_type;     /* see PNG_COLOR_TYPE_ below (from IHDR) */\n   /* The following three should have been named *_method not *_type */\n   png_byte compression_type; /* must be PNG_COMPRESSION_TYPE_BASE (IHDR) */\n   png_byte filter_type;    /* must be PNG_FILTER_TYPE_BASE (from IHDR) */\n   png_byte interlace_type; /* One of PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */\n\n   /* The following are set by png_set_IHDR, called from the application on\n    * write, but the are never actually used by the write code.\n    */\n   png_byte channels;       /* number of data channels per pixel (1, 2, 3, 4) */\n   png_byte pixel_depth;    /* number of bits per pixel */\n   png_byte spare_byte;     /* to align the data, and for future use */\n\n#ifdef PNG_READ_SUPPORTED\n   /* This is never set during write */\n   png_byte signature[8];   /* magic bytes read by libpng from start of file */\n#endif\n\n   /* The rest of the data is optional.  If you are reading, check the\n    * valid field to see if the information in these are valid.  If you\n    * are writing, set the valid field to those chunks you want written,\n    * and initialize the appropriate fields below.\n    */\n\n#if defined(PNG_COLORSPACE_SUPPORTED) || defined(PNG_GAMMA_SUPPORTED)\n   /* png_colorspace only contains 'flags' if neither GAMMA or COLORSPACE are\n    * defined.  When COLORSPACE is switched on all the colorspace-defining\n    * chunks should be enabled, when GAMMA is switched on all the gamma-defining\n    * chunks should be enabled.  If this is not done it becomes possible to read\n    * inconsistent PNG files and assign a probably incorrect interpretation to\n    * the information.  (In other words, by carefully choosing which chunks to\n    * recognize the system configuration can select an interpretation for PNG\n    * files containing ambiguous data and this will result in inconsistent\n    * behavior between different libpng builds!)\n    */\n   png_colorspace colorspace;\n#endif\n\n#ifdef PNG_iCCP_SUPPORTED\n   /* iCCP chunk data. */\n   png_charp iccp_name;     /* profile name */\n   png_bytep iccp_profile;  /* International Color Consortium profile data */\n   png_uint_32 iccp_proflen;  /* ICC profile data length */\n#endif\n\n#ifdef PNG_TEXT_SUPPORTED\n   /* The tEXt, and zTXt chunks contain human-readable textual data in\n    * uncompressed, compressed, and optionally compressed forms, respectively.\n    * The data in \"text\" is an array of pointers to uncompressed,\n    * null-terminated C strings. Each chunk has a keyword that describes the\n    * textual data contained in that chunk.  Keywords are not required to be\n    * unique, and the text string may be empty.  Any number of text chunks may\n    * be in an image.\n    */\n   int num_text; /* number of comments read or comments to write */\n   int max_text; /* current size of text array */\n   png_textp text; /* array of comments read or comments to write */\n#endif /* PNG_TEXT_SUPPORTED */\n\n#ifdef PNG_tIME_SUPPORTED\n   /* The tIME chunk holds the last time the displayed image data was\n    * modified.  See the png_time struct for the contents of this struct.\n    */\n   png_time mod_time;\n#endif\n\n#ifdef PNG_sBIT_SUPPORTED\n   /* The sBIT chunk specifies the number of significant high-order bits\n    * in the pixel data.  Values are in the range [1, bit_depth], and are\n    * only specified for the channels in the pixel data.  The contents of\n    * the low-order bits is not specified.  Data is valid if\n    * (valid & PNG_INFO_sBIT) is non-zero.\n    */\n   png_color_8 sig_bit; /* significant bits in color channels */\n#endif\n\n#if defined(PNG_tRNS_SUPPORTED) || defined(PNG_READ_EXPAND_SUPPORTED) || \\\ndefined(PNG_READ_BACKGROUND_SUPPORTED)\n   /* The tRNS chunk supplies transparency data for paletted images and\n    * other image types that don't need a full alpha channel.  There are\n    * \"num_trans\" transparency values for a paletted image, stored in the\n    * same order as the palette colors, starting from index 0.  Values\n    * for the data are in the range [0, 255], ranging from fully transparent\n    * to fully opaque, respectively.  For non-paletted images, there is a\n    * single color specified that should be treated as fully transparent.\n    * Data is valid if (valid & PNG_INFO_tRNS) is non-zero.\n    */\n   png_bytep trans_alpha;    /* alpha values for paletted image */\n   png_color_16 trans_color; /* transparent color for non-palette image */\n#endif\n\n#if defined(PNG_bKGD_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)\n   /* The bKGD chunk gives the suggested image background color if the\n    * display program does not have its own background color and the image\n    * is needs to composited onto a background before display.  The colors\n    * in \"background\" are normally in the same color space/depth as the\n    * pixel data.  Data is valid if (valid & PNG_INFO_bKGD) is non-zero.\n    */\n   png_color_16 background;\n#endif\n\n#ifdef PNG_oFFs_SUPPORTED\n   /* The oFFs chunk gives the offset in \"offset_unit_type\" units rightwards\n    * and downwards from the top-left corner of the display, page, or other\n    * application-specific co-ordinate space.  See the PNG_OFFSET_ defines\n    * below for the unit types.  Valid if (valid & PNG_INFO_oFFs) non-zero.\n    */\n   png_int_32 x_offset; /* x offset on page */\n   png_int_32 y_offset; /* y offset on page */\n   png_byte offset_unit_type; /* offset units type */\n#endif\n\n#ifdef PNG_pHYs_SUPPORTED\n   /* The pHYs chunk gives the physical pixel density of the image for\n    * display or printing in \"phys_unit_type\" units (see PNG_RESOLUTION_\n    * defines below).  Data is valid if (valid & PNG_INFO_pHYs) is non-zero.\n    */\n   png_uint_32 x_pixels_per_unit; /* horizontal pixel density */\n   png_uint_32 y_pixels_per_unit; /* vertical pixel density */\n   png_byte phys_unit_type; /* resolution type (see PNG_RESOLUTION_ below) */\n#endif\n\n#ifdef PNG_hIST_SUPPORTED\n   /* The hIST chunk contains the relative frequency or importance of the\n    * various palette entries, so that a viewer can intelligently select a\n    * reduced-color palette, if required.  Data is an array of \"num_palette\"\n    * values in the range [0,65535]. Data valid if (valid & PNG_INFO_hIST)\n    * is non-zero.\n    */\n   png_uint_16p hist;\n#endif\n\n#ifdef PNG_pCAL_SUPPORTED\n   /* The pCAL chunk describes a transformation between the stored pixel\n    * values and original physical data values used to create the image.\n    * The integer range [0, 2^bit_depth - 1] maps to the floating-point\n    * range given by [pcal_X0, pcal_X1], and are further transformed by a\n    * (possibly non-linear) transformation function given by \"pcal_type\"\n    * and \"pcal_params\" into \"pcal_units\".  Please see the PNG_EQUATION_\n    * defines below, and the PNG-Group's PNG extensions document for a\n    * complete description of the transformations and how they should be\n    * implemented, and for a description of the ASCII parameter strings.\n    * Data values are valid if (valid & PNG_INFO_pCAL) non-zero.\n    */\n   png_charp pcal_purpose;  /* pCAL chunk description string */\n   png_int_32 pcal_X0;      /* minimum value */\n   png_int_32 pcal_X1;      /* maximum value */\n   png_charp pcal_units;    /* Latin-1 string giving physical units */\n   png_charpp pcal_params;  /* ASCII strings containing parameter values */\n   png_byte pcal_type;      /* equation type (see PNG_EQUATION_ below) */\n   png_byte pcal_nparams;   /* number of parameters given in pcal_params */\n#endif\n\n/* New members added in libpng-1.0.6 */\n   png_uint_32 free_me;     /* flags items libpng is responsible for freeing */\n\n#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED\n   /* Storage for unknown chunks that the library doesn't recognize. */\n   png_unknown_chunkp unknown_chunks;\n\n   /* The type of this field is limited by the type of \n    * png_struct::user_chunk_cache_max, else overflow can occur.\n    */\n   int                unknown_chunks_num;\n#endif\n\n#ifdef PNG_sPLT_SUPPORTED\n   /* Data on sPLT chunks (there may be more than one). */\n   png_sPLT_tp splt_palettes;\n   int         splt_palettes_num; /* Match type returned by png_get API */\n#endif\n\n#ifdef PNG_sCAL_SUPPORTED\n   /* The sCAL chunk describes the actual physical dimensions of the\n    * subject matter of the graphic.  The chunk contains a unit specification\n    * a byte value, and two ASCII strings representing floating-point\n    * values.  The values are width and height corresponsing to one pixel\n    * in the image.  Data values are valid if (valid & PNG_INFO_sCAL) is\n    * non-zero.\n    */\n   png_byte scal_unit;         /* unit of physical scale */\n   png_charp scal_s_width;     /* string containing height */\n   png_charp scal_s_height;    /* string containing width */\n#endif\n\n#ifdef PNG_INFO_IMAGE_SUPPORTED\n   /* Memory has been allocated if (valid & PNG_ALLOCATED_INFO_ROWS)\n      non-zero */\n   /* Data valid if (valid & PNG_INFO_IDAT) non-zero */\n   png_bytepp row_pointers;        /* the image bits */\n#endif\n\n};\n#endif /* PNGINFO_H */\n"
  },
  {
    "path": "Projects/Libraries/CSBase/Source/png/pnglibconf.h",
    "content": "/* libpng 1.6.10 STANDARD API DEFINITION */\n\n/* pnglibconf.h - library build configuration */\n\n/* Libpng version 1.6.10 - March 6, 2014 */\n\n/* Copyright (c) 1998-2013 Glenn Randers-Pehrson */\n\n/* This code is released under the libpng license. */\n/* For conditions of distribution and use, see the disclaimer */\n/* and license in png.h */\n\n/* pnglibconf.h */\n/* Machine generated file: DO NOT EDIT */\n/* Derived from: scripts/pnglibconf.dfa */\n#ifndef PNGLCONF_H\n#define PNGLCONF_H\n/* options */\n#define PNG_16BIT_SUPPORTED\n#define PNG_ALIGNED_MEMORY_SUPPORTED\n/*#undef PNG_ARM_NEON_API_SUPPORTED*/\n/*#undef PNG_ARM_NEON_CHECK_SUPPORTED*/\n#define PNG_BENIGN_ERRORS_SUPPORTED\n#define PNG_BENIGN_READ_ERRORS_SUPPORTED\n/*#undef PNG_BENIGN_WRITE_ERRORS_SUPPORTED*/\n#define PNG_BUILD_GRAYSCALE_PALETTE_SUPPORTED\n#define PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED\n#define PNG_COLORSPACE_SUPPORTED\n#define PNG_CONSOLE_IO_SUPPORTED\n#define PNG_CONVERT_tIME_SUPPORTED\n#define PNG_EASY_ACCESS_SUPPORTED\n/*#undef PNG_ERROR_NUMBERS_SUPPORTED*/\n#define PNG_ERROR_TEXT_SUPPORTED\n#define PNG_FIXED_POINT_SUPPORTED\n#define PNG_FLOATING_ARITHMETIC_SUPPORTED\n#define PNG_FLOATING_POINT_SUPPORTED\n#define PNG_FORMAT_AFIRST_SUPPORTED\n#define PNG_FORMAT_BGR_SUPPORTED\n#define PNG_GAMMA_SUPPORTED\n#define PNG_GET_PALETTE_MAX_SUPPORTED\n#define PNG_HANDLE_AS_UNKNOWN_SUPPORTED\n#define PNG_INCH_CONVERSIONS_SUPPORTED\n#define PNG_INFO_IMAGE_SUPPORTED\n#define PNG_IO_STATE_SUPPORTED\n#define PNG_MNG_FEATURES_SUPPORTED\n#define PNG_POINTER_INDEXING_SUPPORTED\n#define PNG_PROGRESSIVE_READ_SUPPORTED\n#define PNG_READ_16BIT_SUPPORTED\n#define PNG_READ_ALPHA_MODE_SUPPORTED\n#define PNG_READ_ANCILLARY_CHUNKS_SUPPORTED\n#define PNG_READ_BACKGROUND_SUPPORTED\n#define PNG_READ_BGR_SUPPORTED\n#define PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED\n#define PNG_READ_COMPOSITE_NODIV_SUPPORTED\n#define PNG_READ_COMPRESSED_TEXT_SUPPORTED\n#define PNG_READ_EXPAND_16_SUPPORTED\n#define PNG_READ_EXPAND_SUPPORTED\n#define PNG_READ_FILLER_SUPPORTED\n#define PNG_READ_GAMMA_SUPPORTED\n#define PNG_READ_GET_PALETTE_MAX_SUPPORTED\n#define PNG_READ_GRAY_TO_RGB_SUPPORTED\n#define PNG_READ_INTERLACING_SUPPORTED\n#define PNG_READ_INT_FUNCTIONS_SUPPORTED\n#define PNG_READ_INVERT_ALPHA_SUPPORTED\n#define PNG_READ_INVERT_SUPPORTED\n#define PNG_READ_OPT_PLTE_SUPPORTED\n#define PNG_READ_PACKSWAP_SUPPORTED\n#define PNG_READ_PACK_SUPPORTED\n#define PNG_READ_QUANTIZE_SUPPORTED\n#define PNG_READ_RGB_TO_GRAY_SUPPORTED\n#define PNG_READ_SCALE_16_TO_8_SUPPORTED\n#define PNG_READ_SHIFT_SUPPORTED\n#define PNG_READ_STRIP_16_TO_8_SUPPORTED\n#define PNG_READ_STRIP_ALPHA_SUPPORTED\n#define PNG_READ_SUPPORTED\n#define PNG_READ_SWAP_ALPHA_SUPPORTED\n#define PNG_READ_SWAP_SUPPORTED\n#define PNG_READ_TEXT_SUPPORTED\n#define PNG_READ_TRANSFORMS_SUPPORTED\n#define PNG_READ_UNKNOWN_CHUNKS_SUPPORTED\n#define PNG_READ_USER_CHUNKS_SUPPORTED\n#define PNG_READ_USER_TRANSFORM_SUPPORTED\n#define PNG_READ_bKGD_SUPPORTED\n#define PNG_READ_cHRM_SUPPORTED\n#define PNG_READ_gAMA_SUPPORTED\n#define PNG_READ_hIST_SUPPORTED\n#define PNG_READ_iCCP_SUPPORTED\n#define PNG_READ_iTXt_SUPPORTED\n#define PNG_READ_oFFs_SUPPORTED\n#define PNG_READ_pCAL_SUPPORTED\n#define PNG_READ_pHYs_SUPPORTED\n#define PNG_READ_sBIT_SUPPORTED\n#define PNG_READ_sCAL_SUPPORTED\n#define PNG_READ_sPLT_SUPPORTED\n#define PNG_READ_sRGB_SUPPORTED\n#define PNG_READ_tEXt_SUPPORTED\n#define PNG_READ_tIME_SUPPORTED\n#define PNG_READ_tRNS_SUPPORTED\n#define PNG_READ_zTXt_SUPPORTED\n/*#undef PNG_SAFE_LIMITS_SUPPORTED*/\n#define PNG_SAVE_INT_32_SUPPORTED\n#define PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED\n#define PNG_SEQUENTIAL_READ_SUPPORTED\n#define PNG_SETJMP_SUPPORTED\n#define PNG_SET_CHUNK_CACHE_LIMIT_SUPPORTED\n#define PNG_SET_CHUNK_MALLOC_LIMIT_SUPPORTED\n#define PNG_SET_OPTION_SUPPORTED\n#define PNG_SET_UNKNOWN_CHUNKS_SUPPORTED\n#define PNG_SET_USER_LIMITS_SUPPORTED\n#define PNG_SIMPLIFIED_READ_AFIRST_SUPPORTED\n#define PNG_SIMPLIFIED_READ_BGR_SUPPORTED\n#define PNG_SIMPLIFIED_READ_SUPPORTED\n#define PNG_SIMPLIFIED_WRITE_AFIRST_SUPPORTED\n#define PNG_SIMPLIFIED_WRITE_BGR_SUPPORTED\n#define PNG_SIMPLIFIED_WRITE_SUPPORTED\n#define PNG_STDIO_SUPPORTED\n#define PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED\n#define PNG_TEXT_SUPPORTED\n#define PNG_TIME_RFC1123_SUPPORTED\n#define PNG_UNKNOWN_CHUNKS_SUPPORTED\n#define PNG_USER_CHUNKS_SUPPORTED\n#define PNG_USER_LIMITS_SUPPORTED\n#define PNG_USER_MEM_SUPPORTED\n#define PNG_USER_TRANSFORM_INFO_SUPPORTED\n#define PNG_USER_TRANSFORM_PTR_SUPPORTED\n#define PNG_WARNINGS_SUPPORTED\n#define PNG_WRITE_16BIT_SUPPORTED\n#define PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED\n#define PNG_WRITE_BGR_SUPPORTED\n#define PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED\n#define PNG_WRITE_COMPRESSED_TEXT_SUPPORTED\n#define PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED\n#define PNG_WRITE_FILLER_SUPPORTED\n#define PNG_WRITE_FILTER_SUPPORTED\n#define PNG_WRITE_FLUSH_SUPPORTED\n#define PNG_WRITE_GET_PALETTE_MAX_SUPPORTED\n#define PNG_WRITE_INTERLACING_SUPPORTED\n#define PNG_WRITE_INT_FUNCTIONS_SUPPORTED\n#define PNG_WRITE_INVERT_ALPHA_SUPPORTED\n#define PNG_WRITE_INVERT_SUPPORTED\n#define PNG_WRITE_OPTIMIZE_CMF_SUPPORTED\n#define PNG_WRITE_PACKSWAP_SUPPORTED\n#define PNG_WRITE_PACK_SUPPORTED\n#define PNG_WRITE_SHIFT_SUPPORTED\n#define PNG_WRITE_SUPPORTED\n#define PNG_WRITE_SWAP_ALPHA_SUPPORTED\n#define PNG_WRITE_SWAP_SUPPORTED\n#define PNG_WRITE_TEXT_SUPPORTED\n#define PNG_WRITE_TRANSFORMS_SUPPORTED\n#define PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED\n#define PNG_WRITE_USER_TRANSFORM_SUPPORTED\n#define PNG_WRITE_WEIGHTED_FILTER_SUPPORTED\n#define PNG_WRITE_bKGD_SUPPORTED\n#define PNG_WRITE_cHRM_SUPPORTED\n#define PNG_WRITE_gAMA_SUPPORTED\n#define PNG_WRITE_hIST_SUPPORTED\n#define PNG_WRITE_iCCP_SUPPORTED\n#define PNG_WRITE_iTXt_SUPPORTED\n#define PNG_WRITE_oFFs_SUPPORTED\n#define PNG_WRITE_pCAL_SUPPORTED\n#define PNG_WRITE_pHYs_SUPPORTED\n#define PNG_WRITE_sBIT_SUPPORTED\n#define PNG_WRITE_sCAL_SUPPORTED\n#define PNG_WRITE_sPLT_SUPPORTED\n#define PNG_WRITE_sRGB_SUPPORTED\n#define PNG_WRITE_tEXt_SUPPORTED\n#define PNG_WRITE_tIME_SUPPORTED\n#define PNG_WRITE_tRNS_SUPPORTED\n#define PNG_WRITE_zTXt_SUPPORTED\n#define PNG_bKGD_SUPPORTED\n#define PNG_cHRM_SUPPORTED\n#define PNG_gAMA_SUPPORTED\n#define PNG_hIST_SUPPORTED\n#define PNG_iCCP_SUPPORTED\n#define PNG_iTXt_SUPPORTED\n#define PNG_oFFs_SUPPORTED\n#define PNG_pCAL_SUPPORTED\n#define PNG_pHYs_SUPPORTED\n#define PNG_sBIT_SUPPORTED\n#define PNG_sCAL_SUPPORTED\n#define PNG_sPLT_SUPPORTED\n#define PNG_sRGB_SUPPORTED\n#define PNG_tEXt_SUPPORTED\n#define PNG_tIME_SUPPORTED\n#define PNG_tRNS_SUPPORTED\n#define PNG_zTXt_SUPPORTED\n/* end of options */\n/* settings */\n#define PNG_API_RULE 0\n#define PNG_CALLOC_SUPPORTED\n#define PNG_COST_SHIFT 3\n#define PNG_DEFAULT_READ_MACROS 1\n#define PNG_GAMMA_THRESHOLD_FIXED 5000\n#define PNG_IDAT_READ_SIZE PNG_ZBUF_SIZE\n#define PNG_INFLATE_BUF_SIZE 1024\n#define PNG_MAX_GAMMA_8 11\n#define PNG_QUANTIZE_BLUE_BITS 5\n#define PNG_QUANTIZE_GREEN_BITS 5\n#define PNG_QUANTIZE_RED_BITS 5\n#define PNG_TEXT_Z_DEFAULT_COMPRESSION (-1)\n#define PNG_TEXT_Z_DEFAULT_STRATEGY 0\n#define PNG_WEIGHT_SHIFT 8\n#define PNG_ZBUF_SIZE 8192\n#define PNG_ZLIB_VERNUM 0 /* unknown */\n#define PNG_Z_DEFAULT_COMPRESSION (-1)\n#define PNG_Z_DEFAULT_NOFILTER_STRATEGY 0\n#define PNG_Z_DEFAULT_STRATEGY 1\n#define PNG_sCAL_PRECISION 5\n#define PNG_sRGB_PROFILE_CHECKS 2\n/* end of settings */\n#endif /* PNGLCONF_H */\n"
  },
  {
    "path": "Projects/Libraries/CSBase/Source/png/pngmem.c",
    "content": "\n/* pngmem.c - stub functions for memory allocation\n *\n * Last changed in libpng 1.6.8 [December 19, 2013]\n * Copyright (c) 1998-2013 Glenn Randers-Pehrson\n * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)\n * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)\n *\n * This code is released under the libpng license.\n * For conditions of distribution and use, see the disclaimer\n * and license in png.h\n *\n * This file provides a location for all memory allocation.  Users who\n * need special memory handling are expected to supply replacement\n * functions for png_malloc() and png_free(), and to use\n * png_create_read_struct_2() and png_create_write_struct_2() to\n * identify the replacement functions.\n */\n\n#include \"pngpriv.h\"\n\n#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)\n/* Free a png_struct */\nvoid /* PRIVATE */\npng_destroy_png_struct(png_structrp png_ptr)\n{\n   if (png_ptr != NULL)\n   {\n      /* png_free might call png_error and may certainly call\n       * png_get_mem_ptr, so fake a temporary png_struct to support this.\n       */\n      png_struct dummy_struct = *png_ptr;\n      memset(png_ptr, 0, (sizeof *png_ptr));\n      png_free(&dummy_struct, png_ptr);\n\n#     ifdef PNG_SETJMP_SUPPORTED\n         /* We may have a jmp_buf left to deallocate. */\n         png_free_jmpbuf(&dummy_struct);\n#     endif\n   }\n}\n\n/* Allocate memory.  For reasonable files, size should never exceed\n * 64K.  However, zlib may allocate more then 64K if you don't tell\n * it not to.  See zconf.h and png.h for more information.  zlib does\n * need to allocate exactly 64K, so whatever you call here must\n * have the ability to do that.\n */\nPNG_FUNCTION(png_voidp,PNGAPI\npng_calloc,(png_const_structrp png_ptr, png_alloc_size_t size),PNG_ALLOCATED)\n{\n   png_voidp ret;\n\n   ret = png_malloc(png_ptr, size);\n\n   if (ret != NULL)\n      memset(ret, 0, size);\n\n   return ret;\n}\n\n/* png_malloc_base, an internal function added at libpng 1.6.0, does the work of\n * allocating memory, taking into account limits and PNG_USER_MEM_SUPPORTED.\n * Checking and error handling must happen outside this routine; it returns NULL\n * if the allocation cannot be done (for any reason.)\n */\nPNG_FUNCTION(png_voidp /* PRIVATE */,\npng_malloc_base,(png_const_structrp png_ptr, png_alloc_size_t size),\n   PNG_ALLOCATED)\n{\n   /* Moved to png_malloc_base from png_malloc_default in 1.6.0; the DOS\n    * allocators have also been removed in 1.6.0, so any 16-bit system now has\n    * to implement a user memory handler.  This checks to be sure it isn't\n    * called with big numbers.\n    */\n#ifndef PNG_USER_MEM_SUPPORTED\n   PNG_UNUSED(png_ptr)\n#endif\n\n   if (size > 0 && size <= PNG_SIZE_MAX\n#     ifdef PNG_MAX_MALLOC_64K\n         && size <= 65536U\n#     endif\n      )\n   {\n#ifdef PNG_USER_MEM_SUPPORTED\n      if (png_ptr != NULL && png_ptr->malloc_fn != NULL)\n         return png_ptr->malloc_fn(png_constcast(png_structrp,png_ptr), size);\n\n      else\n#endif\n         return malloc((size_t)size); /* checked for truncation above */\n   }\n\n   else\n      return NULL;\n}\n\n#if defined(PNG_TEXT_SUPPORTED) || defined(PNG_sPLT_SUPPORTED) ||\\\n   defined(PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED)\n/* This is really here only to work round a spurious warning in GCC 4.6 and 4.7\n * that arises because of the checks in png_realloc_array that are repeated in\n * png_malloc_array.\n */\nstatic png_voidp\npng_malloc_array_checked(png_const_structrp png_ptr, int nelements,\n   size_t element_size)\n{\n   png_alloc_size_t req = nelements; /* known to be > 0 */\n\n   if (req <= PNG_SIZE_MAX/element_size)\n      return png_malloc_base(png_ptr, req * element_size);\n\n   /* The failure case when the request is too large */\n   return NULL;\n}\n\nPNG_FUNCTION(png_voidp /* PRIVATE */,\npng_malloc_array,(png_const_structrp png_ptr, int nelements,\n   size_t element_size),PNG_ALLOCATED)\n{\n   if (nelements <= 0 || element_size == 0)\n      png_error(png_ptr, \"internal error: array alloc\");\n\n   return png_malloc_array_checked(png_ptr, nelements, element_size);\n}\n\nPNG_FUNCTION(png_voidp /* PRIVATE */,\npng_realloc_array,(png_const_structrp png_ptr, png_const_voidp old_array,\n   int old_elements, int add_elements, size_t element_size),PNG_ALLOCATED)\n{\n   /* These are internal errors: */\n   if (add_elements <= 0 || element_size == 0 || old_elements < 0 ||\n      (old_array == NULL && old_elements > 0))\n      png_error(png_ptr, \"internal error: array realloc\");\n\n   /* Check for overflow on the elements count (so the caller does not have to\n    * check.)\n    */\n   if (add_elements <= INT_MAX - old_elements)\n   {\n      png_voidp new_array = png_malloc_array_checked(png_ptr,\n         old_elements+add_elements, element_size);\n\n      if (new_array != NULL)\n      {\n         /* Because png_malloc_array worked the size calculations below cannot\n          * overflow.\n          */\n         if (old_elements > 0)\n            memcpy(new_array, old_array, element_size*(unsigned)old_elements);\n\n         memset((char*)new_array + element_size*(unsigned)old_elements, 0,\n            element_size*(unsigned)add_elements);\n\n         return new_array;\n      }\n   }\n\n   return NULL; /* error */\n}\n#endif /* TEXT || sPLT || STORE_UNKNOWN_CHUNKS */\n\n/* Various functions that have different error handling are derived from this.\n * png_malloc always exists, but if PNG_USER_MEM_SUPPORTED is defined a separate\n * function png_malloc_default is also provided.\n */\nPNG_FUNCTION(png_voidp,PNGAPI\npng_malloc,(png_const_structrp png_ptr, png_alloc_size_t size),PNG_ALLOCATED)\n{\n   png_voidp ret;\n\n   if (png_ptr == NULL)\n      return NULL;\n\n   ret = png_malloc_base(png_ptr, size);\n\n   if (ret == NULL)\n       png_error(png_ptr, \"Out of memory\"); /* 'm' means png_malloc */\n\n   return ret;\n}\n\n#ifdef PNG_USER_MEM_SUPPORTED\nPNG_FUNCTION(png_voidp,PNGAPI\npng_malloc_default,(png_const_structrp png_ptr, png_alloc_size_t size),\n   PNG_ALLOCATED PNG_DEPRECATED)\n{\n   png_voidp ret;\n\n   if (png_ptr == NULL)\n      return NULL;\n\n   /* Passing 'NULL' here bypasses the application provided memory handler. */\n   ret = png_malloc_base(NULL/*use malloc*/, size);\n\n   if (ret == NULL)\n      png_error(png_ptr, \"Out of Memory\"); /* 'M' means png_malloc_default */\n\n   return ret;\n}\n#endif /* PNG_USER_MEM_SUPPORTED */\n\n/* This function was added at libpng version 1.2.3.  The png_malloc_warn()\n * function will issue a png_warning and return NULL instead of issuing a\n * png_error, if it fails to allocate the requested memory.\n */\nPNG_FUNCTION(png_voidp,PNGAPI\npng_malloc_warn,(png_const_structrp png_ptr, png_alloc_size_t size),\n   PNG_ALLOCATED)\n{\n   if (png_ptr != NULL)\n   {\n      png_voidp ret = png_malloc_base(png_ptr, size);\n\n      if (ret != NULL)\n         return ret;\n\n      png_warning(png_ptr, \"Out of memory\");\n   }\n\n   return NULL;\n}\n\n/* Free a pointer allocated by png_malloc().  If ptr is NULL, return\n * without taking any action.\n */\nvoid PNGAPI\npng_free(png_const_structrp png_ptr, png_voidp ptr)\n{\n   if (png_ptr == NULL || ptr == NULL)\n      return;\n\n#ifdef PNG_USER_MEM_SUPPORTED\n   if (png_ptr->free_fn != NULL)\n      png_ptr->free_fn(png_constcast(png_structrp,png_ptr), ptr);\n\n   else\n      png_free_default(png_ptr, ptr);\n}\n\nPNG_FUNCTION(void,PNGAPI\npng_free_default,(png_const_structrp png_ptr, png_voidp ptr),PNG_DEPRECATED)\n{\n   if (png_ptr == NULL || ptr == NULL)\n      return;\n#endif /* PNG_USER_MEM_SUPPORTED */\n\n   free(ptr);\n}\n\n#ifdef PNG_USER_MEM_SUPPORTED\n/* This function is called when the application wants to use another method\n * of allocating and freeing memory.\n */\nvoid PNGAPI\npng_set_mem_fn(png_structrp png_ptr, png_voidp mem_ptr, png_malloc_ptr\n  malloc_fn, png_free_ptr free_fn)\n{\n   if (png_ptr != NULL)\n   {\n      png_ptr->mem_ptr = mem_ptr;\n      png_ptr->malloc_fn = malloc_fn;\n      png_ptr->free_fn = free_fn;\n   }\n}\n\n/* This function returns a pointer to the mem_ptr associated with the user\n * functions.  The application should free any memory associated with this\n * pointer before png_write_destroy and png_read_destroy are called.\n */\npng_voidp PNGAPI\npng_get_mem_ptr(png_const_structrp png_ptr)\n{\n   if (png_ptr == NULL)\n      return NULL;\n\n   return png_ptr->mem_ptr;\n}\n#endif /* PNG_USER_MEM_SUPPORTED */\n#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */\n"
  },
  {
    "path": "Projects/Libraries/CSBase/Source/png/pngpread.c",
    "content": "\n/* pngpread.c - read a png file in push mode\n *\n * Last changed in libpng 1.6.10 [March 6, 2014]\n * Copyright (c) 1998-2014 Glenn Randers-Pehrson\n * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)\n * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)\n *\n * This code is released under the libpng license.\n * For conditions of distribution and use, see the disclaimer\n * and license in png.h\n */\n\n#include \"pngpriv.h\"\n\n#ifdef PNG_PROGRESSIVE_READ_SUPPORTED\n\n/* Push model modes */\n#define PNG_READ_SIG_MODE   0\n#define PNG_READ_CHUNK_MODE 1\n#define PNG_READ_IDAT_MODE  2\n#define PNG_SKIP_MODE       3\n#define PNG_READ_tEXt_MODE  4\n#define PNG_READ_zTXt_MODE  5\n#define PNG_READ_DONE_MODE  6\n#define PNG_READ_iTXt_MODE  7\n#define PNG_ERROR_MODE      8\n\nvoid PNGAPI\npng_process_data(png_structrp png_ptr, png_inforp info_ptr,\n    png_bytep buffer, png_size_t buffer_size)\n{\n   if (png_ptr == NULL || info_ptr == NULL)\n      return;\n\n   png_push_restore_buffer(png_ptr, buffer, buffer_size);\n\n   while (png_ptr->buffer_size)\n   {\n      png_process_some_data(png_ptr, info_ptr);\n   }\n}\n\npng_size_t PNGAPI\npng_process_data_pause(png_structrp png_ptr, int save)\n{\n   if (png_ptr != NULL)\n   {\n      /* It's easiest for the caller if we do the save, then the caller doesn't\n       * have to supply the same data again:\n       */\n      if (save)\n         png_push_save_buffer(png_ptr);\n      else\n      {\n         /* This includes any pending saved bytes: */\n         png_size_t remaining = png_ptr->buffer_size;\n         png_ptr->buffer_size = 0;\n\n         /* So subtract the saved buffer size, unless all the data\n          * is actually 'saved', in which case we just return 0\n          */\n         if (png_ptr->save_buffer_size < remaining)\n            return remaining - png_ptr->save_buffer_size;\n      }\n   }\n\n   return 0;\n}\n\npng_uint_32 PNGAPI\npng_process_data_skip(png_structrp png_ptr)\n{\n   png_uint_32 remaining = 0;\n\n   if (png_ptr != NULL && png_ptr->process_mode == PNG_SKIP_MODE &&\n      png_ptr->skip_length > 0)\n   {\n      /* At the end of png_process_data the buffer size must be 0 (see the loop\n       * above) so we can detect a broken call here:\n       */\n      if (png_ptr->buffer_size != 0)\n         png_error(png_ptr,\n            \"png_process_data_skip called inside png_process_data\");\n\n      /* If is impossible for there to be a saved buffer at this point -\n       * otherwise we could not be in SKIP mode.  This will also happen if\n       * png_process_skip is called inside png_process_data (but only very\n       * rarely.)\n       */\n      if (png_ptr->save_buffer_size != 0)\n         png_error(png_ptr, \"png_process_data_skip called with saved data\");\n\n      remaining = png_ptr->skip_length;\n      png_ptr->skip_length = 0;\n      png_ptr->process_mode = PNG_READ_CHUNK_MODE;\n   }\n\n   return remaining;\n}\n\n/* What we do with the incoming data depends on what we were previously\n * doing before we ran out of data...\n */\nvoid /* PRIVATE */\npng_process_some_data(png_structrp png_ptr, png_inforp info_ptr)\n{\n   if (png_ptr == NULL)\n      return;\n\n   switch (png_ptr->process_mode)\n   {\n      case PNG_READ_SIG_MODE:\n      {\n         png_push_read_sig(png_ptr, info_ptr);\n         break;\n      }\n\n      case PNG_READ_CHUNK_MODE:\n      {\n         png_push_read_chunk(png_ptr, info_ptr);\n         break;\n      }\n\n      case PNG_READ_IDAT_MODE:\n      {\n         png_push_read_IDAT(png_ptr);\n         break;\n      }\n\n      case PNG_SKIP_MODE:\n      {\n         png_push_crc_finish(png_ptr);\n         break;\n      }\n\n      default:\n      {\n         png_ptr->buffer_size = 0;\n         break;\n      }\n   }\n}\n\n/* Read any remaining signature bytes from the stream and compare them with\n * the correct PNG signature.  It is possible that this routine is called\n * with bytes already read from the signature, either because they have been\n * checked by the calling application, or because of multiple calls to this\n * routine.\n */\nvoid /* PRIVATE */\npng_push_read_sig(png_structrp png_ptr, png_inforp info_ptr)\n{\n   png_size_t num_checked = png_ptr->sig_bytes, /* SAFE, does not exceed 8 */ \n             num_to_check = 8 - num_checked;\n\n   if (png_ptr->buffer_size < num_to_check)\n   {\n      num_to_check = png_ptr->buffer_size;\n   }\n\n   png_push_fill_buffer(png_ptr, &(info_ptr->signature[num_checked]),\n       num_to_check);\n   png_ptr->sig_bytes = (png_byte)(png_ptr->sig_bytes + num_to_check);\n\n   if (png_sig_cmp(info_ptr->signature, num_checked, num_to_check))\n   {\n      if (num_checked < 4 &&\n          png_sig_cmp(info_ptr->signature, num_checked, num_to_check - 4))\n         png_error(png_ptr, \"Not a PNG file\");\n\n      else\n         png_error(png_ptr, \"PNG file corrupted by ASCII conversion\");\n   }\n   else\n   {\n      if (png_ptr->sig_bytes >= 8)\n      {\n         png_ptr->process_mode = PNG_READ_CHUNK_MODE;\n      }\n   }\n}\n\nvoid /* PRIVATE */\npng_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)\n{\n   png_uint_32 chunk_name;\n#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED\n   int keep; /* unknown handling method */\n#endif\n\n   /* First we make sure we have enough data for the 4 byte chunk name\n    * and the 4 byte chunk length before proceeding with decoding the\n    * chunk data.  To fully decode each of these chunks, we also make\n    * sure we have enough data in the buffer for the 4 byte CRC at the\n    * end of every chunk (except IDAT, which is handled separately).\n    */\n   if (!(png_ptr->mode & PNG_HAVE_CHUNK_HEADER))\n   {\n      png_byte chunk_length[4];\n      png_byte chunk_tag[4];\n\n      if (png_ptr->buffer_size < 8)\n      {\n         png_push_save_buffer(png_ptr);\n         return;\n      }\n\n      png_push_fill_buffer(png_ptr, chunk_length, 4);\n      png_ptr->push_length = png_get_uint_31(png_ptr, chunk_length);\n      png_reset_crc(png_ptr);\n      png_crc_read(png_ptr, chunk_tag, 4);\n      png_ptr->chunk_name = PNG_CHUNK_FROM_STRING(chunk_tag);\n      png_check_chunk_name(png_ptr, png_ptr->chunk_name);\n      png_ptr->mode |= PNG_HAVE_CHUNK_HEADER;\n   }\n\n   chunk_name = png_ptr->chunk_name;\n\n   if (chunk_name == png_IDAT)\n   {\n      if (png_ptr->mode & PNG_AFTER_IDAT)\n         png_ptr->mode |= PNG_HAVE_CHUNK_AFTER_IDAT;\n\n      /* If we reach an IDAT chunk, this means we have read all of the\n       * header chunks, and we can start reading the image (or if this\n       * is called after the image has been read - we have an error).\n       */\n      if (!(png_ptr->mode & PNG_HAVE_IHDR))\n         png_error(png_ptr, \"Missing IHDR before IDAT\");\n\n      else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE &&\n          !(png_ptr->mode & PNG_HAVE_PLTE))\n         png_error(png_ptr, \"Missing PLTE before IDAT\");\n\n      png_ptr->mode |= PNG_HAVE_IDAT;\n      png_ptr->process_mode = PNG_READ_IDAT_MODE;\n\n      if (!(png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT))\n         if (png_ptr->push_length == 0)\n            return;\n\n      if (png_ptr->mode & PNG_AFTER_IDAT)\n         png_benign_error(png_ptr, \"Too many IDATs found\");\n   }\n\n   if (chunk_name == png_IHDR)\n   {\n      if (png_ptr->push_length != 13)\n         png_error(png_ptr, \"Invalid IHDR length\");\n\n      if (png_ptr->push_length + 4 > png_ptr->buffer_size)\n      {\n         png_push_save_buffer(png_ptr);\n         return;\n      }\n\n      png_handle_IHDR(png_ptr, info_ptr, png_ptr->push_length);\n   }\n\n   else if (chunk_name == png_IEND)\n   {\n      if (png_ptr->push_length + 4 > png_ptr->buffer_size)\n      {\n         png_push_save_buffer(png_ptr);\n         return;\n      }\n\n      png_handle_IEND(png_ptr, info_ptr, png_ptr->push_length);\n\n      png_ptr->process_mode = PNG_READ_DONE_MODE;\n      png_push_have_end(png_ptr, info_ptr);\n   }\n\n#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED\n   else if ((keep = png_chunk_unknown_handling(png_ptr, chunk_name)) != 0)\n   {\n      if (png_ptr->push_length + 4 > png_ptr->buffer_size)\n      {\n         png_push_save_buffer(png_ptr);\n         return;\n      }\n\n      png_handle_unknown(png_ptr, info_ptr, png_ptr->push_length, keep);\n\n      if (chunk_name == png_PLTE)\n         png_ptr->mode |= PNG_HAVE_PLTE;\n   }\n#endif\n\n   else if (chunk_name == png_PLTE)\n   {\n      if (png_ptr->push_length + 4 > png_ptr->buffer_size)\n      {\n         png_push_save_buffer(png_ptr);\n         return;\n      }\n      png_handle_PLTE(png_ptr, info_ptr, png_ptr->push_length);\n   }\n\n   else if (chunk_name == png_IDAT)\n   {\n      png_ptr->idat_size = png_ptr->push_length;\n      png_ptr->process_mode = PNG_READ_IDAT_MODE;\n      png_push_have_info(png_ptr, info_ptr);\n      png_ptr->zstream.avail_out =\n          (uInt) PNG_ROWBYTES(png_ptr->pixel_depth,\n          png_ptr->iwidth) + 1;\n      png_ptr->zstream.next_out = png_ptr->row_buf;\n      return;\n   }\n\n#ifdef PNG_READ_gAMA_SUPPORTED\n   else if (png_ptr->chunk_name == png_gAMA)\n   {\n      if (png_ptr->push_length + 4 > png_ptr->buffer_size)\n      {\n         png_push_save_buffer(png_ptr);\n         return;\n      }\n\n      png_handle_gAMA(png_ptr, info_ptr, png_ptr->push_length);\n   }\n\n#endif\n#ifdef PNG_READ_sBIT_SUPPORTED\n   else if (png_ptr->chunk_name == png_sBIT)\n   {\n      if (png_ptr->push_length + 4 > png_ptr->buffer_size)\n      {\n         png_push_save_buffer(png_ptr);\n         return;\n      }\n\n      png_handle_sBIT(png_ptr, info_ptr, png_ptr->push_length);\n   }\n\n#endif\n#ifdef PNG_READ_cHRM_SUPPORTED\n   else if (png_ptr->chunk_name == png_cHRM)\n   {\n      if (png_ptr->push_length + 4 > png_ptr->buffer_size)\n      {\n         png_push_save_buffer(png_ptr);\n         return;\n      }\n\n      png_handle_cHRM(png_ptr, info_ptr, png_ptr->push_length);\n   }\n\n#endif\n#ifdef PNG_READ_sRGB_SUPPORTED\n   else if (chunk_name == png_sRGB)\n   {\n      if (png_ptr->push_length + 4 > png_ptr->buffer_size)\n      {\n         png_push_save_buffer(png_ptr);\n         return;\n      }\n\n      png_handle_sRGB(png_ptr, info_ptr, png_ptr->push_length);\n   }\n\n#endif\n#ifdef PNG_READ_iCCP_SUPPORTED\n   else if (png_ptr->chunk_name == png_iCCP)\n   {\n      if (png_ptr->push_length + 4 > png_ptr->buffer_size)\n      {\n         png_push_save_buffer(png_ptr);\n         return;\n      }\n\n      png_handle_iCCP(png_ptr, info_ptr, png_ptr->push_length);\n   }\n\n#endif\n#ifdef PNG_READ_sPLT_SUPPORTED\n   else if (chunk_name == png_sPLT)\n   {\n      if (png_ptr->push_length + 4 > png_ptr->buffer_size)\n      {\n         png_push_save_buffer(png_ptr);\n         return;\n      }\n\n      png_handle_sPLT(png_ptr, info_ptr, png_ptr->push_length);\n   }\n\n#endif\n#ifdef PNG_READ_tRNS_SUPPORTED\n   else if (chunk_name == png_tRNS)\n   {\n      if (png_ptr->push_length + 4 > png_ptr->buffer_size)\n      {\n         png_push_save_buffer(png_ptr);\n         return;\n      }\n\n      png_handle_tRNS(png_ptr, info_ptr, png_ptr->push_length);\n   }\n\n#endif\n#ifdef PNG_READ_bKGD_SUPPORTED\n   else if (chunk_name == png_bKGD)\n   {\n      if (png_ptr->push_length + 4 > png_ptr->buffer_size)\n      {\n         png_push_save_buffer(png_ptr);\n         return;\n      }\n\n      png_handle_bKGD(png_ptr, info_ptr, png_ptr->push_length);\n   }\n\n#endif\n#ifdef PNG_READ_hIST_SUPPORTED\n   else if (chunk_name == png_hIST)\n   {\n      if (png_ptr->push_length + 4 > png_ptr->buffer_size)\n      {\n         png_push_save_buffer(png_ptr);\n         return;\n      }\n\n      png_handle_hIST(png_ptr, info_ptr, png_ptr->push_length);\n   }\n\n#endif\n#ifdef PNG_READ_pHYs_SUPPORTED\n   else if (chunk_name == png_pHYs)\n   {\n      if (png_ptr->push_length + 4 > png_ptr->buffer_size)\n      {\n         png_push_save_buffer(png_ptr);\n         return;\n      }\n\n      png_handle_pHYs(png_ptr, info_ptr, png_ptr->push_length);\n   }\n\n#endif\n#ifdef PNG_READ_oFFs_SUPPORTED\n   else if (chunk_name == png_oFFs)\n   {\n      if (png_ptr->push_length + 4 > png_ptr->buffer_size)\n      {\n         png_push_save_buffer(png_ptr);\n         return;\n      }\n\n      png_handle_oFFs(png_ptr, info_ptr, png_ptr->push_length);\n   }\n#endif\n\n#ifdef PNG_READ_pCAL_SUPPORTED\n   else if (chunk_name == png_pCAL)\n   {\n      if (png_ptr->push_length + 4 > png_ptr->buffer_size)\n      {\n         png_push_save_buffer(png_ptr);\n         return;\n      }\n\n      png_handle_pCAL(png_ptr, info_ptr, png_ptr->push_length);\n   }\n\n#endif\n#ifdef PNG_READ_sCAL_SUPPORTED\n   else if (chunk_name == png_sCAL)\n   {\n      if (png_ptr->push_length + 4 > png_ptr->buffer_size)\n      {\n         png_push_save_buffer(png_ptr);\n         return;\n      }\n\n      png_handle_sCAL(png_ptr, info_ptr, png_ptr->push_length);\n   }\n\n#endif\n#ifdef PNG_READ_tIME_SUPPORTED\n   else if (chunk_name == png_tIME)\n   {\n      if (png_ptr->push_length + 4 > png_ptr->buffer_size)\n      {\n         png_push_save_buffer(png_ptr);\n         return;\n      }\n\n      png_handle_tIME(png_ptr, info_ptr, png_ptr->push_length);\n   }\n\n#endif\n#ifdef PNG_READ_tEXt_SUPPORTED\n   else if (chunk_name == png_tEXt)\n   {\n      if (png_ptr->push_length + 4 > png_ptr->buffer_size)\n      {\n         png_push_save_buffer(png_ptr);\n         return;\n      }\n\n      png_handle_tEXt(png_ptr, info_ptr, png_ptr->push_length);\n   }\n\n#endif\n#ifdef PNG_READ_zTXt_SUPPORTED\n   else if (chunk_name == png_zTXt)\n   {\n      if (png_ptr->push_length + 4 > png_ptr->buffer_size)\n      {\n         png_push_save_buffer(png_ptr);\n         return;\n      }\n\n      png_handle_zTXt(png_ptr, info_ptr, png_ptr->push_length);\n   }\n\n#endif\n#ifdef PNG_READ_iTXt_SUPPORTED\n   else if (chunk_name == png_iTXt)\n   {\n      if (png_ptr->push_length + 4 > png_ptr->buffer_size)\n      {\n         png_push_save_buffer(png_ptr);\n         return;\n      }\n\n      png_handle_iTXt(png_ptr, info_ptr, png_ptr->push_length);\n   }\n#endif\n\n   else\n   {\n      if (png_ptr->push_length + 4 > png_ptr->buffer_size)\n      {\n         png_push_save_buffer(png_ptr);\n         return;\n      }\n      png_handle_unknown(png_ptr, info_ptr, png_ptr->push_length,\n         PNG_HANDLE_CHUNK_AS_DEFAULT);\n   }\n\n   png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER;\n}\n\nvoid /* PRIVATE */\npng_push_crc_skip(png_structrp png_ptr, png_uint_32 skip)\n{\n   png_ptr->process_mode = PNG_SKIP_MODE;\n   png_ptr->skip_length = skip;\n}\n\nvoid /* PRIVATE */\npng_push_crc_finish(png_structrp png_ptr)\n{\n   if (png_ptr->skip_length && png_ptr->save_buffer_size)\n   {\n      png_size_t save_size = png_ptr->save_buffer_size;\n      png_uint_32 skip_length = png_ptr->skip_length;\n\n      /* We want the smaller of 'skip_length' and 'save_buffer_size', but\n       * they are of different types and we don't know which variable has the\n       * fewest bits.  Carefully select the smaller and cast it to the type of\n       * the larger - this cannot overflow.  Do not cast in the following test\n       * - it will break on either 16 or 64 bit platforms.\n       */\n      if (skip_length < save_size)\n         save_size = (png_size_t)skip_length;\n\n      else\n         skip_length = (png_uint_32)save_size;\n\n      png_calculate_crc(png_ptr, png_ptr->save_buffer_ptr, save_size);\n\n      png_ptr->skip_length -= skip_length;\n      png_ptr->buffer_size -= save_size;\n      png_ptr->save_buffer_size -= save_size;\n      png_ptr->save_buffer_ptr += save_size;\n   }\n   if (png_ptr->skip_length && png_ptr->current_buffer_size)\n   {\n      png_size_t save_size = png_ptr->current_buffer_size;\n      png_uint_32 skip_length = png_ptr->skip_length;\n\n      /* We want the smaller of 'skip_length' and 'current_buffer_size', here,\n       * the same problem exists as above and the same solution.\n       */\n      if (skip_length < save_size)\n         save_size = (png_size_t)skip_length;\n\n      else\n         skip_length = (png_uint_32)save_size;\n\n      png_calculate_crc(png_ptr, png_ptr->current_buffer_ptr, save_size);\n\n      png_ptr->skip_length -= skip_length;\n      png_ptr->buffer_size -= save_size;\n      png_ptr->current_buffer_size -= save_size;\n      png_ptr->current_buffer_ptr += save_size;\n   }\n   if (!png_ptr->skip_length)\n   {\n      if (png_ptr->buffer_size < 4)\n      {\n         png_push_save_buffer(png_ptr);\n         return;\n      }\n\n      png_crc_finish(png_ptr, 0);\n      png_ptr->process_mode = PNG_READ_CHUNK_MODE;\n   }\n}\n\nvoid PNGCBAPI\npng_push_fill_buffer(png_structp png_ptr, png_bytep buffer, png_size_t length)\n{\n   png_bytep ptr;\n\n   if (png_ptr == NULL)\n      return;\n\n   ptr = buffer;\n   if (png_ptr->save_buffer_size)\n   {\n      png_size_t save_size;\n\n      if (length < png_ptr->save_buffer_size)\n         save_size = length;\n\n      else\n         save_size = png_ptr->save_buffer_size;\n\n      memcpy(ptr, png_ptr->save_buffer_ptr, save_size);\n      length -= save_size;\n      ptr += save_size;\n      png_ptr->buffer_size -= save_size;\n      png_ptr->save_buffer_size -= save_size;\n      png_ptr->save_buffer_ptr += save_size;\n   }\n   if (length && png_ptr->current_buffer_size)\n   {\n      png_size_t save_size;\n\n      if (length < png_ptr->current_buffer_size)\n         save_size = length;\n\n      else\n         save_size = png_ptr->current_buffer_size;\n\n      memcpy(ptr, png_ptr->current_buffer_ptr, save_size);\n      png_ptr->buffer_size -= save_size;\n      png_ptr->current_buffer_size -= save_size;\n      png_ptr->current_buffer_ptr += save_size;\n   }\n}\n\nvoid /* PRIVATE */\npng_push_save_buffer(png_structrp png_ptr)\n{\n   if (png_ptr->save_buffer_size)\n   {\n      if (png_ptr->save_buffer_ptr != png_ptr->save_buffer)\n      {\n         png_size_t i, istop;\n         png_bytep sp;\n         png_bytep dp;\n\n         istop = png_ptr->save_buffer_size;\n         for (i = 0, sp = png_ptr->save_buffer_ptr, dp = png_ptr->save_buffer;\n             i < istop; i++, sp++, dp++)\n         {\n            *dp = *sp;\n         }\n      }\n   }\n   if (png_ptr->save_buffer_size + png_ptr->current_buffer_size >\n       png_ptr->save_buffer_max)\n   {\n      png_size_t new_max;\n      png_bytep old_buffer;\n\n      if (png_ptr->save_buffer_size > PNG_SIZE_MAX -\n          (png_ptr->current_buffer_size + 256))\n      {\n         png_error(png_ptr, \"Potential overflow of save_buffer\");\n      }\n\n      new_max = png_ptr->save_buffer_size + png_ptr->current_buffer_size + 256;\n      old_buffer = png_ptr->save_buffer;\n      png_ptr->save_buffer = (png_bytep)png_malloc_warn(png_ptr,\n          (png_size_t)new_max);\n\n      if (png_ptr->save_buffer == NULL)\n      {\n         png_free(png_ptr, old_buffer);\n         png_error(png_ptr, \"Insufficient memory for save_buffer\");\n      }\n\n      memcpy(png_ptr->save_buffer, old_buffer, png_ptr->save_buffer_size);\n      png_free(png_ptr, old_buffer);\n      png_ptr->save_buffer_max = new_max;\n   }\n   if (png_ptr->current_buffer_size)\n   {\n      memcpy(png_ptr->save_buffer + png_ptr->save_buffer_size,\n         png_ptr->current_buffer_ptr, png_ptr->current_buffer_size);\n      png_ptr->save_buffer_size += png_ptr->current_buffer_size;\n      png_ptr->current_buffer_size = 0;\n   }\n   png_ptr->save_buffer_ptr = png_ptr->save_buffer;\n   png_ptr->buffer_size = 0;\n}\n\nvoid /* PRIVATE */\npng_push_restore_buffer(png_structrp png_ptr, png_bytep buffer,\n   png_size_t buffer_length)\n{\n   png_ptr->current_buffer = buffer;\n   png_ptr->current_buffer_size = buffer_length;\n   png_ptr->buffer_size = buffer_length + png_ptr->save_buffer_size;\n   png_ptr->current_buffer_ptr = png_ptr->current_buffer;\n}\n\nvoid /* PRIVATE */\npng_push_read_IDAT(png_structrp png_ptr)\n{\n   if (!(png_ptr->mode & PNG_HAVE_CHUNK_HEADER))\n   {\n      png_byte chunk_length[4];\n      png_byte chunk_tag[4];\n\n      /* TODO: this code can be commoned up with the same code in push_read */\n      if (png_ptr->buffer_size < 8)\n      {\n         png_push_save_buffer(png_ptr);\n         return;\n      }\n\n      png_push_fill_buffer(png_ptr, chunk_length, 4);\n      png_ptr->push_length = png_get_uint_31(png_ptr, chunk_length);\n      png_reset_crc(png_ptr);\n      png_crc_read(png_ptr, chunk_tag, 4);\n      png_ptr->chunk_name = PNG_CHUNK_FROM_STRING(chunk_tag);\n      png_ptr->mode |= PNG_HAVE_CHUNK_HEADER;\n\n      if (png_ptr->chunk_name != png_IDAT)\n      {\n         png_ptr->process_mode = PNG_READ_CHUNK_MODE;\n\n         if (!(png_ptr->flags & PNG_FLAG_ZSTREAM_ENDED))\n            png_error(png_ptr, \"Not enough compressed data\");\n\n         return;\n      }\n\n      png_ptr->idat_size = png_ptr->push_length;\n   }\n\n   if (png_ptr->idat_size && png_ptr->save_buffer_size)\n   {\n      png_size_t save_size = png_ptr->save_buffer_size;\n      png_uint_32 idat_size = png_ptr->idat_size;\n\n      /* We want the smaller of 'idat_size' and 'current_buffer_size', but they\n       * are of different types and we don't know which variable has the fewest\n       * bits.  Carefully select the smaller and cast it to the type of the\n       * larger - this cannot overflow.  Do not cast in the following test - it\n       * will break on either 16 or 64 bit platforms.\n       */\n      if (idat_size < save_size)\n         save_size = (png_size_t)idat_size;\n\n      else\n         idat_size = (png_uint_32)save_size;\n\n      png_calculate_crc(png_ptr, png_ptr->save_buffer_ptr, save_size);\n\n      png_process_IDAT_data(png_ptr, png_ptr->save_buffer_ptr, save_size);\n\n      png_ptr->idat_size -= idat_size;\n      png_ptr->buffer_size -= save_size;\n      png_ptr->save_buffer_size -= save_size;\n      png_ptr->save_buffer_ptr += save_size;\n   }\n\n   if (png_ptr->idat_size && png_ptr->current_buffer_size)\n   {\n      png_size_t save_size = png_ptr->current_buffer_size;\n      png_uint_32 idat_size = png_ptr->idat_size;\n\n      /* We want the smaller of 'idat_size' and 'current_buffer_size', but they\n       * are of different types and we don't know which variable has the fewest\n       * bits.  Carefully select the smaller and cast it to the type of the\n       * larger - this cannot overflow.\n       */\n      if (idat_size < save_size)\n         save_size = (png_size_t)idat_size;\n\n      else\n         idat_size = (png_uint_32)save_size;\n\n      png_calculate_crc(png_ptr, png_ptr->current_buffer_ptr, save_size);\n\n      png_process_IDAT_data(png_ptr, png_ptr->current_buffer_ptr, save_size);\n\n      png_ptr->idat_size -= idat_size;\n      png_ptr->buffer_size -= save_size;\n      png_ptr->current_buffer_size -= save_size;\n      png_ptr->current_buffer_ptr += save_size;\n   }\n   if (!png_ptr->idat_size)\n   {\n      if (png_ptr->buffer_size < 4)\n      {\n         png_push_save_buffer(png_ptr);\n         return;\n      }\n\n      png_crc_finish(png_ptr, 0);\n      png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER;\n      png_ptr->mode |= PNG_AFTER_IDAT;\n      png_ptr->zowner = 0;\n   }\n}\n\nvoid /* PRIVATE */\npng_process_IDAT_data(png_structrp png_ptr, png_bytep buffer,\n   png_size_t buffer_length)\n{\n   /* The caller checks for a non-zero buffer length. */\n   if (!(buffer_length > 0) || buffer == NULL)\n      png_error(png_ptr, \"No IDAT data (internal error)\");\n\n   /* This routine must process all the data it has been given\n    * before returning, calling the row callback as required to\n    * handle the uncompressed results.\n    */\n   png_ptr->zstream.next_in = buffer;\n   /* TODO: WARNING: TRUNCATION ERROR: DANGER WILL ROBINSON: */\n   png_ptr->zstream.avail_in = (uInt)buffer_length;\n\n   /* Keep going until the decompressed data is all processed\n    * or the stream marked as finished.\n    */\n   while (png_ptr->zstream.avail_in > 0 &&\n      !(png_ptr->flags & PNG_FLAG_ZSTREAM_ENDED))\n   {\n      int ret;\n\n      /* We have data for zlib, but we must check that zlib\n       * has someplace to put the results.  It doesn't matter\n       * if we don't expect any results -- it may be the input\n       * data is just the LZ end code.\n       */\n      if (!(png_ptr->zstream.avail_out > 0))\n      {\n         /* TODO: WARNING: TRUNCATION ERROR: DANGER WILL ROBINSON: */\n         png_ptr->zstream.avail_out = (uInt)(PNG_ROWBYTES(png_ptr->pixel_depth,\n             png_ptr->iwidth) + 1);\n\n         png_ptr->zstream.next_out = png_ptr->row_buf;\n      }\n\n      /* Using Z_SYNC_FLUSH here means that an unterminated\n       * LZ stream (a stream with a missing end code) can still\n       * be handled, otherwise (Z_NO_FLUSH) a future zlib\n       * implementation might defer output and therefore\n       * change the current behavior (see comments in inflate.c\n       * for why this doesn't happen at present with zlib 1.2.5).\n       */\n      ret = inflate(&png_ptr->zstream, Z_SYNC_FLUSH);\n\n      /* Check for any failure before proceeding. */\n      if (ret != Z_OK && ret != Z_STREAM_END)\n      {\n         /* Terminate the decompression. */\n         png_ptr->flags |= PNG_FLAG_ZSTREAM_ENDED;\n         png_ptr->zowner = 0;\n\n         /* This may be a truncated stream (missing or\n          * damaged end code).  Treat that as a warning.\n          */\n         if (png_ptr->row_number >= png_ptr->num_rows ||\n             png_ptr->pass > 6)\n            png_warning(png_ptr, \"Truncated compressed data in IDAT\");\n\n         else\n            png_error(png_ptr, \"Decompression error in IDAT\");\n\n         /* Skip the check on unprocessed input */\n         return;\n      }\n\n      /* Did inflate output any data? */\n      if (png_ptr->zstream.next_out != png_ptr->row_buf)\n      {\n         /* Is this unexpected data after the last row?\n          * If it is, artificially terminate the LZ output\n          * here.\n          */\n         if (png_ptr->row_number >= png_ptr->num_rows ||\n             png_ptr->pass > 6)\n         {\n            /* Extra data. */\n            png_warning(png_ptr, \"Extra compressed data in IDAT\");\n            png_ptr->flags |= PNG_FLAG_ZSTREAM_ENDED;\n            png_ptr->zowner = 0;\n\n            /* Do no more processing; skip the unprocessed\n             * input check below.\n             */\n            return;\n         }\n\n         /* Do we have a complete row? */\n         if (png_ptr->zstream.avail_out == 0)\n            png_push_process_row(png_ptr);\n      }\n\n      /* And check for the end of the stream. */\n      if (ret == Z_STREAM_END)\n         png_ptr->flags |= PNG_FLAG_ZSTREAM_ENDED;\n   }\n\n   /* All the data should have been processed, if anything\n    * is left at this point we have bytes of IDAT data\n    * after the zlib end code.\n    */\n   if (png_ptr->zstream.avail_in > 0)\n      png_warning(png_ptr, \"Extra compression data in IDAT\");\n}\n\nvoid /* PRIVATE */\npng_push_process_row(png_structrp png_ptr)\n{\n   /* 1.5.6: row_info moved out of png_struct to a local here. */\n   png_row_info row_info;\n\n   row_info.width = png_ptr->iwidth; /* NOTE: width of current interlaced row */\n   row_info.color_type = png_ptr->color_type;\n   row_info.bit_depth = png_ptr->bit_depth;\n   row_info.channels = png_ptr->channels;\n   row_info.pixel_depth = png_ptr->pixel_depth;\n   row_info.rowbytes = PNG_ROWBYTES(row_info.pixel_depth, row_info.width);\n\n   if (png_ptr->row_buf[0] > PNG_FILTER_VALUE_NONE)\n   {\n      if (png_ptr->row_buf[0] < PNG_FILTER_VALUE_LAST)\n         png_read_filter_row(png_ptr, &row_info, png_ptr->row_buf + 1,\n            png_ptr->prev_row + 1, png_ptr->row_buf[0]);\n      else\n         png_error(png_ptr, \"bad adaptive filter value\");\n   }\n\n   /* libpng 1.5.6: the following line was copying png_ptr->rowbytes before\n    * 1.5.6, while the buffer really is this big in current versions of libpng\n    * it may not be in the future, so this was changed just to copy the\n    * interlaced row count:\n    */\n   memcpy(png_ptr->prev_row, png_ptr->row_buf, row_info.rowbytes + 1);\n\n#ifdef PNG_READ_TRANSFORMS_SUPPORTED\n   if (png_ptr->transformations)\n      png_do_read_transformations(png_ptr, &row_info);\n#endif\n\n   /* The transformed pixel depth should match the depth now in row_info. */\n   if (png_ptr->transformed_pixel_depth == 0)\n   {\n      png_ptr->transformed_pixel_depth = row_info.pixel_depth;\n      if (row_info.pixel_depth > png_ptr->maximum_pixel_depth)\n         png_error(png_ptr, \"progressive row overflow\");\n   }\n\n   else if (png_ptr->transformed_pixel_depth != row_info.pixel_depth)\n      png_error(png_ptr, \"internal progressive row size calculation error\");\n\n\n#ifdef PNG_READ_INTERLACING_SUPPORTED\n   /* Blow up interlaced rows to full size */\n   if (png_ptr->interlaced && (png_ptr->transformations & PNG_INTERLACE))\n   {\n      if (png_ptr->pass < 6)\n         png_do_read_interlace(&row_info, png_ptr->row_buf + 1, png_ptr->pass,\n            png_ptr->transformations);\n\n    switch (png_ptr->pass)\n    {\n         case 0:\n         {\n            int i;\n            for (i = 0; i < 8 && png_ptr->pass == 0; i++)\n            {\n               png_push_have_row(png_ptr, png_ptr->row_buf + 1);\n               png_read_push_finish_row(png_ptr); /* Updates png_ptr->pass */\n            }\n\n            if (png_ptr->pass == 2) /* Pass 1 might be empty */\n            {\n               for (i = 0; i < 4 && png_ptr->pass == 2; i++)\n               {\n                  png_push_have_row(png_ptr, NULL);\n                  png_read_push_finish_row(png_ptr);\n               }\n            }\n\n            if (png_ptr->pass == 4 && png_ptr->height <= 4)\n            {\n               for (i = 0; i < 2 && png_ptr->pass == 4; i++)\n               {\n                  png_push_have_row(png_ptr, NULL);\n                  png_read_push_finish_row(png_ptr);\n               }\n            }\n\n            if (png_ptr->pass == 6 && png_ptr->height <= 4)\n            {\n                png_push_have_row(png_ptr, NULL);\n                png_read_push_finish_row(png_ptr);\n            }\n\n            break;\n         }\n\n         case 1:\n         {\n            int i;\n            for (i = 0; i < 8 && png_ptr->pass == 1; i++)\n            {\n               png_push_have_row(png_ptr, png_ptr->row_buf + 1);\n               png_read_push_finish_row(png_ptr);\n            }\n\n            if (png_ptr->pass == 2) /* Skip top 4 generated rows */\n            {\n               for (i = 0; i < 4 && png_ptr->pass == 2; i++)\n               {\n                  png_push_have_row(png_ptr, NULL);\n                  png_read_push_finish_row(png_ptr);\n               }\n            }\n\n            break;\n         }\n\n         case 2:\n         {\n            int i;\n\n            for (i = 0; i < 4 && png_ptr->pass == 2; i++)\n            {\n               png_push_have_row(png_ptr, png_ptr->row_buf + 1);\n               png_read_push_finish_row(png_ptr);\n            }\n\n            for (i = 0; i < 4 && png_ptr->pass == 2; i++)\n            {\n               png_push_have_row(png_ptr, NULL);\n               png_read_push_finish_row(png_ptr);\n            }\n\n            if (png_ptr->pass == 4) /* Pass 3 might be empty */\n            {\n               for (i = 0; i < 2 && png_ptr->pass == 4; i++)\n               {\n                  png_push_have_row(png_ptr, NULL);\n                  png_read_push_finish_row(png_ptr);\n               }\n            }\n\n            break;\n         }\n\n         case 3:\n         {\n            int i;\n\n            for (i = 0; i < 4 && png_ptr->pass == 3; i++)\n            {\n               png_push_have_row(png_ptr, png_ptr->row_buf + 1);\n               png_read_push_finish_row(png_ptr);\n            }\n\n            if (png_ptr->pass == 4) /* Skip top two generated rows */\n            {\n               for (i = 0; i < 2 && png_ptr->pass == 4; i++)\n               {\n                  png_push_have_row(png_ptr, NULL);\n                  png_read_push_finish_row(png_ptr);\n               }\n            }\n\n            break;\n         }\n\n         case 4:\n         {\n            int i;\n\n            for (i = 0; i < 2 && png_ptr->pass == 4; i++)\n            {\n               png_push_have_row(png_ptr, png_ptr->row_buf + 1);\n               png_read_push_finish_row(png_ptr);\n            }\n\n            for (i = 0; i < 2 && png_ptr->pass == 4; i++)\n            {\n               png_push_have_row(png_ptr, NULL);\n               png_read_push_finish_row(png_ptr);\n            }\n\n            if (png_ptr->pass == 6) /* Pass 5 might be empty */\n            {\n               png_push_have_row(png_ptr, NULL);\n               png_read_push_finish_row(png_ptr);\n            }\n\n            break;\n         }\n\n         case 5:\n         {\n            int i;\n\n            for (i = 0; i < 2 && png_ptr->pass == 5; i++)\n            {\n               png_push_have_row(png_ptr, png_ptr->row_buf + 1);\n               png_read_push_finish_row(png_ptr);\n            }\n\n            if (png_ptr->pass == 6) /* Skip top generated row */\n            {\n               png_push_have_row(png_ptr, NULL);\n               png_read_push_finish_row(png_ptr);\n            }\n\n            break;\n         }\n\n         default:\n         case 6:\n         {\n            png_push_have_row(png_ptr, png_ptr->row_buf + 1);\n            png_read_push_finish_row(png_ptr);\n\n            if (png_ptr->pass != 6)\n               break;\n\n            png_push_have_row(png_ptr, NULL);\n            png_read_push_finish_row(png_ptr);\n         }\n      }\n   }\n   else\n#endif\n   {\n      png_push_have_row(png_ptr, png_ptr->row_buf + 1);\n      png_read_push_finish_row(png_ptr);\n   }\n}\n\nvoid /* PRIVATE */\npng_read_push_finish_row(png_structrp png_ptr)\n{\n#ifdef PNG_READ_INTERLACING_SUPPORTED\n   /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */\n\n   /* Start of interlace block */\n   static PNG_CONST png_byte png_pass_start[] = {0, 4, 0, 2, 0, 1, 0};\n\n   /* Offset to next interlace block */\n   static PNG_CONST png_byte png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1};\n\n   /* Start of interlace block in the y direction */\n   static PNG_CONST png_byte png_pass_ystart[] = {0, 0, 4, 0, 2, 0, 1};\n\n   /* Offset to next interlace block in the y direction */\n   static PNG_CONST png_byte png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2};\n\n   /* Height of interlace block.  This is not currently used - if you need\n    * it, uncomment it here and in png.h\n   static PNG_CONST png_byte png_pass_height[] = {8, 8, 4, 4, 2, 2, 1};\n   */\n#endif\n\n   png_ptr->row_number++;\n   if (png_ptr->row_number < png_ptr->num_rows)\n      return;\n\n#ifdef PNG_READ_INTERLACING_SUPPORTED\n   if (png_ptr->interlaced)\n   {\n      png_ptr->row_number = 0;\n      memset(png_ptr->prev_row, 0, png_ptr->rowbytes + 1);\n\n      do\n      {\n         png_ptr->pass++;\n         if ((png_ptr->pass == 1 && png_ptr->width < 5) ||\n             (png_ptr->pass == 3 && png_ptr->width < 3) ||\n             (png_ptr->pass == 5 && png_ptr->width < 2))\n            png_ptr->pass++;\n\n         if (png_ptr->pass > 7)\n            png_ptr->pass--;\n\n         if (png_ptr->pass >= 7)\n            break;\n\n         png_ptr->iwidth = (png_ptr->width +\n             png_pass_inc[png_ptr->pass] - 1 -\n             png_pass_start[png_ptr->pass]) /\n             png_pass_inc[png_ptr->pass];\n\n         if (png_ptr->transformations & PNG_INTERLACE)\n            break;\n\n         png_ptr->num_rows = (png_ptr->height +\n             png_pass_yinc[png_ptr->pass] - 1 -\n             png_pass_ystart[png_ptr->pass]) /\n             png_pass_yinc[png_ptr->pass];\n\n      } while (png_ptr->iwidth == 0 || png_ptr->num_rows == 0);\n   }\n#endif /* PNG_READ_INTERLACING_SUPPORTED */\n}\n\nvoid /* PRIVATE */\npng_push_have_info(png_structrp png_ptr, png_inforp info_ptr)\n{\n   if (png_ptr->info_fn != NULL)\n      (*(png_ptr->info_fn))(png_ptr, info_ptr);\n}\n\nvoid /* PRIVATE */\npng_push_have_end(png_structrp png_ptr, png_inforp info_ptr)\n{\n   if (png_ptr->end_fn != NULL)\n      (*(png_ptr->end_fn))(png_ptr, info_ptr);\n}\n\nvoid /* PRIVATE */\npng_push_have_row(png_structrp png_ptr, png_bytep row)\n{\n   if (png_ptr->row_fn != NULL)\n      (*(png_ptr->row_fn))(png_ptr, row, png_ptr->row_number,\n         (int)png_ptr->pass);\n}\n\n#ifdef PNG_READ_INTERLACING_SUPPORTED\nvoid PNGAPI\npng_progressive_combine_row(png_const_structrp png_ptr, png_bytep old_row,\n    png_const_bytep new_row)\n{\n   if (png_ptr == NULL)\n      return;\n\n   /* new_row is a flag here - if it is NULL then the app callback was called\n    * from an empty row (see the calls to png_struct::row_fn below), otherwise\n    * it must be png_ptr->row_buf+1\n    */\n   if (new_row != NULL)\n      png_combine_row(png_ptr, old_row, 1/*display*/);\n}\n#endif /* PNG_READ_INTERLACING_SUPPORTED */\n\nvoid PNGAPI\npng_set_progressive_read_fn(png_structrp png_ptr, png_voidp progressive_ptr,\n    png_progressive_info_ptr info_fn, png_progressive_row_ptr row_fn,\n    png_progressive_end_ptr end_fn)\n{\n   if (png_ptr == NULL)\n      return;\n\n   png_ptr->info_fn = info_fn;\n   png_ptr->row_fn = row_fn;\n   png_ptr->end_fn = end_fn;\n\n   png_set_read_fn(png_ptr, progressive_ptr, png_push_fill_buffer);\n}\n\npng_voidp PNGAPI\npng_get_progressive_ptr(png_const_structrp png_ptr)\n{\n   if (png_ptr == NULL)\n      return (NULL);\n\n   return png_ptr->io_ptr;\n}\n#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */\n"
  },
  {
    "path": "Projects/Libraries/CSBase/Source/png/pngpriv.h",
    "content": "\n/* pngpriv.h - private declarations for use inside libpng\n *\n * For conditions of distribution and use, see copyright notice in png.h\n * Copyright (c) 1998-2014 Glenn Randers-Pehrson\n * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)\n * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)\n *\n * Last changed in libpng 1.6.10 [March 6, 2014]\n *\n * This code is released under the libpng license.\n * For conditions of distribution and use, see the disclaimer\n * and license in png.h\n */\n\n/* The symbols declared in this file (including the functions declared\n * as extern) are PRIVATE.  They are not part of the libpng public\n * interface, and are not recommended for use by regular applications.\n * Some of them may become public in the future; others may stay private,\n * change in an incompatible way, or even disappear.\n * Although the libpng users are not forbidden to include this header,\n * they should be well aware of the issues that may arise from doing so.\n */\n\n#ifndef PNGPRIV_H\n#define PNGPRIV_H\n\n/* Feature Test Macros.  The following are defined here to ensure that correctly\n * implemented libraries reveal the APIs libpng needs to build and hide those\n * that are not needed and potentially damaging to the compilation.\n *\n * Feature Test Macros must be defined before any system header is included (see\n * POSIX 1003.1 2.8.2 \"POSIX Symbols.\"\n *\n * These macros only have an effect if the operating system supports either\n * POSIX 1003.1 or C99, or both.  On other operating systems (particularly\n * Windows/Visual Studio) there is no effect; the OS specific tests below are\n * still required (as of 2011-05-02.)\n */\n#define _POSIX_SOURCE 1 /* Just the POSIX 1003.1 and C89 APIs */\n\n#ifndef PNG_VERSION_INFO_ONLY\n/* Standard library headers not required by png.h: */\n#  include <stdlib.h>\n#  include <string.h>\n#endif\n\n#define PNGLIB_BUILD /*libpng is being built, not used*/\n\n/* If HAVE_CONFIG_H is defined during the build then the build system must\n * provide an appropriate \"config.h\" file on the include path.  The header file\n * must provide definitions as required below (search for \"HAVE_CONFIG_H\");\n * see configure.ac for more details of the requirements.  The macro\n * \"PNG_NO_CONFIG_H\" is provided for maintainers to test for dependencies on\n * 'configure'; define this macro to prevent the configure build including the\n * configure generated config.h.  Libpng is expected to compile without *any*\n * special build system support on a reasonably ANSI-C compliant system.\n */\n#if defined(HAVE_CONFIG_H) && !defined(PNG_NO_CONFIG_H)\n#  include <config.h>\n\n   /* Pick up the definition of 'restrict' from config.h if it was read: */\n#  define PNG_RESTRICT restrict\n#endif\n\n/* To support symbol prefixing it is necessary to know *before* including png.h\n * whether the fixed point (and maybe other) APIs are exported, because if they\n * are not internal definitions may be required.  This is handled below just\n * before png.h is included, but load the configuration now if it is available.\n */\n#ifndef PNGLCONF_H\n#  include \"pnglibconf.h\"\n#endif\n\n/* Local renames may change non-exported API functions from png.h */\n#if defined(PNG_PREFIX) && !defined(PNGPREFIX_H)\n#  include \"pngprefix.h\"\n#endif\n\n#ifdef PNG_USER_CONFIG\n#  include \"pngusr.h\"\n   /* These should have been defined in pngusr.h */\n#  ifndef PNG_USER_PRIVATEBUILD\n#    define PNG_USER_PRIVATEBUILD \"Custom libpng build\"\n#  endif\n#  ifndef PNG_USER_DLLFNAME_POSTFIX\n#    define PNG_USER_DLLFNAME_POSTFIX \"Cb\"\n#  endif\n#endif\n\n/* Compile time options.\n * =====================\n * In a multi-arch build the compiler may compile the code several times for the\n * same object module, producing different binaries for different architectures.\n * When this happens configure-time setting of the target host options cannot be\n * done and this interferes with the handling of the ARM NEON optimizations, and\n * possibly other similar optimizations.  Put additional tests here; in general\n * this is needed when the same option can be changed at both compile time and\n * run time depending on the target OS (i.e. iOS vs Android.)\n *\n * NOTE: symbol prefixing does not pass $(CFLAGS) to the preprocessor, because\n * this is not possible with certain compilers (Oracle SUN OS CC), as a result\n * it is necessary to ensure that all extern functions that *might* be used\n * regardless of $(CFLAGS) get declared in this file.  The test on __ARM_NEON__\n * below is one example of this behavior because it is controlled by the\n * presence or not of -mfpu=neon on the GCC command line, it is possible to do\n * this in $(CC), e.g. \"CC=gcc -mfpu=neon\", but people who build libpng rarely\n * do this.\n */\n#ifndef PNG_ARM_NEON_OPT\n   /* ARM NEON optimizations are being controlled by the compiler settings,\n    * typically the target FPU.  If the FPU has been set to NEON (-mfpu=neon\n    * with GCC) then the compiler will define __ARM_NEON__ and we can rely\n    * unconditionally on NEON instructions not crashing, otherwise we must\n    * disable use of NEON instructions.\n    *\n    * NOTE: at present these optimizations depend on 'ALIGNED_MEMORY', so they\n    * can only be turned on automatically if that is supported too.  If\n    * PNG_ARM_NEON_OPT is set in CPPFLAGS (to >0) then arm/arm_init.c will fail\n    * to compile with an appropriate #error if ALIGNED_MEMORY has been turned\n    * off.\n    */\n#  if defined(__ARM_NEON__) && defined(PNG_ALIGNED_MEMORY_SUPPORTED)\n#     define PNG_ARM_NEON_OPT 2\n#  else\n#     define PNG_ARM_NEON_OPT 0\n#  endif\n#endif\n\n#if PNG_ARM_NEON_OPT > 0\n   /* NEON optimizations are to be at least considered by libpng, so enable the\n    * callbacks to do this.\n    */\n#  define PNG_FILTER_OPTIMIZATIONS png_init_filter_functions_neon\n\n   /* By default the 'intrinsics' code in arm/filter_neon_intrinsics.c is used\n    * if possible - if __ARM_NEON__ is set and the compiler version is not known\n    * to be broken.  This is controlled by PNG_ARM_NEON_IMPLEMENTATION which can\n    * be:\n    *\n    *    1  The intrinsics code (the default with __ARM_NEON__)\n    *    2  The hand coded assembler (the default without __ARM_NEON__)\n    *\n    * It is possible to set PNG_ARM_NEON_IMPLEMENTATION in CPPFLAGS, however\n    * this is *NOT* supported and may cease to work even after a minor revision\n    * to libpng.  It *is* valid to do this for testing purposes, e.g. speed\n    * testing or a new compiler, but the results should be communicated to the\n    * libpng implementation list for incorporation in the next minor release.\n    */\n#  ifndef PNG_ARM_NEON_IMPLEMENTATION\n#     ifdef __ARM_NEON__\n#        if defined(__clang__)\n            /* At present it is unknown by the libpng developers which versions\n             * of clang support the intrinsics, however some or perhaps all\n             * versions do not work with the assembler so this may be\n             * irrelevant, so just use the default (do nothing here.)\n             */\n#        elif defined(__GNUC__)\n            /* GCC 4.5.4 NEON support is known to be broken.  4.6.3 is known to\n             * work, so if this *is* GCC, or G++, look for a version >4.5\n             */\n#           if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 6)\n#              define PNG_ARM_NEON_IMPLEMENTATION 2\n#           endif /* no GNUC support */\n#        endif /* __GNUC__ */\n#     else /* !defined __ARM_NEON__ */\n         /* The 'intrinsics' code simply won't compile without this -mfpu=neon:\n          */\n#        define PNG_ARM_NEON_IMPLEMENTATION 2\n#     endif /* __ARM_NEON__ */\n#  endif /* !defined PNG_ARM_NEON_IMPLEMENTATION */\n\n#  ifndef PNG_ARM_NEON_IMPLEMENTATION\n      /* Use the intrinsics code by default. */\n#     define PNG_ARM_NEON_IMPLEMENTATION 1\n#  endif\n#endif /* PNG_ARM_NEON_OPT > 0 */\n\n/* Is this a build of a DLL where compilation of the object modules requires\n * different preprocessor settings to those required for a simple library?  If\n * so PNG_BUILD_DLL must be set.\n *\n * If libpng is used inside a DLL but that DLL does not export the libpng APIs\n * PNG_BUILD_DLL must not be set.  To avoid the code below kicking in build a\n * static library of libpng then link the DLL against that.\n */\n#ifndef PNG_BUILD_DLL\n#  ifdef DLL_EXPORT\n      /* This is set by libtool when files are compiled for a DLL; libtool\n       * always compiles twice, even on systems where it isn't necessary.  Set\n       * PNG_BUILD_DLL in case it is necessary:\n       */\n#     define PNG_BUILD_DLL\n#  else\n#     ifdef _WINDLL\n         /* This is set by the Microsoft Visual Studio IDE in projects that\n          * build a DLL.  It can't easily be removed from those projects (it\n          * isn't visible in the Visual Studio UI) so it is a fairly reliable\n          * indication that PNG_IMPEXP needs to be set to the DLL export\n          * attributes.\n          */\n#        define PNG_BUILD_DLL\n#     else\n#        ifdef __DLL__\n            /* This is set by the Borland C system when compiling for a DLL\n             * (as above.)\n             */\n#           define PNG_BUILD_DLL\n#        else\n            /* Add additional compiler cases here. */\n#        endif\n#     endif\n#  endif\n#endif /* Setting PNG_BUILD_DLL if required */\n\n/* See pngconf.h for more details: the builder of the library may set this on\n * the command line to the right thing for the specific compilation system or it\n * may be automagically set above (at present we know of no system where it does\n * need to be set on the command line.)\n *\n * PNG_IMPEXP must be set here when building the library to prevent pngconf.h\n * setting it to the \"import\" setting for a DLL build.\n */\n#ifndef PNG_IMPEXP\n#  ifdef PNG_BUILD_DLL\n#     define PNG_IMPEXP PNG_DLL_EXPORT\n#  else\n      /* Not building a DLL, or the DLL doesn't require specific export\n       * definitions.\n       */\n#     define PNG_IMPEXP\n#  endif\n#endif\n\n/* No warnings for private or deprecated functions in the build: */\n#ifndef PNG_DEPRECATED\n#  define PNG_DEPRECATED\n#endif\n#ifndef PNG_PRIVATE\n#  define PNG_PRIVATE\n#endif\n\n/* Symbol preprocessing support.\n *\n * To enable listing global, but internal, symbols the following macros should\n * always be used to declare an extern data or function object in this file.\n */\n#ifndef PNG_INTERNAL_DATA\n#  define PNG_INTERNAL_DATA(type, name, array) extern type name array\n#endif\n\n#ifndef PNG_INTERNAL_FUNCTION\n#  define PNG_INTERNAL_FUNCTION(type, name, args, attributes)\\\n      extern PNG_FUNCTION(type, name, args, PNG_EMPTY attributes)\n#endif\n\n#ifndef PNG_INTERNAL_CALLBACK\n#  define PNG_INTERNAL_CALLBACK(type, name, args, attributes)\\\n      extern PNG_FUNCTION(type, (PNGCBAPI name), args, PNG_EMPTY attributes)\n#endif\n\n/* If floating or fixed point APIs are disabled they may still be compiled\n * internally.  To handle this make sure they are declared as the appropriate\n * internal extern function (otherwise the symbol prefixing stuff won't work and\n * the functions will be used without definitions.)\n *\n * NOTE: although all the API functions are declared here they are not all\n * actually built!  Because the declarations are still made it is necessary to\n * fake out types that they depend on.\n */\n#ifndef PNG_FP_EXPORT\n#  ifndef PNG_FLOATING_POINT_SUPPORTED\n#     define PNG_FP_EXPORT(ordinal, type, name, args)\\\n         PNG_INTERNAL_FUNCTION(type, name, args, PNG_EMPTY);\n#     ifndef PNG_VERSION_INFO_ONLY\n         typedef struct png_incomplete png_double;\n         typedef png_double*           png_doublep;\n         typedef const png_double*     png_const_doublep;\n         typedef png_double**          png_doublepp;\n#     endif\n#  endif\n#endif\n#ifndef PNG_FIXED_EXPORT\n#  ifndef PNG_FIXED_POINT_SUPPORTED\n#     define PNG_FIXED_EXPORT(ordinal, type, name, args)\\\n         PNG_INTERNAL_FUNCTION(type, name, args, PNG_EMPTY);\n#  endif\n#endif\n\n#include \"png.h\"\n\n/* pngconf.h does not set PNG_DLL_EXPORT unless it is required, so: */\n#ifndef PNG_DLL_EXPORT\n#  define PNG_DLL_EXPORT\n#endif\n\n/* SECURITY and SAFETY:\n *\n * By default libpng is built without any internal limits on image size,\n * individual heap (png_malloc) allocations or the total amount of memory used.\n * If PNG_SAFE_LIMITS_SUPPORTED is defined, however, the limits below are used\n * (unless individually overridden).  These limits are believed to be fairly\n * safe, but builders of secure systems should verify the values against the\n * real system capabilities.\n */\n#ifdef PNG_SAFE_LIMITS_SUPPORTED\n   /* 'safe' limits */\n#  ifndef PNG_USER_WIDTH_MAX\n#     define PNG_USER_WIDTH_MAX 1000000\n#  endif\n#  ifndef PNG_USER_HEIGHT_MAX\n#     define PNG_USER_HEIGHT_MAX 1000000\n#  endif\n#  ifndef PNG_USER_CHUNK_CACHE_MAX\n#     define PNG_USER_CHUNK_CACHE_MAX 128\n#  endif\n#  ifndef PNG_USER_CHUNK_MALLOC_MAX\n#     define PNG_USER_CHUNK_MALLOC_MAX 8000000\n#  endif\n#else\n   /* values for no limits */\n#  ifndef PNG_USER_WIDTH_MAX\n#     define PNG_USER_WIDTH_MAX 0x7fffffff\n#  endif\n#  ifndef PNG_USER_HEIGHT_MAX\n#     define PNG_USER_HEIGHT_MAX 0x7fffffff\n#  endif\n#  ifndef PNG_USER_CHUNK_CACHE_MAX\n#     define PNG_USER_CHUNK_CACHE_MAX 0\n#  endif\n#  ifndef PNG_USER_CHUNK_MALLOC_MAX\n#     define PNG_USER_CHUNK_MALLOC_MAX 0\n#  endif\n#endif\n\n/* Moved to pngpriv.h at libpng-1.5.0 */\n/* NOTE: some of these may have been used in external applications as\n * these definitions were exposed in pngconf.h prior to 1.5.\n */\n\n/* If you are running on a machine where you cannot allocate more\n * than 64K of memory at once, uncomment this.  While libpng will not\n * normally need that much memory in a chunk (unless you load up a very\n * large file), zlib needs to know how big of a chunk it can use, and\n * libpng thus makes sure to check any memory allocation to verify it\n * will fit into memory.\n *\n * zlib provides 'MAXSEG_64K' which, if defined, indicates the\n * same limit and pngconf.h (already included) sets the limit\n * if certain operating systems are detected.\n */\n#if defined(MAXSEG_64K) && !defined(PNG_MAX_MALLOC_64K)\n#  define PNG_MAX_MALLOC_64K\n#endif\n\n#ifndef PNG_UNUSED\n/* Unused formal parameter warnings are silenced using the following macro\n * which is expected to have no bad effects on performance (optimizing\n * compilers will probably remove it entirely).  Note that if you replace\n * it with something other than whitespace, you must include the terminating\n * semicolon.\n */\n#  define PNG_UNUSED(param) (void)param;\n#endif\n\n/* Just a little check that someone hasn't tried to define something\n * contradictory.\n */\n#if (PNG_ZBUF_SIZE > 65536L) && defined(PNG_MAX_MALLOC_64K)\n#  undef PNG_ZBUF_SIZE\n#  define PNG_ZBUF_SIZE 65536L\n#endif\n\n/* If warnings or errors are turned off the code is disabled or redirected here.\n * From 1.5.4 functions have been added to allow very limited formatting of\n * error and warning messages - this code will also be disabled here.\n */\n#ifdef PNG_WARNINGS_SUPPORTED\n#  define PNG_WARNING_PARAMETERS(p) png_warning_parameters p;\n#else\n#  define png_warning_parameter(p,number,string) ((void)0)\n#  define png_warning_parameter_unsigned(p,number,format,value) ((void)0)\n#  define png_warning_parameter_signed(p,number,format,value) ((void)0)\n#  define png_formatted_warning(pp,p,message) ((void)(pp))\n#  define PNG_WARNING_PARAMETERS(p)\n#endif\n#ifndef PNG_ERROR_TEXT_SUPPORTED\n#  define png_fixed_error(s1,s2) png_err(s1)\n#endif\n\n/* C allows up-casts from (void*) to any pointer and (const void*) to any\n * pointer to a const object.  C++ regards this as a type error and requires an\n * explicit, static, cast and provides the static_cast<> rune to ensure that\n * const is not cast away.\n */\n#ifdef __cplusplus\n#  define png_voidcast(type, value) static_cast<type>(value)\n#  define png_constcast(type, value) const_cast<type>(value)\n#  define png_aligncast(type, value) \\\n   static_cast<type>(static_cast<void*>(value))\n#  define png_aligncastconst(type, value) \\\n   static_cast<type>(static_cast<const void*>(value))\n#else\n#  define png_voidcast(type, value) (value)\n#  define png_constcast(type, value) ((type)(value))\n#  define png_aligncast(type, value) ((void*)(value))\n#  define png_aligncastconst(type, value) ((const void*)(value))\n#endif /* __cplusplus */\n\n/* Some fixed point APIs are still required even if not exported because\n * they get used by the corresponding floating point APIs.  This magic\n * deals with this:\n */\n#ifdef PNG_FIXED_POINT_SUPPORTED\n#  define PNGFAPI PNGAPI\n#else\n#  define PNGFAPI /* PRIVATE */\n#endif\n\n#ifndef PNG_VERSION_INFO_ONLY\n/* Other defines specific to compilers can go here.  Try to keep\n * them inside an appropriate ifdef/endif pair for portability.\n */\n#if defined(PNG_FLOATING_POINT_SUPPORTED) ||\\\n    defined(PNG_FLOATING_ARITHMETIC_SUPPORTED)\n   /* png.c requires the following ANSI-C constants if the conversion of\n    * floating point to ASCII is implemented therein:\n    *\n    *  DBL_DIG  Maximum number of decimal digits (can be set to any constant)\n    *  DBL_MIN  Smallest normalized fp number (can be set to an arbitrary value)\n    *  DBL_MAX  Maximum floating point number (can be set to an arbitrary value)\n    */\n#  include <float.h>\n\n#  if (defined(__MWERKS__) && defined(macintosh)) || defined(applec) || \\\n    defined(THINK_C) || defined(__SC__) || defined(TARGET_OS_MAC)\n     /* We need to check that <math.h> hasn't already been included earlier\n      * as it seems it doesn't agree with <fp.h>, yet we should really use\n      * <fp.h> if possible.\n      */\n#    if !defined(__MATH_H__) && !defined(__MATH_H) && !defined(__cmath__)\n#      include <fp.h>\n#    endif\n#  else\n#    include <math.h>\n#  endif\n#  if defined(_AMIGA) && defined(__SASC) && defined(_M68881)\n     /* Amiga SAS/C: We must include builtin FPU functions when compiling using\n      * MATH=68881\n      */\n#    include <m68881.h>\n#  endif\n#endif\n\n/* This provides the non-ANSI (far) memory allocation routines. */\n#if defined(__TURBOC__) && defined(__MSDOS__)\n#  include <mem.h>\n#  include <alloc.h>\n#endif\n\n#if defined(WIN32) || defined(_Windows) || defined(_WINDOWS) || \\\n    defined(_WIN32) || defined(__WIN32__)\n#  include <windows.h>  /* defines _WINDOWS_ macro */\n#endif\n#endif /* PNG_VERSION_INFO_ONLY */\n\n/* Moved here around 1.5.0beta36 from pngconf.h */\n/* Users may want to use these so they are not private.  Any library\n * functions that are passed far data must be model-independent.\n */\n\n/* Memory model/platform independent fns */\n#ifndef PNG_ABORT\n#  ifdef _WINDOWS_\n#    define PNG_ABORT() ExitProcess(0)\n#  else\n#    define PNG_ABORT() abort()\n#  endif\n#endif\n\n/* These macros may need to be architecture dependent. */\n#define PNG_ALIGN_NONE   0 /* do not use data alignment */\n#define PNG_ALIGN_ALWAYS 1 /* assume unaligned accesses are OK */\n#ifdef offsetof\n#  define PNG_ALIGN_OFFSET 2 /* use offsetof to determine alignment */\n#else\n#  define PNG_ALIGN_OFFSET -1 /* prevent the use of this */\n#endif\n#define PNG_ALIGN_SIZE   3 /* use sizeof to determine alignment */\n\n#ifndef PNG_ALIGN_TYPE\n   /* Default to using aligned access optimizations and requiring alignment to a\n    * multiple of the data type size.  Override in a compiler specific fashion\n    * if necessary by inserting tests here:\n    */\n#  define PNG_ALIGN_TYPE PNG_ALIGN_SIZE\n#endif\n\n#if PNG_ALIGN_TYPE == PNG_ALIGN_SIZE\n   /* This is used because in some compiler implementations non-aligned\n    * structure members are supported, so the offsetof approach below fails.\n    * Set PNG_ALIGN_SIZE=0 for compiler combinations where unaligned access\n    * is good for performance.  Do not do this unless you have tested the result\n    * and understand it.\n    */\n#  define png_alignof(type) (sizeof (type))\n#else\n#  if PNG_ALIGN_TYPE == PNG_ALIGN_OFFSET\n#     define png_alignof(type) offsetof(struct{char c; type t;}, t)\n#  else\n#     if PNG_ALIGN_TYPE == PNG_ALIGN_ALWAYS\n#        define png_alignof(type) (1)\n#     endif\n      /* Else leave png_alignof undefined to prevent use thereof */\n#  endif\n#endif\n\n/* This implicitly assumes alignment is always to a power of 2. */\n#ifdef png_alignof\n#  define png_isaligned(ptr, type)\\\n   ((((const char*)ptr-(const char*)0) & (png_alignof(type)-1)) == 0)\n#else\n#  define png_isaligned(ptr, type) 0\n#endif\n\n/* End of memory model/platform independent support */\n/* End of 1.5.0beta36 move from pngconf.h */\n\n/* CONSTANTS and UTILITY MACROS\n * These are used internally by libpng and not exposed in the API\n */\n\n/* Various modes of operation.  Note that after an init, mode is set to\n * zero automatically when the structure is created.  Three of these\n * are defined in png.h because they need to be visible to applications\n * that call png_set_unknown_chunk().\n */\n/* #define PNG_HAVE_IHDR            0x01 (defined in png.h) */\n/* #define PNG_HAVE_PLTE            0x02 (defined in png.h) */\n#define PNG_HAVE_IDAT               0x04\n/* #define PNG_AFTER_IDAT           0x08 (defined in png.h) */\n#define PNG_HAVE_IEND               0x10\n                   /*               0x20 (unused) */\n                   /*               0x40 (unused) */\n                   /*               0x80 (unused) */\n#define PNG_HAVE_CHUNK_HEADER      0x100\n#define PNG_WROTE_tIME             0x200\n#define PNG_WROTE_INFO_BEFORE_PLTE 0x400\n#define PNG_BACKGROUND_IS_GRAY     0x800\n#define PNG_HAVE_PNG_SIGNATURE    0x1000\n#define PNG_HAVE_CHUNK_AFTER_IDAT 0x2000 /* Have another chunk after IDAT */\n                   /*             0x4000 (unused) */\n#define PNG_IS_READ_STRUCT        0x8000 /* Else is a write struct */\n\n/* Flags for the transformations the PNG library does on the image data */\n#define PNG_BGR                 0x0001\n#define PNG_INTERLACE           0x0002\n#define PNG_PACK                0x0004\n#define PNG_SHIFT               0x0008\n#define PNG_SWAP_BYTES          0x0010\n#define PNG_INVERT_MONO         0x0020\n#define PNG_QUANTIZE            0x0040\n#define PNG_COMPOSE             0x0080     /* Was PNG_BACKGROUND */\n#define PNG_BACKGROUND_EXPAND   0x0100\n#define PNG_EXPAND_16           0x0200     /* Added to libpng 1.5.2 */\n#define PNG_16_TO_8             0x0400     /* Becomes 'chop' in 1.5.4 */\n#define PNG_RGBA                0x0800\n#define PNG_EXPAND              0x1000\n#define PNG_GAMMA               0x2000\n#define PNG_GRAY_TO_RGB         0x4000\n#define PNG_FILLER              0x8000\n#define PNG_PACKSWAP           0x10000\n#define PNG_SWAP_ALPHA         0x20000\n#define PNG_STRIP_ALPHA        0x40000\n#define PNG_INVERT_ALPHA       0x80000\n#define PNG_USER_TRANSFORM    0x100000\n#define PNG_RGB_TO_GRAY_ERR   0x200000\n#define PNG_RGB_TO_GRAY_WARN  0x400000\n#define PNG_RGB_TO_GRAY       0x600000 /* two bits, RGB_TO_GRAY_ERR|WARN */\n#define PNG_ENCODE_ALPHA      0x800000 /* Added to libpng-1.5.4 */\n#define PNG_ADD_ALPHA         0x1000000 /* Added to libpng-1.2.7 */\n#define PNG_EXPAND_tRNS       0x2000000 /* Added to libpng-1.2.9 */\n#define PNG_SCALE_16_TO_8     0x4000000 /* Added to libpng-1.5.4 */\n                       /*   0x8000000 unused */\n                       /*  0x10000000 unused */\n                       /*  0x20000000 unused */\n                       /*  0x40000000 unused */\n/* Flags for png_create_struct */\n#define PNG_STRUCT_PNG   0x0001\n#define PNG_STRUCT_INFO  0x0002\n\n/* Scaling factor for filter heuristic weighting calculations */\n#define PNG_WEIGHT_FACTOR (1<<(PNG_WEIGHT_SHIFT))\n#define PNG_COST_FACTOR (1<<(PNG_COST_SHIFT))\n\n/* Flags for the png_ptr->flags rather than declaring a byte for each one */\n#define PNG_FLAG_ZLIB_CUSTOM_STRATEGY     0x0001\n#define PNG_FLAG_ZSTREAM_INITIALIZED      0x0002 /* Added to libpng-1.6.0 */\n                                  /*      0x0004    unused */\n#define PNG_FLAG_ZSTREAM_ENDED            0x0008 /* Added to libpng-1.6.0 */\n                                  /*      0x0010    unused */\n                                  /*      0x0020    unused */\n#define PNG_FLAG_ROW_INIT                 0x0040\n#define PNG_FLAG_FILLER_AFTER             0x0080\n#define PNG_FLAG_CRC_ANCILLARY_USE        0x0100\n#define PNG_FLAG_CRC_ANCILLARY_NOWARN     0x0200\n#define PNG_FLAG_CRC_CRITICAL_USE         0x0400\n#define PNG_FLAG_CRC_CRITICAL_IGNORE      0x0800\n#define PNG_FLAG_ASSUME_sRGB              0x1000 /* Added to libpng-1.5.4 */\n#define PNG_FLAG_OPTIMIZE_ALPHA           0x2000 /* Added to libpng-1.5.4 */\n#define PNG_FLAG_DETECT_UNINITIALIZED     0x4000 /* Added to libpng-1.5.4 */\n/* #define PNG_FLAG_KEEP_UNKNOWN_CHUNKS      0x8000 */\n/* #define PNG_FLAG_KEEP_UNSAFE_CHUNKS      0x10000 */\n#define PNG_FLAG_LIBRARY_MISMATCH        0x20000\n#define PNG_FLAG_STRIP_ERROR_NUMBERS     0x40000\n#define PNG_FLAG_STRIP_ERROR_TEXT        0x80000\n#define PNG_FLAG_BENIGN_ERRORS_WARN     0x100000 /* Added to libpng-1.4.0 */\n#define PNG_FLAG_APP_WARNINGS_WARN      0x200000 /* Added to libpng-1.6.0 */\n#define PNG_FLAG_APP_ERRORS_WARN        0x400000 /* Added to libpng-1.6.0 */\n                                  /*    0x800000    unused */\n                                  /*   0x1000000    unused */\n                                  /*   0x2000000    unused */\n                                  /*   0x4000000    unused */\n                                  /*   0x8000000    unused */\n                                  /*  0x10000000    unused */\n                                  /*  0x20000000    unused */\n                                  /*  0x40000000    unused */\n\n#define PNG_FLAG_CRC_ANCILLARY_MASK (PNG_FLAG_CRC_ANCILLARY_USE | \\\n                                     PNG_FLAG_CRC_ANCILLARY_NOWARN)\n\n#define PNG_FLAG_CRC_CRITICAL_MASK  (PNG_FLAG_CRC_CRITICAL_USE | \\\n                                     PNG_FLAG_CRC_CRITICAL_IGNORE)\n\n#define PNG_FLAG_CRC_MASK           (PNG_FLAG_CRC_ANCILLARY_MASK | \\\n                                     PNG_FLAG_CRC_CRITICAL_MASK)\n\n/* Save typing and make code easier to understand */\n\n#define PNG_COLOR_DIST(c1, c2) (abs((int)((c1).red) - (int)((c2).red)) + \\\n   abs((int)((c1).green) - (int)((c2).green)) + \\\n   abs((int)((c1).blue) - (int)((c2).blue)))\n\n/* Added to libpng-1.6.0: scale a 16-bit value in the range 0..65535 to 0..255\n * by dividing by 257 *with rounding*.  This macro is exact for the given range.\n * See the discourse in pngrtran.c png_do_scale_16_to_8.  The values in the\n * macro were established by experiment (modifying the added value).  The macro\n * has a second variant that takes a value already scaled by 255 and divides by\n * 65535 - this has a maximum error of .502.  Over the range 0..65535*65535 it\n * only gives off-by-one errors and only for 0.5% (1 in 200) of the values.\n */\n#define PNG_DIV65535(v24) (((v24) + 32895) >> 16)\n#define PNG_DIV257(v16) PNG_DIV65535((png_uint_32)(v16) * 255)\n\n/* Added to libpng-1.2.6 JB */\n#define PNG_ROWBYTES(pixel_bits, width) \\\n    ((pixel_bits) >= 8 ? \\\n    ((png_size_t)(width) * (((png_size_t)(pixel_bits)) >> 3)) : \\\n    (( ((png_size_t)(width) * ((png_size_t)(pixel_bits))) + 7) >> 3) )\n\n/* PNG_OUT_OF_RANGE returns true if value is outside the range\n * ideal-delta..ideal+delta.  Each argument is evaluated twice.\n * \"ideal\" and \"delta\" should be constants, normally simple\n * integers, \"value\" a variable. Added to libpng-1.2.6 JB\n */\n#define PNG_OUT_OF_RANGE(value, ideal, delta) \\\n   ( (value) < (ideal)-(delta) || (value) > (ideal)+(delta) )\n\n/* Conversions between fixed and floating point, only defined if\n * required (to make sure the code doesn't accidentally use float\n * when it is supposedly disabled.)\n */\n#ifdef PNG_FLOATING_POINT_SUPPORTED\n/* The floating point conversion can't overflow, though it can and\n * does lose accuracy relative to the original fixed point value.\n * In practice this doesn't matter because png_fixed_point only\n * stores numbers with very low precision.  The png_ptr and s\n * arguments are unused by default but are there in case error\n * checking becomes a requirement.\n */\n#define png_float(png_ptr, fixed, s) (.00001 * (fixed))\n\n/* The fixed point conversion performs range checking and evaluates\n * its argument multiple times, so must be used with care.  The\n * range checking uses the PNG specification values for a signed\n * 32 bit fixed point value except that the values are deliberately\n * rounded-to-zero to an integral value - 21474 (21474.83 is roughly\n * (2^31-1) * 100000). 's' is a string that describes the value being\n * converted.\n *\n * NOTE: this macro will raise a png_error if the range check fails,\n * therefore it is normally only appropriate to use this on values\n * that come from API calls or other sources where an out of range\n * error indicates a programming error, not a data error!\n *\n * NOTE: by default this is off - the macro is not used - because the\n * function call saves a lot of code.\n */\n#ifdef PNG_FIXED_POINT_MACRO_SUPPORTED\n#define png_fixed(png_ptr, fp, s) ((fp) <= 21474 && (fp) >= -21474 ?\\\n    ((png_fixed_point)(100000 * (fp))) : (png_fixed_error(png_ptr, s),0))\n#endif\n/* else the corresponding function is defined below, inside the scope of the\n * cplusplus test.\n */\n#endif\n\n/* Constants for known chunk types.  If you need to add a chunk, define the name\n * here.  For historical reasons these constants have the form png_<name>; i.e.\n * the prefix is lower case.  Please use decimal values as the parameters to\n * match the ISO PNG specification and to avoid relying on the C locale\n * interpretation of character values.\n *\n * Prior to 1.5.6 these constants were strings, as of 1.5.6 png_uint_32 values\n * are computed and a new macro (PNG_STRING_FROM_CHUNK) added to allow a string\n * to be generated if required.\n *\n * PNG_32b correctly produces a value shifted by up to 24 bits, even on\n * architectures where (int) is only 16 bits.\n */\n#define PNG_32b(b,s) ((png_uint_32)(b) << (s))\n#define PNG_U32(b1,b2,b3,b4) \\\n   (PNG_32b(b1,24) | PNG_32b(b2,16) | PNG_32b(b3,8) | PNG_32b(b4,0))\n\n/* Constants for known chunk types.\n *\n * MAINTAINERS: If you need to add a chunk, define the name here.\n * For historical reasons these constants have the form png_<name>; i.e.\n * the prefix is lower case.  Please use decimal values as the parameters to\n * match the ISO PNG specification and to avoid relying on the C locale\n * interpretation of character values.  Please keep the list sorted.\n *\n * Notice that PNG_U32 is used to define a 32-bit value for the 4 byte chunk\n * type.  In fact the specification does not express chunk types this way,\n * however using a 32-bit value means that the chunk type can be read from the\n * stream using exactly the same code as used for a 32-bit unsigned value and\n * can be examined far more efficiently (using one arithmetic compare).\n *\n * Prior to 1.5.6 the chunk type constants were expressed as C strings.  The\n * libpng API still uses strings for 'unknown' chunks and a macro,\n * PNG_STRING_FROM_CHUNK, allows a string to be generated if required.  Notice\n * that for portable code numeric values must still be used; the string \"IHDR\"\n * is not portable and neither is PNG_U32('I', 'H', 'D', 'R').\n *\n * In 1.7.0 the definitions will be made public in png.h to avoid having to\n * duplicate the same definitions in application code.\n */\n#define png_IDAT PNG_U32( 73,  68,  65,  84)\n#define png_IEND PNG_U32( 73,  69,  78,  68)\n#define png_IHDR PNG_U32( 73,  72,  68,  82)\n#define png_PLTE PNG_U32( 80,  76,  84,  69)\n#define png_bKGD PNG_U32( 98,  75,  71,  68)\n#define png_cHRM PNG_U32( 99,  72,  82,  77)\n#define png_fRAc PNG_U32(102,  82,  65,  99) /* registered, not defined */\n#define png_gAMA PNG_U32(103,  65,  77,  65)\n#define png_gIFg PNG_U32(103,  73,  70, 103)\n#define png_gIFt PNG_U32(103,  73,  70, 116) /* deprecated */\n#define png_gIFx PNG_U32(103,  73,  70, 120)\n#define png_hIST PNG_U32(104,  73,  83,  84)\n#define png_iCCP PNG_U32(105,  67,  67,  80)\n#define png_iTXt PNG_U32(105,  84,  88, 116)\n#define png_oFFs PNG_U32(111,  70,  70, 115)\n#define png_pCAL PNG_U32(112,  67,  65,  76)\n#define png_pHYs PNG_U32(112,  72,  89, 115)\n#define png_sBIT PNG_U32(115,  66,  73,  84)\n#define png_sCAL PNG_U32(115,  67,  65,  76)\n#define png_sPLT PNG_U32(115,  80,  76,  84)\n#define png_sRGB PNG_U32(115,  82,  71,  66)\n#define png_sTER PNG_U32(115,  84,  69,  82)\n#define png_tEXt PNG_U32(116,  69,  88, 116)\n#define png_tIME PNG_U32(116,  73,  77,  69)\n#define png_tRNS PNG_U32(116,  82,  78,  83)\n#define png_zTXt PNG_U32(122,  84,  88, 116)\n\n/* The following will work on (signed char*) strings, whereas the get_uint_32\n * macro will fail on top-bit-set values because of the sign extension.\n */\n#define PNG_CHUNK_FROM_STRING(s)\\\n   PNG_U32(0xff&(s)[0], 0xff&(s)[1], 0xff&(s)[2], 0xff&(s)[3])\n\n/* This uses (char), not (png_byte) to avoid warnings on systems where (char) is\n * signed and the argument is a (char[])  This macro will fail miserably on\n * systems where (char) is more than 8 bits.\n */\n#define PNG_STRING_FROM_CHUNK(s,c)\\\n   (void)(((char*)(s))[0]=(char)((c)>>24), ((char*)(s))[1]=(char)((c)>>16),\\\n   ((char*)(s))[2]=(char)((c)>>8), ((char*)(s))[3]=(char)((c)))\n\n/* Do the same but terminate with a null character. */\n#define PNG_CSTRING_FROM_CHUNK(s,c)\\\n   (void)(PNG_STRING_FROM_CHUNK(s,c), ((char*)(s))[4] = 0)\n\n/* Test on flag values as defined in the spec (section 5.4): */\n#define PNG_CHUNK_ANCILLARY(c)   (1 & ((c) >> 29))\n#define PNG_CHUNK_CRITICAL(c)     (!PNG_CHUNK_ANCILLARY(c))\n#define PNG_CHUNK_PRIVATE(c)      (1 & ((c) >> 21))\n#define PNG_CHUNK_RESERVED(c)     (1 & ((c) >> 13))\n#define PNG_CHUNK_SAFE_TO_COPY(c) (1 & ((c) >>  5))\n\n/* Gamma values (new at libpng-1.5.4): */\n#define PNG_GAMMA_MAC_OLD 151724  /* Assume '1.8' is really 2.2/1.45! */\n#define PNG_GAMMA_MAC_INVERSE 65909\n#define PNG_GAMMA_sRGB_INVERSE 45455\n\n/* Almost everything below is C specific; the #defines above can be used in\n * non-C code (so long as it is C-preprocessed) the rest of this stuff cannot.\n */\n#ifndef PNG_VERSION_INFO_ONLY\n\n#include \"pngstruct.h\"\n#include \"pnginfo.h\"\n\n/* Validate the include paths - the include path used to generate pnglibconf.h\n * must match that used in the build, or we must be using pnglibconf.h.prebuilt:\n */\n#if PNG_ZLIB_VERNUM != 0 && PNG_ZLIB_VERNUM != ZLIB_VERNUM\n#  error ZLIB_VERNUM != PNG_ZLIB_VERNUM \\\n      \"-I (include path) error: see the notes in pngpriv.h\"\n   /* This means that when pnglibconf.h was built the copy of zlib.h that it\n    * used is not the same as the one being used here.  Because the build of\n    * libpng makes decisions to use inflateInit2 and inflateReset2 based on the\n    * zlib version number and because this affects handling of certain broken\n    * PNG files the -I directives must match.\n    *\n    * The most likely explanation is that you passed a -I in CFLAGS, this will\n    * not work; all the preprocessor directories and in particular all the -I\n    * directives must be in CPPFLAGS.\n    */\n#endif\n\n/* This is used for 16 bit gamma tables -- only the top level pointers are\n * const; this could be changed:\n */\ntypedef const png_uint_16p * png_const_uint_16pp;\n\n/* Added to libpng-1.5.7: sRGB conversion tables */\n#if defined(PNG_SIMPLIFIED_READ_SUPPORTED) ||\\\n   defined(PNG_SIMPLIFIED_WRITE_SUPPORTED)\n#ifdef PNG_SIMPLIFIED_READ_SUPPORTED\nPNG_INTERNAL_DATA(const png_uint_16, png_sRGB_table, [256]);\n   /* Convert from an sRGB encoded value 0..255 to a 16-bit linear value,\n    * 0..65535.  This table gives the closest 16-bit answers (no errors).\n    */\n#endif\n\nPNG_INTERNAL_DATA(const png_uint_16, png_sRGB_base, [512]);\nPNG_INTERNAL_DATA(const png_byte, png_sRGB_delta, [512]);\n\n#define PNG_sRGB_FROM_LINEAR(linear) ((png_byte)((png_sRGB_base[(linear)>>15] +\\\n   ((((linear)&0x7fff)*png_sRGB_delta[(linear)>>15])>>12)) >> 8))\n   /* Given a value 'linear' in the range 0..255*65535 calculate the 8-bit sRGB\n    * encoded value with maximum error 0.646365.  Note that the input is not a\n    * 16-bit value; it has been multiplied by 255! */\n#endif /* PNG_SIMPLIFIED_READ/WRITE */\n\n\n/* Inhibit C++ name-mangling for libpng functions but not for system calls. */\n#ifdef __cplusplus\nextern \"C\" {\n#endif /* __cplusplus */\n\n/* Internal functions; these are not exported from a DLL however because they\n * are used within several of the C source files they have to be C extern.\n *\n * All of these functions must be declared with PNG_INTERNAL_FUNCTION.\n */\n\n/* Zlib support */\n#define PNG_UNEXPECTED_ZLIB_RETURN (-7)\nPNG_INTERNAL_FUNCTION(void, png_zstream_error,(png_structrp png_ptr, int ret),\n   PNG_EMPTY);\n   /* Used by the zlib handling functions to ensure that z_stream::msg is always\n    * set before they return.\n    */\n\n#ifdef PNG_WRITE_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_free_buffer_list,(png_structrp png_ptr,\n   png_compression_bufferp *list),PNG_EMPTY);\n   /* Free the buffer list used by the compressed write code. */\n#endif\n\n#if defined(PNG_FLOATING_POINT_SUPPORTED) && \\\n   !defined(PNG_FIXED_POINT_MACRO_SUPPORTED) && \\\n   (defined(PNG_gAMA_SUPPORTED) || defined(PNG_cHRM_SUPPORTED) || \\\n   defined(PNG_sCAL_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) || \\\n   defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)) || \\\n   (defined(PNG_sCAL_SUPPORTED) && \\\n   defined(PNG_FLOATING_ARITHMETIC_SUPPORTED))\nPNG_INTERNAL_FUNCTION(png_fixed_point,png_fixed,(png_const_structrp png_ptr,\n   double fp, png_const_charp text),PNG_EMPTY);\n#endif\n\n/* Check the user version string for compatibility, returns false if the version\n * numbers aren't compatible.\n */\nPNG_INTERNAL_FUNCTION(int,png_user_version_check,(png_structrp png_ptr,\n   png_const_charp user_png_ver),PNG_EMPTY);\n\n/* Internal base allocator - no messages, NULL on failure to allocate.  This\n * does, however, call the application provided allocator and that could call\n * png_error (although that would be a bug in the application implementation.)\n */\nPNG_INTERNAL_FUNCTION(png_voidp,png_malloc_base,(png_const_structrp png_ptr,\n   png_alloc_size_t size),PNG_ALLOCATED);\n\n#if defined(PNG_TEXT_SUPPORTED) || defined(PNG_sPLT_SUPPORTED) ||\\\n   defined(PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED)\n/* Internal array allocator, outputs no error or warning messages on failure,\n * just returns NULL.  \n */\nPNG_INTERNAL_FUNCTION(png_voidp,png_malloc_array,(png_const_structrp png_ptr,\n   int nelements, size_t element_size),PNG_ALLOCATED);\n\n/* The same but an existing array is extended by add_elements.  This function\n * also memsets the new elements to 0 and copies the old elements.  The old\n * array is not freed or altered.\n */\nPNG_INTERNAL_FUNCTION(png_voidp,png_realloc_array,(png_const_structrp png_ptr,\n   png_const_voidp array, int old_elements, int add_elements,\n   size_t element_size),PNG_ALLOCATED);\n#endif /* text, sPLT or unknown chunks */\n\n/* Magic to create a struct when there is no struct to call the user supplied\n * memory allocators.  Because error handling has not been set up the memory\n * handlers can't safely call png_error, but this is an obscure and undocumented\n * restriction so libpng has to assume that the 'free' handler, at least, might\n * call png_error.\n */\nPNG_INTERNAL_FUNCTION(png_structp,png_create_png_struct,\n   (png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn,\n    png_error_ptr warn_fn, png_voidp mem_ptr, png_malloc_ptr malloc_fn,\n    png_free_ptr free_fn),PNG_ALLOCATED);\n\n/* Free memory from internal libpng struct */\nPNG_INTERNAL_FUNCTION(void,png_destroy_png_struct,(png_structrp png_ptr),\n   PNG_EMPTY);\n\n/* Free an allocated jmp_buf (always succeeds) */\nPNG_INTERNAL_FUNCTION(void,png_free_jmpbuf,(png_structrp png_ptr),PNG_EMPTY);\n\n/* Function to allocate memory for zlib.  PNGAPI is disallowed. */\nPNG_INTERNAL_FUNCTION(voidpf,png_zalloc,(voidpf png_ptr, uInt items, uInt size),\n   PNG_ALLOCATED);\n\n/* Function to free memory for zlib.  PNGAPI is disallowed. */\nPNG_INTERNAL_FUNCTION(void,png_zfree,(voidpf png_ptr, voidpf ptr),PNG_EMPTY);\n\n/* Next four functions are used internally as callbacks.  PNGCBAPI is required\n * but not PNG_EXPORT.  PNGAPI added at libpng version 1.2.3, changed to\n * PNGCBAPI at 1.5.0\n */\n\nPNG_INTERNAL_FUNCTION(void PNGCBAPI,png_default_read_data,(png_structp png_ptr,\n    png_bytep data, png_size_t length),PNG_EMPTY);\n\n#ifdef PNG_PROGRESSIVE_READ_SUPPORTED\nPNG_INTERNAL_FUNCTION(void PNGCBAPI,png_push_fill_buffer,(png_structp png_ptr,\n    png_bytep buffer, png_size_t length),PNG_EMPTY);\n#endif\n\nPNG_INTERNAL_FUNCTION(void PNGCBAPI,png_default_write_data,(png_structp png_ptr,\n    png_bytep data, png_size_t length),PNG_EMPTY);\n\n#ifdef PNG_WRITE_FLUSH_SUPPORTED\n#  ifdef PNG_STDIO_SUPPORTED\nPNG_INTERNAL_FUNCTION(void PNGCBAPI,png_default_flush,(png_structp png_ptr),\n   PNG_EMPTY);\n#  endif\n#endif\n\n/* Reset the CRC variable */\nPNG_INTERNAL_FUNCTION(void,png_reset_crc,(png_structrp png_ptr),PNG_EMPTY);\n\n/* Write the \"data\" buffer to whatever output you are using */\nPNG_INTERNAL_FUNCTION(void,png_write_data,(png_structrp png_ptr,\n    png_const_bytep data, png_size_t length),PNG_EMPTY);\n\n/* Read and check the PNG file signature */\nPNG_INTERNAL_FUNCTION(void,png_read_sig,(png_structrp png_ptr,\n   png_inforp info_ptr),PNG_EMPTY);\n\n/* Read the chunk header (length + type name) */\nPNG_INTERNAL_FUNCTION(png_uint_32,png_read_chunk_header,(png_structrp png_ptr),\n   PNG_EMPTY);\n\n/* Read data from whatever input you are using into the \"data\" buffer */\nPNG_INTERNAL_FUNCTION(void,png_read_data,(png_structrp png_ptr, png_bytep data,\n    png_size_t length),PNG_EMPTY);\n\n/* Read bytes into buf, and update png_ptr->crc */\nPNG_INTERNAL_FUNCTION(void,png_crc_read,(png_structrp png_ptr, png_bytep buf,\n    png_uint_32 length),PNG_EMPTY);\n\n/* Read \"skip\" bytes, read the file crc, and (optionally) verify png_ptr->crc */\nPNG_INTERNAL_FUNCTION(int,png_crc_finish,(png_structrp png_ptr,\n   png_uint_32 skip),PNG_EMPTY);\n\n/* Read the CRC from the file and compare it to the libpng calculated CRC */\nPNG_INTERNAL_FUNCTION(int,png_crc_error,(png_structrp png_ptr),PNG_EMPTY);\n\n/* Calculate the CRC over a section of data.  Note that we are only\n * passing a maximum of 64K on systems that have this as a memory limit,\n * since this is the maximum buffer size we can specify.\n */\nPNG_INTERNAL_FUNCTION(void,png_calculate_crc,(png_structrp png_ptr,\n   png_const_bytep ptr, png_size_t length),PNG_EMPTY);\n\n#ifdef PNG_WRITE_FLUSH_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_flush,(png_structrp png_ptr),PNG_EMPTY);\n#endif\n\n/* Write various chunks */\n\n/* Write the IHDR chunk, and update the png_struct with the necessary\n * information.\n */\nPNG_INTERNAL_FUNCTION(void,png_write_IHDR,(png_structrp png_ptr,\n   png_uint_32 width, png_uint_32 height, int bit_depth, int color_type,\n   int compression_method, int filter_method, int interlace_method),PNG_EMPTY);\n\nPNG_INTERNAL_FUNCTION(void,png_write_PLTE,(png_structrp png_ptr,\n   png_const_colorp palette, png_uint_32 num_pal),PNG_EMPTY);\n\nPNG_INTERNAL_FUNCTION(void,png_compress_IDAT,(png_structrp png_ptr,\n   png_const_bytep row_data, png_alloc_size_t row_data_length, int flush),\n   PNG_EMPTY);\n\nPNG_INTERNAL_FUNCTION(void,png_write_IEND,(png_structrp png_ptr),PNG_EMPTY);\n\n#ifdef PNG_WRITE_gAMA_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_write_gAMA_fixed,(png_structrp png_ptr,\n    png_fixed_point file_gamma),PNG_EMPTY);\n#endif\n\n#ifdef PNG_WRITE_sBIT_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_write_sBIT,(png_structrp png_ptr,\n    png_const_color_8p sbit, int color_type),PNG_EMPTY);\n#endif\n\n#ifdef PNG_WRITE_cHRM_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_write_cHRM_fixed,(png_structrp png_ptr,\n    const png_xy *xy), PNG_EMPTY);\n    /* The xy value must have been previously validated */\n#endif\n\n#ifdef PNG_WRITE_sRGB_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_write_sRGB,(png_structrp png_ptr,\n    int intent),PNG_EMPTY);\n#endif\n\n#ifdef PNG_WRITE_iCCP_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_write_iCCP,(png_structrp png_ptr,\n   png_const_charp name, png_const_bytep profile), PNG_EMPTY);\n   /* The profile must have been previously validated for correctness, the\n    * length comes from the first four bytes.  Only the base, deflate,\n    * compression is supported.\n    */\n#endif\n\n#ifdef PNG_WRITE_sPLT_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_write_sPLT,(png_structrp png_ptr,\n    png_const_sPLT_tp palette),PNG_EMPTY);\n#endif\n\n#ifdef PNG_WRITE_tRNS_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_write_tRNS,(png_structrp png_ptr,\n    png_const_bytep trans, png_const_color_16p values, int number,\n    int color_type),PNG_EMPTY);\n#endif\n\n#ifdef PNG_WRITE_bKGD_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_write_bKGD,(png_structrp png_ptr,\n    png_const_color_16p values, int color_type),PNG_EMPTY);\n#endif\n\n#ifdef PNG_WRITE_hIST_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_write_hIST,(png_structrp png_ptr,\n    png_const_uint_16p hist, int num_hist),PNG_EMPTY);\n#endif\n\n/* Chunks that have keywords */\n#ifdef PNG_WRITE_tEXt_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_write_tEXt,(png_structrp png_ptr,\n   png_const_charp key, png_const_charp text, png_size_t text_len),PNG_EMPTY);\n#endif\n\n#ifdef PNG_WRITE_zTXt_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_write_zTXt,(png_structrp png_ptr, png_const_charp\n    key, png_const_charp text, png_size_t text_len, int compression),PNG_EMPTY);\n#endif\n\n#ifdef PNG_WRITE_iTXt_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_write_iTXt,(png_structrp png_ptr,\n    int compression, png_const_charp key, png_const_charp lang,\n    png_const_charp lang_key, png_const_charp text),PNG_EMPTY);\n#endif\n\n#ifdef PNG_TEXT_SUPPORTED  /* Added at version 1.0.14 and 1.2.4 */\nPNG_INTERNAL_FUNCTION(int,png_set_text_2,(png_const_structrp png_ptr,\n    png_inforp info_ptr, png_const_textp text_ptr, int num_text),PNG_EMPTY);\n#endif\n\n#ifdef PNG_WRITE_oFFs_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_write_oFFs,(png_structrp png_ptr,\n    png_int_32 x_offset, png_int_32 y_offset, int unit_type),PNG_EMPTY);\n#endif\n\n#ifdef PNG_WRITE_pCAL_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_write_pCAL,(png_structrp png_ptr,\n    png_charp purpose, png_int_32 X0, png_int_32 X1, int type, int nparams,\n    png_const_charp units, png_charpp params),PNG_EMPTY);\n#endif\n\n#ifdef PNG_WRITE_pHYs_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_write_pHYs,(png_structrp png_ptr,\n    png_uint_32 x_pixels_per_unit, png_uint_32 y_pixels_per_unit,\n    int unit_type),PNG_EMPTY);\n#endif\n\n#ifdef PNG_WRITE_tIME_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_write_tIME,(png_structrp png_ptr,\n    png_const_timep mod_time),PNG_EMPTY);\n#endif\n\n#ifdef PNG_WRITE_sCAL_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_write_sCAL_s,(png_structrp png_ptr,\n    int unit, png_const_charp width, png_const_charp height),PNG_EMPTY);\n#endif\n\n/* Called when finished processing a row of data */\nPNG_INTERNAL_FUNCTION(void,png_write_finish_row,(png_structrp png_ptr),\n    PNG_EMPTY);\n\n/* Internal use only.   Called before first row of data */\nPNG_INTERNAL_FUNCTION(void,png_write_start_row,(png_structrp png_ptr),\n    PNG_EMPTY);\n\n/* Combine a row of data, dealing with alpha, etc. if requested.  'row' is an\n * array of png_ptr->width pixels.  If the image is not interlaced or this\n * is the final pass this just does a memcpy, otherwise the \"display\" flag\n * is used to determine whether to copy pixels that are not in the current pass.\n *\n * Because 'png_do_read_interlace' (below) replicates pixels this allows this\n * function to achieve the documented 'blocky' appearance during interlaced read\n * if display is 1 and the 'sparkle' appearance, where existing pixels in 'row'\n * are not changed if they are not in the current pass, when display is 0.\n *\n * 'display' must be 0 or 1, otherwise the memcpy will be done regardless.\n *\n * The API always reads from the png_struct row buffer and always assumes that\n * it is full width (png_do_read_interlace has already been called.)\n *\n * This function is only ever used to write to row buffers provided by the\n * caller of the relevant libpng API and the row must have already been\n * transformed by the read transformations.\n *\n * The PNG_USE_COMPILE_TIME_MASKS option causes generation of pre-computed\n * bitmasks for use within the code, otherwise runtime generated masks are used.\n * The default is compile time masks.\n */\n#ifndef PNG_USE_COMPILE_TIME_MASKS\n#  define PNG_USE_COMPILE_TIME_MASKS 1\n#endif\nPNG_INTERNAL_FUNCTION(void,png_combine_row,(png_const_structrp png_ptr,\n    png_bytep row, int display),PNG_EMPTY);\n\n#ifdef PNG_READ_INTERLACING_SUPPORTED\n/* Expand an interlaced row: the 'row_info' describes the pass data that has\n * been read in and must correspond to the pixels in 'row', the pixels are\n * expanded (moved apart) in 'row' to match the final layout, when doing this\n * the pixels are *replicated* to the intervening space.  This is essential for\n * the correct operation of png_combine_row, above.\n */\nPNG_INTERNAL_FUNCTION(void,png_do_read_interlace,(png_row_infop row_info,\n    png_bytep row, int pass, png_uint_32 transformations),PNG_EMPTY);\n#endif\n\n/* GRR TO DO (2.0 or whenever):  simplify other internal calling interfaces */\n\n#ifdef PNG_WRITE_INTERLACING_SUPPORTED\n/* Grab pixels out of a row for an interlaced pass */\nPNG_INTERNAL_FUNCTION(void,png_do_write_interlace,(png_row_infop row_info,\n    png_bytep row, int pass),PNG_EMPTY);\n#endif\n\n/* Unfilter a row: check the filter value before calling this, there is no point\n * calling it for PNG_FILTER_VALUE_NONE.\n */\nPNG_INTERNAL_FUNCTION(void,png_read_filter_row,(png_structrp pp, png_row_infop\n    row_info, png_bytep row, png_const_bytep prev_row, int filter),PNG_EMPTY);\n\nPNG_INTERNAL_FUNCTION(void,png_read_filter_row_up_neon,(png_row_infop row_info,\n    png_bytep row, png_const_bytep prev_row),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub3_neon,(png_row_infop\n    row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub4_neon,(png_row_infop\n    row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_read_filter_row_avg3_neon,(png_row_infop\n    row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_read_filter_row_avg4_neon,(png_row_infop\n    row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth3_neon,(png_row_infop\n    row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth4_neon,(png_row_infop\n    row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);\n\n/* Choose the best filter to use and filter the row data */\nPNG_INTERNAL_FUNCTION(void,png_write_find_filter,(png_structrp png_ptr,\n    png_row_infop row_info),PNG_EMPTY);\n\n#ifdef PNG_SEQUENTIAL_READ_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_read_IDAT_data,(png_structrp png_ptr,\n   png_bytep output, png_alloc_size_t avail_out),PNG_EMPTY);\n   /* Read 'avail_out' bytes of data from the IDAT stream.  If the output buffer\n    * is NULL the function checks, instead, for the end of the stream.  In this\n    * case a benign error will be issued if the stream end is not found or if\n    * extra data has to be consumed.\n    */\nPNG_INTERNAL_FUNCTION(void,png_read_finish_IDAT,(png_structrp png_ptr),\n   PNG_EMPTY);\n   /* This cleans up when the IDAT LZ stream does not end when the last image\n    * byte is read; there is still some pending input.\n    */\n\nPNG_INTERNAL_FUNCTION(void,png_read_finish_row,(png_structrp png_ptr),\n   PNG_EMPTY);\n   /* Finish a row while reading, dealing with interlacing passes, etc. */\n#endif /* PNG_SEQUENTIAL_READ_SUPPORTED */\n\n/* Initialize the row buffers, etc. */\nPNG_INTERNAL_FUNCTION(void,png_read_start_row,(png_structrp png_ptr),PNG_EMPTY);\n\n#ifdef PNG_READ_TRANSFORMS_SUPPORTED\n/* Optional call to update the users info structure */\nPNG_INTERNAL_FUNCTION(void,png_read_transform_info,(png_structrp png_ptr,\n    png_inforp info_ptr),PNG_EMPTY);\n#endif\n\n/* Shared transform functions, defined in pngtran.c */\n#if defined(PNG_WRITE_FILLER_SUPPORTED) || \\\n    defined(PNG_READ_STRIP_ALPHA_SUPPORTED)\nPNG_INTERNAL_FUNCTION(void,png_do_strip_channel,(png_row_infop row_info,\n    png_bytep row, int at_start),PNG_EMPTY);\n#endif\n\n#ifdef PNG_16BIT_SUPPORTED\n#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED)\nPNG_INTERNAL_FUNCTION(void,png_do_swap,(png_row_infop row_info,\n    png_bytep row),PNG_EMPTY);\n#endif\n#endif\n\n#if defined(PNG_READ_PACKSWAP_SUPPORTED) || \\\n    defined(PNG_WRITE_PACKSWAP_SUPPORTED)\nPNG_INTERNAL_FUNCTION(void,png_do_packswap,(png_row_infop row_info,\n    png_bytep row),PNG_EMPTY);\n#endif\n\n#if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED)\nPNG_INTERNAL_FUNCTION(void,png_do_invert,(png_row_infop row_info,\n    png_bytep row),PNG_EMPTY);\n#endif\n\n#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED)\nPNG_INTERNAL_FUNCTION(void,png_do_bgr,(png_row_infop row_info,\n    png_bytep row),PNG_EMPTY);\n#endif\n\n/* The following decodes the appropriate chunks, and does error correction,\n * then calls the appropriate callback for the chunk if it is valid.\n */\n\n/* Decode the IHDR chunk */\nPNG_INTERNAL_FUNCTION(void,png_handle_IHDR,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_handle_PLTE,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_handle_IEND,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\n\n#ifdef PNG_READ_bKGD_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_handle_bKGD,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\n#endif\n\n#ifdef PNG_READ_cHRM_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_handle_cHRM,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\n#endif\n\n#ifdef PNG_READ_gAMA_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_handle_gAMA,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\n#endif\n\n#ifdef PNG_READ_hIST_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_handle_hIST,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\n#endif\n\n#ifdef PNG_READ_iCCP_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_handle_iCCP,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\n#endif /* PNG_READ_iCCP_SUPPORTED */\n\n#ifdef PNG_READ_iTXt_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_handle_iTXt,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\n#endif\n\n#ifdef PNG_READ_oFFs_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_handle_oFFs,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\n#endif\n\n#ifdef PNG_READ_pCAL_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_handle_pCAL,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\n#endif\n\n#ifdef PNG_READ_pHYs_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_handle_pHYs,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\n#endif\n\n#ifdef PNG_READ_sBIT_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_handle_sBIT,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\n#endif\n\n#ifdef PNG_READ_sCAL_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_handle_sCAL,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\n#endif\n\n#ifdef PNG_READ_sPLT_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_handle_sPLT,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\n#endif /* PNG_READ_sPLT_SUPPORTED */\n\n#ifdef PNG_READ_sRGB_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_handle_sRGB,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\n#endif\n\n#ifdef PNG_READ_tEXt_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_handle_tEXt,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\n#endif\n\n#ifdef PNG_READ_tIME_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_handle_tIME,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\n#endif\n\n#ifdef PNG_READ_tRNS_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_handle_tRNS,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\n#endif\n\n#ifdef PNG_READ_zTXt_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_handle_zTXt,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\n#endif\n\nPNG_INTERNAL_FUNCTION(void,png_check_chunk_name,(png_structrp png_ptr,\n    png_uint_32 chunk_name),PNG_EMPTY);\n\nPNG_INTERNAL_FUNCTION(void,png_handle_unknown,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length, int keep),PNG_EMPTY);\n   /* This is the function that gets called for unknown chunks.  The 'keep'\n    * argument is either non-zero for a known chunk that has been set to be\n    * handled as unknown or zero for an unknown chunk.  By default the function\n    * just skips the chunk or errors out if it is critical.\n    */\n\n#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) ||\\\n    defined(PNG_HANDLE_AS_UNKNOWN_SUPPORTED)\nPNG_INTERNAL_FUNCTION(int,png_chunk_unknown_handling,\n    (png_const_structrp png_ptr, png_uint_32 chunk_name),PNG_EMPTY);\n   /* Exactly as the API png_handle_as_unknown() except that the argument is a\n    * 32-bit chunk name, not a string.\n    */\n#endif /* READ_UNKNOWN_CHUNKS || HANDLE_AS_UNKNOWN */\n\n/* Handle the transformations for reading and writing */\n#ifdef PNG_READ_TRANSFORMS_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_do_read_transformations,(png_structrp png_ptr,\n   png_row_infop row_info),PNG_EMPTY);\n#endif\n#ifdef PNG_WRITE_TRANSFORMS_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_do_write_transformations,(png_structrp png_ptr,\n   png_row_infop row_info),PNG_EMPTY);\n#endif\n\n#ifdef PNG_READ_TRANSFORMS_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_init_read_transformations,(png_structrp png_ptr),\n    PNG_EMPTY);\n#endif\n\n#ifdef PNG_PROGRESSIVE_READ_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_push_read_chunk,(png_structrp png_ptr,\n    png_inforp info_ptr),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_push_read_sig,(png_structrp png_ptr,\n    png_inforp info_ptr),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_push_check_crc,(png_structrp png_ptr),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_push_crc_skip,(png_structrp png_ptr,\n    png_uint_32 length),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_push_crc_finish,(png_structrp png_ptr),\n    PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_push_save_buffer,(png_structrp png_ptr),\n    PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_push_restore_buffer,(png_structrp png_ptr,\n    png_bytep buffer, png_size_t buffer_length),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_push_read_IDAT,(png_structrp png_ptr),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_process_IDAT_data,(png_structrp png_ptr,\n    png_bytep buffer, png_size_t buffer_length),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_push_process_row,(png_structrp png_ptr),\n    PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_push_handle_unknown,(png_structrp png_ptr,\n   png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_push_have_info,(png_structrp png_ptr,\n   png_inforp info_ptr),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_push_have_end,(png_structrp png_ptr,\n   png_inforp info_ptr),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_push_have_row,(png_structrp png_ptr,\n     png_bytep row),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_push_read_end,(png_structrp png_ptr,\n    png_inforp info_ptr),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_process_some_data,(png_structrp png_ptr,\n    png_inforp info_ptr),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_read_push_finish_row,(png_structrp png_ptr),\n    PNG_EMPTY);\n#  ifdef PNG_READ_tEXt_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_push_handle_tEXt,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_push_read_tEXt,(png_structrp png_ptr,\n    png_inforp info_ptr),PNG_EMPTY);\n#  endif\n#  ifdef PNG_READ_zTXt_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_push_handle_zTXt,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_push_read_zTXt,(png_structrp png_ptr,\n    png_inforp info_ptr),PNG_EMPTY);\n#  endif\n#  ifdef PNG_READ_iTXt_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_push_handle_iTXt,(png_structrp png_ptr,\n    png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_push_read_iTXt,(png_structrp png_ptr,\n    png_inforp info_ptr),PNG_EMPTY);\n#  endif\n\n#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */\n\n/* Added at libpng version 1.6.0 */\n#ifdef PNG_GAMMA_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_colorspace_set_gamma,(png_const_structrp png_ptr,\n    png_colorspacerp colorspace, png_fixed_point gAMA), PNG_EMPTY);\n   /* Set the colorspace gamma with a value provided by the application or by\n    * the gAMA chunk on read.  The value will override anything set by an ICC\n    * profile.\n    */\n\nPNG_INTERNAL_FUNCTION(void,png_colorspace_sync_info,(png_const_structrp png_ptr,\n    png_inforp info_ptr), PNG_EMPTY);\n    /* Synchronize the info 'valid' flags with the colorspace */\n\nPNG_INTERNAL_FUNCTION(void,png_colorspace_sync,(png_const_structrp png_ptr,\n    png_inforp info_ptr), PNG_EMPTY);\n    /* Copy the png_struct colorspace to the info_struct and call the above to\n     * synchronize the flags.  Checks for NULL info_ptr and does nothing.\n     */\n#endif\n\n/* Added at libpng version 1.4.0 */\n#ifdef PNG_COLORSPACE_SUPPORTED\n/* These internal functions are for maintaining the colorspace structure within\n * a png_info or png_struct (or, indeed, both).\n */\nPNG_INTERNAL_FUNCTION(int,png_colorspace_set_chromaticities,\n   (png_const_structrp png_ptr, png_colorspacerp colorspace, const png_xy *xy,\n    int preferred), PNG_EMPTY);\n\nPNG_INTERNAL_FUNCTION(int,png_colorspace_set_endpoints,\n   (png_const_structrp png_ptr, png_colorspacerp colorspace, const png_XYZ *XYZ,\n    int preferred), PNG_EMPTY);\n\n#ifdef PNG_sRGB_SUPPORTED\nPNG_INTERNAL_FUNCTION(int,png_colorspace_set_sRGB,(png_const_structrp png_ptr,\n   png_colorspacerp colorspace, int intent), PNG_EMPTY);\n   /* This does set the colorspace gAMA and cHRM values too, but doesn't set the\n    * flags to write them, if it returns false there was a problem and an error\n    * message has already been output (but the colorspace may still need to be\n    * synced to record the invalid flag).\n    */\n#endif /* sRGB */\n\n#ifdef PNG_iCCP_SUPPORTED\nPNG_INTERNAL_FUNCTION(int,png_colorspace_set_ICC,(png_const_structrp png_ptr,\n   png_colorspacerp colorspace, png_const_charp name,\n   png_uint_32 profile_length, png_const_bytep profile, int color_type),\n   PNG_EMPTY);\n   /* The 'name' is used for information only */\n\n/* Routines for checking parts of an ICC profile. */\nPNG_INTERNAL_FUNCTION(int,png_icc_check_length,(png_const_structrp png_ptr,\n   png_colorspacerp colorspace, png_const_charp name,\n   png_uint_32 profile_length), PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(int,png_icc_check_header,(png_const_structrp png_ptr,\n   png_colorspacerp colorspace, png_const_charp name,\n   png_uint_32 profile_length,\n   png_const_bytep profile /* first 132 bytes only */, int color_type),\n   PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(int,png_icc_check_tag_table,(png_const_structrp png_ptr,\n   png_colorspacerp colorspace, png_const_charp name,\n   png_uint_32 profile_length,\n   png_const_bytep profile /* header plus whole tag table */), PNG_EMPTY);\n#ifdef PNG_sRGB_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_icc_set_sRGB,(\n   png_const_structrp png_ptr, png_colorspacerp colorspace,\n   png_const_bytep profile, uLong adler), PNG_EMPTY);\n   /* 'adler' is the Adler32 checksum of the uncompressed profile data. It may\n    * be zero to indicate that it is not available.  It is used, if provided,\n    * as a fast check on the profile when checking to see if it is sRGB.\n    */\n#endif\n#endif /* iCCP */\n\n#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_colorspace_set_rgb_coefficients,\n   (png_structrp png_ptr), PNG_EMPTY);\n   /* Set the rgb_to_gray coefficients from the colorspace Y values */\n#endif /* READ_RGB_TO_GRAY */\n#endif /* COLORSPACE */\n\n/* Added at libpng version 1.4.0 */\nPNG_INTERNAL_FUNCTION(void,png_check_IHDR,(png_const_structrp png_ptr,\n    png_uint_32 width, png_uint_32 height, int bit_depth,\n    int color_type, int interlace_type, int compression_type,\n    int filter_type),PNG_EMPTY);\n\n/* Added at libpng version 1.5.10 */\n#if defined(PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED) || \\\n    defined(PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED)\nPNG_INTERNAL_FUNCTION(void,png_do_check_palette_indexes,\n   (png_structrp png_ptr, png_row_infop row_info),PNG_EMPTY);\n#endif\n\n#if defined(PNG_FLOATING_POINT_SUPPORTED) && defined(PNG_ERROR_TEXT_SUPPORTED)\nPNG_INTERNAL_FUNCTION(void,png_fixed_error,(png_const_structrp png_ptr,\n   png_const_charp name),PNG_NORETURN);\n#endif\n\n/* Puts 'string' into 'buffer' at buffer[pos], taking care never to overwrite\n * the end.  Always leaves the buffer nul terminated.  Never errors out (and\n * there is no error code.)\n */\nPNG_INTERNAL_FUNCTION(size_t,png_safecat,(png_charp buffer, size_t bufsize,\n   size_t pos, png_const_charp string),PNG_EMPTY);\n\n/* Various internal functions to handle formatted warning messages, currently\n * only implemented for warnings.\n */\n#if defined(PNG_WARNINGS_SUPPORTED) || defined(PNG_TIME_RFC1123_SUPPORTED)\n/* Utility to dump an unsigned value into a buffer, given a start pointer and\n * and end pointer (which should point just *beyond* the end of the buffer!)\n * Returns the pointer to the start of the formatted string.  This utility only\n * does unsigned values.\n */\nPNG_INTERNAL_FUNCTION(png_charp,png_format_number,(png_const_charp start,\n   png_charp end, int format, png_alloc_size_t number),PNG_EMPTY);\n\n/* Convenience macro that takes an array: */\n#define PNG_FORMAT_NUMBER(buffer,format,number) \\\n   png_format_number(buffer, buffer + (sizeof buffer), format, number)\n\n/* Suggested size for a number buffer (enough for 64 bits and a sign!) */\n#define PNG_NUMBER_BUFFER_SIZE 24\n\n/* These are the integer formats currently supported, the name is formed from\n * the standard printf(3) format string.\n */\n#define PNG_NUMBER_FORMAT_u     1 /* chose unsigned API! */\n#define PNG_NUMBER_FORMAT_02u   2\n#define PNG_NUMBER_FORMAT_d     1 /* chose signed API! */\n#define PNG_NUMBER_FORMAT_02d   2\n#define PNG_NUMBER_FORMAT_x     3\n#define PNG_NUMBER_FORMAT_02x   4\n#define PNG_NUMBER_FORMAT_fixed 5 /* choose the signed API */\n#endif\n\n#ifdef PNG_WARNINGS_SUPPORTED\n/* New defines and members adding in libpng-1.5.4 */\n#  define PNG_WARNING_PARAMETER_SIZE 32\n#  define PNG_WARNING_PARAMETER_COUNT 8 /* Maximum 9; see pngerror.c */\n\n/* An l-value of this type has to be passed to the APIs below to cache the\n * values of the parameters to a formatted warning message.\n */\ntypedef char png_warning_parameters[PNG_WARNING_PARAMETER_COUNT][\n   PNG_WARNING_PARAMETER_SIZE];\n\nPNG_INTERNAL_FUNCTION(void,png_warning_parameter,(png_warning_parameters p,\n   int number, png_const_charp string),PNG_EMPTY);\n   /* Parameters are limited in size to PNG_WARNING_PARAMETER_SIZE characters,\n    * including the trailing '\\0'.\n    */\nPNG_INTERNAL_FUNCTION(void,png_warning_parameter_unsigned,\n   (png_warning_parameters p, int number, int format, png_alloc_size_t value),\n   PNG_EMPTY);\n   /* Use png_alloc_size_t because it is an unsigned type as big as any we\n    * need to output.  Use the following for a signed value.\n    */\nPNG_INTERNAL_FUNCTION(void,png_warning_parameter_signed,\n   (png_warning_parameters p, int number, int format, png_int_32 value),\n   PNG_EMPTY);\n\nPNG_INTERNAL_FUNCTION(void,png_formatted_warning,(png_const_structrp png_ptr,\n   png_warning_parameters p, png_const_charp message),PNG_EMPTY);\n   /* 'message' follows the X/Open approach of using @1, @2 to insert\n    * parameters previously supplied using the above functions.  Errors in\n    * specifying the parameters will simply result in garbage substitutions.\n    */\n#endif\n\n#ifdef PNG_BENIGN_ERRORS_SUPPORTED\n/* Application errors (new in 1.6); use these functions (declared below) for\n * errors in the parameters or order of API function calls on read.  The\n * 'warning' should be used for an error that can be handled completely; the\n * 'error' for one which can be handled safely but which may lose application\n * information or settings.\n *\n * By default these both result in a png_error call prior to release, while in a\n * released version the 'warning' is just a warning.  However if the application\n * explicitly disables benign errors (explicitly permitting the code to lose\n * information) they both turn into warnings.\n *\n * If benign errors aren't supported they end up as the corresponding base call\n * (png_warning or png_error.)\n */\nPNG_INTERNAL_FUNCTION(void,png_app_warning,(png_const_structrp png_ptr,\n   png_const_charp message),PNG_EMPTY);\n   /* The application provided invalid parameters to an API function or called\n    * an API function at the wrong time, libpng can completely recover.\n    */\n\nPNG_INTERNAL_FUNCTION(void,png_app_error,(png_const_structrp png_ptr,\n   png_const_charp message),PNG_EMPTY);\n   /* As above but libpng will ignore the call, or attempt some other partial\n    * recovery from the error.\n    */\n#else\n#  define png_app_warning(pp,s) png_warning(pp,s)\n#  define png_app_error(pp,s) png_error(pp,s)\n#endif\n\nPNG_INTERNAL_FUNCTION(void,png_chunk_report,(png_const_structrp png_ptr,\n   png_const_charp message, int error),PNG_EMPTY);\n   /* Report a recoverable issue in chunk data.  On read this is used to report\n    * a problem found while reading a particular chunk and the\n    * png_chunk_benign_error or png_chunk_warning function is used as\n    * appropriate.  On write this is used to report an error that comes from\n    * data set via an application call to a png_set_ API and png_app_error or\n    * png_app_warning is used as appropriate.\n    *\n    * The 'error' parameter must have one of the following values:\n    */\n#define PNG_CHUNK_WARNING     0 /* never an error */\n#define PNG_CHUNK_WRITE_ERROR 1 /* an error only on write */\n#define PNG_CHUNK_ERROR       2 /* always an error */\n\n/* ASCII to FP interfaces, currently only implemented if sCAL\n * support is required.\n */\n#if defined(PNG_sCAL_SUPPORTED)\n/* MAX_DIGITS is actually the maximum number of characters in an sCAL\n * width or height, derived from the precision (number of significant\n * digits - a build time settable option) and assumptions about the\n * maximum ridiculous exponent.\n */\n#define PNG_sCAL_MAX_DIGITS (PNG_sCAL_PRECISION+1/*.*/+1/*E*/+10/*exponent*/)\n\n#ifdef PNG_FLOATING_POINT_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_ascii_from_fp,(png_const_structrp png_ptr,\n   png_charp ascii, png_size_t size, double fp, unsigned int precision),\n   PNG_EMPTY);\n#endif /* FLOATING_POINT */\n\n#ifdef PNG_FIXED_POINT_SUPPORTED\nPNG_INTERNAL_FUNCTION(void,png_ascii_from_fixed,(png_const_structrp png_ptr,\n   png_charp ascii, png_size_t size, png_fixed_point fp),PNG_EMPTY);\n#endif /* FIXED_POINT */\n#endif /* sCAL */\n\n#if defined(PNG_sCAL_SUPPORTED) || defined(PNG_pCAL_SUPPORTED)\n/* An internal API to validate the format of a floating point number.\n * The result is the index of the next character.  If the number is\n * not valid it will be the index of a character in the supposed number.\n *\n * The format of a number is defined in the PNG extensions specification\n * and this API is strictly conformant to that spec, not anyone elses!\n *\n * The format as a regular expression is:\n *\n * [+-]?[0-9]+.?([Ee][+-]?[0-9]+)?\n *\n * or:\n *\n * [+-]?.[0-9]+(.[0-9]+)?([Ee][+-]?[0-9]+)?\n *\n * The complexity is that either integer or fraction must be present and the\n * fraction is permitted to have no digits only if the integer is present.\n *\n * NOTE: The dangling E problem.\n *   There is a PNG valid floating point number in the following:\n *\n *       PNG floating point numbers are not greedy.\n *\n *   Working this out requires *TWO* character lookahead (because of the\n *   sign), the parser does not do this - it will fail at the 'r' - this\n *   doesn't matter for PNG sCAL chunk values, but it requires more care\n *   if the value were ever to be embedded in something more complex.  Use\n *   ANSI-C strtod if you need the lookahead.\n */\n/* State table for the parser. */\n#define PNG_FP_INTEGER    0  /* before or in integer */\n#define PNG_FP_FRACTION   1  /* before or in fraction */\n#define PNG_FP_EXPONENT   2  /* before or in exponent */\n#define PNG_FP_STATE      3  /* mask for the above */\n#define PNG_FP_SAW_SIGN   4  /* Saw +/- in current state */\n#define PNG_FP_SAW_DIGIT  8  /* Saw a digit in current state */\n#define PNG_FP_SAW_DOT   16  /* Saw a dot in current state */\n#define PNG_FP_SAW_E     32  /* Saw an E (or e) in current state */\n#define PNG_FP_SAW_ANY   60  /* Saw any of the above 4 */\n\n/* These three values don't affect the parser.  They are set but not used.\n */\n#define PNG_FP_WAS_VALID 64  /* Preceding substring is a valid fp number */\n#define PNG_FP_NEGATIVE 128  /* A negative number, including \"-0\" */\n#define PNG_FP_NONZERO  256  /* A non-zero value */\n#define PNG_FP_STICKY   448  /* The above three flags */\n\n/* This is available for the caller to store in 'state' if required.  Do not\n * call the parser after setting it (the parser sometimes clears it.)\n */\n#define PNG_FP_INVALID  512  /* Available for callers as a distinct value */\n\n/* Result codes for the parser (boolean - true meants ok, false means\n * not ok yet.)\n */\n#define PNG_FP_MAYBE      0  /* The number may be valid in the future */\n#define PNG_FP_OK         1  /* The number is valid */\n\n/* Tests on the sticky non-zero and negative flags.  To pass these checks\n * the state must also indicate that the whole number is valid - this is\n * achieved by testing PNG_FP_SAW_DIGIT (see the implementation for why this\n * is equivalent to PNG_FP_OK above.)\n */\n#define PNG_FP_NZ_MASK (PNG_FP_SAW_DIGIT | PNG_FP_NEGATIVE | PNG_FP_NONZERO)\n   /* NZ_MASK: the string is valid and a non-zero negative value */\n#define PNG_FP_Z_MASK (PNG_FP_SAW_DIGIT | PNG_FP_NONZERO)\n   /* Z MASK: the string is valid and a non-zero value. */\n   /* PNG_FP_SAW_DIGIT: the string is valid. */\n#define PNG_FP_IS_ZERO(state) (((state) & PNG_FP_Z_MASK) == PNG_FP_SAW_DIGIT)\n#define PNG_FP_IS_POSITIVE(state) (((state) & PNG_FP_NZ_MASK) == PNG_FP_Z_MASK)\n#define PNG_FP_IS_NEGATIVE(state) (((state) & PNG_FP_NZ_MASK) == PNG_FP_NZ_MASK)\n\n/* The actual parser.  This can be called repeatedly. It updates\n * the index into the string and the state variable (which must\n * be initialized to 0).  It returns a result code, as above.  There\n * is no point calling the parser any more if it fails to advance to\n * the end of the string - it is stuck on an invalid character (or\n * terminated by '\\0').\n *\n * Note that the pointer will consume an E or even an E+ and then leave\n * a 'maybe' state even though a preceding integer.fraction is valid.\n * The PNG_FP_WAS_VALID flag indicates that a preceding substring was\n * a valid number.  It's possible to recover from this by calling\n * the parser again (from the start, with state 0) but with a string\n * that omits the last character (i.e. set the size to the index of\n * the problem character.)  This has not been tested within libpng.\n */\nPNG_INTERNAL_FUNCTION(int,png_check_fp_number,(png_const_charp string,\n   png_size_t size, int *statep, png_size_tp whereami),PNG_EMPTY);\n\n/* This is the same but it checks a complete string and returns true\n * only if it just contains a floating point number.  As of 1.5.4 this\n * function also returns the state at the end of parsing the number if\n * it was valid (otherwise it returns 0.)  This can be used for testing\n * for negative or zero values using the sticky flag.\n */\nPNG_INTERNAL_FUNCTION(int,png_check_fp_string,(png_const_charp string,\n   png_size_t size),PNG_EMPTY);\n#endif /* pCAL || sCAL */\n\n#if defined(PNG_GAMMA_SUPPORTED) ||\\\n    defined(PNG_INCH_CONVERSIONS_SUPPORTED) || defined(PNG_READ_pHYs_SUPPORTED)\n/* Added at libpng version 1.5.0 */\n/* This is a utility to provide a*times/div (rounded) and indicate\n * if there is an overflow.  The result is a boolean - false (0)\n * for overflow, true (1) if no overflow, in which case *res\n * holds the result.\n */\nPNG_INTERNAL_FUNCTION(int,png_muldiv,(png_fixed_point_p res, png_fixed_point a,\n   png_int_32 multiplied_by, png_int_32 divided_by),PNG_EMPTY);\n#endif\n\n#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_INCH_CONVERSIONS_SUPPORTED)\n/* Same deal, but issue a warning on overflow and return 0. */\nPNG_INTERNAL_FUNCTION(png_fixed_point,png_muldiv_warn,\n   (png_const_structrp png_ptr, png_fixed_point a, png_int_32 multiplied_by,\n   png_int_32 divided_by),PNG_EMPTY);\n#endif\n\n#ifdef PNG_GAMMA_SUPPORTED\n/* Calculate a reciprocal - used for gamma values.  This returns\n * 0 if the argument is 0 in order to maintain an undefined value;\n * there are no warnings.\n */\nPNG_INTERNAL_FUNCTION(png_fixed_point,png_reciprocal,(png_fixed_point a),\n   PNG_EMPTY);\n\n#ifdef PNG_READ_GAMMA_SUPPORTED\n/* The same but gives a reciprocal of the product of two fixed point\n * values.  Accuracy is suitable for gamma calculations but this is\n * not exact - use png_muldiv for that.  Only required at present on read.\n */\nPNG_INTERNAL_FUNCTION(png_fixed_point,png_reciprocal2,(png_fixed_point a,\n   png_fixed_point b),PNG_EMPTY);\n#endif\n\n/* Return true if the gamma value is significantly different from 1.0 */\nPNG_INTERNAL_FUNCTION(int,png_gamma_significant,(png_fixed_point gamma_value),\n   PNG_EMPTY);\n#endif\n\n#ifdef PNG_READ_GAMMA_SUPPORTED\n/* Internal fixed point gamma correction.  These APIs are called as\n * required to convert single values - they don't need to be fast,\n * they are not used when processing image pixel values.\n *\n * While the input is an 'unsigned' value it must actually be the\n * correct bit value - 0..255 or 0..65535 as required.\n */\nPNG_INTERNAL_FUNCTION(png_uint_16,png_gamma_correct,(png_structrp png_ptr,\n   unsigned int value, png_fixed_point gamma_value),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(png_uint_16,png_gamma_16bit_correct,(unsigned int value,\n   png_fixed_point gamma_value),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(png_byte,png_gamma_8bit_correct,(unsigned int value,\n   png_fixed_point gamma_value),PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_destroy_gamma_table,(png_structrp png_ptr),\n   PNG_EMPTY);\nPNG_INTERNAL_FUNCTION(void,png_build_gamma_table,(png_structrp png_ptr,\n   int bit_depth),PNG_EMPTY);\n#endif\n\n/* SIMPLIFIED READ/WRITE SUPPORT */\n#if defined(PNG_SIMPLIFIED_READ_SUPPORTED) ||\\\n   defined(PNG_SIMPLIFIED_WRITE_SUPPORTED)\n/* The internal structure that png_image::opaque points to. */\ntypedef struct png_control\n{\n   png_structp png_ptr;\n   png_infop   info_ptr;\n   png_voidp   error_buf;           /* Always a jmp_buf at present. */\n\n   png_const_bytep memory;          /* Memory buffer. */\n   png_size_t      size;            /* Size of the memory buffer. */\n\n   unsigned int for_write       :1; /* Otherwise it is a read structure */\n   unsigned int owned_file      :1; /* We own the file in io_ptr */\n} png_control;\n\n/* Return the pointer to the jmp_buf from a png_control: necessary because C\n * does not reveal the type of the elements of jmp_buf.\n */\n#ifdef __cplusplus\n#  define png_control_jmp_buf(pc) (((jmp_buf*)((pc)->error_buf))[0])\n#else\n#  define png_control_jmp_buf(pc) ((pc)->error_buf)\n#endif\n\n/* Utility to safely execute a piece of libpng code catching and logging any\n * errors that might occur.  Returns true on success, false on failure (either\n * of the function or as a result of a png_error.)\n */\nPNG_INTERNAL_CALLBACK(void,png_safe_error,(png_structp png_ptr,\n   png_const_charp error_message),PNG_NORETURN);\n\n#ifdef PNG_WARNINGS_SUPPORTED\nPNG_INTERNAL_CALLBACK(void,png_safe_warning,(png_structp png_ptr,\n   png_const_charp warning_message),PNG_EMPTY);\n#else\n#  define png_safe_warning 0/*dummy argument*/\n#endif\n\nPNG_INTERNAL_FUNCTION(int,png_safe_execute,(png_imagep image,\n   int (*function)(png_voidp), png_voidp arg),PNG_EMPTY);\n\n/* Utility to log an error; this also cleans up the png_image; the function\n * always returns 0 (false).\n */\nPNG_INTERNAL_FUNCTION(int,png_image_error,(png_imagep image,\n   png_const_charp error_message),PNG_EMPTY);\n\n#ifndef PNG_SIMPLIFIED_READ_SUPPORTED\n/* png_image_free is used by the write code but not exported */\nPNG_INTERNAL_FUNCTION(void, png_image_free, (png_imagep image), PNG_EMPTY);\n#endif /* !SIMPLIFIED_READ */\n\n#endif /* SIMPLIFIED READ/WRITE */\n\n/* These are initialization functions for hardware specific PNG filter\n * optimizations; list these here then select the appropriate one at compile\n * time using the macro PNG_FILTER_OPTIMIZATIONS.  If the macro is not defined\n * the generic code is used.\n */\n#ifdef PNG_FILTER_OPTIMIZATIONS\nPNG_INTERNAL_FUNCTION(void, PNG_FILTER_OPTIMIZATIONS, (png_structp png_ptr,\n   unsigned int bpp), PNG_EMPTY);\n   /* Just declare the optimization that will be used */\n#else\n   /* List *all* the possible optimizations here - this branch is required if\n    * the builder of libpng passes the definition of PNG_FILTER_OPTIMIZATIONS in\n    * CFLAGS in place of CPPFLAGS *and* uses symbol prefixing.\n    */\nPNG_INTERNAL_FUNCTION(void, png_init_filter_functions_neon,\n   (png_structp png_ptr, unsigned int bpp), PNG_EMPTY);\n#endif\n\n/* Maintainer: Put new private prototypes here ^ */\n\n#include \"pngdebug.h\"\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* PNG_VERSION_INFO_ONLY */\n#endif /* PNGPRIV_H */\n"
  },
  {
    "path": "Projects/Libraries/CSBase/Source/png/pngread.c",
    "content": "\n/* pngread.c - read a PNG file\n *\n * Last changed in libpng 1.6.10 [March 6, 2014]\n * Copyright (c) 1998-2014 Glenn Randers-Pehrson\n * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)\n * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)\n *\n * This code is released under the libpng license.\n * For conditions of distribution and use, see the disclaimer\n * and license in png.h\n *\n * This file contains routines that an application calls directly to\n * read a PNG file or stream.\n */\n\n#include \"pngpriv.h\"\n#if defined(PNG_SIMPLIFIED_READ_SUPPORTED) && defined(PNG_STDIO_SUPPORTED)\n#  include <errno.h>\n#endif\n\n#ifdef PNG_READ_SUPPORTED\n\n/* Create a PNG structure for reading, and allocate any memory needed. */\nPNG_FUNCTION(png_structp,PNGAPI\npng_create_read_struct,(png_const_charp user_png_ver, png_voidp error_ptr,\n    png_error_ptr error_fn, png_error_ptr warn_fn),PNG_ALLOCATED)\n{\n#ifndef PNG_USER_MEM_SUPPORTED\n   png_structp png_ptr = png_create_png_struct(user_png_ver, error_ptr,\n      error_fn, warn_fn, NULL, NULL, NULL);\n#else\n   return png_create_read_struct_2(user_png_ver, error_ptr, error_fn,\n       warn_fn, NULL, NULL, NULL);\n}\n\n/* Alternate create PNG structure for reading, and allocate any memory\n * needed.\n */\nPNG_FUNCTION(png_structp,PNGAPI\npng_create_read_struct_2,(png_const_charp user_png_ver, png_voidp error_ptr,\n    png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr,\n    png_malloc_ptr malloc_fn, png_free_ptr free_fn),PNG_ALLOCATED)\n{\n   png_structp png_ptr = png_create_png_struct(user_png_ver, error_ptr,\n      error_fn, warn_fn, mem_ptr, malloc_fn, free_fn);\n#endif /* PNG_USER_MEM_SUPPORTED */\n\n   if (png_ptr != NULL)\n   {\n      png_ptr->mode = PNG_IS_READ_STRUCT;\n\n      /* Added in libpng-1.6.0; this can be used to detect a read structure if\n       * required (it will be zero in a write structure.)\n       */\n#     ifdef PNG_SEQUENTIAL_READ_SUPPORTED\n         png_ptr->IDAT_read_size = PNG_IDAT_READ_SIZE;\n#     endif\n\n#     ifdef PNG_BENIGN_READ_ERRORS_SUPPORTED\n         png_ptr->flags |= PNG_FLAG_BENIGN_ERRORS_WARN;\n\n         /* In stable builds only warn if an application error can be completely\n          * handled.\n          */\n#        if PNG_LIBPNG_BUILD_BASE_TYPE >= PNG_LIBPNG_BUILD_RC\n            png_ptr->flags |= PNG_FLAG_APP_WARNINGS_WARN;\n#        endif\n#     endif\n\n      /* TODO: delay this, it can be done in png_init_io (if the app doesn't\n       * do it itself) avoiding setting the default function if it is not\n       * required.\n       */\n      png_set_read_fn(png_ptr, NULL, NULL);\n   }\n\n   return png_ptr;\n}\n\n\n#ifdef PNG_SEQUENTIAL_READ_SUPPORTED\n/* Read the information before the actual image data.  This has been\n * changed in v0.90 to allow reading a file that already has the magic\n * bytes read from the stream.  You can tell libpng how many bytes have\n * been read from the beginning of the stream (up to the maximum of 8)\n * via png_set_sig_bytes(), and we will only check the remaining bytes\n * here.  The application can then have access to the signature bytes we\n * read if it is determined that this isn't a valid PNG file.\n */\nvoid PNGAPI\npng_read_info(png_structrp png_ptr, png_inforp info_ptr)\n{\n#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED\n   int keep;\n#endif\n\n   png_debug(1, \"in png_read_info\");\n\n   if (png_ptr == NULL || info_ptr == NULL)\n      return;\n\n   /* Read and check the PNG file signature. */\n   png_read_sig(png_ptr, info_ptr);\n\n   for (;;)\n   {\n      png_uint_32 length = png_read_chunk_header(png_ptr);\n      png_uint_32 chunk_name = png_ptr->chunk_name;\n\n      /* IDAT logic needs to happen here to simplify getting the two flags\n       * right.\n       */\n      if (chunk_name == png_IDAT)\n      {\n         if (!(png_ptr->mode & PNG_HAVE_IHDR))\n            png_chunk_error(png_ptr, \"Missing IHDR before IDAT\");\n\n         else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE &&\n             !(png_ptr->mode & PNG_HAVE_PLTE))\n            png_chunk_error(png_ptr, \"Missing PLTE before IDAT\");\n\n         else if (png_ptr->mode & PNG_AFTER_IDAT)\n            png_chunk_benign_error(png_ptr, \"Too many IDATs found\");\n\n         png_ptr->mode |= PNG_HAVE_IDAT;\n      }\n\n      else if (png_ptr->mode & PNG_HAVE_IDAT)\n         png_ptr->mode |= PNG_AFTER_IDAT;\n\n      /* This should be a binary subdivision search or a hash for\n       * matching the chunk name rather than a linear search.\n       */\n      if (chunk_name == png_IHDR)\n         png_handle_IHDR(png_ptr, info_ptr, length);\n\n      else if (chunk_name == png_IEND)\n         png_handle_IEND(png_ptr, info_ptr, length);\n\n#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED\n      else if ((keep = png_chunk_unknown_handling(png_ptr, chunk_name)) != 0)\n      {\n         png_handle_unknown(png_ptr, info_ptr, length, keep);\n\n         if (chunk_name == png_PLTE)\n            png_ptr->mode |= PNG_HAVE_PLTE;\n\n         else if (chunk_name == png_IDAT)\n         {\n            png_ptr->idat_size = 0; /* It has been consumed */\n            break;\n         }\n      }\n#endif\n      else if (chunk_name == png_PLTE)\n         png_handle_PLTE(png_ptr, info_ptr, length);\n\n      else if (chunk_name == png_IDAT)\n      {\n         png_ptr->idat_size = length;\n         break;\n      }\n\n#ifdef PNG_READ_bKGD_SUPPORTED\n      else if (chunk_name == png_bKGD)\n         png_handle_bKGD(png_ptr, info_ptr, length);\n#endif\n\n#ifdef PNG_READ_cHRM_SUPPORTED\n      else if (chunk_name == png_cHRM)\n         png_handle_cHRM(png_ptr, info_ptr, length);\n#endif\n\n#ifdef PNG_READ_gAMA_SUPPORTED\n      else if (chunk_name == png_gAMA)\n         png_handle_gAMA(png_ptr, info_ptr, length);\n#endif\n\n#ifdef PNG_READ_hIST_SUPPORTED\n      else if (chunk_name == png_hIST)\n         png_handle_hIST(png_ptr, info_ptr, length);\n#endif\n\n#ifdef PNG_READ_oFFs_SUPPORTED\n      else if (chunk_name == png_oFFs)\n         png_handle_oFFs(png_ptr, info_ptr, length);\n#endif\n\n#ifdef PNG_READ_pCAL_SUPPORTED\n      else if (chunk_name == png_pCAL)\n         png_handle_pCAL(png_ptr, info_ptr, length);\n#endif\n\n#ifdef PNG_READ_sCAL_SUPPORTED\n      else if (chunk_name == png_sCAL)\n         png_handle_sCAL(png_ptr, info_ptr, length);\n#endif\n\n#ifdef PNG_READ_pHYs_SUPPORTED\n      else if (chunk_name == png_pHYs)\n         png_handle_pHYs(png_ptr, info_ptr, length);\n#endif\n\n#ifdef PNG_READ_sBIT_SUPPORTED\n      else if (chunk_name == png_sBIT)\n         png_handle_sBIT(png_ptr, info_ptr, length);\n#endif\n\n#ifdef PNG_READ_sRGB_SUPPORTED\n      else if (chunk_name == png_sRGB)\n         png_handle_sRGB(png_ptr, info_ptr, length);\n#endif\n\n#ifdef PNG_READ_iCCP_SUPPORTED\n      else if (chunk_name == png_iCCP)\n         png_handle_iCCP(png_ptr, info_ptr, length);\n#endif\n\n#ifdef PNG_READ_sPLT_SUPPORTED\n      else if (chunk_name == png_sPLT)\n         png_handle_sPLT(png_ptr, info_ptr, length);\n#endif\n\n#ifdef PNG_READ_tEXt_SUPPORTED\n      else if (chunk_name == png_tEXt)\n         png_handle_tEXt(png_ptr, info_ptr, length);\n#endif\n\n#ifdef PNG_READ_tIME_SUPPORTED\n      else if (chunk_name == png_tIME)\n         png_handle_tIME(png_ptr, info_ptr, length);\n#endif\n\n#ifdef PNG_READ_tRNS_SUPPORTED\n      else if (chunk_name == png_tRNS)\n         png_handle_tRNS(png_ptr, info_ptr, length);\n#endif\n\n#ifdef PNG_READ_zTXt_SUPPORTED\n      else if (chunk_name == png_zTXt)\n         png_handle_zTXt(png_ptr, info_ptr, length);\n#endif\n\n#ifdef PNG_READ_iTXt_SUPPORTED\n      else if (chunk_name == png_iTXt)\n         png_handle_iTXt(png_ptr, info_ptr, length);\n#endif\n\n      else\n         png_handle_unknown(png_ptr, info_ptr, length,\n            PNG_HANDLE_CHUNK_AS_DEFAULT);\n   }\n}\n#endif /* PNG_SEQUENTIAL_READ_SUPPORTED */\n\n/* Optional call to update the users info_ptr structure */\nvoid PNGAPI\npng_read_update_info(png_structrp png_ptr, png_inforp info_ptr)\n{\n   png_debug(1, \"in png_read_update_info\");\n\n   if (png_ptr != NULL)\n   {\n      if ((png_ptr->flags & PNG_FLAG_ROW_INIT) == 0)\n      {\n         png_read_start_row(png_ptr);\n\n#        ifdef PNG_READ_TRANSFORMS_SUPPORTED\n            png_read_transform_info(png_ptr, info_ptr);\n#        else\n            PNG_UNUSED(info_ptr)\n#        endif\n      }\n\n      /* New in 1.6.0 this avoids the bug of doing the initializations twice */\n      else\n         png_app_error(png_ptr,\n            \"png_read_update_info/png_start_read_image: duplicate call\");\n   }\n}\n\n#ifdef PNG_SEQUENTIAL_READ_SUPPORTED\n/* Initialize palette, background, etc, after transformations\n * are set, but before any reading takes place.  This allows\n * the user to obtain a gamma-corrected palette, for example.\n * If the user doesn't call this, we will do it ourselves.\n */\nvoid PNGAPI\npng_start_read_image(png_structrp png_ptr)\n{\n   png_debug(1, \"in png_start_read_image\");\n\n   if (png_ptr != NULL)\n   {\n      if ((png_ptr->flags & PNG_FLAG_ROW_INIT) == 0)\n         png_read_start_row(png_ptr);\n\n      /* New in 1.6.0 this avoids the bug of doing the initializations twice */\n      else\n         png_app_error(png_ptr,\n            \"png_start_read_image/png_read_update_info: duplicate call\");\n   }\n}\n#endif /* PNG_SEQUENTIAL_READ_SUPPORTED */\n\n#ifdef PNG_SEQUENTIAL_READ_SUPPORTED\n#ifdef PNG_MNG_FEATURES_SUPPORTED\n/* Undoes intrapixel differencing,\n * NOTE: this is apparently only supported in the 'sequential' reader.\n */\nstatic void\npng_do_read_intrapixel(png_row_infop row_info, png_bytep row)\n{\n   png_debug(1, \"in png_do_read_intrapixel\");\n\n   if (\n       (row_info->color_type & PNG_COLOR_MASK_COLOR))\n   {\n      int bytes_per_pixel;\n      png_uint_32 row_width = row_info->width;\n\n      if (row_info->bit_depth == 8)\n      {\n         png_bytep rp;\n         png_uint_32 i;\n\n         if (row_info->color_type == PNG_COLOR_TYPE_RGB)\n            bytes_per_pixel = 3;\n\n         else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)\n            bytes_per_pixel = 4;\n\n         else\n            return;\n\n         for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel)\n         {\n            *(rp) = (png_byte)((256 + *rp + *(rp + 1)) & 0xff);\n            *(rp+2) = (png_byte)((256 + *(rp + 2) + *(rp + 1)) & 0xff);\n         }\n      }\n      else if (row_info->bit_depth == 16)\n      {\n         png_bytep rp;\n         png_uint_32 i;\n\n         if (row_info->color_type == PNG_COLOR_TYPE_RGB)\n            bytes_per_pixel = 6;\n\n         else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)\n            bytes_per_pixel = 8;\n\n         else\n            return;\n\n         for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel)\n         {\n            png_uint_32 s0   = (*(rp    ) << 8) | *(rp + 1);\n            png_uint_32 s1   = (*(rp + 2) << 8) | *(rp + 3);\n            png_uint_32 s2   = (*(rp + 4) << 8) | *(rp + 5);\n            png_uint_32 red  = (s0 + s1 + 65536) & 0xffff;\n            png_uint_32 blue = (s2 + s1 + 65536) & 0xffff;\n            *(rp    ) = (png_byte)((red >> 8) & 0xff);\n            *(rp + 1) = (png_byte)(red & 0xff);\n            *(rp + 4) = (png_byte)((blue >> 8) & 0xff);\n            *(rp + 5) = (png_byte)(blue & 0xff);\n         }\n      }\n   }\n}\n#endif /* PNG_MNG_FEATURES_SUPPORTED */\n\nvoid PNGAPI\npng_read_row(png_structrp png_ptr, png_bytep row, png_bytep dsp_row)\n{\n   png_row_info row_info;\n\n   if (png_ptr == NULL)\n      return;\n\n   png_debug2(1, \"in png_read_row (row %lu, pass %d)\",\n       (unsigned long)png_ptr->row_number, png_ptr->pass);\n\n   /* png_read_start_row sets the information (in particular iwidth) for this\n    * interlace pass.\n    */\n   if (!(png_ptr->flags & PNG_FLAG_ROW_INIT))\n      png_read_start_row(png_ptr);\n\n   /* 1.5.6: row_info moved out of png_struct to a local here. */\n   row_info.width = png_ptr->iwidth; /* NOTE: width of current interlaced row */\n   row_info.color_type = png_ptr->color_type;\n   row_info.bit_depth = png_ptr->bit_depth;\n   row_info.channels = png_ptr->channels;\n   row_info.pixel_depth = png_ptr->pixel_depth;\n   row_info.rowbytes = PNG_ROWBYTES(row_info.pixel_depth, row_info.width);\n\n   if (png_ptr->row_number == 0 && png_ptr->pass == 0)\n   {\n   /* Check for transforms that have been set but were defined out */\n#if defined(PNG_WRITE_INVERT_SUPPORTED) && !defined(PNG_READ_INVERT_SUPPORTED)\n   if (png_ptr->transformations & PNG_INVERT_MONO)\n      png_warning(png_ptr, \"PNG_READ_INVERT_SUPPORTED is not defined\");\n#endif\n\n#if defined(PNG_WRITE_FILLER_SUPPORTED) && !defined(PNG_READ_FILLER_SUPPORTED)\n   if (png_ptr->transformations & PNG_FILLER)\n      png_warning(png_ptr, \"PNG_READ_FILLER_SUPPORTED is not defined\");\n#endif\n\n#if defined(PNG_WRITE_PACKSWAP_SUPPORTED) && \\\n    !defined(PNG_READ_PACKSWAP_SUPPORTED)\n   if (png_ptr->transformations & PNG_PACKSWAP)\n      png_warning(png_ptr, \"PNG_READ_PACKSWAP_SUPPORTED is not defined\");\n#endif\n\n#if defined(PNG_WRITE_PACK_SUPPORTED) && !defined(PNG_READ_PACK_SUPPORTED)\n   if (png_ptr->transformations & PNG_PACK)\n      png_warning(png_ptr, \"PNG_READ_PACK_SUPPORTED is not defined\");\n#endif\n\n#if defined(PNG_WRITE_SHIFT_SUPPORTED) && !defined(PNG_READ_SHIFT_SUPPORTED)\n   if (png_ptr->transformations & PNG_SHIFT)\n      png_warning(png_ptr, \"PNG_READ_SHIFT_SUPPORTED is not defined\");\n#endif\n\n#if defined(PNG_WRITE_BGR_SUPPORTED) && !defined(PNG_READ_BGR_SUPPORTED)\n   if (png_ptr->transformations & PNG_BGR)\n      png_warning(png_ptr, \"PNG_READ_BGR_SUPPORTED is not defined\");\n#endif\n\n#if defined(PNG_WRITE_SWAP_SUPPORTED) && !defined(PNG_READ_SWAP_SUPPORTED)\n   if (png_ptr->transformations & PNG_SWAP_BYTES)\n      png_warning(png_ptr, \"PNG_READ_SWAP_SUPPORTED is not defined\");\n#endif\n   }\n\n#ifdef PNG_READ_INTERLACING_SUPPORTED\n   /* If interlaced and we do not need a new row, combine row and return.\n    * Notice that the pixels we have from previous rows have been transformed\n    * already; we can only combine like with like (transformed or\n    * untransformed) and, because of the libpng API for interlaced images, this\n    * means we must transform before de-interlacing.\n    */\n   if (png_ptr->interlaced && (png_ptr->transformations & PNG_INTERLACE))\n   {\n      switch (png_ptr->pass)\n      {\n         case 0:\n            if (png_ptr->row_number & 0x07)\n            {\n               if (dsp_row != NULL)\n                  png_combine_row(png_ptr, dsp_row, 1/*display*/);\n               png_read_finish_row(png_ptr);\n               return;\n            }\n            break;\n\n         case 1:\n            if ((png_ptr->row_number & 0x07) || png_ptr->width < 5)\n            {\n               if (dsp_row != NULL)\n                  png_combine_row(png_ptr, dsp_row, 1/*display*/);\n\n               png_read_finish_row(png_ptr);\n               return;\n            }\n            break;\n\n         case 2:\n            if ((png_ptr->row_number & 0x07) != 4)\n            {\n               if (dsp_row != NULL && (png_ptr->row_number & 4))\n                  png_combine_row(png_ptr, dsp_row, 1/*display*/);\n\n               png_read_finish_row(png_ptr);\n               return;\n            }\n            break;\n\n         case 3:\n            if ((png_ptr->row_number & 3) || png_ptr->width < 3)\n            {\n               if (dsp_row != NULL)\n                  png_combine_row(png_ptr, dsp_row, 1/*display*/);\n\n               png_read_finish_row(png_ptr);\n               return;\n            }\n            break;\n\n         case 4:\n            if ((png_ptr->row_number & 3) != 2)\n            {\n               if (dsp_row != NULL && (png_ptr->row_number & 2))\n                  png_combine_row(png_ptr, dsp_row, 1/*display*/);\n\n               png_read_finish_row(png_ptr);\n               return;\n            }\n            break;\n\n         case 5:\n            if ((png_ptr->row_number & 1) || png_ptr->width < 2)\n            {\n               if (dsp_row != NULL)\n                  png_combine_row(png_ptr, dsp_row, 1/*display*/);\n\n               png_read_finish_row(png_ptr);\n               return;\n            }\n            break;\n\n         default:\n         case 6:\n            if (!(png_ptr->row_number & 1))\n            {\n               png_read_finish_row(png_ptr);\n               return;\n            }\n            break;\n      }\n   }\n#endif\n\n   if (!(png_ptr->mode & PNG_HAVE_IDAT))\n      png_error(png_ptr, \"Invalid attempt to read row data\");\n\n   /* Fill the row with IDAT data: */\n   png_read_IDAT_data(png_ptr, png_ptr->row_buf, row_info.rowbytes + 1);\n\n   if (png_ptr->row_buf[0] > PNG_FILTER_VALUE_NONE)\n   {\n      if (png_ptr->row_buf[0] < PNG_FILTER_VALUE_LAST)\n         png_read_filter_row(png_ptr, &row_info, png_ptr->row_buf + 1,\n            png_ptr->prev_row + 1, png_ptr->row_buf[0]);\n      else\n         png_error(png_ptr, \"bad adaptive filter value\");\n   }\n\n   /* libpng 1.5.6: the following line was copying png_ptr->rowbytes before\n    * 1.5.6, while the buffer really is this big in current versions of libpng\n    * it may not be in the future, so this was changed just to copy the\n    * interlaced count:\n    */\n   memcpy(png_ptr->prev_row, png_ptr->row_buf, row_info.rowbytes + 1);\n\n#ifdef PNG_MNG_FEATURES_SUPPORTED\n   if ((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) &&\n       (png_ptr->filter_type == PNG_INTRAPIXEL_DIFFERENCING))\n   {\n      /* Intrapixel differencing */\n      png_do_read_intrapixel(&row_info, png_ptr->row_buf + 1);\n   }\n#endif\n\n#ifdef PNG_READ_TRANSFORMS_SUPPORTED\n   if (png_ptr->transformations)\n      png_do_read_transformations(png_ptr, &row_info);\n#endif\n\n   /* The transformed pixel depth should match the depth now in row_info. */\n   if (png_ptr->transformed_pixel_depth == 0)\n   {\n      png_ptr->transformed_pixel_depth = row_info.pixel_depth;\n      if (row_info.pixel_depth > png_ptr->maximum_pixel_depth)\n         png_error(png_ptr, \"sequential row overflow\");\n   }\n\n   else if (png_ptr->transformed_pixel_depth != row_info.pixel_depth)\n      png_error(png_ptr, \"internal sequential row size calculation error\");\n\n#ifdef PNG_READ_INTERLACING_SUPPORTED\n   /* Blow up interlaced rows to full size */\n   if (png_ptr->interlaced &&\n      (png_ptr->transformations & PNG_INTERLACE))\n   {\n      if (png_ptr->pass < 6)\n         png_do_read_interlace(&row_info, png_ptr->row_buf + 1, png_ptr->pass,\n            png_ptr->transformations);\n\n      if (dsp_row != NULL)\n         png_combine_row(png_ptr, dsp_row, 1/*display*/);\n\n      if (row != NULL)\n         png_combine_row(png_ptr, row, 0/*row*/);\n   }\n\n   else\n#endif\n   {\n      if (row != NULL)\n         png_combine_row(png_ptr, row, -1/*ignored*/);\n\n      if (dsp_row != NULL)\n         png_combine_row(png_ptr, dsp_row, -1/*ignored*/);\n   }\n   png_read_finish_row(png_ptr);\n\n   if (png_ptr->read_row_fn != NULL)\n      (*(png_ptr->read_row_fn))(png_ptr, png_ptr->row_number, png_ptr->pass);\n\n}\n#endif /* PNG_SEQUENTIAL_READ_SUPPORTED */\n\n#ifdef PNG_SEQUENTIAL_READ_SUPPORTED\n/* Read one or more rows of image data.  If the image is interlaced,\n * and png_set_interlace_handling() has been called, the rows need to\n * contain the contents of the rows from the previous pass.  If the\n * image has alpha or transparency, and png_handle_alpha()[*] has been\n * called, the rows contents must be initialized to the contents of the\n * screen.\n *\n * \"row\" holds the actual image, and pixels are placed in it\n * as they arrive.  If the image is displayed after each pass, it will\n * appear to \"sparkle\" in.  \"display_row\" can be used to display a\n * \"chunky\" progressive image, with finer detail added as it becomes\n * available.  If you do not want this \"chunky\" display, you may pass\n * NULL for display_row.  If you do not want the sparkle display, and\n * you have not called png_handle_alpha(), you may pass NULL for rows.\n * If you have called png_handle_alpha(), and the image has either an\n * alpha channel or a transparency chunk, you must provide a buffer for\n * rows.  In this case, you do not have to provide a display_row buffer\n * also, but you may.  If the image is not interlaced, or if you have\n * not called png_set_interlace_handling(), the display_row buffer will\n * be ignored, so pass NULL to it.\n *\n * [*] png_handle_alpha() does not exist yet, as of this version of libpng\n */\n\nvoid PNGAPI\npng_read_rows(png_structrp png_ptr, png_bytepp row,\n    png_bytepp display_row, png_uint_32 num_rows)\n{\n   png_uint_32 i;\n   png_bytepp rp;\n   png_bytepp dp;\n\n   png_debug(1, \"in png_read_rows\");\n\n   if (png_ptr == NULL)\n      return;\n\n   rp = row;\n   dp = display_row;\n   if (rp != NULL && dp != NULL)\n      for (i = 0; i < num_rows; i++)\n      {\n         png_bytep rptr = *rp++;\n         png_bytep dptr = *dp++;\n\n         png_read_row(png_ptr, rptr, dptr);\n      }\n\n   else if (rp != NULL)\n      for (i = 0; i < num_rows; i++)\n      {\n         png_bytep rptr = *rp;\n         png_read_row(png_ptr, rptr, NULL);\n         rp++;\n      }\n\n   else if (dp != NULL)\n      for (i = 0; i < num_rows; i++)\n      {\n         png_bytep dptr = *dp;\n         png_read_row(png_ptr, NULL, dptr);\n         dp++;\n      }\n}\n#endif /* PNG_SEQUENTIAL_READ_SUPPORTED */\n\n#ifdef PNG_SEQUENTIAL_READ_SUPPORTED\n/* Read the entire image.  If the image has an alpha channel or a tRNS\n * chunk, and you have called png_handle_alpha()[*], you will need to\n * initialize the image to the current image that PNG will be overlaying.\n * We set the num_rows again here, in case it was incorrectly set in\n * png_read_start_row() by a call to png_read_update_info() or\n * png_start_read_image() if png_set_interlace_handling() wasn't called\n * prior to either of these functions like it should have been.  You can\n * only call this function once.  If you desire to have an image for\n * each pass of a interlaced image, use png_read_rows() instead.\n *\n * [*] png_handle_alpha() does not exist yet, as of this version of libpng\n */\nvoid PNGAPI\npng_read_image(png_structrp png_ptr, png_bytepp image)\n{\n   png_uint_32 i, image_height;\n   int pass, j;\n   png_bytepp rp;\n\n   png_debug(1, \"in png_read_image\");\n\n   if (png_ptr == NULL)\n      return;\n\n#ifdef PNG_READ_INTERLACING_SUPPORTED\n   if (!(png_ptr->flags & PNG_FLAG_ROW_INIT))\n   {\n      pass = png_set_interlace_handling(png_ptr);\n      /* And make sure transforms are initialized. */\n      png_start_read_image(png_ptr);\n   }\n   else\n   {\n      if (png_ptr->interlaced && !(png_ptr->transformations & PNG_INTERLACE))\n      {\n         /* Caller called png_start_read_image or png_read_update_info without\n          * first turning on the PNG_INTERLACE transform.  We can fix this here,\n          * but the caller should do it!\n          */\n         png_warning(png_ptr, \"Interlace handling should be turned on when \"\n            \"using png_read_image\");\n         /* Make sure this is set correctly */\n         png_ptr->num_rows = png_ptr->height;\n      }\n\n      /* Obtain the pass number, which also turns on the PNG_INTERLACE flag in\n       * the above error case.\n       */\n      pass = png_set_interlace_handling(png_ptr);\n   }\n#else\n   if (png_ptr->interlaced)\n      png_error(png_ptr,\n          \"Cannot read interlaced image -- interlace handler disabled\");\n\n   pass = 1;\n#endif\n\n   image_height=png_ptr->height;\n\n   for (j = 0; j < pass; j++)\n   {\n      rp = image;\n      for (i = 0; i < image_height; i++)\n      {\n         png_read_row(png_ptr, *rp, NULL);\n         rp++;\n      }\n   }\n}\n#endif /* PNG_SEQUENTIAL_READ_SUPPORTED */\n\n#ifdef PNG_SEQUENTIAL_READ_SUPPORTED\n/* Read the end of the PNG file.  Will not read past the end of the\n * file, will verify the end is accurate, and will read any comments\n * or time information at the end of the file, if info is not NULL.\n */\nvoid PNGAPI\npng_read_end(png_structrp png_ptr, png_inforp info_ptr)\n{\n#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED\n   int keep;\n#endif\n\n   png_debug(1, \"in png_read_end\");\n\n   if (png_ptr == NULL)\n      return;\n\n   /* If png_read_end is called in the middle of reading the rows there may\n    * still be pending IDAT data and an owned zstream.  Deal with this here.\n    */\n#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED\n   if (!png_chunk_unknown_handling(png_ptr, png_IDAT))\n#endif\n      png_read_finish_IDAT(png_ptr);\n\n#ifdef PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED\n   /* Report invalid palette index; added at libng-1.5.10 */\n   if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE &&\n      png_ptr->num_palette_max > png_ptr->num_palette)\n     png_benign_error(png_ptr, \"Read palette index exceeding num_palette\");\n#endif\n\n   do\n   {\n      png_uint_32 length = png_read_chunk_header(png_ptr);\n      png_uint_32 chunk_name = png_ptr->chunk_name;\n\n      if (chunk_name == png_IEND)\n         png_handle_IEND(png_ptr, info_ptr, length);\n\n      else if (chunk_name == png_IHDR)\n         png_handle_IHDR(png_ptr, info_ptr, length);\n\n      else if (info_ptr == NULL)\n         png_crc_finish(png_ptr, length);\n\n#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED\n      else if ((keep = png_chunk_unknown_handling(png_ptr, chunk_name)) != 0)\n      {\n         if (chunk_name == png_IDAT)\n         {\n            if ((length > 0) || (png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT))\n               png_benign_error(png_ptr, \"Too many IDATs found\");\n         }\n         png_handle_unknown(png_ptr, info_ptr, length, keep);\n         if (chunk_name == png_PLTE)\n            png_ptr->mode |= PNG_HAVE_PLTE;\n      }\n#endif\n\n      else if (chunk_name == png_IDAT)\n      {\n         /* Zero length IDATs are legal after the last IDAT has been\n          * read, but not after other chunks have been read.\n          */\n         if ((length > 0) || (png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT))\n            png_benign_error(png_ptr, \"Too many IDATs found\");\n\n         png_crc_finish(png_ptr, length);\n      }\n      else if (chunk_name == png_PLTE)\n         png_handle_PLTE(png_ptr, info_ptr, length);\n\n#ifdef PNG_READ_bKGD_SUPPORTED\n      else if (chunk_name == png_bKGD)\n         png_handle_bKGD(png_ptr, info_ptr, length);\n#endif\n\n#ifdef PNG_READ_cHRM_SUPPORTED\n      else if (chunk_name == png_cHRM)\n         png_handle_cHRM(png_ptr, info_ptr, length);\n#endif\n\n#ifdef PNG_READ_gAMA_SUPPORTED\n      else if (chunk_name == png_gAMA)\n         png_handle_gAMA(png_ptr, info_ptr, length);\n#endif\n\n#ifdef PNG_READ_hIST_SUPPORTED\n      else if (chunk_name == png_hIST)\n         png_handle_hIST(png_ptr, info_ptr, length);\n#endif\n\n#ifdef PNG_READ_oFFs_SUPPORTED\n      else if (chunk_name == png_oFFs)\n         png_handle_oFFs(png_ptr, info_ptr, length);\n#endif\n\n#ifdef PNG_READ_pCAL_SUPPORTED\n      else if (chunk_name == png_pCAL)\n         png_handle_pCAL(png_ptr, info_ptr, length);\n#endif\n\n#ifdef PNG_READ_sCAL_SUPPORTED\n      else if (chunk_name == png_sCAL)\n         png_handle_sCAL(png_ptr, info_ptr, length);\n#endif\n\n#ifdef PNG_READ_pHYs_SUPPORTED\n      else if (chunk_name == png_pHYs)\n         png_handle_pHYs(png_ptr, info_ptr, length);\n#endif\n\n#ifdef PNG_READ_sBIT_SUPPORTED\n      else if (chunk_name == png_sBIT)\n         png_handle_sBIT(png_ptr, info_ptr, length);\n#endif\n\n#ifdef PNG_READ_sRGB_SUPPORTED\n      else if (chunk_name == png_sRGB)\n         png_handle_sRGB(png_ptr, info_ptr, length);\n#endif\n\n#ifdef PNG_READ_iCCP_SUPPORTED\n      else if (chunk_name == png_iCCP)\n         png_handle_iCCP(png_ptr, info_ptr, length);\n#endif\n\n#ifdef PNG_READ_sPLT_SUPPORTED\n      else if (chunk_name == png_sPLT)\n         png_handle_sPLT(png_ptr, info_ptr, length);\n#endif\n\n#ifdef PNG_READ_tEXt_SUPPORTED\n      else if (chunk_name == png_tEXt)\n         png_handle_tEXt(png_ptr, info_ptr, length);\n#endif\n\n#ifdef PNG_READ_tIME_SUPPORTED\n      else if (chunk_name == png_tIME)\n         png_handle_tIME(png_ptr, info_ptr, length);\n#endif\n\n#ifdef PNG_READ_tRNS_SUPPORTED\n      else if (chunk_name == png_tRNS)\n         png_handle_tRNS(png_ptr, info_ptr, length);\n#endif\n\n#ifdef PNG_READ_zTXt_SUPPORTED\n      else if (chunk_name == png_zTXt)\n         png_handle_zTXt(png_ptr, info_ptr, length);\n#endif\n\n#ifdef PNG_READ_iTXt_SUPPORTED\n      else if (chunk_name == png_iTXt)\n         png_handle_iTXt(png_ptr, info_ptr, length);\n#endif\n\n      else\n         png_handle_unknown(png_ptr, info_ptr, length,\n            PNG_HANDLE_CHUNK_AS_DEFAULT);\n   } while (!(png_ptr->mode & PNG_HAVE_IEND));\n}\n#endif /* PNG_SEQUENTIAL_READ_SUPPORTED */\n\n/* Free all memory used in the read struct */\nstatic void\npng_read_destroy(png_structrp png_ptr)\n{\n   png_debug(1, \"in png_read_destroy\");\n\n#ifdef PNG_READ_GAMMA_SUPPORTED\n   png_destroy_gamma_table(png_ptr);\n#endif\n\n   png_free(png_ptr, png_ptr->big_row_buf);\n   png_free(png_ptr, png_ptr->big_prev_row);\n   png_free(png_ptr, png_ptr->read_buffer);\n\n#ifdef PNG_READ_QUANTIZE_SUPPORTED\n   png_free(png_ptr, png_ptr->palette_lookup);\n   png_free(png_ptr, png_ptr->quantize_index);\n#endif\n\n   if (png_ptr->free_me & PNG_FREE_PLTE)\n      png_zfree(png_ptr, png_ptr->palette);\n   png_ptr->free_me &= ~PNG_FREE_PLTE;\n\n#if defined(PNG_tRNS_SUPPORTED) || \\\n    defined(PNG_READ_EXPAND_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)\n   if (png_ptr->free_me & PNG_FREE_TRNS)\n      png_free(png_ptr, png_ptr->trans_alpha);\n   png_ptr->free_me &= ~PNG_FREE_TRNS;\n#endif\n\n   inflateEnd(&png_ptr->zstream);\n\n#ifdef PNG_PROGRESSIVE_READ_SUPPORTED\n   png_free(png_ptr, png_ptr->save_buffer);\n#endif\n\n#if defined(PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED) &&\\\n   defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED)\n   png_free(png_ptr, png_ptr->unknown_chunk.data);\n#endif\n\n#ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED\n   png_free(png_ptr, png_ptr->chunk_list);\n#endif\n\n   /* NOTE: the 'setjmp' buffer may still be allocated and the memory and error\n    * callbacks are still set at this point.  They are required to complete the\n    * destruction of the png_struct itself.\n    */\n}\n\n/* Free all memory used by the read */\nvoid PNGAPI\npng_destroy_read_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr,\n    png_infopp end_info_ptr_ptr)\n{\n   png_structrp png_ptr = NULL;\n\n   png_debug(1, \"in png_destroy_read_struct\");\n\n   if (png_ptr_ptr != NULL)\n      png_ptr = *png_ptr_ptr;\n\n   if (png_ptr == NULL)\n      return;\n\n   /* libpng 1.6.0: use the API to destroy info structs to ensure consistent\n    * behavior.  Prior to 1.6.0 libpng did extra 'info' destruction in this API.\n    * The extra was, apparently, unnecessary yet this hides memory leak bugs.\n    */\n   png_destroy_info_struct(png_ptr, end_info_ptr_ptr);\n   png_destroy_info_struct(png_ptr, info_ptr_ptr);\n\n   *png_ptr_ptr = NULL;\n   png_read_destroy(png_ptr);\n   png_destroy_png_struct(png_ptr);\n}\n\nvoid PNGAPI\npng_set_read_status_fn(png_structrp png_ptr, png_read_status_ptr read_row_fn)\n{\n   if (png_ptr == NULL)\n      return;\n\n   png_ptr->read_row_fn = read_row_fn;\n}\n\n\n#ifdef PNG_SEQUENTIAL_READ_SUPPORTED\n#ifdef PNG_INFO_IMAGE_SUPPORTED\nvoid PNGAPI\npng_read_png(png_structrp png_ptr, png_inforp info_ptr,\n                           int transforms,\n                           voidp params)\n{\n   if (png_ptr == NULL || info_ptr == NULL)\n      return;\n\n   /* png_read_info() gives us all of the information from the\n    * PNG file before the first IDAT (image data chunk).\n    */\n   png_read_info(png_ptr, info_ptr);\n   if (info_ptr->height > PNG_UINT_32_MAX/(sizeof (png_bytep)))\n      png_error(png_ptr, \"Image is too high to process with png_read_png()\");\n\n   /* -------------- image transformations start here ------------------- */\n   /* libpng 1.6.10: add code to cause a png_app_error if a selected TRANSFORM\n    * is not implemented.  This will only happen in de-configured (non-default)\n    * libpng builds.  The results can be unexpected - png_read_png may return\n    * short or mal-formed rows because the transform is skipped.\n    */\n\n   /* Tell libpng to strip 16-bit/color files down to 8 bits per color.\n    */\n   if (transforms & PNG_TRANSFORM_SCALE_16)\n     /* Added at libpng-1.5.4. \"strip_16\" produces the same result that it\n      * did in earlier versions, while \"scale_16\" is now more accurate.\n      */\n#ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED\n      png_set_scale_16(png_ptr);\n#else\n      png_app_error(png_ptr, \"PNG_TRANSFORM_SCALE_16 not supported\");\n#endif\n\n   /* If both SCALE and STRIP are required pngrtran will effectively cancel the\n    * latter by doing SCALE first.  This is ok and allows apps not to check for\n    * which is supported to get the right answer.\n    */\n   if (transforms & PNG_TRANSFORM_STRIP_16)\n#ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED\n      png_set_strip_16(png_ptr);\n#else\n      png_app_error(png_ptr, \"PNG_TRANSFORM_STRIP_16 not supported\");\n#endif\n\n   /* Strip alpha bytes from the input data without combining with\n    * the background (not recommended).\n    */\n   if (transforms & PNG_TRANSFORM_STRIP_ALPHA)\n#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED\n      png_set_strip_alpha(png_ptr);\n#else\n      png_app_error(png_ptr, \"PNG_TRANSFORM_STRIP_ALPHA not supported\");\n#endif\n\n   /* Extract multiple pixels with bit depths of 1, 2, or 4 from a single\n    * byte into separate bytes (useful for paletted and grayscale images).\n    */\n   if (transforms & PNG_TRANSFORM_PACKING)\n#ifdef PNG_READ_PACK_SUPPORTED\n      png_set_packing(png_ptr);\n#else\n      png_app_error(png_ptr, \"PNG_TRANSFORM_PACKING not supported\");\n#endif\n\n   /* Change the order of packed pixels to least significant bit first\n    * (not useful if you are using png_set_packing).\n    */\n   if (transforms & PNG_TRANSFORM_PACKSWAP)\n#ifdef PNG_READ_PACKSWAP_SUPPORTED\n      png_set_packswap(png_ptr);\n#else\n      png_app_error(png_ptr, \"PNG_TRANSFORM_PACKSWAP not supported\");\n#endif\n\n   /* Expand paletted colors into true RGB triplets\n    * Expand grayscale images to full 8 bits from 1, 2, or 4 bits/pixel\n    * Expand paletted or RGB images with transparency to full alpha\n    * channels so the data will be available as RGBA quartets.\n    */\n   if (transforms & PNG_TRANSFORM_EXPAND)\n#ifdef PNG_READ_EXPAND_SUPPORTED\n      png_set_expand(png_ptr);\n#else\n      png_app_error(png_ptr, \"PNG_TRANSFORM_EXPAND not supported\");\n#endif\n\n   /* We don't handle background color or gamma transformation or quantizing.\n    */\n\n   /* Invert monochrome files to have 0 as white and 1 as black\n    */\n   if (transforms & PNG_TRANSFORM_INVERT_MONO)\n#ifdef PNG_READ_INVERT_SUPPORTED\n      png_set_invert_mono(png_ptr);\n#else\n      png_app_error(png_ptr, \"PNG_TRANSFORM_INVERT_MONO not supported\");\n#endif\n\n   /* If you want to shift the pixel values from the range [0,255] or\n    * [0,65535] to the original [0,7] or [0,31], or whatever range the\n    * colors were originally in:\n    */\n   if (transforms & PNG_TRANSFORM_SHIFT)\n#ifdef PNG_READ_SHIFT_SUPPORTED\n      if (info_ptr->valid & PNG_INFO_sBIT)\n         png_set_shift(png_ptr, &info_ptr->sig_bit);\n#else\n      png_app_error(png_ptr, \"PNG_TRANSFORM_SHIFT not supported\");\n#endif\n\n   /* Flip the RGB pixels to BGR (or RGBA to BGRA) */\n   if (transforms & PNG_TRANSFORM_BGR)\n#ifdef PNG_READ_BGR_SUPPORTED\n      png_set_bgr(png_ptr);\n#else\n      png_app_error(png_ptr, \"PNG_TRANSFORM_BGR not supported\");\n#endif\n\n   /* Swap the RGBA or GA data to ARGB or AG (or BGRA to ABGR) */\n   if (transforms & PNG_TRANSFORM_SWAP_ALPHA)\n#ifdef PNG_READ_SWAP_ALPHA_SUPPORTED\n      png_set_swap_alpha(png_ptr);\n#else\n      png_app_error(png_ptr, \"PNG_TRANSFORM_SWAP_ALPHA not supported\");\n#endif\n\n   /* Swap bytes of 16-bit files to least significant byte first */\n   if (transforms & PNG_TRANSFORM_SWAP_ENDIAN)\n#ifdef PNG_READ_SWAP_SUPPORTED\n      png_set_swap(png_ptr);\n#else\n      png_app_error(png_ptr, \"PNG_TRANSFORM_SWAP_ENDIAN not supported\");\n#endif\n\n/* Added at libpng-1.2.41 */\n   /* Invert the alpha channel from opacity to transparency */\n   if (transforms & PNG_TRANSFORM_INVERT_ALPHA)\n#ifdef PNG_READ_INVERT_ALPHA_SUPPORTED\n      png_set_invert_alpha(png_ptr);\n#else\n      png_app_error(png_ptr, \"PNG_TRANSFORM_INVERT_ALPHA not supported\");\n#endif\n\n/* Added at libpng-1.2.41 */\n   /* Expand grayscale image to RGB */\n   if (transforms & PNG_TRANSFORM_GRAY_TO_RGB)\n#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED\n      png_set_gray_to_rgb(png_ptr);\n#else\n      png_app_error(png_ptr, \"PNG_TRANSFORM_GRAY_TO_RGB not supported\");\n#endif\n\n/* Added at libpng-1.5.4 */\n   if (transforms & PNG_TRANSFORM_EXPAND_16)\n#ifdef PNG_READ_EXPAND_16_SUPPORTED\n      png_set_expand_16(png_ptr);\n#else\n      png_app_error(png_ptr, \"PNG_TRANSFORM_EXPAND_16 not supported\");\n#endif\n\n   /* We don't handle adding filler bytes */\n\n   /* We use png_read_image and rely on that for interlace handling, but we also\n    * call png_read_update_info therefore must turn on interlace handling now:\n    */\n   (void)png_set_interlace_handling(png_ptr);\n\n   /* Optional call to gamma correct and add the background to the palette\n    * and update info structure.  REQUIRED if you are expecting libpng to\n    * update the palette for you (i.e., you selected such a transform above).\n    */\n   png_read_update_info(png_ptr, info_ptr);\n\n   /* -------------- image transformations end here ------------------- */\n\n   png_free_data(png_ptr, info_ptr, PNG_FREE_ROWS, 0);\n   if (info_ptr->row_pointers == NULL)\n   {\n      png_uint_32 iptr;\n\n      info_ptr->row_pointers = png_voidcast(png_bytepp, png_malloc(png_ptr,\n          info_ptr->height * (sizeof (png_bytep))));\n\n      for (iptr=0; iptr<info_ptr->height; iptr++)\n         info_ptr->row_pointers[iptr] = NULL;\n\n      info_ptr->free_me |= PNG_FREE_ROWS;\n\n      for (iptr = 0; iptr < info_ptr->height; iptr++)\n         info_ptr->row_pointers[iptr] = png_voidcast(png_bytep,\n            png_malloc(png_ptr, info_ptr->rowbytes));\n   }\n\n   png_read_image(png_ptr, info_ptr->row_pointers);\n   info_ptr->valid |= PNG_INFO_IDAT;\n\n   /* Read rest of file, and get additional chunks in info_ptr - REQUIRED */\n   png_read_end(png_ptr, info_ptr);\n\n   PNG_UNUSED(params)\n}\n#endif /* PNG_INFO_IMAGE_SUPPORTED */\n#endif /* PNG_SEQUENTIAL_READ_SUPPORTED */\n\n#ifdef PNG_SIMPLIFIED_READ_SUPPORTED\n/* SIMPLIFIED READ\n *\n * This code currently relies on the sequential reader, though it could easily\n * be made to work with the progressive one.\n */\n/* Arguments to png_image_finish_read: */\n\n/* Encoding of PNG data (used by the color-map code) */\n#  define P_NOTSET  0 /* File encoding not yet known */\n#  define P_sRGB    1 /* 8-bit encoded to sRGB gamma */\n#  define P_LINEAR  2 /* 16-bit linear: not encoded, NOT pre-multiplied! */\n#  define P_FILE    3 /* 8-bit encoded to file gamma, not sRGB or linear */\n#  define P_LINEAR8 4 /* 8-bit linear: only from a file value */\n\n/* Color-map processing: after libpng has run on the PNG image further\n * processing may be needed to conver the data to color-map indicies.\n */\n#define PNG_CMAP_NONE      0\n#define PNG_CMAP_GA        1 /* Process GA data to a color-map with alpha */\n#define PNG_CMAP_TRANS     2 /* Process GA data to a background index */\n#define PNG_CMAP_RGB       3 /* Process RGB data */\n#define PNG_CMAP_RGB_ALPHA 4 /* Process RGBA data */\n\n/* The following document where the background is for each processing case. */\n#define PNG_CMAP_NONE_BACKGROUND      256\n#define PNG_CMAP_GA_BACKGROUND        231\n#define PNG_CMAP_TRANS_BACKGROUND     254\n#define PNG_CMAP_RGB_BACKGROUND       256\n#define PNG_CMAP_RGB_ALPHA_BACKGROUND 216\n\ntypedef struct\n{\n   /* Arguments: */\n   png_imagep image;\n   png_voidp  buffer;\n   png_int_32 row_stride;\n   png_voidp  colormap;\n   png_const_colorp background;\n   /* Local variables: */\n   png_voidp       local_row;\n   png_voidp       first_row;\n   ptrdiff_t       row_bytes;           /* step between rows */\n   int             file_encoding;       /* E_ values above */\n   png_fixed_point gamma_to_linear;     /* For P_FILE, reciprocal of gamma */\n   int             colormap_processing; /* PNG_CMAP_ values above */\n} png_image_read_control;\n\n/* Do all the *safe* initialization - 'safe' means that png_error won't be\n * called, so setting up the jmp_buf is not required.  This means that anything\n * called from here must *not* call png_malloc - it has to call png_malloc_warn\n * instead so that control is returned safely back to this routine.\n */\nstatic int\npng_image_read_init(png_imagep image)\n{\n   if (image->opaque == NULL)\n   {\n      png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, image,\n          png_safe_error, png_safe_warning);\n\n      /* And set the rest of the structure to NULL to ensure that the various\n       * fields are consistent.\n       */\n      memset(image, 0, (sizeof *image));\n      image->version = PNG_IMAGE_VERSION;\n\n      if (png_ptr != NULL)\n      {\n         png_infop info_ptr = png_create_info_struct(png_ptr);\n\n         if (info_ptr != NULL)\n         {\n            png_controlp control = png_voidcast(png_controlp,\n               png_malloc_warn(png_ptr, (sizeof *control)));\n\n            if (control != NULL)\n            {\n               memset(control, 0, (sizeof *control));\n\n               control->png_ptr = png_ptr;\n               control->info_ptr = info_ptr;\n               control->for_write = 0;\n\n               image->opaque = control;\n               return 1;\n            }\n\n            /* Error clean up */\n            png_destroy_info_struct(png_ptr, &info_ptr);\n         }\n\n         png_destroy_read_struct(&png_ptr, NULL, NULL);\n      }\n\n      return png_image_error(image, \"png_image_read: out of memory\");\n   }\n\n   return png_image_error(image, \"png_image_read: opaque pointer not NULL\");\n}\n\n/* Utility to find the base format of a PNG file from a png_struct. */\nstatic png_uint_32\npng_image_format(png_structrp png_ptr)\n{\n   png_uint_32 format = 0;\n\n   if (png_ptr->color_type & PNG_COLOR_MASK_COLOR)\n      format |= PNG_FORMAT_FLAG_COLOR;\n\n   if (png_ptr->color_type & PNG_COLOR_MASK_ALPHA)\n      format |= PNG_FORMAT_FLAG_ALPHA;\n\n   /* Use png_ptr here, not info_ptr, because by examination png_handle_tRNS\n    * sets the png_struct fields; that's all we are interested in here.  The\n    * precise interaction with an app call to png_set_tRNS and PNG file reading\n    * is unclear.\n    */\n   else if (png_ptr->num_trans > 0)\n      format |= PNG_FORMAT_FLAG_ALPHA;\n\n   if (png_ptr->bit_depth == 16)\n      format |= PNG_FORMAT_FLAG_LINEAR;\n\n   if (png_ptr->color_type & PNG_COLOR_MASK_PALETTE)\n      format |= PNG_FORMAT_FLAG_COLORMAP;\n\n   return format;\n}\n\n/* Is the given gamma significantly different from sRGB?  The test is the same\n * one used in pngrtran.c when deciding whether to do gamma correction.  The\n * arithmetic optimizes the division by using the fact that the inverse of the\n * file sRGB gamma is 2.2\n */\nstatic int\npng_gamma_not_sRGB(png_fixed_point g)\n{\n   if (g < PNG_FP_1)\n   {\n      /* An uninitialized gamma is assumed to be sRGB for the simplified API. */\n      if (g == 0)\n         return 0;\n\n      return png_gamma_significant((g * 11 + 2)/5 /* i.e. *2.2, rounded */);\n   }\n\n   return 1;\n}\n\n/* Do the main body of a 'png_image_begin_read' function; read the PNG file\n * header and fill in all the information.  This is executed in a safe context,\n * unlike the init routine above.\n */\nstatic int\npng_image_read_header(png_voidp argument)\n{\n   png_imagep image = png_voidcast(png_imagep, argument);\n   png_structrp png_ptr = image->opaque->png_ptr;\n   png_inforp info_ptr = image->opaque->info_ptr;\n\n   png_set_benign_errors(png_ptr, 1/*warn*/);\n   png_read_info(png_ptr, info_ptr);\n\n   /* Do this the fast way; just read directly out of png_struct. */\n   image->width = png_ptr->width;\n   image->height = png_ptr->height;\n\n   {\n      png_uint_32 format = png_image_format(png_ptr);\n\n      image->format = format;\n\n#ifdef PNG_COLORSPACE_SUPPORTED\n      /* Does the colorspace match sRGB?  If there is no color endpoint\n       * (colorant) information assume yes, otherwise require the\n       * 'ENDPOINTS_MATCHP_sRGB' colorspace flag to have been set.  If the\n       * colorspace has been determined to be invalid ignore it.\n       */\n      if ((format & PNG_FORMAT_FLAG_COLOR) != 0 && ((png_ptr->colorspace.flags\n         & (PNG_COLORSPACE_HAVE_ENDPOINTS|PNG_COLORSPACE_ENDPOINTS_MATCH_sRGB|\n            PNG_COLORSPACE_INVALID)) == PNG_COLORSPACE_HAVE_ENDPOINTS))\n         image->flags |= PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB;\n#endif\n   }\n\n   /* We need the maximum number of entries regardless of the format the\n    * application sets here.\n    */\n   {\n      png_uint_32 cmap_entries;\n\n      switch (png_ptr->color_type)\n      {\n         case PNG_COLOR_TYPE_GRAY:\n            cmap_entries = 1U << png_ptr->bit_depth;\n            break;\n\n         case PNG_COLOR_TYPE_PALETTE:\n            cmap_entries = png_ptr->num_palette;\n            break;\n\n         default:\n            cmap_entries = 256;\n            break;\n      }\n\n      if (cmap_entries > 256)\n         cmap_entries = 256;\n\n      image->colormap_entries = cmap_entries;\n   }\n\n   return 1;\n}\n\n#ifdef PNG_STDIO_SUPPORTED\nint PNGAPI\npng_image_begin_read_from_stdio(png_imagep image, FILE* file)\n{\n   if (image != NULL && image->version == PNG_IMAGE_VERSION)\n   {\n      if (file != NULL)\n      {\n         if (png_image_read_init(image))\n         {\n            /* This is slightly evil, but png_init_io doesn't do anything other\n             * than this and we haven't changed the standard IO functions so\n             * this saves a 'safe' function.\n             */\n            image->opaque->png_ptr->io_ptr = file;\n            return png_safe_execute(image, png_image_read_header, image);\n         }\n      }\n\n      else\n         return png_image_error(image,\n            \"png_image_begin_read_from_stdio: invalid argument\");\n   }\n\n   else if (image != NULL)\n      return png_image_error(image,\n         \"png_image_begin_read_from_stdio: incorrect PNG_IMAGE_VERSION\");\n\n   return 0;\n}\n\nint PNGAPI\npng_image_begin_read_from_file(png_imagep image, const char *file_name)\n{\n   if (image != NULL && image->version == PNG_IMAGE_VERSION)\n   {\n      if (file_name != NULL)\n      {\n         FILE *fp = fopen(file_name, \"rb\");\n\n         if (fp != NULL)\n         {\n            if (png_image_read_init(image))\n            {\n               image->opaque->png_ptr->io_ptr = fp;\n               image->opaque->owned_file = 1;\n               return png_safe_execute(image, png_image_read_header, image);\n            }\n\n            /* Clean up: just the opened file. */\n            (void)fclose(fp);\n         }\n\n         else\n            return png_image_error(image, strerror(errno));\n      }\n\n      else\n         return png_image_error(image,\n            \"png_image_begin_read_from_file: invalid argument\");\n   }\n\n   else if (image != NULL)\n      return png_image_error(image,\n         \"png_image_begin_read_from_file: incorrect PNG_IMAGE_VERSION\");\n\n   return 0;\n}\n#endif /* PNG_STDIO_SUPPORTED */\n\nstatic void PNGCBAPI\npng_image_memory_read(png_structp png_ptr, png_bytep out, png_size_t need)\n{\n   if (png_ptr != NULL)\n   {\n      png_imagep image = png_voidcast(png_imagep, png_ptr->io_ptr);\n      if (image != NULL)\n      {\n         png_controlp cp = image->opaque;\n         if (cp != NULL)\n         {\n            png_const_bytep memory = cp->memory;\n            png_size_t size = cp->size;\n\n            if (memory != NULL && size >= need)\n            {\n               memcpy(out, memory, need);\n               cp->memory = memory + need;\n               cp->size = size - need;\n               return;\n            }\n\n            png_error(png_ptr, \"read beyond end of data\");\n         }\n      }\n\n      png_error(png_ptr, \"invalid memory read\");\n   }\n}\n\nint PNGAPI png_image_begin_read_from_memory(png_imagep image,\n   png_const_voidp memory, png_size_t size)\n{\n   if (image != NULL && image->version == PNG_IMAGE_VERSION)\n   {\n      if (memory != NULL && size > 0)\n      {\n         if (png_image_read_init(image))\n         {\n            /* Now set the IO functions to read from the memory buffer and\n             * store it into io_ptr.  Again do this in-place to avoid calling a\n             * libpng function that requires error handling.\n             */\n            image->opaque->memory = png_voidcast(png_const_bytep, memory);\n            image->opaque->size = size;\n            image->opaque->png_ptr->io_ptr = image;\n            image->opaque->png_ptr->read_data_fn = png_image_memory_read;\n\n            return png_safe_execute(image, png_image_read_header, image);\n         }\n      }\n\n      else\n         return png_image_error(image,\n            \"png_image_begin_read_from_memory: invalid argument\");\n   }\n\n   else if (image != NULL)\n      return png_image_error(image,\n         \"png_image_begin_read_from_memory: incorrect PNG_IMAGE_VERSION\");\n\n   return 0;\n}\n\n/* Utility function to skip chunks that are not used by the simplified image\n * read functions and an appropriate macro to call it.\n */\n#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED\nstatic void\npng_image_skip_unused_chunks(png_structrp png_ptr)\n{\n   /* Prepare the reader to ignore all recognized chunks whose data will not\n    * be used, i.e., all chunks recognized by libpng except for those\n    * involved in basic image reading:\n    *\n    *    IHDR, PLTE, IDAT, IEND\n    *\n    * Or image data handling:\n    *\n    *    tRNS, bKGD, gAMA, cHRM, sRGB, [iCCP] and sBIT.\n    *\n    * This provides a small performance improvement and eliminates any\n    * potential vulnerability to security problems in the unused chunks.\n    *\n    * At present the iCCP chunk data isn't used, so iCCP chunk can be ignored\n    * too.  This allows the simplified API to be compiled without iCCP support,\n    * however if the support is there the chunk is still checked to detect\n    * errors (which are unfortunately quite common.)\n    */\n   {\n         static PNG_CONST png_byte chunks_to_process[] = {\n            98,  75,  71,  68, '\\0',  /* bKGD */\n            99,  72,  82,  77, '\\0',  /* cHRM */\n           103,  65,  77,  65, '\\0',  /* gAMA */\n#        ifdef PNG_READ_iCCP_SUPPORTED\n           105,  67,  67,  80, '\\0',  /* iCCP */\n#        endif\n           115,  66,  73,  84, '\\0',  /* sBIT */\n           115,  82,  71,  66, '\\0',  /* sRGB */\n           };\n\n       /* Ignore unknown chunks and all other chunks except for the\n        * IHDR, PLTE, tRNS, IDAT, and IEND chunks.\n        */\n       png_set_keep_unknown_chunks(png_ptr, PNG_HANDLE_CHUNK_NEVER,\n         NULL, -1);\n\n       /* But do not ignore image data handling chunks */\n       png_set_keep_unknown_chunks(png_ptr, PNG_HANDLE_CHUNK_AS_DEFAULT,\n         chunks_to_process, (sizeof chunks_to_process)/5);\n    }\n}\n\n#  define PNG_SKIP_CHUNKS(p) png_image_skip_unused_chunks(p)\n#else\n#  define PNG_SKIP_CHUNKS(p) ((void)0)\n#endif /* PNG_HANDLE_AS_UNKNOWN_SUPPORTED */\n\n/* The following macro gives the exact rounded answer for all values in the\n * range 0..255 (it actually divides by 51.2, but the rounding still generates\n * the correct numbers 0..5\n */\n#define PNG_DIV51(v8) (((v8) * 5 + 130) >> 8)\n\n/* Utility functions to make particular color-maps */\nstatic void\nset_file_encoding(png_image_read_control *display)\n{\n   png_fixed_point g = display->image->opaque->png_ptr->colorspace.gamma;\n   if (png_gamma_significant(g))\n   {\n      if (png_gamma_not_sRGB(g))\n      {\n         display->file_encoding = P_FILE;\n         display->gamma_to_linear = png_reciprocal(g);\n      }\n\n      else\n         display->file_encoding = P_sRGB;\n   }\n\n   else\n      display->file_encoding = P_LINEAR8;\n}\n\nstatic unsigned int\ndecode_gamma(png_image_read_control *display, png_uint_32 value, int encoding)\n{\n   if (encoding == P_FILE) /* double check */\n      encoding = display->file_encoding;\n\n   if (encoding == P_NOTSET) /* must be the file encoding */\n   {\n      set_file_encoding(display);\n      encoding = display->file_encoding;\n   }\n\n   switch (encoding)\n   {\n      case P_FILE:\n         value = png_gamma_16bit_correct(value*257, display->gamma_to_linear);\n         break;\n\n      case P_sRGB:\n         value = png_sRGB_table[value];\n         break;\n\n      case P_LINEAR:\n         break;\n\n      case P_LINEAR8:\n         value *= 257;\n         break;\n\n      default:\n         png_error(display->image->opaque->png_ptr,\n            \"unexpected encoding (internal error)\");\n         break;\n   }\n\n   return value;\n}\n\nstatic png_uint_32\npng_colormap_compose(png_image_read_control *display,\n   png_uint_32 foreground, int foreground_encoding, png_uint_32 alpha,\n   png_uint_32 background, int encoding)\n{\n   /* The file value is composed on the background, the background has the given\n    * encoding and so does the result, the file is encoded with P_FILE and the\n    * file and alpha are 8-bit values.  The (output) encoding will always be\n    * P_LINEAR or P_sRGB.\n    */\n   png_uint_32 f = decode_gamma(display, foreground, foreground_encoding);\n   png_uint_32 b = decode_gamma(display, background, encoding);\n\n   /* The alpha is always an 8-bit value (it comes from the palette), the value\n    * scaled by 255 is what PNG_sRGB_FROM_LINEAR requires.\n    */\n   f = f * alpha + b * (255-alpha);\n\n   if (encoding == P_LINEAR)\n   {\n      /* Scale to 65535; divide by 255, approximately (in fact this is extremely\n       * accurate, it divides by 255.00000005937181414556, with no overflow.)\n       */\n      f *= 257; /* Now scaled by 65535 */\n      f += f >> 16;\n      f = (f+32768) >> 16;\n   }\n\n   else /* P_sRGB */\n      f = PNG_sRGB_FROM_LINEAR(f);\n\n   return f;\n}\n\n/* NOTE: P_LINEAR values to this routine must be 16-bit, but P_FILE values must\n * be 8-bit.\n */\nstatic void\npng_create_colormap_entry(png_image_read_control *display,\n   png_uint_32 ip, png_uint_32 red, png_uint_32 green, png_uint_32 blue,\n   png_uint_32 alpha, int encoding)\n{\n   png_imagep image = display->image;\n   const int output_encoding = (image->format & PNG_FORMAT_FLAG_LINEAR) ?\n      P_LINEAR : P_sRGB;\n   const int convert_to_Y = (image->format & PNG_FORMAT_FLAG_COLOR) == 0 &&\n      (red != green || green != blue);\n\n   if (ip > 255)\n      png_error(image->opaque->png_ptr, \"color-map index out of range\");\n\n   /* Update the cache with whether the file gamma is significantly different\n    * from sRGB.\n    */\n   if (encoding == P_FILE)\n   {\n      if (display->file_encoding == P_NOTSET)\n         set_file_encoding(display);\n\n      /* Note that the cached value may be P_FILE too, but if it is then the\n       * gamma_to_linear member has been set.\n       */\n      encoding = display->file_encoding;\n   }\n\n   if (encoding == P_FILE)\n   {\n      png_fixed_point g = display->gamma_to_linear;\n\n      red = png_gamma_16bit_correct(red*257, g);\n      green = png_gamma_16bit_correct(green*257, g);\n      blue = png_gamma_16bit_correct(blue*257, g);\n\n      if (convert_to_Y || output_encoding == P_LINEAR)\n      {\n         alpha *= 257;\n         encoding = P_LINEAR;\n      }\n\n      else\n      {\n         red = PNG_sRGB_FROM_LINEAR(red * 255);\n         green = PNG_sRGB_FROM_LINEAR(green * 255);\n         blue = PNG_sRGB_FROM_LINEAR(blue * 255);\n         encoding = P_sRGB;\n      }\n   }\n\n   else if (encoding == P_LINEAR8)\n   {\n      /* This encoding occurs quite frequently in test cases because PngSuite\n       * includes a gAMA 1.0 chunk with most images.\n       */\n      red *= 257;\n      green *= 257;\n      blue *= 257;\n      alpha *= 257;\n      encoding = P_LINEAR;\n   }\n\n   else if (encoding == P_sRGB && (convert_to_Y || output_encoding == P_LINEAR))\n   {\n      /* The values are 8-bit sRGB values, but must be converted to 16-bit\n       * linear.\n       */\n      red = png_sRGB_table[red];\n      green = png_sRGB_table[green];\n      blue = png_sRGB_table[blue];\n      alpha *= 257;\n      encoding = P_LINEAR;\n   }\n\n   /* This is set if the color isn't gray but the output is. */\n   if (encoding == P_LINEAR)\n   {\n      if (convert_to_Y)\n      {\n         /* NOTE: these values are copied from png_do_rgb_to_gray */\n         png_uint_32 y = (png_uint_32)6968 * red  + (png_uint_32)23434 * green +\n            (png_uint_32)2366 * blue;\n\n         if (output_encoding == P_LINEAR)\n            y = (y + 16384) >> 15;\n\n         else\n         {\n            /* y is scaled by 32768, we need it scaled by 255: */\n            y = (y + 128) >> 8;\n            y *= 255;\n            y = PNG_sRGB_FROM_LINEAR((y + 64) >> 7);\n            encoding = P_sRGB;\n         }\n\n         blue = red = green = y;\n      }\n\n      else if (output_encoding == P_sRGB)\n      {\n         red = PNG_sRGB_FROM_LINEAR(red * 255);\n         green = PNG_sRGB_FROM_LINEAR(green * 255);\n         blue = PNG_sRGB_FROM_LINEAR(blue * 255);\n         alpha = PNG_DIV257(alpha);\n         encoding = P_sRGB;\n      }\n   }\n\n   if (encoding != output_encoding)\n      png_error(image->opaque->png_ptr, \"bad encoding (internal error)\");\n\n   /* Store the value. */\n   {\n#     ifdef PNG_FORMAT_AFIRST_SUPPORTED\n         const int afirst = (image->format & PNG_FORMAT_FLAG_AFIRST) != 0 &&\n            (image->format & PNG_FORMAT_FLAG_ALPHA) != 0;\n#     else\n#        define afirst 0\n#     endif\n#     ifdef PNG_FORMAT_BGR_SUPPORTED\n         const int bgr = (image->format & PNG_FORMAT_FLAG_BGR) ? 2 : 0;\n#     else\n#        define bgr 0\n#     endif\n\n      if (output_encoding == P_LINEAR)\n      {\n         png_uint_16p entry = png_voidcast(png_uint_16p, display->colormap);\n\n         entry += ip * PNG_IMAGE_SAMPLE_CHANNELS(image->format);\n\n         /* The linear 16-bit values must be pre-multiplied by the alpha channel\n          * value, if less than 65535 (this is, effectively, composite on black\n          * if the alpha channel is removed.)\n          */\n         switch (PNG_IMAGE_SAMPLE_CHANNELS(image->format))\n         {\n            case 4:\n               entry[afirst ? 0 : 3] = (png_uint_16)alpha;\n               /* FALL THROUGH */\n\n            case 3:\n               if (alpha < 65535)\n               {\n                  if (alpha > 0)\n                  {\n                     blue = (blue * alpha + 32767U)/65535U;\n                     green = (green * alpha + 32767U)/65535U;\n                     red = (red * alpha + 32767U)/65535U;\n                  }\n\n                  else\n                     red = green = blue = 0;\n               }\n               entry[afirst + (2 ^ bgr)] = (png_uint_16)blue;\n               entry[afirst + 1] = (png_uint_16)green;\n               entry[afirst + bgr] = (png_uint_16)red;\n               break;\n\n            case 2:\n               entry[1 ^ afirst] = (png_uint_16)alpha;\n               /* FALL THROUGH */\n\n            case 1:\n               if (alpha < 65535)\n               {\n                  if (alpha > 0)\n                     green = (green * alpha + 32767U)/65535U;\n\n                  else\n                     green = 0;\n               }\n               entry[afirst] = (png_uint_16)green;\n               break;\n\n            default:\n               break;\n         }\n      }\n\n      else /* output encoding is P_sRGB */\n      {\n         png_bytep entry = png_voidcast(png_bytep, display->colormap);\n\n         entry += ip * PNG_IMAGE_SAMPLE_CHANNELS(image->format);\n\n         switch (PNG_IMAGE_SAMPLE_CHANNELS(image->format))\n         {\n            case 4:\n               entry[afirst ? 0 : 3] = (png_byte)alpha;\n            case 3:\n               entry[afirst + (2 ^ bgr)] = (png_byte)blue;\n               entry[afirst + 1] = (png_byte)green;\n               entry[afirst + bgr] = (png_byte)red;\n               break;\n\n            case 2:\n               entry[1 ^ afirst] = (png_byte)alpha;\n            case 1:\n               entry[afirst] = (png_byte)green;\n               break;\n\n            default:\n               break;\n         }\n      }\n\n#     ifdef afirst\n#        undef afirst\n#     endif\n#     ifdef bgr\n#        undef bgr\n#     endif\n   }\n}\n\nstatic int\nmake_gray_file_colormap(png_image_read_control *display)\n{\n   unsigned int i;\n\n   for (i=0; i<256; ++i)\n      png_create_colormap_entry(display, i, i, i, i, 255, P_FILE);\n\n   return i;\n}\n\nstatic int\nmake_gray_colormap(png_image_read_control *display)\n{\n   unsigned int i;\n\n   for (i=0; i<256; ++i)\n      png_create_colormap_entry(display, i, i, i, i, 255, P_sRGB);\n\n   return i;\n}\n#define PNG_GRAY_COLORMAP_ENTRIES 256\n\nstatic int\nmake_ga_colormap(png_image_read_control *display)\n{\n   unsigned int i, a;\n\n   /* Alpha is retained, the output will be a color-map with entries\n    * selected by six levels of alpha.  One transparent entry, 6 gray\n    * levels for all the intermediate alpha values, leaving 230 entries\n    * for the opaque grays.  The color-map entries are the six values\n    * [0..5]*51, the GA processing uses PNG_DIV51(value) to find the\n    * relevant entry.\n    *\n    * if (alpha > 229) // opaque\n    * {\n    *    // The 231 entries are selected to make the math below work:\n    *    base = 0;\n    *    entry = (231 * gray + 128) >> 8;\n    * }\n    * else if (alpha < 26) // transparent\n    * {\n    *    base = 231;\n    *    entry = 0;\n    * }\n    * else // partially opaque\n    * {\n    *    base = 226 + 6 * PNG_DIV51(alpha);\n    *    entry = PNG_DIV51(gray);\n    * }\n    */\n   i = 0;\n   while (i < 231)\n   {\n      unsigned int gray = (i * 256 + 115) / 231;\n      png_create_colormap_entry(display, i++, gray, gray, gray, 255, P_sRGB);\n   }\n\n   /* 255 is used here for the component values for consistency with the code\n    * that undoes premultiplication in pngwrite.c.\n    */\n   png_create_colormap_entry(display, i++, 255, 255, 255, 0, P_sRGB);\n\n   for (a=1; a<5; ++a)\n   {\n      unsigned int g;\n\n      for (g=0; g<6; ++g)\n         png_create_colormap_entry(display, i++, g*51, g*51, g*51, a*51,\n            P_sRGB);\n   }\n\n   return i;\n}\n\n#define PNG_GA_COLORMAP_ENTRIES 256\n\nstatic int\nmake_rgb_colormap(png_image_read_control *display)\n{\n   unsigned int i, r;\n\n   /* Build a 6x6x6 opaque RGB cube */\n   for (i=r=0; r<6; ++r)\n   {\n      unsigned int g;\n\n      for (g=0; g<6; ++g)\n      {\n         unsigned int b;\n\n         for (b=0; b<6; ++b)\n            png_create_colormap_entry(display, i++, r*51, g*51, b*51, 255,\n               P_sRGB);\n      }\n   }\n\n   return i;\n}\n\n#define PNG_RGB_COLORMAP_ENTRIES 216\n\n/* Return a palette index to the above palette given three 8-bit sRGB values. */\n#define PNG_RGB_INDEX(r,g,b) \\\n   ((png_byte)(6 * (6 * PNG_DIV51(r) + PNG_DIV51(g)) + PNG_DIV51(b)))\n\nstatic int\npng_image_read_colormap(png_voidp argument)\n{\n   png_image_read_control *display =\n      png_voidcast(png_image_read_control*, argument);\n   const png_imagep image = display->image;\n\n   const png_structrp png_ptr = image->opaque->png_ptr;\n   const png_uint_32 output_format = image->format;\n   const int output_encoding = (output_format & PNG_FORMAT_FLAG_LINEAR) ?\n      P_LINEAR : P_sRGB;\n\n   unsigned int cmap_entries;\n   unsigned int output_processing;        /* Output processing option */\n   unsigned int data_encoding = P_NOTSET; /* Encoding libpng must produce */\n\n   /* Background information; the background color and the index of this color\n    * in the color-map if it exists (else 256).\n    */\n   unsigned int background_index = 256;\n   png_uint_32 back_r, back_g, back_b;\n\n   /* Flags to accumulate things that need to be done to the input. */\n   int expand_tRNS = 0;\n\n   /* Exclude the NYI feature of compositing onto a color-mapped buffer; it is\n    * very difficult to do, the results look awful, and it is difficult to see\n    * what possible use it is because the application can't control the\n    * color-map.\n    */\n   if (((png_ptr->color_type & PNG_COLOR_MASK_ALPHA) != 0 ||\n         png_ptr->num_trans > 0) /* alpha in input */ &&\n      ((output_format & PNG_FORMAT_FLAG_ALPHA) == 0) /* no alpha in output */)\n   {\n      if (output_encoding == P_LINEAR) /* compose on black */\n         back_b = back_g = back_r = 0;\n\n      else if (display->background == NULL /* no way to remove it */)\n         png_error(png_ptr,\n            \"a background color must be supplied to remove alpha/transparency\");\n\n      /* Get a copy of the background color (this avoids repeating the checks\n       * below.)  The encoding is 8-bit sRGB or 16-bit linear, depending on the\n       * output format.\n       */\n      else\n      {\n         back_g = display->background->green;\n         if (output_format & PNG_FORMAT_FLAG_COLOR)\n         {\n            back_r = display->background->red;\n            back_b = display->background->blue;\n         }\n         else\n            back_b = back_r = back_g;\n      }\n   }\n\n   else if (output_encoding == P_LINEAR)\n      back_b = back_r = back_g = 65535;\n\n   else\n      back_b = back_r = back_g = 255;\n\n   /* Default the input file gamma if required - this is necessary because\n    * libpng assumes that if no gamma information is present the data is in the\n    * output format, but the simplified API deduces the gamma from the input\n    * format.\n    */\n   if ((png_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_GAMMA) == 0)\n   {\n      /* Do this directly, not using the png_colorspace functions, to ensure\n       * that it happens even if the colorspace is invalid (though probably if\n       * it is the setting will be ignored)  Note that the same thing can be\n       * achieved at the application interface with png_set_gAMA.\n       */\n      if (png_ptr->bit_depth == 16 &&\n         (image->flags & PNG_IMAGE_FLAG_16BIT_sRGB) == 0)\n         png_ptr->colorspace.gamma = PNG_GAMMA_LINEAR;\n\n      else\n         png_ptr->colorspace.gamma = PNG_GAMMA_sRGB_INVERSE;\n\n      png_ptr->colorspace.flags |= PNG_COLORSPACE_HAVE_GAMMA;\n   }\n\n   /* Decide what to do based on the PNG color type of the input data.  The\n    * utility function png_create_colormap_entry deals with most aspects of the\n    * output transformations; this code works out how to produce bytes of\n    * color-map entries from the original format.\n    */\n   switch (png_ptr->color_type)\n   {\n      case PNG_COLOR_TYPE_GRAY:\n         if (png_ptr->bit_depth <= 8)\n         {\n            /* There at most 256 colors in the output, regardless of\n             * transparency.\n             */\n            unsigned int step, i, val, trans = 256/*ignore*/, back_alpha = 0;\n\n            cmap_entries = 1U << png_ptr->bit_depth;\n            if (cmap_entries > image->colormap_entries)\n               png_error(png_ptr, \"gray[8] color-map: too few entries\");\n\n            step = 255 / (cmap_entries - 1);\n            output_processing = PNG_CMAP_NONE;\n\n            /* If there is a tRNS chunk then this either selects a transparent\n             * value or, if the output has no alpha, the background color.\n             */\n            if (png_ptr->num_trans > 0)\n            {\n               trans = png_ptr->trans_color.gray;\n\n               if ((output_format & PNG_FORMAT_FLAG_ALPHA) == 0)\n                  back_alpha = output_encoding == P_LINEAR ? 65535 : 255;\n            }\n\n            /* png_create_colormap_entry just takes an RGBA and writes the\n             * corresponding color-map entry using the format from 'image',\n             * including the required conversion to sRGB or linear as\n             * appropriate.  The input values are always either sRGB (if the\n             * gamma correction flag is 0) or 0..255 scaled file encoded values\n             * (if the function must gamma correct them).\n             */\n            for (i=val=0; i<cmap_entries; ++i, val += step)\n            {\n               /* 'i' is a file value.  While this will result in duplicated\n                * entries for 8-bit non-sRGB encoded files it is necessary to\n                * have non-gamma corrected values to do tRNS handling.\n                */\n               if (i != trans)\n                  png_create_colormap_entry(display, i, val, val, val, 255,\n                     P_FILE/*8-bit with file gamma*/);\n\n               /* Else this entry is transparent.  The colors don't matter if\n                * there is an alpha channel (back_alpha == 0), but it does no\n                * harm to pass them in; the values are not set above so this\n                * passes in white.\n                *\n                * NOTE: this preserves the full precision of the application\n                * supplied background color when it is used.\n                */\n               else\n                  png_create_colormap_entry(display, i, back_r, back_g, back_b,\n                     back_alpha, output_encoding);\n            }\n\n            /* We need libpng to preserve the original encoding. */\n            data_encoding = P_FILE;\n\n            /* The rows from libpng, while technically gray values, are now also\n             * color-map indicies; however, they may need to be expanded to 1\n             * byte per pixel.  This is what png_set_packing does (i.e., it\n             * unpacks the bit values into bytes.)\n             */\n            if (png_ptr->bit_depth < 8)\n               png_set_packing(png_ptr);\n         }\n\n         else /* bit depth is 16 */\n         {\n            /* The 16-bit input values can be converted directly to 8-bit gamma\n             * encoded values; however, if a tRNS chunk is present 257 color-map\n             * entries are required.  This means that the extra entry requires\n             * special processing; add an alpha channel, sacrifice gray level\n             * 254 and convert transparent (alpha==0) entries to that.\n             *\n             * Use libpng to chop the data to 8 bits.  Convert it to sRGB at the\n             * same time to minimize quality loss.  If a tRNS chunk is present\n             * this means libpng must handle it too; otherwise it is impossible\n             * to do the exact match on the 16-bit value.\n             *\n             * If the output has no alpha channel *and* the background color is\n             * gray then it is possible to let libpng handle the substitution by\n             * ensuring that the corresponding gray level matches the background\n             * color exactly.\n             */\n            data_encoding = P_sRGB;\n\n            if (PNG_GRAY_COLORMAP_ENTRIES > image->colormap_entries)\n               png_error(png_ptr, \"gray[16] color-map: too few entries\");\n\n            cmap_entries = make_gray_colormap(display);\n\n            if (png_ptr->num_trans > 0)\n            {\n               unsigned int back_alpha;\n\n               if (output_format & PNG_FORMAT_FLAG_ALPHA)\n                  back_alpha = 0;\n\n               else\n               {\n                  if (back_r == back_g && back_g == back_b)\n                  {\n                     /* Background is gray; no special processing will be\n                      * required.\n                      */\n                     png_color_16 c;\n                     png_uint_32 gray = back_g;\n\n                     if (output_encoding == P_LINEAR)\n                     {\n                        gray = PNG_sRGB_FROM_LINEAR(gray * 255);\n\n                        /* And make sure the corresponding palette entry\n                         * matches.\n                         */\n                        png_create_colormap_entry(display, gray, back_g, back_g,\n                           back_g, 65535, P_LINEAR);\n                     }\n\n                     /* The background passed to libpng, however, must be the\n                      * sRGB value.\n                      */\n                     c.index = 0; /*unused*/\n                     c.gray = c.red = c.green = c.blue = (png_uint_16)gray;\n\n                     /* NOTE: does this work without expanding tRNS to alpha?\n                      * It should be the color->gray case below apparently\n                      * doesn't.\n                      */\n                     png_set_background_fixed(png_ptr, &c,\n                        PNG_BACKGROUND_GAMMA_SCREEN, 0/*need_expand*/,\n                        0/*gamma: not used*/);\n\n                     output_processing = PNG_CMAP_NONE;\n                     break;\n                  }\n\n                  back_alpha = output_encoding == P_LINEAR ? 65535 : 255;\n               }\n\n               /* output_processing means that the libpng-processed row will be\n                * 8-bit GA and it has to be processing to single byte color-map\n                * values.  Entry 254 is replaced by either a completely\n                * transparent entry or by the background color at full\n                * precision (and the background color is not a simple gray leve\n                * in this case.)\n                */\n               expand_tRNS = 1;\n               output_processing = PNG_CMAP_TRANS;\n               background_index = 254;\n\n               /* And set (overwrite) color-map entry 254 to the actual\n                * background color at full precision.\n                */\n               png_create_colormap_entry(display, 254, back_r, back_g, back_b,\n                  back_alpha, output_encoding);\n            }\n\n            else\n               output_processing = PNG_CMAP_NONE;\n         }\n         break;\n\n      case PNG_COLOR_TYPE_GRAY_ALPHA:\n         /* 8-bit or 16-bit PNG with two channels - gray and alpha.  A minimum\n          * of 65536 combinations.  If, however, the alpha channel is to be\n          * removed there are only 256 possibilities if the background is gray.\n          * (Otherwise there is a subset of the 65536 possibilities defined by\n          * the triangle between black, white and the background color.)\n          *\n          * Reduce 16-bit files to 8-bit and sRGB encode the result.  No need to\n          * worry about tRNS matching - tRNS is ignored if there is an alpha\n          * channel.\n          */\n         data_encoding = P_sRGB;\n\n         if (output_format & PNG_FORMAT_FLAG_ALPHA)\n         {\n            if (PNG_GA_COLORMAP_ENTRIES > image->colormap_entries)\n               png_error(png_ptr, \"gray+alpha color-map: too few entries\");\n\n            cmap_entries = make_ga_colormap(display);\n\n            background_index = PNG_CMAP_GA_BACKGROUND;\n            output_processing = PNG_CMAP_GA;\n         }\n\n         else /* alpha is removed */\n         {\n            /* Alpha must be removed as the PNG data is processed when the\n             * background is a color because the G and A channels are\n             * independent and the vector addition (non-parallel vectors) is a\n             * 2-D problem.\n             *\n             * This can be reduced to the same algorithm as above by making a\n             * colormap containing gray levels (for the opaque grays), a\n             * background entry (for a transparent pixel) and a set of four six\n             * level color values, one set for each intermediate alpha value.\n             * See the comments in make_ga_colormap for how this works in the\n             * per-pixel processing.\n             *\n             * If the background is gray, however, we only need a 256 entry gray\n             * level color map.  It is sufficient to make the entry generated\n             * for the background color be exactly the color specified.\n             */\n            if ((output_format & PNG_FORMAT_FLAG_COLOR) == 0 ||\n               (back_r == back_g && back_g == back_b))\n            {\n               /* Background is gray; no special processing will be required. */\n               png_color_16 c;\n               png_uint_32 gray = back_g;\n\n               if (PNG_GRAY_COLORMAP_ENTRIES > image->colormap_entries)\n                  png_error(png_ptr, \"gray-alpha color-map: too few entries\");\n\n               cmap_entries = make_gray_colormap(display);\n\n               if (output_encoding == P_LINEAR)\n               {\n                  gray = PNG_sRGB_FROM_LINEAR(gray * 255);\n\n                  /* And make sure the corresponding palette entry matches. */\n                  png_create_colormap_entry(display, gray, back_g, back_g,\n                     back_g, 65535, P_LINEAR);\n               }\n\n               /* The background passed to libpng, however, must be the sRGB\n                * value.\n                */\n               c.index = 0; /*unused*/\n               c.gray = c.red = c.green = c.blue = (png_uint_16)gray;\n\n               png_set_background_fixed(png_ptr, &c,\n                  PNG_BACKGROUND_GAMMA_SCREEN, 0/*need_expand*/,\n                  0/*gamma: not used*/);\n\n               output_processing = PNG_CMAP_NONE;\n            }\n\n            else\n            {\n               png_uint_32 i, a;\n\n               /* This is the same as png_make_ga_colormap, above, except that\n                * the entries are all opaque.\n                */\n               if (PNG_GA_COLORMAP_ENTRIES > image->colormap_entries)\n                  png_error(png_ptr, \"ga-alpha color-map: too few entries\");\n\n               i = 0;\n               while (i < 231)\n               {\n                  png_uint_32 gray = (i * 256 + 115) / 231;\n                  png_create_colormap_entry(display, i++, gray, gray, gray,\n                     255, P_sRGB);\n               }\n\n               /* NOTE: this preserves the full precision of the application\n                * background color.\n                */\n               background_index = i;\n               png_create_colormap_entry(display, i++, back_r, back_g, back_b,\n                  output_encoding == P_LINEAR ? 65535U : 255U, output_encoding);\n\n               /* For non-opaque input composite on the sRGB background - this\n                * requires inverting the encoding for each component.  The input\n                * is still converted to the sRGB encoding because this is a\n                * reasonable approximate to the logarithmic curve of human\n                * visual sensitivity, at least over the narrow range which PNG\n                * represents.  Consequently 'G' is always sRGB encoded, while\n                * 'A' is linear.  We need the linear background colors.\n                */\n               if (output_encoding == P_sRGB) /* else already linear */\n               {\n                  /* This may produce a value not exactly matching the\n                   * background, but that's ok because these numbers are only\n                   * used when alpha != 0\n                   */\n                  back_r = png_sRGB_table[back_r];\n                  back_g = png_sRGB_table[back_g];\n                  back_b = png_sRGB_table[back_b];\n               }\n\n               for (a=1; a<5; ++a)\n               {\n                  unsigned int g;\n\n                  /* PNG_sRGB_FROM_LINEAR expects a 16-bit linear value scaled\n                   * by an 8-bit alpha value (0..255).\n                   */\n                  png_uint_32 alpha = 51 * a;\n                  png_uint_32 back_rx = (255-alpha) * back_r;\n                  png_uint_32 back_gx = (255-alpha) * back_g;\n                  png_uint_32 back_bx = (255-alpha) * back_b;\n\n                  for (g=0; g<6; ++g)\n                  {\n                     png_uint_32 gray = png_sRGB_table[g*51] * alpha;\n\n                     png_create_colormap_entry(display, i++,\n                        PNG_sRGB_FROM_LINEAR(gray + back_rx),\n                        PNG_sRGB_FROM_LINEAR(gray + back_gx),\n                        PNG_sRGB_FROM_LINEAR(gray + back_bx), 255, P_sRGB);\n                  }\n               }\n\n               cmap_entries = i;\n               output_processing = PNG_CMAP_GA;\n            }\n         }\n         break;\n\n      case PNG_COLOR_TYPE_RGB:\n      case PNG_COLOR_TYPE_RGB_ALPHA:\n         /* Exclude the case where the output is gray; we can always handle this\n          * with the cases above.\n          */\n         if ((output_format & PNG_FORMAT_FLAG_COLOR) == 0)\n         {\n            /* The color-map will be grayscale, so we may as well convert the\n             * input RGB values to a simple grayscale and use the grayscale\n             * code above.\n             *\n             * NOTE: calling this apparently damages the recognition of the\n             * transparent color in background color handling; call\n             * png_set_tRNS_to_alpha before png_set_background_fixed.\n             */\n            png_set_rgb_to_gray_fixed(png_ptr, PNG_ERROR_ACTION_NONE, -1,\n               -1);\n            data_encoding = P_sRGB;\n\n            /* The output will now be one or two 8-bit gray or gray+alpha\n             * channels.  The more complex case arises when the input has alpha.\n             */\n            if ((png_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA ||\n               png_ptr->num_trans > 0) &&\n               (output_format & PNG_FORMAT_FLAG_ALPHA) != 0)\n            {\n               /* Both input and output have an alpha channel, so no background\n                * processing is required; just map the GA bytes to the right\n                * color-map entry.\n                */\n               expand_tRNS = 1;\n\n               if (PNG_GA_COLORMAP_ENTRIES > image->colormap_entries)\n                  png_error(png_ptr, \"rgb[ga] color-map: too few entries\");\n\n               cmap_entries = make_ga_colormap(display);\n               background_index = PNG_CMAP_GA_BACKGROUND;\n               output_processing = PNG_CMAP_GA;\n            }\n\n            else\n            {\n               /* Either the input or the output has no alpha channel, so there\n                * will be no non-opaque pixels in the color-map; it will just be\n                * grayscale.\n                */\n               if (PNG_GRAY_COLORMAP_ENTRIES > image->colormap_entries)\n                  png_error(png_ptr, \"rgb[gray] color-map: too few entries\");\n\n               /* Ideally this code would use libpng to do the gamma correction,\n                * but if an input alpha channel is to be removed we will hit the\n                * libpng bug in gamma+compose+rgb-to-gray (the double gamma\n                * correction bug).  Fix this by dropping the gamma correction in\n                * this case and doing it in the palette; this will result in\n                * duplicate palette entries, but that's better than the\n                * alternative of double gamma correction.\n                */\n               if ((png_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA ||\n                  png_ptr->num_trans > 0) &&\n                  png_gamma_not_sRGB(png_ptr->colorspace.gamma))\n               {\n                  cmap_entries = make_gray_file_colormap(display);\n                  data_encoding = P_FILE;\n               }\n\n               else\n                  cmap_entries = make_gray_colormap(display);\n\n               /* But if the input has alpha or transparency it must be removed\n                */\n               if (png_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA ||\n                  png_ptr->num_trans > 0)\n               {\n                  png_color_16 c;\n                  png_uint_32 gray = back_g;\n\n                  /* We need to ensure that the application background exists in\n                   * the colormap and that completely transparent pixels map to\n                   * it.  Achieve this simply by ensuring that the entry\n                   * selected for the background really is the background color.\n                   */\n                  if (data_encoding == P_FILE) /* from the fixup above */\n                  {\n                     /* The app supplied a gray which is in output_encoding, we\n                      * need to convert it to a value of the input (P_FILE)\n                      * encoding then set this palette entry to the required\n                      * output encoding.\n                      */\n                     if (output_encoding == P_sRGB)\n                        gray = png_sRGB_table[gray]; /* now P_LINEAR */\n\n                     gray = PNG_DIV257(png_gamma_16bit_correct(gray,\n                        png_ptr->colorspace.gamma)); /* now P_FILE */\n\n                     /* And make sure the corresponding palette entry contains\n                      * exactly the required sRGB value.\n                      */\n                     png_create_colormap_entry(display, gray, back_g, back_g,\n                        back_g, 0/*unused*/, output_encoding);\n                  }\n\n                  else if (output_encoding == P_LINEAR)\n                  {\n                     gray = PNG_sRGB_FROM_LINEAR(gray * 255);\n\n                     /* And make sure the corresponding palette entry matches.\n                      */\n                     png_create_colormap_entry(display, gray, back_g, back_g,\n                        back_g, 0/*unused*/, P_LINEAR);\n                  }\n\n                  /* The background passed to libpng, however, must be the\n                   * output (normally sRGB) value.\n                   */\n                  c.index = 0; /*unused*/\n                  c.gray = c.red = c.green = c.blue = (png_uint_16)gray;\n\n                  /* NOTE: the following is apparently a bug in libpng. Without\n                   * it the transparent color recognition in\n                   * png_set_background_fixed seems to go wrong.\n                   */\n                  expand_tRNS = 1;\n                  png_set_background_fixed(png_ptr, &c,\n                     PNG_BACKGROUND_GAMMA_SCREEN, 0/*need_expand*/,\n                     0/*gamma: not used*/);\n               }\n\n               output_processing = PNG_CMAP_NONE;\n            }\n         }\n\n         else /* output is color */\n         {\n            /* We could use png_quantize here so long as there is no transparent\n             * color or alpha; png_quantize ignores alpha.  Easier overall just\n             * to do it once and using PNG_DIV51 on the 6x6x6 reduced RGB cube.\n             * Consequently we always want libpng to produce sRGB data.\n             */\n            data_encoding = P_sRGB;\n\n            /* Is there any transparency or alpha? */\n            if (png_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA ||\n               png_ptr->num_trans > 0)\n            {\n               /* Is there alpha in the output too?  If so all four channels are\n                * processed into a special RGB cube with alpha support.\n                */\n               if (output_format & PNG_FORMAT_FLAG_ALPHA)\n               {\n                  png_uint_32 r;\n\n                  if (PNG_RGB_COLORMAP_ENTRIES+1+27 > image->colormap_entries)\n                     png_error(png_ptr, \"rgb+alpha color-map: too few entries\");\n\n                  cmap_entries = make_rgb_colormap(display);\n\n                  /* Add a transparent entry. */\n                  png_create_colormap_entry(display, cmap_entries, 255, 255,\n                     255, 0, P_sRGB);\n\n                  /* This is stored as the background index for the processing\n                   * algorithm.\n                   */\n                  background_index = cmap_entries++;\n\n                  /* Add 27 r,g,b entries each with alpha 0.5. */\n                  for (r=0; r<256; r = (r << 1) | 0x7f)\n                  {\n                     png_uint_32 g;\n\n                     for (g=0; g<256; g = (g << 1) | 0x7f)\n                     {\n                        png_uint_32 b;\n\n                        /* This generates components with the values 0, 127 and\n                         * 255\n                         */\n                        for (b=0; b<256; b = (b << 1) | 0x7f)\n                           png_create_colormap_entry(display, cmap_entries++,\n                              r, g, b, 128, P_sRGB);\n                     }\n                  }\n\n                  expand_tRNS = 1;\n                  output_processing = PNG_CMAP_RGB_ALPHA;\n               }\n\n               else\n               {\n                  /* Alpha/transparency must be removed.  The background must\n                   * exist in the color map (achieved by setting adding it after\n                   * the 666 color-map).  If the standard processing code will\n                   * pick up this entry automatically that's all that is\n                   * required; libpng can be called to do the background\n                   * processing.\n                   */\n                  unsigned int sample_size =\n                     PNG_IMAGE_SAMPLE_SIZE(output_format);\n                  png_uint_32 r, g, b; /* sRGB background */\n\n                  if (PNG_RGB_COLORMAP_ENTRIES+1+27 > image->colormap_entries)\n                     png_error(png_ptr, \"rgb-alpha color-map: too few entries\");\n\n                  cmap_entries = make_rgb_colormap(display);\n\n                  png_create_colormap_entry(display, cmap_entries, back_r,\n                        back_g, back_b, 0/*unused*/, output_encoding);\n\n                  if (output_encoding == P_LINEAR)\n                  {\n                     r = PNG_sRGB_FROM_LINEAR(back_r * 255);\n                     g = PNG_sRGB_FROM_LINEAR(back_g * 255);\n                     b = PNG_sRGB_FROM_LINEAR(back_b * 255);\n                  }\n\n                  else\n                  {\n                     r = back_r;\n                     g = back_g;\n                     b = back_g;\n                  }\n\n                  /* Compare the newly-created color-map entry with the one the\n                   * PNG_CMAP_RGB algorithm will use.  If the two entries don't\n                   * match, add the new one and set this as the background\n                   * index.\n                   */\n                  if (memcmp((png_const_bytep)display->colormap +\n                        sample_size * cmap_entries,\n                     (png_const_bytep)display->colormap +\n                        sample_size * PNG_RGB_INDEX(r,g,b),\n                     sample_size) != 0)\n                  {\n                     /* The background color must be added. */\n                     background_index = cmap_entries++;\n\n                     /* Add 27 r,g,b entries each with created by composing with\n                      * the background at alpha 0.5.\n                      */\n                     for (r=0; r<256; r = (r << 1) | 0x7f)\n                     {\n                        for (g=0; g<256; g = (g << 1) | 0x7f)\n                        {\n                           /* This generates components with the values 0, 127\n                            * and 255\n                            */\n                           for (b=0; b<256; b = (b << 1) | 0x7f)\n                              png_create_colormap_entry(display, cmap_entries++,\n                                 png_colormap_compose(display, r, P_sRGB, 128,\n                                    back_r, output_encoding),\n                                 png_colormap_compose(display, g, P_sRGB, 128,\n                                    back_g, output_encoding),\n                                 png_colormap_compose(display, b, P_sRGB, 128,\n                                    back_b, output_encoding),\n                                 0/*unused*/, output_encoding);\n                        }\n                     }\n\n                     expand_tRNS = 1;\n                     output_processing = PNG_CMAP_RGB_ALPHA;\n                  }\n\n                  else /* background color is in the standard color-map */\n                  {\n                     png_color_16 c;\n\n                     c.index = 0; /*unused*/\n                     c.red = (png_uint_16)back_r;\n                     c.gray = c.green = (png_uint_16)back_g;\n                     c.blue = (png_uint_16)back_b;\n\n                     png_set_background_fixed(png_ptr, &c,\n                        PNG_BACKGROUND_GAMMA_SCREEN, 0/*need_expand*/,\n                        0/*gamma: not used*/);\n\n                     output_processing = PNG_CMAP_RGB;\n                  }\n               }\n            }\n\n            else /* no alpha or transparency in the input */\n            {\n               /* Alpha in the output is irrelevant, simply map the opaque input\n                * pixels to the 6x6x6 color-map.\n                */\n               if (PNG_RGB_COLORMAP_ENTRIES > image->colormap_entries)\n                  png_error(png_ptr, \"rgb color-map: too few entries\");\n\n               cmap_entries = make_rgb_colormap(display);\n               output_processing = PNG_CMAP_RGB;\n            }\n         }\n         break;\n\n      case PNG_COLOR_TYPE_PALETTE:\n         /* It's already got a color-map.  It may be necessary to eliminate the\n          * tRNS entries though.\n          */\n         {\n            unsigned int num_trans = png_ptr->num_trans;\n            png_const_bytep trans = num_trans > 0 ? png_ptr->trans_alpha : NULL;\n            png_const_colorp colormap = png_ptr->palette;\n            const int do_background = trans != NULL &&\n               (output_format & PNG_FORMAT_FLAG_ALPHA) == 0;\n            unsigned int i;\n\n            /* Just in case: */\n            if (trans == NULL)\n               num_trans = 0;\n\n            output_processing = PNG_CMAP_NONE;\n            data_encoding = P_FILE; /* Don't change from color-map indicies */\n            cmap_entries = png_ptr->num_palette;\n            if (cmap_entries > 256)\n               cmap_entries = 256;\n\n            if (cmap_entries > image->colormap_entries)\n               png_error(png_ptr, \"palette color-map: too few entries\");\n\n            for (i=0; i < cmap_entries; ++i)\n            {\n               if (do_background && i < num_trans && trans[i] < 255)\n               {\n                  if (trans[i] == 0)\n                     png_create_colormap_entry(display, i, back_r, back_g,\n                        back_b, 0, output_encoding);\n\n                  else\n                  {\n                     /* Must compose the PNG file color in the color-map entry\n                      * on the sRGB color in 'back'.\n                      */\n                     png_create_colormap_entry(display, i,\n                        png_colormap_compose(display, colormap[i].red, P_FILE,\n                           trans[i], back_r, output_encoding),\n                        png_colormap_compose(display, colormap[i].green, P_FILE,\n                           trans[i], back_g, output_encoding),\n                        png_colormap_compose(display, colormap[i].blue, P_FILE,\n                           trans[i], back_b, output_encoding),\n                        output_encoding == P_LINEAR ? trans[i] * 257U :\n                           trans[i],\n                        output_encoding);\n                  }\n               }\n\n               else\n                  png_create_colormap_entry(display, i, colormap[i].red,\n                     colormap[i].green, colormap[i].blue,\n                     i < num_trans ? trans[i] : 255U, P_FILE/*8-bit*/);\n            }\n\n            /* The PNG data may have indicies packed in fewer than 8 bits, it\n             * must be expanded if so.\n             */\n            if (png_ptr->bit_depth < 8)\n               png_set_packing(png_ptr);\n         }\n         break;\n\n      default:\n         png_error(png_ptr, \"invalid PNG color type\");\n         /*NOT REACHED*/\n         break;\n   }\n\n   /* Now deal with the output processing */\n   if (expand_tRNS && png_ptr->num_trans > 0 &&\n      (png_ptr->color_type & PNG_COLOR_MASK_ALPHA) == 0)\n      png_set_tRNS_to_alpha(png_ptr);\n\n   switch (data_encoding)\n   {\n      default:\n         png_error(png_ptr, \"bad data option (internal error)\");\n         break;\n\n      case P_sRGB:\n         /* Change to 8-bit sRGB */\n         png_set_alpha_mode_fixed(png_ptr, PNG_ALPHA_PNG, PNG_GAMMA_sRGB);\n         /* FALL THROUGH */\n\n      case P_FILE:\n         if (png_ptr->bit_depth > 8)\n            png_set_scale_16(png_ptr);\n         break;\n   }\n\n   if (cmap_entries > 256 || cmap_entries > image->colormap_entries)\n      png_error(png_ptr, \"color map overflow (BAD internal error)\");\n\n   image->colormap_entries = cmap_entries;\n\n   /* Double check using the recorded background index */\n   switch (output_processing)\n   {\n      case PNG_CMAP_NONE:\n         if (background_index != PNG_CMAP_NONE_BACKGROUND)\n            goto bad_background;\n         break;\n\n      case PNG_CMAP_GA:\n         if (background_index != PNG_CMAP_GA_BACKGROUND)\n            goto bad_background;\n         break;\n\n      case PNG_CMAP_TRANS:\n         if (background_index >= cmap_entries ||\n            background_index != PNG_CMAP_TRANS_BACKGROUND)\n            goto bad_background;\n         break;\n\n      case PNG_CMAP_RGB:\n         if (background_index != PNG_CMAP_RGB_BACKGROUND)\n            goto bad_background;\n         break;\n\n      case PNG_CMAP_RGB_ALPHA:\n         if (background_index != PNG_CMAP_RGB_ALPHA_BACKGROUND)\n            goto bad_background;\n         break;\n\n      default:\n         png_error(png_ptr, \"bad processing option (internal error)\");\n\n      bad_background:\n         png_error(png_ptr, \"bad background index (internal error)\");\n   }\n\n   display->colormap_processing = output_processing;\n\n   return 1/*ok*/;\n}\n\n/* The final part of the color-map read called from png_image_finish_read. */\nstatic int\npng_image_read_and_map(png_voidp argument)\n{\n   png_image_read_control *display = png_voidcast(png_image_read_control*,\n      argument);\n   png_imagep image = display->image;\n   png_structrp png_ptr = image->opaque->png_ptr;\n   int passes;\n\n   /* Called when the libpng data must be transformed into the color-mapped\n    * form.  There is a local row buffer in display->local and this routine must\n    * do the interlace handling.\n    */\n   switch (png_ptr->interlaced)\n   {\n      case PNG_INTERLACE_NONE:\n         passes = 1;\n         break;\n\n      case PNG_INTERLACE_ADAM7:\n         passes = PNG_INTERLACE_ADAM7_PASSES;\n         break;\n\n      default:\n         png_error(png_ptr, \"unknown interlace type\");\n   }\n\n   {\n      png_uint_32  height = image->height;\n      png_uint_32  width = image->width;\n      int          proc = display->colormap_processing;\n      png_bytep    first_row = png_voidcast(png_bytep, display->first_row);\n      ptrdiff_t    step_row = display->row_bytes;\n      int pass;\n\n      for (pass = 0; pass < passes; ++pass)\n      {\n         unsigned int     startx, stepx, stepy;\n         png_uint_32      y;\n\n         if (png_ptr->interlaced == PNG_INTERLACE_ADAM7)\n         {\n            /* The row may be empty for a short image: */\n            if (PNG_PASS_COLS(width, pass) == 0)\n               continue;\n\n            startx = PNG_PASS_START_COL(pass);\n            stepx = PNG_PASS_COL_OFFSET(pass);\n            y = PNG_PASS_START_ROW(pass);\n            stepy = PNG_PASS_ROW_OFFSET(pass);\n         }\n\n         else\n         {\n            y = 0;\n            startx = 0;\n            stepx = stepy = 1;\n         }\n\n         for (; y<height; y += stepy)\n         {\n            png_bytep inrow = png_voidcast(png_bytep, display->local_row);\n            png_bytep outrow = first_row + y * step_row;\n            png_const_bytep end_row = outrow + width;\n\n            /* Read read the libpng data into the temporary buffer. */\n            png_read_row(png_ptr, inrow, NULL);\n\n            /* Now process the row according to the processing option, note\n             * that the caller verifies that the format of the libpng output\n             * data is as required.\n             */\n            outrow += startx;\n            switch (proc)\n            {\n               case PNG_CMAP_GA:\n                  for (; outrow < end_row; outrow += stepx)\n                  {\n                     /* The data is always in the PNG order */\n                     unsigned int gray = *inrow++;\n                     unsigned int alpha = *inrow++;\n                     unsigned int entry;\n\n                     /* NOTE: this code is copied as a comment in\n                      * make_ga_colormap above.  Please update the\n                      * comment if you change this code!\n                      */\n                     if (alpha > 229) /* opaque */\n                     {\n                        entry = (231 * gray + 128) >> 8;\n                     }\n                     else if (alpha < 26) /* transparent */\n                     {\n                        entry = 231;\n                     }\n                     else /* partially opaque */\n                     {\n                        entry = 226 + 6 * PNG_DIV51(alpha) + PNG_DIV51(gray);\n                     }\n\n                     *outrow = (png_byte)entry;\n                  }\n                  break;\n\n               case PNG_CMAP_TRANS:\n                  for (; outrow < end_row; outrow += stepx)\n                  {\n                     png_byte gray = *inrow++;\n                     png_byte alpha = *inrow++;\n\n                     if (alpha == 0)\n                        *outrow = PNG_CMAP_TRANS_BACKGROUND;\n\n                     else if (gray != PNG_CMAP_TRANS_BACKGROUND)\n                        *outrow = gray;\n\n                     else\n                        *outrow = (png_byte)(PNG_CMAP_TRANS_BACKGROUND+1);\n                  }\n                  break;\n\n               case PNG_CMAP_RGB:\n                  for (; outrow < end_row; outrow += stepx)\n                  {\n                     *outrow = PNG_RGB_INDEX(inrow[0], inrow[1], inrow[2]);\n                     inrow += 3;\n                  }\n                  break;\n\n               case PNG_CMAP_RGB_ALPHA:\n                  for (; outrow < end_row; outrow += stepx)\n                  {\n                     unsigned int alpha = inrow[3];\n\n                     /* Because the alpha entries only hold alpha==0.5 values\n                      * split the processing at alpha==0.25 (64) and 0.75\n                      * (196).\n                      */\n\n                     if (alpha >= 196)\n                        *outrow = PNG_RGB_INDEX(inrow[0], inrow[1],\n                           inrow[2]);\n\n                     else if (alpha < 64)\n                        *outrow = PNG_CMAP_RGB_ALPHA_BACKGROUND;\n\n                     else\n                     {\n                        /* Likewise there are three entries for each of r, g\n                         * and b.  We could select the entry by popcount on\n                         * the top two bits on those architectures that\n                         * support it, this is what the code below does,\n                         * crudely.\n                         */\n                        unsigned int back_i = PNG_CMAP_RGB_ALPHA_BACKGROUND+1;\n\n                        /* Here are how the values map:\n                         *\n                         * 0x00 .. 0x3f -> 0\n                         * 0x40 .. 0xbf -> 1\n                         * 0xc0 .. 0xff -> 2\n                         *\n                         * So, as above with the explicit alpha checks, the\n                         * breakpoints are at 64 and 196.\n                         */\n                        if (inrow[0] & 0x80) back_i += 9; /* red */\n                        if (inrow[0] & 0x40) back_i += 9;\n                        if (inrow[0] & 0x80) back_i += 3; /* green */\n                        if (inrow[0] & 0x40) back_i += 3;\n                        if (inrow[0] & 0x80) back_i += 1; /* blue */\n                        if (inrow[0] & 0x40) back_i += 1;\n\n                        *outrow = (png_byte)back_i;\n                     }\n\n                     inrow += 4;\n                  }\n                  break;\n\n               default:\n                  break;\n            }\n         }\n      }\n   }\n\n   return 1;\n}\n\nstatic int\npng_image_read_colormapped(png_voidp argument)\n{\n   png_image_read_control *display = png_voidcast(png_image_read_control*,\n      argument);\n   png_imagep image = display->image;\n   png_controlp control = image->opaque;\n   png_structrp png_ptr = control->png_ptr;\n   png_inforp info_ptr = control->info_ptr;\n\n   int passes = 0; /* As a flag */\n\n   PNG_SKIP_CHUNKS(png_ptr);\n\n   /* Update the 'info' structure and make sure the result is as required; first\n    * make sure to turn on the interlace handling if it will be required\n    * (because it can't be turned on *after* the call to png_read_update_info!)\n    */\n   if (display->colormap_processing == PNG_CMAP_NONE)\n      passes = png_set_interlace_handling(png_ptr);\n\n   png_read_update_info(png_ptr, info_ptr);\n\n   /* The expected output can be deduced from the colormap_processing option. */\n   switch (display->colormap_processing)\n   {\n      case PNG_CMAP_NONE:\n         /* Output must be one channel and one byte per pixel, the output\n          * encoding can be anything.\n          */\n         if ((info_ptr->color_type == PNG_COLOR_TYPE_PALETTE ||\n            info_ptr->color_type == PNG_COLOR_TYPE_GRAY) &&\n            info_ptr->bit_depth == 8)\n            break;\n\n         goto bad_output;\n\n      case PNG_CMAP_TRANS:\n      case PNG_CMAP_GA:\n         /* Output must be two channels and the 'G' one must be sRGB, the latter\n          * can be checked with an exact number because it should have been set\n          * to this number above!\n          */\n         if (info_ptr->color_type == PNG_COLOR_TYPE_GRAY_ALPHA &&\n            info_ptr->bit_depth == 8 &&\n            png_ptr->screen_gamma == PNG_GAMMA_sRGB &&\n            image->colormap_entries == 256)\n            break;\n\n         goto bad_output;\n\n      case PNG_CMAP_RGB:\n         /* Output must be 8-bit sRGB encoded RGB */\n         if (info_ptr->color_type == PNG_COLOR_TYPE_RGB &&\n            info_ptr->bit_depth == 8 &&\n            png_ptr->screen_gamma == PNG_GAMMA_sRGB &&\n            image->colormap_entries == 216)\n            break;\n\n         goto bad_output;\n\n      case PNG_CMAP_RGB_ALPHA:\n         /* Output must be 8-bit sRGB encoded RGBA */\n         if (info_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA &&\n            info_ptr->bit_depth == 8 &&\n            png_ptr->screen_gamma == PNG_GAMMA_sRGB &&\n            image->colormap_entries == 244 /* 216 + 1 + 27 */)\n            break;\n\n         /* goto bad_output; */\n         /* FALL THROUGH */\n\n      default:\n      bad_output:\n         png_error(png_ptr, \"bad color-map processing (internal error)\");\n   }\n\n   /* Now read the rows.  Do this here if it is possible to read directly into\n    * the output buffer, otherwise allocate a local row buffer of the maximum\n    * size libpng requires and call the relevant processing routine safely.\n    */\n   {\n      png_voidp first_row = display->buffer;\n      ptrdiff_t row_bytes = display->row_stride;\n\n      /* The following expression is designed to work correctly whether it gives\n       * a signed or an unsigned result.\n       */\n      if (row_bytes < 0)\n      {\n         char *ptr = png_voidcast(char*, first_row);\n         ptr += (image->height-1) * (-row_bytes);\n         first_row = png_voidcast(png_voidp, ptr);\n      }\n\n      display->first_row = first_row;\n      display->row_bytes = row_bytes;\n   }\n\n   if (passes == 0)\n   {\n      int result;\n      png_voidp row = png_malloc(png_ptr, png_get_rowbytes(png_ptr, info_ptr));\n\n      display->local_row = row;\n      result = png_safe_execute(image, png_image_read_and_map, display);\n      display->local_row = NULL;\n      png_free(png_ptr, row);\n\n      return result;\n   }\n\n   else\n   {\n      png_alloc_size_t row_bytes = display->row_bytes;\n\n      while (--passes >= 0)\n      {\n         png_uint_32      y = image->height;\n         png_bytep        row = png_voidcast(png_bytep, display->first_row);\n\n         while (y-- > 0)\n         {\n            png_read_row(png_ptr, row, NULL);\n            row += row_bytes;\n         }\n      }\n\n      return 1;\n   }\n}\n\n/* Just the row reading part of png_image_read. */\nstatic int\npng_image_read_composite(png_voidp argument)\n{\n   png_image_read_control *display = png_voidcast(png_image_read_control*,\n      argument);\n   png_imagep image = display->image;\n   png_structrp png_ptr = image->opaque->png_ptr;\n   int passes;\n\n   switch (png_ptr->interlaced)\n   {\n      case PNG_INTERLACE_NONE:\n         passes = 1;\n         break;\n\n      case PNG_INTERLACE_ADAM7:\n         passes = PNG_INTERLACE_ADAM7_PASSES;\n         break;\n\n      default:\n         png_error(png_ptr, \"unknown interlace type\");\n   }\n\n   {\n      png_uint_32  height = image->height;\n      png_uint_32  width = image->width;\n      ptrdiff_t    step_row = display->row_bytes;\n      unsigned int channels = (image->format & PNG_FORMAT_FLAG_COLOR) ? 3 : 1;\n      int pass;\n\n      for (pass = 0; pass < passes; ++pass)\n      {\n         unsigned int     startx, stepx, stepy;\n         png_uint_32      y;\n\n         if (png_ptr->interlaced == PNG_INTERLACE_ADAM7)\n         {\n            /* The row may be empty for a short image: */\n            if (PNG_PASS_COLS(width, pass) == 0)\n               continue;\n\n            startx = PNG_PASS_START_COL(pass) * channels;\n            stepx = PNG_PASS_COL_OFFSET(pass) * channels;\n            y = PNG_PASS_START_ROW(pass);\n            stepy = PNG_PASS_ROW_OFFSET(pass);\n         }\n\n         else\n         {\n            y = 0;\n            startx = 0;\n            stepx = channels;\n            stepy = 1;\n         }\n\n         for (; y<height; y += stepy)\n         {\n            png_bytep inrow = png_voidcast(png_bytep, display->local_row);\n            png_bytep outrow;\n            png_const_bytep end_row;\n\n            /* Read the row, which is packed: */\n            png_read_row(png_ptr, inrow, NULL);\n\n            outrow = png_voidcast(png_bytep, display->first_row);\n            outrow += y * step_row;\n            end_row = outrow + width * channels;\n\n            /* Now do the composition on each pixel in this row. */\n            outrow += startx;\n            for (; outrow < end_row; outrow += stepx)\n            {\n               png_byte alpha = inrow[channels];\n\n               if (alpha > 0) /* else no change to the output */\n               {\n                  unsigned int c;\n\n                  for (c=0; c<channels; ++c)\n                  {\n                     png_uint_32 component = inrow[c];\n\n                     if (alpha < 255) /* else just use component */\n                     {\n                        /* This is PNG_OPTIMIZED_ALPHA, the component value\n                         * is a linear 8-bit value.  Combine this with the\n                         * current outrow[c] value which is sRGB encoded.\n                         * Arithmetic here is 16-bits to preserve the output\n                         * values correctly.\n                         */\n                        component *= 257*255; /* =65535 */\n                        component += (255-alpha)*png_sRGB_table[outrow[c]];\n\n                        /* So 'component' is scaled by 255*65535 and is\n                         * therefore appropriate for the sRGB to linear\n                         * conversion table.\n                         */\n                        component = PNG_sRGB_FROM_LINEAR(component);\n                     }\n\n                     outrow[c] = (png_byte)component;\n                  }\n               }\n\n               inrow += channels+1; /* components and alpha channel */\n            }\n         }\n      }\n   }\n\n   return 1;\n}\n\n/* The do_local_background case; called when all the following transforms are to\n * be done:\n *\n * PNG_RGB_TO_GRAY\n * PNG_COMPOSITE\n * PNG_GAMMA\n *\n * This is a work-round for the fact that both the PNG_RGB_TO_GRAY and\n * PNG_COMPOSITE code performs gamma correction, so we get double gamma\n * correction.  The fix-up is to prevent the PNG_COMPOSITE operation happening\n * inside libpng, so this routine sees an 8 or 16-bit gray+alpha row and handles\n * the removal or pre-multiplication of the alpha channel.\n */\nstatic int\npng_image_read_background(png_voidp argument)\n{\n   png_image_read_control *display = png_voidcast(png_image_read_control*,\n      argument);\n   png_imagep image = display->image;\n   png_structrp png_ptr = image->opaque->png_ptr;\n   png_inforp info_ptr = image->opaque->info_ptr;\n   png_uint_32 height = image->height;\n   png_uint_32 width = image->width;\n   int pass, passes;\n\n   /* Double check the convoluted logic below.  We expect to get here with\n    * libpng doing rgb to gray and gamma correction but background processing\n    * left to the png_image_read_background function.  The rows libpng produce\n    * might be 8 or 16-bit but should always have two channels; gray plus alpha.\n    */\n   if ((png_ptr->transformations & PNG_RGB_TO_GRAY) == 0)\n      png_error(png_ptr, \"lost rgb to gray\");\n\n   if ((png_ptr->transformations & PNG_COMPOSE) != 0)\n      png_error(png_ptr, \"unexpected compose\");\n\n   if (png_get_channels(png_ptr, info_ptr) != 2)\n      png_error(png_ptr, \"lost/gained channels\");\n\n   /* Expect the 8-bit case to always remove the alpha channel */\n   if ((image->format & PNG_FORMAT_FLAG_LINEAR) == 0 &&\n      (image->format & PNG_FORMAT_FLAG_ALPHA) != 0)\n      png_error(png_ptr, \"unexpected 8-bit transformation\");\n\n   switch (png_ptr->interlaced)\n   {\n      case PNG_INTERLACE_NONE:\n         passes = 1;\n         break;\n\n      case PNG_INTERLACE_ADAM7:\n         passes = PNG_INTERLACE_ADAM7_PASSES;\n         break;\n\n      default:\n         png_error(png_ptr, \"unknown interlace type\");\n   }\n\n   /* Use direct access to info_ptr here because otherwise the simplified API\n    * would require PNG_EASY_ACCESS_SUPPORTED (just for this.)  Note this is\n    * checking the value after libpng expansions, not the original value in the\n    * PNG.\n    */\n   switch (info_ptr->bit_depth)\n   {\n      default:\n         png_error(png_ptr, \"unexpected bit depth\");\n         break;\n\n      case 8:\n         /* 8-bit sRGB gray values with an alpha channel; the alpha channel is\n          * to be removed by composing on a background: either the row if\n          * display->background is NULL or display->background->green if not.\n          * Unlike the code above ALPHA_OPTIMIZED has *not* been done.\n          */\n         {\n            png_bytep first_row = png_voidcast(png_bytep, display->first_row);\n            ptrdiff_t step_row = display->row_bytes;\n\n            for (pass = 0; pass < passes; ++pass)\n            {\n               png_bytep        row = png_voidcast(png_bytep,\n                                                   display->first_row);\n               unsigned int     startx, stepx, stepy;\n               png_uint_32      y;\n\n               if (png_ptr->interlaced == PNG_INTERLACE_ADAM7)\n               {\n                  /* The row may be empty for a short image: */\n                  if (PNG_PASS_COLS(width, pass) == 0)\n                     continue;\n\n                  startx = PNG_PASS_START_COL(pass);\n                  stepx = PNG_PASS_COL_OFFSET(pass);\n                  y = PNG_PASS_START_ROW(pass);\n                  stepy = PNG_PASS_ROW_OFFSET(pass);\n               }\n\n               else\n               {\n                  y = 0;\n                  startx = 0;\n                  stepx = stepy = 1;\n               }\n\n               if (display->background == NULL)\n               {\n                  for (; y<height; y += stepy)\n                  {\n                     png_bytep inrow = png_voidcast(png_bytep,\n                        display->local_row);\n                     png_bytep outrow = first_row + y * step_row;\n                     png_const_bytep end_row = outrow + width;\n\n                     /* Read the row, which is packed: */\n                     png_read_row(png_ptr, inrow, NULL);\n\n                     /* Now do the composition on each pixel in this row. */\n                     outrow += startx;\n                     for (; outrow < end_row; outrow += stepx)\n                     {\n                        png_byte alpha = inrow[1];\n\n                        if (alpha > 0) /* else no change to the output */\n                        {\n                           png_uint_32 component = inrow[0];\n\n                           if (alpha < 255) /* else just use component */\n                           {\n                              /* Since PNG_OPTIMIZED_ALPHA was not set it is\n                               * necessary to invert the sRGB transfer\n                               * function and multiply the alpha out.\n                               */\n                              component = png_sRGB_table[component] * alpha;\n                              component += png_sRGB_table[outrow[0]] *\n                                 (255-alpha);\n                              component = PNG_sRGB_FROM_LINEAR(component);\n                           }\n\n                           outrow[0] = (png_byte)component;\n                        }\n\n                        inrow += 2; /* gray and alpha channel */\n                     }\n                  }\n               }\n\n               else /* constant background value */\n               {\n                  png_byte background8 = display->background->green;\n                  png_uint_16 background = png_sRGB_table[background8];\n\n                  for (; y<height; y += stepy)\n                  {\n                     png_bytep inrow = png_voidcast(png_bytep,\n                        display->local_row);\n                     png_bytep outrow = first_row + y * step_row;\n                     png_const_bytep end_row = outrow + width;\n\n                     /* Read the row, which is packed: */\n                     png_read_row(png_ptr, inrow, NULL);\n\n                     /* Now do the composition on each pixel in this row. */\n                     outrow += startx;\n                     for (; outrow < end_row; outrow += stepx)\n                     {\n                        png_byte alpha = inrow[1];\n\n                        if (alpha > 0) /* else use background */\n                        {\n                           png_uint_32 component = inrow[0];\n\n                           if (alpha < 255) /* else just use component */\n                           {\n                              component = png_sRGB_table[component] * alpha;\n                              component += background * (255-alpha);\n                              component = PNG_sRGB_FROM_LINEAR(component);\n                           }\n\n                           outrow[0] = (png_byte)component;\n                        }\n\n                        else\n                           outrow[0] = background8;\n\n                        inrow += 2; /* gray and alpha channel */\n                     }\n\n                     row += display->row_bytes;\n                  }\n               }\n            }\n         }\n         break;\n\n      case 16:\n         /* 16-bit linear with pre-multiplied alpha; the pre-multiplication must\n          * still be done and, maybe, the alpha channel removed.  This code also\n          * handles the alpha-first option.\n          */\n         {\n            png_uint_16p first_row = png_voidcast(png_uint_16p,\n               display->first_row);\n            /* The division by two is safe because the caller passed in a\n             * stride which was multiplied by 2 (below) to get row_bytes.\n             */\n            ptrdiff_t    step_row = display->row_bytes / 2;\n            int preserve_alpha = (image->format & PNG_FORMAT_FLAG_ALPHA) != 0;\n            unsigned int outchannels = 1+preserve_alpha;\n            int swap_alpha = 0;\n\n#           ifdef PNG_SIMPLIFIED_READ_AFIRST_SUPPORTED\n               if (preserve_alpha && (image->format & PNG_FORMAT_FLAG_AFIRST))\n                  swap_alpha = 1;\n#           endif\n\n            for (pass = 0; pass < passes; ++pass)\n            {\n               unsigned int     startx, stepx, stepy;\n               png_uint_32      y;\n\n               /* The 'x' start and step are adjusted to output components here.\n                */\n               if (png_ptr->interlaced == PNG_INTERLACE_ADAM7)\n               {\n                  /* The row may be empty for a short image: */\n                  if (PNG_PASS_COLS(width, pass) == 0)\n                     continue;\n\n                  startx = PNG_PASS_START_COL(pass) * outchannels;\n                  stepx = PNG_PASS_COL_OFFSET(pass) * outchannels;\n                  y = PNG_PASS_START_ROW(pass);\n                  stepy = PNG_PASS_ROW_OFFSET(pass);\n               }\n\n               else\n               {\n                  y = 0;\n                  startx = 0;\n                  stepx = outchannels;\n                  stepy = 1;\n               }\n\n               for (; y<height; y += stepy)\n               {\n                  png_const_uint_16p inrow;\n                  png_uint_16p outrow = first_row + y*step_row;\n                  png_uint_16p end_row = outrow + width * outchannels;\n\n                  /* Read the row, which is packed: */\n                  png_read_row(png_ptr, png_voidcast(png_bytep,\n                     display->local_row), NULL);\n                  inrow = png_voidcast(png_const_uint_16p, display->local_row);\n\n                  /* Now do the pre-multiplication on each pixel in this row.\n                   */\n                  outrow += startx;\n                  for (; outrow < end_row; outrow += stepx)\n                  {\n                     png_uint_32 component = inrow[0];\n                     png_uint_16 alpha = inrow[1];\n\n                     if (alpha > 0) /* else 0 */\n                     {\n                        if (alpha < 65535) /* else just use component */\n                        {\n                           component *= alpha;\n                           component += 32767;\n                           component /= 65535;\n                        }\n                     }\n\n                     else\n                        component = 0;\n\n                     outrow[swap_alpha] = (png_uint_16)component;\n                     if (preserve_alpha)\n                        outrow[1 ^ swap_alpha] = alpha;\n\n                     inrow += 2; /* components and alpha channel */\n                  }\n               }\n            }\n         }\n         break;\n   }\n\n   return 1;\n}\n\n/* The guts of png_image_finish_read as a png_safe_execute callback. */\nstatic int\npng_image_read_direct(png_voidp argument)\n{\n   png_image_read_control *display = png_voidcast(png_image_read_control*,\n      argument);\n   png_imagep image = display->image;\n   png_structrp png_ptr = image->opaque->png_ptr;\n   png_inforp info_ptr = image->opaque->info_ptr;\n\n   png_uint_32 format = image->format;\n   int linear = (format & PNG_FORMAT_FLAG_LINEAR) != 0;\n   int do_local_compose = 0;\n   int do_local_background = 0; /* to avoid double gamma correction bug */\n   int passes = 0;\n\n   /* Add transforms to ensure the correct output format is produced then check\n    * that the required implementation support is there.  Always expand; always\n    * need 8 bits minimum, no palette and expanded tRNS.\n    */\n   png_set_expand(png_ptr);\n\n   /* Now check the format to see if it was modified. */\n   {\n      png_uint_32 base_format = png_image_format(png_ptr) &\n         ~PNG_FORMAT_FLAG_COLORMAP /* removed by png_set_expand */;\n      png_uint_32 change = format ^ base_format;\n      png_fixed_point output_gamma;\n      int mode; /* alpha mode */\n\n      /* Do this first so that we have a record if rgb to gray is happening. */\n      if (change & PNG_FORMAT_FLAG_COLOR)\n      {\n         /* gray<->color transformation required. */\n         if (format & PNG_FORMAT_FLAG_COLOR)\n            png_set_gray_to_rgb(png_ptr);\n\n         else\n         {\n            /* libpng can't do both rgb to gray and\n             * background/pre-multiplication if there is also significant gamma\n             * correction, because both operations require linear colors and\n             * the code only supports one transform doing the gamma correction.\n             * Handle this by doing the pre-multiplication or background\n             * operation in this code, if necessary.\n             *\n             * TODO: fix this by rewriting pngrtran.c (!)\n             *\n             * For the moment (given that fixing this in pngrtran.c is an\n             * enormous change) 'do_local_background' is used to indicate that\n             * the problem exists.\n             */\n            if (base_format & PNG_FORMAT_FLAG_ALPHA)\n               do_local_background = 1/*maybe*/;\n\n            png_set_rgb_to_gray_fixed(png_ptr, PNG_ERROR_ACTION_NONE,\n               PNG_RGB_TO_GRAY_DEFAULT, PNG_RGB_TO_GRAY_DEFAULT);\n         }\n\n         change &= ~PNG_FORMAT_FLAG_COLOR;\n      }\n\n      /* Set the gamma appropriately, linear for 16-bit input, sRGB otherwise.\n       */\n      {\n         png_fixed_point input_gamma_default;\n\n         if ((base_format & PNG_FORMAT_FLAG_LINEAR) &&\n            (image->flags & PNG_IMAGE_FLAG_16BIT_sRGB) == 0)\n            input_gamma_default = PNG_GAMMA_LINEAR;\n         else\n            input_gamma_default = PNG_DEFAULT_sRGB;\n\n         /* Call png_set_alpha_mode to set the default for the input gamma; the\n          * output gamma is set by a second call below.\n          */\n         png_set_alpha_mode_fixed(png_ptr, PNG_ALPHA_PNG, input_gamma_default);\n      }\n\n      if (linear)\n      {\n         /* If there *is* an alpha channel in the input it must be multiplied\n          * out; use PNG_ALPHA_STANDARD, otherwise just use PNG_ALPHA_PNG.\n          */\n         if (base_format & PNG_FORMAT_FLAG_ALPHA)\n            mode = PNG_ALPHA_STANDARD; /* associated alpha */\n\n         else\n            mode = PNG_ALPHA_PNG;\n\n         output_gamma = PNG_GAMMA_LINEAR;\n      }\n\n      else\n      {\n         mode = PNG_ALPHA_PNG;\n         output_gamma = PNG_DEFAULT_sRGB;\n      }\n\n      /* If 'do_local_background' is set check for the presence of gamma\n       * correction; this is part of the work-round for the libpng bug\n       * described above.\n       *\n       * TODO: fix libpng and remove this.\n       */\n      if (do_local_background)\n      {\n         png_fixed_point gtest;\n\n         /* This is 'png_gamma_threshold' from pngrtran.c; the test used for\n          * gamma correction, the screen gamma hasn't been set on png_struct\n          * yet; it's set below.  png_struct::gamma, however, is set to the\n          * final value.\n          */\n         if (png_muldiv(&gtest, output_gamma, png_ptr->colorspace.gamma,\n               PNG_FP_1) && !png_gamma_significant(gtest))\n            do_local_background = 0;\n\n         else if (mode == PNG_ALPHA_STANDARD)\n         {\n            do_local_background = 2/*required*/;\n            mode = PNG_ALPHA_PNG; /* prevent libpng doing it */\n         }\n\n         /* else leave as 1 for the checks below */\n      }\n\n      /* If the bit-depth changes then handle that here. */\n      if (change & PNG_FORMAT_FLAG_LINEAR)\n      {\n         if (linear /*16-bit output*/)\n            png_set_expand_16(png_ptr);\n\n         else /* 8-bit output */\n            png_set_scale_16(png_ptr);\n\n         change &= ~PNG_FORMAT_FLAG_LINEAR;\n      }\n\n      /* Now the background/alpha channel changes. */\n      if (change & PNG_FORMAT_FLAG_ALPHA)\n      {\n         /* Removing an alpha channel requires composition for the 8-bit\n          * formats; for the 16-bit it is already done, above, by the\n          * pre-multiplication and the channel just needs to be stripped.\n          */\n         if (base_format & PNG_FORMAT_FLAG_ALPHA)\n         {\n            /* If RGB->gray is happening the alpha channel must be left and the\n             * operation completed locally.\n             *\n             * TODO: fix libpng and remove this.\n             */\n            if (do_local_background)\n               do_local_background = 2/*required*/;\n\n            /* 16-bit output: just remove the channel */\n            else if (linear) /* compose on black (well, pre-multiply) */\n               png_set_strip_alpha(png_ptr);\n\n            /* 8-bit output: do an appropriate compose */\n            else if (display->background != NULL)\n            {\n               png_color_16 c;\n\n               c.index = 0; /*unused*/\n               c.red = display->background->red;\n               c.green = display->background->green;\n               c.blue = display->background->blue;\n               c.gray = display->background->green;\n\n               /* This is always an 8-bit sRGB value, using the 'green' channel\n                * for gray is much better than calculating the luminance here;\n                * we can get off-by-one errors in that calculation relative to\n                * the app expectations and that will show up in transparent\n                * pixels.\n                */\n               png_set_background_fixed(png_ptr, &c,\n                  PNG_BACKGROUND_GAMMA_SCREEN, 0/*need_expand*/,\n                  0/*gamma: not used*/);\n            }\n\n            else /* compose on row: implemented below. */\n            {\n               do_local_compose = 1;\n               /* This leaves the alpha channel in the output, so it has to be\n                * removed by the code below.  Set the encoding to the 'OPTIMIZE'\n                * one so the code only has to hack on the pixels that require\n                * composition.\n                */\n               mode = PNG_ALPHA_OPTIMIZED;\n            }\n         }\n\n         else /* output needs an alpha channel */\n         {\n            /* This is tricky because it happens before the swap operation has\n             * been accomplished; however, the swap does *not* swap the added\n             * alpha channel (weird API), so it must be added in the correct\n             * place.\n             */\n            png_uint_32 filler; /* opaque filler */\n            int where;\n\n            if (linear)\n               filler = 65535;\n\n            else\n               filler = 255;\n\n#           ifdef PNG_FORMAT_AFIRST_SUPPORTED\n               if (format & PNG_FORMAT_FLAG_AFIRST)\n               {\n                  where = PNG_FILLER_BEFORE;\n                  change &= ~PNG_FORMAT_FLAG_AFIRST;\n               }\n\n               else\n#           endif\n               where = PNG_FILLER_AFTER;\n\n            png_set_add_alpha(png_ptr, filler, where);\n         }\n\n         /* This stops the (irrelevant) call to swap_alpha below. */\n         change &= ~PNG_FORMAT_FLAG_ALPHA;\n      }\n\n      /* Now set the alpha mode correctly; this is always done, even if there is\n       * no alpha channel in either the input or the output because it correctly\n       * sets the output gamma.\n       */\n      png_set_alpha_mode_fixed(png_ptr, mode, output_gamma);\n\n#     ifdef PNG_FORMAT_BGR_SUPPORTED\n         if (change & PNG_FORMAT_FLAG_BGR)\n         {\n            /* Check only the output format; PNG is never BGR; don't do this if\n             * the output is gray, but fix up the 'format' value in that case.\n             */\n            if (format & PNG_FORMAT_FLAG_COLOR)\n               png_set_bgr(png_ptr);\n\n            else\n               format &= ~PNG_FORMAT_FLAG_BGR;\n\n            change &= ~PNG_FORMAT_FLAG_BGR;\n         }\n#     endif\n\n#     ifdef PNG_FORMAT_AFIRST_SUPPORTED\n         if (change & PNG_FORMAT_FLAG_AFIRST)\n         {\n            /* Only relevant if there is an alpha channel - it's particularly\n             * important to handle this correctly because do_local_compose may\n             * be set above and then libpng will keep the alpha channel for this\n             * code to remove.\n             */\n            if (format & PNG_FORMAT_FLAG_ALPHA)\n            {\n               /* Disable this if doing a local background,\n                * TODO: remove this when local background is no longer required.\n                */\n               if (do_local_background != 2)\n                  png_set_swap_alpha(png_ptr);\n            }\n\n            else\n               format &= ~PNG_FORMAT_FLAG_AFIRST;\n\n            change &= ~PNG_FORMAT_FLAG_AFIRST;\n         }\n#     endif\n\n      /* If the *output* is 16-bit then we need to check for a byte-swap on this\n       * architecture.\n       */\n      if (linear)\n      {\n         PNG_CONST png_uint_16 le = 0x0001;\n\n         if (*(png_const_bytep)&le)\n            png_set_swap(png_ptr);\n      }\n\n      /* If change is not now 0 some transformation is missing - error out. */\n      if (change)\n         png_error(png_ptr, \"png_read_image: unsupported transformation\");\n   }\n\n   PNG_SKIP_CHUNKS(png_ptr);\n\n   /* Update the 'info' structure and make sure the result is as required; first\n    * make sure to turn on the interlace handling if it will be required\n    * (because it can't be turned on *after* the call to png_read_update_info!)\n    *\n    * TODO: remove the do_local_background fixup below.\n    */\n   if (!do_local_compose && do_local_background != 2)\n      passes = png_set_interlace_handling(png_ptr);\n\n   png_read_update_info(png_ptr, info_ptr);\n\n   {\n      png_uint_32 info_format = 0;\n\n      if (info_ptr->color_type & PNG_COLOR_MASK_COLOR)\n         info_format |= PNG_FORMAT_FLAG_COLOR;\n\n      if (info_ptr->color_type & PNG_COLOR_MASK_ALPHA)\n      {\n         /* do_local_compose removes this channel below. */\n         if (!do_local_compose)\n         {\n            /* do_local_background does the same if required. */\n            if (do_local_background != 2 ||\n               (format & PNG_FORMAT_FLAG_ALPHA) != 0)\n               info_format |= PNG_FORMAT_FLAG_ALPHA;\n         }\n      }\n\n      else if (do_local_compose) /* internal error */\n         png_error(png_ptr, \"png_image_read: alpha channel lost\");\n\n      if (info_ptr->bit_depth == 16)\n         info_format |= PNG_FORMAT_FLAG_LINEAR;\n\n#     ifdef PNG_FORMAT_BGR_SUPPORTED\n         if (png_ptr->transformations & PNG_BGR)\n            info_format |= PNG_FORMAT_FLAG_BGR;\n#     endif\n\n#     ifdef PNG_FORMAT_AFIRST_SUPPORTED\n         if (do_local_background == 2)\n         {\n            if (format & PNG_FORMAT_FLAG_AFIRST)\n               info_format |= PNG_FORMAT_FLAG_AFIRST;\n         }\n\n         if ((png_ptr->transformations & PNG_SWAP_ALPHA) != 0 ||\n            ((png_ptr->transformations & PNG_ADD_ALPHA) != 0 &&\n            (png_ptr->flags & PNG_FLAG_FILLER_AFTER) == 0))\n         {\n            if (do_local_background == 2)\n               png_error(png_ptr, \"unexpected alpha swap transformation\");\n\n            info_format |= PNG_FORMAT_FLAG_AFIRST;\n         }\n#     endif\n\n      /* This is actually an internal error. */\n      if (info_format != format)\n         png_error(png_ptr, \"png_read_image: invalid transformations\");\n   }\n\n   /* Now read the rows.  If do_local_compose is set then it is necessary to use\n    * a local row buffer.  The output will be GA, RGBA or BGRA and must be\n    * converted to G, RGB or BGR as appropriate.  The 'local_row' member of the\n    * display acts as a flag.\n    */\n   {\n      png_voidp first_row = display->buffer;\n      ptrdiff_t row_bytes = display->row_stride;\n\n      if (linear)\n         row_bytes *= 2;\n\n      /* The following expression is designed to work correctly whether it gives\n       * a signed or an unsigned result.\n       */\n      if (row_bytes < 0)\n      {\n         char *ptr = png_voidcast(char*, first_row);\n         ptr += (image->height-1) * (-row_bytes);\n         first_row = png_voidcast(png_voidp, ptr);\n      }\n\n      display->first_row = first_row;\n      display->row_bytes = row_bytes;\n   }\n\n   if (do_local_compose)\n   {\n      int result;\n      png_voidp row = png_malloc(png_ptr, png_get_rowbytes(png_ptr, info_ptr));\n\n      display->local_row = row;\n      result = png_safe_execute(image, png_image_read_composite, display);\n      display->local_row = NULL;\n      png_free(png_ptr, row);\n\n      return result;\n   }\n\n   else if (do_local_background == 2)\n   {\n      int result;\n      png_voidp row = png_malloc(png_ptr, png_get_rowbytes(png_ptr, info_ptr));\n\n      display->local_row = row;\n      result = png_safe_execute(image, png_image_read_background, display);\n      display->local_row = NULL;\n      png_free(png_ptr, row);\n\n      return result;\n   }\n\n   else\n   {\n      png_alloc_size_t row_bytes = display->row_bytes;\n\n      while (--passes >= 0)\n      {\n         png_uint_32      y = image->height;\n         png_bytep        row = png_voidcast(png_bytep, display->first_row);\n\n         while (y-- > 0)\n         {\n            png_read_row(png_ptr, row, NULL);\n            row += row_bytes;\n         }\n      }\n\n      return 1;\n   }\n}\n\nint PNGAPI\npng_image_finish_read(png_imagep image, png_const_colorp background,\n   void *buffer, png_int_32 row_stride, void *colormap)\n{\n   if (image != NULL && image->version == PNG_IMAGE_VERSION)\n   {\n      png_uint_32 check;\n\n      if (row_stride == 0)\n         row_stride = PNG_IMAGE_ROW_STRIDE(*image);\n\n      if (row_stride < 0)\n         check = -row_stride;\n\n      else\n         check = row_stride;\n\n      if (image->opaque != NULL && buffer != NULL &&\n         check >= PNG_IMAGE_ROW_STRIDE(*image))\n      {\n         if ((image->format & PNG_FORMAT_FLAG_COLORMAP) == 0 ||\n            (image->colormap_entries > 0 && colormap != NULL))\n         {\n            int result;\n            png_image_read_control display;\n\n            memset(&display, 0, (sizeof display));\n            display.image = image;\n            display.buffer = buffer;\n            display.row_stride = row_stride;\n            display.colormap = colormap;\n            display.background = background;\n            display.local_row = NULL;\n\n            /* Choose the correct 'end' routine; for the color-map case all the\n             * setup has already been done.\n             */\n            if (image->format & PNG_FORMAT_FLAG_COLORMAP)\n               result =\n                  png_safe_execute(image, png_image_read_colormap, &display) &&\n                  png_safe_execute(image, png_image_read_colormapped, &display);\n\n            else\n               result =\n                  png_safe_execute(image, png_image_read_direct, &display);\n\n            png_image_free(image);\n            return result;\n         }\n\n         else\n            return png_image_error(image,\n               \"png_image_finish_read[color-map]: no color-map\");\n      }\n\n      else\n         return png_image_error(image,\n            \"png_image_finish_read: invalid argument\");\n   }\n\n   else if (image != NULL)\n      return png_image_error(image,\n         \"png_image_finish_read: damaged PNG_IMAGE_VERSION\");\n\n   return 0;\n}\n\n#endif /* PNG_SIMPLIFIED_READ_SUPPORTED */\n#endif /* PNG_READ_SUPPORTED */\n"
  },
  {
    "path": "Projects/Libraries/CSBase/Source/png/pngrio.c",
    "content": "\n/* pngrio.c - functions for data input\n *\n * Last changed in libpng 1.6.9 [February 6, 2014]\n * Copyright (c) 1998-2014 Glenn Randers-Pehrson\n * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)\n * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)\n *\n * This code is released under the libpng license.\n * For conditions of distribution and use, see the disclaimer\n * and license in png.h\n *\n * This file provides a location for all input.  Users who need\n * special handling are expected to write a function that has the same\n * arguments as this and performs a similar function, but that possibly\n * has a different input method.  Note that you shouldn't change this\n * function, but rather write a replacement function and then make\n * libpng use it at run time with png_set_read_fn(...).\n */\n\n#include \"pngpriv.h\"\n\n#ifdef PNG_READ_SUPPORTED\n\n/* Read the data from whatever input you are using.  The default routine\n * reads from a file pointer.  Note that this routine sometimes gets called\n * with very small lengths, so you should implement some kind of simple\n * buffering if you are using unbuffered reads.  This should never be asked\n * to read more then 64K on a 16 bit machine.\n */\nvoid /* PRIVATE */\npng_read_data(png_structrp png_ptr, png_bytep data, png_size_t length)\n{\n   png_debug1(4, \"reading %d bytes\", (int)length);\n\n   if (png_ptr->read_data_fn != NULL)\n      (*(png_ptr->read_data_fn))(png_ptr, data, length);\n\n   else\n      png_error(png_ptr, \"Call to NULL read function\");\n}\n\n#ifdef PNG_STDIO_SUPPORTED\n/* This is the function that does the actual reading of data.  If you are\n * not reading from a standard C stream, you should create a replacement\n * read_data function and use it at run time with png_set_read_fn(), rather\n * than changing the library.\n */\nvoid PNGCBAPI\npng_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)\n{\n   png_size_t check;\n\n   if (png_ptr == NULL)\n      return;\n\n   /* fread() returns 0 on error, so it is OK to store this in a png_size_t\n    * instead of an int, which is what fread() actually returns.\n    */\n   check = fread(data, 1, length, png_voidcast(png_FILE_p, png_ptr->io_ptr));\n\n   if (check != length)\n      png_error(png_ptr, \"Read Error\");\n}\n#endif\n\n/* This function allows the application to supply a new input function\n * for libpng if standard C streams aren't being used.\n *\n * This function takes as its arguments:\n *\n * png_ptr      - pointer to a png input data structure\n *\n * io_ptr       - pointer to user supplied structure containing info about\n *                the input functions.  May be NULL.\n *\n * read_data_fn - pointer to a new input function that takes as its\n *                arguments a pointer to a png_struct, a pointer to\n *                a location where input data can be stored, and a 32-bit\n *                unsigned int that is the number of bytes to be read.\n *                To exit and output any fatal error messages the new write\n *                function should call png_error(png_ptr, \"Error msg\").\n *                May be NULL, in which case libpng's default function will\n *                be used.\n */\nvoid PNGAPI\npng_set_read_fn(png_structrp png_ptr, png_voidp io_ptr,\n   png_rw_ptr read_data_fn)\n{\n   if (png_ptr == NULL)\n      return;\n\n   png_ptr->io_ptr = io_ptr;\n\n#ifdef PNG_STDIO_SUPPORTED\n   if (read_data_fn != NULL)\n      png_ptr->read_data_fn = read_data_fn;\n\n   else\n      png_ptr->read_data_fn = png_default_read_data;\n#else\n   png_ptr->read_data_fn = read_data_fn;\n#endif\n\n#ifdef PNG_WRITE_SUPPORTED\n   /* It is an error to write to a read device */\n   if (png_ptr->write_data_fn != NULL)\n   {\n      png_ptr->write_data_fn = NULL;\n      png_warning(png_ptr,\n          \"Can't set both read_data_fn and write_data_fn in the\"\n          \" same structure\");\n   }\n#endif\n\n#ifdef PNG_WRITE_FLUSH_SUPPORTED\n   png_ptr->output_flush_fn = NULL;\n#endif\n}\n#endif /* PNG_READ_SUPPORTED */\n"
  },
  {
    "path": "Projects/Libraries/CSBase/Source/png/pngrtran.c",
    "content": "\n/* pngrtran.c - transforms the data in a row for PNG readers\n *\n * Last changed in libpng 1.6.10 [March 6, 2014]\n * Copyright (c) 1998-2014 Glenn Randers-Pehrson\n * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)\n * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)\n *\n * This code is released under the libpng license.\n * For conditions of distribution and use, see the disclaimer\n * and license in png.h\n *\n * This file contains functions optionally called by an application\n * in order to tell libpng how to handle data when reading a PNG.\n * Transformations that are used in both reading and writing are\n * in pngtrans.c.\n */\n\n#include \"pngpriv.h\"\n\n#ifdef PNG_READ_SUPPORTED\n\n/* Set the action on getting a CRC error for an ancillary or critical chunk. */\nvoid PNGAPI\npng_set_crc_action(png_structrp png_ptr, int crit_action, int ancil_action)\n{\n   png_debug(1, \"in png_set_crc_action\");\n\n   if (png_ptr == NULL)\n      return;\n\n   /* Tell libpng how we react to CRC errors in critical chunks */\n   switch (crit_action)\n   {\n      case PNG_CRC_NO_CHANGE:                        /* Leave setting as is */\n         break;\n\n      case PNG_CRC_WARN_USE:                               /* Warn/use data */\n         png_ptr->flags &= ~PNG_FLAG_CRC_CRITICAL_MASK;\n         png_ptr->flags |= PNG_FLAG_CRC_CRITICAL_USE;\n         break;\n\n      case PNG_CRC_QUIET_USE:                             /* Quiet/use data */\n         png_ptr->flags &= ~PNG_FLAG_CRC_CRITICAL_MASK;\n         png_ptr->flags |= PNG_FLAG_CRC_CRITICAL_USE |\n                           PNG_FLAG_CRC_CRITICAL_IGNORE;\n         break;\n\n      case PNG_CRC_WARN_DISCARD:    /* Not a valid action for critical data */\n         png_warning(png_ptr,\n            \"Can't discard critical data on CRC error\");\n      case PNG_CRC_ERROR_QUIT:                                /* Error/quit */\n\n      case PNG_CRC_DEFAULT:\n      default:\n         png_ptr->flags &= ~PNG_FLAG_CRC_CRITICAL_MASK;\n         break;\n   }\n\n   /* Tell libpng how we react to CRC errors in ancillary chunks */\n   switch (ancil_action)\n   {\n      case PNG_CRC_NO_CHANGE:                       /* Leave setting as is */\n         break;\n\n      case PNG_CRC_WARN_USE:                              /* Warn/use data */\n         png_ptr->flags &= ~PNG_FLAG_CRC_ANCILLARY_MASK;\n         png_ptr->flags |= PNG_FLAG_CRC_ANCILLARY_USE;\n         break;\n\n      case PNG_CRC_QUIET_USE:                            /* Quiet/use data */\n         png_ptr->flags &= ~PNG_FLAG_CRC_ANCILLARY_MASK;\n         png_ptr->flags |= PNG_FLAG_CRC_ANCILLARY_USE |\n                           PNG_FLAG_CRC_ANCILLARY_NOWARN;\n         break;\n\n      case PNG_CRC_ERROR_QUIT:                               /* Error/quit */\n         png_ptr->flags &= ~PNG_FLAG_CRC_ANCILLARY_MASK;\n         png_ptr->flags |= PNG_FLAG_CRC_ANCILLARY_NOWARN;\n         break;\n\n      case PNG_CRC_WARN_DISCARD:                      /* Warn/discard data */\n\n      case PNG_CRC_DEFAULT:\n      default:\n         png_ptr->flags &= ~PNG_FLAG_CRC_ANCILLARY_MASK;\n         break;\n   }\n}\n\n#ifdef PNG_READ_TRANSFORMS_SUPPORTED\n/* Is it OK to set a transformation now?  Only if png_start_read_image or\n * png_read_update_info have not been called.  It is not necessary for the IHDR\n * to have been read in all cases, the parameter allows for this check too.\n */\nstatic int\npng_rtran_ok(png_structrp png_ptr, int need_IHDR)\n{\n   if (png_ptr != NULL)\n   {\n      if (png_ptr->flags & PNG_FLAG_ROW_INIT)\n         png_app_error(png_ptr,\n            \"invalid after png_start_read_image or png_read_update_info\");\n\n      else if (need_IHDR && (png_ptr->mode & PNG_HAVE_IHDR) == 0)\n         png_app_error(png_ptr, \"invalid before the PNG header has been read\");\n\n      else\n      {\n         /* Turn on failure to initialize correctly for all transforms. */\n         png_ptr->flags |= PNG_FLAG_DETECT_UNINITIALIZED;\n\n         return 1; /* Ok */\n      }\n   }\n\n   return 0; /* no png_error possible! */\n}\n#endif\n\n#ifdef PNG_READ_BACKGROUND_SUPPORTED\n/* Handle alpha and tRNS via a background color */\nvoid PNGFAPI\npng_set_background_fixed(png_structrp png_ptr,\n    png_const_color_16p background_color, int background_gamma_code,\n    int need_expand, png_fixed_point background_gamma)\n{\n   png_debug(1, \"in png_set_background_fixed\");\n\n   if (!png_rtran_ok(png_ptr, 0) || background_color == NULL)\n      return;\n\n   if (background_gamma_code == PNG_BACKGROUND_GAMMA_UNKNOWN)\n   {\n      png_warning(png_ptr, \"Application must supply a known background gamma\");\n      return;\n   }\n\n   png_ptr->transformations |= PNG_COMPOSE | PNG_STRIP_ALPHA;\n   png_ptr->transformations &= ~PNG_ENCODE_ALPHA;\n   png_ptr->flags &= ~PNG_FLAG_OPTIMIZE_ALPHA;\n\n   png_ptr->background = *background_color;\n   png_ptr->background_gamma = background_gamma;\n   png_ptr->background_gamma_type = (png_byte)(background_gamma_code);\n   if (need_expand)\n      png_ptr->transformations |= PNG_BACKGROUND_EXPAND;\n   else\n      png_ptr->transformations &= ~PNG_BACKGROUND_EXPAND;\n}\n\n#  ifdef PNG_FLOATING_POINT_SUPPORTED\nvoid PNGAPI\npng_set_background(png_structrp png_ptr,\n    png_const_color_16p background_color, int background_gamma_code,\n    int need_expand, double background_gamma)\n{\n   png_set_background_fixed(png_ptr, background_color, background_gamma_code,\n      need_expand, png_fixed(png_ptr, background_gamma, \"png_set_background\"));\n}\n#  endif  /* FLOATING_POINT */\n#endif /* READ_BACKGROUND */\n\n/* Scale 16-bit depth files to 8-bit depth.  If both of these are set then the\n * one that pngrtran does first (scale) happens.  This is necessary to allow the\n * TRANSFORM and API behavior to be somewhat consistent, and it's simpler.\n */\n#ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED\nvoid PNGAPI\npng_set_scale_16(png_structrp png_ptr)\n{\n   png_debug(1, \"in png_set_scale_16\");\n\n   if (!png_rtran_ok(png_ptr, 0))\n      return;\n\n   png_ptr->transformations |= PNG_SCALE_16_TO_8;\n}\n#endif\n\n#ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED\n/* Chop 16-bit depth files to 8-bit depth */\nvoid PNGAPI\npng_set_strip_16(png_structrp png_ptr)\n{\n   png_debug(1, \"in png_set_strip_16\");\n\n   if (!png_rtran_ok(png_ptr, 0))\n      return;\n\n   png_ptr->transformations |= PNG_16_TO_8;\n}\n#endif\n\n#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED\nvoid PNGAPI\npng_set_strip_alpha(png_structrp png_ptr)\n{\n   png_debug(1, \"in png_set_strip_alpha\");\n\n   if (!png_rtran_ok(png_ptr, 0))\n      return;\n\n   png_ptr->transformations |= PNG_STRIP_ALPHA;\n}\n#endif\n\n#if defined(PNG_READ_ALPHA_MODE_SUPPORTED) || defined(PNG_READ_GAMMA_SUPPORTED)\nstatic png_fixed_point\ntranslate_gamma_flags(png_structrp png_ptr, png_fixed_point output_gamma,\n   int is_screen)\n{\n   /* Check for flag values.  The main reason for having the old Mac value as a\n    * flag is that it is pretty near impossible to work out what the correct\n    * value is from Apple documentation - a working Mac system is needed to\n    * discover the value!\n    */\n   if (output_gamma == PNG_DEFAULT_sRGB ||\n      output_gamma == PNG_FP_1 / PNG_DEFAULT_sRGB)\n   {\n      /* If there is no sRGB support this just sets the gamma to the standard\n       * sRGB value.  (This is a side effect of using this function!)\n       */\n#     ifdef PNG_READ_sRGB_SUPPORTED\n         png_ptr->flags |= PNG_FLAG_ASSUME_sRGB;\n#     else\n         PNG_UNUSED(png_ptr)\n#     endif\n      if (is_screen)\n         output_gamma = PNG_GAMMA_sRGB;\n      else\n         output_gamma = PNG_GAMMA_sRGB_INVERSE;\n   }\n\n   else if (output_gamma == PNG_GAMMA_MAC_18 ||\n      output_gamma == PNG_FP_1 / PNG_GAMMA_MAC_18)\n   {\n      if (is_screen)\n         output_gamma = PNG_GAMMA_MAC_OLD;\n      else\n         output_gamma = PNG_GAMMA_MAC_INVERSE;\n   }\n\n   return output_gamma;\n}\n\n#  ifdef PNG_FLOATING_POINT_SUPPORTED\nstatic png_fixed_point\nconvert_gamma_value(png_structrp png_ptr, double output_gamma)\n{\n   /* The following silently ignores cases where fixed point (times 100,000)\n    * gamma values are passed to the floating point API.  This is safe and it\n    * means the fixed point constants work just fine with the floating point\n    * API.  The alternative would just lead to undetected errors and spurious\n    * bug reports.  Negative values fail inside the _fixed API unless they\n    * correspond to the flag values.\n    */\n   if (output_gamma > 0 && output_gamma < 128)\n      output_gamma *= PNG_FP_1;\n\n   /* This preserves -1 and -2 exactly: */\n   output_gamma = floor(output_gamma + .5);\n\n   if (output_gamma > PNG_FP_MAX || output_gamma < PNG_FP_MIN)\n      png_fixed_error(png_ptr, \"gamma value\");\n\n   return (png_fixed_point)output_gamma;\n}\n#  endif\n#endif /* READ_ALPHA_MODE || READ_GAMMA */\n\n#ifdef PNG_READ_ALPHA_MODE_SUPPORTED\nvoid PNGFAPI\npng_set_alpha_mode_fixed(png_structrp png_ptr, int mode,\n   png_fixed_point output_gamma)\n{\n   int compose = 0;\n   png_fixed_point file_gamma;\n\n   png_debug(1, \"in png_set_alpha_mode\");\n\n   if (!png_rtran_ok(png_ptr, 0))\n      return;\n\n   output_gamma = translate_gamma_flags(png_ptr, output_gamma, 1/*screen*/);\n\n   /* Validate the value to ensure it is in a reasonable range. The value\n    * is expected to be 1 or greater, but this range test allows for some\n    * viewing correction values.  The intent is to weed out users of this API\n    * who use the inverse of the gamma value accidentally!  Since some of these\n    * values are reasonable this may have to be changed.\n    */\n   if (output_gamma < 70000 || output_gamma > 300000)\n      png_error(png_ptr, \"output gamma out of expected range\");\n\n   /* The default file gamma is the inverse of the output gamma; the output\n    * gamma may be changed below so get the file value first:\n    */\n   file_gamma = png_reciprocal(output_gamma);\n\n   /* There are really 8 possibilities here, composed of any combination\n    * of:\n    *\n    *    premultiply the color channels\n    *    do not encode non-opaque pixels\n    *    encode the alpha as well as the color channels\n    *\n    * The differences disappear if the input/output ('screen') gamma is 1.0,\n    * because then the encoding is a no-op and there is only the choice of\n    * premultiplying the color channels or not.\n    *\n    * png_set_alpha_mode and png_set_background interact because both use\n    * png_compose to do the work.  Calling both is only useful when\n    * png_set_alpha_mode is used to set the default mode - PNG_ALPHA_PNG - along\n    * with a default gamma value.  Otherwise PNG_COMPOSE must not be set.\n    */\n   switch (mode)\n   {\n      case PNG_ALPHA_PNG:        /* default: png standard */\n         /* No compose, but it may be set by png_set_background! */\n         png_ptr->transformations &= ~PNG_ENCODE_ALPHA;\n         png_ptr->flags &= ~PNG_FLAG_OPTIMIZE_ALPHA;\n         break;\n\n      case PNG_ALPHA_ASSOCIATED: /* color channels premultiplied */\n         compose = 1;\n         png_ptr->transformations &= ~PNG_ENCODE_ALPHA;\n         png_ptr->flags &= ~PNG_FLAG_OPTIMIZE_ALPHA;\n         /* The output is linear: */\n         output_gamma = PNG_FP_1;\n         break;\n\n      case PNG_ALPHA_OPTIMIZED:  /* associated, non-opaque pixels linear */\n         compose = 1;\n         png_ptr->transformations &= ~PNG_ENCODE_ALPHA;\n         png_ptr->flags |= PNG_FLAG_OPTIMIZE_ALPHA;\n         /* output_gamma records the encoding of opaque pixels! */\n         break;\n\n      case PNG_ALPHA_BROKEN:     /* associated, non-linear, alpha encoded */\n         compose = 1;\n         png_ptr->transformations |= PNG_ENCODE_ALPHA;\n         png_ptr->flags &= ~PNG_FLAG_OPTIMIZE_ALPHA;\n         break;\n\n      default:\n         png_error(png_ptr, \"invalid alpha mode\");\n   }\n\n   /* Only set the default gamma if the file gamma has not been set (this has\n    * the side effect that the gamma in a second call to png_set_alpha_mode will\n    * be ignored.)\n    */\n   if (png_ptr->colorspace.gamma == 0)\n   {\n      png_ptr->colorspace.gamma = file_gamma;\n      png_ptr->colorspace.flags |= PNG_COLORSPACE_HAVE_GAMMA;\n   }\n\n   /* But always set the output gamma: */\n   png_ptr->screen_gamma = output_gamma;\n\n   /* Finally, if pre-multiplying, set the background fields to achieve the\n    * desired result.\n    */\n   if (compose)\n   {\n      /* And obtain alpha pre-multiplication by composing on black: */\n      memset(&png_ptr->background, 0, (sizeof png_ptr->background));\n      png_ptr->background_gamma = png_ptr->colorspace.gamma; /* just in case */\n      png_ptr->background_gamma_type = PNG_BACKGROUND_GAMMA_FILE;\n      png_ptr->transformations &= ~PNG_BACKGROUND_EXPAND;\n\n      if (png_ptr->transformations & PNG_COMPOSE)\n         png_error(png_ptr,\n            \"conflicting calls to set alpha mode and background\");\n\n      png_ptr->transformations |= PNG_COMPOSE;\n   }\n}\n\n#  ifdef PNG_FLOATING_POINT_SUPPORTED\nvoid PNGAPI\npng_set_alpha_mode(png_structrp png_ptr, int mode, double output_gamma)\n{\n   png_set_alpha_mode_fixed(png_ptr, mode, convert_gamma_value(png_ptr,\n      output_gamma));\n}\n#  endif\n#endif\n\n#ifdef PNG_READ_QUANTIZE_SUPPORTED\n/* Dither file to 8-bit.  Supply a palette, the current number\n * of elements in the palette, the maximum number of elements\n * allowed, and a histogram if possible.  If the current number\n * of colors is greater then the maximum number, the palette will be\n * modified to fit in the maximum number.  \"full_quantize\" indicates\n * whether we need a quantizing cube set up for RGB images, or if we\n * simply are reducing the number of colors in a paletted image.\n */\n\ntypedef struct png_dsort_struct\n{\n   struct png_dsort_struct * next;\n   png_byte left;\n   png_byte right;\n} png_dsort;\ntypedef png_dsort *   png_dsortp;\ntypedef png_dsort * * png_dsortpp;\n\nvoid PNGAPI\npng_set_quantize(png_structrp png_ptr, png_colorp palette,\n    int num_palette, int maximum_colors, png_const_uint_16p histogram,\n    int full_quantize)\n{\n   png_debug(1, \"in png_set_quantize\");\n\n   if (!png_rtran_ok(png_ptr, 0))\n      return;\n\n   png_ptr->transformations |= PNG_QUANTIZE;\n\n   if (!full_quantize)\n   {\n      int i;\n\n      png_ptr->quantize_index = (png_bytep)png_malloc(png_ptr,\n          (png_uint_32)(num_palette * (sizeof (png_byte))));\n      for (i = 0; i < num_palette; i++)\n         png_ptr->quantize_index[i] = (png_byte)i;\n   }\n\n   if (num_palette > maximum_colors)\n   {\n      if (histogram != NULL)\n      {\n         /* This is easy enough, just throw out the least used colors.\n          * Perhaps not the best solution, but good enough.\n          */\n\n         int i;\n\n         /* Initialize an array to sort colors */\n         png_ptr->quantize_sort = (png_bytep)png_malloc(png_ptr,\n             (png_uint_32)(num_palette * (sizeof (png_byte))));\n\n         /* Initialize the quantize_sort array */\n         for (i = 0; i < num_palette; i++)\n            png_ptr->quantize_sort[i] = (png_byte)i;\n\n         /* Find the least used palette entries by starting a\n          * bubble sort, and running it until we have sorted\n          * out enough colors.  Note that we don't care about\n          * sorting all the colors, just finding which are\n          * least used.\n          */\n\n         for (i = num_palette - 1; i >= maximum_colors; i--)\n         {\n            int done; /* To stop early if the list is pre-sorted */\n            int j;\n\n            done = 1;\n            for (j = 0; j < i; j++)\n            {\n               if (histogram[png_ptr->quantize_sort[j]]\n                   < histogram[png_ptr->quantize_sort[j + 1]])\n               {\n                  png_byte t;\n\n                  t = png_ptr->quantize_sort[j];\n                  png_ptr->quantize_sort[j] = png_ptr->quantize_sort[j + 1];\n                  png_ptr->quantize_sort[j + 1] = t;\n                  done = 0;\n               }\n            }\n\n            if (done)\n               break;\n         }\n\n         /* Swap the palette around, and set up a table, if necessary */\n         if (full_quantize)\n         {\n            int j = num_palette;\n\n            /* Put all the useful colors within the max, but don't\n             * move the others.\n             */\n            for (i = 0; i < maximum_colors; i++)\n            {\n               if ((int)png_ptr->quantize_sort[i] >= maximum_colors)\n               {\n                  do\n                     j--;\n                  while ((int)png_ptr->quantize_sort[j] >= maximum_colors);\n\n                  palette[i] = palette[j];\n               }\n            }\n         }\n         else\n         {\n            int j = num_palette;\n\n            /* Move all the used colors inside the max limit, and\n             * develop a translation table.\n             */\n            for (i = 0; i < maximum_colors; i++)\n            {\n               /* Only move the colors we need to */\n               if ((int)png_ptr->quantize_sort[i] >= maximum_colors)\n               {\n                  png_color tmp_color;\n\n                  do\n                     j--;\n                  while ((int)png_ptr->quantize_sort[j] >= maximum_colors);\n\n                  tmp_color = palette[j];\n                  palette[j] = palette[i];\n                  palette[i] = tmp_color;\n                  /* Indicate where the color went */\n                  png_ptr->quantize_index[j] = (png_byte)i;\n                  png_ptr->quantize_index[i] = (png_byte)j;\n               }\n            }\n\n            /* Find closest color for those colors we are not using */\n            for (i = 0; i < num_palette; i++)\n            {\n               if ((int)png_ptr->quantize_index[i] >= maximum_colors)\n               {\n                  int min_d, k, min_k, d_index;\n\n                  /* Find the closest color to one we threw out */\n                  d_index = png_ptr->quantize_index[i];\n                  min_d = PNG_COLOR_DIST(palette[d_index], palette[0]);\n                  for (k = 1, min_k = 0; k < maximum_colors; k++)\n                  {\n                     int d;\n\n                     d = PNG_COLOR_DIST(palette[d_index], palette[k]);\n\n                     if (d < min_d)\n                     {\n                        min_d = d;\n                        min_k = k;\n                     }\n                  }\n                  /* Point to closest color */\n                  png_ptr->quantize_index[i] = (png_byte)min_k;\n               }\n            }\n         }\n         png_free(png_ptr, png_ptr->quantize_sort);\n         png_ptr->quantize_sort = NULL;\n      }\n      else\n      {\n         /* This is much harder to do simply (and quickly).  Perhaps\n          * we need to go through a median cut routine, but those\n          * don't always behave themselves with only a few colors\n          * as input.  So we will just find the closest two colors,\n          * and throw out one of them (chosen somewhat randomly).\n          * [We don't understand this at all, so if someone wants to\n          *  work on improving it, be our guest - AED, GRP]\n          */\n         int i;\n         int max_d;\n         int num_new_palette;\n         png_dsortp t;\n         png_dsortpp hash;\n\n         t = NULL;\n\n         /* Initialize palette index arrays */\n         png_ptr->index_to_palette = (png_bytep)png_malloc(png_ptr,\n             (png_uint_32)(num_palette * (sizeof (png_byte))));\n         png_ptr->palette_to_index = (png_bytep)png_malloc(png_ptr,\n             (png_uint_32)(num_palette * (sizeof (png_byte))));\n\n         /* Initialize the sort array */\n         for (i = 0; i < num_palette; i++)\n         {\n            png_ptr->index_to_palette[i] = (png_byte)i;\n            png_ptr->palette_to_index[i] = (png_byte)i;\n         }\n\n         hash = (png_dsortpp)png_calloc(png_ptr, (png_uint_32)(769 *\n             (sizeof (png_dsortp))));\n\n         num_new_palette = num_palette;\n\n         /* Initial wild guess at how far apart the farthest pixel\n          * pair we will be eliminating will be.  Larger\n          * numbers mean more areas will be allocated, Smaller\n          * numbers run the risk of not saving enough data, and\n          * having to do this all over again.\n          *\n          * I have not done extensive checking on this number.\n          */\n         max_d = 96;\n\n         while (num_new_palette > maximum_colors)\n         {\n            for (i = 0; i < num_new_palette - 1; i++)\n            {\n               int j;\n\n               for (j = i + 1; j < num_new_palette; j++)\n               {\n                  int d;\n\n                  d = PNG_COLOR_DIST(palette[i], palette[j]);\n\n                  if (d <= max_d)\n                  {\n\n                     t = (png_dsortp)png_malloc_warn(png_ptr,\n                         (png_uint_32)(sizeof (png_dsort)));\n\n                     if (t == NULL)\n                         break;\n\n                     t->next = hash[d];\n                     t->left = (png_byte)i;\n                     t->right = (png_byte)j;\n                     hash[d] = t;\n                  }\n               }\n               if (t == NULL)\n                  break;\n            }\n\n            if (t != NULL)\n            for (i = 0; i <= max_d; i++)\n            {\n               if (hash[i] != NULL)\n               {\n                  png_dsortp p;\n\n                  for (p = hash[i]; p; p = p->next)\n                  {\n                     if ((int)png_ptr->index_to_palette[p->left]\n                         < num_new_palette &&\n                         (int)png_ptr->index_to_palette[p->right]\n                         < num_new_palette)\n                     {\n                        int j, next_j;\n\n                        if (num_new_palette & 0x01)\n                        {\n                           j = p->left;\n                           next_j = p->right;\n                        }\n                        else\n                        {\n                           j = p->right;\n                           next_j = p->left;\n                        }\n\n                        num_new_palette--;\n                        palette[png_ptr->index_to_palette[j]]\n                            = palette[num_new_palette];\n                        if (!full_quantize)\n                        {\n                           int k;\n\n                           for (k = 0; k < num_palette; k++)\n                           {\n                              if (png_ptr->quantize_index[k] ==\n                                  png_ptr->index_to_palette[j])\n                                 png_ptr->quantize_index[k] =\n                                     png_ptr->index_to_palette[next_j];\n\n                              if ((int)png_ptr->quantize_index[k] ==\n                                  num_new_palette)\n                                 png_ptr->quantize_index[k] =\n                                     png_ptr->index_to_palette[j];\n                           }\n                        }\n\n                        png_ptr->index_to_palette[png_ptr->palette_to_index\n                            [num_new_palette]] = png_ptr->index_to_palette[j];\n\n                        png_ptr->palette_to_index[png_ptr->index_to_palette[j]]\n                            = png_ptr->palette_to_index[num_new_palette];\n\n                        png_ptr->index_to_palette[j] =\n                            (png_byte)num_new_palette;\n\n                        png_ptr->palette_to_index[num_new_palette] =\n                            (png_byte)j;\n                     }\n                     if (num_new_palette <= maximum_colors)\n                        break;\n                  }\n                  if (num_new_palette <= maximum_colors)\n                     break;\n               }\n            }\n\n            for (i = 0; i < 769; i++)\n            {\n               if (hash[i] != NULL)\n               {\n                  png_dsortp p = hash[i];\n                  while (p)\n                  {\n                     t = p->next;\n                     png_free(png_ptr, p);\n                     p = t;\n                  }\n               }\n               hash[i] = 0;\n            }\n            max_d += 96;\n         }\n         png_free(png_ptr, hash);\n         png_free(png_ptr, png_ptr->palette_to_index);\n         png_free(png_ptr, png_ptr->index_to_palette);\n         png_ptr->palette_to_index = NULL;\n         png_ptr->index_to_palette = NULL;\n      }\n      num_palette = maximum_colors;\n   }\n   if (png_ptr->palette == NULL)\n   {\n      png_ptr->palette = palette;\n   }\n   png_ptr->num_palette = (png_uint_16)num_palette;\n\n   if (full_quantize)\n   {\n      int i;\n      png_bytep distance;\n      int total_bits = PNG_QUANTIZE_RED_BITS + PNG_QUANTIZE_GREEN_BITS +\n          PNG_QUANTIZE_BLUE_BITS;\n      int num_red = (1 << PNG_QUANTIZE_RED_BITS);\n      int num_green = (1 << PNG_QUANTIZE_GREEN_BITS);\n      int num_blue = (1 << PNG_QUANTIZE_BLUE_BITS);\n      png_size_t num_entries = ((png_size_t)1 << total_bits);\n\n      png_ptr->palette_lookup = (png_bytep)png_calloc(png_ptr,\n          (png_uint_32)(num_entries * (sizeof (png_byte))));\n\n      distance = (png_bytep)png_malloc(png_ptr, (png_uint_32)(num_entries *\n          (sizeof (png_byte))));\n\n      memset(distance, 0xff, num_entries * (sizeof (png_byte)));\n\n      for (i = 0; i < num_palette; i++)\n      {\n         int ir, ig, ib;\n         int r = (palette[i].red >> (8 - PNG_QUANTIZE_RED_BITS));\n         int g = (palette[i].green >> (8 - PNG_QUANTIZE_GREEN_BITS));\n         int b = (palette[i].blue >> (8 - PNG_QUANTIZE_BLUE_BITS));\n\n         for (ir = 0; ir < num_red; ir++)\n         {\n            /* int dr = abs(ir - r); */\n            int dr = ((ir > r) ? ir - r : r - ir);\n            int index_r = (ir << (PNG_QUANTIZE_BLUE_BITS +\n                PNG_QUANTIZE_GREEN_BITS));\n\n            for (ig = 0; ig < num_green; ig++)\n            {\n               /* int dg = abs(ig - g); */\n               int dg = ((ig > g) ? ig - g : g - ig);\n               int dt = dr + dg;\n               int dm = ((dr > dg) ? dr : dg);\n               int index_g = index_r | (ig << PNG_QUANTIZE_BLUE_BITS);\n\n               for (ib = 0; ib < num_blue; ib++)\n               {\n                  int d_index = index_g | ib;\n                  /* int db = abs(ib - b); */\n                  int db = ((ib > b) ? ib - b : b - ib);\n                  int dmax = ((dm > db) ? dm : db);\n                  int d = dmax + dt + db;\n\n                  if (d < (int)distance[d_index])\n                  {\n                     distance[d_index] = (png_byte)d;\n                     png_ptr->palette_lookup[d_index] = (png_byte)i;\n                  }\n               }\n            }\n         }\n      }\n\n      png_free(png_ptr, distance);\n   }\n}\n#endif /* PNG_READ_QUANTIZE_SUPPORTED */\n\n#ifdef PNG_READ_GAMMA_SUPPORTED\nvoid PNGFAPI\npng_set_gamma_fixed(png_structrp png_ptr, png_fixed_point scrn_gamma,\n   png_fixed_point file_gamma)\n{\n   png_debug(1, \"in png_set_gamma_fixed\");\n\n   if (!png_rtran_ok(png_ptr, 0))\n      return;\n\n   /* New in libpng-1.5.4 - reserve particular negative values as flags. */\n   scrn_gamma = translate_gamma_flags(png_ptr, scrn_gamma, 1/*screen*/);\n   file_gamma = translate_gamma_flags(png_ptr, file_gamma, 0/*file*/);\n\n   /* Checking the gamma values for being >0 was added in 1.5.4 along with the\n    * premultiplied alpha support; this actually hides an undocumented feature\n    * of the previous implementation which allowed gamma processing to be\n    * disabled in background handling.  There is no evidence (so far) that this\n    * was being used; however, png_set_background itself accepted and must still\n    * accept '0' for the gamma value it takes, because it isn't always used.\n    *\n    * Since this is an API change (albeit a very minor one that removes an\n    * undocumented API feature) the following checks were only enabled in\n    * libpng-1.6.0.\n    */\n   if (file_gamma <= 0)\n      png_error(png_ptr, \"invalid file gamma in png_set_gamma\");\n\n   if (scrn_gamma <= 0)\n      png_error(png_ptr, \"invalid screen gamma in png_set_gamma\");\n\n   /* Set the gamma values unconditionally - this overrides the value in the PNG\n    * file if a gAMA chunk was present.  png_set_alpha_mode provides a\n    * different, easier, way to default the file gamma.\n    */\n   png_ptr->colorspace.gamma = file_gamma;\n   png_ptr->colorspace.flags |= PNG_COLORSPACE_HAVE_GAMMA;\n   png_ptr->screen_gamma = scrn_gamma;\n}\n\n#  ifdef PNG_FLOATING_POINT_SUPPORTED\nvoid PNGAPI\npng_set_gamma(png_structrp png_ptr, double scrn_gamma, double file_gamma)\n{\n   png_set_gamma_fixed(png_ptr, convert_gamma_value(png_ptr, scrn_gamma),\n      convert_gamma_value(png_ptr, file_gamma));\n}\n#  endif /* FLOATING_POINT_SUPPORTED */\n#endif /* READ_GAMMA */\n\n#ifdef PNG_READ_EXPAND_SUPPORTED\n/* Expand paletted images to RGB, expand grayscale images of\n * less than 8-bit depth to 8-bit depth, and expand tRNS chunks\n * to alpha channels.\n */\nvoid PNGAPI\npng_set_expand(png_structrp png_ptr)\n{\n   png_debug(1, \"in png_set_expand\");\n\n   if (!png_rtran_ok(png_ptr, 0))\n      return;\n\n   png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS);\n}\n\n/* GRR 19990627:  the following three functions currently are identical\n *  to png_set_expand().  However, it is entirely reasonable that someone\n *  might wish to expand an indexed image to RGB but *not* expand a single,\n *  fully transparent palette entry to a full alpha channel--perhaps instead\n *  convert tRNS to the grayscale/RGB format (16-bit RGB value), or replace\n *  the transparent color with a particular RGB value, or drop tRNS entirely.\n *  IOW, a future version of the library may make the transformations flag\n *  a bit more fine-grained, with separate bits for each of these three\n *  functions.\n *\n *  More to the point, these functions make it obvious what libpng will be\n *  doing, whereas \"expand\" can (and does) mean any number of things.\n *\n *  GRP 20060307: In libpng-1.2.9, png_set_gray_1_2_4_to_8() was modified\n *  to expand only the sample depth but not to expand the tRNS to alpha\n *  and its name was changed to png_set_expand_gray_1_2_4_to_8().\n */\n\n/* Expand paletted images to RGB. */\nvoid PNGAPI\npng_set_palette_to_rgb(png_structrp png_ptr)\n{\n   png_debug(1, \"in png_set_palette_to_rgb\");\n\n   if (!png_rtran_ok(png_ptr, 0))\n      return;\n\n   png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS);\n}\n\n/* Expand grayscale images of less than 8-bit depth to 8 bits. */\nvoid PNGAPI\npng_set_expand_gray_1_2_4_to_8(png_structrp png_ptr)\n{\n   png_debug(1, \"in png_set_expand_gray_1_2_4_to_8\");\n\n   if (!png_rtran_ok(png_ptr, 0))\n      return;\n\n   png_ptr->transformations |= PNG_EXPAND;\n}\n\n/* Expand tRNS chunks to alpha channels. */\nvoid PNGAPI\npng_set_tRNS_to_alpha(png_structrp png_ptr)\n{\n   png_debug(1, \"in png_set_tRNS_to_alpha\");\n\n   if (!png_rtran_ok(png_ptr, 0))\n      return;\n\n   png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS);\n}\n#endif /* defined(PNG_READ_EXPAND_SUPPORTED) */\n\n#ifdef PNG_READ_EXPAND_16_SUPPORTED\n/* Expand to 16-bit channels, expand the tRNS chunk too (because otherwise\n * it may not work correctly.)\n */\nvoid PNGAPI\npng_set_expand_16(png_structrp png_ptr)\n{\n   png_debug(1, \"in png_set_expand_16\");\n\n   if (!png_rtran_ok(png_ptr, 0))\n      return;\n\n   png_ptr->transformations |= (PNG_EXPAND_16 | PNG_EXPAND | PNG_EXPAND_tRNS);\n}\n#endif\n\n#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED\nvoid PNGAPI\npng_set_gray_to_rgb(png_structrp png_ptr)\n{\n   png_debug(1, \"in png_set_gray_to_rgb\");\n\n   if (!png_rtran_ok(png_ptr, 0))\n      return;\n\n   /* Because rgb must be 8 bits or more: */\n   png_set_expand_gray_1_2_4_to_8(png_ptr);\n   png_ptr->transformations |= PNG_GRAY_TO_RGB;\n}\n#endif\n\n#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED\nvoid PNGFAPI\npng_set_rgb_to_gray_fixed(png_structrp png_ptr, int error_action,\n    png_fixed_point red, png_fixed_point green)\n{\n   png_debug(1, \"in png_set_rgb_to_gray\");\n\n   /* Need the IHDR here because of the check on color_type below. */\n   /* TODO: fix this */\n   if (!png_rtran_ok(png_ptr, 1))\n      return;\n\n   switch(error_action)\n   {\n      case PNG_ERROR_ACTION_NONE:\n         png_ptr->transformations |= PNG_RGB_TO_GRAY;\n         break;\n\n      case PNG_ERROR_ACTION_WARN:\n         png_ptr->transformations |= PNG_RGB_TO_GRAY_WARN;\n         break;\n\n      case PNG_ERROR_ACTION_ERROR:\n         png_ptr->transformations |= PNG_RGB_TO_GRAY_ERR;\n         break;\n\n      default:\n         png_error(png_ptr, \"invalid error action to rgb_to_gray\");\n         break;\n   }\n\n   if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)\n#ifdef PNG_READ_EXPAND_SUPPORTED\n      png_ptr->transformations |= PNG_EXPAND;\n#else\n   {\n      /* Make this an error in 1.6 because otherwise the application may assume\n       * that it just worked and get a memory overwrite.\n       */\n      png_error(png_ptr,\n        \"Cannot do RGB_TO_GRAY without EXPAND_SUPPORTED\");\n\n      /* png_ptr->transformations &= ~PNG_RGB_TO_GRAY; */\n   }\n#endif\n   {\n      if (red >= 0 && green >= 0 && red + green <= PNG_FP_1)\n      {\n         png_uint_16 red_int, green_int;\n\n         /* NOTE: this calculation does not round, but this behavior is retained\n          * for consistency, the inaccuracy is very small.  The code here always\n          * overwrites the coefficients, regardless of whether they have been\n          * defaulted or set already.\n          */\n         red_int = (png_uint_16)(((png_uint_32)red*32768)/100000);\n         green_int = (png_uint_16)(((png_uint_32)green*32768)/100000);\n\n         png_ptr->rgb_to_gray_red_coeff   = red_int;\n         png_ptr->rgb_to_gray_green_coeff = green_int;\n         png_ptr->rgb_to_gray_coefficients_set = 1;\n      }\n\n      else\n      {\n         if (red >= 0 && green >= 0)\n            png_app_warning(png_ptr,\n               \"ignoring out of range rgb_to_gray coefficients\");\n\n         /* Use the defaults, from the cHRM chunk if set, else the historical\n          * values which are close to the sRGB/HDTV/ITU-Rec 709 values.  See\n          * png_do_rgb_to_gray for more discussion of the values.  In this case\n          * the coefficients are not marked as 'set' and are not overwritten if\n          * something has already provided a default.\n          */\n         if (png_ptr->rgb_to_gray_red_coeff == 0 &&\n            png_ptr->rgb_to_gray_green_coeff == 0)\n         {\n            png_ptr->rgb_to_gray_red_coeff   = 6968;\n            png_ptr->rgb_to_gray_green_coeff = 23434;\n            /* png_ptr->rgb_to_gray_blue_coeff  = 2366; */\n         }\n      }\n   }\n}\n\n#ifdef PNG_FLOATING_POINT_SUPPORTED\n/* Convert a RGB image to a grayscale of the same width.  This allows us,\n * for example, to convert a 24 bpp RGB image into an 8 bpp grayscale image.\n */\n\nvoid PNGAPI\npng_set_rgb_to_gray(png_structrp png_ptr, int error_action, double red,\n   double green)\n{\n   png_set_rgb_to_gray_fixed(png_ptr, error_action,\n      png_fixed(png_ptr, red, \"rgb to gray red coefficient\"),\n      png_fixed(png_ptr, green, \"rgb to gray green coefficient\"));\n}\n#endif /* FLOATING POINT */\n\n#endif /* RGB_TO_GRAY */\n\n#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \\\n    defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)\nvoid PNGAPI\npng_set_read_user_transform_fn(png_structrp png_ptr, png_user_transform_ptr\n    read_user_transform_fn)\n{\n   png_debug(1, \"in png_set_read_user_transform_fn\");\n\n#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED\n   png_ptr->transformations |= PNG_USER_TRANSFORM;\n   png_ptr->read_user_transform_fn = read_user_transform_fn;\n#endif\n}\n#endif\n\n#ifdef PNG_READ_TRANSFORMS_SUPPORTED\n#ifdef PNG_READ_GAMMA_SUPPORTED\n/* In the case of gamma transformations only do transformations on images where\n * the [file] gamma and screen_gamma are not close reciprocals, otherwise it\n * slows things down slightly, and also needlessly introduces small errors.\n */\nstatic int /* PRIVATE */\npng_gamma_threshold(png_fixed_point screen_gamma, png_fixed_point file_gamma)\n{\n   /* PNG_GAMMA_THRESHOLD is the threshold for performing gamma\n    * correction as a difference of the overall transform from 1.0\n    *\n    * We want to compare the threshold with s*f - 1, if we get\n    * overflow here it is because of wacky gamma values so we\n    * turn on processing anyway.\n    */\n   png_fixed_point gtest;\n   return !png_muldiv(&gtest, screen_gamma, file_gamma, PNG_FP_1) ||\n       png_gamma_significant(gtest);\n}\n#endif\n\n/* Initialize everything needed for the read.  This includes modifying\n * the palette.\n */\n\n/*For the moment 'png_init_palette_transformations' and\n * 'png_init_rgb_transformations' only do some flag canceling optimizations.\n * The intent is that these two routines should have palette or rgb operations\n * extracted from 'png_init_read_transformations'.\n */\nstatic void /* PRIVATE */\npng_init_palette_transformations(png_structrp png_ptr)\n{\n   /* Called to handle the (input) palette case.  In png_do_read_transformations\n    * the first step is to expand the palette if requested, so this code must\n    * take care to only make changes that are invariant with respect to the\n    * palette expansion, or only do them if there is no expansion.\n    *\n    * STRIP_ALPHA has already been handled in the caller (by setting num_trans\n    * to 0.)\n    */\n   int input_has_alpha = 0;\n   int input_has_transparency = 0;\n\n   if (png_ptr->num_trans > 0)\n   {\n      int i;\n\n      /* Ignore if all the entries are opaque (unlikely!) */\n      for (i=0; i<png_ptr->num_trans; ++i)\n      {\n         if (png_ptr->trans_alpha[i] == 255)\n            continue;\n         else if (png_ptr->trans_alpha[i] == 0)\n            input_has_transparency = 1;\n         else\n         {\n            input_has_transparency = 1;\n            input_has_alpha = 1;\n            break;\n         }\n      }\n   }\n\n   /* If no alpha we can optimize. */\n   if (!input_has_alpha)\n   {\n      /* Any alpha means background and associative alpha processing is\n       * required, however if the alpha is 0 or 1 throughout OPTIMIZE_ALPHA\n       * and ENCODE_ALPHA are irrelevant.\n       */\n      png_ptr->transformations &= ~PNG_ENCODE_ALPHA;\n      png_ptr->flags &= ~PNG_FLAG_OPTIMIZE_ALPHA;\n\n      if (!input_has_transparency)\n         png_ptr->transformations &= ~(PNG_COMPOSE | PNG_BACKGROUND_EXPAND);\n   }\n\n#if defined(PNG_READ_EXPAND_SUPPORTED) && defined(PNG_READ_BACKGROUND_SUPPORTED)\n   /* png_set_background handling - deals with the complexity of whether the\n    * background color is in the file format or the screen format in the case\n    * where an 'expand' will happen.\n    */\n\n   /* The following code cannot be entered in the alpha pre-multiplication case\n    * because PNG_BACKGROUND_EXPAND is cancelled below.\n    */\n   if ((png_ptr->transformations & PNG_BACKGROUND_EXPAND) &&\n       (png_ptr->transformations & PNG_EXPAND))\n   {\n      {\n         png_ptr->background.red   =\n             png_ptr->palette[png_ptr->background.index].red;\n         png_ptr->background.green =\n             png_ptr->palette[png_ptr->background.index].green;\n         png_ptr->background.blue  =\n             png_ptr->palette[png_ptr->background.index].blue;\n\n#ifdef PNG_READ_INVERT_ALPHA_SUPPORTED\n        if (png_ptr->transformations & PNG_INVERT_ALPHA)\n        {\n           if (!(png_ptr->transformations & PNG_EXPAND_tRNS))\n           {\n              /* Invert the alpha channel (in tRNS) unless the pixels are\n               * going to be expanded, in which case leave it for later\n               */\n              int i, istop = png_ptr->num_trans;\n\n              for (i=0; i<istop; i++)\n                 png_ptr->trans_alpha[i] = (png_byte)(255 -\n                    png_ptr->trans_alpha[i]);\n           }\n        }\n#endif /* PNG_READ_INVERT_ALPHA_SUPPORTED */\n      }\n   } /* background expand and (therefore) no alpha association. */\n#endif /* PNG_READ_EXPAND_SUPPORTED && PNG_READ_BACKGROUND_SUPPORTED */\n}\n\nstatic void /* PRIVATE */\npng_init_rgb_transformations(png_structrp png_ptr)\n{\n   /* Added to libpng-1.5.4: check the color type to determine whether there\n    * is any alpha or transparency in the image and simply cancel the\n    * background and alpha mode stuff if there isn't.\n    */\n   int input_has_alpha = (png_ptr->color_type & PNG_COLOR_MASK_ALPHA) != 0;\n   int input_has_transparency = png_ptr->num_trans > 0;\n\n   /* If no alpha we can optimize. */\n   if (!input_has_alpha)\n   {\n      /* Any alpha means background and associative alpha processing is\n       * required, however if the alpha is 0 or 1 throughout OPTIMIZE_ALPHA\n       * and ENCODE_ALPHA are irrelevant.\n       */\n#     ifdef PNG_READ_ALPHA_MODE_SUPPORTED\n         png_ptr->transformations &= ~PNG_ENCODE_ALPHA;\n         png_ptr->flags &= ~PNG_FLAG_OPTIMIZE_ALPHA;\n#     endif\n\n      if (!input_has_transparency)\n         png_ptr->transformations &= ~(PNG_COMPOSE | PNG_BACKGROUND_EXPAND);\n   }\n\n#if defined(PNG_READ_EXPAND_SUPPORTED) && defined(PNG_READ_BACKGROUND_SUPPORTED)\n   /* png_set_background handling - deals with the complexity of whether the\n    * background color is in the file format or the screen format in the case\n    * where an 'expand' will happen.\n    */\n\n   /* The following code cannot be entered in the alpha pre-multiplication case\n    * because PNG_BACKGROUND_EXPAND is cancelled below.\n    */\n   if ((png_ptr->transformations & PNG_BACKGROUND_EXPAND) &&\n       (png_ptr->transformations & PNG_EXPAND) &&\n       !(png_ptr->color_type & PNG_COLOR_MASK_COLOR))\n       /* i.e., GRAY or GRAY_ALPHA */\n   {\n      {\n         /* Expand background and tRNS chunks */\n         int gray = png_ptr->background.gray;\n         int trans_gray = png_ptr->trans_color.gray;\n\n         switch (png_ptr->bit_depth)\n         {\n            case 1:\n               gray *= 0xff;\n               trans_gray *= 0xff;\n               break;\n\n            case 2:\n               gray *= 0x55;\n               trans_gray *= 0x55;\n               break;\n\n            case 4:\n               gray *= 0x11;\n               trans_gray *= 0x11;\n               break;\n\n            default:\n\n            case 8:\n               /* FALL THROUGH (Already 8 bits) */\n\n            case 16:\n               /* Already a full 16 bits */\n               break;\n         }\n\n         png_ptr->background.red = png_ptr->background.green =\n            png_ptr->background.blue = (png_uint_16)gray;\n\n         if (!(png_ptr->transformations & PNG_EXPAND_tRNS))\n         {\n            png_ptr->trans_color.red = png_ptr->trans_color.green =\n               png_ptr->trans_color.blue = (png_uint_16)trans_gray;\n         }\n      }\n   } /* background expand and (therefore) no alpha association. */\n#endif /* PNG_READ_EXPAND_SUPPORTED && PNG_READ_BACKGROUND_SUPPORTED */\n}\n\nvoid /* PRIVATE */\npng_init_read_transformations(png_structrp png_ptr)\n{\n   png_debug(1, \"in png_init_read_transformations\");\n\n   /* This internal function is called from png_read_start_row in pngrutil.c\n    * and it is called before the 'rowbytes' calculation is done, so the code\n    * in here can change or update the transformations flags.\n    *\n    * First do updates that do not depend on the details of the PNG image data\n    * being processed.\n    */\n\n#ifdef PNG_READ_GAMMA_SUPPORTED\n   /* Prior to 1.5.4 these tests were performed from png_set_gamma, 1.5.4 adds\n    * png_set_alpha_mode and this is another source for a default file gamma so\n    * the test needs to be performed later - here.  In addition prior to 1.5.4\n    * the tests were repeated for the PALETTE color type here - this is no\n    * longer necessary (and doesn't seem to have been necessary before.)\n    */\n   {\n      /* The following temporary indicates if overall gamma correction is\n       * required.\n       */\n      int gamma_correction = 0;\n\n      if (png_ptr->colorspace.gamma != 0) /* has been set */\n      {\n         if (png_ptr->screen_gamma != 0) /* screen set too */\n            gamma_correction = png_gamma_threshold(png_ptr->colorspace.gamma,\n               png_ptr->screen_gamma);\n\n         else\n            /* Assume the output matches the input; a long time default behavior\n             * of libpng, although the standard has nothing to say about this.\n             */\n            png_ptr->screen_gamma = png_reciprocal(png_ptr->colorspace.gamma);\n      }\n\n      else if (png_ptr->screen_gamma != 0)\n         /* The converse - assume the file matches the screen, note that this\n          * perhaps undesireable default can (from 1.5.4) be changed by calling\n          * png_set_alpha_mode (even if the alpha handling mode isn't required\n          * or isn't changed from the default.)\n          */\n         png_ptr->colorspace.gamma = png_reciprocal(png_ptr->screen_gamma);\n\n      else /* neither are set */\n         /* Just in case the following prevents any processing - file and screen\n          * are both assumed to be linear and there is no way to introduce a\n          * third gamma value other than png_set_background with 'UNIQUE', and,\n          * prior to 1.5.4\n          */\n         png_ptr->screen_gamma = png_ptr->colorspace.gamma = PNG_FP_1;\n\n      /* We have a gamma value now. */\n      png_ptr->colorspace.flags |= PNG_COLORSPACE_HAVE_GAMMA;\n\n      /* Now turn the gamma transformation on or off as appropriate.  Notice\n       * that PNG_GAMMA just refers to the file->screen correction.  Alpha\n       * composition may independently cause gamma correction because it needs\n       * linear data (e.g. if the file has a gAMA chunk but the screen gamma\n       * hasn't been specified.)  In any case this flag may get turned off in\n       * the code immediately below if the transform can be handled outside the\n       * row loop.\n       */\n      if (gamma_correction)\n         png_ptr->transformations |= PNG_GAMMA;\n\n      else\n         png_ptr->transformations &= ~PNG_GAMMA;\n   }\n#endif\n\n   /* Certain transformations have the effect of preventing other\n    * transformations that happen afterward in png_do_read_transformations,\n    * resolve the interdependencies here.  From the code of\n    * png_do_read_transformations the order is:\n    *\n    *  1) PNG_EXPAND (including PNG_EXPAND_tRNS)\n    *  2) PNG_STRIP_ALPHA (if no compose)\n    *  3) PNG_RGB_TO_GRAY\n    *  4) PNG_GRAY_TO_RGB iff !PNG_BACKGROUND_IS_GRAY\n    *  5) PNG_COMPOSE\n    *  6) PNG_GAMMA\n    *  7) PNG_STRIP_ALPHA (if compose)\n    *  8) PNG_ENCODE_ALPHA\n    *  9) PNG_SCALE_16_TO_8\n    * 10) PNG_16_TO_8\n    * 11) PNG_QUANTIZE (converts to palette)\n    * 12) PNG_EXPAND_16\n    * 13) PNG_GRAY_TO_RGB iff PNG_BACKGROUND_IS_GRAY\n    * 14) PNG_INVERT_MONO\n    * 15) PNG_INVERT_ALPHA\n    * 16) PNG_SHIFT\n    * 17) PNG_PACK\n    * 18) PNG_BGR\n    * 19) PNG_PACKSWAP\n    * 20) PNG_FILLER (includes PNG_ADD_ALPHA)\n    * 21) PNG_SWAP_ALPHA\n    * 22) PNG_SWAP_BYTES\n    * 23) PNG_USER_TRANSFORM [must be last]\n    */\n#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED\n   if ((png_ptr->transformations & PNG_STRIP_ALPHA) &&\n      !(png_ptr->transformations & PNG_COMPOSE))\n   {\n      /* Stripping the alpha channel happens immediately after the 'expand'\n       * transformations, before all other transformation, so it cancels out\n       * the alpha handling.  It has the side effect negating the effect of\n       * PNG_EXPAND_tRNS too:\n       */\n      png_ptr->transformations &= ~(PNG_BACKGROUND_EXPAND | PNG_ENCODE_ALPHA |\n         PNG_EXPAND_tRNS);\n      png_ptr->flags &= ~PNG_FLAG_OPTIMIZE_ALPHA;\n\n      /* Kill the tRNS chunk itself too.  Prior to 1.5.4 this did not happen\n       * so transparency information would remain just so long as it wasn't\n       * expanded.  This produces unexpected API changes if the set of things\n       * that do PNG_EXPAND_tRNS changes (perfectly possible given the\n       * documentation - which says ask for what you want, accept what you\n       * get.)  This makes the behavior consistent from 1.5.4:\n       */\n      png_ptr->num_trans = 0;\n   }\n#endif /* STRIP_ALPHA supported, no COMPOSE */\n\n#ifdef PNG_READ_ALPHA_MODE_SUPPORTED\n   /* If the screen gamma is about 1.0 then the OPTIMIZE_ALPHA and ENCODE_ALPHA\n    * settings will have no effect.\n    */\n   if (!png_gamma_significant(png_ptr->screen_gamma))\n   {\n      png_ptr->transformations &= ~PNG_ENCODE_ALPHA;\n      png_ptr->flags &= ~PNG_FLAG_OPTIMIZE_ALPHA;\n   }\n#endif\n\n#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED\n   /* Make sure the coefficients for the rgb to gray conversion are set\n    * appropriately.\n    */\n   if (png_ptr->transformations & PNG_RGB_TO_GRAY)\n      png_colorspace_set_rgb_coefficients(png_ptr);\n#endif\n\n#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED\n#if defined(PNG_READ_EXPAND_SUPPORTED) && defined(PNG_READ_BACKGROUND_SUPPORTED)\n   /* Detect gray background and attempt to enable optimization for\n    * gray --> RGB case.\n    *\n    * Note:  if PNG_BACKGROUND_EXPAND is set and color_type is either RGB or\n    * RGB_ALPHA (in which case need_expand is superfluous anyway), the\n    * background color might actually be gray yet not be flagged as such.\n    * This is not a problem for the current code, which uses\n    * PNG_BACKGROUND_IS_GRAY only to decide when to do the\n    * png_do_gray_to_rgb() transformation.\n    *\n    * TODO: this code needs to be revised to avoid the complexity and\n    * interdependencies.  The color type of the background should be recorded in\n    * png_set_background, along with the bit depth, then the code has a record\n    * of exactly what color space the background is currently in.\n    */\n   if (png_ptr->transformations & PNG_BACKGROUND_EXPAND)\n   {\n      /* PNG_BACKGROUND_EXPAND: the background is in the file color space, so if\n       * the file was grayscale the background value is gray.\n       */\n      if (!(png_ptr->color_type & PNG_COLOR_MASK_COLOR))\n         png_ptr->mode |= PNG_BACKGROUND_IS_GRAY;\n   }\n\n   else if (png_ptr->transformations & PNG_COMPOSE)\n   {\n      /* PNG_COMPOSE: png_set_background was called with need_expand false,\n       * so the color is in the color space of the output or png_set_alpha_mode\n       * was called and the color is black.  Ignore RGB_TO_GRAY because that\n       * happens before GRAY_TO_RGB.\n       */\n      if (png_ptr->transformations & PNG_GRAY_TO_RGB)\n      {\n         if (png_ptr->background.red == png_ptr->background.green &&\n             png_ptr->background.red == png_ptr->background.blue)\n         {\n            png_ptr->mode |= PNG_BACKGROUND_IS_GRAY;\n            png_ptr->background.gray = png_ptr->background.red;\n         }\n      }\n   }\n#endif /* PNG_READ_EXPAND_SUPPORTED && PNG_READ_BACKGROUND_SUPPORTED */\n#endif /* PNG_READ_GRAY_TO_RGB_SUPPORTED */\n\n   /* For indexed PNG data (PNG_COLOR_TYPE_PALETTE) many of the transformations\n    * can be performed directly on the palette, and some (such as rgb to gray)\n    * can be optimized inside the palette.  This is particularly true of the\n    * composite (background and alpha) stuff, which can be pretty much all done\n    * in the palette even if the result is expanded to RGB or gray afterward.\n    *\n    * NOTE: this is Not Yet Implemented, the code behaves as in 1.5.1 and\n    * earlier and the palette stuff is actually handled on the first row.  This\n    * leads to the reported bug that the palette returned by png_get_PLTE is not\n    * updated.\n    */\n   if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)\n      png_init_palette_transformations(png_ptr);\n\n   else\n      png_init_rgb_transformations(png_ptr);\n\n#if defined(PNG_READ_BACKGROUND_SUPPORTED) && \\\n   defined(PNG_READ_EXPAND_16_SUPPORTED)\n   if ((png_ptr->transformations & PNG_EXPAND_16) &&\n      (png_ptr->transformations & PNG_COMPOSE) &&\n      !(png_ptr->transformations & PNG_BACKGROUND_EXPAND) &&\n      png_ptr->bit_depth != 16)\n   {\n      /* TODO: fix this.  Because the expand_16 operation is after the compose\n       * handling the background color must be 8, not 16, bits deep, but the\n       * application will supply a 16-bit value so reduce it here.\n       *\n       * The PNG_BACKGROUND_EXPAND code above does not expand to 16 bits at\n       * present, so that case is ok (until do_expand_16 is moved.)\n       *\n       * NOTE: this discards the low 16 bits of the user supplied background\n       * color, but until expand_16 works properly there is no choice!\n       */\n#     define CHOP(x) (x)=((png_uint_16)PNG_DIV257(x))\n      CHOP(png_ptr->background.red);\n      CHOP(png_ptr->background.green);\n      CHOP(png_ptr->background.blue);\n      CHOP(png_ptr->background.gray);\n#     undef CHOP\n   }\n#endif /* PNG_READ_BACKGROUND_SUPPORTED && PNG_READ_EXPAND_16_SUPPORTED */\n\n#if defined(PNG_READ_BACKGROUND_SUPPORTED) && \\\n   (defined(PNG_READ_SCALE_16_TO_8_SUPPORTED) || \\\n   defined(PNG_READ_STRIP_16_TO_8_SUPPORTED))\n   if ((png_ptr->transformations & (PNG_16_TO_8|PNG_SCALE_16_TO_8)) &&\n      (png_ptr->transformations & PNG_COMPOSE) &&\n      !(png_ptr->transformations & PNG_BACKGROUND_EXPAND) &&\n      png_ptr->bit_depth == 16)\n   {\n      /* On the other hand, if a 16-bit file is to be reduced to 8-bits per\n       * component this will also happen after PNG_COMPOSE and so the background\n       * color must be pre-expanded here.\n       *\n       * TODO: fix this too.\n       */\n      png_ptr->background.red = (png_uint_16)(png_ptr->background.red * 257);\n      png_ptr->background.green =\n         (png_uint_16)(png_ptr->background.green * 257);\n      png_ptr->background.blue = (png_uint_16)(png_ptr->background.blue * 257);\n      png_ptr->background.gray = (png_uint_16)(png_ptr->background.gray * 257);\n   }\n#endif\n\n   /* NOTE: below 'PNG_READ_ALPHA_MODE_SUPPORTED' is presumed to also enable the\n    * background support (see the comments in scripts/pnglibconf.dfa), this\n    * allows pre-multiplication of the alpha channel to be implemented as\n    * compositing on black.  This is probably sub-optimal and has been done in\n    * 1.5.4 betas simply to enable external critique and testing (i.e. to\n    * implement the new API quickly, without lots of internal changes.)\n    */\n\n#ifdef PNG_READ_GAMMA_SUPPORTED\n#  ifdef PNG_READ_BACKGROUND_SUPPORTED\n      /* Includes ALPHA_MODE */\n      png_ptr->background_1 = png_ptr->background;\n#  endif\n\n   /* This needs to change - in the palette image case a whole set of tables are\n    * built when it would be quicker to just calculate the correct value for\n    * each palette entry directly.  Also, the test is too tricky - why check\n    * PNG_RGB_TO_GRAY if PNG_GAMMA is not set?  The answer seems to be that\n    * PNG_GAMMA is cancelled even if the gamma is known?  The test excludes the\n    * PNG_COMPOSE case, so apparently if there is no *overall* gamma correction\n    * the gamma tables will not be built even if composition is required on a\n    * gamma encoded value.\n    *\n    * In 1.5.4 this is addressed below by an additional check on the individual\n    * file gamma - if it is not 1.0 both RGB_TO_GRAY and COMPOSE need the\n    * tables.\n    */\n   if ((png_ptr->transformations & PNG_GAMMA)\n      || ((png_ptr->transformations & PNG_RGB_TO_GRAY)\n         && (png_gamma_significant(png_ptr->colorspace.gamma) ||\n            png_gamma_significant(png_ptr->screen_gamma)))\n      || ((png_ptr->transformations & PNG_COMPOSE)\n         && (png_gamma_significant(png_ptr->colorspace.gamma)\n            || png_gamma_significant(png_ptr->screen_gamma)\n#  ifdef PNG_READ_BACKGROUND_SUPPORTED\n            || (png_ptr->background_gamma_type == PNG_BACKGROUND_GAMMA_UNIQUE\n               && png_gamma_significant(png_ptr->background_gamma))\n#  endif\n      )) || ((png_ptr->transformations & PNG_ENCODE_ALPHA)\n         && png_gamma_significant(png_ptr->screen_gamma))\n      )\n   {\n      png_build_gamma_table(png_ptr, png_ptr->bit_depth);\n\n#ifdef PNG_READ_BACKGROUND_SUPPORTED\n      if (png_ptr->transformations & PNG_COMPOSE)\n      {\n         /* Issue a warning about this combination: because RGB_TO_GRAY is\n          * optimized to do the gamma transform if present yet do_background has\n          * to do the same thing if both options are set a\n          * double-gamma-correction happens.  This is true in all versions of\n          * libpng to date.\n          */\n         if (png_ptr->transformations & PNG_RGB_TO_GRAY)\n            png_warning(png_ptr,\n               \"libpng does not support gamma+background+rgb_to_gray\");\n\n         if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)\n         {\n            /* We don't get to here unless there is a tRNS chunk with non-opaque\n             * entries - see the checking code at the start of this function.\n             */\n            png_color back, back_1;\n            png_colorp palette = png_ptr->palette;\n            int num_palette = png_ptr->num_palette;\n            int i;\n            if (png_ptr->background_gamma_type == PNG_BACKGROUND_GAMMA_FILE)\n            {\n\n               back.red = png_ptr->gamma_table[png_ptr->background.red];\n               back.green = png_ptr->gamma_table[png_ptr->background.green];\n               back.blue = png_ptr->gamma_table[png_ptr->background.blue];\n\n               back_1.red = png_ptr->gamma_to_1[png_ptr->background.red];\n               back_1.green = png_ptr->gamma_to_1[png_ptr->background.green];\n               back_1.blue = png_ptr->gamma_to_1[png_ptr->background.blue];\n            }\n            else\n            {\n               png_fixed_point g, gs;\n\n               switch (png_ptr->background_gamma_type)\n               {\n                  case PNG_BACKGROUND_GAMMA_SCREEN:\n                     g = (png_ptr->screen_gamma);\n                     gs = PNG_FP_1;\n                     break;\n\n                  case PNG_BACKGROUND_GAMMA_FILE:\n                     g = png_reciprocal(png_ptr->colorspace.gamma);\n                     gs = png_reciprocal2(png_ptr->colorspace.gamma,\n                        png_ptr->screen_gamma);\n                     break;\n\n                  case PNG_BACKGROUND_GAMMA_UNIQUE:\n                     g = png_reciprocal(png_ptr->background_gamma);\n                     gs = png_reciprocal2(png_ptr->background_gamma,\n                        png_ptr->screen_gamma);\n                     break;\n                  default:\n                     g = PNG_FP_1;    /* back_1 */\n                     gs = PNG_FP_1;   /* back */\n                     break;\n               }\n\n               if (png_gamma_significant(gs))\n               {\n                  back.red = png_gamma_8bit_correct(png_ptr->background.red,\n                      gs);\n                  back.green = png_gamma_8bit_correct(png_ptr->background.green,\n                      gs);\n                  back.blue = png_gamma_8bit_correct(png_ptr->background.blue,\n                      gs);\n               }\n\n               else\n               {\n                  back.red   = (png_byte)png_ptr->background.red;\n                  back.green = (png_byte)png_ptr->background.green;\n                  back.blue  = (png_byte)png_ptr->background.blue;\n               }\n\n               if (png_gamma_significant(g))\n               {\n                  back_1.red = png_gamma_8bit_correct(png_ptr->background.red,\n                     g);\n                  back_1.green = png_gamma_8bit_correct(\n                     png_ptr->background.green, g);\n                  back_1.blue = png_gamma_8bit_correct(png_ptr->background.blue,\n                     g);\n               }\n\n               else\n               {\n                  back_1.red   = (png_byte)png_ptr->background.red;\n                  back_1.green = (png_byte)png_ptr->background.green;\n                  back_1.blue  = (png_byte)png_ptr->background.blue;\n               }\n            }\n\n            for (i = 0; i < num_palette; i++)\n            {\n               if (i < (int)png_ptr->num_trans &&\n                   png_ptr->trans_alpha[i] != 0xff)\n               {\n                  if (png_ptr->trans_alpha[i] == 0)\n                  {\n                     palette[i] = back;\n                  }\n                  else /* if (png_ptr->trans_alpha[i] != 0xff) */\n                  {\n                     png_byte v, w;\n\n                     v = png_ptr->gamma_to_1[palette[i].red];\n                     png_composite(w, v, png_ptr->trans_alpha[i], back_1.red);\n                     palette[i].red = png_ptr->gamma_from_1[w];\n\n                     v = png_ptr->gamma_to_1[palette[i].green];\n                     png_composite(w, v, png_ptr->trans_alpha[i], back_1.green);\n                     palette[i].green = png_ptr->gamma_from_1[w];\n\n                     v = png_ptr->gamma_to_1[palette[i].blue];\n                     png_composite(w, v, png_ptr->trans_alpha[i], back_1.blue);\n                     palette[i].blue = png_ptr->gamma_from_1[w];\n                  }\n               }\n               else\n               {\n                  palette[i].red = png_ptr->gamma_table[palette[i].red];\n                  palette[i].green = png_ptr->gamma_table[palette[i].green];\n                  palette[i].blue = png_ptr->gamma_table[palette[i].blue];\n               }\n            }\n\n            /* Prevent the transformations being done again.\n             *\n             * NOTE: this is highly dubious; it removes the transformations in\n             * place.  This seems inconsistent with the general treatment of the\n             * transformations elsewhere.\n             */\n            png_ptr->transformations &= ~(PNG_COMPOSE | PNG_GAMMA);\n         } /* color_type == PNG_COLOR_TYPE_PALETTE */\n\n         /* if (png_ptr->background_gamma_type!=PNG_BACKGROUND_GAMMA_UNKNOWN) */\n         else /* color_type != PNG_COLOR_TYPE_PALETTE */\n         {\n            int gs_sig, g_sig;\n            png_fixed_point g = PNG_FP_1;  /* Correction to linear */\n            png_fixed_point gs = PNG_FP_1; /* Correction to screen */\n\n            switch (png_ptr->background_gamma_type)\n            {\n               case PNG_BACKGROUND_GAMMA_SCREEN:\n                  g = png_ptr->screen_gamma;\n                  /* gs = PNG_FP_1; */\n                  break;\n\n               case PNG_BACKGROUND_GAMMA_FILE:\n                  g = png_reciprocal(png_ptr->colorspace.gamma);\n                  gs = png_reciprocal2(png_ptr->colorspace.gamma,\n                     png_ptr->screen_gamma);\n                  break;\n\n               case PNG_BACKGROUND_GAMMA_UNIQUE:\n                  g = png_reciprocal(png_ptr->background_gamma);\n                  gs = png_reciprocal2(png_ptr->background_gamma,\n                      png_ptr->screen_gamma);\n                  break;\n\n               default:\n                  png_error(png_ptr, \"invalid background gamma type\");\n            }\n\n            g_sig = png_gamma_significant(g);\n            gs_sig = png_gamma_significant(gs);\n\n            if (g_sig)\n               png_ptr->background_1.gray = png_gamma_correct(png_ptr,\n                   png_ptr->background.gray, g);\n\n            if (gs_sig)\n               png_ptr->background.gray = png_gamma_correct(png_ptr,\n                   png_ptr->background.gray, gs);\n\n            if ((png_ptr->background.red != png_ptr->background.green) ||\n                (png_ptr->background.red != png_ptr->background.blue) ||\n                (png_ptr->background.red != png_ptr->background.gray))\n            {\n               /* RGB or RGBA with color background */\n               if (g_sig)\n               {\n                  png_ptr->background_1.red = png_gamma_correct(png_ptr,\n                      png_ptr->background.red, g);\n\n                  png_ptr->background_1.green = png_gamma_correct(png_ptr,\n                      png_ptr->background.green, g);\n\n                  png_ptr->background_1.blue = png_gamma_correct(png_ptr,\n                      png_ptr->background.blue, g);\n               }\n\n               if (gs_sig)\n               {\n                  png_ptr->background.red = png_gamma_correct(png_ptr,\n                      png_ptr->background.red, gs);\n\n                  png_ptr->background.green = png_gamma_correct(png_ptr,\n                      png_ptr->background.green, gs);\n\n                  png_ptr->background.blue = png_gamma_correct(png_ptr,\n                      png_ptr->background.blue, gs);\n               }\n            }\n\n            else\n            {\n               /* GRAY, GRAY ALPHA, RGB, or RGBA with gray background */\n               png_ptr->background_1.red = png_ptr->background_1.green\n                   = png_ptr->background_1.blue = png_ptr->background_1.gray;\n\n               png_ptr->background.red = png_ptr->background.green\n                   = png_ptr->background.blue = png_ptr->background.gray;\n            }\n\n            /* The background is now in screen gamma: */\n            png_ptr->background_gamma_type = PNG_BACKGROUND_GAMMA_SCREEN;\n         } /* color_type != PNG_COLOR_TYPE_PALETTE */\n      }/* png_ptr->transformations & PNG_BACKGROUND */\n\n      else\n      /* Transformation does not include PNG_BACKGROUND */\n#endif /* PNG_READ_BACKGROUND_SUPPORTED */\n      if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE\n#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED\n         /* RGB_TO_GRAY needs to have non-gamma-corrected values! */\n         && ((png_ptr->transformations & PNG_EXPAND) == 0 ||\n         (png_ptr->transformations & PNG_RGB_TO_GRAY) == 0)\n#endif\n         )\n      {\n         png_colorp palette = png_ptr->palette;\n         int num_palette = png_ptr->num_palette;\n         int i;\n\n         /* NOTE: there are other transformations that should probably be in\n          * here too.\n          */\n         for (i = 0; i < num_palette; i++)\n         {\n            palette[i].red = png_ptr->gamma_table[palette[i].red];\n            palette[i].green = png_ptr->gamma_table[palette[i].green];\n            palette[i].blue = png_ptr->gamma_table[palette[i].blue];\n         }\n\n         /* Done the gamma correction. */\n         png_ptr->transformations &= ~PNG_GAMMA;\n      } /* color_type == PALETTE && !PNG_BACKGROUND transformation */\n   }\n#ifdef PNG_READ_BACKGROUND_SUPPORTED\n   else\n#endif\n#endif /* PNG_READ_GAMMA_SUPPORTED */\n\n#ifdef PNG_READ_BACKGROUND_SUPPORTED\n   /* No GAMMA transformation (see the hanging else 4 lines above) */\n   if ((png_ptr->transformations & PNG_COMPOSE) &&\n       (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE))\n   {\n      int i;\n      int istop = (int)png_ptr->num_trans;\n      png_color back;\n      png_colorp palette = png_ptr->palette;\n\n      back.red   = (png_byte)png_ptr->background.red;\n      back.green = (png_byte)png_ptr->background.green;\n      back.blue  = (png_byte)png_ptr->background.blue;\n\n      for (i = 0; i < istop; i++)\n      {\n         if (png_ptr->trans_alpha[i] == 0)\n         {\n            palette[i] = back;\n         }\n\n         else if (png_ptr->trans_alpha[i] != 0xff)\n         {\n            /* The png_composite() macro is defined in png.h */\n            png_composite(palette[i].red, palette[i].red,\n                png_ptr->trans_alpha[i], back.red);\n\n            png_composite(palette[i].green, palette[i].green,\n                png_ptr->trans_alpha[i], back.green);\n\n            png_composite(palette[i].blue, palette[i].blue,\n                png_ptr->trans_alpha[i], back.blue);\n         }\n      }\n\n      png_ptr->transformations &= ~PNG_COMPOSE;\n   }\n#endif /* PNG_READ_BACKGROUND_SUPPORTED */\n\n#ifdef PNG_READ_SHIFT_SUPPORTED\n   if ((png_ptr->transformations & PNG_SHIFT) &&\n      !(png_ptr->transformations & PNG_EXPAND) &&\n       (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE))\n   {\n      int i;\n      int istop = png_ptr->num_palette;\n      int shift = 8 - png_ptr->sig_bit.red;\n\n      png_ptr->transformations &= ~PNG_SHIFT;\n\n      /* significant bits can be in the range 1 to 7 for a meaninful result, if\n       * the number of significant bits is 0 then no shift is done (this is an\n       * error condition which is silently ignored.)\n       */\n      if (shift > 0 && shift < 8)\n         for (i=0; i<istop; ++i)\n         {\n            int component = png_ptr->palette[i].red;\n\n            component >>= shift;\n            png_ptr->palette[i].red = (png_byte)component;\n         }\n\n      shift = 8 - png_ptr->sig_bit.green;\n      if (shift > 0 && shift < 8)\n         for (i=0; i<istop; ++i)\n         {\n            int component = png_ptr->palette[i].green;\n\n            component >>= shift;\n            png_ptr->palette[i].green = (png_byte)component;\n         }\n\n      shift = 8 - png_ptr->sig_bit.blue;\n      if (shift > 0 && shift < 8)\n         for (i=0; i<istop; ++i)\n         {\n            int component = png_ptr->palette[i].blue;\n\n            component >>= shift;\n            png_ptr->palette[i].blue = (png_byte)component;\n         }\n   }\n#endif  /* PNG_READ_SHIFT_SUPPORTED */\n}\n\n/* Modify the info structure to reflect the transformations.  The\n * info should be updated so a PNG file could be written with it,\n * assuming the transformations result in valid PNG data.\n */\nvoid /* PRIVATE */\npng_read_transform_info(png_structrp png_ptr, png_inforp info_ptr)\n{\n   png_debug(1, \"in png_read_transform_info\");\n\n#ifdef PNG_READ_EXPAND_SUPPORTED\n   if (png_ptr->transformations & PNG_EXPAND)\n   {\n      if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)\n      {\n         /* This check must match what actually happens in\n          * png_do_expand_palette; if it ever checks the tRNS chunk to see if\n          * it is all opaque we must do the same (at present it does not.)\n          */\n         if (png_ptr->num_trans > 0)\n            info_ptr->color_type = PNG_COLOR_TYPE_RGB_ALPHA;\n\n         else\n            info_ptr->color_type = PNG_COLOR_TYPE_RGB;\n\n         info_ptr->bit_depth = 8;\n         info_ptr->num_trans = 0;\n\n         if (png_ptr->palette == NULL)\n            png_error (png_ptr, \"Palette is NULL in indexed image\");\n      }\n      else\n      {\n         if (png_ptr->num_trans)\n         {\n            if (png_ptr->transformations & PNG_EXPAND_tRNS)\n               info_ptr->color_type |= PNG_COLOR_MASK_ALPHA;\n         }\n         if (info_ptr->bit_depth < 8)\n            info_ptr->bit_depth = 8;\n\n         info_ptr->num_trans = 0;\n      }\n   }\n#endif\n\n#if defined(PNG_READ_BACKGROUND_SUPPORTED) ||\\\n   defined(PNG_READ_ALPHA_MODE_SUPPORTED)\n   /* The following is almost certainly wrong unless the background value is in\n    * the screen space!\n    */\n   if (png_ptr->transformations & PNG_COMPOSE)\n      info_ptr->background = png_ptr->background;\n#endif\n\n#ifdef PNG_READ_GAMMA_SUPPORTED\n   /* The following used to be conditional on PNG_GAMMA (prior to 1.5.4),\n    * however it seems that the code in png_init_read_transformations, which has\n    * been called before this from png_read_update_info->png_read_start_row\n    * sometimes does the gamma transform and cancels the flag.\n    *\n    * TODO: this looks wrong; the info_ptr should end up with a gamma equal to\n    * the screen_gamma value.  The following probably results in weirdness if\n    * the info_ptr is used by the app after the rows have been read.\n    */\n   info_ptr->colorspace.gamma = png_ptr->colorspace.gamma;\n#endif\n\n   if (info_ptr->bit_depth == 16)\n   {\n#  ifdef PNG_READ_16BIT_SUPPORTED\n#     ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED\n         if (png_ptr->transformations & PNG_SCALE_16_TO_8)\n            info_ptr->bit_depth = 8;\n#     endif\n\n#     ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED\n         if (png_ptr->transformations & PNG_16_TO_8)\n            info_ptr->bit_depth = 8;\n#     endif\n\n#  else\n      /* No 16 bit support: force chopping 16-bit input down to 8, in this case\n       * the app program can chose if both APIs are available by setting the\n       * correct scaling to use.\n       */\n#     ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED\n         /* For compatibility with previous versions use the strip method by\n          * default.  This code works because if PNG_SCALE_16_TO_8 is already\n          * set the code below will do that in preference to the chop.\n          */\n         png_ptr->transformations |= PNG_16_TO_8;\n         info_ptr->bit_depth = 8;\n#     else\n\n#        ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED\n            png_ptr->transformations |= PNG_SCALE_16_TO_8;\n            info_ptr->bit_depth = 8;\n#        else\n\n            CONFIGURATION ERROR: you must enable at least one 16 to 8 method\n#        endif\n#    endif\n#endif /* !READ_16BIT_SUPPORTED */\n   }\n\n#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED\n   if (png_ptr->transformations & PNG_GRAY_TO_RGB)\n      info_ptr->color_type = (png_byte)(info_ptr->color_type |\n         PNG_COLOR_MASK_COLOR);\n#endif\n\n#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED\n   if (png_ptr->transformations & PNG_RGB_TO_GRAY)\n      info_ptr->color_type = (png_byte)(info_ptr->color_type &\n         ~PNG_COLOR_MASK_COLOR);\n#endif\n\n#ifdef PNG_READ_QUANTIZE_SUPPORTED\n   if (png_ptr->transformations & PNG_QUANTIZE)\n   {\n      if (((info_ptr->color_type == PNG_COLOR_TYPE_RGB) ||\n          (info_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA)) &&\n          png_ptr->palette_lookup && info_ptr->bit_depth == 8)\n      {\n         info_ptr->color_type = PNG_COLOR_TYPE_PALETTE;\n      }\n   }\n#endif\n\n#ifdef PNG_READ_EXPAND_16_SUPPORTED\n   if (png_ptr->transformations & PNG_EXPAND_16 && info_ptr->bit_depth == 8 &&\n      info_ptr->color_type != PNG_COLOR_TYPE_PALETTE)\n   {\n      info_ptr->bit_depth = 16;\n   }\n#endif\n\n#ifdef PNG_READ_PACK_SUPPORTED\n   if ((png_ptr->transformations & PNG_PACK) && (info_ptr->bit_depth < 8))\n      info_ptr->bit_depth = 8;\n#endif\n\n   if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)\n      info_ptr->channels = 1;\n\n   else if (info_ptr->color_type & PNG_COLOR_MASK_COLOR)\n      info_ptr->channels = 3;\n\n   else\n      info_ptr->channels = 1;\n\n#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED\n   if (png_ptr->transformations & PNG_STRIP_ALPHA)\n   {\n      info_ptr->color_type = (png_byte)(info_ptr->color_type &\n         ~PNG_COLOR_MASK_ALPHA);\n      info_ptr->num_trans = 0;\n   }\n#endif\n\n   if (info_ptr->color_type & PNG_COLOR_MASK_ALPHA)\n      info_ptr->channels++;\n\n#ifdef PNG_READ_FILLER_SUPPORTED\n   /* STRIP_ALPHA and FILLER allowed:  MASK_ALPHA bit stripped above */\n   if ((png_ptr->transformations & PNG_FILLER) &&\n       ((info_ptr->color_type == PNG_COLOR_TYPE_RGB) ||\n       (info_ptr->color_type == PNG_COLOR_TYPE_GRAY)))\n   {\n      info_ptr->channels++;\n      /* If adding a true alpha channel not just filler */\n      if (png_ptr->transformations & PNG_ADD_ALPHA)\n         info_ptr->color_type |= PNG_COLOR_MASK_ALPHA;\n   }\n#endif\n\n#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) && \\\ndefined(PNG_READ_USER_TRANSFORM_SUPPORTED)\n   if (png_ptr->transformations & PNG_USER_TRANSFORM)\n   {\n      if (info_ptr->bit_depth < png_ptr->user_transform_depth)\n         info_ptr->bit_depth = png_ptr->user_transform_depth;\n\n      if (info_ptr->channels < png_ptr->user_transform_channels)\n         info_ptr->channels = png_ptr->user_transform_channels;\n   }\n#endif\n\n   info_ptr->pixel_depth = (png_byte)(info_ptr->channels *\n       info_ptr->bit_depth);\n\n   info_ptr->rowbytes = PNG_ROWBYTES(info_ptr->pixel_depth, info_ptr->width);\n\n   /* Adding in 1.5.4: cache the above value in png_struct so that we can later\n    * check in png_rowbytes that the user buffer won't get overwritten.  Note\n    * that the field is not always set - if png_read_update_info isn't called\n    * the application has to either not do any transforms or get the calculation\n    * right itself.\n    */\n   png_ptr->info_rowbytes = info_ptr->rowbytes;\n\n#ifndef PNG_READ_EXPAND_SUPPORTED\n   if (png_ptr)\n      return;\n#endif\n}\n\n#ifdef PNG_READ_PACK_SUPPORTED\n/* Unpack pixels of 1, 2, or 4 bits per pixel into 1 byte per pixel,\n * without changing the actual values.  Thus, if you had a row with\n * a bit depth of 1, you would end up with bytes that only contained\n * the numbers 0 or 1.  If you would rather they contain 0 and 255, use\n * png_do_shift() after this.\n */\nstatic void\npng_do_unpack(png_row_infop row_info, png_bytep row)\n{\n   png_debug(1, \"in png_do_unpack\");\n\n   if (row_info->bit_depth < 8)\n   {\n      png_uint_32 i;\n      png_uint_32 row_width=row_info->width;\n\n      switch (row_info->bit_depth)\n      {\n         case 1:\n         {\n            png_bytep sp = row + (png_size_t)((row_width - 1) >> 3);\n            png_bytep dp = row + (png_size_t)row_width - 1;\n            png_uint_32 shift = 7 - (int)((row_width + 7) & 0x07);\n            for (i = 0; i < row_width; i++)\n            {\n               *dp = (png_byte)((*sp >> shift) & 0x01);\n\n               if (shift == 7)\n               {\n                  shift = 0;\n                  sp--;\n               }\n\n               else\n                  shift++;\n\n               dp--;\n            }\n            break;\n         }\n\n         case 2:\n         {\n\n            png_bytep sp = row + (png_size_t)((row_width - 1) >> 2);\n            png_bytep dp = row + (png_size_t)row_width - 1;\n            png_uint_32 shift = (int)((3 - ((row_width + 3) & 0x03)) << 1);\n            for (i = 0; i < row_width; i++)\n            {\n               *dp = (png_byte)((*sp >> shift) & 0x03);\n\n               if (shift == 6)\n               {\n                  shift = 0;\n                  sp--;\n               }\n\n               else\n                  shift += 2;\n\n               dp--;\n            }\n            break;\n         }\n\n         case 4:\n         {\n            png_bytep sp = row + (png_size_t)((row_width - 1) >> 1);\n            png_bytep dp = row + (png_size_t)row_width - 1;\n            png_uint_32 shift = (int)((1 - ((row_width + 1) & 0x01)) << 2);\n            for (i = 0; i < row_width; i++)\n            {\n               *dp = (png_byte)((*sp >> shift) & 0x0f);\n\n               if (shift == 4)\n               {\n                  shift = 0;\n                  sp--;\n               }\n\n               else\n                  shift = 4;\n\n               dp--;\n            }\n            break;\n         }\n\n         default:\n            break;\n      }\n      row_info->bit_depth = 8;\n      row_info->pixel_depth = (png_byte)(8 * row_info->channels);\n      row_info->rowbytes = row_width * row_info->channels;\n   }\n}\n#endif\n\n#ifdef PNG_READ_SHIFT_SUPPORTED\n/* Reverse the effects of png_do_shift.  This routine merely shifts the\n * pixels back to their significant bits values.  Thus, if you have\n * a row of bit depth 8, but only 5 are significant, this will shift\n * the values back to 0 through 31.\n */\nstatic void\npng_do_unshift(png_row_infop row_info, png_bytep row,\n    png_const_color_8p sig_bits)\n{\n   int color_type;\n\n   png_debug(1, \"in png_do_unshift\");\n\n   /* The palette case has already been handled in the _init routine. */\n   color_type = row_info->color_type;\n\n   if (color_type != PNG_COLOR_TYPE_PALETTE)\n   {\n      int shift[4];\n      int channels = 0;\n      int bit_depth = row_info->bit_depth;\n\n      if (color_type & PNG_COLOR_MASK_COLOR)\n      {\n         shift[channels++] = bit_depth - sig_bits->red;\n         shift[channels++] = bit_depth - sig_bits->green;\n         shift[channels++] = bit_depth - sig_bits->blue;\n      }\n\n      else\n      {\n         shift[channels++] = bit_depth - sig_bits->gray;\n      }\n\n      if (color_type & PNG_COLOR_MASK_ALPHA)\n      {\n         shift[channels++] = bit_depth - sig_bits->alpha;\n      }\n\n      {\n         int c, have_shift;\n\n         for (c = have_shift = 0; c < channels; ++c)\n         {\n            /* A shift of more than the bit depth is an error condition but it\n             * gets ignored here.\n             */\n            if (shift[c] <= 0 || shift[c] >= bit_depth)\n               shift[c] = 0;\n\n            else\n               have_shift = 1;\n         }\n\n         if (!have_shift)\n            return;\n      }\n\n      switch (bit_depth)\n      {\n         default:\n         /* Must be 1bpp gray: should not be here! */\n            /* NOTREACHED */\n            break;\n\n         case 2:\n         /* Must be 2bpp gray */\n         /* assert(channels == 1 && shift[0] == 1) */\n         {\n            png_bytep bp = row;\n            png_bytep bp_end = bp + row_info->rowbytes;\n\n            while (bp < bp_end)\n            {\n               int b = (*bp >> 1) & 0x55;\n               *bp++ = (png_byte)b;\n            }\n            break;\n         }\n\n         case 4:\n         /* Must be 4bpp gray */\n         /* assert(channels == 1) */\n         {\n            png_bytep bp = row;\n            png_bytep bp_end = bp + row_info->rowbytes;\n            int gray_shift = shift[0];\n            int mask =  0xf >> gray_shift;\n\n            mask |= mask << 4;\n\n            while (bp < bp_end)\n            {\n               int b = (*bp >> gray_shift) & mask;\n               *bp++ = (png_byte)b;\n            }\n            break;\n         }\n\n         case 8:\n         /* Single byte components, G, GA, RGB, RGBA */\n         {\n            png_bytep bp = row;\n            png_bytep bp_end = bp + row_info->rowbytes;\n            int channel = 0;\n\n            while (bp < bp_end)\n            {\n               int b = *bp >> shift[channel];\n               if (++channel >= channels)\n                  channel = 0;\n               *bp++ = (png_byte)b;\n            }\n            break;\n         }\n\n#ifdef PNG_READ_16BIT_SUPPORTED\n         case 16:\n         /* Double byte components, G, GA, RGB, RGBA */\n         {\n            png_bytep bp = row;\n            png_bytep bp_end = bp + row_info->rowbytes;\n            int channel = 0;\n\n            while (bp < bp_end)\n            {\n               int value = (bp[0] << 8) + bp[1];\n\n               value >>= shift[channel];\n               if (++channel >= channels)\n                  channel = 0;\n               *bp++ = (png_byte)(value >> 8);\n               *bp++ = (png_byte)(value & 0xff);\n            }\n            break;\n         }\n#endif\n      }\n   }\n}\n#endif\n\n#ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED\n/* Scale rows of bit depth 16 down to 8 accurately */\nstatic void\npng_do_scale_16_to_8(png_row_infop row_info, png_bytep row)\n{\n   png_debug(1, \"in png_do_scale_16_to_8\");\n\n   if (row_info->bit_depth == 16)\n   {\n      png_bytep sp = row; /* source */\n      png_bytep dp = row; /* destination */\n      png_bytep ep = sp + row_info->rowbytes; /* end+1 */\n\n      while (sp < ep)\n      {\n         /* The input is an array of 16 bit components, these must be scaled to\n          * 8 bits each.  For a 16 bit value V the required value (from the PNG\n          * specification) is:\n          *\n          *    (V * 255) / 65535\n          *\n          * This reduces to round(V / 257), or floor((V + 128.5)/257)\n          *\n          * Represent V as the two byte value vhi.vlo.  Make a guess that the\n          * result is the top byte of V, vhi, then the correction to this value\n          * is:\n          *\n          *    error = floor(((V-vhi.vhi) + 128.5) / 257)\n          *          = floor(((vlo-vhi) + 128.5) / 257)\n          *\n          * This can be approximated using integer arithmetic (and a signed\n          * shift):\n          *\n          *    error = (vlo-vhi+128) >> 8;\n          *\n          * The approximate differs from the exact answer only when (vlo-vhi) is\n          * 128; it then gives a correction of +1 when the exact correction is\n          * 0.  This gives 128 errors.  The exact answer (correct for all 16 bit\n          * input values) is:\n          *\n          *    error = (vlo-vhi+128)*65535 >> 24;\n          *\n          * An alternative arithmetic calculation which also gives no errors is:\n          *\n          *    (V * 255 + 32895) >> 16\n          */\n\n         png_int_32 tmp = *sp++; /* must be signed! */\n         tmp += (((int)*sp++ - tmp + 128) * 65535) >> 24;\n         *dp++ = (png_byte)tmp;\n      }\n\n      row_info->bit_depth = 8;\n      row_info->pixel_depth = (png_byte)(8 * row_info->channels);\n      row_info->rowbytes = row_info->width * row_info->channels;\n   }\n}\n#endif\n\n#ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED\nstatic void\n/* Simply discard the low byte.  This was the default behavior prior\n * to libpng-1.5.4.\n */\npng_do_chop(png_row_infop row_info, png_bytep row)\n{\n   png_debug(1, \"in png_do_chop\");\n\n   if (row_info->bit_depth == 16)\n   {\n      png_bytep sp = row; /* source */\n      png_bytep dp = row; /* destination */\n      png_bytep ep = sp + row_info->rowbytes; /* end+1 */\n\n      while (sp < ep)\n      {\n         *dp++ = *sp;\n         sp += 2; /* skip low byte */\n      }\n\n      row_info->bit_depth = 8;\n      row_info->pixel_depth = (png_byte)(8 * row_info->channels);\n      row_info->rowbytes = row_info->width * row_info->channels;\n   }\n}\n#endif\n\n#ifdef PNG_READ_SWAP_ALPHA_SUPPORTED\nstatic void\npng_do_read_swap_alpha(png_row_infop row_info, png_bytep row)\n{\n   png_debug(1, \"in png_do_read_swap_alpha\");\n\n   {\n      png_uint_32 row_width = row_info->width;\n      if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)\n      {\n         /* This converts from RGBA to ARGB */\n         if (row_info->bit_depth == 8)\n         {\n            png_bytep sp = row + row_info->rowbytes;\n            png_bytep dp = sp;\n            png_byte save;\n            png_uint_32 i;\n\n            for (i = 0; i < row_width; i++)\n            {\n               save = *(--sp);\n               *(--dp) = *(--sp);\n               *(--dp) = *(--sp);\n               *(--dp) = *(--sp);\n               *(--dp) = save;\n            }\n         }\n\n#ifdef PNG_READ_16BIT_SUPPORTED\n         /* This converts from RRGGBBAA to AARRGGBB */\n         else\n         {\n            png_bytep sp = row + row_info->rowbytes;\n            png_bytep dp = sp;\n            png_byte save[2];\n            png_uint_32 i;\n\n            for (i = 0; i < row_width; i++)\n            {\n               save[0] = *(--sp);\n               save[1] = *(--sp);\n               *(--dp) = *(--sp);\n               *(--dp) = *(--sp);\n               *(--dp) = *(--sp);\n               *(--dp) = *(--sp);\n               *(--dp) = *(--sp);\n               *(--dp) = *(--sp);\n               *(--dp) = save[0];\n               *(--dp) = save[1];\n            }\n         }\n#endif\n      }\n\n      else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)\n      {\n         /* This converts from GA to AG */\n         if (row_info->bit_depth == 8)\n         {\n            png_bytep sp = row + row_info->rowbytes;\n            png_bytep dp = sp;\n            png_byte save;\n            png_uint_32 i;\n\n            for (i = 0; i < row_width; i++)\n            {\n               save = *(--sp);\n               *(--dp) = *(--sp);\n               *(--dp) = save;\n            }\n         }\n\n#ifdef PNG_READ_16BIT_SUPPORTED\n         /* This converts from GGAA to AAGG */\n         else\n         {\n            png_bytep sp = row + row_info->rowbytes;\n            png_bytep dp = sp;\n            png_byte save[2];\n            png_uint_32 i;\n\n            for (i = 0; i < row_width; i++)\n            {\n               save[0] = *(--sp);\n               save[1] = *(--sp);\n               *(--dp) = *(--sp);\n               *(--dp) = *(--sp);\n               *(--dp) = save[0];\n               *(--dp) = save[1];\n            }\n         }\n#endif\n      }\n   }\n}\n#endif\n\n#ifdef PNG_READ_INVERT_ALPHA_SUPPORTED\nstatic void\npng_do_read_invert_alpha(png_row_infop row_info, png_bytep row)\n{\n   png_uint_32 row_width;\n   png_debug(1, \"in png_do_read_invert_alpha\");\n\n   row_width = row_info->width;\n   if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)\n   {\n      if (row_info->bit_depth == 8)\n      {\n         /* This inverts the alpha channel in RGBA */\n         png_bytep sp = row + row_info->rowbytes;\n         png_bytep dp = sp;\n         png_uint_32 i;\n\n         for (i = 0; i < row_width; i++)\n         {\n            *(--dp) = (png_byte)(255 - *(--sp));\n\n/*          This does nothing:\n            *(--dp) = *(--sp);\n            *(--dp) = *(--sp);\n            *(--dp) = *(--sp);\n            We can replace it with:\n*/\n            sp-=3;\n            dp=sp;\n         }\n      }\n\n#ifdef PNG_READ_16BIT_SUPPORTED\n      /* This inverts the alpha channel in RRGGBBAA */\n      else\n      {\n         png_bytep sp = row + row_info->rowbytes;\n         png_bytep dp = sp;\n         png_uint_32 i;\n\n         for (i = 0; i < row_width; i++)\n         {\n            *(--dp) = (png_byte)(255 - *(--sp));\n            *(--dp) = (png_byte)(255 - *(--sp));\n\n/*          This does nothing:\n            *(--dp) = *(--sp);\n            *(--dp) = *(--sp);\n            *(--dp) = *(--sp);\n            *(--dp) = *(--sp);\n            *(--dp) = *(--sp);\n            *(--dp) = *(--sp);\n            We can replace it with:\n*/\n            sp-=6;\n            dp=sp;\n         }\n      }\n#endif\n   }\n   else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)\n   {\n      if (row_info->bit_depth == 8)\n      {\n         /* This inverts the alpha channel in GA */\n         png_bytep sp = row + row_info->rowbytes;\n         png_bytep dp = sp;\n         png_uint_32 i;\n\n         for (i = 0; i < row_width; i++)\n         {\n            *(--dp) = (png_byte)(255 - *(--sp));\n            *(--dp) = *(--sp);\n         }\n      }\n\n#ifdef PNG_READ_16BIT_SUPPORTED\n      else\n      {\n         /* This inverts the alpha channel in GGAA */\n         png_bytep sp  = row + row_info->rowbytes;\n         png_bytep dp = sp;\n         png_uint_32 i;\n\n         for (i = 0; i < row_width; i++)\n         {\n            *(--dp) = (png_byte)(255 - *(--sp));\n            *(--dp) = (png_byte)(255 - *(--sp));\n/*\n            *(--dp) = *(--sp);\n            *(--dp) = *(--sp);\n*/\n            sp-=2;\n            dp=sp;\n         }\n      }\n#endif\n   }\n}\n#endif\n\n#ifdef PNG_READ_FILLER_SUPPORTED\n/* Add filler channel if we have RGB color */\nstatic void\npng_do_read_filler(png_row_infop row_info, png_bytep row,\n    png_uint_32 filler, png_uint_32 flags)\n{\n   png_uint_32 i;\n   png_uint_32 row_width = row_info->width;\n\n#ifdef PNG_READ_16BIT_SUPPORTED\n   png_byte hi_filler = (png_byte)((filler>>8) & 0xff);\n#endif\n   png_byte lo_filler = (png_byte)(filler & 0xff);\n\n   png_debug(1, \"in png_do_read_filler\");\n\n   if (\n       row_info->color_type == PNG_COLOR_TYPE_GRAY)\n   {\n      if (row_info->bit_depth == 8)\n      {\n         if (flags & PNG_FLAG_FILLER_AFTER)\n         {\n            /* This changes the data from G to GX */\n            png_bytep sp = row + (png_size_t)row_width;\n            png_bytep dp =  sp + (png_size_t)row_width;\n            for (i = 1; i < row_width; i++)\n            {\n               *(--dp) = lo_filler;\n               *(--dp) = *(--sp);\n            }\n            *(--dp) = lo_filler;\n            row_info->channels = 2;\n            row_info->pixel_depth = 16;\n            row_info->rowbytes = row_width * 2;\n         }\n\n         else\n         {\n            /* This changes the data from G to XG */\n            png_bytep sp = row + (png_size_t)row_width;\n            png_bytep dp = sp  + (png_size_t)row_width;\n            for (i = 0; i < row_width; i++)\n            {\n               *(--dp) = *(--sp);\n               *(--dp) = lo_filler;\n            }\n            row_info->channels = 2;\n            row_info->pixel_depth = 16;\n            row_info->rowbytes = row_width * 2;\n         }\n      }\n\n#ifdef PNG_READ_16BIT_SUPPORTED\n      else if (row_info->bit_depth == 16)\n      {\n         if (flags & PNG_FLAG_FILLER_AFTER)\n         {\n            /* This changes the data from GG to GGXX */\n            png_bytep sp = row + (png_size_t)row_width * 2;\n            png_bytep dp = sp  + (png_size_t)row_width * 2;\n            for (i = 1; i < row_width; i++)\n            {\n               *(--dp) = hi_filler;\n               *(--dp) = lo_filler;\n               *(--dp) = *(--sp);\n               *(--dp) = *(--sp);\n            }\n            *(--dp) = hi_filler;\n            *(--dp) = lo_filler;\n            row_info->channels = 2;\n            row_info->pixel_depth = 32;\n            row_info->rowbytes = row_width * 4;\n         }\n\n         else\n         {\n            /* This changes the data from GG to XXGG */\n            png_bytep sp = row + (png_size_t)row_width * 2;\n            png_bytep dp = sp  + (png_size_t)row_width * 2;\n            for (i = 0; i < row_width; i++)\n            {\n               *(--dp) = *(--sp);\n               *(--dp) = *(--sp);\n               *(--dp) = hi_filler;\n               *(--dp) = lo_filler;\n            }\n            row_info->channels = 2;\n            row_info->pixel_depth = 32;\n            row_info->rowbytes = row_width * 4;\n         }\n      }\n#endif\n   } /* COLOR_TYPE == GRAY */\n   else if (row_info->color_type == PNG_COLOR_TYPE_RGB)\n   {\n      if (row_info->bit_depth == 8)\n      {\n         if (flags & PNG_FLAG_FILLER_AFTER)\n         {\n            /* This changes the data from RGB to RGBX */\n            png_bytep sp = row + (png_size_t)row_width * 3;\n            png_bytep dp = sp  + (png_size_t)row_width;\n            for (i = 1; i < row_width; i++)\n            {\n               *(--dp) = lo_filler;\n               *(--dp) = *(--sp);\n               *(--dp) = *(--sp);\n               *(--dp) = *(--sp);\n            }\n            *(--dp) = lo_filler;\n            row_info->channels = 4;\n            row_info->pixel_depth = 32;\n            row_info->rowbytes = row_width * 4;\n         }\n\n         else\n         {\n            /* This changes the data from RGB to XRGB */\n            png_bytep sp = row + (png_size_t)row_width * 3;\n            png_bytep dp = sp + (png_size_t)row_width;\n            for (i = 0; i < row_width; i++)\n            {\n               *(--dp) = *(--sp);\n               *(--dp) = *(--sp);\n               *(--dp) = *(--sp);\n               *(--dp) = lo_filler;\n            }\n            row_info->channels = 4;\n            row_info->pixel_depth = 32;\n            row_info->rowbytes = row_width * 4;\n         }\n      }\n\n#ifdef PNG_READ_16BIT_SUPPORTED\n      else if (row_info->bit_depth == 16)\n      {\n         if (flags & PNG_FLAG_FILLER_AFTER)\n         {\n            /* This changes the data from RRGGBB to RRGGBBXX */\n            png_bytep sp = row + (png_size_t)row_width * 6;\n            png_bytep dp = sp  + (png_size_t)row_width * 2;\n            for (i = 1; i < row_width; i++)\n            {\n               *(--dp) = hi_filler;\n               *(--dp) = lo_filler;\n               *(--dp) = *(--sp);\n               *(--dp) = *(--sp);\n               *(--dp) = *(--sp);\n               *(--dp) = *(--sp);\n               *(--dp) = *(--sp);\n               *(--dp) = *(--sp);\n            }\n            *(--dp) = hi_filler;\n            *(--dp) = lo_filler;\n            row_info->channels = 4;\n            row_info->pixel_depth = 64;\n            row_info->rowbytes = row_width * 8;\n         }\n\n         else\n         {\n            /* This changes the data from RRGGBB to XXRRGGBB */\n            png_bytep sp = row + (png_size_t)row_width * 6;\n            png_bytep dp = sp  + (png_size_t)row_width * 2;\n            for (i = 0; i < row_width; i++)\n            {\n               *(--dp) = *(--sp);\n               *(--dp) = *(--sp);\n               *(--dp) = *(--sp);\n               *(--dp) = *(--sp);\n               *(--dp) = *(--sp);\n               *(--dp) = *(--sp);\n               *(--dp) = hi_filler;\n               *(--dp) = lo_filler;\n            }\n\n            row_info->channels = 4;\n            row_info->pixel_depth = 64;\n            row_info->rowbytes = row_width * 8;\n         }\n      }\n#endif\n   } /* COLOR_TYPE == RGB */\n}\n#endif\n\n#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED\n/* Expand grayscale files to RGB, with or without alpha */\nstatic void\npng_do_gray_to_rgb(png_row_infop row_info, png_bytep row)\n{\n   png_uint_32 i;\n   png_uint_32 row_width = row_info->width;\n\n   png_debug(1, \"in png_do_gray_to_rgb\");\n\n   if (row_info->bit_depth >= 8 &&\n       !(row_info->color_type & PNG_COLOR_MASK_COLOR))\n   {\n      if (row_info->color_type == PNG_COLOR_TYPE_GRAY)\n      {\n         if (row_info->bit_depth == 8)\n         {\n            /* This changes G to RGB */\n            png_bytep sp = row + (png_size_t)row_width - 1;\n            png_bytep dp = sp  + (png_size_t)row_width * 2;\n            for (i = 0; i < row_width; i++)\n            {\n               *(dp--) = *sp;\n               *(dp--) = *sp;\n               *(dp--) = *(sp--);\n            }\n         }\n\n         else\n         {\n            /* This changes GG to RRGGBB */\n            png_bytep sp = row + (png_size_t)row_width * 2 - 1;\n            png_bytep dp = sp  + (png_size_t)row_width * 4;\n            for (i = 0; i < row_width; i++)\n            {\n               *(dp--) = *sp;\n               *(dp--) = *(sp - 1);\n               *(dp--) = *sp;\n               *(dp--) = *(sp - 1);\n               *(dp--) = *(sp--);\n               *(dp--) = *(sp--);\n            }\n         }\n      }\n\n      else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)\n      {\n         if (row_info->bit_depth == 8)\n         {\n            /* This changes GA to RGBA */\n            png_bytep sp = row + (png_size_t)row_width * 2 - 1;\n            png_bytep dp = sp  + (png_size_t)row_width * 2;\n            for (i = 0; i < row_width; i++)\n            {\n               *(dp--) = *(sp--);\n               *(dp--) = *sp;\n               *(dp--) = *sp;\n               *(dp--) = *(sp--);\n            }\n         }\n\n         else\n         {\n            /* This changes GGAA to RRGGBBAA */\n            png_bytep sp = row + (png_size_t)row_width * 4 - 1;\n            png_bytep dp = sp  + (png_size_t)row_width * 4;\n            for (i = 0; i < row_width; i++)\n            {\n               *(dp--) = *(sp--);\n               *(dp--) = *(sp--);\n               *(dp--) = *sp;\n               *(dp--) = *(sp - 1);\n               *(dp--) = *sp;\n               *(dp--) = *(sp - 1);\n               *(dp--) = *(sp--);\n               *(dp--) = *(sp--);\n            }\n         }\n      }\n      row_info->channels = (png_byte)(row_info->channels + 2);\n      row_info->color_type |= PNG_COLOR_MASK_COLOR;\n      row_info->pixel_depth = (png_byte)(row_info->channels *\n          row_info->bit_depth);\n      row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, row_width);\n   }\n}\n#endif\n\n#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED\n/* Reduce RGB files to grayscale, with or without alpha\n * using the equation given in Poynton's ColorFAQ of 1998-01-04 at\n * <http://www.inforamp.net/~poynton/>  (THIS LINK IS DEAD June 2008 but\n * versions dated 1998 through November 2002 have been archived at\n * http://web.archive.org/web/20000816232553/http://www.inforamp.net/\n * ~poynton/notes/colour_and_gamma/ColorFAQ.txt )\n * Charles Poynton poynton at poynton.com\n *\n *     Y = 0.212671 * R + 0.715160 * G + 0.072169 * B\n *\n *  which can be expressed with integers as\n *\n *     Y = (6969 * R + 23434 * G + 2365 * B)/32768\n *\n * Poynton's current link (as of January 2003 through July 2011):\n * <http://www.poynton.com/notes/colour_and_gamma/>\n * has changed the numbers slightly:\n *\n *     Y = 0.2126*R + 0.7152*G + 0.0722*B\n *\n *  which can be expressed with integers as\n *\n *     Y = (6966 * R + 23436 * G + 2366 * B)/32768\n *\n *  Historically, however, libpng uses numbers derived from the ITU-R Rec 709\n *  end point chromaticities and the D65 white point.  Depending on the\n *  precision used for the D65 white point this produces a variety of different\n *  numbers, however if the four decimal place value used in ITU-R Rec 709 is\n *  used (0.3127,0.3290) the Y calculation would be:\n *\n *     Y = (6968 * R + 23435 * G + 2366 * B)/32768\n *\n *  While this is correct the rounding results in an overflow for white, because\n *  the sum of the rounded coefficients is 32769, not 32768.  Consequently\n *  libpng uses, instead, the closest non-overflowing approximation:\n *\n *     Y = (6968 * R + 23434 * G + 2366 * B)/32768\n *\n *  Starting with libpng-1.5.5, if the image being converted has a cHRM chunk\n *  (including an sRGB chunk) then the chromaticities are used to calculate the\n *  coefficients.  See the chunk handling in pngrutil.c for more information.\n *\n *  In all cases the calculation is to be done in a linear colorspace.  If no\n *  gamma information is available to correct the encoding of the original RGB\n *  values this results in an implicit assumption that the original PNG RGB\n *  values were linear.\n *\n *  Other integer coefficents can be used via png_set_rgb_to_gray().  Because\n *  the API takes just red and green coefficients the blue coefficient is\n *  calculated to make the sum 32768.  This will result in different rounding\n *  to that used above.\n */\nstatic int\npng_do_rgb_to_gray(png_structrp png_ptr, png_row_infop row_info, png_bytep row)\n\n{\n   int rgb_error = 0;\n\n   png_debug(1, \"in png_do_rgb_to_gray\");\n\n   if (!(row_info->color_type & PNG_COLOR_MASK_PALETTE) &&\n       (row_info->color_type & PNG_COLOR_MASK_COLOR))\n   {\n      PNG_CONST png_uint_32 rc = png_ptr->rgb_to_gray_red_coeff;\n      PNG_CONST png_uint_32 gc = png_ptr->rgb_to_gray_green_coeff;\n      PNG_CONST png_uint_32 bc = 32768 - rc - gc;\n      PNG_CONST png_uint_32 row_width = row_info->width;\n      PNG_CONST int have_alpha =\n         (row_info->color_type & PNG_COLOR_MASK_ALPHA) != 0;\n\n      if (row_info->bit_depth == 8)\n      {\n#ifdef PNG_READ_GAMMA_SUPPORTED\n         /* Notice that gamma to/from 1 are not necessarily inverses (if\n          * there is an overall gamma correction).  Prior to 1.5.5 this code\n          * checked the linearized values for equality; this doesn't match\n          * the documentation, the original values must be checked.\n          */\n         if (png_ptr->gamma_from_1 != NULL && png_ptr->gamma_to_1 != NULL)\n         {\n            png_bytep sp = row;\n            png_bytep dp = row;\n            png_uint_32 i;\n\n            for (i = 0; i < row_width; i++)\n            {\n               png_byte red   = *(sp++);\n               png_byte green = *(sp++);\n               png_byte blue  = *(sp++);\n\n               if (red != green || red != blue)\n               {\n                  red = png_ptr->gamma_to_1[red];\n                  green = png_ptr->gamma_to_1[green];\n                  blue = png_ptr->gamma_to_1[blue];\n\n                  rgb_error |= 1;\n                  *(dp++) = png_ptr->gamma_from_1[\n                      (rc*red + gc*green + bc*blue + 16384)>>15];\n               }\n\n               else\n               {\n                  /* If there is no overall correction the table will not be\n                   * set.\n                   */\n                  if (png_ptr->gamma_table != NULL)\n                     red = png_ptr->gamma_table[red];\n\n                  *(dp++) = red;\n               }\n\n               if (have_alpha)\n                  *(dp++) = *(sp++);\n            }\n         }\n         else\n#endif\n         {\n            png_bytep sp = row;\n            png_bytep dp = row;\n            png_uint_32 i;\n\n            for (i = 0; i < row_width; i++)\n            {\n               png_byte red   = *(sp++);\n               png_byte green = *(sp++);\n               png_byte blue  = *(sp++);\n\n               if (red != green || red != blue)\n               {\n                  rgb_error |= 1;\n                  /* NOTE: this is the historical approach which simply\n                   * truncates the results.\n                   */\n                  *(dp++) = (png_byte)((rc*red + gc*green + bc*blue)>>15);\n               }\n\n               else\n                  *(dp++) = red;\n\n               if (have_alpha)\n                  *(dp++) = *(sp++);\n            }\n         }\n      }\n\n      else /* RGB bit_depth == 16 */\n      {\n#ifdef PNG_READ_GAMMA_SUPPORTED\n         if (png_ptr->gamma_16_to_1 != NULL && png_ptr->gamma_16_from_1 != NULL)\n         {\n            png_bytep sp = row;\n            png_bytep dp = row;\n            png_uint_32 i;\n\n            for (i = 0; i < row_width; i++)\n            {\n               png_uint_16 red, green, blue, w;\n\n               red   = (png_uint_16)(((*(sp))<<8) | *(sp + 1)); sp += 2;\n               green = (png_uint_16)(((*(sp))<<8) | *(sp + 1)); sp += 2;\n               blue  = (png_uint_16)(((*(sp))<<8) | *(sp + 1)); sp += 2;\n\n               if (red == green && red == blue)\n               {\n                  if (png_ptr->gamma_16_table != NULL)\n                     w = png_ptr->gamma_16_table[(red&0xff)\n                         >> png_ptr->gamma_shift][red>>8];\n\n                  else\n                     w = red;\n               }\n\n               else\n               {\n                  png_uint_16 red_1   = png_ptr->gamma_16_to_1[(red&0xff)\n                      >> png_ptr->gamma_shift][red>>8];\n                  png_uint_16 green_1 =\n                      png_ptr->gamma_16_to_1[(green&0xff) >>\n                      png_ptr->gamma_shift][green>>8];\n                  png_uint_16 blue_1  = png_ptr->gamma_16_to_1[(blue&0xff)\n                      >> png_ptr->gamma_shift][blue>>8];\n                  png_uint_16 gray16  = (png_uint_16)((rc*red_1 + gc*green_1\n                      + bc*blue_1 + 16384)>>15);\n                  w = png_ptr->gamma_16_from_1[(gray16&0xff) >>\n                      png_ptr->gamma_shift][gray16 >> 8];\n                  rgb_error |= 1;\n               }\n\n               *(dp++) = (png_byte)((w>>8) & 0xff);\n               *(dp++) = (png_byte)(w & 0xff);\n\n               if (have_alpha)\n               {\n                  *(dp++) = *(sp++);\n                  *(dp++) = *(sp++);\n               }\n            }\n         }\n         else\n#endif\n         {\n            png_bytep sp = row;\n            png_bytep dp = row;\n            png_uint_32 i;\n\n            for (i = 0; i < row_width; i++)\n            {\n               png_uint_16 red, green, blue, gray16;\n\n               red   = (png_uint_16)(((*(sp))<<8) | *(sp + 1)); sp += 2;\n               green = (png_uint_16)(((*(sp))<<8) | *(sp + 1)); sp += 2;\n               blue  = (png_uint_16)(((*(sp))<<8) | *(sp + 1)); sp += 2;\n\n               if (red != green || red != blue)\n                  rgb_error |= 1;\n\n               /* From 1.5.5 in the 16 bit case do the accurate conversion even\n                * in the 'fast' case - this is because this is where the code\n                * ends up when handling linear 16 bit data.\n                */\n               gray16  = (png_uint_16)((rc*red + gc*green + bc*blue + 16384) >>\n                  15);\n               *(dp++) = (png_byte)((gray16>>8) & 0xff);\n               *(dp++) = (png_byte)(gray16 & 0xff);\n\n               if (have_alpha)\n               {\n                  *(dp++) = *(sp++);\n                  *(dp++) = *(sp++);\n               }\n            }\n         }\n      }\n\n      row_info->channels = (png_byte)(row_info->channels - 2);\n      row_info->color_type = (png_byte)(row_info->color_type &\n          ~PNG_COLOR_MASK_COLOR);\n      row_info->pixel_depth = (png_byte)(row_info->channels *\n          row_info->bit_depth);\n      row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, row_width);\n   }\n   return rgb_error;\n}\n#endif\n\n#if defined(PNG_READ_BACKGROUND_SUPPORTED) ||\\\n   defined(PNG_READ_ALPHA_MODE_SUPPORTED)\n/* Replace any alpha or transparency with the supplied background color.\n * \"background\" is already in the screen gamma, while \"background_1\" is\n * at a gamma of 1.0.  Paletted files have already been taken care of.\n */\nstatic void\npng_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr)\n{\n#ifdef PNG_READ_GAMMA_SUPPORTED\n   png_const_bytep gamma_table = png_ptr->gamma_table;\n   png_const_bytep gamma_from_1 = png_ptr->gamma_from_1;\n   png_const_bytep gamma_to_1 = png_ptr->gamma_to_1;\n   png_const_uint_16pp gamma_16 = png_ptr->gamma_16_table;\n   png_const_uint_16pp gamma_16_from_1 = png_ptr->gamma_16_from_1;\n   png_const_uint_16pp gamma_16_to_1 = png_ptr->gamma_16_to_1;\n   int gamma_shift = png_ptr->gamma_shift;\n   int optimize = (png_ptr->flags & PNG_FLAG_OPTIMIZE_ALPHA) != 0;\n#endif\n\n   png_bytep sp;\n   png_uint_32 i;\n   png_uint_32 row_width = row_info->width;\n   int shift;\n\n   png_debug(1, \"in png_do_compose\");\n\n   {\n      switch (row_info->color_type)\n      {\n         case PNG_COLOR_TYPE_GRAY:\n         {\n            switch (row_info->bit_depth)\n            {\n               case 1:\n               {\n                  sp = row;\n                  shift = 7;\n                  for (i = 0; i < row_width; i++)\n                  {\n                     if ((png_uint_16)((*sp >> shift) & 0x01)\n                        == png_ptr->trans_color.gray)\n                     {\n                        unsigned int tmp = *sp & (0x7f7f >> (7 - shift));\n                        tmp |= png_ptr->background.gray << shift;\n                        *sp = (png_byte)(tmp & 0xff);\n                     }\n\n                     if (!shift)\n                     {\n                        shift = 7;\n                        sp++;\n                     }\n\n                     else\n                        shift--;\n                  }\n                  break;\n               }\n\n               case 2:\n               {\n#ifdef PNG_READ_GAMMA_SUPPORTED\n                  if (gamma_table != NULL)\n                  {\n                     sp = row;\n                     shift = 6;\n                     for (i = 0; i < row_width; i++)\n                     {\n                        if ((png_uint_16)((*sp >> shift) & 0x03)\n                            == png_ptr->trans_color.gray)\n                        {\n                           unsigned int tmp = *sp & (0x3f3f >> (6 - shift));\n                           tmp |= png_ptr->background.gray << shift;\n                           *sp = (png_byte)(tmp & 0xff);\n                        }\n\n                        else\n                        {\n                           unsigned int p = (*sp >> shift) & 0x03;\n                           unsigned int g = (gamma_table [p | (p << 2) |\n                               (p << 4) | (p << 6)] >> 6) & 0x03;\n                           unsigned int tmp = *sp & (0x3f3f >> (6 - shift));\n                           tmp |= g << shift;\n                           *sp = (png_byte)(tmp & 0xff);\n                        }\n\n                        if (!shift)\n                        {\n                           shift = 6;\n                           sp++;\n                        }\n\n                        else\n                           shift -= 2;\n                     }\n                  }\n\n                  else\n#endif\n                  {\n                     sp = row;\n                     shift = 6;\n                     for (i = 0; i < row_width; i++)\n                     {\n                        if ((png_uint_16)((*sp >> shift) & 0x03)\n                            == png_ptr->trans_color.gray)\n                        {\n                           unsigned int tmp = *sp & (0x3f3f >> (6 - shift));\n                           tmp |= png_ptr->background.gray << shift;\n                           *sp = (png_byte)(tmp & 0xff);\n                        }\n\n                        if (!shift)\n                        {\n                           shift = 6;\n                           sp++;\n                        }\n\n                        else\n                           shift -= 2;\n                     }\n                  }\n                  break;\n               }\n\n               case 4:\n               {\n#ifdef PNG_READ_GAMMA_SUPPORTED\n                  if (gamma_table != NULL)\n                  {\n                     sp = row;\n                     shift = 4;\n                     for (i = 0; i < row_width; i++)\n                     {\n                        if ((png_uint_16)((*sp >> shift) & 0x0f)\n                            == png_ptr->trans_color.gray)\n                        {\n                           unsigned int tmp = *sp & (0xf0f >> (4 - shift));\n                           tmp |= png_ptr->background.gray << shift;\n                           *sp = (png_byte)(tmp & 0xff);\n                        }\n\n                        else\n                        {\n                           unsigned int p = (*sp >> shift) & 0x0f;\n                           unsigned int g = (gamma_table[p | (p << 4)] >> 4) &\n                              0x0f;\n                           unsigned int tmp = *sp & (0xf0f >> (4 - shift));\n                           tmp |= g << shift;\n                           *sp = (png_byte)(tmp & 0xff);\n                        }\n\n                        if (!shift)\n                        {\n                           shift = 4;\n                           sp++;\n                        }\n\n                        else\n                           shift -= 4;\n                     }\n                  }\n\n                  else\n#endif\n                  {\n                     sp = row;\n                     shift = 4;\n                     for (i = 0; i < row_width; i++)\n                     {\n                        if ((png_uint_16)((*sp >> shift) & 0x0f)\n                            == png_ptr->trans_color.gray)\n                        {\n                           unsigned int tmp = *sp & (0xf0f >> (4 - shift));\n                           tmp |= png_ptr->background.gray << shift;\n                           *sp = (png_byte)(tmp & 0xff);\n                        }\n\n                        if (!shift)\n                        {\n                           shift = 4;\n                           sp++;\n                        }\n\n                        else\n                           shift -= 4;\n                     }\n                  }\n                  break;\n               }\n\n               case 8:\n               {\n#ifdef PNG_READ_GAMMA_SUPPORTED\n                  if (gamma_table != NULL)\n                  {\n                     sp = row;\n                     for (i = 0; i < row_width; i++, sp++)\n                     {\n                        if (*sp == png_ptr->trans_color.gray)\n                           *sp = (png_byte)png_ptr->background.gray;\n\n                        else\n                           *sp = gamma_table[*sp];\n                     }\n                  }\n                  else\n#endif\n                  {\n                     sp = row;\n                     for (i = 0; i < row_width; i++, sp++)\n                     {\n                        if (*sp == png_ptr->trans_color.gray)\n                           *sp = (png_byte)png_ptr->background.gray;\n                     }\n                  }\n                  break;\n               }\n\n               case 16:\n               {\n#ifdef PNG_READ_GAMMA_SUPPORTED\n                  if (gamma_16 != NULL)\n                  {\n                     sp = row;\n                     for (i = 0; i < row_width; i++, sp += 2)\n                     {\n                        png_uint_16 v;\n\n                        v = (png_uint_16)(((*sp) << 8) + *(sp + 1));\n\n                        if (v == png_ptr->trans_color.gray)\n                        {\n                           /* Background is already in screen gamma */\n                           *sp = (png_byte)((png_ptr->background.gray >> 8)\n                                & 0xff);\n                           *(sp + 1) = (png_byte)(png_ptr->background.gray\n                                & 0xff);\n                        }\n\n                        else\n                        {\n                           v = gamma_16[*(sp + 1) >> gamma_shift][*sp];\n                           *sp = (png_byte)((v >> 8) & 0xff);\n                           *(sp + 1) = (png_byte)(v & 0xff);\n                        }\n                     }\n                  }\n                  else\n#endif\n                  {\n                     sp = row;\n                     for (i = 0; i < row_width; i++, sp += 2)\n                     {\n                        png_uint_16 v;\n\n                        v = (png_uint_16)(((*sp) << 8) + *(sp + 1));\n\n                        if (v == png_ptr->trans_color.gray)\n                        {\n                           *sp = (png_byte)((png_ptr->background.gray >> 8)\n                                & 0xff);\n                           *(sp + 1) = (png_byte)(png_ptr->background.gray\n                                & 0xff);\n                        }\n                     }\n                  }\n                  break;\n               }\n\n               default:\n                  break;\n            }\n            break;\n         }\n\n         case PNG_COLOR_TYPE_RGB:\n         {\n            if (row_info->bit_depth == 8)\n            {\n#ifdef PNG_READ_GAMMA_SUPPORTED\n               if (gamma_table != NULL)\n               {\n                  sp = row;\n                  for (i = 0; i < row_width; i++, sp += 3)\n                  {\n                     if (*sp == png_ptr->trans_color.red &&\n                         *(sp + 1) == png_ptr->trans_color.green &&\n                         *(sp + 2) == png_ptr->trans_color.blue)\n                     {\n                        *sp = (png_byte)png_ptr->background.red;\n                        *(sp + 1) = (png_byte)png_ptr->background.green;\n                        *(sp + 2) = (png_byte)png_ptr->background.blue;\n                     }\n\n                     else\n                     {\n                        *sp = gamma_table[*sp];\n                        *(sp + 1) = gamma_table[*(sp + 1)];\n                        *(sp + 2) = gamma_table[*(sp + 2)];\n                     }\n                  }\n               }\n               else\n#endif\n               {\n                  sp = row;\n                  for (i = 0; i < row_width; i++, sp += 3)\n                  {\n                     if (*sp == png_ptr->trans_color.red &&\n                         *(sp + 1) == png_ptr->trans_color.green &&\n                         *(sp + 2) == png_ptr->trans_color.blue)\n                     {\n                        *sp = (png_byte)png_ptr->background.red;\n                        *(sp + 1) = (png_byte)png_ptr->background.green;\n                        *(sp + 2) = (png_byte)png_ptr->background.blue;\n                     }\n                  }\n               }\n            }\n            else /* if (row_info->bit_depth == 16) */\n            {\n#ifdef PNG_READ_GAMMA_SUPPORTED\n               if (gamma_16 != NULL)\n               {\n                  sp = row;\n                  for (i = 0; i < row_width; i++, sp += 6)\n                  {\n                     png_uint_16 r = (png_uint_16)(((*sp) << 8) + *(sp + 1));\n\n                     png_uint_16 g = (png_uint_16)(((*(sp + 2)) << 8)\n                         + *(sp + 3));\n\n                     png_uint_16 b = (png_uint_16)(((*(sp + 4)) << 8)\n                         + *(sp + 5));\n\n                     if (r == png_ptr->trans_color.red &&\n                         g == png_ptr->trans_color.green &&\n                         b == png_ptr->trans_color.blue)\n                     {\n                        /* Background is already in screen gamma */\n                        *sp = (png_byte)((png_ptr->background.red >> 8) & 0xff);\n                        *(sp + 1) = (png_byte)(png_ptr->background.red & 0xff);\n                        *(sp + 2) = (png_byte)((png_ptr->background.green >> 8)\n                                & 0xff);\n                        *(sp + 3) = (png_byte)(png_ptr->background.green\n                                & 0xff);\n                        *(sp + 4) = (png_byte)((png_ptr->background.blue >> 8)\n                                & 0xff);\n                        *(sp + 5) = (png_byte)(png_ptr->background.blue & 0xff);\n                     }\n\n                     else\n                     {\n                        png_uint_16 v = gamma_16[*(sp + 1) >> gamma_shift][*sp];\n                        *sp = (png_byte)((v >> 8) & 0xff);\n                        *(sp + 1) = (png_byte)(v & 0xff);\n\n                        v = gamma_16[*(sp + 3) >> gamma_shift][*(sp + 2)];\n                        *(sp + 2) = (png_byte)((v >> 8) & 0xff);\n                        *(sp + 3) = (png_byte)(v & 0xff);\n\n                        v = gamma_16[*(sp + 5) >> gamma_shift][*(sp + 4)];\n                        *(sp + 4) = (png_byte)((v >> 8) & 0xff);\n                        *(sp + 5) = (png_byte)(v & 0xff);\n                     }\n                  }\n               }\n\n               else\n#endif\n               {\n                  sp = row;\n                  for (i = 0; i < row_width; i++, sp += 6)\n                  {\n                     png_uint_16 r = (png_uint_16)(((*sp) << 8) + *(sp + 1));\n\n                     png_uint_16 g = (png_uint_16)(((*(sp + 2)) << 8)\n                         + *(sp + 3));\n\n                     png_uint_16 b = (png_uint_16)(((*(sp + 4)) << 8)\n                         + *(sp + 5));\n\n                     if (r == png_ptr->trans_color.red &&\n                         g == png_ptr->trans_color.green &&\n                         b == png_ptr->trans_color.blue)\n                     {\n                        *sp = (png_byte)((png_ptr->background.red >> 8) & 0xff);\n                        *(sp + 1) = (png_byte)(png_ptr->background.red & 0xff);\n                        *(sp + 2) = (png_byte)((png_ptr->background.green >> 8)\n                                & 0xff);\n                        *(sp + 3) = (png_byte)(png_ptr->background.green\n                                & 0xff);\n                        *(sp + 4) = (png_byte)((png_ptr->background.blue >> 8)\n                                & 0xff);\n                        *(sp + 5) = (png_byte)(png_ptr->background.blue & 0xff);\n                     }\n                  }\n               }\n            }\n            break;\n         }\n\n         case PNG_COLOR_TYPE_GRAY_ALPHA:\n         {\n            if (row_info->bit_depth == 8)\n            {\n#ifdef PNG_READ_GAMMA_SUPPORTED\n               if (gamma_to_1 != NULL && gamma_from_1 != NULL &&\n                   gamma_table != NULL)\n               {\n                  sp = row;\n                  for (i = 0; i < row_width; i++, sp += 2)\n                  {\n                     png_uint_16 a = *(sp + 1);\n\n                     if (a == 0xff)\n                        *sp = gamma_table[*sp];\n\n                     else if (a == 0)\n                     {\n                        /* Background is already in screen gamma */\n                        *sp = (png_byte)png_ptr->background.gray;\n                     }\n\n                     else\n                     {\n                        png_byte v, w;\n\n                        v = gamma_to_1[*sp];\n                        png_composite(w, v, a, png_ptr->background_1.gray);\n                        if (!optimize)\n                           w = gamma_from_1[w];\n                        *sp = w;\n                     }\n                  }\n               }\n               else\n#endif\n               {\n                  sp = row;\n                  for (i = 0; i < row_width; i++, sp += 2)\n                  {\n                     png_byte a = *(sp + 1);\n\n                     if (a == 0)\n                        *sp = (png_byte)png_ptr->background.gray;\n\n                     else if (a < 0xff)\n                        png_composite(*sp, *sp, a, png_ptr->background.gray);\n                  }\n               }\n            }\n            else /* if (png_ptr->bit_depth == 16) */\n            {\n#ifdef PNG_READ_GAMMA_SUPPORTED\n               if (gamma_16 != NULL && gamma_16_from_1 != NULL &&\n                   gamma_16_to_1 != NULL)\n               {\n                  sp = row;\n                  for (i = 0; i < row_width; i++, sp += 4)\n                  {\n                     png_uint_16 a = (png_uint_16)(((*(sp + 2)) << 8)\n                         + *(sp + 3));\n\n                     if (a == (png_uint_16)0xffff)\n                     {\n                        png_uint_16 v;\n\n                        v = gamma_16[*(sp + 1) >> gamma_shift][*sp];\n                        *sp = (png_byte)((v >> 8) & 0xff);\n                        *(sp + 1) = (png_byte)(v & 0xff);\n                     }\n\n                     else if (a == 0)\n                     {\n                        /* Background is already in screen gamma */\n                        *sp = (png_byte)((png_ptr->background.gray >> 8)\n                                & 0xff);\n                        *(sp + 1) = (png_byte)(png_ptr->background.gray & 0xff);\n                     }\n\n                     else\n                     {\n                        png_uint_16 g, v, w;\n\n                        g = gamma_16_to_1[*(sp + 1) >> gamma_shift][*sp];\n                        png_composite_16(v, g, a, png_ptr->background_1.gray);\n                        if (optimize)\n                           w = v;\n                        else\n                           w = gamma_16_from_1[(v&0xff) >> gamma_shift][v >> 8];\n                        *sp = (png_byte)((w >> 8) & 0xff);\n                        *(sp + 1) = (png_byte)(w & 0xff);\n                     }\n                  }\n               }\n               else\n#endif\n               {\n                  sp = row;\n                  for (i = 0; i < row_width; i++, sp += 4)\n                  {\n                     png_uint_16 a = (png_uint_16)(((*(sp + 2)) << 8)\n                         + *(sp + 3));\n\n                     if (a == 0)\n                     {\n                        *sp = (png_byte)((png_ptr->background.gray >> 8)\n                                & 0xff);\n                        *(sp + 1) = (png_byte)(png_ptr->background.gray & 0xff);\n                     }\n\n                     else if (a < 0xffff)\n                     {\n                        png_uint_16 g, v;\n\n                        g = (png_uint_16)(((*sp) << 8) + *(sp + 1));\n                        png_composite_16(v, g, a, png_ptr->background.gray);\n                        *sp = (png_byte)((v >> 8) & 0xff);\n                        *(sp + 1) = (png_byte)(v & 0xff);\n                     }\n                  }\n               }\n            }\n            break;\n         }\n\n         case PNG_COLOR_TYPE_RGB_ALPHA:\n         {\n            if (row_info->bit_depth == 8)\n            {\n#ifdef PNG_READ_GAMMA_SUPPORTED\n               if (gamma_to_1 != NULL && gamma_from_1 != NULL &&\n                   gamma_table != NULL)\n               {\n                  sp = row;\n                  for (i = 0; i < row_width; i++, sp += 4)\n                  {\n                     png_byte a = *(sp + 3);\n\n                     if (a == 0xff)\n                     {\n                        *sp = gamma_table[*sp];\n                        *(sp + 1) = gamma_table[*(sp + 1)];\n                        *(sp + 2) = gamma_table[*(sp + 2)];\n                     }\n\n                     else if (a == 0)\n                     {\n                        /* Background is already in screen gamma */\n                        *sp = (png_byte)png_ptr->background.red;\n                        *(sp + 1) = (png_byte)png_ptr->background.green;\n                        *(sp + 2) = (png_byte)png_ptr->background.blue;\n                     }\n\n                     else\n                     {\n                        png_byte v, w;\n\n                        v = gamma_to_1[*sp];\n                        png_composite(w, v, a, png_ptr->background_1.red);\n                        if (!optimize) w = gamma_from_1[w];\n                        *sp = w;\n\n                        v = gamma_to_1[*(sp + 1)];\n                        png_composite(w, v, a, png_ptr->background_1.green);\n                        if (!optimize) w = gamma_from_1[w];\n                        *(sp + 1) = w;\n\n                        v = gamma_to_1[*(sp + 2)];\n                        png_composite(w, v, a, png_ptr->background_1.blue);\n                        if (!optimize) w = gamma_from_1[w];\n                        *(sp + 2) = w;\n                     }\n                  }\n               }\n               else\n#endif\n               {\n                  sp = row;\n                  for (i = 0; i < row_width; i++, sp += 4)\n                  {\n                     png_byte a = *(sp + 3);\n\n                     if (a == 0)\n                     {\n                        *sp = (png_byte)png_ptr->background.red;\n                        *(sp + 1) = (png_byte)png_ptr->background.green;\n                        *(sp + 2) = (png_byte)png_ptr->background.blue;\n                     }\n\n                     else if (a < 0xff)\n                     {\n                        png_composite(*sp, *sp, a, png_ptr->background.red);\n\n                        png_composite(*(sp + 1), *(sp + 1), a,\n                            png_ptr->background.green);\n\n                        png_composite(*(sp + 2), *(sp + 2), a,\n                            png_ptr->background.blue);\n                     }\n                  }\n               }\n            }\n            else /* if (row_info->bit_depth == 16) */\n            {\n#ifdef PNG_READ_GAMMA_SUPPORTED\n               if (gamma_16 != NULL && gamma_16_from_1 != NULL &&\n                   gamma_16_to_1 != NULL)\n               {\n                  sp = row;\n                  for (i = 0; i < row_width; i++, sp += 8)\n                  {\n                     png_uint_16 a = (png_uint_16)(((png_uint_16)(*(sp + 6))\n                         << 8) + (png_uint_16)(*(sp + 7)));\n\n                     if (a == (png_uint_16)0xffff)\n                     {\n                        png_uint_16 v;\n\n                        v = gamma_16[*(sp + 1) >> gamma_shift][*sp];\n                        *sp = (png_byte)((v >> 8) & 0xff);\n                        *(sp + 1) = (png_byte)(v & 0xff);\n\n                        v = gamma_16[*(sp + 3) >> gamma_shift][*(sp + 2)];\n                        *(sp + 2) = (png_byte)((v >> 8) & 0xff);\n                        *(sp + 3) = (png_byte)(v & 0xff);\n\n                        v = gamma_16[*(sp + 5) >> gamma_shift][*(sp + 4)];\n                        *(sp + 4) = (png_byte)((v >> 8) & 0xff);\n                        *(sp + 5) = (png_byte)(v & 0xff);\n                     }\n\n                     else if (a == 0)\n                     {\n                        /* Background is already in screen gamma */\n                        *sp = (png_byte)((png_ptr->background.red >> 8) & 0xff);\n                        *(sp + 1) = (png_byte)(png_ptr->background.red & 0xff);\n                        *(sp + 2) = (png_byte)((png_ptr->background.green >> 8)\n                                & 0xff);\n                        *(sp + 3) = (png_byte)(png_ptr->background.green\n                                & 0xff);\n                        *(sp + 4) = (png_byte)((png_ptr->background.blue >> 8)\n                                & 0xff);\n                        *(sp + 5) = (png_byte)(png_ptr->background.blue & 0xff);\n                     }\n\n                     else\n                     {\n                        png_uint_16 v, w;\n\n                        v = gamma_16_to_1[*(sp + 1) >> gamma_shift][*sp];\n                        png_composite_16(w, v, a, png_ptr->background_1.red);\n                        if (!optimize)\n                           w = gamma_16_from_1[((w&0xff) >> gamma_shift)][w >>\n                                8];\n                        *sp = (png_byte)((w >> 8) & 0xff);\n                        *(sp + 1) = (png_byte)(w & 0xff);\n\n                        v = gamma_16_to_1[*(sp + 3) >> gamma_shift][*(sp + 2)];\n                        png_composite_16(w, v, a, png_ptr->background_1.green);\n                        if (!optimize)\n                           w = gamma_16_from_1[((w&0xff) >> gamma_shift)][w >>\n                                8];\n\n                        *(sp + 2) = (png_byte)((w >> 8) & 0xff);\n                        *(sp + 3) = (png_byte)(w & 0xff);\n\n                        v = gamma_16_to_1[*(sp + 5) >> gamma_shift][*(sp + 4)];\n                        png_composite_16(w, v, a, png_ptr->background_1.blue);\n                        if (!optimize)\n                           w = gamma_16_from_1[((w&0xff) >> gamma_shift)][w >>\n                                8];\n\n                        *(sp + 4) = (png_byte)((w >> 8) & 0xff);\n                        *(sp + 5) = (png_byte)(w & 0xff);\n                     }\n                  }\n               }\n\n               else\n#endif\n               {\n                  sp = row;\n                  for (i = 0; i < row_width; i++, sp += 8)\n                  {\n                     png_uint_16 a = (png_uint_16)(((png_uint_16)(*(sp + 6))\n                         << 8) + (png_uint_16)(*(sp + 7)));\n\n                     if (a == 0)\n                     {\n                        *sp = (png_byte)((png_ptr->background.red >> 8) & 0xff);\n                        *(sp + 1) = (png_byte)(png_ptr->background.red & 0xff);\n                        *(sp + 2) = (png_byte)((png_ptr->background.green >> 8)\n                                & 0xff);\n                        *(sp + 3) = (png_byte)(png_ptr->background.green\n                                & 0xff);\n                        *(sp + 4) = (png_byte)((png_ptr->background.blue >> 8)\n                                & 0xff);\n                        *(sp + 5) = (png_byte)(png_ptr->background.blue & 0xff);\n                     }\n\n                     else if (a < 0xffff)\n                     {\n                        png_uint_16 v;\n\n                        png_uint_16 r = (png_uint_16)(((*sp) << 8) + *(sp + 1));\n                        png_uint_16 g = (png_uint_16)(((*(sp + 2)) << 8)\n                            + *(sp + 3));\n                        png_uint_16 b = (png_uint_16)(((*(sp + 4)) << 8)\n                            + *(sp + 5));\n\n                        png_composite_16(v, r, a, png_ptr->background.red);\n                        *sp = (png_byte)((v >> 8) & 0xff);\n                        *(sp + 1) = (png_byte)(v & 0xff);\n\n                        png_composite_16(v, g, a, png_ptr->background.green);\n                        *(sp + 2) = (png_byte)((v >> 8) & 0xff);\n                        *(sp + 3) = (png_byte)(v & 0xff);\n\n                        png_composite_16(v, b, a, png_ptr->background.blue);\n                        *(sp + 4) = (png_byte)((v >> 8) & 0xff);\n                        *(sp + 5) = (png_byte)(v & 0xff);\n                     }\n                  }\n               }\n            }\n            break;\n         }\n\n         default:\n            break;\n      }\n   }\n}\n#endif /* PNG_READ_BACKGROUND_SUPPORTED || PNG_READ_ALPHA_MODE_SUPPORTED */\n\n#ifdef PNG_READ_GAMMA_SUPPORTED\n/* Gamma correct the image, avoiding the alpha channel.  Make sure\n * you do this after you deal with the transparency issue on grayscale\n * or RGB images. If your bit depth is 8, use gamma_table, if it\n * is 16, use gamma_16_table and gamma_shift.  Build these with\n * build_gamma_table().\n */\nstatic void\npng_do_gamma(png_row_infop row_info, png_bytep row, png_structrp png_ptr)\n{\n   png_const_bytep gamma_table = png_ptr->gamma_table;\n   png_const_uint_16pp gamma_16_table = png_ptr->gamma_16_table;\n   int gamma_shift = png_ptr->gamma_shift;\n\n   png_bytep sp;\n   png_uint_32 i;\n   png_uint_32 row_width=row_info->width;\n\n   png_debug(1, \"in png_do_gamma\");\n\n   if (((row_info->bit_depth <= 8 && gamma_table != NULL) ||\n       (row_info->bit_depth == 16 && gamma_16_table != NULL)))\n   {\n      switch (row_info->color_type)\n      {\n         case PNG_COLOR_TYPE_RGB:\n         {\n            if (row_info->bit_depth == 8)\n            {\n               sp = row;\n               for (i = 0; i < row_width; i++)\n               {\n                  *sp = gamma_table[*sp];\n                  sp++;\n                  *sp = gamma_table[*sp];\n                  sp++;\n                  *sp = gamma_table[*sp];\n                  sp++;\n               }\n            }\n\n            else /* if (row_info->bit_depth == 16) */\n            {\n               sp = row;\n               for (i = 0; i < row_width; i++)\n               {\n                  png_uint_16 v;\n\n                  v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp];\n                  *sp = (png_byte)((v >> 8) & 0xff);\n                  *(sp + 1) = (png_byte)(v & 0xff);\n                  sp += 2;\n\n                  v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp];\n                  *sp = (png_byte)((v >> 8) & 0xff);\n                  *(sp + 1) = (png_byte)(v & 0xff);\n                  sp += 2;\n\n                  v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp];\n                  *sp = (png_byte)((v >> 8) & 0xff);\n                  *(sp + 1) = (png_byte)(v & 0xff);\n                  sp += 2;\n               }\n            }\n            break;\n         }\n\n         case PNG_COLOR_TYPE_RGB_ALPHA:\n         {\n            if (row_info->bit_depth == 8)\n            {\n               sp = row;\n               for (i = 0; i < row_width; i++)\n               {\n                  *sp = gamma_table[*sp];\n                  sp++;\n\n                  *sp = gamma_table[*sp];\n                  sp++;\n\n                  *sp = gamma_table[*sp];\n                  sp++;\n\n                  sp++;\n               }\n            }\n\n            else /* if (row_info->bit_depth == 16) */\n            {\n               sp = row;\n               for (i = 0; i < row_width; i++)\n               {\n                  png_uint_16 v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp];\n                  *sp = (png_byte)((v >> 8) & 0xff);\n                  *(sp + 1) = (png_byte)(v & 0xff);\n                  sp += 2;\n\n                  v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp];\n                  *sp = (png_byte)((v >> 8) & 0xff);\n                  *(sp + 1) = (png_byte)(v & 0xff);\n                  sp += 2;\n\n                  v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp];\n                  *sp = (png_byte)((v >> 8) & 0xff);\n                  *(sp + 1) = (png_byte)(v & 0xff);\n                  sp += 4;\n               }\n            }\n            break;\n         }\n\n         case PNG_COLOR_TYPE_GRAY_ALPHA:\n         {\n            if (row_info->bit_depth == 8)\n            {\n               sp = row;\n               for (i = 0; i < row_width; i++)\n               {\n                  *sp = gamma_table[*sp];\n                  sp += 2;\n               }\n            }\n\n            else /* if (row_info->bit_depth == 16) */\n            {\n               sp = row;\n               for (i = 0; i < row_width; i++)\n               {\n                  png_uint_16 v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp];\n                  *sp = (png_byte)((v >> 8) & 0xff);\n                  *(sp + 1) = (png_byte)(v & 0xff);\n                  sp += 4;\n               }\n            }\n            break;\n         }\n\n         case PNG_COLOR_TYPE_GRAY:\n         {\n            if (row_info->bit_depth == 2)\n            {\n               sp = row;\n               for (i = 0; i < row_width; i += 4)\n               {\n                  int a = *sp & 0xc0;\n                  int b = *sp & 0x30;\n                  int c = *sp & 0x0c;\n                  int d = *sp & 0x03;\n\n                  *sp = (png_byte)(\n                      ((((int)gamma_table[a|(a>>2)|(a>>4)|(a>>6)])   ) & 0xc0)|\n                      ((((int)gamma_table[(b<<2)|b|(b>>2)|(b>>4)])>>2) & 0x30)|\n                      ((((int)gamma_table[(c<<4)|(c<<2)|c|(c>>2)])>>4) & 0x0c)|\n                      ((((int)gamma_table[(d<<6)|(d<<4)|(d<<2)|d])>>6) ));\n                  sp++;\n               }\n            }\n\n            if (row_info->bit_depth == 4)\n            {\n               sp = row;\n               for (i = 0; i < row_width; i += 2)\n               {\n                  int msb = *sp & 0xf0;\n                  int lsb = *sp & 0x0f;\n\n                  *sp = (png_byte)((((int)gamma_table[msb | (msb >> 4)]) & 0xf0)\n                      | (((int)gamma_table[(lsb << 4) | lsb]) >> 4));\n                  sp++;\n               }\n            }\n\n            else if (row_info->bit_depth == 8)\n            {\n               sp = row;\n               for (i = 0; i < row_width; i++)\n               {\n                  *sp = gamma_table[*sp];\n                  sp++;\n               }\n            }\n\n            else if (row_info->bit_depth == 16)\n            {\n               sp = row;\n               for (i = 0; i < row_width; i++)\n               {\n                  png_uint_16 v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp];\n                  *sp = (png_byte)((v >> 8) & 0xff);\n                  *(sp + 1) = (png_byte)(v & 0xff);\n                  sp += 2;\n               }\n            }\n            break;\n         }\n\n         default:\n            break;\n      }\n   }\n}\n#endif\n\n#ifdef PNG_READ_ALPHA_MODE_SUPPORTED\n/* Encode the alpha channel to the output gamma (the input channel is always\n * linear.)  Called only with color types that have an alpha channel.  Needs the\n * from_1 tables.\n */\nstatic void\npng_do_encode_alpha(png_row_infop row_info, png_bytep row, png_structrp png_ptr)\n{\n   png_uint_32 row_width = row_info->width;\n\n   png_debug(1, \"in png_do_encode_alpha\");\n\n   if (row_info->color_type & PNG_COLOR_MASK_ALPHA)\n   {\n      if (row_info->bit_depth == 8)\n      {\n         PNG_CONST png_bytep table = png_ptr->gamma_from_1;\n\n         if (table != NULL)\n         {\n            PNG_CONST int step =\n               (row_info->color_type & PNG_COLOR_MASK_COLOR) ? 4 : 2;\n\n            /* The alpha channel is the last component: */\n            row += step - 1;\n\n            for (; row_width > 0; --row_width, row += step)\n               *row = table[*row];\n\n            return;\n         }\n      }\n\n      else if (row_info->bit_depth == 16)\n      {\n         PNG_CONST png_uint_16pp table = png_ptr->gamma_16_from_1;\n         PNG_CONST int gamma_shift = png_ptr->gamma_shift;\n\n         if (table != NULL)\n         {\n            PNG_CONST int step =\n               (row_info->color_type & PNG_COLOR_MASK_COLOR) ? 8 : 4;\n\n            /* The alpha channel is the last component: */\n            row += step - 2;\n\n            for (; row_width > 0; --row_width, row += step)\n            {\n               png_uint_16 v;\n\n               v = table[*(row + 1) >> gamma_shift][*row];\n               *row = (png_byte)((v >> 8) & 0xff);\n               *(row + 1) = (png_byte)(v & 0xff);\n            }\n\n            return;\n         }\n      }\n   }\n\n   /* Only get to here if called with a weird row_info; no harm has been done,\n    * so just issue a warning.\n    */\n   png_warning(png_ptr, \"png_do_encode_alpha: unexpected call\");\n}\n#endif\n\n#ifdef PNG_READ_EXPAND_SUPPORTED\n/* Expands a palette row to an RGB or RGBA row depending\n * upon whether you supply trans and num_trans.\n */\nstatic void\npng_do_expand_palette(png_row_infop row_info, png_bytep row,\n   png_const_colorp palette, png_const_bytep trans_alpha, int num_trans)\n{\n   int shift, value;\n   png_bytep sp, dp;\n   png_uint_32 i;\n   png_uint_32 row_width=row_info->width;\n\n   png_debug(1, \"in png_do_expand_palette\");\n\n   if (row_info->color_type == PNG_COLOR_TYPE_PALETTE)\n   {\n      if (row_info->bit_depth < 8)\n      {\n         switch (row_info->bit_depth)\n         {\n            case 1:\n            {\n               sp = row + (png_size_t)((row_width - 1) >> 3);\n               dp = row + (png_size_t)row_width - 1;\n               shift = 7 - (int)((row_width + 7) & 0x07);\n               for (i = 0; i < row_width; i++)\n               {\n                  if ((*sp >> shift) & 0x01)\n                     *dp = 1;\n\n                  else\n                     *dp = 0;\n\n                  if (shift == 7)\n                  {\n                     shift = 0;\n                     sp--;\n                  }\n\n                  else\n                     shift++;\n\n                  dp--;\n               }\n               break;\n            }\n\n            case 2:\n            {\n               sp = row + (png_size_t)((row_width - 1) >> 2);\n               dp = row + (png_size_t)row_width - 1;\n               shift = (int)((3 - ((row_width + 3) & 0x03)) << 1);\n               for (i = 0; i < row_width; i++)\n               {\n                  value = (*sp >> shift) & 0x03;\n                  *dp = (png_byte)value;\n                  if (shift == 6)\n                  {\n                     shift = 0;\n                     sp--;\n                  }\n\n                  else\n                     shift += 2;\n\n                  dp--;\n               }\n               break;\n            }\n\n            case 4:\n            {\n               sp = row + (png_size_t)((row_width - 1) >> 1);\n               dp = row + (png_size_t)row_width - 1;\n               shift = (int)((row_width & 0x01) << 2);\n               for (i = 0; i < row_width; i++)\n               {\n                  value = (*sp >> shift) & 0x0f;\n                  *dp = (png_byte)value;\n                  if (shift == 4)\n                  {\n                     shift = 0;\n                     sp--;\n                  }\n\n                  else\n                     shift += 4;\n\n                  dp--;\n               }\n               break;\n            }\n\n            default:\n               break;\n         }\n         row_info->bit_depth = 8;\n         row_info->pixel_depth = 8;\n         row_info->rowbytes = row_width;\n      }\n\n      if (row_info->bit_depth == 8)\n      {\n         {\n            if (num_trans > 0)\n            {\n               sp = row + (png_size_t)row_width - 1;\n               dp = row + (png_size_t)(row_width << 2) - 1;\n\n               for (i = 0; i < row_width; i++)\n               {\n                  if ((int)(*sp) >= num_trans)\n                     *dp-- = 0xff;\n\n                  else\n                     *dp-- = trans_alpha[*sp];\n\n                  *dp-- = palette[*sp].blue;\n                  *dp-- = palette[*sp].green;\n                  *dp-- = palette[*sp].red;\n                  sp--;\n               }\n               row_info->bit_depth = 8;\n               row_info->pixel_depth = 32;\n               row_info->rowbytes = row_width * 4;\n               row_info->color_type = 6;\n               row_info->channels = 4;\n            }\n\n            else\n            {\n               sp = row + (png_size_t)row_width - 1;\n               dp = row + (png_size_t)(row_width * 3) - 1;\n\n               for (i = 0; i < row_width; i++)\n               {\n                  *dp-- = palette[*sp].blue;\n                  *dp-- = palette[*sp].green;\n                  *dp-- = palette[*sp].red;\n                  sp--;\n               }\n\n               row_info->bit_depth = 8;\n               row_info->pixel_depth = 24;\n               row_info->rowbytes = row_width * 3;\n               row_info->color_type = 2;\n               row_info->channels = 3;\n            }\n         }\n      }\n   }\n}\n\n/* If the bit depth < 8, it is expanded to 8.  Also, if the already\n * expanded transparency value is supplied, an alpha channel is built.\n */\nstatic void\npng_do_expand(png_row_infop row_info, png_bytep row,\n    png_const_color_16p trans_color)\n{\n   int shift, value;\n   png_bytep sp, dp;\n   png_uint_32 i;\n   png_uint_32 row_width=row_info->width;\n\n   png_debug(1, \"in png_do_expand\");\n\n   {\n      if (row_info->color_type == PNG_COLOR_TYPE_GRAY)\n      {\n         unsigned int gray = trans_color ? trans_color->gray : 0;\n\n         if (row_info->bit_depth < 8)\n         {\n            switch (row_info->bit_depth)\n            {\n               case 1:\n               {\n                  gray = (gray & 0x01) * 0xff;\n                  sp = row + (png_size_t)((row_width - 1) >> 3);\n                  dp = row + (png_size_t)row_width - 1;\n                  shift = 7 - (int)((row_width + 7) & 0x07);\n                  for (i = 0; i < row_width; i++)\n                  {\n                     if ((*sp >> shift) & 0x01)\n                        *dp = 0xff;\n\n                     else\n                        *dp = 0;\n\n                     if (shift == 7)\n                     {\n                        shift = 0;\n                        sp--;\n                     }\n\n                     else\n                        shift++;\n\n                     dp--;\n                  }\n                  break;\n               }\n\n               case 2:\n               {\n                  gray = (gray & 0x03) * 0x55;\n                  sp = row + (png_size_t)((row_width - 1) >> 2);\n                  dp = row + (png_size_t)row_width - 1;\n                  shift = (int)((3 - ((row_width + 3) & 0x03)) << 1);\n                  for (i = 0; i < row_width; i++)\n                  {\n                     value = (*sp >> shift) & 0x03;\n                     *dp = (png_byte)(value | (value << 2) | (value << 4) |\n                        (value << 6));\n                     if (shift == 6)\n                     {\n                        shift = 0;\n                        sp--;\n                     }\n\n                     else\n                        shift += 2;\n\n                     dp--;\n                  }\n                  break;\n               }\n\n               case 4:\n               {\n                  gray = (gray & 0x0f) * 0x11;\n                  sp = row + (png_size_t)((row_width - 1) >> 1);\n                  dp = row + (png_size_t)row_width - 1;\n                  shift = (int)((1 - ((row_width + 1) & 0x01)) << 2);\n                  for (i = 0; i < row_width; i++)\n                  {\n                     value = (*sp >> shift) & 0x0f;\n                     *dp = (png_byte)(value | (value << 4));\n                     if (shift == 4)\n                     {\n                        shift = 0;\n                        sp--;\n                     }\n\n                     else\n                        shift = 4;\n\n                     dp--;\n                  }\n                  break;\n               }\n\n               default:\n                  break;\n            }\n\n            row_info->bit_depth = 8;\n            row_info->pixel_depth = 8;\n            row_info->rowbytes = row_width;\n         }\n\n         if (trans_color != NULL)\n         {\n            if (row_info->bit_depth == 8)\n            {\n               gray = gray & 0xff;\n               sp = row + (png_size_t)row_width - 1;\n               dp = row + (png_size_t)(row_width << 1) - 1;\n\n               for (i = 0; i < row_width; i++)\n               {\n                  if (*sp == gray)\n                     *dp-- = 0;\n\n                  else\n                     *dp-- = 0xff;\n\n                  *dp-- = *sp--;\n               }\n            }\n\n            else if (row_info->bit_depth == 16)\n            {\n               unsigned int gray_high = (gray >> 8) & 0xff;\n               unsigned int gray_low = gray & 0xff;\n               sp = row + row_info->rowbytes - 1;\n               dp = row + (row_info->rowbytes << 1) - 1;\n               for (i = 0; i < row_width; i++)\n               {\n                  if (*(sp - 1) == gray_high && *(sp) == gray_low)\n                  {\n                     *dp-- = 0;\n                     *dp-- = 0;\n                  }\n\n                  else\n                  {\n                     *dp-- = 0xff;\n                     *dp-- = 0xff;\n                  }\n\n                  *dp-- = *sp--;\n                  *dp-- = *sp--;\n               }\n            }\n\n            row_info->color_type = PNG_COLOR_TYPE_GRAY_ALPHA;\n            row_info->channels = 2;\n            row_info->pixel_depth = (png_byte)(row_info->bit_depth << 1);\n            row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,\n               row_width);\n         }\n      }\n      else if (row_info->color_type == PNG_COLOR_TYPE_RGB && trans_color)\n      {\n         if (row_info->bit_depth == 8)\n         {\n            png_byte red = (png_byte)(trans_color->red & 0xff);\n            png_byte green = (png_byte)(trans_color->green & 0xff);\n            png_byte blue = (png_byte)(trans_color->blue & 0xff);\n            sp = row + (png_size_t)row_info->rowbytes - 1;\n            dp = row + (png_size_t)(row_width << 2) - 1;\n            for (i = 0; i < row_width; i++)\n            {\n               if (*(sp - 2) == red && *(sp - 1) == green && *(sp) == blue)\n                  *dp-- = 0;\n\n               else\n                  *dp-- = 0xff;\n\n               *dp-- = *sp--;\n               *dp-- = *sp--;\n               *dp-- = *sp--;\n            }\n         }\n         else if (row_info->bit_depth == 16)\n         {\n            png_byte red_high = (png_byte)((trans_color->red >> 8) & 0xff);\n            png_byte green_high = (png_byte)((trans_color->green >> 8) & 0xff);\n            png_byte blue_high = (png_byte)((trans_color->blue >> 8) & 0xff);\n            png_byte red_low = (png_byte)(trans_color->red & 0xff);\n            png_byte green_low = (png_byte)(trans_color->green & 0xff);\n            png_byte blue_low = (png_byte)(trans_color->blue & 0xff);\n            sp = row + row_info->rowbytes - 1;\n            dp = row + (png_size_t)(row_width << 3) - 1;\n            for (i = 0; i < row_width; i++)\n            {\n               if (*(sp - 5) == red_high &&\n                   *(sp - 4) == red_low &&\n                   *(sp - 3) == green_high &&\n                   *(sp - 2) == green_low &&\n                   *(sp - 1) == blue_high &&\n                   *(sp    ) == blue_low)\n               {\n                  *dp-- = 0;\n                  *dp-- = 0;\n               }\n\n               else\n               {\n                  *dp-- = 0xff;\n                  *dp-- = 0xff;\n               }\n\n               *dp-- = *sp--;\n               *dp-- = *sp--;\n               *dp-- = *sp--;\n               *dp-- = *sp--;\n               *dp-- = *sp--;\n               *dp-- = *sp--;\n            }\n         }\n         row_info->color_type = PNG_COLOR_TYPE_RGB_ALPHA;\n         row_info->channels = 4;\n         row_info->pixel_depth = (png_byte)(row_info->bit_depth << 2);\n         row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, row_width);\n      }\n   }\n}\n#endif\n\n#ifdef PNG_READ_EXPAND_16_SUPPORTED\n/* If the bit depth is 8 and the color type is not a palette type expand the\n * whole row to 16 bits.  Has no effect otherwise.\n */\nstatic void\npng_do_expand_16(png_row_infop row_info, png_bytep row)\n{\n   if (row_info->bit_depth == 8 &&\n      row_info->color_type != PNG_COLOR_TYPE_PALETTE)\n   {\n      /* The row have a sequence of bytes containing [0..255] and we need\n       * to turn it into another row containing [0..65535], to do this we\n       * calculate:\n       *\n       *  (input / 255) * 65535\n       *\n       *  Which happens to be exactly input * 257 and this can be achieved\n       *  simply by byte replication in place (copying backwards).\n       */\n      png_byte *sp = row + row_info->rowbytes; /* source, last byte + 1 */\n      png_byte *dp = sp + row_info->rowbytes;  /* destination, end + 1 */\n      while (dp > sp)\n         dp[-2] = dp[-1] = *--sp, dp -= 2;\n\n      row_info->rowbytes *= 2;\n      row_info->bit_depth = 16;\n      row_info->pixel_depth = (png_byte)(row_info->channels * 16);\n   }\n}\n#endif\n\n#ifdef PNG_READ_QUANTIZE_SUPPORTED\nstatic void\npng_do_quantize(png_row_infop row_info, png_bytep row,\n    png_const_bytep palette_lookup, png_const_bytep quantize_lookup)\n{\n   png_bytep sp, dp;\n   png_uint_32 i;\n   png_uint_32 row_width=row_info->width;\n\n   png_debug(1, \"in png_do_quantize\");\n\n   if (row_info->bit_depth == 8)\n   {\n      if (row_info->color_type == PNG_COLOR_TYPE_RGB && palette_lookup)\n      {\n         int r, g, b, p;\n         sp = row;\n         dp = row;\n         for (i = 0; i < row_width; i++)\n         {\n            r = *sp++;\n            g = *sp++;\n            b = *sp++;\n\n            /* This looks real messy, but the compiler will reduce\n             * it down to a reasonable formula.  For example, with\n             * 5 bits per color, we get:\n             * p = (((r >> 3) & 0x1f) << 10) |\n             *    (((g >> 3) & 0x1f) << 5) |\n             *    ((b >> 3) & 0x1f);\n             */\n            p = (((r >> (8 - PNG_QUANTIZE_RED_BITS)) &\n                ((1 << PNG_QUANTIZE_RED_BITS) - 1)) <<\n                (PNG_QUANTIZE_GREEN_BITS + PNG_QUANTIZE_BLUE_BITS)) |\n                (((g >> (8 - PNG_QUANTIZE_GREEN_BITS)) &\n                ((1 << PNG_QUANTIZE_GREEN_BITS) - 1)) <<\n                (PNG_QUANTIZE_BLUE_BITS)) |\n                ((b >> (8 - PNG_QUANTIZE_BLUE_BITS)) &\n                ((1 << PNG_QUANTIZE_BLUE_BITS) - 1));\n\n            *dp++ = palette_lookup[p];\n         }\n\n         row_info->color_type = PNG_COLOR_TYPE_PALETTE;\n         row_info->channels = 1;\n         row_info->pixel_depth = row_info->bit_depth;\n         row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, row_width);\n      }\n\n      else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA &&\n         palette_lookup != NULL)\n      {\n         int r, g, b, p;\n         sp = row;\n         dp = row;\n         for (i = 0; i < row_width; i++)\n         {\n            r = *sp++;\n            g = *sp++;\n            b = *sp++;\n            sp++;\n\n            p = (((r >> (8 - PNG_QUANTIZE_RED_BITS)) &\n                ((1 << PNG_QUANTIZE_RED_BITS) - 1)) <<\n                (PNG_QUANTIZE_GREEN_BITS + PNG_QUANTIZE_BLUE_BITS)) |\n                (((g >> (8 - PNG_QUANTIZE_GREEN_BITS)) &\n                ((1 << PNG_QUANTIZE_GREEN_BITS) - 1)) <<\n                (PNG_QUANTIZE_BLUE_BITS)) |\n                ((b >> (8 - PNG_QUANTIZE_BLUE_BITS)) &\n                ((1 << PNG_QUANTIZE_BLUE_BITS) - 1));\n\n            *dp++ = palette_lookup[p];\n         }\n\n         row_info->color_type = PNG_COLOR_TYPE_PALETTE;\n         row_info->channels = 1;\n         row_info->pixel_depth = row_info->bit_depth;\n         row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, row_width);\n      }\n\n      else if (row_info->color_type == PNG_COLOR_TYPE_PALETTE &&\n         quantize_lookup)\n      {\n         sp = row;\n\n         for (i = 0; i < row_width; i++, sp++)\n         {\n            *sp = quantize_lookup[*sp];\n         }\n      }\n   }\n}\n#endif /* PNG_READ_QUANTIZE_SUPPORTED */\n\n/* Transform the row.  The order of transformations is significant,\n * and is very touchy.  If you add a transformation, take care to\n * decide how it fits in with the other transformations here.\n */\nvoid /* PRIVATE */\npng_do_read_transformations(png_structrp png_ptr, png_row_infop row_info)\n{\n   png_debug(1, \"in png_do_read_transformations\");\n\n   if (png_ptr->row_buf == NULL)\n   {\n      /* Prior to 1.5.4 this output row/pass where the NULL pointer is, but this\n       * error is incredibly rare and incredibly easy to debug without this\n       * information.\n       */\n      png_error(png_ptr, \"NULL row buffer\");\n   }\n\n   /* The following is debugging; prior to 1.5.4 the code was never compiled in;\n    * in 1.5.4 PNG_FLAG_DETECT_UNINITIALIZED was added and the macro\n    * PNG_WARN_UNINITIALIZED_ROW removed.  In 1.6 the new flag is set only for\n    * all transformations, however in practice the ROW_INIT always gets done on\n    * demand, if necessary.\n    */\n   if ((png_ptr->flags & PNG_FLAG_DETECT_UNINITIALIZED) != 0 &&\n      !(png_ptr->flags & PNG_FLAG_ROW_INIT))\n   {\n      /* Application has failed to call either png_read_start_image() or\n       * png_read_update_info() after setting transforms that expand pixels.\n       * This check added to libpng-1.2.19 (but not enabled until 1.5.4).\n       */\n      png_error(png_ptr, \"Uninitialized row\");\n   }\n\n#ifdef PNG_READ_EXPAND_SUPPORTED\n   if (png_ptr->transformations & PNG_EXPAND)\n   {\n      if (row_info->color_type == PNG_COLOR_TYPE_PALETTE)\n      {\n         png_do_expand_palette(row_info, png_ptr->row_buf + 1,\n             png_ptr->palette, png_ptr->trans_alpha, png_ptr->num_trans);\n      }\n\n      else\n      {\n         if (png_ptr->num_trans &&\n             (png_ptr->transformations & PNG_EXPAND_tRNS))\n            png_do_expand(row_info, png_ptr->row_buf + 1,\n                &(png_ptr->trans_color));\n\n         else\n            png_do_expand(row_info, png_ptr->row_buf + 1,\n                NULL);\n      }\n   }\n#endif\n\n#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED\n   if ((png_ptr->transformations & PNG_STRIP_ALPHA) &&\n      !(png_ptr->transformations & PNG_COMPOSE) &&\n      (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA ||\n      row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA))\n      png_do_strip_channel(row_info, png_ptr->row_buf + 1,\n         0 /* at_start == false, because SWAP_ALPHA happens later */);\n#endif\n\n#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED\n   if (png_ptr->transformations & PNG_RGB_TO_GRAY)\n   {\n      int rgb_error =\n          png_do_rgb_to_gray(png_ptr, row_info,\n              png_ptr->row_buf + 1);\n\n      if (rgb_error)\n      {\n         png_ptr->rgb_to_gray_status=1;\n         if ((png_ptr->transformations & PNG_RGB_TO_GRAY) ==\n             PNG_RGB_TO_GRAY_WARN)\n            png_warning(png_ptr, \"png_do_rgb_to_gray found nongray pixel\");\n\n         if ((png_ptr->transformations & PNG_RGB_TO_GRAY) ==\n             PNG_RGB_TO_GRAY_ERR)\n            png_error(png_ptr, \"png_do_rgb_to_gray found nongray pixel\");\n      }\n   }\n#endif\n\n/* From Andreas Dilger e-mail to png-implement, 26 March 1998:\n *\n *   In most cases, the \"simple transparency\" should be done prior to doing\n *   gray-to-RGB, or you will have to test 3x as many bytes to check if a\n *   pixel is transparent.  You would also need to make sure that the\n *   transparency information is upgraded to RGB.\n *\n *   To summarize, the current flow is:\n *   - Gray + simple transparency -> compare 1 or 2 gray bytes and composite\n *                                   with background \"in place\" if transparent,\n *                                   convert to RGB if necessary\n *   - Gray + alpha -> composite with gray background and remove alpha bytes,\n *                                   convert to RGB if necessary\n *\n *   To support RGB backgrounds for gray images we need:\n *   - Gray + simple transparency -> convert to RGB + simple transparency,\n *                                   compare 3 or 6 bytes and composite with\n *                                   background \"in place\" if transparent\n *                                   (3x compare/pixel compared to doing\n *                                   composite with gray bkgrnd)\n *   - Gray + alpha -> convert to RGB + alpha, composite with background and\n *                                   remove alpha bytes (3x float\n *                                   operations/pixel compared with composite\n *                                   on gray background)\n *\n *  Greg's change will do this.  The reason it wasn't done before is for\n *  performance, as this increases the per-pixel operations.  If we would check\n *  in advance if the background was gray or RGB, and position the gray-to-RGB\n *  transform appropriately, then it would save a lot of work/time.\n */\n\n#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED\n   /* If gray -> RGB, do so now only if background is non-gray; else do later\n    * for performance reasons\n    */\n   if ((png_ptr->transformations & PNG_GRAY_TO_RGB) &&\n       !(png_ptr->mode & PNG_BACKGROUND_IS_GRAY))\n      png_do_gray_to_rgb(row_info, png_ptr->row_buf + 1);\n#endif\n\n#if defined(PNG_READ_BACKGROUND_SUPPORTED) ||\\\n   defined(PNG_READ_ALPHA_MODE_SUPPORTED)\n   if (png_ptr->transformations & PNG_COMPOSE)\n      png_do_compose(row_info, png_ptr->row_buf + 1, png_ptr);\n#endif\n\n#ifdef PNG_READ_GAMMA_SUPPORTED\n   if ((png_ptr->transformations & PNG_GAMMA) &&\n#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED\n      /* Because RGB_TO_GRAY does the gamma transform. */\n      !(png_ptr->transformations & PNG_RGB_TO_GRAY) &&\n#endif\n#if defined(PNG_READ_BACKGROUND_SUPPORTED) ||\\\n   defined(PNG_READ_ALPHA_MODE_SUPPORTED)\n      /* Because PNG_COMPOSE does the gamma transform if there is something to\n       * do (if there is an alpha channel or transparency.)\n       */\n       !((png_ptr->transformations & PNG_COMPOSE) &&\n       ((png_ptr->num_trans != 0) ||\n       (png_ptr->color_type & PNG_COLOR_MASK_ALPHA))) &&\n#endif\n      /* Because png_init_read_transformations transforms the palette, unless\n       * RGB_TO_GRAY will do the transform.\n       */\n       (png_ptr->color_type != PNG_COLOR_TYPE_PALETTE))\n      png_do_gamma(row_info, png_ptr->row_buf + 1, png_ptr);\n#endif\n\n#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED\n   if ((png_ptr->transformations & PNG_STRIP_ALPHA) &&\n      (png_ptr->transformations & PNG_COMPOSE) &&\n      (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA ||\n      row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA))\n      png_do_strip_channel(row_info, png_ptr->row_buf + 1,\n         0 /* at_start == false, because SWAP_ALPHA happens later */);\n#endif\n\n#ifdef PNG_READ_ALPHA_MODE_SUPPORTED\n   if ((png_ptr->transformations & PNG_ENCODE_ALPHA) &&\n      (row_info->color_type & PNG_COLOR_MASK_ALPHA))\n      png_do_encode_alpha(row_info, png_ptr->row_buf + 1, png_ptr);\n#endif\n\n#ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED\n   if (png_ptr->transformations & PNG_SCALE_16_TO_8)\n      png_do_scale_16_to_8(row_info, png_ptr->row_buf + 1);\n#endif\n\n#ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED\n   /* There is no harm in doing both of these because only one has any effect,\n    * by putting the 'scale' option first if the app asks for scale (either by\n    * calling the API or in a TRANSFORM flag) this is what happens.\n    */\n   if (png_ptr->transformations & PNG_16_TO_8)\n      png_do_chop(row_info, png_ptr->row_buf + 1);\n#endif\n\n#ifdef PNG_READ_QUANTIZE_SUPPORTED\n   if (png_ptr->transformations & PNG_QUANTIZE)\n   {\n      png_do_quantize(row_info, png_ptr->row_buf + 1,\n          png_ptr->palette_lookup, png_ptr->quantize_index);\n\n      if (row_info->rowbytes == 0)\n         png_error(png_ptr, \"png_do_quantize returned rowbytes=0\");\n   }\n#endif /* PNG_READ_QUANTIZE_SUPPORTED */\n\n#ifdef PNG_READ_EXPAND_16_SUPPORTED\n   /* Do the expansion now, after all the arithmetic has been done.  Notice\n    * that previous transformations can handle the PNG_EXPAND_16 flag if this\n    * is efficient (particularly true in the case of gamma correction, where\n    * better accuracy results faster!)\n    */\n   if (png_ptr->transformations & PNG_EXPAND_16)\n      png_do_expand_16(row_info, png_ptr->row_buf + 1);\n#endif\n\n#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED\n   /* NOTE: moved here in 1.5.4 (from much later in this list.) */\n   if ((png_ptr->transformations & PNG_GRAY_TO_RGB) &&\n       (png_ptr->mode & PNG_BACKGROUND_IS_GRAY))\n      png_do_gray_to_rgb(row_info, png_ptr->row_buf + 1);\n#endif\n\n#ifdef PNG_READ_INVERT_SUPPORTED\n   if (png_ptr->transformations & PNG_INVERT_MONO)\n      png_do_invert(row_info, png_ptr->row_buf + 1);\n#endif\n\n#ifdef PNG_READ_INVERT_ALPHA_SUPPORTED\n   if (png_ptr->transformations & PNG_INVERT_ALPHA)\n      png_do_read_invert_alpha(row_info, png_ptr->row_buf + 1);\n#endif\n\n#ifdef PNG_READ_SHIFT_SUPPORTED\n   if (png_ptr->transformations & PNG_SHIFT)\n      png_do_unshift(row_info, png_ptr->row_buf + 1,\n          &(png_ptr->shift));\n#endif\n\n#ifdef PNG_READ_PACK_SUPPORTED\n   if (png_ptr->transformations & PNG_PACK)\n      png_do_unpack(row_info, png_ptr->row_buf + 1);\n#endif\n\n#ifdef PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED\n   /* Added at libpng-1.5.10 */\n   if (row_info->color_type == PNG_COLOR_TYPE_PALETTE &&\n       png_ptr->num_palette_max >= 0)\n      png_do_check_palette_indexes(png_ptr, row_info);\n#endif\n\n#ifdef PNG_READ_BGR_SUPPORTED\n   if (png_ptr->transformations & PNG_BGR)\n      png_do_bgr(row_info, png_ptr->row_buf + 1);\n#endif\n\n#ifdef PNG_READ_PACKSWAP_SUPPORTED\n   if (png_ptr->transformations & PNG_PACKSWAP)\n      png_do_packswap(row_info, png_ptr->row_buf + 1);\n#endif\n\n#ifdef PNG_READ_FILLER_SUPPORTED\n   if (png_ptr->transformations & PNG_FILLER)\n      png_do_read_filler(row_info, png_ptr->row_buf + 1,\n          (png_uint_32)png_ptr->filler, png_ptr->flags);\n#endif\n\n#ifdef PNG_READ_SWAP_ALPHA_SUPPORTED\n   if (png_ptr->transformations & PNG_SWAP_ALPHA)\n      png_do_read_swap_alpha(row_info, png_ptr->row_buf + 1);\n#endif\n\n#ifdef PNG_READ_16BIT_SUPPORTED\n#ifdef PNG_READ_SWAP_SUPPORTED\n   if (png_ptr->transformations & PNG_SWAP_BYTES)\n      png_do_swap(row_info, png_ptr->row_buf + 1);\n#endif\n#endif\n\n#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED\n   if (png_ptr->transformations & PNG_USER_TRANSFORM)\n    {\n      if (png_ptr->read_user_transform_fn != NULL)\n         (*(png_ptr->read_user_transform_fn)) /* User read transform function */\n             (png_ptr,     /* png_ptr */\n             row_info,     /* row_info: */\n                /*  png_uint_32 width;       width of row */\n                /*  png_size_t rowbytes;     number of bytes in row */\n                /*  png_byte color_type;     color type of pixels */\n                /*  png_byte bit_depth;      bit depth of samples */\n                /*  png_byte channels;       number of channels (1-4) */\n                /*  png_byte pixel_depth;    bits per pixel (depth*channels) */\n             png_ptr->row_buf + 1);    /* start of pixel data for row */\n#ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED\n      if (png_ptr->user_transform_depth)\n         row_info->bit_depth = png_ptr->user_transform_depth;\n\n      if (png_ptr->user_transform_channels)\n         row_info->channels = png_ptr->user_transform_channels;\n#endif\n      row_info->pixel_depth = (png_byte)(row_info->bit_depth *\n          row_info->channels);\n\n      row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, row_info->width);\n   }\n#endif\n}\n\n#endif /* PNG_READ_TRANSFORMS_SUPPORTED */\n#endif /* PNG_READ_SUPPORTED */\n"
  },
  {
    "path": "Projects/Libraries/CSBase/Source/png/pngrutil.c",
    "content": "\n/* pngrutil.c - utilities to read a PNG file\n *\n * Last changed in libpng 1.6.10 [March 6, 2014]\n * Copyright (c) 1998-2014 Glenn Randers-Pehrson\n * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)\n * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)\n *\n * This code is released under the libpng license.\n * For conditions of distribution and use, see the disclaimer\n * and license in png.h\n *\n * This file contains routines that are only called from within\n * libpng itself during the course of reading an image.\n */\n\n#include \"pngpriv.h\"\n\n#ifdef PNG_READ_SUPPORTED\n\npng_uint_32 PNGAPI\npng_get_uint_31(png_const_structrp png_ptr, png_const_bytep buf)\n{\n   png_uint_32 uval = png_get_uint_32(buf);\n\n   if (uval > PNG_UINT_31_MAX)\n      png_error(png_ptr, \"PNG unsigned integer out of range\");\n\n   return (uval);\n}\n\n#if defined(PNG_READ_gAMA_SUPPORTED) || defined(PNG_READ_cHRM_SUPPORTED)\n/* The following is a variation on the above for use with the fixed\n * point values used for gAMA and cHRM.  Instead of png_error it\n * issues a warning and returns (-1) - an invalid value because both\n * gAMA and cHRM use *unsigned* integers for fixed point values.\n */\n#define PNG_FIXED_ERROR (-1)\n\nstatic png_fixed_point /* PRIVATE */\npng_get_fixed_point(png_structrp png_ptr, png_const_bytep buf)\n{\n   png_uint_32 uval = png_get_uint_32(buf);\n\n   if (uval <= PNG_UINT_31_MAX)\n      return (png_fixed_point)uval; /* known to be in range */\n\n   /* The caller can turn off the warning by passing NULL. */\n   if (png_ptr != NULL)\n      png_warning(png_ptr, \"PNG fixed point integer out of range\");\n\n   return PNG_FIXED_ERROR;\n}\n#endif\n\n#ifdef PNG_READ_INT_FUNCTIONS_SUPPORTED\n/* NOTE: the read macros will obscure these definitions, so that if\n * PNG_USE_READ_MACROS is set the library will not use them internally,\n * but the APIs will still be available externally.\n *\n * The parentheses around \"PNGAPI function_name\" in the following three\n * functions are necessary because they allow the macros to co-exist with\n * these (unused but exported) functions.\n */\n\n/* Grab an unsigned 32-bit integer from a buffer in big-endian format. */\npng_uint_32 (PNGAPI\npng_get_uint_32)(png_const_bytep buf)\n{\n   png_uint_32 uval =\n       ((png_uint_32)(*(buf    )) << 24) +\n       ((png_uint_32)(*(buf + 1)) << 16) +\n       ((png_uint_32)(*(buf + 2)) <<  8) +\n       ((png_uint_32)(*(buf + 3))      ) ;\n\n   return uval;\n}\n\n/* Grab a signed 32-bit integer from a buffer in big-endian format.  The\n * data is stored in the PNG file in two's complement format and there\n * is no guarantee that a 'png_int_32' is exactly 32 bits, therefore\n * the following code does a two's complement to native conversion.\n */\npng_int_32 (PNGAPI\npng_get_int_32)(png_const_bytep buf)\n{\n   png_uint_32 uval = png_get_uint_32(buf);\n   if ((uval & 0x80000000) == 0) /* non-negative */\n      return uval;\n\n   uval = (uval ^ 0xffffffff) + 1;  /* 2's complement: -x = ~x+1 */\n   return -(png_int_32)uval;\n}\n\n/* Grab an unsigned 16-bit integer from a buffer in big-endian format. */\npng_uint_16 (PNGAPI\npng_get_uint_16)(png_const_bytep buf)\n{\n   /* ANSI-C requires an int value to accomodate at least 16 bits so this\n    * works and allows the compiler not to worry about possible narrowing\n    * on 32 bit systems.  (Pre-ANSI systems did not make integers smaller\n    * than 16 bits either.)\n    */\n   unsigned int val =\n       ((unsigned int)(*buf) << 8) +\n       ((unsigned int)(*(buf + 1)));\n\n   return (png_uint_16)val;\n}\n\n#endif /* PNG_READ_INT_FUNCTIONS_SUPPORTED */\n\n/* Read and check the PNG file signature */\nvoid /* PRIVATE */\npng_read_sig(png_structrp png_ptr, png_inforp info_ptr)\n{\n   png_size_t num_checked, num_to_check;\n\n   /* Exit if the user application does not expect a signature. */\n   if (png_ptr->sig_bytes >= 8)\n      return;\n\n   num_checked = png_ptr->sig_bytes;\n   num_to_check = 8 - num_checked;\n\n#ifdef PNG_IO_STATE_SUPPORTED\n   png_ptr->io_state = PNG_IO_READING | PNG_IO_SIGNATURE;\n#endif\n\n   /* The signature must be serialized in a single I/O call. */\n   png_read_data(png_ptr, &(info_ptr->signature[num_checked]), num_to_check);\n   png_ptr->sig_bytes = 8;\n\n   if (png_sig_cmp(info_ptr->signature, num_checked, num_to_check))\n   {\n      if (num_checked < 4 &&\n          png_sig_cmp(info_ptr->signature, num_checked, num_to_check - 4))\n         png_error(png_ptr, \"Not a PNG file\");\n      else\n         png_error(png_ptr, \"PNG file corrupted by ASCII conversion\");\n   }\n   if (num_checked < 3)\n      png_ptr->mode |= PNG_HAVE_PNG_SIGNATURE;\n}\n\n/* Read the chunk header (length + type name).\n * Put the type name into png_ptr->chunk_name, and return the length.\n */\npng_uint_32 /* PRIVATE */\npng_read_chunk_header(png_structrp png_ptr)\n{\n   png_byte buf[8];\n   png_uint_32 length;\n\n#ifdef PNG_IO_STATE_SUPPORTED\n   png_ptr->io_state = PNG_IO_READING | PNG_IO_CHUNK_HDR;\n#endif\n\n   /* Read the length and the chunk name.\n    * This must be performed in a single I/O call.\n    */\n   png_read_data(png_ptr, buf, 8);\n   length = png_get_uint_31(png_ptr, buf);\n\n   /* Put the chunk name into png_ptr->chunk_name. */\n   png_ptr->chunk_name = PNG_CHUNK_FROM_STRING(buf+4);\n\n   png_debug2(0, \"Reading %lx chunk, length = %lu\",\n       (unsigned long)png_ptr->chunk_name, (unsigned long)length);\n\n   /* Reset the crc and run it over the chunk name. */\n   png_reset_crc(png_ptr);\n   png_calculate_crc(png_ptr, buf + 4, 4);\n\n   /* Check to see if chunk name is valid. */\n   png_check_chunk_name(png_ptr, png_ptr->chunk_name);\n\n#ifdef PNG_IO_STATE_SUPPORTED\n   png_ptr->io_state = PNG_IO_READING | PNG_IO_CHUNK_DATA;\n#endif\n\n   return length;\n}\n\n/* Read data, and (optionally) run it through the CRC. */\nvoid /* PRIVATE */\npng_crc_read(png_structrp png_ptr, png_bytep buf, png_uint_32 length)\n{\n   if (png_ptr == NULL)\n      return;\n\n   png_read_data(png_ptr, buf, length);\n   png_calculate_crc(png_ptr, buf, length);\n}\n\n/* Optionally skip data and then check the CRC.  Depending on whether we\n * are reading an ancillary or critical chunk, and how the program has set\n * things up, we may calculate the CRC on the data and print a message.\n * Returns '1' if there was a CRC error, '0' otherwise.\n */\nint /* PRIVATE */\npng_crc_finish(png_structrp png_ptr, png_uint_32 skip)\n{\n   /* The size of the local buffer for inflate is a good guess as to a\n    * reasonable size to use for buffering reads from the application.\n    */\n   while (skip > 0)\n   {\n      png_uint_32 len;\n      png_byte tmpbuf[PNG_INFLATE_BUF_SIZE];\n\n      len = (sizeof tmpbuf);\n      if (len > skip)\n         len = skip;\n      skip -= len;\n\n      png_crc_read(png_ptr, tmpbuf, len);\n   }\n\n   if (png_crc_error(png_ptr))\n   {\n      if (PNG_CHUNK_ANCILLARY(png_ptr->chunk_name) ?\n          !(png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_NOWARN) :\n          (png_ptr->flags & PNG_FLAG_CRC_CRITICAL_USE))\n      {\n         png_chunk_warning(png_ptr, \"CRC error\");\n      }\n\n      else\n         png_chunk_error(png_ptr, \"CRC error\");\n\n      return (1);\n   }\n\n   return (0);\n}\n\n/* Compare the CRC stored in the PNG file with that calculated by libpng from\n * the data it has read thus far.\n */\nint /* PRIVATE */\npng_crc_error(png_structrp png_ptr)\n{\n   png_byte crc_bytes[4];\n   png_uint_32 crc;\n   int need_crc = 1;\n\n   if (PNG_CHUNK_ANCILLARY(png_ptr->chunk_name))\n   {\n      if ((png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_MASK) ==\n          (PNG_FLAG_CRC_ANCILLARY_USE | PNG_FLAG_CRC_ANCILLARY_NOWARN))\n         need_crc = 0;\n   }\n\n   else /* critical */\n   {\n      if (png_ptr->flags & PNG_FLAG_CRC_CRITICAL_IGNORE)\n         need_crc = 0;\n   }\n\n#ifdef PNG_IO_STATE_SUPPORTED\n   png_ptr->io_state = PNG_IO_READING | PNG_IO_CHUNK_CRC;\n#endif\n\n   /* The chunk CRC must be serialized in a single I/O call. */\n   png_read_data(png_ptr, crc_bytes, 4);\n\n   if (need_crc)\n   {\n      crc = png_get_uint_32(crc_bytes);\n      return ((int)(crc != png_ptr->crc));\n   }\n\n   else\n      return (0);\n}\n\n#if defined(PNG_READ_iCCP_SUPPORTED) || defined(PNG_READ_iTXt_SUPPORTED) ||\\\n    defined(PNG_READ_pCAL_SUPPORTED) || defined(PNG_READ_sCAL_SUPPORTED) ||\\\n    defined(PNG_READ_sPLT_SUPPORTED) || defined(PNG_READ_tEXt_SUPPORTED) ||\\\n    defined(PNG_READ_zTXt_SUPPORTED) || defined(PNG_SEQUENTIAL_READ_SUPPORTED)\n/* Manage the read buffer; this simply reallocates the buffer if it is not small\n * enough (or if it is not allocated).  The routine returns a pointer to the\n * buffer; if an error occurs and 'warn' is set the routine returns NULL, else\n * it will call png_error (via png_malloc) on failure.  (warn == 2 means\n * 'silent').\n */\nstatic png_bytep\npng_read_buffer(png_structrp png_ptr, png_alloc_size_t new_size, int warn)\n{\n   png_bytep buffer = png_ptr->read_buffer;\n\n   if (buffer != NULL && new_size > png_ptr->read_buffer_size)\n   {\n      png_ptr->read_buffer = NULL;\n      png_ptr->read_buffer = NULL;\n      png_ptr->read_buffer_size = 0;\n      png_free(png_ptr, buffer);\n      buffer = NULL;\n   }\n\n   if (buffer == NULL)\n   {\n      buffer = png_voidcast(png_bytep, png_malloc_base(png_ptr, new_size));\n\n      if (buffer != NULL)\n      {\n         png_ptr->read_buffer = buffer;\n         png_ptr->read_buffer_size = new_size;\n      }\n\n      else if (warn < 2) /* else silent */\n      {\n         if (warn)\n             png_chunk_warning(png_ptr, \"insufficient memory to read chunk\");\n\n         else\n             png_chunk_error(png_ptr, \"insufficient memory to read chunk\");\n      }\n   }\n\n   return buffer;\n}\n#endif /* PNG_READ_iCCP|iTXt|pCAL|sCAL|sPLT|tEXt|zTXt|SEQUENTIAL_READ */\n\n/* png_inflate_claim: claim the zstream for some nefarious purpose that involves\n * decompression.  Returns Z_OK on success, else a zlib error code.  It checks\n * the owner but, in final release builds, just issues a warning if some other\n * chunk apparently owns the stream.  Prior to release it does a png_error.\n */\nstatic int\npng_inflate_claim(png_structrp png_ptr, png_uint_32 owner)\n{\n   if (png_ptr->zowner != 0)\n   {\n      char msg[64];\n\n      PNG_STRING_FROM_CHUNK(msg, png_ptr->zowner);\n      /* So the message that results is \"<chunk> using zstream\"; this is an\n       * internal error, but is very useful for debugging.  i18n requirements\n       * are minimal.\n       */\n      (void)png_safecat(msg, (sizeof msg), 4, \" using zstream\");\n#     if PNG_LIBPNG_BUILD_BASE_TYPE >= PNG_LIBPNG_BUILD_RC\n         png_chunk_warning(png_ptr, msg);\n         png_ptr->zowner = 0;\n#     else\n         png_chunk_error(png_ptr, msg);\n#     endif\n   }\n\n   /* Implementation note: unlike 'png_deflate_claim' this internal function\n    * does not take the size of the data as an argument.  Some efficiency could\n    * be gained by using this when it is known *if* the zlib stream itself does\n    * not record the number; however, this is an illusion: the original writer\n    * of the PNG may have selected a lower window size, and we really must\n    * follow that because, for systems with with limited capabilities, we\n    * would otherwise reject the application's attempts to use a smaller window\n    * size (zlib doesn't have an interface to say \"this or lower\"!).\n    *\n    * inflateReset2 was added to zlib 1.2.4; before this the window could not be\n    * reset, therefore it is necessary to always allocate the maximum window\n    * size with earlier zlibs just in case later compressed chunks need it.\n    */\n   {\n      int ret; /* zlib return code */\n#     if PNG_ZLIB_VERNUM >= 0x1240\n\n#        if defined(PNG_SET_OPTION_SUPPORTED) && \\\n            defined(PNG_MAXIMUM_INFLATE_WINDOW)\n            int window_bits;\n\n            if (((png_ptr->options >> PNG_MAXIMUM_INFLATE_WINDOW) & 3) ==\n               PNG_OPTION_ON)\n               window_bits = 15;\n\n            else\n               window_bits = 0;\n#        else\n#           define window_bits 0\n#        endif\n#     endif\n\n      /* Set this for safety, just in case the previous owner left pointers to\n       * memory allocations.\n       */\n      png_ptr->zstream.next_in = NULL;\n      png_ptr->zstream.avail_in = 0;\n      png_ptr->zstream.next_out = NULL;\n      png_ptr->zstream.avail_out = 0;\n\n      if (png_ptr->flags & PNG_FLAG_ZSTREAM_INITIALIZED)\n      {\n#        if PNG_ZLIB_VERNUM < 0x1240\n            ret = inflateReset(&png_ptr->zstream);\n#        else\n            ret = inflateReset2(&png_ptr->zstream, window_bits);\n#        endif\n      }\n\n      else\n      {\n#        if PNG_ZLIB_VERNUM < 0x1240\n            ret = inflateInit(&png_ptr->zstream);\n#        else\n            ret = inflateInit2(&png_ptr->zstream, window_bits);\n#        endif\n\n         if (ret == Z_OK)\n            png_ptr->flags |= PNG_FLAG_ZSTREAM_INITIALIZED;\n      }\n\n      if (ret == Z_OK)\n         png_ptr->zowner = owner;\n\n      else\n         png_zstream_error(png_ptr, ret);\n\n      return ret;\n   }\n\n#  ifdef window_bits\n#     undef window_bits\n#  endif\n}\n\n#ifdef PNG_READ_COMPRESSED_TEXT_SUPPORTED\n/* png_inflate now returns zlib error codes including Z_OK and Z_STREAM_END to\n * allow the caller to do multiple calls if required.  If the 'finish' flag is\n * set Z_FINISH will be passed to the final inflate() call and Z_STREAM_END must\n * be returned or there has been a problem, otherwise Z_SYNC_FLUSH is used and\n * Z_OK or Z_STREAM_END will be returned on success.\n *\n * The input and output sizes are updated to the actual amounts of data consumed\n * or written, not the amount available (as in a z_stream).  The data pointers\n * are not changed, so the next input is (data+input_size) and the next\n * available output is (output+output_size).\n */\nstatic int\npng_inflate(png_structrp png_ptr, png_uint_32 owner, int finish,\n    /* INPUT: */ png_const_bytep input, png_uint_32p input_size_ptr,\n    /* OUTPUT: */ png_bytep output, png_alloc_size_t *output_size_ptr)\n{\n   if (png_ptr->zowner == owner) /* Else not claimed */\n   {\n      int ret;\n      png_alloc_size_t avail_out = *output_size_ptr;\n      png_uint_32 avail_in = *input_size_ptr;\n\n      /* zlib can't necessarily handle more than 65535 bytes at once (i.e. it\n       * can't even necessarily handle 65536 bytes) because the type uInt is\n       * \"16 bits or more\".  Consequently it is necessary to chunk the input to\n       * zlib.  This code uses ZLIB_IO_MAX, from pngpriv.h, as the maximum (the\n       * maximum value that can be stored in a uInt.)  It is possible to set\n       * ZLIB_IO_MAX to a lower value in pngpriv.h and this may sometimes have\n       * a performance advantage, because it reduces the amount of data accessed\n       * at each step and that may give the OS more time to page it in.\n       */\n      png_ptr->zstream.next_in = PNGZ_INPUT_CAST(input);\n      /* avail_in and avail_out are set below from 'size' */\n      png_ptr->zstream.avail_in = 0;\n      png_ptr->zstream.avail_out = 0;\n\n      /* Read directly into the output if it is available (this is set to\n       * a local buffer below if output is NULL).\n       */\n      if (output != NULL)\n         png_ptr->zstream.next_out = output;\n\n      do\n      {\n         uInt avail;\n         Byte local_buffer[PNG_INFLATE_BUF_SIZE];\n\n         /* zlib INPUT BUFFER */\n         /* The setting of 'avail_in' used to be outside the loop; by setting it\n          * inside it is possible to chunk the input to zlib and simply rely on\n          * zlib to advance the 'next_in' pointer.  This allows arbitrary\n          * amounts of data to be passed through zlib at the unavoidable cost of\n          * requiring a window save (memcpy of up to 32768 output bytes)\n          * every ZLIB_IO_MAX input bytes.\n          */\n         avail_in += png_ptr->zstream.avail_in; /* not consumed last time */\n\n         avail = ZLIB_IO_MAX;\n\n         if (avail_in < avail)\n            avail = (uInt)avail_in; /* safe: < than ZLIB_IO_MAX */\n\n         avail_in -= avail;\n         png_ptr->zstream.avail_in = avail;\n\n         /* zlib OUTPUT BUFFER */\n         avail_out += png_ptr->zstream.avail_out; /* not written last time */\n\n         avail = ZLIB_IO_MAX; /* maximum zlib can process */\n\n         if (output == NULL)\n         {\n            /* Reset the output buffer each time round if output is NULL and\n             * make available the full buffer, up to 'remaining_space'\n             */\n            png_ptr->zstream.next_out = local_buffer;\n            if ((sizeof local_buffer) < avail)\n               avail = (sizeof local_buffer);\n         }\n\n         if (avail_out < avail)\n            avail = (uInt)avail_out; /* safe: < ZLIB_IO_MAX */\n\n         png_ptr->zstream.avail_out = avail;\n         avail_out -= avail;\n\n         /* zlib inflate call */\n         /* In fact 'avail_out' may be 0 at this point, that happens at the end\n          * of the read when the final LZ end code was not passed at the end of\n          * the previous chunk of input data.  Tell zlib if we have reached the\n          * end of the output buffer.\n          */\n         ret = inflate(&png_ptr->zstream, avail_out > 0 ? Z_NO_FLUSH :\n            (finish ? Z_FINISH : Z_SYNC_FLUSH));\n      } while (ret == Z_OK);\n\n      /* For safety kill the local buffer pointer now */\n      if (output == NULL)\n         png_ptr->zstream.next_out = NULL;\n\n      /* Claw back the 'size' and 'remaining_space' byte counts. */\n      avail_in += png_ptr->zstream.avail_in;\n      avail_out += png_ptr->zstream.avail_out;\n\n      /* Update the input and output sizes; the updated values are the amount\n       * consumed or written, effectively the inverse of what zlib uses.\n       */\n      if (avail_out > 0)\n         *output_size_ptr -= avail_out;\n\n      if (avail_in > 0)\n         *input_size_ptr -= avail_in;\n\n      /* Ensure png_ptr->zstream.msg is set (even in the success case!) */\n      png_zstream_error(png_ptr, ret);\n      return ret;\n   }\n\n   else\n   {\n      /* This is a bad internal error.  The recovery assigns to the zstream msg\n       * pointer, which is not owned by the caller, but this is safe; it's only\n       * used on errors!\n       */\n      png_ptr->zstream.msg = PNGZ_MSG_CAST(\"zstream unclaimed\");\n      return Z_STREAM_ERROR;\n   }\n}\n\n/*\n * Decompress trailing data in a chunk.  The assumption is that read_buffer\n * points at an allocated area holding the contents of a chunk with a\n * trailing compressed part.  What we get back is an allocated area\n * holding the original prefix part and an uncompressed version of the\n * trailing part (the malloc area passed in is freed).\n */\nstatic int\npng_decompress_chunk(png_structrp png_ptr,\n   png_uint_32 chunklength, png_uint_32 prefix_size,\n   png_alloc_size_t *newlength /* must be initialized to the maximum! */,\n   int terminate /*add a '\\0' to the end of the uncompressed data*/)\n{\n   /* TODO: implement different limits for different types of chunk.\n    *\n    * The caller supplies *newlength set to the maximum length of the\n    * uncompressed data, but this routine allocates space for the prefix and\n    * maybe a '\\0' terminator too.  We have to assume that 'prefix_size' is\n    * limited only by the maximum chunk size.\n    */\n   png_alloc_size_t limit = PNG_SIZE_MAX;\n\n#  ifdef PNG_SET_CHUNK_MALLOC_LIMIT_SUPPORTED\n      if (png_ptr->user_chunk_malloc_max > 0 &&\n         png_ptr->user_chunk_malloc_max < limit)\n         limit = png_ptr->user_chunk_malloc_max;\n#  elif PNG_USER_CHUNK_MALLOC_MAX > 0\n      if (PNG_USER_CHUNK_MALLOC_MAX < limit)\n         limit = PNG_USER_CHUNK_MALLOC_MAX;\n#  endif\n\n   if (limit >= prefix_size + (terminate != 0))\n   {\n      int ret;\n\n      limit -= prefix_size + (terminate != 0);\n\n      if (limit < *newlength)\n         *newlength = limit;\n\n      /* Now try to claim the stream. */\n      ret = png_inflate_claim(png_ptr, png_ptr->chunk_name);\n\n      if (ret == Z_OK)\n      {\n         png_uint_32 lzsize = chunklength - prefix_size;\n\n         ret = png_inflate(png_ptr, png_ptr->chunk_name, 1/*finish*/,\n            /* input: */ png_ptr->read_buffer + prefix_size, &lzsize,\n            /* output: */ NULL, newlength);\n\n         if (ret == Z_STREAM_END)\n         {\n            /* Use 'inflateReset' here, not 'inflateReset2' because this\n             * preserves the previously decided window size (otherwise it would\n             * be necessary to store the previous window size.)  In practice\n             * this doesn't matter anyway, because png_inflate will call inflate\n             * with Z_FINISH in almost all cases, so the window will not be\n             * maintained.\n             */\n            if (inflateReset(&png_ptr->zstream) == Z_OK)\n            {\n               /* Because of the limit checks above we know that the new,\n                * expanded, size will fit in a size_t (let alone an\n                * png_alloc_size_t).  Use png_malloc_base here to avoid an\n                * extra OOM message.\n                */\n               png_alloc_size_t new_size = *newlength;\n               png_alloc_size_t buffer_size = prefix_size + new_size +\n                  (terminate != 0);\n               png_bytep text = png_voidcast(png_bytep, png_malloc_base(png_ptr,\n                  buffer_size));\n\n               if (text != NULL)\n               {\n                  ret = png_inflate(png_ptr, png_ptr->chunk_name, 1/*finish*/,\n                     png_ptr->read_buffer + prefix_size, &lzsize,\n                     text + prefix_size, newlength);\n\n                  if (ret == Z_STREAM_END)\n                  {\n                     if (new_size == *newlength)\n                     {\n                        if (terminate)\n                           text[prefix_size + *newlength] = 0;\n\n                        if (prefix_size > 0)\n                           memcpy(text, png_ptr->read_buffer, prefix_size);\n\n                        {\n                           png_bytep old_ptr = png_ptr->read_buffer;\n\n                           png_ptr->read_buffer = text;\n                           png_ptr->read_buffer_size = buffer_size;\n                           text = old_ptr; /* freed below */\n                        }\n                     }\n\n                     else\n                     {\n                        /* The size changed on the second read, there can be no\n                         * guarantee that anything is correct at this point.\n                         * The 'msg' pointer has been set to \"unexpected end of\n                         * LZ stream\", which is fine, but return an error code\n                         * that the caller won't accept.\n                         */\n                        ret = PNG_UNEXPECTED_ZLIB_RETURN;\n                     }\n                  }\n\n                  else if (ret == Z_OK)\n                     ret = PNG_UNEXPECTED_ZLIB_RETURN; /* for safety */\n\n                  /* Free the text pointer (this is the old read_buffer on\n                   * success)\n                   */\n                  png_free(png_ptr, text);\n\n                  /* This really is very benign, but it's still an error because\n                   * the extra space may otherwise be used as a Trojan Horse.\n                   */\n                  if (ret == Z_STREAM_END &&\n                     chunklength - prefix_size != lzsize)\n                     png_chunk_benign_error(png_ptr, \"extra compressed data\");\n               }\n\n               else\n               {\n                  /* Out of memory allocating the buffer */\n                  ret = Z_MEM_ERROR;\n                  png_zstream_error(png_ptr, Z_MEM_ERROR);\n               }\n            }\n\n            else\n            {\n               /* inflateReset failed, store the error message */\n               png_zstream_error(png_ptr, ret);\n\n               if (ret == Z_STREAM_END)\n                  ret = PNG_UNEXPECTED_ZLIB_RETURN;\n            }\n         }\n\n         else if (ret == Z_OK)\n            ret = PNG_UNEXPECTED_ZLIB_RETURN;\n\n         /* Release the claimed stream */\n         png_ptr->zowner = 0;\n      }\n\n      else /* the claim failed */ if (ret == Z_STREAM_END) /* impossible! */\n         ret = PNG_UNEXPECTED_ZLIB_RETURN;\n\n      return ret;\n   }\n\n   else\n   {\n      /* Application/configuration limits exceeded */\n      png_zstream_error(png_ptr, Z_MEM_ERROR);\n      return Z_MEM_ERROR;\n   }\n}\n#endif /* PNG_READ_COMPRESSED_TEXT_SUPPORTED */\n\n#ifdef PNG_READ_iCCP_SUPPORTED\n/* Perform a partial read and decompress, producing 'avail_out' bytes and\n * reading from the current chunk as required.\n */\nstatic int\npng_inflate_read(png_structrp png_ptr, png_bytep read_buffer, uInt read_size,\n   png_uint_32p chunk_bytes, png_bytep next_out, png_alloc_size_t *out_size,\n   int finish)\n{\n   if (png_ptr->zowner == png_ptr->chunk_name)\n   {\n      int ret;\n\n      /* next_in and avail_in must have been initialized by the caller. */\n      png_ptr->zstream.next_out = next_out;\n      png_ptr->zstream.avail_out = 0; /* set in the loop */\n\n      do\n      {\n         if (png_ptr->zstream.avail_in == 0)\n         {\n            if (read_size > *chunk_bytes)\n               read_size = (uInt)*chunk_bytes;\n            *chunk_bytes -= read_size;\n\n            if (read_size > 0)\n               png_crc_read(png_ptr, read_buffer, read_size);\n\n            png_ptr->zstream.next_in = read_buffer;\n            png_ptr->zstream.avail_in = read_size;\n         }\n\n         if (png_ptr->zstream.avail_out == 0)\n         {\n            uInt avail = ZLIB_IO_MAX;\n            if (avail > *out_size)\n               avail = (uInt)*out_size;\n            *out_size -= avail;\n\n            png_ptr->zstream.avail_out = avail;\n         }\n\n         /* Use Z_SYNC_FLUSH when there is no more chunk data to ensure that all\n          * the available output is produced; this allows reading of truncated\n          * streams.\n          */\n         ret = inflate(&png_ptr->zstream,\n            *chunk_bytes > 0 ? Z_NO_FLUSH : (finish ? Z_FINISH : Z_SYNC_FLUSH));\n      }\n      while (ret == Z_OK && (*out_size > 0 || png_ptr->zstream.avail_out > 0));\n\n      *out_size += png_ptr->zstream.avail_out;\n      png_ptr->zstream.avail_out = 0; /* Should not be required, but is safe */\n\n      /* Ensure the error message pointer is always set: */\n      png_zstream_error(png_ptr, ret);\n      return ret;\n   }\n\n   else\n   {\n      png_ptr->zstream.msg = PNGZ_MSG_CAST(\"zstream unclaimed\");\n      return Z_STREAM_ERROR;\n   }\n}\n#endif\n\n/* Read and check the IDHR chunk */\nvoid /* PRIVATE */\npng_handle_IHDR(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)\n{\n   png_byte buf[13];\n   png_uint_32 width, height;\n   int bit_depth, color_type, compression_type, filter_type;\n   int interlace_type;\n\n   png_debug(1, \"in png_handle_IHDR\");\n\n   if (png_ptr->mode & PNG_HAVE_IHDR)\n      png_chunk_error(png_ptr, \"out of place\");\n\n   /* Check the length */\n   if (length != 13)\n      png_chunk_error(png_ptr, \"invalid\");\n\n   png_ptr->mode |= PNG_HAVE_IHDR;\n\n   png_crc_read(png_ptr, buf, 13);\n   png_crc_finish(png_ptr, 0);\n\n   width = png_get_uint_31(png_ptr, buf);\n   height = png_get_uint_31(png_ptr, buf + 4);\n   bit_depth = buf[8];\n   color_type = buf[9];\n   compression_type = buf[10];\n   filter_type = buf[11];\n   interlace_type = buf[12];\n\n   /* Set internal variables */\n   png_ptr->width = width;\n   png_ptr->height = height;\n   png_ptr->bit_depth = (png_byte)bit_depth;\n   png_ptr->interlaced = (png_byte)interlace_type;\n   png_ptr->color_type = (png_byte)color_type;\n#ifdef PNG_MNG_FEATURES_SUPPORTED\n   png_ptr->filter_type = (png_byte)filter_type;\n#endif\n   png_ptr->compression_type = (png_byte)compression_type;\n\n   /* Find number of channels */\n   switch (png_ptr->color_type)\n   {\n      default: /* invalid, png_set_IHDR calls png_error */\n      case PNG_COLOR_TYPE_GRAY:\n      case PNG_COLOR_TYPE_PALETTE:\n         png_ptr->channels = 1;\n         break;\n\n      case PNG_COLOR_TYPE_RGB:\n         png_ptr->channels = 3;\n         break;\n\n      case PNG_COLOR_TYPE_GRAY_ALPHA:\n         png_ptr->channels = 2;\n         break;\n\n      case PNG_COLOR_TYPE_RGB_ALPHA:\n         png_ptr->channels = 4;\n         break;\n   }\n\n   /* Set up other useful info */\n   png_ptr->pixel_depth = (png_byte)(png_ptr->bit_depth *\n   png_ptr->channels);\n   png_ptr->rowbytes = PNG_ROWBYTES(png_ptr->pixel_depth, png_ptr->width);\n   png_debug1(3, \"bit_depth = %d\", png_ptr->bit_depth);\n   png_debug1(3, \"channels = %d\", png_ptr->channels);\n   png_debug1(3, \"rowbytes = %lu\", (unsigned long)png_ptr->rowbytes);\n   png_set_IHDR(png_ptr, info_ptr, width, height, bit_depth,\n       color_type, interlace_type, compression_type, filter_type);\n}\n\n/* Read and check the palette */\nvoid /* PRIVATE */\npng_handle_PLTE(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)\n{\n   png_color palette[PNG_MAX_PALETTE_LENGTH];\n   int num, i;\n#ifdef PNG_POINTER_INDEXING_SUPPORTED\n   png_colorp pal_ptr;\n#endif\n\n   png_debug(1, \"in png_handle_PLTE\");\n\n   if (!(png_ptr->mode & PNG_HAVE_IHDR))\n      png_chunk_error(png_ptr, \"missing IHDR\");\n\n   /* Moved to before the 'after IDAT' check below because otherwise duplicate\n    * PLTE chunks are potentially ignored (the spec says there shall not be more\n    * than one PLTE, the error is not treated as benign, so this check trumps\n    * the requirement that PLTE appears before IDAT.)\n    */\n   else if (png_ptr->mode & PNG_HAVE_PLTE)\n      png_chunk_error(png_ptr, \"duplicate\");\n\n   else if (png_ptr->mode & PNG_HAVE_IDAT)\n   {\n      /* This is benign because the non-benign error happened before, when an\n       * IDAT was encountered in a color-mapped image with no PLTE.\n       */\n      png_crc_finish(png_ptr, length);\n      png_chunk_benign_error(png_ptr, \"out of place\");\n      return;\n   }\n\n   png_ptr->mode |= PNG_HAVE_PLTE;\n\n   if (!(png_ptr->color_type & PNG_COLOR_MASK_COLOR))\n   {\n      png_crc_finish(png_ptr, length);\n      png_chunk_benign_error(png_ptr, \"ignored in grayscale PNG\");\n      return;\n   }\n\n#ifndef PNG_READ_OPT_PLTE_SUPPORTED\n   if (png_ptr->color_type != PNG_COLOR_TYPE_PALETTE)\n   {\n      png_crc_finish(png_ptr, length);\n      return;\n   }\n#endif\n\n   if (length > 3*PNG_MAX_PALETTE_LENGTH || length % 3)\n   {\n      png_crc_finish(png_ptr, length);\n\n      if (png_ptr->color_type != PNG_COLOR_TYPE_PALETTE)\n         png_chunk_benign_error(png_ptr, \"invalid\");\n\n      else\n         png_chunk_error(png_ptr, \"invalid\");\n\n      return;\n   }\n\n   /* The cast is safe because 'length' is less than 3*PNG_MAX_PALETTE_LENGTH */\n   num = (int)length / 3;\n\n#ifdef PNG_POINTER_INDEXING_SUPPORTED\n   for (i = 0, pal_ptr = palette; i < num; i++, pal_ptr++)\n   {\n      png_byte buf[3];\n\n      png_crc_read(png_ptr, buf, 3);\n      pal_ptr->red = buf[0];\n      pal_ptr->green = buf[1];\n      pal_ptr->blue = buf[2];\n   }\n#else\n   for (i = 0; i < num; i++)\n   {\n      png_byte buf[3];\n\n      png_crc_read(png_ptr, buf, 3);\n      /* Don't depend upon png_color being any order */\n      palette[i].red = buf[0];\n      palette[i].green = buf[1];\n      palette[i].blue = buf[2];\n   }\n#endif\n\n   /* If we actually need the PLTE chunk (ie for a paletted image), we do\n    * whatever the normal CRC configuration tells us.  However, if we\n    * have an RGB image, the PLTE can be considered ancillary, so\n    * we will act as though it is.\n    */\n#ifndef PNG_READ_OPT_PLTE_SUPPORTED\n   if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)\n#endif\n   {\n      png_crc_finish(png_ptr, 0);\n   }\n\n#ifndef PNG_READ_OPT_PLTE_SUPPORTED\n   else if (png_crc_error(png_ptr))  /* Only if we have a CRC error */\n   {\n      /* If we don't want to use the data from an ancillary chunk,\n       * we have two options: an error abort, or a warning and we\n       * ignore the data in this chunk (which should be OK, since\n       * it's considered ancillary for a RGB or RGBA image).\n       *\n       * IMPLEMENTATION NOTE: this is only here because png_crc_finish uses the\n       * chunk type to determine whether to check the ancillary or the critical\n       * flags.\n       */\n      if (!(png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_USE))\n      {\n         if (png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_NOWARN)\n            return;\n\n         else\n            png_chunk_error(png_ptr, \"CRC error\");\n      }\n\n      /* Otherwise, we (optionally) emit a warning and use the chunk. */\n      else if (!(png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_NOWARN))\n         png_chunk_warning(png_ptr, \"CRC error\");\n   }\n#endif\n\n   /* TODO: png_set_PLTE has the side effect of setting png_ptr->palette to its\n    * own copy of the palette.  This has the side effect that when png_start_row\n    * is called (this happens after any call to png_read_update_info) the\n    * info_ptr palette gets changed.  This is extremely unexpected and\n    * confusing.\n    *\n    * Fix this by not sharing the palette in this way.\n    */\n   png_set_PLTE(png_ptr, info_ptr, palette, num);\n\n   /* The three chunks, bKGD, hIST and tRNS *must* appear after PLTE and before\n    * IDAT.  Prior to 1.6.0 this was not checked; instead the code merely\n    * checked the apparent validity of a tRNS chunk inserted before PLTE on a\n    * palette PNG.  1.6.0 attempts to rigorously follow the standard and\n    * therefore does a benign error if the erroneous condition is detected *and*\n    * cancels the tRNS if the benign error returns.  The alternative is to\n    * amend the standard since it would be rather hypocritical of the standards\n    * maintainers to ignore it.\n    */\n#ifdef PNG_READ_tRNS_SUPPORTED\n   if (png_ptr->num_trans > 0 ||\n      (info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS) != 0))\n   {\n      /* Cancel this because otherwise it would be used if the transforms\n       * require it.  Don't cancel the 'valid' flag because this would prevent\n       * detection of duplicate chunks.\n       */\n      png_ptr->num_trans = 0;\n\n      if (info_ptr != NULL)\n         info_ptr->num_trans = 0;\n\n      png_chunk_benign_error(png_ptr, \"tRNS must be after\");\n   }\n#endif\n\n#ifdef PNG_READ_hIST_SUPPORTED\n   if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_hIST) != 0)\n      png_chunk_benign_error(png_ptr, \"hIST must be after\");\n#endif\n\n#ifdef PNG_READ_bKGD_SUPPORTED\n   if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_bKGD) != 0)\n      png_chunk_benign_error(png_ptr, \"bKGD must be after\");\n#endif\n}\n\nvoid /* PRIVATE */\npng_handle_IEND(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)\n{\n   png_debug(1, \"in png_handle_IEND\");\n\n   if (!(png_ptr->mode & PNG_HAVE_IHDR) || !(png_ptr->mode & PNG_HAVE_IDAT))\n      png_chunk_error(png_ptr, \"out of place\");\n\n   png_ptr->mode |= (PNG_AFTER_IDAT | PNG_HAVE_IEND);\n\n   png_crc_finish(png_ptr, length);\n\n   if (length != 0)\n      png_chunk_benign_error(png_ptr, \"invalid\");\n\n   PNG_UNUSED(info_ptr)\n}\n\n#ifdef PNG_READ_gAMA_SUPPORTED\nvoid /* PRIVATE */\npng_handle_gAMA(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)\n{\n   png_fixed_point igamma;\n   png_byte buf[4];\n\n   png_debug(1, \"in png_handle_gAMA\");\n\n   if (!(png_ptr->mode & PNG_HAVE_IHDR))\n      png_chunk_error(png_ptr, \"missing IHDR\");\n\n   else if (png_ptr->mode & (PNG_HAVE_IDAT|PNG_HAVE_PLTE))\n   {\n      png_crc_finish(png_ptr, length);\n      png_chunk_benign_error(png_ptr, \"out of place\");\n      return;\n   }\n\n   if (length != 4)\n   {\n      png_crc_finish(png_ptr, length);\n      png_chunk_benign_error(png_ptr, \"invalid\");\n      return;\n   }\n\n   png_crc_read(png_ptr, buf, 4);\n\n   if (png_crc_finish(png_ptr, 0))\n      return;\n\n   igamma = png_get_fixed_point(NULL, buf);\n\n   png_colorspace_set_gamma(png_ptr, &png_ptr->colorspace, igamma);\n   png_colorspace_sync(png_ptr, info_ptr);\n}\n#endif\n\n#ifdef PNG_READ_sBIT_SUPPORTED\nvoid /* PRIVATE */\npng_handle_sBIT(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)\n{\n   unsigned int truelen, i;\n   png_byte sample_depth;\n   png_byte buf[4];\n\n   png_debug(1, \"in png_handle_sBIT\");\n\n   if (!(png_ptr->mode & PNG_HAVE_IHDR))\n      png_chunk_error(png_ptr, \"missing IHDR\");\n\n   else if (png_ptr->mode & (PNG_HAVE_IDAT|PNG_HAVE_PLTE))\n   {\n      png_crc_finish(png_ptr, length);\n      png_chunk_benign_error(png_ptr, \"out of place\");\n      return;\n   }\n\n   if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_sBIT))\n   {\n      png_crc_finish(png_ptr, length);\n      png_chunk_benign_error(png_ptr, \"duplicate\");\n      return;\n   }\n\n   if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)\n   {\n      truelen = 3;\n      sample_depth = 8;\n   }\n\n   else\n   {\n      truelen = png_ptr->channels;\n      sample_depth = png_ptr->bit_depth;\n   }\n\n   if (length != truelen || length > 4)\n   {\n      png_chunk_benign_error(png_ptr, \"invalid\");\n      png_crc_finish(png_ptr, length);\n      return;\n   }\n\n   buf[0] = buf[1] = buf[2] = buf[3] = sample_depth;\n   png_crc_read(png_ptr, buf, truelen);\n\n   if (png_crc_finish(png_ptr, 0))\n      return;\n\n   for (i=0; i<truelen; ++i)\n      if (buf[i] == 0 || buf[i] > sample_depth)\n      {\n         png_chunk_benign_error(png_ptr, \"invalid\");\n         return;\n      }\n\n   if (png_ptr->color_type & PNG_COLOR_MASK_COLOR)\n   {\n      png_ptr->sig_bit.red = buf[0];\n      png_ptr->sig_bit.green = buf[1];\n      png_ptr->sig_bit.blue = buf[2];\n      png_ptr->sig_bit.alpha = buf[3];\n   }\n\n   else\n   {\n      png_ptr->sig_bit.gray = buf[0];\n      png_ptr->sig_bit.red = buf[0];\n      png_ptr->sig_bit.green = buf[0];\n      png_ptr->sig_bit.blue = buf[0];\n      png_ptr->sig_bit.alpha = buf[1];\n   }\n\n   png_set_sBIT(png_ptr, info_ptr, &(png_ptr->sig_bit));\n}\n#endif\n\n#ifdef PNG_READ_cHRM_SUPPORTED\nvoid /* PRIVATE */\npng_handle_cHRM(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)\n{\n   png_byte buf[32];\n   png_xy xy;\n\n   png_debug(1, \"in png_handle_cHRM\");\n\n   if (!(png_ptr->mode & PNG_HAVE_IHDR))\n      png_chunk_error(png_ptr, \"missing IHDR\");\n\n   else if (png_ptr->mode & (PNG_HAVE_IDAT|PNG_HAVE_PLTE))\n   {\n      png_crc_finish(png_ptr, length);\n      png_chunk_benign_error(png_ptr, \"out of place\");\n      return;\n   }\n\n   if (length != 32)\n   {\n      png_crc_finish(png_ptr, length);\n      png_chunk_benign_error(png_ptr, \"invalid\");\n      return;\n   }\n\n   png_crc_read(png_ptr, buf, 32);\n\n   if (png_crc_finish(png_ptr, 0))\n      return;\n\n   xy.whitex = png_get_fixed_point(NULL, buf);\n   xy.whitey = png_get_fixed_point(NULL, buf + 4);\n   xy.redx   = png_get_fixed_point(NULL, buf + 8);\n   xy.redy   = png_get_fixed_point(NULL, buf + 12);\n   xy.greenx = png_get_fixed_point(NULL, buf + 16);\n   xy.greeny = png_get_fixed_point(NULL, buf + 20);\n   xy.bluex  = png_get_fixed_point(NULL, buf + 24);\n   xy.bluey  = png_get_fixed_point(NULL, buf + 28);\n\n   if (xy.whitex == PNG_FIXED_ERROR ||\n       xy.whitey == PNG_FIXED_ERROR ||\n       xy.redx   == PNG_FIXED_ERROR ||\n       xy.redy   == PNG_FIXED_ERROR ||\n       xy.greenx == PNG_FIXED_ERROR ||\n       xy.greeny == PNG_FIXED_ERROR ||\n       xy.bluex  == PNG_FIXED_ERROR ||\n       xy.bluey  == PNG_FIXED_ERROR)\n   {\n      png_chunk_benign_error(png_ptr, \"invalid values\");\n      return;\n   }\n\n   /* If a colorspace error has already been output skip this chunk */\n   if (png_ptr->colorspace.flags & PNG_COLORSPACE_INVALID)\n      return;\n\n   if (png_ptr->colorspace.flags & PNG_COLORSPACE_FROM_cHRM)\n   {\n      png_ptr->colorspace.flags |= PNG_COLORSPACE_INVALID;\n      png_colorspace_sync(png_ptr, info_ptr);\n      png_chunk_benign_error(png_ptr, \"duplicate\");\n      return;\n   }\n\n   png_ptr->colorspace.flags |= PNG_COLORSPACE_FROM_cHRM;\n   (void)png_colorspace_set_chromaticities(png_ptr, &png_ptr->colorspace, &xy,\n      1/*prefer cHRM values*/);\n   png_colorspace_sync(png_ptr, info_ptr);\n}\n#endif\n\n#ifdef PNG_READ_sRGB_SUPPORTED\nvoid /* PRIVATE */\npng_handle_sRGB(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)\n{\n   png_byte intent;\n\n   png_debug(1, \"in png_handle_sRGB\");\n\n   if (!(png_ptr->mode & PNG_HAVE_IHDR))\n      png_chunk_error(png_ptr, \"missing IHDR\");\n\n   else if (png_ptr->mode & (PNG_HAVE_IDAT|PNG_HAVE_PLTE))\n   {\n      png_crc_finish(png_ptr, length);\n      png_chunk_benign_error(png_ptr, \"out of place\");\n      return;\n   }\n\n   if (length != 1)\n   {\n      png_crc_finish(png_ptr, length);\n      png_chunk_benign_error(png_ptr, \"invalid\");\n      return;\n   }\n\n   png_crc_read(png_ptr, &intent, 1);\n\n   if (png_crc_finish(png_ptr, 0))\n      return;\n\n   /* If a colorspace error has already been output skip this chunk */\n   if (png_ptr->colorspace.flags & PNG_COLORSPACE_INVALID)\n      return;\n\n   /* Only one sRGB or iCCP chunk is allowed, use the HAVE_INTENT flag to detect\n    * this.\n    */\n   if (png_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_INTENT)\n   {\n      png_ptr->colorspace.flags |= PNG_COLORSPACE_INVALID;\n      png_colorspace_sync(png_ptr, info_ptr);\n      png_chunk_benign_error(png_ptr, \"too many profiles\");\n      return;\n   }\n\n   (void)png_colorspace_set_sRGB(png_ptr, &png_ptr->colorspace, intent);\n   png_colorspace_sync(png_ptr, info_ptr);\n}\n#endif /* PNG_READ_sRGB_SUPPORTED */\n\n#ifdef PNG_READ_iCCP_SUPPORTED\nvoid /* PRIVATE */\npng_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)\n/* Note: this does not properly handle profiles that are > 64K under DOS */\n{\n   png_const_charp errmsg = NULL; /* error message output, or no error */\n   int finished = 0; /* crc checked */\n\n   png_debug(1, \"in png_handle_iCCP\");\n\n   if (!(png_ptr->mode & PNG_HAVE_IHDR))\n      png_chunk_error(png_ptr, \"missing IHDR\");\n\n   else if (png_ptr->mode & (PNG_HAVE_IDAT|PNG_HAVE_PLTE))\n   {\n      png_crc_finish(png_ptr, length);\n      png_chunk_benign_error(png_ptr, \"out of place\");\n      return;\n   }\n\n   /* Consistent with all the above colorspace handling an obviously *invalid*\n    * chunk is just ignored, so does not invalidate the color space.  An\n    * alternative is to set the 'invalid' flags at the start of this routine\n    * and only clear them in they were not set before and all the tests pass.\n    * The minimum 'deflate' stream is assumed to be just the 2 byte header and 4\n    * byte checksum.  The keyword must be one character and there is a\n    * terminator (0) byte and the compression method.\n    */\n   if (length < 9)\n   {\n      png_crc_finish(png_ptr, length);\n      png_chunk_benign_error(png_ptr, \"too short\");\n      return;\n   }\n\n   /* If a colorspace error has already been output skip this chunk */\n   if (png_ptr->colorspace.flags & PNG_COLORSPACE_INVALID)\n   {\n      png_crc_finish(png_ptr, length);\n      return;\n   }\n\n   /* Only one sRGB or iCCP chunk is allowed, use the HAVE_INTENT flag to detect\n    * this.\n    */\n   if ((png_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_INTENT) == 0)\n   {\n      uInt read_length, keyword_length;\n      char keyword[81];\n\n      /* Find the keyword; the keyword plus separator and compression method\n       * bytes can be at most 81 characters long.\n       */\n      read_length = 81; /* maximum */\n      if (read_length > length)\n         read_length = (uInt)length;\n\n      png_crc_read(png_ptr, (png_bytep)keyword, read_length);\n      length -= read_length;\n\n      keyword_length = 0;\n      while (keyword_length < 80 && keyword_length < read_length &&\n         keyword[keyword_length] != 0)\n         ++keyword_length;\n\n      /* TODO: make the keyword checking common */\n      if (keyword_length >= 1 && keyword_length <= 79)\n      {\n         /* We only understand '0' compression - deflate - so if we get a\n          * different value we can't safely decode the chunk.\n          */\n         if (keyword_length+1 < read_length &&\n            keyword[keyword_length+1] == PNG_COMPRESSION_TYPE_BASE)\n         {\n            read_length -= keyword_length+2;\n\n            if (png_inflate_claim(png_ptr, png_iCCP) == Z_OK)\n            {\n               Byte profile_header[132];\n               Byte local_buffer[PNG_INFLATE_BUF_SIZE];\n               png_alloc_size_t size = (sizeof profile_header);\n\n               png_ptr->zstream.next_in = (Bytef*)keyword + (keyword_length+2);\n               png_ptr->zstream.avail_in = read_length;\n               (void)png_inflate_read(png_ptr, local_buffer,\n                  (sizeof local_buffer), &length, profile_header, &size,\n                  0/*finish: don't, because the output is too small*/);\n\n               if (size == 0)\n               {\n                  /* We have the ICC profile header; do the basic header checks.\n                   */\n                  const png_uint_32 profile_length =\n                     png_get_uint_32(profile_header);\n\n                  if (png_icc_check_length(png_ptr, &png_ptr->colorspace,\n                     keyword, profile_length))\n                  {\n                     /* The length is apparently ok, so we can check the 132\n                      * byte header.\n                      */\n                     if (png_icc_check_header(png_ptr, &png_ptr->colorspace,\n                        keyword, profile_length, profile_header,\n                        png_ptr->color_type))\n                     {\n                        /* Now read the tag table; a variable size buffer is\n                         * needed at this point, allocate one for the whole\n                         * profile.  The header check has already validated\n                         * that none of these stuff will overflow.\n                         */\n                        const png_uint_32 tag_count = png_get_uint_32(\n                           profile_header+128);\n                        png_bytep profile = png_read_buffer(png_ptr,\n                           profile_length, 2/*silent*/);\n\n                        if (profile != NULL)\n                        {\n                           memcpy(profile, profile_header,\n                              (sizeof profile_header));\n\n                           size = 12 * tag_count;\n\n                           (void)png_inflate_read(png_ptr, local_buffer,\n                              (sizeof local_buffer), &length,\n                              profile + (sizeof profile_header), &size, 0);\n\n                           /* Still expect a buffer error because we expect\n                            * there to be some tag data!\n                            */\n                           if (size == 0)\n                           {\n                              if (png_icc_check_tag_table(png_ptr,\n                                 &png_ptr->colorspace, keyword, profile_length,\n                                 profile))\n                              {\n                                 /* The profile has been validated for basic\n                                  * security issues, so read the whole thing in.\n                                  */\n                                 size = profile_length - (sizeof profile_header)\n                                    - 12 * tag_count;\n\n                                 (void)png_inflate_read(png_ptr, local_buffer,\n                                    (sizeof local_buffer), &length,\n                                    profile + (sizeof profile_header) +\n                                    12 * tag_count, &size, 1/*finish*/);\n\n                                 if (length > 0 && !(png_ptr->flags &\n                                       PNG_FLAG_BENIGN_ERRORS_WARN))\n                                    errmsg = \"extra compressed data\";\n\n                                 /* But otherwise allow extra data: */\n                                 else if (size == 0)\n                                 {\n                                    if (length > 0)\n                                    {\n                                       /* This can be handled completely, so\n                                        * keep going.\n                                        */\n                                       png_chunk_warning(png_ptr,\n                                          \"extra compressed data\");\n                                    }\n\n                                    png_crc_finish(png_ptr, length);\n                                    finished = 1;\n\n#                                   ifdef PNG_sRGB_SUPPORTED\n                                       /* Check for a match against sRGB */\n                                       png_icc_set_sRGB(png_ptr,\n                                          &png_ptr->colorspace, profile,\n                                          png_ptr->zstream.adler);\n#                                   endif\n\n                                    /* Steal the profile for info_ptr. */\n                                    if (info_ptr != NULL)\n                                    {\n                                       png_free_data(png_ptr, info_ptr,\n                                          PNG_FREE_ICCP, 0);\n\n                                       info_ptr->iccp_name = png_voidcast(char*,\n                                          png_malloc_base(png_ptr,\n                                          keyword_length+1));\n                                       if (info_ptr->iccp_name != NULL)\n                                       {\n                                          memcpy(info_ptr->iccp_name, keyword,\n                                             keyword_length+1);\n                                          info_ptr->iccp_proflen =\n                                             profile_length;\n                                          info_ptr->iccp_profile = profile;\n                                          png_ptr->read_buffer = NULL; /*steal*/\n                                          info_ptr->free_me |= PNG_FREE_ICCP;\n                                          info_ptr->valid |= PNG_INFO_iCCP;\n                                       }\n\n                                       else\n                                       {\n                                          png_ptr->colorspace.flags |=\n                                             PNG_COLORSPACE_INVALID;\n                                          errmsg = \"out of memory\";\n                                       }\n                                    }\n\n                                    /* else the profile remains in the read\n                                     * buffer which gets reused for subsequent\n                                     * chunks.\n                                     */\n\n                                    if (info_ptr != NULL)\n                                       png_colorspace_sync(png_ptr, info_ptr);\n\n                                    if (errmsg == NULL)\n                                    {\n                                       png_ptr->zowner = 0;\n                                       return;\n                                    }\n                                 }\n\n                                 else if (size > 0)\n                                    errmsg = \"truncated\";\n\n                                 else\n                                    errmsg = png_ptr->zstream.msg;\n                              }\n\n                              /* else png_icc_check_tag_table output an error */\n                           }\n\n                           else /* profile truncated */\n                              errmsg = png_ptr->zstream.msg;\n                        }\n\n                        else\n                           errmsg = \"out of memory\";\n                     }\n\n                     /* else png_icc_check_header output an error */\n                  }\n\n                  /* else png_icc_check_length output an error */\n               }\n\n               else /* profile truncated */\n                  errmsg = png_ptr->zstream.msg;\n\n               /* Release the stream */\n               png_ptr->zowner = 0;\n            }\n\n            else /* png_inflate_claim failed */\n               errmsg = png_ptr->zstream.msg;\n         }\n\n         else\n            errmsg = \"bad compression method\"; /* or missing */\n      }\n\n      else\n         errmsg = \"bad keyword\";\n   }\n\n   else\n      errmsg = \"too many profiles\";\n\n   /* Failure: the reason is in 'errmsg' */\n   if (!finished)\n      png_crc_finish(png_ptr, length);\n\n   png_ptr->colorspace.flags |= PNG_COLORSPACE_INVALID;\n   png_colorspace_sync(png_ptr, info_ptr);\n   if (errmsg != NULL) /* else already output */\n      png_chunk_benign_error(png_ptr, errmsg);\n}\n#endif /* PNG_READ_iCCP_SUPPORTED */\n\n#ifdef PNG_READ_sPLT_SUPPORTED\nvoid /* PRIVATE */\npng_handle_sPLT(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)\n/* Note: this does not properly handle chunks that are > 64K under DOS */\n{\n   png_bytep entry_start, buffer;\n   png_sPLT_t new_palette;\n   png_sPLT_entryp pp;\n   png_uint_32 data_length;\n   int entry_size, i;\n   png_uint_32 skip = 0;\n   png_uint_32 dl;\n   png_size_t max_dl;\n\n   png_debug(1, \"in png_handle_sPLT\");\n\n#ifdef PNG_USER_LIMITS_SUPPORTED\n   if (png_ptr->user_chunk_cache_max != 0)\n   {\n      if (png_ptr->user_chunk_cache_max == 1)\n      {\n         png_crc_finish(png_ptr, length);\n         return;\n      }\n\n      if (--png_ptr->user_chunk_cache_max == 1)\n      {\n         png_warning(png_ptr, \"No space in chunk cache for sPLT\");\n         png_crc_finish(png_ptr, length);\n         return;\n      }\n   }\n#endif\n\n   if (!(png_ptr->mode & PNG_HAVE_IHDR))\n      png_chunk_error(png_ptr, \"missing IHDR\");\n\n   else if (png_ptr->mode & PNG_HAVE_IDAT)\n   {\n      png_crc_finish(png_ptr, length);\n      png_chunk_benign_error(png_ptr, \"out of place\");\n      return;\n   }\n\n#ifdef PNG_MAX_MALLOC_64K\n   if (length > 65535U)\n   {\n      png_crc_finish(png_ptr, length);\n      png_chunk_benign_error(png_ptr, \"too large to fit in memory\");\n      return;\n   }\n#endif\n\n   buffer = png_read_buffer(png_ptr, length+1, 2/*silent*/);\n   if (buffer == NULL)\n   {\n      png_crc_finish(png_ptr, length);\n      png_chunk_benign_error(png_ptr, \"out of memory\");\n      return;\n   }\n\n\n   /* WARNING: this may break if size_t is less than 32 bits; it is assumed\n    * that the PNG_MAX_MALLOC_64K test is enabled in this case, but this is a\n    * potential breakage point if the types in pngconf.h aren't exactly right.\n    */\n   png_crc_read(png_ptr, buffer, length);\n\n   if (png_crc_finish(png_ptr, skip))\n      return;\n\n   buffer[length] = 0;\n\n   for (entry_start = buffer; *entry_start; entry_start++)\n      /* Empty loop to find end of name */ ;\n\n   ++entry_start;\n\n   /* A sample depth should follow the separator, and we should be on it  */\n   if (entry_start > buffer + length - 2)\n   {\n      png_warning(png_ptr, \"malformed sPLT chunk\");\n      return;\n   }\n\n   new_palette.depth = *entry_start++;\n   entry_size = (new_palette.depth == 8 ? 6 : 10);\n   /* This must fit in a png_uint_32 because it is derived from the original\n    * chunk data length.\n    */\n   data_length = length - (png_uint_32)(entry_start - buffer);\n\n   /* Integrity-check the data length */\n   if (data_length % entry_size)\n   {\n      png_warning(png_ptr, \"sPLT chunk has bad length\");\n      return;\n   }\n\n   dl = (png_int_32)(data_length / entry_size);\n   max_dl = PNG_SIZE_MAX / (sizeof (png_sPLT_entry));\n\n   if (dl > max_dl)\n   {\n       png_warning(png_ptr, \"sPLT chunk too long\");\n       return;\n   }\n\n   new_palette.nentries = (png_int_32)(data_length / entry_size);\n\n   new_palette.entries = (png_sPLT_entryp)png_malloc_warn(\n       png_ptr, new_palette.nentries * (sizeof (png_sPLT_entry)));\n\n   if (new_palette.entries == NULL)\n   {\n       png_warning(png_ptr, \"sPLT chunk requires too much memory\");\n       return;\n   }\n\n#ifdef PNG_POINTER_INDEXING_SUPPORTED\n   for (i = 0; i < new_palette.nentries; i++)\n   {\n      pp = new_palette.entries + i;\n\n      if (new_palette.depth == 8)\n      {\n         pp->red = *entry_start++;\n         pp->green = *entry_start++;\n         pp->blue = *entry_start++;\n         pp->alpha = *entry_start++;\n      }\n\n      else\n      {\n         pp->red   = png_get_uint_16(entry_start); entry_start += 2;\n         pp->green = png_get_uint_16(entry_start); entry_start += 2;\n         pp->blue  = png_get_uint_16(entry_start); entry_start += 2;\n         pp->alpha = png_get_uint_16(entry_start); entry_start += 2;\n      }\n\n      pp->frequency = png_get_uint_16(entry_start); entry_start += 2;\n   }\n#else\n   pp = new_palette.entries;\n\n   for (i = 0; i < new_palette.nentries; i++)\n   {\n\n      if (new_palette.depth == 8)\n      {\n         pp[i].red   = *entry_start++;\n         pp[i].green = *entry_start++;\n         pp[i].blue  = *entry_start++;\n         pp[i].alpha = *entry_start++;\n      }\n\n      else\n      {\n         pp[i].red   = png_get_uint_16(entry_start); entry_start += 2;\n         pp[i].green = png_get_uint_16(entry_start); entry_start += 2;\n         pp[i].blue  = png_get_uint_16(entry_start); entry_start += 2;\n         pp[i].alpha = png_get_uint_16(entry_start); entry_start += 2;\n      }\n\n      pp[i].frequency = png_get_uint_16(entry_start); entry_start += 2;\n   }\n#endif\n\n   /* Discard all chunk data except the name and stash that */\n   new_palette.name = (png_charp)buffer;\n\n   png_set_sPLT(png_ptr, info_ptr, &new_palette, 1);\n\n   png_free(png_ptr, new_palette.entries);\n}\n#endif /* PNG_READ_sPLT_SUPPORTED */\n\n#ifdef PNG_READ_tRNS_SUPPORTED\nvoid /* PRIVATE */\npng_handle_tRNS(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)\n{\n   png_byte readbuf[PNG_MAX_PALETTE_LENGTH];\n\n   png_debug(1, \"in png_handle_tRNS\");\n\n   if (!(png_ptr->mode & PNG_HAVE_IHDR))\n      png_chunk_error(png_ptr, \"missing IHDR\");\n\n   else if (png_ptr->mode & PNG_HAVE_IDAT)\n   {\n      png_crc_finish(png_ptr, length);\n      png_chunk_benign_error(png_ptr, \"out of place\");\n      return;\n   }\n\n   else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS))\n   {\n      png_crc_finish(png_ptr, length);\n      png_chunk_benign_error(png_ptr, \"duplicate\");\n      return;\n   }\n\n   if (png_ptr->color_type == PNG_COLOR_TYPE_GRAY)\n   {\n      png_byte buf[2];\n\n      if (length != 2)\n      {\n         png_crc_finish(png_ptr, length);\n         png_chunk_benign_error(png_ptr, \"invalid\");\n         return;\n      }\n\n      png_crc_read(png_ptr, buf, 2);\n      png_ptr->num_trans = 1;\n      png_ptr->trans_color.gray = png_get_uint_16(buf);\n   }\n\n   else if (png_ptr->color_type == PNG_COLOR_TYPE_RGB)\n   {\n      png_byte buf[6];\n\n      if (length != 6)\n      {\n         png_crc_finish(png_ptr, length);\n         png_chunk_benign_error(png_ptr, \"invalid\");\n         return;\n      }\n\n      png_crc_read(png_ptr, buf, length);\n      png_ptr->num_trans = 1;\n      png_ptr->trans_color.red = png_get_uint_16(buf);\n      png_ptr->trans_color.green = png_get_uint_16(buf + 2);\n      png_ptr->trans_color.blue = png_get_uint_16(buf + 4);\n   }\n\n   else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)\n   {\n      if (!(png_ptr->mode & PNG_HAVE_PLTE))\n      {\n         /* TODO: is this actually an error in the ISO spec? */\n         png_crc_finish(png_ptr, length);\n         png_chunk_benign_error(png_ptr, \"out of place\");\n         return;\n      }\n\n      if (length > png_ptr->num_palette || length > PNG_MAX_PALETTE_LENGTH ||\n         length == 0)\n      {\n         png_crc_finish(png_ptr, length);\n         png_chunk_benign_error(png_ptr, \"invalid\");\n         return;\n      }\n\n      png_crc_read(png_ptr, readbuf, length);\n      png_ptr->num_trans = (png_uint_16)length;\n   }\n\n   else\n   {\n      png_crc_finish(png_ptr, length);\n      png_chunk_benign_error(png_ptr, \"invalid with alpha channel\");\n      return;\n   }\n\n   if (png_crc_finish(png_ptr, 0))\n   {\n      png_ptr->num_trans = 0;\n      return;\n   }\n\n   /* TODO: this is a horrible side effect in the palette case because the\n    * png_struct ends up with a pointer to the tRNS buffer owned by the\n    * png_info.  Fix this.\n    */\n   png_set_tRNS(png_ptr, info_ptr, readbuf, png_ptr->num_trans,\n       &(png_ptr->trans_color));\n}\n#endif\n\n#ifdef PNG_READ_bKGD_SUPPORTED\nvoid /* PRIVATE */\npng_handle_bKGD(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)\n{\n   unsigned int truelen;\n   png_byte buf[6];\n   png_color_16 background;\n\n   png_debug(1, \"in png_handle_bKGD\");\n\n   if (!(png_ptr->mode & PNG_HAVE_IHDR))\n      png_chunk_error(png_ptr, \"missing IHDR\");\n\n   else if ((png_ptr->mode & PNG_HAVE_IDAT) ||\n      (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE &&\n       !(png_ptr->mode & PNG_HAVE_PLTE)))\n   {\n      png_crc_finish(png_ptr, length);\n      png_chunk_benign_error(png_ptr, \"out of place\");\n      return;\n   }\n\n   else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_bKGD))\n   {\n      png_crc_finish(png_ptr, length);\n      png_chunk_benign_error(png_ptr, \"duplicate\");\n      return;\n   }\n\n   if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)\n      truelen = 1;\n\n   else if (png_ptr->color_type & PNG_COLOR_MASK_COLOR)\n      truelen = 6;\n\n   else\n      truelen = 2;\n\n   if (length != truelen)\n   {\n      png_crc_finish(png_ptr, length);\n      png_chunk_benign_error(png_ptr, \"invalid\");\n      return;\n   }\n\n   png_crc_read(png_ptr, buf, truelen);\n\n   if (png_crc_finish(png_ptr, 0))\n      return;\n\n   /* We convert the index value into RGB components so that we can allow\n    * arbitrary RGB values for background when we have transparency, and\n    * so it is easy to determine the RGB values of the background color\n    * from the info_ptr struct.\n    */\n   if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)\n   {\n      background.index = buf[0];\n\n      if (info_ptr && info_ptr->num_palette)\n      {\n         if (buf[0] >= info_ptr->num_palette)\n         {\n            png_chunk_benign_error(png_ptr, \"invalid index\");\n            return;\n         }\n\n         background.red = (png_uint_16)png_ptr->palette[buf[0]].red;\n         background.green = (png_uint_16)png_ptr->palette[buf[0]].green;\n         background.blue = (png_uint_16)png_ptr->palette[buf[0]].blue;\n      }\n\n      else\n         background.red = background.green = background.blue = 0;\n\n      background.gray = 0;\n   }\n\n   else if (!(png_ptr->color_type & PNG_COLOR_MASK_COLOR)) /* GRAY */\n   {\n      background.index = 0;\n      background.red =\n      background.green =\n      background.blue =\n      background.gray = png_get_uint_16(buf);\n   }\n\n   else\n   {\n      background.index = 0;\n      background.red = png_get_uint_16(buf);\n      background.green = png_get_uint_16(buf + 2);\n      background.blue = png_get_uint_16(buf + 4);\n      background.gray = 0;\n   }\n\n   png_set_bKGD(png_ptr, info_ptr, &background);\n}\n#endif\n\n#ifdef PNG_READ_hIST_SUPPORTED\nvoid /* PRIVATE */\npng_handle_hIST(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)\n{\n   unsigned int num, i;\n   png_uint_16 readbuf[PNG_MAX_PALETTE_LENGTH];\n\n   png_debug(1, \"in png_handle_hIST\");\n\n   if (!(png_ptr->mode & PNG_HAVE_IHDR))\n      png_chunk_error(png_ptr, \"missing IHDR\");\n\n   else if ((png_ptr->mode & PNG_HAVE_IDAT) || !(png_ptr->mode & PNG_HAVE_PLTE))\n   {\n      png_crc_finish(png_ptr, length);\n      png_chunk_benign_error(png_ptr, \"out of place\");\n      return;\n   }\n\n   else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_hIST))\n   {\n      png_crc_finish(png_ptr, length);\n      png_chunk_benign_error(png_ptr, \"duplicate\");\n      return;\n   }\n\n   num = length / 2 ;\n\n   if (num != png_ptr->num_palette || num > PNG_MAX_PALETTE_LENGTH)\n   {\n      png_crc_finish(png_ptr, length);\n      png_chunk_benign_error(png_ptr, \"invalid\");\n      return;\n   }\n\n   for (i = 0; i < num; i++)\n   {\n      png_byte buf[2];\n\n      png_crc_read(png_ptr, buf, 2);\n      readbuf[i] = png_get_uint_16(buf);\n   }\n\n   if (png_crc_finish(png_ptr, 0))\n      return;\n\n   png_set_hIST(png_ptr, info_ptr, readbuf);\n}\n#endif\n\n#ifdef PNG_READ_pHYs_SUPPORTED\nvoid /* PRIVATE */\npng_handle_pHYs(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)\n{\n   png_byte buf[9];\n   png_uint_32 res_x, res_y;\n   int unit_type;\n\n   png_debug(1, \"in png_handle_pHYs\");\n\n   if (!(png_ptr->mode & PNG_HAVE_IHDR))\n      png_chunk_error(png_ptr, \"missing IHDR\");\n\n   else if (png_ptr->mode & PNG_HAVE_IDAT)\n   {\n      png_crc_finish(png_ptr, length);\n      png_chunk_benign_error(png_ptr, \"out of place\");\n      return;\n   }\n\n   else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))\n   {\n      png_crc_finish(png_ptr, length);\n      png_chunk_benign_error(png_ptr, \"duplicate\");\n      return;\n   }\n\n   if (length != 9)\n   {\n      png_crc_finish(png_ptr, length);\n      png_chunk_benign_error(png_ptr, \"invalid\");\n      return;\n   }\n\n   png_crc_read(png_ptr, buf, 9);\n\n   if (png_crc_finish(png_ptr, 0))\n      return;\n\n   res_x = png_get_uint_32(buf);\n   res_y = png_get_uint_32(buf + 4);\n   unit_type = buf[8];\n   png_set_pHYs(png_ptr, info_ptr, res_x, res_y, unit_type);\n}\n#endif\n\n#ifdef PNG_READ_oFFs_SUPPORTED\nvoid /* PRIVATE */\npng_handle_oFFs(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)\n{\n   png_byte buf[9];\n   png_int_32 offset_x, offset_y;\n   int unit_type;\n\n   png_debug(1, \"in png_handle_oFFs\");\n\n   if (!(png_ptr->mode & PNG_HAVE_IHDR))\n      png_chunk_error(png_ptr, \"missing IHDR\");\n\n   else if (png_ptr->mode & PNG_HAVE_IDAT)\n   {\n      png_crc_finish(png_ptr, length);\n      png_chunk_benign_error(png_ptr, \"out of place\");\n      return;\n   }\n\n   else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs))\n   {\n      png_crc_finish(png_ptr, length);\n      png_chunk_benign_error(png_ptr, \"duplicate\");\n      return;\n   }\n\n   if (length != 9)\n   {\n      png_crc_finish(png_ptr, length);\n      png_chunk_benign_error(png_ptr, \"invalid\");\n      return;\n   }\n\n   png_crc_read(png_ptr, buf, 9);\n\n   if (png_crc_finish(png_ptr, 0))\n      return;\n\n   offset_x = png_get_int_32(buf);\n   offset_y = png_get_int_32(buf + 4);\n   unit_type = buf[8];\n   png_set_oFFs(png_ptr, info_ptr, offset_x, offset_y, unit_type);\n}\n#endif\n\n#ifdef PNG_READ_pCAL_SUPPORTED\n/* Read the pCAL chunk (described in the PNG Extensions document) */\nvoid /* PRIVATE */\npng_handle_pCAL(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)\n{\n   png_int_32 X0, X1;\n   png_byte type, nparams;\n   png_bytep buffer, buf, units, endptr;\n   png_charpp params;\n   int i;\n\n   png_debug(1, \"in png_handle_pCAL\");\n\n   if (!(png_ptr->mode & PNG_HAVE_IHDR))\n      png_chunk_error(png_ptr, \"missing IHDR\");\n\n   else if (png_ptr->mode & PNG_HAVE_IDAT)\n   {\n      png_crc_finish(png_ptr, length);\n      png_chunk_benign_error(png_ptr, \"out of place\");\n      return;\n   }\n\n   else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_pCAL))\n   {\n      png_crc_finish(png_ptr, length);\n      png_chunk_benign_error(png_ptr, \"duplicate\");\n      return;\n   }\n\n   png_debug1(2, \"Allocating and reading pCAL chunk data (%u bytes)\",\n       length + 1);\n\n   buffer = png_read_buffer(png_ptr, length+1, 2/*silent*/);\n\n   if (buffer == NULL)\n   {\n      png_crc_finish(png_ptr, length);\n      png_chunk_benign_error(png_ptr, \"out of memory\");\n      return;\n   }\n\n   png_crc_read(png_ptr, buffer, length);\n\n   if (png_crc_finish(png_ptr, 0))\n      return;\n\n   buffer[length] = 0; /* Null terminate the last string */\n\n   png_debug(3, \"Finding end of pCAL purpose string\");\n   for (buf = buffer; *buf; buf++)\n      /* Empty loop */ ;\n\n   endptr = buffer + length;\n\n   /* We need to have at least 12 bytes after the purpose string\n    * in order to get the parameter information.\n    */\n   if (endptr <= buf + 12)\n   {\n      png_chunk_benign_error(png_ptr, \"invalid\");\n      return;\n   }\n\n   png_debug(3, \"Reading pCAL X0, X1, type, nparams, and units\");\n   X0 = png_get_int_32((png_bytep)buf+1);\n   X1 = png_get_int_32((png_bytep)buf+5);\n   type = buf[9];\n   nparams = buf[10];\n   units = buf + 11;\n\n   png_debug(3, \"Checking pCAL equation type and number of parameters\");\n   /* Check that we have the right number of parameters for known\n    * equation types.\n    */\n   if ((type == PNG_EQUATION_LINEAR && nparams != 2) ||\n       (type == PNG_EQUATION_BASE_E && nparams != 3) ||\n       (type == PNG_EQUATION_ARBITRARY && nparams != 3) ||\n       (type == PNG_EQUATION_HYPERBOLIC && nparams != 4))\n   {\n      png_chunk_benign_error(png_ptr, \"invalid parameter count\");\n      return;\n   }\n\n   else if (type >= PNG_EQUATION_LAST)\n   {\n      png_chunk_benign_error(png_ptr, \"unrecognized equation type\");\n   }\n\n   for (buf = units; *buf; buf++)\n      /* Empty loop to move past the units string. */ ;\n\n   png_debug(3, \"Allocating pCAL parameters array\");\n\n   params = png_voidcast(png_charpp, png_malloc_warn(png_ptr,\n       nparams * (sizeof (png_charp))));\n\n   if (params == NULL)\n   {\n      png_chunk_benign_error(png_ptr, \"out of memory\");\n      return;\n   }\n\n   /* Get pointers to the start of each parameter string. */\n   for (i = 0; i < nparams; i++)\n   {\n      buf++; /* Skip the null string terminator from previous parameter. */\n\n      png_debug1(3, \"Reading pCAL parameter %d\", i);\n\n      for (params[i] = (png_charp)buf; buf <= endptr && *buf != 0; buf++)\n         /* Empty loop to move past each parameter string */ ;\n\n      /* Make sure we haven't run out of data yet */\n      if (buf > endptr)\n      {\n         png_free(png_ptr, params);\n         png_chunk_benign_error(png_ptr, \"invalid data\");\n         return;\n      }\n   }\n\n   png_set_pCAL(png_ptr, info_ptr, (png_charp)buffer, X0, X1, type, nparams,\n      (png_charp)units, params);\n\n   png_free(png_ptr, params);\n}\n#endif\n\n#ifdef PNG_READ_sCAL_SUPPORTED\n/* Read the sCAL chunk */\nvoid /* PRIVATE */\npng_handle_sCAL(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)\n{\n   png_bytep buffer;\n   png_size_t i;\n   int state;\n\n   png_debug(1, \"in png_handle_sCAL\");\n\n   if (!(png_ptr->mode & PNG_HAVE_IHDR))\n      png_chunk_error(png_ptr, \"missing IHDR\");\n\n   else if (png_ptr->mode & PNG_HAVE_IDAT)\n   {\n      png_crc_finish(png_ptr, length);\n      png_chunk_benign_error(png_ptr, \"out of place\");\n      return;\n   }\n\n   else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_sCAL))\n   {\n      png_crc_finish(png_ptr, length);\n      png_chunk_benign_error(png_ptr, \"duplicate\");\n      return;\n   }\n\n   /* Need unit type, width, \\0, height: minimum 4 bytes */\n   else if (length < 4)\n   {\n      png_crc_finish(png_ptr, length);\n      png_chunk_benign_error(png_ptr, \"invalid\");\n      return;\n   }\n\n   png_debug1(2, \"Allocating and reading sCAL chunk data (%u bytes)\",\n      length + 1);\n\n   buffer = png_read_buffer(png_ptr, length+1, 2/*silent*/);\n\n   if (buffer == NULL)\n   {\n      png_chunk_benign_error(png_ptr, \"out of memory\");\n      png_crc_finish(png_ptr, length);\n      return;\n   }\n\n   png_crc_read(png_ptr, buffer, length);\n   buffer[length] = 0; /* Null terminate the last string */\n\n   if (png_crc_finish(png_ptr, 0))\n      return;\n\n   /* Validate the unit. */\n   if (buffer[0] != 1 && buffer[0] != 2)\n   {\n      png_chunk_benign_error(png_ptr, \"invalid unit\");\n      return;\n   }\n\n   /* Validate the ASCII numbers, need two ASCII numbers separated by\n    * a '\\0' and they need to fit exactly in the chunk data.\n    */\n   i = 1;\n   state = 0;\n\n   if (!png_check_fp_number((png_const_charp)buffer, length, &state, &i) ||\n       i >= length || buffer[i++] != 0)\n      png_chunk_benign_error(png_ptr, \"bad width format\");\n\n   else if (!PNG_FP_IS_POSITIVE(state))\n      png_chunk_benign_error(png_ptr, \"non-positive width\");\n\n   else\n   {\n      png_size_t heighti = i;\n\n      state = 0;\n      if (!png_check_fp_number((png_const_charp)buffer, length, &state, &i) ||\n         i != length)\n         png_chunk_benign_error(png_ptr, \"bad height format\");\n\n      else if (!PNG_FP_IS_POSITIVE(state))\n         png_chunk_benign_error(png_ptr, \"non-positive height\");\n\n      else\n         /* This is the (only) success case. */\n         png_set_sCAL_s(png_ptr, info_ptr, buffer[0],\n            (png_charp)buffer+1, (png_charp)buffer+heighti);\n   }\n}\n#endif\n\n#ifdef PNG_READ_tIME_SUPPORTED\nvoid /* PRIVATE */\npng_handle_tIME(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)\n{\n   png_byte buf[7];\n   png_time mod_time;\n\n   png_debug(1, \"in png_handle_tIME\");\n\n   if (!(png_ptr->mode & PNG_HAVE_IHDR))\n      png_chunk_error(png_ptr, \"missing IHDR\");\n\n   else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_tIME))\n   {\n      png_crc_finish(png_ptr, length);\n      png_chunk_benign_error(png_ptr, \"duplicate\");\n      return;\n   }\n\n   if (png_ptr->mode & PNG_HAVE_IDAT)\n      png_ptr->mode |= PNG_AFTER_IDAT;\n\n   if (length != 7)\n   {\n      png_crc_finish(png_ptr, length);\n      png_chunk_benign_error(png_ptr, \"invalid\");\n      return;\n   }\n\n   png_crc_read(png_ptr, buf, 7);\n\n   if (png_crc_finish(png_ptr, 0))\n      return;\n\n   mod_time.second = buf[6];\n   mod_time.minute = buf[5];\n   mod_time.hour = buf[4];\n   mod_time.day = buf[3];\n   mod_time.month = buf[2];\n   mod_time.year = png_get_uint_16(buf);\n\n   png_set_tIME(png_ptr, info_ptr, &mod_time);\n}\n#endif\n\n#ifdef PNG_READ_tEXt_SUPPORTED\n/* Note: this does not properly handle chunks that are > 64K under DOS */\nvoid /* PRIVATE */\npng_handle_tEXt(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)\n{\n   png_text  text_info;\n   png_bytep buffer;\n   png_charp key;\n   png_charp text;\n   png_uint_32 skip = 0;\n\n   png_debug(1, \"in png_handle_tEXt\");\n\n#ifdef PNG_USER_LIMITS_SUPPORTED\n   if (png_ptr->user_chunk_cache_max != 0)\n   {\n      if (png_ptr->user_chunk_cache_max == 1)\n      {\n         png_crc_finish(png_ptr, length);\n         return;\n      }\n\n      if (--png_ptr->user_chunk_cache_max == 1)\n      {\n         png_crc_finish(png_ptr, length);\n         png_chunk_benign_error(png_ptr, \"no space in chunk cache\");\n         return;\n      }\n   }\n#endif\n\n   if (!(png_ptr->mode & PNG_HAVE_IHDR))\n      png_chunk_error(png_ptr, \"missing IHDR\");\n\n   if (png_ptr->mode & PNG_HAVE_IDAT)\n      png_ptr->mode |= PNG_AFTER_IDAT;\n\n#ifdef PNG_MAX_MALLOC_64K\n   if (length > 65535U)\n   {\n      png_crc_finish(png_ptr, length);\n      png_chunk_benign_error(png_ptr, \"too large to fit in memory\");\n      return;\n   }\n#endif\n\n   buffer = png_read_buffer(png_ptr, length+1, 1/*warn*/);\n\n   if (buffer == NULL)\n   {\n     png_chunk_benign_error(png_ptr, \"out of memory\");\n     return;\n   }\n\n   png_crc_read(png_ptr, buffer, length);\n\n   if (png_crc_finish(png_ptr, skip))\n      return;\n\n   key = (png_charp)buffer;\n   key[length] = 0;\n\n   for (text = key; *text; text++)\n      /* Empty loop to find end of key */ ;\n\n   if (text != key + length)\n      text++;\n\n   text_info.compression = PNG_TEXT_COMPRESSION_NONE;\n   text_info.key = key;\n   text_info.lang = NULL;\n   text_info.lang_key = NULL;\n   text_info.itxt_length = 0;\n   text_info.text = text;\n   text_info.text_length = strlen(text);\n\n   if (png_set_text_2(png_ptr, info_ptr, &text_info, 1))\n      png_warning(png_ptr, \"Insufficient memory to process text chunk\");\n}\n#endif\n\n#ifdef PNG_READ_zTXt_SUPPORTED\n/* Note: this does not correctly handle chunks that are > 64K under DOS */\nvoid /* PRIVATE */\npng_handle_zTXt(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)\n{\n   png_const_charp errmsg = NULL;\n   png_bytep       buffer;\n   png_uint_32     keyword_length;\n\n   png_debug(1, \"in png_handle_zTXt\");\n\n#ifdef PNG_USER_LIMITS_SUPPORTED\n   if (png_ptr->user_chunk_cache_max != 0)\n   {\n      if (png_ptr->user_chunk_cache_max == 1)\n      {\n         png_crc_finish(png_ptr, length);\n         return;\n      }\n\n      if (--png_ptr->user_chunk_cache_max == 1)\n      {\n         png_crc_finish(png_ptr, length);\n         png_chunk_benign_error(png_ptr, \"no space in chunk cache\");\n         return;\n      }\n   }\n#endif\n\n   if (!(png_ptr->mode & PNG_HAVE_IHDR))\n      png_chunk_error(png_ptr, \"missing IHDR\");\n\n   if (png_ptr->mode & PNG_HAVE_IDAT)\n      png_ptr->mode |= PNG_AFTER_IDAT;\n\n   buffer = png_read_buffer(png_ptr, length, 2/*silent*/);\n\n   if (buffer == NULL)\n   {\n      png_crc_finish(png_ptr, length);\n      png_chunk_benign_error(png_ptr, \"out of memory\");\n      return;\n   }\n\n   png_crc_read(png_ptr, buffer, length);\n\n   if (png_crc_finish(png_ptr, 0))\n      return;\n\n   /* TODO: also check that the keyword contents match the spec! */\n   for (keyword_length = 0;\n      keyword_length < length && buffer[keyword_length] != 0;\n      ++keyword_length)\n      /* Empty loop to find end of name */ ;\n\n   if (keyword_length > 79 || keyword_length < 1)\n      errmsg = \"bad keyword\";\n\n   /* zTXt must have some LZ data after the keyword, although it may expand to\n    * zero bytes; we need a '\\0' at the end of the keyword, the compression type\n    * then the LZ data:\n    */\n   else if (keyword_length + 3 > length)\n      errmsg = \"truncated\";\n\n   else if (buffer[keyword_length+1] != PNG_COMPRESSION_TYPE_BASE)\n      errmsg = \"unknown compression type\";\n\n   else\n   {\n      png_alloc_size_t uncompressed_length = PNG_SIZE_MAX;\n\n      /* TODO: at present png_decompress_chunk imposes a single application\n       * level memory limit, this should be split to different values for iCCP\n       * and text chunks.\n       */\n      if (png_decompress_chunk(png_ptr, length, keyword_length+2,\n         &uncompressed_length, 1/*terminate*/) == Z_STREAM_END)\n      {\n         png_text text;\n\n         /* It worked; png_ptr->read_buffer now looks like a tEXt chunk except\n          * for the extra compression type byte and the fact that it isn't\n          * necessarily '\\0' terminated.\n          */\n         buffer = png_ptr->read_buffer;\n         buffer[uncompressed_length+(keyword_length+2)] = 0;\n\n         text.compression = PNG_TEXT_COMPRESSION_zTXt;\n         text.key = (png_charp)buffer;\n         text.text = (png_charp)(buffer + keyword_length+2);\n         text.text_length = uncompressed_length;\n         text.itxt_length = 0;\n         text.lang = NULL;\n         text.lang_key = NULL;\n\n         if (png_set_text_2(png_ptr, info_ptr, &text, 1))\n            errmsg = \"insufficient memory\";\n      }\n\n      else\n         errmsg = png_ptr->zstream.msg;\n   }\n\n   if (errmsg != NULL)\n      png_chunk_benign_error(png_ptr, errmsg);\n}\n#endif\n\n#ifdef PNG_READ_iTXt_SUPPORTED\n/* Note: this does not correctly handle chunks that are > 64K under DOS */\nvoid /* PRIVATE */\npng_handle_iTXt(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)\n{\n   png_const_charp errmsg = NULL;\n   png_bytep buffer;\n   png_uint_32 prefix_length;\n\n   png_debug(1, \"in png_handle_iTXt\");\n\n#ifdef PNG_USER_LIMITS_SUPPORTED\n   if (png_ptr->user_chunk_cache_max != 0)\n   {\n      if (png_ptr->user_chunk_cache_max == 1)\n      {\n         png_crc_finish(png_ptr, length);\n         return;\n      }\n\n      if (--png_ptr->user_chunk_cache_max == 1)\n      {\n         png_crc_finish(png_ptr, length);\n         png_chunk_benign_error(png_ptr, \"no space in chunk cache\");\n         return;\n      }\n   }\n#endif\n\n   if (!(png_ptr->mode & PNG_HAVE_IHDR))\n      png_chunk_error(png_ptr, \"missing IHDR\");\n\n   if (png_ptr->mode & PNG_HAVE_IDAT)\n      png_ptr->mode |= PNG_AFTER_IDAT;\n\n   buffer = png_read_buffer(png_ptr, length+1, 1/*warn*/);\n\n   if (buffer == NULL)\n   {\n      png_crc_finish(png_ptr, length);\n      png_chunk_benign_error(png_ptr, \"out of memory\");\n      return;\n   }\n\n   png_crc_read(png_ptr, buffer, length);\n\n   if (png_crc_finish(png_ptr, 0))\n      return;\n\n   /* First the keyword. */\n   for (prefix_length=0;\n      prefix_length < length && buffer[prefix_length] != 0;\n      ++prefix_length)\n      /* Empty loop */ ;\n\n   /* Perform a basic check on the keyword length here. */\n   if (prefix_length > 79 || prefix_length < 1)\n      errmsg = \"bad keyword\";\n\n   /* Expect keyword, compression flag, compression type, language, translated\n    * keyword (both may be empty but are 0 terminated) then the text, which may\n    * be empty.\n    */\n   else if (prefix_length + 5 > length)\n      errmsg = \"truncated\";\n\n   else if (buffer[prefix_length+1] == 0 ||\n      (buffer[prefix_length+1] == 1 &&\n      buffer[prefix_length+2] == PNG_COMPRESSION_TYPE_BASE))\n   {\n      int compressed = buffer[prefix_length+1] != 0;\n      png_uint_32 language_offset, translated_keyword_offset;\n      png_alloc_size_t uncompressed_length = 0;\n\n      /* Now the language tag */\n      prefix_length += 3;\n      language_offset = prefix_length;\n\n      for (; prefix_length < length && buffer[prefix_length] != 0;\n         ++prefix_length)\n         /* Empty loop */ ;\n\n      /* WARNING: the length may be invalid here, this is checked below. */\n      translated_keyword_offset = ++prefix_length;\n\n      for (; prefix_length < length && buffer[prefix_length] != 0;\n         ++prefix_length)\n         /* Empty loop */ ;\n\n      /* prefix_length should now be at the trailing '\\0' of the translated\n       * keyword, but it may already be over the end.  None of this arithmetic\n       * can overflow because chunks are at most 2^31 bytes long, but on 16-bit\n       * systems the available allocaton may overflow.\n       */\n      ++prefix_length;\n\n      if (!compressed && prefix_length <= length)\n         uncompressed_length = length - prefix_length;\n\n      else if (compressed && prefix_length < length)\n      {\n         uncompressed_length = PNG_SIZE_MAX;\n\n         /* TODO: at present png_decompress_chunk imposes a single application\n          * level memory limit, this should be split to different values for\n          * iCCP and text chunks.\n          */\n         if (png_decompress_chunk(png_ptr, length, prefix_length,\n            &uncompressed_length, 1/*terminate*/) == Z_STREAM_END)\n            buffer = png_ptr->read_buffer;\n\n         else\n            errmsg = png_ptr->zstream.msg;\n      }\n\n      else\n         errmsg = \"truncated\";\n\n      if (errmsg == NULL)\n      {\n         png_text text;\n\n         buffer[uncompressed_length+prefix_length] = 0;\n\n         if (compressed)\n            text.compression = PNG_ITXT_COMPRESSION_NONE;\n\n         else\n            text.compression = PNG_ITXT_COMPRESSION_zTXt;\n\n         text.key = (png_charp)buffer;\n         text.lang = (png_charp)buffer + language_offset;\n         text.lang_key = (png_charp)buffer + translated_keyword_offset;\n         text.text = (png_charp)buffer + prefix_length;\n         text.text_length = 0;\n         text.itxt_length = uncompressed_length;\n\n         if (png_set_text_2(png_ptr, info_ptr, &text, 1))\n            errmsg = \"insufficient memory\";\n      }\n   }\n\n   else\n      errmsg = \"bad compression info\";\n\n   if (errmsg != NULL)\n      png_chunk_benign_error(png_ptr, errmsg);\n}\n#endif\n\n#ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED\n/* Utility function for png_handle_unknown; set up png_ptr::unknown_chunk */\nstatic int\npng_cache_unknown_chunk(png_structrp png_ptr, png_uint_32 length)\n{\n   png_alloc_size_t limit = PNG_SIZE_MAX;\n\n   if (png_ptr->unknown_chunk.data != NULL)\n   {\n      png_free(png_ptr, png_ptr->unknown_chunk.data);\n      png_ptr->unknown_chunk.data = NULL;\n   }\n\n#  ifdef PNG_SET_CHUNK_MALLOC_LIMIT_SUPPORTED\n      if (png_ptr->user_chunk_malloc_max > 0 &&\n         png_ptr->user_chunk_malloc_max < limit)\n         limit = png_ptr->user_chunk_malloc_max;\n\n#  elif PNG_USER_CHUNK_MALLOC_MAX > 0\n      if (PNG_USER_CHUNK_MALLOC_MAX < limit)\n         limit = PNG_USER_CHUNK_MALLOC_MAX;\n#  endif\n\n   if (length <= limit)\n   {\n      PNG_CSTRING_FROM_CHUNK(png_ptr->unknown_chunk.name, png_ptr->chunk_name);\n      /* The following is safe because of the PNG_SIZE_MAX init above */\n      png_ptr->unknown_chunk.size = (png_size_t)length/*SAFE*/;\n      /* 'mode' is a flag array, only the bottom four bits matter here */\n      png_ptr->unknown_chunk.location = (png_byte)png_ptr->mode/*SAFE*/;\n\n      if (length == 0)\n         png_ptr->unknown_chunk.data = NULL;\n\n      else\n      {\n         /* Do a 'warn' here - it is handled below. */\n         png_ptr->unknown_chunk.data = png_voidcast(png_bytep,\n            png_malloc_warn(png_ptr, length));\n      }\n   }\n\n   if (png_ptr->unknown_chunk.data == NULL && length > 0)\n   {\n      /* This is benign because we clean up correctly */\n      png_crc_finish(png_ptr, length);\n      png_chunk_benign_error(png_ptr, \"unknown chunk exceeds memory limits\");\n      return 0;\n   }\n\n   else\n   {\n      if (length > 0)\n         png_crc_read(png_ptr, png_ptr->unknown_chunk.data, length);\n      png_crc_finish(png_ptr, 0);\n      return 1;\n   }\n}\n#endif /* PNG_READ_UNKNOWN_CHUNKS_SUPPORTED */\n\n/* Handle an unknown, or known but disabled, chunk */\nvoid /* PRIVATE */\npng_handle_unknown(png_structrp png_ptr, png_inforp info_ptr,\n   png_uint_32 length, int keep)\n{\n   int handled = 0; /* the chunk was handled */\n\n   png_debug(1, \"in png_handle_unknown\");\n\n#ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED\n   /* NOTE: this code is based on the code in libpng-1.4.12 except for fixing\n    * the bug which meant that setting a non-default behavior for a specific\n    * chunk would be ignored (the default was always used unless a user\n    * callback was installed).\n    *\n    * 'keep' is the value from the png_chunk_unknown_handling, the setting for\n    * this specific chunk_name, if PNG_HANDLE_AS_UNKNOWN_SUPPORTED, if not it\n    * will always be PNG_HANDLE_CHUNK_AS_DEFAULT and it needs to be set here.\n    * This is just an optimization to avoid multiple calls to the lookup\n    * function.\n    */\n#  ifndef PNG_HANDLE_AS_UNKNOWN_SUPPORTED\n#     ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED\n         keep = png_chunk_unknown_handling(png_ptr, png_ptr->chunk_name);\n#     endif\n#  endif\n\n   /* One of the following methods will read the chunk or skip it (at least one\n    * of these is always defined because this is the only way to switch on\n    * PNG_READ_UNKNOWN_CHUNKS_SUPPORTED)\n    */\n#  ifdef PNG_READ_USER_CHUNKS_SUPPORTED\n      /* The user callback takes precedence over the chunk keep value, but the\n       * keep value is still required to validate a save of a critical chunk.\n       */\n      if (png_ptr->read_user_chunk_fn != NULL)\n      {\n         if (png_cache_unknown_chunk(png_ptr, length))\n         {\n            /* Callback to user unknown chunk handler */\n            int ret = (*(png_ptr->read_user_chunk_fn))(png_ptr,\n               &png_ptr->unknown_chunk);\n\n            /* ret is:\n             * negative: An error occured, png_chunk_error will be called.\n             *     zero: The chunk was not handled, the chunk will be discarded\n             *           unless png_set_keep_unknown_chunks has been used to set\n             *           a 'keep' behavior for this particular chunk, in which\n             *           case that will be used.  A critical chunk will cause an\n             *           error at this point unless it is to be saved.\n             * positive: The chunk was handled, libpng will ignore/discard it.\n             */\n            if (ret < 0)\n               png_chunk_error(png_ptr, \"error in user chunk\");\n\n            else if (ret == 0)\n            {\n               /* If the keep value is 'default' or 'never' override it, but\n                * still error out on critical chunks unless the keep value is\n                * 'always'  While this is weird it is the behavior in 1.4.12.\n                * A possible improvement would be to obey the value set for the\n                * chunk, but this would be an API change that would probably\n                * damage some applications.\n                *\n                * The png_app_warning below catches the case that matters, where\n                * the application has not set specific save or ignore for this\n                * chunk or global save or ignore.\n                */\n               if (keep < PNG_HANDLE_CHUNK_IF_SAFE)\n               {\n#                 ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED\n                     if (png_ptr->unknown_default < PNG_HANDLE_CHUNK_IF_SAFE)\n                     {\n                        png_chunk_warning(png_ptr, \"Saving unknown chunk:\");\n                        png_app_warning(png_ptr,\n                           \"forcing save of an unhandled chunk;\"\n                           \" please call png_set_keep_unknown_chunks\");\n                           /* with keep = PNG_HANDLE_CHUNK_IF_SAFE */\n                     }\n#                 endif\n                  keep = PNG_HANDLE_CHUNK_IF_SAFE;\n               }\n            }\n\n            else /* chunk was handled */\n            {\n               handled = 1;\n               /* Critical chunks can be safely discarded at this point. */\n               keep = PNG_HANDLE_CHUNK_NEVER;\n            }\n         }\n\n         else\n            keep = PNG_HANDLE_CHUNK_NEVER; /* insufficient memory */\n      }\n\n      else\n         /* Use the SAVE_UNKNOWN_CHUNKS code or skip the chunk */\n#  endif /* PNG_READ_USER_CHUNKS_SUPPORTED */\n\n#  ifdef PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED\n      {\n         /* keep is currently just the per-chunk setting, if there was no\n          * setting change it to the global default now (not that this may\n          * still be AS_DEFAULT) then obtain the cache of the chunk if required,\n          * if not simply skip the chunk.\n          */\n         if (keep == PNG_HANDLE_CHUNK_AS_DEFAULT)\n            keep = png_ptr->unknown_default;\n\n         if (keep == PNG_HANDLE_CHUNK_ALWAYS ||\n            (keep == PNG_HANDLE_CHUNK_IF_SAFE &&\n             PNG_CHUNK_ANCILLARY(png_ptr->chunk_name)))\n         {\n            if (!png_cache_unknown_chunk(png_ptr, length))\n               keep = PNG_HANDLE_CHUNK_NEVER;\n         }\n\n         else\n            png_crc_finish(png_ptr, length);\n      }\n#  else\n#     ifndef PNG_READ_USER_CHUNKS_SUPPORTED\n#        error no method to support READ_UNKNOWN_CHUNKS\n#     endif\n\n      {\n         /* If here there is no read callback pointer set and no support is\n          * compiled in to just save the unknown chunks, so simply skip this\n          * chunk.  If 'keep' is something other than AS_DEFAULT or NEVER then\n          * the app has erroneously asked for unknown chunk saving when there\n          * is no support.\n          */\n         if (keep > PNG_HANDLE_CHUNK_NEVER)\n            png_app_error(png_ptr, \"no unknown chunk support available\");\n\n         png_crc_finish(png_ptr, length);\n      }\n#  endif\n\n#  ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED\n      /* Now store the chunk in the chunk list if appropriate, and if the limits\n       * permit it.\n       */\n      if (keep == PNG_HANDLE_CHUNK_ALWAYS ||\n         (keep == PNG_HANDLE_CHUNK_IF_SAFE &&\n          PNG_CHUNK_ANCILLARY(png_ptr->chunk_name)))\n      {\n#     ifdef PNG_USER_LIMITS_SUPPORTED\n         switch (png_ptr->user_chunk_cache_max)\n         {\n            case 2:\n               png_ptr->user_chunk_cache_max = 1;\n               png_chunk_benign_error(png_ptr, \"no space in chunk cache\");\n               /* FALL THROUGH */\n            case 1:\n               /* NOTE: prior to 1.6.0 this case resulted in an unknown critical\n                * chunk being skipped, now there will be a hard error below.\n                */\n               break;\n\n            default: /* not at limit */\n               --(png_ptr->user_chunk_cache_max);\n               /* FALL THROUGH */\n            case 0: /* no limit */\n#     endif /* PNG_USER_LIMITS_SUPPORTED */\n               /* Here when the limit isn't reached or when limits are compiled\n                * out; store the chunk.\n                */\n               png_set_unknown_chunks(png_ptr, info_ptr,\n                  &png_ptr->unknown_chunk, 1);\n               handled = 1;\n#     ifdef PNG_USER_LIMITS_SUPPORTED\n               break;\n         }\n#     endif\n      }\n#  else /* no store support: the chunk must be handled by the user callback */\n      PNG_UNUSED(info_ptr)\n#  endif\n\n   /* Regardless of the error handling below the cached data (if any) can be\n    * freed now.  Notice that the data is not freed if there is a png_error, but\n    * it will be freed by destroy_read_struct.\n    */\n   if (png_ptr->unknown_chunk.data != NULL)\n      png_free(png_ptr, png_ptr->unknown_chunk.data);\n   png_ptr->unknown_chunk.data = NULL;\n\n#else /* !PNG_READ_UNKNOWN_CHUNKS_SUPPORTED */\n   /* There is no support to read an unknown chunk, so just skip it. */\n   png_crc_finish(png_ptr, length);\n   PNG_UNUSED(info_ptr)\n   PNG_UNUSED(keep)\n#endif /* !PNG_READ_UNKNOWN_CHUNKS_SUPPORTED */\n\n   /* Check for unhandled critical chunks */\n   if (!handled && PNG_CHUNK_CRITICAL(png_ptr->chunk_name))\n      png_chunk_error(png_ptr, \"unhandled critical chunk\");\n}\n\n/* This function is called to verify that a chunk name is valid.\n * This function can't have the \"critical chunk check\" incorporated\n * into it, since in the future we will need to be able to call user\n * functions to handle unknown critical chunks after we check that\n * the chunk name itself is valid.\n */\n\n/* Bit hacking: the test for an invalid byte in the 4 byte chunk name is:\n *\n * ((c) < 65 || (c) > 122 || ((c) > 90 && (c) < 97))\n */\n\nvoid /* PRIVATE */\npng_check_chunk_name(png_structrp png_ptr, png_uint_32 chunk_name)\n{\n   int i;\n\n   png_debug(1, \"in png_check_chunk_name\");\n\n   for (i=1; i<=4; ++i)\n   {\n      int c = chunk_name & 0xff;\n\n      if (c < 65 || c > 122 || (c > 90 && c < 97))\n         png_chunk_error(png_ptr, \"invalid chunk type\");\n\n      chunk_name >>= 8;\n   }\n}\n\n/* Combines the row recently read in with the existing pixels in the row.  This\n * routine takes care of alpha and transparency if requested.  This routine also\n * handles the two methods of progressive display of interlaced images,\n * depending on the 'display' value; if 'display' is true then the whole row\n * (dp) is filled from the start by replicating the available pixels.  If\n * 'display' is false only those pixels present in the pass are filled in.\n */\nvoid /* PRIVATE */\npng_combine_row(png_const_structrp png_ptr, png_bytep dp, int display)\n{\n   unsigned int pixel_depth = png_ptr->transformed_pixel_depth;\n   png_const_bytep sp = png_ptr->row_buf + 1;\n   png_uint_32 row_width = png_ptr->width;\n   unsigned int pass = png_ptr->pass;\n   png_bytep end_ptr = 0;\n   png_byte end_byte = 0;\n   unsigned int end_mask;\n\n   png_debug(1, \"in png_combine_row\");\n\n   /* Added in 1.5.6: it should not be possible to enter this routine until at\n    * least one row has been read from the PNG data and transformed.\n    */\n   if (pixel_depth == 0)\n      png_error(png_ptr, \"internal row logic error\");\n\n   /* Added in 1.5.4: the pixel depth should match the information returned by\n    * any call to png_read_update_info at this point.  Do not continue if we got\n    * this wrong.\n    */\n   if (png_ptr->info_rowbytes != 0 && png_ptr->info_rowbytes !=\n          PNG_ROWBYTES(pixel_depth, row_width))\n      png_error(png_ptr, \"internal row size calculation error\");\n\n   /* Don't expect this to ever happen: */\n   if (row_width == 0)\n      png_error(png_ptr, \"internal row width error\");\n\n   /* Preserve the last byte in cases where only part of it will be overwritten,\n    * the multiply below may overflow, we don't care because ANSI-C guarantees\n    * we get the low bits.\n    */\n   end_mask = (pixel_depth * row_width) & 7;\n   if (end_mask != 0)\n   {\n      /* end_ptr == NULL is a flag to say do nothing */\n      end_ptr = dp + PNG_ROWBYTES(pixel_depth, row_width) - 1;\n      end_byte = *end_ptr;\n#     ifdef PNG_READ_PACKSWAP_SUPPORTED\n         if (png_ptr->transformations & PNG_PACKSWAP) /* little-endian byte */\n            end_mask = 0xff << end_mask;\n\n         else /* big-endian byte */\n#     endif\n         end_mask = 0xff >> end_mask;\n      /* end_mask is now the bits to *keep* from the destination row */\n   }\n\n   /* For non-interlaced images this reduces to a memcpy(). A memcpy()\n    * will also happen if interlacing isn't supported or if the application\n    * does not call png_set_interlace_handling().  In the latter cases the\n    * caller just gets a sequence of the unexpanded rows from each interlace\n    * pass.\n    */\n#ifdef PNG_READ_INTERLACING_SUPPORTED\n   if (png_ptr->interlaced && (png_ptr->transformations & PNG_INTERLACE) &&\n      pass < 6 && (display == 0 ||\n      /* The following copies everything for 'display' on passes 0, 2 and 4. */\n      (display == 1 && (pass & 1) != 0)))\n   {\n      /* Narrow images may have no bits in a pass; the caller should handle\n       * this, but this test is cheap:\n       */\n      if (row_width <= PNG_PASS_START_COL(pass))\n         return;\n\n      if (pixel_depth < 8)\n      {\n         /* For pixel depths up to 4 bpp the 8-pixel mask can be expanded to fit\n          * into 32 bits, then a single loop over the bytes using the four byte\n          * values in the 32-bit mask can be used.  For the 'display' option the\n          * expanded mask may also not require any masking within a byte.  To\n          * make this work the PACKSWAP option must be taken into account - it\n          * simply requires the pixels to be reversed in each byte.\n          *\n          * The 'regular' case requires a mask for each of the first 6 passes,\n          * the 'display' case does a copy for the even passes in the range\n          * 0..6.  This has already been handled in the test above.\n          *\n          * The masks are arranged as four bytes with the first byte to use in\n          * the lowest bits (little-endian) regardless of the order (PACKSWAP or\n          * not) of the pixels in each byte.\n          *\n          * NOTE: the whole of this logic depends on the caller of this function\n          * only calling it on rows appropriate to the pass.  This function only\n          * understands the 'x' logic; the 'y' logic is handled by the caller.\n          *\n          * The following defines allow generation of compile time constant bit\n          * masks for each pixel depth and each possibility of swapped or not\n          * swapped bytes.  Pass 'p' is in the range 0..6; 'x', a pixel index,\n          * is in the range 0..7; and the result is 1 if the pixel is to be\n          * copied in the pass, 0 if not.  'S' is for the sparkle method, 'B'\n          * for the block method.\n          *\n          * With some compilers a compile time expression of the general form:\n          *\n          *    (shift >= 32) ? (a >> (shift-32)) : (b >> shift)\n          *\n          * Produces warnings with values of 'shift' in the range 33 to 63\n          * because the right hand side of the ?: expression is evaluated by\n          * the compiler even though it isn't used.  Microsoft Visual C (various\n          * versions) and the Intel C compiler are known to do this.  To avoid\n          * this the following macros are used in 1.5.6.  This is a temporary\n          * solution to avoid destabilizing the code during the release process.\n          */\n#        if PNG_USE_COMPILE_TIME_MASKS\n#           define PNG_LSR(x,s) ((x)>>((s) & 0x1f))\n#           define PNG_LSL(x,s) ((x)<<((s) & 0x1f))\n#        else\n#           define PNG_LSR(x,s) ((x)>>(s))\n#           define PNG_LSL(x,s) ((x)<<(s))\n#        endif\n#        define S_COPY(p,x) (((p)<4 ? PNG_LSR(0x80088822,(3-(p))*8+(7-(x))) :\\\n           PNG_LSR(0xaa55ff00,(7-(p))*8+(7-(x)))) & 1)\n#        define B_COPY(p,x) (((p)<4 ? PNG_LSR(0xff0fff33,(3-(p))*8+(7-(x))) :\\\n           PNG_LSR(0xff55ff00,(7-(p))*8+(7-(x)))) & 1)\n\n         /* Return a mask for pass 'p' pixel 'x' at depth 'd'.  The mask is\n          * little endian - the first pixel is at bit 0 - however the extra\n          * parameter 's' can be set to cause the mask position to be swapped\n          * within each byte, to match the PNG format.  This is done by XOR of\n          * the shift with 7, 6 or 4 for bit depths 1, 2 and 4.\n          */\n#        define PIXEL_MASK(p,x,d,s) \\\n            (PNG_LSL(((PNG_LSL(1U,(d)))-1),(((x)*(d))^((s)?8-(d):0))))\n\n         /* Hence generate the appropriate 'block' or 'sparkle' pixel copy mask.\n          */\n#        define S_MASKx(p,x,d,s) (S_COPY(p,x)?PIXEL_MASK(p,x,d,s):0)\n#        define B_MASKx(p,x,d,s) (B_COPY(p,x)?PIXEL_MASK(p,x,d,s):0)\n\n         /* Combine 8 of these to get the full mask.  For the 1-bpp and 2-bpp\n          * cases the result needs replicating, for the 4-bpp case the above\n          * generates a full 32 bits.\n          */\n#        define MASK_EXPAND(m,d) ((m)*((d)==1?0x01010101:((d)==2?0x00010001:1)))\n\n#        define S_MASK(p,d,s) MASK_EXPAND(S_MASKx(p,0,d,s) + S_MASKx(p,1,d,s) +\\\n            S_MASKx(p,2,d,s) + S_MASKx(p,3,d,s) + S_MASKx(p,4,d,s) +\\\n            S_MASKx(p,5,d,s) + S_MASKx(p,6,d,s) + S_MASKx(p,7,d,s), d)\n\n#        define B_MASK(p,d,s) MASK_EXPAND(B_MASKx(p,0,d,s) + B_MASKx(p,1,d,s) +\\\n            B_MASKx(p,2,d,s) + B_MASKx(p,3,d,s) + B_MASKx(p,4,d,s) +\\\n            B_MASKx(p,5,d,s) + B_MASKx(p,6,d,s) + B_MASKx(p,7,d,s), d)\n\n#if PNG_USE_COMPILE_TIME_MASKS\n         /* Utility macros to construct all the masks for a depth/swap\n          * combination.  The 's' parameter says whether the format is PNG\n          * (big endian bytes) or not.  Only the three odd-numbered passes are\n          * required for the display/block algorithm.\n          */\n#        define S_MASKS(d,s) { S_MASK(0,d,s), S_MASK(1,d,s), S_MASK(2,d,s),\\\n            S_MASK(3,d,s), S_MASK(4,d,s), S_MASK(5,d,s) }\n\n#        define B_MASKS(d,s) { B_MASK(1,d,s), S_MASK(3,d,s), S_MASK(5,d,s) }\n\n#        define DEPTH_INDEX(d) ((d)==1?0:((d)==2?1:2))\n\n         /* Hence the pre-compiled masks indexed by PACKSWAP (or not), depth and\n          * then pass:\n          */\n         static PNG_CONST png_uint_32 row_mask[2/*PACKSWAP*/][3/*depth*/][6] =\n         {\n            /* Little-endian byte masks for PACKSWAP */\n            { S_MASKS(1,0), S_MASKS(2,0), S_MASKS(4,0) },\n            /* Normal (big-endian byte) masks - PNG format */\n            { S_MASKS(1,1), S_MASKS(2,1), S_MASKS(4,1) }\n         };\n\n         /* display_mask has only three entries for the odd passes, so index by\n          * pass>>1.\n          */\n         static PNG_CONST png_uint_32 display_mask[2][3][3] =\n         {\n            /* Little-endian byte masks for PACKSWAP */\n            { B_MASKS(1,0), B_MASKS(2,0), B_MASKS(4,0) },\n            /* Normal (big-endian byte) masks - PNG format */\n            { B_MASKS(1,1), B_MASKS(2,1), B_MASKS(4,1) }\n         };\n\n#        define MASK(pass,depth,display,png)\\\n            ((display)?display_mask[png][DEPTH_INDEX(depth)][pass>>1]:\\\n               row_mask[png][DEPTH_INDEX(depth)][pass])\n\n#else /* !PNG_USE_COMPILE_TIME_MASKS */\n         /* This is the runtime alternative: it seems unlikely that this will\n          * ever be either smaller or faster than the compile time approach.\n          */\n#        define MASK(pass,depth,display,png)\\\n            ((display)?B_MASK(pass,depth,png):S_MASK(pass,depth,png))\n#endif /* !PNG_USE_COMPILE_TIME_MASKS */\n\n         /* Use the appropriate mask to copy the required bits.  In some cases\n          * the byte mask will be 0 or 0xff, optimize these cases.  row_width is\n          * the number of pixels, but the code copies bytes, so it is necessary\n          * to special case the end.\n          */\n         png_uint_32 pixels_per_byte = 8 / pixel_depth;\n         png_uint_32 mask;\n\n#        ifdef PNG_READ_PACKSWAP_SUPPORTED\n            if (png_ptr->transformations & PNG_PACKSWAP)\n               mask = MASK(pass, pixel_depth, display, 0);\n\n            else\n#        endif\n            mask = MASK(pass, pixel_depth, display, 1);\n\n         for (;;)\n         {\n            png_uint_32 m;\n\n            /* It doesn't matter in the following if png_uint_32 has more than\n             * 32 bits because the high bits always match those in m<<24; it is,\n             * however, essential to use OR here, not +, because of this.\n             */\n            m = mask;\n            mask = (m >> 8) | (m << 24); /* rotate right to good compilers */\n            m &= 0xff;\n\n            if (m != 0) /* something to copy */\n            {\n               if (m != 0xff)\n                  *dp = (png_byte)((*dp & ~m) | (*sp & m));\n               else\n                  *dp = *sp;\n            }\n\n            /* NOTE: this may overwrite the last byte with garbage if the image\n             * is not an exact number of bytes wide; libpng has always done\n             * this.\n             */\n            if (row_width <= pixels_per_byte)\n               break; /* May need to restore part of the last byte */\n\n            row_width -= pixels_per_byte;\n            ++dp;\n            ++sp;\n         }\n      }\n\n      else /* pixel_depth >= 8 */\n      {\n         unsigned int bytes_to_copy, bytes_to_jump;\n\n         /* Validate the depth - it must be a multiple of 8 */\n         if (pixel_depth & 7)\n            png_error(png_ptr, \"invalid user transform pixel depth\");\n\n         pixel_depth >>= 3; /* now in bytes */\n         row_width *= pixel_depth;\n\n         /* Regardless of pass number the Adam 7 interlace always results in a\n          * fixed number of pixels to copy then to skip.  There may be a\n          * different number of pixels to skip at the start though.\n          */\n         {\n            unsigned int offset = PNG_PASS_START_COL(pass) * pixel_depth;\n\n            row_width -= offset;\n            dp += offset;\n            sp += offset;\n         }\n\n         /* Work out the bytes to copy. */\n         if (display)\n         {\n            /* When doing the 'block' algorithm the pixel in the pass gets\n             * replicated to adjacent pixels.  This is why the even (0,2,4,6)\n             * passes are skipped above - the entire expanded row is copied.\n             */\n            bytes_to_copy = (1<<((6-pass)>>1)) * pixel_depth;\n\n            /* But don't allow this number to exceed the actual row width. */\n            if (bytes_to_copy > row_width)\n               bytes_to_copy = row_width;\n         }\n\n         else /* normal row; Adam7 only ever gives us one pixel to copy. */\n            bytes_to_copy = pixel_depth;\n\n         /* In Adam7 there is a constant offset between where the pixels go. */\n         bytes_to_jump = PNG_PASS_COL_OFFSET(pass) * pixel_depth;\n\n         /* And simply copy these bytes.  Some optimization is possible here,\n          * depending on the value of 'bytes_to_copy'.  Special case the low\n          * byte counts, which we know to be frequent.\n          *\n          * Notice that these cases all 'return' rather than 'break' - this\n          * avoids an unnecessary test on whether to restore the last byte\n          * below.\n          */\n         switch (bytes_to_copy)\n         {\n            case 1:\n               for (;;)\n               {\n                  *dp = *sp;\n\n                  if (row_width <= bytes_to_jump)\n                     return;\n\n                  dp += bytes_to_jump;\n                  sp += bytes_to_jump;\n                  row_width -= bytes_to_jump;\n               }\n\n            case 2:\n               /* There is a possibility of a partial copy at the end here; this\n                * slows the code down somewhat.\n                */\n               do\n               {\n                  dp[0] = sp[0], dp[1] = sp[1];\n\n                  if (row_width <= bytes_to_jump)\n                     return;\n\n                  sp += bytes_to_jump;\n                  dp += bytes_to_jump;\n                  row_width -= bytes_to_jump;\n               }\n               while (row_width > 1);\n\n               /* And there can only be one byte left at this point: */\n               *dp = *sp;\n               return;\n\n            case 3:\n               /* This can only be the RGB case, so each copy is exactly one\n                * pixel and it is not necessary to check for a partial copy.\n                */\n               for(;;)\n               {\n                  dp[0] = sp[0], dp[1] = sp[1], dp[2] = sp[2];\n\n                  if (row_width <= bytes_to_jump)\n                     return;\n\n                  sp += bytes_to_jump;\n                  dp += bytes_to_jump;\n                  row_width -= bytes_to_jump;\n               }\n\n            default:\n#if PNG_ALIGN_TYPE != PNG_ALIGN_NONE\n               /* Check for double byte alignment and, if possible, use a\n                * 16-bit copy.  Don't attempt this for narrow images - ones that\n                * are less than an interlace panel wide.  Don't attempt it for\n                * wide bytes_to_copy either - use the memcpy there.\n                */\n               if (bytes_to_copy < 16 /*else use memcpy*/ &&\n                  png_isaligned(dp, png_uint_16) &&\n                  png_isaligned(sp, png_uint_16) &&\n                  bytes_to_copy % (sizeof (png_uint_16)) == 0 &&\n                  bytes_to_jump % (sizeof (png_uint_16)) == 0)\n               {\n                  /* Everything is aligned for png_uint_16 copies, but try for\n                   * png_uint_32 first.\n                   */\n                  if (png_isaligned(dp, png_uint_32) &&\n                     png_isaligned(sp, png_uint_32) &&\n                     bytes_to_copy % (sizeof (png_uint_32)) == 0 &&\n                     bytes_to_jump % (sizeof (png_uint_32)) == 0)\n                  {\n                     png_uint_32p dp32 = png_aligncast(png_uint_32p,dp);\n                     png_const_uint_32p sp32 = png_aligncastconst(\n                        png_const_uint_32p, sp);\n                     size_t skip = (bytes_to_jump-bytes_to_copy) /\n                        (sizeof (png_uint_32));\n\n                     do\n                     {\n                        size_t c = bytes_to_copy;\n                        do\n                        {\n                           *dp32++ = *sp32++;\n                           c -= (sizeof (png_uint_32));\n                        }\n                        while (c > 0);\n\n                        if (row_width <= bytes_to_jump)\n                           return;\n\n                        dp32 += skip;\n                        sp32 += skip;\n                        row_width -= bytes_to_jump;\n                     }\n                     while (bytes_to_copy <= row_width);\n\n                     /* Get to here when the row_width truncates the final copy.\n                      * There will be 1-3 bytes left to copy, so don't try the\n                      * 16-bit loop below.\n                      */\n                     dp = (png_bytep)dp32;\n                     sp = (png_const_bytep)sp32;\n                     do\n                        *dp++ = *sp++;\n                     while (--row_width > 0);\n                     return;\n                  }\n\n                  /* Else do it in 16-bit quantities, but only if the size is\n                   * not too large.\n                   */\n                  else\n                  {\n                     png_uint_16p dp16 = png_aligncast(png_uint_16p, dp);\n                     png_const_uint_16p sp16 = png_aligncastconst(\n                        png_const_uint_16p, sp);\n                     size_t skip = (bytes_to_jump-bytes_to_copy) /\n                        (sizeof (png_uint_16));\n\n                     do\n                     {\n                        size_t c = bytes_to_copy;\n                        do\n                        {\n                           *dp16++ = *sp16++;\n                           c -= (sizeof (png_uint_16));\n                        }\n                        while (c > 0);\n\n                        if (row_width <= bytes_to_jump)\n                           return;\n\n                        dp16 += skip;\n                        sp16 += skip;\n                        row_width -= bytes_to_jump;\n                     }\n                     while (bytes_to_copy <= row_width);\n\n                     /* End of row - 1 byte left, bytes_to_copy > row_width: */\n                     dp = (png_bytep)dp16;\n                     sp = (png_const_bytep)sp16;\n                     do\n                        *dp++ = *sp++;\n                     while (--row_width > 0);\n                     return;\n                  }\n               }\n#endif /* PNG_ALIGN_ code */\n\n               /* The true default - use a memcpy: */\n               for (;;)\n               {\n                  memcpy(dp, sp, bytes_to_copy);\n\n                  if (row_width <= bytes_to_jump)\n                     return;\n\n                  sp += bytes_to_jump;\n                  dp += bytes_to_jump;\n                  row_width -= bytes_to_jump;\n                  if (bytes_to_copy > row_width)\n                     bytes_to_copy = row_width;\n               }\n         }\n\n         /* NOT REACHED*/\n      } /* pixel_depth >= 8 */\n\n      /* Here if pixel_depth < 8 to check 'end_ptr' below. */\n   }\n   else\n#endif\n\n   /* If here then the switch above wasn't used so just memcpy the whole row\n    * from the temporary row buffer (notice that this overwrites the end of the\n    * destination row if it is a partial byte.)\n    */\n   memcpy(dp, sp, PNG_ROWBYTES(pixel_depth, row_width));\n\n   /* Restore the overwritten bits from the last byte if necessary. */\n   if (end_ptr != NULL)\n      *end_ptr = (png_byte)((end_byte & end_mask) | (*end_ptr & ~end_mask));\n}\n\n#ifdef PNG_READ_INTERLACING_SUPPORTED\nvoid /* PRIVATE */\npng_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,\n   png_uint_32 transformations /* Because these may affect the byte layout */)\n{\n   /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */\n   /* Offset to next interlace block */\n   static PNG_CONST int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};\n\n   png_debug(1, \"in png_do_read_interlace\");\n   if (row != NULL && row_info != NULL)\n   {\n      png_uint_32 final_width;\n\n      final_width = row_info->width * png_pass_inc[pass];\n\n      switch (row_info->pixel_depth)\n      {\n         case 1:\n         {\n            png_bytep sp = row + (png_size_t)((row_info->width - 1) >> 3);\n            png_bytep dp = row + (png_size_t)((final_width - 1) >> 3);\n            int sshift, dshift;\n            int s_start, s_end, s_inc;\n            int jstop = png_pass_inc[pass];\n            png_byte v;\n            png_uint_32 i;\n            int j;\n\n#ifdef PNG_READ_PACKSWAP_SUPPORTED\n            if (transformations & PNG_PACKSWAP)\n            {\n                sshift = (int)((row_info->width + 7) & 0x07);\n                dshift = (int)((final_width + 7) & 0x07);\n                s_start = 7;\n                s_end = 0;\n                s_inc = -1;\n            }\n\n            else\n#endif\n            {\n                sshift = 7 - (int)((row_info->width + 7) & 0x07);\n                dshift = 7 - (int)((final_width + 7) & 0x07);\n                s_start = 0;\n                s_end = 7;\n                s_inc = 1;\n            }\n\n            for (i = 0; i < row_info->width; i++)\n            {\n               v = (png_byte)((*sp >> sshift) & 0x01);\n               for (j = 0; j < jstop; j++)\n               {\n                  unsigned int tmp = *dp & (0x7f7f >> (7 - dshift));\n                  tmp |= v << dshift;\n                  *dp = (png_byte)(tmp & 0xff);\n\n                  if (dshift == s_end)\n                  {\n                     dshift = s_start;\n                     dp--;\n                  }\n\n                  else\n                     dshift += s_inc;\n               }\n\n               if (sshift == s_end)\n               {\n                  sshift = s_start;\n                  sp--;\n               }\n\n               else\n                  sshift += s_inc;\n            }\n            break;\n         }\n\n         case 2:\n         {\n            png_bytep sp = row + (png_uint_32)((row_info->width - 1) >> 2);\n            png_bytep dp = row + (png_uint_32)((final_width - 1) >> 2);\n            int sshift, dshift;\n            int s_start, s_end, s_inc;\n            int jstop = png_pass_inc[pass];\n            png_uint_32 i;\n\n#ifdef PNG_READ_PACKSWAP_SUPPORTED\n            if (transformations & PNG_PACKSWAP)\n            {\n               sshift = (int)(((row_info->width + 3) & 0x03) << 1);\n               dshift = (int)(((final_width + 3) & 0x03) << 1);\n               s_start = 6;\n               s_end = 0;\n               s_inc = -2;\n            }\n\n            else\n#endif\n            {\n               sshift = (int)((3 - ((row_info->width + 3) & 0x03)) << 1);\n               dshift = (int)((3 - ((final_width + 3) & 0x03)) << 1);\n               s_start = 0;\n               s_end = 6;\n               s_inc = 2;\n            }\n\n            for (i = 0; i < row_info->width; i++)\n            {\n               png_byte v;\n               int j;\n\n               v = (png_byte)((*sp >> sshift) & 0x03);\n               for (j = 0; j < jstop; j++)\n               {\n                  unsigned int tmp = *dp & (0x3f3f >> (6 - dshift));\n                  tmp |= v << dshift;\n                  *dp = (png_byte)(tmp & 0xff);\n\n                  if (dshift == s_end)\n                  {\n                     dshift = s_start;\n                     dp--;\n                  }\n\n                  else\n                     dshift += s_inc;\n               }\n\n               if (sshift == s_end)\n               {\n                  sshift = s_start;\n                  sp--;\n               }\n\n               else\n                  sshift += s_inc;\n            }\n            break;\n         }\n\n         case 4:\n         {\n            png_bytep sp = row + (png_size_t)((row_info->width - 1) >> 1);\n            png_bytep dp = row + (png_size_t)((final_width - 1) >> 1);\n            int sshift, dshift;\n            int s_start, s_end, s_inc;\n            png_uint_32 i;\n            int jstop = png_pass_inc[pass];\n\n#ifdef PNG_READ_PACKSWAP_SUPPORTED\n            if (transformations & PNG_PACKSWAP)\n            {\n               sshift = (int)(((row_info->width + 1) & 0x01) << 2);\n               dshift = (int)(((final_width + 1) & 0x01) << 2);\n               s_start = 4;\n               s_end = 0;\n               s_inc = -4;\n            }\n\n            else\n#endif\n            {\n               sshift = (int)((1 - ((row_info->width + 1) & 0x01)) << 2);\n               dshift = (int)((1 - ((final_width + 1) & 0x01)) << 2);\n               s_start = 0;\n               s_end = 4;\n               s_inc = 4;\n            }\n\n            for (i = 0; i < row_info->width; i++)\n            {\n               png_byte v = (png_byte)((*sp >> sshift) & 0x0f);\n               int j;\n\n               for (j = 0; j < jstop; j++)\n               {\n                  unsigned int tmp = *dp & (0xf0f >> (4 - dshift));\n                  tmp |= v << dshift;\n                  *dp = (png_byte)(tmp & 0xff);\n\n                  if (dshift == s_end)\n                  {\n                     dshift = s_start;\n                     dp--;\n                  }\n\n                  else\n                     dshift += s_inc;\n               }\n\n               if (sshift == s_end)\n               {\n                  sshift = s_start;\n                  sp--;\n               }\n\n               else\n                  sshift += s_inc;\n            }\n            break;\n         }\n\n         default:\n         {\n            png_size_t pixel_bytes = (row_info->pixel_depth >> 3);\n\n            png_bytep sp = row + (png_size_t)(row_info->width - 1)\n                * pixel_bytes;\n\n            png_bytep dp = row + (png_size_t)(final_width - 1) * pixel_bytes;\n\n            int jstop = png_pass_inc[pass];\n            png_uint_32 i;\n\n            for (i = 0; i < row_info->width; i++)\n            {\n               png_byte v[8]; /* SAFE; pixel_depth does not exceed 64 */\n               int j;\n\n               memcpy(v, sp, pixel_bytes);\n\n               for (j = 0; j < jstop; j++)\n               {\n                  memcpy(dp, v, pixel_bytes);\n                  dp -= pixel_bytes;\n               }\n\n               sp -= pixel_bytes;\n            }\n            break;\n         }\n      }\n\n      row_info->width = final_width;\n      row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, final_width);\n   }\n#ifndef PNG_READ_PACKSWAP_SUPPORTED\n   PNG_UNUSED(transformations)  /* Silence compiler warning */\n#endif\n}\n#endif /* PNG_READ_INTERLACING_SUPPORTED */\n\nstatic void\npng_read_filter_row_sub(png_row_infop row_info, png_bytep row,\n   png_const_bytep prev_row)\n{\n   png_size_t i;\n   png_size_t istop = row_info->rowbytes;\n   unsigned int bpp = (row_info->pixel_depth + 7) >> 3;\n   png_bytep rp = row + bpp;\n\n   PNG_UNUSED(prev_row)\n\n   for (i = bpp; i < istop; i++)\n   {\n      *rp = (png_byte)(((int)(*rp) + (int)(*(rp-bpp))) & 0xff);\n      rp++;\n   }\n}\n\nstatic void\npng_read_filter_row_up(png_row_infop row_info, png_bytep row,\n   png_const_bytep prev_row)\n{\n   png_size_t i;\n   png_size_t istop = row_info->rowbytes;\n   png_bytep rp = row;\n   png_const_bytep pp = prev_row;\n\n   for (i = 0; i < istop; i++)\n   {\n      *rp = (png_byte)(((int)(*rp) + (int)(*pp++)) & 0xff);\n      rp++;\n   }\n}\n\nstatic void\npng_read_filter_row_avg(png_row_infop row_info, png_bytep row,\n   png_const_bytep prev_row)\n{\n   png_size_t i;\n   png_bytep rp = row;\n   png_const_bytep pp = prev_row;\n   unsigned int bpp = (row_info->pixel_depth + 7) >> 3;\n   png_size_t istop = row_info->rowbytes - bpp;\n\n   for (i = 0; i < bpp; i++)\n   {\n      *rp = (png_byte)(((int)(*rp) +\n         ((int)(*pp++) / 2 )) & 0xff);\n\n      rp++;\n   }\n\n   for (i = 0; i < istop; i++)\n   {\n      *rp = (png_byte)(((int)(*rp) +\n         (int)(*pp++ + *(rp-bpp)) / 2 ) & 0xff);\n\n      rp++;\n   }\n}\n\nstatic void\npng_read_filter_row_paeth_1byte_pixel(png_row_infop row_info, png_bytep row,\n   png_const_bytep prev_row)\n{\n   png_bytep rp_end = row + row_info->rowbytes;\n   int a, c;\n\n   /* First pixel/byte */\n   c = *prev_row++;\n   a = *row + c;\n   *row++ = (png_byte)a;\n\n   /* Remainder */\n   while (row < rp_end)\n   {\n      int b, pa, pb, pc, p;\n\n      a &= 0xff; /* From previous iteration or start */\n      b = *prev_row++;\n\n      p = b - c;\n      pc = a - c;\n\n#     ifdef PNG_USE_ABS\n         pa = abs(p);\n         pb = abs(pc);\n         pc = abs(p + pc);\n#     else\n         pa = p < 0 ? -p : p;\n         pb = pc < 0 ? -pc : pc;\n         pc = (p + pc) < 0 ? -(p + pc) : p + pc;\n#     endif\n\n      /* Find the best predictor, the least of pa, pb, pc favoring the earlier\n       * ones in the case of a tie.\n       */\n      if (pb < pa) pa = pb, a = b;\n      if (pc < pa) a = c;\n\n      /* Calculate the current pixel in a, and move the previous row pixel to c\n       * for the next time round the loop\n       */\n      c = b;\n      a += *row;\n      *row++ = (png_byte)a;\n   }\n}\n\nstatic void\npng_read_filter_row_paeth_multibyte_pixel(png_row_infop row_info, png_bytep row,\n   png_const_bytep prev_row)\n{\n   int bpp = (row_info->pixel_depth + 7) >> 3;\n   png_bytep rp_end = row + bpp;\n\n   /* Process the first pixel in the row completely (this is the same as 'up'\n    * because there is only one candidate predictor for the first row).\n    */\n   while (row < rp_end)\n   {\n      int a = *row + *prev_row++;\n      *row++ = (png_byte)a;\n   }\n\n   /* Remainder */\n   rp_end += row_info->rowbytes - bpp;\n\n   while (row < rp_end)\n   {\n      int a, b, c, pa, pb, pc, p;\n\n      c = *(prev_row - bpp);\n      a = *(row - bpp);\n      b = *prev_row++;\n\n      p = b - c;\n      pc = a - c;\n\n#     ifdef PNG_USE_ABS\n         pa = abs(p);\n         pb = abs(pc);\n         pc = abs(p + pc);\n#     else\n         pa = p < 0 ? -p : p;\n         pb = pc < 0 ? -pc : pc;\n         pc = (p + pc) < 0 ? -(p + pc) : p + pc;\n#     endif\n\n      if (pb < pa) pa = pb, a = b;\n      if (pc < pa) a = c;\n\n      a += *row;\n      *row++ = (png_byte)a;\n   }\n}\n\nstatic void\npng_init_filter_functions(png_structrp pp)\n   /* This function is called once for every PNG image (except for PNG images\n    * that only use PNG_FILTER_VALUE_NONE for all rows) to set the\n    * implementations required to reverse the filtering of PNG rows.  Reversing\n    * the filter is the first transformation performed on the row data.  It is\n    * performed in place, therefore an implementation can be selected based on\n    * the image pixel format.  If the implementation depends on image width then\n    * take care to ensure that it works correctly if the image is interlaced -\n    * interlacing causes the actual row width to vary.\n    */\n{\n   unsigned int bpp = (pp->pixel_depth + 7) >> 3;\n\n   pp->read_filter[PNG_FILTER_VALUE_SUB-1] = png_read_filter_row_sub;\n   pp->read_filter[PNG_FILTER_VALUE_UP-1] = png_read_filter_row_up;\n   pp->read_filter[PNG_FILTER_VALUE_AVG-1] = png_read_filter_row_avg;\n   if (bpp == 1)\n      pp->read_filter[PNG_FILTER_VALUE_PAETH-1] =\n         png_read_filter_row_paeth_1byte_pixel;\n   else\n      pp->read_filter[PNG_FILTER_VALUE_PAETH-1] =\n         png_read_filter_row_paeth_multibyte_pixel;\n\n#ifdef PNG_FILTER_OPTIMIZATIONS\n   /* To use this define PNG_FILTER_OPTIMIZATIONS as the name of a function to\n    * call to install hardware optimizations for the above functions; simply\n    * replace whatever elements of the pp->read_filter[] array with a hardware\n    * specific (or, for that matter, generic) optimization.\n    *\n    * To see an example of this examine what configure.ac does when\n    * --enable-arm-neon is specified on the command line.\n    */\n   PNG_FILTER_OPTIMIZATIONS(pp, bpp);\n#endif\n}\n\nvoid /* PRIVATE */\npng_read_filter_row(png_structrp pp, png_row_infop row_info, png_bytep row,\n   png_const_bytep prev_row, int filter)\n{\n   /* OPTIMIZATION: DO NOT MODIFY THIS FUNCTION, instead #define\n    * PNG_FILTER_OPTIMIZATIONS to a function that overrides the generic\n    * implementations.  See png_init_filter_functions above.\n    */\n   if (filter > PNG_FILTER_VALUE_NONE && filter < PNG_FILTER_VALUE_LAST)\n   {\n      if (pp->read_filter[0] == NULL)\n         png_init_filter_functions(pp);\n\n      pp->read_filter[filter-1](row_info, row, prev_row);\n   }\n}\n\n#ifdef PNG_SEQUENTIAL_READ_SUPPORTED\nvoid /* PRIVATE */\npng_read_IDAT_data(png_structrp png_ptr, png_bytep output,\n   png_alloc_size_t avail_out)\n{\n   /* Loop reading IDATs and decompressing the result into output[avail_out] */\n   png_ptr->zstream.next_out = output;\n   png_ptr->zstream.avail_out = 0; /* safety: set below */\n\n   if (output == NULL)\n      avail_out = 0;\n\n   do\n   {\n      int ret;\n      png_byte tmpbuf[PNG_INFLATE_BUF_SIZE];\n\n      if (png_ptr->zstream.avail_in == 0)\n      {\n         uInt avail_in;\n         png_bytep buffer;\n\n         while (png_ptr->idat_size == 0)\n         {\n            png_crc_finish(png_ptr, 0);\n\n            png_ptr->idat_size = png_read_chunk_header(png_ptr);\n            /* This is an error even in the 'check' case because the code just\n             * consumed a non-IDAT header.\n             */\n            if (png_ptr->chunk_name != png_IDAT)\n               png_error(png_ptr, \"Not enough image data\");\n         }\n\n         avail_in = png_ptr->IDAT_read_size;\n\n         if (avail_in > png_ptr->idat_size)\n            avail_in = (uInt)png_ptr->idat_size;\n\n         /* A PNG with a gradually increasing IDAT size will defeat this attempt\n          * to minimize memory usage by causing lots of re-allocs, but\n          * realistically doing IDAT_read_size re-allocs is not likely to be a\n          * big problem.\n          */\n         buffer = png_read_buffer(png_ptr, avail_in, 0/*error*/);\n\n         png_crc_read(png_ptr, buffer, avail_in);\n         png_ptr->idat_size -= avail_in;\n\n         png_ptr->zstream.next_in = buffer;\n         png_ptr->zstream.avail_in = avail_in;\n      }\n\n      /* And set up the output side. */\n      if (output != NULL) /* standard read */\n      {\n         uInt out = ZLIB_IO_MAX;\n\n         if (out > avail_out)\n            out = (uInt)avail_out;\n\n         avail_out -= out;\n         png_ptr->zstream.avail_out = out;\n      }\n\n      else /* after last row, checking for end */\n      {\n         png_ptr->zstream.next_out = tmpbuf;\n         png_ptr->zstream.avail_out = (sizeof tmpbuf);\n      }\n\n      /* Use NO_FLUSH; this gives zlib the maximum opportunity to optimize the\n       * process.  If the LZ stream is truncated the sequential reader will\n       * terminally damage the stream, above, by reading the chunk header of the\n       * following chunk (it then exits with png_error).\n       *\n       * TODO: deal more elegantly with truncated IDAT lists.\n       */\n      ret = inflate(&png_ptr->zstream, Z_NO_FLUSH);\n\n      /* Take the unconsumed output back. */\n      if (output != NULL)\n         avail_out += png_ptr->zstream.avail_out;\n\n      else /* avail_out counts the extra bytes */\n         avail_out += (sizeof tmpbuf) - png_ptr->zstream.avail_out;\n\n      png_ptr->zstream.avail_out = 0;\n\n      if (ret == Z_STREAM_END)\n      {\n         /* Do this for safety; we won't read any more into this row. */\n         png_ptr->zstream.next_out = NULL;\n\n         png_ptr->mode |= PNG_AFTER_IDAT;\n         png_ptr->flags |= PNG_FLAG_ZSTREAM_ENDED;\n\n         if (png_ptr->zstream.avail_in > 0 || png_ptr->idat_size > 0)\n            png_chunk_benign_error(png_ptr, \"Extra compressed data\");\n         break;\n      }\n\n      if (ret != Z_OK)\n      {\n         png_zstream_error(png_ptr, ret);\n\n         if (output != NULL)\n            png_chunk_error(png_ptr, png_ptr->zstream.msg);\n\n         else /* checking */\n         {\n            png_chunk_benign_error(png_ptr, png_ptr->zstream.msg);\n            return;\n         }\n      }\n   } while (avail_out > 0);\n\n   if (avail_out > 0)\n   {\n      /* The stream ended before the image; this is the same as too few IDATs so\n       * should be handled the same way.\n       */\n      if (output != NULL)\n         png_error(png_ptr, \"Not enough image data\");\n\n      else /* the deflate stream contained extra data */\n         png_chunk_benign_error(png_ptr, \"Too much image data\");\n   }\n}\n\nvoid /* PRIVATE */\npng_read_finish_IDAT(png_structrp png_ptr)\n{\n   /* We don't need any more data and the stream should have ended, however the\n    * LZ end code may actually not have been processed.  In this case we must\n    * read it otherwise stray unread IDAT data or, more likely, an IDAT chunk\n    * may still remain to be consumed.\n    */\n   if (!(png_ptr->flags & PNG_FLAG_ZSTREAM_ENDED))\n   {\n      /* The NULL causes png_read_IDAT_data to swallow any remaining bytes in\n       * the compressed stream, but the stream may be damaged too, so even after\n       * this call we may need to terminate the zstream ownership.\n       */\n      png_read_IDAT_data(png_ptr, NULL, 0);\n      png_ptr->zstream.next_out = NULL; /* safety */\n\n      /* Now clear everything out for safety; the following may not have been\n       * done.\n       */\n      if (!(png_ptr->flags & PNG_FLAG_ZSTREAM_ENDED))\n      {\n         png_ptr->mode |= PNG_AFTER_IDAT;\n         png_ptr->flags |= PNG_FLAG_ZSTREAM_ENDED;\n      }\n   }\n\n   /* If the zstream has not been released do it now *and* terminate the reading\n    * of the final IDAT chunk.\n    */\n   if (png_ptr->zowner == png_IDAT)\n   {\n      /* Always do this; the pointers otherwise point into the read buffer. */\n      png_ptr->zstream.next_in = NULL;\n      png_ptr->zstream.avail_in = 0;\n\n      /* Now we no longer own the zstream. */\n      png_ptr->zowner = 0;\n\n      /* The slightly weird semantics of the sequential IDAT reading is that we\n       * are always in or at the end of an IDAT chunk, so we always need to do a\n       * crc_finish here.  If idat_size is non-zero we also need to read the\n       * spurious bytes at the end of the chunk now.\n       */\n      (void)png_crc_finish(png_ptr, png_ptr->idat_size);\n   }\n}\n\nvoid /* PRIVATE */\npng_read_finish_row(png_structrp png_ptr)\n{\n#ifdef PNG_READ_INTERLACING_SUPPORTED\n   /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */\n\n   /* Start of interlace block */\n   static PNG_CONST png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};\n\n   /* Offset to next interlace block */\n   static PNG_CONST png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};\n\n   /* Start of interlace block in the y direction */\n   static PNG_CONST png_byte png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1};\n\n   /* Offset to next interlace block in the y direction */\n   static PNG_CONST png_byte png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};\n#endif /* PNG_READ_INTERLACING_SUPPORTED */\n\n   png_debug(1, \"in png_read_finish_row\");\n   png_ptr->row_number++;\n   if (png_ptr->row_number < png_ptr->num_rows)\n      return;\n\n#ifdef PNG_READ_INTERLACING_SUPPORTED\n   if (png_ptr->interlaced)\n   {\n      png_ptr->row_number = 0;\n\n      /* TO DO: don't do this if prev_row isn't needed (requires\n       * read-ahead of the next row's filter byte.\n       */\n      memset(png_ptr->prev_row, 0, png_ptr->rowbytes + 1);\n\n      do\n      {\n         png_ptr->pass++;\n\n         if (png_ptr->pass >= 7)\n            break;\n\n         png_ptr->iwidth = (png_ptr->width +\n            png_pass_inc[png_ptr->pass] - 1 -\n            png_pass_start[png_ptr->pass]) /\n            png_pass_inc[png_ptr->pass];\n\n         if (!(png_ptr->transformations & PNG_INTERLACE))\n         {\n            png_ptr->num_rows = (png_ptr->height +\n                png_pass_yinc[png_ptr->pass] - 1 -\n                png_pass_ystart[png_ptr->pass]) /\n                png_pass_yinc[png_ptr->pass];\n         }\n\n         else  /* if (png_ptr->transformations & PNG_INTERLACE) */\n            break; /* libpng deinterlacing sees every row */\n\n      } while (png_ptr->num_rows == 0 || png_ptr->iwidth == 0);\n\n      if (png_ptr->pass < 7)\n         return;\n   }\n#endif /* PNG_READ_INTERLACING_SUPPORTED */\n\n   /* Here after at the end of the last row of the last pass. */\n   png_read_finish_IDAT(png_ptr);\n}\n#endif /* PNG_SEQUENTIAL_READ_SUPPORTED */\n\nvoid /* PRIVATE */\npng_read_start_row(png_structrp png_ptr)\n{\n#ifdef PNG_READ_INTERLACING_SUPPORTED\n   /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */\n\n   /* Start of interlace block */\n   static PNG_CONST png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};\n\n   /* Offset to next interlace block */\n   static PNG_CONST png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};\n\n   /* Start of interlace block in the y direction */\n   static PNG_CONST png_byte png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1};\n\n   /* Offset to next interlace block in the y direction */\n   static PNG_CONST png_byte png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};\n#endif\n\n   int max_pixel_depth;\n   png_size_t row_bytes;\n\n   png_debug(1, \"in png_read_start_row\");\n\n#ifdef PNG_READ_TRANSFORMS_SUPPORTED\n   png_init_read_transformations(png_ptr);\n#endif\n#ifdef PNG_READ_INTERLACING_SUPPORTED\n   if (png_ptr->interlaced)\n   {\n      if (!(png_ptr->transformations & PNG_INTERLACE))\n         png_ptr->num_rows = (png_ptr->height + png_pass_yinc[0] - 1 -\n             png_pass_ystart[0]) / png_pass_yinc[0];\n\n      else\n         png_ptr->num_rows = png_ptr->height;\n\n      png_ptr->iwidth = (png_ptr->width +\n          png_pass_inc[png_ptr->pass] - 1 -\n          png_pass_start[png_ptr->pass]) /\n          png_pass_inc[png_ptr->pass];\n   }\n\n   else\n#endif /* PNG_READ_INTERLACING_SUPPORTED */\n   {\n      png_ptr->num_rows = png_ptr->height;\n      png_ptr->iwidth = png_ptr->width;\n   }\n\n   max_pixel_depth = png_ptr->pixel_depth;\n\n   /* WARNING: * png_read_transform_info (pngrtran.c) performs a simpliar set of\n    * calculations to calculate the final pixel depth, then\n    * png_do_read_transforms actually does the transforms.  This means that the\n    * code which effectively calculates this value is actually repeated in three\n    * separate places.  They must all match.  Innocent changes to the order of\n    * transformations can and will break libpng in a way that causes memory\n    * overwrites.\n    *\n    * TODO: fix this.\n    */\n#ifdef PNG_READ_PACK_SUPPORTED\n   if ((png_ptr->transformations & PNG_PACK) && png_ptr->bit_depth < 8)\n      max_pixel_depth = 8;\n#endif\n\n#ifdef PNG_READ_EXPAND_SUPPORTED\n   if (png_ptr->transformations & PNG_EXPAND)\n   {\n      if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)\n      {\n         if (png_ptr->num_trans)\n            max_pixel_depth = 32;\n\n         else\n            max_pixel_depth = 24;\n      }\n\n      else if (png_ptr->color_type == PNG_COLOR_TYPE_GRAY)\n      {\n         if (max_pixel_depth < 8)\n            max_pixel_depth = 8;\n\n         if (png_ptr->num_trans)\n            max_pixel_depth *= 2;\n      }\n\n      else if (png_ptr->color_type == PNG_COLOR_TYPE_RGB)\n      {\n         if (png_ptr->num_trans)\n         {\n            max_pixel_depth *= 4;\n            max_pixel_depth /= 3;\n         }\n      }\n   }\n#endif\n\n#ifdef PNG_READ_EXPAND_16_SUPPORTED\n   if (png_ptr->transformations & PNG_EXPAND_16)\n   {\n#     ifdef PNG_READ_EXPAND_SUPPORTED\n         /* In fact it is an error if it isn't supported, but checking is\n          * the safe way.\n          */\n         if (png_ptr->transformations & PNG_EXPAND)\n         {\n            if (png_ptr->bit_depth < 16)\n               max_pixel_depth *= 2;\n         }\n         else\n#     endif\n         png_ptr->transformations &= ~PNG_EXPAND_16;\n   }\n#endif\n\n#ifdef PNG_READ_FILLER_SUPPORTED\n   if (png_ptr->transformations & (PNG_FILLER))\n   {\n      if (png_ptr->color_type == PNG_COLOR_TYPE_GRAY)\n      {\n         if (max_pixel_depth <= 8)\n            max_pixel_depth = 16;\n\n         else\n            max_pixel_depth = 32;\n      }\n\n      else if (png_ptr->color_type == PNG_COLOR_TYPE_RGB ||\n         png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)\n      {\n         if (max_pixel_depth <= 32)\n            max_pixel_depth = 32;\n\n         else\n            max_pixel_depth = 64;\n      }\n   }\n#endif\n\n#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED\n   if (png_ptr->transformations & PNG_GRAY_TO_RGB)\n   {\n      if (\n#ifdef PNG_READ_EXPAND_SUPPORTED\n          (png_ptr->num_trans && (png_ptr->transformations & PNG_EXPAND)) ||\n#endif\n#ifdef PNG_READ_FILLER_SUPPORTED\n          (png_ptr->transformations & (PNG_FILLER)) ||\n#endif\n          png_ptr->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)\n      {\n         if (max_pixel_depth <= 16)\n            max_pixel_depth = 32;\n\n         else\n            max_pixel_depth = 64;\n      }\n\n      else\n      {\n         if (max_pixel_depth <= 8)\n         {\n            if (png_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA)\n               max_pixel_depth = 32;\n\n            else\n               max_pixel_depth = 24;\n         }\n\n         else if (png_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA)\n            max_pixel_depth = 64;\n\n         else\n            max_pixel_depth = 48;\n      }\n   }\n#endif\n\n#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) && \\\ndefined(PNG_USER_TRANSFORM_PTR_SUPPORTED)\n   if (png_ptr->transformations & PNG_USER_TRANSFORM)\n   {\n      int user_pixel_depth = png_ptr->user_transform_depth *\n         png_ptr->user_transform_channels;\n\n      if (user_pixel_depth > max_pixel_depth)\n         max_pixel_depth = user_pixel_depth;\n   }\n#endif\n\n   /* This value is stored in png_struct and double checked in the row read\n    * code.\n    */\n   png_ptr->maximum_pixel_depth = (png_byte)max_pixel_depth;\n   png_ptr->transformed_pixel_depth = 0; /* calculated on demand */\n\n   /* Align the width on the next larger 8 pixels.  Mainly used\n    * for interlacing\n    */\n   row_bytes = ((png_ptr->width + 7) & ~((png_uint_32)7));\n   /* Calculate the maximum bytes needed, adding a byte and a pixel\n    * for safety's sake\n    */\n   row_bytes = PNG_ROWBYTES(max_pixel_depth, row_bytes) +\n       1 + ((max_pixel_depth + 7) >> 3);\n\n#ifdef PNG_MAX_MALLOC_64K\n   if (row_bytes > (png_uint_32)65536L)\n      png_error(png_ptr, \"This image requires a row greater than 64KB\");\n#endif\n\n   if (row_bytes + 48 > png_ptr->old_big_row_buf_size)\n   {\n     png_free(png_ptr, png_ptr->big_row_buf);\n     png_free(png_ptr, png_ptr->big_prev_row);\n\n     if (png_ptr->interlaced)\n        png_ptr->big_row_buf = (png_bytep)png_calloc(png_ptr,\n            row_bytes + 48);\n\n     else\n        png_ptr->big_row_buf = (png_bytep)png_malloc(png_ptr, row_bytes + 48);\n\n     png_ptr->big_prev_row = (png_bytep)png_malloc(png_ptr, row_bytes + 48);\n\n#ifdef PNG_ALIGNED_MEMORY_SUPPORTED\n     /* Use 16-byte aligned memory for row_buf with at least 16 bytes\n      * of padding before and after row_buf; treat prev_row similarly.\n      * NOTE: the alignment is to the start of the pixels, one beyond the start\n      * of the buffer, because of the filter byte.  Prior to libpng 1.5.6 this\n      * was incorrect; the filter byte was aligned, which had the exact\n      * opposite effect of that intended.\n      */\n     {\n        png_bytep temp = png_ptr->big_row_buf + 32;\n        int extra = (int)((temp - (png_bytep)0) & 0x0f);\n        png_ptr->row_buf = temp - extra - 1/*filter byte*/;\n\n        temp = png_ptr->big_prev_row + 32;\n        extra = (int)((temp - (png_bytep)0) & 0x0f);\n        png_ptr->prev_row = temp - extra - 1/*filter byte*/;\n     }\n\n#else\n     /* Use 31 bytes of padding before and 17 bytes after row_buf. */\n     png_ptr->row_buf = png_ptr->big_row_buf + 31;\n     png_ptr->prev_row = png_ptr->big_prev_row + 31;\n#endif\n     png_ptr->old_big_row_buf_size = row_bytes + 48;\n   }\n\n#ifdef PNG_MAX_MALLOC_64K\n   if (png_ptr->rowbytes > 65535)\n      png_error(png_ptr, \"This image requires a row greater than 64KB\");\n\n#endif\n   if (png_ptr->rowbytes > (PNG_SIZE_MAX - 1))\n      png_error(png_ptr, \"Row has too many bytes to allocate in memory\");\n\n   memset(png_ptr->prev_row, 0, png_ptr->rowbytes + 1);\n\n   png_debug1(3, \"width = %u,\", png_ptr->width);\n   png_debug1(3, \"height = %u,\", png_ptr->height);\n   png_debug1(3, \"iwidth = %u,\", png_ptr->iwidth);\n   png_debug1(3, \"num_rows = %u,\", png_ptr->num_rows);\n   png_debug1(3, \"rowbytes = %lu,\", (unsigned long)png_ptr->rowbytes);\n   png_debug1(3, \"irowbytes = %lu\",\n       (unsigned long)PNG_ROWBYTES(png_ptr->pixel_depth, png_ptr->iwidth) + 1);\n\n   /* The sequential reader needs a buffer for IDAT, but the progressive reader\n    * does not, so free the read buffer now regardless; the sequential reader\n    * reallocates it on demand.\n    */\n   if (png_ptr->read_buffer)\n   {\n      png_bytep buffer = png_ptr->read_buffer;\n\n      png_ptr->read_buffer_size = 0;\n      png_ptr->read_buffer = NULL;\n      png_free(png_ptr, buffer);\n   }\n\n   /* Finally claim the zstream for the inflate of the IDAT data, use the bits\n    * value from the stream (note that this will result in a fatal error if the\n    * IDAT stream has a bogus deflate header window_bits value, but this should\n    * not be happening any longer!)\n    */\n   if (png_inflate_claim(png_ptr, png_IDAT) != Z_OK)\n      png_error(png_ptr, png_ptr->zstream.msg);\n\n   png_ptr->flags |= PNG_FLAG_ROW_INIT;\n}\n#endif /* PNG_READ_SUPPORTED */\n"
  },
  {
    "path": "Projects/Libraries/CSBase/Source/png/pngset.c",
    "content": "\n/* pngset.c - storage of image information into info struct\n *\n * Last changed in libpng 1.6.8 [December 19, 2013]\n * Copyright (c) 1998-2013 Glenn Randers-Pehrson\n * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)\n * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)\n *\n * This code is released under the libpng license.\n * For conditions of distribution and use, see the disclaimer\n * and license in png.h\n *\n * The functions here are used during reads to store data from the file\n * into the info struct, and during writes to store application data\n * into the info struct for writing into the file.  This abstracts the\n * info struct and allows us to change the structure in the future.\n */\n\n#include \"pngpriv.h\"\n\n#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)\n\n#ifdef PNG_bKGD_SUPPORTED\nvoid PNGAPI\npng_set_bKGD(png_const_structrp png_ptr, png_inforp info_ptr,\n    png_const_color_16p background)\n{\n   png_debug1(1, \"in %s storage function\", \"bKGD\");\n\n   if (png_ptr == NULL || info_ptr == NULL || background == NULL)\n      return;\n\n   info_ptr->background = *background;\n   info_ptr->valid |= PNG_INFO_bKGD;\n}\n#endif\n\n#ifdef PNG_cHRM_SUPPORTED\nvoid PNGFAPI\npng_set_cHRM_fixed(png_const_structrp png_ptr, png_inforp info_ptr,\n    png_fixed_point white_x, png_fixed_point white_y, png_fixed_point red_x,\n    png_fixed_point red_y, png_fixed_point green_x, png_fixed_point green_y,\n    png_fixed_point blue_x, png_fixed_point blue_y)\n{\n   png_xy xy;\n\n   png_debug1(1, \"in %s storage function\", \"cHRM fixed\");\n\n   if (png_ptr == NULL || info_ptr == NULL)\n      return;\n\n   xy.redx = red_x;\n   xy.redy = red_y;\n   xy.greenx = green_x;\n   xy.greeny = green_y;\n   xy.bluex = blue_x;\n   xy.bluey = blue_y;\n   xy.whitex = white_x;\n   xy.whitey = white_y;\n\n   if (png_colorspace_set_chromaticities(png_ptr, &info_ptr->colorspace, &xy,\n      2/* override with app values*/))\n      info_ptr->colorspace.flags |= PNG_COLORSPACE_FROM_cHRM;\n\n   png_colorspace_sync_info(png_ptr, info_ptr);\n}\n\nvoid PNGFAPI\npng_set_cHRM_XYZ_fixed(png_const_structrp png_ptr, png_inforp info_ptr,\n    png_fixed_point int_red_X, png_fixed_point int_red_Y,\n    png_fixed_point int_red_Z, png_fixed_point int_green_X,\n    png_fixed_point int_green_Y, png_fixed_point int_green_Z,\n    png_fixed_point int_blue_X, png_fixed_point int_blue_Y,\n    png_fixed_point int_blue_Z)\n{\n   png_XYZ XYZ;\n\n   png_debug1(1, \"in %s storage function\", \"cHRM XYZ fixed\");\n\n   if (png_ptr == NULL || info_ptr == NULL)\n      return;\n\n   XYZ.red_X = int_red_X;\n   XYZ.red_Y = int_red_Y;\n   XYZ.red_Z = int_red_Z;\n   XYZ.green_X = int_green_X;\n   XYZ.green_Y = int_green_Y;\n   XYZ.green_Z = int_green_Z;\n   XYZ.blue_X = int_blue_X;\n   XYZ.blue_Y = int_blue_Y;\n   XYZ.blue_Z = int_blue_Z;\n\n   if (png_colorspace_set_endpoints(png_ptr, &info_ptr->colorspace, &XYZ, 2))\n      info_ptr->colorspace.flags |= PNG_COLORSPACE_FROM_cHRM;\n\n   png_colorspace_sync_info(png_ptr, info_ptr);\n}\n\n#  ifdef PNG_FLOATING_POINT_SUPPORTED\nvoid PNGAPI\npng_set_cHRM(png_const_structrp png_ptr, png_inforp info_ptr,\n    double white_x, double white_y, double red_x, double red_y,\n    double green_x, double green_y, double blue_x, double blue_y)\n{\n   png_set_cHRM_fixed(png_ptr, info_ptr,\n      png_fixed(png_ptr, white_x, \"cHRM White X\"),\n      png_fixed(png_ptr, white_y, \"cHRM White Y\"),\n      png_fixed(png_ptr, red_x, \"cHRM Red X\"),\n      png_fixed(png_ptr, red_y, \"cHRM Red Y\"),\n      png_fixed(png_ptr, green_x, \"cHRM Green X\"),\n      png_fixed(png_ptr, green_y, \"cHRM Green Y\"),\n      png_fixed(png_ptr, blue_x, \"cHRM Blue X\"),\n      png_fixed(png_ptr, blue_y, \"cHRM Blue Y\"));\n}\n\nvoid PNGAPI\npng_set_cHRM_XYZ(png_const_structrp png_ptr, png_inforp info_ptr, double red_X,\n    double red_Y, double red_Z, double green_X, double green_Y, double green_Z,\n    double blue_X, double blue_Y, double blue_Z)\n{\n   png_set_cHRM_XYZ_fixed(png_ptr, info_ptr,\n      png_fixed(png_ptr, red_X, \"cHRM Red X\"),\n      png_fixed(png_ptr, red_Y, \"cHRM Red Y\"),\n      png_fixed(png_ptr, red_Z, \"cHRM Red Z\"),\n      png_fixed(png_ptr, green_X, \"cHRM Red X\"),\n      png_fixed(png_ptr, green_Y, \"cHRM Red Y\"),\n      png_fixed(png_ptr, green_Z, \"cHRM Red Z\"),\n      png_fixed(png_ptr, blue_X, \"cHRM Red X\"),\n      png_fixed(png_ptr, blue_Y, \"cHRM Red Y\"),\n      png_fixed(png_ptr, blue_Z, \"cHRM Red Z\"));\n}\n#  endif /* PNG_FLOATING_POINT_SUPPORTED */\n\n#endif /* PNG_cHRM_SUPPORTED */\n\n#ifdef PNG_gAMA_SUPPORTED\nvoid PNGFAPI\npng_set_gAMA_fixed(png_const_structrp png_ptr, png_inforp info_ptr,\n    png_fixed_point file_gamma)\n{\n   png_debug1(1, \"in %s storage function\", \"gAMA\");\n\n   if (png_ptr == NULL || info_ptr == NULL)\n      return;\n\n   png_colorspace_set_gamma(png_ptr, &info_ptr->colorspace, file_gamma);\n   png_colorspace_sync_info(png_ptr, info_ptr);\n}\n\n#  ifdef PNG_FLOATING_POINT_SUPPORTED\nvoid PNGAPI\npng_set_gAMA(png_const_structrp png_ptr, png_inforp info_ptr, double file_gamma)\n{\n   png_set_gAMA_fixed(png_ptr, info_ptr, png_fixed(png_ptr, file_gamma,\n       \"png_set_gAMA\"));\n}\n#  endif\n#endif\n\n#ifdef PNG_hIST_SUPPORTED\nvoid PNGAPI\npng_set_hIST(png_const_structrp png_ptr, png_inforp info_ptr,\n    png_const_uint_16p hist)\n{\n   int i;\n\n   png_debug1(1, \"in %s storage function\", \"hIST\");\n\n   if (png_ptr == NULL || info_ptr == NULL)\n      return;\n\n   if (info_ptr->num_palette == 0 || info_ptr->num_palette\n       > PNG_MAX_PALETTE_LENGTH)\n   {\n      png_warning(png_ptr,\n          \"Invalid palette size, hIST allocation skipped\");\n\n      return;\n   }\n\n   png_free_data(png_ptr, info_ptr, PNG_FREE_HIST, 0);\n\n   /* Changed from info->num_palette to PNG_MAX_PALETTE_LENGTH in\n    * version 1.2.1\n    */\n   info_ptr->hist = png_voidcast(png_uint_16p, png_malloc_warn(png_ptr,\n       PNG_MAX_PALETTE_LENGTH * (sizeof (png_uint_16))));\n\n   if (info_ptr->hist == NULL)\n   {\n      png_warning(png_ptr, \"Insufficient memory for hIST chunk data\");\n      return;\n   }\n\n   info_ptr->free_me |= PNG_FREE_HIST;\n\n   for (i = 0; i < info_ptr->num_palette; i++)\n      info_ptr->hist[i] = hist[i];\n\n   info_ptr->valid |= PNG_INFO_hIST;\n}\n#endif\n\nvoid PNGAPI\npng_set_IHDR(png_const_structrp png_ptr, png_inforp info_ptr,\n    png_uint_32 width, png_uint_32 height, int bit_depth,\n    int color_type, int interlace_type, int compression_type,\n    int filter_type)\n{\n   png_debug1(1, \"in %s storage function\", \"IHDR\");\n\n   if (png_ptr == NULL || info_ptr == NULL)\n      return;\n\n   info_ptr->width = width;\n   info_ptr->height = height;\n   info_ptr->bit_depth = (png_byte)bit_depth;\n   info_ptr->color_type = (png_byte)color_type;\n   info_ptr->compression_type = (png_byte)compression_type;\n   info_ptr->filter_type = (png_byte)filter_type;\n   info_ptr->interlace_type = (png_byte)interlace_type;\n\n   png_check_IHDR (png_ptr, info_ptr->width, info_ptr->height,\n       info_ptr->bit_depth, info_ptr->color_type, info_ptr->interlace_type,\n       info_ptr->compression_type, info_ptr->filter_type);\n\n   if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)\n      info_ptr->channels = 1;\n\n   else if (info_ptr->color_type & PNG_COLOR_MASK_COLOR)\n      info_ptr->channels = 3;\n\n   else\n      info_ptr->channels = 1;\n\n   if (info_ptr->color_type & PNG_COLOR_MASK_ALPHA)\n      info_ptr->channels++;\n\n   info_ptr->pixel_depth = (png_byte)(info_ptr->channels * info_ptr->bit_depth);\n\n   info_ptr->rowbytes = PNG_ROWBYTES(info_ptr->pixel_depth, width);\n}\n\n#ifdef PNG_oFFs_SUPPORTED\nvoid PNGAPI\npng_set_oFFs(png_const_structrp png_ptr, png_inforp info_ptr,\n    png_int_32 offset_x, png_int_32 offset_y, int unit_type)\n{\n   png_debug1(1, \"in %s storage function\", \"oFFs\");\n\n   if (png_ptr == NULL || info_ptr == NULL)\n      return;\n\n   info_ptr->x_offset = offset_x;\n   info_ptr->y_offset = offset_y;\n   info_ptr->offset_unit_type = (png_byte)unit_type;\n   info_ptr->valid |= PNG_INFO_oFFs;\n}\n#endif\n\n#ifdef PNG_pCAL_SUPPORTED\nvoid PNGAPI\npng_set_pCAL(png_const_structrp png_ptr, png_inforp info_ptr,\n    png_const_charp purpose, png_int_32 X0, png_int_32 X1, int type,\n    int nparams, png_const_charp units, png_charpp params)\n{\n   png_size_t length;\n   int i;\n\n   png_debug1(1, \"in %s storage function\", \"pCAL\");\n\n   if (png_ptr == NULL || info_ptr == NULL || purpose == NULL || units == NULL\n      || (nparams > 0 && params == NULL))\n      return;\n\n   length = strlen(purpose) + 1;\n   png_debug1(3, \"allocating purpose for info (%lu bytes)\",\n       (unsigned long)length);\n\n   /* TODO: validate format of calibration name and unit name */\n\n   /* Check that the type matches the specification. */\n   if (type < 0 || type > 3)\n      png_error(png_ptr, \"Invalid pCAL equation type\");\n\n   if (nparams < 0 || nparams > 255)\n      png_error(png_ptr, \"Invalid pCAL parameter count\");\n\n   /* Validate params[nparams] */\n   for (i=0; i<nparams; ++i)\n      if (params[i] == NULL ||\n         !png_check_fp_string(params[i], strlen(params[i])))\n         png_error(png_ptr, \"Invalid format for pCAL parameter\");\n\n   info_ptr->pcal_purpose = png_voidcast(png_charp,\n      png_malloc_warn(png_ptr, length));\n\n   if (info_ptr->pcal_purpose == NULL)\n   {\n      png_warning(png_ptr, \"Insufficient memory for pCAL purpose\");\n      return;\n   }\n\n   memcpy(info_ptr->pcal_purpose, purpose, length);\n\n   png_debug(3, \"storing X0, X1, type, and nparams in info\");\n   info_ptr->pcal_X0 = X0;\n   info_ptr->pcal_X1 = X1;\n   info_ptr->pcal_type = (png_byte)type;\n   info_ptr->pcal_nparams = (png_byte)nparams;\n\n   length = strlen(units) + 1;\n   png_debug1(3, \"allocating units for info (%lu bytes)\",\n     (unsigned long)length);\n\n   info_ptr->pcal_units = png_voidcast(png_charp,\n      png_malloc_warn(png_ptr, length));\n\n   if (info_ptr->pcal_units == NULL)\n   {\n      png_warning(png_ptr, \"Insufficient memory for pCAL units\");\n      return;\n   }\n\n   memcpy(info_ptr->pcal_units, units, length);\n\n   info_ptr->pcal_params = png_voidcast(png_charpp, png_malloc_warn(png_ptr,\n       (png_size_t)((nparams + 1) * (sizeof (png_charp)))));\n\n   if (info_ptr->pcal_params == NULL)\n   {\n      png_warning(png_ptr, \"Insufficient memory for pCAL params\");\n      return;\n   }\n\n   memset(info_ptr->pcal_params, 0, (nparams + 1) * (sizeof (png_charp)));\n\n   for (i = 0; i < nparams; i++)\n   {\n      length = strlen(params[i]) + 1;\n      png_debug2(3, \"allocating parameter %d for info (%lu bytes)\", i,\n          (unsigned long)length);\n\n      info_ptr->pcal_params[i] = (png_charp)png_malloc_warn(png_ptr, length);\n\n      if (info_ptr->pcal_params[i] == NULL)\n      {\n         png_warning(png_ptr, \"Insufficient memory for pCAL parameter\");\n         return;\n      }\n\n      memcpy(info_ptr->pcal_params[i], params[i], length);\n   }\n\n   info_ptr->valid |= PNG_INFO_pCAL;\n   info_ptr->free_me |= PNG_FREE_PCAL;\n}\n#endif\n\n#ifdef PNG_sCAL_SUPPORTED\nvoid PNGAPI\npng_set_sCAL_s(png_const_structrp png_ptr, png_inforp info_ptr,\n    int unit, png_const_charp swidth, png_const_charp sheight)\n{\n   png_size_t lengthw = 0, lengthh = 0;\n\n   png_debug1(1, \"in %s storage function\", \"sCAL\");\n\n   if (png_ptr == NULL || info_ptr == NULL)\n      return;\n\n   /* Double check the unit (should never get here with an invalid\n    * unit unless this is an API call.)\n    */\n   if (unit != 1 && unit != 2)\n      png_error(png_ptr, \"Invalid sCAL unit\");\n\n   if (swidth == NULL || (lengthw = strlen(swidth)) == 0 ||\n       swidth[0] == 45 /* '-' */ || !png_check_fp_string(swidth, lengthw))\n      png_error(png_ptr, \"Invalid sCAL width\");\n\n   if (sheight == NULL || (lengthh = strlen(sheight)) == 0 ||\n       sheight[0] == 45 /* '-' */ || !png_check_fp_string(sheight, lengthh))\n      png_error(png_ptr, \"Invalid sCAL height\");\n\n   info_ptr->scal_unit = (png_byte)unit;\n\n   ++lengthw;\n\n   png_debug1(3, \"allocating unit for info (%u bytes)\", (unsigned int)lengthw);\n\n   info_ptr->scal_s_width = png_voidcast(png_charp,\n      png_malloc_warn(png_ptr, lengthw));\n\n   if (info_ptr->scal_s_width == NULL)\n   {\n      png_warning(png_ptr, \"Memory allocation failed while processing sCAL\");\n      return;\n   }\n\n   memcpy(info_ptr->scal_s_width, swidth, lengthw);\n\n   ++lengthh;\n\n   png_debug1(3, \"allocating unit for info (%u bytes)\", (unsigned int)lengthh);\n\n   info_ptr->scal_s_height = png_voidcast(png_charp,\n      png_malloc_warn(png_ptr, lengthh));\n\n   if (info_ptr->scal_s_height == NULL)\n   {\n      png_free (png_ptr, info_ptr->scal_s_width);\n      info_ptr->scal_s_width = NULL;\n\n      png_warning(png_ptr, \"Memory allocation failed while processing sCAL\");\n      return;\n   }\n\n   memcpy(info_ptr->scal_s_height, sheight, lengthh);\n\n   info_ptr->valid |= PNG_INFO_sCAL;\n   info_ptr->free_me |= PNG_FREE_SCAL;\n}\n\n#  ifdef PNG_FLOATING_POINT_SUPPORTED\nvoid PNGAPI\npng_set_sCAL(png_const_structrp png_ptr, png_inforp info_ptr, int unit,\n    double width, double height)\n{\n   png_debug1(1, \"in %s storage function\", \"sCAL\");\n\n   /* Check the arguments. */\n   if (width <= 0)\n      png_warning(png_ptr, \"Invalid sCAL width ignored\");\n\n   else if (height <= 0)\n      png_warning(png_ptr, \"Invalid sCAL height ignored\");\n\n   else\n   {\n      /* Convert 'width' and 'height' to ASCII. */\n      char swidth[PNG_sCAL_MAX_DIGITS+1];\n      char sheight[PNG_sCAL_MAX_DIGITS+1];\n\n      png_ascii_from_fp(png_ptr, swidth, (sizeof swidth), width,\n         PNG_sCAL_PRECISION);\n      png_ascii_from_fp(png_ptr, sheight, (sizeof sheight), height,\n         PNG_sCAL_PRECISION);\n\n      png_set_sCAL_s(png_ptr, info_ptr, unit, swidth, sheight);\n   }\n}\n#  endif\n\n#  ifdef PNG_FIXED_POINT_SUPPORTED\nvoid PNGAPI\npng_set_sCAL_fixed(png_const_structrp png_ptr, png_inforp info_ptr, int unit,\n    png_fixed_point width, png_fixed_point height)\n{\n   png_debug1(1, \"in %s storage function\", \"sCAL\");\n\n   /* Check the arguments. */\n   if (width <= 0)\n      png_warning(png_ptr, \"Invalid sCAL width ignored\");\n\n   else if (height <= 0)\n      png_warning(png_ptr, \"Invalid sCAL height ignored\");\n\n   else\n   {\n      /* Convert 'width' and 'height' to ASCII. */\n      char swidth[PNG_sCAL_MAX_DIGITS+1];\n      char sheight[PNG_sCAL_MAX_DIGITS+1];\n\n      png_ascii_from_fixed(png_ptr, swidth, (sizeof swidth), width);\n      png_ascii_from_fixed(png_ptr, sheight, (sizeof sheight), height);\n\n      png_set_sCAL_s(png_ptr, info_ptr, unit, swidth, sheight);\n   }\n}\n#  endif\n#endif\n\n#ifdef PNG_pHYs_SUPPORTED\nvoid PNGAPI\npng_set_pHYs(png_const_structrp png_ptr, png_inforp info_ptr,\n    png_uint_32 res_x, png_uint_32 res_y, int unit_type)\n{\n   png_debug1(1, \"in %s storage function\", \"pHYs\");\n\n   if (png_ptr == NULL || info_ptr == NULL)\n      return;\n\n   info_ptr->x_pixels_per_unit = res_x;\n   info_ptr->y_pixels_per_unit = res_y;\n   info_ptr->phys_unit_type = (png_byte)unit_type;\n   info_ptr->valid |= PNG_INFO_pHYs;\n}\n#endif\n\nvoid PNGAPI\npng_set_PLTE(png_structrp png_ptr, png_inforp info_ptr,\n    png_const_colorp palette, int num_palette)\n{\n\n   png_debug1(1, \"in %s storage function\", \"PLTE\");\n\n   if (png_ptr == NULL || info_ptr == NULL)\n      return;\n\n   if (num_palette < 0 || num_palette > PNG_MAX_PALETTE_LENGTH)\n   {\n      if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)\n         png_error(png_ptr, \"Invalid palette length\");\n\n      else\n      {\n         png_warning(png_ptr, \"Invalid palette length\");\n         return;\n      }\n   }\n\n   if ((num_palette > 0 && palette == NULL) ||\n      (num_palette == 0\n#        ifdef PNG_MNG_FEATURES_SUPPORTED\n            && (png_ptr->mng_features_permitted & PNG_FLAG_MNG_EMPTY_PLTE) == 0\n#        endif\n      ))\n   {\n      png_error(png_ptr, \"Invalid palette\");\n      return;\n   }\n\n   /* It may not actually be necessary to set png_ptr->palette here;\n    * we do it for backward compatibility with the way the png_handle_tRNS\n    * function used to do the allocation.\n    *\n    * 1.6.0: the above statement appears to be incorrect; something has to set\n    * the palette inside png_struct on read.\n    */\n   png_free_data(png_ptr, info_ptr, PNG_FREE_PLTE, 0);\n\n   /* Changed in libpng-1.2.1 to allocate PNG_MAX_PALETTE_LENGTH instead\n    * of num_palette entries, in case of an invalid PNG file that has\n    * too-large sample values.\n    */\n   png_ptr->palette = png_voidcast(png_colorp, png_calloc(png_ptr,\n       PNG_MAX_PALETTE_LENGTH * (sizeof (png_color))));\n\n   if (num_palette > 0)\n      memcpy(png_ptr->palette, palette, num_palette * (sizeof (png_color)));\n   info_ptr->palette = png_ptr->palette;\n   info_ptr->num_palette = png_ptr->num_palette = (png_uint_16)num_palette;\n\n   info_ptr->free_me |= PNG_FREE_PLTE;\n\n   info_ptr->valid |= PNG_INFO_PLTE;\n}\n\n#ifdef PNG_sBIT_SUPPORTED\nvoid PNGAPI\npng_set_sBIT(png_const_structrp png_ptr, png_inforp info_ptr,\n    png_const_color_8p sig_bit)\n{\n   png_debug1(1, \"in %s storage function\", \"sBIT\");\n\n   if (png_ptr == NULL || info_ptr == NULL || sig_bit == NULL)\n      return;\n\n   info_ptr->sig_bit = *sig_bit;\n   info_ptr->valid |= PNG_INFO_sBIT;\n}\n#endif\n\n#ifdef PNG_sRGB_SUPPORTED\nvoid PNGAPI\npng_set_sRGB(png_const_structrp png_ptr, png_inforp info_ptr, int srgb_intent)\n{\n   png_debug1(1, \"in %s storage function\", \"sRGB\");\n\n   if (png_ptr == NULL || info_ptr == NULL)\n      return;\n\n   (void)png_colorspace_set_sRGB(png_ptr, &info_ptr->colorspace, srgb_intent);\n   png_colorspace_sync_info(png_ptr, info_ptr);\n}\n\nvoid PNGAPI\npng_set_sRGB_gAMA_and_cHRM(png_const_structrp png_ptr, png_inforp info_ptr,\n    int srgb_intent)\n{\n   png_debug1(1, \"in %s storage function\", \"sRGB_gAMA_and_cHRM\");\n\n   if (png_ptr == NULL || info_ptr == NULL)\n      return;\n\n   if (png_colorspace_set_sRGB(png_ptr, &info_ptr->colorspace, srgb_intent))\n   {\n      /* This causes the gAMA and cHRM to be written too */\n      info_ptr->colorspace.flags |=\n         PNG_COLORSPACE_FROM_gAMA|PNG_COLORSPACE_FROM_cHRM;\n   }\n\n   png_colorspace_sync_info(png_ptr, info_ptr);\n}\n#endif /* sRGB */\n\n\n#ifdef PNG_iCCP_SUPPORTED\nvoid PNGAPI\npng_set_iCCP(png_const_structrp png_ptr, png_inforp info_ptr,\n    png_const_charp name, int compression_type,\n    png_const_bytep profile, png_uint_32 proflen)\n{\n   png_charp new_iccp_name;\n   png_bytep new_iccp_profile;\n   png_size_t length;\n\n   png_debug1(1, \"in %s storage function\", \"iCCP\");\n\n   if (png_ptr == NULL || info_ptr == NULL || name == NULL || profile == NULL)\n      return;\n\n   if (compression_type != PNG_COMPRESSION_TYPE_BASE)\n      png_app_error(png_ptr, \"Invalid iCCP compression method\");\n\n   /* Set the colorspace first because this validates the profile; do not\n    * override previously set app cHRM or gAMA here (because likely as not the\n    * application knows better than libpng what the correct values are.)  Pass\n    * the info_ptr color_type field to png_colorspace_set_ICC because in the\n    * write case it has not yet been stored in png_ptr.\n    */\n   {\n      int result = png_colorspace_set_ICC(png_ptr, &info_ptr->colorspace, name,\n         proflen, profile, info_ptr->color_type);\n\n      png_colorspace_sync_info(png_ptr, info_ptr);\n\n      /* Don't do any of the copying if the profile was bad, or inconsistent. */\n      if (!result)\n         return;\n\n      /* But do write the gAMA and cHRM chunks from the profile. */\n      info_ptr->colorspace.flags |=\n         PNG_COLORSPACE_FROM_gAMA|PNG_COLORSPACE_FROM_cHRM;\n   }\n\n   length = strlen(name)+1;\n   new_iccp_name = png_voidcast(png_charp, png_malloc_warn(png_ptr, length));\n\n   if (new_iccp_name == NULL)\n   {\n      png_benign_error(png_ptr, \"Insufficient memory to process iCCP chunk\");\n      return;\n   }\n\n   memcpy(new_iccp_name, name, length);\n   new_iccp_profile = png_voidcast(png_bytep,\n      png_malloc_warn(png_ptr, proflen));\n\n   if (new_iccp_profile == NULL)\n   {\n      png_free(png_ptr, new_iccp_name);\n      png_benign_error(png_ptr,\n          \"Insufficient memory to process iCCP profile\");\n      return;\n   }\n\n   memcpy(new_iccp_profile, profile, proflen);\n\n   png_free_data(png_ptr, info_ptr, PNG_FREE_ICCP, 0);\n\n   info_ptr->iccp_proflen = proflen;\n   info_ptr->iccp_name = new_iccp_name;\n   info_ptr->iccp_profile = new_iccp_profile;\n   info_ptr->free_me |= PNG_FREE_ICCP;\n   info_ptr->valid |= PNG_INFO_iCCP;\n}\n#endif\n\n#ifdef PNG_TEXT_SUPPORTED\nvoid PNGAPI\npng_set_text(png_const_structrp png_ptr, png_inforp info_ptr,\n    png_const_textp text_ptr, int num_text)\n{\n   int ret;\n   ret = png_set_text_2(png_ptr, info_ptr, text_ptr, num_text);\n\n   if (ret)\n      png_error(png_ptr, \"Insufficient memory to store text\");\n}\n\nint /* PRIVATE */\npng_set_text_2(png_const_structrp png_ptr, png_inforp info_ptr,\n    png_const_textp text_ptr, int num_text)\n{\n   int i;\n\n   png_debug1(1, \"in %lx storage function\", png_ptr == NULL ? \"unexpected\" :\n      (unsigned long)png_ptr->chunk_name);\n\n   if (png_ptr == NULL || info_ptr == NULL || num_text <= 0 || text_ptr == NULL)\n      return(0);\n\n   /* Make sure we have enough space in the \"text\" array in info_struct\n    * to hold all of the incoming text_ptr objects.  This compare can't overflow\n    * because max_text >= num_text (anyway, subtract of two positive integers\n    * can't overflow in any case.)\n    */\n   if (num_text > info_ptr->max_text - info_ptr->num_text)\n   {\n      int old_num_text = info_ptr->num_text;\n      int max_text;\n      png_textp new_text = NULL;\n\n      /* Calculate an appropriate max_text, checking for overflow. */\n      max_text = old_num_text;\n      if (num_text <= INT_MAX - max_text)\n      {\n         max_text += num_text;\n\n         /* Round up to a multiple of 8 */\n         if (max_text < INT_MAX-8)\n            max_text = (max_text + 8) & ~0x7;\n\n         else\n            max_text = INT_MAX;\n\n         /* Now allocate a new array and copy the old members in, this does all\n          * the overflow checks.\n          */\n         new_text = png_voidcast(png_textp,png_realloc_array(png_ptr,\n            info_ptr->text, old_num_text, max_text-old_num_text,\n            sizeof *new_text));\n      }\n\n      if (new_text == NULL)\n      {\n         png_chunk_report(png_ptr, \"too many text chunks\",\n            PNG_CHUNK_WRITE_ERROR);\n         return 1;\n      }\n\n      png_free(png_ptr, info_ptr->text);\n\n      info_ptr->text = new_text;\n      info_ptr->free_me |= PNG_FREE_TEXT;\n      info_ptr->max_text = max_text;\n      /* num_text is adjusted below as the entries are copied in */\n\n      png_debug1(3, \"allocated %d entries for info_ptr->text\", max_text);\n   }\n\n   for (i = 0; i < num_text; i++)\n   {\n      size_t text_length, key_len;\n      size_t lang_len, lang_key_len;\n      png_textp textp = &(info_ptr->text[info_ptr->num_text]);\n\n      if (text_ptr[i].key == NULL)\n          continue;\n\n      if (text_ptr[i].compression < PNG_TEXT_COMPRESSION_NONE ||\n          text_ptr[i].compression >= PNG_TEXT_COMPRESSION_LAST)\n      {\n         png_chunk_report(png_ptr, \"text compression mode is out of range\",\n            PNG_CHUNK_WRITE_ERROR);\n         continue;\n      }\n\n      key_len = strlen(text_ptr[i].key);\n\n      if (text_ptr[i].compression <= 0)\n      {\n         lang_len = 0;\n         lang_key_len = 0;\n      }\n\n      else\n#  ifdef PNG_iTXt_SUPPORTED\n      {\n         /* Set iTXt data */\n\n         if (text_ptr[i].lang != NULL)\n            lang_len = strlen(text_ptr[i].lang);\n\n         else\n            lang_len = 0;\n\n         if (text_ptr[i].lang_key != NULL)\n            lang_key_len = strlen(text_ptr[i].lang_key);\n\n         else\n            lang_key_len = 0;\n      }\n#  else /* PNG_iTXt_SUPPORTED */\n      {\n         png_chunk_report(png_ptr, \"iTXt chunk not supported\",\n            PNG_CHUNK_WRITE_ERROR);\n         continue;\n      }\n#  endif\n\n      if (text_ptr[i].text == NULL || text_ptr[i].text[0] == '\\0')\n      {\n         text_length = 0;\n#  ifdef PNG_iTXt_SUPPORTED\n         if (text_ptr[i].compression > 0)\n            textp->compression = PNG_ITXT_COMPRESSION_NONE;\n\n         else\n#  endif\n            textp->compression = PNG_TEXT_COMPRESSION_NONE;\n      }\n\n      else\n      {\n         text_length = strlen(text_ptr[i].text);\n         textp->compression = text_ptr[i].compression;\n      }\n\n      textp->key = png_voidcast(png_charp,png_malloc_base(png_ptr,\n          key_len + text_length + lang_len + lang_key_len + 4));\n\n      if (textp->key == NULL)\n      {\n         png_chunk_report(png_ptr, \"text chunk: out of memory\",\n               PNG_CHUNK_WRITE_ERROR);\n         return 1;\n      }\n\n      png_debug2(2, \"Allocated %lu bytes at %p in png_set_text\",\n          (unsigned long)(png_uint_32)\n          (key_len + lang_len + lang_key_len + text_length + 4),\n          textp->key);\n\n      memcpy(textp->key, text_ptr[i].key, key_len);\n      *(textp->key + key_len) = '\\0';\n\n      if (text_ptr[i].compression > 0)\n      {\n         textp->lang = textp->key + key_len + 1;\n         memcpy(textp->lang, text_ptr[i].lang, lang_len);\n         *(textp->lang + lang_len) = '\\0';\n         textp->lang_key = textp->lang + lang_len + 1;\n         memcpy(textp->lang_key, text_ptr[i].lang_key, lang_key_len);\n         *(textp->lang_key + lang_key_len) = '\\0';\n         textp->text = textp->lang_key + lang_key_len + 1;\n      }\n\n      else\n      {\n         textp->lang=NULL;\n         textp->lang_key=NULL;\n         textp->text = textp->key + key_len + 1;\n      }\n\n      if (text_length)\n         memcpy(textp->text, text_ptr[i].text, text_length);\n\n      *(textp->text + text_length) = '\\0';\n\n#  ifdef PNG_iTXt_SUPPORTED\n      if (textp->compression > 0)\n      {\n         textp->text_length = 0;\n         textp->itxt_length = text_length;\n      }\n\n      else\n#  endif\n      {\n         textp->text_length = text_length;\n         textp->itxt_length = 0;\n      }\n\n      info_ptr->num_text++;\n      png_debug1(3, \"transferred text chunk %d\", info_ptr->num_text);\n   }\n\n   return(0);\n}\n#endif\n\n#ifdef PNG_tIME_SUPPORTED\nvoid PNGAPI\npng_set_tIME(png_const_structrp png_ptr, png_inforp info_ptr,\n    png_const_timep mod_time)\n{\n   png_debug1(1, \"in %s storage function\", \"tIME\");\n\n   if (png_ptr == NULL || info_ptr == NULL || mod_time == NULL ||\n       (png_ptr->mode & PNG_WROTE_tIME))\n      return;\n\n   if (mod_time->month == 0   || mod_time->month > 12  ||\n       mod_time->day   == 0   || mod_time->day   > 31  ||\n       mod_time->hour  > 23   || mod_time->minute > 59 ||\n       mod_time->second > 60)\n   {\n      png_warning(png_ptr, \"Ignoring invalid time value\");\n      return;\n   }\n\n   info_ptr->mod_time = *mod_time;\n   info_ptr->valid |= PNG_INFO_tIME;\n}\n#endif\n\n#ifdef PNG_tRNS_SUPPORTED\nvoid PNGAPI\npng_set_tRNS(png_structrp png_ptr, png_inforp info_ptr,\n    png_const_bytep trans_alpha, int num_trans, png_const_color_16p trans_color)\n{\n   png_debug1(1, \"in %s storage function\", \"tRNS\");\n\n   if (png_ptr == NULL || info_ptr == NULL)\n      return;\n\n   if (trans_alpha != NULL)\n   {\n       /* It may not actually be necessary to set png_ptr->trans_alpha here;\n        * we do it for backward compatibility with the way the png_handle_tRNS\n        * function used to do the allocation.\n        *\n        * 1.6.0: The above statement is incorrect; png_handle_tRNS effectively\n        * relies on png_set_tRNS storing the information in png_struct\n        * (otherwise it won't be there for the code in pngrtran.c).\n        */\n\n       png_free_data(png_ptr, info_ptr, PNG_FREE_TRNS, 0);\n\n       /* Changed from num_trans to PNG_MAX_PALETTE_LENGTH in version 1.2.1 */\n       png_ptr->trans_alpha = info_ptr->trans_alpha = png_voidcast(png_bytep,\n         png_malloc(png_ptr, PNG_MAX_PALETTE_LENGTH));\n\n       if (num_trans > 0 && num_trans <= PNG_MAX_PALETTE_LENGTH)\n          memcpy(info_ptr->trans_alpha, trans_alpha, (png_size_t)num_trans);\n   }\n\n   if (trans_color != NULL)\n   {\n      int sample_max = (1 << info_ptr->bit_depth);\n\n      if ((info_ptr->color_type == PNG_COLOR_TYPE_GRAY &&\n          trans_color->gray > sample_max) ||\n          (info_ptr->color_type == PNG_COLOR_TYPE_RGB &&\n          (trans_color->red > sample_max ||\n          trans_color->green > sample_max ||\n          trans_color->blue > sample_max)))\n         png_warning(png_ptr,\n            \"tRNS chunk has out-of-range samples for bit_depth\");\n\n      info_ptr->trans_color = *trans_color;\n\n      if (num_trans == 0)\n         num_trans = 1;\n   }\n\n   info_ptr->num_trans = (png_uint_16)num_trans;\n\n   if (num_trans != 0)\n   {\n      info_ptr->valid |= PNG_INFO_tRNS;\n      info_ptr->free_me |= PNG_FREE_TRNS;\n   }\n}\n#endif\n\n#ifdef PNG_sPLT_SUPPORTED\nvoid PNGAPI\npng_set_sPLT(png_const_structrp png_ptr,\n    png_inforp info_ptr, png_const_sPLT_tp entries, int nentries)\n/*\n *  entries        - array of png_sPLT_t structures\n *                   to be added to the list of palettes\n *                   in the info structure.\n *\n *  nentries       - number of palette structures to be\n *                   added.\n */\n{\n   png_sPLT_tp np;\n\n   if (png_ptr == NULL || info_ptr == NULL || nentries <= 0 || entries == NULL)\n      return;\n\n   /* Use the internal realloc function, which checks for all the possible\n    * overflows.  Notice that the parameters are (int) and (size_t)\n    */\n   np = png_voidcast(png_sPLT_tp,png_realloc_array(png_ptr,\n      info_ptr->splt_palettes, info_ptr->splt_palettes_num, nentries,\n      sizeof *np));\n\n   if (np == NULL)\n   {\n      /* Out of memory or too many chunks */\n      png_chunk_report(png_ptr, \"too many sPLT chunks\", PNG_CHUNK_WRITE_ERROR);\n      return;\n   }\n\n   png_free(png_ptr, info_ptr->splt_palettes);\n   info_ptr->splt_palettes = np;\n   info_ptr->free_me |= PNG_FREE_SPLT;\n\n   np += info_ptr->splt_palettes_num;\n\n   do\n   {\n      png_size_t length;\n\n      /* Skip invalid input entries */\n      if (entries->name == NULL || entries->entries == NULL)\n      {\n         /* png_handle_sPLT doesn't do this, so this is an app error */\n         png_app_error(png_ptr, \"png_set_sPLT: invalid sPLT\");\n         /* Just skip the invalid entry */\n         continue;\n      }\n\n      np->depth = entries->depth;\n\n      /* In the even of out-of-memory just return - there's no point keeping on\n       * trying to add sPLT chunks.\n       */\n      length = strlen(entries->name) + 1;\n      np->name = png_voidcast(png_charp, png_malloc_base(png_ptr, length));\n\n      if (np->name == NULL)\n         break;\n\n      memcpy(np->name, entries->name, length);\n\n      /* IMPORTANT: we have memory now that won't get freed if something else\n       * goes wrong, this code must free it.  png_malloc_array produces no\n       * warnings, use a png_chunk_report (below) if there is an error.\n       */\n      np->entries = png_voidcast(png_sPLT_entryp, png_malloc_array(png_ptr,\n          entries->nentries, sizeof (png_sPLT_entry)));\n\n      if (np->entries == NULL)\n      {\n         png_free(png_ptr, np->name);\n         break;\n      }\n\n      np->nentries = entries->nentries;\n      /* This multiply can't overflow because png_malloc_array has already\n       * checked it when doing the allocation.\n       */\n      memcpy(np->entries, entries->entries,\n         entries->nentries * sizeof (png_sPLT_entry));\n\n      /* Note that 'continue' skips the advance of the out pointer and out\n       * count, so an invalid entry is not added.\n       */\n      info_ptr->valid |= PNG_INFO_sPLT;\n      ++(info_ptr->splt_palettes_num);\n      ++np;\n   }\n   while (++entries, --nentries);\n\n   if (nentries > 0)\n      png_chunk_report(png_ptr, \"sPLT out of memory\", PNG_CHUNK_WRITE_ERROR);\n}\n#endif /* PNG_sPLT_SUPPORTED */\n\n#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED\nstatic png_byte\ncheck_location(png_const_structrp png_ptr, int location)\n{\n   location &= (PNG_HAVE_IHDR|PNG_HAVE_PLTE|PNG_AFTER_IDAT);\n\n   /* New in 1.6.0; copy the location and check it.  This is an API\n    * change, previously the app had to use the\n    * png_set_unknown_chunk_location API below for each chunk.\n    */\n   if (location == 0 && !(png_ptr->mode & PNG_IS_READ_STRUCT))\n   {\n      /* Write struct, so unknown chunks come from the app */\n      png_app_warning(png_ptr,\n         \"png_set_unknown_chunks now expects a valid location\");\n      /* Use the old behavior */\n      location = (png_byte)(png_ptr->mode &\n         (PNG_HAVE_IHDR|PNG_HAVE_PLTE|PNG_AFTER_IDAT));\n   }\n\n   /* This need not be an internal error - if the app calls\n    * png_set_unknown_chunks on a read pointer it must get the location right.\n    */\n   if (location == 0)\n      png_error(png_ptr, \"invalid location in png_set_unknown_chunks\");\n\n   /* Now reduce the location to the top-most set bit by removing each least\n    * significant bit in turn.\n    */\n   while (location != (location & -location))\n      location &= ~(location & -location);\n\n   /* The cast is safe because 'location' is a bit mask and only the low four\n    * bits are significant.\n    */\n   return (png_byte)location;\n}\n\nvoid PNGAPI\npng_set_unknown_chunks(png_const_structrp png_ptr,\n   png_inforp info_ptr, png_const_unknown_chunkp unknowns, int num_unknowns)\n{\n   png_unknown_chunkp np;\n\n   if (png_ptr == NULL || info_ptr == NULL || num_unknowns <= 0 ||\n      unknowns == NULL)\n      return;\n\n   /* Check for the failure cases where support has been disabled at compile\n    * time.  This code is hardly ever compiled - it's here because\n    * STORE_UNKNOWN_CHUNKS is set by both read and write code (compiling in this\n    * code) but may be meaningless if the read or write handling of unknown\n    * chunks is not compiled in.\n    */\n#  if !defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) && \\\n      defined(PNG_READ_SUPPORTED)\n      if (png_ptr->mode & PNG_IS_READ_STRUCT)\n      {\n         png_app_error(png_ptr, \"no unknown chunk support on read\");\n         return;\n      }\n#  endif\n#  if !defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED) && \\\n      defined(PNG_WRITE_SUPPORTED)\n      if (!(png_ptr->mode & PNG_IS_READ_STRUCT))\n      {\n         png_app_error(png_ptr, \"no unknown chunk support on write\");\n         return;\n      }\n#  endif\n\n   /* Prior to 1.6.0 this code used png_malloc_warn; however, this meant that\n    * unknown critical chunks could be lost with just a warning resulting in\n    * undefined behavior.  Now png_chunk_report is used to provide behavior\n    * appropriate to read or write.\n    */\n   np = png_voidcast(png_unknown_chunkp, png_realloc_array(png_ptr,\n         info_ptr->unknown_chunks, info_ptr->unknown_chunks_num, num_unknowns,\n         sizeof *np));\n\n   if (np == NULL)\n   {\n      png_chunk_report(png_ptr, \"too many unknown chunks\",\n         PNG_CHUNK_WRITE_ERROR);\n      return;\n   }\n\n   png_free(png_ptr, info_ptr->unknown_chunks);\n   info_ptr->unknown_chunks = np; /* safe because it is initialized */\n   info_ptr->free_me |= PNG_FREE_UNKN;\n\n   np += info_ptr->unknown_chunks_num;\n\n   /* Increment unknown_chunks_num each time round the loop to protect the\n    * just-allocated chunk data.\n    */\n   for (; num_unknowns > 0; --num_unknowns, ++unknowns)\n   {\n      memcpy(np->name, unknowns->name, (sizeof np->name));\n      np->name[(sizeof np->name)-1] = '\\0';\n      np->location = check_location(png_ptr, unknowns->location);\n\n      if (unknowns->size == 0)\n      {\n         np->data = NULL;\n         np->size = 0;\n      }\n\n      else\n      {\n         np->data = png_voidcast(png_bytep,\n            png_malloc_base(png_ptr, unknowns->size));\n\n         if (np->data == NULL)\n         {\n            png_chunk_report(png_ptr, \"unknown chunk: out of memory\",\n               PNG_CHUNK_WRITE_ERROR);\n            /* But just skip storing the unknown chunk */\n            continue;\n         }\n\n         memcpy(np->data, unknowns->data, unknowns->size);\n         np->size = unknowns->size;\n      }\n\n      /* These increments are skipped on out-of-memory for the data - the\n       * unknown chunk entry gets overwritten if the png_chunk_report returns.\n       * This is correct in the read case (the chunk is just dropped.)\n       */\n      ++np;\n      ++(info_ptr->unknown_chunks_num);\n   }\n}\n\nvoid PNGAPI\npng_set_unknown_chunk_location(png_const_structrp png_ptr, png_inforp info_ptr,\n    int chunk, int location)\n{\n   /* This API is pretty pointless in 1.6.0 because the location can be set\n    * before the call to png_set_unknown_chunks.\n    *\n    * TODO: add a png_app_warning in 1.7\n    */\n   if (png_ptr != NULL && info_ptr != NULL && chunk >= 0 &&\n      chunk < info_ptr->unknown_chunks_num)\n   {\n      if ((location & (PNG_HAVE_IHDR|PNG_HAVE_PLTE|PNG_AFTER_IDAT)) == 0)\n      {\n         png_app_error(png_ptr, \"invalid unknown chunk location\");\n         /* Fake out the pre 1.6.0 behavior: */\n         if ((location & PNG_HAVE_IDAT)) /* undocumented! */\n            location = PNG_AFTER_IDAT;\n\n         else\n            location = PNG_HAVE_IHDR; /* also undocumented */\n      }\n\n      info_ptr->unknown_chunks[chunk].location =\n         check_location(png_ptr, location);\n   }\n}\n#endif\n\n\n#ifdef PNG_MNG_FEATURES_SUPPORTED\npng_uint_32 PNGAPI\npng_permit_mng_features (png_structrp png_ptr, png_uint_32 mng_features)\n{\n   png_debug(1, \"in png_permit_mng_features\");\n\n   if (png_ptr == NULL)\n      return 0;\n\n   png_ptr->mng_features_permitted = mng_features & PNG_ALL_MNG_FEATURES;\n\n   return png_ptr->mng_features_permitted;\n}\n#endif\n\n#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED\nstatic unsigned int\nadd_one_chunk(png_bytep list, unsigned int count, png_const_bytep add, int keep)\n{\n   unsigned int i;\n\n   /* Utility function: update the 'keep' state of a chunk if it is already in\n    * the list, otherwise add it to the list.\n    */\n   for (i=0; i<count; ++i, list += 5) if (memcmp(list, add, 4) == 0)\n   {\n      list[4] = (png_byte)keep;\n      return count;\n   }\n\n   if (keep != PNG_HANDLE_CHUNK_AS_DEFAULT)\n   {\n      ++count;\n      memcpy(list, add, 4);\n      list[4] = (png_byte)keep;\n   }\n\n   return count;\n}\n\nvoid PNGAPI\npng_set_keep_unknown_chunks(png_structrp png_ptr, int keep,\n    png_const_bytep chunk_list, int num_chunks_in)\n{\n   png_bytep new_list;\n   unsigned int num_chunks, old_num_chunks;\n\n   if (png_ptr == NULL)\n      return;\n\n   if (keep < 0 || keep >= PNG_HANDLE_CHUNK_LAST)\n   {\n      png_app_error(png_ptr, \"png_set_keep_unknown_chunks: invalid keep\");\n      return;\n   }\n\n   if (num_chunks_in <= 0)\n   {\n      png_ptr->unknown_default = keep;\n\n      /* '0' means just set the flags, so stop here */\n      if (num_chunks_in == 0)\n        return;\n   }\n\n   if (num_chunks_in < 0)\n   {\n      /* Ignore all unknown chunks and all chunks recognized by\n       * libpng except for IHDR, PLTE, tRNS, IDAT, and IEND\n       */\n      static PNG_CONST png_byte chunks_to_ignore[] = {\n         98,  75,  71,  68, '\\0',  /* bKGD */\n         99,  72,  82,  77, '\\0',  /* cHRM */\n        103,  65,  77,  65, '\\0',  /* gAMA */\n        104,  73,  83,  84, '\\0',  /* hIST */\n        105,  67,  67,  80, '\\0',  /* iCCP */\n        105,  84,  88, 116, '\\0',  /* iTXt */\n        111,  70,  70, 115, '\\0',  /* oFFs */\n        112,  67,  65,  76, '\\0',  /* pCAL */\n        112,  72,  89, 115, '\\0',  /* pHYs */\n        115,  66,  73,  84, '\\0',  /* sBIT */\n        115,  67,  65,  76, '\\0',  /* sCAL */\n        115,  80,  76,  84, '\\0',  /* sPLT */\n        115,  84,  69,  82, '\\0',  /* sTER */\n        115,  82,  71,  66, '\\0',  /* sRGB */\n        116,  69,  88, 116, '\\0',  /* tEXt */\n        116,  73,  77,  69, '\\0',  /* tIME */\n        122,  84,  88, 116, '\\0'   /* zTXt */\n      };\n\n      chunk_list = chunks_to_ignore;\n      num_chunks = (sizeof chunks_to_ignore)/5;\n   }\n\n   else /* num_chunks_in > 0 */\n   {\n      if (chunk_list == NULL)\n      {\n         /* Prior to 1.6.0 this was silently ignored, now it is an app_error\n          * which can be switched off.\n          */\n         png_app_error(png_ptr, \"png_set_keep_unknown_chunks: no chunk list\");\n         return;\n      }\n\n      num_chunks = num_chunks_in;\n   }\n\n   old_num_chunks = png_ptr->num_chunk_list;\n   if (png_ptr->chunk_list == NULL)\n      old_num_chunks = 0;\n\n   /* Since num_chunks is always restricted to UINT_MAX/5 this can't overflow.\n    */\n   if (num_chunks + old_num_chunks > UINT_MAX/5)\n   {\n      png_app_error(png_ptr, \"png_set_keep_unknown_chunks: too many chunks\");\n      return;\n   }\n\n   /* If these chunks are being reset to the default then no more memory is\n    * required because add_one_chunk above doesn't extend the list if the 'keep'\n    * parameter is the default.\n    */\n   if (keep)\n   {\n      new_list = png_voidcast(png_bytep, png_malloc(png_ptr,\n          5 * (num_chunks + old_num_chunks)));\n\n      if (old_num_chunks > 0)\n         memcpy(new_list, png_ptr->chunk_list, 5*old_num_chunks);\n   }\n\n   else if (old_num_chunks > 0)\n      new_list = png_ptr->chunk_list;\n\n   else\n      new_list = NULL;\n\n   /* Add the new chunks together with each one's handling code.  If the chunk\n    * already exists the code is updated, otherwise the chunk is added to the\n    * end.  (In libpng 1.6.0 order no longer matters because this code enforces\n    * the earlier convention that the last setting is the one that is used.)\n    */\n   if (new_list != NULL)\n   {\n      png_const_bytep inlist;\n      png_bytep outlist;\n      unsigned int i;\n\n      for (i=0; i<num_chunks; ++i)\n         old_num_chunks = add_one_chunk(new_list, old_num_chunks,\n            chunk_list+5*i, keep);\n\n      /* Now remove any spurious 'default' entries. */\n      num_chunks = 0;\n      for (i=0, inlist=outlist=new_list; i<old_num_chunks; ++i, inlist += 5)\n         if (inlist[4])\n         {\n            if (outlist != inlist)\n               memcpy(outlist, inlist, 5);\n            outlist += 5;\n            ++num_chunks;\n         }\n\n      /* This means the application has removed all the specialized handling. */\n      if (num_chunks == 0)\n      {\n         if (png_ptr->chunk_list != new_list)\n            png_free(png_ptr, new_list);\n\n         new_list = NULL;\n      }\n   }\n\n   else\n      num_chunks = 0;\n\n   png_ptr->num_chunk_list = num_chunks;\n\n   if (png_ptr->chunk_list != new_list)\n   {\n      if (png_ptr->chunk_list != NULL)\n         png_free(png_ptr, png_ptr->chunk_list);\n\n      png_ptr->chunk_list = new_list;\n   }\n}\n#endif\n\n#ifdef PNG_READ_USER_CHUNKS_SUPPORTED\nvoid PNGAPI\npng_set_read_user_chunk_fn(png_structrp png_ptr, png_voidp user_chunk_ptr,\n    png_user_chunk_ptr read_user_chunk_fn)\n{\n   png_debug(1, \"in png_set_read_user_chunk_fn\");\n\n   if (png_ptr == NULL)\n      return;\n\n   png_ptr->read_user_chunk_fn = read_user_chunk_fn;\n   png_ptr->user_chunk_ptr = user_chunk_ptr;\n}\n#endif\n\n#ifdef PNG_INFO_IMAGE_SUPPORTED\nvoid PNGAPI\npng_set_rows(png_const_structrp png_ptr, png_inforp info_ptr,\n    png_bytepp row_pointers)\n{\n   png_debug1(1, \"in %s storage function\", \"rows\");\n\n   if (png_ptr == NULL || info_ptr == NULL)\n      return;\n\n   if (info_ptr->row_pointers && (info_ptr->row_pointers != row_pointers))\n      png_free_data(png_ptr, info_ptr, PNG_FREE_ROWS, 0);\n\n   info_ptr->row_pointers = row_pointers;\n\n   if (row_pointers)\n      info_ptr->valid |= PNG_INFO_IDAT;\n}\n#endif\n\nvoid PNGAPI\npng_set_compression_buffer_size(png_structrp png_ptr, png_size_t size)\n{\n    if (png_ptr == NULL)\n       return;\n\n    if (size == 0 || size > PNG_UINT_31_MAX)\n       png_error(png_ptr, \"invalid compression buffer size\");\n\n#  ifdef PNG_SEQUENTIAL_READ_SUPPORTED\n      if (png_ptr->mode & PNG_IS_READ_STRUCT)\n      {\n         png_ptr->IDAT_read_size = (png_uint_32)size; /* checked above */\n         return;\n      }\n#  endif\n\n#  ifdef PNG_WRITE_SUPPORTED\n      if (!(png_ptr->mode & PNG_IS_READ_STRUCT))\n      {\n         if (png_ptr->zowner != 0)\n         {\n            png_warning(png_ptr,\n              \"Compression buffer size cannot be changed because it is in use\");\n            return;\n         }\n\n         if (size > ZLIB_IO_MAX)\n         {\n            png_warning(png_ptr,\n               \"Compression buffer size limited to system maximum\");\n            size = ZLIB_IO_MAX; /* must fit */\n         }\n\n         else if (size < 6)\n         {\n            /* Deflate will potentially go into an infinite loop on a SYNC_FLUSH\n             * if this is permitted.\n             */\n            png_warning(png_ptr,\n               \"Compression buffer size cannot be reduced below 6\");\n            return;\n         }\n\n         if (png_ptr->zbuffer_size != size)\n         {\n            png_free_buffer_list(png_ptr, &png_ptr->zbuffer_list);\n            png_ptr->zbuffer_size = (uInt)size;\n         }\n      }\n#  endif\n}\n\nvoid PNGAPI\npng_set_invalid(png_const_structrp png_ptr, png_inforp info_ptr, int mask)\n{\n   if (png_ptr && info_ptr)\n      info_ptr->valid &= ~mask;\n}\n\n\n#ifdef PNG_SET_USER_LIMITS_SUPPORTED\n/* This function was added to libpng 1.2.6 */\nvoid PNGAPI\npng_set_user_limits (png_structrp png_ptr, png_uint_32 user_width_max,\n    png_uint_32 user_height_max)\n{\n   /* Images with dimensions larger than these limits will be\n    * rejected by png_set_IHDR().  To accept any PNG datastream\n    * regardless of dimensions, set both limits to 0x7ffffffL.\n    */\n   if (png_ptr == NULL)\n      return;\n\n   png_ptr->user_width_max = user_width_max;\n   png_ptr->user_height_max = user_height_max;\n}\n\n/* This function was added to libpng 1.4.0 */\nvoid PNGAPI\npng_set_chunk_cache_max (png_structrp png_ptr, png_uint_32 user_chunk_cache_max)\n{\n    if (png_ptr)\n       png_ptr->user_chunk_cache_max = user_chunk_cache_max;\n}\n\n/* This function was added to libpng 1.4.1 */\nvoid PNGAPI\npng_set_chunk_malloc_max (png_structrp png_ptr,\n    png_alloc_size_t user_chunk_malloc_max)\n{\n   if (png_ptr)\n      png_ptr->user_chunk_malloc_max = user_chunk_malloc_max;\n}\n#endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */\n\n\n#ifdef PNG_BENIGN_ERRORS_SUPPORTED\nvoid PNGAPI\npng_set_benign_errors(png_structrp png_ptr, int allowed)\n{\n   png_debug(1, \"in png_set_benign_errors\");\n\n   /* If allowed is 1, png_benign_error() is treated as a warning.\n    *\n    * If allowed is 0, png_benign_error() is treated as an error (which\n    * is the default behavior if png_set_benign_errors() is not called).\n    */\n\n   if (allowed)\n      png_ptr->flags |= PNG_FLAG_BENIGN_ERRORS_WARN |\n         PNG_FLAG_APP_WARNINGS_WARN | PNG_FLAG_APP_ERRORS_WARN;\n\n   else\n      png_ptr->flags &= ~(PNG_FLAG_BENIGN_ERRORS_WARN |\n         PNG_FLAG_APP_WARNINGS_WARN | PNG_FLAG_APP_ERRORS_WARN);\n}\n#endif /* PNG_BENIGN_ERRORS_SUPPORTED */\n\n#ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED\n   /* Whether to report invalid palette index; added at libng-1.5.10.\n    * It is possible for an indexed (color-type==3) PNG file to contain\n    * pixels with invalid (out-of-range) indexes if the PLTE chunk has\n    * fewer entries than the image's bit-depth would allow. We recover\n    * from this gracefully by filling any incomplete palette with zeroes\n    * (opaque black).  By default, when this occurs libpng will issue\n    * a benign error.  This API can be used to override that behavior.\n    */\nvoid PNGAPI\npng_set_check_for_invalid_index(png_structrp png_ptr, int allowed)\n{\n   png_debug(1, \"in png_set_check_for_invalid_index\");\n\n   if (allowed > 0)\n      png_ptr->num_palette_max = 0;\n\n   else\n      png_ptr->num_palette_max = -1;\n}\n#endif\n#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */\n"
  },
  {
    "path": "Projects/Libraries/CSBase/Source/png/pngstruct.h",
    "content": "\n/* pngstruct.h - header file for PNG reference library\n *\n * Copyright (c) 1998-2013 Glenn Randers-Pehrson\n * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)\n * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)\n *\n * Last changed in libpng 1.6.1 [March 28, 2013]\n *\n * This code is released under the libpng license.\n * For conditions of distribution and use, see the disclaimer\n * and license in png.h\n */\n\n/* The structure that holds the information to read and write PNG files.\n * The only people who need to care about what is inside of this are the\n * people who will be modifying the library for their own special needs.\n * It should NOT be accessed directly by an application.\n */\n\n#ifndef PNGSTRUCT_H\n#define PNGSTRUCT_H\n/* zlib.h defines the structure z_stream, an instance of which is included\n * in this structure and is required for decompressing the LZ compressed\n * data in PNG files.\n */\n#ifndef ZLIB_CONST\n   /* We must ensure that zlib uses 'const' in declarations. */\n#  define ZLIB_CONST\n#endif\n#include \"zlib.h\"\n#ifdef const\n   /* zlib.h sometimes #defines const to nothing, undo this. */\n#  undef const\n#endif\n\n/* zlib.h has mediocre z_const use before 1.2.6, this stuff is for compatibility\n * with older builds.\n */\n#if ZLIB_VERNUM < 0x1260\n#  define PNGZ_MSG_CAST(s) png_constcast(char*,s)\n#  define PNGZ_INPUT_CAST(b) png_constcast(png_bytep,b)\n#else\n#  define PNGZ_MSG_CAST(s) (s)\n#  define PNGZ_INPUT_CAST(b) (b)\n#endif\n\n/* zlib.h declares a magic type 'uInt' that limits the amount of data that zlib\n * can handle at once.  This type need be no larger than 16 bits (so maximum of\n * 65535), this define allows us to discover how big it is, but limited by the\n * maximuum for png_size_t.  The value can be overriden in a library build\n * (pngusr.h, or set it in CPPFLAGS) and it works to set it to a considerably\n * lower value (e.g. 255 works).  A lower value may help memory usage (slightly)\n * and may even improve performance on some systems (and degrade it on others.)\n */\n#ifndef ZLIB_IO_MAX\n#  define ZLIB_IO_MAX ((uInt)-1)\n#endif\n\n#ifdef PNG_WRITE_SUPPORTED\n/* The type of a compression buffer list used by the write code. */\ntypedef struct png_compression_buffer\n{\n   struct png_compression_buffer *next;\n   png_byte                       output[1]; /* actually zbuf_size */\n} png_compression_buffer, *png_compression_bufferp;\n\n#define PNG_COMPRESSION_BUFFER_SIZE(pp)\\\n   (offsetof(png_compression_buffer, output) + (pp)->zbuffer_size)\n#endif\n\n/* Colorspace support; structures used in png_struct, png_info and in internal\n * functions to hold and communicate information about the color space.\n *\n * PNG_COLORSPACE_SUPPORTED is only required if the application will perform\n * colorspace corrections, otherwise all the colorspace information can be\n * skipped and the size of libpng can be reduced (significantly) by compiling\n * out the colorspace support.\n */\n#ifdef PNG_COLORSPACE_SUPPORTED\n/* The chromaticities of the red, green and blue colorants and the chromaticity\n * of the corresponding white point (i.e. of rgb(1.0,1.0,1.0)).\n */\ntypedef struct png_xy\n{\n   png_fixed_point redx, redy;\n   png_fixed_point greenx, greeny;\n   png_fixed_point bluex, bluey;\n   png_fixed_point whitex, whitey;\n} png_xy;\n\n/* The same data as above but encoded as CIE XYZ values.  When this data comes\n * from chromaticities the sum of the Y values is assumed to be 1.0\n */\ntypedef struct png_XYZ\n{\n   png_fixed_point red_X, red_Y, red_Z;\n   png_fixed_point green_X, green_Y, green_Z;\n   png_fixed_point blue_X, blue_Y, blue_Z;\n} png_XYZ;\n#endif /* COLORSPACE */\n\n#if defined(PNG_COLORSPACE_SUPPORTED) || defined(PNG_GAMMA_SUPPORTED)\n/* A colorspace is all the above plus, potentially, profile information,\n * however at present libpng does not use the profile internally so it is only\n * stored in the png_info struct (if iCCP is supported.)  The rendering intent\n * is retained here and is checked.\n *\n * The file gamma encoding information is also stored here and gamma correction\n * is done by libpng, whereas color correction must currently be done by the\n * application.\n */\ntypedef struct png_colorspace\n{\n#ifdef PNG_GAMMA_SUPPORTED\n   png_fixed_point gamma;        /* File gamma */\n#endif\n\n#ifdef PNG_COLORSPACE_SUPPORTED\n   png_xy      end_points_xy;    /* End points as chromaticities */\n   png_XYZ     end_points_XYZ;   /* End points as CIE XYZ colorant values */\n   png_uint_16 rendering_intent; /* Rendering intent of a profile */\n#endif\n\n   /* Flags are always defined to simplify the code. */\n   png_uint_16 flags;            /* As defined below */\n} png_colorspace, * PNG_RESTRICT png_colorspacerp;\n\ntypedef const png_colorspace * PNG_RESTRICT png_const_colorspacerp;\n\n/* General flags for the 'flags' field */\n#define PNG_COLORSPACE_HAVE_GAMMA           0x0001\n#define PNG_COLORSPACE_HAVE_ENDPOINTS       0x0002\n#define PNG_COLORSPACE_HAVE_INTENT          0x0004\n#define PNG_COLORSPACE_FROM_gAMA            0x0008\n#define PNG_COLORSPACE_FROM_cHRM            0x0010\n#define PNG_COLORSPACE_FROM_sRGB            0x0020\n#define PNG_COLORSPACE_ENDPOINTS_MATCH_sRGB 0x0040\n#define PNG_COLORSPACE_MATCHES_sRGB         0x0080 /* exact match on profile */\n#define PNG_COLORSPACE_INVALID              0x8000\n#define PNG_COLORSPACE_CANCEL(flags)        (0xffff ^ (flags))\n#endif /* COLORSPACE || GAMMA */\n\nstruct png_struct_def\n{\n#ifdef PNG_SETJMP_SUPPORTED\n   jmp_buf jmp_buf_local;     /* New name in 1.6.0 for jmp_buf in png_struct */\n   png_longjmp_ptr longjmp_fn;/* setjmp non-local goto function. */\n   jmp_buf *jmp_buf_ptr;      /* passed to longjmp_fn */\n   size_t jmp_buf_size;       /* size of the above, if allocated */\n#endif\n   png_error_ptr error_fn;    /* function for printing errors and aborting */\n#ifdef PNG_WARNINGS_SUPPORTED\n   png_error_ptr warning_fn;  /* function for printing warnings */\n#endif\n   png_voidp error_ptr;       /* user supplied struct for error functions */\n   png_rw_ptr write_data_fn;  /* function for writing output data */\n   png_rw_ptr read_data_fn;   /* function for reading input data */\n   png_voidp io_ptr;          /* ptr to application struct for I/O functions */\n\n#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED\n   png_user_transform_ptr read_user_transform_fn; /* user read transform */\n#endif\n\n#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED\n   png_user_transform_ptr write_user_transform_fn; /* user write transform */\n#endif\n\n/* These were added in libpng-1.0.2 */\n#ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED\n#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \\\n    defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)\n   png_voidp user_transform_ptr; /* user supplied struct for user transform */\n   png_byte user_transform_depth;    /* bit depth of user transformed pixels */\n   png_byte user_transform_channels; /* channels in user transformed pixels */\n#endif\n#endif\n\n   png_uint_32 mode;          /* tells us where we are in the PNG file */\n   png_uint_32 flags;         /* flags indicating various things to libpng */\n   png_uint_32 transformations; /* which transformations to perform */\n\n   png_uint_32 zowner;        /* ID (chunk type) of zstream owner, 0 if none */\n   z_stream    zstream;       /* decompression structure */\n\n#ifdef PNG_WRITE_SUPPORTED\n   png_compression_bufferp zbuffer_list; /* Created on demand during write */\n   uInt                    zbuffer_size; /* size of the actual buffer */\n\n   int zlib_level;            /* holds zlib compression level */\n   int zlib_method;           /* holds zlib compression method */\n   int zlib_window_bits;      /* holds zlib compression window bits */\n   int zlib_mem_level;        /* holds zlib compression memory level */\n   int zlib_strategy;         /* holds zlib compression strategy */\n#endif\n/* Added at libpng 1.5.4 */\n#ifdef PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED\n   int zlib_text_level;            /* holds zlib compression level */\n   int zlib_text_method;           /* holds zlib compression method */\n   int zlib_text_window_bits;      /* holds zlib compression window bits */\n   int zlib_text_mem_level;        /* holds zlib compression memory level */\n   int zlib_text_strategy;         /* holds zlib compression strategy */\n#endif\n/* End of material added at libpng 1.5.4 */\n/* Added at libpng 1.6.0 */\n#ifdef PNG_WRITE_SUPPORTED\n   int zlib_set_level;        /* Actual values set into the zstream on write */\n   int zlib_set_method;\n   int zlib_set_window_bits;\n   int zlib_set_mem_level;\n   int zlib_set_strategy;\n#endif\n\n   png_uint_32 width;         /* width of image in pixels */\n   png_uint_32 height;        /* height of image in pixels */\n   png_uint_32 num_rows;      /* number of rows in current pass */\n   png_uint_32 usr_width;     /* width of row at start of write */\n   png_size_t rowbytes;       /* size of row in bytes */\n   png_uint_32 iwidth;        /* width of current interlaced row in pixels */\n   png_uint_32 row_number;    /* current row in interlace pass */\n   png_uint_32 chunk_name;    /* PNG_CHUNK() id of current chunk */\n   png_bytep prev_row;        /* buffer to save previous (unfiltered) row.\n                               * This is a pointer into big_prev_row\n                               */\n   png_bytep row_buf;         /* buffer to save current (unfiltered) row.\n                               * This is a pointer into big_row_buf\n                               */\n#ifdef PNG_WRITE_SUPPORTED\n   png_bytep sub_row;         /* buffer to save \"sub\" row when filtering */\n   png_bytep up_row;          /* buffer to save \"up\" row when filtering */\n   png_bytep avg_row;         /* buffer to save \"avg\" row when filtering */\n   png_bytep paeth_row;       /* buffer to save \"Paeth\" row when filtering */\n#endif\n   png_size_t info_rowbytes;  /* Added in 1.5.4: cache of updated row bytes */\n\n   png_uint_32 idat_size;     /* current IDAT size for read */\n   png_uint_32 crc;           /* current chunk CRC value */\n   png_colorp palette;        /* palette from the input file */\n   png_uint_16 num_palette;   /* number of color entries in palette */\n\n/* Added at libpng-1.5.10 */\n#ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED\n   int num_palette_max;       /* maximum palette index found in IDAT */\n#endif\n\n   png_uint_16 num_trans;     /* number of transparency values */\n   png_byte compression;      /* file compression type (always 0) */\n   png_byte filter;           /* file filter type (always 0) */\n   png_byte interlaced;       /* PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */\n   png_byte pass;             /* current interlace pass (0 - 6) */\n   png_byte do_filter;        /* row filter flags (see PNG_FILTER_ below ) */\n   png_byte color_type;       /* color type of file */\n   png_byte bit_depth;        /* bit depth of file */\n   png_byte usr_bit_depth;    /* bit depth of users row: write only */\n   png_byte pixel_depth;      /* number of bits per pixel */\n   png_byte channels;         /* number of channels in file */\n#ifdef PNG_WRITE_SUPPORTED\n   png_byte usr_channels;     /* channels at start of write: write only */\n#endif\n   png_byte sig_bytes;        /* magic bytes read/written from start of file */\n   png_byte maximum_pixel_depth;\n                              /* pixel depth used for the row buffers */\n   png_byte transformed_pixel_depth;\n                              /* pixel depth after read/write transforms */\n#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED)\n   png_uint_16 filler;           /* filler bytes for pixel expansion */\n#endif\n\n#if defined(PNG_bKGD_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) ||\\\n   defined(PNG_READ_ALPHA_MODE_SUPPORTED)\n   png_byte background_gamma_type;\n   png_fixed_point background_gamma;\n   png_color_16 background;   /* background color in screen gamma space */\n#ifdef PNG_READ_GAMMA_SUPPORTED\n   png_color_16 background_1; /* background normalized to gamma 1.0 */\n#endif\n#endif /* PNG_bKGD_SUPPORTED */\n\n#ifdef PNG_WRITE_FLUSH_SUPPORTED\n   png_flush_ptr output_flush_fn; /* Function for flushing output */\n   png_uint_32 flush_dist;    /* how many rows apart to flush, 0 - no flush */\n   png_uint_32 flush_rows;    /* number of rows written since last flush */\n#endif\n\n#ifdef PNG_READ_GAMMA_SUPPORTED\n   int gamma_shift;      /* number of \"insignificant\" bits in 16-bit gamma */\n   png_fixed_point screen_gamma; /* screen gamma value (display_exponent) */\n\n   png_bytep gamma_table;     /* gamma table for 8-bit depth files */\n   png_uint_16pp gamma_16_table; /* gamma table for 16-bit depth files */\n#if defined(PNG_READ_BACKGROUND_SUPPORTED) || \\\n   defined(PNG_READ_ALPHA_MODE_SUPPORTED) || \\\n   defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)\n   png_bytep gamma_from_1;    /* converts from 1.0 to screen */\n   png_bytep gamma_to_1;      /* converts from file to 1.0 */\n   png_uint_16pp gamma_16_from_1; /* converts from 1.0 to screen */\n   png_uint_16pp gamma_16_to_1; /* converts from file to 1.0 */\n#endif /* READ_BACKGROUND || READ_ALPHA_MODE || RGB_TO_GRAY */\n#endif\n\n#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_sBIT_SUPPORTED)\n   png_color_8 sig_bit;       /* significant bits in each available channel */\n#endif\n\n#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED)\n   png_color_8 shift;         /* shift for significant bit tranformation */\n#endif\n\n#if defined(PNG_tRNS_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) \\\n || defined(PNG_READ_EXPAND_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)\n   png_bytep trans_alpha;           /* alpha values for paletted files */\n   png_color_16 trans_color;  /* transparent color for non-paletted files */\n#endif\n\n   png_read_status_ptr read_row_fn;   /* called after each row is decoded */\n   png_write_status_ptr write_row_fn; /* called after each row is encoded */\n#ifdef PNG_PROGRESSIVE_READ_SUPPORTED\n   png_progressive_info_ptr info_fn; /* called after header data fully read */\n   png_progressive_row_ptr row_fn;   /* called after a prog. row is decoded */\n   png_progressive_end_ptr end_fn;   /* called after image is complete */\n   png_bytep save_buffer_ptr;        /* current location in save_buffer */\n   png_bytep save_buffer;            /* buffer for previously read data */\n   png_bytep current_buffer_ptr;     /* current location in current_buffer */\n   png_bytep current_buffer;         /* buffer for recently used data */\n   png_uint_32 push_length;          /* size of current input chunk */\n   png_uint_32 skip_length;          /* bytes to skip in input data */\n   png_size_t save_buffer_size;      /* amount of data now in save_buffer */\n   png_size_t save_buffer_max;       /* total size of save_buffer */\n   png_size_t buffer_size;           /* total amount of available input data */\n   png_size_t current_buffer_size;   /* amount of data now in current_buffer */\n   int process_mode;                 /* what push library is currently doing */\n   int cur_palette;                  /* current push library palette index */\n\n#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */\n\n#if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__)\n/* For the Borland special 64K segment handler */\n   png_bytepp offset_table_ptr;\n   png_bytep offset_table;\n   png_uint_16 offset_table_number;\n   png_uint_16 offset_table_count;\n   png_uint_16 offset_table_count_free;\n#endif\n\n#ifdef PNG_READ_QUANTIZE_SUPPORTED\n   png_bytep palette_lookup; /* lookup table for quantizing */\n   png_bytep quantize_index; /* index translation for palette files */\n#endif\n\n#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED\n   png_byte heuristic_method;        /* heuristic for row filter selection */\n   png_byte num_prev_filters;        /* number of weights for previous rows */\n   png_bytep prev_filters;           /* filter type(s) of previous row(s) */\n   png_uint_16p filter_weights;      /* weight(s) for previous line(s) */\n   png_uint_16p inv_filter_weights;  /* 1/weight(s) for previous line(s) */\n   png_uint_16p filter_costs;        /* relative filter calculation cost */\n   png_uint_16p inv_filter_costs;    /* 1/relative filter calculation cost */\n#endif\n\n   /* Options */\n#ifdef PNG_SET_OPTION_SUPPORTED\n   png_byte options;           /* On/off state (up to 4 options) */\n#endif\n\n#if PNG_LIBPNG_VER < 10700\n/* To do: remove this from libpng-1.7 */\n#ifdef PNG_TIME_RFC1123_SUPPORTED\n   char time_buffer[29]; /* String to hold RFC 1123 time text */\n#endif\n#endif\n\n/* New members added in libpng-1.0.6 */\n\n   png_uint_32 free_me;    /* flags items libpng is responsible for freeing */\n\n#ifdef PNG_USER_CHUNKS_SUPPORTED\n   png_voidp user_chunk_ptr;\n#ifdef PNG_READ_USER_CHUNKS_SUPPORTED\n   png_user_chunk_ptr read_user_chunk_fn; /* user read chunk handler */\n#endif\n#endif\n\n#ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED\n   int          unknown_default; /* As PNG_HANDLE_* */\n   unsigned int num_chunk_list;  /* Number of entries in the list */\n   png_bytep    chunk_list;      /* List of png_byte[5]; the textual chunk name\n                                  * followed by a PNG_HANDLE_* byte */\n#endif\n\n/* New members added in libpng-1.0.3 */\n#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED\n   png_byte rgb_to_gray_status;\n   /* Added in libpng 1.5.5 to record setting of coefficients: */\n   png_byte rgb_to_gray_coefficients_set;\n   /* These were changed from png_byte in libpng-1.0.6 */\n   png_uint_16 rgb_to_gray_red_coeff;\n   png_uint_16 rgb_to_gray_green_coeff;\n   /* deleted in 1.5.5: rgb_to_gray_blue_coeff; */\n#endif\n\n/* New member added in libpng-1.0.4 (renamed in 1.0.9) */\n#if defined(PNG_MNG_FEATURES_SUPPORTED)\n/* Changed from png_byte to png_uint_32 at version 1.2.0 */\n   png_uint_32 mng_features_permitted;\n#endif\n\n/* New member added in libpng-1.0.9, ifdef'ed out in 1.0.12, enabled in 1.2.0 */\n#ifdef PNG_MNG_FEATURES_SUPPORTED\n   png_byte filter_type;\n#endif\n\n/* New members added in libpng-1.2.0 */\n\n/* New members added in libpng-1.0.2 but first enabled by default in 1.2.0 */\n#ifdef PNG_USER_MEM_SUPPORTED\n   png_voidp mem_ptr;             /* user supplied struct for mem functions */\n   png_malloc_ptr malloc_fn;      /* function for allocating memory */\n   png_free_ptr free_fn;          /* function for freeing memory */\n#endif\n\n/* New member added in libpng-1.0.13 and 1.2.0 */\n   png_bytep big_row_buf;         /* buffer to save current (unfiltered) row */\n\n#ifdef PNG_READ_QUANTIZE_SUPPORTED\n/* The following three members were added at version 1.0.14 and 1.2.4 */\n   png_bytep quantize_sort;          /* working sort array */\n   png_bytep index_to_palette;       /* where the original index currently is\n                                        in the palette */\n   png_bytep palette_to_index;       /* which original index points to this\n                                         palette color */\n#endif\n\n/* New members added in libpng-1.0.16 and 1.2.6 */\n   png_byte compression_type;\n\n#ifdef PNG_USER_LIMITS_SUPPORTED\n   png_uint_32 user_width_max;\n   png_uint_32 user_height_max;\n\n   /* Added in libpng-1.4.0: Total number of sPLT, text, and unknown\n    * chunks that can be stored (0 means unlimited).\n    */\n   png_uint_32 user_chunk_cache_max;\n\n   /* Total memory that a zTXt, sPLT, iTXt, iCCP, or unknown chunk\n    * can occupy when decompressed.  0 means unlimited.\n    */\n   png_alloc_size_t user_chunk_malloc_max;\n#endif\n\n/* New member added in libpng-1.0.25 and 1.2.17 */\n#ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED\n   /* Temporary storage for unknown chunk that the library doesn't recognize,\n    * used while reading the chunk.\n    */\n   png_unknown_chunk unknown_chunk;\n#endif\n\n/* New member added in libpng-1.2.26 */\n  png_size_t old_big_row_buf_size;\n\n#ifdef PNG_READ_SUPPORTED\n/* New member added in libpng-1.2.30 */\n  png_bytep        read_buffer;      /* buffer for reading chunk data */\n  png_alloc_size_t read_buffer_size; /* current size of the buffer */\n#endif\n#ifdef PNG_SEQUENTIAL_READ_SUPPORTED\n  uInt             IDAT_read_size;   /* limit on read buffer size for IDAT */\n#endif\n\n#ifdef PNG_IO_STATE_SUPPORTED\n/* New member added in libpng-1.4.0 */\n   png_uint_32 io_state;\n#endif\n\n/* New member added in libpng-1.5.6 */\n   png_bytep big_prev_row;\n\n/* New member added in libpng-1.5.7 */\n   void (*read_filter[PNG_FILTER_VALUE_LAST-1])(png_row_infop row_info,\n      png_bytep row, png_const_bytep prev_row);\n\n#ifdef PNG_READ_SUPPORTED\n#if defined(PNG_COLORSPACE_SUPPORTED) || defined(PNG_GAMMA_SUPPORTED)\n   png_colorspace   colorspace;\n#endif\n#endif\n};\n#endif /* PNGSTRUCT_H */\n"
  },
  {
    "path": "Projects/Libraries/CSBase/Source/png/pngtest.c",
    "content": "\n/* pngtest.c - a simple test program to test libpng\n *\n * Last changed in libpng 1.6.9 [February 6, 2014]\n * Copyright (c) 1998-2014 Glenn Randers-Pehrson\n * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)\n * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)\n *\n * This code is released under the libpng license.\n * For conditions of distribution and use, see the disclaimer\n * and license in png.h\n *\n * This program reads in a PNG image, writes it out again, and then\n * compares the two files.  If the files are identical, this shows that\n * the basic chunk handling, filtering, and (de)compression code is working\n * properly.  It does not currently test all of the transforms, although\n * it probably should.\n *\n * The program will report \"FAIL\" in certain legitimate cases:\n * 1) when the compression level or filter selection method is changed.\n * 2) when the maximum IDAT size (PNG_ZBUF_SIZE in pngconf.h) is not 8192.\n * 3) unknown unsafe-to-copy ancillary chunks or unknown critical chunks\n *    exist in the input file.\n * 4) others not listed here...\n * In these cases, it is best to check with another tool such as \"pngcheck\"\n * to see what the differences between the two files are.\n *\n * If a filename is given on the command-line, then this file is used\n * for the input, rather than the default \"pngtest.png\".  This allows\n * testing a wide variety of files easily.  You can also test a number\n * of files at once by typing \"pngtest -m file1.png file2.png ...\"\n */\n\n#define _POSIX_SOURCE 1\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n\n/* Defined so I can write to a file on gui/windowing platforms */\n/*  #define STDERR stderr  */\n#define STDERR stdout   /* For DOS */\n\n#include \"png.h\"\n\n/* Known chunks that exist in pngtest.png must be supported or pngtest will fail\n * simply as a result of re-ordering them.  This may be fixed in 1.7\n *\n * pngtest allocates a single row buffer for each row and overwrites it,\n * therefore if the write side doesn't support the writing of interlaced images\n * nothing can be done for an interlaced image (and the code below will fail\n * horribly trying to write extra data after writing garbage).\n */\n#if defined PNG_READ_SUPPORTED && /* else nothing can be done */\\\n   defined PNG_READ_bKGD_SUPPORTED &&\\\n   defined PNG_READ_cHRM_SUPPORTED &&\\\n   defined PNG_READ_gAMA_SUPPORTED &&\\\n   defined PNG_READ_oFFs_SUPPORTED &&\\\n   defined PNG_READ_pCAL_SUPPORTED &&\\\n   defined PNG_READ_pHYs_SUPPORTED &&\\\n   defined PNG_READ_sBIT_SUPPORTED &&\\\n   defined PNG_READ_sCAL_SUPPORTED &&\\\n   defined PNG_READ_sRGB_SUPPORTED &&\\\n   defined PNG_READ_tEXt_SUPPORTED &&\\\n   defined PNG_READ_tIME_SUPPORTED &&\\\n   defined PNG_READ_zTXt_SUPPORTED &&\\\n   defined PNG_WRITE_INTERLACING_SUPPORTED\n\n#ifdef PNG_ZLIB_HEADER\n#  include PNG_ZLIB_HEADER /* defined by pnglibconf.h from 1.7 */\n#else\n#  include \"zlib.h\"\n#endif\n\n/* Copied from pngpriv.h but only used in error messages below. */\n#ifndef PNG_ZBUF_SIZE\n#  define PNG_ZBUF_SIZE 8192\n#endif\n#define FCLOSE(file) fclose(file)\n\n#ifndef PNG_STDIO_SUPPORTED\ntypedef FILE                * png_FILE_p;\n#endif\n\n/* Makes pngtest verbose so we can find problems. */\n#ifndef PNG_DEBUG\n#  define PNG_DEBUG 0\n#endif\n\n#if PNG_DEBUG > 1\n#  define pngtest_debug(m)        ((void)fprintf(stderr, m \"\\n\"))\n#  define pngtest_debug1(m,p1)    ((void)fprintf(stderr, m \"\\n\", p1))\n#  define pngtest_debug2(m,p1,p2) ((void)fprintf(stderr, m \"\\n\", p1, p2))\n#else\n#  define pngtest_debug(m)        ((void)0)\n#  define pngtest_debug1(m,p1)    ((void)0)\n#  define pngtest_debug2(m,p1,p2) ((void)0)\n#endif\n\n#if !PNG_DEBUG\n#  define SINGLE_ROWBUF_ALLOC  /* Makes buffer overruns easier to nail */\n#endif\n\n/* Turn on CPU timing\n#define PNGTEST_TIMING\n*/\n\n#ifndef PNG_FLOATING_POINT_SUPPORTED\n#undef PNGTEST_TIMING\n#endif\n\n#ifdef PNGTEST_TIMING\nstatic float t_start, t_stop, t_decode, t_encode, t_misc;\n#include <time.h>\n#endif\n\n#ifdef PNG_TIME_RFC1123_SUPPORTED\n#define PNG_tIME_STRING_LENGTH 29\nstatic int tIME_chunk_present = 0;\nstatic char tIME_string[PNG_tIME_STRING_LENGTH] = \"tIME chunk is not present\";\n#endif\n\nstatic int verbose = 0;\nstatic int strict = 0;\nstatic int relaxed = 0;\nstatic int unsupported_chunks = 0; /* chunk unsupported by libpng in input */\nstatic int error_count = 0; /* count calls to png_error */\nstatic int warning_count = 0; /* count calls to png_warning */\n\n/* Define png_jmpbuf() in case we are using a pre-1.0.6 version of libpng */\n#ifndef png_jmpbuf\n#  define png_jmpbuf(png_ptr) png_ptr->jmpbuf\n#endif\n\n/* Defines for unknown chunk handling if required. */\n#ifndef PNG_HANDLE_CHUNK_ALWAYS\n#  define PNG_HANDLE_CHUNK_ALWAYS       3\n#endif\n#ifndef PNG_HANDLE_CHUNK_IF_SAFE\n#  define PNG_HANDLE_CHUNK_IF_SAFE      2\n#endif\n\n/* Utility to save typing/errors, the argument must be a name */\n#define MEMZERO(var) ((void)memset(&var, 0, sizeof var))\n\n/* Example of using row callbacks to make a simple progress meter */\nstatic int status_pass = 1;\nstatic int status_dots_requested = 0;\nstatic int status_dots = 1;\n\nstatic void PNGCBAPI\nread_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass)\n{\n   if (png_ptr == NULL || row_number > PNG_UINT_31_MAX)\n      return;\n\n   if (status_pass != pass)\n   {\n      fprintf(stdout, \"\\n Pass %d: \", pass);\n      status_pass = pass;\n      status_dots = 31;\n   }\n\n   status_dots--;\n\n   if (status_dots == 0)\n   {\n      fprintf(stdout, \"\\n         \");\n      status_dots=30;\n   }\n\n   fprintf(stdout, \"r\");\n}\n\n#ifdef PNG_WRITE_SUPPORTED\nstatic void PNGCBAPI\nwrite_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass)\n{\n   if (png_ptr == NULL || row_number > PNG_UINT_31_MAX || pass > 7)\n      return;\n\n   fprintf(stdout, \"w\");\n}\n#endif\n\n\n#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED\n/* Example of using user transform callback (we don't transform anything,\n * but merely examine the row filters.  We set this to 256 rather than\n * 5 in case illegal filter values are present.)\n */\nstatic png_uint_32 filters_used[256];\nstatic void PNGCBAPI\ncount_filters(png_structp png_ptr, png_row_infop row_info, png_bytep data)\n{\n   if (png_ptr != NULL && row_info != NULL)\n      ++filters_used[*(data - 1)];\n}\n#endif\n\n#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED\n/* Example of using user transform callback (we don't transform anything,\n * but merely count the zero samples)\n */\n\nstatic png_uint_32 zero_samples;\n\nstatic void PNGCBAPI\ncount_zero_samples(png_structp png_ptr, png_row_infop row_info, png_bytep data)\n{\n   png_bytep dp = data;\n   if (png_ptr == NULL)\n      return;\n\n   /* Contents of row_info:\n    *  png_uint_32 width      width of row\n    *  png_uint_32 rowbytes   number of bytes in row\n    *  png_byte color_type    color type of pixels\n    *  png_byte bit_depth     bit depth of samples\n    *  png_byte channels      number of channels (1-4)\n    *  png_byte pixel_depth   bits per pixel (depth*channels)\n    */\n\n    /* Counts the number of zero samples (or zero pixels if color_type is 3 */\n\n    if (row_info->color_type == 0 || row_info->color_type == 3)\n    {\n       int pos = 0;\n       png_uint_32 n, nstop;\n\n       for (n = 0, nstop=row_info->width; n<nstop; n++)\n       {\n          if (row_info->bit_depth == 1)\n          {\n             if (((*dp << pos++ ) & 0x80) == 0)\n                zero_samples++;\n\n             if (pos == 8)\n             {\n                pos = 0;\n                dp++;\n             }\n          }\n\n          if (row_info->bit_depth == 2)\n          {\n             if (((*dp << (pos+=2)) & 0xc0) == 0)\n                zero_samples++;\n\n             if (pos == 8)\n             {\n                pos = 0;\n                dp++;\n             }\n          }\n\n          if (row_info->bit_depth == 4)\n          {\n             if (((*dp << (pos+=4)) & 0xf0) == 0)\n                zero_samples++;\n\n             if (pos == 8)\n             {\n                pos = 0;\n                dp++;\n             }\n          }\n\n          if (row_info->bit_depth == 8)\n             if (*dp++ == 0)\n                zero_samples++;\n\n          if (row_info->bit_depth == 16)\n          {\n             if ((*dp | *(dp+1)) == 0)\n                zero_samples++;\n             dp+=2;\n          }\n       }\n    }\n    else /* Other color types */\n    {\n       png_uint_32 n, nstop;\n       int channel;\n       int color_channels = row_info->channels;\n       if (row_info->color_type > 3)color_channels--;\n\n       for (n = 0, nstop=row_info->width; n<nstop; n++)\n       {\n          for (channel = 0; channel < color_channels; channel++)\n          {\n             if (row_info->bit_depth == 8)\n                if (*dp++ == 0)\n                   zero_samples++;\n\n             if (row_info->bit_depth == 16)\n             {\n                if ((*dp | *(dp+1)) == 0)\n                   zero_samples++;\n\n                dp+=2;\n             }\n          }\n          if (row_info->color_type > 3)\n          {\n             dp++;\n             if (row_info->bit_depth == 16)\n                dp++;\n          }\n       }\n    }\n}\n#endif /* PNG_WRITE_USER_TRANSFORM_SUPPORTED */\n\n#ifndef PNG_STDIO_SUPPORTED\n/* START of code to validate stdio-free compilation */\n/* These copies of the default read/write functions come from pngrio.c and\n * pngwio.c.  They allow \"don't include stdio\" testing of the library.\n * This is the function that does the actual reading of data.  If you are\n * not reading from a standard C stream, you should create a replacement\n * read_data function and use it at run time with png_set_read_fn(), rather\n * than changing the library.\n */\n\n#ifdef PNG_IO_STATE_SUPPORTED\nvoid\npngtest_check_io_state(png_structp png_ptr, png_size_t data_length,\n   png_uint_32 io_op);\nvoid\npngtest_check_io_state(png_structp png_ptr, png_size_t data_length,\n   png_uint_32 io_op)\n{\n   png_uint_32 io_state = png_get_io_state(png_ptr);\n   int err = 0;\n\n   /* Check if the current operation (reading / writing) is as expected. */\n   if ((io_state & PNG_IO_MASK_OP) != io_op)\n      png_error(png_ptr, \"Incorrect operation in I/O state\");\n\n   /* Check if the buffer size specific to the current location\n    * (file signature / header / data / crc) is as expected.\n    */\n   switch (io_state & PNG_IO_MASK_LOC)\n   {\n   case PNG_IO_SIGNATURE:\n      if (data_length > 8)\n         err = 1;\n      break;\n   case PNG_IO_CHUNK_HDR:\n      if (data_length != 8)\n         err = 1;\n      break;\n   case PNG_IO_CHUNK_DATA:\n      break;  /* no restrictions here */\n   case PNG_IO_CHUNK_CRC:\n      if (data_length != 4)\n         err = 1;\n      break;\n   default:\n      err = 1;  /* uninitialized */\n   }\n   if (err)\n      png_error(png_ptr, \"Bad I/O state or buffer size\");\n}\n#endif\n\nstatic void PNGCBAPI\npngtest_read_data(png_structp png_ptr, png_bytep data, png_size_t length)\n{\n   png_size_t check = 0;\n   png_voidp io_ptr;\n\n   /* fread() returns 0 on error, so it is OK to store this in a png_size_t\n    * instead of an int, which is what fread() actually returns.\n    */\n   io_ptr = png_get_io_ptr(png_ptr);\n   if (io_ptr != NULL)\n   {\n      check = fread(data, 1, length, (png_FILE_p)io_ptr);\n   }\n\n   if (check != length)\n   {\n      png_error(png_ptr, \"Read Error\");\n   }\n\n#ifdef PNG_IO_STATE_SUPPORTED\n   pngtest_check_io_state(png_ptr, length, PNG_IO_READING);\n#endif\n}\n\n#ifdef PNG_WRITE_FLUSH_SUPPORTED\nstatic void PNGCBAPI\npngtest_flush(png_structp png_ptr)\n{\n   /* Do nothing; fflush() is said to be just a waste of energy. */\n   PNG_UNUSED(png_ptr)   /* Stifle compiler warning */\n}\n#endif\n\n/* This is the function that does the actual writing of data.  If you are\n * not writing to a standard C stream, you should create a replacement\n * write_data function and use it at run time with png_set_write_fn(), rather\n * than changing the library.\n */\nstatic void PNGCBAPI\npngtest_write_data(png_structp png_ptr, png_bytep data, png_size_t length)\n{\n   png_size_t check;\n\n   check = fwrite(data, 1, length, (png_FILE_p)png_get_io_ptr(png_ptr));\n\n   if (check != length)\n   {\n      png_error(png_ptr, \"Write Error\");\n   }\n\n#ifdef PNG_IO_STATE_SUPPORTED\n   pngtest_check_io_state(png_ptr, length, PNG_IO_WRITING);\n#endif\n}\n#endif /* !PNG_STDIO_SUPPORTED */\n\n/* This function is called when there is a warning, but the library thinks\n * it can continue anyway.  Replacement functions don't have to do anything\n * here if you don't want to.  In the default configuration, png_ptr is\n * not used, but it is passed in case it may be useful.\n */\ntypedef struct\n{\n   PNG_CONST char *file_name;\n}  pngtest_error_parameters;\n\nstatic void PNGCBAPI\npngtest_warning(png_structp png_ptr, png_const_charp message)\n{\n   PNG_CONST char *name = \"UNKNOWN (ERROR!)\";\n   pngtest_error_parameters *test =\n      (pngtest_error_parameters*)png_get_error_ptr(png_ptr);\n\n   ++warning_count;\n\n   if (test != NULL && test->file_name != NULL)\n      name = test->file_name;\n\n   fprintf(STDERR, \"%s: libpng warning: %s\\n\", name, message);\n}\n\n/* This is the default error handling function.  Note that replacements for\n * this function MUST NOT RETURN, or the program will likely crash.  This\n * function is used by default, or if the program supplies NULL for the\n * error function pointer in png_set_error_fn().\n */\nstatic void PNGCBAPI\npngtest_error(png_structp png_ptr, png_const_charp message)\n{\n   ++error_count;\n\n   pngtest_warning(png_ptr, message);\n   /* We can return because png_error calls the default handler, which is\n    * actually OK in this case.\n    */\n}\n\n/* END of code to validate stdio-free compilation */\n\n/* START of code to validate memory allocation and deallocation */\n#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG\n\n/* Allocate memory.  For reasonable files, size should never exceed\n * 64K.  However, zlib may allocate more then 64K if you don't tell\n * it not to.  See zconf.h and png.h for more information.  zlib does\n * need to allocate exactly 64K, so whatever you call here must\n * have the ability to do that.\n *\n * This piece of code can be compiled to validate max 64K allocations\n * by setting MAXSEG_64K in zlib zconf.h *or* PNG_MAX_MALLOC_64K.\n */\ntypedef struct memory_information\n{\n   png_alloc_size_t          size;\n   png_voidp                 pointer;\n   struct memory_information *next;\n} memory_information;\ntypedef memory_information *memory_infop;\n\nstatic memory_infop pinformation = NULL;\nstatic int current_allocation = 0;\nstatic int maximum_allocation = 0;\nstatic int total_allocation = 0;\nstatic int num_allocations = 0;\n\npng_voidp PNGCBAPI png_debug_malloc PNGARG((png_structp png_ptr,\n    png_alloc_size_t size));\nvoid PNGCBAPI png_debug_free PNGARG((png_structp png_ptr, png_voidp ptr));\n\npng_voidp\nPNGCBAPI png_debug_malloc(png_structp png_ptr, png_alloc_size_t size)\n{\n\n   /* png_malloc has already tested for NULL; png_create_struct calls\n    * png_debug_malloc directly, with png_ptr == NULL which is OK\n    */\n\n   if (size == 0)\n      return (NULL);\n\n   /* This calls the library allocator twice, once to get the requested\n      buffer and once to get a new free list entry. */\n   {\n      /* Disable malloc_fn and free_fn */\n      memory_infop pinfo;\n      png_set_mem_fn(png_ptr, NULL, NULL, NULL);\n      pinfo = (memory_infop)png_malloc(png_ptr,\n         (sizeof *pinfo));\n      pinfo->size = size;\n      current_allocation += size;\n      total_allocation += size;\n      num_allocations ++;\n\n      if (current_allocation > maximum_allocation)\n         maximum_allocation = current_allocation;\n\n      pinfo->pointer = png_malloc(png_ptr, size);\n      /* Restore malloc_fn and free_fn */\n\n      png_set_mem_fn(png_ptr,\n          NULL, png_debug_malloc, png_debug_free);\n\n      if (size != 0 && pinfo->pointer == NULL)\n      {\n         current_allocation -= size;\n         total_allocation -= size;\n         png_error(png_ptr,\n           \"out of memory in pngtest->png_debug_malloc\");\n      }\n\n      pinfo->next = pinformation;\n      pinformation = pinfo;\n      /* Make sure the caller isn't assuming zeroed memory. */\n      memset(pinfo->pointer, 0xdd, pinfo->size);\n\n      if (verbose)\n         printf(\"png_malloc %lu bytes at %p\\n\", (unsigned long)size,\n            pinfo->pointer);\n\n      return (png_voidp)(pinfo->pointer);\n   }\n}\n\n/* Free a pointer.  It is removed from the list at the same time. */\nvoid PNGCBAPI\npng_debug_free(png_structp png_ptr, png_voidp ptr)\n{\n   if (png_ptr == NULL)\n      fprintf(STDERR, \"NULL pointer to png_debug_free.\\n\");\n\n   if (ptr == 0)\n   {\n#if 0 /* This happens all the time. */\n      fprintf(STDERR, \"WARNING: freeing NULL pointer\\n\");\n#endif\n      return;\n   }\n\n   /* Unlink the element from the list. */\n   {\n      memory_infop *ppinfo = &pinformation;\n\n      for (;;)\n      {\n         memory_infop pinfo = *ppinfo;\n\n         if (pinfo->pointer == ptr)\n         {\n            *ppinfo = pinfo->next;\n            current_allocation -= pinfo->size;\n            if (current_allocation < 0)\n               fprintf(STDERR, \"Duplicate free of memory\\n\");\n            /* We must free the list element too, but first kill\n               the memory that is to be freed. */\n            memset(ptr, 0x55, pinfo->size);\n            if (pinfo)\n               free(pinfo);\n            pinfo = NULL;\n            break;\n         }\n\n         if (pinfo->next == NULL)\n         {\n            fprintf(STDERR, \"Pointer %x not found\\n\", (unsigned int)ptr);\n            break;\n         }\n\n         ppinfo = &pinfo->next;\n      }\n   }\n\n   /* Finally free the data. */\n   if (verbose)\n      printf(\"Freeing %p\\n\", ptr);\n\n   if (ptr)\n      free(ptr);\n   ptr = NULL;\n}\n#endif /* PNG_USER_MEM_SUPPORTED && PNG_DEBUG */\n/* END of code to test memory allocation/deallocation */\n\n\n#ifdef PNG_READ_USER_CHUNKS_SUPPORTED\n/* Demonstration of user chunk support of the sTER and vpAg chunks */\n\n/* (sTER is a public chunk not yet known by libpng.  vpAg is a private\nchunk used in ImageMagick to store \"virtual page\" size).  */\n\nstatic struct user_chunk_data\n{\n   png_const_infop info_ptr;\n   png_uint_32     vpAg_width, vpAg_height;\n   png_byte        vpAg_units;\n   png_byte        sTER_mode;\n   int             location[2];\n}\nuser_chunk_data;\n\n/* Used for location and order; zero means nothing. */\n#define have_sTER   0x01\n#define have_vpAg   0x02\n#define before_PLTE 0x10\n#define before_IDAT 0x20\n#define after_IDAT  0x40\n\nstatic void\ninit_callback_info(png_const_infop info_ptr)\n{\n   MEMZERO(user_chunk_data);\n   user_chunk_data.info_ptr = info_ptr;\n}\n\nstatic int\nset_location(png_structp png_ptr, struct user_chunk_data *data, int what)\n{\n   int location;\n\n   if ((data->location[0] & what) || (data->location[1] & what))\n      return 0; /* already have one of these */\n\n   /* Find where we are (the code below zeros info_ptr to indicate that the\n    * chunks before the first IDAT have been read.)\n    */\n   if (data->info_ptr == NULL) /* after IDAT */\n      location = what | after_IDAT;\n\n   else if (png_get_valid(png_ptr, data->info_ptr, PNG_INFO_PLTE))\n      location = what | before_IDAT;\n\n   else\n      location = what | before_PLTE;\n\n   if (data->location[0] == 0)\n      data->location[0] = location;\n\n   else\n      data->location[1] = location;\n\n   return 1; /* handled */\n}\n\nstatic int PNGCBAPI\nread_user_chunk_callback(png_struct *png_ptr, png_unknown_chunkp chunk)\n{\n   struct user_chunk_data *my_user_chunk_data =\n      (struct user_chunk_data*)png_get_user_chunk_ptr(png_ptr);\n\n   if (my_user_chunk_data == NULL)\n      png_error(png_ptr, \"lost user chunk pointer\");\n\n   /* Return one of the following:\n    *    return (-n);  chunk had an error\n    *    return (0);  did not recognize\n    *    return (n);  success\n    *\n    * The unknown chunk structure contains the chunk data:\n    * png_byte name[5];\n    * png_byte *data;\n    * png_size_t size;\n    *\n    * Note that libpng has already taken care of the CRC handling.\n    */\n\n   if (chunk->name[0] == 115 && chunk->name[1] ==  84 &&     /* s  T */\n       chunk->name[2] ==  69 && chunk->name[3] ==  82)       /* E  R */\n      {\n         /* Found sTER chunk */\n         if (chunk->size != 1)\n            return (-1); /* Error return */\n\n         if (chunk->data[0] != 0 && chunk->data[0] != 1)\n            return (-1);  /* Invalid mode */\n\n         if (set_location(png_ptr, my_user_chunk_data, have_sTER))\n         {\n            my_user_chunk_data->sTER_mode=chunk->data[0];\n            return (1);\n         }\n\n         else\n            return (0); /* duplicate sTER - give it to libpng */\n      }\n\n   if (chunk->name[0] != 118 || chunk->name[1] != 112 ||    /* v  p */\n       chunk->name[2] !=  65 || chunk->name[3] != 103)      /* A  g */\n      return (0); /* Did not recognize */\n\n   /* Found ImageMagick vpAg chunk */\n\n   if (chunk->size != 9)\n      return (-1); /* Error return */\n\n   if (!set_location(png_ptr, my_user_chunk_data, have_vpAg))\n      return (0);  /* duplicate vpAg */\n\n   my_user_chunk_data->vpAg_width = png_get_uint_31(png_ptr, chunk->data);\n   my_user_chunk_data->vpAg_height = png_get_uint_31(png_ptr, chunk->data + 4);\n   my_user_chunk_data->vpAg_units = chunk->data[8];\n\n   return (1);\n}\n\n#ifdef PNG_WRITE_SUPPORTED\nstatic void\nwrite_sTER_chunk(png_structp write_ptr)\n{\n   png_byte sTER[5] = {115,  84,  69,  82, '\\0'};\n\n   if (verbose)\n      fprintf(STDERR, \"\\n stereo mode = %d\\n\", user_chunk_data.sTER_mode);\n\n   png_write_chunk(write_ptr, sTER, &user_chunk_data.sTER_mode, 1);\n}\n\nstatic void\nwrite_vpAg_chunk(png_structp write_ptr)\n{\n   png_byte vpAg[5] = {118, 112,  65, 103, '\\0'};\n\n   png_byte vpag_chunk_data[9];\n\n   if (verbose)\n      fprintf(STDERR, \" vpAg = %lu x %lu, units = %d\\n\",\n        (unsigned long)user_chunk_data.vpAg_width,\n        (unsigned long)user_chunk_data.vpAg_height,\n        user_chunk_data.vpAg_units);\n\n   png_save_uint_32(vpag_chunk_data, user_chunk_data.vpAg_width);\n   png_save_uint_32(vpag_chunk_data + 4, user_chunk_data.vpAg_height);\n   vpag_chunk_data[8] = user_chunk_data.vpAg_units;\n   png_write_chunk(write_ptr, vpAg, vpag_chunk_data, 9);\n}\n\nstatic void\nwrite_chunks(png_structp write_ptr, int location)\n{\n   int i;\n\n   /* Notice that this preserves the original chunk order, however chunks\n    * intercepted by the callback will be written *after* chunks passed to\n    * libpng.  This will actually reverse a pair of sTER chunks or a pair of\n    * vpAg chunks, resulting in an error later.  This is not worth worrying\n    * about - the chunks should not be duplicated!\n    */\n   for (i=0; i<2; ++i)\n   {\n      if (user_chunk_data.location[i] == (location | have_sTER))\n         write_sTER_chunk(write_ptr);\n\n      else if (user_chunk_data.location[i] == (location | have_vpAg))\n         write_vpAg_chunk(write_ptr);\n   }\n}\n#endif /* PNG_WRITE_SUPPORTED */\n#else /* !PNG_READ_USER_CHUNKS_SUPPORTED */\n#  define write_chunks(pp,loc) ((void)0)\n#endif\n/* END of code to demonstrate user chunk support */\n\n/* START of code to check that libpng has the required text support; this only\n * checks for the write support because if read support is missing the chunk\n * will simply not be reported back to pngtest.\n */\n#ifdef PNG_TEXT_SUPPORTED\nstatic void\npngtest_check_text_support(png_const_structp png_ptr, png_textp text_ptr,\n   int num_text)\n{\n   while (num_text > 0)\n   {\n      switch (text_ptr[--num_text].compression)\n      {\n         case PNG_TEXT_COMPRESSION_NONE:\n            break;\n\n         case PNG_TEXT_COMPRESSION_zTXt:\n#           ifndef PNG_WRITE_zTXt_SUPPORTED\n               ++unsupported_chunks;\n#           endif\n            break;\n\n         case PNG_ITXT_COMPRESSION_NONE:\n         case PNG_ITXT_COMPRESSION_zTXt:\n#           ifndef PNG_WRITE_iTXt_SUPPORTED\n               ++unsupported_chunks;\n#           endif\n            break;\n\n         default:\n            /* This is an error */\n            png_error(png_ptr, \"invalid text chunk compression field\");\n            break;\n      }\n   }\n}\n#endif\n/* END of code to check that libpng has the required text support */\n\n/* Test one file */\nstatic int\ntest_one_file(PNG_CONST char *inname, PNG_CONST char *outname)\n{\n   static png_FILE_p fpin;\n   static png_FILE_p fpout;  /* \"static\" prevents setjmp corruption */\n   pngtest_error_parameters error_parameters;\n   png_structp read_ptr;\n   png_infop read_info_ptr, end_info_ptr;\n#ifdef PNG_WRITE_SUPPORTED\n   png_structp write_ptr;\n   png_infop write_info_ptr;\n   png_infop write_end_info_ptr;\n   int interlace_preserved = 1;\n#else\n   png_structp write_ptr = NULL;\n   png_infop write_info_ptr = NULL;\n   png_infop write_end_info_ptr = NULL;\n#endif\n   png_bytep row_buf;\n   png_uint_32 y;\n   png_uint_32 width, height;\n   int num_pass = 1, pass;\n   int bit_depth, color_type;\n\n   row_buf = NULL;\n   error_parameters.file_name = inname;\n\n   if ((fpin = fopen(inname, \"rb\")) == NULL)\n   {\n      fprintf(STDERR, \"Could not find input file %s\\n\", inname);\n      return (1);\n   }\n\n   if ((fpout = fopen(outname, \"wb\")) == NULL)\n   {\n      fprintf(STDERR, \"Could not open output file %s\\n\", outname);\n      FCLOSE(fpin);\n      return (1);\n   }\n\n   pngtest_debug(\"Allocating read and write structures\");\n#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG\n   read_ptr =\n      png_create_read_struct_2(PNG_LIBPNG_VER_STRING, NULL,\n      NULL, NULL, NULL, png_debug_malloc, png_debug_free);\n#else\n   read_ptr =\n      png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);\n#endif\n   png_set_error_fn(read_ptr, &error_parameters, pngtest_error,\n      pngtest_warning);\n\n#ifdef PNG_WRITE_SUPPORTED\n#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG\n   write_ptr =\n      png_create_write_struct_2(PNG_LIBPNG_VER_STRING, NULL,\n      NULL, NULL, NULL, png_debug_malloc, png_debug_free);\n#else\n   write_ptr =\n      png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);\n#endif\n   png_set_error_fn(write_ptr, &error_parameters, pngtest_error,\n      pngtest_warning);\n#endif\n   pngtest_debug(\"Allocating read_info, write_info and end_info structures\");\n   read_info_ptr = png_create_info_struct(read_ptr);\n   end_info_ptr = png_create_info_struct(read_ptr);\n#ifdef PNG_WRITE_SUPPORTED\n   write_info_ptr = png_create_info_struct(write_ptr);\n   write_end_info_ptr = png_create_info_struct(write_ptr);\n#endif\n\n#ifdef PNG_READ_USER_CHUNKS_SUPPORTED\n   init_callback_info(read_info_ptr);\n   png_set_read_user_chunk_fn(read_ptr, &user_chunk_data,\n     read_user_chunk_callback);\n#endif\n\n#ifdef PNG_SETJMP_SUPPORTED\n   pngtest_debug(\"Setting jmpbuf for read struct\");\n   if (setjmp(png_jmpbuf(read_ptr)))\n   {\n      fprintf(STDERR, \"%s -> %s: libpng read error\\n\", inname, outname);\n      png_free(read_ptr, row_buf);\n      row_buf = NULL;\n      png_destroy_read_struct(&read_ptr, &read_info_ptr, &end_info_ptr);\n#ifdef PNG_WRITE_SUPPORTED\n      png_destroy_info_struct(write_ptr, &write_end_info_ptr);\n      png_destroy_write_struct(&write_ptr, &write_info_ptr);\n#endif\n      FCLOSE(fpin);\n      FCLOSE(fpout);\n      return (1);\n   }\n\n#ifdef PNG_WRITE_SUPPORTED\n   pngtest_debug(\"Setting jmpbuf for write struct\");\n\n   if (setjmp(png_jmpbuf(write_ptr)))\n   {\n      fprintf(STDERR, \"%s -> %s: libpng write error\\n\", inname, outname);\n      png_destroy_read_struct(&read_ptr, &read_info_ptr, &end_info_ptr);\n      png_destroy_info_struct(write_ptr, &write_end_info_ptr);\n#ifdef PNG_WRITE_SUPPORTED\n      png_destroy_write_struct(&write_ptr, &write_info_ptr);\n#endif\n      FCLOSE(fpin);\n      FCLOSE(fpout);\n      return (1);\n   }\n#endif\n#endif\n\n   if (strict)\n   {\n      /* Treat png_benign_error() as errors on read */\n      png_set_benign_errors(read_ptr, 0);\n\n#ifdef PNG_WRITE_SUPPORTED\n      /* Treat them as errors on write */\n      png_set_benign_errors(write_ptr, 0);\n#endif\n\n      /* if strict is not set, then app warnings and errors are treated as\n       * warnings in release builds, but not in unstable builds; this can be\n       * changed with '--relaxed'.\n       */\n   }\n\n   else if (relaxed)\n   {\n      /* Allow application (pngtest) errors and warnings to pass */\n      png_set_benign_errors(read_ptr, 1);\n\n#ifdef PNG_WRITE_SUPPORTED\n      png_set_benign_errors(write_ptr, 1);\n#endif\n   }\n\n   pngtest_debug(\"Initializing input and output streams\");\n#ifdef PNG_STDIO_SUPPORTED\n   png_init_io(read_ptr, fpin);\n#  ifdef PNG_WRITE_SUPPORTED\n   png_init_io(write_ptr, fpout);\n#  endif\n#else\n   png_set_read_fn(read_ptr, (png_voidp)fpin, pngtest_read_data);\n#  ifdef PNG_WRITE_SUPPORTED\n   png_set_write_fn(write_ptr, (png_voidp)fpout,  pngtest_write_data,\n#    ifdef PNG_WRITE_FLUSH_SUPPORTED\n      pngtest_flush);\n#    else\n      NULL);\n#    endif\n#  endif\n#endif\n\n   if (status_dots_requested == 1)\n   {\n#ifdef PNG_WRITE_SUPPORTED\n      png_set_write_status_fn(write_ptr, write_row_callback);\n#endif\n      png_set_read_status_fn(read_ptr, read_row_callback);\n   }\n\n   else\n   {\n#ifdef PNG_WRITE_SUPPORTED\n      png_set_write_status_fn(write_ptr, NULL);\n#endif\n      png_set_read_status_fn(read_ptr, NULL);\n   }\n\n#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED\n   {\n      int i;\n\n      for (i = 0; i<256; i++)\n         filters_used[i] = 0;\n\n      png_set_read_user_transform_fn(read_ptr, count_filters);\n   }\n#endif\n#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED\n   zero_samples = 0;\n   png_set_write_user_transform_fn(write_ptr, count_zero_samples);\n#endif\n\n#ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED\n   /* Preserve all the unknown chunks, if possible.  If this is disabled then,\n    * even if the png_{get,set}_unknown_chunks stuff is enabled, we can't use\n    * libpng to *save* the unknown chunks on read (because we can't switch the\n    * save option on!)\n    *\n    * Notice that if SET_UNKNOWN_CHUNKS is *not* supported read will discard all\n    * unknown chunks and write will write them all.\n    */\n#ifdef PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED\n   png_set_keep_unknown_chunks(read_ptr, PNG_HANDLE_CHUNK_ALWAYS,\n      NULL, 0);\n#endif\n#ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED\n   png_set_keep_unknown_chunks(write_ptr, PNG_HANDLE_CHUNK_ALWAYS,\n      NULL, 0);\n#endif\n#endif\n\n   pngtest_debug(\"Reading info struct\");\n   png_read_info(read_ptr, read_info_ptr);\n\n#ifdef PNG_READ_USER_CHUNKS_SUPPORTED\n   /* This is a bit of a hack; there is no obvious way in the callback function\n    * to determine that the chunks before the first IDAT have been read, so\n    * remove the info_ptr (which is only used to determine position relative to\n    * PLTE) here to indicate that we are after the IDAT.\n    */\n   user_chunk_data.info_ptr = NULL;\n#endif\n\n   pngtest_debug(\"Transferring info struct\");\n   {\n      int interlace_type, compression_type, filter_type;\n\n      if (png_get_IHDR(read_ptr, read_info_ptr, &width, &height, &bit_depth,\n          &color_type, &interlace_type, &compression_type, &filter_type))\n      {\n         png_set_IHDR(write_ptr, write_info_ptr, width, height, bit_depth,\n            color_type, interlace_type, compression_type, filter_type);\n#ifndef PNG_READ_INTERLACING_SUPPORTED\n         /* num_pass will not be set below, set it here if the image is\n          * interlaced: what happens is that write interlacing is *not* turned\n          * on an the partial interlaced rows are written directly.\n          */\n         switch (interlace_type)\n         {\n            case PNG_INTERLACE_NONE:\n               num_pass = 1;\n               break;\n\n            case PNG_INTERLACE_ADAM7:\n               num_pass = 7;\n                break;\n\n            default:\n                png_error(read_ptr, \"invalid interlace type\");\n                /*NOT REACHED*/\n         }\n#endif\n      }\n   }\n#ifdef PNG_FIXED_POINT_SUPPORTED\n#ifdef PNG_cHRM_SUPPORTED\n   {\n      png_fixed_point white_x, white_y, red_x, red_y, green_x, green_y, blue_x,\n         blue_y;\n\n      if (png_get_cHRM_fixed(read_ptr, read_info_ptr, &white_x, &white_y,\n         &red_x, &red_y, &green_x, &green_y, &blue_x, &blue_y))\n      {\n         png_set_cHRM_fixed(write_ptr, write_info_ptr, white_x, white_y, red_x,\n            red_y, green_x, green_y, blue_x, blue_y);\n      }\n   }\n#endif\n#ifdef PNG_gAMA_SUPPORTED\n   {\n      png_fixed_point gamma;\n\n      if (png_get_gAMA_fixed(read_ptr, read_info_ptr, &gamma))\n         png_set_gAMA_fixed(write_ptr, write_info_ptr, gamma);\n   }\n#endif\n#else /* Use floating point versions */\n#ifdef PNG_FLOATING_POINT_SUPPORTED\n#ifdef PNG_cHRM_SUPPORTED\n   {\n      double white_x, white_y, red_x, red_y, green_x, green_y, blue_x,\n         blue_y;\n\n      if (png_get_cHRM(read_ptr, read_info_ptr, &white_x, &white_y, &red_x,\n         &red_y, &green_x, &green_y, &blue_x, &blue_y))\n      {\n         png_set_cHRM(write_ptr, write_info_ptr, white_x, white_y, red_x,\n            red_y, green_x, green_y, blue_x, blue_y);\n      }\n   }\n#endif\n#ifdef PNG_gAMA_SUPPORTED\n   {\n      double gamma;\n\n      if (png_get_gAMA(read_ptr, read_info_ptr, &gamma))\n         png_set_gAMA(write_ptr, write_info_ptr, gamma);\n   }\n#endif\n#endif /* Floating point */\n#endif /* Fixed point */\n#ifdef PNG_iCCP_SUPPORTED\n   {\n      png_charp name;\n      png_bytep profile;\n      png_uint_32 proflen;\n      int compression_type;\n\n      if (png_get_iCCP(read_ptr, read_info_ptr, &name, &compression_type,\n                      &profile, &proflen))\n      {\n         png_set_iCCP(write_ptr, write_info_ptr, name, compression_type,\n                      profile, proflen);\n      }\n   }\n#endif\n#ifdef PNG_sRGB_SUPPORTED\n   {\n      int intent;\n\n      if (png_get_sRGB(read_ptr, read_info_ptr, &intent))\n         png_set_sRGB(write_ptr, write_info_ptr, intent);\n   }\n#endif\n   {\n      png_colorp palette;\n      int num_palette;\n\n      if (png_get_PLTE(read_ptr, read_info_ptr, &palette, &num_palette))\n         png_set_PLTE(write_ptr, write_info_ptr, palette, num_palette);\n   }\n#ifdef PNG_bKGD_SUPPORTED\n   {\n      png_color_16p background;\n\n      if (png_get_bKGD(read_ptr, read_info_ptr, &background))\n      {\n         png_set_bKGD(write_ptr, write_info_ptr, background);\n      }\n   }\n#endif\n#ifdef PNG_hIST_SUPPORTED\n   {\n      png_uint_16p hist;\n\n      if (png_get_hIST(read_ptr, read_info_ptr, &hist))\n         png_set_hIST(write_ptr, write_info_ptr, hist);\n   }\n#endif\n#ifdef PNG_oFFs_SUPPORTED\n   {\n      png_int_32 offset_x, offset_y;\n      int unit_type;\n\n      if (png_get_oFFs(read_ptr, read_info_ptr, &offset_x, &offset_y,\n          &unit_type))\n      {\n         png_set_oFFs(write_ptr, write_info_ptr, offset_x, offset_y, unit_type);\n      }\n   }\n#endif\n#ifdef PNG_pCAL_SUPPORTED\n   {\n      png_charp purpose, units;\n      png_charpp params;\n      png_int_32 X0, X1;\n      int type, nparams;\n\n      if (png_get_pCAL(read_ptr, read_info_ptr, &purpose, &X0, &X1, &type,\n         &nparams, &units, &params))\n      {\n         png_set_pCAL(write_ptr, write_info_ptr, purpose, X0, X1, type,\n            nparams, units, params);\n      }\n   }\n#endif\n#ifdef PNG_pHYs_SUPPORTED\n   {\n      png_uint_32 res_x, res_y;\n      int unit_type;\n\n      if (png_get_pHYs(read_ptr, read_info_ptr, &res_x, &res_y, &unit_type))\n         png_set_pHYs(write_ptr, write_info_ptr, res_x, res_y, unit_type);\n   }\n#endif\n#ifdef PNG_sBIT_SUPPORTED\n   {\n      png_color_8p sig_bit;\n\n      if (png_get_sBIT(read_ptr, read_info_ptr, &sig_bit))\n         png_set_sBIT(write_ptr, write_info_ptr, sig_bit);\n   }\n#endif\n#ifdef PNG_sCAL_SUPPORTED\n#if defined(PNG_FLOATING_POINT_SUPPORTED) && \\\n   defined(PNG_FLOATING_ARITHMETIC_SUPPORTED)\n   {\n      int unit;\n      double scal_width, scal_height;\n\n      if (png_get_sCAL(read_ptr, read_info_ptr, &unit, &scal_width,\n         &scal_height))\n      {\n         png_set_sCAL(write_ptr, write_info_ptr, unit, scal_width, scal_height);\n      }\n   }\n#else\n#ifdef PNG_FIXED_POINT_SUPPORTED\n   {\n      int unit;\n      png_charp scal_width, scal_height;\n\n      if (png_get_sCAL_s(read_ptr, read_info_ptr, &unit, &scal_width,\n          &scal_height))\n      {\n         png_set_sCAL_s(write_ptr, write_info_ptr, unit, scal_width,\n             scal_height);\n      }\n   }\n#endif\n#endif\n#endif\n#ifdef PNG_TEXT_SUPPORTED\n   {\n      png_textp text_ptr;\n      int num_text;\n\n      if (png_get_text(read_ptr, read_info_ptr, &text_ptr, &num_text) > 0)\n      {\n         pngtest_debug1(\"Handling %d iTXt/tEXt/zTXt chunks\", num_text);\n\n         pngtest_check_text_support(read_ptr, text_ptr, num_text);\n\n         if (verbose)\n         {\n            int i;\n\n            printf(\"\\n\");\n            for (i=0; i<num_text; i++)\n            {\n               printf(\"   Text compression[%d]=%d\\n\",\n                     i, text_ptr[i].compression);\n            }\n         }\n\n         png_set_text(write_ptr, write_info_ptr, text_ptr, num_text);\n      }\n   }\n#endif\n#ifdef PNG_tIME_SUPPORTED\n   {\n      png_timep mod_time;\n\n      if (png_get_tIME(read_ptr, read_info_ptr, &mod_time))\n      {\n         png_set_tIME(write_ptr, write_info_ptr, mod_time);\n#ifdef PNG_TIME_RFC1123_SUPPORTED\n         if (png_convert_to_rfc1123_buffer(tIME_string, mod_time))\n            tIME_string[(sizeof tIME_string) - 1] = '\\0';\n\n         else\n         {\n            strncpy(tIME_string, \"*** invalid time ***\", (sizeof tIME_string));\n            tIME_string[(sizeof tIME_string) - 1] = '\\0';\n         }\n\n         tIME_chunk_present++;\n#endif /* PNG_TIME_RFC1123_SUPPORTED */\n      }\n   }\n#endif\n#ifdef PNG_tRNS_SUPPORTED\n   {\n      png_bytep trans_alpha;\n      int num_trans;\n      png_color_16p trans_color;\n\n      if (png_get_tRNS(read_ptr, read_info_ptr, &trans_alpha, &num_trans,\n         &trans_color))\n      {\n         int sample_max = (1 << bit_depth);\n         /* libpng doesn't reject a tRNS chunk with out-of-range samples */\n         if (!((color_type == PNG_COLOR_TYPE_GRAY &&\n             (int)trans_color->gray > sample_max) ||\n             (color_type == PNG_COLOR_TYPE_RGB &&\n             ((int)trans_color->red > sample_max ||\n             (int)trans_color->green > sample_max ||\n             (int)trans_color->blue > sample_max))))\n            png_set_tRNS(write_ptr, write_info_ptr, trans_alpha, num_trans,\n               trans_color);\n      }\n   }\n#endif\n#ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED\n   {\n      png_unknown_chunkp unknowns;\n      int num_unknowns = png_get_unknown_chunks(read_ptr, read_info_ptr,\n         &unknowns);\n\n      if (num_unknowns)\n      {\n         png_set_unknown_chunks(write_ptr, write_info_ptr, unknowns,\n           num_unknowns);\n#if PNG_LIBPNG_VER < 10600\n         /* Copy the locations from the read_info_ptr.  The automatically\n          * generated locations in write_end_info_ptr are wrong prior to 1.6.0\n          * because they are reset from the write pointer (removed in 1.6.0).\n          */\n         {\n            int i;\n            for (i = 0; i < num_unknowns; i++)\n              png_set_unknown_chunk_location(write_ptr, write_info_ptr, i,\n                unknowns[i].location);\n         }\n#endif\n      }\n   }\n#endif\n\n#ifdef PNG_WRITE_SUPPORTED\n   pngtest_debug(\"Writing info struct\");\n\n   /* Write the info in two steps so that if we write the 'unknown' chunks here\n    * they go to the correct place.\n    */\n   png_write_info_before_PLTE(write_ptr, write_info_ptr);\n\n   write_chunks(write_ptr, before_PLTE); /* before PLTE */\n\n   png_write_info(write_ptr, write_info_ptr);\n\n   write_chunks(write_ptr, before_IDAT); /* after PLTE */\n#endif\n\n#ifdef SINGLE_ROWBUF_ALLOC\n   pngtest_debug(\"Allocating row buffer...\");\n   row_buf = (png_bytep)png_malloc(read_ptr,\n      png_get_rowbytes(read_ptr, read_info_ptr));\n\n   pngtest_debug1(\"\\t0x%08lx\", (unsigned long)row_buf);\n#endif /* SINGLE_ROWBUF_ALLOC */\n   pngtest_debug(\"Writing row data\");\n\n#ifdef PNG_READ_INTERLACING_SUPPORTED\n   num_pass = png_set_interlace_handling(read_ptr);\n   if (png_set_interlace_handling(write_ptr) != num_pass)\n      png_error(write_ptr, \"png_set_interlace_handling: inconsistent num_pass\");\n#endif\n\n#ifdef PNGTEST_TIMING\n   t_stop = (float)clock();\n   t_misc += (t_stop - t_start);\n   t_start = t_stop;\n#endif\n   for (pass = 0; pass < num_pass; pass++)\n   {\n      pngtest_debug1(\"Writing row data for pass %d\", pass);\n      for (y = 0; y < height; y++)\n      {\n#ifndef SINGLE_ROWBUF_ALLOC\n         pngtest_debug2(\"Allocating row buffer (pass %d, y = %u)...\", pass, y);\n         row_buf = (png_bytep)png_malloc(read_ptr,\n            png_get_rowbytes(read_ptr, read_info_ptr));\n\n         pngtest_debug2(\"\\t0x%08lx (%u bytes)\", (unsigned long)row_buf,\n            png_get_rowbytes(read_ptr, read_info_ptr));\n\n#endif /* !SINGLE_ROWBUF_ALLOC */\n         png_read_rows(read_ptr, (png_bytepp)&row_buf, NULL, 1);\n\n#ifdef PNG_WRITE_SUPPORTED\n#ifdef PNGTEST_TIMING\n         t_stop = (float)clock();\n         t_decode += (t_stop - t_start);\n         t_start = t_stop;\n#endif\n         png_write_rows(write_ptr, (png_bytepp)&row_buf, 1);\n#ifdef PNGTEST_TIMING\n         t_stop = (float)clock();\n         t_encode += (t_stop - t_start);\n         t_start = t_stop;\n#endif\n#endif /* PNG_WRITE_SUPPORTED */\n\n#ifndef SINGLE_ROWBUF_ALLOC\n         pngtest_debug2(\"Freeing row buffer (pass %d, y = %u)\", pass, y);\n         png_free(read_ptr, row_buf);\n         row_buf = NULL;\n#endif /* !SINGLE_ROWBUF_ALLOC */\n      }\n   }\n\n#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED\n#  ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED\n      png_free_data(read_ptr, read_info_ptr, PNG_FREE_UNKN, -1);\n#  endif\n#  ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED\n      png_free_data(write_ptr, write_info_ptr, PNG_FREE_UNKN, -1);\n#  endif\n#endif\n\n   pngtest_debug(\"Reading and writing end_info data\");\n\n   png_read_end(read_ptr, end_info_ptr);\n#ifdef PNG_TEXT_SUPPORTED\n   {\n      png_textp text_ptr;\n      int num_text;\n\n      if (png_get_text(read_ptr, end_info_ptr, &text_ptr, &num_text) > 0)\n      {\n         pngtest_debug1(\"Handling %d iTXt/tEXt/zTXt chunks\", num_text);\n\n         pngtest_check_text_support(read_ptr, text_ptr, num_text);\n\n         if (verbose)\n         {\n            int i;\n\n            printf(\"\\n\");\n            for (i=0; i<num_text; i++)\n            {\n               printf(\"   Text compression[%d]=%d\\n\",\n                     i, text_ptr[i].compression);\n            }\n         }\n\n         png_set_text(write_ptr, write_end_info_ptr, text_ptr, num_text);\n      }\n   }\n#endif\n#ifdef PNG_tIME_SUPPORTED\n   {\n      png_timep mod_time;\n\n      if (png_get_tIME(read_ptr, end_info_ptr, &mod_time))\n      {\n         png_set_tIME(write_ptr, write_end_info_ptr, mod_time);\n#ifdef PNG_TIME_RFC1123_SUPPORTED\n         if (png_convert_to_rfc1123_buffer(tIME_string, mod_time))\n            tIME_string[(sizeof tIME_string) - 1] = '\\0';\n\n         else\n         {\n            strncpy(tIME_string, \"*** invalid time ***\", sizeof tIME_string);\n            tIME_string[(sizeof tIME_string)-1] = '\\0';\n         }\n\n         tIME_chunk_present++;\n#endif /* PNG_TIME_RFC1123_SUPPORTED */\n      }\n   }\n#endif\n#ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED\n   {\n      png_unknown_chunkp unknowns;\n      int num_unknowns = png_get_unknown_chunks(read_ptr, end_info_ptr,\n         &unknowns);\n\n      if (num_unknowns)\n      {\n         png_set_unknown_chunks(write_ptr, write_end_info_ptr, unknowns,\n           num_unknowns);\n#if PNG_LIBPNG_VER < 10600\n         /* Copy the locations from the read_info_ptr.  The automatically\n          * generated locations in write_end_info_ptr are wrong prior to 1.6.0\n          * because they are reset from the write pointer (removed in 1.6.0).\n          */\n         {\n            int i;\n            for (i = 0; i < num_unknowns; i++)\n              png_set_unknown_chunk_location(write_ptr, write_end_info_ptr, i,\n                unknowns[i].location);\n         }\n#endif\n      }\n   }\n#endif\n\n#ifdef PNG_WRITE_SUPPORTED\n#ifdef PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED\n   /* Normally one would use Z_DEFAULT_STRATEGY for text compression.\n    * This is here just to make pngtest replicate the results from libpng\n    * versions prior to 1.5.4, and to test this new API.\n    */\n   png_set_text_compression_strategy(write_ptr, Z_FILTERED);\n#endif\n\n   /* When the unknown vpAg/sTER chunks are written by pngtest the only way to\n    * do it is to write them *before* calling png_write_end.  When unknown\n    * chunks are written by libpng, however, they are written just before IEND.\n    * There seems to be no way round this, however vpAg/sTER are not expected\n    * after IDAT.\n    */\n   write_chunks(write_ptr, after_IDAT);\n\n   png_write_end(write_ptr, write_end_info_ptr);\n#endif\n\n#ifdef PNG_EASY_ACCESS_SUPPORTED\n   if (verbose)\n   {\n      png_uint_32 iwidth, iheight;\n      iwidth = png_get_image_width(write_ptr, write_info_ptr);\n      iheight = png_get_image_height(write_ptr, write_info_ptr);\n      fprintf(STDERR, \"\\n Image width = %lu, height = %lu\\n\",\n         (unsigned long)iwidth, (unsigned long)iheight);\n   }\n#endif\n\n   pngtest_debug(\"Destroying data structs\");\n#ifdef SINGLE_ROWBUF_ALLOC\n   pngtest_debug(\"destroying row_buf for read_ptr\");\n   png_free(read_ptr, row_buf);\n   row_buf = NULL;\n#endif /* SINGLE_ROWBUF_ALLOC */\n   pngtest_debug(\"destroying read_ptr, read_info_ptr, end_info_ptr\");\n   png_destroy_read_struct(&read_ptr, &read_info_ptr, &end_info_ptr);\n#ifdef PNG_WRITE_SUPPORTED\n   pngtest_debug(\"destroying write_end_info_ptr\");\n   png_destroy_info_struct(write_ptr, &write_end_info_ptr);\n   pngtest_debug(\"destroying write_ptr, write_info_ptr\");\n   png_destroy_write_struct(&write_ptr, &write_info_ptr);\n#endif\n   pngtest_debug(\"Destruction complete.\");\n\n   FCLOSE(fpin);\n   FCLOSE(fpout);\n\n   /* Summarize any warnings or errors and in 'strict' mode fail the test.\n    * Unsupported chunks can result in warnings, in that case ignore the strict\n    * setting, otherwise fail the test on warnings as well as errors.\n    */\n   if (error_count > 0)\n   {\n      /* We don't really expect to get here because of the setjmp handling\n       * above, but this is safe.\n       */\n      fprintf(STDERR, \"\\n  %s: %d libpng errors found (%d warnings)\",\n         inname, error_count, warning_count);\n\n      if (strict != 0)\n         return (1);\n   }\n\n#  ifdef PNG_WRITE_SUPPORTED\n      /* If there we no write support nothing was written! */\n      else if (unsupported_chunks > 0)\n      {\n         fprintf(STDERR, \"\\n  %s: unsupported chunks (%d)%s\",\n            inname, unsupported_chunks, strict ? \": IGNORED --strict!\" : \"\");\n      }\n#  endif\n\n   else if (warning_count > 0)\n   {\n      fprintf(STDERR, \"\\n  %s: %d libpng warnings found\",\n         inname, warning_count);\n\n      if (strict != 0)\n         return (1);\n   }\n\n   pngtest_debug(\"Opening files for comparison\");\n   if ((fpin = fopen(inname, \"rb\")) == NULL)\n   {\n      fprintf(STDERR, \"Could not find file %s\\n\", inname);\n      return (1);\n   }\n\n   if ((fpout = fopen(outname, \"rb\")) == NULL)\n   {\n      fprintf(STDERR, \"Could not find file %s\\n\", outname);\n      FCLOSE(fpin);\n      return (1);\n   }\n\n#ifdef PNG_WRITE_SUPPORTED /* else nothing was written */\n   if (interlace_preserved) /* else the files will be changed */\n   {\n      for (;;)\n      {\n         static int wrote_question = 0;\n         png_size_t num_in, num_out;\n         char inbuf[256], outbuf[256];\n\n         num_in = fread(inbuf, 1, sizeof inbuf, fpin);\n         num_out = fread(outbuf, 1, sizeof outbuf, fpout);\n\n         if (num_in != num_out)\n         {\n            fprintf(STDERR, \"\\nFiles %s and %s are of a different size\\n\",\n                    inname, outname);\n\n            if (wrote_question == 0 && unsupported_chunks == 0)\n            {\n               fprintf(STDERR,\n         \"   Was %s written with the same maximum IDAT chunk size (%d bytes),\",\n                 inname, PNG_ZBUF_SIZE);\n               fprintf(STDERR,\n                 \"\\n   filtering heuristic (libpng default), compression\");\n               fprintf(STDERR,\n                 \" level (zlib default),\\n   and zlib version (%s)?\\n\\n\",\n                 ZLIB_VERSION);\n               wrote_question = 1;\n            }\n\n            FCLOSE(fpin);\n            FCLOSE(fpout);\n\n            if (strict != 0 && unsupported_chunks == 0)\n              return (1);\n\n            else\n              return (0);\n         }\n\n         if (!num_in)\n            break;\n\n         if (memcmp(inbuf, outbuf, num_in))\n         {\n            fprintf(STDERR, \"\\nFiles %s and %s are different\\n\", inname,\n               outname);\n\n            if (wrote_question == 0 && unsupported_chunks == 0)\n            {\n               fprintf(STDERR,\n         \"   Was %s written with the same maximum IDAT chunk size (%d bytes),\",\n                    inname, PNG_ZBUF_SIZE);\n               fprintf(STDERR,\n                 \"\\n   filtering heuristic (libpng default), compression\");\n               fprintf(STDERR,\n                 \" level (zlib default),\\n   and zlib version (%s)?\\n\\n\",\n                 ZLIB_VERSION);\n               wrote_question = 1;\n            }\n\n            FCLOSE(fpin);\n            FCLOSE(fpout);\n\n            /* NOTE: the unsupported_chunks escape is permitted here because\n             * unsupported text chunk compression will result in the compression\n             * mode being changed (to NONE) yet, in the test case, the result\n             * can be exactly the same size!\n             */\n            if (strict != 0 && unsupported_chunks == 0)\n              return (1);\n\n            else\n              return (0);\n         }\n      }\n   }\n#endif /* PNG_WRITE_SUPPORTED */\n\n   FCLOSE(fpin);\n   FCLOSE(fpout);\n\n   return (0);\n}\n\n/* Input and output filenames */\n#ifdef RISCOS\nstatic PNG_CONST char *inname = \"pngtest/png\";\nstatic PNG_CONST char *outname = \"pngout/png\";\n#else\nstatic PNG_CONST char *inname = \"pngtest.png\";\nstatic PNG_CONST char *outname = \"pngout.png\";\n#endif\n\nint\nmain(int argc, char *argv[])\n{\n   int multiple = 0;\n   int ierror = 0;\n\n   fprintf(STDERR, \"\\n Testing libpng version %s\\n\", PNG_LIBPNG_VER_STRING);\n   fprintf(STDERR, \"   with zlib   version %s\\n\", ZLIB_VERSION);\n   fprintf(STDERR, \"%s\", png_get_copyright(NULL));\n   /* Show the version of libpng used in building the library */\n   fprintf(STDERR, \" library (%lu):%s\",\n      (unsigned long)png_access_version_number(),\n      png_get_header_version(NULL));\n\n   /* Show the version of libpng used in building the application */\n   fprintf(STDERR, \" pngtest (%lu):%s\", (unsigned long)PNG_LIBPNG_VER,\n      PNG_HEADER_VERSION_STRING);\n\n   /* Do some consistency checking on the memory allocation settings, I'm\n    * not sure this matters, but it is nice to know, the first of these\n    * tests should be impossible because of the way the macros are set\n    * in pngconf.h\n    */\n#if defined(MAXSEG_64K) && !defined(PNG_MAX_MALLOC_64K)\n      fprintf(STDERR, \" NOTE: Zlib compiled for max 64k, libpng not\\n\");\n#endif\n   /* I think the following can happen. */\n#if !defined(MAXSEG_64K) && defined(PNG_MAX_MALLOC_64K)\n      fprintf(STDERR, \" NOTE: libpng compiled for max 64k, zlib not\\n\");\n#endif\n\n   if (strcmp(png_libpng_ver, PNG_LIBPNG_VER_STRING))\n   {\n      fprintf(STDERR,\n         \"Warning: versions are different between png.h and png.c\\n\");\n      fprintf(STDERR, \"  png.h version: %s\\n\", PNG_LIBPNG_VER_STRING);\n      fprintf(STDERR, \"  png.c version: %s\\n\\n\", png_libpng_ver);\n      ++ierror;\n   }\n\n   if (argc > 1)\n   {\n      if (strcmp(argv[1], \"-m\") == 0)\n      {\n         multiple = 1;\n         status_dots_requested = 0;\n      }\n\n      else if (strcmp(argv[1], \"-mv\") == 0 ||\n               strcmp(argv[1], \"-vm\") == 0 )\n      {\n         multiple = 1;\n         verbose = 1;\n         status_dots_requested = 1;\n      }\n\n      else if (strcmp(argv[1], \"-v\") == 0)\n      {\n         verbose = 1;\n         status_dots_requested = 1;\n         inname = argv[2];\n      }\n\n      else if (strcmp(argv[1], \"--strict\") == 0)\n      {\n         status_dots_requested = 0;\n         verbose = 1;\n         inname = argv[2];\n         strict++;\n         relaxed = 0;\n      }\n\n      else if (strcmp(argv[1], \"--relaxed\") == 0)\n      {\n         status_dots_requested = 0;\n         verbose = 1;\n         inname = argv[2];\n         strict = 0;\n         relaxed++;\n      }\n\n      else\n      {\n         inname = argv[1];\n         status_dots_requested = 0;\n      }\n   }\n\n   if (!multiple && argc == 3 + verbose)\n     outname = argv[2 + verbose];\n\n   if ((!multiple && argc > 3 + verbose) || (multiple && argc < 2))\n   {\n     fprintf(STDERR,\n       \"usage: %s [infile.png] [outfile.png]\\n\\t%s -m {infile.png}\\n\",\n        argv[0], argv[0]);\n     fprintf(STDERR,\n       \"  reads/writes one PNG file (without -m) or multiple files (-m)\\n\");\n     fprintf(STDERR,\n       \"  with -m %s is used as a temporary file\\n\", outname);\n     exit(1);\n   }\n\n   if (multiple)\n   {\n      int i;\n#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG\n      int allocation_now = current_allocation;\n#endif\n      for (i=2; i<argc; ++i)\n      {\n         int kerror;\n         fprintf(STDERR, \"\\n Testing %s:\", argv[i]);\n         kerror = test_one_file(argv[i], outname);\n         if (kerror == 0)\n         {\n#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED\n            int k;\n#endif\n#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED\n            fprintf(STDERR, \"\\n PASS (%lu zero samples)\\n\",\n               (unsigned long)zero_samples);\n#else\n            fprintf(STDERR, \" PASS\\n\");\n#endif\n#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED\n            for (k = 0; k<256; k++)\n               if (filters_used[k])\n                  fprintf(STDERR, \" Filter %d was used %lu times\\n\",\n                     k, (unsigned long)filters_used[k]);\n#endif\n#ifdef PNG_TIME_RFC1123_SUPPORTED\n         if (tIME_chunk_present != 0)\n            fprintf(STDERR, \" tIME = %s\\n\", tIME_string);\n\n         tIME_chunk_present = 0;\n#endif /* PNG_TIME_RFC1123_SUPPORTED */\n         }\n\n         else\n         {\n            fprintf(STDERR, \" FAIL\\n\");\n            ierror += kerror;\n         }\n#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG\n         if (allocation_now != current_allocation)\n            fprintf(STDERR, \"MEMORY ERROR: %d bytes lost\\n\",\n               current_allocation - allocation_now);\n\n         if (current_allocation != 0)\n         {\n            memory_infop pinfo = pinformation;\n\n            fprintf(STDERR, \"MEMORY ERROR: %d bytes still allocated\\n\",\n               current_allocation);\n\n            while (pinfo != NULL)\n            {\n               fprintf(STDERR, \" %lu bytes at %x\\n\",\n                 (unsigned long)pinfo->size,\n                 (unsigned int)pinfo->pointer);\n               pinfo = pinfo->next;\n            }\n         }\n#endif\n      }\n#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG\n         fprintf(STDERR, \" Current memory allocation: %10d bytes\\n\",\n            current_allocation);\n         fprintf(STDERR, \" Maximum memory allocation: %10d bytes\\n\",\n            maximum_allocation);\n         fprintf(STDERR, \" Total   memory allocation: %10d bytes\\n\",\n            total_allocation);\n         fprintf(STDERR, \"     Number of allocations: %10d\\n\",\n            num_allocations);\n#endif\n   }\n\n   else\n   {\n      int i;\n      for (i = 0; i<3; ++i)\n      {\n         int kerror;\n#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG\n         int allocation_now = current_allocation;\n#endif\n         if (i == 1)\n            status_dots_requested = 1;\n\n         else if (verbose == 0)\n            status_dots_requested = 0;\n\n         if (i == 0 || verbose == 1 || ierror != 0)\n            fprintf(STDERR, \"\\n Testing %s:\", inname);\n\n         kerror = test_one_file(inname, outname);\n\n         if (kerror == 0)\n         {\n            if (verbose == 1 || i == 2)\n            {\n#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED\n                int k;\n#endif\n#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED\n                fprintf(STDERR, \"\\n PASS (%lu zero samples)\\n\",\n                   (unsigned long)zero_samples);\n#else\n                fprintf(STDERR, \" PASS\\n\");\n#endif\n#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED\n                for (k = 0; k<256; k++)\n                   if (filters_used[k])\n                      fprintf(STDERR, \" Filter %d was used %lu times\\n\",\n                         k, (unsigned long)filters_used[k]);\n#endif\n#ifdef PNG_TIME_RFC1123_SUPPORTED\n             if (tIME_chunk_present != 0)\n                fprintf(STDERR, \" tIME = %s\\n\", tIME_string);\n#endif /* PNG_TIME_RFC1123_SUPPORTED */\n            }\n         }\n\n         else\n         {\n            if (verbose == 0 && i != 2)\n               fprintf(STDERR, \"\\n Testing %s:\", inname);\n\n            fprintf(STDERR, \" FAIL\\n\");\n            ierror += kerror;\n         }\n#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG\n         if (allocation_now != current_allocation)\n             fprintf(STDERR, \"MEMORY ERROR: %d bytes lost\\n\",\n               current_allocation - allocation_now);\n\n         if (current_allocation != 0)\n         {\n             memory_infop pinfo = pinformation;\n\n             fprintf(STDERR, \"MEMORY ERROR: %d bytes still allocated\\n\",\n                current_allocation);\n\n             while (pinfo != NULL)\n             {\n                fprintf(STDERR, \" %lu bytes at %x\\n\",\n                   (unsigned long)pinfo->size, (unsigned int)pinfo->pointer);\n                pinfo = pinfo->next;\n             }\n          }\n#endif\n       }\n#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG\n       fprintf(STDERR, \" Current memory allocation: %10d bytes\\n\",\n          current_allocation);\n       fprintf(STDERR, \" Maximum memory allocation: %10d bytes\\n\",\n          maximum_allocation);\n       fprintf(STDERR, \" Total   memory allocation: %10d bytes\\n\",\n          total_allocation);\n       fprintf(STDERR, \"     Number of allocations: %10d\\n\",\n            num_allocations);\n#endif\n   }\n\n#ifdef PNGTEST_TIMING\n   t_stop = (float)clock();\n   t_misc += (t_stop - t_start);\n   t_start = t_stop;\n   fprintf(STDERR, \" CPU time used = %.3f seconds\",\n      (t_misc+t_decode+t_encode)/(float)CLOCKS_PER_SEC);\n   fprintf(STDERR, \" (decoding %.3f,\\n\",\n      t_decode/(float)CLOCKS_PER_SEC);\n   fprintf(STDERR, \"        encoding %.3f ,\",\n      t_encode/(float)CLOCKS_PER_SEC);\n   fprintf(STDERR, \" other %.3f seconds)\\n\\n\",\n      t_misc/(float)CLOCKS_PER_SEC);\n#endif\n\n   if (ierror == 0)\n      fprintf(STDERR, \" libpng passes test\\n\");\n\n   else\n      fprintf(STDERR, \" libpng FAILS test\\n\");\n\n   return (int)(ierror != 0);\n}\n#else\nint\nmain(void)\n{\n   fprintf(STDERR,\n      \" test ignored because libpng was not built with read support\\n\");\n   /* And skip this test */\n   return PNG_LIBPNG_VER < 10600 ? 0 : 77;\n}\n#endif\n\n/* Generate a compiler error if there is an old png.h in the search path. */\ntypedef png_libpng_version_1_6_10 Your_png_h_is_not_version_1_6_10;\n"
  },
  {
    "path": "Projects/Libraries/CSBase/Source/png/pngtrans.c",
    "content": "\n/* pngtrans.c - transforms the data in a row (used by both readers and writers)\n *\n * Last changed in libpng 1.6.9 [February 6, 2014]\n * Copyright (c) 1998-2014 Glenn Randers-Pehrson\n * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)\n * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)\n *\n * This code is released under the libpng license.\n * For conditions of distribution and use, see the disclaimer\n * and license in png.h\n */\n\n#include \"pngpriv.h\"\n\n#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)\n\n#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED)\n/* Turn on BGR-to-RGB mapping */\nvoid PNGAPI\npng_set_bgr(png_structrp png_ptr)\n{\n   png_debug(1, \"in png_set_bgr\");\n\n   if (png_ptr == NULL)\n      return;\n\n   png_ptr->transformations |= PNG_BGR;\n}\n#endif\n\n#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED)\n/* Turn on 16 bit byte swapping */\nvoid PNGAPI\npng_set_swap(png_structrp png_ptr)\n{\n   png_debug(1, \"in png_set_swap\");\n\n   if (png_ptr == NULL)\n      return;\n\n   if (png_ptr->bit_depth == 16)\n      png_ptr->transformations |= PNG_SWAP_BYTES;\n}\n#endif\n\n#if defined(PNG_READ_PACK_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED)\n/* Turn on pixel packing */\nvoid PNGAPI\npng_set_packing(png_structrp png_ptr)\n{\n   png_debug(1, \"in png_set_packing\");\n\n   if (png_ptr == NULL)\n      return;\n\n   if (png_ptr->bit_depth < 8)\n   {\n      png_ptr->transformations |= PNG_PACK;\n#     ifdef PNG_WRITE_SUPPORTED\n         png_ptr->usr_bit_depth = 8;\n#     endif\n   }\n}\n#endif\n\n#if defined(PNG_READ_PACKSWAP_SUPPORTED)||defined(PNG_WRITE_PACKSWAP_SUPPORTED)\n/* Turn on packed pixel swapping */\nvoid PNGAPI\npng_set_packswap(png_structrp png_ptr)\n{\n   png_debug(1, \"in png_set_packswap\");\n\n   if (png_ptr == NULL)\n      return;\n\n   if (png_ptr->bit_depth < 8)\n      png_ptr->transformations |= PNG_PACKSWAP;\n}\n#endif\n\n#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED)\nvoid PNGAPI\npng_set_shift(png_structrp png_ptr, png_const_color_8p true_bits)\n{\n   png_debug(1, \"in png_set_shift\");\n\n   if (png_ptr == NULL)\n      return;\n\n   png_ptr->transformations |= PNG_SHIFT;\n   png_ptr->shift = *true_bits;\n}\n#endif\n\n#if defined(PNG_READ_INTERLACING_SUPPORTED) || \\\n    defined(PNG_WRITE_INTERLACING_SUPPORTED)\nint PNGAPI\npng_set_interlace_handling(png_structrp png_ptr)\n{\n   png_debug(1, \"in png_set_interlace handling\");\n\n   if (png_ptr && png_ptr->interlaced)\n   {\n      png_ptr->transformations |= PNG_INTERLACE;\n      return (7);\n   }\n\n   return (1);\n}\n#endif\n\n#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED)\n/* Add a filler byte on read, or remove a filler or alpha byte on write.\n * The filler type has changed in v0.95 to allow future 2-byte fillers\n * for 48-bit input data, as well as to avoid problems with some compilers\n * that don't like bytes as parameters.\n */\nvoid PNGAPI\npng_set_filler(png_structrp png_ptr, png_uint_32 filler, int filler_loc)\n{\n   png_debug(1, \"in png_set_filler\");\n\n   if (png_ptr == NULL)\n      return;\n\n   /* In libpng 1.6 it is possible to determine whether this is a read or write\n    * operation and therefore to do more checking here for a valid call.\n    */\n   if (png_ptr->mode & PNG_IS_READ_STRUCT)\n   {\n#     ifdef PNG_READ_FILLER_SUPPORTED\n         /* On read png_set_filler is always valid, regardless of the base PNG\n          * format, because other transformations can give a format where the\n          * filler code can execute (basically an 8 or 16-bit component RGB or G\n          * format.)\n          *\n          * NOTE: usr_channels is not used by the read code!  (This has led to\n          * confusion in the past.)  The filler is only used in the read code.\n          */\n         png_ptr->filler = (png_uint_16)filler;\n#     else\n         png_app_error(png_ptr, \"png_set_filler not supported on read\");\n         PNG_UNUSED(filler) /* not used in the write case */\n         return;\n#     endif\n   }\n\n   else /* write */\n   {\n#     ifdef PNG_WRITE_FILLER_SUPPORTED\n         /* On write the usr_channels parameter must be set correctly at the\n          * start to record the number of channels in the app-supplied data.\n          */\n         switch (png_ptr->color_type)\n         {\n            case PNG_COLOR_TYPE_RGB:\n               png_ptr->usr_channels = 4;\n               break;\n\n            case PNG_COLOR_TYPE_GRAY:\n               if (png_ptr->bit_depth >= 8)\n               {\n                  png_ptr->usr_channels = 2;\n                  break;\n               }\n\n               else\n               {\n                  /* There simply isn't any code in libpng to strip out bits\n                   * from bytes when the components are less than a byte in\n                   * size!\n                   */\n                  png_app_error(png_ptr,\n                     \"png_set_filler is invalid for low bit depth gray output\");\n                  return;\n               }\n\n            default:\n               png_app_error(png_ptr,\n                  \"png_set_filler: inappropriate color type\");\n               return;\n         }\n#     else\n         png_app_error(png_ptr, \"png_set_filler not supported on write\");\n         return;\n#     endif\n   }\n\n   /* Here on success - libpng supports the operation, set the transformation\n    * and the flag to say where the filler channel is.\n    */\n   png_ptr->transformations |= PNG_FILLER;\n\n   if (filler_loc == PNG_FILLER_AFTER)\n      png_ptr->flags |= PNG_FLAG_FILLER_AFTER;\n\n   else\n      png_ptr->flags &= ~PNG_FLAG_FILLER_AFTER;\n}\n\n/* Added to libpng-1.2.7 */\nvoid PNGAPI\npng_set_add_alpha(png_structrp png_ptr, png_uint_32 filler, int filler_loc)\n{\n   png_debug(1, \"in png_set_add_alpha\");\n\n   if (png_ptr == NULL)\n      return;\n\n   png_set_filler(png_ptr, filler, filler_loc);\n   /* The above may fail to do anything. */\n   if (png_ptr->transformations & PNG_FILLER)\n      png_ptr->transformations |= PNG_ADD_ALPHA;\n}\n\n#endif\n\n#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) || \\\n    defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED)\nvoid PNGAPI\npng_set_swap_alpha(png_structrp png_ptr)\n{\n   png_debug(1, \"in png_set_swap_alpha\");\n\n   if (png_ptr == NULL)\n      return;\n\n   png_ptr->transformations |= PNG_SWAP_ALPHA;\n}\n#endif\n\n#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) || \\\n    defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED)\nvoid PNGAPI\npng_set_invert_alpha(png_structrp png_ptr)\n{\n   png_debug(1, \"in png_set_invert_alpha\");\n\n   if (png_ptr == NULL)\n      return;\n\n   png_ptr->transformations |= PNG_INVERT_ALPHA;\n}\n#endif\n\n#if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED)\nvoid PNGAPI\npng_set_invert_mono(png_structrp png_ptr)\n{\n   png_debug(1, \"in png_set_invert_mono\");\n\n   if (png_ptr == NULL)\n      return;\n\n   png_ptr->transformations |= PNG_INVERT_MONO;\n}\n\n/* Invert monochrome grayscale data */\nvoid /* PRIVATE */\npng_do_invert(png_row_infop row_info, png_bytep row)\n{\n   png_debug(1, \"in png_do_invert\");\n\n  /* This test removed from libpng version 1.0.13 and 1.2.0:\n   *   if (row_info->bit_depth == 1 &&\n   */\n   if (row_info->color_type == PNG_COLOR_TYPE_GRAY)\n   {\n      png_bytep rp = row;\n      png_size_t i;\n      png_size_t istop = row_info->rowbytes;\n\n      for (i = 0; i < istop; i++)\n      {\n         *rp = (png_byte)(~(*rp));\n         rp++;\n      }\n   }\n\n   else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA &&\n      row_info->bit_depth == 8)\n   {\n      png_bytep rp = row;\n      png_size_t i;\n      png_size_t istop = row_info->rowbytes;\n\n      for (i = 0; i < istop; i += 2)\n      {\n         *rp = (png_byte)(~(*rp));\n         rp += 2;\n      }\n   }\n\n#ifdef PNG_16BIT_SUPPORTED\n   else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA &&\n      row_info->bit_depth == 16)\n   {\n      png_bytep rp = row;\n      png_size_t i;\n      png_size_t istop = row_info->rowbytes;\n\n      for (i = 0; i < istop; i += 4)\n      {\n         *rp = (png_byte)(~(*rp));\n         *(rp + 1) = (png_byte)(~(*(rp + 1)));\n         rp += 4;\n      }\n   }\n#endif\n}\n#endif\n\n#ifdef PNG_16BIT_SUPPORTED\n#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED)\n/* Swaps byte order on 16 bit depth images */\nvoid /* PRIVATE */\npng_do_swap(png_row_infop row_info, png_bytep row)\n{\n   png_debug(1, \"in png_do_swap\");\n\n   if (row_info->bit_depth == 16)\n   {\n      png_bytep rp = row;\n      png_uint_32 i;\n      png_uint_32 istop= row_info->width * row_info->channels;\n\n      for (i = 0; i < istop; i++, rp += 2)\n      {\n         png_byte t = *rp;\n         *rp = *(rp + 1);\n         *(rp + 1) = t;\n      }\n   }\n}\n#endif\n#endif\n\n#if defined(PNG_READ_PACKSWAP_SUPPORTED)||defined(PNG_WRITE_PACKSWAP_SUPPORTED)\nstatic PNG_CONST png_byte onebppswaptable[256] = {\n   0x00, 0x80, 0x40, 0xC0, 0x20, 0xA0, 0x60, 0xE0,\n   0x10, 0x90, 0x50, 0xD0, 0x30, 0xB0, 0x70, 0xF0,\n   0x08, 0x88, 0x48, 0xC8, 0x28, 0xA8, 0x68, 0xE8,\n   0x18, 0x98, 0x58, 0xD8, 0x38, 0xB8, 0x78, 0xF8,\n   0x04, 0x84, 0x44, 0xC4, 0x24, 0xA4, 0x64, 0xE4,\n   0x14, 0x94, 0x54, 0xD4, 0x34, 0xB4, 0x74, 0xF4,\n   0x0C, 0x8C, 0x4C, 0xCC, 0x2C, 0xAC, 0x6C, 0xEC,\n   0x1C, 0x9C, 0x5C, 0xDC, 0x3C, 0xBC, 0x7C, 0xFC,\n   0x02, 0x82, 0x42, 0xC2, 0x22, 0xA2, 0x62, 0xE2,\n   0x12, 0x92, 0x52, 0xD2, 0x32, 0xB2, 0x72, 0xF2,\n   0x0A, 0x8A, 0x4A, 0xCA, 0x2A, 0xAA, 0x6A, 0xEA,\n   0x1A, 0x9A, 0x5A, 0xDA, 0x3A, 0xBA, 0x7A, 0xFA,\n   0x06, 0x86, 0x46, 0xC6, 0x26, 0xA6, 0x66, 0xE6,\n   0x16, 0x96, 0x56, 0xD6, 0x36, 0xB6, 0x76, 0xF6,\n   0x0E, 0x8E, 0x4E, 0xCE, 0x2E, 0xAE, 0x6E, 0xEE,\n   0x1E, 0x9E, 0x5E, 0xDE, 0x3E, 0xBE, 0x7E, 0xFE,\n   0x01, 0x81, 0x41, 0xC1, 0x21, 0xA1, 0x61, 0xE1,\n   0x11, 0x91, 0x51, 0xD1, 0x31, 0xB1, 0x71, 0xF1,\n   0x09, 0x89, 0x49, 0xC9, 0x29, 0xA9, 0x69, 0xE9,\n   0x19, 0x99, 0x59, 0xD9, 0x39, 0xB9, 0x79, 0xF9,\n   0x05, 0x85, 0x45, 0xC5, 0x25, 0xA5, 0x65, 0xE5,\n   0x15, 0x95, 0x55, 0xD5, 0x35, 0xB5, 0x75, 0xF5,\n   0x0D, 0x8D, 0x4D, 0xCD, 0x2D, 0xAD, 0x6D, 0xED,\n   0x1D, 0x9D, 0x5D, 0xDD, 0x3D, 0xBD, 0x7D, 0xFD,\n   0x03, 0x83, 0x43, 0xC3, 0x23, 0xA3, 0x63, 0xE3,\n   0x13, 0x93, 0x53, 0xD3, 0x33, 0xB3, 0x73, 0xF3,\n   0x0B, 0x8B, 0x4B, 0xCB, 0x2B, 0xAB, 0x6B, 0xEB,\n   0x1B, 0x9B, 0x5B, 0xDB, 0x3B, 0xBB, 0x7B, 0xFB,\n   0x07, 0x87, 0x47, 0xC7, 0x27, 0xA7, 0x67, 0xE7,\n   0x17, 0x97, 0x57, 0xD7, 0x37, 0xB7, 0x77, 0xF7,\n   0x0F, 0x8F, 0x4F, 0xCF, 0x2F, 0xAF, 0x6F, 0xEF,\n   0x1F, 0x9F, 0x5F, 0xDF, 0x3F, 0xBF, 0x7F, 0xFF\n};\n\nstatic PNG_CONST png_byte twobppswaptable[256] = {\n   0x00, 0x40, 0x80, 0xC0, 0x10, 0x50, 0x90, 0xD0,\n   0x20, 0x60, 0xA0, 0xE0, 0x30, 0x70, 0xB0, 0xF0,\n   0x04, 0x44, 0x84, 0xC4, 0x14, 0x54, 0x94, 0xD4,\n   0x24, 0x64, 0xA4, 0xE4, 0x34, 0x74, 0xB4, 0xF4,\n   0x08, 0x48, 0x88, 0xC8, 0x18, 0x58, 0x98, 0xD8,\n   0x28, 0x68, 0xA8, 0xE8, 0x38, 0x78, 0xB8, 0xF8,\n   0x0C, 0x4C, 0x8C, 0xCC, 0x1C, 0x5C, 0x9C, 0xDC,\n   0x2C, 0x6C, 0xAC, 0xEC, 0x3C, 0x7C, 0xBC, 0xFC,\n   0x01, 0x41, 0x81, 0xC1, 0x11, 0x51, 0x91, 0xD1,\n   0x21, 0x61, 0xA1, 0xE1, 0x31, 0x71, 0xB1, 0xF1,\n   0x05, 0x45, 0x85, 0xC5, 0x15, 0x55, 0x95, 0xD5,\n   0x25, 0x65, 0xA5, 0xE5, 0x35, 0x75, 0xB5, 0xF5,\n   0x09, 0x49, 0x89, 0xC9, 0x19, 0x59, 0x99, 0xD9,\n   0x29, 0x69, 0xA9, 0xE9, 0x39, 0x79, 0xB9, 0xF9,\n   0x0D, 0x4D, 0x8D, 0xCD, 0x1D, 0x5D, 0x9D, 0xDD,\n   0x2D, 0x6D, 0xAD, 0xED, 0x3D, 0x7D, 0xBD, 0xFD,\n   0x02, 0x42, 0x82, 0xC2, 0x12, 0x52, 0x92, 0xD2,\n   0x22, 0x62, 0xA2, 0xE2, 0x32, 0x72, 0xB2, 0xF2,\n   0x06, 0x46, 0x86, 0xC6, 0x16, 0x56, 0x96, 0xD6,\n   0x26, 0x66, 0xA6, 0xE6, 0x36, 0x76, 0xB6, 0xF6,\n   0x0A, 0x4A, 0x8A, 0xCA, 0x1A, 0x5A, 0x9A, 0xDA,\n   0x2A, 0x6A, 0xAA, 0xEA, 0x3A, 0x7A, 0xBA, 0xFA,\n   0x0E, 0x4E, 0x8E, 0xCE, 0x1E, 0x5E, 0x9E, 0xDE,\n   0x2E, 0x6E, 0xAE, 0xEE, 0x3E, 0x7E, 0xBE, 0xFE,\n   0x03, 0x43, 0x83, 0xC3, 0x13, 0x53, 0x93, 0xD3,\n   0x23, 0x63, 0xA3, 0xE3, 0x33, 0x73, 0xB3, 0xF3,\n   0x07, 0x47, 0x87, 0xC7, 0x17, 0x57, 0x97, 0xD7,\n   0x27, 0x67, 0xA7, 0xE7, 0x37, 0x77, 0xB7, 0xF7,\n   0x0B, 0x4B, 0x8B, 0xCB, 0x1B, 0x5B, 0x9B, 0xDB,\n   0x2B, 0x6B, 0xAB, 0xEB, 0x3B, 0x7B, 0xBB, 0xFB,\n   0x0F, 0x4F, 0x8F, 0xCF, 0x1F, 0x5F, 0x9F, 0xDF,\n   0x2F, 0x6F, 0xAF, 0xEF, 0x3F, 0x7F, 0xBF, 0xFF\n};\n\nstatic PNG_CONST png_byte fourbppswaptable[256] = {\n   0x00, 0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70,\n   0x80, 0x90, 0xA0, 0xB0, 0xC0, 0xD0, 0xE0, 0xF0,\n   0x01, 0x11, 0x21, 0x31, 0x41, 0x51, 0x61, 0x71,\n   0x81, 0x91, 0xA1, 0xB1, 0xC1, 0xD1, 0xE1, 0xF1,\n   0x02, 0x12, 0x22, 0x32, 0x42, 0x52, 0x62, 0x72,\n   0x82, 0x92, 0xA2, 0xB2, 0xC2, 0xD2, 0xE2, 0xF2,\n   0x03, 0x13, 0x23, 0x33, 0x43, 0x53, 0x63, 0x73,\n   0x83, 0x93, 0xA3, 0xB3, 0xC3, 0xD3, 0xE3, 0xF3,\n   0x04, 0x14, 0x24, 0x34, 0x44, 0x54, 0x64, 0x74,\n   0x84, 0x94, 0xA4, 0xB4, 0xC4, 0xD4, 0xE4, 0xF4,\n   0x05, 0x15, 0x25, 0x35, 0x45, 0x55, 0x65, 0x75,\n   0x85, 0x95, 0xA5, 0xB5, 0xC5, 0xD5, 0xE5, 0xF5,\n   0x06, 0x16, 0x26, 0x36, 0x46, 0x56, 0x66, 0x76,\n   0x86, 0x96, 0xA6, 0xB6, 0xC6, 0xD6, 0xE6, 0xF6,\n   0x07, 0x17, 0x27, 0x37, 0x47, 0x57, 0x67, 0x77,\n   0x87, 0x97, 0xA7, 0xB7, 0xC7, 0xD7, 0xE7, 0xF7,\n   0x08, 0x18, 0x28, 0x38, 0x48, 0x58, 0x68, 0x78,\n   0x88, 0x98, 0xA8, 0xB8, 0xC8, 0xD8, 0xE8, 0xF8,\n   0x09, 0x19, 0x29, 0x39, 0x49, 0x59, 0x69, 0x79,\n   0x89, 0x99, 0xA9, 0xB9, 0xC9, 0xD9, 0xE9, 0xF9,\n   0x0A, 0x1A, 0x2A, 0x3A, 0x4A, 0x5A, 0x6A, 0x7A,\n   0x8A, 0x9A, 0xAA, 0xBA, 0xCA, 0xDA, 0xEA, 0xFA,\n   0x0B, 0x1B, 0x2B, 0x3B, 0x4B, 0x5B, 0x6B, 0x7B,\n   0x8B, 0x9B, 0xAB, 0xBB, 0xCB, 0xDB, 0xEB, 0xFB,\n   0x0C, 0x1C, 0x2C, 0x3C, 0x4C, 0x5C, 0x6C, 0x7C,\n   0x8C, 0x9C, 0xAC, 0xBC, 0xCC, 0xDC, 0xEC, 0xFC,\n   0x0D, 0x1D, 0x2D, 0x3D, 0x4D, 0x5D, 0x6D, 0x7D,\n   0x8D, 0x9D, 0xAD, 0xBD, 0xCD, 0xDD, 0xED, 0xFD,\n   0x0E, 0x1E, 0x2E, 0x3E, 0x4E, 0x5E, 0x6E, 0x7E,\n   0x8E, 0x9E, 0xAE, 0xBE, 0xCE, 0xDE, 0xEE, 0xFE,\n   0x0F, 0x1F, 0x2F, 0x3F, 0x4F, 0x5F, 0x6F, 0x7F,\n   0x8F, 0x9F, 0xAF, 0xBF, 0xCF, 0xDF, 0xEF, 0xFF\n};\n\n/* Swaps pixel packing order within bytes */\nvoid /* PRIVATE */\npng_do_packswap(png_row_infop row_info, png_bytep row)\n{\n   png_debug(1, \"in png_do_packswap\");\n\n   if (row_info->bit_depth < 8)\n   {\n      png_bytep rp;\n      png_const_bytep end, table;\n\n      end = row + row_info->rowbytes;\n\n      if (row_info->bit_depth == 1)\n         table = onebppswaptable;\n\n      else if (row_info->bit_depth == 2)\n         table = twobppswaptable;\n\n      else if (row_info->bit_depth == 4)\n         table = fourbppswaptable;\n\n      else\n         return;\n\n      for (rp = row; rp < end; rp++)\n         *rp = table[*rp];\n   }\n}\n#endif /* PNG_READ_PACKSWAP_SUPPORTED or PNG_WRITE_PACKSWAP_SUPPORTED */\n\n#if defined(PNG_WRITE_FILLER_SUPPORTED) || \\\n    defined(PNG_READ_STRIP_ALPHA_SUPPORTED)\n/* Remove a channel - this used to be 'png_do_strip_filler' but it used a\n * somewhat weird combination of flags to determine what to do.  All the calls\n * to png_do_strip_filler are changed in 1.5.2 to call this instead with the\n * correct arguments.\n *\n * The routine isn't general - the channel must be the channel at the start or\n * end (not in the middle) of each pixel.\n */\nvoid /* PRIVATE */\npng_do_strip_channel(png_row_infop row_info, png_bytep row, int at_start)\n{\n   png_bytep sp = row; /* source pointer */\n   png_bytep dp = row; /* destination pointer */\n   png_bytep ep = row + row_info->rowbytes; /* One beyond end of row */\n\n   /* At the start sp will point to the first byte to copy and dp to where\n    * it is copied to.  ep always points just beyond the end of the row, so\n    * the loop simply copies (channels-1) channels until sp reaches ep.\n    *\n    * at_start:        0 -- convert AG, XG, ARGB, XRGB, AAGG, XXGG, etc.\n    *            nonzero -- convert GA, GX, RGBA, RGBX, GGAA, RRGGBBXX, etc.\n    */\n\n   /* GA, GX, XG cases */\n   if (row_info->channels == 2)\n   {\n      if (row_info->bit_depth == 8)\n      {\n         if (at_start) /* Skip initial filler */\n            ++sp;\n         else          /* Skip initial channel and, for sp, the filler */\n            sp += 2, ++dp;\n\n         /* For a 1 pixel wide image there is nothing to do */\n         while (sp < ep)\n            *dp++ = *sp, sp += 2;\n\n         row_info->pixel_depth = 8;\n      }\n\n      else if (row_info->bit_depth == 16)\n      {\n         if (at_start) /* Skip initial filler */\n            sp += 2;\n         else          /* Skip initial channel and, for sp, the filler */\n            sp += 4, dp += 2;\n\n         while (sp < ep)\n            *dp++ = *sp++, *dp++ = *sp, sp += 3;\n\n         row_info->pixel_depth = 16;\n      }\n\n      else\n         return; /* bad bit depth */\n\n      row_info->channels = 1;\n\n      /* Finally fix the color type if it records an alpha channel */\n      if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)\n         row_info->color_type = PNG_COLOR_TYPE_GRAY;\n   }\n\n   /* RGBA, RGBX, XRGB cases */\n   else if (row_info->channels == 4)\n   {\n      if (row_info->bit_depth == 8)\n      {\n         if (at_start) /* Skip initial filler */\n            ++sp;\n         else          /* Skip initial channels and, for sp, the filler */\n            sp += 4, dp += 3;\n\n         /* Note that the loop adds 3 to dp and 4 to sp each time. */\n         while (sp < ep)\n            *dp++ = *sp++, *dp++ = *sp++, *dp++ = *sp, sp += 2;\n\n         row_info->pixel_depth = 24;\n      }\n\n      else if (row_info->bit_depth == 16)\n      {\n         if (at_start) /* Skip initial filler */\n            sp += 2;\n         else          /* Skip initial channels and, for sp, the filler */\n            sp += 8, dp += 6;\n\n         while (sp < ep)\n         {\n            /* Copy 6 bytes, skip 2 */\n            *dp++ = *sp++, *dp++ = *sp++;\n            *dp++ = *sp++, *dp++ = *sp++;\n            *dp++ = *sp++, *dp++ = *sp, sp += 3;\n         }\n\n         row_info->pixel_depth = 48;\n      }\n\n      else\n         return; /* bad bit depth */\n\n      row_info->channels = 3;\n\n      /* Finally fix the color type if it records an alpha channel */\n      if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)\n         row_info->color_type = PNG_COLOR_TYPE_RGB;\n   }\n\n   else\n      return; /* The filler channel has gone already */\n\n   /* Fix the rowbytes value. */\n   row_info->rowbytes = dp-row;\n}\n#endif\n\n#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED)\n/* Swaps red and blue bytes within a pixel */\nvoid /* PRIVATE */\npng_do_bgr(png_row_infop row_info, png_bytep row)\n{\n   png_debug(1, \"in png_do_bgr\");\n\n   if ((row_info->color_type & PNG_COLOR_MASK_COLOR))\n   {\n      png_uint_32 row_width = row_info->width;\n      if (row_info->bit_depth == 8)\n      {\n         if (row_info->color_type == PNG_COLOR_TYPE_RGB)\n         {\n            png_bytep rp;\n            png_uint_32 i;\n\n            for (i = 0, rp = row; i < row_width; i++, rp += 3)\n            {\n               png_byte save = *rp;\n               *rp = *(rp + 2);\n               *(rp + 2) = save;\n            }\n         }\n\n         else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)\n         {\n            png_bytep rp;\n            png_uint_32 i;\n\n            for (i = 0, rp = row; i < row_width; i++, rp += 4)\n            {\n               png_byte save = *rp;\n               *rp = *(rp + 2);\n               *(rp + 2) = save;\n            }\n         }\n      }\n\n#ifdef PNG_16BIT_SUPPORTED\n      else if (row_info->bit_depth == 16)\n      {\n         if (row_info->color_type == PNG_COLOR_TYPE_RGB)\n         {\n            png_bytep rp;\n            png_uint_32 i;\n\n            for (i = 0, rp = row; i < row_width; i++, rp += 6)\n            {\n               png_byte save = *rp;\n               *rp = *(rp + 4);\n               *(rp + 4) = save;\n               save = *(rp + 1);\n               *(rp + 1) = *(rp + 5);\n               *(rp + 5) = save;\n            }\n         }\n\n         else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)\n         {\n            png_bytep rp;\n            png_uint_32 i;\n\n            for (i = 0, rp = row; i < row_width; i++, rp += 8)\n            {\n               png_byte save = *rp;\n               *rp = *(rp + 4);\n               *(rp + 4) = save;\n               save = *(rp + 1);\n               *(rp + 1) = *(rp + 5);\n               *(rp + 5) = save;\n            }\n         }\n      }\n#endif\n   }\n}\n#endif /* PNG_READ_BGR_SUPPORTED or PNG_WRITE_BGR_SUPPORTED */\n\n#if defined(PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED) || \\\n    defined(PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED)\n/* Added at libpng-1.5.10 */\nvoid /* PRIVATE */\npng_do_check_palette_indexes(png_structrp png_ptr, png_row_infop row_info)\n{\n   if (png_ptr->num_palette < (1 << row_info->bit_depth) &&\n      png_ptr->num_palette > 0) /* num_palette can be 0 in MNG files */\n   {\n      /* Calculations moved outside switch in an attempt to stop different\n       * compiler warnings.  'padding' is in *bits* within the last byte, it is\n       * an 'int' because pixel_depth becomes an 'int' in the expression below,\n       * and this calculation is used because it avoids warnings that other\n       * forms produced on either GCC or MSVC.\n       */\n      int padding = (-row_info->pixel_depth * row_info->width) & 7;\n      png_bytep rp = png_ptr->row_buf + row_info->rowbytes;\n\n      switch (row_info->bit_depth)\n      {\n         case 1:\n         {\n            /* in this case, all bytes must be 0 so we don't need\n             * to unpack the pixels except for the rightmost one.\n             */\n            for (; rp > png_ptr->row_buf; rp--)\n            {\n              if (*rp >> padding != 0)\n                 png_ptr->num_palette_max = 1;\n              padding = 0;\n            }\n\n            break;\n         }\n\n         case 2:\n         {\n            for (; rp > png_ptr->row_buf; rp--)\n            {\n              int i = ((*rp >> padding) & 0x03);\n\n              if (i > png_ptr->num_palette_max)\n                 png_ptr->num_palette_max = i;\n\n              i = (((*rp >> padding) >> 2) & 0x03);\n\n              if (i > png_ptr->num_palette_max)\n                 png_ptr->num_palette_max = i;\n\n              i = (((*rp >> padding) >> 4) & 0x03);\n\n              if (i > png_ptr->num_palette_max)\n                 png_ptr->num_palette_max = i;\n\n              i = (((*rp >> padding) >> 6) & 0x03);\n\n              if (i > png_ptr->num_palette_max)\n                 png_ptr->num_palette_max = i;\n\n              padding = 0;\n            }\n\n            break;\n         }\n\n         case 4:\n         {\n            for (; rp > png_ptr->row_buf; rp--)\n            {\n              int i = ((*rp >> padding) & 0x0f);\n\n              if (i > png_ptr->num_palette_max)\n                 png_ptr->num_palette_max = i;\n\n              i = (((*rp >> padding) >> 4) & 0x0f);\n\n              if (i > png_ptr->num_palette_max)\n                 png_ptr->num_palette_max = i;\n\n              padding = 0;\n            }\n\n            break;\n         }\n\n         case 8:\n         {\n            for (; rp > png_ptr->row_buf; rp--)\n            {\n               if (*rp > png_ptr->num_palette_max)\n                  png_ptr->num_palette_max = (int) *rp;\n            }\n\n            break;\n         }\n\n         default:\n            break;\n      }\n   }\n}\n#endif /* PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED */\n\n#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \\\n    defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)\n#ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED\nvoid PNGAPI\npng_set_user_transform_info(png_structrp png_ptr, png_voidp\n   user_transform_ptr, int user_transform_depth, int user_transform_channels)\n{\n   png_debug(1, \"in png_set_user_transform_info\");\n\n   if (png_ptr == NULL)\n      return;\n\n#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED\n   if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0 &&\n      (png_ptr->flags & PNG_FLAG_ROW_INIT) != 0)\n   {\n      png_app_error(png_ptr,\n            \"info change after png_start_read_image or png_read_update_info\");\n      return;\n   }\n#endif\n\n   png_ptr->user_transform_ptr = user_transform_ptr;\n   png_ptr->user_transform_depth = (png_byte)user_transform_depth;\n   png_ptr->user_transform_channels = (png_byte)user_transform_channels;\n}\n#endif\n\n/* This function returns a pointer to the user_transform_ptr associated with\n * the user transform functions.  The application should free any memory\n * associated with this pointer before png_write_destroy and png_read_destroy\n * are called.\n */\n#ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED\npng_voidp PNGAPI\npng_get_user_transform_ptr(png_const_structrp png_ptr)\n{\n   if (png_ptr == NULL)\n      return (NULL);\n\n   return png_ptr->user_transform_ptr;\n}\n#endif\n\n#ifdef PNG_USER_TRANSFORM_INFO_SUPPORTED\npng_uint_32 PNGAPI\npng_get_current_row_number(png_const_structrp png_ptr)\n{\n   /* See the comments in png.h - this is the sub-image row when reading and\n    * interlaced image.\n    */\n   if (png_ptr != NULL)\n      return png_ptr->row_number;\n\n   return PNG_UINT_32_MAX; /* help the app not to fail silently */\n}\n\npng_byte PNGAPI\npng_get_current_pass_number(png_const_structrp png_ptr)\n{\n   if (png_ptr != NULL)\n      return png_ptr->pass;\n   return 8; /* invalid */\n}\n#endif /* PNG_USER_TRANSFORM_INFO_SUPPORTED */\n#endif /* PNG_READ_USER_TRANSFORM_SUPPORTED ||\n          PNG_WRITE_USER_TRANSFORM_SUPPORTED */\n#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */\n"
  },
  {
    "path": "Projects/Libraries/CSBase/Source/png/pngwio.c",
    "content": "\n/* pngwio.c - functions for data output\n *\n * Last changed in libpng 1.6.9 [February 6, 2014]\n * Copyright (c) 1998-2014 Glenn Randers-Pehrson\n * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)\n * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)\n *\n * This code is released under the libpng license.\n * For conditions of distribution and use, see the disclaimer\n * and license in png.h\n *\n * This file provides a location for all output.  Users who need\n * special handling are expected to write functions that have the same\n * arguments as these and perform similar functions, but that possibly\n * use different output methods.  Note that you shouldn't change these\n * functions, but rather write replacement functions and then change\n * them at run time with png_set_write_fn(...).\n */\n\n#include \"pngpriv.h\"\n\n#ifdef PNG_WRITE_SUPPORTED\n\n/* Write the data to whatever output you are using.  The default routine\n * writes to a file pointer.  Note that this routine sometimes gets called\n * with very small lengths, so you should implement some kind of simple\n * buffering if you are using unbuffered writes.  This should never be asked\n * to write more than 64K on a 16 bit machine.\n */\n\nvoid /* PRIVATE */\npng_write_data(png_structrp png_ptr, png_const_bytep data, png_size_t length)\n{\n   /* NOTE: write_data_fn must not change the buffer! */\n   if (png_ptr->write_data_fn != NULL )\n      (*(png_ptr->write_data_fn))(png_ptr, png_constcast(png_bytep,data),\n         length);\n\n   else\n      png_error(png_ptr, \"Call to NULL write function\");\n}\n\n#ifdef PNG_STDIO_SUPPORTED\n/* This is the function that does the actual writing of data.  If you are\n * not writing to a standard C stream, you should create a replacement\n * write_data function and use it at run time with png_set_write_fn(), rather\n * than changing the library.\n */\nvoid PNGCBAPI\npng_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length)\n{\n   png_size_t check;\n\n   if (png_ptr == NULL)\n      return;\n\n   check = fwrite(data, 1, length, (png_FILE_p)(png_ptr->io_ptr));\n\n   if (check != length)\n      png_error(png_ptr, \"Write Error\");\n}\n#endif\n\n/* This function is called to output any data pending writing (normally\n * to disk).  After png_flush is called, there should be no data pending\n * writing in any buffers.\n */\n#ifdef PNG_WRITE_FLUSH_SUPPORTED\nvoid /* PRIVATE */\npng_flush(png_structrp png_ptr)\n{\n   if (png_ptr->output_flush_fn != NULL)\n      (*(png_ptr->output_flush_fn))(png_ptr);\n}\n\n#  ifdef PNG_STDIO_SUPPORTED\nvoid PNGCBAPI\npng_default_flush(png_structp png_ptr)\n{\n   png_FILE_p io_ptr;\n\n   if (png_ptr == NULL)\n      return;\n\n   io_ptr = png_voidcast(png_FILE_p, (png_ptr->io_ptr));\n   fflush(io_ptr);\n}\n#  endif\n#endif\n\n/* This function allows the application to supply new output functions for\n * libpng if standard C streams aren't being used.\n *\n * This function takes as its arguments:\n * png_ptr       - pointer to a png output data structure\n * io_ptr        - pointer to user supplied structure containing info about\n *                 the output functions.  May be NULL.\n * write_data_fn - pointer to a new output function that takes as its\n *                 arguments a pointer to a png_struct, a pointer to\n *                 data to be written, and a 32-bit unsigned int that is\n *                 the number of bytes to be written.  The new write\n *                 function should call png_error(png_ptr, \"Error msg\")\n *                 to exit and output any fatal error messages.  May be\n *                 NULL, in which case libpng's default function will\n *                 be used.\n * flush_data_fn - pointer to a new flush function that takes as its\n *                 arguments a pointer to a png_struct.  After a call to\n *                 the flush function, there should be no data in any buffers\n *                 or pending transmission.  If the output method doesn't do\n *                 any buffering of output, a function prototype must still be\n *                 supplied although it doesn't have to do anything.  If\n *                 PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng compile\n *                 time, output_flush_fn will be ignored, although it must be\n *                 supplied for compatibility.  May be NULL, in which case\n *                 libpng's default function will be used, if\n *                 PNG_WRITE_FLUSH_SUPPORTED is defined.  This is not\n *                 a good idea if io_ptr does not point to a standard\n *                 *FILE structure.\n */\nvoid PNGAPI\npng_set_write_fn(png_structrp png_ptr, png_voidp io_ptr,\n    png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn)\n{\n   if (png_ptr == NULL)\n      return;\n\n   png_ptr->io_ptr = io_ptr;\n\n#ifdef PNG_STDIO_SUPPORTED\n   if (write_data_fn != NULL)\n      png_ptr->write_data_fn = write_data_fn;\n\n   else\n      png_ptr->write_data_fn = png_default_write_data;\n#else\n   png_ptr->write_data_fn = write_data_fn;\n#endif\n\n#ifdef PNG_WRITE_FLUSH_SUPPORTED\n#  ifdef PNG_STDIO_SUPPORTED\n\n   if (output_flush_fn != NULL)\n      png_ptr->output_flush_fn = output_flush_fn;\n\n   else\n      png_ptr->output_flush_fn = png_default_flush;\n\n#  else\n   png_ptr->output_flush_fn = output_flush_fn;\n#  endif\n#else\n   PNG_UNUSED(output_flush_fn)\n#endif /* PNG_WRITE_FLUSH_SUPPORTED */\n\n#ifdef PNG_READ_SUPPORTED\n   /* It is an error to read while writing a png file */\n   if (png_ptr->read_data_fn != NULL)\n   {\n      png_ptr->read_data_fn = NULL;\n\n      png_warning(png_ptr,\n          \"Can't set both read_data_fn and write_data_fn in the\"\n          \" same structure\");\n   }\n#endif\n}\n#endif /* PNG_WRITE_SUPPORTED */\n"
  },
  {
    "path": "Projects/Libraries/CSBase/Source/png/pngwrite.c",
    "content": "\n/* pngwrite.c - general routines to write a PNG file\n *\n * Last changed in libpng 1.6.10 [March 6, 2014]\n * Copyright (c) 1998-2014 Glenn Randers-Pehrson\n * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)\n * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)\n *\n * This code is released under the libpng license.\n * For conditions of distribution and use, see the disclaimer\n * and license in png.h\n */\n\n#include \"pngpriv.h\"\n#if defined(PNG_SIMPLIFIED_WRITE_SUPPORTED) && defined(PNG_STDIO_SUPPORTED)\n#  include <errno.h>\n#endif\n\n#ifdef PNG_WRITE_SUPPORTED\n\n#ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED\n/* Write out all the unknown chunks for the current given location */\nstatic void\nwrite_unknown_chunks(png_structrp png_ptr, png_const_inforp info_ptr,\n   unsigned int where)\n{\n   if (info_ptr->unknown_chunks_num)\n   {\n      png_const_unknown_chunkp up;\n\n      png_debug(5, \"writing extra chunks\");\n\n      for (up = info_ptr->unknown_chunks;\n           up < info_ptr->unknown_chunks + info_ptr->unknown_chunks_num;\n           ++up)\n         if (up->location & where)\n      {\n         /* If per-chunk unknown chunk handling is enabled use it, otherwise\n          * just write the chunks the application has set.\n          */\n#ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED\n         int keep = png_handle_as_unknown(png_ptr, up->name);\n\n         /* NOTE: this code is radically different from the read side in the\n          * matter of handling an ancillary unknown chunk.  In the read side\n          * the default behavior is to discard it, in the code below the default\n          * behavior is to write it.  Critical chunks are, however, only\n          * written if explicitly listed or if the default is set to write all\n          * unknown chunks.\n          *\n          * The default handling is also slightly weird - it is not possible to\n          * stop the writing of all unsafe-to-copy chunks!\n          *\n          * TODO: REVIEW: this would seem to be a bug.\n          */\n         if (keep != PNG_HANDLE_CHUNK_NEVER &&\n             ((up->name[3] & 0x20) /* safe-to-copy overrides everything */ ||\n              keep == PNG_HANDLE_CHUNK_ALWAYS ||\n              (keep == PNG_HANDLE_CHUNK_AS_DEFAULT &&\n               png_ptr->unknown_default == PNG_HANDLE_CHUNK_ALWAYS)))\n#endif\n         {\n            /* TODO: review, what is wrong with a zero length unknown chunk? */\n            if (up->size == 0)\n               png_warning(png_ptr, \"Writing zero-length unknown chunk\");\n\n            png_write_chunk(png_ptr, up->name, up->data, up->size);\n         }\n      }\n   }\n}\n#endif /* PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED */\n\n/* Writes all the PNG information.  This is the suggested way to use the\n * library.  If you have a new chunk to add, make a function to write it,\n * and put it in the correct location here.  If you want the chunk written\n * after the image data, put it in png_write_end().  I strongly encourage\n * you to supply a PNG_INFO_ flag, and check info_ptr->valid before writing\n * the chunk, as that will keep the code from breaking if you want to just\n * write a plain PNG file.  If you have long comments, I suggest writing\n * them in png_write_end(), and compressing them.\n */\nvoid PNGAPI\npng_write_info_before_PLTE(png_structrp png_ptr, png_const_inforp info_ptr)\n{\n   png_debug(1, \"in png_write_info_before_PLTE\");\n\n   if (png_ptr == NULL || info_ptr == NULL)\n      return;\n\n   if (!(png_ptr->mode & PNG_WROTE_INFO_BEFORE_PLTE))\n   {\n   /* Write PNG signature */\n   png_write_sig(png_ptr);\n\n#ifdef PNG_MNG_FEATURES_SUPPORTED\n   if ((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE) && \\\n       (png_ptr->mng_features_permitted))\n   {\n      png_warning(png_ptr, \"MNG features are not allowed in a PNG datastream\");\n      png_ptr->mng_features_permitted = 0;\n   }\n#endif\n\n   /* Write IHDR information. */\n   png_write_IHDR(png_ptr, info_ptr->width, info_ptr->height,\n       info_ptr->bit_depth, info_ptr->color_type, info_ptr->compression_type,\n       info_ptr->filter_type,\n#ifdef PNG_WRITE_INTERLACING_SUPPORTED\n       info_ptr->interlace_type\n#else\n       0\n#endif\n      );\n\n   /* The rest of these check to see if the valid field has the appropriate\n    * flag set, and if it does, writes the chunk.\n    *\n    * 1.6.0: COLORSPACE support controls the writing of these chunks too, and\n    * the chunks will be written if the WRITE routine is there and information\n    * is available in the COLORSPACE.  (See png_colorspace_sync_info in png.c\n    * for where the valid flags get set.)\n    *\n    * Under certain circumstances the colorspace can be invalidated without\n    * syncing the info_struct 'valid' flags; this happens if libpng detects and\n    * error and calls png_error while the color space is being set, yet the\n    * application continues writing the PNG.  So check the 'invalid' flag here\n    * too.\n    */\n#ifdef PNG_GAMMA_SUPPORTED\n#  ifdef PNG_WRITE_gAMA_SUPPORTED\n      if (!(info_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) &&\n         (info_ptr->colorspace.flags & PNG_COLORSPACE_FROM_gAMA) &&\n         (info_ptr->valid & PNG_INFO_gAMA))\n         png_write_gAMA_fixed(png_ptr, info_ptr->colorspace.gamma);\n#  endif\n#endif\n\n#ifdef PNG_COLORSPACE_SUPPORTED\n   /* Write only one of sRGB or an ICC profile.  If a profile was supplied\n    * and it matches one of the known sRGB ones issue a warning.\n    */\n#  ifdef PNG_WRITE_iCCP_SUPPORTED\n      if (!(info_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) &&\n         (info_ptr->valid & PNG_INFO_iCCP))\n      {\n#        ifdef PNG_WRITE_sRGB_SUPPORTED\n            if (info_ptr->valid & PNG_INFO_sRGB)\n               png_app_warning(png_ptr,\n                  \"profile matches sRGB but writing iCCP instead\");\n#        endif\n\n         png_write_iCCP(png_ptr, info_ptr->iccp_name,\n            info_ptr->iccp_profile);\n      }\n#     ifdef PNG_WRITE_sRGB_SUPPORTED\n         else\n#     endif\n#  endif\n\n#  ifdef PNG_WRITE_sRGB_SUPPORTED\n      if (!(info_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) &&\n         (info_ptr->valid & PNG_INFO_sRGB))\n         png_write_sRGB(png_ptr, info_ptr->colorspace.rendering_intent);\n#  endif /* WRITE_sRGB */\n#endif /* COLORSPACE */\n\n#ifdef PNG_WRITE_sBIT_SUPPORTED\n   if (info_ptr->valid & PNG_INFO_sBIT)\n      png_write_sBIT(png_ptr, &(info_ptr->sig_bit), info_ptr->color_type);\n#endif\n\n#ifdef PNG_COLORSPACE_SUPPORTED\n#  ifdef PNG_WRITE_cHRM_SUPPORTED\n      if (!(info_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) &&\n         (info_ptr->colorspace.flags & PNG_COLORSPACE_FROM_cHRM) &&\n         (info_ptr->valid & PNG_INFO_cHRM))\n         png_write_cHRM_fixed(png_ptr, &info_ptr->colorspace.end_points_xy);\n#  endif\n#endif\n\n#ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED\n      write_unknown_chunks(png_ptr, info_ptr, PNG_HAVE_IHDR);\n#endif\n\n      png_ptr->mode |= PNG_WROTE_INFO_BEFORE_PLTE;\n   }\n}\n\nvoid PNGAPI\npng_write_info(png_structrp png_ptr, png_const_inforp info_ptr)\n{\n#if defined(PNG_WRITE_TEXT_SUPPORTED) || defined(PNG_WRITE_sPLT_SUPPORTED)\n   int i;\n#endif\n\n   png_debug(1, \"in png_write_info\");\n\n   if (png_ptr == NULL || info_ptr == NULL)\n      return;\n\n   png_write_info_before_PLTE(png_ptr, info_ptr);\n\n   if (info_ptr->valid & PNG_INFO_PLTE)\n      png_write_PLTE(png_ptr, info_ptr->palette,\n          (png_uint_32)info_ptr->num_palette);\n\n   else if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)\n      png_error(png_ptr, \"Valid palette required for paletted images\");\n\n#ifdef PNG_WRITE_tRNS_SUPPORTED\n   if (info_ptr->valid & PNG_INFO_tRNS)\n   {\n#ifdef PNG_WRITE_INVERT_ALPHA_SUPPORTED\n      /* Invert the alpha channel (in tRNS) */\n      if ((png_ptr->transformations & PNG_INVERT_ALPHA) &&\n          info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)\n      {\n         int j;\n         for (j = 0; j<(int)info_ptr->num_trans; j++)\n            info_ptr->trans_alpha[j] =\n               (png_byte)(255 - info_ptr->trans_alpha[j]);\n      }\n#endif\n      png_write_tRNS(png_ptr, info_ptr->trans_alpha, &(info_ptr->trans_color),\n          info_ptr->num_trans, info_ptr->color_type);\n   }\n#endif\n#ifdef PNG_WRITE_bKGD_SUPPORTED\n   if (info_ptr->valid & PNG_INFO_bKGD)\n      png_write_bKGD(png_ptr, &(info_ptr->background), info_ptr->color_type);\n#endif\n\n#ifdef PNG_WRITE_hIST_SUPPORTED\n   if (info_ptr->valid & PNG_INFO_hIST)\n      png_write_hIST(png_ptr, info_ptr->hist, info_ptr->num_palette);\n#endif\n\n#ifdef PNG_WRITE_oFFs_SUPPORTED\n   if (info_ptr->valid & PNG_INFO_oFFs)\n      png_write_oFFs(png_ptr, info_ptr->x_offset, info_ptr->y_offset,\n          info_ptr->offset_unit_type);\n#endif\n\n#ifdef PNG_WRITE_pCAL_SUPPORTED\n   if (info_ptr->valid & PNG_INFO_pCAL)\n      png_write_pCAL(png_ptr, info_ptr->pcal_purpose, info_ptr->pcal_X0,\n          info_ptr->pcal_X1, info_ptr->pcal_type, info_ptr->pcal_nparams,\n          info_ptr->pcal_units, info_ptr->pcal_params);\n#endif\n\n#ifdef PNG_WRITE_sCAL_SUPPORTED\n   if (info_ptr->valid & PNG_INFO_sCAL)\n      png_write_sCAL_s(png_ptr, (int)info_ptr->scal_unit,\n          info_ptr->scal_s_width, info_ptr->scal_s_height);\n#endif /* sCAL */\n\n#ifdef PNG_WRITE_pHYs_SUPPORTED\n   if (info_ptr->valid & PNG_INFO_pHYs)\n      png_write_pHYs(png_ptr, info_ptr->x_pixels_per_unit,\n          info_ptr->y_pixels_per_unit, info_ptr->phys_unit_type);\n#endif /* pHYs */\n\n#ifdef PNG_WRITE_tIME_SUPPORTED\n   if (info_ptr->valid & PNG_INFO_tIME)\n   {\n      png_write_tIME(png_ptr, &(info_ptr->mod_time));\n      png_ptr->mode |= PNG_WROTE_tIME;\n   }\n#endif /* tIME */\n\n#ifdef PNG_WRITE_sPLT_SUPPORTED\n   if (info_ptr->valid & PNG_INFO_sPLT)\n      for (i = 0; i < (int)info_ptr->splt_palettes_num; i++)\n         png_write_sPLT(png_ptr, info_ptr->splt_palettes + i);\n#endif /* sPLT */\n\n#ifdef PNG_WRITE_TEXT_SUPPORTED\n   /* Check to see if we need to write text chunks */\n   for (i = 0; i < info_ptr->num_text; i++)\n   {\n      png_debug2(2, \"Writing header text chunk %d, type %d\", i,\n          info_ptr->text[i].compression);\n      /* An internationalized chunk? */\n      if (info_ptr->text[i].compression > 0)\n      {\n#ifdef PNG_WRITE_iTXt_SUPPORTED\n         /* Write international chunk */\n         png_write_iTXt(png_ptr,\n             info_ptr->text[i].compression,\n             info_ptr->text[i].key,\n             info_ptr->text[i].lang,\n             info_ptr->text[i].lang_key,\n             info_ptr->text[i].text);\n#else\n          png_warning(png_ptr, \"Unable to write international text\");\n#endif\n          /* Mark this chunk as written */\n          info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_NONE_WR;\n      }\n\n      /* If we want a compressed text chunk */\n      else if (info_ptr->text[i].compression == PNG_TEXT_COMPRESSION_zTXt)\n      {\n#ifdef PNG_WRITE_zTXt_SUPPORTED\n         /* Write compressed chunk */\n         png_write_zTXt(png_ptr, info_ptr->text[i].key,\n             info_ptr->text[i].text, 0,\n             info_ptr->text[i].compression);\n#else\n         png_warning(png_ptr, \"Unable to write compressed text\");\n#endif\n         /* Mark this chunk as written */\n         info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_zTXt_WR;\n      }\n\n      else if (info_ptr->text[i].compression == PNG_TEXT_COMPRESSION_NONE)\n      {\n#ifdef PNG_WRITE_tEXt_SUPPORTED\n         /* Write uncompressed chunk */\n         png_write_tEXt(png_ptr, info_ptr->text[i].key,\n             info_ptr->text[i].text,\n             0);\n         /* Mark this chunk as written */\n         info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_NONE_WR;\n#else\n         /* Can't get here */\n         png_warning(png_ptr, \"Unable to write uncompressed text\");\n#endif\n      }\n   }\n#endif /* tEXt */\n\n#ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED\n   write_unknown_chunks(png_ptr, info_ptr, PNG_HAVE_PLTE);\n#endif\n}\n\n/* Writes the end of the PNG file.  If you don't want to write comments or\n * time information, you can pass NULL for info.  If you already wrote these\n * in png_write_info(), do not write them again here.  If you have long\n * comments, I suggest writing them here, and compressing them.\n */\nvoid PNGAPI\npng_write_end(png_structrp png_ptr, png_inforp info_ptr)\n{\n   png_debug(1, \"in png_write_end\");\n\n   if (png_ptr == NULL)\n      return;\n\n   if (!(png_ptr->mode & PNG_HAVE_IDAT))\n      png_error(png_ptr, \"No IDATs written into file\");\n\n#ifdef PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED\n   if (png_ptr->num_palette_max > png_ptr->num_palette)\n      png_benign_error(png_ptr, \"Wrote palette index exceeding num_palette\");\n#endif\n\n   /* See if user wants us to write information chunks */\n   if (info_ptr != NULL)\n   {\n#ifdef PNG_WRITE_TEXT_SUPPORTED\n      int i; /* local index variable */\n#endif\n#ifdef PNG_WRITE_tIME_SUPPORTED\n      /* Check to see if user has supplied a time chunk */\n      if ((info_ptr->valid & PNG_INFO_tIME) &&\n          !(png_ptr->mode & PNG_WROTE_tIME))\n         png_write_tIME(png_ptr, &(info_ptr->mod_time));\n\n#endif\n#ifdef PNG_WRITE_TEXT_SUPPORTED\n      /* Loop through comment chunks */\n      for (i = 0; i < info_ptr->num_text; i++)\n      {\n         png_debug2(2, \"Writing trailer text chunk %d, type %d\", i,\n            info_ptr->text[i].compression);\n         /* An internationalized chunk? */\n         if (info_ptr->text[i].compression > 0)\n         {\n#ifdef PNG_WRITE_iTXt_SUPPORTED\n            /* Write international chunk */\n            png_write_iTXt(png_ptr,\n                info_ptr->text[i].compression,\n                info_ptr->text[i].key,\n                info_ptr->text[i].lang,\n                info_ptr->text[i].lang_key,\n                info_ptr->text[i].text);\n#else\n            png_warning(png_ptr, \"Unable to write international text\");\n#endif\n            /* Mark this chunk as written */\n            info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_NONE_WR;\n         }\n\n         else if (info_ptr->text[i].compression >= PNG_TEXT_COMPRESSION_zTXt)\n         {\n#ifdef PNG_WRITE_zTXt_SUPPORTED\n            /* Write compressed chunk */\n            png_write_zTXt(png_ptr, info_ptr->text[i].key,\n                info_ptr->text[i].text, 0,\n                info_ptr->text[i].compression);\n#else\n            png_warning(png_ptr, \"Unable to write compressed text\");\n#endif\n            /* Mark this chunk as written */\n            info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_zTXt_WR;\n         }\n\n         else if (info_ptr->text[i].compression == PNG_TEXT_COMPRESSION_NONE)\n         {\n#ifdef PNG_WRITE_tEXt_SUPPORTED\n            /* Write uncompressed chunk */\n            png_write_tEXt(png_ptr, info_ptr->text[i].key,\n                info_ptr->text[i].text, 0);\n#else\n            png_warning(png_ptr, \"Unable to write uncompressed text\");\n#endif\n\n            /* Mark this chunk as written */\n            info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_NONE_WR;\n         }\n      }\n#endif\n#ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED\n      write_unknown_chunks(png_ptr, info_ptr, PNG_AFTER_IDAT);\n#endif\n   }\n\n   png_ptr->mode |= PNG_AFTER_IDAT;\n\n   /* Write end of PNG file */\n   png_write_IEND(png_ptr);\n   /* This flush, added in libpng-1.0.8, removed from libpng-1.0.9beta03,\n    * and restored again in libpng-1.2.30, may cause some applications that\n    * do not set png_ptr->output_flush_fn to crash.  If your application\n    * experiences a problem, please try building libpng with\n    * PNG_WRITE_FLUSH_AFTER_IEND_SUPPORTED defined, and report the event to\n    * png-mng-implement at lists.sf.net .\n    */\n#ifdef PNG_WRITE_FLUSH_SUPPORTED\n#  ifdef PNG_WRITE_FLUSH_AFTER_IEND_SUPPORTED\n   png_flush(png_ptr);\n#  endif\n#endif\n}\n\n#ifdef PNG_CONVERT_tIME_SUPPORTED\nvoid PNGAPI\npng_convert_from_struct_tm(png_timep ptime, PNG_CONST struct tm * ttime)\n{\n   png_debug(1, \"in png_convert_from_struct_tm\");\n\n   ptime->year = (png_uint_16)(1900 + ttime->tm_year);\n   ptime->month = (png_byte)(ttime->tm_mon + 1);\n   ptime->day = (png_byte)ttime->tm_mday;\n   ptime->hour = (png_byte)ttime->tm_hour;\n   ptime->minute = (png_byte)ttime->tm_min;\n   ptime->second = (png_byte)ttime->tm_sec;\n}\n\nvoid PNGAPI\npng_convert_from_time_t(png_timep ptime, time_t ttime)\n{\n   struct tm *tbuf;\n\n   png_debug(1, \"in png_convert_from_time_t\");\n\n   tbuf = gmtime(&ttime);\n   png_convert_from_struct_tm(ptime, tbuf);\n}\n#endif\n\n/* Initialize png_ptr structure, and allocate any memory needed */\nPNG_FUNCTION(png_structp,PNGAPI\npng_create_write_struct,(png_const_charp user_png_ver, png_voidp error_ptr,\n    png_error_ptr error_fn, png_error_ptr warn_fn),PNG_ALLOCATED)\n{\n#ifndef PNG_USER_MEM_SUPPORTED\n   png_structrp png_ptr = png_create_png_struct(user_png_ver, error_ptr,\n      error_fn, warn_fn, NULL, NULL, NULL);\n#else\n   return png_create_write_struct_2(user_png_ver, error_ptr, error_fn,\n       warn_fn, NULL, NULL, NULL);\n}\n\n/* Alternate initialize png_ptr structure, and allocate any memory needed */\nPNG_FUNCTION(png_structp,PNGAPI\npng_create_write_struct_2,(png_const_charp user_png_ver, png_voidp error_ptr,\n    png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr,\n    png_malloc_ptr malloc_fn, png_free_ptr free_fn),PNG_ALLOCATED)\n{\n   png_structrp png_ptr = png_create_png_struct(user_png_ver, error_ptr,\n      error_fn, warn_fn, mem_ptr, malloc_fn, free_fn);\n#endif /* PNG_USER_MEM_SUPPORTED */\n   if (png_ptr != NULL)\n   {\n      /* Set the zlib control values to defaults; they can be overridden by the\n       * application after the struct has been created.\n       */\n      png_ptr->zbuffer_size = PNG_ZBUF_SIZE;\n\n      /* The 'zlib_strategy' setting is irrelevant because png_default_claim in\n       * pngwutil.c defaults it according to whether or not filters will be\n       * used, and ignores this setting.\n       */\n      png_ptr->zlib_strategy = PNG_Z_DEFAULT_STRATEGY;\n      png_ptr->zlib_level = PNG_Z_DEFAULT_COMPRESSION;\n      png_ptr->zlib_mem_level = 8;\n      png_ptr->zlib_window_bits = 15;\n      png_ptr->zlib_method = 8;\n\n#ifdef PNG_WRITE_COMPRESSED_TEXT_SUPPORTED\n      png_ptr->zlib_text_strategy = PNG_TEXT_Z_DEFAULT_STRATEGY;\n      png_ptr->zlib_text_level = PNG_TEXT_Z_DEFAULT_COMPRESSION;\n      png_ptr->zlib_text_mem_level = 8;\n      png_ptr->zlib_text_window_bits = 15;\n      png_ptr->zlib_text_method = 8;\n#endif /* PNG_WRITE_COMPRESSED_TEXT_SUPPORTED */\n\n      /* This is a highly dubious configuration option; by default it is off,\n       * but it may be appropriate for private builds that are testing\n       * extensions not conformant to the current specification, or of\n       * applications that must not fail to write at all costs!\n       */\n#ifdef PNG_BENIGN_WRITE_ERRORS_SUPPORTED\n      png_ptr->flags |= PNG_FLAG_BENIGN_ERRORS_WARN;\n      /* In stable builds only warn if an application error can be completely\n       * handled.\n       */\n#endif\n\n      /* App warnings are warnings in release (or release candidate) builds but\n       * are errors during development.\n       */\n#if PNG_LIBPNG_BUILD_BASE_TYPE >= PNG_LIBPNG_BUILD_RC\n      png_ptr->flags |= PNG_FLAG_APP_WARNINGS_WARN;\n#endif\n\n      /* TODO: delay this, it can be done in png_init_io() (if the app doesn't\n       * do it itself) avoiding setting the default function if it is not\n       * required.\n       */\n      png_set_write_fn(png_ptr, NULL, NULL, NULL);\n   }\n\n   return png_ptr;\n}\n\n\n/* Write a few rows of image data.  If the image is interlaced,\n * either you will have to write the 7 sub images, or, if you\n * have called png_set_interlace_handling(), you will have to\n * \"write\" the image seven times.\n */\nvoid PNGAPI\npng_write_rows(png_structrp png_ptr, png_bytepp row,\n    png_uint_32 num_rows)\n{\n   png_uint_32 i; /* row counter */\n   png_bytepp rp; /* row pointer */\n\n   png_debug(1, \"in png_write_rows\");\n\n   if (png_ptr == NULL)\n      return;\n\n   /* Loop through the rows */\n   for (i = 0, rp = row; i < num_rows; i++, rp++)\n   {\n      png_write_row(png_ptr, *rp);\n   }\n}\n\n/* Write the image.  You only need to call this function once, even\n * if you are writing an interlaced image.\n */\nvoid PNGAPI\npng_write_image(png_structrp png_ptr, png_bytepp image)\n{\n   png_uint_32 i; /* row index */\n   int pass, num_pass; /* pass variables */\n   png_bytepp rp; /* points to current row */\n\n   if (png_ptr == NULL)\n      return;\n\n   png_debug(1, \"in png_write_image\");\n\n#ifdef PNG_WRITE_INTERLACING_SUPPORTED\n   /* Initialize interlace handling.  If image is not interlaced,\n    * this will set pass to 1\n    */\n   num_pass = png_set_interlace_handling(png_ptr);\n#else\n   num_pass = 1;\n#endif\n   /* Loop through passes */\n   for (pass = 0; pass < num_pass; pass++)\n   {\n      /* Loop through image */\n      for (i = 0, rp = image; i < png_ptr->height; i++, rp++)\n      {\n         png_write_row(png_ptr, *rp);\n      }\n   }\n}\n\n#ifdef PNG_MNG_FEATURES_SUPPORTED\n/* Performs intrapixel differencing  */\nstatic void\npng_do_write_intrapixel(png_row_infop row_info, png_bytep row)\n{\n   png_debug(1, \"in png_do_write_intrapixel\");\n\n   if ((row_info->color_type & PNG_COLOR_MASK_COLOR))\n   {\n      int bytes_per_pixel;\n      png_uint_32 row_width = row_info->width;\n      if (row_info->bit_depth == 8)\n      {\n         png_bytep rp;\n         png_uint_32 i;\n\n         if (row_info->color_type == PNG_COLOR_TYPE_RGB)\n            bytes_per_pixel = 3;\n\n         else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)\n            bytes_per_pixel = 4;\n\n         else\n            return;\n\n         for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel)\n         {\n            *(rp)     = (png_byte)((*rp       - *(rp + 1)) & 0xff);\n            *(rp + 2) = (png_byte)((*(rp + 2) - *(rp + 1)) & 0xff);\n         }\n      }\n\n#ifdef PNG_WRITE_16BIT_SUPPORTED\n      else if (row_info->bit_depth == 16)\n      {\n         png_bytep rp;\n         png_uint_32 i;\n\n         if (row_info->color_type == PNG_COLOR_TYPE_RGB)\n            bytes_per_pixel = 6;\n\n         else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)\n            bytes_per_pixel = 8;\n\n         else\n            return;\n\n         for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel)\n         {\n            png_uint_32 s0   = (*(rp    ) << 8) | *(rp + 1);\n            png_uint_32 s1   = (*(rp + 2) << 8) | *(rp + 3);\n            png_uint_32 s2   = (*(rp + 4) << 8) | *(rp + 5);\n            png_uint_32 red  = (png_uint_32)((s0 - s1) & 0xffffL);\n            png_uint_32 blue = (png_uint_32)((s2 - s1) & 0xffffL);\n            *(rp    ) = (png_byte)((red >> 8) & 0xff);\n            *(rp + 1) = (png_byte)(red & 0xff);\n            *(rp + 4) = (png_byte)((blue >> 8) & 0xff);\n            *(rp + 5) = (png_byte)(blue & 0xff);\n         }\n      }\n#endif /* PNG_WRITE_16BIT_SUPPORTED */\n   }\n}\n#endif /* PNG_MNG_FEATURES_SUPPORTED */\n\n/* Called by user to write a row of image data */\nvoid PNGAPI\npng_write_row(png_structrp png_ptr, png_const_bytep row)\n{\n   /* 1.5.6: moved from png_struct to be a local structure: */\n   png_row_info row_info;\n\n   if (png_ptr == NULL)\n      return;\n\n   png_debug2(1, \"in png_write_row (row %u, pass %d)\",\n      png_ptr->row_number, png_ptr->pass);\n\n   /* Initialize transformations and other stuff if first time */\n   if (png_ptr->row_number == 0 && png_ptr->pass == 0)\n   {\n      /* Make sure we wrote the header info */\n      if (!(png_ptr->mode & PNG_WROTE_INFO_BEFORE_PLTE))\n         png_error(png_ptr,\n             \"png_write_info was never called before png_write_row\");\n\n      /* Check for transforms that have been set but were defined out */\n#if !defined(PNG_WRITE_INVERT_SUPPORTED) && defined(PNG_READ_INVERT_SUPPORTED)\n      if (png_ptr->transformations & PNG_INVERT_MONO)\n         png_warning(png_ptr, \"PNG_WRITE_INVERT_SUPPORTED is not defined\");\n#endif\n\n#if !defined(PNG_WRITE_FILLER_SUPPORTED) && defined(PNG_READ_FILLER_SUPPORTED)\n      if (png_ptr->transformations & PNG_FILLER)\n         png_warning(png_ptr, \"PNG_WRITE_FILLER_SUPPORTED is not defined\");\n#endif\n#if !defined(PNG_WRITE_PACKSWAP_SUPPORTED) && \\\n    defined(PNG_READ_PACKSWAP_SUPPORTED)\n      if (png_ptr->transformations & PNG_PACKSWAP)\n         png_warning(png_ptr,\n             \"PNG_WRITE_PACKSWAP_SUPPORTED is not defined\");\n#endif\n\n#if !defined(PNG_WRITE_PACK_SUPPORTED) && defined(PNG_READ_PACK_SUPPORTED)\n      if (png_ptr->transformations & PNG_PACK)\n         png_warning(png_ptr, \"PNG_WRITE_PACK_SUPPORTED is not defined\");\n#endif\n\n#if !defined(PNG_WRITE_SHIFT_SUPPORTED) && defined(PNG_READ_SHIFT_SUPPORTED)\n      if (png_ptr->transformations & PNG_SHIFT)\n         png_warning(png_ptr, \"PNG_WRITE_SHIFT_SUPPORTED is not defined\");\n#endif\n\n#if !defined(PNG_WRITE_BGR_SUPPORTED) && defined(PNG_READ_BGR_SUPPORTED)\n      if (png_ptr->transformations & PNG_BGR)\n         png_warning(png_ptr, \"PNG_WRITE_BGR_SUPPORTED is not defined\");\n#endif\n\n#if !defined(PNG_WRITE_SWAP_SUPPORTED) && defined(PNG_READ_SWAP_SUPPORTED)\n      if (png_ptr->transformations & PNG_SWAP_BYTES)\n         png_warning(png_ptr, \"PNG_WRITE_SWAP_SUPPORTED is not defined\");\n#endif\n\n      png_write_start_row(png_ptr);\n   }\n\n#ifdef PNG_WRITE_INTERLACING_SUPPORTED\n   /* If interlaced and not interested in row, return */\n   if (png_ptr->interlaced && (png_ptr->transformations & PNG_INTERLACE))\n   {\n      switch (png_ptr->pass)\n      {\n         case 0:\n            if (png_ptr->row_number & 0x07)\n            {\n               png_write_finish_row(png_ptr);\n               return;\n            }\n            break;\n\n         case 1:\n            if ((png_ptr->row_number & 0x07) || png_ptr->width < 5)\n            {\n               png_write_finish_row(png_ptr);\n               return;\n            }\n            break;\n\n         case 2:\n            if ((png_ptr->row_number & 0x07) != 4)\n            {\n               png_write_finish_row(png_ptr);\n               return;\n            }\n            break;\n\n         case 3:\n            if ((png_ptr->row_number & 0x03) || png_ptr->width < 3)\n            {\n               png_write_finish_row(png_ptr);\n               return;\n            }\n            break;\n\n         case 4:\n            if ((png_ptr->row_number & 0x03) != 2)\n            {\n               png_write_finish_row(png_ptr);\n               return;\n            }\n            break;\n\n         case 5:\n            if ((png_ptr->row_number & 0x01) || png_ptr->width < 2)\n            {\n               png_write_finish_row(png_ptr);\n               return;\n            }\n            break;\n\n         case 6:\n            if (!(png_ptr->row_number & 0x01))\n            {\n               png_write_finish_row(png_ptr);\n               return;\n            }\n            break;\n\n         default: /* error: ignore it */\n            break;\n      }\n   }\n#endif\n\n   /* Set up row info for transformations */\n   row_info.color_type = png_ptr->color_type;\n   row_info.width = png_ptr->usr_width;\n   row_info.channels = png_ptr->usr_channels;\n   row_info.bit_depth = png_ptr->usr_bit_depth;\n   row_info.pixel_depth = (png_byte)(row_info.bit_depth * row_info.channels);\n   row_info.rowbytes = PNG_ROWBYTES(row_info.pixel_depth, row_info.width);\n\n   png_debug1(3, \"row_info->color_type = %d\", row_info.color_type);\n   png_debug1(3, \"row_info->width = %u\", row_info.width);\n   png_debug1(3, \"row_info->channels = %d\", row_info.channels);\n   png_debug1(3, \"row_info->bit_depth = %d\", row_info.bit_depth);\n   png_debug1(3, \"row_info->pixel_depth = %d\", row_info.pixel_depth);\n   png_debug1(3, \"row_info->rowbytes = %lu\", (unsigned long)row_info.rowbytes);\n\n   /* Copy user's row into buffer, leaving room for filter byte. */\n   memcpy(png_ptr->row_buf + 1, row, row_info.rowbytes);\n\n#ifdef PNG_WRITE_INTERLACING_SUPPORTED\n   /* Handle interlacing */\n   if (png_ptr->interlaced && png_ptr->pass < 6 &&\n       (png_ptr->transformations & PNG_INTERLACE))\n   {\n      png_do_write_interlace(&row_info, png_ptr->row_buf + 1, png_ptr->pass);\n      /* This should always get caught above, but still ... */\n      if (!(row_info.width))\n      {\n         png_write_finish_row(png_ptr);\n         return;\n      }\n   }\n#endif\n\n#ifdef PNG_WRITE_TRANSFORMS_SUPPORTED\n   /* Handle other transformations */\n   if (png_ptr->transformations)\n      png_do_write_transformations(png_ptr, &row_info);\n#endif\n\n   /* At this point the row_info pixel depth must match the 'transformed' depth,\n    * which is also the output depth.\n    */\n   if (row_info.pixel_depth != png_ptr->pixel_depth ||\n      row_info.pixel_depth != png_ptr->transformed_pixel_depth)\n      png_error(png_ptr, \"internal write transform logic error\");\n\n#ifdef PNG_MNG_FEATURES_SUPPORTED\n   /* Write filter_method 64 (intrapixel differencing) only if\n    * 1. Libpng was compiled with PNG_MNG_FEATURES_SUPPORTED and\n    * 2. Libpng did not write a PNG signature (this filter_method is only\n    *    used in PNG datastreams that are embedded in MNG datastreams) and\n    * 3. The application called png_permit_mng_features with a mask that\n    *    included PNG_FLAG_MNG_FILTER_64 and\n    * 4. The filter_method is 64 and\n    * 5. The color_type is RGB or RGBA\n    */\n   if ((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) &&\n       (png_ptr->filter_type == PNG_INTRAPIXEL_DIFFERENCING))\n   {\n      /* Intrapixel differencing */\n      png_do_write_intrapixel(&row_info, png_ptr->row_buf + 1);\n   }\n#endif\n\n/* Added at libpng-1.5.10 */\n#ifdef PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED\n   /* Check for out-of-range palette index */\n   if (row_info.color_type == PNG_COLOR_TYPE_PALETTE &&\n       png_ptr->num_palette_max >= 0)\n      png_do_check_palette_indexes(png_ptr, &row_info);\n#endif\n\n   /* Find a filter if necessary, filter the row and write it out. */\n   png_write_find_filter(png_ptr, &row_info);\n\n   if (png_ptr->write_row_fn != NULL)\n      (*(png_ptr->write_row_fn))(png_ptr, png_ptr->row_number, png_ptr->pass);\n}\n\n#ifdef PNG_WRITE_FLUSH_SUPPORTED\n/* Set the automatic flush interval or 0 to turn flushing off */\nvoid PNGAPI\npng_set_flush(png_structrp png_ptr, int nrows)\n{\n   png_debug(1, \"in png_set_flush\");\n\n   if (png_ptr == NULL)\n      return;\n\n   png_ptr->flush_dist = (nrows < 0 ? 0 : nrows);\n}\n\n/* Flush the current output buffers now */\nvoid PNGAPI\npng_write_flush(png_structrp png_ptr)\n{\n   png_debug(1, \"in png_write_flush\");\n\n   if (png_ptr == NULL)\n      return;\n\n   /* We have already written out all of the data */\n   if (png_ptr->row_number >= png_ptr->num_rows)\n      return;\n\n   png_compress_IDAT(png_ptr, NULL, 0, Z_SYNC_FLUSH);\n   png_ptr->flush_rows = 0;\n   png_flush(png_ptr);\n}\n#endif /* PNG_WRITE_FLUSH_SUPPORTED */\n\n#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED\nstatic void png_reset_filter_heuristics(png_structrp png_ptr);/* forward decl */\n#endif\n\n/* Free any memory used in png_ptr struct without freeing the struct itself. */\nstatic void\npng_write_destroy(png_structrp png_ptr)\n{\n   png_debug(1, \"in png_write_destroy\");\n\n   /* Free any memory zlib uses */\n   if (png_ptr->flags & PNG_FLAG_ZSTREAM_INITIALIZED)\n      deflateEnd(&png_ptr->zstream);\n\n   /* Free our memory.  png_free checks NULL for us. */\n   png_free_buffer_list(png_ptr, &png_ptr->zbuffer_list);\n   png_free(png_ptr, png_ptr->row_buf);\n#ifdef PNG_WRITE_FILTER_SUPPORTED\n   png_free(png_ptr, png_ptr->prev_row);\n   png_free(png_ptr, png_ptr->sub_row);\n   png_free(png_ptr, png_ptr->up_row);\n   png_free(png_ptr, png_ptr->avg_row);\n   png_free(png_ptr, png_ptr->paeth_row);\n#endif\n\n#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED\n   /* Use this to save a little code space, it doesn't free the filter_costs */\n   png_reset_filter_heuristics(png_ptr);\n   png_free(png_ptr, png_ptr->filter_costs);\n   png_free(png_ptr, png_ptr->inv_filter_costs);\n#endif\n\n#ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED\n   png_free(png_ptr, png_ptr->chunk_list);\n#endif\n\n   /* The error handling and memory handling information is left intact at this\n    * point: the jmp_buf may still have to be freed.  See png_destroy_png_struct\n    * for how this happens.\n    */\n}\n\n/* Free all memory used by the write.\n * In libpng 1.6.0 this API changed quietly to no longer accept a NULL value for\n * *png_ptr_ptr.  Prior to 1.6.0 it would accept such a value and it would free\n * the passed in info_structs but it would quietly fail to free any of the data\n * inside them.  In 1.6.0 it quietly does nothing (it has to be quiet because it\n * has no png_ptr.)\n */\nvoid PNGAPI\npng_destroy_write_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr)\n{\n   png_debug(1, \"in png_destroy_write_struct\");\n\n   if (png_ptr_ptr != NULL)\n   {\n      png_structrp png_ptr = *png_ptr_ptr;\n\n      if (png_ptr != NULL) /* added in libpng 1.6.0 */\n      {\n         png_destroy_info_struct(png_ptr, info_ptr_ptr);\n\n         *png_ptr_ptr = NULL;\n         png_write_destroy(png_ptr);\n         png_destroy_png_struct(png_ptr);\n      }\n   }\n}\n\n/* Allow the application to select one or more row filters to use. */\nvoid PNGAPI\npng_set_filter(png_structrp png_ptr, int method, int filters)\n{\n   png_debug(1, \"in png_set_filter\");\n\n   if (png_ptr == NULL)\n      return;\n\n#ifdef PNG_MNG_FEATURES_SUPPORTED\n   if ((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) &&\n       (method == PNG_INTRAPIXEL_DIFFERENCING))\n      method = PNG_FILTER_TYPE_BASE;\n\n#endif\n   if (method == PNG_FILTER_TYPE_BASE)\n   {\n      switch (filters & (PNG_ALL_FILTERS | 0x07))\n      {\n#ifdef PNG_WRITE_FILTER_SUPPORTED\n         case 5:\n         case 6:\n         case 7: png_app_error(png_ptr, \"Unknown row filter for method 0\");\n            /* FALL THROUGH */\n#endif /* PNG_WRITE_FILTER_SUPPORTED */\n         case PNG_FILTER_VALUE_NONE:\n            png_ptr->do_filter = PNG_FILTER_NONE; break;\n\n#ifdef PNG_WRITE_FILTER_SUPPORTED\n         case PNG_FILTER_VALUE_SUB:\n            png_ptr->do_filter = PNG_FILTER_SUB; break;\n\n         case PNG_FILTER_VALUE_UP:\n            png_ptr->do_filter = PNG_FILTER_UP; break;\n\n         case PNG_FILTER_VALUE_AVG:\n            png_ptr->do_filter = PNG_FILTER_AVG; break;\n\n         case PNG_FILTER_VALUE_PAETH:\n            png_ptr->do_filter = PNG_FILTER_PAETH; break;\n\n         default:\n            png_ptr->do_filter = (png_byte)filters; break;\n#else\n         default:\n            png_app_error(png_ptr, \"Unknown row filter for method 0\");\n#endif /* PNG_WRITE_FILTER_SUPPORTED */\n      }\n\n      /* If we have allocated the row_buf, this means we have already started\n       * with the image and we should have allocated all of the filter buffers\n       * that have been selected.  If prev_row isn't already allocated, then\n       * it is too late to start using the filters that need it, since we\n       * will be missing the data in the previous row.  If an application\n       * wants to start and stop using particular filters during compression,\n       * it should start out with all of the filters, and then add and\n       * remove them after the start of compression.\n       */\n      if (png_ptr->row_buf != NULL)\n      {\n#ifdef PNG_WRITE_FILTER_SUPPORTED\n         if ((png_ptr->do_filter & PNG_FILTER_SUB) && png_ptr->sub_row == NULL)\n         {\n            png_ptr->sub_row = (png_bytep)png_malloc(png_ptr,\n                (png_ptr->rowbytes + 1));\n            png_ptr->sub_row[0] = PNG_FILTER_VALUE_SUB;\n         }\n\n         if ((png_ptr->do_filter & PNG_FILTER_UP) && png_ptr->up_row == NULL)\n         {\n            if (png_ptr->prev_row == NULL)\n            {\n               png_warning(png_ptr, \"Can't add Up filter after starting\");\n               png_ptr->do_filter = (png_byte)(png_ptr->do_filter &\n                   ~PNG_FILTER_UP);\n            }\n\n            else\n            {\n               png_ptr->up_row = (png_bytep)png_malloc(png_ptr,\n                   (png_ptr->rowbytes + 1));\n               png_ptr->up_row[0] = PNG_FILTER_VALUE_UP;\n            }\n         }\n\n         if ((png_ptr->do_filter & PNG_FILTER_AVG) && png_ptr->avg_row == NULL)\n         {\n            if (png_ptr->prev_row == NULL)\n            {\n               png_warning(png_ptr, \"Can't add Average filter after starting\");\n               png_ptr->do_filter = (png_byte)(png_ptr->do_filter &\n                   ~PNG_FILTER_AVG);\n            }\n\n            else\n            {\n               png_ptr->avg_row = (png_bytep)png_malloc(png_ptr,\n                   (png_ptr->rowbytes + 1));\n               png_ptr->avg_row[0] = PNG_FILTER_VALUE_AVG;\n            }\n         }\n\n         if ((png_ptr->do_filter & PNG_FILTER_PAETH) &&\n             png_ptr->paeth_row == NULL)\n         {\n            if (png_ptr->prev_row == NULL)\n            {\n               png_warning(png_ptr, \"Can't add Paeth filter after starting\");\n               png_ptr->do_filter &= (png_byte)(~PNG_FILTER_PAETH);\n            }\n\n            else\n            {\n               png_ptr->paeth_row = (png_bytep)png_malloc(png_ptr,\n                   (png_ptr->rowbytes + 1));\n               png_ptr->paeth_row[0] = PNG_FILTER_VALUE_PAETH;\n            }\n         }\n\n         if (png_ptr->do_filter == PNG_NO_FILTERS)\n#endif /* PNG_WRITE_FILTER_SUPPORTED */\n            png_ptr->do_filter = PNG_FILTER_NONE;\n      }\n   }\n   else\n      png_error(png_ptr, \"Unknown custom filter method\");\n}\n\n/* This allows us to influence the way in which libpng chooses the \"best\"\n * filter for the current scanline.  While the \"minimum-sum-of-absolute-\n * differences metric is relatively fast and effective, there is some\n * question as to whether it can be improved upon by trying to keep the\n * filtered data going to zlib more consistent, hopefully resulting in\n * better compression.\n */\n#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED      /* GRR 970116 */\n/* Convenience reset API. */\nstatic void\npng_reset_filter_heuristics(png_structrp png_ptr)\n{\n   /* Clear out any old values in the 'weights' - this must be done because if\n    * the app calls set_filter_heuristics multiple times with different\n    * 'num_weights' values we would otherwise potentially have wrong sized\n    * arrays.\n    */\n   png_ptr->num_prev_filters = 0;\n   png_ptr->heuristic_method = PNG_FILTER_HEURISTIC_UNWEIGHTED;\n   if (png_ptr->prev_filters != NULL)\n   {\n      png_bytep old = png_ptr->prev_filters;\n      png_ptr->prev_filters = NULL;\n      png_free(png_ptr, old);\n   }\n   if (png_ptr->filter_weights != NULL)\n   {\n      png_uint_16p old = png_ptr->filter_weights;\n      png_ptr->filter_weights = NULL;\n      png_free(png_ptr, old);\n   }\n\n   if (png_ptr->inv_filter_weights != NULL)\n   {\n      png_uint_16p old = png_ptr->inv_filter_weights;\n      png_ptr->inv_filter_weights = NULL;\n      png_free(png_ptr, old);\n   }\n\n   /* Leave the filter_costs - this array is fixed size. */\n}\n\nstatic int\npng_init_filter_heuristics(png_structrp png_ptr, int heuristic_method,\n   int num_weights)\n{\n   if (png_ptr == NULL)\n      return 0;\n\n   /* Clear out the arrays */\n   png_reset_filter_heuristics(png_ptr);\n\n   /* Check arguments; the 'reset' function makes the correct settings for the\n    * unweighted case, but we must handle the weight case by initializing the\n    * arrays for the caller.\n    */\n   if (heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED)\n   {\n      int i;\n\n      if (num_weights > 0)\n      {\n         png_ptr->prev_filters = (png_bytep)png_malloc(png_ptr,\n             (png_uint_32)((sizeof (png_byte)) * num_weights));\n\n         /* To make sure that the weighting starts out fairly */\n         for (i = 0; i < num_weights; i++)\n         {\n            png_ptr->prev_filters[i] = 255;\n         }\n\n         png_ptr->filter_weights = (png_uint_16p)png_malloc(png_ptr,\n             (png_uint_32)((sizeof (png_uint_16)) * num_weights));\n\n         png_ptr->inv_filter_weights = (png_uint_16p)png_malloc(png_ptr,\n             (png_uint_32)((sizeof (png_uint_16)) * num_weights));\n\n         for (i = 0; i < num_weights; i++)\n         {\n            png_ptr->inv_filter_weights[i] =\n            png_ptr->filter_weights[i] = PNG_WEIGHT_FACTOR;\n         }\n\n         /* Safe to set this now */\n         png_ptr->num_prev_filters = (png_byte)num_weights;\n      }\n\n      /* If, in the future, there are other filter methods, this would\n       * need to be based on png_ptr->filter.\n       */\n      if (png_ptr->filter_costs == NULL)\n      {\n         png_ptr->filter_costs = (png_uint_16p)png_malloc(png_ptr,\n             (png_uint_32)((sizeof (png_uint_16)) * PNG_FILTER_VALUE_LAST));\n\n         png_ptr->inv_filter_costs = (png_uint_16p)png_malloc(png_ptr,\n             (png_uint_32)((sizeof (png_uint_16)) * PNG_FILTER_VALUE_LAST));\n      }\n\n      for (i = 0; i < PNG_FILTER_VALUE_LAST; i++)\n      {\n         png_ptr->inv_filter_costs[i] =\n         png_ptr->filter_costs[i] = PNG_COST_FACTOR;\n      }\n\n      /* All the arrays are inited, safe to set this: */\n      png_ptr->heuristic_method = PNG_FILTER_HEURISTIC_WEIGHTED;\n\n      /* Return the 'ok' code. */\n      return 1;\n   }\n   else if (heuristic_method == PNG_FILTER_HEURISTIC_DEFAULT ||\n      heuristic_method == PNG_FILTER_HEURISTIC_UNWEIGHTED)\n   {\n      return 1;\n   }\n   else\n   {\n      png_warning(png_ptr, \"Unknown filter heuristic method\");\n      return 0;\n   }\n}\n\n/* Provide floating and fixed point APIs */\n#ifdef PNG_FLOATING_POINT_SUPPORTED\nvoid PNGAPI\npng_set_filter_heuristics(png_structrp png_ptr, int heuristic_method,\n    int num_weights, png_const_doublep filter_weights,\n    png_const_doublep filter_costs)\n{\n   png_debug(1, \"in png_set_filter_heuristics\");\n\n   /* The internal API allocates all the arrays and ensures that the elements of\n    * those arrays are set to the default value.\n    */\n   if (!png_init_filter_heuristics(png_ptr, heuristic_method, num_weights))\n      return;\n\n   /* If using the weighted method copy in the weights. */\n   if (heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED)\n   {\n      int i;\n      for (i = 0; i < num_weights; i++)\n      {\n         if (filter_weights[i] <= 0.0)\n         {\n            png_ptr->inv_filter_weights[i] =\n            png_ptr->filter_weights[i] = PNG_WEIGHT_FACTOR;\n         }\n\n         else\n         {\n            png_ptr->inv_filter_weights[i] =\n                (png_uint_16)(PNG_WEIGHT_FACTOR*filter_weights[i]+.5);\n\n            png_ptr->filter_weights[i] =\n                (png_uint_16)(PNG_WEIGHT_FACTOR/filter_weights[i]+.5);\n         }\n      }\n\n      /* Here is where we set the relative costs of the different filters.  We\n       * should take the desired compression level into account when setting\n       * the costs, so that Paeth, for instance, has a high relative cost at low\n       * compression levels, while it has a lower relative cost at higher\n       * compression settings.  The filter types are in order of increasing\n       * relative cost, so it would be possible to do this with an algorithm.\n       */\n      for (i = 0; i < PNG_FILTER_VALUE_LAST; i++) if (filter_costs[i] >= 1.0)\n      {\n         png_ptr->inv_filter_costs[i] =\n             (png_uint_16)(PNG_COST_FACTOR / filter_costs[i] + .5);\n\n         png_ptr->filter_costs[i] =\n             (png_uint_16)(PNG_COST_FACTOR * filter_costs[i] + .5);\n      }\n   }\n}\n#endif /* FLOATING_POINT */\n\n#ifdef PNG_FIXED_POINT_SUPPORTED\nvoid PNGAPI\npng_set_filter_heuristics_fixed(png_structrp png_ptr, int heuristic_method,\n    int num_weights, png_const_fixed_point_p filter_weights,\n    png_const_fixed_point_p filter_costs)\n{\n   png_debug(1, \"in png_set_filter_heuristics_fixed\");\n\n   /* The internal API allocates all the arrays and ensures that the elements of\n    * those arrays are set to the default value.\n    */\n   if (!png_init_filter_heuristics(png_ptr, heuristic_method, num_weights))\n      return;\n\n   /* If using the weighted method copy in the weights. */\n   if (heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED)\n   {\n      int i;\n      for (i = 0; i < num_weights; i++)\n      {\n         if (filter_weights[i] <= 0)\n         {\n            png_ptr->inv_filter_weights[i] =\n            png_ptr->filter_weights[i] = PNG_WEIGHT_FACTOR;\n         }\n\n         else\n         {\n            png_ptr->inv_filter_weights[i] = (png_uint_16)\n               ((PNG_WEIGHT_FACTOR*filter_weights[i]+PNG_FP_HALF)/PNG_FP_1);\n\n            png_ptr->filter_weights[i] = (png_uint_16)((PNG_WEIGHT_FACTOR*\n               PNG_FP_1+(filter_weights[i]/2))/filter_weights[i]);\n         }\n      }\n\n      /* Here is where we set the relative costs of the different filters.  We\n       * should take the desired compression level into account when setting\n       * the costs, so that Paeth, for instance, has a high relative cost at low\n       * compression levels, while it has a lower relative cost at higher\n       * compression settings.  The filter types are in order of increasing\n       * relative cost, so it would be possible to do this with an algorithm.\n       */\n      for (i = 0; i < PNG_FILTER_VALUE_LAST; i++)\n         if (filter_costs[i] >= PNG_FP_1)\n      {\n         png_uint_32 tmp;\n\n         /* Use a 32 bit unsigned temporary here because otherwise the\n          * intermediate value will be a 32 bit *signed* integer (ANSI rules)\n          * and this will get the wrong answer on division.\n          */\n         tmp = PNG_COST_FACTOR*PNG_FP_1 + (filter_costs[i]/2);\n         tmp /= filter_costs[i];\n\n         png_ptr->inv_filter_costs[i] = (png_uint_16)tmp;\n\n         tmp = PNG_COST_FACTOR * filter_costs[i] + PNG_FP_HALF;\n         tmp /= PNG_FP_1;\n\n         png_ptr->filter_costs[i] = (png_uint_16)tmp;\n      }\n   }\n}\n#endif /* FIXED_POINT */\n#endif /* PNG_WRITE_WEIGHTED_FILTER_SUPPORTED */\n\nvoid PNGAPI\npng_set_compression_level(png_structrp png_ptr, int level)\n{\n   png_debug(1, \"in png_set_compression_level\");\n\n   if (png_ptr == NULL)\n      return;\n\n   png_ptr->zlib_level = level;\n}\n\nvoid PNGAPI\npng_set_compression_mem_level(png_structrp png_ptr, int mem_level)\n{\n   png_debug(1, \"in png_set_compression_mem_level\");\n\n   if (png_ptr == NULL)\n      return;\n\n   png_ptr->zlib_mem_level = mem_level;\n}\n\nvoid PNGAPI\npng_set_compression_strategy(png_structrp png_ptr, int strategy)\n{\n   png_debug(1, \"in png_set_compression_strategy\");\n\n   if (png_ptr == NULL)\n      return;\n\n   /* The flag setting here prevents the libpng dynamic selection of strategy.\n    */\n   png_ptr->flags |= PNG_FLAG_ZLIB_CUSTOM_STRATEGY;\n   png_ptr->zlib_strategy = strategy;\n}\n\n/* If PNG_WRITE_OPTIMIZE_CMF_SUPPORTED is defined, libpng will use a\n * smaller value of window_bits if it can do so safely.\n */\nvoid PNGAPI\npng_set_compression_window_bits(png_structrp png_ptr, int window_bits)\n{\n   if (png_ptr == NULL)\n      return;\n\n   /* Prior to 1.6.0 this would warn but then set the window_bits value, this\n    * meant that negative window bits values could be selected which would cause\n    * libpng to write a non-standard PNG file with raw deflate or gzip\n    * compressed IDAT or ancillary chunks.  Such files can be read and there is\n    * no warning on read, so this seems like a very bad idea.\n    */\n   if (window_bits > 15)\n   {\n      png_warning(png_ptr, \"Only compression windows <= 32k supported by PNG\");\n      window_bits = 15;\n   }\n\n   else if (window_bits < 8)\n   {\n      png_warning(png_ptr, \"Only compression windows >= 256 supported by PNG\");\n      window_bits = 8;\n   }\n\n   png_ptr->zlib_window_bits = window_bits;\n}\n\nvoid PNGAPI\npng_set_compression_method(png_structrp png_ptr, int method)\n{\n   png_debug(1, \"in png_set_compression_method\");\n\n   if (png_ptr == NULL)\n      return;\n\n   /* This would produce an invalid PNG file if it worked, but it doesn't and\n    * deflate will fault it, so it is harmless to just warn here.\n    */\n   if (method != 8)\n      png_warning(png_ptr, \"Only compression method 8 is supported by PNG\");\n\n   png_ptr->zlib_method = method;\n}\n\n/* The following were added to libpng-1.5.4 */\n#ifdef PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED\nvoid PNGAPI\npng_set_text_compression_level(png_structrp png_ptr, int level)\n{\n   png_debug(1, \"in png_set_text_compression_level\");\n\n   if (png_ptr == NULL)\n      return;\n\n   png_ptr->zlib_text_level = level;\n}\n\nvoid PNGAPI\npng_set_text_compression_mem_level(png_structrp png_ptr, int mem_level)\n{\n   png_debug(1, \"in png_set_text_compression_mem_level\");\n\n   if (png_ptr == NULL)\n      return;\n\n   png_ptr->zlib_text_mem_level = mem_level;\n}\n\nvoid PNGAPI\npng_set_text_compression_strategy(png_structrp png_ptr, int strategy)\n{\n   png_debug(1, \"in png_set_text_compression_strategy\");\n\n   if (png_ptr == NULL)\n      return;\n\n   png_ptr->zlib_text_strategy = strategy;\n}\n\n/* If PNG_WRITE_OPTIMIZE_CMF_SUPPORTED is defined, libpng will use a\n * smaller value of window_bits if it can do so safely.\n */\nvoid PNGAPI\npng_set_text_compression_window_bits(png_structrp png_ptr, int window_bits)\n{\n   if (png_ptr == NULL)\n      return;\n\n   if (window_bits > 15)\n   {\n      png_warning(png_ptr, \"Only compression windows <= 32k supported by PNG\");\n      window_bits = 15;\n   }\n\n   else if (window_bits < 8)\n   {\n      png_warning(png_ptr, \"Only compression windows >= 256 supported by PNG\");\n      window_bits = 8;\n   }\n\n   png_ptr->zlib_text_window_bits = window_bits;\n}\n\nvoid PNGAPI\npng_set_text_compression_method(png_structrp png_ptr, int method)\n{\n   png_debug(1, \"in png_set_text_compression_method\");\n\n   if (png_ptr == NULL)\n      return;\n\n   if (method != 8)\n      png_warning(png_ptr, \"Only compression method 8 is supported by PNG\");\n\n   png_ptr->zlib_text_method = method;\n}\n#endif /* PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED */\n/* end of API added to libpng-1.5.4 */\n\nvoid PNGAPI\npng_set_write_status_fn(png_structrp png_ptr, png_write_status_ptr write_row_fn)\n{\n   if (png_ptr == NULL)\n      return;\n\n   png_ptr->write_row_fn = write_row_fn;\n}\n\n#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED\nvoid PNGAPI\npng_set_write_user_transform_fn(png_structrp png_ptr, png_user_transform_ptr\n    write_user_transform_fn)\n{\n   png_debug(1, \"in png_set_write_user_transform_fn\");\n\n   if (png_ptr == NULL)\n      return;\n\n   png_ptr->transformations |= PNG_USER_TRANSFORM;\n   png_ptr->write_user_transform_fn = write_user_transform_fn;\n}\n#endif\n\n\n#ifdef PNG_INFO_IMAGE_SUPPORTED\nvoid PNGAPI\npng_write_png(png_structrp png_ptr, png_inforp info_ptr,\n    int transforms, voidp params)\n{\n   if (png_ptr == NULL || info_ptr == NULL)\n      return;\n\n   if ((info_ptr->valid & PNG_INFO_IDAT) == 0)\n   {\n      png_app_error(png_ptr, \"no rows for png_write_image to write\");\n      return;\n   }\n\n   /* Write the file header information. */\n   png_write_info(png_ptr, info_ptr);\n\n   /* ------ these transformations don't touch the info structure ------- */\n\n   /* Invert monochrome pixels */\n   if (transforms & PNG_TRANSFORM_INVERT_MONO)\n#ifdef PNG_WRITE_INVERT_SUPPORTED\n      png_set_invert_mono(png_ptr);\n#else\n      png_app_error(png_ptr, \"PNG_TRANSFORM_INVERT_MONO not supported\");\n#endif\n\n   /* Shift the pixels up to a legal bit depth and fill in\n    * as appropriate to correctly scale the image.\n    */\n   if (transforms & PNG_TRANSFORM_SHIFT)\n#ifdef PNG_WRITE_SHIFT_SUPPORTED\n      if (info_ptr->valid & PNG_INFO_sBIT)\n         png_set_shift(png_ptr, &info_ptr->sig_bit);\n#else\n      png_app_error(png_ptr, \"PNG_TRANSFORM_SHIFT not supported\");\n#endif\n\n   /* Pack pixels into bytes */\n   if (transforms & PNG_TRANSFORM_PACKING)\n#ifdef PNG_WRITE_PACK_SUPPORTED\n      png_set_packing(png_ptr);\n#else\n      png_app_error(png_ptr, \"PNG_TRANSFORM_PACKING not supported\");\n#endif\n\n   /* Swap location of alpha bytes from ARGB to RGBA */\n   if (transforms & PNG_TRANSFORM_SWAP_ALPHA)\n#ifdef PNG_WRITE_SWAP_ALPHA_SUPPORTED\n      png_set_swap_alpha(png_ptr);\n#else\n      png_app_error(png_ptr, \"PNG_TRANSFORM_SWAP_ALPHA not supported\");\n#endif\n\n   /* Remove a filler (X) from XRGB/RGBX/AG/GA into to convert it into\n    * RGB, note that the code expects the input color type to be G or RGB; no\n    * alpha channel.\n    */\n   if (transforms &\n      (PNG_TRANSFORM_STRIP_FILLER_AFTER|PNG_TRANSFORM_STRIP_FILLER_BEFORE))\n   {\n#ifdef PNG_WRITE_FILLER_SUPPORTED\n      if (transforms & PNG_TRANSFORM_STRIP_FILLER_AFTER)\n      {\n         if (transforms & PNG_TRANSFORM_STRIP_FILLER_BEFORE)\n            png_app_error(png_ptr,\n               \"PNG_TRANSFORM_STRIP_FILLER: BEFORE+AFTER not supported\");\n\n         /* Continue if ignored - this is the pre-1.6.10 behavior */\n         png_set_filler(png_ptr, 0, PNG_FILLER_AFTER);\n      }\n\n      else if (transforms & PNG_TRANSFORM_STRIP_FILLER_BEFORE)\n         png_set_filler(png_ptr, 0, PNG_FILLER_BEFORE);\n#else\n      png_app_error(png_ptr, \"PNG_TRANSFORM_STRIP_FILLER not supported\");\n#endif\n   }\n\n   /* Flip BGR pixels to RGB */\n   if (transforms & PNG_TRANSFORM_BGR)\n#ifdef PNG_WRITE_BGR_SUPPORTED\n      png_set_bgr(png_ptr);\n#else\n      png_app_error(png_ptr, \"PNG_TRANSFORM_BGR not supported\");\n#endif\n\n   /* Swap bytes of 16-bit files to most significant byte first */\n   if (transforms & PNG_TRANSFORM_SWAP_ENDIAN)\n#ifdef PNG_WRITE_SWAP_SUPPORTED\n      png_set_swap(png_ptr);\n#else\n      png_app_error(png_ptr, \"PNG_TRANSFORM_SWAP_ENDIAN not supported\");\n#endif\n\n   /* Swap bits of 1, 2, 4 bit packed pixel formats */\n   if (transforms & PNG_TRANSFORM_PACKSWAP)\n#ifdef PNG_WRITE_PACKSWAP_SUPPORTED\n      png_set_packswap(png_ptr);\n#else\n      png_app_error(png_ptr, \"PNG_TRANSFORM_PACKSWAP not supported\");\n#endif\n\n   /* Invert the alpha channel from opacity to transparency */\n   if (transforms & PNG_TRANSFORM_INVERT_ALPHA)\n#ifdef PNG_WRITE_INVERT_ALPHA_SUPPORTED\n      png_set_invert_alpha(png_ptr);\n#else\n      png_app_error(png_ptr, \"PNG_TRANSFORM_INVERT_ALPHA not supported\");\n#endif\n\n   /* ----------------------- end of transformations ------------------- */\n\n   /* Write the bits */\n   png_write_image(png_ptr, info_ptr->row_pointers);\n\n   /* It is REQUIRED to call this to finish writing the rest of the file */\n   png_write_end(png_ptr, info_ptr);\n\n   PNG_UNUSED(params)\n}\n#endif\n\n\n#ifdef PNG_SIMPLIFIED_WRITE_SUPPORTED\n#ifdef PNG_STDIO_SUPPORTED /* currently required for png_image_write_* */\n/* Initialize the write structure - general purpose utility. */\nstatic int\npng_image_write_init(png_imagep image)\n{\n   png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, image,\n          png_safe_error, png_safe_warning);\n\n   if (png_ptr != NULL)\n   {\n      png_infop info_ptr = png_create_info_struct(png_ptr);\n\n      if (info_ptr != NULL)\n      {\n         png_controlp control = png_voidcast(png_controlp,\n            png_malloc_warn(png_ptr, (sizeof *control)));\n\n         if (control != NULL)\n         {\n            memset(control, 0, (sizeof *control));\n\n            control->png_ptr = png_ptr;\n            control->info_ptr = info_ptr;\n            control->for_write = 1;\n\n            image->opaque = control;\n            return 1;\n         }\n\n         /* Error clean up */\n         png_destroy_info_struct(png_ptr, &info_ptr);\n      }\n\n      png_destroy_write_struct(&png_ptr, NULL);\n   }\n\n   return png_image_error(image, \"png_image_write_: out of memory\");\n}\n\n/* Arguments to png_image_write_main: */\ntypedef struct\n{\n   /* Arguments: */\n   png_imagep      image;\n   png_const_voidp buffer;\n   png_int_32      row_stride;\n   png_const_voidp colormap;\n   int             convert_to_8bit;\n   /* Local variables: */\n   png_const_voidp first_row;\n   ptrdiff_t       row_bytes;\n   png_voidp       local_row;\n} png_image_write_control;\n\n/* Write png_uint_16 input to a 16-bit PNG; the png_ptr has already been set to\n * do any necessary byte swapping.  The component order is defined by the\n * png_image format value.\n */\nstatic int\npng_write_image_16bit(png_voidp argument)\n{\n   png_image_write_control *display = png_voidcast(png_image_write_control*,\n      argument);\n   png_imagep image = display->image;\n   png_structrp png_ptr = image->opaque->png_ptr;\n\n   png_const_uint_16p input_row = png_voidcast(png_const_uint_16p,\n      display->first_row);\n   png_uint_16p output_row = png_voidcast(png_uint_16p, display->local_row);\n   png_uint_16p row_end;\n   const int channels = (image->format & PNG_FORMAT_FLAG_COLOR) ? 3 : 1;\n   int aindex = 0;\n   png_uint_32 y = image->height;\n\n   if (image->format & PNG_FORMAT_FLAG_ALPHA)\n   {\n#     ifdef PNG_SIMPLIFIED_WRITE_AFIRST_SUPPORTED\n         if (image->format & PNG_FORMAT_FLAG_AFIRST)\n         {\n            aindex = -1;\n            ++input_row; /* To point to the first component */\n            ++output_row;\n         }\n\n         else\n#     endif\n         aindex = channels;\n   }\n\n   else\n      png_error(png_ptr, \"png_write_image: internal call error\");\n\n   /* Work out the output row end and count over this, note that the increment\n    * above to 'row' means that row_end can actually be beyond the end of the\n    * row; this is correct.\n    */\n   row_end = output_row + image->width * (channels+1);\n\n   while (y-- > 0)\n   {\n      png_const_uint_16p in_ptr = input_row;\n      png_uint_16p out_ptr = output_row;\n\n      while (out_ptr < row_end)\n      {\n         const png_uint_16 alpha = in_ptr[aindex];\n         png_uint_32 reciprocal = 0;\n         int c;\n\n         out_ptr[aindex] = alpha;\n\n         /* Calculate a reciprocal.  The correct calculation is simply\n          * component/alpha*65535 << 15. (I.e. 15 bits of precision); this\n          * allows correct rounding by adding .5 before the shift.  'reciprocal'\n          * is only initialized when required.\n          */\n         if (alpha > 0 && alpha < 65535)\n            reciprocal = ((0xffff<<15)+(alpha>>1))/alpha;\n\n         c = channels;\n         do /* always at least one channel */\n         {\n            png_uint_16 component = *in_ptr++;\n\n            /* The following gives 65535 for an alpha of 0, which is fine,\n             * otherwise if 0/0 is represented as some other value there is more\n             * likely to be a discontinuity which will probably damage\n             * compression when moving from a fully transparent area to a\n             * nearly transparent one.  (The assumption here is that opaque\n             * areas tend not to be 0 intensity.)\n             */\n            if (component >= alpha)\n               component = 65535;\n\n            /* component<alpha, so component/alpha is less than one and\n             * component*reciprocal is less than 2^31.\n             */\n            else if (component > 0 && alpha < 65535)\n            {\n               png_uint_32 calc = component * reciprocal;\n               calc += 16384; /* round to nearest */\n               component = (png_uint_16)(calc >> 15);\n            }\n\n            *out_ptr++ = component;\n         }\n         while (--c > 0);\n\n         /* Skip to next component (skip the intervening alpha channel) */\n         ++in_ptr;\n         ++out_ptr;\n      }\n\n      png_write_row(png_ptr, png_voidcast(png_const_bytep, display->local_row));\n      input_row += display->row_bytes/(sizeof (png_uint_16));\n   }\n\n   return 1;\n}\n\n/* Given 16-bit input (1 to 4 channels) write 8-bit output.  If an alpha channel\n * is present it must be removed from the components, the components are then\n * written in sRGB encoding.  No components are added or removed.\n *\n * Calculate an alpha reciprocal to reverse pre-multiplication.  As above the\n * calculation can be done to 15 bits of accuracy; however, the output needs to\n * be scaled in the range 0..255*65535, so include that scaling here.\n */\n#define UNP_RECIPROCAL(alpha) ((((0xffff*0xff)<<7)+(alpha>>1))/alpha)\n\nstatic png_byte\npng_unpremultiply(png_uint_32 component, png_uint_32 alpha,\n   png_uint_32 reciprocal/*from the above macro*/)\n{\n   /* The following gives 1.0 for an alpha of 0, which is fine, otherwise if 0/0\n    * is represented as some other value there is more likely to be a\n    * discontinuity which will probably damage compression when moving from a\n    * fully transparent area to a nearly transparent one.  (The assumption here\n    * is that opaque areas tend not to be 0 intensity.)\n    *\n    * There is a rounding problem here; if alpha is less than 128 it will end up\n    * as 0 when scaled to 8 bits.  To avoid introducing spurious colors into the\n    * output change for this too.\n    */\n   if (component >= alpha || alpha < 128)\n      return 255;\n\n   /* component<alpha, so component/alpha is less than one and\n    * component*reciprocal is less than 2^31.\n    */\n   else if (component > 0)\n   {\n      /* The test is that alpha/257 (rounded) is less than 255, the first value\n       * that becomes 255 is 65407.\n       * NOTE: this must agree with the PNG_DIV257 macro (which must, therefore,\n       * be exact!)  [Could also test reciprocal != 0]\n       */\n      if (alpha < 65407)\n      {\n         component *= reciprocal;\n         component += 64; /* round to nearest */\n         component >>= 7;\n      }\n\n      else\n         component *= 255;\n\n      /* Convert the component to sRGB. */\n      return (png_byte)PNG_sRGB_FROM_LINEAR(component);\n   }\n\n   else\n      return 0;\n}\n\nstatic int\npng_write_image_8bit(png_voidp argument)\n{\n   png_image_write_control *display = png_voidcast(png_image_write_control*,\n      argument);\n   png_imagep image = display->image;\n   png_structrp png_ptr = image->opaque->png_ptr;\n\n   png_const_uint_16p input_row = png_voidcast(png_const_uint_16p,\n      display->first_row);\n   png_bytep output_row = png_voidcast(png_bytep, display->local_row);\n   png_uint_32 y = image->height;\n   const int channels = (image->format & PNG_FORMAT_FLAG_COLOR) ? 3 : 1;\n\n   if (image->format & PNG_FORMAT_FLAG_ALPHA)\n   {\n      png_bytep row_end;\n      int aindex;\n\n#     ifdef PNG_SIMPLIFIED_WRITE_AFIRST_SUPPORTED\n         if (image->format & PNG_FORMAT_FLAG_AFIRST)\n         {\n            aindex = -1;\n            ++input_row; /* To point to the first component */\n            ++output_row;\n         }\n\n         else\n#     endif\n         aindex = channels;\n\n      /* Use row_end in place of a loop counter: */\n      row_end = output_row + image->width * (channels+1);\n\n      while (y-- > 0)\n      {\n         png_const_uint_16p in_ptr = input_row;\n         png_bytep out_ptr = output_row;\n\n         while (out_ptr < row_end)\n         {\n            png_uint_16 alpha = in_ptr[aindex];\n            png_byte alphabyte = (png_byte)PNG_DIV257(alpha);\n            png_uint_32 reciprocal = 0;\n            int c;\n\n            /* Scale and write the alpha channel. */\n            out_ptr[aindex] = alphabyte;\n\n            if (alphabyte > 0 && alphabyte < 255)\n               reciprocal = UNP_RECIPROCAL(alpha);\n\n            c = channels;\n            do /* always at least one channel */\n               *out_ptr++ = png_unpremultiply(*in_ptr++, alpha, reciprocal);\n            while (--c > 0);\n\n            /* Skip to next component (skip the intervening alpha channel) */\n            ++in_ptr;\n            ++out_ptr;\n         } /* while out_ptr < row_end */\n\n         png_write_row(png_ptr, png_voidcast(png_const_bytep,\n            display->local_row));\n         input_row += display->row_bytes/(sizeof (png_uint_16));\n      } /* while y */\n   }\n\n   else\n   {\n      /* No alpha channel, so the row_end really is the end of the row and it\n       * is sufficient to loop over the components one by one.\n       */\n      png_bytep row_end = output_row + image->width * channels;\n\n      while (y-- > 0)\n      {\n         png_const_uint_16p in_ptr = input_row;\n         png_bytep out_ptr = output_row;\n\n         while (out_ptr < row_end)\n         {\n            png_uint_32 component = *in_ptr++;\n\n            component *= 255;\n            *out_ptr++ = (png_byte)PNG_sRGB_FROM_LINEAR(component);\n         }\n\n         png_write_row(png_ptr, output_row);\n         input_row += display->row_bytes/(sizeof (png_uint_16));\n      }\n   }\n\n   return 1;\n}\n\nstatic void\npng_image_set_PLTE(png_image_write_control *display)\n{\n   const png_imagep image = display->image;\n   const void *cmap = display->colormap;\n   const int entries = image->colormap_entries > 256 ? 256 :\n      (int)image->colormap_entries;\n\n   /* NOTE: the caller must check for cmap != NULL and entries != 0 */\n   const png_uint_32 format = image->format;\n   const int channels = PNG_IMAGE_SAMPLE_CHANNELS(format);\n\n#  if defined(PNG_FORMAT_BGR_SUPPORTED) &&\\\n      defined(PNG_SIMPLIFIED_WRITE_AFIRST_SUPPORTED)\n      const int afirst = (format & PNG_FORMAT_FLAG_AFIRST) != 0 &&\n         (format & PNG_FORMAT_FLAG_ALPHA) != 0;\n#  else\n#     define afirst 0\n#  endif\n\n#  ifdef PNG_FORMAT_BGR_SUPPORTED\n      const int bgr = (format & PNG_FORMAT_FLAG_BGR) ? 2 : 0;\n#  else\n#     define bgr 0\n#  endif\n\n   int i, num_trans;\n   png_color palette[256];\n   png_byte tRNS[256];\n\n   memset(tRNS, 255, (sizeof tRNS));\n   memset(palette, 0, (sizeof palette));\n\n   for (i=num_trans=0; i<entries; ++i)\n   {\n      /* This gets automatically converted to sRGB with reversal of the\n       * pre-multiplication if the color-map has an alpha channel.\n       */\n      if (format & PNG_FORMAT_FLAG_LINEAR)\n      {\n         png_const_uint_16p entry = png_voidcast(png_const_uint_16p, cmap);\n\n         entry += i * channels;\n\n         if (channels & 1) /* no alpha */\n         {\n            if (channels >= 3) /* RGB */\n            {\n               palette[i].blue = (png_byte)PNG_sRGB_FROM_LINEAR(255 *\n                  entry[(2 ^ bgr)]);\n               palette[i].green = (png_byte)PNG_sRGB_FROM_LINEAR(255 *\n                  entry[1]);\n               palette[i].red = (png_byte)PNG_sRGB_FROM_LINEAR(255 *\n                  entry[bgr]);\n            }\n\n            else /* Gray */\n               palette[i].blue = palette[i].red = palette[i].green =\n                  (png_byte)PNG_sRGB_FROM_LINEAR(255 * *entry);\n         }\n\n         else /* alpha */\n         {\n            png_uint_16 alpha = entry[afirst ? 0 : channels-1];\n            png_byte alphabyte = (png_byte)PNG_DIV257(alpha);\n            png_uint_32 reciprocal = 0;\n\n            /* Calculate a reciprocal, as in the png_write_image_8bit code above\n             * this is designed to produce a value scaled to 255*65535 when\n             * divided by 128 (i.e. asr 7).\n             */\n            if (alphabyte > 0 && alphabyte < 255)\n               reciprocal = (((0xffff*0xff)<<7)+(alpha>>1))/alpha;\n\n            tRNS[i] = alphabyte;\n            if (alphabyte < 255)\n               num_trans = i+1;\n\n            if (channels >= 3) /* RGB */\n            {\n               palette[i].blue = png_unpremultiply(entry[afirst + (2 ^ bgr)],\n                  alpha, reciprocal);\n               palette[i].green = png_unpremultiply(entry[afirst + 1], alpha,\n                  reciprocal);\n               palette[i].red = png_unpremultiply(entry[afirst + bgr], alpha,\n                  reciprocal);\n            }\n\n            else /* gray */\n               palette[i].blue = palette[i].red = palette[i].green =\n                  png_unpremultiply(entry[afirst], alpha, reciprocal);\n         }\n      }\n\n      else /* Color-map has sRGB values */\n      {\n         png_const_bytep entry = png_voidcast(png_const_bytep, cmap);\n\n         entry += i * channels;\n\n         switch (channels)\n         {\n            case 4:\n               tRNS[i] = entry[afirst ? 0 : 3];\n               if (tRNS[i] < 255)\n                  num_trans = i+1;\n               /* FALL THROUGH */\n            case 3:\n               palette[i].blue = entry[afirst + (2 ^ bgr)];\n               palette[i].green = entry[afirst + 1];\n               palette[i].red = entry[afirst + bgr];\n               break;\n\n            case 2:\n               tRNS[i] = entry[1 ^ afirst];\n               if (tRNS[i] < 255)\n                  num_trans = i+1;\n               /* FALL THROUGH */\n            case 1:\n               palette[i].blue = palette[i].red = palette[i].green =\n                  entry[afirst];\n               break;\n\n            default:\n               break;\n         }\n      }\n   }\n\n#  ifdef afirst\n#     undef afirst\n#  endif\n#  ifdef bgr\n#     undef bgr\n#  endif\n\n   png_set_PLTE(image->opaque->png_ptr, image->opaque->info_ptr, palette,\n      entries);\n\n   if (num_trans > 0)\n      png_set_tRNS(image->opaque->png_ptr, image->opaque->info_ptr, tRNS,\n         num_trans, NULL);\n\n   image->colormap_entries = entries;\n}\n\nstatic int\npng_image_write_main(png_voidp argument)\n{\n   png_image_write_control *display = png_voidcast(png_image_write_control*,\n      argument);\n   png_imagep image = display->image;\n   png_structrp png_ptr = image->opaque->png_ptr;\n   png_inforp info_ptr = image->opaque->info_ptr;\n   png_uint_32 format = image->format;\n\n   int colormap = (format & PNG_FORMAT_FLAG_COLORMAP) != 0;\n   int linear = !colormap && (format & PNG_FORMAT_FLAG_LINEAR) != 0; /* input */\n   int alpha = !colormap && (format & PNG_FORMAT_FLAG_ALPHA) != 0;\n   int write_16bit = linear && !colormap && !display->convert_to_8bit;\n\n#  ifdef PNG_BENIGN_ERRORS_SUPPORTED\n      /* Make sure we error out on any bad situation */\n      png_set_benign_errors(png_ptr, 0/*error*/);\n#  endif\n\n   /* Default the 'row_stride' parameter if required. */\n   if (display->row_stride == 0)\n      display->row_stride = PNG_IMAGE_ROW_STRIDE(*image);\n\n   /* Set the required transforms then write the rows in the correct order. */\n   if (format & PNG_FORMAT_FLAG_COLORMAP)\n   {\n      if (display->colormap != NULL && image->colormap_entries > 0)\n      {\n         png_uint_32 entries = image->colormap_entries;\n\n         png_set_IHDR(png_ptr, info_ptr, image->width, image->height,\n            entries > 16 ? 8 : (entries > 4 ? 4 : (entries > 2 ? 2 : 1)),\n            PNG_COLOR_TYPE_PALETTE, PNG_INTERLACE_NONE,\n            PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);\n\n         png_image_set_PLTE(display);\n      }\n\n      else\n         png_error(image->opaque->png_ptr,\n            \"no color-map for color-mapped image\");\n   }\n\n   else\n      png_set_IHDR(png_ptr, info_ptr, image->width, image->height,\n         write_16bit ? 16 : 8,\n         ((format & PNG_FORMAT_FLAG_COLOR) ? PNG_COLOR_MASK_COLOR : 0) +\n         ((format & PNG_FORMAT_FLAG_ALPHA) ? PNG_COLOR_MASK_ALPHA : 0),\n         PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);\n\n   /* Counter-intuitively the data transformations must be called *after*\n    * png_write_info, not before as in the read code, but the 'set' functions\n    * must still be called before.  Just set the color space information, never\n    * write an interlaced image.\n    */\n\n   if (write_16bit)\n   {\n      /* The gamma here is 1.0 (linear) and the cHRM chunk matches sRGB. */\n      png_set_gAMA_fixed(png_ptr, info_ptr, PNG_GAMMA_LINEAR);\n\n      if (!(image->flags & PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB))\n         png_set_cHRM_fixed(png_ptr, info_ptr,\n            /* color      x       y */\n            /* white */ 31270, 32900,\n            /* red   */ 64000, 33000,\n            /* green */ 30000, 60000,\n            /* blue  */ 15000,  6000\n         );\n   }\n\n   else if (!(image->flags & PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB))\n      png_set_sRGB(png_ptr, info_ptr, PNG_sRGB_INTENT_PERCEPTUAL);\n\n   /* Else writing an 8-bit file and the *colors* aren't sRGB, but the 8-bit\n    * space must still be gamma encoded.\n    */\n   else\n      png_set_gAMA_fixed(png_ptr, info_ptr, PNG_GAMMA_sRGB_INVERSE);\n\n   /* Write the file header. */\n   png_write_info(png_ptr, info_ptr);\n\n   /* Now set up the data transformations (*after* the header is written),\n    * remove the handled transformations from the 'format' flags for checking.\n    *\n    * First check for a little endian system if writing 16 bit files.\n    */\n   if (write_16bit)\n   {\n      PNG_CONST png_uint_16 le = 0x0001;\n\n      if (*(png_const_bytep)&le)\n         png_set_swap(png_ptr);\n   }\n\n#  ifdef PNG_SIMPLIFIED_WRITE_BGR_SUPPORTED\n      if (format & PNG_FORMAT_FLAG_BGR)\n      {\n         if (!colormap && (format & PNG_FORMAT_FLAG_COLOR) != 0)\n            png_set_bgr(png_ptr);\n         format &= ~PNG_FORMAT_FLAG_BGR;\n      }\n#  endif\n\n#  ifdef PNG_SIMPLIFIED_WRITE_AFIRST_SUPPORTED\n      if (format & PNG_FORMAT_FLAG_AFIRST)\n      {\n         if (!colormap && (format & PNG_FORMAT_FLAG_ALPHA) != 0)\n            png_set_swap_alpha(png_ptr);\n         format &= ~PNG_FORMAT_FLAG_AFIRST;\n      }\n#  endif\n\n   /* If there are 16 or fewer color-map entries we wrote a lower bit depth\n    * above, but the application data is still byte packed.\n    */\n   if (colormap && image->colormap_entries <= 16)\n      png_set_packing(png_ptr);\n\n   /* That should have handled all (both) the transforms. */\n   if ((format & ~(png_uint_32)(PNG_FORMAT_FLAG_COLOR | PNG_FORMAT_FLAG_LINEAR |\n         PNG_FORMAT_FLAG_ALPHA | PNG_FORMAT_FLAG_COLORMAP)) != 0)\n      png_error(png_ptr, \"png_write_image: unsupported transformation\");\n\n   {\n      png_const_bytep row = png_voidcast(png_const_bytep, display->buffer);\n      ptrdiff_t row_bytes = display->row_stride;\n\n      if (linear)\n         row_bytes *= (sizeof (png_uint_16));\n\n      if (row_bytes < 0)\n         row += (image->height-1) * (-row_bytes);\n\n      display->first_row = row;\n      display->row_bytes = row_bytes;\n   }\n\n   /* Apply 'fast' options if the flag is set. */\n   if ((image->flags & PNG_IMAGE_FLAG_FAST) != 0)\n   {\n      png_set_filter(png_ptr, PNG_FILTER_TYPE_BASE, PNG_NO_FILTERS);\n      /* NOTE: determined by experiment using pngstest, this reflects some\n       * balance between the time to write the image once and the time to read\n       * it about 50 times.  The speed-up in pngstest was about 10-20% of the\n       * total (user) time on a heavily loaded system.\n       */\n      png_set_compression_level(png_ptr, 3);\n   }\n\n   /* Check for the cases that currently require a pre-transform on the row\n    * before it is written.  This only applies when the input is 16-bit and\n    * either there is an alpha channel or it is converted to 8-bit.\n    */\n   if ((linear && alpha) || (!colormap && display->convert_to_8bit))\n   {\n      png_bytep row = png_voidcast(png_bytep, png_malloc(png_ptr,\n         png_get_rowbytes(png_ptr, info_ptr)));\n      int result;\n\n      display->local_row = row;\n      if (write_16bit)\n         result = png_safe_execute(image, png_write_image_16bit, display);\n      else\n         result = png_safe_execute(image, png_write_image_8bit, display);\n      display->local_row = NULL;\n\n      png_free(png_ptr, row);\n\n      /* Skip the 'write_end' on error: */\n      if (!result)\n         return 0;\n   }\n\n   /* Otherwise this is the case where the input is in a format currently\n    * supported by the rest of the libpng write code; call it directly.\n    */\n   else\n   {\n      png_const_bytep row = png_voidcast(png_const_bytep, display->first_row);\n      ptrdiff_t row_bytes = display->row_bytes;\n      png_uint_32 y = image->height;\n\n      while (y-- > 0)\n      {\n         png_write_row(png_ptr, row);\n         row += row_bytes;\n      }\n   }\n\n   png_write_end(png_ptr, info_ptr);\n   return 1;\n}\n\nint PNGAPI\npng_image_write_to_stdio(png_imagep image, FILE *file, int convert_to_8bit,\n   const void *buffer, png_int_32 row_stride, const void *colormap)\n{\n   /* Write the image to the given (FILE*). */\n   if (image != NULL && image->version == PNG_IMAGE_VERSION)\n   {\n      if (file != NULL)\n      {\n         if (png_image_write_init(image))\n         {\n            png_image_write_control display;\n            int result;\n\n            /* This is slightly evil, but png_init_io doesn't do anything other\n             * than this and we haven't changed the standard IO functions so\n             * this saves a 'safe' function.\n             */\n            image->opaque->png_ptr->io_ptr = file;\n\n            memset(&display, 0, (sizeof display));\n            display.image = image;\n            display.buffer = buffer;\n            display.row_stride = row_stride;\n            display.colormap = colormap;\n            display.convert_to_8bit = convert_to_8bit;\n\n            result = png_safe_execute(image, png_image_write_main, &display);\n            png_image_free(image);\n            return result;\n         }\n\n         else\n            return 0;\n      }\n\n      else\n         return png_image_error(image,\n            \"png_image_write_to_stdio: invalid argument\");\n   }\n\n   else if (image != NULL)\n      return png_image_error(image,\n         \"png_image_write_to_stdio: incorrect PNG_IMAGE_VERSION\");\n\n   else\n      return 0;\n}\n\nint PNGAPI\npng_image_write_to_file(png_imagep image, const char *file_name,\n   int convert_to_8bit, const void *buffer, png_int_32 row_stride,\n   const void *colormap)\n{\n   /* Write the image to the named file. */\n   if (image != NULL && image->version == PNG_IMAGE_VERSION)\n   {\n      if (file_name != NULL)\n      {\n         FILE *fp = fopen(file_name, \"wb\");\n\n         if (fp != NULL)\n         {\n            if (png_image_write_to_stdio(image, fp, convert_to_8bit, buffer,\n               row_stride, colormap))\n            {\n               int error; /* from fflush/fclose */\n\n               /* Make sure the file is flushed correctly. */\n               if (fflush(fp) == 0 && ferror(fp) == 0)\n               {\n                  if (fclose(fp) == 0)\n                     return 1;\n\n                  error = errno; /* from fclose */\n               }\n\n               else\n               {\n                  error = errno; /* from fflush or ferror */\n                  (void)fclose(fp);\n               }\n\n               (void)remove(file_name);\n               /* The image has already been cleaned up; this is just used to\n                * set the error (because the original write succeeded).\n                */\n               return png_image_error(image, strerror(error));\n            }\n\n            else\n            {\n               /* Clean up: just the opened file. */\n               (void)fclose(fp);\n               (void)remove(file_name);\n               return 0;\n            }\n         }\n\n         else\n            return png_image_error(image, strerror(errno));\n      }\n\n      else\n         return png_image_error(image,\n            \"png_image_write_to_file: invalid argument\");\n   }\n\n   else if (image != NULL)\n      return png_image_error(image,\n         \"png_image_write_to_file: incorrect PNG_IMAGE_VERSION\");\n\n   else\n      return 0;\n}\n#endif /* PNG_STDIO_SUPPORTED */\n#endif /* SIMPLIFIED_WRITE */\n#endif /* PNG_WRITE_SUPPORTED */\n"
  },
  {
    "path": "Projects/Libraries/CSBase/Source/png/pngwtran.c",
    "content": "\n/* pngwtran.c - transforms the data in a row for PNG writers\n *\n * Last changed in libpng 1.6.9 [February 6, 2014]\n * Copyright (c) 1998-2014 Glenn Randers-Pehrson\n * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)\n * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)\n *\n * This code is released under the libpng license.\n * For conditions of distribution and use, see the disclaimer\n * and license in png.h\n */\n\n#include \"pngpriv.h\"\n\n#ifdef PNG_WRITE_SUPPORTED\n#ifdef PNG_WRITE_TRANSFORMS_SUPPORTED\n\n#ifdef PNG_WRITE_PACK_SUPPORTED\n/* Pack pixels into bytes.  Pass the true bit depth in bit_depth.  The\n * row_info bit depth should be 8 (one pixel per byte).  The channels\n * should be 1 (this only happens on grayscale and paletted images).\n */\nstatic void\npng_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth)\n{\n   png_debug(1, \"in png_do_pack\");\n\n   if (row_info->bit_depth == 8 &&\n      row_info->channels == 1)\n   {\n      switch ((int)bit_depth)\n      {\n         case 1:\n         {\n            png_bytep sp, dp;\n            int mask, v;\n            png_uint_32 i;\n            png_uint_32 row_width = row_info->width;\n\n            sp = row;\n            dp = row;\n            mask = 0x80;\n            v = 0;\n\n            for (i = 0; i < row_width; i++)\n            {\n               if (*sp != 0)\n                  v |= mask;\n\n               sp++;\n\n               if (mask > 1)\n                  mask >>= 1;\n\n               else\n               {\n                  mask = 0x80;\n                  *dp = (png_byte)v;\n                  dp++;\n                  v = 0;\n               }\n            }\n\n            if (mask != 0x80)\n               *dp = (png_byte)v;\n\n            break;\n         }\n\n         case 2:\n         {\n            png_bytep sp, dp;\n            int shift, v;\n            png_uint_32 i;\n            png_uint_32 row_width = row_info->width;\n\n            sp = row;\n            dp = row;\n            shift = 6;\n            v = 0;\n\n            for (i = 0; i < row_width; i++)\n            {\n               png_byte value;\n\n               value = (png_byte)(*sp & 0x03);\n               v |= (value << shift);\n\n               if (shift == 0)\n               {\n                  shift = 6;\n                  *dp = (png_byte)v;\n                  dp++;\n                  v = 0;\n               }\n\n               else\n                  shift -= 2;\n\n               sp++;\n            }\n\n            if (shift != 6)\n               *dp = (png_byte)v;\n\n            break;\n         }\n\n         case 4:\n         {\n            png_bytep sp, dp;\n            int shift, v;\n            png_uint_32 i;\n            png_uint_32 row_width = row_info->width;\n\n            sp = row;\n            dp = row;\n            shift = 4;\n            v = 0;\n\n            for (i = 0; i < row_width; i++)\n            {\n               png_byte value;\n\n               value = (png_byte)(*sp & 0x0f);\n               v |= (value << shift);\n\n               if (shift == 0)\n               {\n                  shift = 4;\n                  *dp = (png_byte)v;\n                  dp++;\n                  v = 0;\n               }\n\n               else\n                  shift -= 4;\n\n               sp++;\n            }\n\n            if (shift != 4)\n               *dp = (png_byte)v;\n\n            break;\n         }\n\n         default:\n            break;\n      }\n\n      row_info->bit_depth = (png_byte)bit_depth;\n      row_info->pixel_depth = (png_byte)(bit_depth * row_info->channels);\n      row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,\n          row_info->width);\n   }\n}\n#endif\n\n#ifdef PNG_WRITE_SHIFT_SUPPORTED\n/* Shift pixel values to take advantage of whole range.  Pass the\n * true number of bits in bit_depth.  The row should be packed\n * according to row_info->bit_depth.  Thus, if you had a row of\n * bit depth 4, but the pixels only had values from 0 to 7, you\n * would pass 3 as bit_depth, and this routine would translate the\n * data to 0 to 15.\n */\nstatic void\npng_do_shift(png_row_infop row_info, png_bytep row,\n    png_const_color_8p bit_depth)\n{\n   png_debug(1, \"in png_do_shift\");\n\n   if (row_info->color_type != PNG_COLOR_TYPE_PALETTE)\n   {\n      int shift_start[4], shift_dec[4];\n      int channels = 0;\n\n      if (row_info->color_type & PNG_COLOR_MASK_COLOR)\n      {\n         shift_start[channels] = row_info->bit_depth - bit_depth->red;\n         shift_dec[channels] = bit_depth->red;\n         channels++;\n\n         shift_start[channels] = row_info->bit_depth - bit_depth->green;\n         shift_dec[channels] = bit_depth->green;\n         channels++;\n\n         shift_start[channels] = row_info->bit_depth - bit_depth->blue;\n         shift_dec[channels] = bit_depth->blue;\n         channels++;\n      }\n\n      else\n      {\n         shift_start[channels] = row_info->bit_depth - bit_depth->gray;\n         shift_dec[channels] = bit_depth->gray;\n         channels++;\n      }\n\n      if (row_info->color_type & PNG_COLOR_MASK_ALPHA)\n      {\n         shift_start[channels] = row_info->bit_depth - bit_depth->alpha;\n         shift_dec[channels] = bit_depth->alpha;\n         channels++;\n      }\n\n      /* With low row depths, could only be grayscale, so one channel */\n      if (row_info->bit_depth < 8)\n      {\n         png_bytep bp = row;\n         png_size_t i;\n         unsigned int mask;\n         png_size_t row_bytes = row_info->rowbytes;\n\n         if (bit_depth->gray == 1 && row_info->bit_depth == 2)\n            mask = 0x55;\n\n         else if (row_info->bit_depth == 4 && bit_depth->gray == 3)\n            mask = 0x11;\n\n         else\n            mask = 0xff;\n\n         for (i = 0; i < row_bytes; i++, bp++)\n         {\n            int j;\n            unsigned int v, out;\n\n            v = *bp;\n            out = 0;\n\n            for (j = shift_start[0]; j > -shift_dec[0]; j -= shift_dec[0])\n            {\n               if (j > 0)\n                  out |= v << j;\n\n               else\n                  out |= (v >> (-j)) & mask;\n            }\n\n            *bp = (png_byte)(out & 0xff);\n         }\n      }\n\n      else if (row_info->bit_depth == 8)\n      {\n         png_bytep bp = row;\n         png_uint_32 i;\n         png_uint_32 istop = channels * row_info->width;\n\n         for (i = 0; i < istop; i++, bp++)\n         {\n\n            const unsigned int c = i%channels;\n            int j;\n            unsigned int v, out;\n\n            v = *bp;\n            out = 0;\n\n            for (j = shift_start[c]; j > -shift_dec[c]; j -= shift_dec[c])\n            {\n               if (j > 0)\n                  out |= v << j;\n\n               else\n                  out |= v >> (-j);\n            }\n\n            *bp = (png_byte)(out & 0xff);\n         }\n      }\n\n      else\n      {\n         png_bytep bp;\n         png_uint_32 i;\n         png_uint_32 istop = channels * row_info->width;\n\n         for (bp = row, i = 0; i < istop; i++)\n         {\n            const unsigned int c = i%channels;\n            int j;\n            unsigned int value, v;\n\n            v = png_get_uint_16(bp);\n            value = 0;\n\n            for (j = shift_start[c]; j > -shift_dec[c]; j -= shift_dec[c])\n            {\n               if (j > 0)\n                  value |= v << j;\n\n               else\n                  value |= v >> (-j);\n            }\n            *bp++ = (png_byte)((value >> 8) & 0xff);\n            *bp++ = (png_byte)(value & 0xff);\n         }\n      }\n   }\n}\n#endif\n\n#ifdef PNG_WRITE_SWAP_ALPHA_SUPPORTED\nstatic void\npng_do_write_swap_alpha(png_row_infop row_info, png_bytep row)\n{\n   png_debug(1, \"in png_do_write_swap_alpha\");\n\n   {\n      if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)\n      {\n         if (row_info->bit_depth == 8)\n         {\n            /* This converts from ARGB to RGBA */\n            png_bytep sp, dp;\n            png_uint_32 i;\n            png_uint_32 row_width = row_info->width;\n\n            for (i = 0, sp = dp = row; i < row_width; i++)\n            {\n               png_byte save = *(sp++);\n               *(dp++) = *(sp++);\n               *(dp++) = *(sp++);\n               *(dp++) = *(sp++);\n               *(dp++) = save;\n            }\n         }\n\n#ifdef PNG_WRITE_16BIT_SUPPORTED\n         else\n         {\n            /* This converts from AARRGGBB to RRGGBBAA */\n            png_bytep sp, dp;\n            png_uint_32 i;\n            png_uint_32 row_width = row_info->width;\n\n            for (i = 0, sp = dp = row; i < row_width; i++)\n            {\n               png_byte save[2];\n               save[0] = *(sp++);\n               save[1] = *(sp++);\n               *(dp++) = *(sp++);\n               *(dp++) = *(sp++);\n               *(dp++) = *(sp++);\n               *(dp++) = *(sp++);\n               *(dp++) = *(sp++);\n               *(dp++) = *(sp++);\n               *(dp++) = save[0];\n               *(dp++) = save[1];\n            }\n         }\n#endif /* PNG_WRITE_16BIT_SUPPORTED */\n      }\n\n      else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)\n      {\n         if (row_info->bit_depth == 8)\n         {\n            /* This converts from AG to GA */\n            png_bytep sp, dp;\n            png_uint_32 i;\n            png_uint_32 row_width = row_info->width;\n\n            for (i = 0, sp = dp = row; i < row_width; i++)\n            {\n               png_byte save = *(sp++);\n               *(dp++) = *(sp++);\n               *(dp++) = save;\n            }\n         }\n\n#ifdef PNG_WRITE_16BIT_SUPPORTED\n         else\n         {\n            /* This converts from AAGG to GGAA */\n            png_bytep sp, dp;\n            png_uint_32 i;\n            png_uint_32 row_width = row_info->width;\n\n            for (i = 0, sp = dp = row; i < row_width; i++)\n            {\n               png_byte save[2];\n               save[0] = *(sp++);\n               save[1] = *(sp++);\n               *(dp++) = *(sp++);\n               *(dp++) = *(sp++);\n               *(dp++) = save[0];\n               *(dp++) = save[1];\n            }\n         }\n#endif /* PNG_WRITE_16BIT_SUPPORTED */\n      }\n   }\n}\n#endif\n\n#ifdef PNG_WRITE_INVERT_ALPHA_SUPPORTED\nstatic void\npng_do_write_invert_alpha(png_row_infop row_info, png_bytep row)\n{\n   png_debug(1, \"in png_do_write_invert_alpha\");\n\n   {\n      if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)\n      {\n         if (row_info->bit_depth == 8)\n         {\n            /* This inverts the alpha channel in RGBA */\n            png_bytep sp, dp;\n            png_uint_32 i;\n            png_uint_32 row_width = row_info->width;\n\n            for (i = 0, sp = dp = row; i < row_width; i++)\n            {\n               /* Does nothing\n               *(dp++) = *(sp++);\n               *(dp++) = *(sp++);\n               *(dp++) = *(sp++);\n               */\n               sp+=3; dp = sp;\n               *(dp++) = (png_byte)(255 - *(sp++));\n            }\n         }\n\n#ifdef PNG_WRITE_16BIT_SUPPORTED\n         else\n         {\n            /* This inverts the alpha channel in RRGGBBAA */\n            png_bytep sp, dp;\n            png_uint_32 i;\n            png_uint_32 row_width = row_info->width;\n\n            for (i = 0, sp = dp = row; i < row_width; i++)\n            {\n               /* Does nothing\n               *(dp++) = *(sp++);\n               *(dp++) = *(sp++);\n               *(dp++) = *(sp++);\n               *(dp++) = *(sp++);\n               *(dp++) = *(sp++);\n               *(dp++) = *(sp++);\n               */\n               sp+=6; dp = sp;\n               *(dp++) = (png_byte)(255 - *(sp++));\n               *(dp++) = (png_byte)(255 - *(sp++));\n            }\n         }\n#endif /* PNG_WRITE_16BIT_SUPPORTED */\n      }\n\n      else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)\n      {\n         if (row_info->bit_depth == 8)\n         {\n            /* This inverts the alpha channel in GA */\n            png_bytep sp, dp;\n            png_uint_32 i;\n            png_uint_32 row_width = row_info->width;\n\n            for (i = 0, sp = dp = row; i < row_width; i++)\n            {\n               *(dp++) = *(sp++);\n               *(dp++) = (png_byte)(255 - *(sp++));\n            }\n         }\n\n#ifdef PNG_WRITE_16BIT_SUPPORTED\n         else\n         {\n            /* This inverts the alpha channel in GGAA */\n            png_bytep sp, dp;\n            png_uint_32 i;\n            png_uint_32 row_width = row_info->width;\n\n            for (i = 0, sp = dp = row; i < row_width; i++)\n            {\n               /* Does nothing\n               *(dp++) = *(sp++);\n               *(dp++) = *(sp++);\n               */\n               sp+=2; dp = sp;\n               *(dp++) = (png_byte)(255 - *(sp++));\n               *(dp++) = (png_byte)(255 - *(sp++));\n            }\n         }\n#endif /* PNG_WRITE_16BIT_SUPPORTED */\n      }\n   }\n}\n#endif\n\n/* Transform the data according to the user's wishes.  The order of\n * transformations is significant.\n */\nvoid /* PRIVATE */\npng_do_write_transformations(png_structrp png_ptr, png_row_infop row_info)\n{\n   png_debug(1, \"in png_do_write_transformations\");\n\n   if (png_ptr == NULL)\n      return;\n\n#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED\n   if (png_ptr->transformations & PNG_USER_TRANSFORM)\n      if (png_ptr->write_user_transform_fn != NULL)\n         (*(png_ptr->write_user_transform_fn)) /* User write transform\n                                                 function */\n             (png_ptr,  /* png_ptr */\n             row_info,  /* row_info: */\n                /*  png_uint_32 width;       width of row */\n                /*  png_size_t rowbytes;     number of bytes in row */\n                /*  png_byte color_type;     color type of pixels */\n                /*  png_byte bit_depth;      bit depth of samples */\n                /*  png_byte channels;       number of channels (1-4) */\n                /*  png_byte pixel_depth;    bits per pixel (depth*channels) */\n             png_ptr->row_buf + 1);      /* start of pixel data for row */\n#endif\n\n#ifdef PNG_WRITE_FILLER_SUPPORTED\n   if (png_ptr->transformations & PNG_FILLER)\n      png_do_strip_channel(row_info, png_ptr->row_buf + 1,\n         !(png_ptr->flags & PNG_FLAG_FILLER_AFTER));\n#endif\n\n#ifdef PNG_WRITE_PACKSWAP_SUPPORTED\n   if (png_ptr->transformations & PNG_PACKSWAP)\n      png_do_packswap(row_info, png_ptr->row_buf + 1);\n#endif\n\n#ifdef PNG_WRITE_PACK_SUPPORTED\n   if (png_ptr->transformations & PNG_PACK)\n      png_do_pack(row_info, png_ptr->row_buf + 1,\n          (png_uint_32)png_ptr->bit_depth);\n#endif\n\n#ifdef PNG_WRITE_SWAP_SUPPORTED\n   if (png_ptr->transformations & PNG_SWAP_BYTES)\n      png_do_swap(row_info, png_ptr->row_buf + 1);\n#endif\n\n#ifdef PNG_WRITE_SHIFT_SUPPORTED\n   if (png_ptr->transformations & PNG_SHIFT)\n      png_do_shift(row_info, png_ptr->row_buf + 1,\n          &(png_ptr->shift));\n#endif\n\n#ifdef PNG_WRITE_SWAP_ALPHA_SUPPORTED\n   if (png_ptr->transformations & PNG_SWAP_ALPHA)\n      png_do_write_swap_alpha(row_info, png_ptr->row_buf + 1);\n#endif\n\n#ifdef PNG_WRITE_INVERT_ALPHA_SUPPORTED\n   if (png_ptr->transformations & PNG_INVERT_ALPHA)\n      png_do_write_invert_alpha(row_info, png_ptr->row_buf + 1);\n#endif\n\n#ifdef PNG_WRITE_BGR_SUPPORTED\n   if (png_ptr->transformations & PNG_BGR)\n      png_do_bgr(row_info, png_ptr->row_buf + 1);\n#endif\n\n#ifdef PNG_WRITE_INVERT_SUPPORTED\n   if (png_ptr->transformations & PNG_INVERT_MONO)\n      png_do_invert(row_info, png_ptr->row_buf + 1);\n#endif\n}\n#endif /* PNG_WRITE_TRANSFORMS_SUPPORTED */\n#endif /* PNG_WRITE_SUPPORTED */\n"
  },
  {
    "path": "Projects/Libraries/CSBase/Source/png/pngwutil.c",
    "content": "\n/* pngwutil.c - utilities to write a PNG file\n *\n * Last changed in libpng 1.6.2 [April 25, 2013]\n * Copyright (c) 1998-2013 Glenn Randers-Pehrson\n * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)\n * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)\n *\n * This code is released under the libpng license.\n * For conditions of distribution and use, see the disclaimer\n * and license in png.h\n */\n\n#include \"pngpriv.h\"\n\n#ifdef PNG_WRITE_SUPPORTED\n\n#ifdef PNG_WRITE_INT_FUNCTIONS_SUPPORTED\n/* Place a 32-bit number into a buffer in PNG byte order.  We work\n * with unsigned numbers for convenience, although one supported\n * ancillary chunk uses signed (two's complement) numbers.\n */\nvoid PNGAPI\npng_save_uint_32(png_bytep buf, png_uint_32 i)\n{\n   buf[0] = (png_byte)((i >> 24) & 0xff);\n   buf[1] = (png_byte)((i >> 16) & 0xff);\n   buf[2] = (png_byte)((i >> 8) & 0xff);\n   buf[3] = (png_byte)(i & 0xff);\n}\n\n/* Place a 16-bit number into a buffer in PNG byte order.\n * The parameter is declared unsigned int, not png_uint_16,\n * just to avoid potential problems on pre-ANSI C compilers.\n */\nvoid PNGAPI\npng_save_uint_16(png_bytep buf, unsigned int i)\n{\n   buf[0] = (png_byte)((i >> 8) & 0xff);\n   buf[1] = (png_byte)(i & 0xff);\n}\n#endif\n\n/* Simple function to write the signature.  If we have already written\n * the magic bytes of the signature, or more likely, the PNG stream is\n * being embedded into another stream and doesn't need its own signature,\n * we should call png_set_sig_bytes() to tell libpng how many of the\n * bytes have already been written.\n */\nvoid PNGAPI\npng_write_sig(png_structrp png_ptr)\n{\n   png_byte png_signature[8] = {137, 80, 78, 71, 13, 10, 26, 10};\n\n#ifdef PNG_IO_STATE_SUPPORTED\n   /* Inform the I/O callback that the signature is being written */\n   png_ptr->io_state = PNG_IO_WRITING | PNG_IO_SIGNATURE;\n#endif\n\n   /* Write the rest of the 8 byte signature */\n   png_write_data(png_ptr, &png_signature[png_ptr->sig_bytes],\n      (png_size_t)(8 - png_ptr->sig_bytes));\n\n   if (png_ptr->sig_bytes < 3)\n      png_ptr->mode |= PNG_HAVE_PNG_SIGNATURE;\n}\n\n/* Write the start of a PNG chunk.  The type is the chunk type.\n * The total_length is the sum of the lengths of all the data you will be\n * passing in png_write_chunk_data().\n */\nstatic void\npng_write_chunk_header(png_structrp png_ptr, png_uint_32 chunk_name,\n    png_uint_32 length)\n{\n   png_byte buf[8];\n\n#if defined(PNG_DEBUG) && (PNG_DEBUG > 0)\n   PNG_CSTRING_FROM_CHUNK(buf, chunk_name);\n   png_debug2(0, \"Writing %s chunk, length = %lu\", buf, (unsigned long)length);\n#endif\n\n   if (png_ptr == NULL)\n      return;\n\n#ifdef PNG_IO_STATE_SUPPORTED\n   /* Inform the I/O callback that the chunk header is being written.\n    * PNG_IO_CHUNK_HDR requires a single I/O call.\n    */\n   png_ptr->io_state = PNG_IO_WRITING | PNG_IO_CHUNK_HDR;\n#endif\n\n   /* Write the length and the chunk name */\n   png_save_uint_32(buf, length);\n   png_save_uint_32(buf + 4, chunk_name);\n   png_write_data(png_ptr, buf, 8);\n\n   /* Put the chunk name into png_ptr->chunk_name */\n   png_ptr->chunk_name = chunk_name;\n\n   /* Reset the crc and run it over the chunk name */\n   png_reset_crc(png_ptr);\n\n   png_calculate_crc(png_ptr, buf + 4, 4);\n\n#ifdef PNG_IO_STATE_SUPPORTED\n   /* Inform the I/O callback that chunk data will (possibly) be written.\n    * PNG_IO_CHUNK_DATA does NOT require a specific number of I/O calls.\n    */\n   png_ptr->io_state = PNG_IO_WRITING | PNG_IO_CHUNK_DATA;\n#endif\n}\n\nvoid PNGAPI\npng_write_chunk_start(png_structrp png_ptr, png_const_bytep chunk_string,\n    png_uint_32 length)\n{\n   png_write_chunk_header(png_ptr, PNG_CHUNK_FROM_STRING(chunk_string), length);\n}\n\n/* Write the data of a PNG chunk started with png_write_chunk_header().\n * Note that multiple calls to this function are allowed, and that the\n * sum of the lengths from these calls *must* add up to the total_length\n * given to png_write_chunk_header().\n */\nvoid PNGAPI\npng_write_chunk_data(png_structrp png_ptr, png_const_bytep data,\n    png_size_t length)\n{\n   /* Write the data, and run the CRC over it */\n   if (png_ptr == NULL)\n      return;\n\n   if (data != NULL && length > 0)\n   {\n      png_write_data(png_ptr, data, length);\n\n      /* Update the CRC after writing the data,\n       * in case that the user I/O routine alters it.\n       */\n      png_calculate_crc(png_ptr, data, length);\n   }\n}\n\n/* Finish a chunk started with png_write_chunk_header(). */\nvoid PNGAPI\npng_write_chunk_end(png_structrp png_ptr)\n{\n   png_byte buf[4];\n\n   if (png_ptr == NULL) return;\n\n#ifdef PNG_IO_STATE_SUPPORTED\n   /* Inform the I/O callback that the chunk CRC is being written.\n    * PNG_IO_CHUNK_CRC requires a single I/O function call.\n    */\n   png_ptr->io_state = PNG_IO_WRITING | PNG_IO_CHUNK_CRC;\n#endif\n\n   /* Write the crc in a single operation */\n   png_save_uint_32(buf, png_ptr->crc);\n\n   png_write_data(png_ptr, buf, (png_size_t)4);\n}\n\n/* Write a PNG chunk all at once.  The type is an array of ASCII characters\n * representing the chunk name.  The array must be at least 4 bytes in\n * length, and does not need to be null terminated.  To be safe, pass the\n * pre-defined chunk names here, and if you need a new one, define it\n * where the others are defined.  The length is the length of the data.\n * All the data must be present.  If that is not possible, use the\n * png_write_chunk_start(), png_write_chunk_data(), and png_write_chunk_end()\n * functions instead.\n */\nstatic void\npng_write_complete_chunk(png_structrp png_ptr, png_uint_32 chunk_name,\n   png_const_bytep data, png_size_t length)\n{\n   if (png_ptr == NULL)\n      return;\n\n   /* On 64 bit architectures 'length' may not fit in a png_uint_32. */\n   if (length > PNG_UINT_31_MAX)\n      png_error(png_ptr, \"length exceeds PNG maxima\");\n\n   png_write_chunk_header(png_ptr, chunk_name, (png_uint_32)length);\n   png_write_chunk_data(png_ptr, data, length);\n   png_write_chunk_end(png_ptr);\n}\n\n/* This is the API that calls the internal function above. */\nvoid PNGAPI\npng_write_chunk(png_structrp png_ptr, png_const_bytep chunk_string,\n   png_const_bytep data, png_size_t length)\n{\n   png_write_complete_chunk(png_ptr, PNG_CHUNK_FROM_STRING(chunk_string), data,\n      length);\n}\n\n/* This is used below to find the size of an image to pass to png_deflate_claim,\n * so it only needs to be accurate if the size is less than 16384 bytes (the\n * point at which a lower LZ window size can be used.)\n */\nstatic png_alloc_size_t\npng_image_size(png_structrp png_ptr)\n{\n   /* Only return sizes up to the maximum of a png_uint_32, do this by limiting\n    * the width and height used to 15 bits.\n    */\n   png_uint_32 h = png_ptr->height;\n\n   if (png_ptr->rowbytes < 32768 && h < 32768)\n   {\n      if (png_ptr->interlaced)\n      {\n         /* Interlacing makes the image larger because of the replication of\n          * both the filter byte and the padding to a byte boundary.\n          */\n         png_uint_32 w = png_ptr->width;\n         unsigned int pd = png_ptr->pixel_depth;\n         png_alloc_size_t cb_base;\n         int pass;\n\n         for (cb_base=0, pass=0; pass<=6; ++pass)\n         {\n            png_uint_32 pw = PNG_PASS_COLS(w, pass);\n\n            if (pw > 0)\n               cb_base += (PNG_ROWBYTES(pd, pw)+1) * PNG_PASS_ROWS(h, pass);\n         }\n\n         return cb_base;\n      }\n\n      else\n         return (png_ptr->rowbytes+1) * h;\n   }\n\n   else\n      return 0xffffffffU;\n}\n\n#ifdef PNG_WRITE_OPTIMIZE_CMF_SUPPORTED\n   /* This is the code to hack the first two bytes of the deflate stream (the\n    * deflate header) to correct the windowBits value to match the actual data\n    * size.  Note that the second argument is the *uncompressed* size but the\n    * first argument is the *compressed* data (and it must be deflate\n    * compressed.)\n    */\nstatic void\noptimize_cmf(png_bytep data, png_alloc_size_t data_size)\n{\n   /* Optimize the CMF field in the zlib stream.  The resultant zlib stream is\n    * still compliant to the stream specification.\n    */\n   if (data_size <= 16384) /* else windowBits must be 15 */\n   {\n      unsigned int z_cmf = data[0];  /* zlib compression method and flags */\n\n      if ((z_cmf & 0x0f) == 8 && (z_cmf & 0xf0) <= 0x70)\n      {\n         unsigned int z_cinfo;\n         unsigned int half_z_window_size;\n\n         z_cinfo = z_cmf >> 4;\n         half_z_window_size = 1U << (z_cinfo + 7);\n\n         if (data_size <= half_z_window_size) /* else no change */\n         {\n            unsigned int tmp;\n\n            do\n            {\n               half_z_window_size >>= 1;\n               --z_cinfo;\n            }\n            while (z_cinfo > 0 && data_size <= half_z_window_size);\n\n            z_cmf = (z_cmf & 0x0f) | (z_cinfo << 4);\n\n            data[0] = (png_byte)z_cmf;\n            tmp = data[1] & 0xe0;\n            tmp += 0x1f - ((z_cmf << 8) + tmp) % 0x1f;\n            data[1] = (png_byte)tmp;\n         }\n      }\n   }\n}\n#else\n#  define optimize_cmf(dp,dl) ((void)0)\n#endif /* PNG_WRITE_OPTIMIZE_CMF_SUPPORTED */\n\n/* Initialize the compressor for the appropriate type of compression. */\nstatic int\npng_deflate_claim(png_structrp png_ptr, png_uint_32 owner,\n   png_alloc_size_t data_size)\n{\n   if (png_ptr->zowner != 0)\n   {\n      char msg[64];\n\n      PNG_STRING_FROM_CHUNK(msg, owner);\n      msg[4] = ':';\n      msg[5] = ' ';\n      PNG_STRING_FROM_CHUNK(msg+6, png_ptr->zowner);\n      /* So the message that results is \"<chunk> using zstream\"; this is an\n       * internal error, but is very useful for debugging.  i18n requirements\n       * are minimal.\n       */\n      (void)png_safecat(msg, (sizeof msg), 10, \" using zstream\");\n#     if PNG_LIBPNG_BUILD_BASE_TYPE >= PNG_LIBPNG_BUILD_RC\n         png_warning(png_ptr, msg);\n\n         /* Attempt sane error recovery */\n         if (png_ptr->zowner == png_IDAT) /* don't steal from IDAT */\n         {\n            png_ptr->zstream.msg = PNGZ_MSG_CAST(\"in use by IDAT\");\n            return Z_STREAM_ERROR;\n         }\n\n         png_ptr->zowner = 0;\n#     else\n         png_error(png_ptr, msg);\n#     endif\n   }\n\n   {\n      int level = png_ptr->zlib_level;\n      int method = png_ptr->zlib_method;\n      int windowBits = png_ptr->zlib_window_bits;\n      int memLevel = png_ptr->zlib_mem_level;\n      int strategy; /* set below */\n      int ret; /* zlib return code */\n\n      if (owner == png_IDAT)\n      {\n         if (png_ptr->flags & PNG_FLAG_ZLIB_CUSTOM_STRATEGY)\n            strategy = png_ptr->zlib_strategy;\n\n         else if (png_ptr->do_filter != PNG_FILTER_NONE)\n            strategy = PNG_Z_DEFAULT_STRATEGY;\n\n         else\n            strategy = PNG_Z_DEFAULT_NOFILTER_STRATEGY;\n      }\n\n      else\n      {\n#        ifdef PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED\n            level = png_ptr->zlib_text_level;\n            method = png_ptr->zlib_text_method;\n            windowBits = png_ptr->zlib_text_window_bits;\n            memLevel = png_ptr->zlib_text_mem_level;\n            strategy = png_ptr->zlib_text_strategy;\n#        else\n            /* If customization is not supported the values all come from the\n             * IDAT values except for the strategy, which is fixed to the\n             * default.  (This is the pre-1.6.0 behavior too, although it was\n             * implemented in a very different way.)\n             */\n            strategy = Z_DEFAULT_STRATEGY;\n#        endif\n      }\n\n      /* Adjust 'windowBits' down if larger than 'data_size'; to stop this\n       * happening just pass 32768 as the data_size parameter.  Notice that zlib\n       * requires an extra 262 bytes in the window in addition to the data to be\n       * able to see the whole of the data, so if data_size+262 takes us to the\n       * next windowBits size we need to fix up the value later.  (Because even\n       * though deflate needs the extra window, inflate does not!)\n       */\n      if (data_size <= 16384)\n      {\n         /* IMPLEMENTATION NOTE: this 'half_window_size' stuff is only here to\n          * work round a Microsoft Visual C misbehavior which, contrary to C-90,\n          * widens the result of the following shift to 64-bits if (and,\n          * apparently, only if) it is used in a test.\n          */\n         unsigned int half_window_size = 1U << (windowBits-1);\n\n         while (data_size + 262 <= half_window_size)\n         {\n            half_window_size >>= 1;\n            --windowBits;\n         }\n      }\n\n      /* Check against the previous initialized values, if any. */\n      if ((png_ptr->flags & PNG_FLAG_ZSTREAM_INITIALIZED) &&\n         (png_ptr->zlib_set_level != level ||\n         png_ptr->zlib_set_method != method ||\n         png_ptr->zlib_set_window_bits != windowBits ||\n         png_ptr->zlib_set_mem_level != memLevel ||\n         png_ptr->zlib_set_strategy != strategy))\n      {\n         if (deflateEnd(&png_ptr->zstream) != Z_OK)\n            png_warning(png_ptr, \"deflateEnd failed (ignored)\");\n\n         png_ptr->flags &= ~PNG_FLAG_ZSTREAM_INITIALIZED;\n      }\n\n      /* For safety clear out the input and output pointers (currently zlib\n       * doesn't use them on Init, but it might in the future).\n       */\n      png_ptr->zstream.next_in = NULL;\n      png_ptr->zstream.avail_in = 0;\n      png_ptr->zstream.next_out = NULL;\n      png_ptr->zstream.avail_out = 0;\n\n      /* Now initialize if required, setting the new parameters, otherwise just\n       * to a simple reset to the previous parameters.\n       */\n      if (png_ptr->flags & PNG_FLAG_ZSTREAM_INITIALIZED)\n         ret = deflateReset(&png_ptr->zstream);\n\n      else\n      {\n         ret = deflateInit2(&png_ptr->zstream, level, method, windowBits,\n            memLevel, strategy);\n\n         if (ret == Z_OK)\n            png_ptr->flags |= PNG_FLAG_ZSTREAM_INITIALIZED;\n      }\n\n      /* The return code is from either deflateReset or deflateInit2; they have\n       * pretty much the same set of error codes.\n       */\n      if (ret == Z_OK)\n         png_ptr->zowner = owner;\n\n      else\n         png_zstream_error(png_ptr, ret);\n\n      return ret;\n   }\n}\n\n/* Clean up (or trim) a linked list of compression buffers. */\nvoid /* PRIVATE */\npng_free_buffer_list(png_structrp png_ptr, png_compression_bufferp *listp)\n{\n   png_compression_bufferp list = *listp;\n\n   if (list != NULL)\n   {\n      *listp = NULL;\n\n      do\n      {\n         png_compression_bufferp next = list->next;\n\n         png_free(png_ptr, list);\n         list = next;\n      }\n      while (list != NULL);\n   }\n}\n\n#ifdef PNG_WRITE_COMPRESSED_TEXT_SUPPORTED\n/* This pair of functions encapsulates the operation of (a) compressing a\n * text string, and (b) issuing it later as a series of chunk data writes.\n * The compression_state structure is shared context for these functions\n * set up by the caller to allow access to the relevant local variables.\n *\n * compression_buffer (new in 1.6.0) is just a linked list of zbuffer_size\n * temporary buffers.  From 1.6.0 it is retained in png_struct so that it will\n * be correctly freed in the event of a write error (previous implementations\n * just leaked memory.)\n */\ntypedef struct\n{\n   png_const_bytep      input;        /* The uncompressed input data */\n   png_alloc_size_t     input_len;    /* Its length */\n   png_uint_32          output_len;   /* Final compressed length */\n   png_byte             output[1024]; /* First block of output */\n} compression_state;\n\nstatic void\npng_text_compress_init(compression_state *comp, png_const_bytep input,\n   png_alloc_size_t input_len)\n{\n   comp->input = input;\n   comp->input_len = input_len;\n   comp->output_len = 0;\n}\n\n/* Compress the data in the compression state input */\nstatic int\npng_text_compress(png_structrp png_ptr, png_uint_32 chunk_name,\n   compression_state *comp, png_uint_32 prefix_len)\n{\n   int ret;\n\n   /* To find the length of the output it is necessary to first compress the\n    * input, the result is buffered rather than using the two-pass algorithm\n    * that is used on the inflate side; deflate is assumed to be slower and a\n    * PNG writer is assumed to have more memory available than a PNG reader.\n    *\n    * IMPLEMENTATION NOTE: the zlib API deflateBound() can be used to find an\n    * upper limit on the output size, but it is always bigger than the input\n    * size so it is likely to be more efficient to use this linked-list\n    * approach.\n    */\n   ret = png_deflate_claim(png_ptr, chunk_name, comp->input_len);\n\n   if (ret != Z_OK)\n      return ret;\n\n   /* Set up the compression buffers, we need a loop here to avoid overflowing a\n    * uInt.  Use ZLIB_IO_MAX to limit the input.  The output is always limited\n    * by the output buffer size, so there is no need to check that.  Since this\n    * is ANSI-C we know that an 'int', hence a uInt, is always at least 16 bits\n    * in size.\n    */\n   {\n      png_compression_bufferp *end = &png_ptr->zbuffer_list;\n      png_alloc_size_t input_len = comp->input_len; /* may be zero! */\n      png_uint_32 output_len;\n\n      /* zlib updates these for us: */\n      png_ptr->zstream.next_in = PNGZ_INPUT_CAST(comp->input);\n      png_ptr->zstream.avail_in = 0; /* Set below */\n      png_ptr->zstream.next_out = comp->output;\n      png_ptr->zstream.avail_out = (sizeof comp->output);\n\n      output_len = png_ptr->zstream.avail_out;\n\n      do\n      {\n         uInt avail_in = ZLIB_IO_MAX;\n\n         if (avail_in > input_len)\n            avail_in = (uInt)input_len;\n\n         input_len -= avail_in;\n\n         png_ptr->zstream.avail_in = avail_in;\n\n         if (png_ptr->zstream.avail_out == 0)\n         {\n            png_compression_buffer *next;\n\n            /* Chunk data is limited to 2^31 bytes in length, so the prefix\n             * length must be counted here.\n             */\n            if (output_len + prefix_len > PNG_UINT_31_MAX)\n            {\n               ret = Z_MEM_ERROR;\n               break;\n            }\n\n            /* Need a new (malloc'ed) buffer, but there may be one present\n             * already.\n             */\n            next = *end;\n            if (next == NULL)\n            {\n               next = png_voidcast(png_compression_bufferp, png_malloc_base\n                  (png_ptr, PNG_COMPRESSION_BUFFER_SIZE(png_ptr)));\n\n               if (next == NULL)\n               {\n                  ret = Z_MEM_ERROR;\n                  break;\n               }\n\n               /* Link in this buffer (so that it will be freed later) */\n               next->next = NULL;\n               *end = next;\n            }\n\n            png_ptr->zstream.next_out = next->output;\n            png_ptr->zstream.avail_out = png_ptr->zbuffer_size;\n            output_len += png_ptr->zstream.avail_out;\n\n            /* Move 'end' to the next buffer pointer. */\n            end = &next->next;\n         }\n\n         /* Compress the data */\n         ret = deflate(&png_ptr->zstream,\n            input_len > 0 ? Z_NO_FLUSH : Z_FINISH);\n\n         /* Claw back input data that was not consumed (because avail_in is\n          * reset above every time round the loop).\n          */\n         input_len += png_ptr->zstream.avail_in;\n         png_ptr->zstream.avail_in = 0; /* safety */\n      }\n      while (ret == Z_OK);\n\n      /* There may be some space left in the last output buffer, this needs to\n       * be subtracted from output_len.\n       */\n      output_len -= png_ptr->zstream.avail_out;\n      png_ptr->zstream.avail_out = 0; /* safety */\n      comp->output_len = output_len;\n\n      /* Now double check the output length, put in a custom message if it is\n       * too long.  Otherwise ensure the z_stream::msg pointer is set to\n       * something.\n       */\n      if (output_len + prefix_len >= PNG_UINT_31_MAX)\n      {\n         png_ptr->zstream.msg = PNGZ_MSG_CAST(\"compressed data too long\");\n         ret = Z_MEM_ERROR;\n      }\n\n      else\n         png_zstream_error(png_ptr, ret);\n\n      /* Reset zlib for another zTXt/iTXt or image data */\n      png_ptr->zowner = 0;\n\n      /* The only success case is Z_STREAM_END, input_len must be 0, if not this\n       * is an internal error.\n       */\n      if (ret == Z_STREAM_END && input_len == 0)\n      {\n         /* Fix up the deflate header, if required */\n         optimize_cmf(comp->output, comp->input_len);\n\n         /* But Z_OK is returned, not Z_STREAM_END; this allows the claim\n          * function above to return Z_STREAM_END on an error (though it never\n          * does in the current versions of zlib.)\n          */\n         return Z_OK;\n      }\n\n      else\n         return ret;\n   }\n}\n\n/* Ship the compressed text out via chunk writes */\nstatic void\npng_write_compressed_data_out(png_structrp png_ptr, compression_state *comp)\n{\n   png_uint_32 output_len = comp->output_len;\n   png_const_bytep output = comp->output;\n   png_uint_32 avail = (sizeof comp->output);\n   png_compression_buffer *next = png_ptr->zbuffer_list;\n\n   for (;;)\n   {\n      if (avail > output_len)\n         avail = output_len;\n\n      png_write_chunk_data(png_ptr, output, avail);\n\n      output_len -= avail;\n\n      if (output_len == 0 || next == NULL)\n         break;\n\n      avail = png_ptr->zbuffer_size;\n      output = next->output;\n      next = next->next;\n   }\n\n   /* This is an internal error; 'next' must have been NULL! */\n   if (output_len > 0)\n      png_error(png_ptr, \"error writing ancillary chunked compressed data\");\n}\n#endif /* PNG_WRITE_COMPRESSED_TEXT_SUPPORTED */\n\n#if defined(PNG_WRITE_TEXT_SUPPORTED) || defined(PNG_WRITE_pCAL_SUPPORTED) || \\\n    defined(PNG_WRITE_iCCP_SUPPORTED) || defined(PNG_WRITE_sPLT_SUPPORTED)\n/* Check that the tEXt or zTXt keyword is valid per PNG 1.0 specification,\n * and if invalid, correct the keyword rather than discarding the entire\n * chunk.  The PNG 1.0 specification requires keywords 1-79 characters in\n * length, forbids leading or trailing whitespace, multiple internal spaces,\n * and the non-break space (0x80) from ISO 8859-1.  Returns keyword length.\n *\n * The 'new_key' buffer must be 80 characters in size (for the keyword plus a\n * trailing '\\0').  If this routine returns 0 then there was no keyword, or a\n * valid one could not be generated, and the caller must png_error.\n */\nstatic png_uint_32\npng_check_keyword(png_structrp png_ptr, png_const_charp key, png_bytep new_key)\n{\n   png_const_charp orig_key = key;\n   png_uint_32 key_len = 0;\n   int bad_character = 0;\n   int space = 1;\n\n   png_debug(1, \"in png_check_keyword\");\n\n   if (key == NULL)\n   {\n      *new_key = 0;\n      return 0;\n   }\n\n   while (*key && key_len < 79)\n   {\n      png_byte ch = (png_byte)(0xff & *key++);\n\n      if ((ch > 32 && ch <= 126) || (ch >= 161 /*&& ch <= 255*/))\n         *new_key++ = ch, ++key_len, space = 0;\n\n      else if (!space)\n      {\n         /* A space or an invalid character when one wasn't seen immediately\n          * before; output just a space.\n          */\n         *new_key++ = 32, ++key_len, space = 1;\n\n         /* If the character was not a space then it is invalid. */\n         if (ch != 32)\n            bad_character = ch;\n      }\n\n      else if (!bad_character)\n         bad_character = ch; /* just skip it, record the first error */\n   }\n\n   if (key_len > 0 && space) /* trailing space */\n   {\n      --key_len, --new_key;\n      if (!bad_character)\n         bad_character = 32;\n   }\n\n   /* Terminate the keyword */\n   *new_key = 0;\n\n   if (key_len == 0)\n      return 0;\n\n   /* Try to only output one warning per keyword: */\n   if (*key) /* keyword too long */\n      png_warning(png_ptr, \"keyword truncated\");\n\n   else if (bad_character)\n   {\n      PNG_WARNING_PARAMETERS(p)\n\n      png_warning_parameter(p, 1, orig_key);\n      png_warning_parameter_signed(p, 2, PNG_NUMBER_FORMAT_02x, bad_character);\n\n      png_formatted_warning(png_ptr, p, \"keyword \\\"@1\\\": bad character '0x@2'\");\n   }\n\n   return key_len;\n}\n#endif\n\n/* Write the IHDR chunk, and update the png_struct with the necessary\n * information.  Note that the rest of this code depends upon this\n * information being correct.\n */\nvoid /* PRIVATE */\npng_write_IHDR(png_structrp png_ptr, png_uint_32 width, png_uint_32 height,\n    int bit_depth, int color_type, int compression_type, int filter_type,\n    int interlace_type)\n{\n   png_byte buf[13]; /* Buffer to store the IHDR info */\n\n   png_debug(1, \"in png_write_IHDR\");\n\n   /* Check that we have valid input data from the application info */\n   switch (color_type)\n   {\n      case PNG_COLOR_TYPE_GRAY:\n         switch (bit_depth)\n         {\n            case 1:\n            case 2:\n            case 4:\n            case 8:\n#ifdef PNG_WRITE_16BIT_SUPPORTED\n            case 16:\n#endif\n               png_ptr->channels = 1; break;\n\n            default:\n               png_error(png_ptr,\n                   \"Invalid bit depth for grayscale image\");\n         }\n         break;\n\n      case PNG_COLOR_TYPE_RGB:\n#ifdef PNG_WRITE_16BIT_SUPPORTED\n         if (bit_depth != 8 && bit_depth != 16)\n#else\n         if (bit_depth != 8)\n#endif\n            png_error(png_ptr, \"Invalid bit depth for RGB image\");\n\n         png_ptr->channels = 3;\n         break;\n\n      case PNG_COLOR_TYPE_PALETTE:\n         switch (bit_depth)\n         {\n            case 1:\n            case 2:\n            case 4:\n            case 8:\n               png_ptr->channels = 1;\n               break;\n\n            default:\n               png_error(png_ptr, \"Invalid bit depth for paletted image\");\n         }\n         break;\n\n      case PNG_COLOR_TYPE_GRAY_ALPHA:\n         if (bit_depth != 8 && bit_depth != 16)\n            png_error(png_ptr, \"Invalid bit depth for grayscale+alpha image\");\n\n         png_ptr->channels = 2;\n         break;\n\n      case PNG_COLOR_TYPE_RGB_ALPHA:\n#ifdef PNG_WRITE_16BIT_SUPPORTED\n         if (bit_depth != 8 && bit_depth != 16)\n#else\n         if (bit_depth != 8)\n#endif\n            png_error(png_ptr, \"Invalid bit depth for RGBA image\");\n\n         png_ptr->channels = 4;\n         break;\n\n      default:\n         png_error(png_ptr, \"Invalid image color type specified\");\n   }\n\n   if (compression_type != PNG_COMPRESSION_TYPE_BASE)\n   {\n      png_warning(png_ptr, \"Invalid compression type specified\");\n      compression_type = PNG_COMPRESSION_TYPE_BASE;\n   }\n\n   /* Write filter_method 64 (intrapixel differencing) only if\n    * 1. Libpng was compiled with PNG_MNG_FEATURES_SUPPORTED and\n    * 2. Libpng did not write a PNG signature (this filter_method is only\n    *    used in PNG datastreams that are embedded in MNG datastreams) and\n    * 3. The application called png_permit_mng_features with a mask that\n    *    included PNG_FLAG_MNG_FILTER_64 and\n    * 4. The filter_method is 64 and\n    * 5. The color_type is RGB or RGBA\n    */\n   if (\n#ifdef PNG_MNG_FEATURES_SUPPORTED\n       !((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) &&\n       ((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE) == 0) &&\n       (color_type == PNG_COLOR_TYPE_RGB ||\n        color_type == PNG_COLOR_TYPE_RGB_ALPHA) &&\n       (filter_type == PNG_INTRAPIXEL_DIFFERENCING)) &&\n#endif\n       filter_type != PNG_FILTER_TYPE_BASE)\n   {\n      png_warning(png_ptr, \"Invalid filter type specified\");\n      filter_type = PNG_FILTER_TYPE_BASE;\n   }\n\n#ifdef PNG_WRITE_INTERLACING_SUPPORTED\n   if (interlace_type != PNG_INTERLACE_NONE &&\n       interlace_type != PNG_INTERLACE_ADAM7)\n   {\n      png_warning(png_ptr, \"Invalid interlace type specified\");\n      interlace_type = PNG_INTERLACE_ADAM7;\n   }\n#else\n   interlace_type=PNG_INTERLACE_NONE;\n#endif\n\n   /* Save the relevent information */\n   png_ptr->bit_depth = (png_byte)bit_depth;\n   png_ptr->color_type = (png_byte)color_type;\n   png_ptr->interlaced = (png_byte)interlace_type;\n#ifdef PNG_MNG_FEATURES_SUPPORTED\n   png_ptr->filter_type = (png_byte)filter_type;\n#endif\n   png_ptr->compression_type = (png_byte)compression_type;\n   png_ptr->width = width;\n   png_ptr->height = height;\n\n   png_ptr->pixel_depth = (png_byte)(bit_depth * png_ptr->channels);\n   png_ptr->rowbytes = PNG_ROWBYTES(png_ptr->pixel_depth, width);\n   /* Set the usr info, so any transformations can modify it */\n   png_ptr->usr_width = png_ptr->width;\n   png_ptr->usr_bit_depth = png_ptr->bit_depth;\n   png_ptr->usr_channels = png_ptr->channels;\n\n   /* Pack the header information into the buffer */\n   png_save_uint_32(buf, width);\n   png_save_uint_32(buf + 4, height);\n   buf[8] = (png_byte)bit_depth;\n   buf[9] = (png_byte)color_type;\n   buf[10] = (png_byte)compression_type;\n   buf[11] = (png_byte)filter_type;\n   buf[12] = (png_byte)interlace_type;\n\n   /* Write the chunk */\n   png_write_complete_chunk(png_ptr, png_IHDR, buf, (png_size_t)13);\n\n   if (!(png_ptr->do_filter))\n   {\n      if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE ||\n          png_ptr->bit_depth < 8)\n         png_ptr->do_filter = PNG_FILTER_NONE;\n\n      else\n         png_ptr->do_filter = PNG_ALL_FILTERS;\n   }\n\n   png_ptr->mode = PNG_HAVE_IHDR; /* not READY_FOR_ZTXT */\n}\n\n/* Write the palette.  We are careful not to trust png_color to be in the\n * correct order for PNG, so people can redefine it to any convenient\n * structure.\n */\nvoid /* PRIVATE */\npng_write_PLTE(png_structrp png_ptr, png_const_colorp palette,\n    png_uint_32 num_pal)\n{\n   png_uint_32 i;\n   png_const_colorp pal_ptr;\n   png_byte buf[3];\n\n   png_debug(1, \"in png_write_PLTE\");\n\n   if ((\n#ifdef PNG_MNG_FEATURES_SUPPORTED\n       !(png_ptr->mng_features_permitted & PNG_FLAG_MNG_EMPTY_PLTE) &&\n#endif\n       num_pal == 0) || num_pal > 256)\n   {\n      if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)\n      {\n         png_error(png_ptr, \"Invalid number of colors in palette\");\n      }\n\n      else\n      {\n         png_warning(png_ptr, \"Invalid number of colors in palette\");\n         return;\n      }\n   }\n\n   if (!(png_ptr->color_type&PNG_COLOR_MASK_COLOR))\n   {\n      png_warning(png_ptr,\n          \"Ignoring request to write a PLTE chunk in grayscale PNG\");\n\n      return;\n   }\n\n   png_ptr->num_palette = (png_uint_16)num_pal;\n   png_debug1(3, \"num_palette = %d\", png_ptr->num_palette);\n\n   png_write_chunk_header(png_ptr, png_PLTE, (png_uint_32)(num_pal * 3));\n#ifdef PNG_POINTER_INDEXING_SUPPORTED\n\n   for (i = 0, pal_ptr = palette; i < num_pal; i++, pal_ptr++)\n   {\n      buf[0] = pal_ptr->red;\n      buf[1] = pal_ptr->green;\n      buf[2] = pal_ptr->blue;\n      png_write_chunk_data(png_ptr, buf, (png_size_t)3);\n   }\n\n#else\n   /* This is a little slower but some buggy compilers need to do this\n    * instead\n    */\n   pal_ptr=palette;\n\n   for (i = 0; i < num_pal; i++)\n   {\n      buf[0] = pal_ptr[i].red;\n      buf[1] = pal_ptr[i].green;\n      buf[2] = pal_ptr[i].blue;\n      png_write_chunk_data(png_ptr, buf, (png_size_t)3);\n   }\n\n#endif\n   png_write_chunk_end(png_ptr);\n   png_ptr->mode |= PNG_HAVE_PLTE;\n}\n\n/* This is similar to png_text_compress, above, except that it does not require\n * all of the data at once and, instead of buffering the compressed result,\n * writes it as IDAT chunks.  Unlike png_text_compress it *can* png_error out\n * because it calls the write interface.  As a result it does its own error\n * reporting and does not return an error code.  In the event of error it will\n * just call png_error.  The input data length may exceed 32-bits.  The 'flush'\n * parameter is exactly the same as that to deflate, with the following\n * meanings:\n *\n * Z_NO_FLUSH: normal incremental output of compressed data\n * Z_SYNC_FLUSH: do a SYNC_FLUSH, used by png_write_flush\n * Z_FINISH: this is the end of the input, do a Z_FINISH and clean up\n *\n * The routine manages the acquire and release of the png_ptr->zstream by\n * checking and (at the end) clearing png_ptr->zowner, it does some sanity\n * checks on the 'mode' flags while doing this.\n */\nvoid /* PRIVATE */\npng_compress_IDAT(png_structrp png_ptr, png_const_bytep input,\n   png_alloc_size_t input_len, int flush)\n{\n   if (png_ptr->zowner != png_IDAT)\n   {\n      /* First time.   Ensure we have a temporary buffer for compression and\n       * trim the buffer list if it has more than one entry to free memory.\n       * If 'WRITE_COMPRESSED_TEXT' is not set the list will never have been\n       * created at this point, but the check here is quick and safe.\n       */\n      if (png_ptr->zbuffer_list == NULL)\n      {\n         png_ptr->zbuffer_list = png_voidcast(png_compression_bufferp,\n            png_malloc(png_ptr, PNG_COMPRESSION_BUFFER_SIZE(png_ptr)));\n         png_ptr->zbuffer_list->next = NULL;\n      }\n\n      else\n         png_free_buffer_list(png_ptr, &png_ptr->zbuffer_list->next);\n\n      /* It is a terminal error if we can't claim the zstream. */\n      if (png_deflate_claim(png_ptr, png_IDAT, png_image_size(png_ptr)) != Z_OK)\n         png_error(png_ptr, png_ptr->zstream.msg);\n\n      /* The output state is maintained in png_ptr->zstream, so it must be\n       * initialized here after the claim.\n       */\n      png_ptr->zstream.next_out = png_ptr->zbuffer_list->output;\n      png_ptr->zstream.avail_out = png_ptr->zbuffer_size;\n   }\n\n   /* Now loop reading and writing until all the input is consumed or an error\n    * terminates the operation.  The _out values are maintained across calls to\n    * this function, but the input must be reset each time.\n    */\n   png_ptr->zstream.next_in = PNGZ_INPUT_CAST(input);\n   png_ptr->zstream.avail_in = 0; /* set below */\n   for (;;)\n   {\n      int ret;\n\n      /* INPUT: from the row data */\n      uInt avail = ZLIB_IO_MAX;\n\n      if (avail > input_len)\n         avail = (uInt)input_len; /* safe because of the check */\n\n      png_ptr->zstream.avail_in = avail;\n      input_len -= avail;\n\n      ret = deflate(&png_ptr->zstream, input_len > 0 ? Z_NO_FLUSH : flush);\n\n      /* Include as-yet unconsumed input */\n      input_len += png_ptr->zstream.avail_in;\n      png_ptr->zstream.avail_in = 0;\n\n      /* OUTPUT: write complete IDAT chunks when avail_out drops to zero, note\n       * that these two zstream fields are preserved across the calls, therefore\n       * there is no need to set these up on entry to the loop.\n       */\n      if (png_ptr->zstream.avail_out == 0)\n      {\n         png_bytep data = png_ptr->zbuffer_list->output;\n         uInt size = png_ptr->zbuffer_size;\n\n         /* Write an IDAT containing the data then reset the buffer.  The\n          * first IDAT may need deflate header optimization.\n          */\n#        ifdef PNG_WRITE_OPTIMIZE_CMF_SUPPORTED\n            if (!(png_ptr->mode & PNG_HAVE_IDAT) &&\n               png_ptr->compression_type == PNG_COMPRESSION_TYPE_BASE)\n               optimize_cmf(data, png_image_size(png_ptr));\n#        endif\n\n         png_write_complete_chunk(png_ptr, png_IDAT, data, size);\n         png_ptr->mode |= PNG_HAVE_IDAT;\n\n         png_ptr->zstream.next_out = data;\n         png_ptr->zstream.avail_out = size;\n\n         /* For SYNC_FLUSH or FINISH it is essential to keep calling zlib with\n          * the same flush parameter until it has finished output, for NO_FLUSH\n          * it doesn't matter.\n          */\n         if (ret == Z_OK && flush != Z_NO_FLUSH)\n            continue;\n      }\n\n      /* The order of these checks doesn't matter much; it just effect which\n       * possible error might be detected if multiple things go wrong at once.\n       */\n      if (ret == Z_OK) /* most likely return code! */\n      {\n         /* If all the input has been consumed then just return.  If Z_FINISH\n          * was used as the flush parameter something has gone wrong if we get\n          * here.\n          */\n         if (input_len == 0)\n         {\n            if (flush == Z_FINISH)\n               png_error(png_ptr, \"Z_OK on Z_FINISH with output space\");\n\n            return;\n         }\n      }\n\n      else if (ret == Z_STREAM_END && flush == Z_FINISH)\n      {\n         /* This is the end of the IDAT data; any pending output must be\n          * flushed.  For small PNG files we may still be at the beginning.\n          */\n         png_bytep data = png_ptr->zbuffer_list->output;\n         uInt size = png_ptr->zbuffer_size - png_ptr->zstream.avail_out;\n\n#        ifdef PNG_WRITE_OPTIMIZE_CMF_SUPPORTED\n            if (!(png_ptr->mode & PNG_HAVE_IDAT) &&\n               png_ptr->compression_type == PNG_COMPRESSION_TYPE_BASE)\n               optimize_cmf(data, png_image_size(png_ptr));\n#        endif\n\n         png_write_complete_chunk(png_ptr, png_IDAT, data, size);\n         png_ptr->zstream.avail_out = 0;\n         png_ptr->zstream.next_out = NULL;\n         png_ptr->mode |= PNG_HAVE_IDAT | PNG_AFTER_IDAT;\n\n         png_ptr->zowner = 0; /* Release the stream */\n         return;\n      }\n\n      else\n      {\n         /* This is an error condition. */\n         png_zstream_error(png_ptr, ret);\n         png_error(png_ptr, png_ptr->zstream.msg);\n      }\n   }\n}\n\n/* Write an IEND chunk */\nvoid /* PRIVATE */\npng_write_IEND(png_structrp png_ptr)\n{\n   png_debug(1, \"in png_write_IEND\");\n\n   png_write_complete_chunk(png_ptr, png_IEND, NULL, (png_size_t)0);\n   png_ptr->mode |= PNG_HAVE_IEND;\n}\n\n#ifdef PNG_WRITE_gAMA_SUPPORTED\n/* Write a gAMA chunk */\nvoid /* PRIVATE */\npng_write_gAMA_fixed(png_structrp png_ptr, png_fixed_point file_gamma)\n{\n   png_byte buf[4];\n\n   png_debug(1, \"in png_write_gAMA\");\n\n   /* file_gamma is saved in 1/100,000ths */\n   png_save_uint_32(buf, (png_uint_32)file_gamma);\n   png_write_complete_chunk(png_ptr, png_gAMA, buf, (png_size_t)4);\n}\n#endif\n\n#ifdef PNG_WRITE_sRGB_SUPPORTED\n/* Write a sRGB chunk */\nvoid /* PRIVATE */\npng_write_sRGB(png_structrp png_ptr, int srgb_intent)\n{\n   png_byte buf[1];\n\n   png_debug(1, \"in png_write_sRGB\");\n\n   if (srgb_intent >= PNG_sRGB_INTENT_LAST)\n      png_warning(png_ptr,\n          \"Invalid sRGB rendering intent specified\");\n\n   buf[0]=(png_byte)srgb_intent;\n   png_write_complete_chunk(png_ptr, png_sRGB, buf, (png_size_t)1);\n}\n#endif\n\n#ifdef PNG_WRITE_iCCP_SUPPORTED\n/* Write an iCCP chunk */\nvoid /* PRIVATE */\npng_write_iCCP(png_structrp png_ptr, png_const_charp name,\n    png_const_bytep profile)\n{\n   png_uint_32 name_len;\n   png_uint_32 profile_len;\n   png_byte new_name[81]; /* 1 byte for the compression byte */\n   compression_state comp;\n\n   png_debug(1, \"in png_write_iCCP\");\n\n   /* These are all internal problems: the profile should have been checked\n    * before when it was stored.\n    */\n   if (profile == NULL)\n      png_error(png_ptr, \"No profile for iCCP chunk\"); /* internal error */\n\n   profile_len = png_get_uint_32(profile);\n\n   if (profile_len < 132)\n      png_error(png_ptr, \"ICC profile too short\");\n\n   if (profile_len & 0x03)\n      png_error(png_ptr, \"ICC profile length invalid (not a multiple of 4)\");\n\n   {\n      png_uint_32 embedded_profile_len = png_get_uint_32(profile);\n\n      if (profile_len != embedded_profile_len)\n         png_error(png_ptr, \"Profile length does not match profile\");\n   }\n\n   name_len = png_check_keyword(png_ptr, name, new_name);\n\n   if (name_len == 0)\n      png_error(png_ptr, \"iCCP: invalid keyword\");\n\n   new_name[++name_len] = PNG_COMPRESSION_TYPE_BASE;\n\n   /* Make sure we include the NULL after the name and the compression type */\n   ++name_len;\n\n   png_text_compress_init(&comp, profile, profile_len);\n\n   /* Allow for keyword terminator and compression byte */\n   if (png_text_compress(png_ptr, png_iCCP, &comp, name_len) != Z_OK)\n      png_error(png_ptr, png_ptr->zstream.msg);\n\n   png_write_chunk_header(png_ptr, png_iCCP, name_len + comp.output_len);\n\n   png_write_chunk_data(png_ptr, new_name, name_len);\n\n   png_write_compressed_data_out(png_ptr, &comp);\n\n   png_write_chunk_end(png_ptr);\n}\n#endif\n\n#ifdef PNG_WRITE_sPLT_SUPPORTED\n/* Write a sPLT chunk */\nvoid /* PRIVATE */\npng_write_sPLT(png_structrp png_ptr, png_const_sPLT_tp spalette)\n{\n   png_uint_32 name_len;\n   png_byte new_name[80];\n   png_byte entrybuf[10];\n   png_size_t entry_size = (spalette->depth == 8 ? 6 : 10);\n   png_size_t palette_size = entry_size * spalette->nentries;\n   png_sPLT_entryp ep;\n#ifndef PNG_POINTER_INDEXING_SUPPORTED\n   int i;\n#endif\n\n   png_debug(1, \"in png_write_sPLT\");\n\n   name_len = png_check_keyword(png_ptr, spalette->name, new_name);\n\n   if (name_len == 0)\n      png_error(png_ptr, \"sPLT: invalid keyword\");\n\n   /* Make sure we include the NULL after the name */\n   png_write_chunk_header(png_ptr, png_sPLT,\n       (png_uint_32)(name_len + 2 + palette_size));\n\n   png_write_chunk_data(png_ptr, (png_bytep)new_name,\n       (png_size_t)(name_len + 1));\n\n   png_write_chunk_data(png_ptr, &spalette->depth, (png_size_t)1);\n\n   /* Loop through each palette entry, writing appropriately */\n#ifdef PNG_POINTER_INDEXING_SUPPORTED\n   for (ep = spalette->entries; ep<spalette->entries + spalette->nentries; ep++)\n   {\n      if (spalette->depth == 8)\n      {\n         entrybuf[0] = (png_byte)ep->red;\n         entrybuf[1] = (png_byte)ep->green;\n         entrybuf[2] = (png_byte)ep->blue;\n         entrybuf[3] = (png_byte)ep->alpha;\n         png_save_uint_16(entrybuf + 4, ep->frequency);\n      }\n\n      else\n      {\n         png_save_uint_16(entrybuf + 0, ep->red);\n         png_save_uint_16(entrybuf + 2, ep->green);\n         png_save_uint_16(entrybuf + 4, ep->blue);\n         png_save_uint_16(entrybuf + 6, ep->alpha);\n         png_save_uint_16(entrybuf + 8, ep->frequency);\n      }\n\n      png_write_chunk_data(png_ptr, entrybuf, entry_size);\n   }\n#else\n   ep=spalette->entries;\n   for (i = 0; i>spalette->nentries; i++)\n   {\n      if (spalette->depth == 8)\n      {\n         entrybuf[0] = (png_byte)ep[i].red;\n         entrybuf[1] = (png_byte)ep[i].green;\n         entrybuf[2] = (png_byte)ep[i].blue;\n         entrybuf[3] = (png_byte)ep[i].alpha;\n         png_save_uint_16(entrybuf + 4, ep[i].frequency);\n      }\n\n      else\n      {\n         png_save_uint_16(entrybuf + 0, ep[i].red);\n         png_save_uint_16(entrybuf + 2, ep[i].green);\n         png_save_uint_16(entrybuf + 4, ep[i].blue);\n         png_save_uint_16(entrybuf + 6, ep[i].alpha);\n         png_save_uint_16(entrybuf + 8, ep[i].frequency);\n      }\n\n      png_write_chunk_data(png_ptr, entrybuf, entry_size);\n   }\n#endif\n\n   png_write_chunk_end(png_ptr);\n}\n#endif\n\n#ifdef PNG_WRITE_sBIT_SUPPORTED\n/* Write the sBIT chunk */\nvoid /* PRIVATE */\npng_write_sBIT(png_structrp png_ptr, png_const_color_8p sbit, int color_type)\n{\n   png_byte buf[4];\n   png_size_t size;\n\n   png_debug(1, \"in png_write_sBIT\");\n\n   /* Make sure we don't depend upon the order of PNG_COLOR_8 */\n   if (color_type & PNG_COLOR_MASK_COLOR)\n   {\n      png_byte maxbits;\n\n      maxbits = (png_byte)(color_type==PNG_COLOR_TYPE_PALETTE ? 8 :\n          png_ptr->usr_bit_depth);\n\n      if (sbit->red == 0 || sbit->red > maxbits ||\n          sbit->green == 0 || sbit->green > maxbits ||\n          sbit->blue == 0 || sbit->blue > maxbits)\n      {\n         png_warning(png_ptr, \"Invalid sBIT depth specified\");\n         return;\n      }\n\n      buf[0] = sbit->red;\n      buf[1] = sbit->green;\n      buf[2] = sbit->blue;\n      size = 3;\n   }\n\n   else\n   {\n      if (sbit->gray == 0 || sbit->gray > png_ptr->usr_bit_depth)\n      {\n         png_warning(png_ptr, \"Invalid sBIT depth specified\");\n         return;\n      }\n\n      buf[0] = sbit->gray;\n      size = 1;\n   }\n\n   if (color_type & PNG_COLOR_MASK_ALPHA)\n   {\n      if (sbit->alpha == 0 || sbit->alpha > png_ptr->usr_bit_depth)\n      {\n         png_warning(png_ptr, \"Invalid sBIT depth specified\");\n         return;\n      }\n\n      buf[size++] = sbit->alpha;\n   }\n\n   png_write_complete_chunk(png_ptr, png_sBIT, buf, size);\n}\n#endif\n\n#ifdef PNG_WRITE_cHRM_SUPPORTED\n/* Write the cHRM chunk */\nvoid /* PRIVATE */\npng_write_cHRM_fixed(png_structrp png_ptr, const png_xy *xy)\n{\n   png_byte buf[32];\n\n   png_debug(1, \"in png_write_cHRM\");\n\n   /* Each value is saved in 1/100,000ths */\n   png_save_int_32(buf,      xy->whitex);\n   png_save_int_32(buf +  4, xy->whitey);\n\n   png_save_int_32(buf +  8, xy->redx);\n   png_save_int_32(buf + 12, xy->redy);\n\n   png_save_int_32(buf + 16, xy->greenx);\n   png_save_int_32(buf + 20, xy->greeny);\n\n   png_save_int_32(buf + 24, xy->bluex);\n   png_save_int_32(buf + 28, xy->bluey);\n\n   png_write_complete_chunk(png_ptr, png_cHRM, buf, 32);\n}\n#endif\n\n#ifdef PNG_WRITE_tRNS_SUPPORTED\n/* Write the tRNS chunk */\nvoid /* PRIVATE */\npng_write_tRNS(png_structrp png_ptr, png_const_bytep trans_alpha,\n    png_const_color_16p tran, int num_trans, int color_type)\n{\n   png_byte buf[6];\n\n   png_debug(1, \"in png_write_tRNS\");\n\n   if (color_type == PNG_COLOR_TYPE_PALETTE)\n   {\n      if (num_trans <= 0 || num_trans > (int)png_ptr->num_palette)\n      {\n         png_app_warning(png_ptr,\n             \"Invalid number of transparent colors specified\");\n         return;\n      }\n\n      /* Write the chunk out as it is */\n      png_write_complete_chunk(png_ptr, png_tRNS, trans_alpha,\n         (png_size_t)num_trans);\n   }\n\n   else if (color_type == PNG_COLOR_TYPE_GRAY)\n   {\n      /* One 16 bit value */\n      if (tran->gray >= (1 << png_ptr->bit_depth))\n      {\n         png_app_warning(png_ptr,\n             \"Ignoring attempt to write tRNS chunk out-of-range for bit_depth\");\n\n         return;\n      }\n\n      png_save_uint_16(buf, tran->gray);\n      png_write_complete_chunk(png_ptr, png_tRNS, buf, (png_size_t)2);\n   }\n\n   else if (color_type == PNG_COLOR_TYPE_RGB)\n   {\n      /* Three 16 bit values */\n      png_save_uint_16(buf, tran->red);\n      png_save_uint_16(buf + 2, tran->green);\n      png_save_uint_16(buf + 4, tran->blue);\n#ifdef PNG_WRITE_16BIT_SUPPORTED\n      if (png_ptr->bit_depth == 8 && (buf[0] | buf[2] | buf[4]))\n#else\n      if (buf[0] | buf[2] | buf[4])\n#endif\n      {\n         png_app_warning(png_ptr,\n           \"Ignoring attempt to write 16-bit tRNS chunk when bit_depth is 8\");\n         return;\n      }\n\n      png_write_complete_chunk(png_ptr, png_tRNS, buf, (png_size_t)6);\n   }\n\n   else\n   {\n      png_app_warning(png_ptr, \"Can't write tRNS with an alpha channel\");\n   }\n}\n#endif\n\n#ifdef PNG_WRITE_bKGD_SUPPORTED\n/* Write the background chunk */\nvoid /* PRIVATE */\npng_write_bKGD(png_structrp png_ptr, png_const_color_16p back, int color_type)\n{\n   png_byte buf[6];\n\n   png_debug(1, \"in png_write_bKGD\");\n\n   if (color_type == PNG_COLOR_TYPE_PALETTE)\n   {\n      if (\n#ifdef PNG_MNG_FEATURES_SUPPORTED\n          (png_ptr->num_palette ||\n          (!(png_ptr->mng_features_permitted & PNG_FLAG_MNG_EMPTY_PLTE))) &&\n#endif\n         back->index >= png_ptr->num_palette)\n      {\n         png_warning(png_ptr, \"Invalid background palette index\");\n         return;\n      }\n\n      buf[0] = back->index;\n      png_write_complete_chunk(png_ptr, png_bKGD, buf, (png_size_t)1);\n   }\n\n   else if (color_type & PNG_COLOR_MASK_COLOR)\n   {\n      png_save_uint_16(buf, back->red);\n      png_save_uint_16(buf + 2, back->green);\n      png_save_uint_16(buf + 4, back->blue);\n#ifdef PNG_WRITE_16BIT_SUPPORTED\n      if (png_ptr->bit_depth == 8 && (buf[0] | buf[2] | buf[4]))\n#else\n      if (buf[0] | buf[2] | buf[4])\n#endif\n      {\n         png_warning(png_ptr,\n             \"Ignoring attempt to write 16-bit bKGD chunk when bit_depth is 8\");\n\n         return;\n      }\n\n      png_write_complete_chunk(png_ptr, png_bKGD, buf, (png_size_t)6);\n   }\n\n   else\n   {\n      if (back->gray >= (1 << png_ptr->bit_depth))\n      {\n         png_warning(png_ptr,\n             \"Ignoring attempt to write bKGD chunk out-of-range for bit_depth\");\n\n         return;\n      }\n\n      png_save_uint_16(buf, back->gray);\n      png_write_complete_chunk(png_ptr, png_bKGD, buf, (png_size_t)2);\n   }\n}\n#endif\n\n#ifdef PNG_WRITE_hIST_SUPPORTED\n/* Write the histogram */\nvoid /* PRIVATE */\npng_write_hIST(png_structrp png_ptr, png_const_uint_16p hist, int num_hist)\n{\n   int i;\n   png_byte buf[3];\n\n   png_debug(1, \"in png_write_hIST\");\n\n   if (num_hist > (int)png_ptr->num_palette)\n   {\n      png_debug2(3, \"num_hist = %d, num_palette = %d\", num_hist,\n          png_ptr->num_palette);\n\n      png_warning(png_ptr, \"Invalid number of histogram entries specified\");\n      return;\n   }\n\n   png_write_chunk_header(png_ptr, png_hIST, (png_uint_32)(num_hist * 2));\n\n   for (i = 0; i < num_hist; i++)\n   {\n      png_save_uint_16(buf, hist[i]);\n      png_write_chunk_data(png_ptr, buf, (png_size_t)2);\n   }\n\n   png_write_chunk_end(png_ptr);\n}\n#endif\n\n#ifdef PNG_WRITE_tEXt_SUPPORTED\n/* Write a tEXt chunk */\nvoid /* PRIVATE */\npng_write_tEXt(png_structrp png_ptr, png_const_charp key, png_const_charp text,\n    png_size_t text_len)\n{\n   png_uint_32 key_len;\n   png_byte new_key[80];\n\n   png_debug(1, \"in png_write_tEXt\");\n\n   key_len = png_check_keyword(png_ptr, key, new_key);\n\n   if (key_len == 0)\n      png_error(png_ptr, \"tEXt: invalid keyword\");\n\n   if (text == NULL || *text == '\\0')\n      text_len = 0;\n\n   else\n      text_len = strlen(text);\n\n   if (text_len > PNG_UINT_31_MAX - (key_len+1))\n      png_error(png_ptr, \"tEXt: text too long\");\n\n   /* Make sure we include the 0 after the key */\n   png_write_chunk_header(png_ptr, png_tEXt,\n       (png_uint_32)/*checked above*/(key_len + text_len + 1));\n   /*\n    * We leave it to the application to meet PNG-1.0 requirements on the\n    * contents of the text.  PNG-1.0 through PNG-1.2 discourage the use of\n    * any non-Latin-1 characters except for NEWLINE.  ISO PNG will forbid them.\n    * The NUL character is forbidden by PNG-1.0 through PNG-1.2 and ISO PNG.\n    */\n   png_write_chunk_data(png_ptr, new_key, key_len + 1);\n\n   if (text_len)\n      png_write_chunk_data(png_ptr, (png_const_bytep)text, text_len);\n\n   png_write_chunk_end(png_ptr);\n}\n#endif\n\n#ifdef PNG_WRITE_zTXt_SUPPORTED\n/* Write a compressed text chunk */\nvoid /* PRIVATE */\npng_write_zTXt(png_structrp png_ptr, png_const_charp key, png_const_charp text,\n    png_size_t text_len, int compression)\n{\n   png_uint_32 key_len;\n   png_byte new_key[81];\n   compression_state comp;\n\n   png_debug(1, \"in png_write_zTXt\");\n   PNG_UNUSED(text_len) /* Always use strlen */\n\n   if (compression == PNG_TEXT_COMPRESSION_NONE)\n   {\n      png_write_tEXt(png_ptr, key, text, 0);\n      return;\n   }\n\n   if (compression != PNG_TEXT_COMPRESSION_zTXt)\n      png_error(png_ptr, \"zTXt: invalid compression type\");\n\n   key_len = png_check_keyword(png_ptr, key, new_key);\n\n   if (key_len == 0)\n      png_error(png_ptr, \"zTXt: invalid keyword\");\n\n   /* Add the compression method and 1 for the keyword separator. */\n   new_key[++key_len] = PNG_COMPRESSION_TYPE_BASE;\n   ++key_len;\n\n   /* Compute the compressed data; do it now for the length */\n   png_text_compress_init(&comp, (png_const_bytep)text,\n      text == NULL ? 0 : strlen(text));\n\n   if (png_text_compress(png_ptr, png_zTXt, &comp, key_len) != Z_OK)\n      png_error(png_ptr, png_ptr->zstream.msg);\n\n   /* Write start of chunk */\n   png_write_chunk_header(png_ptr, png_zTXt, key_len + comp.output_len);\n\n   /* Write key */\n   png_write_chunk_data(png_ptr, new_key, key_len);\n\n   /* Write the compressed data */\n   png_write_compressed_data_out(png_ptr, &comp);\n\n   /* Close the chunk */\n   png_write_chunk_end(png_ptr);\n}\n#endif\n\n#ifdef PNG_WRITE_iTXt_SUPPORTED\n/* Write an iTXt chunk */\nvoid /* PRIVATE */\npng_write_iTXt(png_structrp png_ptr, int compression, png_const_charp key,\n    png_const_charp lang, png_const_charp lang_key, png_const_charp text)\n{\n   png_uint_32 key_len, prefix_len;\n   png_size_t lang_len, lang_key_len;\n   png_byte new_key[82];\n   compression_state comp;\n\n   png_debug(1, \"in png_write_iTXt\");\n\n   key_len = png_check_keyword(png_ptr, key, new_key);\n\n   if (key_len == 0)\n      png_error(png_ptr, \"iTXt: invalid keyword\");\n\n   /* Set the compression flag */\n   switch (compression)\n   {\n      case PNG_ITXT_COMPRESSION_NONE:\n      case PNG_TEXT_COMPRESSION_NONE:\n         compression = new_key[++key_len] = 0; /* no compression */\n         break;\n\n      case PNG_TEXT_COMPRESSION_zTXt:\n      case PNG_ITXT_COMPRESSION_zTXt:\n         compression = new_key[++key_len] = 1; /* compressed */\n         break;\n\n      default:\n         png_error(png_ptr, \"iTXt: invalid compression\");\n   }\n\n   new_key[++key_len] = PNG_COMPRESSION_TYPE_BASE;\n   ++key_len; /* for the keywod separator */\n\n   /* We leave it to the application to meet PNG-1.0 requirements on the\n    * contents of the text.  PNG-1.0 through PNG-1.2 discourage the use of\n    * any non-Latin-1 characters except for NEWLINE.  ISO PNG, however,\n    * specifies that the text is UTF-8 and this really doesn't require any\n    * checking.\n    *\n    * The NUL character is forbidden by PNG-1.0 through PNG-1.2 and ISO PNG.\n    *\n    * TODO: validate the language tag correctly (see the spec.)\n    */\n   if (lang == NULL) lang = \"\"; /* empty language is valid */\n   lang_len = strlen(lang)+1;\n   if (lang_key == NULL) lang_key = \"\"; /* may be empty */\n   lang_key_len = strlen(lang_key)+1;\n   if (text == NULL) text = \"\"; /* may be empty */\n\n   prefix_len = key_len;\n   if (lang_len > PNG_UINT_31_MAX-prefix_len)\n      prefix_len = PNG_UINT_31_MAX;\n   else\n      prefix_len = (png_uint_32)(prefix_len + lang_len);\n\n   if (lang_key_len > PNG_UINT_31_MAX-prefix_len)\n      prefix_len = PNG_UINT_31_MAX;\n   else\n      prefix_len = (png_uint_32)(prefix_len + lang_key_len);\n\n   png_text_compress_init(&comp, (png_const_bytep)text, strlen(text));\n\n   if (compression)\n   {\n      if (png_text_compress(png_ptr, png_iTXt, &comp, prefix_len) != Z_OK)\n         png_error(png_ptr, png_ptr->zstream.msg);\n   }\n\n   else\n   {\n      if (comp.input_len > PNG_UINT_31_MAX-prefix_len)\n         png_error(png_ptr, \"iTXt: uncompressed text too long\");\n\n      /* So the string will fit in a chunk: */\n      comp.output_len = (png_uint_32)/*SAFE*/comp.input_len;\n   }\n\n   png_write_chunk_header(png_ptr, png_iTXt, comp.output_len + prefix_len);\n\n   png_write_chunk_data(png_ptr, new_key, key_len);\n\n   png_write_chunk_data(png_ptr, (png_const_bytep)lang, lang_len);\n\n   png_write_chunk_data(png_ptr, (png_const_bytep)lang_key, lang_key_len);\n\n   if (compression)\n      png_write_compressed_data_out(png_ptr, &comp);\n\n   else\n      png_write_chunk_data(png_ptr, (png_const_bytep)text, comp.input_len);\n\n   png_write_chunk_end(png_ptr);\n}\n#endif\n\n#ifdef PNG_WRITE_oFFs_SUPPORTED\n/* Write the oFFs chunk */\nvoid /* PRIVATE */\npng_write_oFFs(png_structrp png_ptr, png_int_32 x_offset, png_int_32 y_offset,\n    int unit_type)\n{\n   png_byte buf[9];\n\n   png_debug(1, \"in png_write_oFFs\");\n\n   if (unit_type >= PNG_OFFSET_LAST)\n      png_warning(png_ptr, \"Unrecognized unit type for oFFs chunk\");\n\n   png_save_int_32(buf, x_offset);\n   png_save_int_32(buf + 4, y_offset);\n   buf[8] = (png_byte)unit_type;\n\n   png_write_complete_chunk(png_ptr, png_oFFs, buf, (png_size_t)9);\n}\n#endif\n#ifdef PNG_WRITE_pCAL_SUPPORTED\n/* Write the pCAL chunk (described in the PNG extensions document) */\nvoid /* PRIVATE */\npng_write_pCAL(png_structrp png_ptr, png_charp purpose, png_int_32 X0,\n    png_int_32 X1, int type, int nparams, png_const_charp units,\n    png_charpp params)\n{\n   png_uint_32 purpose_len;\n   png_size_t units_len, total_len;\n   png_size_tp params_len;\n   png_byte buf[10];\n   png_byte new_purpose[80];\n   int i;\n\n   png_debug1(1, \"in png_write_pCAL (%d parameters)\", nparams);\n\n   if (type >= PNG_EQUATION_LAST)\n      png_error(png_ptr, \"Unrecognized equation type for pCAL chunk\");\n\n   purpose_len = png_check_keyword(png_ptr, purpose, new_purpose);\n\n   if (purpose_len == 0)\n      png_error(png_ptr, \"pCAL: invalid keyword\");\n\n   ++purpose_len; /* terminator */\n\n   png_debug1(3, \"pCAL purpose length = %d\", (int)purpose_len);\n   units_len = strlen(units) + (nparams == 0 ? 0 : 1);\n   png_debug1(3, \"pCAL units length = %d\", (int)units_len);\n   total_len = purpose_len + units_len + 10;\n\n   params_len = (png_size_tp)png_malloc(png_ptr,\n       (png_alloc_size_t)(nparams * (sizeof (png_size_t))));\n\n   /* Find the length of each parameter, making sure we don't count the\n    * null terminator for the last parameter.\n    */\n   for (i = 0; i < nparams; i++)\n   {\n      params_len[i] = strlen(params[i]) + (i == nparams - 1 ? 0 : 1);\n      png_debug2(3, \"pCAL parameter %d length = %lu\", i,\n          (unsigned long)params_len[i]);\n      total_len += params_len[i];\n   }\n\n   png_debug1(3, \"pCAL total length = %d\", (int)total_len);\n   png_write_chunk_header(png_ptr, png_pCAL, (png_uint_32)total_len);\n   png_write_chunk_data(png_ptr, new_purpose, purpose_len);\n   png_save_int_32(buf, X0);\n   png_save_int_32(buf + 4, X1);\n   buf[8] = (png_byte)type;\n   buf[9] = (png_byte)nparams;\n   png_write_chunk_data(png_ptr, buf, (png_size_t)10);\n   png_write_chunk_data(png_ptr, (png_const_bytep)units, (png_size_t)units_len);\n\n   for (i = 0; i < nparams; i++)\n   {\n      png_write_chunk_data(png_ptr, (png_const_bytep)params[i], params_len[i]);\n   }\n\n   png_free(png_ptr, params_len);\n   png_write_chunk_end(png_ptr);\n}\n#endif\n\n#ifdef PNG_WRITE_sCAL_SUPPORTED\n/* Write the sCAL chunk */\nvoid /* PRIVATE */\npng_write_sCAL_s(png_structrp png_ptr, int unit, png_const_charp width,\n    png_const_charp height)\n{\n   png_byte buf[64];\n   png_size_t wlen, hlen, total_len;\n\n   png_debug(1, \"in png_write_sCAL_s\");\n\n   wlen = strlen(width);\n   hlen = strlen(height);\n   total_len = wlen + hlen + 2;\n\n   if (total_len > 64)\n   {\n      png_warning(png_ptr, \"Can't write sCAL (buffer too small)\");\n      return;\n   }\n\n   buf[0] = (png_byte)unit;\n   memcpy(buf + 1, width, wlen + 1);      /* Append the '\\0' here */\n   memcpy(buf + wlen + 2, height, hlen);  /* Do NOT append the '\\0' here */\n\n   png_debug1(3, \"sCAL total length = %u\", (unsigned int)total_len);\n   png_write_complete_chunk(png_ptr, png_sCAL, buf, total_len);\n}\n#endif\n\n#ifdef PNG_WRITE_pHYs_SUPPORTED\n/* Write the pHYs chunk */\nvoid /* PRIVATE */\npng_write_pHYs(png_structrp png_ptr, png_uint_32 x_pixels_per_unit,\n    png_uint_32 y_pixels_per_unit,\n    int unit_type)\n{\n   png_byte buf[9];\n\n   png_debug(1, \"in png_write_pHYs\");\n\n   if (unit_type >= PNG_RESOLUTION_LAST)\n      png_warning(png_ptr, \"Unrecognized unit type for pHYs chunk\");\n\n   png_save_uint_32(buf, x_pixels_per_unit);\n   png_save_uint_32(buf + 4, y_pixels_per_unit);\n   buf[8] = (png_byte)unit_type;\n\n   png_write_complete_chunk(png_ptr, png_pHYs, buf, (png_size_t)9);\n}\n#endif\n\n#ifdef PNG_WRITE_tIME_SUPPORTED\n/* Write the tIME chunk.  Use either png_convert_from_struct_tm()\n * or png_convert_from_time_t(), or fill in the structure yourself.\n */\nvoid /* PRIVATE */\npng_write_tIME(png_structrp png_ptr, png_const_timep mod_time)\n{\n   png_byte buf[7];\n\n   png_debug(1, \"in png_write_tIME\");\n\n   if (mod_time->month  > 12 || mod_time->month  < 1 ||\n       mod_time->day    > 31 || mod_time->day    < 1 ||\n       mod_time->hour   > 23 || mod_time->second > 60)\n   {\n      png_warning(png_ptr, \"Invalid time specified for tIME chunk\");\n      return;\n   }\n\n   png_save_uint_16(buf, mod_time->year);\n   buf[2] = mod_time->month;\n   buf[3] = mod_time->day;\n   buf[4] = mod_time->hour;\n   buf[5] = mod_time->minute;\n   buf[6] = mod_time->second;\n\n   png_write_complete_chunk(png_ptr, png_tIME, buf, (png_size_t)7);\n}\n#endif\n\n/* Initializes the row writing capability of libpng */\nvoid /* PRIVATE */\npng_write_start_row(png_structrp png_ptr)\n{\n#ifdef PNG_WRITE_INTERLACING_SUPPORTED\n   /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */\n\n   /* Start of interlace block */\n   static PNG_CONST png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};\n\n   /* Offset to next interlace block */\n   static PNG_CONST png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};\n\n   /* Start of interlace block in the y direction */\n   static PNG_CONST png_byte png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1};\n\n   /* Offset to next interlace block in the y direction */\n   static PNG_CONST png_byte png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};\n#endif\n\n   png_alloc_size_t buf_size;\n   int usr_pixel_depth;\n\n   png_debug(1, \"in png_write_start_row\");\n\n   usr_pixel_depth = png_ptr->usr_channels * png_ptr->usr_bit_depth;\n   buf_size = PNG_ROWBYTES(usr_pixel_depth, png_ptr->width) + 1;\n\n   /* 1.5.6: added to allow checking in the row write code. */\n   png_ptr->transformed_pixel_depth = png_ptr->pixel_depth;\n   png_ptr->maximum_pixel_depth = (png_byte)usr_pixel_depth;\n\n   /* Set up row buffer */\n   png_ptr->row_buf = (png_bytep)png_malloc(png_ptr, buf_size);\n\n   png_ptr->row_buf[0] = PNG_FILTER_VALUE_NONE;\n\n#ifdef PNG_WRITE_FILTER_SUPPORTED\n   /* Set up filtering buffer, if using this filter */\n   if (png_ptr->do_filter & PNG_FILTER_SUB)\n   {\n      png_ptr->sub_row = (png_bytep)png_malloc(png_ptr, png_ptr->rowbytes + 1);\n\n      png_ptr->sub_row[0] = PNG_FILTER_VALUE_SUB;\n   }\n\n   /* We only need to keep the previous row if we are using one of these. */\n   if (png_ptr->do_filter & (PNG_FILTER_AVG | PNG_FILTER_UP | PNG_FILTER_PAETH))\n   {\n      /* Set up previous row buffer */\n      png_ptr->prev_row = (png_bytep)png_calloc(png_ptr, buf_size);\n\n      if (png_ptr->do_filter & PNG_FILTER_UP)\n      {\n         png_ptr->up_row = (png_bytep)png_malloc(png_ptr,\n            png_ptr->rowbytes + 1);\n\n         png_ptr->up_row[0] = PNG_FILTER_VALUE_UP;\n      }\n\n      if (png_ptr->do_filter & PNG_FILTER_AVG)\n      {\n         png_ptr->avg_row = (png_bytep)png_malloc(png_ptr,\n             png_ptr->rowbytes + 1);\n\n         png_ptr->avg_row[0] = PNG_FILTER_VALUE_AVG;\n      }\n\n      if (png_ptr->do_filter & PNG_FILTER_PAETH)\n      {\n         png_ptr->paeth_row = (png_bytep)png_malloc(png_ptr,\n             png_ptr->rowbytes + 1);\n\n         png_ptr->paeth_row[0] = PNG_FILTER_VALUE_PAETH;\n      }\n   }\n#endif /* PNG_WRITE_FILTER_SUPPORTED */\n\n#ifdef PNG_WRITE_INTERLACING_SUPPORTED\n   /* If interlaced, we need to set up width and height of pass */\n   if (png_ptr->interlaced)\n   {\n      if (!(png_ptr->transformations & PNG_INTERLACE))\n      {\n         png_ptr->num_rows = (png_ptr->height + png_pass_yinc[0] - 1 -\n             png_pass_ystart[0]) / png_pass_yinc[0];\n\n         png_ptr->usr_width = (png_ptr->width + png_pass_inc[0] - 1 -\n             png_pass_start[0]) / png_pass_inc[0];\n      }\n\n      else\n      {\n         png_ptr->num_rows = png_ptr->height;\n         png_ptr->usr_width = png_ptr->width;\n      }\n   }\n\n   else\n#endif\n   {\n      png_ptr->num_rows = png_ptr->height;\n      png_ptr->usr_width = png_ptr->width;\n   }\n}\n\n/* Internal use only.  Called when finished processing a row of data. */\nvoid /* PRIVATE */\npng_write_finish_row(png_structrp png_ptr)\n{\n#ifdef PNG_WRITE_INTERLACING_SUPPORTED\n   /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */\n\n   /* Start of interlace block */\n   static PNG_CONST png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};\n\n   /* Offset to next interlace block */\n   static PNG_CONST png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};\n\n   /* Start of interlace block in the y direction */\n   static PNG_CONST png_byte png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1};\n\n   /* Offset to next interlace block in the y direction */\n   static PNG_CONST png_byte png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};\n#endif\n\n   png_debug(1, \"in png_write_finish_row\");\n\n   /* Next row */\n   png_ptr->row_number++;\n\n   /* See if we are done */\n   if (png_ptr->row_number < png_ptr->num_rows)\n      return;\n\n#ifdef PNG_WRITE_INTERLACING_SUPPORTED\n   /* If interlaced, go to next pass */\n   if (png_ptr->interlaced)\n   {\n      png_ptr->row_number = 0;\n      if (png_ptr->transformations & PNG_INTERLACE)\n      {\n         png_ptr->pass++;\n      }\n\n      else\n      {\n         /* Loop until we find a non-zero width or height pass */\n         do\n         {\n            png_ptr->pass++;\n\n            if (png_ptr->pass >= 7)\n               break;\n\n            png_ptr->usr_width = (png_ptr->width +\n                png_pass_inc[png_ptr->pass] - 1 -\n                png_pass_start[png_ptr->pass]) /\n                png_pass_inc[png_ptr->pass];\n\n            png_ptr->num_rows = (png_ptr->height +\n                png_pass_yinc[png_ptr->pass] - 1 -\n                png_pass_ystart[png_ptr->pass]) /\n                png_pass_yinc[png_ptr->pass];\n\n            if (png_ptr->transformations & PNG_INTERLACE)\n               break;\n\n         } while (png_ptr->usr_width == 0 || png_ptr->num_rows == 0);\n\n      }\n\n      /* Reset the row above the image for the next pass */\n      if (png_ptr->pass < 7)\n      {\n         if (png_ptr->prev_row != NULL)\n            memset(png_ptr->prev_row, 0,\n                (png_size_t)(PNG_ROWBYTES(png_ptr->usr_channels*\n                png_ptr->usr_bit_depth, png_ptr->width)) + 1);\n\n         return;\n      }\n   }\n#endif\n\n   /* If we get here, we've just written the last row, so we need\n      to flush the compressor */\n   png_compress_IDAT(png_ptr, NULL, 0, Z_FINISH);\n}\n\n#ifdef PNG_WRITE_INTERLACING_SUPPORTED\n/* Pick out the correct pixels for the interlace pass.\n * The basic idea here is to go through the row with a source\n * pointer and a destination pointer (sp and dp), and copy the\n * correct pixels for the pass.  As the row gets compacted,\n * sp will always be >= dp, so we should never overwrite anything.\n * See the default: case for the easiest code to understand.\n */\nvoid /* PRIVATE */\npng_do_write_interlace(png_row_infop row_info, png_bytep row, int pass)\n{\n   /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */\n\n   /* Start of interlace block */\n   static PNG_CONST png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};\n\n   /* Offset to next interlace block */\n   static PNG_CONST png_byte  png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};\n\n   png_debug(1, \"in png_do_write_interlace\");\n\n   /* We don't have to do anything on the last pass (6) */\n   if (pass < 6)\n   {\n      /* Each pixel depth is handled separately */\n      switch (row_info->pixel_depth)\n      {\n         case 1:\n         {\n            png_bytep sp;\n            png_bytep dp;\n            int shift;\n            int d;\n            int value;\n            png_uint_32 i;\n            png_uint_32 row_width = row_info->width;\n\n            dp = row;\n            d = 0;\n            shift = 7;\n\n            for (i = png_pass_start[pass]; i < row_width;\n               i += png_pass_inc[pass])\n            {\n               sp = row + (png_size_t)(i >> 3);\n               value = (int)(*sp >> (7 - (int)(i & 0x07))) & 0x01;\n               d |= (value << shift);\n\n               if (shift == 0)\n               {\n                  shift = 7;\n                  *dp++ = (png_byte)d;\n                  d = 0;\n               }\n\n               else\n                  shift--;\n\n            }\n            if (shift != 7)\n               *dp = (png_byte)d;\n\n            break;\n         }\n\n         case 2:\n         {\n            png_bytep sp;\n            png_bytep dp;\n            int shift;\n            int d;\n            int value;\n            png_uint_32 i;\n            png_uint_32 row_width = row_info->width;\n\n            dp = row;\n            shift = 6;\n            d = 0;\n\n            for (i = png_pass_start[pass]; i < row_width;\n               i += png_pass_inc[pass])\n            {\n               sp = row + (png_size_t)(i >> 2);\n               value = (*sp >> ((3 - (int)(i & 0x03)) << 1)) & 0x03;\n               d |= (value << shift);\n\n               if (shift == 0)\n               {\n                  shift = 6;\n                  *dp++ = (png_byte)d;\n                  d = 0;\n               }\n\n               else\n                  shift -= 2;\n            }\n            if (shift != 6)\n               *dp = (png_byte)d;\n\n            break;\n         }\n\n         case 4:\n         {\n            png_bytep sp;\n            png_bytep dp;\n            int shift;\n            int d;\n            int value;\n            png_uint_32 i;\n            png_uint_32 row_width = row_info->width;\n\n            dp = row;\n            shift = 4;\n            d = 0;\n            for (i = png_pass_start[pass]; i < row_width;\n                i += png_pass_inc[pass])\n            {\n               sp = row + (png_size_t)(i >> 1);\n               value = (*sp >> ((1 - (int)(i & 0x01)) << 2)) & 0x0f;\n               d |= (value << shift);\n\n               if (shift == 0)\n               {\n                  shift = 4;\n                  *dp++ = (png_byte)d;\n                  d = 0;\n               }\n\n               else\n                  shift -= 4;\n            }\n            if (shift != 4)\n               *dp = (png_byte)d;\n\n            break;\n         }\n\n         default:\n         {\n            png_bytep sp;\n            png_bytep dp;\n            png_uint_32 i;\n            png_uint_32 row_width = row_info->width;\n            png_size_t pixel_bytes;\n\n            /* Start at the beginning */\n            dp = row;\n\n            /* Find out how many bytes each pixel takes up */\n            pixel_bytes = (row_info->pixel_depth >> 3);\n\n            /* Loop through the row, only looking at the pixels that matter */\n            for (i = png_pass_start[pass]; i < row_width;\n               i += png_pass_inc[pass])\n            {\n               /* Find out where the original pixel is */\n               sp = row + (png_size_t)i * pixel_bytes;\n\n               /* Move the pixel */\n               if (dp != sp)\n                  memcpy(dp, sp, pixel_bytes);\n\n               /* Next pixel */\n               dp += pixel_bytes;\n            }\n            break;\n         }\n      }\n      /* Set new row width */\n      row_info->width = (row_info->width +\n          png_pass_inc[pass] - 1 -\n          png_pass_start[pass]) /\n          png_pass_inc[pass];\n\n      row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,\n          row_info->width);\n   }\n}\n#endif\n\n/* This filters the row, chooses which filter to use, if it has not already\n * been specified by the application, and then writes the row out with the\n * chosen filter.\n */\nstatic void\npng_write_filtered_row(png_structrp png_ptr, png_bytep filtered_row,\n   png_size_t row_bytes);\n\n#define PNG_MAXSUM (((png_uint_32)(-1)) >> 1)\n#define PNG_HISHIFT 10\n#define PNG_LOMASK ((png_uint_32)0xffffL)\n#define PNG_HIMASK ((png_uint_32)(~PNG_LOMASK >> PNG_HISHIFT))\nvoid /* PRIVATE */\npng_write_find_filter(png_structrp png_ptr, png_row_infop row_info)\n{\n   png_bytep best_row;\n#ifdef PNG_WRITE_FILTER_SUPPORTED\n   png_bytep prev_row, row_buf;\n   png_uint_32 mins, bpp;\n   png_byte filter_to_do = png_ptr->do_filter;\n   png_size_t row_bytes = row_info->rowbytes;\n#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED\n   int num_p_filters = png_ptr->num_prev_filters;\n#endif\n\n   png_debug(1, \"in png_write_find_filter\");\n\n#ifndef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED\n  if (png_ptr->row_number == 0 && filter_to_do == PNG_ALL_FILTERS)\n  {\n     /* These will never be selected so we need not test them. */\n     filter_to_do &= ~(PNG_FILTER_UP | PNG_FILTER_PAETH);\n  }\n#endif\n\n   /* Find out how many bytes offset each pixel is */\n   bpp = (row_info->pixel_depth + 7) >> 3;\n\n   prev_row = png_ptr->prev_row;\n#endif\n   best_row = png_ptr->row_buf;\n#ifdef PNG_WRITE_FILTER_SUPPORTED\n   row_buf = best_row;\n   mins = PNG_MAXSUM;\n\n   /* The prediction method we use is to find which method provides the\n    * smallest value when summing the absolute values of the distances\n    * from zero, using anything >= 128 as negative numbers.  This is known\n    * as the \"minimum sum of absolute differences\" heuristic.  Other\n    * heuristics are the \"weighted minimum sum of absolute differences\"\n    * (experimental and can in theory improve compression), and the \"zlib\n    * predictive\" method (not implemented yet), which does test compressions\n    * of lines using different filter methods, and then chooses the\n    * (series of) filter(s) that give minimum compressed data size (VERY\n    * computationally expensive).\n    *\n    * GRR 980525:  consider also\n    *\n    *   (1) minimum sum of absolute differences from running average (i.e.,\n    *       keep running sum of non-absolute differences & count of bytes)\n    *       [track dispersion, too?  restart average if dispersion too large?]\n    *\n    *  (1b) minimum sum of absolute differences from sliding average, probably\n    *       with window size <= deflate window (usually 32K)\n    *\n    *   (2) minimum sum of squared differences from zero or running average\n    *       (i.e., ~ root-mean-square approach)\n    */\n\n\n   /* We don't need to test the 'no filter' case if this is the only filter\n    * that has been chosen, as it doesn't actually do anything to the data.\n    */\n   if ((filter_to_do & PNG_FILTER_NONE) && filter_to_do != PNG_FILTER_NONE)\n   {\n      png_bytep rp;\n      png_uint_32 sum = 0;\n      png_size_t i;\n      int v;\n\n      for (i = 0, rp = row_buf + 1; i < row_bytes; i++, rp++)\n      {\n         v = *rp;\n         sum += (v < 128) ? v : 256 - v;\n      }\n\n#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED\n      if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED)\n      {\n         png_uint_32 sumhi, sumlo;\n         int j;\n         sumlo = sum & PNG_LOMASK;\n         sumhi = (sum >> PNG_HISHIFT) & PNG_HIMASK; /* Gives us some footroom */\n\n         /* Reduce the sum if we match any of the previous rows */\n         for (j = 0; j < num_p_filters; j++)\n         {\n            if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_NONE)\n            {\n               sumlo = (sumlo * png_ptr->filter_weights[j]) >>\n                   PNG_WEIGHT_SHIFT;\n\n               sumhi = (sumhi * png_ptr->filter_weights[j]) >>\n                   PNG_WEIGHT_SHIFT;\n            }\n         }\n\n         /* Factor in the cost of this filter (this is here for completeness,\n          * but it makes no sense to have a \"cost\" for the NONE filter, as\n          * it has the minimum possible computational cost - none).\n          */\n         sumlo = (sumlo * png_ptr->filter_costs[PNG_FILTER_VALUE_NONE]) >>\n             PNG_COST_SHIFT;\n\n         sumhi = (sumhi * png_ptr->filter_costs[PNG_FILTER_VALUE_NONE]) >>\n             PNG_COST_SHIFT;\n\n         if (sumhi > PNG_HIMASK)\n            sum = PNG_MAXSUM;\n\n         else\n            sum = (sumhi << PNG_HISHIFT) + sumlo;\n      }\n#endif\n      mins = sum;\n   }\n\n   /* Sub filter */\n   if (filter_to_do == PNG_FILTER_SUB)\n   /* It's the only filter so no testing is needed */\n   {\n      png_bytep rp, lp, dp;\n      png_size_t i;\n\n      for (i = 0, rp = row_buf + 1, dp = png_ptr->sub_row + 1; i < bpp;\n           i++, rp++, dp++)\n      {\n         *dp = *rp;\n      }\n\n      for (lp = row_buf + 1; i < row_bytes;\n         i++, rp++, lp++, dp++)\n      {\n         *dp = (png_byte)(((int)*rp - (int)*lp) & 0xff);\n      }\n\n      best_row = png_ptr->sub_row;\n   }\n\n   else if (filter_to_do & PNG_FILTER_SUB)\n   {\n      png_bytep rp, dp, lp;\n      png_uint_32 sum = 0, lmins = mins;\n      png_size_t i;\n      int v;\n\n#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED\n      /* We temporarily increase the \"minimum sum\" by the factor we\n       * would reduce the sum of this filter, so that we can do the\n       * early exit comparison without scaling the sum each time.\n       */\n      if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED)\n      {\n         int j;\n         png_uint_32 lmhi, lmlo;\n         lmlo = lmins & PNG_LOMASK;\n         lmhi = (lmins >> PNG_HISHIFT) & PNG_HIMASK;\n\n         for (j = 0; j < num_p_filters; j++)\n         {\n            if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_SUB)\n            {\n               lmlo = (lmlo * png_ptr->inv_filter_weights[j]) >>\n                   PNG_WEIGHT_SHIFT;\n\n               lmhi = (lmhi * png_ptr->inv_filter_weights[j]) >>\n                   PNG_WEIGHT_SHIFT;\n            }\n         }\n\n         lmlo = (lmlo * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_SUB]) >>\n             PNG_COST_SHIFT;\n\n         lmhi = (lmhi * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_SUB]) >>\n             PNG_COST_SHIFT;\n\n         if (lmhi > PNG_HIMASK)\n            lmins = PNG_MAXSUM;\n\n         else\n            lmins = (lmhi << PNG_HISHIFT) + lmlo;\n      }\n#endif\n\n      for (i = 0, rp = row_buf + 1, dp = png_ptr->sub_row + 1; i < bpp;\n           i++, rp++, dp++)\n      {\n         v = *dp = *rp;\n\n         sum += (v < 128) ? v : 256 - v;\n      }\n\n      for (lp = row_buf + 1; i < row_bytes;\n         i++, rp++, lp++, dp++)\n      {\n         v = *dp = (png_byte)(((int)*rp - (int)*lp) & 0xff);\n\n         sum += (v < 128) ? v : 256 - v;\n\n         if (sum > lmins)  /* We are already worse, don't continue. */\n            break;\n      }\n\n#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED\n      if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED)\n      {\n         int j;\n         png_uint_32 sumhi, sumlo;\n         sumlo = sum & PNG_LOMASK;\n         sumhi = (sum >> PNG_HISHIFT) & PNG_HIMASK;\n\n         for (j = 0; j < num_p_filters; j++)\n         {\n            if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_SUB)\n            {\n               sumlo = (sumlo * png_ptr->inv_filter_weights[j]) >>\n                   PNG_WEIGHT_SHIFT;\n\n               sumhi = (sumhi * png_ptr->inv_filter_weights[j]) >>\n                   PNG_WEIGHT_SHIFT;\n            }\n         }\n\n         sumlo = (sumlo * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_SUB]) >>\n             PNG_COST_SHIFT;\n\n         sumhi = (sumhi * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_SUB]) >>\n             PNG_COST_SHIFT;\n\n         if (sumhi > PNG_HIMASK)\n            sum = PNG_MAXSUM;\n\n         else\n            sum = (sumhi << PNG_HISHIFT) + sumlo;\n      }\n#endif\n\n      if (sum < mins)\n      {\n         mins = sum;\n         best_row = png_ptr->sub_row;\n      }\n   }\n\n   /* Up filter */\n   if (filter_to_do == PNG_FILTER_UP)\n   {\n      png_bytep rp, dp, pp;\n      png_size_t i;\n\n      for (i = 0, rp = row_buf + 1, dp = png_ptr->up_row + 1,\n          pp = prev_row + 1; i < row_bytes;\n          i++, rp++, pp++, dp++)\n      {\n         *dp = (png_byte)(((int)*rp - (int)*pp) & 0xff);\n      }\n\n      best_row = png_ptr->up_row;\n   }\n\n   else if (filter_to_do & PNG_FILTER_UP)\n   {\n      png_bytep rp, dp, pp;\n      png_uint_32 sum = 0, lmins = mins;\n      png_size_t i;\n      int v;\n\n\n#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED\n      if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED)\n      {\n         int j;\n         png_uint_32 lmhi, lmlo;\n         lmlo = lmins & PNG_LOMASK;\n         lmhi = (lmins >> PNG_HISHIFT) & PNG_HIMASK;\n\n         for (j = 0; j < num_p_filters; j++)\n         {\n            if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_UP)\n            {\n               lmlo = (lmlo * png_ptr->inv_filter_weights[j]) >>\n                   PNG_WEIGHT_SHIFT;\n\n               lmhi = (lmhi * png_ptr->inv_filter_weights[j]) >>\n                   PNG_WEIGHT_SHIFT;\n            }\n         }\n\n         lmlo = (lmlo * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_UP]) >>\n             PNG_COST_SHIFT;\n\n         lmhi = (lmhi * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_UP]) >>\n             PNG_COST_SHIFT;\n\n         if (lmhi > PNG_HIMASK)\n            lmins = PNG_MAXSUM;\n\n         else\n            lmins = (lmhi << PNG_HISHIFT) + lmlo;\n      }\n#endif\n\n      for (i = 0, rp = row_buf + 1, dp = png_ptr->up_row + 1,\n          pp = prev_row + 1; i < row_bytes; i++)\n      {\n         v = *dp++ = (png_byte)(((int)*rp++ - (int)*pp++) & 0xff);\n\n         sum += (v < 128) ? v : 256 - v;\n\n         if (sum > lmins)  /* We are already worse, don't continue. */\n            break;\n      }\n\n#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED\n      if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED)\n      {\n         int j;\n         png_uint_32 sumhi, sumlo;\n         sumlo = sum & PNG_LOMASK;\n         sumhi = (sum >> PNG_HISHIFT) & PNG_HIMASK;\n\n         for (j = 0; j < num_p_filters; j++)\n         {\n            if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_UP)\n            {\n               sumlo = (sumlo * png_ptr->filter_weights[j]) >>\n                   PNG_WEIGHT_SHIFT;\n\n               sumhi = (sumhi * png_ptr->filter_weights[j]) >>\n                   PNG_WEIGHT_SHIFT;\n            }\n         }\n\n         sumlo = (sumlo * png_ptr->filter_costs[PNG_FILTER_VALUE_UP]) >>\n             PNG_COST_SHIFT;\n\n         sumhi = (sumhi * png_ptr->filter_costs[PNG_FILTER_VALUE_UP]) >>\n             PNG_COST_SHIFT;\n\n         if (sumhi > PNG_HIMASK)\n            sum = PNG_MAXSUM;\n\n         else\n            sum = (sumhi << PNG_HISHIFT) + sumlo;\n      }\n#endif\n\n      if (sum < mins)\n      {\n         mins = sum;\n         best_row = png_ptr->up_row;\n      }\n   }\n\n   /* Avg filter */\n   if (filter_to_do == PNG_FILTER_AVG)\n   {\n      png_bytep rp, dp, pp, lp;\n      png_uint_32 i;\n\n      for (i = 0, rp = row_buf + 1, dp = png_ptr->avg_row + 1,\n           pp = prev_row + 1; i < bpp; i++)\n      {\n         *dp++ = (png_byte)(((int)*rp++ - ((int)*pp++ / 2)) & 0xff);\n      }\n\n      for (lp = row_buf + 1; i < row_bytes; i++)\n      {\n         *dp++ = (png_byte)(((int)*rp++ - (((int)*pp++ + (int)*lp++) / 2))\n                 & 0xff);\n      }\n      best_row = png_ptr->avg_row;\n   }\n\n   else if (filter_to_do & PNG_FILTER_AVG)\n   {\n      png_bytep rp, dp, pp, lp;\n      png_uint_32 sum = 0, lmins = mins;\n      png_size_t i;\n      int v;\n\n#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED\n      if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED)\n      {\n         int j;\n         png_uint_32 lmhi, lmlo;\n         lmlo = lmins & PNG_LOMASK;\n         lmhi = (lmins >> PNG_HISHIFT) & PNG_HIMASK;\n\n         for (j = 0; j < num_p_filters; j++)\n         {\n            if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_AVG)\n            {\n               lmlo = (lmlo * png_ptr->inv_filter_weights[j]) >>\n                   PNG_WEIGHT_SHIFT;\n\n               lmhi = (lmhi * png_ptr->inv_filter_weights[j]) >>\n                   PNG_WEIGHT_SHIFT;\n            }\n         }\n\n         lmlo = (lmlo * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_AVG]) >>\n             PNG_COST_SHIFT;\n\n         lmhi = (lmhi * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_AVG]) >>\n             PNG_COST_SHIFT;\n\n         if (lmhi > PNG_HIMASK)\n            lmins = PNG_MAXSUM;\n\n         else\n            lmins = (lmhi << PNG_HISHIFT) + lmlo;\n      }\n#endif\n\n      for (i = 0, rp = row_buf + 1, dp = png_ptr->avg_row + 1,\n           pp = prev_row + 1; i < bpp; i++)\n      {\n         v = *dp++ = (png_byte)(((int)*rp++ - ((int)*pp++ / 2)) & 0xff);\n\n         sum += (v < 128) ? v : 256 - v;\n      }\n\n      for (lp = row_buf + 1; i < row_bytes; i++)\n      {\n         v = *dp++ =\n             (png_byte)(((int)*rp++ - (((int)*pp++ + (int)*lp++) / 2)) & 0xff);\n\n         sum += (v < 128) ? v : 256 - v;\n\n         if (sum > lmins)  /* We are already worse, don't continue. */\n            break;\n      }\n\n#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED\n      if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED)\n      {\n         int j;\n         png_uint_32 sumhi, sumlo;\n         sumlo = sum & PNG_LOMASK;\n         sumhi = (sum >> PNG_HISHIFT) & PNG_HIMASK;\n\n         for (j = 0; j < num_p_filters; j++)\n         {\n            if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_NONE)\n            {\n               sumlo = (sumlo * png_ptr->filter_weights[j]) >>\n                   PNG_WEIGHT_SHIFT;\n\n               sumhi = (sumhi * png_ptr->filter_weights[j]) >>\n                   PNG_WEIGHT_SHIFT;\n            }\n         }\n\n         sumlo = (sumlo * png_ptr->filter_costs[PNG_FILTER_VALUE_AVG]) >>\n             PNG_COST_SHIFT;\n\n         sumhi = (sumhi * png_ptr->filter_costs[PNG_FILTER_VALUE_AVG]) >>\n             PNG_COST_SHIFT;\n\n         if (sumhi > PNG_HIMASK)\n            sum = PNG_MAXSUM;\n\n         else\n            sum = (sumhi << PNG_HISHIFT) + sumlo;\n      }\n#endif\n\n      if (sum < mins)\n      {\n         mins = sum;\n         best_row = png_ptr->avg_row;\n      }\n   }\n\n   /* Paeth filter */\n   if (filter_to_do == PNG_FILTER_PAETH)\n   {\n      png_bytep rp, dp, pp, cp, lp;\n      png_size_t i;\n\n      for (i = 0, rp = row_buf + 1, dp = png_ptr->paeth_row + 1,\n          pp = prev_row + 1; i < bpp; i++)\n      {\n         *dp++ = (png_byte)(((int)*rp++ - (int)*pp++) & 0xff);\n      }\n\n      for (lp = row_buf + 1, cp = prev_row + 1; i < row_bytes; i++)\n      {\n         int a, b, c, pa, pb, pc, p;\n\n         b = *pp++;\n         c = *cp++;\n         a = *lp++;\n\n         p = b - c;\n         pc = a - c;\n\n#ifdef PNG_USE_ABS\n         pa = abs(p);\n         pb = abs(pc);\n         pc = abs(p + pc);\n#else\n         pa = p < 0 ? -p : p;\n         pb = pc < 0 ? -pc : pc;\n         pc = (p + pc) < 0 ? -(p + pc) : p + pc;\n#endif\n\n         p = (pa <= pb && pa <=pc) ? a : (pb <= pc) ? b : c;\n\n         *dp++ = (png_byte)(((int)*rp++ - p) & 0xff);\n      }\n      best_row = png_ptr->paeth_row;\n   }\n\n   else if (filter_to_do & PNG_FILTER_PAETH)\n   {\n      png_bytep rp, dp, pp, cp, lp;\n      png_uint_32 sum = 0, lmins = mins;\n      png_size_t i;\n      int v;\n\n#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED\n      if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED)\n      {\n         int j;\n         png_uint_32 lmhi, lmlo;\n         lmlo = lmins & PNG_LOMASK;\n         lmhi = (lmins >> PNG_HISHIFT) & PNG_HIMASK;\n\n         for (j = 0; j < num_p_filters; j++)\n         {\n            if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_PAETH)\n            {\n               lmlo = (lmlo * png_ptr->inv_filter_weights[j]) >>\n                   PNG_WEIGHT_SHIFT;\n\n               lmhi = (lmhi * png_ptr->inv_filter_weights[j]) >>\n                   PNG_WEIGHT_SHIFT;\n            }\n         }\n\n         lmlo = (lmlo * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_PAETH]) >>\n             PNG_COST_SHIFT;\n\n         lmhi = (lmhi * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_PAETH]) >>\n             PNG_COST_SHIFT;\n\n         if (lmhi > PNG_HIMASK)\n            lmins = PNG_MAXSUM;\n\n         else\n            lmins = (lmhi << PNG_HISHIFT) + lmlo;\n      }\n#endif\n\n      for (i = 0, rp = row_buf + 1, dp = png_ptr->paeth_row + 1,\n          pp = prev_row + 1; i < bpp; i++)\n      {\n         v = *dp++ = (png_byte)(((int)*rp++ - (int)*pp++) & 0xff);\n\n         sum += (v < 128) ? v : 256 - v;\n      }\n\n      for (lp = row_buf + 1, cp = prev_row + 1; i < row_bytes; i++)\n      {\n         int a, b, c, pa, pb, pc, p;\n\n         b = *pp++;\n         c = *cp++;\n         a = *lp++;\n\n#ifndef PNG_SLOW_PAETH\n         p = b - c;\n         pc = a - c;\n#ifdef PNG_USE_ABS\n         pa = abs(p);\n         pb = abs(pc);\n         pc = abs(p + pc);\n#else\n         pa = p < 0 ? -p : p;\n         pb = pc < 0 ? -pc : pc;\n         pc = (p + pc) < 0 ? -(p + pc) : p + pc;\n#endif\n         p = (pa <= pb && pa <=pc) ? a : (pb <= pc) ? b : c;\n#else /* PNG_SLOW_PAETH */\n         p = a + b - c;\n         pa = abs(p - a);\n         pb = abs(p - b);\n         pc = abs(p - c);\n\n         if (pa <= pb && pa <= pc)\n            p = a;\n\n         else if (pb <= pc)\n            p = b;\n\n         else\n            p = c;\n#endif /* PNG_SLOW_PAETH */\n\n         v = *dp++ = (png_byte)(((int)*rp++ - p) & 0xff);\n\n         sum += (v < 128) ? v : 256 - v;\n\n         if (sum > lmins)  /* We are already worse, don't continue. */\n            break;\n      }\n\n#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED\n      if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED)\n      {\n         int j;\n         png_uint_32 sumhi, sumlo;\n         sumlo = sum & PNG_LOMASK;\n         sumhi = (sum >> PNG_HISHIFT) & PNG_HIMASK;\n\n         for (j = 0; j < num_p_filters; j++)\n         {\n            if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_PAETH)\n            {\n               sumlo = (sumlo * png_ptr->filter_weights[j]) >>\n                   PNG_WEIGHT_SHIFT;\n\n               sumhi = (sumhi * png_ptr->filter_weights[j]) >>\n                   PNG_WEIGHT_SHIFT;\n            }\n         }\n\n         sumlo = (sumlo * png_ptr->filter_costs[PNG_FILTER_VALUE_PAETH]) >>\n             PNG_COST_SHIFT;\n\n         sumhi = (sumhi * png_ptr->filter_costs[PNG_FILTER_VALUE_PAETH]) >>\n             PNG_COST_SHIFT;\n\n         if (sumhi > PNG_HIMASK)\n            sum = PNG_MAXSUM;\n\n         else\n            sum = (sumhi << PNG_HISHIFT) + sumlo;\n      }\n#endif\n\n      if (sum < mins)\n      {\n         best_row = png_ptr->paeth_row;\n      }\n   }\n#endif /* PNG_WRITE_FILTER_SUPPORTED */\n\n   /* Do the actual writing of the filtered row data from the chosen filter. */\n   png_write_filtered_row(png_ptr, best_row, row_info->rowbytes+1);\n\n#ifdef PNG_WRITE_FILTER_SUPPORTED\n#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED\n   /* Save the type of filter we picked this time for future calculations */\n   if (png_ptr->num_prev_filters > 0)\n   {\n      int j;\n\n      for (j = 1; j < num_p_filters; j++)\n      {\n         png_ptr->prev_filters[j] = png_ptr->prev_filters[j - 1];\n      }\n\n      png_ptr->prev_filters[j] = best_row[0];\n   }\n#endif\n#endif /* PNG_WRITE_FILTER_SUPPORTED */\n}\n\n\n/* Do the actual writing of a previously filtered row. */\nstatic void\npng_write_filtered_row(png_structrp png_ptr, png_bytep filtered_row,\n   png_size_t full_row_length/*includes filter byte*/)\n{\n   png_debug(1, \"in png_write_filtered_row\");\n\n   png_debug1(2, \"filter = %d\", filtered_row[0]);\n\n   png_compress_IDAT(png_ptr, filtered_row, full_row_length, Z_NO_FLUSH);\n\n   /* Swap the current and previous rows */\n   if (png_ptr->prev_row != NULL)\n   {\n      png_bytep tptr;\n\n      tptr = png_ptr->prev_row;\n      png_ptr->prev_row = png_ptr->row_buf;\n      png_ptr->row_buf = tptr;\n   }\n\n   /* Finish row - updates counters and flushes zlib if last row */\n   png_write_finish_row(png_ptr);\n\n#ifdef PNG_WRITE_FLUSH_SUPPORTED\n   png_ptr->flush_rows++;\n\n   if (png_ptr->flush_dist > 0 &&\n       png_ptr->flush_rows >= png_ptr->flush_dist)\n   {\n      png_write_flush(png_ptr);\n   }\n#endif\n}\n#endif /* PNG_WRITE_SUPPORTED */\n"
  },
  {
    "path": "Projects/Libraries/CSBase/Source/rapidxml/rapidxml.hpp",
    "content": "#ifndef RAPIDXML_HPP_INCLUDED\r\n#define RAPIDXML_HPP_INCLUDED\r\n\r\n// Copyright (C) 2006, 2009 Marcin Kalicinski\r\n// Version 1.13\r\n// Revision $DateTime: 2009/05/13 01:46:17 $\r\n//! \\file rapidxml.hpp This file contains rapidxml parser and DOM implementation\r\n\r\n// If standard library is disabled, user must provide implementations of required functions and typedefs\r\n#if !defined(RAPIDXML_NO_STDLIB)\r\n    #include <cstdlib>      // For std::size_t\r\n    #include <cassert>      // For assert\r\n    #include <new>          // For placement new\r\n#endif\r\n\r\n// On MSVC, disable \"conditional expression is constant\" warning (level 4). \r\n// This warning is almost impossible to avoid with certain types of templated code\r\n#ifdef _MSC_VER\r\n    #pragma warning(push)\r\n    #pragma warning(disable:4127)   // Conditional expression is constant\r\n#endif\r\n\r\n///////////////////////////////////////////////////////////////////////////\r\n// RAPIDXML_PARSE_ERROR\r\n    \r\n#if defined(RAPIDXML_NO_EXCEPTIONS)\r\n\r\n#define RAPIDXML_PARSE_ERROR(what, where) { parse_error_handler(what, where); assert(0); }\r\n\r\nnamespace rapidxml\r\n{\r\n    //! When exceptions are disabled by defining RAPIDXML_NO_EXCEPTIONS, \r\n    //! this function is called to notify user about the error.\r\n    //! It must be defined by the user.\r\n    //! <br><br>\r\n    //! This function cannot return. If it does, the results are undefined.\r\n    //! <br><br>\r\n    //! A very simple definition might look like that:\r\n    //! <pre>\r\n    //! void %rapidxml::%parse_error_handler(const char *what, void *where)\r\n    //! {\r\n    //!     std::cout << \"Parse error: \" << what << \"\\n\";\r\n    //!     std::abort();\r\n    //! }\r\n    //! </pre>\r\n    //! \\param what Human readable description of the error.\r\n    //! \\param where Pointer to character data where error was detected.\r\n    void parse_error_handler(const char *what, void *where);\r\n}\r\n\r\n#else\r\n    \r\n#include <exception>    // For std::exception\r\n\r\n#define RAPIDXML_PARSE_ERROR(what, where) throw parse_error(what, where)\r\n\r\nnamespace rapidxml\r\n{\r\n\r\n    //! Parse error exception. \r\n    //! This exception is thrown by the parser when an error occurs. \r\n    //! Use what() function to get human-readable error message. \r\n    //! Use where() function to get a pointer to position within source text where error was detected.\r\n    //! <br><br>\r\n    //! If throwing exceptions by the parser is undesirable, \r\n    //! it can be disabled by defining RAPIDXML_NO_EXCEPTIONS macro before rapidxml.hpp is included.\r\n    //! This will cause the parser to call rapidxml::parse_error_handler() function instead of throwing an exception.\r\n    //! This function must be defined by the user.\r\n    //! <br><br>\r\n    //! This class derives from <code>std::exception</code> class.\r\n    class parse_error: public std::exception\r\n    {\r\n    \r\n    public:\r\n    \r\n        //! Constructs parse error\r\n        parse_error(const char *what, void *where)\r\n            : m_what(what)\r\n            , m_where(where)\r\n        {\r\n        }\r\n\r\n        //! Gets human readable description of error.\r\n        //! \\return Pointer to null terminated description of the error.\r\n        virtual const char *what() const throw()\r\n        {\r\n            return m_what;\r\n        }\r\n\r\n        //! Gets pointer to character data where error happened.\r\n        //! Ch should be the same as char type of xml_document that produced the error.\r\n        //! \\return Pointer to location within the parsed string where error occured.\r\n        template<class Ch>\r\n        Ch *where() const\r\n        {\r\n            return reinterpret_cast<Ch *>(m_where);\r\n        }\r\n\r\n    private:  \r\n\r\n        const char *m_what;\r\n        void *m_where;\r\n\r\n    };\r\n}\r\n\r\n#endif\r\n\r\n///////////////////////////////////////////////////////////////////////////\r\n// Pool sizes\r\n\r\n#ifndef RAPIDXML_STATIC_POOL_SIZE\r\n    // Size of static memory block of memory_pool.\r\n    // Define RAPIDXML_STATIC_POOL_SIZE before including rapidxml.hpp if you want to override the default value.\r\n    // No dynamic memory allocations are performed by memory_pool until static memory is exhausted.\r\n    #define RAPIDXML_STATIC_POOL_SIZE (64 * 1024)\r\n#endif\r\n\r\n#ifndef RAPIDXML_DYNAMIC_POOL_SIZE\r\n    // Size of dynamic memory block of memory_pool.\r\n    // Define RAPIDXML_DYNAMIC_POOL_SIZE before including rapidxml.hpp if you want to override the default value.\r\n    // After the static block is exhausted, dynamic blocks with approximately this size are allocated by memory_pool.\r\n    #define RAPIDXML_DYNAMIC_POOL_SIZE (64 * 1024)\r\n#endif\r\n\r\n#ifndef RAPIDXML_ALIGNMENT\r\n    // Memory allocation alignment.\r\n    // Define RAPIDXML_ALIGNMENT before including rapidxml.hpp if you want to override the default value, which is the size of pointer.\r\n    // All memory allocations for nodes, attributes and strings will be aligned to this value.\r\n    // This must be a power of 2 and at least 1, otherwise memory_pool will not work.\r\n    #define RAPIDXML_ALIGNMENT sizeof(void *)\r\n#endif\r\n\r\nnamespace rapidxml\r\n{\r\n    // Forward declarations\r\n    template<class Ch> class xml_node;\r\n    template<class Ch> class xml_attribute;\r\n    template<class Ch> class xml_document;\r\n    \r\n    //! Enumeration listing all node types produced by the parser.\r\n    //! Use xml_node::type() function to query node type.\r\n    enum node_type\r\n    {\r\n        node_document,      //!< A document node. Name and value are empty.\r\n        node_element,       //!< An element node. Name contains element name. Value contains text of first data node.\r\n        node_data,          //!< A data node. Name is empty. Value contains data text.\r\n        node_cdata,         //!< A CDATA node. Name is empty. Value contains data text.\r\n        node_comment,       //!< A comment node. Name is empty. Value contains comment text.\r\n        node_declaration,   //!< A declaration node. Name and value are empty. Declaration parameters (version, encoding and standalone) are in node attributes.\r\n        node_doctype,       //!< A DOCTYPE node. Name is empty. Value contains DOCTYPE text.\r\n        node_pi             //!< A PI node. Name contains target. Value contains instructions.\r\n    };\r\n\r\n    ///////////////////////////////////////////////////////////////////////\r\n    // Parsing flags\r\n\r\n    //! Parse flag instructing the parser to not create data nodes. \r\n    //! Text of first data node will still be placed in value of parent element, unless rapidxml::parse_no_element_values flag is also specified.\r\n    //! Can be combined with other flags by use of | operator.\r\n    //! <br><br>\r\n    //! See xml_document::parse() function.\r\n    const int parse_no_data_nodes = 0x1;            \r\n\r\n    //! Parse flag instructing the parser to not use text of first data node as a value of parent element.\r\n    //! Can be combined with other flags by use of | operator.\r\n    //! Note that child data nodes of element node take precendence over its value when printing. \r\n    //! That is, if element has one or more child data nodes <em>and</em> a value, the value will be ignored.\r\n    //! Use rapidxml::parse_no_data_nodes flag to prevent creation of data nodes if you want to manipulate data using values of elements.\r\n    //! <br><br>\r\n    //! See xml_document::parse() function.\r\n    const int parse_no_element_values = 0x2;\r\n    \r\n    //! Parse flag instructing the parser to not place zero terminators after strings in the source text.\r\n    //! By default zero terminators are placed, modifying source text.\r\n    //! Can be combined with other flags by use of | operator.\r\n    //! <br><br>\r\n    //! See xml_document::parse() function.\r\n    const int parse_no_string_terminators = 0x4;\r\n    \r\n    //! Parse flag instructing the parser to not translate entities in the source text.\r\n    //! By default entities are translated, modifying source text.\r\n    //! Can be combined with other flags by use of | operator.\r\n    //! <br><br>\r\n    //! See xml_document::parse() function.\r\n    const int parse_no_entity_translation = 0x8;\r\n    \r\n    //! Parse flag instructing the parser to disable UTF-8 handling and assume plain 8 bit characters.\r\n    //! By default, UTF-8 handling is enabled.\r\n    //! Can be combined with other flags by use of | operator.\r\n    //! <br><br>\r\n    //! See xml_document::parse() function.\r\n    const int parse_no_utf8 = 0x10;\r\n    \r\n    //! Parse flag instructing the parser to create XML declaration node.\r\n    //! By default, declaration node is not created.\r\n    //! Can be combined with other flags by use of | operator.\r\n    //! <br><br>\r\n    //! See xml_document::parse() function.\r\n    const int parse_declaration_node = 0x20;\r\n    \r\n    //! Parse flag instructing the parser to create comments nodes.\r\n    //! By default, comment nodes are not created.\r\n    //! Can be combined with other flags by use of | operator.\r\n    //! <br><br>\r\n    //! See xml_document::parse() function.\r\n    const int parse_comment_nodes = 0x40;\r\n    \r\n    //! Parse flag instructing the parser to create DOCTYPE node.\r\n    //! By default, doctype node is not created.\r\n    //! Although W3C specification allows at most one DOCTYPE node, RapidXml will silently accept documents with more than one.\r\n    //! Can be combined with other flags by use of | operator.\r\n    //! <br><br>\r\n    //! See xml_document::parse() function.\r\n    const int parse_doctype_node = 0x80;\r\n    \r\n    //! Parse flag instructing the parser to create PI nodes.\r\n    //! By default, PI nodes are not created.\r\n    //! Can be combined with other flags by use of | operator.\r\n    //! <br><br>\r\n    //! See xml_document::parse() function.\r\n    const int parse_pi_nodes = 0x100;\r\n    \r\n    //! Parse flag instructing the parser to validate closing tag names. \r\n    //! If not set, name inside closing tag is irrelevant to the parser.\r\n    //! By default, closing tags are not validated.\r\n    //! Can be combined with other flags by use of | operator.\r\n    //! <br><br>\r\n    //! See xml_document::parse() function.\r\n    const int parse_validate_closing_tags = 0x200;\r\n    \r\n    //! Parse flag instructing the parser to trim all leading and trailing whitespace of data nodes.\r\n    //! By default, whitespace is not trimmed. \r\n    //! This flag does not cause the parser to modify source text.\r\n    //! Can be combined with other flags by use of | operator.\r\n    //! <br><br>\r\n    //! See xml_document::parse() function.\r\n    const int parse_trim_whitespace = 0x400;\r\n\r\n    //! Parse flag instructing the parser to condense all whitespace runs of data nodes to a single space character.\r\n    //! Trimming of leading and trailing whitespace of data is controlled by rapidxml::parse_trim_whitespace flag.\r\n    //! By default, whitespace is not normalized. \r\n    //! If this flag is specified, source text will be modified.\r\n    //! Can be combined with other flags by use of | operator.\r\n    //! <br><br>\r\n    //! See xml_document::parse() function.\r\n    const int parse_normalize_whitespace = 0x800;\r\n\r\n    // Compound flags\r\n    \r\n    //! Parse flags which represent default behaviour of the parser. \r\n    //! This is always equal to 0, so that all other flags can be simply ored together.\r\n    //! Normally there is no need to inconveniently disable flags by anding with their negated (~) values.\r\n    //! This also means that meaning of each flag is a <i>negation</i> of the default setting. \r\n    //! For example, if flag name is rapidxml::parse_no_utf8, it means that utf-8 is <i>enabled</i> by default,\r\n    //! and using the flag will disable it.\r\n    //! <br><br>\r\n    //! See xml_document::parse() function.\r\n    const int parse_default = 0;\r\n    \r\n    //! A combination of parse flags that forbids any modifications of the source text. \r\n    //! This also results in faster parsing. However, note that the following will occur:\r\n    //! <ul>\r\n    //! <li>names and values of nodes will not be zero terminated, you have to use xml_base::name_size() and xml_base::value_size() functions to determine where name and value ends</li>\r\n    //! <li>entities will not be translated</li>\r\n    //! <li>whitespace will not be normalized</li>\r\n    //! </ul>\r\n    //! See xml_document::parse() function.\r\n    const int parse_non_destructive = parse_no_string_terminators | parse_no_entity_translation;\r\n    \r\n    //! A combination of parse flags resulting in fastest possible parsing, without sacrificing important data.\r\n    //! <br><br>\r\n    //! See xml_document::parse() function.\r\n    const int parse_fastest = parse_non_destructive | parse_no_data_nodes;\r\n    \r\n    //! A combination of parse flags resulting in largest amount of data being extracted. \r\n    //! This usually results in slowest parsing.\r\n    //! <br><br>\r\n    //! See xml_document::parse() function.\r\n    const int parse_full = parse_declaration_node | parse_comment_nodes | parse_doctype_node | parse_pi_nodes | parse_validate_closing_tags;\r\n\r\n    ///////////////////////////////////////////////////////////////////////\r\n    // Internals\r\n\r\n    //! \\cond internal\r\n    namespace internal\r\n    {\r\n\r\n        // Struct that contains lookup tables for the parser\r\n        // It must be a template to allow correct linking (because it has static data members, which are defined in a header file).\r\n        template<int Dummy>\r\n        struct lookup_tables\r\n        {\r\n            static const unsigned char lookup_whitespace[256];              // Whitespace table\r\n            static const unsigned char lookup_node_name[256];               // Node name table\r\n            static const unsigned char lookup_text[256];                    // Text table\r\n            static const unsigned char lookup_text_pure_no_ws[256];         // Text table\r\n            static const unsigned char lookup_text_pure_with_ws[256];       // Text table\r\n            static const unsigned char lookup_attribute_name[256];          // Attribute name table\r\n            static const unsigned char lookup_attribute_data_1[256];        // Attribute data table with single quote\r\n            static const unsigned char lookup_attribute_data_1_pure[256];   // Attribute data table with single quote\r\n            static const unsigned char lookup_attribute_data_2[256];        // Attribute data table with double quotes\r\n            static const unsigned char lookup_attribute_data_2_pure[256];   // Attribute data table with double quotes\r\n            static const unsigned char lookup_digits[256];                  // Digits\r\n            static const unsigned char lookup_upcase[256];                  // To uppercase conversion table for ASCII characters\r\n        };\r\n\r\n        // Find length of the string\r\n        template<class Ch>\r\n        inline std::size_t measure(const Ch *p)\r\n        {\r\n            const Ch *tmp = p;\r\n            while (*tmp) \r\n                ++tmp;\r\n            return tmp - p;\r\n        }\r\n\r\n        // Compare strings for equality\r\n        template<class Ch>\r\n        inline bool compare(const Ch *p1, std::size_t size1, const Ch *p2, std::size_t size2, bool case_sensitive)\r\n        {\r\n            if (size1 != size2)\r\n                return false;\r\n            if (case_sensitive)\r\n            {\r\n                for (const Ch *end = p1 + size1; p1 < end; ++p1, ++p2)\r\n                    if (*p1 != *p2)\r\n                        return false;\r\n            }\r\n            else\r\n            {\r\n                for (const Ch *end = p1 + size1; p1 < end; ++p1, ++p2)\r\n                    if (lookup_tables<0>::lookup_upcase[static_cast<unsigned char>(*p1)] != lookup_tables<0>::lookup_upcase[static_cast<unsigned char>(*p2)])\r\n                        return false;\r\n            }\r\n            return true;\r\n        }\r\n    }\r\n    //! \\endcond\r\n\r\n    ///////////////////////////////////////////////////////////////////////\r\n    // Memory pool\r\n    \r\n    //! This class is used by the parser to create new nodes and attributes, without overheads of dynamic memory allocation.\r\n    //! In most cases, you will not need to use this class directly. \r\n    //! However, if you need to create nodes manually or modify names/values of nodes, \r\n    //! you are encouraged to use memory_pool of relevant xml_document to allocate the memory. \r\n    //! Not only is this faster than allocating them by using <code>new</code> operator, \r\n    //! but also their lifetime will be tied to the lifetime of document, \r\n    //! possibly simplyfing memory management. \r\n    //! <br><br>\r\n    //! Call allocate_node() or allocate_attribute() functions to obtain new nodes or attributes from the pool. \r\n    //! You can also call allocate_string() function to allocate strings.\r\n    //! Such strings can then be used as names or values of nodes without worrying about their lifetime.\r\n    //! Note that there is no <code>free()</code> function -- all allocations are freed at once when clear() function is called, \r\n    //! or when the pool is destroyed.\r\n    //! <br><br>\r\n    //! It is also possible to create a standalone memory_pool, and use it \r\n    //! to allocate nodes, whose lifetime will not be tied to any document.\r\n    //! <br><br>\r\n    //! Pool maintains <code>RAPIDXML_STATIC_POOL_SIZE</code> bytes of statically allocated memory. \r\n    //! Until static memory is exhausted, no dynamic memory allocations are done.\r\n    //! When static memory is exhausted, pool allocates additional blocks of memory of size <code>RAPIDXML_DYNAMIC_POOL_SIZE</code> each,\r\n    //! by using global <code>new[]</code> and <code>delete[]</code> operators. \r\n    //! This behaviour can be changed by setting custom allocation routines. \r\n    //! Use set_allocator() function to set them.\r\n    //! <br><br>\r\n    //! Allocations for nodes, attributes and strings are aligned at <code>RAPIDXML_ALIGNMENT</code> bytes.\r\n    //! This value defaults to the size of pointer on target architecture.\r\n    //! <br><br>\r\n    //! To obtain absolutely top performance from the parser,\r\n    //! it is important that all nodes are allocated from a single, contiguous block of memory.\r\n    //! Otherwise, cache misses when jumping between two (or more) disjoint blocks of memory can slow down parsing quite considerably.\r\n    //! If required, you can tweak <code>RAPIDXML_STATIC_POOL_SIZE</code>, <code>RAPIDXML_DYNAMIC_POOL_SIZE</code> and <code>RAPIDXML_ALIGNMENT</code> \r\n    //! to obtain best wasted memory to performance compromise.\r\n    //! To do it, define their values before rapidxml.hpp file is included.\r\n    //! \\param Ch Character type of created nodes. \r\n    template<class Ch = char>\r\n    class memory_pool\r\n    {\r\n        \r\n    public:\r\n\r\n        //! \\cond internal\r\n        typedef void *(rapidxml_alloc_func)(std::size_t);       // Type of user-defined function used to allocate memory\r\n        typedef void (free_func)(void *);              // Type of user-defined function used to free memory\r\n        //! \\endcond\r\n        \r\n        //! Constructs empty pool with default allocator functions.\r\n        memory_pool()\r\n            : m_rapidxml_alloc_func(0)\r\n            , m_free_func(0)\r\n        {\r\n            init();\r\n        }\r\n\r\n        //! Destroys pool and frees all the memory. \r\n        //! This causes memory occupied by nodes allocated by the pool to be freed.\r\n        //! Nodes allocated from the pool are no longer valid.\r\n        ~memory_pool()\r\n        {\r\n            clear();\r\n        }\r\n\r\n        //! Allocates a new node from the pool, and optionally assigns name and value to it. \r\n        //! If the allocation request cannot be accomodated, this function will throw <code>std::bad_alloc</code>.\r\n        //! If exceptions are disabled by defining RAPIDXML_NO_EXCEPTIONS, this function\r\n        //! will call rapidxml::parse_error_handler() function.\r\n        //! \\param type Type of node to create.\r\n        //! \\param name Name to assign to the node, or 0 to assign no name.\r\n        //! \\param value Value to assign to the node, or 0 to assign no value.\r\n        //! \\param name_size Size of name to assign, or 0 to automatically calculate size from name string.\r\n        //! \\param value_size Size of value to assign, or 0 to automatically calculate size from value string.\r\n        //! \\return Pointer to allocated node. This pointer will never be NULL.\r\n        xml_node<Ch> *allocate_node(node_type type, \r\n                                    const Ch *name = 0, const Ch *value = 0, \r\n                                    std::size_t name_size = 0, std::size_t value_size = 0)\r\n        {\r\n            void *memory = allocate_aligned(sizeof(xml_node<Ch>));\r\n            xml_node<Ch> *node = new(memory) xml_node<Ch>(type);\r\n            if (name)\r\n            {\r\n                if (name_size > 0)\r\n                    node->name(name, name_size);\r\n                else\r\n                    node->name(name);\r\n            }\r\n            if (value)\r\n            {\r\n                if (value_size > 0)\r\n                    node->value(value, value_size);\r\n                else\r\n                    node->value(value);\r\n            }\r\n            return node;\r\n        }\r\n\r\n        //! Allocates a new attribute from the pool, and optionally assigns name and value to it.\r\n        //! If the allocation request cannot be accomodated, this function will throw <code>std::bad_alloc</code>.\r\n        //! If exceptions are disabled by defining RAPIDXML_NO_EXCEPTIONS, this function\r\n        //! will call rapidxml::parse_error_handler() function.\r\n        //! \\param name Name to assign to the attribute, or 0 to assign no name.\r\n        //! \\param value Value to assign to the attribute, or 0 to assign no value.\r\n        //! \\param name_size Size of name to assign, or 0 to automatically calculate size from name string.\r\n        //! \\param value_size Size of value to assign, or 0 to automatically calculate size from value string.\r\n        //! \\return Pointer to allocated attribute. This pointer will never be NULL.\r\n        xml_attribute<Ch> *allocate_attribute(const Ch *name = 0, const Ch *value = 0, \r\n                                              std::size_t name_size = 0, std::size_t value_size = 0)\r\n        {\r\n            void *memory = allocate_aligned(sizeof(xml_attribute<Ch>));\r\n            xml_attribute<Ch> *attribute = new(memory) xml_attribute<Ch>;\r\n            if (name)\r\n            {\r\n                if (name_size > 0)\r\n                    attribute->name(name, name_size);\r\n                else\r\n                    attribute->name(name);\r\n            }\r\n            if (value)\r\n            {\r\n                if (value_size > 0)\r\n                    attribute->value(value, value_size);\r\n                else\r\n                    attribute->value(value);\r\n            }\r\n            return attribute;\r\n        }\r\n\r\n        //! Allocates a char array of given size from the pool, and optionally copies a given string to it.\r\n        //! If the allocation request cannot be accomodated, this function will throw <code>std::bad_alloc</code>.\r\n        //! If exceptions are disabled by defining RAPIDXML_NO_EXCEPTIONS, this function\r\n        //! will call rapidxml::parse_error_handler() function.\r\n        //! \\param source String to initialize the allocated memory with, or 0 to not initialize it.\r\n        //! \\param size Number of characters to allocate, or zero to calculate it automatically from source string length; if size is 0, source string must be specified and null terminated.\r\n        //! \\return Pointer to allocated char array. This pointer will never be NULL.\r\n        Ch *allocate_string(const Ch *source = 0, std::size_t size = 0)\r\n        {\r\n            assert(source || size);     // Either source or size (or both) must be specified\r\n            if (size == 0)\r\n                size = internal::measure(source) + 1;\r\n            Ch *result = static_cast<Ch *>(allocate_aligned(size * sizeof(Ch)));\r\n            if (source)\r\n                for (std::size_t i = 0; i < size; ++i)\r\n                    result[i] = source[i];\r\n            return result;\r\n        }\r\n\r\n        //! Clones an xml_node and its hierarchy of child nodes and attributes.\r\n        //! Nodes and attributes are allocated from this memory pool.\r\n        //! Names and values are not cloned, they are shared between the clone and the source.\r\n        //! Result node can be optionally specified as a second parameter, \r\n        //! in which case its contents will be replaced with cloned source node.\r\n        //! This is useful when you want to clone entire document.\r\n        //! \\param source Node to clone.\r\n        //! \\param result Node to put results in, or 0 to automatically allocate result node\r\n        //! \\return Pointer to cloned node. This pointer will never be NULL.\r\n        xml_node<Ch> *clone_node(const xml_node<Ch> *source, xml_node<Ch> *result = 0)\r\n        {\r\n            // Prepare result node\r\n            if (result)\r\n            {\r\n                result->remove_all_attributes();\r\n                result->remove_all_nodes();\r\n                result->type(source->type());\r\n            }\r\n            else\r\n                result = allocate_node(source->type());\r\n\r\n            // Clone name and value\r\n            result->name(source->name(), source->name_size());\r\n            result->value(source->value(), source->value_size());\r\n\r\n            // Clone child nodes and attributes\r\n            for (xml_node<Ch> *child = source->first_node(); child; child = child->next_sibling())\r\n                result->append_node(clone_node(child));\r\n            for (xml_attribute<Ch> *attr = source->first_attribute(); attr; attr = attr->next_attribute())\r\n                result->append_attribute(allocate_attribute(attr->name(), attr->value(), attr->name_size(), attr->value_size()));\r\n\r\n            return result;\r\n        }\r\n\r\n        //! Clears the pool. \r\n        //! This causes memory occupied by nodes allocated by the pool to be freed.\r\n        //! Any nodes or strings allocated from the pool will no longer be valid.\r\n        void clear()\r\n        {\r\n            while (m_begin != m_static_memory)\r\n            {\r\n                char *previous_begin = reinterpret_cast<header *>(align(m_begin))->previous_begin;\r\n                if (m_free_func)\r\n                    m_free_func(m_begin);\r\n                else\r\n                    delete[] m_begin;\r\n                m_begin = previous_begin;\r\n            }\r\n            init();\r\n        }\r\n\r\n        //! Sets or resets the user-defined memory allocation functions for the pool.\r\n        //! This can only be called when no memory is allocated from the pool yet, otherwise results are undefined.\r\n        //! Allocation function must not return invalid pointer on failure. It should either throw,\r\n        //! stop the program, or use <code>longjmp()</code> function to pass control to other place of program. \r\n        //! If it returns invalid pointer, results are undefined.\r\n        //! <br><br>\r\n        //! User defined allocation functions must have the following forms:\r\n        //! <br><code>\r\n        //! <br>void *allocate(std::size_t size);\r\n        //! <br>void free(void *pointer);\r\n        //! </code><br>\r\n        //! \\param af Allocation function, or 0 to restore default function\r\n        //! \\param ff Free function, or 0 to restore default function\r\n        void set_allocator(rapidxml_alloc_func *af, free_func *ff)\r\n        {\r\n            assert(m_begin == m_static_memory && m_ptr == align(m_begin));    // Verify that no memory is allocated yet\r\n            m_rapidxml_alloc_func = af;\r\n            m_free_func = ff;\r\n        }\r\n\r\n    private:\r\n\r\n        struct header\r\n        {\r\n            char *previous_begin;\r\n        };\r\n\r\n        void init()\r\n        {\r\n            m_begin = m_static_memory;\r\n            m_ptr = align(m_begin);\r\n            m_end = m_static_memory + sizeof(m_static_memory);\r\n        }\r\n        \r\n        char *align(char *ptr)\r\n        {\r\n            std::size_t alignment = ((RAPIDXML_ALIGNMENT - (std::size_t(ptr) & (RAPIDXML_ALIGNMENT - 1))) & (RAPIDXML_ALIGNMENT - 1));\r\n            return ptr + alignment;\r\n        }\r\n        \r\n        char *allocate_raw(std::size_t size)\r\n        {\r\n            // Allocate\r\n            void *memory;   \r\n            if (m_rapidxml_alloc_func)   // Allocate memory using either user-specified allocation function or global operator new[]\r\n            {\r\n                memory = m_rapidxml_alloc_func(size);\r\n                assert(memory); // Allocator is not allowed to return 0, on failure it must either throw, stop the program or use longjmp\r\n            }\r\n            else\r\n            {\r\n                memory = new char[size];\r\n#ifdef RAPIDXML_NO_EXCEPTIONS\r\n                if (!memory)            // If exceptions are disabled, verify memory allocation, because new will not be able to throw bad_alloc\r\n                    RAPIDXML_PARSE_ERROR(\"out of memory\", 0);\r\n#endif\r\n            }\r\n            return static_cast<char *>(memory);\r\n        }\r\n        \r\n        void *allocate_aligned(std::size_t size)\r\n        {\r\n            // Calculate aligned pointer\r\n            char *result = align(m_ptr);\r\n\r\n            // If not enough memory left in current pool, allocate a new pool\r\n            if (result + size > m_end)\r\n            {\r\n                // Calculate required pool size (may be bigger than RAPIDXML_DYNAMIC_POOL_SIZE)\r\n                std::size_t pool_size = RAPIDXML_DYNAMIC_POOL_SIZE;\r\n                if (pool_size < size)\r\n                    pool_size = size;\r\n                \r\n                // Allocate\r\n                std::size_t alloc_size = sizeof(header) + (2 * RAPIDXML_ALIGNMENT - 2) + pool_size;     // 2 alignments required in worst case: one for header, one for actual allocation\r\n                char *raw_memory = allocate_raw(alloc_size);\r\n                    \r\n                // Setup new pool in allocated memory\r\n                char *pool = align(raw_memory);\r\n                header *new_header = reinterpret_cast<header *>(pool);\r\n                new_header->previous_begin = m_begin;\r\n                m_begin = raw_memory;\r\n                m_ptr = pool + sizeof(header);\r\n                m_end = raw_memory + alloc_size;\r\n\r\n                // Calculate aligned pointer again using new pool\r\n                result = align(m_ptr);\r\n            }\r\n\r\n            // Update pool and return aligned pointer\r\n            m_ptr = result + size;\r\n            return result;\r\n        }\r\n\r\n        char *m_begin;                                      // Start of raw memory making up current pool\r\n        char *m_ptr;                                        // First free byte in current pool\r\n        char *m_end;                                        // One past last available byte in current pool\r\n        char m_static_memory[RAPIDXML_STATIC_POOL_SIZE];    // Static raw memory\r\n        rapidxml_alloc_func *m_rapidxml_alloc_func;                           // Allocator function, or 0 if default is to be used\r\n        free_func *m_free_func;                             // Free function, or 0 if default is to be used\r\n    };\r\n\r\n    ///////////////////////////////////////////////////////////////////////////\r\n    // XML base\r\n\r\n    //! Base class for xml_node and xml_attribute implementing common functions: \r\n    //! name(), name_size(), value(), value_size() and parent().\r\n    //! \\param Ch Character type to use\r\n    template<class Ch = char>\r\n    class xml_base\r\n    {\r\n\r\n    public:\r\n        \r\n        ///////////////////////////////////////////////////////////////////////////\r\n        // Construction & destruction\r\n    \r\n        // Construct a base with empty name, value and parent\r\n        xml_base()\r\n            : m_name(0)\r\n            , m_value(0)\r\n            , m_parent(0)\r\n        {\r\n        }\r\n\r\n        ///////////////////////////////////////////////////////////////////////////\r\n        // Node data access\r\n    \r\n        //! Gets name of the node. \r\n        //! Interpretation of name depends on type of node.\r\n        //! Note that name will not be zero-terminated if rapidxml::parse_no_string_terminators option was selected during parse.\r\n        //! <br><br>\r\n        //! Use name_size() function to determine length of the name.\r\n        //! \\return Name of node, or empty string if node has no name.\r\n        Ch *name() const\r\n        {\r\n            return m_name ? m_name : nullstr();\r\n        }\r\n\r\n        //! Gets size of node name, not including terminator character.\r\n        //! This function works correctly irrespective of whether name is or is not zero terminated.\r\n        //! \\return Size of node name, in characters.\r\n        std::size_t name_size() const\r\n        {\r\n            return m_name ? m_name_size : 0;\r\n        }\r\n\r\n        //! Gets value of node. \r\n        //! Interpretation of value depends on type of node.\r\n        //! Note that value will not be zero-terminated if rapidxml::parse_no_string_terminators option was selected during parse.\r\n        //! <br><br>\r\n        //! Use value_size() function to determine length of the value.\r\n        //! \\return Value of node, or empty string if node has no value.\r\n        Ch *value() const\r\n        {\r\n            return m_value ? m_value : nullstr();\r\n        }\r\n\r\n        //! Gets size of node value, not including terminator character.\r\n        //! This function works correctly irrespective of whether value is or is not zero terminated.\r\n        //! \\return Size of node value, in characters.\r\n        std::size_t value_size() const\r\n        {\r\n            return m_value ? m_value_size : 0;\r\n        }\r\n\r\n        ///////////////////////////////////////////////////////////////////////////\r\n        // Node modification\r\n    \r\n        //! Sets name of node to a non zero-terminated string.\r\n        //! See \\ref ownership_of_strings.\r\n        //! <br><br>\r\n        //! Note that node does not own its name or value, it only stores a pointer to it. \r\n        //! It will not delete or otherwise free the pointer on destruction.\r\n        //! It is reponsibility of the user to properly manage lifetime of the string.\r\n        //! The easiest way to achieve it is to use memory_pool of the document to allocate the string -\r\n        //! on destruction of the document the string will be automatically freed.\r\n        //! <br><br>\r\n        //! Size of name must be specified separately, because name does not have to be zero terminated.\r\n        //! Use name(const Ch *) function to have the length automatically calculated (string must be zero terminated).\r\n        //! \\param name Name of node to set. Does not have to be zero terminated.\r\n        //! \\param size Size of name, in characters. This does not include zero terminator, if one is present.\r\n        void name(const Ch *name, std::size_t size)\r\n        {\r\n            m_name = const_cast<Ch *>(name);\r\n            m_name_size = size;\r\n        }\r\n\r\n        //! Sets name of node to a zero-terminated string.\r\n        //! See also \\ref ownership_of_strings and xml_node::name(const Ch *, std::size_t).\r\n        //! \\param name Name of node to set. Must be zero terminated.\r\n        void name(const Ch *name)\r\n        {\r\n            this->name(name, internal::measure(name));\r\n        }\r\n\r\n        //! Sets value of node to a non zero-terminated string.\r\n        //! See \\ref ownership_of_strings.\r\n        //! <br><br>\r\n        //! Note that node does not own its name or value, it only stores a pointer to it. \r\n        //! It will not delete or otherwise free the pointer on destruction.\r\n        //! It is reponsibility of the user to properly manage lifetime of the string.\r\n        //! The easiest way to achieve it is to use memory_pool of the document to allocate the string -\r\n        //! on destruction of the document the string will be automatically freed.\r\n        //! <br><br>\r\n        //! Size of value must be specified separately, because it does not have to be zero terminated.\r\n        //! Use value(const Ch *) function to have the length automatically calculated (string must be zero terminated).\r\n        //! <br><br>\r\n        //! If an element has a child node of type node_data, it will take precedence over element value when printing.\r\n        //! If you want to manipulate data of elements using values, use parser flag rapidxml::parse_no_data_nodes to prevent creation of data nodes by the parser.\r\n        //! \\param value value of node to set. Does not have to be zero terminated.\r\n        //! \\param size Size of value, in characters. This does not include zero terminator, if one is present.\r\n        void value(const Ch *value, std::size_t size)\r\n        {\r\n            m_value = const_cast<Ch *>(value);\r\n            m_value_size = size;\r\n        }\r\n\r\n        //! Sets value of node to a zero-terminated string.\r\n        //! See also \\ref ownership_of_strings and xml_node::value(const Ch *, std::size_t).\r\n        //! \\param value Vame of node to set. Must be zero terminated.\r\n        void value(const Ch *value)\r\n        {\r\n            this->value(value, internal::measure(value));\r\n        }\r\n\r\n        ///////////////////////////////////////////////////////////////////////////\r\n        // Related nodes access\r\n    \r\n        //! Gets node parent.\r\n        //! \\return Pointer to parent node, or 0 if there is no parent.\r\n        xml_node<Ch> *parent() const\r\n        {\r\n            return m_parent;\r\n        }\r\n\r\n    protected:\r\n\r\n        // Return empty string\r\n        static Ch *nullstr()\r\n        {\r\n            static Ch zero = Ch('\\0');\r\n            return &zero;\r\n        }\r\n\r\n        Ch *m_name;                         // Name of node, or 0 if no name\r\n        Ch *m_value;                        // Value of node, or 0 if no value\r\n        std::size_t m_name_size;            // Length of node name, or undefined of no name\r\n        std::size_t m_value_size;           // Length of node value, or undefined if no value\r\n        xml_node<Ch> *m_parent;             // Pointer to parent node, or 0 if none\r\n\r\n    };\r\n\r\n    //! Class representing attribute node of XML document. \r\n    //! Each attribute has name and value strings, which are available through name() and value() functions (inherited from xml_base).\r\n    //! Note that after parse, both name and value of attribute will point to interior of source text used for parsing. \r\n    //! Thus, this text must persist in memory for the lifetime of attribute.\r\n    //! \\param Ch Character type to use.\r\n    template<class Ch = char>\r\n    class xml_attribute: public xml_base<Ch>\r\n    {\r\n\r\n        friend class xml_node<Ch>;\r\n    \r\n    public:\r\n\r\n        ///////////////////////////////////////////////////////////////////////////\r\n        // Construction & destruction\r\n    \r\n        //! Constructs an empty attribute with the specified type. \r\n        //! Consider using memory_pool of appropriate xml_document if allocating attributes manually.\r\n        xml_attribute()\r\n        {\r\n        }\r\n\r\n        ///////////////////////////////////////////////////////////////////////////\r\n        // Related nodes access\r\n    \r\n        //! Gets document of which attribute is a child.\r\n        //! \\return Pointer to document that contains this attribute, or 0 if there is no parent document.\r\n        xml_document<Ch> *document() const\r\n        {\r\n            if (xml_node<Ch> *node = this->parent())\r\n            {\r\n                while (node->parent())\r\n                    node = node->parent();\r\n                return node->type() == node_document ? static_cast<xml_document<Ch> *>(node) : 0;\r\n            }\r\n            else\r\n                return 0;\r\n        }\r\n\r\n        //! Gets previous attribute, optionally matching attribute name. \r\n        //! \\param name Name of attribute to find, or 0 to return previous attribute regardless of its name; this string doesn't have to be zero-terminated if name_size is non-zero\r\n        //! \\param name_size Size of name, in characters, or 0 to have size calculated automatically from string\r\n        //! \\param case_sensitive Should name comparison be case-sensitive; non case-sensitive comparison works properly only for ASCII characters\r\n        //! \\return Pointer to found attribute, or 0 if not found.\r\n        xml_attribute<Ch> *previous_attribute(const Ch *name = 0, std::size_t name_size = 0, bool case_sensitive = true) const\r\n        {\r\n            if (name)\r\n            {\r\n                if (name_size == 0)\r\n                    name_size = internal::measure(name);\r\n                for (xml_attribute<Ch> *attribute = m_prev_attribute; attribute; attribute = attribute->m_prev_attribute)\r\n                    if (internal::compare(attribute->name(), attribute->name_size(), name, name_size, case_sensitive))\r\n                        return attribute;\r\n                return 0;\r\n            }\r\n            else\r\n                return this->m_parent ? m_prev_attribute : 0;\r\n        }\r\n\r\n        //! Gets next attribute, optionally matching attribute name. \r\n        //! \\param name Name of attribute to find, or 0 to return next attribute regardless of its name; this string doesn't have to be zero-terminated if name_size is non-zero\r\n        //! \\param name_size Size of name, in characters, or 0 to have size calculated automatically from string\r\n        //! \\param case_sensitive Should name comparison be case-sensitive; non case-sensitive comparison works properly only for ASCII characters\r\n        //! \\return Pointer to found attribute, or 0 if not found.\r\n        xml_attribute<Ch> *next_attribute(const Ch *name = 0, std::size_t name_size = 0, bool case_sensitive = true) const\r\n        {\r\n            if (name)\r\n            {\r\n                if (name_size == 0)\r\n                    name_size = internal::measure(name);\r\n                for (xml_attribute<Ch> *attribute = m_next_attribute; attribute; attribute = attribute->m_next_attribute)\r\n                    if (internal::compare(attribute->name(), attribute->name_size(), name, name_size, case_sensitive))\r\n                        return attribute;\r\n                return 0;\r\n            }\r\n            else\r\n                return this->m_parent ? m_next_attribute : 0;\r\n        }\r\n\r\n    private:\r\n\r\n        xml_attribute<Ch> *m_prev_attribute;        // Pointer to previous sibling of attribute, or 0 if none; only valid if parent is non-zero\r\n        xml_attribute<Ch> *m_next_attribute;        // Pointer to next sibling of attribute, or 0 if none; only valid if parent is non-zero\r\n    \r\n    };\r\n\r\n    ///////////////////////////////////////////////////////////////////////////\r\n    // XML node\r\n\r\n    //! Class representing a node of XML document. \r\n    //! Each node may have associated name and value strings, which are available through name() and value() functions. \r\n    //! Interpretation of name and value depends on type of the node.\r\n    //! Type of node can be determined by using type() function.\r\n    //! <br><br>\r\n    //! Note that after parse, both name and value of node, if any, will point interior of source text used for parsing. \r\n    //! Thus, this text must persist in the memory for the lifetime of node.\r\n    //! \\param Ch Character type to use.\r\n    template<class Ch = char>\r\n    class xml_node: public xml_base<Ch>\r\n    {\r\n\r\n    public:\r\n\r\n        ///////////////////////////////////////////////////////////////////////////\r\n        // Construction & destruction\r\n    \r\n        //! Constructs an empty node with the specified type. \r\n        //! Consider using memory_pool of appropriate document to allocate nodes manually.\r\n        //! \\param type Type of node to construct.\r\n        xml_node(node_type type)\r\n            : m_type(type)\r\n            , m_first_node(0)\r\n            , m_first_attribute(0)\r\n        {\r\n        }\r\n\r\n        ///////////////////////////////////////////////////////////////////////////\r\n        // Node data access\r\n    \r\n        //! Gets type of node.\r\n        //! \\return Type of node.\r\n        node_type type() const\r\n        {\r\n            return m_type;\r\n        }\r\n\r\n        ///////////////////////////////////////////////////////////////////////////\r\n        // Related nodes access\r\n    \r\n        //! Gets document of which node is a child.\r\n        //! \\return Pointer to document that contains this node, or 0 if there is no parent document.\r\n        xml_document<Ch> *document() const\r\n        {\r\n            xml_node<Ch> *node = const_cast<xml_node<Ch> *>(this);\r\n            while (node->parent())\r\n                node = node->parent();\r\n            return node->type() == node_document ? static_cast<xml_document<Ch> *>(node) : 0;\r\n        }\r\n\r\n        //! Gets first child node, optionally matching node name.\r\n        //! \\param name Name of child to find, or 0 to return first child regardless of its name; this string doesn't have to be zero-terminated if name_size is non-zero\r\n        //! \\param name_size Size of name, in characters, or 0 to have size calculated automatically from string\r\n        //! \\param case_sensitive Should name comparison be case-sensitive; non case-sensitive comparison works properly only for ASCII characters\r\n        //! \\return Pointer to found child, or 0 if not found.\r\n        xml_node<Ch> *first_node(const Ch *name = 0, std::size_t name_size = 0, bool case_sensitive = true) const\r\n        {\r\n            if (name)\r\n            {\r\n                if (name_size == 0)\r\n                    name_size = internal::measure(name);\r\n                for (xml_node<Ch> *child = m_first_node; child; child = child->next_sibling())\r\n                    if (internal::compare(child->name(), child->name_size(), name, name_size, case_sensitive))\r\n                        return child;\r\n                return 0;\r\n            }\r\n            else\r\n                return m_first_node;\r\n        }\r\n\r\n        //! Gets last child node, optionally matching node name. \r\n        //! Behaviour is undefined if node has no children.\r\n        //! Use first_node() to test if node has children.\r\n        //! \\param name Name of child to find, or 0 to return last child regardless of its name; this string doesn't have to be zero-terminated if name_size is non-zero\r\n        //! \\param name_size Size of name, in characters, or 0 to have size calculated automatically from string\r\n        //! \\param case_sensitive Should name comparison be case-sensitive; non case-sensitive comparison works properly only for ASCII characters\r\n        //! \\return Pointer to found child, or 0 if not found.\r\n        xml_node<Ch> *last_node(const Ch *name = 0, std::size_t name_size = 0, bool case_sensitive = true) const\r\n        {\r\n            assert(m_first_node);  // Cannot query for last child if node has no children\r\n            if (name)\r\n            {\r\n                if (name_size == 0)\r\n                    name_size = internal::measure(name);\r\n                for (xml_node<Ch> *child = m_last_node; child; child = child->previous_sibling())\r\n                    if (internal::compare(child->name(), child->name_size(), name, name_size, case_sensitive))\r\n                        return child;\r\n                return 0;\r\n            }\r\n            else\r\n                return m_last_node;\r\n        }\r\n\r\n        //! Gets previous sibling node, optionally matching node name. \r\n        //! Behaviour is undefined if node has no parent.\r\n        //! Use parent() to test if node has a parent.\r\n        //! \\param name Name of sibling to find, or 0 to return previous sibling regardless of its name; this string doesn't have to be zero-terminated if name_size is non-zero\r\n        //! \\param name_size Size of name, in characters, or 0 to have size calculated automatically from string\r\n        //! \\param case_sensitive Should name comparison be case-sensitive; non case-sensitive comparison works properly only for ASCII characters\r\n        //! \\return Pointer to found sibling, or 0 if not found.\r\n        xml_node<Ch> *previous_sibling(const Ch *name = 0, std::size_t name_size = 0, bool case_sensitive = true) const\r\n        {\r\n            assert(this->m_parent);     // Cannot query for siblings if node has no parent\r\n            if (name)\r\n            {\r\n                if (name_size == 0)\r\n                    name_size = internal::measure(name);\r\n                for (xml_node<Ch> *sibling = m_prev_sibling; sibling; sibling = sibling->m_prev_sibling)\r\n                    if (internal::compare(sibling->name(), sibling->name_size(), name, name_size, case_sensitive))\r\n                        return sibling;\r\n                return 0;\r\n            }\r\n            else\r\n                return m_prev_sibling;\r\n        }\r\n\r\n        //! Gets next sibling node, optionally matching node name. \r\n        //! Behaviour is undefined if node has no parent.\r\n        //! Use parent() to test if node has a parent.\r\n        //! \\param name Name of sibling to find, or 0 to return next sibling regardless of its name; this string doesn't have to be zero-terminated if name_size is non-zero\r\n        //! \\param name_size Size of name, in characters, or 0 to have size calculated automatically from string\r\n        //! \\param case_sensitive Should name comparison be case-sensitive; non case-sensitive comparison works properly only for ASCII characters\r\n        //! \\return Pointer to found sibling, or 0 if not found.\r\n        xml_node<Ch> *next_sibling(const Ch *name = 0, std::size_t name_size = 0, bool case_sensitive = true) const\r\n        {\r\n            assert(this->m_parent);     // Cannot query for siblings if node has no parent\r\n            if (name)\r\n            {\r\n                if (name_size == 0)\r\n                    name_size = internal::measure(name);\r\n                for (xml_node<Ch> *sibling = m_next_sibling; sibling; sibling = sibling->m_next_sibling)\r\n                    if (internal::compare(sibling->name(), sibling->name_size(), name, name_size, case_sensitive))\r\n                        return sibling;\r\n                return 0;\r\n            }\r\n            else\r\n                return m_next_sibling;\r\n        }\r\n\r\n        //! Gets first attribute of node, optionally matching attribute name.\r\n        //! \\param name Name of attribute to find, or 0 to return first attribute regardless of its name; this string doesn't have to be zero-terminated if name_size is non-zero\r\n        //! \\param name_size Size of name, in characters, or 0 to have size calculated automatically from string\r\n        //! \\param case_sensitive Should name comparison be case-sensitive; non case-sensitive comparison works properly only for ASCII characters\r\n        //! \\return Pointer to found attribute, or 0 if not found.\r\n        xml_attribute<Ch> *first_attribute(const Ch *name = 0, std::size_t name_size = 0, bool case_sensitive = true) const\r\n        {\r\n            if (name)\r\n            {\r\n                if (name_size == 0)\r\n                    name_size = internal::measure(name);\r\n                for (xml_attribute<Ch> *attribute = m_first_attribute; attribute; attribute = attribute->m_next_attribute)\r\n                    if (internal::compare(attribute->name(), attribute->name_size(), name, name_size, case_sensitive))\r\n                        return attribute;\r\n                return 0;\r\n            }\r\n            else\r\n                return m_first_attribute;\r\n        }\r\n\r\n        //! Gets last attribute of node, optionally matching attribute name.\r\n        //! \\param name Name of attribute to find, or 0 to return last attribute regardless of its name; this string doesn't have to be zero-terminated if name_size is non-zero\r\n        //! \\param name_size Size of name, in characters, or 0 to have size calculated automatically from string\r\n        //! \\param case_sensitive Should name comparison be case-sensitive; non case-sensitive comparison works properly only for ASCII characters\r\n        //! \\return Pointer to found attribute, or 0 if not found.\r\n        xml_attribute<Ch> *last_attribute(const Ch *name = 0, std::size_t name_size = 0, bool case_sensitive = true) const\r\n        {\r\n            if (name)\r\n            {\r\n                if (name_size == 0)\r\n                    name_size = internal::measure(name);\r\n                for (xml_attribute<Ch> *attribute = m_last_attribute; attribute; attribute = attribute->m_prev_attribute)\r\n                    if (internal::compare(attribute->name(), attribute->name_size(), name, name_size, case_sensitive))\r\n                        return attribute;\r\n                return 0;\r\n            }\r\n            else\r\n                return m_first_attribute ? m_last_attribute : 0;\r\n        }\r\n\r\n        ///////////////////////////////////////////////////////////////////////////\r\n        // Node modification\r\n    \r\n        //! Sets type of node.\r\n        //! \\param type Type of node to set.\r\n        void type(node_type type)\r\n        {\r\n            m_type = type;\r\n        }\r\n\r\n        ///////////////////////////////////////////////////////////////////////////\r\n        // Node manipulation\r\n\r\n        //! Prepends a new child node.\r\n        //! The prepended child becomes the first child, and all existing children are moved one position back.\r\n        //! \\param child Node to prepend.\r\n        void prepend_node(xml_node<Ch> *child)\r\n        {\r\n            assert(child && !child->parent() && child->type() != node_document);\r\n            if (first_node())\r\n            {\r\n                child->m_next_sibling = m_first_node;\r\n                m_first_node->m_prev_sibling = child;\r\n            }\r\n            else\r\n            {\r\n                child->m_next_sibling = 0;\r\n                m_last_node = child;\r\n            }\r\n            m_first_node = child;\r\n            child->m_parent = this;\r\n            child->m_prev_sibling = 0;\r\n        }\r\n\r\n        //! Appends a new child node. \r\n        //! The appended child becomes the last child.\r\n        //! \\param child Node to append.\r\n        void append_node(xml_node<Ch> *child)\r\n        {\r\n            assert(child && !child->parent() && child->type() != node_document);\r\n            if (first_node())\r\n            {\r\n                child->m_prev_sibling = m_last_node;\r\n                m_last_node->m_next_sibling = child;\r\n            }\r\n            else\r\n            {\r\n                child->m_prev_sibling = 0;\r\n                m_first_node = child;\r\n            }\r\n            m_last_node = child;\r\n            child->m_parent = this;\r\n            child->m_next_sibling = 0;\r\n        }\r\n\r\n        //! Inserts a new child node at specified place inside the node. \r\n        //! All children after and including the specified node are moved one position back.\r\n        //! \\param where Place where to insert the child, or 0 to insert at the back.\r\n        //! \\param child Node to insert.\r\n        void insert_node(xml_node<Ch> *where, xml_node<Ch> *child)\r\n        {\r\n            assert(!where || where->parent() == this);\r\n            assert(child && !child->parent() && child->type() != node_document);\r\n            if (where == m_first_node)\r\n                prepend_node(child);\r\n            else if (where == 0)\r\n                append_node(child);\r\n            else\r\n            {\r\n                child->m_prev_sibling = where->m_prev_sibling;\r\n                child->m_next_sibling = where;\r\n                where->m_prev_sibling->m_next_sibling = child;\r\n                where->m_prev_sibling = child;\r\n                child->m_parent = this;\r\n            }\r\n        }\r\n\r\n        //! Removes first child node. \r\n        //! If node has no children, behaviour is undefined.\r\n        //! Use first_node() to test if node has children.\r\n        void remove_first_node()\r\n        {\r\n            assert(first_node());\r\n            xml_node<Ch> *child = m_first_node;\r\n            m_first_node = child->m_next_sibling;\r\n            if (child->m_next_sibling)\r\n                child->m_next_sibling->m_prev_sibling = 0;\r\n            else\r\n                m_last_node = 0;\r\n            child->m_parent = 0;\r\n        }\r\n\r\n        //! Removes last child of the node. \r\n        //! If node has no children, behaviour is undefined.\r\n        //! Use first_node() to test if node has children.\r\n        void remove_last_node()\r\n        {\r\n            assert(first_node());\r\n            xml_node<Ch> *child = m_last_node;\r\n            if (child->m_prev_sibling)\r\n            {\r\n                m_last_node = child->m_prev_sibling;\r\n                child->m_prev_sibling->m_next_sibling = 0;\r\n            }\r\n            else\r\n                m_first_node = 0;\r\n            child->m_parent = 0;\r\n        }\r\n\r\n        //! Removes specified child from the node\r\n        // \\param where Pointer to child to be removed.\r\n        void remove_node(xml_node<Ch> *where)\r\n        {\r\n            assert(where && where->parent() == this);\r\n            assert(first_node());\r\n            if (where == m_first_node)\r\n                remove_first_node();\r\n            else if (where == m_last_node)\r\n                remove_last_node();\r\n            else\r\n            {\r\n                where->m_prev_sibling->m_next_sibling = where->m_next_sibling;\r\n                where->m_next_sibling->m_prev_sibling = where->m_prev_sibling;\r\n                where->m_parent = 0;\r\n            }\r\n        }\r\n\r\n        //! Removes all child nodes (but not attributes).\r\n        void remove_all_nodes()\r\n        {\r\n            for (xml_node<Ch> *node = first_node(); node; node = node->m_next_sibling)\r\n                node->m_parent = 0;\r\n            m_first_node = 0;\r\n        }\r\n\r\n        //! Prepends a new attribute to the node.\r\n        //! \\param attribute Attribute to prepend.\r\n        void prepend_attribute(xml_attribute<Ch> *attribute)\r\n        {\r\n            assert(attribute && !attribute->parent());\r\n            if (first_attribute())\r\n            {\r\n                attribute->m_next_attribute = m_first_attribute;\r\n                m_first_attribute->m_prev_attribute = attribute;\r\n            }\r\n            else\r\n            {\r\n                attribute->m_next_attribute = 0;\r\n                m_last_attribute = attribute;\r\n            }\r\n            m_first_attribute = attribute;\r\n            attribute->m_parent = this;\r\n            attribute->m_prev_attribute = 0;\r\n        }\r\n\r\n        //! Appends a new attribute to the node.\r\n        //! \\param attribute Attribute to append.\r\n        void append_attribute(xml_attribute<Ch> *attribute)\r\n        {\r\n            assert(attribute && !attribute->parent());\r\n            if (first_attribute())\r\n            {\r\n                attribute->m_prev_attribute = m_last_attribute;\r\n                m_last_attribute->m_next_attribute = attribute;\r\n            }\r\n            else\r\n            {\r\n                attribute->m_prev_attribute = 0;\r\n                m_first_attribute = attribute;\r\n            }\r\n            m_last_attribute = attribute;\r\n            attribute->m_parent = this;\r\n            attribute->m_next_attribute = 0;\r\n        }\r\n\r\n        //! Inserts a new attribute at specified place inside the node. \r\n        //! All attributes after and including the specified attribute are moved one position back.\r\n        //! \\param where Place where to insert the attribute, or 0 to insert at the back.\r\n        //! \\param attribute Attribute to insert.\r\n        void insert_attribute(xml_attribute<Ch> *where, xml_attribute<Ch> *attribute)\r\n        {\r\n            assert(!where || where->parent() == this);\r\n            assert(attribute && !attribute->parent());\r\n            if (where == m_first_attribute)\r\n                prepend_attribute(attribute);\r\n            else if (where == 0)\r\n                append_attribute(attribute);\r\n            else\r\n            {\r\n                attribute->m_prev_attribute = where->m_prev_attribute;\r\n                attribute->m_next_attribute = where;\r\n                where->m_prev_attribute->m_next_attribute = attribute;\r\n                where->m_prev_attribute = attribute;\r\n                attribute->m_parent = this;\r\n            }\r\n        }\r\n\r\n        //! Removes first attribute of the node. \r\n        //! If node has no attributes, behaviour is undefined.\r\n        //! Use first_attribute() to test if node has attributes.\r\n        void remove_first_attribute()\r\n        {\r\n            assert(first_attribute());\r\n            xml_attribute<Ch> *attribute = m_first_attribute;\r\n            if (attribute->m_next_attribute)\r\n            {\r\n                attribute->m_next_attribute->m_prev_attribute = 0;\r\n            }\r\n            else\r\n                m_last_attribute = 0;\r\n            attribute->m_parent = 0;\r\n            m_first_attribute = attribute->m_next_attribute;\r\n        }\r\n\r\n        //! Removes last attribute of the node. \r\n        //! If node has no attributes, behaviour is undefined.\r\n        //! Use first_attribute() to test if node has attributes.\r\n        void remove_last_attribute()\r\n        {\r\n            assert(first_attribute());\r\n            xml_attribute<Ch> *attribute = m_last_attribute;\r\n            if (attribute->m_prev_attribute)\r\n            {\r\n                attribute->m_prev_attribute->m_next_attribute = 0;\r\n                m_last_attribute = attribute->m_prev_attribute;\r\n            }\r\n            else\r\n                m_first_attribute = 0;\r\n            attribute->m_parent = 0;\r\n        }\r\n\r\n        //! Removes specified attribute from node.\r\n        //! \\param where Pointer to attribute to be removed.\r\n        void remove_attribute(xml_attribute<Ch> *where)\r\n        {\r\n            assert(first_attribute() && where->parent() == this);\r\n            if (where == m_first_attribute)\r\n                remove_first_attribute();\r\n            else if (where == m_last_attribute)\r\n                remove_last_attribute();\r\n            else\r\n            {\r\n                where->m_prev_attribute->m_next_attribute = where->m_next_attribute;\r\n                where->m_next_attribute->m_prev_attribute = where->m_prev_attribute;\r\n                where->m_parent = 0;\r\n            }\r\n        }\r\n\r\n        //! Removes all attributes of node.\r\n        void remove_all_attributes()\r\n        {\r\n            for (xml_attribute<Ch> *attribute = first_attribute(); attribute; attribute = attribute->m_next_attribute)\r\n                attribute->m_parent = 0;\r\n            m_first_attribute = 0;\r\n        }\r\n        \r\n    private:\r\n\r\n        ///////////////////////////////////////////////////////////////////////////\r\n        // Restrictions\r\n\r\n        // No copying\r\n        xml_node(const xml_node &);\r\n        void operator =(const xml_node &);\r\n    \r\n        ///////////////////////////////////////////////////////////////////////////\r\n        // Data members\r\n    \r\n        // Note that some of the pointers below have UNDEFINED values if certain other pointers are 0.\r\n        // This is required for maximum performance, as it allows the parser to omit initialization of \r\n        // unneded/redundant values.\r\n        //\r\n        // The rules are as follows:\r\n        // 1. first_node and first_attribute contain valid pointers, or 0 if node has no children/attributes respectively\r\n        // 2. last_node and last_attribute are valid only if node has at least one child/attribute respectively, otherwise they contain garbage\r\n        // 3. prev_sibling and next_sibling are valid only if node has a parent, otherwise they contain garbage\r\n\r\n        node_type m_type;                       // Type of node; always valid\r\n        xml_node<Ch> *m_first_node;             // Pointer to first child node, or 0 if none; always valid\r\n        xml_node<Ch> *m_last_node;              // Pointer to last child node, or 0 if none; this value is only valid if m_first_node is non-zero\r\n        xml_attribute<Ch> *m_first_attribute;   // Pointer to first attribute of node, or 0 if none; always valid\r\n        xml_attribute<Ch> *m_last_attribute;    // Pointer to last attribute of node, or 0 if none; this value is only valid if m_first_attribute is non-zero\r\n        xml_node<Ch> *m_prev_sibling;           // Pointer to previous sibling of node, or 0 if none; this value is only valid if m_parent is non-zero\r\n        xml_node<Ch> *m_next_sibling;           // Pointer to next sibling of node, or 0 if none; this value is only valid if m_parent is non-zero\r\n\r\n    };\r\n\r\n    ///////////////////////////////////////////////////////////////////////////\r\n    // XML document\r\n    \r\n    //! This class represents root of the DOM hierarchy. \r\n    //! It is also an xml_node and a memory_pool through public inheritance.\r\n    //! Use parse() function to build a DOM tree from a zero-terminated XML text string.\r\n    //! parse() function allocates memory for nodes and attributes by using functions of xml_document, \r\n    //! which are inherited from memory_pool.\r\n    //! To access root node of the document, use the document itself, as if it was an xml_node.\r\n    //! \\param Ch Character type to use.\r\n    template<class Ch = char>\r\n    class xml_document: public xml_node<Ch>, public memory_pool<Ch>\r\n    {\r\n    \r\n    public:\r\n\r\n        //! Constructs empty XML document\r\n        xml_document()\r\n            : xml_node<Ch>(node_document)\r\n        {\r\n        }\r\n\r\n        //! Parses zero-terminated XML string according to given flags.\r\n        //! Passed string will be modified by the parser, unless rapidxml::parse_non_destructive flag is used.\r\n        //! The string must persist for the lifetime of the document.\r\n        //! In case of error, rapidxml::parse_error exception will be thrown.\r\n        //! <br><br>\r\n        //! If you want to parse contents of a file, you must first load the file into the memory, and pass pointer to its beginning.\r\n        //! Make sure that data is zero-terminated.\r\n        //! <br><br>\r\n        //! Document can be parsed into multiple times. \r\n        //! Each new call to parse removes previous nodes and attributes (if any), but does not clear memory pool.\r\n        //! \\param text XML data to parse; pointer is non-const to denote fact that this data may be modified by the parser.\r\n        template<int Flags>\r\n        void parse(Ch *text)\r\n        {\r\n            assert(text);\r\n            \r\n            // Remove current contents\r\n            this->remove_all_nodes();\r\n            this->remove_all_attributes();\r\n            \r\n            // Parse BOM, if any\r\n            parse_bom<Flags>(text);\r\n            \r\n            // Parse children\r\n            while (1)\r\n            {\r\n                // Skip whitespace before node\r\n                skip<whitespace_pred, Flags>(text);\r\n                if (*text == 0)\r\n                    break;\r\n\r\n                // Parse and append new child\r\n                if (*text == Ch('<'))\r\n                {\r\n                    ++text;     // Skip '<'\r\n                    if (xml_node<Ch> *node = parse_node<Flags>(text))\r\n                        this->append_node(node);\r\n                }\r\n                else\r\n                    RAPIDXML_PARSE_ERROR(\"expected <\", text);\r\n            }\r\n\r\n        }\r\n\r\n        //! Clears the document by deleting all nodes and clearing the memory pool.\r\n        //! All nodes owned by document pool are destroyed.\r\n        void clear()\r\n        {\r\n            this->remove_all_nodes();\r\n            this->remove_all_attributes();\r\n            memory_pool<Ch>::clear();\r\n        }\r\n        \r\n    private:\r\n\r\n        ///////////////////////////////////////////////////////////////////////\r\n        // Internal character utility functions\r\n        \r\n        // Detect whitespace character\r\n        struct whitespace_pred\r\n        {\r\n            static unsigned char test(Ch ch)\r\n            {\r\n                return internal::lookup_tables<0>::lookup_whitespace[static_cast<unsigned char>(ch)];\r\n            }\r\n        };\r\n\r\n        // Detect node name character\r\n        struct node_name_pred\r\n        {\r\n            static unsigned char test(Ch ch)\r\n            {\r\n                return internal::lookup_tables<0>::lookup_node_name[static_cast<unsigned char>(ch)];\r\n            }\r\n        };\r\n\r\n        // Detect attribute name character\r\n        struct attribute_name_pred\r\n        {\r\n            static unsigned char test(Ch ch)\r\n            {\r\n                return internal::lookup_tables<0>::lookup_attribute_name[static_cast<unsigned char>(ch)];\r\n            }\r\n        };\r\n\r\n        // Detect text character (PCDATA)\r\n        struct text_pred\r\n        {\r\n            static unsigned char test(Ch ch)\r\n            {\r\n                return internal::lookup_tables<0>::lookup_text[static_cast<unsigned char>(ch)];\r\n            }\r\n        };\r\n\r\n        // Detect text character (PCDATA) that does not require processing\r\n        struct text_pure_no_ws_pred\r\n        {\r\n            static unsigned char test(Ch ch)\r\n            {\r\n                return internal::lookup_tables<0>::lookup_text_pure_no_ws[static_cast<unsigned char>(ch)];\r\n            }\r\n        };\r\n\r\n        // Detect text character (PCDATA) that does not require processing\r\n        struct text_pure_with_ws_pred\r\n        {\r\n            static unsigned char test(Ch ch)\r\n            {\r\n                return internal::lookup_tables<0>::lookup_text_pure_with_ws[static_cast<unsigned char>(ch)];\r\n            }\r\n        };\r\n\r\n        // Detect attribute value character\r\n        template<Ch Quote>\r\n        struct attribute_value_pred\r\n        {\r\n            static unsigned char test(Ch ch)\r\n            {\r\n                if (Quote == Ch('\\''))\r\n                    return internal::lookup_tables<0>::lookup_attribute_data_1[static_cast<unsigned char>(ch)];\r\n                if (Quote == Ch('\\\"'))\r\n                    return internal::lookup_tables<0>::lookup_attribute_data_2[static_cast<unsigned char>(ch)];\r\n                return 0;       // Should never be executed, to avoid warnings on Comeau\r\n            }\r\n        };\r\n\r\n        // Detect attribute value character\r\n        template<Ch Quote>\r\n        struct attribute_value_pure_pred\r\n        {\r\n            static unsigned char test(Ch ch)\r\n            {\r\n                if (Quote == Ch('\\''))\r\n                    return internal::lookup_tables<0>::lookup_attribute_data_1_pure[static_cast<unsigned char>(ch)];\r\n                if (Quote == Ch('\\\"'))\r\n                    return internal::lookup_tables<0>::lookup_attribute_data_2_pure[static_cast<unsigned char>(ch)];\r\n                return 0;       // Should never be executed, to avoid warnings on Comeau\r\n            }\r\n        };\r\n\r\n        // Insert coded character, using UTF8 or 8-bit ASCII\r\n        template<int Flags>\r\n        static void insert_coded_character(Ch *&text, unsigned long code)\r\n        {\r\n            if (Flags & parse_no_utf8)\r\n            {\r\n                // Insert 8-bit ASCII character\r\n                // Todo: possibly verify that code is less than 256 and use replacement char otherwise?\r\n                text[0] = static_cast<unsigned char>(code);\r\n                text += 1;\r\n            }\r\n            else\r\n            {\r\n                // Insert UTF8 sequence\r\n                if (code < 0x80)    // 1 byte sequence\r\n                {\r\n\t                text[0] = static_cast<unsigned char>(code);\r\n                    text += 1;\r\n                }\r\n                else if (code < 0x800)  // 2 byte sequence\r\n                {\r\n\t                text[1] = static_cast<unsigned char>((code | 0x80) & 0xBF); code >>= 6;\r\n\t                text[0] = static_cast<unsigned char>(code | 0xC0);\r\n                    text += 2;\r\n                }\r\n\t            else if (code < 0x10000)    // 3 byte sequence\r\n                {\r\n\t                text[2] = static_cast<unsigned char>((code | 0x80) & 0xBF); code >>= 6;\r\n\t                text[1] = static_cast<unsigned char>((code | 0x80) & 0xBF); code >>= 6;\r\n\t                text[0] = static_cast<unsigned char>(code | 0xE0);\r\n                    text += 3;\r\n                }\r\n\t            else if (code < 0x110000)   // 4 byte sequence\r\n                {\r\n\t                text[3] = static_cast<unsigned char>((code | 0x80) & 0xBF); code >>= 6;\r\n\t                text[2] = static_cast<unsigned char>((code | 0x80) & 0xBF); code >>= 6;\r\n\t                text[1] = static_cast<unsigned char>((code | 0x80) & 0xBF); code >>= 6;\r\n\t                text[0] = static_cast<unsigned char>(code | 0xF0);\r\n                    text += 4;\r\n                }\r\n                else    // Invalid, only codes up to 0x10FFFF are allowed in Unicode\r\n                {\r\n                    RAPIDXML_PARSE_ERROR(\"invalid numeric character entity\", text);\r\n                }\r\n            }\r\n        }\r\n\r\n        // Skip characters until predicate evaluates to true\r\n        template<class StopPred, int Flags>\r\n        static void skip(Ch *&text)\r\n        {\r\n            Ch *tmp = text;\r\n            while (StopPred::test(*tmp))\r\n                ++tmp;\r\n            text = tmp;\r\n        }\r\n\r\n        // Skip characters until predicate evaluates to true while doing the following:\r\n        // - replacing XML character entity references with proper characters (&apos; &amp; &quot; &lt; &gt; &#...;)\r\n        // - condensing whitespace sequences to single space character\r\n        template<class StopPred, class StopPredPure, int Flags>\r\n        static Ch *skip_and_expand_character_refs(Ch *&text)\r\n        {\r\n            // If entity translation, whitespace condense and whitespace trimming is disabled, use plain skip\r\n            if (Flags & parse_no_entity_translation && \r\n                !(Flags & parse_normalize_whitespace) &&\r\n                !(Flags & parse_trim_whitespace))\r\n            {\r\n                skip<StopPred, Flags>(text);\r\n                return text;\r\n            }\r\n            \r\n            // Use simple skip until first modification is detected\r\n            skip<StopPredPure, Flags>(text);\r\n\r\n            // Use translation skip\r\n            Ch *src = text;\r\n            Ch *dest = src;\r\n            while (StopPred::test(*src))\r\n            {\r\n                // If entity translation is enabled    \r\n                if (!(Flags & parse_no_entity_translation))\r\n                {\r\n                    // Test if replacement is needed\r\n                    if (src[0] == Ch('&'))\r\n                    {\r\n                        switch (src[1])\r\n                        {\r\n\r\n                        // &amp; &apos;\r\n                        case Ch('a'): \r\n                            if (src[2] == Ch('m') && src[3] == Ch('p') && src[4] == Ch(';'))\r\n                            {\r\n                                *dest = Ch('&');\r\n                                ++dest;\r\n                                src += 5;\r\n                                continue;\r\n                            }\r\n                            if (src[2] == Ch('p') && src[3] == Ch('o') && src[4] == Ch('s') && src[5] == Ch(';'))\r\n                            {\r\n                                *dest = Ch('\\'');\r\n                                ++dest;\r\n                                src += 6;\r\n                                continue;\r\n                            }\r\n                            break;\r\n\r\n                        // &quot;\r\n                        case Ch('q'): \r\n                            if (src[2] == Ch('u') && src[3] == Ch('o') && src[4] == Ch('t') && src[5] == Ch(';'))\r\n                            {\r\n                                *dest = Ch('\"');\r\n                                ++dest;\r\n                                src += 6;\r\n                                continue;\r\n                            }\r\n                            break;\r\n\r\n                        // &gt;\r\n                        case Ch('g'): \r\n                            if (src[2] == Ch('t') && src[3] == Ch(';'))\r\n                            {\r\n                                *dest = Ch('>');\r\n                                ++dest;\r\n                                src += 4;\r\n                                continue;\r\n                            }\r\n                            break;\r\n\r\n                        // &lt;\r\n                        case Ch('l'): \r\n                            if (src[2] == Ch('t') && src[3] == Ch(';'))\r\n                            {\r\n                                *dest = Ch('<');\r\n                                ++dest;\r\n                                src += 4;\r\n                                continue;\r\n                            }\r\n                            break;\r\n\r\n                        // &#...; - assumes ASCII\r\n                        case Ch('#'): \r\n                            if (src[2] == Ch('x'))\r\n                            {\r\n                                unsigned long code = 0;\r\n                                src += 3;   // Skip &#x\r\n                                while (1)\r\n                                {\r\n                                    unsigned char digit = internal::lookup_tables<0>::lookup_digits[static_cast<unsigned char>(*src)];\r\n                                    if (digit == 0xFF)\r\n                                        break;\r\n                                    code = code * 16 + digit;\r\n                                    ++src;\r\n                                }\r\n                                insert_coded_character<Flags>(dest, code);    // Put character in output\r\n                            }\r\n                            else\r\n                            {\r\n                                unsigned long code = 0;\r\n                                src += 2;   // Skip &#\r\n                                while (1)\r\n                                {\r\n                                    unsigned char digit = internal::lookup_tables<0>::lookup_digits[static_cast<unsigned char>(*src)];\r\n                                    if (digit == 0xFF)\r\n                                        break;\r\n                                    code = code * 10 + digit;\r\n                                    ++src;\r\n                                }\r\n                                insert_coded_character<Flags>(dest, code);    // Put character in output\r\n                            }\r\n                            if (*src == Ch(';'))\r\n                                ++src;\r\n                            else\r\n                                RAPIDXML_PARSE_ERROR(\"expected ;\", src);\r\n                            continue;\r\n\r\n                        // Something else\r\n                        default:\r\n                            // Ignore, just copy '&' verbatim\r\n                            break;\r\n\r\n                        }\r\n                    }\r\n                }\r\n                \r\n                // If whitespace condensing is enabled\r\n                if (Flags & parse_normalize_whitespace)\r\n                {\r\n                    // Test if condensing is needed                 \r\n                    if (whitespace_pred::test(*src))\r\n                    {\r\n                        *dest = Ch(' '); ++dest;    // Put single space in dest\r\n                        ++src;                      // Skip first whitespace char\r\n                        // Skip remaining whitespace chars\r\n                        while (whitespace_pred::test(*src))\r\n                            ++src;\r\n                        continue;\r\n                    }\r\n                }\r\n\r\n                // No replacement, only copy character\r\n                *dest++ = *src++;\r\n\r\n            }\r\n\r\n            // Return new end\r\n            text = src;\r\n            return dest;\r\n\r\n        }\r\n\r\n        ///////////////////////////////////////////////////////////////////////\r\n        // Internal parsing functions\r\n        \r\n        // Parse BOM, if any\r\n        template<int Flags>\r\n        void parse_bom(Ch *&text)\r\n        {\r\n            // UTF-8?\r\n            if (static_cast<unsigned char>(text[0]) == 0xEF && \r\n                static_cast<unsigned char>(text[1]) == 0xBB && \r\n                static_cast<unsigned char>(text[2]) == 0xBF)\r\n            {\r\n                text += 3;      // Skup utf-8 bom\r\n            }\r\n        }\r\n\r\n        // Parse XML declaration (<?xml...)\r\n        template<int Flags>\r\n        xml_node<Ch> *parse_xml_declaration(Ch *&text)\r\n        {\r\n            // If parsing of declaration is disabled\r\n            if (!(Flags & parse_declaration_node))\r\n            {\r\n                // Skip until end of declaration\r\n                while (text[0] != Ch('?') || text[1] != Ch('>'))\r\n                {\r\n                    if (!text[0])\r\n                        RAPIDXML_PARSE_ERROR(\"unexpected end of data\", text);\r\n                    ++text;\r\n                }\r\n                text += 2;    // Skip '?>'\r\n                return 0;\r\n            }\r\n\r\n            // Create declaration\r\n            xml_node<Ch> *declaration = this->allocate_node(node_declaration);\r\n\r\n            // Skip whitespace before attributes or ?>\r\n            skip<whitespace_pred, Flags>(text);\r\n\r\n            // Parse declaration attributes\r\n            parse_node_attributes<Flags>(text, declaration);\r\n            \r\n            // Skip ?>\r\n            if (text[0] != Ch('?') || text[1] != Ch('>'))\r\n                RAPIDXML_PARSE_ERROR(\"expected ?>\", text);\r\n            text += 2;\r\n            \r\n            return declaration;\r\n        }\r\n\r\n        // Parse XML comment (<!--...)\r\n        template<int Flags>\r\n        xml_node<Ch> *parse_comment(Ch *&text)\r\n        {\r\n            // If parsing of comments is disabled\r\n            if (!(Flags & parse_comment_nodes))\r\n            {\r\n                // Skip until end of comment\r\n                while (text[0] != Ch('-') || text[1] != Ch('-') || text[2] != Ch('>'))\r\n                {\r\n                    if (!text[0])\r\n                        RAPIDXML_PARSE_ERROR(\"unexpected end of data\", text);\r\n                    ++text;\r\n                }\r\n                text += 3;     // Skip '-->'\r\n                return 0;      // Do not produce comment node\r\n            }\r\n\r\n            // Remember value start\r\n            Ch *value = text;\r\n\r\n            // Skip until end of comment\r\n            while (text[0] != Ch('-') || text[1] != Ch('-') || text[2] != Ch('>'))\r\n            {\r\n                if (!text[0])\r\n                    RAPIDXML_PARSE_ERROR(\"unexpected end of data\", text);\r\n                ++text;\r\n            }\r\n\r\n            // Create comment node\r\n            xml_node<Ch> *comment = this->allocate_node(node_comment);\r\n            comment->value(value, text - value);\r\n            \r\n            // Place zero terminator after comment value\r\n            if (!(Flags & parse_no_string_terminators))\r\n                *text = Ch('\\0');\r\n            \r\n            text += 3;     // Skip '-->'\r\n            return comment;\r\n        }\r\n\r\n        // Parse DOCTYPE\r\n        template<int Flags>\r\n        xml_node<Ch> *parse_doctype(Ch *&text)\r\n        {\r\n            // Remember value start\r\n            Ch *value = text;\r\n\r\n            // Skip to >\r\n            while (*text != Ch('>'))\r\n            {\r\n                // Determine character type\r\n                switch (*text)\r\n                {\r\n                \r\n                // If '[' encountered, scan for matching ending ']' using naive algorithm with depth\r\n                // This works for all W3C test files except for 2 most wicked\r\n                case Ch('['):\r\n                {\r\n                    ++text;     // Skip '['\r\n                    int depth = 1;\r\n                    while (depth > 0)\r\n                    {\r\n                        switch (*text)\r\n                        {\r\n                            case Ch('['): ++depth; break;\r\n                            case Ch(']'): --depth; break;\r\n                            case 0: RAPIDXML_PARSE_ERROR(\"unexpected end of data\", text);\r\n                        }\r\n                        ++text;\r\n                    }\r\n                    break;\r\n                }\r\n                \r\n                // Error on end of text\r\n                case Ch('\\0'):\r\n                    RAPIDXML_PARSE_ERROR(\"unexpected end of data\", text);\r\n                \r\n                // Other character, skip it\r\n                default:\r\n                    ++text;\r\n\r\n                }\r\n            }\r\n            \r\n            // If DOCTYPE nodes enabled\r\n            if (Flags & parse_doctype_node)\r\n            {\r\n                // Create a new doctype node\r\n                xml_node<Ch> *doctype = this->allocate_node(node_doctype);\r\n                doctype->value(value, text - value);\r\n                \r\n                // Place zero terminator after value\r\n                if (!(Flags & parse_no_string_terminators))\r\n                    *text = Ch('\\0');\r\n\r\n                text += 1;      // skip '>'\r\n                return doctype;\r\n            }\r\n            else\r\n            {\r\n                text += 1;      // skip '>'\r\n                return 0;\r\n            }\r\n\r\n        }\r\n\r\n        // Parse PI\r\n        template<int Flags>\r\n        xml_node<Ch> *parse_pi(Ch *&text)\r\n        {\r\n            // If creation of PI nodes is enabled\r\n            if (Flags & parse_pi_nodes)\r\n            {\r\n                // Create pi node\r\n                xml_node<Ch> *pi = this->allocate_node(node_pi);\r\n\r\n                // Extract PI target name\r\n                Ch *name = text;\r\n                skip<node_name_pred, Flags>(text);\r\n                if (text == name)\r\n                    RAPIDXML_PARSE_ERROR(\"expected PI target\", text);\r\n                pi->name(name, text - name);\r\n                \r\n                // Skip whitespace between pi target and pi\r\n                skip<whitespace_pred, Flags>(text);\r\n\r\n                // Remember start of pi\r\n                Ch *value = text;\r\n                \r\n                // Skip to '?>'\r\n                while (text[0] != Ch('?') || text[1] != Ch('>'))\r\n                {\r\n                    if (*text == Ch('\\0'))\r\n                        RAPIDXML_PARSE_ERROR(\"unexpected end of data\", text);\r\n                    ++text;\r\n                }\r\n\r\n                // Set pi value (verbatim, no entity expansion or whitespace normalization)\r\n                pi->value(value, text - value);     \r\n                \r\n                // Place zero terminator after name and value\r\n                if (!(Flags & parse_no_string_terminators))\r\n                {\r\n                    pi->name()[pi->name_size()] = Ch('\\0');\r\n                    pi->value()[pi->value_size()] = Ch('\\0');\r\n                }\r\n                \r\n                text += 2;                          // Skip '?>'\r\n                return pi;\r\n            }\r\n            else\r\n            {\r\n                // Skip to '?>'\r\n                while (text[0] != Ch('?') || text[1] != Ch('>'))\r\n                {\r\n                    if (*text == Ch('\\0'))\r\n                        RAPIDXML_PARSE_ERROR(\"unexpected end of data\", text);\r\n                    ++text;\r\n                }\r\n                text += 2;    // Skip '?>'\r\n                return 0;\r\n            }\r\n        }\r\n\r\n        // Parse and append data\r\n        // Return character that ends data.\r\n        // This is necessary because this character might have been overwritten by a terminating 0\r\n        template<int Flags>\r\n        Ch parse_and_append_data(xml_node<Ch> *node, Ch *&text, Ch *contents_start)\r\n        {\r\n            // Backup to contents start if whitespace trimming is disabled\r\n            if (!(Flags & parse_trim_whitespace))\r\n                text = contents_start;     \r\n            \r\n            // Skip until end of data\r\n            Ch *value = text, *end;\r\n            if (Flags & parse_normalize_whitespace)\r\n                end = skip_and_expand_character_refs<text_pred, text_pure_with_ws_pred, Flags>(text);   \r\n            else\r\n                end = skip_and_expand_character_refs<text_pred, text_pure_no_ws_pred, Flags>(text);\r\n\r\n            // Trim trailing whitespace if flag is set; leading was already trimmed by whitespace skip after >\r\n            if (Flags & parse_trim_whitespace)\r\n            {\r\n                if (Flags & parse_normalize_whitespace)\r\n                {\r\n                    // Whitespace is already condensed to single space characters by skipping function, so just trim 1 char off the end\r\n                    if (*(end - 1) == Ch(' '))\r\n                        --end;\r\n                }\r\n                else\r\n                {\r\n                    // Backup until non-whitespace character is found\r\n                    while (whitespace_pred::test(*(end - 1)))\r\n                        --end;\r\n                }\r\n            }\r\n            \r\n            // If characters are still left between end and value (this test is only necessary if normalization is enabled)\r\n            // Create new data node\r\n            if (!(Flags & parse_no_data_nodes))\r\n            {\r\n                xml_node<Ch> *data = this->allocate_node(node_data);\r\n                data->value(value, end - value);\r\n                node->append_node(data);\r\n            }\r\n\r\n            // Add data to parent node if no data exists yet\r\n            if (!(Flags & parse_no_element_values)) \r\n                if (*node->value() == Ch('\\0'))\r\n                    node->value(value, end - value);\r\n\r\n            // Place zero terminator after value\r\n            if (!(Flags & parse_no_string_terminators))\r\n            {\r\n                Ch ch = *text;\r\n                *end = Ch('\\0');\r\n                return ch;      // Return character that ends data; this is required because zero terminator overwritten it\r\n            }\r\n\r\n            // Return character that ends data\r\n            return *text;\r\n        }\r\n\r\n        // Parse CDATA\r\n        template<int Flags>\r\n        xml_node<Ch> *parse_cdata(Ch *&text)\r\n        {\r\n            // If CDATA is disabled\r\n            if (Flags & parse_no_data_nodes)\r\n            {\r\n                // Skip until end of cdata\r\n                while (text[0] != Ch(']') || text[1] != Ch(']') || text[2] != Ch('>'))\r\n                {\r\n                    if (!text[0])\r\n                        RAPIDXML_PARSE_ERROR(\"unexpected end of data\", text);\r\n                    ++text;\r\n                }\r\n                text += 3;      // Skip ]]>\r\n                return 0;       // Do not produce CDATA node\r\n            }\r\n\r\n            // Skip until end of cdata\r\n            Ch *value = text;\r\n            while (text[0] != Ch(']') || text[1] != Ch(']') || text[2] != Ch('>'))\r\n            {\r\n                if (!text[0])\r\n                    RAPIDXML_PARSE_ERROR(\"unexpected end of data\", text);\r\n                ++text;\r\n            }\r\n\r\n            // Create new cdata node\r\n            xml_node<Ch> *cdata = this->allocate_node(node_cdata);\r\n            cdata->value(value, text - value);\r\n\r\n            // Place zero terminator after value\r\n            if (!(Flags & parse_no_string_terminators))\r\n                *text = Ch('\\0');\r\n\r\n            text += 3;      // Skip ]]>\r\n            return cdata;\r\n        }\r\n        \r\n        // Parse element node\r\n        template<int Flags>\r\n        xml_node<Ch> *parse_element(Ch *&text)\r\n        {\r\n            // Create element node\r\n            xml_node<Ch> *element = this->allocate_node(node_element);\r\n\r\n            // Extract element name\r\n            Ch *name = text;\r\n            skip<node_name_pred, Flags>(text);\r\n            if (text == name)\r\n                RAPIDXML_PARSE_ERROR(\"expected element name\", text);\r\n            element->name(name, text - name);\r\n            \r\n            // Skip whitespace between element name and attributes or >\r\n            skip<whitespace_pred, Flags>(text);\r\n\r\n            // Parse attributes, if any\r\n            parse_node_attributes<Flags>(text, element);\r\n\r\n            // Determine ending type\r\n            if (*text == Ch('>'))\r\n            {\r\n                ++text;\r\n                parse_node_contents<Flags>(text, element);\r\n            }\r\n            else if (*text == Ch('/'))\r\n            {\r\n                ++text;\r\n                if (*text != Ch('>'))\r\n                    RAPIDXML_PARSE_ERROR(\"expected >\", text);\r\n                ++text;\r\n            }\r\n            else\r\n                RAPIDXML_PARSE_ERROR(\"expected >\", text);\r\n\r\n            // Place zero terminator after name\r\n            if (!(Flags & parse_no_string_terminators))\r\n                element->name()[element->name_size()] = Ch('\\0');\r\n\r\n            // Return parsed element\r\n            return element;\r\n        }\r\n\r\n        // Determine node type, and parse it\r\n        template<int Flags>\r\n        xml_node<Ch> *parse_node(Ch *&text)\r\n        {\r\n            // Parse proper node type\r\n            switch (text[0])\r\n            {\r\n\r\n            // <...\r\n            default: \r\n                // Parse and append element node\r\n                return parse_element<Flags>(text);\r\n\r\n            // <?...\r\n            case Ch('?'): \r\n                ++text;     // Skip ?\r\n                if ((text[0] == Ch('x') || text[0] == Ch('X')) &&\r\n                    (text[1] == Ch('m') || text[1] == Ch('M')) && \r\n                    (text[2] == Ch('l') || text[2] == Ch('L')) &&\r\n                    whitespace_pred::test(text[3]))\r\n                {\r\n                    // '<?xml ' - xml declaration\r\n                    text += 4;      // Skip 'xml '\r\n                    return parse_xml_declaration<Flags>(text);\r\n                }\r\n                else\r\n                {\r\n                    // Parse PI\r\n                    return parse_pi<Flags>(text);\r\n                }\r\n            \r\n            // <!...\r\n            case Ch('!'): \r\n\r\n                // Parse proper subset of <! node\r\n                switch (text[1])    \r\n                {\r\n                \r\n                // <!-\r\n                case Ch('-'):\r\n                    if (text[2] == Ch('-'))\r\n                    {\r\n                        // '<!--' - xml comment\r\n                        text += 3;     // Skip '!--'\r\n                        return parse_comment<Flags>(text);\r\n                    }\r\n                    break;\r\n\r\n                // <![\r\n                case Ch('['):\r\n                    if (text[2] == Ch('C') && text[3] == Ch('D') && text[4] == Ch('A') && \r\n                        text[5] == Ch('T') && text[6] == Ch('A') && text[7] == Ch('['))\r\n                    {\r\n                        // '<![CDATA[' - cdata\r\n                        text += 8;     // Skip '![CDATA['\r\n                        return parse_cdata<Flags>(text);\r\n                    }\r\n                    break;\r\n\r\n                // <!D\r\n                case Ch('D'):\r\n                    if (text[2] == Ch('O') && text[3] == Ch('C') && text[4] == Ch('T') && \r\n                        text[5] == Ch('Y') && text[6] == Ch('P') && text[7] == Ch('E') && \r\n                        whitespace_pred::test(text[8]))\r\n                    {\r\n                        // '<!DOCTYPE ' - doctype\r\n                        text += 9;      // skip '!DOCTYPE '\r\n                        return parse_doctype<Flags>(text);\r\n                    }\r\n\r\n                }   // switch\r\n\r\n                // Attempt to skip other, unrecognized node types starting with <!\r\n                ++text;     // Skip !\r\n                while (*text != Ch('>'))\r\n                {\r\n                    if (*text == 0)\r\n                        RAPIDXML_PARSE_ERROR(\"unexpected end of data\", text);\r\n                    ++text;\r\n                }\r\n                ++text;     // Skip '>'\r\n                return 0;   // No node recognized\r\n\r\n            }\r\n        }\r\n\r\n        // Parse contents of the node - children, data etc.\r\n        template<int Flags>\r\n        void parse_node_contents(Ch *&text, xml_node<Ch> *node)\r\n        {\r\n            // For all children and text\r\n            while (1)\r\n            {\r\n                // Skip whitespace between > and node contents\r\n                Ch *contents_start = text;      // Store start of node contents before whitespace is skipped\r\n                skip<whitespace_pred, Flags>(text);\r\n                Ch next_char = *text;\r\n\r\n            // After data nodes, instead of continuing the loop, control jumps here.\r\n            // This is because zero termination inside parse_and_append_data() function\r\n            // would wreak havoc with the above code.\r\n            // Also, skipping whitespace after data nodes is unnecessary.\r\n            after_data_node:    \r\n                \r\n                // Determine what comes next: node closing, child node, data node, or 0?\r\n                switch (next_char)\r\n                {\r\n                \r\n                // Node closing or child node\r\n                case Ch('<'):\r\n                    if (text[1] == Ch('/'))\r\n                    {\r\n                        // Node closing\r\n                        text += 2;      // Skip '</'\r\n                        if (Flags & parse_validate_closing_tags)\r\n                        {\r\n                            // Skip and validate closing tag name\r\n                            Ch *closing_name = text;\r\n                            skip<node_name_pred, Flags>(text);\r\n                            if (!internal::compare(node->name(), node->name_size(), closing_name, text - closing_name, true))\r\n                                RAPIDXML_PARSE_ERROR(\"invalid closing tag name\", text);\r\n                        }\r\n                        else\r\n                        {\r\n                            // No validation, just skip name\r\n                            skip<node_name_pred, Flags>(text);\r\n                        }\r\n                        // Skip remaining whitespace after node name\r\n                        skip<whitespace_pred, Flags>(text);\r\n                        if (*text != Ch('>'))\r\n                            RAPIDXML_PARSE_ERROR(\"expected >\", text);\r\n                        ++text;     // Skip '>'\r\n                        return;     // Node closed, finished parsing contents\r\n                    }\r\n                    else\r\n                    {\r\n                        // Child node\r\n                        ++text;     // Skip '<'\r\n                        if (xml_node<Ch> *child = parse_node<Flags>(text))\r\n                            node->append_node(child);\r\n                    }\r\n                    break;\r\n\r\n                // End of data - error\r\n                case Ch('\\0'):\r\n                    RAPIDXML_PARSE_ERROR(\"unexpected end of data\", text);\r\n\r\n                // Data node\r\n                default:\r\n                    next_char = parse_and_append_data<Flags>(node, text, contents_start);\r\n                    goto after_data_node;   // Bypass regular processing after data nodes\r\n\r\n                }\r\n            }\r\n        }\r\n        \r\n        // Parse XML attributes of the node\r\n        template<int Flags>\r\n        void parse_node_attributes(Ch *&text, xml_node<Ch> *node)\r\n        {\r\n            // For all attributes \r\n            while (attribute_name_pred::test(*text))\r\n            {\r\n                // Extract attribute name\r\n                Ch *name = text;\r\n                ++text;     // Skip first character of attribute name\r\n                skip<attribute_name_pred, Flags>(text);\r\n                if (text == name)\r\n                    RAPIDXML_PARSE_ERROR(\"expected attribute name\", name);\r\n\r\n                // Create new attribute\r\n                xml_attribute<Ch> *attribute = this->allocate_attribute();\r\n                attribute->name(name, text - name);\r\n                node->append_attribute(attribute);\r\n\r\n                // Skip whitespace after attribute name\r\n                skip<whitespace_pred, Flags>(text);\r\n\r\n                // Skip =\r\n                if (*text != Ch('='))\r\n                    RAPIDXML_PARSE_ERROR(\"expected =\", text);\r\n                ++text;\r\n\r\n                // Add terminating zero after name\r\n                if (!(Flags & parse_no_string_terminators))\r\n                    attribute->name()[attribute->name_size()] = 0;\r\n\r\n                // Skip whitespace after =\r\n                skip<whitespace_pred, Flags>(text);\r\n\r\n                // Skip quote and remember if it was ' or \"\r\n                Ch quote = *text;\r\n                if (quote != Ch('\\'') && quote != Ch('\"'))\r\n                    RAPIDXML_PARSE_ERROR(\"expected ' or \\\"\", text);\r\n                ++text;\r\n\r\n                // Extract attribute value and expand char refs in it\r\n                Ch *value = text, *end;\r\n                const int AttFlags = Flags & ~parse_normalize_whitespace;   // No whitespace normalization in attributes\r\n                if (quote == Ch('\\''))\r\n                    end = skip_and_expand_character_refs<attribute_value_pred<Ch('\\'')>, attribute_value_pure_pred<Ch('\\'')>, AttFlags>(text);\r\n                else\r\n                    end = skip_and_expand_character_refs<attribute_value_pred<Ch('\"')>, attribute_value_pure_pred<Ch('\"')>, AttFlags>(text);\r\n                \r\n                // Set attribute value\r\n                attribute->value(value, end - value);\r\n                \r\n                // Make sure that end quote is present\r\n                if (*text != quote)\r\n                    RAPIDXML_PARSE_ERROR(\"expected ' or \\\"\", text);\r\n                ++text;     // Skip quote\r\n\r\n                // Add terminating zero after value\r\n                if (!(Flags & parse_no_string_terminators))\r\n                    attribute->value()[attribute->value_size()] = 0;\r\n\r\n                // Skip whitespace after attribute value\r\n                skip<whitespace_pred, Flags>(text);\r\n            }\r\n        }\r\n\r\n    };\r\n\r\n    //! \\cond internal\r\n    namespace internal\r\n    {\r\n\r\n        // Whitespace (space \\n \\r \\t)\r\n        template<int Dummy>\r\n        const unsigned char lookup_tables<Dummy>::lookup_whitespace[256] = \r\n        {\r\n          // 0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F\r\n             0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  1,  0,  0,  1,  0,  0,  // 0\r\n             0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  // 1\r\n             1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  // 2\r\n             0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  // 3\r\n             0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  // 4\r\n             0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  // 5\r\n             0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  // 6\r\n             0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  // 7\r\n             0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  // 8\r\n             0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  // 9\r\n             0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  // A\r\n             0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  // B\r\n             0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  // C\r\n             0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  // D\r\n             0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  // E\r\n             0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0   // F\r\n        };\r\n\r\n        // Node name (anything but space \\n \\r \\t / > ? \\0)\r\n        template<int Dummy>\r\n        const unsigned char lookup_tables<Dummy>::lookup_node_name[256] = \r\n        {\r\n          // 0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F\r\n             0,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  1,  1,  0,  1,  1,  // 0\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 1\r\n             0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  // 2\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  // 3\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 4\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 5\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 6\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 7\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 8\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 9\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // A\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // B\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // C\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // D\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // E\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1   // F\r\n        };\r\n\r\n        // Text (i.e. PCDATA) (anything but < \\0)\r\n        template<int Dummy>\r\n        const unsigned char lookup_tables<Dummy>::lookup_text[256] = \r\n        {\r\n          // 0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F\r\n             0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 0\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 1\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 2\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  1,  1,  1,  // 3\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 4\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 5\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 6\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 7\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 8\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 9\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // A\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // B\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // C\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // D\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // E\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1   // F\r\n        };\r\n\r\n        // Text (i.e. PCDATA) that does not require processing when ws normalization is disabled \r\n        // (anything but < \\0 &)\r\n        template<int Dummy>\r\n        const unsigned char lookup_tables<Dummy>::lookup_text_pure_no_ws[256] = \r\n        {\r\n          // 0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F\r\n             0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 0\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 1\r\n             1,  1,  1,  1,  1,  1,  0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 2\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  1,  1,  1,  // 3\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 4\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 5\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 6\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 7\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 8\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 9\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // A\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // B\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // C\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // D\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // E\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1   // F\r\n        };\r\n\r\n        // Text (i.e. PCDATA) that does not require processing when ws normalizationis is enabled\r\n        // (anything but < \\0 & space \\n \\r \\t)\r\n        template<int Dummy>\r\n        const unsigned char lookup_tables<Dummy>::lookup_text_pure_with_ws[256] = \r\n        {\r\n          // 0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F\r\n             0,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  1,  1,  0,  1,  1,  // 0\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 1\r\n             0,  1,  1,  1,  1,  1,  0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 2\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  1,  1,  1,  // 3\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 4\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 5\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 6\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 7\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 8\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 9\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // A\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // B\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // C\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // D\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // E\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1   // F\r\n        };\r\n\r\n        // Attribute name (anything but space \\n \\r \\t / < > = ? ! \\0)\r\n        template<int Dummy>\r\n        const unsigned char lookup_tables<Dummy>::lookup_attribute_name[256] = \r\n        {\r\n          // 0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F\r\n             0,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  1,  1,  0,  1,  1,  // 0\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 1\r\n             0,  0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  // 2\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  // 3\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 4\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 5\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 6\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 7\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 8\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 9\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // A\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // B\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // C\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // D\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // E\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1   // F\r\n        };\r\n\r\n        // Attribute data with single quote (anything but ' \\0)\r\n        template<int Dummy>\r\n        const unsigned char lookup_tables<Dummy>::lookup_attribute_data_1[256] = \r\n        {\r\n          // 0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F\r\n             0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 0\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 1\r\n             1,  1,  1,  1,  1,  1,  1,  0,  1,  1,  1,  1,  1,  1,  1,  1,  // 2\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 3\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 4\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 5\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 6\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 7\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 8\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 9\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // A\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // B\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // C\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // D\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // E\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1   // F\r\n        };\r\n\r\n        // Attribute data with single quote that does not require processing (anything but ' \\0 &)\r\n        template<int Dummy>\r\n        const unsigned char lookup_tables<Dummy>::lookup_attribute_data_1_pure[256] = \r\n        {\r\n          // 0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F\r\n             0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 0\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 1\r\n             1,  1,  1,  1,  1,  1,  0,  0,  1,  1,  1,  1,  1,  1,  1,  1,  // 2\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 3\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 4\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 5\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 6\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 7\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 8\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 9\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // A\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // B\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // C\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // D\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // E\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1   // F\r\n        };\r\n\r\n        // Attribute data with double quote (anything but \" \\0)\r\n        template<int Dummy>\r\n        const unsigned char lookup_tables<Dummy>::lookup_attribute_data_2[256] = \r\n        {\r\n          // 0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F\r\n             0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 0\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 1\r\n             1,  1,  0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 2\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 3\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 4\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 5\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 6\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 7\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 8\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 9\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // A\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // B\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // C\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // D\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // E\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1   // F\r\n        };\r\n\r\n        // Attribute data with double quote that does not require processing (anything but \" \\0 &)\r\n        template<int Dummy>\r\n        const unsigned char lookup_tables<Dummy>::lookup_attribute_data_2_pure[256] = \r\n        {\r\n          // 0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F\r\n             0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 0\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 1\r\n             1,  1,  0,  1,  1,  1,  0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 2\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 3\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 4\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 5\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 6\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 7\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 8\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // 9\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // A\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // B\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // C\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // D\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  // E\r\n             1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1   // F\r\n        };\r\n\r\n        // Digits (dec and hex, 255 denotes end of numeric character reference)\r\n        template<int Dummy>\r\n        const unsigned char lookup_tables<Dummy>::lookup_digits[256] = \r\n        {\r\n          // 0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F\r\n           255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  // 0\r\n           255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  // 1\r\n           255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  // 2\r\n             0,  1,  2,  3,  4,  5,  6,  7,  8,  9,255,255,255,255,255,255,  // 3\r\n           255, 10, 11, 12, 13, 14, 15,255,255,255,255,255,255,255,255,255,  // 4\r\n           255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  // 5\r\n           255, 10, 11, 12, 13, 14, 15,255,255,255,255,255,255,255,255,255,  // 6\r\n           255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  // 7\r\n           255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  // 8\r\n           255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  // 9\r\n           255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  // A\r\n           255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  // B\r\n           255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  // C\r\n           255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  // D\r\n           255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  // E\r\n           255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255   // F\r\n        };\r\n    \r\n        // Upper case conversion\r\n        template<int Dummy>\r\n        const unsigned char lookup_tables<Dummy>::lookup_upcase[256] = \r\n        {\r\n          // 0,  1,  2,  3,  4,  5,  6,  7,  8,  9,  A   B   C   D   E   F\r\n           0,  1,  2,  3,  4,  5,  6,  7,  8,  9,  10, 11, 12, 13, 14, 15,   // 0\r\n           16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,   // 1\r\n           32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,   // 2\r\n           48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,   // 3\r\n           64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,   // 4\r\n           80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,   // 5\r\n           96, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,   // 6\r\n           80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 123,124,125,126,127,  // 7\r\n           128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,  // 8\r\n           144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,  // 9\r\n           160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,  // A\r\n           176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,  // B\r\n           192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,  // C\r\n           208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,  // D\r\n           224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,  // E\r\n           240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255   // F\r\n        };\r\n    }\r\n    //! \\endcond\r\n\r\n}\r\n\r\n// Undefine internal macros\r\n#undef RAPIDXML_PARSE_ERROR\r\n\r\n// On MSVC, restore warnings state\r\n#ifdef _MSC_VER\r\n    #pragma warning(pop)\r\n#endif\r\n\r\n#endif\r\n"
  },
  {
    "path": "Projects/Libraries/CSBase/Source/rapidxml/rapidxml_iterators.hpp",
    "content": "#ifndef RAPIDXML_ITERATORS_HPP_INCLUDED\r\n#define RAPIDXML_ITERATORS_HPP_INCLUDED\r\n\r\n// Copyright (C) 2006, 2009 Marcin Kalicinski\r\n// Version 1.13\r\n// Revision $DateTime: 2009/05/13 01:46:17 $\r\n//! \\file rapidxml_iterators.hpp This file contains rapidxml iterators\r\n\r\n#include \"rapidxml.hpp\"\r\n\r\nnamespace rapidxml\r\n{\r\n\r\n    //! Iterator of child nodes of xml_node\r\n    template<class Ch>\r\n    class node_iterator\r\n    {\r\n    \r\n    public:\r\n\r\n        typedef typename xml_node<Ch> value_type;\r\n        typedef typename xml_node<Ch> &reference;\r\n        typedef typename xml_node<Ch> *pointer;\r\n        typedef std::ptrdiff_t difference_type;\r\n        typedef std::bidirectional_iterator_tag iterator_category;\r\n        \r\n        node_iterator()\r\n            : m_node(0)\r\n        {\r\n        }\r\n\r\n        node_iterator(xml_node<Ch> *node)\r\n            : m_node(node->first_node())\r\n        {\r\n        }\r\n        \r\n        reference operator *() const\r\n        {\r\n            assert(m_node);\r\n            return *m_node;\r\n        }\r\n\r\n        pointer operator->() const\r\n        {\r\n            assert(m_node);\r\n            return m_node;\r\n        }\r\n\r\n        node_iterator& operator++()\r\n        {\r\n            assert(m_node);\r\n            m_node = m_node->next_sibling();\r\n            return *this;\r\n        }\r\n\r\n        node_iterator operator++(int)\r\n        {\r\n            node_iterator tmp = *this;\r\n            ++this;\r\n            return tmp;\r\n        }\r\n\r\n        node_iterator& operator--()\r\n        {\r\n            assert(m_node && m_node->previous_sibling());\r\n            m_node = m_node->previous_sibling();\r\n            return *this;\r\n        }\r\n\r\n        node_iterator operator--(int)\r\n        {\r\n            node_iterator tmp = *this;\r\n            ++this;\r\n            return tmp;\r\n        }\r\n\r\n        bool operator ==(const node_iterator<Ch> &rhs)\r\n        {\r\n            return m_node == rhs.m_node;\r\n        }\r\n\r\n        bool operator !=(const node_iterator<Ch> &rhs)\r\n        {\r\n            return m_node != rhs.m_node;\r\n        }\r\n\r\n    private:\r\n\r\n        xml_node<Ch> *m_node;\r\n\r\n    };\r\n\r\n    //! Iterator of child attributes of xml_node\r\n    template<class Ch>\r\n    class attribute_iterator\r\n    {\r\n    \r\n    public:\r\n\r\n        typedef typename xml_attribute<Ch> value_type;\r\n        typedef typename xml_attribute<Ch> &reference;\r\n        typedef typename xml_attribute<Ch> *pointer;\r\n        typedef std::ptrdiff_t difference_type;\r\n        typedef std::bidirectional_iterator_tag iterator_category;\r\n        \r\n        attribute_iterator()\r\n            : m_attribute(0)\r\n        {\r\n        }\r\n\r\n        attribute_iterator(xml_node<Ch> *node)\r\n            : m_attribute(node->first_attribute())\r\n        {\r\n        }\r\n        \r\n        reference operator *() const\r\n        {\r\n            assert(m_attribute);\r\n            return *m_attribute;\r\n        }\r\n\r\n        pointer operator->() const\r\n        {\r\n            assert(m_attribute);\r\n            return m_attribute;\r\n        }\r\n\r\n        attribute_iterator& operator++()\r\n        {\r\n            assert(m_attribute);\r\n            m_attribute = m_attribute->next_attribute();\r\n            return *this;\r\n        }\r\n\r\n        attribute_iterator operator++(int)\r\n        {\r\n            attribute_iterator tmp = *this;\r\n            ++this;\r\n            return tmp;\r\n        }\r\n\r\n        attribute_iterator& operator--()\r\n        {\r\n            assert(m_attribute && m_attribute->previous_attribute());\r\n            m_attribute = m_attribute->previous_attribute();\r\n            return *this;\r\n        }\r\n\r\n        attribute_iterator operator--(int)\r\n        {\r\n            attribute_iterator tmp = *this;\r\n            ++this;\r\n            return tmp;\r\n        }\r\n\r\n        bool operator ==(const attribute_iterator<Ch> &rhs)\r\n        {\r\n            return m_attribute == rhs.m_attribute;\r\n        }\r\n\r\n        bool operator !=(const attribute_iterator<Ch> &rhs)\r\n        {\r\n            return m_attribute != rhs.m_attribute;\r\n        }\r\n\r\n    private:\r\n\r\n        xml_attribute<Ch> *m_attribute;\r\n\r\n    };\r\n\r\n}\r\n\r\n#endif\r\n"
  },
  {
    "path": "Projects/Libraries/CSBase/Source/rapidxml/rapidxml_print.hpp",
    "content": "#ifndef RAPIDXML_PRINT_HPP_INCLUDED\r\n#define RAPIDXML_PRINT_HPP_INCLUDED\r\n\r\n// Copyright (C) 2006, 2009 Marcin Kalicinski\r\n// Version 1.13\r\n// Revision $DateTime: 2009/05/13 01:46:17 $\r\n//! \\file rapidxml_print.hpp This file contains rapidxml printer implementation\r\n\r\n#include \"rapidxml.hpp\"\r\n\r\n// Only include streams if not disabled\r\n#ifndef RAPIDXML_NO_STREAMS\r\n    #include <ostream>\r\n    #include <iterator>\r\n#endif\r\n\r\nnamespace rapidxml\r\n{\r\n\r\n    ///////////////////////////////////////////////////////////////////////\r\n    // Printing flags\r\n\r\n    const int print_no_indenting = 0x1;   //!< Printer flag instructing the printer to suppress indenting of XML. See print() function.\r\n\r\n    ///////////////////////////////////////////////////////////////////////\r\n    // Internal\r\n\r\n    //! \\cond internal\r\n    namespace internal\r\n    {\r\n        ///////////////////////////////////////////////////////////////////////////\r\n        // Function declarations\r\n        \r\n        template<class OutIt, class Ch>\r\n        inline OutIt copy_chars(const Ch *begin, const Ch *end, OutIt out);\r\n        \r\n        template<class OutIt, class Ch>\r\n        inline OutIt copy_and_expand_chars(const Ch *begin, const Ch *end, Ch noexpand, OutIt out);\r\n        \r\n        template<class OutIt, class Ch>\r\n        inline OutIt fill_chars(OutIt out, int n, Ch ch);\r\n        \r\n        template<class Ch, Ch ch>\r\n        inline bool find_char(const Ch *begin, const Ch *end);\r\n        \r\n        template<class OutIt, class Ch>\r\n        inline OutIt print_node(OutIt out, const xml_node<Ch> *node, int flags, int indent);\r\n        \r\n        template<class OutIt, class Ch>\r\n        inline OutIt print_children(OutIt out, const xml_node<Ch> *node, int flags, int indent);\r\n        \r\n        template<class OutIt, class Ch>\r\n        inline OutIt print_attributes(OutIt out, const xml_node<Ch> *node, int flags);\r\n        \r\n        template<class OutIt, class Ch>\r\n        inline OutIt print_data_node(OutIt out, const xml_node<Ch> *node, int flags, int indent);\r\n        \r\n        template<class OutIt, class Ch>\r\n        inline OutIt print_cdata_node(OutIt out, const xml_node<Ch> *node, int flags, int indent);\r\n        \r\n        template<class OutIt, class Ch>\r\n        inline OutIt print_element_node(OutIt out, const xml_node<Ch> *node, int flags, int indent);\r\n        \r\n        template<class OutIt, class Ch>\r\n        inline OutIt print_declaration_node(OutIt out, const xml_node<Ch> *node, int flags, int indent);\r\n        \r\n        template<class OutIt, class Ch>\r\n        inline OutIt print_comment_node(OutIt out, const xml_node<Ch> *node, int flags, int indent);\r\n        \r\n        template<class OutIt, class Ch>\r\n        inline OutIt print_doctype_node(OutIt out, const xml_node<Ch> *node, int flags, int indent);\r\n        \r\n        template<class OutIt, class Ch>\r\n        inline OutIt print_pi_node(OutIt out, const xml_node<Ch> *node, int flags, int indent);\r\n        \r\n        ///////////////////////////////////////////////////////////////////////////\r\n        // Internal character operations\r\n    \r\n        // Copy characters from given range to given output iterator\r\n        template<class OutIt, class Ch>\r\n        inline OutIt copy_chars(const Ch *begin, const Ch *end, OutIt out)\r\n        {\r\n            while (begin != end)\r\n                *out++ = *begin++;\r\n            return out;\r\n        }\r\n        \r\n        // Copy characters from given range to given output iterator and expand\r\n        // characters into references (&lt; &gt; &apos; &quot; &amp;)\r\n        template<class OutIt, class Ch>\r\n        inline OutIt copy_and_expand_chars(const Ch *begin, const Ch *end, Ch noexpand, OutIt out)\r\n        {\r\n            while (begin != end)\r\n            {\r\n                if (*begin == noexpand)\r\n                {\r\n                    *out++ = *begin;    // No expansion, copy character\r\n                }\r\n                else\r\n                {\r\n                    switch (*begin)\r\n                    {\r\n                    case Ch('<'):\r\n                        *out++ = Ch('&'); *out++ = Ch('l'); *out++ = Ch('t'); *out++ = Ch(';');\r\n                        break;\r\n                    case Ch('>'): \r\n                        *out++ = Ch('&'); *out++ = Ch('g'); *out++ = Ch('t'); *out++ = Ch(';');\r\n                        break;\r\n                    case Ch('\\''): \r\n                        *out++ = Ch('&'); *out++ = Ch('a'); *out++ = Ch('p'); *out++ = Ch('o'); *out++ = Ch('s'); *out++ = Ch(';');\r\n                        break;\r\n                    case Ch('\"'): \r\n                        *out++ = Ch('&'); *out++ = Ch('q'); *out++ = Ch('u'); *out++ = Ch('o'); *out++ = Ch('t'); *out++ = Ch(';');\r\n                        break;\r\n                    case Ch('&'): \r\n                        *out++ = Ch('&'); *out++ = Ch('a'); *out++ = Ch('m'); *out++ = Ch('p'); *out++ = Ch(';'); \r\n                        break;\r\n                    default:\r\n                        *out++ = *begin;    // No expansion, copy character\r\n                    }\r\n                }\r\n                ++begin;    // Step to next character\r\n            }\r\n            return out;\r\n        }\r\n\r\n        // Fill given output iterator with repetitions of the same character\r\n        template<class OutIt, class Ch>\r\n        inline OutIt fill_chars(OutIt out, int n, Ch ch)\r\n        {\r\n            for (int i = 0; i < n; ++i)\r\n                *out++ = ch;\r\n            return out;\r\n        }\r\n\r\n        // Find character\r\n        template<class Ch, Ch ch>\r\n        inline bool find_char(const Ch *begin, const Ch *end)\r\n        {\r\n            while (begin != end)\r\n                if (*begin++ == ch)\r\n                    return true;\r\n            return false;\r\n        }\r\n\r\n        ///////////////////////////////////////////////////////////////////////////\r\n        // Internal printing operations\r\n    \r\n        // Print node\r\n        template<class OutIt, class Ch>\r\n        inline OutIt print_node(OutIt out, const xml_node<Ch> *node, int flags, int indent)\r\n        {\r\n            // Print proper node type\r\n            switch (node->type())\r\n            {\r\n\r\n            // Document\r\n            case node_document:\r\n                out = print_children(out, node, flags, indent);\r\n                break;\r\n\r\n            // Element\r\n            case node_element:\r\n                out = print_element_node(out, node, flags, indent);\r\n                break;\r\n            \r\n            // Data\r\n            case node_data:\r\n                out = print_data_node(out, node, flags, indent);\r\n                break;\r\n            \r\n            // CDATA\r\n            case node_cdata:\r\n                out = print_cdata_node(out, node, flags, indent);\r\n                break;\r\n\r\n            // Declaration\r\n            case node_declaration:\r\n                out = print_declaration_node(out, node, flags, indent);\r\n                break;\r\n\r\n            // Comment\r\n            case node_comment:\r\n                out = print_comment_node(out, node, flags, indent);\r\n                break;\r\n            \r\n            // Doctype\r\n            case node_doctype:\r\n                out = print_doctype_node(out, node, flags, indent);\r\n                break;\r\n\r\n            // Pi\r\n            case node_pi:\r\n                out = print_pi_node(out, node, flags, indent);\r\n                break;\r\n\r\n                // Unknown\r\n            default:\r\n                assert(0);\r\n                break;\r\n            }\r\n            \r\n            // If indenting not disabled, add line break after node\r\n            if (!(flags & print_no_indenting))\r\n                *out = Ch('\\n'), ++out;\r\n\r\n            // Return modified iterator\r\n            return out;\r\n        }\r\n        \r\n        // Print children of the node                               \r\n        template<class OutIt, class Ch>\r\n        inline OutIt print_children(OutIt out, const xml_node<Ch> *node, int flags, int indent)\r\n        {\r\n            for (xml_node<Ch> *child = node->first_node(); child; child = child->next_sibling())\r\n                out = print_node(out, child, flags, indent);\r\n            return out;\r\n        }\r\n\r\n        // Print attributes of the node\r\n        template<class OutIt, class Ch>\r\n        inline OutIt print_attributes(OutIt out, const xml_node<Ch> *node, int flags)\r\n        {\r\n            for (xml_attribute<Ch> *attribute = node->first_attribute(); attribute; attribute = attribute->next_attribute())\r\n            {\r\n                if (attribute->name() && attribute->value())\r\n                {\r\n                    // Print attribute name\r\n                    *out = Ch(' '), ++out;\r\n                    out = copy_chars(attribute->name(), attribute->name() + attribute->name_size(), out);\r\n                    *out = Ch('='), ++out;\r\n                    // Print attribute value using appropriate quote type\r\n                    if (find_char<Ch, Ch('\"')>(attribute->value(), attribute->value() + attribute->value_size()))\r\n                    {\r\n                        *out = Ch('\\''), ++out;\r\n                        out = copy_and_expand_chars(attribute->value(), attribute->value() + attribute->value_size(), Ch('\"'), out);\r\n                        *out = Ch('\\''), ++out;\r\n                    }\r\n                    else\r\n                    {\r\n                        *out = Ch('\"'), ++out;\r\n                        out = copy_and_expand_chars(attribute->value(), attribute->value() + attribute->value_size(), Ch('\\''), out);\r\n                        *out = Ch('\"'), ++out;\r\n                    }\r\n                }\r\n            }\r\n            return out;\r\n        }\r\n\r\n        // Print data node\r\n        template<class OutIt, class Ch>\r\n        inline OutIt print_data_node(OutIt out, const xml_node<Ch> *node, int flags, int indent)\r\n        {\r\n            assert(node->type() == node_data);\r\n            if (!(flags & print_no_indenting))\r\n                out = fill_chars(out, indent, Ch('\\t'));\r\n            out = copy_and_expand_chars(node->value(), node->value() + node->value_size(), Ch(0), out);\r\n            return out;\r\n        }\r\n\r\n        // Print data node\r\n        template<class OutIt, class Ch>\r\n        inline OutIt print_cdata_node(OutIt out, const xml_node<Ch> *node, int flags, int indent)\r\n        {\r\n            assert(node->type() == node_cdata);\r\n            if (!(flags & print_no_indenting))\r\n                out = fill_chars(out, indent, Ch('\\t'));\r\n            *out = Ch('<'); ++out;\r\n            *out = Ch('!'); ++out;\r\n            *out = Ch('['); ++out;\r\n            *out = Ch('C'); ++out;\r\n            *out = Ch('D'); ++out;\r\n            *out = Ch('A'); ++out;\r\n            *out = Ch('T'); ++out;\r\n            *out = Ch('A'); ++out;\r\n            *out = Ch('['); ++out;\r\n            out = copy_chars(node->value(), node->value() + node->value_size(), out);\r\n            *out = Ch(']'); ++out;\r\n            *out = Ch(']'); ++out;\r\n            *out = Ch('>'); ++out;\r\n            return out;\r\n        }\r\n\r\n        // Print element node\r\n        template<class OutIt, class Ch>\r\n        inline OutIt print_element_node(OutIt out, const xml_node<Ch> *node, int flags, int indent)\r\n        {\r\n            assert(node->type() == node_element);\r\n\r\n            // Print element name and attributes, if any\r\n            if (!(flags & print_no_indenting))\r\n                out = fill_chars(out, indent, Ch('\\t'));\r\n            *out = Ch('<'), ++out;\r\n            out = copy_chars(node->name(), node->name() + node->name_size(), out);\r\n            out = print_attributes(out, node, flags);\r\n            \r\n            // If node is childless\r\n            if (node->value_size() == 0 && !node->first_node())\r\n            {\r\n                // Print childless node tag ending\r\n                *out = Ch('/'), ++out;\r\n                *out = Ch('>'), ++out;\r\n            }\r\n            else\r\n            {\r\n                // Print normal node tag ending\r\n                *out = Ch('>'), ++out;\r\n\r\n                // Test if node contains a single data node only (and no other nodes)\r\n                xml_node<Ch> *child = node->first_node();\r\n                if (!child)\r\n                {\r\n                    // If node has no children, only print its value without indenting\r\n                    out = copy_and_expand_chars(node->value(), node->value() + node->value_size(), Ch(0), out);\r\n                }\r\n                else if (child->next_sibling() == 0 && child->type() == node_data)\r\n                {\r\n                    // If node has a sole data child, only print its value without indenting\r\n                    out = copy_and_expand_chars(child->value(), child->value() + child->value_size(), Ch(0), out);\r\n                }\r\n                else\r\n                {\r\n                    // Print all children with full indenting\r\n                    if (!(flags & print_no_indenting))\r\n                        *out = Ch('\\n'), ++out;\r\n                    out = print_children(out, node, flags, indent + 1);\r\n                    if (!(flags & print_no_indenting))\r\n                        out = fill_chars(out, indent, Ch('\\t'));\r\n                }\r\n\r\n                // Print node end\r\n                *out = Ch('<'), ++out;\r\n                *out = Ch('/'), ++out;\r\n                out = copy_chars(node->name(), node->name() + node->name_size(), out);\r\n                *out = Ch('>'), ++out;\r\n            }\r\n            return out;\r\n        }\r\n\r\n        // Print declaration node\r\n        template<class OutIt, class Ch>\r\n        inline OutIt print_declaration_node(OutIt out, const xml_node<Ch> *node, int flags, int indent)\r\n        {\r\n            // Print declaration start\r\n            if (!(flags & print_no_indenting))\r\n                out = fill_chars(out, indent, Ch('\\t'));\r\n            *out = Ch('<'), ++out;\r\n            *out = Ch('?'), ++out;\r\n            *out = Ch('x'), ++out;\r\n            *out = Ch('m'), ++out;\r\n            *out = Ch('l'), ++out;\r\n\r\n            // Print attributes\r\n            out = print_attributes(out, node, flags);\r\n            \r\n            // Print declaration end\r\n            *out = Ch('?'), ++out;\r\n            *out = Ch('>'), ++out;\r\n            \r\n            return out;\r\n        }\r\n\r\n        // Print comment node\r\n        template<class OutIt, class Ch>\r\n        inline OutIt print_comment_node(OutIt out, const xml_node<Ch> *node, int flags, int indent)\r\n        {\r\n            assert(node->type() == node_comment);\r\n            if (!(flags & print_no_indenting))\r\n                out = fill_chars(out, indent, Ch('\\t'));\r\n            *out = Ch('<'), ++out;\r\n            *out = Ch('!'), ++out;\r\n            *out = Ch('-'), ++out;\r\n            *out = Ch('-'), ++out;\r\n            out = copy_chars(node->value(), node->value() + node->value_size(), out);\r\n            *out = Ch('-'), ++out;\r\n            *out = Ch('-'), ++out;\r\n            *out = Ch('>'), ++out;\r\n            return out;\r\n        }\r\n\r\n        // Print doctype node\r\n        template<class OutIt, class Ch>\r\n        inline OutIt print_doctype_node(OutIt out, const xml_node<Ch> *node, int flags, int indent)\r\n        {\r\n            assert(node->type() == node_doctype);\r\n            if (!(flags & print_no_indenting))\r\n                out = fill_chars(out, indent, Ch('\\t'));\r\n            *out = Ch('<'), ++out;\r\n            *out = Ch('!'), ++out;\r\n            *out = Ch('D'), ++out;\r\n            *out = Ch('O'), ++out;\r\n            *out = Ch('C'), ++out;\r\n            *out = Ch('T'), ++out;\r\n            *out = Ch('Y'), ++out;\r\n            *out = Ch('P'), ++out;\r\n            *out = Ch('E'), ++out;\r\n            *out = Ch(' '), ++out;\r\n            out = copy_chars(node->value(), node->value() + node->value_size(), out);\r\n            *out = Ch('>'), ++out;\r\n            return out;\r\n        }\r\n\r\n        // Print pi node\r\n        template<class OutIt, class Ch>\r\n        inline OutIt print_pi_node(OutIt out, const xml_node<Ch> *node, int flags, int indent)\r\n        {\r\n            assert(node->type() == node_pi);\r\n            if (!(flags & print_no_indenting))\r\n                out = fill_chars(out, indent, Ch('\\t'));\r\n            *out = Ch('<'), ++out;\r\n            *out = Ch('?'), ++out;\r\n            out = copy_chars(node->name(), node->name() + node->name_size(), out);\r\n            *out = Ch(' '), ++out;\r\n            out = copy_chars(node->value(), node->value() + node->value_size(), out);\r\n            *out = Ch('?'), ++out;\r\n            *out = Ch('>'), ++out;\r\n            return out;\r\n        }\r\n\r\n    }\r\n    //! \\endcond\r\n\r\n    ///////////////////////////////////////////////////////////////////////////\r\n    // Printing\r\n\r\n    //! Prints XML to given output iterator.\r\n    //! \\param out Output iterator to print to.\r\n    //! \\param node Node to be printed. Pass xml_document to print entire document.\r\n    //! \\param flags Flags controlling how XML is printed.\r\n    //! \\return Output iterator pointing to position immediately after last character of printed text.\r\n    template<class OutIt, class Ch> \r\n    inline OutIt print(OutIt out, const xml_node<Ch> &node, int flags = 0)\r\n    {\r\n        return internal::print_node(out, &node, flags, 0);\r\n    }\r\n\r\n#ifndef RAPIDXML_NO_STREAMS\r\n\r\n    //! Prints XML to given output stream.\r\n    //! \\param out Output stream to print to.\r\n    //! \\param node Node to be printed. Pass xml_document to print entire document.\r\n    //! \\param flags Flags controlling how XML is printed.\r\n    //! \\return Output stream.\r\n    template<class Ch> \r\n    inline std::basic_ostream<Ch> &print(std::basic_ostream<Ch> &out, const xml_node<Ch> &node, int flags = 0)\r\n    {\r\n        print(std::ostream_iterator<Ch>(out), node, flags);\r\n        return out;\r\n    }\r\n\r\n    //! Prints formatted XML to given output stream. Uses default printing flags. Use print() function to customize printing process.\r\n    //! \\param out Output stream to print to.\r\n    //! \\param node Node to be printed.\r\n    //! \\return Output stream.\r\n    template<class Ch> \r\n    inline std::basic_ostream<Ch> &operator <<(std::basic_ostream<Ch> &out, const xml_node<Ch> &node)\r\n    {\r\n        return print(out, node);\r\n    }\r\n\r\n#endif\r\n\r\n}\r\n\r\n#endif\r\n"
  },
  {
    "path": "Projects/Libraries/CSBase/Source/rapidxml/rapidxml_utils.hpp",
    "content": "#ifndef RAPIDXML_UTILS_HPP_INCLUDED\r\n#define RAPIDXML_UTILS_HPP_INCLUDED\r\n\r\n// Copyright (C) 2006, 2009 Marcin Kalicinski\r\n// Version 1.13\r\n// Revision $DateTime: 2009/05/13 01:46:17 $\r\n//! \\file rapidxml_utils.hpp This file contains high-level rapidxml utilities that can be useful\r\n//! in certain simple scenarios. They should probably not be used if maximizing performance is the main objective.\r\n\r\n#include \"rapidxml.hpp\"\r\n#include <vector>\r\n#include <string>\r\n#include <fstream>\r\n#include <stdexcept>\r\n\r\nnamespace rapidxml\r\n{\r\n\r\n    //! Represents data loaded from a file\r\n    template<class Ch = char>\r\n    class file\r\n    {\r\n        \r\n    public:\r\n        \r\n        //! Loads file into the memory. Data will be automatically destroyed by the destructor.\r\n        //! \\param filename Filename to load.\r\n        file(const char *filename)\r\n        {\r\n            using namespace std;\r\n\r\n            // Open stream\r\n            basic_ifstream<Ch> stream(filename, ios::binary);\r\n            if (!stream)\r\n                throw runtime_error(string(\"cannot open file \") + filename);\r\n            stream.unsetf(ios::skipws);\r\n            \r\n            // Determine stream size\r\n            stream.seekg(0, ios::end);\r\n            size_t size = stream.tellg();\r\n            stream.seekg(0);   \r\n            \r\n            // Load data and add terminating 0\r\n            m_data.resize(size + 1);\r\n            stream.read(&m_data.front(), static_cast<streamsize>(size));\r\n            m_data[size] = 0;\r\n        }\r\n\r\n        //! Loads file into the memory. Data will be automatically destroyed by the destructor\r\n        //! \\param stream Stream to load from\r\n        file(std::basic_istream<Ch> &stream)\r\n        {\r\n            using namespace std;\r\n\r\n            // Load data and add terminating 0\r\n            stream.unsetf(ios::skipws);\r\n            m_data.assign(istreambuf_iterator<Ch>(stream), istreambuf_iterator<Ch>());\r\n            if (stream.fail() || stream.bad())\r\n                throw runtime_error(\"error reading stream\");\r\n            m_data.push_back(0);\r\n        }\r\n        \r\n        //! Gets file data.\r\n        //! \\return Pointer to data of file.\r\n        Ch *data()\r\n        {\r\n            return &m_data.front();\r\n        }\r\n\r\n        //! Gets file data.\r\n        //! \\return Pointer to data of file.\r\n        const Ch *data() const\r\n        {\r\n            return &m_data.front();\r\n        }\r\n\r\n        //! Gets file data size.\r\n        //! \\return Size of file data, in characters.\r\n        std::size_t size() const\r\n        {\r\n            return m_data.size();\r\n        }\r\n\r\n    private:\r\n\r\n        std::vector<Ch> m_data;   // File data\r\n\r\n    };\r\n\r\n    //! Counts children of node. Time complexity is O(n).\r\n    //! \\return Number of children of node\r\n    template<class Ch>\r\n    inline std::size_t count_children(xml_node<Ch> *node)\r\n    {\r\n        xml_node<Ch> *child = node->first_node();\r\n        std::size_t count = 0;\r\n        while (child)\r\n        {\r\n            ++count;\r\n            child = child->next_sibling();\r\n        }\r\n        return count;\r\n    }\r\n\r\n    //! Counts attributes of node. Time complexity is O(n).\r\n    //! \\return Number of attributes of node\r\n    template<class Ch>\r\n    inline std::size_t count_attributes(xml_node<Ch> *node)\r\n    {\r\n        xml_attribute<Ch> *attr = node->first_attribute();\r\n        std::size_t count = 0;\r\n        while (attr)\r\n        {\r\n            ++count;\r\n            attr = attr->next_attribute();\r\n        }\r\n        return count;\r\n    }\r\n\r\n}\r\n\r\n#endif\r\n"
  },
  {
    "path": "Projects/Libraries/CSBase/Source/zlib/adler32.c",
    "content": "/* adler32.c -- compute the Adler-32 checksum of a data stream\n * Copyright (C) 1995-2011, 2016 Mark Adler\n * For conditions of distribution and use, see copyright notice in zlib.h\n */\n\n/* @(#) $Id$ */\n\n#include \"zutil.h\"\n\nlocal uLong adler32_combine_ OF((uLong adler1, uLong adler2, z_off64_t len2));\n\n#define BASE 65521U     /* largest prime smaller than 65536 */\n#define NMAX 5552\n/* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */\n\n#define DO1(buf,i)  {adler += (buf)[i]; sum2 += adler;}\n#define DO2(buf,i)  DO1(buf,i); DO1(buf,i+1);\n#define DO4(buf,i)  DO2(buf,i); DO2(buf,i+2);\n#define DO8(buf,i)  DO4(buf,i); DO4(buf,i+4);\n#define DO16(buf)   DO8(buf,0); DO8(buf,8);\n\n/* use NO_DIVIDE if your processor does not do division in hardware --\n   try it both ways to see which is faster */\n#ifdef NO_DIVIDE\n/* note that this assumes BASE is 65521, where 65536 % 65521 == 15\n   (thank you to John Reiser for pointing this out) */\n#  define CHOP(a) \\\n    do { \\\n        unsigned long tmp = a >> 16; \\\n        a &= 0xffffUL; \\\n        a += (tmp << 4) - tmp; \\\n    } while (0)\n#  define MOD28(a) \\\n    do { \\\n        CHOP(a); \\\n        if (a >= BASE) a -= BASE; \\\n    } while (0)\n#  define MOD(a) \\\n    do { \\\n        CHOP(a); \\\n        MOD28(a); \\\n    } while (0)\n#  define MOD63(a) \\\n    do { /* this assumes a is not negative */ \\\n        z_off64_t tmp = a >> 32; \\\n        a &= 0xffffffffL; \\\n        a += (tmp << 8) - (tmp << 5) + tmp; \\\n        tmp = a >> 16; \\\n        a &= 0xffffL; \\\n        a += (tmp << 4) - tmp; \\\n        tmp = a >> 16; \\\n        a &= 0xffffL; \\\n        a += (tmp << 4) - tmp; \\\n        if (a >= BASE) a -= BASE; \\\n    } while (0)\n#else\n#  define MOD(a) a %= BASE\n#  define MOD28(a) a %= BASE\n#  define MOD63(a) a %= BASE\n#endif\n\n/* ========================================================================= */\nuLong ZEXPORT adler32_z(adler, buf, len)\n    uLong adler;\n    const Bytef *buf;\n    z_size_t len;\n{\n    unsigned long sum2;\n    unsigned n;\n\n    /* split Adler-32 into component sums */\n    sum2 = (adler >> 16) & 0xffff;\n    adler &= 0xffff;\n\n    /* in case user likes doing a byte at a time, keep it fast */\n    if (len == 1) {\n        adler += buf[0];\n        if (adler >= BASE)\n            adler -= BASE;\n        sum2 += adler;\n        if (sum2 >= BASE)\n            sum2 -= BASE;\n        return adler | (sum2 << 16);\n    }\n\n    /* initial Adler-32 value (deferred check for len == 1 speed) */\n    if (buf == Z_NULL)\n        return 1L;\n\n    /* in case short lengths are provided, keep it somewhat fast */\n    if (len < 16) {\n        while (len--) {\n            adler += *buf++;\n            sum2 += adler;\n        }\n        if (adler >= BASE)\n            adler -= BASE;\n        MOD28(sum2);            /* only added so many BASE's */\n        return adler | (sum2 << 16);\n    }\n\n    /* do length NMAX blocks -- requires just one modulo operation */\n    while (len >= NMAX) {\n        len -= NMAX;\n        n = NMAX / 16;          /* NMAX is divisible by 16 */\n        do {\n            DO16(buf);          /* 16 sums unrolled */\n            buf += 16;\n        } while (--n);\n        MOD(adler);\n        MOD(sum2);\n    }\n\n    /* do remaining bytes (less than NMAX, still just one modulo) */\n    if (len) {                  /* avoid modulos if none remaining */\n        while (len >= 16) {\n            len -= 16;\n            DO16(buf);\n            buf += 16;\n        }\n        while (len--) {\n            adler += *buf++;\n            sum2 += adler;\n        }\n        MOD(adler);\n        MOD(sum2);\n    }\n\n    /* return recombined sums */\n    return adler | (sum2 << 16);\n}\n\n/* ========================================================================= */\nuLong ZEXPORT adler32(adler, buf, len)\n    uLong adler;\n    const Bytef *buf;\n    uInt len;\n{\n    return adler32_z(adler, buf, len);\n}\n\n/* ========================================================================= */\nlocal uLong adler32_combine_(adler1, adler2, len2)\n    uLong adler1;\n    uLong adler2;\n    z_off64_t len2;\n{\n    unsigned long sum1;\n    unsigned long sum2;\n    unsigned rem;\n\n    /* for negative len, return invalid adler32 as a clue for debugging */\n    if (len2 < 0)\n        return 0xffffffffUL;\n\n    /* the derivation of this formula is left as an exercise for the reader */\n    MOD63(len2);                /* assumes len2 >= 0 */\n    rem = (unsigned)len2;\n    sum1 = adler1 & 0xffff;\n    sum2 = rem * sum1;\n    MOD(sum2);\n    sum1 += (adler2 & 0xffff) + BASE - 1;\n    sum2 += ((adler1 >> 16) & 0xffff) + ((adler2 >> 16) & 0xffff) + BASE - rem;\n    if (sum1 >= BASE) sum1 -= BASE;\n    if (sum1 >= BASE) sum1 -= BASE;\n    if (sum2 >= ((unsigned long)BASE << 1)) sum2 -= ((unsigned long)BASE << 1);\n    if (sum2 >= BASE) sum2 -= BASE;\n    return sum1 | (sum2 << 16);\n}\n\n/* ========================================================================= */\nuLong ZEXPORT adler32_combine(adler1, adler2, len2)\n    uLong adler1;\n    uLong adler2;\n    z_off_t len2;\n{\n    return adler32_combine_(adler1, adler2, len2);\n}\n\nuLong ZEXPORT adler32_combine64(adler1, adler2, len2)\n    uLong adler1;\n    uLong adler2;\n    z_off64_t len2;\n{\n    return adler32_combine_(adler1, adler2, len2);\n}\n"
  },
  {
    "path": "Projects/Libraries/CSBase/Source/zlib/compress.c",
    "content": "/* compress.c -- compress a memory buffer\n * Copyright (C) 1995-2005, 2014, 2016 Jean-loup Gailly, Mark Adler\n * For conditions of distribution and use, see copyright notice in zlib.h\n */\n\n/* @(#) $Id$ */\n\n#define ZLIB_INTERNAL\n#include \"zlib.h\"\n\n/* ===========================================================================\n     Compresses the source buffer into the destination buffer. The level\n   parameter has the same meaning as in deflateInit.  sourceLen is the byte\n   length of the source buffer. Upon entry, destLen is the total size of the\n   destination buffer, which must be at least 0.1% larger than sourceLen plus\n   12 bytes. Upon exit, destLen is the actual size of the compressed buffer.\n\n     compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough\n   memory, Z_BUF_ERROR if there was not enough room in the output buffer,\n   Z_STREAM_ERROR if the level parameter is invalid.\n*/\nint ZEXPORT compress2 (dest, destLen, source, sourceLen, level)\n    Bytef *dest;\n    uLongf *destLen;\n    const Bytef *source;\n    uLong sourceLen;\n    int level;\n{\n    z_stream stream;\n    int err;\n    const uInt max = (uInt)-1;\n    uLong left;\n\n    left = *destLen;\n    *destLen = 0;\n\n    stream.zalloc = (alloc_func)0;\n    stream.zfree = (free_func)0;\n    stream.opaque = (voidpf)0;\n\n    err = deflateInit(&stream, level);\n    if (err != Z_OK) return err;\n\n    stream.next_out = dest;\n    stream.avail_out = 0;\n    stream.next_in = (z_const Bytef *)source;\n    stream.avail_in = 0;\n\n    do {\n        if (stream.avail_out == 0) {\n            stream.avail_out = left > (uLong)max ? max : (uInt)left;\n            left -= stream.avail_out;\n        }\n        if (stream.avail_in == 0) {\n            stream.avail_in = sourceLen > (uLong)max ? max : (uInt)sourceLen;\n            sourceLen -= stream.avail_in;\n        }\n        err = deflate(&stream, sourceLen ? Z_NO_FLUSH : Z_FINISH);\n    } while (err == Z_OK);\n\n    *destLen = stream.total_out;\n    deflateEnd(&stream);\n    return err == Z_STREAM_END ? Z_OK : err;\n}\n\n/* ===========================================================================\n */\nint ZEXPORT compress (dest, destLen, source, sourceLen)\n    Bytef *dest;\n    uLongf *destLen;\n    const Bytef *source;\n    uLong sourceLen;\n{\n    return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION);\n}\n\n/* ===========================================================================\n     If the default memLevel or windowBits for deflateInit() is changed, then\n   this function needs to be updated.\n */\nuLong ZEXPORT compressBound (sourceLen)\n    uLong sourceLen;\n{\n    return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) +\n           (sourceLen >> 25) + 13;\n}\n"
  },
  {
    "path": "Projects/Libraries/CSBase/Source/zlib/crc32.c",
    "content": "/* crc32.c -- compute the CRC-32 of a data stream\n * Copyright (C) 1995-2006, 2010, 2011, 2012, 2016 Mark Adler\n * For conditions of distribution and use, see copyright notice in zlib.h\n *\n * Thanks to Rodney Brown <rbrown64@csc.com.au> for his contribution of faster\n * CRC methods: exclusive-oring 32 bits of data at a time, and pre-computing\n * tables for updating the shift register in one step with three exclusive-ors\n * instead of four steps with four exclusive-ors.  This results in about a\n * factor of two increase in speed on a Power PC G4 (PPC7455) using gcc -O3.\n */\n\n/* @(#) $Id$ */\n\n/*\n  Note on the use of DYNAMIC_CRC_TABLE: there is no mutex or semaphore\n  protection on the static variables used to control the first-use generation\n  of the crc tables.  Therefore, if you #define DYNAMIC_CRC_TABLE, you should\n  first call get_crc_table() to initialize the tables before allowing more than\n  one thread to use crc32().\n\n  DYNAMIC_CRC_TABLE and MAKECRCH can be #defined to write out crc32.h.\n */\n\n#ifdef MAKECRCH\n#  include <stdio.h>\n#  ifndef DYNAMIC_CRC_TABLE\n#    define DYNAMIC_CRC_TABLE\n#  endif /* !DYNAMIC_CRC_TABLE */\n#endif /* MAKECRCH */\n\n#include \"zutil.h\"      /* for STDC and FAR definitions */\n\n/* Definitions for doing the crc four data bytes at a time. */\n#if !defined(NOBYFOUR) && defined(Z_U4)\n#  define BYFOUR\n#endif\n#ifdef BYFOUR\n   local unsigned long crc32_little OF((unsigned long,\n                        const unsigned char FAR *, z_size_t));\n   local unsigned long crc32_big OF((unsigned long,\n                        const unsigned char FAR *, z_size_t));\n#  define TBLS 8\n#else\n#  define TBLS 1\n#endif /* BYFOUR */\n\n/* Local functions for crc concatenation */\nlocal unsigned long gf2_matrix_times OF((unsigned long *mat,\n                                         unsigned long vec));\nlocal void gf2_matrix_square OF((unsigned long *square, unsigned long *mat));\nlocal uLong crc32_combine_ OF((uLong crc1, uLong crc2, z_off64_t len2));\n\n\n#ifdef DYNAMIC_CRC_TABLE\n\nlocal volatile int crc_table_empty = 1;\nlocal z_crc_t FAR crc_table[TBLS][256];\nlocal void make_crc_table OF((void));\n#ifdef MAKECRCH\n   local void write_table OF((FILE *, const z_crc_t FAR *));\n#endif /* MAKECRCH */\n/*\n  Generate tables for a byte-wise 32-bit CRC calculation on the polynomial:\n  x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x+1.\n\n  Polynomials over GF(2) are represented in binary, one bit per coefficient,\n  with the lowest powers in the most significant bit.  Then adding polynomials\n  is just exclusive-or, and multiplying a polynomial by x is a right shift by\n  one.  If we call the above polynomial p, and represent a byte as the\n  polynomial q, also with the lowest power in the most significant bit (so the\n  byte 0xb1 is the polynomial x^7+x^3+x+1), then the CRC is (q*x^32) mod p,\n  where a mod b means the remainder after dividing a by b.\n\n  This calculation is done using the shift-register method of multiplying and\n  taking the remainder.  The register is initialized to zero, and for each\n  incoming bit, x^32 is added mod p to the register if the bit is a one (where\n  x^32 mod p is p+x^32 = x^26+...+1), and the register is multiplied mod p by\n  x (which is shifting right by one and adding x^32 mod p if the bit shifted\n  out is a one).  We start with the highest power (least significant bit) of\n  q and repeat for all eight bits of q.\n\n  The first table is simply the CRC of all possible eight bit values.  This is\n  all the information needed to generate CRCs on data a byte at a time for all\n  combinations of CRC register values and incoming bytes.  The remaining tables\n  allow for word-at-a-time CRC calculation for both big-endian and little-\n  endian machines, where a word is four bytes.\n*/\nlocal void make_crc_table()\n{\n    z_crc_t c;\n    int n, k;\n    z_crc_t poly;                       /* polynomial exclusive-or pattern */\n    /* terms of polynomial defining this crc (except x^32): */\n    static volatile int first = 1;      /* flag to limit concurrent making */\n    static const unsigned char p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26};\n\n    /* See if another task is already doing this (not thread-safe, but better\n       than nothing -- significantly reduces duration of vulnerability in\n       case the advice about DYNAMIC_CRC_TABLE is ignored) */\n    if (first) {\n        first = 0;\n\n        /* make exclusive-or pattern from polynomial (0xedb88320UL) */\n        poly = 0;\n        for (n = 0; n < (int)(sizeof(p)/sizeof(unsigned char)); n++)\n            poly |= (z_crc_t)1 << (31 - p[n]);\n\n        /* generate a crc for every 8-bit value */\n        for (n = 0; n < 256; n++) {\n            c = (z_crc_t)n;\n            for (k = 0; k < 8; k++)\n                c = c & 1 ? poly ^ (c >> 1) : c >> 1;\n            crc_table[0][n] = c;\n        }\n\n#ifdef BYFOUR\n        /* generate crc for each value followed by one, two, and three zeros,\n           and then the byte reversal of those as well as the first table */\n        for (n = 0; n < 256; n++) {\n            c = crc_table[0][n];\n            crc_table[4][n] = ZSWAP32(c);\n            for (k = 1; k < 4; k++) {\n                c = crc_table[0][c & 0xff] ^ (c >> 8);\n                crc_table[k][n] = c;\n                crc_table[k + 4][n] = ZSWAP32(c);\n            }\n        }\n#endif /* BYFOUR */\n\n        crc_table_empty = 0;\n    }\n    else {      /* not first */\n        /* wait for the other guy to finish (not efficient, but rare) */\n        while (crc_table_empty)\n            ;\n    }\n\n#ifdef MAKECRCH\n    /* write out CRC tables to crc32.h */\n    {\n        FILE *out;\n\n        out = fopen(\"crc32.h\", \"w\");\n        if (out == NULL) return;\n        fprintf(out, \"/* crc32.h -- tables for rapid CRC calculation\\n\");\n        fprintf(out, \" * Generated automatically by crc32.c\\n */\\n\\n\");\n        fprintf(out, \"local const z_crc_t FAR \");\n        fprintf(out, \"crc_table[TBLS][256] =\\n{\\n  {\\n\");\n        write_table(out, crc_table[0]);\n#  ifdef BYFOUR\n        fprintf(out, \"#ifdef BYFOUR\\n\");\n        for (k = 1; k < 8; k++) {\n            fprintf(out, \"  },\\n  {\\n\");\n            write_table(out, crc_table[k]);\n        }\n        fprintf(out, \"#endif\\n\");\n#  endif /* BYFOUR */\n        fprintf(out, \"  }\\n};\\n\");\n        fclose(out);\n    }\n#endif /* MAKECRCH */\n}\n\n#ifdef MAKECRCH\nlocal void write_table(out, table)\n    FILE *out;\n    const z_crc_t FAR *table;\n{\n    int n;\n\n    for (n = 0; n < 256; n++)\n        fprintf(out, \"%s0x%08lxUL%s\", n % 5 ? \"\" : \"    \",\n                (unsigned long)(table[n]),\n                n == 255 ? \"\\n\" : (n % 5 == 4 ? \",\\n\" : \", \"));\n}\n#endif /* MAKECRCH */\n\n#else /* !DYNAMIC_CRC_TABLE */\n/* ========================================================================\n * Tables of CRC-32s of all single-byte values, made by make_crc_table().\n */\n#include \"crc32.h\"\n#endif /* DYNAMIC_CRC_TABLE */\n\n/* =========================================================================\n * This function can be used by asm versions of crc32()\n */\nconst z_crc_t FAR * ZEXPORT get_crc_table()\n{\n#ifdef DYNAMIC_CRC_TABLE\n    if (crc_table_empty)\n        make_crc_table();\n#endif /* DYNAMIC_CRC_TABLE */\n    return (const z_crc_t FAR *)crc_table;\n}\n\n/* ========================================================================= */\n#define DO1 crc = crc_table[0][((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8)\n#define DO8 DO1; DO1; DO1; DO1; DO1; DO1; DO1; DO1\n\n/* ========================================================================= */\nunsigned long ZEXPORT crc32_z(crc, buf, len)\n    unsigned long crc;\n    const unsigned char FAR *buf;\n    z_size_t len;\n{\n    if (buf == Z_NULL) return 0UL;\n\n#ifdef DYNAMIC_CRC_TABLE\n    if (crc_table_empty)\n        make_crc_table();\n#endif /* DYNAMIC_CRC_TABLE */\n\n#ifdef BYFOUR\n    if (sizeof(void *) == sizeof(ptrdiff_t)) {\n        z_crc_t endian;\n\n        endian = 1;\n        if (*((unsigned char *)(&endian)))\n            return crc32_little(crc, buf, len);\n        else\n            return crc32_big(crc, buf, len);\n    }\n#endif /* BYFOUR */\n    crc = crc ^ 0xffffffffUL;\n    while (len >= 8) {\n        DO8;\n        len -= 8;\n    }\n    if (len) do {\n        DO1;\n    } while (--len);\n    return crc ^ 0xffffffffUL;\n}\n\n/* ========================================================================= */\nunsigned long ZEXPORT crc32(crc, buf, len)\n    unsigned long crc;\n    const unsigned char FAR *buf;\n    uInt len;\n{\n    return crc32_z(crc, buf, len);\n}\n\n#ifdef BYFOUR\n\n/*\n   This BYFOUR code accesses the passed unsigned char * buffer with a 32-bit\n   integer pointer type. This violates the strict aliasing rule, where a\n   compiler can assume, for optimization purposes, that two pointers to\n   fundamentally different types won't ever point to the same memory. This can\n   manifest as a problem only if one of the pointers is written to. This code\n   only reads from those pointers. So long as this code remains isolated in\n   this compilation unit, there won't be a problem. For this reason, this code\n   should not be copied and pasted into a compilation unit in which other code\n   writes to the buffer that is passed to these routines.\n */\n\n/* ========================================================================= */\n#define DOLIT4 c ^= *buf4++; \\\n        c = crc_table[3][c & 0xff] ^ crc_table[2][(c >> 8) & 0xff] ^ \\\n            crc_table[1][(c >> 16) & 0xff] ^ crc_table[0][c >> 24]\n#define DOLIT32 DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4\n\n/* ========================================================================= */\nlocal unsigned long crc32_little(crc, buf, len)\n    unsigned long crc;\n    const unsigned char FAR *buf;\n    z_size_t len;\n{\n    register z_crc_t c;\n    register const z_crc_t FAR *buf4;\n\n    c = (z_crc_t)crc;\n    c = ~c;\n    while (len && ((ptrdiff_t)buf & 3)) {\n        c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8);\n        len--;\n    }\n\n    buf4 = (const z_crc_t FAR *)(const void FAR *)buf;\n    while (len >= 32) {\n        DOLIT32;\n        len -= 32;\n    }\n    while (len >= 4) {\n        DOLIT4;\n        len -= 4;\n    }\n    buf = (const unsigned char FAR *)buf4;\n\n    if (len) do {\n        c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8);\n    } while (--len);\n    c = ~c;\n    return (unsigned long)c;\n}\n\n/* ========================================================================= */\n#define DOBIG4 c ^= *buf4++; \\\n        c = crc_table[4][c & 0xff] ^ crc_table[5][(c >> 8) & 0xff] ^ \\\n            crc_table[6][(c >> 16) & 0xff] ^ crc_table[7][c >> 24]\n#define DOBIG32 DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4\n\n/* ========================================================================= */\nlocal unsigned long crc32_big(crc, buf, len)\n    unsigned long crc;\n    const unsigned char FAR *buf;\n    z_size_t len;\n{\n    register z_crc_t c;\n    register const z_crc_t FAR *buf4;\n\n    c = ZSWAP32((z_crc_t)crc);\n    c = ~c;\n    while (len && ((ptrdiff_t)buf & 3)) {\n        c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8);\n        len--;\n    }\n\n    buf4 = (const z_crc_t FAR *)(const void FAR *)buf;\n    while (len >= 32) {\n        DOBIG32;\n        len -= 32;\n    }\n    while (len >= 4) {\n        DOBIG4;\n        len -= 4;\n    }\n    buf = (const unsigned char FAR *)buf4;\n\n    if (len) do {\n        c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8);\n    } while (--len);\n    c = ~c;\n    return (unsigned long)(ZSWAP32(c));\n}\n\n#endif /* BYFOUR */\n\n#define GF2_DIM 32      /* dimension of GF(2) vectors (length of CRC) */\n\n/* ========================================================================= */\nlocal unsigned long gf2_matrix_times(mat, vec)\n    unsigned long *mat;\n    unsigned long vec;\n{\n    unsigned long sum;\n\n    sum = 0;\n    while (vec) {\n        if (vec & 1)\n            sum ^= *mat;\n        vec >>= 1;\n        mat++;\n    }\n    return sum;\n}\n\n/* ========================================================================= */\nlocal void gf2_matrix_square(square, mat)\n    unsigned long *square;\n    unsigned long *mat;\n{\n    int n;\n\n    for (n = 0; n < GF2_DIM; n++)\n        square[n] = gf2_matrix_times(mat, mat[n]);\n}\n\n/* ========================================================================= */\nlocal uLong crc32_combine_(crc1, crc2, len2)\n    uLong crc1;\n    uLong crc2;\n    z_off64_t len2;\n{\n    int n;\n    unsigned long row;\n    unsigned long even[GF2_DIM];    /* even-power-of-two zeros operator */\n    unsigned long odd[GF2_DIM];     /* odd-power-of-two zeros operator */\n\n    /* degenerate case (also disallow negative lengths) */\n    if (len2 <= 0)\n        return crc1;\n\n    /* put operator for one zero bit in odd */\n    odd[0] = 0xedb88320UL;          /* CRC-32 polynomial */\n    row = 1;\n    for (n = 1; n < GF2_DIM; n++) {\n        odd[n] = row;\n        row <<= 1;\n    }\n\n    /* put operator for two zero bits in even */\n    gf2_matrix_square(even, odd);\n\n    /* put operator for four zero bits in odd */\n    gf2_matrix_square(odd, even);\n\n    /* apply len2 zeros to crc1 (first square will put the operator for one\n       zero byte, eight zero bits, in even) */\n    do {\n        /* apply zeros operator for this bit of len2 */\n        gf2_matrix_square(even, odd);\n        if (len2 & 1)\n            crc1 = gf2_matrix_times(even, crc1);\n        len2 >>= 1;\n\n        /* if no more bits set, then done */\n        if (len2 == 0)\n            break;\n\n        /* another iteration of the loop with odd and even swapped */\n        gf2_matrix_square(odd, even);\n        if (len2 & 1)\n            crc1 = gf2_matrix_times(odd, crc1);\n        len2 >>= 1;\n\n        /* if no more bits set, then done */\n    } while (len2 != 0);\n\n    /* return combined crc */\n    crc1 ^= crc2;\n    return crc1;\n}\n\n/* ========================================================================= */\nuLong ZEXPORT crc32_combine(crc1, crc2, len2)\n    uLong crc1;\n    uLong crc2;\n    z_off_t len2;\n{\n    return crc32_combine_(crc1, crc2, len2);\n}\n\nuLong ZEXPORT crc32_combine64(crc1, crc2, len2)\n    uLong crc1;\n    uLong crc2;\n    z_off64_t len2;\n{\n    return crc32_combine_(crc1, crc2, len2);\n}\n"
  },
  {
    "path": "Projects/Libraries/CSBase/Source/zlib/crc32.h",
    "content": "/* crc32.h -- tables for rapid CRC calculation\n * Generated automatically by crc32.c\n */\n\nlocal const z_crc_t FAR crc_table[TBLS][256] =\n{\n  {\n    0x00000000UL, 0x77073096UL, 0xee0e612cUL, 0x990951baUL, 0x076dc419UL,\n    0x706af48fUL, 0xe963a535UL, 0x9e6495a3UL, 0x0edb8832UL, 0x79dcb8a4UL,\n    0xe0d5e91eUL, 0x97d2d988UL, 0x09b64c2bUL, 0x7eb17cbdUL, 0xe7b82d07UL,\n    0x90bf1d91UL, 0x1db71064UL, 0x6ab020f2UL, 0xf3b97148UL, 0x84be41deUL,\n    0x1adad47dUL, 0x6ddde4ebUL, 0xf4d4b551UL, 0x83d385c7UL, 0x136c9856UL,\n    0x646ba8c0UL, 0xfd62f97aUL, 0x8a65c9ecUL, 0x14015c4fUL, 0x63066cd9UL,\n    0xfa0f3d63UL, 0x8d080df5UL, 0x3b6e20c8UL, 0x4c69105eUL, 0xd56041e4UL,\n    0xa2677172UL, 0x3c03e4d1UL, 0x4b04d447UL, 0xd20d85fdUL, 0xa50ab56bUL,\n    0x35b5a8faUL, 0x42b2986cUL, 0xdbbbc9d6UL, 0xacbcf940UL, 0x32d86ce3UL,\n    0x45df5c75UL, 0xdcd60dcfUL, 0xabd13d59UL, 0x26d930acUL, 0x51de003aUL,\n    0xc8d75180UL, 0xbfd06116UL, 0x21b4f4b5UL, 0x56b3c423UL, 0xcfba9599UL,\n    0xb8bda50fUL, 0x2802b89eUL, 0x5f058808UL, 0xc60cd9b2UL, 0xb10be924UL,\n    0x2f6f7c87UL, 0x58684c11UL, 0xc1611dabUL, 0xb6662d3dUL, 0x76dc4190UL,\n    0x01db7106UL, 0x98d220bcUL, 0xefd5102aUL, 0x71b18589UL, 0x06b6b51fUL,\n    0x9fbfe4a5UL, 0xe8b8d433UL, 0x7807c9a2UL, 0x0f00f934UL, 0x9609a88eUL,\n    0xe10e9818UL, 0x7f6a0dbbUL, 0x086d3d2dUL, 0x91646c97UL, 0xe6635c01UL,\n    0x6b6b51f4UL, 0x1c6c6162UL, 0x856530d8UL, 0xf262004eUL, 0x6c0695edUL,\n    0x1b01a57bUL, 0x8208f4c1UL, 0xf50fc457UL, 0x65b0d9c6UL, 0x12b7e950UL,\n    0x8bbeb8eaUL, 0xfcb9887cUL, 0x62dd1ddfUL, 0x15da2d49UL, 0x8cd37cf3UL,\n    0xfbd44c65UL, 0x4db26158UL, 0x3ab551ceUL, 0xa3bc0074UL, 0xd4bb30e2UL,\n    0x4adfa541UL, 0x3dd895d7UL, 0xa4d1c46dUL, 0xd3d6f4fbUL, 0x4369e96aUL,\n    0x346ed9fcUL, 0xad678846UL, 0xda60b8d0UL, 0x44042d73UL, 0x33031de5UL,\n    0xaa0a4c5fUL, 0xdd0d7cc9UL, 0x5005713cUL, 0x270241aaUL, 0xbe0b1010UL,\n    0xc90c2086UL, 0x5768b525UL, 0x206f85b3UL, 0xb966d409UL, 0xce61e49fUL,\n    0x5edef90eUL, 0x29d9c998UL, 0xb0d09822UL, 0xc7d7a8b4UL, 0x59b33d17UL,\n    0x2eb40d81UL, 0xb7bd5c3bUL, 0xc0ba6cadUL, 0xedb88320UL, 0x9abfb3b6UL,\n    0x03b6e20cUL, 0x74b1d29aUL, 0xead54739UL, 0x9dd277afUL, 0x04db2615UL,\n    0x73dc1683UL, 0xe3630b12UL, 0x94643b84UL, 0x0d6d6a3eUL, 0x7a6a5aa8UL,\n    0xe40ecf0bUL, 0x9309ff9dUL, 0x0a00ae27UL, 0x7d079eb1UL, 0xf00f9344UL,\n    0x8708a3d2UL, 0x1e01f268UL, 0x6906c2feUL, 0xf762575dUL, 0x806567cbUL,\n    0x196c3671UL, 0x6e6b06e7UL, 0xfed41b76UL, 0x89d32be0UL, 0x10da7a5aUL,\n    0x67dd4accUL, 0xf9b9df6fUL, 0x8ebeeff9UL, 0x17b7be43UL, 0x60b08ed5UL,\n    0xd6d6a3e8UL, 0xa1d1937eUL, 0x38d8c2c4UL, 0x4fdff252UL, 0xd1bb67f1UL,\n    0xa6bc5767UL, 0x3fb506ddUL, 0x48b2364bUL, 0xd80d2bdaUL, 0xaf0a1b4cUL,\n    0x36034af6UL, 0x41047a60UL, 0xdf60efc3UL, 0xa867df55UL, 0x316e8eefUL,\n    0x4669be79UL, 0xcb61b38cUL, 0xbc66831aUL, 0x256fd2a0UL, 0x5268e236UL,\n    0xcc0c7795UL, 0xbb0b4703UL, 0x220216b9UL, 0x5505262fUL, 0xc5ba3bbeUL,\n    0xb2bd0b28UL, 0x2bb45a92UL, 0x5cb36a04UL, 0xc2d7ffa7UL, 0xb5d0cf31UL,\n    0x2cd99e8bUL, 0x5bdeae1dUL, 0x9b64c2b0UL, 0xec63f226UL, 0x756aa39cUL,\n    0x026d930aUL, 0x9c0906a9UL, 0xeb0e363fUL, 0x72076785UL, 0x05005713UL,\n    0x95bf4a82UL, 0xe2b87a14UL, 0x7bb12baeUL, 0x0cb61b38UL, 0x92d28e9bUL,\n    0xe5d5be0dUL, 0x7cdcefb7UL, 0x0bdbdf21UL, 0x86d3d2d4UL, 0xf1d4e242UL,\n    0x68ddb3f8UL, 0x1fda836eUL, 0x81be16cdUL, 0xf6b9265bUL, 0x6fb077e1UL,\n    0x18b74777UL, 0x88085ae6UL, 0xff0f6a70UL, 0x66063bcaUL, 0x11010b5cUL,\n    0x8f659effUL, 0xf862ae69UL, 0x616bffd3UL, 0x166ccf45UL, 0xa00ae278UL,\n    0xd70dd2eeUL, 0x4e048354UL, 0x3903b3c2UL, 0xa7672661UL, 0xd06016f7UL,\n    0x4969474dUL, 0x3e6e77dbUL, 0xaed16a4aUL, 0xd9d65adcUL, 0x40df0b66UL,\n    0x37d83bf0UL, 0xa9bcae53UL, 0xdebb9ec5UL, 0x47b2cf7fUL, 0x30b5ffe9UL,\n    0xbdbdf21cUL, 0xcabac28aUL, 0x53b39330UL, 0x24b4a3a6UL, 0xbad03605UL,\n    0xcdd70693UL, 0x54de5729UL, 0x23d967bfUL, 0xb3667a2eUL, 0xc4614ab8UL,\n    0x5d681b02UL, 0x2a6f2b94UL, 0xb40bbe37UL, 0xc30c8ea1UL, 0x5a05df1bUL,\n    0x2d02ef8dUL\n#ifdef BYFOUR\n  },\n  {\n    0x00000000UL, 0x191b3141UL, 0x32366282UL, 0x2b2d53c3UL, 0x646cc504UL,\n    0x7d77f445UL, 0x565aa786UL, 0x4f4196c7UL, 0xc8d98a08UL, 0xd1c2bb49UL,\n    0xfaefe88aUL, 0xe3f4d9cbUL, 0xacb54f0cUL, 0xb5ae7e4dUL, 0x9e832d8eUL,\n    0x87981ccfUL, 0x4ac21251UL, 0x53d92310UL, 0x78f470d3UL, 0x61ef4192UL,\n    0x2eaed755UL, 0x37b5e614UL, 0x1c98b5d7UL, 0x05838496UL, 0x821b9859UL,\n    0x9b00a918UL, 0xb02dfadbUL, 0xa936cb9aUL, 0xe6775d5dUL, 0xff6c6c1cUL,\n    0xd4413fdfUL, 0xcd5a0e9eUL, 0x958424a2UL, 0x8c9f15e3UL, 0xa7b24620UL,\n    0xbea97761UL, 0xf1e8e1a6UL, 0xe8f3d0e7UL, 0xc3de8324UL, 0xdac5b265UL,\n    0x5d5daeaaUL, 0x44469febUL, 0x6f6bcc28UL, 0x7670fd69UL, 0x39316baeUL,\n    0x202a5aefUL, 0x0b07092cUL, 0x121c386dUL, 0xdf4636f3UL, 0xc65d07b2UL,\n    0xed705471UL, 0xf46b6530UL, 0xbb2af3f7UL, 0xa231c2b6UL, 0x891c9175UL,\n    0x9007a034UL, 0x179fbcfbUL, 0x0e848dbaUL, 0x25a9de79UL, 0x3cb2ef38UL,\n    0x73f379ffUL, 0x6ae848beUL, 0x41c51b7dUL, 0x58de2a3cUL, 0xf0794f05UL,\n    0xe9627e44UL, 0xc24f2d87UL, 0xdb541cc6UL, 0x94158a01UL, 0x8d0ebb40UL,\n    0xa623e883UL, 0xbf38d9c2UL, 0x38a0c50dUL, 0x21bbf44cUL, 0x0a96a78fUL,\n    0x138d96ceUL, 0x5ccc0009UL, 0x45d73148UL, 0x6efa628bUL, 0x77e153caUL,\n    0xbabb5d54UL, 0xa3a06c15UL, 0x888d3fd6UL, 0x91960e97UL, 0xded79850UL,\n    0xc7cca911UL, 0xece1fad2UL, 0xf5facb93UL, 0x7262d75cUL, 0x6b79e61dUL,\n    0x4054b5deUL, 0x594f849fUL, 0x160e1258UL, 0x0f152319UL, 0x243870daUL,\n    0x3d23419bUL, 0x65fd6ba7UL, 0x7ce65ae6UL, 0x57cb0925UL, 0x4ed03864UL,\n    0x0191aea3UL, 0x188a9fe2UL, 0x33a7cc21UL, 0x2abcfd60UL, 0xad24e1afUL,\n    0xb43fd0eeUL, 0x9f12832dUL, 0x8609b26cUL, 0xc94824abUL, 0xd05315eaUL,\n    0xfb7e4629UL, 0xe2657768UL, 0x2f3f79f6UL, 0x362448b7UL, 0x1d091b74UL,\n    0x04122a35UL, 0x4b53bcf2UL, 0x52488db3UL, 0x7965de70UL, 0x607eef31UL,\n    0xe7e6f3feUL, 0xfefdc2bfUL, 0xd5d0917cUL, 0xcccba03dUL, 0x838a36faUL,\n    0x9a9107bbUL, 0xb1bc5478UL, 0xa8a76539UL, 0x3b83984bUL, 0x2298a90aUL,\n    0x09b5fac9UL, 0x10aecb88UL, 0x5fef5d4fUL, 0x46f46c0eUL, 0x6dd93fcdUL,\n    0x74c20e8cUL, 0xf35a1243UL, 0xea412302UL, 0xc16c70c1UL, 0xd8774180UL,\n    0x9736d747UL, 0x8e2de606UL, 0xa500b5c5UL, 0xbc1b8484UL, 0x71418a1aUL,\n    0x685abb5bUL, 0x4377e898UL, 0x5a6cd9d9UL, 0x152d4f1eUL, 0x0c367e5fUL,\n    0x271b2d9cUL, 0x3e001cddUL, 0xb9980012UL, 0xa0833153UL, 0x8bae6290UL,\n    0x92b553d1UL, 0xddf4c516UL, 0xc4eff457UL, 0xefc2a794UL, 0xf6d996d5UL,\n    0xae07bce9UL, 0xb71c8da8UL, 0x9c31de6bUL, 0x852aef2aUL, 0xca6b79edUL,\n    0xd37048acUL, 0xf85d1b6fUL, 0xe1462a2eUL, 0x66de36e1UL, 0x7fc507a0UL,\n    0x54e85463UL, 0x4df36522UL, 0x02b2f3e5UL, 0x1ba9c2a4UL, 0x30849167UL,\n    0x299fa026UL, 0xe4c5aeb8UL, 0xfdde9ff9UL, 0xd6f3cc3aUL, 0xcfe8fd7bUL,\n    0x80a96bbcUL, 0x99b25afdUL, 0xb29f093eUL, 0xab84387fUL, 0x2c1c24b0UL,\n    0x350715f1UL, 0x1e2a4632UL, 0x07317773UL, 0x4870e1b4UL, 0x516bd0f5UL,\n    0x7a468336UL, 0x635db277UL, 0xcbfad74eUL, 0xd2e1e60fUL, 0xf9ccb5ccUL,\n    0xe0d7848dUL, 0xaf96124aUL, 0xb68d230bUL, 0x9da070c8UL, 0x84bb4189UL,\n    0x03235d46UL, 0x1a386c07UL, 0x31153fc4UL, 0x280e0e85UL, 0x674f9842UL,\n    0x7e54a903UL, 0x5579fac0UL, 0x4c62cb81UL, 0x8138c51fUL, 0x9823f45eUL,\n    0xb30ea79dUL, 0xaa1596dcUL, 0xe554001bUL, 0xfc4f315aUL, 0xd7626299UL,\n    0xce7953d8UL, 0x49e14f17UL, 0x50fa7e56UL, 0x7bd72d95UL, 0x62cc1cd4UL,\n    0x2d8d8a13UL, 0x3496bb52UL, 0x1fbbe891UL, 0x06a0d9d0UL, 0x5e7ef3ecUL,\n    0x4765c2adUL, 0x6c48916eUL, 0x7553a02fUL, 0x3a1236e8UL, 0x230907a9UL,\n    0x0824546aUL, 0x113f652bUL, 0x96a779e4UL, 0x8fbc48a5UL, 0xa4911b66UL,\n    0xbd8a2a27UL, 0xf2cbbce0UL, 0xebd08da1UL, 0xc0fdde62UL, 0xd9e6ef23UL,\n    0x14bce1bdUL, 0x0da7d0fcUL, 0x268a833fUL, 0x3f91b27eUL, 0x70d024b9UL,\n    0x69cb15f8UL, 0x42e6463bUL, 0x5bfd777aUL, 0xdc656bb5UL, 0xc57e5af4UL,\n    0xee530937UL, 0xf7483876UL, 0xb809aeb1UL, 0xa1129ff0UL, 0x8a3fcc33UL,\n    0x9324fd72UL\n  },\n  {\n    0x00000000UL, 0x01c26a37UL, 0x0384d46eUL, 0x0246be59UL, 0x0709a8dcUL,\n    0x06cbc2ebUL, 0x048d7cb2UL, 0x054f1685UL, 0x0e1351b8UL, 0x0fd13b8fUL,\n    0x0d9785d6UL, 0x0c55efe1UL, 0x091af964UL, 0x08d89353UL, 0x0a9e2d0aUL,\n    0x0b5c473dUL, 0x1c26a370UL, 0x1de4c947UL, 0x1fa2771eUL, 0x1e601d29UL,\n    0x1b2f0bacUL, 0x1aed619bUL, 0x18abdfc2UL, 0x1969b5f5UL, 0x1235f2c8UL,\n    0x13f798ffUL, 0x11b126a6UL, 0x10734c91UL, 0x153c5a14UL, 0x14fe3023UL,\n    0x16b88e7aUL, 0x177ae44dUL, 0x384d46e0UL, 0x398f2cd7UL, 0x3bc9928eUL,\n    0x3a0bf8b9UL, 0x3f44ee3cUL, 0x3e86840bUL, 0x3cc03a52UL, 0x3d025065UL,\n    0x365e1758UL, 0x379c7d6fUL, 0x35dac336UL, 0x3418a901UL, 0x3157bf84UL,\n    0x3095d5b3UL, 0x32d36beaUL, 0x331101ddUL, 0x246be590UL, 0x25a98fa7UL,\n    0x27ef31feUL, 0x262d5bc9UL, 0x23624d4cUL, 0x22a0277bUL, 0x20e69922UL,\n    0x2124f315UL, 0x2a78b428UL, 0x2bbade1fUL, 0x29fc6046UL, 0x283e0a71UL,\n    0x2d711cf4UL, 0x2cb376c3UL, 0x2ef5c89aUL, 0x2f37a2adUL, 0x709a8dc0UL,\n    0x7158e7f7UL, 0x731e59aeUL, 0x72dc3399UL, 0x7793251cUL, 0x76514f2bUL,\n    0x7417f172UL, 0x75d59b45UL, 0x7e89dc78UL, 0x7f4bb64fUL, 0x7d0d0816UL,\n    0x7ccf6221UL, 0x798074a4UL, 0x78421e93UL, 0x7a04a0caUL, 0x7bc6cafdUL,\n    0x6cbc2eb0UL, 0x6d7e4487UL, 0x6f38fadeUL, 0x6efa90e9UL, 0x6bb5866cUL,\n    0x6a77ec5bUL, 0x68315202UL, 0x69f33835UL, 0x62af7f08UL, 0x636d153fUL,\n    0x612bab66UL, 0x60e9c151UL, 0x65a6d7d4UL, 0x6464bde3UL, 0x662203baUL,\n    0x67e0698dUL, 0x48d7cb20UL, 0x4915a117UL, 0x4b531f4eUL, 0x4a917579UL,\n    0x4fde63fcUL, 0x4e1c09cbUL, 0x4c5ab792UL, 0x4d98dda5UL, 0x46c49a98UL,\n    0x4706f0afUL, 0x45404ef6UL, 0x448224c1UL, 0x41cd3244UL, 0x400f5873UL,\n    0x4249e62aUL, 0x438b8c1dUL, 0x54f16850UL, 0x55330267UL, 0x5775bc3eUL,\n    0x56b7d609UL, 0x53f8c08cUL, 0x523aaabbUL, 0x507c14e2UL, 0x51be7ed5UL,\n    0x5ae239e8UL, 0x5b2053dfUL, 0x5966ed86UL, 0x58a487b1UL, 0x5deb9134UL,\n    0x5c29fb03UL, 0x5e6f455aUL, 0x5fad2f6dUL, 0xe1351b80UL, 0xe0f771b7UL,\n    0xe2b1cfeeUL, 0xe373a5d9UL, 0xe63cb35cUL, 0xe7fed96bUL, 0xe5b86732UL,\n    0xe47a0d05UL, 0xef264a38UL, 0xeee4200fUL, 0xeca29e56UL, 0xed60f461UL,\n    0xe82fe2e4UL, 0xe9ed88d3UL, 0xebab368aUL, 0xea695cbdUL, 0xfd13b8f0UL,\n    0xfcd1d2c7UL, 0xfe976c9eUL, 0xff5506a9UL, 0xfa1a102cUL, 0xfbd87a1bUL,\n    0xf99ec442UL, 0xf85cae75UL, 0xf300e948UL, 0xf2c2837fUL, 0xf0843d26UL,\n    0xf1465711UL, 0xf4094194UL, 0xf5cb2ba3UL, 0xf78d95faUL, 0xf64fffcdUL,\n    0xd9785d60UL, 0xd8ba3757UL, 0xdafc890eUL, 0xdb3ee339UL, 0xde71f5bcUL,\n    0xdfb39f8bUL, 0xddf521d2UL, 0xdc374be5UL, 0xd76b0cd8UL, 0xd6a966efUL,\n    0xd4efd8b6UL, 0xd52db281UL, 0xd062a404UL, 0xd1a0ce33UL, 0xd3e6706aUL,\n    0xd2241a5dUL, 0xc55efe10UL, 0xc49c9427UL, 0xc6da2a7eUL, 0xc7184049UL,\n    0xc25756ccUL, 0xc3953cfbUL, 0xc1d382a2UL, 0xc011e895UL, 0xcb4dafa8UL,\n    0xca8fc59fUL, 0xc8c97bc6UL, 0xc90b11f1UL, 0xcc440774UL, 0xcd866d43UL,\n    0xcfc0d31aUL, 0xce02b92dUL, 0x91af9640UL, 0x906dfc77UL, 0x922b422eUL,\n    0x93e92819UL, 0x96a63e9cUL, 0x976454abUL, 0x9522eaf2UL, 0x94e080c5UL,\n    0x9fbcc7f8UL, 0x9e7eadcfUL, 0x9c381396UL, 0x9dfa79a1UL, 0x98b56f24UL,\n    0x99770513UL, 0x9b31bb4aUL, 0x9af3d17dUL, 0x8d893530UL, 0x8c4b5f07UL,\n    0x8e0de15eUL, 0x8fcf8b69UL, 0x8a809decUL, 0x8b42f7dbUL, 0x89044982UL,\n    0x88c623b5UL, 0x839a6488UL, 0x82580ebfUL, 0x801eb0e6UL, 0x81dcdad1UL,\n    0x8493cc54UL, 0x8551a663UL, 0x8717183aUL, 0x86d5720dUL, 0xa9e2d0a0UL,\n    0xa820ba97UL, 0xaa6604ceUL, 0xaba46ef9UL, 0xaeeb787cUL, 0xaf29124bUL,\n    0xad6fac12UL, 0xacadc625UL, 0xa7f18118UL, 0xa633eb2fUL, 0xa4755576UL,\n    0xa5b73f41UL, 0xa0f829c4UL, 0xa13a43f3UL, 0xa37cfdaaUL, 0xa2be979dUL,\n    0xb5c473d0UL, 0xb40619e7UL, 0xb640a7beUL, 0xb782cd89UL, 0xb2cddb0cUL,\n    0xb30fb13bUL, 0xb1490f62UL, 0xb08b6555UL, 0xbbd72268UL, 0xba15485fUL,\n    0xb853f606UL, 0xb9919c31UL, 0xbcde8ab4UL, 0xbd1ce083UL, 0xbf5a5edaUL,\n    0xbe9834edUL\n  },\n  {\n    0x00000000UL, 0xb8bc6765UL, 0xaa09c88bUL, 0x12b5afeeUL, 0x8f629757UL,\n    0x37def032UL, 0x256b5fdcUL, 0x9dd738b9UL, 0xc5b428efUL, 0x7d084f8aUL,\n    0x6fbde064UL, 0xd7018701UL, 0x4ad6bfb8UL, 0xf26ad8ddUL, 0xe0df7733UL,\n    0x58631056UL, 0x5019579fUL, 0xe8a530faUL, 0xfa109f14UL, 0x42acf871UL,\n    0xdf7bc0c8UL, 0x67c7a7adUL, 0x75720843UL, 0xcdce6f26UL, 0x95ad7f70UL,\n    0x2d111815UL, 0x3fa4b7fbUL, 0x8718d09eUL, 0x1acfe827UL, 0xa2738f42UL,\n    0xb0c620acUL, 0x087a47c9UL, 0xa032af3eUL, 0x188ec85bUL, 0x0a3b67b5UL,\n    0xb28700d0UL, 0x2f503869UL, 0x97ec5f0cUL, 0x8559f0e2UL, 0x3de59787UL,\n    0x658687d1UL, 0xdd3ae0b4UL, 0xcf8f4f5aUL, 0x7733283fUL, 0xeae41086UL,\n    0x525877e3UL, 0x40edd80dUL, 0xf851bf68UL, 0xf02bf8a1UL, 0x48979fc4UL,\n    0x5a22302aUL, 0xe29e574fUL, 0x7f496ff6UL, 0xc7f50893UL, 0xd540a77dUL,\n    0x6dfcc018UL, 0x359fd04eUL, 0x8d23b72bUL, 0x9f9618c5UL, 0x272a7fa0UL,\n    0xbafd4719UL, 0x0241207cUL, 0x10f48f92UL, 0xa848e8f7UL, 0x9b14583dUL,\n    0x23a83f58UL, 0x311d90b6UL, 0x89a1f7d3UL, 0x1476cf6aUL, 0xaccaa80fUL,\n    0xbe7f07e1UL, 0x06c36084UL, 0x5ea070d2UL, 0xe61c17b7UL, 0xf4a9b859UL,\n    0x4c15df3cUL, 0xd1c2e785UL, 0x697e80e0UL, 0x7bcb2f0eUL, 0xc377486bUL,\n    0xcb0d0fa2UL, 0x73b168c7UL, 0x6104c729UL, 0xd9b8a04cUL, 0x446f98f5UL,\n    0xfcd3ff90UL, 0xee66507eUL, 0x56da371bUL, 0x0eb9274dUL, 0xb6054028UL,\n    0xa4b0efc6UL, 0x1c0c88a3UL, 0x81dbb01aUL, 0x3967d77fUL, 0x2bd27891UL,\n    0x936e1ff4UL, 0x3b26f703UL, 0x839a9066UL, 0x912f3f88UL, 0x299358edUL,\n    0xb4446054UL, 0x0cf80731UL, 0x1e4da8dfUL, 0xa6f1cfbaUL, 0xfe92dfecUL,\n    0x462eb889UL, 0x549b1767UL, 0xec277002UL, 0x71f048bbUL, 0xc94c2fdeUL,\n    0xdbf98030UL, 0x6345e755UL, 0x6b3fa09cUL, 0xd383c7f9UL, 0xc1366817UL,\n    0x798a0f72UL, 0xe45d37cbUL, 0x5ce150aeUL, 0x4e54ff40UL, 0xf6e89825UL,\n    0xae8b8873UL, 0x1637ef16UL, 0x048240f8UL, 0xbc3e279dUL, 0x21e91f24UL,\n    0x99557841UL, 0x8be0d7afUL, 0x335cb0caUL, 0xed59b63bUL, 0x55e5d15eUL,\n    0x47507eb0UL, 0xffec19d5UL, 0x623b216cUL, 0xda874609UL, 0xc832e9e7UL,\n    0x708e8e82UL, 0x28ed9ed4UL, 0x9051f9b1UL, 0x82e4565fUL, 0x3a58313aUL,\n    0xa78f0983UL, 0x1f336ee6UL, 0x0d86c108UL, 0xb53aa66dUL, 0xbd40e1a4UL,\n    0x05fc86c1UL, 0x1749292fUL, 0xaff54e4aUL, 0x322276f3UL, 0x8a9e1196UL,\n    0x982bbe78UL, 0x2097d91dUL, 0x78f4c94bUL, 0xc048ae2eUL, 0xd2fd01c0UL,\n    0x6a4166a5UL, 0xf7965e1cUL, 0x4f2a3979UL, 0x5d9f9697UL, 0xe523f1f2UL,\n    0x4d6b1905UL, 0xf5d77e60UL, 0xe762d18eUL, 0x5fdeb6ebUL, 0xc2098e52UL,\n    0x7ab5e937UL, 0x680046d9UL, 0xd0bc21bcUL, 0x88df31eaUL, 0x3063568fUL,\n    0x22d6f961UL, 0x9a6a9e04UL, 0x07bda6bdUL, 0xbf01c1d8UL, 0xadb46e36UL,\n    0x15080953UL, 0x1d724e9aUL, 0xa5ce29ffUL, 0xb77b8611UL, 0x0fc7e174UL,\n    0x9210d9cdUL, 0x2aacbea8UL, 0x38191146UL, 0x80a57623UL, 0xd8c66675UL,\n    0x607a0110UL, 0x72cfaefeUL, 0xca73c99bUL, 0x57a4f122UL, 0xef189647UL,\n    0xfdad39a9UL, 0x45115eccUL, 0x764dee06UL, 0xcef18963UL, 0xdc44268dUL,\n    0x64f841e8UL, 0xf92f7951UL, 0x41931e34UL, 0x5326b1daUL, 0xeb9ad6bfUL,\n    0xb3f9c6e9UL, 0x0b45a18cUL, 0x19f00e62UL, 0xa14c6907UL, 0x3c9b51beUL,\n    0x842736dbUL, 0x96929935UL, 0x2e2efe50UL, 0x2654b999UL, 0x9ee8defcUL,\n    0x8c5d7112UL, 0x34e11677UL, 0xa9362eceUL, 0x118a49abUL, 0x033fe645UL,\n    0xbb838120UL, 0xe3e09176UL, 0x5b5cf613UL, 0x49e959fdUL, 0xf1553e98UL,\n    0x6c820621UL, 0xd43e6144UL, 0xc68bceaaUL, 0x7e37a9cfUL, 0xd67f4138UL,\n    0x6ec3265dUL, 0x7c7689b3UL, 0xc4caeed6UL, 0x591dd66fUL, 0xe1a1b10aUL,\n    0xf3141ee4UL, 0x4ba87981UL, 0x13cb69d7UL, 0xab770eb2UL, 0xb9c2a15cUL,\n    0x017ec639UL, 0x9ca9fe80UL, 0x241599e5UL, 0x36a0360bUL, 0x8e1c516eUL,\n    0x866616a7UL, 0x3eda71c2UL, 0x2c6fde2cUL, 0x94d3b949UL, 0x090481f0UL,\n    0xb1b8e695UL, 0xa30d497bUL, 0x1bb12e1eUL, 0x43d23e48UL, 0xfb6e592dUL,\n    0xe9dbf6c3UL, 0x516791a6UL, 0xccb0a91fUL, 0x740cce7aUL, 0x66b96194UL,\n    0xde0506f1UL\n  },\n  {\n    0x00000000UL, 0x96300777UL, 0x2c610eeeUL, 0xba510999UL, 0x19c46d07UL,\n    0x8ff46a70UL, 0x35a563e9UL, 0xa395649eUL, 0x3288db0eUL, 0xa4b8dc79UL,\n    0x1ee9d5e0UL, 0x88d9d297UL, 0x2b4cb609UL, 0xbd7cb17eUL, 0x072db8e7UL,\n    0x911dbf90UL, 0x6410b71dUL, 0xf220b06aUL, 0x4871b9f3UL, 0xde41be84UL,\n    0x7dd4da1aUL, 0xebe4dd6dUL, 0x51b5d4f4UL, 0xc785d383UL, 0x56986c13UL,\n    0xc0a86b64UL, 0x7af962fdUL, 0xecc9658aUL, 0x4f5c0114UL, 0xd96c0663UL,\n    0x633d0ffaUL, 0xf50d088dUL, 0xc8206e3bUL, 0x5e10694cUL, 0xe44160d5UL,\n    0x727167a2UL, 0xd1e4033cUL, 0x47d4044bUL, 0xfd850dd2UL, 0x6bb50aa5UL,\n    0xfaa8b535UL, 0x6c98b242UL, 0xd6c9bbdbUL, 0x40f9bcacUL, 0xe36cd832UL,\n    0x755cdf45UL, 0xcf0dd6dcUL, 0x593dd1abUL, 0xac30d926UL, 0x3a00de51UL,\n    0x8051d7c8UL, 0x1661d0bfUL, 0xb5f4b421UL, 0x23c4b356UL, 0x9995bacfUL,\n    0x0fa5bdb8UL, 0x9eb80228UL, 0x0888055fUL, 0xb2d90cc6UL, 0x24e90bb1UL,\n    0x877c6f2fUL, 0x114c6858UL, 0xab1d61c1UL, 0x3d2d66b6UL, 0x9041dc76UL,\n    0x0671db01UL, 0xbc20d298UL, 0x2a10d5efUL, 0x8985b171UL, 0x1fb5b606UL,\n    0xa5e4bf9fUL, 0x33d4b8e8UL, 0xa2c90778UL, 0x34f9000fUL, 0x8ea80996UL,\n    0x18980ee1UL, 0xbb0d6a7fUL, 0x2d3d6d08UL, 0x976c6491UL, 0x015c63e6UL,\n    0xf4516b6bUL, 0x62616c1cUL, 0xd8306585UL, 0x4e0062f2UL, 0xed95066cUL,\n    0x7ba5011bUL, 0xc1f40882UL, 0x57c40ff5UL, 0xc6d9b065UL, 0x50e9b712UL,\n    0xeab8be8bUL, 0x7c88b9fcUL, 0xdf1ddd62UL, 0x492dda15UL, 0xf37cd38cUL,\n    0x654cd4fbUL, 0x5861b24dUL, 0xce51b53aUL, 0x7400bca3UL, 0xe230bbd4UL,\n    0x41a5df4aUL, 0xd795d83dUL, 0x6dc4d1a4UL, 0xfbf4d6d3UL, 0x6ae96943UL,\n    0xfcd96e34UL, 0x468867adUL, 0xd0b860daUL, 0x732d0444UL, 0xe51d0333UL,\n    0x5f4c0aaaUL, 0xc97c0dddUL, 0x3c710550UL, 0xaa410227UL, 0x10100bbeUL,\n    0x86200cc9UL, 0x25b56857UL, 0xb3856f20UL, 0x09d466b9UL, 0x9fe461ceUL,\n    0x0ef9de5eUL, 0x98c9d929UL, 0x2298d0b0UL, 0xb4a8d7c7UL, 0x173db359UL,\n    0x810db42eUL, 0x3b5cbdb7UL, 0xad6cbac0UL, 0x2083b8edUL, 0xb6b3bf9aUL,\n    0x0ce2b603UL, 0x9ad2b174UL, 0x3947d5eaUL, 0xaf77d29dUL, 0x1526db04UL,\n    0x8316dc73UL, 0x120b63e3UL, 0x843b6494UL, 0x3e6a6d0dUL, 0xa85a6a7aUL,\n    0x0bcf0ee4UL, 0x9dff0993UL, 0x27ae000aUL, 0xb19e077dUL, 0x44930ff0UL,\n    0xd2a30887UL, 0x68f2011eUL, 0xfec20669UL, 0x5d5762f7UL, 0xcb676580UL,\n    0x71366c19UL, 0xe7066b6eUL, 0x761bd4feUL, 0xe02bd389UL, 0x5a7ada10UL,\n    0xcc4add67UL, 0x6fdfb9f9UL, 0xf9efbe8eUL, 0x43beb717UL, 0xd58eb060UL,\n    0xe8a3d6d6UL, 0x7e93d1a1UL, 0xc4c2d838UL, 0x52f2df4fUL, 0xf167bbd1UL,\n    0x6757bca6UL, 0xdd06b53fUL, 0x4b36b248UL, 0xda2b0dd8UL, 0x4c1b0aafUL,\n    0xf64a0336UL, 0x607a0441UL, 0xc3ef60dfUL, 0x55df67a8UL, 0xef8e6e31UL,\n    0x79be6946UL, 0x8cb361cbUL, 0x1a8366bcUL, 0xa0d26f25UL, 0x36e26852UL,\n    0x95770cccUL, 0x03470bbbUL, 0xb9160222UL, 0x2f260555UL, 0xbe3bbac5UL,\n    0x280bbdb2UL, 0x925ab42bUL, 0x046ab35cUL, 0xa7ffd7c2UL, 0x31cfd0b5UL,\n    0x8b9ed92cUL, 0x1daede5bUL, 0xb0c2649bUL, 0x26f263ecUL, 0x9ca36a75UL,\n    0x0a936d02UL, 0xa906099cUL, 0x3f360eebUL, 0x85670772UL, 0x13570005UL,\n    0x824abf95UL, 0x147ab8e2UL, 0xae2bb17bUL, 0x381bb60cUL, 0x9b8ed292UL,\n    0x0dbed5e5UL, 0xb7efdc7cUL, 0x21dfdb0bUL, 0xd4d2d386UL, 0x42e2d4f1UL,\n    0xf8b3dd68UL, 0x6e83da1fUL, 0xcd16be81UL, 0x5b26b9f6UL, 0xe177b06fUL,\n    0x7747b718UL, 0xe65a0888UL, 0x706a0fffUL, 0xca3b0666UL, 0x5c0b0111UL,\n    0xff9e658fUL, 0x69ae62f8UL, 0xd3ff6b61UL, 0x45cf6c16UL, 0x78e20aa0UL,\n    0xeed20dd7UL, 0x5483044eUL, 0xc2b30339UL, 0x612667a7UL, 0xf71660d0UL,\n    0x4d476949UL, 0xdb776e3eUL, 0x4a6ad1aeUL, 0xdc5ad6d9UL, 0x660bdf40UL,\n    0xf03bd837UL, 0x53aebca9UL, 0xc59ebbdeUL, 0x7fcfb247UL, 0xe9ffb530UL,\n    0x1cf2bdbdUL, 0x8ac2bacaUL, 0x3093b353UL, 0xa6a3b424UL, 0x0536d0baUL,\n    0x9306d7cdUL, 0x2957de54UL, 0xbf67d923UL, 0x2e7a66b3UL, 0xb84a61c4UL,\n    0x021b685dUL, 0x942b6f2aUL, 0x37be0bb4UL, 0xa18e0cc3UL, 0x1bdf055aUL,\n    0x8def022dUL\n  },\n  {\n    0x00000000UL, 0x41311b19UL, 0x82623632UL, 0xc3532d2bUL, 0x04c56c64UL,\n    0x45f4777dUL, 0x86a75a56UL, 0xc796414fUL, 0x088ad9c8UL, 0x49bbc2d1UL,\n    0x8ae8effaUL, 0xcbd9f4e3UL, 0x0c4fb5acUL, 0x4d7eaeb5UL, 0x8e2d839eUL,\n    0xcf1c9887UL, 0x5112c24aUL, 0x1023d953UL, 0xd370f478UL, 0x9241ef61UL,\n    0x55d7ae2eUL, 0x14e6b537UL, 0xd7b5981cUL, 0x96848305UL, 0x59981b82UL,\n    0x18a9009bUL, 0xdbfa2db0UL, 0x9acb36a9UL, 0x5d5d77e6UL, 0x1c6c6cffUL,\n    0xdf3f41d4UL, 0x9e0e5acdUL, 0xa2248495UL, 0xe3159f8cUL, 0x2046b2a7UL,\n    0x6177a9beUL, 0xa6e1e8f1UL, 0xe7d0f3e8UL, 0x2483dec3UL, 0x65b2c5daUL,\n    0xaaae5d5dUL, 0xeb9f4644UL, 0x28cc6b6fUL, 0x69fd7076UL, 0xae6b3139UL,\n    0xef5a2a20UL, 0x2c09070bUL, 0x6d381c12UL, 0xf33646dfUL, 0xb2075dc6UL,\n    0x715470edUL, 0x30656bf4UL, 0xf7f32abbUL, 0xb6c231a2UL, 0x75911c89UL,\n    0x34a00790UL, 0xfbbc9f17UL, 0xba8d840eUL, 0x79dea925UL, 0x38efb23cUL,\n    0xff79f373UL, 0xbe48e86aUL, 0x7d1bc541UL, 0x3c2ade58UL, 0x054f79f0UL,\n    0x447e62e9UL, 0x872d4fc2UL, 0xc61c54dbUL, 0x018a1594UL, 0x40bb0e8dUL,\n    0x83e823a6UL, 0xc2d938bfUL, 0x0dc5a038UL, 0x4cf4bb21UL, 0x8fa7960aUL,\n    0xce968d13UL, 0x0900cc5cUL, 0x4831d745UL, 0x8b62fa6eUL, 0xca53e177UL,\n    0x545dbbbaUL, 0x156ca0a3UL, 0xd63f8d88UL, 0x970e9691UL, 0x5098d7deUL,\n    0x11a9ccc7UL, 0xd2fae1ecUL, 0x93cbfaf5UL, 0x5cd76272UL, 0x1de6796bUL,\n    0xdeb55440UL, 0x9f844f59UL, 0x58120e16UL, 0x1923150fUL, 0xda703824UL,\n    0x9b41233dUL, 0xa76bfd65UL, 0xe65ae67cUL, 0x2509cb57UL, 0x6438d04eUL,\n    0xa3ae9101UL, 0xe29f8a18UL, 0x21cca733UL, 0x60fdbc2aUL, 0xafe124adUL,\n    0xeed03fb4UL, 0x2d83129fUL, 0x6cb20986UL, 0xab2448c9UL, 0xea1553d0UL,\n    0x29467efbUL, 0x687765e2UL, 0xf6793f2fUL, 0xb7482436UL, 0x741b091dUL,\n    0x352a1204UL, 0xf2bc534bUL, 0xb38d4852UL, 0x70de6579UL, 0x31ef7e60UL,\n    0xfef3e6e7UL, 0xbfc2fdfeUL, 0x7c91d0d5UL, 0x3da0cbccUL, 0xfa368a83UL,\n    0xbb07919aUL, 0x7854bcb1UL, 0x3965a7a8UL, 0x4b98833bUL, 0x0aa99822UL,\n    0xc9fab509UL, 0x88cbae10UL, 0x4f5def5fUL, 0x0e6cf446UL, 0xcd3fd96dUL,\n    0x8c0ec274UL, 0x43125af3UL, 0x022341eaUL, 0xc1706cc1UL, 0x804177d8UL,\n    0x47d73697UL, 0x06e62d8eUL, 0xc5b500a5UL, 0x84841bbcUL, 0x1a8a4171UL,\n    0x5bbb5a68UL, 0x98e87743UL, 0xd9d96c5aUL, 0x1e4f2d15UL, 0x5f7e360cUL,\n    0x9c2d1b27UL, 0xdd1c003eUL, 0x120098b9UL, 0x533183a0UL, 0x9062ae8bUL,\n    0xd153b592UL, 0x16c5f4ddUL, 0x57f4efc4UL, 0x94a7c2efUL, 0xd596d9f6UL,\n    0xe9bc07aeUL, 0xa88d1cb7UL, 0x6bde319cUL, 0x2aef2a85UL, 0xed796bcaUL,\n    0xac4870d3UL, 0x6f1b5df8UL, 0x2e2a46e1UL, 0xe136de66UL, 0xa007c57fUL,\n    0x6354e854UL, 0x2265f34dUL, 0xe5f3b202UL, 0xa4c2a91bUL, 0x67918430UL,\n    0x26a09f29UL, 0xb8aec5e4UL, 0xf99fdefdUL, 0x3accf3d6UL, 0x7bfde8cfUL,\n    0xbc6ba980UL, 0xfd5ab299UL, 0x3e099fb2UL, 0x7f3884abUL, 0xb0241c2cUL,\n    0xf1150735UL, 0x32462a1eUL, 0x73773107UL, 0xb4e17048UL, 0xf5d06b51UL,\n    0x3683467aUL, 0x77b25d63UL, 0x4ed7facbUL, 0x0fe6e1d2UL, 0xccb5ccf9UL,\n    0x8d84d7e0UL, 0x4a1296afUL, 0x0b238db6UL, 0xc870a09dUL, 0x8941bb84UL,\n    0x465d2303UL, 0x076c381aUL, 0xc43f1531UL, 0x850e0e28UL, 0x42984f67UL,\n    0x03a9547eUL, 0xc0fa7955UL, 0x81cb624cUL, 0x1fc53881UL, 0x5ef42398UL,\n    0x9da70eb3UL, 0xdc9615aaUL, 0x1b0054e5UL, 0x5a314ffcUL, 0x996262d7UL,\n    0xd85379ceUL, 0x174fe149UL, 0x567efa50UL, 0x952dd77bUL, 0xd41ccc62UL,\n    0x138a8d2dUL, 0x52bb9634UL, 0x91e8bb1fUL, 0xd0d9a006UL, 0xecf37e5eUL,\n    0xadc26547UL, 0x6e91486cUL, 0x2fa05375UL, 0xe836123aUL, 0xa9070923UL,\n    0x6a542408UL, 0x2b653f11UL, 0xe479a796UL, 0xa548bc8fUL, 0x661b91a4UL,\n    0x272a8abdUL, 0xe0bccbf2UL, 0xa18dd0ebUL, 0x62defdc0UL, 0x23efe6d9UL,\n    0xbde1bc14UL, 0xfcd0a70dUL, 0x3f838a26UL, 0x7eb2913fUL, 0xb924d070UL,\n    0xf815cb69UL, 0x3b46e642UL, 0x7a77fd5bUL, 0xb56b65dcUL, 0xf45a7ec5UL,\n    0x370953eeUL, 0x763848f7UL, 0xb1ae09b8UL, 0xf09f12a1UL, 0x33cc3f8aUL,\n    0x72fd2493UL\n  },\n  {\n    0x00000000UL, 0x376ac201UL, 0x6ed48403UL, 0x59be4602UL, 0xdca80907UL,\n    0xebc2cb06UL, 0xb27c8d04UL, 0x85164f05UL, 0xb851130eUL, 0x8f3bd10fUL,\n    0xd685970dUL, 0xe1ef550cUL, 0x64f91a09UL, 0x5393d808UL, 0x0a2d9e0aUL,\n    0x3d475c0bUL, 0x70a3261cUL, 0x47c9e41dUL, 0x1e77a21fUL, 0x291d601eUL,\n    0xac0b2f1bUL, 0x9b61ed1aUL, 0xc2dfab18UL, 0xf5b56919UL, 0xc8f23512UL,\n    0xff98f713UL, 0xa626b111UL, 0x914c7310UL, 0x145a3c15UL, 0x2330fe14UL,\n    0x7a8eb816UL, 0x4de47a17UL, 0xe0464d38UL, 0xd72c8f39UL, 0x8e92c93bUL,\n    0xb9f80b3aUL, 0x3cee443fUL, 0x0b84863eUL, 0x523ac03cUL, 0x6550023dUL,\n    0x58175e36UL, 0x6f7d9c37UL, 0x36c3da35UL, 0x01a91834UL, 0x84bf5731UL,\n    0xb3d59530UL, 0xea6bd332UL, 0xdd011133UL, 0x90e56b24UL, 0xa78fa925UL,\n    0xfe31ef27UL, 0xc95b2d26UL, 0x4c4d6223UL, 0x7b27a022UL, 0x2299e620UL,\n    0x15f32421UL, 0x28b4782aUL, 0x1fdeba2bUL, 0x4660fc29UL, 0x710a3e28UL,\n    0xf41c712dUL, 0xc376b32cUL, 0x9ac8f52eUL, 0xada2372fUL, 0xc08d9a70UL,\n    0xf7e75871UL, 0xae591e73UL, 0x9933dc72UL, 0x1c259377UL, 0x2b4f5176UL,\n    0x72f11774UL, 0x459bd575UL, 0x78dc897eUL, 0x4fb64b7fUL, 0x16080d7dUL,\n    0x2162cf7cUL, 0xa4748079UL, 0x931e4278UL, 0xcaa0047aUL, 0xfdcac67bUL,\n    0xb02ebc6cUL, 0x87447e6dUL, 0xdefa386fUL, 0xe990fa6eUL, 0x6c86b56bUL,\n    0x5bec776aUL, 0x02523168UL, 0x3538f369UL, 0x087faf62UL, 0x3f156d63UL,\n    0x66ab2b61UL, 0x51c1e960UL, 0xd4d7a665UL, 0xe3bd6464UL, 0xba032266UL,\n    0x8d69e067UL, 0x20cbd748UL, 0x17a11549UL, 0x4e1f534bUL, 0x7975914aUL,\n    0xfc63de4fUL, 0xcb091c4eUL, 0x92b75a4cUL, 0xa5dd984dUL, 0x989ac446UL,\n    0xaff00647UL, 0xf64e4045UL, 0xc1248244UL, 0x4432cd41UL, 0x73580f40UL,\n    0x2ae64942UL, 0x1d8c8b43UL, 0x5068f154UL, 0x67023355UL, 0x3ebc7557UL,\n    0x09d6b756UL, 0x8cc0f853UL, 0xbbaa3a52UL, 0xe2147c50UL, 0xd57ebe51UL,\n    0xe839e25aUL, 0xdf53205bUL, 0x86ed6659UL, 0xb187a458UL, 0x3491eb5dUL,\n    0x03fb295cUL, 0x5a456f5eUL, 0x6d2fad5fUL, 0x801b35e1UL, 0xb771f7e0UL,\n    0xeecfb1e2UL, 0xd9a573e3UL, 0x5cb33ce6UL, 0x6bd9fee7UL, 0x3267b8e5UL,\n    0x050d7ae4UL, 0x384a26efUL, 0x0f20e4eeUL, 0x569ea2ecUL, 0x61f460edUL,\n    0xe4e22fe8UL, 0xd388ede9UL, 0x8a36abebUL, 0xbd5c69eaUL, 0xf0b813fdUL,\n    0xc7d2d1fcUL, 0x9e6c97feUL, 0xa90655ffUL, 0x2c101afaUL, 0x1b7ad8fbUL,\n    0x42c49ef9UL, 0x75ae5cf8UL, 0x48e900f3UL, 0x7f83c2f2UL, 0x263d84f0UL,\n    0x115746f1UL, 0x944109f4UL, 0xa32bcbf5UL, 0xfa958df7UL, 0xcdff4ff6UL,\n    0x605d78d9UL, 0x5737bad8UL, 0x0e89fcdaUL, 0x39e33edbUL, 0xbcf571deUL,\n    0x8b9fb3dfUL, 0xd221f5ddUL, 0xe54b37dcUL, 0xd80c6bd7UL, 0xef66a9d6UL,\n    0xb6d8efd4UL, 0x81b22dd5UL, 0x04a462d0UL, 0x33cea0d1UL, 0x6a70e6d3UL,\n    0x5d1a24d2UL, 0x10fe5ec5UL, 0x27949cc4UL, 0x7e2adac6UL, 0x494018c7UL,\n    0xcc5657c2UL, 0xfb3c95c3UL, 0xa282d3c1UL, 0x95e811c0UL, 0xa8af4dcbUL,\n    0x9fc58fcaUL, 0xc67bc9c8UL, 0xf1110bc9UL, 0x740744ccUL, 0x436d86cdUL,\n    0x1ad3c0cfUL, 0x2db902ceUL, 0x4096af91UL, 0x77fc6d90UL, 0x2e422b92UL,\n    0x1928e993UL, 0x9c3ea696UL, 0xab546497UL, 0xf2ea2295UL, 0xc580e094UL,\n    0xf8c7bc9fUL, 0xcfad7e9eUL, 0x9613389cUL, 0xa179fa9dUL, 0x246fb598UL,\n    0x13057799UL, 0x4abb319bUL, 0x7dd1f39aUL, 0x3035898dUL, 0x075f4b8cUL,\n    0x5ee10d8eUL, 0x698bcf8fUL, 0xec9d808aUL, 0xdbf7428bUL, 0x82490489UL,\n    0xb523c688UL, 0x88649a83UL, 0xbf0e5882UL, 0xe6b01e80UL, 0xd1dadc81UL,\n    0x54cc9384UL, 0x63a65185UL, 0x3a181787UL, 0x0d72d586UL, 0xa0d0e2a9UL,\n    0x97ba20a8UL, 0xce0466aaUL, 0xf96ea4abUL, 0x7c78ebaeUL, 0x4b1229afUL,\n    0x12ac6fadUL, 0x25c6adacUL, 0x1881f1a7UL, 0x2feb33a6UL, 0x765575a4UL,\n    0x413fb7a5UL, 0xc429f8a0UL, 0xf3433aa1UL, 0xaafd7ca3UL, 0x9d97bea2UL,\n    0xd073c4b5UL, 0xe71906b4UL, 0xbea740b6UL, 0x89cd82b7UL, 0x0cdbcdb2UL,\n    0x3bb10fb3UL, 0x620f49b1UL, 0x55658bb0UL, 0x6822d7bbUL, 0x5f4815baUL,\n    0x06f653b8UL, 0x319c91b9UL, 0xb48adebcUL, 0x83e01cbdUL, 0xda5e5abfUL,\n    0xed3498beUL\n  },\n  {\n    0x00000000UL, 0x6567bcb8UL, 0x8bc809aaUL, 0xeeafb512UL, 0x5797628fUL,\n    0x32f0de37UL, 0xdc5f6b25UL, 0xb938d79dUL, 0xef28b4c5UL, 0x8a4f087dUL,\n    0x64e0bd6fUL, 0x018701d7UL, 0xb8bfd64aUL, 0xddd86af2UL, 0x3377dfe0UL,\n    0x56106358UL, 0x9f571950UL, 0xfa30a5e8UL, 0x149f10faUL, 0x71f8ac42UL,\n    0xc8c07bdfUL, 0xada7c767UL, 0x43087275UL, 0x266fcecdUL, 0x707fad95UL,\n    0x1518112dUL, 0xfbb7a43fUL, 0x9ed01887UL, 0x27e8cf1aUL, 0x428f73a2UL,\n    0xac20c6b0UL, 0xc9477a08UL, 0x3eaf32a0UL, 0x5bc88e18UL, 0xb5673b0aUL,\n    0xd00087b2UL, 0x6938502fUL, 0x0c5fec97UL, 0xe2f05985UL, 0x8797e53dUL,\n    0xd1878665UL, 0xb4e03addUL, 0x5a4f8fcfUL, 0x3f283377UL, 0x8610e4eaUL,\n    0xe3775852UL, 0x0dd8ed40UL, 0x68bf51f8UL, 0xa1f82bf0UL, 0xc49f9748UL,\n    0x2a30225aUL, 0x4f579ee2UL, 0xf66f497fUL, 0x9308f5c7UL, 0x7da740d5UL,\n    0x18c0fc6dUL, 0x4ed09f35UL, 0x2bb7238dUL, 0xc518969fUL, 0xa07f2a27UL,\n    0x1947fdbaUL, 0x7c204102UL, 0x928ff410UL, 0xf7e848a8UL, 0x3d58149bUL,\n    0x583fa823UL, 0xb6901d31UL, 0xd3f7a189UL, 0x6acf7614UL, 0x0fa8caacUL,\n    0xe1077fbeUL, 0x8460c306UL, 0xd270a05eUL, 0xb7171ce6UL, 0x59b8a9f4UL,\n    0x3cdf154cUL, 0x85e7c2d1UL, 0xe0807e69UL, 0x0e2fcb7bUL, 0x6b4877c3UL,\n    0xa20f0dcbUL, 0xc768b173UL, 0x29c70461UL, 0x4ca0b8d9UL, 0xf5986f44UL,\n    0x90ffd3fcUL, 0x7e5066eeUL, 0x1b37da56UL, 0x4d27b90eUL, 0x284005b6UL,\n    0xc6efb0a4UL, 0xa3880c1cUL, 0x1ab0db81UL, 0x7fd76739UL, 0x9178d22bUL,\n    0xf41f6e93UL, 0x03f7263bUL, 0x66909a83UL, 0x883f2f91UL, 0xed589329UL,\n    0x546044b4UL, 0x3107f80cUL, 0xdfa84d1eUL, 0xbacff1a6UL, 0xecdf92feUL,\n    0x89b82e46UL, 0x67179b54UL, 0x027027ecUL, 0xbb48f071UL, 0xde2f4cc9UL,\n    0x3080f9dbUL, 0x55e74563UL, 0x9ca03f6bUL, 0xf9c783d3UL, 0x176836c1UL,\n    0x720f8a79UL, 0xcb375de4UL, 0xae50e15cUL, 0x40ff544eUL, 0x2598e8f6UL,\n    0x73888baeUL, 0x16ef3716UL, 0xf8408204UL, 0x9d273ebcUL, 0x241fe921UL,\n    0x41785599UL, 0xafd7e08bUL, 0xcab05c33UL, 0x3bb659edUL, 0x5ed1e555UL,\n    0xb07e5047UL, 0xd519ecffUL, 0x6c213b62UL, 0x094687daUL, 0xe7e932c8UL,\n    0x828e8e70UL, 0xd49eed28UL, 0xb1f95190UL, 0x5f56e482UL, 0x3a31583aUL,\n    0x83098fa7UL, 0xe66e331fUL, 0x08c1860dUL, 0x6da63ab5UL, 0xa4e140bdUL,\n    0xc186fc05UL, 0x2f294917UL, 0x4a4ef5afUL, 0xf3762232UL, 0x96119e8aUL,\n    0x78be2b98UL, 0x1dd99720UL, 0x4bc9f478UL, 0x2eae48c0UL, 0xc001fdd2UL,\n    0xa566416aUL, 0x1c5e96f7UL, 0x79392a4fUL, 0x97969f5dUL, 0xf2f123e5UL,\n    0x05196b4dUL, 0x607ed7f5UL, 0x8ed162e7UL, 0xebb6de5fUL, 0x528e09c2UL,\n    0x37e9b57aUL, 0xd9460068UL, 0xbc21bcd0UL, 0xea31df88UL, 0x8f566330UL,\n    0x61f9d622UL, 0x049e6a9aUL, 0xbda6bd07UL, 0xd8c101bfUL, 0x366eb4adUL,\n    0x53090815UL, 0x9a4e721dUL, 0xff29cea5UL, 0x11867bb7UL, 0x74e1c70fUL,\n    0xcdd91092UL, 0xa8beac2aUL, 0x46111938UL, 0x2376a580UL, 0x7566c6d8UL,\n    0x10017a60UL, 0xfeaecf72UL, 0x9bc973caUL, 0x22f1a457UL, 0x479618efUL,\n    0xa939adfdUL, 0xcc5e1145UL, 0x06ee4d76UL, 0x6389f1ceUL, 0x8d2644dcUL,\n    0xe841f864UL, 0x51792ff9UL, 0x341e9341UL, 0xdab12653UL, 0xbfd69aebUL,\n    0xe9c6f9b3UL, 0x8ca1450bUL, 0x620ef019UL, 0x07694ca1UL, 0xbe519b3cUL,\n    0xdb362784UL, 0x35999296UL, 0x50fe2e2eUL, 0x99b95426UL, 0xfcdee89eUL,\n    0x12715d8cUL, 0x7716e134UL, 0xce2e36a9UL, 0xab498a11UL, 0x45e63f03UL,\n    0x208183bbUL, 0x7691e0e3UL, 0x13f65c5bUL, 0xfd59e949UL, 0x983e55f1UL,\n    0x2106826cUL, 0x44613ed4UL, 0xaace8bc6UL, 0xcfa9377eUL, 0x38417fd6UL,\n    0x5d26c36eUL, 0xb389767cUL, 0xd6eecac4UL, 0x6fd61d59UL, 0x0ab1a1e1UL,\n    0xe41e14f3UL, 0x8179a84bUL, 0xd769cb13UL, 0xb20e77abUL, 0x5ca1c2b9UL,\n    0x39c67e01UL, 0x80fea99cUL, 0xe5991524UL, 0x0b36a036UL, 0x6e511c8eUL,\n    0xa7166686UL, 0xc271da3eUL, 0x2cde6f2cUL, 0x49b9d394UL, 0xf0810409UL,\n    0x95e6b8b1UL, 0x7b490da3UL, 0x1e2eb11bUL, 0x483ed243UL, 0x2d596efbUL,\n    0xc3f6dbe9UL, 0xa6916751UL, 0x1fa9b0ccUL, 0x7ace0c74UL, 0x9461b966UL,\n    0xf10605deUL\n#endif\n  }\n};\n"
  },
  {
    "path": "Projects/Libraries/CSBase/Source/zlib/deflate.c",
    "content": "/* deflate.c -- compress data using the deflation algorithm\n * Copyright (C) 1995-2017 Jean-loup Gailly and Mark Adler\n * For conditions of distribution and use, see copyright notice in zlib.h\n */\n\n/*\n *  ALGORITHM\n *\n *      The \"deflation\" process depends on being able to identify portions\n *      of the input text which are identical to earlier input (within a\n *      sliding window trailing behind the input currently being processed).\n *\n *      The most straightforward technique turns out to be the fastest for\n *      most input files: try all possible matches and select the longest.\n *      The key feature of this algorithm is that insertions into the string\n *      dictionary are very simple and thus fast, and deletions are avoided\n *      completely. Insertions are performed at each input character, whereas\n *      string matches are performed only when the previous match ends. So it\n *      is preferable to spend more time in matches to allow very fast string\n *      insertions and avoid deletions. The matching algorithm for small\n *      strings is inspired from that of Rabin & Karp. A brute force approach\n *      is used to find longer strings when a small match has been found.\n *      A similar algorithm is used in comic (by Jan-Mark Wams) and freeze\n *      (by Leonid Broukhis).\n *         A previous version of this file used a more sophisticated algorithm\n *      (by Fiala and Greene) which is guaranteed to run in linear amortized\n *      time, but has a larger average cost, uses more memory and is patented.\n *      However the F&G algorithm may be faster for some highly redundant\n *      files if the parameter max_chain_length (described below) is too large.\n *\n *  ACKNOWLEDGEMENTS\n *\n *      The idea of lazy evaluation of matches is due to Jan-Mark Wams, and\n *      I found it in 'freeze' written by Leonid Broukhis.\n *      Thanks to many people for bug reports and testing.\n *\n *  REFERENCES\n *\n *      Deutsch, L.P.,\"DEFLATE Compressed Data Format Specification\".\n *      Available in http://tools.ietf.org/html/rfc1951\n *\n *      A description of the Rabin and Karp algorithm is given in the book\n *         \"Algorithms\" by R. Sedgewick, Addison-Wesley, p252.\n *\n *      Fiala,E.R., and Greene,D.H.\n *         Data Compression with Finite Windows, Comm.ACM, 32,4 (1989) 490-595\n *\n */\n\n/* @(#) $Id$ */\n\n#include \"deflate.h\"\n\nconst char deflate_copyright[] =\n   \" deflate 1.2.11 Copyright 1995-2017 Jean-loup Gailly and Mark Adler \";\n/*\n  If you use the zlib library in a product, an acknowledgment is welcome\n  in the documentation of your product. If for some reason you cannot\n  include such an acknowledgment, I would appreciate that you keep this\n  copyright string in the executable of your product.\n */\n\n/* ===========================================================================\n *  Function prototypes.\n */\ntypedef enum {\n    need_more,      /* block not completed, need more input or more output */\n    block_done,     /* block flush performed */\n    finish_started, /* finish started, need only more output at next deflate */\n    finish_done     /* finish done, accept no more input or output */\n} block_state;\n\ntypedef block_state (*compress_func) OF((deflate_state *s, int flush));\n/* Compression function. Returns the block state after the call. */\n\nlocal int deflateStateCheck      OF((z_streamp strm));\nlocal void slide_hash     OF((deflate_state *s));\nlocal void fill_window    OF((deflate_state *s));\nlocal block_state deflate_stored OF((deflate_state *s, int flush));\nlocal block_state deflate_fast   OF((deflate_state *s, int flush));\n#ifndef FASTEST\nlocal block_state deflate_slow   OF((deflate_state *s, int flush));\n#endif\nlocal block_state deflate_rle    OF((deflate_state *s, int flush));\nlocal block_state deflate_huff   OF((deflate_state *s, int flush));\nlocal void lm_init        OF((deflate_state *s));\nlocal void putShortMSB    OF((deflate_state *s, uInt b));\nlocal void flush_pending  OF((z_streamp strm));\nlocal unsigned read_buf   OF((z_streamp strm, Bytef *buf, unsigned size));\n#ifdef ASMV\n#  pragma message(\"Assembler code may have bugs -- use at your own risk\")\n      void match_init OF((void)); /* asm code initialization */\n      uInt longest_match  OF((deflate_state *s, IPos cur_match));\n#else\nlocal uInt longest_match  OF((deflate_state *s, IPos cur_match));\n#endif\n\n#ifdef ZLIB_DEBUG\nlocal  void check_match OF((deflate_state *s, IPos start, IPos match,\n                            int length));\n#endif\n\n/* ===========================================================================\n * Local data\n */\n\n#define NIL 0\n/* Tail of hash chains */\n\n#ifndef TOO_FAR\n#  define TOO_FAR 4096\n#endif\n/* Matches of length 3 are discarded if their distance exceeds TOO_FAR */\n\n/* Values for max_lazy_match, good_match and max_chain_length, depending on\n * the desired pack level (0..9). The values given below have been tuned to\n * exclude worst case performance for pathological files. Better values may be\n * found for specific files.\n */\ntypedef struct config_s {\n   ush good_length; /* reduce lazy search above this match length */\n   ush max_lazy;    /* do not perform lazy search above this match length */\n   ush nice_length; /* quit search above this match length */\n   ush max_chain;\n   compress_func func;\n} config;\n\n#ifdef FASTEST\nlocal const config configuration_table[2] = {\n/*      good lazy nice chain */\n/* 0 */ {0,    0,  0,    0, deflate_stored},  /* store only */\n/* 1 */ {4,    4,  8,    4, deflate_fast}}; /* max speed, no lazy matches */\n#else\nlocal const config configuration_table[10] = {\n/*      good lazy nice chain */\n/* 0 */ {0,    0,  0,    0, deflate_stored},  /* store only */\n/* 1 */ {4,    4,  8,    4, deflate_fast}, /* max speed, no lazy matches */\n/* 2 */ {4,    5, 16,    8, deflate_fast},\n/* 3 */ {4,    6, 32,   32, deflate_fast},\n\n/* 4 */ {4,    4, 16,   16, deflate_slow},  /* lazy matches */\n/* 5 */ {8,   16, 32,   32, deflate_slow},\n/* 6 */ {8,   16, 128, 128, deflate_slow},\n/* 7 */ {8,   32, 128, 256, deflate_slow},\n/* 8 */ {32, 128, 258, 1024, deflate_slow},\n/* 9 */ {32, 258, 258, 4096, deflate_slow}}; /* max compression */\n#endif\n\n/* Note: the deflate() code requires max_lazy >= MIN_MATCH and max_chain >= 4\n * For deflate_fast() (levels <= 3) good is ignored and lazy has a different\n * meaning.\n */\n\n/* rank Z_BLOCK between Z_NO_FLUSH and Z_PARTIAL_FLUSH */\n#define RANK(f) (((f) * 2) - ((f) > 4 ? 9 : 0))\n\n/* ===========================================================================\n * Update a hash value with the given input byte\n * IN  assertion: all calls to UPDATE_HASH are made with consecutive input\n *    characters, so that a running hash key can be computed from the previous\n *    key instead of complete recalculation each time.\n */\n#define UPDATE_HASH(s,h,c) (h = (((h)<<s->hash_shift) ^ (c)) & s->hash_mask)\n\n\n/* ===========================================================================\n * Insert string str in the dictionary and set match_head to the previous head\n * of the hash chain (the most recent string with same hash key). Return\n * the previous length of the hash chain.\n * If this file is compiled with -DFASTEST, the compression level is forced\n * to 1, and no hash chains are maintained.\n * IN  assertion: all calls to INSERT_STRING are made with consecutive input\n *    characters and the first MIN_MATCH bytes of str are valid (except for\n *    the last MIN_MATCH-1 bytes of the input file).\n */\n#ifdef FASTEST\n#define INSERT_STRING(s, str, match_head) \\\n   (UPDATE_HASH(s, s->ins_h, s->window[(str) + (MIN_MATCH-1)]), \\\n    match_head = s->head[s->ins_h], \\\n    s->head[s->ins_h] = (Pos)(str))\n#else\n#define INSERT_STRING(s, str, match_head) \\\n   (UPDATE_HASH(s, s->ins_h, s->window[(str) + (MIN_MATCH-1)]), \\\n    match_head = s->prev[(str) & s->w_mask] = s->head[s->ins_h], \\\n    s->head[s->ins_h] = (Pos)(str))\n#endif\n\n/* ===========================================================================\n * Initialize the hash table (avoiding 64K overflow for 16 bit systems).\n * prev[] will be initialized on the fly.\n */\n#define CLEAR_HASH(s) \\\n    s->head[s->hash_size-1] = NIL; \\\n    zmemzero((Bytef *)s->head, (unsigned)(s->hash_size-1)*sizeof(*s->head));\n\n/* ===========================================================================\n * Slide the hash table when sliding the window down (could be avoided with 32\n * bit values at the expense of memory usage). We slide even when level == 0 to\n * keep the hash table consistent if we switch back to level > 0 later.\n */\nlocal void slide_hash(s)\n    deflate_state *s;\n{\n    unsigned n, m;\n    Posf *p;\n    uInt wsize = s->w_size;\n\n    n = s->hash_size;\n    p = &s->head[n];\n    do {\n        m = *--p;\n        *p = (Pos)(m >= wsize ? m - wsize : NIL);\n    } while (--n);\n    n = wsize;\n#ifndef FASTEST\n    p = &s->prev[n];\n    do {\n        m = *--p;\n        *p = (Pos)(m >= wsize ? m - wsize : NIL);\n        /* If n is not on any hash chain, prev[n] is garbage but\n         * its value will never be used.\n         */\n    } while (--n);\n#endif\n}\n\n/* ========================================================================= */\nint ZEXPORT deflateInit_(strm, level, version, stream_size)\n    z_streamp strm;\n    int level;\n    const char *version;\n    int stream_size;\n{\n    return deflateInit2_(strm, level, Z_DEFLATED, MAX_WBITS, DEF_MEM_LEVEL,\n                         Z_DEFAULT_STRATEGY, version, stream_size);\n    /* To do: ignore strm->next_in if we use it as window */\n}\n\n/* ========================================================================= */\nint ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy,\n                  version, stream_size)\n    z_streamp strm;\n    int  level;\n    int  method;\n    int  windowBits;\n    int  memLevel;\n    int  strategy;\n    const char *version;\n    int stream_size;\n{\n    deflate_state *s;\n    int wrap = 1;\n    static const char my_version[] = ZLIB_VERSION;\n\n    ushf *overlay;\n    /* We overlay pending_buf and d_buf+l_buf. This works since the average\n     * output size for (length,distance) codes is <= 24 bits.\n     */\n\n    if (version == Z_NULL || version[0] != my_version[0] ||\n        stream_size != sizeof(z_stream)) {\n        return Z_VERSION_ERROR;\n    }\n    if (strm == Z_NULL) return Z_STREAM_ERROR;\n\n    strm->msg = Z_NULL;\n    if (strm->zalloc == (alloc_func)0) {\n#ifdef Z_SOLO\n        return Z_STREAM_ERROR;\n#else\n        strm->zalloc = zcalloc;\n        strm->opaque = (voidpf)0;\n#endif\n    }\n    if (strm->zfree == (free_func)0)\n#ifdef Z_SOLO\n        return Z_STREAM_ERROR;\n#else\n        strm->zfree = zcfree;\n#endif\n\n#ifdef FASTEST\n    if (level != 0) level = 1;\n#else\n    if (level == Z_DEFAULT_COMPRESSION) level = 6;\n#endif\n\n    if (windowBits < 0) { /* suppress zlib wrapper */\n        wrap = 0;\n        windowBits = -windowBits;\n    }\n#ifdef GZIP\n    else if (windowBits > 15) {\n        wrap = 2;       /* write gzip wrapper instead */\n        windowBits -= 16;\n    }\n#endif\n    if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || method != Z_DEFLATED ||\n        windowBits < 8 || windowBits > 15 || level < 0 || level > 9 ||\n        strategy < 0 || strategy > Z_FIXED || (windowBits == 8 && wrap != 1)) {\n        return Z_STREAM_ERROR;\n    }\n    if (windowBits == 8) windowBits = 9;  /* until 256-byte window bug fixed */\n    s = (deflate_state *) ZALLOC(strm, 1, sizeof(deflate_state));\n    if (s == Z_NULL) return Z_MEM_ERROR;\n    strm->state = (struct internal_state FAR *)s;\n    s->strm = strm;\n    s->status = INIT_STATE;     /* to pass state test in deflateReset() */\n\n    s->wrap = wrap;\n    s->gzhead = Z_NULL;\n    s->w_bits = (uInt)windowBits;\n    s->w_size = 1 << s->w_bits;\n    s->w_mask = s->w_size - 1;\n\n    s->hash_bits = (uInt)memLevel + 7;\n    s->hash_size = 1 << s->hash_bits;\n    s->hash_mask = s->hash_size - 1;\n    s->hash_shift =  ((s->hash_bits+MIN_MATCH-1)/MIN_MATCH);\n\n    s->window = (Bytef *) ZALLOC(strm, s->w_size, 2*sizeof(Byte));\n    s->prev   = (Posf *)  ZALLOC(strm, s->w_size, sizeof(Pos));\n    s->head   = (Posf *)  ZALLOC(strm, s->hash_size, sizeof(Pos));\n\n    s->high_water = 0;      /* nothing written to s->window yet */\n\n    s->lit_bufsize = 1 << (memLevel + 6); /* 16K elements by default */\n\n    overlay = (ushf *) ZALLOC(strm, s->lit_bufsize, sizeof(ush)+2);\n    s->pending_buf = (uchf *) overlay;\n    s->pending_buf_size = (ulg)s->lit_bufsize * (sizeof(ush)+2L);\n\n    if (s->window == Z_NULL || s->prev == Z_NULL || s->head == Z_NULL ||\n        s->pending_buf == Z_NULL) {\n        s->status = FINISH_STATE;\n        strm->msg = ERR_MSG(Z_MEM_ERROR);\n        deflateEnd (strm);\n        return Z_MEM_ERROR;\n    }\n    s->d_buf = overlay + s->lit_bufsize/sizeof(ush);\n    s->l_buf = s->pending_buf + (1+sizeof(ush))*s->lit_bufsize;\n\n    s->level = level;\n    s->strategy = strategy;\n    s->method = (Byte)method;\n\n    return deflateReset(strm);\n}\n\n/* =========================================================================\n * Check for a valid deflate stream state. Return 0 if ok, 1 if not.\n */\nlocal int deflateStateCheck (strm)\n    z_streamp strm;\n{\n    deflate_state *s;\n    if (strm == Z_NULL ||\n        strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0)\n        return 1;\n    s = strm->state;\n    if (s == Z_NULL || s->strm != strm || (s->status != INIT_STATE &&\n#ifdef GZIP\n                                           s->status != GZIP_STATE &&\n#endif\n                                           s->status != EXTRA_STATE &&\n                                           s->status != NAME_STATE &&\n                                           s->status != COMMENT_STATE &&\n                                           s->status != HCRC_STATE &&\n                                           s->status != BUSY_STATE &&\n                                           s->status != FINISH_STATE))\n        return 1;\n    return 0;\n}\n\n/* ========================================================================= */\nint ZEXPORT deflateSetDictionary (strm, dictionary, dictLength)\n    z_streamp strm;\n    const Bytef *dictionary;\n    uInt  dictLength;\n{\n    deflate_state *s;\n    uInt str, n;\n    int wrap;\n    unsigned avail;\n    z_const unsigned char *next;\n\n    if (deflateStateCheck(strm) || dictionary == Z_NULL)\n        return Z_STREAM_ERROR;\n    s = strm->state;\n    wrap = s->wrap;\n    if (wrap == 2 || (wrap == 1 && s->status != INIT_STATE) || s->lookahead)\n        return Z_STREAM_ERROR;\n\n    /* when using zlib wrappers, compute Adler-32 for provided dictionary */\n    if (wrap == 1)\n        strm->adler = adler32(strm->adler, dictionary, dictLength);\n    s->wrap = 0;                    /* avoid computing Adler-32 in read_buf */\n\n    /* if dictionary would fill window, just replace the history */\n    if (dictLength >= s->w_size) {\n        if (wrap == 0) {            /* already empty otherwise */\n            CLEAR_HASH(s);\n            s->strstart = 0;\n            s->block_start = 0L;\n            s->insert = 0;\n        }\n        dictionary += dictLength - s->w_size;  /* use the tail */\n        dictLength = s->w_size;\n    }\n\n    /* insert dictionary into window and hash */\n    avail = strm->avail_in;\n    next = strm->next_in;\n    strm->avail_in = dictLength;\n    strm->next_in = (z_const Bytef *)dictionary;\n    fill_window(s);\n    while (s->lookahead >= MIN_MATCH) {\n        str = s->strstart;\n        n = s->lookahead - (MIN_MATCH-1);\n        do {\n            UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]);\n#ifndef FASTEST\n            s->prev[str & s->w_mask] = s->head[s->ins_h];\n#endif\n            s->head[s->ins_h] = (Pos)str;\n            str++;\n        } while (--n);\n        s->strstart = str;\n        s->lookahead = MIN_MATCH-1;\n        fill_window(s);\n    }\n    s->strstart += s->lookahead;\n    s->block_start = (long)s->strstart;\n    s->insert = s->lookahead;\n    s->lookahead = 0;\n    s->match_length = s->prev_length = MIN_MATCH-1;\n    s->match_available = 0;\n    strm->next_in = next;\n    strm->avail_in = avail;\n    s->wrap = wrap;\n    return Z_OK;\n}\n\n/* ========================================================================= */\nint ZEXPORT deflateGetDictionary (strm, dictionary, dictLength)\n    z_streamp strm;\n    Bytef *dictionary;\n    uInt  *dictLength;\n{\n    deflate_state *s;\n    uInt len;\n\n    if (deflateStateCheck(strm))\n        return Z_STREAM_ERROR;\n    s = strm->state;\n    len = s->strstart + s->lookahead;\n    if (len > s->w_size)\n        len = s->w_size;\n    if (dictionary != Z_NULL && len)\n        zmemcpy(dictionary, s->window + s->strstart + s->lookahead - len, len);\n    if (dictLength != Z_NULL)\n        *dictLength = len;\n    return Z_OK;\n}\n\n/* ========================================================================= */\nint ZEXPORT deflateResetKeep (strm)\n    z_streamp strm;\n{\n    deflate_state *s;\n\n    if (deflateStateCheck(strm)) {\n        return Z_STREAM_ERROR;\n    }\n\n    strm->total_in = strm->total_out = 0;\n    strm->msg = Z_NULL; /* use zfree if we ever allocate msg dynamically */\n    strm->data_type = Z_UNKNOWN;\n\n    s = (deflate_state *)strm->state;\n    s->pending = 0;\n    s->pending_out = s->pending_buf;\n\n    if (s->wrap < 0) {\n        s->wrap = -s->wrap; /* was made negative by deflate(..., Z_FINISH); */\n    }\n    s->status =\n#ifdef GZIP\n        s->wrap == 2 ? GZIP_STATE :\n#endif\n        s->wrap ? INIT_STATE : BUSY_STATE;\n    strm->adler =\n#ifdef GZIP\n        s->wrap == 2 ? crc32(0L, Z_NULL, 0) :\n#endif\n        adler32(0L, Z_NULL, 0);\n    s->last_flush = Z_NO_FLUSH;\n\n    _tr_init(s);\n\n    return Z_OK;\n}\n\n/* ========================================================================= */\nint ZEXPORT deflateReset (strm)\n    z_streamp strm;\n{\n    int ret;\n\n    ret = deflateResetKeep(strm);\n    if (ret == Z_OK)\n        lm_init(strm->state);\n    return ret;\n}\n\n/* ========================================================================= */\nint ZEXPORT deflateSetHeader (strm, head)\n    z_streamp strm;\n    gz_headerp head;\n{\n    if (deflateStateCheck(strm) || strm->state->wrap != 2)\n        return Z_STREAM_ERROR;\n    strm->state->gzhead = head;\n    return Z_OK;\n}\n\n/* ========================================================================= */\nint ZEXPORT deflatePending (strm, pending, bits)\n    unsigned *pending;\n    int *bits;\n    z_streamp strm;\n{\n    if (deflateStateCheck(strm)) return Z_STREAM_ERROR;\n    if (pending != Z_NULL)\n        *pending = strm->state->pending;\n    if (bits != Z_NULL)\n        *bits = strm->state->bi_valid;\n    return Z_OK;\n}\n\n/* ========================================================================= */\nint ZEXPORT deflatePrime (strm, bits, value)\n    z_streamp strm;\n    int bits;\n    int value;\n{\n    deflate_state *s;\n    int put;\n\n    if (deflateStateCheck(strm)) return Z_STREAM_ERROR;\n    s = strm->state;\n    if ((Bytef *)(s->d_buf) < s->pending_out + ((Buf_size + 7) >> 3))\n        return Z_BUF_ERROR;\n    do {\n        put = Buf_size - s->bi_valid;\n        if (put > bits)\n            put = bits;\n        s->bi_buf |= (ush)((value & ((1 << put) - 1)) << s->bi_valid);\n        s->bi_valid += put;\n        _tr_flush_bits(s);\n        value >>= put;\n        bits -= put;\n    } while (bits);\n    return Z_OK;\n}\n\n/* ========================================================================= */\nint ZEXPORT deflateParams(strm, level, strategy)\n    z_streamp strm;\n    int level;\n    int strategy;\n{\n    deflate_state *s;\n    compress_func func;\n\n    if (deflateStateCheck(strm)) return Z_STREAM_ERROR;\n    s = strm->state;\n\n#ifdef FASTEST\n    if (level != 0) level = 1;\n#else\n    if (level == Z_DEFAULT_COMPRESSION) level = 6;\n#endif\n    if (level < 0 || level > 9 || strategy < 0 || strategy > Z_FIXED) {\n        return Z_STREAM_ERROR;\n    }\n    func = configuration_table[s->level].func;\n\n    if ((strategy != s->strategy || func != configuration_table[level].func) &&\n        s->high_water) {\n        /* Flush the last buffer: */\n        int err = deflate(strm, Z_BLOCK);\n        if (err == Z_STREAM_ERROR)\n            return err;\n        if (strm->avail_out == 0)\n            return Z_BUF_ERROR;\n    }\n    if (s->level != level) {\n        if (s->level == 0 && s->matches != 0) {\n            if (s->matches == 1)\n                slide_hash(s);\n            else\n                CLEAR_HASH(s);\n            s->matches = 0;\n        }\n        s->level = level;\n        s->max_lazy_match   = configuration_table[level].max_lazy;\n        s->good_match       = configuration_table[level].good_length;\n        s->nice_match       = configuration_table[level].nice_length;\n        s->max_chain_length = configuration_table[level].max_chain;\n    }\n    s->strategy = strategy;\n    return Z_OK;\n}\n\n/* ========================================================================= */\nint ZEXPORT deflateTune(strm, good_length, max_lazy, nice_length, max_chain)\n    z_streamp strm;\n    int good_length;\n    int max_lazy;\n    int nice_length;\n    int max_chain;\n{\n    deflate_state *s;\n\n    if (deflateStateCheck(strm)) return Z_STREAM_ERROR;\n    s = strm->state;\n    s->good_match = (uInt)good_length;\n    s->max_lazy_match = (uInt)max_lazy;\n    s->nice_match = nice_length;\n    s->max_chain_length = (uInt)max_chain;\n    return Z_OK;\n}\n\n/* =========================================================================\n * For the default windowBits of 15 and memLevel of 8, this function returns\n * a close to exact, as well as small, upper bound on the compressed size.\n * They are coded as constants here for a reason--if the #define's are\n * changed, then this function needs to be changed as well.  The return\n * value for 15 and 8 only works for those exact settings.\n *\n * For any setting other than those defaults for windowBits and memLevel,\n * the value returned is a conservative worst case for the maximum expansion\n * resulting from using fixed blocks instead of stored blocks, which deflate\n * can emit on compressed data for some combinations of the parameters.\n *\n * This function could be more sophisticated to provide closer upper bounds for\n * every combination of windowBits and memLevel.  But even the conservative\n * upper bound of about 14% expansion does not seem onerous for output buffer\n * allocation.\n */\nuLong ZEXPORT deflateBound(strm, sourceLen)\n    z_streamp strm;\n    uLong sourceLen;\n{\n    deflate_state *s;\n    uLong complen, wraplen;\n\n    /* conservative upper bound for compressed data */\n    complen = sourceLen +\n              ((sourceLen + 7) >> 3) + ((sourceLen + 63) >> 6) + 5;\n\n    /* if can't get parameters, return conservative bound plus zlib wrapper */\n    if (deflateStateCheck(strm))\n        return complen + 6;\n\n    /* compute wrapper length */\n    s = strm->state;\n    switch (s->wrap) {\n    case 0:                                 /* raw deflate */\n        wraplen = 0;\n        break;\n    case 1:                                 /* zlib wrapper */\n        wraplen = 6 + (s->strstart ? 4 : 0);\n        break;\n#ifdef GZIP\n    case 2:                                 /* gzip wrapper */\n        wraplen = 18;\n        if (s->gzhead != Z_NULL) {          /* user-supplied gzip header */\n            Bytef *str;\n            if (s->gzhead->extra != Z_NULL)\n                wraplen += 2 + s->gzhead->extra_len;\n            str = s->gzhead->name;\n            if (str != Z_NULL)\n                do {\n                    wraplen++;\n                } while (*str++);\n            str = s->gzhead->comment;\n            if (str != Z_NULL)\n                do {\n                    wraplen++;\n                } while (*str++);\n            if (s->gzhead->hcrc)\n                wraplen += 2;\n        }\n        break;\n#endif\n    default:                                /* for compiler happiness */\n        wraplen = 6;\n    }\n\n    /* if not default parameters, return conservative bound */\n    if (s->w_bits != 15 || s->hash_bits != 8 + 7)\n        return complen + wraplen;\n\n    /* default settings: return tight bound for that case */\n    return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) +\n           (sourceLen >> 25) + 13 - 6 + wraplen;\n}\n\n/* =========================================================================\n * Put a short in the pending buffer. The 16-bit value is put in MSB order.\n * IN assertion: the stream state is correct and there is enough room in\n * pending_buf.\n */\nlocal void putShortMSB (s, b)\n    deflate_state *s;\n    uInt b;\n{\n    put_byte(s, (Byte)(b >> 8));\n    put_byte(s, (Byte)(b & 0xff));\n}\n\n/* =========================================================================\n * Flush as much pending output as possible. All deflate() output, except for\n * some deflate_stored() output, goes through this function so some\n * applications may wish to modify it to avoid allocating a large\n * strm->next_out buffer and copying into it. (See also read_buf()).\n */\nlocal void flush_pending(strm)\n    z_streamp strm;\n{\n    unsigned len;\n    deflate_state *s = strm->state;\n\n    _tr_flush_bits(s);\n    len = s->pending;\n    if (len > strm->avail_out) len = strm->avail_out;\n    if (len == 0) return;\n\n    zmemcpy(strm->next_out, s->pending_out, len);\n    strm->next_out  += len;\n    s->pending_out  += len;\n    strm->total_out += len;\n    strm->avail_out -= len;\n    s->pending      -= len;\n    if (s->pending == 0) {\n        s->pending_out = s->pending_buf;\n    }\n}\n\n/* ===========================================================================\n * Update the header CRC with the bytes s->pending_buf[beg..s->pending - 1].\n */\n#define HCRC_UPDATE(beg) \\\n    do { \\\n        if (s->gzhead->hcrc && s->pending > (beg)) \\\n            strm->adler = crc32(strm->adler, s->pending_buf + (beg), \\\n                                s->pending - (beg)); \\\n    } while (0)\n\n/* ========================================================================= */\nint ZEXPORT deflate (strm, flush)\n    z_streamp strm;\n    int flush;\n{\n    int old_flush; /* value of flush param for previous deflate call */\n    deflate_state *s;\n\n    if (deflateStateCheck(strm) || flush > Z_BLOCK || flush < 0) {\n        return Z_STREAM_ERROR;\n    }\n    s = strm->state;\n\n    if (strm->next_out == Z_NULL ||\n        (strm->avail_in != 0 && strm->next_in == Z_NULL) ||\n        (s->status == FINISH_STATE && flush != Z_FINISH)) {\n        ERR_RETURN(strm, Z_STREAM_ERROR);\n    }\n    if (strm->avail_out == 0) ERR_RETURN(strm, Z_BUF_ERROR);\n\n    old_flush = s->last_flush;\n    s->last_flush = flush;\n\n    /* Flush as much pending output as possible */\n    if (s->pending != 0) {\n        flush_pending(strm);\n        if (strm->avail_out == 0) {\n            /* Since avail_out is 0, deflate will be called again with\n             * more output space, but possibly with both pending and\n             * avail_in equal to zero. There won't be anything to do,\n             * but this is not an error situation so make sure we\n             * return OK instead of BUF_ERROR at next call of deflate:\n             */\n            s->last_flush = -1;\n            return Z_OK;\n        }\n\n    /* Make sure there is something to do and avoid duplicate consecutive\n     * flushes. For repeated and useless calls with Z_FINISH, we keep\n     * returning Z_STREAM_END instead of Z_BUF_ERROR.\n     */\n    } else if (strm->avail_in == 0 && RANK(flush) <= RANK(old_flush) &&\n               flush != Z_FINISH) {\n        ERR_RETURN(strm, Z_BUF_ERROR);\n    }\n\n    /* User must not provide more input after the first FINISH: */\n    if (s->status == FINISH_STATE && strm->avail_in != 0) {\n        ERR_RETURN(strm, Z_BUF_ERROR);\n    }\n\n    /* Write the header */\n    if (s->status == INIT_STATE) {\n        /* zlib header */\n        uInt header = (Z_DEFLATED + ((s->w_bits-8)<<4)) << 8;\n        uInt level_flags;\n\n        if (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2)\n            level_flags = 0;\n        else if (s->level < 6)\n            level_flags = 1;\n        else if (s->level == 6)\n            level_flags = 2;\n        else\n            level_flags = 3;\n        header |= (level_flags << 6);\n        if (s->strstart != 0) header |= PRESET_DICT;\n        header += 31 - (header % 31);\n\n        putShortMSB(s, header);\n\n        /* Save the adler32 of the preset dictionary: */\n        if (s->strstart != 0) {\n            putShortMSB(s, (uInt)(strm->adler >> 16));\n            putShortMSB(s, (uInt)(strm->adler & 0xffff));\n        }\n        strm->adler = adler32(0L, Z_NULL, 0);\n        s->status = BUSY_STATE;\n\n        /* Compression must start with an empty pending buffer */\n        flush_pending(strm);\n        if (s->pending != 0) {\n            s->last_flush = -1;\n            return Z_OK;\n        }\n    }\n#ifdef GZIP\n    if (s->status == GZIP_STATE) {\n        /* gzip header */\n        strm->adler = crc32(0L, Z_NULL, 0);\n        put_byte(s, 31);\n        put_byte(s, 139);\n        put_byte(s, 8);\n        if (s->gzhead == Z_NULL) {\n            put_byte(s, 0);\n            put_byte(s, 0);\n            put_byte(s, 0);\n            put_byte(s, 0);\n            put_byte(s, 0);\n            put_byte(s, s->level == 9 ? 2 :\n                     (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ?\n                      4 : 0));\n            put_byte(s, OS_CODE);\n            s->status = BUSY_STATE;\n\n            /* Compression must start with an empty pending buffer */\n            flush_pending(strm);\n            if (s->pending != 0) {\n                s->last_flush = -1;\n                return Z_OK;\n            }\n        }\n        else {\n            put_byte(s, (s->gzhead->text ? 1 : 0) +\n                     (s->gzhead->hcrc ? 2 : 0) +\n                     (s->gzhead->extra == Z_NULL ? 0 : 4) +\n                     (s->gzhead->name == Z_NULL ? 0 : 8) +\n                     (s->gzhead->comment == Z_NULL ? 0 : 16)\n                     );\n            put_byte(s, (Byte)(s->gzhead->time & 0xff));\n            put_byte(s, (Byte)((s->gzhead->time >> 8) & 0xff));\n            put_byte(s, (Byte)((s->gzhead->time >> 16) & 0xff));\n            put_byte(s, (Byte)((s->gzhead->time >> 24) & 0xff));\n            put_byte(s, s->level == 9 ? 2 :\n                     (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ?\n                      4 : 0));\n            put_byte(s, s->gzhead->os & 0xff);\n            if (s->gzhead->extra != Z_NULL) {\n                put_byte(s, s->gzhead->extra_len & 0xff);\n                put_byte(s, (s->gzhead->extra_len >> 8) & 0xff);\n            }\n            if (s->gzhead->hcrc)\n                strm->adler = crc32(strm->adler, s->pending_buf,\n                                    s->pending);\n            s->gzindex = 0;\n            s->status = EXTRA_STATE;\n        }\n    }\n    if (s->status == EXTRA_STATE) {\n        if (s->gzhead->extra != Z_NULL) {\n            ulg beg = s->pending;   /* start of bytes to update crc */\n            uInt left = (s->gzhead->extra_len & 0xffff) - s->gzindex;\n            while (s->pending + left > s->pending_buf_size) {\n                uInt copy = s->pending_buf_size - s->pending;\n                zmemcpy(s->pending_buf + s->pending,\n                        s->gzhead->extra + s->gzindex, copy);\n                s->pending = s->pending_buf_size;\n                HCRC_UPDATE(beg);\n                s->gzindex += copy;\n                flush_pending(strm);\n                if (s->pending != 0) {\n                    s->last_flush = -1;\n                    return Z_OK;\n                }\n                beg = 0;\n                left -= copy;\n            }\n            zmemcpy(s->pending_buf + s->pending,\n                    s->gzhead->extra + s->gzindex, left);\n            s->pending += left;\n            HCRC_UPDATE(beg);\n            s->gzindex = 0;\n        }\n        s->status = NAME_STATE;\n    }\n    if (s->status == NAME_STATE) {\n        if (s->gzhead->name != Z_NULL) {\n            ulg beg = s->pending;   /* start of bytes to update crc */\n            int val;\n            do {\n                if (s->pending == s->pending_buf_size) {\n                    HCRC_UPDATE(beg);\n                    flush_pending(strm);\n                    if (s->pending != 0) {\n                        s->last_flush = -1;\n                        return Z_OK;\n                    }\n                    beg = 0;\n                }\n                val = s->gzhead->name[s->gzindex++];\n                put_byte(s, val);\n            } while (val != 0);\n            HCRC_UPDATE(beg);\n            s->gzindex = 0;\n        }\n        s->status = COMMENT_STATE;\n    }\n    if (s->status == COMMENT_STATE) {\n        if (s->gzhead->comment != Z_NULL) {\n            ulg beg = s->pending;   /* start of bytes to update crc */\n            int val;\n            do {\n                if (s->pending == s->pending_buf_size) {\n                    HCRC_UPDATE(beg);\n                    flush_pending(strm);\n                    if (s->pending != 0) {\n                        s->last_flush = -1;\n                        return Z_OK;\n                    }\n                    beg = 0;\n                }\n                val = s->gzhead->comment[s->gzindex++];\n                put_byte(s, val);\n            } while (val != 0);\n            HCRC_UPDATE(beg);\n        }\n        s->status = HCRC_STATE;\n    }\n    if (s->status == HCRC_STATE) {\n        if (s->gzhead->hcrc) {\n            if (s->pending + 2 > s->pending_buf_size) {\n                flush_pending(strm);\n                if (s->pending != 0) {\n                    s->last_flush = -1;\n                    return Z_OK;\n                }\n            }\n            put_byte(s, (Byte)(strm->adler & 0xff));\n            put_byte(s, (Byte)((strm->adler >> 8) & 0xff));\n            strm->adler = crc32(0L, Z_NULL, 0);\n        }\n        s->status = BUSY_STATE;\n\n        /* Compression must start with an empty pending buffer */\n        flush_pending(strm);\n        if (s->pending != 0) {\n            s->last_flush = -1;\n            return Z_OK;\n        }\n    }\n#endif\n\n    /* Start a new block or continue the current one.\n     */\n    if (strm->avail_in != 0 || s->lookahead != 0 ||\n        (flush != Z_NO_FLUSH && s->status != FINISH_STATE)) {\n        block_state bstate;\n\n        bstate = s->level == 0 ? deflate_stored(s, flush) :\n                 s->strategy == Z_HUFFMAN_ONLY ? deflate_huff(s, flush) :\n                 s->strategy == Z_RLE ? deflate_rle(s, flush) :\n                 (*(configuration_table[s->level].func))(s, flush);\n\n        if (bstate == finish_started || bstate == finish_done) {\n            s->status = FINISH_STATE;\n        }\n        if (bstate == need_more || bstate == finish_started) {\n            if (strm->avail_out == 0) {\n                s->last_flush = -1; /* avoid BUF_ERROR next call, see above */\n            }\n            return Z_OK;\n            /* If flush != Z_NO_FLUSH && avail_out == 0, the next call\n             * of deflate should use the same flush parameter to make sure\n             * that the flush is complete. So we don't have to output an\n             * empty block here, this will be done at next call. This also\n             * ensures that for a very small output buffer, we emit at most\n             * one empty block.\n             */\n        }\n        if (bstate == block_done) {\n            if (flush == Z_PARTIAL_FLUSH) {\n                _tr_align(s);\n            } else if (flush != Z_BLOCK) { /* FULL_FLUSH or SYNC_FLUSH */\n                _tr_stored_block(s, (char*)0, 0L, 0);\n                /* For a full flush, this empty block will be recognized\n                 * as a special marker by inflate_sync().\n                 */\n                if (flush == Z_FULL_FLUSH) {\n                    CLEAR_HASH(s);             /* forget history */\n                    if (s->lookahead == 0) {\n                        s->strstart = 0;\n                        s->block_start = 0L;\n                        s->insert = 0;\n                    }\n                }\n            }\n            flush_pending(strm);\n            if (strm->avail_out == 0) {\n              s->last_flush = -1; /* avoid BUF_ERROR at next call, see above */\n              return Z_OK;\n            }\n        }\n    }\n\n    if (flush != Z_FINISH) return Z_OK;\n    if (s->wrap <= 0) return Z_STREAM_END;\n\n    /* Write the trailer */\n#ifdef GZIP\n    if (s->wrap == 2) {\n        put_byte(s, (Byte)(strm->adler & 0xff));\n        put_byte(s, (Byte)((strm->adler >> 8) & 0xff));\n        put_byte(s, (Byte)((strm->adler >> 16) & 0xff));\n        put_byte(s, (Byte)((strm->adler >> 24) & 0xff));\n        put_byte(s, (Byte)(strm->total_in & 0xff));\n        put_byte(s, (Byte)((strm->total_in >> 8) & 0xff));\n        put_byte(s, (Byte)((strm->total_in >> 16) & 0xff));\n        put_byte(s, (Byte)((strm->total_in >> 24) & 0xff));\n    }\n    else\n#endif\n    {\n        putShortMSB(s, (uInt)(strm->adler >> 16));\n        putShortMSB(s, (uInt)(strm->adler & 0xffff));\n    }\n    flush_pending(strm);\n    /* If avail_out is zero, the application will call deflate again\n     * to flush the rest.\n     */\n    if (s->wrap > 0) s->wrap = -s->wrap; /* write the trailer only once! */\n    return s->pending != 0 ? Z_OK : Z_STREAM_END;\n}\n\n/* ========================================================================= */\nint ZEXPORT deflateEnd (strm)\n    z_streamp strm;\n{\n    int status;\n\n    if (deflateStateCheck(strm)) return Z_STREAM_ERROR;\n\n    status = strm->state->status;\n\n    /* Deallocate in reverse order of allocations: */\n    TRY_FREE(strm, strm->state->pending_buf);\n    TRY_FREE(strm, strm->state->head);\n    TRY_FREE(strm, strm->state->prev);\n    TRY_FREE(strm, strm->state->window);\n\n    ZFREE(strm, strm->state);\n    strm->state = Z_NULL;\n\n    return status == BUSY_STATE ? Z_DATA_ERROR : Z_OK;\n}\n\n/* =========================================================================\n * Copy the source state to the destination state.\n * To simplify the source, this is not supported for 16-bit MSDOS (which\n * doesn't have enough memory anyway to duplicate compression states).\n */\nint ZEXPORT deflateCopy (dest, source)\n    z_streamp dest;\n    z_streamp source;\n{\n#ifdef MAXSEG_64K\n    return Z_STREAM_ERROR;\n#else\n    deflate_state *ds;\n    deflate_state *ss;\n    ushf *overlay;\n\n\n    if (deflateStateCheck(source) || dest == Z_NULL) {\n        return Z_STREAM_ERROR;\n    }\n\n    ss = source->state;\n\n    zmemcpy((voidpf)dest, (voidpf)source, sizeof(z_stream));\n\n    ds = (deflate_state *) ZALLOC(dest, 1, sizeof(deflate_state));\n    if (ds == Z_NULL) return Z_MEM_ERROR;\n    dest->state = (struct internal_state FAR *) ds;\n    zmemcpy((voidpf)ds, (voidpf)ss, sizeof(deflate_state));\n    ds->strm = dest;\n\n    ds->window = (Bytef *) ZALLOC(dest, ds->w_size, 2*sizeof(Byte));\n    ds->prev   = (Posf *)  ZALLOC(dest, ds->w_size, sizeof(Pos));\n    ds->head   = (Posf *)  ZALLOC(dest, ds->hash_size, sizeof(Pos));\n    overlay = (ushf *) ZALLOC(dest, ds->lit_bufsize, sizeof(ush)+2);\n    ds->pending_buf = (uchf *) overlay;\n\n    if (ds->window == Z_NULL || ds->prev == Z_NULL || ds->head == Z_NULL ||\n        ds->pending_buf == Z_NULL) {\n        deflateEnd (dest);\n        return Z_MEM_ERROR;\n    }\n    /* following zmemcpy do not work for 16-bit MSDOS */\n    zmemcpy(ds->window, ss->window, ds->w_size * 2 * sizeof(Byte));\n    zmemcpy((voidpf)ds->prev, (voidpf)ss->prev, ds->w_size * sizeof(Pos));\n    zmemcpy((voidpf)ds->head, (voidpf)ss->head, ds->hash_size * sizeof(Pos));\n    zmemcpy(ds->pending_buf, ss->pending_buf, (uInt)ds->pending_buf_size);\n\n    ds->pending_out = ds->pending_buf + (ss->pending_out - ss->pending_buf);\n    ds->d_buf = overlay + ds->lit_bufsize/sizeof(ush);\n    ds->l_buf = ds->pending_buf + (1+sizeof(ush))*ds->lit_bufsize;\n\n    ds->l_desc.dyn_tree = ds->dyn_ltree;\n    ds->d_desc.dyn_tree = ds->dyn_dtree;\n    ds->bl_desc.dyn_tree = ds->bl_tree;\n\n    return Z_OK;\n#endif /* MAXSEG_64K */\n}\n\n/* ===========================================================================\n * Read a new buffer from the current input stream, update the adler32\n * and total number of bytes read.  All deflate() input goes through\n * this function so some applications may wish to modify it to avoid\n * allocating a large strm->next_in buffer and copying from it.\n * (See also flush_pending()).\n */\nlocal unsigned read_buf(strm, buf, size)\n    z_streamp strm;\n    Bytef *buf;\n    unsigned size;\n{\n    unsigned len = strm->avail_in;\n\n    if (len > size) len = size;\n    if (len == 0) return 0;\n\n    strm->avail_in  -= len;\n\n    zmemcpy(buf, strm->next_in, len);\n    if (strm->state->wrap == 1) {\n        strm->adler = adler32(strm->adler, buf, len);\n    }\n#ifdef GZIP\n    else if (strm->state->wrap == 2) {\n        strm->adler = crc32(strm->adler, buf, len);\n    }\n#endif\n    strm->next_in  += len;\n    strm->total_in += len;\n\n    return len;\n}\n\n/* ===========================================================================\n * Initialize the \"longest match\" routines for a new zlib stream\n */\nlocal void lm_init (s)\n    deflate_state *s;\n{\n    s->window_size = (ulg)2L*s->w_size;\n\n    CLEAR_HASH(s);\n\n    /* Set the default configuration parameters:\n     */\n    s->max_lazy_match   = configuration_table[s->level].max_lazy;\n    s->good_match       = configuration_table[s->level].good_length;\n    s->nice_match       = configuration_table[s->level].nice_length;\n    s->max_chain_length = configuration_table[s->level].max_chain;\n\n    s->strstart = 0;\n    s->block_start = 0L;\n    s->lookahead = 0;\n    s->insert = 0;\n    s->match_length = s->prev_length = MIN_MATCH-1;\n    s->match_available = 0;\n    s->ins_h = 0;\n#ifndef FASTEST\n#ifdef ASMV\n    match_init(); /* initialize the asm code */\n#endif\n#endif\n}\n\n#ifndef FASTEST\n/* ===========================================================================\n * Set match_start to the longest match starting at the given string and\n * return its length. Matches shorter or equal to prev_length are discarded,\n * in which case the result is equal to prev_length and match_start is\n * garbage.\n * IN assertions: cur_match is the head of the hash chain for the current\n *   string (strstart) and its distance is <= MAX_DIST, and prev_length >= 1\n * OUT assertion: the match length is not greater than s->lookahead.\n */\n#ifndef ASMV\n/* For 80x86 and 680x0, an optimized version will be provided in match.asm or\n * match.S. The code will be functionally equivalent.\n */\nlocal uInt longest_match(s, cur_match)\n    deflate_state *s;\n    IPos cur_match;                             /* current match */\n{\n    unsigned chain_length = s->max_chain_length;/* max hash chain length */\n    register Bytef *scan = s->window + s->strstart; /* current string */\n    register Bytef *match;                      /* matched string */\n    register int len;                           /* length of current match */\n    int best_len = (int)s->prev_length;         /* best match length so far */\n    int nice_match = s->nice_match;             /* stop if match long enough */\n    IPos limit = s->strstart > (IPos)MAX_DIST(s) ?\n        s->strstart - (IPos)MAX_DIST(s) : NIL;\n    /* Stop when cur_match becomes <= limit. To simplify the code,\n     * we prevent matches with the string of window index 0.\n     */\n    Posf *prev = s->prev;\n    uInt wmask = s->w_mask;\n\n#ifdef UNALIGNED_OK\n    /* Compare two bytes at a time. Note: this is not always beneficial.\n     * Try with and without -DUNALIGNED_OK to check.\n     */\n    register Bytef *strend = s->window + s->strstart + MAX_MATCH - 1;\n    register ush scan_start = *(ushf*)scan;\n    register ush scan_end   = *(ushf*)(scan+best_len-1);\n#else\n    register Bytef *strend = s->window + s->strstart + MAX_MATCH;\n    register Byte scan_end1  = scan[best_len-1];\n    register Byte scan_end   = scan[best_len];\n#endif\n\n    /* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16.\n     * It is easy to get rid of this optimization if necessary.\n     */\n    Assert(s->hash_bits >= 8 && MAX_MATCH == 258, \"Code too clever\");\n\n    /* Do not waste too much time if we already have a good match: */\n    if (s->prev_length >= s->good_match) {\n        chain_length >>= 2;\n    }\n    /* Do not look for matches beyond the end of the input. This is necessary\n     * to make deflate deterministic.\n     */\n    if ((uInt)nice_match > s->lookahead) nice_match = (int)s->lookahead;\n\n    Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, \"need lookahead\");\n\n    do {\n        Assert(cur_match < s->strstart, \"no future\");\n        match = s->window + cur_match;\n\n        /* Skip to next match if the match length cannot increase\n         * or if the match length is less than 2.  Note that the checks below\n         * for insufficient lookahead only occur occasionally for performance\n         * reasons.  Therefore uninitialized memory will be accessed, and\n         * conditional jumps will be made that depend on those values.\n         * However the length of the match is limited to the lookahead, so\n         * the output of deflate is not affected by the uninitialized values.\n         */\n#if (defined(UNALIGNED_OK) && MAX_MATCH == 258)\n        /* This code assumes sizeof(unsigned short) == 2. Do not use\n         * UNALIGNED_OK if your compiler uses a different size.\n         */\n        if (*(ushf*)(match+best_len-1) != scan_end ||\n            *(ushf*)match != scan_start) continue;\n\n        /* It is not necessary to compare scan[2] and match[2] since they are\n         * always equal when the other bytes match, given that the hash keys\n         * are equal and that HASH_BITS >= 8. Compare 2 bytes at a time at\n         * strstart+3, +5, ... up to strstart+257. We check for insufficient\n         * lookahead only every 4th comparison; the 128th check will be made\n         * at strstart+257. If MAX_MATCH-2 is not a multiple of 8, it is\n         * necessary to put more guard bytes at the end of the window, or\n         * to check more often for insufficient lookahead.\n         */\n        Assert(scan[2] == match[2], \"scan[2]?\");\n        scan++, match++;\n        do {\n        } while (*(ushf*)(scan+=2) == *(ushf*)(match+=2) &&\n                 *(ushf*)(scan+=2) == *(ushf*)(match+=2) &&\n                 *(ushf*)(scan+=2) == *(ushf*)(match+=2) &&\n                 *(ushf*)(scan+=2) == *(ushf*)(match+=2) &&\n                 scan < strend);\n        /* The funny \"do {}\" generates better code on most compilers */\n\n        /* Here, scan <= window+strstart+257 */\n        Assert(scan <= s->window+(unsigned)(s->window_size-1), \"wild scan\");\n        if (*scan == *match) scan++;\n\n        len = (MAX_MATCH - 1) - (int)(strend-scan);\n        scan = strend - (MAX_MATCH-1);\n\n#else /* UNALIGNED_OK */\n\n        if (match[best_len]   != scan_end  ||\n            match[best_len-1] != scan_end1 ||\n            *match            != *scan     ||\n            *++match          != scan[1])      continue;\n\n        /* The check at best_len-1 can be removed because it will be made\n         * again later. (This heuristic is not always a win.)\n         * It is not necessary to compare scan[2] and match[2] since they\n         * are always equal when the other bytes match, given that\n         * the hash keys are equal and that HASH_BITS >= 8.\n         */\n        scan += 2, match++;\n        Assert(*scan == *match, \"match[2]?\");\n\n        /* We check for insufficient lookahead only every 8th comparison;\n         * the 256th check will be made at strstart+258.\n         */\n        do {\n        } while (*++scan == *++match && *++scan == *++match &&\n                 *++scan == *++match && *++scan == *++match &&\n                 *++scan == *++match && *++scan == *++match &&\n                 *++scan == *++match && *++scan == *++match &&\n                 scan < strend);\n\n        Assert(scan <= s->window+(unsigned)(s->window_size-1), \"wild scan\");\n\n        len = MAX_MATCH - (int)(strend - scan);\n        scan = strend - MAX_MATCH;\n\n#endif /* UNALIGNED_OK */\n\n        if (len > best_len) {\n            s->match_start = cur_match;\n            best_len = len;\n            if (len >= nice_match) break;\n#ifdef UNALIGNED_OK\n            scan_end = *(ushf*)(scan+best_len-1);\n#else\n            scan_end1  = scan[best_len-1];\n            scan_end   = scan[best_len];\n#endif\n        }\n    } while ((cur_match = prev[cur_match & wmask]) > limit\n             && --chain_length != 0);\n\n    if ((uInt)best_len <= s->lookahead) return (uInt)best_len;\n    return s->lookahead;\n}\n#endif /* ASMV */\n\n#else /* FASTEST */\n\n/* ---------------------------------------------------------------------------\n * Optimized version for FASTEST only\n */\nlocal uInt longest_match(s, cur_match)\n    deflate_state *s;\n    IPos cur_match;                             /* current match */\n{\n    register Bytef *scan = s->window + s->strstart; /* current string */\n    register Bytef *match;                       /* matched string */\n    register int len;                           /* length of current match */\n    register Bytef *strend = s->window + s->strstart + MAX_MATCH;\n\n    /* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16.\n     * It is easy to get rid of this optimization if necessary.\n     */\n    Assert(s->hash_bits >= 8 && MAX_MATCH == 258, \"Code too clever\");\n\n    Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, \"need lookahead\");\n\n    Assert(cur_match < s->strstart, \"no future\");\n\n    match = s->window + cur_match;\n\n    /* Return failure if the match length is less than 2:\n     */\n    if (match[0] != scan[0] || match[1] != scan[1]) return MIN_MATCH-1;\n\n    /* The check at best_len-1 can be removed because it will be made\n     * again later. (This heuristic is not always a win.)\n     * It is not necessary to compare scan[2] and match[2] since they\n     * are always equal when the other bytes match, given that\n     * the hash keys are equal and that HASH_BITS >= 8.\n     */\n    scan += 2, match += 2;\n    Assert(*scan == *match, \"match[2]?\");\n\n    /* We check for insufficient lookahead only every 8th comparison;\n     * the 256th check will be made at strstart+258.\n     */\n    do {\n    } while (*++scan == *++match && *++scan == *++match &&\n             *++scan == *++match && *++scan == *++match &&\n             *++scan == *++match && *++scan == *++match &&\n             *++scan == *++match && *++scan == *++match &&\n             scan < strend);\n\n    Assert(scan <= s->window+(unsigned)(s->window_size-1), \"wild scan\");\n\n    len = MAX_MATCH - (int)(strend - scan);\n\n    if (len < MIN_MATCH) return MIN_MATCH - 1;\n\n    s->match_start = cur_match;\n    return (uInt)len <= s->lookahead ? (uInt)len : s->lookahead;\n}\n\n#endif /* FASTEST */\n\n#ifdef ZLIB_DEBUG\n\n#define EQUAL 0\n/* result of memcmp for equal strings */\n\n/* ===========================================================================\n * Check that the match at match_start is indeed a match.\n */\nlocal void check_match(s, start, match, length)\n    deflate_state *s;\n    IPos start, match;\n    int length;\n{\n    /* check that the match is indeed a match */\n    if (zmemcmp(s->window + match,\n                s->window + start, length) != EQUAL) {\n        fprintf(stderr, \" start %u, match %u, length %d\\n\",\n                start, match, length);\n        do {\n            fprintf(stderr, \"%c%c\", s->window[match++], s->window[start++]);\n        } while (--length != 0);\n        z_error(\"invalid match\");\n    }\n    if (z_verbose > 1) {\n        fprintf(stderr,\"\\\\[%d,%d]\", start-match, length);\n        do { putc(s->window[start++], stderr); } while (--length != 0);\n    }\n}\n#else\n#  define check_match(s, start, match, length)\n#endif /* ZLIB_DEBUG */\n\n/* ===========================================================================\n * Fill the window when the lookahead becomes insufficient.\n * Updates strstart and lookahead.\n *\n * IN assertion: lookahead < MIN_LOOKAHEAD\n * OUT assertions: strstart <= window_size-MIN_LOOKAHEAD\n *    At least one byte has been read, or avail_in == 0; reads are\n *    performed for at least two bytes (required for the zip translate_eol\n *    option -- not supported here).\n */\nlocal void fill_window(s)\n    deflate_state *s;\n{\n    unsigned n;\n    unsigned more;    /* Amount of free space at the end of the window. */\n    uInt wsize = s->w_size;\n\n    Assert(s->lookahead < MIN_LOOKAHEAD, \"already enough lookahead\");\n\n    do {\n        more = (unsigned)(s->window_size -(ulg)s->lookahead -(ulg)s->strstart);\n\n        /* Deal with !@#$% 64K limit: */\n        if (sizeof(int) <= 2) {\n            if (more == 0 && s->strstart == 0 && s->lookahead == 0) {\n                more = wsize;\n\n            } else if (more == (unsigned)(-1)) {\n                /* Very unlikely, but possible on 16 bit machine if\n                 * strstart == 0 && lookahead == 1 (input done a byte at time)\n                 */\n                more--;\n            }\n        }\n\n        /* If the window is almost full and there is insufficient lookahead,\n         * move the upper half to the lower one to make room in the upper half.\n         */\n        if (s->strstart >= wsize+MAX_DIST(s)) {\n\n            zmemcpy(s->window, s->window+wsize, (unsigned)wsize - more);\n            s->match_start -= wsize;\n            s->strstart    -= wsize; /* we now have strstart >= MAX_DIST */\n            s->block_start -= (long) wsize;\n            slide_hash(s);\n            more += wsize;\n        }\n        if (s->strm->avail_in == 0) break;\n\n        /* If there was no sliding:\n         *    strstart <= WSIZE+MAX_DIST-1 && lookahead <= MIN_LOOKAHEAD - 1 &&\n         *    more == window_size - lookahead - strstart\n         * => more >= window_size - (MIN_LOOKAHEAD-1 + WSIZE + MAX_DIST-1)\n         * => more >= window_size - 2*WSIZE + 2\n         * In the BIG_MEM or MMAP case (not yet supported),\n         *   window_size == input_size + MIN_LOOKAHEAD  &&\n         *   strstart + s->lookahead <= input_size => more >= MIN_LOOKAHEAD.\n         * Otherwise, window_size == 2*WSIZE so more >= 2.\n         * If there was sliding, more >= WSIZE. So in all cases, more >= 2.\n         */\n        Assert(more >= 2, \"more < 2\");\n\n        n = read_buf(s->strm, s->window + s->strstart + s->lookahead, more);\n        s->lookahead += n;\n\n        /* Initialize the hash value now that we have some input: */\n        if (s->lookahead + s->insert >= MIN_MATCH) {\n            uInt str = s->strstart - s->insert;\n            s->ins_h = s->window[str];\n            UPDATE_HASH(s, s->ins_h, s->window[str + 1]);\n#if MIN_MATCH != 3\n            Call UPDATE_HASH() MIN_MATCH-3 more times\n#endif\n            while (s->insert) {\n                UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]);\n#ifndef FASTEST\n                s->prev[str & s->w_mask] = s->head[s->ins_h];\n#endif\n                s->head[s->ins_h] = (Pos)str;\n                str++;\n                s->insert--;\n                if (s->lookahead + s->insert < MIN_MATCH)\n                    break;\n            }\n        }\n        /* If the whole input has less than MIN_MATCH bytes, ins_h is garbage,\n         * but this is not important since only literal bytes will be emitted.\n         */\n\n    } while (s->lookahead < MIN_LOOKAHEAD && s->strm->avail_in != 0);\n\n    /* If the WIN_INIT bytes after the end of the current data have never been\n     * written, then zero those bytes in order to avoid memory check reports of\n     * the use of uninitialized (or uninitialised as Julian writes) bytes by\n     * the longest match routines.  Update the high water mark for the next\n     * time through here.  WIN_INIT is set to MAX_MATCH since the longest match\n     * routines allow scanning to strstart + MAX_MATCH, ignoring lookahead.\n     */\n    if (s->high_water < s->window_size) {\n        ulg curr = s->strstart + (ulg)(s->lookahead);\n        ulg init;\n\n        if (s->high_water < curr) {\n            /* Previous high water mark below current data -- zero WIN_INIT\n             * bytes or up to end of window, whichever is less.\n             */\n            init = s->window_size - curr;\n            if (init > WIN_INIT)\n                init = WIN_INIT;\n            zmemzero(s->window + curr, (unsigned)init);\n            s->high_water = curr + init;\n        }\n        else if (s->high_water < (ulg)curr + WIN_INIT) {\n            /* High water mark at or above current data, but below current data\n             * plus WIN_INIT -- zero out to current data plus WIN_INIT, or up\n             * to end of window, whichever is less.\n             */\n            init = (ulg)curr + WIN_INIT - s->high_water;\n            if (init > s->window_size - s->high_water)\n                init = s->window_size - s->high_water;\n            zmemzero(s->window + s->high_water, (unsigned)init);\n            s->high_water += init;\n        }\n    }\n\n    Assert((ulg)s->strstart <= s->window_size - MIN_LOOKAHEAD,\n           \"not enough room for search\");\n}\n\n/* ===========================================================================\n * Flush the current block, with given end-of-file flag.\n * IN assertion: strstart is set to the end of the current match.\n */\n#define FLUSH_BLOCK_ONLY(s, last) { \\\n   _tr_flush_block(s, (s->block_start >= 0L ? \\\n                   (charf *)&s->window[(unsigned)s->block_start] : \\\n                   (charf *)Z_NULL), \\\n                (ulg)((long)s->strstart - s->block_start), \\\n                (last)); \\\n   s->block_start = s->strstart; \\\n   flush_pending(s->strm); \\\n   Tracev((stderr,\"[FLUSH]\")); \\\n}\n\n/* Same but force premature exit if necessary. */\n#define FLUSH_BLOCK(s, last) { \\\n   FLUSH_BLOCK_ONLY(s, last); \\\n   if (s->strm->avail_out == 0) return (last) ? finish_started : need_more; \\\n}\n\n/* Maximum stored block length in deflate format (not including header). */\n#define MAX_STORED 65535\n\n/* Minimum of a and b. */\n#define MIN(a, b) ((a) > (b) ? (b) : (a))\n\n/* ===========================================================================\n * Copy without compression as much as possible from the input stream, return\n * the current block state.\n *\n * In case deflateParams() is used to later switch to a non-zero compression\n * level, s->matches (otherwise unused when storing) keeps track of the number\n * of hash table slides to perform. If s->matches is 1, then one hash table\n * slide will be done when switching. If s->matches is 2, the maximum value\n * allowed here, then the hash table will be cleared, since two or more slides\n * is the same as a clear.\n *\n * deflate_stored() is written to minimize the number of times an input byte is\n * copied. It is most efficient with large input and output buffers, which\n * maximizes the opportunites to have a single copy from next_in to next_out.\n */\nlocal block_state deflate_stored(s, flush)\n    deflate_state *s;\n    int flush;\n{\n    /* Smallest worthy block size when not flushing or finishing. By default\n     * this is 32K. This can be as small as 507 bytes for memLevel == 1. For\n     * large input and output buffers, the stored block size will be larger.\n     */\n    unsigned min_block = MIN(s->pending_buf_size - 5, s->w_size);\n\n    /* Copy as many min_block or larger stored blocks directly to next_out as\n     * possible. If flushing, copy the remaining available input to next_out as\n     * stored blocks, if there is enough space.\n     */\n    unsigned len, left, have, last = 0;\n    unsigned used = s->strm->avail_in;\n    do {\n        /* Set len to the maximum size block that we can copy directly with the\n         * available input data and output space. Set left to how much of that\n         * would be copied from what's left in the window.\n         */\n        len = MAX_STORED;       /* maximum deflate stored block length */\n        have = (s->bi_valid + 42) >> 3;         /* number of header bytes */\n        if (s->strm->avail_out < have)          /* need room for header */\n            break;\n            /* maximum stored block length that will fit in avail_out: */\n        have = s->strm->avail_out - have;\n        left = s->strstart - s->block_start;    /* bytes left in window */\n        if (len > (ulg)left + s->strm->avail_in)\n            len = left + s->strm->avail_in;     /* limit len to the input */\n        if (len > have)\n            len = have;                         /* limit len to the output */\n\n        /* If the stored block would be less than min_block in length, or if\n         * unable to copy all of the available input when flushing, then try\n         * copying to the window and the pending buffer instead. Also don't\n         * write an empty block when flushing -- deflate() does that.\n         */\n        if (len < min_block && ((len == 0 && flush != Z_FINISH) ||\n                                flush == Z_NO_FLUSH ||\n                                len != left + s->strm->avail_in))\n            break;\n\n        /* Make a dummy stored block in pending to get the header bytes,\n         * including any pending bits. This also updates the debugging counts.\n         */\n        last = flush == Z_FINISH && len == left + s->strm->avail_in ? 1 : 0;\n        _tr_stored_block(s, (char *)0, 0L, last);\n\n        /* Replace the lengths in the dummy stored block with len. */\n        s->pending_buf[s->pending - 4] = len;\n        s->pending_buf[s->pending - 3] = len >> 8;\n        s->pending_buf[s->pending - 2] = ~len;\n        s->pending_buf[s->pending - 1] = ~len >> 8;\n\n        /* Write the stored block header bytes. */\n        flush_pending(s->strm);\n\n#ifdef ZLIB_DEBUG\n        /* Update debugging counts for the data about to be copied. */\n        s->compressed_len += len << 3;\n        s->bits_sent += len << 3;\n#endif\n\n        /* Copy uncompressed bytes from the window to next_out. */\n        if (left) {\n            if (left > len)\n                left = len;\n            zmemcpy(s->strm->next_out, s->window + s->block_start, left);\n            s->strm->next_out += left;\n            s->strm->avail_out -= left;\n            s->strm->total_out += left;\n            s->block_start += left;\n            len -= left;\n        }\n\n        /* Copy uncompressed bytes directly from next_in to next_out, updating\n         * the check value.\n         */\n        if (len) {\n            read_buf(s->strm, s->strm->next_out, len);\n            s->strm->next_out += len;\n            s->strm->avail_out -= len;\n            s->strm->total_out += len;\n        }\n    } while (last == 0);\n\n    /* Update the sliding window with the last s->w_size bytes of the copied\n     * data, or append all of the copied data to the existing window if less\n     * than s->w_size bytes were copied. Also update the number of bytes to\n     * insert in the hash tables, in the event that deflateParams() switches to\n     * a non-zero compression level.\n     */\n    used -= s->strm->avail_in;      /* number of input bytes directly copied */\n    if (used) {\n        /* If any input was used, then no unused input remains in the window,\n         * therefore s->block_start == s->strstart.\n         */\n        if (used >= s->w_size) {    /* supplant the previous history */\n            s->matches = 2;         /* clear hash */\n            zmemcpy(s->window, s->strm->next_in - s->w_size, s->w_size);\n            s->strstart = s->w_size;\n        }\n        else {\n            if (s->window_size - s->strstart <= used) {\n                /* Slide the window down. */\n                s->strstart -= s->w_size;\n                zmemcpy(s->window, s->window + s->w_size, s->strstart);\n                if (s->matches < 2)\n                    s->matches++;   /* add a pending slide_hash() */\n            }\n            zmemcpy(s->window + s->strstart, s->strm->next_in - used, used);\n            s->strstart += used;\n        }\n        s->block_start = s->strstart;\n        s->insert += MIN(used, s->w_size - s->insert);\n    }\n    if (s->high_water < s->strstart)\n        s->high_water = s->strstart;\n\n    /* If the last block was written to next_out, then done. */\n    if (last)\n        return finish_done;\n\n    /* If flushing and all input has been consumed, then done. */\n    if (flush != Z_NO_FLUSH && flush != Z_FINISH &&\n        s->strm->avail_in == 0 && (long)s->strstart == s->block_start)\n        return block_done;\n\n    /* Fill the window with any remaining input. */\n    have = s->window_size - s->strstart - 1;\n    if (s->strm->avail_in > have && s->block_start >= (long)s->w_size) {\n        /* Slide the window down. */\n        s->block_start -= s->w_size;\n        s->strstart -= s->w_size;\n        zmemcpy(s->window, s->window + s->w_size, s->strstart);\n        if (s->matches < 2)\n            s->matches++;           /* add a pending slide_hash() */\n        have += s->w_size;          /* more space now */\n    }\n    if (have > s->strm->avail_in)\n        have = s->strm->avail_in;\n    if (have) {\n        read_buf(s->strm, s->window + s->strstart, have);\n        s->strstart += have;\n    }\n    if (s->high_water < s->strstart)\n        s->high_water = s->strstart;\n\n    /* There was not enough avail_out to write a complete worthy or flushed\n     * stored block to next_out. Write a stored block to pending instead, if we\n     * have enough input for a worthy block, or if flushing and there is enough\n     * room for the remaining input as a stored block in the pending buffer.\n     */\n    have = (s->bi_valid + 42) >> 3;         /* number of header bytes */\n        /* maximum stored block length that will fit in pending: */\n    have = MIN(s->pending_buf_size - have, MAX_STORED);\n    min_block = MIN(have, s->w_size);\n    left = s->strstart - s->block_start;\n    if (left >= min_block ||\n        ((left || flush == Z_FINISH) && flush != Z_NO_FLUSH &&\n         s->strm->avail_in == 0 && left <= have)) {\n        len = MIN(left, have);\n        last = flush == Z_FINISH && s->strm->avail_in == 0 &&\n               len == left ? 1 : 0;\n        _tr_stored_block(s, (charf *)s->window + s->block_start, len, last);\n        s->block_start += len;\n        flush_pending(s->strm);\n    }\n\n    /* We've done all we can with the available input and output. */\n    return last ? finish_started : need_more;\n}\n\n/* ===========================================================================\n * Compress as much as possible from the input stream, return the current\n * block state.\n * This function does not perform lazy evaluation of matches and inserts\n * new strings in the dictionary only for unmatched strings or for short\n * matches. It is used only for the fast compression options.\n */\nlocal block_state deflate_fast(s, flush)\n    deflate_state *s;\n    int flush;\n{\n    IPos hash_head;       /* head of the hash chain */\n    int bflush;           /* set if current block must be flushed */\n\n    for (;;) {\n        /* Make sure that we always have enough lookahead, except\n         * at the end of the input file. We need MAX_MATCH bytes\n         * for the next match, plus MIN_MATCH bytes to insert the\n         * string following the next match.\n         */\n        if (s->lookahead < MIN_LOOKAHEAD) {\n            fill_window(s);\n            if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) {\n                return need_more;\n            }\n            if (s->lookahead == 0) break; /* flush the current block */\n        }\n\n        /* Insert the string window[strstart .. strstart+2] in the\n         * dictionary, and set hash_head to the head of the hash chain:\n         */\n        hash_head = NIL;\n        if (s->lookahead >= MIN_MATCH) {\n            INSERT_STRING(s, s->strstart, hash_head);\n        }\n\n        /* Find the longest match, discarding those <= prev_length.\n         * At this point we have always match_length < MIN_MATCH\n         */\n        if (hash_head != NIL && s->strstart - hash_head <= MAX_DIST(s)) {\n            /* To simplify the code, we prevent matches with the string\n             * of window index 0 (in particular we have to avoid a match\n             * of the string with itself at the start of the input file).\n             */\n            s->match_length = longest_match (s, hash_head);\n            /* longest_match() sets match_start */\n        }\n        if (s->match_length >= MIN_MATCH) {\n            check_match(s, s->strstart, s->match_start, s->match_length);\n\n            _tr_tally_dist(s, s->strstart - s->match_start,\n                           s->match_length - MIN_MATCH, bflush);\n\n            s->lookahead -= s->match_length;\n\n            /* Insert new strings in the hash table only if the match length\n             * is not too large. This saves time but degrades compression.\n             */\n#ifndef FASTEST\n            if (s->match_length <= s->max_insert_length &&\n                s->lookahead >= MIN_MATCH) {\n                s->match_length--; /* string at strstart already in table */\n                do {\n                    s->strstart++;\n                    INSERT_STRING(s, s->strstart, hash_head);\n                    /* strstart never exceeds WSIZE-MAX_MATCH, so there are\n                     * always MIN_MATCH bytes ahead.\n                     */\n                } while (--s->match_length != 0);\n                s->strstart++;\n            } else\n#endif\n            {\n                s->strstart += s->match_length;\n                s->match_length = 0;\n                s->ins_h = s->window[s->strstart];\n                UPDATE_HASH(s, s->ins_h, s->window[s->strstart+1]);\n#if MIN_MATCH != 3\n                Call UPDATE_HASH() MIN_MATCH-3 more times\n#endif\n                /* If lookahead < MIN_MATCH, ins_h is garbage, but it does not\n                 * matter since it will be recomputed at next deflate call.\n                 */\n            }\n        } else {\n            /* No match, output a literal byte */\n            Tracevv((stderr,\"%c\", s->window[s->strstart]));\n            _tr_tally_lit (s, s->window[s->strstart], bflush);\n            s->lookahead--;\n            s->strstart++;\n        }\n        if (bflush) FLUSH_BLOCK(s, 0);\n    }\n    s->insert = s->strstart < MIN_MATCH-1 ? s->strstart : MIN_MATCH-1;\n    if (flush == Z_FINISH) {\n        FLUSH_BLOCK(s, 1);\n        return finish_done;\n    }\n    if (s->last_lit)\n        FLUSH_BLOCK(s, 0);\n    return block_done;\n}\n\n#ifndef FASTEST\n/* ===========================================================================\n * Same as above, but achieves better compression. We use a lazy\n * evaluation for matches: a match is finally adopted only if there is\n * no better match at the next window position.\n */\nlocal block_state deflate_slow(s, flush)\n    deflate_state *s;\n    int flush;\n{\n    IPos hash_head;          /* head of hash chain */\n    int bflush;              /* set if current block must be flushed */\n\n    /* Process the input block. */\n    for (;;) {\n        /* Make sure that we always have enough lookahead, except\n         * at the end of the input file. We need MAX_MATCH bytes\n         * for the next match, plus MIN_MATCH bytes to insert the\n         * string following the next match.\n         */\n        if (s->lookahead < MIN_LOOKAHEAD) {\n            fill_window(s);\n            if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) {\n                return need_more;\n            }\n            if (s->lookahead == 0) break; /* flush the current block */\n        }\n\n        /* Insert the string window[strstart .. strstart+2] in the\n         * dictionary, and set hash_head to the head of the hash chain:\n         */\n        hash_head = NIL;\n        if (s->lookahead >= MIN_MATCH) {\n            INSERT_STRING(s, s->strstart, hash_head);\n        }\n\n        /* Find the longest match, discarding those <= prev_length.\n         */\n        s->prev_length = s->match_length, s->prev_match = s->match_start;\n        s->match_length = MIN_MATCH-1;\n\n        if (hash_head != NIL && s->prev_length < s->max_lazy_match &&\n            s->strstart - hash_head <= MAX_DIST(s)) {\n            /* To simplify the code, we prevent matches with the string\n             * of window index 0 (in particular we have to avoid a match\n             * of the string with itself at the start of the input file).\n             */\n            s->match_length = longest_match (s, hash_head);\n            /* longest_match() sets match_start */\n\n            if (s->match_length <= 5 && (s->strategy == Z_FILTERED\n#if TOO_FAR <= 32767\n                || (s->match_length == MIN_MATCH &&\n                    s->strstart - s->match_start > TOO_FAR)\n#endif\n                )) {\n\n                /* If prev_match is also MIN_MATCH, match_start is garbage\n                 * but we will ignore the current match anyway.\n                 */\n                s->match_length = MIN_MATCH-1;\n            }\n        }\n        /* If there was a match at the previous step and the current\n         * match is not better, output the previous match:\n         */\n        if (s->prev_length >= MIN_MATCH && s->match_length <= s->prev_length) {\n            uInt max_insert = s->strstart + s->lookahead - MIN_MATCH;\n            /* Do not insert strings in hash table beyond this. */\n\n            check_match(s, s->strstart-1, s->prev_match, s->prev_length);\n\n            _tr_tally_dist(s, s->strstart -1 - s->prev_match,\n                           s->prev_length - MIN_MATCH, bflush);\n\n            /* Insert in hash table all strings up to the end of the match.\n             * strstart-1 and strstart are already inserted. If there is not\n             * enough lookahead, the last two strings are not inserted in\n             * the hash table.\n             */\n            s->lookahead -= s->prev_length-1;\n            s->prev_length -= 2;\n            do {\n                if (++s->strstart <= max_insert) {\n                    INSERT_STRING(s, s->strstart, hash_head);\n                }\n            } while (--s->prev_length != 0);\n            s->match_available = 0;\n            s->match_length = MIN_MATCH-1;\n            s->strstart++;\n\n            if (bflush) FLUSH_BLOCK(s, 0);\n\n        } else if (s->match_available) {\n            /* If there was no match at the previous position, output a\n             * single literal. If there was a match but the current match\n             * is longer, truncate the previous match to a single literal.\n             */\n            Tracevv((stderr,\"%c\", s->window[s->strstart-1]));\n            _tr_tally_lit(s, s->window[s->strstart-1], bflush);\n            if (bflush) {\n                FLUSH_BLOCK_ONLY(s, 0);\n            }\n            s->strstart++;\n            s->lookahead--;\n            if (s->strm->avail_out == 0) return need_more;\n        } else {\n            /* There is no previous match to compare with, wait for\n             * the next step to decide.\n             */\n            s->match_available = 1;\n            s->strstart++;\n            s->lookahead--;\n        }\n    }\n    Assert (flush != Z_NO_FLUSH, \"no flush?\");\n    if (s->match_available) {\n        Tracevv((stderr,\"%c\", s->window[s->strstart-1]));\n        _tr_tally_lit(s, s->window[s->strstart-1], bflush);\n        s->match_available = 0;\n    }\n    s->insert = s->strstart < MIN_MATCH-1 ? s->strstart : MIN_MATCH-1;\n    if (flush == Z_FINISH) {\n        FLUSH_BLOCK(s, 1);\n        return finish_done;\n    }\n    if (s->last_lit)\n        FLUSH_BLOCK(s, 0);\n    return block_done;\n}\n#endif /* FASTEST */\n\n/* ===========================================================================\n * For Z_RLE, simply look for runs of bytes, generate matches only of distance\n * one.  Do not maintain a hash table.  (It will be regenerated if this run of\n * deflate switches away from Z_RLE.)\n */\nlocal block_state deflate_rle(s, flush)\n    deflate_state *s;\n    int flush;\n{\n    int bflush;             /* set if current block must be flushed */\n    uInt prev;              /* byte at distance one to match */\n    Bytef *scan, *strend;   /* scan goes up to strend for length of run */\n\n    for (;;) {\n        /* Make sure that we always have enough lookahead, except\n         * at the end of the input file. We need MAX_MATCH bytes\n         * for the longest run, plus one for the unrolled loop.\n         */\n        if (s->lookahead <= MAX_MATCH) {\n            fill_window(s);\n            if (s->lookahead <= MAX_MATCH && flush == Z_NO_FLUSH) {\n                return need_more;\n            }\n            if (s->lookahead == 0) break; /* flush the current block */\n        }\n\n        /* See how many times the previous byte repeats */\n        s->match_length = 0;\n        if (s->lookahead >= MIN_MATCH && s->strstart > 0) {\n            scan = s->window + s->strstart - 1;\n            prev = *scan;\n            if (prev == *++scan && prev == *++scan && prev == *++scan) {\n                strend = s->window + s->strstart + MAX_MATCH;\n                do {\n                } while (prev == *++scan && prev == *++scan &&\n                         prev == *++scan && prev == *++scan &&\n                         prev == *++scan && prev == *++scan &&\n                         prev == *++scan && prev == *++scan &&\n                         scan < strend);\n                s->match_length = MAX_MATCH - (uInt)(strend - scan);\n                if (s->match_length > s->lookahead)\n                    s->match_length = s->lookahead;\n            }\n            Assert(scan <= s->window+(uInt)(s->window_size-1), \"wild scan\");\n        }\n\n        /* Emit match if have run of MIN_MATCH or longer, else emit literal */\n        if (s->match_length >= MIN_MATCH) {\n            check_match(s, s->strstart, s->strstart - 1, s->match_length);\n\n            _tr_tally_dist(s, 1, s->match_length - MIN_MATCH, bflush);\n\n            s->lookahead -= s->match_length;\n            s->strstart += s->match_length;\n            s->match_length = 0;\n        } else {\n            /* No match, output a literal byte */\n            Tracevv((stderr,\"%c\", s->window[s->strstart]));\n            _tr_tally_lit (s, s->window[s->strstart], bflush);\n            s->lookahead--;\n            s->strstart++;\n        }\n        if (bflush) FLUSH_BLOCK(s, 0);\n    }\n    s->insert = 0;\n    if (flush == Z_FINISH) {\n        FLUSH_BLOCK(s, 1);\n        return finish_done;\n    }\n    if (s->last_lit)\n        FLUSH_BLOCK(s, 0);\n    return block_done;\n}\n\n/* ===========================================================================\n * For Z_HUFFMAN_ONLY, do not look for matches.  Do not maintain a hash table.\n * (It will be regenerated if this run of deflate switches away from Huffman.)\n */\nlocal block_state deflate_huff(s, flush)\n    deflate_state *s;\n    int flush;\n{\n    int bflush;             /* set if current block must be flushed */\n\n    for (;;) {\n        /* Make sure that we have a literal to write. */\n        if (s->lookahead == 0) {\n            fill_window(s);\n            if (s->lookahead == 0) {\n                if (flush == Z_NO_FLUSH)\n                    return need_more;\n                break;      /* flush the current block */\n            }\n        }\n\n        /* Output a literal byte */\n        s->match_length = 0;\n        Tracevv((stderr,\"%c\", s->window[s->strstart]));\n        _tr_tally_lit (s, s->window[s->strstart], bflush);\n        s->lookahead--;\n        s->strstart++;\n        if (bflush) FLUSH_BLOCK(s, 0);\n    }\n    s->insert = 0;\n    if (flush == Z_FINISH) {\n        FLUSH_BLOCK(s, 1);\n        return finish_done;\n    }\n    if (s->last_lit)\n        FLUSH_BLOCK(s, 0);\n    return block_done;\n}\n"
  },
  {
    "path": "Projects/Libraries/CSBase/Source/zlib/deflate.h",
    "content": "/* deflate.h -- internal compression state\n * Copyright (C) 1995-2016 Jean-loup Gailly\n * For conditions of distribution and use, see copyright notice in zlib.h\n */\n\n/* WARNING: this file should *not* be used by applications. It is\n   part of the implementation of the compression library and is\n   subject to change. Applications should only use zlib.h.\n */\n\n/* @(#) $Id$ */\n\n#ifndef DEFLATE_H\n#define DEFLATE_H\n\n#include \"zutil.h\"\n\n/* define NO_GZIP when compiling if you want to disable gzip header and\n   trailer creation by deflate().  NO_GZIP would be used to avoid linking in\n   the crc code when it is not needed.  For shared libraries, gzip encoding\n   should be left enabled. */\n#ifndef NO_GZIP\n#  define GZIP\n#endif\n\n/* ===========================================================================\n * Internal compression state.\n */\n\n#define LENGTH_CODES 29\n/* number of length codes, not counting the special END_BLOCK code */\n\n#define LITERALS  256\n/* number of literal bytes 0..255 */\n\n#define L_CODES (LITERALS+1+LENGTH_CODES)\n/* number of Literal or Length codes, including the END_BLOCK code */\n\n#define D_CODES   30\n/* number of distance codes */\n\n#define BL_CODES  19\n/* number of codes used to transfer the bit lengths */\n\n#define HEAP_SIZE (2*L_CODES+1)\n/* maximum heap size */\n\n#define MAX_BITS 15\n/* All codes must not exceed MAX_BITS bits */\n\n#define Buf_size 16\n/* size of bit buffer in bi_buf */\n\n#define INIT_STATE    42    /* zlib header -> BUSY_STATE */\n#ifdef GZIP\n#  define GZIP_STATE  57    /* gzip header -> BUSY_STATE | EXTRA_STATE */\n#endif\n#define EXTRA_STATE   69    /* gzip extra block -> NAME_STATE */\n#define NAME_STATE    73    /* gzip file name -> COMMENT_STATE */\n#define COMMENT_STATE 91    /* gzip comment -> HCRC_STATE */\n#define HCRC_STATE   103    /* gzip header CRC -> BUSY_STATE */\n#define BUSY_STATE   113    /* deflate -> FINISH_STATE */\n#define FINISH_STATE 666    /* stream complete */\n/* Stream status */\n\n\n/* Data structure describing a single value and its code string. */\ntypedef struct ct_data_s {\n    union {\n        ush  freq;       /* frequency count */\n        ush  code;       /* bit string */\n    } fc;\n    union {\n        ush  dad;        /* father node in Huffman tree */\n        ush  len;        /* length of bit string */\n    } dl;\n} FAR ct_data;\n\n#define Freq fc.freq\n#define Code fc.code\n#define Dad  dl.dad\n#define Len  dl.len\n\ntypedef struct static_tree_desc_s  static_tree_desc;\n\ntypedef struct tree_desc_s {\n    ct_data *dyn_tree;           /* the dynamic tree */\n    int     max_code;            /* largest code with non zero frequency */\n    const static_tree_desc *stat_desc;  /* the corresponding static tree */\n} FAR tree_desc;\n\ntypedef ush Pos;\ntypedef Pos FAR Posf;\ntypedef unsigned IPos;\n\n/* A Pos is an index in the character window. We use short instead of int to\n * save space in the various tables. IPos is used only for parameter passing.\n */\n\ntypedef struct internal_state {\n    z_streamp strm;      /* pointer back to this zlib stream */\n    int   status;        /* as the name implies */\n    Bytef *pending_buf;  /* output still pending */\n    ulg   pending_buf_size; /* size of pending_buf */\n    Bytef *pending_out;  /* next pending byte to output to the stream */\n    ulg   pending;       /* nb of bytes in the pending buffer */\n    int   wrap;          /* bit 0 true for zlib, bit 1 true for gzip */\n    gz_headerp  gzhead;  /* gzip header information to write */\n    ulg   gzindex;       /* where in extra, name, or comment */\n    Byte  method;        /* can only be DEFLATED */\n    int   last_flush;    /* value of flush param for previous deflate call */\n\n                /* used by deflate.c: */\n\n    uInt  w_size;        /* LZ77 window size (32K by default) */\n    uInt  w_bits;        /* log2(w_size)  (8..16) */\n    uInt  w_mask;        /* w_size - 1 */\n\n    Bytef *window;\n    /* Sliding window. Input bytes are read into the second half of the window,\n     * and move to the first half later to keep a dictionary of at least wSize\n     * bytes. With this organization, matches are limited to a distance of\n     * wSize-MAX_MATCH bytes, but this ensures that IO is always\n     * performed with a length multiple of the block size. Also, it limits\n     * the window size to 64K, which is quite useful on MSDOS.\n     * To do: use the user input buffer as sliding window.\n     */\n\n    ulg window_size;\n    /* Actual size of window: 2*wSize, except when the user input buffer\n     * is directly used as sliding window.\n     */\n\n    Posf *prev;\n    /* Link to older string with same hash index. To limit the size of this\n     * array to 64K, this link is maintained only for the last 32K strings.\n     * An index in this array is thus a window index modulo 32K.\n     */\n\n    Posf *head; /* Heads of the hash chains or NIL. */\n\n    uInt  ins_h;          /* hash index of string to be inserted */\n    uInt  hash_size;      /* number of elements in hash table */\n    uInt  hash_bits;      /* log2(hash_size) */\n    uInt  hash_mask;      /* hash_size-1 */\n\n    uInt  hash_shift;\n    /* Number of bits by which ins_h must be shifted at each input\n     * step. It must be such that after MIN_MATCH steps, the oldest\n     * byte no longer takes part in the hash key, that is:\n     *   hash_shift * MIN_MATCH >= hash_bits\n     */\n\n    long block_start;\n    /* Window position at the beginning of the current output block. Gets\n     * negative when the window is moved backwards.\n     */\n\n    uInt match_length;           /* length of best match */\n    IPos prev_match;             /* previous match */\n    int match_available;         /* set if previous match exists */\n    uInt strstart;               /* start of string to insert */\n    uInt match_start;            /* start of matching string */\n    uInt lookahead;              /* number of valid bytes ahead in window */\n\n    uInt prev_length;\n    /* Length of the best match at previous step. Matches not greater than this\n     * are discarded. This is used in the lazy match evaluation.\n     */\n\n    uInt max_chain_length;\n    /* To speed up deflation, hash chains are never searched beyond this\n     * length.  A higher limit improves compression ratio but degrades the\n     * speed.\n     */\n\n    uInt max_lazy_match;\n    /* Attempt to find a better match only when the current match is strictly\n     * smaller than this value. This mechanism is used only for compression\n     * levels >= 4.\n     */\n#   define max_insert_length  max_lazy_match\n    /* Insert new strings in the hash table only if the match length is not\n     * greater than this length. This saves time but degrades compression.\n     * max_insert_length is used only for compression levels <= 3.\n     */\n\n    int level;    /* compression level (1..9) */\n    int strategy; /* favor or force Huffman coding*/\n\n    uInt good_match;\n    /* Use a faster search when the previous match is longer than this */\n\n    int nice_match; /* Stop searching when current match exceeds this */\n\n                /* used by trees.c: */\n    /* Didn't use ct_data typedef below to suppress compiler warning */\n    struct ct_data_s dyn_ltree[HEAP_SIZE];   /* literal and length tree */\n    struct ct_data_s dyn_dtree[2*D_CODES+1]; /* distance tree */\n    struct ct_data_s bl_tree[2*BL_CODES+1];  /* Huffman tree for bit lengths */\n\n    struct tree_desc_s l_desc;               /* desc. for literal tree */\n    struct tree_desc_s d_desc;               /* desc. for distance tree */\n    struct tree_desc_s bl_desc;              /* desc. for bit length tree */\n\n    ush bl_count[MAX_BITS+1];\n    /* number of codes at each bit length for an optimal tree */\n\n    int heap[2*L_CODES+1];      /* heap used to build the Huffman trees */\n    int heap_len;               /* number of elements in the heap */\n    int heap_max;               /* element of largest frequency */\n    /* The sons of heap[n] are heap[2*n] and heap[2*n+1]. heap[0] is not used.\n     * The same heap array is used to build all trees.\n     */\n\n    uch depth[2*L_CODES+1];\n    /* Depth of each subtree used as tie breaker for trees of equal frequency\n     */\n\n    uchf *l_buf;          /* buffer for literals or lengths */\n\n    uInt  lit_bufsize;\n    /* Size of match buffer for literals/lengths.  There are 4 reasons for\n     * limiting lit_bufsize to 64K:\n     *   - frequencies can be kept in 16 bit counters\n     *   - if compression is not successful for the first block, all input\n     *     data is still in the window so we can still emit a stored block even\n     *     when input comes from standard input.  (This can also be done for\n     *     all blocks if lit_bufsize is not greater than 32K.)\n     *   - if compression is not successful for a file smaller than 64K, we can\n     *     even emit a stored file instead of a stored block (saving 5 bytes).\n     *     This is applicable only for zip (not gzip or zlib).\n     *   - creating new Huffman trees less frequently may not provide fast\n     *     adaptation to changes in the input data statistics. (Take for\n     *     example a binary file with poorly compressible code followed by\n     *     a highly compressible string table.) Smaller buffer sizes give\n     *     fast adaptation but have of course the overhead of transmitting\n     *     trees more frequently.\n     *   - I can't count above 4\n     */\n\n    uInt last_lit;      /* running index in l_buf */\n\n    ushf *d_buf;\n    /* Buffer for distances. To simplify the code, d_buf and l_buf have\n     * the same number of elements. To use different lengths, an extra flag\n     * array would be necessary.\n     */\n\n    ulg opt_len;        /* bit length of current block with optimal trees */\n    ulg static_len;     /* bit length of current block with static trees */\n    uInt matches;       /* number of string matches in current block */\n    uInt insert;        /* bytes at end of window left to insert */\n\n#ifdef ZLIB_DEBUG\n    ulg compressed_len; /* total bit length of compressed file mod 2^32 */\n    ulg bits_sent;      /* bit length of compressed data sent mod 2^32 */\n#endif\n\n    ush bi_buf;\n    /* Output buffer. bits are inserted starting at the bottom (least\n     * significant bits).\n     */\n    int bi_valid;\n    /* Number of valid bits in bi_buf.  All bits above the last valid bit\n     * are always zero.\n     */\n\n    ulg high_water;\n    /* High water mark offset in window for initialized bytes -- bytes above\n     * this are set to zero in order to avoid memory check warnings when\n     * longest match routines access bytes past the input.  This is then\n     * updated to the new high water mark.\n     */\n\n} FAR deflate_state;\n\n/* Output a byte on the stream.\n * IN assertion: there is enough room in pending_buf.\n */\n#define put_byte(s, c) {s->pending_buf[s->pending++] = (Bytef)(c);}\n\n\n#define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1)\n/* Minimum amount of lookahead, except at the end of the input file.\n * See deflate.c for comments about the MIN_MATCH+1.\n */\n\n#define MAX_DIST(s)  ((s)->w_size-MIN_LOOKAHEAD)\n/* In order to simplify the code, particularly on 16 bit machines, match\n * distances are limited to MAX_DIST instead of WSIZE.\n */\n\n#define WIN_INIT MAX_MATCH\n/* Number of bytes after end of data in window to initialize in order to avoid\n   memory checker errors from longest match routines */\n\n        /* in trees.c */\nvoid ZLIB_INTERNAL _tr_init OF((deflate_state *s));\nint ZLIB_INTERNAL _tr_tally OF((deflate_state *s, unsigned dist, unsigned lc));\nvoid ZLIB_INTERNAL _tr_flush_block OF((deflate_state *s, charf *buf,\n                        ulg stored_len, int last));\nvoid ZLIB_INTERNAL _tr_flush_bits OF((deflate_state *s));\nvoid ZLIB_INTERNAL _tr_align OF((deflate_state *s));\nvoid ZLIB_INTERNAL _tr_stored_block OF((deflate_state *s, charf *buf,\n                        ulg stored_len, int last));\n\n#define d_code(dist) \\\n   ((dist) < 256 ? _dist_code[dist] : _dist_code[256+((dist)>>7)])\n/* Mapping from a distance to a distance code. dist is the distance - 1 and\n * must not have side effects. _dist_code[256] and _dist_code[257] are never\n * used.\n */\n\n#ifndef ZLIB_DEBUG\n/* Inline versions of _tr_tally for speed: */\n\n#if defined(GEN_TREES_H) || !defined(STDC)\n  extern uch ZLIB_INTERNAL _length_code[];\n  extern uch ZLIB_INTERNAL _dist_code[];\n#else\n  extern const uch ZLIB_INTERNAL _length_code[];\n  extern const uch ZLIB_INTERNAL _dist_code[];\n#endif\n\n# define _tr_tally_lit(s, c, flush) \\\n  { uch cc = (c); \\\n    s->d_buf[s->last_lit] = 0; \\\n    s->l_buf[s->last_lit++] = cc; \\\n    s->dyn_ltree[cc].Freq++; \\\n    flush = (s->last_lit == s->lit_bufsize-1); \\\n   }\n# define _tr_tally_dist(s, distance, length, flush) \\\n  { uch len = (uch)(length); \\\n    ush dist = (ush)(distance); \\\n    s->d_buf[s->last_lit] = dist; \\\n    s->l_buf[s->last_lit++] = len; \\\n    dist--; \\\n    s->dyn_ltree[_length_code[len]+LITERALS+1].Freq++; \\\n    s->dyn_dtree[d_code(dist)].Freq++; \\\n    flush = (s->last_lit == s->lit_bufsize-1); \\\n  }\n#else\n# define _tr_tally_lit(s, c, flush) flush = _tr_tally(s, 0, c)\n# define _tr_tally_dist(s, distance, length, flush) \\\n              flush = _tr_tally(s, distance, length)\n#endif\n\n#endif /* DEFLATE_H */\n"
  },
  {
    "path": "Projects/Libraries/CSBase/Source/zlib/gzclose.c",
    "content": "/* gzclose.c -- zlib gzclose() function\n * Copyright (C) 2004, 2010 Mark Adler\n * For conditions of distribution and use, see copyright notice in zlib.h\n */\n\n#include \"gzguts.h\"\n\n/* gzclose() is in a separate file so that it is linked in only if it is used.\n   That way the other gzclose functions can be used instead to avoid linking in\n   unneeded compression or decompression routines. */\nint ZEXPORT gzclose(file)\n    gzFile file;\n{\n#ifndef NO_GZCOMPRESS\n    gz_statep state;\n\n    if (file == NULL)\n        return Z_STREAM_ERROR;\n    state = (gz_statep)file;\n\n    return state->mode == GZ_READ ? gzclose_r(file) : gzclose_w(file);\n#else\n    return gzclose_r(file);\n#endif\n}\n"
  },
  {
    "path": "Projects/Libraries/CSBase/Source/zlib/gzguts.h",
    "content": "/* gzguts.h -- zlib internal header definitions for gz* operations\n * Copyright (C) 2004, 2005, 2010, 2011, 2012, 2013, 2016 Mark Adler\n * For conditions of distribution and use, see copyright notice in zlib.h\n */\n\n#ifdef _LARGEFILE64_SOURCE\n#  ifndef _LARGEFILE_SOURCE\n#    define _LARGEFILE_SOURCE 1\n#  endif\n#  ifdef _FILE_OFFSET_BITS\n#    undef _FILE_OFFSET_BITS\n#  endif\n#endif\n\n#ifdef HAVE_HIDDEN\n#  define ZLIB_INTERNAL __attribute__((visibility (\"hidden\")))\n#else\n#  define ZLIB_INTERNAL\n#endif\n\n#include <stdio.h>\n#include \"zlib.h\"\n#ifdef STDC\n#  include <string.h>\n#  include <stdlib.h>\n#  include <limits.h>\n#endif\n\n#ifndef _POSIX_SOURCE\n#  define _POSIX_SOURCE\n#endif\n#include <fcntl.h>\n\n#ifdef _WIN32\n#  include <stddef.h>\n#endif\n\n#if defined(__TURBOC__) || defined(_MSC_VER) || defined(_WIN32)\n#  include <io.h>\n#endif\n\n#if defined(_WIN32) || defined(__CYGWIN__)\n#  define WIDECHAR\n#endif\n\n#ifdef WINAPI_FAMILY\n#  define open _open\n#  define read _read\n#  define write _write\n#  define close _close\n#endif\n\n#ifdef NO_DEFLATE       /* for compatibility with old definition */\n#  define NO_GZCOMPRESS\n#endif\n\n#if defined(STDC99) || (defined(__TURBOC__) && __TURBOC__ >= 0x550)\n#  ifndef HAVE_VSNPRINTF\n#    define HAVE_VSNPRINTF\n#  endif\n#endif\n\n#if defined(__CYGWIN__)\n#  ifndef HAVE_VSNPRINTF\n#    define HAVE_VSNPRINTF\n#  endif\n#endif\n\n#if defined(MSDOS) && defined(__BORLANDC__) && (BORLANDC > 0x410)\n#  ifndef HAVE_VSNPRINTF\n#    define HAVE_VSNPRINTF\n#  endif\n#endif\n\n#ifndef HAVE_VSNPRINTF\n#  ifdef MSDOS\n/* vsnprintf may exist on some MS-DOS compilers (DJGPP?),\n   but for now we just assume it doesn't. */\n#    define NO_vsnprintf\n#  endif\n#  ifdef __TURBOC__\n#    define NO_vsnprintf\n#  endif\n#  ifdef WIN32\n/* In Win32, vsnprintf is available as the \"non-ANSI\" _vsnprintf. */\n#    if !defined(vsnprintf) && !defined(NO_vsnprintf)\n#      if !defined(_MSC_VER) || ( defined(_MSC_VER) && _MSC_VER < 1500 )\n#         define vsnprintf _vsnprintf\n#      endif\n#    endif\n#  endif\n#  ifdef __SASC\n#    define NO_vsnprintf\n#  endif\n#  ifdef VMS\n#    define NO_vsnprintf\n#  endif\n#  ifdef __OS400__\n#    define NO_vsnprintf\n#  endif\n#  ifdef __MVS__\n#    define NO_vsnprintf\n#  endif\n#endif\n\n/* unlike snprintf (which is required in C99), _snprintf does not guarantee\n   null termination of the result -- however this is only used in gzlib.c where\n   the result is assured to fit in the space provided */\n#if defined(_MSC_VER) && _MSC_VER < 1900\n#  define snprintf _snprintf\n#endif\n\n#ifndef local\n#  define local static\n#endif\n/* since \"static\" is used to mean two completely different things in C, we\n   define \"local\" for the non-static meaning of \"static\", for readability\n   (compile with -Dlocal if your debugger can't find static symbols) */\n\n/* gz* functions always use library allocation functions */\n#ifndef STDC\n  extern voidp  malloc OF((uInt size));\n  extern void   free   OF((voidpf ptr));\n#endif\n\n/* get errno and strerror definition */\n#if defined UNDER_CE\n#  include <windows.h>\n#  define zstrerror() gz_strwinerror((DWORD)GetLastError())\n#else\n#  ifndef NO_STRERROR\n#    include <errno.h>\n#    define zstrerror() strerror(errno)\n#  else\n#    define zstrerror() \"stdio error (consult errno)\"\n#  endif\n#endif\n\n/* provide prototypes for these when building zlib without LFS */\n#if !defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0\n    ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *));\n    ZEXTERN z_off64_t ZEXPORT gzseek64 OF((gzFile, z_off64_t, int));\n    ZEXTERN z_off64_t ZEXPORT gztell64 OF((gzFile));\n    ZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile));\n#endif\n\n/* default memLevel */\n#if MAX_MEM_LEVEL >= 8\n#  define DEF_MEM_LEVEL 8\n#else\n#  define DEF_MEM_LEVEL  MAX_MEM_LEVEL\n#endif\n\n/* default i/o buffer size -- double this for output when reading (this and\n   twice this must be able to fit in an unsigned type) */\n#define GZBUFSIZE 8192\n\n/* gzip modes, also provide a little integrity check on the passed structure */\n#define GZ_NONE 0\n#define GZ_READ 7247\n#define GZ_WRITE 31153\n#define GZ_APPEND 1     /* mode set to GZ_WRITE after the file is opened */\n\n/* values for gz_state how */\n#define LOOK 0      /* look for a gzip header */\n#define COPY 1      /* copy input directly */\n#define GZIP 2      /* decompress a gzip stream */\n\n/* internal gzip file state data structure */\ntypedef struct {\n        /* exposed contents for gzgetc() macro */\n    struct gzFile_s x;      /* \"x\" for exposed */\n                            /* x.have: number of bytes available at x.next */\n                            /* x.next: next output data to deliver or write */\n                            /* x.pos: current position in uncompressed data */\n        /* used for both reading and writing */\n    int mode;               /* see gzip modes above */\n    int fd;                 /* file descriptor */\n    char *path;             /* path or fd for error messages */\n    unsigned size;          /* buffer size, zero if not allocated yet */\n    unsigned want;          /* requested buffer size, default is GZBUFSIZE */\n    unsigned char *in;      /* input buffer (double-sized when writing) */\n    unsigned char *out;     /* output buffer (double-sized when reading) */\n    int direct;             /* 0 if processing gzip, 1 if transparent */\n        /* just for reading */\n    int how;                /* 0: get header, 1: copy, 2: decompress */\n    z_off64_t start;        /* where the gzip data started, for rewinding */\n    int eof;                /* true if end of input file reached */\n    int past;               /* true if read requested past end */\n        /* just for writing */\n    int level;              /* compression level */\n    int strategy;           /* compression strategy */\n        /* seek request */\n    z_off64_t skip;         /* amount to skip (already rewound if backwards) */\n    int seek;               /* true if seek request pending */\n        /* error information */\n    int err;                /* error code */\n    char *msg;              /* error message */\n        /* zlib inflate or deflate stream */\n    z_stream strm;          /* stream structure in-place (not a pointer) */\n} gz_state;\ntypedef gz_state FAR *gz_statep;\n\n/* shared functions */\nvoid ZLIB_INTERNAL gz_error OF((gz_statep, int, const char *));\n#if defined UNDER_CE\nchar ZLIB_INTERNAL *gz_strwinerror OF((DWORD error));\n#endif\n\n/* GT_OFF(x), where x is an unsigned value, is true if x > maximum z_off64_t\n   value -- needed when comparing unsigned to z_off64_t, which is signed\n   (possible z_off64_t types off_t, off64_t, and long are all signed) */\n#ifdef INT_MAX\n#  define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > INT_MAX)\n#else\nunsigned ZLIB_INTERNAL gz_intmax OF((void));\n#  define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > gz_intmax())\n#endif\n"
  },
  {
    "path": "Projects/Libraries/CSBase/Source/zlib/gzlib.c",
    "content": "/* gzlib.c -- zlib functions common to reading and writing gzip files\n * Copyright (C) 2004-2017 Mark Adler\n * For conditions of distribution and use, see copyright notice in zlib.h\n */\n\n#include \"gzguts.h\"\n\n#if defined(_WIN32) && !defined(__BORLANDC__) && !defined(__MINGW32__)\n#  define LSEEK _lseeki64\n#else\n#if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0\n#  define LSEEK lseek64\n#else\n#  define LSEEK lseek\n#endif\n#endif\n\n/* Local functions */\nlocal void gz_reset OF((gz_statep));\nlocal gzFile gz_open OF((const void *, int, const char *));\n\n#if defined UNDER_CE\n\n/* Map the Windows error number in ERROR to a locale-dependent error message\n   string and return a pointer to it.  Typically, the values for ERROR come\n   from GetLastError.\n\n   The string pointed to shall not be modified by the application, but may be\n   overwritten by a subsequent call to gz_strwinerror\n\n   The gz_strwinerror function does not change the current setting of\n   GetLastError. */\nchar ZLIB_INTERNAL *gz_strwinerror (error)\n     DWORD error;\n{\n    static char buf[1024];\n\n    wchar_t *msgbuf;\n    DWORD lasterr = GetLastError();\n    DWORD chars = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM\n        | FORMAT_MESSAGE_ALLOCATE_BUFFER,\n        NULL,\n        error,\n        0, /* Default language */\n        (LPVOID)&msgbuf,\n        0,\n        NULL);\n    if (chars != 0) {\n        /* If there is an \\r\\n appended, zap it.  */\n        if (chars >= 2\n            && msgbuf[chars - 2] == '\\r' && msgbuf[chars - 1] == '\\n') {\n            chars -= 2;\n            msgbuf[chars] = 0;\n        }\n\n        if (chars > sizeof (buf) - 1) {\n            chars = sizeof (buf) - 1;\n            msgbuf[chars] = 0;\n        }\n\n        wcstombs(buf, msgbuf, chars + 1);\n        LocalFree(msgbuf);\n    }\n    else {\n        sprintf(buf, \"unknown win32 error (%ld)\", error);\n    }\n\n    SetLastError(lasterr);\n    return buf;\n}\n\n#endif /* UNDER_CE */\n\n/* Reset gzip file state */\nlocal void gz_reset(state)\n    gz_statep state;\n{\n    state->x.have = 0;              /* no output data available */\n    if (state->mode == GZ_READ) {   /* for reading ... */\n        state->eof = 0;             /* not at end of file */\n        state->past = 0;            /* have not read past end yet */\n        state->how = LOOK;          /* look for gzip header */\n    }\n    state->seek = 0;                /* no seek request pending */\n    gz_error(state, Z_OK, NULL);    /* clear error */\n    state->x.pos = 0;               /* no uncompressed data yet */\n    state->strm.avail_in = 0;       /* no input data yet */\n}\n\n/* Open a gzip file either by name or file descriptor. */\nlocal gzFile gz_open(path, fd, mode)\n    const void *path;\n    int fd;\n    const char *mode;\n{\n    gz_statep state;\n    z_size_t len;\n    int oflag;\n#ifdef O_CLOEXEC\n    int cloexec = 0;\n#endif\n#ifdef O_EXCL\n    int exclusive = 0;\n#endif\n\n    /* check input */\n    if (path == NULL)\n        return NULL;\n\n    /* allocate gzFile structure to return */\n    state = (gz_statep)malloc(sizeof(gz_state));\n    if (state == NULL)\n        return NULL;\n    state->size = 0;            /* no buffers allocated yet */\n    state->want = GZBUFSIZE;    /* requested buffer size */\n    state->msg = NULL;          /* no error message yet */\n\n    /* interpret mode */\n    state->mode = GZ_NONE;\n    state->level = Z_DEFAULT_COMPRESSION;\n    state->strategy = Z_DEFAULT_STRATEGY;\n    state->direct = 0;\n    while (*mode) {\n        if (*mode >= '0' && *mode <= '9')\n            state->level = *mode - '0';\n        else\n            switch (*mode) {\n            case 'r':\n                state->mode = GZ_READ;\n                break;\n#ifndef NO_GZCOMPRESS\n            case 'w':\n                state->mode = GZ_WRITE;\n                break;\n            case 'a':\n                state->mode = GZ_APPEND;\n                break;\n#endif\n            case '+':       /* can't read and write at the same time */\n                free(state);\n                return NULL;\n            case 'b':       /* ignore -- will request binary anyway */\n                break;\n#ifdef O_CLOEXEC\n            case 'e':\n                cloexec = 1;\n                break;\n#endif\n#ifdef O_EXCL\n            case 'x':\n                exclusive = 1;\n                break;\n#endif\n            case 'f':\n                state->strategy = Z_FILTERED;\n                break;\n            case 'h':\n                state->strategy = Z_HUFFMAN_ONLY;\n                break;\n            case 'R':\n                state->strategy = Z_RLE;\n                break;\n            case 'F':\n                state->strategy = Z_FIXED;\n                break;\n            case 'T':\n                state->direct = 1;\n                break;\n            default:        /* could consider as an error, but just ignore */\n                ;\n            }\n        mode++;\n    }\n\n    /* must provide an \"r\", \"w\", or \"a\" */\n    if (state->mode == GZ_NONE) {\n        free(state);\n        return NULL;\n    }\n\n    /* can't force transparent read */\n    if (state->mode == GZ_READ) {\n        if (state->direct) {\n            free(state);\n            return NULL;\n        }\n        state->direct = 1;      /* for empty file */\n    }\n\n    /* save the path name for error messages */\n#ifdef WIDECHAR\n    if (fd == -2) {\n        len = wcstombs(NULL, path, 0);\n        if (len == (z_size_t)-1)\n            len = 0;\n    }\n    else\n#endif\n        len = strlen((const char *)path);\n    state->path = (char *)malloc(len + 1);\n    if (state->path == NULL) {\n        free(state);\n        return NULL;\n    }\n#ifdef WIDECHAR\n    if (fd == -2)\n        if (len)\n            wcstombs(state->path, path, len + 1);\n        else\n            *(state->path) = 0;\n    else\n#endif\n#if !defined(NO_snprintf) && !defined(NO_vsnprintf)\n        (void)snprintf(state->path, len + 1, \"%s\", (const char *)path);\n#else\n        strcpy(state->path, path);\n#endif\n\n    /* compute the flags for open() */\n    oflag =\n#ifdef O_LARGEFILE\n        O_LARGEFILE |\n#endif\n#ifdef O_BINARY\n        O_BINARY |\n#endif\n#ifdef O_CLOEXEC\n        (cloexec ? O_CLOEXEC : 0) |\n#endif\n        (state->mode == GZ_READ ?\n         O_RDONLY :\n         (O_WRONLY | O_CREAT |\n#ifdef O_EXCL\n          (exclusive ? O_EXCL : 0) |\n#endif\n          (state->mode == GZ_WRITE ?\n           O_TRUNC :\n           O_APPEND)));\n\n    /* open the file with the appropriate flags (or just use fd) */\n    state->fd = fd > -1 ? fd : (\n#ifdef WIDECHAR\n        fd == -2 ? _wopen(path, oflag, 0666) :\n#endif\n        open((const char *)path, oflag, 0666));\n    if (state->fd == -1) {\n        free(state->path);\n        free(state);\n        return NULL;\n    }\n    if (state->mode == GZ_APPEND) {\n        LSEEK(state->fd, 0, SEEK_END);  /* so gzoffset() is correct */\n        state->mode = GZ_WRITE;         /* simplify later checks */\n    }\n\n    /* save the current position for rewinding (only if reading) */\n    if (state->mode == GZ_READ) {\n        state->start = LSEEK(state->fd, 0, SEEK_CUR);\n        if (state->start == -1) state->start = 0;\n    }\n\n    /* initialize stream */\n    gz_reset(state);\n\n    /* return stream */\n    return (gzFile)state;\n}\n\n/* -- see zlib.h -- */\ngzFile ZEXPORT gzopen(path, mode)\n    const char *path;\n    const char *mode;\n{\n    return gz_open(path, -1, mode);\n}\n\n/* -- see zlib.h -- */\ngzFile ZEXPORT gzopen64(path, mode)\n    const char *path;\n    const char *mode;\n{\n    return gz_open(path, -1, mode);\n}\n\n/* -- see zlib.h -- */\ngzFile ZEXPORT gzdopen(fd, mode)\n    int fd;\n    const char *mode;\n{\n    char *path;         /* identifier for error messages */\n    gzFile gz;\n\n    if (fd == -1 || (path = (char *)malloc(7 + 3 * sizeof(int))) == NULL)\n        return NULL;\n#if !defined(NO_snprintf) && !defined(NO_vsnprintf)\n    (void)snprintf(path, 7 + 3 * sizeof(int), \"<fd:%d>\", fd);\n#else\n    sprintf(path, \"<fd:%d>\", fd);   /* for debugging */\n#endif\n    gz = gz_open(path, fd, mode);\n    free(path);\n    return gz;\n}\n\n/* -- see zlib.h -- */\n#ifdef WIDECHAR\ngzFile ZEXPORT gzopen_w(path, mode)\n    const wchar_t *path;\n    const char *mode;\n{\n    return gz_open(path, -2, mode);\n}\n#endif\n\n/* -- see zlib.h -- */\nint ZEXPORT gzbuffer(file, size)\n    gzFile file;\n    unsigned size;\n{\n    gz_statep state;\n\n    /* get internal structure and check integrity */\n    if (file == NULL)\n        return -1;\n    state = (gz_statep)file;\n    if (state->mode != GZ_READ && state->mode != GZ_WRITE)\n        return -1;\n\n    /* make sure we haven't already allocated memory */\n    if (state->size != 0)\n        return -1;\n\n    /* check and set requested size */\n    if ((size << 1) < size)\n        return -1;              /* need to be able to double it */\n    if (size < 2)\n        size = 2;               /* need two bytes to check magic header */\n    state->want = size;\n    return 0;\n}\n\n/* -- see zlib.h -- */\nint ZEXPORT gzrewind(file)\n    gzFile file;\n{\n    gz_statep state;\n\n    /* get internal structure */\n    if (file == NULL)\n        return -1;\n    state = (gz_statep)file;\n\n    /* check that we're reading and that there's no error */\n    if (state->mode != GZ_READ ||\n            (state->err != Z_OK && state->err != Z_BUF_ERROR))\n        return -1;\n\n    /* back up and start over */\n    if (LSEEK(state->fd, state->start, SEEK_SET) == -1)\n        return -1;\n    gz_reset(state);\n    return 0;\n}\n\n/* -- see zlib.h -- */\nz_off64_t ZEXPORT gzseek64(file, offset, whence)\n    gzFile file;\n    z_off64_t offset;\n    int whence;\n{\n    unsigned n;\n    z_off64_t ret;\n    gz_statep state;\n\n    /* get internal structure and check integrity */\n    if (file == NULL)\n        return -1;\n    state = (gz_statep)file;\n    if (state->mode != GZ_READ && state->mode != GZ_WRITE)\n        return -1;\n\n    /* check that there's no error */\n    if (state->err != Z_OK && state->err != Z_BUF_ERROR)\n        return -1;\n\n    /* can only seek from start or relative to current position */\n    if (whence != SEEK_SET && whence != SEEK_CUR)\n        return -1;\n\n    /* normalize offset to a SEEK_CUR specification */\n    if (whence == SEEK_SET)\n        offset -= state->x.pos;\n    else if (state->seek)\n        offset += state->skip;\n    state->seek = 0;\n\n    /* if within raw area while reading, just go there */\n    if (state->mode == GZ_READ && state->how == COPY &&\n            state->x.pos + offset >= 0) {\n        ret = LSEEK(state->fd, offset - state->x.have, SEEK_CUR);\n        if (ret == -1)\n            return -1;\n        state->x.have = 0;\n        state->eof = 0;\n        state->past = 0;\n        state->seek = 0;\n        gz_error(state, Z_OK, NULL);\n        state->strm.avail_in = 0;\n        state->x.pos += offset;\n        return state->x.pos;\n    }\n\n    /* calculate skip amount, rewinding if needed for back seek when reading */\n    if (offset < 0) {\n        if (state->mode != GZ_READ)         /* writing -- can't go backwards */\n            return -1;\n        offset += state->x.pos;\n        if (offset < 0)                     /* before start of file! */\n            return -1;\n        if (gzrewind(file) == -1)           /* rewind, then skip to offset */\n            return -1;\n    }\n\n    /* if reading, skip what's in output buffer (one less gzgetc() check) */\n    if (state->mode == GZ_READ) {\n        n = GT_OFF(state->x.have) || (z_off64_t)state->x.have > offset ?\n            (unsigned)offset : state->x.have;\n        state->x.have -= n;\n        state->x.next += n;\n        state->x.pos += n;\n        offset -= n;\n    }\n\n    /* request skip (if not zero) */\n    if (offset) {\n        state->seek = 1;\n        state->skip = offset;\n    }\n    return state->x.pos + offset;\n}\n\n/* -- see zlib.h -- */\nz_off_t ZEXPORT gzseek(file, offset, whence)\n    gzFile file;\n    z_off_t offset;\n    int whence;\n{\n    z_off64_t ret;\n\n    ret = gzseek64(file, (z_off64_t)offset, whence);\n    return ret == (z_off_t)ret ? (z_off_t)ret : -1;\n}\n\n/* -- see zlib.h -- */\nz_off64_t ZEXPORT gztell64(file)\n    gzFile file;\n{\n    gz_statep state;\n\n    /* get internal structure and check integrity */\n    if (file == NULL)\n        return -1;\n    state = (gz_statep)file;\n    if (state->mode != GZ_READ && state->mode != GZ_WRITE)\n        return -1;\n\n    /* return position */\n    return state->x.pos + (state->seek ? state->skip : 0);\n}\n\n/* -- see zlib.h -- */\nz_off_t ZEXPORT gztell(file)\n    gzFile file;\n{\n    z_off64_t ret;\n\n    ret = gztell64(file);\n    return ret == (z_off_t)ret ? (z_off_t)ret : -1;\n}\n\n/* -- see zlib.h -- */\nz_off64_t ZEXPORT gzoffset64(file)\n    gzFile file;\n{\n    z_off64_t offset;\n    gz_statep state;\n\n    /* get internal structure and check integrity */\n    if (file == NULL)\n        return -1;\n    state = (gz_statep)file;\n    if (state->mode != GZ_READ && state->mode != GZ_WRITE)\n        return -1;\n\n    /* compute and return effective offset in file */\n    offset = LSEEK(state->fd, 0, SEEK_CUR);\n    if (offset == -1)\n        return -1;\n    if (state->mode == GZ_READ)             /* reading */\n        offset -= state->strm.avail_in;     /* don't count buffered input */\n    return offset;\n}\n\n/* -- see zlib.h -- */\nz_off_t ZEXPORT gzoffset(file)\n    gzFile file;\n{\n    z_off64_t ret;\n\n    ret = gzoffset64(file);\n    return ret == (z_off_t)ret ? (z_off_t)ret : -1;\n}\n\n/* -- see zlib.h -- */\nint ZEXPORT gzeof(file)\n    gzFile file;\n{\n    gz_statep state;\n\n    /* get internal structure and check integrity */\n    if (file == NULL)\n        return 0;\n    state = (gz_statep)file;\n    if (state->mode != GZ_READ && state->mode != GZ_WRITE)\n        return 0;\n\n    /* return end-of-file state */\n    return state->mode == GZ_READ ? state->past : 0;\n}\n\n/* -- see zlib.h -- */\nconst char * ZEXPORT gzerror(file, errnum)\n    gzFile file;\n    int *errnum;\n{\n    gz_statep state;\n\n    /* get internal structure and check integrity */\n    if (file == NULL)\n        return NULL;\n    state = (gz_statep)file;\n    if (state->mode != GZ_READ && state->mode != GZ_WRITE)\n        return NULL;\n\n    /* return error information */\n    if (errnum != NULL)\n        *errnum = state->err;\n    return state->err == Z_MEM_ERROR ? \"out of memory\" :\n                                       (state->msg == NULL ? \"\" : state->msg);\n}\n\n/* -- see zlib.h -- */\nvoid ZEXPORT gzclearerr(file)\n    gzFile file;\n{\n    gz_statep state;\n\n    /* get internal structure and check integrity */\n    if (file == NULL)\n        return;\n    state = (gz_statep)file;\n    if (state->mode != GZ_READ && state->mode != GZ_WRITE)\n        return;\n\n    /* clear error and end-of-file */\n    if (state->mode == GZ_READ) {\n        state->eof = 0;\n        state->past = 0;\n    }\n    gz_error(state, Z_OK, NULL);\n}\n\n/* Create an error message in allocated memory and set state->err and\n   state->msg accordingly.  Free any previous error message already there.  Do\n   not try to free or allocate space if the error is Z_MEM_ERROR (out of\n   memory).  Simply save the error message as a static string.  If there is an\n   allocation failure constructing the error message, then convert the error to\n   out of memory. */\nvoid ZLIB_INTERNAL gz_error(state, err, msg)\n    gz_statep state;\n    int err;\n    const char *msg;\n{\n    /* free previously allocated message and clear */\n    if (state->msg != NULL) {\n        if (state->err != Z_MEM_ERROR)\n            free(state->msg);\n        state->msg = NULL;\n    }\n\n    /* if fatal, set state->x.have to 0 so that the gzgetc() macro fails */\n    if (err != Z_OK && err != Z_BUF_ERROR)\n        state->x.have = 0;\n\n    /* set error code, and if no message, then done */\n    state->err = err;\n    if (msg == NULL)\n        return;\n\n    /* for an out of memory error, return literal string when requested */\n    if (err == Z_MEM_ERROR)\n        return;\n\n    /* construct error message with path */\n    if ((state->msg = (char *)malloc(strlen(state->path) + strlen(msg) + 3)) ==\n            NULL) {\n        state->err = Z_MEM_ERROR;\n        return;\n    }\n#if !defined(NO_snprintf) && !defined(NO_vsnprintf)\n    (void)snprintf(state->msg, strlen(state->path) + strlen(msg) + 3,\n                   \"%s%s%s\", state->path, \": \", msg);\n#else\n    strcpy(state->msg, state->path);\n    strcat(state->msg, \": \");\n    strcat(state->msg, msg);\n#endif\n}\n\n#ifndef INT_MAX\n/* portably return maximum value for an int (when limits.h presumed not\n   available) -- we need to do this to cover cases where 2's complement not\n   used, since C standard permits 1's complement and sign-bit representations,\n   otherwise we could just use ((unsigned)-1) >> 1 */\nunsigned ZLIB_INTERNAL gz_intmax()\n{\n    unsigned p, q;\n\n    p = 1;\n    do {\n        q = p;\n        p <<= 1;\n        p++;\n    } while (p > q);\n    return q >> 1;\n}\n#endif\n"
  },
  {
    "path": "Projects/Libraries/CSBase/Source/zlib/gzread.c",
    "content": "/* gzread.c -- zlib functions for reading gzip files\n * Copyright (C) 2004, 2005, 2010, 2011, 2012, 2013, 2016 Mark Adler\n * For conditions of distribution and use, see copyright notice in zlib.h\n */\n\n#include \"gzguts.h\"\n\n/* Local functions */\nlocal int gz_load OF((gz_statep, unsigned char *, unsigned, unsigned *));\nlocal int gz_avail OF((gz_statep));\nlocal int gz_look OF((gz_statep));\nlocal int gz_decomp OF((gz_statep));\nlocal int gz_fetch OF((gz_statep));\nlocal int gz_skip OF((gz_statep, z_off64_t));\nlocal z_size_t gz_read OF((gz_statep, voidp, z_size_t));\n\n/* Use read() to load a buffer -- return -1 on error, otherwise 0.  Read from\n   state->fd, and update state->eof, state->err, and state->msg as appropriate.\n   This function needs to loop on read(), since read() is not guaranteed to\n   read the number of bytes requested, depending on the type of descriptor. */\nlocal int gz_load(state, buf, len, have)\n    gz_statep state;\n    unsigned char *buf;\n    unsigned len;\n    unsigned *have;\n{\n    int ret;\n    unsigned get, max = ((unsigned)-1 >> 2) + 1;\n\n    *have = 0;\n    do {\n        get = len - *have;\n        if (get > max)\n            get = max;\n        ret = read(state->fd, buf + *have, get);\n        if (ret <= 0)\n            break;\n        *have += (unsigned)ret;\n    } while (*have < len);\n    if (ret < 0) {\n        gz_error(state, Z_ERRNO, zstrerror());\n        return -1;\n    }\n    if (ret == 0)\n        state->eof = 1;\n    return 0;\n}\n\n/* Load up input buffer and set eof flag if last data loaded -- return -1 on\n   error, 0 otherwise.  Note that the eof flag is set when the end of the input\n   file is reached, even though there may be unused data in the buffer.  Once\n   that data has been used, no more attempts will be made to read the file.\n   If strm->avail_in != 0, then the current data is moved to the beginning of\n   the input buffer, and then the remainder of the buffer is loaded with the\n   available data from the input file. */\nlocal int gz_avail(state)\n    gz_statep state;\n{\n    unsigned got;\n    z_streamp strm = &(state->strm);\n\n    if (state->err != Z_OK && state->err != Z_BUF_ERROR)\n        return -1;\n    if (state->eof == 0) {\n        if (strm->avail_in) {       /* copy what's there to the start */\n            unsigned char *p = state->in;\n            unsigned const char *q = strm->next_in;\n            unsigned n = strm->avail_in;\n            do {\n                *p++ = *q++;\n            } while (--n);\n        }\n        if (gz_load(state, state->in + strm->avail_in,\n                    state->size - strm->avail_in, &got) == -1)\n            return -1;\n        strm->avail_in += got;\n        strm->next_in = state->in;\n    }\n    return 0;\n}\n\n/* Look for gzip header, set up for inflate or copy.  state->x.have must be 0.\n   If this is the first time in, allocate required memory.  state->how will be\n   left unchanged if there is no more input data available, will be set to COPY\n   if there is no gzip header and direct copying will be performed, or it will\n   be set to GZIP for decompression.  If direct copying, then leftover input\n   data from the input buffer will be copied to the output buffer.  In that\n   case, all further file reads will be directly to either the output buffer or\n   a user buffer.  If decompressing, the inflate state will be initialized.\n   gz_look() will return 0 on success or -1 on failure. */\nlocal int gz_look(state)\n    gz_statep state;\n{\n    z_streamp strm = &(state->strm);\n\n    /* allocate read buffers and inflate memory */\n    if (state->size == 0) {\n        /* allocate buffers */\n        state->in = (unsigned char *)malloc(state->want);\n        state->out = (unsigned char *)malloc(state->want << 1);\n        if (state->in == NULL || state->out == NULL) {\n            free(state->out);\n            free(state->in);\n            gz_error(state, Z_MEM_ERROR, \"out of memory\");\n            return -1;\n        }\n        state->size = state->want;\n\n        /* allocate inflate memory */\n        state->strm.zalloc = Z_NULL;\n        state->strm.zfree = Z_NULL;\n        state->strm.opaque = Z_NULL;\n        state->strm.avail_in = 0;\n        state->strm.next_in = Z_NULL;\n        if (inflateInit2(&(state->strm), 15 + 16) != Z_OK) {    /* gunzip */\n            free(state->out);\n            free(state->in);\n            state->size = 0;\n            gz_error(state, Z_MEM_ERROR, \"out of memory\");\n            return -1;\n        }\n    }\n\n    /* get at least the magic bytes in the input buffer */\n    if (strm->avail_in < 2) {\n        if (gz_avail(state) == -1)\n            return -1;\n        if (strm->avail_in == 0)\n            return 0;\n    }\n\n    /* look for gzip magic bytes -- if there, do gzip decoding (note: there is\n       a logical dilemma here when considering the case of a partially written\n       gzip file, to wit, if a single 31 byte is written, then we cannot tell\n       whether this is a single-byte file, or just a partially written gzip\n       file -- for here we assume that if a gzip file is being written, then\n       the header will be written in a single operation, so that reading a\n       single byte is sufficient indication that it is not a gzip file) */\n    if (strm->avail_in > 1 &&\n            strm->next_in[0] == 31 && strm->next_in[1] == 139) {\n        inflateReset(strm);\n        state->how = GZIP;\n        state->direct = 0;\n        return 0;\n    }\n\n    /* no gzip header -- if we were decoding gzip before, then this is trailing\n       garbage.  Ignore the trailing garbage and finish. */\n    if (state->direct == 0) {\n        strm->avail_in = 0;\n        state->eof = 1;\n        state->x.have = 0;\n        return 0;\n    }\n\n    /* doing raw i/o, copy any leftover input to output -- this assumes that\n       the output buffer is larger than the input buffer, which also assures\n       space for gzungetc() */\n    state->x.next = state->out;\n    if (strm->avail_in) {\n        memcpy(state->x.next, strm->next_in, strm->avail_in);\n        state->x.have = strm->avail_in;\n        strm->avail_in = 0;\n    }\n    state->how = COPY;\n    state->direct = 1;\n    return 0;\n}\n\n/* Decompress from input to the provided next_out and avail_out in the state.\n   On return, state->x.have and state->x.next point to the just decompressed\n   data.  If the gzip stream completes, state->how is reset to LOOK to look for\n   the next gzip stream or raw data, once state->x.have is depleted.  Returns 0\n   on success, -1 on failure. */\nlocal int gz_decomp(state)\n    gz_statep state;\n{\n    int ret = Z_OK;\n    unsigned had;\n    z_streamp strm = &(state->strm);\n\n    /* fill output buffer up to end of deflate stream */\n    had = strm->avail_out;\n    do {\n        /* get more input for inflate() */\n        if (strm->avail_in == 0 && gz_avail(state) == -1)\n            return -1;\n        if (strm->avail_in == 0) {\n            gz_error(state, Z_BUF_ERROR, \"unexpected end of file\");\n            break;\n        }\n\n        /* decompress and handle errors */\n        ret = inflate(strm, Z_NO_FLUSH);\n        if (ret == Z_STREAM_ERROR || ret == Z_NEED_DICT) {\n            gz_error(state, Z_STREAM_ERROR,\n                     \"internal error: inflate stream corrupt\");\n            return -1;\n        }\n        if (ret == Z_MEM_ERROR) {\n            gz_error(state, Z_MEM_ERROR, \"out of memory\");\n            return -1;\n        }\n        if (ret == Z_DATA_ERROR) {              /* deflate stream invalid */\n            gz_error(state, Z_DATA_ERROR,\n                     strm->msg == NULL ? \"compressed data error\" : strm->msg);\n            return -1;\n        }\n    } while (strm->avail_out && ret != Z_STREAM_END);\n\n    /* update available output */\n    state->x.have = had - strm->avail_out;\n    state->x.next = strm->next_out - state->x.have;\n\n    /* if the gzip stream completed successfully, look for another */\n    if (ret == Z_STREAM_END)\n        state->how = LOOK;\n\n    /* good decompression */\n    return 0;\n}\n\n/* Fetch data and put it in the output buffer.  Assumes state->x.have is 0.\n   Data is either copied from the input file or decompressed from the input\n   file depending on state->how.  If state->how is LOOK, then a gzip header is\n   looked for to determine whether to copy or decompress.  Returns -1 on error,\n   otherwise 0.  gz_fetch() will leave state->how as COPY or GZIP unless the\n   end of the input file has been reached and all data has been processed.  */\nlocal int gz_fetch(state)\n    gz_statep state;\n{\n    z_streamp strm = &(state->strm);\n\n    do {\n        switch(state->how) {\n        case LOOK:      /* -> LOOK, COPY (only if never GZIP), or GZIP */\n            if (gz_look(state) == -1)\n                return -1;\n            if (state->how == LOOK)\n                return 0;\n            break;\n        case COPY:      /* -> COPY */\n            if (gz_load(state, state->out, state->size << 1, &(state->x.have))\n                    == -1)\n                return -1;\n            state->x.next = state->out;\n            return 0;\n        case GZIP:      /* -> GZIP or LOOK (if end of gzip stream) */\n            strm->avail_out = state->size << 1;\n            strm->next_out = state->out;\n            if (gz_decomp(state) == -1)\n                return -1;\n        }\n    } while (state->x.have == 0 && (!state->eof || strm->avail_in));\n    return 0;\n}\n\n/* Skip len uncompressed bytes of output.  Return -1 on error, 0 on success. */\nlocal int gz_skip(state, len)\n    gz_statep state;\n    z_off64_t len;\n{\n    unsigned n;\n\n    /* skip over len bytes or reach end-of-file, whichever comes first */\n    while (len)\n        /* skip over whatever is in output buffer */\n        if (state->x.have) {\n            n = GT_OFF(state->x.have) || (z_off64_t)state->x.have > len ?\n                (unsigned)len : state->x.have;\n            state->x.have -= n;\n            state->x.next += n;\n            state->x.pos += n;\n            len -= n;\n        }\n\n        /* output buffer empty -- return if we're at the end of the input */\n        else if (state->eof && state->strm.avail_in == 0)\n            break;\n\n        /* need more data to skip -- load up output buffer */\n        else {\n            /* get more output, looking for header if required */\n            if (gz_fetch(state) == -1)\n                return -1;\n        }\n    return 0;\n}\n\n/* Read len bytes into buf from file, or less than len up to the end of the\n   input.  Return the number of bytes read.  If zero is returned, either the\n   end of file was reached, or there was an error.  state->err must be\n   consulted in that case to determine which. */\nlocal z_size_t gz_read(state, buf, len)\n    gz_statep state;\n    voidp buf;\n    z_size_t len;\n{\n    z_size_t got;\n    unsigned n;\n\n    /* if len is zero, avoid unnecessary operations */\n    if (len == 0)\n        return 0;\n\n    /* process a skip request */\n    if (state->seek) {\n        state->seek = 0;\n        if (gz_skip(state, state->skip) == -1)\n            return 0;\n    }\n\n    /* get len bytes to buf, or less than len if at the end */\n    got = 0;\n    do {\n        /* set n to the maximum amount of len that fits in an unsigned int */\n        n = -1;\n        if (n > len)\n            n = len;\n\n        /* first just try copying data from the output buffer */\n        if (state->x.have) {\n            if (state->x.have < n)\n                n = state->x.have;\n            memcpy(buf, state->x.next, n);\n            state->x.next += n;\n            state->x.have -= n;\n        }\n\n        /* output buffer empty -- return if we're at the end of the input */\n        else if (state->eof && state->strm.avail_in == 0) {\n            state->past = 1;        /* tried to read past end */\n            break;\n        }\n\n        /* need output data -- for small len or new stream load up our output\n           buffer */\n        else if (state->how == LOOK || n < (state->size << 1)) {\n            /* get more output, looking for header if required */\n            if (gz_fetch(state) == -1)\n                return 0;\n            continue;       /* no progress yet -- go back to copy above */\n            /* the copy above assures that we will leave with space in the\n               output buffer, allowing at least one gzungetc() to succeed */\n        }\n\n        /* large len -- read directly into user buffer */\n        else if (state->how == COPY) {      /* read directly */\n            if (gz_load(state, (unsigned char *)buf, n, &n) == -1)\n                return 0;\n        }\n\n        /* large len -- decompress directly into user buffer */\n        else {  /* state->how == GZIP */\n            state->strm.avail_out = n;\n            state->strm.next_out = (unsigned char *)buf;\n            if (gz_decomp(state) == -1)\n                return 0;\n            n = state->x.have;\n            state->x.have = 0;\n        }\n\n        /* update progress */\n        len -= n;\n        buf = (char *)buf + n;\n        got += n;\n        state->x.pos += n;\n    } while (len);\n\n    /* return number of bytes read into user buffer */\n    return got;\n}\n\n/* -- see zlib.h -- */\nint ZEXPORT gzread(file, buf, len)\n    gzFile file;\n    voidp buf;\n    unsigned len;\n{\n    gz_statep state;\n\n    /* get internal structure */\n    if (file == NULL)\n        return -1;\n    state = (gz_statep)file;\n\n    /* check that we're reading and that there's no (serious) error */\n    if (state->mode != GZ_READ ||\n            (state->err != Z_OK && state->err != Z_BUF_ERROR))\n        return -1;\n\n    /* since an int is returned, make sure len fits in one, otherwise return\n       with an error (this avoids a flaw in the interface) */\n    if ((int)len < 0) {\n        gz_error(state, Z_STREAM_ERROR, \"request does not fit in an int\");\n        return -1;\n    }\n\n    /* read len or fewer bytes to buf */\n    len = gz_read(state, buf, len);\n\n    /* check for an error */\n    if (len == 0 && state->err != Z_OK && state->err != Z_BUF_ERROR)\n        return -1;\n\n    /* return the number of bytes read (this is assured to fit in an int) */\n    return (int)len;\n}\n\n/* -- see zlib.h -- */\nz_size_t ZEXPORT gzfread(buf, size, nitems, file)\n    voidp buf;\n    z_size_t size;\n    z_size_t nitems;\n    gzFile file;\n{\n    z_size_t len;\n    gz_statep state;\n\n    /* get internal structure */\n    if (file == NULL)\n        return 0;\n    state = (gz_statep)file;\n\n    /* check that we're reading and that there's no (serious) error */\n    if (state->mode != GZ_READ ||\n            (state->err != Z_OK && state->err != Z_BUF_ERROR))\n        return 0;\n\n    /* compute bytes to read -- error on overflow */\n    len = nitems * size;\n    if (size && len / size != nitems) {\n        gz_error(state, Z_STREAM_ERROR, \"request does not fit in a size_t\");\n        return 0;\n    }\n\n    /* read len or fewer bytes to buf, return the number of full items read */\n    return len ? gz_read(state, buf, len) / size : 0;\n}\n\n/* -- see zlib.h -- */\n#ifdef Z_PREFIX_SET\n#  undef z_gzgetc\n#else\n#  undef gzgetc\n#endif\nint ZEXPORT gzgetc(file)\n    gzFile file;\n{\n    int ret;\n    unsigned char buf[1];\n    gz_statep state;\n\n    /* get internal structure */\n    if (file == NULL)\n        return -1;\n    state = (gz_statep)file;\n\n    /* check that we're reading and that there's no (serious) error */\n    if (state->mode != GZ_READ ||\n        (state->err != Z_OK && state->err != Z_BUF_ERROR))\n        return -1;\n\n    /* try output buffer (no need to check for skip request) */\n    if (state->x.have) {\n        state->x.have--;\n        state->x.pos++;\n        return *(state->x.next)++;\n    }\n\n    /* nothing there -- try gz_read() */\n    ret = gz_read(state, buf, 1);\n    return ret < 1 ? -1 : buf[0];\n}\n\nint ZEXPORT gzgetc_(file)\ngzFile file;\n{\n    return gzgetc(file);\n}\n\n/* -- see zlib.h -- */\nint ZEXPORT gzungetc(c, file)\n    int c;\n    gzFile file;\n{\n    gz_statep state;\n\n    /* get internal structure */\n    if (file == NULL)\n        return -1;\n    state = (gz_statep)file;\n\n    /* check that we're reading and that there's no (serious) error */\n    if (state->mode != GZ_READ ||\n        (state->err != Z_OK && state->err != Z_BUF_ERROR))\n        return -1;\n\n    /* process a skip request */\n    if (state->seek) {\n        state->seek = 0;\n        if (gz_skip(state, state->skip) == -1)\n            return -1;\n    }\n\n    /* can't push EOF */\n    if (c < 0)\n        return -1;\n\n    /* if output buffer empty, put byte at end (allows more pushing) */\n    if (state->x.have == 0) {\n        state->x.have = 1;\n        state->x.next = state->out + (state->size << 1) - 1;\n        state->x.next[0] = (unsigned char)c;\n        state->x.pos--;\n        state->past = 0;\n        return c;\n    }\n\n    /* if no room, give up (must have already done a gzungetc()) */\n    if (state->x.have == (state->size << 1)) {\n        gz_error(state, Z_DATA_ERROR, \"out of room to push characters\");\n        return -1;\n    }\n\n    /* slide output data if needed and insert byte before existing data */\n    if (state->x.next == state->out) {\n        unsigned char *src = state->out + state->x.have;\n        unsigned char *dest = state->out + (state->size << 1);\n        while (src > state->out)\n            *--dest = *--src;\n        state->x.next = dest;\n    }\n    state->x.have++;\n    state->x.next--;\n    state->x.next[0] = (unsigned char)c;\n    state->x.pos--;\n    state->past = 0;\n    return c;\n}\n\n/* -- see zlib.h -- */\nchar * ZEXPORT gzgets(file, buf, len)\n    gzFile file;\n    char *buf;\n    int len;\n{\n    unsigned left, n;\n    char *str;\n    unsigned char *eol;\n    gz_statep state;\n\n    /* check parameters and get internal structure */\n    if (file == NULL || buf == NULL || len < 1)\n        return NULL;\n    state = (gz_statep)file;\n\n    /* check that we're reading and that there's no (serious) error */\n    if (state->mode != GZ_READ ||\n        (state->err != Z_OK && state->err != Z_BUF_ERROR))\n        return NULL;\n\n    /* process a skip request */\n    if (state->seek) {\n        state->seek = 0;\n        if (gz_skip(state, state->skip) == -1)\n            return NULL;\n    }\n\n    /* copy output bytes up to new line or len - 1, whichever comes first --\n       append a terminating zero to the string (we don't check for a zero in\n       the contents, let the user worry about that) */\n    str = buf;\n    left = (unsigned)len - 1;\n    if (left) do {\n        /* assure that something is in the output buffer */\n        if (state->x.have == 0 && gz_fetch(state) == -1)\n            return NULL;                /* error */\n        if (state->x.have == 0) {       /* end of file */\n            state->past = 1;            /* read past end */\n            break;                      /* return what we have */\n        }\n\n        /* look for end-of-line in current output buffer */\n        n = state->x.have > left ? left : state->x.have;\n        eol = (unsigned char *)memchr(state->x.next, '\\n', n);\n        if (eol != NULL)\n            n = (unsigned)(eol - state->x.next) + 1;\n\n        /* copy through end-of-line, or remainder if not found */\n        memcpy(buf, state->x.next, n);\n        state->x.have -= n;\n        state->x.next += n;\n        state->x.pos += n;\n        left -= n;\n        buf += n;\n    } while (left && eol == NULL);\n\n    /* return terminated string, or if nothing, end of file */\n    if (buf == str)\n        return NULL;\n    buf[0] = 0;\n    return str;\n}\n\n/* -- see zlib.h -- */\nint ZEXPORT gzdirect(file)\n    gzFile file;\n{\n    gz_statep state;\n\n    /* get internal structure */\n    if (file == NULL)\n        return 0;\n    state = (gz_statep)file;\n\n    /* if the state is not known, but we can find out, then do so (this is\n       mainly for right after a gzopen() or gzdopen()) */\n    if (state->mode == GZ_READ && state->how == LOOK && state->x.have == 0)\n        (void)gz_look(state);\n\n    /* return 1 if transparent, 0 if processing a gzip stream */\n    return state->direct;\n}\n\n/* -- see zlib.h -- */\nint ZEXPORT gzclose_r(file)\n    gzFile file;\n{\n    int ret, err;\n    gz_statep state;\n\n    /* get internal structure */\n    if (file == NULL)\n        return Z_STREAM_ERROR;\n    state = (gz_statep)file;\n\n    /* check that we're reading */\n    if (state->mode != GZ_READ)\n        return Z_STREAM_ERROR;\n\n    /* free memory and close file */\n    if (state->size) {\n        inflateEnd(&(state->strm));\n        free(state->out);\n        free(state->in);\n    }\n    err = state->err == Z_BUF_ERROR ? Z_BUF_ERROR : Z_OK;\n    gz_error(state, Z_OK, NULL);\n    free(state->path);\n    ret = close(state->fd);\n    free(state);\n    return ret ? Z_ERRNO : err;\n}\n"
  },
  {
    "path": "Projects/Libraries/CSBase/Source/zlib/gzwrite.c",
    "content": "/* gzwrite.c -- zlib functions for writing gzip files\n * Copyright (C) 2004-2017 Mark Adler\n * For conditions of distribution and use, see copyright notice in zlib.h\n */\n\n#include \"gzguts.h\"\n\n/* Local functions */\nlocal int gz_init OF((gz_statep));\nlocal int gz_comp OF((gz_statep, int));\nlocal int gz_zero OF((gz_statep, z_off64_t));\nlocal z_size_t gz_write OF((gz_statep, voidpc, z_size_t));\n\n/* Initialize state for writing a gzip file.  Mark initialization by setting\n   state->size to non-zero.  Return -1 on a memory allocation failure, or 0 on\n   success. */\nlocal int gz_init(state)\n    gz_statep state;\n{\n    int ret;\n    z_streamp strm = &(state->strm);\n\n    /* allocate input buffer (double size for gzprintf) */\n    state->in = (unsigned char *)malloc(state->want << 1);\n    if (state->in == NULL) {\n        gz_error(state, Z_MEM_ERROR, \"out of memory\");\n        return -1;\n    }\n\n    /* only need output buffer and deflate state if compressing */\n    if (!state->direct) {\n        /* allocate output buffer */\n        state->out = (unsigned char *)malloc(state->want);\n        if (state->out == NULL) {\n            free(state->in);\n            gz_error(state, Z_MEM_ERROR, \"out of memory\");\n            return -1;\n        }\n\n        /* allocate deflate memory, set up for gzip compression */\n        strm->zalloc = Z_NULL;\n        strm->zfree = Z_NULL;\n        strm->opaque = Z_NULL;\n        ret = deflateInit2(strm, state->level, Z_DEFLATED,\n                           MAX_WBITS + 16, DEF_MEM_LEVEL, state->strategy);\n        if (ret != Z_OK) {\n            free(state->out);\n            free(state->in);\n            gz_error(state, Z_MEM_ERROR, \"out of memory\");\n            return -1;\n        }\n        strm->next_in = NULL;\n    }\n\n    /* mark state as initialized */\n    state->size = state->want;\n\n    /* initialize write buffer if compressing */\n    if (!state->direct) {\n        strm->avail_out = state->size;\n        strm->next_out = state->out;\n        state->x.next = strm->next_out;\n    }\n    return 0;\n}\n\n/* Compress whatever is at avail_in and next_in and write to the output file.\n   Return -1 if there is an error writing to the output file or if gz_init()\n   fails to allocate memory, otherwise 0.  flush is assumed to be a valid\n   deflate() flush value.  If flush is Z_FINISH, then the deflate() state is\n   reset to start a new gzip stream.  If gz->direct is true, then simply write\n   to the output file without compressing, and ignore flush. */\nlocal int gz_comp(state, flush)\n    gz_statep state;\n    int flush;\n{\n    int ret, writ;\n    unsigned have, put, max = ((unsigned)-1 >> 2) + 1;\n    z_streamp strm = &(state->strm);\n\n    /* allocate memory if this is the first time through */\n    if (state->size == 0 && gz_init(state) == -1)\n        return -1;\n\n    /* write directly if requested */\n    if (state->direct) {\n        while (strm->avail_in) {\n            put = strm->avail_in > max ? max : strm->avail_in;\n            writ = write(state->fd, strm->next_in, put);\n            if (writ < 0) {\n                gz_error(state, Z_ERRNO, zstrerror());\n                return -1;\n            }\n            strm->avail_in -= (unsigned)writ;\n            strm->next_in += writ;\n        }\n        return 0;\n    }\n\n    /* run deflate() on provided input until it produces no more output */\n    ret = Z_OK;\n    do {\n        /* write out current buffer contents if full, or if flushing, but if\n           doing Z_FINISH then don't write until we get to Z_STREAM_END */\n        if (strm->avail_out == 0 || (flush != Z_NO_FLUSH &&\n            (flush != Z_FINISH || ret == Z_STREAM_END))) {\n            while (strm->next_out > state->x.next) {\n                put = strm->next_out - state->x.next > (int)max ? max :\n                      (unsigned)(strm->next_out - state->x.next);\n                writ = write(state->fd, state->x.next, put);\n                if (writ < 0) {\n                    gz_error(state, Z_ERRNO, zstrerror());\n                    return -1;\n                }\n                state->x.next += writ;\n            }\n            if (strm->avail_out == 0) {\n                strm->avail_out = state->size;\n                strm->next_out = state->out;\n                state->x.next = state->out;\n            }\n        }\n\n        /* compress */\n        have = strm->avail_out;\n        ret = deflate(strm, flush);\n        if (ret == Z_STREAM_ERROR) {\n            gz_error(state, Z_STREAM_ERROR,\n                      \"internal error: deflate stream corrupt\");\n            return -1;\n        }\n        have -= strm->avail_out;\n    } while (have);\n\n    /* if that completed a deflate stream, allow another to start */\n    if (flush == Z_FINISH)\n        deflateReset(strm);\n\n    /* all done, no errors */\n    return 0;\n}\n\n/* Compress len zeros to output.  Return -1 on a write error or memory\n   allocation failure by gz_comp(), or 0 on success. */\nlocal int gz_zero(state, len)\n    gz_statep state;\n    z_off64_t len;\n{\n    int first;\n    unsigned n;\n    z_streamp strm = &(state->strm);\n\n    /* consume whatever's left in the input buffer */\n    if (strm->avail_in && gz_comp(state, Z_NO_FLUSH) == -1)\n        return -1;\n\n    /* compress len zeros (len guaranteed > 0) */\n    first = 1;\n    while (len) {\n        n = GT_OFF(state->size) || (z_off64_t)state->size > len ?\n            (unsigned)len : state->size;\n        if (first) {\n            memset(state->in, 0, n);\n            first = 0;\n        }\n        strm->avail_in = n;\n        strm->next_in = state->in;\n        state->x.pos += n;\n        if (gz_comp(state, Z_NO_FLUSH) == -1)\n            return -1;\n        len -= n;\n    }\n    return 0;\n}\n\n/* Write len bytes from buf to file.  Return the number of bytes written.  If\n   the returned value is less than len, then there was an error. */\nlocal z_size_t gz_write(state, buf, len)\n    gz_statep state;\n    voidpc buf;\n    z_size_t len;\n{\n    z_size_t put = len;\n\n    /* if len is zero, avoid unnecessary operations */\n    if (len == 0)\n        return 0;\n\n    /* allocate memory if this is the first time through */\n    if (state->size == 0 && gz_init(state) == -1)\n        return 0;\n\n    /* check for seek request */\n    if (state->seek) {\n        state->seek = 0;\n        if (gz_zero(state, state->skip) == -1)\n            return 0;\n    }\n\n    /* for small len, copy to input buffer, otherwise compress directly */\n    if (len < state->size) {\n        /* copy to input buffer, compress when full */\n        do {\n            unsigned have, copy;\n\n            if (state->strm.avail_in == 0)\n                state->strm.next_in = state->in;\n            have = (unsigned)((state->strm.next_in + state->strm.avail_in) -\n                              state->in);\n            copy = state->size - have;\n            if (copy > len)\n                copy = len;\n            memcpy(state->in + have, buf, copy);\n            state->strm.avail_in += copy;\n            state->x.pos += copy;\n            buf = (const char *)buf + copy;\n            len -= copy;\n            if (len && gz_comp(state, Z_NO_FLUSH) == -1)\n                return 0;\n        } while (len);\n    }\n    else {\n        /* consume whatever's left in the input buffer */\n        if (state->strm.avail_in && gz_comp(state, Z_NO_FLUSH) == -1)\n            return 0;\n\n        /* directly compress user buffer to file */\n        state->strm.next_in = (z_const Bytef *)buf;\n        do {\n            unsigned n = (unsigned)-1;\n            if (n > len)\n                n = len;\n            state->strm.avail_in = n;\n            state->x.pos += n;\n            if (gz_comp(state, Z_NO_FLUSH) == -1)\n                return 0;\n            len -= n;\n        } while (len);\n    }\n\n    /* input was all buffered or compressed */\n    return put;\n}\n\n/* -- see zlib.h -- */\nint ZEXPORT gzwrite(file, buf, len)\n    gzFile file;\n    voidpc buf;\n    unsigned len;\n{\n    gz_statep state;\n\n    /* get internal structure */\n    if (file == NULL)\n        return 0;\n    state = (gz_statep)file;\n\n    /* check that we're writing and that there's no error */\n    if (state->mode != GZ_WRITE || state->err != Z_OK)\n        return 0;\n\n    /* since an int is returned, make sure len fits in one, otherwise return\n       with an error (this avoids a flaw in the interface) */\n    if ((int)len < 0) {\n        gz_error(state, Z_DATA_ERROR, \"requested length does not fit in int\");\n        return 0;\n    }\n\n    /* write len bytes from buf (the return value will fit in an int) */\n    return (int)gz_write(state, buf, len);\n}\n\n/* -- see zlib.h -- */\nz_size_t ZEXPORT gzfwrite(buf, size, nitems, file)\n    voidpc buf;\n    z_size_t size;\n    z_size_t nitems;\n    gzFile file;\n{\n    z_size_t len;\n    gz_statep state;\n\n    /* get internal structure */\n    if (file == NULL)\n        return 0;\n    state = (gz_statep)file;\n\n    /* check that we're writing and that there's no error */\n    if (state->mode != GZ_WRITE || state->err != Z_OK)\n        return 0;\n\n    /* compute bytes to read -- error on overflow */\n    len = nitems * size;\n    if (size && len / size != nitems) {\n        gz_error(state, Z_STREAM_ERROR, \"request does not fit in a size_t\");\n        return 0;\n    }\n\n    /* write len bytes to buf, return the number of full items written */\n    return len ? gz_write(state, buf, len) / size : 0;\n}\n\n/* -- see zlib.h -- */\nint ZEXPORT gzputc(file, c)\n    gzFile file;\n    int c;\n{\n    unsigned have;\n    unsigned char buf[1];\n    gz_statep state;\n    z_streamp strm;\n\n    /* get internal structure */\n    if (file == NULL)\n        return -1;\n    state = (gz_statep)file;\n    strm = &(state->strm);\n\n    /* check that we're writing and that there's no error */\n    if (state->mode != GZ_WRITE || state->err != Z_OK)\n        return -1;\n\n    /* check for seek request */\n    if (state->seek) {\n        state->seek = 0;\n        if (gz_zero(state, state->skip) == -1)\n            return -1;\n    }\n\n    /* try writing to input buffer for speed (state->size == 0 if buffer not\n       initialized) */\n    if (state->size) {\n        if (strm->avail_in == 0)\n            strm->next_in = state->in;\n        have = (unsigned)((strm->next_in + strm->avail_in) - state->in);\n        if (have < state->size) {\n            state->in[have] = (unsigned char)c;\n            strm->avail_in++;\n            state->x.pos++;\n            return c & 0xff;\n        }\n    }\n\n    /* no room in buffer or not initialized, use gz_write() */\n    buf[0] = (unsigned char)c;\n    if (gz_write(state, buf, 1) != 1)\n        return -1;\n    return c & 0xff;\n}\n\n/* -- see zlib.h -- */\nint ZEXPORT gzputs(file, str)\n    gzFile file;\n    const char *str;\n{\n    int ret;\n    z_size_t len;\n    gz_statep state;\n\n    /* get internal structure */\n    if (file == NULL)\n        return -1;\n    state = (gz_statep)file;\n\n    /* check that we're writing and that there's no error */\n    if (state->mode != GZ_WRITE || state->err != Z_OK)\n        return -1;\n\n    /* write string */\n    len = strlen(str);\n    ret = gz_write(state, str, len);\n    return ret == 0 && len != 0 ? -1 : ret;\n}\n\n#if defined(STDC) || defined(Z_HAVE_STDARG_H)\n#include <stdarg.h>\n\n/* -- see zlib.h -- */\nint ZEXPORTVA gzvprintf(gzFile file, const char *format, va_list va)\n{\n    int len;\n    unsigned left;\n    char *next;\n    gz_statep state;\n    z_streamp strm;\n\n    /* get internal structure */\n    if (file == NULL)\n        return Z_STREAM_ERROR;\n    state = (gz_statep)file;\n    strm = &(state->strm);\n\n    /* check that we're writing and that there's no error */\n    if (state->mode != GZ_WRITE || state->err != Z_OK)\n        return Z_STREAM_ERROR;\n\n    /* make sure we have some buffer space */\n    if (state->size == 0 && gz_init(state) == -1)\n        return state->err;\n\n    /* check for seek request */\n    if (state->seek) {\n        state->seek = 0;\n        if (gz_zero(state, state->skip) == -1)\n            return state->err;\n    }\n\n    /* do the printf() into the input buffer, put length in len -- the input\n       buffer is double-sized just for this function, so there is guaranteed to\n       be state->size bytes available after the current contents */\n    if (strm->avail_in == 0)\n        strm->next_in = state->in;\n    next = (char *)(state->in + (strm->next_in - state->in) + strm->avail_in);\n    next[state->size - 1] = 0;\n#ifdef NO_vsnprintf\n#  ifdef HAS_vsprintf_void\n    (void)vsprintf(next, format, va);\n    for (len = 0; len < state->size; len++)\n        if (next[len] == 0) break;\n#  else\n    len = vsprintf(next, format, va);\n#  endif\n#else\n#  ifdef HAS_vsnprintf_void\n    (void)vsnprintf(next, state->size, format, va);\n    len = strlen(next);\n#  else\n    len = vsnprintf(next, state->size, format, va);\n#  endif\n#endif\n\n    /* check that printf() results fit in buffer */\n    if (len == 0 || (unsigned)len >= state->size || next[state->size - 1] != 0)\n        return 0;\n\n    /* update buffer and position, compress first half if past that */\n    strm->avail_in += (unsigned)len;\n    state->x.pos += len;\n    if (strm->avail_in >= state->size) {\n        left = strm->avail_in - state->size;\n        strm->avail_in = state->size;\n        if (gz_comp(state, Z_NO_FLUSH) == -1)\n            return state->err;\n        memcpy(state->in, state->in + state->size, left);\n        strm->next_in = state->in;\n        strm->avail_in = left;\n    }\n    return len;\n}\n\nint ZEXPORTVA gzprintf(gzFile file, const char *format, ...)\n{\n    va_list va;\n    int ret;\n\n    va_start(va, format);\n    ret = gzvprintf(file, format, va);\n    va_end(va);\n    return ret;\n}\n\n#else /* !STDC && !Z_HAVE_STDARG_H */\n\n/* -- see zlib.h -- */\nint ZEXPORTVA gzprintf (file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,\n                       a11, a12, a13, a14, a15, a16, a17, a18, a19, a20)\n    gzFile file;\n    const char *format;\n    int a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,\n        a11, a12, a13, a14, a15, a16, a17, a18, a19, a20;\n{\n    unsigned len, left;\n    char *next;\n    gz_statep state;\n    z_streamp strm;\n\n    /* get internal structure */\n    if (file == NULL)\n        return Z_STREAM_ERROR;\n    state = (gz_statep)file;\n    strm = &(state->strm);\n\n    /* check that can really pass pointer in ints */\n    if (sizeof(int) != sizeof(void *))\n        return Z_STREAM_ERROR;\n\n    /* check that we're writing and that there's no error */\n    if (state->mode != GZ_WRITE || state->err != Z_OK)\n        return Z_STREAM_ERROR;\n\n    /* make sure we have some buffer space */\n    if (state->size == 0 && gz_init(state) == -1)\n        return state->error;\n\n    /* check for seek request */\n    if (state->seek) {\n        state->seek = 0;\n        if (gz_zero(state, state->skip) == -1)\n            return state->error;\n    }\n\n    /* do the printf() into the input buffer, put length in len -- the input\n       buffer is double-sized just for this function, so there is guaranteed to\n       be state->size bytes available after the current contents */\n    if (strm->avail_in == 0)\n        strm->next_in = state->in;\n    next = (char *)(strm->next_in + strm->avail_in);\n    next[state->size - 1] = 0;\n#ifdef NO_snprintf\n#  ifdef HAS_sprintf_void\n    sprintf(next, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12,\n            a13, a14, a15, a16, a17, a18, a19, a20);\n    for (len = 0; len < size; len++)\n        if (next[len] == 0)\n            break;\n#  else\n    len = sprintf(next, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11,\n                  a12, a13, a14, a15, a16, a17, a18, a19, a20);\n#  endif\n#else\n#  ifdef HAS_snprintf_void\n    snprintf(next, state->size, format, a1, a2, a3, a4, a5, a6, a7, a8, a9,\n             a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);\n    len = strlen(next);\n#  else\n    len = snprintf(next, state->size, format, a1, a2, a3, a4, a5, a6, a7, a8,\n                   a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);\n#  endif\n#endif\n\n    /* check that printf() results fit in buffer */\n    if (len == 0 || len >= state->size || next[state->size - 1] != 0)\n        return 0;\n\n    /* update buffer and position, compress first half if past that */\n    strm->avail_in += len;\n    state->x.pos += len;\n    if (strm->avail_in >= state->size) {\n        left = strm->avail_in - state->size;\n        strm->avail_in = state->size;\n        if (gz_comp(state, Z_NO_FLUSH) == -1)\n            return state->err;\n        memcpy(state->in, state->in + state->size, left);\n        strm->next_in = state->in;\n        strm->avail_in = left;\n    }\n    return (int)len;\n}\n\n#endif\n\n/* -- see zlib.h -- */\nint ZEXPORT gzflush(file, flush)\n    gzFile file;\n    int flush;\n{\n    gz_statep state;\n\n    /* get internal structure */\n    if (file == NULL)\n        return Z_STREAM_ERROR;\n    state = (gz_statep)file;\n\n    /* check that we're writing and that there's no error */\n    if (state->mode != GZ_WRITE || state->err != Z_OK)\n        return Z_STREAM_ERROR;\n\n    /* check flush parameter */\n    if (flush < 0 || flush > Z_FINISH)\n        return Z_STREAM_ERROR;\n\n    /* check for seek request */\n    if (state->seek) {\n        state->seek = 0;\n        if (gz_zero(state, state->skip) == -1)\n            return state->err;\n    }\n\n    /* compress remaining data with requested flush */\n    (void)gz_comp(state, flush);\n    return state->err;\n}\n\n/* -- see zlib.h -- */\nint ZEXPORT gzsetparams(file, level, strategy)\n    gzFile file;\n    int level;\n    int strategy;\n{\n    gz_statep state;\n    z_streamp strm;\n\n    /* get internal structure */\n    if (file == NULL)\n        return Z_STREAM_ERROR;\n    state = (gz_statep)file;\n    strm = &(state->strm);\n\n    /* check that we're writing and that there's no error */\n    if (state->mode != GZ_WRITE || state->err != Z_OK)\n        return Z_STREAM_ERROR;\n\n    /* if no change is requested, then do nothing */\n    if (level == state->level && strategy == state->strategy)\n        return Z_OK;\n\n    /* check for seek request */\n    if (state->seek) {\n        state->seek = 0;\n        if (gz_zero(state, state->skip) == -1)\n            return state->err;\n    }\n\n    /* change compression parameters for subsequent input */\n    if (state->size) {\n        /* flush previous input with previous parameters before changing */\n        if (strm->avail_in && gz_comp(state, Z_BLOCK) == -1)\n            return state->err;\n        deflateParams(strm, level, strategy);\n    }\n    state->level = level;\n    state->strategy = strategy;\n    return Z_OK;\n}\n\n/* -- see zlib.h -- */\nint ZEXPORT gzclose_w(file)\n    gzFile file;\n{\n    int ret = Z_OK;\n    gz_statep state;\n\n    /* get internal structure */\n    if (file == NULL)\n        return Z_STREAM_ERROR;\n    state = (gz_statep)file;\n\n    /* check that we're writing */\n    if (state->mode != GZ_WRITE)\n        return Z_STREAM_ERROR;\n\n    /* check for seek request */\n    if (state->seek) {\n        state->seek = 0;\n        if (gz_zero(state, state->skip) == -1)\n            ret = state->err;\n    }\n\n    /* flush, free memory, and close file */\n    if (gz_comp(state, Z_FINISH) == -1)\n        ret = state->err;\n    if (state->size) {\n        if (!state->direct) {\n            (void)deflateEnd(&(state->strm));\n            free(state->out);\n        }\n        free(state->in);\n    }\n    gz_error(state, Z_OK, NULL);\n    free(state->path);\n    if (close(state->fd) == -1)\n        ret = Z_ERRNO;\n    free(state);\n    return ret;\n}\n"
  },
  {
    "path": "Projects/Libraries/CSBase/Source/zlib/infback.c",
    "content": "/* infback.c -- inflate using a call-back interface\n * Copyright (C) 1995-2016 Mark Adler\n * For conditions of distribution and use, see copyright notice in zlib.h\n */\n\n/*\n   This code is largely copied from inflate.c.  Normally either infback.o or\n   inflate.o would be linked into an application--not both.  The interface\n   with inffast.c is retained so that optimized assembler-coded versions of\n   inflate_fast() can be used with either inflate.c or infback.c.\n */\n\n#include \"zutil.h\"\n#include \"inftrees.h\"\n#include \"inflate.h\"\n#include \"inffast.h\"\n\n/* function prototypes */\nlocal void fixedtables OF((struct inflate_state FAR *state));\n\n/*\n   strm provides memory allocation functions in zalloc and zfree, or\n   Z_NULL to use the library memory allocation functions.\n\n   windowBits is in the range 8..15, and window is a user-supplied\n   window and output buffer that is 2**windowBits bytes.\n */\nint ZEXPORT inflateBackInit_(strm, windowBits, window, version, stream_size)\nz_streamp strm;\nint windowBits;\nunsigned char FAR *window;\nconst char *version;\nint stream_size;\n{\n    struct inflate_state FAR *state;\n\n    if (version == Z_NULL || version[0] != ZLIB_VERSION[0] ||\n        stream_size != (int)(sizeof(z_stream)))\n        return Z_VERSION_ERROR;\n    if (strm == Z_NULL || window == Z_NULL ||\n        windowBits < 8 || windowBits > 15)\n        return Z_STREAM_ERROR;\n    strm->msg = Z_NULL;                 /* in case we return an error */\n    if (strm->zalloc == (alloc_func)0) {\n#ifdef Z_SOLO\n        return Z_STREAM_ERROR;\n#else\n        strm->zalloc = zcalloc;\n        strm->opaque = (voidpf)0;\n#endif\n    }\n    if (strm->zfree == (free_func)0)\n#ifdef Z_SOLO\n        return Z_STREAM_ERROR;\n#else\n    strm->zfree = zcfree;\n#endif\n    state = (struct inflate_state FAR *)ZALLOC(strm, 1,\n                                               sizeof(struct inflate_state));\n    if (state == Z_NULL) return Z_MEM_ERROR;\n    Tracev((stderr, \"inflate: allocated\\n\"));\n    strm->state = (struct internal_state FAR *)state;\n    state->dmax = 32768U;\n    state->wbits = (uInt)windowBits;\n    state->wsize = 1U << windowBits;\n    state->window = window;\n    state->wnext = 0;\n    state->whave = 0;\n    return Z_OK;\n}\n\n/*\n   Return state with length and distance decoding tables and index sizes set to\n   fixed code decoding.  Normally this returns fixed tables from inffixed.h.\n   If BUILDFIXED is defined, then instead this routine builds the tables the\n   first time it's called, and returns those tables the first time and\n   thereafter.  This reduces the size of the code by about 2K bytes, in\n   exchange for a little execution time.  However, BUILDFIXED should not be\n   used for threaded applications, since the rewriting of the tables and virgin\n   may not be thread-safe.\n */\nlocal void fixedtables(state)\nstruct inflate_state FAR *state;\n{\n#ifdef BUILDFIXED\n    static int virgin = 1;\n    static code *lenfix, *distfix;\n    static code fixed[544];\n\n    /* build fixed huffman tables if first call (may not be thread safe) */\n    if (virgin) {\n        unsigned sym, bits;\n        static code *next;\n\n        /* literal/length table */\n        sym = 0;\n        while (sym < 144) state->lens[sym++] = 8;\n        while (sym < 256) state->lens[sym++] = 9;\n        while (sym < 280) state->lens[sym++] = 7;\n        while (sym < 288) state->lens[sym++] = 8;\n        next = fixed;\n        lenfix = next;\n        bits = 9;\n        inflate_table(LENS, state->lens, 288, &(next), &(bits), state->work);\n\n        /* distance table */\n        sym = 0;\n        while (sym < 32) state->lens[sym++] = 5;\n        distfix = next;\n        bits = 5;\n        inflate_table(DISTS, state->lens, 32, &(next), &(bits), state->work);\n\n        /* do this just once */\n        virgin = 0;\n    }\n#else /* !BUILDFIXED */\n#   include \"inffixed.h\"\n#endif /* BUILDFIXED */\n    state->lencode = lenfix;\n    state->lenbits = 9;\n    state->distcode = distfix;\n    state->distbits = 5;\n}\n\n/* Macros for inflateBack(): */\n\n/* Load returned state from inflate_fast() */\n#define LOAD() \\\n    do { \\\n        put = strm->next_out; \\\n        left = strm->avail_out; \\\n        next = strm->next_in; \\\n        have = strm->avail_in; \\\n        hold = state->hold; \\\n        bits = state->bits; \\\n    } while (0)\n\n/* Set state from registers for inflate_fast() */\n#define RESTORE() \\\n    do { \\\n        strm->next_out = put; \\\n        strm->avail_out = left; \\\n        strm->next_in = next; \\\n        strm->avail_in = have; \\\n        state->hold = hold; \\\n        state->bits = bits; \\\n    } while (0)\n\n/* Clear the input bit accumulator */\n#define INITBITS() \\\n    do { \\\n        hold = 0; \\\n        bits = 0; \\\n    } while (0)\n\n/* Assure that some input is available.  If input is requested, but denied,\n   then return a Z_BUF_ERROR from inflateBack(). */\n#define PULL() \\\n    do { \\\n        if (have == 0) { \\\n            have = in(in_desc, &next); \\\n            if (have == 0) { \\\n                next = Z_NULL; \\\n                ret = Z_BUF_ERROR; \\\n                goto inf_leave; \\\n            } \\\n        } \\\n    } while (0)\n\n/* Get a byte of input into the bit accumulator, or return from inflateBack()\n   with an error if there is no input available. */\n#define PULLBYTE() \\\n    do { \\\n        PULL(); \\\n        have--; \\\n        hold += (unsigned long)(*next++) << bits; \\\n        bits += 8; \\\n    } while (0)\n\n/* Assure that there are at least n bits in the bit accumulator.  If there is\n   not enough available input to do that, then return from inflateBack() with\n   an error. */\n#define NEEDBITS(n) \\\n    do { \\\n        while (bits < (unsigned)(n)) \\\n            PULLBYTE(); \\\n    } while (0)\n\n/* Return the low n bits of the bit accumulator (n < 16) */\n#define BITS(n) \\\n    ((unsigned)hold & ((1U << (n)) - 1))\n\n/* Remove n bits from the bit accumulator */\n#define DROPBITS(n) \\\n    do { \\\n        hold >>= (n); \\\n        bits -= (unsigned)(n); \\\n    } while (0)\n\n/* Remove zero to seven bits as needed to go to a byte boundary */\n#define BYTEBITS() \\\n    do { \\\n        hold >>= bits & 7; \\\n        bits -= bits & 7; \\\n    } while (0)\n\n/* Assure that some output space is available, by writing out the window\n   if it's full.  If the write fails, return from inflateBack() with a\n   Z_BUF_ERROR. */\n#define ROOM() \\\n    do { \\\n        if (left == 0) { \\\n            put = state->window; \\\n            left = state->wsize; \\\n            state->whave = left; \\\n            if (out(out_desc, put, left)) { \\\n                ret = Z_BUF_ERROR; \\\n                goto inf_leave; \\\n            } \\\n        } \\\n    } while (0)\n\n/*\n   strm provides the memory allocation functions and window buffer on input,\n   and provides information on the unused input on return.  For Z_DATA_ERROR\n   returns, strm will also provide an error message.\n\n   in() and out() are the call-back input and output functions.  When\n   inflateBack() needs more input, it calls in().  When inflateBack() has\n   filled the window with output, or when it completes with data in the\n   window, it calls out() to write out the data.  The application must not\n   change the provided input until in() is called again or inflateBack()\n   returns.  The application must not change the window/output buffer until\n   inflateBack() returns.\n\n   in() and out() are called with a descriptor parameter provided in the\n   inflateBack() call.  This parameter can be a structure that provides the\n   information required to do the read or write, as well as accumulated\n   information on the input and output such as totals and check values.\n\n   in() should return zero on failure.  out() should return non-zero on\n   failure.  If either in() or out() fails, than inflateBack() returns a\n   Z_BUF_ERROR.  strm->next_in can be checked for Z_NULL to see whether it\n   was in() or out() that caused in the error.  Otherwise,  inflateBack()\n   returns Z_STREAM_END on success, Z_DATA_ERROR for an deflate format\n   error, or Z_MEM_ERROR if it could not allocate memory for the state.\n   inflateBack() can also return Z_STREAM_ERROR if the input parameters\n   are not correct, i.e. strm is Z_NULL or the state was not initialized.\n */\nint ZEXPORT inflateBack(strm, in, in_desc, out, out_desc)\nz_streamp strm;\nin_func in;\nvoid FAR *in_desc;\nout_func out;\nvoid FAR *out_desc;\n{\n    struct inflate_state FAR *state;\n    z_const unsigned char FAR *next;    /* next input */\n    unsigned char FAR *put;     /* next output */\n    unsigned have, left;        /* available input and output */\n    unsigned long hold;         /* bit buffer */\n    unsigned bits;              /* bits in bit buffer */\n    unsigned copy;              /* number of stored or match bytes to copy */\n    unsigned char FAR *from;    /* where to copy match bytes from */\n    code here;                  /* current decoding table entry */\n    code last;                  /* parent table entry */\n    unsigned len;               /* length to copy for repeats, bits to drop */\n    int ret;                    /* return code */\n    static const unsigned short order[19] = /* permutation of code lengths */\n        {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};\n\n    /* Check that the strm exists and that the state was initialized */\n    if (strm == Z_NULL || strm->state == Z_NULL)\n        return Z_STREAM_ERROR;\n    state = (struct inflate_state FAR *)strm->state;\n\n    /* Reset the state */\n    strm->msg = Z_NULL;\n    state->mode = TYPE;\n    state->last = 0;\n    state->whave = 0;\n    next = strm->next_in;\n    have = next != Z_NULL ? strm->avail_in : 0;\n    hold = 0;\n    bits = 0;\n    put = state->window;\n    left = state->wsize;\n\n    /* Inflate until end of block marked as last */\n    for (;;)\n        switch (state->mode) {\n        case TYPE:\n            /* determine and dispatch block type */\n            if (state->last) {\n                BYTEBITS();\n                state->mode = DONE;\n                break;\n            }\n            NEEDBITS(3);\n            state->last = BITS(1);\n            DROPBITS(1);\n            switch (BITS(2)) {\n            case 0:                             /* stored block */\n                Tracev((stderr, \"inflate:     stored block%s\\n\",\n                        state->last ? \" (last)\" : \"\"));\n                state->mode = STORED;\n                break;\n            case 1:                             /* fixed block */\n                fixedtables(state);\n                Tracev((stderr, \"inflate:     fixed codes block%s\\n\",\n                        state->last ? \" (last)\" : \"\"));\n                state->mode = LEN;              /* decode codes */\n                break;\n            case 2:                             /* dynamic block */\n                Tracev((stderr, \"inflate:     dynamic codes block%s\\n\",\n                        state->last ? \" (last)\" : \"\"));\n                state->mode = TABLE;\n                break;\n            case 3:\n                strm->msg = (char *)\"invalid block type\";\n                state->mode = BAD;\n            }\n            DROPBITS(2);\n            break;\n\n        case STORED:\n            /* get and verify stored block length */\n            BYTEBITS();                         /* go to byte boundary */\n            NEEDBITS(32);\n            if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) {\n                strm->msg = (char *)\"invalid stored block lengths\";\n                state->mode = BAD;\n                break;\n            }\n            state->length = (unsigned)hold & 0xffff;\n            Tracev((stderr, \"inflate:       stored length %u\\n\",\n                    state->length));\n            INITBITS();\n\n            /* copy stored block from input to output */\n            while (state->length != 0) {\n                copy = state->length;\n                PULL();\n                ROOM();\n                if (copy > have) copy = have;\n                if (copy > left) copy = left;\n                zmemcpy(put, next, copy);\n                have -= copy;\n                next += copy;\n                left -= copy;\n                put += copy;\n                state->length -= copy;\n            }\n            Tracev((stderr, \"inflate:       stored end\\n\"));\n            state->mode = TYPE;\n            break;\n\n        case TABLE:\n            /* get dynamic table entries descriptor */\n            NEEDBITS(14);\n            state->nlen = BITS(5) + 257;\n            DROPBITS(5);\n            state->ndist = BITS(5) + 1;\n            DROPBITS(5);\n            state->ncode = BITS(4) + 4;\n            DROPBITS(4);\n#ifndef PKZIP_BUG_WORKAROUND\n            if (state->nlen > 286 || state->ndist > 30) {\n                strm->msg = (char *)\"too many length or distance symbols\";\n                state->mode = BAD;\n                break;\n            }\n#endif\n            Tracev((stderr, \"inflate:       table sizes ok\\n\"));\n\n            /* get code length code lengths (not a typo) */\n            state->have = 0;\n            while (state->have < state->ncode) {\n                NEEDBITS(3);\n                state->lens[order[state->have++]] = (unsigned short)BITS(3);\n                DROPBITS(3);\n            }\n            while (state->have < 19)\n                state->lens[order[state->have++]] = 0;\n            state->next = state->codes;\n            state->lencode = (code const FAR *)(state->next);\n            state->lenbits = 7;\n            ret = inflate_table(CODES, state->lens, 19, &(state->next),\n                                &(state->lenbits), state->work);\n            if (ret) {\n                strm->msg = (char *)\"invalid code lengths set\";\n                state->mode = BAD;\n                break;\n            }\n            Tracev((stderr, \"inflate:       code lengths ok\\n\"));\n\n            /* get length and distance code code lengths */\n            state->have = 0;\n            while (state->have < state->nlen + state->ndist) {\n                for (;;) {\n                    here = state->lencode[BITS(state->lenbits)];\n                    if ((unsigned)(here.bits) <= bits) break;\n                    PULLBYTE();\n                }\n                if (here.val < 16) {\n                    DROPBITS(here.bits);\n                    state->lens[state->have++] = here.val;\n                }\n                else {\n                    if (here.val == 16) {\n                        NEEDBITS(here.bits + 2);\n                        DROPBITS(here.bits);\n                        if (state->have == 0) {\n                            strm->msg = (char *)\"invalid bit length repeat\";\n                            state->mode = BAD;\n                            break;\n                        }\n                        len = (unsigned)(state->lens[state->have - 1]);\n                        copy = 3 + BITS(2);\n                        DROPBITS(2);\n                    }\n                    else if (here.val == 17) {\n                        NEEDBITS(here.bits + 3);\n                        DROPBITS(here.bits);\n                        len = 0;\n                        copy = 3 + BITS(3);\n                        DROPBITS(3);\n                    }\n                    else {\n                        NEEDBITS(here.bits + 7);\n                        DROPBITS(here.bits);\n                        len = 0;\n                        copy = 11 + BITS(7);\n                        DROPBITS(7);\n                    }\n                    if (state->have + copy > state->nlen + state->ndist) {\n                        strm->msg = (char *)\"invalid bit length repeat\";\n                        state->mode = BAD;\n                        break;\n                    }\n                    while (copy--)\n                        state->lens[state->have++] = (unsigned short)len;\n                }\n            }\n\n            /* handle error breaks in while */\n            if (state->mode == BAD) break;\n\n            /* check for end-of-block code (better have one) */\n            if (state->lens[256] == 0) {\n                strm->msg = (char *)\"invalid code -- missing end-of-block\";\n                state->mode = BAD;\n                break;\n            }\n\n            /* build code tables -- note: do not change the lenbits or distbits\n               values here (9 and 6) without reading the comments in inftrees.h\n               concerning the ENOUGH constants, which depend on those values */\n            state->next = state->codes;\n            state->lencode = (code const FAR *)(state->next);\n            state->lenbits = 9;\n            ret = inflate_table(LENS, state->lens, state->nlen, &(state->next),\n                                &(state->lenbits), state->work);\n            if (ret) {\n                strm->msg = (char *)\"invalid literal/lengths set\";\n                state->mode = BAD;\n                break;\n            }\n            state->distcode = (code const FAR *)(state->next);\n            state->distbits = 6;\n            ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist,\n                            &(state->next), &(state->distbits), state->work);\n            if (ret) {\n                strm->msg = (char *)\"invalid distances set\";\n                state->mode = BAD;\n                break;\n            }\n            Tracev((stderr, \"inflate:       codes ok\\n\"));\n            state->mode = LEN;\n\n        case LEN:\n            /* use inflate_fast() if we have enough input and output */\n            if (have >= 6 && left >= 258) {\n                RESTORE();\n                if (state->whave < state->wsize)\n                    state->whave = state->wsize - left;\n                inflate_fast(strm, state->wsize);\n                LOAD();\n                break;\n            }\n\n            /* get a literal, length, or end-of-block code */\n            for (;;) {\n                here = state->lencode[BITS(state->lenbits)];\n                if ((unsigned)(here.bits) <= bits) break;\n                PULLBYTE();\n            }\n            if (here.op && (here.op & 0xf0) == 0) {\n                last = here;\n                for (;;) {\n                    here = state->lencode[last.val +\n                            (BITS(last.bits + last.op) >> last.bits)];\n                    if ((unsigned)(last.bits + here.bits) <= bits) break;\n                    PULLBYTE();\n                }\n                DROPBITS(last.bits);\n            }\n            DROPBITS(here.bits);\n            state->length = (unsigned)here.val;\n\n            /* process literal */\n            if (here.op == 0) {\n                Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?\n                        \"inflate:         literal '%c'\\n\" :\n                        \"inflate:         literal 0x%02x\\n\", here.val));\n                ROOM();\n                *put++ = (unsigned char)(state->length);\n                left--;\n                state->mode = LEN;\n                break;\n            }\n\n            /* process end of block */\n            if (here.op & 32) {\n                Tracevv((stderr, \"inflate:         end of block\\n\"));\n                state->mode = TYPE;\n                break;\n            }\n\n            /* invalid code */\n            if (here.op & 64) {\n                strm->msg = (char *)\"invalid literal/length code\";\n                state->mode = BAD;\n                break;\n            }\n\n            /* length code -- get extra bits, if any */\n            state->extra = (unsigned)(here.op) & 15;\n            if (state->extra != 0) {\n                NEEDBITS(state->extra);\n                state->length += BITS(state->extra);\n                DROPBITS(state->extra);\n            }\n            Tracevv((stderr, \"inflate:         length %u\\n\", state->length));\n\n            /* get distance code */\n            for (;;) {\n                here = state->distcode[BITS(state->distbits)];\n                if ((unsigned)(here.bits) <= bits) break;\n                PULLBYTE();\n            }\n            if ((here.op & 0xf0) == 0) {\n                last = here;\n                for (;;) {\n                    here = state->distcode[last.val +\n                            (BITS(last.bits + last.op) >> last.bits)];\n                    if ((unsigned)(last.bits + here.bits) <= bits) break;\n                    PULLBYTE();\n                }\n                DROPBITS(last.bits);\n            }\n            DROPBITS(here.bits);\n            if (here.op & 64) {\n                strm->msg = (char *)\"invalid distance code\";\n                state->mode = BAD;\n                break;\n            }\n            state->offset = (unsigned)here.val;\n\n            /* get distance extra bits, if any */\n            state->extra = (unsigned)(here.op) & 15;\n            if (state->extra != 0) {\n                NEEDBITS(state->extra);\n                state->offset += BITS(state->extra);\n                DROPBITS(state->extra);\n            }\n            if (state->offset > state->wsize - (state->whave < state->wsize ?\n                                                left : 0)) {\n                strm->msg = (char *)\"invalid distance too far back\";\n                state->mode = BAD;\n                break;\n            }\n            Tracevv((stderr, \"inflate:         distance %u\\n\", state->offset));\n\n            /* copy match from window to output */\n            do {\n                ROOM();\n                copy = state->wsize - state->offset;\n                if (copy < left) {\n                    from = put + copy;\n                    copy = left - copy;\n                }\n                else {\n                    from = put - state->offset;\n                    copy = left;\n                }\n                if (copy > state->length) copy = state->length;\n                state->length -= copy;\n                left -= copy;\n                do {\n                    *put++ = *from++;\n                } while (--copy);\n            } while (state->length != 0);\n            break;\n\n        case DONE:\n            /* inflate stream terminated properly -- write leftover output */\n            ret = Z_STREAM_END;\n            if (left < state->wsize) {\n                if (out(out_desc, state->window, state->wsize - left))\n                    ret = Z_BUF_ERROR;\n            }\n            goto inf_leave;\n\n        case BAD:\n            ret = Z_DATA_ERROR;\n            goto inf_leave;\n\n        default:                /* can't happen, but makes compilers happy */\n            ret = Z_STREAM_ERROR;\n            goto inf_leave;\n        }\n\n    /* Return unused input */\n  inf_leave:\n    strm->next_in = next;\n    strm->avail_in = have;\n    return ret;\n}\n\nint ZEXPORT inflateBackEnd(strm)\nz_streamp strm;\n{\n    if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0)\n        return Z_STREAM_ERROR;\n    ZFREE(strm, strm->state);\n    strm->state = Z_NULL;\n    Tracev((stderr, \"inflate: end\\n\"));\n    return Z_OK;\n}\n"
  },
  {
    "path": "Projects/Libraries/CSBase/Source/zlib/inffast.c",
    "content": "/* inffast.c -- fast decoding\n * Copyright (C) 1995-2017 Mark Adler\n * For conditions of distribution and use, see copyright notice in zlib.h\n */\n\n#include \"zutil.h\"\n#include \"inftrees.h\"\n#include \"inflate.h\"\n#include \"inffast.h\"\n\n#ifdef ASMINF\n#  pragma message(\"Assembler code may have bugs -- use at your own risk\")\n#else\n\n/*\n   Decode literal, length, and distance codes and write out the resulting\n   literal and match bytes until either not enough input or output is\n   available, an end-of-block is encountered, or a data error is encountered.\n   When large enough input and output buffers are supplied to inflate(), for\n   example, a 16K input buffer and a 64K output buffer, more than 95% of the\n   inflate execution time is spent in this routine.\n\n   Entry assumptions:\n\n        state->mode == LEN\n        strm->avail_in >= 6\n        strm->avail_out >= 258\n        start >= strm->avail_out\n        state->bits < 8\n\n   On return, state->mode is one of:\n\n        LEN -- ran out of enough output space or enough available input\n        TYPE -- reached end of block code, inflate() to interpret next block\n        BAD -- error in block data\n\n   Notes:\n\n    - The maximum input bits used by a length/distance pair is 15 bits for the\n      length code, 5 bits for the length extra, 15 bits for the distance code,\n      and 13 bits for the distance extra.  This totals 48 bits, or six bytes.\n      Therefore if strm->avail_in >= 6, then there is enough input to avoid\n      checking for available input while decoding.\n\n    - The maximum bytes that a single length/distance pair can output is 258\n      bytes, which is the maximum length that can be coded.  inflate_fast()\n      requires strm->avail_out >= 258 for each loop to avoid checking for\n      output space.\n */\nvoid ZLIB_INTERNAL inflate_fast(strm, start)\nz_streamp strm;\nunsigned start;         /* inflate()'s starting value for strm->avail_out */\n{\n    struct inflate_state FAR *state;\n    z_const unsigned char FAR *in;      /* local strm->next_in */\n    z_const unsigned char FAR *last;    /* have enough input while in < last */\n    unsigned char FAR *out;     /* local strm->next_out */\n    unsigned char FAR *beg;     /* inflate()'s initial strm->next_out */\n    unsigned char FAR *end;     /* while out < end, enough space available */\n#ifdef INFLATE_STRICT\n    unsigned dmax;              /* maximum distance from zlib header */\n#endif\n    unsigned wsize;             /* window size or zero if not using window */\n    unsigned whave;             /* valid bytes in the window */\n    unsigned wnext;             /* window write index */\n    unsigned char FAR *window;  /* allocated sliding window, if wsize != 0 */\n    unsigned long hold;         /* local strm->hold */\n    unsigned bits;              /* local strm->bits */\n    code const FAR *lcode;      /* local strm->lencode */\n    code const FAR *dcode;      /* local strm->distcode */\n    unsigned lmask;             /* mask for first level of length codes */\n    unsigned dmask;             /* mask for first level of distance codes */\n    code here;                  /* retrieved table entry */\n    unsigned op;                /* code bits, operation, extra bits, or */\n                                /*  window position, window bytes to copy */\n    unsigned len;               /* match length, unused bytes */\n    unsigned dist;              /* match distance */\n    unsigned char FAR *from;    /* where to copy match from */\n\n    /* copy state to local variables */\n    state = (struct inflate_state FAR *)strm->state;\n    in = strm->next_in;\n    last = in + (strm->avail_in - 5);\n    out = strm->next_out;\n    beg = out - (start - strm->avail_out);\n    end = out + (strm->avail_out - 257);\n#ifdef INFLATE_STRICT\n    dmax = state->dmax;\n#endif\n    wsize = state->wsize;\n    whave = state->whave;\n    wnext = state->wnext;\n    window = state->window;\n    hold = state->hold;\n    bits = state->bits;\n    lcode = state->lencode;\n    dcode = state->distcode;\n    lmask = (1U << state->lenbits) - 1;\n    dmask = (1U << state->distbits) - 1;\n\n    /* decode literals and length/distances until end-of-block or not enough\n       input data or output space */\n    do {\n        if (bits < 15) {\n            hold += (unsigned long)(*in++) << bits;\n            bits += 8;\n            hold += (unsigned long)(*in++) << bits;\n            bits += 8;\n        }\n        here = lcode[hold & lmask];\n      dolen:\n        op = (unsigned)(here.bits);\n        hold >>= op;\n        bits -= op;\n        op = (unsigned)(here.op);\n        if (op == 0) {                          /* literal */\n            Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?\n                    \"inflate:         literal '%c'\\n\" :\n                    \"inflate:         literal 0x%02x\\n\", here.val));\n            *out++ = (unsigned char)(here.val);\n        }\n        else if (op & 16) {                     /* length base */\n            len = (unsigned)(here.val);\n            op &= 15;                           /* number of extra bits */\n            if (op) {\n                if (bits < op) {\n                    hold += (unsigned long)(*in++) << bits;\n                    bits += 8;\n                }\n                len += (unsigned)hold & ((1U << op) - 1);\n                hold >>= op;\n                bits -= op;\n            }\n            Tracevv((stderr, \"inflate:         length %u\\n\", len));\n            if (bits < 15) {\n                hold += (unsigned long)(*in++) << bits;\n                bits += 8;\n                hold += (unsigned long)(*in++) << bits;\n                bits += 8;\n            }\n            here = dcode[hold & dmask];\n          dodist:\n            op = (unsigned)(here.bits);\n            hold >>= op;\n            bits -= op;\n            op = (unsigned)(here.op);\n            if (op & 16) {                      /* distance base */\n                dist = (unsigned)(here.val);\n                op &= 15;                       /* number of extra bits */\n                if (bits < op) {\n                    hold += (unsigned long)(*in++) << bits;\n                    bits += 8;\n                    if (bits < op) {\n                        hold += (unsigned long)(*in++) << bits;\n                        bits += 8;\n                    }\n                }\n                dist += (unsigned)hold & ((1U << op) - 1);\n#ifdef INFLATE_STRICT\n                if (dist > dmax) {\n                    strm->msg = (char *)\"invalid distance too far back\";\n                    state->mode = BAD;\n                    break;\n                }\n#endif\n                hold >>= op;\n                bits -= op;\n                Tracevv((stderr, \"inflate:         distance %u\\n\", dist));\n                op = (unsigned)(out - beg);     /* max distance in output */\n                if (dist > op) {                /* see if copy from window */\n                    op = dist - op;             /* distance back in window */\n                    if (op > whave) {\n                        if (state->sane) {\n                            strm->msg =\n                                (char *)\"invalid distance too far back\";\n                            state->mode = BAD;\n                            break;\n                        }\n#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR\n                        if (len <= op - whave) {\n                            do {\n                                *out++ = 0;\n                            } while (--len);\n                            continue;\n                        }\n                        len -= op - whave;\n                        do {\n                            *out++ = 0;\n                        } while (--op > whave);\n                        if (op == 0) {\n                            from = out - dist;\n                            do {\n                                *out++ = *from++;\n                            } while (--len);\n                            continue;\n                        }\n#endif\n                    }\n                    from = window;\n                    if (wnext == 0) {           /* very common case */\n                        from += wsize - op;\n                        if (op < len) {         /* some from window */\n                            len -= op;\n                            do {\n                                *out++ = *from++;\n                            } while (--op);\n                            from = out - dist;  /* rest from output */\n                        }\n                    }\n                    else if (wnext < op) {      /* wrap around window */\n                        from += wsize + wnext - op;\n                        op -= wnext;\n                        if (op < len) {         /* some from end of window */\n                            len -= op;\n                            do {\n                                *out++ = *from++;\n                            } while (--op);\n                            from = window;\n                            if (wnext < len) {  /* some from start of window */\n                                op = wnext;\n                                len -= op;\n                                do {\n                                    *out++ = *from++;\n                                } while (--op);\n                                from = out - dist;      /* rest from output */\n                            }\n                        }\n                    }\n                    else {                      /* contiguous in window */\n                        from += wnext - op;\n                        if (op < len) {         /* some from window */\n                            len -= op;\n                            do {\n                                *out++ = *from++;\n                            } while (--op);\n                            from = out - dist;  /* rest from output */\n                        }\n                    }\n                    while (len > 2) {\n                        *out++ = *from++;\n                        *out++ = *from++;\n                        *out++ = *from++;\n                        len -= 3;\n                    }\n                    if (len) {\n                        *out++ = *from++;\n                        if (len > 1)\n                            *out++ = *from++;\n                    }\n                }\n                else {\n                    from = out - dist;          /* copy direct from output */\n                    do {                        /* minimum length is three */\n                        *out++ = *from++;\n                        *out++ = *from++;\n                        *out++ = *from++;\n                        len -= 3;\n                    } while (len > 2);\n                    if (len) {\n                        *out++ = *from++;\n                        if (len > 1)\n                            *out++ = *from++;\n                    }\n                }\n            }\n            else if ((op & 64) == 0) {          /* 2nd level distance code */\n                here = dcode[here.val + (hold & ((1U << op) - 1))];\n                goto dodist;\n            }\n            else {\n                strm->msg = (char *)\"invalid distance code\";\n                state->mode = BAD;\n                break;\n            }\n        }\n        else if ((op & 64) == 0) {              /* 2nd level length code */\n            here = lcode[here.val + (hold & ((1U << op) - 1))];\n            goto dolen;\n        }\n        else if (op & 32) {                     /* end-of-block */\n            Tracevv((stderr, \"inflate:         end of block\\n\"));\n            state->mode = TYPE;\n            break;\n        }\n        else {\n            strm->msg = (char *)\"invalid literal/length code\";\n            state->mode = BAD;\n            break;\n        }\n    } while (in < last && out < end);\n\n    /* return unused bytes (on entry, bits < 8, so in won't go too far back) */\n    len = bits >> 3;\n    in -= len;\n    bits -= len << 3;\n    hold &= (1U << bits) - 1;\n\n    /* update state and return */\n    strm->next_in = in;\n    strm->next_out = out;\n    strm->avail_in = (unsigned)(in < last ? 5 + (last - in) : 5 - (in - last));\n    strm->avail_out = (unsigned)(out < end ?\n                                 257 + (end - out) : 257 - (out - end));\n    state->hold = hold;\n    state->bits = bits;\n    return;\n}\n\n/*\n   inflate_fast() speedups that turned out slower (on a PowerPC G3 750CXe):\n   - Using bit fields for code structure\n   - Different op definition to avoid & for extra bits (do & for table bits)\n   - Three separate decoding do-loops for direct, window, and wnext == 0\n   - Special case for distance > 1 copies to do overlapped load and store copy\n   - Explicit branch predictions (based on measured branch probabilities)\n   - Deferring match copy and interspersed it with decoding subsequent codes\n   - Swapping literal/length else\n   - Swapping window/direct else\n   - Larger unrolled copy loops (three is about right)\n   - Moving len -= 3 statement into middle of loop\n */\n\n#endif /* !ASMINF */\n"
  },
  {
    "path": "Projects/Libraries/CSBase/Source/zlib/inffast.h",
    "content": "/* inffast.h -- header to use inffast.c\n * Copyright (C) 1995-2003, 2010 Mark Adler\n * For conditions of distribution and use, see copyright notice in zlib.h\n */\n\n/* WARNING: this file should *not* be used by applications. It is\n   part of the implementation of the compression library and is\n   subject to change. Applications should only use zlib.h.\n */\n\nvoid ZLIB_INTERNAL inflate_fast OF((z_streamp strm, unsigned start));\n"
  },
  {
    "path": "Projects/Libraries/CSBase/Source/zlib/inffixed.h",
    "content": "    /* inffixed.h -- table for decoding fixed codes\n     * Generated automatically by makefixed().\n     */\n\n    /* WARNING: this file should *not* be used by applications.\n       It is part of the implementation of this library and is\n       subject to change. Applications should only use zlib.h.\n     */\n\n    static const code lenfix[512] = {\n        {96,7,0},{0,8,80},{0,8,16},{20,8,115},{18,7,31},{0,8,112},{0,8,48},\n        {0,9,192},{16,7,10},{0,8,96},{0,8,32},{0,9,160},{0,8,0},{0,8,128},\n        {0,8,64},{0,9,224},{16,7,6},{0,8,88},{0,8,24},{0,9,144},{19,7,59},\n        {0,8,120},{0,8,56},{0,9,208},{17,7,17},{0,8,104},{0,8,40},{0,9,176},\n        {0,8,8},{0,8,136},{0,8,72},{0,9,240},{16,7,4},{0,8,84},{0,8,20},\n        {21,8,227},{19,7,43},{0,8,116},{0,8,52},{0,9,200},{17,7,13},{0,8,100},\n        {0,8,36},{0,9,168},{0,8,4},{0,8,132},{0,8,68},{0,9,232},{16,7,8},\n        {0,8,92},{0,8,28},{0,9,152},{20,7,83},{0,8,124},{0,8,60},{0,9,216},\n        {18,7,23},{0,8,108},{0,8,44},{0,9,184},{0,8,12},{0,8,140},{0,8,76},\n        {0,9,248},{16,7,3},{0,8,82},{0,8,18},{21,8,163},{19,7,35},{0,8,114},\n        {0,8,50},{0,9,196},{17,7,11},{0,8,98},{0,8,34},{0,9,164},{0,8,2},\n        {0,8,130},{0,8,66},{0,9,228},{16,7,7},{0,8,90},{0,8,26},{0,9,148},\n        {20,7,67},{0,8,122},{0,8,58},{0,9,212},{18,7,19},{0,8,106},{0,8,42},\n        {0,9,180},{0,8,10},{0,8,138},{0,8,74},{0,9,244},{16,7,5},{0,8,86},\n        {0,8,22},{64,8,0},{19,7,51},{0,8,118},{0,8,54},{0,9,204},{17,7,15},\n        {0,8,102},{0,8,38},{0,9,172},{0,8,6},{0,8,134},{0,8,70},{0,9,236},\n        {16,7,9},{0,8,94},{0,8,30},{0,9,156},{20,7,99},{0,8,126},{0,8,62},\n        {0,9,220},{18,7,27},{0,8,110},{0,8,46},{0,9,188},{0,8,14},{0,8,142},\n        {0,8,78},{0,9,252},{96,7,0},{0,8,81},{0,8,17},{21,8,131},{18,7,31},\n        {0,8,113},{0,8,49},{0,9,194},{16,7,10},{0,8,97},{0,8,33},{0,9,162},\n        {0,8,1},{0,8,129},{0,8,65},{0,9,226},{16,7,6},{0,8,89},{0,8,25},\n        {0,9,146},{19,7,59},{0,8,121},{0,8,57},{0,9,210},{17,7,17},{0,8,105},\n        {0,8,41},{0,9,178},{0,8,9},{0,8,137},{0,8,73},{0,9,242},{16,7,4},\n        {0,8,85},{0,8,21},{16,8,258},{19,7,43},{0,8,117},{0,8,53},{0,9,202},\n        {17,7,13},{0,8,101},{0,8,37},{0,9,170},{0,8,5},{0,8,133},{0,8,69},\n        {0,9,234},{16,7,8},{0,8,93},{0,8,29},{0,9,154},{20,7,83},{0,8,125},\n        {0,8,61},{0,9,218},{18,7,23},{0,8,109},{0,8,45},{0,9,186},{0,8,13},\n        {0,8,141},{0,8,77},{0,9,250},{16,7,3},{0,8,83},{0,8,19},{21,8,195},\n        {19,7,35},{0,8,115},{0,8,51},{0,9,198},{17,7,11},{0,8,99},{0,8,35},\n        {0,9,166},{0,8,3},{0,8,131},{0,8,67},{0,9,230},{16,7,7},{0,8,91},\n        {0,8,27},{0,9,150},{20,7,67},{0,8,123},{0,8,59},{0,9,214},{18,7,19},\n        {0,8,107},{0,8,43},{0,9,182},{0,8,11},{0,8,139},{0,8,75},{0,9,246},\n        {16,7,5},{0,8,87},{0,8,23},{64,8,0},{19,7,51},{0,8,119},{0,8,55},\n        {0,9,206},{17,7,15},{0,8,103},{0,8,39},{0,9,174},{0,8,7},{0,8,135},\n        {0,8,71},{0,9,238},{16,7,9},{0,8,95},{0,8,31},{0,9,158},{20,7,99},\n        {0,8,127},{0,8,63},{0,9,222},{18,7,27},{0,8,111},{0,8,47},{0,9,190},\n        {0,8,15},{0,8,143},{0,8,79},{0,9,254},{96,7,0},{0,8,80},{0,8,16},\n        {20,8,115},{18,7,31},{0,8,112},{0,8,48},{0,9,193},{16,7,10},{0,8,96},\n        {0,8,32},{0,9,161},{0,8,0},{0,8,128},{0,8,64},{0,9,225},{16,7,6},\n        {0,8,88},{0,8,24},{0,9,145},{19,7,59},{0,8,120},{0,8,56},{0,9,209},\n        {17,7,17},{0,8,104},{0,8,40},{0,9,177},{0,8,8},{0,8,136},{0,8,72},\n        {0,9,241},{16,7,4},{0,8,84},{0,8,20},{21,8,227},{19,7,43},{0,8,116},\n        {0,8,52},{0,9,201},{17,7,13},{0,8,100},{0,8,36},{0,9,169},{0,8,4},\n        {0,8,132},{0,8,68},{0,9,233},{16,7,8},{0,8,92},{0,8,28},{0,9,153},\n        {20,7,83},{0,8,124},{0,8,60},{0,9,217},{18,7,23},{0,8,108},{0,8,44},\n        {0,9,185},{0,8,12},{0,8,140},{0,8,76},{0,9,249},{16,7,3},{0,8,82},\n        {0,8,18},{21,8,163},{19,7,35},{0,8,114},{0,8,50},{0,9,197},{17,7,11},\n        {0,8,98},{0,8,34},{0,9,165},{0,8,2},{0,8,130},{0,8,66},{0,9,229},\n        {16,7,7},{0,8,90},{0,8,26},{0,9,149},{20,7,67},{0,8,122},{0,8,58},\n        {0,9,213},{18,7,19},{0,8,106},{0,8,42},{0,9,181},{0,8,10},{0,8,138},\n        {0,8,74},{0,9,245},{16,7,5},{0,8,86},{0,8,22},{64,8,0},{19,7,51},\n        {0,8,118},{0,8,54},{0,9,205},{17,7,15},{0,8,102},{0,8,38},{0,9,173},\n        {0,8,6},{0,8,134},{0,8,70},{0,9,237},{16,7,9},{0,8,94},{0,8,30},\n        {0,9,157},{20,7,99},{0,8,126},{0,8,62},{0,9,221},{18,7,27},{0,8,110},\n        {0,8,46},{0,9,189},{0,8,14},{0,8,142},{0,8,78},{0,9,253},{96,7,0},\n        {0,8,81},{0,8,17},{21,8,131},{18,7,31},{0,8,113},{0,8,49},{0,9,195},\n        {16,7,10},{0,8,97},{0,8,33},{0,9,163},{0,8,1},{0,8,129},{0,8,65},\n        {0,9,227},{16,7,6},{0,8,89},{0,8,25},{0,9,147},{19,7,59},{0,8,121},\n        {0,8,57},{0,9,211},{17,7,17},{0,8,105},{0,8,41},{0,9,179},{0,8,9},\n        {0,8,137},{0,8,73},{0,9,243},{16,7,4},{0,8,85},{0,8,21},{16,8,258},\n        {19,7,43},{0,8,117},{0,8,53},{0,9,203},{17,7,13},{0,8,101},{0,8,37},\n        {0,9,171},{0,8,5},{0,8,133},{0,8,69},{0,9,235},{16,7,8},{0,8,93},\n        {0,8,29},{0,9,155},{20,7,83},{0,8,125},{0,8,61},{0,9,219},{18,7,23},\n        {0,8,109},{0,8,45},{0,9,187},{0,8,13},{0,8,141},{0,8,77},{0,9,251},\n        {16,7,3},{0,8,83},{0,8,19},{21,8,195},{19,7,35},{0,8,115},{0,8,51},\n        {0,9,199},{17,7,11},{0,8,99},{0,8,35},{0,9,167},{0,8,3},{0,8,131},\n        {0,8,67},{0,9,231},{16,7,7},{0,8,91},{0,8,27},{0,9,151},{20,7,67},\n        {0,8,123},{0,8,59},{0,9,215},{18,7,19},{0,8,107},{0,8,43},{0,9,183},\n        {0,8,11},{0,8,139},{0,8,75},{0,9,247},{16,7,5},{0,8,87},{0,8,23},\n        {64,8,0},{19,7,51},{0,8,119},{0,8,55},{0,9,207},{17,7,15},{0,8,103},\n        {0,8,39},{0,9,175},{0,8,7},{0,8,135},{0,8,71},{0,9,239},{16,7,9},\n        {0,8,95},{0,8,31},{0,9,159},{20,7,99},{0,8,127},{0,8,63},{0,9,223},\n        {18,7,27},{0,8,111},{0,8,47},{0,9,191},{0,8,15},{0,8,143},{0,8,79},\n        {0,9,255}\n    };\n\n    static const code distfix[32] = {\n        {16,5,1},{23,5,257},{19,5,17},{27,5,4097},{17,5,5},{25,5,1025},\n        {21,5,65},{29,5,16385},{16,5,3},{24,5,513},{20,5,33},{28,5,8193},\n        {18,5,9},{26,5,2049},{22,5,129},{64,5,0},{16,5,2},{23,5,385},\n        {19,5,25},{27,5,6145},{17,5,7},{25,5,1537},{21,5,97},{29,5,24577},\n        {16,5,4},{24,5,769},{20,5,49},{28,5,12289},{18,5,13},{26,5,3073},\n        {22,5,193},{64,5,0}\n    };\n"
  },
  {
    "path": "Projects/Libraries/CSBase/Source/zlib/inflate.c",
    "content": "/* inflate.c -- zlib decompression\n * Copyright (C) 1995-2016 Mark Adler\n * For conditions of distribution and use, see copyright notice in zlib.h\n */\n\n/*\n * Change history:\n *\n * 1.2.beta0    24 Nov 2002\n * - First version -- complete rewrite of inflate to simplify code, avoid\n *   creation of window when not needed, minimize use of window when it is\n *   needed, make inffast.c even faster, implement gzip decoding, and to\n *   improve code readability and style over the previous zlib inflate code\n *\n * 1.2.beta1    25 Nov 2002\n * - Use pointers for available input and output checking in inffast.c\n * - Remove input and output counters in inffast.c\n * - Change inffast.c entry and loop from avail_in >= 7 to >= 6\n * - Remove unnecessary second byte pull from length extra in inffast.c\n * - Unroll direct copy to three copies per loop in inffast.c\n *\n * 1.2.beta2    4 Dec 2002\n * - Change external routine names to reduce potential conflicts\n * - Correct filename to inffixed.h for fixed tables in inflate.c\n * - Make hbuf[] unsigned char to match parameter type in inflate.c\n * - Change strm->next_out[-state->offset] to *(strm->next_out - state->offset)\n *   to avoid negation problem on Alphas (64 bit) in inflate.c\n *\n * 1.2.beta3    22 Dec 2002\n * - Add comments on state->bits assertion in inffast.c\n * - Add comments on op field in inftrees.h\n * - Fix bug in reuse of allocated window after inflateReset()\n * - Remove bit fields--back to byte structure for speed\n * - Remove distance extra == 0 check in inflate_fast()--only helps for lengths\n * - Change post-increments to pre-increments in inflate_fast(), PPC biased?\n * - Add compile time option, POSTINC, to use post-increments instead (Intel?)\n * - Make MATCH copy in inflate() much faster for when inflate_fast() not used\n * - Use local copies of stream next and avail values, as well as local bit\n *   buffer and bit count in inflate()--for speed when inflate_fast() not used\n *\n * 1.2.beta4    1 Jan 2003\n * - Split ptr - 257 statements in inflate_table() to avoid compiler warnings\n * - Move a comment on output buffer sizes from inffast.c to inflate.c\n * - Add comments in inffast.c to introduce the inflate_fast() routine\n * - Rearrange window copies in inflate_fast() for speed and simplification\n * - Unroll last copy for window match in inflate_fast()\n * - Use local copies of window variables in inflate_fast() for speed\n * - Pull out common wnext == 0 case for speed in inflate_fast()\n * - Make op and len in inflate_fast() unsigned for consistency\n * - Add FAR to lcode and dcode declarations in inflate_fast()\n * - Simplified bad distance check in inflate_fast()\n * - Added inflateBackInit(), inflateBack(), and inflateBackEnd() in new\n *   source file infback.c to provide a call-back interface to inflate for\n *   programs like gzip and unzip -- uses window as output buffer to avoid\n *   window copying\n *\n * 1.2.beta5    1 Jan 2003\n * - Improved inflateBack() interface to allow the caller to provide initial\n *   input in strm.\n * - Fixed stored blocks bug in inflateBack()\n *\n * 1.2.beta6    4 Jan 2003\n * - Added comments in inffast.c on effectiveness of POSTINC\n * - Typecasting all around to reduce compiler warnings\n * - Changed loops from while (1) or do {} while (1) to for (;;), again to\n *   make compilers happy\n * - Changed type of window in inflateBackInit() to unsigned char *\n *\n * 1.2.beta7    27 Jan 2003\n * - Changed many types to unsigned or unsigned short to avoid warnings\n * - Added inflateCopy() function\n *\n * 1.2.0        9 Mar 2003\n * - Changed inflateBack() interface to provide separate opaque descriptors\n *   for the in() and out() functions\n * - Changed inflateBack() argument and in_func typedef to swap the length\n *   and buffer address return values for the input function\n * - Check next_in and next_out for Z_NULL on entry to inflate()\n *\n * The history for versions after 1.2.0 are in ChangeLog in zlib distribution.\n */\n\n#include \"zutil.h\"\n#include \"inftrees.h\"\n#include \"inflate.h\"\n#include \"inffast.h\"\n\n#ifdef MAKEFIXED\n#  ifndef BUILDFIXED\n#    define BUILDFIXED\n#  endif\n#endif\n\n/* function prototypes */\nlocal int inflateStateCheck OF((z_streamp strm));\nlocal void fixedtables OF((struct inflate_state FAR *state));\nlocal int updatewindow OF((z_streamp strm, const unsigned char FAR *end,\n                           unsigned copy));\n#ifdef BUILDFIXED\n   void makefixed OF((void));\n#endif\nlocal unsigned syncsearch OF((unsigned FAR *have, const unsigned char FAR *buf,\n                              unsigned len));\n\nlocal int inflateStateCheck(strm)\nz_streamp strm;\n{\n    struct inflate_state FAR *state;\n    if (strm == Z_NULL ||\n        strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0)\n        return 1;\n    state = (struct inflate_state FAR *)strm->state;\n    if (state == Z_NULL || state->strm != strm ||\n        state->mode < HEAD || state->mode > SYNC)\n        return 1;\n    return 0;\n}\n\nint ZEXPORT inflateResetKeep(strm)\nz_streamp strm;\n{\n    struct inflate_state FAR *state;\n\n    if (inflateStateCheck(strm)) return Z_STREAM_ERROR;\n    state = (struct inflate_state FAR *)strm->state;\n    strm->total_in = strm->total_out = state->total = 0;\n    strm->msg = Z_NULL;\n    if (state->wrap)        /* to support ill-conceived Java test suite */\n        strm->adler = state->wrap & 1;\n    state->mode = HEAD;\n    state->last = 0;\n    state->havedict = 0;\n    state->dmax = 32768U;\n    state->head = Z_NULL;\n    state->hold = 0;\n    state->bits = 0;\n    state->lencode = state->distcode = state->next = state->codes;\n    state->sane = 1;\n    state->back = -1;\n    Tracev((stderr, \"inflate: reset\\n\"));\n    return Z_OK;\n}\n\nint ZEXPORT inflateReset(strm)\nz_streamp strm;\n{\n    struct inflate_state FAR *state;\n\n    if (inflateStateCheck(strm)) return Z_STREAM_ERROR;\n    state = (struct inflate_state FAR *)strm->state;\n    state->wsize = 0;\n    state->whave = 0;\n    state->wnext = 0;\n    return inflateResetKeep(strm);\n}\n\nint ZEXPORT inflateReset2(strm, windowBits)\nz_streamp strm;\nint windowBits;\n{\n    int wrap;\n    struct inflate_state FAR *state;\n\n    /* get the state */\n    if (inflateStateCheck(strm)) return Z_STREAM_ERROR;\n    state = (struct inflate_state FAR *)strm->state;\n\n    /* extract wrap request from windowBits parameter */\n    if (windowBits < 0) {\n        wrap = 0;\n        windowBits = -windowBits;\n    }\n    else {\n        wrap = (windowBits >> 4) + 5;\n#ifdef GUNZIP\n        if (windowBits < 48)\n            windowBits &= 15;\n#endif\n    }\n\n    /* set number of window bits, free window if different */\n    if (windowBits && (windowBits < 8 || windowBits > 15))\n        return Z_STREAM_ERROR;\n    if (state->window != Z_NULL && state->wbits != (unsigned)windowBits) {\n        ZFREE(strm, state->window);\n        state->window = Z_NULL;\n    }\n\n    /* update state and reset the rest of it */\n    state->wrap = wrap;\n    state->wbits = (unsigned)windowBits;\n    return inflateReset(strm);\n}\n\nint ZEXPORT inflateInit2_(strm, windowBits, version, stream_size)\nz_streamp strm;\nint windowBits;\nconst char *version;\nint stream_size;\n{\n    int ret;\n    struct inflate_state FAR *state;\n\n    if (version == Z_NULL || version[0] != ZLIB_VERSION[0] ||\n        stream_size != (int)(sizeof(z_stream)))\n        return Z_VERSION_ERROR;\n    if (strm == Z_NULL) return Z_STREAM_ERROR;\n    strm->msg = Z_NULL;                 /* in case we return an error */\n    if (strm->zalloc == (alloc_func)0) {\n#ifdef Z_SOLO\n        return Z_STREAM_ERROR;\n#else\n        strm->zalloc = zcalloc;\n        strm->opaque = (voidpf)0;\n#endif\n    }\n    if (strm->zfree == (free_func)0)\n#ifdef Z_SOLO\n        return Z_STREAM_ERROR;\n#else\n        strm->zfree = zcfree;\n#endif\n    state = (struct inflate_state FAR *)\n            ZALLOC(strm, 1, sizeof(struct inflate_state));\n    if (state == Z_NULL) return Z_MEM_ERROR;\n    Tracev((stderr, \"inflate: allocated\\n\"));\n    strm->state = (struct internal_state FAR *)state;\n    state->strm = strm;\n    state->window = Z_NULL;\n    state->mode = HEAD;     /* to pass state test in inflateReset2() */\n    ret = inflateReset2(strm, windowBits);\n    if (ret != Z_OK) {\n        ZFREE(strm, state);\n        strm->state = Z_NULL;\n    }\n    return ret;\n}\n\nint ZEXPORT inflateInit_(strm, version, stream_size)\nz_streamp strm;\nconst char *version;\nint stream_size;\n{\n    return inflateInit2_(strm, DEF_WBITS, version, stream_size);\n}\n\nint ZEXPORT inflatePrime(strm, bits, value)\nz_streamp strm;\nint bits;\nint value;\n{\n    struct inflate_state FAR *state;\n\n    if (inflateStateCheck(strm)) return Z_STREAM_ERROR;\n    state = (struct inflate_state FAR *)strm->state;\n    if (bits < 0) {\n        state->hold = 0;\n        state->bits = 0;\n        return Z_OK;\n    }\n    if (bits > 16 || state->bits + (uInt)bits > 32) return Z_STREAM_ERROR;\n    value &= (1L << bits) - 1;\n    state->hold += (unsigned)value << state->bits;\n    state->bits += (uInt)bits;\n    return Z_OK;\n}\n\n/*\n   Return state with length and distance decoding tables and index sizes set to\n   fixed code decoding.  Normally this returns fixed tables from inffixed.h.\n   If BUILDFIXED is defined, then instead this routine builds the tables the\n   first time it's called, and returns those tables the first time and\n   thereafter.  This reduces the size of the code by about 2K bytes, in\n   exchange for a little execution time.  However, BUILDFIXED should not be\n   used for threaded applications, since the rewriting of the tables and virgin\n   may not be thread-safe.\n */\nlocal void fixedtables(state)\nstruct inflate_state FAR *state;\n{\n#ifdef BUILDFIXED\n    static int virgin = 1;\n    static code *lenfix, *distfix;\n    static code fixed[544];\n\n    /* build fixed huffman tables if first call (may not be thread safe) */\n    if (virgin) {\n        unsigned sym, bits;\n        static code *next;\n\n        /* literal/length table */\n        sym = 0;\n        while (sym < 144) state->lens[sym++] = 8;\n        while (sym < 256) state->lens[sym++] = 9;\n        while (sym < 280) state->lens[sym++] = 7;\n        while (sym < 288) state->lens[sym++] = 8;\n        next = fixed;\n        lenfix = next;\n        bits = 9;\n        inflate_table(LENS, state->lens, 288, &(next), &(bits), state->work);\n\n        /* distance table */\n        sym = 0;\n        while (sym < 32) state->lens[sym++] = 5;\n        distfix = next;\n        bits = 5;\n        inflate_table(DISTS, state->lens, 32, &(next), &(bits), state->work);\n\n        /* do this just once */\n        virgin = 0;\n    }\n#else /* !BUILDFIXED */\n#   include \"inffixed.h\"\n#endif /* BUILDFIXED */\n    state->lencode = lenfix;\n    state->lenbits = 9;\n    state->distcode = distfix;\n    state->distbits = 5;\n}\n\n#ifdef MAKEFIXED\n#include <stdio.h>\n\n/*\n   Write out the inffixed.h that is #include'd above.  Defining MAKEFIXED also\n   defines BUILDFIXED, so the tables are built on the fly.  makefixed() writes\n   those tables to stdout, which would be piped to inffixed.h.  A small program\n   can simply call makefixed to do this:\n\n    void makefixed(void);\n\n    int main(void)\n    {\n        makefixed();\n        return 0;\n    }\n\n   Then that can be linked with zlib built with MAKEFIXED defined and run:\n\n    a.out > inffixed.h\n */\nvoid makefixed()\n{\n    unsigned low, size;\n    struct inflate_state state;\n\n    fixedtables(&state);\n    puts(\"    /* inffixed.h -- table for decoding fixed codes\");\n    puts(\"     * Generated automatically by makefixed().\");\n    puts(\"     */\");\n    puts(\"\");\n    puts(\"    /* WARNING: this file should *not* be used by applications.\");\n    puts(\"       It is part of the implementation of this library and is\");\n    puts(\"       subject to change. Applications should only use zlib.h.\");\n    puts(\"     */\");\n    puts(\"\");\n    size = 1U << 9;\n    printf(\"    static const code lenfix[%u] = {\", size);\n    low = 0;\n    for (;;) {\n        if ((low % 7) == 0) printf(\"\\n        \");\n        printf(\"{%u,%u,%d}\", (low & 127) == 99 ? 64 : state.lencode[low].op,\n               state.lencode[low].bits, state.lencode[low].val);\n        if (++low == size) break;\n        putchar(',');\n    }\n    puts(\"\\n    };\");\n    size = 1U << 5;\n    printf(\"\\n    static const code distfix[%u] = {\", size);\n    low = 0;\n    for (;;) {\n        if ((low % 6) == 0) printf(\"\\n        \");\n        printf(\"{%u,%u,%d}\", state.distcode[low].op, state.distcode[low].bits,\n               state.distcode[low].val);\n        if (++low == size) break;\n        putchar(',');\n    }\n    puts(\"\\n    };\");\n}\n#endif /* MAKEFIXED */\n\n/*\n   Update the window with the last wsize (normally 32K) bytes written before\n   returning.  If window does not exist yet, create it.  This is only called\n   when a window is already in use, or when output has been written during this\n   inflate call, but the end of the deflate stream has not been reached yet.\n   It is also called to create a window for dictionary data when a dictionary\n   is loaded.\n\n   Providing output buffers larger than 32K to inflate() should provide a speed\n   advantage, since only the last 32K of output is copied to the sliding window\n   upon return from inflate(), and since all distances after the first 32K of\n   output will fall in the output data, making match copies simpler and faster.\n   The advantage may be dependent on the size of the processor's data caches.\n */\nlocal int updatewindow(strm, end, copy)\nz_streamp strm;\nconst Bytef *end;\nunsigned copy;\n{\n    struct inflate_state FAR *state;\n    unsigned dist;\n\n    state = (struct inflate_state FAR *)strm->state;\n\n    /* if it hasn't been done already, allocate space for the window */\n    if (state->window == Z_NULL) {\n        state->window = (unsigned char FAR *)\n                        ZALLOC(strm, 1U << state->wbits,\n                               sizeof(unsigned char));\n        if (state->window == Z_NULL) return 1;\n    }\n\n    /* if window not in use yet, initialize */\n    if (state->wsize == 0) {\n        state->wsize = 1U << state->wbits;\n        state->wnext = 0;\n        state->whave = 0;\n    }\n\n    /* copy state->wsize or less output bytes into the circular window */\n    if (copy >= state->wsize) {\n        zmemcpy(state->window, end - state->wsize, state->wsize);\n        state->wnext = 0;\n        state->whave = state->wsize;\n    }\n    else {\n        dist = state->wsize - state->wnext;\n        if (dist > copy) dist = copy;\n        zmemcpy(state->window + state->wnext, end - copy, dist);\n        copy -= dist;\n        if (copy) {\n            zmemcpy(state->window, end - copy, copy);\n            state->wnext = copy;\n            state->whave = state->wsize;\n        }\n        else {\n            state->wnext += dist;\n            if (state->wnext == state->wsize) state->wnext = 0;\n            if (state->whave < state->wsize) state->whave += dist;\n        }\n    }\n    return 0;\n}\n\n/* Macros for inflate(): */\n\n/* check function to use adler32() for zlib or crc32() for gzip */\n#ifdef GUNZIP\n#  define UPDATE(check, buf, len) \\\n    (state->flags ? crc32(check, buf, len) : adler32(check, buf, len))\n#else\n#  define UPDATE(check, buf, len) adler32(check, buf, len)\n#endif\n\n/* check macros for header crc */\n#ifdef GUNZIP\n#  define CRC2(check, word) \\\n    do { \\\n        hbuf[0] = (unsigned char)(word); \\\n        hbuf[1] = (unsigned char)((word) >> 8); \\\n        check = crc32(check, hbuf, 2); \\\n    } while (0)\n\n#  define CRC4(check, word) \\\n    do { \\\n        hbuf[0] = (unsigned char)(word); \\\n        hbuf[1] = (unsigned char)((word) >> 8); \\\n        hbuf[2] = (unsigned char)((word) >> 16); \\\n        hbuf[3] = (unsigned char)((word) >> 24); \\\n        check = crc32(check, hbuf, 4); \\\n    } while (0)\n#endif\n\n/* Load registers with state in inflate() for speed */\n#define LOAD() \\\n    do { \\\n        put = strm->next_out; \\\n        left = strm->avail_out; \\\n        next = strm->next_in; \\\n        have = strm->avail_in; \\\n        hold = state->hold; \\\n        bits = state->bits; \\\n    } while (0)\n\n/* Restore state from registers in inflate() */\n#define RESTORE() \\\n    do { \\\n        strm->next_out = put; \\\n        strm->avail_out = left; \\\n        strm->next_in = next; \\\n        strm->avail_in = have; \\\n        state->hold = hold; \\\n        state->bits = bits; \\\n    } while (0)\n\n/* Clear the input bit accumulator */\n#define INITBITS() \\\n    do { \\\n        hold = 0; \\\n        bits = 0; \\\n    } while (0)\n\n/* Get a byte of input into the bit accumulator, or return from inflate()\n   if there is no input available. */\n#define PULLBYTE() \\\n    do { \\\n        if (have == 0) goto inf_leave; \\\n        have--; \\\n        hold += (unsigned long)(*next++) << bits; \\\n        bits += 8; \\\n    } while (0)\n\n/* Assure that there are at least n bits in the bit accumulator.  If there is\n   not enough available input to do that, then return from inflate(). */\n#define NEEDBITS(n) \\\n    do { \\\n        while (bits < (unsigned)(n)) \\\n            PULLBYTE(); \\\n    } while (0)\n\n/* Return the low n bits of the bit accumulator (n < 16) */\n#define BITS(n) \\\n    ((unsigned)hold & ((1U << (n)) - 1))\n\n/* Remove n bits from the bit accumulator */\n#define DROPBITS(n) \\\n    do { \\\n        hold >>= (n); \\\n        bits -= (unsigned)(n); \\\n    } while (0)\n\n/* Remove zero to seven bits as needed to go to a byte boundary */\n#define BYTEBITS() \\\n    do { \\\n        hold >>= bits & 7; \\\n        bits -= bits & 7; \\\n    } while (0)\n\n/*\n   inflate() uses a state machine to process as much input data and generate as\n   much output data as possible before returning.  The state machine is\n   structured roughly as follows:\n\n    for (;;) switch (state) {\n    ...\n    case STATEn:\n        if (not enough input data or output space to make progress)\n            return;\n        ... make progress ...\n        state = STATEm;\n        break;\n    ...\n    }\n\n   so when inflate() is called again, the same case is attempted again, and\n   if the appropriate resources are provided, the machine proceeds to the\n   next state.  The NEEDBITS() macro is usually the way the state evaluates\n   whether it can proceed or should return.  NEEDBITS() does the return if\n   the requested bits are not available.  The typical use of the BITS macros\n   is:\n\n        NEEDBITS(n);\n        ... do something with BITS(n) ...\n        DROPBITS(n);\n\n   where NEEDBITS(n) either returns from inflate() if there isn't enough\n   input left to load n bits into the accumulator, or it continues.  BITS(n)\n   gives the low n bits in the accumulator.  When done, DROPBITS(n) drops\n   the low n bits off the accumulator.  INITBITS() clears the accumulator\n   and sets the number of available bits to zero.  BYTEBITS() discards just\n   enough bits to put the accumulator on a byte boundary.  After BYTEBITS()\n   and a NEEDBITS(8), then BITS(8) would return the next byte in the stream.\n\n   NEEDBITS(n) uses PULLBYTE() to get an available byte of input, or to return\n   if there is no input available.  The decoding of variable length codes uses\n   PULLBYTE() directly in order to pull just enough bytes to decode the next\n   code, and no more.\n\n   Some states loop until they get enough input, making sure that enough\n   state information is maintained to continue the loop where it left off\n   if NEEDBITS() returns in the loop.  For example, want, need, and keep\n   would all have to actually be part of the saved state in case NEEDBITS()\n   returns:\n\n    case STATEw:\n        while (want < need) {\n            NEEDBITS(n);\n            keep[want++] = BITS(n);\n            DROPBITS(n);\n        }\n        state = STATEx;\n    case STATEx:\n\n   As shown above, if the next state is also the next case, then the break\n   is omitted.\n\n   A state may also return if there is not enough output space available to\n   complete that state.  Those states are copying stored data, writing a\n   literal byte, and copying a matching string.\n\n   When returning, a \"goto inf_leave\" is used to update the total counters,\n   update the check value, and determine whether any progress has been made\n   during that inflate() call in order to return the proper return code.\n   Progress is defined as a change in either strm->avail_in or strm->avail_out.\n   When there is a window, goto inf_leave will update the window with the last\n   output written.  If a goto inf_leave occurs in the middle of decompression\n   and there is no window currently, goto inf_leave will create one and copy\n   output to the window for the next call of inflate().\n\n   In this implementation, the flush parameter of inflate() only affects the\n   return code (per zlib.h).  inflate() always writes as much as possible to\n   strm->next_out, given the space available and the provided input--the effect\n   documented in zlib.h of Z_SYNC_FLUSH.  Furthermore, inflate() always defers\n   the allocation of and copying into a sliding window until necessary, which\n   provides the effect documented in zlib.h for Z_FINISH when the entire input\n   stream available.  So the only thing the flush parameter actually does is:\n   when flush is set to Z_FINISH, inflate() cannot return Z_OK.  Instead it\n   will return Z_BUF_ERROR if it has not reached the end of the stream.\n */\n\nint ZEXPORT inflate(strm, flush)\nz_streamp strm;\nint flush;\n{\n    struct inflate_state FAR *state;\n    z_const unsigned char FAR *next;    /* next input */\n    unsigned char FAR *put;     /* next output */\n    unsigned have, left;        /* available input and output */\n    unsigned long hold;         /* bit buffer */\n    unsigned bits;              /* bits in bit buffer */\n    unsigned in, out;           /* save starting available input and output */\n    unsigned copy;              /* number of stored or match bytes to copy */\n    unsigned char FAR *from;    /* where to copy match bytes from */\n    code here;                  /* current decoding table entry */\n    code last;                  /* parent table entry */\n    unsigned len;               /* length to copy for repeats, bits to drop */\n    int ret;                    /* return code */\n#ifdef GUNZIP\n    unsigned char hbuf[4];      /* buffer for gzip header crc calculation */\n#endif\n    static const unsigned short order[19] = /* permutation of code lengths */\n        {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};\n\n    if (inflateStateCheck(strm) || strm->next_out == Z_NULL ||\n        (strm->next_in == Z_NULL && strm->avail_in != 0))\n        return Z_STREAM_ERROR;\n\n    state = (struct inflate_state FAR *)strm->state;\n    if (state->mode == TYPE) state->mode = TYPEDO;      /* skip check */\n    LOAD();\n    in = have;\n    out = left;\n    ret = Z_OK;\n    for (;;)\n        switch (state->mode) {\n        case HEAD:\n            if (state->wrap == 0) {\n                state->mode = TYPEDO;\n                break;\n            }\n            NEEDBITS(16);\n#ifdef GUNZIP\n            if ((state->wrap & 2) && hold == 0x8b1f) {  /* gzip header */\n                if (state->wbits == 0)\n                    state->wbits = 15;\n                state->check = crc32(0L, Z_NULL, 0);\n                CRC2(state->check, hold);\n                INITBITS();\n                state->mode = FLAGS;\n                break;\n            }\n            state->flags = 0;           /* expect zlib header */\n            if (state->head != Z_NULL)\n                state->head->done = -1;\n            if (!(state->wrap & 1) ||   /* check if zlib header allowed */\n#else\n            if (\n#endif\n                ((BITS(8) << 8) + (hold >> 8)) % 31) {\n                strm->msg = (char *)\"incorrect header check\";\n                state->mode = BAD;\n                break;\n            }\n            if (BITS(4) != Z_DEFLATED) {\n                strm->msg = (char *)\"unknown compression method\";\n                state->mode = BAD;\n                break;\n            }\n            DROPBITS(4);\n            len = BITS(4) + 8;\n            if (state->wbits == 0)\n                state->wbits = len;\n            if (len > 15 || len > state->wbits) {\n                strm->msg = (char *)\"invalid window size\";\n                state->mode = BAD;\n                break;\n            }\n            state->dmax = 1U << len;\n            Tracev((stderr, \"inflate:   zlib header ok\\n\"));\n            strm->adler = state->check = adler32(0L, Z_NULL, 0);\n            state->mode = hold & 0x200 ? DICTID : TYPE;\n            INITBITS();\n            break;\n#ifdef GUNZIP\n        case FLAGS:\n            NEEDBITS(16);\n            state->flags = (int)(hold);\n            if ((state->flags & 0xff) != Z_DEFLATED) {\n                strm->msg = (char *)\"unknown compression method\";\n                state->mode = BAD;\n                break;\n            }\n            if (state->flags & 0xe000) {\n                strm->msg = (char *)\"unknown header flags set\";\n                state->mode = BAD;\n                break;\n            }\n            if (state->head != Z_NULL)\n                state->head->text = (int)((hold >> 8) & 1);\n            if ((state->flags & 0x0200) && (state->wrap & 4))\n                CRC2(state->check, hold);\n            INITBITS();\n            state->mode = TIME;\n        case TIME:\n            NEEDBITS(32);\n            if (state->head != Z_NULL)\n                state->head->time = hold;\n            if ((state->flags & 0x0200) && (state->wrap & 4))\n                CRC4(state->check, hold);\n            INITBITS();\n            state->mode = OS;\n        case OS:\n            NEEDBITS(16);\n            if (state->head != Z_NULL) {\n                state->head->xflags = (int)(hold & 0xff);\n                state->head->os = (int)(hold >> 8);\n            }\n            if ((state->flags & 0x0200) && (state->wrap & 4))\n                CRC2(state->check, hold);\n            INITBITS();\n            state->mode = EXLEN;\n        case EXLEN:\n            if (state->flags & 0x0400) {\n                NEEDBITS(16);\n                state->length = (unsigned)(hold);\n                if (state->head != Z_NULL)\n                    state->head->extra_len = (unsigned)hold;\n                if ((state->flags & 0x0200) && (state->wrap & 4))\n                    CRC2(state->check, hold);\n                INITBITS();\n            }\n            else if (state->head != Z_NULL)\n                state->head->extra = Z_NULL;\n            state->mode = EXTRA;\n        case EXTRA:\n            if (state->flags & 0x0400) {\n                copy = state->length;\n                if (copy > have) copy = have;\n                if (copy) {\n                    if (state->head != Z_NULL &&\n                        state->head->extra != Z_NULL) {\n                        len = state->head->extra_len - state->length;\n                        zmemcpy(state->head->extra + len, next,\n                                len + copy > state->head->extra_max ?\n                                state->head->extra_max - len : copy);\n                    }\n                    if ((state->flags & 0x0200) && (state->wrap & 4))\n                        state->check = crc32(state->check, next, copy);\n                    have -= copy;\n                    next += copy;\n                    state->length -= copy;\n                }\n                if (state->length) goto inf_leave;\n            }\n            state->length = 0;\n            state->mode = NAME;\n        case NAME:\n            if (state->flags & 0x0800) {\n                if (have == 0) goto inf_leave;\n                copy = 0;\n                do {\n                    len = (unsigned)(next[copy++]);\n                    if (state->head != Z_NULL &&\n                            state->head->name != Z_NULL &&\n                            state->length < state->head->name_max)\n                        state->head->name[state->length++] = (Bytef)len;\n                } while (len && copy < have);\n                if ((state->flags & 0x0200) && (state->wrap & 4))\n                    state->check = crc32(state->check, next, copy);\n                have -= copy;\n                next += copy;\n                if (len) goto inf_leave;\n            }\n            else if (state->head != Z_NULL)\n                state->head->name = Z_NULL;\n            state->length = 0;\n            state->mode = COMMENT;\n        case COMMENT:\n            if (state->flags & 0x1000) {\n                if (have == 0) goto inf_leave;\n                copy = 0;\n                do {\n                    len = (unsigned)(next[copy++]);\n                    if (state->head != Z_NULL &&\n                            state->head->comment != Z_NULL &&\n                            state->length < state->head->comm_max)\n                        state->head->comment[state->length++] = (Bytef)len;\n                } while (len && copy < have);\n                if ((state->flags & 0x0200) && (state->wrap & 4))\n                    state->check = crc32(state->check, next, copy);\n                have -= copy;\n                next += copy;\n                if (len) goto inf_leave;\n            }\n            else if (state->head != Z_NULL)\n                state->head->comment = Z_NULL;\n            state->mode = HCRC;\n        case HCRC:\n            if (state->flags & 0x0200) {\n                NEEDBITS(16);\n                if ((state->wrap & 4) && hold != (state->check & 0xffff)) {\n                    strm->msg = (char *)\"header crc mismatch\";\n                    state->mode = BAD;\n                    break;\n                }\n                INITBITS();\n            }\n            if (state->head != Z_NULL) {\n                state->head->hcrc = (int)((state->flags >> 9) & 1);\n                state->head->done = 1;\n            }\n            strm->adler = state->check = crc32(0L, Z_NULL, 0);\n            state->mode = TYPE;\n            break;\n#endif\n        case DICTID:\n            NEEDBITS(32);\n            strm->adler = state->check = ZSWAP32(hold);\n            INITBITS();\n            state->mode = DICT;\n        case DICT:\n            if (state->havedict == 0) {\n                RESTORE();\n                return Z_NEED_DICT;\n            }\n            strm->adler = state->check = adler32(0L, Z_NULL, 0);\n            state->mode = TYPE;\n        case TYPE:\n            if (flush == Z_BLOCK || flush == Z_TREES) goto inf_leave;\n        case TYPEDO:\n            if (state->last) {\n                BYTEBITS();\n                state->mode = CHECK;\n                break;\n            }\n            NEEDBITS(3);\n            state->last = BITS(1);\n            DROPBITS(1);\n            switch (BITS(2)) {\n            case 0:                             /* stored block */\n                Tracev((stderr, \"inflate:     stored block%s\\n\",\n                        state->last ? \" (last)\" : \"\"));\n                state->mode = STORED;\n                break;\n            case 1:                             /* fixed block */\n                fixedtables(state);\n                Tracev((stderr, \"inflate:     fixed codes block%s\\n\",\n                        state->last ? \" (last)\" : \"\"));\n                state->mode = LEN_;             /* decode codes */\n                if (flush == Z_TREES) {\n                    DROPBITS(2);\n                    goto inf_leave;\n                }\n                break;\n            case 2:                             /* dynamic block */\n                Tracev((stderr, \"inflate:     dynamic codes block%s\\n\",\n                        state->last ? \" (last)\" : \"\"));\n                state->mode = TABLE;\n                break;\n            case 3:\n                strm->msg = (char *)\"invalid block type\";\n                state->mode = BAD;\n            }\n            DROPBITS(2);\n            break;\n        case STORED:\n            BYTEBITS();                         /* go to byte boundary */\n            NEEDBITS(32);\n            if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) {\n                strm->msg = (char *)\"invalid stored block lengths\";\n                state->mode = BAD;\n                break;\n            }\n            state->length = (unsigned)hold & 0xffff;\n            Tracev((stderr, \"inflate:       stored length %u\\n\",\n                    state->length));\n            INITBITS();\n            state->mode = COPY_;\n            if (flush == Z_TREES) goto inf_leave;\n        case COPY_:\n            state->mode = COPY;\n        case COPY:\n            copy = state->length;\n            if (copy) {\n                if (copy > have) copy = have;\n                if (copy > left) copy = left;\n                if (copy == 0) goto inf_leave;\n                zmemcpy(put, next, copy);\n                have -= copy;\n                next += copy;\n                left -= copy;\n                put += copy;\n                state->length -= copy;\n                break;\n            }\n            Tracev((stderr, \"inflate:       stored end\\n\"));\n            state->mode = TYPE;\n            break;\n        case TABLE:\n            NEEDBITS(14);\n            state->nlen = BITS(5) + 257;\n            DROPBITS(5);\n            state->ndist = BITS(5) + 1;\n            DROPBITS(5);\n            state->ncode = BITS(4) + 4;\n            DROPBITS(4);\n#ifndef PKZIP_BUG_WORKAROUND\n            if (state->nlen > 286 || state->ndist > 30) {\n                strm->msg = (char *)\"too many length or distance symbols\";\n                state->mode = BAD;\n                break;\n            }\n#endif\n            Tracev((stderr, \"inflate:       table sizes ok\\n\"));\n            state->have = 0;\n            state->mode = LENLENS;\n        case LENLENS:\n            while (state->have < state->ncode) {\n                NEEDBITS(3);\n                state->lens[order[state->have++]] = (unsigned short)BITS(3);\n                DROPBITS(3);\n            }\n            while (state->have < 19)\n                state->lens[order[state->have++]] = 0;\n            state->next = state->codes;\n            state->lencode = (const code FAR *)(state->next);\n            state->lenbits = 7;\n            ret = inflate_table(CODES, state->lens, 19, &(state->next),\n                                &(state->lenbits), state->work);\n            if (ret) {\n                strm->msg = (char *)\"invalid code lengths set\";\n                state->mode = BAD;\n                break;\n            }\n            Tracev((stderr, \"inflate:       code lengths ok\\n\"));\n            state->have = 0;\n            state->mode = CODELENS;\n        case CODELENS:\n            while (state->have < state->nlen + state->ndist) {\n                for (;;) {\n                    here = state->lencode[BITS(state->lenbits)];\n                    if ((unsigned)(here.bits) <= bits) break;\n                    PULLBYTE();\n                }\n                if (here.val < 16) {\n                    DROPBITS(here.bits);\n                    state->lens[state->have++] = here.val;\n                }\n                else {\n                    if (here.val == 16) {\n                        NEEDBITS(here.bits + 2);\n                        DROPBITS(here.bits);\n                        if (state->have == 0) {\n                            strm->msg = (char *)\"invalid bit length repeat\";\n                            state->mode = BAD;\n                            break;\n                        }\n                        len = state->lens[state->have - 1];\n                        copy = 3 + BITS(2);\n                        DROPBITS(2);\n                    }\n                    else if (here.val == 17) {\n                        NEEDBITS(here.bits + 3);\n                        DROPBITS(here.bits);\n                        len = 0;\n                        copy = 3 + BITS(3);\n                        DROPBITS(3);\n                    }\n                    else {\n                        NEEDBITS(here.bits + 7);\n                        DROPBITS(here.bits);\n                        len = 0;\n                        copy = 11 + BITS(7);\n                        DROPBITS(7);\n                    }\n                    if (state->have + copy > state->nlen + state->ndist) {\n                        strm->msg = (char *)\"invalid bit length repeat\";\n                        state->mode = BAD;\n                        break;\n                    }\n                    while (copy--)\n                        state->lens[state->have++] = (unsigned short)len;\n                }\n            }\n\n            /* handle error breaks in while */\n            if (state->mode == BAD) break;\n\n            /* check for end-of-block code (better have one) */\n            if (state->lens[256] == 0) {\n                strm->msg = (char *)\"invalid code -- missing end-of-block\";\n                state->mode = BAD;\n                break;\n            }\n\n            /* build code tables -- note: do not change the lenbits or distbits\n               values here (9 and 6) without reading the comments in inftrees.h\n               concerning the ENOUGH constants, which depend on those values */\n            state->next = state->codes;\n            state->lencode = (const code FAR *)(state->next);\n            state->lenbits = 9;\n            ret = inflate_table(LENS, state->lens, state->nlen, &(state->next),\n                                &(state->lenbits), state->work);\n            if (ret) {\n                strm->msg = (char *)\"invalid literal/lengths set\";\n                state->mode = BAD;\n                break;\n            }\n            state->distcode = (const code FAR *)(state->next);\n            state->distbits = 6;\n            ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist,\n                            &(state->next), &(state->distbits), state->work);\n            if (ret) {\n                strm->msg = (char *)\"invalid distances set\";\n                state->mode = BAD;\n                break;\n            }\n            Tracev((stderr, \"inflate:       codes ok\\n\"));\n            state->mode = LEN_;\n            if (flush == Z_TREES) goto inf_leave;\n        case LEN_:\n            state->mode = LEN;\n        case LEN:\n            if (have >= 6 && left >= 258) {\n                RESTORE();\n                inflate_fast(strm, out);\n                LOAD();\n                if (state->mode == TYPE)\n                    state->back = -1;\n                break;\n            }\n            state->back = 0;\n            for (;;) {\n                here = state->lencode[BITS(state->lenbits)];\n                if ((unsigned)(here.bits) <= bits) break;\n                PULLBYTE();\n            }\n            if (here.op && (here.op & 0xf0) == 0) {\n                last = here;\n                for (;;) {\n                    here = state->lencode[last.val +\n                            (BITS(last.bits + last.op) >> last.bits)];\n                    if ((unsigned)(last.bits + here.bits) <= bits) break;\n                    PULLBYTE();\n                }\n                DROPBITS(last.bits);\n                state->back += last.bits;\n            }\n            DROPBITS(here.bits);\n            state->back += here.bits;\n            state->length = (unsigned)here.val;\n            if ((int)(here.op) == 0) {\n                Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?\n                        \"inflate:         literal '%c'\\n\" :\n                        \"inflate:         literal 0x%02x\\n\", here.val));\n                state->mode = LIT;\n                break;\n            }\n            if (here.op & 32) {\n                Tracevv((stderr, \"inflate:         end of block\\n\"));\n                state->back = -1;\n                state->mode = TYPE;\n                break;\n            }\n            if (here.op & 64) {\n                strm->msg = (char *)\"invalid literal/length code\";\n                state->mode = BAD;\n                break;\n            }\n            state->extra = (unsigned)(here.op) & 15;\n            state->mode = LENEXT;\n        case LENEXT:\n            if (state->extra) {\n                NEEDBITS(state->extra);\n                state->length += BITS(state->extra);\n                DROPBITS(state->extra);\n                state->back += state->extra;\n            }\n            Tracevv((stderr, \"inflate:         length %u\\n\", state->length));\n            state->was = state->length;\n            state->mode = DIST;\n        case DIST:\n            for (;;) {\n                here = state->distcode[BITS(state->distbits)];\n                if ((unsigned)(here.bits) <= bits) break;\n                PULLBYTE();\n            }\n            if ((here.op & 0xf0) == 0) {\n                last = here;\n                for (;;) {\n                    here = state->distcode[last.val +\n                            (BITS(last.bits + last.op) >> last.bits)];\n                    if ((unsigned)(last.bits + here.bits) <= bits) break;\n                    PULLBYTE();\n                }\n                DROPBITS(last.bits);\n                state->back += last.bits;\n            }\n            DROPBITS(here.bits);\n            state->back += here.bits;\n            if (here.op & 64) {\n                strm->msg = (char *)\"invalid distance code\";\n                state->mode = BAD;\n                break;\n            }\n            state->offset = (unsigned)here.val;\n            state->extra = (unsigned)(here.op) & 15;\n            state->mode = DISTEXT;\n        case DISTEXT:\n            if (state->extra) {\n                NEEDBITS(state->extra);\n                state->offset += BITS(state->extra);\n                DROPBITS(state->extra);\n                state->back += state->extra;\n            }\n#ifdef INFLATE_STRICT\n            if (state->offset > state->dmax) {\n                strm->msg = (char *)\"invalid distance too far back\";\n                state->mode = BAD;\n                break;\n            }\n#endif\n            Tracevv((stderr, \"inflate:         distance %u\\n\", state->offset));\n            state->mode = MATCH;\n        case MATCH:\n            if (left == 0) goto inf_leave;\n            copy = out - left;\n            if (state->offset > copy) {         /* copy from window */\n                copy = state->offset - copy;\n                if (copy > state->whave) {\n                    if (state->sane) {\n                        strm->msg = (char *)\"invalid distance too far back\";\n                        state->mode = BAD;\n                        break;\n                    }\n#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR\n                    Trace((stderr, \"inflate.c too far\\n\"));\n                    copy -= state->whave;\n                    if (copy > state->length) copy = state->length;\n                    if (copy > left) copy = left;\n                    left -= copy;\n                    state->length -= copy;\n                    do {\n                        *put++ = 0;\n                    } while (--copy);\n                    if (state->length == 0) state->mode = LEN;\n                    break;\n#endif\n                }\n                if (copy > state->wnext) {\n                    copy -= state->wnext;\n                    from = state->window + (state->wsize - copy);\n                }\n                else\n                    from = state->window + (state->wnext - copy);\n                if (copy > state->length) copy = state->length;\n            }\n            else {                              /* copy from output */\n                from = put - state->offset;\n                copy = state->length;\n            }\n            if (copy > left) copy = left;\n            left -= copy;\n            state->length -= copy;\n            do {\n                *put++ = *from++;\n            } while (--copy);\n            if (state->length == 0) state->mode = LEN;\n            break;\n        case LIT:\n            if (left == 0) goto inf_leave;\n            *put++ = (unsigned char)(state->length);\n            left--;\n            state->mode = LEN;\n            break;\n        case CHECK:\n            if (state->wrap) {\n                NEEDBITS(32);\n                out -= left;\n                strm->total_out += out;\n                state->total += out;\n                if ((state->wrap & 4) && out)\n                    strm->adler = state->check =\n                        UPDATE(state->check, put - out, out);\n                out = left;\n                if ((state->wrap & 4) && (\n#ifdef GUNZIP\n                     state->flags ? hold :\n#endif\n                     ZSWAP32(hold)) != state->check) {\n                    strm->msg = (char *)\"incorrect data check\";\n                    state->mode = BAD;\n                    break;\n                }\n                INITBITS();\n                Tracev((stderr, \"inflate:   check matches trailer\\n\"));\n            }\n#ifdef GUNZIP\n            state->mode = LENGTH;\n        case LENGTH:\n            if (state->wrap && state->flags) {\n                NEEDBITS(32);\n                if (hold != (state->total & 0xffffffffUL)) {\n                    strm->msg = (char *)\"incorrect length check\";\n                    state->mode = BAD;\n                    break;\n                }\n                INITBITS();\n                Tracev((stderr, \"inflate:   length matches trailer\\n\"));\n            }\n#endif\n            state->mode = DONE;\n        case DONE:\n            ret = Z_STREAM_END;\n            goto inf_leave;\n        case BAD:\n            ret = Z_DATA_ERROR;\n            goto inf_leave;\n        case MEM:\n            return Z_MEM_ERROR;\n        case SYNC:\n        default:\n            return Z_STREAM_ERROR;\n        }\n\n    /*\n       Return from inflate(), updating the total counts and the check value.\n       If there was no progress during the inflate() call, return a buffer\n       error.  Call updatewindow() to create and/or update the window state.\n       Note: a memory error from inflate() is non-recoverable.\n     */\n  inf_leave:\n    RESTORE();\n    if (state->wsize || (out != strm->avail_out && state->mode < BAD &&\n            (state->mode < CHECK || flush != Z_FINISH)))\n        if (updatewindow(strm, strm->next_out, out - strm->avail_out)) {\n            state->mode = MEM;\n            return Z_MEM_ERROR;\n        }\n    in -= strm->avail_in;\n    out -= strm->avail_out;\n    strm->total_in += in;\n    strm->total_out += out;\n    state->total += out;\n    if ((state->wrap & 4) && out)\n        strm->adler = state->check =\n            UPDATE(state->check, strm->next_out - out, out);\n    strm->data_type = (int)state->bits + (state->last ? 64 : 0) +\n                      (state->mode == TYPE ? 128 : 0) +\n                      (state->mode == LEN_ || state->mode == COPY_ ? 256 : 0);\n    if (((in == 0 && out == 0) || flush == Z_FINISH) && ret == Z_OK)\n        ret = Z_BUF_ERROR;\n    return ret;\n}\n\nint ZEXPORT inflateEnd(strm)\nz_streamp strm;\n{\n    struct inflate_state FAR *state;\n    if (inflateStateCheck(strm))\n        return Z_STREAM_ERROR;\n    state = (struct inflate_state FAR *)strm->state;\n    if (state->window != Z_NULL) ZFREE(strm, state->window);\n    ZFREE(strm, strm->state);\n    strm->state = Z_NULL;\n    Tracev((stderr, \"inflate: end\\n\"));\n    return Z_OK;\n}\n\nint ZEXPORT inflateGetDictionary(strm, dictionary, dictLength)\nz_streamp strm;\nBytef *dictionary;\nuInt *dictLength;\n{\n    struct inflate_state FAR *state;\n\n    /* check state */\n    if (inflateStateCheck(strm)) return Z_STREAM_ERROR;\n    state = (struct inflate_state FAR *)strm->state;\n\n    /* copy dictionary */\n    if (state->whave && dictionary != Z_NULL) {\n        zmemcpy(dictionary, state->window + state->wnext,\n                state->whave - state->wnext);\n        zmemcpy(dictionary + state->whave - state->wnext,\n                state->window, state->wnext);\n    }\n    if (dictLength != Z_NULL)\n        *dictLength = state->whave;\n    return Z_OK;\n}\n\nint ZEXPORT inflateSetDictionary(strm, dictionary, dictLength)\nz_streamp strm;\nconst Bytef *dictionary;\nuInt dictLength;\n{\n    struct inflate_state FAR *state;\n    unsigned long dictid;\n    int ret;\n\n    /* check state */\n    if (inflateStateCheck(strm)) return Z_STREAM_ERROR;\n    state = (struct inflate_state FAR *)strm->state;\n    if (state->wrap != 0 && state->mode != DICT)\n        return Z_STREAM_ERROR;\n\n    /* check for correct dictionary identifier */\n    if (state->mode == DICT) {\n        dictid = adler32(0L, Z_NULL, 0);\n        dictid = adler32(dictid, dictionary, dictLength);\n        if (dictid != state->check)\n            return Z_DATA_ERROR;\n    }\n\n    /* copy dictionary to window using updatewindow(), which will amend the\n       existing dictionary if appropriate */\n    ret = updatewindow(strm, dictionary + dictLength, dictLength);\n    if (ret) {\n        state->mode = MEM;\n        return Z_MEM_ERROR;\n    }\n    state->havedict = 1;\n    Tracev((stderr, \"inflate:   dictionary set\\n\"));\n    return Z_OK;\n}\n\nint ZEXPORT inflateGetHeader(strm, head)\nz_streamp strm;\ngz_headerp head;\n{\n    struct inflate_state FAR *state;\n\n    /* check state */\n    if (inflateStateCheck(strm)) return Z_STREAM_ERROR;\n    state = (struct inflate_state FAR *)strm->state;\n    if ((state->wrap & 2) == 0) return Z_STREAM_ERROR;\n\n    /* save header structure */\n    state->head = head;\n    head->done = 0;\n    return Z_OK;\n}\n\n/*\n   Search buf[0..len-1] for the pattern: 0, 0, 0xff, 0xff.  Return when found\n   or when out of input.  When called, *have is the number of pattern bytes\n   found in order so far, in 0..3.  On return *have is updated to the new\n   state.  If on return *have equals four, then the pattern was found and the\n   return value is how many bytes were read including the last byte of the\n   pattern.  If *have is less than four, then the pattern has not been found\n   yet and the return value is len.  In the latter case, syncsearch() can be\n   called again with more data and the *have state.  *have is initialized to\n   zero for the first call.\n */\nlocal unsigned syncsearch(have, buf, len)\nunsigned FAR *have;\nconst unsigned char FAR *buf;\nunsigned len;\n{\n    unsigned got;\n    unsigned next;\n\n    got = *have;\n    next = 0;\n    while (next < len && got < 4) {\n        if ((int)(buf[next]) == (got < 2 ? 0 : 0xff))\n            got++;\n        else if (buf[next])\n            got = 0;\n        else\n            got = 4 - got;\n        next++;\n    }\n    *have = got;\n    return next;\n}\n\nint ZEXPORT inflateSync(strm)\nz_streamp strm;\n{\n    unsigned len;               /* number of bytes to look at or looked at */\n    unsigned long in, out;      /* temporary to save total_in and total_out */\n    unsigned char buf[4];       /* to restore bit buffer to byte string */\n    struct inflate_state FAR *state;\n\n    /* check parameters */\n    if (inflateStateCheck(strm)) return Z_STREAM_ERROR;\n    state = (struct inflate_state FAR *)strm->state;\n    if (strm->avail_in == 0 && state->bits < 8) return Z_BUF_ERROR;\n\n    /* if first time, start search in bit buffer */\n    if (state->mode != SYNC) {\n        state->mode = SYNC;\n        state->hold <<= state->bits & 7;\n        state->bits -= state->bits & 7;\n        len = 0;\n        while (state->bits >= 8) {\n            buf[len++] = (unsigned char)(state->hold);\n            state->hold >>= 8;\n            state->bits -= 8;\n        }\n        state->have = 0;\n        syncsearch(&(state->have), buf, len);\n    }\n\n    /* search available input */\n    len = syncsearch(&(state->have), strm->next_in, strm->avail_in);\n    strm->avail_in -= len;\n    strm->next_in += len;\n    strm->total_in += len;\n\n    /* return no joy or set up to restart inflate() on a new block */\n    if (state->have != 4) return Z_DATA_ERROR;\n    in = strm->total_in;  out = strm->total_out;\n    inflateReset(strm);\n    strm->total_in = in;  strm->total_out = out;\n    state->mode = TYPE;\n    return Z_OK;\n}\n\n/*\n   Returns true if inflate is currently at the end of a block generated by\n   Z_SYNC_FLUSH or Z_FULL_FLUSH. This function is used by one PPP\n   implementation to provide an additional safety check. PPP uses\n   Z_SYNC_FLUSH but removes the length bytes of the resulting empty stored\n   block. When decompressing, PPP checks that at the end of input packet,\n   inflate is waiting for these length bytes.\n */\nint ZEXPORT inflateSyncPoint(strm)\nz_streamp strm;\n{\n    struct inflate_state FAR *state;\n\n    if (inflateStateCheck(strm)) return Z_STREAM_ERROR;\n    state = (struct inflate_state FAR *)strm->state;\n    return state->mode == STORED && state->bits == 0;\n}\n\nint ZEXPORT inflateCopy(dest, source)\nz_streamp dest;\nz_streamp source;\n{\n    struct inflate_state FAR *state;\n    struct inflate_state FAR *copy;\n    unsigned char FAR *window;\n    unsigned wsize;\n\n    /* check input */\n    if (inflateStateCheck(source) || dest == Z_NULL)\n        return Z_STREAM_ERROR;\n    state = (struct inflate_state FAR *)source->state;\n\n    /* allocate space */\n    copy = (struct inflate_state FAR *)\n           ZALLOC(source, 1, sizeof(struct inflate_state));\n    if (copy == Z_NULL) return Z_MEM_ERROR;\n    window = Z_NULL;\n    if (state->window != Z_NULL) {\n        window = (unsigned char FAR *)\n                 ZALLOC(source, 1U << state->wbits, sizeof(unsigned char));\n        if (window == Z_NULL) {\n            ZFREE(source, copy);\n            return Z_MEM_ERROR;\n        }\n    }\n\n    /* copy state */\n    zmemcpy((voidpf)dest, (voidpf)source, sizeof(z_stream));\n    zmemcpy((voidpf)copy, (voidpf)state, sizeof(struct inflate_state));\n    copy->strm = dest;\n    if (state->lencode >= state->codes &&\n        state->lencode <= state->codes + ENOUGH - 1) {\n        copy->lencode = copy->codes + (state->lencode - state->codes);\n        copy->distcode = copy->codes + (state->distcode - state->codes);\n    }\n    copy->next = copy->codes + (state->next - state->codes);\n    if (window != Z_NULL) {\n        wsize = 1U << state->wbits;\n        zmemcpy(window, state->window, wsize);\n    }\n    copy->window = window;\n    dest->state = (struct internal_state FAR *)copy;\n    return Z_OK;\n}\n\nint ZEXPORT inflateUndermine(strm, subvert)\nz_streamp strm;\nint subvert;\n{\n    struct inflate_state FAR *state;\n\n    if (inflateStateCheck(strm)) return Z_STREAM_ERROR;\n    state = (struct inflate_state FAR *)strm->state;\n#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR\n    state->sane = !subvert;\n    return Z_OK;\n#else\n    (void)subvert;\n    state->sane = 1;\n    return Z_DATA_ERROR;\n#endif\n}\n\nint ZEXPORT inflateValidate(strm, check)\nz_streamp strm;\nint check;\n{\n    struct inflate_state FAR *state;\n\n    if (inflateStateCheck(strm)) return Z_STREAM_ERROR;\n    state = (struct inflate_state FAR *)strm->state;\n    if (check)\n        state->wrap |= 4;\n    else\n        state->wrap &= ~4;\n    return Z_OK;\n}\n\nlong ZEXPORT inflateMark(strm)\nz_streamp strm;\n{\n    struct inflate_state FAR *state;\n\n    if (inflateStateCheck(strm))\n        return -(1L << 16);\n    state = (struct inflate_state FAR *)strm->state;\n    return (long)(((unsigned long)((long)state->back)) << 16) +\n        (state->mode == COPY ? state->length :\n            (state->mode == MATCH ? state->was - state->length : 0));\n}\n\nunsigned long ZEXPORT inflateCodesUsed(strm)\nz_streamp strm;\n{\n    struct inflate_state FAR *state;\n    if (inflateStateCheck(strm)) return (unsigned long)-1;\n    state = (struct inflate_state FAR *)strm->state;\n    return (unsigned long)(state->next - state->codes);\n}\n"
  },
  {
    "path": "Projects/Libraries/CSBase/Source/zlib/inflate.h",
    "content": "/* inflate.h -- internal inflate state definition\n * Copyright (C) 1995-2016 Mark Adler\n * For conditions of distribution and use, see copyright notice in zlib.h\n */\n\n/* WARNING: this file should *not* be used by applications. It is\n   part of the implementation of the compression library and is\n   subject to change. Applications should only use zlib.h.\n */\n\n/* define NO_GZIP when compiling if you want to disable gzip header and\n   trailer decoding by inflate().  NO_GZIP would be used to avoid linking in\n   the crc code when it is not needed.  For shared libraries, gzip decoding\n   should be left enabled. */\n#ifndef NO_GZIP\n#  define GUNZIP\n#endif\n\n/* Possible inflate modes between inflate() calls */\ntypedef enum {\n    HEAD = 16180,   /* i: waiting for magic header */\n    FLAGS,      /* i: waiting for method and flags (gzip) */\n    TIME,       /* i: waiting for modification time (gzip) */\n    OS,         /* i: waiting for extra flags and operating system (gzip) */\n    EXLEN,      /* i: waiting for extra length (gzip) */\n    EXTRA,      /* i: waiting for extra bytes (gzip) */\n    NAME,       /* i: waiting for end of file name (gzip) */\n    COMMENT,    /* i: waiting for end of comment (gzip) */\n    HCRC,       /* i: waiting for header crc (gzip) */\n    DICTID,     /* i: waiting for dictionary check value */\n    DICT,       /* waiting for inflateSetDictionary() call */\n        TYPE,       /* i: waiting for type bits, including last-flag bit */\n        TYPEDO,     /* i: same, but skip check to exit inflate on new block */\n        STORED,     /* i: waiting for stored size (length and complement) */\n        COPY_,      /* i/o: same as COPY below, but only first time in */\n        COPY,       /* i/o: waiting for input or output to copy stored block */\n        TABLE,      /* i: waiting for dynamic block table lengths */\n        LENLENS,    /* i: waiting for code length code lengths */\n        CODELENS,   /* i: waiting for length/lit and distance code lengths */\n            LEN_,       /* i: same as LEN below, but only first time in */\n            LEN,        /* i: waiting for length/lit/eob code */\n            LENEXT,     /* i: waiting for length extra bits */\n            DIST,       /* i: waiting for distance code */\n            DISTEXT,    /* i: waiting for distance extra bits */\n            MATCH,      /* o: waiting for output space to copy string */\n            LIT,        /* o: waiting for output space to write literal */\n    CHECK,      /* i: waiting for 32-bit check value */\n    LENGTH,     /* i: waiting for 32-bit length (gzip) */\n    DONE,       /* finished check, done -- remain here until reset */\n    BAD,        /* got a data error -- remain here until reset */\n    MEM,        /* got an inflate() memory error -- remain here until reset */\n    SYNC        /* looking for synchronization bytes to restart inflate() */\n} inflate_mode;\n\n/*\n    State transitions between above modes -\n\n    (most modes can go to BAD or MEM on error -- not shown for clarity)\n\n    Process header:\n        HEAD -> (gzip) or (zlib) or (raw)\n        (gzip) -> FLAGS -> TIME -> OS -> EXLEN -> EXTRA -> NAME -> COMMENT ->\n                  HCRC -> TYPE\n        (zlib) -> DICTID or TYPE\n        DICTID -> DICT -> TYPE\n        (raw) -> TYPEDO\n    Read deflate blocks:\n            TYPE -> TYPEDO -> STORED or TABLE or LEN_ or CHECK\n            STORED -> COPY_ -> COPY -> TYPE\n            TABLE -> LENLENS -> CODELENS -> LEN_\n            LEN_ -> LEN\n    Read deflate codes in fixed or dynamic block:\n                LEN -> LENEXT or LIT or TYPE\n                LENEXT -> DIST -> DISTEXT -> MATCH -> LEN\n                LIT -> LEN\n    Process trailer:\n        CHECK -> LENGTH -> DONE\n */\n\n/* State maintained between inflate() calls -- approximately 7K bytes, not\n   including the allocated sliding window, which is up to 32K bytes. */\nstruct inflate_state {\n    z_streamp strm;             /* pointer back to this zlib stream */\n    inflate_mode mode;          /* current inflate mode */\n    int last;                   /* true if processing last block */\n    int wrap;                   /* bit 0 true for zlib, bit 1 true for gzip,\n                                   bit 2 true to validate check value */\n    int havedict;               /* true if dictionary provided */\n    int flags;                  /* gzip header method and flags (0 if zlib) */\n    unsigned dmax;              /* zlib header max distance (INFLATE_STRICT) */\n    unsigned long check;        /* protected copy of check value */\n    unsigned long total;        /* protected copy of output count */\n    gz_headerp head;            /* where to save gzip header information */\n        /* sliding window */\n    unsigned wbits;             /* log base 2 of requested window size */\n    unsigned wsize;             /* window size or zero if not using window */\n    unsigned whave;             /* valid bytes in the window */\n    unsigned wnext;             /* window write index */\n    unsigned char FAR *window;  /* allocated sliding window, if needed */\n        /* bit accumulator */\n    unsigned long hold;         /* input bit accumulator */\n    unsigned bits;              /* number of bits in \"in\" */\n        /* for string and stored block copying */\n    unsigned length;            /* literal or length of data to copy */\n    unsigned offset;            /* distance back to copy string from */\n        /* for table and code decoding */\n    unsigned extra;             /* extra bits needed */\n        /* fixed and dynamic code tables */\n    code const FAR *lencode;    /* starting table for length/literal codes */\n    code const FAR *distcode;   /* starting table for distance codes */\n    unsigned lenbits;           /* index bits for lencode */\n    unsigned distbits;          /* index bits for distcode */\n        /* dynamic table building */\n    unsigned ncode;             /* number of code length code lengths */\n    unsigned nlen;              /* number of length code lengths */\n    unsigned ndist;             /* number of distance code lengths */\n    unsigned have;              /* number of code lengths in lens[] */\n    code FAR *next;             /* next available space in codes[] */\n    unsigned short lens[320];   /* temporary storage for code lengths */\n    unsigned short work[288];   /* work area for code table building */\n    code codes[ENOUGH];         /* space for code tables */\n    int sane;                   /* if false, allow invalid distance too far */\n    int back;                   /* bits back of last unprocessed length/lit */\n    unsigned was;               /* initial length of match */\n};\n"
  },
  {
    "path": "Projects/Libraries/CSBase/Source/zlib/inftrees.c",
    "content": "/* inftrees.c -- generate Huffman trees for efficient decoding\n * Copyright (C) 1995-2017 Mark Adler\n * For conditions of distribution and use, see copyright notice in zlib.h\n */\n\n#include \"zutil.h\"\n#include \"inftrees.h\"\n\n#define MAXBITS 15\n\nconst char inflate_copyright[] =\n   \" inflate 1.2.11 Copyright 1995-2017 Mark Adler \";\n/*\n  If you use the zlib library in a product, an acknowledgment is welcome\n  in the documentation of your product. If for some reason you cannot\n  include such an acknowledgment, I would appreciate that you keep this\n  copyright string in the executable of your product.\n */\n\n/*\n   Build a set of tables to decode the provided canonical Huffman code.\n   The code lengths are lens[0..codes-1].  The result starts at *table,\n   whose indices are 0..2^bits-1.  work is a writable array of at least\n   lens shorts, which is used as a work area.  type is the type of code\n   to be generated, CODES, LENS, or DISTS.  On return, zero is success,\n   -1 is an invalid code, and +1 means that ENOUGH isn't enough.  table\n   on return points to the next available entry's address.  bits is the\n   requested root table index bits, and on return it is the actual root\n   table index bits.  It will differ if the request is greater than the\n   longest code or if it is less than the shortest code.\n */\nint ZLIB_INTERNAL inflate_table(type, lens, codes, table, bits, work)\ncodetype type;\nunsigned short FAR *lens;\nunsigned codes;\ncode FAR * FAR *table;\nunsigned FAR *bits;\nunsigned short FAR *work;\n{\n    unsigned len;               /* a code's length in bits */\n    unsigned sym;               /* index of code symbols */\n    unsigned min, max;          /* minimum and maximum code lengths */\n    unsigned root;              /* number of index bits for root table */\n    unsigned curr;              /* number of index bits for current table */\n    unsigned drop;              /* code bits to drop for sub-table */\n    int left;                   /* number of prefix codes available */\n    unsigned used;              /* code entries in table used */\n    unsigned huff;              /* Huffman code */\n    unsigned incr;              /* for incrementing code, index */\n    unsigned fill;              /* index for replicating entries */\n    unsigned low;               /* low bits for current root entry */\n    unsigned mask;              /* mask for low root bits */\n    code here;                  /* table entry for duplication */\n    code FAR *next;             /* next available space in table */\n    const unsigned short FAR *base;     /* base value table to use */\n    const unsigned short FAR *extra;    /* extra bits table to use */\n    unsigned match;             /* use base and extra for symbol >= match */\n    unsigned short count[MAXBITS+1];    /* number of codes of each length */\n    unsigned short offs[MAXBITS+1];     /* offsets in table for each length */\n    static const unsigned short lbase[31] = { /* Length codes 257..285 base */\n        3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,\n        35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};\n    static const unsigned short lext[31] = { /* Length codes 257..285 extra */\n        16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,\n        19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 77, 202};\n    static const unsigned short dbase[32] = { /* Distance codes 0..29 base */\n        1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,\n        257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,\n        8193, 12289, 16385, 24577, 0, 0};\n    static const unsigned short dext[32] = { /* Distance codes 0..29 extra */\n        16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22,\n        23, 23, 24, 24, 25, 25, 26, 26, 27, 27,\n        28, 28, 29, 29, 64, 64};\n\n    /*\n       Process a set of code lengths to create a canonical Huffman code.  The\n       code lengths are lens[0..codes-1].  Each length corresponds to the\n       symbols 0..codes-1.  The Huffman code is generated by first sorting the\n       symbols by length from short to long, and retaining the symbol order\n       for codes with equal lengths.  Then the code starts with all zero bits\n       for the first code of the shortest length, and the codes are integer\n       increments for the same length, and zeros are appended as the length\n       increases.  For the deflate format, these bits are stored backwards\n       from their more natural integer increment ordering, and so when the\n       decoding tables are built in the large loop below, the integer codes\n       are incremented backwards.\n\n       This routine assumes, but does not check, that all of the entries in\n       lens[] are in the range 0..MAXBITS.  The caller must assure this.\n       1..MAXBITS is interpreted as that code length.  zero means that that\n       symbol does not occur in this code.\n\n       The codes are sorted by computing a count of codes for each length,\n       creating from that a table of starting indices for each length in the\n       sorted table, and then entering the symbols in order in the sorted\n       table.  The sorted table is work[], with that space being provided by\n       the caller.\n\n       The length counts are used for other purposes as well, i.e. finding\n       the minimum and maximum length codes, determining if there are any\n       codes at all, checking for a valid set of lengths, and looking ahead\n       at length counts to determine sub-table sizes when building the\n       decoding tables.\n     */\n\n    /* accumulate lengths for codes (assumes lens[] all in 0..MAXBITS) */\n    for (len = 0; len <= MAXBITS; len++)\n        count[len] = 0;\n    for (sym = 0; sym < codes; sym++)\n        count[lens[sym]]++;\n\n    /* bound code lengths, force root to be within code lengths */\n    root = *bits;\n    for (max = MAXBITS; max >= 1; max--)\n        if (count[max] != 0) break;\n    if (root > max) root = max;\n    if (max == 0) {                     /* no symbols to code at all */\n        here.op = (unsigned char)64;    /* invalid code marker */\n        here.bits = (unsigned char)1;\n        here.val = (unsigned short)0;\n        *(*table)++ = here;             /* make a table to force an error */\n        *(*table)++ = here;\n        *bits = 1;\n        return 0;     /* no symbols, but wait for decoding to report error */\n    }\n    for (min = 1; min < max; min++)\n        if (count[min] != 0) break;\n    if (root < min) root = min;\n\n    /* check for an over-subscribed or incomplete set of lengths */\n    left = 1;\n    for (len = 1; len <= MAXBITS; len++) {\n        left <<= 1;\n        left -= count[len];\n        if (left < 0) return -1;        /* over-subscribed */\n    }\n    if (left > 0 && (type == CODES || max != 1))\n        return -1;                      /* incomplete set */\n\n    /* generate offsets into symbol table for each length for sorting */\n    offs[1] = 0;\n    for (len = 1; len < MAXBITS; len++)\n        offs[len + 1] = offs[len] + count[len];\n\n    /* sort symbols by length, by symbol order within each length */\n    for (sym = 0; sym < codes; sym++)\n        if (lens[sym] != 0) work[offs[lens[sym]]++] = (unsigned short)sym;\n\n    /*\n       Create and fill in decoding tables.  In this loop, the table being\n       filled is at next and has curr index bits.  The code being used is huff\n       with length len.  That code is converted to an index by dropping drop\n       bits off of the bottom.  For codes where len is less than drop + curr,\n       those top drop + curr - len bits are incremented through all values to\n       fill the table with replicated entries.\n\n       root is the number of index bits for the root table.  When len exceeds\n       root, sub-tables are created pointed to by the root entry with an index\n       of the low root bits of huff.  This is saved in low to check for when a\n       new sub-table should be started.  drop is zero when the root table is\n       being filled, and drop is root when sub-tables are being filled.\n\n       When a new sub-table is needed, it is necessary to look ahead in the\n       code lengths to determine what size sub-table is needed.  The length\n       counts are used for this, and so count[] is decremented as codes are\n       entered in the tables.\n\n       used keeps track of how many table entries have been allocated from the\n       provided *table space.  It is checked for LENS and DIST tables against\n       the constants ENOUGH_LENS and ENOUGH_DISTS to guard against changes in\n       the initial root table size constants.  See the comments in inftrees.h\n       for more information.\n\n       sym increments through all symbols, and the loop terminates when\n       all codes of length max, i.e. all codes, have been processed.  This\n       routine permits incomplete codes, so another loop after this one fills\n       in the rest of the decoding tables with invalid code markers.\n     */\n\n    /* set up for code type */\n    switch (type) {\n    case CODES:\n        base = extra = work;    /* dummy value--not used */\n        match = 20;\n        break;\n    case LENS:\n        base = lbase;\n        extra = lext;\n        match = 257;\n        break;\n    default:    /* DISTS */\n        base = dbase;\n        extra = dext;\n        match = 0;\n    }\n\n    /* initialize state for loop */\n    huff = 0;                   /* starting code */\n    sym = 0;                    /* starting code symbol */\n    len = min;                  /* starting code length */\n    next = *table;              /* current table to fill in */\n    curr = root;                /* current table index bits */\n    drop = 0;                   /* current bits to drop from code for index */\n    low = (unsigned)(-1);       /* trigger new sub-table when len > root */\n    used = 1U << root;          /* use root table entries */\n    mask = used - 1;            /* mask for comparing low */\n\n    /* check available table space */\n    if ((type == LENS && used > ENOUGH_LENS) ||\n        (type == DISTS && used > ENOUGH_DISTS))\n        return 1;\n\n    /* process all codes and make table entries */\n    for (;;) {\n        /* create table entry */\n        here.bits = (unsigned char)(len - drop);\n        if (work[sym] + 1U < match) {\n            here.op = (unsigned char)0;\n            here.val = work[sym];\n        }\n        else if (work[sym] >= match) {\n            here.op = (unsigned char)(extra[work[sym] - match]);\n            here.val = base[work[sym] - match];\n        }\n        else {\n            here.op = (unsigned char)(32 + 64);         /* end of block */\n            here.val = 0;\n        }\n\n        /* replicate for those indices with low len bits equal to huff */\n        incr = 1U << (len - drop);\n        fill = 1U << curr;\n        min = fill;                 /* save offset to next table */\n        do {\n            fill -= incr;\n            next[(huff >> drop) + fill] = here;\n        } while (fill != 0);\n\n        /* backwards increment the len-bit code huff */\n        incr = 1U << (len - 1);\n        while (huff & incr)\n            incr >>= 1;\n        if (incr != 0) {\n            huff &= incr - 1;\n            huff += incr;\n        }\n        else\n            huff = 0;\n\n        /* go to next symbol, update count, len */\n        sym++;\n        if (--(count[len]) == 0) {\n            if (len == max) break;\n            len = lens[work[sym]];\n        }\n\n        /* create new sub-table if needed */\n        if (len > root && (huff & mask) != low) {\n            /* if first time, transition to sub-tables */\n            if (drop == 0)\n                drop = root;\n\n            /* increment past last table */\n            next += min;            /* here min is 1 << curr */\n\n            /* determine length of next table */\n            curr = len - drop;\n            left = (int)(1 << curr);\n            while (curr + drop < max) {\n                left -= count[curr + drop];\n                if (left <= 0) break;\n                curr++;\n                left <<= 1;\n            }\n\n            /* check for enough space */\n            used += 1U << curr;\n            if ((type == LENS && used > ENOUGH_LENS) ||\n                (type == DISTS && used > ENOUGH_DISTS))\n                return 1;\n\n            /* point entry in root table to sub-table */\n            low = huff & mask;\n            (*table)[low].op = (unsigned char)curr;\n            (*table)[low].bits = (unsigned char)root;\n            (*table)[low].val = (unsigned short)(next - *table);\n        }\n    }\n\n    /* fill in remaining table entry if code is incomplete (guaranteed to have\n       at most one remaining entry, since if the code is incomplete, the\n       maximum code length that was allowed to get this far is one bit) */\n    if (huff != 0) {\n        here.op = (unsigned char)64;            /* invalid code marker */\n        here.bits = (unsigned char)(len - drop);\n        here.val = (unsigned short)0;\n        next[huff] = here;\n    }\n\n    /* set return parameters */\n    *table += used;\n    *bits = root;\n    return 0;\n}\n"
  },
  {
    "path": "Projects/Libraries/CSBase/Source/zlib/inftrees.h",
    "content": "/* inftrees.h -- header to use inftrees.c\n * Copyright (C) 1995-2005, 2010 Mark Adler\n * For conditions of distribution and use, see copyright notice in zlib.h\n */\n\n/* WARNING: this file should *not* be used by applications. It is\n   part of the implementation of the compression library and is\n   subject to change. Applications should only use zlib.h.\n */\n\n/* Structure for decoding tables.  Each entry provides either the\n   information needed to do the operation requested by the code that\n   indexed that table entry, or it provides a pointer to another\n   table that indexes more bits of the code.  op indicates whether\n   the entry is a pointer to another table, a literal, a length or\n   distance, an end-of-block, or an invalid code.  For a table\n   pointer, the low four bits of op is the number of index bits of\n   that table.  For a length or distance, the low four bits of op\n   is the number of extra bits to get after the code.  bits is\n   the number of bits in this code or part of the code to drop off\n   of the bit buffer.  val is the actual byte to output in the case\n   of a literal, the base length or distance, or the offset from\n   the current table to the next table.  Each entry is four bytes. */\ntypedef struct {\n    unsigned char op;           /* operation, extra bits, table bits */\n    unsigned char bits;         /* bits in this part of the code */\n    unsigned short val;         /* offset in table or code value */\n} code;\n\n/* op values as set by inflate_table():\n    00000000 - literal\n    0000tttt - table link, tttt != 0 is the number of table index bits\n    0001eeee - length or distance, eeee is the number of extra bits\n    01100000 - end of block\n    01000000 - invalid code\n */\n\n/* Maximum size of the dynamic table.  The maximum number of code structures is\n   1444, which is the sum of 852 for literal/length codes and 592 for distance\n   codes.  These values were found by exhaustive searches using the program\n   examples/enough.c found in the zlib distribtution.  The arguments to that\n   program are the number of symbols, the initial root table size, and the\n   maximum bit length of a code.  \"enough 286 9 15\" for literal/length codes\n   returns returns 852, and \"enough 30 6 15\" for distance codes returns 592.\n   The initial root table size (9 or 6) is found in the fifth argument of the\n   inflate_table() calls in inflate.c and infback.c.  If the root table size is\n   changed, then these maximum sizes would be need to be recalculated and\n   updated. */\n#define ENOUGH_LENS 852\n#define ENOUGH_DISTS 592\n#define ENOUGH (ENOUGH_LENS+ENOUGH_DISTS)\n\n/* Type of code to build for inflate_table() */\ntypedef enum {\n    CODES,\n    LENS,\n    DISTS\n} codetype;\n\nint ZLIB_INTERNAL inflate_table OF((codetype type, unsigned short FAR *lens,\n                             unsigned codes, code FAR * FAR *table,\n                             unsigned FAR *bits, unsigned short FAR *work));\n"
  },
  {
    "path": "Projects/Libraries/CSBase/Source/zlib/trees.c",
    "content": "/* trees.c -- output deflated data using Huffman coding\n * Copyright (C) 1995-2017 Jean-loup Gailly\n * detect_data_type() function provided freely by Cosmin Truta, 2006\n * For conditions of distribution and use, see copyright notice in zlib.h\n */\n\n/*\n *  ALGORITHM\n *\n *      The \"deflation\" process uses several Huffman trees. The more\n *      common source values are represented by shorter bit sequences.\n *\n *      Each code tree is stored in a compressed form which is itself\n * a Huffman encoding of the lengths of all the code strings (in\n * ascending order by source values).  The actual code strings are\n * reconstructed from the lengths in the inflate process, as described\n * in the deflate specification.\n *\n *  REFERENCES\n *\n *      Deutsch, L.P.,\"'Deflate' Compressed Data Format Specification\".\n *      Available in ftp.uu.net:/pub/archiving/zip/doc/deflate-1.1.doc\n *\n *      Storer, James A.\n *          Data Compression:  Methods and Theory, pp. 49-50.\n *          Computer Science Press, 1988.  ISBN 0-7167-8156-5.\n *\n *      Sedgewick, R.\n *          Algorithms, p290.\n *          Addison-Wesley, 1983. ISBN 0-201-06672-6.\n */\n\n/* @(#) $Id$ */\n\n/* #define GEN_TREES_H */\n\n#include \"deflate.h\"\n\n#ifdef ZLIB_DEBUG\n#  include <ctype.h>\n#endif\n\n/* ===========================================================================\n * Constants\n */\n\n#define MAX_BL_BITS 7\n/* Bit length codes must not exceed MAX_BL_BITS bits */\n\n#define END_BLOCK 256\n/* end of block literal code */\n\n#define REP_3_6      16\n/* repeat previous bit length 3-6 times (2 bits of repeat count) */\n\n#define REPZ_3_10    17\n/* repeat a zero length 3-10 times  (3 bits of repeat count) */\n\n#define REPZ_11_138  18\n/* repeat a zero length 11-138 times  (7 bits of repeat count) */\n\nlocal const int extra_lbits[LENGTH_CODES] /* extra bits for each length code */\n   = {0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0};\n\nlocal const int extra_dbits[D_CODES] /* extra bits for each distance code */\n   = {0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13};\n\nlocal const int extra_blbits[BL_CODES]/* extra bits for each bit length code */\n   = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7};\n\nlocal const uch bl_order[BL_CODES]\n   = {16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15};\n/* The lengths of the bit length codes are sent in order of decreasing\n * probability, to avoid transmitting the lengths for unused bit length codes.\n */\n\n/* ===========================================================================\n * Local data. These are initialized only once.\n */\n\n#define DIST_CODE_LEN  512 /* see definition of array dist_code below */\n\n#if defined(GEN_TREES_H) || !defined(STDC)\n/* non ANSI compilers may not accept trees.h */\n\nlocal ct_data static_ltree[L_CODES+2];\n/* The static literal tree. Since the bit lengths are imposed, there is no\n * need for the L_CODES extra codes used during heap construction. However\n * The codes 286 and 287 are needed to build a canonical tree (see _tr_init\n * below).\n */\n\nlocal ct_data static_dtree[D_CODES];\n/* The static distance tree. (Actually a trivial tree since all codes use\n * 5 bits.)\n */\n\nuch _dist_code[DIST_CODE_LEN];\n/* Distance codes. The first 256 values correspond to the distances\n * 3 .. 258, the last 256 values correspond to the top 8 bits of\n * the 15 bit distances.\n */\n\nuch _length_code[MAX_MATCH-MIN_MATCH+1];\n/* length code for each normalized match length (0 == MIN_MATCH) */\n\nlocal int base_length[LENGTH_CODES];\n/* First normalized length for each code (0 = MIN_MATCH) */\n\nlocal int base_dist[D_CODES];\n/* First normalized distance for each code (0 = distance of 1) */\n\n#else\n#  include \"trees.h\"\n#endif /* GEN_TREES_H */\n\nstruct static_tree_desc_s {\n    const ct_data *static_tree;  /* static tree or NULL */\n    const intf *extra_bits;      /* extra bits for each code or NULL */\n    int     extra_base;          /* base index for extra_bits */\n    int     elems;               /* max number of elements in the tree */\n    int     max_length;          /* max bit length for the codes */\n};\n\nlocal const static_tree_desc  static_l_desc =\n{static_ltree, extra_lbits, LITERALS+1, L_CODES, MAX_BITS};\n\nlocal const static_tree_desc  static_d_desc =\n{static_dtree, extra_dbits, 0,          D_CODES, MAX_BITS};\n\nlocal const static_tree_desc  static_bl_desc =\n{(const ct_data *)0, extra_blbits, 0,   BL_CODES, MAX_BL_BITS};\n\n/* ===========================================================================\n * Local (static) routines in this file.\n */\n\nlocal void tr_static_init OF((void));\nlocal void init_block     OF((deflate_state *s));\nlocal void pqdownheap     OF((deflate_state *s, ct_data *tree, int k));\nlocal void gen_bitlen     OF((deflate_state *s, tree_desc *desc));\nlocal void gen_codes      OF((ct_data *tree, int max_code, ushf *bl_count));\nlocal void build_tree     OF((deflate_state *s, tree_desc *desc));\nlocal void scan_tree      OF((deflate_state *s, ct_data *tree, int max_code));\nlocal void send_tree      OF((deflate_state *s, ct_data *tree, int max_code));\nlocal int  build_bl_tree  OF((deflate_state *s));\nlocal void send_all_trees OF((deflate_state *s, int lcodes, int dcodes,\n                              int blcodes));\nlocal void compress_block OF((deflate_state *s, const ct_data *ltree,\n                              const ct_data *dtree));\nlocal int  detect_data_type OF((deflate_state *s));\nlocal unsigned bi_reverse OF((unsigned value, int length));\nlocal void bi_windup      OF((deflate_state *s));\nlocal void bi_flush       OF((deflate_state *s));\n\n#ifdef GEN_TREES_H\nlocal void gen_trees_header OF((void));\n#endif\n\n#ifndef ZLIB_DEBUG\n#  define send_code(s, c, tree) send_bits(s, tree[c].Code, tree[c].Len)\n   /* Send a code of the given tree. c and tree must not have side effects */\n\n#else /* !ZLIB_DEBUG */\n#  define send_code(s, c, tree) \\\n     { if (z_verbose>2) fprintf(stderr,\"\\ncd %3d \",(c)); \\\n       send_bits(s, tree[c].Code, tree[c].Len); }\n#endif\n\n/* ===========================================================================\n * Output a short LSB first on the stream.\n * IN assertion: there is enough room in pendingBuf.\n */\n#define put_short(s, w) { \\\n    put_byte(s, (uch)((w) & 0xff)); \\\n    put_byte(s, (uch)((ush)(w) >> 8)); \\\n}\n\n/* ===========================================================================\n * Send a value on a given number of bits.\n * IN assertion: length <= 16 and value fits in length bits.\n */\n#ifdef ZLIB_DEBUG\nlocal void send_bits      OF((deflate_state *s, int value, int length));\n\nlocal void send_bits(s, value, length)\n    deflate_state *s;\n    int value;  /* value to send */\n    int length; /* number of bits */\n{\n    Tracevv((stderr,\" l %2d v %4x \", length, value));\n    Assert(length > 0 && length <= 15, \"invalid length\");\n    s->bits_sent += (ulg)length;\n\n    /* If not enough room in bi_buf, use (valid) bits from bi_buf and\n     * (16 - bi_valid) bits from value, leaving (width - (16-bi_valid))\n     * unused bits in value.\n     */\n    if (s->bi_valid > (int)Buf_size - length) {\n        s->bi_buf |= (ush)value << s->bi_valid;\n        put_short(s, s->bi_buf);\n        s->bi_buf = (ush)value >> (Buf_size - s->bi_valid);\n        s->bi_valid += length - Buf_size;\n    } else {\n        s->bi_buf |= (ush)value << s->bi_valid;\n        s->bi_valid += length;\n    }\n}\n#else /* !ZLIB_DEBUG */\n\n#define send_bits(s, value, length) \\\n{ int len = length;\\\n  if (s->bi_valid > (int)Buf_size - len) {\\\n    int val = (int)value;\\\n    s->bi_buf |= (ush)val << s->bi_valid;\\\n    put_short(s, s->bi_buf);\\\n    s->bi_buf = (ush)val >> (Buf_size - s->bi_valid);\\\n    s->bi_valid += len - Buf_size;\\\n  } else {\\\n    s->bi_buf |= (ush)(value) << s->bi_valid;\\\n    s->bi_valid += len;\\\n  }\\\n}\n#endif /* ZLIB_DEBUG */\n\n\n/* the arguments must not have side effects */\n\n/* ===========================================================================\n * Initialize the various 'constant' tables.\n */\nlocal void tr_static_init()\n{\n#if defined(GEN_TREES_H) || !defined(STDC)\n    static int static_init_done = 0;\n    int n;        /* iterates over tree elements */\n    int bits;     /* bit counter */\n    int length;   /* length value */\n    int code;     /* code value */\n    int dist;     /* distance index */\n    ush bl_count[MAX_BITS+1];\n    /* number of codes at each bit length for an optimal tree */\n\n    if (static_init_done) return;\n\n    /* For some embedded targets, global variables are not initialized: */\n#ifdef NO_INIT_GLOBAL_POINTERS\n    static_l_desc.static_tree = static_ltree;\n    static_l_desc.extra_bits = extra_lbits;\n    static_d_desc.static_tree = static_dtree;\n    static_d_desc.extra_bits = extra_dbits;\n    static_bl_desc.extra_bits = extra_blbits;\n#endif\n\n    /* Initialize the mapping length (0..255) -> length code (0..28) */\n    length = 0;\n    for (code = 0; code < LENGTH_CODES-1; code++) {\n        base_length[code] = length;\n        for (n = 0; n < (1<<extra_lbits[code]); n++) {\n            _length_code[length++] = (uch)code;\n        }\n    }\n    Assert (length == 256, \"tr_static_init: length != 256\");\n    /* Note that the length 255 (match length 258) can be represented\n     * in two different ways: code 284 + 5 bits or code 285, so we\n     * overwrite length_code[255] to use the best encoding:\n     */\n    _length_code[length-1] = (uch)code;\n\n    /* Initialize the mapping dist (0..32K) -> dist code (0..29) */\n    dist = 0;\n    for (code = 0 ; code < 16; code++) {\n        base_dist[code] = dist;\n        for (n = 0; n < (1<<extra_dbits[code]); n++) {\n            _dist_code[dist++] = (uch)code;\n        }\n    }\n    Assert (dist == 256, \"tr_static_init: dist != 256\");\n    dist >>= 7; /* from now on, all distances are divided by 128 */\n    for ( ; code < D_CODES; code++) {\n        base_dist[code] = dist << 7;\n        for (n = 0; n < (1<<(extra_dbits[code]-7)); n++) {\n            _dist_code[256 + dist++] = (uch)code;\n        }\n    }\n    Assert (dist == 256, \"tr_static_init: 256+dist != 512\");\n\n    /* Construct the codes of the static literal tree */\n    for (bits = 0; bits <= MAX_BITS; bits++) bl_count[bits] = 0;\n    n = 0;\n    while (n <= 143) static_ltree[n++].Len = 8, bl_count[8]++;\n    while (n <= 255) static_ltree[n++].Len = 9, bl_count[9]++;\n    while (n <= 279) static_ltree[n++].Len = 7, bl_count[7]++;\n    while (n <= 287) static_ltree[n++].Len = 8, bl_count[8]++;\n    /* Codes 286 and 287 do not exist, but we must include them in the\n     * tree construction to get a canonical Huffman tree (longest code\n     * all ones)\n     */\n    gen_codes((ct_data *)static_ltree, L_CODES+1, bl_count);\n\n    /* The static distance tree is trivial: */\n    for (n = 0; n < D_CODES; n++) {\n        static_dtree[n].Len = 5;\n        static_dtree[n].Code = bi_reverse((unsigned)n, 5);\n    }\n    static_init_done = 1;\n\n#  ifdef GEN_TREES_H\n    gen_trees_header();\n#  endif\n#endif /* defined(GEN_TREES_H) || !defined(STDC) */\n}\n\n/* ===========================================================================\n * Genererate the file trees.h describing the static trees.\n */\n#ifdef GEN_TREES_H\n#  ifndef ZLIB_DEBUG\n#    include <stdio.h>\n#  endif\n\n#  define SEPARATOR(i, last, width) \\\n      ((i) == (last)? \"\\n};\\n\\n\" :    \\\n       ((i) % (width) == (width)-1 ? \",\\n\" : \", \"))\n\nvoid gen_trees_header()\n{\n    FILE *header = fopen(\"trees.h\", \"w\");\n    int i;\n\n    Assert (header != NULL, \"Can't open trees.h\");\n    fprintf(header,\n            \"/* header created automatically with -DGEN_TREES_H */\\n\\n\");\n\n    fprintf(header, \"local const ct_data static_ltree[L_CODES+2] = {\\n\");\n    for (i = 0; i < L_CODES+2; i++) {\n        fprintf(header, \"{{%3u},{%3u}}%s\", static_ltree[i].Code,\n                static_ltree[i].Len, SEPARATOR(i, L_CODES+1, 5));\n    }\n\n    fprintf(header, \"local const ct_data static_dtree[D_CODES] = {\\n\");\n    for (i = 0; i < D_CODES; i++) {\n        fprintf(header, \"{{%2u},{%2u}}%s\", static_dtree[i].Code,\n                static_dtree[i].Len, SEPARATOR(i, D_CODES-1, 5));\n    }\n\n    fprintf(header, \"const uch ZLIB_INTERNAL _dist_code[DIST_CODE_LEN] = {\\n\");\n    for (i = 0; i < DIST_CODE_LEN; i++) {\n        fprintf(header, \"%2u%s\", _dist_code[i],\n                SEPARATOR(i, DIST_CODE_LEN-1, 20));\n    }\n\n    fprintf(header,\n        \"const uch ZLIB_INTERNAL _length_code[MAX_MATCH-MIN_MATCH+1]= {\\n\");\n    for (i = 0; i < MAX_MATCH-MIN_MATCH+1; i++) {\n        fprintf(header, \"%2u%s\", _length_code[i],\n                SEPARATOR(i, MAX_MATCH-MIN_MATCH, 20));\n    }\n\n    fprintf(header, \"local const int base_length[LENGTH_CODES] = {\\n\");\n    for (i = 0; i < LENGTH_CODES; i++) {\n        fprintf(header, \"%1u%s\", base_length[i],\n                SEPARATOR(i, LENGTH_CODES-1, 20));\n    }\n\n    fprintf(header, \"local const int base_dist[D_CODES] = {\\n\");\n    for (i = 0; i < D_CODES; i++) {\n        fprintf(header, \"%5u%s\", base_dist[i],\n                SEPARATOR(i, D_CODES-1, 10));\n    }\n\n    fclose(header);\n}\n#endif /* GEN_TREES_H */\n\n/* ===========================================================================\n * Initialize the tree data structures for a new zlib stream.\n */\nvoid ZLIB_INTERNAL _tr_init(s)\n    deflate_state *s;\n{\n    tr_static_init();\n\n    s->l_desc.dyn_tree = s->dyn_ltree;\n    s->l_desc.stat_desc = &static_l_desc;\n\n    s->d_desc.dyn_tree = s->dyn_dtree;\n    s->d_desc.stat_desc = &static_d_desc;\n\n    s->bl_desc.dyn_tree = s->bl_tree;\n    s->bl_desc.stat_desc = &static_bl_desc;\n\n    s->bi_buf = 0;\n    s->bi_valid = 0;\n#ifdef ZLIB_DEBUG\n    s->compressed_len = 0L;\n    s->bits_sent = 0L;\n#endif\n\n    /* Initialize the first block of the first file: */\n    init_block(s);\n}\n\n/* ===========================================================================\n * Initialize a new block.\n */\nlocal void init_block(s)\n    deflate_state *s;\n{\n    int n; /* iterates over tree elements */\n\n    /* Initialize the trees. */\n    for (n = 0; n < L_CODES;  n++) s->dyn_ltree[n].Freq = 0;\n    for (n = 0; n < D_CODES;  n++) s->dyn_dtree[n].Freq = 0;\n    for (n = 0; n < BL_CODES; n++) s->bl_tree[n].Freq = 0;\n\n    s->dyn_ltree[END_BLOCK].Freq = 1;\n    s->opt_len = s->static_len = 0L;\n    s->last_lit = s->matches = 0;\n}\n\n#define SMALLEST 1\n/* Index within the heap array of least frequent node in the Huffman tree */\n\n\n/* ===========================================================================\n * Remove the smallest element from the heap and recreate the heap with\n * one less element. Updates heap and heap_len.\n */\n#define pqremove(s, tree, top) \\\n{\\\n    top = s->heap[SMALLEST]; \\\n    s->heap[SMALLEST] = s->heap[s->heap_len--]; \\\n    pqdownheap(s, tree, SMALLEST); \\\n}\n\n/* ===========================================================================\n * Compares to subtrees, using the tree depth as tie breaker when\n * the subtrees have equal frequency. This minimizes the worst case length.\n */\n#define smaller(tree, n, m, depth) \\\n   (tree[n].Freq < tree[m].Freq || \\\n   (tree[n].Freq == tree[m].Freq && depth[n] <= depth[m]))\n\n/* ===========================================================================\n * Restore the heap property by moving down the tree starting at node k,\n * exchanging a node with the smallest of its two sons if necessary, stopping\n * when the heap property is re-established (each father smaller than its\n * two sons).\n */\nlocal void pqdownheap(s, tree, k)\n    deflate_state *s;\n    ct_data *tree;  /* the tree to restore */\n    int k;               /* node to move down */\n{\n    int v = s->heap[k];\n    int j = k << 1;  /* left son of k */\n    while (j <= s->heap_len) {\n        /* Set j to the smallest of the two sons: */\n        if (j < s->heap_len &&\n            smaller(tree, s->heap[j+1], s->heap[j], s->depth)) {\n            j++;\n        }\n        /* Exit if v is smaller than both sons */\n        if (smaller(tree, v, s->heap[j], s->depth)) break;\n\n        /* Exchange v with the smallest son */\n        s->heap[k] = s->heap[j];  k = j;\n\n        /* And continue down the tree, setting j to the left son of k */\n        j <<= 1;\n    }\n    s->heap[k] = v;\n}\n\n/* ===========================================================================\n * Compute the optimal bit lengths for a tree and update the total bit length\n * for the current block.\n * IN assertion: the fields freq and dad are set, heap[heap_max] and\n *    above are the tree nodes sorted by increasing frequency.\n * OUT assertions: the field len is set to the optimal bit length, the\n *     array bl_count contains the frequencies for each bit length.\n *     The length opt_len is updated; static_len is also updated if stree is\n *     not null.\n */\nlocal void gen_bitlen(s, desc)\n    deflate_state *s;\n    tree_desc *desc;    /* the tree descriptor */\n{\n    ct_data *tree        = desc->dyn_tree;\n    int max_code         = desc->max_code;\n    const ct_data *stree = desc->stat_desc->static_tree;\n    const intf *extra    = desc->stat_desc->extra_bits;\n    int base             = desc->stat_desc->extra_base;\n    int max_length       = desc->stat_desc->max_length;\n    int h;              /* heap index */\n    int n, m;           /* iterate over the tree elements */\n    int bits;           /* bit length */\n    int xbits;          /* extra bits */\n    ush f;              /* frequency */\n    int overflow = 0;   /* number of elements with bit length too large */\n\n    for (bits = 0; bits <= MAX_BITS; bits++) s->bl_count[bits] = 0;\n\n    /* In a first pass, compute the optimal bit lengths (which may\n     * overflow in the case of the bit length tree).\n     */\n    tree[s->heap[s->heap_max]].Len = 0; /* root of the heap */\n\n    for (h = s->heap_max+1; h < HEAP_SIZE; h++) {\n        n = s->heap[h];\n        bits = tree[tree[n].Dad].Len + 1;\n        if (bits > max_length) bits = max_length, overflow++;\n        tree[n].Len = (ush)bits;\n        /* We overwrite tree[n].Dad which is no longer needed */\n\n        if (n > max_code) continue; /* not a leaf node */\n\n        s->bl_count[bits]++;\n        xbits = 0;\n        if (n >= base) xbits = extra[n-base];\n        f = tree[n].Freq;\n        s->opt_len += (ulg)f * (unsigned)(bits + xbits);\n        if (stree) s->static_len += (ulg)f * (unsigned)(stree[n].Len + xbits);\n    }\n    if (overflow == 0) return;\n\n    Tracev((stderr,\"\\nbit length overflow\\n\"));\n    /* This happens for example on obj2 and pic of the Calgary corpus */\n\n    /* Find the first bit length which could increase: */\n    do {\n        bits = max_length-1;\n        while (s->bl_count[bits] == 0) bits--;\n        s->bl_count[bits]--;      /* move one leaf down the tree */\n        s->bl_count[bits+1] += 2; /* move one overflow item as its brother */\n        s->bl_count[max_length]--;\n        /* The brother of the overflow item also moves one step up,\n         * but this does not affect bl_count[max_length]\n         */\n        overflow -= 2;\n    } while (overflow > 0);\n\n    /* Now recompute all bit lengths, scanning in increasing frequency.\n     * h is still equal to HEAP_SIZE. (It is simpler to reconstruct all\n     * lengths instead of fixing only the wrong ones. This idea is taken\n     * from 'ar' written by Haruhiko Okumura.)\n     */\n    for (bits = max_length; bits != 0; bits--) {\n        n = s->bl_count[bits];\n        while (n != 0) {\n            m = s->heap[--h];\n            if (m > max_code) continue;\n            if ((unsigned) tree[m].Len != (unsigned) bits) {\n                Tracev((stderr,\"code %d bits %d->%d\\n\", m, tree[m].Len, bits));\n                s->opt_len += ((ulg)bits - tree[m].Len) * tree[m].Freq;\n                tree[m].Len = (ush)bits;\n            }\n            n--;\n        }\n    }\n}\n\n/* ===========================================================================\n * Generate the codes for a given tree and bit counts (which need not be\n * optimal).\n * IN assertion: the array bl_count contains the bit length statistics for\n * the given tree and the field len is set for all tree elements.\n * OUT assertion: the field code is set for all tree elements of non\n *     zero code length.\n */\nlocal void gen_codes (tree, max_code, bl_count)\n    ct_data *tree;             /* the tree to decorate */\n    int max_code;              /* largest code with non zero frequency */\n    ushf *bl_count;            /* number of codes at each bit length */\n{\n    ush next_code[MAX_BITS+1]; /* next code value for each bit length */\n    unsigned code = 0;         /* running code value */\n    int bits;                  /* bit index */\n    int n;                     /* code index */\n\n    /* The distribution counts are first used to generate the code values\n     * without bit reversal.\n     */\n    for (bits = 1; bits <= MAX_BITS; bits++) {\n        code = (code + bl_count[bits-1]) << 1;\n        next_code[bits] = (ush)code;\n    }\n    /* Check that the bit counts in bl_count are consistent. The last code\n     * must be all ones.\n     */\n    Assert (code + bl_count[MAX_BITS]-1 == (1<<MAX_BITS)-1,\n            \"inconsistent bit counts\");\n    Tracev((stderr,\"\\ngen_codes: max_code %d \", max_code));\n\n    for (n = 0;  n <= max_code; n++) {\n        int len = tree[n].Len;\n        if (len == 0) continue;\n        /* Now reverse the bits */\n        tree[n].Code = (ush)bi_reverse(next_code[len]++, len);\n\n        Tracecv(tree != static_ltree, (stderr,\"\\nn %3d %c l %2d c %4x (%x) \",\n             n, (isgraph(n) ? n : ' '), len, tree[n].Code, next_code[len]-1));\n    }\n}\n\n/* ===========================================================================\n * Construct one Huffman tree and assigns the code bit strings and lengths.\n * Update the total bit length for the current block.\n * IN assertion: the field freq is set for all tree elements.\n * OUT assertions: the fields len and code are set to the optimal bit length\n *     and corresponding code. The length opt_len is updated; static_len is\n *     also updated if stree is not null. The field max_code is set.\n */\nlocal void build_tree(s, desc)\n    deflate_state *s;\n    tree_desc *desc; /* the tree descriptor */\n{\n    ct_data *tree         = desc->dyn_tree;\n    const ct_data *stree  = desc->stat_desc->static_tree;\n    int elems             = desc->stat_desc->elems;\n    int n, m;          /* iterate over heap elements */\n    int max_code = -1; /* largest code with non zero frequency */\n    int node;          /* new node being created */\n\n    /* Construct the initial heap, with least frequent element in\n     * heap[SMALLEST]. The sons of heap[n] are heap[2*n] and heap[2*n+1].\n     * heap[0] is not used.\n     */\n    s->heap_len = 0, s->heap_max = HEAP_SIZE;\n\n    for (n = 0; n < elems; n++) {\n        if (tree[n].Freq != 0) {\n            s->heap[++(s->heap_len)] = max_code = n;\n            s->depth[n] = 0;\n        } else {\n            tree[n].Len = 0;\n        }\n    }\n\n    /* The pkzip format requires that at least one distance code exists,\n     * and that at least one bit should be sent even if there is only one\n     * possible code. So to avoid special checks later on we force at least\n     * two codes of non zero frequency.\n     */\n    while (s->heap_len < 2) {\n        node = s->heap[++(s->heap_len)] = (max_code < 2 ? ++max_code : 0);\n        tree[node].Freq = 1;\n        s->depth[node] = 0;\n        s->opt_len--; if (stree) s->static_len -= stree[node].Len;\n        /* node is 0 or 1 so it does not have extra bits */\n    }\n    desc->max_code = max_code;\n\n    /* The elements heap[heap_len/2+1 .. heap_len] are leaves of the tree,\n     * establish sub-heaps of increasing lengths:\n     */\n    for (n = s->heap_len/2; n >= 1; n--) pqdownheap(s, tree, n);\n\n    /* Construct the Huffman tree by repeatedly combining the least two\n     * frequent nodes.\n     */\n    node = elems;              /* next internal node of the tree */\n    do {\n        pqremove(s, tree, n);  /* n = node of least frequency */\n        m = s->heap[SMALLEST]; /* m = node of next least frequency */\n\n        s->heap[--(s->heap_max)] = n; /* keep the nodes sorted by frequency */\n        s->heap[--(s->heap_max)] = m;\n\n        /* Create a new node father of n and m */\n        tree[node].Freq = tree[n].Freq + tree[m].Freq;\n        s->depth[node] = (uch)((s->depth[n] >= s->depth[m] ?\n                                s->depth[n] : s->depth[m]) + 1);\n        tree[n].Dad = tree[m].Dad = (ush)node;\n#ifdef DUMP_BL_TREE\n        if (tree == s->bl_tree) {\n            fprintf(stderr,\"\\nnode %d(%d), sons %d(%d) %d(%d)\",\n                    node, tree[node].Freq, n, tree[n].Freq, m, tree[m].Freq);\n        }\n#endif\n        /* and insert the new node in the heap */\n        s->heap[SMALLEST] = node++;\n        pqdownheap(s, tree, SMALLEST);\n\n    } while (s->heap_len >= 2);\n\n    s->heap[--(s->heap_max)] = s->heap[SMALLEST];\n\n    /* At this point, the fields freq and dad are set. We can now\n     * generate the bit lengths.\n     */\n    gen_bitlen(s, (tree_desc *)desc);\n\n    /* The field len is now set, we can generate the bit codes */\n    gen_codes ((ct_data *)tree, max_code, s->bl_count);\n}\n\n/* ===========================================================================\n * Scan a literal or distance tree to determine the frequencies of the codes\n * in the bit length tree.\n */\nlocal void scan_tree (s, tree, max_code)\n    deflate_state *s;\n    ct_data *tree;   /* the tree to be scanned */\n    int max_code;    /* and its largest code of non zero frequency */\n{\n    int n;                     /* iterates over all tree elements */\n    int prevlen = -1;          /* last emitted length */\n    int curlen;                /* length of current code */\n    int nextlen = tree[0].Len; /* length of next code */\n    int count = 0;             /* repeat count of the current code */\n    int max_count = 7;         /* max repeat count */\n    int min_count = 4;         /* min repeat count */\n\n    if (nextlen == 0) max_count = 138, min_count = 3;\n    tree[max_code+1].Len = (ush)0xffff; /* guard */\n\n    for (n = 0; n <= max_code; n++) {\n        curlen = nextlen; nextlen = tree[n+1].Len;\n        if (++count < max_count && curlen == nextlen) {\n            continue;\n        } else if (count < min_count) {\n            s->bl_tree[curlen].Freq += count;\n        } else if (curlen != 0) {\n            if (curlen != prevlen) s->bl_tree[curlen].Freq++;\n            s->bl_tree[REP_3_6].Freq++;\n        } else if (count <= 10) {\n            s->bl_tree[REPZ_3_10].Freq++;\n        } else {\n            s->bl_tree[REPZ_11_138].Freq++;\n        }\n        count = 0; prevlen = curlen;\n        if (nextlen == 0) {\n            max_count = 138, min_count = 3;\n        } else if (curlen == nextlen) {\n            max_count = 6, min_count = 3;\n        } else {\n            max_count = 7, min_count = 4;\n        }\n    }\n}\n\n/* ===========================================================================\n * Send a literal or distance tree in compressed form, using the codes in\n * bl_tree.\n */\nlocal void send_tree (s, tree, max_code)\n    deflate_state *s;\n    ct_data *tree; /* the tree to be scanned */\n    int max_code;       /* and its largest code of non zero frequency */\n{\n    int n;                     /* iterates over all tree elements */\n    int prevlen = -1;          /* last emitted length */\n    int curlen;                /* length of current code */\n    int nextlen = tree[0].Len; /* length of next code */\n    int count = 0;             /* repeat count of the current code */\n    int max_count = 7;         /* max repeat count */\n    int min_count = 4;         /* min repeat count */\n\n    /* tree[max_code+1].Len = -1; */  /* guard already set */\n    if (nextlen == 0) max_count = 138, min_count = 3;\n\n    for (n = 0; n <= max_code; n++) {\n        curlen = nextlen; nextlen = tree[n+1].Len;\n        if (++count < max_count && curlen == nextlen) {\n            continue;\n        } else if (count < min_count) {\n            do { send_code(s, curlen, s->bl_tree); } while (--count != 0);\n\n        } else if (curlen != 0) {\n            if (curlen != prevlen) {\n                send_code(s, curlen, s->bl_tree); count--;\n            }\n            Assert(count >= 3 && count <= 6, \" 3_6?\");\n            send_code(s, REP_3_6, s->bl_tree); send_bits(s, count-3, 2);\n\n        } else if (count <= 10) {\n            send_code(s, REPZ_3_10, s->bl_tree); send_bits(s, count-3, 3);\n\n        } else {\n            send_code(s, REPZ_11_138, s->bl_tree); send_bits(s, count-11, 7);\n        }\n        count = 0; prevlen = curlen;\n        if (nextlen == 0) {\n            max_count = 138, min_count = 3;\n        } else if (curlen == nextlen) {\n            max_count = 6, min_count = 3;\n        } else {\n            max_count = 7, min_count = 4;\n        }\n    }\n}\n\n/* ===========================================================================\n * Construct the Huffman tree for the bit lengths and return the index in\n * bl_order of the last bit length code to send.\n */\nlocal int build_bl_tree(s)\n    deflate_state *s;\n{\n    int max_blindex;  /* index of last bit length code of non zero freq */\n\n    /* Determine the bit length frequencies for literal and distance trees */\n    scan_tree(s, (ct_data *)s->dyn_ltree, s->l_desc.max_code);\n    scan_tree(s, (ct_data *)s->dyn_dtree, s->d_desc.max_code);\n\n    /* Build the bit length tree: */\n    build_tree(s, (tree_desc *)(&(s->bl_desc)));\n    /* opt_len now includes the length of the tree representations, except\n     * the lengths of the bit lengths codes and the 5+5+4 bits for the counts.\n     */\n\n    /* Determine the number of bit length codes to send. The pkzip format\n     * requires that at least 4 bit length codes be sent. (appnote.txt says\n     * 3 but the actual value used is 4.)\n     */\n    for (max_blindex = BL_CODES-1; max_blindex >= 3; max_blindex--) {\n        if (s->bl_tree[bl_order[max_blindex]].Len != 0) break;\n    }\n    /* Update opt_len to include the bit length tree and counts */\n    s->opt_len += 3*((ulg)max_blindex+1) + 5+5+4;\n    Tracev((stderr, \"\\ndyn trees: dyn %ld, stat %ld\",\n            s->opt_len, s->static_len));\n\n    return max_blindex;\n}\n\n/* ===========================================================================\n * Send the header for a block using dynamic Huffman trees: the counts, the\n * lengths of the bit length codes, the literal tree and the distance tree.\n * IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4.\n */\nlocal void send_all_trees(s, lcodes, dcodes, blcodes)\n    deflate_state *s;\n    int lcodes, dcodes, blcodes; /* number of codes for each tree */\n{\n    int rank;                    /* index in bl_order */\n\n    Assert (lcodes >= 257 && dcodes >= 1 && blcodes >= 4, \"not enough codes\");\n    Assert (lcodes <= L_CODES && dcodes <= D_CODES && blcodes <= BL_CODES,\n            \"too many codes\");\n    Tracev((stderr, \"\\nbl counts: \"));\n    send_bits(s, lcodes-257, 5); /* not +255 as stated in appnote.txt */\n    send_bits(s, dcodes-1,   5);\n    send_bits(s, blcodes-4,  4); /* not -3 as stated in appnote.txt */\n    for (rank = 0; rank < blcodes; rank++) {\n        Tracev((stderr, \"\\nbl code %2d \", bl_order[rank]));\n        send_bits(s, s->bl_tree[bl_order[rank]].Len, 3);\n    }\n    Tracev((stderr, \"\\nbl tree: sent %ld\", s->bits_sent));\n\n    send_tree(s, (ct_data *)s->dyn_ltree, lcodes-1); /* literal tree */\n    Tracev((stderr, \"\\nlit tree: sent %ld\", s->bits_sent));\n\n    send_tree(s, (ct_data *)s->dyn_dtree, dcodes-1); /* distance tree */\n    Tracev((stderr, \"\\ndist tree: sent %ld\", s->bits_sent));\n}\n\n/* ===========================================================================\n * Send a stored block\n */\nvoid ZLIB_INTERNAL _tr_stored_block(s, buf, stored_len, last)\n    deflate_state *s;\n    charf *buf;       /* input block */\n    ulg stored_len;   /* length of input block */\n    int last;         /* one if this is the last block for a file */\n{\n    send_bits(s, (STORED_BLOCK<<1)+last, 3);    /* send block type */\n    bi_windup(s);        /* align on byte boundary */\n    put_short(s, (ush)stored_len);\n    put_short(s, (ush)~stored_len);\n    zmemcpy(s->pending_buf + s->pending, (Bytef *)buf, stored_len);\n    s->pending += stored_len;\n#ifdef ZLIB_DEBUG\n    s->compressed_len = (s->compressed_len + 3 + 7) & (ulg)~7L;\n    s->compressed_len += (stored_len + 4) << 3;\n    s->bits_sent += 2*16;\n    s->bits_sent += stored_len<<3;\n#endif\n}\n\n/* ===========================================================================\n * Flush the bits in the bit buffer to pending output (leaves at most 7 bits)\n */\nvoid ZLIB_INTERNAL _tr_flush_bits(s)\n    deflate_state *s;\n{\n    bi_flush(s);\n}\n\n/* ===========================================================================\n * Send one empty static block to give enough lookahead for inflate.\n * This takes 10 bits, of which 7 may remain in the bit buffer.\n */\nvoid ZLIB_INTERNAL _tr_align(s)\n    deflate_state *s;\n{\n    send_bits(s, STATIC_TREES<<1, 3);\n    send_code(s, END_BLOCK, static_ltree);\n#ifdef ZLIB_DEBUG\n    s->compressed_len += 10L; /* 3 for block type, 7 for EOB */\n#endif\n    bi_flush(s);\n}\n\n/* ===========================================================================\n * Determine the best encoding for the current block: dynamic trees, static\n * trees or store, and write out the encoded block.\n */\nvoid ZLIB_INTERNAL _tr_flush_block(s, buf, stored_len, last)\n    deflate_state *s;\n    charf *buf;       /* input block, or NULL if too old */\n    ulg stored_len;   /* length of input block */\n    int last;         /* one if this is the last block for a file */\n{\n    ulg opt_lenb, static_lenb; /* opt_len and static_len in bytes */\n    int max_blindex = 0;  /* index of last bit length code of non zero freq */\n\n    /* Build the Huffman trees unless a stored block is forced */\n    if (s->level > 0) {\n\n        /* Check if the file is binary or text */\n        if (s->strm->data_type == Z_UNKNOWN)\n            s->strm->data_type = detect_data_type(s);\n\n        /* Construct the literal and distance trees */\n        build_tree(s, (tree_desc *)(&(s->l_desc)));\n        Tracev((stderr, \"\\nlit data: dyn %ld, stat %ld\", s->opt_len,\n                s->static_len));\n\n        build_tree(s, (tree_desc *)(&(s->d_desc)));\n        Tracev((stderr, \"\\ndist data: dyn %ld, stat %ld\", s->opt_len,\n                s->static_len));\n        /* At this point, opt_len and static_len are the total bit lengths of\n         * the compressed block data, excluding the tree representations.\n         */\n\n        /* Build the bit length tree for the above two trees, and get the index\n         * in bl_order of the last bit length code to send.\n         */\n        max_blindex = build_bl_tree(s);\n\n        /* Determine the best encoding. Compute the block lengths in bytes. */\n        opt_lenb = (s->opt_len+3+7)>>3;\n        static_lenb = (s->static_len+3+7)>>3;\n\n        Tracev((stderr, \"\\nopt %lu(%lu) stat %lu(%lu) stored %lu lit %u \",\n                opt_lenb, s->opt_len, static_lenb, s->static_len, stored_len,\n                s->last_lit));\n\n        if (static_lenb <= opt_lenb) opt_lenb = static_lenb;\n\n    } else {\n        Assert(buf != (char*)0, \"lost buf\");\n        opt_lenb = static_lenb = stored_len + 5; /* force a stored block */\n    }\n\n#ifdef FORCE_STORED\n    if (buf != (char*)0) { /* force stored block */\n#else\n    if (stored_len+4 <= opt_lenb && buf != (char*)0) {\n                       /* 4: two words for the lengths */\n#endif\n        /* The test buf != NULL is only necessary if LIT_BUFSIZE > WSIZE.\n         * Otherwise we can't have processed more than WSIZE input bytes since\n         * the last block flush, because compression would have been\n         * successful. If LIT_BUFSIZE <= WSIZE, it is never too late to\n         * transform a block into a stored block.\n         */\n        _tr_stored_block(s, buf, stored_len, last);\n\n#ifdef FORCE_STATIC\n    } else if (static_lenb >= 0) { /* force static trees */\n#else\n    } else if (s->strategy == Z_FIXED || static_lenb == opt_lenb) {\n#endif\n        send_bits(s, (STATIC_TREES<<1)+last, 3);\n        compress_block(s, (const ct_data *)static_ltree,\n                       (const ct_data *)static_dtree);\n#ifdef ZLIB_DEBUG\n        s->compressed_len += 3 + s->static_len;\n#endif\n    } else {\n        send_bits(s, (DYN_TREES<<1)+last, 3);\n        send_all_trees(s, s->l_desc.max_code+1, s->d_desc.max_code+1,\n                       max_blindex+1);\n        compress_block(s, (const ct_data *)s->dyn_ltree,\n                       (const ct_data *)s->dyn_dtree);\n#ifdef ZLIB_DEBUG\n        s->compressed_len += 3 + s->opt_len;\n#endif\n    }\n    Assert (s->compressed_len == s->bits_sent, \"bad compressed size\");\n    /* The above check is made mod 2^32, for files larger than 512 MB\n     * and uLong implemented on 32 bits.\n     */\n    init_block(s);\n\n    if (last) {\n        bi_windup(s);\n#ifdef ZLIB_DEBUG\n        s->compressed_len += 7;  /* align on byte boundary */\n#endif\n    }\n    Tracev((stderr,\"\\ncomprlen %lu(%lu) \", s->compressed_len>>3,\n           s->compressed_len-7*last));\n}\n\n/* ===========================================================================\n * Save the match info and tally the frequency counts. Return true if\n * the current block must be flushed.\n */\nint ZLIB_INTERNAL _tr_tally (s, dist, lc)\n    deflate_state *s;\n    unsigned dist;  /* distance of matched string */\n    unsigned lc;    /* match length-MIN_MATCH or unmatched char (if dist==0) */\n{\n    s->d_buf[s->last_lit] = (ush)dist;\n    s->l_buf[s->last_lit++] = (uch)lc;\n    if (dist == 0) {\n        /* lc is the unmatched char */\n        s->dyn_ltree[lc].Freq++;\n    } else {\n        s->matches++;\n        /* Here, lc is the match length - MIN_MATCH */\n        dist--;             /* dist = match distance - 1 */\n        Assert((ush)dist < (ush)MAX_DIST(s) &&\n               (ush)lc <= (ush)(MAX_MATCH-MIN_MATCH) &&\n               (ush)d_code(dist) < (ush)D_CODES,  \"_tr_tally: bad match\");\n\n        s->dyn_ltree[_length_code[lc]+LITERALS+1].Freq++;\n        s->dyn_dtree[d_code(dist)].Freq++;\n    }\n\n#ifdef TRUNCATE_BLOCK\n    /* Try to guess if it is profitable to stop the current block here */\n    if ((s->last_lit & 0x1fff) == 0 && s->level > 2) {\n        /* Compute an upper bound for the compressed length */\n        ulg out_length = (ulg)s->last_lit*8L;\n        ulg in_length = (ulg)((long)s->strstart - s->block_start);\n        int dcode;\n        for (dcode = 0; dcode < D_CODES; dcode++) {\n            out_length += (ulg)s->dyn_dtree[dcode].Freq *\n                (5L+extra_dbits[dcode]);\n        }\n        out_length >>= 3;\n        Tracev((stderr,\"\\nlast_lit %u, in %ld, out ~%ld(%ld%%) \",\n               s->last_lit, in_length, out_length,\n               100L - out_length*100L/in_length));\n        if (s->matches < s->last_lit/2 && out_length < in_length/2) return 1;\n    }\n#endif\n    return (s->last_lit == s->lit_bufsize-1);\n    /* We avoid equality with lit_bufsize because of wraparound at 64K\n     * on 16 bit machines and because stored blocks are restricted to\n     * 64K-1 bytes.\n     */\n}\n\n/* ===========================================================================\n * Send the block data compressed using the given Huffman trees\n */\nlocal void compress_block(s, ltree, dtree)\n    deflate_state *s;\n    const ct_data *ltree; /* literal tree */\n    const ct_data *dtree; /* distance tree */\n{\n    unsigned dist;      /* distance of matched string */\n    int lc;             /* match length or unmatched char (if dist == 0) */\n    unsigned lx = 0;    /* running index in l_buf */\n    unsigned code;      /* the code to send */\n    int extra;          /* number of extra bits to send */\n\n    if (s->last_lit != 0) do {\n        dist = s->d_buf[lx];\n        lc = s->l_buf[lx++];\n        if (dist == 0) {\n            send_code(s, lc, ltree); /* send a literal byte */\n            Tracecv(isgraph(lc), (stderr,\" '%c' \", lc));\n        } else {\n            /* Here, lc is the match length - MIN_MATCH */\n            code = _length_code[lc];\n            send_code(s, code+LITERALS+1, ltree); /* send the length code */\n            extra = extra_lbits[code];\n            if (extra != 0) {\n                lc -= base_length[code];\n                send_bits(s, lc, extra);       /* send the extra length bits */\n            }\n            dist--; /* dist is now the match distance - 1 */\n            code = d_code(dist);\n            Assert (code < D_CODES, \"bad d_code\");\n\n            send_code(s, code, dtree);       /* send the distance code */\n            extra = extra_dbits[code];\n            if (extra != 0) {\n                dist -= (unsigned)base_dist[code];\n                send_bits(s, dist, extra);   /* send the extra distance bits */\n            }\n        } /* literal or match pair ? */\n\n        /* Check that the overlay between pending_buf and d_buf+l_buf is ok: */\n        Assert((uInt)(s->pending) < s->lit_bufsize + 2*lx,\n               \"pendingBuf overflow\");\n\n    } while (lx < s->last_lit);\n\n    send_code(s, END_BLOCK, ltree);\n}\n\n/* ===========================================================================\n * Check if the data type is TEXT or BINARY, using the following algorithm:\n * - TEXT if the two conditions below are satisfied:\n *    a) There are no non-portable control characters belonging to the\n *       \"black list\" (0..6, 14..25, 28..31).\n *    b) There is at least one printable character belonging to the\n *       \"white list\" (9 {TAB}, 10 {LF}, 13 {CR}, 32..255).\n * - BINARY otherwise.\n * - The following partially-portable control characters form a\n *   \"gray list\" that is ignored in this detection algorithm:\n *   (7 {BEL}, 8 {BS}, 11 {VT}, 12 {FF}, 26 {SUB}, 27 {ESC}).\n * IN assertion: the fields Freq of dyn_ltree are set.\n */\nlocal int detect_data_type(s)\n    deflate_state *s;\n{\n    /* black_mask is the bit mask of black-listed bytes\n     * set bits 0..6, 14..25, and 28..31\n     * 0xf3ffc07f = binary 11110011111111111100000001111111\n     */\n    unsigned long black_mask = 0xf3ffc07fUL;\n    int n;\n\n    /* Check for non-textual (\"black-listed\") bytes. */\n    for (n = 0; n <= 31; n++, black_mask >>= 1)\n        if ((black_mask & 1) && (s->dyn_ltree[n].Freq != 0))\n            return Z_BINARY;\n\n    /* Check for textual (\"white-listed\") bytes. */\n    if (s->dyn_ltree[9].Freq != 0 || s->dyn_ltree[10].Freq != 0\n            || s->dyn_ltree[13].Freq != 0)\n        return Z_TEXT;\n    for (n = 32; n < LITERALS; n++)\n        if (s->dyn_ltree[n].Freq != 0)\n            return Z_TEXT;\n\n    /* There are no \"black-listed\" or \"white-listed\" bytes:\n     * this stream either is empty or has tolerated (\"gray-listed\") bytes only.\n     */\n    return Z_BINARY;\n}\n\n/* ===========================================================================\n * Reverse the first len bits of a code, using straightforward code (a faster\n * method would use a table)\n * IN assertion: 1 <= len <= 15\n */\nlocal unsigned bi_reverse(code, len)\n    unsigned code; /* the value to invert */\n    int len;       /* its bit length */\n{\n    register unsigned res = 0;\n    do {\n        res |= code & 1;\n        code >>= 1, res <<= 1;\n    } while (--len > 0);\n    return res >> 1;\n}\n\n/* ===========================================================================\n * Flush the bit buffer, keeping at most 7 bits in it.\n */\nlocal void bi_flush(s)\n    deflate_state *s;\n{\n    if (s->bi_valid == 16) {\n        put_short(s, s->bi_buf);\n        s->bi_buf = 0;\n        s->bi_valid = 0;\n    } else if (s->bi_valid >= 8) {\n        put_byte(s, (Byte)s->bi_buf);\n        s->bi_buf >>= 8;\n        s->bi_valid -= 8;\n    }\n}\n\n/* ===========================================================================\n * Flush the bit buffer and align the output on a byte boundary\n */\nlocal void bi_windup(s)\n    deflate_state *s;\n{\n    if (s->bi_valid > 8) {\n        put_short(s, s->bi_buf);\n    } else if (s->bi_valid > 0) {\n        put_byte(s, (Byte)s->bi_buf);\n    }\n    s->bi_buf = 0;\n    s->bi_valid = 0;\n#ifdef ZLIB_DEBUG\n    s->bits_sent = (s->bits_sent+7) & ~7;\n#endif\n}\n"
  },
  {
    "path": "Projects/Libraries/CSBase/Source/zlib/trees.h",
    "content": "/* header created automatically with -DGEN_TREES_H */\n\nlocal const ct_data static_ltree[L_CODES+2] = {\n{{ 12},{  8}}, {{140},{  8}}, {{ 76},{  8}}, {{204},{  8}}, {{ 44},{  8}},\n{{172},{  8}}, {{108},{  8}}, {{236},{  8}}, {{ 28},{  8}}, {{156},{  8}},\n{{ 92},{  8}}, {{220},{  8}}, {{ 60},{  8}}, {{188},{  8}}, {{124},{  8}},\n{{252},{  8}}, {{  2},{  8}}, {{130},{  8}}, {{ 66},{  8}}, {{194},{  8}},\n{{ 34},{  8}}, {{162},{  8}}, {{ 98},{  8}}, {{226},{  8}}, {{ 18},{  8}},\n{{146},{  8}}, {{ 82},{  8}}, {{210},{  8}}, {{ 50},{  8}}, {{178},{  8}},\n{{114},{  8}}, {{242},{  8}}, {{ 10},{  8}}, {{138},{  8}}, {{ 74},{  8}},\n{{202},{  8}}, {{ 42},{  8}}, {{170},{  8}}, {{106},{  8}}, {{234},{  8}},\n{{ 26},{  8}}, {{154},{  8}}, {{ 90},{  8}}, {{218},{  8}}, {{ 58},{  8}},\n{{186},{  8}}, {{122},{  8}}, {{250},{  8}}, {{  6},{  8}}, {{134},{  8}},\n{{ 70},{  8}}, {{198},{  8}}, {{ 38},{  8}}, {{166},{  8}}, {{102},{  8}},\n{{230},{  8}}, {{ 22},{  8}}, {{150},{  8}}, {{ 86},{  8}}, {{214},{  8}},\n{{ 54},{  8}}, {{182},{  8}}, {{118},{  8}}, {{246},{  8}}, {{ 14},{  8}},\n{{142},{  8}}, {{ 78},{  8}}, {{206},{  8}}, {{ 46},{  8}}, {{174},{  8}},\n{{110},{  8}}, {{238},{  8}}, {{ 30},{  8}}, {{158},{  8}}, {{ 94},{  8}},\n{{222},{  8}}, {{ 62},{  8}}, {{190},{  8}}, {{126},{  8}}, {{254},{  8}},\n{{  1},{  8}}, {{129},{  8}}, {{ 65},{  8}}, {{193},{  8}}, {{ 33},{  8}},\n{{161},{  8}}, {{ 97},{  8}}, {{225},{  8}}, {{ 17},{  8}}, {{145},{  8}},\n{{ 81},{  8}}, {{209},{  8}}, {{ 49},{  8}}, {{177},{  8}}, {{113},{  8}},\n{{241},{  8}}, {{  9},{  8}}, {{137},{  8}}, {{ 73},{  8}}, {{201},{  8}},\n{{ 41},{  8}}, {{169},{  8}}, {{105},{  8}}, {{233},{  8}}, {{ 25},{  8}},\n{{153},{  8}}, {{ 89},{  8}}, {{217},{  8}}, {{ 57},{  8}}, {{185},{  8}},\n{{121},{  8}}, {{249},{  8}}, {{  5},{  8}}, {{133},{  8}}, {{ 69},{  8}},\n{{197},{  8}}, {{ 37},{  8}}, {{165},{  8}}, {{101},{  8}}, {{229},{  8}},\n{{ 21},{  8}}, {{149},{  8}}, {{ 85},{  8}}, {{213},{  8}}, {{ 53},{  8}},\n{{181},{  8}}, {{117},{  8}}, {{245},{  8}}, {{ 13},{  8}}, {{141},{  8}},\n{{ 77},{  8}}, {{205},{  8}}, {{ 45},{  8}}, {{173},{  8}}, {{109},{  8}},\n{{237},{  8}}, {{ 29},{  8}}, {{157},{  8}}, {{ 93},{  8}}, {{221},{  8}},\n{{ 61},{  8}}, {{189},{  8}}, {{125},{  8}}, {{253},{  8}}, {{ 19},{  9}},\n{{275},{  9}}, {{147},{  9}}, {{403},{  9}}, {{ 83},{  9}}, {{339},{  9}},\n{{211},{  9}}, {{467},{  9}}, {{ 51},{  9}}, {{307},{  9}}, {{179},{  9}},\n{{435},{  9}}, {{115},{  9}}, {{371},{  9}}, {{243},{  9}}, {{499},{  9}},\n{{ 11},{  9}}, {{267},{  9}}, {{139},{  9}}, {{395},{  9}}, {{ 75},{  9}},\n{{331},{  9}}, {{203},{  9}}, {{459},{  9}}, {{ 43},{  9}}, {{299},{  9}},\n{{171},{  9}}, {{427},{  9}}, {{107},{  9}}, {{363},{  9}}, {{235},{  9}},\n{{491},{  9}}, {{ 27},{  9}}, {{283},{  9}}, {{155},{  9}}, {{411},{  9}},\n{{ 91},{  9}}, {{347},{  9}}, {{219},{  9}}, {{475},{  9}}, {{ 59},{  9}},\n{{315},{  9}}, {{187},{  9}}, {{443},{  9}}, {{123},{  9}}, {{379},{  9}},\n{{251},{  9}}, {{507},{  9}}, {{  7},{  9}}, {{263},{  9}}, {{135},{  9}},\n{{391},{  9}}, {{ 71},{  9}}, {{327},{  9}}, {{199},{  9}}, {{455},{  9}},\n{{ 39},{  9}}, {{295},{  9}}, {{167},{  9}}, {{423},{  9}}, {{103},{  9}},\n{{359},{  9}}, {{231},{  9}}, {{487},{  9}}, {{ 23},{  9}}, {{279},{  9}},\n{{151},{  9}}, {{407},{  9}}, {{ 87},{  9}}, {{343},{  9}}, {{215},{  9}},\n{{471},{  9}}, {{ 55},{  9}}, {{311},{  9}}, {{183},{  9}}, {{439},{  9}},\n{{119},{  9}}, {{375},{  9}}, {{247},{  9}}, {{503},{  9}}, {{ 15},{  9}},\n{{271},{  9}}, {{143},{  9}}, {{399},{  9}}, {{ 79},{  9}}, {{335},{  9}},\n{{207},{  9}}, {{463},{  9}}, {{ 47},{  9}}, {{303},{  9}}, {{175},{  9}},\n{{431},{  9}}, {{111},{  9}}, {{367},{  9}}, {{239},{  9}}, {{495},{  9}},\n{{ 31},{  9}}, {{287},{  9}}, {{159},{  9}}, {{415},{  9}}, {{ 95},{  9}},\n{{351},{  9}}, {{223},{  9}}, {{479},{  9}}, {{ 63},{  9}}, {{319},{  9}},\n{{191},{  9}}, {{447},{  9}}, {{127},{  9}}, {{383},{  9}}, {{255},{  9}},\n{{511},{  9}}, {{  0},{  7}}, {{ 64},{  7}}, {{ 32},{  7}}, {{ 96},{  7}},\n{{ 16},{  7}}, {{ 80},{  7}}, {{ 48},{  7}}, {{112},{  7}}, {{  8},{  7}},\n{{ 72},{  7}}, {{ 40},{  7}}, {{104},{  7}}, {{ 24},{  7}}, {{ 88},{  7}},\n{{ 56},{  7}}, {{120},{  7}}, {{  4},{  7}}, {{ 68},{  7}}, {{ 36},{  7}},\n{{100},{  7}}, {{ 20},{  7}}, {{ 84},{  7}}, {{ 52},{  7}}, {{116},{  7}},\n{{  3},{  8}}, {{131},{  8}}, {{ 67},{  8}}, {{195},{  8}}, {{ 35},{  8}},\n{{163},{  8}}, {{ 99},{  8}}, {{227},{  8}}\n};\n\nlocal const ct_data static_dtree[D_CODES] = {\n{{ 0},{ 5}}, {{16},{ 5}}, {{ 8},{ 5}}, {{24},{ 5}}, {{ 4},{ 5}},\n{{20},{ 5}}, {{12},{ 5}}, {{28},{ 5}}, {{ 2},{ 5}}, {{18},{ 5}},\n{{10},{ 5}}, {{26},{ 5}}, {{ 6},{ 5}}, {{22},{ 5}}, {{14},{ 5}},\n{{30},{ 5}}, {{ 1},{ 5}}, {{17},{ 5}}, {{ 9},{ 5}}, {{25},{ 5}},\n{{ 5},{ 5}}, {{21},{ 5}}, {{13},{ 5}}, {{29},{ 5}}, {{ 3},{ 5}},\n{{19},{ 5}}, {{11},{ 5}}, {{27},{ 5}}, {{ 7},{ 5}}, {{23},{ 5}}\n};\n\nconst uch ZLIB_INTERNAL _dist_code[DIST_CODE_LEN] = {\n 0,  1,  2,  3,  4,  4,  5,  5,  6,  6,  6,  6,  7,  7,  7,  7,  8,  8,  8,  8,\n 8,  8,  8,  8,  9,  9,  9,  9,  9,  9,  9,  9, 10, 10, 10, 10, 10, 10, 10, 10,\n10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,\n11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,\n12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13,\n13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,\n13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,\n14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,\n14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,\n14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15,\n15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,\n15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,\n15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,  0,  0, 16, 17,\n18, 18, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22,\n23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,\n24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,\n26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,\n26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27,\n27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,\n27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,\n28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,\n28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,\n28, 28, 28, 28, 28, 28, 28, 28, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,\n29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,\n29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,\n29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29\n};\n\nconst uch ZLIB_INTERNAL _length_code[MAX_MATCH-MIN_MATCH+1]= {\n 0,  1,  2,  3,  4,  5,  6,  7,  8,  8,  9,  9, 10, 10, 11, 11, 12, 12, 12, 12,\n13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16,\n17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19,\n19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,\n21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22,\n22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23,\n23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,\n24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,\n25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,\n25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 26, 26, 26,\n26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,\n26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,\n27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28\n};\n\nlocal const int base_length[LENGTH_CODES] = {\n0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 20, 24, 28, 32, 40, 48, 56,\n64, 80, 96, 112, 128, 160, 192, 224, 0\n};\n\nlocal const int base_dist[D_CODES] = {\n    0,     1,     2,     3,     4,     6,     8,    12,    16,    24,\n   32,    48,    64,    96,   128,   192,   256,   384,   512,   768,\n 1024,  1536,  2048,  3072,  4096,  6144,  8192, 12288, 16384, 24576\n};\n\n"
  },
  {
    "path": "Projects/Libraries/CSBase/Source/zlib/uncompr.c",
    "content": "/* uncompr.c -- decompress a memory buffer\n * Copyright (C) 1995-2003, 2010, 2014, 2016 Jean-loup Gailly, Mark Adler\n * For conditions of distribution and use, see copyright notice in zlib.h\n */\n\n/* @(#) $Id$ */\n\n#define ZLIB_INTERNAL\n#include \"zlib.h\"\n\n/* ===========================================================================\n     Decompresses the source buffer into the destination buffer.  *sourceLen is\n   the byte length of the source buffer. Upon entry, *destLen is the total size\n   of the destination buffer, which must be large enough to hold the entire\n   uncompressed data. (The size of the uncompressed data must have been saved\n   previously by the compressor and transmitted to the decompressor by some\n   mechanism outside the scope of this compression library.) Upon exit,\n   *destLen is the size of the decompressed data and *sourceLen is the number\n   of source bytes consumed. Upon return, source + *sourceLen points to the\n   first unused input byte.\n\n     uncompress returns Z_OK if success, Z_MEM_ERROR if there was not enough\n   memory, Z_BUF_ERROR if there was not enough room in the output buffer, or\n   Z_DATA_ERROR if the input data was corrupted, including if the input data is\n   an incomplete zlib stream.\n*/\nint ZEXPORT uncompress2 (dest, destLen, source, sourceLen)\n    Bytef *dest;\n    uLongf *destLen;\n    const Bytef *source;\n    uLong *sourceLen;\n{\n    z_stream stream;\n    int err;\n    const uInt max = (uInt)-1;\n    uLong len, left;\n    Byte buf[1];    /* for detection of incomplete stream when *destLen == 0 */\n\n    len = *sourceLen;\n    if (*destLen) {\n        left = *destLen;\n        *destLen = 0;\n    }\n    else {\n        left = 1;\n        dest = buf;\n    }\n\n    stream.next_in = (z_const Bytef *)source;\n    stream.avail_in = 0;\n    stream.zalloc = (alloc_func)0;\n    stream.zfree = (free_func)0;\n    stream.opaque = (voidpf)0;\n\n    err = inflateInit(&stream);\n    if (err != Z_OK) return err;\n\n    stream.next_out = dest;\n    stream.avail_out = 0;\n\n    do {\n        if (stream.avail_out == 0) {\n            stream.avail_out = left > (uLong)max ? max : (uInt)left;\n            left -= stream.avail_out;\n        }\n        if (stream.avail_in == 0) {\n            stream.avail_in = len > (uLong)max ? max : (uInt)len;\n            len -= stream.avail_in;\n        }\n        err = inflate(&stream, Z_NO_FLUSH);\n    } while (err == Z_OK);\n\n    *sourceLen -= len + stream.avail_in;\n    if (dest != buf)\n        *destLen = stream.total_out;\n    else if (stream.total_out && err == Z_BUF_ERROR)\n        left = 1;\n\n    inflateEnd(&stream);\n    return err == Z_STREAM_END ? Z_OK :\n           err == Z_NEED_DICT ? Z_DATA_ERROR  :\n           err == Z_BUF_ERROR && left + stream.avail_out ? Z_DATA_ERROR :\n           err;\n}\n\nint ZEXPORT uncompress (dest, destLen, source, sourceLen)\n    Bytef *dest;\n    uLongf *destLen;\n    const Bytef *source;\n    uLong sourceLen;\n{\n    return uncompress2(dest, destLen, source, &sourceLen);\n}\n"
  },
  {
    "path": "Projects/Libraries/CSBase/Source/zlib/zconf.h",
    "content": "/* zconf.h -- configuration of the zlib compression library\n * Copyright (C) 1995-2016 Jean-loup Gailly, Mark Adler\n * For conditions of distribution and use, see copyright notice in zlib.h\n */\n\n/* @(#) $Id$ */\n\n#ifndef ZCONF_H\n#define ZCONF_H\n\n/*\n * If you *really* need a unique prefix for all types and library functions,\n * compile with -DZ_PREFIX. The \"standard\" zlib should be compiled without it.\n * Even better than compiling with -DZ_PREFIX would be to use configure to set\n * this permanently in zconf.h using \"./configure --zprefix\".\n */\n#ifdef Z_PREFIX     /* may be set to #if 1 by ./configure */\n#  define Z_PREFIX_SET\n\n/* all linked symbols and init macros */\n#  define _dist_code            z__dist_code\n#  define _length_code          z__length_code\n#  define _tr_align             z__tr_align\n#  define _tr_flush_bits        z__tr_flush_bits\n#  define _tr_flush_block       z__tr_flush_block\n#  define _tr_init              z__tr_init\n#  define _tr_stored_block      z__tr_stored_block\n#  define _tr_tally             z__tr_tally\n#  define adler32               z_adler32\n#  define adler32_combine       z_adler32_combine\n#  define adler32_combine64     z_adler32_combine64\n#  define adler32_z             z_adler32_z\n#  ifndef Z_SOLO\n#    define compress              z_compress\n#    define compress2             z_compress2\n#    define compressBound         z_compressBound\n#  endif\n#  define crc32                 z_crc32\n#  define crc32_combine         z_crc32_combine\n#  define crc32_combine64       z_crc32_combine64\n#  define crc32_z               z_crc32_z\n#  define deflate               z_deflate\n#  define deflateBound          z_deflateBound\n#  define deflateCopy           z_deflateCopy\n#  define deflateEnd            z_deflateEnd\n#  define deflateGetDictionary  z_deflateGetDictionary\n#  define deflateInit           z_deflateInit\n#  define deflateInit2          z_deflateInit2\n#  define deflateInit2_         z_deflateInit2_\n#  define deflateInit_          z_deflateInit_\n#  define deflateParams         z_deflateParams\n#  define deflatePending        z_deflatePending\n#  define deflatePrime          z_deflatePrime\n#  define deflateReset          z_deflateReset\n#  define deflateResetKeep      z_deflateResetKeep\n#  define deflateSetDictionary  z_deflateSetDictionary\n#  define deflateSetHeader      z_deflateSetHeader\n#  define deflateTune           z_deflateTune\n#  define deflate_copyright     z_deflate_copyright\n#  define get_crc_table         z_get_crc_table\n#  ifndef Z_SOLO\n#    define gz_error              z_gz_error\n#    define gz_intmax             z_gz_intmax\n#    define gz_strwinerror        z_gz_strwinerror\n#    define gzbuffer              z_gzbuffer\n#    define gzclearerr            z_gzclearerr\n#    define gzclose               z_gzclose\n#    define gzclose_r             z_gzclose_r\n#    define gzclose_w             z_gzclose_w\n#    define gzdirect              z_gzdirect\n#    define gzdopen               z_gzdopen\n#    define gzeof                 z_gzeof\n#    define gzerror               z_gzerror\n#    define gzflush               z_gzflush\n#    define gzfread               z_gzfread\n#    define gzfwrite              z_gzfwrite\n#    define gzgetc                z_gzgetc\n#    define gzgetc_               z_gzgetc_\n#    define gzgets                z_gzgets\n#    define gzoffset              z_gzoffset\n#    define gzoffset64            z_gzoffset64\n#    define gzopen                z_gzopen\n#    define gzopen64              z_gzopen64\n#    ifdef _WIN32\n#      define gzopen_w              z_gzopen_w\n#    endif\n#    define gzprintf              z_gzprintf\n#    define gzputc                z_gzputc\n#    define gzputs                z_gzputs\n#    define gzread                z_gzread\n#    define gzrewind              z_gzrewind\n#    define gzseek                z_gzseek\n#    define gzseek64              z_gzseek64\n#    define gzsetparams           z_gzsetparams\n#    define gztell                z_gztell\n#    define gztell64              z_gztell64\n#    define gzungetc              z_gzungetc\n#    define gzvprintf             z_gzvprintf\n#    define gzwrite               z_gzwrite\n#  endif\n#  define inflate               z_inflate\n#  define inflateBack           z_inflateBack\n#  define inflateBackEnd        z_inflateBackEnd\n#  define inflateBackInit       z_inflateBackInit\n#  define inflateBackInit_      z_inflateBackInit_\n#  define inflateCodesUsed      z_inflateCodesUsed\n#  define inflateCopy           z_inflateCopy\n#  define inflateEnd            z_inflateEnd\n#  define inflateGetDictionary  z_inflateGetDictionary\n#  define inflateGetHeader      z_inflateGetHeader\n#  define inflateInit           z_inflateInit\n#  define inflateInit2          z_inflateInit2\n#  define inflateInit2_         z_inflateInit2_\n#  define inflateInit_          z_inflateInit_\n#  define inflateMark           z_inflateMark\n#  define inflatePrime          z_inflatePrime\n#  define inflateReset          z_inflateReset\n#  define inflateReset2         z_inflateReset2\n#  define inflateResetKeep      z_inflateResetKeep\n#  define inflateSetDictionary  z_inflateSetDictionary\n#  define inflateSync           z_inflateSync\n#  define inflateSyncPoint      z_inflateSyncPoint\n#  define inflateUndermine      z_inflateUndermine\n#  define inflateValidate       z_inflateValidate\n#  define inflate_copyright     z_inflate_copyright\n#  define inflate_fast          z_inflate_fast\n#  define inflate_table         z_inflate_table\n#  ifndef Z_SOLO\n#    define uncompress            z_uncompress\n#    define uncompress2           z_uncompress2\n#  endif\n#  define zError                z_zError\n#  ifndef Z_SOLO\n#    define zcalloc               z_zcalloc\n#    define zcfree                z_zcfree\n#  endif\n#  define zlibCompileFlags      z_zlibCompileFlags\n#  define zlibVersion           z_zlibVersion\n\n/* all zlib typedefs in zlib.h and zconf.h */\n#  define Byte                  z_Byte\n#  define Bytef                 z_Bytef\n#  define alloc_func            z_alloc_func\n#  define charf                 z_charf\n#  define free_func             z_free_func\n#  ifndef Z_SOLO\n#    define gzFile                z_gzFile\n#  endif\n#  define gz_header             z_gz_header\n#  define gz_headerp            z_gz_headerp\n#  define in_func               z_in_func\n#  define intf                  z_intf\n#  define out_func              z_out_func\n#  define uInt                  z_uInt\n#  define uIntf                 z_uIntf\n#  define uLong                 z_uLong\n#  define uLongf                z_uLongf\n#  define voidp                 z_voidp\n#  define voidpc                z_voidpc\n#  define voidpf                z_voidpf\n\n/* all zlib structs in zlib.h and zconf.h */\n#  define gz_header_s           z_gz_header_s\n#  define internal_state        z_internal_state\n\n#endif\n\n#if defined(__MSDOS__) && !defined(MSDOS)\n#  define MSDOS\n#endif\n#if (defined(OS_2) || defined(__OS2__)) && !defined(OS2)\n#  define OS2\n#endif\n#if defined(_WINDOWS) && !defined(WINDOWS)\n#  define WINDOWS\n#endif\n#if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__)\n#  ifndef WIN32\n#    define WIN32\n#  endif\n#endif\n#if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32)\n#  if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__)\n#    ifndef SYS16BIT\n#      define SYS16BIT\n#    endif\n#  endif\n#endif\n\n/*\n * Compile with -DMAXSEG_64K if the alloc function cannot allocate more\n * than 64k bytes at a time (needed on systems with 16-bit int).\n */\n#ifdef SYS16BIT\n#  define MAXSEG_64K\n#endif\n#ifdef MSDOS\n#  define UNALIGNED_OK\n#endif\n\n#ifdef __STDC_VERSION__\n#  ifndef STDC\n#    define STDC\n#  endif\n#  if __STDC_VERSION__ >= 199901L\n#    ifndef STDC99\n#      define STDC99\n#    endif\n#  endif\n#endif\n#if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus))\n#  define STDC\n#endif\n#if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__))\n#  define STDC\n#endif\n#if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32))\n#  define STDC\n#endif\n#if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__))\n#  define STDC\n#endif\n\n#if defined(__OS400__) && !defined(STDC)    /* iSeries (formerly AS/400). */\n#  define STDC\n#endif\n\n#ifndef STDC\n#  ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */\n#    define const       /* note: need a more gentle solution here */\n#  endif\n#endif\n\n#if defined(ZLIB_CONST) && !defined(z_const)\n#  define z_const const\n#else\n#  define z_const\n#endif\n\n#ifdef Z_SOLO\n   typedef unsigned long z_size_t;\n#else\n#  define z_longlong long long\n#  if defined(NO_SIZE_T)\n     typedef unsigned NO_SIZE_T z_size_t;\n#  elif defined(STDC)\n#    include <stddef.h>\n     typedef size_t z_size_t;\n#  else\n     typedef unsigned long z_size_t;\n#  endif\n#  undef z_longlong\n#endif\n\n/* Maximum value for memLevel in deflateInit2 */\n#ifndef MAX_MEM_LEVEL\n#  ifdef MAXSEG_64K\n#    define MAX_MEM_LEVEL 8\n#  else\n#    define MAX_MEM_LEVEL 9\n#  endif\n#endif\n\n/* Maximum value for windowBits in deflateInit2 and inflateInit2.\n * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files\n * created by gzip. (Files created by minigzip can still be extracted by\n * gzip.)\n */\n#ifndef MAX_WBITS\n#  define MAX_WBITS   15 /* 32K LZ77 window */\n#endif\n\n/* The memory requirements for deflate are (in bytes):\n            (1 << (windowBits+2)) +  (1 << (memLevel+9))\n that is: 128K for windowBits=15  +  128K for memLevel = 8  (default values)\n plus a few kilobytes for small objects. For example, if you want to reduce\n the default memory requirements from 256K to 128K, compile with\n     make CFLAGS=\"-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7\"\n Of course this will generally degrade compression (there's no free lunch).\n\n   The memory requirements for inflate are (in bytes) 1 << windowBits\n that is, 32K for windowBits=15 (default value) plus about 7 kilobytes\n for small objects.\n*/\n\n                        /* Type declarations */\n\n#ifndef OF /* function prototypes */\n#  ifdef STDC\n#    define OF(args)  args\n#  else\n#    define OF(args)  ()\n#  endif\n#endif\n\n#ifndef Z_ARG /* function prototypes for stdarg */\n#  if defined(STDC) || defined(Z_HAVE_STDARG_H)\n#    define Z_ARG(args)  args\n#  else\n#    define Z_ARG(args)  ()\n#  endif\n#endif\n\n/* The following definitions for FAR are needed only for MSDOS mixed\n * model programming (small or medium model with some far allocations).\n * This was tested only with MSC; for other MSDOS compilers you may have\n * to define NO_MEMCPY in zutil.h.  If you don't need the mixed model,\n * just define FAR to be empty.\n */\n#ifdef SYS16BIT\n#  if defined(M_I86SM) || defined(M_I86MM)\n     /* MSC small or medium model */\n#    define SMALL_MEDIUM\n#    ifdef _MSC_VER\n#      define FAR _far\n#    else\n#      define FAR far\n#    endif\n#  endif\n#  if (defined(__SMALL__) || defined(__MEDIUM__))\n     /* Turbo C small or medium model */\n#    define SMALL_MEDIUM\n#    ifdef __BORLANDC__\n#      define FAR _far\n#    else\n#      define FAR far\n#    endif\n#  endif\n#endif\n\n#if defined(WINDOWS) || defined(WIN32)\n   /* If building or using zlib as a DLL, define ZLIB_DLL.\n    * This is not mandatory, but it offers a little performance increase.\n    */\n#  ifdef ZLIB_DLL\n#    if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500))\n#      ifdef ZLIB_INTERNAL\n#        define ZEXTERN extern __declspec(dllexport)\n#      else\n#        define ZEXTERN extern __declspec(dllimport)\n#      endif\n#    endif\n#  endif  /* ZLIB_DLL */\n   /* If building or using zlib with the WINAPI/WINAPIV calling convention,\n    * define ZLIB_WINAPI.\n    * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI.\n    */\n#  ifdef ZLIB_WINAPI\n#    ifdef FAR\n#      undef FAR\n#    endif\n#    include <windows.h>\n     /* No need for _export, use ZLIB.DEF instead. */\n     /* For complete Windows compatibility, use WINAPI, not __stdcall. */\n#    define ZEXPORT WINAPI\n#    ifdef WIN32\n#      define ZEXPORTVA WINAPIV\n#    else\n#      define ZEXPORTVA FAR CDECL\n#    endif\n#  endif\n#endif\n\n#if defined (__BEOS__)\n#  ifdef ZLIB_DLL\n#    ifdef ZLIB_INTERNAL\n#      define ZEXPORT   __declspec(dllexport)\n#      define ZEXPORTVA __declspec(dllexport)\n#    else\n#      define ZEXPORT   __declspec(dllimport)\n#      define ZEXPORTVA __declspec(dllimport)\n#    endif\n#  endif\n#endif\n\n#ifndef ZEXTERN\n#  define ZEXTERN extern\n#endif\n#ifndef ZEXPORT\n#  define ZEXPORT\n#endif\n#ifndef ZEXPORTVA\n#  define ZEXPORTVA\n#endif\n\n#ifndef FAR\n#  define FAR\n#endif\n\n#if !defined(__MACTYPES__)\ntypedef unsigned char  Byte;  /* 8 bits */\n#endif\ntypedef unsigned int   uInt;  /* 16 bits or more */\ntypedef unsigned long  uLong; /* 32 bits or more */\n\n#ifdef SMALL_MEDIUM\n   /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */\n#  define Bytef Byte FAR\n#else\n   typedef Byte  FAR Bytef;\n#endif\ntypedef char  FAR charf;\ntypedef int   FAR intf;\ntypedef uInt  FAR uIntf;\ntypedef uLong FAR uLongf;\n\n#ifdef STDC\n   typedef void const *voidpc;\n   typedef void FAR   *voidpf;\n   typedef void       *voidp;\n#else\n   typedef Byte const *voidpc;\n   typedef Byte FAR   *voidpf;\n   typedef Byte       *voidp;\n#endif\n\n#if !defined(Z_U4) && !defined(Z_SOLO) && defined(STDC)\n#  include <limits.h>\n#  if (UINT_MAX == 0xffffffffUL)\n#    define Z_U4 unsigned\n#  elif (ULONG_MAX == 0xffffffffUL)\n#    define Z_U4 unsigned long\n#  elif (USHRT_MAX == 0xffffffffUL)\n#    define Z_U4 unsigned short\n#  endif\n#endif\n\n#ifdef Z_U4\n   typedef Z_U4 z_crc_t;\n#else\n   typedef unsigned long z_crc_t;\n#endif\n\n#if 1    /* was set to #if 1 by ./configure */\n#  define Z_HAVE_UNISTD_H\n#endif\n\n#if 1    /* was set to #if 1 by ./configure */\n#  define Z_HAVE_STDARG_H\n#endif\n\n#ifdef STDC\n#  ifndef Z_SOLO\n#    include <sys/types.h>      /* for off_t */\n#  endif\n#endif\n\n#if defined(STDC) || defined(Z_HAVE_STDARG_H)\n#  ifndef Z_SOLO\n#    include <stdarg.h>         /* for va_list */\n#  endif\n#endif\n\n#ifdef _WIN32\n#  ifndef Z_SOLO\n#    include <stddef.h>         /* for wchar_t */\n#  endif\n#endif\n\n/* a little trick to accommodate both \"#define _LARGEFILE64_SOURCE\" and\n * \"#define _LARGEFILE64_SOURCE 1\" as requesting 64-bit operations, (even\n * though the former does not conform to the LFS document), but considering\n * both \"#undef _LARGEFILE64_SOURCE\" and \"#define _LARGEFILE64_SOURCE 0\" as\n * equivalently requesting no 64-bit operations\n */\n#if defined(_LARGEFILE64_SOURCE) && -_LARGEFILE64_SOURCE - -1 == 1\n#  undef _LARGEFILE64_SOURCE\n#endif\n\n#if defined(__WATCOMC__) && !defined(Z_HAVE_UNISTD_H)\n#  define Z_HAVE_UNISTD_H\n#endif\n#ifndef Z_SOLO\n#  if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE)\n#    include <unistd.h>         /* for SEEK_*, off_t, and _LFS64_LARGEFILE */\n#    ifdef VMS\n#      include <unixio.h>       /* for off_t */\n#    endif\n#    ifndef z_off_t\n#      define z_off_t off_t\n#    endif\n#  endif\n#endif\n\n#if defined(_LFS64_LARGEFILE) && _LFS64_LARGEFILE-0\n#  define Z_LFS64\n#endif\n\n#if defined(_LARGEFILE64_SOURCE) && defined(Z_LFS64)\n#  define Z_LARGE64\n#endif\n\n#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS-0 == 64 && defined(Z_LFS64)\n#  define Z_WANT64\n#endif\n\n#if !defined(SEEK_SET) && !defined(Z_SOLO)\n#  define SEEK_SET        0       /* Seek from beginning of file.  */\n#  define SEEK_CUR        1       /* Seek from current position.  */\n#  define SEEK_END        2       /* Set file pointer to EOF plus \"offset\" */\n#endif\n\n#ifndef z_off_t\n#  define z_off_t long\n#endif\n\n#if !defined(_WIN32) && defined(Z_LARGE64)\n#  define z_off64_t off64_t\n#else\n#  if defined(_WIN32) && !defined(__GNUC__) && !defined(Z_SOLO)\n#    define z_off64_t __int64\n#  else\n#    define z_off64_t z_off_t\n#  endif\n#endif\n\n/* MVS linker does not support external names larger than 8 bytes */\n#if defined(__MVS__)\n  #pragma map(deflateInit_,\"DEIN\")\n  #pragma map(deflateInit2_,\"DEIN2\")\n  #pragma map(deflateEnd,\"DEEND\")\n  #pragma map(deflateBound,\"DEBND\")\n  #pragma map(inflateInit_,\"ININ\")\n  #pragma map(inflateInit2_,\"ININ2\")\n  #pragma map(inflateEnd,\"INEND\")\n  #pragma map(inflateSync,\"INSY\")\n  #pragma map(inflateSetDictionary,\"INSEDI\")\n  #pragma map(compressBound,\"CMBND\")\n  #pragma map(inflate_table,\"INTABL\")\n  #pragma map(inflate_fast,\"INFA\")\n  #pragma map(inflate_copyright,\"INCOPY\")\n#endif\n\n#endif /* ZCONF_H */\n"
  },
  {
    "path": "Projects/Libraries/CSBase/Source/zlib/zlib.h",
    "content": "/* zlib.h -- interface of the 'zlib' general purpose compression library\n  version 1.2.11, January 15th, 2017\n\n  Copyright (C) 1995-2017 Jean-loup Gailly and Mark Adler\n\n  This software is provided 'as-is', without any express or implied\n  warranty.  In no event will the authors be held liable for any damages\n  arising from the use of this software.\n\n  Permission is granted to anyone to use this software for any purpose,\n  including commercial applications, and to alter it and redistribute it\n  freely, subject to the following restrictions:\n\n  1. The origin of this software must not be misrepresented; you must not\n     claim that you wrote the original software. If you use this software\n     in a product, an acknowledgment in the product documentation would be\n     appreciated but is not required.\n  2. Altered source versions must be plainly marked as such, and must not be\n     misrepresented as being the original software.\n  3. This notice may not be removed or altered from any source distribution.\n\n  Jean-loup Gailly        Mark Adler\n  jloup@gzip.org          madler@alumni.caltech.edu\n\n\n  The data format used by the zlib library is described by RFCs (Request for\n  Comments) 1950 to 1952 in the files http://tools.ietf.org/html/rfc1950\n  (zlib format), rfc1951 (deflate format) and rfc1952 (gzip format).\n*/\n\n#ifndef ZLIB_H\n#define ZLIB_H\n\n#include \"zconf.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#define ZLIB_VERSION \"1.2.11\"\n#define ZLIB_VERNUM 0x12b0\n#define ZLIB_VER_MAJOR 1\n#define ZLIB_VER_MINOR 2\n#define ZLIB_VER_REVISION 11\n#define ZLIB_VER_SUBREVISION 0\n\n/*\n    The 'zlib' compression library provides in-memory compression and\n  decompression functions, including integrity checks of the uncompressed data.\n  This version of the library supports only one compression method (deflation)\n  but other algorithms will be added later and will have the same stream\n  interface.\n\n    Compression can be done in a single step if the buffers are large enough,\n  or can be done by repeated calls of the compression function.  In the latter\n  case, the application must provide more input and/or consume the output\n  (providing more output space) before each call.\n\n    The compressed data format used by default by the in-memory functions is\n  the zlib format, which is a zlib wrapper documented in RFC 1950, wrapped\n  around a deflate stream, which is itself documented in RFC 1951.\n\n    The library also supports reading and writing files in gzip (.gz) format\n  with an interface similar to that of stdio using the functions that start\n  with \"gz\".  The gzip format is different from the zlib format.  gzip is a\n  gzip wrapper, documented in RFC 1952, wrapped around a deflate stream.\n\n    This library can optionally read and write gzip and raw deflate streams in\n  memory as well.\n\n    The zlib format was designed to be compact and fast for use in memory\n  and on communications channels.  The gzip format was designed for single-\n  file compression on file systems, has a larger header than zlib to maintain\n  directory information, and uses a different, slower check method than zlib.\n\n    The library does not install any signal handler.  The decoder checks\n  the consistency of the compressed data, so the library should never crash\n  even in the case of corrupted input.\n*/\n\ntypedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size));\ntypedef void   (*free_func)  OF((voidpf opaque, voidpf address));\n\nstruct internal_state;\n\ntypedef struct z_stream_s {\n    z_const Bytef *next_in;     /* next input byte */\n    uInt     avail_in;  /* number of bytes available at next_in */\n    uLong    total_in;  /* total number of input bytes read so far */\n\n    Bytef    *next_out; /* next output byte will go here */\n    uInt     avail_out; /* remaining free space at next_out */\n    uLong    total_out; /* total number of bytes output so far */\n\n    z_const char *msg;  /* last error message, NULL if no error */\n    struct internal_state FAR *state; /* not visible by applications */\n\n    alloc_func zalloc;  /* used to allocate the internal state */\n    free_func  zfree;   /* used to free the internal state */\n    voidpf     opaque;  /* private data object passed to zalloc and zfree */\n\n    int     data_type;  /* best guess about the data type: binary or text\n                           for deflate, or the decoding state for inflate */\n    uLong   adler;      /* Adler-32 or CRC-32 value of the uncompressed data */\n    uLong   reserved;   /* reserved for future use */\n} z_stream;\n\ntypedef z_stream FAR *z_streamp;\n\n/*\n     gzip header information passed to and from zlib routines.  See RFC 1952\n  for more details on the meanings of these fields.\n*/\ntypedef struct gz_header_s {\n    int     text;       /* true if compressed data believed to be text */\n    uLong   time;       /* modification time */\n    int     xflags;     /* extra flags (not used when writing a gzip file) */\n    int     os;         /* operating system */\n    Bytef   *extra;     /* pointer to extra field or Z_NULL if none */\n    uInt    extra_len;  /* extra field length (valid if extra != Z_NULL) */\n    uInt    extra_max;  /* space at extra (only when reading header) */\n    Bytef   *name;      /* pointer to zero-terminated file name or Z_NULL */\n    uInt    name_max;   /* space at name (only when reading header) */\n    Bytef   *comment;   /* pointer to zero-terminated comment or Z_NULL */\n    uInt    comm_max;   /* space at comment (only when reading header) */\n    int     hcrc;       /* true if there was or will be a header crc */\n    int     done;       /* true when done reading gzip header (not used\n                           when writing a gzip file) */\n} gz_header;\n\ntypedef gz_header FAR *gz_headerp;\n\n/*\n     The application must update next_in and avail_in when avail_in has dropped\n   to zero.  It must update next_out and avail_out when avail_out has dropped\n   to zero.  The application must initialize zalloc, zfree and opaque before\n   calling the init function.  All other fields are set by the compression\n   library and must not be updated by the application.\n\n     The opaque value provided by the application will be passed as the first\n   parameter for calls of zalloc and zfree.  This can be useful for custom\n   memory management.  The compression library attaches no meaning to the\n   opaque value.\n\n     zalloc must return Z_NULL if there is not enough memory for the object.\n   If zlib is used in a multi-threaded application, zalloc and zfree must be\n   thread safe.  In that case, zlib is thread-safe.  When zalloc and zfree are\n   Z_NULL on entry to the initialization function, they are set to internal\n   routines that use the standard library functions malloc() and free().\n\n     On 16-bit systems, the functions zalloc and zfree must be able to allocate\n   exactly 65536 bytes, but will not be required to allocate more than this if\n   the symbol MAXSEG_64K is defined (see zconf.h).  WARNING: On MSDOS, pointers\n   returned by zalloc for objects of exactly 65536 bytes *must* have their\n   offset normalized to zero.  The default allocation function provided by this\n   library ensures this (see zutil.c).  To reduce memory requirements and avoid\n   any allocation of 64K objects, at the expense of compression ratio, compile\n   the library with -DMAX_WBITS=14 (see zconf.h).\n\n     The fields total_in and total_out can be used for statistics or progress\n   reports.  After compression, total_in holds the total size of the\n   uncompressed data and may be saved for use by the decompressor (particularly\n   if the decompressor wants to decompress everything in a single step).\n*/\n\n                        /* constants */\n\n#define Z_NO_FLUSH      0\n#define Z_PARTIAL_FLUSH 1\n#define Z_SYNC_FLUSH    2\n#define Z_FULL_FLUSH    3\n#define Z_FINISH        4\n#define Z_BLOCK         5\n#define Z_TREES         6\n/* Allowed flush values; see deflate() and inflate() below for details */\n\n#define Z_OK            0\n#define Z_STREAM_END    1\n#define Z_NEED_DICT     2\n#define Z_ERRNO        (-1)\n#define Z_STREAM_ERROR (-2)\n#define Z_DATA_ERROR   (-3)\n#define Z_MEM_ERROR    (-4)\n#define Z_BUF_ERROR    (-5)\n#define Z_VERSION_ERROR (-6)\n/* Return codes for the compression/decompression functions. Negative values\n * are errors, positive values are used for special but normal events.\n */\n\n#define Z_NO_COMPRESSION         0\n#define Z_BEST_SPEED             1\n#define Z_BEST_COMPRESSION       9\n#define Z_DEFAULT_COMPRESSION  (-1)\n/* compression levels */\n\n#define Z_FILTERED            1\n#define Z_HUFFMAN_ONLY        2\n#define Z_RLE                 3\n#define Z_FIXED               4\n#define Z_DEFAULT_STRATEGY    0\n/* compression strategy; see deflateInit2() below for details */\n\n#define Z_BINARY   0\n#define Z_TEXT     1\n#define Z_ASCII    Z_TEXT   /* for compatibility with 1.2.2 and earlier */\n#define Z_UNKNOWN  2\n/* Possible values of the data_type field for deflate() */\n\n#define Z_DEFLATED   8\n/* The deflate compression method (the only one supported in this version) */\n\n#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */\n\n#define zlib_version zlibVersion()\n/* for compatibility with versions < 1.0.2 */\n\n\n                        /* basic functions */\n\nZEXTERN const char * ZEXPORT zlibVersion OF((void));\n/* The application can compare zlibVersion and ZLIB_VERSION for consistency.\n   If the first character differs, the library code actually used is not\n   compatible with the zlib.h header file used by the application.  This check\n   is automatically made by deflateInit and inflateInit.\n */\n\n/*\nZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level));\n\n     Initializes the internal stream state for compression.  The fields\n   zalloc, zfree and opaque must be initialized before by the caller.  If\n   zalloc and zfree are set to Z_NULL, deflateInit updates them to use default\n   allocation functions.\n\n     The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9:\n   1 gives best speed, 9 gives best compression, 0 gives no compression at all\n   (the input data is simply copied a block at a time).  Z_DEFAULT_COMPRESSION\n   requests a default compromise between speed and compression (currently\n   equivalent to level 6).\n\n     deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough\n   memory, Z_STREAM_ERROR if level is not a valid compression level, or\n   Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible\n   with the version assumed by the caller (ZLIB_VERSION).  msg is set to null\n   if there is no error message.  deflateInit does not perform any compression:\n   this will be done by deflate().\n*/\n\n\nZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush));\n/*\n    deflate compresses as much data as possible, and stops when the input\n  buffer becomes empty or the output buffer becomes full.  It may introduce\n  some output latency (reading input without producing any output) except when\n  forced to flush.\n\n    The detailed semantics are as follows.  deflate performs one or both of the\n  following actions:\n\n  - Compress more input starting at next_in and update next_in and avail_in\n    accordingly.  If not all input can be processed (because there is not\n    enough room in the output buffer), next_in and avail_in are updated and\n    processing will resume at this point for the next call of deflate().\n\n  - Generate more output starting at next_out and update next_out and avail_out\n    accordingly.  This action is forced if the parameter flush is non zero.\n    Forcing flush frequently degrades the compression ratio, so this parameter\n    should be set only when necessary.  Some output may be provided even if\n    flush is zero.\n\n    Before the call of deflate(), the application should ensure that at least\n  one of the actions is possible, by providing more input and/or consuming more\n  output, and updating avail_in or avail_out accordingly; avail_out should\n  never be zero before the call.  The application can consume the compressed\n  output when it wants, for example when the output buffer is full (avail_out\n  == 0), or after each call of deflate().  If deflate returns Z_OK and with\n  zero avail_out, it must be called again after making room in the output\n  buffer because there might be more output pending. See deflatePending(),\n  which can be used if desired to determine whether or not there is more ouput\n  in that case.\n\n    Normally the parameter flush is set to Z_NO_FLUSH, which allows deflate to\n  decide how much data to accumulate before producing output, in order to\n  maximize compression.\n\n    If the parameter flush is set to Z_SYNC_FLUSH, all pending output is\n  flushed to the output buffer and the output is aligned on a byte boundary, so\n  that the decompressor can get all input data available so far.  (In\n  particular avail_in is zero after the call if enough output space has been\n  provided before the call.) Flushing may degrade compression for some\n  compression algorithms and so it should be used only when necessary.  This\n  completes the current deflate block and follows it with an empty stored block\n  that is three bits plus filler bits to the next byte, followed by four bytes\n  (00 00 ff ff).\n\n    If flush is set to Z_PARTIAL_FLUSH, all pending output is flushed to the\n  output buffer, but the output is not aligned to a byte boundary.  All of the\n  input data so far will be available to the decompressor, as for Z_SYNC_FLUSH.\n  This completes the current deflate block and follows it with an empty fixed\n  codes block that is 10 bits long.  This assures that enough bytes are output\n  in order for the decompressor to finish the block before the empty fixed\n  codes block.\n\n    If flush is set to Z_BLOCK, a deflate block is completed and emitted, as\n  for Z_SYNC_FLUSH, but the output is not aligned on a byte boundary, and up to\n  seven bits of the current block are held to be written as the next byte after\n  the next deflate block is completed.  In this case, the decompressor may not\n  be provided enough bits at this point in order to complete decompression of\n  the data provided so far to the compressor.  It may need to wait for the next\n  block to be emitted.  This is for advanced applications that need to control\n  the emission of deflate blocks.\n\n    If flush is set to Z_FULL_FLUSH, all output is flushed as with\n  Z_SYNC_FLUSH, and the compression state is reset so that decompression can\n  restart from this point if previous compressed data has been damaged or if\n  random access is desired.  Using Z_FULL_FLUSH too often can seriously degrade\n  compression.\n\n    If deflate returns with avail_out == 0, this function must be called again\n  with the same value of the flush parameter and more output space (updated\n  avail_out), until the flush is complete (deflate returns with non-zero\n  avail_out).  In the case of a Z_FULL_FLUSH or Z_SYNC_FLUSH, make sure that\n  avail_out is greater than six to avoid repeated flush markers due to\n  avail_out == 0 on return.\n\n    If the parameter flush is set to Z_FINISH, pending input is processed,\n  pending output is flushed and deflate returns with Z_STREAM_END if there was\n  enough output space.  If deflate returns with Z_OK or Z_BUF_ERROR, this\n  function must be called again with Z_FINISH and more output space (updated\n  avail_out) but no more input data, until it returns with Z_STREAM_END or an\n  error.  After deflate has returned Z_STREAM_END, the only possible operations\n  on the stream are deflateReset or deflateEnd.\n\n    Z_FINISH can be used in the first deflate call after deflateInit if all the\n  compression is to be done in a single step.  In order to complete in one\n  call, avail_out must be at least the value returned by deflateBound (see\n  below).  Then deflate is guaranteed to return Z_STREAM_END.  If not enough\n  output space is provided, deflate will not return Z_STREAM_END, and it must\n  be called again as described above.\n\n    deflate() sets strm->adler to the Adler-32 checksum of all input read\n  so far (that is, total_in bytes).  If a gzip stream is being generated, then\n  strm->adler will be the CRC-32 checksum of the input read so far.  (See\n  deflateInit2 below.)\n\n    deflate() may update strm->data_type if it can make a good guess about\n  the input data type (Z_BINARY or Z_TEXT).  If in doubt, the data is\n  considered binary.  This field is only for information purposes and does not\n  affect the compression algorithm in any manner.\n\n    deflate() returns Z_OK if some progress has been made (more input\n  processed or more output produced), Z_STREAM_END if all input has been\n  consumed and all output has been produced (only when flush is set to\n  Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example\n  if next_in or next_out was Z_NULL or the state was inadvertently written over\n  by the application), or Z_BUF_ERROR if no progress is possible (for example\n  avail_in or avail_out was zero).  Note that Z_BUF_ERROR is not fatal, and\n  deflate() can be called again with more input and more output space to\n  continue compressing.\n*/\n\n\nZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm));\n/*\n     All dynamically allocated data structures for this stream are freed.\n   This function discards any unprocessed input and does not flush any pending\n   output.\n\n     deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the\n   stream state was inconsistent, Z_DATA_ERROR if the stream was freed\n   prematurely (some input or output was discarded).  In the error case, msg\n   may be set but then points to a static string (which must not be\n   deallocated).\n*/\n\n\n/*\nZEXTERN int ZEXPORT inflateInit OF((z_streamp strm));\n\n     Initializes the internal stream state for decompression.  The fields\n   next_in, avail_in, zalloc, zfree and opaque must be initialized before by\n   the caller.  In the current version of inflate, the provided input is not\n   read or consumed.  The allocation of a sliding window will be deferred to\n   the first call of inflate (if the decompression does not complete on the\n   first call).  If zalloc and zfree are set to Z_NULL, inflateInit updates\n   them to use default allocation functions.\n\n     inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough\n   memory, Z_VERSION_ERROR if the zlib library version is incompatible with the\n   version assumed by the caller, or Z_STREAM_ERROR if the parameters are\n   invalid, such as a null pointer to the structure.  msg is set to null if\n   there is no error message.  inflateInit does not perform any decompression.\n   Actual decompression will be done by inflate().  So next_in, and avail_in,\n   next_out, and avail_out are unused and unchanged.  The current\n   implementation of inflateInit() does not process any header information --\n   that is deferred until inflate() is called.\n*/\n\n\nZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush));\n/*\n    inflate decompresses as much data as possible, and stops when the input\n  buffer becomes empty or the output buffer becomes full.  It may introduce\n  some output latency (reading input without producing any output) except when\n  forced to flush.\n\n  The detailed semantics are as follows.  inflate performs one or both of the\n  following actions:\n\n  - Decompress more input starting at next_in and update next_in and avail_in\n    accordingly.  If not all input can be processed (because there is not\n    enough room in the output buffer), then next_in and avail_in are updated\n    accordingly, and processing will resume at this point for the next call of\n    inflate().\n\n  - Generate more output starting at next_out and update next_out and avail_out\n    accordingly.  inflate() provides as much output as possible, until there is\n    no more input data or no more space in the output buffer (see below about\n    the flush parameter).\n\n    Before the call of inflate(), the application should ensure that at least\n  one of the actions is possible, by providing more input and/or consuming more\n  output, and updating the next_* and avail_* values accordingly.  If the\n  caller of inflate() does not provide both available input and available\n  output space, it is possible that there will be no progress made.  The\n  application can consume the uncompressed output when it wants, for example\n  when the output buffer is full (avail_out == 0), or after each call of\n  inflate().  If inflate returns Z_OK and with zero avail_out, it must be\n  called again after making room in the output buffer because there might be\n  more output pending.\n\n    The flush parameter of inflate() can be Z_NO_FLUSH, Z_SYNC_FLUSH, Z_FINISH,\n  Z_BLOCK, or Z_TREES.  Z_SYNC_FLUSH requests that inflate() flush as much\n  output as possible to the output buffer.  Z_BLOCK requests that inflate()\n  stop if and when it gets to the next deflate block boundary.  When decoding\n  the zlib or gzip format, this will cause inflate() to return immediately\n  after the header and before the first block.  When doing a raw inflate,\n  inflate() will go ahead and process the first block, and will return when it\n  gets to the end of that block, or when it runs out of data.\n\n    The Z_BLOCK option assists in appending to or combining deflate streams.\n  To assist in this, on return inflate() always sets strm->data_type to the\n  number of unused bits in the last byte taken from strm->next_in, plus 64 if\n  inflate() is currently decoding the last block in the deflate stream, plus\n  128 if inflate() returned immediately after decoding an end-of-block code or\n  decoding the complete header up to just before the first byte of the deflate\n  stream.  The end-of-block will not be indicated until all of the uncompressed\n  data from that block has been written to strm->next_out.  The number of\n  unused bits may in general be greater than seven, except when bit 7 of\n  data_type is set, in which case the number of unused bits will be less than\n  eight.  data_type is set as noted here every time inflate() returns for all\n  flush options, and so can be used to determine the amount of currently\n  consumed input in bits.\n\n    The Z_TREES option behaves as Z_BLOCK does, but it also returns when the\n  end of each deflate block header is reached, before any actual data in that\n  block is decoded.  This allows the caller to determine the length of the\n  deflate block header for later use in random access within a deflate block.\n  256 is added to the value of strm->data_type when inflate() returns\n  immediately after reaching the end of the deflate block header.\n\n    inflate() should normally be called until it returns Z_STREAM_END or an\n  error.  However if all decompression is to be performed in a single step (a\n  single call of inflate), the parameter flush should be set to Z_FINISH.  In\n  this case all pending input is processed and all pending output is flushed;\n  avail_out must be large enough to hold all of the uncompressed data for the\n  operation to complete.  (The size of the uncompressed data may have been\n  saved by the compressor for this purpose.)  The use of Z_FINISH is not\n  required to perform an inflation in one step.  However it may be used to\n  inform inflate that a faster approach can be used for the single inflate()\n  call.  Z_FINISH also informs inflate to not maintain a sliding window if the\n  stream completes, which reduces inflate's memory footprint.  If the stream\n  does not complete, either because not all of the stream is provided or not\n  enough output space is provided, then a sliding window will be allocated and\n  inflate() can be called again to continue the operation as if Z_NO_FLUSH had\n  been used.\n\n     In this implementation, inflate() always flushes as much output as\n  possible to the output buffer, and always uses the faster approach on the\n  first call.  So the effects of the flush parameter in this implementation are\n  on the return value of inflate() as noted below, when inflate() returns early\n  when Z_BLOCK or Z_TREES is used, and when inflate() avoids the allocation of\n  memory for a sliding window when Z_FINISH is used.\n\n     If a preset dictionary is needed after this call (see inflateSetDictionary\n  below), inflate sets strm->adler to the Adler-32 checksum of the dictionary\n  chosen by the compressor and returns Z_NEED_DICT; otherwise it sets\n  strm->adler to the Adler-32 checksum of all output produced so far (that is,\n  total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as described\n  below.  At the end of the stream, inflate() checks that its computed Adler-32\n  checksum is equal to that saved by the compressor and returns Z_STREAM_END\n  only if the checksum is correct.\n\n    inflate() can decompress and check either zlib-wrapped or gzip-wrapped\n  deflate data.  The header type is detected automatically, if requested when\n  initializing with inflateInit2().  Any information contained in the gzip\n  header is not retained unless inflateGetHeader() is used.  When processing\n  gzip-wrapped deflate data, strm->adler32 is set to the CRC-32 of the output\n  produced so far.  The CRC-32 is checked against the gzip trailer, as is the\n  uncompressed length, modulo 2^32.\n\n    inflate() returns Z_OK if some progress has been made (more input processed\n  or more output produced), Z_STREAM_END if the end of the compressed data has\n  been reached and all uncompressed output has been produced, Z_NEED_DICT if a\n  preset dictionary is needed at this point, Z_DATA_ERROR if the input data was\n  corrupted (input stream not conforming to the zlib format or incorrect check\n  value, in which case strm->msg points to a string with a more specific\n  error), Z_STREAM_ERROR if the stream structure was inconsistent (for example\n  next_in or next_out was Z_NULL, or the state was inadvertently written over\n  by the application), Z_MEM_ERROR if there was not enough memory, Z_BUF_ERROR\n  if no progress was possible or if there was not enough room in the output\n  buffer when Z_FINISH is used.  Note that Z_BUF_ERROR is not fatal, and\n  inflate() can be called again with more input and more output space to\n  continue decompressing.  If Z_DATA_ERROR is returned, the application may\n  then call inflateSync() to look for a good compression block if a partial\n  recovery of the data is to be attempted.\n*/\n\n\nZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm));\n/*\n     All dynamically allocated data structures for this stream are freed.\n   This function discards any unprocessed input and does not flush any pending\n   output.\n\n     inflateEnd returns Z_OK if success, or Z_STREAM_ERROR if the stream state\n   was inconsistent.\n*/\n\n\n                        /* Advanced functions */\n\n/*\n    The following functions are needed only in some special applications.\n*/\n\n/*\nZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm,\n                                     int  level,\n                                     int  method,\n                                     int  windowBits,\n                                     int  memLevel,\n                                     int  strategy));\n\n     This is another version of deflateInit with more compression options.  The\n   fields next_in, zalloc, zfree and opaque must be initialized before by the\n   caller.\n\n     The method parameter is the compression method.  It must be Z_DEFLATED in\n   this version of the library.\n\n     The windowBits parameter is the base two logarithm of the window size\n   (the size of the history buffer).  It should be in the range 8..15 for this\n   version of the library.  Larger values of this parameter result in better\n   compression at the expense of memory usage.  The default value is 15 if\n   deflateInit is used instead.\n\n     For the current implementation of deflate(), a windowBits value of 8 (a\n   window size of 256 bytes) is not supported.  As a result, a request for 8\n   will result in 9 (a 512-byte window).  In that case, providing 8 to\n   inflateInit2() will result in an error when the zlib header with 9 is\n   checked against the initialization of inflate().  The remedy is to not use 8\n   with deflateInit2() with this initialization, or at least in that case use 9\n   with inflateInit2().\n\n     windowBits can also be -8..-15 for raw deflate.  In this case, -windowBits\n   determines the window size.  deflate() will then generate raw deflate data\n   with no zlib header or trailer, and will not compute a check value.\n\n     windowBits can also be greater than 15 for optional gzip encoding.  Add\n   16 to windowBits to write a simple gzip header and trailer around the\n   compressed data instead of a zlib wrapper.  The gzip header will have no\n   file name, no extra data, no comment, no modification time (set to zero), no\n   header crc, and the operating system will be set to the appropriate value,\n   if the operating system was determined at compile time.  If a gzip stream is\n   being written, strm->adler is a CRC-32 instead of an Adler-32.\n\n     For raw deflate or gzip encoding, a request for a 256-byte window is\n   rejected as invalid, since only the zlib header provides a means of\n   transmitting the window size to the decompressor.\n\n     The memLevel parameter specifies how much memory should be allocated\n   for the internal compression state.  memLevel=1 uses minimum memory but is\n   slow and reduces compression ratio; memLevel=9 uses maximum memory for\n   optimal speed.  The default value is 8.  See zconf.h for total memory usage\n   as a function of windowBits and memLevel.\n\n     The strategy parameter is used to tune the compression algorithm.  Use the\n   value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a\n   filter (or predictor), Z_HUFFMAN_ONLY to force Huffman encoding only (no\n   string match), or Z_RLE to limit match distances to one (run-length\n   encoding).  Filtered data consists mostly of small values with a somewhat\n   random distribution.  In this case, the compression algorithm is tuned to\n   compress them better.  The effect of Z_FILTERED is to force more Huffman\n   coding and less string matching; it is somewhat intermediate between\n   Z_DEFAULT_STRATEGY and Z_HUFFMAN_ONLY.  Z_RLE is designed to be almost as\n   fast as Z_HUFFMAN_ONLY, but give better compression for PNG image data.  The\n   strategy parameter only affects the compression ratio but not the\n   correctness of the compressed output even if it is not set appropriately.\n   Z_FIXED prevents the use of dynamic Huffman codes, allowing for a simpler\n   decoder for special applications.\n\n     deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough\n   memory, Z_STREAM_ERROR if any parameter is invalid (such as an invalid\n   method), or Z_VERSION_ERROR if the zlib library version (zlib_version) is\n   incompatible with the version assumed by the caller (ZLIB_VERSION).  msg is\n   set to null if there is no error message.  deflateInit2 does not perform any\n   compression: this will be done by deflate().\n*/\n\nZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm,\n                                             const Bytef *dictionary,\n                                             uInt  dictLength));\n/*\n     Initializes the compression dictionary from the given byte sequence\n   without producing any compressed output.  When using the zlib format, this\n   function must be called immediately after deflateInit, deflateInit2 or\n   deflateReset, and before any call of deflate.  When doing raw deflate, this\n   function must be called either before any call of deflate, or immediately\n   after the completion of a deflate block, i.e. after all input has been\n   consumed and all output has been delivered when using any of the flush\n   options Z_BLOCK, Z_PARTIAL_FLUSH, Z_SYNC_FLUSH, or Z_FULL_FLUSH.  The\n   compressor and decompressor must use exactly the same dictionary (see\n   inflateSetDictionary).\n\n     The dictionary should consist of strings (byte sequences) that are likely\n   to be encountered later in the data to be compressed, with the most commonly\n   used strings preferably put towards the end of the dictionary.  Using a\n   dictionary is most useful when the data to be compressed is short and can be\n   predicted with good accuracy; the data can then be compressed better than\n   with the default empty dictionary.\n\n     Depending on the size of the compression data structures selected by\n   deflateInit or deflateInit2, a part of the dictionary may in effect be\n   discarded, for example if the dictionary is larger than the window size\n   provided in deflateInit or deflateInit2.  Thus the strings most likely to be\n   useful should be put at the end of the dictionary, not at the front.  In\n   addition, the current implementation of deflate will use at most the window\n   size minus 262 bytes of the provided dictionary.\n\n     Upon return of this function, strm->adler is set to the Adler-32 value\n   of the dictionary; the decompressor may later use this value to determine\n   which dictionary has been used by the compressor.  (The Adler-32 value\n   applies to the whole dictionary even if only a subset of the dictionary is\n   actually used by the compressor.) If a raw deflate was requested, then the\n   Adler-32 value is not computed and strm->adler is not set.\n\n     deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a\n   parameter is invalid (e.g.  dictionary being Z_NULL) or the stream state is\n   inconsistent (for example if deflate has already been called for this stream\n   or if not at a block boundary for raw deflate).  deflateSetDictionary does\n   not perform any compression: this will be done by deflate().\n*/\n\nZEXTERN int ZEXPORT deflateGetDictionary OF((z_streamp strm,\n                                             Bytef *dictionary,\n                                             uInt  *dictLength));\n/*\n     Returns the sliding dictionary being maintained by deflate.  dictLength is\n   set to the number of bytes in the dictionary, and that many bytes are copied\n   to dictionary.  dictionary must have enough space, where 32768 bytes is\n   always enough.  If deflateGetDictionary() is called with dictionary equal to\n   Z_NULL, then only the dictionary length is returned, and nothing is copied.\n   Similary, if dictLength is Z_NULL, then it is not set.\n\n     deflateGetDictionary() may return a length less than the window size, even\n   when more than the window size in input has been provided. It may return up\n   to 258 bytes less in that case, due to how zlib's implementation of deflate\n   manages the sliding window and lookahead for matches, where matches can be\n   up to 258 bytes long. If the application needs the last window-size bytes of\n   input, then that would need to be saved by the application outside of zlib.\n\n     deflateGetDictionary returns Z_OK on success, or Z_STREAM_ERROR if the\n   stream state is inconsistent.\n*/\n\nZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest,\n                                    z_streamp source));\n/*\n     Sets the destination stream as a complete copy of the source stream.\n\n     This function can be useful when several compression strategies will be\n   tried, for example when there are several ways of pre-processing the input\n   data with a filter.  The streams that will be discarded should then be freed\n   by calling deflateEnd.  Note that deflateCopy duplicates the internal\n   compression state which can be quite large, so this strategy is slow and can\n   consume lots of memory.\n\n     deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not\n   enough memory, Z_STREAM_ERROR if the source stream state was inconsistent\n   (such as zalloc being Z_NULL).  msg is left unchanged in both source and\n   destination.\n*/\n\nZEXTERN int ZEXPORT deflateReset OF((z_streamp strm));\n/*\n     This function is equivalent to deflateEnd followed by deflateInit, but\n   does not free and reallocate the internal compression state.  The stream\n   will leave the compression level and any other attributes that may have been\n   set unchanged.\n\n     deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source\n   stream state was inconsistent (such as zalloc or state being Z_NULL).\n*/\n\nZEXTERN int ZEXPORT deflateParams OF((z_streamp strm,\n                                      int level,\n                                      int strategy));\n/*\n     Dynamically update the compression level and compression strategy.  The\n   interpretation of level and strategy is as in deflateInit2().  This can be\n   used to switch between compression and straight copy of the input data, or\n   to switch to a different kind of input data requiring a different strategy.\n   If the compression approach (which is a function of the level) or the\n   strategy is changed, and if any input has been consumed in a previous\n   deflate() call, then the input available so far is compressed with the old\n   level and strategy using deflate(strm, Z_BLOCK).  There are three approaches\n   for the compression levels 0, 1..3, and 4..9 respectively.  The new level\n   and strategy will take effect at the next call of deflate().\n\n     If a deflate(strm, Z_BLOCK) is performed by deflateParams(), and it does\n   not have enough output space to complete, then the parameter change will not\n   take effect.  In this case, deflateParams() can be called again with the\n   same parameters and more output space to try again.\n\n     In order to assure a change in the parameters on the first try, the\n   deflate stream should be flushed using deflate() with Z_BLOCK or other flush\n   request until strm.avail_out is not zero, before calling deflateParams().\n   Then no more input data should be provided before the deflateParams() call.\n   If this is done, the old level and strategy will be applied to the data\n   compressed before deflateParams(), and the new level and strategy will be\n   applied to the the data compressed after deflateParams().\n\n     deflateParams returns Z_OK on success, Z_STREAM_ERROR if the source stream\n   state was inconsistent or if a parameter was invalid, or Z_BUF_ERROR if\n   there was not enough output space to complete the compression of the\n   available input data before a change in the strategy or approach.  Note that\n   in the case of a Z_BUF_ERROR, the parameters are not changed.  A return\n   value of Z_BUF_ERROR is not fatal, in which case deflateParams() can be\n   retried with more output space.\n*/\n\nZEXTERN int ZEXPORT deflateTune OF((z_streamp strm,\n                                    int good_length,\n                                    int max_lazy,\n                                    int nice_length,\n                                    int max_chain));\n/*\n     Fine tune deflate's internal compression parameters.  This should only be\n   used by someone who understands the algorithm used by zlib's deflate for\n   searching for the best matching string, and even then only by the most\n   fanatic optimizer trying to squeeze out the last compressed bit for their\n   specific input data.  Read the deflate.c source code for the meaning of the\n   max_lazy, good_length, nice_length, and max_chain parameters.\n\n     deflateTune() can be called after deflateInit() or deflateInit2(), and\n   returns Z_OK on success, or Z_STREAM_ERROR for an invalid deflate stream.\n */\n\nZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm,\n                                       uLong sourceLen));\n/*\n     deflateBound() returns an upper bound on the compressed size after\n   deflation of sourceLen bytes.  It must be called after deflateInit() or\n   deflateInit2(), and after deflateSetHeader(), if used.  This would be used\n   to allocate an output buffer for deflation in a single pass, and so would be\n   called before deflate().  If that first deflate() call is provided the\n   sourceLen input bytes, an output buffer allocated to the size returned by\n   deflateBound(), and the flush value Z_FINISH, then deflate() is guaranteed\n   to return Z_STREAM_END.  Note that it is possible for the compressed size to\n   be larger than the value returned by deflateBound() if flush options other\n   than Z_FINISH or Z_NO_FLUSH are used.\n*/\n\nZEXTERN int ZEXPORT deflatePending OF((z_streamp strm,\n                                       unsigned *pending,\n                                       int *bits));\n/*\n     deflatePending() returns the number of bytes and bits of output that have\n   been generated, but not yet provided in the available output.  The bytes not\n   provided would be due to the available output space having being consumed.\n   The number of bits of output not provided are between 0 and 7, where they\n   await more bits to join them in order to fill out a full byte.  If pending\n   or bits are Z_NULL, then those values are not set.\n\n     deflatePending returns Z_OK if success, or Z_STREAM_ERROR if the source\n   stream state was inconsistent.\n */\n\nZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm,\n                                     int bits,\n                                     int value));\n/*\n     deflatePrime() inserts bits in the deflate output stream.  The intent\n   is that this function is used to start off the deflate output with the bits\n   leftover from a previous deflate stream when appending to it.  As such, this\n   function can only be used for raw deflate, and must be used before the first\n   deflate() call after a deflateInit2() or deflateReset().  bits must be less\n   than or equal to 16, and that many of the least significant bits of value\n   will be inserted in the output.\n\n     deflatePrime returns Z_OK if success, Z_BUF_ERROR if there was not enough\n   room in the internal buffer to insert the bits, or Z_STREAM_ERROR if the\n   source stream state was inconsistent.\n*/\n\nZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm,\n                                         gz_headerp head));\n/*\n     deflateSetHeader() provides gzip header information for when a gzip\n   stream is requested by deflateInit2().  deflateSetHeader() may be called\n   after deflateInit2() or deflateReset() and before the first call of\n   deflate().  The text, time, os, extra field, name, and comment information\n   in the provided gz_header structure are written to the gzip header (xflag is\n   ignored -- the extra flags are set according to the compression level).  The\n   caller must assure that, if not Z_NULL, name and comment are terminated with\n   a zero byte, and that if extra is not Z_NULL, that extra_len bytes are\n   available there.  If hcrc is true, a gzip header crc is included.  Note that\n   the current versions of the command-line version of gzip (up through version\n   1.3.x) do not support header crc's, and will report that it is a \"multi-part\n   gzip file\" and give up.\n\n     If deflateSetHeader is not used, the default gzip header has text false,\n   the time set to zero, and os set to 255, with no extra, name, or comment\n   fields.  The gzip header is returned to the default state by deflateReset().\n\n     deflateSetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source\n   stream state was inconsistent.\n*/\n\n/*\nZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm,\n                                     int  windowBits));\n\n     This is another version of inflateInit with an extra parameter.  The\n   fields next_in, avail_in, zalloc, zfree and opaque must be initialized\n   before by the caller.\n\n     The windowBits parameter is the base two logarithm of the maximum window\n   size (the size of the history buffer).  It should be in the range 8..15 for\n   this version of the library.  The default value is 15 if inflateInit is used\n   instead.  windowBits must be greater than or equal to the windowBits value\n   provided to deflateInit2() while compressing, or it must be equal to 15 if\n   deflateInit2() was not used.  If a compressed stream with a larger window\n   size is given as input, inflate() will return with the error code\n   Z_DATA_ERROR instead of trying to allocate a larger window.\n\n     windowBits can also be zero to request that inflate use the window size in\n   the zlib header of the compressed stream.\n\n     windowBits can also be -8..-15 for raw inflate.  In this case, -windowBits\n   determines the window size.  inflate() will then process raw deflate data,\n   not looking for a zlib or gzip header, not generating a check value, and not\n   looking for any check values for comparison at the end of the stream.  This\n   is for use with other formats that use the deflate compressed data format\n   such as zip.  Those formats provide their own check values.  If a custom\n   format is developed using the raw deflate format for compressed data, it is\n   recommended that a check value such as an Adler-32 or a CRC-32 be applied to\n   the uncompressed data as is done in the zlib, gzip, and zip formats.  For\n   most applications, the zlib format should be used as is.  Note that comments\n   above on the use in deflateInit2() applies to the magnitude of windowBits.\n\n     windowBits can also be greater than 15 for optional gzip decoding.  Add\n   32 to windowBits to enable zlib and gzip decoding with automatic header\n   detection, or add 16 to decode only the gzip format (the zlib format will\n   return a Z_DATA_ERROR).  If a gzip stream is being decoded, strm->adler is a\n   CRC-32 instead of an Adler-32.  Unlike the gunzip utility and gzread() (see\n   below), inflate() will not automatically decode concatenated gzip streams.\n   inflate() will return Z_STREAM_END at the end of the gzip stream.  The state\n   would need to be reset to continue decoding a subsequent gzip stream.\n\n     inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough\n   memory, Z_VERSION_ERROR if the zlib library version is incompatible with the\n   version assumed by the caller, or Z_STREAM_ERROR if the parameters are\n   invalid, such as a null pointer to the structure.  msg is set to null if\n   there is no error message.  inflateInit2 does not perform any decompression\n   apart from possibly reading the zlib header if present: actual decompression\n   will be done by inflate().  (So next_in and avail_in may be modified, but\n   next_out and avail_out are unused and unchanged.) The current implementation\n   of inflateInit2() does not process any header information -- that is\n   deferred until inflate() is called.\n*/\n\nZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm,\n                                             const Bytef *dictionary,\n                                             uInt  dictLength));\n/*\n     Initializes the decompression dictionary from the given uncompressed byte\n   sequence.  This function must be called immediately after a call of inflate,\n   if that call returned Z_NEED_DICT.  The dictionary chosen by the compressor\n   can be determined from the Adler-32 value returned by that call of inflate.\n   The compressor and decompressor must use exactly the same dictionary (see\n   deflateSetDictionary).  For raw inflate, this function can be called at any\n   time to set the dictionary.  If the provided dictionary is smaller than the\n   window and there is already data in the window, then the provided dictionary\n   will amend what's there.  The application must insure that the dictionary\n   that was used for compression is provided.\n\n     inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a\n   parameter is invalid (e.g.  dictionary being Z_NULL) or the stream state is\n   inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the\n   expected one (incorrect Adler-32 value).  inflateSetDictionary does not\n   perform any decompression: this will be done by subsequent calls of\n   inflate().\n*/\n\nZEXTERN int ZEXPORT inflateGetDictionary OF((z_streamp strm,\n                                             Bytef *dictionary,\n                                             uInt  *dictLength));\n/*\n     Returns the sliding dictionary being maintained by inflate.  dictLength is\n   set to the number of bytes in the dictionary, and that many bytes are copied\n   to dictionary.  dictionary must have enough space, where 32768 bytes is\n   always enough.  If inflateGetDictionary() is called with dictionary equal to\n   Z_NULL, then only the dictionary length is returned, and nothing is copied.\n   Similary, if dictLength is Z_NULL, then it is not set.\n\n     inflateGetDictionary returns Z_OK on success, or Z_STREAM_ERROR if the\n   stream state is inconsistent.\n*/\n\nZEXTERN int ZEXPORT inflateSync OF((z_streamp strm));\n/*\n     Skips invalid compressed data until a possible full flush point (see above\n   for the description of deflate with Z_FULL_FLUSH) can be found, or until all\n   available input is skipped.  No output is provided.\n\n     inflateSync searches for a 00 00 FF FF pattern in the compressed data.\n   All full flush points have this pattern, but not all occurrences of this\n   pattern are full flush points.\n\n     inflateSync returns Z_OK if a possible full flush point has been found,\n   Z_BUF_ERROR if no more input was provided, Z_DATA_ERROR if no flush point\n   has been found, or Z_STREAM_ERROR if the stream structure was inconsistent.\n   In the success case, the application may save the current current value of\n   total_in which indicates where valid compressed data was found.  In the\n   error case, the application may repeatedly call inflateSync, providing more\n   input each time, until success or end of the input data.\n*/\n\nZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest,\n                                    z_streamp source));\n/*\n     Sets the destination stream as a complete copy of the source stream.\n\n     This function can be useful when randomly accessing a large stream.  The\n   first pass through the stream can periodically record the inflate state,\n   allowing restarting inflate at those points when randomly accessing the\n   stream.\n\n     inflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not\n   enough memory, Z_STREAM_ERROR if the source stream state was inconsistent\n   (such as zalloc being Z_NULL).  msg is left unchanged in both source and\n   destination.\n*/\n\nZEXTERN int ZEXPORT inflateReset OF((z_streamp strm));\n/*\n     This function is equivalent to inflateEnd followed by inflateInit,\n   but does not free and reallocate the internal decompression state.  The\n   stream will keep attributes that may have been set by inflateInit2.\n\n     inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source\n   stream state was inconsistent (such as zalloc or state being Z_NULL).\n*/\n\nZEXTERN int ZEXPORT inflateReset2 OF((z_streamp strm,\n                                      int windowBits));\n/*\n     This function is the same as inflateReset, but it also permits changing\n   the wrap and window size requests.  The windowBits parameter is interpreted\n   the same as it is for inflateInit2.  If the window size is changed, then the\n   memory allocated for the window is freed, and the window will be reallocated\n   by inflate() if needed.\n\n     inflateReset2 returns Z_OK if success, or Z_STREAM_ERROR if the source\n   stream state was inconsistent (such as zalloc or state being Z_NULL), or if\n   the windowBits parameter is invalid.\n*/\n\nZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm,\n                                     int bits,\n                                     int value));\n/*\n     This function inserts bits in the inflate input stream.  The intent is\n   that this function is used to start inflating at a bit position in the\n   middle of a byte.  The provided bits will be used before any bytes are used\n   from next_in.  This function should only be used with raw inflate, and\n   should be used before the first inflate() call after inflateInit2() or\n   inflateReset().  bits must be less than or equal to 16, and that many of the\n   least significant bits of value will be inserted in the input.\n\n     If bits is negative, then the input stream bit buffer is emptied.  Then\n   inflatePrime() can be called again to put bits in the buffer.  This is used\n   to clear out bits leftover after feeding inflate a block description prior\n   to feeding inflate codes.\n\n     inflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source\n   stream state was inconsistent.\n*/\n\nZEXTERN long ZEXPORT inflateMark OF((z_streamp strm));\n/*\n     This function returns two values, one in the lower 16 bits of the return\n   value, and the other in the remaining upper bits, obtained by shifting the\n   return value down 16 bits.  If the upper value is -1 and the lower value is\n   zero, then inflate() is currently decoding information outside of a block.\n   If the upper value is -1 and the lower value is non-zero, then inflate is in\n   the middle of a stored block, with the lower value equaling the number of\n   bytes from the input remaining to copy.  If the upper value is not -1, then\n   it is the number of bits back from the current bit position in the input of\n   the code (literal or length/distance pair) currently being processed.  In\n   that case the lower value is the number of bytes already emitted for that\n   code.\n\n     A code is being processed if inflate is waiting for more input to complete\n   decoding of the code, or if it has completed decoding but is waiting for\n   more output space to write the literal or match data.\n\n     inflateMark() is used to mark locations in the input data for random\n   access, which may be at bit positions, and to note those cases where the\n   output of a code may span boundaries of random access blocks.  The current\n   location in the input stream can be determined from avail_in and data_type\n   as noted in the description for the Z_BLOCK flush parameter for inflate.\n\n     inflateMark returns the value noted above, or -65536 if the provided\n   source stream state was inconsistent.\n*/\n\nZEXTERN int ZEXPORT inflateGetHeader OF((z_streamp strm,\n                                         gz_headerp head));\n/*\n     inflateGetHeader() requests that gzip header information be stored in the\n   provided gz_header structure.  inflateGetHeader() may be called after\n   inflateInit2() or inflateReset(), and before the first call of inflate().\n   As inflate() processes the gzip stream, head->done is zero until the header\n   is completed, at which time head->done is set to one.  If a zlib stream is\n   being decoded, then head->done is set to -1 to indicate that there will be\n   no gzip header information forthcoming.  Note that Z_BLOCK or Z_TREES can be\n   used to force inflate() to return immediately after header processing is\n   complete and before any actual data is decompressed.\n\n     The text, time, xflags, and os fields are filled in with the gzip header\n   contents.  hcrc is set to true if there is a header CRC.  (The header CRC\n   was valid if done is set to one.) If extra is not Z_NULL, then extra_max\n   contains the maximum number of bytes to write to extra.  Once done is true,\n   extra_len contains the actual extra field length, and extra contains the\n   extra field, or that field truncated if extra_max is less than extra_len.\n   If name is not Z_NULL, then up to name_max characters are written there,\n   terminated with a zero unless the length is greater than name_max.  If\n   comment is not Z_NULL, then up to comm_max characters are written there,\n   terminated with a zero unless the length is greater than comm_max.  When any\n   of extra, name, or comment are not Z_NULL and the respective field is not\n   present in the header, then that field is set to Z_NULL to signal its\n   absence.  This allows the use of deflateSetHeader() with the returned\n   structure to duplicate the header.  However if those fields are set to\n   allocated memory, then the application will need to save those pointers\n   elsewhere so that they can be eventually freed.\n\n     If inflateGetHeader is not used, then the header information is simply\n   discarded.  The header is always checked for validity, including the header\n   CRC if present.  inflateReset() will reset the process to discard the header\n   information.  The application would need to call inflateGetHeader() again to\n   retrieve the header from the next gzip stream.\n\n     inflateGetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source\n   stream state was inconsistent.\n*/\n\n/*\nZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits,\n                                        unsigned char FAR *window));\n\n     Initialize the internal stream state for decompression using inflateBack()\n   calls.  The fields zalloc, zfree and opaque in strm must be initialized\n   before the call.  If zalloc and zfree are Z_NULL, then the default library-\n   derived memory allocation routines are used.  windowBits is the base two\n   logarithm of the window size, in the range 8..15.  window is a caller\n   supplied buffer of that size.  Except for special applications where it is\n   assured that deflate was used with small window sizes, windowBits must be 15\n   and a 32K byte window must be supplied to be able to decompress general\n   deflate streams.\n\n     See inflateBack() for the usage of these routines.\n\n     inflateBackInit will return Z_OK on success, Z_STREAM_ERROR if any of\n   the parameters are invalid, Z_MEM_ERROR if the internal state could not be\n   allocated, or Z_VERSION_ERROR if the version of the library does not match\n   the version of the header file.\n*/\n\ntypedef unsigned (*in_func) OF((void FAR *,\n                                z_const unsigned char FAR * FAR *));\ntypedef int (*out_func) OF((void FAR *, unsigned char FAR *, unsigned));\n\nZEXTERN int ZEXPORT inflateBack OF((z_streamp strm,\n                                    in_func in, void FAR *in_desc,\n                                    out_func out, void FAR *out_desc));\n/*\n     inflateBack() does a raw inflate with a single call using a call-back\n   interface for input and output.  This is potentially more efficient than\n   inflate() for file i/o applications, in that it avoids copying between the\n   output and the sliding window by simply making the window itself the output\n   buffer.  inflate() can be faster on modern CPUs when used with large\n   buffers.  inflateBack() trusts the application to not change the output\n   buffer passed by the output function, at least until inflateBack() returns.\n\n     inflateBackInit() must be called first to allocate the internal state\n   and to initialize the state with the user-provided window buffer.\n   inflateBack() may then be used multiple times to inflate a complete, raw\n   deflate stream with each call.  inflateBackEnd() is then called to free the\n   allocated state.\n\n     A raw deflate stream is one with no zlib or gzip header or trailer.\n   This routine would normally be used in a utility that reads zip or gzip\n   files and writes out uncompressed files.  The utility would decode the\n   header and process the trailer on its own, hence this routine expects only\n   the raw deflate stream to decompress.  This is different from the default\n   behavior of inflate(), which expects a zlib header and trailer around the\n   deflate stream.\n\n     inflateBack() uses two subroutines supplied by the caller that are then\n   called by inflateBack() for input and output.  inflateBack() calls those\n   routines until it reads a complete deflate stream and writes out all of the\n   uncompressed data, or until it encounters an error.  The function's\n   parameters and return types are defined above in the in_func and out_func\n   typedefs.  inflateBack() will call in(in_desc, &buf) which should return the\n   number of bytes of provided input, and a pointer to that input in buf.  If\n   there is no input available, in() must return zero -- buf is ignored in that\n   case -- and inflateBack() will return a buffer error.  inflateBack() will\n   call out(out_desc, buf, len) to write the uncompressed data buf[0..len-1].\n   out() should return zero on success, or non-zero on failure.  If out()\n   returns non-zero, inflateBack() will return with an error.  Neither in() nor\n   out() are permitted to change the contents of the window provided to\n   inflateBackInit(), which is also the buffer that out() uses to write from.\n   The length written by out() will be at most the window size.  Any non-zero\n   amount of input may be provided by in().\n\n     For convenience, inflateBack() can be provided input on the first call by\n   setting strm->next_in and strm->avail_in.  If that input is exhausted, then\n   in() will be called.  Therefore strm->next_in must be initialized before\n   calling inflateBack().  If strm->next_in is Z_NULL, then in() will be called\n   immediately for input.  If strm->next_in is not Z_NULL, then strm->avail_in\n   must also be initialized, and then if strm->avail_in is not zero, input will\n   initially be taken from strm->next_in[0 ..  strm->avail_in - 1].\n\n     The in_desc and out_desc parameters of inflateBack() is passed as the\n   first parameter of in() and out() respectively when they are called.  These\n   descriptors can be optionally used to pass any information that the caller-\n   supplied in() and out() functions need to do their job.\n\n     On return, inflateBack() will set strm->next_in and strm->avail_in to\n   pass back any unused input that was provided by the last in() call.  The\n   return values of inflateBack() can be Z_STREAM_END on success, Z_BUF_ERROR\n   if in() or out() returned an error, Z_DATA_ERROR if there was a format error\n   in the deflate stream (in which case strm->msg is set to indicate the nature\n   of the error), or Z_STREAM_ERROR if the stream was not properly initialized.\n   In the case of Z_BUF_ERROR, an input or output error can be distinguished\n   using strm->next_in which will be Z_NULL only if in() returned an error.  If\n   strm->next_in is not Z_NULL, then the Z_BUF_ERROR was due to out() returning\n   non-zero.  (in() will always be called before out(), so strm->next_in is\n   assured to be defined if out() returns non-zero.)  Note that inflateBack()\n   cannot return Z_OK.\n*/\n\nZEXTERN int ZEXPORT inflateBackEnd OF((z_streamp strm));\n/*\n     All memory allocated by inflateBackInit() is freed.\n\n     inflateBackEnd() returns Z_OK on success, or Z_STREAM_ERROR if the stream\n   state was inconsistent.\n*/\n\nZEXTERN uLong ZEXPORT zlibCompileFlags OF((void));\n/* Return flags indicating compile-time options.\n\n    Type sizes, two bits each, 00 = 16 bits, 01 = 32, 10 = 64, 11 = other:\n     1.0: size of uInt\n     3.2: size of uLong\n     5.4: size of voidpf (pointer)\n     7.6: size of z_off_t\n\n    Compiler, assembler, and debug options:\n     8: ZLIB_DEBUG\n     9: ASMV or ASMINF -- use ASM code\n     10: ZLIB_WINAPI -- exported functions use the WINAPI calling convention\n     11: 0 (reserved)\n\n    One-time table building (smaller code, but not thread-safe if true):\n     12: BUILDFIXED -- build static block decoding tables when needed\n     13: DYNAMIC_CRC_TABLE -- build CRC calculation tables when needed\n     14,15: 0 (reserved)\n\n    Library content (indicates missing functionality):\n     16: NO_GZCOMPRESS -- gz* functions cannot compress (to avoid linking\n                          deflate code when not needed)\n     17: NO_GZIP -- deflate can't write gzip streams, and inflate can't detect\n                    and decode gzip streams (to avoid linking crc code)\n     18-19: 0 (reserved)\n\n    Operation variations (changes in library functionality):\n     20: PKZIP_BUG_WORKAROUND -- slightly more permissive inflate\n     21: FASTEST -- deflate algorithm with only one, lowest compression level\n     22,23: 0 (reserved)\n\n    The sprintf variant used by gzprintf (zero is best):\n     24: 0 = vs*, 1 = s* -- 1 means limited to 20 arguments after the format\n     25: 0 = *nprintf, 1 = *printf -- 1 means gzprintf() not secure!\n     26: 0 = returns value, 1 = void -- 1 means inferred string length returned\n\n    Remainder:\n     27-31: 0 (reserved)\n */\n\n#ifndef Z_SOLO\n\n                        /* utility functions */\n\n/*\n     The following utility functions are implemented on top of the basic\n   stream-oriented functions.  To simplify the interface, some default options\n   are assumed (compression level and memory usage, standard memory allocation\n   functions).  The source code of these utility functions can be modified if\n   you need special options.\n*/\n\nZEXTERN int ZEXPORT compress OF((Bytef *dest,   uLongf *destLen,\n                                 const Bytef *source, uLong sourceLen));\n/*\n     Compresses the source buffer into the destination buffer.  sourceLen is\n   the byte length of the source buffer.  Upon entry, destLen is the total size\n   of the destination buffer, which must be at least the value returned by\n   compressBound(sourceLen).  Upon exit, destLen is the actual size of the\n   compressed data.  compress() is equivalent to compress2() with a level\n   parameter of Z_DEFAULT_COMPRESSION.\n\n     compress returns Z_OK if success, Z_MEM_ERROR if there was not\n   enough memory, Z_BUF_ERROR if there was not enough room in the output\n   buffer.\n*/\n\nZEXTERN int ZEXPORT compress2 OF((Bytef *dest,   uLongf *destLen,\n                                  const Bytef *source, uLong sourceLen,\n                                  int level));\n/*\n     Compresses the source buffer into the destination buffer.  The level\n   parameter has the same meaning as in deflateInit.  sourceLen is the byte\n   length of the source buffer.  Upon entry, destLen is the total size of the\n   destination buffer, which must be at least the value returned by\n   compressBound(sourceLen).  Upon exit, destLen is the actual size of the\n   compressed data.\n\n     compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough\n   memory, Z_BUF_ERROR if there was not enough room in the output buffer,\n   Z_STREAM_ERROR if the level parameter is invalid.\n*/\n\nZEXTERN uLong ZEXPORT compressBound OF((uLong sourceLen));\n/*\n     compressBound() returns an upper bound on the compressed size after\n   compress() or compress2() on sourceLen bytes.  It would be used before a\n   compress() or compress2() call to allocate the destination buffer.\n*/\n\nZEXTERN int ZEXPORT uncompress OF((Bytef *dest,   uLongf *destLen,\n                                   const Bytef *source, uLong sourceLen));\n/*\n     Decompresses the source buffer into the destination buffer.  sourceLen is\n   the byte length of the source buffer.  Upon entry, destLen is the total size\n   of the destination buffer, which must be large enough to hold the entire\n   uncompressed data.  (The size of the uncompressed data must have been saved\n   previously by the compressor and transmitted to the decompressor by some\n   mechanism outside the scope of this compression library.) Upon exit, destLen\n   is the actual size of the uncompressed data.\n\n     uncompress returns Z_OK if success, Z_MEM_ERROR if there was not\n   enough memory, Z_BUF_ERROR if there was not enough room in the output\n   buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete.  In\n   the case where there is not enough room, uncompress() will fill the output\n   buffer with the uncompressed data up to that point.\n*/\n\nZEXTERN int ZEXPORT uncompress2 OF((Bytef *dest,   uLongf *destLen,\n                                    const Bytef *source, uLong *sourceLen));\n/*\n     Same as uncompress, except that sourceLen is a pointer, where the\n   length of the source is *sourceLen.  On return, *sourceLen is the number of\n   source bytes consumed.\n*/\n\n                        /* gzip file access functions */\n\n/*\n     This library supports reading and writing files in gzip (.gz) format with\n   an interface similar to that of stdio, using the functions that start with\n   \"gz\".  The gzip format is different from the zlib format.  gzip is a gzip\n   wrapper, documented in RFC 1952, wrapped around a deflate stream.\n*/\n\ntypedef struct gzFile_s *gzFile;    /* semi-opaque gzip file descriptor */\n\n/*\nZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode));\n\n     Opens a gzip (.gz) file for reading or writing.  The mode parameter is as\n   in fopen (\"rb\" or \"wb\") but can also include a compression level (\"wb9\") or\n   a strategy: 'f' for filtered data as in \"wb6f\", 'h' for Huffman-only\n   compression as in \"wb1h\", 'R' for run-length encoding as in \"wb1R\", or 'F'\n   for fixed code compression as in \"wb9F\".  (See the description of\n   deflateInit2 for more information about the strategy parameter.)  'T' will\n   request transparent writing or appending with no compression and not using\n   the gzip format.\n\n     \"a\" can be used instead of \"w\" to request that the gzip stream that will\n   be written be appended to the file.  \"+\" will result in an error, since\n   reading and writing to the same gzip file is not supported.  The addition of\n   \"x\" when writing will create the file exclusively, which fails if the file\n   already exists.  On systems that support it, the addition of \"e\" when\n   reading or writing will set the flag to close the file on an execve() call.\n\n     These functions, as well as gzip, will read and decode a sequence of gzip\n   streams in a file.  The append function of gzopen() can be used to create\n   such a file.  (Also see gzflush() for another way to do this.)  When\n   appending, gzopen does not test whether the file begins with a gzip stream,\n   nor does it look for the end of the gzip streams to begin appending.  gzopen\n   will simply append a gzip stream to the existing file.\n\n     gzopen can be used to read a file which is not in gzip format; in this\n   case gzread will directly read from the file without decompression.  When\n   reading, this will be detected automatically by looking for the magic two-\n   byte gzip header.\n\n     gzopen returns NULL if the file could not be opened, if there was\n   insufficient memory to allocate the gzFile state, or if an invalid mode was\n   specified (an 'r', 'w', or 'a' was not provided, or '+' was provided).\n   errno can be checked to determine if the reason gzopen failed was that the\n   file could not be opened.\n*/\n\nZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode));\n/*\n     gzdopen associates a gzFile with the file descriptor fd.  File descriptors\n   are obtained from calls like open, dup, creat, pipe or fileno (if the file\n   has been previously opened with fopen).  The mode parameter is as in gzopen.\n\n     The next call of gzclose on the returned gzFile will also close the file\n   descriptor fd, just like fclose(fdopen(fd, mode)) closes the file descriptor\n   fd.  If you want to keep fd open, use fd = dup(fd_keep); gz = gzdopen(fd,\n   mode);.  The duplicated descriptor should be saved to avoid a leak, since\n   gzdopen does not close fd if it fails.  If you are using fileno() to get the\n   file descriptor from a FILE *, then you will have to use dup() to avoid\n   double-close()ing the file descriptor.  Both gzclose() and fclose() will\n   close the associated file descriptor, so they need to have different file\n   descriptors.\n\n     gzdopen returns NULL if there was insufficient memory to allocate the\n   gzFile state, if an invalid mode was specified (an 'r', 'w', or 'a' was not\n   provided, or '+' was provided), or if fd is -1.  The file descriptor is not\n   used until the next gz* read, write, seek, or close operation, so gzdopen\n   will not detect if fd is invalid (unless fd is -1).\n*/\n\nZEXTERN int ZEXPORT gzbuffer OF((gzFile file, unsigned size));\n/*\n     Set the internal buffer size used by this library's functions.  The\n   default buffer size is 8192 bytes.  This function must be called after\n   gzopen() or gzdopen(), and before any other calls that read or write the\n   file.  The buffer memory allocation is always deferred to the first read or\n   write.  Three times that size in buffer space is allocated.  A larger buffer\n   size of, for example, 64K or 128K bytes will noticeably increase the speed\n   of decompression (reading).\n\n     The new buffer size also affects the maximum length for gzprintf().\n\n     gzbuffer() returns 0 on success, or -1 on failure, such as being called\n   too late.\n*/\n\nZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy));\n/*\n     Dynamically update the compression level or strategy.  See the description\n   of deflateInit2 for the meaning of these parameters.  Previously provided\n   data is flushed before the parameter change.\n\n     gzsetparams returns Z_OK if success, Z_STREAM_ERROR if the file was not\n   opened for writing, Z_ERRNO if there is an error writing the flushed data,\n   or Z_MEM_ERROR if there is a memory allocation error.\n*/\n\nZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len));\n/*\n     Reads the given number of uncompressed bytes from the compressed file.  If\n   the input file is not in gzip format, gzread copies the given number of\n   bytes into the buffer directly from the file.\n\n     After reaching the end of a gzip stream in the input, gzread will continue\n   to read, looking for another gzip stream.  Any number of gzip streams may be\n   concatenated in the input file, and will all be decompressed by gzread().\n   If something other than a gzip stream is encountered after a gzip stream,\n   that remaining trailing garbage is ignored (and no error is returned).\n\n     gzread can be used to read a gzip file that is being concurrently written.\n   Upon reaching the end of the input, gzread will return with the available\n   data.  If the error code returned by gzerror is Z_OK or Z_BUF_ERROR, then\n   gzclearerr can be used to clear the end of file indicator in order to permit\n   gzread to be tried again.  Z_OK indicates that a gzip stream was completed\n   on the last gzread.  Z_BUF_ERROR indicates that the input file ended in the\n   middle of a gzip stream.  Note that gzread does not return -1 in the event\n   of an incomplete gzip stream.  This error is deferred until gzclose(), which\n   will return Z_BUF_ERROR if the last gzread ended in the middle of a gzip\n   stream.  Alternatively, gzerror can be used before gzclose to detect this\n   case.\n\n     gzread returns the number of uncompressed bytes actually read, less than\n   len for end of file, or -1 for error.  If len is too large to fit in an int,\n   then nothing is read, -1 is returned, and the error state is set to\n   Z_STREAM_ERROR.\n*/\n\nZEXTERN z_size_t ZEXPORT gzfread OF((voidp buf, z_size_t size, z_size_t nitems,\n                                     gzFile file));\n/*\n     Read up to nitems items of size size from file to buf, otherwise operating\n   as gzread() does.  This duplicates the interface of stdio's fread(), with\n   size_t request and return types.  If the library defines size_t, then\n   z_size_t is identical to size_t.  If not, then z_size_t is an unsigned\n   integer type that can contain a pointer.\n\n     gzfread() returns the number of full items read of size size, or zero if\n   the end of the file was reached and a full item could not be read, or if\n   there was an error.  gzerror() must be consulted if zero is returned in\n   order to determine if there was an error.  If the multiplication of size and\n   nitems overflows, i.e. the product does not fit in a z_size_t, then nothing\n   is read, zero is returned, and the error state is set to Z_STREAM_ERROR.\n\n     In the event that the end of file is reached and only a partial item is\n   available at the end, i.e. the remaining uncompressed data length is not a\n   multiple of size, then the final partial item is nevetheless read into buf\n   and the end-of-file flag is set.  The length of the partial item read is not\n   provided, but could be inferred from the result of gztell().  This behavior\n   is the same as the behavior of fread() implementations in common libraries,\n   but it prevents the direct use of gzfread() to read a concurrently written\n   file, reseting and retrying on end-of-file, when size is not 1.\n*/\n\nZEXTERN int ZEXPORT gzwrite OF((gzFile file,\n                                voidpc buf, unsigned len));\n/*\n     Writes the given number of uncompressed bytes into the compressed file.\n   gzwrite returns the number of uncompressed bytes written or 0 in case of\n   error.\n*/\n\nZEXTERN z_size_t ZEXPORT gzfwrite OF((voidpc buf, z_size_t size,\n                                      z_size_t nitems, gzFile file));\n/*\n     gzfwrite() writes nitems items of size size from buf to file, duplicating\n   the interface of stdio's fwrite(), with size_t request and return types.  If\n   the library defines size_t, then z_size_t is identical to size_t.  If not,\n   then z_size_t is an unsigned integer type that can contain a pointer.\n\n     gzfwrite() returns the number of full items written of size size, or zero\n   if there was an error.  If the multiplication of size and nitems overflows,\n   i.e. the product does not fit in a z_size_t, then nothing is written, zero\n   is returned, and the error state is set to Z_STREAM_ERROR.\n*/\n\nZEXTERN int ZEXPORTVA gzprintf Z_ARG((gzFile file, const char *format, ...));\n/*\n     Converts, formats, and writes the arguments to the compressed file under\n   control of the format string, as in fprintf.  gzprintf returns the number of\n   uncompressed bytes actually written, or a negative zlib error code in case\n   of error.  The number of uncompressed bytes written is limited to 8191, or\n   one less than the buffer size given to gzbuffer().  The caller should assure\n   that this limit is not exceeded.  If it is exceeded, then gzprintf() will\n   return an error (0) with nothing written.  In this case, there may also be a\n   buffer overflow with unpredictable consequences, which is possible only if\n   zlib was compiled with the insecure functions sprintf() or vsprintf()\n   because the secure snprintf() or vsnprintf() functions were not available.\n   This can be determined using zlibCompileFlags().\n*/\n\nZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s));\n/*\n     Writes the given null-terminated string to the compressed file, excluding\n   the terminating null character.\n\n     gzputs returns the number of characters written, or -1 in case of error.\n*/\n\nZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len));\n/*\n     Reads bytes from the compressed file until len-1 characters are read, or a\n   newline character is read and transferred to buf, or an end-of-file\n   condition is encountered.  If any characters are read or if len == 1, the\n   string is terminated with a null character.  If no characters are read due\n   to an end-of-file or len < 1, then the buffer is left untouched.\n\n     gzgets returns buf which is a null-terminated string, or it returns NULL\n   for end-of-file or in case of error.  If there was an error, the contents at\n   buf are indeterminate.\n*/\n\nZEXTERN int ZEXPORT gzputc OF((gzFile file, int c));\n/*\n     Writes c, converted to an unsigned char, into the compressed file.  gzputc\n   returns the value that was written, or -1 in case of error.\n*/\n\nZEXTERN int ZEXPORT gzgetc OF((gzFile file));\n/*\n     Reads one byte from the compressed file.  gzgetc returns this byte or -1\n   in case of end of file or error.  This is implemented as a macro for speed.\n   As such, it does not do all of the checking the other functions do.  I.e.\n   it does not check to see if file is NULL, nor whether the structure file\n   points to has been clobbered or not.\n*/\n\nZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file));\n/*\n     Push one character back onto the stream to be read as the first character\n   on the next read.  At least one character of push-back is allowed.\n   gzungetc() returns the character pushed, or -1 on failure.  gzungetc() will\n   fail if c is -1, and may fail if a character has been pushed but not read\n   yet.  If gzungetc is used immediately after gzopen or gzdopen, at least the\n   output buffer size of pushed characters is allowed.  (See gzbuffer above.)\n   The pushed character will be discarded if the stream is repositioned with\n   gzseek() or gzrewind().\n*/\n\nZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush));\n/*\n     Flushes all pending output into the compressed file.  The parameter flush\n   is as in the deflate() function.  The return value is the zlib error number\n   (see function gzerror below).  gzflush is only permitted when writing.\n\n     If the flush parameter is Z_FINISH, the remaining data is written and the\n   gzip stream is completed in the output.  If gzwrite() is called again, a new\n   gzip stream will be started in the output.  gzread() is able to read such\n   concatenated gzip streams.\n\n     gzflush should be called only when strictly necessary because it will\n   degrade compression if called too often.\n*/\n\n/*\nZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file,\n                                   z_off_t offset, int whence));\n\n     Sets the starting position for the next gzread or gzwrite on the given\n   compressed file.  The offset represents a number of bytes in the\n   uncompressed data stream.  The whence parameter is defined as in lseek(2);\n   the value SEEK_END is not supported.\n\n     If the file is opened for reading, this function is emulated but can be\n   extremely slow.  If the file is opened for writing, only forward seeks are\n   supported; gzseek then compresses a sequence of zeroes up to the new\n   starting position.\n\n     gzseek returns the resulting offset location as measured in bytes from\n   the beginning of the uncompressed stream, or -1 in case of error, in\n   particular if the file is opened for writing and the new starting position\n   would be before the current position.\n*/\n\nZEXTERN int ZEXPORT    gzrewind OF((gzFile file));\n/*\n     Rewinds the given file. This function is supported only for reading.\n\n     gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET)\n*/\n\n/*\nZEXTERN z_off_t ZEXPORT    gztell OF((gzFile file));\n\n     Returns the starting position for the next gzread or gzwrite on the given\n   compressed file.  This position represents a number of bytes in the\n   uncompressed data stream, and is zero when starting, even if appending or\n   reading a gzip stream from the middle of a file using gzdopen().\n\n     gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR)\n*/\n\n/*\nZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile file));\n\n     Returns the current offset in the file being read or written.  This offset\n   includes the count of bytes that precede the gzip stream, for example when\n   appending or when using gzdopen() for reading.  When reading, the offset\n   does not include as yet unused buffered input.  This information can be used\n   for a progress indicator.  On error, gzoffset() returns -1.\n*/\n\nZEXTERN int ZEXPORT gzeof OF((gzFile file));\n/*\n     Returns true (1) if the end-of-file indicator has been set while reading,\n   false (0) otherwise.  Note that the end-of-file indicator is set only if the\n   read tried to go past the end of the input, but came up short.  Therefore,\n   just like feof(), gzeof() may return false even if there is no more data to\n   read, in the event that the last read request was for the exact number of\n   bytes remaining in the input file.  This will happen if the input file size\n   is an exact multiple of the buffer size.\n\n     If gzeof() returns true, then the read functions will return no more data,\n   unless the end-of-file indicator is reset by gzclearerr() and the input file\n   has grown since the previous end of file was detected.\n*/\n\nZEXTERN int ZEXPORT gzdirect OF((gzFile file));\n/*\n     Returns true (1) if file is being copied directly while reading, or false\n   (0) if file is a gzip stream being decompressed.\n\n     If the input file is empty, gzdirect() will return true, since the input\n   does not contain a gzip stream.\n\n     If gzdirect() is used immediately after gzopen() or gzdopen() it will\n   cause buffers to be allocated to allow reading the file to determine if it\n   is a gzip file.  Therefore if gzbuffer() is used, it should be called before\n   gzdirect().\n\n     When writing, gzdirect() returns true (1) if transparent writing was\n   requested (\"wT\" for the gzopen() mode), or false (0) otherwise.  (Note:\n   gzdirect() is not needed when writing.  Transparent writing must be\n   explicitly requested, so the application already knows the answer.  When\n   linking statically, using gzdirect() will include all of the zlib code for\n   gzip file reading and decompression, which may not be desired.)\n*/\n\nZEXTERN int ZEXPORT    gzclose OF((gzFile file));\n/*\n     Flushes all pending output if necessary, closes the compressed file and\n   deallocates the (de)compression state.  Note that once file is closed, you\n   cannot call gzerror with file, since its structures have been deallocated.\n   gzclose must not be called more than once on the same file, just as free\n   must not be called more than once on the same allocation.\n\n     gzclose will return Z_STREAM_ERROR if file is not valid, Z_ERRNO on a\n   file operation error, Z_MEM_ERROR if out of memory, Z_BUF_ERROR if the\n   last read ended in the middle of a gzip stream, or Z_OK on success.\n*/\n\nZEXTERN int ZEXPORT gzclose_r OF((gzFile file));\nZEXTERN int ZEXPORT gzclose_w OF((gzFile file));\n/*\n     Same as gzclose(), but gzclose_r() is only for use when reading, and\n   gzclose_w() is only for use when writing or appending.  The advantage to\n   using these instead of gzclose() is that they avoid linking in zlib\n   compression or decompression code that is not used when only reading or only\n   writing respectively.  If gzclose() is used, then both compression and\n   decompression code will be included the application when linking to a static\n   zlib library.\n*/\n\nZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum));\n/*\n     Returns the error message for the last error which occurred on the given\n   compressed file.  errnum is set to zlib error number.  If an error occurred\n   in the file system and not in the compression library, errnum is set to\n   Z_ERRNO and the application may consult errno to get the exact error code.\n\n     The application must not modify the returned string.  Future calls to\n   this function may invalidate the previously returned string.  If file is\n   closed, then the string previously returned by gzerror will no longer be\n   available.\n\n     gzerror() should be used to distinguish errors from end-of-file for those\n   functions above that do not distinguish those cases in their return values.\n*/\n\nZEXTERN void ZEXPORT gzclearerr OF((gzFile file));\n/*\n     Clears the error and end-of-file flags for file.  This is analogous to the\n   clearerr() function in stdio.  This is useful for continuing to read a gzip\n   file that is being written concurrently.\n*/\n\n#endif /* !Z_SOLO */\n\n                        /* checksum functions */\n\n/*\n     These functions are not related to compression but are exported\n   anyway because they might be useful in applications using the compression\n   library.\n*/\n\nZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len));\n/*\n     Update a running Adler-32 checksum with the bytes buf[0..len-1] and\n   return the updated checksum.  If buf is Z_NULL, this function returns the\n   required initial value for the checksum.\n\n     An Adler-32 checksum is almost as reliable as a CRC-32 but can be computed\n   much faster.\n\n   Usage example:\n\n     uLong adler = adler32(0L, Z_NULL, 0);\n\n     while (read_buffer(buffer, length) != EOF) {\n       adler = adler32(adler, buffer, length);\n     }\n     if (adler != original_adler) error();\n*/\n\nZEXTERN uLong ZEXPORT adler32_z OF((uLong adler, const Bytef *buf,\n                                    z_size_t len));\n/*\n     Same as adler32(), but with a size_t length.\n*/\n\n/*\nZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2,\n                                          z_off_t len2));\n\n     Combine two Adler-32 checksums into one.  For two sequences of bytes, seq1\n   and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for\n   each, adler1 and adler2.  adler32_combine() returns the Adler-32 checksum of\n   seq1 and seq2 concatenated, requiring only adler1, adler2, and len2.  Note\n   that the z_off_t type (like off_t) is a signed integer.  If len2 is\n   negative, the result has no meaning or utility.\n*/\n\nZEXTERN uLong ZEXPORT crc32   OF((uLong crc, const Bytef *buf, uInt len));\n/*\n     Update a running CRC-32 with the bytes buf[0..len-1] and return the\n   updated CRC-32.  If buf is Z_NULL, this function returns the required\n   initial value for the crc.  Pre- and post-conditioning (one's complement) is\n   performed within this function so it shouldn't be done by the application.\n\n   Usage example:\n\n     uLong crc = crc32(0L, Z_NULL, 0);\n\n     while (read_buffer(buffer, length) != EOF) {\n       crc = crc32(crc, buffer, length);\n     }\n     if (crc != original_crc) error();\n*/\n\nZEXTERN uLong ZEXPORT crc32_z OF((uLong adler, const Bytef *buf,\n                                  z_size_t len));\n/*\n     Same as crc32(), but with a size_t length.\n*/\n\n/*\nZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2));\n\n     Combine two CRC-32 check values into one.  For two sequences of bytes,\n   seq1 and seq2 with lengths len1 and len2, CRC-32 check values were\n   calculated for each, crc1 and crc2.  crc32_combine() returns the CRC-32\n   check value of seq1 and seq2 concatenated, requiring only crc1, crc2, and\n   len2.\n*/\n\n\n                        /* various hacks, don't look :) */\n\n/* deflateInit and inflateInit are macros to allow checking the zlib version\n * and the compiler's view of z_stream:\n */\nZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level,\n                                     const char *version, int stream_size));\nZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm,\n                                     const char *version, int stream_size));\nZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int  level, int  method,\n                                      int windowBits, int memLevel,\n                                      int strategy, const char *version,\n                                      int stream_size));\nZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int  windowBits,\n                                      const char *version, int stream_size));\nZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits,\n                                         unsigned char FAR *window,\n                                         const char *version,\n                                         int stream_size));\n#ifdef Z_PREFIX_SET\n#  define z_deflateInit(strm, level) \\\n          deflateInit_((strm), (level), ZLIB_VERSION, (int)sizeof(z_stream))\n#  define z_inflateInit(strm) \\\n          inflateInit_((strm), ZLIB_VERSION, (int)sizeof(z_stream))\n#  define z_deflateInit2(strm, level, method, windowBits, memLevel, strategy) \\\n          deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\\\n                        (strategy), ZLIB_VERSION, (int)sizeof(z_stream))\n#  define z_inflateInit2(strm, windowBits) \\\n          inflateInit2_((strm), (windowBits), ZLIB_VERSION, \\\n                        (int)sizeof(z_stream))\n#  define z_inflateBackInit(strm, windowBits, window) \\\n          inflateBackInit_((strm), (windowBits), (window), \\\n                           ZLIB_VERSION, (int)sizeof(z_stream))\n#else\n#  define deflateInit(strm, level) \\\n          deflateInit_((strm), (level), ZLIB_VERSION, (int)sizeof(z_stream))\n#  define inflateInit(strm) \\\n          inflateInit_((strm), ZLIB_VERSION, (int)sizeof(z_stream))\n#  define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \\\n          deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\\\n                        (strategy), ZLIB_VERSION, (int)sizeof(z_stream))\n#  define inflateInit2(strm, windowBits) \\\n          inflateInit2_((strm), (windowBits), ZLIB_VERSION, \\\n                        (int)sizeof(z_stream))\n#  define inflateBackInit(strm, windowBits, window) \\\n          inflateBackInit_((strm), (windowBits), (window), \\\n                           ZLIB_VERSION, (int)sizeof(z_stream))\n#endif\n\n#ifndef Z_SOLO\n\n/* gzgetc() macro and its supporting function and exposed data structure.  Note\n * that the real internal state is much larger than the exposed structure.\n * This abbreviated structure exposes just enough for the gzgetc() macro.  The\n * user should not mess with these exposed elements, since their names or\n * behavior could change in the future, perhaps even capriciously.  They can\n * only be used by the gzgetc() macro.  You have been warned.\n */\nstruct gzFile_s {\n    unsigned have;\n    unsigned char *next;\n    z_off64_t pos;\n};\nZEXTERN int ZEXPORT gzgetc_ OF((gzFile file));  /* backward compatibility */\n#ifdef Z_PREFIX_SET\n#  undef z_gzgetc\n#  define z_gzgetc(g) \\\n          ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : (gzgetc)(g))\n#else\n#  define gzgetc(g) \\\n          ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : (gzgetc)(g))\n#endif\n\n/* provide 64-bit offset functions if _LARGEFILE64_SOURCE defined, and/or\n * change the regular functions to 64 bits if _FILE_OFFSET_BITS is 64 (if\n * both are true, the application gets the *64 functions, and the regular\n * functions are changed to 64 bits) -- in case these are set on systems\n * without large file support, _LFS64_LARGEFILE must also be true\n */\n#ifdef Z_LARGE64\n   ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *));\n   ZEXTERN z_off64_t ZEXPORT gzseek64 OF((gzFile, z_off64_t, int));\n   ZEXTERN z_off64_t ZEXPORT gztell64 OF((gzFile));\n   ZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile));\n   ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off64_t));\n   ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off64_t));\n#endif\n\n#if !defined(ZLIB_INTERNAL) && defined(Z_WANT64)\n#  ifdef Z_PREFIX_SET\n#    define z_gzopen z_gzopen64\n#    define z_gzseek z_gzseek64\n#    define z_gztell z_gztell64\n#    define z_gzoffset z_gzoffset64\n#    define z_adler32_combine z_adler32_combine64\n#    define z_crc32_combine z_crc32_combine64\n#  else\n#    define gzopen gzopen64\n#    define gzseek gzseek64\n#    define gztell gztell64\n#    define gzoffset gzoffset64\n#    define adler32_combine adler32_combine64\n#    define crc32_combine crc32_combine64\n#  endif\n#  ifndef Z_LARGE64\n     ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *));\n     ZEXTERN z_off_t ZEXPORT gzseek64 OF((gzFile, z_off_t, int));\n     ZEXTERN z_off_t ZEXPORT gztell64 OF((gzFile));\n     ZEXTERN z_off_t ZEXPORT gzoffset64 OF((gzFile));\n     ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t));\n     ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t));\n#  endif\n#else\n   ZEXTERN gzFile ZEXPORT gzopen OF((const char *, const char *));\n   ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile, z_off_t, int));\n   ZEXTERN z_off_t ZEXPORT gztell OF((gzFile));\n   ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile));\n   ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t));\n   ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t));\n#endif\n\n#else /* Z_SOLO */\n\n   ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t));\n   ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t));\n\n#endif /* !Z_SOLO */\n\n/* undocumented functions */\nZEXTERN const char   * ZEXPORT zError           OF((int));\nZEXTERN int            ZEXPORT inflateSyncPoint OF((z_streamp));\nZEXTERN const z_crc_t FAR * ZEXPORT get_crc_table    OF((void));\nZEXTERN int            ZEXPORT inflateUndermine OF((z_streamp, int));\nZEXTERN int            ZEXPORT inflateValidate OF((z_streamp, int));\nZEXTERN unsigned long  ZEXPORT inflateCodesUsed OF ((z_streamp));\nZEXTERN int            ZEXPORT inflateResetKeep OF((z_streamp));\nZEXTERN int            ZEXPORT deflateResetKeep OF((z_streamp));\n#if (defined(_WIN32) || defined(__CYGWIN__)) && !defined(Z_SOLO)\nZEXTERN gzFile         ZEXPORT gzopen_w OF((const wchar_t *path,\n                                            const char *mode));\n#endif\n#if defined(STDC) || defined(Z_HAVE_STDARG_H)\n#  ifndef Z_SOLO\nZEXTERN int            ZEXPORTVA gzvprintf Z_ARG((gzFile file,\n                                                  const char *format,\n                                                  va_list va));\n#  endif\n#endif\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* ZLIB_H */\n"
  },
  {
    "path": "Projects/Libraries/CSBase/Source/zlib/zutil.c",
    "content": "/* zutil.c -- target dependent utility functions for the compression library\n * Copyright (C) 1995-2017 Jean-loup Gailly\n * For conditions of distribution and use, see copyright notice in zlib.h\n */\n\n/* @(#) $Id$ */\n\n#include \"zutil.h\"\n#ifndef Z_SOLO\n#  include \"gzguts.h\"\n#endif\n\nz_const char * const z_errmsg[10] = {\n    (z_const char *)\"need dictionary\",     /* Z_NEED_DICT       2  */\n    (z_const char *)\"stream end\",          /* Z_STREAM_END      1  */\n    (z_const char *)\"\",                    /* Z_OK              0  */\n    (z_const char *)\"file error\",          /* Z_ERRNO         (-1) */\n    (z_const char *)\"stream error\",        /* Z_STREAM_ERROR  (-2) */\n    (z_const char *)\"data error\",          /* Z_DATA_ERROR    (-3) */\n    (z_const char *)\"insufficient memory\", /* Z_MEM_ERROR     (-4) */\n    (z_const char *)\"buffer error\",        /* Z_BUF_ERROR     (-5) */\n    (z_const char *)\"incompatible version\",/* Z_VERSION_ERROR (-6) */\n    (z_const char *)\"\"\n};\n\n\nconst char * ZEXPORT zlibVersion()\n{\n    return ZLIB_VERSION;\n}\n\nuLong ZEXPORT zlibCompileFlags()\n{\n    uLong flags;\n\n    flags = 0;\n    switch ((int)(sizeof(uInt))) {\n    case 2:     break;\n    case 4:     flags += 1;     break;\n    case 8:     flags += 2;     break;\n    default:    flags += 3;\n    }\n    switch ((int)(sizeof(uLong))) {\n    case 2:     break;\n    case 4:     flags += 1 << 2;        break;\n    case 8:     flags += 2 << 2;        break;\n    default:    flags += 3 << 2;\n    }\n    switch ((int)(sizeof(voidpf))) {\n    case 2:     break;\n    case 4:     flags += 1 << 4;        break;\n    case 8:     flags += 2 << 4;        break;\n    default:    flags += 3 << 4;\n    }\n    switch ((int)(sizeof(z_off_t))) {\n    case 2:     break;\n    case 4:     flags += 1 << 6;        break;\n    case 8:     flags += 2 << 6;        break;\n    default:    flags += 3 << 6;\n    }\n#ifdef ZLIB_DEBUG\n    flags += 1 << 8;\n#endif\n#if defined(ASMV) || defined(ASMINF)\n    flags += 1 << 9;\n#endif\n#ifdef ZLIB_WINAPI\n    flags += 1 << 10;\n#endif\n#ifdef BUILDFIXED\n    flags += 1 << 12;\n#endif\n#ifdef DYNAMIC_CRC_TABLE\n    flags += 1 << 13;\n#endif\n#ifdef NO_GZCOMPRESS\n    flags += 1L << 16;\n#endif\n#ifdef NO_GZIP\n    flags += 1L << 17;\n#endif\n#ifdef PKZIP_BUG_WORKAROUND\n    flags += 1L << 20;\n#endif\n#ifdef FASTEST\n    flags += 1L << 21;\n#endif\n#if defined(STDC) || defined(Z_HAVE_STDARG_H)\n#  ifdef NO_vsnprintf\n    flags += 1L << 25;\n#    ifdef HAS_vsprintf_void\n    flags += 1L << 26;\n#    endif\n#  else\n#    ifdef HAS_vsnprintf_void\n    flags += 1L << 26;\n#    endif\n#  endif\n#else\n    flags += 1L << 24;\n#  ifdef NO_snprintf\n    flags += 1L << 25;\n#    ifdef HAS_sprintf_void\n    flags += 1L << 26;\n#    endif\n#  else\n#    ifdef HAS_snprintf_void\n    flags += 1L << 26;\n#    endif\n#  endif\n#endif\n    return flags;\n}\n\n#ifdef ZLIB_DEBUG\n#include <stdlib.h>\n#  ifndef verbose\n#    define verbose 0\n#  endif\nint ZLIB_INTERNAL z_verbose = verbose;\n\nvoid ZLIB_INTERNAL z_error (m)\n    char *m;\n{\n    fprintf(stderr, \"%s\\n\", m);\n    exit(1);\n}\n#endif\n\n/* exported to allow conversion of error code to string for compress() and\n * uncompress()\n */\nconst char * ZEXPORT zError(err)\n    int err;\n{\n    return ERR_MSG(err);\n}\n\n#if defined(_WIN32_WCE)\n    /* The Microsoft C Run-Time Library for Windows CE doesn't have\n     * errno.  We define it as a global variable to simplify porting.\n     * Its value is always 0 and should not be used.\n     */\n    int errno = 0;\n#endif\n\n#ifndef HAVE_MEMCPY\n\nvoid ZLIB_INTERNAL zmemcpy(dest, source, len)\n    Bytef* dest;\n    const Bytef* source;\n    uInt  len;\n{\n    if (len == 0) return;\n    do {\n        *dest++ = *source++; /* ??? to be unrolled */\n    } while (--len != 0);\n}\n\nint ZLIB_INTERNAL zmemcmp(s1, s2, len)\n    const Bytef* s1;\n    const Bytef* s2;\n    uInt  len;\n{\n    uInt j;\n\n    for (j = 0; j < len; j++) {\n        if (s1[j] != s2[j]) return 2*(s1[j] > s2[j])-1;\n    }\n    return 0;\n}\n\nvoid ZLIB_INTERNAL zmemzero(dest, len)\n    Bytef* dest;\n    uInt  len;\n{\n    if (len == 0) return;\n    do {\n        *dest++ = 0;  /* ??? to be unrolled */\n    } while (--len != 0);\n}\n#endif\n\n#ifndef Z_SOLO\n\n#ifdef SYS16BIT\n\n#ifdef __TURBOC__\n/* Turbo C in 16-bit mode */\n\n#  define MY_ZCALLOC\n\n/* Turbo C malloc() does not allow dynamic allocation of 64K bytes\n * and farmalloc(64K) returns a pointer with an offset of 8, so we\n * must fix the pointer. Warning: the pointer must be put back to its\n * original form in order to free it, use zcfree().\n */\n\n#define MAX_PTR 10\n/* 10*64K = 640K */\n\nlocal int next_ptr = 0;\n\ntypedef struct ptr_table_s {\n    voidpf org_ptr;\n    voidpf new_ptr;\n} ptr_table;\n\nlocal ptr_table table[MAX_PTR];\n/* This table is used to remember the original form of pointers\n * to large buffers (64K). Such pointers are normalized with a zero offset.\n * Since MSDOS is not a preemptive multitasking OS, this table is not\n * protected from concurrent access. This hack doesn't work anyway on\n * a protected system like OS/2. Use Microsoft C instead.\n */\n\nvoidpf ZLIB_INTERNAL zcalloc (voidpf opaque, unsigned items, unsigned size)\n{\n    voidpf buf;\n    ulg bsize = (ulg)items*size;\n\n    (void)opaque;\n\n    /* If we allocate less than 65520 bytes, we assume that farmalloc\n     * will return a usable pointer which doesn't have to be normalized.\n     */\n    if (bsize < 65520L) {\n        buf = farmalloc(bsize);\n        if (*(ush*)&buf != 0) return buf;\n    } else {\n        buf = farmalloc(bsize + 16L);\n    }\n    if (buf == NULL || next_ptr >= MAX_PTR) return NULL;\n    table[next_ptr].org_ptr = buf;\n\n    /* Normalize the pointer to seg:0 */\n    *((ush*)&buf+1) += ((ush)((uch*)buf-0) + 15) >> 4;\n    *(ush*)&buf = 0;\n    table[next_ptr++].new_ptr = buf;\n    return buf;\n}\n\nvoid ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr)\n{\n    int n;\n\n    (void)opaque;\n\n    if (*(ush*)&ptr != 0) { /* object < 64K */\n        farfree(ptr);\n        return;\n    }\n    /* Find the original pointer */\n    for (n = 0; n < next_ptr; n++) {\n        if (ptr != table[n].new_ptr) continue;\n\n        farfree(table[n].org_ptr);\n        while (++n < next_ptr) {\n            table[n-1] = table[n];\n        }\n        next_ptr--;\n        return;\n    }\n    Assert(0, \"zcfree: ptr not found\");\n}\n\n#endif /* __TURBOC__ */\n\n\n#ifdef M_I86\n/* Microsoft C in 16-bit mode */\n\n#  define MY_ZCALLOC\n\n#if (!defined(_MSC_VER) || (_MSC_VER <= 600))\n#  define _halloc  halloc\n#  define _hfree   hfree\n#endif\n\nvoidpf ZLIB_INTERNAL zcalloc (voidpf opaque, uInt items, uInt size)\n{\n    (void)opaque;\n    return _halloc((long)items, size);\n}\n\nvoid ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr)\n{\n    (void)opaque;\n    _hfree(ptr);\n}\n\n#endif /* M_I86 */\n\n#endif /* SYS16BIT */\n\n\n#ifndef MY_ZCALLOC /* Any system without a special alloc function */\n\n#ifndef STDC\nextern voidp  malloc OF((uInt size));\nextern voidp  calloc OF((uInt items, uInt size));\nextern void   free   OF((voidpf ptr));\n#endif\n\nvoidpf ZLIB_INTERNAL zcalloc (opaque, items, size)\n    voidpf opaque;\n    unsigned items;\n    unsigned size;\n{\n    (void)opaque;\n    return sizeof(uInt) > 2 ? (voidpf)malloc(items * size) :\n                              (voidpf)calloc(items, size);\n}\n\nvoid ZLIB_INTERNAL zcfree (opaque, ptr)\n    voidpf opaque;\n    voidpf ptr;\n{\n    (void)opaque;\n    free(ptr);\n}\n\n#endif /* MY_ZCALLOC */\n\n#endif /* !Z_SOLO */\n"
  },
  {
    "path": "Projects/Libraries/CSBase/Source/zlib/zutil.h",
    "content": "/* zutil.h -- internal interface and configuration of the compression library\n * Copyright (C) 1995-2016 Jean-loup Gailly, Mark Adler\n * For conditions of distribution and use, see copyright notice in zlib.h\n */\n\n/* WARNING: this file should *not* be used by applications. It is\n   part of the implementation of the compression library and is\n   subject to change. Applications should only use zlib.h.\n */\n\n/* @(#) $Id$ */\n\n#ifndef ZUTIL_H\n#define ZUTIL_H\n\n#ifdef HAVE_HIDDEN\n#  define ZLIB_INTERNAL __attribute__((visibility (\"hidden\")))\n#else\n#  define ZLIB_INTERNAL\n#endif\n\n#include \"zlib.h\"\n\n#if defined(STDC) && !defined(Z_SOLO)\n#  if !(defined(_WIN32_WCE) && defined(_MSC_VER))\n#    include <stddef.h>\n#  endif\n#  include <string.h>\n#  include <stdlib.h>\n#endif\n\n#ifdef Z_SOLO\n   typedef long ptrdiff_t;  /* guess -- will be caught if guess is wrong */\n#endif\n\n#ifndef local\n#  define local static\n#endif\n/* since \"static\" is used to mean two completely different things in C, we\n   define \"local\" for the non-static meaning of \"static\", for readability\n   (compile with -Dlocal if your debugger can't find static symbols) */\n\ntypedef unsigned char  uch;\ntypedef uch FAR uchf;\ntypedef unsigned short ush;\ntypedef ush FAR ushf;\ntypedef unsigned long  ulg;\n\nextern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */\n/* (size given to avoid silly warnings with Visual C++) */\n\n#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)]\n\n#define ERR_RETURN(strm,err) \\\n  return (strm->msg = ERR_MSG(err), (err))\n/* To be used only when the state is known to be valid */\n\n        /* common constants */\n\n#ifndef DEF_WBITS\n#  define DEF_WBITS MAX_WBITS\n#endif\n/* default windowBits for decompression. MAX_WBITS is for compression only */\n\n#if MAX_MEM_LEVEL >= 8\n#  define DEF_MEM_LEVEL 8\n#else\n#  define DEF_MEM_LEVEL  MAX_MEM_LEVEL\n#endif\n/* default memLevel */\n\n#define STORED_BLOCK 0\n#define STATIC_TREES 1\n#define DYN_TREES    2\n/* The three kinds of block type */\n\n#define MIN_MATCH  3\n#define MAX_MATCH  258\n/* The minimum and maximum match lengths */\n\n#define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */\n\n        /* target dependencies */\n\n#if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32))\n#  define OS_CODE  0x00\n#  ifndef Z_SOLO\n#    if defined(__TURBOC__) || defined(__BORLANDC__)\n#      if (__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__))\n         /* Allow compilation with ANSI keywords only enabled */\n         void _Cdecl farfree( void *block );\n         void *_Cdecl farmalloc( unsigned long nbytes );\n#      else\n#        include <alloc.h>\n#      endif\n#    else /* MSC or DJGPP */\n#      include <malloc.h>\n#    endif\n#  endif\n#endif\n\n#ifdef AMIGA\n#  define OS_CODE  1\n#endif\n\n#if defined(VAXC) || defined(VMS)\n#  define OS_CODE  2\n#  define F_OPEN(name, mode) \\\n     fopen((name), (mode), \"mbc=60\", \"ctx=stm\", \"rfm=fix\", \"mrs=512\")\n#endif\n\n#ifdef __370__\n#  if __TARGET_LIB__ < 0x20000000\n#    define OS_CODE 4\n#  elif __TARGET_LIB__ < 0x40000000\n#    define OS_CODE 11\n#  else\n#    define OS_CODE 8\n#  endif\n#endif\n\n#if defined(ATARI) || defined(atarist)\n#  define OS_CODE  5\n#endif\n\n#ifdef OS2\n#  define OS_CODE  6\n#  if defined(M_I86) && !defined(Z_SOLO)\n#    include <malloc.h>\n#  endif\n#endif\n\n#if defined(MACOS) || defined(TARGET_OS_MAC)\n#  define OS_CODE  7\n#  ifndef Z_SOLO\n#    if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os\n#      include <unix.h> /* for fdopen */\n#    else\n#      ifndef fdopen\n#        define fdopen(fd,mode) NULL /* No fdopen() */\n#      endif\n#    endif\n#  endif\n#endif\n\n#ifdef __acorn\n#  define OS_CODE 13\n#endif\n\n#if defined(WIN32) && !defined(__CYGWIN__)\n#  define OS_CODE  10\n#endif\n\n#ifdef _BEOS_\n#  define OS_CODE  16\n#endif\n\n#ifdef __TOS_OS400__\n#  define OS_CODE 18\n#endif\n\n#ifdef __APPLE__\n#  define OS_CODE 19\n#endif\n\n#if defined(_BEOS_) || defined(RISCOS)\n#  define fdopen(fd,mode) NULL /* No fdopen() */\n#endif\n\n#if (defined(_MSC_VER) && (_MSC_VER > 600)) && !defined __INTERIX\n#  if defined(_WIN32_WCE)\n#    define fdopen(fd,mode) NULL /* No fdopen() */\n#    ifndef _PTRDIFF_T_DEFINED\n       typedef int ptrdiff_t;\n#      define _PTRDIFF_T_DEFINED\n#    endif\n#  else\n#    define fdopen(fd,type)  _fdopen(fd,type)\n#  endif\n#endif\n\n#if defined(__BORLANDC__) && !defined(MSDOS)\n  #pragma warn -8004\n  #pragma warn -8008\n  #pragma warn -8066\n#endif\n\n/* provide prototypes for these when building zlib without LFS */\n#if !defined(_WIN32) && \\\n    (!defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0)\n    ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t));\n    ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t));\n#endif\n\n        /* common defaults */\n\n#ifndef OS_CODE\n#  define OS_CODE  3     /* assume Unix */\n#endif\n\n#ifndef F_OPEN\n#  define F_OPEN(name, mode) fopen((name), (mode))\n#endif\n\n         /* functions */\n\n#if defined(pyr) || defined(Z_SOLO)\n#  define NO_MEMCPY\n#endif\n#if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__)\n /* Use our own functions for small and medium model with MSC <= 5.0.\n  * You may have to use the same strategy for Borland C (untested).\n  * The __SC__ check is for Symantec.\n  */\n#  define NO_MEMCPY\n#endif\n#if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY)\n#  define HAVE_MEMCPY\n#endif\n#ifdef HAVE_MEMCPY\n#  ifdef SMALL_MEDIUM /* MSDOS small or medium model */\n#    define zmemcpy _fmemcpy\n#    define zmemcmp _fmemcmp\n#    define zmemzero(dest, len) _fmemset(dest, 0, len)\n#  else\n#    define zmemcpy memcpy\n#    define zmemcmp memcmp\n#    define zmemzero(dest, len) memset(dest, 0, len)\n#  endif\n#else\n   void ZLIB_INTERNAL zmemcpy OF((Bytef* dest, const Bytef* source, uInt len));\n   int ZLIB_INTERNAL zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len));\n   void ZLIB_INTERNAL zmemzero OF((Bytef* dest, uInt len));\n#endif\n\n/* Diagnostic functions */\n#ifdef ZLIB_DEBUG\n#  include <stdio.h>\n   extern int ZLIB_INTERNAL z_verbose;\n   extern void ZLIB_INTERNAL z_error OF((char *m));\n#  define Assert(cond,msg) {if(!(cond)) z_error(msg);}\n#  define Trace(x) {if (z_verbose>=0) fprintf x ;}\n#  define Tracev(x) {if (z_verbose>0) fprintf x ;}\n#  define Tracevv(x) {if (z_verbose>1) fprintf x ;}\n#  define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;}\n#  define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;}\n#else\n#  define Assert(cond,msg)\n#  define Trace(x)\n#  define Tracev(x)\n#  define Tracevv(x)\n#  define Tracec(c,x)\n#  define Tracecv(c,x)\n#endif\n\n#ifndef Z_SOLO\n   voidpf ZLIB_INTERNAL zcalloc OF((voidpf opaque, unsigned items,\n                                    unsigned size));\n   void ZLIB_INTERNAL zcfree  OF((voidpf opaque, voidpf ptr));\n#endif\n\n#define ZALLOC(strm, items, size) \\\n           (*((strm)->zalloc))((strm)->opaque, (items), (size))\n#define ZFREE(strm, addr)  (*((strm)->zfree))((strm)->opaque, (voidpf)(addr))\n#define TRY_FREE(s, p) {if (p) ZFREE(s, p);}\n\n/* Reverse the bytes in a 32-bit value */\n#define ZSWAP32(q) ((((q) >> 24) & 0xff) + (((q) >> 8) & 0xff00) + \\\n                    (((q) & 0xff00) << 8) + (((q) & 0xff) << 24))\n\n#endif /* ZUTIL_H */\n"
  },
  {
    "path": "Projects/Libraries/CSBase/jni/Android.mk",
    "content": "#\n#  Android.mk\n#  ChilliSource\n#  Created by Ian Copland on 13/06/2014.\n#\n#  The MIT License (MIT)\n#\n#  Copyright (c) 2014 Tag Games Limited\n#\n#  Permission is hereby granted, free of charge, to any person obtaining a copy\n#  of this software and associated documentation files (the \"Software\"), to deal\n#  in the Software without restriction, including without limitation the rights\n#  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n#  copies of the Software, and to permit persons to whom the Software is\n#  furnished to do so, subject to the following conditions:\n#\n#  The above copyright notice and this permission notice shall be included in\n#  all copies or substantial portions of the Software.\n#\n#  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n#  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n#  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n#  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n#  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n#  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n#  THE SOFTWARE.\n#\n\nGET_FILES_SCRIPT:=../../../Tools/Scripts/get_file_paths_with_extensions.py\nLOCAL_PATH := $(call my-dir)\n\n#get all the files to be build\nSOURCE_FILES := $(shell 'python' '$(GET_FILES_SCRIPT)' '-d' 'Source/' '-p' '../' '-e' 'cpp,c')\n\n#build the ChilliSource library\ninclude $(CLEAR_VARS)\nLOCAL_MODULE := CSBase\nLOCAL_CFLAGS := -O3 -DNDEBUG -DUSE_FILE32API -fsigned-char\nLOCAL_CXXFLAGS := -std=c++11 -pthread -fexceptions -frtti\nLOCAL_SRC_FILES := $(SOURCE_FILES)\nLOCAL_C_INCLUDES := $(LOCAL_PATH)/../Source/\ninclude $(BUILD_STATIC_LIBRARY)\n\n"
  },
  {
    "path": "Projects/Libraries/CSBase/jni/Application.mk",
    "content": "#\n#  Application.mk\n#  ChilliSource\n#  Created by Ian Copland on 12/03/2012.\n#\n#  The MIT License (MIT)\n#\n#  Copyright (c) 2012 Tag Games Limited\n#\n#  Permission is hereby granted, free of charge, to any person obtaining a copy\n#  of this software and associated documentation files (the \"Software\"), to deal\n#  in the Software without restriction, including without limitation the rights\n#  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n#  copies of the Software, and to permit persons to whom the Software is\n#  furnished to do so, subject to the following conditions:\n#\n#  The above copyright notice and this permission notice shall be included in\n#  all copies or substantial portions of the Software.\n#\n#  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n#  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n#  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n#  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n#  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n#  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n#  THE SOFTWARE.\n#\n\nNDK_TOOLCHAIN_VERSION := 4.9\nAPP_STL := gnustl_static\nAPP_ABI := armeabi armeabi-v7a arm64-v8a x86 x86_64\nLOCAL_CPP_FEATURES += exceptions rtti\n"
  },
  {
    "path": "Projects/Libraries/CSBase/rpi_csbase_build.py",
    "content": "#!/usr/bin/python\n#  The MIT License (MIT)\n#\n#  Copyright (c) 2017 Tag Games Limited\n#\n#  Permission is hereby granted, free of charge, to any person obtaining a copy\n#  of this software and associated documentation files (the \"Software\"), to deal\n#  in the Software without restriction, including without limitation the rights\n#  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n#  copies of the Software, and to permit persons to whom the Software is\n#  furnished to do so, subject to the following conditions:\n#\n#  The above copyright notice and this permission notice shall be included in\n#  all copies or substantial portions of the Software.\n#\n#  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n#  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n#  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n#  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n#  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n#  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n#  THE SOFTWARE.\n#-----------------------------------------------------------------------------------\nimport sys\nCS_ROOT = \"../../..\"\nsys.path.append(\"{}/Tools/Scripts/\".format(CS_ROOT))\nimport subprocess\nimport os\nfrom ninja_syntax import Writer\nfrom file_system_utils import delete_directory\n\nCOMPILER_FLAGS_DEFAULT_CPP = \"-c -std=c++11 -fsigned-char -pthread -fexceptions -frtti -DCS_TARGETPLATFORM_RPI\"\nCOMPILER_FLAGS_DEFAULT_C = \"-c -fsigned-char -pthread -fexceptions -DCS_TARGETPLATFORM_RPI\"\nCOMPILER_FLAGS_TARGET_MAP = { \"debug\":\"-g -DDEBUG -DCS_ENABLE_DEBUG\",  \t\"release\":\"-O3 -DNDEBUG\" }\nSOURCE_PATHS = [\"Source\"]\nINCLUDE_PATHS = \"-IPlatformSource/RPi -I{}\".format(\" \".join(SOURCE_PATHS))\n\n# Write build commands to the given ninja file for all source files that have the given extension in the given directories\n#\n# @param ninja_file\n#\tFile to write commands to\n# @param dirs\n#\tList of directories to search for source files\n# @param exts\n# \tThe list source file extension to look for in the format \"a,b,c\"\n# @param compile_rule\n# \tName of the compile rule to compile this type of source file\n# @param dep_rule\n# \tName of the rule to generate depencencies for this type of source file\n# @param build_dir\n# \tLocation to output compiled files to\n# \n# @return List of output file paths\n# \ndef _write_build_command(ninja_file, dirs, exts, compile_rule, dep_rule, build_dir):\n\n\tget_files_script = os.path.normpath(\"{}/Tools/Scripts/get_file_paths_with_extensions.py\".format(CS_ROOT))\n\tsource_files = []\n\tfor d in dirs:\n\t\tsource_files += subprocess.check_output(['python', get_files_script, '--directory', d, '--extensions', exts], universal_newlines=True).split(\" \")\n\n\tsource_files = list(filter(lambda x: len(x) > 0, source_files))\n\tsource_files = list(filter(lambda x: len(x) > 0, source_files))\n\t# Convert the source files extensions from .c/cpp etc. to .o\n\toutput_files = map(lambda x: os.path.splitext(x)[0]+'.o', source_files)\n\t# Make the file paths relative to the build dir\n\toutput_files = map(lambda x: os.path.join(build_dir, x), output_files)\n\t# Convert from windows separators to unix ones as Ninja has a bug where it doesn't escape windows properly\n\toutput_files = list(map(lambda x: x.replace('\\\\', '/'), output_files))\n\n\tfor source_file, output_file in zip(source_files, output_files):\n\t\tninja_file.build(rule=compile_rule, inputs=source_file, outputs=output_file)\n\t\tninja_file.build(rule=dep_rule, inputs=source_file, outputs=output_file+\".d\")\n\n\treturn output_files\n\n# Generate a ninja \"makefile\"\n#\n# @param cpp_compiler_path\n# \tPath to the g++ compiler\n# @param c_compiler_path\n# \tPath to the gcc compiler\n# @param archiver_path\n# \tPath to the gcc archiver for making static libs\n# @param target_scheme\n# \tUsed to apply compiler flags\n# @param build_dir\n# \tLocation to output temp build files to\n# @param lib_path\n#\tpath to temporary lib directory\n#\ndef _generate_ninja_file(cpp_compiler_path, c_compiler_path, archiver_path, target_scheme, build_dir, lib_path):\n\n\twith open(os.path.join(build_dir, \"Application.ninja\"), \"w\") as build_file:\n\t\tninja_file = Writer(build_file)\n\n\t\tninja_file.variable(key=\"builddir\", value=build_dir)\n\n\t\tcpp_compiler_flags = COMPILER_FLAGS_DEFAULT_CPP + \" \" + COMPILER_FLAGS_TARGET_MAP[target_scheme] + \" \" + INCLUDE_PATHS\n\t\tc_compiler_flags = COMPILER_FLAGS_DEFAULT_C + \" \" + COMPILER_FLAGS_TARGET_MAP[target_scheme] + \" \" + INCLUDE_PATHS\n\n\t\t# Write the compiler rule for c, cpp and cc\n\t\tninja_file.rule(\"compile_cpp\", command=\"{} {} -o $out $in\".format(cpp_compiler_path, cpp_compiler_flags), description=\"Compiling C++ source: $in\", depfile=\"$out.o.d\", deps=\"gcc\")\n\t\tninja_file.rule(\"compile_c\", command=\"{} {} -o $out $in\".format(c_compiler_path, c_compiler_flags), description=\"Compiling C source: $in\", depfile=\"$out.o.d\", deps=\"gcc\")\n\n\t\t# Write the rule that generates the dependencies\n\t\tninja_file.rule(\"dependencies_cpp\", command=\"{} {} -MM -MG -MF $out $in\".format(cpp_compiler_path, cpp_compiler_flags), description=\"Generating C++ dependency: $in\")\n\t\tninja_file.rule(\"dependencies_c\", command=\"{} {} -MM -MG -MF $out $in\".format(c_compiler_path, c_compiler_flags), description=\"Generating C dependency: $in\")\n\n\t\t# Write the rule to build the static library. Note we use response files as on Windows the command is too long for CreateProcess\n\t\tninja_file.rule(\"archive\", command=\"{} rcs $out @$out.rsp\".format(archiver_path), description=\"Building static library: $out\", rspfile=\"$out.rsp\", rspfile_content=\"$in\")\n\n\t\t# Write the compile command for all source files.\n\t\toutput_files = _write_build_command(ninja_file, SOURCE_PATHS, 'cpp', 'compile_cpp', 'dependencies_cpp', build_dir)\n\t\toutput_files += _write_build_command(ninja_file, SOURCE_PATHS, 'c,cc', 'compile_c', 'dependencies_c', build_dir)\n\n\t\t# Write the command to generate the static library for ChilliSource and the application\n\t\tninja_file.build(rule=\"archive\", inputs=output_files, outputs=lib_path)\n\n# Generates the ninja \"makefile\", builds the application and copies\n# the assets to the output folder\n#\n# @param target_scheme\n# \tUsed to apply compiler flags\n# @param num_jobs\n# \tUsed to restrict the number of concurrent build jobs. If None then unrestricted\n# @param cpp_compiler_path\n# \tPath to the g++ compiler\n# @param c_compiler_path\n# \tPath to the gcc compiler\n# @param archiver_path\n# \tPath to the gcc archiver for making static libs\n# @param build_dir\n# \tLocation to output temp build files to\n# @param lib_path\n#\tpath to temporary lib directory\n#\ndef _build(target_scheme, num_jobs, cpp_compiler_path, c_compiler_path, archiver_path, build_dir, lib_path):\n\n\ttry:\n\t\tos.makedirs(build_dir)\n\texcept OSError:\n\t\tprint(\"Build directory already exists\")\n\n\t# Remove the old libraries and exes but not the compiled files\n\t_clean(None, lib_path)\n\n\t# Generate the ninja \"makefile\" based on the target scheme and platform\n\t_generate_ninja_file(cpp_compiler_path, c_compiler_path, archiver_path, target_scheme, build_dir, lib_path)\n\n\t# Build the exe using ninja\n\tif num_jobs == \"None\":\n\t\tsubprocess.call(['ninja', '-f', os.path.join(build_dir, 'Application.ninja')])\n\telse:\n\t\tsubprocess.call(['ninja', '-f', os.path.join(build_dir, 'Application.ninja'), '-j', str(num_jobs)])\n\n# Cleans the output, build and libs. Passing None\n# will prevent them from being cleaned\n#\n# @param build_dir\n#\tLocation for temporary build files\n# @param lib_path\n#\tpath to temporary lib directory\n#\ndef _clean(build_dir, lib_path):\n\n\tif lib_path != None and os.path.isfile(lib_path):\n\t\tos.remove(lib_path)\n\tif build_dir != None and os.path.isdir(build_dir):\n\t\tdelete_directory(build_dir)\n\n# Begin building for Raspberry Pi\n#\n# @param args \n#\tThe list of arguments - Should have an additional argument \"debug\" or \"release\" optionally followed by \"clean\" then numjobs, c++ compiler path, c compiler path and archiver path e.g \"debug clean 2 g++ gcc ar\"\n#\ndef run(args):\n\n\tif len(args) < 4 and len(args) != 2:\n\t\tprint(\"Too few args {}. Usage: debug|release [clean] <numjobs> <cpp_compiler> <c_compiler> <archiver>\".format(len(args)))\n\t\treturn\n\n\ttarget_scheme = args[0].lower()\n\n\tif target_scheme not in ['debug', 'release']:\n\t\tprint(\"Incorrect target scheme {}. Usage: debug|release [clean] <numjobs> <cpp_compiler> <c_compiler> <archiver>\".format(target_scheme))\n\t\treturn\n\n\tbuild_dir = os.path.normpath(\"build/RPi/{}\".format(target_scheme))\n\tlib_path = os.path.normpath(\"{}/libCSBase.a\".format(build_dir))\n\n\tif len(args) > 1 and args[1].lower() == \"clean\":\n\t\t# Remove all libraries, exes and compiled files\n\t\t_clean(build_dir, lib_path)\n\telse:\n\t\t_build(target_scheme, args[1], args[2], args[3], args[4], build_dir, lib_path)\n\nif __name__ == \"__main__\":\n\trun(sys.argv[1:])"
  },
  {
    "path": "Projects/Tools/AndroidManifestBuilder/.classpath",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<classpath>\n\t<classpathentry kind=\"src\" path=\"src\"/>\n\t<classpathentry kind=\"con\" path=\"org.eclipse.jdt.launching.JRE_CONTAINER\"/>\n\t<classpathentry combineaccessrules=\"false\" kind=\"src\" path=\"/CoreUtils\"/>\n\t<classpathentry kind=\"output\" path=\"bin\"/>\n</classpath>\n"
  },
  {
    "path": "Projects/Tools/AndroidManifestBuilder/.project",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<projectDescription>\n\t<name>AndroidManifestBuilder</name>\n\t<comment></comment>\n\t<projects>\n\t</projects>\n\t<buildSpec>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.jdt.core.javabuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t</buildSpec>\n\t<natures>\n\t\t<nature>org.eclipse.jdt.core.javanature</nature>\n\t</natures>\n</projectDescription>\n"
  },
  {
    "path": "Projects/Tools/AndroidManifestBuilder/Manifest.txt",
    "content": "Manifest-Version: 1.0\r\nMain-Class: com.chillisource.androidmanifestbuilder.Main\r\n\r\n"
  },
  {
    "path": "Projects/Tools/AndroidManifestBuilder/src/com/chilliworks/chillisource/androidmanifestbuilder/AndroidManifestBuilder.java",
    "content": "/**\n * AndroidManifestGenerator.java\n * ChilliSource\n * Created by Ian Copland on 20/06/2014.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2014 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.androidmanifestbuilder;\n\nimport java.io.StringReader;\n\nimport javax.xml.parsers.DocumentBuilder;\nimport javax.xml.parsers.DocumentBuilderFactory;\n\nimport org.w3c.dom.Document;\nimport org.w3c.dom.Node;\nimport org.xml.sax.InputSource;\n\nimport com.chilliworks.chillisource.coreutils.FileUtils;\nimport com.chilliworks.chillisource.coreutils.Logging;\n\n/**\n * Generates the android manifest containing all the required settings\n * for building ChilliSource as well as the extra settings requested\n * by the user.\n * \n * @author Ian Copland\n */\npublic final class AndroidManifestBuilder\n{\n\t/**\n\t * Generates the android manifest from the ChilliSource template\n\t * and the applications CS manifest.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param The user manifest file path.\n\t * @param The template manifest file path.\n\t * @param The output AndroidManifest.xml file path.\n\t */\n\tpublic static void generate(String in_inputFilePath, String in_templateFilePath, String in_outputFilePath)\n\t{\n\t\tUserManifestData userManifestData = readUserManifest(in_inputFilePath);\n\t\tString templateData = readTemplate(in_templateFilePath);\n\t\tString outputData = applyUserDataToTemplate(userManifestData, templateData);\n\t\twriteOutput(in_outputFilePath, outputData);\n\t}\n\t/**\n\t * Reads the user manifest from file.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param The file path to the user manifest.\n\t * \n\t * @return A container for all information in the user manifest.\n\t */\n\tprivate static UserManifestData readUserManifest(String in_filePath)\n\t{\n\t\tLogging.logVerbose(\"Reading user manifest data from '\" + in_filePath + \"'\");\n\t\t\n\t\tUserManifestData output = new UserManifestData();\n\t\t\n\t\ttry\n\t\t{\n\t\t\tString xmlString = FileUtils.readFile(in_filePath);\n\t\t\tif (xmlString == null)\n\t\t\t{\n\t\t\t\tLogging.logFatal(\"Could not read user manifest file from '\" + in_filePath + \"'\");\n\t\t\t}\n\t\t\t\n\t\t\tInputSource inputSource = new InputSource();\n\t\t\tinputSource.setCharacterStream(new StringReader(xmlString));\n\t\t\tDocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();\n\t\t\tdbFactory.setNamespaceAware(false);\n\t\t\tDocumentBuilder dBuilder = dbFactory.newDocumentBuilder();\n\t\t\tDocument doc = dBuilder.parse(inputSource);\n\t\t\tdoc.getDocumentElement().normalize();\n\t\t\t\n\t\t\t//read all attributes\n\t\t\tNode root = doc.getElementsByTagName(\"cs-manifest\").item(0);\n\n\t\t\tNode packageName = root.getAttributes().getNamedItem(\"package\");\n\t\t\tif (packageName != null)\n\t\t\t{\n\t\t\t\toutput.m_package = packageName.getNodeValue();\n\t\t\t}\n\t\t\t\n\t\t\tNode orientationNode = root.getAttributes().getNamedItem(\"screenOrientation\");\n\t\t\tif (orientationNode != null)\n\t\t\t{\n\t\t\t\toutput.m_orientation = orientationNode.getNodeValue();\n\t\t\t}\n\t\t\t\n\t\t\tNode apkExpansionDownloadViewNode = root.getAttributes().getNamedItem(\"apkExpansionDownloadView\");\n\t\t\tif (apkExpansionDownloadViewNode != null)\n\t\t\t{\n\t\t\t\toutput.m_apkExpansionDownloadView = apkExpansionDownloadViewNode.getNodeValue();\n\t\t\t}\n\t\t\t\n\t\t\tNode multiDexNode = root.getAttributes().getNamedItem(\"multi-dex-enabled\");\n\t\t\tif(multiDexNode != null)\n\t\t\t{\n\t\t\t\toutput.m_multiDexEnabled = multiDexNode.getNodeValue().equalsIgnoreCase(\"true\");\n\t\t\t}\n\t\t\t\n\t\t\toutput.m_manifestExtra = getElementContentAsString(xmlString, \"manifest-extra\");\n\t\t\toutput.m_applicationExtra = getElementContentAsString(xmlString, \"application-extra\");\n\t\t\toutput.m_permissions = getElementContentAsString(xmlString, \"permissions\");\n\t\t}\n\t\tcatch (Exception e)\n\t\t{\n\t\t\tLogging.logFatal(\"Failed to read user manifest xml '\" + in_filePath + \"'\");\n\t\t}\n\t\t\n\t\treturn output;\n\t}\n\t/**\n\t * Reads the template from file.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param The template file path.\n\t * \n\t * @return A string containing the contents of the template file.\n\t */\n\tprivate static String readTemplate(String in_filePath)\n\t{\n\t\tLogging.logVerbose(\"Reading manifest template from '\" + in_filePath + \"'\");\n\t\t\n\t\tString templateData = FileUtils.readFile(in_filePath);\n\t\tif (templateData.length() == 0)\n\t\t{\n\t\t\tLogging.logFatal(\"Could not read template data\");\n\t\t}\n\t\treturn templateData;\n\t}\n\t/**\n\t * Applies the user data to the template file.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param The user data.\n\t * @param The template.\n\t * \n\t * @return A string containing the output AndroidManifest.xml\n\t */\n\tprivate static String applyUserDataToTemplate(UserManifestData in_userData, String in_template)\n\t{\n\t\tString output = in_template;\n\t\t\n\t\toutput = output.replace(\"[[PACKAGE]]\", in_userData.m_package);\n\t\toutput = output.replace(\"[[ORIENTATION]]\", in_userData.m_orientation);\n\t\toutput = output.replace(\"[[APKEXPANSIONDOWNLOADVIEW]]\", in_userData.m_apkExpansionDownloadView);\n\t\toutput = output.replace(\"[[MANIFESTEXTRA]]\", in_userData.m_manifestExtra);\n\t\toutput = output.replace(\"[[APPLICATIONEXTRA]]\", in_userData.m_applicationExtra);\n\t\toutput = output.replace(\"[[PERMISSIONS]]\", in_userData.m_permissions);\n\t\t\n\t\tString multiDex = in_userData.m_multiDexEnabled ? \"android:name=\\\"android.support.multidex.MultiDexApplication\\\"\" : \"\";\n\t\toutput = output.replace(\"[[MULTIDEXENABLED]]\", multiDex);\n\t\t\n\t\treturn output;\n\t}\n\t/**\n\t * Writes the output data to disk.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param The output file path.\n\t * @param The output data.\n\t */\n\tprivate static void writeOutput(String in_filePath, String in_outputData)\n\t{\n\t\tLogging.logVerbose(\"Writing output file to '\" + in_filePath + \"'\");\n\t\t\n\t\tif (FileUtils.writeFile(in_filePath, in_outputData) == false)\n\t\t{\n\t\t\tLogging.logFatal(\"Failed to write file '\" + in_filePath + \"'\");\n\t\t}\n\t}\n\t/**\n\t * Searches through an xml string for the given xml tag and returns it's\n\t * content, including other tags, as a string.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param The xml string.\n\t * @param The element name.\n\t * \n\t * @return The contents of the element as a string.\n\t */\n\tprivate static String getElementContentAsString(String in_stringXml, String in_elementName)\n\t{\n\t\tString output = \"\";\n\t\t\n\t\tString startTag = \"<\" + in_elementName + \">\";\n\t\tString endTag = \"</\" + in_elementName + \">\";\n\t\tint start = in_stringXml.indexOf(startTag) + startTag.length();\n\t\tint end = in_stringXml.indexOf(endTag);\n\t\tif (start != -1 && end != -1)\n\t\t{\n\t\t\toutput = in_stringXml.substring(start, end);\n\t\t}\n\t\t\n\t\treturn output;\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/AndroidManifestBuilder/src/com/chilliworks/chillisource/androidmanifestbuilder/Main.java",
    "content": "/**\n * Main.java\n * ChilliSource\n * Created by Ian Copland on 20/06/2014.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2014 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.androidmanifestbuilder;\n\nimport com.chilliworks.chillisource.coreutils.Logging;\nimport com.chilliworks.chillisource.coreutils.StringUtils;\nimport com.chilliworks.chillisource.coreutils.Logging.LoggingLevel;\n\n/**\n * Handles the entry point into the application. This manages the parsing of the input parameters and\n * passes them on to the rest of the tool.\n * \n * @author Ian Copland\n */\npublic final class Main\n{\n\tprivate static final String k_paramInput = \"--input\";\n\tprivate static final String k_paramInputShort = \"-i\";\n\tprivate static final String k_paramTemplate = \"--template\";\n\tprivate static final String k_paramTemplateShort = \"-t\";\n\tprivate static final String k_paramOutput = \"--output\";\n\tprivate static final String k_paramOutputShort = \"-o\";\n\tprivate static final String k_paramHelp = \"--help\";\n\tprivate static final String k_paramHelpShort = \"-h\";\n\t\n\t/**\n\t * The entry point into the application\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param The input arguments.\n\t */\n\tpublic static void main(String[] in_arguments) throws Exception \n\t{\n\t\tString[] arguments = Logging.start(in_arguments);\n\t\t\n\t\tif (arguments.length == 0)\n\t\t{\n\t\t\tprintHelpText();\n\t\t\treturn;\n\t\t}\n\t\t\n\t\tString input = \"\";\n\t\tString template = \"\";\n\t\tString output = \"\";\n\t\tfor (int i = 0; i < arguments.length; ++i)\n\t\t{\n\t\t\t//input\n\t\t\tif (arguments[i].equalsIgnoreCase(k_paramInput) == true || arguments[i].equalsIgnoreCase(k_paramInputShort) == true)\n\t\t\t{\n\t\t\t\tif (i+1 < arguments.length)\n\t\t\t\t\tinput = StringUtils.standardiseFilePath(arguments[i+1]);\n\t\t\t\telse\n\t\t\t\t\tLogging.logFatal(\"No input file path provided!\");\n\t\t\t\ti++;\n\t\t\t}\n\t\t\t\n\t\t\t//template\n\t\t\telse if (arguments[i].equalsIgnoreCase(k_paramTemplate) == true || arguments[i].equalsIgnoreCase(k_paramTemplateShort) == true)\n\t\t\t{\n\t\t\t\tif (i+1 < arguments.length)\n\t\t\t\t\ttemplate = StringUtils.standardiseFilePath(arguments[i+1]);\n\t\t\t\telse\n\t\t\t\t\tLogging.logFatal(\"No template file path provided!\");\n\t\t\t\ti++;\n\t\t\t}\n\t\t\t\n\t\t\t//output\n\t\t\telse if (arguments[i].equalsIgnoreCase(k_paramOutput) == true || arguments[i].equalsIgnoreCase(k_paramOutputShort) == true)\n\t\t\t{\n\t\t\t\tif (i+1 < arguments.length)\n\t\t\t\t\toutput = StringUtils.standardiseFilePath(arguments[i+1]);\n\t\t\t\telse\n\t\t\t\t\tLogging.logFatal(\"No output file path provided!\");\n\t\t\t\ti++;\n\t\t\t}\n\t\t\t\n\t\t\t//help\n\t\t\telse if (arguments[i].equalsIgnoreCase(k_paramHelp) == true || arguments[i].equalsIgnoreCase(k_paramHelpShort) == true)\n\t\t\t{\n\t\t\t\tprintHelpText();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t\n\t\t\t//failure\n\t\t\telse\n\t\t\t{\n\t\t\t\tLogging.logFatal(\"Invalid parameter found: \" + arguments[i]);\n\t\t\t}\n\t\t}\n\t\t\n\t\tif (input.length() == 0 || template.length() ==0 || output.length() == 0)\n\t\t{\n\t\t\tLogging.logFatal(\"Must provide input, template and output file paths.\");\n\t\t}\n\t\t\n\t\tAndroidManifestBuilder.generate(input, template, output);\n\t\t\n\t\tLogging.finish();\n\t}\n\t/**\n\t * Outputs help test for this tool. This will be displayed regardless of \n\t * the current logging level.\n\t *\n\t * @author Ian Copland\n\t */\n\tpublic static void printHelpText()\n\t{\n\t\tLogging.setLoggingLevel(LoggingLevel.VERBOSE);\n\t\tLogging.logVerbose(\"Usage: java -jar AndroidManifestBuilder.jar --input <file path> --template <file path> --output <file path> [--logginglevel <level>] [--help]\");\n\t\tLogging.logVerbose(\"Parameters:\");\n\t\tLogging.logVerbose(\" \" + k_paramInput + \"(\" + k_paramInputShort + \"): The file path to the user manifest.\");\n\t\tLogging.logVerbose(\" \" + k_paramTemplate + \"(\" + k_paramTemplateShort + \"): The file path to the template manifest.\");\n\t\tLogging.logVerbose(\" \" + k_paramOutput + \"(\" + k_paramOutputShort + \"): The file path to the output AndroidManifest.xml.\");\n\t\tLogging.logVerbose(\" \" + Logging.PARAM_LOGGING_LEVEL + \"(\" + Logging.SHORT_PARAM_LOGGING_LEVEL + \"): [Optional] The level of messages to log.\");\n\t\tLogging.logVerbose(\" \" + k_paramHelp + \"(\" + k_paramHelpShort + \"): [Optional] Display this help message.\");\n\t\tLogging.logVerbose(\"Logging Levels:\");\n\t\tLogging.logVerbose(\" \" + Logging.LOGGING_LEVEL_NONE + \": No logging.\");\n\t\tLogging.logVerbose(\" \" + Logging.LOGGING_LEVEL_FATAL + \": Only log fatal errors.\");\n\t\tLogging.logVerbose(\" \" + Logging.LOGGING_LEVEL_ERROR + \": Only log errors.\");\n\t\tLogging.logVerbose(\" \" + Logging.LOGGING_LEVEL_WARNING + \": Log errors and warnings.\");\n\t\tLogging.logVerbose(\" \" + Logging.LOGGING_LEVEL_VERBOSE + \": Log all messages.\");\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/AndroidManifestBuilder/src/com/chilliworks/chillisource/androidmanifestbuilder/UserManifestData.java",
    "content": "/**\n * UserManifestData.java\n * ChilliSource\n * Created by Ian Copland on 20/06/2014.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2014 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.androidmanifestbuilder;\n\n/**\n * A container for the data in the user manifest.\n * \n * @author Ian Copland\n */\npublic final class UserManifestData\n{\n\tpublic String m_package = \"\";\n\tpublic String m_orientation = \"sensor\";\n\tpublic String m_apkExpansionDownloadView = \"\";\n\tpublic String m_manifestExtra = \"\";\n\tpublic String m_applicationExtra = \"\";\n\tpublic String m_permissions = \"\";\n\tpublic boolean m_multiDexEnabled = false;\n}\n"
  },
  {
    "path": "Projects/Tools/CSAtlasBuilder/.classpath",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<classpath>\n\t<classpathentry kind=\"src\" path=\"src\"/>\n\t<classpathentry combineaccessrules=\"false\" kind=\"src\" path=\"/CoreUtils\"/>\n\t<classpathentry combineaccessrules=\"false\" kind=\"src\" path=\"/TexturePackerUtils\"/>\n\t<classpathentry kind=\"con\" path=\"org.eclipse.jdt.launching.JRE_CONTAINER\"/>\n\t<classpathentry combineaccessrules=\"false\" kind=\"src\" path=\"/PNGToCSImage\"/>\n\t<classpathentry kind=\"output\" path=\"bin\"/>\n</classpath>\n"
  },
  {
    "path": "Projects/Tools/CSAtlasBuilder/.gitignore",
    "content": "bin\n\n"
  },
  {
    "path": "Projects/Tools/CSAtlasBuilder/.project",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<projectDescription>\n\t<name>CSAtlasBuilder</name>\n\t<comment></comment>\n\t<projects>\n\t</projects>\n\t<buildSpec>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.jdt.core.javabuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t</buildSpec>\n\t<natures>\n\t\t<nature>org.eclipse.jdt.core.javanature</nature>\n\t</natures>\n</projectDescription>\n"
  },
  {
    "path": "Projects/Tools/CSAtlasBuilder/src/com/chilliworks/chillisource/csatlasbuilder/AtlasBuilderOptions.java",
    "content": "/**\n * AtlasBuilderOptions.java\n * ChilliSource\n * Created by Ian Copland on 26/06/2014.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2014 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.csatlasbuilder;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\nimport com.chilliworks.chillisource.texturepackerutils.TexturePacker.PlacementHeuristic;\n\npublic class AtlasBuilderOptions\n{\n\tpublic List<AtlasImage> m_atlasImages = new ArrayList<AtlasImage>(); //Available through java library access only.\n\tpublic String m_inputDirectoryPath = \"\";\n\tpublic String m_outputFilePath = \"\";\n\tpublic String m_fileList = \"\";\n\tpublic int m_fixedWidth = -1;\n\tpublic int m_fixedHeight = -1;\n\tpublic int[] m_validHeights = new int[0];\n\tpublic int[] m_validWidths = new int[0];\n\tpublic int m_maxWidth = 2048;\n\tpublic int m_maxHeight = 2048;\n\tpublic int m_divisibleBy = 4;\n\tpublic boolean m_crop = true;\n\tpublic int m_padding = 1;\n\tpublic int m_innerPadding = 0;\n\tpublic int m_extrude = 1;\n\tpublic PlacementHeuristic m_packingHeuristic = PlacementHeuristic.BOTTOMRIGHT;\n\tpublic String m_imageCompression = \"\";\n\tpublic String m_imageFormat = \"\";\n\tpublic boolean m_imageDither = false;\n\tpublic boolean m_imagePremultiplyAlpha = true;\n}\n"
  },
  {
    "path": "Projects/Tools/CSAtlasBuilder/src/com/chilliworks/chillisource/csatlasbuilder/AtlasImage.java",
    "content": "/**\n * AtlasImage.java\n * ChilliSource\n * Created by Ian Copland on 09/09/2014.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2014 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.csatlasbuilder;\n\nimport java.io.File;\n\n/**\n * A simple container class for information on a single exportable image\n * in a texture atlas.\n * \n * @author Ian Copland\n *\n */\npublic final class AtlasImage\n{\n\tprivate File m_sourceImageFile;\n\tprivate String m_atlasImageId;\n\t\n\t/**\n\t * Constructor.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param in_file - The image file.\n\t * @param in_atlasImageId - The atlas image id.\n\t */\n\tpublic AtlasImage(File in_sourceImageFile, String in_atlasImageId)\n\t{\n\t\tm_sourceImageFile = in_sourceImageFile;\n\t\tm_atlasImageId = in_atlasImageId;\n\t}\n\t/**\n\t * @author Ian Copland\n\t * \n\t * @return The source image file.\n\t */\n\tpublic File getSourceImageFile()\n\t{\n\t\treturn m_sourceImageFile;\n\t}\n\t/**\n\t * @author Ian Copland\n\t * \n\t * @return The atlas image Id.\n\t */\n\tpublic String getAtlasImageId()\n\t{\n\t\treturn m_atlasImageId;\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/CSAtlasBuilder/src/com/chilliworks/chillisource/csatlasbuilder/CSAtlasBuilder.java",
    "content": "/**\n*  CSAtlasBuilder.java\n*  ChilliSource\n*  Created by Robert Henning on 07/09/2006.\n*\n*  The MIT License (MIT)\n*\n*  Copyright (c) 2006 Tag Games Limited\n*\n*  Permission is hereby granted, free of charge, to any person obtaining a copy\n*  of this software and associated documentation files (the \"Software\"), to deal\n*  in the Software without restriction, including without limitation the rights\n*  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n*  copies of the Software, and to permit persons to whom the Software is\n*  furnished to do so, subject to the following conditions:\n*\n*  The above copyright notice and this permission notice shall be included in\n*  all copies or substantial portions of the Software.\n*\n*  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n*  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n*  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n*  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n*  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n*  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n*  THE SOFTWARE.\n*/\n\npackage com.chilliworks.chillisource.csatlasbuilder;\n\nimport java.io.DataInputStream;\nimport java.io.DataOutputStream;\nimport java.io.File;\nimport java.io.FileInputStream;\nimport java.io.FileNotFoundException;\nimport java.io.FileOutputStream;\nimport java.io.IOException;\nimport java.util.ArrayList;\nimport java.util.List;\n\nimport javax.imageio.ImageIO;\n\nimport com.chilliworks.chillisource.coreutils.CSException;\nimport com.chilliworks.chillisource.coreutils.FileUtils;\nimport com.chilliworks.chillisource.coreutils.LittleEndianWriterUtils;\nimport com.chilliworks.chillisource.coreutils.Logging;\nimport com.chilliworks.chillisource.coreutils.StringUtils;\nimport com.chilliworks.chillisource.pngtocsimage.PNGToCSImage;\nimport com.chilliworks.chillisource.pngtocsimage.PNGToCSImageOptions;\nimport com.chilliworks.chillisource.texturepackerutils.PackedTexture;\nimport com.chilliworks.chillisource.texturepackerutils.PackerInfo;\nimport com.chilliworks.chillisource.texturepackerutils.TexturePacker;\n\n/**\n * Packs images into a single \"texture atlas\".\n * \n * @author R Henning\n */\npublic class CSAtlasBuilder\n{\n\tprivate static final String k_versionString = \"2.14\";\n\tprivate static final short k_versionNum = 3;\n\tprivate static final String k_atlasExtension = \".csatlas\";\n\tprivate static final String k_atlasIdExtension = \".csatlasid\";\n\tprivate static final String k_csImageExtension = \".csimage\";\n\t\n\tprivate AtlasBuilderOptions m_options = null;\n\tprivate File m_rootDirectory = null; // Root directory from which files are read,set from\n\tprivate String m_outputFilePathWithoutExtension;\n\t\n\t/**\n\t * @author R Henning\n\t * \n\t * @param The options for the tool.\n\t * \n\t * @return Whether or not the run was successful.\n\t */\n\tpublic boolean buildAtlas(AtlasBuilderOptions in_options) throws Exception\n\t{\n\t\tLogging.logVerbose(\"TextureAtlasTool version \" + k_versionString);\n\t\tLogging.logVerbose(\"-----------------------\");\n\n\t\tm_options = in_options;\n\t\t\n\t\tString extension = StringUtils.getExtension(m_options.m_outputFilePath);\n\t\t\n\t\t//Check for a valid extension, i.e. either csatlas/csatlasid/csimage\n\t\tif(!(extension.equals(k_atlasExtension.substring(1)) || extension.equals(k_atlasIdExtension.substring(1)) || extension.equals(k_csImageExtension.substring(1))))\n\t\t{\n\t\t\tthrow new CSException(\"Output filepath (\" + m_options.m_outputFilePath +  \") has wrong extension type, valid output extensions are \" + k_atlasExtension + \", \" + k_atlasIdExtension + \" and \" + k_csImageExtension);\n\t\t}\n\t\t\n\t\t//Remove the extension from the outputpath\n\t\tm_outputFilePathWithoutExtension = StringUtils.removeExtension(m_options.m_outputFilePath);\n\t\t\n\t\tLogging.logVerbose(\"input dir name is:\\\"\" + m_options.m_inputDirectoryPath + \"\\\"\");\n\n\t\tm_rootDirectory = new File(m_options.m_inputDirectoryPath);\n\t\t\n\t\tList<AtlasImage> atlasImagesToProcess;\n\t\tif (m_options.m_atlasImages.size() > 0)\n\t\t{\n\t\t\tatlasImagesToProcess = m_options.m_atlasImages;\n\t\t}\n\t\telse if (m_options.m_fileList.length() > 0)\n\t\t{\n\t\t\tatlasImagesToProcess = new ArrayList<AtlasImage>();\n\t\t\tloadFilesFromOrderingFile(atlasImagesToProcess);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tatlasImagesToProcess = new ArrayList<AtlasImage>();\n\t\t\taddImageFilesInDirectory(m_rootDirectory, true, atlasImagesToProcess);\n\t\t}\n\t\t\n\t\tTexturePacker packer = new TexturePacker();\n\t\tpacker\n\t\t.setDivisibleBy(m_options.m_divisibleBy)\n\t\t.setExtrusion(m_options.m_extrude)\n\t\t.setFixedHeight(m_options.m_fixedHeight)\n\t\t.setFixedWidth(m_options.m_fixedWidth)\n\t\t.setMaxHeight(m_options.m_maxHeight)\n\t\t.setMaxWidth(m_options.m_maxWidth)\n\t\t.setValidHeights(m_options.m_validHeights)\n\t\t.setValidWidths(m_options.m_validWidths)\n\t\t.setHeuristic(m_options.m_packingHeuristic)\n\t\t.setInnerPadding(m_options.m_innerPadding)\n\t\t.setOuterPadding(m_options.m_padding)\n\t\t.enableCropping(m_options.m_crop);\n\t\t\n\t\tArrayList<File> filesToProcess = new ArrayList<File>();\n\t\tfor (AtlasImage atlasImage : atlasImagesToProcess)\n\t\t{\n\t\t\tfilesToProcess.add(atlasImage.getSourceImageFile());\n\t\t}\n\t\t\n\t\tPackedTexture result = packer.pack(filesToProcess, null);\n\t\tif(result == null)\n\t\t{\n\t\t\treturn false;\n\t\t}\n\t\t\n\t\t///////////////////////////////////////////////////////\n\t\t// It's output time!\n\t\t///////////////////////////////////////////////////////\n\t\t// Write our combined png file\n\t\tFile F = new File(m_outputFilePathWithoutExtension + \".png\");\n\t\tImageIO.write(result.getPackedTexture(), \"png\", F);\n\n\t\twriteBinaryFile(result);\n\t\twriteStringIDs(result, atlasImagesToProcess);\n\t\tconvertToCSImage();\n\n\t\tLogging.logVerbose(\"Goodbye!\\n\");\n\n\t\treturn true;\n\t}\n\t/**\n\t * Checks if images specified with options will fit in the sprite sheet dimensions, will populate the error params if not\n\t * @param in_options - Atlas Options\n\t * @param out_errorInfo - Error Info\n\t * @return If the options can fit\n\t * @throws Exception\n\t */\n\tpublic boolean checkCanFit(AtlasBuilderOptions in_options, PackerInfo out_errorInfo) throws Exception\n\t{\n\t\tLogging.logVerbose(\"TextureAtlasTool version \" + k_versionString);\n\t\tLogging.logVerbose(\"-----------------------\");\n\n\t\tm_options = in_options;\n\t\tm_rootDirectory = new File(m_options.m_inputDirectoryPath);\n\t\t\n\t\tList<AtlasImage> atlasImagesToProcess;\n\t\tif (m_options.m_atlasImages.size() > 0)\n\t\t{\n\t\t\tatlasImagesToProcess = m_options.m_atlasImages;\n\t\t}\n\t\telse if (m_options.m_fileList.length() > 0)\n\t\t{\n\t\t\tatlasImagesToProcess = new ArrayList<AtlasImage>();\n\t\t\tloadFilesFromOrderingFile(atlasImagesToProcess);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tatlasImagesToProcess = new ArrayList<AtlasImage>();\n\t\t\taddImageFilesInDirectory(m_rootDirectory, true, atlasImagesToProcess);\n\t\t}\n\t\t\n\t\tTexturePacker packer = new TexturePacker();\n\t\tpacker\n\t\t.setDivisibleBy(m_options.m_divisibleBy)\n\t\t.setExtrusion(m_options.m_extrude)\n\t\t.setFixedHeight(m_options.m_fixedHeight)\n\t\t.setFixedWidth(m_options.m_fixedWidth)\n\t\t.setMaxHeight(m_options.m_maxHeight)\n\t\t.setMaxWidth(m_options.m_maxWidth)\n\t\t.setValidHeights(m_options.m_validHeights)\n\t\t.setValidWidths(m_options.m_validWidths)\n\t\t.setHeuristic(m_options.m_packingHeuristic)\n\t\t.setInnerPadding(m_options.m_innerPadding)\n\t\t.setOuterPadding(m_options.m_padding)\n\t\t.enableCropping(m_options.m_crop)\n\t\t.disableFatalLogs();\n\t\t\n\t\tArrayList<File> filesToProcess = new ArrayList<File>();\n\t\tfor (AtlasImage atlasImage : atlasImagesToProcess)\n\t\t{\n\t\t\tfilesToProcess.add(atlasImage.getSourceImageFile());\n\t\t}\n\t\t\n\t\tPackedTexture result = packer.pack(filesToProcess, out_errorInfo);\n\t\tif(result == null)\n\t\t{\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t}\n\t/**\n\t * @author R Henning\n\t * \n\t * @param The input directory.\n\t * @param Whether or not to recurse. Will only recurse one level deep.\n\t * @param [Out] The output list of files.\n\t */\n\tprivate void addImageFilesInDirectory(File in_directory, boolean in_recursiveDirectorySearch, List<AtlasImage> out_atlasImages) throws CSException\n\t{\n\t\tString[] dirContents = in_directory.list();\n\n\t\tfor (int i = 0; i < dirContents.length; i++)\n\t\t{\n\t\t\tFile contentFile = new File(in_directory, dirContents[i]);\n\n\t\t\tif (contentFile.isDirectory() && in_recursiveDirectorySearch)\n\t\t\t{\n\t\t\t\taddImageFilesInDirectory(contentFile, false, out_atlasImages); // only go one level deep\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tboolean IsPngFile = dirContents[i].endsWith(\".png\") || dirContents[i].endsWith(\".PNG\");\n\t\t\t\tif (IsPngFile == true)\n\t\t\t\t{\n\t\t\t\t\tString atlasImageId = generateSpriteNameFromFile(contentFile);\n\t\t\t\t\tout_atlasImages.add(new AtlasImage(contentFile, atlasImageId));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\t/**\n\t * @author R Henning\n\t * \n\t * @param The input file.\n\t * \n\t * @return The output sprite name.\n\t */\n\tprivate String generateSpriteNameFromFile(File in_file) throws CSException\n\t{\n\t\t//choose the output format for the filenames.\n\t\tString srcFilePath = null;\n\t\tString rootDir = null;\n\t\ttry\n\t\t{\n\t\t\tsrcFilePath = in_file.getCanonicalPath();\n\t\t\trootDir = m_rootDirectory.getCanonicalPath();\n\t\t}\n\t\tcatch (Exception e)\n\t\t{\n\t\t\tthrow new CSException(StringUtils.convertExceptionToString(e));\n\t\t}\n\t\t\n\t\tString srcFilePathWithoutExtension = srcFilePath.substring(0, srcFilePath.lastIndexOf(\".\"));\n\t\tint rootDirLength = rootDir.length();\n\t\tString srcFilePathFromRoot = srcFilePathWithoutExtension.substring(rootDirLength, srcFilePathWithoutExtension.length());\n\n\t\t// replace slashes with underscores\n\t\tString srcFilePathWithoutSlashes = srcFilePathFromRoot.replace('\\\\', '_').replace('/', '_'); \n\t\t\n\t\t//if the first char is an underscore, remove it.\n\t\tif (srcFilePathWithoutSlashes.length() > 0 && srcFilePathWithoutSlashes.getBytes()[0] == '_')\n\t\t{\n\t\t\tsrcFilePathWithoutSlashes = srcFilePathWithoutSlashes.substring(1);\n\t\t}\n\t\treturn srcFilePathWithoutSlashes;\n\t}\n\t/**\n\t * @author R Henning\n\t * \n\t * @param [Out] The list of files.\n\t */\n\tprivate void loadFilesFromOrderingFile(List<AtlasImage> out_atlasImages) throws Exception\n\t{\n\t\tFile f = new File(m_options.m_fileList);\n\t\tFileInputStream in = new FileInputStream(f);\n\n\t\tDataInputStream I = new DataInputStream(in);\n\t\tint length = (int) f.length();\n\t\tbyte tmp[] = new byte[length];\n\t\tI.readFully(tmp);\n\t\tI.close();\n\t\t\n\t\tString fileAsString = new String(tmp);\n\n\t\tString[] lines = fileAsString.replace('\\r','\\n').split(\"\\n\");\n\n\t\tfor(String line : lines)\n\t\t{\n\t\t\tif ((line != null) && (line.length()> 0))\n\t\t\t{\n\t\t\t\tFile imageFile = new File(StringUtils.standardiseFilePath(m_options.m_inputDirectoryPath + \"/\" + line));\n\t\t\t\tString atlasImageId = generateSpriteNameFromFile(imageFile);\n\t\t\t\tout_atlasImages.add(new AtlasImage(imageFile, atlasImageId));\n\t\t\t}\n\t\t}\n\t}\n\t/**\n\t * Converts the temporary png file to CSImage.\n\t * \n\t * @author S Downie\n\t */\n\tprivate void convertToCSImage() throws CSException\n\t{\n\t\tLogging.logVerbose(\"Converting to CSImage\");\n\t\t\n\t\tPNGToCSImageOptions options = new PNGToCSImageOptions();\n\t\toptions.strInputFilename = m_outputFilePathWithoutExtension + \".png\";\n\t\toptions.strOutputFilename = m_outputFilePathWithoutExtension + k_csImageExtension;\n\t\t\n\t\tif (m_options.m_imageCompression.length() > 0)\n\t\t{\n\t\t\toptions.eCompressionType = PNGToCSImage.convertStringToCompressionFormat(m_options.m_imageCompression);\n\t\t}\n\t\t\n\t\tif (m_options.m_imageFormat.length() > 0)\n\t\t{\n\t\t\toptions.eConversionType = PNGToCSImage.convertStringToConversionFormat(m_options.m_imageFormat);\n\t\t}\n\t\t\n\t\tif (m_options.m_imageDither == true)\n\t\t{\n\t\t\toptions.bDither = true;\n\t\t}\n\t\t\n\t\tif (m_options.m_imagePremultiplyAlpha == false)\n\t\t{\n\t\t\toptions.bPremultiply = false;\n\t\t}\n\t\t\n\t\ttry\n        {\n            PNGToCSImage.run(options);\n        }\n        catch(CSException cse)\n        {\n            throw new CSException(\"An exception occurred while converting to CSImage\", cse);\n        }\n        catch(Exception e)\n        {\n            throw new CSException(\"An exception occurred while converting to CSImage\", e);\n        }\n\t\t\n\t\tFileUtils.deleteFile(m_outputFilePathWithoutExtension + \".png\");\n\t}\n\t/**\n\t * @author R Henning\n\t * \n\t * @param The packed texure.\n\t */\n\tprivate void writeBinaryFile(PackedTexture in_packedTexture) throws FileNotFoundException, IOException, Exception\n\t{\n\t\tint numImages = in_packedTexture.getNumImages();\n\t\tDataOutputStream dosBinary = new DataOutputStream(new FileOutputStream(m_outputFilePathWithoutExtension + k_atlasExtension));\n\t\t\n\t\tLittleEndianWriterUtils.writeInt16(dosBinary, (short) numImages);\n\t\tLittleEndianWriterUtils.writeInt16(dosBinary, k_versionNum); // file format revision\n\n\t\t//Write out spritesheet size\n\t\tLittleEndianWriterUtils.writeInt16(dosBinary, (short) in_packedTexture.getPackedWidth());\n\t\tLittleEndianWriterUtils.writeInt16(dosBinary, (short) in_packedTexture.getPackedHeight());\n\t\t\n\t\tLogging.logVerbose(\"Output Image size::\" + in_packedTexture.getPackedWidth() + \" x \" + in_packedTexture.getPackedHeight());\n\t\t\n\t\tfor (int i = 0; i < numImages; i++)\n\t\t{\n\t\t\tint ix = in_packedTexture.getOffsetX(i);\n\t\t\tint iy = in_packedTexture.getOffsetY(i);\n\n\t\t\tint ox = in_packedTexture.getOriginX(i);\n\t\t\tint oy = in_packedTexture.getOriginY(i);\n\t\t\tint width =  in_packedTexture.getCroppedWidth(i);\n\t\t\tint height = in_packedTexture.getCroppedHeight(i);\n\t\t\tint orig_width = in_packedTexture.getOriginalWidth(i);\n\t\t\tint orig_height = in_packedTexture.getOriginalHeight(i);\n\t\t\t\n\t\t\tLogging.logVerbose(\"Writing pixels from:\" + in_packedTexture.getOriginalFile(i).getName());\n\t\t\tLogging.logVerbose(\"Image:\" + i + \" position:\" + ox + \",\" + oy + \":\" + width + \",\" + height);\n\n\t\t\tLittleEndianWriterUtils.writeInt16(dosBinary, (short) ox);\n\t\t\tLittleEndianWriterUtils.writeInt16(dosBinary, (short) oy);\n\t\t\tLittleEndianWriterUtils.writeInt16(dosBinary, (short) width);\n\t\t\tLittleEndianWriterUtils.writeInt16(dosBinary, (short) height);\n\t\t\tLittleEndianWriterUtils.writeInt16(dosBinary, (short) ix);\n\t\t\tLittleEndianWriterUtils.writeInt16(dosBinary, (short) iy);\n\t\t\tLittleEndianWriterUtils.writeInt16(dosBinary, (short) orig_width);\n\t\t\tLittleEndianWriterUtils.writeInt16(dosBinary, (short) orig_height);\n\t\t}\n\n\t\tdosBinary.close();\n\t}\n\t/**\n\t * @author R Henning\n\t * \n\t * @param in_packedTexture - The packaged texture.\n\t * @param in_textureToSpriteNameMapper - Optional file to spriteId name map \n\t */\n\tprivate void writeStringIDs(PackedTexture in_packedTexture, List<AtlasImage> in_atlasImages) throws IOException, CSException\n\t{\n\t\tint numImages = in_packedTexture.getNumImages();\n\t\t\n\t\tFileOutputStream outC = new FileOutputStream(m_outputFilePathWithoutExtension + k_atlasIdExtension);\n\t\tDataOutputStream dosC = new DataOutputStream(outC);\n\n\t\tfor (int i = 0; i < numImages; i++)\n\t\t{\n\t\t\tString atlasImageId = \"\";\n\t\t\t\n\t\t\tfor (AtlasImage atlasImage : in_atlasImages)\n\t\t\t{\n\t\t\t\tif (atlasImage.getSourceImageFile().equals(in_packedTexture.getOriginalFile(i)) == true)\n\t\t\t\t{\n\t\t\t\t\tatlasImageId = atlasImage.getAtlasImageId();\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tif (atlasImageId.length() == 0)\n\t\t\t{\n\t\t\t\tdosC.close();\n\t\t\t    throw new CSException(\"Couldn't file atlas image Id for image: \" + in_packedTexture.getOriginalFile(i).getName());\n\t\t\t}\n\t\t\t\n\t\t\tdosC.writeBytes(atlasImageId);\n\t\t\tdosC.writeByte('\\n');\n\t\t}\n\n\t\tdosC.close();\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/CSAtlasBuilder/src/com/chilliworks/chillisource/csatlasbuilder/Main.java",
    "content": "/**\n * Main.java\n * ChilliSource\n * Created by Ian Copland on 27/06/2014.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2014 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.csatlasbuilder;\n\nimport com.chilliworks.chillisource.coreutils.CSException;\nimport com.chilliworks.chillisource.coreutils.Logging;\nimport com.chilliworks.chillisource.coreutils.Logging.LoggingLevel;\nimport com.chilliworks.chillisource.coreutils.StringUtils;\nimport com.chilliworks.chillisource.texturepackerutils.TexturePacker.PlacementHeuristic;\n\n/**\n * Handles the entry point into the application. This manages the parsing of the input parameters and\n * passes them on to the rest of the tool.\n * \n * @author Ian Copland\n */\npublic final class Main\n{\n\tprivate static final String k_paramInput = \"--input\";\n\tprivate static final String k_paramInputShort = \"-i\";\n\tprivate static final String k_paramOutput = \"--output\";\n\tprivate static final String k_paramOutputShort = \"-o\";\n\tprivate static final String k_paramFileList = \"--filelist\";\n\tprivate static final String k_paramFileListShort = \"-fl\";\n\tprivate static final String k_paramFixedWidth = \"--fixedwidth\";\n\tprivate static final String k_paramFixedWidthShort = \"-fw\";\n\tprivate static final String k_paramFixedHeight = \"--fixedheight\";\n\tprivate static final String k_paramFixedHeightShort = \"-fh\";\n\tprivate static final String k_paramValidWidths = \"--validwidths\";\n\tprivate static final String k_paramValidWidthsShort = \"-vw\";\n\tprivate static final String k_paramValidHeights = \"--validheights\";\n\tprivate static final String k_paramValidHeightsShort = \"-vh\";\n\tprivate static final String k_paramMaxWidth = \"--maxwidth\";\n\tprivate static final String k_paramMaxWidthShort = \"-mw\";\n\tprivate static final String k_paramMaxHeight = \"--maxheight\";\n\tprivate static final String k_paramMaxHeightShort = \"-mh\";\n\tprivate static final String k_paramDivisibleBy = \"--divisibleby\";\n\tprivate static final String k_paramDivisibleByShort = \"-db\";\n\tprivate static final String k_paramDisableCrop = \"--disablecrop\";\n\tprivate static final String k_paramDisableCropShort = \"-dc\";\n\tprivate static final String k_paramPadding = \"--padding\";\n\tprivate static final String k_paramPaddingShort = \"-p\";\n\tprivate static final String k_paramInnerPadding = \"--innerpadding\";\n\tprivate static final String k_paramInnerPaddingShort = \"-ip\";\n\tprivate static final String k_paramExtrude = \"--extrude\";\n\tprivate static final String k_paramExtrudeShort = \"-e\";\n\tprivate static final String k_paramPlacementHeuristic = \"--placementheuristic\";\n\tprivate static final String k_paramPlacementHeuristicShort = \"-ph\";\n\tprivate static final String k_paramImageCompression = \"--imagecompression\";\n\tprivate static final String k_paramImageCompressionShort = \"-ic\";\n\tprivate static final String k_paramImageFormat = \"--imageformat\";\n\tprivate static final String k_paramImageFormatShort = \"-if\";\n\tprivate static final String k_paramDitherImage = \"--ditherimage\";\n\tprivate static final String k_paramDitherImageShort = \"-di\";\n\tprivate static final String k_paramDisablePremultipliedAlpha = \"--disablepremultipliedalpha\";\n\tprivate static final String k_paramDisablePremultipliedAlphaShort = \"-dpa\";\n\tprivate static final String k_paramHelp = \"--help\";\n\tprivate static final String k_paramHelpShort = \"-h\";\n\tprivate static final String k_placementHeuristicTopLeft = \"topleft\";\n\tprivate static final String k_placementHeuristicBottomRight = \"bottomright\";\n\t\n\t/**\n\t * The entry point into the application\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param The input arguments.\n\t */\n\tpublic static void main(String[] in_arguments)\n\t{\n\t\tString[] arguments = Logging.start(in_arguments);\n\t\t\n\t\tif (arguments.length == 0)\n\t\t{\n\t\t\tprintHelpText();\n\t\t\treturn;\n\t\t}\n\t\t\n\t\tAtlasBuilderOptions options = new AtlasBuilderOptions();\n\t\tfor (int i = 0; i < arguments.length; ++i)\n\t\t{\n\t\t\t//input\n\t\t\tif (arguments[i].equalsIgnoreCase(k_paramInput) == true || arguments[i].equalsIgnoreCase(k_paramInputShort) == true)\n\t\t\t{\n\t\t\t\tif (i+1 < arguments.length)\n\t\t\t\t\toptions.m_inputDirectoryPath = StringUtils.standardiseDirectoryPath(arguments[i+1]);\n\t\t\t\telse\n\t\t\t\t\tLogging.logFatal(\"No input directory path provided!\");\n\t\t\t\ti++;\n\t\t\t}\n\t\t\t\n\t\t\t//output\n\t\t\telse if (arguments[i].equalsIgnoreCase(k_paramOutput) == true || arguments[i].equalsIgnoreCase(k_paramOutputShort) == true)\n\t\t\t{\n\t\t\t\tif (i+1 < arguments.length)\n\t\t\t\t\toptions.m_outputFilePath = StringUtils.standardiseFilePath(arguments[i+1]);\n\t\t\t\telse\n\t\t\t\t\tLogging.logFatal(\"No output file path provided!\");\n\t\t\t\ti++;\n\t\t\t}\n\t\t\t\n\t\t\t//file list\n\t\t\telse if (arguments[i].equalsIgnoreCase(k_paramFileList) == true || arguments[i].equalsIgnoreCase(k_paramFileListShort) == true)\n\t\t\t{\n\t\t\t\tif (i+1 < arguments.length)\n\t\t\t\t\toptions.m_fileList = StringUtils.standardiseFilePath(arguments[i+1]);\n\t\t\t\telse\n\t\t\t\t\tLogging.logFatal(\"No file list provided!\");\n\t\t\t\ti++;\n\t\t\t}\n\t\t\t\n\t\t\t//fixed width\n\t\t\telse if (arguments[i].equalsIgnoreCase(k_paramFixedWidth) == true || arguments[i].equalsIgnoreCase(k_paramFixedWidthShort) == true)\n\t\t\t{\n\t\t\t\tif (i+1 < arguments.length)\n\t\t\t\t\toptions.m_fixedWidth = Integer.parseInt(arguments[i+1]);\n\t\t\t\telse\n\t\t\t\t\tLogging.logFatal(\"No fixed width provided!\");\n\t\t\t\ti++;\n\t\t\t}\n\t\t\t\n\t\t\t//fixed height\n\t\t\telse if (arguments[i].equalsIgnoreCase(k_paramFixedHeight) == true || arguments[i].equalsIgnoreCase(k_paramFixedHeightShort) == true)\n\t\t\t{\n\t\t\t\tif (i+1 < arguments.length)\n\t\t\t\t\toptions.m_fixedHeight = Integer.parseInt(arguments[i+1]);\n\t\t\t\telse\n\t\t\t\t\tLogging.logFatal(\"No fixed height provided!\");\n\t\t\t\ti++;\n\t\t\t}\n\t\t\t\n\t\t\t//valid widths\n\t\t\telse if (arguments[i].equalsIgnoreCase(k_paramValidWidths) == true || arguments[i].equalsIgnoreCase(k_paramValidWidthsShort) == true)\n\t\t\t{\n\t\t\t\tif (i+1 < arguments.length)\n\t\t\t\t\toptions.m_validWidths = parseIntegerArray(arguments[i+1]);\n\t\t\t\telse\n\t\t\t\t\tLogging.logFatal(\"No valid widths provided!\");\n\t\t\t\ti++;\n\t\t\t}\n\t\t\t\n\t\t\t//valid heights\n\t\t\telse if (arguments[i].equalsIgnoreCase(k_paramValidHeights) == true || arguments[i].equalsIgnoreCase(k_paramValidHeightsShort) == true)\n\t\t\t{\n\t\t\t\tif (i+1 < arguments.length)\n\t\t\t\t\toptions.m_validHeights = parseIntegerArray(arguments[i+1]);\n\t\t\t\telse\n\t\t\t\t\tLogging.logFatal(\"No valid heights provided!\");\n\t\t\t\ti++;\n\t\t\t}\n\t\t\t\n\t\t\t//max width\n\t\t\telse if (arguments[i].equalsIgnoreCase(k_paramMaxWidth) == true || arguments[i].equalsIgnoreCase(k_paramMaxWidthShort) == true)\n\t\t\t{\n\t\t\t\tif (i+1 < arguments.length)\n\t\t\t\t\toptions.m_maxWidth = Integer.parseInt(arguments[i+1]);\n\t\t\t\telse\n\t\t\t\t\tLogging.logFatal(\"No max width provided!\");\n\t\t\t\ti++;\n\t\t\t}\n\t\t\t\n\t\t\t//max height\n\t\t\telse if (arguments[i].equalsIgnoreCase(k_paramMaxHeight) == true || arguments[i].equalsIgnoreCase(k_paramMaxHeightShort) == true)\n\t\t\t{\n\t\t\t\tif (i+1 < arguments.length)\n\t\t\t\t\toptions.m_maxHeight = Integer.parseInt(arguments[i+1]);\n\t\t\t\telse\n\t\t\t\t\tLogging.logFatal(\"No max height provided!\");\n\t\t\t\ti++;\n\t\t\t}\n\t\t\t\n\t\t\t//divisible by\n\t\t\telse if (arguments[i].equalsIgnoreCase(k_paramDivisibleBy) == true || arguments[i].equalsIgnoreCase(k_paramDivisibleByShort) == true)\n\t\t\t{\n\t\t\t\tif (i+1 < arguments.length)\n\t\t\t\t\toptions.m_divisibleBy = Integer.parseInt(arguments[i+1]);\n\t\t\t\telse\n\t\t\t\t\tLogging.logFatal(\"No divisible by value provided!\");\n\t\t\t\ti++;\n\t\t\t}\n\t\t\t\n\t\t\t//disable cropping\n\t\t\telse if (arguments[i].equalsIgnoreCase(k_paramDisableCrop) == true || arguments[i].equalsIgnoreCase(k_paramDisableCropShort) == true)\n\t\t\t{\n\t\t\t\toptions.m_crop = false;\n\t\t\t}\n\t\t\t\n\t\t\t//padding\n\t\t\telse if (arguments[i].equalsIgnoreCase(k_paramPadding) == true || arguments[i].equalsIgnoreCase(k_paramPaddingShort) == true)\n\t\t\t{\n\t\t\t\tif (i+1 < arguments.length)\n\t\t\t\t\toptions.m_padding = Integer.parseInt(arguments[i+1]);\n\t\t\t\telse\n\t\t\t\t\tLogging.logFatal(\"No padding provided!\");\n\t\t\t\ti++;\n\t\t\t}\n\t\t\t\n\t\t\t//inner padding\n\t\t\telse if (arguments[i].equalsIgnoreCase(k_paramInnerPadding) == true || arguments[i].equalsIgnoreCase(k_paramInnerPaddingShort) == true)\n\t\t\t{\n\t\t\t\tif (i+1 < arguments.length)\n\t\t\t\t\toptions.m_innerPadding = Integer.parseInt(arguments[i+1]);\n\t\t\t\telse\n\t\t\t\t\tLogging.logFatal(\"No inner padding provided!\");\n\t\t\t\ti++;\n\t\t\t}\n\t\t\t\n\t\t\t//extrude\n\t\t\telse if (arguments[i].equalsIgnoreCase(k_paramExtrude) == true || arguments[i].equalsIgnoreCase(k_paramExtrudeShort) == true)\n\t\t\t{\n\t\t\t\tif (i+1 < arguments.length)\n\t\t\t\t\toptions.m_extrude = Integer.parseInt(arguments[i+1]);\n\t\t\t\telse\n\t\t\t\t\tLogging.logFatal(\"No extrude provided!\");\n\t\t\t\ti++;\n\t\t\t}\n\t\t\t\n\t\t\t//packing heuristic\n\t\t\telse if (arguments[i].equalsIgnoreCase(k_paramPlacementHeuristic) == true || arguments[i].equalsIgnoreCase(k_paramPlacementHeuristicShort) == true)\n\t\t\t{\n\t\t\t\tif (i+1 < arguments.length)\n\t\t\t\t\toptions.m_packingHeuristic = parsePackingHeuristic(arguments[i+1]);\n\t\t\t\telse\n\t\t\t\t\tLogging.logFatal(\"No placement heuristic provided!\");\n\t\t\t\ti++;\n\t\t\t}\n\t\t\t\n\t\t\t//image compression\n\t\t\telse if (arguments[i].equalsIgnoreCase(k_paramImageCompression) == true || arguments[i].equalsIgnoreCase(k_paramImageCompressionShort) == true)\n\t\t\t{\n\t\t\t\tif (i+1 < arguments.length)\n\t\t\t\t\toptions.m_imageCompression = arguments[i+1];\n\t\t\t\telse\n\t\t\t\t\tLogging.logFatal(\"No image compression provided!\");\n\t\t\t\ti++;\n\t\t\t}\n\t\t\t\n\t\t\t//image format\n\t\t\telse if (arguments[i].equalsIgnoreCase(k_paramImageFormat) == true || arguments[i].equalsIgnoreCase(k_paramImageFormatShort) == true)\n\t\t\t{\n\t\t\t\tif (i+1 < arguments.length)\n\t\t\t\t\toptions.m_imageFormat = arguments[i+1];\n\t\t\t\telse\n\t\t\t\t\tLogging.logFatal(\"No image format provided!\");\n\t\t\t\ti++;\n\t\t\t}\n\t\t\t\n\t\t\t//image dither\n\t\t\telse if (arguments[i].equalsIgnoreCase(k_paramDitherImage) == true || arguments[i].equalsIgnoreCase(k_paramDitherImageShort) == true)\n\t\t\t{\n\t\t\t\toptions.m_imageDither = true;\n\t\t\t}\n\t\t\t\n\t\t\t//image premultiply alpha\n\t\t\telse if (arguments[i].equalsIgnoreCase(k_paramDisablePremultipliedAlpha) == true || arguments[i].equalsIgnoreCase(k_paramDisablePremultipliedAlphaShort) == true)\n\t\t\t{\n\t\t\t\toptions.m_imagePremultiplyAlpha = false;\n\t\t\t}\n\t\t\t\n\t\t\t//help\n\t\t\telse if (arguments[i].equalsIgnoreCase(k_paramHelp) == true || arguments[i].equalsIgnoreCase(k_paramHelpShort) == true)\n\t\t\t{\n\t\t\t\tprintHelpText();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t\n\t\t\t//failure\n\t\t\telse\n\t\t\t{\n\t\t\t\tLogging.logFatal(\"Invalid parameter found: \" + arguments[i]);\n\t\t\t}\n\t\t}\n\t\t\n\t\tif (options.m_inputDirectoryPath.length() == 0 || options.m_outputFilePath.length() == 0)\n\t\t{\n\t\t\tLogging.logFatal(\"Must provide input directory and output file paths.\");\n\t\t}\n\t\t\n\t\ttry\n        {\n            CSAtlasBuilder tool = new CSAtlasBuilder();\n            tool.buildAtlas(options);\n        }\n        catch(CSException cse)\n        {\n            Logging.logFatal(cse.getMessage());\n        }\n        catch(Exception e)\n        {\n            Logging.logFatal(StringUtils.convertExceptionToString(e));\n        }\n\t\t\n\t\tLogging.finish();\n\t}\n\t/**\n\t * Parses a comma separated list of integers into an array.\n\t *\n\t * @author Ian Copland\n\t * \n\t * @param A string containing a comma separated list of\n\t * integers.\n\t * \n\t * @return An array containing the list of integers.\n\t */\n\tprivate static int[] parseIntegerArray(String in_commaSeparatedList)\n\t{\n\t\tint[] integers = null;\n\t\t\n\t\ttry\n\t\t{\n\t\t\tString[] stringIntegers = in_commaSeparatedList.split(\",\");\n\t\t\tintegers = new int[stringIntegers.length];\n\t\t\tfor (int i = 0; i < stringIntegers.length; ++i)\n\t\t\t{\n\t\t\t\tintegers[i] = Integer.parseInt(stringIntegers[i]);\n\t\t\t}\n\t\t}\n\t\tcatch (Exception e)\n\t\t{\n\t\t\tLogging.logFatal(StringUtils.convertExceptionToString(e));\n\t\t}\n\t\t\n\t\treturn integers;\n\t}\n\t/**\n\t * Parses the packing heuristic.\n\t *\n\t * @author Ian Copland\n\t * \n\t * @param Packing heuristic as a string.\n\t * \n\t * @return The heuristic.\n\t */\n\tprivate static PlacementHeuristic parsePackingHeuristic(String in_packingHeuristic)\n\t{\n\t\tif (in_packingHeuristic.equalsIgnoreCase(k_placementHeuristicTopLeft) == true)\n\t\t{\n\t\t\treturn PlacementHeuristic.TOPLEFT;\n\t\t}\n\t\telse if (in_packingHeuristic.equalsIgnoreCase(k_placementHeuristicBottomRight) == true)\n\t\t{\n\t\t\treturn PlacementHeuristic.BOTTOMRIGHT;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tLogging.logFatal(\"Invalid packing heuristic: \" + in_packingHeuristic);\n\t\t\treturn PlacementHeuristic.TOPLEFT;\n\t\t}\n\t}\n\t/**\n\t * Outputs help test for this tool. This will be displayed regardless of \n\t * the current logging level.\n\t *\n\t * @author Ian Copland\n\t */\n\tprivate static void printHelpText()\n\t{\n\t\tLogging.setLoggingLevel(LoggingLevel.VERBOSE);\n\t\tLogging.logVerbose(\"Usage: java -jar CSAtlasBuilder.jar \" + k_paramInput + \" <directory path> \" + k_paramOutput + \" <file path> [\" + k_paramFileList + \" <file path>] \" +\n\t\t\t\t\"[\" + k_paramFixedWidth + \" <width>] [\" + k_paramFixedHeight + \" <height>] [\" + k_paramValidWidths + \" <w1,w2,w3...>] [\" + k_paramValidHeights + \" <h1,h2,h3...>] \" +\n\t\t\t\t\"[\" + k_paramMaxWidth + \" <width>] [\" + k_paramMaxHeight + \" <height>] [\" + k_paramDivisibleBy + \"<number>] [\" + k_paramDisableCrop + \"] [\" + k_paramPadding + \" <padding>] \" +\n\t\t\t\t\"[\" + k_paramInnerPadding + \" <padding>] [\" + k_paramExtrude + \" <extrude>] [\" + k_paramPlacementHeuristic + \" <heuristic>] [\" + k_paramImageCompression + \" <compression>] \" +\n\t\t\t\t\"[\" + k_paramImageFormat + \" <format>] [\" + k_paramDitherImage + \"] [\" + k_paramDisablePremultipliedAlpha + \"] [\" + Logging.PARAM_LOGGING_LEVEL + \" <level>] [\" + k_paramHelp + \"]\");\n\t\tLogging.logVerbose(\"Parameters:\");\n\t\tLogging.logVerbose(\" \" + k_paramInput + \"(\" + k_paramInputShort + \"): The input directory path containing the character PNGs.\");\n\t\tLogging.logVerbose(\" \" + k_paramOutput + \"(\" + k_paramOutputShort + \"): The output font file path.\");\n\t\tLogging.logVerbose(\" \" + k_paramFileList + \"(\" + k_paramFileListShort + \"): [Optional] A file describing the order of of input files.\");\n\t\tLogging.logVerbose(\" \" + k_paramFixedWidth + \"(\" + k_paramFixedWidthShort + \"): [Optional] Forces the output font image to have the given width.\");\n\t\tLogging.logVerbose(\" \" + k_paramFixedHeight + \"(\" + k_paramFixedHeightShort + \"): [Optional] Forces the output font image to have the given height.\");\n\t\tLogging.logVerbose(\" \" + k_paramValidWidths + \"(\" + k_paramValidWidthsShort + \"): [Optional] A comma separated list of valid output widths.\");\n\t\tLogging.logVerbose(\" \" + k_paramValidHeights + \"(\" + k_paramValidHeightsShort + \"): [Optional] A comma separated list of valid output heights.\");\n\t\tLogging.logVerbose(\" \" + k_paramMaxWidth + \"(\" + k_paramMaxWidthShort + \"): [Optional] The maximum possible width for the output font image.\");\n\t\tLogging.logVerbose(\" \" + k_paramMaxHeight + \"(\" + k_paramMaxHeightShort + \"): [Optional] The maximum possible height for the output font image.\");\n\t\tLogging.logVerbose(\" \" + k_paramDivisibleBy + \"(\" + k_paramDivisibleByShort + \"): [Optional] The output image will dimensions divisible by the given value.\");\n\t\tLogging.logVerbose(\" \" + k_paramDisableCrop + \"(\" + k_paramDisableCropShort + \"): [Optional] If set sprite alpha cropping will be disabled.\");\n\t\tLogging.logVerbose(\" \" + k_paramPadding + \"(\" + k_paramPaddingShort + \"): [Optional] The amount of padding between sprites in the atlas.\");\n\t\tLogging.logVerbose(\" \" + k_paramInnerPadding + \"(\" + k_paramInnerPaddingShort + \"): [Optional] The amount of pixels to leave uncropped.\");\n\t\tLogging.logVerbose(\" \" + k_paramExtrude + \"(\" + k_paramExtrudeShort + \"): [Optional] The amount to extrude the edge of a sprite into the padding. This is used to reduce alpha bleeding.\");\n\t\tLogging.logVerbose(\" \" + k_paramPlacementHeuristic + \"(\" + k_paramPlacementHeuristicShort + \"): [Optional] The heuristic to use when packing characters.\");\n\t\tLogging.logVerbose(\" \" + k_paramImageCompression + \"(\" + k_paramImageCompressionShort + \"): [Optional] The compression used for the output font image.\");\n\t\tLogging.logVerbose(\" \" + k_paramImageFormat + \"(\" + k_paramImageFormatShort + \"): [Optional] The format of the output font image.\");\n\t\tLogging.logVerbose(\" \" + k_paramDitherImage + \"(\" + k_paramDitherImageShort + \"): [Optional] If set the output font image will be dithered.\");\n\t\tLogging.logVerbose(\" \" + k_paramDisablePremultipliedAlpha + \"(\" + k_paramDisablePremultipliedAlphaShort + \"): [Optional] It set the output image will not have it's alpha premultiplied.\");\n\t\tLogging.logVerbose(\" \" + Logging.PARAM_LOGGING_LEVEL + \"(\" + Logging.SHORT_PARAM_LOGGING_LEVEL + \"): [Optional] The level of messages to log.\");\n\t\tLogging.logVerbose(\" \" + k_paramHelp + \"(\" + k_paramHelpShort + \"): [Optional] Display this help message.\");\n\t\tLogging.logVerbose(\"Placement Heuristics:\");\n\t\tLogging.logVerbose(\" \" + k_placementHeuristicTopLeft + \": Place top left.\");\n\t\tLogging.logVerbose(\" \" + k_placementHeuristicBottomRight + \": Place bottom right.\");\n\t\tLogging.logVerbose(\"Image Formats:\");\n\t\tLogging.logVerbose(\" L8\");\n\t\tLogging.logVerbose(\" LA88\");\n\t\tLogging.logVerbose(\" RGB565\");\n\t\tLogging.logVerbose(\" RGBA4444\");\n\t\tLogging.logVerbose(\" RGB888\");\n\t\tLogging.logVerbose(\" RGBA8888\");\n\t\tLogging.logVerbose(\"Compression Types:\");\n\t\tLogging.logVerbose(\" None\");\n\t\tLogging.logVerbose(\" Default\");\n\t\tLogging.logVerbose(\"Logging Levels:\");\n\t\tLogging.logVerbose(\" \" + Logging.LOGGING_LEVEL_NONE + \": No logging.\");\n\t\tLogging.logVerbose(\" \" + Logging.LOGGING_LEVEL_FATAL + \": Only log fatal errors.\");\n\t\tLogging.logVerbose(\" \" + Logging.LOGGING_LEVEL_ERROR + \": Only log errors.\");\n\t\tLogging.logVerbose(\" \" + Logging.LOGGING_LEVEL_WARNING + \": Log errors and warnings.\");\n\t\tLogging.logVerbose(\" \" + Logging.LOGGING_LEVEL_VERBOSE + \": Log all messages.\");\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/CSFontBuilder/.classpath",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<classpath>\n\t<classpathentry kind=\"src\" path=\"src\"/>\n\t<classpathentry combineaccessrules=\"false\" kind=\"src\" path=\"/CoreUtils\"/>\n\t<classpathentry kind=\"con\" path=\"org.eclipse.jdt.launching.JRE_CONTAINER\"/>\n\t<classpathentry combineaccessrules=\"false\" kind=\"src\" path=\"/PNGToCSImage\"/>\n\t<classpathentry combineaccessrules=\"false\" kind=\"src\" path=\"/TexturePackerUtils\"/>\n\t<classpathentry kind=\"output\" path=\"bin\"/>\n</classpath>\n"
  },
  {
    "path": "Projects/Tools/CSFontBuilder/.gitignore",
    "content": "/bin\n/bin\n/bin\n/bin\n/bin\n"
  },
  {
    "path": "Projects/Tools/CSFontBuilder/.project",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<projectDescription>\n\t<name>CSFontBuilder</name>\n\t<comment></comment>\n\t<projects>\n\t</projects>\n\t<buildSpec>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.jdt.core.javabuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t</buildSpec>\n\t<natures>\n\t\t<nature>org.eclipse.jdt.core.javanature</nature>\n\t</natures>\n</projectDescription>\n"
  },
  {
    "path": "Projects/Tools/CSFontBuilder/src/com/chilliworks/chillisource/csfontbuilder/Main.java",
    "content": "/**\n * Main.java\n * ChilliSource\n * Created by Ian Copland on 08/10/2014.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2014 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.csfontbuilder;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\nimport com.chilliworks.chillisource.coreutils.CSException;\nimport com.chilliworks.chillisource.coreutils.Logging;\nimport com.chilliworks.chillisource.coreutils.StringUtils;\nimport com.chilliworks.chillisource.coreutils.Logging.LoggingLevel;\nimport com.chilliworks.chillisource.csfontbuilder.fontbuilder.FontBuilder;\nimport com.chilliworks.chillisource.csfontbuilder.fontfromglyphsbuilder.FontFromGlyphsBuilder;\nimport com.chilliworks.chillisource.csfontbuilder.fontfromglyphsbuilder.FontFromGlyphsBuilderOptions;\nimport com.chilliworks.chillisource.csfontbuilder.fontfromglyphsbuilder.FontFromGlyphsBuilderOptionsParser;\nimport com.chilliworks.chillisource.csfontbuilder.glyphsbuilder.GlyphsBuilder;\nimport com.chilliworks.chillisource.csfontbuilder.glyphsbuilder.GlyphsBuilderOptions;\nimport com.chilliworks.chillisource.csfontbuilder.glyphsbuilder.GlyphsBuilderOptionsParser;\n\n/**\n * Handles the entry point into the application. This manages the parsing of the input parameters and\n * passes them on to the rest of the tool.\n * \n * @author Ian Copland\n */\npublic final class Main\n{\n\tprivate static final String PARAM_MODE = \"--mode\";\n\tprivate static final String PARAM_HELP = \"--help\";\n\tprivate static final String PARAM_INPUT = \"--input\";\n\tprivate static final String PARAM_OUTPUT = \"--output\";\n\t\n\tprivate static final String SHORT_PARAM_MODE = \"-m\";\n\tprivate static final String SHORT_PARAM_HELP = \"-h\";\n\tprivate static final String SHORT_PARAM_INPUT = \"-i\";\n\tprivate static final String SHORT_PARAM_OUTPUT = \"-o\";\n\n\tprivate static final String MODE_FONT = \"font\";\n\tprivate static final String MODE_GLYPHS = \"glyphs\";\n\tprivate static final String MODE_FONT_FROM_GLYPHS = \"fontfromglyphs\";\n\t\n\t/**\n\t * An enum describing the possible modes that the tool can be run in.\n\t * \n\t * @author Ian Copland\n\t */\n\tprivate enum Mode\n\t{\n\t\tFONT,\n\t\tGLYPHS,\n\t\tFONT_FROM_GLYPHS\n\t}\n\t/**\n\t * The entry point into the application\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param in_arguments - The input arguments.\n\t */\n\tpublic static void main(String[] in_arguments) throws Exception \n\t{\n\t\tString[] arguments = Logging.start(in_arguments);\n\t\t\n\t\tif (arguments.length == 0)\n\t\t{\n\t\t\tprintHelpText();\n\t\t\treturn;\n\t\t}\n\t\t\n\t\t//read the base arguments\n\t\tMode mode = Mode.FONT;\n\t\tfor (int i = 0; i < arguments.length; ++i)\n\t\t{\n\t\t\t//mode\n\t\t\tif (arguments[i].equalsIgnoreCase(PARAM_MODE) == true || arguments[i].equalsIgnoreCase(SHORT_PARAM_MODE) == true)\n\t\t\t{\n\t\t\t\tif (i+1 < arguments.length)\n\t\t\t\t\tmode = parseMode(arguments[i+1]);\n\t\t\t\telse\n\t\t\t\t\tLogging.logFatal(\"No mode provided!\");\n\t\t\t\ti++;\n\t\t\t}\n\t\t\t\n\t\t\t//help\n\t\t\telse if (arguments[i].equalsIgnoreCase(PARAM_HELP) == true || arguments[i].equalsIgnoreCase(SHORT_PARAM_HELP) == true)\n\t\t\t{\n\t\t\t\tprintHelpText();\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\t\n\t\t//remove used commands\n\t\targuments = stripBaseArguments(arguments);\n\t\t\n\t\tswitch (mode)\n\t\t{\n\t\tcase FONT:\n\t\t\tprocessFontMode(arguments);\n\t\t\tbreak;\n\t\tcase GLYPHS:\n\t\t\tprocessGlyphsMode(arguments);\n\t\t\tbreak;\n\t\tcase FONT_FROM_GLYPHS:\n\t\t\tprocessFontFromGlyphsMode(arguments);\n\t\t\tbreak;\n\t\t}\n\t\t\n\t\tLogging.finish();\n\t}\n\t/**\n\t * Processes the font mode arguments and passes them onto the tool.\n\t *\n\t * @author Ian Copland\n\t * \n\t * @param in_arguments - The arguments for Font mode. \n\t */\n\tprivate static void processFontMode(String[] in_arguments)\n\t{\n\t\tGlyphsBuilderOptions glyphsBuilderOptions = new GlyphsBuilderOptions();\n\t\tString[] remainingArguments = GlyphsBuilderOptionsParser.parse(in_arguments, glyphsBuilderOptions);\n\t\t\n\t\tFontFromGlyphsBuilderOptions fontFromGlyphsBuilderOptions = new FontFromGlyphsBuilderOptions();\n\t\tremainingArguments = FontFromGlyphsBuilderOptionsParser.parse(remainingArguments, fontFromGlyphsBuilderOptions);\n\t\t\n\t\tString outputFilePath = \"\";\n\t\t\n\t\tfor (int i = 0; i < remainingArguments.length; ++i)\n\t\t{\n\t\t\t//output\n\t\t\tif (remainingArguments[i].equalsIgnoreCase(PARAM_OUTPUT) == true || remainingArguments[i].equalsIgnoreCase(SHORT_PARAM_OUTPUT) == true)\n\t\t\t{\n\t\t\t\tif (i+1 < remainingArguments.length)\n\t\t\t\t\toutputFilePath = StringUtils.standardiseFilePath(remainingArguments[i+1]);\n\t\t\t\telse\n\t\t\t\t\tLogging.logFatal(\"No output directory path provided!\");\n\t\t\t\ti++;\n\t\t\t}\n\t\t\t\n\t\t\t//Error\n\t\t\telse\n\t\t\t{\n\t\t\t\tLogging.logFatal(\"Invalid parameter for 'Font' mode: \" + remainingArguments[i]);\n\t\t\t}\n\t\t}\n\t\t\n\t\tif (outputFilePath.length() == 0)\n\t\t{\n\t\t\tLogging.logFatal(\"An output directory path must be specified.\");\n\t\t}\n\t\t\n\t\ttry\n\t\t{\n\t\t\tFontBuilder.build(outputFilePath, glyphsBuilderOptions, fontFromGlyphsBuilderOptions);\n\t\t}\n\t\tcatch (CSException e)\n\t\t{\n\t\t\tLogging.logVerbose(StringUtils.convertExceptionToString(e));\n\t\t\tLogging.logFatal(e.getMessage());\n\t\t}\n\t}\n\t/**\n\t * Processes the glyphs mode arguments and passes them onto the tool.\n\t *\n\t * @author Ian Copland\n\t * \n\t * @param in_arguments - The arguments for Glyphs mode. \n\t */\n\tprivate static void processGlyphsMode(String[] in_arguments)\n\t{\n\t\tGlyphsBuilderOptions options = new GlyphsBuilderOptions();\n\t\tString[] remainingArguments = GlyphsBuilderOptionsParser.parse(in_arguments, options);\n\t\t\n\t\tString outputDirectoryPath = \"\";\n\t\t\n\t\tfor (int i = 0; i < remainingArguments.length; ++i)\n\t\t{\n\t\t\t//output\n\t\t\tif (remainingArguments[i].equalsIgnoreCase(PARAM_OUTPUT) == true || remainingArguments[i].equalsIgnoreCase(SHORT_PARAM_OUTPUT) == true)\n\t\t\t{\n\t\t\t\tif (i+1 < remainingArguments.length)\n\t\t\t\t\toutputDirectoryPath = StringUtils.standardiseDirectoryPath(remainingArguments[i+1]);\n\t\t\t\telse\n\t\t\t\t\tLogging.logFatal(\"No output directory path provided!\");\n\t\t\t\ti++;\n\t\t\t}\n\t\t\t\n\t\t\t//Error\n\t\t\telse\n\t\t\t{\n\t\t\t\tLogging.logFatal(\"Invalid parameter for 'Glyphs' mode: \" + remainingArguments[i]);\n\t\t\t}\n\t\t}\n\t\t\n\t\tif (outputDirectoryPath.length() == 0)\n\t\t{\n\t\t\tLogging.logFatal(\"An output directory path must be specfied.\");\n\t\t}\n\t\t\n\t\ttry\n\t\t{\n\t\t\tGlyphsBuilder.build(outputDirectoryPath, options);\n\t\t}\n\t\tcatch (CSException e)\n\t\t{\n\t\t\tLogging.logVerbose(StringUtils.convertExceptionToString(e));\n\t\t\tLogging.logFatal(e.getMessage());\n\t\t}\n\t}\n\t/**\n\t * Processes the font from glyphs mode arguments and passes them onto the tool.\n\t *\n\t * @author Ian Copland\n\t * \n\t * @param in_arguments - The arguments for Font From Gylphs mode. \n\t */\n\tprivate static void processFontFromGlyphsMode(String[] in_arguments)\n\t{\n\t\tFontFromGlyphsBuilderOptions options = new FontFromGlyphsBuilderOptions();\n\t\tString[] remainingArguments = FontFromGlyphsBuilderOptionsParser.parse(in_arguments, options);\n\t\t\n\t\tString inputDirectoryPath = \"\";\n\t\tString outputFilePath = \"\";\n\t\t\n\t\tfor (int i = 0; i < remainingArguments.length; ++i)\n\t\t{\n\t\t\t//input\n\t\t\tif (remainingArguments[i].equalsIgnoreCase(PARAM_INPUT) == true || remainingArguments[i].equalsIgnoreCase(SHORT_PARAM_INPUT) == true)\n\t\t\t{\n\t\t\t\tif (i+1 < remainingArguments.length)\n\t\t\t\t\tinputDirectoryPath = StringUtils.standardiseDirectoryPath(remainingArguments[i+1]);\n\t\t\t\telse\n\t\t\t\t\tLogging.logFatal(\"No input directory path provided!\");\n\t\t\t\ti++;\n\t\t\t}\n\t\t\t\n\t\t\t//output\n\t\t\telse if (remainingArguments[i].equalsIgnoreCase(PARAM_OUTPUT) == true || remainingArguments[i].equalsIgnoreCase(SHORT_PARAM_OUTPUT) == true)\n\t\t\t{\n\t\t\t\tif (i+1 < remainingArguments.length)\n\t\t\t\t\toutputFilePath = StringUtils.standardiseFilePath(remainingArguments[i+1]);\n\t\t\t\telse\n\t\t\t\t\tLogging.logFatal(\"No output file path provided!\");\n\t\t\t\ti++;\n\t\t\t}\n\t\t\t\n\t\t\t//Error\n\t\t\telse\n\t\t\t{\n\t\t\t\tLogging.logFatal(\"Invalid parameter for 'Glyphs' mode: \" + remainingArguments[i]);\n\t\t\t}\n\t\t}\n\t\t\n\t\ttry\n\t\t{\n\t\t\tFontFromGlyphsBuilder.build(inputDirectoryPath, outputFilePath, options);\n\t\t}\n\t\tcatch (CSException e)\n\t\t{\n\t\t\tLogging.logVerbose(StringUtils.convertExceptionToString(e));\n\t\t\tLogging.logFatal(e.getMessage());\n\t\t}\n\t}\n\t/**\n\t * Strips the base arguments from the argument list.\n\t *\n\t * @author Ian Copland\n\t * \n\t * @param The string to parse.\n\t * \n\t * @return The mode the string is describing.\n\t */\n\tprivate static String[] stripBaseArguments(String[] in_arguments)\n\t{\n\t\tList<String> output = new ArrayList<>();\n\t\tfor (int i = 0; i < in_arguments.length; ++i)\n\t\t{\n\t\t\tif (in_arguments[i].equalsIgnoreCase(PARAM_MODE) == true || in_arguments[i].equalsIgnoreCase(SHORT_PARAM_MODE) == true)\n\t\t\t{\n\t\t\t\t++i;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\telse if (in_arguments[i].equalsIgnoreCase(PARAM_HELP) == true || in_arguments[i].equalsIgnoreCase(SHORT_PARAM_HELP) == true)\n\t\t\t{\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\toutput.add(in_arguments[i]);\n\t\t\t}\n\t\t}\n\t\treturn output.toArray(new String[0]);\n\t}\n\t/**\n\t * Parses a mode from the given string.\n\t *\n\t * @author Ian Copland\n\t * \n\t * @param The string to parse.\n\t * \n\t * @return The mode the string is describing.\n\t */\n\tprivate static Mode parseMode(String in_stringToParse)\n\t{\n\t\tif (in_stringToParse.equalsIgnoreCase(MODE_FONT) == true)\n\t\t{\n\t\t\treturn Mode.FONT;\n\t\t}\n\t\telse if (in_stringToParse.equalsIgnoreCase(MODE_GLYPHS) == true)\n\t\t{\n\t\t\treturn Mode.GLYPHS;\n\t\t}\n\t\telse if (in_stringToParse.equalsIgnoreCase(MODE_FONT_FROM_GLYPHS) == true)\n\t\t{\n\t\t\treturn Mode.FONT_FROM_GLYPHS;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tLogging.logFatal(\"Invalid mode provided: \" + in_stringToParse);\n\t\t\treturn Mode.FONT;\n\t\t}\n\t}\n\t/**\n\t * Outputs help test for this tool. This will be displayed regardless of \n\t * the current logging level.\n\t *\n\t * @author Ian Copland\n\t */\n\tprivate static void printHelpText()\n\t{\n\t\tLogging.setLoggingLevel(LoggingLevel.VERBOSE);\n\t\tLogging.logVerbose(\"Usage: java -jar CFontBuilder.jar [\" + Logging.PARAM_LOGGING_LEVEL + \" <level>] [\" + PARAM_HELP + \"] [\" + PARAM_MODE + \" <mode>] <mode specific parameters>\");\n\t\tLogging.logVerbose(\" \");\n\t\tLogging.logVerbose(\"Base Parameters:\");\n\t\tLogging.logVerbose(\" \" + PARAM_MODE + \"(\" + SHORT_PARAM_MODE + \"): The mode the tool is run in. This defaults to Font mode.\");\n\t\tLogging.logVerbose(\" \" + Logging.PARAM_LOGGING_LEVEL + \"(\" + Logging.SHORT_PARAM_LOGGING_LEVEL + \"): [Optional] The level of messages to log.\");\n\t\tLogging.logVerbose(\" \" + PARAM_HELP + \"(\" + SHORT_PARAM_HELP + \"): [Optional] Display this help message.\");\n\t\tLogging.logVerbose(\" \");\n\t\tLogging.logVerbose(\"Font Mode Parameters:\");\n\t\tLogging.logVerbose(\" \" + PARAM_OUTPUT + \"(\" + SHORT_PARAM_OUTPUT + \"): The output file path of the CSFont file.\");\n\t\tLogging.logVerbose(\" \" + GlyphsBuilderOptionsParser.PARAM_CHARACTERS + \"(\" + GlyphsBuilderOptionsParser.SHORT_PARAM_CHARACTERS + \"): [Optional] The list of characters that glyphs should be created for. Defaults to the full character set for english, french, italian, german and spanish.\");\n\t\tLogging.logVerbose(\" \" + GlyphsBuilderOptionsParser.PARAM_FONT_NAME + \"(\" + GlyphsBuilderOptionsParser.SHORT_PARAM_FONT_NAME + \"): [Optional] The name of the system font that should be used to create the bitmap glyphs. Defaults to Arial.\");\n\t\tLogging.logVerbose(\" \" + GlyphsBuilderOptionsParser.PARAM_FONT_STYLE + \"(\" + GlyphsBuilderOptionsParser.SHORT_PARAM_FONT_STYLE + \"): [Optional] The font style that should be used. Defaults to Plain.\");\n\t\tLogging.logVerbose(\" \" + GlyphsBuilderOptionsParser.PARAM_FONT_SIZE + \"(\" + GlyphsBuilderOptionsParser.SHORT_PARAM_FONT_SIZE + \"): [Optional] The point size of the output glyphs. Defaults to 12.\");\n\t\tLogging.logVerbose(\" \" + GlyphsBuilderOptionsParser.PARAM_FONT_COLOUR + \"(\" + GlyphsBuilderOptionsParser.SHORT_PARAM_FONT_COLOUR + \"): [Optional] The colour of the output glyphs. Defaults to white.\");\n\t\tLogging.logVerbose(\" \" + GlyphsBuilderOptionsParser.PARAM_ENABLE_DROP_SHADOW + \"(\" + GlyphsBuilderOptionsParser.SHORT_PARAM_ENABLE_DROP_SHADOW + \"): [Optional] Enables outputting the glyphs with a drop shadow.\");\n\t\tLogging.logVerbose(\" \" + GlyphsBuilderOptionsParser.PARAM_DROP_SHADOW_COLOUR + \"(\" + GlyphsBuilderOptionsParser.SHORT_PARAM_DROP_SHADOW_COLOUR + \"): [Optional] Sets the colour of the drop shadow. Does nothing if a drop shadow is not enabled. Defaults to grey.\");\n\t\tLogging.logVerbose(\" \" + GlyphsBuilderOptionsParser.PARAM_DROP_SHADOW_OFFSET + \"(\" + GlyphsBuilderOptionsParser.SHORT_PARAM_DROP_SHADOW_OFFSET + \"): [Optional] Sets the offset of the drop shadow. Does nothing if a drop shadow is not enabled. Defaults to (2, 2).\");\n\t\tLogging.logVerbose(\" \" + GlyphsBuilderOptionsParser.PARAM_ENABLE_OUTLINE + \"(\" + GlyphsBuilderOptionsParser.SHORT_PARAM_ENABLE_OUTLINE + \"): [Optional] Enables outputting the glyphs with an outline.\");\n\t\tLogging.logVerbose(\" \" + GlyphsBuilderOptionsParser.PARAM_OUTLINE_COLOUR + \"(\" + GlyphsBuilderOptionsParser.SHORT_PARAM_OUTLINE_COLOUR + \"): [Optional] Sets the colour of the outline. Does nothing if an outline is not enabled. Defaults to black.\");\n\t\tLogging.logVerbose(\" \" + GlyphsBuilderOptionsParser.PARAM_OUTLINE_SIZE + \"(\" + GlyphsBuilderOptionsParser.SHORT_PARAM_OUTLINE_SIZE + \"): [Optional] Sets the size of the outline. Does nothing if an outline is not enabled. Defaults to 1.\");\n\t\tLogging.logVerbose(\" \" + GlyphsBuilderOptionsParser.PARAM_ENABLE_GLOW + \"(\" + GlyphsBuilderOptionsParser.SHORT_PARAM_ENABLE_GLOW + \"): [Optional] Enables outputting the glyphs with a glow.\");\n\t\tLogging.logVerbose(\" \" + GlyphsBuilderOptionsParser.PARAM_GLOW_COLOUR + \"(\" + GlyphsBuilderOptionsParser.SHORT_PARAM_GLOW_COLOUR + \"): [Optional] Sets the colour of the glow. Does nothing if a glow is not enabled. Defaults to white.\");\n\t\tLogging.logVerbose(\" \" + GlyphsBuilderOptionsParser.PARAM_GLOW_SIZE + \"(\" + GlyphsBuilderOptionsParser.SHORT_PARAM_GLOW_SIZE + \"): [Optional] Sets the size of the glow. Does nothing if a glow is not enabled. Defaults to 3.\");\n\t\tLogging.logVerbose(\" \" + FontFromGlyphsBuilderOptionsParser.PARAM_FIXED_WIDTH + \"(\" + FontFromGlyphsBuilderOptionsParser.SHORT_PARAM_FIXED_WIDTH + \"): [Optional] Forces the output font image to have the given width.\");\n\t\tLogging.logVerbose(\" \" + FontFromGlyphsBuilderOptionsParser.PARAM_FIXED_HEIGHT + \"(\" + FontFromGlyphsBuilderOptionsParser.SHORT_PARAM_FIXED_HEIGHT + \"): [Optional] Forces the output font image to have the given height.\");\n\t\tLogging.logVerbose(\" \" + FontFromGlyphsBuilderOptionsParser.PARAM_VALID_WIDTHS + \"(\" + FontFromGlyphsBuilderOptionsParser.SHORT_PARAM_VALID_WIDTHS + \"): [Optional] A comma separated list of valid output widths.\");\n\t\tLogging.logVerbose(\" \" + FontFromGlyphsBuilderOptionsParser.PARAM_VALID_HEIGHTS + \"(\" + FontFromGlyphsBuilderOptionsParser.SHORT_PARAM_VALID_HEIGHTS + \"): [Optional] A comma separated list of valid output heights.\");\n\t\tLogging.logVerbose(\" \" + FontFromGlyphsBuilderOptionsParser.PARAM_MAX_WIDTH + \"(\" + FontFromGlyphsBuilderOptionsParser.SHORT_PARAM_MAX_WIDTH + \"): [Optional] The maximum possible width for the output font image.\");\n\t\tLogging.logVerbose(\" \" + FontFromGlyphsBuilderOptionsParser.PARAM_MAX_HEIGHT + \"(\" + FontFromGlyphsBuilderOptionsParser.SHORT_PARAM_MAX_HEIGHT + \"): [Optional] The maximum possible height for the output font image.\");\n\t\tLogging.logVerbose(\" \" + FontFromGlyphsBuilderOptionsParser.PARAM_DIVISIBLE_BY + \"(\" + FontFromGlyphsBuilderOptionsParser.SHORT_PARAM_DIVISIBLE_BY + \"): [Optional] The output image will dimensions divisible by the given value.\");\n\t\tLogging.logVerbose(\" \" + FontFromGlyphsBuilderOptionsParser.PARAM_PLACEMENT_HEURISTIC + \"(\" + FontFromGlyphsBuilderOptionsParser.SHORT_PARAM_PLACEMENT_HEURISTIC + \"): [Optional] The heuristic to use when packing characters.\");\n\t\tLogging.logVerbose(\" \" + FontFromGlyphsBuilderOptionsParser.PARAM_IMAGE_COMPRESSION + \"(\" + FontFromGlyphsBuilderOptionsParser.SHORT_PARAM_IMAGE_COMPRESSION + \"): [Optional] The compression used for the output font image.\");\n\t\tLogging.logVerbose(\" \" + FontFromGlyphsBuilderOptionsParser.PARAM_IMAGE_FORMAT + \"(\" + FontFromGlyphsBuilderOptionsParser.SHORT_PARAM_IMAGE_FORMAT + \"): [Optional] The format of the output font image.\");\n\t\tLogging.logVerbose(\" \" + FontFromGlyphsBuilderOptionsParser.PARAM_IMAGE_FORMAT + \"(\" + FontFromGlyphsBuilderOptionsParser.SHORT_PARAM_IMAGE_FORMAT + \"): [Optional] If set the output font image will be dithered.\");\n\t\tLogging.logVerbose(\" \" + FontFromGlyphsBuilderOptionsParser.PARAM_DISABLE_PREMULTIPLIED_ALPHA + \"(\" + FontFromGlyphsBuilderOptionsParser.SHORT_PARAM_DISABLE_PREMULTIPLIED_ALPHA + \"): [Optional] If set the output font image will not have its alpha premultiplied.\");\n\t\tLogging.logVerbose(\" \");\n\t\tLogging.logVerbose(\"Glyphs Mode Parameters:\");\n\t\tLogging.logVerbose(\" \" + PARAM_OUTPUT + \"(\" + SHORT_PARAM_OUTPUT + \"): The output directory where the bitmap glyphs should be placed.\");\n\t\tLogging.logVerbose(\" \" + GlyphsBuilderOptionsParser.PARAM_CHARACTERS + \"(\" + GlyphsBuilderOptionsParser.SHORT_PARAM_CHARACTERS + \"): [Optional] The list of characters that glyphs should be created for. Defaults to the full character set for english, french, italian, german and spanish.\");\n\t\tLogging.logVerbose(\" \" + GlyphsBuilderOptionsParser.PARAM_FONT_NAME + \"(\" + GlyphsBuilderOptionsParser.SHORT_PARAM_FONT_NAME + \"): [Optional] The name of the system font that should be used to create the bitmap glyphs. Defaults to Arial.\");\n\t\tLogging.logVerbose(\" \" + GlyphsBuilderOptionsParser.PARAM_FONT_STYLE + \"(\" + GlyphsBuilderOptionsParser.SHORT_PARAM_FONT_STYLE + \"): [Optional] The font style that should be used. Defaults to Plain.\");\n\t\tLogging.logVerbose(\" \" + GlyphsBuilderOptionsParser.PARAM_FONT_SIZE + \"(\" + GlyphsBuilderOptionsParser.SHORT_PARAM_FONT_SIZE + \"): [Optional] The point size of the output glyphs. Defaults to 12.\");\n\t\tLogging.logVerbose(\" \" + GlyphsBuilderOptionsParser.PARAM_FONT_COLOUR + \"(\" + GlyphsBuilderOptionsParser.SHORT_PARAM_FONT_COLOUR + \"): [Optional] The colour of the output glyphs. Defaults to white.\");\n\t\tLogging.logVerbose(\" \" + GlyphsBuilderOptionsParser.PARAM_ENABLE_DROP_SHADOW + \"(\" + GlyphsBuilderOptionsParser.SHORT_PARAM_ENABLE_DROP_SHADOW + \"): [Optional] Enables outputting the glyphs with a drop shadow.\");\n\t\tLogging.logVerbose(\" \" + GlyphsBuilderOptionsParser.PARAM_DROP_SHADOW_COLOUR + \"(\" + GlyphsBuilderOptionsParser.SHORT_PARAM_DROP_SHADOW_COLOUR + \"): [Optional] Sets the colour of the drop shadow. Does nothing if a drop shadow is not enabled. Defaults to grey.\");\n\t\tLogging.logVerbose(\" \" + GlyphsBuilderOptionsParser.PARAM_DROP_SHADOW_OFFSET + \"(\" + GlyphsBuilderOptionsParser.SHORT_PARAM_DROP_SHADOW_OFFSET + \"): [Optional] Sets the offset of the drop shadow. Does nothing if a drop shadow is not enabled. Defaults to (2, 2).\");\n\t\tLogging.logVerbose(\" \" + GlyphsBuilderOptionsParser.PARAM_ENABLE_OUTLINE + \"(\" + GlyphsBuilderOptionsParser.SHORT_PARAM_ENABLE_OUTLINE + \"): [Optional] Enables outputting the glyphs with an outline.\");\n\t\tLogging.logVerbose(\" \" + GlyphsBuilderOptionsParser.PARAM_OUTLINE_COLOUR + \"(\" + GlyphsBuilderOptionsParser.SHORT_PARAM_OUTLINE_COLOUR + \"): [Optional] Sets the colour of the outline. Does nothing if an outline is not enabled. Defaults to black.\");\n\t\tLogging.logVerbose(\" \" + GlyphsBuilderOptionsParser.PARAM_OUTLINE_SIZE + \"(\" + GlyphsBuilderOptionsParser.SHORT_PARAM_OUTLINE_SIZE + \"): [Optional] Sets the size of the outline. Does nothing if an outline is not enabled. Defaults to 1.\");\n\t\tLogging.logVerbose(\" \" + GlyphsBuilderOptionsParser.PARAM_ENABLE_GLOW + \"(\" + GlyphsBuilderOptionsParser.SHORT_PARAM_ENABLE_GLOW + \"): [Optional] Enables outputting the glyphs with a glow.\");\n\t\tLogging.logVerbose(\" \" + GlyphsBuilderOptionsParser.PARAM_GLOW_COLOUR + \"(\" + GlyphsBuilderOptionsParser.SHORT_PARAM_GLOW_COLOUR + \"): [Optional] Sets the colour of the glow. Does nothing if a glow is not enabled. Defaults to white.\");\n\t\tLogging.logVerbose(\" \" + GlyphsBuilderOptionsParser.PARAM_GLOW_SIZE + \"(\" + GlyphsBuilderOptionsParser.SHORT_PARAM_GLOW_SIZE + \"): [Optional] Sets the size of the glow. Does nothing if a glow is not enabled. Defaults to 3.\");\n\t\tLogging.logVerbose(\" \");\n\t\tLogging.logVerbose(\"Font From Glyphs Mode Parameters:\");\n\t\tLogging.logVerbose(\" \" + PARAM_INPUT + \"(\" + SHORT_PARAM_INPUT + \"): The input directory path containing the bitmap glyphs and the FontInfo.csfontinfo file.\");\n\t\tLogging.logVerbose(\" \" + PARAM_OUTPUT + \"(\" + SHORT_PARAM_OUTPUT + \"): The output file path of the CSFont file.\");\n\t\tLogging.logVerbose(\" \" + FontFromGlyphsBuilderOptionsParser.PARAM_FIXED_WIDTH + \"(\" + FontFromGlyphsBuilderOptionsParser.SHORT_PARAM_FIXED_WIDTH + \"): [Optional] Forces the output font image to have the given width.\");\n\t\tLogging.logVerbose(\" \" + FontFromGlyphsBuilderOptionsParser.PARAM_FIXED_HEIGHT + \"(\" + FontFromGlyphsBuilderOptionsParser.SHORT_PARAM_FIXED_HEIGHT + \"): [Optional] Forces the output font image to have the given height.\");\n\t\tLogging.logVerbose(\" \" + FontFromGlyphsBuilderOptionsParser.PARAM_VALID_WIDTHS + \"(\" + FontFromGlyphsBuilderOptionsParser.SHORT_PARAM_VALID_WIDTHS + \"): [Optional] A comma separated list of valid output widths.\");\n\t\tLogging.logVerbose(\" \" + FontFromGlyphsBuilderOptionsParser.PARAM_VALID_HEIGHTS + \"(\" + FontFromGlyphsBuilderOptionsParser.SHORT_PARAM_VALID_HEIGHTS + \"): [Optional] A comma separated list of valid output heights.\");\n\t\tLogging.logVerbose(\" \" + FontFromGlyphsBuilderOptionsParser.PARAM_MAX_WIDTH + \"(\" + FontFromGlyphsBuilderOptionsParser.SHORT_PARAM_MAX_WIDTH + \"): [Optional] The maximum possible width for the output font image.\");\n\t\tLogging.logVerbose(\" \" + FontFromGlyphsBuilderOptionsParser.PARAM_MAX_HEIGHT + \"(\" + FontFromGlyphsBuilderOptionsParser.SHORT_PARAM_MAX_HEIGHT + \"): [Optional] The maximum possible height for the output font image.\");\n\t\tLogging.logVerbose(\" \" + FontFromGlyphsBuilderOptionsParser.PARAM_DIVISIBLE_BY + \"(\" + FontFromGlyphsBuilderOptionsParser.SHORT_PARAM_DIVISIBLE_BY + \"): [Optional] The output image will dimensions divisible by the given value.\");\n\t\tLogging.logVerbose(\" \" + FontFromGlyphsBuilderOptionsParser.PARAM_PLACEMENT_HEURISTIC + \"(\" + FontFromGlyphsBuilderOptionsParser.SHORT_PARAM_PLACEMENT_HEURISTIC + \"): [Optional] The heuristic to use when packing characters.\");\n\t\tLogging.logVerbose(\" \" + FontFromGlyphsBuilderOptionsParser.PARAM_IMAGE_COMPRESSION + \"(\" + FontFromGlyphsBuilderOptionsParser.SHORT_PARAM_IMAGE_COMPRESSION + \"): [Optional] The compression used for the output font image.\");\n\t\tLogging.logVerbose(\" \" + FontFromGlyphsBuilderOptionsParser.PARAM_IMAGE_FORMAT + \"(\" + FontFromGlyphsBuilderOptionsParser.SHORT_PARAM_IMAGE_FORMAT + \"): [Optional] The format of the output font image.\");\n\t\tLogging.logVerbose(\" \" + FontFromGlyphsBuilderOptionsParser.PARAM_IMAGE_FORMAT + \"(\" + FontFromGlyphsBuilderOptionsParser.SHORT_PARAM_IMAGE_FORMAT + \"): [Optional] If set the output font image will be dithered.\");\n\t\tLogging.logVerbose(\" \" + FontFromGlyphsBuilderOptionsParser.PARAM_DISABLE_PREMULTIPLIED_ALPHA + \"(\" + FontFromGlyphsBuilderOptionsParser.SHORT_PARAM_DISABLE_PREMULTIPLIED_ALPHA + \"): [Optional] If set the output font image will not have its alpha premultiplied.\");\n\t\tLogging.logVerbose(\" \");\n\t\tLogging.logVerbose(\"Modes:\");\n\t\tLogging.logVerbose(\" \" + MODE_FONT + \": Creates a CSFont file from the input ttf or oft font file.\");\n\t\tLogging.logVerbose(\" \" + MODE_GLYPHS + \": Creates bitmap glyphs from the input ttf or oft font file.\");\n\t\tLogging.logVerbose(\" \" + MODE_FONT_FROM_GLYPHS + \": Creates a CSFont file from the input bitmap glyphs.\");\n\t\tLogging.logVerbose(\" \");\n\t\tLogging.logVerbose(\"Logging Levels:\");\n\t\tLogging.logVerbose(\" \" + Logging.LOGGING_LEVEL_NONE + \": No logging.\");\n\t\tLogging.logVerbose(\" \" + Logging.LOGGING_LEVEL_FATAL + \": Only log fatal errors.\");\n\t\tLogging.logVerbose(\" \" + Logging.LOGGING_LEVEL_ERROR + \": Only log errors.\");\n\t\tLogging.logVerbose(\" \" + Logging.LOGGING_LEVEL_WARNING + \": Log errors and warnings.\");\n\t\tLogging.logVerbose(\" \" + Logging.LOGGING_LEVEL_VERBOSE + \": Log all messages.\");\n\t\tLogging.logVerbose(\" \");\n\t\tLogging.logVerbose(\"Font Styles:\");\n\t\tLogging.logVerbose(\" \" + GlyphsBuilderOptionsParser.FONT_STYLE_PLAIN + \": The regular style for the font.\");\n\t\tLogging.logVerbose(\" \" + GlyphsBuilderOptionsParser.FONT_STYLE_BOLD + \": The bold style for the font.\");\n\t\tLogging.logVerbose(\" \" + GlyphsBuilderOptionsParser.FONT_STYLE_ITALIC + \": The italic style for the font.\");\n\t\tLogging.logVerbose(\" \");\n\t\tLogging.logVerbose(\"Placement Heuristics:\");\n\t\tLogging.logVerbose(\" \" + FontFromGlyphsBuilderOptionsParser.PLACEMENT_HEURISTIC_TOP_LEFT + \": Place top left.\");\n\t\tLogging.logVerbose(\" \" + FontFromGlyphsBuilderOptionsParser.PLACEMENT_HEURISTIC_BOTTOM_RIGHT + \": Place bottom right.\");\n\t\tLogging.logVerbose(\" \");\n\t\tLogging.logVerbose(\"Image Formats:\");\n\t\tLogging.logVerbose(\" L8\");\n\t\tLogging.logVerbose(\" LA88\");\n\t\tLogging.logVerbose(\" RGB565\");\n\t\tLogging.logVerbose(\" RGBA4444\");\n\t\tLogging.logVerbose(\" RGB888\");\n\t\tLogging.logVerbose(\" RGBA8888\");\n\t\tLogging.logVerbose(\" \");\n\t\tLogging.logVerbose(\"Compression Types:\");\n\t\tLogging.logVerbose(\" None\");\n\t\tLogging.logVerbose(\" Default\");\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/CSFontBuilder/src/com/chilliworks/chillisource/csfontbuilder/fontbuilder/FontBuilder.java",
    "content": "/**\n * FontBuilder.java\n * ChilliSource\n * Created by Ian Copland on 08/10/2014.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2014 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.csfontbuilder.fontbuilder;\n\nimport java.io.File;\nimport java.util.Random;\n\nimport com.chilliworks.chillisource.coreutils.CSException;\nimport com.chilliworks.chillisource.coreutils.FileUtils;\nimport com.chilliworks.chillisource.coreutils.StringUtils;\nimport com.chilliworks.chillisource.csfontbuilder.fontfromglyphsbuilder.FontFromGlyphsBuilder;\nimport com.chilliworks.chillisource.csfontbuilder.fontfromglyphsbuilder.FontFromGlyphsBuilderOptions;\nimport com.chilliworks.chillisource.csfontbuilder.glyphsbuilder.GlyphsBuilder;\nimport com.chilliworks.chillisource.csfontbuilder.glyphsbuilder.GlyphsBuilderOptions;\n \n/**\n * A static class containing methods for building CSFont bitmap fonts from\n * vector fonts in either TTF or OTF format.\n * \n * @author Ian Copland\n */\npublic final class FontBuilder\n{\n\tprivate static final String TEMP_DIRECTORY_PATH_PREFIX = \"_temp-glyphs-\";\n\t\n\t/**\n\t * Builds a CSFont from a TTF or OTF vector font with the given options.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param in_outputFilePath - The output csfont file path.\n\t * @param in_glyphBuilderOptions - The glyphs builder options.\n\t * @param in_fontFromGlyphsBuilderOptions - The font from glyphs builder options.\n\t * \n\t * @throws CSException - An exception which provides a message describing \n\t * the error which has occurred.\n\t */\n\tpublic static void build(String in_outputFilePath, GlyphsBuilderOptions in_glyphBuilderOptions, FontFromGlyphsBuilderOptions in_fontFromGlyphsBuilderOptions) throws CSException\n\t{\n\t\tString randomHex = Long.toHexString(new Random().nextLong());\n\t\tString outputDirectoryPath = StringUtils.getDirectory(in_outputFilePath);\n\t\tString tempDirectoryPath = outputDirectoryPath + TEMP_DIRECTORY_PATH_PREFIX + randomHex + \"/\";\n\t\t\n\t\tcreateTempDirectory(tempDirectoryPath);\n\t\t\n\t\ttry\n\t\t{\n\t\t\tGlyphsBuilder.build(tempDirectoryPath, in_glyphBuilderOptions);\n\t\t\tFontFromGlyphsBuilder.build(tempDirectoryPath, in_outputFilePath, in_fontFromGlyphsBuilderOptions);\n\t\t}\n\t\tcatch (CSException e)\n\t\t{\n\t\t\tthrow new CSException(e.getMessage(), e);\n\t\t}\n\t\tfinally\n\t\t{\n\t\t\tdeleteTempDirectory(tempDirectoryPath);\n\t\t}\n\t}\n\t/**\n\t * Creates the temporary directory to create the output files in.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param in_tempDirectoryPath - The temporary directory path.\n\t * \n\t * @throws CSException - An exception which provides a message \n\t * describing the error which has occurred.\n\t */\n\tprivate static void createTempDirectory(String in_tempDirectoryPath) throws CSException\n\t{\n\t\tif (new File(in_tempDirectoryPath).exists() == true)\n\t\t{\n\t\t\tthrow new CSException(\"Could not create temp directory as it already exists: \" + in_tempDirectoryPath);\n\t\t}\n\t\t\n\t\tif (FileUtils.createDirectory(in_tempDirectoryPath) == false)\n\t\t{\n\t\t\tthrow new CSException(\"Could not create temp directory: \" + in_tempDirectoryPath);\n\t\t}\n\t}\n\t/**\n\t * Deletes the temporary directory and its contents.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param in_tempDirectoryPath - The temporary directory path.\n\t * \n\t * @throws CSException - An exception which provides a message \n\t * describing the error which has occurred.\n\t */\n\tprivate static void deleteTempDirectory(String in_tempDirectoryPath) throws CSException\n\t{\n\t\tif (FileUtils.deleteDirectory(in_tempDirectoryPath) == false)\n\t\t{\n\t\t\tthrow new CSException(\"Could not delete temp directory: \" + in_tempDirectoryPath);\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/CSFontBuilder/src/com/chilliworks/chillisource/csfontbuilder/fontfromglyphsbuilder/CSFontWriter.java",
    "content": "/**\n * CSFontWriter.java\n * ChilliSource\n * Created by Ian Copland on 21/10/2014.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2014 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.csfontbuilder.fontfromglyphsbuilder;\n\nimport java.io.DataOutputStream;\nimport java.io.File;\nimport java.io.FileOutputStream;\nimport java.io.IOException;\nimport java.util.Random;\n\nimport javax.imageio.ImageIO;\n\nimport com.chilliworks.chillisource.coreutils.CSException;\nimport com.chilliworks.chillisource.coreutils.FileUtils;\nimport com.chilliworks.chillisource.coreutils.LittleEndianWriterUtils;\nimport com.chilliworks.chillisource.coreutils.Logging;\nimport com.chilliworks.chillisource.coreutils.StringUtils;\nimport com.chilliworks.chillisource.coreutils.StringWriterUtils;\nimport com.chilliworks.chillisource.pngtocsimage.PNGToCSImage;\nimport com.chilliworks.chillisource.pngtocsimage.PNGToCSImageOptions;\nimport com.chilliworks.chillisource.texturepackerutils.PackedTexture;\n\n/**\n * A container for a series of methods used to write a CSFont to disk. This\n * includes writing the CSFont binary file and the packed glyph image as\n * a CSImage file.\n * \n * @author Ian Copland\n */\npublic final class CSFontWriter\n{\n\tprivate static final String TEMP_DIRECTORY_PATH_PREFIX = \"_temp-csfont-\";\n\tprivate static final String EXTENSION_CSFONT = \".csfont\";\n\tprivate static final String EXTENSION_CSIMAGE = \".csimage\";\n\tprivate static final int CSFONT_FILE_VERSION_NUMBER = 2;\n\t\n\t/**\n\t * Writes the CSFont binary file and the pack bitmap glyph CSImage file\n\t * to disk using the given options.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param in_outputFilePath - The file path of the output CSFont binary\n\t * file. The CSImage file will have the same path but with the csimage\n\t * extension.\n\t * @param in_options - The output options.\n\t * @param in_glyphs - The glyphs which are to be outputted.\n\t * @param in_packedBitmapFont - The packed bitmap font data.\n\t * \n\t * @throws CSException - An exception which provides a message describing \n\t * the error which has occurred.\n\t */\n\tpublic static void write(String in_outputFilePath, FontFromGlyphsBuilderOptions in_options, Glyphs in_glyphs, PackedTexture in_packedBitmapFont) throws CSException\n\t{\n\t\tif ((in_outputFilePath.toLowerCase().endsWith(EXTENSION_CSFONT) || in_outputFilePath.toLowerCase().endsWith(EXTENSION_CSFONT)) == false)\n\t\t{\n\t\t\tthrow new CSException(in_outputFilePath + \" has the wrong extension. Extension must be \" + EXTENSION_CSFONT + \" or \" + EXTENSION_CSIMAGE + \".\");\n\t\t}\n\t\t\n\t\tString randomHex = Long.toHexString(new Random().nextLong());\n\t\tString outputFileRoot = StringUtils.removeExtension(StringUtils.getFileName(in_outputFilePath));\n\t\tString outputDirectoryPath = StringUtils.getDirectory(in_outputFilePath);\n\t\tString tempDirectoryPath = outputDirectoryPath + TEMP_DIRECTORY_PATH_PREFIX + randomHex + \"/\";\n\t\tString tempPNGImageFilePath = tempDirectoryPath + outputFileRoot + \".png\";\n\t\tString tempCSImageFilePath = tempDirectoryPath + outputFileRoot + EXTENSION_CSIMAGE;\n\t\tString tempCSFontFilePath = tempDirectoryPath + outputFileRoot + EXTENSION_CSFONT;\n\t\tString outputCSImageFilePath = outputDirectoryPath + outputFileRoot + EXTENSION_CSIMAGE;\n\t\tString outputCSFontFilePath = outputDirectoryPath + outputFileRoot + EXTENSION_CSFONT;\n\t\t\n\t\tcreateTempDirectory(tempDirectoryPath);\n\t\t\n\t\ttry\n\t\t{\n\t\t\tcreateBitmapFontPNG(tempPNGImageFilePath, in_packedBitmapFont);\n\t\t\tconvertBitmapFontToCSImage(tempPNGImageFilePath, tempCSImageFilePath, in_options);\n\t\t\tcreateCSFont(tempCSFontFilePath, in_glyphs, in_packedBitmapFont);\n\t\t\tcopyToOutput(tempCSImageFilePath, tempCSFontFilePath, outputCSImageFilePath, outputCSFontFilePath);\n\t\t}\n\t\tcatch (CSException e)\n\t\t{\n\t\t\tthrow new CSException(e.getMessage(), e);\n\t\t}\n\t\tfinally\n\t\t{\n\t\t\tdeleteTempDirectory(tempDirectoryPath);\n\t\t}\n\t}\t\n\t/**\n\t * Creates the temporary directory to create the output files in.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param in_tempDirectoryPath - The temporary directory path.\n\t * \n\t * @throws CSException - An exception which provides a message \n\t * describing the error which has occurred.\n\t */\n\tprivate static void createTempDirectory(String in_tempDirectoryPath) throws CSException\n\t{\n\t\tif (new File(in_tempDirectoryPath).exists() == true)\n\t\t{\n\t\t\tthrow new CSException(\"Could not create temporary directory as it already exists: \" + in_tempDirectoryPath);\n\t\t}\n\t\t\n\t\tif (FileUtils.createDirectory(in_tempDirectoryPath) == false)\n\t\t{\n\t\t\tthrow new CSException(\"Could not create temporary directory: \" + in_tempDirectoryPath);\n\t\t}\n\t}\n\t/**\n\t * Writes the packed bitmap font image to disk as a PNG. This can later be \n\t * converted to CS Image.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param in_outputFilePath - The output file path for the PNG bitmap font image.\n\t * @param in_packedBitmapFont - The packed bitmap font data.\n\t * \n\t * @throws CSException - An exception which provides a message describing the \n\t * error which has occurred.\n\t */\n\tprivate static void createBitmapFontPNG(String in_outputFilePath, PackedTexture in_packedBitmapFont) throws CSException\n\t{\n\t\ttry\n\t\t{\n\t\t\tFile imageFile = new File(in_outputFilePath);\n\t\t\tImageIO.write(in_packedBitmapFont.getPackedTexture(), \"png\", imageFile);\n\t\t}\n\t\tcatch (Exception e)\n\t\t{\n\t\t\tLogging.logVerbose(StringUtils.convertExceptionToString(e));\n\t\t\tthrow new CSException(\"Could not create the temporary bitmap font PNG file: \" + in_outputFilePath, e);\n\t\t}\n\t}\n\t/**\n\t * Converts the packed bitmap font image from PNG format to CSImage. \n\t * \n\t * @author Ian Copland\n\t * \n\t * @param in_inputFilePath - The PNG image file path.\n\t * @param in_outputFilePath - The CSImage file path.\n\t * @param in_options - The options with which to create the CSImage file.\n\t * \n\t * @throws CSException - An exception which provides a message describing \n\t * the error which has occurred.\n\t */\n\tprivate static void convertBitmapFontToCSImage(String in_inputFilePath, String in_outputFilePath, FontFromGlyphsBuilderOptions in_options) throws CSException\n\t{\n\t\ttry\n\t\t{\n\t\t\tPNGToCSImageOptions pngToCSImageOptions = new PNGToCSImageOptions();\n\t\t\tpngToCSImageOptions.strInputFilename = in_inputFilePath;\n\t\t\tpngToCSImageOptions.strOutputFilename = in_outputFilePath;\n\t\t\t\n\t\t\tif (in_options.m_imageCompression.length() > 0)\n\t\t\t{\n\t\t\t\tpngToCSImageOptions.eCompressionType = PNGToCSImage.convertStringToCompressionFormat(in_options.m_imageCompression);\n\t\t\t}\n\t\t\t\n\t\t\tif (in_options.m_imageFormat.length() > 0)\n\t\t\t{\n\t\t\t\tpngToCSImageOptions.eConversionType = PNGToCSImage.convertStringToConversionFormat(in_options.m_imageFormat);\n\t\t\t}\n\t\t\t\n\t\t\tif (in_options.m_imageDither == true)\n\t\t\t{\n\t\t\t\tpngToCSImageOptions.bDither = true;\n\t\t\t}\n\t\t\t\n\t\t\tif (in_options.m_imagePremultiplyAlpha == false)\n\t\t\t{\n\t\t\t\tpngToCSImageOptions.bPremultiply = false;\n\t\t\t}\n\t\t\t\n\t\t\tPNGToCSImage.run(pngToCSImageOptions);\n\t\t}\n\t\tcatch (Exception e)\n\t\t{\n\t\t\tLogging.logVerbose(StringUtils.convertExceptionToString(e));\n\t\t\tthrow new CSException(\"Could not convert the temp PNG to CSImage: \" + in_outputFilePath, e);\n\t\t}\n\t}\n\t/**\n\t * Creates the CSFont binary file from the glyphs data and the packed image\n\t * data.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param in_outputFilePath - The output file path of the CSFont file.\n\t * @param in_glyphs - The input glyphs data.\n\t * @param in_packedBitmapFont - The input packed bitmap font data.\n\t * \n\t * @throws CSException - An exception which provides a message describing\n\t * the error which has occurred.\n\t */\n\tprivate static void createCSFont(String in_outputFilePath, Glyphs in_glyphs, PackedTexture in_packedBitmapFont) throws CSException\n\t{\n\t\ttry (DataOutputStream stream = new DataOutputStream(new FileOutputStream(in_outputFilePath)))\n\t\t{\n\t\t\twriteStandardHeader(stream, in_glyphs, in_packedBitmapFont);\n\t\t\twriteINFOChunk(stream, in_glyphs, in_packedBitmapFont);\n\t\t\twriteCHARChunk(stream, in_glyphs);\n\t\t\twriteGLPHChunk(stream, in_glyphs, in_packedBitmapFont);\n\t\t}\n\t\tcatch (IOException e)\n\t\t{\n\t\t\tLogging.logVerbose(StringUtils.convertExceptionToString(e));\n\t\t\tthrow new CSException(\"Could not create the CSFont file: \" + in_outputFilePath, e);\n\t\t}\n\t}\n\t/**\n\t * Writes the ChilliSource standard file header to the given stream. This\n\t * contains information such as the file Id, version number and the file chunk\n\t * table.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param in_stream - The stream to write the header to.\n\t * @param in_glyphs - The input glyphs data.\n\t * @param in_packedBitmapFont - The input packed bitmap font data.\n\t * \n\t * @throws IOException - Any exception thrown by the output stream.\n\t */\n\tprivate static void writeStandardHeader(DataOutputStream in_stream, Glyphs in_glyphs, PackedTexture in_packedBitmapFont) throws IOException\n\t{\n\t\t//write the ChilliSource Id\n\t\tStringWriterUtils.writeUTF8String(in_stream, \"CSCS\");\n\t\t\n\t\t//write the endianness check flag\n\t\tLittleEndianWriterUtils.writeInt32(in_stream, 9999);\n\t\t\t\t\n\t\t//write the file type identifier. This is 1 for CSFont files.\n\t\tLittleEndianWriterUtils.writeInt32(in_stream, 1);\n\t\t\n\t\t//write the CSFont version number.\n\t\tLittleEndianWriterUtils.writeInt32(in_stream, CSFONT_FILE_VERSION_NUMBER);\n\t\t\n\t\t//write the number of chunk table entries. This will be constant for now as there are always 3 entries: Font Info, Valid Characters and Glyph Data.\n\t\tfinal int NUM_ENTRIES = 3;\n\t\tLittleEndianWriterUtils.writeInt32(in_stream, NUM_ENTRIES);\n\t\t\n\t\t//calculate the sizes of the chunks\n\t\tfinal int GLOBAL_HEADER_SIZE = 5 * 4; //5x 4byte values\n\t\tfinal int CHUNK_TABLE_ENTRY_SIZE = 3 * 4; //3x 4byte values\n\t\tfinal int CHUNK_TABLE_SIZE = NUM_ENTRIES * CHUNK_TABLE_ENTRY_SIZE;\n\t\tfinal int INFO_CHUNK_OFFSET = GLOBAL_HEADER_SIZE + CHUNK_TABLE_SIZE;\n\t\tfinal int INFO_CHUNK_SIZE = 7 * 4; //7x 4byte values\n\t\tfinal int CHAR_CHUNK_OFFSET = GLOBAL_HEADER_SIZE + CHUNK_TABLE_SIZE + INFO_CHUNK_SIZE;\n\t\t\n\t\tint charChunkSize = calculateCHARChunkSize(in_glyphs);\n\t\tint glphChunkOffset = GLOBAL_HEADER_SIZE + CHUNK_TABLE_SIZE + INFO_CHUNK_SIZE + charChunkSize;\n\t\tint glphChunkSize = calculateGLPHChunkSize(in_packedBitmapFont);\n\t\t\n\t\t//write the INFO chunk entry.\n\t\tStringWriterUtils.writeUTF8String(in_stream, \"INFO\");\n\t\tLittleEndianWriterUtils.writeInt32(in_stream, INFO_CHUNK_OFFSET);\n\t\tLittleEndianWriterUtils.writeInt32(in_stream, INFO_CHUNK_SIZE);\n\t\t\n\t\t//write the CHAR chunk entry.\n\t\tStringWriterUtils.writeUTF8String(in_stream, \"CHAR\");\n\t\tLittleEndianWriterUtils.writeInt32(in_stream, CHAR_CHUNK_OFFSET);\n\t\tLittleEndianWriterUtils.writeInt32(in_stream, charChunkSize);\n\t\t\n\t\t//write the GLPH chunk entry.\n\t\tStringWriterUtils.writeUTF8String(in_stream, \"GLPH\");\n\t\tLittleEndianWriterUtils.writeInt32(in_stream, glphChunkOffset);\n\t\tLittleEndianWriterUtils.writeInt32(in_stream, glphChunkSize);\n\t}\n\t/**\n\t * @author Ian Copland\n\t * \n\t * @param in_glyphs- The glyphs.\n\t * \n\t * @return The size of the CHAR chunk.\n\t */\n\tprivate static int calculateCHARChunkSize(Glyphs in_glyphs)\n\t{\n\t\tString charString = new String();\n\t\t\n\t\tfor (int i = 0; i < in_glyphs.getNumGlyphs(); ++i)\n\t\t{\n\t\t\tcharString += \"\" + in_glyphs.getGlyph(i).getCharacter();\n\t\t}\n\t\t\n\t\tbyte[] charBytes = StringUtils.stringToUTF8Bytes(charString);\n\t\treturn charBytes.length;\n\t}\n\t/**\n\t * @author Ian Copland\n\t * \n\t * @return The size of the GLPH chunk.\n\t */\n\tprivate static int calculateGLPHChunkSize(PackedTexture in_packedBitmapFont)\n\t{\n\t\tfinal int GLPH_ENTRY_SIZE = 10 * 2; //10x 2byte values.\n\t\treturn in_packedBitmapFont.getNumImages() * GLPH_ENTRY_SIZE;\n\t}\n\t/**\n\t * Writes the INFO chunk to the output stream. The INFO chunk contains information\n\t * relating all glyphs such as the vertical padding, and data relating to the \n\t * original font including the point size and line height.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param in_stream - The stream to write the header to.\n\t * @param in_glyphs - The input glyphs data.\n\t * @param in_packedBitmapFont - The input packed bitmap font data.\n\t * \n\t * @throws IOException - Any exception thrown by the output stream.\n\t */\n\tprivate static void writeINFOChunk(DataOutputStream in_stream, Glyphs in_glyphs, PackedTexture in_packedBitmapFont) throws IOException\n\t{\n\t\t//write the original font information.\n\t\tLittleEndianWriterUtils.writeInt32(in_stream, in_glyphs.getFontSize());\n\t\tLittleEndianWriterUtils.writeInt32(in_stream, in_glyphs.getLineHeight());\n\t\tLittleEndianWriterUtils.writeInt32(in_stream, in_glyphs.getDescent());\n\t\tLittleEndianWriterUtils.writeInt32(in_stream, in_glyphs.getSpaceAdvance());\n\t\t\n\t\t//write info on the bitmap font image\n\t\tLittleEndianWriterUtils.writeInt32(in_stream, in_packedBitmapFont.getPackedWidth());\n\t\tLittleEndianWriterUtils.writeInt32(in_stream, in_packedBitmapFont.getPackedHeight());\n\t\tLittleEndianWriterUtils.writeInt32(in_stream, in_glyphs.getVerticalPadding());\n\t}\n\t/**\n\t * Writes the CHAR chunk to the output stream. The CHAR chunk contains the list\n\t * of valid characters in the font. Characters are written as a UTF8 string.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param in_stream - The stream to write the header to.\n\t * @param in_glyphs - The glyphs.\n\t * \n\t * @throws IOException - Any exception thrown by the output stream.\n\t */\n\tprivate static void writeCHARChunk(DataOutputStream in_stream, Glyphs in_glyphs) throws IOException\n\t{\n\t\tString charString = new String();\n\t\t\n\t\tfor (int i = 0; i < in_glyphs.getNumGlyphs(); ++i)\n\t\t{\n\t\t\tcharString += \"\" + in_glyphs.getGlyph(i).getCharacter();\n\t\t}\n\t\t\n\t\tStringWriterUtils.writeUTF8String(in_stream, charString);\n\t}\n\t/**\n\t * Writes the GLPH chunk to the output stream. The GLPH chunk contains all of the\n\t * data for each glyph.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param in_stream - The stream to write the header to.\n\t * @param in_glyphs - The glyphs.\n\t * @param in_packedBitmapFont - The input packed bitmap font data.\n\t * \n\t * @throws IOException - Any exception thrown by the output stream.\n\t */\n\tprivate static void writeGLPHChunk(DataOutputStream in_stream, Glyphs in_glyphs, PackedTexture in_packedBitmapFont) throws IOException\n\t{\n\t\tassert (in_glyphs.getNumGlyphs() == in_packedBitmapFont.getNumImages()) : \"Cannot write GLPH chunk with different amount of glyphs to packed images.\";\n\t\t\n\t\tfor (int i = 0; i < in_packedBitmapFont.getNumImages(); ++i)\n\t\t{\n\t\t\tshort imageOriginX = (short)in_packedBitmapFont.getOriginX(i);\n\t\t\tshort imageOriginY = (short)in_packedBitmapFont.getOriginY(i);\n\t\t\tshort imagePackedWidth =  (short)in_packedBitmapFont.getCroppedWidth(i);\n\t\t\tshort imagePackedHeight = (short)in_packedBitmapFont.getCroppedHeight(i);\n\t\t\tshort imagePackedOffsetX = (short)in_packedBitmapFont.getOffsetX(i);\n\t\t\tshort imagePackedOffsetY = (short)in_packedBitmapFont.getOffsetY(i);\n\t\t\tshort imageOriginalWidth = (short)in_packedBitmapFont.getOriginalWidth(i);\n\t\t\tshort imageOriginalHeight = (short)in_packedBitmapFont.getOriginalHeight(i);\n\t\t\t\n\t\t\tGlyph glyph = in_glyphs.getGlyph(i);\n\t\t\tshort glyphOrigin = (short)glyph.getOrigin();\n\t\t\tshort glyphAdvance = (short)glyph.getAdvance();\n\t\t\t\n\t\t\tLittleEndianWriterUtils.writeInt16(in_stream, imageOriginX);\n\t\t\tLittleEndianWriterUtils.writeInt16(in_stream, imageOriginY);\n\t\t\tLittleEndianWriterUtils.writeInt16(in_stream, imagePackedWidth);\n\t\t\tLittleEndianWriterUtils.writeInt16(in_stream, imagePackedHeight);\n\t\t\tLittleEndianWriterUtils.writeInt16(in_stream, imagePackedOffsetX);\n\t\t\tLittleEndianWriterUtils.writeInt16(in_stream, imagePackedOffsetY);\n\t\t\tLittleEndianWriterUtils.writeInt16(in_stream, imageOriginalWidth);\n\t\t\tLittleEndianWriterUtils.writeInt16(in_stream, imageOriginalHeight);\n\t\t\tLittleEndianWriterUtils.writeInt16(in_stream, glyphOrigin);\n\t\t\tLittleEndianWriterUtils.writeInt16(in_stream, glyphAdvance);\n\t\t}\n\t}\n\t/**\n\t * Copies the output files from the temp directory to the output.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param in_sourceCSImageFilePath - The source CSImage file path.\n\t * @param in_sourceCSFontFilePath - The source CSFont file path.\n\t * @param in_destCSImageFilePath - The destination CSImage file path.\n\t * @param in_destCSFontFilePath - The destination CSFont file path.\n\t * \n\t * @throws CSException - An exception which provides a message \n\t * describing the error which has occurred.\n\t */\n\tprivate static void copyToOutput(String in_sourceCSImageFilePath, String in_sourceCSFontFilePath, String in_destCSImageFilePath, String in_destCSFontFilePath) throws CSException\n\t{\n\t\tif (FileUtils.copyFile(in_sourceCSImageFilePath, in_destCSImageFilePath) == false)\n\t\t{\n\t\t\tthrow new CSException(\"Could not copy to output directory: \" + in_destCSImageFilePath);\n\t\t}\n\t\t\n\t\tif (FileUtils.copyFile(in_sourceCSFontFilePath, in_destCSFontFilePath) == false)\n\t\t{\n\t\t\tthrow new CSException(\"Could not copy to output directory: \" + in_destCSFontFilePath);\n\t\t}\n\t}\n\t/**\n\t * Deletes the temporary directory and its contents.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param in_tempDirectoryPath - The temporary directory path.\n\t * \n\t * @throws CSException - An exception which provides a message \n\t * describing the error which has occurred.\n\t */\n\tprivate static void deleteTempDirectory(String in_tempDirectoryPath) throws CSException\n\t{\n\t\tif (FileUtils.deleteDirectory(in_tempDirectoryPath) == false)\n\t\t{\n\t\t\tthrow new CSException(\"Could not delete temporary directory: \" + in_tempDirectoryPath);\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/CSFontBuilder/src/com/chilliworks/chillisource/csfontbuilder/fontfromglyphsbuilder/FontFromGlyphsBuilder.java",
    "content": "/**\n * FontFromGlyphsBuilder.java\n * ChilliSource\n * Created by Ian Copland on 09/10/2014.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2014 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.csfontbuilder.fontfromglyphsbuilder;\n\nimport java.io.File;\nimport java.util.ArrayList;\n\nimport com.chilliworks.chillisource.coreutils.CSException;\nimport com.chilliworks.chillisource.coreutils.Logging;\nimport com.chilliworks.chillisource.coreutils.StringUtils;\nimport com.chilliworks.chillisource.texturepackerutils.PackedTexture;\nimport com.chilliworks.chillisource.texturepackerutils.TexturePacker;\n \n/**\n * A static class that provides methods for building a CSFont bitmap font\n * from a collection of bitmap glyphs and an optional kerning info file.\n * \n * @author Ian Copland\n */\npublic final class FontFromGlyphsBuilder\n{\n\t/**\n\t * Builds a CSFont bitmap font from a series of bitmap glyphs with the \n\t * given options.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param in_inputDirectoryPath - The input directory path containing the\n\t * glyphs.\n\t * @param in_outputFilePath - The output file path for the CSFont file.\n\t * @param in_options - The builder options.\n\t * \n\t * @throws CSException - An exception which provides a message describing \n\t * the error which has occurred.\n\t */\n\tpublic static void build(String in_inputDirectoryPath, String in_outputFilePath, FontFromGlyphsBuilderOptions in_options) throws CSException\n\t{\n\t\tGlyphs glyphs = GlyphsReader.read(in_inputDirectoryPath);\n\t\tPackedTexture packedBitmapFont = packBitmapFont(in_options, glyphs);\n\t\tCSFontWriter.write(in_outputFilePath, in_options, glyphs, packedBitmapFont);\n\t}\n\t/**\n\t * Uses the texture package to pack all gylphs into a single image. This takes into account\n\t * the options provided to the tool for things like the size of the image and the packing\n\t * heuristic.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param in_options - The options which should be used to generate the packed bitmap.\n\t * @param in_glyphs - The glyphs which should be packed.\n\t * \n\t * @return The packaged texture. This will never be null.\n\t * \n\t * @throws CSException - An exception which provides a message describing the error which\n\t * has occurred.\n\t */\n\tprivate static PackedTexture packBitmapFont(FontFromGlyphsBuilderOptions in_options, Glyphs in_glyphs) throws CSException\n\t{\n\t\ttry\n\t\t{\n\t\t\tfinal int PADDING = 2;\n\t\t\t\n\t\t\tArrayList<File> filesToProcess = new ArrayList<File>();\n\t\t\tfor (int i = 0; i < in_glyphs.getNumGlyphs(); ++i)\n\t\t\t{\n\t\t\t\tGlyph glyph = in_glyphs.getGlyph(i);\n\t\t\t\tfilesToProcess.add(new File(glyph.getFilePath()));\n\t\t\t}\n\t\n\t\t\tTexturePacker packer = new TexturePacker();\n\t\t\tpacker.setDivisibleBy(in_options.m_divisibleBy);\n\t\t\tpacker.setExtrusion(0);\n\t\t\tpacker.setFixedHeight(in_options.m_fixedHeight);\n\t\t\tpacker.setFixedWidth(in_options.m_fixedWidth);\n\t\t\tpacker.setMaxHeight(in_options.m_maxHeight);\n\t\t\tpacker.setMaxWidth(in_options.m_maxWidth);\n\t\t\tpacker.setValidHeights(in_options.m_validHeights);\n\t\t\tpacker.setValidWidths(in_options.m_validWidths);\n\t\t\tpacker.setHeuristic(in_options.m_packingHeuristic);\n\t\t\tpacker.setInnerPadding(0);\n\t\t\tpacker.setOuterPadding(PADDING);\n\t\t\tpacker.enableCropping(true);\n\t\t\treturn packer.pack(filesToProcess, null);\n\t\t}\n\t\tcatch (Exception e)\n\t\t{\n\t\t\tLogging.logVerbose(StringUtils.convertExceptionToString(e));\n\t\t\tthrow new CSException(\"Could not pack bitmap font.\", e);\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/CSFontBuilder/src/com/chilliworks/chillisource/csfontbuilder/fontfromglyphsbuilder/FontFromGlyphsBuilderOptions.java",
    "content": "/**\n * FontFromGlyphsBuilderOptions.java\n * ChilliSource\n * Created by Ian Copland on 09/10/2014.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2014 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.csfontbuilder.fontfromglyphsbuilder;\n\nimport com.chilliworks.chillisource.texturepackerutils.TexturePacker.PlacementHeuristic;\n\n/**\n * A container for the input options for the Font From Glyphs Builder.\n *  \n * @author Ian Copland\n */\npublic final class FontFromGlyphsBuilderOptions\n{\n\tpublic int m_fixedWidth = -1;\n\tpublic int m_fixedHeight = -1;\n\tpublic int[] m_validHeights = new int[0];\n\tpublic int[] m_validWidths = new int[0];\n\tpublic int m_maxWidth = 2048;\n\tpublic int m_maxHeight = 2048;\n\tpublic int m_divisibleBy = 4;\n\tpublic PlacementHeuristic m_packingHeuristic = PlacementHeuristic.BOTTOMRIGHT;\n\tpublic String m_imageCompression = \"\";\n\tpublic String m_imageFormat = \"\";\n\tpublic boolean m_imageDither = false;\n\tpublic boolean m_imagePremultiplyAlpha = true;\n}\n"
  },
  {
    "path": "Projects/Tools/CSFontBuilder/src/com/chilliworks/chillisource/csfontbuilder/fontfromglyphsbuilder/FontFromGlyphsBuilderOptionsParser.java",
    "content": "/**\n * FontFromGlyphsBuilderOptionsParser.java\n * ChilliSource\n * Created by Ian Copland on 22/10/2014.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2014 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.csfontbuilder.fontfromglyphsbuilder;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\nimport com.chilliworks.chillisource.coreutils.Logging;\nimport com.chilliworks.chillisource.coreutils.StringUtils;\nimport com.chilliworks.chillisource.texturepackerutils.TexturePacker.PlacementHeuristic;\n\n/**\n * A container for methods relating to parsing font from glyphs builder \n * options.\n * \n * @author Ian Copland\n */\npublic final class FontFromGlyphsBuilderOptionsParser\n{\n\tpublic static final String PARAM_FIXED_WIDTH = \"--fixedwidth\";\n\tpublic static final String PARAM_FIXED_HEIGHT = \"--fixedheight\";\n\tpublic static final String PARAM_VALID_WIDTHS = \"--validwidths\";\n\tpublic static final String PARAM_VALID_HEIGHTS = \"--validheights\";\n\tpublic static final String PARAM_MAX_WIDTH = \"--maxwidth\";\n\tpublic static final String PARAM_MAX_HEIGHT = \"--maxheight\";\n\tpublic static final String PARAM_DIVISIBLE_BY = \"--divisibleby\";\n\tpublic static final String PARAM_PLACEMENT_HEURISTIC = \"--placementheuristic\";\n\tpublic static final String PARAM_IMAGE_COMPRESSION = \"--imagecompression\";\n\tpublic static final String PARAM_IMAGE_FORMAT = \"--imageformat\";\n\tpublic static final String PARAM_DITHER_IMAGE = \"--ditherimage\";\n\tpublic static final String PARAM_DISABLE_PREMULTIPLIED_ALPHA = \"--disablepremultipliedalpha\";\n\t\n\tpublic static final String SHORT_PARAM_FIXED_WIDTH = \"-fw\";\n\tpublic static final String SHORT_PARAM_FIXED_HEIGHT = \"-fh\";\n\tpublic static final String SHORT_PARAM_VALID_WIDTHS = \"-vw\";\n\tpublic static final String SHORT_PARAM_VALID_HEIGHTS = \"-vh\";\n\tpublic static final String SHORT_PARAM_MAX_WIDTH = \"-mw\";\n\tpublic static final String SHORT_PARAM_MAX_HEIGHT = \"-mh\";\n\tpublic static final String SHORT_PARAM_DIVISIBLE_BY = \"-db\";\n\tpublic static final String SHORT_PARAM_PLACEMENT_HEURISTIC = \"-ph\";\n\tpublic static final String SHORT_PARAM_IMAGE_COMPRESSION = \"-ic\";\n\tpublic static final String SHORT_PARAM_IMAGE_FORMAT = \"-if\";\n\tpublic static final String SHORT_PARAM_DITHER_IMAGE = \"-di\";\n\tpublic static final String SHORT_PARAM_DISABLE_PREMULTIPLIED_ALPHA = \"-dpa\";\n\t\n\tpublic static final String PLACEMENT_HEURISTIC_TOP_LEFT = \"topleft\";\n\tpublic static final String PLACEMENT_HEURISTIC_BOTTOM_RIGHT = \"bottomright\";\n\t\n\t/**\n\t * Processes all font from glyph mode options.\n\t *\n\t * @author Ian Copland\n\t * \n\t * @param in_arguments - The arguments for Font From Glyph mode. \n\t * @param out_options - The output options.\n\t * \n\t * @return The list of unused arguments.\n\t */\n\tpublic static String[] parse(String[] in_arguments, FontFromGlyphsBuilderOptions out_options)\n\t{\n\t\tassert (in_arguments != null) : \"Arguments cannot be null\";\n\t\tassert (out_options != null) : \"Output options cannot be null\";\n\t\t\n\t\tList<String> unusedArguments = new ArrayList<>();\n\t\t\n\t\tfor (int i = 0; i < in_arguments.length; ++i)\n\t\t{\t\t\t\n\t\t\t//fixed width\n\t\t\tif (in_arguments[i].equalsIgnoreCase(PARAM_FIXED_WIDTH) == true || in_arguments[i].equalsIgnoreCase(SHORT_PARAM_FIXED_WIDTH) == true)\n\t\t\t{\n\t\t\t\tif (i+1 < in_arguments.length)\n\t\t\t\t\tout_options.m_fixedWidth = Integer.parseInt(in_arguments[i+1]);\n\t\t\t\telse\n\t\t\t\t\tLogging.logFatal(\"No fixed width provided!\");\n\t\t\t\t++i;\n\t\t\t}\n\t\t\t\n\t\t\t//fixed height\n\t\t\telse if (in_arguments[i].equalsIgnoreCase(PARAM_FIXED_HEIGHT) == true || in_arguments[i].equalsIgnoreCase(SHORT_PARAM_FIXED_HEIGHT) == true)\n\t\t\t{\n\t\t\t\tif (i+1 < in_arguments.length)\n\t\t\t\t\tout_options.m_fixedHeight = Integer.parseInt(in_arguments[i+1]);\n\t\t\t\telse\n\t\t\t\t\tLogging.logFatal(\"No fixed height provided!\");\n\t\t\t\t++i;\n\t\t\t}\n\t\t\t\n\t\t\t//valid widths\n\t\t\telse if (in_arguments[i].equalsIgnoreCase(PARAM_VALID_WIDTHS) == true || in_arguments[i].equalsIgnoreCase(SHORT_PARAM_VALID_WIDTHS) == true)\n\t\t\t{\n\t\t\t\tif (i+1 < in_arguments.length)\n\t\t\t\t\tout_options.m_validWidths = parseIntegerArray(in_arguments[i+1]);\n\t\t\t\telse\n\t\t\t\t\tLogging.logFatal(\"No valid widths provided!\");\n\t\t\t\t++i;\n\t\t\t}\n\t\t\t\n\t\t\t//valid heights\n\t\t\telse if (in_arguments[i].equalsIgnoreCase(PARAM_VALID_HEIGHTS) == true || in_arguments[i].equalsIgnoreCase(SHORT_PARAM_VALID_HEIGHTS) == true)\n\t\t\t{\n\t\t\t\tif (i+1 < in_arguments.length)\n\t\t\t\t\tout_options.m_validHeights = parseIntegerArray(in_arguments[i+1]);\n\t\t\t\telse\n\t\t\t\t\tLogging.logFatal(\"No valid heights provided!\");\n\t\t\t\t++i;\n\t\t\t}\n\t\t\t\n\t\t\t//max width\n\t\t\telse if (in_arguments[i].equalsIgnoreCase(PARAM_MAX_WIDTH) == true || in_arguments[i].equalsIgnoreCase(SHORT_PARAM_MAX_WIDTH) == true)\n\t\t\t{\n\t\t\t\tif (i+1 < in_arguments.length)\n\t\t\t\t\tout_options.m_maxWidth = Integer.parseInt(in_arguments[i+1]);\n\t\t\t\telse\n\t\t\t\t\tLogging.logFatal(\"No max width provided!\");\n\t\t\t\t++i;\n\t\t\t}\n\t\t\t\n\t\t\t//max height\n\t\t\telse if (in_arguments[i].equalsIgnoreCase(PARAM_MAX_HEIGHT) == true || in_arguments[i].equalsIgnoreCase(SHORT_PARAM_MAX_HEIGHT) == true)\n\t\t\t{\n\t\t\t\tif (i+1 < in_arguments.length)\n\t\t\t\t\tout_options.m_maxHeight = Integer.parseInt(in_arguments[i+1]);\n\t\t\t\telse\n\t\t\t\t\tLogging.logFatal(\"No max height provided!\");\n\t\t\t\t++i;\n\t\t\t}\n\t\t\t\n\t\t\t//divisible by\n\t\t\telse if (in_arguments[i].equalsIgnoreCase(PARAM_DIVISIBLE_BY) == true || in_arguments[i].equalsIgnoreCase(SHORT_PARAM_DIVISIBLE_BY) == true)\n\t\t\t{\n\t\t\t\tif (i+1 < in_arguments.length)\n\t\t\t\t\tout_options.m_divisibleBy = Integer.parseInt(in_arguments[i+1]);\n\t\t\t\telse\n\t\t\t\t\tLogging.logFatal(\"No divisible by value provided!\");\n\t\t\t\t++i;\n\t\t\t}\n\t\t\t\n\t\t\t//packing heuristic\n\t\t\telse if (in_arguments[i].equalsIgnoreCase(PARAM_PLACEMENT_HEURISTIC) == true || in_arguments[i].equalsIgnoreCase(SHORT_PARAM_PLACEMENT_HEURISTIC) == true)\n\t\t\t{\n\t\t\t\tif (i+1 < in_arguments.length)\n\t\t\t\t\tout_options.m_packingHeuristic = parsePlacementHeuristic(in_arguments[i+1]);\n\t\t\t\telse\n\t\t\t\t\tLogging.logFatal(\"No placement heuristic provided!\");\n\t\t\t\t++i;\n\t\t\t}\n\t\t\t\n\t\t\t//image compression\n\t\t\telse if (in_arguments[i].equalsIgnoreCase(PARAM_IMAGE_COMPRESSION) == true || in_arguments[i].equalsIgnoreCase(SHORT_PARAM_IMAGE_COMPRESSION) == true)\n\t\t\t{\n\t\t\t\tif (i+1 < in_arguments.length)\n\t\t\t\t\tout_options.m_imageCompression = in_arguments[i+1];\n\t\t\t\telse\n\t\t\t\t\tLogging.logFatal(\"No image compression provided!\");\n\t\t\t\t++i;\n\t\t\t}\n\t\t\t\n\t\t\t//image format\n\t\t\telse if (in_arguments[i].equalsIgnoreCase(PARAM_IMAGE_FORMAT) == true || in_arguments[i].equalsIgnoreCase(SHORT_PARAM_IMAGE_FORMAT) == true)\n\t\t\t{\n\t\t\t\tif (i+1 < in_arguments.length)\n\t\t\t\t\tout_options.m_imageFormat = in_arguments[i+1];\n\t\t\t\telse\n\t\t\t\t\tLogging.logFatal(\"No image format provided!\");\n\t\t\t\t++i;\n\t\t\t}\n\t\t\t\n\t\t\t//image dither\n\t\t\telse if (in_arguments[i].equalsIgnoreCase(PARAM_DITHER_IMAGE) == true || in_arguments[i].equalsIgnoreCase(SHORT_PARAM_DITHER_IMAGE) == true)\n\t\t\t{\n\t\t\t\tout_options.m_imageDither = true;\n\t\t\t}\n\t\t\t\n\t\t\t//image premultiply alpha\n\t\t\telse if (in_arguments[i].equalsIgnoreCase(PARAM_DISABLE_PREMULTIPLIED_ALPHA) == true || in_arguments[i].equalsIgnoreCase(SHORT_PARAM_DISABLE_PREMULTIPLIED_ALPHA) == true)\n\t\t\t{\n\t\t\t\tout_options.m_imagePremultiplyAlpha = false;\n\t\t\t}\n\t\t\t\n\t\t\t//otherwise add to the unused arg list\n\t\t\telse\n\t\t\t{\n\t\t\t\tunusedArguments.add(in_arguments[i]);\n\t\t\t}\n\t\t}\n\t\t\n\t\treturn unusedArguments.toArray(new String[0]);\n\t}\n\t/**\n\t * Parses a comma separated list of integers into an array.\n\t *\n\t * @author Ian Copland\n\t * \n\t * @param A string containing a comma separated list of\n\t * integers.\n\t * \n\t * @return An array containing the list of integers.\n\t */\n\tprivate static int[] parseIntegerArray(String in_commaSeparatedList)\n\t{\n\t\tint[] integers = null;\n\t\t\n\t\ttry\n\t\t{\n\t\t\tString[] stringIntegers = in_commaSeparatedList.split(\",\");\n\t\t\tintegers = new int[stringIntegers.length];\n\t\t\tfor (int i = 0; i < stringIntegers.length; ++i)\n\t\t\t{\n\t\t\t\tintegers[i] = Integer.parseInt(stringIntegers[i]);\n\t\t\t}\n\t\t}\n\t\tcatch (Exception e)\n\t\t{\n\t\t\tLogging.logFatal(StringUtils.convertExceptionToString(e));\n\t\t}\n\t\t\n\t\treturn integers;\n\t}\n\t/**\n\t * Parses the placement heuristic.\n\t *\n\t * @author Ian Copland\n\t * \n\t * @param placement heuristic as a string.\n\t * \n\t * @return The heuristic.\n\t */\n\tprivate static PlacementHeuristic parsePlacementHeuristic(String in_packingHeuristic)\n\t{\n\t\tif (in_packingHeuristic.equalsIgnoreCase(PLACEMENT_HEURISTIC_TOP_LEFT) == true)\n\t\t{\n\t\t\treturn PlacementHeuristic.TOPLEFT;\n\t\t}\n\t\telse if (in_packingHeuristic.equalsIgnoreCase(PLACEMENT_HEURISTIC_BOTTOM_RIGHT) == true)\n\t\t{\n\t\t\treturn PlacementHeuristic.BOTTOMRIGHT;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tLogging.logFatal(\"Invalid packing heuristic: \" + in_packingHeuristic);\n\t\t\treturn PlacementHeuristic.TOPLEFT;\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/CSFontBuilder/src/com/chilliworks/chillisource/csfontbuilder/fontfromglyphsbuilder/Glyph.java",
    "content": "/**\n * GlyphInfo.java\n * ChilliSource\n * Created by Ian Copland on 22/10/2014.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2014 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.csfontbuilder.fontfromglyphsbuilder;\n\n/**\n * A simple container for information on a single glyph.\n * \n * @author Ian Copland\n */\npublic final class Glyph\n{\n\tprivate final char m_character;\n\tprivate final String m_filePath;\n\tprivate final int m_origin;\n\tprivate final int m_advance;\n\t\n\t/**\n\t * Constructor.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param in_character - The character the glyph represents.\n\t * @param in_filePath - The file path to the bitmap glyph image.\n\t * @param in_origin - The x position of the glyphs origin in the image.\n\t * @param in_advance - The x advance from the origin that the next glyph\n\t * should be rendered at.\n\t * @param in_glyphSize - The glyph size.\n\t */\n\tpublic Glyph(char in_character, String in_filePath, int in_origin, int in_advance)\n\t{\n\t\tm_character = in_character;\n\t\tm_filePath = in_filePath;\n\t\tm_origin = in_origin;\n\t\tm_advance = in_advance;\n\t}\n\t/**\n\t * @author Ian Copland\n\t * \n\t * @return The character the glyph represents.\n\t */\n\tpublic char getCharacter()\n\t{\n\t\treturn m_character;\n\t}\n\t/**\n\t * @author Ian Copland\n\t * \n\t * @return The path to the bitmap glyph image.\n\t */\n\tpublic String getFilePath()\n\t{\n\t\treturn m_filePath;\n\t}\n\t/**\n\t * @author Ian Copland\n\t * \n\t * @return The x position of the glyphs origin in the image.\n\t */\n\tpublic int getOrigin()\n\t{\n\t\treturn m_origin;\n\t}\n\t/**\n\t * @author Ian Copland\n\t * \n\t * @return The x advance from the origin that the next glyph\n\t * should be rendered at.\n\t */\n\tpublic int getAdvance()\n\t{\n\t\treturn m_advance;\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/CSFontBuilder/src/com/chilliworks/chillisource/csfontbuilder/fontfromglyphsbuilder/Glyphs.java",
    "content": "/**\n * Glyphs.java\n * ChilliSource\n * Created by Ian Copland on 21/10/2014.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2014 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.csfontbuilder.fontfromglyphsbuilder;\n\n/**\n * A container for the glyphs that will used to generated a bitmap font.\n * \n * @author Ian Copland\n */\npublic final class Glyphs\n{\n\tprivate final Glyph[] m_glyphs;\n\tprivate final int m_fontSize;\n\tprivate final int m_lineHeight;\n\tprivate final int m_descent;\n\tprivate final int m_spaceAdvance;\n\tprivate final int m_verticalPadding;\n\t\n\t/**\n\t * Constructor. \n\t * \n\t * @author Ian Copland\n\t * \n\t * @param in_glyphs - The glyphs.\n\t * @param in_fontSize - The point size of the font the glyphs were created from.\n\t * @param in_lineHeight - The total height of a line of text.\n\t * @param in_descent - The amount of space under the baseline in a line of text.\n\t * @param in_spaceAdvance - The advance for a space character.\n\t * @param in_verticalPadding - The amount of padding at the top and bottom of a\n\t * glyph.\n\t */\n\tpublic Glyphs(Glyph[] in_glyphs, int in_fontSize, int in_lineHeight, int in_descent, int in_spaceAdvance, int in_verticalPadding)\n\t{\n\t\tm_glyphs = in_glyphs;\n\t\tm_fontSize = in_fontSize;\n\t\tm_lineHeight = in_lineHeight;\n\t\tm_descent = in_descent;\n\t\tm_spaceAdvance = in_spaceAdvance;\n\t\tm_verticalPadding = in_verticalPadding;\n\t}\n\t/**\n\t * @author Ian Copland\n\t * \n\t * @return The number of glyphs.\n\t */\n\tpublic int getNumGlyphs()\n\t{\n\t\treturn m_glyphs.length;\n\t}\n\t/**\n\t * @author Ian Copland\n\t * \n\t * @return The glyph at the given index.\n\t */\n\tpublic Glyph getGlyph(int in_index)\n\t{\n\t\tassert (in_index >= 0 && in_index < m_glyphs.length) : \"Glyph index out of range.\";\n\t\t\n\t\treturn m_glyphs[in_index];\n\t}\n\t/**\n\t * @author Ian Copland\n\t * \n\t * @return The point size of the font the glyphs were created from.\n\t */\n\tpublic int getFontSize()\n\t{\n\t\treturn m_fontSize;\n\t}\n\t/**\n\t * @author Ian Copland\n\t * \n\t * @return The total height of a line of text.\n\t */\n\tpublic int getLineHeight()\n\t{\n\t\treturn m_lineHeight;\n\t}\n\t/**\n\t * @author Ian Copland\n\t * \n\t * @return The amount of space under the baseline in a line of text.\n\t */\n\tpublic int getDescent()\n\t{\n\t\treturn m_descent;\n\t}\n\t/**\n\t * @author Ian Copland\n\t * \n\t * @return The advance for a space character.\n\t */\n\tpublic int getSpaceAdvance()\n\t{\n\t\treturn m_spaceAdvance;\n\t}\n\t/**\n\t * @author Ian Copland\n\t * \n\t * @return The amount of padding at the top and bottom of a glyph.\n\t */\n\tpublic int getVerticalPadding()\n\t{\n\t\treturn m_verticalPadding;\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/CSFontBuilder/src/com/chilliworks/chillisource/csfontbuilder/fontfromglyphsbuilder/GlyphsReader.java",
    "content": "/**\n * GlyphsReader.java\n * ChilliSource\n * Created by Ian Copland on 21/10/2014.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2014 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.csfontbuilder.fontfromglyphsbuilder;\n\nimport java.io.File;\nimport java.util.ArrayList;\nimport java.util.List;\n\nimport org.json.JSONObject;\n\nimport com.chilliworks.chillisource.coreutils.CSException;\nimport com.chilliworks.chillisource.coreutils.FileUtils;\nimport com.chilliworks.chillisource.coreutils.Logging;\nimport com.chilliworks.chillisource.coreutils.StringUtils;\n\n/**\n * Provides a series of methods for reading bitmap font glyphs to file.\n * \n * @author Ian Copland\n */\npublic final class GlyphsReader\n{\n\tprivate static final String FONT_INFO_FILE_PATH = \"FontInfo.csfontinfo\";\n\t\n\t/**\n\t * Reads bitmap glyph files and the Font Info file from the given \n\t * directory. \n\t * \n\t * @author Ian Copland\n\t * \n\t * @param in_inputDirectoryPath - The input directory containing the\n\t * bitmap glyphs and font info file.\n\t * \n\t * @return The glyphs container. This will never be null.\n\t * \n\t * @throws CSException - An exception which provides a message describing\n\t * the error which has occurred.\n\t */\n\tpublic static Glyphs read(String in_inputDirectoryPath) throws CSException\n\t{\n\t\tString[] glyphFilePaths = findImageFilesInDirectory(in_inputDirectoryPath);\n\t\tchar[] glyphCharacters = getCharacterForFilePaths(glyphFilePaths);\n\t\treturn buildGlyphs(glyphCharacters, glyphFilePaths, in_inputDirectoryPath);\n\t}\n\t/**\n\t * Retrieves the path to all files in the given directory.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param in_directoryPath - The directory to search for images in.\n\t * \n\t * @return The array of file paths. The path will include the input\n\t * directory path. This will never be null.\n\t * \n\t * @throws CSException - An exception which provides a message describing\n\t * the error which has occurred.\n\t */\n\tprivate static String[] findImageFilesInDirectory(String in_directoryPath) throws CSException\n\t{\n\t\tFile directory = new File(in_directoryPath);\n\t\tif (directory.exists() == false)\n\t\t{\n\t\t\tthrow new CSException(\"Glyphs directory doesn't exist: \" + in_directoryPath);\n\t\t}\n\t\t\n\t\tList<String> imageFilePaths = new ArrayList<>();\n\t\t\n\t\tString[] contents = directory.list();\n\t\tfor (String itemPath : contents)\n\t\t{\n\t\t\tFile item = new File(directory, itemPath);\n\t\t\tif (item.isFile() == true && itemPath.toLowerCase().endsWith(\".png\") == true)\n\t\t\t{\n\t\t\t\timageFilePaths.add(item.getPath());\n\t\t\t}\n\t\t}\n\t\t\n\t\treturn imageFilePaths.toArray(new String[0]);\n\t}\n\t/**\n\t * Gets the character each image at the given file paths represents. This\n\t * is parsed from the image file names, which is the unicode for the\n\t * character.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param in_glyphFilePaths - The file paths of all the glyph images.\n\t * \n\t * @return The array of characters. This will never be null.\n\t */\n\tprivate static char[] getCharacterForFilePaths(String[] in_glyphFilePaths)\n\t{\n\t\tchar[] characters = new char[in_glyphFilePaths.length];\n\t\t\n\t\tfor (int i = 0; i < in_glyphFilePaths.length; ++i)\n\t\t{\n\t\t\tString glyphFilePath = in_glyphFilePaths[i];\n\t\t\tString glyphFileName = StringUtils.getFileName(glyphFilePath);\n\t\t\tString glyphFileRoot = StringUtils.removeExtension(glyphFileName);\n\t\t\tcharacters[i] = (char) Integer.parseInt(glyphFileRoot, 16);\n\t\t}\n\t\t\n\t\treturn characters;\n\t}\n\t/**\n\t * Builds the glyphs from the given data and the contents of the Font\n\t * Info file in the given directory.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param in_characters - The list of glyph characters.\n\t * @param in_filePaths - The list of glyph bitmap image file paths.\n\t * @param in_inputDirectoryPath - The directory path that contains the \n\t * font info file.\n\t * \n\t * @return A 4-tuple containing the font size, line height, descent and\n\t * effect padding of the font. This will never be null.\n\t * \n\t * @throws CSException - An exception which provides a message describing\n\t * the error which has occurred.\n\t */\n\tprivate static Glyphs buildGlyphs(char[] in_characters, String[] in_filePaths, String in_inputDirectoryPath) throws CSException\n\t{\n\t\tassert (in_characters.length == in_filePaths.length) : \"Cannot build glyphs with different sized character and file path arrays.\";\n\t\t\n\t\tString filePath = in_inputDirectoryPath + FONT_INFO_FILE_PATH;\n\t\t\n\t\ttry\n\t\t{\n\t\t\tString fileContents = FileUtils.readFile(filePath);\n\t\t\tif (fileContents.length() == 0)\n\t\t\t{\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\t\n\t\t\tJSONObject jsonRoot = new JSONObject(fileContents);\n\t\t\tint fontSize = jsonRoot.getInt(\"FontSize\");\n\t\t\tint lineHeight = jsonRoot.getInt(\"LineHeight\");\n\t\t\tint descent = jsonRoot.getInt(\"Descent\");\n\t\t\tint spaceAdvance = jsonRoot.getInt(\"SpaceAdvance\");\n\t\t\tint verticalPadding = jsonRoot.getInt(\"VerticalPadding\");\n\t\t\t\n\t\t\tJSONObject jsonGlyphs = jsonRoot.getJSONObject(\"Glyphs\");\n\t\t\tGlyph[] glyphs = new Glyph[in_characters.length];\n\t\t\tfor (int i = 0; i < in_characters.length; ++i)\n\t\t\t{\n\t\t\t\tchar character = in_characters[i];\n\t\t\t\tJSONObject jsonGlyph = jsonGlyphs.getJSONObject(\"\" + character);\n\t\t\t\t\n\t\t\t\tint origin = jsonGlyph.getInt(\"Origin\");\n\t\t\t\tint advance = jsonGlyph.getInt(\"Advance\");\n\t\t\t\t\n\t\t\t\tglyphs[i] = new Glyph(character, in_filePaths[i], origin, advance);\n\t\t\t}\n\t\t\t\n\t\t\treturn new Glyphs(glyphs, fontSize, lineHeight, descent, spaceAdvance, verticalPadding);\n\t\t}\n\t\tcatch (Exception e)\n\t\t{\n\t\t\tLogging.logVerbose(StringUtils.convertExceptionToString(e));\n\t\t\tthrow new CSException(\"Could not read the font info file: \" + filePath, e);\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/CSFontBuilder/src/com/chilliworks/chillisource/csfontbuilder/glyphsbuilder/Glyph.java",
    "content": "/**\n * GlyphInfo.java\n * ChilliSource\n * Created by Ian Copland on 22/10/2014.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2014 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.csfontbuilder.glyphsbuilder;\n\nimport java.awt.image.BufferedImage;\n\n/**\n * A simple container for information on a single glyph.\n * \n * @author Ian Copland\n */\npublic final class Glyph\n{\n\tprivate final char m_character;\n\tprivate final BufferedImage m_image;\n\tprivate final int m_origin;\n\tprivate final int m_advance;\n\t\n\t/**\n\t * Constructor.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param in_character - The character the glyph represents.\n\t * @param in_image - The bitmap image for the glyph.\n\t * @param in_origin - The x position of the glyphs origin in the image.\n\t * @param in_advance - The x advance from the origin that the next glyph\n\t * should be rendered at.\n\t * @param in_glyphSize - The glyph size.\n\t */\n\tpublic Glyph(char in_character, BufferedImage in_image, int in_origin, int in_advance)\n\t{\n\t\tm_character = in_character;\n\t\tm_image = in_image;\n\t\tm_origin = in_origin;\n\t\tm_advance = in_advance;\n\t}\n\t/**\n\t * @author Ian Copland\n\t * \n\t * @return The character the glyph represents.\n\t */\n\tpublic char getCharacter()\n\t{\n\t\treturn m_character;\n\t}\n\t/**\n\t * @author Ian Copland\n\t * \n\t * @return The bitmap image for the glyph.\n\t */\n\tpublic BufferedImage getImage()\n\t{\n\t\treturn m_image;\n\t}\n\t/**\n\t * @author Ian Copland\n\t * \n\t * @return The x position of the glyphs origin in the image.\n\t */\n\tpublic int getOrigin()\n\t{\n\t\treturn m_origin;\n\t}\n\t/**\n\t * @author Ian Copland\n\t * \n\t * @return The x advance from the origin that the next glyph\n\t * should be rendered at.\n\t */\n\tpublic int getAdvance()\n\t{\n\t\treturn m_advance;\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/CSFontBuilder/src/com/chilliworks/chillisource/csfontbuilder/glyphsbuilder/Glyphs.java",
    "content": "/**\n * Glyphs.java\n * ChilliSource\n * Created by Ian Copland on 22/10/2014.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2014 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.csfontbuilder.glyphsbuilder;\n\n/**\n * A container for information on a collection of glyphs. This is immutable after\n * construction.\n * \n * @author Ian Copland\n */\npublic final class Glyphs\n{\n\tprivate final Glyph[] m_glyphs;\n\tprivate final int m_fontSize;\n\tprivate final int m_lineHeight;\n\tprivate final int m_descent;\n\tprivate final int m_spaceAdvance;\n\tprivate final int m_verticalPadding;\n\t\n\t/**\n\t * Constructor. \n\t * \n\t * @author Ian Copland\n\t * \n\t * @param in_glyphs - The glyphs.\n\t * @param in_fontSize - The point size of the font the glyphs were created from.\n\t * @param in_lineHeight - The total height of a line of text.\n\t * @param in_descent - The amount of space under the baseline in a line of text.\n\t * @param in_spaceAdvance - The advance for a space character.\n\t * @param in_verticalPadding - The amount of padding at the top and bottom of a\n\t * glyph.\n\t */\n\tpublic Glyphs(Glyph[] in_glyphs, int in_fontSize, int in_lineHeight, int in_descent, int in_spaceAdvance, int in_verticalPadding)\n\t{\n\t\tm_glyphs = in_glyphs;\n\t\tm_fontSize = in_fontSize;\n\t\tm_lineHeight = in_lineHeight;\n\t\tm_descent = in_descent;\n\t\tm_spaceAdvance = in_spaceAdvance;\n\t\tm_verticalPadding = in_verticalPadding;\n\t}\n\t/**\n\t * @author Ian Copland\n\t * \n\t * @return The number of glyphs.\n\t */\n\tpublic int getNumGlyphs()\n\t{\n\t\treturn m_glyphs.length;\n\t}\n\t/**\n\t * @author Ian Copland\n\t * \n\t * @return The number of glyphs.\n\t */\n\tpublic Glyph getGlyph(int in_index)\n\t{\n\t\tassert (in_index >= 0 && in_index < m_glyphs.length) : \"Invalid glyph index.\";\n\t\t\n\t\treturn m_glyphs[in_index];\n\t}\n\t/**\n\t * @author Ian Copland\n\t * \n\t * @return The point size of the font the glyphs were created from.\n\t */\n\tpublic int getFontSize()\n\t{\n\t\treturn m_fontSize;\n\t}\n\t/**\n\t * @author Ian Copland\n\t * \n\t * @return The total height of a line of text.\n\t */\n\tpublic int getLineHeight()\n\t{\n\t\treturn m_lineHeight;\n\t}\n\t/**\n\t * @author Ian Copland\n\t * \n\t * @return The amount of space under the baseline in a line of text.\n\t */\n\tpublic int getDescent()\n\t{\n\t\treturn m_descent;\n\t}\n\t/**\n\t * @author Ian Copland\n\t * \n\t * @return The advance for a space character.\n\t */\n\tpublic int getSpaceAdvance()\n\t{\n\t\treturn m_spaceAdvance;\n\t}\n\t/**\n\t * @author Ian Copland\n\t * \n\t * @return The amount of padding at the top and bottom of a glyph.\n\t */\n\tpublic int getVerticalPadding()\n\t{\n\t\treturn m_verticalPadding;\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/CSFontBuilder/src/com/chilliworks/chillisource/csfontbuilder/glyphsbuilder/GlyphsBuilder.java",
    "content": "/**\n * GlyphsBuilder.java\n * ChilliSource\n * Created by Ian Copland on 09/10/2014.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2014 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.csfontbuilder.glyphsbuilder;\n\nimport com.chilliworks.chillisource.coreutils.CSException;\n \n/**\n * A static class containing methods for converting a vector font (TTF or OTF) to\n * bitmap font glyphs with kerning info.\n * \n * @author Ian Copland\n */\npublic final class GlyphsBuilder\n{\n\t/**\n\t * Converts the font described in the input options to bitmap font glyphs. Also\n\t * outputs kerning info for the glyphs.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param in_outputDirectoryPath - The output directory for the glyphs.\n\t * @param in_options - The builder options.\n\t * \n\t * @throws CSException - An exception which provides a message describing the \n\t * error which has occurred.\n\t */\n\tpublic static void build(String in_outputDirectoryPath, GlyphsBuilderOptions in_options) throws CSException\n\t{\n\t\tGlyphs glyphs = GlyphsRenderer.render(in_options);\n\t\tGlyphsWriter.write(glyphs, in_outputDirectoryPath);\n\t}\t\n\n}\n"
  },
  {
    "path": "Projects/Tools/CSFontBuilder/src/com/chilliworks/chillisource/csfontbuilder/glyphsbuilder/GlyphsBuilderOptions.java",
    "content": "/**\n * GlyphsBuilderOptions.java\n * ChilliSource\n * Created by Ian Copland on 09/10/2014.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2014 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.csfontbuilder.glyphsbuilder;\n\nimport java.awt.Font;\n\nimport com.chilliworks.chillisource.coreutils.Colour;\nimport com.chilliworks.chillisource.coreutils.Integer2;\n\n/**\n * A container for the input options for the Glyphs Builder.\n *  \n * @author Ian Copland\n */\npublic final class GlyphsBuilderOptions\n{\n\tpublic String m_characters = \"!$%&,-.0123456789:;?@ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz¡£¥©®¿ÀÌÍßàáãäçèéêíóõöùúü–’“”…₩€元\";\n\tpublic String m_fontName = \"Arial\";\n\tpublic int m_fontStyle = Font.PLAIN;\n\tpublic int m_fontSize = 12;\n\tpublic Colour m_fontColour = Colour.WHITE;\n\tpublic boolean m_enableDropShadow = false;\n\tpublic Colour m_dropShadowColour = new Colour(0.3, 0.3, 0.3, 0.85);\n\tpublic Integer2 m_dropShadowOffset = new Integer2(2, 2);\n\tpublic boolean m_enableOutline = false;\n\tpublic Colour m_outlineColour = Colour.BLACK;\n\tpublic int m_outlineSize = 1;\n\tpublic boolean m_enableGlow = false;\n\tpublic Colour m_glowColour = new Colour(1.0, 1.0, 1.0, 0.1);\n\tpublic int m_glowSize = 3;\n}\n"
  },
  {
    "path": "Projects/Tools/CSFontBuilder/src/com/chilliworks/chillisource/csfontbuilder/glyphsbuilder/GlyphsBuilderOptionsParser.java",
    "content": "/**\n * GlyphsBuilderOptionsParser.java\n * ChilliSource\n * Created by Ian Copland on 22/10/2014.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2014 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.csfontbuilder.glyphsbuilder;\n\nimport java.awt.Font;\nimport java.util.ArrayList;\nimport java.util.List;\n\nimport com.chilliworks.chillisource.coreutils.Colour;\nimport com.chilliworks.chillisource.coreutils.Integer2;\nimport com.chilliworks.chillisource.coreutils.Logging;\n\n/**\n * A container for methods relating to parsing glyphs builder options.\n * \n * @author Ian Copland\n */\npublic final class GlyphsBuilderOptionsParser\n{\n\tpublic static final String PARAM_CHARACTERS = \"--characters\";\n\tpublic static final String PARAM_FONT_NAME = \"--fontname\";\n\tpublic static final String PARAM_FONT_STYLE = \"--fontstyle\";\n\tpublic static final String PARAM_FONT_SIZE = \"--fontsize\";\n\tpublic static final String PARAM_FONT_COLOUR = \"--fontcolour\";\n\tpublic static final String PARAM_ENABLE_DROP_SHADOW = \"--enabledropshadow\";\n\tpublic static final String PARAM_DROP_SHADOW_COLOUR = \"--dropshadowcolour\";\n\tpublic static final String PARAM_DROP_SHADOW_OFFSET = \"--dropshadowoffset\";\n\tpublic static final String PARAM_ENABLE_OUTLINE = \"--enableoutline\";\n\tpublic static final String PARAM_OUTLINE_COLOUR = \"--outlinecolour\";\n\tpublic static final String PARAM_OUTLINE_SIZE = \"--outlinesize\";\n\tpublic static final String PARAM_ENABLE_GLOW = \"--enableglow\";\n\tpublic static final String PARAM_GLOW_COLOUR = \"--glowcolour\";\n\tpublic static final String PARAM_GLOW_SIZE = \"--glowsize\";\n\t\n\tpublic static final String SHORT_PARAM_CHARACTERS = \"-ch\";\n\tpublic static final String SHORT_PARAM_FONT_NAME = \"-fn\";\n\tpublic static final String SHORT_PARAM_FONT_STYLE = \"-fst\";\n\tpublic static final String SHORT_PARAM_FONT_SIZE = \"-fsi\";\n\tpublic static final String SHORT_PARAM_FONT_COLOUR = \"-fc\";\n\tpublic static final String SHORT_PARAM_ENABLE_DROP_SHADOW = \"-eds\";\n\tpublic static final String SHORT_PARAM_DROP_SHADOW_COLOUR = \"-dsc\";\n\tpublic static final String SHORT_PARAM_DROP_SHADOW_OFFSET = \"-dso\";\n\tpublic static final String SHORT_PARAM_ENABLE_OUTLINE = \"-eo\";\n\tpublic static final String SHORT_PARAM_OUTLINE_COLOUR = \"-oc\";\n\tpublic static final String SHORT_PARAM_OUTLINE_SIZE = \"-os\";\n\tpublic static final String SHORT_PARAM_ENABLE_GLOW = \"-eg\";\n\tpublic static final String SHORT_PARAM_GLOW_COLOUR = \"-gc\";\n\tpublic static final String SHORT_PARAM_GLOW_SIZE = \"-gs\";\n\t\n\tpublic static final String FONT_STYLE_PLAIN = \"plain\";\n\tpublic static final String FONT_STYLE_BOLD = \"bold\";\n\tpublic static final String FONT_STYLE_ITALIC = \"italic\";\n\t\n\t/**\n\t * Processes all glyph mode options.\n\t *\n\t * @author Ian Copland\n\t * \n\t * @param in_arguments - The arguments for Glyphs mode. \n\t * @param out_options - The output options.\n\t * \n\t * @return The unused argument list.\n\t */\n\tpublic static String[] parse(String[] in_arguments, GlyphsBuilderOptions out_options)\n\t{\n\t\tassert (in_arguments != null) : \"Arguments cannot be null\";\n\t\tassert (out_options != null) : \"Output options cannot be null\";\n\t\t\n\t\tList<String> unusedArguments = new ArrayList<String>();\n\n\t\tfor (int i = 0; i < in_arguments.length; ++i)\n\t\t{\n\t\t\t//characters\n\t\t\tif (in_arguments[i].equalsIgnoreCase(PARAM_CHARACTERS) == true || in_arguments[i].equalsIgnoreCase(SHORT_PARAM_CHARACTERS) == true)\n\t\t\t{\n\t\t\t\tif (i+1 < in_arguments.length)\n\t\t\t\t\tout_options.m_characters = in_arguments[i+1];\n\t\t\t\telse\n\t\t\t\t\tLogging.logFatal(\"No character list provided.\");\n\t\t\t\ti++;\n\t\t\t}\n\t\t\t\n\t\t\t//font name\n\t\t\telse if (in_arguments[i].equalsIgnoreCase(PARAM_FONT_NAME) == true || in_arguments[i].equalsIgnoreCase(SHORT_PARAM_FONT_NAME) == true)\n\t\t\t{\n\t\t\t\tif (i+1 < in_arguments.length)\n\t\t\t\t\tout_options.m_fontName = in_arguments[i+1];\n\t\t\t\telse\n\t\t\t\t\tLogging.logFatal(\"No font name provided!\");\n\t\t\t\ti++;\n\t\t\t}\n\t\t\t\n\t\t\t//font style\n\t\t\telse if (in_arguments[i].equalsIgnoreCase(PARAM_FONT_STYLE) == true || in_arguments[i].equalsIgnoreCase(SHORT_PARAM_FONT_STYLE) == true)\n\t\t\t{\n\t\t\t\tif (i+1 < in_arguments.length)\n\t\t\t\t\tout_options.m_fontStyle = parseFontStyle(in_arguments[i+1]);\n\t\t\t\telse\n\t\t\t\t\tLogging.logFatal(\"No font style provided!\");\n\t\t\t\ti++;\n\t\t\t}\n\t\t\t\n\t\t\t//font size\n\t\t\telse if (in_arguments[i].equalsIgnoreCase(PARAM_FONT_SIZE) == true || in_arguments[i].equalsIgnoreCase(SHORT_PARAM_FONT_SIZE) == true)\n\t\t\t{\n\t\t\t\tif (i+1 < in_arguments.length)\n\t\t\t\t\tout_options.m_fontSize = Integer.parseInt(in_arguments[i+1]);\n\t\t\t\telse\n\t\t\t\t\tLogging.logFatal(\"No font size provided!\");\n\t\t\t\ti++;\n\t\t\t}\n\t\t\t\n\t\t\t//font colour\n\t\t\telse if (in_arguments[i].equalsIgnoreCase(PARAM_FONT_COLOUR) == true || in_arguments[i].equalsIgnoreCase(SHORT_PARAM_FONT_COLOUR) == true)\n\t\t\t{\n\t\t\t\tif (i+1 < in_arguments.length)\n\t\t\t\t\tout_options.m_fontColour = Colour.parseColour(in_arguments[i+1]);\n\t\t\t\telse\n\t\t\t\t\tLogging.logFatal(\"No font colour provided!\");\n\t\t\t\ti++;\n\t\t\t}\n\t\t\t\n\t\t\t//drop shadow\n\t\t\telse if (in_arguments[i].equalsIgnoreCase(PARAM_ENABLE_DROP_SHADOW) == true || in_arguments[i].equalsIgnoreCase(SHORT_PARAM_ENABLE_DROP_SHADOW) == true)\n\t\t\t{\n\t\t\t\tout_options.m_enableDropShadow = true;\n\t\t\t}\n\t\t\t\n\t\t\t//drop shadow colour\n\t\t\telse if (in_arguments[i].equalsIgnoreCase(PARAM_DROP_SHADOW_COLOUR) == true || in_arguments[i].equalsIgnoreCase(SHORT_PARAM_DROP_SHADOW_COLOUR) == true)\n\t\t\t{\n\t\t\t\tif (i+1 < in_arguments.length)\n\t\t\t\t\tout_options.m_dropShadowColour = Colour.parseColour(in_arguments[i+1]);\n\t\t\t\telse\n\t\t\t\t\tLogging.logFatal(\"No drop shadow colour provided!\");\n\t\t\t\ti++;\n\t\t\t}\n\t\t\t\n\t\t\t//drop shadow offset\n\t\t\telse if (in_arguments[i].equalsIgnoreCase(PARAM_DROP_SHADOW_OFFSET) == true || in_arguments[i].equalsIgnoreCase(SHORT_PARAM_DROP_SHADOW_OFFSET) == true)\n\t\t\t{\n\t\t\t\tif (i+1 < in_arguments.length)\n\t\t\t\t\tout_options.m_dropShadowOffset = Integer2.parseInt2(in_arguments[i+1]);\n\t\t\t\telse\n\t\t\t\t\tLogging.logFatal(\"No drop shadow offset provided!\");\n\t\t\t\ti++;\n\t\t\t}\n\t\t\t\n\t\t\t//outline\n\t\t\telse if (in_arguments[i].equalsIgnoreCase(PARAM_ENABLE_OUTLINE) == true || in_arguments[i].equalsIgnoreCase(SHORT_PARAM_ENABLE_OUTLINE) == true)\n\t\t\t{\n\t\t\t\tout_options.m_enableOutline = true;\n\t\t\t}\n\t\t\t\n\t\t\t//outline colour\n\t\t\telse if (in_arguments[i].equalsIgnoreCase(PARAM_OUTLINE_COLOUR) == true || in_arguments[i].equalsIgnoreCase(SHORT_PARAM_OUTLINE_COLOUR) == true)\n\t\t\t{\n\t\t\t\tif (i+1 < in_arguments.length)\n\t\t\t\t\tout_options.m_outlineColour = Colour.parseColour(in_arguments[i+1]);\n\t\t\t\telse\n\t\t\t\t\tLogging.logFatal(\"No outline colour provided!\");\n\t\t\t\ti++;\n\t\t\t}\n\t\t\t\n\t\t\t//outline size\n\t\t\telse if (in_arguments[i].equalsIgnoreCase(PARAM_OUTLINE_SIZE) == true || in_arguments[i].equalsIgnoreCase(SHORT_PARAM_OUTLINE_SIZE) == true)\n\t\t\t{\n\t\t\t\tif (i+1 < in_arguments.length)\n\t\t\t\t\tout_options.m_outlineSize = Integer.parseInt(in_arguments[i+1]);\n\t\t\t\telse\n\t\t\t\t\tLogging.logFatal(\"No outline size provided!\");\n\t\t\t\ti++;\n\t\t\t}\n\t\t\t\n\t\t\t//glow\n\t\t\telse if (in_arguments[i].equalsIgnoreCase(PARAM_ENABLE_GLOW) == true || in_arguments[i].equalsIgnoreCase(SHORT_PARAM_ENABLE_GLOW) == true)\n\t\t\t{\n\t\t\t\tout_options.m_enableGlow = true;\n\t\t\t}\n\t\t\t\n\t\t\t//glow colour\n\t\t\telse if (in_arguments[i].equalsIgnoreCase(PARAM_GLOW_COLOUR) == true || in_arguments[i].equalsIgnoreCase(SHORT_PARAM_GLOW_COLOUR) == true)\n\t\t\t{\n\t\t\t\tif (i+1 < in_arguments.length)\n\t\t\t\t\tout_options.m_glowColour = Colour.parseColour(in_arguments[i+1]);\n\t\t\t\telse\n\t\t\t\t\tLogging.logFatal(\"No glow colour provided!\");\n\t\t\t\ti++;\n\t\t\t}\n\t\t\t\n\t\t\t//glow size\n\t\t\telse if (in_arguments[i].equalsIgnoreCase(PARAM_GLOW_SIZE) == true || in_arguments[i].equalsIgnoreCase(SHORT_PARAM_GLOW_SIZE) == true)\n\t\t\t{\n\t\t\t\tif (i+1 < in_arguments.length)\n\t\t\t\t\tout_options.m_glowSize = Integer.parseInt(in_arguments[i+1]);\n\t\t\t\telse\n\t\t\t\t\tLogging.logFatal(\"No glow size provided!\");\n\t\t\t\ti++;\n\t\t\t}\n\t\t\t\n\t\t\t//otherwise add to the unused arg list\n\t\t\telse\n\t\t\t{\n\t\t\t\tunusedArguments.add(in_arguments[i]);\n\t\t\t}\n\t\t}\n\t\t\n\t\treturn unusedArguments.toArray(new String[0]);\n\t}\n\t/**\n\t * Parses a font style from string.\n\t *\n\t * @author Ian Copland\n\t * \n\t * @param The string to parse.\n\t * \n\t * @return The font style the string is describing.\n\t */\n\tprivate static int parseFontStyle(String in_stringToParse)\n\t{\n\t\tif (in_stringToParse.equalsIgnoreCase(FONT_STYLE_PLAIN) == true)\n\t\t{\n\t\t\treturn Font.PLAIN;\n\t\t}\n\t\telse if (in_stringToParse.equalsIgnoreCase(FONT_STYLE_BOLD) == true)\n\t\t{\n\t\t\treturn Font.BOLD;\n\t\t}\n\t\telse if (in_stringToParse.equalsIgnoreCase(FONT_STYLE_ITALIC) == true)\n\t\t{\n\t\t\treturn Font.ITALIC;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tLogging.logFatal(\"Invalid font style provided: \" + in_stringToParse);\n\t\t\treturn Font.PLAIN;\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/CSFontBuilder/src/com/chilliworks/chillisource/csfontbuilder/glyphsbuilder/GlyphsRenderer.java",
    "content": "/**\n * GlyphsRenderer.java\n * ChilliSource\n * Created by Ian Copland on 21/10/2014.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2014 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.csfontbuilder.glyphsbuilder;\n\nimport java.awt.Color;\nimport java.awt.Font;\nimport java.awt.FontMetrics;\nimport java.awt.Graphics2D;\nimport java.awt.RenderingHints;\nimport java.awt.font.FontRenderContext;\nimport java.awt.font.GlyphMetrics;\nimport java.awt.font.GlyphVector;\nimport java.awt.image.BufferedImage;\nimport java.awt.image.ConvolveOp;\nimport java.awt.image.Kernel;\n\nimport com.chilliworks.chillisource.coreutils.Colour;\nimport com.chilliworks.chillisource.coreutils.Integer2;\n\n/**\n * A collection of methods for creating a series of bitmap images containing\n * individual glyphs from a font.\n * \n * @author Ian Copland\n */\npublic final class GlyphsRenderer\n{\n\t/**\n\t * Creates a series of bitmap images containing glyphs from the given\n\t * font.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param in_options - The options for the glyph builder.\n\t * \n\t * @return The glyph bitmap images. This will never be null.\n\t */\n\tpublic static Glyphs render(GlyphsBuilderOptions in_options)\n\t{\n\t\t//get the font height and Y positions.\n\t\tFont font = new Font(in_options.m_fontName, in_options.m_fontStyle, in_options.m_fontSize);\n\t\tint fontLineHeight = calcFontHeight(font);\n\t\tint fontDescent = calcFontDescent(font);\n\t\tint fontSpaceAdvance = calcFontSpaceAdvance(font);\n\t\tint fontY = fontLineHeight - fontDescent;\n\t\t\n\t\t//calculate the padding required for the effects applied to the font.\n\t\tInteger2 totalPadding = Integer2.ZERO;\n\t\tif (in_options.m_enableDropShadow == true)\n\t\t{\n\t\t\t//because of the blur drop shadow needs some additional padding.\n\t\t\tInteger2 blurPadding = new Integer2(1, 1);\n\t\t\tInteger2 dropShadowPadding = Integer2.add(in_options.m_dropShadowOffset, blurPadding);\n\t\t\ttotalPadding = Integer2.max(totalPadding, dropShadowPadding);\n\t\t}\n\t\t\n\t\tif (in_options.m_enableOutline == true)\n\t\t{\n\t\t\tInteger2 outlinePadding = new Integer2(in_options.m_outlineSize, in_options.m_outlineSize);\n\t\t\ttotalPadding = Integer2.max(totalPadding, outlinePadding);\n\t\t}\n\t\t\n\t\tif (in_options.m_enableGlow == true)\n\t\t{\n\t\t\t//because of the blur glow needs some additional padding.\n\t\t\tInteger2 blurPadding = new Integer2(1, 1);\n\t\t\tInteger2 glowPadding = Integer2.add(new Integer2(in_options.m_glowSize, in_options.m_glowSize), blurPadding);\n\t\t\ttotalPadding = Integer2.max(totalPadding, glowPadding);\n\t\t}\n\t\t\n\t\t//add in the base padding to accommodate for the fact that integer rounding means position values can be up to half of a pixel out.\n\t\ttotalPadding = Integer2.add(totalPadding, new Integer2(1, 1));\n\t\t\n\t\t//render each glyph\n\t\tchar[] glyphCharacters = in_options.m_characters.toCharArray();\n\t\tGlyph[] glyphs = new Glyph[glyphCharacters.length];\n\t\tfor (int i = 0; i < glyphCharacters.length; ++i)\n\t\t{\n\t\t\tchar glyphChar = glyphCharacters[i];\n\t\t\t\n\t\t\t//get the information on the glyph.\n\t\t\tFontRenderContext fontRenderContext = new FontRenderContext(null, true, false);\n\t\t\tGlyphVector glyphVector = font.createGlyphVector(fontRenderContext, Character.toString(glyphChar));\n\t\t\tGlyphMetrics glyphMetrics = glyphVector.getGlyphMetrics(0);\n\n\t\t\t//calculate the image data for this glyph.\n\t\t\tInteger2 imageSize = new Integer2(((int)Math.ceil(glyphMetrics.getBounds2D().getWidth())) + 2 * totalPadding.getX(), fontLineHeight + 2 * totalPadding.getY());\n\t\t\tInteger2 glyphRenderPos = new Integer2(totalPadding.getX() - ((int)Math.round(glyphMetrics.getLSB())), fontY + totalPadding.getY());\n\t\t\t\n\t\t\t//create the glyph image\n\t\t\tBufferedImage glyphImage = new BufferedImage(imageSize.getX(), imageSize.getY(), BufferedImage.TYPE_INT_ARGB);\n\t\t\tGraphics2D graphics = glyphImage.createGraphics();\n\t\t\tgraphics.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);\n\t\t\t\n\t\t\t//draw the drop shadow glyph if required.\n\t\t\tif (in_options.m_enableDropShadow == true)\n\t\t\t{\n\t\t\t\tInteger2 shadowGlyphRenderPos = Integer2.add(glyphRenderPos, in_options.m_dropShadowOffset);\n\t\t\t\tBufferedImage shadowImage = renderDropShadow(glyphVector, imageSize, shadowGlyphRenderPos, in_options.m_dropShadowColour);\n\t\t\t\tgraphics.drawImage(shadowImage, null, null);\n\t\t\t}\n\t\t\t\n\t\t\t//draw the glow glyph if required.\n\t\t\tif (in_options.m_enableGlow == true)\n\t\t\t{\n\t\t\t\tBufferedImage glowImage = renderGlow(glyphVector, imageSize, glyphRenderPos, in_options.m_glowColour, in_options.m_glowSize);\n\t\t\t\tgraphics.drawImage(glowImage, null, null);\n\t\t\t}\n\t\t\t\n\t\t\t//draw the outline glyph if required.\n\t\t\tif (in_options.m_enableOutline == true)\n\t\t\t{\n\t\t\t\tBufferedImage outlineImage = renderOutline(glyphVector, imageSize, glyphRenderPos, in_options.m_outlineColour, in_options.m_outlineSize);\n\t\t\t\tgraphics.drawImage(outlineImage, null, null);\n\t\t\t}\n\t\t\t\n\t\t\t//draw the glyph\n\t\t\tgraphics.setColor(new Color((float)in_options.m_fontColour.getR(), (float)in_options.m_fontColour.getG(), (float)in_options.m_fontColour.getB(), (float)in_options.m_fontColour.getA()));\n\t\t\tgraphics.drawGlyphVector(glyphVector, glyphRenderPos.getX(), glyphRenderPos.getY());\n\t\t\t\n\t\t\t//calculate the glyph info\n\t\t\tint glyphOrigin = totalPadding.getX() - (int)Math.floor(glyphMetrics.getLSB());\n\t\t\tint glyphAdvance = (int)Math.floor(glyphMetrics.getAdvanceX());\n\t\t\t\n\t\t\tglyphs[i] = new Glyph(glyphChar, glyphImage, glyphOrigin, glyphAdvance);\n\t\t}\n\t\t\n\t\treturn new Glyphs(glyphs, in_options.m_fontSize, fontLineHeight, fontDescent, fontSpaceAdvance, totalPadding.getY());\n\t}\n\t/**\n\t * Calculates the height of the given font.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param in_font - The font.\n\t * \n\t * @return The height of the font.\n\t */\n\tprivate static int calcFontHeight(Font in_font)\n\t{\n\t\tBufferedImage image = new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB);\n\t    Graphics2D graphics1 = image.createGraphics();\n\t    FontMetrics fontMetrics = graphics1.getFontMetrics(in_font);\n\t    int fontHeight = fontMetrics.getHeight();\n\t    graphics1.dispose();\n\t    \n\t    return fontHeight;\n\t}\n\t/**\n\t * Calculates the descent of the given font. This is the offset from the baseline of\n\t * the font that most glyphs will be rendered at.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param in_font - The font.\n\t * \n\t * @return The height of the font.\n\t */\n\tprivate static int calcFontDescent(Font in_font)\n\t{\n\t\tBufferedImage image = new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB);\n\t    Graphics2D graphics1 = image.createGraphics();\n\t    FontMetrics fontMetrics = graphics1.getFontMetrics(in_font);\n\t    int fontDescent = fontMetrics.getDescent();\n\t    graphics1.dispose();\n\t    \n\t    return fontDescent;\n\t}\n\t/**\n\t * Calculates the space advance for the given font.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param in_font - The font.\n\t * \n\t * @return The space advance of the font.\n\t */\n\tprivate static int calcFontSpaceAdvance(Font in_font)\n\t{\n\t\tFontRenderContext fontRenderContext = new FontRenderContext(null, true, false);\n\t\tGlyphVector glyphVector = in_font.createGlyphVector(fontRenderContext, \" \");\n\t\tGlyphMetrics glyphMetrics = glyphVector.getGlyphMetrics(0);\n\n\t    return (int)Math.floor(glyphMetrics.getAdvanceX());\n\t}\n\t/**\n\t * Renders the drop shadow for the given glyph vector.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param in_glyphVector - The glyph vector.\n\t * @param in_imageSize - The size of the image the shadow should be rendered to.\n\t * @param in_shadowPosition - The position of the shadow in the image.\n\t * @param in_shadowColour - The colour of the shadow.\n\t * \n\t * @return An image with the drop shadow rendered into it.\n\t */\n\tprivate static BufferedImage renderDropShadow(GlyphVector in_glyphVector, Integer2 in_imageSize, Integer2 in_shadowPosition, Colour in_shadowColour)\n\t{\n\t\tBufferedImage image = new BufferedImage(in_imageSize.getX(), in_imageSize.getY(), BufferedImage.TYPE_INT_ARGB);\n\t\tGraphics2D graphics = image.createGraphics();\n\t\tgraphics.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);\n\t\t\n\t\tgraphics.setColor(new Color((float)in_shadowColour.getR(), (float)in_shadowColour.getG(), (float)in_shadowColour.getB(), (float)in_shadowColour.getA()));\n\t\tgraphics.drawGlyphVector(in_glyphVector, in_shadowPosition.getX(), in_shadowPosition.getY());\n\t\t\n\t\tfinal float BLUR_FACTOR = (1.0f / 9.0f);\n\t\tfloat[] blur = new float[]\n\t\t{\n\t\t\tBLUR_FACTOR, BLUR_FACTOR, BLUR_FACTOR,\n\t\t\tBLUR_FACTOR, BLUR_FACTOR, BLUR_FACTOR,\n\t\t\tBLUR_FACTOR, BLUR_FACTOR, BLUR_FACTOR\n\t\t};\n\t\t\n\t\tKernel kernel = new Kernel(3, 3, blur);\n\t\tConvolveOp op = new ConvolveOp(kernel, ConvolveOp.EDGE_NO_OP, null);\n\t\treturn op.filter(image, null);\n\t}\n\t/**\n\t * Renders the outline for the given glyph vector.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param in_glyphVector - The glyph vector.\n\t * @param in_imageSize - The size of the image the outline should be rendered to.\n\t * @param in_glyphPosition - The position of the outline in the image.\n\t * @param in_outlineColour - The colour of the outline.\n\t * @param in_outlineSize - The size of the outline.\n\t * \n\t * @return An image with the outline rendered into it.\n\t */\n\tprivate static BufferedImage renderOutline(GlyphVector in_glyphVector, Integer2 in_imageSize, Integer2 in_glyphPosition, Colour in_outlineColour, int in_outlineSize)\n\t{\n\t\tBufferedImage image = new BufferedImage(in_imageSize.getX(), in_imageSize.getY(), BufferedImage.TYPE_INT_ARGB);\n\t\tGraphics2D graphics = image.createGraphics();\n\t\tgraphics.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);\n\t\t\n\t\tgraphics.setColor(new Color((float)in_outlineColour.getR(), (float)in_outlineColour.getG(), (float)in_outlineColour.getB(), (float)in_outlineColour.getA()));\n\t\t\n\t\tfor (int x = -in_outlineSize; x <= in_outlineSize; x += in_outlineSize)\n\t\t{\n\t\t\tfor (int y = -in_outlineSize; y <= in_outlineSize; y += in_outlineSize)\n\t\t\t{\n\t\t\t\tgraphics.drawGlyphVector(in_glyphVector, in_glyphPosition.getX() + x, in_glyphPosition.getY() + y);\n\t\t\t}\n\t\t}\n\t\t\n\t\treturn image;\n\t}\n\t/**\n\t * Renders the glow for the given glyph vector.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param in_glyphVector - The glyph vector.\n\t * @param in_imageSize - The size of the image the glow should be rendered to.\n\t * @param in_glyphPosition - The position of the glow in the image.\n\t * @param in_glowColour - The colour of the glow.\n\t * @param in_glowSize - The size of the glow.\n\t * \n\t * @return An image with the glow rendered into it.\n\t */\n\tprivate static BufferedImage renderGlow(GlyphVector in_glyphVector, Integer2 in_imageSize, Integer2 in_glyphPosition, Colour in_glowColour, int in_glowSize)\n\t{\n\t\tBufferedImage image = new BufferedImage(in_imageSize.getX(), in_imageSize.getY(), BufferedImage.TYPE_INT_ARGB);\n\t\tGraphics2D graphics = image.createGraphics();\n\t\tgraphics.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);\n\t\t\n\t\tgraphics.setColor(new Color((float)in_glowColour.getR(), (float)in_glowColour.getG(), (float)in_glowColour.getB(), (float)in_glowColour.getA()));\n\t\t\n\t\tfor (int x = -in_glowSize; x <= in_glowSize; x += in_glowSize)\n\t\t{\n\t\t\tfor (int y = -in_glowSize; y <= in_glowSize; y += in_glowSize)\n\t\t\t{\n\t\t\t\tgraphics.drawGlyphVector(in_glyphVector, in_glyphPosition.getX() + x, in_glyphPosition.getY() + y);\n\t\t\t}\n\t\t}\n\t\t\n\t\tfinal float BLUR_FACTOR = (1.0f / 9.0f);\n\t\tfloat[] blur = new float[]\n\t\t{\n\t\t\tBLUR_FACTOR, BLUR_FACTOR, BLUR_FACTOR,\n\t\t\tBLUR_FACTOR, BLUR_FACTOR, BLUR_FACTOR,\n\t\t\tBLUR_FACTOR, BLUR_FACTOR, BLUR_FACTOR\n\t\t};\n\t\t\n\t\tKernel kernel = new Kernel(3, 3, blur);\n\t\tConvolveOp op = new ConvolveOp(kernel, ConvolveOp.EDGE_NO_OP, null);\n\t\treturn op.filter(image, null);\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/CSFontBuilder/src/com/chilliworks/chillisource/csfontbuilder/glyphsbuilder/GlyphsWriter.java",
    "content": "/**\n * GlyphsWriter.java\n * ChilliSource\n * Created by Ian Copland on 21/10/2014.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2014 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.csfontbuilder.glyphsbuilder;\n\nimport java.io.File;\nimport java.io.IOException;\n\nimport javax.imageio.ImageIO;\n\nimport org.json.JSONObject;\n\nimport com.chilliworks.chillisource.coreutils.CSException;\nimport com.chilliworks.chillisource.coreutils.FileUtils;\nimport com.chilliworks.chillisource.coreutils.Logging;\nimport com.chilliworks.chillisource.coreutils.StringUtils;\n\n/**\n * Provides a series of methods for writing bitmap font glyphs to file.\n * \n * @author Ian Copland\n */\npublic final class GlyphsWriter\n{\n\tprivate static final String FONT_INFO_FILE_PATH = \"FontInfo.csfontinfo\";\n\t\n\t/**\n\t * Saves the given glyphs to the output directory. This will write the bitmap images\n\t * and a JSON file containing the information on the glyphs, such as font size,\n\t * line height and the descent.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param in_glyphs - The glyphs that should be written to disk.\n\t * @param in_outputDirectoryPath - The path to the output directory.\n\t * \n\t * @throws CSException - An exception which provides a message describing the error \n\t * which has occurred.\n\t */\n\tpublic static void write(Glyphs in_glyphs, String in_outputDirectoryPath) throws CSException\n\t{\n\t\twriteBitmapGlyphs(in_glyphs, in_outputDirectoryPath);\n\t\twriteFontInfo(in_glyphs, in_outputDirectoryPath);\n\t}\n\t/**\n\t * Saves the output bitmap glyphs to the given directory.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param in_glyphs - The glyphs that should be written to disk.\n\t * @param in_outputDirectoryPath - The path to the output directory.\n\t * \n\t * @throws CSException - An exception which provides a message describing the error \n\t * which has occurred.\n\t */\n\tprivate static void writeBitmapGlyphs(Glyphs in_glyphs, String in_outputDirectoryPath) throws CSException\n\t{\n\t\ttry \n\t\t{\n\t\t\tfor (int i = 0; i < in_glyphs.getNumGlyphs(); ++i)\n\t\t\t{\n\t\t\t\tGlyph glyph = in_glyphs.getGlyph(i);\n\t\t\t\tString characterString = Integer.toHexString((int)glyph.getCharacter());\n\t\t\t\tString upperCharacterString = characterString.toUpperCase();\n\t\t\t\t\n\t\t\t    File outputfile = new File(in_outputDirectoryPath + upperCharacterString + \".png\");\n\t\t\t    ImageIO.write(glyph.getImage(), \"png\", outputfile);\n\t\t\t}\n\t\t} \n\t\tcatch (IOException e) \n\t\t{\n\t\t\tLogging.logVerbose(StringUtils.convertExceptionToString(e));\n\t\t\tthrow new CSException(\"Failed to save glyphs to directory: \" + in_outputDirectoryPath, e);\n\t\t}\n\t}\n\t/**\n\t * Writes the font into for the given glyphs to the given directory.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param in_glyphs - The glyphs whose info should be written to disk.\n\t * @param in_outputDirectoryPath - The path to the output directory.\n\t * \n\t * @throws CSException - An exception which provides a message describing\n\t * the error which has occurred.\n\t */\n\tprivate static void writeFontInfo(Glyphs in_glyphs, String in_outputDirectoryPath) throws CSException\n\t{\n\t\tJSONObject jsonRoot = new JSONObject();\n\t\tjsonRoot.put(\"FontSize\", in_glyphs.getFontSize());\n\t\tjsonRoot.put(\"LineHeight\", in_glyphs.getLineHeight());\n\t\tjsonRoot.put(\"Descent\", in_glyphs.getDescent());\n\t\tjsonRoot.put(\"SpaceAdvance\", in_glyphs.getSpaceAdvance());\n\t\tjsonRoot.put(\"VerticalPadding\", in_glyphs.getVerticalPadding());\n\t\t\n\t\tJSONObject jsonGlyphs = new JSONObject();\n\t\tfor (int i = 0; i < in_glyphs.getNumGlyphs(); ++i)\n\t\t{\n\t\t\tGlyph glyph = in_glyphs.getGlyph(i);\n\t\t\tJSONObject jsonGlyph = new JSONObject();\n\t\t\tjsonGlyph.put(\"Origin\", glyph.getOrigin());\n\t\t\tjsonGlyph.put(\"Advance\", glyph.getAdvance());\n\t\t\tjsonGlyphs.put(\"\" + glyph.getCharacter(), jsonGlyph);\n\t\t}\n\t\tjsonRoot.put(\"Glyphs\", jsonGlyphs);\n\t\t\n\t\tString jsonString = jsonRoot.toString(2);\n\t\t\n\t\tString outputFilePath = StringUtils.standardiseFilePath(in_outputDirectoryPath + FONT_INFO_FILE_PATH);\n\t\tif (FileUtils.writeFile(outputFilePath, jsonString) == false)\n\t\t{\n\t\t\tthrow new CSException(\"Failed to write the font info file: \" + outputFilePath);\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/CSProjectGenerator/.classpath",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<classpath>\n\t<classpathentry kind=\"src\" path=\"src\"/>\n\t<classpathentry kind=\"con\" path=\"org.eclipse.jdt.launching.JRE_CONTAINER\"/>\n\t<classpathentry combineaccessrules=\"false\" kind=\"src\" path=\"/CoreUtils\"/>\n\t<classpathentry kind=\"output\" path=\"bin\"/>\n</classpath>\n"
  },
  {
    "path": "Projects/Tools/CSProjectGenerator/.project",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<projectDescription>\n\t<name>CSProjectGenerator</name>\n\t<comment></comment>\n\t<projects>\n\t</projects>\n\t<buildSpec>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.jdt.core.javabuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t</buildSpec>\n\t<natures>\n\t\t<nature>org.eclipse.jdt.core.javanature</nature>\n\t</natures>\n</projectDescription>\n"
  },
  {
    "path": "Projects/Tools/CSProjectGenerator/Manifest.txt",
    "content": "Manifest-Version: 1.0\r\nMain-Class: com.chilliworks.chillisource.csprojectgenerator.Main\r\n\r\n"
  },
  {
    "path": "Projects/Tools/CSProjectGenerator/src/com/chilliworks/chillisource/csprojectgenerator/CSProjectGenerator.java",
    "content": "/**\n * CSProjectGenerator.java\n * ChilliSource\n * Created by Ian Copland on 15/10/2014.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2014 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.csprojectgenerator;\n\nimport java.io.File;\nimport java.io.IOException;\nimport java.net.URISyntaxException;\nimport java.nio.file.Files;\nimport java.nio.file.Path;\nimport java.nio.file.Paths;\nimport java.security.CodeSource;\nimport java.util.ArrayList;\nimport java.util.Collections;\nimport java.util.List;\n\nimport com.chilliworks.chillisource.coreutils.CSException;\nimport com.chilliworks.chillisource.coreutils.FileUtils;\nimport com.chilliworks.chillisource.coreutils.Logging;\nimport com.chilliworks.chillisource.coreutils.StringUtils;\nimport com.chilliworks.chillisource.coreutils.ZipUtils;\n\n/**\n * A collection of methods for generating new ChilliSource projects.\n * \n * @author Ian Copland\n */\npublic final class CSProjectGenerator\n{\n\tprivate static final String k_templateProjectName = \"CSEmptyTemplate\";\n\tprivate static final String k_templatePackageName = \"ext.company.csemptytemplate\";\n\tprivate static final String k_projectZipFilePath = \"CSProjectGenerator/\" + k_templateProjectName + \".zip\";\n\tprivate static final String k_csSourceDirectoryPath = \"../\";\n\tprivate static final String k_csDestinationDirectoryPath = \"ChilliSource/\";\n\tprivate static final String k_tempDirectory = \"_temp-csprojectgenerator/\";\n\t\n\t/**\n\t * Generates a new ChilliSource project using the given options.\n\t * \n\t * @author Ian Copland\n\t *\n\t * @param in_options - The options with which to create the new project.\n\t */\n\tpublic static void generate(Options in_options) throws CSException\n\t{\n\t\tvalidateOptions(in_options);\n\t\tunzipProject(in_options);\n\t\tupdateProjectFiles(in_options);\n\t\tcopyChilliSource(in_options);\n\t\tcopyToOutput(in_options);\n\t\tcleanupTemp(in_options);\n\t}\n\t/**\n\t * Confirms that the given options are valid.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param in_options - The options.\n\t */\n\tprivate static void validateOptions(Options in_options) throws CSException\n\t{\n\t\t//check that the project name is valid.\n\t\tif (in_options.m_projectName.matches(\"[a-zA-Z0-9]+\") == false)\n\t\t{\n\t\t\tthrow new CSException(\"Project name can only contain: a-z, A-Z or 0-9.\");\n\t\t}\n\t\t\n\t\t//check that that package name is valid\n\t\tif (in_options.m_packageName.matches(\"[a-z.]+\") == false)\n\t\t{\n\t\t\tthrow new CSException(\"Package name can only contain: a-z and '.'\");\n\t\t}\n\t\t\n\t\t//confirm that the project path doesn't already exist.\n\t\tString outputProjectDirectoryPathName = StringUtils.standardiseDirectoryPath(in_options.m_outputDirectory + in_options.m_projectName);\n\t\tFile outputProjectDirectory = new File(outputProjectDirectoryPathName);\n\t\tif (outputProjectDirectory.exists() == true)\n\t\t{\n\t\t\tthrow new CSException(\"Output project directory '\" + outputProjectDirectoryPathName + \"' already exists!\");\n\t\t}\n\t\t\n\t\t//ensure the output path is not inside ChilliSource as this will break copying of files.\n\t\ttry\n\t\t{\n\t\t\tString outputProjectDirectoryPathNameAbs = outputProjectDirectory.getCanonicalPath();\n\t\t\tString csDirectoryPathName = StringUtils.standardiseDirectoryPath(getJarDirectoryPath(in_options) + k_csSourceDirectoryPath); \n\t\t\tString csDirectoryPathNameAbs = new File(csDirectoryPathName).getCanonicalPath();\n\t\t\n\t\t\tPath outputProjectDirectoryPath = Paths.get(outputProjectDirectoryPathNameAbs);\n\t\t\tPath csDirectoryPath = Paths.get(csDirectoryPathNameAbs);\n\n\t\t\tif (outputProjectDirectoryPath.startsWith(csDirectoryPath) == true)\n\t\t\t{\n\t\t\t\tthrow new CSException(\"Output project directory '\" + outputProjectDirectoryPathName + \"' cannot be located inside ChilliSource.\");\n\t\t\t}\n\t\t}\n\t\tcatch (Exception e)\n\t\t{\n\t\t\tLogging.logVerbose(StringUtils.convertExceptionToString(e));\n\t\t\tthrow new CSException(\"Failed to validate output directory path.\", e);\n\t\t}\n\t}\n\t/**\n\t * unzips the project to the temp directory.\n\t * \n\t * @author Ian Copland\n\t *\n\t * @param in_options - The options with which to create the new project.\n\t */\n\tprivate static void unzipProject(Options in_options) throws CSException\n\t{\n\t\ttry \n\t\t{\n\t\t\tLogging.logVerbose(\"Unzipping project to temporary directory.\");\n\t\t\t\n\t\t\tString tempDirectoryPath = StringUtils.standardiseDirectoryPath(in_options.m_outputDirectory + k_tempDirectory);\n\t\t\tif (new File(tempDirectoryPath).exists() == true)\n\t\t\t{\n\t\t\t\tthrow new CSException(\"Temp directory already exists.\");\n\t\t\t}\n\t\t\t\n\t\t\tString pathToZip = getJarDirectoryPath(in_options) + k_projectZipFilePath;\n\t\t\tZipUtils.extract(pathToZip, tempDirectoryPath);\n\t    } \n\t\tcatch (IOException e) \n\t    {\n\t\t\tLogging.logVerbose(StringUtils.convertExceptionToString(e));\n\t\t\t\n\t\t\tcleanupTemp(in_options);\n\t        throw new CSException(\"Could not open project zip file: \" + k_projectZipFilePath, e);\n\t    }\n\t}\n\t/**\n\t * Get the directory path that contains this jar file\n\t * \n\t * @author S Downie\n\t * \n\t * @param in_options - The options with which to create the new project.\n\t * \n\t * @return Directory path to jar folder\n\t */\n\tprivate static String getJarDirectoryPath(Options in_options) throws CSException\n\t{\n\t\tString jarDir = \"\";\n\t\t\n\t\tCodeSource codeSource = CSProjectGenerator.class.getProtectionDomain().getCodeSource();\n\t\tFile jarFile;\n\t\ttry \n\t\t{\n\t\t\tjarFile = new File(codeSource.getLocation().toURI().getPath());\n\t\t\tjarDir = jarFile.getParentFile().getPath() + File.separator;\n\t\t} \n\t\tcatch (URISyntaxException e) \n\t\t{\n\t\t\tLogging.logVerbose(StringUtils.convertExceptionToString(e));\n\t\t\t\n\t\t\tcleanupTemp(in_options);\n\t\t\tthrow new CSException(\"Could not get jar directory path.\", e);\n\t\t}\n\t\t \n\t\treturn StringUtils.standardiseDirectoryPath(jarDir);\n\t}\n\t/**\n\t * updates the project and package name throughout the project.\n\t * \n\t * @author Ian Copland\n\t *\n\t * @param in_options - The options with which to create the new project.\n\t */\n\tprivate static void updateProjectFiles(Options in_options) throws CSException\n\t{\n\t\tString[] filesToUpdateContents = new String[]\n\t\t{\n\t\t\t\".gitignore\",\n\t\t\t\"AppSource/App.cpp\",\n\t\t\t\"AppSource/App.h\",\n\t\t\t\"AppSource/State.cpp\",\n\t\t\t\"AppSource/State.h\",\n\t\t\t\"Content/BuildAll.bat\",\n\t\t\t\"Content/BuildAll.command\",\n\t\t\t\"Content/BuildAll.sh\",\n\t\t\t\"Content/AppResources/App.config\",\n\t\t\t\"Projects/Android/\" + k_templateProjectName.toLowerCase() + \"/build.gradle\",\n\t\t\t\"Projects/Android/\" + k_templateProjectName.toLowerCase() + \"/settings.gradle\",\n\t\t\t\"Projects/Android/\" + k_templateProjectName.toLowerCase() + \"/\" + k_templateProjectName.toLowerCase() + \".iml\",\n\t\t\t\"Projects/Android/\" + k_templateProjectName.toLowerCase() + \"/.idea/.name\",\n\t\t\t\"Projects/Android/\" + k_templateProjectName.toLowerCase() + \"/.idea/modules.xml\",\n\t\t\t\"Projects/Android/\" + k_templateProjectName.toLowerCase() + \"/app/app.iml\",\n\t\t\t\"Projects/Android/\" + k_templateProjectName.toLowerCase() + \"/app/build.gradle\",\n\t\t\t\"Projects/Android/\" + k_templateProjectName.toLowerCase() + \"/app/proguard-rules.pro\",\n\t\t\t\"Projects/Android/\" + k_templateProjectName.toLowerCase() + \"/app/src/main/AndroidManifest.xml\",\n\t\t\t\"Projects/Android/\" + k_templateProjectName.toLowerCase() + \"/app/src/main/CSAndroidManifest.xml\",\n\t\t\t\"Projects/Android/\" + k_templateProjectName.toLowerCase() + \"/app/src/main/jni/Android.mk\",\n\t\t\t\"Projects/Android/\" + k_templateProjectName.toLowerCase() + \"/app/src/main/jni/Application.mk\",\n\t\t\t\"Projects/Android/\" + k_templateProjectName.toLowerCase() + \"/app/src/main/res/values/strings.xml\",\n\t\t\t\"Projects/iOS/\" + k_templateProjectName + \".xcodeproj/project.pbxproj\",\n\t\t\t\"Projects/iOS/\" + k_templateProjectName + \".xcodeproj/xcshareddata/xcschemes/\" + k_templateProjectName + \".xcscheme\",\n\t\t\t\"Projects/iOS/ProjectResources/Info.plist\",\n\t\t\t\"Projects/Windows/\" + k_templateProjectName + \".sln\",\n\t\t\t\"Projects/Windows/\" + k_templateProjectName + \".vcxproj\",\n\t\t\t\"Projects/Windows/\" + k_templateProjectName + \".vcxproj.filters\",\n\t\t\t\"Tools/Scripts/content_builder.py\",\n\t\t\t\"Tools/Scripts/file_system_utils.py\",\n\t\t\t\"Tools/Scripts/model_builder.py\",\n\t\t\t\"Tools/Scripts/text_builder.py\",\n\t\t\t\"Tools/Scripts/texture_atlas_builder.py\",\n\t\t\t\"Tools/Scripts/texture_builder.py\"\n\t\t};\n\t\t\n\t\tupdateFileContents(in_options, filesToUpdateContents);\n\t\t\n\t\tString[] filesToUpdateFileName = new String[]\n\t\t{\n\t\t\t\"Projects/Android/\" + k_templateProjectName.toLowerCase() + \"/\" + k_templateProjectName.toLowerCase() + \".iml\",\n\t\t\t\"Projects/iOS/\" + k_templateProjectName + \".xcodeproj/xcshareddata/xcschemes/\" + k_templateProjectName + \".xcscheme\",\n\t\t\t\"Projects/Windows/\" + k_templateProjectName + \".sln\",\n\t\t\t\"Projects/Windows/\" + k_templateProjectName + \".vcxproj\",\n\t\t\t\"Projects/Windows/\" + k_templateProjectName + \".vcxproj.filters\"\n\n\t\t};\n\t\t\n\t\tupdateFileNames(in_options, filesToUpdateFileName);\n\t\t\n\t\tString[] directoriesToUpdateDirectoryName = new String[]\n\t\t{\n\t\t\t\"Projects/Android/\" + k_templateProjectName.toLowerCase(),\n\t\t\t\"Projects/iOS/\" + k_templateProjectName + \".xcodeproj\"\n\t\t};\n\t\t\n\t\tupdateDirectoryNames(in_options, directoriesToUpdateDirectoryName);\n\t}\n\t/**\n\t * Updates the contents of the files at the given file paths to the project \n\t * and package name given in the options.\n\t * \n\t * @author Ian Copland\n\t *\n\t * @param in_options - The options with which to create the new project.\n\t * @param in_filePaths - The array of file paths that should have their\n\t * contents updated.\n\t */\n\tprivate static void updateFileContents(Options in_options, String[] in_filePaths) throws CSException\n\t{\n\t\tString tempDirectoryPath = StringUtils.standardiseDirectoryPath(in_options.m_outputDirectory + k_tempDirectory);\n\t\tString tempProjectDirectory = StringUtils.standardiseDirectoryPath(tempDirectoryPath + k_templateProjectName);\n\t\t\n\t\tfor (String filePath : in_filePaths)\n\t\t{\n\t\t\tLogging.logVerbose(\"Updating file contents: \" + filePath);\n\t\t\t\n\t\t\tString fullFilePath = StringUtils.standardiseFilePath(tempProjectDirectory + filePath);\n\t\t\tString fileContents = FileUtils.readFile(fullFilePath);\n\t\t\tif (fileContents == null || fileContents.length() == 0)\n\t\t\t{\n\t\t\t\tcleanupTemp(in_options);\n\t\t\t\tthrow new CSException(\"Could not read file: \" + filePath);\n\t\t\t}\n\n\t\t\tfileContents = fileContents.replace(k_templatePackageName, in_options.m_packageName);\n\t\t\tfileContents = fileContents.replace(k_templateProjectName.toLowerCase(), in_options.m_projectName.toLowerCase());\n\t\t\tfileContents = fileContents.replace(k_templateProjectName.toUpperCase(), in_options.m_projectName.toUpperCase());\n\t\t\tfileContents = fileContents.replace(k_templateProjectName, in_options.m_projectName);\n\t\t\t\n\t\t\tif (FileUtils.writeFile(fullFilePath, fileContents) == false)\n\t\t\t{\n\t\t\t\tcleanupTemp(in_options);\n\t\t\t\tthrow new CSException(\"Could not write file: \" + filePath);\n\t\t\t}\n\t\t}\n\t}\n\t/**\n\t * Updates the files names of the files at the given file paths to the project \n\t * and package name given in the options.\n\t * \n\t * @author Ian Copland\n\t *\n\t * @param in_options - The options with which to create the new project.\n\t * @param in_filePaths - The array of file paths that should have their\n\t * file names updated.\n\t */\n\tprivate static void updateFileNames(Options in_options, String[] in_filePaths) throws CSException\n\t{\n\t\tString tempDirectoryPath = StringUtils.standardiseDirectoryPath(in_options.m_outputDirectory + k_tempDirectory);\n\t\tString tempProjectDirectory = StringUtils.standardiseDirectoryPath(tempDirectoryPath + k_templateProjectName);\n\t\t\n\t\tfor (String currentFilePath : in_filePaths)\n\t\t{\n\t\t\tLogging.logVerbose(\"Updating file name: \" + currentFilePath);\n\t\t\t\n\t\t\tString fileName = StringUtils.getFileName(currentFilePath);\n\t\t\tString directory = StringUtils.getDirectory(currentFilePath);\n\t\t\t\n\t\t\tString newFileName = fileName.replace(k_templatePackageName, in_options.m_packageName);\n\t\t\tnewFileName = newFileName.replace(k_templateProjectName.toLowerCase(), in_options.m_projectName.toLowerCase());\n\t\t\tnewFileName = newFileName.replace(k_templateProjectName, in_options.m_projectName);\n\t\t\t\n\t\t\tString currentFullFilePath = StringUtils.standardiseFilePath(tempProjectDirectory + currentFilePath);\n\t\t\tString newFullFilePath = StringUtils.standardiseFilePath(tempProjectDirectory + directory + newFileName);\n\t\t\t\n\t\t\tif (FileUtils.renameFile(currentFullFilePath, newFullFilePath) == false)\n\t\t\t{\n\t\t\t\tcleanupTemp(in_options);\n\t\t\t\tthrow new CSException(\"Failed to rename file: \" + currentFilePath);\n\t\t\t}\n\t\t}\n\t}\n\t/**\n\t * Updates the directory names of the directories at the given directory paths \n\t * to the project and package name given in the options.\n\t * \n\t * @author Ian Copland\n\t *\n\t * @param in_options - The options with which to create the new project.\n\t * @param in_filePaths - The array of directory paths that should have their\n\t * directory names updated.\n\t */\n\tprivate static void updateDirectoryNames(Options in_options, String[] in_directoryPaths) throws CSException\n\t{\n\t\tString tempDirectoryPath = StringUtils.standardiseDirectoryPath(in_options.m_outputDirectory + k_tempDirectory);\n\t\tString tempProjectDirectory = StringUtils.standardiseDirectoryPath(tempDirectoryPath + k_templateProjectName);\n\t\t\n\t\tfor (String currentDirectoryPath : in_directoryPaths)\n\t\t{\n\t\t\tLogging.logVerbose(\"Updating directory name: \" + currentDirectoryPath);\n\n\t\t\tString newDirectoryPath = currentDirectoryPath.replace(k_templatePackageName, in_options.m_packageName);\n\t\t\tnewDirectoryPath = newDirectoryPath.replace(k_templateProjectName.toLowerCase(), in_options.m_projectName.toLowerCase());\n\t\t\tnewDirectoryPath = newDirectoryPath.replace(k_templateProjectName, in_options.m_projectName);\n\t\t\t\n\t\t\tString currentFullDirectoryPath = StringUtils.standardiseFilePath(tempProjectDirectory + currentDirectoryPath);\n\t\t\tString newFullDirectoryPath = StringUtils.standardiseFilePath(tempProjectDirectory + newDirectoryPath);\n\t\t\t\n\t\t\tif (FileUtils.renameDirectory(currentFullDirectoryPath, newFullDirectoryPath) == false)\n\t\t\t{\n\t\t\t\tcleanupTemp(in_options);\n\t\t\t\tthrow new CSException(\"Failed to rename directory: \" + newFullDirectoryPath);\n\t\t\t}\n\t\t}\n\t}\n\t/**\n\t * Copies ChilliSource into the project directory.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param in_options - The options with which to create the new project.\n\t */\n\tprivate static void copyChilliSource(Options in_options) throws CSException\n\t{\n\t\tString tempDirectoryPath = StringUtils.standardiseDirectoryPath(in_options.m_outputDirectory + k_tempDirectory);\n\t\tString tempProjectDirectory = StringUtils.standardiseDirectoryPath(tempDirectoryPath + k_templateProjectName);\n\t\tString csSourcePath = StringUtils.standardiseDirectoryPath(getJarDirectoryPath(in_options) + k_csSourceDirectoryPath); \n\t\tString csDestinationPath = StringUtils.standardiseDirectoryPath(tempProjectDirectory + k_csDestinationDirectoryPath);\n\t\t\n\t\tLogging.logVerbose(\"Copying ChilliSource into the project.\");\n\t\t\n\t\tList<String> ignore = new ArrayList<>();\n\t\tCollections.addAll(ignore, \"bin\", \"obj\");\n\t\tif (FileUtils.copyDirectory(csSourcePath, csDestinationPath, ignore) == false)\n\t\t{\n\t\t\tcleanupTemp(in_options);\n\t\t\tthrow new CSException(\"Could not copy ChilliSource into project.\");\n\t\t}\n\t\t\n\t\t//remove any remnants of the git project.\n\t\ttry\n\t\t{\n\t\t\tPath gitPath = Paths.get(csDestinationPath + \".git\");\n\t\t\tif (Files.isDirectory(gitPath) == true)\n\t\t\t{\n\t\t\t\tFileUtils.deleteDirectory(gitPath.toString());\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tFiles.deleteIfExists(gitPath);\n\t\t\t}\n\t\t\tFiles.deleteIfExists(Paths.get(csDestinationPath + \".gitignore\"));\n\t\t}\n\t\tcatch (Exception e)\n\t\t{\n\t\t\tcleanupTemp(in_options);\n\t\t\tthrow new CSException(\"Could not delete git remnants.\", e);\n\t\t}\n\t}\n\t/**\n\t * Copies the project to the output directory.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param in_options - The options with which to create the new project.\n\t */\n\tprivate static void copyToOutput(Options in_options) throws CSException\n\t{\n\t\tString tempDirectoryPath = StringUtils.standardiseDirectoryPath(in_options.m_outputDirectory + k_tempDirectory);\n\t\tString tempProjectDirectory = StringUtils.standardiseDirectoryPath(tempDirectoryPath + k_templateProjectName);\n\t\tString outputProjectDirectory = StringUtils.standardiseDirectoryPath(in_options.m_outputDirectory + in_options.m_projectName);\n\t\t\n\t\tLogging.logVerbose(\"Copying project to output directory: \" + outputProjectDirectory);\n\t\t\n\t\tList<String> ignore = new ArrayList<>();\n\t\tCollections.addAll(ignore, \"bin\", \"obj\");\n\t\tif (FileUtils.copyDirectory(tempProjectDirectory, outputProjectDirectory, ignore) == false)\n\t\t{\n\t\t\tcleanupTemp(in_options);\n\t\t\tthrow new CSException(\"Could not copy to output directory: \" + outputProjectDirectory);\n\t\t}\n\t}\n\t/**\n\t * Cleans up the temporary directory.\n\t *\n\t * @author Ian Copland\n\t * \n\t * @param in_options - The options with which to create the new project.\n\t */\n\tprivate static void cleanupTemp(Options in_options)\n\t{\n\t\tLogging.logVerbose(\"Deleting temp directory.\");\n\t\tString tempDirectoryPath = StringUtils.standardiseDirectoryPath(in_options.m_outputDirectory + k_tempDirectory);\n\t\tFileUtils.deleteDirectory(tempDirectoryPath);\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/CSProjectGenerator/src/com/chilliworks/chillisource/csprojectgenerator/Main.java",
    "content": "/**\n * Main.java\n * ChilliSource\n * Created by Ian Copland on 15/10/2014.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2014 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.csprojectgenerator;\n\nimport com.chilliworks.chillisource.coreutils.CSException;\nimport com.chilliworks.chillisource.coreutils.Logging;\nimport com.chilliworks.chillisource.coreutils.StringUtils;\nimport com.chilliworks.chillisource.coreutils.Logging.LoggingLevel;\n\n/**\n * Handles the entry point into the application. This manages the parsing of the input parameters and\n * passes them on to the rest of the tool.\n * \n * @author Ian Copland\n */\npublic final class Main\n{\n\tprivate static final String k_paramProjectName = \"--projectname\";\n\tprivate static final String k_paramPackageName = \"--packagename\";\n\tprivate static final String k_paramOutputDirectory = \"--output\";\n\tprivate static final String k_paramHelp = \"--help\";\n\n\tprivate static final String k_shortParamProjectName = \"-pr\";\n\tprivate static final String k_shortParamPackageName = \"-pa\";\n\tprivate static final String k_shortParamOutputDirectory = \"-o\";\n\tprivate static final String k_shortParamHelp= \"-h\";\n\t\n\t/**\n\t * The entry point into the application\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param The input arguments.\n\t */\n\tpublic static void main(String[] in_arguments) throws Exception \n\t{\n\t\tString[] arguments = Logging.start(in_arguments);\n\t\t\n\t\tif (arguments.length == 0)\n\t\t{\n\t\t\tprintHelpText();\n\t\t\treturn;\n\t\t}\n\t\t\n\t\tOptions options = new Options();\n\t\tfor (int i = 0; i < arguments.length; ++i)\n\t\t{\n\t\t\t//input\n\t\t\tif (arguments[i].equalsIgnoreCase(k_paramProjectName) == true || arguments[i].equalsIgnoreCase(k_shortParamProjectName) == true)\n\t\t\t{\n\t\t\t\tif (i+1 < arguments.length)\n\t\t\t\t\toptions.m_projectName = arguments[i+1];\n\t\t\t\telse\n\t\t\t\t\tLogging.logFatal(\"No project name provided!\");\n\t\t\t\ti++;\n\t\t\t}\n\t\t\t\n\t\t\t//template\n\t\t\telse if (arguments[i].equalsIgnoreCase(k_paramPackageName) == true || arguments[i].equalsIgnoreCase(k_shortParamPackageName) == true)\n\t\t\t{\n\t\t\t\tif (i+1 < arguments.length)\n\t\t\t\t\toptions.m_packageName = arguments[i+1];\n\t\t\t\telse\n\t\t\t\t\tLogging.logFatal(\"No package name provided!\");\n\t\t\t\ti++;\n\t\t\t}\n\t\t\t\n\t\t\t//output\n\t\t\telse if (arguments[i].equalsIgnoreCase(k_paramOutputDirectory) == true || arguments[i].equalsIgnoreCase(k_shortParamOutputDirectory) == true)\n\t\t\t{\n\t\t\t\tif (i+1 < arguments.length)\n\t\t\t\t\toptions.m_outputDirectory = StringUtils.standardiseDirectoryPath(arguments[i+1]);\n\t\t\t\telse\n\t\t\t\t\tLogging.logFatal(\"No output directory path provided!\");\n\t\t\t\ti++;\n\t\t\t}\n\t\t\t\n\t\t\t//help\n\t\t\telse if (arguments[i].equalsIgnoreCase(k_paramHelp) == true || arguments[i].equalsIgnoreCase(k_shortParamHelp) == true)\n\t\t\t{\n\t\t\t\tprintHelpText();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t\n\t\t\t//failure\n\t\t\telse\n\t\t\t{\n\t\t\t\tLogging.logFatal(\"Invalid parameter found: \" + arguments[i]);\n\t\t\t}\n\t\t}\n\t\t\n\t\tif (options.m_projectName.length() == 0 || options.m_packageName.length() ==0)\n\t\t{\n\t\t\tLogging.logFatal(\"Must provide project name, package name.\");\n\t\t}\n\t\t\n\t\ttry\n\t\t{\n\t\t\tCSProjectGenerator.generate(options);\n\t\t}\n\t\tcatch (CSException e)\n\t\t{\n\t\t\tLogging.logFatal(e.getMessage());\n\t\t}\n\t\t\n\t\tLogging.finish();\n\t}\n\t/**\n\t * Outputs help test for this tool. This will be displayed regardless of \n\t * the current logging level.\n\t *\n\t * @author Ian Copland\n\t */\n\tpublic static void printHelpText()\n\t{\n\t\tLogging.setLoggingLevel(LoggingLevel.VERBOSE);\n\t\tLogging.logVerbose(\"Usage: java -jar CSProjectGenerator.jar \" + k_paramProjectName + \" <project name> \" + k_paramPackageName + \" <package name> \" + k_paramOutputDirectory + \n\t\t\t\t\" <directory path> [\" + Logging.PARAM_LOGGING_LEVEL + \" <level>] [\" + k_paramHelp + \"]\");\n\t\tLogging.logVerbose(\"Parameters:\");\n\t\tLogging.logVerbose(\" \" + k_paramProjectName + \"(\" + k_shortParamProjectName + \"): The name of the project. This will be the name of the project directory on disk, as well as the default window or app name.\");\n\t\tLogging.logVerbose(\" \" + k_paramPackageName + \"(\" + k_shortParamPackageName + \"): The package name of the project on relevant platforms. This should be in the form 'ext.company.projectname'.\");\n\t\tLogging.logVerbose(\" \" + k_paramOutputDirectory + \"(\" + k_shortParamOutputDirectory + \"): [Optional] The path to the directory which the project will be created in. By default the project is created in the current working directory.\");\n\t\tLogging.logVerbose(\" \" + Logging.PARAM_LOGGING_LEVEL + \"(\" + Logging.SHORT_PARAM_LOGGING_LEVEL + \"): [Optional] The level of messages to log. Defaults to 'warning'.\");\n\t\tLogging.logVerbose(\" \" + k_paramHelp + \"(\" + k_shortParamHelp + \"): [Optional] Display this help message.\");\n\t\tLogging.logVerbose(\"Logging Levels:\");\n\t\tLogging.logVerbose(\" \" + Logging.LOGGING_LEVEL_NONE + \": No logging.\");\n\t\tLogging.logVerbose(\" \" + Logging.LOGGING_LEVEL_FATAL + \": Only log fatal errors.\");\n\t\tLogging.logVerbose(\" \" + Logging.LOGGING_LEVEL_ERROR + \": Only log errors.\");\n\t\tLogging.logVerbose(\" \" + Logging.LOGGING_LEVEL_WARNING + \": Log errors and warnings.\");\n\t\tLogging.logVerbose(\" \" + Logging.LOGGING_LEVEL_VERBOSE + \": Log all messages.\");\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/CSProjectGenerator/src/com/chilliworks/chillisource/csprojectgenerator/Options.java",
    "content": "/**\n * Options.java\n * ChilliSource\n * Created by Ian Copland on 15/10/2014.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2014 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.csprojectgenerator;\n\n/**\n * A container for options for the project generator.\n * \n * @author Ian Copland\n */\npublic final class Options\n{\n\tString m_projectName = \"\";\n\tString m_packageName = \"\";\n\tString m_outputDirectory = \"./\";\n}\n"
  },
  {
    "path": "Projects/Tools/CSTextBuilder/.classpath",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<classpath>\n\t<classpathentry kind=\"src\" path=\"src\"/>\n\t<classpathentry kind=\"con\" path=\"org.eclipse.jdt.launching.JRE_CONTAINER\"/>\n\t<classpathentry kind=\"lib\" path=\"lib/jxl.jar\"/>\n\t<classpathentry combineaccessrules=\"false\" kind=\"src\" path=\"/CoreUtils\"/>\n\t<classpathentry kind=\"output\" path=\"bin\"/>\n</classpath>\n"
  },
  {
    "path": "Projects/Tools/CSTextBuilder/.project",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<projectDescription>\n\t<name>CSTextBuilder</name>\n\t<comment></comment>\n\t<projects>\n\t</projects>\n\t<buildSpec>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.jdt.core.javabuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t</buildSpec>\n\t<natures>\n\t\t<nature>org.eclipse.jdt.core.javanature</nature>\n\t</natures>\n</projectDescription>\n"
  },
  {
    "path": "Projects/Tools/CSTextBuilder/Manifest/man.txt",
    "content": "Manifest-Version: 1.0\r\nMain-Class: com.chillisource.cstextbuilder.Main\r\n\r\n"
  },
  {
    "path": "Projects/Tools/CSTextBuilder/src/com/chilliworks/chillisource/cstextbuilder/CSTextBuilder.java",
    "content": "/**\r\n * CSTextBuilder.java\r\n * ChilliSource\r\n * Created by Robert Henning on 15/01/2013.\r\n * \r\n * The MIT License (MIT)\r\n * \r\n * Copyright (c) 2013 Tag Games Limited\r\n * \r\n * Permission is hereby granted, free of charge, to any person obtaining a copy\r\n * of this software and associated documentation files (the \"Software\"), to deal\r\n * in the Software without restriction, including without limitation the rights\r\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\n * copies of the Software, and to permit persons to whom the Software is\r\n * furnished to do so, subject to the following conditions:\r\n * \r\n * The above copyright notice and this permission notice shall be included in\r\n * all copies or substantial portions of the Software.\r\n * \r\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r\n * THE SOFTWARE.\r\n */\r\n\r\npackage com.chilliworks.chillisource.cstextbuilder;\r\n\r\nimport java.io.File;\r\nimport java.util.ArrayList;\r\nimport java.util.List;\r\n\r\nimport org.json.JSONObject;\r\n\r\nimport com.chilliworks.chillisource.coreutils.FileUtils;\r\nimport com.chilliworks.chillisource.coreutils.Logging;\r\nimport com.chilliworks.chillisource.coreutils.Logging.LoggingLevel;\r\n\r\nimport jxl.Cell;\r\nimport jxl.CellType;\r\nimport jxl.Sheet;\r\nimport jxl.Workbook;\r\nimport jxl.WorkbookSettings;\r\n\r\n/**\r\n * Builds localised text from the given excel sheet.\r\n * \r\n * @author R Henning\r\n */\r\npublic class CSTextBuilder\r\n{\r\n\tprivate static final int k_versionNumber = 1;\r\n\tprivate static final String\tk_constantColumnHeading = \"Constant\";\r\n\tprivate static final String k_excludeColumnHeading = \"Exclude\";\r\n\tprivate static Workbook m_workbook = null;\r\n\t\r\n\t/**\r\n\t * Run the text extractor.\r\n\t * \r\n\t * @author R Henning\r\n\t * \r\n\t * @param The options.\r\n\t */\r\n\tpublic static void run(ExtractTextOptions in_options)\r\n\t{\r\n\t\ttry\r\n\t\t{\r\n\t\t\topenExcelFile(in_options);\r\n\t\t\t\r\n\t\t\tint dwSheetIndex = 0;\r\n\t\t\tSheet CurrentSheet = openSheet(dwSheetIndex);\r\n\t\t\tint dwConstantColumn = getColumn(CurrentSheet, k_constantColumnHeading);\r\n\t\t\tif(!validateMandatoryColumn(dwConstantColumn, k_constantColumnHeading, true))\r\n\t\t\t\treturn;\r\n\t\t\t\r\n\t\t\tint dwExcludeColumn = getColumn(CurrentSheet, k_excludeColumnHeading);\r\n\t\t\tif(!validateMandatoryColumn(dwExcludeColumn, k_excludeColumnHeading, true))\r\n\t\t\t\treturn;\r\n\t\t\t\r\n\t\t\tint dwTextColumn = getTextColumnForLanguage(CurrentSheet, in_options.m_language);\r\n\t\t\tList<String> textIds = extractTextIds(CurrentSheet, dwConstantColumn, dwExcludeColumn);\r\n\t\t\tList<String> texts = extractText(CurrentSheet, dwTextColumn, dwExcludeColumn);\r\n\t\t\t\r\n\t\t\twriteJson(in_options.m_outputFilePath, textIds, texts);\r\n\t\t}\r\n\t\tcatch(Exception e)\r\n\t\t{\r\n\t\t\tLogging.logFatal(\"Exception occured. \"+e.getMessage());\r\n\t\t}\r\n\t\tfinally\r\n\t\t{\r\n\t\t\tcloseExcelFile();\r\n\t\t\tLogging.logVerbose(\"\\\\o/ Text extraction complete. Have a nice day. \\\\o/\");\r\n\t\t}\r\n\t}\r\n\t/**\r\n\t * @author R Henning\r\n\t * \r\n\t * @param The tool options.\r\n\t */\r\n\tprivate static void openExcelFile(ExtractTextOptions in_options) throws Exception\r\n\t{\r\n\t\tFile f = new File(in_options.m_inputFilePath);\r\n\t\tLogging.logVerbose(\"Input file path is \\\"\"+f.getCanonicalPath()+\"\\\"\");\r\n        \r\n        if(!f.exists())\r\n        {\r\n        \tLogging.logFatal(\"Input file \\\"\"+in_options.m_inputFilePath+\"\\\" does not exist.\");\r\n        }\r\n\r\n        if(!f.isFile())\r\n        {\r\n        \tLogging.logFatal(\"Input file \\\"\"+in_options.m_inputFilePath+\"\\\" is not a valid file.\");\r\n        }\r\n\r\n        if(!f.canRead())\r\n        {\r\n        \tLogging.logFatal(\"Input file \\\"\"+in_options.m_inputFilePath+\"\\\" cannot be read.\");\r\n        }\r\n\r\n        Logging.logVerbose(\"Opening workbook...\");\r\n        WorkbookSettings ws = new WorkbookSettings();\r\n        if (Logging.getLoggingLevel() == LoggingLevel.ERROR || Logging.getLoggingLevel() == LoggingLevel.FATAL || Logging.getLoggingLevel() == LoggingLevel.NONE)\r\n        {\r\n        \tws.setSuppressWarnings(true);\r\n        }\r\n        ws.setEncoding(\"Cp1252\");\r\n        m_workbook = Workbook.getWorkbook(f, ws);\r\n\t}\r\n\t/**\r\n\t * @author R Henning\r\n\t * \r\n\t * @param The sheet to open.\r\n\t * \r\n\t * @return The output sheet.\r\n\t */\r\n\tprivate static Sheet openSheet(int in_sheet)\r\n\t{\r\n\t\tSheet CurrentSheet = null;\r\n\t\t\r\n\t\ttry\r\n        {\r\n            Logging.logVerbose(\"Opening sheet \"+in_sheet);\r\n            CurrentSheet = m_workbook.getSheet(in_sheet);\r\n        }\r\n        catch(IndexOutOfBoundsException ioobe)\r\n        {\r\n            Logging.logFatal(\"Exception trying to open sheet \"+in_sheet+\". \"+ioobe.getMessage());\r\n        }\r\n\t\t\r\n\t\treturn CurrentSheet;\r\n\t}\r\n\t/**\r\n\t * @author R Henning\r\n\t * \r\n\t * @param The sheet.\r\n\t * @param The heading.\r\n\t * \r\n\t * @return The column.\r\n\t */\r\n\tprivate static int getColumn(Sheet in_sheet, String in_heading) throws Exception\r\n    {\r\n    \tCell HeadingCell;\r\n    \tint dwColumn = -1;\r\n    \t\r\n    \tif((in_sheet == null) || (in_heading == null))\r\n    \t{\r\n    \t\tLogging.logFatal(\"Unable to get column with heading \\\"\"+in_heading+\"\\\"\");\r\n    \t}\r\n\r\n    \tif((in_heading != null) && (in_heading != \"\"))\r\n    \t{\r\n\t\t\tHeadingCell = in_sheet.findCell(in_heading);\r\n\t\t\tif(null != HeadingCell)\r\n\t\t\t\tdwColumn = HeadingCell.getColumn();\r\n    \t}\r\n    \t\r\n    \tif(dwColumn != -1)\r\n    \t\tLogging.logVerbose(\"Found heading \\\"\"+in_heading+\"\\\" at column \"+dwColumn);\r\n    \telse\r\n    \t\tLogging.logVerbose(\"Unable to find heading \\\"\"+in_heading+\"\\\"\");\r\n    \t\r\n    \treturn dwColumn;\r\n    }\r\n\t/**\r\n\t * @author R Henning\r\n\t * \r\n\t * @param The column.\r\n\t * @param The heading.\r\n\t * @param Whether or not to log errors.\r\n\t * \r\n\t * @return Whether or not the heading is valid.\r\n\t */\r\n\tprivate static boolean validateMandatoryColumn(int in_column, String in_heading, boolean in_logError)\r\n\t{\r\n\t\tif(-1 == in_column)\r\n\t\t{\r\n\t\t\tif(in_logError)\r\n\t\t\t\tLogging.logError(\"Missing mandatory column heading \\\"\"+in_heading+\"\\\"\");\r\n\t\t\treturn false;\r\n\t\t}\r\n\t\t\r\n\t\treturn true;\r\n\t}\r\n\t/**\r\n\t * @author R Henning\r\n\t * \r\n\t * @param The sheet.\r\n\t * @param The Language.\r\n\t * \r\n\t * @return The text column.\r\n\t */\r\n\tprivate static int getTextColumnForLanguage(Sheet in_sheet, String in_language) throws Exception\r\n\t{\r\n\t\tint dwTextColumn = getColumn(in_sheet, in_language);\r\n\t\tif(!validateMandatoryColumn(dwTextColumn, in_language, false))\r\n\t\t{\r\n\t\t\tdwTextColumn = getColumn(in_sheet, in_language.toLowerCase());\r\n\t\t\tif(!validateMandatoryColumn(dwTextColumn, in_language, false))\r\n\t\t\t{\r\n\t\t\t\tdwTextColumn = getColumn(in_sheet, in_language.toUpperCase());\r\n\t\t\t\tif(!validateMandatoryColumn(dwTextColumn, in_language, false))\r\n\t\t\t\t{\r\n\t\t\t\t\tLogging.logFatal(\"Unable to get language column for \\\"\"+in_language+\"\\\"\");\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\t\r\n\t\treturn dwTextColumn;\r\n\t}\r\n\t/**\r\n\t * @author R Henning\r\n\t * \r\n\t * @param The sheet.\r\n\t * @param The text column.\r\n\t * @param The exclude column.\r\n\t * \r\n\t * @return The output buffer of ids.\r\n\t */\r\n\tprivate static List<String> extractTextIds(Sheet in_sheet, int in_constantColumn, int in_excludeColumn)\r\n\t{\r\n\t\tList<String> output = new ArrayList<String>();\r\n\t\t\r\n\t\tint dwRowCount = in_sheet.getRows();\r\n\t\tfor(int dwRow = 1; dwRow < dwRowCount; dwRow++)\r\n\t\t{\r\n\t\t\tCell CurrentCell = in_sheet.getCell(in_excludeColumn, dwRow);\r\n    \t\tif(CurrentCell.getType() != CellType.EMPTY)\r\n    \t\t\tcontinue;\r\n    \t\t\r\n    \t\tCurrentCell = in_sheet.getCell(in_constantColumn, dwRow);\r\n\t\t\tString strTextIdString = CurrentCell.getContents().trim();\r\n\t\t\tif((null == strTextIdString) || (\"\" == strTextIdString))\r\n\t\t\t\tstrTextIdString = \"EMPTY_TEXT_ID\";\r\n\t\t\t\r\n\t\t\toutput.add(strTextIdString);\r\n\t\t}\r\n\t\t\r\n\t\treturn output;\r\n\t}\r\n\t/**\r\n\t * @author R Henning\r\n\t * \r\n\t * @param The sheet.\r\n\t * @param The text column.\r\n\t * @param The exclude column.\r\n\t * \r\n\t * @return The output buffer of strings.\r\n\t */\r\n\tprivate static List<String> extractText(Sheet in_sheet, int in_textColumn, int in_excludeColumn) throws Exception\r\n\t{\r\n\t\tList<String> output = new ArrayList<String>();\r\n\t\t\r\n\t\tint dwRowCount = in_sheet.getRows();\r\n\t\tfor(int dwRow = 1; dwRow < dwRowCount; dwRow++)\r\n\t\t{\r\n\t\t\tCell CurrentCell = in_sheet.getCell(in_excludeColumn, dwRow);\r\n    \t\tif(CurrentCell.getType() != CellType.EMPTY)\r\n    \t\t\tcontinue;\r\n    \t\t\r\n    \t\tCurrentCell = in_sheet.getCell(in_textColumn, dwRow);\r\n\t\t\tString strTextString = CurrentCell.getContents();\r\n\t\t\tif((null == strTextString) || (\"\" == strTextString))\r\n\t\t\t\tstrTextString = \"EMPTY TEXT\";\r\n\t\t\t\r\n\t\t\toutput.add(strTextString);\r\n\t\t}\r\n\t\t\r\n\t\treturn output;\r\n\t}\r\n\t/**\r\n\t * Closes the excel file if it is open.\r\n\t * \r\n\t * @author R Henning\r\n\t */\r\n\tprivate static void closeExcelFile()\r\n\t{\r\n\t\ttry\r\n\t\t{\r\n\t\t\tif(m_workbook != null)\r\n\t        {\r\n\t\t\t\tLogging.logVerbose(\"Closing workbook...\");\r\n\t            m_workbook.close();\r\n\t            m_workbook = null;\r\n\t        }\r\n\t\t}\r\n\t\tcatch(Exception e)\r\n\t\t{\r\n\t\t\tLogging.logFatal(\"Exception closing file. \"+e.getMessage());\r\n\t\t}\r\n\t}\r\n\t/**\r\n\t * Outputs the Id's and Strings as JSON key-value pairs.\r\n\t * \r\n\t * @author Ian Copland\r\n\t * \r\n\t * @param The output file path.\r\n\t * @param The list of text Ids.\r\n\t * @param The list of text.\r\n\t */\r\n\tprivate static void writeJson(String in_filePath, List<String> in_textIds, List<String> in_texts)\r\n\t{\r\n\t\tif (in_textIds.size() != in_texts.size())\r\n\t\t{\r\n\t\t\tLogging.logFatal(\"Text and Id count's are not the same!\");\r\n\t\t}\r\n\t\t\r\n\t\tJSONObject jsonRoot = new JSONObject();\r\n\t\tjsonRoot.put(\"Version\", k_versionNumber);\r\n\t\t\r\n\t\tJSONObject jsonText = new JSONObject();\r\n\t\tfor (int i = 0; i < in_textIds.size(); ++i)\r\n\t\t{\r\n\t\t\tjsonText.put(in_textIds.get(i), in_texts.get(i));\r\n\t\t}\r\n\t\tjsonRoot.put(\"Text\", jsonText);\r\n\t\t\r\n\t\tString output = jsonRoot.toString(2);\r\n\t\tif (FileUtils.writeFile(in_filePath, output) == false)\r\n\t\t{\r\n\t\t\tLogging.logFatal(\"Failed to write file: \" + in_filePath);\r\n\t\t}\r\n\t}\r\n}\r\n"
  },
  {
    "path": "Projects/Tools/CSTextBuilder/src/com/chilliworks/chillisource/cstextbuilder/ExtractTextOptions.java",
    "content": "/**\r\n * ExtractTextOptions.java\r\n * ChilliSource\r\n * Created by Robert Henning on 15/01/2013.\r\n * \r\n * The MIT License (MIT)\r\n * \r\n * Copyright (c) 2013 Tag Games Limited\r\n * \r\n * Permission is hereby granted, free of charge, to any person obtaining a copy\r\n * of this software and associated documentation files (the \"Software\"), to deal\r\n * in the Software without restriction, including without limitation the rights\r\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\n * copies of the Software, and to permit persons to whom the Software is\r\n * furnished to do so, subject to the following conditions:\r\n * \r\n * The above copyright notice and this permission notice shall be included in\r\n * all copies or substantial portions of the Software.\r\n * \r\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r\n * THE SOFTWARE.\r\n */\r\n\r\npackage com.chilliworks.chillisource.cstextbuilder;\r\n\r\npublic class ExtractTextOptions\r\n{\r\n\tpublic String m_inputFilePath = new String();\r\n\tpublic String m_outputFilePath = new String();\r\n\tpublic String m_language = new String();\r\n}\r\n"
  },
  {
    "path": "Projects/Tools/CSTextBuilder/src/com/chilliworks/chillisource/cstextbuilder/Main.java",
    "content": "/**\r\n * Main.java\r\n * ChilliSource\r\n * Created by Robert Henning on 15/01/2013.\r\n * \r\n * The MIT License (MIT)\r\n * \r\n * Copyright (c) 2013 Tag Games Limited\r\n * \r\n * Permission is hereby granted, free of charge, to any person obtaining a copy\r\n * of this software and associated documentation files (the \"Software\"), to deal\r\n * in the Software without restriction, including without limitation the rights\r\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\n * copies of the Software, and to permit persons to whom the Software is\r\n * furnished to do so, subject to the following conditions:\r\n * \r\n * The above copyright notice and this permission notice shall be included in\r\n * all copies or substantial portions of the Software.\r\n * \r\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r\n * THE SOFTWARE.\r\n */\r\n\r\npackage com.chilliworks.chillisource.cstextbuilder;\r\n\r\nimport com.chilliworks.chillisource.coreutils.Logging;\r\nimport com.chilliworks.chillisource.coreutils.StringUtils;\r\nimport com.chilliworks.chillisource.coreutils.Logging.LoggingLevel;\r\n\r\npublic class Main\r\n{\r\n\tprivate static final String k_paramInput = \"--input\";\r\n\tprivate static final String k_paramInputShort = \"-i\";\r\n\tprivate static final String k_paramOutput = \"--output\";\r\n\tprivate static final String k_paramOutputShort = \"-o\";\r\n\tprivate static final String k_paramLanguage = \"--language\";\r\n\tprivate static final String k_paramLanguageShort = \"-l\";\r\n\tprivate static final String k_paramHelp = \"--help\";\r\n\tprivate static final String k_paramHelpShort = \"-h\";\r\n\t\r\n\tpublic static void main(String[] in_arguments) throws Exception\r\n\t{\r\n\t\tString[] arguments = Logging.start(in_arguments);\r\n\t\tLogging.logVerbose(\"Text Extractor; Version 1.3.\");\r\n\t\t\r\n\t\tif (arguments.length == 0)\r\n\t\t{\r\n\t\t\tprintHelpText();\r\n\t\t\treturn;\r\n\t\t}\r\n\t\t\r\n\t\tExtractTextOptions options = new ExtractTextOptions();\r\n\t\tfor (int i = 0; i < arguments.length; ++i)\r\n\t\t{\r\n\t\t\t//input\r\n\t\t\tif (arguments[i].equalsIgnoreCase(k_paramInput) == true || arguments[i].equalsIgnoreCase(k_paramInputShort) == true)\r\n\t\t\t{\r\n\t\t\t\tif (i+1 < arguments.length)\r\n\t\t\t\t\toptions.m_inputFilePath = StringUtils.standardiseFilePath(arguments[i+1]);\r\n\t\t\t\telse\r\n\t\t\t\t\tLogging.logFatal(\"No input file path provided!\");\r\n\t\t\t\ti++;\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\t//output\r\n\t\t\telse if (arguments[i].equalsIgnoreCase(k_paramOutput) == true || arguments[i].equalsIgnoreCase(k_paramOutputShort) == true)\r\n\t\t\t{\r\n\t\t\t\tif (i+1 < arguments.length)\r\n\t\t\t\t\toptions.m_outputFilePath = StringUtils.standardiseFilePath(arguments[i+1]);\r\n\t\t\t\telse\r\n\t\t\t\t\tLogging.logFatal(\"No output file path provided!\");\r\n\t\t\t\ti++;\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\t//template\r\n\t\t\telse if (arguments[i].equalsIgnoreCase(k_paramLanguage) == true || arguments[i].equalsIgnoreCase(k_paramLanguage) == true)\r\n\t\t\t{\r\n\t\t\t\tif (i+1 < arguments.length)\r\n\t\t\t\t\toptions.m_language = arguments[i+1];\r\n\t\t\t\telse\r\n\t\t\t\t\tLogging.logFatal(\"No langauge provided!\");\r\n\t\t\t\ti++;\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\t//help\r\n\t\t\telse if (arguments[i].equalsIgnoreCase(k_paramHelp) == true || arguments[i].equalsIgnoreCase(k_paramHelpShort) == true)\r\n\t\t\t{\r\n\t\t\t\tprintHelpText();\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\t//failure\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tLogging.logFatal(\"Invalid parameter found: \" + arguments[i]);\r\n\t\t\t}\r\n\t\t}\r\n\t\t\r\n\t\tif (options.m_inputFilePath.length() == 0 || options.m_outputFilePath.length() ==0 || options.m_language.length() == 0)\r\n\t\t{\r\n\t\t\tLogging.logFatal(\"Must provide input and output file paths and a language.\");\r\n\t\t}\r\n\t\t\r\n\t\tCSTextBuilder.run(options);\r\n\t\t\r\n\t\tLogging.finish();\r\n\t}\r\n\t//------------------------------------------------------\r\n\t/// Print Help Text\r\n\t///\r\n\t/// Prints out instructions on how to use this tool.\r\n\t//------------------------------------------------------\r\n\tprivate static void printHelpText()\r\n\t{\r\n\t\tLogging.setLoggingLevel(LoggingLevel.VERBOSE);\r\n\t\tLogging.logVerbose(\"Usage: java -jar CSTextBuilder.jar \" + k_paramInput + \" <file path> \" + k_paramOutput + \" <file path> \" + k_paramLanguage + \" <language code> [\" + \r\n\t\t\t\tLogging.PARAM_LOGGING_LEVEL + \" <level>] [\" + k_paramHelp + \"]\");\r\n\t\tLogging.logVerbose(\"Parameters:\");\r\n\t\tLogging.logVerbose(\" \" + k_paramInput + \"(\" + k_paramInputShort + \"): The file path to the source .xls file.\");\r\n\t\tLogging.logVerbose(\" \" + k_paramOutput + \"(\" + k_paramOutputShort + \"): The output file path.\");\r\n\t\tLogging.logVerbose(\" \" + k_paramLanguage + \"(\" + k_paramLanguageShort + \"): Name of language column in source .xls to extract text from.\");\r\n\t\tLogging.logVerbose(\" \" + Logging.PARAM_LOGGING_LEVEL + \"(\" + Logging.SHORT_PARAM_LOGGING_LEVEL + \"): The level of message to log to console.\");\r\n\t\tLogging.logVerbose(\" \" + k_paramHelp + \"(\" + k_paramHelpShort + \"): Print this help message.\");\r\n\t\tLogging.logVerbose(\"Logging Levels:\");\r\n\t\tLogging.logVerbose(\" \" + Logging.LOGGING_LEVEL_NONE + \": No logging.\");\r\n\t\tLogging.logVerbose(\" \" + Logging.LOGGING_LEVEL_FATAL + \": Only log fatal errors.\");\r\n\t\tLogging.logVerbose(\" \" + Logging.LOGGING_LEVEL_ERROR + \": Only log errors.\");\r\n\t\tLogging.logVerbose(\" \" + Logging.LOGGING_LEVEL_WARNING + \": Log errors and warnings.\");\r\n\t\tLogging.logVerbose(\" \" + Logging.LOGGING_LEVEL_VERBOSE + \": Log all messages.\");\r\n\t}\r\n}\r\n"
  },
  {
    "path": "Projects/Tools/CkTool/.classpath",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<classpath>\n\t<classpathentry kind=\"src\" path=\"src\"/>\n\t<classpathentry kind=\"con\" path=\"org.eclipse.jdt.launching.JRE_CONTAINER\"/>\n\t<classpathentry combineaccessrules=\"false\" kind=\"src\" path=\"/CoreUtils\"/>\n\t<classpathentry kind=\"output\" path=\"bin\"/>\n</classpath>\n"
  },
  {
    "path": "Projects/Tools/CkTool/.project",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<projectDescription>\n\t<name>CkTool</name>\n\t<comment></comment>\n\t<projects>\n\t</projects>\n\t<buildSpec>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.jdt.core.javabuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t</buildSpec>\n\t<natures>\n\t\t<nature>org.eclipse.jdt.core.javanature</nature>\n\t</natures>\n</projectDescription>\n"
  },
  {
    "path": "Projects/Tools/CkTool/Manifest.txt",
    "content": "Manifest-Version: 1.0\r\nMain-Class: com.chilliworks.chillisource.cktool.Main\r\n\r\n"
  },
  {
    "path": "Projects/Tools/CkTool/src/com/chilliworks/chillisource/cktool/CkTool.java",
    "content": "/**\n * CkTool.java\n * ChilliSource\n * Created by Ian Copland on 20/01/2015.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2015 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.cktool;\n\nimport java.io.File;\nimport java.net.URISyntaxException;\nimport java.security.CodeSource;\nimport java.util.LinkedList;\nimport java.util.List;\n\nimport com.chilliworks.chillisource.coreutils.CSException;\nimport com.chilliworks.chillisource.coreutils.ExternalProcess;\nimport com.chilliworks.chillisource.coreutils.Logging;\nimport com.chilliworks.chillisource.coreutils.StringUtils;\n\n/**\n * A basic wrapper arround the Cricket Audio cktool. This is used to make it easier\n * to use the tool accross different platforms.\n * \n * @author Ian Copland\n */\npublic final class CkTool \n{\n\t/**\n\t * Executes CkTool using the given options.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param in_options - The options.\n\t * \n\t * @throws CSException - Any exception that occurs while executing the CkTool.\n\t */\n\tpublic static void Execute(Options in_options) throws CSException\n\t{\n\t\tList<String> commandList = BuildCommandList(in_options);\n\t\tExternalProcess process = new ExternalProcess(commandList);\n\t\t\n\t\tList<String> messages = process.getMessages();\n\t\tfor (String message : messages)\n\t\t{\n\t\t\tif (message.toLowerCase().startsWith(\"error:\") == true)\n\t\t\t{\n\t\t\t\tthrow new CSException(message.substring(6));\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tLogging.logVerbose(message);\n\t\t\t}\n\t\t}\n\t}\n\t/**\n\t * Builds the list of commands to execute from the given options.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @return Directory path to jar folder\n\t * \n\t * @throws CSException - Any exception that occurs while building the command list.\n\t */\n\tprivate static List<String> BuildCommandList(Options in_options) throws CSException\n\t{\n\t\tLinkedList<String> commands = new LinkedList<String>();\n\t\tcommands.add(GetExecutableFilePath());\n\t\tcommands.add(ActionToString(in_options.m_action));\n\t\t\n\t\tif (Logging.getLoggingLevel() == Logging.LoggingLevel.VERBOSE)\n\t\t{\n\t\t\tcommands.add(\"-verbose\");\n\t\t}\n\t\t\n\t\tif (in_options.m_action == Options.Action.BUILD_BANK_SINGLE)\n\t\t{\n\t\t\tcommands.add(\"-single\");\n\t\t}\n\t\t\n\t\tif (in_options.m_format.isEmpty() == false)\n\t\t{\n\t\t\tcommands.add(\"-format\");\n\t\t\tcommands.add(in_options.m_format);\n\t\t}\n\t\t\n\t\tif (in_options.m_volume.isEmpty() == false)\n\t\t{\n\t\t\tcommands.add(\"-volume\");\n\t\t\tcommands.add(in_options.m_volume);\n\t\t}\n\t\t\n\t\tif (in_options.m_pan.isEmpty() == false)\n\t\t{\n\t\t\tcommands.add(\"-pan\");\n\t\t\tcommands.add(in_options.m_pan);\n\t\t}\n\t\t\n\t\tif (in_options.m_loopStart.isEmpty() == false)\n\t\t{\n\t\t\tcommands.add(\"-loopStart\");\n\t\t\tcommands.add(in_options.m_loopStart);\n\t\t}\n\t\t\n\t\tif (in_options.m_loopEnd.isEmpty() == false)\n\t\t{\n\t\t\tcommands.add(\"-loopEnd\");\n\t\t\tcommands.add(in_options.m_loopEnd);\n\t\t}\n\t\t\n\t\tif (in_options.m_loopCount.isEmpty() == false)\n\t\t{\n\t\t\tcommands.add(\"-loopCount\");\n\t\t\tcommands.add(in_options.m_loopCount);\n\t\t}\n\t\t\n\t\tcommands.add(StringUtils.standardiseFilePath(in_options.m_inputFilePath));\n\t\tcommands.add(StringUtils.standardiseFilePath(in_options.m_outputFilePath));\n\t\treturn commands;\n\t}\n\t/**\n\t * Get the directory path that contains this jar file. Note: This REQUIRES that the \n\t * jar be exported as a normal jar, NOT a runnable jar, otherwise it won't work.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @return The directory path to jar folder.\n\t * \n\t * @throws CSException - An exception thrown if the directory path cannot be calculated. \n\t */\n\tprivate static String getJarDirectoryPath() throws CSException\n\t{\n\t\tString jarDir = \"\";\n\t\t\n\t\tCodeSource codeSource = CkTool.class.getProtectionDomain().getCodeSource();\n\t\tFile jarFile;\n\t\ttry \n\t\t{\n\t\t\tjarFile = new File(codeSource.getLocation().toURI().getPath());\n\t\t\tjarDir = jarFile.getParentFile().getPath() + File.separator;\n\t\t} \n\t\tcatch (URISyntaxException e) \n\t\t{\n\t\t\tthrow new CSException(\"An exception occurred while calculating the jar directory path().\", e);\n\t\t}\n\t\t \n\t\treturn jarDir;\n\t}\n\t/**\n\t * Returns the file path to the executable.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @return The path of the exectable.\n\t * \n\t * @throws CSException - An exception thrown if the file path cannot be calculated.\n\t */\n\tprivate static String GetExecutableFilePath() throws CSException\n\t{\n\t\tString strExecutableName = \"\";\n\t\t\n\t\ttry\n\t\t{\n\t\t\t//get the path to the jar\n\t\t\tString strPathToHere = getJarDirectoryPath();\n\t\t\t\n\t\t\t//get which version of the executable should be used.\n\t\t\tString strOS = System.getProperty(\"os.name\");\n\t\t\t\n\t\t\tif (strOS.startsWith(\"Windows\") == true)\n\t\t\t{\n\t\t\t\tstrExecutableName = strPathToHere + \"CkTool\\\\Windows\\\\cktool.exe\";\n\t\t\t}\n\t\t\telse if (strOS.startsWith(\"Mac\") == true)\n\t\t\t{\n\t\t\t\tstrExecutableName = strPathToHere + \"CkTool/OSX/cktool\";\n\t\t\t}\n\t\t\telse if (strOS.startsWith(\"Linux\") == true)\n\t\t\t{\n\t\t\t\tstrExecutableName = strPathToHere + \"CkTool/Linux/cktool\";\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tLogging.logFatal(\"This platform is not supported!\");\n\t\t\t}\n\t\t}\n\t\tcatch (Exception e)\n\t\t{\n\t\t\tthrow new CSException(\"Exception occurred in GetExecutableName()\", e);\n\t\t}\n\t\t\n\t\treturn strExecutableName;\n\t}\n\t/**\n\t * Converts the given action to a string.\n\t * \n\t * @author Ian Copland\n\t *\n\t * @param in_action - The action to convert to string.\n\t * \n\t * @return The action as a string.\n\t * \n\t * @throws CSException - An exception thrown if the action cannot be converted to string.\n\t */\n\tprivate static String ActionToString(Options.Action in_action) throws CSException\n\t{\n\t\tswitch (in_action)\n\t\t{\n\t\tcase BUILD_BANK:\n\t\tcase BUILD_BANK_SINGLE:\n\t\t\treturn \"buildbank\";\n\t\tcase BUILD_STREAM:\n\t\t\treturn \"buildstream\";\n\t\tdefault:\n\t\t\tthrow new CSException(\"Invalid action!\");\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/CkTool/src/com/chilliworks/chillisource/cktool/Main.java",
    "content": "/**\n * Main.java\n * ChilliSource\n * Created by Ian Copland on 20/01/2015.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2015 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.cktool;\n\nimport com.chilliworks.chillisource.coreutils.CSException;\nimport com.chilliworks.chillisource.coreutils.Logging;\nimport com.chilliworks.chillisource.coreutils.Logging.LoggingLevel;\n\n/**\n * A static class that provides the main entry point into the application.\n * \n * @author Ian Copland\n */\npublic final class Main \n{\n\tprivate static final String PARAM_ACTION = \"--action\";\n\tprivate static final String PARAM_INPUT = \"--input\";\n\tprivate static final String PARAM_OUTPUT = \"--output\";\n\tprivate static final String PARAM_FORMAT = \"--format\";\n\tprivate static final String PARAM_VOLUME = \"--volume\";\n\tprivate static final String PARAM_PAN = \"--pan\";\n\tprivate static final String PARAM_LOOP_START = \"--loopstart\";\n\tprivate static final String PARAM_LOOP_END = \"--loopend\";\n\tprivate static final String PARAM_LOOP_COUNT = \"--loopcount\";\n\tprivate static final String PARAM_HELP = \"--help\";\n\t\n\tprivate static final String SHORT_PARAM_ACTION = \"-a\";\n\tprivate static final String SHORT_PARAM_INPUT = \"-i\";\n\tprivate static final String SHORT_PARAM_OUTPUT = \"-o\";\n\tprivate static final String SHORT_PARAM_FORMAT = \"-f\";\n\tprivate static final String SHORT_PARAM_VOLUME = \"-v\";\n\tprivate static final String SHORT_PARAM_PAN = \"-p\";\n\tprivate static final String SHORT_PARAM_LOOP_START = \"-ls\";\n\tprivate static final String SHORT_PARAM_LOOP_END = \"-le\";\n\tprivate static final String SHORT_PARAM_LOOP_COUNT = \"-lc\";\n\tprivate static final String SHORT_PARAM_HELP = \"-h\";\n\t\n\tprivate static final String ACTION_BUILD_BANK = \"buildbank\";\n\tprivate static final String ACTION_BUILD_BANK_SINGLE = \"buildbanksingle\";\n\tprivate static final String ACTION_BUILD_STREAM = \"buildstream\";\n\t\n\t/**\n\t * The entry point into the application.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param in_arguments - The argument list.\n\t */\n\tpublic static void main(String[] in_arguments)\n\t{\t\n\t\t//setup the logger.\n\t\tString[] arguments = Logging.start(in_arguments);\n\t\t\n\t\t//check the number of arguments make sense.\n\t\tif (arguments.length == 0)\n\t\t{\n\t\t\tPrintHelpText();\n\t\t\treturn;\n\t\t}\n\t\t\n\t\t//gather up commands\n\t\tOptions options = new Options();\n\t\tfor (int i = 0; i < arguments.length; ++i)\n\t\t{\n\t\t\t//Action param\n\t\t\tif (arguments[i].equalsIgnoreCase(PARAM_ACTION) == true || arguments[i].equalsIgnoreCase(SHORT_PARAM_ACTION) == true)\n\t\t\t{\n\t\t\t\tif (i+1 < arguments.length)\n\t\t\t\t\toptions.m_action = ParseAction(arguments[i+1]);\n\t\t\t\telse\n\t\t\t\t\tLogging.logFatal(\"No action provided!\");\n\t\t\t\t++i;\n\t\t\t}\n\t\t\t\n\t\t\t//Input param\n\t\t\telse if (arguments[i].equalsIgnoreCase(PARAM_INPUT) == true || arguments[i].equalsIgnoreCase(SHORT_PARAM_INPUT) == true)\n\t\t\t{\n\t\t\t\tif (i+1 < arguments.length)\n\t\t\t\t\toptions.m_inputFilePath = arguments[i+1];\n\t\t\t\telse\n\t\t\t\t\tLogging.logFatal(\"No input file provided!\");\n\t\t\t\t++i;\n\t\t\t}\n\t\t\t\n\t\t\t//output param\n\t\t\telse if (arguments[i].equalsIgnoreCase(PARAM_OUTPUT) == true || arguments[i].equalsIgnoreCase(SHORT_PARAM_OUTPUT) == true)\n\t\t\t{\n\t\t\t\tif (i+1 < arguments.length)\n\t\t\t\t\toptions.m_outputFilePath = arguments[i+1];\n\t\t\t\telse\n\t\t\t\t\tLogging.logFatal(\"No output file provided!\");\n\t\t\t\t++i;\n\t\t\t}\n\t\t\t\n\t\t\t//format param\n\t\t\telse if (arguments[i].equalsIgnoreCase(PARAM_FORMAT) == true || arguments[i].equalsIgnoreCase(SHORT_PARAM_FORMAT) == true)\n\t\t\t{\n\t\t\t\tif (i+1 < arguments.length)\n\t\t\t\t\toptions.m_format = arguments[i+1];\n\t\t\t\telse\n\t\t\t\t\tLogging.logFatal(\"No format provided!\");\n\t\t\t\t++i;\n\t\t\t}\n\t\t\t\n\t\t\t//volume param\n\t\t\telse if (arguments[i].equalsIgnoreCase(PARAM_VOLUME) == true || arguments[i].equalsIgnoreCase(SHORT_PARAM_VOLUME) == true)\n\t\t\t{\n\t\t\t\tif (i+1 < arguments.length)\n\t\t\t\t\toptions.m_volume = arguments[i+1];\n\t\t\t\telse\n\t\t\t\t\tLogging.logFatal(\"No format provided!\");\n\t\t\t\t++i;\n\t\t\t}\n\t\t\t\n\t\t\t//pan param\n\t\t\telse if (arguments[i].equalsIgnoreCase(PARAM_PAN) == true || arguments[i].equalsIgnoreCase(SHORT_PARAM_PAN) == true)\n\t\t\t{\n\t\t\t\tif (i+1 < arguments.length)\n\t\t\t\t\toptions.m_pan = arguments[i+1];\n\t\t\t\telse\n\t\t\t\t\tLogging.logFatal(\"No pan provided!\");\n\t\t\t\t++i;\n\t\t\t}\n\t\t\t\n\t\t\t//loop start param\n\t\t\telse if (arguments[i].equalsIgnoreCase(PARAM_LOOP_START) == true || arguments[i].equalsIgnoreCase(SHORT_PARAM_LOOP_START) == true)\n\t\t\t{\n\t\t\t\tif (i+1 < arguments.length)\n\t\t\t\t\toptions.m_loopStart = arguments[i+1];\n\t\t\t\telse\n\t\t\t\t\tLogging.logFatal(\"No loop start provided!\");\n\t\t\t\t++i;\n\t\t\t}\n\t\t\t\n\t\t\t//loop end param\n\t\t\telse if (arguments[i].equalsIgnoreCase(PARAM_LOOP_END) == true || arguments[i].equalsIgnoreCase(SHORT_PARAM_LOOP_END) == true)\n\t\t\t{\n\t\t\t\tif (i+1 < arguments.length)\n\t\t\t\t\toptions.m_loopEnd = arguments[i+1];\n\t\t\t\telse\n\t\t\t\t\tLogging.logFatal(\"No loop end provided!\");\n\t\t\t\t++i;\n\t\t\t}\n\t\t\t\n\t\t\t//loop count param\n\t\t\telse if (arguments[i].equalsIgnoreCase(PARAM_LOOP_COUNT) == true || arguments[i].equalsIgnoreCase(SHORT_PARAM_LOOP_COUNT) == true)\n\t\t\t{\n\t\t\t\tif (i+1 < arguments.length)\n\t\t\t\t\toptions.m_loopCount = arguments[i+1];\n\t\t\t\telse\n\t\t\t\t\tLogging.logFatal(\"No loop count provided!\");\n\t\t\t\t++i;\n\t\t\t}\n\t\t\t\n\t\t\t//help param\n\t\t\telse if (arguments[i].equalsIgnoreCase(PARAM_HELP) == true || arguments[i].equalsIgnoreCase(SHORT_PARAM_HELP) == true)\n\t\t\t{\n\t\t\t\tPrintHelpText();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t\n\t\t\t//failure\n\t\t\telse\n\t\t\t{\n\t\t\t\tLogging.logFatal(\"Invalid argument found: \" + arguments[i]);\n\t\t\t}\n\t\t}\n\t\t\n\t\tValidateOptions(options);\n\t\t\n\t\ttry\n\t\t{\n\t\t\tCkTool.Execute(options);\n\t\t}\n\t\tcatch (CSException in_exception)\n\t\t{\n\t\t\tLogging.logFatal(in_exception.getMessage());\n\t\t}\n\n\t\tLogging.finish();\n\t}\n\t/**\n\t * Parses an action. If the given action string is not valid the app will terminate.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param in_actionString - The action in string form.\n\t *\n\t * @return The parsed action.\n\t */\n\tprivate static Options.Action ParseAction(String in_actionString)\n\t{\n\t\tif (in_actionString.equalsIgnoreCase(ACTION_BUILD_BANK) == true)\n\t\t{\n\t\t\treturn Options.Action.BUILD_BANK;\n\t\t}\n\t\telse if (in_actionString.equalsIgnoreCase(ACTION_BUILD_BANK_SINGLE) == true)\n\t\t{\n\t\t\treturn Options.Action.BUILD_BANK_SINGLE;\n\t\t} \n\t\telse if (in_actionString.equalsIgnoreCase(ACTION_BUILD_STREAM) == true)\n\t\t{\n\t\t\treturn Options.Action.BUILD_STREAM;\n\t\t} \n\t\telse\n\t\t{\n\t\t\tLogging.logFatal(\"Invalid action provided: \" + in_actionString);\n\t\t\treturn Options.Action.NONE;\n\t\t}\n\t}\n\t/**\n\t * Confirms that the given options are valid. If they are not, the application will exit.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param in_options - The options.\n\t */\n\tprivate static void ValidateOptions(Options in_options)\n\t{\n\t\tif (in_options.m_action == Options.Action.NONE)\n\t\t{\n\t\t\tLogging.logFatal(\"Must provide an action.\");\n\t\t}\n\t\t\n\t\tif (in_options.m_inputFilePath.isEmpty() == true)\n\t\t{\n\t\t\tLogging.logFatal(\"Must provide an input file path.\");\n\t\t}\n\t\t\n\t\tif (in_options.m_outputFilePath.isEmpty() == true)\n\t\t{\n\t\t\tLogging.logFatal(\"Must provide an output file path.\");\n\t\t}\n\t\t\n\t\tif (in_options.m_action == Options.Action.BUILD_BANK && in_options.m_format.isEmpty() == false)\n\t\t{\n\t\t\tLogging.logFatal(\"Format cannot be applied to a bank created from a xml description.\");\n\t\t}\n\t\t\n\t\tif (in_options.m_action == Options.Action.BUILD_BANK && in_options.m_volume.isEmpty() == false)\n\t\t{\n\t\t\tLogging.logFatal(\"Volume cannot be applied to a bank created from a xml description.\");\n\t\t}\n\t\t\n\t\tif (in_options.m_action == Options.Action.BUILD_BANK && in_options.m_pan.isEmpty() == false)\n\t\t{\n\t\t\tLogging.logFatal(\"Pan cannot be applied to a bank created from a xml description.\");\n\t\t}\n\t\t\n\t\tif (in_options.m_action == Options.Action.BUILD_BANK && in_options.m_loopStart.isEmpty() == false)\n\t\t{\n\t\t\tLogging.logFatal(\"Loop start cannot be applied to a bank created from a xml description.\");\n\t\t}\n\t\t\n\t\tif (in_options.m_action == Options.Action.BUILD_BANK && in_options.m_loopEnd.isEmpty() == false)\n\t\t{\n\t\t\tLogging.logFatal(\"Loop end cannot be applied to a bank created from a xml description.\");\n\t\t}\n\t\t\n\t\tif (in_options.m_action == Options.Action.BUILD_BANK && in_options.m_loopCount.isEmpty() == false)\n\t\t{\n\t\t\tLogging.logFatal(\"Loop count cannot be applied to a bank created from a xml description.\");\n\t\t}\n\t}\n\t/**\n\t * Prints the help text to the console. Forces the logging level to verbose.\n\t * \n\t * @author Ian Copland\n\t */\n\tprivate static void PrintHelpText()\n\t{\n\t\tLogging.setLoggingLevel(LoggingLevel.VERBOSE);\n\t\tLogging.logVerbose(\" \");\n\t\tLogging.logVerbose(\"==========\");\n\t\tLogging.logVerbose(\"  CkTool  \");\n\t\tLogging.logVerbose(\"==========\");\n\t\tLogging.logVerbose(\" \");\n\t\tLogging.logVerbose(\"CkTool is a simple cross-platform java wrapper around the Cricket Audio cktool. For further information see the Cricket\");\n\t\tLogging.logVerbose(\"Audio Documentation at: http://www.crickettechnology.com/\");\n\t\tLogging.logVerbose(\" \");\n\t\tLogging.logVerbose(\"ChilliSource has obtained special permission to include Cricket Audio as part of the engine. See the documentation on CricketAudioSystem for \" +\n\t\t\t\t\"details on how to use Cricket Audio. You are free to use Cricket Audio as part of ChilliSource within your app subject to the Cricket Audio free license \" +\n\t\t\t\t\"(http://www.crickettechnology.com/free_license) as outline below:\");\n\t\tLogging.logVerbose(\" \");\n\t\tLogging.logVerbose(\"Cricket Audio free license\");\n\t\tLogging.logVerbose(\" \");\n\t\tLogging.logVerbose(\"Cricket Audio is available FREE in binary form for iOS, Android, Windows Phone 8, OS X, Windows, and Linux. \");\n\t\tLogging.logVerbose(\" \");\n\t\tLogging.logVerbose(\"This free license has a few requirements:\");\n\t\tLogging.logVerbose(\" \");\n\t\tLogging.logVerbose(\"* Include the following message somewhere in your app, visible to users (for example, on a credits screen):\");\n\t\tLogging.logVerbose(\" \");\n\t\tLogging.logVerbose(\"                                      Built with Cricket Audio\");\n\t\tLogging.logVerbose(\" \");\n\t\tLogging.logVerbose(\"                                      www.crickettechnology.com\");\n\t\tLogging.logVerbose(\" \");\n\t\tLogging.logVerbose(\"* You may optionally include our logo (available in .svg or .png format).\");\n\t\tLogging.logVerbose(\" \");\n\t\tLogging.logVerbose(\"* Do not distribute our software to anyone, or post it for download on any site; refer them to our website instead.\");\n\t\tLogging.logVerbose(\"  This license does not permit you to distribute Cricket Audio in an SDK, library, or other software development product. Contact us at \" +\n\t\t\t\t\"info@crickettechnology.com for additional licensing options.\");\n\t\tLogging.logVerbose(\" \");\n\t\tLogging.logVerbose(\"* If you release an app that uses Cricket Audio, you must let Cricket Technology know. Cricket Technology will include a link to it on our customers page.\");\n\t\tLogging.logVerbose(\" \");\n\t\tLogging.logVerbose(\"If you do not want to include the credit in your app, or if you do not want to notify us of your app's release, or if you want the source code, \" +\n\t\t\t\t\"you can purchase a source code license (http://www.crickettechnology.com/source_license).\");\n\t\tLogging.logVerbose(\" \");\n\t\tLogging.logVerbose(\"-------\");\n\t\tLogging.logVerbose(\" Usage\");\n\t\tLogging.logVerbose(\"-------\");\n\t\tLogging.logVerbose(\" \");\n\t\tLogging.logVerbose(\"java -jar CkTool.jar \" + PARAM_ACTION + \" <action> \" + PARAM_INPUT + \" <filepath> \" + PARAM_OUTPUT + \" <filepath> [\" + PARAM_FORMAT + \" <format>] \" +\n\t\t\t\t\"[\" + PARAM_VOLUME + \" <volume>] [\" + PARAM_PAN + \" <pan>] [\" + PARAM_LOOP_START + \" <frame>] [\" + PARAM_LOOP_END + \" <frame>] [\" + PARAM_LOOP_COUNT + \" <count>] \" +\n\t\t\t\t\"[\" + Logging.PARAM_LOGGING_LEVEL + \" <level>] [\"+ PARAM_HELP +\"]\");\n\t\tLogging.logVerbose(\" \");\n\t\tLogging.logVerbose(\"Parameters:\");\n\t\tLogging.logVerbose(\" \" + PARAM_ACTION + \"(\" + SHORT_PARAM_ACTION + \"): The action to perform.\");\n\t\tLogging.logVerbose(\" \" + PARAM_INPUT + \"(\" + SHORT_PARAM_INPUT + \"): The input filepath.\");\n\t\tLogging.logVerbose(\" \" + PARAM_OUTPUT + \"(\" + SHORT_PARAM_OUTPUT + \"): The output filepath.\");\n\t\tLogging.logVerbose(\" \" + PARAM_FORMAT + \"(\" + SHORT_PARAM_FORMAT + \"): The output format of the audio. This only applies to streams and banks created from a single audio file.\");\n\t\tLogging.logVerbose(\" \" + PARAM_VOLUME + \"(\" + SHORT_PARAM_VOLUME + \"): The output volume of the audio. This only applies to streams and banks created from a single audio file.\");\n\t\tLogging.logVerbose(\" \" + PARAM_PAN + \"(\" + SHORT_PARAM_PAN + \"): The output pan of the audio. This only applies to streams and banks created from a single audio file.\");\n\t\tLogging.logVerbose(\" \" + PARAM_LOOP_START + \"(\" + SHORT_PARAM_LOOP_START + \"): The start frame of a loop in the audio. This only applies to streams and banks created from a single audio file.\");\n\t\tLogging.logVerbose(\" \" + PARAM_LOOP_END + \"(\" + SHORT_PARAM_LOOP_END + \"): The end frame of a loop in the audio. This only applies to streams and banks created from a single audio file.\");\n\t\tLogging.logVerbose(\" \" + PARAM_LOOP_COUNT + \"(\" + SHORT_PARAM_LOOP_COUNT + \"): The number of times the audio will loop. This only applies to streams and banks created from a single audio file.\");\n\t\tLogging.logVerbose(\" \" + Logging.PARAM_LOGGING_LEVEL + \"(\" + Logging.SHORT_PARAM_LOGGING_LEVEL + \"): Sets the logging level.\");\n\t\tLogging.logVerbose(\" \" + PARAM_HELP + \"p(\" + SHORT_PARAM_HELP + \"): Displays this help message.\");\n\t\tLogging.logVerbose(\" \");\n\t\tLogging.logVerbose(\"Actions:\");\n\t\tLogging.logVerbose(\" \" + ACTION_BUILD_BANK + \": Builds an audio bank (.ckb) from the given xml bank description file (.ckbx).\");\n\t\tLogging.logVerbose(\" \" + ACTION_BUILD_BANK_SINGLE + \": Builds an audio bank (.ckb) which contains a single peice of audio from the given audio file.\");\n\t\tLogging.logVerbose(\" \" + ACTION_BUILD_STREAM + \": Builds an audio stream (.cks) from the given audio file.\");\n\t\tLogging.logVerbose(\" \");\n\t\tLogging.logVerbose(\"Logging Levels:\");\n\t\tLogging.logVerbose(\" \" + Logging.LOGGING_LEVEL_NONE + \": No logging.\");\n\t\tLogging.logVerbose(\" \" + Logging.LOGGING_LEVEL_FATAL + \": Only log fatal errors.\");\n\t\tLogging.logVerbose(\" \" + Logging.LOGGING_LEVEL_ERROR + \": Only log errors.\");\n\t\tLogging.logVerbose(\" \" + Logging.LOGGING_LEVEL_WARNING + \": Log errors and warnings.\");\n\t\tLogging.logVerbose(\" \" + Logging.LOGGING_LEVEL_VERBOSE + \": Log all messages.\");\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/CkTool/src/com/chilliworks/chillisource/cktool/Options.java",
    "content": "/**\n * Options.java\n * ChilliSource\n * Created by Ian Copland on 20/01/2015.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2015 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.cktool;\n\n/**\n * A container for options for the CkTool.\n * \n * @author Ian Copland\n */\npublic final class Options \n{\n\t/**\n\t * The action to perform using the cktool.\n\t * \n\t * @author Ian Copland\n\t */\n\tpublic enum Action\n\t{\n\t\tNONE,\n\t\tBUILD_BANK,\n\t\tBUILD_BANK_SINGLE,\n\t\tBUILD_STREAM\n\t}\n\t\n\tpublic String m_inputFilePath = \"\";\n\tpublic String m_outputFilePath = \"\";\n\tpublic Action m_action = Action.NONE;\n\tpublic String m_format = \"\";\n\tpublic String m_volume = \"\";\n\tpublic String m_pan = \"\";\n\tpublic String m_loopStart = \"\";\n\tpublic String m_loopEnd = \"\";\n\tpublic String m_loopCount = \"\";\n}\n"
  },
  {
    "path": "Projects/Tools/ColladaParserUtils/.classpath",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<classpath>\n\t<classpathentry kind=\"src\" path=\"src\"/>\n\t<classpathentry kind=\"con\" path=\"org.eclipse.jdt.launching.JRE_CONTAINER\"/>\n\t<classpathentry combineaccessrules=\"false\" kind=\"src\" path=\"/CoreUtils\"/>\n\t<classpathentry kind=\"output\" path=\"bin\"/>\n</classpath>\n"
  },
  {
    "path": "Projects/Tools/ColladaParserUtils/.project",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<projectDescription>\n\t<name>ColladaParserUtils</name>\n\t<comment></comment>\n\t<projects>\n\t</projects>\n\t<buildSpec>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.jdt.core.javabuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t</buildSpec>\n\t<natures>\n\t\t<nature>org.eclipse.jdt.core.javanature</nature>\n\t</natures>\n</projectDescription>\n"
  },
  {
    "path": "Projects/Tools/ColladaParserUtils/src/com/chilliworks/chillisource/colladaparserutils/AssetParser.java",
    "content": "/**\n * AssetParser.java\n * ChilliSource\n * Created by Ian Copland on 16/01/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.colladaparserutils;\n\nimport org.xml.sax.Attributes;\nimport org.xml.sax.SAXException;\n\nimport com.chilliworks.chillisource.colladaparserutils.colladadata.Collada;\nimport com.chilliworks.chillisource.colladaparserutils.colladadata.ColladaAuthoringTool;\nimport com.chilliworks.chillisource.colladaparserutils.colladadata.ColladaContributor;\n\npublic class AssetParser \n{\n\t//--------------------------------------------------------------\n\t/// Private Member Data\n\t//--------------------------------------------------------------\n\tprivate Collada mCollada;\n\tprivate ColladaContributor mCurrentContributor = null;\n\tprivate ColladaAuthoringTool mCurrentAuthoringTool = null;\n\t//--------------------------------------------------------------\n\t/// Constructor\n\t//--------------------------------------------------------------\n\tpublic AssetParser(Collada inColladaData)\n\t{\n\t\tmCollada = inColladaData;\n\t}\n\t//--------------------------------------------------------------\n\t/// Start Element\n\t///\n\t/// Callback method used by SAX whenever a new element is found.\n\t//--------------------------------------------------------------\n\tpublic boolean StartElement(String instrUri, String instrLocalName,String instrQName, Attributes inAttributes) throws SAXException \n\t{\n\t\tif (instrQName.equalsIgnoreCase(\"contributor\"))\n\t\t\treturn PushContributor(inAttributes);\n\t\telse if (instrQName.equalsIgnoreCase(\"authoring_tool\"))\n\t\t\treturn PushAuthoringTool(inAttributes);\n\t\telse\n\t\t\treturn false;\n\t}\n\t//--------------------------------------------------------------\n\t/// End Element\n\t///\n\t/// Callback method used by SAX whenever a new element is found.\n\t//--------------------------------------------------------------\n\tpublic void EndElement(String instrUri, String instrLocalName, String instrQName, String inData) throws SAXException \n\t{\n\t\tif (instrQName.equalsIgnoreCase(\"contributor\"))\n\t\t\tPopContributor(inData);\n\t\telse if (instrQName.equalsIgnoreCase(\"authoring_tool\"))\n\t\t\tPopAuthoringTool(inData);\n\t}\n\t//--------------------------------------------------------------\n\t/// Push Contributor\n\t///\n\t/// Pushes the contributor element type.\n\t//--------------------------------------------------------------\n\tprivate boolean PushContributor(Attributes inAttributes)\n\t{\n\t\tif (mCurrentContributor == null)\n\t\t{\n\t\t\tmCurrentContributor = mCollada.mAsset.mContributor;\n\t\t}\n\t\treturn false;\n\t}\n\t//--------------------------------------------------------------\n\t/// Pop Contributor\n\t///\n\t/// Pops the contributor element type.\n\t//--------------------------------------------------------------\n\tprivate void PopContributor(String inData)\n\t{\n\t\tmCurrentContributor = null;\n\t}\n\t//--------------------------------------------------------------\n\t/// Push Authoring Tool\n\t///\n\t/// Pushes the Authoring Tool element type.\n\t//--------------------------------------------------------------\n\tprivate boolean PushAuthoringTool(Attributes inAttributes)\n\t{\n\t\tif (mCurrentContributor != null)\n\t\t{\n\t\t\tmCurrentAuthoringTool = mCurrentContributor.mAuthoringTool;\n\t\t}\n\t\t\n\t\treturn true;\n\t}\n\t//--------------------------------------------------------------\n\t/// Pop Authoring Tool\n\t///\n\t/// Pops the Authoring Tool element type.\n\t//--------------------------------------------------------------\n\tprivate void PopAuthoringTool(String inData)\n\t{\n\t\tif (mCurrentAuthoringTool != null)\n\t\t{\n\t\t\tmCurrentAuthoringTool.mstrName = inData;\n\t\t\tmCurrentAuthoringTool = null;\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/ColladaParserUtils/src/com/chilliworks/chillisource/colladaparserutils/ColladaParser.java",
    "content": "/**\n * ColladaParser.java\n * ChilliSource\n * Created by Ian Copland on 16/01/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.colladaparserutils;\n\nimport org.xml.sax.Attributes;\nimport org.xml.sax.SAXException;\n\nimport com.chilliworks.chillisource.colladaparserutils.colladadata.*;\n\npublic class ColladaParser extends org.xml.sax.helpers.DefaultHandler\n{\n\t//--------------------------------------------------------------\n\t/// Parser State\n\t//--------------------------------------------------------------\n\tenum PARSER_STATE\n\t{\n\t\tPS_BASE,\n\t\tPS_ASSET,\n\t\tPS_GEOMETRIES,\n\t\tPS_MATERIALS,\n\t\tPS_IMAGES,\n\t\tPS_EFFECTS,\n\t\tPS_VISUAL_SCENES,\n\t\tPS_CONTROLLERS,\n\t\tPS_ANIMATIONS,\n\t\tPS_SCENE\n\t}\n\t//--------------------------------------------------------------\n\t/// Private member Data\n\t//--------------------------------------------------------------\n\tprivate boolean mbReadCharacters;\n\tprivate StringBuffer mstrCurrentCharacterBuffer;\n\tprivate Collada mCollada;\n\tprivate AssetParser mAssetParser;\n\tprivate LibraryEffectsParser mEffectsParser;\n\tprivate LibraryMaterialsParser mMaterialsParser;\n\tprivate LibraryGeometriesParser mGeometriesParser;\n\tprivate LibraryVisualScenesParser mVisualScenesParser;\n\tprivate LibraryImagesParser mImagesParser;\n\tprivate LibraryControllersParser mControllersParser;\n\tprivate LibraryAnimationsParser mAnimationsParser;\n\tprivate SceneParser mSceneParser;\n\tprivate PARSER_STATE meState;\n\t//--------------------------------------------------------------\n\t/// Constructor\n\t//--------------------------------------------------------------\n\tpublic ColladaParser(Collada inColladaData)\n\t{\n\t\tmCollada = inColladaData;\n\t\t\n\t\tmAssetParser = new AssetParser(inColladaData);\n\t\tmEffectsParser = new LibraryEffectsParser(mCollada);\n\t\tmMaterialsParser = new LibraryMaterialsParser(mCollada);\n\t\tmGeometriesParser = new LibraryGeometriesParser(mCollada);\n\t\tmImagesParser = new LibraryImagesParser(mCollada);\n\t\tmVisualScenesParser = new LibraryVisualScenesParser(mCollada);\n\t\tmControllersParser = new LibraryControllersParser(mCollada);\n\t\tmAnimationsParser = new LibraryAnimationsParser(mCollada);\n\t\tmSceneParser = new SceneParser(mCollada);\n\t\t\n\t\tmstrCurrentCharacterBuffer = null;\n\t\tmbReadCharacters = false;\n\t\tmeState = PARSER_STATE.PS_BASE;\n\t}\n\t//--------------------------------------------------------------\n\t/// Start Element\n\t///\n\t/// Callback method used by SAX whenever a new element is found.\n\t//--------------------------------------------------------------\n\tpublic void startElement(String instrUri, String instrLocalName,String instrQName, Attributes inAttributes) throws SAXException \n\t{\n\t\tmstrCurrentCharacterBuffer = new StringBuffer();\n\t\t\n\t\tswitch (meState)\n\t\t{\n\t\tcase PS_BASE:\n\t\t\tmbReadCharacters = StartBaseElement(instrUri, instrLocalName,instrQName, inAttributes);\n\t\t\tbreak;\n\t\tcase PS_ASSET:\n\t\t\tmbReadCharacters = StartAssetElement(instrUri, instrLocalName,instrQName, inAttributes);\n\t\t\tbreak;\n\t\tcase PS_GEOMETRIES:\n\t\t\tmbReadCharacters = StartGeometriesElement(instrUri, instrLocalName,instrQName, inAttributes);\n\t\t\tbreak;\n\t\tcase PS_IMAGES:\n\t\t\tmbReadCharacters = StartImagesElement(instrUri, instrLocalName,instrQName, inAttributes);\n\t\t\tbreak;\n\t\tcase PS_MATERIALS:\n\t\t\tmbReadCharacters = StartMaterialsElement(instrUri, instrLocalName,instrQName, inAttributes);\n\t\t\tbreak;\n\t\tcase PS_EFFECTS:\n\t\t\tmbReadCharacters = StartEffectsElement(instrUri, instrLocalName,instrQName, inAttributes);\n\t\t\tbreak;\n\t\tcase PS_VISUAL_SCENES:\n\t\t\tmbReadCharacters = StartVisualScenesElement(instrUri, instrLocalName,instrQName, inAttributes);\n\t\t\tbreak;\n\t\tcase PS_CONTROLLERS:\n\t\t\tmbReadCharacters = StartControllersElement(instrUri, instrLocalName,instrQName, inAttributes);\n\t\t\tbreak;\n\t\tcase PS_ANIMATIONS:\n\t\t\tmbReadCharacters = StartAnimationsElement(instrUri, instrLocalName,instrQName, inAttributes);\n\t\t\tbreak;\n\t\tcase PS_SCENE:\n\t\t\tmbReadCharacters = StartSceneElement(instrUri, instrLocalName,instrQName, inAttributes);\n\t\t\tbreak;\n\t\t}\n\t}\n\t//--------------------------------------------------------------\n\t/// End Element\n\t///\n\t/// Callback method used by SAX whenever a new element is found.\n\t//--------------------------------------------------------------\n\tpublic void endElement(String instrUri, String instrLocalName,String instrQName) throws SAXException \n\t{\n\t\tswitch (meState)\n\t\t{\n\t\tcase PS_BASE:\n\t\t\tEndBaseElement(instrUri, instrLocalName,instrQName);\n\t\t\tbreak;\n\t\tcase PS_ASSET:\n\t\t\tEndAssetElement(instrUri, instrLocalName,instrQName);\n\t\t\tbreak;\n\t\tcase PS_GEOMETRIES:\n\t\t\tEndGeometriesElement(instrUri, instrLocalName,instrQName);\n\t\t\tbreak;\n\t\tcase PS_IMAGES:\n\t\t\tEndImagesElement(instrUri, instrLocalName,instrQName);\n\t\t\tbreak;\n\t\tcase PS_MATERIALS:\n\t\t\tEndMaterialsElement(instrUri, instrLocalName,instrQName);\n\t\t\tbreak;\n\t\tcase PS_EFFECTS:\n\t\t\tEndEffectsElement(instrUri, instrLocalName,instrQName);\n\t\t\tbreak;\n\t\tcase PS_VISUAL_SCENES:\n\t\t\tEndVisualScenesElement(instrUri, instrLocalName,instrQName);\n\t\t\tbreak;\n\t\tcase PS_CONTROLLERS:\n\t\t\tEndControllersElement(instrUri, instrLocalName,instrQName);\n\t\t\tbreak;\n\t\tcase PS_ANIMATIONS:\n\t\t\tEndAnimationsElement(instrUri, instrLocalName,instrQName);\n\t\t\tbreak;\n\t\tcase PS_SCENE:\n\t\t\tEndSceneElement(instrUri, instrLocalName,instrQName);\n\t\t\tbreak;\n\t\t}\n\t\t\n\t\tmbReadCharacters = false;\n\t\tmstrCurrentCharacterBuffer = null;\n\t}\n\t//--------------------------------------------------------------\n\t/// Characters\n\t///\n\t/// Callback method used by SAX whenever contents of a element \n\t/// is found.\n\t//--------------------------------------------------------------\n\tpublic void characters(char inbyCharacters[], int indwStart, int indwLength) throws SAXException \n\t{\n\t\tif (mbReadCharacters == false) return;\n\t\t\n\t\tmstrCurrentCharacterBuffer.append(inbyCharacters, indwStart, indwLength);\n\t}\n\t//--------------------------------------------------------------\n\t/// Start Base Element\n\t///\n\t/// Starts a base element, for example a library.\n\t//--------------------------------------------------------------\n\tprivate boolean StartBaseElement(String instrUri, String instrLocalName,String instrQName, Attributes inAttributes)\n\t{\n\t\tif (instrQName.equalsIgnoreCase(\"COLLADA\") == true)\n\t\t{\n\t\t\t//Do nothing\n\t\t}\n\t\telse if (instrQName.equalsIgnoreCase(\"asset\") == true)\n\t\t{\n\t\t\tmeState = PARSER_STATE.PS_ASSET;\n\t\t}\n\t\telse if (instrQName.equalsIgnoreCase(\"library_geometries\") == true)\n\t\t{\n\t\t\tmeState = PARSER_STATE.PS_GEOMETRIES;\n\t\t}\n\t\telse if (instrQName.equalsIgnoreCase(\"library_images\") == true)\n\t\t{\n\t\t\tmeState = PARSER_STATE.PS_IMAGES;\n\t\t}\n\t\telse if (instrQName.equalsIgnoreCase(\"library_materials\") == true)\n\t\t{\n\t\t\tmeState = PARSER_STATE.PS_MATERIALS;\n\t\t}\n\t\telse if (instrQName.equalsIgnoreCase(\"library_effects\") == true)\n\t\t{\n\t\t\tmeState = PARSER_STATE.PS_EFFECTS;\n\t\t}\n\t\telse if (instrQName.equalsIgnoreCase(\"library_visual_scenes\") == true)\n\t\t{\n\t\t\tmeState = PARSER_STATE.PS_VISUAL_SCENES;\n\t\t}\n\t\telse if (instrQName.equalsIgnoreCase(\"library_controllers\") == true)\n\t\t{\n\t\t\tmeState = PARSER_STATE.PS_CONTROLLERS;\n\t\t}\n\t\telse if (instrQName.equalsIgnoreCase(\"library_animations\") == true)\n\t\t{\n\t\t\tmeState = PARSER_STATE.PS_ANIMATIONS;\n\t\t}\n\t\telse if (instrQName.equalsIgnoreCase(\"scene\") == true)\n\t\t{\n\t\t\tmeState = PARSER_STATE.PS_SCENE;\n\t\t}\n\t\telse\n\t\t{\n\t\t\t//element is unknown and unimportant.\n\t\t}\n\t\t\n\t\treturn false;\n\t}\n\t//--------------------------------------------------------------\n\t/// End Base Element\n\t///\n\t/// Ends a base element, for example a library.\n\t//--------------------------------------------------------------\n\tprivate void EndBaseElement(String instrUri, String instrLocalName,String instrQName) throws SAXException\n\t{\n\t\t\n\t}\n\t//--------------------------------------------------------------\n\t/// Start Asset Element\n\t///\n\t/// Starts an asset element.\n\t//--------------------------------------------------------------\n\tprivate boolean StartAssetElement(String instrUri, String instrLocalName,String instrQName, Attributes inAttributes) throws SAXException\n\t{\n\t\treturn mAssetParser.StartElement(instrUri, instrLocalName,instrQName, inAttributes);\n\t}\n\t//--------------------------------------------------------------\n\t/// End Asset Element\n\t///\n\t/// Ends an asset element.\n\t//--------------------------------------------------------------\n\tprivate void EndAssetElement(String instrUri, String instrLocalName, String instrQName) throws SAXException\n\t{\n\t\tif (instrQName.equalsIgnoreCase(\"asset\"))\n\t\t{\n\t\t\tmeState = PARSER_STATE.PS_BASE;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tif (mstrCurrentCharacterBuffer != null && mstrCurrentCharacterBuffer.length() > 0)\n\t\t\t\tmAssetParser.EndElement(instrUri, instrLocalName, instrQName, mstrCurrentCharacterBuffer.toString());\n\t\t\telse\n\t\t\t\tmAssetParser.EndElement(instrUri, instrLocalName, instrQName, \" \");\n\t\t}\n\t}\n\t//--------------------------------------------------------------\n\t/// Start Geometries Element\n\t///\n\t/// Starts a geometries element.\n\t//--------------------------------------------------------------\n\tprivate boolean StartGeometriesElement(String instrUri, String instrLocalName,String instrQName, Attributes inAttributes) throws SAXException\n\t{\n\t\treturn mGeometriesParser.StartElement(instrUri, instrLocalName, instrQName, inAttributes);\n\t}\n\t//--------------------------------------------------------------\n\t/// End Geometries Element\n\t///\n\t/// Ends a geometries element.\n\t//--------------------------------------------------------------\n\tprivate void EndGeometriesElement(String instrUri, String instrLocalName, String instrQName) throws SAXException\n\t{\n\t\tif (instrQName.equalsIgnoreCase(\"library_geometries\"))\n\t\t{\n\t\t\tmeState = PARSER_STATE.PS_BASE;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tif (mstrCurrentCharacterBuffer != null && mstrCurrentCharacterBuffer.length() > 0)\n\t\t\t\tmGeometriesParser.EndElement(instrUri, instrLocalName, instrQName, mstrCurrentCharacterBuffer.toString());\n\t\t\telse\n\t\t\t\tmGeometriesParser.EndElement(instrUri, instrLocalName, instrQName, \" \");\n\t\t}\n\t}\n\t//--------------------------------------------------------------\n\t/// Start Images Element\n\t///\n\t/// Starts an images element.\n\t//--------------------------------------------------------------\n\tprivate boolean StartImagesElement(String instrUri, String instrLocalName,String instrQName, Attributes inAttributes) throws SAXException\n\t{\n\t\treturn mImagesParser.StartElement(instrUri, instrLocalName,instrQName, inAttributes);\n\t}\n\t//--------------------------------------------------------------\n\t/// End Images Element\n\t///\n\t/// Ends an images element.\n\t//--------------------------------------------------------------\n\tprivate void EndImagesElement(String instrUri, String instrLocalName, String instrQName) throws SAXException\n\t{\n\t\tif (instrQName.equalsIgnoreCase(\"library_images\"))\n\t\t{\n\t\t\tmeState = PARSER_STATE.PS_BASE;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tif (mstrCurrentCharacterBuffer != null && mstrCurrentCharacterBuffer.length() > 0)\n\t\t\t\tmImagesParser.EndElement(instrUri, instrLocalName, instrQName, mstrCurrentCharacterBuffer.toString());\n\t\t\telse\n\t\t\t\tmImagesParser.EndElement(instrUri, instrLocalName, instrQName, \" \");\n\t\t}\n\t}\n\t//--------------------------------------------------------------\n\t/// Start Materials Element\n\t///\n\t/// Starts a materials element.\n\t//--------------------------------------------------------------\n\tprivate boolean StartMaterialsElement(String instrUri, String instrLocalName,String instrQName, Attributes inAttributes) throws SAXException\n\t{\n\t\treturn mMaterialsParser.StartElement(instrUri, instrLocalName,instrQName, inAttributes);\n\t}\n\t//--------------------------------------------------------------\n\t/// Ends Materials Element\n\t///\n\t/// Ends a materials element.\n\t//--------------------------------------------------------------\n\tprivate void EndMaterialsElement(String instrUri, String instrLocalName, String instrQName) throws SAXException\n\t{\n\t\tif (instrQName.equalsIgnoreCase(\"library_materials\"))\n\t\t{\n\t\t\tmeState = PARSER_STATE.PS_BASE;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tif (mstrCurrentCharacterBuffer != null && mstrCurrentCharacterBuffer.length() > 0)\n\t\t\t\tmMaterialsParser.EndElement(instrUri, instrLocalName, instrQName, mstrCurrentCharacterBuffer.toString());\n\t\t\telse\n\t\t\t\tmMaterialsParser.EndElement(instrUri, instrLocalName, instrQName, \" \");\n\t\t}\n\t}\n\t//--------------------------------------------------------------\n\t/// Start Effects Element\n\t///\n\t/// Starts an effects element.\n\t//--------------------------------------------------------------\n\tprivate boolean StartEffectsElement(String instrUri, String instrLocalName,String instrQName, Attributes inAttributes) throws SAXException\n\t{\n\t\treturn mEffectsParser.StartElement(instrUri, instrLocalName,instrQName, inAttributes);\n\t}\n\t//--------------------------------------------------------------\n\t/// End Effects Element\n\t///\n\t/// End an effects element.\n\t//--------------------------------------------------------------\n\tprivate void EndEffectsElement(String instrUri, String instrLocalName, String instrQName) throws SAXException\n\t{\n\t\tif (instrQName.equalsIgnoreCase(\"library_effects\"))\n\t\t{\n\t\t\tmeState = PARSER_STATE.PS_BASE;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tif (mstrCurrentCharacterBuffer != null && mstrCurrentCharacterBuffer.length() > 0)\n\t\t\t\tmEffectsParser.EndElement(instrUri, instrLocalName, instrQName, mstrCurrentCharacterBuffer.toString());\n\t\t\telse\n\t\t\t\tmEffectsParser.EndElement(instrUri, instrLocalName, instrQName, \" \");\n\t\t}\n\t}\n\t//--------------------------------------------------------------\n\t/// Start Visual Scenes Element\n\t///\n\t/// Starts a visual scenes element.\n\t//--------------------------------------------------------------\n\tprivate boolean StartVisualScenesElement(String instrUri, String instrLocalName,String instrQName, Attributes inAttributes) throws SAXException\n\t{\n\t\treturn mVisualScenesParser.StartElement(instrUri, instrLocalName,instrQName, inAttributes);\n\t}\n\t//--------------------------------------------------------------\n\t/// End Visual Scenes Element\n\t///\n\t/// Ends a visual scenes element.\n\t//--------------------------------------------------------------\n\tprivate void EndVisualScenesElement(String instrUri, String instrLocalName, String instrQName) throws SAXException\n\t{\n\t\tif (instrQName.equalsIgnoreCase(\"library_visual_scenes\"))\n\t\t{\n\t\t\tmeState = PARSER_STATE.PS_BASE;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tif (mstrCurrentCharacterBuffer != null && mstrCurrentCharacterBuffer.length() > 0)\n\t\t\t\tmVisualScenesParser.EndElement(instrUri, instrLocalName, instrQName, mstrCurrentCharacterBuffer.toString());\n\t\t\telse\n\t\t\t\tmVisualScenesParser.EndElement(instrUri, instrLocalName, instrQName, \" \");\n\t\t}\n\t}\n\t//--------------------------------------------------------------\n\t/// Start Controllers Element\n\t///\n\t/// Starts a controllers element.\n\t//--------------------------------------------------------------\n\tprivate boolean StartControllersElement(String instrUri, String instrLocalName,String instrQName, Attributes inAttributes) throws SAXException\n\t{\n\t\treturn mControllersParser.StartElement(instrUri, instrLocalName,instrQName, inAttributes);\n\t}\n\t//--------------------------------------------------------------\n\t/// End Controllers Element\n\t///\n\t/// Ends a controllers element.\n\t//--------------------------------------------------------------\n\tprivate void EndControllersElement(String instrUri, String instrLocalName, String instrQName) throws SAXException\n\t{\n\t\tif (instrQName.equalsIgnoreCase(\"library_controllers\"))\n\t\t{\n\t\t\tmeState = PARSER_STATE.PS_BASE;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tif (mstrCurrentCharacterBuffer != null && mstrCurrentCharacterBuffer.length() > 0)\n\t\t\t\tmControllersParser.EndElement(instrUri, instrLocalName, instrQName, mstrCurrentCharacterBuffer.toString());\n\t\t\telse\n\t\t\t\tmControllersParser.EndElement(instrUri, instrLocalName, instrQName, \" \");\n\t\t}\n\t}\n\t//--------------------------------------------------------------\n\t/// Start Animations Element\n\t///\n\t/// Starts an animations element.\n\t//--------------------------------------------------------------\n\tprivate boolean StartAnimationsElement(String instrUri, String instrLocalName,String instrQName, Attributes inAttributes) throws SAXException\n\t{\n\t\treturn mAnimationsParser.StartElement(instrUri, instrLocalName,instrQName, inAttributes);\n\t}\n\t//--------------------------------------------------------------\n\t/// End Animations Element\n\t///\n\t/// End an animations element.\n\t//--------------------------------------------------------------\n\tprivate void EndAnimationsElement(String instrUri, String instrLocalName, String instrQName) throws SAXException\n\t{\n\t\tif (instrQName.equalsIgnoreCase(\"library_animations\"))\n\t\t{\n\t\t\tmeState = PARSER_STATE.PS_BASE;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tif (mstrCurrentCharacterBuffer != null && mstrCurrentCharacterBuffer.length() > 0)\n\t\t\t\tmAnimationsParser.EndElement(instrUri, instrLocalName, instrQName, mstrCurrentCharacterBuffer.toString());\n\t\t\telse\n\t\t\t\tmAnimationsParser.EndElement(instrUri, instrLocalName, instrQName, \" \");\n\t\t}\n\t}\n\t//--------------------------------------------------------------\n\t/// Start Scene Element\n\t///\n\t/// Starts a scene element.\n\t//--------------------------------------------------------------\n\tprivate boolean StartSceneElement(String instrUri, String instrLocalName,String instrQName, Attributes inAttributes) throws SAXException\n\t{\n\t\treturn mSceneParser.StartElement(instrUri, instrLocalName,instrQName, inAttributes);\n\t}\n\t//--------------------------------------------------------------\n\t/// End Scene Element\n\t///\n\t/// Ends a scene element.\n\t//--------------------------------------------------------------\n\tprivate void EndSceneElement(String instrUri, String instrLocalName, String instrQName) throws SAXException\n\t{\n\t\tif (instrQName.equalsIgnoreCase(\"scene\"))\n\t\t{\n\t\t\tmeState = PARSER_STATE.PS_BASE;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tif (mstrCurrentCharacterBuffer != null && mstrCurrentCharacterBuffer.length() > 0)\n\t\t\t\tmSceneParser.EndElement(instrUri, instrLocalName, instrQName, mstrCurrentCharacterBuffer.toString());\n\t\t\telse\n\t\t\t\tmSceneParser.EndElement(instrUri, instrLocalName, instrQName, \" \");\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/ColladaParserUtils/src/com/chilliworks/chillisource/colladaparserutils/ColladaUtils.java",
    "content": "/**\n * ColladaUtils.java\n * ChilliSource\n * Created by Ian Copland on 16/01/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.colladaparserutils;\n\nimport java.util.ArrayList;\n\nimport org.xml.sax.Attributes;\n\npublic class ColladaUtils\n{\n\t//--------------------------------------------------------------\n\t/// Split On Whitespace\n\t///\n\t/// Breaks a string up on all types of whitespace.\n\t///\n\t/// @return the output string array.\n\t//--------------------------------------------------------------\n\tpublic static String[] SplitOnWhitespace(String instrData)\n\t{\n\t\tString[] astrData = instrData.split(\"\\\\s+\");\n\t\tArrayList<String> llOutput = new ArrayList<String>();\n\t\t\n\t\tfor (int i = 0; i < astrData.length; ++i)\n\t\t{\n\t\t\tif (astrData[i] != null && astrData[i].length() != 0)\n\t\t\t{\n\t\t\t\tllOutput.add(astrData[i]);\n\t\t\t}\n\t\t}\n\t\t\n\t\tString[] astrOutput = new String[llOutput.size()];\n\t\treturn llOutput.toArray(astrOutput);\n\t}\n\t//--------------------------------------------------------------\n\t/// Get Int Attribute Or Zero\n\t///\n\t/// @return either the value of the attribute, or 0.\n\t//--------------------------------------------------------------\n\tpublic static int GetIntAttributeOrZero(Attributes inAttributes, String inName)\n\t{\n\t\tif (inAttributes.getIndex(inName) > -1)\n\t\t{\n\t\t\treturn Integer.parseInt(inAttributes.getValue(inName));\n\t\t}\n\t\t\n\t\treturn 0;\n\t}\n\t//--------------------------------------------------------------\n\t/// Get Int Attribute Or Zero\n\t///\n\t/// @return either the value of the attribute, or an empty string.\n\t//--------------------------------------------------------------\n\tpublic static String GetStringAttributeOrEmpty(Attributes inAttributes, String inName)\n\t{\n\t\tif (inAttributes.getIndex(inName) > -1)\n\t\t{\n\t\t\treturn inAttributes.getValue(inName);\n\t\t}\n\t\t\n\t\treturn \"\";\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/ColladaParserUtils/src/com/chilliworks/chillisource/colladaparserutils/LibraryAnimationsParser.java",
    "content": "/**\n * LibraryAnimationsParser.java\n * ChilliSource\n * Created by Ian Copland on 16/01/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.colladaparserutils;\n\nimport org.xml.sax.Attributes;\nimport org.xml.sax.SAXException;\n\nimport com.chilliworks.chillisource.colladaparserutils.colladadata.*;\nimport com.chilliworks.chillisource.coreutils.Logging;\n\npublic class LibraryAnimationsParser \n{\n\t//--------------------------------------------------------------\n\t/// Private Member Data\n\t//--------------------------------------------------------------\n\tprivate int mdwIgnoreStack;\n\tprivate Collada mCollada;\n\tprivate ColladaAnimation mCurrentAnimation;\n\tprivate ColladaSource mCurrentSource;\n\tprivate ColladaFloatArray mCurrentFloatArray;\n\tprivate ColladaNameArray mCurrentNameArray;\n\tprivate ColladaSampler mCurrentSampler;\n\t//--------------------------------------------------------------\n\t/// Constructor\n\t//--------------------------------------------------------------\n\tpublic LibraryAnimationsParser(Collada inColladaData)\n\t{\n\t\tmCollada = inColladaData;\n\t\tmdwIgnoreStack = 0;\n\t}\n\t//--------------------------------------------------------------\n\t/// Start Element\n\t///\n\t/// Callback method used by SAX whenever a new element is found.\n\t//--------------------------------------------------------------\n\tpublic boolean StartElement(String instrUri, String instrLocalName,String instrQName, Attributes inAttributes) throws SAXException \n\t{\n\t\t//push element type on to the imaginary element stack\n\t\tif (instrQName.equalsIgnoreCase(\"animation\"))\n\t\t\treturn PushAnimation(inAttributes);\n\t\telse if (instrQName.equalsIgnoreCase(\"source\"))\n\t\t\treturn PushSource(inAttributes);\n\t\telse if (instrQName.equalsIgnoreCase(\"float_array\"))\n\t\t\treturn PushFloatArray(inAttributes);\n\t\telse if (instrQName.equalsIgnoreCase(\"name_array\"))\n\t\t\treturn PushNameArray(inAttributes);\n\t\telse if (instrQName.equalsIgnoreCase(\"sampler\"))\n\t\t\treturn PushSampler(inAttributes);\n\t\telse if (instrQName.equalsIgnoreCase(\"input\"))\n\t\t\treturn PushInput(inAttributes);\n\t\telse if (instrQName.equalsIgnoreCase(\"channel\"))\n\t\t\treturn PushChannel(inAttributes);\n\t\telse\n\t\t{\n\t\t\tmdwIgnoreStack++;\n\t\t\treturn false;\n\t\t}\n\t}\n\t//--------------------------------------------------------------\n\t/// End Element\n\t///\n\t/// Callback method used by SAX whenever a new element is found.\n\t//--------------------------------------------------------------\n\tpublic void EndElement(String instrUri, String instrLocalName, String instrQName, String inData) throws SAXException \n\t{\n\t\t//pop element type off to the imaginary element stack\n\t\tif (instrQName.equalsIgnoreCase(\"animation\"))\n\t\t\tPopAnimation(inData);\n\t\telse if (instrQName.equalsIgnoreCase(\"source\"))\n\t\t\tPopSource(inData);\n\t\telse if (instrQName.equalsIgnoreCase(\"float_array\"))\n\t\t\tPopFloatArray(inData);\n\t\telse if (instrQName.equalsIgnoreCase(\"name_array\"))\n\t\t\tPopNameArray(inData);\n\t\telse if (instrQName.equalsIgnoreCase(\"sampler\"))\n\t\t\tPopSampler(inData);\n\t\telse if (instrQName.equalsIgnoreCase(\"input\"))\n\t\t\tPopInput(inData);\n\t\telse if (instrQName.equalsIgnoreCase(\"channel\"))\n\t\t\tPopChannel(inData);\n\t\telse\n\t\t\tmdwIgnoreStack--;\n\t}\n\t//--------------------------------------------------------------\n\t/// Push Animation\n\t///\n\t/// Pushes the animation element type onto the element stack.\n\t//--------------------------------------------------------------\n\tprivate boolean PushAnimation(Attributes inAttributes)\n\t{\n\t\tif (mdwIgnoreStack > 0 ) return false;\n\t\t\n\t\tmCurrentAnimation = new ColladaAnimation();\n\t\tmCollada.m_animations.add(mCurrentAnimation);\n\t\t\n\t\treturn false;\n\t}\n\t//--------------------------------------------------------------\n\t/// Pop Animation\n\t///\n\t/// Pops the animation element type from the element stack.\n\t//--------------------------------------------------------------\n\tprivate void PopAnimation(String inData)\n\t{\n\t\tif (mdwIgnoreStack > 0 ) return;\n\t\t\n\t\tmCurrentAnimation = null;\n\t}\n\t//--------------------------------------------------------------\n\t/// Push Source\n\t///\n\t/// Pushes the source element type on to the element stack.\n\t//--------------------------------------------------------------\n\tprivate boolean PushSource(Attributes inAttributes)\n\t{\n\t\tif (mdwIgnoreStack > 0 ) return false;\n\t\t\n\t\t//create new source element\n\t\tmCurrentSource = new ColladaSource();\n\t\tmCurrentSource.mstrId = inAttributes.getValue(\"id\");\n\t\t\n\t\t//try and add to parent\n\t\tif (mCurrentAnimation != null)\n\t\t\tmCurrentAnimation.mSourceTable.put(mCurrentSource.mstrId, mCurrentSource);\n\t\telse\n\t\t\tLogging.logFatal(\"mCurrentController.mSkin is null!\");\n\t\t\n\t\treturn false;\n\t}\n\t//--------------------------------------------------------------\n\t/// Pop Source\n\t///\n\t/// Pops the source element type from the element stack.\n\t//--------------------------------------------------------------\n\tprivate void PopSource(String inData)\n\t{\n\t\tif (mdwIgnoreStack > 0 ) return;\n\t\t\n\t\tmCurrentSource = null;\n\t}\n\t//--------------------------------------------------------------\n\t/// Push Float Array\n\t///\n\t/// Pushes the float array element type on to the element stack.\n\t//--------------------------------------------------------------\n\tprivate boolean PushFloatArray(Attributes inAttributes)\n\t{\n\t\tif (mdwIgnoreStack > 0 ) return false;\n\t\t\n\t\t//create the float array\n\t\tmCurrentFloatArray = new ColladaFloatArray();\n\t\tmCurrentFloatArray.mdwCount = Integer.parseInt(inAttributes.getValue(\"count\"));\n\t\tmCurrentFloatArray.mstrId = inAttributes.getValue(\"id\");\n\t\tmCurrentFloatArray.mafData = new float[mCurrentFloatArray.mdwCount];\n\t\t\n\t\t//try and add to parent\n\t\tif (mCurrentSource != null)\n\t\t\tmCurrentSource.mFloatArray = mCurrentFloatArray;\n\t\telse\n\t\t\tLogging.logFatal(\"No available parent for float array!\");\n\t\t\n\t\treturn true;\n\t}\n\t//--------------------------------------------------------------\n\t/// Pop Float Array\n\t///\n\t/// Pops the float array element type from the element stack.\n\t//--------------------------------------------------------------\n\tprivate void PopFloatArray(String inData)\n\t{\n\t\tif (mdwIgnoreStack > 0 ) return;\n\t\t\n\t\t//convert to a list of float strings\n\t\tString[] astrSplitBuffer = ColladaUtils.SplitOnWhitespace(inData);\n\t\t\n\t\tif (astrSplitBuffer.length == mCurrentFloatArray.mdwCount)\n\t\t{\n\t\t\t//convert the float strings to a list of actual floats\n\t\t\tfor (int i = 0; i < astrSplitBuffer.length; i++)\n\t\t\t{\n\t\t\t\tmCurrentFloatArray.mafData[i] = Float.parseFloat(astrSplitBuffer[i]);\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tLogging.logFatal(\"Incorrect number of values for 'float array'!\");\n\t\t}\n\t\t\n\t\tmCurrentFloatArray = null;\n\t}\n\t//--------------------------------------------------------------\n\t/// Push Name Array\n\t///\n\t/// Pushes the name array element type on to the element stack.\n\t//--------------------------------------------------------------\n\tprivate boolean PushNameArray(Attributes inAttributes)\n\t{\n\t\tif (mdwIgnoreStack > 0 ) return false;\n\t\t\n\t\t//create the float array\n\t\tmCurrentNameArray = new ColladaNameArray();\n\t\tmCurrentNameArray.mdwCount = Integer.parseInt(inAttributes.getValue(\"count\"));\n\t\tmCurrentNameArray.mstrId = inAttributes.getValue(\"id\");\n\t\tmCurrentNameArray.mstrData = new String[mCurrentNameArray.mdwCount];\n\t\t\n\t\t//try and add to parent\n\t\tif (mCurrentSource != null)\n\t\t\tmCurrentSource.mNameArray = mCurrentNameArray;\n\t\telse\n\t\t\tLogging.logFatal(\"No available parent for name array!\");\n\t\t\n\t\treturn true;\n\t}\n\t//--------------------------------------------------------------\n\t/// Pop Name Array\n\t///\n\t/// Pops the name array element type from the element stack.\n\t//--------------------------------------------------------------\n\tprivate void PopNameArray(String inData)\n\t{\n\t\tif (mdwIgnoreStack > 0 ) return;\n\t\t\n\t\t//convert to a list of float strings\n\t\tString[] astrSplitBuffer = ColladaUtils.SplitOnWhitespace(inData);\n\t\t\n\t\tif (astrSplitBuffer.length == mCurrentNameArray.mdwCount)\n\t\t{\n\t\t\t//convert the float strings to a list of actual floats\n\t\t\tfor (int i = 0; i < astrSplitBuffer.length; i++)\n\t\t\t{\n\t\t\t\tmCurrentNameArray.mstrData[i] = astrSplitBuffer[i];\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tLogging.logFatal(\"Incorrect number of values for 'name array'!\");\n\t\t}\n\t\t\n\t\tmCurrentNameArray = null;\n\t}\n\t//--------------------------------------------------------------\n\t/// Push Sampler\n\t///\n\t/// Pushes the sampler element type on to the element stack.\n\t//--------------------------------------------------------------\n\tprivate boolean PushSampler(Attributes inAttributes)\n\t{\n\t\tif (mdwIgnoreStack > 0 ) return false;\n\t\t\n\t\t//create new source element\n\t\tmCurrentSampler = new ColladaSampler();\n\t\tmCurrentSampler.mstrId = inAttributes.getValue(\"id\");\n\t\t\n\t\t//try and add to parent\n\t\tif (mCurrentAnimation != null)\n\t\t\tmCurrentAnimation.mSamplerTable.put(mCurrentSampler.mstrId, mCurrentSampler);\n\t\telse\n\t\t\tLogging.logFatal(\"mCurrentAnimation is null!\");\n\t\t\n\t\treturn false;\n\t}\n\t//--------------------------------------------------------------\n\t/// Pop Sampler\n\t///\n\t/// Pops the sampler element type from the element stack.\n\t//--------------------------------------------------------------\n\tprivate void PopSampler(String inData)\n\t{\n\t\tif (mdwIgnoreStack > 0 ) return;\n\t\t\n\t\tmCurrentSampler = null;\n\t}\n\t//--------------------------------------------------------------\n\t/// Push Input\n\t///\n\t/// Push the input element type on to the element stack.\n\t//--------------------------------------------------------------\n\tprivate boolean PushInput(Attributes inAttributes)\n\t{\n\t\tif (mdwIgnoreStack > 0 ) return false;\n\t\t\n\t\t//create the \"input\"\n\t\tColladaInput input = new ColladaInput();\n\t\tinput.mstrSemantic = inAttributes.getValue(\"semantic\");\n\t\tinput.mstrSource = inAttributes.getValue(\"source\");\n\t\tinput.mdwOffset = ColladaUtils.GetIntAttributeOrZero(inAttributes, \"offset\");\n\t\tinput.mdwSet = ColladaUtils.GetIntAttributeOrZero(inAttributes, \"set\");\n\t\t\n\t\t//try and add to parent\n\t\tif (mCurrentSampler != null)\n\t\t\tmCurrentSampler.mInputTable.put(input.mstrSemantic, input);\n\t\telse\n\t\t\tLogging.logFatal(\"No available parent for 'input'!\");\n\t\t\n\t\treturn false;\n\n\t}\n\t//--------------------------------------------------------------\n\t/// Pop Input\n\t///\n\t/// Pops the input element type on to the element stack.\n\t//--------------------------------------------------------------\n\tprivate void PopInput(String inData)\n\t{\n\t\tif (mdwIgnoreStack > 0 ) return;\n\t}\n\t//--------------------------------------------------------------\n\t/// Push Channel\n\t///\n\t/// Pushes the channel element type on to the element stack.\n\t//--------------------------------------------------------------\n\tprivate boolean PushChannel(Attributes inAttributes)\n\t{\n\t\tif (mdwIgnoreStack > 0 ) return false;\n\t\t\n\t\t//create the \"input\"\n\t\tColladaChannel channel = new ColladaChannel();\n\t\tchannel.mstrTarget = inAttributes.getValue(\"target\");\n\t\tchannel.mstrSource = inAttributes.getValue(\"source\");\n\t\t\n\t\t//try and add to parent\n\t\tif (mCurrentAnimation != null)\n\t\t\tmCurrentAnimation.mChannelList.add(channel);\n\t\telse\n\t\t\tLogging.logFatal(\"mCurrentAnimation is null!\");\n\t\t\n\t\treturn false;\n\n\t}\n\t//--------------------------------------------------------------\n\t/// Pop Channel\n\t///\n\t/// Pops the channel element type from the element stack.\n\t//--------------------------------------------------------------\n\tprivate void PopChannel(String inData)\n\t{\n\t\tif (mdwIgnoreStack > 0 ) return;\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/ColladaParserUtils/src/com/chilliworks/chillisource/colladaparserutils/LibraryControllersParser.java",
    "content": "/**\n * LibraryAnimationsParser.java\n * ChilliSource\n * Created by Ian Copland on 16/01/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.colladaparserutils;\n\nimport org.xml.sax.Attributes;\nimport org.xml.sax.SAXException;\n\nimport com.chilliworks.chillisource.colladaparserutils.colladadata.*;\nimport com.chilliworks.chillisource.coreutils.Logging;\n\npublic class LibraryControllersParser \n{\n\t//--------------------------------------------------------------\n\t/// Private Member Data\n\t//--------------------------------------------------------------\n\tprivate int mdwIgnoreStack;\n\tprivate Collada mCollada;\n\tprivate ColladaController mCurrentController;\n\tprivate ColladaBindShapeMatrix mCurrentBindShapeMatrix;\n\tprivate ColladaSource mCurrentSource;\n\tprivate ColladaFloatArray mCurrentFloatArray;\n\tprivate ColladaNameArray mCurrentNameArray;\n\tprivate ColladaJoints mCurrentJoints;\n\tprivate ColladaVertexWeights mCurrentVertexWeights;\n\tprivate ColladaVCount mCurrentVCount;\n\tprivate ColladaV mCurrentV;\n\t//--------------------------------------------------------------\n\t/// Constructor\n\t//--------------------------------------------------------------\n\tpublic LibraryControllersParser(Collada inColladaData)\n\t{\n\t\tmCollada = inColladaData;\n\t\tmdwIgnoreStack = 0;\n\t}\n\t//--------------------------------------------------------------\n\t/// Start Element\n\t///\n\t/// Callback method used by SAX whenever a new element is found.\n\t//--------------------------------------------------------------\n\tpublic boolean StartElement(String instrUri, String instrLocalName,String instrQName, Attributes inAttributes) throws SAXException \n\t{\n\t\t//push element type on to the imaginary element stack\n\t\tif (instrQName.equalsIgnoreCase(\"controller\"))\n\t\t\treturn PushController(inAttributes);\n\t\telse if (instrQName.equalsIgnoreCase(\"skin\"))\n\t\t\treturn PushSkin(inAttributes);\n\t\telse if (instrQName.equalsIgnoreCase(\"bind_shape_matrix\"))\n\t\t\treturn PushBindShapeMatrix(inAttributes);\n\t\telse if (instrQName.equalsIgnoreCase(\"source\"))\n\t\t\treturn PushSource(inAttributes);\n\t\telse if (instrQName.equalsIgnoreCase(\"float_array\"))\n\t\t\treturn PushFloatArray(inAttributes);\n\t\telse if (instrQName.equalsIgnoreCase(\"name_array\"))\n\t\t\treturn PushNameArray(inAttributes);\n\t\telse if (instrQName.equalsIgnoreCase(\"joints\"))\n\t\t\treturn PushJoints(inAttributes);\n\t\telse if (instrQName.equalsIgnoreCase(\"input\"))\n\t\t\treturn PushInput(inAttributes);\n\t\telse if (instrQName.equalsIgnoreCase(\"vertex_weights\"))\n\t\t\treturn PushVertexWeights(inAttributes);\n\t\telse if (instrQName.equalsIgnoreCase(\"vcount\"))\n\t\t\treturn PushVCount(inAttributes);\n\t\telse if (instrQName.equalsIgnoreCase(\"v\"))\n\t\t\treturn PushV(inAttributes);\n\t\telse\n\t\t{\n\t\t\tmdwIgnoreStack++;\n\t\t\treturn false;\n\t\t}\n\t}\n\t//--------------------------------------------------------------\n\t/// End Element\n\t///\n\t/// Callback method used by SAX whenever a new element is found.\n\t//--------------------------------------------------------------\n\tpublic void EndElement(String instrUri, String instrLocalName, String instrQName, String inData) throws SAXException \n\t{\n\t\t//pop element type off to the imaginary element stack\n\t\tif (instrQName.equalsIgnoreCase(\"controller\"))\n\t\t\tPopController(inData);\n\t\telse if (instrQName.equalsIgnoreCase(\"skin\"))\n\t\t\tPopSkin(inData);\n\t\telse if (instrQName.equalsIgnoreCase(\"bind_shape_matrix\"))\n\t\t\tPopBindShapeMatrix(inData);\n\t\telse if (instrQName.equalsIgnoreCase(\"source\"))\n\t\t\tPopSource(inData);\n\t\telse if (instrQName.equalsIgnoreCase(\"float_array\"))\n\t\t\tPopFloatArray(inData);\n\t\telse if (instrQName.equalsIgnoreCase(\"name_array\"))\n\t\t\tPopNameArray(inData);\n\t\telse if (instrQName.equalsIgnoreCase(\"joints\"))\n\t\t\tPopJoints(inData);\n\t\telse if (instrQName.equalsIgnoreCase(\"input\"))\n\t\t\tPopInput(inData);\n\t\telse if (instrQName.equalsIgnoreCase(\"vertex_weights\"))\n\t\t\tPopVertexWeights(inData);\n\t\telse if (instrQName.equalsIgnoreCase(\"vcount\"))\n\t\t\tPopVCount(inData);\n\t\telse if (instrQName.equalsIgnoreCase(\"v\"))\n\t\t\tPopV(inData);\n\t\telse\n\t\t\tmdwIgnoreStack--;\n\t\t\t\n\t}\n\t//--------------------------------------------------------------\n\t/// Push Controller\n\t///\n\t/// Pushes a controller element type on to the element stack.\n\t//--------------------------------------------------------------\n\tprivate boolean PushController(Attributes inAttributes)\n\t{\n\t\tif (mdwIgnoreStack > 0 ) return false;\n\t\t\n\t\tmCurrentController = new ColladaController();\n\t\tmCurrentController.mstrId = inAttributes.getValue(\"id\");\n\t\t\n\t\tif (mCollada.mLibraryControllers != null)\n\t\t\tmCollada.mLibraryControllers.put(mCurrentController.mstrId, mCurrentController);\n\t\telse\n\t\t\tLogging.logFatal(\"mLibraryControllers is null!\");\n\t\t\n\t\treturn false;\n\t}\n\t//--------------------------------------------------------------\n\t/// Pop Controller\n\t///\n\t/// Pops a controller element type from the element stack.\n\t//--------------------------------------------------------------\n\tprivate void PopController(String inData)\n\t{\n\t\tif (mdwIgnoreStack > 0 ) return;\n\t\t\n\t\tmCurrentController = null;\n\t}\n\t//--------------------------------------------------------------\n\t/// Push Skin\n\t///\n\t/// Pushes a skin element type on to the element stack.\n\t//--------------------------------------------------------------\n\tprivate boolean PushSkin(Attributes inAttributes)\n\t{\n\t\tif (mdwIgnoreStack > 0 ) return false;\n\t\t\n\t\tColladaSkin newSkin = new ColladaSkin();\n\t\tnewSkin.mstrSource = inAttributes.getValue(\"source\");\n\t\t\n\t\tif (mCurrentController != null)\n\t\t\tmCurrentController.mSkin = newSkin;\n\t\telse\n\t\t\tLogging.logFatal(\"mCurrentController is null!\");\n\t\t\n\t\treturn false;\n\t}\n\t//--------------------------------------------------------------\n\t/// Pop Skin\n\t///\n\t/// Pops a skin element type from the element stack.\n\t//--------------------------------------------------------------\n\tprivate void PopSkin(String inData)\n\t{\n\t\tif (mdwIgnoreStack > 0 ) return;\n\t}\n\t//--------------------------------------------------------------\n\t/// Push Bind Shape Matrix\n\t///\n\t/// Pushes a bind shape matrix element type on to the element stack.\n\t//--------------------------------------------------------------\n\tprivate boolean PushBindShapeMatrix(Attributes inAttributes)\n\t{\n\t\tif (mdwIgnoreStack > 0 ) return false;\n\t\t\n\t\tmCurrentBindShapeMatrix = new ColladaBindShapeMatrix();\n\t\t\n\t\tif (mCurrentController != null && mCurrentController.mSkin != null)\n\t\t\tmCurrentController.mSkin.mBindShapeMatrix = mCurrentBindShapeMatrix;\n\t\telse\n\t\t\tLogging.logFatal(\"mBindShapeMatrix is null!\");\n\t\t\n\t\treturn true;\n\t}\n\t//--------------------------------------------------------------\n\t/// Pop Bind Shape Matrix\n\t///\n\t/// Pops a bind shape matrix element type from the element stack.\n\t//--------------------------------------------------------------\n\tprivate void PopBindShapeMatrix(String inData)\n\t{\n\t\tif (mdwIgnoreStack > 0 ) return;\n\t\t\n\t\tString[] astrSplitBuffer = ColladaUtils.SplitOnWhitespace(inData);\n\t\t\n\t\tmCurrentBindShapeMatrix.maafValues = new float[4][4];\n\t\t\n\t\tfor (int i = 0; i < 4; i++)\n\t\t{\n\t\t\tfor (int j = 0; j < 4; j++)\n\t\t\t{\n\t\t\t\tmCurrentBindShapeMatrix.maafValues[i][j] = Float.parseFloat(astrSplitBuffer[i * 4 + j]);\n\t\t\t}\n\t\t}\n\t\t\n\t\tmCurrentBindShapeMatrix = null;\n\t}\n\t//--------------------------------------------------------------\n\t/// Push Source\n\t///\n\t/// Pushes a source element type on to the element stack.\n\t//--------------------------------------------------------------\n\tprivate boolean PushSource(Attributes inAttributes)\n\t{\n\t\tif (mdwIgnoreStack > 0 ) return false;\n\t\t\n\t\t//create new source element\n\t\tmCurrentSource = new ColladaSource();\n\t\tmCurrentSource.mstrId = inAttributes.getValue(\"id\");\n\t\t\n\t\t//try and add to parent\n\t\tif (mCurrentController != null && mCurrentController.mSkin != null)\n\t\t\tmCurrentController.mSkin.mSourceTable.put(mCurrentSource.mstrId, mCurrentSource);\n\t\telse\n\t\t\tLogging.logFatal(\"mCurrentController.mSkin is null!\");\n\t\t\n\t\treturn false;\n\t}\n\t//--------------------------------------------------------------\n\t/// Pop Source\n\t///\n\t/// Pops a source element type from the element stack.\n\t//--------------------------------------------------------------\n\tprivate void PopSource(String inData)\n\t{\n\t\tif (mdwIgnoreStack > 0 ) return;\n\t\t\n\t\tmCurrentSource = null;\n\t}\n\t//--------------------------------------------------------------\n\t/// Push Float Array\n\t///\n\t/// Pushes a float array element type onto the element stack.\n\t//--------------------------------------------------------------\n\tprivate boolean PushFloatArray(Attributes inAttributes)\n\t{\n\t\tif (mdwIgnoreStack > 0 ) return false;\n\t\t\n\t\t//create the float array\n\t\tmCurrentFloatArray = new ColladaFloatArray();\n\t\tmCurrentFloatArray.mdwCount = Integer.parseInt(inAttributes.getValue(\"count\"));\n\t\tmCurrentFloatArray.mstrId = inAttributes.getValue(\"id\");\n\t\tmCurrentFloatArray.mafData = new float[mCurrentFloatArray.mdwCount];\n\t\t\n\t\t//try and add to parent\n\t\tif (mCurrentSource != null)\n\t\t\tmCurrentSource.mFloatArray = mCurrentFloatArray;\n\t\telse\n\t\t\tLogging.logFatal(\"No available parent for float array!\");\n\t\t\n\t\treturn true;\n\t}\n\t//--------------------------------------------------------------\n\t/// Pop Float Array\n\t///\n\t/// Pops a float array element type from the element stack.\n\t//--------------------------------------------------------------\n\tprivate void PopFloatArray(String inData)\n\t{\n\t\tif (mdwIgnoreStack > 0 ) return;\n\t\t\n\t\t//convert to a list of float strings\n\t\tString[] astrSplitBuffer = ColladaUtils.SplitOnWhitespace(inData);\n\t\t\n\t\tif (astrSplitBuffer.length == mCurrentFloatArray.mdwCount)\n\t\t{\n\t\t\t//convert the float strings to a list of actual floats\n\t\t\tfor (int i = 0; i < astrSplitBuffer.length; i++)\n\t\t\t{\n\t\t\t\tmCurrentFloatArray.mafData[i] = Float.parseFloat(astrSplitBuffer[i]);\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tLogging.logFatal(\"Incorrect number of values for 'float array'!\");\n\t\t}\n\t\t\n\t\tmCurrentFloatArray = null;\n\t}\n\t//--------------------------------------------------------------\n\t/// Push Name Array\n\t///\n\t/// Pushes a name array element type on to the element stack.\n\t//--------------------------------------------------------------\n\tprivate boolean PushNameArray(Attributes inAttributes)\n\t{\n\t\tif (mdwIgnoreStack > 0 ) return false;\n\t\t\n\t\t//create the float array\n\t\tmCurrentNameArray = new ColladaNameArray();\n\t\tmCurrentNameArray.mdwCount = Integer.parseInt(inAttributes.getValue(\"count\"));\n\t\tmCurrentNameArray.mstrId = inAttributes.getValue(\"id\");\n\t\tmCurrentNameArray.mstrData = new String[mCurrentNameArray.mdwCount];\n\t\t\n\t\t//try and add to parent\n\t\tif (mCurrentSource != null)\n\t\t\tmCurrentSource.mNameArray = mCurrentNameArray;\n\t\telse\n\t\t\tLogging.logFatal(\"No available parent for name array!\");\n\t\t\n\t\treturn true;\n\t}\n\t//--------------------------------------------------------------\n\t/// Pop Name Array\n\t///\n\t/// Pops a name array element type from the element stack.\n\t//--------------------------------------------------------------\n\tprivate void PopNameArray(String inData)\n\t{\n\t\tif (mdwIgnoreStack > 0 ) return;\n\t\t\n\t\t//convert to a list of float strings\n\t\tString[] astrSplitBuffer = ColladaUtils.SplitOnWhitespace(inData);\n\t\t\n\t\tif (astrSplitBuffer.length == mCurrentNameArray.mdwCount)\n\t\t{\n\t\t\t//convert the float strings to a list of actual floats\n\t\t\tfor (int i = 0; i < astrSplitBuffer.length; i++)\n\t\t\t{\n\t\t\t\tmCurrentNameArray.mstrData[i] = astrSplitBuffer[i];\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tLogging.logFatal(\"Incorrect number of values for 'name array'!\");\n\t\t}\n\t\t\n\t\tmCurrentNameArray = null;\n\t}\n\t//--------------------------------------------------------------\n\t/// Push Joints\n\t///\n\t/// Pushes a joints element type on to the element stack.\n\t//--------------------------------------------------------------\n\tprivate boolean PushJoints(Attributes inAttributes)\n\t{\n\t\tif (mdwIgnoreStack > 0 ) return false;\n\t\tmCurrentJoints = new ColladaJoints();\n\t\t\n\t\tif (mCurrentController != null && mCurrentController.mSkin != null)\n\t\t\tmCurrentController.mSkin.mJoints = mCurrentJoints;\n\t\telse\n\t\t\tLogging.logFatal(\"mCurrentController.mSkin is null!\");\n\t\t\n\t\treturn true;\n\t}\n\t//--------------------------------------------------------------\n\t/// Pop Joints\n\t///\n\t/// Pops a joints element type from the element stack.\n\t//--------------------------------------------------------------\n\tprivate void PopJoints(String inData)\n\t{\n\t\tif (mdwIgnoreStack > 0 ) return;\n\t\t\n\t\tmCurrentJoints = null;\n\t}\n\t//--------------------------------------------------------------\n\t/// Push Input\n\t///\n\t/// Pushes an input element type on to the element stack.\n\t//--------------------------------------------------------------\n\tprivate boolean PushInput(Attributes inAttributes)\n\t{\n\t\tif (mdwIgnoreStack > 0 ) return false;\n\t\t\n\t\t//create the \"input\"\n\t\tColladaInput input = new ColladaInput();\n\t\tinput.mstrSemantic = inAttributes.getValue(\"semantic\");\n\t\tinput.mstrSource = inAttributes.getValue(\"source\");\n\t\tinput.mdwOffset = ColladaUtils.GetIntAttributeOrZero(inAttributes, \"offset\");\n\t\tinput.mdwSet = ColladaUtils.GetIntAttributeOrZero(inAttributes, \"set\");\n\t\t\n\t\t//try and add to parent\n\t\tif (mCurrentJoints != null)\n\t\t\tmCurrentJoints.mInputs.add(input);\n\t\telse if (mCurrentVertexWeights != null)\n\t\t\tmCurrentVertexWeights.mInputs.add(input);\n\t\telse\n\t\t\tLogging.logFatal(\"No available parent for 'input'!\");\n\t\t\n\t\treturn false;\n\n\t}\n\t//--------------------------------------------------------------\n\t/// Pop Input\n\t///\n\t/// Pops an input element type from the element stack.\n\t//--------------------------------------------------------------\n\tprivate void PopInput(String inData)\n\t{\n\t\tif (mdwIgnoreStack > 0 ) return;\n\t}\n\t//--------------------------------------------------------------\n\t/// Push Vertex Weights\n\t///\n\t/// Pushes a vertex weights element type on to the element stack.\n\t//--------------------------------------------------------------\n\tprivate boolean PushVertexWeights(Attributes inAttributes)\n\t{\n\t\tif (mdwIgnoreStack > 0 ) return false;\n\t\t\n\t\t//create the \"input\"\n\t\tmCurrentVertexWeights = new ColladaVertexWeights();\n\t\tmCurrentVertexWeights.mdwCount = Integer.parseInt(inAttributes.getValue(\"count\"));\n\t\t\n\t\t//try and add to parent\n\t\tif (mCurrentController != null && mCurrentController.mSkin != null)\n\t\t\tmCurrentController.mSkin.mVertexWeights = mCurrentVertexWeights;\n\t\telse\n\t\t\tLogging.logFatal(\"mCurrentController.mSkin is null!\");\n\t\t\n\t\treturn false;\n\n\t}\n\t//--------------------------------------------------------------\n\t/// Pops Vertex Weights\n\t///\n\t/// Pops a vertex weights element type from the element stack.\n\t//--------------------------------------------------------------\n\tprivate void PopVertexWeights(String inData)\n\t{\n\t\tif (mdwIgnoreStack > 0 ) return;\n\t\t\n\t\tmCurrentVertexWeights = null;\n\t}\n\t//--------------------------------------------------------------\n\t/// Push VCount\n\t///\n\t/// Pushes a vcount element type on to the element stack.\n\t//--------------------------------------------------------------\n\tprivate boolean PushVCount(Attributes inAttributes)\n\t{\n\t\tif (mdwIgnoreStack > 0 ) return false;\n\t\t\n\t\t//create current p\n\t\tmCurrentVCount = new ColladaVCount();\n\t\t\n\t\tif (mCurrentVertexWeights != null)\n\t\t{\n\t\t\tmCurrentVertexWeights.mVCount = mCurrentVCount;\n\t\t}else\n\t\t\tLogging.logFatal(\"No available parent for 'vcount'!\");\n\t\t\n\t\treturn true;\n\t}\n\t//--------------------------------------------------------------\n\t/// Pop VCount\n\t///\n\t/// Pops a vcount element type from the element stack.\n\t//--------------------------------------------------------------\n\tprivate void PopVCount(String inData)\n\t{\n\t\tif (mdwIgnoreStack > 0 ) return;\n\t\t\n\t\t//convert to a list of int strings\n\t\tString[] astrSplitBuffer = ColladaUtils.SplitOnWhitespace(inData);\n\t\t\n\t\tif (astrSplitBuffer.length > 0)\n\t\t{\n\t\t\tmCurrentVCount.madwData = new int[astrSplitBuffer.length];\n\t\t\t\n\t\t\tfor (int i = 0; i < astrSplitBuffer.length; i++)\n\t\t\t{\n\t\t\t\tmCurrentVCount.madwData[i] = Integer.parseInt(astrSplitBuffer[i]);\n\t\t\t}\n\t\t}\n\t\t\n\t\tmCurrentVCount = null;\n\t}\n\t//--------------------------------------------------------------\n\t/// Push V\n\t///\n\t/// Pushes a v element type on to the element stack.\n\t//--------------------------------------------------------------\n\tprivate boolean PushV(Attributes inAttributes)\n\t{\n\t\tif (mdwIgnoreStack > 0 ) return false;\n\t\t\n\t\t//create current p\n\t\tmCurrentV = new ColladaV();\n\t\t\n\t\tif (mCurrentVertexWeights != null)\n\t\t{\n\t\t\tmCurrentVertexWeights.mV = mCurrentV;\n\t\t}else\n\t\t\tLogging.logFatal(\"No available parent for 'v'!\");\n\t\t\n\t\treturn true;\n\t}\n\t//--------------------------------------------------------------\n\t/// Pop V\n\t///\n\t/// Pops a v element type from the element stack.\n\t//--------------------------------------------------------------\n\tprivate void PopV(String inData)\n\t{\n\t\tif (mdwIgnoreStack > 0 ) return;\n\t\t\n\t\t//convert to a list of int strings\n\t\tString[] astrSplitBuffer = ColladaUtils.SplitOnWhitespace(inData);\n\t\t\n\t\tif (astrSplitBuffer.length > 0)\n\t\t{\n\t\t\tmCurrentV.madwData = new int[astrSplitBuffer.length];\n\n\t\t\tfor (int i = 0; i < astrSplitBuffer.length; i++)\n\t\t\t{\n\t\t\t\tmCurrentV.madwData[i] = Integer.parseInt(astrSplitBuffer[i]);\n\t\t\t}\n\t\t}\n\t\t\n\t\tmCurrentVCount = null;\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/ColladaParserUtils/src/com/chilliworks/chillisource/colladaparserutils/LibraryEffectsParser.java",
    "content": "/**\n * LibraryEffectsParser.java\n * ChilliSource\n * Created by Ian Copland on 16/01/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.colladaparserutils;\n\nimport org.xml.sax.Attributes;\nimport org.xml.sax.SAXException;\n\nimport com.chilliworks.chillisource.colladaparserutils.colladadata.*;\nimport com.chilliworks.chillisource.coreutils.Logging;\n\npublic class LibraryEffectsParser \n{\n\t//--------------------------------------------------------------\n\t/// Private Member Data\n\t//--------------------------------------------------------------\n\tprivate int mdwIgnoreStack;\n\tprivate Collada mCollada;\n\tprivate ColladaEffect mCurrentEffect;\n\tprivate ColladaNewParam mCurrentNewParam;\n\tprivate ColladaTechnique mCurrentTechnique;\n\tprivate ColladaMaterialColour mCurrentMaterialColour;\n\tprivate ColladaShininess mCurrentShininess;\n\tprivate ColladaColour mCurrentColour;\n\tprivate ColladaFloat mCurrentFloat;\n\tprivate ColladaSource mCurrentSource;\n\tprivate ColladaInitFrom mCurrentInitFrom;\n\t//--------------------------------------------------------------\n\t/// Constructor\n\t//--------------------------------------------------------------\n\tpublic LibraryEffectsParser(Collada inColladaData)\n\t{\n\t\tmCollada = inColladaData;\n\t\tmdwIgnoreStack = 0;\n\t}\n\t//--------------------------------------------------------------\n\t/// Start Element\n\t///\n\t/// Callback method used by SAX whenever a new element is found.\n\t//--------------------------------------------------------------\n\tpublic boolean StartElement(String instrUri, String instrLocalName,String instrQName, Attributes inAttributes) throws SAXException \n\t{\t\n\t\t//push element type on to the imaginary element stack\n\t\tif (instrQName.equalsIgnoreCase(\"effect\"))\n\t\t\treturn PushEffect(inAttributes);\n\t\telse if (instrQName.equalsIgnoreCase(\"profile_COMMON\"))\n\t\t\treturn PushProfileCommon(inAttributes);\n\t\telse if (instrQName.equalsIgnoreCase(\"newparam\"))\n\t\t\treturn PushNewParam(inAttributes);\n\t\telse if (instrQName.equalsIgnoreCase(\"surface\"))\n\t\t\treturn PushSurface(inAttributes);\n\t\telse if (instrQName.equalsIgnoreCase(\"sampler2D\"))\n\t\t\treturn PushSampler2D(inAttributes);\n\t\telse if (instrQName.equalsIgnoreCase(\"technique\"))\n\t\t\treturn PushTechnique(inAttributes);\n\t\telse if (instrQName.equalsIgnoreCase(\"blinn\"))\n\t\t\treturn PushBlinn(inAttributes);\n\t\telse if (instrQName.equalsIgnoreCase(\"phong\"))\n\t\t\treturn PushPhong(inAttributes);\n\t\telse if (instrQName.equalsIgnoreCase(\"emissive\"))\n\t\t\treturn PushEmissive(inAttributes);\n\t\telse if (instrQName.equalsIgnoreCase(\"ambient\"))\n\t\t\treturn PushAmbient(inAttributes);\n\t\telse if (instrQName.equalsIgnoreCase(\"diffuse\"))\n\t\t\treturn PushDiffuse(inAttributes);\n\t\telse if (instrQName.equalsIgnoreCase(\"specular\"))\n\t\t\treturn PushSpecular(inAttributes);\n\t\telse if (instrQName.equalsIgnoreCase(\"shininess\"))\n\t\t\treturn PushShininess(inAttributes);\n\t\telse if (instrQName.equalsIgnoreCase(\"color\"))\n\t\t\treturn PushColour(inAttributes);\n\t\telse if (instrQName.equalsIgnoreCase(\"texture\"))\n\t\t\treturn PushTexture(inAttributes);\n\t\telse if (instrQName.equalsIgnoreCase(\"float\"))\n\t\t\treturn PushFloat(inAttributes);\n\t\telse if (instrQName.equalsIgnoreCase(\"source\"))\n\t\t\treturn PushSource(inAttributes);\n\t\telse if (instrQName.equalsIgnoreCase(\"init_from\"))\n\t\t\treturn PushInitFrom(inAttributes);\n\t\telse\n\t\t{\n\t\t\tmdwIgnoreStack++;\n\t\t\treturn false;\n\t\t}\n\t}\n\t//--------------------------------------------------------------\n\t/// End Element\n\t///\n\t/// Callback method used by SAX whenever a new element is found.\n\t//--------------------------------------------------------------\n\tpublic void EndElement(String instrUri, String instrLocalName,String instrQName, String inData) throws SAXException \n\t{\n\t\t//pop element type off to the imaginary element stack\n\t\tif (instrQName.equalsIgnoreCase(\"effect\"))\n\t\t\tPopEffect(inData);\n\t\telse if (instrQName.equalsIgnoreCase(\"profile_COMMON\"))\n\t\t\tPopProfileCommon(inData);\n\t\telse if (instrQName.equalsIgnoreCase(\"newparam\"))\n\t\t\tPopNewParam(inData);\n\t\telse if (instrQName.equalsIgnoreCase(\"surface\"))\n\t\t\tPopSurface(inData);\n\t\telse if (instrQName.equalsIgnoreCase(\"sampler2D\"))\n\t\t\tPopSampler2D(inData);\n\t\telse if (instrQName.equalsIgnoreCase(\"technique\"))\n\t\t\tPopTechnique(inData);\n\t\telse if (instrQName.equalsIgnoreCase(\"blinn\"))\n\t\t\tPopBlinn(inData);\n\t\telse if (instrQName.equalsIgnoreCase(\"phong\"))\n\t\t\tPopPhong(inData);\n\t\telse if (instrQName.equalsIgnoreCase(\"emissive\"))\n\t\t\tPopEmissive(inData);\n\t\telse if (instrQName.equalsIgnoreCase(\"ambient\"))\n\t\t\tPopAmbient(inData);\n\t\telse if (instrQName.equalsIgnoreCase(\"diffuse\"))\n\t\t\tPopDiffuse(inData);\n\t\telse if (instrQName.equalsIgnoreCase(\"specular\"))\n\t\t\tPopSpecular(inData);\n\t\telse if (instrQName.equalsIgnoreCase(\"shininess\"))\n\t\t\tPopShininess(inData);\n\t\telse if (instrQName.equalsIgnoreCase(\"color\"))\n\t\t\tPopColour(inData);\n\t\telse if (instrQName.equalsIgnoreCase(\"texture\"))\n\t\t\tPopTexture(inData);\n\t\telse if (instrQName.equalsIgnoreCase(\"float\"))\n\t\t\tPopFloat(inData);\n\t\telse if (instrQName.equalsIgnoreCase(\"source\"))\n\t\t\tPopSource(inData);\n\t\telse if (instrQName.equalsIgnoreCase(\"init_from\"))\n\t\t\tPopInitFrom(inData);\n\t\telse\n\t\t\tmdwIgnoreStack--;\n\t}\n\t//--------------------------------------------------------------\n\t/// Push Effect\n\t///\n\t/// Pushes an effect element type on to the element stack.\n\t//--------------------------------------------------------------\n\tprivate boolean PushEffect(Attributes inAttributes)\n\t{\n\t\tif (mdwIgnoreStack > 0 ) return false;\n\t\t\n\t\tmCurrentEffect = new ColladaEffect();\n\t\tmCurrentEffect.mstrId = inAttributes.getValue(\"id\");\n\t\t\n\t\tif (mCollada.mLibraryEffects != null)\n\t\t\tmCollada.mLibraryEffects.put(mCurrentEffect.mstrId, mCurrentEffect);\n\t\telse\n\t\t\tLogging.logFatal(\"mLibraryEffects is null!\");\n\t\t\n\t\treturn false;\n\t}\n\t//--------------------------------------------------------------\n\t/// Pop Effect\n\t///\n\t/// Pops an effect element type from the element stack.\n\t//--------------------------------------------------------------\n\tprivate void PopEffect(String inData)\n\t{\n\t\tmCurrentEffect = null;\n\t}\n\t//--------------------------------------------------------------\n\t/// Push Profile Common\n\t///\n\t/// Pushes an profile common element type on to the element stack.\n\t//--------------------------------------------------------------\n\tprivate boolean PushProfileCommon(Attributes inAttributes)\n\t{\n\t\tif (mdwIgnoreStack > 0 ) return false;\n\t\t\n\t\tColladaProfileCommon profileCommon = new ColladaProfileCommon();\n\t\t\n\t\tif (mCurrentEffect != null)\n\t\t\tmCurrentEffect.mProfileCommon = profileCommon;\n\t\telse\n\t\t\tLogging.logFatal(\"mCurrentEffect is null!\");\n\t\t\n\t\treturn false;\n\t}\n\t//--------------------------------------------------------------\n\t/// Pop Profile Common\n\t///\n\t/// Pops an profile common element type from the element stack.\n\t//--------------------------------------------------------------\n\tprivate void PopProfileCommon(String inData)\n\t{\n\t\tif (mdwIgnoreStack > 0 ) return;\n\t}\n\t//--------------------------------------------------------------\n\t/// Push New Param\n\t///\n\t/// Pushes an new param element type on to the element stack.\n\t//--------------------------------------------------------------\n\tprivate boolean PushNewParam(Attributes inAttributes)\n\t{\n\t\tif (mdwIgnoreStack > 0 ) return false;\n\t\t\n\t\tmCurrentNewParam = new ColladaNewParam();\n\t\tmCurrentNewParam.mstrSId = inAttributes.getValue(\"sid\");\n\t\t\n\t\tif (mCurrentEffect != null && mCurrentEffect.mProfileCommon != null)\n\t\t\tmCurrentEffect.mProfileCommon.mNewParams.put(mCurrentNewParam.mstrSId, mCurrentNewParam);\n\t\telse\n\t\t\tLogging.logFatal(\"mCurrentEffect is null!\");\n\t\t\n\t\treturn false;\n\t}\n\t//--------------------------------------------------------------\n\t/// Pop New Param\n\t///\n\t/// Pops an new param element type from the element stack.\n\t//--------------------------------------------------------------\n\tprivate void PopNewParam(String inData)\n\t{\n\t\tif (mdwIgnoreStack > 0 ) return;\n\t\tmCurrentNewParam = null;\n\t}\n\t//--------------------------------------------------------------\n\t/// Push Surface\n\t///\n\t/// Pushes a surface element type on to the element stack.\n\t//--------------------------------------------------------------\n\tprivate boolean PushSurface(Attributes inAttributes)\n\t{\n\t\tif (mdwIgnoreStack > 0 ) return false;\n\t\t\n\t\tColladaSurface newSurface = new ColladaSurface();\n\t\tnewSurface.mstrType = inAttributes.getValue(\"type\");\n\t\t\n\t\tif (mCurrentNewParam != null)\n\t\t\tmCurrentNewParam.mSurface = newSurface;\n\t\telse\n\t\t\tLogging.logFatal(\"mCurrentNewParam is null!\");\n\t\t\n\t\treturn false;\n\t}\n\t//--------------------------------------------------------------\n\t/// Pop Surface\n\t///\n\t/// Pops a surface element type from the element stack.\n\t//--------------------------------------------------------------\n\tprivate void PopSurface(String inData)\n\t{\n\t\tif (mdwIgnoreStack > 0 ) return;\n\t}\n\t//--------------------------------------------------------------\n\t/// Push Sampler 2D\n\t///\n\t/// Pushes a sampler 2D element type on to the element stack.\n\t//--------------------------------------------------------------\n\tprivate boolean PushSampler2D(Attributes inAttributes)\n\t{\n\t\tif (mdwIgnoreStack > 0 ) return false;\n\t\t\n\t\tColladaSampler2D newSampler2D = new ColladaSampler2D();\n\t\t\n\t\tif (mCurrentNewParam != null)\n\t\t\tmCurrentNewParam.mSampler2D = newSampler2D;\n\t\telse\n\t\t\tLogging.logFatal(\"mCurrentNewParam is null!\");\n\t\t\n\t\treturn false;\n\t}\n\t//--------------------------------------------------------------\n\t/// Pop Sampler 2D\n\t///\n\t/// pops a sampler 2D element type from the element stack.\n\t//--------------------------------------------------------------\n\tprivate void PopSampler2D(String inData)\n\t{\n\t\tif (mdwIgnoreStack > 0 ) return;\n\t}\n\t//--------------------------------------------------------------\n\t/// Push Technique\n\t///\n\t/// Pushes a technique element type on to the element stack.\n\t//--------------------------------------------------------------\n\tprivate boolean PushTechnique(Attributes inAttributes)\n\t{\n\t\tif (mdwIgnoreStack > 0 ) return false;\n\t\t\n\t\tmCurrentTechnique = new ColladaTechnique();\n\t\tmCurrentTechnique.mstrSId = inAttributes.getValue(\"sid\");\n\t\t\n\t\tif (mCurrentEffect != null && mCurrentEffect.mProfileCommon != null)\n\t\t\tmCurrentEffect.mProfileCommon.mTechnique = mCurrentTechnique;\n\t\telse\n\t\t\tLogging.logFatal(\"mCurrentEffect is null!\");\n\t\t\n\t\treturn false;\n\t}\n\t//--------------------------------------------------------------\n\t/// Pop Technique\n\t///\n\t/// Pops a technique element type from the element stack.\n\t//--------------------------------------------------------------\n\tprivate void PopTechnique(String inData)\n\t{\n\t\tif (mdwIgnoreStack > 0 ) return;\n\t\tmCurrentTechnique = null;\n\t}\n\t//--------------------------------------------------------------\n\t/// Push Blinn\n\t///\n\t/// Pushes a blinn element type on to the element stack.\n\t//--------------------------------------------------------------\n\tprivate boolean PushBlinn(Attributes inAttributes)\n\t{\n\t\tif (mdwIgnoreStack > 0 ) return false;\n\t\t\n\t\tColladaBlinnAndPhong newBlinnAndPhong = new ColladaBlinnAndPhong();\n\t\t\n\t\tif (mCurrentTechnique != null)\n\t\t\tmCurrentTechnique.mBlinnAndPhong = newBlinnAndPhong;\n\t\telse\n\t\t\tLogging.logFatal(\"mCurrentTechnique is null!\");\n\t\t\n\t\treturn false;\n\t}\n\t//--------------------------------------------------------------\n\t/// Pop Blinn\n\t///\n\t/// Pops a blinn element type from the element stack.\n\t//--------------------------------------------------------------\n\tprivate void PopBlinn(String inData)\n\t{\n\t\tif (mdwIgnoreStack > 0 ) return;\n\t}\n\t//--------------------------------------------------------------\n\t/// Push Phong\n\t///\n\t/// Pushes a phong element type on to the element stack.\n\t//--------------------------------------------------------------\n\tprivate boolean PushPhong(Attributes inAttributes)\n\t{\n\t\tif (mdwIgnoreStack > 0 ) return false;\n\t\t\n\t\tColladaBlinnAndPhong newBlinnAndPhong = new ColladaBlinnAndPhong();\n\t\t\n\t\tif (mCurrentTechnique != null)\n\t\t\tmCurrentTechnique.mBlinnAndPhong = newBlinnAndPhong;\n\t\telse\n\t\t\tLogging.logFatal(\"mCurrentTechnique is null!\");\n\t\t\n\t\treturn false;\n\t}\n\t//--------------------------------------------------------------\n\t/// Pop Phong\n\t///\n\t/// Pops a phong element type from the element stack.\n\t//--------------------------------------------------------------\n\tprivate void PopPhong(String inData)\n\t{\n\t\tif (mdwIgnoreStack > 0 ) return;\n\t}\n\t//--------------------------------------------------------------\n\t/// Push Emissive\n\t///\n\t/// Pushes an emissive element type on to the element stack.\n\t//--------------------------------------------------------------\n\tprivate boolean PushEmissive(Attributes inAttributes)\n\t{\n\t\tif (mdwIgnoreStack > 0 ) return false;\n\t\t\n\t\tmCurrentMaterialColour = new ColladaMaterialColour();\n\t\t\n\t\t//Default the emissive\n\t\tmCurrentMaterialColour.mColour = ColladaBlinnAndPhong.DEFAULT_EMISSIVE;\n\t\t\n\t\tif (mCurrentTechnique != null && mCurrentTechnique.mBlinnAndPhong != null)\n\t\t\tmCurrentTechnique.mBlinnAndPhong.mEmissive = mCurrentMaterialColour;\n\t\telse\n\t\t\tLogging.logFatal(\"mBlinnAndPhong is null!\");\n\t\t\n\t\treturn false;\n\t}\n\t//--------------------------------------------------------------\n\t/// Pop Emissive\n\t///\n\t/// Pops an emissive element type from the element stack.\n\t//--------------------------------------------------------------\n\tprivate void PopEmissive(String inData)\n\t{\n\t\tif (mdwIgnoreStack > 0 ) return;\n\t\tmCurrentMaterialColour = null;\n\t}\n\t//--------------------------------------------------------------\n\t/// Push Ambient\n\t///\n\t/// Pushes an ambient element type on to the element stack.\n\t//--------------------------------------------------------------\n\tprivate boolean PushAmbient(Attributes inAttributes)\n\t{\n\t\tif (mdwIgnoreStack > 0 ) return false;\n\t\t\n\t\tmCurrentMaterialColour = new ColladaMaterialColour();\n\t\t\n\t\tif (mCurrentTechnique != null && mCurrentTechnique.mBlinnAndPhong != null)\n\t\t\tmCurrentTechnique.mBlinnAndPhong.mAmbient = mCurrentMaterialColour;\n\t\telse\n\t\t\tLogging.logFatal(\"mBlinnAndPhong is null!\");\n\t\t\n\t\treturn false;\n\t}\n\t//--------------------------------------------------------------\n\t/// Pop Ambient\n\t///\n\t/// Pops an ambient element type from the element stack.\n\t//--------------------------------------------------------------\n\tprivate void PopAmbient(String inData)\n\t{\n\t\tif (mdwIgnoreStack > 0 ) return;\n\t\tmCurrentMaterialColour = null;\n\t}\n\t//--------------------------------------------------------------\n\t/// Push Diffuse\n\t///\n\t/// Pushes a diffuse element type on to the element stack.\n\t//--------------------------------------------------------------\n\tprivate boolean PushDiffuse(Attributes inAttributes)\n\t{\n\t\tif (mdwIgnoreStack > 0 ) return false;\n\t\t\n\t\tmCurrentMaterialColour = new ColladaMaterialColour();\n\t\t\n\t\t//Default the diffuse\n\t\tmCurrentMaterialColour.mColour = ColladaBlinnAndPhong.DEFAULT_DIFFUSE;\n\t\t\n\t\tif (mCurrentTechnique != null && mCurrentTechnique.mBlinnAndPhong != null)\n\t\t\tmCurrentTechnique.mBlinnAndPhong.mDiffuse = mCurrentMaterialColour;\n\t\telse\n\t\t\tLogging.logFatal(\"mBlinnAndPhong is null!\");\n\t\t\n\t\treturn false;\n\t}\n\t//--------------------------------------------------------------\n\t/// Pop Diffuse\n\t///\n\t/// Pops a diffuse element type from the element stack.\n\t//--------------------------------------------------------------\n\tprivate void PopDiffuse(String inData)\n\t{\n\t\tif (mdwIgnoreStack > 0 ) return;\n\t\tmCurrentMaterialColour = null;\n\t}\n\t//--------------------------------------------------------------\n\t/// Push Specular\n\t///\n\t/// Pushes a specular element type on to the element stack.\n\t//--------------------------------------------------------------\n\tprivate boolean PushSpecular(Attributes inAttributes)\n\t{\n\t\tif (mdwIgnoreStack > 0 ) return false;\n\t\t\n\t\tmCurrentMaterialColour = new ColladaMaterialColour();\n\t\t\n\t\tif (mCurrentTechnique != null && mCurrentTechnique.mBlinnAndPhong != null)\n\t\t\tmCurrentTechnique.mBlinnAndPhong.mSpecular = mCurrentMaterialColour;\n\t\telse\n\t\t\tLogging.logFatal(\"mBlinnAndPhong is null!\");\n\t\t\n\t\treturn false;\n\t}\n\t//--------------------------------------------------------------\n\t/// Pop Specular\n\t///\n\t/// Pops a specular element type from the element stack.\n\t//--------------------------------------------------------------\n\tprivate void PopSpecular(String inData)\n\t{\n\t\tif (mdwIgnoreStack > 0 ) return;\n\t\tmCurrentMaterialColour = null;\n\t}\n\t//--------------------------------------------------------------\n\t/// Push Shininess\n\t///\n\t/// Pushes a shininess element type on to the element stack.\n\t//--------------------------------------------------------------\n\tprivate boolean PushShininess(Attributes inAttributes)\n\t{\n\t\tif (mdwIgnoreStack > 0 ) return false;\n\t\t\n\t\tmCurrentShininess = new ColladaShininess();\n\t\t\n\t\tif (mCurrentTechnique != null && mCurrentTechnique.mBlinnAndPhong != null)\n\t\t\tmCurrentTechnique.mBlinnAndPhong.mShininess = mCurrentShininess;\n\t\telse\n\t\t\tLogging.logFatal(\"mBlinnAndPhong is null!\");\n\t\t\n\t\treturn false;\n\t}\n\t//--------------------------------------------------------------\n\t/// Pop Shininess\n\t///\n\t/// Pops a shininess element type from the element stack.\n\t//--------------------------------------------------------------\n\tprivate void PopShininess(String inData)\n\t{\n\t\tif (mdwIgnoreStack > 0 ) return;\n\t\tmCurrentShininess = null;\n\t}\n\t//--------------------------------------------------------------\n\t/// Push Colour\n\t///\n\t/// Pushes a colour element type on to the element stack.\n\t//--------------------------------------------------------------\n\tprivate boolean PushColour(Attributes inAttributes)\n\t{\n\t\tif (mdwIgnoreStack > 0 ) return false;\n\t\t\n\t\tmCurrentColour = new ColladaColour();\n\t\t\n\t\tif (mCurrentMaterialColour != null)\n\t\t\tmCurrentMaterialColour.mColour = mCurrentColour;\n\t\telse\n\t\t\tLogging.logFatal(\"mBlinnAndPhong is null!\");\n\n\t\treturn true;\n\t}\n\t//--------------------------------------------------------------\n\t/// Pop Colour\n\t///\n\t/// Pops a colour element type from the element stack.\n\t//--------------------------------------------------------------\n\tprivate void PopColour(String inData)\n\t{\n\t\tif (mdwIgnoreStack > 0 ) return;\n\t\tString[] splitColourString = ColladaUtils.SplitOnWhitespace(inData);\n\t\t\n\t\tif (splitColourString.length != 4)\n\t\t{\n\t\t\tLogging.logFatal(\"ColladaColour does not contain 4 values!\");\n\t\t}\n\t\t\n\t\tmCurrentColour.mfR = Float.parseFloat(splitColourString[0]);\n\t\tmCurrentColour.mfG = Float.parseFloat(splitColourString[1]);\n\t\tmCurrentColour.mfB = Float.parseFloat(splitColourString[2]);\n\t\tmCurrentColour.mfA = Float.parseFloat(splitColourString[3]);\n\t\t\n\t\tmCurrentColour = null;\n\t}\n\t//--------------------------------------------------------------\n\t/// Push Texture\n\t///\n\t/// Pushes a texture element type on to the element stack.\n\t//--------------------------------------------------------------\n\tprivate boolean PushTexture(Attributes inAttributes)\n\t{\n\t\tif (mdwIgnoreStack > 0 ) return false;\n\t\t\n\t\tColladaTexture texture = new ColladaTexture();\n\t\ttexture.mstrTexCoord = inAttributes.getValue(\"texcoord\");\n\t\ttexture.mstrTexture = inAttributes.getValue(\"texture\");\n\t\t\n\t\tif (mCurrentMaterialColour != null)\n\t\t\tmCurrentMaterialColour.mTexture = texture;\n\t\telse\n\t\t\tLogging.logFatal(\"mCurrentMaterialColour is null!\");\n\t\t\n\t\treturn false;\n\t}\n\t//--------------------------------------------------------------\n\t/// Pop Texture\n\t///\n\t/// Pops a texture element type from the element stack.\n\t//--------------------------------------------------------------\n\tprivate void PopTexture(String inData)\n\t{\n\t\tif (mdwIgnoreStack > 0 ) return;\n\t}\n\t//--------------------------------------------------------------\n\t/// Push Float\n\t///\n\t/// Pushes a float element type on to the element stack.\n\t//--------------------------------------------------------------\n\tprivate boolean PushFloat(Attributes inAttributes)\n\t{\n\t\tif (mdwIgnoreStack > 0 ) return false;\n\t\t\n\t\tmCurrentFloat = new ColladaFloat();\n\t\t\n\t\tif (mCurrentShininess != null)\n\t\t\tmCurrentShininess.mFloat = mCurrentFloat;\n\t\telse\n\t\t\tLogging.logFatal(\"mCurrentShininess is null!\");\n\t\t\n\t\treturn true;\n\t}\n\t//--------------------------------------------------------------\n\t/// Pop Float\n\t///\n\t/// Pops a float element type from the element stack.\n\t//--------------------------------------------------------------\n\tprivate void PopFloat(String inData)\n\t{\n\t\tif (mdwIgnoreStack > 0 ) return;\n\t\tmCurrentFloat.mfValue = Float.parseFloat(inData);\n\t\t\n\t\tmCurrentFloat = null;\n\t}\n\t//--------------------------------------------------------------\n\t/// Push Source\n\t///\n\t/// Pushes a source element type on to the element stack.\n\t//--------------------------------------------------------------\n\tprivate boolean PushSource(Attributes inAttributes)\n\t{\n\t\tif (mdwIgnoreStack > 0 ) return false;\n\t\t\n\t\tmCurrentSource = new ColladaSource();\n\t\t\n\t\tif (mCurrentNewParam != null && mCurrentNewParam.mSampler2D != null)\n\t\t\tmCurrentNewParam.mSampler2D.mSource = mCurrentSource;\n\t\telse\n\t\t\tLogging.logFatal(\"mSampler2D is null!\");\n\t\t\n\t\treturn true;\n\t}\n\t//--------------------------------------------------------------\n\t/// Pop Source\n\t///\n\t/// Pops a source element type from the element stack.\n\t//--------------------------------------------------------------\n\tprivate void PopSource(String inData)\n\t{\n\t\tif (mdwIgnoreStack > 0 ) return;\n\t\t\n\t\tmCurrentSource.mstrContents = inData;\n\t\t\n\t\tmCurrentSource = null;\n\t}\n\t//--------------------------------------------------------------\n\t/// Push Init From\n\t///\n\t/// Pushes an init from element type on to the element stack.\n\t//--------------------------------------------------------------\n\tprivate boolean PushInitFrom(Attributes inAttributes)\n\t{\n\t\tif (mdwIgnoreStack > 0 ) return false;\n\t\t\n\t\tmCurrentInitFrom = new ColladaInitFrom();\n\t\t\n\t\tif (mCurrentNewParam != null && mCurrentNewParam.mSurface != null)\n\t\t\tmCurrentNewParam.mSurface.mInitFrom = mCurrentInitFrom;\n\t\telse\n\t\t\tLogging.logFatal(\"mSurface is null!\");\n\t\t\n\t\treturn true;\n\t}\n\t//--------------------------------------------------------------\n\t/// Pop Init From\n\t///\n\t/// Pops an init from element type from the element stack.\n\t//--------------------------------------------------------------\n\tprivate void PopInitFrom(String inData)\n\t{\n\t\tif (mdwIgnoreStack > 0 ) return;\n\t\t\n\t\tmCurrentInitFrom.mstrValue = inData;\n\t\t\n\t\tmCurrentSource = null;\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/ColladaParserUtils/src/com/chilliworks/chillisource/colladaparserutils/LibraryGeometriesParser.java",
    "content": "/**\n * LibraryGeometriesParser.java\n * ChilliSource\n * Created by Ian Copland on 16/01/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.colladaparserutils;\n\nimport org.xml.sax.Attributes;\nimport org.xml.sax.SAXException;\n\nimport com.chilliworks.chillisource.colladaparserutils.colladadata.*;\nimport com.chilliworks.chillisource.coreutils.Logging;\n\npublic class LibraryGeometriesParser \n{\n\t//--------------------------------------------------------------\n\t/// Private Member Data\n\t//--------------------------------------------------------------\n\tprivate int mdwIgnoreStack;\n\tprivate Collada mCollada;\n\tprivate ColladaGeometry mCurrentGeometry;\n\tprivate ColladaSource mCurrentSource;\n\tprivate ColladaTechniqueCommon mCurrentTechniqueCommon;\n\tprivate ColladaFloatArray mCurrentFloatArray;\n\tprivate ColladaVertices mCurrentVertices;\n\tprivate ColladaTriangles mCurrentTriangles;\n\tprivate ColladaP mCurrentP;\n\t//--------------------------------------------------------------\n\t/// Constructor\n\t//--------------------------------------------------------------\n\tpublic LibraryGeometriesParser(Collada inColladaData)\n\t{\n\t\tmCollada = inColladaData;\n\t\tmdwIgnoreStack = 0;\n\t}\n\t//--------------------------------------------------------------\n\t/// Start Element\n\t///\n\t/// Callback method used by SAX whenever a new element is found.\n\t//--------------------------------------------------------------\n\tpublic boolean StartElement(String instrUri, String instrLocalName, String instrQName, Attributes inAttributes) throws SAXException \n\t{\n\t\t//push element type on to the imaginary element stack\n\t\tif (instrQName.equalsIgnoreCase(\"geometry\"))\n\t\t\treturn PushGeometry(inAttributes);\n\t\telse if (instrQName.equalsIgnoreCase(\"mesh\"))\n\t\t\treturn PushMesh(inAttributes);\n\t\telse if (instrQName.equalsIgnoreCase(\"source\"))\n\t\t\treturn PushSource(inAttributes);\n\t\telse if (instrQName.equalsIgnoreCase(\"technique_common\"))\n\t\t\treturn PushTechniqueCommon(inAttributes);\n\t\telse if (instrQName.equalsIgnoreCase(\"accessor\"))\n\t\t\treturn PushAccessor(inAttributes);\n\t\telse if (instrQName.equalsIgnoreCase(\"float_array\"))\n\t\t\treturn PushFloatArray(inAttributes);\n\t\telse if (instrQName.equalsIgnoreCase(\"vertices\"))\n\t\t\treturn PushVertices(inAttributes);\n\t\telse if (instrQName.equalsIgnoreCase(\"triangles\") || instrQName.equalsIgnoreCase(\"polylist\"))\n\t\t\treturn PushTriangles(inAttributes);\n\t\telse if (instrQName.equalsIgnoreCase(\"input\"))\n\t\t\treturn PushInput(inAttributes);\n\t\telse if (instrQName.equalsIgnoreCase(\"vcount\"))\n\t\t\treturn PushVCount(inAttributes);\n\t\telse if (instrQName.equalsIgnoreCase(\"p\"))\n\t\t\treturn PushP(inAttributes);\n\t\telse\n\t\t{\n\t\t\tmdwIgnoreStack++;\n\t\t\treturn false;\n\t\t}\n\t}\n\t//--------------------------------------------------------------\n\t/// End Element\n\t///\n\t/// Callback method used by SAX whenever a new element is found.\n\t//--------------------------------------------------------------\n\tpublic void EndElement(String instrUri, String instrLocalName, String instrQName, String inData) throws SAXException \n\t{\n\t\t//pop element type off to the imaginary element stack\n\t\tif (instrQName.equalsIgnoreCase(\"geometry\"))\n\t\t\tPopGeometry(inData);\n\t\telse if (instrQName.equalsIgnoreCase(\"mesh\"))\n\t\t\tPopMesh(inData);\n\t\telse if (instrQName.equalsIgnoreCase(\"source\"))\n\t\t\tPopSource(inData);\n\t\telse if (instrQName.equalsIgnoreCase(\"technique_common\"))\n\t\t\tPopTechniqueCommon(inData);\n\t\telse if (instrQName.equalsIgnoreCase(\"accessor\"))\n\t\t\tPopAccessor(inData);\n\t\telse if (instrQName.equalsIgnoreCase(\"float_array\"))\n\t\t\tPopFloatArray(inData);\n\t\telse if (instrQName.equalsIgnoreCase(\"vertices\"))\n\t\t\tPopVertices(inData);\n\t\telse if (instrQName.equalsIgnoreCase(\"triangles\") || instrQName.equalsIgnoreCase(\"polylist\"))\n\t\t\tPopTriangles(inData);\n\t\telse if (instrQName.equalsIgnoreCase(\"input\"))\n\t\t\tPopInput(inData);\n\t\telse if (instrQName.equalsIgnoreCase(\"vcount\"))\n\t\t\tPopVCount(inData);\n\t\telse if (instrQName.equalsIgnoreCase(\"p\"))\n\t\t\tPopP(inData);\n\t\telse\n\t\t\tmdwIgnoreStack--;\n\t}\n\t//--------------------------------------------------------------\n\t/// Push Geometry\n\t///\n\t/// Pushes a geometry element on to the element stack.\n\t//--------------------------------------------------------------\n\tprivate boolean PushGeometry(Attributes inAttributes)\n\t{\n\t\tif (mdwIgnoreStack > 0 ) return false;\n\t\t\n\t\t//create a new library geometry\n\t\tmCurrentGeometry = new ColladaGeometry();\n\t\tmCurrentGeometry.mstrId = inAttributes.getValue(\"id\");\n\t\tmCurrentGeometry.mstrName = inAttributes.getValue(\"name\");\n\t\t\n\t\t//try and add to library\n\t\tif (mCollada.mLibraryGeometries != null)\n\t\t\tmCollada.mLibraryGeometries.put(mCurrentGeometry.mstrId, mCurrentGeometry);\n\t\telse\n\t\t\tLogging.logFatal(\"mLibraryGeometries is null!\");\n\t\t\n\t\treturn false;\n\t}\n\t//--------------------------------------------------------------\n\t/// Pop Geometry\n\t///\n\t/// Pops a geometry element from the element stack.\n\t//--------------------------------------------------------------\n\tprivate void PopGeometry(String inData)\n\t{\n\t\tif (mdwIgnoreStack > 0 ) return;\n\t\t\n\t\tmCurrentGeometry = null;\n\t}\n\t//--------------------------------------------------------------\n\t/// Push VCount\n\t///\n\t/// Pushes a vertex count element on to the element stack.\n\t//--------------------------------------------------------------\n\tprivate boolean PushVCount(Attributes inAttributes)\n\t{\n\t\tif (mdwIgnoreStack > 0 ) return false;\n\t\t\n\t\treturn true;\n\t}\n\t//--------------------------------------------------------------\n\t/// Pop VCount\n\t///\n\t/// Pops a vertex count element from the element stack.\n\t//--------------------------------------------------------------\n\tprivate void PopVCount(String inData)\n\t{\n\t\tif (mdwIgnoreStack > 0 ) return;\n\t\t\n\t\t\n\t\tString[] values = inData.split(\" \");\n\t\tfor(String val : values)\n\t\t{\n\t\t\tif(val.equals(\"3\") == false)\n\t\t\t{\n\t\t\t\tLogging.logFatal(\"Exporter only supports models with triangles\");\n\t\t\t}\n\t\t}\n\t}\n\t//--------------------------------------------------------------\n\t/// Push Mesh\n\t///\n\t/// Pushes a mesh element on to the element stack.\n\t//--------------------------------------------------------------\n\tprivate boolean PushMesh(Attributes inAttributes)\n\t{\n\t\tif (mdwIgnoreStack > 0 ) return false;\n\t\t\n\t\t//check geometry exists\n\t\tif (mCurrentGeometry == null)\n\t\t\tLogging.logFatal(\"mCurrentGeometry is null!\");\n\t\t\n\t\tmCurrentGeometry.meType = ColladaGeometry.COLLADA_GEOMETRY_TYPE.MESH;\n\t\t\n\t\treturn false;\n\t}\n\t//--------------------------------------------------------------\n\t/// Pop Mesh\n\t///\n\t/// Pops a mesh element from the element stack.\n\t//--------------------------------------------------------------\n\tprivate void PopMesh(String inData)\n\t{\n\t\tif (mdwIgnoreStack > 0 ) return;\n\t}\n\t//--------------------------------------------------------------\n\t/// Push Source\n\t///\n\t/// Pushes a source element on to the element stack.\n\t//--------------------------------------------------------------\n\tprivate boolean PushSource(Attributes inAttributes)\n\t{\n\t\tif (mdwIgnoreStack > 0 ) return false;\n\t\t\n\t\t//create new source element\n\t\tmCurrentSource = new ColladaSource();\n\t\tmCurrentSource.mstrId = inAttributes.getValue(\"id\");\n\t\t\n\t\t//try and add to parent\n\t\tif (mCurrentGeometry != null && mCurrentGeometry.mMesh != null)\n\t\t\tmCurrentGeometry.mMesh.mSources.put(mCurrentSource.mstrId, mCurrentSource);\n\t\telse\n\t\t\tLogging.logFatal(\"mCurrentGeometry.mMesh is null!\");\n\t\t\n\t\treturn false;\n\t}\n\t//--------------------------------------------------------------\n\t/// Pop Source\n\t///\n\t/// Pops a source element from the element stack.\n\t//--------------------------------------------------------------\n\tprivate void PopSource(String inData)\n\t{\n\t\tif (mdwIgnoreStack > 0 ) return;\n\t\t\n\t\tmCurrentSource = null;\n\t}\n\t//--------------------------------------------------------------\n\t/// Push Technique Common\n\t///\n\t/// Pushes a technique common element on to the element stack.\n\t//--------------------------------------------------------------\n\tprivate boolean PushTechniqueCommon(Attributes inAttributes)\n\t{\n\t\tif (mdwIgnoreStack > 0 ) return false;\n\t\t\n\t\t//check geometry exists\n\t\tif (mCurrentSource != null)\n\t\t{\n\t\t\tmCurrentTechniqueCommon = mCurrentSource.mTechniqueCommon;\n\t\t}\n\t\t\n\t\treturn false;\n\t}\n\t//--------------------------------------------------------------\n\t/// Pop Technique Common\n\t///\n\t/// Pops a technique common element from the element stack.\n\t//--------------------------------------------------------------\n\tprivate void PopTechniqueCommon(String inData)\n\t{\n\t\tif (mdwIgnoreStack > 0 ) return;\n\t\tmCurrentTechniqueCommon = null;\n\t}\n\t//--------------------------------------------------------------\n\t/// Push Accessor\n\t///\n\t/// Pushes an accessor element on to the element stack.\n\t//--------------------------------------------------------------\n\tprivate boolean PushAccessor(Attributes inAttributes)\n\t{\n\t\tif (mdwIgnoreStack > 0 ) return false;\n\t\t\n\t\tif (mCurrentTechniqueCommon != null)\n\t\t{\n\t\t\tmCurrentTechniqueCommon.mAccessor.mstrSource = inAttributes.getValue(\"source\");\n\t\t\tmCurrentTechniqueCommon.mAccessor.mdwCount = Integer.parseInt(inAttributes.getValue(\"count\"));\n\t\t\tmCurrentTechniqueCommon.mAccessor.mdwStride = Integer.parseInt(inAttributes.getValue(\"stride\"));\n\t\t}\n\t\t\n\t\treturn false;\n\t}\n\t//--------------------------------------------------------------\n\t/// Pop Accessor\n\t///\n\t/// Pops an accessor element on to the element stack.\n\t//--------------------------------------------------------------\n\tprivate void PopAccessor(String inData)\n\t{\n\t\tif (mdwIgnoreStack > 0 ) return;\n\t}\n\t//--------------------------------------------------------------\n\t/// Push Float Array\n\t///\n\t/// Pushes a float array element on to the element stack.\n\t//--------------------------------------------------------------\n\tprivate boolean PushFloatArray(Attributes inAttributes)\n\t{\n\t\tif (mdwIgnoreStack > 0 ) return false;\n\t\t\n\t\t//create the float array\n\t\tmCurrentFloatArray = new ColladaFloatArray();\n\t\tmCurrentFloatArray.mdwCount = Integer.parseInt(inAttributes.getValue(\"count\"));\n\t\tmCurrentFloatArray.mstrId = inAttributes.getValue(\"id\");\n\t\tmCurrentFloatArray.mafData = new float[mCurrentFloatArray.mdwCount];\n\t\t\n\t\t//try and add to parent\n\t\tif (mCurrentSource != null)\n\t\t\tmCurrentSource.mFloatArray = mCurrentFloatArray;\n\t\telse\n\t\t\tLogging.logFatal(\"No available parent for float array!\");\n\t\t\n\t\treturn true;\n\t}\n\t//--------------------------------------------------------------\n\t/// Pop Float Array\n\t///\n\t/// Pops a float array element from the element stack.\n\t//--------------------------------------------------------------\n\tprivate void PopFloatArray(String inData)\n\t{\n\t\tif (mdwIgnoreStack > 0 ) return;\n\t\t\n\t\t//convert to a list of float strings\n\t\tString[] astrSplitBuffer = ColladaUtils.SplitOnWhitespace(inData);\n\t\t\n\t\tif (astrSplitBuffer.length == mCurrentFloatArray.mdwCount)\n\t\t{\n\t\t\t//convert the float strings to a list of actual floats\n\t\t\tfor (int i = 0; i < astrSplitBuffer.length; i++)\n\t\t\t{\n\t\t\t\tmCurrentFloatArray.mafData[i] = Float.parseFloat(astrSplitBuffer[i]);\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tLogging.logFatal(\"Incorrect number of values for 'float array'!\");\n\t\t}\n\t\t\n\t\tmCurrentFloatArray = null;\n\t}\n\t//--------------------------------------------------------------\n\t/// Push Vertices\n\t///\n\t/// Pushes a vertices array element on to the element stack.\n\t//--------------------------------------------------------------\n\tprivate boolean PushVertices(Attributes inAttributes)\n\t{\n\t\tif (mdwIgnoreStack > 0 ) return false;\n\t\t\n\t\tmCurrentVertices = new ColladaVertices();\n\t\tmCurrentVertices.mstrId = inAttributes.getValue(\"id\");\n\t\t\n\t\tif (mCurrentGeometry != null && mCurrentGeometry.mMesh != null)\n\t\t\tmCurrentGeometry.mMesh.mVertices = mCurrentVertices;\n\t\telse\n\t\t\tLogging.logFatal(\"No available parent for 'vertices'!\");\n\t\t\n\t\treturn false;\n\t}\n\t//--------------------------------------------------------------\n\t/// Pop Vertices\n\t///\n\t/// Pops a vertices array element on to the element stack.\n\t//--------------------------------------------------------------\n\tprivate void PopVertices(String inData)\n\t{\n\t\tif (mdwIgnoreStack > 0 ) return;\n\t\t\n\t\tmCurrentVertices = null;\n\t}\n\t//--------------------------------------------------------------\n\t/// Push Triangles\n\t///\n\t/// Pushes a triangles element on to the element stack.\n\t//--------------------------------------------------------------\n\tprivate boolean PushTriangles(Attributes inAttributes)\n\t{\n\t\tif (mdwIgnoreStack > 0 ) return false;\n\t\t\n\t\t//create the \"traingles\"\n\t\tmCurrentTriangles = new ColladaTriangles();\n\t\tmCurrentTriangles.mdwCount = Integer.parseInt(inAttributes.getValue(\"count\"));\n\t\tmCurrentTriangles.mstrMaterial = inAttributes.getValue(\"material\");\n\t\t\n\t\t//try and add to parent\n\t\tif (mCurrentGeometry != null && mCurrentGeometry.mMesh != null)\n\t\t\tmCurrentGeometry.mMesh.mTrianglesList.add(mCurrentTriangles);\n\t\telse\n\t\t\tLogging.logFatal(\"No available mesh for triangles!\");\n\t\t\n\t\treturn false;\n\t}\n\t//--------------------------------------------------------------\n\t/// Pop Triangles\n\t///\n\t/// Pops a triangles element from the element stack.\n\t//--------------------------------------------------------------\n\tprivate void PopTriangles(String inData)\n\t{\n\t\tif (mdwIgnoreStack > 0 ) return;\n\t\t\n\t\tmCurrentTriangles = null;\n\t}\n\t//--------------------------------------------------------------\n\t/// Push Input\n\t///\n\t/// Pushes an input element on to the element stack.\n\t//--------------------------------------------------------------\n\tprivate boolean PushInput(Attributes inAttributes)\n\t{\n\t\tif (mdwIgnoreStack > 0 ) return false;\n\t\t\n\t\t//create the \"input\"\n\t\tColladaInput input = new ColladaInput();\n\t\tinput.mstrSemantic = inAttributes.getValue(\"semantic\");\n\t\tinput.mstrSource = inAttributes.getValue(\"source\");\n\t\tinput.mdwOffset = ColladaUtils.GetIntAttributeOrZero(inAttributes, \"offset\");\n\t\tinput.mdwSet = ColladaUtils.GetIntAttributeOrZero(inAttributes, \"set\");\n\t\t\n\t\t//try and add to parent\n\t\tif (mCurrentVertices != null)\n\t\t\tmCurrentVertices.mInput = input;\n\t\telse if (mCurrentTriangles != null)\n\t\t\tmCurrentTriangles.mInputList.add(input);\n\t\telse\n\t\t\tLogging.logFatal(\"No available parent for 'input'!\");\n\t\t\n\t\treturn false;\n\n\t}\n\t//--------------------------------------------------------------\n\t/// Pop Input\n\t///\n\t/// Pops an input element on to the element stack.\n\t//--------------------------------------------------------------\n\tprivate void PopInput(String inData)\n\t{\n\t\tif (mdwIgnoreStack > 0 ) return;\n\t}\n\t//--------------------------------------------------------------\n\t/// Push P\n\t///\n\t/// Pushes a p element on to the element stack.\n\t//--------------------------------------------------------------\n\tprivate boolean PushP(Attributes inAttributes)\n\t{\n\t\tif (mdwIgnoreStack > 0 ) return false;\n\t\t\n\t\t//create current p\n\t\tmCurrentP = new ColladaP();\n\t\t\n\t\tif (mCurrentTriangles != null)\n\t\t{\n\t\t\tmCurrentTriangles.mP = mCurrentP;\n\t\t\tmCurrentTriangles.mP.madwValues = new int[mCurrentTriangles.mdwCount * 3 * mCurrentTriangles.mInputList.size()];\n\t\t}else\n\t\t\tLogging.logFatal(\"No available parent for 'P'!\");\n\t\t\n\t\treturn true;\n\t}\n\t//--------------------------------------------------------------\n\t/// Pop P\n\t///\n\t/// Pops a p element on to the element stack.\n\t//--------------------------------------------------------------\n\tprivate void PopP(String inData)\n\t{\n\t\tif (mdwIgnoreStack > 0 ) return;\n\t\t\n\t\t//convert to a list of int strings\n\t\tString[] astrSplitBuffer = ColladaUtils.SplitOnWhitespace(inData);\n\t\t\n\t\tif (astrSplitBuffer.length > 0)\n\t\t{\n\t\t\tif (mCurrentP.madwValues != null && astrSplitBuffer.length == mCurrentP.madwValues.length)\n\t\t\t{\n\t\t\t\tfor (int i = 0; i < astrSplitBuffer.length; i++)\n\t\t\t\t{\n\t\t\t\t\tmCurrentP.madwValues[i] = Integer.parseInt(astrSplitBuffer[i]);\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tLogging.logFatal(\"Incorrect number of values for 'P'\");\n\t\t\t}\n\t\t}\n\t\t\n\t\tmCurrentP = null;\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/ColladaParserUtils/src/com/chilliworks/chillisource/colladaparserutils/LibraryImagesParser.java",
    "content": "/**\n * LibraryImagesParser.java\n * ChilliSource\n * Created by Ian Copland on 16/01/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.colladaparserutils;\n\nimport org.xml.sax.Attributes;\nimport org.xml.sax.SAXException;\n\nimport com.chilliworks.chillisource.colladaparserutils.colladadata.Collada;\nimport com.chilliworks.chillisource.colladaparserutils.colladadata.ColladaImage;\nimport com.chilliworks.chillisource.colladaparserutils.colladadata.ColladaInitFrom;\nimport com.chilliworks.chillisource.coreutils.Logging;\n\npublic class LibraryImagesParser \n{\n\t//-------------------------------------------------------------\n\t/// Private Member Data\n\t//-------------------------------------------------------------\n\tprivate Collada mCollada;\n\tprivate ColladaImage mCurrentImage;\n\tprivate ColladaInitFrom mCurrentInitFrom;\n\t//--------------------------------------------------------------\n\t/// Constructor\n\t//--------------------------------------------------------------\n\tpublic LibraryImagesParser(Collada inColladaData)\n\t{\n\t\tmCollada = inColladaData;\n\t}\n\t//--------------------------------------------------------------\n\t/// Start Element\n\t///\n\t/// Callback method used by SAX whenever a new element is found.\n\t//--------------------------------------------------------------\n\tpublic boolean StartElement(String instrUri, String instrLocalName,String instrQName, Attributes inAttributes) throws SAXException \n\t{\n\t\t//push element type on to the imaginary element stack\n\t\tif (instrQName.equalsIgnoreCase(\"image\"))\n\t\t\treturn PushImage(inAttributes);\n\t\telse if (instrQName.equalsIgnoreCase(\"init_from\"))\n\t\t\treturn PushInitFrom(inAttributes);\n\t\telse\n\t\t\treturn false;\n\t}\n\t//--------------------------------------------------------------\n\t/// End Element\n\t///\n\t/// Callback method used by SAX whenever a new element is found.\n\t//--------------------------------------------------------------\n\tpublic void EndElement(String instrUri, String instrLocalName, String instrQName, String inData) throws SAXException \n\t{\n\t\t//pop element type off to the imaginary element stack\n\t\tif (instrQName.equalsIgnoreCase(\"image\"))\n\t\t\tPopImage(inData);\n\t\telse if (instrQName.equalsIgnoreCase(\"init_from\"))\n\t\t\tPopInitFrom(inData);\n\t}\n\t//--------------------------------------------------------------\n\t/// Push Image\n\t///\n\t/// Pushes an image element on to the element stack.\n\t//--------------------------------------------------------------\n\tprivate boolean PushImage(Attributes inAttributes)\n\t{\n\t\tmCurrentImage = new ColladaImage();\n\t\tmCurrentImage.mstrId = inAttributes.getValue(\"id\");\n\t\t\n\t\tif (mCollada.mLibraryImages != null)\n\t\t\tmCollada.mLibraryImages.put(mCurrentImage.mstrId, mCurrentImage);\n\t\telse\n\t\t\tLogging.logFatal(\"mLibraryImages is null!\");\n\t\t\n\t\treturn false;\n\t}\n\t//--------------------------------------------------------------\n\t/// Pop Image\n\t///\n\t/// Pops an image element from the element stack.\n\t//--------------------------------------------------------------\n\tprivate void PopImage(String inData)\n\t{\n\t\tmCurrentImage = null;\n\t}\n\t//--------------------------------------------------------------\n\t/// Push Init From\n\t///\n\t/// Pushes an init from element on to the element stack.\n\t//--------------------------------------------------------------\n\tprivate boolean PushInitFrom(Attributes inAttributes)\n\t{\n\t\tmCurrentInitFrom = new ColladaInitFrom();\n\t\t\n\t\tif (mCurrentImage != null)\n\t\t\tmCurrentImage.mInitFrom = mCurrentInitFrom;\n\t\telse\n\t\t\tLogging.logFatal(\"no parent for 'init from'!\");\n\t\t\n\t\treturn true;\n\t}\n\t//--------------------------------------------------------------\n\t/// Pop Init From\n\t///\n\t/// Pops an init from element from the element stack.\n\t//--------------------------------------------------------------\n\tprivate void PopInitFrom(String inData)\n\t{\n\t\tmCurrentInitFrom.mstrValue = inData;\n\t\t\n\t\tmCurrentInitFrom = null;\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/ColladaParserUtils/src/com/chilliworks/chillisource/colladaparserutils/LibraryMaterialsParser.java",
    "content": "/**\n * LibraryMaterialsParser.java\n * ChilliSource\n * Created by Ian Copland on 16/01/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.colladaparserutils;\n\nimport org.xml.sax.Attributes;\nimport org.xml.sax.SAXException;\n\nimport com.chilliworks.chillisource.colladaparserutils.colladadata.*;\nimport com.chilliworks.chillisource.coreutils.Logging;\n\npublic class LibraryMaterialsParser \n{\n\t//--------------------------------------------------------------\n\t/// Private Memeber Data\n\t//--------------------------------------------------------------\n\tprivate Collada mCollada;\n\tprivate ColladaMaterial mCurrentMaterial;\n\t//--------------------------------------------------------------\n\t/// Constructor\n\t//--------------------------------------------------------------\n\tpublic LibraryMaterialsParser(Collada inColladaData)\n\t{\n\t\tmCollada = inColladaData;\n\t}\n\t//--------------------------------------------------------------\n\t/// Start Element\n\t///\n\t/// Callback method used by SAX whenever the start of an element \n\t/// is found.\n\t//--------------------------------------------------------------\n\tpublic boolean StartElement(String instrUri, String instrLocalName,String instrQName, Attributes inAttributes) throws SAXException \n\t{\t\t\n\t\t//push element type on to the imaginary element stack\n\t\tif (instrQName.equalsIgnoreCase(\"material\"))\n\t\t\treturn PushMaterial(inAttributes);\n\t\telse if (instrQName.equalsIgnoreCase(\"instance_effect\"))\n\t\t\treturn PushInstanceEffect(inAttributes);\n\t\telse\n\t\t\treturn false;\n\t}\n\t//--------------------------------------------------------------\n\t/// End Element\n\t///\n\t/// Callback method used by SAX whenever the end of an element \n\t/// is found.\n\t//--------------------------------------------------------------\n\tpublic void EndElement(String instrUri, String instrLocalName, String instrQName, String inData) throws SAXException \n\t{\n\t\t//pop element type off to the imaginary element stack\n\t\tif (instrQName.equalsIgnoreCase(\"material\"))\n\t\t\tPopMaterial(inData);\n\t\telse if (instrQName.equalsIgnoreCase(\"instance_effect\"))\n\t\t\tPopInstanceEffect(inData);\n\t}\n\t//--------------------------------------------------------------\n\t/// Push Material\n\t///\n\t/// Pushes a material element on to the element stack.\n\t//--------------------------------------------------------------\n\tprivate boolean PushMaterial(Attributes inAttributes)\n\t{\n\t\tmCurrentMaterial = new ColladaMaterial();\n\t\tmCurrentMaterial.mstrId = inAttributes.getValue(\"id\");\n\t\tmCurrentMaterial.mstrName = inAttributes.getValue(\"name\");\n\t\t\n\t\tif (mCollada.mLibraryMaterials != null)\n\t\t{\n\t\t\tmCollada.mLibraryMaterials.put(mCurrentMaterial.mstrId, mCurrentMaterial);\n\t\t}else\n\t\t\tLogging.logFatal(\"mLibraryMaterials is null!\");\n\t\t\n\t\treturn false;\n\t}\n\t//--------------------------------------------------------------\n\t/// Pop Material\n\t///\n\t/// Pops a material element from the element stack.\n\t//--------------------------------------------------------------\n\tprivate void PopMaterial(String inData)\n\t{\n\t\tmCurrentMaterial = null;\n\t}\n\t//--------------------------------------------------------------\n\t/// Push Instance Effect\n\t///\n\t/// Pushes an instance effect element on to the element stack.\n\t//--------------------------------------------------------------\n\tprivate boolean PushInstanceEffect(Attributes inAttributes)\n\t{\n\t\tColladaInstanceEffect instanceEffect = new ColladaInstanceEffect();\n\t\tinstanceEffect.mstrUrl = inAttributes.getValue(\"url\");\n\t\t\n\t\tif (mCurrentMaterial != null)\n\t\t\tmCurrentMaterial.mInstanceEffect = instanceEffect;\n\t\telse\n\t\t\tLogging.logFatal(\"mCurrentMaterial is null!\");\n\n\t\treturn false;\n\t}\n\t//--------------------------------------------------------------\n\t/// Pop Instance Effect\n\t///\n\t/// Pops an instance effect element from the element stack.\n\t//--------------------------------------------------------------\n\tprivate void PopInstanceEffect(String inData)\n\t{\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/ColladaParserUtils/src/com/chilliworks/chillisource/colladaparserutils/LibraryVisualScenesParser.java",
    "content": "/**\n * LibraryVisualScenesParser.java\n * ChilliSource\n * Created by Ian Copland on 16/01/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.colladaparserutils;\n\nimport java.util.Stack;\n\nimport org.xml.sax.Attributes;\nimport org.xml.sax.SAXException;\n\nimport com.chilliworks.chillisource.colladaparserutils.colladadata.*;\nimport com.chilliworks.chillisource.coreutils.Logging;\nimport com.chilliworks.chillisource.coreutils.Matrix4;\nimport com.chilliworks.chillisource.coreutils.Quaternion;\nimport com.chilliworks.chillisource.coreutils.Vector3;\n\npublic class LibraryVisualScenesParser \n{\n\t//--------------------------------------------------------------\n\t/// Private Member Data\n\t//--------------------------------------------------------------\n\tprivate Collada mCollada;\n\tprivate ColladaVisualScene mCurrentVisualScene;\n\tprivate ColladaInstanceController mCurrentInstanceController;\n\tprivate ColladaSkeleton mCurrentSkeleton;\n\tprivate ColladaBindMaterial mCurrentBindMaterial;\n\tprivate ColladaTechniqueCommon mCurrentTechniqueCommon;\n\tprivate ColladaInstanceMaterial mCurrentInstanceMaterial;\n\tprivate ColladaInstanceGeometry mCurrentInstanceGeometry;\n\tprivate Stack<ColladaNode> mNodeStack;\n\tprivate int mdwNextNodeIndex;\n\t//--------------------------------------------------------------\n\t/// Constructor\n\t//--------------------------------------------------------------\n\tpublic LibraryVisualScenesParser(Collada inColladaData)\n\t{\n\t\tmCollada = inColladaData;\n\t\tmNodeStack = new Stack<ColladaNode>();\n\t\tmdwNextNodeIndex = 0;\n\t}\n\t//--------------------------------------------------------------\n\t/// Start Element\n\t///\n\t/// Callback method used by SAX whenever a new element is found.\n\t//--------------------------------------------------------------\n\tpublic boolean StartElement(String instrUri, String instrLocalName,String instrQName, Attributes inAttributes) throws SAXException \n\t{\n\t\t//push element type on to the imaginary element stack\n\t\tif (instrQName.equalsIgnoreCase(\"visual_scene\"))\n\t\t\treturn PushVisualScene(inAttributes);\n\t\telse if (instrQName.equalsIgnoreCase(\"node\"))\n\t\t\treturn PushNode(inAttributes);\n\t\telse if (instrQName.equalsIgnoreCase(\"instance_light\"))\n\t\t\treturn PushInstanceLight(inAttributes);\n\t\telse if (instrQName.equalsIgnoreCase(\"matrix\"))\n\t\t\treturn PushMatrix(inAttributes);\n\t\telse if (instrQName.equalsIgnoreCase(\"translate\"))\n\t\t\treturn pushTranslate(inAttributes);\n\t\telse if (instrQName.equalsIgnoreCase(\"rotate\"))\n\t\t\treturn pushRotate(inAttributes);\n\t\telse if (instrQName.equalsIgnoreCase(\"scale\"))\n\t\t\treturn pushScale(inAttributes);\n\t\telse if (instrQName.equalsIgnoreCase(\"instance_controller\"))\n\t\t\treturn PushInstanceController(inAttributes);\n\t\telse if (instrQName.equalsIgnoreCase(\"skeleton\"))\n\t\t\treturn PushSkeleton(inAttributes);\n\t\telse if (instrQName.equalsIgnoreCase(\"bind_material\"))\n\t\t\treturn PushBindMaterial(inAttributes);\n\t\telse if (instrQName.equalsIgnoreCase(\"technique_common\"))\n\t\t\treturn PushTechniqueCommon(inAttributes);\n\t\telse if (instrQName.equalsIgnoreCase(\"instance_material\"))\n\t\t\treturn PushInstanceMaterial(inAttributes);\n\t\telse if (instrQName.equalsIgnoreCase(\"bind_vertex_input\"))\n\t\t\treturn PushBindVertexInput(inAttributes);\n\t\telse if (instrQName.equalsIgnoreCase(\"instance_geometry\"))\n\t\t\treturn PushInstanceGeometry(inAttributes);\n\t\telse if (instrQName.equalsIgnoreCase(\"instance_camera\"))\n\t\t\treturn PushInstanceCamera(inAttributes);\n\t\telse if (instrQName.equalsIgnoreCase(\"extra\"))\n\t\t\treturn PushExtra(inAttributes);\n\t\telse if (instrQName.equalsIgnoreCase(\"technique\"))\n\t\t\treturn PushTechnique(inAttributes);\n\t\telse if (instrQName.equalsIgnoreCase(\"user_properties\"))\n\t\t\treturn PushUserProperties(inAttributes);\n\t\telse\n\t\t\treturn false;\n\t}\n\t//--------------------------------------------------------------\n\t/// End Element\n\t///\n\t/// Callback method used by SAX whenever the end of an element \n\t/// is found.\n\t//--------------------------------------------------------------\n\tpublic void EndElement(String instrUri, String instrLocalName, String instrQName, String inData) throws SAXException \n\t{\n\t\t//pop element type off to the imaginary element stack\n\t\tif (instrQName.equalsIgnoreCase(\"visual_scene\"))\n\t\t\tPopVisualScene(inData);\n\t\telse if (instrQName.equalsIgnoreCase(\"node\"))\n\t\t\tPopNode(inData);\n\t\telse if (instrQName.equalsIgnoreCase(\"instance_light\"))\n\t\t\tPopInstanceLight(inData);\n\t\telse if (instrQName.equalsIgnoreCase(\"matrix\"))\n\t\t\tPopMatrix(inData);\n\t\telse if (instrQName.equalsIgnoreCase(\"translate\"))\n\t\t\tpopTranslate(inData);\n\t\telse if (instrQName.equalsIgnoreCase(\"rotate\"))\n\t\t\tpopRotate(inData);\n\t\telse if (instrQName.equalsIgnoreCase(\"scale\"))\n\t\t\tpopScale(inData);\n\t\telse if (instrQName.equalsIgnoreCase(\"instance_controller\"))\n\t\t\tPopInstanceController(inData);\n\t\telse if (instrQName.equalsIgnoreCase(\"skeleton\"))\n\t\t\tPopSkeleton(inData);\n\t\telse if (instrQName.equalsIgnoreCase(\"bind_material\"))\n\t\t\tPopBindMaterial(inData);\n\t\telse if (instrQName.equalsIgnoreCase(\"technique_common\"))\n\t\t\tPopTechniqueCommon(inData);\n\t\telse if (instrQName.equalsIgnoreCase(\"instance_material\"))\n\t\t\tPopInstanceMaterial(inData);\n\t\telse if (instrQName.equalsIgnoreCase(\"bind_vertex_input\"))\n\t\t\tPopBindVertexInput(inData);\n\t\telse if (instrQName.equalsIgnoreCase(\"instance_geometry\"))\n\t\t\tPopInstanceGeometry(inData);\n\t\telse if (instrQName.equalsIgnoreCase(\"instance_camera\"))\n\t\t\tPopInstanceCamera(inData);\n\t\telse if (instrQName.equalsIgnoreCase(\"extra\"))\n\t\t\tPopExtra(inData);\n\t\telse if (instrQName.equalsIgnoreCase(\"technique\"))\n\t\t\tPopTechnique(inData);\n\t\telse if (instrQName.equalsIgnoreCase(\"user_properties\"))\n\t\t\tPopUserProperties(inData);\n\t}\n\t//--------------------------------------------------------------\n\t/// Push Visual Scene\n\t///\n\t/// Pushes a visual scene element on to the element stack.\n\t//--------------------------------------------------------------\n\tprivate boolean PushVisualScene(Attributes inAttributes)\n\t{\n\t\tmCurrentVisualScene = new ColladaVisualScene();\n\t\tmCurrentVisualScene.mstrId = inAttributes.getValue(\"id\");\n\t\t\n\t\tif (mCollada.mLibraryVisualScenes != null)\n\t\t\tmCollada.mLibraryVisualScenes.put(mCurrentVisualScene.mstrId, mCurrentVisualScene);\n\t\telse\n\t\t\tLogging.logFatal(\"mLibraryVisualScenes is null!\");\n\t\t\n\t\treturn false;\n\t}\n\t//--------------------------------------------------------------\n\t/// Pop Visual Scene\n\t///\n\t/// Pops a visual scene element from the element stack.\n\t//--------------------------------------------------------------\n\tprivate void PopVisualScene(String inData)\n\t{\n\t\tmCurrentVisualScene = null;\n\t}\n\t//--------------------------------------------------------------\n\t/// Push Node\n\t///\n\t/// Pushes a node element on to the element stack.\n\t//--------------------------------------------------------------\n\tprivate boolean PushNode(Attributes inAttributes)\n\t{\n\t\tColladaNode newNode = new ColladaNode();\n\t\tnewNode.mstrName = inAttributes.getValue(\"name\");\n\t\tnewNode.mstrId = ColladaUtils.GetStringAttributeOrEmpty(inAttributes, \"id\");\n\t\tnewNode.mstrSId = ColladaUtils.GetStringAttributeOrEmpty(inAttributes, \"sid\");\n\t\tnewNode.mstrType = ColladaUtils.GetStringAttributeOrEmpty(inAttributes, \"type\");\n\t\t\n\t\t//if there is no id, set the id to the name so the id can still be used as the key.\n\t\tif (newNode.mstrId.equalsIgnoreCase(\"\") == true)\n\t\t{\n\t\t\tnewNode.mstrId = \"node\" + mdwNextNodeIndex++;\n\t\t}\n\t\t\n\t\t//if this node is a joint, flag it as such\n\t\tif (newNode.mstrType.equalsIgnoreCase(\"JOINT\") == true)\n\t\t{\n\t\t\tnewNode.meType = ColladaNode.COLLADA_NODE_TYPE.JOINT;\n\t\t}\n\t\t\n\t\tif (mCurrentVisualScene != null && mNodeStack.size() == 0)\n\t\t\tmCurrentVisualScene.mRootNodes.put(newNode.mstrId, newNode);\n\t\telse if (mNodeStack.size() > 0)\n\t\t\tmNodeStack.peek().mChildNodes.put(newNode.mstrId, newNode);\n\t\telse\n\t\t\tLogging.logFatal(\"mCurrentVisualScene is null!\");\n\t\t\n\t\t//add to node stack\n\t\tmNodeStack.push(newNode);\n\t\t\n\t\treturn false;\n\t}\n\t//--------------------------------------------------------------\n\t/// Pop Node\n\t///\n\t/// Pops a node element from the element stack.\n\t//--------------------------------------------------------------\n\tprivate void PopNode(String inData)\n\t{\n\t\tmNodeStack.pop();\n\t}\n\t//--------------------------------------------------------------\n\t/// Push Instance Light\n\t///\n\t/// Pushes an instance light element on to the element stack.\n\t//--------------------------------------------------------------\n\tprivate boolean PushInstanceLight(Attributes inAttributes)\n\t{\n\t\tColladaInstanceLight newLight = new ColladaInstanceLight();\n\t\tnewLight.mstrUrl = inAttributes.getValue(\"url\");\n\t\t\n\t\tif (mNodeStack.size() > 0)\n\t\t{\n\t\t\tif (mNodeStack.peek().meType == ColladaNode.COLLADA_NODE_TYPE.BASE)\n\t\t\t{\n\t\t\t\tmNodeStack.peek().mInstanceLight = newLight;\n\t\t\t\tmNodeStack.peek().meType = ColladaNode.COLLADA_NODE_TYPE.LIGHT;\n\t\t\t}\n\t\t}\n\t\telse\n\t\t\tLogging.logFatal(\"mCurrentVisualScene is null!\");\n\t\t\n\t\treturn false;\n\t}\n\t//--------------------------------------------------------------\n\t/// Pop Instance Light\n\t///\n\t/// Pops an instance light element from the element stack.\n\t//--------------------------------------------------------------\n\tprivate void PopInstanceLight(String inData)\n\t{\n\t\t\n\t}\n\t//--------------------------------------------------------------\n\t/// Push Matrix\n\t///\n\t/// Pushes a matrix element on to the element stack.\n\t//--------------------------------------------------------------\n\tprivate boolean PushMatrix(Attributes inAttributes)\n\t{\n\t\tif (mNodeStack.size() < 1)\n\t\t{\n\t\t\tLogging.logFatal(\"mNodeStack is empty!\");\n\t\t}\n\t\t\n\t\treturn true;\n\t}\n\t//--------------------------------------------------------------\n\t/// Pop Matrix\n\t///\n\t/// Pops a matrix element from the element stack.\n\t//--------------------------------------------------------------\n\tprivate void PopMatrix(String inData)\n\t{\n\t\tString[] astrSplitBuffer = ColladaUtils.SplitOnWhitespace(inData);\n\t\t\n\t\tfloat[][] values = new float[4][4];\n\t\tfor (int i = 0; i < 4; i++)\n\t\t{\n\t\t\tfor (int j = 0; j < 4; j++)\n\t\t\t{\n\t\t\t\tvalues[i][j] = Float.parseFloat(astrSplitBuffer[i * 4 + j]);\n\t\t\t}\n\t\t}\n\t\t\n\t\tMatrix4 matrix = new Matrix4(values[0][0], values[1][0], values[2][0], values[3][0],\n\t\t\tvalues[0][1], values[1][1], values[2][1], values[3][1],\n\t\t\tvalues[0][2], values[1][2], values[2][2], values[3][2],\n\t\t\tvalues[0][3], values[1][3], values[2][3], values[3][3]);\n\t\t\n\t\tmNodeStack.peek().m_transform = Matrix4.multiply(matrix, mNodeStack.peek().m_transform);\n\t}\n\t/**\n\t * Pushes a new translate element. This assumes the element is part of the Collada Node that is top of the\n\t * Collada Node stack, applying the translation to its transform.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param in_attributes - The attributes of the element.\n\t */\n\tprivate boolean pushTranslate(Attributes in_attributes)\n\t{\n\t\tif (mNodeStack.size() < 1)\n\t\t{\n\t\t\tLogging.logFatal(\"The collada node stack is empty - no node to apply the translation to.\");\n\t\t}\n\t\t\n\t\treturn true;\n\t}\n\t/**\n\t * Pops a translate element. This assumes the element is part of the Collada Node that is top of the\n\t * Collada Node stack, applying the translation to its transform.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param in_data - The text between the element tags.\n\t */\n\tprivate void popTranslate(String in_data)\n\t{\n\t\tfinal int k_numComponents = 3;\n\t\t\n\t\tString[] split = ColladaUtils.SplitOnWhitespace(in_data);\n\t\tif (split.length != k_numComponents)\n\t\t{\n\t\t\tLogging.logFatal(\"Could not read <translate> node.\");\n\t\t}\n\t\t\n\t\tfloat[] values = new float[k_numComponents];\n\t\tfor (int i = 0; i < k_numComponents; i++)\n\t\t{\n\t\t\tvalues[i] = Float.parseFloat(split[i]);\n\t\t}\n\t\t\n\t\tVector3 translation = new Vector3(values[0], values[1], values[2]);\n\t\tmNodeStack.peek().m_transform = Matrix4.multiply(Matrix4.createTranslation(translation), mNodeStack.peek().m_transform);\n\t}\n\t/**\n\t * Pushes a new rotate element. This assumes the element is part of the Collada Node that is top of the\n\t * Collada Node stack, applying the rotation to its transform.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param in_attributes - The attributes of the element.\n\t */\n\tprivate boolean pushRotate(Attributes in_attributes)\n\t{\n\t\tif (mNodeStack.size() < 1)\n\t\t{\n\t\t\tLogging.logFatal(\"The collada node stack is empty - no node to apply the translation to.\");\n\t\t}\n\t\t\n\t\treturn true;\n\t}\n\t/**\n\t * Pops a rotate element. This assumes the element is part of the Collada Node that is top of the\n\t * Collada Node stack, applying the rotation to its transform.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param in_data - The text between the element tags.\n\t */\n\tprivate void popRotate(String in_data)\n\t{\n\t\tfinal int k_numComponents = 4;\n\t\t\n\t\tString[] split = ColladaUtils.SplitOnWhitespace(in_data);\n\t\tif (split.length != k_numComponents)\n\t\t{\n\t\t\tLogging.logFatal(\"Could not read <rotate> node.\");\n\t\t}\n\t\t\n\t\tfloat[] values = new float[k_numComponents];\n\t\tfor (int i = 0; i < k_numComponents; i++)\n\t\t{\n\t\t\tvalues[i] = Float.parseFloat(split[i]);\n\t\t}\n\t\t\n\t\tQuaternion rotation = new Quaternion(new Vector3(values[0], values[1], values[2]), values[3]);\n\t\tmNodeStack.peek().m_transform = Matrix4.multiply(Matrix4.createRotation(rotation), mNodeStack.peek().m_transform);\n\t}\n\t/**\n\t * Pushes a new scale element. This assumes the element is part of the Collada Node that is top of the\n\t * Collada Node stack, applying the scale to its transform.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param in_attributes - The attributes of the element.\n\t */\n\tprivate boolean pushScale(Attributes in_attributes)\n\t{\n\t\tif (mNodeStack.size() < 1)\n\t\t{\n\t\t\tLogging.logFatal(\"The collada node stack is empty - no node to apply the translation to.\");\n\t\t}\n\t\t\n\t\treturn true;\n\t}\n\t/**\n\t * Pops a scale element. This assumes the element is part of the Collada Node that is top of the\n\t * Collada Node stack, applying the scale to its transform.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param in_data - The text between the element tags.\n\t */\n\tprivate void popScale(String in_data)\n\t{\n\t\tfinal int k_numComponents = 3;\n\t\t\n\t\tString[] split = ColladaUtils.SplitOnWhitespace(in_data);\n\t\tif (split.length != k_numComponents)\n\t\t{\n\t\t\tLogging.logFatal(\"Could not read <scale> node.\");\n\t\t}\n\t\t\n\t\tfloat[] values = new float[k_numComponents];\n\t\tfor (int i = 0; i < k_numComponents; i++)\n\t\t{\n\t\t\tvalues[i] = Float.parseFloat(split[i]);\n\t\t}\n\t\t\n\t\tVector3 scale = new Vector3(values[0], values[1], values[2]);\n\t\tmNodeStack.peek().m_transform = Matrix4.multiply(Matrix4.createScale(scale), mNodeStack.peek().m_transform);\n\t}\n\t//--------------------------------------------------------------\n\t/// Push Instance Controller\n\t///\n\t/// Pushes an instance controller element on to the element stack.\n\t//--------------------------------------------------------------\n\tprivate boolean PushInstanceController(Attributes inAttributes)\n\t{\n\t\tmCurrentInstanceController = new ColladaInstanceController();\n\t\tmCurrentInstanceController.mstrUrl = ColladaUtils.GetStringAttributeOrEmpty(inAttributes, \"url\");\n\t\t\n\t\tif (mNodeStack.size() > 0)\n\t\t{\n\t\t\tif (mNodeStack.peek().meType == ColladaNode.COLLADA_NODE_TYPE.BASE)\n\t\t\t{\n\t\t\t\tmNodeStack.peek().mInstanceController = mCurrentInstanceController;\n\t\t\t\tmNodeStack.peek().meType = ColladaNode.COLLADA_NODE_TYPE.CONTROLLER;\n\t\t\t}\n\t\t}\n\t\telse\n\t\t\tLogging.logFatal(\"mNodeStack is empty!\");\n\t\t\n\t\treturn false;\n\t}\n\t//--------------------------------------------------------------\n\t/// Pop Instance Controller\n\t///\n\t/// Pops an instance controller element from the element stack.\n\t//--------------------------------------------------------------\n\tprivate void PopInstanceController(String inData)\n\t{\n\t\tmCurrentInstanceController = null;\n\t}\n\t//--------------------------------------------------------------\n\t/// Push Skeleton\n\t///\n\t/// Pushes a skeleton element on to the element stack.\n\t//--------------------------------------------------------------\n\tprivate boolean PushSkeleton(Attributes inAttributes)\n\t{\n\t\tmCurrentSkeleton = new ColladaSkeleton();\n\t\t\n\t\tif (mCurrentInstanceController != null)\n\t\t\tmCurrentInstanceController.m_skeletons.add(mCurrentSkeleton);\n\t\telse\n\t\t\tLogging.logFatal(\"mCurrentInstanceController is null!\");\n\t\t\n\t\treturn true;\n\t}\n\t//--------------------------------------------------------------\n\t/// Pop Skeleton\n\t///\n\t/// Pops a skeleton element from the element stack.\n\t//--------------------------------------------------------------\n\tprivate void PopSkeleton(String inData)\n\t{\n\t\tmCurrentSkeleton.mstrValue = inData;\n\t\tmCurrentSkeleton = null;\n\t}\n\t//--------------------------------------------------------------\n\t/// Push Bind Material\n\t///\n\t/// Pushes a bind material element on to the element stack.\n\t//--------------------------------------------------------------\n\tprivate boolean PushBindMaterial(Attributes inAttributes)\n\t{\n\t\tmCurrentBindMaterial = new ColladaBindMaterial();\n\t\t\n\t\tif (mCurrentInstanceController != null)\n\t\t\tmCurrentInstanceController.mBindMaterial = mCurrentBindMaterial;\n\t\telse if (mCurrentInstanceGeometry != null)\n\t\t\tmCurrentInstanceGeometry.mBindMaterial = mCurrentBindMaterial;\n\t\telse\n\t\t\tLogging.logFatal(\"mCurrentInstanceController is null!\");\n\t\t\n\t\treturn false;\n\t}\n\t//--------------------------------------------------------------\n\t/// Pop Bind Material\n\t///\n\t/// Pops a bind material element on to the element stack.\n\t//--------------------------------------------------------------\n\tprivate void PopBindMaterial(String inData)\n\t{\n\t\tmCurrentBindMaterial = null;\n\t}\n\t//--------------------------------------------------------------\n\t/// Push Technique Common\n\t///\n\t/// Pushes a technique common element on to the element stack.\n\t//--------------------------------------------------------------\n\tprivate boolean PushTechniqueCommon(Attributes inAttributes)\n\t{\n\t\tmCurrentTechniqueCommon = new ColladaTechniqueCommon();\n\t\t\n\t\tif (mCurrentBindMaterial != null)\n\t\t\tmCurrentBindMaterial.mTechniqueCommon = mCurrentTechniqueCommon;\n\t\telse\n\t\t\tLogging.logFatal(\"mCurrentBindMaterial is null!\");\n\t\t\n\t\treturn false;\n\t}\n\t//--------------------------------------------------------------\n\t/// Pop Technique Common\n\t///\n\t/// Pops a technique common element from the element stack.\n\t//--------------------------------------------------------------\n\tprivate void PopTechniqueCommon(String inData)\n\t{\n\t\tmCurrentTechniqueCommon = null;\n\t}\n\t//--------------------------------------------------------------\n\t/// Push Instance Material\n\t///\n\t/// Pushes an instance material element on to the element stack.\n\t//--------------------------------------------------------------\n\tprivate boolean PushInstanceMaterial(Attributes inAttributes)\n\t{\n\t\tmCurrentInstanceMaterial = new ColladaInstanceMaterial();\n\t\tmCurrentInstanceMaterial.mstrSymbol = inAttributes.getValue(\"symbol\");\n\t\tmCurrentInstanceMaterial.mstrTarget = inAttributes.getValue(\"target\");\n\t\t\n\t\tif (mCurrentTechniqueCommon != null)\n\t\t\tmCurrentTechniqueCommon.mInstanceMaterialList.add(mCurrentInstanceMaterial);\n\t\telse\n\t\t\tLogging.logFatal(\"mCurrentTechniqueCommon is null!\");\n\t\t\n\t\treturn false;\n\t}\n\t//--------------------------------------------------------------\n\t/// Pop Instance Material\n\t///\n\t/// Pops an instance material element from the element stack.\n\t//--------------------------------------------------------------\n\tprivate void PopInstanceMaterial(String inData)\n\t{\n\t\tmCurrentInstanceMaterial = null;\n\t}\n\t//--------------------------------------------------------------\n\t/// Push Bind Vertex Input\n\t///\n\t/// Pushes a Bind Vertex Input element on to the element stack.\n\t//--------------------------------------------------------------\n\tprivate boolean PushBindVertexInput(Attributes inAttributes)\n\t{\n\t\tColladaBindVertexInput newBindvBindVertexInput = new ColladaBindVertexInput();\n\t\tnewBindvBindVertexInput.mstrInputSemantic = inAttributes.getValue(\"input_semantic\");\n\t\tnewBindvBindVertexInput.mstrInputSet = inAttributes.getValue(\"input_set\");\n\t\tnewBindvBindVertexInput.mstrSemantic = inAttributes.getValue(\"semantic\");\n\t\t\n\t\tif (mCurrentInstanceMaterial != null)\n\t\t\tmCurrentInstanceMaterial.mBindVertexInput = newBindvBindVertexInput;\n\t\telse\n\t\t\tLogging.logFatal(\"mCurrentInstanceMaterial is null!\");\n\t\t\n\t\treturn false;\n\t}\n\t//--------------------------------------------------------------\n\t/// Pop Bind Vertex Input\n\t///\n\t/// Pops a Bind Vertex Input element from the element stack.\n\t//--------------------------------------------------------------\n\tprivate void PopBindVertexInput(String inData)\n\t{\n\t}\n\t//--------------------------------------------------------------\n\t/// Push Instance Geometry\n\t///\n\t/// Pushes an instance geometry element on to the element stack.\n\t//--------------------------------------------------------------\n\tprivate boolean PushInstanceGeometry(Attributes inAttributes)\n\t{\n\t\tmCurrentInstanceGeometry = new ColladaInstanceGeometry();\n\t\tmCurrentInstanceGeometry.mstrUrl = ColladaUtils.GetStringAttributeOrEmpty(inAttributes, \"url\");\n\t\t\n\t\tif (mNodeStack.size() > 0)\n\t\t{\n\t\t\tif (mNodeStack.peek().meType == ColladaNode.COLLADA_NODE_TYPE.BASE)\n\t\t\t{\n\t\t\t\tmNodeStack.peek().mInstanceGeometry = mCurrentInstanceGeometry;\n\t\t\t\tmNodeStack.peek().meType = ColladaNode.COLLADA_NODE_TYPE.GEOMETRY;\n\t\t\t}\n\t\t}\n\t\telse\n\t\t\tLogging.logFatal(\"mNodeStack is empty!\");\n\t\t\n\t\treturn false;\n\t}\n\t//--------------------------------------------------------------\n\t/// Pop Instance Geometry\n\t///\n\t/// Pops an instance geometry element from the element stack.\n\t//--------------------------------------------------------------\n\tprivate void PopInstanceGeometry(String inData)\n\t{\n\t\tmCurrentInstanceController = null;\n\t}\n\t//--------------------------------------------------------------\n\t/// Push Instance Camera\n\t///\n\t/// Pushes an instance camera element on to the element stack.\n\t//--------------------------------------------------------------\n\tprivate boolean PushInstanceCamera(Attributes inAttributes)\n\t{\n\t\tColladaInstanceCamera newCamera = new ColladaInstanceCamera();\n\t\tnewCamera.mstrUrl = inAttributes.getValue(\"url\");\n\t\t\n\t\tif (mNodeStack.size() > 0)\n\t\t{\n\t\t\tif (mNodeStack.peek().meType == ColladaNode.COLLADA_NODE_TYPE.BASE)\n\t\t\t{\n\t\t\t\tmNodeStack.peek().mInstanceCamera = newCamera;\n\t\t\t\tmNodeStack.peek().meType = ColladaNode.COLLADA_NODE_TYPE.CAMERA;\n\t\t\t}\n\t\t}\n\t\telse\n\t\t\tLogging.logFatal(\"mNodeStack is empty!\");\n\t\t\n\t\treturn false;\n\t}\n\t//--------------------------------------------------------------\n\t/// Pop Instance Camera\n\t///\n\t/// Pops an instance camera element on to the element stack.\n\t//--------------------------------------------------------------\n\tprivate void PopInstanceCamera(String inData)\n\t{\n\t}\n\t//--------------------------------------------------------------\n\t/// Push Extra\n\t///\n\t/// Pushes an extra element on to the element stack.\n\t//--------------------------------------------------------------\n\tprivate boolean PushExtra(Attributes inAttributes)\n\t{\n\t\tColladaExtra extra = new ColladaExtra();\n\t\t\n\t\tif (mNodeStack.size() > 0)\n\t\t{\n\t\t\tmNodeStack.peek().mExtra = extra;\n\t\t}\n\t\t\n\t\treturn false;\n\t}\n\t//--------------------------------------------------------------\n\t/// Pop Extra\n\t///\n\t/// Pops an extra element from the element stack.\n\t//--------------------------------------------------------------\n\tprivate void PopExtra(String inData)\n\t{\n\t}\n\t//--------------------------------------------------------------\n\t/// Push Technique\n\t///\n\t/// Pushes a technique on to the element stack.\n\t//--------------------------------------------------------------\n\tprivate boolean PushTechnique(Attributes inAttributes)\n\t{\n\t\tColladaTechnique technique = new ColladaTechnique();\n\t\ttechnique.mstrProfile = inAttributes.getValue(\"profile\");\n\t\t\n\t\tif (mNodeStack.size() > 0 && mNodeStack.peek().mExtra != null)\n\t\t{\n\t\t\tmNodeStack.peek().mExtra.mTechnique = technique;\n\t\t}\n\t\t\n\t\treturn false;\n\t}\n\t//--------------------------------------------------------------\n\t/// Pop Technique\n\t///\n\t/// Pops a Technique element from the element stack.\n\t//--------------------------------------------------------------\n\tprivate void PopTechnique(String inData)\n\t{\n\t}\n\t//--------------------------------------------------------------\n\t/// Push User Properties\n\t///\n\t/// Pushes a user properties element on to the element stack.\n\t//--------------------------------------------------------------\n\tprivate boolean PushUserProperties(Attributes inAttributes)\n\t{\n\t\tColladaUserProperties userProperties = new ColladaUserProperties();\n\t\t\n\t\tif (mNodeStack.size() > 0 && mNodeStack.peek().mExtra != null && mNodeStack.peek().mExtra.mTechnique != null)\n\t\t{\n\t\t\tmNodeStack.peek().mExtra.mTechnique.mUserProperties = userProperties;\n\t\t\treturn true;\n\t\t}\n\t\t\n\t\treturn false;\n\t}\n\t//--------------------------------------------------------------\n\t/// Pop User Properties\n\t///\n\t/// Pops a user properties from the element stack.\n\t//--------------------------------------------------------------\n\tprivate void PopUserProperties(String inData)\n\t{\n\t\tif (mNodeStack.size() > 0 && mNodeStack.peek().mExtra != null && mNodeStack.peek().mExtra.mTechnique != null && mNodeStack.peek().mExtra.mTechnique.mUserProperties != null)\n\t\t{\n\t\t\tmNodeStack.peek().mExtra.mTechnique.mUserProperties.mstrData = inData;\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/ColladaParserUtils/src/com/chilliworks/chillisource/colladaparserutils/SceneParser.java",
    "content": "/**\n * SceneParser.java\n * ChilliSource\n * Created by Ian Copland on 16/01/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.colladaparserutils;\n\nimport org.xml.sax.Attributes;\nimport org.xml.sax.SAXException;\n\nimport com.chilliworks.chillisource.colladaparserutils.colladadata.*;\nimport com.chilliworks.chillisource.coreutils.Logging;\n\npublic class SceneParser \n{\n\t//--------------------------------------------------------------\n\t/// Private Member Data\n\t//--------------------------------------------------------------\n\tprivate Collada mCollada;\n\t//--------------------------------------------------------------\n\t/// Constructor\n\t//--------------------------------------------------------------\n\tpublic SceneParser(Collada inColladaData)\n\t{\n\t\tmCollada = inColladaData;\n\t}\n\t//--------------------------------------------------------------\n\t/// Start Element\n\t///\n\t/// Callback method used by SAX whenever the start of an element \n\t/// is found.\n\t//--------------------------------------------------------------\n\tpublic boolean StartElement(String instrUri, String instrLocalName,String instrQName, Attributes inAttributes) throws SAXException \n\t{\n\t\t//push element type on to the imaginary element stack\n\t\tif (instrQName.equalsIgnoreCase(\"instance_visual_scene\"))\n\t\t\treturn PushInstanceVisualScene(inAttributes);\n\t\telse\n\t\t\treturn false;\n\t}\n\t//--------------------------------------------------------------\n\t/// End Element\n\t///\n\t/// Callback method used by SAX whenever the end of an element \n\t/// is found.\n\t//--------------------------------------------------------------\n\tpublic void EndElement(String instrUri, String instrLocalName, String instrQName, String inData) throws SAXException \n\t{\n\t\t//pop element type off to the imaginary element stack\n\t\tif (instrQName.equalsIgnoreCase(\"instance_visual_scene\"))\n\t\t\tPopInstanceVisualScene(inData);\n\t}\n\t//--------------------------------------------------------------\n\t/// Push Instance Visual Scene\n\t///\n\t/// Pushes an instance visual scene element on to the element stack.\n\t//--------------------------------------------------------------\n\tprivate boolean PushInstanceVisualScene(Attributes inAttributes)\n\t{\n\t\tColladaInstanceVisualScene newIVS = new ColladaInstanceVisualScene();\n\t\tnewIVS.mstrUrl = inAttributes.getValue(\"url\");\n\t\t\n\t\tif (mCollada.mScene != null)\n\t\t\tmCollada.mScene.mInstanceVisualScene = newIVS;\n\t\telse\n\t\t\tLogging.logFatal(\"mScene is null!\");\n\t\t\n\t\treturn false;\n\t}\n\t//--------------------------------------------------------------\n\t/// Pop Instance Visual Scene\n\t///\n\t/// Pops an instance visual scene element from the element stack.\n\t//--------------------------------------------------------------\n\tprivate void PopInstanceVisualScene(String inData)\n\t{\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/ColladaParserUtils/src/com/chilliworks/chillisource/colladaparserutils/colladadata/Collada.java",
    "content": "/**\n * Collada.java\n * ChilliSource\n * Created by Ian Copland on 16/01/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.colladaparserutils.colladadata;\n\nimport java.util.ArrayList;\nimport java.util.Hashtable;\nimport java.util.List;\n\npublic class Collada \n{\n\tpublic ColladaAsset mAsset;\n\tpublic Hashtable<String, ColladaGeometry> mLibraryGeometries;\n\tpublic Hashtable<String, ColladaImage> mLibraryImages;\n\tpublic Hashtable<String, ColladaMaterial> mLibraryMaterials;\n\tpublic Hashtable<String, ColladaEffect> mLibraryEffects;\n\tpublic Hashtable<String, ColladaVisualScene> mLibraryVisualScenes;\n\tpublic Hashtable<String, ColladaController> mLibraryControllers;\n\tpublic List<ColladaAnimation> m_animations = new ArrayList<>();\n\tpublic ColladaScene mScene;\n\t\n\tpublic Collada()\n\t{\n\t\tmAsset = new ColladaAsset();\n\t\tmLibraryGeometries = new Hashtable<String, ColladaGeometry>();\n\t\tmLibraryImages = new Hashtable<String, ColladaImage>();\n\t\tmLibraryMaterials = new Hashtable<String, ColladaMaterial>();\n\t\tmLibraryEffects = new Hashtable<String, ColladaEffect>();\n\t\tmLibraryControllers = new Hashtable<String, ColladaController>();\n\t\tmLibraryVisualScenes = new Hashtable<String, ColladaVisualScene>();\n\t\tmScene = new ColladaScene();\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/ColladaParserUtils/src/com/chilliworks/chillisource/colladaparserutils/colladadata/ColladaAccessor.java",
    "content": "/**\n * ColladaAccessor.java\n * ChilliSource\n * Created by Ian Copland on 16/01/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.colladaparserutils.colladadata;\n\nimport java.util.LinkedList;\n\npublic class ColladaAccessor \n{\n\tpublic LinkedList<ColladaParam> mParams;\n\tpublic int mdwCount;\n\tpublic int mdwStride;\n\tpublic String mstrSource;\n\t\n\tpublic ColladaAccessor()\n\t{\n\t\tmParams = new LinkedList<ColladaParam>();\n\t\tmdwCount = 0;\n\t\tmdwStride = 0;\n\t\tmstrSource = new String();\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/ColladaParserUtils/src/com/chilliworks/chillisource/colladaparserutils/colladadata/ColladaAnimation.java",
    "content": "/**\n * ColladaAnimation.java\n * ChilliSource\n * Created by Ian Copland on 16/01/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.colladaparserutils.colladadata;\n\nimport java.util.Hashtable;\nimport java.util.LinkedList;\n\npublic class ColladaAnimation \n{\n\tpublic Hashtable<String, ColladaSource> mSourceTable;\n\tpublic Hashtable<String, ColladaSampler> mSamplerTable;\n\tpublic LinkedList<ColladaChannel> mChannelList;\n\t\n\tpublic ColladaAnimation()\n\t{\n\t\tmSourceTable = new Hashtable<String, ColladaSource>();\n\t\tmSamplerTable = new Hashtable<String, ColladaSampler>();\n\t\tmChannelList = new LinkedList<ColladaChannel>();\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/ColladaParserUtils/src/com/chilliworks/chillisource/colladaparserutils/colladadata/ColladaAsset.java",
    "content": "/**\n * ColladaAsset.java\n * ChilliSource\n * Created by Ian Copland on 16/01/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.colladaparserutils.colladadata;\n\npublic class ColladaAsset \n{\n\tpublic ColladaContributor mContributor = new ColladaContributor();\n}\n"
  },
  {
    "path": "Projects/Tools/ColladaParserUtils/src/com/chilliworks/chillisource/colladaparserutils/colladadata/ColladaAuthoringTool.java",
    "content": "/**\n * ColladaAuthoringTool.java\n * ChilliSource\n * Created by Ian Copland on 16/01/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.colladaparserutils.colladadata;\n\npublic class ColladaAuthoringTool \n{\n\tpublic String mstrName = \"\";\n}\n"
  },
  {
    "path": "Projects/Tools/ColladaParserUtils/src/com/chilliworks/chillisource/colladaparserutils/colladadata/ColladaBindMaterial.java",
    "content": "/**\n * ColladaBindMaterial.java\n * ChilliSource\n * Created by Ian Copland on 16/01/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.colladaparserutils.colladadata;\n\npublic class ColladaBindMaterial \n{\n\tpublic ColladaTechniqueCommon mTechniqueCommon;\n\t\n\tpublic ColladaBindMaterial()\n\t{\n\t\tmTechniqueCommon = new ColladaTechniqueCommon();\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/ColladaParserUtils/src/com/chilliworks/chillisource/colladaparserutils/colladadata/ColladaBindShapeMatrix.java",
    "content": "/**\n * ColladaBindShapeMatrix.java\n * ChilliSource\n * Created by Ian Copland on 16/01/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.colladaparserutils.colladadata;\n\npublic class ColladaBindShapeMatrix \n{\n\tpublic float[][] maafValues;\n\t\n\tpublic ColladaBindShapeMatrix()\n\t{\n\t\t\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/ColladaParserUtils/src/com/chilliworks/chillisource/colladaparserutils/colladadata/ColladaBindVertexInput.java",
    "content": "/**\n * ColladaBindVertexInput.java\n * ChilliSource\n * Created by Ian Copland on 16/01/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.colladaparserutils.colladadata;\n\npublic class ColladaBindVertexInput \n{\n\tpublic String mstrSemantic;\n\tpublic String mstrInputSemantic;\n\tpublic String mstrInputSet;\n\t\n\tpublic ColladaBindVertexInput()\n\t{\n\t\tmstrSemantic = new String();\n\t\tmstrInputSemantic = new String();\n\t\tmstrInputSet = new String();\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/ColladaParserUtils/src/com/chilliworks/chillisource/colladaparserutils/colladadata/ColladaBlinnAndPhong.java",
    "content": "/**\n * ColladaBlinnAndPhong.java\n * ChilliSource\n * Created by Ian Copland on 16/01/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.colladaparserutils.colladadata;\n\npublic class ColladaBlinnAndPhong \n{\n\tpublic static final ColladaColour DEFAULT_EMISSIVE = new ColladaColour(0.0f, 0.0f, 0.0f, 1.0f);\n\tpublic static final ColladaColour DEFAULT_DIFFUSE = new ColladaColour(1.0f, 1.0f, 1.0f, 1.0f);\n\t\n\tpublic ColladaMaterialColour mEmissive;\n\tpublic ColladaMaterialColour mAmbient;\n\tpublic ColladaMaterialColour mDiffuse;\n\tpublic ColladaMaterialColour mSpecular;\n\tpublic ColladaShininess mShininess;\n\t//Note: There should be more data here, however it has not been included becuase its unlikely to be needed any time soon.\n\t\n\tpublic ColladaBlinnAndPhong()\n\t{\n\t\tmEmissive = new ColladaMaterialColour();\n\t\tmAmbient = new ColladaMaterialColour();\n\t\tmDiffuse = new ColladaMaterialColour();\n\t\tmSpecular = new ColladaMaterialColour();\n\t\tmShininess = new ColladaShininess();\n\t\t\n\t\t//Default the diffuse\n\t\tmEmissive.mColour = DEFAULT_EMISSIVE;\n\t\tmDiffuse.mColour = DEFAULT_DIFFUSE;\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/ColladaParserUtils/src/com/chilliworks/chillisource/colladaparserutils/colladadata/ColladaChannel.java",
    "content": "/**\n * ColladaChannel.java\n * ChilliSource\n * Created by Ian Copland on 16/01/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.colladaparserutils.colladadata;\n\npublic class ColladaChannel \n{\n\tpublic String mstrSource;\n\tpublic String mstrTarget;\n\t\n\tpublic ColladaChannel()\n\t{\n\t\tmstrSource = new String();\n\t\tmstrTarget = new String();\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/ColladaParserUtils/src/com/chilliworks/chillisource/colladaparserutils/colladadata/ColladaColour.java",
    "content": "/**\n * ColladaColour.java\n * ChilliSource\n * Created by Ian Copland on 16/01/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.colladaparserutils.colladadata;\n\npublic class ColladaColour \n{\n\tpublic float mfR;\n\tpublic float mfG;\n\tpublic float mfB;\n\tpublic float mfA;\n\t\n\tpublic ColladaColour()\n\t{\n\t\tmfR = 1.0f;\n\t\tmfG = 1.0f;\n\t\tmfB = 1.0f;\n\t\tmfA = 1.0f;\n\t}\n\t\n\tpublic ColladaColour(float infR, float infG, float infB, float infA)\n\t{\n\t\tmfR = infR;\n\t\tmfG = infG;\n\t\tmfB = infB;\n\t\tmfA = infA;\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/ColladaParserUtils/src/com/chilliworks/chillisource/colladaparserutils/colladadata/ColladaContributor.java",
    "content": "/**\n * ColladaContributor.java\n * ChilliSource\n * Created by Ian Copland on 16/01/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.colladaparserutils.colladadata;\n\npublic class ColladaContributor \n{\n\tpublic ColladaAuthoringTool mAuthoringTool = new ColladaAuthoringTool();\n}\n"
  },
  {
    "path": "Projects/Tools/ColladaParserUtils/src/com/chilliworks/chillisource/colladaparserutils/colladadata/ColladaController.java",
    "content": "/**\n * ColladaController.java\n * ChilliSource\n * Created by Ian Copland on 16/01/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.colladaparserutils.colladadata;\n\npublic class ColladaController \n{\n\tpublic String mstrId;\n\tpublic ColladaSkin mSkin;\n\t\n\tpublic ColladaController()\n\t{\n\t\tmstrId = new String();\n\t\tmSkin = new ColladaSkin();\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/ColladaParserUtils/src/com/chilliworks/chillisource/colladaparserutils/colladadata/ColladaEffect.java",
    "content": "/**\n * ColladaEffect.java\n * ChilliSource\n * Created by Ian Copland on 16/01/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.colladaparserutils.colladadata;\n\npublic class ColladaEffect \n{\n\tpublic String mstrId;\n\tpublic ColladaProfileCommon mProfileCommon;\n\t//NOTE: \"Extra\" effect information is not read, as it is unlikely to be needed any time soon.\n\t\n\tpublic ColladaEffect()\n\t{\n\t\tmstrId = new String();\n\t\tmProfileCommon = new ColladaProfileCommon();\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/ColladaParserUtils/src/com/chilliworks/chillisource/colladaparserutils/colladadata/ColladaExtra.java",
    "content": "/**\n * ColladaExtra.java\n * ChilliSource\n * Created by Ian Copland on 16/01/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.colladaparserutils.colladadata;\n\npublic class ColladaExtra \n{\n\tpublic ColladaTechnique mTechnique;\n\t\n\tpublic ColladaExtra()\n\t{\n\t\tmTechnique = new ColladaTechnique();\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/ColladaParserUtils/src/com/chilliworks/chillisource/colladaparserutils/colladadata/ColladaFloat.java",
    "content": "/**\n * ColladaFloat.java\n * ChilliSource\n * Created by Ian Copland on 16/01/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.colladaparserutils.colladadata;\n\npublic class ColladaFloat \n{\n\tpublic float mfValue;\n\t\n\tpublic ColladaFloat()\n\t{\n\t\tmfValue = 0.0f;\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/ColladaParserUtils/src/com/chilliworks/chillisource/colladaparserutils/colladadata/ColladaFloatArray.java",
    "content": "/**\n * ColladaFloatArray.java\n * ChilliSource\n * Created by Ian Copland on 16/01/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.colladaparserutils.colladadata;\n\npublic class ColladaFloatArray \n{\n\tpublic String mstrId;\n\tpublic int mdwCount;\n\tpublic float[] mafData;\n\t\n\tpublic ColladaFloatArray()\n\t{\n\t\tmstrId = new String();\n\t\tmdwCount = 0;\n\t\tmafData = null;\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/ColladaParserUtils/src/com/chilliworks/chillisource/colladaparserutils/colladadata/ColladaGeometry.java",
    "content": "/**\n * ColladaGeometry.java\n * ChilliSource\n * Created by Ian Copland on 16/01/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.colladaparserutils.colladadata;\n\npublic class ColladaGeometry \n{\n\tpublic enum COLLADA_GEOMETRY_TYPE\n\t{\n\t\tNONE,\n\t\tMESH,\n\t\tSPLINE\n\t}\n\t\n\tpublic ColladaMesh mMesh;\n\tpublic String mstrId;\n\tpublic String mstrName;\n\tpublic COLLADA_GEOMETRY_TYPE meType; \n\t\n\tpublic ColladaGeometry()\n\t{\n\t\tmMesh = new ColladaMesh();\n\t\tmstrId = new String();\n\t\tmstrName = new String();\n\t\tmeType = COLLADA_GEOMETRY_TYPE.NONE;\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/ColladaParserUtils/src/com/chilliworks/chillisource/colladaparserutils/colladadata/ColladaImage.java",
    "content": "/**\n * ColladaImage.java\n * ChilliSource\n * Created by Ian Copland on 16/01/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.colladaparserutils.colladadata;\n\npublic class ColladaImage \n{\n\tpublic String mstrId;\n\tpublic ColladaInitFrom mInitFrom;\n\t\n\tpublic ColladaImage()\n\t{\n\t\tmstrId = new String();\n\t\tmInitFrom = new ColladaInitFrom();\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/ColladaParserUtils/src/com/chilliworks/chillisource/colladaparserutils/colladadata/ColladaInitFrom.java",
    "content": "/**\n * ColladaInitFrom.java\n * ChilliSource\n * Created by Ian Copland on 16/01/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.colladaparserutils.colladadata;\n\npublic class ColladaInitFrom \n{\n\tpublic String mstrValue;\n\t\n\tpublic ColladaInitFrom()\n\t{\n\t\tmstrValue = new String();\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/ColladaParserUtils/src/com/chilliworks/chillisource/colladaparserutils/colladadata/ColladaInput.java",
    "content": "/**\n * ColladaInput.java\n * ChilliSource\n * Created by Ian Copland on 16/01/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.colladaparserutils.colladadata;\n\npublic class ColladaInput \n{\n\tpublic String mstrSemantic;\n\tpublic String mstrSource;\n\tpublic int mdwOffset;\n\tpublic int mdwSet;\n\t\n\tpublic ColladaInput()\n\t{\n\t\tmstrSemantic = new String();\n\t\tmstrSource = new String();\n\t\tmdwOffset = 0;\n\t\tmdwSet = 0;\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/ColladaParserUtils/src/com/chilliworks/chillisource/colladaparserutils/colladadata/ColladaInstanceCamera.java",
    "content": "/**\n * ColladaInstanceCamera.java\n * ChilliSource\n * Created by Ian Copland on 16/01/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.colladaparserutils.colladadata;\n\npublic class ColladaInstanceCamera \n{\n\tpublic String mstrUrl;\n\t\n\tpublic ColladaInstanceCamera()\n\t{\n\t\tmstrUrl = new String();\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/ColladaParserUtils/src/com/chilliworks/chillisource/colladaparserutils/colladadata/ColladaInstanceController.java",
    "content": "/**\n * ColladaInstanceController.java\n * ChilliSource\n * Created by Ian Copland on 16/01/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.colladaparserutils.colladadata;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\npublic class ColladaInstanceController \n{\n\tpublic String mstrUrl;\n\tpublic List<ColladaSkeleton> m_skeletons = new ArrayList<>();\n\tpublic ColladaBindMaterial mBindMaterial;\n\t\n\tpublic ColladaInstanceController()\n\t{\n\t\tmstrUrl = new String();\n\t\tmBindMaterial = new ColladaBindMaterial();\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/ColladaParserUtils/src/com/chilliworks/chillisource/colladaparserutils/colladadata/ColladaInstanceEffect.java",
    "content": "/**\n * ColladaInstanceEffect.java\n * ChilliSource\n * Created by Ian Copland on 16/01/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.colladaparserutils.colladadata;\n\npublic class ColladaInstanceEffect \n{\n\tpublic String mstrUrl;\n\t\n\tpublic ColladaInstanceEffect()\n\t{\n\t\tmstrUrl = new String();\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/ColladaParserUtils/src/com/chilliworks/chillisource/colladaparserutils/colladadata/ColladaInstanceGeometry.java",
    "content": "/**\n * ColladaInstanceGeometry.java\n * ChilliSource\n * Created by Ian Copland on 16/01/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.colladaparserutils.colladadata;\n\npublic class ColladaInstanceGeometry \n{\n\tpublic String mstrUrl;\n\tpublic ColladaBindMaterial mBindMaterial;\n\t\n\tpublic ColladaInstanceGeometry()\n\t{\n\t\tmstrUrl = new String();\n\t\tmBindMaterial = new ColladaBindMaterial();\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/ColladaParserUtils/src/com/chilliworks/chillisource/colladaparserutils/colladadata/ColladaInstanceLight.java",
    "content": "/**\n * ColladaInstanceLight.java\n * ChilliSource\n * Created by Ian Copland on 16/01/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.colladaparserutils.colladadata;\n\npublic class ColladaInstanceLight \n{\n\tpublic String mstrUrl;\n\t\n\tpublic ColladaInstanceLight()\n\t{\n\t\tmstrUrl = new String();\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/ColladaParserUtils/src/com/chilliworks/chillisource/colladaparserutils/colladadata/ColladaInstanceMaterial.java",
    "content": "/**\n * ColladaInstanceMaterial.java\n * ChilliSource\n * Created by Ian Copland on 16/01/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.colladaparserutils.colladadata;\n\npublic class ColladaInstanceMaterial \n{\n\tpublic String mstrSymbol;\n\tpublic String mstrTarget;\n\tpublic ColladaBindVertexInput mBindVertexInput;\n\t\n\tpublic ColladaInstanceMaterial()\n\t{\n\t\tmstrSymbol = new String();\n\t\tmstrTarget = new String();\n\t\tmBindVertexInput = new ColladaBindVertexInput();\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/ColladaParserUtils/src/com/chilliworks/chillisource/colladaparserutils/colladadata/ColladaInstanceVisualScene.java",
    "content": "/**\n * ColladInstanceVisualScene.java\n * ChilliSource\n * Created by Ian Copland on 16/01/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.colladaparserutils.colladadata;\n\npublic class ColladaInstanceVisualScene \n{\n\tpublic String mstrUrl;\n\t\n\tpublic ColladaInstanceVisualScene()\n\t{\n\t\tmstrUrl = new String();\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/ColladaParserUtils/src/com/chilliworks/chillisource/colladaparserutils/colladadata/ColladaJoints.java",
    "content": "/**\n * ColladaInstanceJoints.java\n * ChilliSource\n * Created by Ian Copland on 16/01/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.colladaparserutils.colladadata;\n\nimport java.util.LinkedList;\n\npublic class ColladaJoints \n{\n\tpublic LinkedList<ColladaInput> mInputs;\n\t\n\tpublic ColladaJoints()\n\t{\n\t\tmInputs = new LinkedList<ColladaInput>();\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/ColladaParserUtils/src/com/chilliworks/chillisource/colladaparserutils/colladadata/ColladaMaterial.java",
    "content": "/**\n * ColladaMaterial.java\n * ChilliSource\n * Created by Ian Copland on 16/01/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.colladaparserutils.colladadata;\n\npublic class ColladaMaterial \n{\n\tpublic String mstrId;\n\tpublic String mstrName;\n\tpublic ColladaInstanceEffect mInstanceEffect;\n\t\n\tpublic ColladaMaterial()\n\t{\n\t\tmstrId = new String();\n\t\tmstrName = new String();\n\t\tmInstanceEffect = new ColladaInstanceEffect();\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/ColladaParserUtils/src/com/chilliworks/chillisource/colladaparserutils/colladadata/ColladaMaterialColour.java",
    "content": "/**\n * ColladaMaterialColour.java\n * ChilliSource\n * Created by Ian Copland on 16/01/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.colladaparserutils.colladadata;\n\npublic class ColladaMaterialColour \n{\n\tpublic ColladaColour mColour;\n\tpublic ColladaTexture mTexture;\n\t\n\tpublic ColladaMaterialColour()\n\t{\n\t\tmColour = new ColladaColour();\n\t\tmTexture = new ColladaTexture();\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/ColladaParserUtils/src/com/chilliworks/chillisource/colladaparserutils/colladadata/ColladaMesh.java",
    "content": "/**\n * ColladaMesh.java\n * ChilliSource\n * Created by Ian Copland on 16/01/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.colladaparserutils.colladadata;\n\nimport java.util.Hashtable;\nimport java.util.LinkedList;\n\npublic class ColladaMesh \n{\n\tpublic Hashtable<String, ColladaSource> mSources;\n\tpublic ColladaVertices mVertices;\n\tpublic LinkedList<ColladaTriangles> mTrianglesList;\n\t\n\tpublic ColladaMesh()\n\t{\n\t\tmSources = new Hashtable<String, ColladaSource>();\n\t\tmVertices = new ColladaVertices();\n\t\tmTrianglesList = new LinkedList<ColladaTriangles>();\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/ColladaParserUtils/src/com/chilliworks/chillisource/colladaparserutils/colladadata/ColladaNameArray.java",
    "content": "/**\n * ColladaNameArray.java\n * ChilliSource\n * Created by Ian Copland on 16/01/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.colladaparserutils.colladadata;\n\npublic class ColladaNameArray \n{\n\tpublic String mstrId;\n\tpublic int mdwCount;\n\tpublic String[] mstrData;\n\t\n\tpublic ColladaNameArray()\n\t{\n\t\tmstrId = new String();\n\t\tmdwCount = 0;\n\t\tmstrData = null;\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/ColladaParserUtils/src/com/chilliworks/chillisource/colladaparserutils/colladadata/ColladaNewParam.java",
    "content": "/**\n * ColladaNewParam.java\n * ChilliSource\n * Created by Ian Copland on 16/01/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.colladaparserutils.colladadata;\n\npublic class ColladaNewParam \n{\n\tpublic String mstrSId;\n\tpublic ColladaSurface mSurface;\n\tpublic ColladaSampler2D mSampler2D;\n\t\n\tpublic ColladaNewParam()\n\t{\n\t\tmstrSId = new String();\n\t\tmSurface = new ColladaSurface();\n\t\tmSampler2D = new ColladaSampler2D();\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/ColladaParserUtils/src/com/chilliworks/chillisource/colladaparserutils/colladadata/ColladaNode.java",
    "content": "/**\n * ColladaNode.java\n * ChilliSource\n * Created by Ian Copland on 16/01/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.colladaparserutils.colladadata;\n\nimport java.util.Hashtable;\n\nimport com.chilliworks.chillisource.coreutils.Matrix4;\n\npublic class ColladaNode \n{\n\tpublic enum COLLADA_NODE_TYPE\n\t{\n\t\tBASE,\n\t\tJOINT,\n\t\tLIGHT,\n\t\tGEOMETRY,\n\t\tCONTROLLER,\n\t\tCAMERA\n\t}\n\t\n\tpublic Hashtable<String, ColladaNode> mChildNodes;\n\tpublic String mstrId;\n\tpublic String mstrName;\n\tpublic String mstrType;\n\tpublic String mstrSId;\n\tpublic COLLADA_NODE_TYPE meType;\n\tpublic ColladaInstanceLight mInstanceLight;\n\tpublic ColladaInstanceGeometry mInstanceGeometry;\n\tpublic ColladaInstanceController mInstanceController;\n\tpublic ColladaInstanceCamera mInstanceCamera;\n\tpublic ColladaExtra mExtra;\n\tpublic Matrix4 m_transform = Matrix4.IDENTITY;\n\t\n\tpublic ColladaNode()\n\t{\n\t\tmChildNodes = new Hashtable<String, ColladaNode>();\n\t\tmstrId = new String();\n\t\tmstrName = new String();\n\t\tmeType = COLLADA_NODE_TYPE.BASE;\n\t\tmInstanceLight = new ColladaInstanceLight();\n\t\tmInstanceGeometry = new ColladaInstanceGeometry();\n\t\tmInstanceController = new ColladaInstanceController();\n\t\tmInstanceCamera = new ColladaInstanceCamera();\n\t\tmExtra = new ColladaExtra();\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/ColladaParserUtils/src/com/chilliworks/chillisource/colladaparserutils/colladadata/ColladaP.java",
    "content": "/**\n * ColladaP.java\n * ChilliSource\n * Created by Ian Copland on 16/01/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.colladaparserutils.colladadata;\n\npublic class ColladaP \n{\n\tpublic int[] madwValues;\n\t\n\tpublic ColladaP()\n\t{\n\t\tmadwValues = null;\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/ColladaParserUtils/src/com/chilliworks/chillisource/colladaparserutils/colladadata/ColladaParam.java",
    "content": "/**\n * ColladaParam.java\n * ChilliSource\n * Created by Ian Copland on 16/01/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.colladaparserutils.colladadata;\n\npublic class ColladaParam \n{\n\tpublic String mstrName;\n\tpublic String mstrType;\n\t\n\tpublic ColladaParam()\n\t{\n\t\tmstrName = new String();\n\t\tmstrType = new String();\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/ColladaParserUtils/src/com/chilliworks/chillisource/colladaparserutils/colladadata/ColladaProfileCommon.java",
    "content": "/**\n * ColladaProfileCommon.java\n * ChilliSource\n * Created by Ian Copland on 16/01/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.colladaparserutils.colladadata;\n\nimport java.util.Hashtable;\n\npublic class ColladaProfileCommon \n{\n\tpublic Hashtable<String, ColladaNewParam> mNewParams;\n\tpublic ColladaTechnique mTechnique;\n\t\n\tpublic ColladaProfileCommon()\n\t{\n\t\tmNewParams = new Hashtable<String, ColladaNewParam>();\n\t\tmTechnique = new ColladaTechnique();\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/ColladaParserUtils/src/com/chilliworks/chillisource/colladaparserutils/colladadata/ColladaSampler.java",
    "content": "/**\n * ColladaSampler.java\n * ChilliSource\n * Created by Ian Copland on 16/01/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.colladaparserutils.colladadata;\n\nimport java.util.Hashtable;\n\n\npublic class ColladaSampler \n{\n\tpublic String mstrId;\n\tpublic Hashtable<String, ColladaInput> mInputTable;\n\t\n\tpublic ColladaSampler()\n\t{\n\t\tmstrId = new String();\n\t\tmInputTable = new Hashtable<String, ColladaInput>();\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/ColladaParserUtils/src/com/chilliworks/chillisource/colladaparserutils/colladadata/ColladaSampler2D.java",
    "content": "/**\n * ColladaSampler2D.java\n * ChilliSource\n * Created by Ian Copland on 16/01/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.colladaparserutils.colladadata;\n\npublic class ColladaSampler2D \n{\n\tpublic ColladaSource mSource;\n}\n"
  },
  {
    "path": "Projects/Tools/ColladaParserUtils/src/com/chilliworks/chillisource/colladaparserutils/colladadata/ColladaScene.java",
    "content": "/**\n * ColladaScene.java\n * ChilliSource\n * Created by Ian Copland on 16/01/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.colladaparserutils.colladadata;\n\npublic class ColladaScene \n{\n\tpublic ColladaInstanceVisualScene mInstanceVisualScene;\n\t\n\tpublic ColladaScene()\n\t{\n\t\tmInstanceVisualScene = new ColladaInstanceVisualScene();\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/ColladaParserUtils/src/com/chilliworks/chillisource/colladaparserutils/colladadata/ColladaShininess.java",
    "content": "/**\n * ColladaShininess.java\n * ChilliSource\n * Created by Ian Copland on 16/01/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.colladaparserutils.colladadata;\n\npublic class ColladaShininess \n{\n\tpublic ColladaFloat mFloat;\n\t\n\tpublic ColladaShininess()\n\t{\n\t\tmFloat = new ColladaFloat();\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/ColladaParserUtils/src/com/chilliworks/chillisource/colladaparserutils/colladadata/ColladaSkeleton.java",
    "content": "/**\n * ColladaSkeleton.java\n * ChilliSource\n * Created by Ian Copland on 16/01/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.colladaparserutils.colladadata;\n\npublic class ColladaSkeleton \n{\n\tpublic String mstrValue;\n\t\n\tpublic ColladaSkeleton()\n\t{\n\t\tmstrValue = new String();\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/ColladaParserUtils/src/com/chilliworks/chillisource/colladaparserutils/colladadata/ColladaSkin.java",
    "content": "/**\n * ColladaSkin.java\n * ChilliSource\n * Created by Ian Copland on 16/01/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.colladaparserutils.colladadata;\n\nimport java.util.Hashtable;\n\npublic class ColladaSkin \n{\n\tpublic String mstrSource;\n\tpublic ColladaBindShapeMatrix mBindShapeMatrix;\n\tpublic Hashtable<String, ColladaSource> mSourceTable;\n\tpublic ColladaJoints mJoints;\n\tpublic ColladaVertexWeights mVertexWeights;\n\t\n\tpublic ColladaSkin()\n\t{\n\t\tmstrSource = new String();\n\t\tmBindShapeMatrix = new ColladaBindShapeMatrix();\n\t\tmSourceTable = new Hashtable<String, ColladaSource>();\n\t\tmJoints = new ColladaJoints();\n\t\tmVertexWeights = new ColladaVertexWeights();\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/ColladaParserUtils/src/com/chilliworks/chillisource/colladaparserutils/colladadata/ColladaSource.java",
    "content": "/**\n * ColladaSource.java\n * ChilliSource\n * Created by Ian Copland on 16/01/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.colladaparserutils.colladadata;\n\npublic class ColladaSource \n{\n\tpublic ColladaFloatArray mFloatArray;\n\tpublic ColladaNameArray mNameArray;\n\tpublic ColladaTechniqueCommon mTechniqueCommon;\n\tpublic String mstrId;\n\tpublic String mstrContents;\n\t\n\tpublic ColladaSource()\n\t{\n\t\tmNameArray = new ColladaNameArray();\n\t\tmFloatArray = new ColladaFloatArray();\n\t\tmTechniqueCommon = new ColladaTechniqueCommon();\n\t\tmstrId = new String();\n\t\tmstrContents = new String();\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/ColladaParserUtils/src/com/chilliworks/chillisource/colladaparserutils/colladadata/ColladaSurface.java",
    "content": "/**\n * ColladaSurface.java\n * ChilliSource\n * Created by Ian Copland on 16/01/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.colladaparserutils.colladadata;\n\npublic class ColladaSurface \n{\n\tpublic String mstrType;\n\tpublic ColladaInitFrom mInitFrom;\n\t\n\tpublic ColladaSurface()\n\t{\n\t\tmstrType = new String();\n\t\tmInitFrom = new ColladaInitFrom();\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/ColladaParserUtils/src/com/chilliworks/chillisource/colladaparserutils/colladadata/ColladaTechnique.java",
    "content": "/**\n * ColladaTechnique.java\n * ChilliSource\n * Created by Ian Copland on 16/01/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.colladaparserutils.colladadata;\n\npublic class ColladaTechnique \n{\n\tpublic String mstrSId;\n\tpublic String mstrProfile;\n\tpublic ColladaBlinnAndPhong mBlinnAndPhong;\n\tpublic ColladaUserProperties mUserProperties; \n\t\n\tpublic ColladaTechnique()\n\t{\n\t\tmstrSId = new String();\n\t\tmstrProfile = new String();\n\t\tmBlinnAndPhong = new ColladaBlinnAndPhong();\n\t\tmUserProperties = new ColladaUserProperties();\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/ColladaParserUtils/src/com/chilliworks/chillisource/colladaparserutils/colladadata/ColladaTechniqueCommon.java",
    "content": "/**\n * ColladaTechniqueCommon.java\n * ChilliSource\n * Created by Ian Copland on 16/01/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.colladaparserutils.colladadata;\n\nimport java.util.LinkedList;\n\npublic class ColladaTechniqueCommon \n{\n\tpublic ColladaAccessor mAccessor;\n\tpublic LinkedList<ColladaInstanceMaterial> mInstanceMaterialList;\n\t\n\tpublic ColladaTechniqueCommon()\n\t{\n\t\tmAccessor = new ColladaAccessor();\n\t\tmInstanceMaterialList = new LinkedList<ColladaInstanceMaterial>();\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/ColladaParserUtils/src/com/chilliworks/chillisource/colladaparserutils/colladadata/ColladaTexture.java",
    "content": "/**\n * ColladaTexture.java\n * ChilliSource\n * Created by Ian Copland on 16/01/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.colladaparserutils.colladadata;\n\npublic class ColladaTexture \n{\n\tpublic String mstrTexture;\n\tpublic String mstrTexCoord;\n\t\n\tpublic ColladaTexture()\n\t{\n\t\tmstrTexture = new String();\n\t\tmstrTexCoord = new String();\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/ColladaParserUtils/src/com/chilliworks/chillisource/colladaparserutils/colladadata/ColladaTriangles.java",
    "content": "/**\n * ColladaTriangles.java\n * ChilliSource\n * Created by Ian Copland on 16/01/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.colladaparserutils.colladadata;\n\nimport java.util.LinkedList;\n\npublic class ColladaTriangles \n{\n\tpublic String mstrMaterial;\n\tpublic int mdwCount;\n\tpublic LinkedList<ColladaInput> mInputList;\n\tpublic ColladaP mP;\n\t\n\tpublic ColladaTriangles()\n\t{\n\t\tmstrMaterial = new String();\n\t\tmdwCount = 0;\n\t\tmInputList = new LinkedList<ColladaInput>();\n\t\tmP = new ColladaP();\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/ColladaParserUtils/src/com/chilliworks/chillisource/colladaparserutils/colladadata/ColladaUserProperties.java",
    "content": "/**\n * ColladaUserProperties.java\n * ChilliSource\n * Created by Ian Copland on 16/01/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.colladaparserutils.colladadata;\n\npublic class ColladaUserProperties \n{\n\tpublic String mstrData;\n\t\n\tpublic ColladaUserProperties()\n\t{\n\t\tmstrData = new String();\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/ColladaParserUtils/src/com/chilliworks/chillisource/colladaparserutils/colladadata/ColladaV.java",
    "content": "/**\n * ColladaV.java\n * ChilliSource\n * Created by Ian Copland on 16/01/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.colladaparserutils.colladadata;\n\npublic class ColladaV \n{\n\tpublic int[] madwData;\n\t\n\tpublic ColladaV()\n\t{\n\t\t\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/ColladaParserUtils/src/com/chilliworks/chillisource/colladaparserutils/colladadata/ColladaVCount.java",
    "content": "/**\n * ColladaVCount.java\n * ChilliSource\n * Created by Ian Copland on 16/01/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.colladaparserutils.colladadata;\n\npublic class ColladaVCount \n{\n\tpublic int[] madwData;\n\t\n\tpublic ColladaVCount()\n\t{\n\t\t\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/ColladaParserUtils/src/com/chilliworks/chillisource/colladaparserutils/colladadata/ColladaVertexWeights.java",
    "content": "/**\n * ColladaVertexWeights.java\n * ChilliSource\n * Created by Ian Copland on 16/01/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.colladaparserutils.colladadata;\n\nimport java.util.LinkedList;\n\npublic class ColladaVertexWeights \n{\n\tpublic int mdwCount;\n\tpublic LinkedList<ColladaInput> mInputs;\n\tpublic ColladaVCount mVCount;\n\tpublic ColladaV mV;\n\t\n\tpublic ColladaVertexWeights()\n\t{\n\t\tmdwCount = 0;\n\t\tmInputs = new LinkedList<ColladaInput>();\n\t\tmVCount = new ColladaVCount();\n\t\tmV = new ColladaV();\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/ColladaParserUtils/src/com/chilliworks/chillisource/colladaparserutils/colladadata/ColladaVertices.java",
    "content": "/**\n * ColladaVertices.java\n * ChilliSource\n * Created by Ian Copland on 16/01/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.colladaparserutils.colladadata;\n\npublic class ColladaVertices \n{\n\tpublic String mstrId;\n\tpublic ColladaInput mInput;\n\t\n\tpublic ColladaVertices()\n\t{\n\t\tmstrId = new String();\n\t\tmInput = new ColladaInput();\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/ColladaParserUtils/src/com/chilliworks/chillisource/colladaparserutils/colladadata/ColladaVisualScene.java",
    "content": "/**\n * ColladaVisualScene.java\n * ChilliSource\n * Created by Ian Copland on 16/01/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.colladaparserutils.colladadata;\n\nimport java.util.Hashtable;\n\npublic class ColladaVisualScene \n{\n\tpublic Hashtable<String, ColladaNode> mRootNodes;\n\tpublic String mstrId;\n\t\n\tpublic ColladaVisualScene()\n\t{\n\t\tmRootNodes = new Hashtable<String, ColladaNode>();\n\t\tmstrId = new String();\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/ColladaToCSAnim/.classpath",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<classpath>\n\t<classpathentry kind=\"src\" path=\"src\"/>\n\t<classpathentry kind=\"con\" path=\"org.eclipse.jdt.launching.JRE_CONTAINER\"/>\n\t<classpathentry combineaccessrules=\"false\" kind=\"src\" path=\"/CoreUtils\"/>\n\t<classpathentry combineaccessrules=\"false\" kind=\"src\" path=\"/ColladaParserUtils\"/>\n\t<classpathentry kind=\"output\" path=\"bin\"/>\n</classpath>\n"
  },
  {
    "path": "Projects/Tools/ColladaToCSAnim/.project",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<projectDescription>\n\t<name>ColladaToCSAnim</name>\n\t<comment></comment>\n\t<projects>\n\t</projects>\n\t<buildSpec>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.jdt.core.javabuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t</buildSpec>\n\t<natures>\n\t\t<nature>org.eclipse.jdt.core.javanature</nature>\n\t</natures>\n</projectDescription>\n"
  },
  {
    "path": "Projects/Tools/ColladaToCSAnim/Manifest/Manifest.txt",
    "content": "Manifest-Version: 1.0\r\nMain-Class: com.chillisource.colladatocsanim.Main\r\n\r\n"
  },
  {
    "path": "Projects/Tools/ColladaToCSAnim/src/com/chilliworks/chillisource/colladatocsanim/Animation.java",
    "content": "/**\n * Animation.java\n * ChilliSource\n * Created by Ian Copland on 16/01/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.colladatocsanim;\n\nimport java.util.LinkedList;\n\nimport com.chilliworks.chillisource.coreutils.Matrix4;\n\npublic class Animation \n{\n\tpublic float mfFrameRate;\n\tpublic LinkedList<Matrix4> mTransformList;\n\t\n\tpublic Animation()\n\t{\n\t\tmfFrameRate = 0.0f;\n\t\tmTransformList = new LinkedList<Matrix4>();\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/ColladaToCSAnim/src/com/chilliworks/chillisource/colladatocsanim/CSAnimConverter.java",
    "content": "/**\n * CSAnimConverter.java\n * ChilliSource\n * Created by Ian Copland on 16/01/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.colladatocsanim;\n\nimport java.util.LinkedList;\n\nimport com.chilliworks.chillisource.colladaparserutils.colladadata.*;\nimport com.chilliworks.chillisource.colladatocsanim.csanim.*;\nimport com.chilliworks.chillisource.coreutils.Logging;\nimport com.chilliworks.chillisource.coreutils.Matrix4;\nimport com.chilliworks.chillisource.coreutils.Quaternion;\nimport com.chilliworks.chillisource.coreutils.Tuple3;\nimport com.chilliworks.chillisource.coreutils.Vector3;\n\npublic class CSAnimConverter \n{\n\t/**\n\t * private data\n\t */\n\tAnimation[] mAnimations;\n\t\n\t/**\n\t * Constructor\n\t */\n\tpublic CSAnimConverter()\n\t{\n\t\t\n\t}\n\t\n\t/**\n\t * Converts the input collections of data from the collada file into something useable for outputing in MoAnim format.\n\t * @param inMeshList\n\t * @param inTextureList\n\t */\n\tpublic void ConvertToMoAnimFormat(LinkedList<String> inNodesToExport, Collada inCollada, CSAnim inMoAnim)\n\t{\n\t\tmAnimations = new Animation[inMoAnim.mSkeleton.mNodeList.size()];\n\t\t\n\t\tfor (int i = 0; i < inMoAnim.mSkeleton.mNodeList.size(); i++)\n\t\t\tmAnimations[i] = new Animation();\n\t\t\n\t\tLinkedList<String> allowedNodes = new LinkedList<String>();\n\t\t\n\t\t//build the list of acceptable nodes\n\t\tfor (ColladaNode node : inCollada.mLibraryVisualScenes.get(inCollada.mScene.mInstanceVisualScene.mstrUrl.substring(1)).mRootNodes.values())\n\t\t{\n\t\t\tTryAddToAllowedList(node, inNodesToExport, allowedNodes, false);\n\t\t}\n\t\t\n\t\t//iterate through all animation channels\n\t\tfor (ColladaAnimation animation : inCollada.m_animations)\n\t\t{\n\t\t\tfor (ColladaChannel channel: animation.mChannelList)\n\t\t\t{\n\t\t\t\tTryAddChannel(inCollada, inMoAnim, allowedNodes, animation, channel);\n\t\t\t}\n\t\t}\n\t\t\n\t\t//convert the animation data, intro frame data.\n\t\tConvertAnimationsToFrames(inMoAnim);\n\t}\n\t\n\t/**\n\t * Adds to the list of node names that are allowed. Only animation on nodes contained in this list will be outputted.\n\t * @param inNode\n\t * @param inNodesToExport\n\t * @param inAllowedNodes\n\t */\n\tprivate void TryAddToAllowedList(ColladaNode inNode, LinkedList<String> inNodesToExport, LinkedList<String> inAllowedNodes, boolean inbParentExported)\n\t{\n\t\tboolean bShouldAdd = inbParentExported;\n\t\t\n\t\t//if the parent was not exported, check and see if this node should be\n\t\tif (bShouldAdd == false)\n\t\t{\n\t\t\tfor (String nodeName: inNodesToExport)\n\t\t\t{\n\t\t\t\tif (nodeName.equalsIgnoreCase(inNode.mstrId) == true)\n\t\t\t\t{\n\t\t\t\t\tbShouldAdd = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\t//if it should be added, then add it!\n\t\tif (bShouldAdd == true)\n\t\t{\n\t\t\tinAllowedNodes.add(inNode.mstrId);\n\t\t}\n\t\t\n\t\t//try children\n\t\tfor (ColladaNode node: inNode.mChildNodes.values())\n\t\t{\n\t\t\tTryAddToAllowedList(node, inNodesToExport, inAllowedNodes, bShouldAdd);\n\t\t}\n\t}\n\t\n\t/**\n\t * Adds the animation described by the input channel if the channel is targeting an allowed node.\n\t * @param inCollada\n\t * @param inAllowedNodes\n\t * @param in_animation - The animation\n\t * @param inChannel\n\t */\n\tprivate void TryAddChannel(Collada inCollada, CSAnim inMoAnim, LinkedList<String> inAllowedNodes, ColladaAnimation in_animation, ColladaChannel inChannel)\n\t{\n\t\t//get the targeted node name.\n\t\tString[] strSplitTarget = inChannel.mstrTarget.split(\"/\");\n\t\tString strTargetNode = strSplitTarget[0];\n\t\t\n\t\tfor (String nodeName: inAllowedNodes)\n\t\t{\n\t\t\tif (nodeName.equalsIgnoreCase(strTargetNode) == true)\n\t\t\t{\n\t\t\t\t//if this channel should indeed be used then get the sampler\n\t\t\t\tColladaSampler sampler = in_animation.mSamplerTable.get(inChannel.mstrSource.substring(1));\n\t\t\t\t\n\t\t\t\t//use the sampler to get the sources\n\t\t\t\tColladaSource timelineSource = in_animation.mSourceTable.get(sampler.mInputTable.get(\"INPUT\").mstrSource.substring(1));\n\t\t\t\tColladaSource transformSource = in_animation.mSourceTable.get(sampler.mInputTable.get(\"OUTPUT\").mstrSource.substring(1));\n\t\t\t\tColladaSource interpolationSource = in_animation.mSourceTable.get(sampler.mInputTable.get(\"INTERPOLATION\").mstrSource.substring(1));\n\n\t\t\t\t//get the skeleton node name\n\t\t\t\tColladaNode node = GetNodeWithID(new LinkedList<ColladaNode>(\n\t\t\t\t\t\tinCollada.mLibraryVisualScenes.get(inCollada.mScene.mInstanceVisualScene.mstrUrl.substring(1)).mRootNodes.values()), \n\t\t\t\t\t\tstrTargetNode);\n\t\t\t\t\n\t\t\t\t//if this node is indeed a skeleton node, then add the animation for it.\n\t\t\t\tif (node != null && node.mstrId.length() > 0)\n\t\t\t\t\tAddAnimation(inMoAnim, timelineSource, transformSource, interpolationSource, node.mstrId);\n\t\t\t\t\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t}\n\t\n\t/**\n\t * Adds an animation to the \"animation\" list. This list is then used to build the frame data for outputting in MoAnim.\n\t * @param inTimelineSource\n\t * @param inTransformSource\n\t * @param inInterpolationSource\n\t */\n\tpublic void AddAnimation(CSAnim inMoAnim, ColladaSource inTimelineSource, ColladaSource inTransformSource, ColladaSource inInterpolationSource, String instrSkeletonNodeId)\n\t{\n\t\tAnimation anim = new Animation();\n\t\t\n\t\t//confirm that all interpolations are linear, throw an error if they are not\n\t\tfor (String interpType: inInterpolationSource.mNameArray.mstrData)\n\t\t{\n\t\t\tif (interpType.equals(\"LINEAR\") == false)\n\t\t\t{\n\t\t\t\tLogging.logFatal(\"Unsupported Interpolation type: \" + interpType);\n\t\t\t}\n\t\t}\n\t\t\n\t\t//get the frame rate\n\t\tif (inTimelineSource.mFloatArray.mdwCount > 1)\n\t\t{\n\t\t\tanim.mfFrameRate = inTimelineSource.mFloatArray.mafData[1] - inTimelineSource.mFloatArray.mafData[0];\n\t\t}\n\t\t\n\t\t//get the index of the skeleton node this is paired with.\n\t\tint index = SkeletonBuilder.GetIndexOfSkeletonNodeById(inMoAnim, instrSkeletonNodeId);\n\t\t\n\t\tif(index == -1)\n\t\t\treturn;\n\t\t\n\t\t//get all the matrix data\n\t\tfloat[] m = inTransformSource.mFloatArray.mafData;\n\t\tfor (int i = 0; i < inTransformSource.mFloatArray.mdwCount / 16; i++)\n\t\t{\n\t\t\t//create new matrix from the float array\n\t\t\tMatrix4 mat = new Matrix4(m[i*16 + 0], m[i*16 + 4], m[i*16 + 8], m[i*16 + 12],\n\t\t\t\tm[i*16 + 1], m[i*16 + 5], m[i*16 + 9], m[i*16 + 13],\n\t\t\t\tm[i*16 + 2], m[i*16 + 6], m[i*16 + 10], m[i*16 + 14],\n\t\t\t\tm[i*16 + 3], m[i*16 + 7], m[i*16 + 11], m[i*16 + 15]);\n\n\t\t\t//add matrix to animation\n\t\t\tanim.mTransformList.add(mat);\n\t\t}\n\n\t\t//add anim to anim array\n\t\tmAnimations[index] = anim;\n\t}\n\t\n\t/**\n\t * Gets the collada node with the passed in ID\n\t * @param inCollada\n\t * @param strTargetNode\n\t * @return\n\t */\n\tprivate ColladaNode GetNodeWithID(LinkedList<ColladaNode> inNodeList, String strTargetNode)\n\t{\n\t\tfor (ColladaNode node:\tinNodeList)\n\t\t{\n\t\t\tif (node.mstrId.equals(strTargetNode) == true)\n\t\t\t\treturn node;\n\t\t\t\n\t\t\tColladaNode childNode = GetNodeWithID(new LinkedList<ColladaNode>(node.mChildNodes.values()), strTargetNode);\n\t\t\t\n\t\t\tif (childNode != null)\n\t\t\t\treturn childNode;\n\t\t}\n\t\t\n\t\treturn null;\n\t}\n\t\n\t/**\n\t * Convert the Animation data into frame data that can be used for outputting in MoAnim\n\t * @param inAnim\n\t */\n\tprivate void ConvertAnimationsToFrames(CSAnim inAnim)\n\t{\n\t\tif (mAnimations.length > 0 && mAnimations.length == inAnim.mSkeleton.mNodeList.size())\n\t\t{\n\t\t\t//get the first non 0 framerate\n\t\t\tfor (int i = 0; i < mAnimations.length; i++)\n\t\t\t{\n\t\t\t\tif (mAnimations[i].mfFrameRate != 0.0f)\n\t\t\t\t{\n\t\t\t\t\tinAnim.mfFrameRate = mAnimations[i].mfFrameRate;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\t//get the number of frames\n\t\t\tint dwNumFrames = 0;\n\t\t\tfor (int i = 0; i < mAnimations.length; i++)\n\t\t\t{\n\t\t\t\tif (mAnimations[i].mTransformList.size() != 0)\n\t\t\t\t{\n\t\t\t\t\tdwNumFrames = mAnimations[i].mTransformList.size();\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\t//iterate through each frame\n\t\t\tfor (int i = 0; i < dwNumFrames; i++)\n\t\t\t{\n\t\t\t\tCSAnimFrame frame = new CSAnimFrame();\n\t\t\t\t\n\t\t\t\tfor (int j = 0; j < mAnimations.length; j++)\n\t\t\t\t{\n\t\t\t\t\tMatrix4 transform;\n\t\t\t\t\tif (mAnimations[j].mTransformList.size() > 0)\n\t\t\t\t\t\ttransform = mAnimations[j].mTransformList.get(i);\n\t\t\t\t\telse\n\t\t\t\t\t\ttransform = inAnim.mSkeleton.mNodeList.get(j).mInitialPoseMatrix;\n\t\t\t\t\t\n\t\t\t\t\tTuple3<Vector3, Vector3, Quaternion> decomposedTransform = transform.decomposeTransforms();\n\t\t\t\t\t\n\t\t\t\t\tframe.mNodeTranslations.add(decomposedTransform.getFirst());\n\t\t\t\t\tframe.mNodeOrienations.add(Quaternion.normalise(decomposedTransform.getThird()));\n\t\t\t\t\tframe.mNodeScalings.add(decomposedTransform.getSecond());\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tinAnim.mFrames.add(frame);\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tLogging.logFatal(\"Animation and skeleton node counts do not match!\");\n\t\t}\n\t}\n}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
  },
  {
    "path": "Projects/Tools/ColladaToCSAnim/src/com/chilliworks/chillisource/colladatocsanim/CSAnimOutputer.java",
    "content": "/**\n * CSAnimOutputter.java\n * ChilliSource\n * Created by Ian Copland on 16/01/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.colladatocsanim;\n\nimport java.io.DataOutputStream;\nimport java.io.FileOutputStream;\n\nimport com.chilliworks.chillisource.colladatocsanim.csanim.*;\nimport com.chilliworks.chillisource.coreutils.LittleEndianWriterUtils;\nimport com.chilliworks.chillisource.coreutils.Logging;\nimport com.chilliworks.chillisource.coreutils.Quaternion;\nimport com.chilliworks.chillisource.coreutils.Vector3;\n\npublic class CSAnimOutputer \n{\n\t/**\n\t * Constants\n\t */\n\tprivate static final int ENDIANESS_CHECK_VALUE = 7777;\n\tprivate static final int VERSION_NUMBER = 4;\n\t\n\t/**\n\t * Private Data\n\t */\n\tDataOutputStream mStream;\n\t\n\t/**\n\t * Constructor\n\t */\n\tpublic CSAnimOutputer()\n\t{\n\t\t\n\t}\n\t\n\t/**\n\t * Output\n\t */\n\tpublic boolean Output(ColladaToCSAnimOptions inConversionParams, CSAnim inMoModel) throws Exception\n\t{\n\t\tboolean bSuccess = true;\n\t\t\n\t\t//try and open a new file stream. if this fails, throw a fatal error.\n\t\ttry\n\t\t{\t\n\t\t\tmStream = new DataOutputStream(new FileOutputStream(inConversionParams.m_outputFilePath));\n\t\t}\n\t\tcatch (Exception e)\n\t\t{\n\t\t\tif(mStream != null)\n\t\t\t{\n\t\t\t\tmStream.close();\n\t\t\t}\n\t\t\tLogging.logFatal(\"Failed to open output file: \" + inConversionParams.m_outputFilePath);\n\t\t}\n\t\t\n\t\t//output the file\n\t\ttry\n\t\t{\n\t\t\tif (mStream != null)\n\t\t\t{\n\t\t\t\tbSuccess = WriteHeader(inConversionParams, inMoModel);\n\t\t\t\tif (bSuccess == true)\n\t\t\t\t\tbSuccess = WriteBody(inConversionParams, inMoModel);\n\t\t\t}\n\t\t}\n\t\tcatch (Exception e)\n\t\t{\n\t\t\tmStream.close();\n\t\t\tLogging.logFatal(\"Failed to write to file: \" + inConversionParams.m_outputFilePath);\n\t\t}\n\t\t\n\t\t//close the filestream\n\t\tmStream.close();\n\n\t\treturn bSuccess;\n\t}\n\t\n\t/**\n\t * Writes the MoAnim header\n\t * @param inConversionParams\n\t * @param inAnim\n\t * @return\n\t */\n\tpublic boolean WriteHeader(ColladaToCSAnimOptions inConversionParams, CSAnim inAnim) throws Exception\n\t{\n\t\t//write endianness check and version number\n\t\tLittleEndianWriterUtils.writeUInt32(mStream, ENDIANESS_CHECK_VALUE);\n\t\tLittleEndianWriterUtils.writeUInt32(mStream, VERSION_NUMBER);\n\t\t\n\t\t//declare that there are no features\n\t\tmStream.writeByte((byte)0);\n\t\t\n\t\t//Write the number of frames and joints\n\t\tLittleEndianWriterUtils.writeUInt16(mStream, inAnim.mFrames.size());\n\t\tLittleEndianWriterUtils.writeInt16(mStream, (short)inAnim.mSkeleton.mNodeList.size());\n\t\t\n\t\t//Write the frame rate\n\t\tLittleEndianWriterUtils.writeFloat32(mStream, inAnim.mfFrameRate);\n\t\t\n\t\treturn true;\n\t}\n\t\n\t/**\n\t * Writes the MoAnim body\n\t * @param inConversionParams\n\t * @param inAnim\n\t * @return\n\t */\n\tpublic boolean WriteBody(ColladaToCSAnimOptions inConversionParams, CSAnim inAnim) throws Exception\n\t{\n\t\t//loop through each joint in each frame\n\t\tfor (int i = 0; i < inAnim.mFrames.size(); i++)\n\t\t{\n\t\t\tCSAnimFrame frame = inAnim.mFrames.get(i);\n\t\t\t\n\t\t\tfor (int j = 0; j < frame.mNodeTranslations.size(); j++)\n\t\t\t{\n\t\t\t\tVector3 translation = frame.mNodeTranslations.get(j);\n\t\t\t\tQuaternion orientation = frame.mNodeOrienations.get(j);\n\t\t\t\tVector3 scale = frame.mNodeScalings.get(j);\n\t\t\t\t\n\t\t\t\tLittleEndianWriterUtils.writeFloat32(mStream, (float)translation.getX());\n\t\t\t\tLittleEndianWriterUtils.writeFloat32(mStream, (float)translation.getY());\n\t\t\t\tLittleEndianWriterUtils.writeFloat32(mStream, (float)translation.getZ());\n\t\t\t\t\n\t\t\t\tLittleEndianWriterUtils.writeFloat32(mStream, (float)orientation.getX());\n\t\t\t\tLittleEndianWriterUtils.writeFloat32(mStream, (float)orientation.getY());\n\t\t\t\tLittleEndianWriterUtils.writeFloat32(mStream, (float)orientation.getZ());\n\t\t\t\tLittleEndianWriterUtils.writeFloat32(mStream, (float)orientation.getW());\n\n\t\t\t\tLittleEndianWriterUtils.writeFloat32(mStream, (float)scale.getX());\n\t\t\t\tLittleEndianWriterUtils.writeFloat32(mStream, (float)scale.getY());\n\t\t\t\tLittleEndianWriterUtils.writeFloat32(mStream, (float)scale.getZ());\n\t\t\t}\n\t\t}\n\n\t\treturn true;\n\t}\n\t\n}\n"
  },
  {
    "path": "Projects/Tools/ColladaToCSAnim/src/com/chilliworks/chillisource/colladatocsanim/CSAnimTransformer.java",
    "content": "/**\n * CSAnimTransformer.java\n * ChilliSource\n * Created by Ian Copland on 16/01/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.colladatocsanim;\n\nimport com.chilliworks.chillisource.colladatocsanim.csanim.*;\nimport com.chilliworks.chillisource.coreutils.Quaternion;\nimport com.chilliworks.chillisource.coreutils.Vector3;\n\n/**\n * Performs transformations on the output model data, such as coordinate system\n * conversions.\n * \n * @author Ian Copland\n *\n */\npublic final class CSAnimTransformer \n{\n\t/**\n\t * This applies all transformations requested in the input parameters, such as\n\t * swapping the handedness of the output coordinate system.\n\t *\n\t * @author Ian Copland\n\t * \n\t * @param in_conversionParams - The tools input parameters.\n\t * @param in_anim - The animation to apply transformations to.\n\t */\n\tpublic static void transform(ColladaToCSAnimOptions in_conversionParams, CSAnim in_anim)\n\t{\n\t\tif (in_conversionParams.m_swapHandedness == true)\n\t\t{\n\t\t\tswapHandedness(in_anim);\n\t\t}\n\t\t\n\t\tif (in_conversionParams.m_swapYAndZ == true)\n\t\t{\n\t\t\tswapYAndZ(in_anim);\n\t\t}\n\t}\n\t/**\n\t * Swaps the X and Y component of all data in the output animation. This allows conversion\n\t * between different coordinate systems.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param inMoModel\n\t */\n\tprivate static void swapHandedness(CSAnim in_anim)\n\t{\n\t\tfor (int i = 0; i < in_anim.mFrames.size(); i++)\n\t\t{\n\t\t\tCSAnimFrame frame = in_anim.mFrames.get(i);\n\t\t\t\n\t\t\tfor (int j = 0; j < frame.mNodeTranslations.size(); j++)\n\t\t\t{\n\t\t\t\tVector3 translation = frame.mNodeTranslations.get(j);\n\t\t\t\tVector3 newTranslation = new Vector3(translation.getX(), -translation.getY(), translation.getZ());\n\t\t\t\tframe.mNodeTranslations.set(j, newTranslation);\n\t\t\t\t\n\t\t\t\tQuaternion orientation = frame.mNodeOrienations.get(j);\n\t\t\t\tQuaternion newQuaternion = new Quaternion(orientation.getX(), -orientation.getY(), orientation.getZ(), -orientation.getW());\n\t\t\t\tframe.mNodeOrienations.set(j, newQuaternion);\n\t\t\t}\n\t\t}\n\t}\n\t/**\n\t * Swaps the X and Y component of all data in the output animation. This allows conversion\n\t * between different coordinate systems.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param inMoModel\n\t */\n\tprivate static void swapYAndZ(CSAnim in_anim)\n\t{\n\t\tfor (int i = 0; i < in_anim.mFrames.size(); i++)\n\t\t{\n\t\t\tCSAnimFrame frame = in_anim.mFrames.get(i);\n\t\t\t\n\t\t\tfor (int j = 0; j < frame.mNodeTranslations.size(); j++)\n\t\t\t{\n\t\t\t\tVector3 translation = frame.mNodeTranslations.get(j);\n\t\t\t\tVector3 newTranslation = new Vector3(translation.getX(), translation.getZ(), translation.getY());\n\t\t\t\tframe.mNodeTranslations.set(j, newTranslation);\n\t\t\t\t\n\t\t\t\tQuaternion orientation = frame.mNodeOrienations.get(j);\n\t\t\t\tVector3 vAxis = orientation.getAxis();\n\t\t\t\tdouble fAngle = orientation.getAngle();\n\t\t\t\tVector3 newAxis = new Vector3(vAxis.getX(), vAxis.getZ(), vAxis.getY());\n\t\t\t\tfAngle = -fAngle;\n\t\t\t\tQuaternion newOrientation = new Quaternion(newAxis, fAngle);\n\t\t\t\tframe.mNodeOrienations.set(j, newOrientation);\n\t\t\t\t\n\t\t\t\tVector3 scale = frame.mNodeScalings.get(j);\n\t\t\t\tVector3 newScale = new Vector3(scale.getX(), scale.getZ(), scale.getY());\n\t\t\t\tframe.mNodeScalings.set(j, newScale);\n\t\t\t}\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/ColladaToCSAnim/src/com/chilliworks/chillisource/colladatocsanim/ColladaToCSAnim.java",
    "content": "/**\n * ColladaToCSAnim.java\n * ChilliSource\n * Created by Ian Copland on 16/01/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.colladatocsanim;\n\nimport java.io.FileNotFoundException;\nimport java.util.LinkedList;\n\nimport javax.xml.parsers.SAXParser;\nimport javax.xml.parsers.SAXParserFactory;\n\nimport com.chilliworks.chillisource.colladaparserutils.ColladaParser;\nimport com.chilliworks.chillisource.colladaparserutils.colladadata.*;\nimport com.chilliworks.chillisource.colladatocsanim.csanim.*;\nimport com.chilliworks.chillisource.coreutils.Logging;\n\n/**\n * A collection of methods for converting from Collada file format to\n * CSAnim format.\n * \n * @author Ian Copland\n */\npublic final class ColladaToCSAnim \n{\n\t/**\n\t * Converts a collada file to CSAnim.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param in_options - The conversion options.\n\t */\n\tpublic static void Convert(ColladaToCSAnimOptions in_options) throws Exception\n\t{\n\t\tCollada colladaData = new Collada();\n\t\ttry\n\t\t{\n\t\t\t//create the handler\n\t\t\tColladaParser handler = new ColladaParser(colladaData);\n\t\t\t\n\t\t\t//create the parser\n\t\t\tSAXParserFactory factory = SAXParserFactory.newInstance();\n\t\t\tSAXParser saxParser = factory.newSAXParser();\n\t\t\t\n\t\t\t//start reading the collada file\n\t\t\tsaxParser.parse(in_options.m_inputFilePath, handler);\n\t\t}\n\t\tcatch (FileNotFoundException e)\n\t\t{\n\t\t\tLogging.logFatal(\"Could not find file: \" + in_options.m_inputFilePath);\n\t\t}\n\t\tcatch (Exception e)\n\t\t{\n\t\t\tString strFullStackTrace = new String();\n\t\t\tfor (StackTraceElement stackTrace: e.getStackTrace())\n\t\t\t\tstrFullStackTrace += stackTrace.toString() + \"\\n\";\n\t\t\tLogging.logFatal(\"Exception occurred while parsing the collada file. The following is the exception error message:\\n-\\n \" + strFullStackTrace + \"-\");\n\t\t}\n\t\t\n\t\t//get the nodes to be exported\n\t\tLinkedList<String> nodes = new LinkedList<String>();\n\t\tfor (ColladaNode node : colladaData.mLibraryVisualScenes.get(colladaData.mScene.mInstanceVisualScene.mstrUrl.substring(1)).mRootNodes.values())\n\t\t{\n\t\t\tnodes.add(node.mstrId);\n\t\t}\n\t\t\n\t\t//create the new animation file\n\t\tCSAnim anim = new CSAnim();\n\t\t\n\t\t//build the skeleton for reference\n\t\tSkeletonBuilder.BuildSkeleton(nodes, colladaData, anim);\n\t\t\n\t\t//build the animation data\n\t\tCSAnimConverter converter = new CSAnimConverter(); \n\t\tconverter.ConvertToMoAnimFormat(nodes, colladaData, anim);\n\t\t\n\t\t//Modify the data to the intended output format\n\t\tCSAnimTransformer.transform(in_options, anim);\n\t\t\t\n\t\t//output info on the MoAnim\n\t\toutputInfoOnMoAnim(anim);\n\n\t\t//output MoStatic file\n\t\tCSAnimOutputer outputer = new CSAnimOutputer();\n\t\t\n\t\tif (outputer.Output(in_options, anim) == true)\n\t\t{\n\t\t\t//output info on output\n\t\t\toutputInfoOnOutput(in_options);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tLogging.logError(\"Output failed!\");\n\t\t}\n\t}\n\t\n\t/**\n\t * Prints info on the output animation data.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param in_animation - The animation.\n\t */\n\tprivate static void outputInfoOnMoAnim(CSAnim in_animation)\n\t{\n\t\tLogging.logVerbose(\"MoAnim Data Generated\");\n\t\tLogging.logVerbose(\" Frame rate: \" + in_animation.mfFrameRate);\n\t\tLogging.logVerbose(\" Number of frames: \" + in_animation.mFrames.size());\n\t\tLogging.logVerbose(\" Skeleton\");\n\t\tLogging.logVerbose(\"  Skeleton Nodes: \" + in_animation.mSkeleton.mNodeList.size());\n\t}\n\t\n\t/**\n\t * output data on the output file.\n\t *\n\t * @author Ian Copland\n\t * \n\t * @param in_options - The output options.\n\t */\n\tprivate static void outputInfoOnOutput(ColladaToCSAnimOptions in_options)\n\t{\n\t\tLogging.logVerbose(\"Successfully created \" + in_options.m_outputFilePath);\n\t\tLogging.logVerbose(\" Transforms\");\n\t\tLogging.logVerbose(\"  Swap Handedness: \" + Boolean.toString(in_options.m_swapHandedness));\n\t\tLogging.logVerbose(\"  Swap Y and Z: \" + Boolean.toString(in_options.m_swapYAndZ));\n\t\tLogging.logVerbose(\" \");\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/ColladaToCSAnim/src/com/chilliworks/chillisource/colladatocsanim/ColladaToCSAnimOptions.java",
    "content": "/**\n * ColladaToCSAnimOptions.java\n * ChilliSource\n * Created by Ian Copland on 16/01/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.colladatocsanim;\n\n/**\n * A container for the options for the Collada To CSAnim tool.\n * \n * @author Ian Copland\n */\npublic final class ColladaToCSAnimOptions \n{\n\tpublic String m_inputFilePath = new String();\n\tpublic String m_outputFilePath = new String();\n\tpublic boolean m_swapHandedness = false;\n\tpublic boolean m_swapYAndZ = false;\n}\n"
  },
  {
    "path": "Projects/Tools/ColladaToCSAnim/src/com/chilliworks/chillisource/colladatocsanim/Main.java",
    "content": "/**\n * Main.java\n * ChilliSource\n * Created by Ian Copland on 16/01/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.colladatocsanim;\n\nimport com.chilliworks.chillisource.coreutils.Logging;\nimport com.chilliworks.chillisource.coreutils.StringUtils;\nimport com.chilliworks.chillisource.coreutils.Logging.LoggingLevel;\n\n/**\n * The entry point into the application.\n * \n * @author Ian Copland\n */\npublic final class Main \n{\n\tprivate static final String k_paramNameInput = \"--input\";\n\tprivate static final String k_paramNameOutput = \"--output\";\n\tprivate static final String k_paramNameSwapHandedness = \"--swaphandedness\";\n\tprivate static final String k_paramNameSwapYAndZ = \"--swapyandz\";\n\tprivate static final String k_paramNameHelp = \"--help\";\n\tprivate static final String k_shortParamNameInput = \"-i\";\n\tprivate static final String k_shortParamNameOutput = \"-o\";\n\tprivate static final String k_shortParamNameSwapHandedness = \"-sh\";\n\tprivate static final String k_shortParamNameSwapYAndZ = \"-sy\";\n\tprivate static final String k_shortParamNameHelp = \"-h\";\n\n\t/**\n\t * Entry point for the application.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param The input arguments.\n\t */\n\tpublic static void main(String[] in_args) throws Exception \n\t{\n\t\t//setup the logger.\n\t\tString[] arguments = Logging.start(in_args);\n\t\t\n\t\t//check the number of arguments make sense.\n\t\tif (arguments.length == 0)\n\t\t{\n\t\t\tprintHelpText();\n\t\t\treturn;\n\t\t}\n\t\t\n\t\t//gather up commands\n\t\tColladaToCSAnimOptions params = new ColladaToCSAnimOptions();\n\t\tfor (int i = 0; i < arguments.length; ++i)\n\t\t{\n\t\t\t//input\n\t\t\tif (arguments[i].equalsIgnoreCase(k_paramNameInput) == true || arguments[i].equalsIgnoreCase(k_shortParamNameInput) == true)\n\t\t\t{\n\t\t\t\tif (i+1 < arguments.length)\n\t\t\t\t\tparams.m_inputFilePath = StringUtils.standardiseFilePath(arguments[i+1]);\n\t\t\t\telse\n\t\t\t\t\tLogging.logFatal(\"No input file provided!\");\n\t\t\t\ti++;\n\t\t\t}\n\t\t\t\n\t\t\t//output\n\t\t\telse if (arguments[i].equalsIgnoreCase(k_paramNameOutput) == true || arguments[i].equalsIgnoreCase(k_shortParamNameOutput) == true)\n\t\t\t{\n\t\t\t\tif (i+1 < arguments.length)\n\t\t\t\t\tparams.m_outputFilePath = StringUtils.standardiseFilePath(arguments[i+1]);\n\t\t\t\telse\n\t\t\t\t\tLogging.logFatal(\"No output file provided!\");\n\t\t\t\ti++;\n\t\t\t}\n\t\t\t\n\t\t\t//swap handedness\n\t\t\telse if (arguments[i].equalsIgnoreCase(k_paramNameSwapHandedness) == true || arguments[i].equalsIgnoreCase(k_shortParamNameSwapHandedness) == true)\n\t\t\t{\n\t\t\t\tparams.m_swapHandedness = true;\n\t\t\t}\n\t\t\t\n\t\t\t//swap y and z\n\t\t\telse if (arguments[i].equalsIgnoreCase(k_paramNameSwapYAndZ) == true || arguments[i].equalsIgnoreCase(k_shortParamNameSwapYAndZ) == true)\n\t\t\t{\n\t\t\t\tparams.m_swapYAndZ = true;\n\t\t\t}\n\t\t\t\n\t\t\t//help\n\t\t\telse if (arguments[i].equalsIgnoreCase(k_paramNameHelp) == true || arguments[i].equalsIgnoreCase(k_shortParamNameHelp) == true)\n\t\t\t{\n\t\t\t\tprintHelpText();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t\n\t\t\t//Failure\n\t\t\telse\n\t\t\t{\n\t\t\t\tLogging.logFatal(\"Invalid parameter found: \" + arguments[i]);\n\t\t\t}\n\t\t}\n\t\t\n\t\tif (params.m_inputFilePath.length() == 0 || params.m_outputFilePath.length() == 0)\n\t\t{\n\t\t\tLogging.logFatal(\"Must provide an input and output file path.\");\n\t\t}\n\t\t\n\t\tColladaToCSAnim.Convert(params);\n\t\t\n\t\tLogging.finish();\n\t}\n\t/**\n\t * Prints out instructions on how to use this tool. This will print regardless\n\t * of the logging level.\n\t * \n\t * @author Ian Copland\n\t */\n\tpublic static void printHelpText()\n\t{\n\t\tLogging.setLoggingLevel(LoggingLevel.VERBOSE);\n\t\tLogging.logVerbose(\"Usage: java -jar ColladaToCSAnim.jar \" + k_paramNameInput + \" <file path> \" + k_paramNameOutput + \" <file path> [\" + k_paramNameSwapHandedness + \"] [\" + k_paramNameSwapYAndZ + \"] [\" + k_paramNameHelp + \"] [\" + Logging.PARAM_LOGGING_LEVEL + \" <level>]\");\n\t\tLogging.logVerbose(\"Parameters:\");\n\t\tLogging.logVerbose(\" \" + k_paramNameInput + \"(\" + k_shortParamNameInput + \"): The input filename.\");\n\t\tLogging.logVerbose(\" \" + k_paramNameOutput + \"(\" + k_shortParamNameOutput + \"): The output filename.\");\n\t\tLogging.logVerbose(\" \" + k_paramNameSwapHandedness + \"(\" + k_shortParamNameSwapHandedness + \"): [Optional] Swaps the handedness of the output coordinate system.\");\n\t\tLogging.logVerbose(\" \" + k_paramNameSwapYAndZ + \"(\" + k_shortParamNameSwapYAndZ + \"): [Optional] Swaps the Y and Z of the output coordinate system.\");\n\t\tLogging.logVerbose(\" \" + Logging.PARAM_LOGGING_LEVEL + \"(\" + Logging.SHORT_PARAM_LOGGING_LEVEL + \"): [Optional] The level of messages to log.\");\n\t\tLogging.logVerbose(\" \" + k_paramNameHelp + \"(\" + k_shortParamNameHelp + \"): [Optional] Display this help message.\");\n\t\tLogging.logVerbose(\"Logging Levels:\");\n\t\tLogging.logVerbose(\" \" + Logging.LOGGING_LEVEL_NONE + \": No logging.\");\n\t\tLogging.logVerbose(\" \" + Logging.LOGGING_LEVEL_FATAL + \": Only log fatal errors.\");\n\t\tLogging.logVerbose(\" \" + Logging.LOGGING_LEVEL_ERROR + \": Only log errors.\");\n\t\tLogging.logVerbose(\" \" + Logging.LOGGING_LEVEL_WARNING + \": Log errors and warnings.\");\n\t\tLogging.logVerbose(\" \" + Logging.LOGGING_LEVEL_VERBOSE + \": Log all messages.\");\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/ColladaToCSAnim/src/com/chilliworks/chillisource/colladatocsanim/SkeletonBuilder.java",
    "content": "/**\n * SkeletonBuilder.java\n * ChilliSource\n * Created by Ian Copland on 16/01/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.colladatocsanim;\n\nimport java.util.Collections;\nimport java.util.LinkedList;\n\nimport com.chilliworks.chillisource.colladaparserutils.colladadata.*;\nimport com.chilliworks.chillisource.colladaparserutils.colladadata.ColladaNode.COLLADA_NODE_TYPE;\nimport com.chilliworks.chillisource.colladatocsanim.csanim.*;\nimport com.chilliworks.chillisource.coreutils.Logging;\n\npublic class SkeletonBuilder \n{\n\t//-------------------------------------------------------------------\n\t/// BuildSkeleton\n\t///\n\t/// Converts the input collections of data from the collada file into\n\t/// something useable for outputing in MoAnim format.\n\t//-------------------------------------------------------------------\n\tstatic public void BuildSkeleton(LinkedList<String> inNodesToExport, Collada inCollada, CSAnim inMoAnim)\n\t{\n\t\t//build the skeleton\n\t\tfor (ColladaNode node : inCollada.mLibraryVisualScenes.get(inCollada.mScene.mInstanceVisualScene.mstrUrl.substring(1)).mRootNodes.values())\n\t\t{\n\t\t\tTryBuildSkeletonForNode(inCollada, inMoAnim, node, inNodesToExport, false);\n\t\t}\n\t}\n\t//-------------------------------------------------------------------\n\t/// TryBuildSkeletonForNode\n\t///\n\t/// Builds the model data for a node if its parent was build, or if \n\t/// its id is in the list of nodes to export.\n\t//-------------------------------------------------------------------\n\tstatic private void TryBuildSkeletonForNode(Collada inCollada, CSAnim inAnim, ColladaNode inNode,LinkedList<String> inNodesToExport, boolean inbParentExported)\n\t{\n\t\tboolean bShouldExport = inbParentExported;\n\t\t\n\t\t//if the parent was not exported, check and see if this node should be\n\t\tif (bShouldExport == false)\n\t\t{\n\t\t\tfor (String nodeName: inNodesToExport)\n\t\t\t{\n\t\t\t\tif (nodeName.equalsIgnoreCase(inNode.mstrId) == true)\n\t\t\t\t{\n\t\t\t\t\tbShouldExport = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\t//if this should be exported, then see if it can be\n\t\tif (bShouldExport == true && inNode.meType == ColladaNode.COLLADA_NODE_TYPE.CONTROLLER)\n\t\t{\n\t\t\tif (inNode.mInstanceController.m_skeletons.size() == 0)\n\t\t\t{\n\t\t\t\tLogging.logFatal(\"Cannot create animation becuase the model has no skeleton.\");\n\t\t\t}\n\t\t\t\n\t\t\tif (inNode.mInstanceController.m_skeletons.size() > 1)\n\t\t\t{\n\t\t\t\tLogging.logFatal(\"Cannot create animation becuase the model has more than one skeleton.\");\n\t\t\t}\n\t\t\t\n\t\t\tString skeletonName = inNode.mInstanceController.m_skeletons.get(0).mstrValue.substring(1);\n\n\t\t\t//export this node if possible\n\t\t\tif (skeletonName.length() > 0)\n\t\t\t{\n\t\t\t\t\tTryBuildSkeleton(new LinkedList<ColladaNode>(\n\t\t\t\t\t\t\tinCollada.mLibraryVisualScenes.get(inCollada.mScene.mInstanceVisualScene.mstrUrl.substring(1)).mRootNodes.values()),\n\t\t\t\t\t\t\tskeletonName, inAnim);\n\t\t\t}\n\t\t\n\t\t}\n\t\t\n\t\t//try children\n\t\tfor (ColladaNode node: inNode.mChildNodes.values())\n\t\t{\n\t\t\tTryBuildSkeletonForNode(inCollada, inAnim, node, inNodesToExport, bShouldExport);\n\t\t}\n\t}\n\t//-------------------------------------------------------------------\n\t/// Try Build Skeleton\n\t///\n\t/// Tries to build the skeleton if it has not already been built. \n\t/// If it has already been built, this then confirms that it is using \n\t/// the same skeleton.\n\t//-------------------------------------------------------------------\n\tstatic public void TryBuildSkeleton(LinkedList<ColladaNode> inNodes, String instrSkeletonName, CSAnim inModel)\n\t{\n\t\tif (inModel.mSkeleton.mbLocked == false)\n\t\t{\n\t\t\tBuildSkeleton(inNodes, instrSkeletonName, inModel);\n\t\t\tOrderSkeleton(inModel);\n\t\t\tinModel.mSkeleton.mbLocked = true;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tCSAnim testModel = new CSAnim();\n\t\t\tBuildSkeleton(inNodes, instrSkeletonName, testModel);\n\t\t\tOrderSkeleton(testModel);\n\t\t\t\n\t\t\tif (CompareSkeletons(inModel.mSkeleton, testModel.mSkeleton) == false)\n\t\t\t{\n\t\t\t\tString strRootNode1 = \"\", strRootNode2 = \"\";\n\t\t\t\tif (inModel.mSkeleton.mNodeList.size() > 0)\n\t\t\t\t\tstrRootNode1 = inModel.mSkeleton.mNodeList.get(0).mstrName;\n\t\t\t\tif (testModel.mSkeleton.mNodeList.size() > 0)\n\t\t\t\t\tstrRootNode2 = testModel.mSkeleton.mNodeList.get(0).mstrName;\n\t\t\t\tLogging.logFatal(\"A second skeleton has been found. All meshes must be attached to the same skeleton. Attaching a mesh to a subset of the skeleton counts as a different skeleton. The two different skeleton root nodes are: '\" + strRootNode1 + \"' and '\" + strRootNode2 + \"'\");\n\t\t\t}\n\t\t}\n\t}\n\t//-------------------------------------------------------------------\n\t/// Compare Skeletons\n\t///\n\t/// Compares the two skeletons to see if all relevent data in them \n\t/// is the same.\n\t//-------------------------------------------------------------------\n\tstatic private boolean CompareSkeletons(CSAnimSkeleton inSkeleton1, CSAnimSkeleton inSkeleton2)\n\t{\n\t\t//check the list counts are the same\n\t\tif (inSkeleton1.mNodeList.size() != inSkeleton2.mNodeList.size())\n\t\t\treturn false;\n\t\t\n\t\t//check all the skeleton nodes\n\t\tfor (int i = 0; i < inSkeleton1.mNodeList.size(); i++)\n\t\t{\n\t\t\tCSAnimSkeletonNode node1 = inSkeleton1.mNodeList.get(i);\n\t\t\tCSAnimSkeletonNode node2 = inSkeleton2.mNodeList.get(i);\n\t\t\t\n\t\t\tif (node1.mstrName.equals(node2.mstrName) == false)\n\t\t\t\treturn false;\n\t\t\tif (node1.mdwParentNodeIndex != node2.mdwParentNodeIndex)\n\t\t\t\treturn false;\n\t\t}\n\t\t\n\t\treturn true;\n\t}\n\t//-------------------------------------------------------------------\n\t/// Build Skeleton\n\t///\n\t/// builds to the skeleton.\n\t//-------------------------------------------------------------------\n\tstatic private boolean BuildSkeleton(LinkedList<ColladaNode> inNodes, String instrSkeletonName, CSAnim inModel)\n\t{\n\t\t//find the \"root\" node that we are using\n\t\tfor (ColladaNode node : inNodes)\n\t\t{\n\t\t\tif (node.mstrId.equals(instrSkeletonName))\n\t\t\t{\n\t\t\t\t//build skeleton\n\t\t\t\tAddToSkeleton(node, null, inModel);\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tif (BuildSkeleton(new LinkedList<ColladaNode>(node.mChildNodes.values()), instrSkeletonName, inModel) == true)\n\t\t\t\t{\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\treturn false;\n\t}\n\t//-------------------------------------------------------------------\n\t/// Add To Skeleton\n\t///\n\t/// Adds a node tree to the skeleton.\n\t//-------------------------------------------------------------------\n\tstatic private void AddToSkeleton(ColladaNode inNode, ColladaNode inParent, CSAnim inModel)\n\t{\n\t\t//if its a skeleton node, then add it to the skeleton node list\n\t\tif (inNode.meType == COLLADA_NODE_TYPE.JOINT || inNode.meType == COLLADA_NODE_TYPE.BASE)\n\t\t{\n\t\t\tTryAddSkeletonNode(inNode, inParent, inModel);\n\t\t\tfor (ColladaNode node: inNode.mChildNodes.values())\n\t\t\t{\n\t\t\t\tAddToSkeleton(node, inNode, inModel);\n\t\t\t}\n\t\t}\n\t}\n\t//-------------------------------------------------------------------\n\t/// Try Add Skeleton Node\n\t///\n\t/// Tries to add a joint to the skeleton.\n\t//-------------------------------------------------------------------\n\tstatic private void TryAddSkeletonNode(ColladaNode inNode, ColladaNode inParent, CSAnim inModel)\n\t{\n\t\t//check and see if this node already exists\n\t\tfor (int i = 0; i < inModel.mSkeleton.mNodeList.size(); i++)\n\t\t{\n\t\t\tCSAnimSkeletonNode node = inModel.mSkeleton.mNodeList.get(i);\n\t\t\tif (node.mstrId.equalsIgnoreCase(inNode.mstrId))\n\t\t\t{\n\t\t\t\t//if the node does already exist, then make sure the parent is correct\n\t\t\t\tif (node.mstrParentId.length() == 0 && inParent != null)\n\t\t\t\t{\n\t\t\t\t\tnode.mstrParentId = inParent.mstrId;\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\t\n\t\t//create a new skeleton node\n\t\tCSAnimSkeletonNode newSkeletonNode = new CSAnimSkeletonNode();\n\t\tnewSkeletonNode.mstrName = inNode.mstrName;\n\t\tnewSkeletonNode.mstrId = inNode.mstrId;\n\t\tif (inParent != null)\n\t\t{\n\t\t\tnewSkeletonNode.mstrParentId = inParent.mstrId;\n\t\t}\n\t\t\n\t\tnewSkeletonNode.mInitialPoseMatrix = inNode.m_transform;\n\t\t\n\t\t//add the joint\n\t\tinModel.mSkeleton.mNodeList.add(newSkeletonNode);\n\t}\n\t//-------------------------------------------------------------------\n\t/// Order Skeleton\n\t///\n\t/// Orders the skeleton based on the the id.\n\t//-------------------------------------------------------------------\n\tstatic private void OrderSkeleton(CSAnim inModel)\n\t{\n\t\tCollections.sort(inModel.mSkeleton.mNodeList, new SkeletonNodeComparator());\n\t\t\n\t\t//iterator the list and get the parent indices\n\t\tfor (CSAnimSkeletonNode node : inModel.mSkeleton.mNodeList)\n\t\t{\n\t\t\tif(node.mstrParentId.length() > 0)\n\t\t\t{\n\t\t\t\tnode.mdwParentNodeIndex = GetIndexOfSkeletonNodeById(inModel, node.mstrParentId);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tnode.mdwParentNodeIndex = -1;\n\t\t\t}\n\t\t}\n\t}\n\t//-------------------------------------------------------------------\n\t/// Get Index Of Skeleton Node By Id\n\t///\n\t/// @return The index of the skeleton node with the passed in id.\n\t//-------------------------------------------------------------------\n\tstatic public int GetIndexOfSkeletonNodeById(CSAnim inModel, String instrId)\n\t{\n\t\tfor (int i = 0; i < inModel.mSkeleton.mNodeList.size(); i++)\n\t\t{\n\t\t\tCSAnimSkeletonNode node = inModel.mSkeleton.mNodeList.get(i);\n\t\t\tif (node.mstrId.equalsIgnoreCase(instrId))\n\t\t\t{\n\t\t\t\treturn i;\n\t\t\t}\n\t\t}\n\t\t\n\t\tLogging.logError(\"Cannot find skeleton node with ID: \" + instrId);\n\t\treturn -1;\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/ColladaToCSAnim/src/com/chilliworks/chillisource/colladatocsanim/SkeletonNodeComparator.java",
    "content": "/**\n * SkeletonNodeComparator.java\n * ChilliSource\n * Created by Ian Copland on 16/01/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.colladatocsanim;\n\nimport java.util.Comparator;\n\nimport com.chilliworks.chillisource.colladatocsanim.csanim.CSAnimSkeletonNode;\n\npublic class SkeletonNodeComparator implements Comparator<CSAnimSkeletonNode>\n{\n\t//-------------------------------------------------------------------\n\t/// Compare\n\t///\n\t/// Compares two MoModelSkeletonNode\n\t//-------------------------------------------------------------------\n\tpublic int compare(CSAnimSkeletonNode inJoint1, CSAnimSkeletonNode inJoint2)\n\t{\n\t\t\n\t\tif (inJoint1.mstrParentId.compareTo(inJoint2.mstrParentId) > 0)\n\t\t\treturn 1;\n\t\telse if (inJoint1.mstrParentId.compareTo(inJoint2.mstrParentId) < 0)\n\t\t\treturn -1;\n\t\telse\n\t\t\treturn 0;\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/ColladaToCSAnim/src/com/chilliworks/chillisource/colladatocsanim/csanim/CSAnim.java",
    "content": "/**\n * CSAnim.java\n * ChilliSource\n * Created by Ian Copland on 16/01/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.colladatocsanim.csanim;\n\nimport java.util.LinkedList;\n\npublic class CSAnim\n{\n\t/**\n\t * Private data\n\t */\n\tpublic CSAnimSkeleton mSkeleton;\n\tpublic LinkedList<CSAnimFrame> mFrames;\n\tpublic float mfFrameRate;\n\t\n\t/**\n\t * Constructor\n\t */\n\tpublic CSAnim()\n\t{\n\t\tmfFrameRate = 0.0f;\n\t\tmSkeleton = new CSAnimSkeleton();\n\t\tmFrames = new LinkedList<CSAnimFrame>();\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/ColladaToCSAnim/src/com/chilliworks/chillisource/colladatocsanim/csanim/CSAnimFrame.java",
    "content": "/**\n * CSAnim.java\n * ChilliSource\n * Created by Ian Copland on 16/01/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.colladatocsanim.csanim;\n\nimport java.util.LinkedList;\n\nimport com.chilliworks.chillisource.coreutils.Quaternion;\nimport com.chilliworks.chillisource.coreutils.Vector3;\n\npublic class CSAnimFrame \n{\n\tpublic LinkedList<Vector3> mNodeTranslations;\n\tpublic LinkedList<Quaternion> mNodeOrienations;\n\tpublic LinkedList<Vector3> mNodeScalings;\n\t\n\tpublic CSAnimFrame()\n\t{\n\t\tmNodeOrienations = new LinkedList<Quaternion>();\n\t\tmNodeTranslations = new LinkedList<Vector3>();\n\t\tmNodeScalings = new LinkedList<Vector3>();\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/ColladaToCSAnim/src/com/chilliworks/chillisource/colladatocsanim/csanim/CSAnimSkeleton.java",
    "content": "/**\n * CSAnimSkeleton.java\n * ChilliSource\n * Created by Ian Copland on 16/01/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.colladatocsanim.csanim;\n\nimport java.util.LinkedList;\n\npublic class CSAnimSkeleton \n{\n\tpublic LinkedList<CSAnimSkeletonNode> mNodeList;\n\tpublic boolean mbLocked;\n\t\n\tpublic CSAnimSkeleton()\n\t{\n\t\tmNodeList = new LinkedList<CSAnimSkeletonNode>();\n\t\tmbLocked = false;\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/ColladaToCSAnim/src/com/chilliworks/chillisource/colladatocsanim/csanim/CSAnimSkeletonNode.java",
    "content": "/**\n * CSAnimSkeletonNode.java\n * ChilliSource\n * Created by Ian Copland on 16/01/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.colladatocsanim.csanim;\n\nimport com.chilliworks.chillisource.coreutils.Matrix4;\n\npublic class CSAnimSkeletonNode \n{\n\tpublic String mstrId;\n\tpublic String mstrName;\n\tpublic String mstrParentId;\n\tpublic int mdwParentNodeIndex;\n\tpublic Matrix4 mInitialPoseMatrix;\n\t\n\tpublic CSAnimSkeletonNode()\n\t{\n\t\tmstrId = new String();\n\t\tmstrName = new String();\n\t\tmstrParentId = new String();\n\t\tmdwParentNodeIndex = -1; \n\t\tmInitialPoseMatrix = Matrix4.IDENTITY;\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/ColladaToCSModel/.classpath",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<classpath>\n\t<classpathentry kind=\"src\" path=\"src\"/>\n\t<classpathentry kind=\"con\" path=\"org.eclipse.jdt.launching.JRE_CONTAINER\"/>\n\t<classpathentry combineaccessrules=\"false\" kind=\"src\" path=\"/ColladaParserUtils\"/>\n\t<classpathentry combineaccessrules=\"false\" kind=\"src\" path=\"/CoreUtils\"/>\n\t<classpathentry kind=\"output\" path=\"bin\"/>\n</classpath>\n"
  },
  {
    "path": "Projects/Tools/ColladaToCSModel/.project",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<projectDescription>\n\t<name>ColladaToCSModel</name>\n\t<comment></comment>\n\t<projects>\n\t</projects>\n\t<buildSpec>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.jdt.core.javabuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t</buildSpec>\n\t<natures>\n\t\t<nature>org.eclipse.jdt.core.javanature</nature>\n\t</natures>\n</projectDescription>\n"
  },
  {
    "path": "Projects/Tools/ColladaToCSModel/Manifest/Manifest.txt",
    "content": "Manifest-Version: 1.0\r\nMain-Class: com.chillisource.colladatocsmodel.Main\r\n\r\n"
  },
  {
    "path": "Projects/Tools/ColladaToCSModel/src/com/chilliworks/chillisource/colladatocsmodel/CSModelConverter.java",
    "content": "/**\n * CSModelConverter.java\n * ChilliSource\n * Created by Ian Copland on 15/01/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.colladatocsmodel;\n\nimport java.util.ArrayList;\nimport java.util.Hashtable;\nimport java.util.LinkedList;\nimport java.util.Stack;\n\nimport com.chilliworks.chillisource.colladaparserutils.colladadata.*;\nimport com.chilliworks.chillisource.colladaparserutils.colladadata.ColladaGeometry.COLLADA_GEOMETRY_TYPE;\nimport com.chilliworks.chillisource.colladatocsmodel.csmodel.*;\nimport com.chilliworks.chillisource.coreutils.*;\n\npublic class CSModelConverter \n{\n\t//-------------------------------------------------------------------\n\t/// Index Type\n\t//-------------------------------------------------------------------\n\tenum MS_INDEX_TYPE\n\t{\n\t\tNONE,\n\t\tPOSITION,\n\t\tNORMAL,\n\t\tTEXCOORD,\n\t\tCOLOUR,\n\t\tWEIGHT,\n\t\tJOINT_INDEX\n\t}\n\t//-------------------------------------------------------------------\n\t/// Private Member Data\n\t//-------------------------------------------------------------------\n\tStack<Matrix4> mMatrixStack;\n\tColladaToCSModelOptions mConversionParams;\n\tUserPropertiesParser mPropertiesParser;\n\t//-------------------------------------------------------------------\n\t/// Constructor\n\t//-------------------------------------------------------------------\n\tpublic CSModelConverter()\n\t{\n\t\tmMatrixStack = new Stack<Matrix4>();\n\t\tmMatrixStack.push(Matrix4.IDENTITY);\n\t\tmPropertiesParser = new UserPropertiesParser();\n\t}\n\t//-------------------------------------------------------------------\n\t/// Convert To MoModel Format\n\t///\n\t/// Converts the input collections of data from the Collada file into \n\t/// something usable for outputting in MoModel format.\n\t//-------------------------------------------------------------------\n\tpublic CSModel ConvertToMoModelFormat(LinkedList<String> inNodesToExport, Collada inCollada, ColladaToCSModelOptions inParams)\n\t{\n\t\tmConversionParams = inParams;\n\t\tCSModel model = new CSModel();\n\t\t\n\t\t//build the model data\n\t\tfor (ColladaNode node : inCollada.mLibraryVisualScenes.get(inCollada.mScene.mInstanceVisualScene.mstrUrl.substring(1)).mRootNodes.values())\n\t\t{\n\t\t\tTryBuildModelDataForNode(inCollada, model, node, inNodesToExport, false);\n\t\t}\n\t\t\n\t\t//set the model overall hit box\n\t\t\n\t\tfor (CSModelMesh mesh: model.mMeshTable.values())\n\t\t{\n\t\t\tif (mesh.mvMin.getX() < model.mvMin.getX())\n\t\t\t\tmodel.mvMin = new Vector3(mesh.mvMin.getX(), model.mvMin.getY(), model.mvMin.getZ());\n\t\t\tif (mesh.mvMin.getY() < model.mvMin.getY())\n\t\t\t\tmodel.mvMin = new Vector3(model.mvMin.getX(), mesh.mvMin.getY(), model.mvMin.getZ());\n\t\t\tif (mesh.mvMin.getZ() < model.mvMin.getZ())\n\t\t\t\tmodel.mvMin = new Vector3(model.mvMin.getX(), model.mvMin.getY(), mesh.mvMin.getZ());\n\t\t\t\n\t\t\tif (mesh.mvMax.getX() > model.mvMax.getX())\n\t\t\t\tmodel.mvMax = new Vector3(mesh.mvMax.getX(), model.mvMax.getY(), model.mvMax.getZ());\n\t\t\tif (mesh.mvMax.getY() > model.mvMax.getY())\n\t\t\t\tmodel.mvMax = new Vector3(model.mvMax.getX(), mesh.mvMax.getY(), model.mvMax.getZ());\n\t\t\tif (mesh.mvMax.getZ() > model.mvMax.getZ())\n\t\t\t\tmodel.mvMax = new Vector3(model.mvMax.getX(), model.mvMax.getY(), mesh.mvMax.getZ());\n\t\t}\n\t\t\n\t\treturn model;\n\t}\n\t//-------------------------------------------------------------------\n\t/// Set Texture\n\t///\n\t/// Sets the texture for the MoStatic mesh\n\t//-------------------------------------------------------------------\n\tprivate void SetTexture(ColladaMaterial inMaterial, Collada inCollada, CSModelMesh outMesh)\n\t{\n\t\tif(inMaterial == null)\n\t\t\treturn;\n\t\t\n\t\t//get the image from the material\n\t\tString effectName = inMaterial.mInstanceEffect.mstrUrl.substring(1);\n\t\tColladaEffect effect = inCollada.mLibraryEffects.get(effectName);\n\t\tString samplerName = effect.mProfileCommon.mTechnique.mBlinnAndPhong.mDiffuse.mTexture.mstrTexture;\n\t\t\n\t\tif (samplerName.length() == 0)\n\t\t\treturn;\n\t\t\n\t\t//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\t\t//                        HACK ALERT!\n\t\t//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\t\t// The FBX Collada exporter that 3DS Max uses is not fully\n\t\t// complient to the collada specification. The way it handles\n\t\t// diffuse textures in the technique is incorrect, refering\n\t\t// directly to the image, rather than a sampler2D that uses\n\t\t// the image. In order to support this we have added a hack \n\t\t// that checks if the collada file was created using this \n\t\t// exporter and bypasses the sampler2D if it is.\n\t\t//\n\t\t// If the FBX Collada exporter is no longer needed, please remove\n\t\t// this hack.\n\t\t\n\t\tColladaImage image;\n\t\tif (inCollada.mAsset.mContributor.mAuthoringTool.mstrName.equals(\"FBX COLLADA exporter\") == false)\n\t\t{\n\t\t\tString surfaceName = effect.mProfileCommon.mNewParams.get(samplerName).mSampler2D.mSource.mstrContents;\n\t\t\tString imageName = effect.mProfileCommon.mNewParams.get(surfaceName).mSurface.mInitFrom.mstrValue;\n\t\t\timage = inCollada.mLibraryImages.get(imageName);\n\t\t}\n\t\telse\n\t\t{\n\t\t\timage = inCollada.mLibraryImages.get(samplerName);\n\t\t}\n\t\t\n\t\t//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\t\t//                        END HACK\n\t\t//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\t\t\n\t\tif (image != null)\n\t\t{\n\t\t\t//just take the first texture\n\t\t\tString strTextureFullpath = image.mInitFrom.mstrValue;\n\t\t\t\n\t\t\t//convert all \"\\\" to \"/\"\n\t\t\tstrTextureFullpath = strTextureFullpath.replace(\"\\\\\", \"/\");\n\t\t\t\n\t\t\t//get rid of the directory paths\n\t\t\tString[] strBrokenUpTexture = strTextureFullpath.split(\"/\");\n\t\t\t\n\t\t\tif (strBrokenUpTexture.length > 0)\n\t\t\t{\n\t\t\t\t//set the texture!\n\t\t\t\toutMesh.mstrTextureName = strBrokenUpTexture[strBrokenUpTexture.length - 1];\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\toutMesh.mstrTextureName = strTextureFullpath;\n\t\t\t}\n\t\t}\n\t}\n\t//-------------------------------------------------------------------\n\t/// Try Build Model Data For Node\n\t///\n\t/// Builds the model data for a node if its parent was build, or if its \n\t/// id is in the list of nodes to export.\n\t//-------------------------------------------------------------------\n\tprivate void TryBuildModelDataForNode(Collada inCollada, CSModel inModel, ColladaNode inNode,LinkedList<String> inNodesToExport, boolean inbParentExported)\n\t{\n\t\tboolean bShouldExport = inbParentExported;\n\t\t\n\t\t//calculate the world position of this node.\n\t\tMatrix4 localMat = inNode.m_transform;\n\t\t\n\t\tMatrix4 worldMat = Matrix4.multiply(localMat, mMatrixStack.peek());\n\t\tmMatrixStack.push(worldMat);\n\t\t\n\t\t//if the parent was not exported, check and see if this node should be\n\t\tif (bShouldExport == false)\n\t\t{\n\t\t\tfor (String nodeName: inNodesToExport)\n\t\t\t{\n\t\t\t\tif (nodeName.equalsIgnoreCase(inNode.mstrId) == true)\n\t\t\t\t{\n\t\t\t\t\tbShouldExport = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\t//if this should be exported, then see if it can be\n\t\tif (bShouldExport == true && \n\t\t\tinNode.meType == ColladaNode.COLLADA_NODE_TYPE.CONTROLLER || inNode.meType == ColladaNode.COLLADA_NODE_TYPE.GEOMETRY)\n\t\t{\n\t\t\tboolean bCanExport = false;\n\t\t\tString skeletonName = new String();\n\t\t\tString geomName = new String();\n\t\t\tHashtable<String, String> materialNameMap = new Hashtable<String, String>();\n\t\t\tString controllerName = new String();\n\t\t\t\n\t\t\tif (inNode.meType == ColladaNode.COLLADA_NODE_TYPE.CONTROLLER)\n\t\t\t{\n\t\t\t\tif (inNode.mInstanceController.m_skeletons.size() == 0)\n\t\t\t\t{\n\t\t\t\t\tLogging.logFatal(\"Cannot create model becuase the model has no skeleton.\");\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif (inNode.mInstanceController.m_skeletons.size() > 1)\n\t\t\t\t{\n\t\t\t\t\tLogging.logFatal(\"Cannot create model becuase the model has more than one skeleton.\");\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tcontrollerName = inNode.mInstanceController.mstrUrl.substring(1);\n\t\t\t\tskeletonName = inNode.mInstanceController.m_skeletons.get(0).mstrValue.substring(1);\n\t\t\t\tgeomName = inCollada.mLibraryControllers.get(inNode.mInstanceController.mstrUrl.substring(1)).mSkin.mstrSource.substring(1);\n\t\t\t\t\n\t\t\t\tfor (int i = 0; i < inNode.mInstanceController.mBindMaterial.mTechniqueCommon.mInstanceMaterialList.size(); i++)\n\t\t\t\t{\n\t\t\t\t\tColladaInstanceMaterial material = inNode.mInstanceController.mBindMaterial.mTechniqueCommon.mInstanceMaterialList.get(i);\n\t\t\t\t\tif (material.mstrTarget.length() > 0 && material.mstrSymbol.length() > 0)\n\t\t\t\t\t{\n\t\t\t\t\t\tmaterialNameMap.put(material.mstrSymbol, material.mstrTarget.substring(1));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tbCanExport = true;\n\t\t\t}\n\t\t\t\n\t\t\tif (inNode.meType == ColladaNode.COLLADA_NODE_TYPE.GEOMETRY)\n\t\t\t{\n\t\t\t\tcontrollerName = null;\n\t\t\t\tgeomName = inNode.mInstanceGeometry.mstrUrl.substring(1);\n\t\t\t\t\n\t\t\t\tfor (int i = 0; i < inNode.mInstanceGeometry.mBindMaterial.mTechniqueCommon.mInstanceMaterialList.size(); i++)\n\t\t\t\t{\n\t\t\t\t\tColladaInstanceMaterial material = inNode.mInstanceGeometry.mBindMaterial.mTechniqueCommon.mInstanceMaterialList.get(i);\n\t\t\t\t\tif (material.mstrTarget.length() > 0 && material.mstrSymbol.length() > 0)\n\t\t\t\t\t{\n\t\t\t\t\t\tmaterialNameMap.put(material.mstrSymbol, material.mstrTarget.substring(1));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tbCanExport = true;\n\t\t\t}\n\t\t\t\n\t\t\t//export this node if possible\n\t\t\tif (bCanExport == true)\n\t\t\t{\n\t\t\t\t//if there is a skeleton, build it!\n\t\t\t\tif (skeletonName.length() > 0)\n\t\t\t\t{\n\t\t\t\t\tSkeletonBuilder.TryBuildSkeleton(new LinkedList<ColladaNode>(inCollada.mLibraryVisualScenes.get(inCollada.mScene.mInstanceVisualScene.mstrUrl.substring(1)).mRootNodes.values()),\n\t\t\t\t\t\t\tskeletonName, inModel);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tBuildModelData(geomName, controllerName, materialNameMap, inCollada, inModel);\n\t\t\t}\n\t\t\n\t\t}\n\t\t\n\t\t//try children\n\t\tfor (ColladaNode node: inNode.mChildNodes.values())\n\t\t{\n\t\t\tTryBuildModelDataForNode(inCollada, inModel, node, inNodesToExport, bShouldExport);\n\t\t}\n\t\t\n\t\tmMatrixStack.pop();\n\t}\n\t\n\t//-------------------------------------------------------------------\n\t/// Build Model Data\n\t///\n\t/// Builds the model data for the MoStatic mesh from the collada meshes.\n\t//-------------------------------------------------------------------\n\tprivate void BuildModelData(String instrGeometryName, String instrControllerName, Hashtable<String, String> instrMaterialNameMap, Collada inCollada, CSModel inModel)\n\t{\n\t\tColladaGeometry geometry = null;\n\t\tif (inCollada.mLibraryGeometries.containsKey(instrGeometryName) == true)\n\t\t\tgeometry = inCollada.mLibraryGeometries.get(instrGeometryName);\n\t\t\n\t\tColladaController controller = null;\n\t\tif (instrControllerName != null && inCollada.mLibraryControllers.containsKey(instrControllerName) == true)\n\t\t\tcontroller = inCollada.mLibraryControllers.get(instrControllerName);\n\t\t\n\t\tif (geometry != null && geometry.meType == COLLADA_GEOMETRY_TYPE.MESH)\n\t\t{\n\t\t\t//A geometry \"mesh\" can contain more than one mesh, so iterate over them\n\t\t\tfor (int i = 0; i < geometry.mMesh.mTrianglesList.size(); i++)\n\t\t\t{\n\t\t\t\tColladaTriangles triangles = geometry.mMesh.mTrianglesList.get(i);\n\t\t\t\t\n\t\t\t\t//find the material\n\t\t\t\tString strMaterialName = \"\";\n\t\t\t\tif (triangles.mstrMaterial != null && triangles.mstrMaterial.length() > 0 && instrMaterialNameMap.containsKey(triangles.mstrMaterial) == true)\n\t\t\t\t{\n\t\t\t\t\tstrMaterialName = instrMaterialNameMap.get(triangles.mstrMaterial);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tColladaMaterial material = null;\n\t\t\t\tif (strMaterialName != null && strMaterialName.length() > 0 && inCollada.mLibraryMaterials.containsKey(strMaterialName) == true)\n\t\t\t\t{\n\t\t\t\t\tmaterial = inCollada.mLibraryMaterials.get(strMaterialName);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\t//if the \"Combine Meshes\" transform is being used, then combine all meshes that use the same material.\n\t\t\t\tCSModelMesh mesh = null;\n\t\t\t\tif (material != null && mConversionParams.m_combineMeshes == true)\n\t\t\t\t{\n\t\t\t\t\t//get the mesh name\n\t\t\t\t\tString meshName = triangles.mstrMaterial;\n\t\t\t\t\t\n\t\t\t\t\t//get the mesh\n\t\t\t\t\tmesh = inModel.mMeshTable.get(meshName);\n\t\t\t\t\t\n\t\t\t\t\tif (mesh == null)\n\t\t\t\t\t{\n\t\t\t\t\t\tmesh = new CSModelMesh();\n\t\t\t\t\t\tmesh.mstrName = meshName;\n\t\t\t\t\t\tinModel.mMeshTable.put(meshName, mesh);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tString strMeshName = geometry.mstrName;\n\t\t\t\t\t\n\t\t\t\t\t//if this collada mesh contains more than one mesh, append the material thats being used so we can differentiate.\n\t\t\t\t\tif (geometry.mMesh.mTrianglesList.size() > 1)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (material == null)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tLogging.logFatal(\"Cannot have multiple meshes in one geometry if they do not have materials.\");\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\t\tstrMeshName += \"-\" + triangles.mstrMaterial;\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tmesh = new CSModelMesh();\n\t\t\t\t\tmesh.mstrName = strMeshName;\n\t\t\t\t\tinModel.mMeshTable.put(mesh.mstrName, mesh);\n\t\t\t\t\t\n\t\t\t\t\tif (controller != null)\n\t\t\t\t\t{\n\t\t\t\t\t\tBuildInverseBindMatrices(inModel, mesh, controller);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\t//build the vertex and index data\n\t\t\t\tBuildVertices(geometry, controller, triangles, mesh, inModel);\n\t\t\t\t\n\t\t\t\t//Get the texture name\n\t\t\t\tSetTexture(material, inCollada, mesh);\n\t\t\t\t\n\t\t\t\t//build the material\n\t\t\t\tBuildMaterial(material, inCollada, mesh);\n\t\t\t}\n\t\t}\n\t}\n\t//-------------------------------------------------------------------\n\t/// Build Inverse Bind Matrices\n\t///\n\t/// Adds the inverse bind matrix data to the mesh.\n\t//-------------------------------------------------------------------\n\tprivate void BuildInverseBindMatrices(CSModel inModel, CSModelMesh inMesh, ColladaController inController)\n\t{\n\t\t//iterate and get the inputs\n\t\tString jointSourceName = new String();\n\t\tString ibpSourceName = new String();\n\t\t\n\t\tfor (ColladaInput input : inController.mSkin.mJoints.mInputs)\n\t\t{\n\t\t\tif (input.mstrSemantic.equalsIgnoreCase(\"INV_BIND_MATRIX\") == true)\n\t\t\t\tibpSourceName = input.mstrSource.substring(1);\n\t\t\tif (input.mstrSemantic.equalsIgnoreCase(\"JOINT\") == true)\n\t\t\t\tjointSourceName = input.mstrSource.substring(1);\n\t\t}\n\t\t\n\t\tif (jointSourceName.length() == 0 || ibpSourceName.length() == 0)\n\t\t\tLogging.logFatal(\"Could not get the source names for the Inverse Bind Pose data.\");\n\t\t\n\t\t//get the sources\n\t\tColladaSource jointSource = inController.mSkin.mSourceTable.get(jointSourceName);\n\t\tColladaSource ibpSource = inController.mSkin.mSourceTable.get(ibpSourceName);\n\t\t\n\t\tif (jointSource.mNameArray.mdwCount != ibpSource.mFloatArray.mdwCount / 16 || jointSource.mNameArray.mdwCount != SkeletonBuilder.GetNumberOfJoints(inModel))\n\t\t{\n\t\t\tLogging.logFatal(\"The number of joints in the controller does not match the number of joints in the Skeleton! This is most likely becuase there is something in the skeleton hierarchy that the tool cannot handle, for example geometry.\");\n\t\t}\n\t\t\n\t\t//iterate through the joints\n\t\tinMesh.maInverseBindMatrices = new Matrix4[jointSource.mNameArray.mdwCount];\n\t\tfor (int i = 0; i < jointSource.mNameArray.mdwCount; i++)\n\t\t{\n\t\t\t//get the joint sid and matrix\n\t\t\tString jointName = jointSource.mNameArray.mstrData[i];\n\t\t\t\n\t\t\tfloat[] matData = new float[16];\n\t\t\tfor (int j = 0; j < 4; j++)\n\t\t\t\tfor (int k = 0; k < 4; k++)\n\t\t\t\t\tmatData[j + 4 * k] = ibpSource.mFloatArray.mafData[i * 16 + (j * 4 + k)];\n\n\t\t\t//get the index for this joint\n\t\t\tint jointIndex = SkeletonBuilder.GetIndexOfJointBySId(inModel, jointName);\n\t\t\t\n\t\t\tinMesh.maInverseBindMatrices[jointIndex] = new Matrix4(matData[0], matData[1], matData[2], matData[3],\n\t\t\t\t\tmatData[4], matData[5], matData[6], matData[7],\n\t\t\t\t\tmatData[8], matData[9], matData[10], matData[11],\n\t\t\t\t\tmatData[12], matData[13], matData[14], matData[15]);\n\t\t}\n\t}\n\t//-------------------------------------------------------------------\n\t/// Build Material\n\t///\n\t/// Builds the material from the collada data.\n\t//-------------------------------------------------------------------\n\tprivate void BuildMaterial(ColladaMaterial inMaterial, Collada inCollada, CSModelMesh inMesh)\n\t{\n\t\tif(inMaterial == null)\n\t\t\treturn;\n\t\t\n\t\t//get the effect for this geometry\n\t\tString effectName = inMaterial.mInstanceEffect.mstrUrl.substring(1);\n\t\tColladaEffect effect = inCollada.mLibraryEffects.get(effectName);\n\t\t\n\t\t//get each of the material properties\n\t\tCSModelMaterial newMat = new CSModelMaterial();\n\t\t\n\t\t//set the name\n\t\tnewMat.mstrName = inMaterial.mstrName;\n\t\t\n\t\t//emissive (Note: Phong materials dont contain emissive data. In this case the value will default to that specified in \"ColladaBlinnAndPhong\")\n\t\tdouble emissiveR = effect.mProfileCommon.mTechnique.mBlinnAndPhong.mEmissive.mColour.mfR;\n\t\tdouble emissiveG = effect.mProfileCommon.mTechnique.mBlinnAndPhong.mEmissive.mColour.mfG;\n\t\tdouble emissiveB = effect.mProfileCommon.mTechnique.mBlinnAndPhong.mEmissive.mColour.mfB;\n\t\tdouble emissiveA = effect.mProfileCommon.mTechnique.mBlinnAndPhong.mEmissive.mColour.mfA;\n\t\tnewMat.mvEmissive = new Vector4(emissiveR, emissiveG, emissiveB, emissiveA);\n\t\t\n\t\t//ambient\n\t\tdouble ambientR = effect.mProfileCommon.mTechnique.mBlinnAndPhong.mAmbient.mColour.mfR;\n\t\tdouble ambientG = effect.mProfileCommon.mTechnique.mBlinnAndPhong.mAmbient.mColour.mfG;\n\t\tdouble ambientB = effect.mProfileCommon.mTechnique.mBlinnAndPhong.mAmbient.mColour.mfB;\n\t\tdouble ambientA = effect.mProfileCommon.mTechnique.mBlinnAndPhong.mAmbient.mColour.mfA;\n\t\tnewMat.mvAmbient = new Vector4(ambientR, ambientG, ambientB, ambientA);\n\t\t\n\t\t//diffuse (NOTE: If there is a texture, the collada file does not contain diffuse data. In this case the value will default to that specified \n\t\t//in \"ColladaBlinnAndPhong\")\n\t\tdouble diffuseR = effect.mProfileCommon.mTechnique.mBlinnAndPhong.mDiffuse.mColour.mfR;\n\t\tdouble diffuseG = effect.mProfileCommon.mTechnique.mBlinnAndPhong.mDiffuse.mColour.mfG;\n\t\tdouble diffuseB = effect.mProfileCommon.mTechnique.mBlinnAndPhong.mDiffuse.mColour.mfB;\n\t\tdouble diffuseA = effect.mProfileCommon.mTechnique.mBlinnAndPhong.mAmbient.mColour.mfA;\n\t\tnewMat.mvDiffuse = new Vector4(diffuseR, diffuseG, diffuseB, diffuseA);\n\t\t\n\t\t//specular\n\t\tdouble specularR = effect.mProfileCommon.mTechnique.mBlinnAndPhong.mSpecular.mColour.mfR;\n\t\tdouble specularG = effect.mProfileCommon.mTechnique.mBlinnAndPhong.mSpecular.mColour.mfG;\n\t\tdouble specularB = effect.mProfileCommon.mTechnique.mBlinnAndPhong.mSpecular.mColour.mfB;\n\t\tdouble specularA = effect.mProfileCommon.mTechnique.mBlinnAndPhong.mSpecular.mColour.mfA;\n\t\tnewMat.mvSpecular = new Vector4(specularR, specularG, specularB, specularA);\n\t\t\n\t\t//shininess\n\t\tnewMat.mfShininess = effect.mProfileCommon.mTechnique.mBlinnAndPhong.mShininess.mFloat.mfValue;\n\t\t\n\t\tinMesh.mMaterial = newMat;\n\t}\n\t//-------------------------------------------------------------------\n\t/// Build Vertices\n\t///\n\t/// Builds the vertex and index data from the collada data.\n\t//-------------------------------------------------------------------\n\tprivate void BuildVertices(ColladaGeometry inGeometry, ColladaController inController, ColladaTriangles inTriangles, CSModelMesh inMesh, CSModel inModel)\n\t{\n\t\t//build the index type array\n\t\tMS_INDEX_TYPE[] eIndexTypeArray = new MS_INDEX_TYPE[inTriangles.mInputList.size()];\n\t\tfor (int i = 0; i < inTriangles.mInputList.size(); i++)\n\t\t{\n\t\t\tMS_INDEX_TYPE eType = MS_INDEX_TYPE.NONE;\n\t\t\t\n\t\t\tif (inTriangles.mInputList.get(i).mstrSemantic.equalsIgnoreCase(\"VERTEX\") == true)\n\t\t\t\teType = MS_INDEX_TYPE.POSITION;\n\t\t\telse if (inTriangles.mInputList.get(i).mstrSemantic.equalsIgnoreCase(\"NORMAL\") == true)\n\t\t\t\teType = MS_INDEX_TYPE.NORMAL;\n\t\t\telse if (inTriangles.mInputList.get(i).mstrSemantic.equalsIgnoreCase(\"COLOR\") == true)\n\t\t\t\teType = MS_INDEX_TYPE.COLOUR;\n\t\t\telse if (inTriangles.mInputList.get(i).mstrSemantic.equalsIgnoreCase(\"TEXCOORD\") == true)\n\t\t\t\teType = MS_INDEX_TYPE.TEXCOORD;\n\t\t\t\n\t\t\teIndexTypeArray[inTriangles.mInputList.get(i).mdwOffset] = eType;\n\t\t}\n\t\t\n\t\t//build the weight data\n\t\tCSModelWeightIndexData weightData = BuildWeightIndexData(inController);\n\t\t\n\t\tint numVerts = inTriangles.mP.madwValues.length / inTriangles.mInputList.size();\n\t\t\n\t\tArrayList<CSModelVertex> allVerts = new ArrayList<CSModelVertex>();\n\t\tallVerts.ensureCapacity(numVerts);\n\t\t\n\t\t//use this to build the vertices\n\t\tfor (int i = 0; i < numVerts; i++)\n\t\t{\n\t\t\tint dwPositionIndex = -1;\n\t\t\tint dwNormalIndex = -1;\n\t\t\tint dwTexCoordIndex = -1;\n\t\t\tint dwColourIndex = -1;\n\t\t\tint dwWeightDataIndex = -1;\n\t\t\t\n\t\t\tfor (int j = 0; j < inTriangles.mInputList.size(); j++)\n\t\t\t{\n\t\t\t\tswitch (eIndexTypeArray[j])\n\t\t\t\t{\n\t\t\t\tcase POSITION:\n\t\t\t\t\tdwPositionIndex = inTriangles.mP.madwValues[i * inTriangles.mInputList.size() + j];\n\t\t\t\t\t\n\t\t\t\t\tif (weightData != null)\n\t\t\t\t\t{\n\t\t\t\t\t\tdwWeightDataIndex = dwPositionIndex;\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tbreak;\n\t\t\t\tcase NORMAL:\n\t\t\t\t\tdwNormalIndex = inTriangles.mP.madwValues[i * inTriangles.mInputList.size() + j];\n\t\t\t\t\tbreak;\n\t\t\t\tcase COLOUR:\n\t\t\t\t\tdwColourIndex = inTriangles.mP.madwValues[i * inTriangles.mInputList.size() + j];\n\t\t\t\t\tbreak;\n\t\t\t\tcase TEXCOORD:\n\t\t\t\t\tdwTexCoordIndex = inTriangles.mP.madwValues[i * inTriangles.mInputList.size() + j];\n\t\t\t\t\tbreak;\n\t\t\t\tcase NONE:\n\t\t\t\t\tLogging.logError(\"Found unknown index type in mesh: \" + inGeometry.mstrId);\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tCSModelVertex vertex = BuildVertex(inGeometry, inController, inTriangles, inModel, weightData, dwPositionIndex, dwNormalIndex, dwTexCoordIndex, dwColourIndex, dwWeightDataIndex);\n\t\t\tallVerts.add(vertex);\n\t\t\tAddVertex(inMesh, vertex);\n\t\t}\n\t\t\n\t\tAddTangentBasis(allVerts);\n\t}\n\t//-------------------------------------------------------------------\n\t/// Build Weight Index Data\n\t///\n\t/// Builds the weight index data from the collada controller.\n\t//-------------------------------------------------------------------\n\tprivate CSModelWeightIndexData BuildWeightIndexData(ColladaController inController)\n\t{\n\t\tif (inController != null)\n\t\t{\n\t\t\t//build the index type array\n\t\t\tMS_INDEX_TYPE[] eIndexTypeArray = new MS_INDEX_TYPE[inController.mSkin.mVertexWeights.mInputs.size()];\n\t\t\tfor (int i = 0; i < inController.mSkin.mVertexWeights.mInputs.size(); i++)\n\t\t\t{\n\t\t\t\tMS_INDEX_TYPE eType = MS_INDEX_TYPE.NONE;\n\t\t\t\t\n\t\t\t\tif (inController.mSkin.mVertexWeights.mInputs.get(i).mstrSemantic.equalsIgnoreCase(\"JOINT\") == true)\n\t\t\t\t\teType = MS_INDEX_TYPE.JOINT_INDEX;\n\t\t\t\telse if (inController.mSkin.mVertexWeights.mInputs.get(i).mstrSemantic.equalsIgnoreCase(\"WEIGHT\") == true)\n\t\t\t\t\teType = MS_INDEX_TYPE.WEIGHT;\n\t\t\t\t\n\t\t\t\teIndexTypeArray[inController.mSkin.mVertexWeights.mInputs.get(i).mdwOffset] = eType;\n\t\t\t}\n\t\t\t\n\t\t\tCSModelWeightIndexData weightData = new CSModelWeightIndexData();\n\t\t\tweightData.mWeightIndices = new int[inController.mSkin.mVertexWeights.mdwCount][];\n\t\t\tweightData.mJointIndices = new int[inController.mSkin.mVertexWeights.mdwCount][];\n\t\t\tint dwCount = 0;\n\t\t\tfor (int i = 0; i < inController.mSkin.mVertexWeights.mdwCount; i++)\n\t\t\t{\n\t\t\t\tweightData.mWeightIndices[i] = new int[inController.mSkin.mVertexWeights.mVCount.madwData[i]];\n\t\t\t\tweightData.mJointIndices[i] = new int[inController.mSkin.mVertexWeights.mVCount.madwData[i]];\n\t\t\t\tfor (int j = 0; j < inController.mSkin.mVertexWeights.mVCount.madwData[i]; j++)\n\t\t\t\t{\n\t\t\t\t\tfor (int k = 0; k < eIndexTypeArray.length; k++)\n\t\t\t\t\t{\n\t\t\t\t\t\tswitch (eIndexTypeArray[k])\n\t\t\t\t\t\t{\n\t\t\t\t\t\tcase WEIGHT:\n\t\t\t\t\t\t\tweightData.mWeightIndices[i][j] = inController.mSkin.mVertexWeights.mV.madwData[dwCount++];\t\t\t\t\t\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase JOINT_INDEX:\n\t\t\t\t\t\t\tweightData.mJointIndices[i][j] = inController.mSkin.mVertexWeights.mV.madwData[dwCount++];\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\treturn weightData;\n\t\t}\n\t\t\n\t\treturn null;\n\t}\n\t//-------------------------------------------------------------------\n\t/// Build Vertex\n\t///\n\t/// Builds a vertex from a collada mesh and collada index data.\n\t//-------------------------------------------------------------------\n\tprivate CSModelVertex BuildVertex(ColladaGeometry inGeometry, ColladaController inController, ColladaTriangles inTriangles, CSModel inModel, CSModelWeightIndexData inWeightData, int indwPositionIndex, int indwNormalIndex, int indwTexCoordIndex, int indwColourIndex, int indwWeightDataIndex)\n\t{\n\t\tCSModelVertex newVert = new CSModelVertex();\n\t\tAddPosition(inGeometry, inController, inTriangles, newVert, indwPositionIndex);\n\t\tAddNormal(inGeometry, inController, inTriangles, newVert, indwNormalIndex);\n\t\tAddTextureCoordinate(inGeometry, inTriangles, newVert, indwTexCoordIndex);\n\t\tAddColour(inGeometry, inTriangles, newVert, indwColourIndex);\n\t\tAddVertexWeights(inGeometry, inController, newVert, inWeightData, indwWeightDataIndex);\n\t\tAddJointIndices(inGeometry, inController, inModel, newVert, inWeightData, indwWeightDataIndex);\n\t\treturn newVert;\n\t}\n\t//-------------------------------------------------------------------\n\t/// Add Position\n\t///\n\t/// Adds the position to a vertex.\n\t//-------------------------------------------------------------------\n\tprivate void AddPosition(ColladaGeometry inGeometry, ColladaController inController, ColladaTriangles inTriangles, CSModelVertex inVertex, int indwPositionIndex)\n\t{\n\t\t//add the position\n\t\tif (indwPositionIndex != -1)\n\t\t{\n\t\t\t//get the position input\n\t\t\tColladaInput input = GetInputFromGeometry(inGeometry, inTriangles, \"VERTEX\");\n\t\t\tif (inGeometry.mMesh.mVertices.mstrId.equals(input.mstrSource.substring(1)) == false || inGeometry.mMesh.mVertices.mInput.mstrSemantic.equals(\"POSITION\") == false)\n\t\t\t{\n\t\t\t\tLogging.logFatal(\"'Vertices' with id '\" + inGeometry.mMesh.mVertices.mstrId + \"' and semantic '\"+ inGeometry.mMesh.mVertices.mInput.mstrSemantic +\"' is not supported.\");\n\t\t\t}\n\t\t\t\n\t\t\t//get the source and stride\n\t\t\tColladaSource source = inGeometry.mMesh.mSources.get(inGeometry.mMesh.mVertices.mInput.mstrSource.substring(1));\n\t\t\tint dwStride = source.mTechniqueCommon.mAccessor.mdwStride;\n\t\t\tif (dwStride < 3)\n\t\t\t{\n\t\t\t\tLogging.logFatal(\"A stride of less than 3 is not supported for POSITION sources.\");\n\t\t\t}\n\t\t\t\n\t\t\t//get the vertex data\n\t\t\tdouble posX = source.mFloatArray.mafData[indwPositionIndex * dwStride + 0];\n\t\t\tdouble posY = source.mFloatArray.mafData[indwPositionIndex * dwStride + 1];\n\t\t\tdouble posZ = source.mFloatArray.mafData[indwPositionIndex * dwStride + 2];\n\t\t\tinVertex.mvPosition = new Vector3(posX, posY, posZ);\n\t\t\t\n\t\t\t//if there is a controller, apply its bind shape matrix\n\t\t\tif (inController != null)\n\t\t\t{\n\t\t\t\t//convert the bind shape matrix to something we can use.\n\t\t\t\tfloat[][] matData = inController.mSkin.mBindShapeMatrix.maafValues;\n\t\t\t\t\n\t\t\t\tMatrix4 bindShapeMatrix = new Matrix4(matData[0][0], matData[1][0], matData[2][0], matData[3][0],\n\t\t\t\t\tmatData[0][1], matData[1][1], matData[2][1], matData[3][1],\n\t\t\t\t\tmatData[0][2], matData[1][2], matData[2][2], matData[3][2],\n\t\t\t\t\tmatData[0][3], matData[1][3], matData[2][3], matData[3][3]);\n\n\t\t\t\tinVertex.mvPosition = Vector3.multiply(inVertex.mvPosition, bindShapeMatrix);\n\t\t\t}\n\t\t\t\n\t\t\tinVertex.mvPosition = Vector3.multiply(inVertex.mvPosition, mMatrixStack.peek());\n\t\t}\n\t}\n\t//-------------------------------------------------------------------\n\t/// Add Normal\n\t///\n\t/// Adds the normal to a vertex.\n\t//-------------------------------------------------------------------\n\tprivate void AddNormal(ColladaGeometry inGeometry, ColladaController inController, ColladaTriangles inTriangles, CSModelVertex inVertex, int indwNormalIndex)\n\t{\n\t\tif (indwNormalIndex != -1)\n\t\t{\n\t\t\t//get the normal input\n\t\t\tColladaInput input = GetInputFromGeometry(inGeometry, inTriangles, \"NORMAL\");\n\t\t\t\n\t\t\t//get the source and stride\n\t\t\tColladaSource source = inGeometry.mMesh.mSources.get(input.mstrSource.substring(1));\n\t\t\tint dwStride = source.mTechniqueCommon.mAccessor.mdwStride;\n\t\t\tif (dwStride < 3)\n\t\t\t{\n\t\t\t\tLogging.logFatal(\"A stride of less than 3 is not supported for NORMAL sources.\");\n\t\t\t}\n\t\t\t\n\t\t\tdouble normX = source.mFloatArray.mafData[indwNormalIndex * dwStride + 0];\n\t\t\tdouble normY = source.mFloatArray.mafData[indwNormalIndex * dwStride + 1];\n\t\t\tdouble normZ = source.mFloatArray.mafData[indwNormalIndex * dwStride + 2];\n\t\t\tinVertex.mvNormal = new Vector3(normX, normY, normZ);\n\t\t\t\n\t\t\t//if there is a controller, apply its bind shape matrix\n\t\t\tif (inController != null)\n\t\t\t{\n\t\t\t\tfloat[][] matData = inController.mSkin.mBindShapeMatrix.maafValues;\n\t\t\t\t\n\t\t\t\tMatrix4 bindShapeMatrix = new Matrix4(matData[0][0], matData[1][0], matData[2][0], matData[3][0],\n\t\t\t\t\tmatData[0][1], matData[1][1], matData[2][1], matData[3][1],\n\t\t\t\t\tmatData[0][2], matData[1][2], matData[2][2], matData[3][2],\n\t\t\t\t\t0.0, 0.0, 0.0, matData[3][3]);\n\t\t\t\t\n\t\t\t\tinVertex.mvNormal = Vector3.multiply(inVertex.mvNormal, bindShapeMatrix);\n\t\t\t}\n\t\t\t\n\t\t\tMatrix4 worldMat = mMatrixStack.peek();\n\t\t\tMatrix4 normalWorldMatrix = new Matrix4(worldMat.get(0), worldMat.get(1), worldMat.get(2), worldMat.get(3), \n\t\t\t\t\tworldMat.get(4), worldMat.get(5), worldMat.get(6), worldMat.get(7), \n\t\t\t\t\tworldMat.get(8), worldMat.get(9), worldMat.get(10), worldMat.get(11), \n\t\t\t\t\t0.0, 0.0, 0.0, worldMat.get(15));\n\n\t\t\tinVertex.mvNormal = Vector3.multiply(inVertex.mvNormal, normalWorldMatrix);\n\t\t\tinVertex.mvNormal = Vector3.normalise(inVertex.mvNormal);\n\t\t}\n\t}\n\t//-------------------------------------------------------------------\n\t/// For all verts (operating on triangles) calculates the tangent and bitangents\n\t///\n\t//-------------------------------------------------------------------\n\tprivate void AddTangentBasis(ArrayList<CSModelVertex> vertices)\n\t{\n\t\tassert(vertices.size() % 3 == 0) : \"Vertices should be specified as triangles and total num be divisible by 3\";\n\n\t\tfor(int i=0; i<vertices.size(); i+=3)\n\t\t{\n\t\t\t// Edges of the triangle : position delta\n\t\t\tVector3 deltaPos1 = Vector3.subtract(vertices.get(i+1).mvPosition, vertices.get(i+0).mvPosition);\n        \tVector3 deltaPos2 = Vector3.subtract(vertices.get(i+2).mvPosition, vertices.get(i+0).mvPosition);\n\n        \t// UV delta\n        \tVector2 deltaUV1 = Vector2.subtract(vertices.get(i+1).mvTextureCoordinate, vertices.get(i+0).mvTextureCoordinate);\n        \tVector2 deltaUV2 = Vector2.subtract(vertices.get(i+2).mvTextureCoordinate, vertices.get(i+0).mvTextureCoordinate);\n        \n        \tdouble r = 1.0 / (deltaUV1.getX() * deltaUV2.getY() - deltaUV1.getY() * deltaUV2.getX());\n        \tVector3 tangent = Vector3.multiply(Vector3.subtract( Vector3.multiply(deltaPos1, deltaUV2.getY()), Vector3.multiply(deltaPos2, deltaUV1.getY()) ), r);\n        \tVector3 bitangent = Vector3.multiply(Vector3.subtract( Vector3.multiply(deltaPos2, deltaUV1.getX()), Vector3.multiply(deltaPos1, deltaUV2.getX()) ), r);\n        \t\n        \tvertices.get(i+0).mvTangent = tangent;\n        \tvertices.get(i+1).mvTangent = tangent;\n        \tvertices.get(i+2).mvTangent = tangent;\n        \t\n        \tvertices.get(i+0).mvBitangent = bitangent;\n        \tvertices.get(i+1).mvBitangent = bitangent;\n        \tvertices.get(i+2).mvBitangent = bitangent;\n\t\t}\n\n\t}\n\t//-------------------------------------------------------------------\n\t/// Add Texture Coordinates\n\t///\n\t/// Adds the texture coordinates to a vertex.\n\t//-------------------------------------------------------------------\n\tprivate void AddTextureCoordinate(ColladaGeometry inGeometry, ColladaTriangles inTriangles, CSModelVertex inVertex, int indwTexCoordIndex)\n\t{\n\t\t//add the texture coordinates\n\t\tif (indwTexCoordIndex != -1)\n\t\t{\n\t\t\t//get the tex coord input\n\t\t\tColladaInput input = GetInputFromGeometry(inGeometry, inTriangles, \"TEXCOORD\");\n\t\t\t\n\t\t\t//get the source and stride\n\t\t\tColladaSource source = inGeometry.mMesh.mSources.get(input.mstrSource.substring(1));\n\t\t\tint dwStride = source.mTechniqueCommon.mAccessor.mdwStride;\n\t\t\tif (dwStride < 2)\n\t\t\t{\n\t\t\t\tLogging.logFatal(\"A stride of less than 2 is not supported for TEXCOORD sources.\");\n\t\t\t}\n\t\t\t\n\t\t\tdouble texCoordX = source.mFloatArray.mafData[indwTexCoordIndex * dwStride + 0]; \n\t\t\tdouble texCoordY = source.mFloatArray.mafData[indwTexCoordIndex * dwStride + 1];\n\t\t\tinVertex.mvTextureCoordinate = new Vector2(texCoordX, texCoordY);\n\t\t}\n\t}\n\t//-------------------------------------------------------------------\n\t/// Add Colour\n\t///\n\t/// Adds the colour to a vertex.\n\t//-------------------------------------------------------------------\n\tprivate void AddColour(ColladaGeometry inGeometry, ColladaTriangles inTriangles, CSModelVertex inVertex, int indwColourIndex)\n\t{\n\t\t//add the vertex colours\n\t\tif (indwColourIndex != -1)\n\t\t{\n\t\t\t//get the colour input\n\t\t\tColladaInput input = GetInputFromGeometry(inGeometry, inTriangles, \"COLOR\");\n\t\t\t\n\t\t\t//get the source and stride\n\t\t\tColladaSource source = inGeometry.mMesh.mSources.get(input.mstrSource.substring(1));\n\t\t\tint dwStride = source.mTechniqueCommon.mAccessor.mdwStride;\n\t\t\tif (dwStride < 3)\n\t\t\t{\n\t\t\t\tLogging.logFatal(\"A stride of less than 2 is not supported for COLOR sources.\");\n\t\t\t}\n\t\t\t\n\t\t\t\n\t\t\tdouble vertexR = source.mFloatArray.mafData[indwColourIndex * dwStride + 0] * 255.0f; \n\t\t\tdouble vertexG = source.mFloatArray.mafData[indwColourIndex * dwStride + 1] * 255.0f;\n\t\t\tdouble vertexB = source.mFloatArray.mafData[indwColourIndex * dwStride + 2] * 255.0f;\n\t\t\tdouble vertexA = 255.0f;\n\t\t\tinVertex.mvVertexColour = new Vector4(vertexR, vertexG, vertexB, vertexA);\n\t\t}\n\t}\n\t//-------------------------------------------------------------------\n\t/// Add Vertex Weights\n\t///\n\t/// Adds the vertex weights to a vertex.\n\t//-------------------------------------------------------------------\n\tprivate void AddVertexWeights(ColladaGeometry inGeometry, ColladaController inController, CSModelVertex inVertex, CSModelWeightIndexData inWeightData, int indwWeightDataIndex)\n\t{\n\t\t//add the vertex weights\n\t\tif (indwWeightDataIndex != -1 && inWeightData != null)\n\t\t{\n\t\t\t//get the vertex weight input\n\t\t\tColladaInput input = GetInputFromController(inController, \"WEIGHT\");\n\t\t\t\n\t\t\t//get the source\n\t\t\tColladaSource source = inController.mSkin.mSourceTable.get(input.mstrSource.substring(1));\n\t\t\t\n\t\t\t//weight 0\n\t\t\tdouble weightX = 0.0;\n\t\t\tif (inWeightData.mWeightIndices[indwWeightDataIndex].length > 0)\n\t\t\t{\n\t\t\t\tint index = inWeightData.mWeightIndices[indwWeightDataIndex][0];\n\t\t\t\tweightX = source.mFloatArray.mafData[index];\n\t\t\t}\n\t\t\t\n\t\t\t//weight 1\n\t\t\tdouble weightY = 0.0;\n\t\t\tif (inWeightData.mWeightIndices[indwWeightDataIndex].length > 1)\n\t\t\t{\n\t\t\t\tint index = inWeightData.mWeightIndices[indwWeightDataIndex][1];\n\t\t\t\tweightY = source.mFloatArray.mafData[index];\n\t\t\t}\n\t\t\t\n\t\t\t//weight 2\n\t\t\tdouble weightZ = 0.0;\n\t\t\tif (inWeightData.mWeightIndices[indwWeightDataIndex].length > 2)\n\t\t\t{\n\t\t\t\tint index = inWeightData.mWeightIndices[indwWeightDataIndex][2];\n\t\t\t\tweightZ = source.mFloatArray.mafData[index];\n\t\t\t}\n\t\t\t\n\t\t\t//weight 3\n\t\t\tdouble weightW = 0.0;\n\t\t\tif (inWeightData.mWeightIndices[indwWeightDataIndex].length > 3)\n\t\t\t{\n\t\t\t\tint index = inWeightData.mWeightIndices[indwWeightDataIndex][3];\n\t\t\t\tweightW = source.mFloatArray.mafData[index];\n\t\t\t}\n\t\t\t\n\t\t\tinVertex.mvWeights = new Vector4(weightX, weightY, weightZ, weightW);\n\t\t\t\n\t\t\t//check that the weights are valid.\n\t\t\tfinal double kfTolerance = 0.0001;\n\t\t\tdouble fTotal = inVertex.mvWeights.getX() + inVertex.mvWeights.getY() + inVertex.mvWeights.getZ() + inVertex.mvWeights.getW();\n\t\t\tif (fTotal < 1.0 - kfTolerance || fTotal > 1.0 + kfTolerance)\n\t\t\t{\n\t\t\t\tLogging.logWarning(\"Vertex weights do not add up to 1.0.\");\n\t\t\t}\n\t\t}\n\t}\n\t//-------------------------------------------------------------------\n\t/// Add Joint Indices\n\t///\n\t/// Adds the joint indices to a vertex.\n\t//-------------------------------------------------------------------\n\tprivate void AddJointIndices(ColladaGeometry inGeometry, ColladaController inController, CSModel inModel, CSModelVertex inVertex, CSModelWeightIndexData inWeightData, int indwWeightDataIndex)\n\t{\n\t\t//add the joint indices\n\t\tif (indwWeightDataIndex != -1 && inWeightData != null)\n\t\t{\n\t\t\t//get the vertex weight input\n\t\t\tColladaInput input = GetInputFromController(inController, \"JOINT\");\n\t\t\t\n\t\t\t//get the source\n\t\t\tColladaSource source = inController.mSkin.mSourceTable.get(input.mstrSource.substring(1));\n\t\t\t\n\t\t\tint jointIndexX = 0;\n\t\t\tint jointIndexY = 0;\n\t\t\tint jointIndexZ = 0;\n\t\t\tint jointIndexW = 0;\n\t\t\t\n\t\t\t//weight 0\n\t\t\tif (inWeightData.mJointIndices[indwWeightDataIndex].length > 0)\n\t\t\t{\n\t\t\t\tint index = inWeightData.mJointIndices[indwWeightDataIndex][0];\n\t\t\t\tjointIndexX = SkeletonBuilder.GetIndexOfJointBySId(inModel, source.mNameArray.mstrData[index]);\n\t\t\t}\n\t\t\t\n\t\t\t//weight 1\n\t\t\tif (inWeightData.mJointIndices[indwWeightDataIndex].length > 1)\n\t\t\t{\n\t\t\t\tint index = inWeightData.mJointIndices[indwWeightDataIndex][1];\n\t\t\t\tjointIndexY = SkeletonBuilder.GetIndexOfJointBySId(inModel, source.mNameArray.mstrData[index]);\n\t\t\t}\n\t\t\t\n\t\t\t//weight 2\n\t\t\tif (inWeightData.mJointIndices[indwWeightDataIndex].length > 2)\n\t\t\t{\n\t\t\t\tint index = inWeightData.mJointIndices[indwWeightDataIndex][2];\n\t\t\t\tjointIndexZ = SkeletonBuilder.GetIndexOfJointBySId(inModel, source.mNameArray.mstrData[index]);\n\t\t\t}\n\t\t\t\n\t\t\t//weight 3\n\t\t\tif (inWeightData.mJointIndices[indwWeightDataIndex].length > 3)\n\t\t\t{\n\t\t\t\tint index = inWeightData.mJointIndices[indwWeightDataIndex][3];\n\t\t\t\tjointIndexW = SkeletonBuilder.GetIndexOfJointBySId(inModel, source.mNameArray.mstrData[index]);\n\t\t\t}\n\t\t\t\n\t\t\tinVertex.mvJointIndices = new Integer4(jointIndexX, jointIndexY, jointIndexZ, jointIndexW);\n\t\t}\n\t}\n\t//-------------------------------------------------------------------\n\t/// Get Input From Geometry\n\t///\n\t/// Get the input for the given sematic.\n\t//-------------------------------------------------------------------\n\tprivate ColladaInput GetInputFromGeometry(ColladaGeometry inGeometry, ColladaTriangles inTriangles, String instrSemantic)\n\t{\n\t\tfor (ColladaInput input : inTriangles.mInputList)\n\t\t{\n\t\t\tif (input.mstrSemantic.equals(instrSemantic))\n\t\t\t{\n\t\t\t\treturn input;\n\t\t\t}\n\t\t}\n\t\t\n\t\tLogging.logFatal(\"Geometry '\" + inGeometry.mstrName + \"' doesn't contain semantic '\" + instrSemantic + \"'\");\n\t\treturn null;\n\t}\n\t//-------------------------------------------------------------------\n\t/// Get Input From Controller\n\t///\n\t/// Get the input for the given sematic.\n\t//-------------------------------------------------------------------\n\tprivate ColladaInput GetInputFromController(ColladaController inController, String instrSemantic)\n\t{\n\t\tfor (ColladaInput input : inController.mSkin.mVertexWeights.mInputs)\n\t\t{\n\t\t\tif (input.mstrSemantic.equals(instrSemantic))\n\t\t\t{\n\t\t\t\treturn input;\n\t\t\t}\n\t\t}\n\t\t\n\t\tLogging.logFatal(\"Controller '\" + inController.mstrId + \"' doesn't contain semantic '\" + instrSemantic + \"'\");\n\t\treturn null;\n\t}\n\t//-------------------------------------------------------------------\n\t/// Add Vertex\n\t///\n\t/// Checks to see if a vertex already exists. If it does then simply \n\t/// add an index to it, if not add it and add a index to the new vertex.\n\t//-------------------------------------------------------------------\n\tprivate void AddVertex(CSModelMesh inMesh, CSModelVertex inVertex)\n\t{\n\t\t//check and see if this vertex already exists\n\t\tint dwIndex = FindVertex(inMesh, inVertex);\n\t\t\n\t\tif (dwIndex > -1)\n\t\t{\n\t\t\tinMesh.mIndexList.add(dwIndex);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tinMesh.mVertexList.add(inVertex);\n\t\t\tinMesh.mIndexList.add(inMesh.mVertexList.size() - 1);\n\t\t\t\n\t\t\t//update mesh boundries\n\t\t\tif (inVertex.mvPosition.getX() > inMesh.mvMax.getX())\n\t\t\t\tinMesh.mvMax = new Vector3(inVertex.mvPosition.getX(), inMesh.mvMax.getY(), inMesh.mvMax.getZ());\n\t\t\tif (inVertex.mvPosition.getY() > inMesh.mvMax.getY())\n\t\t\t\tinMesh.mvMax = new Vector3(inMesh.mvMax.getX(), inVertex.mvPosition.getY(), inMesh.mvMax.getZ());\n\t\t\tif (inVertex.mvPosition.getZ() > inMesh.mvMax.getZ())\n\t\t\t\tinMesh.mvMax = new Vector3(inMesh.mvMax.getX(), inMesh.mvMax.getY(), inVertex.mvPosition.getZ());\n\t\t\tif (inVertex.mvPosition.getX() < inMesh.mvMin.getX())\n\t\t\t\tinMesh.mvMin = new Vector3(inVertex.mvPosition.getX(), inMesh.mvMin.getY(), inMesh.mvMin.getZ());\n\t\t\tif (inVertex.mvPosition.getY() < inMesh.mvMin.getY())\n\t\t\t\tinMesh.mvMin = new Vector3(inMesh.mvMin.getX(), inVertex.mvPosition.getY(), inMesh.mvMin.getZ());\n\t\t\tif (inVertex.mvPosition.getZ() < inMesh.mvMin.getZ())\n\t\t\t\tinMesh.mvMin = new Vector3(inMesh.mvMin.getX(), inMesh.mvMin.getY(), inVertex.mvPosition.getZ());\n\t\t}\n\t}\n\t//-------------------------------------------------------------------\n\t/// Find Vertex\n\t///\n\t/// Finds an identical vertex to the one passed in, and returns its\n\t/// index in the mesh. if it does not exist -1 is returned.\n\t//-------------------------------------------------------------------\n\tprivate int FindVertex(CSModelMesh inMesh, CSModelVertex inVertex)\n\t{\n\t\tint count = 0;\n\t\tfor (CSModelVertex vert: inMesh.mVertexList)\n\t\t{\n\t\t\tif (vert.equals(inVertex) == true)\n\t\t\t\treturn count;\n\t\t\t\n\t\t\tcount++;\n\t\t}\n\t\treturn -1;\n\t}\n}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
  },
  {
    "path": "Projects/Tools/ColladaToCSModel/src/com/chilliworks/chillisource/colladatocsmodel/CSModelOutputer.java",
    "content": "/**\n * CSModelOutputer.java\n * ChilliSource\n * Created by Ian Copland on 15/01/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.colladatocsmodel;\n\nimport java.io.DataOutputStream;\nimport java.io.FileOutputStream;\nimport java.util.LinkedList;\n\nimport com.chilliworks.chillisource.colladatocsmodel.csmodel.*;\nimport com.chilliworks.chillisource.coreutils.*;\n\n\npublic class CSModelOutputer \n{\n\t//-------------------------------------------------------------------\n\t/// Constants\n\t//-------------------------------------------------------------------\n\tprivate static final int kdwEndiannessCheckValue = 6666;\n\tprivate static final int kdwVersionNumber = 13;\n\n\tprivate static final int kdwFeatureHasAnimationData = 1;\n\t\n\tprivate static final int kdwVertexPosition = 1;\n\tprivate static final int kdwVertexNormal = 2;\n\tprivate static final int kdwVertexTangent = 3;\n\tprivate static final int kdwVertexBitangent = 4;\n\tprivate static final int kdwVertexTexCoord = 5;\n\tprivate static final int kdwVertexColour = 6;\n\tprivate static final int kdwVertexWeight = 7;\n\tprivate static final int kdwVertexJointIndex = 8;\n\t\n\tprivate static final int kdwSkeletonNodeTypeStandard = 0;\n\tprivate static final int kdwSkeletonNodeTypeJoint = 1;\n\t\n\tprivate static final int HIGHEST_UNSIGNED_SHORT = 65535;\n\t//-------------------------------------------------------------------\n\t/// Private Member Data\n\t//-------------------------------------------------------------------\n\tDataOutputStream mStream;\n\tint mdwSizeOfIndices;\n\t//-------------------------------------------------------------------\n\t/// Constructor\n\t//-------------------------------------------------------------------\n\tpublic CSModelOutputer()\n\t{\n\t}\n\t//-------------------------------------------------------------------\n\t/// Output\n\t///\n\t/// Outputs the given MoModel data to file.\n\t//-------------------------------------------------------------------\n\tpublic boolean Output(ColladaToCSModelOptions inConversionParams, CSModel inMoModel) throws Exception\n\t{\n\t\tboolean bSuccess = true;\n\t\t\n\t\tCalculateSizeOfIndices(inMoModel);\n\t\t\n\t\t//try and open a new file stream. if this fails, throw a fatal error.\n\t\ttry\n\t\t{\n\t\t\tmStream = new DataOutputStream(new FileOutputStream(inConversionParams.m_outputFilePath));\n\t\t}\n\t\tcatch (Exception e)\n\t\t{\n\t\t\tmStream.close();\n\t\t\tLogging.logFatal(\"Failed to open output file: \" + inConversionParams.m_outputFilePath);\n\t\t}\n\t\t\n\t\t//output the file\n\t\ttry\n\t\t{\n\t\t\tif (mStream != null)\n\t\t\t{\n\t\t\t\tbSuccess = WriteGlobalHeader(inConversionParams, inMoModel);\n\t\t\t\tif (bSuccess == true)\n\t\t\t\t{\n\t\t\t\t\tbSuccess = WriteSkeleton(inConversionParams, inMoModel);\n\t\t\t\t\tif (bSuccess == true)\n\t\t\t\t\t{\n\t\t\t\t\t\tfor (CSModelMesh mesh: inMoModel.mMeshTable.values())\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tbSuccess = WriteMeshHeader(inConversionParams, mesh);\n\t\t\t\t\t\t\tif (bSuccess == false)\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tbSuccess = WriteMeshBody(inConversionParams, mesh);\n\t\t\t\t\t\t\tif (bSuccess == false)\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tcatch (Exception e)\n\t\t{\n\t\t\tmStream.close();\n\t\t\tLogging.logFatal(\"Failed to write to file: \" + inConversionParams.m_outputFilePath);\n\t\t}\n\t\t\n\t\t//close the filestream\n\t\tmStream.close();\n\t\t\n\t\treturn bSuccess;\n\t}\n\t//-------------------------------------------------------------------\n\t/// Calculate Size Of Indices\n\t///\n\t/// Calculates the size of an index. This will try and be of size 2 \n\t/// (unsigned short integer), but if its too big it will become 4.\n\t//-------------------------------------------------------------------\n\tprivate void CalculateSizeOfIndices(CSModel inMoModel)\n\t{\n\t\tmdwSizeOfIndices = 2;\n\t\t\n\t\tfor (CSModelMesh mesh: inMoModel.mMeshTable.values())\n\t\t{\n\t\t\tif (mesh.mIndexList.size() >= HIGHEST_UNSIGNED_SHORT || mesh.mVertexList.size() >= HIGHEST_UNSIGNED_SHORT)\n\t\t\t{\n\t\t\t\tmdwSizeOfIndices = 4;\n\t\t\t}\n\t\t}\n\t}\n\t//-------------------------------------------------------------------\n\t/// Get Num Features\n\t///\n\t/// Calculates the number of features to be outputed from the \n\t/// conversion parameters\n\t//-------------------------------------------------------------------\n\tprivate int GetNumFeatures(ColladaToCSModelOptions inConversionParams)\n\t{\n\t\tint dwNumFeatures = 0;\n\t\t\n\t\tif (inConversionParams.m_animated == true) \n\t\t\tdwNumFeatures++;\n\t\t\n\t\treturn dwNumFeatures;\n\t}\n\t//-------------------------------------------------------------------\n\t/// Get Num Vertex Elements\n\t///\n\t/// Calculates the number of vertex elements to be outputed from the \n\t/// conversion parameters\n\t//-------------------------------------------------------------------\n\tprivate int GetNumVertexElements(ColladaToCSModelOptions inConversionParams)\n\t{\n\t\tint dwNumVertexElements = 0;\n\t\t\n\t\tif (inConversionParams.m_vertexHasPosition == true) \n\t\t\tdwNumVertexElements++;\n\t\tif (inConversionParams.m_vertexHasNormal == true)\n\t\t\tdwNumVertexElements++;\n\t\tif (inConversionParams.m_vertexHasTangent == true)\n\t\t\tdwNumVertexElements++;\n\t\tif (inConversionParams.m_vertexHasBitangent == true)\n\t\t\tdwNumVertexElements++;\n\t\tif (inConversionParams.m_vertexHasTexCoords == true)\n\t\t\tdwNumVertexElements++;\n\t\tif (inConversionParams.m_vertexHasColour == true) \n\t\t\tdwNumVertexElements++;\n\t\tif (inConversionParams.m_vertexHasWeights == true) \n\t\t\tdwNumVertexElements++;\n\t\tif (inConversionParams.m_vertexHasJointIndices == true) \n\t\t\tdwNumVertexElements++;\n\t\t\n\t\treturn dwNumVertexElements;\n\t}\n\t//-------------------------------------------------------------------\n\t/// Write Global Header\n\t///\n\t/// Writes the file format header.\n\t//-------------------------------------------------------------------\n\tprivate boolean WriteGlobalHeader(ColladaToCSModelOptions inConversionParams, CSModel inMoModel) throws Exception\n\t{\n\t\t//write the endianess check value and version number\n\t\tLittleEndianWriterUtils.writeUInt32(mStream, kdwEndiannessCheckValue);\n\t\tLittleEndianWriterUtils.writeUInt32(mStream, kdwVersionNumber);\n\t\t\n\t\t//output the feature declaration\n\t\tmStream.writeByte((byte)GetNumFeatures(inConversionParams));\n\t\tif (inConversionParams.m_animated == true) \n\t\t{\n\t\t\tmStream.writeByte((byte)kdwFeatureHasAnimationData);\n\t\t}\n\t\t\n\t\t//output the Vertex Description\n\t\tmStream.writeByte((byte)GetNumVertexElements(inConversionParams));\n\t\tif (inConversionParams.m_vertexHasPosition == true)\n\t\t\tmStream.writeByte((byte)kdwVertexPosition);\n\t\tif (inConversionParams.m_vertexHasNormal == true)\n\t\t\tmStream.writeByte((byte)kdwVertexNormal);\n\t\tif (inConversionParams.m_vertexHasTangent == true)\n\t\t\tmStream.writeByte((byte)kdwVertexTangent);\n\t\tif (inConversionParams.m_vertexHasBitangent == true)\n\t\t\tmStream.writeByte((byte)kdwVertexBitangent);\n\t\tif (inConversionParams.m_vertexHasTexCoords == true) \n\t\t\tmStream.writeByte((byte)kdwVertexTexCoord);\n\t\tif (inConversionParams.m_vertexHasColour == true) \n\t\t\tmStream.writeByte((byte)kdwVertexColour);\n\t\tif (inConversionParams.m_vertexHasWeights == true) \n\t\t\tmStream.writeByte((byte)kdwVertexWeight);\n\t\tif (inConversionParams.m_vertexHasJointIndices == true) \n\t\t\tmStream.writeByte((byte)kdwVertexJointIndex);\n\t\t\n\t\t//index declaration\n\t\tmStream.writeByte((byte)mdwSizeOfIndices);\n\t\t\n\t\t//output the bounding box data\n\t\tLittleEndianWriterUtils.writeFloat32(mStream, (float)inMoModel.mvMin.getX());\n\t\tLittleEndianWriterUtils.writeFloat32(mStream, (float)inMoModel.mvMin.getY());\n\t\tLittleEndianWriterUtils.writeFloat32(mStream, (float)inMoModel.mvMin.getZ());\n\t\tLittleEndianWriterUtils.writeFloat32(mStream, (float)inMoModel.mvMax.getX());\n\t\tLittleEndianWriterUtils.writeFloat32(mStream, (float)inMoModel.mvMax.getY());\n\t\tLittleEndianWriterUtils.writeFloat32(mStream, (float)inMoModel.mvMax.getZ());\n\t\t\n\t\t//output meshes!\n\t\tLittleEndianWriterUtils.writeUInt16(mStream, inMoModel.mMeshTable.size());\n\t\t\n\t\tif (inConversionParams.m_animated == true)\n\t\t{\n\t\t\tLittleEndianWriterUtils.writeInt16(mStream, (short)inMoModel.mSkeleton.mNodeList.size());\n\t\t\tmStream.writeByte((byte)SkeletonBuilder.GetNumberOfJoints(inMoModel));\n\t\t}\n\t\t\n\t\treturn true;\n\t}\n\t//-------------------------------------------------------------------\n\t/// Write Skeleton\n\t///\n\t/// Writes the skeleton data to file.\n\t//-------------------------------------------------------------------\n\tprivate boolean WriteSkeleton(ColladaToCSModelOptions inConversionParams, CSModel inMoModel) throws Exception\n\t{\n\t\tif (inConversionParams.m_animated == true)\n\t\t{\n\t\t\tfor (int i = 0; i < inMoModel.mSkeleton.mNodeList.size(); i++)\n\t\t\t{\n\t\t\t\tCSModelSkeletonNode node = inMoModel.mSkeleton.mNodeList.get(i);\n\t\t\t\t\n\t\t\t\t//write joint name\n\t\t\t\tStringWriterUtils.writeUTF8StringNullTerminated(mStream, node.mstrName);\n\t\t\t\t\n\t\t\t\t//write parent index\n\t\t\t\tLittleEndianWriterUtils.writeInt16(mStream, (short)node.mdwParentNodeIndex);\n\t\t\t\t\n\t\t\t\t//write the note type\n\t\t\t\tif (node.mbIsJoint == false)\n\t\t\t\t{\n\t\t\t\t\tmStream.writeByte((byte)kdwSkeletonNodeTypeStandard);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tmStream.writeByte((byte)kdwSkeletonNodeTypeJoint);\n\t\t\t\t\t\n\t\t\t\t\t//Also write the joint index.\n\t\t\t\t\tmStream.writeByte((byte)node.mdwJointIndex);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\treturn true;\n\t}\n\t//-------------------------------------------------------------------\n\t/// Write Mesh Header\n\t///\n\t/// Writes the mesh header data to file.\n\t//-------------------------------------------------------------------\n\tprivate boolean WriteMeshHeader(ColladaToCSModelOptions inConversionParams, CSModelMesh inMoModelMesh) throws Exception\n\t{\n\t\t//write the mesh name\n\t\tStringWriterUtils.writeUTF8StringNullTerminated(mStream, inMoModelMesh.mstrName);\n\t\t\n\t\t//write the number of verts and indices\n\t\tif (mdwSizeOfIndices == 2)\n\t\t{\n\t\t\tLittleEndianWriterUtils.writeUInt16(mStream, inMoModelMesh.mVertexList.size());\n\t\t\tLittleEndianWriterUtils.writeUInt16(mStream, inMoModelMesh.mIndexList.size() / 3);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tLittleEndianWriterUtils.writeUInt32(mStream, (long)inMoModelMesh.mVertexList.size());\n\t\t\tLittleEndianWriterUtils.writeUInt32(mStream, (long)inMoModelMesh.mIndexList.size() / 3);\n\t\t}\n\t\t\n\t\t//write the bounds\n\t\tLittleEndianWriterUtils.writeFloat32(mStream, (float)inMoModelMesh.mvMin.getX());\n\t\tLittleEndianWriterUtils.writeFloat32(mStream, (float)inMoModelMesh.mvMin.getY());\n\t\tLittleEndianWriterUtils.writeFloat32(mStream, (float)inMoModelMesh.mvMin.getZ());\n\t\tLittleEndianWriterUtils.writeFloat32(mStream, (float)inMoModelMesh.mvMax.getX());\n\t\tLittleEndianWriterUtils.writeFloat32(mStream, (float)inMoModelMesh.mvMax.getY());\n\t\tLittleEndianWriterUtils.writeFloat32(mStream, (float)inMoModelMesh.mvMax.getZ());\n\t\t\n\t\treturn true;\n\t}\n\t//-------------------------------------------------------------------\n\t/// Write Mesh Body\n\t///\n\t/// Writes the mesh body data to file.\n\t//-------------------------------------------------------------------\n\tprivate boolean WriteMeshBody(ColladaToCSModelOptions inConversionParams, CSModelMesh inMoStaticMesh) throws Exception\n\t{\n\t\tboolean bSuccess = true;\n\t\t\n\t\tbSuccess = WriteInverseBindMatrices(inConversionParams, inMoStaticMesh);\n\t\t\n\t\tif (bSuccess == true)\n\t\t\tbSuccess = WriteVertices(inConversionParams, inMoStaticMesh);\n\t\t\n\t\tif (bSuccess == true)\n\t\t\tbSuccess = WriteIndices(inConversionParams, inMoStaticMesh);\n\t\t\n\t\treturn bSuccess;\n\t}\n\t//-------------------------------------------------------------------\n\t/// Write Inverse Bind Matrices\n\t///\n\t/// Writes the inverse bind matrices if they need to be.\n\t//-------------------------------------------------------------------\n\tprivate boolean WriteInverseBindMatrices(ColladaToCSModelOptions inConversionParams, CSModelMesh inMoStaticMesh) throws Exception\n\t{\n\t\tif (inConversionParams.m_animated == true)\n\t\t{\n\t\t\tif (inMoStaticMesh.maInverseBindMatrices != null)\n\t\t\t{\n\t\t\t\tfor (int i = 0; i < inMoStaticMesh.maInverseBindMatrices.length; i++)\n\t\t\t\t{\n\t\t\t\t\tfor (int j = 0; j < 16; j++)\n\t\t\t\t\t{\n\t\t\t\t\t\tLittleEndianWriterUtils.writeFloat32(mStream, (float)inMoStaticMesh.maInverseBindMatrices[i].get(j));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\treturn true;\n\t}\n\t//-------------------------------------------------------------------\n\t/// Write Vertices\n\t///\n\t/// Writes the vertices to the output stream\n\t//-------------------------------------------------------------------\n\tprivate boolean WriteVertices(ColladaToCSModelOptions inConversionParams, CSModelMesh inMoStaticMesh) throws Exception\n\t{\n\t\tLinkedList<CSModelVertex> vertexList = inMoStaticMesh.mVertexList;\n\t\t\n\t\tfor (int i = 0; i < vertexList.size(); i++)\n\t\t{\n\t\t\tCSModelVertex vertex = vertexList.get(i);\n\t\t\t\n\t\t\t//write the position data\n\t\t\tif (inConversionParams.m_vertexHasPosition == true)\n\t\t\t{\n\t\t\t\tLittleEndianWriterUtils.writeFloat32(mStream, (float)vertex.mvPosition.getX());\n\t\t\t\tLittleEndianWriterUtils.writeFloat32(mStream, (float)vertex.mvPosition.getY());\n\t\t\t\tLittleEndianWriterUtils.writeFloat32(mStream, (float)vertex.mvPosition.getZ());\n\t\t\t\tLittleEndianWriterUtils.writeFloat32(mStream, 1.0f);\n\t\t\t}\n\t\t\t\n\t\t\t//write the normal data if its in the format\n\t\t\tif (inConversionParams.m_vertexHasNormal == true)\n\t\t\t{\n\t\t\t\tLittleEndianWriterUtils.writeFloat32(mStream, (float)vertex.mvNormal.getX());\n\t\t\t\tLittleEndianWriterUtils.writeFloat32(mStream, (float)vertex.mvNormal.getY());\n\t\t\t\tLittleEndianWriterUtils.writeFloat32(mStream, (float)vertex.mvNormal.getZ());\n\t\t\t}\n\t\t\t\n\t\t\t//write the normal tangent data if its in the format\n\t\t\tif (inConversionParams.m_vertexHasTangent == true)\n\t\t\t{\n\t\t\t\tLittleEndianWriterUtils.writeFloat32(mStream, (float)vertex.mvTangent.getX());\n\t\t\t\tLittleEndianWriterUtils.writeFloat32(mStream, (float)vertex.mvTangent.getY());\n\t\t\t\tLittleEndianWriterUtils.writeFloat32(mStream, (float)vertex.mvTangent.getZ());\n\t\t\t}\n\t\t\t\n\t\t\t//write the normal bitangent data if its in the format\n\t\t\tif (inConversionParams.m_vertexHasBitangent == true)\n\t\t\t{\n\t\t\t\tLittleEndianWriterUtils.writeFloat32(mStream, (float)vertex.mvBitangent.getX());\n\t\t\t\tLittleEndianWriterUtils.writeFloat32(mStream, (float)vertex.mvBitangent.getY());\n\t\t\t\tLittleEndianWriterUtils.writeFloat32(mStream, (float)vertex.mvBitangent.getZ());\n\t\t\t}\n\t\t\t\n\t\t\t//write the tex coord data if its in the format\n\t\t\tif (inConversionParams.m_vertexHasTexCoords == true)\n\t\t\t{\n\t\t\t\tLittleEndianWriterUtils.writeFloat32(mStream, (float)vertex.mvTextureCoordinate.getX());\n\t\t\t\tLittleEndianWriterUtils.writeFloat32(mStream, (float)vertex.mvTextureCoordinate.getY());\n\t\t\t}\n\t\t\t\n\t\t\t//write the colour data if its in the format\n\t\t\tif (inConversionParams.m_vertexHasColour == true)\n\t\t\t{\n\t\t\t\tmStream.writeByte((byte)vertex.mvVertexColour.getX());\n\t\t\t\tmStream.writeByte((byte)vertex.mvVertexColour.getY());\n\t\t\t\tmStream.writeByte((byte)vertex.mvVertexColour.getZ());\n\t\t\t\tmStream.writeByte((byte)vertex.mvVertexColour.getW());\n\t\t\t}\n\t\t\t\n\t\t\t//write the vertex weight if its in the format\n\t\t\tif (inConversionParams.m_vertexHasWeights == true)\n\t\t\t{\n\t\t\t\tLittleEndianWriterUtils.writeFloat32(mStream, (float)vertex.mvWeights.getX());\n\t\t\t\tLittleEndianWriterUtils.writeFloat32(mStream, (float)vertex.mvWeights.getY());\n\t\t\t\tLittleEndianWriterUtils.writeFloat32(mStream, (float)vertex.mvWeights.getZ());\n\t\t\t\tLittleEndianWriterUtils.writeFloat32(mStream, (float)vertex.mvWeights.getW());\n\t\t\t}\n\t\t\t\n\t\t\t//write the joint indices if its in the format\n\t\t\tif (inConversionParams.m_vertexHasJointIndices == true)\n\t\t\t{\n\t\t\t\tmStream.writeByte((byte)vertex.mvJointIndices.getX());\n\t\t\t\tmStream.writeByte((byte)vertex.mvJointIndices.getY());\n\t\t\t\tmStream.writeByte((byte)vertex.mvJointIndices.getZ());\n\t\t\t\tmStream.writeByte((byte)vertex.mvJointIndices.getW());\n\t\t\t}\n\t\t}\n\t\t\n\t\treturn true;\n\t}\n\t//-------------------------------------------------------------------\n\t/// Write Indices\n\t///\n\t/// Writes the indices to the output stream\n\t//-------------------------------------------------------------------\n\tprivate boolean WriteIndices(ColladaToCSModelOptions inConversionParams, CSModelMesh inMoStaticMesh) throws Exception\n\t{\n\t\tif (inMoStaticMesh.mIndexList.size() > 0)\n\t\t{\n\t\t\tLinkedList<Integer> indexList = inMoStaticMesh.mIndexList;\n\t\t\t\n\t\t\tif (mdwSizeOfIndices == 2)\n\t\t\t{\n\t\t\t\tfor (int i = 0; i < indexList.size() / 3; i++)\n\t\t\t\t{\n\t\t\t\t\tLittleEndianWriterUtils.writeUInt16(mStream, indexList.get(i * 3 + 0));\n\t\t\t\t\tLittleEndianWriterUtils.writeUInt16(mStream, indexList.get(i * 3 + 1));\n\t\t\t\t\tLittleEndianWriterUtils.writeUInt16(mStream, indexList.get(i * 3 + 2));\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tfor (int i = 0; i < indexList.size() / 3; i++)\n\t\t\t\t{\n\t\t\t\t\tLittleEndianWriterUtils.writeUInt32(mStream, (long)indexList.get(i * 3 + 0));\n\t\t\t\t\tLittleEndianWriterUtils.writeUInt32(mStream, (long)indexList.get(i * 3 + 1));\n\t\t\t\t\tLittleEndianWriterUtils.writeUInt32(mStream, (long)indexList.get(i * 3 + 2));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/ColladaToCSModel/src/com/chilliworks/chillisource/colladatocsmodel/CSModelTransformer.java",
    "content": "/**\n * CSModelTransformer.java\n * ChilliSource\n * Created by Ian Copland on 15/01/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.colladatocsmodel;\n\nimport java.util.LinkedList;\n\nimport com.chilliworks.chillisource.colladatocsmodel.csmodel.CSModel;\nimport com.chilliworks.chillisource.colladatocsmodel.csmodel.CSModelMesh;\nimport com.chilliworks.chillisource.colladatocsmodel.csmodel.CSModelVertex;\nimport com.chilliworks.chillisource.coreutils.Matrix4;\nimport com.chilliworks.chillisource.coreutils.Vector2;\nimport com.chilliworks.chillisource.coreutils.Vector3;\n\npublic final class CSModelTransformer \n{\n\t/**\n\t * Applies all transforms specified in the input options.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param in_options - The options.\n\t * @param in_model - The model.\n\t */\n\tpublic static void transform(ColladaToCSModelOptions in_options, CSModel in_model)\n\t{\n\t\tif (in_options.m_swapHandedness == true)\n\t\t{\n\t\t\tswapHandedness(in_model);\n\t\t}\n\t\t\n\t\tif (in_options.m_swapYAndZ == true)\n\t\t{\n\t\t\tswapYAndZ(in_model);\n\t\t}\n\t\t\n\t\tif (in_options.m_flipVerticalTexCoords == true)\n\t\t{\n\t\t\tflipVerticalTexCoords(in_model);\n\t\t}\n\t}\n\t/**\n\t * Swaps the handedness of the output model data.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param in_model - The model.\n\t */\n\tprivate static void swapHandedness(CSModel in_model)\n\t{\n\t\t//overall bounds\n\t\tin_model.mvMin = new Vector3(in_model.mvMin.getX(), -in_model.mvMax.getY(), in_model.mvMin.getZ());\n\t\tin_model.mvMax = new Vector3(in_model.mvMax.getX(), -in_model.mvMin.getY(), in_model.mvMax.getZ());\n\t\t\n\t\t//each mesh bounds, positions and normals\n\t\tfor (CSModelMesh mesh: in_model.mMeshTable.values())\n\t\t{\n\t\t\t//bounds\n\t\t\tmesh.mvMin = new Vector3(mesh.mvMin.getX(), -mesh.mvMax.getY(), mesh.mvMin.getZ());\n\t\t\tmesh.mvMax = new Vector3(mesh.mvMax.getX(), -mesh.mvMin.getY(), mesh.mvMax.getZ());\n\t\t\t\n\t\t\t//position and normal\n\t\t\tfor (CSModelVertex vert: mesh.mVertexList)\n\t\t\t{\n\t\t\t\tvert.mvPosition = new Vector3(vert.mvPosition.getX(), -vert.mvPosition.getY(), vert.mvPosition.getZ());\n\t\t\t\tvert.mvNormal = new Vector3(vert.mvNormal.getX(), -vert.mvNormal.getY(), vert.mvNormal.getZ());\n\t\t\t\tvert.mvTangent = new Vector3(vert.mvTangent.getX(), -vert.mvTangent.getY(), vert.mvTangent.getZ());\n\t\t\t\tvert.mvBitangent = new Vector3(vert.mvBitangent.getX(), -vert.mvBitangent.getY(), vert.mvBitangent.getZ());\n\t\t\t}\n\t\t\t\n\t\t\t//Mirror inverse bind matrices\n\t\t\tif (mesh.maInverseBindMatrices != null)\n\t\t\t{\n\t\t\t\tfor (int i = 0; i < mesh.maInverseBindMatrices.length; i++)\n\t\t\t\t{\n\t\t\t\t\tMatrix4 invertY = new Matrix4(\n\t\t\t\t\t\t\t1.0f, 0.0f, 0.0f, 0.0f,\n\t\t\t\t\t\t\t0.0f,-1.0f, 0.0f, 0.0f,\n\t\t\t\t\t\t\t0.0f, 0.0f, 1.0f, 0.0f,\n\t\t\t\t\t\t\t0.0f, 0.0f, 0.0f, 1.0f);\n\t\t\t\t\tmesh.maInverseBindMatrices[i] = Matrix4.multiply(Matrix4.multiply(Matrix4.inverse(invertY), mesh.maInverseBindMatrices[i]), invertY);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\t//each mesh bounds, positions and normals\n\t\tfor (CSModelMesh mesh: in_model.mMeshTable.values())\n\t\t{\n\t\t\t//indices\n\t\t\tLinkedList<Integer> newIndices = new LinkedList<Integer>();\n\t\t\tfor (int i = 0; i < mesh.mIndexList.size() / 3; i++)\n\t\t\t{\n\t\t\t\tnewIndices.add(mesh.mIndexList.get(i * 3 + 0));\n\t\t\t\tnewIndices.add(mesh.mIndexList.get(i * 3 + 2));\n\t\t\t\tnewIndices.add(mesh.mIndexList.get(i * 3 + 1));\n\t\t\t}\n\t\t\tmesh.mIndexList = newIndices;\n\t\t}\n\t}\n\t/**\n\t * Swaps y and z for all data in the model. This is needed to convert \n\t * from 3DS Max space to ChilliSource space.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param in_model - The model.\n\t */\n\tprivate static void swapYAndZ(CSModel in_model)\n\t{\n\t\t//overall bounds\n\t\tin_model.mvMin = new Vector3(in_model.mvMin.getX(), in_model.mvMin.getZ(), in_model.mvMin.getY());\n\t\tin_model.mvMax = new Vector3(in_model.mvMax.getX(), in_model.mvMax.getZ(), in_model.mvMax.getY());\n\t\t\n\t\t//each mesh bounds, positions and normals\n\t\tfor (CSModelMesh mesh: in_model.mMeshTable.values())\n\t\t{\n\t\t\t//bounds\n\t\t\tmesh.mvMin = new Vector3(mesh.mvMin.getX(), mesh.mvMin.getZ(), mesh.mvMin.getY());\n\t\t\tmesh.mvMax = new Vector3(mesh.mvMax.getX(), mesh.mvMax.getZ(), mesh.mvMax.getY());\n\t\t\t\n\t\t\t//position and normal\n\t\t\tfor (CSModelVertex vert: mesh.mVertexList)\n\t\t\t{\n\t\t\t\tvert.mvPosition = new Vector3(vert.mvPosition.getX(), vert.mvPosition.getZ(), vert.mvPosition.getY());\n\t\t\t\tvert.mvNormal = new Vector3(vert.mvNormal.getX(), vert.mvNormal.getZ(), vert.mvNormal.getY());\n\t\t\t\tvert.mvTangent = new Vector3(vert.mvTangent.getX(), vert.mvTangent.getZ(), vert.mvTangent.getY());\n\t\t\t\tvert.mvBitangent = new Vector3(vert.mvBitangent.getX(), vert.mvBitangent.getZ(), vert.mvBitangent.getY());\n\t\t\t}\n\t\t\t\n\t\t\t//convert inverse bind matrices\n\t\t\tif (mesh.maInverseBindMatrices != null)\n\t\t\t{\n\t\t\t\tfor (int i = 0; i < mesh.maInverseBindMatrices.length; i++)\n\t\t\t\t{\t\n\t\t\t\t\tmesh.maInverseBindMatrices[i] = Matrix4.swapYandZ(mesh.maInverseBindMatrices[i]);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\t/**\n\t * Inverts the y component of the texture coordinates. This is because 3DS Max \n\t * uses the opposite coordinate system to what ChilliSource uses.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param in_model - The model.\n\t */\n\tprivate static void flipVerticalTexCoords(CSModel in_model)\n\t{\n\t\tfor (CSModelMesh mesh: in_model.mMeshTable.values())\n\t\t{\n\t\t\tfor (CSModelVertex vert: mesh.mVertexList)\n\t\t\t{\n\t\t\t\tvert.mvTextureCoordinate = new Vector2(vert.mvTextureCoordinate.getX(), 1.0f - vert.mvTextureCoordinate.getY());\n\t\t\t}\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/ColladaToCSModel/src/com/chilliworks/chillisource/colladatocsmodel/CSModelWeightIndexData.java",
    "content": "/**\n * CSModelWeightIndexData.java\n * ChilliSource\n * Created by Ian Copland on 15/01/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.colladatocsmodel;\n\npublic class CSModelWeightIndexData \n{\n\tint[][] mWeightIndices;\n\tint[][] mJointIndices;\n}\n"
  },
  {
    "path": "Projects/Tools/ColladaToCSModel/src/com/chilliworks/chillisource/colladatocsmodel/ColladaToCSModel.java",
    "content": "/**\n * ColladaToCSModel.java\n * ChilliSource\n * Created by Ian Copland on 15/01/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.colladatocsmodel;\n\nimport java.io.FileNotFoundException;\nimport java.util.LinkedList;\n\nimport javax.xml.parsers.SAXParser;\nimport javax.xml.parsers.SAXParserFactory;\n\nimport com.chilliworks.chillisource.colladaparserutils.ColladaParser;\nimport com.chilliworks.chillisource.colladaparserutils.colladadata.*;\nimport com.chilliworks.chillisource.colladatocsmodel.csmodel.CSModel;\nimport com.chilliworks.chillisource.colladatocsmodel.csmodel.CSModelMesh;\nimport com.chilliworks.chillisource.coreutils.*;\n\n/**\n * Provides methods for converting a Collada model file to CSModel.\n * \n * @author Ian Copland\n */\npublic final class ColladaToCSModel \n{\n\t/**\n\t * Converts from a Collada model file to CSModel.\n\t * \n\t * author Ian Copland\n\t * \n\t * @param in_options - The options.\n\t * \n\t * @throws Exception\n\t */\n\tpublic static void convert(ColladaToCSModelOptions inParams) throws Exception\n\t{\n\t\tCollada colladaData = new Collada();\n\t\ttry\n\t\t{\n\t\t\t//create the handler\n\t\t\tColladaParser handler = new ColladaParser(colladaData);\n\t\t\t\n\t\t\t//create the parser\n\t\t\tSAXParserFactory factory = SAXParserFactory.newInstance();\n\t\t\tSAXParser saxParser = factory.newSAXParser();\n\t\t\t\n\t\t\t//start reading the collada file\n\t\t\tsaxParser.parse(inParams.m_inputFilePath, handler);\n\t\t}\n\t\tcatch (FileNotFoundException e)\n\t\t{\n\t\t\tLogging.logFatal(\"Could not find file: \" + inParams.m_inputFilePath);\n\t\t}\n\t\tcatch (Exception e)\n\t\t{\n\t\t\tLogging.logFatal(\"Exception occurred while parsing the collada file. The following is the exception error message:\\n-\\n \" + StringUtils.convertExceptionToString(e) + \"-\");\n\t\t}\n\t\t\n\t\t//get the meshes to be exported\n\t\tLinkedList<String> nodes = new LinkedList<String>();\n\t\tfor (ColladaNode node : colladaData.mLibraryVisualScenes.get(colladaData.mScene.mInstanceVisualScene.mstrUrl.substring(1)).mRootNodes.values())\n\t\t{\n\t\t\tnodes.add(node.mstrId);\n\t\t}\n\t\t\n\t\t//convert to MoModel Format\n\t\tCSModelConverter converter = new CSModelConverter(); \n\t\tCSModel model = converter.ConvertToMoModelFormat(nodes, colladaData, inParams);\n\t\t\n\t\t//Check the momodel for warnings and errors\n\t\tModelChecker.CheckModel(model);\n\t\t\n\t\t//Modify the data to the intended output format\n\t\tCSModelTransformer.transform(inParams, model);\n\t\t\t\n\t\t//output info on the mo model mesh\n\t\toutputInfoOnMoModel(model);\n\n\t\t//output MoStatic file\n\t\tCSModelOutputer outputer = new CSModelOutputer();\n\t\t\n\t\tif (outputer.Output(inParams, model) == true)\n\t\t{\n\t\t\t//output info on output\n\t\t\toutputInfoOnOutput(inParams);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tLogging.logError(\"Output failed!\");\n\t\t}\n\t}\n\t/**\n\t * Prints information on the output mesh.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param in_options - The options.\n\t */\n\tprivate static void outputInfoOnMoModel(CSModel in_options)\n\t{\n\t\tLogging.logVerbose(\"MoModel Model Generated.\");\n\t\tLogging.logVerbose(\" Min Boundary: (\" + in_options.mvMin.getX() + \", \" + in_options.mvMin.getY() + \", \" + in_options.mvMin.getZ() + \")\");\n\t\tLogging.logVerbose(\" Max Boundary: (\" + in_options.mvMax.getX() + \", \" + in_options.mvMax.getY() + \", \" + in_options.mvMax.getZ() + \")\");\n\t\tLogging.logVerbose(\" Skeleton\");\n\t\tLogging.logVerbose(\"  Num Skeleton Nodes: \" + in_options.mSkeleton.mNodeList.size());\n\t\tLogging.logVerbose(\"   Number of which are Joints: \" + SkeletonBuilder.GetNumberOfJoints(in_options));\n\t\tLogging.logVerbose(\" Number of Meshes: \" + in_options.mMeshTable.size());\n\t\tfor (CSModelMesh mesh: in_options.mMeshTable.values())\n\t\t{\n\t\t\tLogging.logVerbose(\" Mesh \" + mesh.mstrName);\n\t\t\tLogging.logVerbose(\"  Number of Vertices: \" + mesh.mVertexList.size());\n\t\t\tLogging.logVerbose(\"  Number of Indices: \" + mesh.mIndexList.size());\n\t\t\tLogging.logVerbose(\"  Texture: \" + mesh.mstrTextureName);\n\t\t\tLogging.logVerbose(\"  Min Boundary: (\" + mesh.mvMin.getX() + \", \" + mesh.mvMin.getY() + \", \" + mesh.mvMin.getZ() + \")\");\n\t\t\tLogging.logVerbose(\"  Max Boundary: (\" + mesh.mvMax.getX() + \", \" + mesh.mvMax.getY() + \", \" + mesh.mvMax.getZ() + \")\");\n\t\t\tLogging.logVerbose(\"  Material\");\n\t\t\tLogging.logVerbose(\"   Emissive: (\" + mesh.mMaterial.mvEmissive.getX() + \", \" + mesh.mMaterial.mvEmissive.getY() + \", \" + mesh.mMaterial.mvEmissive.getZ() + \", \" + mesh.mMaterial.mvEmissive.getW() + \")\");\n\t\t\tLogging.logVerbose(\"   Ambient: (\" + mesh.mMaterial.mvAmbient.getX() + \", \" + mesh.mMaterial.mvAmbient.getY() + \", \" + mesh.mMaterial.mvAmbient.getZ() + \", \" + mesh.mMaterial.mvAmbient.getW() + \")\");\n\t\t\tLogging.logVerbose(\"   Diffuse: (\" + mesh.mMaterial.mvDiffuse.getX() + \", \" + mesh.mMaterial.mvDiffuse.getY() + \", \" + mesh.mMaterial.mvDiffuse.getZ() + \", \" + mesh.mMaterial.mvDiffuse.getW() + \")\");\n\t\t\tLogging.logVerbose(\"   Specular: (\" + mesh.mMaterial.mvSpecular.getX() + \", \" + mesh.mMaterial.mvSpecular.getY() + \", \" + mesh.mMaterial.mvSpecular.getZ() + \", \" + mesh.mMaterial.mvSpecular.getW() + \")\");\n\t\t\tLogging.logVerbose(\"   Shininess: \" + mesh.mMaterial.mfShininess);\n\t\t}\n\t}\n\t/**\n\t * Prints information on the output file.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param in_options - The options.\n\t */\n\tprivate static void outputInfoOnOutput(ColladaToCSModelOptions in_options)\n\t{\n\t\tLogging.logVerbose(\"Successfully created \" + in_options.m_outputFilePath);\n\t\tLogging.logVerbose(\" Features\");\n\t\tLogging.logVerbose(\"  Has Animation Data: \" + Boolean.toString(in_options.m_animated));\n\t\tLogging.logVerbose(\" Vertex Declaration\");\n\t\tLogging.logVerbose(\"  Position: \" + Boolean.toString(in_options.m_vertexHasPosition));\n\t\tLogging.logVerbose(\"  Normal: \" + Boolean.toString(in_options.m_vertexHasNormal));\n\t\tLogging.logVerbose(\"  Tangent: \" + Boolean.toString(in_options.m_vertexHasTangent));\n\t\tLogging.logVerbose(\"  Bitangent: \" + Boolean.toString(in_options.m_vertexHasBitangent));\n\t\tLogging.logVerbose(\"  Texture Coordinates: \" + Boolean.toString(in_options.m_vertexHasTexCoords));\n\t\tLogging.logVerbose(\"  Colour: \" + Boolean.toString(in_options.m_vertexHasColour));\n\t\tLogging.logVerbose(\"  Weights: \" + Boolean.toString(in_options.m_vertexHasWeights));\n\t\tLogging.logVerbose(\"  Joint Indices: \" + Boolean.toString(in_options.m_vertexHasJointIndices));\n\t\tLogging.logVerbose(\" Transforms\");\n\t\tLogging.logVerbose(\"  Flip vertical texture coordinates: \" + Boolean.toString(in_options.m_flipVerticalTexCoords));\n\t\tLogging.logVerbose(\"  Swap Y and Z: \" + Boolean.toString(in_options.m_swapYAndZ));\n\t\tLogging.logVerbose(\" \");\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/ColladaToCSModel/src/com/chilliworks/chillisource/colladatocsmodel/ColladaToCSModelOptions.java",
    "content": "/**\n * ColladaToCSModelOptions.java\n * ChilliSource\n * Created by Ian Copland on 15/01/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.colladatocsmodel;\n\n/**\n * A container for the input options for the Collada To CSModel tool.\n * \n * @author Ian Copland\n */\npublic final class ColladaToCSModelOptions \n{\n\tpublic String m_inputFilePath = \"\";\n\tpublic String m_outputFilePath = \"\";\n\tpublic boolean m_animated = false;\n\tpublic boolean m_swapHandedness = false;\n\tpublic boolean m_swapYAndZ = false;\n\tpublic boolean m_flipVerticalTexCoords = true;\n\tpublic boolean m_combineMeshes = true;\n\t\n\tpublic boolean m_vertexHasPosition = false;\n\tpublic boolean m_vertexHasTexCoords = false;\n\tpublic boolean m_vertexHasNormal = false;\n\tpublic boolean m_vertexHasTangent = false;\n\tpublic boolean m_vertexHasBitangent = false;\n\tpublic boolean m_vertexHasColour = false;\n\tpublic boolean m_vertexHasWeights = false;\n\tpublic boolean m_vertexHasJointIndices = false;\n}\n"
  },
  {
    "path": "Projects/Tools/ColladaToCSModel/src/com/chilliworks/chillisource/colladatocsmodel/Main.java",
    "content": "/**\n * Main.java\n * ChilliSource\n * Created by Ian Copland on 15/01/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.colladatocsmodel;\n\nimport com.chilliworks.chillisource.coreutils.*;\nimport com.chilliworks.chillisource.coreutils.Logging.LoggingLevel;\n\n/**\n * Provides the entry point into the application.\n * \n * @author Ian Copland\n */\npublic final class Main \n{\n\tprivate static final String k_paramNameInput = \"--input\";\n\tprivate static final String k_paramNameOutput = \"--output\";\n\tprivate static final String k_paramNameVertexFormat = \"--vertexformat\";\n\tprivate static final String k_paramNameAnimated = \"--animated\";\n\tprivate static final String k_paramNameSwapHandedness = \"--swaphandedness\";\n\tprivate static final String k_paramNameSwapYAndZ = \"--swapyandz\";\n\tprivate static final String k_paramNameDisableMeshBatch = \"--disablemeshbatch\";\n\tprivate static final String k_paramNameDisabletTexCoordFlip = \"--disabletexcoordflip\";\n\tprivate static final String k_paramNameHelp = \"--help\";\n\tprivate static final String k_shortParamNameInput = \"-i\";\n\tprivate static final String k_shortParamNameOutput = \"-o\";\n\tprivate static final String k_shortParamNameVertexFormat = \"-vf\";\n\tprivate static final String k_shortParamNameAnimated = \"-a\";\n\tprivate static final String k_shortParamNameSwapHandedness = \"-sh\";\n\tprivate static final String k_shortParamNameSwapYAndZ = \"-sy\";\n\tprivate static final String k_shortParamNameDisableMeshBatch = \"-dmb\";\n\tprivate static final String k_shortParamNameDisabletTexCoordFlip = \"-dtf\";\n\tprivate static final String k_shortParamNameHelp = \"-h\";\n\tprivate static final char k_vertexElementPosition = 'p';\n\tprivate static final char k_vertexElementTexCoord = 't';\n\tprivate static final char k_vertexElementNormal = 'n';\n\tprivate static final char k_vertexElementTangent = 'a';\n\tprivate static final char k_vertexElementBitangent = 'b';\n\tprivate static final char k_vertexElementColour = 'c';\n\tprivate static final char k_vertexElementWeights = 'w';\n\tprivate static final char k_vertexElementJoints = 'j';\n\t\n\t/**\n\t * The entry point into the application.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param in_args - The input arguments.\n\t */\n\tpublic static void main(String[] in_args) throws Exception \n\t{\n\t\t//setup the logger.\n\t\tString[] arguments = Logging.start(in_args);\n\t\t\n\t\t//check the number of arguments make sense.\n\t\tif (arguments.length == 0)\n\t\t{\n\t\t\tprintHelpText();\n\t\t\treturn;\n\t\t}\n\t\t\n\t\t//gather up commands\n\t\tboolean vertexDeclarationProvided = false;\n\t\tColladaToCSModelOptions params = new ColladaToCSModelOptions();\n\t\tfor (int i = 0; i < arguments.length; ++i)\n\t\t{\n\t\t\t//input\n\t\t\tif (arguments[i].equalsIgnoreCase(k_paramNameInput) == true || arguments[i].equalsIgnoreCase(k_shortParamNameInput) == true)\n\t\t\t{\n\t\t\t\tif (i+1 < arguments.length)\n\t\t\t\t\tparams.m_inputFilePath = StringUtils.standardiseFilePath(arguments[i+1]);\n\t\t\t\telse\n\t\t\t\t\tLogging.logFatal(\"No input file provided!\");\n\t\t\t\ti++;\n\t\t\t}\n\t\t\t\n\t\t\t//output\n\t\t\telse if (arguments[i].equalsIgnoreCase(k_paramNameOutput) == true || arguments[i].equalsIgnoreCase(k_shortParamNameOutput) == true)\n\t\t\t{\n\t\t\t\tif (i+1 < arguments.length)\n\t\t\t\t\tparams.m_outputFilePath = StringUtils.standardiseFilePath(arguments[i+1]);\n\t\t\t\telse\n\t\t\t\t\tLogging.logFatal(\"No output file provided!\");\n\t\t\t\ti++;\n\t\t\t}\n\t\t\t\n\t\t\t//vertex declaration\n\t\t\telse if (arguments[i].equalsIgnoreCase(k_paramNameVertexFormat) == true || arguments[i].equalsIgnoreCase(k_shortParamNameVertexFormat) == true)\n\t\t\t{\n\t\t\t\tvertexDeclarationProvided = true;\n\t\t\t\t\n\t\t\t\tif (i+1 < arguments.length)\n\t\t\t\t\tParseVertexDeclaration(params, arguments[i+1]);\n\t\t\t\telse\n\t\t\t\t\tLogging.logFatal(\"No vertex declaration provided!\");\n\t\t\t\ti++;\n\t\t\t}\n\t\t\t\n\t\t\t//animated\n\t\t\telse if (arguments[i].equalsIgnoreCase(k_paramNameAnimated) == true || arguments[i].equalsIgnoreCase(k_shortParamNameAnimated) == true)\n\t\t\t{\n\t\t\t\tparams.m_animated = true;\n\t\t\t}\n\t\t\t\n\t\t\t//animated\n\t\t\telse if (arguments[i].equalsIgnoreCase(k_paramNameSwapHandedness) == true || arguments[i].equalsIgnoreCase(k_shortParamNameSwapHandedness) == true)\n\t\t\t{\n\t\t\t\tparams.m_swapHandedness = true;\n\t\t\t}\n\t\t\t\n\t\t\t//animated\n\t\t\telse if (arguments[i].equalsIgnoreCase(k_paramNameSwapYAndZ) == true || arguments[i].equalsIgnoreCase(k_shortParamNameSwapYAndZ) == true)\n\t\t\t{\n\t\t\t\tparams.m_swapYAndZ = true;\n\t\t\t}\n\t\t\t\n\t\t\t//animated\n\t\t\telse if (arguments[i].equalsIgnoreCase(k_paramNameDisableMeshBatch) == true || arguments[i].equalsIgnoreCase(k_shortParamNameDisableMeshBatch) == true)\n\t\t\t{\n\t\t\t\tparams.m_combineMeshes = false;\n\t\t\t}\n\t\t\t\n\t\t\t//animated\n\t\t\telse if (arguments[i].equalsIgnoreCase(k_paramNameDisabletTexCoordFlip) == true || arguments[i].equalsIgnoreCase(k_shortParamNameDisabletTexCoordFlip) == true)\n\t\t\t{\n\t\t\t\tparams.m_flipVerticalTexCoords = false;\n\t\t\t}\n\t\t\t\n\t\t\t//help\n\t\t\telse if (arguments[i].equalsIgnoreCase(k_paramNameHelp) == true || arguments[i].equalsIgnoreCase(k_shortParamNameHelp) == true)\n\t\t\t{\n\t\t\t\tprintHelpText();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t\n\t\t\t//failure\n\t\t\telse\n\t\t\t{\n\t\t\t\tLogging.logFatal(\"Invalid argument found: \" + arguments[i]);\n\t\t\t}\n\t\t}\n\t\t\n\t\tif (vertexDeclarationProvided == false)\n\t\t{\n\t\t\tapplyDefaultVertexFormat(params);\n\t\t}\n\t\t\n\t\t//check for weird combinations of parameters\n\t\tParamsChecker.CheckParameters(params);\n\t\t\n\t\tColladaToCSModel.convert(params);\n\t\t\n\t\tLogging.finish();\n\t}\n\t//-------------------------------------------------------------------\n\t/// Parse Vertex Declaration\n\t///\n\t/// Parses a string vertex declaration.\n\t///\n\t/// @param the conversion params.\n\t/// @param the string to parse.\n\t//-------------------------------------------------------------------\n\tstatic void ParseVertexDeclaration(ColladaToCSModelOptions inParams, String instrVertexDecl)\n\t{\n\t\tfor (int i = 0; i < instrVertexDecl.length(); ++i)\n\t\t{\n\t\t\tif (instrVertexDecl.charAt(i) == k_vertexElementPosition)\n\t\t\t\tinParams.m_vertexHasPosition = true;\n\t\t\tif (instrVertexDecl.charAt(i) == k_vertexElementNormal)\n\t\t\t\tinParams.m_vertexHasNormal = true;\n\t\t\tif (instrVertexDecl.charAt(i) == k_vertexElementTangent)\n\t\t\t\tinParams.m_vertexHasTangent = true;\n\t\t\tif (instrVertexDecl.charAt(i) == k_vertexElementBitangent)\n\t\t\t\tinParams.m_vertexHasBitangent = true;\n\t\t\tif (instrVertexDecl.charAt(i) == k_vertexElementTexCoord)\n\t\t\t\tinParams.m_vertexHasTexCoords = true;\n\t\t\tif (instrVertexDecl.charAt(i) == k_vertexElementColour)\n\t\t\t\tinParams.m_vertexHasColour = true;\n\t\t\tif (instrVertexDecl.charAt(i) == k_vertexElementWeights)\n\t\t\t\tinParams.m_vertexHasWeights = true;\n\t\t\tif (instrVertexDecl.charAt(i) == k_vertexElementJoints)\n\t\t\t\tinParams.m_vertexHasJointIndices = true;\n\t\t}\n\t}\n\t/**\n\t * Applies the default vertex format. This always includes position, tex coordinates\n\t * and normals. For animated models this also includes weights and joints.\n\t * \n\t * @param Ian Copland\n\t * \n\t * @param in_options - The options to apply the default to.\n\t */\n\tstatic void applyDefaultVertexFormat(ColladaToCSModelOptions in_options)\n\t{\n\t\tin_options.m_vertexHasPosition = true;\n\t\tin_options.m_vertexHasTexCoords = true;\n\t\tin_options.m_vertexHasNormal = true;\n\t\tin_options.m_vertexHasTangent = true;\n\t\tin_options.m_vertexHasBitangent = true;\n\t\tin_options.m_vertexHasColour = false;\n\t\t\n\t\tif (in_options.m_animated == true)\n\t\t{\n\t\t\tin_options.m_vertexHasJointIndices = true;\n\t\t\tin_options.m_vertexHasWeights = true;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tin_options.m_vertexHasJointIndices = false;\n\t\t\tin_options.m_vertexHasWeights = false;\n\t\t}\n\t}\n\t/**\n\t * Prints the help text. This will print regardless of logging level.\n\t * \n\t * @param Ian Copland\n\t */\n\tpublic static void printHelpText()\n\t{\n\t\tLogging.setLoggingLevel(LoggingLevel.VERBOSE);\n\t\tLogging.logVerbose(\"Usage: java -jar ColladaToCSModel.jar \" + k_paramNameInput + \" <file path> \" + k_paramNameOutput + \" <file path> [\" + k_paramNameVertexFormat + \" <vertex declaration>] [\" + k_paramNameAnimated + \"] [\" + k_paramNameSwapHandedness + \"] [\" + k_paramNameSwapYAndZ + \"] [\" + k_paramNameDisableMeshBatch + \"] [\" + k_paramNameDisabletTexCoordFlip + \"] [\" + k_paramNameHelp + \"] [\" + Logging.PARAM_LOGGING_LEVEL + \" <level>]\");\n\t\tLogging.logVerbose(\"Parameters:\");\n\t\tLogging.logVerbose(\" \" + k_paramNameInput + \"(\" + k_shortParamNameInput + \"): The input filename.\");\n\t\tLogging.logVerbose(\" \" + k_paramNameOutput + \"(\" + k_shortParamNameOutput + \"): The output filename.\");\n\t\tLogging.logVerbose(\" \" + k_paramNameVertexFormat + \"(\" + k_shortParamNameVertexFormat + \"): [Optional] A list of elements that a vertex in this model will contain.\");\n\t\tLogging.logVerbose(\" \" + k_paramNameAnimated + \"(\" + k_shortParamNameAnimated + \"): [Optional] Enables outputting of animation data.\");\n\t\tLogging.logVerbose(\" \" + k_paramNameSwapHandedness + \"(\" + k_shortParamNameSwapHandedness + \"): [Optional] Enables transforming the output data to swap the coordinate system handedness.\");\n\t\tLogging.logVerbose(\" \" + k_paramNameSwapYAndZ + \"(\" + k_shortParamNameSwapYAndZ + \"): [Optional] Enables transforming the output data to swap the Y and Z coordinates.\");\n\t\tLogging.logVerbose(\" \" + k_paramNameDisableMeshBatch + \"(\" + k_shortParamNameDisableMeshBatch + \"): [Optional] Disables batching meshes with the same material together.\");\n\t\tLogging.logVerbose(\" \" + k_paramNameDisabletTexCoordFlip + \"(\" + k_shortParamNameDisabletTexCoordFlip + \"): [Optional] Disables flipping the Y component of the texture coordinates.\");\n\t\tLogging.logVerbose(\" \" + Logging.PARAM_LOGGING_LEVEL + \"(\" + Logging.SHORT_PARAM_LOGGING_LEVEL + \"): [Optional] The level of messages to log.\");\n\t\tLogging.logVerbose(\" \" + k_paramNameHelp + \"(\" + k_shortParamNameHelp + \"): [Optional] Display this help message.\");\n\t\tLogging.logVerbose(\"Vertex Elements:\");\n\t\tLogging.logVerbose(\" \" + k_vertexElementPosition + \": A vertex will contain a position.\");\n\t\tLogging.logVerbose(\" \" + k_vertexElementTexCoord + \": A vertex will contain texture coordinates.\");\n\t\tLogging.logVerbose(\" \" + k_vertexElementNormal + \": A vertex will contain a normal.\");\n\t\tLogging.logVerbose(\" \" + k_vertexElementTangent + \": A vertex will contain a tangent to the normal.\");\n\t\tLogging.logVerbose(\" \" + k_vertexElementBitangent + \": A vertex will contain a bitangent to the tangent.\");\n\t\tLogging.logVerbose(\" \" + k_vertexElementColour + \": A vertex will contain a colour.\");\n\t\tLogging.logVerbose(\" \" + k_vertexElementWeights + \": A vertex will contain weights.\");\n\t\tLogging.logVerbose(\" \" + k_vertexElementJoints + \": A vertex will contain joint indices.\");\n\t\tLogging.logVerbose(\"Logging Levels:\");\n\t\tLogging.logVerbose(\" \" + Logging.LOGGING_LEVEL_NONE + \": No logging.\");\n\t\tLogging.logVerbose(\" \" + Logging.LOGGING_LEVEL_FATAL + \": Only log fatal errors.\");\n\t\tLogging.logVerbose(\" \" + Logging.LOGGING_LEVEL_ERROR + \": Only log errors.\");\n\t\tLogging.logVerbose(\" \" + Logging.LOGGING_LEVEL_WARNING + \": Log errors and warnings.\");\n\t\tLogging.logVerbose(\" \" + Logging.LOGGING_LEVEL_VERBOSE + \": Log all messages.\");\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/ColladaToCSModel/src/com/chilliworks/chillisource/colladatocsmodel/ModelChecker.java",
    "content": "/**\n * ModelChecker.java\n * ChilliSource\n * Created by Ian Copland on 18/04/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.colladatocsmodel;\n\nimport com.chilliworks.chillisource.colladatocsmodel.csmodel.CSModel;\nimport com.chilliworks.chillisource.colladatocsmodel.csmodel.CSModelMesh;\nimport com.chilliworks.chillisource.coreutils.Logging;\n\npublic class ModelChecker \n{\n\tstatic final int kdwMaxUnsignedShort = 65536;\n\t//----------------------------------------------------\n\t/// Check Model\n\t///\n\t/// Checks whether the model will be able to be\n\t/// loaded into ChilliSource. This checks things like\n\t/// triangle count and number of mesh influencing joints.\n\t///\n\t/// @param The model.\n\t//----------------------------------------------------\n\tstatic public void CheckModel(CSModel inModel)\n\t{\n\t\t//Test that the model is not too big for ChilliSource to render.\n\t\tboolean bContainsLargeMesh = false;\n\t\tfor (CSModelMesh mesh : inModel.mMeshTable.values())\n\t\t{\n\t\t\tboolean bFoundLargeIndex = false;\n\t\t\tfor (Integer dwIndex : mesh.mIndexList)\n\t\t\t{\n\t\t\t\tif (dwIndex > kdwMaxUnsignedShort)\n\t\t\t\t{\n\t\t\t\t\tbFoundLargeIndex = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tif (bFoundLargeIndex == true || mesh.mIndexList.size() > kdwMaxUnsignedShort)\n\t\t\t{\n\t\t\t\tbContainsLargeMesh = true;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (bContainsLargeMesh == true)\n\t\t{\n\t\t\tLogging.logWarning(\"Mesh is too large! This model will require integer indices to render which ChilliSource currently does not support!\");\n\t\t}\n\t\t\n\t\t//test the amount of skeleton nodes\n\t\tif (inModel.mSkeleton.mNodeList.size() > 256)\n\t\t{\n\t\t\tLogging.logWarning(\"The skeleton contains a huge number of nodes! Over 256 nodes is probably too many.\");\n\t\t}\n\t\t\n\t\t//test the amount of joints\n\t\tif (SkeletonBuilder.GetNumberOfJoints(inModel) > 60)\n\t\t{\n\t\t\tLogging.logWarning(\"The skeleton contains a huge number of joints! Over 60 nodes is probably too many.\");\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/ColladaToCSModel/src/com/chilliworks/chillisource/colladatocsmodel/ParamsChecker.java",
    "content": "/**\n * ParamsChecker.java\n * ChilliSource\n * Created by Ian Copland on 18/04/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.colladatocsmodel;\n\nimport com.chilliworks.chillisource.coreutils.Logging;\n\npublic class ParamsChecker \n{\n\t//----------------------------------------------------\n\t/// Check Parameters\n\t///\n\t/// Checks the input parameters for anything weird\n\t/// and throws a warning if it finds anything.\n\t///\n\t/// @param the parameters.\n\t//----------------------------------------------------\n\tstatic public void CheckParameters(ColladaToCSModelOptions inParams)\n\t{\n\t\tif (inParams.m_inputFilePath.length() == 0 || inParams.m_outputFilePath.length() == 0)\n\t\t{\n\t\t\tLogging.logFatal(\"Must provide an input and output file path.\");\n\t\t}\n\t\t\n\t\t//check for no positional data\n\t\tif (inParams.m_vertexHasPosition == false)\n\t\t{\n\t\t\tLogging.logWarning(\"The 'positions' vertex element is not enabled meaning the output model will have no vertex position data.\");\n\t\t}\n\t\t\n\t\t//check for use of animation without the animation vertex elements\n\t\tif (inParams.m_animated == true && (inParams.m_vertexHasJointIndices == false || inParams.m_vertexHasWeights == false))\n\t\t{\n\t\t\tLogging.logWarning(\"The 'Animation Data' feature is being used without both the animation vertex elements('Joint Indices' and 'Weights') enabled.\");\n\t\t}\n\t\t\n\t\t//check for use of the animation vertex elements without animation data\n\t\tif (inParams.m_animated == false && (inParams.m_vertexHasJointIndices == true || inParams.m_vertexHasWeights == true))\n\t\t{\n\t\t\tLogging.logWarning(\"Animation vertex elements(joint indices or weights) are being used without the 'Animation Data' feature enabled.\");\n\t\t}\n\t\t\t\t\n\t\t//check for use of combine meshes with an animated model.\n\t\tif (inParams.m_animated == true && inParams.m_combineMeshes == true)\n\t\t{\n\t\t\tLogging.logWarning(\"Combine meshes is enabled for an animated mesh. This will break the animation data, so turning it off.\");\n\t\t\tinParams.m_combineMeshes = false;\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/ColladaToCSModel/src/com/chilliworks/chillisource/colladatocsmodel/SkeletonBuilder.java",
    "content": "/**\n * SkeletonBuilder.java\n * ChilliSource\n * Created by Ian Copland on 18/04/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.colladatocsmodel;\n\nimport java.util.Collections;\nimport java.util.LinkedList;\n\nimport com.chilliworks.chillisource.colladaparserutils.colladadata.ColladaNode;\nimport com.chilliworks.chillisource.colladaparserutils.colladadata.ColladaNode.COLLADA_NODE_TYPE;\nimport com.chilliworks.chillisource.colladatocsmodel.csmodel.CSModel;\nimport com.chilliworks.chillisource.colladatocsmodel.csmodel.CSModelSkeleton;\nimport com.chilliworks.chillisource.colladatocsmodel.csmodel.CSModelSkeletonNode;\nimport com.chilliworks.chillisource.coreutils.Logging;\n\npublic class SkeletonBuilder \n{\n\t//-------------------------------------------------------------------\n\t/// Try Build Skeleton\n\t///\n\t/// Tries to build the skeleton if it has not already been built. \n\t/// If it has already been built, this then confirms that it is using \n\t/// the same skeleton.\n\t//-------------------------------------------------------------------\n\tstatic public void TryBuildSkeleton(LinkedList<ColladaNode> inNodes, String instrSkeletonName, CSModel inModel)\n\t{\n\t\tif (inModel.mSkeleton.mbLocked == false)\n\t\t{\n\t\t\tBuildSkeleton(inNodes, instrSkeletonName, inModel);\n\t\t\tOrderSkeleton(inModel);\n\t\t\tinModel.mSkeleton.mbLocked = true;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tCSModel testModel = new CSModel();\n\t\t\tBuildSkeleton(inNodes, instrSkeletonName, testModel);\n\t\t\tOrderSkeleton(testModel);\n\t\t\t\n\t\t\tif (CompareSkeletons(inModel.mSkeleton, testModel.mSkeleton) == false)\n\t\t\t{\n\t\t\t\tString strRootNode1 = \"\", strRootNode2 = \"\";\n\t\t\t\tif (inModel.mSkeleton.mNodeList.size() > 0)\n\t\t\t\t\tstrRootNode1 = inModel.mSkeleton.mNodeList.get(0).mstrName;\n\t\t\t\tif (testModel.mSkeleton.mNodeList.size() > 0)\n\t\t\t\t\tstrRootNode2 = testModel.mSkeleton.mNodeList.get(0).mstrName;\n\t\t\t\tLogging.logFatal(\"A second skeleton has been found. All meshes must be attached to the same skeleton. Attaching a mesh to a subset of the skeleton counts as a different skeleton. The two different skeleton root nodes are: '\" + strRootNode1 + \"' and '\" + strRootNode2 + \"'\");\n\t\t\t}\n\t\t}\n\t}\n\t//-------------------------------------------------------------------\n\t/// Compare Skeletons\n\t///\n\t/// Compares the two skeletons to see if all relevent data in them \n\t/// is the same.\n\t//-------------------------------------------------------------------\n\tstatic private boolean CompareSkeletons(CSModelSkeleton inSkeleton1, CSModelSkeleton inSkeleton2)\n\t{\n\t\t//check the list counts are the same\n\t\tif (inSkeleton1.mNodeList.size() != inSkeleton2.mNodeList.size())\n\t\t\treturn false;\n\t\t\n\t\t//check all the joints\n\t\tfor (int i = 0; i < inSkeleton1.mNodeList.size(); i++)\n\t\t{\n\t\t\tCSModelSkeletonNode node1 = inSkeleton1.mNodeList.get(i);\n\t\t\tCSModelSkeletonNode node2 = inSkeleton2.mNodeList.get(i);\n\t\t\t\n\t\t\tif (node1.mstrName.equals(node2.mstrName) == false)\n\t\t\t\treturn false;\n\t\t\tif (node1.mdwParentNodeIndex != node2.mdwParentNodeIndex)\n\t\t\t\treturn false;\n\t\t}\n\t\t\n\t\treturn true;\n\t}\n\t//-------------------------------------------------------------------\n\t/// Build Skeleton\n\t///\n\t/// builds to the skeleton.\n\t//-------------------------------------------------------------------\n\tstatic private boolean BuildSkeleton(LinkedList<ColladaNode> inNodes, String instrSkeletonName, CSModel inModel)\n\t{\n\t\t//find the \"root\" node that we are using\n\t\tfor (ColladaNode node : inNodes)\n\t\t{\n\t\t\tif (node.mstrId.equals(instrSkeletonName))\n\t\t\t{\n\t\t\t\t//build skeleton\n\t\t\t\tAddToSkeleton(node, null, inModel);\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tif (BuildSkeleton(new LinkedList<ColladaNode>(node.mChildNodes.values()), instrSkeletonName, inModel) == true)\n\t\t\t\t{\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\treturn false;\n\t}\n\t//-------------------------------------------------------------------\n\t/// Add To Skeleton\n\t///\n\t/// Adds a node tree to the skeleton.\n\t//-------------------------------------------------------------------\n\tstatic private void AddToSkeleton(ColladaNode inNode, ColladaNode inParent, CSModel inModel)\n\t{\n\t\t//if its a skeleton node, then add it to the skeleton node list\n\t\tif (inNode.meType == COLLADA_NODE_TYPE.JOINT || inNode.meType == COLLADA_NODE_TYPE.BASE)\n\t\t{\n\t\t\tTryAddSkeletonNode(inNode, inParent, inModel);\n\t\t\tfor (ColladaNode node: inNode.mChildNodes.values())\n\t\t\t{\n\t\t\t\tAddToSkeleton(node, inNode, inModel);\n\t\t\t}\n\t\t}\n\t}\n\t//-------------------------------------------------------------------\n\t/// Try Add Skeleton Node\n\t///\n\t/// Tries to add a joint to the skeleton.\n\t//-------------------------------------------------------------------\n\tstatic private void TryAddSkeletonNode(ColladaNode inNode, ColladaNode inParent, CSModel inModel)\n\t{\n\t\t//check and see if this node already exists\n\t\tfor (int i = 0; i < inModel.mSkeleton.mNodeList.size(); i++)\n\t\t{\n\t\t\tCSModelSkeletonNode node = inModel.mSkeleton.mNodeList.get(i);\n\t\t\tif (node.mstrId.equalsIgnoreCase(inNode.mstrId))\n\t\t\t{\n\t\t\t\t//if the node does already exist, then make sure the parent is correct\n\t\t\t\tif (node.mstrParentId.length() == 0 && inParent != null)\n\t\t\t\t{\n\t\t\t\t\tnode.mstrParentId = inParent.mstrId;\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\t\n\t\t//create a new skeleton node\n\t\tCSModelSkeletonNode newSkeletonNode = new CSModelSkeletonNode();\n\t\tnewSkeletonNode.mstrName = inNode.mstrName;\n\t\tnewSkeletonNode.mstrId = inNode.mstrId;\n\t\tif (inParent != null)\n\t\t{\n\t\t\tnewSkeletonNode.mstrParentId = inParent.mstrId;\n\t\t}\n\t\t\n\t\t//if it's a joint store the SId.\n\t\tif (inNode.meType == COLLADA_NODE_TYPE.JOINT)\n\t\t{\n\t\t\tnewSkeletonNode.mbIsJoint = true;\n\t\t\tnewSkeletonNode.mstrSId = inNode.mstrSId;\n\t\t}\n\t\t\n\t\t//add the joint\n\t\tinModel.mSkeleton.mNodeList.add(newSkeletonNode);\n\t}\n\t//-------------------------------------------------------------------\n\t/// Order Skeleton\n\t///\n\t/// Orders the skeleton based on the joints ordering index. The parent \n\t/// indices for each joint, and the joint index for each attachment \n\t/// point are then calculated.\n\t//-------------------------------------------------------------------\n\tstatic private void OrderSkeleton(CSModel inModel)\n\t{\n\t\tCollections.sort(inModel.mSkeleton.mNodeList, new SkeletonNodeComparator());\n\t\t\n\t\tint dwJointCount = 0;\n\t\t\n\t\t//iterator the list and get the parent indices\n\t\tfor (CSModelSkeletonNode node : inModel.mSkeleton.mNodeList)\n\t\t{\n\t\t\tif (node.mbIsJoint == true)\n\t\t\t{\n\t\t\t\tnode.mdwJointIndex = dwJointCount;\n\t\t\t\tdwJointCount++;\n\t\t\t}\n\t\t\tnode.mdwParentNodeIndex = GetIndexOfSkeletonNodeById(inModel, node.mstrParentId);\n\t\t}\n\t}\n\t//-------------------------------------------------------------------\n\t/// Get Index Of Skeleton Node By Id\n\t///\n\t/// @return The index of the skeleton node with the passed in id.\n\t//-------------------------------------------------------------------\n\tstatic private int GetIndexOfSkeletonNodeById(CSModel inModel, String instrId)\n\t{\n\t\tfor (int i = 0; i < inModel.mSkeleton.mNodeList.size(); i++)\n\t\t{\n\t\t\tCSModelSkeletonNode node = inModel.mSkeleton.mNodeList.get(i);\n\t\t\tif (node.mstrId.equalsIgnoreCase(instrId))\n\t\t\t{\n\t\t\t\treturn i;\n\t\t\t}\n\t\t}\n\t\treturn -1;\n\t}\n\t//-------------------------------------------------------------------\n\t/// Get Index Of Joint By SId\n\t///\n\t/// @return The index of the joint with the passed in name.\n\t//-------------------------------------------------------------------\n\tstatic public int GetIndexOfJointBySId(CSModel inModel, String instrSId)\n\t{\n\t\tfor (int i = 0; i < inModel.mSkeleton.mNodeList.size(); i++)\n\t\t{\n\t\t\tCSModelSkeletonNode node = inModel.mSkeleton.mNodeList.get(i);\n\t\t\tif (node.mbIsJoint == true && node.mstrSId.equalsIgnoreCase(instrSId))\n\t\t\t{\n\t\t\t\treturn node.mdwJointIndex;\n\t\t\t}\n\t\t}\n\t\t\n\t\treturn -1;\n\t}\n\t//-------------------------------------------------------------------\n\t/// Get Number of Joints\n\t///\n\t/// @return The number of joints in the given skeleton\n\t//-------------------------------------------------------------------\n\tstatic public int GetNumberOfJoints(CSModel inModel)\n\t{\n\t\tint dwCount = 0;\n\t\tfor (int i = 0; i < inModel.mSkeleton.mNodeList.size(); i++)\n\t\t{\n\t\t\tCSModelSkeletonNode node = inModel.mSkeleton.mNodeList.get(i);\n\t\t\tif (node.mbIsJoint == true)\n\t\t\t{\n\t\t\t\tdwCount++;\n\t\t\t}\n\t\t}\n\t\treturn dwCount;\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/ColladaToCSModel/src/com/chilliworks/chillisource/colladatocsmodel/SkeletonNodeComparator.java",
    "content": "/**\n * SkeletonNodeComparator.java\n * ChilliSource\n * Created by Ian Copland on 15/01/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.colladatocsmodel;\n\nimport java.util.Comparator;\n\nimport com.chilliworks.chillisource.colladatocsmodel.csmodel.CSModelSkeletonNode;\n\npublic class SkeletonNodeComparator implements Comparator<CSModelSkeletonNode>\n{\n\t//-------------------------------------------------------------------\n\t/// Compare\n\t///\n\t/// Compares two MoModelSkeletonNode\n\t//-------------------------------------------------------------------\n\tpublic int compare(CSModelSkeletonNode inJoint1, CSModelSkeletonNode inJoint2)\n\t{\n\t\t\n\t\tif (inJoint1.mstrParentId.compareTo(inJoint2.mstrParentId) > 0)\n\t\t\treturn 1;\n\t\telse if (inJoint1.mstrParentId.compareTo(inJoint2.mstrParentId) < 0)\n\t\t\treturn -1;\n\t\telse\n\t\t\treturn 0;\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/ColladaToCSModel/src/com/chilliworks/chillisource/colladatocsmodel/UserPropertiesParser.java",
    "content": "/**\n * UserPropertiesParser.java\n * ChilliSource\n * Created by Ian Copland on 15/01/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.colladatocsmodel;\n\nimport java.util.Hashtable;\n\npublic class UserPropertiesParser \n{\n\t//-------------------------------------------------------\n\t/// Parse\n\t///\n\t/// Parses the user data string into a hash table of\n\t/// properties.\n\t///\n\t/// @param the string.\n\t/// @param the output properties.\n\t//-------------------------------------------------------\n\tstatic public Hashtable<String, String> Parse(String instrData)\n\t{\n\t\tHashtable<String, String> properties = new Hashtable<String, String>();\n\t\t\n\t\t//first of all break into statements\n\t\tString[] strStatements = instrData.split(\"\\n|\\r|;\");\n\t\t\n\t\t//now iterate over each statement, removing all whitespace then splitting into key and value.\n\t\tfor (int i = 0; i < strStatements.length; i++)\n\t\t{\n\t\t\tstrStatements[i] = strStatements[i].replaceAll(\" |\\t\", \"\");\n\t\t\tString[] strSplit = strStatements[i].split(\"=\");\n\t\t\tif (strSplit.length == 2)\n\t\t\t{\n\t\t\t\tproperties.put(strSplit[0], strSplit[1]);\n\t\t\t}\n\t\t}\n\t\t\n\t\treturn properties;\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/ColladaToCSModel/src/com/chilliworks/chillisource/colladatocsmodel/csmodel/CSModel.java",
    "content": "/**\n * CSModel.h\n * ChilliSource\n * Created by Ian Copland on 15/01/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.colladatocsmodel.csmodel;\n\nimport java.util.Hashtable;\n\nimport com.chilliworks.chillisource.coreutils.Vector3;\n\npublic class CSModel\n{\n\t/**\n\t * Private data\n\t */\n\tpublic Hashtable<String, CSModelMesh> mMeshTable;\n\tpublic Vector3 mvMax;\n\tpublic Vector3 mvMin;\n\tpublic CSModelSkeleton mSkeleton;\n\t\n\t/**\n\t * Constructor\n\t */\n\tpublic CSModel()\n\t{\n\t\tmMeshTable = new Hashtable<String, CSModelMesh>();\n\t\tmvMax = new Vector3(-Float.MAX_VALUE, -Float.MAX_VALUE, -Float.MAX_VALUE);\n\t\tmvMin = new Vector3(Float.MAX_VALUE, Float.MAX_VALUE, Float.MAX_VALUE);\n\t\tmSkeleton = new CSModelSkeleton();\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/ColladaToCSModel/src/com/chilliworks/chillisource/colladatocsmodel/csmodel/CSModelMaterial.java",
    "content": "/**\n * CSModelMaterial.h\n * ChilliSource\n * Created by Ian Copland on 15/01/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.colladatocsmodel.csmodel;\n\nimport com.chilliworks.chillisource.coreutils.Vector4;\n\npublic class CSModelMaterial \n{\n\tpublic Vector4 mvEmissive;\n\tpublic Vector4 mvAmbient;\n\tpublic Vector4 mvDiffuse;\n\tpublic Vector4 mvSpecular;\n\tpublic float mfShininess;\n\tpublic String mstrName;\n\t\n\tpublic CSModelMaterial()\n\t{\n\t\tmvEmissive = Vector4.ZERO;\n\t\tmvAmbient = Vector4.ZERO;\n\t\tmvDiffuse = Vector4.ZERO;\n\t\tmvSpecular = Vector4.ZERO;\n\t\tmfShininess = 0.0f;\n\t\tmstrName = new String();\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/ColladaToCSModel/src/com/chilliworks/chillisource/colladatocsmodel/csmodel/CSModelMesh.java",
    "content": "/**\n * CSModelMesh.h\n * ChilliSource\n * Created by Ian Copland on 15/01/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.colladatocsmodel.csmodel;\n\nimport java.util.LinkedList;\n\nimport com.chilliworks.chillisource.coreutils.Matrix4;\nimport com.chilliworks.chillisource.coreutils.Vector3;\n\npublic class CSModelMesh \n{\n\tpublic LinkedList<CSModelVertex> mVertexList;\n\tpublic LinkedList<Integer> mIndexList;\n\tpublic String mstrTextureName;\n\tpublic CSModelMaterial mMaterial;\n\tpublic Vector3 mvMax;\n\tpublic Vector3 mvMin;\n\tpublic String mstrName;\n\tpublic CSModelSkeleton mSkeleton;\n\tpublic Matrix4[] maInverseBindMatrices;\n\t\n\tpublic CSModelMesh()\n\t{\n\t\tmaInverseBindMatrices = null;\n\t\tmVertexList = new LinkedList<CSModelVertex>();\n\t\tmIndexList = new LinkedList<Integer>();\n\t\tmvMax = new Vector3(-Float.MAX_VALUE, -Float.MAX_VALUE, -Float.MAX_VALUE);\n\t\tmvMin = new Vector3(Float.MAX_VALUE, Float.MAX_VALUE, Float.MAX_VALUE);\n\t\tmstrTextureName = new String();\n\t\tmMaterial = new CSModelMaterial();\n\t\tmstrName = new String();\n\t\tmSkeleton = new CSModelSkeleton();\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/ColladaToCSModel/src/com/chilliworks/chillisource/colladatocsmodel/csmodel/CSModelSkeleton.java",
    "content": "/**\n * CSModelSkeleton.h\n * ChilliSource\n * Created by Ian Copland on 15/01/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.colladatocsmodel.csmodel;\n\nimport java.util.LinkedList;\n\npublic class CSModelSkeleton \n{\n\tpublic LinkedList<CSModelSkeletonNode> mNodeList;\n\tpublic boolean mbLocked;\n\t\n\tpublic CSModelSkeleton()\n\t{\n\t\tmNodeList = new LinkedList<CSModelSkeletonNode>();\n\t\tmbLocked = false;\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/ColladaToCSModel/src/com/chilliworks/chillisource/colladatocsmodel/csmodel/CSModelSkeletonNode.java",
    "content": "/**\n * CSModelJoint.h\n * ChilliSource\n * Created by Ian Copland on 15/01/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.colladatocsmodel.csmodel;\n\npublic class CSModelSkeletonNode\n{\n\tenum SKELETON_NODE_TYPE\n\t{\n\t\tSTANDARD,\n\t\tJOINT\n\t}\n\tpublic String mstrId;\n\tpublic String mstrParentId;\n\tpublic String mstrName;\n\tSKELETON_NODE_TYPE meType;\n\tpublic int mdwParentNodeIndex;\n\n\t//Joint specific stuff\n\tpublic boolean mbIsJoint;\n\tpublic String mstrSId;\n\tpublic int mdwJointIndex; \n\t\n\tpublic CSModelSkeletonNode()\n\t{\n\t\tmstrId = new String();\n\t\tmstrParentId = new String();\n\t\tmstrName = new String();\n\t\tmdwParentNodeIndex = -1;\n\t\t\n\t\tmbIsJoint = false;\n\t\tmstrSId = new String();\n\t\tmdwJointIndex = -1;\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/ColladaToCSModel/src/com/chilliworks/chillisource/colladatocsmodel/csmodel/CSModelVertex.java",
    "content": "/**\n * CSModelVertex.h\n * ChilliSource\n * Created by Ian Copland on 15/01/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.colladatocsmodel.csmodel;\n\nimport com.chilliworks.chillisource.coreutils.Integer4;\nimport com.chilliworks.chillisource.coreutils.Vector2;\nimport com.chilliworks.chillisource.coreutils.Vector3;\nimport com.chilliworks.chillisource.coreutils.Vector4;\n\n\npublic class CSModelVertex \n{\n\tpublic Vector3 mvPosition;\n\tpublic Vector3 mvNormal;\n\tpublic Vector3 mvTangent;\n\tpublic Vector3 mvBitangent;\n\tpublic Vector2 mvTextureCoordinate;\n\tpublic Vector4 mvVertexColour;\n\tpublic Vector4 mvWeights;\n\tpublic Integer4 mvJointIndices;\n\t\n\tpublic CSModelVertex()\n\t{\n\t\tmvPosition = Vector3.ZERO;\n\t\tmvNormal = Vector3.ZERO;\n\t\tmvTangent = Vector3.ZERO;\n\t\tmvBitangent = Vector3.ZERO;\n\t\tmvTextureCoordinate = Vector2.ZERO;\n\t\tmvVertexColour = Vector4.ZERO;\n\t\tmvWeights = Vector4.ZERO;\n\t\tmvJointIndices = Integer4.ZERO;\n\t}\n\n\tpublic boolean equals(Object inObj)\n\t{\n\t    if (this == inObj)\n\t    {\n\t    \treturn true;\n\t    }\n\t    else if ((inObj instanceof CSModelVertex) == false)\n\t    {\n\t    \treturn false;\n\t    }\n\t    \n\t    CSModelVertex vertex = (CSModelVertex)inObj;\n\t    if (mvPosition.equals(vertex.mvPosition) && mvNormal.equals(vertex.mvNormal) && mvTangent.equals(vertex.mvTangent) && mvBitangent.equals(vertex.mvBitangent) && mvTextureCoordinate.equals(vertex.mvTextureCoordinate) &&\n\t\t\tmvVertexColour.equals(vertex.mvVertexColour) && mvWeights.equals(vertex.mvWeights)&& mvJointIndices.equals(vertex.mvJointIndices))\n\t    {\n\t    \treturn true;\n\t    }\n\t    \n\t    return false;\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/CoreUtils/.classpath",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<classpath>\n\t<classpathentry kind=\"src\" path=\"src\"/>\n\t<classpathentry kind=\"con\" path=\"org.eclipse.jdt.launching.JRE_CONTAINER\"/>\n\t<classpathentry kind=\"output\" path=\"bin\"/>\n</classpath>\n"
  },
  {
    "path": "Projects/Tools/CoreUtils/.gitignore",
    "content": "bin\n\n"
  },
  {
    "path": "Projects/Tools/CoreUtils/.project",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<projectDescription>\n\t<name>CoreUtils</name>\n\t<comment></comment>\n\t<projects>\n\t</projects>\n\t<buildSpec>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.jdt.core.javabuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t</buildSpec>\n\t<natures>\n\t\t<nature>org.eclipse.jdt.core.javanature</nature>\n\t</natures>\n</projectDescription>\n"
  },
  {
    "path": "Projects/Tools/CoreUtils/src/com/chilliworks/chillisource/coreutils/CSException.java",
    "content": "/**\n * Result.java\n * ChilliSource\n * Created by Ian Copland on 24/10/2014.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2014 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.coreutils;\n\n/**\n * A general Exception class that provides an error string. This is used for\n * cases where the exception has arisen due to a fatal error in the throwing\n * method and there can be no recovery other than displaying an error to the\n * user.\n * \n * @author Ian Copland\n */\npublic final class CSException extends Exception\n{\n\tprivate static final long serialVersionUID = -8853364100633327738L;\n\t\n\t/**\n\t * Constructor. Creates the exception with the given error message.\n\t * \n\t * @param in_errorMessage - A description of the error that has arisen. This \n\t * should be in a form displayable to the user.\n\t */\n\tpublic CSException(String in_errorMessage)\n\t{\n\t\tsuper(in_errorMessage);\n\t\t\n\t\tassert (in_errorMessage != null) : \"Must provide an error message.\";\n\t}\n\t/**\n\t * Constructor. Creates the exception with the given error message.\n\t * \n\t * @param in_errorMessage - A description of the error that has arisen. This \n\t * should be in a form displayable to the user.\n\t * @param in_throwable - The throwable that caused this exception.\n\t */\n\tpublic CSException(String in_errorMessage, Throwable in_throwable)\n\t{\n\t\tsuper(in_errorMessage, in_throwable);\n\t\t\n\t\tassert (in_errorMessage != null) : \"Must provide an error message.\";\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/CoreUtils/src/com/chilliworks/chillisource/coreutils/Colour.java",
    "content": "/**\n * Colour.java\n * ChilliSource\n * Created by Ian Copland on 09/10/2014\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2014 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.coreutils;\n\n/**\n * A class for containing RGBA colour values in the range 0.0-1.0. After construction the contents of the\n * class are immutable making it safe to pass into methods.\n * \n * @author Ian Copland\n */\npublic final class Colour\n{\n\tpublic final static Colour WHITE = new Colour(1.0, 1.0, 1.0, 1.0);\n\tpublic final static Colour BLACK = new Colour(0.0, 0.0, 0.0, 1.0);\n\t\n\tprivate final double m_r;\n\tprivate final double m_g;\n\tprivate final double m_b;\n\tprivate final double m_a;\n\t\n\t/**\n\t * Parses a colour from a string. colour values should be given in\n\t * the range 0.0 - 1.0 and each component should be separated by\n\t * a comma. For example: 0.8, 1.0, 0.1, 1.0.\n\t * \n\t * @author Ian Copland\n\t *\n\t * @param in_colourString - The colour string\n\t */\n\tpublic static Colour parseColour(String in_colourString)\n\t{\n\t\tString[] components = in_colourString.split(\",\");\n\t\tif (components.length == 3 || components.length == 4)\n\t\t{\n\t\t\tdouble r = Float.parseFloat(components[0].trim());\n\t\t\tdouble g = Float.parseFloat(components[1].trim());\n\t\t\tdouble b = Float.parseFloat(components[2].trim());\n\t\t\tdouble a = 1.0;\n\t\t\tif (components.length == 4)\n\t\t\t{\n\t\t\t\ta = Float.parseFloat(components[3].trim());\n\t\t\t}\n\t\t\t\n\t\t\tr = Math.max(Math.min(r, 1.0), 0.0);\n\t\t\tg = Math.max(Math.min(g, 1.0), 0.0);\n\t\t\tb = Math.max(Math.min(b, 1.0), 0.0);\n\t\t\ta = Math.max(Math.min(a, 1.0), 0.0);\n\t\t\t\n\t\t\treturn new Colour(r, g, b, a);\n\t\t}\n\t\telse\n\t\t{\n\t\t\treturn Colour.WHITE;\n\t\t}\n\t}\n\t/**\n\t * Constructs a new colour with the given RGBA values.\n\t * \n\t * @author Ian Copland\n\t *\n\t * @param in_r - The red colour value.\n\t * @param in_g - The green colour value.\n\t * @param in_b - The blue colour value.\n\t * @param in_a - The alpha value.\n\t */\n\tpublic Colour(double in_r, double in_g, double in_b, double in_a)\n\t{\n\t\tassert (in_r >= 0.0 && in_r <= 1.0) : \"Colour: red value must be in the range 0.0-1.0.\";\n\t\tassert (in_g >= 0.0 && in_g <= 1.0) : \"Colour: green value must be in the range 0.0-1.0.\";\n\t\tassert (in_b >= 0.0 && in_b <= 1.0) : \"Colour: blue value must be in the range 0.0-1.0.\";\n\t\tassert (in_a >= 0.0 && in_a <= 1.0) : \"Colour: alpha value must be in the range 0.0-1.0.\";\n\t\t\n\t\tm_r = in_r;\n\t\tm_g = in_g;\n\t\tm_b = in_b;\n\t\tm_a = in_a;\n\t}\n\t/**\n\t * @author Ian Copland\n\t *\n\t * @return The red colour value.\n\t */\n\tpublic double getR()\n\t{\n\t\treturn m_r;\n\t}\n\t/**\n\t * @author Ian Copland\n\t *\n\t * @return The green colour value.\n\t */\n\tpublic double getG()\n\t{\n\t\treturn m_g;\n\t}\t\n\t/**\n\t * @author Ian Copland\n\t *\n\t * @return The blue colour value.\n\t */\n\tpublic double getB()\n\t{\n\t\treturn m_b;\n\t}\n\t/**\n\t * @author Ian Copland\n\t *\n\t * @return The alpha value.\n\t */\n\tpublic double getA()\n\t{\n\t\treturn m_a;\n\t}\n\t/**\n\t * @author Ian Copland\n\t *\n\t * @return This object in string form.\n\t */\n\t@Override public String toString()\n\t{\n\t\treturn \"\" + m_r + \", \" + m_g + \", \" + m_b + \",\" + m_a;\n\t}\n\t/**\n\t * Returns whether or not this object is equal in value to the given\n\t * object.\n\t * \n\t * @author Ian Copland\n\t *\n\t * @param in_object - The other object.\n\t *\n\t * @return Whether or not the given object is equal to this.\n\t */\n\t@Override public boolean equals(Object in_object)\n\t{\n\t\tif (in_object == this)\n\t    {\n\t    \treturn true;\n\t    }\n\t\t\n\t\tif (in_object == null)\n\t    {\n\t    \treturn false;\n\t    }\n\t    \t\n\t    if ((in_object instanceof Colour) == false)\n\t    {\n\t    \treturn false;\n\t    }\n\t    \n\t    Colour colour = (Colour)in_object;\n\t    return (Double.compare(m_r, colour.m_r) == 0 && Double.compare(m_g, colour.m_g) == 0 && Double.compare(m_b, colour.m_b) == 0 && Double.compare(m_a, colour.m_a) == 0);\n\t}\n\t/**\n\t * @author Ian Copland\n\t *\n\t * @return The hash code for this object.\n\t */\n\t@Override public int hashCode()\n\t{\n\t\tint hash = HashCodeUtils.INITIAL_VALUE;\n\t\thash = HashCodeUtils.add(hash, m_r);\n\t\thash = HashCodeUtils.add(hash, m_g);\n\t\thash = HashCodeUtils.add(hash, m_b);\n\t\thash = HashCodeUtils.add(hash, m_a);\n\t\treturn hash;\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/CoreUtils/src/com/chilliworks/chillisource/coreutils/ExternalProcess.java",
    "content": "/**\n * ExternalProcess.java\n * ChilliSource\n * Created by Ian Copland on 07/09/2012\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2012 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.coreutils;\n\nimport java.io.BufferedReader;\nimport java.io.InputStream;\nimport java.io.InputStreamReader;\nimport java.util.LinkedList;\nimport java.util.List;\n\n//==================================================\n/// External Process\n///\n/// Runs external processes.\n//==================================================\npublic final class ExternalProcess \n{\n\t//------------------------------------------------------\n\t/// Private member data\n\t//------------------------------------------------------\n\tprivate List<String> mstrMessages = new LinkedList<String>();\n\tprivate List<String> mstrWarnings = new LinkedList<String>();\n\tprivate List<String> mstrErrors = new LinkedList<String>();\n\t//----------------------------------------------\n\t/// Constructor\n\t//----------------------------------------------\n\tpublic ExternalProcess()\n\t{\n\t}\n\t//----------------------------------------------\n\t/// Constructor\n\t//----------------------------------------------\n\tpublic ExternalProcess(List<String> inastrCommands)\n\t{\n\t\trun(inastrCommands);\n\t}\n\t//------------------------------------------------------\n\t/// Run External Process\n\t///\n\t/// reads and outputs the processes input stream.\n\t///\n\t/// @param the process that owns the input stream.\n\t//------------------------------------------------------\n\tpublic void run(List<String> inastrCommands)\n\t{\n\t\ttry\n\t\t{\n\t\t\t//run the application\n\t\t\tfinal Process process = new ProcessBuilder(inastrCommands).start();\n\t\t\tRunnable inputRunnable = new Runnable()\n\t\t\t{\n\t\t\t\t@Override public void run() \n\t\t\t\t{\n\t\t\t\t\treadInputStream(process);\n\t\t\t\t}\n\t\t\t};\n\t\t\tRunnable errorRunnable = new Runnable()\n\t\t\t{\n\t\t\t\t@Override public void run() \n\t\t\t\t{\n\t\t\t\t\treadErrorStream(process);\n\t\t\t\t}\n\t\t\t};\n\t\t\tThread inputThread = new Thread(inputRunnable);\n\t\t\tThread errorThread = new Thread(errorRunnable);\n\t\t\tinputThread.start();\n\t\t\terrorThread.start();\n\t\t\tinputThread.join();\n\t\t\terrorThread.join();\n\t\t\tprocess.waitFor();\n\t\t\tprocess.destroy();\n\t\t}\n\t\tcatch (Exception e)\n\t\t{\n\t\t\tLogging.logFatal(\"Exception occurred while running external process: \\n\" + e.getStackTrace());\n\t\t}\n\t}\n\t//------------------------------------------------------\n\t/// Get Messages\n\t///\n\t/// @return all messages from the run application.\n\t//------------------------------------------------------\n\tpublic List<String> getMessages()\n\t{\n\t\treturn mstrMessages;\n\t}\n\t//------------------------------------------------------\n\t/// Get Warnings\n\t///\n\t/// @return all warnings from the run application.\n\t//------------------------------------------------------\n\tpublic List<String> getWarnings()\n\t{\n\t\treturn mstrWarnings;\n\t}\n\t//------------------------------------------------------\n\t/// Get Errors\n\t///\n\t/// @return all errors from the run application.\n\t//------------------------------------------------------\n\tpublic List<String> getErrors()\n\t{\n\t\treturn mstrErrors;\n\t}\n\t//------------------------------------------------------\n\t/// Read Input Stream\n\t///\n\t/// reads and outputs the processes input stream.\n\t///\n\t/// @param the process that owns the input stream.\n\t//------------------------------------------------------\n\tprivate void readInputStream(Process inProcess)\n\t{\n\t\ttry\n\t\t{\n\t\t\tInputStream inputStream = inProcess.getInputStream();\n\t\t\tInputStreamReader inputStreamReader = new InputStreamReader(inputStream);\n\t\t\tBufferedReader bufferedInputReader = new BufferedReader(inputStreamReader);\n\t\t\t\n\t\t\tString inputLine = null;\n\t\t\tdo\n\t\t\t{\n\t\t\t\tinputLine = bufferedInputReader.readLine();\n\t\t\t\tif (inputLine != null)\n\t\t\t\t{\t\n\t\t\t\t\tmstrMessages.add(inputLine);\n\t\t\t\t}\n\t\t\t}\n\t\t\twhile (inputLine != null);\n\t\t}\n\t\tcatch (Exception e)\n\t\t{\n\t\t\tLogging.logFatal(\"Something has gone wrong while reading the input stream!\\n\" + e.getStackTrace().toString());\n\t\t}\n\t}\n\t//------------------------------------------------------\n\t/// Read Error Stream\n\t///\n\t/// reads and outputs the processes error stream.\n\t///\n\t/// @param the process that owns the error stream.\n\t//------------------------------------------------------\n\tprivate void readErrorStream(Process inProcess)\n\t{\n\t\ttry\n\t\t{\n\t\t\tInputStream errorStream = inProcess.getErrorStream();\n\t\t\tInputStreamReader errorStreamReader = new InputStreamReader(errorStream);\n\t\t\tBufferedReader bufferedErrorReader = new BufferedReader(errorStreamReader);\n\t\t\t\n\t\t\tString errorLine = null;\n\t\t\tdo\n\t\t\t{\n\t\t\t\terrorLine = bufferedErrorReader.readLine();\n\t\t\t\tif (errorLine != null)\n\t\t\t\t{\n\t\t\t\t\tString strMessage;\n\t\t\t\t\tif (errorLine.startsWith(\"FATAL\") == true)\n\t\t\t\t\t{\n\t\t\t\t\t\tstrMessage = errorLine.substring(7);\n\t\t\t\t\t\tmstrErrors.add(strMessage);\n\t\t\t\t\t}\n\t\t\t\t\telse if (errorLine.startsWith(\"ERROR\") == true)\n\t\t\t\t\t{\n\t\t\t\t\t\tstrMessage = errorLine.substring(7);\n\t\t\t\t\t\tmstrErrors.add(strMessage);\n\t\t\t\t\t}\n\t\t\t\t\telse if (errorLine.startsWith(\"WARNING\") == true)\n\t\t\t\t\t{\n\t\t\t\t\t\tstrMessage = errorLine.substring(9);\n\t\t\t\t\t\tmstrWarnings.add(strMessage);\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tstrMessage = errorLine;\n\t\t\t\t\t\tmstrErrors.add(strMessage);\n\t\t\t\t\t}\n\t\t\n\t\t\t\t}\n\t\t\t}\n\t\t\twhile (errorLine != null);\n\t\t}\n\t\tcatch (Exception e)\n\t\t{\n\t\t\tLogging.logFatal(\"Something has gone wrong while reading the error stream!\\n\" + e.getStackTrace().toString());\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/CoreUtils/src/com/chilliworks/chillisource/coreutils/FileUtils.java",
    "content": "/**\r\n * FileUtils.java\r\n * ChilliSource\r\n * Created by Ian Copland on 30/01/2013\r\n * \r\n * The MIT License (MIT)\r\n * \r\n * Copyright (c) 2013 Tag Games Limited\r\n * \r\n * Permission is hereby granted, free of charge, to any person obtaining a copy\r\n * of this software and associated documentation files (the \"Software\"), to deal\r\n * in the Software without restriction, including without limitation the rights\r\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\n * copies of the Software, and to permit persons to whom the Software is\r\n * furnished to do so, subject to the following conditions:\r\n * \r\n * The above copyright notice and this permission notice shall be included in\r\n * all copies or substantial portions of the Software.\r\n * \r\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r\n * THE SOFTWARE.\r\n */\r\n\r\npackage com.chilliworks.chillisource.coreutils;\r\n\r\nimport java.io.BufferedInputStream;\r\nimport java.io.BufferedOutputStream;\r\nimport java.io.File;\r\nimport java.io.FileInputStream;\r\nimport java.io.FileOutputStream;\r\nimport java.io.IOException;\r\nimport java.io.InputStream;\r\nimport java.io.OutputStream;\r\nimport java.nio.charset.StandardCharsets;\r\nimport java.nio.file.Files;\r\nimport java.nio.file.Path;\r\nimport java.nio.file.Paths;\r\nimport java.security.MessageDigest;\r\nimport java.util.ArrayList;\r\nimport java.util.Arrays;\r\nimport java.util.List;\r\nimport java.util.zip.CRC32;\r\n\r\npublic class FileUtils \r\n{\r\n\tprivate static final int INPUT_STREAM_BUFFER_SIZE = 8 * 1024;\r\n\t\r\n\t/**\r\n\t * Reads the entire contents of a file into a string.\r\n\t * \r\n\t * @author Ian Copland\r\n\t * \r\n\t * @param The file path.\r\n\t * \r\n\t * @return The contents of the file. Failure will return an\r\n\t * empty string.\r\n\t */\r\n\tpublic static String readFile(String in_filePath)\r\n\t{\t\r\n\t\tString output = \"\";\r\n\t\ttry\r\n\t\t{\r\n\t\t\tbyte[] encoded = Files.readAllBytes(Paths.get(in_filePath));\r\n\t\t\toutput = new String(encoded, StandardCharsets.UTF_8);\r\n\t\t}\r\n\t\tcatch (Exception e)\r\n\t\t{\r\n\t\t}\r\n\t\t\r\n\t\treturn output;\r\n\t}\r\n\t/**\r\n\t * Writes the contents of a string to file.\r\n\t * \r\n\t * @author Ian Copland\r\n\t * \r\n\t * @param The output file path.\r\n\t * @param The string to write.\r\n\t * \r\n\t * @return Whether or not the write was successful.\r\n\t */\r\n\tpublic static boolean writeFile(String in_filePath, String in_contents)\r\n\t{\r\n\t\ttry\r\n\t\t{\r\n\t\t\tFiles.write(Paths.get(in_filePath), in_contents.getBytes(StandardCharsets.UTF_8));\r\n\t\t\treturn true;\r\n\t\t}\r\n\t\tcatch (Exception e)\r\n\t\t{\r\n\t\t\treturn false;\r\n\t\t}\r\n\t}\r\n\t/**\r\n\t * Write a byte array to file.\r\n\t * \r\n\t * @author Ian Copland\r\n\t * \r\n\t * @param The filename.\r\n\t * @param The data to be written to file.\r\n\t * @return Whether or not the file was successfully written.\r\n\t */\r\n\tpublic static boolean writeFile(final String in_filePath, final byte[] in_contents)\r\n\t{\r\n\t\tboolean bSuccess = false;\r\n\t\ttry\r\n\t\t{\r\n\t\t\tOutputStream stream = null;\r\n\t\t\ttry\r\n\t\t\t{\r\n\t\t\t\tFile file = new File(in_filePath);\r\n\t\t\t\tstream = new BufferedOutputStream(new FileOutputStream(file));\r\n\t\t\t\tstream.write(in_contents);\r\n\t\t\t\tbSuccess = true;\r\n\t\t\t}\r\n\t        catch (Exception e)\r\n\t        {\r\n\t        \tthrow e;\r\n\t        }\r\n\t\t\tfinally\r\n\t\t\t{\r\n\t\t\t\tif (stream != null)\r\n\t\t\t\t{\r\n\t\t\t\t\tstream.close();\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\tcatch (Exception e)\r\n\t\t{\r\n\t\t\tLogging.logError(StringUtils.convertExceptionToString(e));\r\n\t\t}\r\n\t\treturn bSuccess;\r\n\t}\r\n\t/**\r\n\t * Copies a file from one location to another.\r\n\t * \r\n\t * @author Ian Copland\r\n\t * \r\n\t * @param the input filename.\r\n\t * @param the output filename.\r\n\t * \r\n\t * @return whether or not this was successful.\r\n\t */\r\n\tpublic static boolean copyFile(String in_inputFilePath, String in_outputFilePath)\r\n\t{\r\n\t\ttry\r\n\t\t{\r\n\t\t\tPath sourcePath = new File(in_inputFilePath).toPath();\r\n\t\t\tPath destPath = new File(in_outputFilePath).toPath();\r\n\t\t\t\r\n\t\t\tif (Files.isDirectory(sourcePath) == true || Files.isSymbolicLink(sourcePath) == true)\r\n\t\t\t{\r\n\t\t\t\tLogging.logError(\"Could not copy file '\" + in_inputFilePath + \"' to '\" + in_outputFilePath + \"' becuase it is not a file.\");\r\n\t\t\t\treturn false;\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\tFiles.copy(sourcePath, destPath);\r\n\t\t}\r\n\t\tcatch(Exception e)\r\n\t\t{\r\n\t\t\tLogging.logError(\"Failed to copy file '\" + in_inputFilePath + \"' to '\" + in_outputFilePath + \"'\");\r\n\t\t\treturn false;\r\n\t\t}\r\n\t\t\r\n\t\treturn true;\r\n\t}\r\n\t/**\r\n\t * Renames a file. If a file or directory already exists at the new location, this will \r\n\t * fail.\r\n\t * \r\n\t * @author Ian Copland\r\n\t * \r\n\t * @param in_currentFilePath - The file path to the file which should be renamed.\r\n\t * @param in_newFilePath - The new file path.\r\n\t * \r\n\t * @return whether or not this was successful.\r\n\t */\r\n\tpublic static boolean renameFile(String in_currentFilePath, String in_newFilePath)\r\n\t{\r\n\t\tFile currentFile = new File(in_currentFilePath);\r\n\t\tif (currentFile.exists() == false || currentFile.isFile() == false)\r\n\t\t{\r\n\t\t\treturn false;\r\n\t\t}\r\n\t\t\r\n\t\tFile newFile = new File(in_newFilePath);\r\n\t\tif (newFile.exists() == true)\r\n\t\t{\r\n\t\t\treturn false;\r\n\t\t}\r\n\t\t\r\n\t\tif (currentFile.renameTo(newFile) == false)\r\n\t\t{\r\n\t\t\treturn false;\r\n\t\t}\r\n\t    \r\n\t\treturn true;\r\n\t}\r\n\t/**\r\n\t * Deletes a file.\r\n\t * \r\n\t * @author I Copland\r\n\t * \r\n\t * @param the filename.\r\n\t * \r\n\t * @return whether or not this was successful.\r\n\t */\r\n\tpublic static boolean deleteFile(String in_filePath)\r\n\t{\r\n\t\tFile file = new File(in_filePath);\r\n\t\treturn deleteFile(file);\r\n\t}\r\n\t/**\r\n\t * Deletes a file.\r\n\t * \r\n\t * @author I Copland\r\n\t * \r\n\t * @param the file.\r\n\t * \r\n\t * @return whether or not this was successful.\r\n\t */\r\n\tpublic static boolean deleteFile(File in_file)\r\n\t{\r\n\t\tif(!in_file.exists() || !in_file.isFile())\r\n\t\t\treturn false;\r\n\t\t\r\n\t\treturn in_file.delete();\r\n\t}\r\n\t/**\r\n\t * Recursively creates directories.\r\n\t * \r\n\t * @author Ian Copland\r\n\t * \r\n\t * @param The directory to create\r\n\t * \r\n\t * @return Whether or not this was successful. Failure to create the directory \r\n\t * because it already exists counts as success.\r\n\t */\r\n\tpublic static boolean createDirectory(String in_directoryPath)\r\n\t{\r\n\t\t//break the path onto sections.\r\n\t\tString strDirectory = StringUtils.standardiseDirectoryPath(in_directoryPath);\r\n\t\tString[] strPathSections = strDirectory.split(\"/\");\r\n\t\t\r\n\t\tString strPathSoFar = \"\";\r\n\t\tfor (String strPathSection: strPathSections)\r\n\t\t{\r\n\t\t\tstrPathSoFar += strPathSection + \"/\";\r\n\t\t\t\r\n\t\t\tFile newDir = new File(strPathSoFar);\r\n\t\t\tif (newDir.exists() == false)\r\n\t\t\t{\r\n\t\t\t\tif (newDir.mkdir() == false)\r\n\t\t\t\t{\r\n\t\t\t\t\tLogging.logError(\"Failed to create directory: \" + strPathSoFar);\r\n\t\t\t\t\treturn false;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\t\r\n\t\treturn true;\r\n\t}\r\n\t/**\r\n\t * Copies a directory from one location to another.\r\n\t * \r\n\t * @author Ian Copland\r\n\t * \r\n\t * @param the input directory.\r\n\t * @param the output directory.\r\n\t * @param whether or not to ignore dot directories and files.\r\n\t * \r\n\t * @return whether or not this was successful.\r\n\t */\r\n\tpublic static boolean copyDirectory(String in_inputDirectoryPath, String in_outputDirectoryPath, List<String> in_directoryPathsToIgnore)\r\n\t{\r\n\t\ttry\r\n\t\t{\r\n\t\t\t//ignore some dirs.\r\n\t\t\tfor (String strIgnore : in_directoryPathsToIgnore)\r\n\t\t\t{\r\n\t\t\t\tif (in_inputDirectoryPath.contains(strIgnore) == true)\r\n\t\t\t\t{\r\n\t\t\t\t\t//This doesn't count as failure as we are choosing to ignore these dirs.\r\n\t\t\t\t\treturn true;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\t//if the directory doesn't exist, then create it!\r\n\t\t\tFile destinationDir = new File(in_outputDirectoryPath);\r\n\t\t\tif (destinationDir.exists() == false)\r\n\t\t\t{\r\n\t\t\t\tdestinationDir.mkdir();\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\t//navigate the directory\r\n\t\t\tFile sourceDir = new File(in_inputDirectoryPath);\r\n\t\t\tString[] astrList = sourceDir.list();\r\n\t\t\tif (astrList != null) \r\n\t\t\t{\r\n\t\t\t\tfor (int i = 0; i < astrList.length; i++) \r\n\t\t\t\t{\r\n\t\t\t\t\tFile entry = new File(sourceDir, astrList[i]);\r\n\t\t\t\t\tif (entry.isDirectory())\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tcopyDirectory(StringUtils.standardiseDirectoryPath(in_inputDirectoryPath) + StringUtils.standardiseDirectoryPath(astrList[i]),\r\n\t\t\t\t\t\t\t\tStringUtils.standardiseDirectoryPath(in_outputDirectoryPath) + StringUtils.standardiseDirectoryPath(astrList[i]), in_directoryPathsToIgnore);\r\n\t\t\t\t\t}\r\n\t\t\t\t\telse\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tcopyFile(StringUtils.standardiseDirectoryPath(in_inputDirectoryPath) + StringUtils.standardiseFilePath(astrList[i]),\r\n\t\t\t\t\t\t\t\tStringUtils.standardiseDirectoryPath(in_outputDirectoryPath) + StringUtils.standardiseFilePath(astrList[i]));\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\tcatch(Exception e)\r\n\t\t{\r\n\t\t\tLogging.logError(\"Failed to copy directory '\" + in_inputDirectoryPath + \"' to '\" + in_outputDirectoryPath + \"'\");\r\n\t\t\treturn false;\r\n\t\t}\r\n\t\t\r\n\t\treturn true;\r\n\t}\r\n\t/**\r\n\t * Renames a directory. If a file or directory already exists at the new location, this will fail.\r\n\t * \r\n\t * @author Ian Copland\r\n\t * \r\n\t * @param in_currentDirectoryPath - The directory path to the directory which should be renamed.\r\n\t * @param in_newDirectoryPath - The new directory path.\r\n\t * \r\n\t * @return whether or not this was successful.\r\n\t */\r\n\tpublic static boolean renameDirectory(String in_currentDirectoryPath, String in_newDirectoryPath)\r\n\t{\r\n\t\tFile currentDirectory = new File(in_currentDirectoryPath);\r\n\t\tif (currentDirectory.exists() == false || currentDirectory.isDirectory() == false)\r\n\t\t{\r\n\t\t\treturn false;\r\n\t\t}\r\n\t\t\r\n\t\tFile newDirectory = new File(in_newDirectoryPath);\r\n\t\tif (newDirectory.exists() == true)\r\n\t\t{\r\n\t\t\treturn false;\r\n\t\t}\r\n\t\t\r\n\t\tif (currentDirectory.renameTo(newDirectory) == false)\r\n\t\t{\r\n\t\t\treturn false;\r\n\t\t}\r\n\t    \r\n\t\treturn true;\r\n\t}\r\n\t/**\r\n\t * Deletes a directory and all its contents.\r\n\t * \r\n\t * @author Ian Copland\r\n\t * \r\n\t * @param The directory to delete.\r\n\t * @return Whether or not this was successful. Failure to delete the directory because it does not exist counts as success.\r\n\t */\r\n\tpublic static boolean deleteDirectory(String in_directoryPath)\r\n\t{\r\n\t\tFile directory = new File(in_directoryPath);\r\n\r\n\t\tif (!directory.exists())\r\n\t\t\treturn true;\r\n\t\tif (!directory.isDirectory())\r\n\t\t\treturn false;\r\n\t\t\r\n\t\tString[] astrList = directory.list();\r\n\t\tif (astrList != null) \r\n\t\t{\r\n\t\t\tfor (int i = 0; i < astrList.length; i++) \r\n\t\t\t{\r\n\t\t\t\tFile entry = new File(directory, astrList[i]);\r\n\t\t\t\tif (entry.isDirectory())\r\n\t\t\t\t{\r\n\t\t\t\t\tif (!deleteDirectory(entry.getAbsolutePath()))\r\n\t\t\t\t\t\treturn false;\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t{\r\n\t\t\t\t\tif (!entry.delete())\r\n\t\t\t\t\t\treturn false;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn directory.delete();\r\n\t}\r\n\t/**\r\n\t * Returns all the file paths in the given directory.\r\n\t * \r\n\t * @author Ian Copland\r\n\t * \r\n\t * @param the directory path.\r\n\t * \r\n\t * @return the list of file paths.\r\n\t */\r\n\tstatic public String[] getFilePaths(String in_directoryPath)\r\n\t{\r\n\t\tString strDirectory = StringUtils.standardiseDirectoryPath(in_directoryPath);\r\n\t\tString[] astrFilenames = getFullFilePaths(strDirectory);\r\n\t\t\r\n\t\tfor (int i = 0; i < astrFilenames.length; ++i)\r\n\t\t\tastrFilenames[i] = astrFilenames[i].substring(strDirectory.length());\r\n\t\t\r\n\t\treturn astrFilenames;\r\n\t}\r\n\t/**\r\n\t * Returns all the directory paths in the given directory.\r\n\t * \r\n\t * @author Ian Copland\r\n\t * \r\n\t * @param the directory path.\r\n\t * \r\n\t * @return the list of directory paths.\r\n\t */\r\n\tstatic public String[] getDirectoriesInDirectory(String in_directoryPath)\r\n\t{\r\n\t\tString strDirectory = StringUtils.standardiseDirectoryPath(in_directoryPath);\r\n\t\tString[] astrDirectories = getFullDirectoryPaths(strDirectory);\r\n\t\t\r\n\t\tfor (int i = 0; i < astrDirectories.length; ++i)\r\n\t\t\tastrDirectories[i] = astrDirectories[i].substring(strDirectory.length());\r\n\t\t\r\n\t\treturn astrDirectories;\r\n\t}\r\n\t/**\r\n\t * Calculates the MD5 checksum for the file at the given path.\r\n\t * \r\n\t * @param The file path.\r\n\t * \r\n\t * @return The MD5 Checksum.\r\n\t */\r\n\tstatic public String calcFileMD5(String in_filePath)\r\n\t{\r\n\t\tString strChecksum = \"\";\r\n\t\t\r\n\t\ttry\r\n\t\t{\r\n\t\t\tInputStream fis =  new FileInputStream(in_filePath);\r\n\t\r\n\t\t\tbyte[] buffer = new byte[1024];\r\n\t\t\tMessageDigest complete = MessageDigest.getInstance(\"MD5\");\r\n\t\t\tint numRead;\r\n\t\t\t\r\n\t\t\tdo \r\n\t\t\t{\r\n\t\t\t    numRead = fis.read(buffer);\r\n\t\t\t    if (numRead > 0) \r\n\t\t\t    {\r\n\t\t\t        complete.update(buffer, 0, numRead);\r\n\t\t\t    }\r\n\t\t\t} \r\n\t\t\twhile (numRead != -1);\r\n\t\t\t\r\n\t\t\tfis.close();\r\n\t\t\tbyte[] abyChecksum = complete.digest();\r\n\t\t\t\r\n\t\t\tfor (int i=0; i < abyChecksum.length; i++) \r\n\t\t\t{\r\n\t\t\t\tstrChecksum += Integer.toString((abyChecksum[i] & 0xff) + 0x100, 16).substring(1);\r\n\t\t    }\r\n\t\t}\r\n\t\tcatch (Exception e)\r\n\t\t{\r\n\t\t\tLogging.logError(\"Could not calculate checksum for file: \" + in_filePath);\r\n\t\t}\r\n\t\t\r\n\t\treturn strChecksum;\r\n\t}\r\n\t/**\r\n\t * @param in_filePath - The file path.\r\n\t * \r\n\t * @return The CRC32 hash of the file at the given file path.\r\n\t * \r\n\t * @throws IOException - This will be thrown if there is an error reading the file.\r\n\t */\r\n\tstatic public long calcFileCRC32(String in_filePath) throws IOException\r\n\t{\r\n\t\ttry (BufferedInputStream stream = new BufferedInputStream(new FileInputStream(in_filePath), INPUT_STREAM_BUFFER_SIZE))\r\n\t\t{\r\n\t\t\tbyte[] buffer = new byte[INPUT_STREAM_BUFFER_SIZE];\r\n\t\t\tCRC32 crc32 = new CRC32();\r\n\t\t\t\r\n\t\t\tint count = 0;\r\n\t        while((count = stream.read(buffer, 0, buffer.length)) != -1) \r\n\t        {\r\n\t        \tcrc32.update(buffer, 0, count);\r\n\t        }\r\n\t\t\t\r\n\t        return crc32.getValue();\r\n\t\t}\r\n\t\tcatch (IOException e)\r\n\t\t{\r\n\t\t\tthrow e;\r\n\t\t}\r\n\t}\r\n\t/**\r\n\t * Returns all the filenames in the given directory. Files names include \r\n\t * the input directory.\r\n\t * \r\n\t * @author I Copland\r\n\t * \r\n\t * @param the directory path.\r\n\t * \r\n\t * @return the list of file paths.\r\n\t */\r\n\tprivate static String[] getFullFilePaths(String in_directoryPath)\r\n\t{\r\n\t\tString strDirectory = StringUtils.standardiseDirectoryPath(in_directoryPath);\r\n\t\tArrayList<String> astrFilenames = new ArrayList<String>();\r\n\t\t\r\n\t\tFile directory = new File(strDirectory);\r\n\t\tif (!directory.exists() || !directory.isDirectory())\r\n\t\t\treturn new String[0];\r\n\t\t\r\n\t\tString[] astrList = directory.list();\r\n\t\tif (astrList != null) \r\n\t\t{\r\n\t\t\tfor (int i = 0; i < astrList.length; i++) \r\n\t\t\t{\r\n\t\t\t\tFile entry = new File(directory, astrList[i]);\r\n\t\t\t\tif (entry.isDirectory())\r\n\t\t\t\t{\r\n\t\t\t\t\tString[] astrMoreFilenames = getFullFilePaths(entry.getPath());\r\n\t\t\t\t\tastrFilenames.addAll(Arrays.asList(astrMoreFilenames));\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t{\r\n\t\t\t\t\tastrFilenames.add(entry.getPath());\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\t\r\n\t\tString[] astrOutput = new String[astrFilenames.size()];\r\n\t\tastrFilenames.toArray(astrOutput);\r\n\t\treturn astrOutput;\r\n\t}\r\n\t/**\r\n\t * Returns all the directory paths in the given directory. directory paths\r\n\t * include the input directory.\r\n\t * \r\n\t * @author I Copland\r\n\t * \r\n\t * @param the directory path.\r\n\t * \r\n\t * @return the list of directory paths.\r\n\t */\r\n\tprivate static String[] getFullDirectoryPaths(String in_directoryPath)\r\n\t{\r\n\t\tString strDirectory = StringUtils.standardiseDirectoryPath(in_directoryPath);\r\n\t\tArrayList<String> astrDirectories = new ArrayList<String>();\r\n\t\t\r\n\t\tFile directory = new File(strDirectory);\r\n\t\tif (!directory.exists() || !directory.isDirectory())\r\n\t\t\treturn new String[0];\r\n\t\t\r\n\t\tString[] astrList = directory.list();\r\n\t\tif (astrList != null) \r\n\t\t{\r\n\t\t\tfor (int i = 0; i < astrList.length; i++) \r\n\t\t\t{\r\n\t\t\t\tFile entry = new File(directory, astrList[i]);\r\n\t\t\t\tif (entry.isDirectory())\r\n\t\t\t\t{\r\n\t\t\t\t\tastrDirectories.add(entry.getPath());\r\n\t\t\t\t\tString[] astrMoreDirectories = getFullDirectoryPaths(entry.getPath());\r\n\t\t\t\t\tastrDirectories.addAll(Arrays.asList(astrMoreDirectories));\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\t\r\n\t\tString[] astrOutput = new String[astrDirectories.size()];\r\n\t\tastrDirectories.toArray(astrOutput);\r\n\t\treturn astrOutput;\r\n\t}\r\n}\r\n"
  },
  {
    "path": "Projects/Tools/CoreUtils/src/com/chilliworks/chillisource/coreutils/HashCodeUtils.java",
    "content": "/**\n * HashCodeUtils.java\n * ChilliSource\n * Created by Ian Copland on 31/10/2014\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2014 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.coreutils;\n\n/**\n * A utilities class for calculating object hash codes returned from hashCode().\n * To generate a hash for each member of a class the previous hash needs to be\n * passed into the next. For the initial member INITIAL_VALUE should be passed\n * in as the previous hash.\n * \n * @author Ian Copland\n *\n */\npublic final class HashCodeUtils\n{\n\tpublic static int INITIAL_VALUE = 131;\n\t\n\tprivate static int ARITRARY_PRIME_NUMBER = 79;\n\n\t/**\n\t * Adds a value into the hash.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param in_currentHash - The current hash value before adding the new value.\n\t * @param in_value - The new value to add to the hash.\n\t * \n\t * @return The new hash code.\n\t */\n\tpublic static <TType> int add(int in_currentHash, TType in_value)\n\t{\n\t\treturn in_currentHash * ARITRARY_PRIME_NUMBER + in_value.hashCode();\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/CoreUtils/src/com/chilliworks/chillisource/coreutils/Integer2.java",
    "content": "/**\n * Integer2.java\n * ChilliSource\n * Created by Ian Copland on 09/10/2014.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2014 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.coreutils;\n\n/**\n * An integer vector class. This is immutable after creation meaning it can\n * safely be passed into methods without side-effects.\n * \n * @author Ian Copland\n */\npublic final class Integer2\n{\n\tpublic static final Integer2 ZERO = new Integer2(0, 0);\n\tpublic static final Integer2 ONE = new Integer2(1, 1);\n\t\n\tprivate final int m_x;\n\tprivate final int m_y;\n\t\n\t/**\n\t * Returns the addition of the two provided Integer2s.\n\t * \n\t * @author Ian Copland\n\t *\n\t * @param in_a - the first Integer2.\n\t * @param in_b - the second Integer2.\n\t * \n\t * @return The result of the addition.\n\t */\n\tpublic static Integer2 add(Integer2 in_a, Integer2 in_b)\n\t{\n\t\treturn new Integer2(in_a.getX() + in_b.getX(), in_a.getY() + in_b.getY());\n\t}\n\t/**\n\t * Returns the subtraction of the two provided Integer2s.\n\t * \n\t * @author Ian Copland\n\t *\n\t * @param in_a - the first Integer2.\n\t * @param in_b - the second Integer2.\n\t * \n\t * @return The result of the subtraction.\n\t */\n\tpublic static Integer2 subtract(Integer2 in_a, Integer2 in_b)\n\t{\n\t\treturn new Integer2(in_a.getX() - in_b.getX(), in_a.getY() - in_b.getY());\n\t}\n\t/**\n\t * Returns the result of multiplying all components of the Integer2 by\n\t * the scalar.\n\t * \n\t * @author Ian Copland\n\t *\n\t * @param in_a - the Integer2.\n\t * @param in_b - the scalar.\n\t * \n\t * @return The result of the multiplication.\n\t */\n\tpublic static Integer2 multiply(Integer2 in_a, int in_b)\n\t{\n\t\treturn new Integer2(in_a.getX() * in_b, in_a.getY() * in_b);\n\t}\n\t/**\n\t * Returns the result of multiplying the two Interger2's together.\n\t * \n\t * @author Ian Copland\n\t *\n\t * @param in_a - the first Integer2.\n\t * @param in_b - the second Integer2.\n\t * \n\t * @return The result of the multiplication.\n\t */\n\tpublic static Integer2 multiply(Integer2 in_a, Integer2 in_b)\n\t{\n\t\treturn new Integer2(in_a.getX() * in_b.getX(), in_a.getY() * in_b.getY());\n\t}\n\t/**\n\t * Takes the min value for each component from the two Integer2s.\n\t * \n\t * @author Ian Copland\n\t *\n\t * @param in_a - the first Integer2.\n\t * @param in_b - the second Integer2.\n\t * \n\t * @return The min value.\n\t */\n\tpublic static Integer2 min(Integer2 in_a, Integer2 in_b)\n\t{\n\t\treturn new Integer2(Math.min(in_a.getX(), in_b.getX()), Math.min(in_a.getY(), in_b.getY()));\n\t}\n\t/**\n\t * Takes the max value for each component from the two Integer2s.\n\t * \n\t * @author Ian Copland\n\t *\n\t * @param in_a - the first Integer2.\n\t * @param in_b - the second Integer2.\n\t * \n\t * @return The max value.\n\t */\n\tpublic static Integer2 max(Integer2 in_a, Integer2 in_b)\n\t{\n\t\treturn new Integer2(Math.max(in_a.getX(), in_b.getX()), Math.max(in_a.getY(), in_b.getY()));\n\t}\n\t/**\n\t * Parses an Integer2 from a string. Integer2 values should be provided \n\t * as integers and each component should be separated by a comma. For \n\t * example:  2, 600.\n\t * \n\t * @author Ian Copland\n\t *\n\t * @param in_int2String - The Integer2 string.\n\t */\n\tpublic static Integer2 parseInt2(String in_int2String)\n\t{\n\t\tString[] components = in_int2String.split(\",\");\n\t\tif (components.length == 2)\n\t\t{\n\t\t\tint x = Integer.parseInt(components[0].trim());\n\t\t\tint y = Integer.parseInt(components[1].trim());\n\t\t\t\n\t\t\treturn new Integer2(x, y);\n\t\t}\n\t\telse\n\t\t{\n\t\t\treturn Integer2.ZERO;\n\t\t}\n\t}\n\t/**\n\t * Constructor.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param in_x - The x value.\n\t * @param in_y - The y value.\n\t */\n\tpublic Integer2(int in_x, int in_y)\n\t{\n\t\tm_x = in_x;\n\t\tm_y = in_y;\n\t}\n\t/**\n\t * @author Ian Copland\n\t * \n\t * @return The x component.\n\t */\n\tpublic int getX()\n\t{\n\t\treturn m_x;\n\t}\n\t/**\n\t * @author Ian Copland\n\t * \n\t * @return The y component.\n\t */\n\tpublic int getY()\n\t{\n\t\treturn m_y;\n\t}\n\t/**\n\t * @author Ian Copland\n\t *\n\t * @return This object in string form.\n\t */\n\t@Override public String toString()\n\t{\n\t\treturn m_x + \", \" + m_y;\n\t}\n\t/**\n\t * Returns whether or not this object is equal in value to the given\n\t * object.\n\t * \n\t * @author Ian Copland\n\t *\n\t * @param in_object - The other object.\n\t *\n\t * @return Whether or not the given object is equal to this.\n\t */\n\t@Override public boolean equals(Object in_object)\n\t{\n\t\tif (in_object == this)\n\t    {\n\t    \treturn true;\n\t    }\n\t\t\n\t\tif (in_object == null)\n\t    {\n\t    \treturn false;\n\t    }\n\t    \t\n\t    if ((in_object instanceof Integer2) == false)\n\t    {\n\t    \treturn false;\n\t    }\n\t    \n\t    Integer2 integer2 = (Integer2)in_object;\n\t    return (m_x == integer2.m_x && m_y == integer2.m_y);\n\t}\n\t/**\n\t * @author Ian Copland\n\t *\n\t * @return The hash code for this object.\n\t */\n\t@Override public int hashCode()\n\t{\n\t\tint hash = HashCodeUtils.INITIAL_VALUE;\n\t\thash = HashCodeUtils.add(hash, m_x);\n\t\thash = HashCodeUtils.add(hash, m_y);\n\t\treturn hash;\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/CoreUtils/src/com/chilliworks/chillisource/coreutils/Integer3.java",
    "content": "/**\n * Integer3.java\n * ChilliSource\n * Created by Ian Copland on 27/10/2014.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2014 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.coreutils;\n\n/**\n * An integer vector class. This is immutable after creation meaning it can\n * safely be passed into methods without side-effects.\n * \n * @author Ian Copland\n */\npublic final class Integer3\n{\n\tpublic static final Integer3 ZERO = new Integer3(0, 0, 0);\n\tpublic static final Integer3 ONE = new Integer3(1, 1, 1);\n\t\n\tprivate final int m_x;\n\tprivate final int m_y;\n\tprivate final int m_z;\n\t\n\t/**\n\t * Returns the addition of the two provided Integer3s.\n\t * \n\t * @author Ian Copland\n\t *\n\t * @param in_a - the first Integer3.\n\t * @param in_b - the second Integer3.\n\t * \n\t * @return The result of the addition.\n\t */\n\tpublic static Integer3 add(Integer3 in_a, Integer3 in_b)\n\t{\n\t\treturn new Integer3(in_a.getX() + in_b.getX(), in_a.getY() + in_b.getY(), in_a.getZ() + in_b.getZ());\n\t}\n\t/**\n\t * Returns the subtraction of the two provided Integer3s.\n\t * \n\t * @author Ian Copland\n\t *\n\t * @param in_a - the first Integer3.\n\t * @param in_b - the second Integer3.\n\t * \n\t * @return The result of the subtraction.\n\t */\n\tpublic static Integer3 subtract(Integer3 in_a, Integer3 in_b)\n\t{\n\t\treturn new Integer3(in_a.getX() - in_b.getX(), in_a.getY() - in_b.getY(), in_a.getZ() - in_b.getZ());\n\t}\n\t/**\n\t * Returns the result of multiplying all components of the Integer3 by\n\t * the scalar.\n\t * \n\t * @author Ian Copland\n\t *\n\t * @param in_a - the Integer3.\n\t * @param in_b - the scalar.\n\t * \n\t * @return The result of the multiplication.\n\t */\n\tpublic static Integer3 multiply(Integer3 in_a, int in_b)\n\t{\n\t\treturn new Integer3(in_a.getX() * in_b, in_a.getY() * in_b, in_a.getZ() * in_b);\n\t}\n\t/**\n\t * Returns the result of multiplying the two Interger3's together.\n\t * \n\t * @author Ian Copland\n\t *\n\t * @param in_a - the first Integer3.\n\t * @param in_b - the second Integer3.\n\t * \n\t * @return The result of the multiplication.\n\t */\n\tpublic static Integer3 multiply(Integer3 in_a, Integer3 in_b)\n\t{\n\t\treturn new Integer3(in_a.getX() * in_b.getX(), in_a.getY() * in_b.getY(), in_a.getZ() * in_b.getZ());\n\t}\n\t/**\n\t * Takes the min value for each component from the two Integer3s.\n\t * \n\t * @author Ian Copland\n\t *\n\t * @param in_a - the first Integer3.\n\t * @param in_b - the second Integer3.\n\t * \n\t * @return The min value.\n\t */\n\tpublic static Integer3 min(Integer3 in_a, Integer3 in_b)\n\t{\n\t\treturn new Integer3(Math.min(in_a.getX(), in_b.getX()), Math.min(in_a.getY(), in_b.getY()), Math.min(in_a.getZ(), in_b.getZ()));\n\t}\n\t/**\n\t * Takes the max value for each component from the two Integer3s.\n\t * \n\t * @author Ian Copland\n\t *\n\t * @param in_a - the first Integer3.\n\t * @param in_b - the second Integer3.\n\t * \n\t * @return The max value.\n\t */\n\tpublic static Integer3 max(Integer3 in_a, Integer3 in_b)\n\t{\n\t\treturn new Integer3(Math.max(in_a.getX(), in_b.getX()), Math.max(in_a.getY(), in_b.getY()), Math.max(in_a.getZ(), in_b.getZ()));\n\t}\n\t/**\n\t * Parses an Integer3 from a string. Integer3 values should be provided \n\t * as integers and each component should be separated by a comma. For \n\t * example:  2, 600, -7.\n\t * \n\t * @author Ian Copland\n\t *\n\t * @param in_int3String - The Integer3 string.\n\t */\n\tpublic static Integer3 parseInt3(String in_int3String)\n\t{\n\t\tString[] components = in_int3String.split(\",\");\n\t\tif (components.length == 3)\n\t\t{\n\t\t\tint x = Integer.parseInt(components[0].trim());\n\t\t\tint y = Integer.parseInt(components[1].trim());\n\t\t\tint z = Integer.parseInt(components[2].trim());\n\t\t\t\n\t\t\treturn new Integer3(x, y, z);\n\t\t}\n\t\telse\n\t\t{\n\t\t\treturn Integer3.ZERO;\n\t\t}\n\t}\n\t/**\n\t * Constructor.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param in_x - The x value.\n\t * @param in_y - The y value.\n\t * @param in_z - The z value.\n\t */\n\tpublic Integer3(int in_x, int in_y, int in_z)\n\t{\n\t\tm_x = in_x;\n\t\tm_y = in_y;\n\t\tm_z = in_z;\n\t}\n\t/**\n\t * @author Ian Copland\n\t * \n\t * @return The x component.\n\t */\n\tpublic int getX()\n\t{\n\t\treturn m_x;\n\t}\n\t/**\n\t * @author Ian Copland\n\t * \n\t * @return The y component.\n\t */\n\tpublic int getY()\n\t{\n\t\treturn m_y;\n\t}\n\t/**\n\t * @author Ian Copland\n\t * \n\t * @return The z component.\n\t */\n\tpublic int getZ()\n\t{\n\t\treturn m_z;\n\t}\n\t/**\n\t * @author Ian Copland\n\t *\n\t * @return This object in string form.\n\t */\n\t@Override public String toString()\n\t{\n\t\treturn m_x + \", \" + m_y + \", \" + m_z;\n\t}\n\t/**\n\t * Returns whether or not this object is equal in value to the given\n\t * object.\n\t * \n\t * @author Ian Copland\n\t *\n\t * @param in_object - The other object.\n\t *\n\t * @return Whether or not the given object is equal to this.\n\t */\n\t@Override public boolean equals(Object in_object)\n\t{\n\t\tif (in_object == this)\n\t    {\n\t    \treturn true;\n\t    }\n\t\t\n\t\tif (in_object == null)\n\t    {\n\t    \treturn false;\n\t    }\n\t    \t\n\t    if ((in_object instanceof Integer3) == false)\n\t    {\n\t    \treturn false;\n\t    }\n\t    \n\t    Integer3 integer3 = (Integer3)in_object;\n\t    return (m_x == integer3.m_x && m_y == integer3.m_y && m_z == integer3.m_z);\n\t}\t\n\t/**\n\t * @author Ian Copland\n\t *\n\t * @return The hash code for this object.\n\t */\n\t@Override public int hashCode()\n\t{\n\t\tint hash = HashCodeUtils.INITIAL_VALUE;\n\t\thash = HashCodeUtils.add(hash, m_x);\n\t\thash = HashCodeUtils.add(hash, m_y);\n\t\thash = HashCodeUtils.add(hash, m_z);\n\t\treturn hash;\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/CoreUtils/src/com/chilliworks/chillisource/coreutils/Integer4.java",
    "content": "/**\n * Integer4.java\n * ChilliSource\n * Created by Ian Copland on 30/01/2013\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.coreutils;\n\n/**\n * An integer vector class. This is immutable after creation meaning it can\n * safely be passed into methods without side-effects.\n * \n * @author Ian Copland\n */\npublic final class Integer4\n{\n\tpublic static final Integer4 ZERO = new Integer4(0, 0, 0, 0);\n\tpublic static final Integer4 ONE = new Integer4(1, 1, 1, 1);\n\t\n\tprivate final int m_x;\n\tprivate final int m_y;\n\tprivate final int m_z;\n\tprivate final int m_w;\n\t\n\t/**\n\t * Returns the addition of the two provided Integer4s.\n\t * \n\t * @author Ian Copland\n\t *\n\t * @param in_a - the first Integer4.\n\t * @param in_b - the second Integer4.\n\t * \n\t * @return The result of the addition.\n\t */\n\tpublic static Integer4 add(Integer4 in_a, Integer4 in_b)\n\t{\n\t\treturn new Integer4(in_a.getX() + in_b.getX(), in_a.getY() + in_b.getY(), in_a.getZ() + in_b.getZ(), in_a.getW() + in_b.getW());\n\t}\n\t/**\n\t * Returns the subtraction of the two provided Integer4s.\n\t * \n\t * @author Ian Copland\n\t *\n\t * @param in_a - the first Integer4.\n\t * @param in_b - the second Integer4.\n\t * \n\t * @return The result of the subtraction.\n\t */\n\tpublic static Integer4 subtract(Integer4 in_a, Integer4 in_b)\n\t{\n\t\treturn new Integer4(in_a.getX() - in_b.getX(), in_a.getY() - in_b.getY(), in_a.getZ() - in_b.getZ(), in_a.getW() - in_b.getW());\n\t}\n\t/**\n\t * Returns the result of multiplying all components of the Integer4 by\n\t * the scalar.\n\t * \n\t * @author Ian Copland\n\t *\n\t * @param in_a - the Integer4.\n\t * @param in_b - the scalar.\n\t * \n\t * @return The result of the multiplication.\n\t */\n\tpublic static Integer4 multiply(Integer4 in_a, int in_b)\n\t{\n\t\treturn new Integer4(in_a.getX() * in_b, in_a.getY() * in_b, in_a.getZ() * in_b, in_a.getW() * in_b);\n\t}\n\t/**\n\t * Returns the result of multiplying the two Interger4's together.\n\t * \n\t * @author Ian Copland\n\t *\n\t * @param in_a - the first Integer4.\n\t * @param in_b - the second Integer4.\n\t * \n\t * @return The result of the multiplication.\n\t */\n\tpublic static Integer4 multiply(Integer4 in_a, Integer4 in_b)\n\t{\n\t\treturn new Integer4(in_a.getX() * in_b.getX(), in_a.getY() * in_b.getY(), in_a.getZ() * in_b.getZ(), in_a.getW() * in_b.getW());\n\t}\n\t/**\n\t * Takes the min value for each component from the two Integer4s.\n\t * \n\t * @author Ian Copland\n\t *\n\t * @param in_a - the first Integer4.\n\t * @param in_b - the second Integer4.\n\t * \n\t * @return The min value.\n\t */\n\tpublic static Integer4 min(Integer4 in_a, Integer4 in_b)\n\t{\n\t\treturn new Integer4(Math.min(in_a.getX(), in_b.getX()), Math.min(in_a.getY(), in_b.getY()), Math.min(in_a.getZ(), in_b.getZ()), Math.min(in_a.getW(), in_b.getW()));\n\t}\n\t/**\n\t * Takes the max value for each component from the two Integer4s.\n\t * \n\t * @author Ian Copland\n\t *\n\t * @param in_a - the first Integer4.\n\t * @param in_b - the second Integer4.\n\t * \n\t * @return The max value.\n\t */\n\tpublic static Integer4 max(Integer4 in_a, Integer4 in_b)\n\t{\n\t\treturn new Integer4(Math.max(in_a.getX(), in_b.getX()), Math.max(in_a.getY(), in_b.getY()), Math.max(in_a.getZ(), in_b.getZ()), Math.max(in_a.getW(), in_b.getW()));\n\t}\n\t/**\n\t * Parses an Integer4 from a string. Integer4 values should be provided \n\t * as integers and each component should be separated by a comma. For \n\t * example:  2, 600, -7, -23.\n\t * \n\t * @author Ian Copland\n\t *\n\t * @param in_int4String - The Integer4 string.\n\t */\n\tpublic static Integer4 parseInt4(String in_int4String)\n\t{\n\t\tString[] components = in_int4String.split(\",\");\n\t\tif (components.length == 4)\n\t\t{\n\t\t\tint x = Integer.parseInt(components[0].trim());\n\t\t\tint y = Integer.parseInt(components[1].trim());\n\t\t\tint z = Integer.parseInt(components[2].trim());\n\t\t\tint w = Integer.parseInt(components[3].trim());\n\t\t\t\n\t\t\treturn new Integer4(x, y, z, w);\n\t\t}\n\t\telse\n\t\t{\n\t\t\treturn Integer4.ZERO;\n\t\t}\n\t}\n\t/**\n\t * Constructor.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param in_x - The x value.\n\t * @param in_y - The y value.\n\t * @param in_z - The z value.\n\t * @param in_w - The w value.\n\t */\n\tpublic Integer4(int in_x, int in_y, int in_z, int in_w)\n\t{\n\t\tm_x = in_x;\n\t\tm_y = in_y;\n\t\tm_z = in_z;\n\t\tm_w = in_w;\n\t}\n\t/**\n\t * @author Ian Copland\n\t * \n\t * @return The x component.\n\t */\n\tpublic int getX()\n\t{\n\t\treturn m_x;\n\t}\n\t/**\n\t * @author Ian Copland\n\t * \n\t * @return The y component.\n\t */\n\tpublic int getY()\n\t{\n\t\treturn m_y;\n\t}\n\t/**\n\t * @author Ian Copland\n\t * \n\t * @return The z component.\n\t */\n\tpublic int getZ()\n\t{\n\t\treturn m_z;\n\t}\n\t/**\n\t * @author Ian Copland\n\t * \n\t * @return The w component.\n\t */\n\tpublic int getW()\n\t{\n\t\treturn m_w;\n\t}\n\t/**\n\t * @author Ian Copland\n\t *\n\t * @return This object in string form.\n\t */\n\t@Override public String toString()\n\t{\n\t\treturn m_x + \", \" + m_y + \", \" + m_z + \", \" + m_w;\n\t}\n\t/**\n\t * Returns whether or not this object is equal in value to the given\n\t * object.\n\t * \n\t * @author Ian Copland\n\t *\n\t * @param in_object - The other object.\n\t *\n\t * @return Whether or not the given object is equal to this.\n\t */\n\t@Override public boolean equals(Object in_object)\n\t{\n\t\tif (in_object == this)\n\t    {\n\t    \treturn true;\n\t    }\n\t\t\n\t\tif (in_object == null)\n\t    {\n\t    \treturn false;\n\t    }\n\t    \t\n\t    if ((in_object instanceof Integer4) == false)\n\t    {\n\t    \treturn false;\n\t    }\n\t    \n\t    Integer4 integer4 = (Integer4)in_object;\n\t    return (m_x == integer4.m_x && m_y == integer4.m_y && m_z == integer4.m_z && m_w == integer4.m_w);\n\t}\n\t/**\n\t * @author Ian Copland\n\t *\n\t * @return The hash code for this object.\n\t */\n\t@Override public int hashCode()\n\t{\n\t\tint hash = HashCodeUtils.INITIAL_VALUE;\n\t\thash = HashCodeUtils.add(hash, m_x);\n\t\thash = HashCodeUtils.add(hash, m_y);\n\t\thash = HashCodeUtils.add(hash, m_z);\n\t\thash = HashCodeUtils.add(hash, m_w);\n\t\treturn hash;\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/CoreUtils/src/com/chilliworks/chillisource/coreutils/LittleEndianWriterUtils.java",
    "content": "/**\n * LittleEndianWriterUtils.java\n * ChilliSource\n * Created by Ian Copland on 24/10/2014\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2014 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.coreutils;\n\nimport java.io.DataOutputStream;\nimport java.io.IOException;\nimport java.io.OutputStream;\n\n/**\n * A collection of methods for writing little endian binary files. All values\n * written using this will first be converted to little endian byte order.\n * \n * @author Ian Copland\n */\npublic final class LittleEndianWriterUtils\n{\n\tprivate static final long MAX_UNSIGNED_INT = 4294967295l;\n\tprivate static final int MAX_UNSIGNED_SHORT = 65535;\n\t\n\t/**\n\t * Writes a signed 32-bit integer value to the given output stream. The value \n\t * will be converted to little endian before being written.\n\t * \n\t * @param in_stream - The stream to write the value to.\n\t * @param in_value - The value to write to the stream.\n\t * \n\t * @throws IOException - Any IO Exception thrown by the given stream.\n\t */\n\tpublic static void writeInt32(OutputStream in_stream, int in_value) throws IOException\n\t{\n\t\tbyte[] bytes = new byte[4];\n\t\t\n\t\tbytes[0] = (byte)(in_value & 0xFF);\n\t\tbytes[1] = (byte)(in_value >>> 8 & 0xFF);\n\t\tbytes[2] = (byte)(in_value >>> 16 & 0xFF);\n\t\tbytes[3] = (byte)(in_value >>> 24 & 0xFF);\n\t\t\n\t\tin_stream.write(bytes);\n\t}\n\t/**\n\t * Writes an unsigned 32-bit integer value to the given output stream. The value \n\t * will be converted to little endian before being written.\n\t * \n\t * This is used to write unsigned values out with the max range of a signed int. \n\t * The value is provided as a long which should not be below zero or exceed \n\t * (2^32)-1. If a value is provided outside this range this will try to assert, \n\t * otherwise it will clamp to the valid range.\n\t * \n\t * @param in_stream - The stream to write the value to.\n\t * @param in_value - The value to write to the stream.\n\t * \n\t * @throws IOException - Any IO Exception thrown by the given stream.\n\t */\n\tpublic static void writeUInt32(OutputStream in_stream, long in_value) throws IOException\n\t{\n\t\tassert (in_value >= 0 && in_value <= MAX_UNSIGNED_INT) : \"Value outside range of a unsigned 32-bit integer.\";\n\t\tlong value = Math.max(in_value, 0);\n\t\tvalue = Math.min(value, MAX_UNSIGNED_INT);\n\t\t\n\t\tbyte[] bytes = new byte[4];\n\t\t\n\t\tbytes[0] = (byte)(value & 0xFF);\n\t\tbytes[1] = (byte)(value >>> 8 & 0xFF);\n\t\tbytes[2] = (byte)(value >>> 16 & 0xFF);\n\t\tbytes[3] = (byte)(value >>> 24 & 0xFF);\n\t\t\n\t\tin_stream.write(bytes);\n\t}\n\t/**\n\t * Writes a signed 16-bit integer value to the given output stream. The value will \n\t * be converted to little endian before being written.\n\t * \n\t * @param in_stream - The stream to write the value to.\n\t * @param in_value - The value to write to the stream.\n\t * \n\t * @throws IOException - Any IO Exception thrown by the given stream.\n\t */\n\tpublic static void writeInt16(OutputStream in_stream, short in_value) throws IOException\n\t{\n\t\tbyte[] bytes = new byte[2];\n\t\t\n\t\tbytes[0] = (byte)(in_value & 0xFF);\n\t\tbytes[1] = (byte)(in_value >>> 8 & 0xFF);\n\t\t\n\t\tin_stream.write(bytes);\n\t}\n\t/**\n\t * Writes an unsigned 16-bit integer value to the given output stream. The value \n\t * will be converted to little endian before being written.\n\t * \n\t * This is used to provide unsigned values out with the max range of a signed short. \n\t * The value is provided as an int which should not be below zero or exceed (2^16)-1.\n\t * If a value is provided outside this range this will try to assert, otherwise it \n\t * will clamp to the valid range.\n\t * \n\t * @param in_stream - The stream to write the value to.\n\t * @param in_value - The value to write to the stream.\n\t * \n\t * @throws IOException - Any IO Exception thrown by the given stream.\n\t */\n\tpublic static void writeUInt16(OutputStream in_stream, int in_value) throws IOException\n\t{\n\t\tassert (in_value >= 0 && in_value <= MAX_UNSIGNED_SHORT) : \"Value outside range of a unsigned 16-bit integer.\";\n\t\tint value = Math.max(in_value, 0);\n\t\tvalue = Math.min(value, MAX_UNSIGNED_SHORT);\n\n\t\tbyte[] bytes = new byte[2];\n\t\t\n\t\tbytes[0] = (byte)(value & 0xFF);\n\t\tbytes[1] = (byte)(value >>> 8 & 0xFF);\n\t\t\n\t\tin_stream.write(bytes);\n\t}\n\t/**\n\t * Writes an float value to the given output stream. The value will be \n\t * converted to little endian before being written.\n\t * \n\t * @param in_stream - The stream to write the value to.\n\t * @param in_value - The value to write to the stream.\n\t * \n\t * @throws IOException - Any IO Exception thrown by the given stream.\n\t */\n\tpublic static void writeFloat32(DataOutputStream in_stream, float in_value) throws IOException\n\t{\n\t\twriteInt32(in_stream, Float.floatToRawIntBits(in_value));\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/CoreUtils/src/com/chilliworks/chillisource/coreutils/Logging.java",
    "content": "/**\r\n * Logging.java\r\n * ChilliSource\r\n * Created by Ian Copland on 30/01/2013\r\n * \r\n * The MIT License (MIT)\r\n * \r\n * Copyright (c) 2013 Tag Games Limited\r\n * \r\n * Permission is hereby granted, free of charge, to any person obtaining a copy\r\n * of this software and associated documentation files (the \"Software\"), to deal\r\n * in the Software without restriction, including without limitation the rights\r\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\n * copies of the Software, and to permit persons to whom the Software is\r\n * furnished to do so, subject to the following conditions:\r\n * \r\n * The above copyright notice and this permission notice shall be included in\r\n * all copies or substantial portions of the Software.\r\n * \r\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r\n * THE SOFTWARE.\r\n */\r\n\r\npackage com.chilliworks.chillisource.coreutils;\r\n\r\nimport java.util.ArrayList;\r\nimport java.util.List;\r\n\r\n/**\r\n * A convenience class for logging messages and errors. All logging\r\n * should occur between calling start() and finish().\r\n * \r\n * @author Ian Copland\r\n */\r\npublic class Logging \r\n{\t\r\n\t/**\r\n\t * An enum describing the different logging levels.\r\n\t * \r\n\t * @author Ian Copland\r\n\t */\r\n\tpublic enum LoggingLevel\r\n\t{\r\n\t\tNONE,\r\n\t\tFATAL,\r\n\t\tERROR,\r\n\t\tWARNING,\r\n\t\tVERBOSE\r\n\t}\r\n\r\n\tpublic static String PARAM_LOGGING_LEVEL = \"--logginglevel\";\r\n\tpublic static String SHORT_PARAM_LOGGING_LEVEL = \"-ll\";\r\n\tpublic static String LOGGING_LEVEL_NONE = \"none\";\r\n\tpublic static String LOGGING_LEVEL_FATAL = \"fatal\";\r\n\tpublic static String LOGGING_LEVEL_ERROR = \"error\";\r\n\tpublic static String LOGGING_LEVEL_WARNING = \"warning\";\r\n\tpublic static String LOGGING_LEVEL_VERBOSE = \"verbose\";\r\n\r\n\tprivate static LoggingLevel m_loggingLevel = LoggingLevel.WARNING;\r\n\tprivate static int m_numWarnings = 0;\r\n\tprivate static int m_numErrors = 0;\r\n\tprivate static boolean m_active = false;\r\n\t\r\n\t/**\r\n\t * Checks the input arguments for the logging level parameter and updates\r\n\t * accordingly.\r\n\t * \r\n\t * @author Ian Copland\r\n\t * \r\n\t * @param The list of parameters into the application.\r\n\t * \r\n\t * @return The parameter array with the logging params stripped out.\r\n\t */\r\n\tpublic static String[] start(String[] in_args)\r\n\t{\r\n\t\tList<String> remainingArgs = new ArrayList<String>();\r\n\t\t\r\n\t\tif (m_active == false)\r\n\t\t{\r\n\t\t\tm_active = true;\r\n\t\t\t\r\n\t\t\tfor (int i = 0; i < in_args.length; ++i)\r\n\t\t\t{\r\n\t\t\t\tif (in_args[i].equalsIgnoreCase(PARAM_LOGGING_LEVEL) == true || in_args[i].equalsIgnoreCase(SHORT_PARAM_LOGGING_LEVEL) == true)\r\n\t\t\t\t{\r\n\t\t\t\t\tif (i+1 < in_args.length)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tString strLoggingLevel = in_args[i+1];\r\n\t\t\t\t\t\tif (strLoggingLevel.equalsIgnoreCase(LOGGING_LEVEL_NONE) == true) \t\t\t\r\n\t\t\t\t\t\t\tLogging.setLoggingLevel(LoggingLevel.NONE);\r\n\t\t\t\t\t\telse if (strLoggingLevel.equalsIgnoreCase(LOGGING_LEVEL_FATAL) == true) \t\r\n\t\t\t\t\t\t\tLogging.setLoggingLevel(LoggingLevel.FATAL); \r\n\t\t\t\t\t\telse if (strLoggingLevel.equalsIgnoreCase(LOGGING_LEVEL_ERROR) == true) \t\r\n\t\t\t\t\t\t\tLogging.setLoggingLevel(LoggingLevel.ERROR); \r\n\t\t\t\t\t\telse if (strLoggingLevel.equalsIgnoreCase(LOGGING_LEVEL_WARNING) == true) \t\r\n\t\t\t\t\t\t\tLogging.setLoggingLevel(LoggingLevel.WARNING); \r\n\t\t\t\t\t\telse if (strLoggingLevel.equalsIgnoreCase(LOGGING_LEVEL_VERBOSE) == true) \t\r\n\t\t\t\t\t\t\tLogging.setLoggingLevel(LoggingLevel.VERBOSE);\r\n\t\t\t\t\t\telse\r\n\t\t\t\t\t\t\tLogging.logFatal(\"Invalid Logging Level parameter provided.\");\r\n\t\t\t\t\t}\r\n\t\t\t\t\telse\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tLogging.logFatal(\"Logging level argument specified with no level provided.\");\r\n\t\t\t\t\t}\r\n\t\t\t\t\ti++;\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t{\r\n\t\t\t\t\tremainingArgs.add(in_args[i]);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\t\r\n\t\treturn remainingArgs.toArray(new String[0]);\r\n\t}\r\n\t/**\r\n\t * Sets the current logging level. Note that this should normally\r\n\t * be set by the user through the --logginglevel parameter.\r\n\t * \r\n\t * @author Ian Copland\r\n\t * \r\n\t * @param The logging level.\r\n\t */\r\n\tpublic static void setLoggingLevel(LoggingLevel in_loggingLevel)\r\n\t{\r\n\t\tm_loggingLevel = in_loggingLevel;\r\n\t}\r\n\t/**\r\n\t * @author Ian Copland\r\n\t * \r\n\t * @return The current logging level.\r\n\t */\r\n\tpublic static LoggingLevel getLoggingLevel()\r\n\t{\r\n\t\treturn m_loggingLevel;\r\n\t}\r\n\t/**\r\n\t * Logs a message to the standard out stream if the logging \r\n\t * level is set to verbose.\r\n\t * \r\n\t * @author Ian Copland\r\n\t * \r\n\t * @param The message to log.\r\n\t */\r\n\tpublic static void logVerbose(String in_message)\r\n\t{\r\n\t\tif (m_active == true && m_loggingLevel.ordinal() >= LoggingLevel.VERBOSE.ordinal())\r\n\t\t{\r\n\t\t\tprintStandard(in_message);\r\n\t\t}\r\n\t}\r\n\t/**\r\n\t * Logs a warning to the standard error stream if the logging\r\n\t * level is set to warning or higher.\r\n\t * \r\n\t * @author Ian Copland\r\n\t * \r\n\t * @param The warning to log.\r\n\t */\r\n\tpublic static void logWarning(String in_message)\r\n\t{\r\n\t\tif (m_active == true && m_loggingLevel.ordinal() >= LoggingLevel.WARNING.ordinal())\r\n\t\t{\r\n\t\t\tprintError(\"WARNING: \" + in_message);\r\n\t\t\t++m_numWarnings;\r\n\t\t}\r\n\t}\r\n\t/**\r\n\t * Logs an error to the standard error stream if the logging\r\n\t * level is set to error or higher.\r\n\t * \r\n\t * @author Ian Copland\r\n\t * \r\n\t * @param The error to log.\r\n\t */\r\n\tpublic static void logError(String in_message)\r\n\t{\r\n\t\tif (m_active == true && m_loggingLevel.ordinal() >= LoggingLevel.ERROR.ordinal())\r\n\t\t{\r\n\t\t\tprintError(\"ERROR: \" + in_message);\r\n\t\t\t++m_numErrors;\r\n\t\t}\r\n\t}\r\n\t/**\r\n\t * Logs an error to the standard error stream if the logging\r\n\t * level is set to error or higher. Also exits the application.\r\n\t * \r\n\t * @author Ian Copland\r\n\t * \r\n\t * @param The error to log.\r\n\t */\r\n\tpublic static void logFatal(String in_message)\r\n\t{\r\n\t\tif (m_active == true)\r\n\t\t{\r\n\t\t\tif (m_loggingLevel.ordinal() >= LoggingLevel.ERROR.ordinal())\r\n\t\t\t{\r\n\t\t\t\tprintError(\"FATAL: \" + in_message);\r\n\t\t\t\t++m_numErrors;\r\n\t\t\t\tfinish();\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\tSystem.exit(1);\r\n\t\t}\r\n\t}\r\n\t/**\r\n\t * Finishes logging. If any warnings or errors have occurred the number\r\n\t * of them will be printed.\r\n\t * \r\n\t * @author Ian Copland\r\n\t */\r\n\tpublic static void finish()\r\n\t{\r\n\t\tif (m_active == true && m_loggingLevel.ordinal() >= LoggingLevel.FATAL.ordinal())\r\n\t\t{\r\n\t\t\tif (m_numWarnings > 0 || m_numErrors > 0 || m_loggingLevel.ordinal() >= LoggingLevel.VERBOSE.ordinal())\r\n\t\t\t{\r\n\t\t\t\tprintStandard(Integer.toString(m_numWarnings) + \" Warnings found.\");\r\n\t\t\t\tprintStandard(Integer.toString(m_numErrors) + \" Errors found.\");\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\t/**\r\n\t * Prints a single line to the standard out stream.\r\n\t * \r\n\t * @author Ian Copland\r\n\t * \r\n\t * @param The line to print.\r\n\t */\r\n\tprivate static void printStandard(String in_message)\r\n\t{\r\n\t\tSystem.out.print(in_message + \"\\n\");\r\n\t}\r\n\t/**\r\n\t * Prints a single line to the standard error stream.\r\n\t * \r\n\t * @author Ian Copland\r\n\t * \r\n\t * @param The line to print.\r\n\t */\r\n\tprivate static void printError(String in_message)\r\n\t{\r\n\t\tSystem.err.print(in_message + \"\\n\");\r\n\t}\r\n}\r\n\r\n"
  },
  {
    "path": "Projects/Tools/CoreUtils/src/com/chilliworks/chillisource/coreutils/Matrix4.java",
    "content": "/**\n * Matrix4.java\n * ChilliSource\n * Created by Ian Copland on 30/01/2013\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.coreutils;\n\n/**\n * A basic 4x4 matrix math class. This is immutable after construction to ensure it is safe\n * to pass into methods.\n * \n * @author Ian Copland\n */\npublic final class Matrix4 \n{\n\tpublic static final Matrix4 IDENTITY = new Matrix4(\n\t\t\t1.0, 0.0, 0.0, 0.0,  \n\t\t\t0.0, 1.0, 0.0, 0.0,  \n\t\t\t0.0, 0.0, 1.0, 0.0,  \n\t\t\t0.0, 0.0, 0.0, 1.0);\n\n\tprivate double[] m_data;\n\n\t/**\n\t * Creates a new matrix which describes the given translation.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param in_translation - The translation the matrix should describe.\n\t * \n\t * @return The translation matrix.\n\t */\n\tpublic static Matrix4 createTranslation(Vector3 in_translation)\n\t{\n\t\treturn new Matrix4(1.0, 0.0, 0.0, 0.0,\n\t\t\t\t0.0, 1.0, 0.0, 0.0,\n\t\t\t\t0.0, 0.0, 1.0, 0.0,\n\t\t\t\tin_translation.getX(), in_translation.getY(), in_translation.getZ(), 1.0);\n\t}\n\t/**\n\t * Creates a new matrix which describes the given scale.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param in_scale - The scale the matrix should describe.\n\t * \n\t * @return The scale matrix.\n\t */\n\tpublic static Matrix4 createScale(Vector3 in_scale)\n\t{\n\t\treturn new Matrix4(in_scale.getX(), 0.0, 0.0, 0.0,\n\t\t\t\t0.0, in_scale.getY(), 0.0, 0.0,\n\t\t\t\t0.0, 0.0, in_scale.getZ(), 0.0,\n\t\t\t\t0.0, 0.0, 0.0, 1.0);\n\t}\n\t/**\n\t * Creates a new rotation matrix which describes the given rotation\n\t * around the X axis.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param in_angle - The angle around the X axis in radians.\n\t * \n\t * @return The rotation matrix.\n\t */\n\tpublic static Matrix4 createRotateX(double in_angle)\n\t{\n\t\tdouble cosA = Math.cos(in_angle);\n\t\tdouble sinA = Math.sin(in_angle);\n\t\t\n\t\treturn new Matrix4(1.0, 0.0, 0.0, 0.0,\n\t\t\t\t0.0, cosA, sinA, 0.0,\n\t\t\t\t0.0, -sinA, cosA, 0.0,\n\t\t\t\t0.0, 0.0, 0.0, 1.0);\n\t}\n\t/**\n\t * Creates a new rotation matrix which describes the given rotation\n\t * around the Y axis.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param in_angle - The angle around the Y axis in radians.\n\t * \n\t * @return The rotation matrix.\n\t */\n\tpublic static Matrix4 createRotateY(double in_angle)\n\t{\n\t\tdouble cosA = Math.cos(in_angle);\n\t\tdouble sinA = Math.sin(in_angle);\n\t\t\n\t\treturn new Matrix4(cosA, 0.0, -sinA, 0.0,\n\t\t\t\t0.0, 1.0, 0.0, 0.0,\n\t\t\t\tsinA, 0.0, cosA, 0.0,\n\t\t\t\t0.0, 0.0, 0.0, 1.0);\n\t}\n\t/**\n\t * Creates a new rotation matrix which describes the given rotation\n\t * around the Z axis.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param in_angle - The angle around the Z axis in radians.\n\t * \n\t * @return The rotation matrix.\n\t */\n\tpublic static Matrix4 createRotateZ(double in_angle)\n\t{\n\t\tdouble cosA = Math.cos(in_angle);\n\t\tdouble sinA = Math.sin(in_angle);\n\t\t\n\t\treturn new Matrix4(cosA, sinA, 0.0, 0.0,\n\t\t\t\t-sinA, cosA, 0.0, 0.0,\n\t\t\t\t0.0, 0.0, 1.0, 0.0,\n\t\t\t\t0.0, 0.0, 0.0, 1.0);\n\t}\n\t/**\n\t * Creates a rotation matrix that describes the rotation given by\n\t * the input quaternion.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param in_orientation - The orientation quaternion.\n\t * \n\t * @return The rotation matrix.\n\t */\n\tpublic static Matrix4 createRotation(Quaternion in_orientation)\n\t{\n\t\tQuaternion q = Quaternion.normalise(in_orientation);\n\n\t\tdouble wSquared = q.getW() * q.getW();\n\t\tdouble xSquared = q.getX() * q.getX();\n\t\tdouble ySquared = q.getY() * q.getY();\n\t\tdouble zSquared = q.getZ() * q.getZ();\n\n\t\tdouble a0 = wSquared + xSquared - ySquared - zSquared;\n\t\tdouble a1 = 2.0 * q.getX() * q.getY() + 2.0 * q.getW() * q.getZ();\n\t\tdouble a2 = 2.0 * q.getX() * q.getZ() - 2.0 * q.getW() * q.getY();\n\t\t\n\t\tdouble b0 = 2.0 * q.getX() * q.getY() - 2.0 * q.getW() * q.getZ();\n\t\tdouble b1 = wSquared - xSquared + ySquared - zSquared;\n\t\tdouble b2 = 2.0 * q.getY() * q.getZ() + 2.0 * q.getW() * q.getX();\n\t\t\n\t\tdouble c0 = 2.0 * q.getX() * q.getZ() + 2.0 * q.getW() * q.getY();\n\t\tdouble c1 = 2.0 * q.getY() * q.getZ() - 2.0 * q.getW() * q.getX();\n\t\tdouble c2 = wSquared - xSquared - ySquared + zSquared;\n\t\n\t\treturn new Matrix4(a0, a1, a2, 0.0,\n\t\t\t\tb0, b1, b2, 0.0,\n\t\t\t\tc0, c1, c2, 0.0,\n\t\t\t\t0.0, 0.0, 0.0, 1.0);\n\t}\n\t/**\n\t * Creates a new transform matrix from the given translation, scale and orientation.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param in_translation - The translation vector.\n\t * @param in_scale - The scale vector.\n\t * @param in_orientation - The orientation quaternion.\n\t * \n\t * @return The new transform matrix.\n\t */\n\tpublic static Matrix4 createTransform(Vector3 in_translation, Vector3 in_scale, Quaternion in_orientation)\n\t{\n\t\tMatrix4 rot = in_orientation.toMatrix();\n\t\t\n\t\treturn new Matrix4(in_scale.getX() * rot.m_data[0], in_scale.getX() * rot.m_data[1], in_scale.getX() * rot.m_data[2], 0.0,\n\t\t\t\tin_scale.getY() * rot.m_data[4], in_scale.getY() * rot.m_data[5], in_scale.getY() * rot.m_data[6], 0.0,\n\t\t\t\tin_scale.getZ() * rot.m_data[8], in_scale.getZ() * rot.m_data[9], in_scale.getZ() * rot.m_data[10], 0.0,\n\t\t\t\tin_translation.getX(), in_translation.getY(), in_translation.getZ(), 1.0);\n\t}\n\t/**\n\t * @author Ian Copland\n\t * \n\t * @param in_a - The first matrix.\n\t * @param in_b - The second matrix.\n\t * \n\t * @return The result of multiplying the two matrices together.\n\t */\n\tpublic static Matrix4 multiply(Matrix4 inA, Matrix4 inB)\n\t{\n\t\tdouble a0 = inA.m_data[0] * inB.m_data[0] + inA.m_data[1] * inB.m_data[4] + inA.m_data[2] * inB.m_data[8] + inA.m_data[3] * inB.m_data[12];\n\t\tdouble a1 = inA.m_data[0] * inB.m_data[1] + inA.m_data[1] * inB.m_data[5] + inA.m_data[2] * inB.m_data[9] + inA.m_data[3] * inB.m_data[13];\n\t\tdouble a2 = inA.m_data[0] * inB.m_data[2] + inA.m_data[1] * inB.m_data[6] + inA.m_data[2] * inB.m_data[10] + inA.m_data[3] * inB.m_data[14];\n\t\tdouble a3 = inA.m_data[0] * inB.m_data[3] + inA.m_data[1] * inB.m_data[7] + inA.m_data[2] * inB.m_data[11] + inA.m_data[3] * inB.m_data[15];\n\t\t\n\t\tdouble b0 = inA.m_data[4] * inB.m_data[0] + inA.m_data[5] * inB.m_data[4] + inA.m_data[6] * inB.m_data[8] + inA.m_data[7] * inB.m_data[12];\n\t\tdouble b1 = inA.m_data[4] * inB.m_data[1] + inA.m_data[5] * inB.m_data[5] + inA.m_data[6] * inB.m_data[9] + inA.m_data[7] * inB.m_data[13];\n\t\tdouble b2 = inA.m_data[4] * inB.m_data[2] + inA.m_data[5] * inB.m_data[6] + inA.m_data[6] * inB.m_data[10] + inA.m_data[7] * inB.m_data[14];\n\t\tdouble b3 = inA.m_data[4] * inB.m_data[3] + inA.m_data[5] * inB.m_data[7] + inA.m_data[6] * inB.m_data[11] + inA.m_data[7] * inB.m_data[15];\n\t\t\n\t\tdouble c0 = inA.m_data[8] * inB.m_data[0] + inA.m_data[9] * inB.m_data[4] + inA.m_data[10] * inB.m_data[8] + inA.m_data[11] * inB.m_data[12];\n\t\tdouble c1 = inA.m_data[8] * inB.m_data[1] + inA.m_data[9] * inB.m_data[5] + inA.m_data[10] * inB.m_data[9] + inA.m_data[11] * inB.m_data[13];\n\t\tdouble c2 = inA.m_data[8] * inB.m_data[2] + inA.m_data[9] * inB.m_data[6] + inA.m_data[10] * inB.m_data[10] + inA.m_data[11] * inB.m_data[14];\n\t\tdouble c3 = inA.m_data[8] * inB.m_data[3] + inA.m_data[9] * inB.m_data[7] + inA.m_data[10] * inB.m_data[11] + inA.m_data[11] * inB.m_data[15];\n\t\t\n\t\tdouble d0 = inA.m_data[12] * inB.m_data[0] + inA.m_data[13] * inB.m_data[4] + inA.m_data[14] * inB.m_data[8] + inA.m_data[15] * inB.m_data[12];\n\t\tdouble d1 = inA.m_data[12] * inB.m_data[1] + inA.m_data[13] * inB.m_data[5] + inA.m_data[14] * inB.m_data[9] + inA.m_data[15] * inB.m_data[13];\n\t\tdouble d2 = inA.m_data[12] * inB.m_data[2] + inA.m_data[13] * inB.m_data[6] + inA.m_data[14] * inB.m_data[10] + inA.m_data[15] * inB.m_data[14];\n\t\tdouble d3 = inA.m_data[12] * inB.m_data[3] + inA.m_data[13] * inB.m_data[7] + inA.m_data[14] * inB.m_data[11] + inA.m_data[15] * inB.m_data[15];\n\t\t\n\t\treturn new Matrix4(a0, a1, a2, a3,\n\t\t\t\tb0, b1, b2, b3,\n\t\t\t\tc0, c1, c2, c3,\n\t\t\t\td0, d1, d2, d3);\n\t}\n\t/**\n\t * Returns a new matrix that is the inverse of the given matrix.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param in_mat - The matrix to get the inverse of.\n\t * \n\t * @return The inverse matrix.\n\t */\n\tpublic static Matrix4 inverse(Matrix4 in_mat)\n\t{\n\t\tdouble m00 = in_mat.m_data[0]; double m01 = in_mat.m_data[1]; double m02 = in_mat.m_data[2]; double m03 = in_mat.m_data[3];\n\t\tdouble m10 = in_mat.m_data[4]; double m11 = in_mat.m_data[5]; double m12 = in_mat.m_data[6]; double m13 = in_mat.m_data[7];\n\t\tdouble m20 = in_mat.m_data[8]; double m21 = in_mat.m_data[9]; double m22 = in_mat.m_data[10]; double m23 = in_mat.m_data[11];\n\t\tdouble m30 = in_mat.m_data[12]; double m31 = in_mat.m_data[13]; double m32 = in_mat.m_data[14]; double m33 = in_mat.m_data[15];\n\t\t\n\t\tdouble v0 = m20 * m31 - m21 * m30;\n\t\tdouble v1 = m20 * m32 - m22 * m30;\n\t\tdouble v2 = m20 * m33 - m23 * m30;\n\t\tdouble v3 = m21 * m32 - m22 * m31;\n\t\tdouble v4 = m21 * m33 - m23 * m31;\n\t\tdouble v5 = m22 * m33 - m23 * m32;\n\t\t\n\t\tdouble t00 = + (v5 * m11 - v4 * m12 + v3 * m13);\n\t\tdouble t10 = - (v5 * m10 - v2 * m12 + v1 * m13);\n\t\tdouble t20 = + (v4 * m10 - v2 * m11 + v0 * m13);\n\t\tdouble t30 = - (v3 * m10 - v1 * m11 + v0 * m12);\n\t\t\n\t\tdouble invDet = 1.0 / (t00 * m00 + t10 * m01 + t20 * m02 + t30 * m03);\n\t\t\n\t\tdouble d00 = t00 * invDet;\n\t\tdouble d10 = t10 * invDet;\n\t\tdouble d20 = t20 * invDet;\n\t\tdouble d30 = t30 * invDet;\n\t\t\n\t\tdouble d01 = -(v5 * m01 - v4 * m02 + v3 * m03) * invDet;\n\t\tdouble d11 =  (v5 * m00 - v2 * m02 + v1 * m03) * invDet;\n\t\tdouble d21 = -(v4 * m00 - v2 * m01 + v0 * m03) * invDet;\n\t\tdouble d31 =  (v3 * m00 - v1 * m01 + v0 * m02) * invDet;\n\t\t\n\t\tv0 = m10 * m31 - m11 * m30;\n\t\tv1 = m10 * m32 - m12 * m30;\n\t\tv2 = m10 * m33 - m13 * m30;\n\t\tv3 = m11 * m32 - m12 * m31;\n\t\tv4 = m11 * m33 - m13 * m31;\n\t\tv5 = m12 * m33 - m13 * m32;\n\t\t\n\t\tdouble d02 =  (v5 * m01 - v4 * m02 + v3 * m03) * invDet;\n\t\tdouble d12 = -(v5 * m00 - v2 * m02 + v1 * m03) * invDet;\n\t\tdouble d22 =  (v4 * m00 - v2 * m01 + v0 * m03) * invDet;\n\t\tdouble d32 = -(v3 * m00 - v1 * m01 + v0 * m02) * invDet;\n\t\t\n\t\tv0 = m21 * m10 - m20 * m11;\n\t\tv1 = m22 * m10 - m20 * m12;\n\t\tv2 = m23 * m10 - m20 * m13;\n\t\tv3 = m22 * m11 - m21 * m12;\n\t\tv4 = m23 * m11 - m21 * m13;\n\t\tv5 = m23 * m12 - m22 * m13;\n\t\t\n\t\tdouble d03 = -(v5 * m01 - v4 * m02 + v3 * m03) * invDet;\n\t\tdouble d13 =  (v5 * m00 - v2 * m02 + v1 * m03) * invDet;\n\t\tdouble d23 = -(v4 * m00 - v2 * m01 + v0 * m03) * invDet;\n\t\tdouble d33 =  (v3 * m00 - v1 * m01 + v0 * m02) * invDet;\n\t\t\n\t\treturn new Matrix4(d00, d01, d02, d03,\n\t\t\td10, d11, d12, d13,\n\t\t\td20, d21, d22, d23,\n\t\t\td30, d31, d32, d33);\n\t}\n\t/**\n\t * Returns a copy of the given matrix with the Y and Z components swapped.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param in_mat - The matrix to swap the components of.\n\t * \n\t * @return The new matrix with swapped Y and Z.\n\t */\n\tpublic static Matrix4 swapYandZ(Matrix4 in_mat)\n\t{\n\t\treturn new Matrix4(in_mat.m_data[0], in_mat.m_data[2], in_mat.m_data[1], in_mat.m_data[3],\n\t\t\tin_mat.m_data[8], in_mat.m_data[10], in_mat.m_data[9], in_mat.m_data[11],\n\t\t\tin_mat.m_data[4], in_mat.m_data[6], in_mat.m_data[5], in_mat.m_data[7],\n\t\t\tin_mat.m_data[12], in_mat.m_data[14], in_mat.m_data[13], in_mat.m_data[15]);\n\t}\n\t/**\n\t * Constructor. Creates the matrix with the given components. After construction this\n\t * is immutable.\n\t * \n\t * @param in_a0 - The component at row 1, column 1.\n\t * @param in_a1 - The component at row 1, column 2.\n\t * @param in_a2 - The component at row 1, column 3.\n\t * @param in_a3 - The component at row 1, column 4.\n\t * @param in_b0 - The component at row 2, column 1.\n\t * @param in_b1 - The component at row 2, column 2.\n\t * @param in_b2 - The component at row 2, column 3.\n\t * @param in_b3 - The component at row 2, column 4.\n\t * @param in_c0 - The component at row 3, column 1.\n\t * @param in_c1 - The component at row 3, column 2.\n\t * @param in_c2 - The component at row 3, column 3.\n\t * @param in_c3 - The component at row 3, column 4.\n\t * @param in_d0 - The component at row 4, column 1.\n\t * @param in_d1 - The component at row 4, column 2.\n\t * @param in_d2 - The component at row 4, column 3.\n\t * @param in_d3 - The component at row 4, column 4.\n\t */\n\tpublic Matrix4(double in_a0, double in_a1, double in_a2, double in_a3,\n\t\t\tdouble in_b0, double in_b1, double in_b2, double in_b3,\n\t\t\tdouble in_c0, double in_c1, double in_c2, double in_c3,\n\t\t\tdouble in_d0, double in_d1, double in_d2, double in_d3)\n\t{\n\t\tm_data = new double[16];\n\t\tm_data[0] = in_a0; \tm_data[1] = in_a1; \tm_data[2] = in_a2; \tm_data[3] = in_a3;\n\t\tm_data[4] = in_b0; \tm_data[5] = in_b1; \tm_data[6] = in_b2; \tm_data[7] = in_b3;\n\t\tm_data[8] = in_c0; \tm_data[9] = in_c1; \tm_data[10] = in_c2; m_data[11] = in_c3;\n\t\tm_data[12] = in_d0; m_data[13] = in_d1; m_data[14] = in_d2; m_data[15] = in_d3;\n\t}\n\t/**\n\t * @author Ian Copland\n\t * \n\t * @param in_column - The column. \n\t * @param in_row - The row.\n\t * \n\t * @return The value at the given column and row.\n\t */\n\tpublic double get(int in_column, int in_row)\n\t{\n\t\treturn m_data[in_column + in_row * 4];\n\t}\n\t/**\n\t * @author Ian Copland\n\t * \n\t * @param in_index - The index into the \n\t * \n\t * @return The value at the given index. Values are stored in row-major \n\t * ordering.\n\t */\n\tpublic double get(int in_index)\n\t{\n\t\treturn m_data[in_index];\n\t}\n\t/**\n\t * @author Ian Copland\n\t * \n\t * @return Returns the rotation and euler angles.\n\t */\n\tpublic Vector3 getEulerAngles()\n\t{\n\t\t// The following algorithm has been taken from \"Computing Euler angles from a rotation matrix\" by Gregory G. Slabaugh. \n\t\t// The original document can be found at: http://www.gregslabaugh.name/publications/euler.pdf\n\t\t// Note: While the algorithm can return two sets of possible  answers, we are only returning 1 for simplicities sake.\n\t\t\n\t\tdouble x = 0.0;\n\t\tdouble y = 0.0;\n\t\tdouble z = 0.0;\n\t\tif (m_data[8] != 1.0 && m_data[8] != -1.0)\n\t\t{\n\t\t\t//only take one set of angles.\n\t\t\ty = -Math.asin(m_data[8]); \n\t\t\tx = Math.atan2(m_data[9] / Math.cos(y), m_data[9] / Math.cos(y));\n\t\t\tz = Math.atan2(m_data[4] / Math.cos(y), m_data[0] / Math.cos(y));\n\t\t}\n\t\telse\n\t\t{\n\t\t\tz = 0.0;\n\t\t\tif (m_data[8] == -1)\n\t\t\t{\n\t\t\t\ty = Math.PI * 0.5;\n\t\t\t\tx = z + Math.atan2(m_data[1], m_data[2]);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\ty = -Math.PI * 0.5;\n\t\t\t\tx = -z + Math.atan2(-m_data[1], -m_data[2]);\n\t\t\t}\n\t\t}\n\t\t\n\t\treturn new Vector3(x, y ,z);\n\t}\n\t/**\n\t * @author Ian Copland\n\t * \n\t * @return Whether or not this matrix has a scaling component.\n\t */\n\tpublic boolean containsScale()\n\t{\n\t\tMatrix4 theCopy = new Matrix4(m_data[0], m_data[1], m_data[2], m_data[3], \n\t\t\t\tm_data[4], m_data[5], m_data[6], m_data[6], \n\t\t\t\tm_data[8], m_data[9], m_data[10], m_data[11], \n\t\t\t\t0.0, 0.0, 0.0, m_data[15]);\n\n\t\tVector3 rotationX = Vector3.multiply(new Vector3(1.0, 0.0, 0.0), theCopy);\n\t\tVector3 rotationY = Vector3.multiply(new Vector3(0.0, 1.0, 0.0), theCopy);\n\t\tVector3 rotationZ = Vector3.multiply(new Vector3(0.0, 0.0, 1.0), theCopy);\n\t\t\n\t\tfinal double TOLERANCE = 0.00001;\n\t\tif (rotationY.getLength() < 1.0 - TOLERANCE || rotationY.getLength() > 1.0 + TOLERANCE ||\n\t\t\trotationX.getLength() < 1.0 - TOLERANCE || rotationX.getLength() > 1.0 + TOLERANCE ||\n\t\t\trotationZ.getLength() < 1.0 - TOLERANCE || rotationZ.getLength() > 1.0 + TOLERANCE)\n\t\t{\n\t\t\treturn true;\n\t\t}\n\t\t\n\t\treturn false;\n\t}\n\t/**\n\t * @author Ian Copland\n\t * \n\t * @return The translation part of the transform described by the matrix.\n\t */\n\tpublic Vector3 getTranslation()\n\t{\n\t\treturn new Vector3(m_data[12], m_data[13], m_data[14]);\n\t}\n\t/**\n\t * Returns the transform decomposed into its translation, scale and orientation.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @return A 3-tuple containg the transform, scale and orientation of the transform.\n\t */\n\tpublic Tuple3<Vector3, Vector3, Quaternion> decomposeTransforms()\n    {\n\t\t// Factor M = QR = QDU where Q is orthogonal, D is diagonal,\n\t\t// and U is upper triangular with ones on its diagonal.  Algorithm uses\n\t\t// Gram-Schmidt orthogonalization (the QR algorithm).\n\t\t//\n\t\t// If M = [ m0 | m1 | m2 ] and Q = [ q0 | q1 | q2 ], then\n\t\t//\n\t\t//   q0 = m0/|m0|\n\t\t//   q1 = (m1-(q0*m1)q0)/|m1-(q0*m1)q0|\n\t\t//   q2 = (m2-(q0*m2)q0-(q1*m2)q1)/|m2-(q0*m2)q0-(q1*m2)q1|\n\t\t//\n\t\t// where |V| indicates length of vector V and A*B indicates dot\n\t\t// product of vectors A and B.  The matrix R has entries\n\t\t//\n\t\t//   r00 = q0*m0  r01 = q0*m1  r02 = q0*m2\n\t\t//   r10 = 0      r11 = q1*m1  r12 = q1*m2\n\t\t//   r20 = 0      r21 = 0      r22 = q2*m2\n\t\t//\n\t\t// so D = diag(r00,r11,r22) and U has entries u01 = r01/r00,\n\t\t// u02 = r02/r00, and u12 = r12/r11.\n\t\t\n\t\t// Q = rotation\n\t\t// D = scaling\n\t\t// U = shear\n\t\t\n\t\t// D stores the three diagonal entries r00, r11, r22\n\t\t// U stores the entries U[0] = u01, U[1] = u02, U[2] = u12\n\t\t\n\t\t// build orthogonal matrix Q\n\t\tdouble invLength = 1.0 / Math.sqrt(m_data[0] * m_data[0] + m_data[1] * m_data[1] + m_data[2] * m_data[2]);\n\t\tdouble qA0 = m_data[0] * invLength;\n\t\tdouble qA1 = m_data[1] * invLength;\n\t\tdouble qA2 = m_data[2] * invLength;\n\t\t\n\t\tdouble fDot = qA0 * m_data[4] + qA1 * m_data[5] + qA2 * m_data[6];\n\t\tdouble qB0 = m_data[4] - fDot * qA0;\n\t\tdouble qB1 = m_data[5] - fDot * qA1;\n\t\tdouble qB2 = m_data[6] - fDot * qA2;\n\t\tinvLength = 1.0 / Math.sqrt(qB0 * qB0 + qB1 * qB1 + qB2 * qB2);\n\t\tqB0 *= invLength;\n\t\tqB1 *= invLength;\n\t\tqB2 *= invLength;\n\t\t\n\t\tfDot = qA0 * m_data[8] + qA1 * m_data[9] + qA2 * m_data[10];\n\t\tdouble qC0 = m_data[8] - fDot * qA0;\n\t\tdouble qC1 = m_data[9] - fDot * qA1;\n\t\tdouble qC2 = m_data[10] - fDot * qA2;\n\t\tfDot = qB0 * m_data[8] + qB1 * m_data[9] + qB2 * m_data[10];\n\t\tqC0 -= fDot * qB0;\n\t\tqC1 -= fDot * qB1;\n\t\tqC2 -= fDot * qB2;\n\t\tinvLength = 1.0 / Math.sqrt(qC0 * qC0 + qC1 * qC1 + qC2 * qC2);\n\t\tqC0 *= invLength;\n\t\tqC1 *= invLength;\n\t\tqC2 *= invLength;\n\t\t\n\t\t//guarantee that orthogonal matrix has determinant 1 (no reflections)\n\t\tdouble fDet = qA0 * qB1 * qC2 + qB0 * qC1 * qA2 +\n\t\t\t\tqC0 * qA1 * qB2 - qC0 * qB1 * qA2 -\n\t\t\t\tqB0 * qA1 * qC2 - qA0 * qC1 * qB2;\n\t\t\n\t\tMatrix4 q;\n\t\tif (fDet >= 0.0)\n\t\t{\n\t\t\tq = new Matrix4(qA0, qA1, qA2, 0.0,\n\t\t\t\t\tqB0, qB1, qB2, 0.0,\n\t\t\t\t\tqC0, qC1, qC2, 0.0,\n\t\t\t\t\t0.0, 0.0, 0.0, 1.0);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tq = new Matrix4(-qA0, -qA1, -qA2, 0.0,\n\t\t\t\t\t-qB0, -qB1, -qB2, 0.0,\n\t\t\t\t\t-qC0, -qC1, -qC2, 0.0,\n\t\t\t\t\t0.0, 0.0, 0.0, -1.0);\n\t\t}\n\t\t\n\t\t//build \"right\" matrix R\n\t\tdouble rA0 = q.m_data[0] * m_data[0] + q.m_data[1] * m_data[1] + q.m_data[2] * m_data[2];\n\t\tdouble rB0 = q.m_data[0] * m_data[4] + q.m_data[1] * m_data[5] + q.m_data[2] * m_data[6];\n\t\tdouble rB1 = q.m_data[4] * m_data[4] + q.m_data[5] * m_data[5] + q.m_data[6] * m_data[6];\n\t\tdouble rC0 = q.m_data[0] * m_data[8] + q.m_data[1] * m_data[9] + q.m_data[2] * m_data[10];\n\t\tdouble rC1 = q.m_data[4] * m_data[8] + q.m_data[5] * m_data[9] + q.m_data[6] * m_data[10];\n\t\tdouble rC2 = q.m_data[8] * m_data[8] + q.m_data[9] * m_data[9] + q.m_data[10] * m_data[10];\n\t\tMatrix4 r = new Matrix4(rA0, 0.0, 0.0, 0.0,\n\t\t\t\trB0, rB1, 0.0, 0.0,\n\t\t\t\trC0, rC1, rC2, 0.0,\n\t\t\t\t0.0, 0.0, 0.0, 1.0);\n\t\t\n\t\t//get the translation\n\t\tVector3 translation = new Vector3(m_data[12], m_data[13], m_data[14]);\n\t\t\n\t\t//the scaling component\n\t\tVector3 scale = new Vector3(r.m_data[0], r.m_data[5], r.m_data[10]);\n\t\n\t\t//get the orientation\n\t\tQuaternion orientation = new Quaternion(q);\n\t\t\n\t\treturn new Tuple3<Vector3, Vector3, Quaternion>(translation, scale, orientation);\n\t}\n\t/**\n\t * @author Ian Copland\n\t * \n\t * @return A string representation of the matrix.\n\t */\n\t@Override public String toString()\n\t{\n\t\treturn  \"\" + m_data[0] + \", \" + m_data[1] + \", \" + m_data[2] + \", \" + m_data[3] + \", \" + \n\t\t\tm_data[4] + \", \" + m_data[5] + \", \" + m_data[6] + \", \" + m_data[7] + \", \" + \n\t\t\tm_data[8] + \", \" + m_data[9] + \", \" + m_data[10] + \", \" + m_data[11] + \", \" +\n\t\t\tm_data[12] + \", \" + m_data[13] + \", \" + m_data[14] + \", \" + m_data[15];\n\t}\n\t/**\n\t * @author Ian Copland\n\t *\n\t * @param in_object - The other object.\n\t *\n\t * @return Whether or not the given object is equal to this.\n\t */\n\t@Override public boolean equals(Object in_object)\n\t{\n\t\tif (in_object == this)\n\t    {\n\t    \treturn true;\n\t    }\n\t\t\n\t\tif (in_object == null)\n\t    {\n\t    \treturn false;\n\t    }\n\t    \t\n\t    if ((in_object instanceof Matrix4) == false)\n\t    {\n\t    \treturn false;\n\t    }\n\t    \n\t    Matrix4 matrix4 = (Matrix4)in_object;\n\t    for (int i = 0; i < 16; ++i)\n    \t{\n\t    \tif (Double.compare(m_data[i], matrix4.m_data[i]) != 0)\n\t    \t{\n\t    \t\treturn false;\n\t    \t}\n    \t}\n\t    \n\t    return true;\n\t}\n\t/**\n\t * @author Ian Copland\n\t *\n\t * @return The hash code for this object.\n\t */\n\t@Override public int hashCode()\n\t{\n\t\tint hash = HashCodeUtils.INITIAL_VALUE;\n\t\tfor (int i = 0; i < 16; ++i)\n    \t{\n\t\t\thash = HashCodeUtils.add(hash, m_data[i]);\n    \t}\n\t\treturn hash;\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/CoreUtils/src/com/chilliworks/chillisource/coreutils/Pair.java",
    "content": "/**\n * Pair.java\n * ChilliSource\n * Created by Ian Copland on 08/10/2014.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2014 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.coreutils;\n\n/**\n * A simple pair, or 2-tuple class similar to std::pair<x,y> in C++. Typical use\n * case for this is private methods that return multiple values.\n * \n * @author Ian Copland\n *\n * @param <TFirst> The type of the first value.\n * @param <TSecond> The type of the second value.\n */\npublic final class Pair<TFirst, TSecond>\n{\n\tprivate final TFirst m_first;\n\tprivate final TSecond m_second;\n\t\n\t/**\n\t * Constructor. Creates the pair from the two given values.\n\t * \n\t * @author Ian Copland\n\t *\n\t * @param in_first - The first value.\n\t * @param in_second - The second value.\n\t */\n\tpublic Pair(TFirst in_first, TSecond in_second)\n\t{\n\t\tm_first = in_first;\n\t\tm_second = in_second;\n\t}\n\t/**\n\t * @author Ian Copland\n\t *\n\t * @return The first value.\n\t */\n\tpublic TFirst getFirst()\n\t{\n\t\treturn m_first;\n\t}\n\t/**\n\t * @author Ian Copland\n\t *\n\t * @return The second value.\n\t */\n\tpublic TSecond getSecond()\n\t{\n\t\treturn m_second;\n\t}\n\t/**\n\t * @author Ian Copland\n\t *\n\t * @return The pair as a string.\n\t */\n\t@Override public String toString() \n\t{\n        return m_first + \", \" + m_second;\n    }\n\t/**\n\t * Compares equality with the given object.\n\t * \n\t * @author Ian Copland\n\t *\n\t * @return Whether or not the two objects are equal.\n\t */\n    @Override public boolean equals(Object in_object) \n    {\n        if (in_object == this) \n        {\n            return true;\n        }\n    \t\n        if (in_object == null) \n        {\n            return false;\n        }\n        \n        if ((in_object instanceof Pair<?, ?>) == false)\n        {\n            return false;\n        }\n        \n        Pair<?, ?> pair = (Pair<?, ?>)in_object;\n        boolean firstEquals = ((m_first == null && pair.m_first == null) || (m_first != null && m_first.equals(pair.m_first) == true));\n        boolean secondEquals = ((m_second == null && pair.m_second == null) || (m_second != null && m_second.equals(pair.m_second) == true));\n        return (firstEquals == true && secondEquals == true);\n    }\n\t/**\n\t * @author Ian Copland\n\t *\n\t * @return The hash code for this object.\n\t */\n\t@Override public int hashCode()\n\t{\n\t\tint hash = HashCodeUtils.INITIAL_VALUE;\n\t\thash = HashCodeUtils.add(hash, m_first);\n\t\thash = HashCodeUtils.add(hash, m_second);\n\t\treturn hash;\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/CoreUtils/src/com/chilliworks/chillisource/coreutils/Quaternion.java",
    "content": "/**\n * Quaternion.java\n * ChilliSource\n * Created by Ian Copland on 30/01/2013\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.coreutils;\n\n/**\n * A basic Quaternion math class. This is immutable after construction so it can safely\n * be passed into methods.\n * \n * @author Ian Copland\n */\npublic final class Quaternion \n{\n\tpublic static final Quaternion IDENTITY = new Quaternion(0.0, 0.0, 0.0, 1.0);\n\t\n\tprivate double m_x;\n\tprivate double m_y;\n\tprivate double m_z;\n\tprivate double m_w;\n\n\t/**\n\t * Returns a normalised copy of the given quaternion.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param The Quaternion to copy.\n\t * \n\t * @return The normalised copy.\n\t */\n\tpublic static Quaternion normalise(Quaternion in_quaternion)\n\t{\n\t\tdouble s = 1.0 / Math.sqrt(in_quaternion.m_w * in_quaternion.m_w + in_quaternion.m_x * in_quaternion.m_x + in_quaternion.m_y * in_quaternion.m_y + in_quaternion.m_z * in_quaternion.m_z);\n\t\treturn new Quaternion(in_quaternion.m_x * s, in_quaternion.m_y * s, in_quaternion.m_z * s, in_quaternion.m_w * s);\n\t}\n\t/**\n\t * Constructor. Creates a new quaternion with the given components. After \n\t * construction the quaternion is immutable.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param in_x - The x component.\n\t * @param in_y - The y component.\n\t * @param in_z - The z component.\n\t * @param in_w - The w component.\n\t */\n\tpublic Quaternion(double in_x, double in_y, double in_z, double in_w)\n\t{\n\t\tm_x = in_x;\n\t\tm_y = in_y;\n\t\tm_z = in_z;\n\t\tm_w = in_w;\n\t}\n\t/**\n\t * Constructor. Creates a quaternion which describes the same rotation as\n\t * the given rotation. Matrix. After construction the quaternion is \n\t * immutable.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param in_matrix - The rotation matrix.\n\t */\n\tpublic Quaternion(Matrix4 in_matrix)\n\t{\n\t\t// Algorithm in Ken Shoemake's article in 1987 SIGGRAPH course notes\n\t\t// article \"Quaternion Calculus and Fast Animation\".\n\t\t\n\t\tdouble trace = in_matrix.get(0) + in_matrix.get(5) + in_matrix.get(10) + 1.0;\n\t\tdouble root = 0.0;\n\t\t\n\t\tif (trace > 0.0)\n\t\t{\n\t\t\troot = Math.sqrt(trace);\n\t\t\tm_w = 0.5 * root;\n\t\t\troot = 0.5 / root; \n\t\t\tm_x = (in_matrix.get(6) - in_matrix.get(9)) * root;\n\t\t\tm_y = (in_matrix.get(8) - in_matrix.get(2)) * root;\n\t\t\tm_z = (in_matrix.get(1) - in_matrix.get(4)) * root;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tint[] iNext = { 1, 2, 0 };\n\t\t\tint i = 0;\n\t\t\tif (in_matrix.get(5) > in_matrix.get(0))\n\t\t\t{\n\t\t\t\ti = 1;\n\t\t\t}\n\t\t\t\n\t\t\tif (in_matrix.get(10) > in_matrix.get(i,i))\n\t\t\t{\n\t\t\t\ti = 2;\n\t\t\t}\n\t\t\t\n\t\t\tint j = iNext[i];\n\t\t\tint k = iNext[j];\n\t\t\t\n\t\t\troot = Math.sqrt(in_matrix.get(i,i) - in_matrix.get(j,j) - in_matrix.get(k,k) + 1.0);\n\t\t\t\n\t\t\tdouble[] apkQuat = {0.0, 0.0, 0.0};\n\t\t\tapkQuat[i] = 0.5 * root;\n\t\t\troot = 0.5f/root;\n\t\t\t\n\t\t\tm_w = (in_matrix.get(k, j) - in_matrix.get(j, k)) * root;\n\t\t\t\n\t\t\tapkQuat[j] = (in_matrix.get(j, i) + in_matrix.get(i, j)) * root;\n\t\t\tapkQuat[k] = (in_matrix.get(k, i) + in_matrix.get(i, k)) * root;\n\t\t\t\n\t\t\tm_x = apkQuat[0];\n\t\t\tm_y = apkQuat[1];\n\t\t\tm_z = apkQuat[2];\n\t\t}\n\t}\n\t/**\n\t * Constructor. Creates a quaternion which describes the same rotation as the\n\t * given axis and angle. After construction the quaternion is immutable.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param in_axis - The axis.\n\t * @param in_angle - The angle.\n\t */\n\tpublic Quaternion(Vector3 in_axis, double in_angle)\n\t{\n\t\tVector3 norm = Vector3.normalise(in_axis);\n\t\tdouble halfAngle = in_angle / 2.0;\n\t\tdouble sinAngle = Math.sin(halfAngle);\n\t\t\n\t\tm_x = norm.getX() * sinAngle;\n\t\tm_y = norm.getY() * sinAngle;\n\t\tm_z = norm.getZ() * sinAngle;\n\t\tm_w = Math.cos(halfAngle);\n\t}\n\t/**\n\t * @author Ian Copland\n\t * \n\t * @return The x component of the quaternion.\n\t */\n\tpublic double getX()\n\t{\n\t\treturn m_x;\n\t}\n\t/**\n\t * @author Ian Copland\n\t * \n\t * @return The y component of the quaternion.\n\t */\n\tpublic double getY()\n\t{\n\t\treturn m_y;\n\t}\n\t/**\n\t * @author Ian Copland\n\t * \n\t * @return The z component of the quaternion.\n\t */\n\tpublic double getZ()\n\t{\n\t\treturn m_z;\n\t}\n\t/**\n\t * @author Ian Copland\n\t * \n\t * @return The w component of the quaternion.\n\t */\n\tpublic double getW()\n\t{\n\t\treturn m_w;\n\t}\n\t/**\n\t * @author Ian Copland\n\t * \n\t * @return The axis of rotation described by the Quaternion.\n\t */\n\tpublic Vector3 getAxis()\n\t{\n\t\tdouble sqrLength = (m_x * m_x + m_y * m_y + m_z * m_z);\n\n\t\tif (sqrLength > 0.0)\n\t\t{\n\t\t\tdouble inverseLength = 1.0 / Math.sqrt(sqrLength);\n\t\t\treturn new Vector3(m_x * inverseLength, m_y * inverseLength, m_z * inverseLength);\n\t\t}\n\n\t\treturn new Vector3(1.0, 0.0, 0.0); \n\t}\n\t/**\n\t * @author Ian Copland\n\t * \n\t * @return The angle of rotation described by the Quaternion.\n\t */\n\tpublic double getAngle()\n\t{\n\t\tdouble sqrLength = (m_x * m_x + m_y * m_y + m_z * m_z);\n\n\t\tif (sqrLength > 0.0)\n\t\t{\n\t\t\treturn 2.0 * Math.acos(m_w);\n\t\t} \n\n\t\treturn 0.0;\n\t}\n\t/**\n\t * @author Ian Copland\n\t * \n\t * @return A matrix which describes the same rotation as this quaternion.\n\t */\n\tpublic Matrix4 toMatrix()\n\t{\n\t\tdouble x2 = m_x * m_x;\n\t\tdouble y2 = m_y * m_y;\n\t\tdouble z2 = m_z * m_z;\n\t\tdouble xy = m_x * m_y;\n\t\tdouble xz = m_x * m_z;\n\t\tdouble yz = m_y * m_z;\n\t\tdouble wx = m_w * m_x;\n\t\tdouble wy = m_w * m_y;\n\t\tdouble wz = m_w * m_z;\n\t\t\n\t\treturn new Matrix4(1.0 - 2.0 * (y2 + z2), 2.0 * (xy + wz), 2.0 * (xz - wy), 0.0,\n\t\t\t\t2.0 * (xy - wz), 1.0 - 2.0 * (x2 + z2), 2.0 * (yz + wx), 0.0,\n\t\t\t\t2.0 * (xz + wy), 2.0 * (yz - wx), 1.0 - 2.0 * (x2 + y2), 0.0,\n\t\t\t\t0.0, 0.0, 0.0, 1.0);\n\t}\n\t/**\n\t * @author Ian Copland\n\t *\n\t * @return This object in string form.\n\t */\n\t@Override public String toString()\n\t{\n\t\treturn m_x + \", \" + m_y + \", \" + m_z + \", \" + m_w;\n\t}\n\t/**\n\t * Returns whether or not this object is equal in value to the given\n\t * object.\n\t * \n\t * @author Ian Copland\n\t *\n\t * @param in_object - The other object.\n\t *\n\t * @return Whether or not the given object is equal to this.\n\t */\n\t@Override public boolean equals(Object in_object)\n\t{\n\t\tif (in_object == this)\n\t    {\n\t    \treturn true;\n\t    }\n\t\t\n\t\tif (in_object == null)\n\t    {\n\t    \treturn false;\n\t    }\n\t    \t\n\t    if ((in_object instanceof Quaternion) == false)\n\t    {\n\t    \treturn false;\n\t    }\n\t    \n\t    Quaternion vector4 = (Quaternion)in_object;\n\t    return (Double.compare(m_x, vector4.m_x) == 0 && Double.compare(m_y, vector4.m_y) == 0 && Double.compare(m_z, vector4.m_z) == 0 && Double.compare(m_w, vector4.m_w) == 0);\n\t}\n\t/**\n\t * @author Ian Copland\n\t *\n\t * @return The hash code for this object.\n\t */\n\t@Override public int hashCode()\n\t{\n\t\tint hash = HashCodeUtils.INITIAL_VALUE;\n\t\thash = HashCodeUtils.add(hash, m_x);\n\t\thash = HashCodeUtils.add(hash, m_y);\n\t\thash = HashCodeUtils.add(hash, m_z);\n\t\thash = HashCodeUtils.add(hash, m_w);\n\t\treturn hash;\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/CoreUtils/src/com/chilliworks/chillisource/coreutils/StringUtils.java",
    "content": "/**\r\n * StringUtils.java\r\n * ChilliSource\r\n * Created by Ian Copland on 30/01/2013\r\n * \r\n * The MIT License (MIT)\r\n * \r\n * Copyright (c) 2013 Tag Games Limited\r\n * \r\n * Permission is hereby granted, free of charge, to any person obtaining a copy\r\n * of this software and associated documentation files (the \"Software\"), to deal\r\n * in the Software without restriction, including without limitation the rights\r\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\n * copies of the Software, and to permit persons to whom the Software is\r\n * furnished to do so, subject to the following conditions:\r\n * \r\n * The above copyright notice and this permission notice shall be included in\r\n * all copies or substantial portions of the Software.\r\n * \r\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r\n * THE SOFTWARE.\r\n */\r\n\r\npackage com.chilliworks.chillisource.coreutils;\r\n\r\nimport java.io.File;\r\nimport java.nio.charset.Charset;\r\n\r\n/**\r\n * A collection of convenience methods for working with Strings.\r\n * \r\n * @author Ian Copland\r\n */\r\npublic class StringUtils \r\n{\r\n\tprivate static final Charset UTF8_CHARSET = Charset.forName(\"UTF-8\");\r\n\t\r\n\t/**\r\n\t * Converts a string in UTF-16 format to a UTF8 byte array.\r\n\t * \r\n\t * @author Ian Copland\r\n\t * \r\n\t * @param in_string - The string to convert.\r\n\t * \r\n\t * @return The output byte array in UTF-8 format. \r\n\t */\r\n\tpublic static byte[] stringToUTF8Bytes(String in_string)\r\n\t{\r\n\t\treturn in_string.getBytes(UTF8_CHARSET);\r\n\t}\r\n\t/**\r\n\t * Converts UTF-8 byte array to a string in UTF-16 format.\r\n\t * \r\n\t * @param in_utf8Bytes - The byte array to convert.\r\n\t * \r\n\t * @return The output string.\r\n\t */\r\n\tpublic static String utf8BytesToString(final byte[] in_utf8Bytes)\r\n\t{\r\n\t\treturn new String(in_utf8Bytes, UTF8_CHARSET);\r\n\t}\r\n\t/**\r\n\t * Standardised the path to a file.\r\n\t * \r\n\t * @author Ian Copland\r\n\t * \r\n\t * @param The file path.\r\n\t * \r\n\t * @return The standardised file path.\r\n\t */\r\n\tpublic static String standardiseFilePath(String in_filePath)\r\n\t{\r\n\t\tString standardisedPath = in_filePath.replace(\"\\\\\", \"/\");\r\n\t\tstandardisedPath = standardisedPath.replace(\"//\", \"/\");\r\n\t\tif (standardisedPath.endsWith(\"/\") == true)\r\n\t\t{\r\n\t\t\tstandardisedPath = standardisedPath.substring(0, standardisedPath.length() - 1);\r\n\t\t}\r\n\t\treturn standardisedPath;\r\n\t}\r\n\t/**\r\n\t * Standardised the path to a file.\r\n\t * \r\n\t * @author Ian Copland\r\n\t * \r\n\t * @param The file path.\r\n\t * \r\n\t * @return The standardised file path.\r\n\t */\r\n\tpublic static String standardiseDirectoryPath(String in_directoryPath)\r\n\t{\r\n\t\tString standardisedPath = in_directoryPath.replace(\"\\\\\", \"/\");\r\n\t\tstandardisedPath = in_directoryPath.replace(\"//\", \"/\");\r\n\t\tif (standardisedPath.endsWith(\"/\") == false)\r\n\t\t{\r\n\t\t\tstandardisedPath += \"/\";\r\n\t\t}\r\n\t\treturn standardisedPath;\r\n\t}\r\n\t/**\r\n\t * @author Ian Copland\r\n\t *\r\n\t * @param in_path - The absolute file path\r\n\t * @param in_basePath - The base directory path\r\n\t *\r\n\t * @return The given file path relative to the base path.\r\n\t */\r\n\tpublic static String getRelativeFilePath(String in_filePath, String in_basePath) \r\n\t{\r\n\t    String relativePath = new File(in_basePath).toURI().relativize(new File(in_filePath).toURI()).getPath();\r\n\t    return standardiseFilePath(relativePath);\r\n\t}\r\n\t/**\r\n\t * @author Ian Copland\r\n\t *\r\n\t * @param in_path - The absolute directory path\r\n\t * @param in_basePath - The base directory path\r\n\t *\r\n\t * @return the given directory path relative to the base path.\r\n\t */\r\n\tpublic static String getRelativeDirectoryPath(String in_filePath, String in_basePath) \r\n\t{\r\n\t    String relativePath = new File(in_basePath).toURI().relativize(new File(in_filePath).toURI()).getPath();\r\n\t    return standardiseDirectoryPath(relativePath);\r\n\t}\r\n\t/**\r\n\t * @author Ian Copland\r\n\t * \r\n\t * @param in_filePath - The file path.\r\n\t * \r\n\t * @return The extension of a file path string.\r\n\t */\r\n\tpublic static String getExtension(String in_filePath)\r\n\t{\r\n\t\tint dwIndex = in_filePath.lastIndexOf(\".\");\r\n\t\tif (dwIndex != -1)\r\n\t\t\treturn in_filePath.substring(dwIndex + 1);\r\n\t\treturn \"\";\r\n\t}\r\n\t/**\r\n\t * @author Ian Copland\r\n\t * \r\n\t * @param in_filePath - The file path.\r\n\t * \r\n\t * @return The file path without the extension.\r\n\t */\r\n\tpublic static String removeExtension(String in_filePath)\r\n\t{\r\n\t\tint index = in_filePath.lastIndexOf(\".\");\r\n\t\t\r\n\t\tif (index != -1)\r\n\t\t{\r\n\t\t\treturn in_filePath.substring(0, index);\r\n\t\t}\r\n\t\t\r\n\t\treturn in_filePath;\r\n\t}\r\n\t/**\r\n\t * @author Ian Copland\r\n\t * \r\n\t * @param in_filePath - The file path.\r\n\t * \r\n\t * @return The directory path part of the given file name.\r\n\t * This will be standardised.\r\n\t */\r\n\tpublic static String getDirectory(String in_filePath)\r\n\t{\r\n\t\tString standardisedFilePath = StringUtils.standardiseFilePath(in_filePath);\r\n\t\tint index = standardisedFilePath.lastIndexOf(\"/\");\r\n\t\t\r\n\t\tif (index != -1)\r\n\t\t{\r\n\t\t\treturn standardisedFilePath.substring(0, index + 1);\r\n\t\t}\r\n\t\t\r\n\t\treturn \"\";\r\n\t}\r\n\t/**\r\n\t * @author Ian Copland\r\n\t * \r\n\t * @param in_filePath - The file path.\r\n\t * \r\n\t * @return The file name part of the file path.\r\n\t */\r\n\tpublic static String getFileName(String in_filePath)\r\n\t{\r\n\t\tString standardisedFilePath = StringUtils.standardiseFilePath(in_filePath);\r\n\t\tint index = standardisedFilePath.lastIndexOf(\"/\");\r\n\t\t\r\n\t\tif (index != -1)\r\n\t\t{\r\n\t\t\tstandardisedFilePath = standardisedFilePath.substring(index + 1);\r\n\t\t}\r\n\t\t\r\n\t\treturn standardisedFilePath;\r\n\t}\r\n\t/**\r\n\t * Removes all spaces, line returns and tabs from the given string.\r\n\t * \r\n\t * @author Ian Copland\r\n\t * \r\n\t * @param in_string - The input string with whitespace.\r\n\t * \r\n\t * @return The input string minus whitespace.\r\n\t */\r\n\tpublic static String removeWhitespace(String in_string)\r\n\t{\r\n\t\tString strOutput = new String(in_string);\r\n\t\tstrOutput = strOutput.replace(\" \", \"\");\r\n\t\tstrOutput = strOutput.replace(\"\\n\", \"\");\r\n\t\tstrOutput = strOutput.replace(\"\\r\", \"\");\r\n\t\tstrOutput = strOutput.replace(\"\\t\", \"\");\r\n\t\treturn strOutput;\r\n\t}\r\n\t/**\r\n\t * @author Ian Copland\r\n\t * \r\n\t * @param in_string - The string to check.\r\n\t * \r\n\t * @return Whether or not the string contains any spaces, line returns and tabs.\r\n\t */\r\n\tpublic static boolean containsWhitespace(String in_string)\r\n\t{\r\n\t\treturn in_string.contains(\" \") == true || in_string.contains(\"\\n\") == true || in_string.contains(\"\\r\") == true || in_string.contains(\"\\t\") == true;\r\n\t}\r\n\t/**\r\n\t * @author Ian Copland\r\n\t * \r\n\t * @param in_exception - The exception.\r\n\t * \r\n\t * @return The contents of the exception in string form. This includes the\r\n\t * stack trace.\r\n\t */\r\n\tpublic static String convertExceptionToString(Exception in_exception)\r\n\t{\r\n\t\tString strOutput = in_exception.getLocalizedMessage();\r\n\t\tfor (StackTraceElement element: in_exception.getStackTrace())\r\n\t\t{\r\n\t\t\tstrOutput += \"\\n\" + element.toString();\r\n\t\t}\r\n\t\t\r\n\t\treturn strOutput;\r\n\t}\r\n}\r\n"
  },
  {
    "path": "Projects/Tools/CoreUtils/src/com/chilliworks/chillisource/coreutils/StringWriterUtils.java",
    "content": "/**\n * StringWriterUtils.java\n * ChilliSource\n * Created by Ian Copland on 27/10/2014\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2014 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.coreutils;\n\nimport java.io.IOException;\nimport java.io.OutputStream;\n\n/**\n * A collection of convenience methods for writing strings to an output stream.\n * \n * @author Ian Copland\n */\npublic final class StringWriterUtils\n{\n\t/**\n\t * Writes a UTF8 string to the given output stream. This will not be\n\t * null terminated.\n\t * \n\t * @param in_stream - The stream to write the string to.\n\t * @param String - The string value.\n\t * \n\t * @throws IOException - Any IO Exception thrown by the given stream.\n\t */\n\tpublic static void writeUTF8String(OutputStream in_stream, String in_value) throws IOException\n\t{\n\t\tin_stream.write(StringUtils.stringToUTF8Bytes(in_value));\n\t}\n\t/**\n\t * Writes a null terminated UTF8 string to the given output stream.\n\t * \n\t * @param in_stream - The stream to write the string to.\n\t * @param String - The string value.\n\t * \n\t * @throws IOException - Any IO Exception thrown by the given stream.\n\t */\n\tpublic static void writeUTF8StringNullTerminated(OutputStream in_stream, String in_value) throws IOException\n\t{\n\t\twriteUTF8String(in_stream, in_value);\n\t\t\n\t\tbyte[] nullTerminator = new byte[1];\n\t\tnullTerminator[0] = 0;\n\t\tin_stream.write(nullTerminator);\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/CoreUtils/src/com/chilliworks/chillisource/coreutils/Tuple3.java",
    "content": "/**\n * Tuple3.java\n * ChilliSource\n * Created by Ian Copland on 23/10/2014.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2014 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.coreutils;\n\n/**\n * A simple 3-tuple class similar to std::tuple<x, y, z> in C++. Typical use\n * case for this is private methods that return multiple values.\n * \n * @author Ian Copland\n *\n * @param <TFirst> The type of the first value.\n * @param <TSecond> The type of the second value.\n * @param <TThird> The type of the third value.\n */\npublic final class Tuple3<TFirst, TSecond, TThird>\n{\n\tprivate final TFirst m_first;\n\tprivate final TSecond m_second;\n\tprivate final TThird m_third;\n\t\n\t/**\n\t * Constructor. Creates the tuple from the given values.\n\t * \n\t * @author Ian Copland\n\t *\n\t * @param in_first - The first value.\n\t * @param in_second - The second value.\n\t * @param in_third - The third value.\n\t */\n\tpublic Tuple3(TFirst in_first, TSecond in_second, TThird in_third)\n\t{\n\t\tm_first = in_first;\n\t\tm_second = in_second;\n\t\tm_third = in_third;\n\t}\n\t/**\n\t * @author Ian Copland\n\t *\n\t * @return The first value.\n\t */\n\tpublic TFirst getFirst()\n\t{\n\t\treturn m_first;\n\t}\n\t/**\n\t * @author Ian Copland\n\t *\n\t * @return The second value.\n\t */\n\tpublic TSecond getSecond()\n\t{\n\t\treturn m_second;\n\t}\n\t/**\n\t * @author Ian Copland\n\t *\n\t * @return The third value.\n\t */\n\tpublic TThird getThird()\n\t{\n\t\treturn m_third;\n\t}\n\t/**\n\t * @author Ian Copland\n\t *\n\t * @return The tuple as a string.\n\t */\n\t@Override public String toString() \n\t{\n        return m_first + \", \" + m_second + \", \" + m_third;\n    }\n\t/**\n\t * Compares equality with the given object.\n\t * \n\t * @author Ian Copland\n\t *\n\t * @return Whether or not the two objects are equal.\n\t */\n    @Override public boolean equals(Object in_object) \n    {\n        if (in_object == this) \n        {\n            return true;\n        }\n    \t\n        if (in_object == null) \n        {\n            return false;\n        }\n        \n        if ((in_object instanceof Tuple3<?, ?, ?>) == false)\n        {\n            return false;\n        }\n        \n        Tuple3<?, ?, ?> tuple = (Tuple3<?, ?, ?>)in_object;\n        boolean firstEquals = ((m_first == null && tuple.m_first == null) || (m_first != null && m_first.equals(tuple.m_first) == true));\n        boolean secondEquals = ((m_second == null && tuple.m_second == null) || (m_second != null && m_second.equals(tuple.m_second) == true));\n        boolean thirdEquals = ((m_third == null && tuple.m_third == null) || (m_third != null && m_third.equals(tuple.m_third) == true));\n        return (firstEquals == true && secondEquals == true && thirdEquals == true);\n    }\n\t/**\n\t * @author Ian Copland\n\t *\n\t * @return The hash code for this object.\n\t */\n\t@Override public int hashCode()\n\t{\n\t\tint hash = HashCodeUtils.INITIAL_VALUE;\n\t\thash = HashCodeUtils.add(hash, m_first);\n\t\thash = HashCodeUtils.add(hash, m_second);\n\t\thash = HashCodeUtils.add(hash, m_third);\n\t\treturn hash;\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/CoreUtils/src/com/chilliworks/chillisource/coreutils/Tuple4.java",
    "content": "/**\n * Tuple4.java\n * ChilliSource\n * Created by Ian Copland on 23/10/2014.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2014 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.coreutils;\n\n/**\n * A simple 4-tuple class similar to std::tuple<x, y, z, w> in C++. Typical use\n * case for this is private methods that return multiple values.\n * \n * @author Ian Copland\n *\n * @param <TFirst> The type of the first value.\n * @param <TSecond> The type of the second value.\n * @param <TThird> The type of the third value.\n * @param <TFourth> The type of the fourth value.\n */\npublic final class Tuple4<TFirst, TSecond, TThird, TFourth>\n{\n\tprivate final TFirst m_first;\n\tprivate final TSecond m_second;\n\tprivate final TThird m_third;\n\tprivate final TFourth m_fourth;\n\t\n\t/**\n\t * Constructor. Creates the tuple from the given values.\n\t * \n\t * @author Ian Copland\n\t *\n\t * @param in_first - The first value.\n\t * @param in_second - The second value.\n\t * @param in_third - The third value.\n\t * @param in_fouth - The fourth value.\n\t */\n\tpublic Tuple4(TFirst in_first, TSecond in_second, TThird in_third, TFourth in_fourth)\n\t{\n\t\tm_first = in_first;\n\t\tm_second = in_second;\n\t\tm_third = in_third;\n\t\tm_fourth = in_fourth;\n\t}\n\t/**\n\t * @author Ian Copland\n\t *\n\t * @return The first value.\n\t */\n\tpublic TFirst getFirst()\n\t{\n\t\treturn m_first;\n\t}\n\t/**\n\t * @author Ian Copland\n\t *\n\t * @return The second value.\n\t */\n\tpublic TSecond getSecond()\n\t{\n\t\treturn m_second;\n\t}\n\t/**\n\t * @author Ian Copland\n\t *\n\t * @return The third value.\n\t */\n\tpublic TThird getThird()\n\t{\n\t\treturn m_third;\n\t}\n\t/**\n\t * @author Ian Copland\n\t *\n\t * @return The fourth value.\n\t */\n\tpublic TFourth getFourth()\n\t{\n\t\treturn m_fourth;\n\t}\n\t/**\n\t * @author Ian Copland\n\t *\n\t * @return The tuple as a string.\n\t */\n\t@Override public String toString() \n\t{\n        return m_first + \", \" + m_second + \", \" + m_third + \", \" + m_fourth;\n    }\n\t/**\n\t * Compares equality with the given object.\n\t * \n\t * @author Ian Copland\n\t *\n\t * @return Whether or not the two objects are equal.\n\t */\n    @Override public boolean equals(Object in_object) \n    {\n        if (in_object == this) \n        {\n            return true;\n        }\n    \t\n        if (in_object == null) \n        {\n            return false;\n        }\n        \n        if ((in_object instanceof Tuple4<?, ?, ?, ?>) == false)\n        {\n            return false;\n        }\n        \n        Tuple4<?, ?, ?, ?> tuple = (Tuple4<?, ?, ?, ?>)in_object;\n        boolean firstEquals = ((m_first == null && tuple.m_first == null) || (m_first != null && m_first.equals(tuple.m_first) == true));\n        boolean secondEquals = ((m_second == null && tuple.m_second == null) || (m_second != null && m_second.equals(tuple.m_second) == true));\n        boolean thirdEquals = ((m_third == null && tuple.m_third == null) || (m_third != null && m_third.equals(tuple.m_third) == true));\n        boolean fourthEquals = ((m_fourth == null && tuple.m_fourth == null) || (m_fourth != null && m_fourth.equals(tuple.m_fourth) == true));\n        return (firstEquals == true && secondEquals == true && thirdEquals == true && fourthEquals == true);\n    }\n\t/**\n\t * @author Ian Copland\n\t *\n\t * @return The hash code for this object.\n\t */\n\t@Override public int hashCode()\n\t{\n\t\tint hash = HashCodeUtils.INITIAL_VALUE;\n\t\thash = HashCodeUtils.add(hash, m_first);\n\t\thash = HashCodeUtils.add(hash, m_second);\n\t\thash = HashCodeUtils.add(hash, m_third);\n\t\thash = HashCodeUtils.add(hash, m_fourth);\n\t\treturn hash;\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/CoreUtils/src/com/chilliworks/chillisource/coreutils/Tuple5.java",
    "content": "/**\n * Tuple5.java\n * ChilliSource\n * Created by Ian Copland on 23/10/2014.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2014 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.coreutils;\n\n/**\n * A simple 5-tuple class similar to std::tuple<x, y, z, w, v> in C++. Typical use\n * case for this is private methods that return multiple values.\n * \n * @author Ian Copland\n *\n * @param <TFirst> The type of the first value.\n * @param <TSecond> The type of the second value.\n * @param <TThird> The type of the third value.\n * @param <TFourth> The type of the fourth value.\n * @param <TFifth> The type of the fifth value.\n */\npublic final class Tuple5<TFirst, TSecond, TThird, TFourth, TFifth>\n{\n\tprivate final TFirst m_first;\n\tprivate final TSecond m_second;\n\tprivate final TThird m_third;\n\tprivate final TFourth m_fourth;\n\tprivate final TFifth m_fifth;\n\t\n\t/**\n\t * Constructor. Creates the tuple from the given values.\n\t * \n\t * @author Ian Copland\n\t *\n\t * @param in_first - The first value.\n\t * @param in_second - The second value.\n\t * @param in_third - The third value.\n\t * @param in_fouth - The fourth value.\n\t * @param in_fifth - The fifth value.\n\t */\n\tpublic Tuple5(TFirst in_first, TSecond in_second, TThird in_third, TFourth in_fourth, TFifth in_fifth)\n\t{\n\t\tm_first = in_first;\n\t\tm_second = in_second;\n\t\tm_third = in_third;\n\t\tm_fourth = in_fourth;\n\t\tm_fifth = in_fifth;\n\t}\n\t/**\n\t * @author Ian Copland\n\t *\n\t * @return The first value.\n\t */\n\tpublic TFirst getFirst()\n\t{\n\t\treturn m_first;\n\t}\n\t/**\n\t * @author Ian Copland\n\t *\n\t * @return The second value.\n\t */\n\tpublic TSecond getSecond()\n\t{\n\t\treturn m_second;\n\t}\n\t/**\n\t * @author Ian Copland\n\t *\n\t * @return The third value.\n\t */\n\tpublic TThird getThird()\n\t{\n\t\treturn m_third;\n\t}\n\t/**\n\t * @author Ian Copland\n\t *\n\t * @return The fourth value.\n\t */\n\tpublic TFourth getFourth()\n\t{\n\t\treturn m_fourth;\n\t}\n\t/**\n\t * @author Ian Copland\n\t *\n\t * @return The fourth value.\n\t */\n\tpublic TFifth getFifth()\n\t{\n\t\treturn m_fifth;\n\t}\n\t/**\n\t * @author Ian Copland\n\t *\n\t * @return The tuple as a string.\n\t */\n\t@Override public String toString() \n\t{\n        return m_first + \", \" + m_second + \", \" + m_third + \", \" + m_fourth + \", \" + m_fifth;\n    }\n\t/**\n\t * Compares equality with the given object.\n\t * \n\t * @author Ian Copland\n\t *\n\t * @return Whether or not the two objects are equal.\n\t */\n    @Override public boolean equals(Object in_object) \n    {\n        if (in_object == this) \n        {\n            return true;\n        }\n    \t\n        if (in_object == null) \n        {\n            return false;\n        }\n        \n        if ((in_object instanceof Tuple5<?, ?, ?, ?, ?>) == false)\n        {\n            return false;\n        }\n        \n        Tuple5<?, ?, ?, ?, ?> tuple = (Tuple5<?, ?, ?, ?, ?>)in_object;\n        boolean firstEquals = ((m_first == null && tuple.m_first == null) || (m_first != null && m_first.equals(tuple.m_first) == true));\n        boolean secondEquals = ((m_second == null && tuple.m_second == null) || (m_second != null && m_second.equals(tuple.m_second) == true));\n        boolean thirdEquals = ((m_third == null && tuple.m_third == null) || (m_third != null && m_third.equals(tuple.m_third) == true));\n        boolean fourthEquals = ((m_fourth == null && tuple.m_fourth == null) || (m_fourth != null && m_fourth.equals(tuple.m_fourth) == true));\n        boolean fifthEquals = ((m_fifth == null && tuple.m_fifth == null) || (m_fifth != null && m_fifth.equals(tuple.m_fifth) == true));\n        return (firstEquals == true && secondEquals == true && thirdEquals == true && fourthEquals == true && fifthEquals == true);\n    }\n\t/**\n\t * @author Ian Copland\n\t *\n\t * @return The hash code for this object.\n\t */\n\t@Override public int hashCode()\n\t{\n\t\tint hash = HashCodeUtils.INITIAL_VALUE;\n\t\thash = HashCodeUtils.add(hash, m_first);\n\t\thash = HashCodeUtils.add(hash, m_second);\n\t\thash = HashCodeUtils.add(hash, m_third);\n\t\thash = HashCodeUtils.add(hash, m_fourth);\n\t\thash = HashCodeUtils.add(hash, m_fifth);\n\t\treturn hash;\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/CoreUtils/src/com/chilliworks/chillisource/coreutils/Vector2.java",
    "content": "/**\n * Vector2.java\n * ChilliSource\n * Created by Ian Copland on 30/01/2013\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.coreutils;\n\n/**\n * A vector math class. This is immutable after creation meaning it can\n * safely be passed into methods without side-effects.\n * \n * @author Ian Copland\n */\npublic final class Vector2\n{\n\tpublic static final Vector2 ZERO = new Vector2(0.0, 0.0);\n\tpublic static final Vector2 ONE = new Vector2(1.0, 1.0);\n\t\n\tprivate final double m_x;\n\tprivate final double m_y;\n\t\n\t/**\n\t * Returns the addition of the two provided Vector2s.\n\t * \n\t * @author Ian Copland\n\t *\n\t * @param in_a - the first Vector2.\n\t * @param in_b - the second Vector2.\n\t * \n\t * @return The result of the addition.\n\t */\n\tpublic static Vector2 add(Vector2 in_a, Vector2 in_b)\n\t{\n\t\treturn new Vector2(in_a.getX() + in_b.getX(), in_a.getY() + in_b.getY());\n\t}\n\t/**\n\t * Returns the subtraction of the two provided Vector2s.\n\t * \n\t * @author Ian Copland\n\t *\n\t * @param in_a - the first Vector2.\n\t * @param in_b - the second Vector2.\n\t * \n\t * @return The result of the subtraction.\n\t */\n\tpublic static Vector2 subtract(Vector2 in_a, Vector2 in_b)\n\t{\n\t\treturn new Vector2(in_a.getX() - in_b.getX(), in_a.getY() - in_b.getY());\n\t}\n\t/**\n\t * Returns the result of multiplying all components of the Vector2 by\n\t * the scalar.\n\t * \n\t * @author Ian Copland\n\t *\n\t * @param in_a - the Vector2.\n\t * @param in_b - the scalar.\n\t * \n\t * @return The result of the multiplication.\n\t */\n\tpublic static Vector2 multiply(Vector2 in_a, double in_b)\n\t{\n\t\treturn new Vector2(in_a.getX() * in_b, in_a.getY() * in_b);\n\t}\n\t/**\n\t * Returns the result of multiplying two Vector2s together.\n\t * \n\t * @author Ian Copland\n\t *\n\t * @param in_a - the first Vector2.\n\t * @param in_b - the second Vector2.\n\t * \n\t * @return The result of the multiplication.\n\t */\n\tpublic static Vector2 multiply(Vector2 in_a, Vector2 in_b)\n\t{\n\t\treturn new Vector2(in_a.getX() * in_b.getX(), in_a.getY() * in_b.getY());\n\t}\n\t/**\n\t * Returns the result of dividing all components of the Vector2 by\n\t * the scalar.\n\t * \n\t * @author Ian Copland\n\t *\n\t * @param in_a - the Vector2.\n\t * @param in_b - the scalar.\n\t * \n\t * @return The result of the multiplication.\n\t */\n\tpublic static Vector2 divide(Vector2 in_a, double in_b)\n\t{\n\t\tdouble invB = 1.0 / in_b;\n\t\treturn new Vector2(in_a.getX() * invB, in_a.getY() * in_b);\n\t}\n\t/**\n\t * Returns the result of dividing two Vector2s.\n\t * \n\t * @author Ian Copland\n\t *\n\t * @param in_a - the first Vector2.\n\t * @param in_b - the second Vector2.\n\t * \n\t * @return The result of the division.\n\t */\n\tpublic static Vector2 divide(Vector2 in_a, Vector2 in_b)\n\t{\n\t\treturn new Vector2(in_a.getX() / in_b.getX(), in_a.getY() / in_b.getY());\n\t}\n\t/**\n\t * Takes the min value for each component from the two Vector2s.\n\t * \n\t * @author Ian Copland\n\t *\n\t * @param in_a - the first Vector2.\n\t * @param in_b - the second Vector2.\n\t * \n\t * @return The min value.\n\t */\n\tpublic static Vector2 min(Vector2 in_a, Vector2 in_b)\n\t{\n\t\treturn new Vector2(Math.min(in_a.getX(), in_b.getX()), Math.min(in_a.getY(), in_b.getY()));\n\t}\n\t/**\n\t * Takes the max value for each component from the two Vector2s.\n\t * \n\t * @author Ian Copland\n\t *\n\t * @param in_a - the first Vector2.\n\t * @param in_b - the second Vector2.\n\t * \n\t * @return The max value.\n\t */\n\tpublic static Vector2 max(Vector2 in_a, Vector2 in_b)\n\t{\n\t\treturn new Vector2(Math.max(in_a.getX(), in_b.getX()), Math.max(in_a.getY(), in_b.getY()));\n\t}\n\t/**\n\t * returns a normalised copy of the given vector.\n\t * \n\t * @author Ian Copland\n\t *\n\t * @param in_vec - the vector to normalise.\n\t * \n\t * @return The normalised vector.\n\t */\n\tpublic static Vector2 normalise(Vector2 in_vec)\n\t{\n\t\tdouble invLength = 1.0 / in_vec.getLength();\n\t\treturn new Vector2(in_vec.m_x * invLength, in_vec.m_y * invLength);\n\t}\n\t/**\n\t * Parses an Vector2 from a string. Vector2 values should be provided \n\t * as real numbers and each component should be separated by a comma. For \n\t * example:  2.0, 600.0.\n\t * \n\t * @author Ian Copland\n\t *\n\t * @param in_vector2String - The Vector2 string.\n\t */\n\tpublic static Vector2 parseVec3(String in_vector2String)\n\t{\n\t\tString[] components = in_vector2String.split(\",\");\n\t\tif (components.length == 2)\n\t\t{\n\t\t\tdouble x = Double.parseDouble(components[0].trim());\n\t\t\tdouble y = Double.parseDouble(components[1].trim());\n\t\t\t\n\t\t\treturn new Vector2(x, y);\n\t\t}\n\t\telse\n\t\t{\n\t\t\treturn Vector2.ZERO;\n\t\t}\n\t}\n\t/**\n\t * Constructor.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param in_x - The x value.\n\t * @param in_y - The y value.\n\t */\n\tpublic Vector2(double in_x, double in_y)\n\t{\n\t\tm_x = in_x;\n\t\tm_y = in_y;\n\t}\n\t/**\n\t * @author Ian Copland\n\t * \n\t * @return The x component.\n\t */\n\tpublic double getX()\n\t{\n\t\treturn m_x;\n\t}\n\t/**\n\t * @author Ian Copland\n\t * \n\t * @return The y component.\n\t */\n\tpublic double getY()\n\t{\n\t\treturn m_y;\n\t}\n\t/**\n\t * @author Ian Copland\n\t * \n\t * @return The length of the vector.\n\t */\n\tpublic double getLength()\n\t{\n\t\treturn Math.sqrt(m_x * m_x + m_y * m_y);\n\t}\n\t/**\n\t * @author Ian Copland\n\t *\n\t * @return This object in string form.\n\t */\n\t@Override public String toString()\n\t{\n\t\treturn m_x + \", \" + m_y;\n\t}\n\t/**\n\t * Returns whether or not this object is equal in value to the given\n\t * object.\n\t * \n\t * @author Ian Copland\n\t *\n\t * @param in_object - The other object.\n\t *\n\t * @return Whether or not the given object is equal to this.\n\t */\n\t@Override public boolean equals(Object in_object)\n\t{\n\t\tif (in_object == this)\n\t    {\n\t    \treturn true;\n\t    }\n\t\t\n\t\tif (in_object == null)\n\t    {\n\t    \treturn false;\n\t    }\n\t    \t\n\t    if ((in_object instanceof Vector2) == false)\n\t    {\n\t    \treturn false;\n\t    }\n\t    \n\t    Vector2 vector2 = (Vector2)in_object;\n\t    return (Double.compare(m_x, vector2.m_x) == 0 && Double.compare(m_y, vector2.m_y) == 0);\n\t}\t\n\t/**\n\t * @author Ian Copland\n\t *\n\t * @return The hash code for this object.\n\t */\n\t@Override public int hashCode()\n\t{\n\t\tint hash = HashCodeUtils.INITIAL_VALUE;\n\t\thash = HashCodeUtils.add(hash, m_x);\n\t\thash = HashCodeUtils.add(hash, m_y);\n\t\treturn hash;\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/CoreUtils/src/com/chilliworks/chillisource/coreutils/Vector3.java",
    "content": "/**\n * Vector3.java\n * ChilliSource\n * Created by Ian Copland on 30/01/2013\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.coreutils;\n\n/**\n * A vector math class. This is immutable after creation meaning it can\n * safely be passed into methods without side-effects.\n * \n * @author Ian Copland\n */\npublic final class Vector3\n{\n\tpublic static final Vector3 ZERO = new Vector3(0.0, 0.0, 0.0);\n\tpublic static final Vector3 ONE = new Vector3(1.0, 1.0, 1.0);\n\t\n\tprivate final double m_x;\n\tprivate final double m_y;\n\tprivate final double m_z;\n\t\n\t/**\n\t * Returns the addition of the two provided Vector3s.\n\t * \n\t * @author Ian Copland\n\t *\n\t * @param in_a - the first Vector3.\n\t * @param in_b - the second Vector3.\n\t * \n\t * @return The result of the addition.\n\t */\n\tpublic static Vector3 add(Vector3 in_a, Vector3 in_b)\n\t{\n\t\treturn new Vector3(in_a.getX() + in_b.getX(), in_a.getY() + in_b.getY(), in_a.getZ() + in_b.getZ());\n\t}\n\t/**\n\t * Returns the subtraction of the two provided Vector3s.\n\t * \n\t * @author Ian Copland\n\t *\n\t * @param in_a - the first Vector3.\n\t * @param in_b - the second Vector3.\n\t * \n\t * @return The result of the subtraction.\n\t */\n\tpublic static Vector3 subtract(Vector3 in_a, Vector3 in_b)\n\t{\n\t\treturn new Vector3(in_a.getX() - in_b.getX(), in_a.getY() - in_b.getY(), in_a.getZ() - in_b.getZ());\n\t}\n\t/**\n\t * Returns the result of multiplying all components of the Vector3 by\n\t * the scalar.\n\t * \n\t * @author Ian Copland\n\t *\n\t * @param in_a - the Vector3.\n\t * @param in_b - the scalar.\n\t * \n\t * @return The result of the multiplication.\n\t */\n\tpublic static Vector3 multiply(Vector3 in_a, double in_b)\n\t{\n\t\treturn new Vector3(in_a.getX() * in_b, in_a.getY() * in_b, in_a.getZ() * in_b);\n\t}\t\n\t/**\n\t * Returns the result of multiplying the Vector3 by a 4x4 matrix.\n\t * \n\t * @author Ian Copland\n\t *\n\t * @param in_a - the Vector3.\n\t * @param in_b - the Matrix4.\n\t * \n\t * @return The result of the multiplication.\n\t */\n\tpublic static Vector3 multiply(Vector3 inVector, Matrix4 inMatrix)\n\t{\n\t\tdouble x = inVector.getX() * inMatrix.get(0) + inVector.getY() * inMatrix.get(4) + inVector.getZ() * inMatrix.get(8) + inMatrix.get(12);\n\t\tdouble y = inVector.getX() * inMatrix.get(1) + inVector.getY() * inMatrix.get(5) + inVector.getZ() * inMatrix.get(9) + inMatrix.get(13);\n\t\tdouble z = inVector.getX() * inMatrix.get(2) + inVector.getY() * inMatrix.get(6) + inVector.getZ() * inMatrix.get(10) + inMatrix.get(14);\n\t\treturn new Vector3(x, y, z);\n\t}\n\t/**\n\t * Returns the result of multiplying two Vector3s together.\n\t * \n\t * @author Ian Copland\n\t *\n\t * @param in_a - the first Vector3.\n\t * @param in_b - the second Vector3.\n\t * \n\t * @return The result of the multiplication.\n\t */\n\tpublic static Vector3 multiply(Vector3 in_a, Vector3 in_b)\n\t{\n\t\treturn new Vector3(in_a.getX() * in_b.getX(), in_a.getY() * in_b.getY(), in_a.getZ() * in_b.getZ());\n\t}\n\t/**\n\t * Returns the result of dividing all components of the Vector3 by\n\t * the scalar.\n\t * \n\t * @author Ian Copland\n\t *\n\t * @param in_a - the Vector3.\n\t * @param in_b - the scalar.\n\t * \n\t * @return The result of the multiplication.\n\t */\n\tpublic static Vector3 divide(Vector3 in_a, double in_b)\n\t{\n\t\tdouble invB = 1.0 / in_b;\n\t\treturn new Vector3(in_a.getX() * invB, in_a.getY() * invB, in_a.getZ() * invB);\n\t}\n\t/**\n\t * Returns the result of dividing two Vector3s.\n\t * \n\t * @author Ian Copland\n\t *\n\t * @param in_a - the first Vector3.\n\t * @param in_b - the second Vector3.\n\t * \n\t * @return The result of the division.\n\t */\n\tpublic static Vector3 divide(Vector3 in_a, Vector3 in_b)\n\t{\n\t\treturn new Vector3(in_a.getX() / in_b.getX(), in_a.getY() / in_b.getY(), in_a.getZ() / in_b.getZ());\n\t}\n\t/**\n\t * Takes the min value for each component from the two Vector3s.\n\t * \n\t * @author Ian Copland\n\t *\n\t * @param in_a - the first Vector3.\n\t * @param in_b - the second Vector3.\n\t * \n\t * @return The min value.\n\t */\n\tpublic static Vector3 min(Vector3 in_a, Vector3 in_b)\n\t{\n\t\treturn new Vector3(Math.min(in_a.getX(), in_b.getX()), Math.min(in_a.getY(), in_b.getY()), Math.min(in_a.getZ(), in_b.getZ()));\n\t}\n\t/**\n\t * Takes the max value for each component from the two Vector3s.\n\t * \n\t * @author Ian Copland\n\t *\n\t * @param in_a - the first Vector3.\n\t * @param in_b - the second Vector3.\n\t * \n\t * @return The max value.\n\t */\n\tpublic static Vector3 max(Vector3 in_a, Vector3 in_b)\n\t{\n\t\treturn new Vector3(Math.max(in_a.getX(), in_b.getX()), Math.max(in_a.getY(), in_b.getY()), Math.max(in_a.getZ(), in_b.getZ()));\n\t}\n\t/**\n\t * returns a normalised copy of the given vector.\n\t * \n\t * @author Ian Copland\n\t *\n\t * @param in_vec - the vector to normalise.\n\t * \n\t * @return The normalised vector.\n\t */\n\tpublic static Vector3 normalise(Vector3 in_vec)\n\t{\n\t\tdouble invLength = 1.0 / in_vec.getLength();\n\t\treturn new Vector3(in_vec.m_x * invLength, in_vec.m_y * invLength, in_vec.m_z * invLength);\n\t}\n\t/**\n\t * Parses an Vector3 from a string. Vector3 values should be provided \n\t * as real numbers and each component should be separated by a comma. For \n\t * example:  2.0, 600.0, -7.0.\n\t * \n\t * @author Ian Copland\n\t *\n\t * @param in_vector3String - The Vector3 string.\n\t */\n\tpublic static Vector3 parseVec3(String in_vector3String)\n\t{\n\t\tString[] components = in_vector3String.split(\",\");\n\t\tif (components.length == 3)\n\t\t{\n\t\t\tdouble x = Double.parseDouble(components[0].trim());\n\t\t\tdouble y = Double.parseDouble(components[1].trim());\n\t\t\tdouble z = Double.parseDouble(components[2].trim());\n\t\t\t\n\t\t\treturn new Vector3(x, y, z);\n\t\t}\n\t\telse\n\t\t{\n\t\t\treturn Vector3.ZERO;\n\t\t}\n\t}\n\t/**\n\t * Constructor.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param in_x - The x value.\n\t * @param in_y - The y value.\n\t * @param in_z - The z value.\n\t */\n\tpublic Vector3(double in_x, double in_y, double in_z)\n\t{\n\t\tm_x = in_x;\n\t\tm_y = in_y;\n\t\tm_z = in_z;\n\t}\n\t/**\n\t * @author Ian Copland\n\t * \n\t * @return The x component.\n\t */\n\tpublic double getX()\n\t{\n\t\treturn m_x;\n\t}\n\t/**\n\t * @author Ian Copland\n\t * \n\t * @return The y component.\n\t */\n\tpublic double getY()\n\t{\n\t\treturn m_y;\n\t}\n\t/**\n\t * @author Ian Copland\n\t * \n\t * @return The z component.\n\t */\n\tpublic double getZ()\n\t{\n\t\treturn m_z;\n\t}\n\t/**\n\t * @author Ian Copland\n\t * \n\t * @return The length of the vector.\n\t */\n\tpublic double getLength()\n\t{\n\t\treturn Math.sqrt(m_x * m_x + m_y * m_y + m_z * m_z);\n\t}\n\t/**\n\t * @author Ian Copland\n\t *\n\t * @return This object in string form.\n\t */\n\t@Override public String toString()\n\t{\n\t\treturn m_x + \", \" + m_y + \", \" + m_z;\n\t}\n\t/**\n\t * Returns whether or not this object is equal in value to the given\n\t * object.\n\t * \n\t * @author Ian Copland\n\t *\n\t * @param in_object - The other object.\n\t *\n\t * @return Whether or not the given object is equal to this.\n\t */\n\t@Override public boolean equals(Object in_object)\n\t{\n\t\tif (in_object == this)\n\t    {\n\t    \treturn true;\n\t    }\n\t\t\n\t\tif (in_object == null)\n\t    {\n\t    \treturn false;\n\t    }\n\t    \t\n\t    if ((in_object instanceof Vector3) == false)\n\t    {\n\t    \treturn false;\n\t    }\n\t    \n\t    Vector3 vector3 = (Vector3)in_object;\n\t    return (Double.compare(m_x, vector3.m_x) == 0 && Double.compare(m_y, vector3.m_y) == 0 && Double.compare(m_z, vector3.m_z) == 0);\n\t}\t\n\t/**\n\t * @author Ian Copland\n\t *\n\t * @return The hash code for this object.\n\t */\n\t@Override public int hashCode()\n\t{\n\t\tint hash = HashCodeUtils.INITIAL_VALUE;\n\t\thash = HashCodeUtils.add(hash, m_x);\n\t\thash = HashCodeUtils.add(hash, m_y);\n\t\thash = HashCodeUtils.add(hash, m_z);\n\t\treturn hash;\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/CoreUtils/src/com/chilliworks/chillisource/coreutils/Vector4.java",
    "content": "/**\n * Vector4.java\n * ChilliSource\n * Created by Ian Copland on 30/01/2013\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.coreutils;\n\n/**\n * A vector math class. This is immutable after creation meaning it can\n * safely be passed into methods without side-effects.\n * \n * @author Ian Copland\n */\npublic final class Vector4\n{\n\tpublic static final Vector4 ZERO = new Vector4(0.0, 0.0, 0.0, 0.0);\n\tpublic static final Vector4 ONE = new Vector4(1.0, 1.0, 1.0, 1.0);\n\t\n\tprivate final double m_x;\n\tprivate final double m_y;\n\tprivate final double m_z;\n\tprivate final double m_w;\n\t\n\t/**\n\t * Returns the addition of the two provided Vector4s.\n\t * \n\t * @author Ian Copland\n\t *\n\t * @param in_a - the first Vector4.\n\t * @param in_b - the second Vector4.\n\t * \n\t * @return The result of the addition.\n\t */\n\tpublic static Vector4 add(Vector4 in_a, Vector4 in_b)\n\t{\n\t\treturn new Vector4(in_a.getX() + in_b.getX(), in_a.getY() + in_b.getY(), in_a.getZ() + in_b.getZ(), in_a.getW() + in_b.getW());\n\t}\n\t/**\n\t * Returns the subtraction of the two provided Vector4s.\n\t * \n\t * @author Ian Copland\n\t *\n\t * @param in_a - the first Vector4.\n\t * @param in_b - the second Vector4.\n\t * \n\t * @return The result of the subtraction.\n\t */\n\tpublic static Vector4 subtract(Vector4 in_a, Vector4 in_b)\n\t{\n\t\treturn new Vector4(in_a.getX() - in_b.getX(), in_a.getY() - in_b.getY(), in_a.getZ() - in_b.getZ(), in_a.getW() - in_b.getW());\n\t}\n\t/**\n\t * Returns the result of multiplying all components of the Vector4 by\n\t * the scalar.\n\t * \n\t * @author Ian Copland\n\t *\n\t * @param in_a - the Vector4.\n\t * @param in_b - the scalar.\n\t * \n\t * @return The result of the multiplication.\n\t */\n\tpublic static Vector4 multiply(Vector4 in_a, double in_b)\n\t{\n\t\treturn new Vector4(in_a.getX() * in_b, in_a.getY() * in_b, in_a.getZ() * in_b, in_a.getW() * in_b);\n\t}\n\t/**\n\t * Returns the result of multiplying two Vector4s together.\n\t * \n\t * @author Ian Copland\n\t *\n\t * @param in_a - the first Vector4.\n\t * @param in_b - the second Vector4.\n\t * \n\t * @return The result of the multiplication.\n\t */\n\tpublic static Vector4 multiply(Vector4 in_a, Vector4 in_b)\n\t{\n\t\treturn new Vector4(in_a.getX() * in_b.getX(), in_a.getY() * in_b.getY(), in_a.getZ() * in_b.getZ(), in_a.getW() * in_b.getW());\n\t}\n\t/**\n\t * Returns the result of dividing all components of the Vector4 by\n\t * the scalar.\n\t * \n\t * @author Ian Copland\n\t *\n\t * @param in_a - the Vector4.\n\t * @param in_b - the scalar.\n\t * \n\t * @return The result of the multiplication.\n\t */\n\tpublic static Vector4 divide(Vector4 in_a, double in_b)\n\t{\n\t\tdouble invB = in_b;\n\t\treturn new Vector4(in_a.getX() * invB, in_a.getY() * invB, in_a.getZ() * invB, in_a.getW() * invB);\n\t}\n\t/**\n\t * Returns the result of dividing two Vector4s.\n\t * \n\t * @author Ian Copland\n\t *\n\t * @param in_a - the first Vector4.\n\t * @param in_b - the second Vector4.\n\t * \n\t * @return The result of the division.\n\t */\n\tpublic static Vector4 divide(Vector4 in_a, Vector4 in_b)\n\t{\n\t\treturn new Vector4(in_a.getX() / in_b.getX(), in_a.getY() / in_b.getY(), in_a.getZ() / in_b.getZ(), in_a.getW() / in_b.getW());\n\t}\n\t/**\n\t * Takes the min value for each component from the two Vector4s.\n\t * \n\t * @author Ian Copland\n\t *\n\t * @param in_a - the first Vector4.\n\t * @param in_b - the second Vector4.\n\t * \n\t * @return The min value.\n\t */\n\tpublic static Vector4 min(Vector4 in_a, Vector4 in_b)\n\t{\n\t\treturn new Vector4(Math.min(in_a.getX(), in_b.getX()), Math.min(in_a.getY(), in_b.getY()), Math.min(in_a.getZ(), in_b.getZ()), Math.min(in_a.getW(), in_b.getW()));\n\t}\n\t/**\n\t * Takes the max value for each component from the two Vector4s.\n\t * \n\t * @author Ian Copland\n\t *\n\t * @param in_a - the first Vector4.\n\t * @param in_b - the second Vector4.\n\t * \n\t * @return The max value.\n\t */\n\tpublic static Vector4 max(Vector4 in_a, Vector4 in_b)\n\t{\n\t\treturn new Vector4(Math.max(in_a.getX(), in_b.getX()), Math.max(in_a.getY(), in_b.getY()), Math.max(in_a.getZ(), in_b.getZ()), Math.max(in_a.getW(), in_b.getW()));\n\t}\n\t/**\n\t * returns a normalised copy of the given vector.\n\t * \n\t * @author Ian Copland\n\t *\n\t * @param in_vec - the vector to normalise.\n\t * \n\t * @return The normalised vector.\n\t */\n\tpublic static Vector4 normalise(Vector4 in_vec)\n\t{\n\t\tdouble invLength = 1.0 / in_vec.getLength();\n\t\treturn new Vector4(in_vec.m_x * invLength, in_vec.m_y * invLength, in_vec.m_z * invLength, in_vec.m_w * invLength);\n\t}\n\t/**\n\t * Parses an Vector4 from a string. Vector4 values should be provided \n\t * as real numbers and each component should be separated by a comma. For \n\t * example:  2.0, 600.0, -7.0, -23.0.\n\t * \n\t * @author Ian Copland\n\t *\n\t * @param in_vector4String - The Vector4 string.\n\t */\n\tpublic static Vector4 parseVec4(String in_vector4String)\n\t{\n\t\tString[] components = in_vector4String.split(\",\");\n\t\tif (components.length == 4)\n\t\t{\n\t\t\tdouble x = Double.parseDouble(components[0].trim());\n\t\t\tdouble y = Double.parseDouble(components[1].trim());\n\t\t\tdouble z = Double.parseDouble(components[2].trim());\n\t\t\tdouble w = Double.parseDouble(components[3].trim());\n\t\t\t\n\t\t\treturn new Vector4(x, y, z, w);\n\t\t}\n\t\telse\n\t\t{\n\t\t\treturn Vector4.ZERO;\n\t\t}\n\t}\n\t/**\n\t * Constructor.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param in_x - The x value.\n\t * @param in_y - The y value.\n\t * @param in_z - The z value.\n\t * @param in_w - The w value.\n\t */\n\tpublic Vector4(double in_x, double in_y, double in_z, double in_w)\n\t{\n\t\tm_x = in_x;\n\t\tm_y = in_y;\n\t\tm_z = in_z;\n\t\tm_w = in_w;\n\t}\n\t/**\n\t * @author Ian Copland\n\t * \n\t * @return The x component.\n\t */\n\tpublic double getX()\n\t{\n\t\treturn m_x;\n\t}\n\t/**\n\t * @author Ian Copland\n\t * \n\t * @return The y component.\n\t */\n\tpublic double getY()\n\t{\n\t\treturn m_y;\n\t}\n\t/**\n\t * @author Ian Copland\n\t * \n\t * @return The z component.\n\t */\n\tpublic double getZ()\n\t{\n\t\treturn m_z;\n\t}\n\t/**\n\t * @author Ian Copland\n\t * \n\t * @return The w component.\n\t */\n\tpublic double getW()\n\t{\n\t\treturn m_w;\n\t}\n\t/**\n\t * @author Ian Copland\n\t * \n\t * @return The length of the vector.\n\t */\n\tpublic double getLength()\n\t{\n\t\treturn Math.sqrt(m_x * m_x + m_y * m_y + m_z * m_z + m_w * m_w);\n\t}\n\t/**\n\t * @author Ian Copland\n\t *\n\t * @return This object in string form.\n\t */\n\t@Override public String toString()\n\t{\n\t\treturn m_x + \", \" + m_y + \", \" + m_z + \", \" + m_w;\n\t}\n\t/**\n\t * Returns whether or not this object is equal in value to the given\n\t * object.\n\t * \n\t * @author Ian Copland\n\t *\n\t * @param in_object - The other object.\n\t *\n\t * @return Whether or not the given object is equal to this.\n\t */\n\t@Override public boolean equals(Object in_object)\n\t{\n\t\tif (in_object == this)\n\t    {\n\t    \treturn true;\n\t    }\n\t\t\n\t\tif (in_object == null)\n\t    {\n\t    \treturn false;\n\t    }\n\t    \t\n\t    if ((in_object instanceof Vector4) == false)\n\t    {\n\t    \treturn false;\n\t    }\n\t    \n\t    Vector4 vector4 = (Vector4)in_object;\n\t    return (Double.compare(m_x, vector4.m_x) == 0 && Double.compare(m_y, vector4.m_y) == 0 && Double.compare(m_z, vector4.m_z) == 0 && Double.compare(m_w, vector4.m_w) == 0);\n\t}\n\t/**\n\t * @author Ian Copland\n\t *\n\t * @return The hash code for this object.\n\t */\n\t@Override public int hashCode()\n\t{\n\t\tint hash = HashCodeUtils.INITIAL_VALUE;\n\t\thash = HashCodeUtils.add(hash, m_x);\n\t\thash = HashCodeUtils.add(hash, m_y);\n\t\thash = HashCodeUtils.add(hash, m_z);\n\t\thash = HashCodeUtils.add(hash, m_w);\n\t\treturn hash;\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/CoreUtils/src/com/chilliworks/chillisource/coreutils/ZipUtils.java",
    "content": "/**\n * ZipUtils.java\n * ChilliSource\n * Created by Ian Copland on 16/10/2014\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2014 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.coreutils;\n\nimport java.io.BufferedInputStream;\nimport java.io.BufferedOutputStream;\nimport java.io.File;\nimport java.io.FileInputStream;\nimport java.io.FileOutputStream;\nimport java.io.IOException;\nimport java.util.List;\nimport java.util.zip.ZipEntry;\nimport java.util.zip.ZipInputStream;\nimport java.util.zip.ZipOutputStream;\n\n/**\n * A collection of methods for working with zip files.\n * \n * @author Ian Copland\n */\npublic final class ZipUtils\n{\n    private static final int BUFFER_SIZE = 8 * 1024;\n\t\n\t/**\n     * Zips the contents of of the given directory. The directory itself will\n     * not be included in the zip. The zip should not already exist. Optionally\n\t * extensions can be provided which should remain uncompressed inside the zip.\n     *\n     * @author Ian Copland\n     *\n     * @param in_directoryPath - The path to the directory whose contents will\n     * be zipped.\n     * @param in_zipFilePath - The path to the output zip file.\n     * @param in_uncompressedExtensions - A list of file extensions which should \n     * not be compressed. These must contain no whitespace and must have a leading\n     * full stop.\n     * \n     * @throws IOException - if the zip could not be created.\n     */\n\tpublic static void zip(String in_directoryPath, String in_zipFilePath, List<String> in_uncompressedExtensions) throws IOException\n\t{\n\t\tif (new File(in_zipFilePath).exists() == true)\n\t\t{\n\t\t\tthrow new IOException(\"Cannot create zip file becuase it already exists.\");\n\t\t}\n\n        byte[] buffer = new byte[BUFFER_SIZE];\n\t\t\n        try (ZipOutputStream zipStream = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(in_zipFilePath))))\n\t\t{\n            File directory = new File(in_directoryPath);\n            String[] directoryContents = directory.list();\n            for (String directoryItemName : directoryContents) \n            {\n                File directoryItem = new File(directory, directoryItemName);\n                if (directoryItem.isDirectory() == true) \n                {\n                    zipDirectoryRecursive(zipStream, directoryItem.getAbsolutePath(), in_directoryPath, in_uncompressedExtensions, buffer);\n                } \n                else if (directoryItem.isFile() == true) \n                {\n                    zipFile(zipStream, directoryItem.getAbsolutePath(), in_directoryPath, in_uncompressedExtensions, buffer);\n                }\n            }\n        }\n        catch(IOException e) \n\t\t{\n        \te.printStackTrace();\n        \tLogging.logFatal(e.getMessage());\n        \t\n        \tFile zip = new File(in_zipFilePath);\n        \tif (zip.exists() == true)\n    \t\t{\n        \t\tzip.delete();\n    \t\t}\n        \t\n            throw e;\n        }\n\t}\n\t/**\n\t * Extracts the contents of the zip file at the given file path to the\n\t * given directory path.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param in_zipFilePath - The input zip file path.\n\t * @param in_outputDirectoryPath - The output directory path.\n\t * \n\t * @throws IOException\n\t */\n\tpublic static void extract(String in_zipFilePath, String in_outputDirectoryPath) throws IOException\n\t{\n\t\tString zipFilePath = StringUtils.standardiseFilePath(in_zipFilePath);\n\t\tString outputDirectoryPath = StringUtils.standardiseDirectoryPath(in_outputDirectoryPath);\n\t\t\n\t\ttry (ZipInputStream zipStream = new ZipInputStream(new FileInputStream(zipFilePath)))\n\t\t{\n\t\t\tZipEntry zipEntry = null;\n\t\t\twhile ((zipEntry = zipStream.getNextEntry()) != null)\n\t\t\t{\n\t\t\t\tif(zipEntry.isDirectory() == true)\n\t\t\t\t{\n\t\t\t\t\tFile directory = new File(outputDirectoryPath + zipEntry.getName());\n\t\t\t\t\tif(directory.exists() == false)\n\t\t\t\t\t{\n\t\t\t\t\t\tdirectory.mkdirs();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tString relDirectoryPath = StringUtils.getDirectory(zipEntry.getName());\n\t\t\t\t\t\n\t\t\t\t\tFile directory = new File(outputDirectoryPath + relDirectoryPath);\n\t\t\t\t\tif(directory.exists() == false)\n\t\t\t\t\t{\n\t\t\t\t\t\tdirectory.mkdirs();\n\t\t\t\t\t}\n\t\t\n\t\t\t\t\textractFile(zipStream, outputDirectoryPath + zipEntry.getName());\n\t\t\t\t}  \n\t\t\t}\n\t\t}\n\t\tcatch (IOException e)\n\t\t{\n\t\t\tthrow e;\n\t\t}\n\t}\n\t/**\n\t * Recursively adds the directory to the given zip.\n\t *\n\t * @author Ian Copland\n\t *\n\t * @param in_zipStream - The stream to add the file to.\n\t * @param in_absDirectoryPath - The full path to the directory.\n\t * @param in_relativeTo - The directory the zip entries should be relative to\n\t * @param in_uncompressedExtensions - A list of file extensions which should not be \n\t * compressed\n\t * @param in_copyBuffer - A buffer used by the zipFile method. This is provided\n\t * as an optimisation to avoid re-allocating the buffer for each file.\n\t * \n\t * @throws IOException - If the directory could not be added to the zip.\n\t */\n\tprivate static void zipDirectoryRecursive(ZipOutputStream in_zipStream, String in_absDirectoryPath, String in_relativeTo, List<String> in_uncompressedExtensions, byte[] in_copyBuffer) throws IOException\n\t{\n\t    File directory = new File(in_absDirectoryPath);\n\n\t    String[] directoryContents = directory.list();\n\t    for (String directoryItemName : directoryContents) \n\t    {\n\t        File directoryItem = new File(directory, directoryItemName);\n\t        if (directoryItem.isDirectory() == true) \n\t        {\n\t            zipDirectoryRecursive(in_zipStream, directoryItem.getAbsolutePath(), in_relativeTo, in_uncompressedExtensions, in_copyBuffer);\n\t        } else if (directoryItem.isFile() == true) \n\t        {\n\t            zipFile(in_zipStream, directoryItem.getAbsolutePath(), in_relativeTo, in_uncompressedExtensions, in_copyBuffer);\n\t        }\n\t    }\n\t}\n\t/**\n\t * Adds the given file to the zip.\n\t *\n\t * @author Ian Copland\n\t *\n\t * @param in_zipStream - The stream to add the file to.\n\t * @param in_absFilePath - The full file path.\n\t * @param in_relativeTo - The path the file is relative to.\n\t * @param in_uncompressedExt - A list of file extensions which should not be compressed\n\t * @param in_copyBuffer - a buffer used in copying the file contents. This is provided\n\t * as an optimisation to avoid re-allocating the buffer for each file.\n\t * \n\t * @throws IOException - If the file could not be added to the zip file.\n\t */\n\tprivate static void zipFile(ZipOutputStream in_zipStream, String in_absFilePath, String in_relativeTo, List<String> in_uncompressedExt, byte[] in_copyBuffer) throws IOException\n\t{\n        String relativePath = StringUtils.getRelativeFilePath(in_absFilePath, in_relativeTo);\n        ZipEntry entry = new ZipEntry(relativePath);\n\n        if (hasExtension(relativePath, in_uncompressedExt) == true) \n        {\n        \tlong fileSize = new File(in_absFilePath).length();\n        \tlong crc = FileUtils.calcFileCRC32(in_absFilePath); \n        \t\n        \tentry.setMethod(ZipOutputStream.STORED);\n        \tentry.setCrc(crc);\n        \tentry.setSize(fileSize);\n        \tentry.setCompressedSize(fileSize);\n        } \n        else \n        {\n        \tentry.setMethod(ZipOutputStream.DEFLATED);\n        }\n        \n        in_zipStream.putNextEntry(entry);\n\t\t\n\t    try (BufferedInputStream bufferedInputStream = new BufferedInputStream(new FileInputStream(in_absFilePath), in_copyBuffer.length))\n\t    {        \n\t        int count = 0;\n\t        while((count = bufferedInputStream.read(in_copyBuffer, 0, in_copyBuffer.length)) != -1) \n\t        {\n\t            in_zipStream.write(in_copyBuffer, 0, count);\n\t        }\n\t    }\n\t    catch(IOException e) \n\t    {\n\t        throw e;\n\t    }\n\t}\n\t/**\n\t * @author Ian Copland\n\t *\n\t * @param in_filePath - A file path.\n\t * @param in_extensions - A list of extensions.\n\t *\n\t * @return Whether or not the given file path has one of the given extensions.\n\t */\n\tprivate static boolean hasExtension(String in_filePath, List<String> in_extensions) \n\t{\n\t    String lowerFilePath = in_filePath.toLowerCase();\n\t    for (String extension : in_extensions) \n\t    {\n\t        if (lowerFilePath.endsWith(extension) == true) \n\t        {\n\t            return true;\n\t        }\n\t    }\n\t    return false;\n\t}\n\t/**\n\t * Extracts the file described by the given zip entry to the given output file path.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param in_zipStream - The input zip stream.\n\t * @param in_outputFilePath - The output directory path.\n\t * \n\t * @throws IOException\n\t */\n\tprivate static void extractFile(ZipInputStream in_zipStream, String in_outputFilePath) throws IOException\n\t{\n\t\tString outputFilePath = StringUtils.standardiseFilePath(in_outputFilePath);\n\t\t\n\t    try (BufferedOutputStream outputStream = new BufferedOutputStream(new FileOutputStream(new File(outputFilePath))))\n\t    {\n\t    \tbyte[] buffer = new byte[BUFFER_SIZE];\n\t    \tint size = -1;\n\t    \t\n\t    \twhile ((size = in_zipStream.read(buffer)) != -1)\n\t\t    {\n\t    \t\toutputStream.write(buffer, 0, size);\n\t\t    }\n\t    }\n\t    catch (IOException e)\n\t    {\n\t    \tthrow e;\n\t    }\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/CoreUtils/src/org/json/JSONArray.java",
    "content": "package org.json;\n\n/*\n Copyright (c) 2002 JSON.org\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n The Software shall be used for Good, not Evil.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n */\n\nimport java.io.IOException;\nimport java.io.StringWriter;\nimport java.io.Writer;\nimport java.lang.reflect.Array;\nimport java.util.ArrayList;\nimport java.util.Collection;\nimport java.util.Iterator;\nimport java.util.Map;\n\n/**\n * A JSONArray is an ordered sequence of values. Its external text form is a\n * string wrapped in square brackets with commas separating the values. The\n * internal form is an object having <code>get</code> and <code>opt</code>\n * methods for accessing the values by index, and <code>put</code> methods for\n * adding or replacing values. The values can be any of these types:\n * <code>Boolean</code>, <code>JSONArray</code>, <code>JSONObject</code>,\n * <code>Number</code>, <code>String</code>, or the\n * <code>JSONObject.NULL object</code>.\n * <p>\n * The constructor can convert a JSON text into a Java object. The\n * <code>toString</code> method converts to JSON text.\n * <p>\n * A <code>get</code> method returns a value if one can be found, and throws an\n * exception if one cannot be found. An <code>opt</code> method returns a\n * default value instead of throwing an exception, and so is useful for\n * obtaining optional values.\n * <p>\n * The generic <code>get()</code> and <code>opt()</code> methods return an\n * object which you can cast or query for type. There are also typed\n * <code>get</code> and <code>opt</code> methods that do type checking and type\n * coercion for you.\n * <p>\n * The texts produced by the <code>toString</code> methods strictly conform to\n * JSON syntax rules. The constructors are more forgiving in the texts they will\n * accept:\n * <ul>\n * <li>An extra <code>,</code>&nbsp;<small>(comma)</small> may appear just\n * before the closing bracket.</li>\n * <li>The <code>null</code> value will be inserted when there is <code>,</code>\n * &nbsp;<small>(comma)</small> elision.</li>\n * <li>Strings may be quoted with <code>'</code>&nbsp;<small>(single\n * quote)</small>.</li>\n * <li>Strings do not need to be quoted at all if they do not begin with a quote\n * or single quote, and if they do not contain leading or trailing spaces, and\n * if they do not contain any of these characters:\n * <code>{ } [ ] / \\ : , #</code> and if they do not look like numbers and\n * if they are not the reserved words <code>true</code>, <code>false</code>, or\n * <code>null</code>.</li>\n * </ul>\n *\n * @author JSON.org\n * @version 2014-05-03\n */\npublic class JSONArray {\n\n    /**\n     * The arrayList where the JSONArray's properties are kept.\n     */\n    private final ArrayList<Object> myArrayList;\n\n    /**\n     * Construct an empty JSONArray.\n     */\n    public JSONArray() {\n        this.myArrayList = new ArrayList<Object>();\n    }\n\n    /**\n     * Construct a JSONArray from a JSONTokener.\n     *\n     * @param x\n     *            A JSONTokener\n     * @throws JSONException\n     *             If there is a syntax error.\n     */\n    public JSONArray(JSONTokener x) throws JSONException {\n        this();\n        if (x.nextClean() != '[') {\n            throw x.syntaxError(\"A JSONArray text must start with '['\");\n        }\n        if (x.nextClean() != ']') {\n            x.back();\n            for (;;) {\n                if (x.nextClean() == ',') {\n                    x.back();\n                    this.myArrayList.add(JSONObject.NULL);\n                } else {\n                    x.back();\n                    this.myArrayList.add(x.nextValue());\n                }\n                switch (x.nextClean()) {\n                case ',':\n                    if (x.nextClean() == ']') {\n                        return;\n                    }\n                    x.back();\n                    break;\n                case ']':\n                    return;\n                default:\n                    throw x.syntaxError(\"Expected a ',' or ']'\");\n                }\n            }\n        }\n    }\n\n    /**\n     * Construct a JSONArray from a source JSON text.\n     *\n     * @param source\n     *            A string that begins with <code>[</code>&nbsp;<small>(left\n     *            bracket)</small> and ends with <code>]</code>\n     *            &nbsp;<small>(right bracket)</small>.\n     * @throws JSONException\n     *             If there is a syntax error.\n     */\n    public JSONArray(String source) throws JSONException {\n        this(new JSONTokener(source));\n    }\n\n    /**\n     * Construct a JSONArray from a Collection.\n     *\n     * @param collection\n     *            A Collection.\n     */\n    public JSONArray(Collection<Object> collection) {\n        this.myArrayList = new ArrayList<Object>();\n        if (collection != null) {\n            Iterator<Object> iter = collection.iterator();\n            while (iter.hasNext()) {\n                this.myArrayList.add(JSONObject.wrap(iter.next()));\n            }\n        }\n    }\n\n    /**\n     * Construct a JSONArray from an array\n     *\n     * @throws JSONException\n     *             If not an array.\n     */\n    public JSONArray(Object array) throws JSONException {\n        this();\n        if (array.getClass().isArray()) {\n            int length = Array.getLength(array);\n            for (int i = 0; i < length; i += 1) {\n                this.put(JSONObject.wrap(Array.get(array, i)));\n            }\n        } else {\n            throw new JSONException(\n                    \"JSONArray initial value should be a string or collection or array.\");\n        }\n    }\n\n    /**\n     * Get the object value associated with an index.\n     *\n     * @param index\n     *            The index must be between 0 and length() - 1.\n     * @return An object value.\n     * @throws JSONException\n     *             If there is no value for the index.\n     */\n    public Object get(int index) throws JSONException {\n        Object object = this.opt(index);\n        if (object == null) {\n            throw new JSONException(\"JSONArray[\" + index + \"] not found.\");\n        }\n        return object;\n    }\n\n    /**\n     * Get the boolean value associated with an index. The string values \"true\"\n     * and \"false\" are converted to boolean.\n     *\n     * @param index\n     *            The index must be between 0 and length() - 1.\n     * @return The truth.\n     * @throws JSONException\n     *             If there is no value for the index or if the value is not\n     *             convertible to boolean.\n     */\n    public boolean getBoolean(int index) throws JSONException {\n        Object object = this.get(index);\n        if (object.equals(Boolean.FALSE)\n                || (object instanceof String && ((String) object)\n                        .equalsIgnoreCase(\"false\"))) {\n            return false;\n        } else if (object.equals(Boolean.TRUE)\n                || (object instanceof String && ((String) object)\n                        .equalsIgnoreCase(\"true\"))) {\n            return true;\n        }\n        throw new JSONException(\"JSONArray[\" + index + \"] is not a boolean.\");\n    }\n\n    /**\n     * Get the double value associated with an index.\n     *\n     * @param index\n     *            The index must be between 0 and length() - 1.\n     * @return The value.\n     * @throws JSONException\n     *             If the key is not found or if the value cannot be converted\n     *             to a number.\n     */\n    public double getDouble(int index) throws JSONException {\n        Object object = this.get(index);\n        try {\n            return object instanceof Number ? ((Number) object).doubleValue()\n                    : Double.parseDouble((String) object);\n        } catch (Exception e) {\n            throw new JSONException(\"JSONArray[\" + index + \"] is not a number.\");\n        }\n    }\n\n    /**\n     * Get the int value associated with an index.\n     *\n     * @param index\n     *            The index must be between 0 and length() - 1.\n     * @return The value.\n     * @throws JSONException\n     *             If the key is not found or if the value is not a number.\n     */\n    public int getInt(int index) throws JSONException {\n        Object object = this.get(index);\n        try {\n            return object instanceof Number ? ((Number) object).intValue()\n                    : Integer.parseInt((String) object);\n        } catch (Exception e) {\n            throw new JSONException(\"JSONArray[\" + index + \"] is not a number.\");\n        }\n    }\n\n    /**\n     * Get the JSONArray associated with an index.\n     *\n     * @param index\n     *            The index must be between 0 and length() - 1.\n     * @return A JSONArray value.\n     * @throws JSONException\n     *             If there is no value for the index. or if the value is not a\n     *             JSONArray\n     */\n    public JSONArray getJSONArray(int index) throws JSONException {\n        Object object = this.get(index);\n        if (object instanceof JSONArray) {\n            return (JSONArray) object;\n        }\n        throw new JSONException(\"JSONArray[\" + index + \"] is not a JSONArray.\");\n    }\n\n    /**\n     * Get the JSONObject associated with an index.\n     *\n     * @param index\n     *            subscript\n     * @return A JSONObject value.\n     * @throws JSONException\n     *             If there is no value for the index or if the value is not a\n     *             JSONObject\n     */\n    public JSONObject getJSONObject(int index) throws JSONException {\n        Object object = this.get(index);\n        if (object instanceof JSONObject) {\n            return (JSONObject) object;\n        }\n        throw new JSONException(\"JSONArray[\" + index + \"] is not a JSONObject.\");\n    }\n\n    /**\n     * Get the long value associated with an index.\n     *\n     * @param index\n     *            The index must be between 0 and length() - 1.\n     * @return The value.\n     * @throws JSONException\n     *             If the key is not found or if the value cannot be converted\n     *             to a number.\n     */\n    public long getLong(int index) throws JSONException {\n        Object object = this.get(index);\n        try {\n            return object instanceof Number ? ((Number) object).longValue()\n                    : Long.parseLong((String) object);\n        } catch (Exception e) {\n            throw new JSONException(\"JSONArray[\" + index + \"] is not a number.\");\n        }\n    }\n\n    /**\n     * Get the string associated with an index.\n     *\n     * @param index\n     *            The index must be between 0 and length() - 1.\n     * @return A string value.\n     * @throws JSONException\n     *             If there is no string value for the index.\n     */\n    public String getString(int index) throws JSONException {\n        Object object = this.get(index);\n        if (object instanceof String) {\n            return (String) object;\n        }\n        throw new JSONException(\"JSONArray[\" + index + \"] not a string.\");\n    }\n\n    /**\n     * Determine if the value is null.\n     *\n     * @param index\n     *            The index must be between 0 and length() - 1.\n     * @return true if the value at the index is null, or if there is no value.\n     */\n    public boolean isNull(int index) {\n        return JSONObject.NULL.equals(this.opt(index));\n    }\n\n    /**\n     * Make a string from the contents of this JSONArray. The\n     * <code>separator</code> string is inserted between each element. Warning:\n     * This method assumes that the data structure is acyclical.\n     *\n     * @param separator\n     *            A string that will be inserted between the elements.\n     * @return a string.\n     * @throws JSONException\n     *             If the array contains an invalid number.\n     */\n    public String join(String separator) throws JSONException {\n        int len = this.length();\n        StringBuilder sb = new StringBuilder();\n\n        for (int i = 0; i < len; i += 1) {\n            if (i > 0) {\n                sb.append(separator);\n            }\n            sb.append(JSONObject.valueToString(this.myArrayList.get(i)));\n        }\n        return sb.toString();\n    }\n\n    /**\n     * Get the number of elements in the JSONArray, included nulls.\n     *\n     * @return The length (or size).\n     */\n    public int length() {\n        return this.myArrayList.size();\n    }\n\n    /**\n     * Get the optional object value associated with an index.\n     *\n     * @param index\n     *            The index must be between 0 and length() - 1.\n     * @return An object value, or null if there is no object at that index.\n     */\n    public Object opt(int index) {\n        return (index < 0 || index >= this.length()) ? null : this.myArrayList\n                .get(index);\n    }\n\n    /**\n     * Get the optional boolean value associated with an index. It returns false\n     * if there is no value at that index, or if the value is not Boolean.TRUE\n     * or the String \"true\".\n     *\n     * @param index\n     *            The index must be between 0 and length() - 1.\n     * @return The truth.\n     */\n    public boolean optBoolean(int index) {\n        return this.optBoolean(index, false);\n    }\n\n    /**\n     * Get the optional boolean value associated with an index. It returns the\n     * defaultValue if there is no value at that index or if it is not a Boolean\n     * or the String \"true\" or \"false\" (case insensitive).\n     *\n     * @param index\n     *            The index must be between 0 and length() - 1.\n     * @param defaultValue\n     *            A boolean default.\n     * @return The truth.\n     */\n    public boolean optBoolean(int index, boolean defaultValue) {\n        try {\n            return this.getBoolean(index);\n        } catch (Exception e) {\n            return defaultValue;\n        }\n    }\n\n    /**\n     * Get the optional double value associated with an index. NaN is returned\n     * if there is no value for the index, or if the value is not a number and\n     * cannot be converted to a number.\n     *\n     * @param index\n     *            The index must be between 0 and length() - 1.\n     * @return The value.\n     */\n    public double optDouble(int index) {\n        return this.optDouble(index, Double.NaN);\n    }\n\n    /**\n     * Get the optional double value associated with an index. The defaultValue\n     * is returned if there is no value for the index, or if the value is not a\n     * number and cannot be converted to a number.\n     *\n     * @param index\n     *            subscript\n     * @param defaultValue\n     *            The default value.\n     * @return The value.\n     */\n    public double optDouble(int index, double defaultValue) {\n        try {\n            return this.getDouble(index);\n        } catch (Exception e) {\n            return defaultValue;\n        }\n    }\n\n    /**\n     * Get the optional int value associated with an index. Zero is returned if\n     * there is no value for the index, or if the value is not a number and\n     * cannot be converted to a number.\n     *\n     * @param index\n     *            The index must be between 0 and length() - 1.\n     * @return The value.\n     */\n    public int optInt(int index) {\n        return this.optInt(index, 0);\n    }\n\n    /**\n     * Get the optional int value associated with an index. The defaultValue is\n     * returned if there is no value for the index, or if the value is not a\n     * number and cannot be converted to a number.\n     *\n     * @param index\n     *            The index must be between 0 and length() - 1.\n     * @param defaultValue\n     *            The default value.\n     * @return The value.\n     */\n    public int optInt(int index, int defaultValue) {\n        try {\n            return this.getInt(index);\n        } catch (Exception e) {\n            return defaultValue;\n        }\n    }\n\n    /**\n     * Get the optional JSONArray associated with an index.\n     *\n     * @param index\n     *            subscript\n     * @return A JSONArray value, or null if the index has no value, or if the\n     *         value is not a JSONArray.\n     */\n    public JSONArray optJSONArray(int index) {\n        Object o = this.opt(index);\n        return o instanceof JSONArray ? (JSONArray) o : null;\n    }\n\n    /**\n     * Get the optional JSONObject associated with an index. Null is returned if\n     * the key is not found, or null if the index has no value, or if the value\n     * is not a JSONObject.\n     *\n     * @param index\n     *            The index must be between 0 and length() - 1.\n     * @return A JSONObject value.\n     */\n    public JSONObject optJSONObject(int index) {\n        Object o = this.opt(index);\n        return o instanceof JSONObject ? (JSONObject) o : null;\n    }\n\n    /**\n     * Get the optional long value associated with an index. Zero is returned if\n     * there is no value for the index, or if the value is not a number and\n     * cannot be converted to a number.\n     *\n     * @param index\n     *            The index must be between 0 and length() - 1.\n     * @return The value.\n     */\n    public long optLong(int index) {\n        return this.optLong(index, 0);\n    }\n\n    /**\n     * Get the optional long value associated with an index. The defaultValue is\n     * returned if there is no value for the index, or if the value is not a\n     * number and cannot be converted to a number.\n     *\n     * @param index\n     *            The index must be between 0 and length() - 1.\n     * @param defaultValue\n     *            The default value.\n     * @return The value.\n     */\n    public long optLong(int index, long defaultValue) {\n        try {\n            return this.getLong(index);\n        } catch (Exception e) {\n            return defaultValue;\n        }\n    }\n\n    /**\n     * Get the optional string value associated with an index. It returns an\n     * empty string if there is no value at that index. If the value is not a\n     * string and is not null, then it is coverted to a string.\n     *\n     * @param index\n     *            The index must be between 0 and length() - 1.\n     * @return A String value.\n     */\n    public String optString(int index) {\n        return this.optString(index, \"\");\n    }\n\n    /**\n     * Get the optional string associated with an index. The defaultValue is\n     * returned if the key is not found.\n     *\n     * @param index\n     *            The index must be between 0 and length() - 1.\n     * @param defaultValue\n     *            The default value.\n     * @return A String value.\n     */\n    public String optString(int index, String defaultValue) {\n        Object object = this.opt(index);\n        return JSONObject.NULL.equals(object) ? defaultValue : object\n                .toString();\n    }\n\n    /**\n     * Append a boolean value. This increases the array's length by one.\n     *\n     * @param value\n     *            A boolean value.\n     * @return this.\n     */\n    public JSONArray put(boolean value) {\n        this.put(value ? Boolean.TRUE : Boolean.FALSE);\n        return this;\n    }\n\n    /**\n     * Put a value in the JSONArray, where the value will be a JSONArray which\n     * is produced from a Collection.\n     *\n     * @param value\n     *            A Collection value.\n     * @return this.\n     */\n    public JSONArray put(Collection<Object> value) {\n        this.put(new JSONArray(value));\n        return this;\n    }\n\n    /**\n     * Append a double value. This increases the array's length by one.\n     *\n     * @param value\n     *            A double value.\n     * @throws JSONException\n     *             if the value is not finite.\n     * @return this.\n     */\n    public JSONArray put(double value) throws JSONException {\n        Double d = new Double(value);\n        JSONObject.testValidity(d);\n        this.put(d);\n        return this;\n    }\n\n    /**\n     * Append an int value. This increases the array's length by one.\n     *\n     * @param value\n     *            An int value.\n     * @return this.\n     */\n    public JSONArray put(int value) {\n        this.put(new Integer(value));\n        return this;\n    }\n\n    /**\n     * Append an long value. This increases the array's length by one.\n     *\n     * @param value\n     *            A long value.\n     * @return this.\n     */\n    public JSONArray put(long value) {\n        this.put(new Long(value));\n        return this;\n    }\n\n    /**\n     * Put a value in the JSONArray, where the value will be a JSONObject which\n     * is produced from a Map.\n     *\n     * @param value\n     *            A Map value.\n     * @return this.\n     */\n    public JSONArray put(Map<String, Object> value) {\n        this.put(new JSONObject(value));\n        return this;\n    }\n\n    /**\n     * Append an object value. This increases the array's length by one.\n     *\n     * @param value\n     *            An object value. The value should be a Boolean, Double,\n     *            Integer, JSONArray, JSONObject, Long, or String, or the\n     *            JSONObject.NULL object.\n     * @return this.\n     */\n    public JSONArray put(Object value) {\n        this.myArrayList.add(value);\n        return this;\n    }\n\n    /**\n     * Put or replace a boolean value in the JSONArray. If the index is greater\n     * than the length of the JSONArray, then null elements will be added as\n     * necessary to pad it out.\n     *\n     * @param index\n     *            The subscript.\n     * @param value\n     *            A boolean value.\n     * @return this.\n     * @throws JSONException\n     *             If the index is negative.\n     */\n    public JSONArray put(int index, boolean value) throws JSONException {\n        this.put(index, value ? Boolean.TRUE : Boolean.FALSE);\n        return this;\n    }\n\n    /**\n     * Put a value in the JSONArray, where the value will be a JSONArray which\n     * is produced from a Collection.\n     *\n     * @param index\n     *            The subscript.\n     * @param value\n     *            A Collection value.\n     * @return this.\n     * @throws JSONException\n     *             If the index is negative or if the value is not finite.\n     */\n    public JSONArray put(int index, Collection<Object> value) throws JSONException {\n        this.put(index, new JSONArray(value));\n        return this;\n    }\n\n    /**\n     * Put or replace a double value. If the index is greater than the length of\n     * the JSONArray, then null elements will be added as necessary to pad it\n     * out.\n     *\n     * @param index\n     *            The subscript.\n     * @param value\n     *            A double value.\n     * @return this.\n     * @throws JSONException\n     *             If the index is negative or if the value is not finite.\n     */\n    public JSONArray put(int index, double value) throws JSONException {\n        this.put(index, new Double(value));\n        return this;\n    }\n\n    /**\n     * Put or replace an int value. If the index is greater than the length of\n     * the JSONArray, then null elements will be added as necessary to pad it\n     * out.\n     *\n     * @param index\n     *            The subscript.\n     * @param value\n     *            An int value.\n     * @return this.\n     * @throws JSONException\n     *             If the index is negative.\n     */\n    public JSONArray put(int index, int value) throws JSONException {\n        this.put(index, new Integer(value));\n        return this;\n    }\n\n    /**\n     * Put or replace a long value. If the index is greater than the length of\n     * the JSONArray, then null elements will be added as necessary to pad it\n     * out.\n     *\n     * @param index\n     *            The subscript.\n     * @param value\n     *            A long value.\n     * @return this.\n     * @throws JSONException\n     *             If the index is negative.\n     */\n    public JSONArray put(int index, long value) throws JSONException {\n        this.put(index, new Long(value));\n        return this;\n    }\n\n    /**\n     * Put a value in the JSONArray, where the value will be a JSONObject that\n     * is produced from a Map.\n     *\n     * @param index\n     *            The subscript.\n     * @param value\n     *            The Map value.\n     * @return this.\n     * @throws JSONException\n     *             If the index is negative or if the the value is an invalid\n     *             number.\n     */\n    public JSONArray put(int index, Map<String, Object> value) throws JSONException {\n        this.put(index, new JSONObject(value));\n        return this;\n    }\n\n    /**\n     * Put or replace an object value in the JSONArray. If the index is greater\n     * than the length of the JSONArray, then null elements will be added as\n     * necessary to pad it out.\n     *\n     * @param index\n     *            The subscript.\n     * @param value\n     *            The value to put into the array. The value should be a\n     *            Boolean, Double, Integer, JSONArray, JSONObject, Long, or\n     *            String, or the JSONObject.NULL object.\n     * @return this.\n     * @throws JSONException\n     *             If the index is negative or if the the value is an invalid\n     *             number.\n     */\n    public JSONArray put(int index, Object value) throws JSONException {\n        JSONObject.testValidity(value);\n        if (index < 0) {\n            throw new JSONException(\"JSONArray[\" + index + \"] not found.\");\n        }\n        if (index < this.length()) {\n            this.myArrayList.set(index, value);\n        } else {\n            while (index != this.length()) {\n                this.put(JSONObject.NULL);\n            }\n            this.put(value);\n        }\n        return this;\n    }\n\n    /**\n     * Remove an index and close the hole.\n     *\n     * @param index\n     *            The index of the element to be removed.\n     * @return The value that was associated with the index, or null if there\n     *         was no value.\n     */\n    public Object remove(int index) {\n        return index >= 0 && index < this.length()\n            ? this.myArrayList.remove(index)\n            : null;\n    }\n\n    /**\n     * Determine if two JSONArrays are similar.\n     * They must contain similar sequences.\n     *\n     * @param other The other JSONArray\n     * @return true if they are equal\n     */\n    public boolean similar(Object other) {\n        if (!(other instanceof JSONArray)) {\n            return false;\n        }\n        int len = this.length();\n        if (len != ((JSONArray)other).length()) {\n            return false;\n        }\n        for (int i = 0; i < len; i += 1) {\n            Object valueThis = this.get(i);\n            Object valueOther = ((JSONArray)other).get(i);\n            if (valueThis instanceof JSONObject) {\n                if (!((JSONObject)valueThis).similar(valueOther)) {\n                    return false;\n                }\n            } else if (valueThis instanceof JSONArray) {\n                if (!((JSONArray)valueThis).similar(valueOther)) {\n                    return false;\n                }\n            } else if (!valueThis.equals(valueOther)) {\n                return false;\n            }\n        }\n        return true;\n    }\n\n    /**\n     * Produce a JSONObject by combining a JSONArray of names with the values of\n     * this JSONArray.\n     *\n     * @param names\n     *            A JSONArray containing a list of key strings. These will be\n     *            paired with the values.\n     * @return A JSONObject, or null if there are no names or if this JSONArray\n     *         has no values.\n     * @throws JSONException\n     *             If any of the names are null.\n     */\n    public JSONObject toJSONObject(JSONArray names) throws JSONException {\n        if (names == null || names.length() == 0 || this.length() == 0) {\n            return null;\n        }\n        JSONObject jo = new JSONObject();\n        for (int i = 0; i < names.length(); i += 1) {\n            jo.put(names.getString(i), this.opt(i));\n        }\n        return jo;\n    }\n\n    /**\n     * Make a JSON text of this JSONArray. For compactness, no unnecessary\n     * whitespace is added. If it is not possible to produce a syntactically\n     * correct JSON text then null will be returned instead. This could occur if\n     * the array contains an invalid number.\n     * <p>\n     * Warning: This method assumes that the data structure is acyclical.\n     *\n     * @return a printable, displayable, transmittable representation of the\n     *         array.\n     */\n    public String toString() {\n        try {\n            return this.toString(0);\n        } catch (Exception e) {\n            return null;\n        }\n    }\n\n    /**\n     * Make a prettyprinted JSON text of this JSONArray. Warning: This method\n     * assumes that the data structure is acyclical.\n     *\n     * @param indentFactor\n     *            The number of spaces to add to each level of indentation.\n     * @return a printable, displayable, transmittable representation of the\n     *         object, beginning with <code>[</code>&nbsp;<small>(left\n     *         bracket)</small> and ending with <code>]</code>\n     *         &nbsp;<small>(right bracket)</small>.\n     * @throws JSONException\n     */\n    public String toString(int indentFactor) throws JSONException {\n        StringWriter sw = new StringWriter();\n        synchronized (sw.getBuffer()) {\n            return this.write(sw, indentFactor, 0).toString();\n        }\n    }\n\n    /**\n     * Write the contents of the JSONArray as JSON text to a writer. For\n     * compactness, no whitespace is added.\n     * <p>\n     * Warning: This method assumes that the data structure is acyclical.\n     *\n     * @return The writer.\n     * @throws JSONException\n     */\n    public Writer write(Writer writer) throws JSONException {\n        return this.write(writer, 0, 0);\n    }\n\n    /**\n     * Write the contents of the JSONArray as JSON text to a writer. For\n     * compactness, no whitespace is added.\n     * <p>\n     * Warning: This method assumes that the data structure is acyclical.\n     *\n     * @param indentFactor\n     *            The number of spaces to add to each level of indentation.\n     * @param indent\n     *            The indention of the top level.\n     * @return The writer.\n     * @throws JSONException\n     */\n    Writer write(Writer writer, int indentFactor, int indent)\n            throws JSONException {\n        try {\n            boolean commanate = false;\n            int length = this.length();\n            writer.write('[');\n\n            if (length == 1) {\n                JSONObject.writeValue(writer, this.myArrayList.get(0),\n                        indentFactor, indent);\n            } else if (length != 0) {\n                final int newindent = indent + indentFactor;\n\n                for (int i = 0; i < length; i += 1) {\n                    if (commanate) {\n                        writer.write(',');\n                    }\n                    if (indentFactor > 0) {\n                        writer.write('\\n');\n                    }\n                    JSONObject.indent(writer, newindent);\n                    JSONObject.writeValue(writer, this.myArrayList.get(i),\n                            indentFactor, newindent);\n                    commanate = true;\n                }\n                if (indentFactor > 0) {\n                    writer.write('\\n');\n                }\n                JSONObject.indent(writer, indent);\n            }\n            writer.write(']');\n            return writer;\n        } catch (IOException e) {\n            throw new JSONException(e);\n        }\n    }\n}\n"
  },
  {
    "path": "Projects/Tools/CoreUtils/src/org/json/JSONException.java",
    "content": "package org.json;\n\n/**\n * The JSONException is thrown by the JSON.org classes when things are amiss.\n *\n * @author JSON.org\n * @version 2014-05-03\n */\npublic class JSONException extends RuntimeException {\n    private static final long serialVersionUID = 0;\n    private Throwable cause;\n\n    /**\n     * Constructs a JSONException with an explanatory message.\n     *\n     * @param message\n     *            Detail about the reason for the exception.\n     */\n    public JSONException(String message) {\n        super(message);\n    }\n\n    /**\n     * Constructs a new JSONException with the specified cause.\n     * @param cause The cause.\n     */\n    public JSONException(Throwable cause) {\n        super(cause.getMessage());\n        this.cause = cause;\n    }\n\n    /**\n     * Returns the cause of this exception or null if the cause is nonexistent\n     * or unknown.\n     *\n     * @return the cause of this exception or null if the cause is nonexistent\n     *          or unknown.\n     */\n    @Override\n    public Throwable getCause() {\n        return this.cause;\n    }\n}\n"
  },
  {
    "path": "Projects/Tools/CoreUtils/src/org/json/JSONObject.java",
    "content": "package org.json;\n\n/*\n Copyright (c) 2002 JSON.org\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n The Software shall be used for Good, not Evil.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n */\n\nimport java.io.IOException;\nimport java.io.StringWriter;\nimport java.io.Writer;\nimport java.lang.reflect.Field;\nimport java.lang.reflect.Method;\nimport java.lang.reflect.Modifier;\nimport java.util.Collection;\nimport java.util.Enumeration;\nimport java.util.HashMap;\nimport java.util.Iterator;\nimport java.util.Locale;\nimport java.util.Map;\nimport java.util.Map.Entry;\nimport java.util.ResourceBundle;\nimport java.util.Set;\n\n/**\n * A JSONObject is an unordered collection of name/value pairs. Its external\n * form is a string wrapped in curly braces with colons between the names and\n * values, and commas between the values and names. The internal form is an\n * object having <code>get</code> and <code>opt</code> methods for accessing\n * the values by name, and <code>put</code> methods for adding or replacing\n * values by name. The values can be any of these types: <code>Boolean</code>,\n * <code>JSONArray</code>, <code>JSONObject</code>, <code>Number</code>,\n * <code>String</code>, or the <code>JSONObject.NULL</code> object. A\n * JSONObject constructor can be used to convert an external form JSON text\n * into an internal form whose values can be retrieved with the\n * <code>get</code> and <code>opt</code> methods, or to convert values into a\n * JSON text using the <code>put</code> and <code>toString</code> methods. A\n * <code>get</code> method returns a value if one can be found, and throws an\n * exception if one cannot be found. An <code>opt</code> method returns a\n * default value instead of throwing an exception, and so is useful for\n * obtaining optional values.\n * <p>\n * The generic <code>get()</code> and <code>opt()</code> methods return an\n * object, which you can cast or query for type. There are also typed\n * <code>get</code> and <code>opt</code> methods that do type checking and type\n * coercion for you. The opt methods differ from the get methods in that they\n * do not throw. Instead, they return a specified value, such as null.\n * <p>\n * The <code>put</code> methods add or replace values in an object. For\n * example,\n *\n * <pre>\n * myString = new JSONObject()\n *         .put(&quot;JSON&quot;, &quot;Hello, World!&quot;).toString();\n * </pre>\n *\n * produces the string <code>{\"JSON\": \"Hello, World\"}</code>.\n * <p>\n * The texts produced by the <code>toString</code> methods strictly conform to\n * the JSON syntax rules. The constructors are more forgiving in the texts they\n * will accept:\n * <ul>\n * <li>An extra <code>,</code>&nbsp;<small>(comma)</small> may appear just\n * before the closing brace.</li>\n * <li>Strings may be quoted with <code>'</code>&nbsp;<small>(single\n * quote)</small>.</li>\n * <li>Strings do not need to be quoted at all if they do not begin with a\n * quote or single quote, and if they do not contain leading or trailing\n * spaces, and if they do not contain any of these characters:\n * <code>{ } [ ] / \\ : , #</code> and if they do not look like numbers and\n * if they are not the reserved words <code>true</code>, <code>false</code>,\n * or <code>null</code>.</li>\n * </ul>\n *\n * @author JSON.org\n * @version 2014-05-03\n */\npublic class JSONObject {\n    /**\n     * JSONObject.NULL is equivalent to the value that JavaScript calls null,\n     * whilst Java's null is equivalent to the value that JavaScript calls\n     * undefined.\n     */\n    private static final class Null {\n\n        /**\n         * There is only intended to be a single instance of the NULL object,\n         * so the clone method returns itself.\n         *\n         * @return NULL.\n         */\n        @Override\n        protected final Object clone() {\n            return this;\n        }\n\n        /**\n         * A Null object is equal to the null value and to itself.\n         *\n         * @param object\n         *            An object to test for nullness.\n         * @return true if the object parameter is the JSONObject.NULL object or\n         *         null.\n         */\n        @Override\n        public boolean equals(Object object) {\n            return object == null || object == this;\n        }\n\n        /**\n         * Get the \"null\" string value.\n         *\n         * @return The string \"null\".\n         */\n        public String toString() {\n            return \"null\";\n        }\n    }\n\n    /**\n     * The map where the JSONObject's properties are kept.\n     */\n    private final Map<String, Object> map;\n\n    /**\n     * It is sometimes more convenient and less ambiguous to have a\n     * <code>NULL</code> object than to use Java's <code>null</code> value.\n     * <code>JSONObject.NULL.equals(null)</code> returns <code>true</code>.\n     * <code>JSONObject.NULL.toString()</code> returns <code>\"null\"</code>.\n     */\n    public static final Object NULL = new Null();\n\n    /**\n     * Construct an empty JSONObject.\n     */\n    public JSONObject() {\n        this.map = new HashMap<String, Object>();\n    }\n\n    /**\n     * Construct a JSONObject from a subset of another JSONObject. An array of\n     * strings is used to identify the keys that should be copied. Missing keys\n     * are ignored.\n     *\n     * @param jo\n     *            A JSONObject.\n     * @param names\n     *            An array of strings.\n     * @throws JSONException\n     * @exception JSONException\n     *                If a value is a non-finite number or if a name is\n     *                duplicated.\n     */\n    public JSONObject(JSONObject jo, String[] names) {\n        this();\n        for (int i = 0; i < names.length; i += 1) {\n            try {\n                this.putOnce(names[i], jo.opt(names[i]));\n            } catch (Exception ignore) {\n            }\n        }\n    }\n\n    /**\n     * Construct a JSONObject from a JSONTokener.\n     *\n     * @param x\n     *            A JSONTokener object containing the source string.\n     * @throws JSONException\n     *             If there is a syntax error in the source string or a\n     *             duplicated key.\n     */\n    public JSONObject(JSONTokener x) throws JSONException {\n        this();\n        char c;\n        String key;\n\n        if (x.nextClean() != '{') {\n            throw x.syntaxError(\"A JSONObject text must begin with '{'\");\n        }\n        for (;;) {\n            c = x.nextClean();\n            switch (c) {\n            case 0:\n                throw x.syntaxError(\"A JSONObject text must end with '}'\");\n            case '}':\n                return;\n            default:\n                x.back();\n                key = x.nextValue().toString();\n            }\n\n// The key is followed by ':'.\n\n            c = x.nextClean();\n            if (c != ':') {\n                throw x.syntaxError(\"Expected a ':' after a key\");\n            }\n            this.putOnce(key, x.nextValue());\n\n// Pairs are separated by ','.\n\n            switch (x.nextClean()) {\n            case ';':\n            case ',':\n                if (x.nextClean() == '}') {\n                    return;\n                }\n                x.back();\n                break;\n            case '}':\n                return;\n            default:\n                throw x.syntaxError(\"Expected a ',' or '}'\");\n            }\n        }\n    }\n\n    /**\n     * Construct a JSONObject from a Map.\n     *\n     * @param map\n     *            A map object that can be used to initialize the contents of\n     *            the JSONObject.\n     * @throws JSONException\n     */\n    public JSONObject(Map<String, Object> map) {\n        this.map = new HashMap<String, Object>();\n        if (map != null) {\n            Iterator<Entry<String, Object>> i = map.entrySet().iterator();\n            while (i.hasNext()) {\n                Entry<String, Object> entry = i.next();\n                Object value = entry.getValue();\n                if (value != null) {\n                    this.map.put(entry.getKey(), wrap(value));\n                }\n            }\n        }\n    }\n\n    /**\n     * Construct a JSONObject from an Object using bean getters. It reflects on\n     * all of the public methods of the object. For each of the methods with no\n     * parameters and a name starting with <code>\"get\"</code> or\n     * <code>\"is\"</code> followed by an uppercase letter, the method is invoked,\n     * and a key and the value returned from the getter method are put into the\n     * new JSONObject.\n     *\n     * The key is formed by removing the <code>\"get\"</code> or <code>\"is\"</code>\n     * prefix. If the second remaining character is not upper case, then the\n     * first character is converted to lower case.\n     *\n     * For example, if an object has a method named <code>\"getName\"</code>, and\n     * if the result of calling <code>object.getName()</code> is\n     * <code>\"Larry Fine\"</code>, then the JSONObject will contain\n     * <code>\"name\": \"Larry Fine\"</code>.\n     *\n     * @param bean\n     *            An object that has getter methods that should be used to make\n     *            a JSONObject.\n     */\n    public JSONObject(Object bean) {\n        this();\n        this.populateMap(bean);\n    }\n\n    /**\n     * Construct a JSONObject from an Object, using reflection to find the\n     * public members. The resulting JSONObject's keys will be the strings from\n     * the names array, and the values will be the field values associated with\n     * those keys in the object. If a key is not found or not visible, then it\n     * will not be copied into the new JSONObject.\n     *\n     * @param object\n     *            An object that has fields that should be used to make a\n     *            JSONObject.\n     * @param names\n     *            An array of strings, the names of the fields to be obtained\n     *            from the object.\n     */\n    public JSONObject(Object object, String names[]) {\n        this();\n        @SuppressWarnings(\"rawtypes\")\n\t\tClass c = object.getClass();\n        for (int i = 0; i < names.length; i += 1) {\n            String name = names[i];\n            try {\n                this.putOpt(name, c.getField(name).get(object));\n            } catch (Exception ignore) {\n            }\n        }\n    }\n\n    /**\n     * Construct a JSONObject from a source JSON text string. This is the most\n     * commonly used JSONObject constructor.\n     *\n     * @param source\n     *            A string beginning with <code>{</code>&nbsp;<small>(left\n     *            brace)</small> and ending with <code>}</code>\n     *            &nbsp;<small>(right brace)</small>.\n     * @exception JSONException\n     *                If there is a syntax error in the source string or a\n     *                duplicated key.\n     */\n    public JSONObject(String source) throws JSONException {\n        this(new JSONTokener(source));\n    }\n\n    /**\n     * Construct a JSONObject from a ResourceBundle.\n     *\n     * @param baseName\n     *            The ResourceBundle base name.\n     * @param locale\n     *            The Locale to load the ResourceBundle for.\n     * @throws JSONException\n     *             If any JSONExceptions are detected.\n     */\n    public JSONObject(String baseName, Locale locale) throws JSONException {\n        this();\n        ResourceBundle bundle = ResourceBundle.getBundle(baseName, locale,\n                Thread.currentThread().getContextClassLoader());\n\n// Iterate through the keys in the bundle.\n\n        Enumeration<String> keys = bundle.getKeys();\n        while (keys.hasMoreElements()) {\n            Object key = keys.nextElement();\n            if (key != null) {\n\n// Go through the path, ensuring that there is a nested JSONObject for each\n// segment except the last. Add the value using the last segment's name into\n// the deepest nested JSONObject.\n\n                String[] path = ((String) key).split(\"\\\\.\");\n                int last = path.length - 1;\n                JSONObject target = this;\n                for (int i = 0; i < last; i += 1) {\n                    String segment = path[i];\n                    JSONObject nextTarget = target.optJSONObject(segment);\n                    if (nextTarget == null) {\n                        nextTarget = new JSONObject();\n                        target.put(segment, nextTarget);\n                    }\n                    target = nextTarget;\n                }\n                target.put(path[last], bundle.getString((String) key));\n            }\n        }\n    }\n\n    /**\n     * Accumulate values under a key. It is similar to the put method except\n     * that if there is already an object stored under the key then a JSONArray\n     * is stored under the key to hold all of the accumulated values. If there\n     * is already a JSONArray, then the new value is appended to it. In\n     * contrast, the put method replaces the previous value.\n     *\n     * If only one value is accumulated that is not a JSONArray, then the result\n     * will be the same as using put. But if multiple values are accumulated,\n     * then the result will be like append.\n     *\n     * @param key\n     *            A key string.\n     * @param value\n     *            An object to be accumulated under the key.\n     * @return this.\n     * @throws JSONException\n     *             If the value is an invalid number or if the key is null.\n     */\n    public JSONObject accumulate(String key, Object value) throws JSONException {\n        testValidity(value);\n        Object object = this.opt(key);\n        if (object == null) {\n            this.put(key,\n                    value instanceof JSONArray ? new JSONArray().put(value)\n                            : value);\n        } else if (object instanceof JSONArray) {\n            ((JSONArray) object).put(value);\n        } else {\n            this.put(key, new JSONArray().put(object).put(value));\n        }\n        return this;\n    }\n\n    /**\n     * Append values to the array under a key. If the key does not exist in the\n     * JSONObject, then the key is put in the JSONObject with its value being a\n     * JSONArray containing the value parameter. If the key was already\n     * associated with a JSONArray, then the value parameter is appended to it.\n     *\n     * @param key\n     *            A key string.\n     * @param value\n     *            An object to be accumulated under the key.\n     * @return this.\n     * @throws JSONException\n     *             If the key is null or if the current value associated with\n     *             the key is not a JSONArray.\n     */\n    public JSONObject append(String key, Object value) throws JSONException {\n        testValidity(value);\n        Object object = this.opt(key);\n        if (object == null) {\n            this.put(key, new JSONArray().put(value));\n        } else if (object instanceof JSONArray) {\n            this.put(key, ((JSONArray) object).put(value));\n        } else {\n            throw new JSONException(\"JSONObject[\" + key\n                    + \"] is not a JSONArray.\");\n        }\n        return this;\n    }\n\n    /**\n     * Produce a string from a double. The string \"null\" will be returned if the\n     * number is not finite.\n     *\n     * @param d\n     *            A double.\n     * @return A String.\n     */\n    public static String doubleToString(double d) {\n        if (Double.isInfinite(d) || Double.isNaN(d)) {\n            return \"null\";\n        }\n\n// Shave off trailing zeros and decimal point, if possible.\n\n        String string = Double.toString(d);\n        if (string.indexOf('.') > 0 && string.indexOf('e') < 0\n                && string.indexOf('E') < 0) {\n            while (string.endsWith(\"0\")) {\n                string = string.substring(0, string.length() - 1);\n            }\n            if (string.endsWith(\".\")) {\n                string = string.substring(0, string.length() - 1);\n            }\n        }\n        return string;\n    }\n\n    /**\n     * Get the value object associated with a key.\n     *\n     * @param key\n     *            A key string.\n     * @return The object associated with the key.\n     * @throws JSONException\n     *             if the key is not found.\n     */\n    public Object get(String key) throws JSONException {\n        if (key == null) {\n            throw new JSONException(\"Null key.\");\n        }\n        Object object = this.opt(key);\n        if (object == null) {\n            throw new JSONException(\"JSONObject[\" + quote(key) + \"] not found.\");\n        }\n        return object;\n    }\n\n    /**\n     * Get the boolean value associated with a key.\n     *\n     * @param key\n     *            A key string.\n     * @return The truth.\n     * @throws JSONException\n     *             if the value is not a Boolean or the String \"true\" or\n     *             \"false\".\n     */\n    public boolean getBoolean(String key) throws JSONException {\n        Object object = this.get(key);\n        if (object.equals(Boolean.FALSE)\n                || (object instanceof String && ((String) object)\n                        .equalsIgnoreCase(\"false\"))) {\n            return false;\n        } else if (object.equals(Boolean.TRUE)\n                || (object instanceof String && ((String) object)\n                        .equalsIgnoreCase(\"true\"))) {\n            return true;\n        }\n        throw new JSONException(\"JSONObject[\" + quote(key)\n                + \"] is not a Boolean.\");\n    }\n\n    /**\n     * Get the double value associated with a key.\n     *\n     * @param key\n     *            A key string.\n     * @return The numeric value.\n     * @throws JSONException\n     *             if the key is not found or if the value is not a Number\n     *             object and cannot be converted to a number.\n     */\n    public double getDouble(String key) throws JSONException {\n        Object object = this.get(key);\n        try {\n            return object instanceof Number ? ((Number) object).doubleValue()\n                    : Double.parseDouble((String) object);\n        } catch (Exception e) {\n            throw new JSONException(\"JSONObject[\" + quote(key)\n                    + \"] is not a number.\");\n        }\n    }\n\n    /**\n     * Get the int value associated with a key.\n     *\n     * @param key\n     *            A key string.\n     * @return The integer value.\n     * @throws JSONException\n     *             if the key is not found or if the value cannot be converted\n     *             to an integer.\n     */\n    public int getInt(String key) throws JSONException {\n        Object object = this.get(key);\n        try {\n            return object instanceof Number ? ((Number) object).intValue()\n                    : Integer.parseInt((String) object);\n        } catch (Exception e) {\n            throw new JSONException(\"JSONObject[\" + quote(key)\n                    + \"] is not an int.\");\n        }\n    }\n\n    /**\n     * Get the JSONArray value associated with a key.\n     *\n     * @param key\n     *            A key string.\n     * @return A JSONArray which is the value.\n     * @throws JSONException\n     *             if the key is not found or if the value is not a JSONArray.\n     */\n    public JSONArray getJSONArray(String key) throws JSONException {\n        Object object = this.get(key);\n        if (object instanceof JSONArray) {\n            return (JSONArray) object;\n        }\n        throw new JSONException(\"JSONObject[\" + quote(key)\n                + \"] is not a JSONArray.\");\n    }\n\n    /**\n     * Get the JSONObject value associated with a key.\n     *\n     * @param key\n     *            A key string.\n     * @return A JSONObject which is the value.\n     * @throws JSONException\n     *             if the key is not found or if the value is not a JSONObject.\n     */\n    public JSONObject getJSONObject(String key) throws JSONException {\n        Object object = this.get(key);\n        if (object instanceof JSONObject) {\n            return (JSONObject) object;\n        }\n        throw new JSONException(\"JSONObject[\" + quote(key)\n                + \"] is not a JSONObject.\");\n    }\n\n    /**\n     * Get the long value associated with a key.\n     *\n     * @param key\n     *            A key string.\n     * @return The long value.\n     * @throws JSONException\n     *             if the key is not found or if the value cannot be converted\n     *             to a long.\n     */\n    public long getLong(String key) throws JSONException {\n        Object object = this.get(key);\n        try {\n            return object instanceof Number ? ((Number) object).longValue()\n                    : Long.parseLong((String) object);\n        } catch (Exception e) {\n            throw new JSONException(\"JSONObject[\" + quote(key)\n                    + \"] is not a long.\");\n        }\n    }\n\n    /**\n     * Get an array of field names from a JSONObject.\n     *\n     * @return An array of field names, or null if there are no names.\n     */\n    public static String[] getNames(JSONObject jo) {\n        int length = jo.length();\n        if (length == 0) {\n            return null;\n        }\n        Iterator<String> iterator = jo.keys();\n        String[] names = new String[length];\n        int i = 0;\n        while (iterator.hasNext()) {\n            names[i] = iterator.next();\n            i += 1;\n        }\n        return names;\n    }\n\n    /**\n     * Get an array of field names from an Object.\n     *\n     * @return An array of field names, or null if there are no names.\n     */\n    public static String[] getNames(Object object) {\n        if (object == null) {\n            return null;\n        }\n        @SuppressWarnings(\"rawtypes\")\n\t\tClass klass = object.getClass();\n        Field[] fields = klass.getFields();\n        int length = fields.length;\n        if (length == 0) {\n            return null;\n        }\n        String[] names = new String[length];\n        for (int i = 0; i < length; i += 1) {\n            names[i] = fields[i].getName();\n        }\n        return names;\n    }\n\n    /**\n     * Get the string associated with a key.\n     *\n     * @param key\n     *            A key string.\n     * @return A string which is the value.\n     * @throws JSONException\n     *             if there is no string value for the key.\n     */\n    public String getString(String key) throws JSONException {\n        Object object = this.get(key);\n        if (object instanceof String) {\n            return (String) object;\n        }\n        throw new JSONException(\"JSONObject[\" + quote(key) + \"] not a string.\");\n    }\n\n    /**\n     * Determine if the JSONObject contains a specific key.\n     *\n     * @param key\n     *            A key string.\n     * @return true if the key exists in the JSONObject.\n     */\n    public boolean has(String key) {\n        return this.map.containsKey(key);\n    }\n\n    /**\n     * Increment a property of a JSONObject. If there is no such property,\n     * create one with a value of 1. If there is such a property, and if it is\n     * an Integer, Long, Double, or Float, then add one to it.\n     *\n     * @param key\n     *            A key string.\n     * @return this.\n     * @throws JSONException\n     *             If there is already a property with this name that is not an\n     *             Integer, Long, Double, or Float.\n     */\n    public JSONObject increment(String key) throws JSONException {\n        Object value = this.opt(key);\n        if (value == null) {\n            this.put(key, 1);\n        } else if (value instanceof Integer) {\n            this.put(key, (Integer) value + 1);\n        } else if (value instanceof Long) {\n            this.put(key, (Long) value + 1);\n        } else if (value instanceof Double) {\n            this.put(key, (Double) value + 1);\n        } else if (value instanceof Float) {\n            this.put(key, (Float) value + 1);\n        } else {\n            throw new JSONException(\"Unable to increment [\" + quote(key) + \"].\");\n        }\n        return this;\n    }\n\n    /**\n     * Determine if the value associated with the key is null or if there is no\n     * value.\n     *\n     * @param key\n     *            A key string.\n     * @return true if there is no value associated with the key or if the value\n     *         is the JSONObject.NULL object.\n     */\n    public boolean isNull(String key) {\n        return JSONObject.NULL.equals(this.opt(key));\n    }\n\n    /**\n     * Get an enumeration of the keys of the JSONObject.\n     *\n     * @return An iterator of the keys.\n     */\n    public Iterator<String> keys() {\n        return this.keySet().iterator();\n    }\n\n    /**\n     * Get a set of keys of the JSONObject.\n     *\n     * @return A keySet.\n     */\n    public Set<String> keySet() {\n        return this.map.keySet();\n    }\n\n    /**\n     * Get the number of keys stored in the JSONObject.\n     *\n     * @return The number of keys in the JSONObject.\n     */\n    public int length() {\n        return this.map.size();\n    }\n\n    /**\n     * Produce a JSONArray containing the names of the elements of this\n     * JSONObject.\n     *\n     * @return A JSONArray containing the key strings, or null if the JSONObject\n     *         is empty.\n     */\n    public JSONArray names() {\n        JSONArray ja = new JSONArray();\n        Iterator<String> keys = this.keys();\n        while (keys.hasNext()) {\n            ja.put(keys.next());\n        }\n        return ja.length() == 0 ? null : ja;\n    }\n\n    /**\n     * Produce a string from a Number.\n     *\n     * @param number\n     *            A Number\n     * @return A String.\n     * @throws JSONException\n     *             If n is a non-finite number.\n     */\n    public static String numberToString(Number number) throws JSONException {\n        if (number == null) {\n            throw new JSONException(\"Null pointer\");\n        }\n        testValidity(number);\n\n// Shave off trailing zeros and decimal point, if possible.\n\n        String string = number.toString();\n        if (string.indexOf('.') > 0 && string.indexOf('e') < 0\n                && string.indexOf('E') < 0) {\n            while (string.endsWith(\"0\")) {\n                string = string.substring(0, string.length() - 1);\n            }\n            if (string.endsWith(\".\")) {\n                string = string.substring(0, string.length() - 1);\n            }\n        }\n        return string;\n    }\n\n    /**\n     * Get an optional value associated with a key.\n     *\n     * @param key\n     *            A key string.\n     * @return An object which is the value, or null if there is no value.\n     */\n    public Object opt(String key) {\n        return key == null ? null : this.map.get(key);\n    }\n\n    /**\n     * Get an optional boolean associated with a key. It returns false if there\n     * is no such key, or if the value is not Boolean.TRUE or the String \"true\".\n     *\n     * @param key\n     *            A key string.\n     * @return The truth.\n     */\n    public boolean optBoolean(String key) {\n        return this.optBoolean(key, false);\n    }\n\n    /**\n     * Get an optional boolean associated with a key. It returns the\n     * defaultValue if there is no such key, or if it is not a Boolean or the\n     * String \"true\" or \"false\" (case insensitive).\n     *\n     * @param key\n     *            A key string.\n     * @param defaultValue\n     *            The default.\n     * @return The truth.\n     */\n    public boolean optBoolean(String key, boolean defaultValue) {\n        try {\n            return this.getBoolean(key);\n        } catch (Exception e) {\n            return defaultValue;\n        }\n    }\n\n    /**\n     * Get an optional double associated with a key, or NaN if there is no such\n     * key or if its value is not a number. If the value is a string, an attempt\n     * will be made to evaluate it as a number.\n     *\n     * @param key\n     *            A string which is the key.\n     * @return An object which is the value.\n     */\n    public double optDouble(String key) {\n        return this.optDouble(key, Double.NaN);\n    }\n\n    /**\n     * Get an optional double associated with a key, or the defaultValue if\n     * there is no such key or if its value is not a number. If the value is a\n     * string, an attempt will be made to evaluate it as a number.\n     *\n     * @param key\n     *            A key string.\n     * @param defaultValue\n     *            The default.\n     * @return An object which is the value.\n     */\n    public double optDouble(String key, double defaultValue) {\n        try {\n            return this.getDouble(key);\n        } catch (Exception e) {\n            return defaultValue;\n        }\n    }\n\n    /**\n     * Get an optional int value associated with a key, or zero if there is no\n     * such key or if the value is not a number. If the value is a string, an\n     * attempt will be made to evaluate it as a number.\n     *\n     * @param key\n     *            A key string.\n     * @return An object which is the value.\n     */\n    public int optInt(String key) {\n        return this.optInt(key, 0);\n    }\n\n    /**\n     * Get an optional int value associated with a key, or the default if there\n     * is no such key or if the value is not a number. If the value is a string,\n     * an attempt will be made to evaluate it as a number.\n     *\n     * @param key\n     *            A key string.\n     * @param defaultValue\n     *            The default.\n     * @return An object which is the value.\n     */\n    public int optInt(String key, int defaultValue) {\n        try {\n            return this.getInt(key);\n        } catch (Exception e) {\n            return defaultValue;\n        }\n    }\n\n    /**\n     * Get an optional JSONArray associated with a key. It returns null if there\n     * is no such key, or if its value is not a JSONArray.\n     *\n     * @param key\n     *            A key string.\n     * @return A JSONArray which is the value.\n     */\n    public JSONArray optJSONArray(String key) {\n        Object o = this.opt(key);\n        return o instanceof JSONArray ? (JSONArray) o : null;\n    }\n\n    /**\n     * Get an optional JSONObject associated with a key. It returns null if\n     * there is no such key, or if its value is not a JSONObject.\n     *\n     * @param key\n     *            A key string.\n     * @return A JSONObject which is the value.\n     */\n    public JSONObject optJSONObject(String key) {\n        Object object = this.opt(key);\n        return object instanceof JSONObject ? (JSONObject) object : null;\n    }\n\n    /**\n     * Get an optional long value associated with a key, or zero if there is no\n     * such key or if the value is not a number. If the value is a string, an\n     * attempt will be made to evaluate it as a number.\n     *\n     * @param key\n     *            A key string.\n     * @return An object which is the value.\n     */\n    public long optLong(String key) {\n        return this.optLong(key, 0);\n    }\n\n    /**\n     * Get an optional long value associated with a key, or the default if there\n     * is no such key or if the value is not a number. If the value is a string,\n     * an attempt will be made to evaluate it as a number.\n     *\n     * @param key\n     *            A key string.\n     * @param defaultValue\n     *            The default.\n     * @return An object which is the value.\n     */\n    public long optLong(String key, long defaultValue) {\n        try {\n            return this.getLong(key);\n        } catch (Exception e) {\n            return defaultValue;\n        }\n    }\n\n    /**\n     * Get an optional string associated with a key. It returns an empty string\n     * if there is no such key. If the value is not a string and is not null,\n     * then it is converted to a string.\n     *\n     * @param key\n     *            A key string.\n     * @return A string which is the value.\n     */\n    public String optString(String key) {\n        return this.optString(key, \"\");\n    }\n\n    /**\n     * Get an optional string associated with a key. It returns the defaultValue\n     * if there is no such key.\n     *\n     * @param key\n     *            A key string.\n     * @param defaultValue\n     *            The default.\n     * @return A string which is the value.\n     */\n    public String optString(String key, String defaultValue) {\n        Object object = this.opt(key);\n        return NULL.equals(object) ? defaultValue : object.toString();\n    }\n\n    private void populateMap(Object bean) {\n        @SuppressWarnings(\"rawtypes\")\n\t\tClass klass = bean.getClass();\n\n// If klass is a System class then set includeSuperClass to false.\n\n        boolean includeSuperClass = klass.getClassLoader() != null;\n\n        Method[] methods = includeSuperClass ? klass.getMethods() : klass\n                .getDeclaredMethods();\n        for (int i = 0; i < methods.length; i += 1) {\n            try {\n                Method method = methods[i];\n                if (Modifier.isPublic(method.getModifiers())) {\n                    String name = method.getName();\n                    String key = \"\";\n                    if (name.startsWith(\"get\")) {\n                        if (\"getClass\".equals(name)\n                                || \"getDeclaringClass\".equals(name)) {\n                            key = \"\";\n                        } else {\n                            key = name.substring(3);\n                        }\n                    } else if (name.startsWith(\"is\")) {\n                        key = name.substring(2);\n                    }\n                    if (key.length() > 0\n                            && Character.isUpperCase(key.charAt(0))\n                            && method.getParameterTypes().length == 0) {\n                        if (key.length() == 1) {\n                            key = key.toLowerCase();\n                        } else if (!Character.isUpperCase(key.charAt(1))) {\n                            key = key.substring(0, 1).toLowerCase()\n                                    + key.substring(1);\n                        }\n\n                        Object result = method.invoke(bean, (Object[]) null);\n                        if (result != null) {\n                            this.map.put(key, wrap(result));\n                        }\n                    }\n                }\n            } catch (Exception ignore) {\n            }\n        }\n    }\n\n    /**\n     * Put a key/boolean pair in the JSONObject.\n     *\n     * @param key\n     *            A key string.\n     * @param value\n     *            A boolean which is the value.\n     * @return this.\n     * @throws JSONException\n     *             If the key is null.\n     */\n    public JSONObject put(String key, boolean value) throws JSONException {\n        this.put(key, value ? Boolean.TRUE : Boolean.FALSE);\n        return this;\n    }\n\n    /**\n     * Put a key/value pair in the JSONObject, where the value will be a\n     * JSONArray which is produced from a Collection.\n     *\n     * @param key\n     *            A key string.\n     * @param value\n     *            A Collection value.\n     * @return this.\n     * @throws JSONException\n     */\n    public JSONObject put(String key, Collection<Object> value) throws JSONException {\n        this.put(key, new JSONArray(value));\n        return this;\n    }\n\n    /**\n     * Put a key/double pair in the JSONObject.\n     *\n     * @param key\n     *            A key string.\n     * @param value\n     *            A double which is the value.\n     * @return this.\n     * @throws JSONException\n     *             If the key is null or if the number is invalid.\n     */\n    public JSONObject put(String key, double value) throws JSONException {\n        this.put(key, new Double(value));\n        return this;\n    }\n\n    /**\n     * Put a key/int pair in the JSONObject.\n     *\n     * @param key\n     *            A key string.\n     * @param value\n     *            An int which is the value.\n     * @return this.\n     * @throws JSONException\n     *             If the key is null.\n     */\n    public JSONObject put(String key, int value) throws JSONException {\n        this.put(key, new Integer(value));\n        return this;\n    }\n\n    /**\n     * Put a key/long pair in the JSONObject.\n     *\n     * @param key\n     *            A key string.\n     * @param value\n     *            A long which is the value.\n     * @return this.\n     * @throws JSONException\n     *             If the key is null.\n     */\n    public JSONObject put(String key, long value) throws JSONException {\n        this.put(key, new Long(value));\n        return this;\n    }\n\n    /**\n     * Put a key/value pair in the JSONObject, where the value will be a\n     * JSONObject which is produced from a Map.\n     *\n     * @param key\n     *            A key string.\n     * @param value\n     *            A Map value.\n     * @return this.\n     * @throws JSONException\n     */\n    public JSONObject put(String key, Map<String, Object> value) throws JSONException {\n        this.put(key, new JSONObject(value));\n        return this;\n    }\n\n    /**\n     * Put a key/value pair in the JSONObject. If the value is null, then the\n     * key will be removed from the JSONObject if it is present.\n     *\n     * @param key\n     *            A key string.\n     * @param value\n     *            An object which is the value. It should be of one of these\n     *            types: Boolean, Double, Integer, JSONArray, JSONObject, Long,\n     *            String, or the JSONObject.NULL object.\n     * @return this.\n     * @throws JSONException\n     *             If the value is non-finite number or if the key is null.\n     */\n    public JSONObject put(String key, Object value) throws JSONException {\n        if (key == null) {\n            throw new NullPointerException(\"Null key.\");\n        }\n        if (value != null) {\n            testValidity(value);\n            this.map.put(key, value);\n        } else {\n            this.remove(key);\n        }\n        return this;\n    }\n\n    /**\n     * Put a key/value pair in the JSONObject, but only if the key and the value\n     * are both non-null, and only if there is not already a member with that\n     * name.\n     *\n     * @param key string\n     * @param value object\n     * @return this.\n     * @throws JSONException\n     *             if the key is a duplicate\n     */\n    public JSONObject putOnce(String key, Object value) throws JSONException {\n        if (key != null && value != null) {\n            if (this.opt(key) != null) {\n                throw new JSONException(\"Duplicate key \\\"\" + key + \"\\\"\");\n            }\n            this.put(key, value);\n        }\n        return this;\n    }\n\n    /**\n     * Put a key/value pair in the JSONObject, but only if the key and the value\n     * are both non-null.\n     *\n     * @param key\n     *            A key string.\n     * @param value\n     *            An object which is the value. It should be of one of these\n     *            types: Boolean, Double, Integer, JSONArray, JSONObject, Long,\n     *            String, or the JSONObject.NULL object.\n     * @return this.\n     * @throws JSONException\n     *             If the value is a non-finite number.\n     */\n    public JSONObject putOpt(String key, Object value) throws JSONException {\n        if (key != null && value != null) {\n            this.put(key, value);\n        }\n        return this;\n    }\n\n    /**\n     * Produce a string in double quotes with backslash sequences in all the\n     * right places. A backslash will be inserted within </, producing <\\/,\n     * allowing JSON text to be delivered in HTML. In JSON text, a string cannot\n     * contain a control character or an unescaped quote or backslash.\n     *\n     * @param string\n     *            A String\n     * @return A String correctly formatted for insertion in a JSON text.\n     */\n    public static String quote(String string) {\n        StringWriter sw = new StringWriter();\n        synchronized (sw.getBuffer()) {\n            try {\n                return quote(string, sw).toString();\n            } catch (IOException ignored) {\n                // will never happen - we are writing to a string writer\n                return \"\";\n            }\n        }\n    }\n\n    public static Writer quote(String string, Writer w) throws IOException {\n        if (string == null || string.length() == 0) {\n            w.write(\"\\\"\\\"\");\n            return w;\n        }\n\n        char b;\n        char c = 0;\n        String hhhh;\n        int i;\n        int len = string.length();\n\n        w.write('\"');\n        for (i = 0; i < len; i += 1) {\n            b = c;\n            c = string.charAt(i);\n            switch (c) {\n            case '\\\\':\n            case '\"':\n                w.write('\\\\');\n                w.write(c);\n                break;\n            case '/':\n                if (b == '<') {\n                    w.write('\\\\');\n                }\n                w.write(c);\n                break;\n            case '\\b':\n                w.write(\"\\\\b\");\n                break;\n            case '\\t':\n                w.write(\"\\\\t\");\n                break;\n            case '\\n':\n                w.write(\"\\\\n\");\n                break;\n            case '\\f':\n                w.write(\"\\\\f\");\n                break;\n            case '\\r':\n                w.write(\"\\\\r\");\n                break;\n            default:\n                if (c < ' ' || (c >= '\\u0080' && c < '\\u00a0')\n                        || (c >= '\\u2000' && c < '\\u2100')) {\n                    w.write(\"\\\\u\");\n                    hhhh = Integer.toHexString(c);\n                    w.write(\"0000\", 0, 4 - hhhh.length());\n                    w.write(hhhh);\n                } else {\n                    w.write(c);\n                }\n            }\n        }\n        w.write('\"');\n        return w;\n    }\n\n    /**\n     * Remove a name and its value, if present.\n     *\n     * @param key\n     *            The name to be removed.\n     * @return The value that was associated with the name, or null if there was\n     *         no value.\n     */\n    public Object remove(String key) {\n        return this.map.remove(key);\n    }\n\n    /**\n     * Determine if two JSONObjects are similar.\n     * They must contain the same set of names which must be associated with\n     * similar values.\n     *\n     * @param other The other JSONObject\n     * @return true if they are equal\n     */\n    public boolean similar(Object other) {\n        try {\n            if (!(other instanceof JSONObject)) {\n                return false;\n            }\n            Set<String> set = this.keySet();\n            if (!set.equals(((JSONObject)other).keySet())) {\n                return false;\n            }\n            Iterator<String> iterator = set.iterator();\n            while (iterator.hasNext()) {\n                String name = iterator.next();\n                Object valueThis = this.get(name);\n                Object valueOther = ((JSONObject)other).get(name);\n                if (valueThis instanceof JSONObject) {\n                    if (!((JSONObject)valueThis).similar(valueOther)) {\n                        return false;\n                    }\n                } else if (valueThis instanceof JSONArray) {\n                    if (!((JSONArray)valueThis).similar(valueOther)) {\n                        return false;\n                    }\n                } else if (!valueThis.equals(valueOther)) {\n                    return false;\n                }\n            }\n            return true;\n        } catch (Throwable exception) {\n            return false;\n        }\n    }\n\n    /**\n     * Try to convert a string into a number, boolean, or null. If the string\n     * can't be converted, return the string.\n     *\n     * @param string\n     *            A String.\n     * @return A simple JSON value.\n     */\n    public static Object stringToValue(String string) {\n        Double d;\n        if (string.equals(\"\")) {\n            return string;\n        }\n        if (string.equalsIgnoreCase(\"true\")) {\n            return Boolean.TRUE;\n        }\n        if (string.equalsIgnoreCase(\"false\")) {\n            return Boolean.FALSE;\n        }\n        if (string.equalsIgnoreCase(\"null\")) {\n            return JSONObject.NULL;\n        }\n\n        /*\n         * If it might be a number, try converting it. If a number cannot be\n         * produced, then the value will just be a string.\n         */\n\n        char b = string.charAt(0);\n        if ((b >= '0' && b <= '9') || b == '-') {\n            try {\n                if (string.indexOf('.') > -1 || string.indexOf('e') > -1\n                        || string.indexOf('E') > -1) {\n                    d = Double.valueOf(string);\n                    if (!d.isInfinite() && !d.isNaN()) {\n                        return d;\n                    }\n                } else {\n                    Long myLong = new Long(string);\n                    if (string.equals(myLong.toString())) {\n                        if (myLong == myLong.intValue()) {\n                            return myLong.intValue();\n                        } else {\n                            return myLong;\n                        }\n                    }\n                }\n            } catch (Exception ignore) {\n            }\n        }\n        return string;\n    }\n\n    /**\n     * Throw an exception if the object is a NaN or infinite number.\n     *\n     * @param o\n     *            The object to test.\n     * @throws JSONException\n     *             If o is a non-finite number.\n     */\n    public static void testValidity(Object o) throws JSONException {\n        if (o != null) {\n            if (o instanceof Double) {\n                if (((Double) o).isInfinite() || ((Double) o).isNaN()) {\n                    throw new JSONException(\n                            \"JSON does not allow non-finite numbers.\");\n                }\n            } else if (o instanceof Float) {\n                if (((Float) o).isInfinite() || ((Float) o).isNaN()) {\n                    throw new JSONException(\n                            \"JSON does not allow non-finite numbers.\");\n                }\n            }\n        }\n    }\n\n    /**\n     * Produce a JSONArray containing the values of the members of this\n     * JSONObject.\n     *\n     * @param names\n     *            A JSONArray containing a list of key strings. This determines\n     *            the sequence of the values in the result.\n     * @return A JSONArray of values.\n     * @throws JSONException\n     *             If any of the values are non-finite numbers.\n     */\n    public JSONArray toJSONArray(JSONArray names) throws JSONException {\n        if (names == null || names.length() == 0) {\n            return null;\n        }\n        JSONArray ja = new JSONArray();\n        for (int i = 0; i < names.length(); i += 1) {\n            ja.put(this.opt(names.getString(i)));\n        }\n        return ja;\n    }\n\n    /**\n     * Make a JSON text of this JSONObject. For compactness, no whitespace is\n     * added. If this would not result in a syntactically correct JSON text,\n     * then null will be returned instead.\n     * <p>\n     * Warning: This method assumes that the data structure is acyclical.\n     *\n     * @return a printable, displayable, portable, transmittable representation\n     *         of the object, beginning with <code>{</code>&nbsp;<small>(left\n     *         brace)</small> and ending with <code>}</code>&nbsp;<small>(right\n     *         brace)</small>.\n     */\n    public String toString() {\n        try {\n            return this.toString(0);\n        } catch (Exception e) {\n            return null;\n        }\n    }\n\n    /**\n     * Make a prettyprinted JSON text of this JSONObject.\n     * <p>\n     * Warning: This method assumes that the data structure is acyclical.\n     *\n     * @param indentFactor\n     *            The number of spaces to add to each level of indentation.\n     * @return a printable, displayable, portable, transmittable representation\n     *         of the object, beginning with <code>{</code>&nbsp;<small>(left\n     *         brace)</small> and ending with <code>}</code>&nbsp;<small>(right\n     *         brace)</small>.\n     * @throws JSONException\n     *             If the object contains an invalid number.\n     */\n    public String toString(int indentFactor) throws JSONException {\n        StringWriter w = new StringWriter();\n        synchronized (w.getBuffer()) {\n            return this.write(w, indentFactor, 0).toString();\n        }\n    }\n\n    /**\n     * Make a JSON text of an Object value. If the object has an\n     * value.toJSONString() method, then that method will be used to produce the\n     * JSON text. The method is required to produce a strictly conforming text.\n     * If the object does not contain a toJSONString method (which is the most\n     * common case), then a text will be produced by other means. If the value\n     * is an array or Collection, then a JSONArray will be made from it and its\n     * toJSONString method will be called. If the value is a MAP, then a\n     * JSONObject will be made from it and its toJSONString method will be\n     * called. Otherwise, the value's toString method will be called, and the\n     * result will be quoted.\n     *\n     * <p>\n     * Warning: This method assumes that the data structure is acyclical.\n     *\n     * @param value\n     *            The value to be serialized.\n     * @return a printable, displayable, transmittable representation of the\n     *         object, beginning with <code>{</code>&nbsp;<small>(left\n     *         brace)</small> and ending with <code>}</code>&nbsp;<small>(right\n     *         brace)</small>.\n     * @throws JSONException\n     *             If the value is or contains an invalid number.\n     */\n    @SuppressWarnings(\"unchecked\")\n\tpublic static String valueToString(Object value) throws JSONException {\n        if (value == null || value.equals(null)) {\n            return \"null\";\n        }\n        if (value instanceof JSONString) {\n            Object object;\n            try {\n                object = ((JSONString) value).toJSONString();\n            } catch (Exception e) {\n                throw new JSONException(e);\n            }\n            if (object instanceof String) {\n                return (String) object;\n            }\n            throw new JSONException(\"Bad value from toJSONString: \" + object);\n        }\n        if (value instanceof Number) {\n            return numberToString((Number) value);\n        }\n        if (value instanceof Boolean || value instanceof JSONObject\n                || value instanceof JSONArray) {\n            return value.toString();\n        }\n        if (value instanceof Map) {\n            return new JSONObject((Map<String, Object>)value).toString();\n        }\n        if (value instanceof Collection) {\n            return new JSONArray((Collection<Object>) value).toString();\n        }\n        if (value.getClass().isArray()) {\n            return new JSONArray(value).toString();\n        }\n        return quote(value.toString());\n    }\n\n    /**\n     * Wrap an object, if necessary. If the object is null, return the NULL\n     * object. If it is an array or collection, wrap it in a JSONArray. If it is\n     * a map, wrap it in a JSONObject. If it is a standard property (Double,\n     * String, et al) then it is already wrapped. Otherwise, if it comes from\n     * one of the java packages, turn it into a string. And if it doesn't, try\n     * to wrap it in a JSONObject. If the wrapping fails, then null is returned.\n     *\n     * @param object\n     *            The object to wrap\n     * @return The wrapped value\n     */\n    @SuppressWarnings(\"unchecked\")\n\tpublic static Object wrap(Object object) {\n        try {\n            if (object == null) {\n                return NULL;\n            }\n            if (object instanceof JSONObject || object instanceof JSONArray\n                    || NULL.equals(object) || object instanceof JSONString\n                    || object instanceof Byte || object instanceof Character\n                    || object instanceof Short || object instanceof Integer\n                    || object instanceof Long || object instanceof Boolean\n                    || object instanceof Float || object instanceof Double\n                    || object instanceof String) {\n                return object;\n            }\n\n            if (object instanceof Collection) {\n                return new JSONArray((Collection<Object>) object);\n            }\n            if (object.getClass().isArray()) {\n                return new JSONArray(object);\n            }\n            if (object instanceof Map) {\n                return new JSONObject((Map<String, Object>) object);\n            }\n            Package objectPackage = object.getClass().getPackage();\n            String objectPackageName = objectPackage != null ? objectPackage\n                    .getName() : \"\";\n            if (objectPackageName.startsWith(\"java.\")\n                    || objectPackageName.startsWith(\"javax.\")\n                    || object.getClass().getClassLoader() == null) {\n                return object.toString();\n            }\n            return new JSONObject(object);\n        } catch (Exception exception) {\n            return null;\n        }\n    }\n\n    /**\n     * Write the contents of the JSONObject as JSON text to a writer. For\n     * compactness, no whitespace is added.\n     * <p>\n     * Warning: This method assumes that the data structure is acyclical.\n     *\n     * @return The writer.\n     * @throws JSONException\n     */\n    public Writer write(Writer writer) throws JSONException {\n        return this.write(writer, 0, 0);\n    }\n\n    @SuppressWarnings(\"unchecked\")\n\tstatic final Writer writeValue(Writer writer, Object value,\n            int indentFactor, int indent) throws JSONException, IOException {\n        if (value == null || value.equals(null)) {\n            writer.write(\"null\");\n        } else if (value instanceof JSONObject) {\n            ((JSONObject) value).write(writer, indentFactor, indent);\n        } else if (value instanceof JSONArray) {\n            ((JSONArray) value).write(writer, indentFactor, indent);\n        } else if (value instanceof Map) {\n            new JSONObject((Map<String, Object>) value).write(writer, indentFactor, indent);\n        } else if (value instanceof Collection) {\n            new JSONArray((Collection<Object>) value).write(writer, indentFactor,\n                    indent);\n        } else if (value.getClass().isArray()) {\n            new JSONArray(value).write(writer, indentFactor, indent);\n        } else if (value instanceof Number) {\n            writer.write(numberToString((Number) value));\n        } else if (value instanceof Boolean) {\n            writer.write(value.toString());\n        } else if (value instanceof JSONString) {\n            Object o;\n            try {\n                o = ((JSONString) value).toJSONString();\n            } catch (Exception e) {\n                throw new JSONException(e);\n            }\n            writer.write(o != null ? o.toString() : quote(value.toString()));\n        } else {\n            quote(value.toString(), writer);\n        }\n        return writer;\n    }\n\n    static final void indent(Writer writer, int indent) throws IOException {\n        for (int i = 0; i < indent; i += 1) {\n            writer.write(' ');\n        }\n    }\n\n    /**\n     * Write the contents of the JSONObject as JSON text to a writer. For\n     * compactness, no whitespace is added.\n     * <p>\n     * Warning: This method assumes that the data structure is acyclical.\n     *\n     * @return The writer.\n     * @throws JSONException\n     */\n    Writer write(Writer writer, int indentFactor, int indent)\n            throws JSONException {\n        try {\n            boolean commanate = false;\n            final int length = this.length();\n            Iterator<String> keys = this.keys();\n            writer.write('{');\n\n            if (length == 1) {\n                Object key = keys.next();\n                writer.write(quote(key.toString()));\n                writer.write(':');\n                if (indentFactor > 0) {\n                    writer.write(' ');\n                }\n                writeValue(writer, this.map.get(key), indentFactor, indent);\n            } else if (length != 0) {\n                final int newindent = indent + indentFactor;\n                while (keys.hasNext()) {\n                    Object key = keys.next();\n                    if (commanate) {\n                        writer.write(',');\n                    }\n                    if (indentFactor > 0) {\n                        writer.write('\\n');\n                    }\n                    indent(writer, newindent);\n                    writer.write(quote(key.toString()));\n                    writer.write(':');\n                    if (indentFactor > 0) {\n                        writer.write(' ');\n                    }\n                    writeValue(writer, this.map.get(key), indentFactor, newindent);\n                    commanate = true;\n                }\n                if (indentFactor > 0) {\n                    writer.write('\\n');\n                }\n                indent(writer, indent);\n            }\n            writer.write('}');\n            return writer;\n        } catch (IOException exception) {\n            throw new JSONException(exception);\n        }\n    }\n}\n"
  },
  {
    "path": "Projects/Tools/CoreUtils/src/org/json/JSONString.java",
    "content": "package org.json;\n/**\n * The <code>JSONString</code> interface allows a <code>toJSONString()</code>\n * method so that a class can change the behavior of\n * <code>JSONObject.toString()</code>, <code>JSONArray.toString()</code>,\n * and <code>JSONWriter.value(</code>Object<code>)</code>. The\n * <code>toJSONString</code> method will be used instead of the default behavior\n * of using the Object's <code>toString()</code> method and quoting the result.\n */\npublic interface JSONString {\n    /**\n     * The <code>toJSONString</code> method allows a class to produce its own JSON\n     * serialization.\n     *\n     * @return A strictly syntactically correct JSON text.\n     */\n    public String toJSONString();\n}\n"
  },
  {
    "path": "Projects/Tools/CoreUtils/src/org/json/JSONStringer.java",
    "content": "package org.json;\r\n\r\n/*\r\nCopyright (c) 2006 JSON.org\r\n\r\nPermission is hereby granted, free of charge, to any person obtaining a copy\r\nof this software and associated documentation files (the \"Software\"), to deal\r\nin the Software without restriction, including without limitation the rights\r\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\ncopies of the Software, and to permit persons to whom the Software is\r\nfurnished to do so, subject to the following conditions:\r\n\r\nThe above copyright notice and this permission notice shall be included in all\r\ncopies or substantial portions of the Software.\r\n\r\nThe Software shall be used for Good, not Evil.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r\nSOFTWARE.\r\n*/\r\n\r\nimport java.io.StringWriter;\r\n\r\n/**\r\n * JSONStringer provides a quick and convenient way of producing JSON text.\r\n * The texts produced strictly conform to JSON syntax rules. No whitespace is\r\n * added, so the results are ready for transmission or storage. Each instance of\r\n * JSONStringer can produce one JSON text.\r\n * <p>\r\n * A JSONStringer instance provides a <code>value</code> method for appending\r\n * values to the\r\n * text, and a <code>key</code>\r\n * method for adding keys before values in objects. There are <code>array</code>\r\n * and <code>endArray</code> methods that make and bound array values, and\r\n * <code>object</code> and <code>endObject</code> methods which make and bound\r\n * object values. All of these methods return the JSONWriter instance,\r\n * permitting cascade style. For example, <pre>\r\n * myString = new JSONStringer()\r\n *     .object()\r\n *         .key(\"JSON\")\r\n *         .value(\"Hello, World!\")\r\n *     .endObject()\r\n *     .toString();</pre> which produces the string <pre>\r\n * {\"JSON\":\"Hello, World!\"}</pre>\r\n * <p>\r\n * The first method called must be <code>array</code> or <code>object</code>.\r\n * There are no methods for adding commas or colons. JSONStringer adds them for\r\n * you. Objects and arrays can be nested up to 20 levels deep.\r\n * <p>\r\n * This can sometimes be easier than using a JSONObject to build a string.\r\n * @author JSON.org\r\n * @version 2008-09-18\r\n */\r\npublic class JSONStringer extends JSONWriter {\r\n    /**\r\n     * Make a fresh JSONStringer. It can be used to build one JSON text.\r\n     */\r\n    public JSONStringer() {\r\n        super(new StringWriter());\r\n    }\r\n\r\n    /**\r\n     * Return the JSON text. This method is used to obtain the product of the\r\n     * JSONStringer instance. It will return <code>null</code> if there was a\r\n     * problem in the construction of the JSON text (such as the calls to\r\n     * <code>array</code> were not properly balanced with calls to\r\n     * <code>endArray</code>).\r\n     * @return The JSON text.\r\n     */\r\n    public String toString() {\r\n        return this.mode == 'd' ? this.writer.toString() : null;\r\n    }\r\n}\r\n"
  },
  {
    "path": "Projects/Tools/CoreUtils/src/org/json/JSONTokener.java",
    "content": "package org.json;\n\nimport java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.InputStreamReader;\nimport java.io.Reader;\nimport java.io.StringReader;\n\n/*\nCopyright (c) 2002 JSON.org\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nThe Software shall be used for Good, not Evil.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n*/\n\n/**\n * A JSONTokener takes a source string and extracts characters and tokens from\n * it. It is used by the JSONObject and JSONArray constructors to parse\n * JSON source strings.\n * @author JSON.org\n * @version 2014-05-03\n */\npublic class JSONTokener {\n\n    private long    character;\n    private boolean eof;\n    private long    index;\n    private long    line;\n    private char    previous;\n    private Reader  reader;\n    private boolean usePrevious;\n\n\n    /**\n     * Construct a JSONTokener from a Reader.\n     *\n     * @param reader     A reader.\n     */\n    public JSONTokener(Reader reader) {\n        this.reader = reader.markSupported()\n            ? reader\n            : new BufferedReader(reader);\n        this.eof = false;\n        this.usePrevious = false;\n        this.previous = 0;\n        this.index = 0;\n        this.character = 1;\n        this.line = 1;\n    }\n\n\n    /**\n     * Construct a JSONTokener from an InputStream.\n     * @param inputStream The source.\n     */\n    public JSONTokener(InputStream inputStream) throws JSONException {\n        this(new InputStreamReader(inputStream));\n    }\n\n\n    /**\n     * Construct a JSONTokener from a string.\n     *\n     * @param s     A source string.\n     */\n    public JSONTokener(String s) {\n        this(new StringReader(s));\n    }\n\n\n    /**\n     * Back up one character. This provides a sort of lookahead capability,\n     * so that you can test for a digit or letter before attempting to parse\n     * the next number or identifier.\n     */\n    public void back() throws JSONException {\n        if (this.usePrevious || this.index <= 0) {\n            throw new JSONException(\"Stepping back two steps is not supported\");\n        }\n        this.index -= 1;\n        this.character -= 1;\n        this.usePrevious = true;\n        this.eof = false;\n    }\n\n\n    /**\n     * Get the hex value of a character (base16).\n     * @param c A character between '0' and '9' or between 'A' and 'F' or\n     * between 'a' and 'f'.\n     * @return  An int between 0 and 15, or -1 if c was not a hex digit.\n     */\n    public static int dehexchar(char c) {\n        if (c >= '0' && c <= '9') {\n            return c - '0';\n        }\n        if (c >= 'A' && c <= 'F') {\n            return c - ('A' - 10);\n        }\n        if (c >= 'a' && c <= 'f') {\n            return c - ('a' - 10);\n        }\n        return -1;\n    }\n\n    public boolean end() {\n        return this.eof && !this.usePrevious;\n    }\n\n\n    /**\n     * Determine if the source string still contains characters that next()\n     * can consume.\n     * @return true if not yet at the end of the source.\n     */\n    public boolean more() throws JSONException {\n        this.next();\n        if (this.end()) {\n            return false;\n        }\n        this.back();\n        return true;\n    }\n\n\n    /**\n     * Get the next character in the source string.\n     *\n     * @return The next character, or 0 if past the end of the source string.\n     */\n    public char next() throws JSONException {\n        int c;\n        if (this.usePrevious) {\n            this.usePrevious = false;\n            c = this.previous;\n        } else {\n            try {\n                c = this.reader.read();\n            } catch (IOException exception) {\n                throw new JSONException(exception);\n            }\n\n            if (c <= 0) { // End of stream\n                this.eof = true;\n                c = 0;\n            }\n        }\n        this.index += 1;\n        if (this.previous == '\\r') {\n            this.line += 1;\n            this.character = c == '\\n' ? 0 : 1;\n        } else if (c == '\\n') {\n            this.line += 1;\n            this.character = 0;\n        } else {\n            this.character += 1;\n        }\n        this.previous = (char) c;\n        return this.previous;\n    }\n\n\n    /**\n     * Consume the next character, and check that it matches a specified\n     * character.\n     * @param c The character to match.\n     * @return The character.\n     * @throws JSONException if the character does not match.\n     */\n    public char next(char c) throws JSONException {\n        char n = this.next();\n        if (n != c) {\n            throw this.syntaxError(\"Expected '\" + c + \"' and instead saw '\" +\n                    n + \"'\");\n        }\n        return n;\n    }\n\n\n    /**\n     * Get the next n characters.\n     *\n     * @param n     The number of characters to take.\n     * @return      A string of n characters.\n     * @throws JSONException\n     *   Substring bounds error if there are not\n     *   n characters remaining in the source string.\n     */\n     public String next(int n) throws JSONException {\n         if (n == 0) {\n             return \"\";\n         }\n\n         char[] chars = new char[n];\n         int pos = 0;\n\n         while (pos < n) {\n             chars[pos] = this.next();\n             if (this.end()) {\n                 throw this.syntaxError(\"Substring bounds error\");\n             }\n             pos += 1;\n         }\n         return new String(chars);\n     }\n\n\n    /**\n     * Get the next char in the string, skipping whitespace.\n     * @throws JSONException\n     * @return  A character, or 0 if there are no more characters.\n     */\n    public char nextClean() throws JSONException {\n        for (;;) {\n            char c = this.next();\n            if (c == 0 || c > ' ') {\n                return c;\n            }\n        }\n    }\n\n\n    /**\n     * Return the characters up to the next close quote character.\n     * Backslash processing is done. The formal JSON format does not\n     * allow strings in single quotes, but an implementation is allowed to\n     * accept them.\n     * @param quote The quoting character, either\n     *      <code>\"</code>&nbsp;<small>(double quote)</small> or\n     *      <code>'</code>&nbsp;<small>(single quote)</small>.\n     * @return      A String.\n     * @throws JSONException Unterminated string.\n     */\n    public String nextString(char quote) throws JSONException {\n        char c;\n        StringBuilder sb = new StringBuilder();\n        for (;;) {\n            c = this.next();\n            switch (c) {\n            case 0:\n            case '\\n':\n            case '\\r':\n                throw this.syntaxError(\"Unterminated string\");\n            case '\\\\':\n                c = this.next();\n                switch (c) {\n                case 'b':\n                    sb.append('\\b');\n                    break;\n                case 't':\n                    sb.append('\\t');\n                    break;\n                case 'n':\n                    sb.append('\\n');\n                    break;\n                case 'f':\n                    sb.append('\\f');\n                    break;\n                case 'r':\n                    sb.append('\\r');\n                    break;\n                case 'u':\n                    sb.append((char)Integer.parseInt(this.next(4), 16));\n                    break;\n                case '\"':\n                case '\\'':\n                case '\\\\':\n                case '/':\n                    sb.append(c);\n                    break;\n                default:\n                    throw this.syntaxError(\"Illegal escape.\");\n                }\n                break;\n            default:\n                if (c == quote) {\n                    return sb.toString();\n                }\n                sb.append(c);\n            }\n        }\n    }\n\n\n    /**\n     * Get the text up but not including the specified character or the\n     * end of line, whichever comes first.\n     * @param  delimiter A delimiter character.\n     * @return   A string.\n     */\n    public String nextTo(char delimiter) throws JSONException {\n        StringBuilder sb = new StringBuilder();\n        for (;;) {\n            char c = this.next();\n            if (c == delimiter || c == 0 || c == '\\n' || c == '\\r') {\n                if (c != 0) {\n                    this.back();\n                }\n                return sb.toString().trim();\n            }\n            sb.append(c);\n        }\n    }\n\n\n    /**\n     * Get the text up but not including one of the specified delimiter\n     * characters or the end of line, whichever comes first.\n     * @param delimiters A set of delimiter characters.\n     * @return A string, trimmed.\n     */\n    public String nextTo(String delimiters) throws JSONException {\n        char c;\n        StringBuilder sb = new StringBuilder();\n        for (;;) {\n            c = this.next();\n            if (delimiters.indexOf(c) >= 0 || c == 0 ||\n                    c == '\\n' || c == '\\r') {\n                if (c != 0) {\n                    this.back();\n                }\n                return sb.toString().trim();\n            }\n            sb.append(c);\n        }\n    }\n\n\n    /**\n     * Get the next value. The value can be a Boolean, Double, Integer,\n     * JSONArray, JSONObject, Long, or String, or the JSONObject.NULL object.\n     * @throws JSONException If syntax error.\n     *\n     * @return An object.\n     */\n    public Object nextValue() throws JSONException {\n        char c = this.nextClean();\n        String string;\n\n        switch (c) {\n            case '\"':\n            case '\\'':\n                return this.nextString(c);\n            case '{':\n                this.back();\n                return new JSONObject(this);\n            case '[':\n                this.back();\n                return new JSONArray(this);\n        }\n\n        /*\n         * Handle unquoted text. This could be the values true, false, or\n         * null, or it can be a number. An implementation (such as this one)\n         * is allowed to also accept non-standard forms.\n         *\n         * Accumulate characters until we reach the end of the text or a\n         * formatting character.\n         */\n\n        StringBuilder sb = new StringBuilder();\n        while (c >= ' ' && \",:]}/\\\\\\\"[{;=#\".indexOf(c) < 0) {\n            sb.append(c);\n            c = this.next();\n        }\n        this.back();\n\n        string = sb.toString().trim();\n        if (\"\".equals(string)) {\n            throw this.syntaxError(\"Missing value\");\n        }\n        return JSONObject.stringToValue(string);\n    }\n\n\n    /**\n     * Skip characters until the next character is the requested character.\n     * If the requested character is not found, no characters are skipped.\n     * @param to A character to skip to.\n     * @return The requested character, or zero if the requested character\n     * is not found.\n     */\n    public char skipTo(char to) throws JSONException {\n        char c;\n        try {\n            long startIndex = this.index;\n            long startCharacter = this.character;\n            long startLine = this.line;\n            this.reader.mark(1000000);\n            do {\n                c = this.next();\n                if (c == 0) {\n                    this.reader.reset();\n                    this.index = startIndex;\n                    this.character = startCharacter;\n                    this.line = startLine;\n                    return c;\n                }\n            } while (c != to);\n        } catch (IOException exception) {\n            throw new JSONException(exception);\n        }\n        this.back();\n        return c;\n    }\n\n\n    /**\n     * Make a JSONException to signal a syntax error.\n     *\n     * @param message The error message.\n     * @return  A JSONException object, suitable for throwing\n     */\n    public JSONException syntaxError(String message) {\n        return new JSONException(message + this.toString());\n    }\n\n\n    /**\n     * Make a printable string of this JSONTokener.\n     *\n     * @return \" at {index} [character {character} line {line}]\"\n     */\n    public String toString() {\n        return \" at \" + this.index + \" [character \" + this.character + \" line \" +\n            this.line + \"]\";\n    }\n}\n"
  },
  {
    "path": "Projects/Tools/CoreUtils/src/org/json/JSONWriter.java",
    "content": "package org.json;\r\n\r\nimport java.io.IOException;\r\nimport java.io.Writer;\r\n\r\n/*\r\nCopyright (c) 2006 JSON.org\r\n\r\nPermission is hereby granted, free of charge, to any person obtaining a copy\r\nof this software and associated documentation files (the \"Software\"), to deal\r\nin the Software without restriction, including without limitation the rights\r\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\ncopies of the Software, and to permit persons to whom the Software is\r\nfurnished to do so, subject to the following conditions:\r\n\r\nThe above copyright notice and this permission notice shall be included in all\r\ncopies or substantial portions of the Software.\r\n\r\nThe Software shall be used for Good, not Evil.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r\nSOFTWARE.\r\n*/\r\n\r\n/**\r\n * JSONWriter provides a quick and convenient way of producing JSON text.\r\n * The texts produced strictly conform to JSON syntax rules. No whitespace is\r\n * added, so the results are ready for transmission or storage. Each instance of\r\n * JSONWriter can produce one JSON text.\r\n * <p>\r\n * A JSONWriter instance provides a <code>value</code> method for appending\r\n * values to the\r\n * text, and a <code>key</code>\r\n * method for adding keys before values in objects. There are <code>array</code>\r\n * and <code>endArray</code> methods that make and bound array values, and\r\n * <code>object</code> and <code>endObject</code> methods which make and bound\r\n * object values. All of these methods return the JSONWriter instance,\r\n * permitting a cascade style. For example, <pre>\r\n * new JSONWriter(myWriter)\r\n *     .object()\r\n *         .key(\"JSON\")\r\n *         .value(\"Hello, World!\")\r\n *     .endObject();</pre> which writes <pre>\r\n * {\"JSON\":\"Hello, World!\"}</pre>\r\n * <p>\r\n * The first method called must be <code>array</code> or <code>object</code>.\r\n * There are no methods for adding commas or colons. JSONWriter adds them for\r\n * you. Objects and arrays can be nested up to 20 levels deep.\r\n * <p>\r\n * This can sometimes be easier than using a JSONObject to build a string.\r\n * @author JSON.org\r\n * @version 2011-11-24\r\n */\r\npublic class JSONWriter {\r\n    private static final int maxdepth = 200;\r\n\r\n    /**\r\n     * The comma flag determines if a comma should be output before the next\r\n     * value.\r\n     */\r\n    private boolean comma;\r\n\r\n    /**\r\n     * The current mode. Values:\r\n     * 'a' (array),\r\n     * 'd' (done),\r\n     * 'i' (initial),\r\n     * 'k' (key),\r\n     * 'o' (object).\r\n     */\r\n    protected char mode;\r\n\r\n    /**\r\n     * The object/array stack.\r\n     */\r\n    private final JSONObject stack[];\r\n\r\n    /**\r\n     * The stack top index. A value of 0 indicates that the stack is empty.\r\n     */\r\n    private int top;\r\n\r\n    /**\r\n     * The writer that will receive the output.\r\n     */\r\n    protected Writer writer;\r\n\r\n    /**\r\n     * Make a fresh JSONWriter. It can be used to build one JSON text.\r\n     */\r\n    public JSONWriter(Writer w) {\r\n        this.comma = false;\r\n        this.mode = 'i';\r\n        this.stack = new JSONObject[maxdepth];\r\n        this.top = 0;\r\n        this.writer = w;\r\n    }\r\n\r\n    /**\r\n     * Append a value.\r\n     * @param string A string value.\r\n     * @return this\r\n     * @throws JSONException If the value is out of sequence.\r\n     */\r\n    private JSONWriter append(String string) throws JSONException {\r\n        if (string == null) {\r\n            throw new JSONException(\"Null pointer\");\r\n        }\r\n        if (this.mode == 'o' || this.mode == 'a') {\r\n            try {\r\n                if (this.comma && this.mode == 'a') {\r\n                    this.writer.write(',');\r\n                }\r\n                this.writer.write(string);\r\n            } catch (IOException e) {\r\n                throw new JSONException(e);\r\n            }\r\n            if (this.mode == 'o') {\r\n                this.mode = 'k';\r\n            }\r\n            this.comma = true;\r\n            return this;\r\n        }\r\n        throw new JSONException(\"Value out of sequence.\");\r\n    }\r\n\r\n    /**\r\n     * Begin appending a new array. All values until the balancing\r\n     * <code>endArray</code> will be appended to this array. The\r\n     * <code>endArray</code> method must be called to mark the array's end.\r\n     * @return this\r\n     * @throws JSONException If the nesting is too deep, or if the object is\r\n     * started in the wrong place (for example as a key or after the end of the\r\n     * outermost array or object).\r\n     */\r\n    public JSONWriter array() throws JSONException {\r\n        if (this.mode == 'i' || this.mode == 'o' || this.mode == 'a') {\r\n            this.push(null);\r\n            this.append(\"[\");\r\n            this.comma = false;\r\n            return this;\r\n        }\r\n        throw new JSONException(\"Misplaced array.\");\r\n    }\r\n\r\n    /**\r\n     * End something.\r\n     * @param mode Mode\r\n     * @param c Closing character\r\n     * @return this\r\n     * @throws JSONException If unbalanced.\r\n     */\r\n    private JSONWriter end(char mode, char c) throws JSONException {\r\n        if (this.mode != mode) {\r\n            throw new JSONException(mode == 'a'\r\n                ? \"Misplaced endArray.\"\r\n                : \"Misplaced endObject.\");\r\n        }\r\n        this.pop(mode);\r\n        try {\r\n            this.writer.write(c);\r\n        } catch (IOException e) {\r\n            throw new JSONException(e);\r\n        }\r\n        this.comma = true;\r\n        return this;\r\n    }\r\n\r\n    /**\r\n     * End an array. This method most be called to balance calls to\r\n     * <code>array</code>.\r\n     * @return this\r\n     * @throws JSONException If incorrectly nested.\r\n     */\r\n    public JSONWriter endArray() throws JSONException {\r\n        return this.end('a', ']');\r\n    }\r\n\r\n    /**\r\n     * End an object. This method most be called to balance calls to\r\n     * <code>object</code>.\r\n     * @return this\r\n     * @throws JSONException If incorrectly nested.\r\n     */\r\n    public JSONWriter endObject() throws JSONException {\r\n        return this.end('k', '}');\r\n    }\r\n\r\n    /**\r\n     * Append a key. The key will be associated with the next value. In an\r\n     * object, every value must be preceded by a key.\r\n     * @param string A key string.\r\n     * @return this\r\n     * @throws JSONException If the key is out of place. For example, keys\r\n     *  do not belong in arrays or if the key is null.\r\n     */\r\n    public JSONWriter key(String string) throws JSONException {\r\n        if (string == null) {\r\n            throw new JSONException(\"Null key.\");\r\n        }\r\n        if (this.mode == 'k') {\r\n            try {\r\n                this.stack[this.top - 1].putOnce(string, Boolean.TRUE);\r\n                if (this.comma) {\r\n                    this.writer.write(',');\r\n                }\r\n                this.writer.write(JSONObject.quote(string));\r\n                this.writer.write(':');\r\n                this.comma = false;\r\n                this.mode = 'o';\r\n                return this;\r\n            } catch (IOException e) {\r\n                throw new JSONException(e);\r\n            }\r\n        }\r\n        throw new JSONException(\"Misplaced key.\");\r\n    }\r\n\r\n\r\n    /**\r\n     * Begin appending a new object. All keys and values until the balancing\r\n     * <code>endObject</code> will be appended to this object. The\r\n     * <code>endObject</code> method must be called to mark the object's end.\r\n     * @return this\r\n     * @throws JSONException If the nesting is too deep, or if the object is\r\n     * started in the wrong place (for example as a key or after the end of the\r\n     * outermost array or object).\r\n     */\r\n    public JSONWriter object() throws JSONException {\r\n        if (this.mode == 'i') {\r\n            this.mode = 'o';\r\n        }\r\n        if (this.mode == 'o' || this.mode == 'a') {\r\n            this.append(\"{\");\r\n            this.push(new JSONObject());\r\n            this.comma = false;\r\n            return this;\r\n        }\r\n        throw new JSONException(\"Misplaced object.\");\r\n\r\n    }\r\n\r\n\r\n    /**\r\n     * Pop an array or object scope.\r\n     * @param c The scope to close.\r\n     * @throws JSONException If nesting is wrong.\r\n     */\r\n    private void pop(char c) throws JSONException {\r\n        if (this.top <= 0) {\r\n            throw new JSONException(\"Nesting error.\");\r\n        }\r\n        char m = this.stack[this.top - 1] == null ? 'a' : 'k';\r\n        if (m != c) {\r\n            throw new JSONException(\"Nesting error.\");\r\n        }\r\n        this.top -= 1;\r\n        this.mode = this.top == 0\r\n            ? 'd'\r\n            : this.stack[this.top - 1] == null\r\n            ? 'a'\r\n            : 'k';\r\n    }\r\n\r\n    /**\r\n     * Push an array or object scope.\r\n     * @param jo The scope to open.\r\n     * @throws JSONException If nesting is too deep.\r\n     */\r\n    private void push(JSONObject jo) throws JSONException {\r\n        if (this.top >= maxdepth) {\r\n            throw new JSONException(\"Nesting too deep.\");\r\n        }\r\n        this.stack[this.top] = jo;\r\n        this.mode = jo == null ? 'a' : 'k';\r\n        this.top += 1;\r\n    }\r\n\r\n\r\n    /**\r\n     * Append either the value <code>true</code> or the value\r\n     * <code>false</code>.\r\n     * @param b A boolean.\r\n     * @return this\r\n     * @throws JSONException\r\n     */\r\n    public JSONWriter value(boolean b) throws JSONException {\r\n        return this.append(b ? \"true\" : \"false\");\r\n    }\r\n\r\n    /**\r\n     * Append a double value.\r\n     * @param d A double.\r\n     * @return this\r\n     * @throws JSONException If the number is not finite.\r\n     */\r\n    public JSONWriter value(double d) throws JSONException {\r\n        return this.value(new Double(d));\r\n    }\r\n\r\n    /**\r\n     * Append a long value.\r\n     * @param l A long.\r\n     * @return this\r\n     * @throws JSONException\r\n     */\r\n    public JSONWriter value(long l) throws JSONException {\r\n        return this.append(Long.toString(l));\r\n    }\r\n\r\n\r\n    /**\r\n     * Append an object value.\r\n     * @param object The object to append. It can be null, or a Boolean, Number,\r\n     *   String, JSONObject, or JSONArray, or an object that implements JSONString.\r\n     * @return this\r\n     * @throws JSONException If the value is out of sequence.\r\n     */\r\n    public JSONWriter value(Object object) throws JSONException {\r\n        return this.append(JSONObject.valueToString(object));\r\n    }\r\n}\r\n"
  },
  {
    "path": "Projects/Tools/PNGAlphaPremultiplier/.classpath",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<classpath>\n\t<classpathentry kind=\"src\" path=\"src\"/>\n\t<classpathentry kind=\"con\" path=\"org.eclipse.jdt.launching.JRE_CONTAINER\"/>\n\t<classpathentry combineaccessrules=\"false\" kind=\"src\" path=\"/CoreUtils\"/>\n\t<classpathentry kind=\"output\" path=\"bin\"/>\n</classpath>\n"
  },
  {
    "path": "Projects/Tools/PNGAlphaPremultiplier/.gitignore",
    "content": "/bin\n"
  },
  {
    "path": "Projects/Tools/PNGAlphaPremultiplier/.project",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<projectDescription>\n\t<name>PNGAlphaPremultiplier</name>\n\t<comment></comment>\n\t<projects>\n\t</projects>\n\t<buildSpec>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.jdt.core.javabuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t</buildSpec>\n\t<natures>\n\t\t<nature>org.eclipse.jdt.core.javanature</nature>\n\t</natures>\n</projectDescription>\n"
  },
  {
    "path": "Projects/Tools/PNGAlphaPremultiplier/Manifest/Manifest.txt",
    "content": "Manifest-Version: 1.0\r\nMain-Class: com.chilliworks.chillisource.pngalphapremultiplier.Main\r\n\r\n"
  },
  {
    "path": "Projects/Tools/PNGAlphaPremultiplier/Native/Config.mk",
    "content": "#-------------------------------------------------------------------\n# Config.mk\n# ChilliSource\n#\n# Created by Ian Copland on 15/03/2012\n# Copyright 2012 Tag Games. All rights reserved.\n#-------------------------------------------------------------------\n#-------------------------------------------------------------------\n# PROJECT_NAME\n#\n# The name of the project. This will be used as the output\n# exectable name.\n#-------------------------------------------------------------------\nPROJECT_NAME = PNGAlphaPremultiplier\n#-------------------------------------------------------------------\n# PROJECT_INCLUDE_PATHS\n#\n# A list of all the include paths used. This should be in the format\n# -I<relativepath>\n#-------------------------------------------------------------------\nPROJECT_INCLUDE_PATHS = -ISource/ -ISource/LibPng/ -ISource/ZLib/\n#-------------------------------------------------------------------\n# PROJECT_C_SOURCE_FILES\n#\n# A list of all the c sources to be built in the project.\n#-------------------------------------------------------------------\nPROJECT_C_SOURCE_FILES = Source/PNGAlphaPremultiplier.c \\\n\tSource/LibPng/png.c \\\n\tSource/LibPng/pngerror.c \\\n\tSource/LibPng/pngget.c \\\n\tSource/LibPng/pngmem.c \\\n\tSource/LibPng/pngpread.c \\\n\tSource/LibPng/pngread.c \\\n\tSource/LibPng/pngrio.c \\\n\tSource/LibPng/pngrtran.c \\\n\tSource/LibPng/pngrutil.c \\\n\tSource/LibPng/pngset.c \\\n\tSource/LibPng/pngtrans.c \\\n\tSource/LibPng/pngwio.c \\\n\tSource/LibPng/pngwrite.c \\\n\tSource/LibPng/pngwtran.c \\\n\tSource/LibPng/pngwutil.c \\\n\tSource/ZLib/adler32.c \\\n\tSource/ZLib/compress.c \\\n\tSource/ZLib/crc32.c \\\n\tSource/ZLib/deflate.c \\\n\tSource/ZLib/gzclose.c \\\n\tSource/ZLib/gzlib.c \\\n\tSource/ZLib/gzread.c \\\n\tSource/ZLib/gzwrite.c \\\n\tSource/ZLib/infback.c \\\n\tSource/ZLib/inffast.c \\\n\tSource/ZLib/inflate.c \\\n\tSource/ZLib/inftrees.c \\\n\tSource/ZLib/trees.c \\\n\tSource/ZLib/uncompr.c \\\n\tSource/ZLib/zutil.c\n#-------------------------------------------------------------------\n# PROJECT_CPP_SOURCE_FILES\n#\n# A list of all the c++ sources to be built in the project.\n#-------------------------------------------------------------------\nPROJECT_CPP_SOURCE_FILES = Source/Main.cpp \\\n\tSource/Logging.cpp \\\n\tSource/CLogging.cpp \\\n\tSource/StringUtils.cpp\n"
  },
  {
    "path": "Projects/Tools/PNGAlphaPremultiplier/Native/Makefile",
    "content": "#-------------------------------------------------------------------\n# Makefile\n# ChilliSource\n#\n# Created by Ian Copland on 14/03/2012\n# Copyright 2012 Tag Games. All rights reserved.\n#-------------------------------------------------------------------\ninclude Config.mk\n#-------------------------------------------------------------------\n# Definitions\n#-------------------------------------------------------------------\nCC\t\t\t\t= gcc\nCCXX\t\t\t= g++\nCFLAGS\t\t\t= -std=c89 -m32 -Wall -O3 -DUSE_MMAP $(PROJECT_INCLUDE_PATHS)\nCXXFLAGS\t\t= -std=c++11 -m32 -Wall -O3 -DUSE_MMAP $(PROJECT_INCLUDE_PATHS)\nLDFLAGS\t\t\t= -m32\nEXECUTABLE\t\t= $(PROJECT_NAME)\nCSOURCES\t\t= $(PROJECT_C_SOURCE_FILES)\nCXXSOURCES\t\t= $(PROJECT_CPP_SOURCE_FILES)\nCOBJECTS\t\t= $(CSOURCES:.c=.o)\nCXXOBJECTS\t\t= $(CXXSOURCES:.cpp=.o)\n#-------------------------------------------------------------------\n# All\n#\n# Builds everything. This is the default command.\n#-------------------------------------------------------------------\nall: $(EXECUTABLE)\n#-------------------------------------------------------------------\n# EXECUTABLE\n#\n# Builds the executable with the given name.\n#-------------------------------------------------------------------\n$(EXECUTABLE): $(CSOURCES) $(CXXSOURCES) $(COBJECTS) $(CXXOBJECTS)\n\t$(CCXX) $(LDFLAGS) $(COBJECTS) $(CXXOBJECTS) -o $@\n#-------------------------------------------------------------------\n# Clean\n#\n# Cleans everything.\n#-------------------------------------------------------------------\nclean:\n\trm -rf $(COBJECTS) $(CXXOBJECTS)\n#-------------------------------------------------------------------\n# .c.o\n#\n# Specifies how all c object files are built\n#-------------------------------------------------------------------\n.c.o:\n\t$(CC) $(CFLAGS) -c $< -o $@\n#-------------------------------------------------------------------\n# .cpp.o\n#\n# Specifies how all cpp object files are built\n#-------------------------------------------------------------------\n.cpp.o:\n\t$(CCXX) $(CXXFLAGS) -c $< -o $@\n"
  },
  {
    "path": "Projects/Tools/PNGAlphaPremultiplier/Native/PNGAlphaPremultiplier.sln",
    "content": "﻿\r\nMicrosoft Visual Studio Solution File, Format Version 12.00\r\n# Visual Studio Express 2013 for Windows Desktop\r\nVisualStudioVersion = 12.0.21005.1\r\nMinimumVisualStudioVersion = 10.0.40219.1\r\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"PNGAlphaPremultiplier\", \"PNGAlphaPremultiplier.vcxproj\", \"{347925E2-7E76-4B7A-A566-FA8513222004}\"\r\nEndProject\r\nGlobal\r\n\tGlobalSection(SolutionConfigurationPlatforms) = preSolution\r\n\t\tDebug|Win32 = Debug|Win32\r\n\t\tRelease|Win32 = Release|Win32\r\n\tEndGlobalSection\r\n\tGlobalSection(ProjectConfigurationPlatforms) = postSolution\r\n\t\t{347925E2-7E76-4B7A-A566-FA8513222004}.Debug|Win32.ActiveCfg = Debug|Win32\r\n\t\t{347925E2-7E76-4B7A-A566-FA8513222004}.Debug|Win32.Build.0 = Debug|Win32\r\n\t\t{347925E2-7E76-4B7A-A566-FA8513222004}.Release|Win32.ActiveCfg = Release|Win32\r\n\t\t{347925E2-7E76-4B7A-A566-FA8513222004}.Release|Win32.Build.0 = Release|Win32\r\n\tEndGlobalSection\r\n\tGlobalSection(SolutionProperties) = preSolution\r\n\t\tHideSolutionNode = FALSE\r\n\tEndGlobalSection\r\nEndGlobal\r\n"
  },
  {
    "path": "Projects/Tools/PNGAlphaPremultiplier/Native/PNGAlphaPremultiplier.vcxproj",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Project DefaultTargets=\"Build\" ToolsVersion=\"12.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\r\n  <ItemGroup Label=\"ProjectConfigurations\">\r\n    <ProjectConfiguration Include=\"Debug|Win32\">\r\n      <Configuration>Debug</Configuration>\r\n      <Platform>Win32</Platform>\r\n    </ProjectConfiguration>\r\n    <ProjectConfiguration Include=\"Release|Win32\">\r\n      <Configuration>Release</Configuration>\r\n      <Platform>Win32</Platform>\r\n    </ProjectConfiguration>\r\n  </ItemGroup>\r\n  <PropertyGroup Label=\"Globals\">\r\n    <ProjectGuid>{347925E2-7E76-4B7A-A566-FA8513222004}</ProjectGuid>\r\n    <Keyword>Win32Proj</Keyword>\r\n    <RootNamespace>PNGAlphaPremultiplier</RootNamespace>\r\n  </PropertyGroup>\r\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.Default.props\" />\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\" Label=\"Configuration\">\r\n    <ConfigurationType>Application</ConfigurationType>\r\n    <UseDebugLibraries>true</UseDebugLibraries>\r\n    <PlatformToolset>v120</PlatformToolset>\r\n    <CharacterSet>Unicode</CharacterSet>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\" Label=\"Configuration\">\r\n    <ConfigurationType>Application</ConfigurationType>\r\n    <UseDebugLibraries>false</UseDebugLibraries>\r\n    <PlatformToolset>v120</PlatformToolset>\r\n    <WholeProgramOptimization>true</WholeProgramOptimization>\r\n    <CharacterSet>Unicode</CharacterSet>\r\n  </PropertyGroup>\r\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.props\" />\r\n  <ImportGroup Label=\"ExtensionSettings\">\r\n  </ImportGroup>\r\n  <ImportGroup Label=\"PropertySheets\" Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n  </ImportGroup>\r\n  <ImportGroup Label=\"PropertySheets\" Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n  </ImportGroup>\r\n  <PropertyGroup Label=\"UserMacros\" />\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">\r\n    <LinkIncremental>true</LinkIncremental>\r\n    <IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);$(ProjectDir)Source\\LibPng;$(ProjectDir)Source\\ZLib</IncludePath>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">\r\n    <LinkIncremental>false</LinkIncremental>\r\n    <IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);$(ProjectDir)\\Source\\LibPng;$(ProjectDir)\\Source\\ZLib</IncludePath>\r\n  </PropertyGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">\r\n    <ClCompile>\r\n      <PrecompiledHeader>\r\n      </PrecompiledHeader>\r\n      <WarningLevel>Level3</WarningLevel>\r\n      <Optimization>Disabled</Optimization>\r\n      <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n    </ClCompile>\r\n    <Link>\r\n      <SubSystem>Console</SubSystem>\r\n      <GenerateDebugInformation>true</GenerateDebugInformation>\r\n    </Link>\r\n  </ItemDefinitionGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">\r\n    <ClCompile>\r\n      <WarningLevel>Level3</WarningLevel>\r\n      <PrecompiledHeader>\r\n      </PrecompiledHeader>\r\n      <Optimization>MaxSpeed</Optimization>\r\n      <FunctionLevelLinking>true</FunctionLevelLinking>\r\n      <IntrinsicFunctions>true</IntrinsicFunctions>\r\n      <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n    </ClCompile>\r\n    <Link>\r\n      <SubSystem>Console</SubSystem>\r\n      <GenerateDebugInformation>true</GenerateDebugInformation>\r\n      <EnableCOMDATFolding>true</EnableCOMDATFolding>\r\n      <OptimizeReferences>true</OptimizeReferences>\r\n    </Link>\r\n  </ItemDefinitionGroup>\r\n  <ItemGroup>\r\n    <ClCompile Include=\"Source\\CLogging.cpp\" />\r\n    <ClCompile Include=\"Source\\LibPng\\example.c\" />\r\n    <ClCompile Include=\"Source\\LibPng\\png.c\" />\r\n    <ClCompile Include=\"Source\\LibPng\\pngerror.c\" />\r\n    <ClCompile Include=\"Source\\LibPng\\pngget.c\" />\r\n    <ClCompile Include=\"Source\\LibPng\\pngmem.c\" />\r\n    <ClCompile Include=\"Source\\LibPng\\pngpread.c\" />\r\n    <ClCompile Include=\"Source\\LibPng\\pngread.c\" />\r\n    <ClCompile Include=\"Source\\LibPng\\pngrio.c\" />\r\n    <ClCompile Include=\"Source\\LibPng\\pngrtran.c\" />\r\n    <ClCompile Include=\"Source\\LibPng\\pngrutil.c\" />\r\n    <ClCompile Include=\"Source\\LibPng\\pngset.c\" />\r\n    <ClCompile Include=\"Source\\LibPng\\pngtrans.c\" />\r\n    <ClCompile Include=\"Source\\LibPng\\pngwio.c\" />\r\n    <ClCompile Include=\"Source\\LibPng\\pngwrite.c\" />\r\n    <ClCompile Include=\"Source\\LibPng\\pngwtran.c\" />\r\n    <ClCompile Include=\"Source\\LibPng\\pngwutil.c\" />\r\n    <ClCompile Include=\"Source\\Logging.cpp\" />\r\n    <ClCompile Include=\"Source\\Main.cpp\" />\r\n    <ClCompile Include=\"Source\\PNGAlphaPremultiplier.c\" />\r\n    <ClCompile Include=\"Source\\StringUtils.cpp\" />\r\n    <ClCompile Include=\"Source\\ZLib\\adler32.c\" />\r\n    <ClCompile Include=\"Source\\ZLib\\compress.c\" />\r\n    <ClCompile Include=\"Source\\ZLib\\crc32.c\" />\r\n    <ClCompile Include=\"Source\\ZLib\\deflate.c\" />\r\n    <ClCompile Include=\"Source\\ZLib\\gzclose.c\" />\r\n    <ClCompile Include=\"Source\\ZLib\\gzlib.c\" />\r\n    <ClCompile Include=\"Source\\ZLib\\gzread.c\" />\r\n    <ClCompile Include=\"Source\\ZLib\\gzwrite.c\" />\r\n    <ClCompile Include=\"Source\\ZLib\\infback.c\" />\r\n    <ClCompile Include=\"Source\\ZLib\\inffast.c\" />\r\n    <ClCompile Include=\"Source\\ZLib\\inflate.c\" />\r\n    <ClCompile Include=\"Source\\ZLib\\inftrees.c\" />\r\n    <ClCompile Include=\"Source\\ZLib\\trees.c\" />\r\n    <ClCompile Include=\"Source\\ZLib\\uncompr.c\" />\r\n    <ClCompile Include=\"Source\\ZLib\\zutil.c\" />\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <ClInclude Include=\"Source\\CLogging.h\" />\r\n    <ClInclude Include=\"Source\\LibPng\\png.h\" />\r\n    <ClInclude Include=\"Source\\LibPng\\pngconf.h\" />\r\n    <ClInclude Include=\"Source\\LibPng\\pnginfo.h\" />\r\n    <ClInclude Include=\"Source\\LibPng\\pnglibconf.h\" />\r\n    <ClInclude Include=\"Source\\LibPng\\pngpriv.h\" />\r\n    <ClInclude Include=\"Source\\LibPng\\pngstruct.h\" />\r\n    <ClInclude Include=\"Source\\Logging.h\" />\r\n    <ClInclude Include=\"Source\\PNGAlphaPremultiplier.h\" />\r\n    <ClInclude Include=\"Source\\StringUtils.h\" />\r\n    <ClInclude Include=\"Source\\ZLib\\crc32.h\" />\r\n    <ClInclude Include=\"Source\\ZLib\\deflate.h\" />\r\n    <ClInclude Include=\"Source\\ZLib\\gzguts.h\" />\r\n    <ClInclude Include=\"Source\\ZLib\\inffast.h\" />\r\n    <ClInclude Include=\"Source\\ZLib\\inffixed.h\" />\r\n    <ClInclude Include=\"Source\\ZLib\\inflate.h\" />\r\n    <ClInclude Include=\"Source\\ZLib\\inftrees.h\" />\r\n    <ClInclude Include=\"Source\\ZLib\\trees.h\" />\r\n    <ClInclude Include=\"Source\\ZLib\\zconf.h\" />\r\n    <ClInclude Include=\"Source\\ZLib\\zlib.h\" />\r\n    <ClInclude Include=\"Source\\ZLib\\zutil.h\" />\r\n  </ItemGroup>\r\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.targets\" />\r\n  <ImportGroup Label=\"ExtensionTargets\">\r\n  </ImportGroup>\r\n</Project>"
  },
  {
    "path": "Projects/Tools/PNGAlphaPremultiplier/Native/Source/CLogging.cpp",
    "content": "//\r\n//  CLogging.cpp\r\n//  ChilliSource\r\n//  Created by Ian Copland on 25/06/2014.\r\n//\r\n//  The MIT License (MIT)\r\n//\r\n//  Copyright (c) 2014 Tag Games Limited\r\n//\r\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\r\n//  of this software and associated documentation files (the \"Software\"), to deal\r\n//  in the Software without restriction, including without limitation the rights\r\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\n//  copies of the Software, and to permit persons to whom the Software is\r\n//  furnished to do so, subject to the following conditions:\r\n//\r\n//  The above copyright notice and this permission notice shall be included in\r\n//  all copies or substantial portions of the Software.\r\n//\r\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r\n//  THE SOFTWARE.\r\n//\r\n \r\n#include \"CLogging.h\"\r\n\r\n#include \"Logging.h\"\r\n \r\n//-------------------------------------------------\r\n//-------------------------------------------------\r\nvoid LogVerbose(const char* in_message)\r\n{\r\n\tLogging::LogVerbose(std::string(in_message));\r\n}\r\n//-------------------------------------------------\r\n//-------------------------------------------------\r\nvoid LogWarning(const char* in_message)\r\n{\r\n\tLogging::LogWarning(std::string(in_message));\r\n}\r\n//-------------------------------------------------\r\n//-------------------------------------------------\r\nvoid LogError(const char* in_message)\r\n{\r\n\tLogging::LogError(std::string(in_message));\r\n}\r\n//-------------------------------------------------\r\n//-------------------------------------------------\r\nvoid LogFatal(const char* in_message)\r\n{\r\n\tLogging::LogFatal(std::string(in_message));\r\n}\r\n"
  },
  {
    "path": "Projects/Tools/PNGAlphaPremultiplier/Native/Source/CLogging.h",
    "content": "/**\r\n * CLogging.h\r\n * ChilliSource\r\n * Created by Ian Copland on 25/06/2014.\r\n * \r\n * The MIT License (MIT)\r\n * \r\n * Copyright (c) 2014 Tag Games Limited\r\n * \r\n * Permission is hereby granted, free of charge, to any person obtaining a copy\r\n * of this software and associated documentation files (the \"Software\"), to deal\r\n * in the Software without restriction, including without limitation the rights\r\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\n * copies of the Software, and to permit persons to whom the Software is\r\n * furnished to do so, subject to the following conditions:\r\n * \r\n * The above copyright notice and this permission notice shall be included in\r\n * all copies or substantial portions of the Software.\r\n * \r\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r\n * THE SOFTWARE.\r\n */\r\n\r\n#ifndef _PNGALPHAPREMULTIPLIER_CLOGGING_H_\r\n#define _PNGALPHAPREMULTIPLIER_CLOGGING_H_\r\n\r\n#ifdef __cplusplus\r\nextern \"C\" \r\n{\r\n#endif \r\n\r\n/**\r\n * Provides a C interface for the Logging::LogVerbose() function.\r\n * \r\n * @author Ian Copland\r\n * \r\n * @param The message, null terminated.\r\n */\r\nvoid LogVerbose(const char* in_message);\r\n/**\r\n * Provides a C interface for the Logging::LogWarning() function.\r\n * \r\n * @author Ian Copland\r\n * \r\n * @param The message, null terminated.\r\n */\r\nvoid LogWarning(const char* in_message);\r\n/**\r\n * Provides a C interface for the Logging::LogError() function.\r\n * \r\n * @author Ian Copland\r\n * \r\n * @param The message, null terminated.\r\n */\r\nvoid LogError(const char* in_message);\r\n/**\r\n * Provides a C interface for the Logging::LogFatal() function.\r\n * \r\n * @author Ian Copland\r\n * \r\n * @param The message, null terminated.\r\n */\r\nvoid LogFatal(const char* in_message);\r\n\r\n#ifdef __cplusplus\r\n}\r\n#endif\r\n\r\n#endif\r\n"
  },
  {
    "path": "Projects/Tools/PNGAlphaPremultiplier/Native/Source/LibPng/example.c",
    "content": "\n#if 0 /* in case someone actually tries to compile this */\n\n/* example.c - an example of using libpng\n * Last changed in libpng 1.5.7 [December 15, 2011]\n * Maintained 1998-2011 Glenn Randers-Pehrson\n * Maintained 1996, 1997 Andreas Dilger\n * Written 1995, 1996 Guy Eric Schalnat, Group 42, Inc.\n */\n\n/* This is an example of how to use libpng to read and write PNG files.\n * The file libpng-manual.txt is much more verbose then this.  If you have not\n * read it, do so first.  This was designed to be a starting point of an\n * implementation.  This is not officially part of libpng, is hereby placed\n * in the public domain, and therefore does not require a copyright notice.\n * To the extent possible under law, the authors have waived all copyright and\n * related or neighboring rights to this file.\n *\n * This file does not currently compile, because it is missing certain\n * parts, like allocating memory to hold an image.  You will have to\n * supply these parts to get it to compile.  For an example of a minimal\n * working PNG reader/writer, see pngtest.c, included in this distribution;\n * see also the programs in the contrib directory.\n */\n\n#define _POSIX_SOURCE 1  /* libpng and zlib are POSIX-compliant.  You may\n                          * change this if your application uses non-POSIX\n                          * extensions. */\n\n#include \"png.h\"\n\n /* The png_jmpbuf() macro, used in error handling, became available in\n  * libpng version 1.0.6.  If you want to be able to run your code with older\n  * versions of libpng, you must define the macro yourself (but only if it\n  * is not already defined by libpng!).\n  */\n\n#ifndef png_jmpbuf\n#  define png_jmpbuf(png_ptr) ((png_ptr)->png_jmpbuf)\n#endif\n\n/* Check to see if a file is a PNG file using png_sig_cmp().  png_sig_cmp()\n * returns zero if the image is a PNG and nonzero if it isn't a PNG.\n *\n * The function check_if_png() shown here, but not used, returns nonzero (true)\n * if the file can be opened and is a PNG, 0 (false) otherwise.\n *\n * If this call is successful, and you are going to keep the file open,\n * you should call png_set_sig_bytes(png_ptr, PNG_BYTES_TO_CHECK); once\n * you have created the png_ptr, so that libpng knows your application\n * has read that many bytes from the start of the file.  Make sure you\n * don't call png_set_sig_bytes() with more than 8 bytes read or give it\n * an incorrect number of bytes read, or you will either have read too\n * many bytes (your fault), or you are telling libpng to read the wrong\n * number of magic bytes (also your fault).\n *\n * Many applications already read the first 2 or 4 bytes from the start\n * of the image to determine the file type, so it would be easiest just\n * to pass the bytes to png_sig_cmp() or even skip that if you know\n * you have a PNG file, and call png_set_sig_bytes().\n */\n#define PNG_BYTES_TO_CHECK 4\nint check_if_png(char *file_name, FILE **fp)\n{\n   char buf[PNG_BYTES_TO_CHECK];\n\n   /* Open the prospective PNG file. */\n   if ((*fp = fopen(file_name, \"rb\")) == NULL)\n      return 0;\n\n   /* Read in some of the signature bytes */\n   if (fread(buf, 1, PNG_BYTES_TO_CHECK, *fp) != PNG_BYTES_TO_CHECK)\n      return 0;\n\n   /* Compare the first PNG_BYTES_TO_CHECK bytes of the signature.\n      Return nonzero (true) if they match */\n\n   return(!png_sig_cmp(buf, (png_size_t)0, PNG_BYTES_TO_CHECK));\n}\n\n/* Read a PNG file.  You may want to return an error code if the read\n * fails (depending upon the failure).  There are two \"prototypes\" given\n * here - one where we are given the filename, and we need to open the\n * file, and the other where we are given an open file (possibly with\n * some or all of the magic bytes read - see comments above).\n */\n#ifdef open_file /* prototype 1 */\nvoid read_png(char *file_name)  /* We need to open the file */\n{\n   png_structp png_ptr;\n   png_infop info_ptr;\n   unsigned int sig_read = 0;\n   png_uint_32 width, height;\n   int bit_depth, color_type, interlace_type;\n   FILE *fp;\n\n   if ((fp = fopen(file_name, \"rb\")) == NULL)\n      return (ERROR);\n\n#else no_open_file /* prototype 2 */\nvoid read_png(FILE *fp, unsigned int sig_read)  /* File is already open */\n{\n   png_structp png_ptr;\n   png_infop info_ptr;\n   png_uint_32 width, height;\n   int bit_depth, color_type, interlace_type;\n#endif no_open_file /* Only use one prototype! */\n\n   /* Create and initialize the png_struct with the desired error handler\n    * functions.  If you want to use the default stderr and longjump method,\n    * you can supply NULL for the last three parameters.  We also supply the\n    * the compiler header file version, so that we know if the application\n    * was compiled with a compatible version of the library.  REQUIRED\n    */\n   png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,\n      png_voidp user_error_ptr, user_error_fn, user_warning_fn);\n\n   if (png_ptr == NULL)\n   {\n      fclose(fp);\n      return (ERROR);\n   }\n\n   /* Allocate/initialize the memory for image information.  REQUIRED. */\n   info_ptr = png_create_info_struct(png_ptr);\n   if (info_ptr == NULL)\n   {\n      fclose(fp);\n      png_destroy_read_struct(&png_ptr, NULL, NULL);\n      return (ERROR);\n   }\n\n   /* Set error handling if you are using the setjmp/longjmp method (this is\n    * the normal method of doing things with libpng).  REQUIRED unless you\n    * set up your own error handlers in the png_create_read_struct() earlier.\n    */\n\n   if (setjmp(png_jmpbuf(png_ptr)))\n   {\n      /* Free all of the memory associated with the png_ptr and info_ptr */\n      png_destroy_read_struct(&png_ptr, &info_ptr, NULL);\n      fclose(fp);\n      /* If we get here, we had a problem reading the file */\n      return (ERROR);\n   }\n\n   /* One of the following I/O initialization methods is REQUIRED */\n#ifdef streams /* PNG file I/O method 1 */\n   /* Set up the input control if you are using standard C streams */\n   png_init_io(png_ptr, fp);\n\n#else no_streams /* PNG file I/O method 2 */\n   /* If you are using replacement read functions, instead of calling\n    * png_init_io() here you would call:\n    */\n   png_set_read_fn(png_ptr, (void *)user_io_ptr, user_read_fn);\n   /* where user_io_ptr is a structure you want available to the callbacks */\n#endif no_streams /* Use only one I/O method! */\n\n   /* If we have already read some of the signature */\n   png_set_sig_bytes(png_ptr, sig_read);\n\n#ifdef hilevel\n   /*\n    * If you have enough memory to read in the entire image at once,\n    * and you need to specify only transforms that can be controlled\n    * with one of the PNG_TRANSFORM_* bits (this presently excludes\n    * quantizing, filling, setting background, and doing gamma\n    * adjustment), then you can read the entire image (including\n    * pixels) into the info structure with this call:\n    */\n   png_read_png(png_ptr, info_ptr, png_transforms, NULL);\n\n#else\n   /* OK, you're doing it the hard way, with the lower-level functions */\n\n   /* The call to png_read_info() gives us all of the information from the\n    * PNG file before the first IDAT (image data chunk).  REQUIRED\n    */\n   png_read_info(png_ptr, info_ptr);\n\n   png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type,\n       &interlace_type, NULL, NULL);\n\n   /* Set up the data transformations you want.  Note that these are all\n    * optional.  Only call them if you want/need them.  Many of the\n    * transformations only work on specific types of images, and many\n    * are mutually exclusive.\n    */\n\n   /* Tell libpng to strip 16 bit/color files down to 8 bits/color.\n    * Use accurate scaling if it's available, otherwise just chop off the\n    * low byte.\n    */\n#ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED\n    png_set_scale_16(png_ptr);\n#else\n   png_set_strip_16(png_ptr);\n#endif\n\n   /* Strip alpha bytes from the input data without combining with the\n    * background (not recommended).\n    */\n   png_set_strip_alpha(png_ptr);\n\n   /* Extract multiple pixels with bit depths of 1, 2, and 4 from a single\n    * byte into separate bytes (useful for paletted and grayscale images).\n    */\n   png_set_packing(png_ptr);\n\n   /* Change the order of packed pixels to least significant bit first\n    * (not useful if you are using png_set_packing). */\n   png_set_packswap(png_ptr);\n\n   /* Expand paletted colors into true RGB triplets */\n   if (color_type == PNG_COLOR_TYPE_PALETTE)\n      png_set_palette_to_rgb(png_ptr);\n\n   /* Expand grayscale images to the full 8 bits from 1, 2, or 4 bits/pixel */\n   if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8)\n      png_set_expand_gray_1_2_4_to_8(png_ptr);\n\n   /* Expand paletted or RGB images with transparency to full alpha channels\n    * so the data will be available as RGBA quartets.\n    */\n   if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS))\n      png_set_tRNS_to_alpha(png_ptr);\n\n   /* Set the background color to draw transparent and alpha images over.\n    * It is possible to set the red, green, and blue components directly\n    * for paletted images instead of supplying a palette index.  Note that\n    * even if the PNG file supplies a background, you are not required to\n    * use it - you should use the (solid) application background if it has one.\n    */\n\n   png_color_16 my_background, *image_background;\n\n   if (png_get_bKGD(png_ptr, info_ptr, &image_background))\n      png_set_background(png_ptr, image_background,\n                         PNG_BACKGROUND_GAMMA_FILE, 1, 1.0);\n   else\n      png_set_background(png_ptr, &my_background,\n                         PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0);\n\n   /* Some suggestions as to how to get a screen gamma value\n    *\n    * Note that screen gamma is the display_exponent, which includes\n    * the CRT_exponent and any correction for viewing conditions\n    */\n   if (/* We have a user-defined screen gamma value */)\n   {\n      screen_gamma = user-defined screen_gamma;\n   }\n   /* This is one way that applications share the same screen gamma value */\n   else if ((gamma_str = getenv(\"SCREEN_GAMMA\")) != NULL)\n   {\n      screen_gamma = atof(gamma_str);\n   }\n   /* If we don't have another value */\n   else\n   {\n      screen_gamma = 2.2;  /* A good guess for a PC monitor in a dimly\n                              lit room */\n      screen_gamma = 1.7 or 1.0;  /* A good guess for Mac systems */\n   }\n\n   /* Tell libpng to handle the gamma conversion for you.  The final call\n    * is a good guess for PC generated images, but it should be configurable\n    * by the user at run time by the user.  It is strongly suggested that\n    * your application support gamma correction.\n    */\n\n   int intent;\n\n   if (png_get_sRGB(png_ptr, info_ptr, &intent))\n      png_set_gamma(png_ptr, screen_gamma, 0.45455);\n   else\n   {\n      double image_gamma;\n      if (png_get_gAMA(png_ptr, info_ptr, &image_gamma))\n         png_set_gamma(png_ptr, screen_gamma, image_gamma);\n      else\n         png_set_gamma(png_ptr, screen_gamma, 0.45455);\n   }\n\n#ifdef PNG_READ_QUANTIZE_SUPPORTED\n   /* Quantize RGB files down to 8 bit palette or reduce palettes\n    * to the number of colors available on your screen.\n    */\n   if (color_type & PNG_COLOR_MASK_COLOR)\n   {\n      int num_palette;\n      png_colorp palette;\n\n      /* This reduces the image to the application supplied palette */\n      if (/* We have our own palette */)\n      {\n         /* An array of colors to which the image should be quantized */\n         png_color std_color_cube[MAX_SCREEN_COLORS];\n\n         png_set_quantize(png_ptr, std_color_cube, MAX_SCREEN_COLORS,\n            MAX_SCREEN_COLORS, NULL, 0);\n      }\n      /* This reduces the image to the palette supplied in the file */\n      else if (png_get_PLTE(png_ptr, info_ptr, &palette, &num_palette))\n      {\n         png_uint_16p histogram = NULL;\n\n         png_get_hIST(png_ptr, info_ptr, &histogram);\n\n         png_set_quantize(png_ptr, palette, num_palette,\n                        max_screen_colors, histogram, 0);\n      }\n   }\n#endif /* PNG_READ_QUANTIZE_SUPPORTED */\n\n   /* Invert monochrome files to have 0 as white and 1 as black */\n   png_set_invert_mono(png_ptr);\n\n   /* If you want to shift the pixel values from the range [0,255] or\n    * [0,65535] to the original [0,7] or [0,31], or whatever range the\n    * colors were originally in:\n    */\n   if (png_get_valid(png_ptr, info_ptr, PNG_INFO_sBIT))\n   {\n      png_color_8p sig_bit_p;\n\n      png_get_sBIT(png_ptr, info_ptr, &sig_bit_p);\n      png_set_shift(png_ptr, sig_bit_p);\n   }\n\n   /* Flip the RGB pixels to BGR (or RGBA to BGRA) */\n   if (color_type & PNG_COLOR_MASK_COLOR)\n      png_set_bgr(png_ptr);\n\n   /* Swap the RGBA or GA data to ARGB or AG (or BGRA to ABGR) */\n   png_set_swap_alpha(png_ptr);\n\n   /* Swap bytes of 16 bit files to least significant byte first */\n   png_set_swap(png_ptr);\n\n   /* Add filler (or alpha) byte (before/after each RGB triplet) */\n   png_set_filler(png_ptr, 0xff, PNG_FILLER_AFTER);\n\n#ifdef PNG_READ_INTERLACING_SUPPORTED\n   /* Turn on interlace handling.  REQUIRED if you are not using\n    * png_read_image().  To see how to handle interlacing passes,\n    * see the png_read_row() method below:\n    */\n   number_passes = png_set_interlace_handling(png_ptr);\n#else\n   number_passes = 1;\n#endif /* PNG_READ_INTERLACING_SUPPORTED */\n\n\n   /* Optional call to gamma correct and add the background to the palette\n    * and update info structure.  REQUIRED if you are expecting libpng to\n    * update the palette for you (ie you selected such a transform above).\n    */\n   png_read_update_info(png_ptr, info_ptr);\n\n   /* Allocate the memory to hold the image using the fields of info_ptr. */\n\n   /* The easiest way to read the image: */\n   png_bytep row_pointers[height];\n\n   /* Clear the pointer array */\n   for (row = 0; row < height; row++)\n      row_pointers[row] = NULL;\n\n   for (row = 0; row < height; row++)\n      row_pointers[row] = png_malloc(png_ptr, png_get_rowbytes(png_ptr,\n         info_ptr));\n\n   /* Now it's time to read the image.  One of these methods is REQUIRED */\n#ifdef entire /* Read the entire image in one go */\n   png_read_image(png_ptr, row_pointers);\n\n#else no_entire /* Read the image one or more scanlines at a time */\n   /* The other way to read images - deal with interlacing: */\n\n   for (pass = 0; pass < number_passes; pass++)\n   {\n#ifdef single /* Read the image a single row at a time */\n      for (y = 0; y < height; y++)\n      {\n         png_read_rows(png_ptr, &row_pointers[y], NULL, 1);\n      }\n\n#else no_single /* Read the image several rows at a time */\n      for (y = 0; y < height; y += number_of_rows)\n      {\n#ifdef sparkle /* Read the image using the \"sparkle\" effect. */\n         png_read_rows(png_ptr, &row_pointers[y], NULL,\n            number_of_rows);\n#else no_sparkle /* Read the image using the \"rectangle\" effect */\n         png_read_rows(png_ptr, NULL, &row_pointers[y],\n            number_of_rows);\n#endif no_sparkle /* Use only one of these two methods */\n      }\n\n      /* If you want to display the image after every pass, do so here */\n#endif no_single /* Use only one of these two methods */\n   }\n#endif no_entire /* Use only one of these two methods */\n\n   /* Read rest of file, and get additional chunks in info_ptr - REQUIRED */\n   png_read_end(png_ptr, info_ptr);\n#endif hilevel\n\n   /* At this point you have read the entire image */\n\n   /* Clean up after the read, and free any memory allocated - REQUIRED */\n   png_destroy_read_struct(&png_ptr, &info_ptr, NULL);\n\n   /* Close the file */\n   fclose(fp);\n\n   /* That's it */\n   return (OK);\n}\n\n/* Progressively read a file */\n\nint\ninitialize_png_reader(png_structp *png_ptr, png_infop *info_ptr)\n{\n   /* Create and initialize the png_struct with the desired error handler\n    * functions.  If you want to use the default stderr and longjump method,\n    * you can supply NULL for the last three parameters.  We also check that\n    * the library version is compatible in case we are using dynamically\n    * linked libraries.\n    */\n   *png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,\n       png_voidp user_error_ptr, user_error_fn, user_warning_fn);\n\n   if (*png_ptr == NULL)\n   {\n      *info_ptr = NULL;\n      return (ERROR);\n   }\n\n   *info_ptr = png_create_info_struct(png_ptr);\n\n   if (*info_ptr == NULL)\n   {\n      png_destroy_read_struct(png_ptr, info_ptr, NULL);\n      return (ERROR);\n   }\n\n   if (setjmp(png_jmpbuf((*png_ptr))))\n   {\n      png_destroy_read_struct(png_ptr, info_ptr, NULL);\n      return (ERROR);\n   }\n\n   /* This one's new.  You will need to provide all three\n    * function callbacks, even if you aren't using them all.\n    * If you aren't using all functions, you can specify NULL\n    * parameters.  Even when all three functions are NULL,\n    * you need to call png_set_progressive_read_fn().\n    * These functions shouldn't be dependent on global or\n    * static variables if you are decoding several images\n    * simultaneously.  You should store stream specific data\n    * in a separate struct, given as the second parameter,\n    * and retrieve the pointer from inside the callbacks using\n    * the function png_get_progressive_ptr(png_ptr).\n    */\n   png_set_progressive_read_fn(*png_ptr, (void *)stream_data,\n      info_callback, row_callback, end_callback);\n\n   return (OK);\n}\n\nint\nprocess_data(png_structp *png_ptr, png_infop *info_ptr,\n   png_bytep buffer, png_uint_32 length)\n{\n   if (setjmp(png_jmpbuf((*png_ptr))))\n   {\n      /* Free the png_ptr and info_ptr memory on error */\n      png_destroy_read_struct(png_ptr, info_ptr, NULL);\n      return (ERROR);\n   }\n\n   /* This one's new also.  Simply give it chunks of data as\n    * they arrive from the data stream (in order, of course).\n    * On segmented machines, don't give it any more than 64K.\n    * The library seems to run fine with sizes of 4K, although\n    * you can give it much less if necessary (I assume you can\n    * give it chunks of 1 byte, but I haven't tried with less\n    * than 256 bytes yet).  When this function returns, you may\n    * want to display any rows that were generated in the row\n    * callback, if you aren't already displaying them there.\n    */\n   png_process_data(*png_ptr, *info_ptr, buffer, length);\n   return (OK);\n}\n\ninfo_callback(png_structp png_ptr, png_infop info)\n{\n   /* Do any setup here, including setting any of the transformations\n    * mentioned in the Reading PNG files section.  For now, you _must_\n    * call either png_start_read_image() or png_read_update_info()\n    * after all the transformations are set (even if you don't set\n    * any).  You may start getting rows before png_process_data()\n    * returns, so this is your last chance to prepare for that.\n    */\n}\n\nrow_callback(png_structp png_ptr, png_bytep new_row,\n   png_uint_32 row_num, int pass)\n{\n   /*\n    * This function is called for every row in the image.  If the\n    * image is interlaced, and you turned on the interlace handler,\n    * this function will be called for every row in every pass.\n    *\n    * In this function you will receive a pointer to new row data from\n    * libpng called new_row that is to replace a corresponding row (of\n    * the same data format) in a buffer allocated by your application.\n    *\n    * The new row data pointer \"new_row\" may be NULL, indicating there is\n    * no new data to be replaced (in cases of interlace loading).\n    *\n    * If new_row is not NULL then you need to call\n    * png_progressive_combine_row() to replace the corresponding row as\n    * shown below:\n    */\n\n   /* Get pointer to corresponding row in our\n    * PNG read buffer.\n    */\n   png_bytep old_row = ((png_bytep *)our_data)[row_num];\n\n#ifdef PNG_READ_INTERLACING_SUPPORTED\n   /* If both rows are allocated then copy the new row\n    * data to the corresponding row data.\n    */\n   if ((old_row != NULL) && (new_row != NULL))\n   png_progressive_combine_row(png_ptr, old_row, new_row);\n\n   /*\n    * The rows and passes are called in order, so you don't really\n    * need the row_num and pass, but I'm supplying them because it\n    * may make your life easier.\n    *\n    * For the non-NULL rows of interlaced images, you must call\n    * png_progressive_combine_row() passing in the new row and the\n    * old row, as demonstrated above.  You can call this function for\n    * NULL rows (it will just return) and for non-interlaced images\n    * (it just does the png_memcpy for you) if it will make the code\n    * easier.  Thus, you can just do this for all cases:\n    */\n\n   png_progressive_combine_row(png_ptr, old_row, new_row);\n\n   /* where old_row is what was displayed for previous rows.  Note\n    * that the first pass (pass == 0 really) will completely cover\n    * the old row, so the rows do not have to be initialized.  After\n    * the first pass (and only for interlaced images), you will have\n    * to pass the current row as new_row, and the function will combine\n    * the old row and the new row.\n    */\n#endif /* PNG_READ_INTERLACING_SUPPORTED */\n}\n\nend_callback(png_structp png_ptr, png_infop info)\n{\n   /* This function is called when the whole image has been read,\n    * including any chunks after the image (up to and including\n    * the IEND).  You will usually have the same info chunk as you\n    * had in the header, although some data may have been added\n    * to the comments and time fields.\n    *\n    * Most people won't do much here, perhaps setting a flag that\n    * marks the image as finished.\n    */\n}\n\n/* Write a png file */\nvoid write_png(char *file_name /* , ... other image information ... */)\n{\n   FILE *fp;\n   png_structp png_ptr;\n   png_infop info_ptr;\n   png_colorp palette;\n\n   /* Open the file */\n   fp = fopen(file_name, \"wb\");\n   if (fp == NULL)\n      return (ERROR);\n\n   /* Create and initialize the png_struct with the desired error handler\n    * functions.  If you want to use the default stderr and longjump method,\n    * you can supply NULL for the last three parameters.  We also check that\n    * the library version is compatible with the one used at compile time,\n    * in case we are using dynamically linked libraries.  REQUIRED.\n    */\n   png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING,\n      png_voidp user_error_ptr, user_error_fn, user_warning_fn);\n\n   if (png_ptr == NULL)\n   {\n      fclose(fp);\n      return (ERROR);\n   }\n\n   /* Allocate/initialize the image information data.  REQUIRED */\n   info_ptr = png_create_info_struct(png_ptr);\n   if (info_ptr == NULL)\n   {\n      fclose(fp);\n      png_destroy_write_struct(&png_ptr,  NULL);\n      return (ERROR);\n   }\n\n   /* Set error handling.  REQUIRED if you aren't supplying your own\n    * error handling functions in the png_create_write_struct() call.\n    */\n   if (setjmp(png_jmpbuf(png_ptr)))\n   {\n      /* If we get here, we had a problem writing the file */\n      fclose(fp);\n      png_destroy_write_struct(&png_ptr, &info_ptr);\n      return (ERROR);\n   }\n\n   /* One of the following I/O initialization functions is REQUIRED */\n\n#ifdef streams /* I/O initialization method 1 */\n   /* Set up the output control if you are using standard C streams */\n   png_init_io(png_ptr, fp);\n\n#else no_streams /* I/O initialization method 2 */\n   /* If you are using replacement write functions, instead of calling\n    * png_init_io() here you would call\n    */\n   png_set_write_fn(png_ptr, (void *)user_io_ptr, user_write_fn,\n      user_IO_flush_function);\n   /* where user_io_ptr is a structure you want available to the callbacks */\n#endif no_streams /* Only use one initialization method */\n\n#ifdef hilevel\n   /* This is the easy way.  Use it if you already have all the\n    * image info living in the structure.  You could \"|\" many\n    * PNG_TRANSFORM flags into the png_transforms integer here.\n    */\n   png_write_png(png_ptr, info_ptr, png_transforms, NULL);\n\n#else\n   /* This is the hard way */\n\n   /* Set the image information here.  Width and height are up to 2^31,\n    * bit_depth is one of 1, 2, 4, 8, or 16, but valid values also depend on\n    * the color_type selected. color_type is one of PNG_COLOR_TYPE_GRAY,\n    * PNG_COLOR_TYPE_GRAY_ALPHA, PNG_COLOR_TYPE_PALETTE, PNG_COLOR_TYPE_RGB,\n    * or PNG_COLOR_TYPE_RGB_ALPHA.  interlace is either PNG_INTERLACE_NONE or\n    * PNG_INTERLACE_ADAM7, and the compression_type and filter_type MUST\n    * currently be PNG_COMPRESSION_TYPE_BASE and PNG_FILTER_TYPE_BASE. REQUIRED\n    */\n   png_set_IHDR(png_ptr, info_ptr, width, height, bit_depth, PNG_COLOR_TYPE_???,\n      PNG_INTERLACE_????, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);\n\n   /* Set the palette if there is one.  REQUIRED for indexed-color images */\n   palette = (png_colorp)png_malloc(png_ptr, PNG_MAX_PALETTE_LENGTH\n             * png_sizeof(png_color));\n   /* ... Set palette colors ... */\n   png_set_PLTE(png_ptr, info_ptr, palette, PNG_MAX_PALETTE_LENGTH);\n   /* You must not free palette here, because png_set_PLTE only makes a link to\n    * the palette that you malloced.  Wait until you are about to destroy\n    * the png structure.\n    */\n\n   /* Optional significant bit (sBIT) chunk */\n   png_color_8 sig_bit;\n\n   /* If we are dealing with a grayscale image then */\n   sig_bit.gray = true_bit_depth;\n\n   /* Otherwise, if we are dealing with a color image then */\n   sig_bit.red = true_red_bit_depth;\n   sig_bit.green = true_green_bit_depth;\n   sig_bit.blue = true_blue_bit_depth;\n\n   /* If the image has an alpha channel then */\n   sig_bit.alpha = true_alpha_bit_depth;\n\n   png_set_sBIT(png_ptr, info_ptr, &sig_bit);\n\n\n   /* Optional gamma chunk is strongly suggested if you have any guess\n    * as to the correct gamma of the image.\n    */\n   png_set_gAMA(png_ptr, info_ptr, gamma);\n\n   /* Optionally write comments into the image */\n   text_ptr[0].key = \"Title\";\n   text_ptr[0].text = \"Mona Lisa\";\n   text_ptr[0].compression = PNG_TEXT_COMPRESSION_NONE;\n   text_ptr[0].itxt_length = 0;\n   text_ptr[0].lang = NULL;\n   text_ptr[0].lang_key = NULL;\n   text_ptr[1].key = \"Author\";\n   text_ptr[1].text = \"Leonardo DaVinci\";\n   text_ptr[1].compression = PNG_TEXT_COMPRESSION_NONE;\n   text_ptr[1].itxt_length = 0;\n   text_ptr[1].lang = NULL;\n   text_ptr[1].lang_key = NULL;\n   text_ptr[2].key = \"Description\";\n   text_ptr[2].text = \"<long text>\";\n   text_ptr[2].compression = PNG_TEXT_COMPRESSION_zTXt;\n   text_ptr[2].itxt_length = 0;\n   text_ptr[2].lang = NULL;\n   text_ptr[2].lang_key = NULL;\n   png_set_text(png_ptr, info_ptr, text_ptr, 3);\n\n   /* Other optional chunks like cHRM, bKGD, tRNS, tIME, oFFs, pHYs */\n\n   /* Note that if sRGB is present the gAMA and cHRM chunks must be ignored\n    * on read and, if your application chooses to write them, they must\n    * be written in accordance with the sRGB profile\n    */\n\n   /* Write the file header information.  REQUIRED */\n   png_write_info(png_ptr, info_ptr);\n\n   /* If you want, you can write the info in two steps, in case you need to\n    * write your private chunk ahead of PLTE:\n    *\n    *   png_write_info_before_PLTE(write_ptr, write_info_ptr);\n    *   write_my_chunk();\n    *   png_write_info(png_ptr, info_ptr);\n    *\n    * However, given the level of known- and unknown-chunk support in 1.2.0\n    * and up, this should no longer be necessary.\n    */\n\n   /* Once we write out the header, the compression type on the text\n    * chunks gets changed to PNG_TEXT_COMPRESSION_NONE_WR or\n    * PNG_TEXT_COMPRESSION_zTXt_WR, so it doesn't get written out again\n    * at the end.\n    */\n\n   /* Set up the transformations you want.  Note that these are\n    * all optional.  Only call them if you want them.\n    */\n\n   /* Invert monochrome pixels */\n   png_set_invert_mono(png_ptr);\n\n   /* Shift the pixels up to a legal bit depth and fill in\n    * as appropriate to correctly scale the image.\n    */\n   png_set_shift(png_ptr, &sig_bit);\n\n   /* Pack pixels into bytes */\n   png_set_packing(png_ptr);\n\n   /* Swap location of alpha bytes from ARGB to RGBA */\n   png_set_swap_alpha(png_ptr);\n\n   /* Get rid of filler (OR ALPHA) bytes, pack XRGB/RGBX/ARGB/RGBA into\n    * RGB (4 channels -> 3 channels). The second parameter is not used.\n    */\n   png_set_filler(png_ptr, 0, PNG_FILLER_BEFORE);\n\n   /* Flip BGR pixels to RGB */\n   png_set_bgr(png_ptr);\n\n   /* Swap bytes of 16-bit files to most significant byte first */\n   png_set_swap(png_ptr);\n\n   /* Swap bits of 1, 2, 4 bit packed pixel formats */\n   png_set_packswap(png_ptr);\n\n   /* Turn on interlace handling if you are not using png_write_image() */\n   if (interlacing)\n      number_passes = png_set_interlace_handling(png_ptr);\n\n   else\n      number_passes = 1;\n\n   /* The easiest way to write the image (you may have a different memory\n    * layout, however, so choose what fits your needs best).  You need to\n    * use the first method if you aren't handling interlacing yourself.\n    */\n   png_uint_32 k, height, width;\n   png_byte image[height][width*bytes_per_pixel];\n   png_bytep row_pointers[height];\n\n   if (height > PNG_UINT_32_MAX/png_sizeof(png_bytep))\n     png_error (png_ptr, \"Image is too tall to process in memory\");\n\n   for (k = 0; k < height; k++)\n     row_pointers[k] = image + k*width*bytes_per_pixel;\n\n   /* One of the following output methods is REQUIRED */\n\n#ifdef entire /* Write out the entire image data in one call */\n   png_write_image(png_ptr, row_pointers);\n\n   /* The other way to write the image - deal with interlacing */\n\n#else no_entire /* Write out the image data by one or more scanlines */\n\n   /* The number of passes is either 1 for non-interlaced images,\n    * or 7 for interlaced images.\n    */\n   for (pass = 0; pass < number_passes; pass++)\n   {\n      /* Write a few rows at a time. */\n      png_write_rows(png_ptr, &row_pointers[first_row], number_of_rows);\n\n      /* If you are only writing one row at a time, this works */\n      for (y = 0; y < height; y++)\n         png_write_rows(png_ptr, &row_pointers[y], 1);\n   }\n#endif no_entire /* Use only one output method */\n\n   /* You can write optional chunks like tEXt, zTXt, and tIME at the end\n    * as well.  Shouldn't be necessary in 1.2.0 and up as all the public\n    * chunks are supported and you can use png_set_unknown_chunks() to\n    * register unknown chunks into the info structure to be written out.\n    */\n\n   /* It is REQUIRED to call this to finish writing the rest of the file */\n   png_write_end(png_ptr, info_ptr);\n#endif hilevel\n\n   /* If you png_malloced a palette, free it here (don't free info_ptr->palette,\n    * as recommended in versions 1.0.5m and earlier of this example; if\n    * libpng mallocs info_ptr->palette, libpng will free it).  If you\n    * allocated it with malloc() instead of png_malloc(), use free() instead\n    * of png_free().\n    */\n   png_free(png_ptr, palette);\n   palette = NULL;\n\n   /* Similarly, if you png_malloced any data that you passed in with\n    * png_set_something(), such as a hist or trans array, free it here,\n    * when you can be sure that libpng is through with it.\n    */\n   png_free(png_ptr, trans);\n   trans = NULL;\n   /* Whenever you use png_free() it is a good idea to set the pointer to\n    * NULL in case your application inadvertently tries to png_free() it\n    * again.  When png_free() sees a NULL it returns without action, thus\n    * avoiding the double-free security problem.\n    */\n\n   /* Clean up after the write, and free any memory allocated */\n   png_destroy_write_struct(&png_ptr, &info_ptr);\n\n   /* Close the file */\n   fclose(fp);\n\n   /* That's it */\n   return (OK);\n}\n\n#endif /* if 0 */\n"
  },
  {
    "path": "Projects/Tools/PNGAlphaPremultiplier/Native/Source/LibPng/png.c",
    "content": "\n/* png.c - location for general purpose libpng functions\n *\n * Last changed in libpng 1.5.7 [December 15, 2011]\n * Copyright (c) 1998-2011 Glenn Randers-Pehrson\n * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)\n * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)\n *\n * This code is released under the libpng license.\n * For conditions of distribution and use, see the disclaimer\n * and license in png.h\n */\n\n#include \"pngpriv.h\"\n\n/* Generate a compiler error if there is an old png.h in the search path. */\ntypedef png_libpng_version_1_5_9 Your_png_h_is_not_version_1_5_9;\n\n/* Tells libpng that we have already handled the first \"num_bytes\" bytes\n * of the PNG file signature.  If the PNG data is embedded into another\n * stream we can set num_bytes = 8 so that libpng will not attempt to read\n * or write any of the magic bytes before it starts on the IHDR.\n */\n\n#ifdef PNG_READ_SUPPORTED\nvoid PNGAPI\npng_set_sig_bytes(png_structp png_ptr, int num_bytes)\n{\n   png_debug(1, \"in png_set_sig_bytes\");\n\n   if (png_ptr == NULL)\n      return;\n\n   if (num_bytes > 8)\n      png_error(png_ptr, \"Too many bytes for PNG signature\");\n\n   png_ptr->sig_bytes = (png_byte)(num_bytes < 0 ? 0 : num_bytes);\n}\n\n/* Checks whether the supplied bytes match the PNG signature.  We allow\n * checking less than the full 8-byte signature so that those apps that\n * already read the first few bytes of a file to determine the file type\n * can simply check the remaining bytes for extra assurance.  Returns\n * an integer less than, equal to, or greater than zero if sig is found,\n * respectively, to be less than, to match, or be greater than the correct\n * PNG signature (this is the same behavior as strcmp, memcmp, etc).\n */\nint PNGAPI\npng_sig_cmp(png_const_bytep sig, png_size_t start, png_size_t num_to_check)\n{\n   png_byte png_signature[8] = {137, 80, 78, 71, 13, 10, 26, 10};\n\n   if (num_to_check > 8)\n      num_to_check = 8;\n\n   else if (num_to_check < 1)\n      return (-1);\n\n   if (start > 7)\n      return (-1);\n\n   if (start + num_to_check > 8)\n      num_to_check = 8 - start;\n\n   return ((int)(png_memcmp(&sig[start], &png_signature[start], num_to_check)));\n}\n\n#endif /* PNG_READ_SUPPORTED */\n\n#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)\n/* Function to allocate memory for zlib */\nPNG_FUNCTION(voidpf /* PRIVATE */,\npng_zalloc,(voidpf png_ptr, uInt items, uInt size),PNG_ALLOCATED)\n{\n   png_voidp ptr;\n   png_structp p=(png_structp)png_ptr;\n   png_uint_32 save_flags=p->flags;\n   png_alloc_size_t num_bytes;\n\n   if (png_ptr == NULL)\n      return (NULL);\n\n   if (items > PNG_UINT_32_MAX/size)\n   {\n     png_warning (p, \"Potential overflow in png_zalloc()\");\n     return (NULL);\n   }\n   num_bytes = (png_alloc_size_t)items * size;\n\n   p->flags|=PNG_FLAG_MALLOC_NULL_MEM_OK;\n   ptr = (png_voidp)png_malloc((png_structp)png_ptr, num_bytes);\n   p->flags=save_flags;\n\n   return ((voidpf)ptr);\n}\n\n/* Function to free memory for zlib */\nvoid /* PRIVATE */\npng_zfree(voidpf png_ptr, voidpf ptr)\n{\n   png_free((png_structp)png_ptr, (png_voidp)ptr);\n}\n\n/* Reset the CRC variable to 32 bits of 1's.  Care must be taken\n * in case CRC is > 32 bits to leave the top bits 0.\n */\nvoid /* PRIVATE */\npng_reset_crc(png_structp png_ptr)\n{\n   /* The cast is safe because the crc is a 32 bit value. */\n   png_ptr->crc = (png_uint_32)crc32(0, Z_NULL, 0);\n}\n\n/* Calculate the CRC over a section of data.  We can only pass as\n * much data to this routine as the largest single buffer size.  We\n * also check that this data will actually be used before going to the\n * trouble of calculating it.\n */\nvoid /* PRIVATE */\npng_calculate_crc(png_structp png_ptr, png_const_bytep ptr, png_size_t length)\n{\n   int need_crc = 1;\n\n   if (PNG_CHUNK_ANCILLIARY(png_ptr->chunk_name))\n   {\n      if ((png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_MASK) ==\n          (PNG_FLAG_CRC_ANCILLARY_USE | PNG_FLAG_CRC_ANCILLARY_NOWARN))\n         need_crc = 0;\n   }\n\n   else /* critical */\n   {\n      if (png_ptr->flags & PNG_FLAG_CRC_CRITICAL_IGNORE)\n         need_crc = 0;\n   }\n\n   /* 'uLong' is defined as unsigned long, this means that on some systems it is\n    * a 64 bit value.  crc32, however, returns 32 bits so the following cast is\n    * safe.  'uInt' may be no more than 16 bits, so it is necessary to perform a\n    * loop here.\n    */\n   if (need_crc && length > 0)\n   {\n      uLong crc = png_ptr->crc; /* Should never issue a warning */\n\n      do\n      {\n         uInt safeLength = (uInt)length;\n         if (safeLength == 0)\n            safeLength = (uInt)-1; /* evil, but safe */\n\n         crc = crc32(crc, ptr, safeLength);\n\n         /* The following should never issue compiler warnings, if they do the\n          * target system has characteristics that will probably violate other\n          * assumptions within the libpng code.\n          */\n         ptr += safeLength;\n         length -= safeLength;\n      }\n      while (length > 0);\n\n      /* And the following is always safe because the crc is only 32 bits. */\n      png_ptr->crc = (png_uint_32)crc;\n   }\n}\n\n/* Check a user supplied version number, called from both read and write\n * functions that create a png_struct\n */\nint\npng_user_version_check(png_structp png_ptr, png_const_charp user_png_ver)\n{\n   if (user_png_ver)\n   {\n      int i = 0;\n\n      do\n      {\n         if (user_png_ver[i] != png_libpng_ver[i])\n            png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH;\n      } while (png_libpng_ver[i++]);\n   }\n\n   else\n      png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH;\n\n   if (png_ptr->flags & PNG_FLAG_LIBRARY_MISMATCH)\n   {\n     /* Libpng 0.90 and later are binary incompatible with libpng 0.89, so\n      * we must recompile any applications that use any older library version.\n      * For versions after libpng 1.0, we will be compatible, so we need\n      * only check the first digit.\n      */\n      if (user_png_ver == NULL || user_png_ver[0] != png_libpng_ver[0] ||\n          (user_png_ver[0] == '1' && user_png_ver[2] != png_libpng_ver[2]) ||\n          (user_png_ver[0] == '0' && user_png_ver[2] < '9'))\n      {\n#ifdef PNG_WARNINGS_SUPPORTED\n         size_t pos = 0;\n         char m[128];\n\n         pos = png_safecat(m, sizeof m, pos, \"Application built with libpng-\");\n         pos = png_safecat(m, sizeof m, pos, user_png_ver);\n         pos = png_safecat(m, sizeof m, pos, \" but running with \");\n         pos = png_safecat(m, sizeof m, pos, png_libpng_ver);\n\n         png_warning(png_ptr, m);\n#endif\n\n#ifdef PNG_ERROR_NUMBERS_SUPPORTED\n         png_ptr->flags = 0;\n#endif\n\n         return 0;\n      }\n   }\n\n   /* Success return. */\n   return 1;\n}\n\n/* Allocate the memory for an info_struct for the application.  We don't\n * really need the png_ptr, but it could potentially be useful in the\n * future.  This should be used in favour of malloc(png_sizeof(png_info))\n * and png_info_init() so that applications that want to use a shared\n * libpng don't have to be recompiled if png_info changes size.\n */\nPNG_FUNCTION(png_infop,PNGAPI\npng_create_info_struct,(png_structp png_ptr),PNG_ALLOCATED)\n{\n   png_infop info_ptr;\n\n   png_debug(1, \"in png_create_info_struct\");\n\n   if (png_ptr == NULL)\n      return (NULL);\n\n#ifdef PNG_USER_MEM_SUPPORTED\n   info_ptr = (png_infop)png_create_struct_2(PNG_STRUCT_INFO,\n      png_ptr->malloc_fn, png_ptr->mem_ptr);\n#else\n   info_ptr = (png_infop)png_create_struct(PNG_STRUCT_INFO);\n#endif\n   if (info_ptr != NULL)\n      png_info_init_3(&info_ptr, png_sizeof(png_info));\n\n   return (info_ptr);\n}\n\n/* This function frees the memory associated with a single info struct.\n * Normally, one would use either png_destroy_read_struct() or\n * png_destroy_write_struct() to free an info struct, but this may be\n * useful for some applications.\n */\nvoid PNGAPI\npng_destroy_info_struct(png_structp png_ptr, png_infopp info_ptr_ptr)\n{\n   png_infop info_ptr = NULL;\n\n   png_debug(1, \"in png_destroy_info_struct\");\n\n   if (png_ptr == NULL)\n      return;\n\n   if (info_ptr_ptr != NULL)\n      info_ptr = *info_ptr_ptr;\n\n   if (info_ptr != NULL)\n   {\n      png_info_destroy(png_ptr, info_ptr);\n\n#ifdef PNG_USER_MEM_SUPPORTED\n      png_destroy_struct_2((png_voidp)info_ptr, png_ptr->free_fn,\n          png_ptr->mem_ptr);\n#else\n      png_destroy_struct((png_voidp)info_ptr);\n#endif\n      *info_ptr_ptr = NULL;\n   }\n}\n\n/* Initialize the info structure.  This is now an internal function (0.89)\n * and applications using it are urged to use png_create_info_struct()\n * instead.\n */\n\nvoid PNGAPI\npng_info_init_3(png_infopp ptr_ptr, png_size_t png_info_struct_size)\n{\n   png_infop info_ptr = *ptr_ptr;\n\n   png_debug(1, \"in png_info_init_3\");\n\n   if (info_ptr == NULL)\n      return;\n\n   if (png_sizeof(png_info) > png_info_struct_size)\n   {\n      png_destroy_struct(info_ptr);\n      info_ptr = (png_infop)png_create_struct(PNG_STRUCT_INFO);\n      *ptr_ptr = info_ptr;\n   }\n\n   /* Set everything to 0 */\n   png_memset(info_ptr, 0, png_sizeof(png_info));\n}\n\nvoid PNGAPI\npng_data_freer(png_structp png_ptr, png_infop info_ptr,\n   int freer, png_uint_32 mask)\n{\n   png_debug(1, \"in png_data_freer\");\n\n   if (png_ptr == NULL || info_ptr == NULL)\n      return;\n\n   if (freer == PNG_DESTROY_WILL_FREE_DATA)\n      info_ptr->free_me |= mask;\n\n   else if (freer == PNG_USER_WILL_FREE_DATA)\n      info_ptr->free_me &= ~mask;\n\n   else\n      png_warning(png_ptr,\n         \"Unknown freer parameter in png_data_freer\");\n}\n\nvoid PNGAPI\npng_free_data(png_structp png_ptr, png_infop info_ptr, png_uint_32 mask,\n   int num)\n{\n   png_debug(1, \"in png_free_data\");\n\n   if (png_ptr == NULL || info_ptr == NULL)\n      return;\n\n#ifdef PNG_TEXT_SUPPORTED\n   /* Free text item num or (if num == -1) all text items */\n   if ((mask & PNG_FREE_TEXT) & info_ptr->free_me)\n   {\n      if (num != -1)\n      {\n         if (info_ptr->text && info_ptr->text[num].key)\n         {\n            png_free(png_ptr, info_ptr->text[num].key);\n            info_ptr->text[num].key = NULL;\n         }\n      }\n\n      else\n      {\n         int i;\n         for (i = 0; i < info_ptr->num_text; i++)\n             png_free_data(png_ptr, info_ptr, PNG_FREE_TEXT, i);\n         png_free(png_ptr, info_ptr->text);\n         info_ptr->text = NULL;\n         info_ptr->num_text=0;\n      }\n   }\n#endif\n\n#ifdef PNG_tRNS_SUPPORTED\n   /* Free any tRNS entry */\n   if ((mask & PNG_FREE_TRNS) & info_ptr->free_me)\n   {\n      png_free(png_ptr, info_ptr->trans_alpha);\n      info_ptr->trans_alpha = NULL;\n      info_ptr->valid &= ~PNG_INFO_tRNS;\n   }\n#endif\n\n#ifdef PNG_sCAL_SUPPORTED\n   /* Free any sCAL entry */\n   if ((mask & PNG_FREE_SCAL) & info_ptr->free_me)\n   {\n      png_free(png_ptr, info_ptr->scal_s_width);\n      png_free(png_ptr, info_ptr->scal_s_height);\n      info_ptr->scal_s_width = NULL;\n      info_ptr->scal_s_height = NULL;\n      info_ptr->valid &= ~PNG_INFO_sCAL;\n   }\n#endif\n\n#ifdef PNG_pCAL_SUPPORTED\n   /* Free any pCAL entry */\n   if ((mask & PNG_FREE_PCAL) & info_ptr->free_me)\n   {\n      png_free(png_ptr, info_ptr->pcal_purpose);\n      png_free(png_ptr, info_ptr->pcal_units);\n      info_ptr->pcal_purpose = NULL;\n      info_ptr->pcal_units = NULL;\n      if (info_ptr->pcal_params != NULL)\n         {\n            int i;\n            for (i = 0; i < (int)info_ptr->pcal_nparams; i++)\n            {\n               png_free(png_ptr, info_ptr->pcal_params[i]);\n               info_ptr->pcal_params[i] = NULL;\n            }\n            png_free(png_ptr, info_ptr->pcal_params);\n            info_ptr->pcal_params = NULL;\n         }\n      info_ptr->valid &= ~PNG_INFO_pCAL;\n   }\n#endif\n\n#ifdef PNG_iCCP_SUPPORTED\n   /* Free any iCCP entry */\n   if ((mask & PNG_FREE_ICCP) & info_ptr->free_me)\n   {\n      png_free(png_ptr, info_ptr->iccp_name);\n      png_free(png_ptr, info_ptr->iccp_profile);\n      info_ptr->iccp_name = NULL;\n      info_ptr->iccp_profile = NULL;\n      info_ptr->valid &= ~PNG_INFO_iCCP;\n   }\n#endif\n\n#ifdef PNG_sPLT_SUPPORTED\n   /* Free a given sPLT entry, or (if num == -1) all sPLT entries */\n   if ((mask & PNG_FREE_SPLT) & info_ptr->free_me)\n   {\n      if (num != -1)\n      {\n         if (info_ptr->splt_palettes)\n         {\n            png_free(png_ptr, info_ptr->splt_palettes[num].name);\n            png_free(png_ptr, info_ptr->splt_palettes[num].entries);\n            info_ptr->splt_palettes[num].name = NULL;\n            info_ptr->splt_palettes[num].entries = NULL;\n         }\n      }\n\n      else\n      {\n         if (info_ptr->splt_palettes_num)\n         {\n            int i;\n            for (i = 0; i < (int)info_ptr->splt_palettes_num; i++)\n               png_free_data(png_ptr, info_ptr, PNG_FREE_SPLT, i);\n\n            png_free(png_ptr, info_ptr->splt_palettes);\n            info_ptr->splt_palettes = NULL;\n            info_ptr->splt_palettes_num = 0;\n         }\n         info_ptr->valid &= ~PNG_INFO_sPLT;\n      }\n   }\n#endif\n\n#ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED\n   if (png_ptr->unknown_chunk.data)\n   {\n      png_free(png_ptr, png_ptr->unknown_chunk.data);\n      png_ptr->unknown_chunk.data = NULL;\n   }\n\n   if ((mask & PNG_FREE_UNKN) & info_ptr->free_me)\n   {\n      if (num != -1)\n      {\n          if (info_ptr->unknown_chunks)\n          {\n             png_free(png_ptr, info_ptr->unknown_chunks[num].data);\n             info_ptr->unknown_chunks[num].data = NULL;\n          }\n      }\n\n      else\n      {\n         int i;\n\n         if (info_ptr->unknown_chunks_num)\n         {\n            for (i = 0; i < info_ptr->unknown_chunks_num; i++)\n               png_free_data(png_ptr, info_ptr, PNG_FREE_UNKN, i);\n\n            png_free(png_ptr, info_ptr->unknown_chunks);\n            info_ptr->unknown_chunks = NULL;\n            info_ptr->unknown_chunks_num = 0;\n         }\n      }\n   }\n#endif\n\n#ifdef PNG_hIST_SUPPORTED\n   /* Free any hIST entry */\n   if ((mask & PNG_FREE_HIST)  & info_ptr->free_me)\n   {\n      png_free(png_ptr, info_ptr->hist);\n      info_ptr->hist = NULL;\n      info_ptr->valid &= ~PNG_INFO_hIST;\n   }\n#endif\n\n   /* Free any PLTE entry that was internally allocated */\n   if ((mask & PNG_FREE_PLTE) & info_ptr->free_me)\n   {\n      png_zfree(png_ptr, info_ptr->palette);\n      info_ptr->palette = NULL;\n      info_ptr->valid &= ~PNG_INFO_PLTE;\n      info_ptr->num_palette = 0;\n   }\n\n#ifdef PNG_INFO_IMAGE_SUPPORTED\n   /* Free any image bits attached to the info structure */\n   if ((mask & PNG_FREE_ROWS) & info_ptr->free_me)\n   {\n      if (info_ptr->row_pointers)\n      {\n         int row;\n         for (row = 0; row < (int)info_ptr->height; row++)\n         {\n            png_free(png_ptr, info_ptr->row_pointers[row]);\n            info_ptr->row_pointers[row] = NULL;\n         }\n         png_free(png_ptr, info_ptr->row_pointers);\n         info_ptr->row_pointers = NULL;\n      }\n      info_ptr->valid &= ~PNG_INFO_IDAT;\n   }\n#endif\n\n   if (num != -1)\n      mask &= ~PNG_FREE_MUL;\n\n   info_ptr->free_me &= ~mask;\n}\n\n/* This is an internal routine to free any memory that the info struct is\n * pointing to before re-using it or freeing the struct itself.  Recall\n * that png_free() checks for NULL pointers for us.\n */\nvoid /* PRIVATE */\npng_info_destroy(png_structp png_ptr, png_infop info_ptr)\n{\n   png_debug(1, \"in png_info_destroy\");\n\n   png_free_data(png_ptr, info_ptr, PNG_FREE_ALL, -1);\n\n#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED\n   if (png_ptr->num_chunk_list)\n   {\n      png_free(png_ptr, png_ptr->chunk_list);\n      png_ptr->chunk_list = NULL;\n      png_ptr->num_chunk_list = 0;\n   }\n#endif\n\n   png_info_init_3(&info_ptr, png_sizeof(png_info));\n}\n#endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */\n\n/* This function returns a pointer to the io_ptr associated with the user\n * functions.  The application should free any memory associated with this\n * pointer before png_write_destroy() or png_read_destroy() are called.\n */\npng_voidp PNGAPI\npng_get_io_ptr(png_structp png_ptr)\n{\n   if (png_ptr == NULL)\n      return (NULL);\n\n   return (png_ptr->io_ptr);\n}\n\n#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)\n#  ifdef PNG_STDIO_SUPPORTED\n/* Initialize the default input/output functions for the PNG file.  If you\n * use your own read or write routines, you can call either png_set_read_fn()\n * or png_set_write_fn() instead of png_init_io().  If you have defined\n * PNG_NO_STDIO or otherwise disabled PNG_STDIO_SUPPORTED, you must use a\n * function of your own because \"FILE *\" isn't necessarily available.\n */\nvoid PNGAPI\npng_init_io(png_structp png_ptr, png_FILE_p fp)\n{\n   png_debug(1, \"in png_init_io\");\n\n   if (png_ptr == NULL)\n      return;\n\n   png_ptr->io_ptr = (png_voidp)fp;\n}\n#  endif\n\n#  ifdef PNG_TIME_RFC1123_SUPPORTED\n/* Convert the supplied time into an RFC 1123 string suitable for use in\n * a \"Creation Time\" or other text-based time string.\n */\npng_const_charp PNGAPI\npng_convert_to_rfc1123(png_structp png_ptr, png_const_timep ptime)\n{\n   static PNG_CONST char short_months[12][4] =\n        {\"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\",\n         \"Jul\", \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\"};\n\n   if (png_ptr == NULL)\n      return (NULL);\n\n   if (ptime->year > 9999 /* RFC1123 limitation */ ||\n       ptime->month == 0    ||  ptime->month > 12  ||\n       ptime->day   == 0    ||  ptime->day   > 31  ||\n       ptime->hour  > 23    ||  ptime->minute > 59 ||\n       ptime->second > 60)\n   {\n      png_warning(png_ptr, \"Ignoring invalid time value\");\n      return (NULL);\n   }\n\n   {\n      size_t pos = 0;\n      char number_buf[5]; /* enough for a four-digit year */\n\n#     define APPEND_STRING(string)\\\n         pos = png_safecat(png_ptr->time_buffer, sizeof png_ptr->time_buffer,\\\n            pos, (string))\n#     define APPEND_NUMBER(format, value)\\\n         APPEND_STRING(PNG_FORMAT_NUMBER(number_buf, format, (value)))\n#     define APPEND(ch)\\\n         if (pos < (sizeof png_ptr->time_buffer)-1)\\\n            png_ptr->time_buffer[pos++] = (ch)\n\n      APPEND_NUMBER(PNG_NUMBER_FORMAT_u, (unsigned)ptime->day);\n      APPEND(' ');\n      APPEND_STRING(short_months[(ptime->month - 1)]);\n      APPEND(' ');\n      APPEND_NUMBER(PNG_NUMBER_FORMAT_u, ptime->year);\n      APPEND(' ');\n      APPEND_NUMBER(PNG_NUMBER_FORMAT_02u, (unsigned)ptime->hour);\n      APPEND(':');\n      APPEND_NUMBER(PNG_NUMBER_FORMAT_02u, (unsigned)ptime->minute);\n      APPEND(':');\n      APPEND_NUMBER(PNG_NUMBER_FORMAT_02u, (unsigned)ptime->second);\n      APPEND_STRING(\" +0000\"); /* This reliably terminates the buffer */\n\n#     undef APPEND\n#     undef APPEND_NUMBER\n#     undef APPEND_STRING\n   }\n\n   return png_ptr->time_buffer;\n}\n#  endif /* PNG_TIME_RFC1123_SUPPORTED */\n\n#endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */\n\npng_const_charp PNGAPI\npng_get_copyright(png_const_structp png_ptr)\n{\n   PNG_UNUSED(png_ptr)  /* Silence compiler warning about unused png_ptr */\n#ifdef PNG_STRING_COPYRIGHT\n   return PNG_STRING_COPYRIGHT\n#else\n#  ifdef __STDC__\n   return PNG_STRING_NEWLINE \\\n     \"libpng version 1.5.9 - February 18, 2012\" PNG_STRING_NEWLINE \\\n     \"Copyright (c) 1998-2011 Glenn Randers-Pehrson\" PNG_STRING_NEWLINE \\\n     \"Copyright (c) 1996-1997 Andreas Dilger\" PNG_STRING_NEWLINE \\\n     \"Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.\" \\\n     PNG_STRING_NEWLINE;\n#  else\n      return \"libpng version 1.5.9 - February 18, 2012\\\n      Copyright (c) 1998-2011 Glenn Randers-Pehrson\\\n      Copyright (c) 1996-1997 Andreas Dilger\\\n      Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.\";\n#  endif\n#endif\n}\n\n/* The following return the library version as a short string in the\n * format 1.0.0 through 99.99.99zz.  To get the version of *.h files\n * used with your application, print out PNG_LIBPNG_VER_STRING, which\n * is defined in png.h.\n * Note: now there is no difference between png_get_libpng_ver() and\n * png_get_header_ver().  Due to the version_nn_nn_nn typedef guard,\n * it is guaranteed that png.c uses the correct version of png.h.\n */\npng_const_charp PNGAPI\npng_get_libpng_ver(png_const_structp png_ptr)\n{\n   /* Version of *.c files used when building libpng */\n   return png_get_header_ver(png_ptr);\n}\n\npng_const_charp PNGAPI\npng_get_header_ver(png_const_structp png_ptr)\n{\n   /* Version of *.h files used when building libpng */\n   PNG_UNUSED(png_ptr)  /* Silence compiler warning about unused png_ptr */\n   return PNG_LIBPNG_VER_STRING;\n}\n\npng_const_charp PNGAPI\npng_get_header_version(png_const_structp png_ptr)\n{\n   /* Returns longer string containing both version and date */\n   PNG_UNUSED(png_ptr)  /* Silence compiler warning about unused png_ptr */\n#ifdef __STDC__\n   return PNG_HEADER_VERSION_STRING\n#  ifndef PNG_READ_SUPPORTED\n   \"     (NO READ SUPPORT)\"\n#  endif\n   PNG_STRING_NEWLINE;\n#else\n   return PNG_HEADER_VERSION_STRING;\n#endif\n}\n\n#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED\nint PNGAPI\npng_handle_as_unknown(png_structp png_ptr, png_const_bytep chunk_name)\n{\n   /* Check chunk_name and return \"keep\" value if it's on the list, else 0 */\n   png_const_bytep p, p_end;\n\n   if (png_ptr == NULL || chunk_name == NULL || png_ptr->num_chunk_list <= 0)\n      return PNG_HANDLE_CHUNK_AS_DEFAULT;\n\n   p_end = png_ptr->chunk_list;\n   p = p_end + png_ptr->num_chunk_list*5; /* beyond end */\n\n   /* The code is the fifth byte after each four byte string.  Historically this\n    * code was always searched from the end of the list, so it should continue\n    * to do so in case there are duplicated entries.\n    */\n   do /* num_chunk_list > 0, so at least one */\n   {\n      p -= 5;\n      if (!png_memcmp(chunk_name, p, 4))\n         return p[4];\n   }\n   while (p > p_end);\n\n   return PNG_HANDLE_CHUNK_AS_DEFAULT;\n}\n\nint /* PRIVATE */\npng_chunk_unknown_handling(png_structp png_ptr, png_uint_32 chunk_name)\n{\n   png_byte chunk_string[5];\n\n   PNG_CSTRING_FROM_CHUNK(chunk_string, chunk_name);\n   return png_handle_as_unknown(png_ptr, chunk_string);\n}\n#endif\n\n#ifdef PNG_READ_SUPPORTED\n/* This function, added to libpng-1.0.6g, is untested. */\nint PNGAPI\npng_reset_zstream(png_structp png_ptr)\n{\n   if (png_ptr == NULL)\n      return Z_STREAM_ERROR;\n\n   return (inflateReset(&png_ptr->zstream));\n}\n#endif /* PNG_READ_SUPPORTED */\n\n/* This function was added to libpng-1.0.7 */\npng_uint_32 PNGAPI\npng_access_version_number(void)\n{\n   /* Version of *.c files used when building libpng */\n   return((png_uint_32)PNG_LIBPNG_VER);\n}\n\n\n\n#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)\n/* png_convert_size: a PNGAPI but no longer in png.h, so deleted\n * at libpng 1.5.5!\n */\n\n/* Added at libpng version 1.2.34 and 1.4.0 (moved from pngset.c) */\n#  ifdef PNG_CHECK_cHRM_SUPPORTED\n\nint /* PRIVATE */\npng_check_cHRM_fixed(png_structp png_ptr,\n   png_fixed_point white_x, png_fixed_point white_y, png_fixed_point red_x,\n   png_fixed_point red_y, png_fixed_point green_x, png_fixed_point green_y,\n   png_fixed_point blue_x, png_fixed_point blue_y)\n{\n   int ret = 1;\n   unsigned long xy_hi,xy_lo,yx_hi,yx_lo;\n\n   png_debug(1, \"in function png_check_cHRM_fixed\");\n\n   if (png_ptr == NULL)\n      return 0;\n\n   /* (x,y,z) values are first limited to 0..100000 (PNG_FP_1), the white\n    * y must also be greater than 0.  To test for the upper limit calculate\n    * (PNG_FP_1-y) - x must be <= to this for z to be >= 0 (and the expression\n    * cannot overflow.)  At this point we know x and y are >= 0 and (x+y) is\n    * <= PNG_FP_1.  The previous test on PNG_MAX_UINT_31 is removed because it\n    * pointless (and it produces compiler warnings!)\n    */\n   if (white_x < 0 || white_y <= 0 ||\n         red_x < 0 ||   red_y <  0 ||\n       green_x < 0 || green_y <  0 ||\n        blue_x < 0 ||  blue_y <  0)\n   {\n      png_warning(png_ptr,\n        \"Ignoring attempt to set negative chromaticity value\");\n      ret = 0;\n   }\n   /* And (x+y) must be <= PNG_FP_1 (so z is >= 0) */\n   if (white_x > PNG_FP_1 - white_y)\n   {\n      png_warning(png_ptr, \"Invalid cHRM white point\");\n      ret = 0;\n   }\n\n   if (red_x > PNG_FP_1 - red_y)\n   {\n      png_warning(png_ptr, \"Invalid cHRM red point\");\n      ret = 0;\n   }\n\n   if (green_x > PNG_FP_1 - green_y)\n   {\n      png_warning(png_ptr, \"Invalid cHRM green point\");\n      ret = 0;\n   }\n\n   if (blue_x > PNG_FP_1 - blue_y)\n   {\n      png_warning(png_ptr, \"Invalid cHRM blue point\");\n      ret = 0;\n   }\n\n   png_64bit_product(green_x - red_x, blue_y - red_y, &xy_hi, &xy_lo);\n   png_64bit_product(green_y - red_y, blue_x - red_x, &yx_hi, &yx_lo);\n\n   if (xy_hi == yx_hi && xy_lo == yx_lo)\n   {\n      png_warning(png_ptr,\n         \"Ignoring attempt to set cHRM RGB triangle with zero area\");\n      ret = 0;\n   }\n\n   return ret;\n}\n#  endif /* PNG_CHECK_cHRM_SUPPORTED */\n\n#ifdef PNG_cHRM_SUPPORTED\n/* Added at libpng-1.5.5 to support read and write of true CIEXYZ values for\n * cHRM, as opposed to using chromaticities.  These internal APIs return\n * non-zero on a parameter error.  The X, Y and Z values are required to be\n * positive and less than 1.0.\n */\nint png_xy_from_XYZ(png_xy *xy, png_XYZ XYZ)\n{\n   png_int_32 d, dwhite, whiteX, whiteY;\n\n   d = XYZ.redX + XYZ.redY + XYZ.redZ;\n   if (!png_muldiv(&xy->redx, XYZ.redX, PNG_FP_1, d)) return 1;\n   if (!png_muldiv(&xy->redy, XYZ.redY, PNG_FP_1, d)) return 1;\n   dwhite = d;\n   whiteX = XYZ.redX;\n   whiteY = XYZ.redY;\n\n   d = XYZ.greenX + XYZ.greenY + XYZ.greenZ;\n   if (!png_muldiv(&xy->greenx, XYZ.greenX, PNG_FP_1, d)) return 1;\n   if (!png_muldiv(&xy->greeny, XYZ.greenY, PNG_FP_1, d)) return 1;\n   dwhite += d;\n   whiteX += XYZ.greenX;\n   whiteY += XYZ.greenY;\n\n   d = XYZ.blueX + XYZ.blueY + XYZ.blueZ;\n   if (!png_muldiv(&xy->bluex, XYZ.blueX, PNG_FP_1, d)) return 1;\n   if (!png_muldiv(&xy->bluey, XYZ.blueY, PNG_FP_1, d)) return 1;\n   dwhite += d;\n   whiteX += XYZ.blueX;\n   whiteY += XYZ.blueY;\n\n   /* The reference white is simply the same of the end-point (X,Y,Z) vectors,\n    * thus:\n    */\n   if (!png_muldiv(&xy->whitex, whiteX, PNG_FP_1, dwhite)) return 1;\n   if (!png_muldiv(&xy->whitey, whiteY, PNG_FP_1, dwhite)) return 1;\n\n   return 0;\n}\n\nint png_XYZ_from_xy(png_XYZ *XYZ, png_xy xy)\n{\n   png_fixed_point red_inverse, green_inverse, blue_scale;\n   png_fixed_point left, right, denominator;\n\n   /* Check xy and, implicitly, z.  Note that wide gamut color spaces typically\n    * have end points with 0 tristimulus values (these are impossible end\n    * points, but they are used to cover the possible colors.)\n    */\n   if (xy.redx < 0 || xy.redx > PNG_FP_1) return 1;\n   if (xy.redy < 0 || xy.redy > PNG_FP_1-xy.redx) return 1;\n   if (xy.greenx < 0 || xy.greenx > PNG_FP_1) return 1;\n   if (xy.greeny < 0 || xy.greeny > PNG_FP_1-xy.greenx) return 1;\n   if (xy.bluex < 0 || xy.bluex > PNG_FP_1) return 1;\n   if (xy.bluey < 0 || xy.bluey > PNG_FP_1-xy.bluex) return 1;\n   if (xy.whitex < 0 || xy.whitex > PNG_FP_1) return 1;\n   if (xy.whitey < 0 || xy.whitey > PNG_FP_1-xy.whitex) return 1;\n\n   /* The reverse calculation is more difficult because the original tristimulus\n    * value had 9 independent values (red,green,blue)x(X,Y,Z) however only 8\n    * derived values were recorded in the cHRM chunk;\n    * (red,green,blue,white)x(x,y).  This loses one degree of freedom and\n    * therefore an arbitrary ninth value has to be introduced to undo the\n    * original transformations.\n    *\n    * Think of the original end-points as points in (X,Y,Z) space.  The\n    * chromaticity values (c) have the property:\n    *\n    *           C\n    *   c = ---------\n    *       X + Y + Z\n    *\n    * For each c (x,y,z) from the corresponding original C (X,Y,Z).  Thus the\n    * three chromaticity values (x,y,z) for each end-point obey the\n    * relationship:\n    *\n    *   x + y + z = 1\n    *\n    * This describes the plane in (X,Y,Z) space that intersects each axis at the\n    * value 1.0; call this the chromaticity plane.  Thus the chromaticity\n    * calculation has scaled each end-point so that it is on the x+y+z=1 plane\n    * and chromaticity is the intersection of the vector from the origin to the\n    * (X,Y,Z) value with the chromaticity plane.\n    *\n    * To fully invert the chromaticity calculation we would need the three\n    * end-point scale factors, (red-scale, green-scale, blue-scale), but these\n    * were not recorded.  Instead we calculated the reference white (X,Y,Z) and\n    * recorded the chromaticity of this.  The reference white (X,Y,Z) would have\n    * given all three of the scale factors since:\n    *\n    *    color-C = color-c * color-scale\n    *    white-C = red-C + green-C + blue-C\n    *            = red-c*red-scale + green-c*green-scale + blue-c*blue-scale\n    *\n    * But cHRM records only white-x and white-y, so we have lost the white scale\n    * factor:\n    *\n    *    white-C = white-c*white-scale\n    *\n    * To handle this the inverse transformation makes an arbitrary assumption\n    * about white-scale:\n    *\n    *    Assume: white-Y = 1.0\n    *    Hence:  white-scale = 1/white-y\n    *    Or:     red-Y + green-Y + blue-Y = 1.0\n    *\n    * Notice the last statement of the assumption gives an equation in three of\n    * the nine values we want to calculate.  8 more equations come from the\n    * above routine as summarised at the top above (the chromaticity\n    * calculation):\n    *\n    *    Given: color-x = color-X / (color-X + color-Y + color-Z)\n    *    Hence: (color-x - 1)*color-X + color.x*color-Y + color.x*color-Z = 0\n    *\n    * This is 9 simultaneous equations in the 9 variables \"color-C\" and can be\n    * solved by Cramer's rule.  Cramer's rule requires calculating 10 9x9 matrix\n    * determinants, however this is not as bad as it seems because only 28 of\n    * the total of 90 terms in the various matrices are non-zero.  Nevertheless\n    * Cramer's rule is notoriously numerically unstable because the determinant\n    * calculation involves the difference of large, but similar, numbers.  It is\n    * difficult to be sure that the calculation is stable for real world values\n    * and it is certain that it becomes unstable where the end points are close\n    * together.\n    *\n    * So this code uses the perhaps slighly less optimal but more understandable\n    * and totally obvious approach of calculating color-scale.\n    *\n    * This algorithm depends on the precision in white-scale and that is\n    * (1/white-y), so we can immediately see that as white-y approaches 0 the\n    * accuracy inherent in the cHRM chunk drops off substantially.\n    *\n    * libpng arithmetic: a simple invertion of the above equations\n    * ------------------------------------------------------------\n    *\n    *    white_scale = 1/white-y\n    *    white-X = white-x * white-scale\n    *    white-Y = 1.0\n    *    white-Z = (1 - white-x - white-y) * white_scale\n    *\n    *    white-C = red-C + green-C + blue-C\n    *            = red-c*red-scale + green-c*green-scale + blue-c*blue-scale\n    *\n    * This gives us three equations in (red-scale,green-scale,blue-scale) where\n    * all the coefficients are now known:\n    *\n    *    red-x*red-scale + green-x*green-scale + blue-x*blue-scale\n    *       = white-x/white-y\n    *    red-y*red-scale + green-y*green-scale + blue-y*blue-scale = 1\n    *    red-z*red-scale + green-z*green-scale + blue-z*blue-scale\n    *       = (1 - white-x - white-y)/white-y\n    *\n    * In the last equation color-z is (1 - color-x - color-y) so we can add all\n    * three equations together to get an alternative third:\n    *\n    *    red-scale + green-scale + blue-scale = 1/white-y = white-scale\n    *\n    * So now we have a Cramer's rule solution where the determinants are just\n    * 3x3 - far more tractible.  Unfortunately 3x3 determinants still involve\n    * multiplication of three coefficients so we can't guarantee to avoid\n    * overflow in the libpng fixed point representation.  Using Cramer's rule in\n    * floating point is probably a good choice here, but it's not an option for\n    * fixed point.  Instead proceed to simplify the first two equations by\n    * eliminating what is likely to be the largest value, blue-scale:\n    *\n    *    blue-scale = white-scale - red-scale - green-scale\n    *\n    * Hence:\n    *\n    *    (red-x - blue-x)*red-scale + (green-x - blue-x)*green-scale =\n    *                (white-x - blue-x)*white-scale\n    *\n    *    (red-y - blue-y)*red-scale + (green-y - blue-y)*green-scale =\n    *                1 - blue-y*white-scale\n    *\n    * And now we can trivially solve for (red-scale,green-scale):\n    *\n    *    green-scale =\n    *                (white-x - blue-x)*white-scale - (red-x - blue-x)*red-scale\n    *                -----------------------------------------------------------\n    *                                  green-x - blue-x\n    *\n    *    red-scale =\n    *                1 - blue-y*white-scale - (green-y - blue-y) * green-scale\n    *                ---------------------------------------------------------\n    *                                  red-y - blue-y\n    *\n    * Hence:\n    *\n    *    red-scale =\n    *          ( (green-x - blue-x) * (white-y - blue-y) -\n    *            (green-y - blue-y) * (white-x - blue-x) ) / white-y\n    * -------------------------------------------------------------------------\n    *  (green-x - blue-x)*(red-y - blue-y)-(green-y - blue-y)*(red-x - blue-x)\n    *\n    *    green-scale =\n    *          ( (red-y - blue-y) * (white-x - blue-x) -\n    *            (red-x - blue-x) * (white-y - blue-y) ) / white-y\n    * -------------------------------------------------------------------------\n    *  (green-x - blue-x)*(red-y - blue-y)-(green-y - blue-y)*(red-x - blue-x)\n    *\n    * Accuracy:\n    * The input values have 5 decimal digits of accuracy.  The values are all in\n    * the range 0 < value < 1, so simple products are in the same range but may\n    * need up to 10 decimal digits to preserve the original precision and avoid\n    * underflow.  Because we are using a 32-bit signed representation we cannot\n    * match this; the best is a little over 9 decimal digits, less than 10.\n    *\n    * The approach used here is to preserve the maximum precision within the\n    * signed representation.  Because the red-scale calculation above uses the\n    * difference between two products of values that must be in the range -1..+1\n    * it is sufficient to divide the product by 7; ceil(100,000/32767*2).  The\n    * factor is irrelevant in the calculation because it is applied to both\n    * numerator and denominator.\n    *\n    * Note that the values of the differences of the products of the\n    * chromaticities in the above equations tend to be small, for example for\n    * the sRGB chromaticities they are:\n    *\n    * red numerator:    -0.04751\n    * green numerator:  -0.08788\n    * denominator:      -0.2241 (without white-y multiplication)\n    *\n    *  The resultant Y coefficients from the chromaticities of some widely used\n    *  color space definitions are (to 15 decimal places):\n    *\n    *  sRGB\n    *    0.212639005871510 0.715168678767756 0.072192315360734\n    *  Kodak ProPhoto\n    *    0.288071128229293 0.711843217810102 0.000085653960605\n    *  Adobe RGB\n    *    0.297344975250536 0.627363566255466 0.075291458493998\n    *  Adobe Wide Gamut RGB\n    *    0.258728243040113 0.724682314948566 0.016589442011321\n    */\n   /* By the argument, above overflow should be impossible here. The return\n    * value of 2 indicates an internal error to the caller.\n    */\n   if (!png_muldiv(&left, xy.greenx-xy.bluex, xy.redy - xy.bluey, 7)) return 2;\n   if (!png_muldiv(&right, xy.greeny-xy.bluey, xy.redx - xy.bluex, 7)) return 2;\n   denominator = left - right;\n\n   /* Now find the red numerator. */\n   if (!png_muldiv(&left, xy.greenx-xy.bluex, xy.whitey-xy.bluey, 7)) return 2;\n   if (!png_muldiv(&right, xy.greeny-xy.bluey, xy.whitex-xy.bluex, 7)) return 2;\n\n   /* Overflow is possible here and it indicates an extreme set of PNG cHRM\n    * chunk values.  This calculation actually returns the reciprocal of the\n    * scale value because this allows us to delay the multiplication of white-y\n    * into the denominator, which tends to produce a small number.\n    */\n   if (!png_muldiv(&red_inverse, xy.whitey, denominator, left-right) ||\n       red_inverse <= xy.whitey /* r+g+b scales = white scale */)\n      return 1;\n\n   /* Similarly for green_inverse: */\n   if (!png_muldiv(&left, xy.redy-xy.bluey, xy.whitex-xy.bluex, 7)) return 2;\n   if (!png_muldiv(&right, xy.redx-xy.bluex, xy.whitey-xy.bluey, 7)) return 2;\n   if (!png_muldiv(&green_inverse, xy.whitey, denominator, left-right) ||\n       green_inverse <= xy.whitey)\n      return 1;\n\n   /* And the blue scale, the checks above guarantee this can't overflow but it\n    * can still produce 0 for extreme cHRM values.\n    */\n   blue_scale = png_reciprocal(xy.whitey) - png_reciprocal(red_inverse) -\n      png_reciprocal(green_inverse);\n   if (blue_scale <= 0) return 1;\n\n\n   /* And fill in the png_XYZ: */\n   if (!png_muldiv(&XYZ->redX, xy.redx, PNG_FP_1, red_inverse)) return 1;\n   if (!png_muldiv(&XYZ->redY, xy.redy, PNG_FP_1, red_inverse)) return 1;\n   if (!png_muldiv(&XYZ->redZ, PNG_FP_1 - xy.redx - xy.redy, PNG_FP_1,\n      red_inverse))\n      return 1;\n\n   if (!png_muldiv(&XYZ->greenX, xy.greenx, PNG_FP_1, green_inverse)) return 1;\n   if (!png_muldiv(&XYZ->greenY, xy.greeny, PNG_FP_1, green_inverse)) return 1;\n   if (!png_muldiv(&XYZ->greenZ, PNG_FP_1 - xy.greenx - xy.greeny, PNG_FP_1,\n      green_inverse))\n      return 1;\n\n   if (!png_muldiv(&XYZ->blueX, xy.bluex, blue_scale, PNG_FP_1)) return 1;\n   if (!png_muldiv(&XYZ->blueY, xy.bluey, blue_scale, PNG_FP_1)) return 1;\n   if (!png_muldiv(&XYZ->blueZ, PNG_FP_1 - xy.bluex - xy.bluey, blue_scale,\n      PNG_FP_1))\n      return 1;\n\n   return 0; /*success*/\n}\n\nint png_XYZ_from_xy_checked(png_structp png_ptr, png_XYZ *XYZ, png_xy xy)\n{\n   switch (png_XYZ_from_xy(XYZ, xy))\n   {\n      case 0: /* success */\n         return 1;\n\n      case 1:\n         /* The chunk may be technically valid, but we got png_fixed_point\n          * overflow while trying to get XYZ values out of it.  This is\n          * entirely benign - the cHRM chunk is pretty extreme.\n          */\n         png_warning(png_ptr,\n            \"extreme cHRM chunk cannot be converted to tristimulus values\");\n         break;\n\n      default:\n         /* libpng is broken; this should be a warning but if it happens we\n          * want error reports so for the moment it is an error.\n          */\n         png_error(png_ptr, \"internal error in png_XYZ_from_xy\");\n         break;\n   }\n\n   /* ERROR RETURN */\n   return 0;\n}\n#endif\n\nvoid /* PRIVATE */\npng_check_IHDR(png_structp png_ptr,\n   png_uint_32 width, png_uint_32 height, int bit_depth,\n   int color_type, int interlace_type, int compression_type,\n   int filter_type)\n{\n   int error = 0;\n\n   /* Check for width and height valid values */\n   if (width == 0)\n   {\n      png_warning(png_ptr, \"Image width is zero in IHDR\");\n      error = 1;\n   }\n\n   if (height == 0)\n   {\n      png_warning(png_ptr, \"Image height is zero in IHDR\");\n      error = 1;\n   }\n\n#  ifdef PNG_SET_USER_LIMITS_SUPPORTED\n   if (width > png_ptr->user_width_max)\n\n#  else\n   if (width > PNG_USER_WIDTH_MAX)\n#  endif\n   {\n      png_warning(png_ptr, \"Image width exceeds user limit in IHDR\");\n      error = 1;\n   }\n\n#  ifdef PNG_SET_USER_LIMITS_SUPPORTED\n   if (height > png_ptr->user_height_max)\n#  else\n   if (height > PNG_USER_HEIGHT_MAX)\n#  endif\n   {\n      png_warning(png_ptr, \"Image height exceeds user limit in IHDR\");\n      error = 1;\n   }\n\n   if (width > PNG_UINT_31_MAX)\n   {\n      png_warning(png_ptr, \"Invalid image width in IHDR\");\n      error = 1;\n   }\n\n   if (height > PNG_UINT_31_MAX)\n   {\n      png_warning(png_ptr, \"Invalid image height in IHDR\");\n      error = 1;\n   }\n\n   if (width > (PNG_UINT_32_MAX\n                 >> 3)      /* 8-byte RGBA pixels */\n                 - 48       /* bigrowbuf hack */\n                 - 1        /* filter byte */\n                 - 7*8      /* rounding of width to multiple of 8 pixels */\n                 - 8)       /* extra max_pixel_depth pad */\n      png_warning(png_ptr, \"Width is too large for libpng to process pixels\");\n\n   /* Check other values */\n   if (bit_depth != 1 && bit_depth != 2 && bit_depth != 4 &&\n       bit_depth != 8 && bit_depth != 16)\n   {\n      png_warning(png_ptr, \"Invalid bit depth in IHDR\");\n      error = 1;\n   }\n\n   if (color_type < 0 || color_type == 1 ||\n       color_type == 5 || color_type > 6)\n   {\n      png_warning(png_ptr, \"Invalid color type in IHDR\");\n      error = 1;\n   }\n\n   if (((color_type == PNG_COLOR_TYPE_PALETTE) && bit_depth > 8) ||\n       ((color_type == PNG_COLOR_TYPE_RGB ||\n         color_type == PNG_COLOR_TYPE_GRAY_ALPHA ||\n         color_type == PNG_COLOR_TYPE_RGB_ALPHA) && bit_depth < 8))\n   {\n      png_warning(png_ptr, \"Invalid color type/bit depth combination in IHDR\");\n      error = 1;\n   }\n\n   if (interlace_type >= PNG_INTERLACE_LAST)\n   {\n      png_warning(png_ptr, \"Unknown interlace method in IHDR\");\n      error = 1;\n   }\n\n   if (compression_type != PNG_COMPRESSION_TYPE_BASE)\n   {\n      png_warning(png_ptr, \"Unknown compression method in IHDR\");\n      error = 1;\n   }\n\n#  ifdef PNG_MNG_FEATURES_SUPPORTED\n   /* Accept filter_method 64 (intrapixel differencing) only if\n    * 1. Libpng was compiled with PNG_MNG_FEATURES_SUPPORTED and\n    * 2. Libpng did not read a PNG signature (this filter_method is only\n    *    used in PNG datastreams that are embedded in MNG datastreams) and\n    * 3. The application called png_permit_mng_features with a mask that\n    *    included PNG_FLAG_MNG_FILTER_64 and\n    * 4. The filter_method is 64 and\n    * 5. The color_type is RGB or RGBA\n    */\n   if ((png_ptr->mode & PNG_HAVE_PNG_SIGNATURE) &&\n       png_ptr->mng_features_permitted)\n      png_warning(png_ptr, \"MNG features are not allowed in a PNG datastream\");\n\n   if (filter_type != PNG_FILTER_TYPE_BASE)\n   {\n      if (!((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) &&\n          (filter_type == PNG_INTRAPIXEL_DIFFERENCING) &&\n          ((png_ptr->mode & PNG_HAVE_PNG_SIGNATURE) == 0) &&\n          (color_type == PNG_COLOR_TYPE_RGB ||\n          color_type == PNG_COLOR_TYPE_RGB_ALPHA)))\n      {\n         png_warning(png_ptr, \"Unknown filter method in IHDR\");\n         error = 1;\n      }\n\n      if (png_ptr->mode & PNG_HAVE_PNG_SIGNATURE)\n      {\n         png_warning(png_ptr, \"Invalid filter method in IHDR\");\n         error = 1;\n      }\n   }\n\n#  else\n   if (filter_type != PNG_FILTER_TYPE_BASE)\n   {\n      png_warning(png_ptr, \"Unknown filter method in IHDR\");\n      error = 1;\n   }\n#  endif\n\n   if (error == 1)\n      png_error(png_ptr, \"Invalid IHDR data\");\n}\n\n#if defined(PNG_sCAL_SUPPORTED) || defined(PNG_pCAL_SUPPORTED)\n/* ASCII to fp functions */\n/* Check an ASCII formated floating point value, see the more detailed\n * comments in pngpriv.h\n */\n/* The following is used internally to preserve the sticky flags */\n#define png_fp_add(state, flags) ((state) |= (flags))\n#define png_fp_set(state, value) ((state) = (value) | ((state) & PNG_FP_STICKY))\n\nint /* PRIVATE */\npng_check_fp_number(png_const_charp string, png_size_t size, int *statep,\n   png_size_tp whereami)\n{\n   int state = *statep;\n   png_size_t i = *whereami;\n\n   while (i < size)\n   {\n      int type;\n      /* First find the type of the next character */\n      switch (string[i])\n      {\n      case 43:  type = PNG_FP_SAW_SIGN;                   break;\n      case 45:  type = PNG_FP_SAW_SIGN + PNG_FP_NEGATIVE; break;\n      case 46:  type = PNG_FP_SAW_DOT;                    break;\n      case 48:  type = PNG_FP_SAW_DIGIT;                  break;\n      case 49: case 50: case 51: case 52:\n      case 53: case 54: case 55: case 56:\n      case 57:  type = PNG_FP_SAW_DIGIT + PNG_FP_NONZERO; break;\n      case 69:\n      case 101: type = PNG_FP_SAW_E;                      break;\n      default:  goto PNG_FP_End;\n      }\n\n      /* Now deal with this type according to the current\n       * state, the type is arranged to not overlap the\n       * bits of the PNG_FP_STATE.\n       */\n      switch ((state & PNG_FP_STATE) + (type & PNG_FP_SAW_ANY))\n      {\n      case PNG_FP_INTEGER + PNG_FP_SAW_SIGN:\n         if (state & PNG_FP_SAW_ANY)\n            goto PNG_FP_End; /* not a part of the number */\n\n         png_fp_add(state, type);\n         break;\n\n      case PNG_FP_INTEGER + PNG_FP_SAW_DOT:\n         /* Ok as trailer, ok as lead of fraction. */\n         if (state & PNG_FP_SAW_DOT) /* two dots */\n            goto PNG_FP_End;\n\n         else if (state & PNG_FP_SAW_DIGIT) /* trailing dot? */\n            png_fp_add(state, type);\n\n         else\n            png_fp_set(state, PNG_FP_FRACTION | type);\n\n         break;\n\n      case PNG_FP_INTEGER + PNG_FP_SAW_DIGIT:\n         if (state & PNG_FP_SAW_DOT) /* delayed fraction */\n            png_fp_set(state, PNG_FP_FRACTION | PNG_FP_SAW_DOT);\n\n         png_fp_add(state, type | PNG_FP_WAS_VALID);\n\n         break;\n\n      case PNG_FP_INTEGER + PNG_FP_SAW_E:\n         if ((state & PNG_FP_SAW_DIGIT) == 0)\n            goto PNG_FP_End;\n\n         png_fp_set(state, PNG_FP_EXPONENT);\n\n         break;\n\n   /* case PNG_FP_FRACTION + PNG_FP_SAW_SIGN:\n         goto PNG_FP_End; ** no sign in fraction */\n\n   /* case PNG_FP_FRACTION + PNG_FP_SAW_DOT:\n         goto PNG_FP_End; ** Because SAW_DOT is always set */\n\n      case PNG_FP_FRACTION + PNG_FP_SAW_DIGIT:\n         png_fp_add(state, type | PNG_FP_WAS_VALID);\n         break;\n\n      case PNG_FP_FRACTION + PNG_FP_SAW_E:\n         /* This is correct because the trailing '.' on an\n          * integer is handled above - so we can only get here\n          * with the sequence \".E\" (with no preceding digits).\n          */\n         if ((state & PNG_FP_SAW_DIGIT) == 0)\n            goto PNG_FP_End;\n\n         png_fp_set(state, PNG_FP_EXPONENT);\n\n         break;\n\n      case PNG_FP_EXPONENT + PNG_FP_SAW_SIGN:\n         if (state & PNG_FP_SAW_ANY)\n            goto PNG_FP_End; /* not a part of the number */\n\n         png_fp_add(state, PNG_FP_SAW_SIGN);\n\n         break;\n\n   /* case PNG_FP_EXPONENT + PNG_FP_SAW_DOT:\n         goto PNG_FP_End; */\n\n      case PNG_FP_EXPONENT + PNG_FP_SAW_DIGIT:\n         png_fp_add(state, PNG_FP_SAW_DIGIT | PNG_FP_WAS_VALID);\n\n         break;\n\n   /* case PNG_FP_EXPONEXT + PNG_FP_SAW_E:\n         goto PNG_FP_End; */\n\n      default: goto PNG_FP_End; /* I.e. break 2 */\n      }\n\n      /* The character seems ok, continue. */\n      ++i;\n   }\n\nPNG_FP_End:\n   /* Here at the end, update the state and return the correct\n    * return code.\n    */\n   *statep = state;\n   *whereami = i;\n\n   return (state & PNG_FP_SAW_DIGIT) != 0;\n}\n\n\n/* The same but for a complete string. */\nint\npng_check_fp_string(png_const_charp string, png_size_t size)\n{\n   int        state=0;\n   png_size_t char_index=0;\n\n   if (png_check_fp_number(string, size, &state, &char_index) &&\n      (char_index == size || string[char_index] == 0))\n      return state /* must be non-zero - see above */;\n\n   return 0; /* i.e. fail */\n}\n#endif /* pCAL or sCAL */\n\n#ifdef PNG_READ_sCAL_SUPPORTED\n#  ifdef PNG_FLOATING_POINT_SUPPORTED\n/* Utility used below - a simple accurate power of ten from an integral\n * exponent.\n */\nstatic double\npng_pow10(int power)\n{\n   int recip = 0;\n   double d = 1;\n\n   /* Handle negative exponent with a reciprocal at the end because\n    * 10 is exact whereas .1 is inexact in base 2\n    */\n   if (power < 0)\n   {\n      if (power < DBL_MIN_10_EXP) return 0;\n      recip = 1, power = -power;\n   }\n\n   if (power > 0)\n   {\n      /* Decompose power bitwise. */\n      double mult = 10;\n      do\n      {\n         if (power & 1) d *= mult;\n         mult *= mult;\n         power >>= 1;\n      }\n      while (power > 0);\n\n      if (recip) d = 1/d;\n   }\n   /* else power is 0 and d is 1 */\n\n   return d;\n}\n\n/* Function to format a floating point value in ASCII with a given\n * precision.\n */\nvoid /* PRIVATE */\npng_ascii_from_fp(png_structp png_ptr, png_charp ascii, png_size_t size,\n    double fp, unsigned int precision)\n{\n   /* We use standard functions from math.h, but not printf because\n    * that would require stdio.  The caller must supply a buffer of\n    * sufficient size or we will png_error.  The tests on size and\n    * the space in ascii[] consumed are indicated below.\n    */\n   if (precision < 1)\n      precision = DBL_DIG;\n\n   /* Enforce the limit of the implementation precision too. */\n   if (precision > DBL_DIG+1)\n      precision = DBL_DIG+1;\n\n   /* Basic sanity checks */\n   if (size >= precision+5) /* See the requirements below. */\n   {\n      if (fp < 0)\n      {\n         fp = -fp;\n         *ascii++ = 45; /* '-'  PLUS 1 TOTAL 1 */\n         --size;\n      }\n\n      if (fp >= DBL_MIN && fp <= DBL_MAX)\n      {\n         int exp_b10;       /* A base 10 exponent */\n         double base;   /* 10^exp_b10 */\n\n         /* First extract a base 10 exponent of the number,\n          * the calculation below rounds down when converting\n          * from base 2 to base 10 (multiply by log10(2) -\n          * 0.3010, but 77/256 is 0.3008, so exp_b10 needs to\n          * be increased.  Note that the arithmetic shift\n          * performs a floor() unlike C arithmetic - using a\n          * C multiply would break the following for negative\n          * exponents.\n          */\n         (void)frexp(fp, &exp_b10); /* exponent to base 2 */\n\n         exp_b10 = (exp_b10 * 77) >> 8; /* <= exponent to base 10 */\n\n         /* Avoid underflow here. */\n         base = png_pow10(exp_b10); /* May underflow */\n\n         while (base < DBL_MIN || base < fp)\n         {\n            /* And this may overflow. */\n            double test = png_pow10(exp_b10+1);\n\n            if (test <= DBL_MAX)\n               ++exp_b10, base = test;\n\n            else\n               break;\n         }\n\n         /* Normalize fp and correct exp_b10, after this fp is in the\n          * range [.1,1) and exp_b10 is both the exponent and the digit\n          * *before* which the decimal point should be inserted\n          * (starting with 0 for the first digit).  Note that this\n          * works even if 10^exp_b10 is out of range because of the\n          * test on DBL_MAX above.\n          */\n         fp /= base;\n         while (fp >= 1) fp /= 10, ++exp_b10;\n\n         /* Because of the code above fp may, at this point, be\n          * less than .1, this is ok because the code below can\n          * handle the leading zeros this generates, so no attempt\n          * is made to correct that here.\n          */\n\n         {\n            int czero, clead, cdigits;\n            char exponent[10];\n\n            /* Allow up to two leading zeros - this will not lengthen\n             * the number compared to using E-n.\n             */\n            if (exp_b10 < 0 && exp_b10 > -3) /* PLUS 3 TOTAL 4 */\n            {\n               czero = -exp_b10; /* PLUS 2 digits: TOTAL 3 */\n               exp_b10 = 0;      /* Dot added below before first output. */\n            }\n            else\n               czero = 0;    /* No zeros to add */\n\n            /* Generate the digit list, stripping trailing zeros and\n             * inserting a '.' before a digit if the exponent is 0.\n             */\n            clead = czero; /* Count of leading zeros */\n            cdigits = 0;   /* Count of digits in list. */\n\n            do\n            {\n               double d;\n\n               fp *= 10;\n               /* Use modf here, not floor and subtract, so that\n                * the separation is done in one step.  At the end\n                * of the loop don't break the number into parts so\n                * that the final digit is rounded.\n                */\n               if (cdigits+czero-clead+1 < (int)precision)\n                  fp = modf(fp, &d);\n\n               else\n               {\n                  d = floor(fp + .5);\n\n                  if (d > 9)\n                  {\n                     /* Rounding up to 10, handle that here. */\n                     if (czero > 0)\n                     {\n                        --czero, d = 1;\n                        if (cdigits == 0) --clead;\n                     }\n                     else\n                     {\n                        while (cdigits > 0 && d > 9)\n                        {\n                           int ch = *--ascii;\n\n                           if (exp_b10 != (-1))\n                              ++exp_b10;\n\n                           else if (ch == 46)\n                           {\n                              ch = *--ascii, ++size;\n                              /* Advance exp_b10 to '1', so that the\n                               * decimal point happens after the\n                               * previous digit.\n                               */\n                              exp_b10 = 1;\n                           }\n\n                           --cdigits;\n                           d = ch - 47;  /* I.e. 1+(ch-48) */\n                        }\n\n                        /* Did we reach the beginning? If so adjust the\n                         * exponent but take into account the leading\n                         * decimal point.\n                         */\n                        if (d > 9)  /* cdigits == 0 */\n                        {\n                           if (exp_b10 == (-1))\n                           {\n                              /* Leading decimal point (plus zeros?), if\n                               * we lose the decimal point here it must\n                               * be reentered below.\n                               */\n                              int ch = *--ascii;\n\n                              if (ch == 46)\n                                 ++size, exp_b10 = 1;\n\n                              /* Else lost a leading zero, so 'exp_b10' is\n                               * still ok at (-1)\n                               */\n                           }\n                           else\n                              ++exp_b10;\n\n                           /* In all cases we output a '1' */\n                           d = 1;\n                        }\n                     }\n                  }\n                  fp = 0; /* Guarantees termination below. */\n               }\n\n               if (d == 0)\n               {\n                  ++czero;\n                  if (cdigits == 0) ++clead;\n               }\n               else\n               {\n                  /* Included embedded zeros in the digit count. */\n                  cdigits += czero - clead;\n                  clead = 0;\n\n                  while (czero > 0)\n                  {\n                     /* exp_b10 == (-1) means we just output the decimal\n                      * place - after the DP don't adjust 'exp_b10' any\n                      * more!\n                      */\n                     if (exp_b10 != (-1))\n                     {\n                        if (exp_b10 == 0) *ascii++ = 46, --size;\n                        /* PLUS 1: TOTAL 4 */\n                        --exp_b10;\n                     }\n                     *ascii++ = 48, --czero;\n                  }\n\n                  if (exp_b10 != (-1))\n                  {\n                     if (exp_b10 == 0) *ascii++ = 46, --size; /* counted\n                                                                 above */\n                     --exp_b10;\n                  }\n                  *ascii++ = (char)(48 + (int)d), ++cdigits;\n               }\n            }\n            while (cdigits+czero-clead < (int)precision && fp > DBL_MIN);\n\n            /* The total output count (max) is now 4+precision */\n\n            /* Check for an exponent, if we don't need one we are\n             * done and just need to terminate the string.  At\n             * this point exp_b10==(-1) is effectively if flag - it got\n             * to '-1' because of the decrement after outputing\n             * the decimal point above (the exponent required is\n             * *not* -1!)\n             */\n            if (exp_b10 >= (-1) && exp_b10 <= 2)\n            {\n               /* The following only happens if we didn't output the\n                * leading zeros above for negative exponent, so this\n                * doest add to the digit requirement.  Note that the\n                * two zeros here can only be output if the two leading\n                * zeros were *not* output, so this doesn't increase\n                * the output count.\n                */\n               while (--exp_b10 >= 0) *ascii++ = 48;\n\n               *ascii = 0;\n\n               /* Total buffer requirement (including the '\\0') is\n                * 5+precision - see check at the start.\n                */\n               return;\n            }\n\n            /* Here if an exponent is required, adjust size for\n             * the digits we output but did not count.  The total\n             * digit output here so far is at most 1+precision - no\n             * decimal point and no leading or trailing zeros have\n             * been output.\n             */\n            size -= cdigits;\n\n            *ascii++ = 69, --size;    /* 'E': PLUS 1 TOTAL 2+precision */\n\n            /* The following use of an unsigned temporary avoids ambiguities in\n             * the signed arithmetic on exp_b10 and permits GCC at least to do\n             * better optimization.\n             */\n            {\n               unsigned int uexp_b10;\n\n               if (exp_b10 < 0)\n               {\n                  *ascii++ = 45, --size; /* '-': PLUS 1 TOTAL 3+precision */\n                  uexp_b10 = -exp_b10;\n               }\n\n               else\n                  uexp_b10 = exp_b10;\n\n               cdigits = 0;\n\n               while (uexp_b10 > 0)\n               {\n                  exponent[cdigits++] = (char)(48 + uexp_b10 % 10);\n                  uexp_b10 /= 10;\n               }\n            }\n\n            /* Need another size check here for the exponent digits, so\n             * this need not be considered above.\n             */\n            if ((int)size > cdigits)\n            {\n               while (cdigits > 0) *ascii++ = exponent[--cdigits];\n\n               *ascii = 0;\n\n               return;\n            }\n         }\n      }\n      else if (!(fp >= DBL_MIN))\n      {\n         *ascii++ = 48; /* '0' */\n         *ascii = 0;\n         return;\n      }\n      else\n      {\n         *ascii++ = 105; /* 'i' */\n         *ascii++ = 110; /* 'n' */\n         *ascii++ = 102; /* 'f' */\n         *ascii = 0;\n         return;\n      }\n   }\n\n   /* Here on buffer too small. */\n   png_error(png_ptr, \"ASCII conversion buffer too small\");\n}\n\n#  endif /* FLOATING_POINT */\n\n#  ifdef PNG_FIXED_POINT_SUPPORTED\n/* Function to format a fixed point value in ASCII.\n */\nvoid /* PRIVATE */\npng_ascii_from_fixed(png_structp png_ptr, png_charp ascii, png_size_t size,\n    png_fixed_point fp)\n{\n   /* Require space for 10 decimal digits, a decimal point, a minus sign and a\n    * trailing \\0, 13 characters:\n    */\n   if (size > 12)\n   {\n      png_uint_32 num;\n\n      /* Avoid overflow here on the minimum integer. */\n      if (fp < 0)\n         *ascii++ = 45, --size, num = -fp;\n      else\n         num = fp;\n\n      if (num <= 0x80000000) /* else overflowed */\n      {\n         unsigned int ndigits = 0, first = 16 /* flag value */;\n         char digits[10];\n\n         while (num)\n         {\n            /* Split the low digit off num: */\n            unsigned int tmp = num/10;\n            num -= tmp*10;\n            digits[ndigits++] = (char)(48 + num);\n            /* Record the first non-zero digit, note that this is a number\n             * starting at 1, it's not actually the array index.\n             */\n            if (first == 16 && num > 0)\n               first = ndigits;\n            num = tmp;\n         }\n\n         if (ndigits > 0)\n         {\n            while (ndigits > 5) *ascii++ = digits[--ndigits];\n            /* The remaining digits are fractional digits, ndigits is '5' or\n             * smaller at this point.  It is certainly not zero.  Check for a\n             * non-zero fractional digit:\n             */\n            if (first <= 5)\n            {\n               unsigned int i;\n               *ascii++ = 46; /* decimal point */\n               /* ndigits may be <5 for small numbers, output leading zeros\n                * then ndigits digits to first:\n                */\n               i = 5;\n               while (ndigits < i) *ascii++ = 48, --i;\n               while (ndigits >= first) *ascii++ = digits[--ndigits];\n               /* Don't output the trailing zeros! */\n            }\n         }\n         else\n            *ascii++ = 48;\n\n         /* And null terminate the string: */\n         *ascii = 0;\n         return;\n      }\n   }\n\n   /* Here on buffer too small. */\n   png_error(png_ptr, \"ASCII conversion buffer too small\");\n}\n#   endif /* FIXED_POINT */\n#endif /* READ_SCAL */\n\n#if defined(PNG_FLOATING_POINT_SUPPORTED) && \\\n   !defined(PNG_FIXED_POINT_MACRO_SUPPORTED)\npng_fixed_point\npng_fixed(png_structp png_ptr, double fp, png_const_charp text)\n{\n   double r = floor(100000 * fp + .5);\n\n   if (r > 2147483647. || r < -2147483648.)\n      png_fixed_error(png_ptr, text);\n\n   return (png_fixed_point)r;\n}\n#endif\n\n#if defined(PNG_READ_GAMMA_SUPPORTED) || \\\n    defined(PNG_INCH_CONVERSIONS_SUPPORTED) || defined(PNG__READ_pHYs_SUPPORTED)\n/* muldiv functions */\n/* This API takes signed arguments and rounds the result to the nearest\n * integer (or, for a fixed point number - the standard argument - to\n * the nearest .00001).  Overflow and divide by zero are signalled in\n * the result, a boolean - true on success, false on overflow.\n */\nint\npng_muldiv(png_fixed_point_p res, png_fixed_point a, png_int_32 times,\n    png_int_32 divisor)\n{\n   /* Return a * times / divisor, rounded. */\n   if (divisor != 0)\n   {\n      if (a == 0 || times == 0)\n      {\n         *res = 0;\n         return 1;\n      }\n      else\n      {\n#ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED\n         double r = a;\n         r *= times;\n         r /= divisor;\n         r = floor(r+.5);\n\n         /* A png_fixed_point is a 32-bit integer. */\n         if (r <= 2147483647. && r >= -2147483648.)\n         {\n            *res = (png_fixed_point)r;\n            return 1;\n         }\n#else\n         int negative = 0;\n         png_uint_32 A, T, D;\n         png_uint_32 s16, s32, s00;\n\n         if (a < 0)\n            negative = 1, A = -a;\n         else\n            A = a;\n\n         if (times < 0)\n            negative = !negative, T = -times;\n         else\n            T = times;\n\n         if (divisor < 0)\n            negative = !negative, D = -divisor;\n         else\n            D = divisor;\n\n         /* Following can't overflow because the arguments only\n          * have 31 bits each, however the result may be 32 bits.\n          */\n         s16 = (A >> 16) * (T & 0xffff) +\n                           (A & 0xffff) * (T >> 16);\n         /* Can't overflow because the a*times bit is only 30\n          * bits at most.\n          */\n         s32 = (A >> 16) * (T >> 16) + (s16 >> 16);\n         s00 = (A & 0xffff) * (T & 0xffff);\n\n         s16 = (s16 & 0xffff) << 16;\n         s00 += s16;\n\n         if (s00 < s16)\n            ++s32; /* carry */\n\n         if (s32 < D) /* else overflow */\n         {\n            /* s32.s00 is now the 64-bit product, do a standard\n             * division, we know that s32 < D, so the maximum\n             * required shift is 31.\n             */\n            int bitshift = 32;\n            png_fixed_point result = 0; /* NOTE: signed */\n\n            while (--bitshift >= 0)\n            {\n               png_uint_32 d32, d00;\n\n               if (bitshift > 0)\n                  d32 = D >> (32-bitshift), d00 = D << bitshift;\n\n               else\n                  d32 = 0, d00 = D;\n\n               if (s32 > d32)\n               {\n                  if (s00 < d00) --s32; /* carry */\n                  s32 -= d32, s00 -= d00, result += 1<<bitshift;\n               }\n\n               else\n                  if (s32 == d32 && s00 >= d00)\n                     s32 = 0, s00 -= d00, result += 1<<bitshift;\n            }\n\n            /* Handle the rounding. */\n            if (s00 >= (D >> 1))\n               ++result;\n\n            if (negative)\n               result = -result;\n\n            /* Check for overflow. */\n            if ((negative && result <= 0) || (!negative && result >= 0))\n            {\n               *res = result;\n               return 1;\n            }\n         }\n#endif\n      }\n   }\n\n   return 0;\n}\n#endif /* READ_GAMMA || INCH_CONVERSIONS */\n\n#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_INCH_CONVERSIONS_SUPPORTED)\n/* The following is for when the caller doesn't much care about the\n * result.\n */\npng_fixed_point\npng_muldiv_warn(png_structp png_ptr, png_fixed_point a, png_int_32 times,\n    png_int_32 divisor)\n{\n   png_fixed_point result;\n\n   if (png_muldiv(&result, a, times, divisor))\n      return result;\n\n   png_warning(png_ptr, \"fixed point overflow ignored\");\n   return 0;\n}\n#endif\n\n#ifdef PNG_READ_GAMMA_SUPPORTED /* more fixed point functions for gammma */\n/* Calculate a reciprocal, return 0 on div-by-zero or overflow. */\npng_fixed_point\npng_reciprocal(png_fixed_point a)\n{\n#ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED\n   double r = floor(1E10/a+.5);\n\n   if (r <= 2147483647. && r >= -2147483648.)\n      return (png_fixed_point)r;\n#else\n   png_fixed_point res;\n\n   if (png_muldiv(&res, 100000, 100000, a))\n      return res;\n#endif\n\n   return 0; /* error/overflow */\n}\n\n/* A local convenience routine. */\nstatic png_fixed_point\npng_product2(png_fixed_point a, png_fixed_point b)\n{\n   /* The required result is 1/a * 1/b; the following preserves accuracy. */\n#ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED\n   double r = a * 1E-5;\n   r *= b;\n   r = floor(r+.5);\n\n   if (r <= 2147483647. && r >= -2147483648.)\n      return (png_fixed_point)r;\n#else\n   png_fixed_point res;\n\n   if (png_muldiv(&res, a, b, 100000))\n      return res;\n#endif\n\n   return 0; /* overflow */\n}\n\n/* The inverse of the above. */\npng_fixed_point\npng_reciprocal2(png_fixed_point a, png_fixed_point b)\n{\n   /* The required result is 1/a * 1/b; the following preserves accuracy. */\n#ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED\n   double r = 1E15/a;\n   r /= b;\n   r = floor(r+.5);\n\n   if (r <= 2147483647. && r >= -2147483648.)\n      return (png_fixed_point)r;\n#else\n   /* This may overflow because the range of png_fixed_point isn't symmetric,\n    * but this API is only used for the product of file and screen gamma so it\n    * doesn't matter that the smallest number it can produce is 1/21474, not\n    * 1/100000\n    */\n   png_fixed_point res = png_product2(a, b);\n\n   if (res != 0)\n      return png_reciprocal(res);\n#endif\n\n   return 0; /* overflow */\n}\n#endif /* READ_GAMMA */\n\n#ifdef PNG_CHECK_cHRM_SUPPORTED\n/* Added at libpng version 1.2.34 (Dec 8, 2008) and 1.4.0 (Jan 2,\n * 2010: moved from pngset.c) */\n/*\n *    Multiply two 32-bit numbers, V1 and V2, using 32-bit\n *    arithmetic, to produce a 64-bit result in the HI/LO words.\n *\n *                  A B\n *                x C D\n *               ------\n *              AD || BD\n *        AC || CB || 0\n *\n *    where A and B are the high and low 16-bit words of V1,\n *    C and D are the 16-bit words of V2, AD is the product of\n *    A and D, and X || Y is (X << 16) + Y.\n*/\n\nvoid /* PRIVATE */\npng_64bit_product (long v1, long v2, unsigned long *hi_product,\n    unsigned long *lo_product)\n{\n   int a, b, c, d;\n   long lo, hi, x, y;\n\n   a = (v1 >> 16) & 0xffff;\n   b = v1 & 0xffff;\n   c = (v2 >> 16) & 0xffff;\n   d = v2 & 0xffff;\n\n   lo = b * d;                   /* BD */\n   x = a * d + c * b;            /* AD + CB */\n   y = ((lo >> 16) & 0xffff) + x;\n\n   lo = (lo & 0xffff) | ((y & 0xffff) << 16);\n   hi = (y >> 16) & 0xffff;\n\n   hi += a * c;                  /* AC */\n\n   *hi_product = (unsigned long)hi;\n   *lo_product = (unsigned long)lo;\n}\n#endif /* CHECK_cHRM */\n\n#ifdef PNG_READ_GAMMA_SUPPORTED /* gamma table code */\n#ifndef PNG_FLOATING_ARITHMETIC_SUPPORTED\n/* Fixed point gamma.\n *\n * To calculate gamma this code implements fast log() and exp() calls using only\n * fixed point arithmetic.  This code has sufficient precision for either 8-bit\n * or 16-bit sample values.\n *\n * The tables used here were calculated using simple 'bc' programs, but C double\n * precision floating point arithmetic would work fine.  The programs are given\n * at the head of each table.\n *\n * 8-bit log table\n *   This is a table of -log(value/255)/log(2) for 'value' in the range 128 to\n *   255, so it's the base 2 logarithm of a normalized 8-bit floating point\n *   mantissa.  The numbers are 32-bit fractions.\n */\nstatic png_uint_32\npng_8bit_l2[128] =\n{\n#  ifdef PNG_DO_BC\n      for (i=128;i<256;++i) { .5 - l(i/255)/l(2)*65536*65536; }\n#  else\n   4270715492U, 4222494797U, 4174646467U, 4127164793U, 4080044201U, 4033279239U,\n   3986864580U, 3940795015U, 3895065449U, 3849670902U, 3804606499U, 3759867474U,\n   3715449162U, 3671346997U, 3627556511U, 3584073329U, 3540893168U, 3498011834U,\n   3455425220U, 3413129301U, 3371120137U, 3329393864U, 3287946700U, 3246774933U,\n   3205874930U, 3165243125U, 3124876025U, 3084770202U, 3044922296U, 3005329011U,\n   2965987113U, 2926893432U, 2888044853U, 2849438323U, 2811070844U, 2772939474U,\n   2735041326U, 2697373562U, 2659933400U, 2622718104U, 2585724991U, 2548951424U,\n   2512394810U, 2476052606U, 2439922311U, 2404001468U, 2368287663U, 2332778523U,\n   2297471715U, 2262364947U, 2227455964U, 2192742551U, 2158222529U, 2123893754U,\n   2089754119U, 2055801552U, 2022034013U, 1988449497U, 1955046031U, 1921821672U,\n   1888774511U, 1855902668U, 1823204291U, 1790677560U, 1758320682U, 1726131893U,\n   1694109454U, 1662251657U, 1630556815U, 1599023271U, 1567649391U, 1536433567U,\n   1505374214U, 1474469770U, 1443718700U, 1413119487U, 1382670639U, 1352370686U,\n   1322218179U, 1292211689U, 1262349810U, 1232631153U, 1203054352U, 1173618059U,\n   1144320946U, 1115161701U, 1086139034U, 1057251672U, 1028498358U, 999877854U,\n   971388940U, 943030410U, 914801076U, 886699767U, 858725327U, 830876614U,\n   803152505U, 775551890U, 748073672U, 720716771U, 693480120U, 666362667U,\n   639363374U, 612481215U, 585715177U, 559064263U, 532527486U, 506103872U,\n   479792461U, 453592303U, 427502463U, 401522014U, 375650043U, 349885648U,\n   324227938U, 298676034U, 273229066U, 247886176U, 222646516U, 197509248U,\n   172473545U, 147538590U, 122703574U, 97967701U, 73330182U, 48790236U,\n   24347096U, 0U\n#  endif\n\n#if 0\n   /* The following are the values for 16-bit tables - these work fine for the\n    * 8-bit conversions but produce very slightly larger errors in the 16-bit\n    * log (about 1.2 as opposed to 0.7 absolute error in the final value).  To\n    * use these all the shifts below must be adjusted appropriately.\n    */\n   65166, 64430, 63700, 62976, 62257, 61543, 60835, 60132, 59434, 58741, 58054,\n   57371, 56693, 56020, 55352, 54689, 54030, 53375, 52726, 52080, 51439, 50803,\n   50170, 49542, 48918, 48298, 47682, 47070, 46462, 45858, 45257, 44661, 44068,\n   43479, 42894, 42312, 41733, 41159, 40587, 40020, 39455, 38894, 38336, 37782,\n   37230, 36682, 36137, 35595, 35057, 34521, 33988, 33459, 32932, 32408, 31887,\n   31369, 30854, 30341, 29832, 29325, 28820, 28319, 27820, 27324, 26830, 26339,\n   25850, 25364, 24880, 24399, 23920, 23444, 22970, 22499, 22029, 21562, 21098,\n   20636, 20175, 19718, 19262, 18808, 18357, 17908, 17461, 17016, 16573, 16132,\n   15694, 15257, 14822, 14390, 13959, 13530, 13103, 12678, 12255, 11834, 11415,\n   10997, 10582, 10168, 9756, 9346, 8937, 8531, 8126, 7723, 7321, 6921, 6523,\n   6127, 5732, 5339, 4947, 4557, 4169, 3782, 3397, 3014, 2632, 2251, 1872, 1495,\n   1119, 744, 372\n#endif\n};\n\nPNG_STATIC png_int_32\npng_log8bit(unsigned int x)\n{\n   unsigned int lg2 = 0;\n   /* Each time 'x' is multiplied by 2, 1 must be subtracted off the final log,\n    * because the log is actually negate that means adding 1.  The final\n    * returned value thus has the range 0 (for 255 input) to 7.994 (for 1\n    * input), return 7.99998 for the overflow (log 0) case - so the result is\n    * always at most 19 bits.\n    */\n   if ((x &= 0xff) == 0)\n      return 0xffffffff;\n\n   if ((x & 0xf0) == 0)\n      lg2  = 4, x <<= 4;\n\n   if ((x & 0xc0) == 0)\n      lg2 += 2, x <<= 2;\n\n   if ((x & 0x80) == 0)\n      lg2 += 1, x <<= 1;\n\n   /* result is at most 19 bits, so this cast is safe: */\n   return (png_int_32)((lg2 << 16) + ((png_8bit_l2[x-128]+32768)>>16));\n}\n\n/* The above gives exact (to 16 binary places) log2 values for 8-bit images,\n * for 16-bit images we use the most significant 8 bits of the 16-bit value to\n * get an approximation then multiply the approximation by a correction factor\n * determined by the remaining up to 8 bits.  This requires an additional step\n * in the 16-bit case.\n *\n * We want log2(value/65535), we have log2(v'/255), where:\n *\n *    value = v' * 256 + v''\n *          = v' * f\n *\n * So f is value/v', which is equal to (256+v''/v') since v' is in the range 128\n * to 255 and v'' is in the range 0 to 255 f will be in the range 256 to less\n * than 258.  The final factor also needs to correct for the fact that our 8-bit\n * value is scaled by 255, whereas the 16-bit values must be scaled by 65535.\n *\n * This gives a final formula using a calculated value 'x' which is value/v' and\n * scaling by 65536 to match the above table:\n *\n *   log2(x/257) * 65536\n *\n * Since these numbers are so close to '1' we can use simple linear\n * interpolation between the two end values 256/257 (result -368.61) and 258/257\n * (result 367.179).  The values used below are scaled by a further 64 to give\n * 16-bit precision in the interpolation:\n *\n * Start (256): -23591\n * Zero  (257):      0\n * End   (258):  23499\n */\nPNG_STATIC png_int_32\npng_log16bit(png_uint_32 x)\n{\n   unsigned int lg2 = 0;\n\n   /* As above, but now the input has 16 bits. */\n   if ((x &= 0xffff) == 0)\n      return 0xffffffff;\n\n   if ((x & 0xff00) == 0)\n      lg2  = 8, x <<= 8;\n\n   if ((x & 0xf000) == 0)\n      lg2 += 4, x <<= 4;\n\n   if ((x & 0xc000) == 0)\n      lg2 += 2, x <<= 2;\n\n   if ((x & 0x8000) == 0)\n      lg2 += 1, x <<= 1;\n\n   /* Calculate the base logarithm from the top 8 bits as a 28-bit fractional\n    * value.\n    */\n   lg2 <<= 28;\n   lg2 += (png_8bit_l2[(x>>8)-128]+8) >> 4;\n\n   /* Now we need to interpolate the factor, this requires a division by the top\n    * 8 bits.  Do this with maximum precision.\n    */\n   x = ((x << 16) + (x >> 9)) / (x >> 8);\n\n   /* Since we divided by the top 8 bits of 'x' there will be a '1' at 1<<24,\n    * the value at 1<<16 (ignoring this) will be 0 or 1; this gives us exactly\n    * 16 bits to interpolate to get the low bits of the result.  Round the\n    * answer.  Note that the end point values are scaled by 64 to retain overall\n    * precision and that 'lg2' is current scaled by an extra 12 bits, so adjust\n    * the overall scaling by 6-12.  Round at every step.\n    */\n   x -= 1U << 24;\n\n   if (x <= 65536U) /* <= '257' */\n      lg2 += ((23591U * (65536U-x)) + (1U << (16+6-12-1))) >> (16+6-12);\n\n   else\n      lg2 -= ((23499U * (x-65536U)) + (1U << (16+6-12-1))) >> (16+6-12);\n\n   /* Safe, because the result can't have more than 20 bits: */\n   return (png_int_32)((lg2 + 2048) >> 12);\n}\n\n/* The 'exp()' case must invert the above, taking a 20-bit fixed point\n * logarithmic value and returning a 16 or 8-bit number as appropriate.  In\n * each case only the low 16 bits are relevant - the fraction - since the\n * integer bits (the top 4) simply determine a shift.\n *\n * The worst case is the 16-bit distinction between 65535 and 65534, this\n * requires perhaps spurious accuracy in the decoding of the logarithm to\n * distinguish log2(65535/65534.5) - 10^-5 or 17 bits.  There is little chance\n * of getting this accuracy in practice.\n *\n * To deal with this the following exp() function works out the exponent of the\n * frational part of the logarithm by using an accurate 32-bit value from the\n * top four fractional bits then multiplying in the remaining bits.\n */\nstatic png_uint_32\npng_32bit_exp[16] =\n{\n#  ifdef PNG_DO_BC\n      for (i=0;i<16;++i) { .5 + e(-i/16*l(2))*2^32; }\n#  else\n   /* NOTE: the first entry is deliberately set to the maximum 32-bit value. */\n   4294967295U, 4112874773U, 3938502376U, 3771522796U, 3611622603U, 3458501653U,\n   3311872529U, 3171459999U, 3037000500U, 2908241642U, 2784941738U, 2666869345U,\n   2553802834U, 2445529972U, 2341847524U, 2242560872U\n#  endif\n};\n\n/* Adjustment table; provided to explain the numbers in the code below. */\n#ifdef PNG_DO_BC\nfor (i=11;i>=0;--i){ print i, \" \", (1 - e(-(2^i)/65536*l(2))) * 2^(32-i), \"\\n\"}\n   11 44937.64284865548751208448\n   10 45180.98734845585101160448\n    9 45303.31936980687359311872\n    8 45364.65110595323018870784\n    7 45395.35850361789624614912\n    6 45410.72259715102037508096\n    5 45418.40724413220722311168\n    4 45422.25021786898173001728\n    3 45424.17186732298419044352\n    2 45425.13273269940811464704\n    1 45425.61317555035558641664\n    0 45425.85339951654943850496\n#endif\n\nPNG_STATIC png_uint_32\npng_exp(png_fixed_point x)\n{\n   if (x > 0 && x <= 0xfffff) /* Else overflow or zero (underflow) */\n   {\n      /* Obtain a 4-bit approximation */\n      png_uint_32 e = png_32bit_exp[(x >> 12) & 0xf];\n\n      /* Incorporate the low 12 bits - these decrease the returned value by\n       * multiplying by a number less than 1 if the bit is set.  The multiplier\n       * is determined by the above table and the shift. Notice that the values\n       * converge on 45426 and this is used to allow linear interpolation of the\n       * low bits.\n       */\n      if (x & 0x800)\n         e -= (((e >> 16) * 44938U) +  16U) >> 5;\n\n      if (x & 0x400)\n         e -= (((e >> 16) * 45181U) +  32U) >> 6;\n\n      if (x & 0x200)\n         e -= (((e >> 16) * 45303U) +  64U) >> 7;\n\n      if (x & 0x100)\n         e -= (((e >> 16) * 45365U) + 128U) >> 8;\n\n      if (x & 0x080)\n         e -= (((e >> 16) * 45395U) + 256U) >> 9;\n\n      if (x & 0x040)\n         e -= (((e >> 16) * 45410U) + 512U) >> 10;\n\n      /* And handle the low 6 bits in a single block. */\n      e -= (((e >> 16) * 355U * (x & 0x3fU)) + 256U) >> 9;\n\n      /* Handle the upper bits of x. */\n      e >>= x >> 16;\n      return e;\n   }\n\n   /* Check for overflow */\n   if (x <= 0)\n      return png_32bit_exp[0];\n\n   /* Else underflow */\n   return 0;\n}\n\nPNG_STATIC png_byte\npng_exp8bit(png_fixed_point lg2)\n{\n   /* Get a 32-bit value: */\n   png_uint_32 x = png_exp(lg2);\n\n   /* Convert the 32-bit value to 0..255 by multiplying by 256-1, note that the\n    * second, rounding, step can't overflow because of the first, subtraction,\n    * step.\n    */\n   x -= x >> 8;\n   return (png_byte)((x + 0x7fffffU) >> 24);\n}\n\nPNG_STATIC png_uint_16\npng_exp16bit(png_fixed_point lg2)\n{\n   /* Get a 32-bit value: */\n   png_uint_32 x = png_exp(lg2);\n\n   /* Convert the 32-bit value to 0..65535 by multiplying by 65536-1: */\n   x -= x >> 16;\n   return (png_uint_16)((x + 32767U) >> 16);\n}\n#endif /* FLOATING_ARITHMETIC */\n\npng_byte\npng_gamma_8bit_correct(unsigned int value, png_fixed_point gamma_val)\n{\n   if (value > 0 && value < 255)\n   {\n#     ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED\n         double r = floor(255*pow(value/255.,gamma_val*.00001)+.5);\n         return (png_byte)r;\n#     else\n         png_int_32 lg2 = png_log8bit(value);\n         png_fixed_point res;\n\n         if (png_muldiv(&res, gamma_val, lg2, PNG_FP_1))\n            return png_exp8bit(res);\n\n         /* Overflow. */\n         value = 0;\n#     endif\n   }\n\n   return (png_byte)value;\n}\n\npng_uint_16\npng_gamma_16bit_correct(unsigned int value, png_fixed_point gamma_val)\n{\n   if (value > 0 && value < 65535)\n   {\n#     ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED\n         double r = floor(65535*pow(value/65535.,gamma_val*.00001)+.5);\n         return (png_uint_16)r;\n#     else\n         png_int_32 lg2 = png_log16bit(value);\n         png_fixed_point res;\n\n         if (png_muldiv(&res, gamma_val, lg2, PNG_FP_1))\n            return png_exp16bit(res);\n\n         /* Overflow. */\n         value = 0;\n#     endif\n   }\n\n   return (png_uint_16)value;\n}\n\n/* This does the right thing based on the bit_depth field of the\n * png_struct, interpreting values as 8-bit or 16-bit.  While the result\n * is nominally a 16-bit value if bit depth is 8 then the result is\n * 8-bit (as are the arguments.)\n */\npng_uint_16 /* PRIVATE */\npng_gamma_correct(png_structp png_ptr, unsigned int value,\n    png_fixed_point gamma_val)\n{\n   if (png_ptr->bit_depth == 8)\n      return png_gamma_8bit_correct(value, gamma_val);\n\n   else\n      return png_gamma_16bit_correct(value, gamma_val);\n}\n\n/* This is the shared test on whether a gamma value is 'significant' - whether\n * it is worth doing gamma correction.\n */\nint /* PRIVATE */\npng_gamma_significant(png_fixed_point gamma_val)\n{\n   return gamma_val < PNG_FP_1 - PNG_GAMMA_THRESHOLD_FIXED ||\n       gamma_val > PNG_FP_1 + PNG_GAMMA_THRESHOLD_FIXED;\n}\n\n/* Internal function to build a single 16-bit table - the table consists of\n * 'num' 256-entry subtables, where 'num' is determined by 'shift' - the amount\n * to shift the input values right (or 16-number_of_signifiant_bits).\n *\n * The caller is responsible for ensuring that the table gets cleaned up on\n * png_error (i.e. if one of the mallocs below fails) - i.e. the *table argument\n * should be somewhere that will be cleaned.\n */\nstatic void\npng_build_16bit_table(png_structp png_ptr, png_uint_16pp *ptable,\n   PNG_CONST unsigned int shift, PNG_CONST png_fixed_point gamma_val)\n{\n   /* Various values derived from 'shift': */\n   PNG_CONST unsigned int num = 1U << (8U - shift);\n   PNG_CONST unsigned int max = (1U << (16U - shift))-1U;\n   PNG_CONST unsigned int max_by_2 = 1U << (15U-shift);\n   unsigned int i;\n\n   png_uint_16pp table = *ptable =\n       (png_uint_16pp)png_calloc(png_ptr, num * png_sizeof(png_uint_16p));\n\n   for (i = 0; i < num; i++)\n   {\n      png_uint_16p sub_table = table[i] =\n          (png_uint_16p)png_malloc(png_ptr, 256 * png_sizeof(png_uint_16));\n\n      /* The 'threshold' test is repeated here because it can arise for one of\n       * the 16-bit tables even if the others don't hit it.\n       */\n      if (png_gamma_significant(gamma_val))\n      {\n         /* The old code would overflow at the end and this would cause the\n          * 'pow' function to return a result >1, resulting in an\n          * arithmetic error.  This code follows the spec exactly; ig is\n          * the recovered input sample, it always has 8-16 bits.\n          *\n          * We want input * 65535/max, rounded, the arithmetic fits in 32\n          * bits (unsigned) so long as max <= 32767.\n          */\n         unsigned int j;\n         for (j = 0; j < 256; j++)\n         {\n            png_uint_32 ig = (j << (8-shift)) + i;\n#           ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED\n               /* Inline the 'max' scaling operation: */\n               double d = floor(65535*pow(ig/(double)max, gamma_val*.00001)+.5);\n               sub_table[j] = (png_uint_16)d;\n#           else\n               if (shift)\n                  ig = (ig * 65535U + max_by_2)/max;\n\n               sub_table[j] = png_gamma_16bit_correct(ig, gamma_val);\n#           endif\n         }\n      }\n      else\n      {\n         /* We must still build a table, but do it the fast way. */\n         unsigned int j;\n\n         for (j = 0; j < 256; j++)\n         {\n            png_uint_32 ig = (j << (8-shift)) + i;\n\n            if (shift)\n               ig = (ig * 65535U + max_by_2)/max;\n\n            sub_table[j] = (png_uint_16)ig;\n         }\n      }\n   }\n}\n\n/* NOTE: this function expects the *inverse* of the overall gamma transformation\n * required.\n */\nstatic void\npng_build_16to8_table(png_structp png_ptr, png_uint_16pp *ptable,\n   PNG_CONST unsigned int shift, PNG_CONST png_fixed_point gamma_val)\n{\n   PNG_CONST unsigned int num = 1U << (8U - shift);\n   PNG_CONST unsigned int max = (1U << (16U - shift))-1U;\n   unsigned int i;\n   png_uint_32 last;\n\n   png_uint_16pp table = *ptable =\n       (png_uint_16pp)png_calloc(png_ptr, num * png_sizeof(png_uint_16p));\n\n   /* 'num' is the number of tables and also the number of low bits of the\n    * input 16-bit value used to select a table.  Each table is itself indexed\n    * by the high 8 bits of the value.\n    */\n   for (i = 0; i < num; i++)\n      table[i] = (png_uint_16p)png_malloc(png_ptr,\n          256 * png_sizeof(png_uint_16));\n\n   /* 'gamma_val' is set to the reciprocal of the value calculated above, so\n    * pow(out,g) is an *input* value.  'last' is the last input value set.\n    *\n    * In the loop 'i' is used to find output values.  Since the output is\n    * 8-bit there are only 256 possible values.  The tables are set up to\n    * select the closest possible output value for each input by finding\n    * the input value at the boundary between each pair of output values\n    * and filling the table up to that boundary with the lower output\n    * value.\n    *\n    * The boundary values are 0.5,1.5..253.5,254.5.  Since these are 9-bit\n    * values the code below uses a 16-bit value in i; the values start at\n    * 128.5 (for 0.5) and step by 257, for a total of 254 values (the last\n    * entries are filled with 255).  Start i at 128 and fill all 'last'\n    * table entries <= 'max'\n    */\n   last = 0;\n   for (i = 0; i < 255; ++i) /* 8-bit output value */\n   {\n      /* Find the corresponding maximum input value */\n      png_uint_16 out = (png_uint_16)(i * 257U); /* 16-bit output value */\n\n      /* Find the boundary value in 16 bits: */\n      png_uint_32 bound = png_gamma_16bit_correct(out+128U, gamma_val);\n\n      /* Adjust (round) to (16-shift) bits: */\n      bound = (bound * max + 32768U)/65535U + 1U;\n\n      while (last < bound)\n      {\n         table[last & (0xffU >> shift)][last >> (8U - shift)] = out;\n         last++;\n      }\n   }\n\n   /* And fill in the final entries. */\n   while (last < (num << 8))\n   {\n      table[last & (0xff >> shift)][last >> (8U - shift)] = 65535U;\n      last++;\n   }\n}\n\n/* Build a single 8-bit table: same as the 16-bit case but much simpler (and\n * typically much faster).  Note that libpng currently does no sBIT processing\n * (apparently contrary to the spec) so a 256-entry table is always generated.\n */\nstatic void\npng_build_8bit_table(png_structp png_ptr, png_bytepp ptable,\n   PNG_CONST png_fixed_point gamma_val)\n{\n   unsigned int i;\n   png_bytep table = *ptable = (png_bytep)png_malloc(png_ptr, 256);\n\n   if (png_gamma_significant(gamma_val)) for (i=0; i<256; i++)\n      table[i] = png_gamma_8bit_correct(i, gamma_val);\n\n   else for (i=0; i<256; ++i)\n      table[i] = (png_byte)i;\n}\n\n/* Used from png_read_destroy and below to release the memory used by the gamma\n * tables.\n */\nvoid /* PRIVATE */\npng_destroy_gamma_table(png_structp png_ptr)\n{\n   png_free(png_ptr, png_ptr->gamma_table);\n   png_ptr->gamma_table = NULL;\n\n   if (png_ptr->gamma_16_table != NULL)\n   {\n      int i;\n      int istop = (1 << (8 - png_ptr->gamma_shift));\n      for (i = 0; i < istop; i++)\n      {\n         png_free(png_ptr, png_ptr->gamma_16_table[i]);\n      }\n   png_free(png_ptr, png_ptr->gamma_16_table);\n   png_ptr->gamma_16_table = NULL;\n   }\n\n#if defined(PNG_READ_BACKGROUND_SUPPORTED) || \\\n   defined(PNG_READ_ALPHA_MODE_SUPPORTED) || \\\n   defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)\n   png_free(png_ptr, png_ptr->gamma_from_1);\n   png_ptr->gamma_from_1 = NULL;\n   png_free(png_ptr, png_ptr->gamma_to_1);\n   png_ptr->gamma_to_1 = NULL;\n\n   if (png_ptr->gamma_16_from_1 != NULL)\n   {\n      int i;\n      int istop = (1 << (8 - png_ptr->gamma_shift));\n      for (i = 0; i < istop; i++)\n      {\n         png_free(png_ptr, png_ptr->gamma_16_from_1[i]);\n      }\n   png_free(png_ptr, png_ptr->gamma_16_from_1);\n   png_ptr->gamma_16_from_1 = NULL;\n   }\n   if (png_ptr->gamma_16_to_1 != NULL)\n   {\n      int i;\n      int istop = (1 << (8 - png_ptr->gamma_shift));\n      for (i = 0; i < istop; i++)\n      {\n         png_free(png_ptr, png_ptr->gamma_16_to_1[i]);\n      }\n   png_free(png_ptr, png_ptr->gamma_16_to_1);\n   png_ptr->gamma_16_to_1 = NULL;\n   }\n#endif /* READ_BACKGROUND || READ_ALPHA_MODE || RGB_TO_GRAY */\n}\n\n/* We build the 8- or 16-bit gamma tables here.  Note that for 16-bit\n * tables, we don't make a full table if we are reducing to 8-bit in\n * the future.  Note also how the gamma_16 tables are segmented so that\n * we don't need to allocate > 64K chunks for a full 16-bit table.\n */\nvoid /* PRIVATE */\npng_build_gamma_table(png_structp png_ptr, int bit_depth)\n{\n  png_debug(1, \"in png_build_gamma_table\");\n\n  /* Remove any existing table; this copes with multiple calls to\n   * png_read_update_info.  The warning is because building the gamma tables\n   * multiple times is a performance hit - it's harmless but the ability to call\n   * png_read_update_info() multiple times is new in 1.5.6 so it seems sensible\n   * to warn if the app introduces such a hit.\n   */\n  if (png_ptr->gamma_table != NULL || png_ptr->gamma_16_table != NULL)\n  {\n    png_warning(png_ptr, \"gamma table being rebuilt\");\n    png_destroy_gamma_table(png_ptr);\n  }\n\n  if (bit_depth <= 8)\n  {\n     png_build_8bit_table(png_ptr, &png_ptr->gamma_table,\n         png_ptr->screen_gamma > 0 ?  png_reciprocal2(png_ptr->gamma,\n         png_ptr->screen_gamma) : PNG_FP_1);\n\n#if defined(PNG_READ_BACKGROUND_SUPPORTED) || \\\n   defined(PNG_READ_ALPHA_MODE_SUPPORTED) || \\\n   defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)\n     if (png_ptr->transformations & (PNG_COMPOSE | PNG_RGB_TO_GRAY))\n     {\n        png_build_8bit_table(png_ptr, &png_ptr->gamma_to_1,\n            png_reciprocal(png_ptr->gamma));\n\n        png_build_8bit_table(png_ptr, &png_ptr->gamma_from_1,\n            png_ptr->screen_gamma > 0 ?  png_reciprocal(png_ptr->screen_gamma) :\n            png_ptr->gamma/* Probably doing rgb_to_gray */);\n     }\n#endif /* READ_BACKGROUND || READ_ALPHA_MODE || RGB_TO_GRAY */\n  }\n  else\n  {\n     png_byte shift, sig_bit;\n\n     if (png_ptr->color_type & PNG_COLOR_MASK_COLOR)\n     {\n        sig_bit = png_ptr->sig_bit.red;\n\n        if (png_ptr->sig_bit.green > sig_bit)\n           sig_bit = png_ptr->sig_bit.green;\n\n        if (png_ptr->sig_bit.blue > sig_bit)\n           sig_bit = png_ptr->sig_bit.blue;\n     }\n     else\n        sig_bit = png_ptr->sig_bit.gray;\n\n     /* 16-bit gamma code uses this equation:\n      *\n      *   ov = table[(iv & 0xff) >> gamma_shift][iv >> 8]\n      *\n      * Where 'iv' is the input color value and 'ov' is the output value -\n      * pow(iv, gamma).\n      *\n      * Thus the gamma table consists of up to 256 256-entry tables.  The table\n      * is selected by the (8-gamma_shift) most significant of the low 8 bits of\n      * the color value then indexed by the upper 8 bits:\n      *\n      *   table[low bits][high 8 bits]\n      *\n      * So the table 'n' corresponds to all those 'iv' of:\n      *\n      *   <all high 8-bit values><n << gamma_shift>..<(n+1 << gamma_shift)-1>\n      *\n      */\n     if (sig_bit > 0 && sig_bit < 16U)\n        shift = (png_byte)(16U - sig_bit); /* shift == insignificant bits */\n\n     else\n        shift = 0; /* keep all 16 bits */\n\n     if (png_ptr->transformations & (PNG_16_TO_8 | PNG_SCALE_16_TO_8))\n     {\n        /* PNG_MAX_GAMMA_8 is the number of bits to keep - effectively\n         * the significant bits in the *input* when the output will\n         * eventually be 8 bits.  By default it is 11.\n         */\n        if (shift < (16U - PNG_MAX_GAMMA_8))\n           shift = (16U - PNG_MAX_GAMMA_8);\n     }\n\n     if (shift > 8U)\n        shift = 8U; /* Guarantees at least one table! */\n\n     png_ptr->gamma_shift = shift;\n\n#ifdef PNG_16BIT_SUPPORTED\n     /* NOTE: prior to 1.5.4 this test used to include PNG_BACKGROUND (now\n      * PNG_COMPOSE).  This effectively smashed the background calculation for\n      * 16-bit output because the 8-bit table assumes the result will be reduced\n      * to 8 bits.\n      */\n     if (png_ptr->transformations & (PNG_16_TO_8 | PNG_SCALE_16_TO_8))\n#endif\n         png_build_16to8_table(png_ptr, &png_ptr->gamma_16_table, shift,\n         png_ptr->screen_gamma > 0 ? png_product2(png_ptr->gamma,\n         png_ptr->screen_gamma) : PNG_FP_1);\n\n#ifdef PNG_16BIT_SUPPORTED\n     else\n         png_build_16bit_table(png_ptr, &png_ptr->gamma_16_table, shift,\n         png_ptr->screen_gamma > 0 ? png_reciprocal2(png_ptr->gamma,\n         png_ptr->screen_gamma) : PNG_FP_1);\n#endif\n\n#if defined(PNG_READ_BACKGROUND_SUPPORTED) || \\\n   defined(PNG_READ_ALPHA_MODE_SUPPORTED) || \\\n   defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)\n     if (png_ptr->transformations & (PNG_COMPOSE | PNG_RGB_TO_GRAY))\n     {\n        png_build_16bit_table(png_ptr, &png_ptr->gamma_16_to_1, shift,\n            png_reciprocal(png_ptr->gamma));\n\n        /* Notice that the '16 from 1' table should be full precision, however\n         * the lookup on this table still uses gamma_shift, so it can't be.\n         * TODO: fix this.\n         */\n        png_build_16bit_table(png_ptr, &png_ptr->gamma_16_from_1, shift,\n            png_ptr->screen_gamma > 0 ? png_reciprocal(png_ptr->screen_gamma) :\n            png_ptr->gamma/* Probably doing rgb_to_gray */);\n     }\n#endif /* READ_BACKGROUND || READ_ALPHA_MODE || RGB_TO_GRAY */\n  }\n}\n#endif /* READ_GAMMA */\n#endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */\n"
  },
  {
    "path": "Projects/Tools/PNGAlphaPremultiplier/Native/Source/LibPng/png.h",
    "content": "\n/* png.h - header file for PNG reference library\n *\n * libpng version 1.5.9 - February 18, 2012\n * Copyright (c) 1998-2012 Glenn Randers-Pehrson\n * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)\n * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)\n *\n * This code is released under the libpng license (See LICENSE, below)\n *\n * Authors and maintainers:\n *   libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat\n *   libpng versions 0.89c, June 1996, through 0.96, May 1997: Andreas Dilger\n *   libpng versions 0.97, January 1998, through 1.5.9 - February 18, 2012: Glenn\n *   See also \"Contributing Authors\", below.\n *\n * Note about libpng version numbers:\n *\n *   Due to various miscommunications, unforeseen code incompatibilities\n *   and occasional factors outside the authors' control, version numbering\n *   on the library has not always been consistent and straightforward.\n *   The following table summarizes matters since version 0.89c, which was\n *   the first widely used release:\n *\n *    source                 png.h  png.h  shared-lib\n *    version                string   int  version\n *    -------                ------ -----  ----------\n *    0.89c \"1.0 beta 3\"     0.89      89  1.0.89\n *    0.90  \"1.0 beta 4\"     0.90      90  0.90  [should have been 2.0.90]\n *    0.95  \"1.0 beta 5\"     0.95      95  0.95  [should have been 2.0.95]\n *    0.96  \"1.0 beta 6\"     0.96      96  0.96  [should have been 2.0.96]\n *    0.97b \"1.00.97 beta 7\" 1.00.97   97  1.0.1 [should have been 2.0.97]\n *    0.97c                  0.97      97  2.0.97\n *    0.98                   0.98      98  2.0.98\n *    0.99                   0.99      98  2.0.99\n *    0.99a-m                0.99      99  2.0.99\n *    1.00                   1.00     100  2.1.0 [100 should be 10000]\n *    1.0.0      (from here on, the   100  2.1.0 [100 should be 10000]\n *    1.0.1       png.h string is   10001  2.1.0\n *    1.0.1a-e    identical to the  10002  from here on, the shared library\n *    1.0.2       source version)   10002  is 2.V where V is the source code\n *    1.0.2a-b                      10003  version, except as noted.\n *    1.0.3                         10003\n *    1.0.3a-d                      10004\n *    1.0.4                         10004\n *    1.0.4a-f                      10005\n *    1.0.5 (+ 2 patches)           10005\n *    1.0.5a-d                      10006\n *    1.0.5e-r                      10100 (not source compatible)\n *    1.0.5s-v                      10006 (not binary compatible)\n *    1.0.6 (+ 3 patches)           10006 (still binary incompatible)\n *    1.0.6d-f                      10007 (still binary incompatible)\n *    1.0.6g                        10007\n *    1.0.6h                        10007  10.6h (testing xy.z so-numbering)\n *    1.0.6i                        10007  10.6i\n *    1.0.6j                        10007  2.1.0.6j (incompatible with 1.0.0)\n *    1.0.7beta11-14        DLLNUM  10007  2.1.0.7beta11-14 (binary compatible)\n *    1.0.7beta15-18           1    10007  2.1.0.7beta15-18 (binary compatible)\n *    1.0.7rc1-2               1    10007  2.1.0.7rc1-2 (binary compatible)\n *    1.0.7                    1    10007  (still compatible)\n *    1.0.8beta1-4             1    10008  2.1.0.8beta1-4\n *    1.0.8rc1                 1    10008  2.1.0.8rc1\n *    1.0.8                    1    10008  2.1.0.8\n *    1.0.9beta1-6             1    10009  2.1.0.9beta1-6\n *    1.0.9rc1                 1    10009  2.1.0.9rc1\n *    1.0.9beta7-10            1    10009  2.1.0.9beta7-10\n *    1.0.9rc2                 1    10009  2.1.0.9rc2\n *    1.0.9                    1    10009  2.1.0.9\n *    1.0.10beta1              1    10010  2.1.0.10beta1\n *    1.0.10rc1                1    10010  2.1.0.10rc1\n *    1.0.10                   1    10010  2.1.0.10\n *    1.0.11beta1-3            1    10011  2.1.0.11beta1-3\n *    1.0.11rc1                1    10011  2.1.0.11rc1\n *    1.0.11                   1    10011  2.1.0.11\n *    1.0.12beta1-2            2    10012  2.1.0.12beta1-2\n *    1.0.12rc1                2    10012  2.1.0.12rc1\n *    1.0.12                   2    10012  2.1.0.12\n *    1.1.0a-f                 -    10100  2.1.1.0a-f (branch abandoned)\n *    1.2.0beta1-2             2    10200  2.1.2.0beta1-2\n *    1.2.0beta3-5             3    10200  3.1.2.0beta3-5\n *    1.2.0rc1                 3    10200  3.1.2.0rc1\n *    1.2.0                    3    10200  3.1.2.0\n *    1.2.1beta1-4             3    10201  3.1.2.1beta1-4\n *    1.2.1rc1-2               3    10201  3.1.2.1rc1-2\n *    1.2.1                    3    10201  3.1.2.1\n *    1.2.2beta1-6            12    10202  12.so.0.1.2.2beta1-6\n *    1.0.13beta1             10    10013  10.so.0.1.0.13beta1\n *    1.0.13rc1               10    10013  10.so.0.1.0.13rc1\n *    1.2.2rc1                12    10202  12.so.0.1.2.2rc1\n *    1.0.13                  10    10013  10.so.0.1.0.13\n *    1.2.2                   12    10202  12.so.0.1.2.2\n *    1.2.3rc1-6              12    10203  12.so.0.1.2.3rc1-6\n *    1.2.3                   12    10203  12.so.0.1.2.3\n *    1.2.4beta1-3            13    10204  12.so.0.1.2.4beta1-3\n *    1.0.14rc1               13    10014  10.so.0.1.0.14rc1\n *    1.2.4rc1                13    10204  12.so.0.1.2.4rc1\n *    1.0.14                  10    10014  10.so.0.1.0.14\n *    1.2.4                   13    10204  12.so.0.1.2.4\n *    1.2.5beta1-2            13    10205  12.so.0.1.2.5beta1-2\n *    1.0.15rc1-3             10    10015  10.so.0.1.0.15rc1-3\n *    1.2.5rc1-3              13    10205  12.so.0.1.2.5rc1-3\n *    1.0.15                  10    10015  10.so.0.1.0.15\n *    1.2.5                   13    10205  12.so.0.1.2.5\n *    1.2.6beta1-4            13    10206  12.so.0.1.2.6beta1-4\n *    1.0.16                  10    10016  10.so.0.1.0.16\n *    1.2.6                   13    10206  12.so.0.1.2.6\n *    1.2.7beta1-2            13    10207  12.so.0.1.2.7beta1-2\n *    1.0.17rc1               10    10017  12.so.0.1.0.17rc1\n *    1.2.7rc1                13    10207  12.so.0.1.2.7rc1\n *    1.0.17                  10    10017  12.so.0.1.0.17\n *    1.2.7                   13    10207  12.so.0.1.2.7\n *    1.2.8beta1-5            13    10208  12.so.0.1.2.8beta1-5\n *    1.0.18rc1-5             10    10018  12.so.0.1.0.18rc1-5\n *    1.2.8rc1-5              13    10208  12.so.0.1.2.8rc1-5\n *    1.0.18                  10    10018  12.so.0.1.0.18\n *    1.2.8                   13    10208  12.so.0.1.2.8\n *    1.2.9beta1-3            13    10209  12.so.0.1.2.9beta1-3\n *    1.2.9beta4-11           13    10209  12.so.0.9[.0]\n *    1.2.9rc1                13    10209  12.so.0.9[.0]\n *    1.2.9                   13    10209  12.so.0.9[.0]\n *    1.2.10beta1-7           13    10210  12.so.0.10[.0]\n *    1.2.10rc1-2             13    10210  12.so.0.10[.0]\n *    1.2.10                  13    10210  12.so.0.10[.0]\n *    1.4.0beta1-5            14    10400  14.so.0.0[.0]\n *    1.2.11beta1-4           13    10211  12.so.0.11[.0]\n *    1.4.0beta7-8            14    10400  14.so.0.0[.0]\n *    1.2.11                  13    10211  12.so.0.11[.0]\n *    1.2.12                  13    10212  12.so.0.12[.0]\n *    1.4.0beta9-14           14    10400  14.so.0.0[.0]\n *    1.2.13                  13    10213  12.so.0.13[.0]\n *    1.4.0beta15-36          14    10400  14.so.0.0[.0]\n *    1.4.0beta37-87          14    10400  14.so.14.0[.0]\n *    1.4.0rc01               14    10400  14.so.14.0[.0]\n *    1.4.0beta88-109         14    10400  14.so.14.0[.0]\n *    1.4.0rc02-08            14    10400  14.so.14.0[.0]\n *    1.4.0                   14    10400  14.so.14.0[.0]\n *    1.4.1beta01-03          14    10401  14.so.14.1[.0]\n *    1.4.1rc01               14    10401  14.so.14.1[.0]\n *    1.4.1beta04-12          14    10401  14.so.14.1[.0]\n *    1.4.1                   14    10401  14.so.14.1[.0]\n *    1.4.2                   14    10402  14.so.14.2[.0]\n *    1.4.3                   14    10403  14.so.14.3[.0]\n *    1.4.4                   14    10404  14.so.14.4[.0]\n *    1.5.0beta01-58          15    10500  15.so.15.0[.0]\n *    1.5.0rc01-07            15    10500  15.so.15.0[.0]\n *    1.5.0                   15    10500  15.so.15.0[.0]\n *    1.5.1beta01-11          15    10501  15.so.15.1[.0]\n *    1.5.1rc01-02            15    10501  15.so.15.1[.0]\n *    1.5.1                   15    10501  15.so.15.1[.0]\n *    1.5.2beta01-03          15    10502  15.so.15.2[.0]\n *    1.5.2rc01-03            15    10502  15.so.15.2[.0]\n *    1.5.2                   15    10502  15.so.15.2[.0]\n *    1.5.3beta01-10          15    10503  15.so.15.3[.0]\n *    1.5.3rc01-02            15    10503  15.so.15.3[.0]\n *    1.5.3beta11             15    10503  15.so.15.3[.0]\n *    1.5.3 [omitted]\n *    1.5.4beta01-08          15    10504  15.so.15.4[.0]\n *    1.5.4rc01               15    10504  15.so.15.4[.0]\n *    1.5.4                   15    10504  15.so.15.4[.0]\n *    1.5.5beta01-08          15    10505  15.so.15.5[.0]\n *    1.5.5rc01               15    10505  15.so.15.5[.0]\n *    1.5.5                   15    10505  15.so.15.5[.0]\n *    1.5.6beta01-07          15    10506  15.so.15.6[.0]\n *    1.5.6rc01-03            15    10506  15.so.15.6[.0]\n *    1.5.6                   15    10506  15.so.15.6[.0]\n *    1.5.7beta01-05          15    10507  15.so.15.7[.0]\n *    1.5.7rc01-03            15    10507  15.so.15.7[.0]\n *    1.5.7                   15    10507  15.so.15.7[.0]\n *    1.5.8beta01             15    10508  15.so.15.8[.0]\n *    1.5.8rc01               15    10508  15.so.15.8[.0]\n *    1.5.8                   15    10508  15.so.15.8[.0]\n *    1.5.9beta01-02          15    10509  15.so.15.9[.0]\n *    1.5.9rc01               15    10509  15.so.15.9[.0]\n *    1.5.9                   15    10509  15.so.15.9[.0]\n *\n *   Henceforth the source version will match the shared-library major\n *   and minor numbers; the shared-library major version number will be\n *   used for changes in backward compatibility, as it is intended.  The\n *   PNG_LIBPNG_VER macro, which is not used within libpng but is available\n *   for applications, is an unsigned integer of the form xyyzz corresponding\n *   to the source version x.y.z (leading zeros in y and z).  Beta versions\n *   were given the previous public release number plus a letter, until\n *   version 1.0.6j; from then on they were given the upcoming public\n *   release number plus \"betaNN\" or \"rcN\".\n *\n *   Binary incompatibility exists only when applications make direct access\n *   to the info_ptr or png_ptr members through png.h, and the compiled\n *   application is loaded with a different version of the library.\n *\n *   DLLNUM will change each time there are forward or backward changes\n *   in binary compatibility (e.g., when a new feature is added).\n *\n * See libpng-manual.txt or libpng.3 for more information.  The PNG\n * specification is available as a W3C Recommendation and as an ISO\n * Specification, <http://www.w3.org/TR/2003/REC-PNG-20031110/\n */\n\n/*\n * COPYRIGHT NOTICE, DISCLAIMER, and LICENSE:\n *\n * If you modify libpng you may insert additional notices immediately following\n * this sentence.\n *\n * This code is released under the libpng license.\n *\n * libpng versions 1.2.6, August 15, 2004, through 1.5.9, February 18, 2012, are\n * Copyright (c) 2004, 2006-2012 Glenn Randers-Pehrson, and are\n * distributed according to the same disclaimer and license as libpng-1.2.5\n * with the following individual added to the list of Contributing Authors:\n *\n *    Cosmin Truta\n *\n * libpng versions 1.0.7, July 1, 2000, through 1.2.5, October 3, 2002, are\n * Copyright (c) 2000-2002 Glenn Randers-Pehrson, and are\n * distributed according to the same disclaimer and license as libpng-1.0.6\n * with the following individuals added to the list of Contributing Authors:\n *\n *    Simon-Pierre Cadieux\n *    Eric S. Raymond\n *    Gilles Vollant\n *\n * and with the following additions to the disclaimer:\n *\n *    There is no warranty against interference with your enjoyment of the\n *    library or against infringement.  There is no warranty that our\n *    efforts or the library will fulfill any of your particular purposes\n *    or needs.  This library is provided with all faults, and the entire\n *    risk of satisfactory quality, performance, accuracy, and effort is with\n *    the user.\n *\n * libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are\n * Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson, and are\n * distributed according to the same disclaimer and license as libpng-0.96,\n * with the following individuals added to the list of Contributing Authors:\n *\n *    Tom Lane\n *    Glenn Randers-Pehrson\n *    Willem van Schaik\n *\n * libpng versions 0.89, June 1996, through 0.96, May 1997, are\n * Copyright (c) 1996, 1997 Andreas Dilger\n * Distributed according to the same disclaimer and license as libpng-0.88,\n * with the following individuals added to the list of Contributing Authors:\n *\n *    John Bowler\n *    Kevin Bracey\n *    Sam Bushell\n *    Magnus Holmgren\n *    Greg Roelofs\n *    Tom Tanner\n *\n * libpng versions 0.5, May 1995, through 0.88, January 1996, are\n * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.\n *\n * For the purposes of this copyright and license, \"Contributing Authors\"\n * is defined as the following set of individuals:\n *\n *    Andreas Dilger\n *    Dave Martindale\n *    Guy Eric Schalnat\n *    Paul Schmidt\n *    Tim Wegner\n *\n * The PNG Reference Library is supplied \"AS IS\".  The Contributing Authors\n * and Group 42, Inc. disclaim all warranties, expressed or implied,\n * including, without limitation, the warranties of merchantability and of\n * fitness for any purpose.  The Contributing Authors and Group 42, Inc.\n * assume no liability for direct, indirect, incidental, special, exemplary,\n * or consequential damages, which may result from the use of the PNG\n * Reference Library, even if advised of the possibility of such damage.\n *\n * Permission is hereby granted to use, copy, modify, and distribute this\n * source code, or portions hereof, for any purpose, without fee, subject\n * to the following restrictions:\n *\n *   1. The origin of this source code must not be misrepresented.\n *\n *   2. Altered versions must be plainly marked as such and must not\n *      be misrepresented as being the original source.\n *\n *   3. This Copyright notice may not be removed or altered from\n *      any source or altered source distribution.\n *\n * The Contributing Authors and Group 42, Inc. specifically permit, without\n * fee, and encourage the use of this source code as a component to\n * supporting the PNG file format in commercial products.  If you use this\n * source code in a product, acknowledgment is not required but would be\n * appreciated.\n */\n\n/*\n * A \"png_get_copyright\" function is available, for convenient use in \"about\"\n * boxes and the like:\n *\n *     printf(\"%s\", png_get_copyright(NULL));\n *\n * Also, the PNG logo (in PNG format, of course) is supplied in the\n * files \"pngbar.png\" and \"pngbar.jpg (88x31) and \"pngnow.png\" (98x31).\n */\n\n/*\n * Libpng is OSI Certified Open Source Software.  OSI Certified is a\n * certification mark of the Open Source Initiative.\n */\n\n/*\n * The contributing authors would like to thank all those who helped\n * with testing, bug fixes, and patience.  This wouldn't have been\n * possible without all of you.\n *\n * Thanks to Frank J. T. Wojcik for helping with the documentation.\n */\n\n/*\n * Y2K compliance in libpng:\n * =========================\n *\n *    February 18, 2012\n *\n *    Since the PNG Development group is an ad-hoc body, we can't make\n *    an official declaration.\n *\n *    This is your unofficial assurance that libpng from version 0.71 and\n *    upward through 1.5.9 are Y2K compliant.  It is my belief that\n *    earlier versions were also Y2K compliant.\n *\n *    Libpng only has two year fields.  One is a 2-byte unsigned integer\n *    that will hold years up to 65535.  The other holds the date in text\n *    format, and will hold years up to 9999.\n *\n *    The integer is\n *        \"png_uint_16 year\" in png_time_struct.\n *\n *    The string is\n *        \"png_char time_buffer\" in png_struct\n *\n *    There are seven time-related functions:\n *        png.c: png_convert_to_rfc_1123() in png.c\n *          (formerly png_convert_to_rfc_1152() in error)\n *        png_convert_from_struct_tm() in pngwrite.c, called in pngwrite.c\n *        png_convert_from_time_t() in pngwrite.c\n *        png_get_tIME() in pngget.c\n *        png_handle_tIME() in pngrutil.c, called in pngread.c\n *        png_set_tIME() in pngset.c\n *        png_write_tIME() in pngwutil.c, called in pngwrite.c\n *\n *    All handle dates properly in a Y2K environment.  The\n *    png_convert_from_time_t() function calls gmtime() to convert from system\n *    clock time, which returns (year - 1900), which we properly convert to\n *    the full 4-digit year.  There is a possibility that applications using\n *    libpng are not passing 4-digit years into the png_convert_to_rfc_1123()\n *    function, or that they are incorrectly passing only a 2-digit year\n *    instead of \"year - 1900\" into the png_convert_from_struct_tm() function,\n *    but this is not under our control.  The libpng documentation has always\n *    stated that it works with 4-digit years, and the APIs have been\n *    documented as such.\n *\n *    The tIME chunk itself is also Y2K compliant.  It uses a 2-byte unsigned\n *    integer to hold the year, and can hold years as large as 65535.\n *\n *    zlib, upon which libpng depends, is also Y2K compliant.  It contains\n *    no date-related code.\n *\n *       Glenn Randers-Pehrson\n *       libpng maintainer\n *       PNG Development Group\n */\n\n#ifndef PNG_H\n#define PNG_H\n\n/* This is not the place to learn how to use libpng. The file libpng-manual.txt\n * describes how to use libpng, and the file example.c summarizes it\n * with some code on which to build.  This file is useful for looking\n * at the actual function definitions and structure components.\n *\n * If you just need to read a PNG file and don't want to read the documentation\n * skip to the end of this file and read the section entitled 'simplified API'.\n */\n\n/* Version information for png.h - this should match the version in png.c */\n#define PNG_LIBPNG_VER_STRING \"1.5.9\"\n#define PNG_HEADER_VERSION_STRING \\\n     \" libpng version 1.5.9 - February 18, 2012\\n\"\n\n#define PNG_LIBPNG_VER_SONUM   15\n#define PNG_LIBPNG_VER_DLLNUM  15\n\n/* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */\n#define PNG_LIBPNG_VER_MAJOR   1\n#define PNG_LIBPNG_VER_MINOR   5\n#define PNG_LIBPNG_VER_RELEASE 9\n\n/* This should match the numeric part of the final component of\n * PNG_LIBPNG_VER_STRING, omitting any leading zero:\n */\n\n#define PNG_LIBPNG_VER_BUILD  0\n\n/* Release Status */\n#define PNG_LIBPNG_BUILD_ALPHA    1\n#define PNG_LIBPNG_BUILD_BETA     2\n#define PNG_LIBPNG_BUILD_RC       3\n#define PNG_LIBPNG_BUILD_STABLE   4\n#define PNG_LIBPNG_BUILD_RELEASE_STATUS_MASK 7\n\n/* Release-Specific Flags */\n#define PNG_LIBPNG_BUILD_PATCH    8 /* Can be OR'ed with\n                                       PNG_LIBPNG_BUILD_STABLE only */\n#define PNG_LIBPNG_BUILD_PRIVATE 16 /* Cannot be OR'ed with\n                                       PNG_LIBPNG_BUILD_SPECIAL */\n#define PNG_LIBPNG_BUILD_SPECIAL 32 /* Cannot be OR'ed with\n                                       PNG_LIBPNG_BUILD_PRIVATE */\n\n#define PNG_LIBPNG_BUILD_BASE_TYPE PNG_LIBPNG_BUILD_BETA\n\n/* Careful here.  At one time, Guy wanted to use 082, but that would be octal.\n * We must not include leading zeros.\n * Versions 0.7 through 1.0.0 were in the range 0 to 100 here (only\n * version 1.0.0 was mis-numbered 100 instead of 10000).  From\n * version 1.0.1 it's    xxyyzz, where x=major, y=minor, z=release\n */\n#define PNG_LIBPNG_VER 10509 /* 1.5.9 */\n\n/* Library configuration: these options cannot be changed after\n * the library has been built.\n */\n#ifndef PNGLCONF_H\n    /* If pnglibconf.h is missing, you can\n     * copy scripts/pnglibconf.h.prebuilt to pnglibconf.h\n     */\n#   include \"pnglibconf.h\"\n#endif\n\n#ifndef PNG_VERSION_INFO_ONLY\n#  ifndef PNG_BUILDING_SYMBOL_TABLE\n  /*\n   *   Standard header files (not needed for the version info or while\n   *   building symbol table -- see scripts/pnglibconf.dfa)\n   */\n#    ifdef PNG_SETJMP_SUPPORTED\n#      include <setjmp.h>\n#    endif\n\n    /* Need the time information for converting tIME chunks, it\n     * defines struct tm:\n     */\n#    ifdef PNG_CONVERT_tIME_SUPPORTED\n       /* \"time.h\" functions are not supported on all operating systems */\n#      include <time.h>\n#    endif\n#  endif\n\n/* Machine specific configuration. */\n#  include \"pngconf.h\"\n#endif\n\n/*\n * Added at libpng-1.2.8\n *\n * Ref MSDN: Private as priority over Special\n * VS_FF_PRIVATEBUILD File *was not* built using standard release\n * procedures. If this value is given, the StringFileInfo block must\n * contain a PrivateBuild string.\n *\n * VS_FF_SPECIALBUILD File *was* built by the original company using\n * standard release procedures but is a variation of the standard\n * file of the same version number. If this value is given, the\n * StringFileInfo block must contain a SpecialBuild string.\n */\n\n#ifdef PNG_USER_PRIVATEBUILD /* From pnglibconf.h */\n#  define PNG_LIBPNG_BUILD_TYPE \\\n       (PNG_LIBPNG_BUILD_BASE_TYPE | PNG_LIBPNG_BUILD_PRIVATE)\n#else\n#  ifdef PNG_LIBPNG_SPECIALBUILD\n#    define PNG_LIBPNG_BUILD_TYPE \\\n         (PNG_LIBPNG_BUILD_BASE_TYPE | PNG_LIBPNG_BUILD_SPECIAL)\n#  else\n#    define PNG_LIBPNG_BUILD_TYPE (PNG_LIBPNG_BUILD_BASE_TYPE)\n#  endif\n#endif\n\n#ifndef PNG_VERSION_INFO_ONLY\n\n/* Inhibit C++ name-mangling for libpng functions but not for system calls. */\n#ifdef __cplusplus\nextern \"C\" {\n#endif /* __cplusplus */\n\n/* Version information for C files, stored in png.c.  This had better match\n * the version above.\n */\n#define png_libpng_ver png_get_header_ver(NULL)\n\n/* This file is arranged in several sections:\n *\n * 1. Any configuration options that can be specified by for the application\n *    code when it is built.  (Build time configuration is in pnglibconf.h)\n * 2. Type definitions (base types are defined in pngconf.h), structure\n *    definitions.\n * 3. Exported library functions.\n *\n * The library source code has additional files (principally pngpriv.h) that\n * allow configuration of the library.\n */\n/* Section 1: run time configuration\n * See pnglibconf.h for build time configuration\n *\n * Run time configuration allows the application to choose between\n * implementations of certain arithmetic APIs.  The default is set\n * at build time and recorded in pnglibconf.h, but it is safe to\n * override these (and only these) settings.  Note that this won't\n * change what the library does, only application code, and the\n * settings can (and probably should) be made on a per-file basis\n * by setting the #defines before including png.h\n *\n * Use macros to read integers from PNG data or use the exported\n * functions?\n *   PNG_USE_READ_MACROS: use the macros (see below)  Note that\n *     the macros evaluate their argument multiple times.\n *   PNG_NO_USE_READ_MACROS: call the relevant library function.\n *\n * Use the alternative algorithm for compositing alpha samples that\n * does not use division?\n *   PNG_READ_COMPOSITE_NODIV_SUPPORTED: use the 'no division'\n *      algorithm.\n *   PNG_NO_READ_COMPOSITE_NODIV: use the 'division' algorithm.\n *\n * How to handle benign errors if PNG_ALLOW_BENIGN_ERRORS is\n * false?\n *   PNG_ALLOW_BENIGN_ERRORS: map calls to the benign error\n *      APIs to png_warning.\n * Otherwise the calls are mapped to png_error.\n */\n\n/* Section 2: type definitions, including structures and compile time\n * constants.\n * See pngconf.h for base types that vary by machine/system\n */\n\n/* This triggers a compiler error in png.c, if png.c and png.h\n * do not agree upon the version number.\n */\ntypedef char* png_libpng_version_1_5_9;\n\n/* Three color definitions.  The order of the red, green, and blue, (and the\n * exact size) is not important, although the size of the fields need to\n * be png_byte or png_uint_16 (as defined below).\n */\ntypedef struct png_color_struct\n{\n   png_byte red;\n   png_byte green;\n   png_byte blue;\n} png_color;\ntypedef png_color FAR * png_colorp;\ntypedef PNG_CONST png_color FAR * png_const_colorp;\ntypedef png_color FAR * FAR * png_colorpp;\n\ntypedef struct png_color_16_struct\n{\n   png_byte index;    /* used for palette files */\n   png_uint_16 red;   /* for use in red green blue files */\n   png_uint_16 green;\n   png_uint_16 blue;\n   png_uint_16 gray;  /* for use in grayscale files */\n} png_color_16;\ntypedef png_color_16 FAR * png_color_16p;\ntypedef PNG_CONST png_color_16 FAR * png_const_color_16p;\ntypedef png_color_16 FAR * FAR * png_color_16pp;\n\ntypedef struct png_color_8_struct\n{\n   png_byte red;   /* for use in red green blue files */\n   png_byte green;\n   png_byte blue;\n   png_byte gray;  /* for use in grayscale files */\n   png_byte alpha; /* for alpha channel files */\n} png_color_8;\ntypedef png_color_8 FAR * png_color_8p;\ntypedef PNG_CONST png_color_8 FAR * png_const_color_8p;\ntypedef png_color_8 FAR * FAR * png_color_8pp;\n\n/*\n * The following two structures are used for the in-core representation\n * of sPLT chunks.\n */\ntypedef struct png_sPLT_entry_struct\n{\n   png_uint_16 red;\n   png_uint_16 green;\n   png_uint_16 blue;\n   png_uint_16 alpha;\n   png_uint_16 frequency;\n} png_sPLT_entry;\ntypedef png_sPLT_entry FAR * png_sPLT_entryp;\ntypedef PNG_CONST png_sPLT_entry FAR * png_const_sPLT_entryp;\ntypedef png_sPLT_entry FAR * FAR * png_sPLT_entrypp;\n\n/*  When the depth of the sPLT palette is 8 bits, the color and alpha samples\n *  occupy the LSB of their respective members, and the MSB of each member\n *  is zero-filled.  The frequency member always occupies the full 16 bits.\n */\n\ntypedef struct png_sPLT_struct\n{\n   png_charp name;           /* palette name */\n   png_byte depth;           /* depth of palette samples */\n   png_sPLT_entryp entries;  /* palette entries */\n   png_int_32 nentries;      /* number of palette entries */\n} png_sPLT_t;\ntypedef png_sPLT_t FAR * png_sPLT_tp;\ntypedef PNG_CONST png_sPLT_t FAR * png_const_sPLT_tp;\ntypedef png_sPLT_t FAR * FAR * png_sPLT_tpp;\n\n#ifdef PNG_TEXT_SUPPORTED\n/* png_text holds the contents of a text/ztxt/itxt chunk in a PNG file,\n * and whether that contents is compressed or not.  The \"key\" field\n * points to a regular zero-terminated C string.  The \"text\" fields can be a\n * regular C string, an empty string, or a NULL pointer.\n * However, the structure returned by png_get_text() will always contain\n * the \"text\" field as a regular zero-terminated C string (possibly\n * empty), never a NULL pointer, so it can be safely used in printf() and\n * other string-handling functions.  Note that the \"itxt_length\", \"lang\", and\n * \"lang_key\" members of the structure only exist when the library is built\n * with iTXt chunk support.  Prior to libpng-1.4.0 the library was built by\n * default without iTXt support. Also note that when iTXt *is* supported,\n * the \"lang\" and \"lang_key\" fields contain NULL pointers when the\n * \"compression\" field contains * PNG_TEXT_COMPRESSION_NONE or\n * PNG_TEXT_COMPRESSION_zTXt. Note that the \"compression value\" is not the\n * same as what appears in the PNG tEXt/zTXt/iTXt chunk's \"compression flag\"\n * which is always 0 or 1, or its \"compression method\" which is always 0.\n */\ntypedef struct png_text_struct\n{\n   int  compression;       /* compression value:\n                             -1: tEXt, none\n                              0: zTXt, deflate\n                              1: iTXt, none\n                              2: iTXt, deflate  */\n   png_charp key;          /* keyword, 1-79 character description of \"text\" */\n   png_charp text;         /* comment, may be an empty string (ie \"\")\n                              or a NULL pointer */\n   png_size_t text_length; /* length of the text string */\n   png_size_t itxt_length; /* length of the itxt string */\n   png_charp lang;         /* language code, 0-79 characters\n                              or a NULL pointer */\n   png_charp lang_key;     /* keyword translated UTF-8 string, 0 or more\n                              chars or a NULL pointer */\n} png_text;\ntypedef png_text FAR * png_textp;\ntypedef PNG_CONST png_text FAR * png_const_textp;\ntypedef png_text FAR * FAR * png_textpp;\n#endif\n\n/* Supported compression types for text in PNG files (tEXt, and zTXt).\n * The values of the PNG_TEXT_COMPRESSION_ defines should NOT be changed. */\n#define PNG_TEXT_COMPRESSION_NONE_WR -3\n#define PNG_TEXT_COMPRESSION_zTXt_WR -2\n#define PNG_TEXT_COMPRESSION_NONE    -1\n#define PNG_TEXT_COMPRESSION_zTXt     0\n#define PNG_ITXT_COMPRESSION_NONE     1\n#define PNG_ITXT_COMPRESSION_zTXt     2\n#define PNG_TEXT_COMPRESSION_LAST     3  /* Not a valid value */\n\n/* png_time is a way to hold the time in an machine independent way.\n * Two conversions are provided, both from time_t and struct tm.  There\n * is no portable way to convert to either of these structures, as far\n * as I know.  If you know of a portable way, send it to me.  As a side\n * note - PNG has always been Year 2000 compliant!\n */\ntypedef struct png_time_struct\n{\n   png_uint_16 year; /* full year, as in, 1995 */\n   png_byte month;   /* month of year, 1 - 12 */\n   png_byte day;     /* day of month, 1 - 31 */\n   png_byte hour;    /* hour of day, 0 - 23 */\n   png_byte minute;  /* minute of hour, 0 - 59 */\n   png_byte second;  /* second of minute, 0 - 60 (for leap seconds) */\n} png_time;\ntypedef png_time FAR * png_timep;\ntypedef PNG_CONST png_time FAR * png_const_timep;\ntypedef png_time FAR * FAR * png_timepp;\n\n#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) || \\\n    defined(PNG_HANDLE_AS_UNKNOWN_SUPPORTED)\n/* png_unknown_chunk is a structure to hold queued chunks for which there is\n * no specific support.  The idea is that we can use this to queue\n * up private chunks for output even though the library doesn't actually\n * know about their semantics.\n */\ntypedef struct png_unknown_chunk_t\n{\n    png_byte name[5];\n    png_byte *data;\n    png_size_t size;\n\n    /* libpng-using applications should NOT directly modify this byte. */\n    png_byte location; /* mode of operation at read time */\n}\n\n\npng_unknown_chunk;\ntypedef png_unknown_chunk FAR * png_unknown_chunkp;\ntypedef PNG_CONST png_unknown_chunk FAR * png_const_unknown_chunkp;\ntypedef png_unknown_chunk FAR * FAR * png_unknown_chunkpp;\n#endif\n\n/* Values for the unknown chunk location byte */\n\n#define PNG_HAVE_IHDR  0x01\n#define PNG_HAVE_PLTE  0x02\n#define PNG_AFTER_IDAT 0x08\n\n/* The complete definition of png_info has, as of libpng-1.5.0,\n * been moved into a separate header file that is not accessible to\n * applications.  Read libpng-manual.txt or libpng.3 for more info.\n */\ntypedef struct png_info_def png_info;\ntypedef png_info FAR * png_infop;\ntypedef PNG_CONST png_info FAR * png_const_infop;\ntypedef png_info FAR * FAR * png_infopp;\n\n/* Maximum positive integer used in PNG is (2^31)-1 */\n#define PNG_UINT_31_MAX ((png_uint_32)0x7fffffffL)\n#define PNG_UINT_32_MAX ((png_uint_32)(-1))\n#define PNG_SIZE_MAX ((png_size_t)(-1))\n\n/* These are constants for fixed point values encoded in the\n * PNG specification manner (x100000)\n */\n#define PNG_FP_1    100000\n#define PNG_FP_HALF  50000\n#define PNG_FP_MAX  ((png_fixed_point)0x7fffffffL)\n#define PNG_FP_MIN  (-PNG_FP_MAX)\n\n/* These describe the color_type field in png_info. */\n/* color type masks */\n#define PNG_COLOR_MASK_PALETTE    1\n#define PNG_COLOR_MASK_COLOR      2\n#define PNG_COLOR_MASK_ALPHA      4\n\n/* color types.  Note that not all combinations are legal */\n#define PNG_COLOR_TYPE_GRAY 0\n#define PNG_COLOR_TYPE_PALETTE  (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_PALETTE)\n#define PNG_COLOR_TYPE_RGB        (PNG_COLOR_MASK_COLOR)\n#define PNG_COLOR_TYPE_RGB_ALPHA  (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_ALPHA)\n#define PNG_COLOR_TYPE_GRAY_ALPHA (PNG_COLOR_MASK_ALPHA)\n/* aliases */\n#define PNG_COLOR_TYPE_RGBA  PNG_COLOR_TYPE_RGB_ALPHA\n#define PNG_COLOR_TYPE_GA  PNG_COLOR_TYPE_GRAY_ALPHA\n\n/* This is for compression type. PNG 1.0-1.2 only define the single type. */\n#define PNG_COMPRESSION_TYPE_BASE 0 /* Deflate method 8, 32K window */\n#define PNG_COMPRESSION_TYPE_DEFAULT PNG_COMPRESSION_TYPE_BASE\n\n/* This is for filter type. PNG 1.0-1.2 only define the single type. */\n#define PNG_FILTER_TYPE_BASE      0 /* Single row per-byte filtering */\n#define PNG_INTRAPIXEL_DIFFERENCING 64 /* Used only in MNG datastreams */\n#define PNG_FILTER_TYPE_DEFAULT   PNG_FILTER_TYPE_BASE\n\n/* These are for the interlacing type.  These values should NOT be changed. */\n#define PNG_INTERLACE_NONE        0 /* Non-interlaced image */\n#define PNG_INTERLACE_ADAM7       1 /* Adam7 interlacing */\n#define PNG_INTERLACE_LAST        2 /* Not a valid value */\n\n/* These are for the oFFs chunk.  These values should NOT be changed. */\n#define PNG_OFFSET_PIXEL          0 /* Offset in pixels */\n#define PNG_OFFSET_MICROMETER     1 /* Offset in micrometers (1/10^6 meter) */\n#define PNG_OFFSET_LAST           2 /* Not a valid value */\n\n/* These are for the pCAL chunk.  These values should NOT be changed. */\n#define PNG_EQUATION_LINEAR       0 /* Linear transformation */\n#define PNG_EQUATION_BASE_E       1 /* Exponential base e transform */\n#define PNG_EQUATION_ARBITRARY    2 /* Arbitrary base exponential transform */\n#define PNG_EQUATION_HYPERBOLIC   3 /* Hyperbolic sine transformation */\n#define PNG_EQUATION_LAST         4 /* Not a valid value */\n\n/* These are for the sCAL chunk.  These values should NOT be changed. */\n#define PNG_SCALE_UNKNOWN         0 /* unknown unit (image scale) */\n#define PNG_SCALE_METER           1 /* meters per pixel */\n#define PNG_SCALE_RADIAN          2 /* radians per pixel */\n#define PNG_SCALE_LAST            3 /* Not a valid value */\n\n/* These are for the pHYs chunk.  These values should NOT be changed. */\n#define PNG_RESOLUTION_UNKNOWN    0 /* pixels/unknown unit (aspect ratio) */\n#define PNG_RESOLUTION_METER      1 /* pixels/meter */\n#define PNG_RESOLUTION_LAST       2 /* Not a valid value */\n\n/* These are for the sRGB chunk.  These values should NOT be changed. */\n#define PNG_sRGB_INTENT_PERCEPTUAL 0\n#define PNG_sRGB_INTENT_RELATIVE   1\n#define PNG_sRGB_INTENT_SATURATION 2\n#define PNG_sRGB_INTENT_ABSOLUTE   3\n#define PNG_sRGB_INTENT_LAST       4 /* Not a valid value */\n\n/* This is for text chunks */\n#define PNG_KEYWORD_MAX_LENGTH     79\n\n/* Maximum number of entries in PLTE/sPLT/tRNS arrays */\n#define PNG_MAX_PALETTE_LENGTH    256\n\n/* These determine if an ancillary chunk's data has been successfully read\n * from the PNG header, or if the application has filled in the corresponding\n * data in the info_struct to be written into the output file.  The values\n * of the PNG_INFO_<chunk> defines should NOT be changed.\n */\n#define PNG_INFO_gAMA 0x0001\n#define PNG_INFO_sBIT 0x0002\n#define PNG_INFO_cHRM 0x0004\n#define PNG_INFO_PLTE 0x0008\n#define PNG_INFO_tRNS 0x0010\n#define PNG_INFO_bKGD 0x0020\n#define PNG_INFO_hIST 0x0040\n#define PNG_INFO_pHYs 0x0080\n#define PNG_INFO_oFFs 0x0100\n#define PNG_INFO_tIME 0x0200\n#define PNG_INFO_pCAL 0x0400\n#define PNG_INFO_sRGB 0x0800   /* GR-P, 0.96a */\n#define PNG_INFO_iCCP 0x1000   /* ESR, 1.0.6 */\n#define PNG_INFO_sPLT 0x2000   /* ESR, 1.0.6 */\n#define PNG_INFO_sCAL 0x4000   /* ESR, 1.0.6 */\n#define PNG_INFO_IDAT 0x8000   /* ESR, 1.0.6 */\n\n/* This is used for the transformation routines, as some of them\n * change these values for the row.  It also should enable using\n * the routines for other purposes.\n */\ntypedef struct png_row_info_struct\n{\n   png_uint_32 width;    /* width of row */\n   png_size_t rowbytes;  /* number of bytes in row */\n   png_byte color_type;  /* color type of row */\n   png_byte bit_depth;   /* bit depth of row */\n   png_byte channels;    /* number of channels (1, 2, 3, or 4) */\n   png_byte pixel_depth; /* bits per pixel (depth * channels) */\n} png_row_info;\n\ntypedef png_row_info FAR * png_row_infop;\ntypedef png_row_info FAR * FAR * png_row_infopp;\n\n/* The complete definition of png_struct has, as of libpng-1.5.0,\n * been moved into a separate header file that is not accessible to\n * applications.  Read libpng-manual.txt or libpng.3 for more info.\n */\ntypedef struct png_struct_def png_struct;\ntypedef PNG_CONST png_struct FAR * png_const_structp;\ntypedef png_struct FAR * png_structp;\n\n/* These are the function types for the I/O functions and for the functions\n * that allow the user to override the default I/O functions with his or her\n * own.  The png_error_ptr type should match that of user-supplied warning\n * and error functions, while the png_rw_ptr type should match that of the\n * user read/write data functions.  Note that the 'write' function must not\n * modify the buffer it is passed. The 'read' function, on the other hand, is\n * expected to return the read data in the buffer.\n */\ntypedef PNG_CALLBACK(void, *png_error_ptr, (png_structp, png_const_charp));\ntypedef PNG_CALLBACK(void, *png_rw_ptr, (png_structp, png_bytep, png_size_t));\ntypedef PNG_CALLBACK(void, *png_flush_ptr, (png_structp));\ntypedef PNG_CALLBACK(void, *png_read_status_ptr, (png_structp, png_uint_32,\n    int));\ntypedef PNG_CALLBACK(void, *png_write_status_ptr, (png_structp, png_uint_32,\n    int));\n\n#ifdef PNG_PROGRESSIVE_READ_SUPPORTED\ntypedef PNG_CALLBACK(void, *png_progressive_info_ptr, (png_structp, png_infop));\ntypedef PNG_CALLBACK(void, *png_progressive_end_ptr, (png_structp, png_infop));\n\n/* The following callback receives png_uint_32 row_number, int pass for the\n * png_bytep data of the row.  When transforming an interlaced image the\n * row number is the row number within the sub-image of the interlace pass, so\n * the value will increase to the height of the sub-image (not the full image)\n * then reset to 0 for the next pass.\n *\n * Use PNG_ROW_FROM_PASS_ROW(row, pass) and PNG_COL_FROM_PASS_COL(col, pass) to\n * find the output pixel (x,y) given an interlaced sub-image pixel\n * (row,col,pass).  (See below for these macros.)\n */\ntypedef PNG_CALLBACK(void, *png_progressive_row_ptr, (png_structp, png_bytep,\n    png_uint_32, int));\n#endif\n\n#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \\\n    defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)\ntypedef PNG_CALLBACK(void, *png_user_transform_ptr, (png_structp, png_row_infop,\n    png_bytep));\n#endif\n\n#ifdef PNG_USER_CHUNKS_SUPPORTED\ntypedef PNG_CALLBACK(int, *png_user_chunk_ptr, (png_structp,\n    png_unknown_chunkp));\n#endif\n#ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED\ntypedef PNG_CALLBACK(void, *png_unknown_chunk_ptr, (png_structp));\n#endif\n\n#ifdef PNG_SETJMP_SUPPORTED\n/* This must match the function definition in <setjmp.h>, and the application\n * must include this before png.h to obtain the definition of jmp_buf.  The\n * function is required to be PNG_NORETURN, but this is not checked.  If the\n * function does return the application will crash via an abort() or similar\n * system level call.\n *\n * If you get a warning here while building the library you may need to make\n * changes to ensure that pnglibconf.h records the calling convention used by\n * your compiler.  This may be very difficult - try using a different compiler\n * to build the library!\n */\nPNG_FUNCTION(void, (PNGCAPI *png_longjmp_ptr), PNGARG((jmp_buf, int)), typedef);\n#endif\n\n/* Transform masks for the high-level interface */\n#define PNG_TRANSFORM_IDENTITY       0x0000    /* read and write */\n#define PNG_TRANSFORM_STRIP_16       0x0001    /* read only */\n#define PNG_TRANSFORM_STRIP_ALPHA    0x0002    /* read only */\n#define PNG_TRANSFORM_PACKING        0x0004    /* read and write */\n#define PNG_TRANSFORM_PACKSWAP       0x0008    /* read and write */\n#define PNG_TRANSFORM_EXPAND         0x0010    /* read only */\n#define PNG_TRANSFORM_INVERT_MONO    0x0020    /* read and write */\n#define PNG_TRANSFORM_SHIFT          0x0040    /* read and write */\n#define PNG_TRANSFORM_BGR            0x0080    /* read and write */\n#define PNG_TRANSFORM_SWAP_ALPHA     0x0100    /* read and write */\n#define PNG_TRANSFORM_SWAP_ENDIAN    0x0200    /* read and write */\n#define PNG_TRANSFORM_INVERT_ALPHA   0x0400    /* read and write */\n#define PNG_TRANSFORM_STRIP_FILLER   0x0800    /* write only */\n/* Added to libpng-1.2.34 */\n#define PNG_TRANSFORM_STRIP_FILLER_BEFORE PNG_TRANSFORM_STRIP_FILLER\n#define PNG_TRANSFORM_STRIP_FILLER_AFTER 0x1000 /* write only */\n/* Added to libpng-1.4.0 */\n#define PNG_TRANSFORM_GRAY_TO_RGB   0x2000      /* read only */\n/* Added to libpng-1.5.4 */\n#define PNG_TRANSFORM_EXPAND_16     0x4000      /* read only */\n#define PNG_TRANSFORM_SCALE_16      0x8000      /* read only */\n\n/* Flags for MNG supported features */\n#define PNG_FLAG_MNG_EMPTY_PLTE     0x01\n#define PNG_FLAG_MNG_FILTER_64      0x04\n#define PNG_ALL_MNG_FEATURES        0x05\n\n/* NOTE: prior to 1.5 these functions had no 'API' style declaration,\n * this allowed the zlib default functions to be used on Windows\n * platforms.  In 1.5 the zlib default malloc (which just calls malloc and\n * ignores the first argument) should be completely compatible with the\n * following.\n */\ntypedef PNG_CALLBACK(png_voidp, *png_malloc_ptr, (png_structp,\n    png_alloc_size_t));\ntypedef PNG_CALLBACK(void, *png_free_ptr, (png_structp, png_voidp));\n\ntypedef png_struct FAR * FAR * png_structpp;\n\n/* Section 3: exported functions\n * Here are the function definitions most commonly used.  This is not\n * the place to find out how to use libpng.  See libpng-manual.txt for the\n * full explanation, see example.c for the summary.  This just provides\n * a simple one line description of the use of each function.\n *\n * The PNG_EXPORT() and PNG_EXPORTA() macros used below are defined in\n * pngconf.h and in the *.dfn files in the scripts directory.\n *\n *   PNG_EXPORT(ordinal, type, name, (args));\n *\n *       ordinal:    ordinal that is used while building\n *                   *.def files. The ordinal value is only\n *                   relevant when preprocessing png.h with\n *                   the *.dfn files for building symbol table\n *                   entries, and are removed by pngconf.h.\n *       type:       return type of the function\n *       name:       function name\n *       args:       function arguments, with types\n *\n * When we wish to append attributes to a function prototype we use\n * the PNG_EXPORTA() macro instead.\n *\n *   PNG_EXPORTA(ordinal, type, name, (args), attributes);\n *\n *       ordinal, type, name, and args: same as in PNG_EXPORT().\n *       attributes: function attributes\n */\n\n/* Returns the version number of the library */\nPNG_EXPORT(1, png_uint_32, png_access_version_number, (void));\n\n/* Tell lib we have already handled the first <num_bytes> magic bytes.\n * Handling more than 8 bytes from the beginning of the file is an error.\n */\nPNG_EXPORT(2, void, png_set_sig_bytes, (png_structp png_ptr, int num_bytes));\n\n/* Check sig[start] through sig[start + num_to_check - 1] to see if it's a\n * PNG file.  Returns zero if the supplied bytes match the 8-byte PNG\n * signature, and non-zero otherwise.  Having num_to_check == 0 or\n * start > 7 will always fail (ie return non-zero).\n */\nPNG_EXPORT(3, int, png_sig_cmp, (png_const_bytep sig, png_size_t start,\n    png_size_t num_to_check));\n\n/* Simple signature checking function.  This is the same as calling\n * png_check_sig(sig, n) := !png_sig_cmp(sig, 0, n).\n */\n#define png_check_sig(sig, n) !png_sig_cmp((sig), 0, (n))\n\n/* Allocate and initialize png_ptr struct for reading, and any other memory. */\nPNG_EXPORTA(4, png_structp, png_create_read_struct,\n    (png_const_charp user_png_ver, png_voidp error_ptr,\n    png_error_ptr error_fn, png_error_ptr warn_fn),\n    PNG_ALLOCATED);\n\n/* Allocate and initialize png_ptr struct for writing, and any other memory */\nPNG_EXPORTA(5, png_structp, png_create_write_struct,\n    (png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn,\n    png_error_ptr warn_fn),\n    PNG_ALLOCATED);\n\nPNG_EXPORT(6, png_size_t, png_get_compression_buffer_size,\n    (png_const_structp png_ptr));\n\nPNG_EXPORT(7, void, png_set_compression_buffer_size, (png_structp png_ptr,\n    png_size_t size));\n\n/* Moved from pngconf.h in 1.4.0 and modified to ensure setjmp/longjmp\n * match up.\n */\n#ifdef PNG_SETJMP_SUPPORTED\n/* This function returns the jmp_buf built in to *png_ptr.  It must be\n * supplied with an appropriate 'longjmp' function to use on that jmp_buf\n * unless the default error function is overridden in which case NULL is\n * acceptable.  The size of the jmp_buf is checked against the actual size\n * allocated by the library - the call will return NULL on a mismatch\n * indicating an ABI mismatch.\n */\nPNG_EXPORT(8, jmp_buf*, png_set_longjmp_fn, (png_structp png_ptr,\n    png_longjmp_ptr longjmp_fn, size_t jmp_buf_size));\n#  define png_jmpbuf(png_ptr) \\\n      (*png_set_longjmp_fn((png_ptr), longjmp, sizeof (jmp_buf)))\n#else\n#  define png_jmpbuf(png_ptr) \\\n      (LIBPNG_WAS_COMPILED_WITH__PNG_NO_SETJMP)\n#endif\n/* This function should be used by libpng applications in place of\n * longjmp(png_ptr->jmpbuf, val).  If longjmp_fn() has been set, it\n * will use it; otherwise it will call PNG_ABORT().  This function was\n * added in libpng-1.5.0.\n */\nPNG_EXPORTA(9, void, png_longjmp, (png_structp png_ptr, int val),\n    PNG_NORETURN);\n\n#ifdef PNG_READ_SUPPORTED\n/* Reset the compression stream */\nPNG_EXPORT(10, int, png_reset_zstream, (png_structp png_ptr));\n#endif\n\n/* New functions added in libpng-1.0.2 (not enabled by default until 1.2.0) */\n#ifdef PNG_USER_MEM_SUPPORTED\nPNG_EXPORTA(11, png_structp, png_create_read_struct_2,\n    (png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn,\n    png_error_ptr warn_fn,\n    png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn),\n    PNG_ALLOCATED);\nPNG_EXPORTA(12, png_structp, png_create_write_struct_2,\n    (png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn,\n    png_error_ptr warn_fn,\n    png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn),\n    PNG_ALLOCATED);\n#endif\n\n/* Write the PNG file signature. */\nPNG_EXPORT(13, void, png_write_sig, (png_structp png_ptr));\n\n/* Write a PNG chunk - size, type, (optional) data, CRC. */\nPNG_EXPORT(14, void, png_write_chunk, (png_structp png_ptr, png_const_bytep\n    chunk_name, png_const_bytep data, png_size_t length));\n\n/* Write the start of a PNG chunk - length and chunk name. */\nPNG_EXPORT(15, void, png_write_chunk_start, (png_structp png_ptr,\n    png_const_bytep chunk_name, png_uint_32 length));\n\n/* Write the data of a PNG chunk started with png_write_chunk_start(). */\nPNG_EXPORT(16, void, png_write_chunk_data, (png_structp png_ptr,\n    png_const_bytep data, png_size_t length));\n\n/* Finish a chunk started with png_write_chunk_start() (includes CRC). */\nPNG_EXPORT(17, void, png_write_chunk_end, (png_structp png_ptr));\n\n/* Allocate and initialize the info structure */\nPNG_EXPORTA(18, png_infop, png_create_info_struct, (png_structp png_ptr),\n    PNG_ALLOCATED);\n\nPNG_EXPORT(19, void, png_info_init_3, (png_infopp info_ptr,\n    png_size_t png_info_struct_size));\n\n/* Writes all the PNG information before the image. */\nPNG_EXPORT(20, void, png_write_info_before_PLTE,\n    (png_structp png_ptr, png_infop info_ptr));\nPNG_EXPORT(21, void, png_write_info,\n    (png_structp png_ptr, png_infop info_ptr));\n\n#ifdef PNG_SEQUENTIAL_READ_SUPPORTED\n/* Read the information before the actual image data. */\nPNG_EXPORT(22, void, png_read_info,\n    (png_structp png_ptr, png_infop info_ptr));\n#endif\n\n#ifdef PNG_TIME_RFC1123_SUPPORTED\nPNG_EXPORT(23, png_const_charp, png_convert_to_rfc1123,\n    (png_structp png_ptr,\n    png_const_timep ptime));\n#endif\n\n#ifdef PNG_CONVERT_tIME_SUPPORTED\n/* Convert from a struct tm to png_time */\nPNG_EXPORT(24, void, png_convert_from_struct_tm, (png_timep ptime,\n    PNG_CONST struct tm FAR * ttime));\n\n/* Convert from time_t to png_time.  Uses gmtime() */\nPNG_EXPORT(25, void, png_convert_from_time_t,\n    (png_timep ptime, time_t ttime));\n#endif /* PNG_CONVERT_tIME_SUPPORTED */\n\n#ifdef PNG_READ_EXPAND_SUPPORTED\n/* Expand data to 24-bit RGB, or 8-bit grayscale, with alpha if available. */\nPNG_EXPORT(26, void, png_set_expand, (png_structp png_ptr));\nPNG_EXPORT(27, void, png_set_expand_gray_1_2_4_to_8, (png_structp png_ptr));\nPNG_EXPORT(28, void, png_set_palette_to_rgb, (png_structp png_ptr));\nPNG_EXPORT(29, void, png_set_tRNS_to_alpha, (png_structp png_ptr));\n#endif\n\n#ifdef PNG_READ_EXPAND_16_SUPPORTED\n/* Expand to 16-bit channels, forces conversion of palette to RGB and expansion\n * of a tRNS chunk if present.\n */\nPNG_EXPORT(221, void, png_set_expand_16, (png_structp png_ptr));\n#endif\n\n#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED)\n/* Use blue, green, red order for pixels. */\nPNG_EXPORT(30, void, png_set_bgr, (png_structp png_ptr));\n#endif\n\n#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED\n/* Expand the grayscale to 24-bit RGB if necessary. */\nPNG_EXPORT(31, void, png_set_gray_to_rgb, (png_structp png_ptr));\n#endif\n\n#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED\n/* Reduce RGB to grayscale. */\n#define PNG_ERROR_ACTION_NONE  1\n#define PNG_ERROR_ACTION_WARN  2\n#define PNG_ERROR_ACTION_ERROR 3\n#define PNG_RGB_TO_GRAY_DEFAULT (-1)/*for red/green coefficients*/\n\nPNG_FP_EXPORT(32, void, png_set_rgb_to_gray, (png_structp png_ptr,\n    int error_action, double red, double green));\nPNG_FIXED_EXPORT(33, void, png_set_rgb_to_gray_fixed, (png_structp png_ptr,\n    int error_action, png_fixed_point red, png_fixed_point green));\n\nPNG_EXPORT(34, png_byte, png_get_rgb_to_gray_status, (png_const_structp\n    png_ptr));\n#endif\n\n#ifdef PNG_BUILD_GRAYSCALE_PALETTE_SUPPORTED\nPNG_EXPORT(35, void, png_build_grayscale_palette, (int bit_depth,\n    png_colorp palette));\n#endif\n\n#ifdef PNG_READ_ALPHA_MODE_SUPPORTED\n/* How the alpha channel is interpreted - this affects how the color channels of\n * a PNG file are returned when an alpha channel, or tRNS chunk in a palette\n * file, is present.\n *\n * This has no effect on the way pixels are written into a PNG output\n * datastream. The color samples in a PNG datastream are never premultiplied\n * with the alpha samples.\n *\n * The default is to return data according to the PNG specification: the alpha\n * channel is a linear measure of the contribution of the pixel to the\n * corresponding composited pixel.  The gamma encoded color channels must be\n * scaled according to the contribution and to do this it is necessary to undo\n * the encoding, scale the color values, perform the composition and reencode\n * the values.  This is the 'PNG' mode.\n *\n * The alternative is to 'associate' the alpha with the color information by\n * storing color channel values that have been scaled by the alpha.  The\n * advantage is that the color channels can be resampled (the image can be\n * scaled) in this form.  The disadvantage is that normal practice is to store\n * linear, not (gamma) encoded, values and this requires 16-bit channels for\n * still images rather than the 8-bit channels that are just about sufficient if\n * gamma encoding is used.  In addition all non-transparent pixel values,\n * including completely opaque ones, must be gamma encoded to produce the final\n * image.  This is the 'STANDARD', 'ASSOCIATED' or 'PREMULTIPLIED' mode (the\n * latter being the two common names for associated alpha color channels.)\n *\n * Since it is not necessary to perform arithmetic on opaque color values so\n * long as they are not to be resampled and are in the final color space it is\n * possible to optimize the handling of alpha by storing the opaque pixels in\n * the PNG format (adjusted for the output color space) while storing partially\n * opaque pixels in the standard, linear, format.  The accuracy required for\n * standard alpha composition is relatively low, because the pixels are\n * isolated, therefore typically the accuracy loss in storing 8-bit linear\n * values is acceptable.  (This is not true if the alpha channel is used to\n * simulate transparency over large areas - use 16 bits or the PNG mode in\n * this case!)  This is the 'OPTIMIZED' mode.  For this mode a pixel is\n * treated as opaque only if the alpha value is equal to the maximum value.\n *\n * The final choice is to gamma encode the alpha channel as well.  This is\n * broken because, in practice, no implementation that uses this choice\n * correctly undoes the encoding before handling alpha composition.  Use this\n * choice only if other serious errors in the software or hardware you use\n * mandate it; the typical serious error is for dark halos to appear around\n * opaque areas of the composited PNG image because of arithmetic overflow.\n *\n * The API function png_set_alpha_mode specifies which of these choices to use\n * with an enumerated 'mode' value and the gamma of the required output:\n */\n#define PNG_ALPHA_PNG           0 /* according to the PNG standard */\n#define PNG_ALPHA_STANDARD      1 /* according to Porter/Duff */\n#define PNG_ALPHA_ASSOCIATED    1 /* as above; this is the normal practice */\n#define PNG_ALPHA_PREMULTIPLIED 1 /* as above */\n#define PNG_ALPHA_OPTIMIZED     2 /* 'PNG' for opaque pixels, else 'STANDARD' */\n#define PNG_ALPHA_BROKEN        3 /* the alpha channel is gamma encoded */\n\nPNG_FP_EXPORT(227, void, png_set_alpha_mode, (png_structp png_ptr, int mode,\n    double output_gamma));\nPNG_FIXED_EXPORT(228, void, png_set_alpha_mode_fixed, (png_structp png_ptr,\n    int mode, png_fixed_point output_gamma));\n#endif\n\n#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_ALPHA_MODE_SUPPORTED)\n/* The output_gamma value is a screen gamma in libpng terminology: it expresses\n * how to decode the output values, not how they are encoded.  The values used\n * correspond to the normal numbers used to describe the overall gamma of a\n * computer display system; for example 2.2 for an sRGB conformant system.  The\n * values are scaled by 100000 in the _fixed version of the API (so 220000 for\n * sRGB.)\n *\n * The inverse of the value is always used to provide a default for the PNG file\n * encoding if it has no gAMA chunk and if png_set_gamma() has not been called\n * to override the PNG gamma information.\n *\n * When the ALPHA_OPTIMIZED mode is selected the output gamma is used to encode\n * opaque pixels however pixels with lower alpha values are not encoded,\n * regardless of the output gamma setting.\n *\n * When the standard Porter Duff handling is requested with mode 1 the output\n * encoding is set to be linear and the output_gamma value is only relevant\n * as a default for input data that has no gamma information.  The linear output\n * encoding will be overridden if png_set_gamma() is called - the results may be\n * highly unexpected!\n *\n * The following numbers are derived from the sRGB standard and the research\n * behind it.  sRGB is defined to be approximated by a PNG gAMA chunk value of\n * 0.45455 (1/2.2) for PNG.  The value implicitly includes any viewing\n * correction required to take account of any differences in the color\n * environment of the original scene and the intended display environment; the\n * value expresses how to *decode* the image for display, not how the original\n * data was *encoded*.\n *\n * sRGB provides a peg for the PNG standard by defining a viewing environment.\n * sRGB itself, and earlier TV standards, actually use a more complex transform\n * (a linear portion then a gamma 2.4 power law) than PNG can express.  (PNG is\n * limited to simple power laws.)  By saying that an image for direct display on\n * an sRGB conformant system should be stored with a gAMA chunk value of 45455\n * (11.3.3.2 and 11.3.3.5 of the ISO PNG specification) the PNG specification\n * makes it possible to derive values for other display systems and\n * environments.\n *\n * The Mac value is deduced from the sRGB based on an assumption that the actual\n * extra viewing correction used in early Mac display systems was implemented as\n * a power 1.45 lookup table.\n *\n * Any system where a programmable lookup table is used or where the behavior of\n * the final display device characteristics can be changed requires system\n * specific code to obtain the current characteristic.  However this can be\n * difficult and most PNG gamma correction only requires an approximate value.\n *\n * By default, if png_set_alpha_mode() is not called, libpng assumes that all\n * values are unencoded, linear, values and that the output device also has a\n * linear characteristic.  This is only very rarely correct - it is invariably\n * better to call png_set_alpha_mode() with PNG_DEFAULT_sRGB than rely on the\n * default if you don't know what the right answer is!\n *\n * The special value PNG_GAMMA_MAC_18 indicates an older Mac system (pre Mac OS\n * 10.6) which used a correction table to implement a somewhat lower gamma on an\n * otherwise sRGB system.\n *\n * Both these values are reserved (not simple gamma values) in order to allow\n * more precise correction internally in the future.\n *\n * NOTE: the following values can be passed to either the fixed or floating\n * point APIs, but the floating point API will also accept floating point\n * values.\n */\n#define PNG_DEFAULT_sRGB -1       /* sRGB gamma and color space */\n#define PNG_GAMMA_MAC_18 -2       /* Old Mac '1.8' gamma and color space */\n#define PNG_GAMMA_sRGB   220000   /* Television standards--matches sRGB gamma */\n#define PNG_GAMMA_LINEAR PNG_FP_1 /* Linear */\n#endif\n\n/* The following are examples of calls to png_set_alpha_mode to achieve the\n * required overall gamma correction and, where necessary, alpha\n * premultiplication.\n *\n * png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_DEFAULT_sRGB);\n *    This is the default libpng handling of the alpha channel - it is not\n *    pre-multiplied into the color components.  In addition the call states\n *    that the output is for a sRGB system and causes all PNG files without gAMA\n *    chunks to be assumed to be encoded using sRGB.\n *\n * png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_GAMMA_MAC);\n *    In this case the output is assumed to be something like an sRGB conformant\n *    display preceeded by a power-law lookup table of power 1.45.  This is how\n *    early Mac systems behaved.\n *\n * png_set_alpha_mode(pp, PNG_ALPHA_STANDARD, PNG_GAMMA_LINEAR);\n *    This is the classic Jim Blinn approach and will work in academic\n *    environments where everything is done by the book.  It has the shortcoming\n *    of assuming that input PNG data with no gamma information is linear - this\n *    is unlikely to be correct unless the PNG files where generated locally.\n *    Most of the time the output precision will be so low as to show\n *    significant banding in dark areas of the image.\n *\n * png_set_expand_16(pp);\n * png_set_alpha_mode(pp, PNG_ALPHA_STANDARD, PNG_DEFAULT_sRGB);\n *    This is a somewhat more realistic Jim Blinn inspired approach.  PNG files\n *    are assumed to have the sRGB encoding if not marked with a gamma value and\n *    the output is always 16 bits per component.  This permits accurate scaling\n *    and processing of the data.  If you know that your input PNG files were\n *    generated locally you might need to replace PNG_DEFAULT_sRGB with the\n *    correct value for your system.\n *\n * png_set_alpha_mode(pp, PNG_ALPHA_OPTIMIZED, PNG_DEFAULT_sRGB);\n *    If you just need to composite the PNG image onto an existing background\n *    and if you control the code that does this you can use the optimization\n *    setting.  In this case you just copy completely opaque pixels to the\n *    output.  For pixels that are not completely transparent (you just skip\n *    those) you do the composition math using png_composite or png_composite_16\n *    below then encode the resultant 8-bit or 16-bit values to match the output\n *    encoding.\n *\n * Other cases\n *    If neither the PNG nor the standard linear encoding work for you because\n *    of the software or hardware you use then you have a big problem.  The PNG\n *    case will probably result in halos around the image.  The linear encoding\n *    will probably result in a washed out, too bright, image (it's actually too\n *    contrasty.)  Try the ALPHA_OPTIMIZED mode above - this will probably\n *    substantially reduce the halos.  Alternatively try:\n *\n * png_set_alpha_mode(pp, PNG_ALPHA_BROKEN, PNG_DEFAULT_sRGB);\n *    This option will also reduce the halos, but there will be slight dark\n *    halos round the opaque parts of the image where the background is light.\n *    In the OPTIMIZED mode the halos will be light halos where the background\n *    is dark.  Take your pick - the halos are unavoidable unless you can get\n *    your hardware/software fixed!  (The OPTIMIZED approach is slightly\n *    faster.)\n *\n * When the default gamma of PNG files doesn't match the output gamma.\n *    If you have PNG files with no gamma information png_set_alpha_mode allows\n *    you to provide a default gamma, but it also sets the ouput gamma to the\n *    matching value.  If you know your PNG files have a gamma that doesn't\n *    match the output you can take advantage of the fact that\n *    png_set_alpha_mode always sets the output gamma but only sets the PNG\n *    default if it is not already set:\n *\n * png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_DEFAULT_sRGB);\n * png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_GAMMA_MAC);\n *    The first call sets both the default and the output gamma values, the\n *    second call overrides the output gamma without changing the default.  This\n *    is easier than achieving the same effect with png_set_gamma.  You must use\n *    PNG_ALPHA_PNG for the first call - internal checking in png_set_alpha will\n *    fire if more than one call to png_set_alpha_mode and png_set_background is\n *    made in the same read operation, however multiple calls with PNG_ALPHA_PNG\n *    are ignored.\n */\n\n#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED\nPNG_EXPORT(36, void, png_set_strip_alpha, (png_structp png_ptr));\n#endif\n\n#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) || \\\n    defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED)\nPNG_EXPORT(37, void, png_set_swap_alpha, (png_structp png_ptr));\n#endif\n\n#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) || \\\n    defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED)\nPNG_EXPORT(38, void, png_set_invert_alpha, (png_structp png_ptr));\n#endif\n\n#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED)\n/* Add a filler byte to 8-bit Gray or 24-bit RGB images. */\nPNG_EXPORT(39, void, png_set_filler, (png_structp png_ptr, png_uint_32 filler,\n    int flags));\n/* The values of the PNG_FILLER_ defines should NOT be changed */\n#  define PNG_FILLER_BEFORE 0\n#  define PNG_FILLER_AFTER 1\n/* Add an alpha byte to 8-bit Gray or 24-bit RGB images. */\nPNG_EXPORT(40, void, png_set_add_alpha,\n    (png_structp png_ptr, png_uint_32 filler,\n    int flags));\n#endif /* PNG_READ_FILLER_SUPPORTED || PNG_WRITE_FILLER_SUPPORTED */\n\n#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED)\n/* Swap bytes in 16-bit depth files. */\nPNG_EXPORT(41, void, png_set_swap, (png_structp png_ptr));\n#endif\n\n#if defined(PNG_READ_PACK_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED)\n/* Use 1 byte per pixel in 1, 2, or 4-bit depth files. */\nPNG_EXPORT(42, void, png_set_packing, (png_structp png_ptr));\n#endif\n\n#if defined(PNG_READ_PACKSWAP_SUPPORTED) || \\\n    defined(PNG_WRITE_PACKSWAP_SUPPORTED)\n/* Swap packing order of pixels in bytes. */\nPNG_EXPORT(43, void, png_set_packswap, (png_structp png_ptr));\n#endif\n\n#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED)\n/* Converts files to legal bit depths. */\nPNG_EXPORT(44, void, png_set_shift, (png_structp png_ptr, png_const_color_8p\n    true_bits));\n#endif\n\n#if defined(PNG_READ_INTERLACING_SUPPORTED) || \\\n    defined(PNG_WRITE_INTERLACING_SUPPORTED)\n/* Have the code handle the interlacing.  Returns the number of passes.\n * MUST be called before png_read_update_info or png_start_read_image,\n * otherwise it will not have the desired effect.  Note that it is still\n * necessary to call png_read_row or png_read_rows png_get_image_height\n * times for each pass.\n*/\nPNG_EXPORT(45, int, png_set_interlace_handling, (png_structp png_ptr));\n#endif\n\n#if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED)\n/* Invert monochrome files */\nPNG_EXPORT(46, void, png_set_invert_mono, (png_structp png_ptr));\n#endif\n\n#ifdef PNG_READ_BACKGROUND_SUPPORTED\n/* Handle alpha and tRNS by replacing with a background color.  Prior to\n * libpng-1.5.4 this API must not be called before the PNG file header has been\n * read.  Doing so will result in unexpected behavior and possible warnings or\n * errors if the PNG file contains a bKGD chunk.\n */\nPNG_FP_EXPORT(47, void, png_set_background, (png_structp png_ptr,\n    png_const_color_16p background_color, int background_gamma_code,\n    int need_expand, double background_gamma));\nPNG_FIXED_EXPORT(215, void, png_set_background_fixed, (png_structp png_ptr,\n    png_const_color_16p background_color, int background_gamma_code,\n    int need_expand, png_fixed_point background_gamma));\n#endif\n#ifdef PNG_READ_BACKGROUND_SUPPORTED\n#  define PNG_BACKGROUND_GAMMA_UNKNOWN 0\n#  define PNG_BACKGROUND_GAMMA_SCREEN  1\n#  define PNG_BACKGROUND_GAMMA_FILE    2\n#  define PNG_BACKGROUND_GAMMA_UNIQUE  3\n#endif\n\n#ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED\n/* Scale a 16-bit depth file down to 8-bit, accurately. */\nPNG_EXPORT(229, void, png_set_scale_16, (png_structp png_ptr));\n#endif\n\n#ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED\n#define PNG_READ_16_TO_8 SUPPORTED /* Name prior to 1.5.4 */\n/* Strip the second byte of information from a 16-bit depth file. */\nPNG_EXPORT(48, void, png_set_strip_16, (png_structp png_ptr));\n#endif\n\n#ifdef PNG_READ_QUANTIZE_SUPPORTED\n/* Turn on quantizing, and reduce the palette to the number of colors\n * available.\n */\nPNG_EXPORT(49, void, png_set_quantize,\n    (png_structp png_ptr, png_colorp palette,\n    int num_palette, int maximum_colors, png_const_uint_16p histogram,\n    int full_quantize));\n#endif\n\n#ifdef PNG_READ_GAMMA_SUPPORTED\n/* The threshold on gamma processing is configurable but hard-wired into the\n * library.  The following is the floating point variant.\n */\n#define PNG_GAMMA_THRESHOLD (PNG_GAMMA_THRESHOLD_FIXED*.00001)\n\n/* Handle gamma correction. Screen_gamma=(display_exponent).\n * NOTE: this API simply sets the screen and file gamma values. It will\n * therefore override the value for gamma in a PNG file if it is called after\n * the file header has been read - use with care  - call before reading the PNG\n * file for best results!\n *\n * These routines accept the same gamma values as png_set_alpha_mode (described\n * above).  The PNG_GAMMA_ defines and PNG_DEFAULT_sRGB can be passed to either\n * API (floating point or fixed.)  Notice, however, that the 'file_gamma' value\n * is the inverse of a 'screen gamma' value.\n */\nPNG_FP_EXPORT(50, void, png_set_gamma,\n    (png_structp png_ptr, double screen_gamma,\n    double override_file_gamma));\nPNG_FIXED_EXPORT(208, void, png_set_gamma_fixed, (png_structp png_ptr,\n    png_fixed_point screen_gamma, png_fixed_point override_file_gamma));\n#endif\n\n#ifdef PNG_WRITE_FLUSH_SUPPORTED\n/* Set how many lines between output flushes - 0 for no flushing */\nPNG_EXPORT(51, void, png_set_flush, (png_structp png_ptr, int nrows));\n/* Flush the current PNG output buffer */\nPNG_EXPORT(52, void, png_write_flush, (png_structp png_ptr));\n#endif\n\n/* Optional update palette with requested transformations */\nPNG_EXPORT(53, void, png_start_read_image, (png_structp png_ptr));\n\n/* Optional call to update the users info structure */\nPNG_EXPORT(54, void, png_read_update_info,\n    (png_structp png_ptr, png_infop info_ptr));\n\n#ifdef PNG_SEQUENTIAL_READ_SUPPORTED\n/* Read one or more rows of image data. */\nPNG_EXPORT(55, void, png_read_rows, (png_structp png_ptr, png_bytepp row,\n    png_bytepp display_row, png_uint_32 num_rows));\n#endif\n\n#ifdef PNG_SEQUENTIAL_READ_SUPPORTED\n/* Read a row of data. */\nPNG_EXPORT(56, void, png_read_row, (png_structp png_ptr, png_bytep row,\n    png_bytep display_row));\n#endif\n\n#ifdef PNG_SEQUENTIAL_READ_SUPPORTED\n/* Read the whole image into memory at once. */\nPNG_EXPORT(57, void, png_read_image, (png_structp png_ptr, png_bytepp image));\n#endif\n\n/* Write a row of image data */\nPNG_EXPORT(58, void, png_write_row,\n    (png_structp png_ptr, png_const_bytep row));\n\n/* Write a few rows of image data: (*row) is not written; however, the type\n * is declared as writeable to maintain compatibility with previous versions\n * of libpng and to allow the 'display_row' array from read_rows to be passed\n * unchanged to write_rows.\n */\nPNG_EXPORT(59, void, png_write_rows, (png_structp png_ptr, png_bytepp row,\n    png_uint_32 num_rows));\n\n/* Write the image data */\nPNG_EXPORT(60, void, png_write_image,\n    (png_structp png_ptr, png_bytepp image));\n\n/* Write the end of the PNG file. */\nPNG_EXPORT(61, void, png_write_end,\n    (png_structp png_ptr, png_infop info_ptr));\n\n#ifdef PNG_SEQUENTIAL_READ_SUPPORTED\n/* Read the end of the PNG file. */\nPNG_EXPORT(62, void, png_read_end, (png_structp png_ptr, png_infop info_ptr));\n#endif\n\n/* Free any memory associated with the png_info_struct */\nPNG_EXPORT(63, void, png_destroy_info_struct, (png_structp png_ptr,\n    png_infopp info_ptr_ptr));\n\n/* Free any memory associated with the png_struct and the png_info_structs */\nPNG_EXPORT(64, void, png_destroy_read_struct, (png_structpp png_ptr_ptr,\n    png_infopp info_ptr_ptr, png_infopp end_info_ptr_ptr));\n\n/* Free any memory associated with the png_struct and the png_info_structs */\nPNG_EXPORT(65, void, png_destroy_write_struct, (png_structpp png_ptr_ptr,\n    png_infopp info_ptr_ptr));\n\n/* Set the libpng method of handling chunk CRC errors */\nPNG_EXPORT(66, void, png_set_crc_action,\n    (png_structp png_ptr, int crit_action, int ancil_action));\n\n/* Values for png_set_crc_action() say how to handle CRC errors in\n * ancillary and critical chunks, and whether to use the data contained\n * therein.  Note that it is impossible to \"discard\" data in a critical\n * chunk.  For versions prior to 0.90, the action was always error/quit,\n * whereas in version 0.90 and later, the action for CRC errors in ancillary\n * chunks is warn/discard.  These values should NOT be changed.\n *\n *      value                       action:critical     action:ancillary\n */\n#define PNG_CRC_DEFAULT       0  /* error/quit          warn/discard data */\n#define PNG_CRC_ERROR_QUIT    1  /* error/quit          error/quit        */\n#define PNG_CRC_WARN_DISCARD  2  /* (INVALID)           warn/discard data */\n#define PNG_CRC_WARN_USE      3  /* warn/use data       warn/use data     */\n#define PNG_CRC_QUIET_USE     4  /* quiet/use data      quiet/use data    */\n#define PNG_CRC_NO_CHANGE     5  /* use current value   use current value */\n\n/* These functions give the user control over the scan-line filtering in\n * libpng and the compression methods used by zlib.  These functions are\n * mainly useful for testing, as the defaults should work with most users.\n * Those users who are tight on memory or want faster performance at the\n * expense of compression can modify them.  See the compression library\n * header file (zlib.h) for an explination of the compression functions.\n */\n\n/* Set the filtering method(s) used by libpng.  Currently, the only valid\n * value for \"method\" is 0.\n */\nPNG_EXPORT(67, void, png_set_filter,\n    (png_structp png_ptr, int method, int filters));\n\n/* Flags for png_set_filter() to say which filters to use.  The flags\n * are chosen so that they don't conflict with real filter types\n * below, in case they are supplied instead of the #defined constants.\n * These values should NOT be changed.\n */\n#define PNG_NO_FILTERS     0x00\n#define PNG_FILTER_NONE    0x08\n#define PNG_FILTER_SUB     0x10\n#define PNG_FILTER_UP      0x20\n#define PNG_FILTER_AVG     0x40\n#define PNG_FILTER_PAETH   0x80\n#define PNG_ALL_FILTERS (PNG_FILTER_NONE | PNG_FILTER_SUB | PNG_FILTER_UP | \\\n                         PNG_FILTER_AVG | PNG_FILTER_PAETH)\n\n/* Filter values (not flags) - used in pngwrite.c, pngwutil.c for now.\n * These defines should NOT be changed.\n */\n#define PNG_FILTER_VALUE_NONE  0\n#define PNG_FILTER_VALUE_SUB   1\n#define PNG_FILTER_VALUE_UP    2\n#define PNG_FILTER_VALUE_AVG   3\n#define PNG_FILTER_VALUE_PAETH 4\n#define PNG_FILTER_VALUE_LAST  5\n\n#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED /* EXPERIMENTAL */\n/* The \"heuristic_method\" is given by one of the PNG_FILTER_HEURISTIC_\n * defines, either the default (minimum-sum-of-absolute-differences), or\n * the experimental method (weighted-minimum-sum-of-absolute-differences).\n *\n * Weights are factors >= 1.0, indicating how important it is to keep the\n * filter type consistent between rows.  Larger numbers mean the current\n * filter is that many times as likely to be the same as the \"num_weights\"\n * previous filters.  This is cumulative for each previous row with a weight.\n * There needs to be \"num_weights\" values in \"filter_weights\", or it can be\n * NULL if the weights aren't being specified.  Weights have no influence on\n * the selection of the first row filter.  Well chosen weights can (in theory)\n * improve the compression for a given image.\n *\n * Costs are factors >= 1.0 indicating the relative decoding costs of a\n * filter type.  Higher costs indicate more decoding expense, and are\n * therefore less likely to be selected over a filter with lower computational\n * costs.  There needs to be a value in \"filter_costs\" for each valid filter\n * type (given by PNG_FILTER_VALUE_LAST), or it can be NULL if you aren't\n * setting the costs.  Costs try to improve the speed of decompression without\n * unduly increasing the compressed image size.\n *\n * A negative weight or cost indicates the default value is to be used, and\n * values in the range [0.0, 1.0) indicate the value is to remain unchanged.\n * The default values for both weights and costs are currently 1.0, but may\n * change if good general weighting/cost heuristics can be found.  If both\n * the weights and costs are set to 1.0, this degenerates the WEIGHTED method\n * to the UNWEIGHTED method, but with added encoding time/computation.\n */\nPNG_FP_EXPORT(68, void, png_set_filter_heuristics, (png_structp png_ptr,\n    int heuristic_method, int num_weights, png_const_doublep filter_weights,\n    png_const_doublep filter_costs));\nPNG_FIXED_EXPORT(209, void, png_set_filter_heuristics_fixed,\n    (png_structp png_ptr,\n    int heuristic_method, int num_weights, png_const_fixed_point_p\n    filter_weights, png_const_fixed_point_p filter_costs));\n#endif /*  PNG_WRITE_WEIGHTED_FILTER_SUPPORTED */\n\n/* Heuristic used for row filter selection.  These defines should NOT be\n * changed.\n */\n#define PNG_FILTER_HEURISTIC_DEFAULT    0  /* Currently \"UNWEIGHTED\" */\n#define PNG_FILTER_HEURISTIC_UNWEIGHTED 1  /* Used by libpng < 0.95 */\n#define PNG_FILTER_HEURISTIC_WEIGHTED   2  /* Experimental feature */\n#define PNG_FILTER_HEURISTIC_LAST       3  /* Not a valid value */\n\n#ifdef PNG_WRITE_SUPPORTED\n/* Set the library compression level.  Currently, valid values range from\n * 0 - 9, corresponding directly to the zlib compression levels 0 - 9\n * (0 - no compression, 9 - \"maximal\" compression).  Note that tests have\n * shown that zlib compression levels 3-6 usually perform as well as level 9\n * for PNG images, and do considerably fewer caclulations.  In the future,\n * these values may not correspond directly to the zlib compression levels.\n */\nPNG_EXPORT(69, void, png_set_compression_level,\n    (png_structp png_ptr, int level));\n\nPNG_EXPORT(70, void, png_set_compression_mem_level, (png_structp png_ptr,\n    int mem_level));\n\nPNG_EXPORT(71, void, png_set_compression_strategy, (png_structp png_ptr,\n    int strategy));\n\n/* If PNG_WRITE_OPTIMIZE_CMF_SUPPORTED is defined, libpng will use a\n * smaller value of window_bits if it can do so safely.\n */\nPNG_EXPORT(72, void, png_set_compression_window_bits, (png_structp png_ptr,\n    int window_bits));\n\nPNG_EXPORT(73, void, png_set_compression_method, (png_structp png_ptr,\n    int method));\n#endif\n\n#ifdef PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED\n/* Also set zlib parameters for compressing non-IDAT chunks */\nPNG_EXPORT(222, void, png_set_text_compression_level,\n    (png_structp png_ptr, int level));\n\nPNG_EXPORT(223, void, png_set_text_compression_mem_level, (png_structp png_ptr,\n    int mem_level));\n\nPNG_EXPORT(224, void, png_set_text_compression_strategy, (png_structp png_ptr,\n    int strategy));\n\n/* If PNG_WRITE_OPTIMIZE_CMF_SUPPORTED is defined, libpng will use a\n * smaller value of window_bits if it can do so safely.\n */\nPNG_EXPORT(225, void, png_set_text_compression_window_bits, (png_structp\n    png_ptr, int window_bits));\n\nPNG_EXPORT(226, void, png_set_text_compression_method, (png_structp png_ptr,\n    int method));\n#endif /* PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED */\n\n/* These next functions are called for input/output, memory, and error\n * handling.  They are in the file pngrio.c, pngwio.c, and pngerror.c,\n * and call standard C I/O routines such as fread(), fwrite(), and\n * fprintf().  These functions can be made to use other I/O routines\n * at run time for those applications that need to handle I/O in a\n * different manner by calling png_set_???_fn().  See libpng-manual.txt for\n * more information.\n */\n\n#ifdef PNG_STDIO_SUPPORTED\n/* Initialize the input/output for the PNG file to the default functions. */\nPNG_EXPORT(74, void, png_init_io, (png_structp png_ptr, png_FILE_p fp));\n#endif\n\n/* Replace the (error and abort), and warning functions with user\n * supplied functions.  If no messages are to be printed you must still\n * write and use replacement functions. The replacement error_fn should\n * still do a longjmp to the last setjmp location if you are using this\n * method of error handling.  If error_fn or warning_fn is NULL, the\n * default function will be used.\n */\n\nPNG_EXPORT(75, void, png_set_error_fn,\n    (png_structp png_ptr, png_voidp error_ptr,\n    png_error_ptr error_fn, png_error_ptr warning_fn));\n\n/* Return the user pointer associated with the error functions */\nPNG_EXPORT(76, png_voidp, png_get_error_ptr, (png_const_structp png_ptr));\n\n/* Replace the default data output functions with a user supplied one(s).\n * If buffered output is not used, then output_flush_fn can be set to NULL.\n * If PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng compile time\n * output_flush_fn will be ignored (and thus can be NULL).\n * It is probably a mistake to use NULL for output_flush_fn if\n * write_data_fn is not also NULL unless you have built libpng with\n * PNG_WRITE_FLUSH_SUPPORTED undefined, because in this case libpng's\n * default flush function, which uses the standard *FILE structure, will\n * be used.\n */\nPNG_EXPORT(77, void, png_set_write_fn, (png_structp png_ptr, png_voidp io_ptr,\n    png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn));\n\n/* Replace the default data input function with a user supplied one. */\nPNG_EXPORT(78, void, png_set_read_fn, (png_structp png_ptr, png_voidp io_ptr,\n    png_rw_ptr read_data_fn));\n\n/* Return the user pointer associated with the I/O functions */\nPNG_EXPORT(79, png_voidp, png_get_io_ptr, (png_structp png_ptr));\n\nPNG_EXPORT(80, void, png_set_read_status_fn, (png_structp png_ptr,\n    png_read_status_ptr read_row_fn));\n\nPNG_EXPORT(81, void, png_set_write_status_fn, (png_structp png_ptr,\n    png_write_status_ptr write_row_fn));\n\n#ifdef PNG_USER_MEM_SUPPORTED\n/* Replace the default memory allocation functions with user supplied one(s). */\nPNG_EXPORT(82, void, png_set_mem_fn, (png_structp png_ptr, png_voidp mem_ptr,\n    png_malloc_ptr malloc_fn, png_free_ptr free_fn));\n/* Return the user pointer associated with the memory functions */\nPNG_EXPORT(83, png_voidp, png_get_mem_ptr, (png_const_structp png_ptr));\n#endif\n\n#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED\nPNG_EXPORT(84, void, png_set_read_user_transform_fn, (png_structp png_ptr,\n    png_user_transform_ptr read_user_transform_fn));\n#endif\n\n#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED\nPNG_EXPORT(85, void, png_set_write_user_transform_fn, (png_structp png_ptr,\n    png_user_transform_ptr write_user_transform_fn));\n#endif\n\n#ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED\nPNG_EXPORT(86, void, png_set_user_transform_info, (png_structp png_ptr,\n    png_voidp user_transform_ptr, int user_transform_depth,\n    int user_transform_channels));\n/* Return the user pointer associated with the user transform functions */\nPNG_EXPORT(87, png_voidp, png_get_user_transform_ptr,\n    (png_const_structp png_ptr));\n#endif\n\n#ifdef PNG_USER_TRANSFORM_INFO_SUPPORTED\n/* Return information about the row currently being processed.  Note that these\n * APIs do not fail but will return unexpected results if called outside a user\n * transform callback.  Also note that when transforming an interlaced image the\n * row number is the row number within the sub-image of the interlace pass, so\n * the value will increase to the height of the sub-image (not the full image)\n * then reset to 0 for the next pass.\n *\n * Use PNG_ROW_FROM_PASS_ROW(row, pass) and PNG_COL_FROM_PASS_COL(col, pass) to\n * find the output pixel (x,y) given an interlaced sub-image pixel\n * (row,col,pass).  (See below for these macros.)\n */\nPNG_EXPORT(217, png_uint_32, png_get_current_row_number, (png_const_structp));\nPNG_EXPORT(218, png_byte, png_get_current_pass_number, (png_const_structp));\n#endif\n\n#ifdef PNG_USER_CHUNKS_SUPPORTED\nPNG_EXPORT(88, void, png_set_read_user_chunk_fn, (png_structp png_ptr,\n    png_voidp user_chunk_ptr, png_user_chunk_ptr read_user_chunk_fn));\nPNG_EXPORT(89, png_voidp, png_get_user_chunk_ptr, (png_const_structp png_ptr));\n#endif\n\n#ifdef PNG_PROGRESSIVE_READ_SUPPORTED\n/* Sets the function callbacks for the push reader, and a pointer to a\n * user-defined structure available to the callback functions.\n */\nPNG_EXPORT(90, void, png_set_progressive_read_fn, (png_structp png_ptr,\n    png_voidp progressive_ptr, png_progressive_info_ptr info_fn,\n    png_progressive_row_ptr row_fn, png_progressive_end_ptr end_fn));\n\n/* Returns the user pointer associated with the push read functions */\nPNG_EXPORT(91, png_voidp, png_get_progressive_ptr, (png_const_structp png_ptr));\n\n/* Function to be called when data becomes available */\nPNG_EXPORT(92, void, png_process_data,\n    (png_structp png_ptr, png_infop info_ptr,\n    png_bytep buffer, png_size_t buffer_size));\n\n/* A function which may be called *only* within png_process_data to stop the\n * processing of any more data.  The function returns the number of bytes\n * remaining, excluding any that libpng has cached internally.  A subsequent\n * call to png_process_data must supply these bytes again.  If the argument\n * 'save' is set to true the routine will first save all the pending data and\n * will always return 0.\n */\nPNG_EXPORT(219, png_size_t, png_process_data_pause, (png_structp, int save));\n\n/* A function which may be called *only* outside (after) a call to\n * png_process_data.  It returns the number of bytes of data to skip in the\n * input.  Normally it will return 0, but if it returns a non-zero value the\n * application must skip than number of bytes of input data and pass the\n * following data to the next call to png_process_data.\n */\nPNG_EXPORT(220, png_uint_32, png_process_data_skip, (png_structp));\n\n#ifdef PNG_READ_INTERLACING_SUPPORTED\n/* Function that combines rows.  'new_row' is a flag that should come from\n * the callback and be non-NULL if anything needs to be done; the library\n * stores its own version of the new data internally and ignores the passed\n * in value.\n */\nPNG_EXPORT(93, void, png_progressive_combine_row, (png_structp png_ptr,\n    png_bytep old_row, png_const_bytep new_row));\n#endif /* PNG_READ_INTERLACING_SUPPORTED */\n#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */\n\nPNG_EXPORTA(94, png_voidp, png_malloc,\n    (png_structp png_ptr, png_alloc_size_t size),\n    PNG_ALLOCATED);\n/* Added at libpng version 1.4.0 */\nPNG_EXPORTA(95, png_voidp, png_calloc,\n    (png_structp png_ptr, png_alloc_size_t size),\n    PNG_ALLOCATED);\n\n/* Added at libpng version 1.2.4 */\nPNG_EXPORTA(96, png_voidp, png_malloc_warn, (png_structp png_ptr,\n    png_alloc_size_t size), PNG_ALLOCATED);\n\n/* Frees a pointer allocated by png_malloc() */\nPNG_EXPORT(97, void, png_free, (png_structp png_ptr, png_voidp ptr));\n\n/* Free data that was allocated internally */\nPNG_EXPORT(98, void, png_free_data,\n    (png_structp png_ptr, png_infop info_ptr, png_uint_32 free_me, int num));\n\n/* Reassign responsibility for freeing existing data, whether allocated\n * by libpng or by the application */\nPNG_EXPORT(99, void, png_data_freer,\n    (png_structp png_ptr, png_infop info_ptr, int freer, png_uint_32 mask));\n\n/* Assignments for png_data_freer */\n#define PNG_DESTROY_WILL_FREE_DATA 1\n#define PNG_SET_WILL_FREE_DATA 1\n#define PNG_USER_WILL_FREE_DATA 2\n/* Flags for png_ptr->free_me and info_ptr->free_me */\n#define PNG_FREE_HIST 0x0008\n#define PNG_FREE_ICCP 0x0010\n#define PNG_FREE_SPLT 0x0020\n#define PNG_FREE_ROWS 0x0040\n#define PNG_FREE_PCAL 0x0080\n#define PNG_FREE_SCAL 0x0100\n#define PNG_FREE_UNKN 0x0200\n#define PNG_FREE_LIST 0x0400\n#define PNG_FREE_PLTE 0x1000\n#define PNG_FREE_TRNS 0x2000\n#define PNG_FREE_TEXT 0x4000\n#define PNG_FREE_ALL  0x7fff\n#define PNG_FREE_MUL  0x4220 /* PNG_FREE_SPLT|PNG_FREE_TEXT|PNG_FREE_UNKN */\n\n#ifdef PNG_USER_MEM_SUPPORTED\nPNG_EXPORTA(100, png_voidp, png_malloc_default, (png_structp png_ptr,\n    png_alloc_size_t size), PNG_ALLOCATED);\nPNG_EXPORT(101, void, png_free_default, (png_structp png_ptr, png_voidp ptr));\n#endif\n\n#ifdef PNG_ERROR_TEXT_SUPPORTED\n/* Fatal error in PNG image of libpng - can't continue */\nPNG_EXPORTA(102, void, png_error,\n    (png_structp png_ptr, png_const_charp error_message),\n    PNG_NORETURN);\n\n/* The same, but the chunk name is prepended to the error string. */\nPNG_EXPORTA(103, void, png_chunk_error, (png_structp png_ptr,\n    png_const_charp error_message), PNG_NORETURN);\n\n#else\n/* Fatal error in PNG image of libpng - can't continue */\nPNG_EXPORTA(104, void, png_err, (png_structp png_ptr), PNG_NORETURN);\n#endif\n\n#ifdef PNG_WARNINGS_SUPPORTED\n/* Non-fatal error in libpng.  Can continue, but may have a problem. */\nPNG_EXPORT(105, void, png_warning, (png_structp png_ptr,\n    png_const_charp warning_message));\n\n/* Non-fatal error in libpng, chunk name is prepended to message. */\nPNG_EXPORT(106, void, png_chunk_warning, (png_structp png_ptr,\n    png_const_charp warning_message));\n#endif\n\n#ifdef PNG_BENIGN_ERRORS_SUPPORTED\n/* Benign error in libpng.  Can continue, but may have a problem.\n * User can choose whether to handle as a fatal error or as a warning. */\n#  undef png_benign_error\nPNG_EXPORT(107, void, png_benign_error, (png_structp png_ptr,\n    png_const_charp warning_message));\n\n/* Same, chunk name is prepended to message. */\n#  undef png_chunk_benign_error\nPNG_EXPORT(108, void, png_chunk_benign_error, (png_structp png_ptr,\n    png_const_charp warning_message));\n\nPNG_EXPORT(109, void, png_set_benign_errors,\n    (png_structp png_ptr, int allowed));\n#else\n#  ifdef PNG_ALLOW_BENIGN_ERRORS\n#    define png_benign_error png_warning\n#    define png_chunk_benign_error png_chunk_warning\n#  else\n#    define png_benign_error png_error\n#    define png_chunk_benign_error png_chunk_error\n#  endif\n#endif\n\n/* The png_set_<chunk> functions are for storing values in the png_info_struct.\n * Similarly, the png_get_<chunk> calls are used to read values from the\n * png_info_struct, either storing the parameters in the passed variables, or\n * setting pointers into the png_info_struct where the data is stored.  The\n * png_get_<chunk> functions return a non-zero value if the data was available\n * in info_ptr, or return zero and do not change any of the parameters if the\n * data was not available.\n *\n * These functions should be used instead of directly accessing png_info\n * to avoid problems with future changes in the size and internal layout of\n * png_info_struct.\n */\n/* Returns \"flag\" if chunk data is valid in info_ptr. */\nPNG_EXPORT(110, png_uint_32, png_get_valid,\n    (png_const_structp png_ptr, png_const_infop info_ptr,\n    png_uint_32 flag));\n\n/* Returns number of bytes needed to hold a transformed row. */\nPNG_EXPORT(111, png_size_t, png_get_rowbytes, (png_const_structp png_ptr,\n    png_const_infop info_ptr));\n\n#ifdef PNG_INFO_IMAGE_SUPPORTED\n/* Returns row_pointers, which is an array of pointers to scanlines that was\n * returned from png_read_png().\n */\nPNG_EXPORT(112, png_bytepp, png_get_rows,\n    (png_const_structp png_ptr, png_const_infop info_ptr));\n/* Set row_pointers, which is an array of pointers to scanlines for use\n * by png_write_png().\n */\nPNG_EXPORT(113, void, png_set_rows, (png_structp png_ptr,\n    png_infop info_ptr, png_bytepp row_pointers));\n#endif\n\n/* Returns number of color channels in image. */\nPNG_EXPORT(114, png_byte, png_get_channels,\n    (png_const_structp png_ptr, png_const_infop info_ptr));\n\n#ifdef PNG_EASY_ACCESS_SUPPORTED\n/* Returns image width in pixels. */\nPNG_EXPORT(115, png_uint_32, png_get_image_width, (png_const_structp png_ptr,\n    png_const_infop info_ptr));\n\n/* Returns image height in pixels. */\nPNG_EXPORT(116, png_uint_32, png_get_image_height, (png_const_structp png_ptr,\n    png_const_infop info_ptr));\n\n/* Returns image bit_depth. */\nPNG_EXPORT(117, png_byte, png_get_bit_depth,\n    (png_const_structp png_ptr, png_const_infop info_ptr));\n\n/* Returns image color_type. */\nPNG_EXPORT(118, png_byte, png_get_color_type, (png_const_structp png_ptr,\n    png_const_infop info_ptr));\n\n/* Returns image filter_type. */\nPNG_EXPORT(119, png_byte, png_get_filter_type, (png_const_structp png_ptr,\n    png_const_infop info_ptr));\n\n/* Returns image interlace_type. */\nPNG_EXPORT(120, png_byte, png_get_interlace_type, (png_const_structp png_ptr,\n    png_const_infop info_ptr));\n\n/* Returns image compression_type. */\nPNG_EXPORT(121, png_byte, png_get_compression_type, (png_const_structp png_ptr,\n    png_const_infop info_ptr));\n\n/* Returns image resolution in pixels per meter, from pHYs chunk data. */\nPNG_EXPORT(122, png_uint_32, png_get_pixels_per_meter,\n    (png_const_structp png_ptr, png_const_infop info_ptr));\nPNG_EXPORT(123, png_uint_32, png_get_x_pixels_per_meter,\n    (png_const_structp png_ptr, png_const_infop info_ptr));\nPNG_EXPORT(124, png_uint_32, png_get_y_pixels_per_meter,\n    (png_const_structp png_ptr, png_const_infop info_ptr));\n\n/* Returns pixel aspect ratio, computed from pHYs chunk data.  */\nPNG_FP_EXPORT(125, float, png_get_pixel_aspect_ratio,\n    (png_const_structp png_ptr, png_const_infop info_ptr));\nPNG_FIXED_EXPORT(210, png_fixed_point, png_get_pixel_aspect_ratio_fixed,\n    (png_const_structp png_ptr, png_const_infop info_ptr));\n\n/* Returns image x, y offset in pixels or microns, from oFFs chunk data. */\nPNG_EXPORT(126, png_int_32, png_get_x_offset_pixels,\n    (png_const_structp png_ptr, png_const_infop info_ptr));\nPNG_EXPORT(127, png_int_32, png_get_y_offset_pixels,\n    (png_const_structp png_ptr, png_const_infop info_ptr));\nPNG_EXPORT(128, png_int_32, png_get_x_offset_microns,\n    (png_const_structp png_ptr, png_const_infop info_ptr));\nPNG_EXPORT(129, png_int_32, png_get_y_offset_microns,\n    (png_const_structp png_ptr, png_const_infop info_ptr));\n\n#endif /* PNG_EASY_ACCESS_SUPPORTED */\n\n/* Returns pointer to signature string read from PNG header */\nPNG_EXPORT(130, png_const_bytep, png_get_signature,\n    (png_const_structp png_ptr, png_infop info_ptr));\n\n#ifdef PNG_bKGD_SUPPORTED\nPNG_EXPORT(131, png_uint_32, png_get_bKGD,\n    (png_const_structp png_ptr, png_infop info_ptr,\n    png_color_16p *background));\n#endif\n\n#ifdef PNG_bKGD_SUPPORTED\nPNG_EXPORT(132, void, png_set_bKGD, (png_structp png_ptr, png_infop info_ptr,\n    png_const_color_16p background));\n#endif\n\n#ifdef PNG_cHRM_SUPPORTED\nPNG_FP_EXPORT(133, png_uint_32, png_get_cHRM, (png_const_structp png_ptr,\n   png_const_infop info_ptr, double *white_x, double *white_y, double *red_x,\n    double *red_y, double *green_x, double *green_y, double *blue_x,\n    double *blue_y));\nPNG_FP_EXPORT(230, png_uint_32, png_get_cHRM_XYZ, (png_structp png_ptr,\n    png_const_infop info_ptr, double *red_X, double *red_Y, double *red_Z,\n    double *green_X, double *green_Y, double *green_Z, double *blue_X,\n    double *blue_Y, double *blue_Z));\n#ifdef PNG_FIXED_POINT_SUPPORTED /* Otherwise not implemented */\nPNG_FIXED_EXPORT(134, png_uint_32, png_get_cHRM_fixed,\n    (png_const_structp png_ptr,\n    png_const_infop info_ptr, png_fixed_point *int_white_x,\n    png_fixed_point *int_white_y, png_fixed_point *int_red_x,\n    png_fixed_point *int_red_y, png_fixed_point *int_green_x,\n    png_fixed_point *int_green_y, png_fixed_point *int_blue_x,\n    png_fixed_point *int_blue_y));\n#endif\nPNG_FIXED_EXPORT(231, png_uint_32, png_get_cHRM_XYZ_fixed,\n    (png_structp png_ptr, png_const_infop info_ptr,\n    png_fixed_point *int_red_X, png_fixed_point *int_red_Y,\n    png_fixed_point *int_red_Z, png_fixed_point *int_green_X,\n    png_fixed_point *int_green_Y, png_fixed_point *int_green_Z,\n    png_fixed_point *int_blue_X, png_fixed_point *int_blue_Y,\n    png_fixed_point *int_blue_Z));\n#endif\n\n#ifdef PNG_cHRM_SUPPORTED\nPNG_FP_EXPORT(135, void, png_set_cHRM,\n    (png_structp png_ptr, png_infop info_ptr,\n    double white_x, double white_y, double red_x, double red_y, double green_x,\n    double green_y, double blue_x, double blue_y));\nPNG_FP_EXPORT(232, void, png_set_cHRM_XYZ, (png_structp png_ptr,\n    png_infop info_ptr, double red_X, double red_Y, double red_Z,\n    double green_X, double green_Y, double green_Z, double blue_X,\n    double blue_Y, double blue_Z));\nPNG_FIXED_EXPORT(136, void, png_set_cHRM_fixed, (png_structp png_ptr,\n    png_infop info_ptr, png_fixed_point int_white_x,\n    png_fixed_point int_white_y, png_fixed_point int_red_x,\n    png_fixed_point int_red_y, png_fixed_point int_green_x,\n    png_fixed_point int_green_y, png_fixed_point int_blue_x,\n    png_fixed_point int_blue_y));\nPNG_FIXED_EXPORT(233, void, png_set_cHRM_XYZ_fixed, (png_structp png_ptr,\n    png_infop info_ptr, png_fixed_point int_red_X, png_fixed_point int_red_Y,\n    png_fixed_point int_red_Z, png_fixed_point int_green_X,\n    png_fixed_point int_green_Y, png_fixed_point int_green_Z,\n    png_fixed_point int_blue_X, png_fixed_point int_blue_Y,\n    png_fixed_point int_blue_Z));\n#endif\n\n#ifdef PNG_gAMA_SUPPORTED\nPNG_FP_EXPORT(137, png_uint_32, png_get_gAMA,\n    (png_const_structp png_ptr, png_const_infop info_ptr,\n    double *file_gamma));\nPNG_FIXED_EXPORT(138, png_uint_32, png_get_gAMA_fixed,\n    (png_const_structp png_ptr, png_const_infop info_ptr,\n    png_fixed_point *int_file_gamma));\n#endif\n\n#ifdef PNG_gAMA_SUPPORTED\nPNG_FP_EXPORT(139, void, png_set_gAMA, (png_structp png_ptr,\n    png_infop info_ptr, double file_gamma));\nPNG_FIXED_EXPORT(140, void, png_set_gAMA_fixed, (png_structp png_ptr,\n    png_infop info_ptr, png_fixed_point int_file_gamma));\n#endif\n\n#ifdef PNG_hIST_SUPPORTED\nPNG_EXPORT(141, png_uint_32, png_get_hIST,\n    (png_const_structp png_ptr, png_const_infop info_ptr,\n    png_uint_16p *hist));\n#endif\n\n#ifdef PNG_hIST_SUPPORTED\nPNG_EXPORT(142, void, png_set_hIST, (png_structp png_ptr,\n    png_infop info_ptr, png_const_uint_16p hist));\n#endif\n\nPNG_EXPORT(143, png_uint_32, png_get_IHDR,\n    (png_structp png_ptr, png_infop info_ptr,\n    png_uint_32 *width, png_uint_32 *height, int *bit_depth, int *color_type,\n    int *interlace_method, int *compression_method, int *filter_method));\n\nPNG_EXPORT(144, void, png_set_IHDR,\n    (png_structp png_ptr, png_infop info_ptr,\n    png_uint_32 width, png_uint_32 height, int bit_depth, int color_type,\n    int interlace_method, int compression_method, int filter_method));\n\n#ifdef PNG_oFFs_SUPPORTED\nPNG_EXPORT(145, png_uint_32, png_get_oFFs,\n    (png_const_structp png_ptr, png_const_infop info_ptr,\n    png_int_32 *offset_x, png_int_32 *offset_y, int *unit_type));\n#endif\n\n#ifdef PNG_oFFs_SUPPORTED\nPNG_EXPORT(146, void, png_set_oFFs,\n    (png_structp png_ptr, png_infop info_ptr,\n    png_int_32 offset_x, png_int_32 offset_y, int unit_type));\n#endif\n\n#ifdef PNG_pCAL_SUPPORTED\nPNG_EXPORT(147, png_uint_32, png_get_pCAL,\n    (png_const_structp png_ptr, png_const_infop info_ptr,\n    png_charp *purpose, png_int_32 *X0, png_int_32 *X1, int *type,\n    int *nparams,\n    png_charp *units, png_charpp *params));\n#endif\n\n#ifdef PNG_pCAL_SUPPORTED\nPNG_EXPORT(148, void, png_set_pCAL, (png_structp png_ptr,\n    png_infop info_ptr,\n    png_const_charp purpose, png_int_32 X0, png_int_32 X1, int type,\n    int nparams, png_const_charp units, png_charpp params));\n#endif\n\n#ifdef PNG_pHYs_SUPPORTED\nPNG_EXPORT(149, png_uint_32, png_get_pHYs,\n    (png_const_structp png_ptr, png_const_infop info_ptr,\n    png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type));\n#endif\n\n#ifdef PNG_pHYs_SUPPORTED\nPNG_EXPORT(150, void, png_set_pHYs,\n    (png_structp png_ptr, png_infop info_ptr,\n    png_uint_32 res_x, png_uint_32 res_y, int unit_type));\n#endif\n\nPNG_EXPORT(151, png_uint_32, png_get_PLTE,\n    (png_const_structp png_ptr, png_const_infop info_ptr,\n    png_colorp *palette, int *num_palette));\n\nPNG_EXPORT(152, void, png_set_PLTE,\n    (png_structp png_ptr, png_infop info_ptr,\n    png_const_colorp palette, int num_palette));\n\n#ifdef PNG_sBIT_SUPPORTED\nPNG_EXPORT(153, png_uint_32, png_get_sBIT,\n    (png_const_structp png_ptr, png_infop info_ptr,\n    png_color_8p *sig_bit));\n#endif\n\n#ifdef PNG_sBIT_SUPPORTED\nPNG_EXPORT(154, void, png_set_sBIT,\n    (png_structp png_ptr, png_infop info_ptr, png_const_color_8p sig_bit));\n#endif\n\n#ifdef PNG_sRGB_SUPPORTED\nPNG_EXPORT(155, png_uint_32, png_get_sRGB, (png_const_structp png_ptr,\n    png_const_infop info_ptr, int *file_srgb_intent));\n#endif\n\n#ifdef PNG_sRGB_SUPPORTED\nPNG_EXPORT(156, void, png_set_sRGB,\n    (png_structp png_ptr, png_infop info_ptr, int srgb_intent));\nPNG_EXPORT(157, void, png_set_sRGB_gAMA_and_cHRM, (png_structp png_ptr,\n    png_infop info_ptr, int srgb_intent));\n#endif\n\n#ifdef PNG_iCCP_SUPPORTED\nPNG_EXPORT(158, png_uint_32, png_get_iCCP,\n    (png_const_structp png_ptr, png_const_infop info_ptr,\n    png_charpp name, int *compression_type, png_bytepp profile,\n    png_uint_32 *proflen));\n#endif\n\n#ifdef PNG_iCCP_SUPPORTED\nPNG_EXPORT(159, void, png_set_iCCP,\n    (png_structp png_ptr, png_infop info_ptr,\n    png_const_charp name, int compression_type, png_const_bytep profile,\n    png_uint_32 proflen));\n#endif\n\n#ifdef PNG_sPLT_SUPPORTED\nPNG_EXPORT(160, png_uint_32, png_get_sPLT,\n    (png_const_structp png_ptr, png_const_infop info_ptr,\n    png_sPLT_tpp entries));\n#endif\n\n#ifdef PNG_sPLT_SUPPORTED\nPNG_EXPORT(161, void, png_set_sPLT,\n    (png_structp png_ptr, png_infop info_ptr,\n    png_const_sPLT_tp entries, int nentries));\n#endif\n\n#ifdef PNG_TEXT_SUPPORTED\n/* png_get_text also returns the number of text chunks in *num_text */\nPNG_EXPORT(162, png_uint_32, png_get_text,\n    (png_const_structp png_ptr, png_const_infop info_ptr,\n    png_textp *text_ptr, int *num_text));\n#endif\n\n/* Note while png_set_text() will accept a structure whose text,\n * language, and  translated keywords are NULL pointers, the structure\n * returned by png_get_text will always contain regular\n * zero-terminated C strings.  They might be empty strings but\n * they will never be NULL pointers.\n */\n\n#ifdef PNG_TEXT_SUPPORTED\nPNG_EXPORT(163, void, png_set_text,\n    (png_structp png_ptr, png_infop info_ptr,\n    png_const_textp text_ptr, int num_text));\n#endif\n\n#ifdef PNG_tIME_SUPPORTED\nPNG_EXPORT(164, png_uint_32, png_get_tIME,\n    (png_const_structp png_ptr, png_infop info_ptr, png_timep *mod_time));\n#endif\n\n#ifdef PNG_tIME_SUPPORTED\nPNG_EXPORT(165, void, png_set_tIME,\n    (png_structp png_ptr, png_infop info_ptr, png_const_timep mod_time));\n#endif\n\n#ifdef PNG_tRNS_SUPPORTED\nPNG_EXPORT(166, png_uint_32, png_get_tRNS,\n    (png_const_structp png_ptr, png_infop info_ptr,\n    png_bytep *trans_alpha, int *num_trans, png_color_16p *trans_color));\n#endif\n\n#ifdef PNG_tRNS_SUPPORTED\nPNG_EXPORT(167, void, png_set_tRNS,\n    (png_structp png_ptr, png_infop info_ptr,\n    png_const_bytep trans_alpha, int num_trans,\n    png_const_color_16p trans_color));\n#endif\n\n#ifdef PNG_sCAL_SUPPORTED\nPNG_FP_EXPORT(168, png_uint_32, png_get_sCAL,\n    (png_const_structp png_ptr, png_const_infop info_ptr,\n    int *unit, double *width, double *height));\n#ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED\n/* NOTE: this API is currently implemented using floating point arithmetic,\n * consequently it can only be used on systems with floating point support.\n * In any case the range of values supported by png_fixed_point is small and it\n * is highly recommended that png_get_sCAL_s be used instead.\n */\nPNG_FIXED_EXPORT(214, png_uint_32, png_get_sCAL_fixed,\n    (png_structp png_ptr, png_const_infop info_ptr, int *unit,\n    png_fixed_point *width,\n    png_fixed_point *height));\n#endif\nPNG_EXPORT(169, png_uint_32, png_get_sCAL_s,\n    (png_const_structp png_ptr, png_const_infop info_ptr,\n    int *unit, png_charpp swidth, png_charpp sheight));\n\nPNG_FP_EXPORT(170, void, png_set_sCAL,\n    (png_structp png_ptr, png_infop info_ptr,\n    int unit, double width, double height));\nPNG_FIXED_EXPORT(213, void, png_set_sCAL_fixed, (png_structp png_ptr,\n   png_infop info_ptr, int unit, png_fixed_point width,\n   png_fixed_point height));\nPNG_EXPORT(171, void, png_set_sCAL_s,\n    (png_structp png_ptr, png_infop info_ptr,\n    int unit, png_const_charp swidth, png_const_charp sheight));\n#endif /* PNG_sCAL_SUPPORTED */\n\n#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED\n/* Provide a list of chunks and how they are to be handled, if the built-in\n   handling or default unknown chunk handling is not desired.  Any chunks not\n   listed will be handled in the default manner.  The IHDR and IEND chunks\n   must not be listed.  Because this turns off the default handling for chunks\n   that would otherwise be recognized the behavior of libpng transformations may\n   well become incorrect!\n      keep = 0: PNG_HANDLE_CHUNK_AS_DEFAULT: follow default behavior\n           = 1: PNG_HANDLE_CHUNK_NEVER:      do not keep\n           = 2: PNG_HANDLE_CHUNK_IF_SAFE:    keep only if safe-to-copy\n           = 3: PNG_HANDLE_CHUNK_ALWAYS:     keep even if unsafe-to-copy\n*/\nPNG_EXPORT(172, void, png_set_keep_unknown_chunks,\n    (png_structp png_ptr, int keep,\n    png_const_bytep chunk_list, int num_chunks));\n\n/* The handling code is returned; the result is therefore true (non-zero) if\n * special handling is required, false for the default handling.\n */\nPNG_EXPORT(173, int, png_handle_as_unknown, (png_structp png_ptr,\n    png_const_bytep chunk_name));\n#endif\n#ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED\nPNG_EXPORT(174, void, png_set_unknown_chunks, (png_structp png_ptr,\n    png_infop info_ptr, png_const_unknown_chunkp unknowns,\n    int num_unknowns));\nPNG_EXPORT(175, void, png_set_unknown_chunk_location,\n    (png_structp png_ptr, png_infop info_ptr, int chunk, int location));\nPNG_EXPORT(176, int, png_get_unknown_chunks, (png_const_structp png_ptr,\n    png_const_infop info_ptr, png_unknown_chunkpp entries));\n#endif\n\n/* Png_free_data() will turn off the \"valid\" flag for anything it frees.\n * If you need to turn it off for a chunk that your application has freed,\n * you can use png_set_invalid(png_ptr, info_ptr, PNG_INFO_CHNK);\n */\nPNG_EXPORT(177, void, png_set_invalid,\n    (png_structp png_ptr, png_infop info_ptr, int mask));\n\n#ifdef PNG_INFO_IMAGE_SUPPORTED\n/* The \"params\" pointer is currently not used and is for future expansion. */\nPNG_EXPORT(178, void, png_read_png, (png_structp png_ptr, png_infop info_ptr,\n    int transforms, png_voidp params));\nPNG_EXPORT(179, void, png_write_png, (png_structp png_ptr, png_infop info_ptr,\n    int transforms, png_voidp params));\n#endif\n\nPNG_EXPORT(180, png_const_charp, png_get_copyright,\n    (png_const_structp png_ptr));\nPNG_EXPORT(181, png_const_charp, png_get_header_ver,\n    (png_const_structp png_ptr));\nPNG_EXPORT(182, png_const_charp, png_get_header_version,\n    (png_const_structp png_ptr));\nPNG_EXPORT(183, png_const_charp, png_get_libpng_ver,\n    (png_const_structp png_ptr));\n\n#ifdef PNG_MNG_FEATURES_SUPPORTED\nPNG_EXPORT(184, png_uint_32, png_permit_mng_features, (png_structp png_ptr,\n    png_uint_32 mng_features_permitted));\n#endif\n\n/* For use in png_set_keep_unknown, added to version 1.2.6 */\n#define PNG_HANDLE_CHUNK_AS_DEFAULT   0\n#define PNG_HANDLE_CHUNK_NEVER        1\n#define PNG_HANDLE_CHUNK_IF_SAFE      2\n#define PNG_HANDLE_CHUNK_ALWAYS       3\n\n/* Strip the prepended error numbers (\"#nnn \") from error and warning\n * messages before passing them to the error or warning handler.\n */\n#ifdef PNG_ERROR_NUMBERS_SUPPORTED\nPNG_EXPORT(185, void, png_set_strip_error_numbers,\n    (png_structp png_ptr,\n    png_uint_32 strip_mode));\n#endif\n\n/* Added in libpng-1.2.6 */\n#ifdef PNG_SET_USER_LIMITS_SUPPORTED\nPNG_EXPORT(186, void, png_set_user_limits, (png_structp png_ptr,\n    png_uint_32 user_width_max, png_uint_32 user_height_max));\nPNG_EXPORT(187, png_uint_32, png_get_user_width_max,\n    (png_const_structp png_ptr));\nPNG_EXPORT(188, png_uint_32, png_get_user_height_max,\n    (png_const_structp png_ptr));\n/* Added in libpng-1.4.0 */\nPNG_EXPORT(189, void, png_set_chunk_cache_max, (png_structp png_ptr,\n    png_uint_32 user_chunk_cache_max));\nPNG_EXPORT(190, png_uint_32, png_get_chunk_cache_max,\n    (png_const_structp png_ptr));\n/* Added in libpng-1.4.1 */\nPNG_EXPORT(191, void, png_set_chunk_malloc_max, (png_structp png_ptr,\n    png_alloc_size_t user_chunk_cache_max));\nPNG_EXPORT(192, png_alloc_size_t, png_get_chunk_malloc_max,\n    (png_const_structp png_ptr));\n#endif\n\n#if defined(PNG_INCH_CONVERSIONS_SUPPORTED)\nPNG_EXPORT(193, png_uint_32, png_get_pixels_per_inch,\n    (png_const_structp png_ptr, png_const_infop info_ptr));\n\nPNG_EXPORT(194, png_uint_32, png_get_x_pixels_per_inch,\n    (png_const_structp png_ptr, png_const_infop info_ptr));\n\nPNG_EXPORT(195, png_uint_32, png_get_y_pixels_per_inch,\n    (png_const_structp png_ptr, png_const_infop info_ptr));\n\nPNG_FP_EXPORT(196, float, png_get_x_offset_inches,\n    (png_const_structp png_ptr, png_const_infop info_ptr));\n#ifdef PNG_FIXED_POINT_SUPPORTED /* otherwise not implemented. */\nPNG_FIXED_EXPORT(211, png_fixed_point, png_get_x_offset_inches_fixed,\n    (png_structp png_ptr, png_const_infop info_ptr));\n#endif\n\nPNG_FP_EXPORT(197, float, png_get_y_offset_inches, (png_const_structp png_ptr,\n    png_const_infop info_ptr));\n#ifdef PNG_FIXED_POINT_SUPPORTED /* otherwise not implemented. */\nPNG_FIXED_EXPORT(212, png_fixed_point, png_get_y_offset_inches_fixed,\n    (png_structp png_ptr, png_const_infop info_ptr));\n#endif\n\n#  ifdef PNG_pHYs_SUPPORTED\nPNG_EXPORT(198, png_uint_32, png_get_pHYs_dpi, (png_const_structp png_ptr,\n    png_const_infop info_ptr, png_uint_32 *res_x, png_uint_32 *res_y,\n    int *unit_type));\n#  endif /* PNG_pHYs_SUPPORTED */\n#endif  /* PNG_INCH_CONVERSIONS_SUPPORTED */\n\n/* Added in libpng-1.4.0 */\n#ifdef PNG_IO_STATE_SUPPORTED\nPNG_EXPORT(199, png_uint_32, png_get_io_state, (png_structp png_ptr));\n\nPNG_EXPORTA(200, png_const_bytep, png_get_io_chunk_name,\n    (png_structp png_ptr), PNG_DEPRECATED);\nPNG_EXPORT(216, png_uint_32, png_get_io_chunk_type,\n    (png_const_structp png_ptr));\n\n/* The flags returned by png_get_io_state() are the following: */\n#  define PNG_IO_NONE        0x0000   /* no I/O at this moment */\n#  define PNG_IO_READING     0x0001   /* currently reading */\n#  define PNG_IO_WRITING     0x0002   /* currently writing */\n#  define PNG_IO_SIGNATURE   0x0010   /* currently at the file signature */\n#  define PNG_IO_CHUNK_HDR   0x0020   /* currently at the chunk header */\n#  define PNG_IO_CHUNK_DATA  0x0040   /* currently at the chunk data */\n#  define PNG_IO_CHUNK_CRC   0x0080   /* currently at the chunk crc */\n#  define PNG_IO_MASK_OP     0x000f   /* current operation: reading/writing */\n#  define PNG_IO_MASK_LOC    0x00f0   /* current location: sig/hdr/data/crc */\n#endif /* ?PNG_IO_STATE_SUPPORTED */\n\n/* Interlace support.  The following macros are always defined so that if\n * libpng interlace handling is turned off the macros may be used to handle\n * interlaced images within the application.\n */\n#define PNG_INTERLACE_ADAM7_PASSES 7\n\n/* Two macros to return the first row and first column of the original,\n * full, image which appears in a given pass.  'pass' is in the range 0\n * to 6 and the result is in the range 0 to 7.\n */\n#define PNG_PASS_START_ROW(pass) (((1&~(pass))<<(3-((pass)>>1)))&7)\n#define PNG_PASS_START_COL(pass) (((1& (pass))<<(3-(((pass)+1)>>1)))&7)\n\n/* A macro to return the offset between pixels in the output row for a pair of\n * pixels in the input - effectively the inverse of the 'COL_SHIFT' macro that\n * follows.  Note that ROW_OFFSET is the offset from one row to the next whereas\n * COL_OFFSET is from one column to the next, within a row.\n */\n#define PNG_PASS_ROW_OFFSET(pass) ((pass)>2?(8>>(((pass)-1)>>1)):8)\n#define PNG_PASS_COL_OFFSET(pass) (1<<((7-(pass))>>1))\n\n/* Two macros to help evaluate the number of rows or columns in each\n * pass.  This is expressed as a shift - effectively log2 of the number or\n * rows or columns in each 8x8 tile of the original image.\n */\n#define PNG_PASS_ROW_SHIFT(pass) ((pass)>2?(8-(pass))>>1:3)\n#define PNG_PASS_COL_SHIFT(pass) ((pass)>1?(7-(pass))>>1:3)\n\n/* Hence two macros to determine the number of rows or columns in a given\n * pass of an image given its height or width.  In fact these macros may\n * return non-zero even though the sub-image is empty, because the other\n * dimension may be empty for a small image.\n */\n#define PNG_PASS_ROWS(height, pass) (((height)+(((1<<PNG_PASS_ROW_SHIFT(pass))\\\n   -1)-PNG_PASS_START_ROW(pass)))>>PNG_PASS_ROW_SHIFT(pass))\n#define PNG_PASS_COLS(width, pass) (((width)+(((1<<PNG_PASS_COL_SHIFT(pass))\\\n   -1)-PNG_PASS_START_COL(pass)))>>PNG_PASS_COL_SHIFT(pass))\n\n/* For the reader row callbacks (both progressive and sequential) it is\n * necessary to find the row in the output image given a row in an interlaced\n * image, so two more macros:\n */\n#define PNG_ROW_FROM_PASS_ROW(yIn, pass) \\\n   (((yIn)<<PNG_PASS_ROW_SHIFT(pass))+PNG_PASS_START_ROW(pass))\n#define PNG_COL_FROM_PASS_COL(xIn, pass) \\\n   (((xIn)<<PNG_PASS_COL_SHIFT(pass))+PNG_PASS_START_COL(pass))\n\n/* Two macros which return a boolean (0 or 1) saying whether the given row\n * or column is in a particular pass.  These use a common utility macro that\n * returns a mask for a given pass - the offset 'off' selects the row or\n * column version.  The mask has the appropriate bit set for each column in\n * the tile.\n */\n#define PNG_PASS_MASK(pass,off) ( \\\n   ((0x110145AF>>(((7-(off))-(pass))<<2)) & 0xF) | \\\n   ((0x01145AF0>>(((7-(off))-(pass))<<2)) & 0xF0))\n\n#define PNG_ROW_IN_INTERLACE_PASS(y, pass) \\\n   ((PNG_PASS_MASK(pass,0) >> ((y)&7)) & 1)\n#define PNG_COL_IN_INTERLACE_PASS(x, pass) \\\n   ((PNG_PASS_MASK(pass,1) >> ((x)&7)) & 1)\n\n#ifdef PNG_READ_COMPOSITE_NODIV_SUPPORTED\n/* With these routines we avoid an integer divide, which will be slower on\n * most machines.  However, it does take more operations than the corresponding\n * divide method, so it may be slower on a few RISC systems.  There are two\n * shifts (by 8 or 16 bits) and an addition, versus a single integer divide.\n *\n * Note that the rounding factors are NOT supposed to be the same!  128 and\n * 32768 are correct for the NODIV code; 127 and 32767 are correct for the\n * standard method.\n *\n * [Optimized code by Greg Roelofs and Mark Adler...blame us for bugs. :-) ]\n */\n\n /* fg and bg should be in `gamma 1.0' space; alpha is the opacity */\n\n#  define png_composite(composite, fg, alpha, bg)         \\\n     { png_uint_16 temp = (png_uint_16)((png_uint_16)(fg) \\\n           * (png_uint_16)(alpha)                         \\\n           + (png_uint_16)(bg)*(png_uint_16)(255          \\\n           - (png_uint_16)(alpha)) + 128);                \\\n       (composite) = (png_byte)((temp + (temp >> 8)) >> 8); }\n\n#  define png_composite_16(composite, fg, alpha, bg)       \\\n     { png_uint_32 temp = (png_uint_32)((png_uint_32)(fg)  \\\n           * (png_uint_32)(alpha)                          \\\n           + (png_uint_32)(bg)*(65535                      \\\n           - (png_uint_32)(alpha)) + 32768);               \\\n       (composite) = (png_uint_16)((temp + (temp >> 16)) >> 16); }\n\n#else  /* Standard method using integer division */\n\n#  define png_composite(composite, fg, alpha, bg)                          \\\n     (composite) = (png_byte)(((png_uint_16)(fg) * (png_uint_16)(alpha) +  \\\n     (png_uint_16)(bg) * (png_uint_16)(255 - (png_uint_16)(alpha)) +       \\\n     127) / 255)\n\n#  define png_composite_16(composite, fg, alpha, bg)                         \\\n     (composite) = (png_uint_16)(((png_uint_32)(fg) * (png_uint_32)(alpha) + \\\n     (png_uint_32)(bg)*(png_uint_32)(65535 - (png_uint_32)(alpha)) +         \\\n     32767) / 65535)\n#endif /* PNG_READ_COMPOSITE_NODIV_SUPPORTED */\n\n#ifdef PNG_READ_INT_FUNCTIONS_SUPPORTED\nPNG_EXPORT(201, png_uint_32, png_get_uint_32, (png_const_bytep buf));\nPNG_EXPORT(202, png_uint_16, png_get_uint_16, (png_const_bytep buf));\nPNG_EXPORT(203, png_int_32, png_get_int_32, (png_const_bytep buf));\n#endif\n\nPNG_EXPORT(204, png_uint_32, png_get_uint_31, (png_structp png_ptr,\n    png_const_bytep buf));\n/* No png_get_int_16 -- may be added if there's a real need for it. */\n\n/* Place a 32-bit number into a buffer in PNG byte order (big-endian). */\n#ifdef PNG_WRITE_INT_FUNCTIONS_SUPPORTED\nPNG_EXPORT(205, void, png_save_uint_32, (png_bytep buf, png_uint_32 i));\n#endif\n#ifdef PNG_SAVE_INT_32_SUPPORTED\nPNG_EXPORT(206, void, png_save_int_32, (png_bytep buf, png_int_32 i));\n#endif\n\n/* Place a 16-bit number into a buffer in PNG byte order.\n * The parameter is declared unsigned int, not png_uint_16,\n * just to avoid potential problems on pre-ANSI C compilers.\n */\n#ifdef PNG_WRITE_INT_FUNCTIONS_SUPPORTED\nPNG_EXPORT(207, void, png_save_uint_16, (png_bytep buf, unsigned int i));\n/* No png_save_int_16 -- may be added if there's a real need for it. */\n#endif\n\n#ifdef PNG_USE_READ_MACROS\n/* Inline macros to do direct reads of bytes from the input buffer.\n * The png_get_int_32() routine assumes we are using two's complement\n * format for negative values, which is almost certainly true.\n */\n#  define png_get_uint_32(buf) \\\n     (((png_uint_32)(*(buf)) << 24) + \\\n      ((png_uint_32)(*((buf) + 1)) << 16) + \\\n      ((png_uint_32)(*((buf) + 2)) << 8) + \\\n      ((png_uint_32)(*((buf) + 3))))\n\n   /* From libpng-1.4.0 until 1.4.4, the png_get_uint_16 macro (but not the\n    * function) incorrectly returned a value of type png_uint_32.\n    */\n#  define png_get_uint_16(buf) \\\n     ((png_uint_16) \\\n      (((unsigned int)(*(buf)) << 8) + \\\n       ((unsigned int)(*((buf) + 1)))))\n\n#  define png_get_int_32(buf) \\\n     ((png_int_32)((*(buf) & 0x80) \\\n      ? -((png_int_32)((png_get_uint_32(buf) ^ 0xffffffffL) + 1)) \\\n      : (png_int_32)png_get_uint_32(buf)))\n#endif\n\n/* Maintainer: Put new public prototypes here ^, in libpng.3, and project\n * defs\n */\n\n/* The last ordinal number (this is the *last* one already used; the next\n * one to use is one more than this.)  Maintainer, remember to add an entry to\n * scripts/symbols.def as well.\n */\n#ifdef PNG_EXPORT_LAST_ORDINAL\n  PNG_EXPORT_LAST_ORDINAL(233);\n#endif\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* PNG_VERSION_INFO_ONLY */\n/* Do not put anything past this line */\n#endif /* PNG_H */\n"
  },
  {
    "path": "Projects/Tools/PNGAlphaPremultiplier/Native/Source/LibPng/pngconf.h",
    "content": "\n/* pngconf.h - machine configurable file for libpng\n *\n * libpng version 1.5.9 - February 18, 2012\n *\n * Copyright (c) 1998-2012 Glenn Randers-Pehrson\n * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)\n * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)\n *\n * This code is released under the libpng license.\n * For conditions of distribution and use, see the disclaimer\n * and license in png.h\n *\n */\n\n/* Any machine specific code is near the front of this file, so if you\n * are configuring libpng for a machine, you may want to read the section\n * starting here down to where it starts to typedef png_color, png_text,\n * and png_info.\n */\n\n#ifndef PNGCONF_H\n#define PNGCONF_H\n\n#ifndef PNG_BUILDING_SYMBOL_TABLE\n/* PNG_NO_LIMITS_H may be used to turn off the use of the standard C\n * definition file for  machine specific limits, this may impact the\n * correctness of the definitons below (see uses of INT_MAX).\n */\n#  ifndef PNG_NO_LIMITS_H\n#    include <limits.h>\n#  endif\n\n/* For the memory copy APIs (i.e. the standard definitions of these),\n * because this file defines png_memcpy and so on the base APIs must\n * be defined here.\n */\n#  ifdef BSD\n#    include <strings.h>\n#  else\n#    include <string.h>\n#  endif\n\n/* For png_FILE_p - this provides the standard definition of a\n * FILE\n */\n#  ifdef PNG_STDIO_SUPPORTED\n#    include <stdio.h>\n#  endif\n#endif\n\n/* This controls optimization of the reading of 16 and 32 bit values\n * from PNG files.  It can be set on a per-app-file basis - it\n * just changes whether a macro is used to the function is called.\n * The library builder sets the default, if read functions are not\n * built into the library the macro implementation is forced on.\n */\n#ifndef PNG_READ_INT_FUNCTIONS_SUPPORTED\n#  define PNG_USE_READ_MACROS\n#endif\n#if !defined(PNG_NO_USE_READ_MACROS) && !defined(PNG_USE_READ_MACROS)\n#  if PNG_DEFAULT_READ_MACROS\n#    define PNG_USE_READ_MACROS\n#  endif\n#endif\n\n/* COMPILER SPECIFIC OPTIONS.\n *\n * These options are provided so that a variety of difficult compilers\n * can be used.  Some are fixed at build time (e.g. PNG_API_RULE\n * below) but still have compiler specific implementations, others\n * may be changed on a per-file basis when compiling against libpng.\n */\n\n/* The PNGARG macro protects us against machines that don't have function\n * prototypes (ie K&R style headers).  If your compiler does not handle\n * function prototypes, define this macro and use the included ansi2knr.\n * I've always been able to use _NO_PROTO as the indicator, but you may\n * need to drag the empty declaration out in front of here, or change the\n * ifdef to suit your own needs.\n */\n#ifndef PNGARG\n\n#  ifdef OF /* zlib prototype munger */\n#    define PNGARG(arglist) OF(arglist)\n#  else\n\n#    ifdef _NO_PROTO\n#      define PNGARG(arglist) ()\n#    else\n#      define PNGARG(arglist) arglist\n#    endif /* _NO_PROTO */\n\n#  endif /* OF */\n\n#endif /* PNGARG */\n\n/* Function calling conventions.\n * =============================\n * Normally it is not necessary to specify to the compiler how to call\n * a function - it just does it - however on x86 systems derived from\n * Microsoft and Borland C compilers ('IBM PC', 'DOS', 'Windows' systems\n * and some others) there are multiple ways to call a function and the\n * default can be changed on the compiler command line.  For this reason\n * libpng specifies the calling convention of every exported function and\n * every function called via a user supplied function pointer.  This is\n * done in this file by defining the following macros:\n *\n * PNGAPI    Calling convention for exported functions.\n * PNGCBAPI  Calling convention for user provided (callback) functions.\n * PNGCAPI   Calling convention used by the ANSI-C library (required\n *           for longjmp callbacks and sometimes used internally to\n *           specify the calling convention for zlib).\n *\n * These macros should never be overridden.  If it is necessary to\n * change calling convention in a private build this can be done\n * by setting PNG_API_RULE (which defaults to 0) to one of the values\n * below to select the correct 'API' variants.\n *\n * PNG_API_RULE=0 Use PNGCAPI - the 'C' calling convention - throughout.\n *                This is correct in every known environment.\n * PNG_API_RULE=1 Use the operating system convention for PNGAPI and\n *                the 'C' calling convention (from PNGCAPI) for\n *                callbacks (PNGCBAPI).  This is no longer required\n *                in any known environment - if it has to be used\n *                please post an explanation of the problem to the\n *                libpng mailing list.\n *\n * These cases only differ if the operating system does not use the C\n * calling convention, at present this just means the above cases\n * (x86 DOS/Windows sytems) and, even then, this does not apply to\n * Cygwin running on those systems.\n *\n * Note that the value must be defined in pnglibconf.h so that what\n * the application uses to call the library matches the conventions\n * set when building the library.\n */\n\n/* Symbol export\n * =============\n * When building a shared library it is almost always necessary to tell\n * the compiler which symbols to export.  The png.h macro 'PNG_EXPORT'\n * is used to mark the symbols.  On some systems these symbols can be\n * extracted at link time and need no special processing by the compiler,\n * on other systems the symbols are flagged by the compiler and just\n * the declaration requires a special tag applied (unfortunately) in a\n * compiler dependent way.  Some systems can do either.\n *\n * A small number of older systems also require a symbol from a DLL to\n * be flagged to the program that calls it.  This is a problem because\n * we do not know in the header file included by application code that\n * the symbol will come from a shared library, as opposed to a statically\n * linked one.  For this reason the application must tell us by setting\n * the magic flag PNG_USE_DLL to turn on the special processing before\n * it includes png.h.\n *\n * Four additional macros are used to make this happen:\n *\n * PNG_IMPEXP The magic (if any) to cause a symbol to be exported from\n *            the build or imported if PNG_USE_DLL is set - compiler\n *            and system specific.\n *\n * PNG_EXPORT_TYPE(type) A macro that pre or appends PNG_IMPEXP to\n *                       'type', compiler specific.\n *\n * PNG_DLL_EXPORT Set to the magic to use during a libpng build to\n *                make a symbol exported from the DLL.  Not used in the\n *                public header files; see pngpriv.h for how it is used\n *                in the libpng build.\n *\n * PNG_DLL_IMPORT Set to the magic to force the libpng symbols to come\n *                from a DLL - used to define PNG_IMPEXP when\n *                PNG_USE_DLL is set.\n */\n\n/* System specific discovery.\n * ==========================\n * This code is used at build time to find PNG_IMPEXP, the API settings\n * and PNG_EXPORT_TYPE(), it may also set a macro to indicate the DLL\n * import processing is possible.  On Windows/x86 systems it also sets\n * compiler-specific macros to the values required to change the calling\n * conventions of the various functions.\n */\n#if ( defined(_Windows) || defined(_WINDOWS) || defined(WIN32) ||\\\n      defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) ) &&\\\n    ( defined(_X86_) || defined(_X64_) || defined(_M_IX86) ||\\\n      defined(_M_X64) || defined(_M_IA64) )\n  /* Windows system (DOS doesn't support DLLs) running on x86/x64.  Includes\n   * builds under Cygwin or MinGW.  Also includes Watcom builds but these need\n   * special treatment because they are not compatible with GCC or Visual C\n   * because of different calling conventions.\n   */\n#  if PNG_API_RULE == 2\n    /* If this line results in an error, either because __watcall is not\n     * understood or because of a redefine just below you cannot use *this*\n     * build of the library with the compiler you are using.  *This* build was\n     * build using Watcom and applications must also be built using Watcom!\n     */\n#    define PNGCAPI __watcall\n#  endif\n\n#  if defined(__GNUC__) || (defined (_MSC_VER) && (_MSC_VER >= 800))\n#    define PNGCAPI __cdecl\n#    if PNG_API_RULE == 1\n#      define PNGAPI __stdcall\n#    endif\n#  else\n    /* An older compiler, or one not detected (erroneously) above,\n     * if necessary override on the command line to get the correct\n     * variants for the compiler.\n     */\n#    ifndef PNGCAPI\n#      define PNGCAPI _cdecl\n#    endif\n#    if PNG_API_RULE == 1 && !defined(PNGAPI)\n#      define PNGAPI _stdcall\n#    endif\n#  endif /* compiler/api */\n  /* NOTE: PNGCBAPI always defaults to PNGCAPI. */\n\n#  if defined(PNGAPI) && !defined(PNG_USER_PRIVATEBUILD)\n   ERROR: PNG_USER_PRIVATEBUILD must be defined if PNGAPI is changed\n#  endif\n\n#  if (defined(_MSC_VER) && _MSC_VER < 800) ||\\\n      (defined(__BORLANDC__) && __BORLANDC__ < 0x500)\n    /* older Borland and MSC\n     * compilers used '__export' and required this to be after\n     * the type.\n     */\n#    ifndef PNG_EXPORT_TYPE\n#      define PNG_EXPORT_TYPE(type) type PNG_IMPEXP\n#    endif\n#    define PNG_DLL_EXPORT __export\n#  else /* newer compiler */\n#    define PNG_DLL_EXPORT __declspec(dllexport)\n#    ifndef PNG_DLL_IMPORT\n#      define PNG_DLL_IMPORT __declspec(dllimport)\n#    endif\n#  endif /* compiler */\n\n#else /* !Windows/x86 */\n#  if (defined(__IBMC__) || defined(__IBMCPP__)) && defined(__OS2__)\n#    define PNGAPI _System\n#  else /* !Windows/x86 && !OS/2 */\n    /* Use the defaults, or define PNG*API on the command line (but\n     * this will have to be done for every compile!)\n     */\n#  endif /* other system, !OS/2 */\n#endif /* !Windows/x86 */\n\n/* Now do all the defaulting . */\n#ifndef PNGCAPI\n#  define PNGCAPI\n#endif\n#ifndef PNGCBAPI\n#  define PNGCBAPI PNGCAPI\n#endif\n#ifndef PNGAPI\n#  define PNGAPI PNGCAPI\n#endif\n\n/* PNG_IMPEXP may be set on the compilation system command line or (if not set)\n * then in an internal header file when building the library, otherwise (when\n * using the library) it is set here.\n */\n#ifndef PNG_IMPEXP\n#  if defined(PNG_USE_DLL) && defined(PNG_DLL_IMPORT)\n     /* This forces use of a DLL, disallowing static linking */\n#    define PNG_IMPEXP PNG_DLL_IMPORT\n#  endif\n\n#  ifndef PNG_IMPEXP\n#    define PNG_IMPEXP\n#  endif\n#endif\n\n/* In 1.5.2 the definition of PNG_FUNCTION has been changed to always treat\n * 'attributes' as a storage class - the attributes go at the start of the\n * function definition, and attributes are always appended regardless of the\n * compiler.  This considerably simplifies these macros but may cause problems\n * if any compilers both need function attributes and fail to handle them as\n * a storage class (this is unlikely.)\n */\n#ifndef PNG_FUNCTION\n#  define PNG_FUNCTION(type, name, args, attributes) attributes type name args\n#endif\n\n#ifndef PNG_EXPORT_TYPE\n#  define PNG_EXPORT_TYPE(type) PNG_IMPEXP type\n#endif\n\n   /* The ordinal value is only relevant when preprocessing png.h for symbol\n    * table entries, so we discard it here.  See the .dfn files in the\n    * scripts directory.\n    */\n#ifndef PNG_EXPORTA\n\n#  define PNG_EXPORTA(ordinal, type, name, args, attributes)\\\n      PNG_FUNCTION(PNG_EXPORT_TYPE(type),(PNGAPI name),PNGARG(args), \\\n        extern attributes)\n#endif\n\n/* ANSI-C (C90) does not permit a macro to be invoked with an empty argument,\n * so make something non-empty to satisfy the requirement:\n */\n#define PNG_EMPTY /*empty list*/\n\n#define PNG_EXPORT(ordinal, type, name, args)\\\n   PNG_EXPORTA(ordinal, type, name, args, PNG_EMPTY)\n\n/* Use PNG_REMOVED to comment out a removed interface. */\n#ifndef PNG_REMOVED\n#  define PNG_REMOVED(ordinal, type, name, args, attributes)\n#endif\n\n#ifndef PNG_CALLBACK\n#  define PNG_CALLBACK(type, name, args) type (PNGCBAPI name) PNGARG(args)\n#endif\n\n/* Support for compiler specific function attributes.  These are used\n * so that where compiler support is available incorrect use of API\n * functions in png.h will generate compiler warnings.\n *\n * Added at libpng-1.2.41.\n */\n\n#ifndef PNG_NO_PEDANTIC_WARNINGS\n#  ifndef PNG_PEDANTIC_WARNINGS_SUPPORTED\n#    define PNG_PEDANTIC_WARNINGS_SUPPORTED\n#  endif\n#endif\n\n#ifdef PNG_PEDANTIC_WARNINGS_SUPPORTED\n  /* Support for compiler specific function attributes.  These are used\n   * so that where compiler support is available incorrect use of API\n   * functions in png.h will generate compiler warnings.  Added at libpng\n   * version 1.2.41.\n   */\n#  if defined(__GNUC__)\n#    ifndef PNG_USE_RESULT\n#      define PNG_USE_RESULT __attribute__((__warn_unused_result__))\n#    endif\n#    ifndef PNG_NORETURN\n#      define PNG_NORETURN   __attribute__((__noreturn__))\n#    endif\n#    ifndef PNG_ALLOCATED\n#      define PNG_ALLOCATED  __attribute__((__malloc__))\n#    endif\n#    ifndef PNG_DEPRECATED\n#      define PNG_DEPRECATED __attribute__((__deprecated__))\n#    endif\n#    ifndef PNG_PRIVATE\n#      if 0 /* Doesn't work so we use deprecated instead*/\n#        define PNG_PRIVATE \\\n          __attribute__((warning(\"This function is not exported by libpng.\")))\n#      else\n#        define PNG_PRIVATE \\\n          __attribute__((__deprecated__))\n#      endif\n#    endif\n#  endif /* __GNUC__ */\n\n#  if defined(_MSC_VER)  && (_MSC_VER >= 1300)\n#    ifndef PNG_USE_RESULT\n#      define PNG_USE_RESULT /* not supported */\n#    endif\n#    ifndef PNG_NORETURN\n#      define PNG_NORETURN __declspec(noreturn)\n#    endif\n#    ifndef PNG_ALLOCATED\n#      if (_MSC_VER >= 1400)\n#        define PNG_ALLOCATED __declspec(restrict)\n#      endif\n#    endif\n#    ifndef PNG_DEPRECATED\n#      define PNG_DEPRECATED __declspec(deprecated)\n#    endif\n#    ifndef PNG_PRIVATE\n#      define PNG_PRIVATE __declspec(deprecated)\n#    endif\n#  endif /* _MSC_VER */\n#endif /* PNG_PEDANTIC_WARNINGS */\n\n#ifndef PNG_DEPRECATED\n#  define PNG_DEPRECATED  /* Use of this function is deprecated */\n#endif\n#ifndef PNG_USE_RESULT\n#  define PNG_USE_RESULT  /* The result of this function must be checked */\n#endif\n#ifndef PNG_NORETURN\n#  define PNG_NORETURN    /* This function does not return */\n#endif\n#ifndef PNG_ALLOCATED\n#  define PNG_ALLOCATED   /* The result of the function is new memory */\n#endif\n#ifndef PNG_PRIVATE\n#  define PNG_PRIVATE     /* This is a private libpng function */\n#endif\n#ifndef PNG_FP_EXPORT     /* A floating point API. */\n#  ifdef PNG_FLOATING_POINT_SUPPORTED\n#     define PNG_FP_EXPORT(ordinal, type, name, args)\\\n         PNG_EXPORT(ordinal, type, name, args)\n#  else                   /* No floating point APIs */\n#     define PNG_FP_EXPORT(ordinal, type, name, args)\n#  endif\n#endif\n#ifndef PNG_FIXED_EXPORT  /* A fixed point API. */\n#  ifdef PNG_FIXED_POINT_SUPPORTED\n#     define PNG_FIXED_EXPORT(ordinal, type, name, args)\\\n         PNG_EXPORT(ordinal, type, name, args)\n#  else                   /* No fixed point APIs */\n#     define PNG_FIXED_EXPORT(ordinal, type, name, args)\n#  endif\n#endif\n\n/* The following uses const char * instead of char * for error\n * and warning message functions, so some compilers won't complain.\n * If you do not want to use const, define PNG_NO_CONST here.\n *\n * This should not change how the APIs are called, so it can be done\n * on a per-file basis in the application.\n */\n#ifndef PNG_CONST\n#  ifndef PNG_NO_CONST\n#    define PNG_CONST const\n#  else\n#    define PNG_CONST\n#  endif\n#endif\n\n/* Some typedefs to get us started.  These should be safe on most of the\n * common platforms.  The typedefs should be at least as large as the\n * numbers suggest (a png_uint_32 must be at least 32 bits long), but they\n * don't have to be exactly that size.  Some compilers dislike passing\n * unsigned shorts as function parameters, so you may be better off using\n * unsigned int for png_uint_16.\n */\n\n#if defined(INT_MAX) && (INT_MAX > 0x7ffffffeL)\ntypedef unsigned int png_uint_32;\ntypedef int png_int_32;\n#else\ntypedef unsigned long png_uint_32;\ntypedef long png_int_32;\n#endif\ntypedef unsigned short png_uint_16;\ntypedef short png_int_16;\ntypedef unsigned char png_byte;\n\n#ifdef PNG_NO_SIZE_T\ntypedef unsigned int png_size_t;\n#else\ntypedef size_t png_size_t;\n#endif\n#define png_sizeof(x) (sizeof (x))\n\n/* The following is needed for medium model support.  It cannot be in the\n * pngpriv.h header.  Needs modification for other compilers besides\n * MSC.  Model independent support declares all arrays and pointers to be\n * large using the far keyword.  The zlib version used must also support\n * model independent data.  As of version zlib 1.0.4, the necessary changes\n * have been made in zlib.  The USE_FAR_KEYWORD define triggers other\n * changes that are needed. (Tim Wegner)\n */\n\n/* Separate compiler dependencies (problem here is that zlib.h always\n * defines FAR. (SJT)\n */\n#ifdef __BORLANDC__\n#  if defined(__LARGE__) || defined(__HUGE__) || defined(__COMPACT__)\n#    define LDATA 1\n#  else\n#    define LDATA 0\n#  endif\n  /* GRR:  why is Cygwin in here?  Cygwin is not Borland C... */\n#  if !defined(__WIN32__) && !defined(__FLAT__) && !defined(__CYGWIN__)\n#    define PNG_MAX_MALLOC_64K /* only used in build */\n#    if (LDATA != 1)\n#      ifndef FAR\n#        define FAR __far\n#      endif\n#      define USE_FAR_KEYWORD\n#    endif   /* LDATA != 1 */\n         /* Possibly useful for moving data out of default segment.\n          * Uncomment it if you want. Could also define FARDATA as\n          * const if your compiler supports it. (SJT)\n#        define FARDATA FAR\n          */\n#  endif  /* __WIN32__, __FLAT__, __CYGWIN__ */\n#endif   /* __BORLANDC__ */\n\n\n/* Suggest testing for specific compiler first before testing for\n * FAR.  The Watcom compiler defines both __MEDIUM__ and M_I86MM,\n * making reliance oncertain keywords suspect. (SJT)\n */\n\n/* MSC Medium model */\n#ifdef FAR\n#  ifdef M_I86MM\n#    define USE_FAR_KEYWORD\n#    define FARDATA FAR\n#    include <dos.h>\n#  endif\n#endif\n\n/* SJT: default case */\n#ifndef FAR\n#  define FAR\n#endif\n\n/* At this point FAR is always defined */\n#ifndef FARDATA\n#  define FARDATA\n#endif\n\n/* Typedef for floating-point numbers that are converted\n * to fixed-point with a multiple of 100,000, e.g., gamma\n */\ntypedef png_int_32 png_fixed_point;\n\n/* Add typedefs for pointers */\ntypedef void                      FAR * png_voidp;\ntypedef PNG_CONST void            FAR * png_const_voidp;\ntypedef png_byte                  FAR * png_bytep;\ntypedef PNG_CONST png_byte        FAR * png_const_bytep;\ntypedef png_uint_32               FAR * png_uint_32p;\ntypedef PNG_CONST png_uint_32     FAR * png_const_uint_32p;\ntypedef png_int_32                FAR * png_int_32p;\ntypedef PNG_CONST png_int_32      FAR * png_const_int_32p;\ntypedef png_uint_16               FAR * png_uint_16p;\ntypedef PNG_CONST png_uint_16     FAR * png_const_uint_16p;\ntypedef png_int_16                FAR * png_int_16p;\ntypedef PNG_CONST png_int_16      FAR * png_const_int_16p;\ntypedef char                      FAR * png_charp;\ntypedef PNG_CONST char            FAR * png_const_charp;\ntypedef png_fixed_point           FAR * png_fixed_point_p;\ntypedef PNG_CONST png_fixed_point FAR * png_const_fixed_point_p;\ntypedef png_size_t                FAR * png_size_tp;\ntypedef PNG_CONST png_size_t      FAR * png_const_size_tp;\n\n#ifdef PNG_STDIO_SUPPORTED\ntypedef FILE            * png_FILE_p;\n#endif\n\n#ifdef PNG_FLOATING_POINT_SUPPORTED\ntypedef double           FAR * png_doublep;\ntypedef PNG_CONST double FAR * png_const_doublep;\n#endif\n\n/* Pointers to pointers; i.e. arrays */\ntypedef png_byte        FAR * FAR * png_bytepp;\ntypedef png_uint_32     FAR * FAR * png_uint_32pp;\ntypedef png_int_32      FAR * FAR * png_int_32pp;\ntypedef png_uint_16     FAR * FAR * png_uint_16pp;\ntypedef png_int_16      FAR * FAR * png_int_16pp;\ntypedef PNG_CONST char  FAR * FAR * png_const_charpp;\ntypedef char            FAR * FAR * png_charpp;\ntypedef png_fixed_point FAR * FAR * png_fixed_point_pp;\n#ifdef PNG_FLOATING_POINT_SUPPORTED\ntypedef double          FAR * FAR * png_doublepp;\n#endif\n\n/* Pointers to pointers to pointers; i.e., pointer to array */\ntypedef char            FAR * FAR * FAR * png_charppp;\n\n/* png_alloc_size_t is guaranteed to be no smaller than png_size_t,\n * and no smaller than png_uint_32.  Casts from png_size_t or png_uint_32\n * to png_alloc_size_t are not necessary; in fact, it is recommended\n * not to use them at all so that the compiler can complain when something\n * turns out to be problematic.\n * Casts in the other direction (from png_alloc_size_t to png_size_t or\n * png_uint_32) should be explicitly applied; however, we do not expect\n * to encounter practical situations that require such conversions.\n */\n#if defined(__TURBOC__) && !defined(__FLAT__)\n   typedef unsigned long png_alloc_size_t;\n#else\n#  if defined(_MSC_VER) && defined(MAXSEG_64K)\n     typedef unsigned long    png_alloc_size_t;\n#  else\n     /* This is an attempt to detect an old Windows system where (int) is\n      * actually 16 bits, in that case png_malloc must have an argument with a\n      * bigger size to accomodate the requirements of the library.\n      */\n#    if (defined(_Windows) || defined(_WINDOWS) || defined(_WINDOWS_)) && \\\n        (!defined(INT_MAX) || INT_MAX <= 0x7ffffffeL)\n       typedef DWORD         png_alloc_size_t;\n#    else\n       typedef png_size_t    png_alloc_size_t;\n#    endif\n#  endif\n#endif\n\n#endif /* PNGCONF_H */\n"
  },
  {
    "path": "Projects/Tools/PNGAlphaPremultiplier/Native/Source/LibPng/pngdebug.h",
    "content": "\n/* pngdebug.h - Debugging macros for libpng, also used in pngtest.c\n *\n * Copyright (c) 1998-2011 Glenn Randers-Pehrson\n * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)\n * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)\n *\n * Last changed in libpng 1.5.0 [January 6, 2011]\n *\n * This code is released under the libpng license.\n * For conditions of distribution and use, see the disclaimer\n * and license in png.h\n */\n\n/* Define PNG_DEBUG at compile time for debugging information.  Higher\n * numbers for PNG_DEBUG mean more debugging information.  This has\n * only been added since version 0.95 so it is not implemented throughout\n * libpng yet, but more support will be added as needed.\n *\n * png_debug[1-2]?(level, message ,arg{0-2})\n *   Expands to a statement (either a simple expression or a compound\n *   do..while(0) statement) that outputs a message with parameter\n *   substitution if PNG_DEBUG is defined to 2 or more.  If PNG_DEBUG\n *   is undefined, 0 or 1 every png_debug expands to a simple expression\n *   (actually ((void)0)).\n *\n *   level: level of detail of message, starting at 0.  A level 'n'\n *          message is preceded by 'n' tab characters (not implemented\n *          on Microsoft compilers unless PNG_DEBUG_FILE is also\n *          defined, to allow debug DLL compilation with no standard IO).\n *   message: a printf(3) style text string.  A trailing '\\n' is added\n *            to the message.\n *   arg: 0 to 2 arguments for printf(3) style substitution in message.\n */\n#ifndef PNGDEBUG_H\n#define PNGDEBUG_H\n/* These settings control the formatting of messages in png.c and pngerror.c */\n/* Moved to pngdebug.h at 1.5.0 */\n#  ifndef PNG_LITERAL_SHARP\n#    define PNG_LITERAL_SHARP 0x23\n#  endif\n#  ifndef PNG_LITERAL_LEFT_SQUARE_BRACKET\n#    define PNG_LITERAL_LEFT_SQUARE_BRACKET 0x5b\n#  endif\n#  ifndef PNG_LITERAL_RIGHT_SQUARE_BRACKET\n#    define PNG_LITERAL_RIGHT_SQUARE_BRACKET 0x5d\n#  endif\n#  ifndef PNG_STRING_NEWLINE\n#    define PNG_STRING_NEWLINE \"\\n\"\n#  endif\n\n#ifdef PNG_DEBUG\n#  if (PNG_DEBUG > 0)\n#    if !defined(PNG_DEBUG_FILE) && defined(_MSC_VER)\n#      include <crtdbg.h>\n#      if (PNG_DEBUG > 1)\n#        ifndef _DEBUG\n#          define _DEBUG\n#        endif\n#        ifndef png_debug\n#          define png_debug(l,m)  _RPT0(_CRT_WARN,m PNG_STRING_NEWLINE)\n#        endif\n#        ifndef png_debug1\n#          define png_debug1(l,m,p1)  _RPT1(_CRT_WARN,m PNG_STRING_NEWLINE,p1)\n#        endif\n#        ifndef png_debug2\n#          define png_debug2(l,m,p1,p2) \\\n             _RPT2(_CRT_WARN,m PNG_STRING_NEWLINE,p1,p2)\n#        endif\n#      endif\n#    else /* PNG_DEBUG_FILE || !_MSC_VER */\n#      ifndef PNG_STDIO_SUPPORTED\n#        include <stdio.h> /* not included yet */\n#      endif\n#      ifndef PNG_DEBUG_FILE\n#        define PNG_DEBUG_FILE stderr\n#      endif /* PNG_DEBUG_FILE */\n\n#      if (PNG_DEBUG > 1)\n/* Note: [\"%s\"m PNG_STRING_NEWLINE] probably does not work on\n * non-ISO compilers\n */\n#        ifdef __STDC__\n#          ifndef png_debug\n#            define png_debug(l,m) \\\n       do { \\\n       int num_tabs=l; \\\n       fprintf(PNG_DEBUG_FILE,\"%s\"m PNG_STRING_NEWLINE,(num_tabs==1 ? \"\\t\" : \\\n         (num_tabs==2 ? \"\\t\\t\":(num_tabs>2 ? \"\\t\\t\\t\":\"\")))); \\\n       } while (0)\n#          endif\n#          ifndef png_debug1\n#            define png_debug1(l,m,p1) \\\n       do { \\\n       int num_tabs=l; \\\n       fprintf(PNG_DEBUG_FILE,\"%s\"m PNG_STRING_NEWLINE,(num_tabs==1 ? \"\\t\" : \\\n         (num_tabs==2 ? \"\\t\\t\":(num_tabs>2 ? \"\\t\\t\\t\":\"\"))),p1); \\\n       } while (0)\n#          endif\n#          ifndef png_debug2\n#            define png_debug2(l,m,p1,p2) \\\n       do { \\\n       int num_tabs=l; \\\n       fprintf(PNG_DEBUG_FILE,\"%s\"m PNG_STRING_NEWLINE,(num_tabs==1 ? \"\\t\" : \\\n         (num_tabs==2 ? \"\\t\\t\":(num_tabs>2 ? \"\\t\\t\\t\":\"\"))),p1,p2); \\\n       } while (0)\n#          endif\n#        else /* __STDC __ */\n#          ifndef png_debug\n#            define png_debug(l,m) \\\n       do { \\\n       int num_tabs=l; \\\n       char format[256]; \\\n       snprintf(format,256,\"%s%s%s\",(num_tabs==1 ? \"\\t\" : \\\n         (num_tabs==2 ? \"\\t\\t\":(num_tabs>2 ? \"\\t\\t\\t\":\"\"))), \\\n         m,PNG_STRING_NEWLINE); \\\n       fprintf(PNG_DEBUG_FILE,format); \\\n       } while (0)\n#          endif\n#          ifndef png_debug1\n#            define png_debug1(l,m,p1) \\\n       do { \\\n       int num_tabs=l; \\\n       char format[256]; \\\n       snprintf(format,256,\"%s%s%s\",(num_tabs==1 ? \"\\t\" : \\\n         (num_tabs==2 ? \"\\t\\t\":(num_tabs>2 ? \"\\t\\t\\t\":\"\"))), \\\n         m,PNG_STRING_NEWLINE); \\\n       fprintf(PNG_DEBUG_FILE,format,p1); \\\n       } while (0)\n#          endif\n#          ifndef png_debug2\n#            define png_debug2(l,m,p1,p2) \\\n       do { \\\n       int num_tabs=l; \\\n       char format[256]; \\\n       snprintf(format,256,\"%s%s%s\",(num_tabs==1 ? \"\\t\" : \\\n         (num_tabs==2 ? \"\\t\\t\":(num_tabs>2 ? \"\\t\\t\\t\":\"\"))), \\\n         m,PNG_STRING_NEWLINE); \\\n       fprintf(PNG_DEBUG_FILE,format,p1,p2); \\\n       } while (0)\n#          endif\n#        endif /* __STDC __ */\n#      endif /* (PNG_DEBUG > 1) */\n\n#    endif /* _MSC_VER */\n#  endif /* (PNG_DEBUG > 0) */\n#endif /* PNG_DEBUG */\n#ifndef png_debug\n#  define png_debug(l, m) ((void)0)\n#endif\n#ifndef png_debug1\n#  define png_debug1(l, m, p1) ((void)0)\n#endif\n#ifndef png_debug2\n#  define png_debug2(l, m, p1, p2) ((void)0)\n#endif\n#endif /* PNGDEBUG_H */\n"
  },
  {
    "path": "Projects/Tools/PNGAlphaPremultiplier/Native/Source/LibPng/pngerror.c",
    "content": "\n/* pngerror.c - stub functions for i/o and memory allocation\n *\n * Last changed in libpng 1.5.8 [February 1, 2011]\n * Copyright (c) 1998-2012 Glenn Randers-Pehrson\n * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)\n * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)\n *\n * This code is released under the libpng license.\n * For conditions of distribution and use, see the disclaimer\n * and license in png.h\n *\n * This file provides a location for all error handling.  Users who\n * need special error handling are expected to write replacement functions\n * and use png_set_error_fn() to use those functions.  See the instructions\n * at each function.\n */\n\n#include \"pngpriv.h\"\n\n#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)\n\nstatic PNG_FUNCTION(void, png_default_error,PNGARG((png_structp png_ptr,\n    png_const_charp error_message)),PNG_NORETURN);\n\n#ifdef PNG_WARNINGS_SUPPORTED\nstatic void /* PRIVATE */\npng_default_warning PNGARG((png_structp png_ptr,\n   png_const_charp warning_message));\n#endif /* PNG_WARNINGS_SUPPORTED */\n\n/* This function is called whenever there is a fatal error.  This function\n * should not be changed.  If there is a need to handle errors differently,\n * you should supply a replacement error function and use png_set_error_fn()\n * to replace the error function at run-time.\n */\n#ifdef PNG_ERROR_TEXT_SUPPORTED\nPNG_FUNCTION(void,PNGAPI\npng_error,(png_structp png_ptr, png_const_charp error_message),PNG_NORETURN)\n{\n#ifdef PNG_ERROR_NUMBERS_SUPPORTED\n   char msg[16];\n   if (png_ptr != NULL)\n   {\n      if (png_ptr->flags&\n         (PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT))\n      {\n         if (*error_message == PNG_LITERAL_SHARP)\n         {\n            /* Strip \"#nnnn \" from beginning of error message. */\n            int offset;\n            for (offset = 1; offset<15; offset++)\n               if (error_message[offset] == ' ')\n                  break;\n\n            if (png_ptr->flags&PNG_FLAG_STRIP_ERROR_TEXT)\n            {\n               int i;\n               for (i = 0; i < offset - 1; i++)\n                  msg[i] = error_message[i + 1];\n               msg[i - 1] = '\\0';\n               error_message = msg;\n            }\n\n            else\n               error_message += offset;\n      }\n\n      else\n      {\n         if (png_ptr->flags&PNG_FLAG_STRIP_ERROR_TEXT)\n         {\n            msg[0] = '0';\n            msg[1] = '\\0';\n            error_message = msg;\n         }\n       }\n     }\n   }\n#endif\n   if (png_ptr != NULL && png_ptr->error_fn != NULL)\n      (*(png_ptr->error_fn))(png_ptr, error_message);\n\n   /* If the custom handler doesn't exist, or if it returns,\n      use the default handler, which will not return. */\n   png_default_error(png_ptr, error_message);\n}\n#else\nPNG_FUNCTION(void,PNGAPI\npng_err,(png_structp png_ptr),PNG_NORETURN)\n{\n   /* Prior to 1.5.2 the error_fn received a NULL pointer, expressed\n    * erroneously as '\\0', instead of the empty string \"\".  This was\n    * apparently an error, introduced in libpng-1.2.20, and png_default_error\n    * will crash in this case.\n    */\n   if (png_ptr != NULL && png_ptr->error_fn != NULL)\n      (*(png_ptr->error_fn))(png_ptr, \"\");\n\n   /* If the custom handler doesn't exist, or if it returns,\n      use the default handler, which will not return. */\n   png_default_error(png_ptr, \"\");\n}\n#endif /* PNG_ERROR_TEXT_SUPPORTED */\n\n/* Utility to safely appends strings to a buffer.  This never errors out so\n * error checking is not required in the caller.\n */\nsize_t\npng_safecat(png_charp buffer, size_t bufsize, size_t pos,\n   png_const_charp string)\n{\n   if (buffer != NULL && pos < bufsize)\n   {\n      if (string != NULL)\n         while (*string != '\\0' && pos < bufsize-1)\n           buffer[pos++] = *string++;\n\n      buffer[pos] = '\\0';\n   }\n\n   return pos;\n}\n\n#if defined(PNG_WARNINGS_SUPPORTED) || defined(PNG_TIME_RFC1123_SUPPORTED)\n/* Utility to dump an unsigned value into a buffer, given a start pointer and\n * and end pointer (which should point just *beyond* the end of the buffer!)\n * Returns the pointer to the start of the formatted string.\n */\npng_charp\npng_format_number(png_const_charp start, png_charp end, int format,\n   png_alloc_size_t number)\n{\n   int count = 0;    /* number of digits output */\n   int mincount = 1; /* minimum number required */\n   int output = 0;   /* digit output (for the fixed point format) */\n\n   *--end = '\\0';\n\n   /* This is written so that the loop always runs at least once, even with\n    * number zero.\n    */\n   while (end > start && (number != 0 || count < mincount))\n   {\n\n      static const char digits[] = \"0123456789ABCDEF\";\n\n      switch (format)\n      {\n         case PNG_NUMBER_FORMAT_fixed:\n            /* Needs five digits (the fraction) */\n            mincount = 5;\n            if (output || number % 10 != 0)\n            {\n               *--end = digits[number % 10];\n               output = 1;\n            }\n            number /= 10;\n            break;\n\n         case PNG_NUMBER_FORMAT_02u:\n            /* Expects at least 2 digits. */\n            mincount = 2;\n            /* fall through */\n\n         case PNG_NUMBER_FORMAT_u:\n            *--end = digits[number % 10];\n            number /= 10;\n            break;\n\n         case PNG_NUMBER_FORMAT_02x:\n            /* This format expects at least two digits */\n            mincount = 2;\n            /* fall through */\n\n         case PNG_NUMBER_FORMAT_x:\n            *--end = digits[number & 0xf];\n            number >>= 4;\n            break;\n\n         default: /* an error */\n            number = 0;\n            break;\n      }\n\n      /* Keep track of the number of digits added */\n      ++count;\n\n      /* Float a fixed number here: */\n      if (format == PNG_NUMBER_FORMAT_fixed) if (count == 5) if (end > start)\n      {\n         /* End of the fraction, but maybe nothing was output?  In that case\n          * drop the decimal point.  If the number is a true zero handle that\n          * here.\n          */\n         if (output)\n            *--end = '.';\n         else if (number == 0) /* and !output */\n            *--end = '0';\n      }\n   }\n\n   return end;\n}\n#endif\n\n#ifdef PNG_WARNINGS_SUPPORTED\n/* This function is called whenever there is a non-fatal error.  This function\n * should not be changed.  If there is a need to handle warnings differently,\n * you should supply a replacement warning function and use\n * png_set_error_fn() to replace the warning function at run-time.\n */\nvoid PNGAPI\npng_warning(png_structp png_ptr, png_const_charp warning_message)\n{\n   int offset = 0;\n   if (png_ptr != NULL)\n   {\n#ifdef PNG_ERROR_NUMBERS_SUPPORTED\n   if (png_ptr->flags&\n       (PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT))\n#endif\n      {\n         if (*warning_message == PNG_LITERAL_SHARP)\n         {\n            for (offset = 1; offset < 15; offset++)\n               if (warning_message[offset] == ' ')\n                  break;\n         }\n      }\n   }\n   if (png_ptr != NULL && png_ptr->warning_fn != NULL)\n      (*(png_ptr->warning_fn))(png_ptr, warning_message + offset);\n   else\n      png_default_warning(png_ptr, warning_message + offset);\n}\n\n/* These functions support 'formatted' warning messages with up to\n * PNG_WARNING_PARAMETER_COUNT parameters.  In the format string the parameter\n * is introduced by @<number>, where 'number' starts at 1.  This follows the\n * standard established by X/Open for internationalizable error messages.\n */\nvoid\npng_warning_parameter(png_warning_parameters p, int number,\n   png_const_charp string)\n{\n   if (number > 0 && number <= PNG_WARNING_PARAMETER_COUNT)\n      (void)png_safecat(p[number-1], (sizeof p[number-1]), 0, string);\n}\n\nvoid\npng_warning_parameter_unsigned(png_warning_parameters p, int number, int format,\n   png_alloc_size_t value)\n{\n   char buffer[PNG_NUMBER_BUFFER_SIZE];\n   png_warning_parameter(p, number, PNG_FORMAT_NUMBER(buffer, format, value));\n}\n\nvoid\npng_warning_parameter_signed(png_warning_parameters p, int number, int format,\n   png_int_32 value)\n{\n   png_alloc_size_t u;\n   png_charp str;\n   char buffer[PNG_NUMBER_BUFFER_SIZE];\n\n   /* Avoid overflow by doing the negate in a png_alloc_size_t: */\n   u = (png_alloc_size_t)value;\n   if (value < 0)\n      u = ~u + 1;\n\n   str = PNG_FORMAT_NUMBER(buffer, format, u);\n\n   if (value < 0 && str > buffer)\n      *--str = '-';\n\n   png_warning_parameter(p, number, str);\n}\n\nvoid\npng_formatted_warning(png_structp png_ptr, png_warning_parameters p,\n   png_const_charp message)\n{\n   /* The internal buffer is just 192 bytes - enough for all our messages,\n    * overflow doesn't happen because this code checks!  If someone figures\n    * out how to send us a message longer than 192 bytes, all that will\n    * happen is that the message will be truncated appropriately.\n    */\n   size_t i = 0; /* Index in the msg[] buffer: */\n   char msg[192];\n\n   /* Each iteration through the following loop writes at most one character\n    * to msg[i++] then returns here to validate that there is still space for\n    * the trailing '\\0'.  It may (in the case of a parameter) read more than\n    * one character from message[]; it must check for '\\0' and continue to the\n    * test if it finds the end of string.\n    */\n   while (i<(sizeof msg)-1 && *message != '\\0')\n   {\n      /* '@' at end of string is now just printed (previously it was skipped);\n       * it is an error in the calling code to terminate the string with @.\n       */\n      if (p != NULL && *message == '@' && message[1] != '\\0')\n      {\n         int parameter_char = *++message; /* Consume the '@' */\n         static const char valid_parameters[] = \"123456789\";\n         int parameter = 0;\n\n         /* Search for the parameter digit, the index in the string is the\n          * parameter to use.\n          */\n         while (valid_parameters[parameter] != parameter_char &&\n            valid_parameters[parameter] != '\\0')\n            ++parameter;\n\n         /* If the parameter digit is out of range it will just get printed. */\n         if (parameter < PNG_WARNING_PARAMETER_COUNT)\n         {\n            /* Append this parameter */\n            png_const_charp parm = p[parameter];\n            png_const_charp pend = p[parameter] + (sizeof p[parameter]);\n\n            /* No need to copy the trailing '\\0' here, but there is no guarantee\n             * that parm[] has been initialized, so there is no guarantee of a\n             * trailing '\\0':\n             */\n            while (i<(sizeof msg)-1 && *parm != '\\0' && parm < pend)\n               msg[i++] = *parm++;\n\n            /* Consume the parameter digit too: */\n            ++message;\n            continue;\n         }\n\n         /* else not a parameter and there is a character after the @ sign; just\n          * copy that.  This is known not to be '\\0' because of the test above.\n          */\n      }\n\n      /* At this point *message can't be '\\0', even in the bad parameter case\n       * above where there is a lone '@' at the end of the message string.\n       */\n      msg[i++] = *message++;\n   }\n\n   /* i is always less than (sizeof msg), so: */\n   msg[i] = '\\0';\n\n   /* And this is the formatted message, it may be larger than\n    * PNG_MAX_ERROR_TEXT, but that is only used for 'chunk' errors and these are\n    * not (currently) formatted.\n    */\n   png_warning(png_ptr, msg);\n}\n#endif /* PNG_WARNINGS_SUPPORTED */\n\n#ifdef PNG_BENIGN_ERRORS_SUPPORTED\nvoid PNGAPI\npng_benign_error(png_structp png_ptr, png_const_charp error_message)\n{\n  if (png_ptr->flags & PNG_FLAG_BENIGN_ERRORS_WARN)\n     png_warning(png_ptr, error_message);\n  else\n     png_error(png_ptr, error_message);\n}\n#endif\n\n/* These utilities are used internally to build an error message that relates\n * to the current chunk.  The chunk name comes from png_ptr->chunk_name,\n * this is used to prefix the message.  The message is limited in length\n * to 63 bytes, the name characters are output as hex digits wrapped in []\n * if the character is invalid.\n */\n#define isnonalpha(c) ((c) < 65 || (c) > 122 || ((c) > 90 && (c) < 97))\nstatic PNG_CONST char png_digit[16] = {\n   '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',\n   'A', 'B', 'C', 'D', 'E', 'F'\n};\n\n#define PNG_MAX_ERROR_TEXT 64\n#if defined(PNG_WARNINGS_SUPPORTED) || defined(PNG_ERROR_TEXT_SUPPORTED)\nstatic void /* PRIVATE */\npng_format_buffer(png_structp png_ptr, png_charp buffer, png_const_charp\n    error_message)\n{\n   png_uint_32 chunk_name = png_ptr->chunk_name;\n   int iout = 0, ishift = 24;\n\n   while (ishift >= 0)\n   {\n      int c = (int)(chunk_name >> ishift) & 0xff;\n\n      ishift -= 8;\n      if (isnonalpha(c))\n      {\n         buffer[iout++] = PNG_LITERAL_LEFT_SQUARE_BRACKET;\n         buffer[iout++] = png_digit[(c & 0xf0) >> 4];\n         buffer[iout++] = png_digit[c & 0x0f];\n         buffer[iout++] = PNG_LITERAL_RIGHT_SQUARE_BRACKET;\n      }\n\n      else\n      {\n         buffer[iout++] = (char)c;\n      }\n   }\n\n   if (error_message == NULL)\n      buffer[iout] = '\\0';\n\n   else\n   {\n      int iin = 0;\n\n      buffer[iout++] = ':';\n      buffer[iout++] = ' ';\n\n      while (iin < PNG_MAX_ERROR_TEXT-1 && error_message[iin] != '\\0')\n         buffer[iout++] = error_message[iin++];\n\n      /* iin < PNG_MAX_ERROR_TEXT, so the following is safe: */\n      buffer[iout] = '\\0';\n   }\n}\n#endif /* PNG_WARNINGS_SUPPORTED || PNG_ERROR_TEXT_SUPPORTED */\n\n#if defined(PNG_READ_SUPPORTED) && defined(PNG_ERROR_TEXT_SUPPORTED)\nPNG_FUNCTION(void,PNGAPI\npng_chunk_error,(png_structp png_ptr, png_const_charp error_message),\n   PNG_NORETURN)\n{\n   char msg[18+PNG_MAX_ERROR_TEXT];\n   if (png_ptr == NULL)\n      png_error(png_ptr, error_message);\n\n   else\n   {\n      png_format_buffer(png_ptr, msg, error_message);\n      png_error(png_ptr, msg);\n   }\n}\n#endif /* PNG_READ_SUPPORTED && PNG_ERROR_TEXT_SUPPORTED */\n\n#ifdef PNG_WARNINGS_SUPPORTED\nvoid PNGAPI\npng_chunk_warning(png_structp png_ptr, png_const_charp warning_message)\n{\n   char msg[18+PNG_MAX_ERROR_TEXT];\n   if (png_ptr == NULL)\n      png_warning(png_ptr, warning_message);\n\n   else\n   {\n      png_format_buffer(png_ptr, msg, warning_message);\n      png_warning(png_ptr, msg);\n   }\n}\n#endif /* PNG_WARNINGS_SUPPORTED */\n\n#ifdef PNG_READ_SUPPORTED\n#ifdef PNG_BENIGN_ERRORS_SUPPORTED\nvoid PNGAPI\npng_chunk_benign_error(png_structp png_ptr, png_const_charp error_message)\n{\n   if (png_ptr->flags & PNG_FLAG_BENIGN_ERRORS_WARN)\n      png_chunk_warning(png_ptr, error_message);\n\n   else\n      png_chunk_error(png_ptr, error_message);\n}\n#endif\n#endif /* PNG_READ_SUPPORTED */\n\n#ifdef PNG_ERROR_TEXT_SUPPORTED\n#ifdef PNG_FLOATING_POINT_SUPPORTED\nPNG_FUNCTION(void,\npng_fixed_error,(png_structp png_ptr, png_const_charp name),PNG_NORETURN)\n{\n#  define fixed_message \"fixed point overflow in \"\n#  define fixed_message_ln ((sizeof fixed_message)-1)\n   int  iin;\n   char msg[fixed_message_ln+PNG_MAX_ERROR_TEXT];\n   png_memcpy(msg, fixed_message, fixed_message_ln);\n   iin = 0;\n   if (name != NULL) while (iin < (PNG_MAX_ERROR_TEXT-1) && name[iin] != 0)\n   {\n      msg[fixed_message_ln + iin] = name[iin];\n      ++iin;\n   }\n   msg[fixed_message_ln + iin] = 0;\n   png_error(png_ptr, msg);\n}\n#endif\n#endif\n\n#ifdef PNG_SETJMP_SUPPORTED\n/* This API only exists if ANSI-C style error handling is used,\n * otherwise it is necessary for png_default_error to be overridden.\n */\njmp_buf* PNGAPI\npng_set_longjmp_fn(png_structp png_ptr, png_longjmp_ptr longjmp_fn,\n    size_t jmp_buf_size)\n{\n   if (png_ptr == NULL || jmp_buf_size != png_sizeof(jmp_buf))\n      return NULL;\n\n   png_ptr->longjmp_fn = longjmp_fn;\n   return &png_ptr->longjmp_buffer;\n}\n#endif\n\n/* This is the default error handling function.  Note that replacements for\n * this function MUST NOT RETURN, or the program will likely crash.  This\n * function is used by default, or if the program supplies NULL for the\n * error function pointer in png_set_error_fn().\n */\nstatic PNG_FUNCTION(void /* PRIVATE */,\npng_default_error,(png_structp png_ptr, png_const_charp error_message),\n   PNG_NORETURN)\n{\n#ifdef PNG_CONSOLE_IO_SUPPORTED\n#ifdef PNG_ERROR_NUMBERS_SUPPORTED\n   /* Check on NULL only added in 1.5.4 */\n   if (error_message != NULL && *error_message == PNG_LITERAL_SHARP)\n   {\n      /* Strip \"#nnnn \" from beginning of error message. */\n      int offset;\n      char error_number[16];\n      for (offset = 0; offset<15; offset++)\n      {\n         error_number[offset] = error_message[offset + 1];\n         if (error_message[offset] == ' ')\n            break;\n      }\n\n      if ((offset > 1) && (offset < 15))\n      {\n         error_number[offset - 1] = '\\0';\n         fprintf(stderr, \"libpng error no. %s: %s\",\n             error_number, error_message + offset + 1);\n         fprintf(stderr, PNG_STRING_NEWLINE);\n      }\n\n      else\n      {\n         fprintf(stderr, \"libpng error: %s, offset=%d\",\n             error_message, offset);\n         fprintf(stderr, PNG_STRING_NEWLINE);\n      }\n   }\n   else\n#endif\n   {\n      fprintf(stderr, \"libpng error: %s\", error_message ? error_message :\n         \"undefined\");\n      fprintf(stderr, PNG_STRING_NEWLINE);\n   }\n#else\n   PNG_UNUSED(error_message) /* Make compiler happy */\n#endif\n   png_longjmp(png_ptr, 1);\n}\n\nPNG_FUNCTION(void,PNGAPI\npng_longjmp,(png_structp png_ptr, int val),PNG_NORETURN)\n{\n#ifdef PNG_SETJMP_SUPPORTED\n   if (png_ptr && png_ptr->longjmp_fn)\n   {\n#  ifdef USE_FAR_KEYWORD\n      {\n         jmp_buf tmp_jmpbuf;\n         png_memcpy(tmp_jmpbuf, png_ptr->longjmp_buffer, png_sizeof(jmp_buf));\n         png_ptr->longjmp_fn(tmp_jmpbuf, val);\n      }\n\n#  else\n   png_ptr->longjmp_fn(png_ptr->longjmp_buffer, val);\n#  endif\n   }\n#endif\n   /* Here if not setjmp support or if png_ptr is null. */\n   PNG_ABORT();\n}\n\n#ifdef PNG_WARNINGS_SUPPORTED\n/* This function is called when there is a warning, but the library thinks\n * it can continue anyway.  Replacement functions don't have to do anything\n * here if you don't want them to.  In the default configuration, png_ptr is\n * not used, but it is passed in case it may be useful.\n */\nstatic void /* PRIVATE */\npng_default_warning(png_structp png_ptr, png_const_charp warning_message)\n{\n#ifdef PNG_CONSOLE_IO_SUPPORTED\n#  ifdef PNG_ERROR_NUMBERS_SUPPORTED\n   if (*warning_message == PNG_LITERAL_SHARP)\n   {\n      int offset;\n      char warning_number[16];\n      for (offset = 0; offset < 15; offset++)\n      {\n         warning_number[offset] = warning_message[offset + 1];\n         if (warning_message[offset] == ' ')\n            break;\n      }\n\n      if ((offset > 1) && (offset < 15))\n      {\n         warning_number[offset + 1] = '\\0';\n         fprintf(stderr, \"libpng warning no. %s: %s\",\n             warning_number, warning_message + offset);\n         fprintf(stderr, PNG_STRING_NEWLINE);\n      }\n\n      else\n      {\n         fprintf(stderr, \"libpng warning: %s\",\n             warning_message);\n         fprintf(stderr, PNG_STRING_NEWLINE);\n      }\n   }\n   else\n#  endif\n\n   {\n      fprintf(stderr, \"libpng warning: %s\", warning_message);\n      fprintf(stderr, PNG_STRING_NEWLINE);\n   }\n#else\n   PNG_UNUSED(warning_message) /* Make compiler happy */\n#endif\n   PNG_UNUSED(png_ptr) /* Make compiler happy */\n}\n#endif /* PNG_WARNINGS_SUPPORTED */\n\n/* This function is called when the application wants to use another method\n * of handling errors and warnings.  Note that the error function MUST NOT\n * return to the calling routine or serious problems will occur.  The return\n * method used in the default routine calls longjmp(png_ptr->longjmp_buffer, 1)\n */\nvoid PNGAPI\npng_set_error_fn(png_structp png_ptr, png_voidp error_ptr,\n    png_error_ptr error_fn, png_error_ptr warning_fn)\n{\n   if (png_ptr == NULL)\n      return;\n\n   png_ptr->error_ptr = error_ptr;\n   png_ptr->error_fn = error_fn;\n#ifdef PNG_WARNINGS_SUPPORTED\n   png_ptr->warning_fn = warning_fn;\n#else\n   PNG_UNUSED(warning_fn)\n#endif\n}\n\n\n/* This function returns a pointer to the error_ptr associated with the user\n * functions.  The application should free any memory associated with this\n * pointer before png_write_destroy and png_read_destroy are called.\n */\npng_voidp PNGAPI\npng_get_error_ptr(png_const_structp png_ptr)\n{\n   if (png_ptr == NULL)\n      return NULL;\n\n   return ((png_voidp)png_ptr->error_ptr);\n}\n\n\n#ifdef PNG_ERROR_NUMBERS_SUPPORTED\nvoid PNGAPI\npng_set_strip_error_numbers(png_structp png_ptr, png_uint_32 strip_mode)\n{\n   if (png_ptr != NULL)\n   {\n      png_ptr->flags &=\n         ((~(PNG_FLAG_STRIP_ERROR_NUMBERS |\n         PNG_FLAG_STRIP_ERROR_TEXT))&strip_mode);\n   }\n}\n#endif\n#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */\n"
  },
  {
    "path": "Projects/Tools/PNGAlphaPremultiplier/Native/Source/LibPng/pngget.c",
    "content": "\n/* pngget.c - retrieval of values from info struct\n *\n * Last changed in libpng 1.5.7 [December 15, 2011]\n * Copyright (c) 1998-2011 Glenn Randers-Pehrson\n * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)\n * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)\n *\n * This code is released under the libpng license.\n * For conditions of distribution and use, see the disclaimer\n * and license in png.h\n *\n */\n\n#include \"pngpriv.h\"\n\n#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)\n\npng_uint_32 PNGAPI\npng_get_valid(png_const_structp png_ptr, png_const_infop info_ptr,\n    png_uint_32 flag)\n{\n   if (png_ptr != NULL && info_ptr != NULL)\n      return(info_ptr->valid & flag);\n\n   return(0);\n}\n\npng_size_t PNGAPI\npng_get_rowbytes(png_const_structp png_ptr, png_const_infop info_ptr)\n{\n   if (png_ptr != NULL && info_ptr != NULL)\n      return(info_ptr->rowbytes);\n\n   return(0);\n}\n\n#ifdef PNG_INFO_IMAGE_SUPPORTED\npng_bytepp PNGAPI\npng_get_rows(png_const_structp png_ptr, png_const_infop info_ptr)\n{\n   if (png_ptr != NULL && info_ptr != NULL)\n      return(info_ptr->row_pointers);\n\n   return(0);\n}\n#endif\n\n#ifdef PNG_EASY_ACCESS_SUPPORTED\n/* Easy access to info, added in libpng-0.99 */\npng_uint_32 PNGAPI\npng_get_image_width(png_const_structp png_ptr, png_const_infop info_ptr)\n{\n   if (png_ptr != NULL && info_ptr != NULL)\n      return info_ptr->width;\n\n   return (0);\n}\n\npng_uint_32 PNGAPI\npng_get_image_height(png_const_structp png_ptr, png_const_infop info_ptr)\n{\n   if (png_ptr != NULL && info_ptr != NULL)\n      return info_ptr->height;\n\n   return (0);\n}\n\npng_byte PNGAPI\npng_get_bit_depth(png_const_structp png_ptr, png_const_infop info_ptr)\n{\n   if (png_ptr != NULL && info_ptr != NULL)\n      return info_ptr->bit_depth;\n\n   return (0);\n}\n\npng_byte PNGAPI\npng_get_color_type(png_const_structp png_ptr, png_const_infop info_ptr)\n{\n   if (png_ptr != NULL && info_ptr != NULL)\n      return info_ptr->color_type;\n\n   return (0);\n}\n\npng_byte PNGAPI\npng_get_filter_type(png_const_structp png_ptr, png_const_infop info_ptr)\n{\n   if (png_ptr != NULL && info_ptr != NULL)\n      return info_ptr->filter_type;\n\n   return (0);\n}\n\npng_byte PNGAPI\npng_get_interlace_type(png_const_structp png_ptr, png_const_infop info_ptr)\n{\n   if (png_ptr != NULL && info_ptr != NULL)\n      return info_ptr->interlace_type;\n\n   return (0);\n}\n\npng_byte PNGAPI\npng_get_compression_type(png_const_structp png_ptr, png_const_infop info_ptr)\n{\n   if (png_ptr != NULL && info_ptr != NULL)\n      return info_ptr->compression_type;\n\n   return (0);\n}\n\npng_uint_32 PNGAPI\npng_get_x_pixels_per_meter(png_const_structp png_ptr, png_const_infop info_ptr)\n{\n#ifdef PNG_pHYs_SUPPORTED\n   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))\n      {\n         png_debug1(1, \"in %s retrieval function\",\n             \"png_get_x_pixels_per_meter\");\n\n         if (info_ptr->phys_unit_type == PNG_RESOLUTION_METER)\n            return (info_ptr->x_pixels_per_unit);\n      }\n#endif\n\n   return (0);\n}\n\npng_uint_32 PNGAPI\npng_get_y_pixels_per_meter(png_const_structp png_ptr, png_const_infop info_ptr)\n{\n#ifdef PNG_pHYs_SUPPORTED\n   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))\n   {\n      png_debug1(1, \"in %s retrieval function\",\n          \"png_get_y_pixels_per_meter\");\n\n      if (info_ptr->phys_unit_type == PNG_RESOLUTION_METER)\n         return (info_ptr->y_pixels_per_unit);\n   }\n#endif\n\n   return (0);\n}\n\npng_uint_32 PNGAPI\npng_get_pixels_per_meter(png_const_structp png_ptr, png_const_infop info_ptr)\n{\n#ifdef PNG_pHYs_SUPPORTED\n   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))\n   {\n      png_debug1(1, \"in %s retrieval function\", \"png_get_pixels_per_meter\");\n\n      if (info_ptr->phys_unit_type == PNG_RESOLUTION_METER &&\n          info_ptr->x_pixels_per_unit == info_ptr->y_pixels_per_unit)\n         return (info_ptr->x_pixels_per_unit);\n   }\n#endif\n\n   return (0);\n}\n\n#ifdef PNG_FLOATING_POINT_SUPPORTED\nfloat PNGAPI\npng_get_pixel_aspect_ratio(png_const_structp png_ptr, png_const_infop info_ptr)\n{\n#ifdef PNG_READ_pHYs_SUPPORTED\n   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))\n   {\n      png_debug1(1, \"in %s retrieval function\", \"png_get_aspect_ratio\");\n\n      if (info_ptr->x_pixels_per_unit != 0)\n         return ((float)((float)info_ptr->y_pixels_per_unit\n             /(float)info_ptr->x_pixels_per_unit));\n   }\n#endif\n\n   return ((float)0.0);\n}\n#endif\n\n#ifdef PNG_FIXED_POINT_SUPPORTED\npng_fixed_point PNGAPI\npng_get_pixel_aspect_ratio_fixed(png_const_structp png_ptr,\n    png_const_infop info_ptr)\n{\n#ifdef PNG_READ_pHYs_SUPPORTED\n   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs)\n       && info_ptr->x_pixels_per_unit > 0 && info_ptr->y_pixels_per_unit > 0\n       && info_ptr->x_pixels_per_unit <= PNG_UINT_31_MAX\n       && info_ptr->y_pixels_per_unit <= PNG_UINT_31_MAX)\n   {\n      png_fixed_point res;\n\n      png_debug1(1, \"in %s retrieval function\", \"png_get_aspect_ratio_fixed\");\n\n      /* The following casts work because a PNG 4 byte integer only has a valid\n       * range of 0..2^31-1; otherwise the cast might overflow.\n       */\n      if (png_muldiv(&res, (png_int_32)info_ptr->y_pixels_per_unit, PNG_FP_1,\n          (png_int_32)info_ptr->x_pixels_per_unit))\n         return res;\n   }\n#endif\n\n   return 0;\n}\n#endif\n\npng_int_32 PNGAPI\npng_get_x_offset_microns(png_const_structp png_ptr, png_const_infop info_ptr)\n{\n#ifdef PNG_oFFs_SUPPORTED\n   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs))\n   {\n      png_debug1(1, \"in %s retrieval function\", \"png_get_x_offset_microns\");\n\n      if (info_ptr->offset_unit_type == PNG_OFFSET_MICROMETER)\n         return (info_ptr->x_offset);\n   }\n#endif\n\n   return (0);\n}\n\npng_int_32 PNGAPI\npng_get_y_offset_microns(png_const_structp png_ptr, png_const_infop info_ptr)\n{\n#ifdef PNG_oFFs_SUPPORTED\n   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs))\n   {\n      png_debug1(1, \"in %s retrieval function\", \"png_get_y_offset_microns\");\n\n      if (info_ptr->offset_unit_type == PNG_OFFSET_MICROMETER)\n         return (info_ptr->y_offset);\n   }\n#endif\n\n   return (0);\n}\n\npng_int_32 PNGAPI\npng_get_x_offset_pixels(png_const_structp png_ptr, png_const_infop info_ptr)\n{\n#ifdef PNG_oFFs_SUPPORTED\n   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs))\n   {\n      png_debug1(1, \"in %s retrieval function\", \"png_get_x_offset_pixels\");\n\n      if (info_ptr->offset_unit_type == PNG_OFFSET_PIXEL)\n         return (info_ptr->x_offset);\n   }\n#endif\n\n   return (0);\n}\n\npng_int_32 PNGAPI\npng_get_y_offset_pixels(png_const_structp png_ptr, png_const_infop info_ptr)\n{\n#ifdef PNG_oFFs_SUPPORTED\n   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs))\n   {\n      png_debug1(1, \"in %s retrieval function\", \"png_get_y_offset_pixels\");\n\n      if (info_ptr->offset_unit_type == PNG_OFFSET_PIXEL)\n         return (info_ptr->y_offset);\n   }\n#endif\n\n   return (0);\n}\n\n#ifdef PNG_INCH_CONVERSIONS_SUPPORTED\nstatic png_uint_32\nppi_from_ppm(png_uint_32 ppm)\n{\n#if 0\n   /* The conversion is *(2.54/100), in binary (32 digits):\n    * .00000110100000001001110101001001\n    */\n   png_uint_32 t1001, t1101;\n   ppm >>= 1;                  /* .1 */\n   t1001 = ppm + (ppm >> 3);   /* .1001 */\n   t1101 = t1001 + (ppm >> 1); /* .1101 */\n   ppm >>= 20;                 /* .000000000000000000001 */\n   t1101 += t1101 >> 15;       /* .1101000000000001101 */\n   t1001 >>= 11;               /* .000000000001001 */\n   t1001 += t1001 >> 12;       /* .000000000001001000000001001 */\n   ppm += t1001;               /* .000000000001001000001001001 */\n   ppm += t1101;               /* .110100000001001110101001001 */\n   return (ppm + 16) >> 5;/* .00000110100000001001110101001001 */\n#else\n   /* The argument is a PNG unsigned integer, so it is not permitted\n    * to be bigger than 2^31.\n    */\n   png_fixed_point result;\n   if (ppm <= PNG_UINT_31_MAX && png_muldiv(&result, (png_int_32)ppm, 127,\n       5000))\n      return result;\n\n   /* Overflow. */\n   return 0;\n#endif\n}\n\npng_uint_32 PNGAPI\npng_get_pixels_per_inch(png_const_structp png_ptr, png_const_infop info_ptr)\n{\n   return ppi_from_ppm(png_get_pixels_per_meter(png_ptr, info_ptr));\n}\n\npng_uint_32 PNGAPI\npng_get_x_pixels_per_inch(png_const_structp png_ptr, png_const_infop info_ptr)\n{\n   return ppi_from_ppm(png_get_x_pixels_per_meter(png_ptr, info_ptr));\n}\n\npng_uint_32 PNGAPI\npng_get_y_pixels_per_inch(png_const_structp png_ptr, png_const_infop info_ptr)\n{\n   return ppi_from_ppm(png_get_y_pixels_per_meter(png_ptr, info_ptr));\n}\n\n#ifdef PNG_FIXED_POINT_SUPPORTED\nstatic png_fixed_point\npng_fixed_inches_from_microns(png_structp png_ptr, png_int_32 microns)\n{\n   /* Convert from metres * 1,000,000 to inches * 100,000, meters to\n    * inches is simply *(100/2.54), so we want *(10/2.54) == 500/127.\n    * Notice that this can overflow - a warning is output and 0 is\n    * returned.\n    */\n   return png_muldiv_warn(png_ptr, microns, 500, 127);\n}\n\npng_fixed_point PNGAPI\npng_get_x_offset_inches_fixed(png_structp png_ptr,\n    png_const_infop info_ptr)\n{\n   return png_fixed_inches_from_microns(png_ptr,\n       png_get_x_offset_microns(png_ptr, info_ptr));\n}\n#endif\n\n#ifdef PNG_FIXED_POINT_SUPPORTED\npng_fixed_point PNGAPI\npng_get_y_offset_inches_fixed(png_structp png_ptr,\n    png_const_infop info_ptr)\n{\n   return png_fixed_inches_from_microns(png_ptr,\n       png_get_y_offset_microns(png_ptr, info_ptr));\n}\n#endif\n\n#ifdef PNG_FLOATING_POINT_SUPPORTED\nfloat PNGAPI\npng_get_x_offset_inches(png_const_structp png_ptr, png_const_infop info_ptr)\n{\n   /* To avoid the overflow do the conversion directly in floating\n    * point.\n    */\n   return (float)(png_get_x_offset_microns(png_ptr, info_ptr) * .00003937);\n}\n#endif\n\n#ifdef PNG_FLOATING_POINT_SUPPORTED\nfloat PNGAPI\npng_get_y_offset_inches(png_const_structp png_ptr, png_const_infop info_ptr)\n{\n   /* To avoid the overflow do the conversion directly in floating\n    * point.\n    */\n   return (float)(png_get_y_offset_microns(png_ptr, info_ptr) * .00003937);\n}\n#endif\n\n#ifdef PNG_pHYs_SUPPORTED\npng_uint_32 PNGAPI\npng_get_pHYs_dpi(png_const_structp png_ptr, png_const_infop info_ptr,\n    png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)\n{\n   png_uint_32 retval = 0;\n\n   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))\n   {\n      png_debug1(1, \"in %s retrieval function\", \"pHYs\");\n\n      if (res_x != NULL)\n      {\n         *res_x = info_ptr->x_pixels_per_unit;\n         retval |= PNG_INFO_pHYs;\n      }\n\n      if (res_y != NULL)\n      {\n         *res_y = info_ptr->y_pixels_per_unit;\n         retval |= PNG_INFO_pHYs;\n      }\n\n      if (unit_type != NULL)\n      {\n         *unit_type = (int)info_ptr->phys_unit_type;\n         retval |= PNG_INFO_pHYs;\n\n         if (*unit_type == 1)\n         {\n            if (res_x != NULL) *res_x = (png_uint_32)(*res_x * .0254 + .50);\n            if (res_y != NULL) *res_y = (png_uint_32)(*res_y * .0254 + .50);\n         }\n      }\n   }\n\n   return (retval);\n}\n#endif /* PNG_pHYs_SUPPORTED */\n#endif  /* PNG_INCH_CONVERSIONS_SUPPORTED */\n\n/* png_get_channels really belongs in here, too, but it's been around longer */\n\n#endif  /* PNG_EASY_ACCESS_SUPPORTED */\n\npng_byte PNGAPI\npng_get_channels(png_const_structp png_ptr, png_const_infop info_ptr)\n{\n   if (png_ptr != NULL && info_ptr != NULL)\n      return(info_ptr->channels);\n\n   return (0);\n}\n\npng_const_bytep PNGAPI\npng_get_signature(png_const_structp png_ptr, png_infop info_ptr)\n{\n   if (png_ptr != NULL && info_ptr != NULL)\n      return(info_ptr->signature);\n\n   return (NULL);\n}\n\n#ifdef PNG_bKGD_SUPPORTED\npng_uint_32 PNGAPI\npng_get_bKGD(png_const_structp png_ptr, png_infop info_ptr,\n   png_color_16p *background)\n{\n   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_bKGD)\n       && background != NULL)\n   {\n      png_debug1(1, \"in %s retrieval function\", \"bKGD\");\n\n      *background = &(info_ptr->background);\n      return (PNG_INFO_bKGD);\n   }\n\n   return (0);\n}\n#endif\n\n#ifdef PNG_cHRM_SUPPORTED\n/* The XYZ APIs were added in 1.5.5 to take advantage of the code added at the\n * same time to correct the rgb grayscale coefficient defaults obtained from the\n * cHRM chunk in 1.5.4\n */\npng_uint_32 PNGFAPI\npng_get_cHRM_XYZ_fixed(png_structp png_ptr, png_const_infop info_ptr,\n    png_fixed_point *int_red_X, png_fixed_point *int_red_Y,\n    png_fixed_point *int_red_Z, png_fixed_point *int_green_X,\n    png_fixed_point *int_green_Y, png_fixed_point *int_green_Z,\n    png_fixed_point *int_blue_X, png_fixed_point *int_blue_Y,\n    png_fixed_point *int_blue_Z)\n{\n   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM))\n   {\n      png_xy xy;\n      png_XYZ XYZ;\n\n      png_debug1(1, \"in %s retrieval function\", \"cHRM_XYZ\");\n\n      xy.whitex = info_ptr->x_white;\n      xy.whitey = info_ptr->y_white;\n      xy.redx = info_ptr->x_red;\n      xy.redy = info_ptr->y_red;\n      xy.greenx = info_ptr->x_green;\n      xy.greeny = info_ptr->y_green;\n      xy.bluex = info_ptr->x_blue;\n      xy.bluey = info_ptr->y_blue;\n\n      /* The *_checked function handles error reporting, so just return 0 if\n       * there is a failure here.\n       */\n      if (png_XYZ_from_xy_checked(png_ptr, &XYZ, xy))\n      {\n         if (int_red_X != NULL)\n            *int_red_X = XYZ.redX;\n         if (int_red_Y != NULL)\n            *int_red_Y = XYZ.redY;\n         if (int_red_Z != NULL)\n            *int_red_Z = XYZ.redZ;\n         if (int_green_X != NULL)\n            *int_green_X = XYZ.greenX;\n         if (int_green_Y != NULL)\n            *int_green_Y = XYZ.greenY;\n         if (int_green_Z != NULL)\n            *int_green_Z = XYZ.greenZ;\n         if (int_blue_X != NULL)\n            *int_blue_X = XYZ.blueX;\n         if (int_blue_Y != NULL)\n            *int_blue_Y = XYZ.blueY;\n         if (int_blue_Z != NULL)\n            *int_blue_Z = XYZ.blueZ;\n\n         return (PNG_INFO_cHRM);\n      }\n   }\n\n   return (0);\n}\n\n#  ifdef PNG_FLOATING_POINT_SUPPORTED\npng_uint_32 PNGAPI\npng_get_cHRM(png_const_structp png_ptr, png_const_infop info_ptr,\n    double *white_x, double *white_y, double *red_x, double *red_y,\n    double *green_x, double *green_y, double *blue_x, double *blue_y)\n{\n   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM))\n   {\n      png_debug1(1, \"in %s retrieval function\", \"cHRM\");\n\n      if (white_x != NULL)\n         *white_x = png_float(png_ptr, info_ptr->x_white, \"cHRM white X\");\n      if (white_y != NULL)\n         *white_y = png_float(png_ptr, info_ptr->y_white, \"cHRM white Y\");\n      if (red_x != NULL)\n         *red_x = png_float(png_ptr, info_ptr->x_red, \"cHRM red X\");\n      if (red_y != NULL)\n         *red_y = png_float(png_ptr, info_ptr->y_red, \"cHRM red Y\");\n      if (green_x != NULL)\n         *green_x = png_float(png_ptr, info_ptr->x_green, \"cHRM green X\");\n      if (green_y != NULL)\n         *green_y = png_float(png_ptr, info_ptr->y_green, \"cHRM green Y\");\n      if (blue_x != NULL)\n         *blue_x = png_float(png_ptr, info_ptr->x_blue, \"cHRM blue X\");\n      if (blue_y != NULL)\n         *blue_y = png_float(png_ptr, info_ptr->y_blue, \"cHRM blue Y\");\n      return (PNG_INFO_cHRM);\n   }\n\n   return (0);\n}\n\npng_uint_32 PNGAPI\npng_get_cHRM_XYZ(png_structp png_ptr, png_const_infop info_ptr,\n   double *red_X, double *red_Y, double *red_Z, double *green_X,\n   double *green_Y, double *green_Z, double *blue_X, double *blue_Y,\n   double *blue_Z)\n{\n   png_XYZ XYZ;\n\n   if (png_get_cHRM_XYZ_fixed(png_ptr, info_ptr,\n      &XYZ.redX, &XYZ.redY, &XYZ.redZ, &XYZ.greenX, &XYZ.greenY, &XYZ.greenZ,\n      &XYZ.blueX, &XYZ.blueY, &XYZ.blueZ) & PNG_INFO_cHRM)\n   {\n      if (red_X != NULL)\n         *red_X = png_float(png_ptr, XYZ.redX, \"cHRM red X\");\n      if (red_Y != NULL)\n         *red_Y = png_float(png_ptr, XYZ.redY, \"cHRM red Y\");\n      if (red_Z != NULL)\n         *red_Z = png_float(png_ptr, XYZ.redZ, \"cHRM red Z\");\n      if (green_X != NULL)\n         *green_X = png_float(png_ptr, XYZ.greenX, \"cHRM green X\");\n      if (green_Y != NULL)\n         *green_Y = png_float(png_ptr, XYZ.greenY, \"cHRM green Y\");\n      if (green_Z != NULL)\n         *green_Z = png_float(png_ptr, XYZ.greenZ, \"cHRM green Z\");\n      if (blue_X != NULL)\n         *blue_X = png_float(png_ptr, XYZ.blueX, \"cHRM blue X\");\n      if (blue_Y != NULL)\n         *blue_Y = png_float(png_ptr, XYZ.blueY, \"cHRM blue Y\");\n      if (blue_Z != NULL)\n         *blue_Z = png_float(png_ptr, XYZ.blueZ, \"cHRM blue Z\");\n      return (PNG_INFO_cHRM);\n   }\n\n   return (0);\n}\n#  endif\n\n#  ifdef PNG_FIXED_POINT_SUPPORTED\npng_uint_32 PNGAPI\npng_get_cHRM_fixed(png_const_structp png_ptr, png_const_infop info_ptr,\n    png_fixed_point *white_x, png_fixed_point *white_y, png_fixed_point *red_x,\n    png_fixed_point *red_y, png_fixed_point *green_x, png_fixed_point *green_y,\n    png_fixed_point *blue_x, png_fixed_point *blue_y)\n{\n   png_debug1(1, \"in %s retrieval function\", \"cHRM\");\n\n   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM))\n   {\n      if (white_x != NULL)\n         *white_x = info_ptr->x_white;\n      if (white_y != NULL)\n         *white_y = info_ptr->y_white;\n      if (red_x != NULL)\n         *red_x = info_ptr->x_red;\n      if (red_y != NULL)\n         *red_y = info_ptr->y_red;\n      if (green_x != NULL)\n         *green_x = info_ptr->x_green;\n      if (green_y != NULL)\n         *green_y = info_ptr->y_green;\n      if (blue_x != NULL)\n         *blue_x = info_ptr->x_blue;\n      if (blue_y != NULL)\n         *blue_y = info_ptr->y_blue;\n      return (PNG_INFO_cHRM);\n   }\n\n   return (0);\n}\n#  endif\n#endif\n\n#ifdef PNG_gAMA_SUPPORTED\npng_uint_32 PNGFAPI\npng_get_gAMA_fixed(png_const_structp png_ptr, png_const_infop info_ptr,\n    png_fixed_point *file_gamma)\n{\n   png_debug1(1, \"in %s retrieval function\", \"gAMA\");\n\n   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA)\n       && file_gamma != NULL)\n   {\n      *file_gamma = info_ptr->gamma;\n      return (PNG_INFO_gAMA);\n   }\n\n   return (0);\n}\n#  ifdef PNG_FLOATING_POINT_SUPPORTED\npng_uint_32 PNGAPI\npng_get_gAMA(png_const_structp png_ptr, png_const_infop info_ptr,\n    double *file_gamma)\n{\n   png_fixed_point igamma;\n   png_uint_32 ok = png_get_gAMA_fixed(png_ptr, info_ptr, &igamma);\n\n   if (ok)\n      *file_gamma = png_float(png_ptr, igamma, \"png_get_gAMA\");\n\n   return ok;\n}\n\n#  endif\n#endif\n\n#ifdef PNG_sRGB_SUPPORTED\npng_uint_32 PNGAPI\npng_get_sRGB(png_const_structp png_ptr, png_const_infop info_ptr,\n    int *file_srgb_intent)\n{\n   png_debug1(1, \"in %s retrieval function\", \"sRGB\");\n\n   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sRGB)\n       && file_srgb_intent != NULL)\n   {\n      *file_srgb_intent = (int)info_ptr->srgb_intent;\n      return (PNG_INFO_sRGB);\n   }\n\n   return (0);\n}\n#endif\n\n#ifdef PNG_iCCP_SUPPORTED\npng_uint_32 PNGAPI\npng_get_iCCP(png_const_structp png_ptr, png_const_infop info_ptr,\n    png_charpp name, int *compression_type,\n    png_bytepp profile, png_uint_32 *proflen)\n{\n   png_debug1(1, \"in %s retrieval function\", \"iCCP\");\n\n   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_iCCP)\n       && name != NULL && compression_type != NULL && profile != NULL &&\n\t\t proflen != NULL)\n   {\n      *name = info_ptr->iccp_name;\n      *profile = info_ptr->iccp_profile;\n      /* Compression_type is a dummy so the API won't have to change\n       * if we introduce multiple compression types later.\n       */\n      *proflen = info_ptr->iccp_proflen;\n      *compression_type = info_ptr->iccp_compression;\n      return (PNG_INFO_iCCP);\n   }\n\n   return (0);\n}\n#endif\n\n#ifdef PNG_sPLT_SUPPORTED\npng_uint_32 PNGAPI\npng_get_sPLT(png_const_structp png_ptr, png_const_infop info_ptr,\n    png_sPLT_tpp spalettes)\n{\n   if (png_ptr != NULL && info_ptr != NULL && spalettes != NULL)\n   {\n      *spalettes = info_ptr->splt_palettes;\n      return ((png_uint_32)info_ptr->splt_palettes_num);\n   }\n\n   return (0);\n}\n#endif\n\n#ifdef PNG_hIST_SUPPORTED\npng_uint_32 PNGAPI\npng_get_hIST(png_const_structp png_ptr, png_const_infop info_ptr,\n    png_uint_16p *hist)\n{\n   png_debug1(1, \"in %s retrieval function\", \"hIST\");\n\n   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_hIST)\n       && hist != NULL)\n   {\n      *hist = info_ptr->hist;\n      return (PNG_INFO_hIST);\n   }\n\n   return (0);\n}\n#endif\n\npng_uint_32 PNGAPI\npng_get_IHDR(png_structp png_ptr, png_infop info_ptr,\n    png_uint_32 *width, png_uint_32 *height, int *bit_depth,\n    int *color_type, int *interlace_type, int *compression_type,\n    int *filter_type)\n\n{\n   png_debug1(1, \"in %s retrieval function\", \"IHDR\");\n\n   if (png_ptr == NULL || info_ptr == NULL || width == NULL ||\n       height == NULL || bit_depth == NULL || color_type == NULL)\n      return (0);\n\n   *width = info_ptr->width;\n   *height = info_ptr->height;\n   *bit_depth = info_ptr->bit_depth;\n   *color_type = info_ptr->color_type;\n\n   if (compression_type != NULL)\n      *compression_type = info_ptr->compression_type;\n\n   if (filter_type != NULL)\n      *filter_type = info_ptr->filter_type;\n\n   if (interlace_type != NULL)\n      *interlace_type = info_ptr->interlace_type;\n\n   /* This is redundant if we can be sure that the info_ptr values were all\n    * assigned in png_set_IHDR().  We do the check anyhow in case an\n    * application has ignored our advice not to mess with the members\n    * of info_ptr directly.\n    */\n   png_check_IHDR (png_ptr, info_ptr->width, info_ptr->height,\n       info_ptr->bit_depth, info_ptr->color_type, info_ptr->interlace_type,\n       info_ptr->compression_type, info_ptr->filter_type);\n\n   return (1);\n}\n\n#ifdef PNG_oFFs_SUPPORTED\npng_uint_32 PNGAPI\npng_get_oFFs(png_const_structp png_ptr, png_const_infop info_ptr,\n    png_int_32 *offset_x, png_int_32 *offset_y, int *unit_type)\n{\n   png_debug1(1, \"in %s retrieval function\", \"oFFs\");\n\n   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs)\n       && offset_x != NULL && offset_y != NULL && unit_type != NULL)\n   {\n      *offset_x = info_ptr->x_offset;\n      *offset_y = info_ptr->y_offset;\n      *unit_type = (int)info_ptr->offset_unit_type;\n      return (PNG_INFO_oFFs);\n   }\n\n   return (0);\n}\n#endif\n\n#ifdef PNG_pCAL_SUPPORTED\npng_uint_32 PNGAPI\npng_get_pCAL(png_const_structp png_ptr, png_const_infop info_ptr,\n    png_charp *purpose, png_int_32 *X0, png_int_32 *X1, int *type, int *nparams,\n    png_charp *units, png_charpp *params)\n{\n   png_debug1(1, \"in %s retrieval function\", \"pCAL\");\n\n   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pCAL)\n       && purpose != NULL && X0 != NULL && X1 != NULL && type != NULL &&\n       nparams != NULL && units != NULL && params != NULL)\n   {\n      *purpose = info_ptr->pcal_purpose;\n      *X0 = info_ptr->pcal_X0;\n      *X1 = info_ptr->pcal_X1;\n      *type = (int)info_ptr->pcal_type;\n      *nparams = (int)info_ptr->pcal_nparams;\n      *units = info_ptr->pcal_units;\n      *params = info_ptr->pcal_params;\n      return (PNG_INFO_pCAL);\n   }\n\n   return (0);\n}\n#endif\n\n#ifdef PNG_sCAL_SUPPORTED\n#  ifdef PNG_FIXED_POINT_SUPPORTED\n#    ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED\npng_uint_32 PNGAPI\npng_get_sCAL_fixed(png_structp png_ptr, png_const_infop info_ptr,\n    int *unit, png_fixed_point *width, png_fixed_point *height)\n{\n   if (png_ptr != NULL && info_ptr != NULL &&\n       (info_ptr->valid & PNG_INFO_sCAL))\n   {\n      *unit = info_ptr->scal_unit;\n      /*TODO: make this work without FP support */\n      *width = png_fixed(png_ptr, atof(info_ptr->scal_s_width), \"sCAL width\");\n      *height = png_fixed(png_ptr, atof(info_ptr->scal_s_height),\n         \"sCAL height\");\n      return (PNG_INFO_sCAL);\n   }\n\n   return(0);\n}\n#    endif /* FLOATING_ARITHMETIC */\n#  endif /* FIXED_POINT */\n#  ifdef PNG_FLOATING_POINT_SUPPORTED\npng_uint_32 PNGAPI\npng_get_sCAL(png_const_structp png_ptr, png_const_infop info_ptr,\n    int *unit, double *width, double *height)\n{\n   if (png_ptr != NULL && info_ptr != NULL &&\n       (info_ptr->valid & PNG_INFO_sCAL))\n   {\n      *unit = info_ptr->scal_unit;\n      *width = atof(info_ptr->scal_s_width);\n      *height = atof(info_ptr->scal_s_height);\n      return (PNG_INFO_sCAL);\n   }\n\n   return(0);\n}\n#  endif /* FLOATING POINT */\npng_uint_32 PNGAPI\npng_get_sCAL_s(png_const_structp png_ptr, png_const_infop info_ptr,\n    int *unit, png_charpp width, png_charpp height)\n{\n   if (png_ptr != NULL && info_ptr != NULL &&\n       (info_ptr->valid & PNG_INFO_sCAL))\n   {\n      *unit = info_ptr->scal_unit;\n      *width = info_ptr->scal_s_width;\n      *height = info_ptr->scal_s_height;\n      return (PNG_INFO_sCAL);\n   }\n\n   return(0);\n}\n#endif /* sCAL */\n\n#ifdef PNG_pHYs_SUPPORTED\npng_uint_32 PNGAPI\npng_get_pHYs(png_const_structp png_ptr, png_const_infop info_ptr,\n    png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)\n{\n   png_uint_32 retval = 0;\n\n   png_debug1(1, \"in %s retrieval function\", \"pHYs\");\n\n   if (png_ptr != NULL && info_ptr != NULL &&\n       (info_ptr->valid & PNG_INFO_pHYs))\n   {\n      if (res_x != NULL)\n      {\n         *res_x = info_ptr->x_pixels_per_unit;\n         retval |= PNG_INFO_pHYs;\n      }\n\n      if (res_y != NULL)\n      {\n         *res_y = info_ptr->y_pixels_per_unit;\n         retval |= PNG_INFO_pHYs;\n      }\n\n      if (unit_type != NULL)\n      {\n         *unit_type = (int)info_ptr->phys_unit_type;\n         retval |= PNG_INFO_pHYs;\n      }\n   }\n\n   return (retval);\n}\n#endif /* pHYs */\n\npng_uint_32 PNGAPI\npng_get_PLTE(png_const_structp png_ptr, png_const_infop info_ptr,\n    png_colorp *palette, int *num_palette)\n{\n   png_debug1(1, \"in %s retrieval function\", \"PLTE\");\n\n   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_PLTE)\n       && palette != NULL)\n   {\n      *palette = info_ptr->palette;\n      *num_palette = info_ptr->num_palette;\n      png_debug1(3, \"num_palette = %d\", *num_palette);\n      return (PNG_INFO_PLTE);\n   }\n\n   return (0);\n}\n\n#ifdef PNG_sBIT_SUPPORTED\npng_uint_32 PNGAPI\npng_get_sBIT(png_const_structp png_ptr, png_infop info_ptr,\n    png_color_8p *sig_bit)\n{\n   png_debug1(1, \"in %s retrieval function\", \"sBIT\");\n\n   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sBIT)\n       && sig_bit != NULL)\n   {\n      *sig_bit = &(info_ptr->sig_bit);\n      return (PNG_INFO_sBIT);\n   }\n\n   return (0);\n}\n#endif\n\n#ifdef PNG_TEXT_SUPPORTED\npng_uint_32 PNGAPI\npng_get_text(png_const_structp png_ptr, png_const_infop info_ptr,\n    png_textp *text_ptr, int *num_text)\n{\n   if (png_ptr != NULL && info_ptr != NULL && info_ptr->num_text > 0)\n   {\n      png_debug1(1, \"in 0x%lx retrieval function\",\n         (unsigned long)png_ptr->chunk_name);\n\n      if (text_ptr != NULL)\n         *text_ptr = info_ptr->text;\n\n      if (num_text != NULL)\n         *num_text = info_ptr->num_text;\n\n      return ((png_uint_32)info_ptr->num_text);\n   }\n\n   if (num_text != NULL)\n      *num_text = 0;\n\n   return(0);\n}\n#endif\n\n#ifdef PNG_tIME_SUPPORTED\npng_uint_32 PNGAPI\npng_get_tIME(png_const_structp png_ptr, png_infop info_ptr, png_timep *mod_time)\n{\n   png_debug1(1, \"in %s retrieval function\", \"tIME\");\n\n   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tIME)\n       && mod_time != NULL)\n   {\n      *mod_time = &(info_ptr->mod_time);\n      return (PNG_INFO_tIME);\n   }\n\n   return (0);\n}\n#endif\n\n#ifdef PNG_tRNS_SUPPORTED\npng_uint_32 PNGAPI\npng_get_tRNS(png_const_structp png_ptr, png_infop info_ptr,\n    png_bytep *trans_alpha, int *num_trans, png_color_16p *trans_color)\n{\n   png_uint_32 retval = 0;\n   if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS))\n   {\n      png_debug1(1, \"in %s retrieval function\", \"tRNS\");\n\n      if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)\n      {\n         if (trans_alpha != NULL)\n         {\n            *trans_alpha = info_ptr->trans_alpha;\n            retval |= PNG_INFO_tRNS;\n         }\n\n         if (trans_color != NULL)\n            *trans_color = &(info_ptr->trans_color);\n      }\n\n      else /* if (info_ptr->color_type != PNG_COLOR_TYPE_PALETTE) */\n      {\n         if (trans_color != NULL)\n         {\n            *trans_color = &(info_ptr->trans_color);\n            retval |= PNG_INFO_tRNS;\n         }\n\n         if (trans_alpha != NULL)\n            *trans_alpha = NULL;\n      }\n\n      if (num_trans != NULL)\n      {\n         *num_trans = info_ptr->num_trans;\n         retval |= PNG_INFO_tRNS;\n      }\n   }\n\n   return (retval);\n}\n#endif\n\n#ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED\nint PNGAPI\npng_get_unknown_chunks(png_const_structp png_ptr, png_const_infop info_ptr,\n    png_unknown_chunkpp unknowns)\n{\n   if (png_ptr != NULL && info_ptr != NULL && unknowns != NULL)\n   {\n      *unknowns = info_ptr->unknown_chunks;\n      return info_ptr->unknown_chunks_num;\n   }\n\n   return (0);\n}\n#endif\n\n#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED\npng_byte PNGAPI\npng_get_rgb_to_gray_status (png_const_structp png_ptr)\n{\n   return (png_byte)(png_ptr ? png_ptr->rgb_to_gray_status : 0);\n}\n#endif\n\n#ifdef PNG_USER_CHUNKS_SUPPORTED\npng_voidp PNGAPI\npng_get_user_chunk_ptr(png_const_structp png_ptr)\n{\n   return (png_ptr ? png_ptr->user_chunk_ptr : NULL);\n}\n#endif\n\npng_size_t PNGAPI\npng_get_compression_buffer_size(png_const_structp png_ptr)\n{\n   return (png_ptr ? png_ptr->zbuf_size : 0);\n}\n\n#ifdef PNG_SET_USER_LIMITS_SUPPORTED\n/* These functions were added to libpng 1.2.6 and were enabled\n * by default in libpng-1.4.0 */\npng_uint_32 PNGAPI\npng_get_user_width_max (png_const_structp png_ptr)\n{\n   return (png_ptr ? png_ptr->user_width_max : 0);\n}\n\npng_uint_32 PNGAPI\npng_get_user_height_max (png_const_structp png_ptr)\n{\n   return (png_ptr ? png_ptr->user_height_max : 0);\n}\n\n/* This function was added to libpng 1.4.0 */\npng_uint_32 PNGAPI\npng_get_chunk_cache_max (png_const_structp png_ptr)\n{\n   return (png_ptr ? png_ptr->user_chunk_cache_max : 0);\n}\n\n/* This function was added to libpng 1.4.1 */\npng_alloc_size_t PNGAPI\npng_get_chunk_malloc_max (png_const_structp png_ptr)\n{\n   return (png_ptr ? png_ptr->user_chunk_malloc_max : 0);\n}\n#endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */\n\n/* These functions were added to libpng 1.4.0 */\n#ifdef PNG_IO_STATE_SUPPORTED\npng_uint_32 PNGAPI\npng_get_io_state (png_structp png_ptr)\n{\n   return png_ptr->io_state;\n}\n\npng_uint_32 PNGAPI\npng_get_io_chunk_type (png_const_structp png_ptr)\n{\n   return png_ptr->chunk_name;\n}\n\npng_const_bytep PNGAPI\npng_get_io_chunk_name (png_structp png_ptr)\n{\n   PNG_CSTRING_FROM_CHUNK(png_ptr->io_chunk_string, png_ptr->chunk_name);\n   return png_ptr->io_chunk_string;\n}\n#endif /* ?PNG_IO_STATE_SUPPORTED */\n\n#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */\n"
  },
  {
    "path": "Projects/Tools/PNGAlphaPremultiplier/Native/Source/LibPng/pnginfo.h",
    "content": "\n/* pnginfo.h - header file for PNG reference library\n *\n * Copyright (c) 1998-2011 Glenn Randers-Pehrson\n * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)\n * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)\n *\n * Last changed in libpng 1.5.0 [January 6, 2011]\n *\n * This code is released under the libpng license.\n * For conditions of distribution and use, see the disclaimer\n * and license in png.h\n */\n\n /* png_info is a structure that holds the information in a PNG file so\n * that the application can find out the characteristics of the image.\n * If you are reading the file, this structure will tell you what is\n * in the PNG file.  If you are writing the file, fill in the information\n * you want to put into the PNG file, using png_set_*() functions, then\n * call png_write_info().\n *\n * The names chosen should be very close to the PNG specification, so\n * consult that document for information about the meaning of each field.\n *\n * With libpng < 0.95, it was only possible to directly set and read the\n * the values in the png_info_struct, which meant that the contents and\n * order of the values had to remain fixed.  With libpng 0.95 and later,\n * however, there are now functions that abstract the contents of\n * png_info_struct from the application, so this makes it easier to use\n * libpng with dynamic libraries, and even makes it possible to use\n * libraries that don't have all of the libpng ancillary chunk-handing\n * functionality.  In libpng-1.5.0 this was moved into a separate private\n * file that is not visible to applications.\n *\n * The following members may have allocated storage attached that should be\n * cleaned up before the structure is discarded: palette, trans, text,\n * pcal_purpose, pcal_units, pcal_params, hist, iccp_name, iccp_profile,\n * splt_palettes, scal_unit, row_pointers, and unknowns.   By default, these\n * are automatically freed when the info structure is deallocated, if they were\n * allocated internally by libpng.  This behavior can be changed by means\n * of the png_data_freer() function.\n *\n * More allocation details: all the chunk-reading functions that\n * change these members go through the corresponding png_set_*\n * functions.  A function to clear these members is available: see\n * png_free_data().  The png_set_* functions do not depend on being\n * able to point info structure members to any of the storage they are\n * passed (they make their own copies), EXCEPT that the png_set_text\n * functions use the same storage passed to them in the text_ptr or\n * itxt_ptr structure argument, and the png_set_rows and png_set_unknowns\n * functions do not make their own copies.\n */\n#ifndef PNGINFO_H\n#define PNGINFO_H\n\nstruct png_info_def\n{\n   /* the following are necessary for every PNG file */\n   png_uint_32 width;  /* width of image in pixels (from IHDR) */\n   png_uint_32 height; /* height of image in pixels (from IHDR) */\n   png_uint_32 valid;  /* valid chunk data (see PNG_INFO_ below) */\n   png_size_t rowbytes; /* bytes needed to hold an untransformed row */\n   png_colorp palette;      /* array of color values (valid & PNG_INFO_PLTE) */\n   png_uint_16 num_palette; /* number of color entries in \"palette\" (PLTE) */\n   png_uint_16 num_trans;   /* number of transparent palette color (tRNS) */\n   png_byte bit_depth;      /* 1, 2, 4, 8, or 16 bits/channel (from IHDR) */\n   png_byte color_type;     /* see PNG_COLOR_TYPE_ below (from IHDR) */\n   /* The following three should have been named *_method not *_type */\n   png_byte compression_type; /* must be PNG_COMPRESSION_TYPE_BASE (IHDR) */\n   png_byte filter_type;    /* must be PNG_FILTER_TYPE_BASE (from IHDR) */\n   png_byte interlace_type; /* One of PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */\n\n   /* The following is informational only on read, and not used on writes. */\n   png_byte channels;       /* number of data channels per pixel (1, 2, 3, 4) */\n   png_byte pixel_depth;    /* number of bits per pixel */\n   png_byte spare_byte;     /* to align the data, and for future use */\n   png_byte signature[8];   /* magic bytes read by libpng from start of file */\n\n   /* The rest of the data is optional.  If you are reading, check the\n    * valid field to see if the information in these are valid.  If you\n    * are writing, set the valid field to those chunks you want written,\n    * and initialize the appropriate fields below.\n    */\n\n#if defined(PNG_gAMA_SUPPORTED)\n   /* The gAMA chunk describes the gamma characteristics of the system\n    * on which the image was created, normally in the range [1.0, 2.5].\n    * Data is valid if (valid & PNG_INFO_gAMA) is non-zero.\n    */\n   png_fixed_point gamma;\n#endif\n\n#ifdef PNG_sRGB_SUPPORTED\n    /* GR-P, 0.96a */\n    /* Data valid if (valid & PNG_INFO_sRGB) non-zero. */\n   png_byte srgb_intent; /* sRGB rendering intent [0, 1, 2, or 3] */\n#endif\n\n#ifdef PNG_TEXT_SUPPORTED\n   /* The tEXt, and zTXt chunks contain human-readable textual data in\n    * uncompressed, compressed, and optionally compressed forms, respectively.\n    * The data in \"text\" is an array of pointers to uncompressed,\n    * null-terminated C strings. Each chunk has a keyword that describes the\n    * textual data contained in that chunk.  Keywords are not required to be\n    * unique, and the text string may be empty.  Any number of text chunks may\n    * be in an image.\n    */\n   int num_text; /* number of comments read or comments to write */\n   int max_text; /* current size of text array */\n   png_textp text; /* array of comments read or comments to write */\n#endif /* PNG_TEXT_SUPPORTED */\n\n#ifdef PNG_tIME_SUPPORTED\n   /* The tIME chunk holds the last time the displayed image data was\n    * modified.  See the png_time struct for the contents of this struct.\n    */\n   png_time mod_time;\n#endif\n\n#ifdef PNG_sBIT_SUPPORTED\n   /* The sBIT chunk specifies the number of significant high-order bits\n    * in the pixel data.  Values are in the range [1, bit_depth], and are\n    * only specified for the channels in the pixel data.  The contents of\n    * the low-order bits is not specified.  Data is valid if\n    * (valid & PNG_INFO_sBIT) is non-zero.\n    */\n   png_color_8 sig_bit; /* significant bits in color channels */\n#endif\n\n#if defined(PNG_tRNS_SUPPORTED) || defined(PNG_READ_EXPAND_SUPPORTED) || \\\ndefined(PNG_READ_BACKGROUND_SUPPORTED)\n   /* The tRNS chunk supplies transparency data for paletted images and\n    * other image types that don't need a full alpha channel.  There are\n    * \"num_trans\" transparency values for a paletted image, stored in the\n    * same order as the palette colors, starting from index 0.  Values\n    * for the data are in the range [0, 255], ranging from fully transparent\n    * to fully opaque, respectively.  For non-paletted images, there is a\n    * single color specified that should be treated as fully transparent.\n    * Data is valid if (valid & PNG_INFO_tRNS) is non-zero.\n    */\n   png_bytep trans_alpha;    /* alpha values for paletted image */\n   png_color_16 trans_color; /* transparent color for non-palette image */\n#endif\n\n#if defined(PNG_bKGD_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)\n   /* The bKGD chunk gives the suggested image background color if the\n    * display program does not have its own background color and the image\n    * is needs to composited onto a background before display.  The colors\n    * in \"background\" are normally in the same color space/depth as the\n    * pixel data.  Data is valid if (valid & PNG_INFO_bKGD) is non-zero.\n    */\n   png_color_16 background;\n#endif\n\n#ifdef PNG_oFFs_SUPPORTED\n   /* The oFFs chunk gives the offset in \"offset_unit_type\" units rightwards\n    * and downwards from the top-left corner of the display, page, or other\n    * application-specific co-ordinate space.  See the PNG_OFFSET_ defines\n    * below for the unit types.  Valid if (valid & PNG_INFO_oFFs) non-zero.\n    */\n   png_int_32 x_offset; /* x offset on page */\n   png_int_32 y_offset; /* y offset on page */\n   png_byte offset_unit_type; /* offset units type */\n#endif\n\n#ifdef PNG_pHYs_SUPPORTED\n   /* The pHYs chunk gives the physical pixel density of the image for\n    * display or printing in \"phys_unit_type\" units (see PNG_RESOLUTION_\n    * defines below).  Data is valid if (valid & PNG_INFO_pHYs) is non-zero.\n    */\n   png_uint_32 x_pixels_per_unit; /* horizontal pixel density */\n   png_uint_32 y_pixels_per_unit; /* vertical pixel density */\n   png_byte phys_unit_type; /* resolution type (see PNG_RESOLUTION_ below) */\n#endif\n\n#ifdef PNG_hIST_SUPPORTED\n   /* The hIST chunk contains the relative frequency or importance of the\n    * various palette entries, so that a viewer can intelligently select a\n    * reduced-color palette, if required.  Data is an array of \"num_palette\"\n    * values in the range [0,65535]. Data valid if (valid & PNG_INFO_hIST)\n    * is non-zero.\n    */\n   png_uint_16p hist;\n#endif\n\n#ifdef PNG_cHRM_SUPPORTED\n   /* The cHRM chunk describes the CIE color characteristics of the monitor\n    * on which the PNG was created.  This data allows the viewer to do gamut\n    * mapping of the input image to ensure that the viewer sees the same\n    * colors in the image as the creator.  Values are in the range\n    * [0.0, 0.8].  Data valid if (valid & PNG_INFO_cHRM) non-zero.\n    */\n   png_fixed_point x_white;\n   png_fixed_point y_white;\n   png_fixed_point x_red;\n   png_fixed_point y_red;\n   png_fixed_point x_green;\n   png_fixed_point y_green;\n   png_fixed_point x_blue;\n   png_fixed_point y_blue;\n#endif\n\n#ifdef PNG_pCAL_SUPPORTED\n   /* The pCAL chunk describes a transformation between the stored pixel\n    * values and original physical data values used to create the image.\n    * The integer range [0, 2^bit_depth - 1] maps to the floating-point\n    * range given by [pcal_X0, pcal_X1], and are further transformed by a\n    * (possibly non-linear) transformation function given by \"pcal_type\"\n    * and \"pcal_params\" into \"pcal_units\".  Please see the PNG_EQUATION_\n    * defines below, and the PNG-Group's PNG extensions document for a\n    * complete description of the transformations and how they should be\n    * implemented, and for a description of the ASCII parameter strings.\n    * Data values are valid if (valid & PNG_INFO_pCAL) non-zero.\n    */\n   png_charp pcal_purpose;  /* pCAL chunk description string */\n   png_int_32 pcal_X0;      /* minimum value */\n   png_int_32 pcal_X1;      /* maximum value */\n   png_charp pcal_units;    /* Latin-1 string giving physical units */\n   png_charpp pcal_params;  /* ASCII strings containing parameter values */\n   png_byte pcal_type;      /* equation type (see PNG_EQUATION_ below) */\n   png_byte pcal_nparams;   /* number of parameters given in pcal_params */\n#endif\n\n/* New members added in libpng-1.0.6 */\n   png_uint_32 free_me;     /* flags items libpng is responsible for freeing */\n\n#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) || \\\n defined(PNG_HANDLE_AS_UNKNOWN_SUPPORTED)\n   /* Storage for unknown chunks that the library doesn't recognize. */\n   png_unknown_chunkp unknown_chunks;\n   int unknown_chunks_num;\n#endif\n\n#ifdef PNG_iCCP_SUPPORTED\n   /* iCCP chunk data. */\n   png_charp iccp_name;     /* profile name */\n   png_bytep iccp_profile;  /* International Color Consortium profile data */\n   png_uint_32 iccp_proflen;  /* ICC profile data length */\n   png_byte iccp_compression; /* Always zero */\n#endif\n\n#ifdef PNG_sPLT_SUPPORTED\n   /* Data on sPLT chunks (there may be more than one). */\n   png_sPLT_tp splt_palettes;\n   png_uint_32 splt_palettes_num;\n#endif\n\n#ifdef PNG_sCAL_SUPPORTED\n   /* The sCAL chunk describes the actual physical dimensions of the\n    * subject matter of the graphic.  The chunk contains a unit specification\n    * a byte value, and two ASCII strings representing floating-point\n    * values.  The values are width and height corresponsing to one pixel\n    * in the image.  Data values are valid if (valid & PNG_INFO_sCAL) is\n    * non-zero.\n    */\n   png_byte scal_unit;         /* unit of physical scale */\n   png_charp scal_s_width;     /* string containing height */\n   png_charp scal_s_height;    /* string containing width */\n#endif\n\n#ifdef PNG_INFO_IMAGE_SUPPORTED\n   /* Memory has been allocated if (valid & PNG_ALLOCATED_INFO_ROWS)\n      non-zero */\n   /* Data valid if (valid & PNG_INFO_IDAT) non-zero */\n   png_bytepp row_pointers;        /* the image bits */\n#endif\n\n};\n#endif /* PNGINFO_H */\n"
  },
  {
    "path": "Projects/Tools/PNGAlphaPremultiplier/Native/Source/LibPng/pnglibconf.h",
    "content": "\n/* libpng STANDARD API DEFINITION */\n\n/* pnglibconf.h - library build configuration */\n\n/* Libpng 1.5.9 - February 18, 2012 */\n\n/* Copyright (c) 1998-2011 Glenn Randers-Pehrson */\n\n/* This code is released under the libpng license. */\n/* For conditions of distribution and use, see the disclaimer */\n/* and license in png.h */\n\n/* pnglibconf.h */\n/* Derived from: scripts/pnglibconf.dfa */\n/* If you edit this file by hand you must obey the rules expressed in */\n/* pnglibconf.dfa with respect to the dependencies between the following */\n/* symbols.  It is much better to generate a new file using */\n/* scripts/libpngconf.mak */\n\n#ifndef PNGLCONF_H\n#define PNGLCONF_H\n/* settings */\n#define PNG_API_RULE 0\n#define PNG_CALLOC_SUPPORTED\n#define PNG_COST_SHIFT 3\n#define PNG_DEFAULT_READ_MACROS 1\n#define PNG_GAMMA_THRESHOLD_FIXED 5000\n#define PNG_MAX_GAMMA_8 11\n#define PNG_QUANTIZE_BLUE_BITS 5\n#define PNG_QUANTIZE_GREEN_BITS 5\n#define PNG_QUANTIZE_RED_BITS 5\n#define PNG_sCAL_PRECISION 5\n#define PNG_USER_CHUNK_CACHE_MAX 0\n#define PNG_USER_CHUNK_MALLOC_MAX 0\n#define PNG_USER_HEIGHT_MAX 1000000\n#define PNG_USER_WIDTH_MAX 1000000\n#define PNG_WEIGHT_SHIFT 8\n#define PNG_ZBUF_SIZE 8192\n/* end of settings */\n/* options */\n#define PNG_16BIT_SUPPORTED\n#define PNG_ALIGN_MEMORY_SUPPORTED\n#define PNG_BENIGN_ERRORS_SUPPORTED\n#define PNG_bKGD_SUPPORTED\n#define PNG_BUILD_GRAYSCALE_PALETTE_SUPPORTED\n#define PNG_CHECK_cHRM_SUPPORTED\n#define PNG_cHRM_SUPPORTED\n#define PNG_CONSOLE_IO_SUPPORTED\n#define PNG_CONVERT_tIME_SUPPORTED\n#define PNG_EASY_ACCESS_SUPPORTED\n/*#undef PNG_ERROR_NUMBERS_SUPPORTED*/\n#define PNG_ERROR_TEXT_SUPPORTED\n#define PNG_FIXED_POINT_SUPPORTED\n#define PNG_FLOATING_ARITHMETIC_SUPPORTED\n#define PNG_FLOATING_POINT_SUPPORTED\n#define PNG_gAMA_SUPPORTED\n#define PNG_HANDLE_AS_UNKNOWN_SUPPORTED\n#define PNG_hIST_SUPPORTED\n#define PNG_iCCP_SUPPORTED\n#define PNG_INCH_CONVERSIONS_SUPPORTED\n#define PNG_INFO_IMAGE_SUPPORTED\n#define PNG_IO_STATE_SUPPORTED\n#define PNG_iTXt_SUPPORTED\n#define PNG_MNG_FEATURES_SUPPORTED\n#define PNG_oFFs_SUPPORTED\n#define PNG_pCAL_SUPPORTED\n#define PNG_pHYs_SUPPORTED\n#define PNG_POINTER_INDEXING_SUPPORTED\n#define PNG_PROGRESSIVE_READ_SUPPORTED\n#define PNG_READ_16BIT_SUPPORTED\n#define PNG_READ_ALPHA_MODE_SUPPORTED\n#define PNG_READ_ANCILLARY_CHUNKS_SUPPORTED\n#define PNG_READ_BACKGROUND_SUPPORTED\n#define PNG_READ_BGR_SUPPORTED\n#define PNG_READ_bKGD_SUPPORTED\n#define PNG_READ_cHRM_SUPPORTED\n#define PNG_READ_COMPOSITE_NODIV_SUPPORTED\n#define PNG_READ_COMPRESSED_TEXT_SUPPORTED\n#define PNG_READ_EXPAND_16_SUPPORTED\n#define PNG_READ_EXPAND_SUPPORTED\n#define PNG_READ_FILLER_SUPPORTED\n#define PNG_READ_gAMA_SUPPORTED\n#define PNG_READ_GAMMA_SUPPORTED\n#define PNG_READ_GRAY_TO_RGB_SUPPORTED\n#define PNG_READ_hIST_SUPPORTED\n#define PNG_READ_iCCP_SUPPORTED\n#define PNG_READ_INTERLACING_SUPPORTED\n#define PNG_READ_INT_FUNCTIONS_SUPPORTED\n#define PNG_READ_INVERT_ALPHA_SUPPORTED\n#define PNG_READ_INVERT_SUPPORTED\n#define PNG_READ_iTXt_SUPPORTED\n#define PNG_READ_oFFs_SUPPORTED\n#define PNG_READ_OPT_PLTE_SUPPORTED\n#define PNG_READ_PACK_SUPPORTED\n#define PNG_READ_PACKSWAP_SUPPORTED\n#define PNG_READ_pCAL_SUPPORTED\n#define PNG_READ_pHYs_SUPPORTED\n#define PNG_READ_QUANTIZE_SUPPORTED\n#define PNG_READ_RGB_TO_GRAY_SUPPORTED\n#define PNG_READ_sBIT_SUPPORTED\n#define PNG_READ_SCALE_16_TO_8_SUPPORTED\n#define PNG_READ_sCAL_SUPPORTED\n#define PNG_READ_SHIFT_SUPPORTED\n#define PNG_READ_sPLT_SUPPORTED\n#define PNG_READ_sRGB_SUPPORTED\n#define PNG_READ_STRIP_16_TO_8_SUPPORTED\n#define PNG_READ_STRIP_ALPHA_SUPPORTED\n#define PNG_READ_SUPPORTED\n#define PNG_READ_SWAP_ALPHA_SUPPORTED\n#define PNG_READ_SWAP_SUPPORTED\n#define PNG_READ_tEXt_SUPPORTED\n#define PNG_READ_TEXT_SUPPORTED\n#define PNG_READ_tIME_SUPPORTED\n#define PNG_READ_TRANSFORMS_SUPPORTED\n#define PNG_READ_tRNS_SUPPORTED\n#define PNG_READ_UNKNOWN_CHUNKS_SUPPORTED\n#define PNG_READ_USER_CHUNKS_SUPPORTED\n#define PNG_READ_USER_TRANSFORM_SUPPORTED\n#define PNG_READ_zTXt_SUPPORTED\n#define PNG_SAVE_INT_32_SUPPORTED\n#define PNG_sBIT_SUPPORTED\n#define PNG_sCAL_SUPPORTED\n#define PNG_SEQUENTIAL_READ_SUPPORTED\n#define PNG_SET_CHUNK_CACHE_LIMIT_SUPPORTED\n#define PNG_SET_CHUNK_MALLOC_LIMIT_SUPPORTED\n#define PNG_SETJMP_SUPPORTED\n#define PNG_SET_USER_LIMITS_SUPPORTED\n#define PNG_sPLT_SUPPORTED\n#define PNG_sRGB_SUPPORTED\n#define PNG_STDIO_SUPPORTED\n#define PNG_tEXt_SUPPORTED\n#define PNG_TEXT_SUPPORTED\n#define PNG_TIME_RFC1123_SUPPORTED\n#define PNG_tIME_SUPPORTED\n#define PNG_tRNS_SUPPORTED\n#define PNG_UNKNOWN_CHUNKS_SUPPORTED\n#define PNG_USER_CHUNKS_SUPPORTED\n#define PNG_USER_LIMITS_SUPPORTED\n#define PNG_USER_MEM_SUPPORTED\n#define PNG_USER_TRANSFORM_INFO_SUPPORTED\n#define PNG_USER_TRANSFORM_PTR_SUPPORTED\n#define PNG_WARNINGS_SUPPORTED\n#define PNG_WRITE_16BIT_SUPPORTED\n#define PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED\n#define PNG_WRITE_BGR_SUPPORTED\n#define PNG_WRITE_bKGD_SUPPORTED\n#define PNG_WRITE_cHRM_SUPPORTED\n#define PNG_WRITE_COMPRESSED_TEXT_SUPPORTED\n#define PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED\n#define PNG_WRITE_FILLER_SUPPORTED\n#define PNG_WRITE_FILTER_SUPPORTED\n#define PNG_WRITE_FLUSH_SUPPORTED\n#define PNG_WRITE_gAMA_SUPPORTED\n#define PNG_WRITE_hIST_SUPPORTED\n#define PNG_WRITE_iCCP_SUPPORTED\n#define PNG_WRITE_INTERLACING_SUPPORTED\n#define PNG_WRITE_INT_FUNCTIONS_SUPPORTED\n#define PNG_WRITE_INVERT_ALPHA_SUPPORTED\n#define PNG_WRITE_INVERT_SUPPORTED\n#define PNG_WRITE_iTXt_SUPPORTED\n#define PNG_WRITE_oFFs_SUPPORTED\n#define PNG_WRITE_OPTIMIZE_CMF_SUPPORTED\n#define PNG_WRITE_PACK_SUPPORTED\n#define PNG_WRITE_PACKSWAP_SUPPORTED\n#define PNG_WRITE_pCAL_SUPPORTED\n#define PNG_WRITE_pHYs_SUPPORTED\n#define PNG_WRITE_sBIT_SUPPORTED\n#define PNG_WRITE_sCAL_SUPPORTED\n#define PNG_WRITE_SHIFT_SUPPORTED\n#define PNG_WRITE_sPLT_SUPPORTED\n#define PNG_WRITE_sRGB_SUPPORTED\n#define PNG_WRITE_SUPPORTED\n#define PNG_WRITE_SWAP_ALPHA_SUPPORTED\n#define PNG_WRITE_SWAP_SUPPORTED\n#define PNG_WRITE_tEXt_SUPPORTED\n#define PNG_WRITE_TEXT_SUPPORTED\n#define PNG_WRITE_tIME_SUPPORTED\n#define PNG_WRITE_TRANSFORMS_SUPPORTED\n#define PNG_WRITE_tRNS_SUPPORTED\n#define PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED\n#define PNG_WRITE_USER_TRANSFORM_SUPPORTED\n#define PNG_WRITE_WEIGHTED_FILTER_SUPPORTED\n#define PNG_WRITE_zTXt_SUPPORTED\n#define PNG_zTXt_SUPPORTED\n/* end of options */\n#endif /* PNGLCONF_H */\n"
  },
  {
    "path": "Projects/Tools/PNGAlphaPremultiplier/Native/Source/LibPng/pngmem.c",
    "content": "\n/* pngmem.c - stub functions for memory allocation\n *\n * Last changed in libpng 1.5.7 [December 15, 2011]\n * Copyright (c) 1998-2011 Glenn Randers-Pehrson\n * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)\n * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)\n *\n * This code is released under the libpng license.\n * For conditions of distribution and use, see the disclaimer\n * and license in png.h\n *\n * This file provides a location for all memory allocation.  Users who\n * need special memory handling are expected to supply replacement\n * functions for png_malloc() and png_free(), and to use\n * png_create_read_struct_2() and png_create_write_struct_2() to\n * identify the replacement functions.\n */\n\n#include \"pngpriv.h\"\n\n#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)\n\n/* Borland DOS special memory handler */\n#if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__)\n/* If you change this, be sure to change the one in png.h also */\n\n/* Allocate memory for a png_struct.  The malloc and memset can be replaced\n   by a single call to calloc() if this is thought to improve performance. */\nPNG_FUNCTION(png_voidp /* PRIVATE */,\npng_create_struct,(int type),PNG_ALLOCATED)\n{\n#  ifdef PNG_USER_MEM_SUPPORTED\n   return (png_create_struct_2(type, NULL, NULL));\n}\n\n/* Alternate version of png_create_struct, for use with user-defined malloc. */\nPNG_FUNCTION(png_voidp /* PRIVATE */,\npng_create_struct_2,(int type, png_malloc_ptr malloc_fn, png_voidp mem_ptr),\n   PNG_ALLOCATED)\n{\n#  endif /* PNG_USER_MEM_SUPPORTED */\n   png_size_t size;\n   png_voidp struct_ptr;\n\n   if (type == PNG_STRUCT_INFO)\n      size = png_sizeof(png_info);\n\n   else if (type == PNG_STRUCT_PNG)\n      size = png_sizeof(png_struct);\n\n   else\n      return (png_get_copyright(NULL));\n\n#  ifdef PNG_USER_MEM_SUPPORTED\n   if (malloc_fn != NULL)\n   {\n      png_struct dummy_struct;\n      memset(&dummy_struct, 0, sizeof dummy_struct);\n      dummy_struct.mem_ptr=mem_ptr;\n      struct_ptr = (*(malloc_fn))(&dummy_struct, (png_alloc_size_t)size);\n   }\n\n   else\n#  endif /* PNG_USER_MEM_SUPPORTED */\n   struct_ptr = (png_voidp)farmalloc(size);\n   if (struct_ptr != NULL)\n      png_memset(struct_ptr, 0, size);\n\n   return (struct_ptr);\n}\n\n/* Free memory allocated by a png_create_struct() call */\nvoid /* PRIVATE */\npng_destroy_struct(png_voidp struct_ptr)\n{\n#  ifdef PNG_USER_MEM_SUPPORTED\n   png_destroy_struct_2(struct_ptr, NULL, NULL);\n}\n\n/* Free memory allocated by a png_create_struct() call */\nvoid /* PRIVATE */\npng_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn,\n    png_voidp mem_ptr)\n{\n#  endif\n   if (struct_ptr != NULL)\n   {\n#  ifdef PNG_USER_MEM_SUPPORTED\n      if (free_fn != NULL)\n      {\n         png_struct dummy_struct;\n         memset(&dummy_struct, 0, sizeof dummy_struct);\n         dummy_struct.mem_ptr=mem_ptr;\n         (*(free_fn))(&dummy_struct, struct_ptr);\n         return;\n      }\n\n#  endif /* PNG_USER_MEM_SUPPORTED */\n      farfree (struct_ptr);\n   }\n}\n\n/* Allocate memory.  For reasonable files, size should never exceed\n * 64K.  However, zlib may allocate more then 64K if you don't tell\n * it not to.  See zconf.h and png.h for more information. zlib does\n * need to allocate exactly 64K, so whatever you call here must\n * have the ability to do that.\n *\n * Borland seems to have a problem in DOS mode for exactly 64K.\n * It gives you a segment with an offset of 8 (perhaps to store its\n * memory stuff).  zlib doesn't like this at all, so we have to\n * detect and deal with it.  This code should not be needed in\n * Windows or OS/2 modes, and only in 16 bit mode.  This code has\n * been updated by Alexander Lehmann for version 0.89 to waste less\n * memory.\n *\n * Note that we can't use png_size_t for the \"size\" declaration,\n * since on some systems a png_size_t is a 16-bit quantity, and as a\n * result, we would be truncating potentially larger memory requests\n * (which should cause a fatal error) and introducing major problems.\n */\nPNG_FUNCTION(png_voidp,PNGAPI\npng_calloc,(png_structp png_ptr, png_alloc_size_t size),PNG_ALLOCATED)\n{\n   png_voidp ret;\n\n   ret = (png_malloc(png_ptr, size));\n\n   if (ret != NULL)\n      png_memset(ret,0,(png_size_t)size);\n\n   return (ret);\n}\n\nPNG_FUNCTION(png_voidp,PNGAPI\npng_malloc,(png_structp png_ptr, png_alloc_size_t size),PNG_ALLOCATED)\n{\n   png_voidp ret;\n\n   if (png_ptr == NULL || size == 0)\n      return (NULL);\n\n#  ifdef PNG_USER_MEM_SUPPORTED\n   if (png_ptr->malloc_fn != NULL)\n      ret = ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, size));\n\n   else\n      ret = (png_malloc_default(png_ptr, size));\n\n   if (ret == NULL && (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)\n       png_error(png_ptr, \"Out of memory\");\n\n   return (ret);\n}\n\nPNG_FUNCTION(png_voidp,PNGAPI\npng_malloc_default,(png_structp png_ptr, png_alloc_size_t size),PNG_ALLOCATED)\n{\n   png_voidp ret;\n#  endif /* PNG_USER_MEM_SUPPORTED */\n\n   if (png_ptr == NULL || size == 0)\n      return (NULL);\n\n#  ifdef PNG_MAX_MALLOC_64K\n   if (size > (png_uint_32)65536L)\n   {\n      png_warning(png_ptr, \"Cannot Allocate > 64K\");\n      ret = NULL;\n   }\n\n   else\n#  endif\n\n   if (size != (size_t)size)\n      ret = NULL;\n\n   else if (size == (png_uint_32)65536L)\n   {\n      if (png_ptr->offset_table == NULL)\n      {\n         /* Try to see if we need to do any of this fancy stuff */\n         ret = farmalloc(size);\n         if (ret == NULL || ((png_size_t)ret & 0xffff))\n         {\n            int num_blocks;\n            png_uint_32 total_size;\n            png_bytep table;\n            int i, mem_level, window_bits;\n            png_byte huge * hptr;\n            int window_bits\n\n            if (ret != NULL)\n            {\n               farfree(ret);\n               ret = NULL;\n            }\n\n            window_bits =\n                png_ptr->zlib_window_bits >= png_ptr->zlib_text_window_bits ?\n                png_ptr->zlib_window_bits : png_ptr->zlib_text_window_bits;\n\n            if (window_bits > 14)\n               num_blocks = (int)(1 << (window_bits - 14));\n\n            else\n               num_blocks = 1;\n\n            mem_level =\n                png_ptr->zlib_mem_level >= png_ptr->zlib_text_mem_level ?\n                png_ptr->zlib_mem_level : png_ptr->zlib_text_mem_level;\n\n            if (mem_level >= 7)\n               num_blocks += (int)(1 << (mem_level - 7));\n\n            else\n               num_blocks++;\n\n            total_size = ((png_uint_32)65536L) * (png_uint_32)num_blocks+16;\n\n            table = farmalloc(total_size);\n\n            if (table == NULL)\n            {\n#  ifndef PNG_USER_MEM_SUPPORTED\n               if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)\n                  png_error(png_ptr, \"Out Of Memory\"); /* Note \"O\", \"M\" */\n\n               else\n                  png_warning(png_ptr, \"Out Of Memory\");\n#  endif\n               return (NULL);\n            }\n\n            if ((png_size_t)table & 0xfff0)\n            {\n#  ifndef PNG_USER_MEM_SUPPORTED\n               if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)\n                  png_error(png_ptr,\n                    \"Farmalloc didn't return normalized pointer\");\n\n               else\n                  png_warning(png_ptr,\n                    \"Farmalloc didn't return normalized pointer\");\n#  endif\n               return (NULL);\n            }\n\n            png_ptr->offset_table = table;\n            png_ptr->offset_table_ptr = farmalloc(num_blocks *\n               png_sizeof(png_bytep));\n\n            if (png_ptr->offset_table_ptr == NULL)\n            {\n#  ifndef PNG_USER_MEM_SUPPORTED\n               if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)\n                  png_error(png_ptr, \"Out Of memory\"); /* Note \"O\", \"m\" */\n\n               else\n                  png_warning(png_ptr, \"Out Of memory\");\n#  endif\n               return (NULL);\n            }\n\n            hptr = (png_byte huge *)table;\n            if ((png_size_t)hptr & 0xf)\n            {\n               hptr = (png_byte huge *)((long)(hptr) & 0xfffffff0L);\n               hptr = hptr + 16L;  /* \"hptr += 16L\" fails on Turbo C++ 3.0 */\n            }\n\n            for (i = 0; i < num_blocks; i++)\n            {\n               png_ptr->offset_table_ptr[i] = (png_bytep)hptr;\n               hptr = hptr + (png_uint_32)65536L;  /* \"+=\" fails on TC++3.0 */\n            }\n\n            png_ptr->offset_table_number = num_blocks;\n            png_ptr->offset_table_count = 0;\n            png_ptr->offset_table_count_free = 0;\n         }\n      }\n\n      if (png_ptr->offset_table_count >= png_ptr->offset_table_number)\n      {\n#  ifndef PNG_USER_MEM_SUPPORTED\n         if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)\n            png_error(png_ptr, \"Out of Memory\"); /* Note \"O\" and \"M\" */\n\n         else\n            png_warning(png_ptr, \"Out of Memory\");\n#  endif\n         return (NULL);\n      }\n\n      ret = png_ptr->offset_table_ptr[png_ptr->offset_table_count++];\n   }\n\n   else\n      ret = farmalloc(size);\n\n#  ifndef PNG_USER_MEM_SUPPORTED\n   if (ret == NULL)\n   {\n      if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)\n         png_error(png_ptr, \"Out of memory\"); /* Note \"o\" and \"m\" */\n\n      else\n         png_warning(png_ptr, \"Out of memory\"); /* Note \"o\" and \"m\" */\n   }\n#  endif\n\n   return (ret);\n}\n\n/* Free a pointer allocated by png_malloc().  In the default\n * configuration, png_ptr is not used, but is passed in case it\n * is needed.  If ptr is NULL, return without taking any action.\n */\nvoid PNGAPI\npng_free(png_structp png_ptr, png_voidp ptr)\n{\n   if (png_ptr == NULL || ptr == NULL)\n      return;\n\n#  ifdef PNG_USER_MEM_SUPPORTED\n   if (png_ptr->free_fn != NULL)\n   {\n      (*(png_ptr->free_fn))(png_ptr, ptr);\n      return;\n   }\n\n   else\n      png_free_default(png_ptr, ptr);\n}\n\nvoid PNGAPI\npng_free_default(png_structp png_ptr, png_voidp ptr)\n{\n#  endif /* PNG_USER_MEM_SUPPORTED */\n\n   if (png_ptr == NULL || ptr == NULL)\n      return;\n\n   if (png_ptr->offset_table != NULL)\n   {\n      int i;\n\n      for (i = 0; i < png_ptr->offset_table_count; i++)\n      {\n         if (ptr == png_ptr->offset_table_ptr[i])\n         {\n            ptr = NULL;\n            png_ptr->offset_table_count_free++;\n            break;\n         }\n      }\n      if (png_ptr->offset_table_count_free == png_ptr->offset_table_count)\n      {\n         farfree(png_ptr->offset_table);\n         farfree(png_ptr->offset_table_ptr);\n         png_ptr->offset_table = NULL;\n         png_ptr->offset_table_ptr = NULL;\n      }\n   }\n\n   if (ptr != NULL)\n      farfree(ptr);\n}\n\n#else /* Not the Borland DOS special memory handler */\n\n/* Allocate memory for a png_struct or a png_info.  The malloc and\n   memset can be replaced by a single call to calloc() if this is thought\n   to improve performance noticably. */\nPNG_FUNCTION(png_voidp /* PRIVATE */,\npng_create_struct,(int type),PNG_ALLOCATED)\n{\n#  ifdef PNG_USER_MEM_SUPPORTED\n   return (png_create_struct_2(type, NULL, NULL));\n}\n\n/* Allocate memory for a png_struct or a png_info.  The malloc and\n   memset can be replaced by a single call to calloc() if this is thought\n   to improve performance noticably. */\nPNG_FUNCTION(png_voidp /* PRIVATE */,\npng_create_struct_2,(int type, png_malloc_ptr malloc_fn, png_voidp mem_ptr),\n   PNG_ALLOCATED)\n{\n#  endif /* PNG_USER_MEM_SUPPORTED */\n   png_size_t size;\n   png_voidp struct_ptr;\n\n   if (type == PNG_STRUCT_INFO)\n      size = png_sizeof(png_info);\n\n   else if (type == PNG_STRUCT_PNG)\n      size = png_sizeof(png_struct);\n\n   else\n      return (NULL);\n\n#  ifdef PNG_USER_MEM_SUPPORTED\n   if (malloc_fn != NULL)\n   {\n      png_struct dummy_struct;\n      png_structp png_ptr = &dummy_struct;\n      png_ptr->mem_ptr=mem_ptr;\n      struct_ptr = (*(malloc_fn))(png_ptr, size);\n\n      if (struct_ptr != NULL)\n         png_memset(struct_ptr, 0, size);\n\n      return (struct_ptr);\n   }\n#  endif /* PNG_USER_MEM_SUPPORTED */\n\n#  if defined(__TURBOC__) && !defined(__FLAT__)\n   struct_ptr = (png_voidp)farmalloc(size);\n#  else\n#    if defined(_MSC_VER) && defined(MAXSEG_64K)\n   struct_ptr = (png_voidp)halloc(size, 1);\n#    else\n   struct_ptr = (png_voidp)malloc(size);\n#    endif\n#  endif\n\n   if (struct_ptr != NULL)\n      png_memset(struct_ptr, 0, size);\n\n   return (struct_ptr);\n}\n\n\n/* Free memory allocated by a png_create_struct() call */\nvoid /* PRIVATE */\npng_destroy_struct(png_voidp struct_ptr)\n{\n#  ifdef PNG_USER_MEM_SUPPORTED\n   png_destroy_struct_2(struct_ptr, NULL, NULL);\n}\n\n/* Free memory allocated by a png_create_struct() call */\nvoid /* PRIVATE */\npng_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn,\n    png_voidp mem_ptr)\n{\n#  endif /* PNG_USER_MEM_SUPPORTED */\n   if (struct_ptr != NULL)\n   {\n#  ifdef PNG_USER_MEM_SUPPORTED\n      if (free_fn != NULL)\n      {\n         png_struct dummy_struct;\n         png_structp png_ptr = &dummy_struct;\n         png_ptr->mem_ptr=mem_ptr;\n         (*(free_fn))(png_ptr, struct_ptr);\n         return;\n      }\n#  endif /* PNG_USER_MEM_SUPPORTED */\n#  if defined(__TURBOC__) && !defined(__FLAT__)\n      farfree(struct_ptr);\n\n#  else\n#    if defined(_MSC_VER) && defined(MAXSEG_64K)\n      hfree(struct_ptr);\n\n#    else\n      free(struct_ptr);\n\n#    endif\n#  endif\n   }\n}\n\n/* Allocate memory.  For reasonable files, size should never exceed\n * 64K.  However, zlib may allocate more then 64K if you don't tell\n * it not to.  See zconf.h and png.h for more information.  zlib does\n * need to allocate exactly 64K, so whatever you call here must\n * have the ability to do that.\n */\n\nPNG_FUNCTION(png_voidp,PNGAPI\npng_calloc,(png_structp png_ptr, png_alloc_size_t size),PNG_ALLOCATED)\n{\n   png_voidp ret;\n\n   ret = (png_malloc(png_ptr, size));\n\n   if (ret != NULL)\n      png_memset(ret,0,(png_size_t)size);\n\n   return (ret);\n}\n\nPNG_FUNCTION(png_voidp,PNGAPI\npng_malloc,(png_structp png_ptr, png_alloc_size_t size),PNG_ALLOCATED)\n{\n   png_voidp ret;\n\n#  ifdef PNG_USER_MEM_SUPPORTED\n   if (png_ptr == NULL || size == 0)\n      return (NULL);\n\n   if (png_ptr->malloc_fn != NULL)\n      ret = ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, (png_size_t)size));\n\n   else\n      ret = (png_malloc_default(png_ptr, size));\n\n   if (ret == NULL && (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)\n       png_error(png_ptr, \"Out of Memory\");\n\n   return (ret);\n}\n\nPNG_FUNCTION(png_voidp,PNGAPI\npng_malloc_default,(png_structp png_ptr, png_alloc_size_t size),PNG_ALLOCATED)\n{\n   png_voidp ret;\n#  endif /* PNG_USER_MEM_SUPPORTED */\n\n   if (png_ptr == NULL || size == 0)\n      return (NULL);\n\n#  ifdef PNG_MAX_MALLOC_64K\n   if (size > (png_uint_32)65536L)\n   {\n#    ifndef PNG_USER_MEM_SUPPORTED\n      if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)\n         png_error(png_ptr, \"Cannot Allocate > 64K\");\n\n      else\n#    endif\n         return NULL;\n   }\n#  endif\n\n   /* Check for overflow */\n#  if defined(__TURBOC__) && !defined(__FLAT__)\n\n   if (size != (unsigned long)size)\n      ret = NULL;\n\n   else\n      ret = farmalloc(size);\n\n#  else\n#    if defined(_MSC_VER) && defined(MAXSEG_64K)\n   if (size != (unsigned long)size)\n      ret = NULL;\n\n   else\n      ret = halloc(size, 1);\n\n#    else\n   if (size != (size_t)size)\n      ret = NULL;\n\n   else\n      ret = malloc((size_t)size);\n#    endif\n#  endif\n\n#  ifndef PNG_USER_MEM_SUPPORTED\n   if (ret == NULL && (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)\n      png_error(png_ptr, \"Out of Memory\");\n#  endif\n\n   return (ret);\n}\n\n/* Free a pointer allocated by png_malloc().  If ptr is NULL, return\n * without taking any action.\n */\nvoid PNGAPI\npng_free(png_structp png_ptr, png_voidp ptr)\n{\n   if (png_ptr == NULL || ptr == NULL)\n      return;\n\n#  ifdef PNG_USER_MEM_SUPPORTED\n   if (png_ptr->free_fn != NULL)\n   {\n      (*(png_ptr->free_fn))(png_ptr, ptr);\n      return;\n   }\n\n   else\n      png_free_default(png_ptr, ptr);\n}\n\nvoid PNGAPI\npng_free_default(png_structp png_ptr, png_voidp ptr)\n{\n   if (png_ptr == NULL || ptr == NULL)\n      return;\n\n#  endif /* PNG_USER_MEM_SUPPORTED */\n\n#  if defined(__TURBOC__) && !defined(__FLAT__)\n   farfree(ptr);\n\n#  else\n#    if defined(_MSC_VER) && defined(MAXSEG_64K)\n   hfree(ptr);\n\n#    else\n   free(ptr);\n\n#    endif\n#  endif\n}\n#endif /* Not Borland DOS special memory handler */\n\n/* This function was added at libpng version 1.2.3.  The png_malloc_warn()\n * function will set up png_malloc() to issue a png_warning and return NULL\n * instead of issuing a png_error, if it fails to allocate the requested\n * memory.\n */\nPNG_FUNCTION(png_voidp,PNGAPI\npng_malloc_warn,(png_structp png_ptr, png_alloc_size_t size),PNG_ALLOCATED)\n{\n   png_voidp ptr;\n   png_uint_32 save_flags;\n   if (png_ptr == NULL)\n      return (NULL);\n\n   save_flags = png_ptr->flags;\n   png_ptr->flags|=PNG_FLAG_MALLOC_NULL_MEM_OK;\n   ptr = (png_voidp)png_malloc((png_structp)png_ptr, size);\n   png_ptr->flags=save_flags;\n   return(ptr);\n}\n\n\n#ifdef PNG_USER_MEM_SUPPORTED\n/* This function is called when the application wants to use another method\n * of allocating and freeing memory.\n */\nvoid PNGAPI\npng_set_mem_fn(png_structp png_ptr, png_voidp mem_ptr, png_malloc_ptr\n  malloc_fn, png_free_ptr free_fn)\n{\n   if (png_ptr != NULL)\n   {\n      png_ptr->mem_ptr = mem_ptr;\n      png_ptr->malloc_fn = malloc_fn;\n      png_ptr->free_fn = free_fn;\n   }\n}\n\n/* This function returns a pointer to the mem_ptr associated with the user\n * functions.  The application should free any memory associated with this\n * pointer before png_write_destroy and png_read_destroy are called.\n */\npng_voidp PNGAPI\npng_get_mem_ptr(png_const_structp png_ptr)\n{\n   if (png_ptr == NULL)\n      return (NULL);\n\n   return ((png_voidp)png_ptr->mem_ptr);\n}\n#endif /* PNG_USER_MEM_SUPPORTED */\n#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */\n"
  },
  {
    "path": "Projects/Tools/PNGAlphaPremultiplier/Native/Source/LibPng/pngpread.c",
    "content": "\n/* pngpread.c - read a png file in push mode\n *\n * Last changed in libpng 1.5.9 [February 18, 2012]\n * Copyright (c) 1998-2011 Glenn Randers-Pehrson\n * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)\n * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)\n *\n * This code is released under the libpng license.\n * For conditions of distribution and use, see the disclaimer\n * and license in png.h\n */\n\n#include \"pngpriv.h\"\n\n#ifdef PNG_PROGRESSIVE_READ_SUPPORTED\n\n/* Push model modes */\n#define PNG_READ_SIG_MODE   0\n#define PNG_READ_CHUNK_MODE 1\n#define PNG_READ_IDAT_MODE  2\n#define PNG_SKIP_MODE       3\n#define PNG_READ_tEXt_MODE  4\n#define PNG_READ_zTXt_MODE  5\n#define PNG_READ_DONE_MODE  6\n#define PNG_READ_iTXt_MODE  7\n#define PNG_ERROR_MODE      8\n\nvoid PNGAPI\npng_process_data(png_structp png_ptr, png_infop info_ptr,\n    png_bytep buffer, png_size_t buffer_size)\n{\n   if (png_ptr == NULL || info_ptr == NULL)\n      return;\n\n   png_push_restore_buffer(png_ptr, buffer, buffer_size);\n\n   while (png_ptr->buffer_size)\n   {\n      png_process_some_data(png_ptr, info_ptr);\n   }\n}\n\npng_size_t PNGAPI\npng_process_data_pause(png_structp png_ptr, int save)\n{\n   if (png_ptr != NULL)\n   {\n      /* It's easiest for the caller if we do the save, then the caller doesn't\n       * have to supply the same data again:\n       */\n      if (save)\n         png_push_save_buffer(png_ptr);\n      else\n      {\n         /* This includes any pending saved bytes: */\n         png_size_t remaining = png_ptr->buffer_size;\n         png_ptr->buffer_size = 0;\n\n         /* So subtract the saved buffer size, unless all the data\n          * is actually 'saved', in which case we just return 0\n          */\n         if (png_ptr->save_buffer_size < remaining)\n            return remaining - png_ptr->save_buffer_size;\n      }\n   }\n\n   return 0;\n}\n\npng_uint_32 PNGAPI\npng_process_data_skip(png_structp png_ptr)\n{\n   png_uint_32 remaining = 0;\n\n   if (png_ptr != NULL && png_ptr->process_mode == PNG_SKIP_MODE &&\n      png_ptr->skip_length > 0)\n   {\n      /* At the end of png_process_data the buffer size must be 0 (see the loop\n       * above) so we can detect a broken call here:\n       */\n      if (png_ptr->buffer_size != 0)\n         png_error(png_ptr,\n            \"png_process_data_skip called inside png_process_data\");\n\n      /* If is impossible for there to be a saved buffer at this point -\n       * otherwise we could not be in SKIP mode.  This will also happen if\n       * png_process_skip is called inside png_process_data (but only very\n       * rarely.)\n       */\n      if (png_ptr->save_buffer_size != 0)\n         png_error(png_ptr, \"png_process_data_skip called with saved data\");\n\n      remaining = png_ptr->skip_length;\n      png_ptr->skip_length = 0;\n      png_ptr->process_mode = PNG_READ_CHUNK_MODE;\n   }\n\n   return remaining;\n}\n\n/* What we do with the incoming data depends on what we were previously\n * doing before we ran out of data...\n */\nvoid /* PRIVATE */\npng_process_some_data(png_structp png_ptr, png_infop info_ptr)\n{\n   if (png_ptr == NULL)\n      return;\n\n   switch (png_ptr->process_mode)\n   {\n      case PNG_READ_SIG_MODE:\n      {\n         png_push_read_sig(png_ptr, info_ptr);\n         break;\n      }\n\n      case PNG_READ_CHUNK_MODE:\n      {\n         png_push_read_chunk(png_ptr, info_ptr);\n         break;\n      }\n\n      case PNG_READ_IDAT_MODE:\n      {\n         png_push_read_IDAT(png_ptr);\n         break;\n      }\n\n#ifdef PNG_READ_tEXt_SUPPORTED\n      case PNG_READ_tEXt_MODE:\n      {\n         png_push_read_tEXt(png_ptr, info_ptr);\n         break;\n      }\n\n#endif\n#ifdef PNG_READ_zTXt_SUPPORTED\n      case PNG_READ_zTXt_MODE:\n      {\n         png_push_read_zTXt(png_ptr, info_ptr);\n         break;\n      }\n\n#endif\n#ifdef PNG_READ_iTXt_SUPPORTED\n      case PNG_READ_iTXt_MODE:\n      {\n         png_push_read_iTXt(png_ptr, info_ptr);\n         break;\n      }\n\n#endif\n      case PNG_SKIP_MODE:\n      {\n         png_push_crc_finish(png_ptr);\n         break;\n      }\n\n      default:\n      {\n         png_ptr->buffer_size = 0;\n         break;\n      }\n   }\n}\n\n/* Read any remaining signature bytes from the stream and compare them with\n * the correct PNG signature.  It is possible that this routine is called\n * with bytes already read from the signature, either because they have been\n * checked by the calling application, or because of multiple calls to this\n * routine.\n */\nvoid /* PRIVATE */\npng_push_read_sig(png_structp png_ptr, png_infop info_ptr)\n{\n   png_size_t num_checked = png_ptr->sig_bytes,\n             num_to_check = 8 - num_checked;\n\n   if (png_ptr->buffer_size < num_to_check)\n   {\n      num_to_check = png_ptr->buffer_size;\n   }\n\n   png_push_fill_buffer(png_ptr, &(info_ptr->signature[num_checked]),\n       num_to_check);\n   png_ptr->sig_bytes = (png_byte)(png_ptr->sig_bytes + num_to_check);\n\n   if (png_sig_cmp(info_ptr->signature, num_checked, num_to_check))\n   {\n      if (num_checked < 4 &&\n          png_sig_cmp(info_ptr->signature, num_checked, num_to_check - 4))\n         png_error(png_ptr, \"Not a PNG file\");\n\n      else\n         png_error(png_ptr, \"PNG file corrupted by ASCII conversion\");\n   }\n   else\n   {\n      if (png_ptr->sig_bytes >= 8)\n      {\n         png_ptr->process_mode = PNG_READ_CHUNK_MODE;\n      }\n   }\n}\n\nvoid /* PRIVATE */\npng_push_read_chunk(png_structp png_ptr, png_infop info_ptr)\n{\n   png_uint_32 chunk_name;\n\n   /* First we make sure we have enough data for the 4 byte chunk name\n    * and the 4 byte chunk length before proceeding with decoding the\n    * chunk data.  To fully decode each of these chunks, we also make\n    * sure we have enough data in the buffer for the 4 byte CRC at the\n    * end of every chunk (except IDAT, which is handled separately).\n    */\n   if (!(png_ptr->mode & PNG_HAVE_CHUNK_HEADER))\n   {\n      png_byte chunk_length[4];\n      png_byte chunk_tag[4];\n\n      if (png_ptr->buffer_size < 8)\n      {\n         png_push_save_buffer(png_ptr);\n         return;\n      }\n\n      png_push_fill_buffer(png_ptr, chunk_length, 4);\n      png_ptr->push_length = png_get_uint_31(png_ptr, chunk_length);\n      png_reset_crc(png_ptr);\n      png_crc_read(png_ptr, chunk_tag, 4);\n      png_ptr->chunk_name = PNG_CHUNK_FROM_STRING(chunk_tag);\n      png_check_chunk_name(png_ptr, png_ptr->chunk_name);\n      png_ptr->mode |= PNG_HAVE_CHUNK_HEADER;\n   }\n\n   chunk_name = png_ptr->chunk_name;\n\n   if (chunk_name == png_IDAT)\n   {\n      /* This is here above the if/else case statement below because if the\n       * unknown handling marks 'IDAT' as unknown then the IDAT handling case is\n       * completely skipped.\n       *\n       * TODO: there must be a better way of doing this.\n       */\n      if (png_ptr->mode & PNG_AFTER_IDAT)\n         png_ptr->mode |= PNG_HAVE_CHUNK_AFTER_IDAT;\n   }\n\n   if (chunk_name == png_IHDR)\n   {\n      if (png_ptr->push_length != 13)\n         png_error(png_ptr, \"Invalid IHDR length\");\n\n      if (png_ptr->push_length + 4 > png_ptr->buffer_size)\n      {\n         png_push_save_buffer(png_ptr);\n         return;\n      }\n\n      png_handle_IHDR(png_ptr, info_ptr, png_ptr->push_length);\n   }\n\n   else if (chunk_name == png_IEND)\n   {\n      if (png_ptr->push_length + 4 > png_ptr->buffer_size)\n      {\n         png_push_save_buffer(png_ptr);\n         return;\n      }\n\n      png_handle_IEND(png_ptr, info_ptr, png_ptr->push_length);\n\n      png_ptr->process_mode = PNG_READ_DONE_MODE;\n      png_push_have_end(png_ptr, info_ptr);\n   }\n\n#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED\n   else if (png_chunk_unknown_handling(png_ptr, chunk_name))\n   {\n      if (png_ptr->push_length + 4 > png_ptr->buffer_size)\n      {\n         png_push_save_buffer(png_ptr);\n         return;\n      }\n\n      if (chunk_name == png_IDAT)\n         png_ptr->mode |= PNG_HAVE_IDAT;\n\n      png_handle_unknown(png_ptr, info_ptr, png_ptr->push_length);\n\n      if (chunk_name == png_PLTE)\n         png_ptr->mode |= PNG_HAVE_PLTE;\n\n      else if (chunk_name == png_IDAT)\n      {\n         if (!(png_ptr->mode & PNG_HAVE_IHDR))\n            png_error(png_ptr, \"Missing IHDR before IDAT\");\n\n         else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE &&\n             !(png_ptr->mode & PNG_HAVE_PLTE))\n            png_error(png_ptr, \"Missing PLTE before IDAT\");\n      }\n   }\n\n#endif\n   else if (chunk_name == png_PLTE)\n   {\n      if (png_ptr->push_length + 4 > png_ptr->buffer_size)\n      {\n         png_push_save_buffer(png_ptr);\n         return;\n      }\n      png_handle_PLTE(png_ptr, info_ptr, png_ptr->push_length);\n   }\n\n   else if (chunk_name == png_IDAT)\n   {\n      /* If we reach an IDAT chunk, this means we have read all of the\n       * header chunks, and we can start reading the image (or if this\n       * is called after the image has been read - we have an error).\n       */\n\n      if (!(png_ptr->mode & PNG_HAVE_IHDR))\n         png_error(png_ptr, \"Missing IHDR before IDAT\");\n\n      else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE &&\n          !(png_ptr->mode & PNG_HAVE_PLTE))\n         png_error(png_ptr, \"Missing PLTE before IDAT\");\n\n      if (png_ptr->mode & PNG_HAVE_IDAT)\n      {\n         if (!(png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT))\n            if (png_ptr->push_length == 0)\n               return;\n\n         if (png_ptr->mode & PNG_AFTER_IDAT)\n            png_benign_error(png_ptr, \"Too many IDATs found\");\n      }\n\n      png_ptr->idat_size = png_ptr->push_length;\n      png_ptr->mode |= PNG_HAVE_IDAT;\n      png_ptr->process_mode = PNG_READ_IDAT_MODE;\n      png_push_have_info(png_ptr, info_ptr);\n      png_ptr->zstream.avail_out =\n          (uInt) PNG_ROWBYTES(png_ptr->pixel_depth,\n          png_ptr->iwidth) + 1;\n      png_ptr->zstream.next_out = png_ptr->row_buf;\n      return;\n   }\n\n#ifdef PNG_READ_gAMA_SUPPORTED\n   else if (png_ptr->chunk_name == png_gAMA)\n   {\n      if (png_ptr->push_length + 4 > png_ptr->buffer_size)\n      {\n         png_push_save_buffer(png_ptr);\n         return;\n      }\n\n      png_handle_gAMA(png_ptr, info_ptr, png_ptr->push_length);\n   }\n\n#endif\n#ifdef PNG_READ_sBIT_SUPPORTED\n   else if (png_ptr->chunk_name == png_sBIT)\n   {\n      if (png_ptr->push_length + 4 > png_ptr->buffer_size)\n      {\n         png_push_save_buffer(png_ptr);\n         return;\n      }\n\n      png_handle_sBIT(png_ptr, info_ptr, png_ptr->push_length);\n   }\n\n#endif\n#ifdef PNG_READ_cHRM_SUPPORTED\n   else if (png_ptr->chunk_name == png_cHRM)\n   {\n      if (png_ptr->push_length + 4 > png_ptr->buffer_size)\n      {\n         png_push_save_buffer(png_ptr);\n         return;\n      }\n\n      png_handle_cHRM(png_ptr, info_ptr, png_ptr->push_length);\n   }\n\n#endif\n#ifdef PNG_READ_sRGB_SUPPORTED\n   else if (chunk_name == png_sRGB)\n   {\n      if (png_ptr->push_length + 4 > png_ptr->buffer_size)\n      {\n         png_push_save_buffer(png_ptr);\n         return;\n      }\n\n      png_handle_sRGB(png_ptr, info_ptr, png_ptr->push_length);\n   }\n\n#endif\n#ifdef PNG_READ_iCCP_SUPPORTED\n   else if (png_ptr->chunk_name == png_iCCP)\n   {\n      if (png_ptr->push_length + 4 > png_ptr->buffer_size)\n      {\n         png_push_save_buffer(png_ptr);\n         return;\n      }\n\n      png_handle_iCCP(png_ptr, info_ptr, png_ptr->push_length);\n   }\n\n#endif\n#ifdef PNG_READ_sPLT_SUPPORTED\n   else if (chunk_name == png_sPLT)\n   {\n      if (png_ptr->push_length + 4 > png_ptr->buffer_size)\n      {\n         png_push_save_buffer(png_ptr);\n         return;\n      }\n\n      png_handle_sPLT(png_ptr, info_ptr, png_ptr->push_length);\n   }\n\n#endif\n#ifdef PNG_READ_tRNS_SUPPORTED\n   else if (chunk_name == png_tRNS)\n   {\n      if (png_ptr->push_length + 4 > png_ptr->buffer_size)\n      {\n         png_push_save_buffer(png_ptr);\n         return;\n      }\n\n      png_handle_tRNS(png_ptr, info_ptr, png_ptr->push_length);\n   }\n\n#endif\n#ifdef PNG_READ_bKGD_SUPPORTED\n   else if (chunk_name == png_bKGD)\n   {\n      if (png_ptr->push_length + 4 > png_ptr->buffer_size)\n      {\n         png_push_save_buffer(png_ptr);\n         return;\n      }\n\n      png_handle_bKGD(png_ptr, info_ptr, png_ptr->push_length);\n   }\n\n#endif\n#ifdef PNG_READ_hIST_SUPPORTED\n   else if (chunk_name == png_hIST)\n   {\n      if (png_ptr->push_length + 4 > png_ptr->buffer_size)\n      {\n         png_push_save_buffer(png_ptr);\n         return;\n      }\n\n      png_handle_hIST(png_ptr, info_ptr, png_ptr->push_length);\n   }\n\n#endif\n#ifdef PNG_READ_pHYs_SUPPORTED\n   else if (chunk_name == png_pHYs)\n   {\n      if (png_ptr->push_length + 4 > png_ptr->buffer_size)\n      {\n         png_push_save_buffer(png_ptr);\n         return;\n      }\n\n      png_handle_pHYs(png_ptr, info_ptr, png_ptr->push_length);\n   }\n\n#endif\n#ifdef PNG_READ_oFFs_SUPPORTED\n   else if (chunk_name == png_oFFs)\n   {\n      if (png_ptr->push_length + 4 > png_ptr->buffer_size)\n      {\n         png_push_save_buffer(png_ptr);\n         return;\n      }\n\n      png_handle_oFFs(png_ptr, info_ptr, png_ptr->push_length);\n   }\n#endif\n\n#ifdef PNG_READ_pCAL_SUPPORTED\n   else if (chunk_name == png_pCAL)\n   {\n      if (png_ptr->push_length + 4 > png_ptr->buffer_size)\n      {\n         png_push_save_buffer(png_ptr);\n         return;\n      }\n\n      png_handle_pCAL(png_ptr, info_ptr, png_ptr->push_length);\n   }\n\n#endif\n#ifdef PNG_READ_sCAL_SUPPORTED\n   else if (chunk_name == png_sCAL)\n   {\n      if (png_ptr->push_length + 4 > png_ptr->buffer_size)\n      {\n         png_push_save_buffer(png_ptr);\n         return;\n      }\n\n      png_handle_sCAL(png_ptr, info_ptr, png_ptr->push_length);\n   }\n\n#endif\n#ifdef PNG_READ_tIME_SUPPORTED\n   else if (chunk_name == png_tIME)\n   {\n      if (png_ptr->push_length + 4 > png_ptr->buffer_size)\n      {\n         png_push_save_buffer(png_ptr);\n         return;\n      }\n\n      png_handle_tIME(png_ptr, info_ptr, png_ptr->push_length);\n   }\n\n#endif\n#ifdef PNG_READ_tEXt_SUPPORTED\n   else if (chunk_name == png_tEXt)\n   {\n      if (png_ptr->push_length + 4 > png_ptr->buffer_size)\n      {\n         png_push_save_buffer(png_ptr);\n         return;\n      }\n\n      png_push_handle_tEXt(png_ptr, info_ptr, png_ptr->push_length);\n   }\n\n#endif\n#ifdef PNG_READ_zTXt_SUPPORTED\n   else if (chunk_name == png_zTXt)\n   {\n      if (png_ptr->push_length + 4 > png_ptr->buffer_size)\n      {\n         png_push_save_buffer(png_ptr);\n         return;\n      }\n\n      png_push_handle_zTXt(png_ptr, info_ptr, png_ptr->push_length);\n   }\n\n#endif\n#ifdef PNG_READ_iTXt_SUPPORTED\n   else if (chunk_name == png_iTXt)\n   {\n      if (png_ptr->push_length + 4 > png_ptr->buffer_size)\n      {\n         png_push_save_buffer(png_ptr);\n         return;\n      }\n\n      png_push_handle_iTXt(png_ptr, info_ptr, png_ptr->push_length);\n   }\n\n#endif\n   else\n   {\n      if (png_ptr->push_length + 4 > png_ptr->buffer_size)\n      {\n         png_push_save_buffer(png_ptr);\n         return;\n      }\n      png_push_handle_unknown(png_ptr, info_ptr, png_ptr->push_length);\n   }\n\n   png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER;\n}\n\nvoid /* PRIVATE */\npng_push_crc_skip(png_structp png_ptr, png_uint_32 skip)\n{\n   png_ptr->process_mode = PNG_SKIP_MODE;\n   png_ptr->skip_length = skip;\n}\n\nvoid /* PRIVATE */\npng_push_crc_finish(png_structp png_ptr)\n{\n   if (png_ptr->skip_length && png_ptr->save_buffer_size)\n   {\n      png_size_t save_size = png_ptr->save_buffer_size;\n      png_uint_32 skip_length = png_ptr->skip_length;\n\n      /* We want the smaller of 'skip_length' and 'save_buffer_size', but\n       * they are of different types and we don't know which variable has the\n       * fewest bits.  Carefully select the smaller and cast it to the type of\n       * the larger - this cannot overflow.  Do not cast in the following test\n       * - it will break on either 16 or 64 bit platforms.\n       */\n      if (skip_length < save_size)\n         save_size = (png_size_t)skip_length;\n\n      else\n         skip_length = (png_uint_32)save_size;\n\n      png_calculate_crc(png_ptr, png_ptr->save_buffer_ptr, save_size);\n\n      png_ptr->skip_length -= skip_length;\n      png_ptr->buffer_size -= save_size;\n      png_ptr->save_buffer_size -= save_size;\n      png_ptr->save_buffer_ptr += save_size;\n   }\n   if (png_ptr->skip_length && png_ptr->current_buffer_size)\n   {\n      png_size_t save_size = png_ptr->current_buffer_size;\n      png_uint_32 skip_length = png_ptr->skip_length;\n\n      /* We want the smaller of 'skip_length' and 'current_buffer_size', here,\n       * the same problem exists as above and the same solution.\n       */\n      if (skip_length < save_size)\n         save_size = (png_size_t)skip_length;\n\n      else\n         skip_length = (png_uint_32)save_size;\n\n      png_calculate_crc(png_ptr, png_ptr->current_buffer_ptr, save_size);\n\n      png_ptr->skip_length -= skip_length;\n      png_ptr->buffer_size -= save_size;\n      png_ptr->current_buffer_size -= save_size;\n      png_ptr->current_buffer_ptr += save_size;\n   }\n   if (!png_ptr->skip_length)\n   {\n      if (png_ptr->buffer_size < 4)\n      {\n         png_push_save_buffer(png_ptr);\n         return;\n      }\n\n      png_crc_finish(png_ptr, 0);\n      png_ptr->process_mode = PNG_READ_CHUNK_MODE;\n   }\n}\n\nvoid PNGCBAPI\npng_push_fill_buffer(png_structp png_ptr, png_bytep buffer, png_size_t length)\n{\n   png_bytep ptr;\n\n   if (png_ptr == NULL)\n      return;\n\n   ptr = buffer;\n   if (png_ptr->save_buffer_size)\n   {\n      png_size_t save_size;\n\n      if (length < png_ptr->save_buffer_size)\n         save_size = length;\n\n      else\n         save_size = png_ptr->save_buffer_size;\n\n      png_memcpy(ptr, png_ptr->save_buffer_ptr, save_size);\n      length -= save_size;\n      ptr += save_size;\n      png_ptr->buffer_size -= save_size;\n      png_ptr->save_buffer_size -= save_size;\n      png_ptr->save_buffer_ptr += save_size;\n   }\n   if (length && png_ptr->current_buffer_size)\n   {\n      png_size_t save_size;\n\n      if (length < png_ptr->current_buffer_size)\n         save_size = length;\n\n      else\n         save_size = png_ptr->current_buffer_size;\n\n      png_memcpy(ptr, png_ptr->current_buffer_ptr, save_size);\n      png_ptr->buffer_size -= save_size;\n      png_ptr->current_buffer_size -= save_size;\n      png_ptr->current_buffer_ptr += save_size;\n   }\n}\n\nvoid /* PRIVATE */\npng_push_save_buffer(png_structp png_ptr)\n{\n   if (png_ptr->save_buffer_size)\n   {\n      if (png_ptr->save_buffer_ptr != png_ptr->save_buffer)\n      {\n         png_size_t i, istop;\n         png_bytep sp;\n         png_bytep dp;\n\n         istop = png_ptr->save_buffer_size;\n         for (i = 0, sp = png_ptr->save_buffer_ptr, dp = png_ptr->save_buffer;\n             i < istop; i++, sp++, dp++)\n         {\n            *dp = *sp;\n         }\n      }\n   }\n   if (png_ptr->save_buffer_size + png_ptr->current_buffer_size >\n       png_ptr->save_buffer_max)\n   {\n      png_size_t new_max;\n      png_bytep old_buffer;\n\n      if (png_ptr->save_buffer_size > PNG_SIZE_MAX -\n          (png_ptr->current_buffer_size + 256))\n      {\n         png_error(png_ptr, \"Potential overflow of save_buffer\");\n      }\n\n      new_max = png_ptr->save_buffer_size + png_ptr->current_buffer_size + 256;\n      old_buffer = png_ptr->save_buffer;\n      png_ptr->save_buffer = (png_bytep)png_malloc_warn(png_ptr, new_max);\n\n      if (png_ptr->save_buffer == NULL)\n      {\n         png_free(png_ptr, old_buffer);\n         png_error(png_ptr, \"Insufficient memory for save_buffer\");\n      }\n\n      png_memcpy(png_ptr->save_buffer, old_buffer, png_ptr->save_buffer_size);\n      png_free(png_ptr, old_buffer);\n      png_ptr->save_buffer_max = new_max;\n   }\n   if (png_ptr->current_buffer_size)\n   {\n      png_memcpy(png_ptr->save_buffer + png_ptr->save_buffer_size,\n         png_ptr->current_buffer_ptr, png_ptr->current_buffer_size);\n      png_ptr->save_buffer_size += png_ptr->current_buffer_size;\n      png_ptr->current_buffer_size = 0;\n   }\n   png_ptr->save_buffer_ptr = png_ptr->save_buffer;\n   png_ptr->buffer_size = 0;\n}\n\nvoid /* PRIVATE */\npng_push_restore_buffer(png_structp png_ptr, png_bytep buffer,\n   png_size_t buffer_length)\n{\n   png_ptr->current_buffer = buffer;\n   png_ptr->current_buffer_size = buffer_length;\n   png_ptr->buffer_size = buffer_length + png_ptr->save_buffer_size;\n   png_ptr->current_buffer_ptr = png_ptr->current_buffer;\n}\n\nvoid /* PRIVATE */\npng_push_read_IDAT(png_structp png_ptr)\n{\n   if (!(png_ptr->mode & PNG_HAVE_CHUNK_HEADER))\n   {\n      png_byte chunk_length[4];\n      png_byte chunk_tag[4];\n\n      /* TODO: this code can be commoned up with the same code in push_read */\n      if (png_ptr->buffer_size < 8)\n      {\n         png_push_save_buffer(png_ptr);\n         return;\n      }\n\n      png_push_fill_buffer(png_ptr, chunk_length, 4);\n      png_ptr->push_length = png_get_uint_31(png_ptr, chunk_length);\n      png_reset_crc(png_ptr);\n      png_crc_read(png_ptr, chunk_tag, 4);\n      png_ptr->chunk_name = PNG_CHUNK_FROM_STRING(chunk_tag);\n      png_ptr->mode |= PNG_HAVE_CHUNK_HEADER;\n\n      if (png_ptr->chunk_name != png_IDAT)\n      {\n         png_ptr->process_mode = PNG_READ_CHUNK_MODE;\n\n         if (!(png_ptr->flags & PNG_FLAG_ZLIB_FINISHED))\n            png_error(png_ptr, \"Not enough compressed data\");\n\n         return;\n      }\n\n      png_ptr->idat_size = png_ptr->push_length;\n   }\n\n   if (png_ptr->idat_size && png_ptr->save_buffer_size)\n   {\n      png_size_t save_size = png_ptr->save_buffer_size;\n      png_uint_32 idat_size = png_ptr->idat_size;\n\n      /* We want the smaller of 'idat_size' and 'current_buffer_size', but they\n       * are of different types and we don't know which variable has the fewest\n       * bits.  Carefully select the smaller and cast it to the type of the\n       * larger - this cannot overflow.  Do not cast in the following test - it\n       * will break on either 16 or 64 bit platforms.\n       */\n      if (idat_size < save_size)\n         save_size = (png_size_t)idat_size;\n\n      else\n         idat_size = (png_uint_32)save_size;\n\n      png_calculate_crc(png_ptr, png_ptr->save_buffer_ptr, save_size);\n\n      png_process_IDAT_data(png_ptr, png_ptr->save_buffer_ptr, save_size);\n\n      png_ptr->idat_size -= idat_size;\n      png_ptr->buffer_size -= save_size;\n      png_ptr->save_buffer_size -= save_size;\n      png_ptr->save_buffer_ptr += save_size;\n   }\n\n   if (png_ptr->idat_size && png_ptr->current_buffer_size)\n   {\n      png_size_t save_size = png_ptr->current_buffer_size;\n      png_uint_32 idat_size = png_ptr->idat_size;\n\n      /* We want the smaller of 'idat_size' and 'current_buffer_size', but they\n       * are of different types and we don't know which variable has the fewest\n       * bits.  Carefully select the smaller and cast it to the type of the\n       * larger - this cannot overflow.\n       */\n      if (idat_size < save_size)\n         save_size = (png_size_t)idat_size;\n\n      else\n         idat_size = (png_uint_32)save_size;\n\n      png_calculate_crc(png_ptr, png_ptr->current_buffer_ptr, save_size);\n\n      png_process_IDAT_data(png_ptr, png_ptr->current_buffer_ptr, save_size);\n\n      png_ptr->idat_size -= idat_size;\n      png_ptr->buffer_size -= save_size;\n      png_ptr->current_buffer_size -= save_size;\n      png_ptr->current_buffer_ptr += save_size;\n   }\n   if (!png_ptr->idat_size)\n   {\n      if (png_ptr->buffer_size < 4)\n      {\n         png_push_save_buffer(png_ptr);\n         return;\n      }\n\n      png_crc_finish(png_ptr, 0);\n      png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER;\n      png_ptr->mode |= PNG_AFTER_IDAT;\n   }\n}\n\nvoid /* PRIVATE */\npng_process_IDAT_data(png_structp png_ptr, png_bytep buffer,\n   png_size_t buffer_length)\n{\n   /* The caller checks for a non-zero buffer length. */\n   if (!(buffer_length > 0) || buffer == NULL)\n      png_error(png_ptr, \"No IDAT data (internal error)\");\n\n   /* This routine must process all the data it has been given\n    * before returning, calling the row callback as required to\n    * handle the uncompressed results.\n    */\n   png_ptr->zstream.next_in = buffer;\n   png_ptr->zstream.avail_in = (uInt)buffer_length;\n\n   /* Keep going until the decompressed data is all processed\n    * or the stream marked as finished.\n    */\n   while (png_ptr->zstream.avail_in > 0 &&\n          !(png_ptr->flags & PNG_FLAG_ZLIB_FINISHED))\n   {\n      int ret;\n\n      /* We have data for zlib, but we must check that zlib\n       * has someplace to put the results.  It doesn't matter\n       * if we don't expect any results -- it may be the input\n       * data is just the LZ end code.\n       */\n      if (!(png_ptr->zstream.avail_out > 0))\n      {\n         png_ptr->zstream.avail_out =\n             (uInt) PNG_ROWBYTES(png_ptr->pixel_depth,\n             png_ptr->iwidth) + 1;\n\n         png_ptr->zstream.next_out = png_ptr->row_buf;\n      }\n\n      /* Using Z_SYNC_FLUSH here means that an unterminated\n       * LZ stream (a stream with a missing end code) can still\n       * be handled, otherwise (Z_NO_FLUSH) a future zlib\n       * implementation might defer output and therefore\n       * change the current behavior (see comments in inflate.c\n       * for why this doesn't happen at present with zlib 1.2.5).\n       */\n      ret = inflate(&png_ptr->zstream, Z_SYNC_FLUSH);\n\n      /* Check for any failure before proceeding. */\n      if (ret != Z_OK && ret != Z_STREAM_END)\n      {\n         /* Terminate the decompression. */\n         png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED;\n\n         /* This may be a truncated stream (missing or\n          * damaged end code).  Treat that as a warning.\n          */\n         if (png_ptr->row_number >= png_ptr->num_rows ||\n             png_ptr->pass > 6)\n            png_warning(png_ptr, \"Truncated compressed data in IDAT\");\n\n         else\n            png_error(png_ptr, \"Decompression error in IDAT\");\n\n         /* Skip the check on unprocessed input */\n         return;\n      }\n\n      /* Did inflate output any data? */\n      if (png_ptr->zstream.next_out != png_ptr->row_buf)\n      {\n         /* Is this unexpected data after the last row?\n          * If it is, artificially terminate the LZ output\n          * here.\n          */\n         if (png_ptr->row_number >= png_ptr->num_rows ||\n             png_ptr->pass > 6)\n         {\n            /* Extra data. */\n            png_warning(png_ptr, \"Extra compressed data in IDAT\");\n            png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED;\n\n            /* Do no more processing; skip the unprocessed\n             * input check below.\n             */\n            return;\n         }\n\n         /* Do we have a complete row? */\n         if (png_ptr->zstream.avail_out == 0)\n            png_push_process_row(png_ptr);\n      }\n\n      /* And check for the end of the stream. */\n      if (ret == Z_STREAM_END)\n         png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED;\n   }\n\n   /* All the data should have been processed, if anything\n    * is left at this point we have bytes of IDAT data\n    * after the zlib end code.\n    */\n   if (png_ptr->zstream.avail_in > 0)\n      png_warning(png_ptr, \"Extra compression data in IDAT\");\n}\n\nvoid /* PRIVATE */\npng_push_process_row(png_structp png_ptr)\n{\n   /* 1.5.6: row_info moved out of png_struct to a local here. */\n   png_row_info row_info;\n\n   row_info.width = png_ptr->iwidth; /* NOTE: width of current interlaced row */\n   row_info.color_type = png_ptr->color_type;\n   row_info.bit_depth = png_ptr->bit_depth;\n   row_info.channels = png_ptr->channels;\n   row_info.pixel_depth = png_ptr->pixel_depth;\n   row_info.rowbytes = PNG_ROWBYTES(row_info.pixel_depth, row_info.width);\n\n   if (png_ptr->row_buf[0] > PNG_FILTER_VALUE_NONE)\n   {\n      if (png_ptr->row_buf[0] < PNG_FILTER_VALUE_LAST)\n         png_read_filter_row(png_ptr, &row_info, png_ptr->row_buf + 1,\n            png_ptr->prev_row + 1, png_ptr->row_buf[0]);\n      else\n         png_error(png_ptr, \"bad adaptive filter value\");\n   }\n\n   /* libpng 1.5.6: the following line was copying png_ptr->rowbytes before\n    * 1.5.6, while the buffer really is this big in current versions of libpng\n    * it may not be in the future, so this was changed just to copy the\n    * interlaced row count:\n    */\n   png_memcpy(png_ptr->prev_row, png_ptr->row_buf, row_info.rowbytes + 1);\n\n#ifdef PNG_READ_TRANSFORMS_SUPPORTED\n   if (png_ptr->transformations)\n      png_do_read_transformations(png_ptr, &row_info);\n#endif\n\n   /* The transformed pixel depth should match the depth now in row_info. */\n   if (png_ptr->transformed_pixel_depth == 0)\n   {\n      png_ptr->transformed_pixel_depth = row_info.pixel_depth;\n      if (row_info.pixel_depth > png_ptr->maximum_pixel_depth)\n         png_error(png_ptr, \"progressive row overflow\");\n   }\n\n   else if (png_ptr->transformed_pixel_depth != row_info.pixel_depth)\n      png_error(png_ptr, \"internal progressive row size calculation error\");\n\n\n#ifdef PNG_READ_INTERLACING_SUPPORTED\n   /* Blow up interlaced rows to full size */\n   if (png_ptr->interlaced && (png_ptr->transformations & PNG_INTERLACE))\n   {\n      if (png_ptr->pass < 6)\n         png_do_read_interlace(&row_info, png_ptr->row_buf + 1, png_ptr->pass,\n            png_ptr->transformations);\n\n    switch (png_ptr->pass)\n    {\n         case 0:\n         {\n            int i;\n            for (i = 0; i < 8 && png_ptr->pass == 0; i++)\n            {\n               png_push_have_row(png_ptr, png_ptr->row_buf + 1);\n               png_read_push_finish_row(png_ptr); /* Updates png_ptr->pass */\n            }\n\n            if (png_ptr->pass == 2) /* Pass 1 might be empty */\n            {\n               for (i = 0; i < 4 && png_ptr->pass == 2; i++)\n               {\n                  png_push_have_row(png_ptr, NULL);\n                  png_read_push_finish_row(png_ptr);\n               }\n            }\n\n            if (png_ptr->pass == 4 && png_ptr->height <= 4)\n            {\n               for (i = 0; i < 2 && png_ptr->pass == 4; i++)\n               {\n                  png_push_have_row(png_ptr, NULL);\n                  png_read_push_finish_row(png_ptr);\n               }\n            }\n\n            if (png_ptr->pass == 6 && png_ptr->height <= 4)\n            {\n                png_push_have_row(png_ptr, NULL);\n                png_read_push_finish_row(png_ptr);\n            }\n\n            break;\n         }\n\n         case 1:\n         {\n            int i;\n            for (i = 0; i < 8 && png_ptr->pass == 1; i++)\n            {\n               png_push_have_row(png_ptr, png_ptr->row_buf + 1);\n               png_read_push_finish_row(png_ptr);\n            }\n\n            if (png_ptr->pass == 2) /* Skip top 4 generated rows */\n            {\n               for (i = 0; i < 4 && png_ptr->pass == 2; i++)\n               {\n                  png_push_have_row(png_ptr, NULL);\n                  png_read_push_finish_row(png_ptr);\n               }\n            }\n\n            break;\n         }\n\n         case 2:\n         {\n            int i;\n\n            for (i = 0; i < 4 && png_ptr->pass == 2; i++)\n            {\n               png_push_have_row(png_ptr, png_ptr->row_buf + 1);\n               png_read_push_finish_row(png_ptr);\n            }\n\n            for (i = 0; i < 4 && png_ptr->pass == 2; i++)\n            {\n               png_push_have_row(png_ptr, NULL);\n               png_read_push_finish_row(png_ptr);\n            }\n\n            if (png_ptr->pass == 4) /* Pass 3 might be empty */\n            {\n               for (i = 0; i < 2 && png_ptr->pass == 4; i++)\n               {\n                  png_push_have_row(png_ptr, NULL);\n                  png_read_push_finish_row(png_ptr);\n               }\n            }\n\n            break;\n         }\n\n         case 3:\n         {\n            int i;\n\n            for (i = 0; i < 4 && png_ptr->pass == 3; i++)\n            {\n               png_push_have_row(png_ptr, png_ptr->row_buf + 1);\n               png_read_push_finish_row(png_ptr);\n            }\n\n            if (png_ptr->pass == 4) /* Skip top two generated rows */\n            {\n               for (i = 0; i < 2 && png_ptr->pass == 4; i++)\n               {\n                  png_push_have_row(png_ptr, NULL);\n                  png_read_push_finish_row(png_ptr);\n               }\n            }\n\n            break;\n         }\n\n         case 4:\n         {\n            int i;\n\n            for (i = 0; i < 2 && png_ptr->pass == 4; i++)\n            {\n               png_push_have_row(png_ptr, png_ptr->row_buf + 1);\n               png_read_push_finish_row(png_ptr);\n            }\n\n            for (i = 0; i < 2 && png_ptr->pass == 4; i++)\n            {\n               png_push_have_row(png_ptr, NULL);\n               png_read_push_finish_row(png_ptr);\n            }\n\n            if (png_ptr->pass == 6) /* Pass 5 might be empty */\n            {\n               png_push_have_row(png_ptr, NULL);\n               png_read_push_finish_row(png_ptr);\n            }\n\n            break;\n         }\n\n         case 5:\n         {\n            int i;\n\n            for (i = 0; i < 2 && png_ptr->pass == 5; i++)\n            {\n               png_push_have_row(png_ptr, png_ptr->row_buf + 1);\n               png_read_push_finish_row(png_ptr);\n            }\n\n            if (png_ptr->pass == 6) /* Skip top generated row */\n            {\n               png_push_have_row(png_ptr, NULL);\n               png_read_push_finish_row(png_ptr);\n            }\n\n            break;\n         }\n\n         default:\n         case 6:\n         {\n            png_push_have_row(png_ptr, png_ptr->row_buf + 1);\n            png_read_push_finish_row(png_ptr);\n\n            if (png_ptr->pass != 6)\n               break;\n\n            png_push_have_row(png_ptr, NULL);\n            png_read_push_finish_row(png_ptr);\n         }\n      }\n   }\n   else\n#endif\n   {\n      png_push_have_row(png_ptr, png_ptr->row_buf + 1);\n      png_read_push_finish_row(png_ptr);\n   }\n}\n\nvoid /* PRIVATE */\npng_read_push_finish_row(png_structp png_ptr)\n{\n#ifdef PNG_READ_INTERLACING_SUPPORTED\n   /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */\n\n   /* Start of interlace block */\n   static PNG_CONST png_byte FARDATA png_pass_start[] = {0, 4, 0, 2, 0, 1, 0};\n\n   /* Offset to next interlace block */\n   static PNG_CONST png_byte FARDATA png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1};\n\n   /* Start of interlace block in the y direction */\n   static PNG_CONST png_byte FARDATA png_pass_ystart[] = {0, 0, 4, 0, 2, 0, 1};\n\n   /* Offset to next interlace block in the y direction */\n   static PNG_CONST png_byte FARDATA png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2};\n\n   /* Height of interlace block.  This is not currently used - if you need\n    * it, uncomment it here and in png.h\n   static PNG_CONST png_byte FARDATA png_pass_height[] = {8, 8, 4, 4, 2, 2, 1};\n   */\n#endif\n\n   png_ptr->row_number++;\n   if (png_ptr->row_number < png_ptr->num_rows)\n      return;\n\n#ifdef PNG_READ_INTERLACING_SUPPORTED\n   if (png_ptr->interlaced)\n   {\n      png_ptr->row_number = 0;\n      png_memset(png_ptr->prev_row, 0, png_ptr->rowbytes + 1);\n\n      do\n      {\n         png_ptr->pass++;\n         if ((png_ptr->pass == 1 && png_ptr->width < 5) ||\n             (png_ptr->pass == 3 && png_ptr->width < 3) ||\n             (png_ptr->pass == 5 && png_ptr->width < 2))\n            png_ptr->pass++;\n\n         if (png_ptr->pass > 7)\n            png_ptr->pass--;\n\n         if (png_ptr->pass >= 7)\n            break;\n\n         png_ptr->iwidth = (png_ptr->width +\n             png_pass_inc[png_ptr->pass] - 1 -\n             png_pass_start[png_ptr->pass]) /\n             png_pass_inc[png_ptr->pass];\n\n         if (png_ptr->transformations & PNG_INTERLACE)\n            break;\n\n         png_ptr->num_rows = (png_ptr->height +\n             png_pass_yinc[png_ptr->pass] - 1 -\n             png_pass_ystart[png_ptr->pass]) /\n             png_pass_yinc[png_ptr->pass];\n\n      } while (png_ptr->iwidth == 0 || png_ptr->num_rows == 0);\n   }\n#endif /* PNG_READ_INTERLACING_SUPPORTED */\n}\n\n#ifdef PNG_READ_tEXt_SUPPORTED\nvoid /* PRIVATE */\npng_push_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32\n    length)\n{\n   if (!(png_ptr->mode & PNG_HAVE_IHDR) || (png_ptr->mode & PNG_HAVE_IEND))\n      {\n         PNG_UNUSED(info_ptr) /* To quiet some compiler warnings */\n         png_error(png_ptr, \"Out of place tEXt\");\n         /* NOT REACHED */\n      }\n\n#ifdef PNG_MAX_MALLOC_64K\n   png_ptr->skip_length = 0;  /* This may not be necessary */\n\n   if (length > (png_uint_32)65535L) /* Can't hold entire string in memory */\n   {\n      png_warning(png_ptr, \"tEXt chunk too large to fit in memory\");\n      png_ptr->skip_length = length - (png_uint_32)65535L;\n      length = (png_uint_32)65535L;\n   }\n#endif\n\n   png_ptr->current_text = (png_charp)png_malloc(png_ptr, length + 1);\n   png_ptr->current_text[length] = '\\0';\n   png_ptr->current_text_ptr = png_ptr->current_text;\n   png_ptr->current_text_size = (png_size_t)length;\n   png_ptr->current_text_left = (png_size_t)length;\n   png_ptr->process_mode = PNG_READ_tEXt_MODE;\n}\n\nvoid /* PRIVATE */\npng_push_read_tEXt(png_structp png_ptr, png_infop info_ptr)\n{\n   if (png_ptr->buffer_size && png_ptr->current_text_left)\n   {\n      png_size_t text_size;\n\n      if (png_ptr->buffer_size < png_ptr->current_text_left)\n         text_size = png_ptr->buffer_size;\n\n      else\n         text_size = png_ptr->current_text_left;\n\n      png_crc_read(png_ptr, (png_bytep)png_ptr->current_text_ptr, text_size);\n      png_ptr->current_text_left -= text_size;\n      png_ptr->current_text_ptr += text_size;\n   }\n   if (!(png_ptr->current_text_left))\n   {\n      png_textp text_ptr;\n      png_charp text;\n      png_charp key;\n      int ret;\n\n      if (png_ptr->buffer_size < 4)\n      {\n         png_push_save_buffer(png_ptr);\n         return;\n      }\n\n      png_push_crc_finish(png_ptr);\n\n#ifdef PNG_MAX_MALLOC_64K\n      if (png_ptr->skip_length)\n         return;\n#endif\n\n      key = png_ptr->current_text;\n\n      for (text = key; *text; text++)\n         /* Empty loop */ ;\n\n      if (text < key + png_ptr->current_text_size)\n         text++;\n\n      text_ptr = (png_textp)png_malloc(png_ptr, png_sizeof(png_text));\n      text_ptr->compression = PNG_TEXT_COMPRESSION_NONE;\n      text_ptr->key = key;\n      text_ptr->itxt_length = 0;\n      text_ptr->lang = NULL;\n      text_ptr->lang_key = NULL;\n      text_ptr->text = text;\n\n      ret = png_set_text_2(png_ptr, info_ptr, text_ptr, 1);\n\n      png_free(png_ptr, key);\n      png_free(png_ptr, text_ptr);\n      png_ptr->current_text = NULL;\n\n      if (ret)\n         png_warning(png_ptr, \"Insufficient memory to store text chunk\");\n   }\n}\n#endif\n\n#ifdef PNG_READ_zTXt_SUPPORTED\nvoid /* PRIVATE */\npng_push_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32\n   length)\n{\n   if (!(png_ptr->mode & PNG_HAVE_IHDR) || (png_ptr->mode & PNG_HAVE_IEND))\n   {\n      PNG_UNUSED(info_ptr) /* To quiet some compiler warnings */\n      png_error(png_ptr, \"Out of place zTXt\");\n      /* NOT REACHED */\n   }\n\n#ifdef PNG_MAX_MALLOC_64K\n   /* We can't handle zTXt chunks > 64K, since we don't have enough space\n    * to be able to store the uncompressed data.  Actually, the threshold\n    * is probably around 32K, but it isn't as definite as 64K is.\n    */\n   if (length > (png_uint_32)65535L)\n   {\n      png_warning(png_ptr, \"zTXt chunk too large to fit in memory\");\n      png_push_crc_skip(png_ptr, length);\n      return;\n   }\n#endif\n\n   png_ptr->current_text = (png_charp)png_malloc(png_ptr, length + 1);\n   png_ptr->current_text[length] = '\\0';\n   png_ptr->current_text_ptr = png_ptr->current_text;\n   png_ptr->current_text_size = (png_size_t)length;\n   png_ptr->current_text_left = (png_size_t)length;\n   png_ptr->process_mode = PNG_READ_zTXt_MODE;\n}\n\nvoid /* PRIVATE */\npng_push_read_zTXt(png_structp png_ptr, png_infop info_ptr)\n{\n   if (png_ptr->buffer_size && png_ptr->current_text_left)\n   {\n      png_size_t text_size;\n\n      if (png_ptr->buffer_size < (png_uint_32)png_ptr->current_text_left)\n         text_size = png_ptr->buffer_size;\n\n      else\n         text_size = png_ptr->current_text_left;\n\n      png_crc_read(png_ptr, (png_bytep)png_ptr->current_text_ptr, text_size);\n      png_ptr->current_text_left -= text_size;\n      png_ptr->current_text_ptr += text_size;\n   }\n   if (!(png_ptr->current_text_left))\n   {\n      png_textp text_ptr;\n      png_charp text;\n      png_charp key;\n      int ret;\n      png_size_t text_size, key_size;\n\n      if (png_ptr->buffer_size < 4)\n      {\n         png_push_save_buffer(png_ptr);\n         return;\n      }\n\n      png_push_crc_finish(png_ptr);\n\n      key = png_ptr->current_text;\n\n      for (text = key; *text; text++)\n         /* Empty loop */ ;\n\n      /* zTXt can't have zero text */\n      if (text >= key + png_ptr->current_text_size)\n      {\n         png_ptr->current_text = NULL;\n         png_free(png_ptr, key);\n         return;\n      }\n\n      text++;\n\n      if (*text != PNG_TEXT_COMPRESSION_zTXt) /* Check compression byte */\n      {\n         png_ptr->current_text = NULL;\n         png_free(png_ptr, key);\n         return;\n      }\n\n      text++;\n\n      png_ptr->zstream.next_in = (png_bytep)text;\n      png_ptr->zstream.avail_in = (uInt)(png_ptr->current_text_size -\n          (text - key));\n      png_ptr->zstream.next_out = png_ptr->zbuf;\n      png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size;\n\n      key_size = text - key;\n      text_size = 0;\n      text = NULL;\n      ret = Z_STREAM_END;\n\n      while (png_ptr->zstream.avail_in)\n      {\n         ret = inflate(&png_ptr->zstream, Z_PARTIAL_FLUSH);\n         if (ret != Z_OK && ret != Z_STREAM_END)\n         {\n            inflateReset(&png_ptr->zstream);\n            png_ptr->zstream.avail_in = 0;\n            png_ptr->current_text = NULL;\n            png_free(png_ptr, key);\n            png_free(png_ptr, text);\n            return;\n         }\n\n         if (!(png_ptr->zstream.avail_out) || ret == Z_STREAM_END)\n         {\n            if (text == NULL)\n            {\n               text = (png_charp)png_malloc(png_ptr,\n                   (png_ptr->zbuf_size\n                   - png_ptr->zstream.avail_out + key_size + 1));\n\n               png_memcpy(text + key_size, png_ptr->zbuf,\n                   png_ptr->zbuf_size - png_ptr->zstream.avail_out);\n\n               png_memcpy(text, key, key_size);\n\n               text_size = key_size + png_ptr->zbuf_size -\n                   png_ptr->zstream.avail_out;\n\n               *(text + text_size) = '\\0';\n            }\n\n            else\n            {\n               png_charp tmp;\n\n               tmp = text;\n               text = (png_charp)png_malloc(png_ptr, text_size +\n                   (png_ptr->zbuf_size\n                   - png_ptr->zstream.avail_out + 1));\n\n               png_memcpy(text, tmp, text_size);\n               png_free(png_ptr, tmp);\n\n               png_memcpy(text + text_size, png_ptr->zbuf,\n                   png_ptr->zbuf_size - png_ptr->zstream.avail_out);\n\n               text_size += png_ptr->zbuf_size - png_ptr->zstream.avail_out;\n               *(text + text_size) = '\\0';\n            }\n\n            if (ret != Z_STREAM_END)\n            {\n               png_ptr->zstream.next_out = png_ptr->zbuf;\n               png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size;\n            }\n         }\n         else\n         {\n            break;\n         }\n\n         if (ret == Z_STREAM_END)\n            break;\n      }\n\n      inflateReset(&png_ptr->zstream);\n      png_ptr->zstream.avail_in = 0;\n\n      if (ret != Z_STREAM_END)\n      {\n         png_ptr->current_text = NULL;\n         png_free(png_ptr, key);\n         png_free(png_ptr, text);\n         return;\n      }\n\n      png_ptr->current_text = NULL;\n      png_free(png_ptr, key);\n      key = text;\n      text += key_size;\n\n      text_ptr = (png_textp)png_malloc(png_ptr,\n          png_sizeof(png_text));\n      text_ptr->compression = PNG_TEXT_COMPRESSION_zTXt;\n      text_ptr->key = key;\n      text_ptr->itxt_length = 0;\n      text_ptr->lang = NULL;\n      text_ptr->lang_key = NULL;\n      text_ptr->text = text;\n\n      ret = png_set_text_2(png_ptr, info_ptr, text_ptr, 1);\n\n      png_free(png_ptr, key);\n      png_free(png_ptr, text_ptr);\n\n      if (ret)\n         png_warning(png_ptr, \"Insufficient memory to store text chunk\");\n   }\n}\n#endif\n\n#ifdef PNG_READ_iTXt_SUPPORTED\nvoid /* PRIVATE */\npng_push_handle_iTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32\n    length)\n{\n   if (!(png_ptr->mode & PNG_HAVE_IHDR) || (png_ptr->mode & PNG_HAVE_IEND))\n   {\n      PNG_UNUSED(info_ptr) /* To quiet some compiler warnings */\n      png_error(png_ptr, \"Out of place iTXt\");\n      /* NOT REACHED */\n   }\n\n#ifdef PNG_MAX_MALLOC_64K\n   png_ptr->skip_length = 0;  /* This may not be necessary */\n\n   if (length > (png_uint_32)65535L) /* Can't hold entire string in memory */\n   {\n      png_warning(png_ptr, \"iTXt chunk too large to fit in memory\");\n      png_ptr->skip_length = length - (png_uint_32)65535L;\n      length = (png_uint_32)65535L;\n   }\n#endif\n\n   png_ptr->current_text = (png_charp)png_malloc(png_ptr, length + 1);\n   png_ptr->current_text[length] = '\\0';\n   png_ptr->current_text_ptr = png_ptr->current_text;\n   png_ptr->current_text_size = (png_size_t)length;\n   png_ptr->current_text_left = (png_size_t)length;\n   png_ptr->process_mode = PNG_READ_iTXt_MODE;\n}\n\nvoid /* PRIVATE */\npng_push_read_iTXt(png_structp png_ptr, png_infop info_ptr)\n{\n\n   if (png_ptr->buffer_size && png_ptr->current_text_left)\n   {\n      png_size_t text_size;\n\n      if (png_ptr->buffer_size < png_ptr->current_text_left)\n         text_size = png_ptr->buffer_size;\n\n      else\n         text_size = png_ptr->current_text_left;\n\n      png_crc_read(png_ptr, (png_bytep)png_ptr->current_text_ptr, text_size);\n      png_ptr->current_text_left -= text_size;\n      png_ptr->current_text_ptr += text_size;\n   }\n\n   if (!(png_ptr->current_text_left))\n   {\n      png_textp text_ptr;\n      png_charp key;\n      int comp_flag;\n      png_charp lang;\n      png_charp lang_key;\n      png_charp text;\n      int ret;\n\n      if (png_ptr->buffer_size < 4)\n      {\n         png_push_save_buffer(png_ptr);\n         return;\n      }\n\n      png_push_crc_finish(png_ptr);\n\n#ifdef PNG_MAX_MALLOC_64K\n      if (png_ptr->skip_length)\n         return;\n#endif\n\n      key = png_ptr->current_text;\n\n      for (lang = key; *lang; lang++)\n         /* Empty loop */ ;\n\n      if (lang < key + png_ptr->current_text_size - 3)\n         lang++;\n\n      comp_flag = *lang++;\n      lang++;     /* Skip comp_type, always zero */\n\n      for (lang_key = lang; *lang_key; lang_key++)\n         /* Empty loop */ ;\n\n      lang_key++;        /* Skip NUL separator */\n\n      text=lang_key;\n\n      if (lang_key < key + png_ptr->current_text_size - 1)\n      {\n         for (; *text; text++)\n            /* Empty loop */ ;\n      }\n\n      if (text < key + png_ptr->current_text_size)\n         text++;\n\n      text_ptr = (png_textp)png_malloc(png_ptr,\n          png_sizeof(png_text));\n\n      text_ptr->compression = comp_flag + 2;\n      text_ptr->key = key;\n      text_ptr->lang = lang;\n      text_ptr->lang_key = lang_key;\n      text_ptr->text = text;\n      text_ptr->text_length = 0;\n      text_ptr->itxt_length = png_strlen(text);\n\n      ret = png_set_text_2(png_ptr, info_ptr, text_ptr, 1);\n\n      png_ptr->current_text = NULL;\n\n      png_free(png_ptr, text_ptr);\n      if (ret)\n         png_warning(png_ptr, \"Insufficient memory to store iTXt chunk\");\n   }\n}\n#endif\n\n/* This function is called when we haven't found a handler for this\n * chunk.  If there isn't a problem with the chunk itself (ie a bad chunk\n * name or a critical chunk), the chunk is (currently) silently ignored.\n */\nvoid /* PRIVATE */\npng_push_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32\n    length)\n{\n   png_uint_32 skip = 0;\n   png_uint_32 chunk_name = png_ptr->chunk_name;\n\n   if (PNG_CHUNK_CRITICAL(chunk_name))\n   {\n#ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED\n      if (png_chunk_unknown_handling(png_ptr, chunk_name) !=\n          PNG_HANDLE_CHUNK_ALWAYS\n#ifdef PNG_READ_USER_CHUNKS_SUPPORTED\n          && png_ptr->read_user_chunk_fn == NULL\n#endif\n          )\n#endif\n         png_chunk_error(png_ptr, \"unknown critical chunk\");\n\n      PNG_UNUSED(info_ptr) /* To quiet some compiler warnings */\n   }\n\n#ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED\n   /* TODO: the code below is apparently just using the\n    * png_struct::unknown_chunk member as a temporarily variable, it should be\n    * possible to eliminate both it and the temporary buffer.\n    */\n   if (png_ptr->flags & PNG_FLAG_KEEP_UNKNOWN_CHUNKS)\n   {\n#ifdef PNG_MAX_MALLOC_64K\n      if (length > 65535)\n      {\n         png_warning(png_ptr, \"unknown chunk too large to fit in memory\");\n         skip = length - 65535;\n         length = 65535;\n      }\n#endif\n      /* This is just a record for the user; libpng doesn't use the character\n       * form of the name.\n       */\n      PNG_CSTRING_FROM_CHUNK(png_ptr->unknown_chunk.name, png_ptr->chunk_name);\n\n      png_ptr->unknown_chunk.size = length;\n\n      if (length == 0)\n         png_ptr->unknown_chunk.data = NULL;\n\n      else\n      {\n         png_ptr->unknown_chunk.data = (png_bytep)png_malloc(png_ptr,\n            png_ptr->unknown_chunk.size);\n         png_crc_read(png_ptr, (png_bytep)png_ptr->unknown_chunk.data,\n            png_ptr->unknown_chunk.size);\n      }\n\n#ifdef PNG_READ_USER_CHUNKS_SUPPORTED\n      if (png_ptr->read_user_chunk_fn != NULL)\n      {\n         /* Callback to user unknown chunk handler */\n         int ret;\n         ret = (*(png_ptr->read_user_chunk_fn))\n             (png_ptr, &png_ptr->unknown_chunk);\n\n         if (ret < 0)\n            png_chunk_error(png_ptr, \"error in user chunk\");\n\n         if (ret == 0)\n         {\n            if (PNG_CHUNK_CRITICAL(png_ptr->chunk_name))\n               if (png_chunk_unknown_handling(png_ptr, chunk_name) !=\n                   PNG_HANDLE_CHUNK_ALWAYS)\n                  png_chunk_error(png_ptr, \"unknown critical chunk\");\n            png_set_unknown_chunks(png_ptr, info_ptr,\n                &png_ptr->unknown_chunk, 1);\n         }\n      }\n\n      else\n#endif\n         png_set_unknown_chunks(png_ptr, info_ptr, &png_ptr->unknown_chunk, 1);\n      png_free(png_ptr, png_ptr->unknown_chunk.data);\n      png_ptr->unknown_chunk.data = NULL;\n   }\n\n   else\n#endif\n      skip=length;\n   png_push_crc_skip(png_ptr, skip);\n}\n\nvoid /* PRIVATE */\npng_push_have_info(png_structp png_ptr, png_infop info_ptr)\n{\n   if (png_ptr->info_fn != NULL)\n      (*(png_ptr->info_fn))(png_ptr, info_ptr);\n}\n\nvoid /* PRIVATE */\npng_push_have_end(png_structp png_ptr, png_infop info_ptr)\n{\n   if (png_ptr->end_fn != NULL)\n      (*(png_ptr->end_fn))(png_ptr, info_ptr);\n}\n\nvoid /* PRIVATE */\npng_push_have_row(png_structp png_ptr, png_bytep row)\n{\n   if (png_ptr->row_fn != NULL)\n      (*(png_ptr->row_fn))(png_ptr, row, png_ptr->row_number,\n         (int)png_ptr->pass);\n}\n\n#ifdef PNG_READ_INTERLACING_SUPPORTED\nvoid PNGAPI\npng_progressive_combine_row (png_structp png_ptr, png_bytep old_row,\n    png_const_bytep new_row)\n{\n   if (png_ptr == NULL)\n      return;\n\n   /* new_row is a flag here - if it is NULL then the app callback was called\n    * from an empty row (see the calls to png_struct::row_fn below), otherwise\n    * it must be png_ptr->row_buf+1\n    */\n   if (new_row != NULL)\n      png_combine_row(png_ptr, old_row, 1/*display*/);\n}\n#endif /* PNG_READ_INTERLACING_SUPPORTED */\n\nvoid PNGAPI\npng_set_progressive_read_fn(png_structp png_ptr, png_voidp progressive_ptr,\n    png_progressive_info_ptr info_fn, png_progressive_row_ptr row_fn,\n    png_progressive_end_ptr end_fn)\n{\n   if (png_ptr == NULL)\n      return;\n\n   png_ptr->info_fn = info_fn;\n   png_ptr->row_fn = row_fn;\n   png_ptr->end_fn = end_fn;\n\n   png_set_read_fn(png_ptr, progressive_ptr, png_push_fill_buffer);\n}\n\npng_voidp PNGAPI\npng_get_progressive_ptr(png_const_structp png_ptr)\n{\n   if (png_ptr == NULL)\n      return (NULL);\n\n   return png_ptr->io_ptr;\n}\n#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */\n"
  },
  {
    "path": "Projects/Tools/PNGAlphaPremultiplier/Native/Source/LibPng/pngpriv.h",
    "content": "\n/* pngpriv.h - private declarations for use inside libpng\n *\n * For conditions of distribution and use, see copyright notice in png.h\n * Copyright (c) 1998-2011 Glenn Randers-Pehrson\n * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)\n * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)\n *\n * Last changed in libpng 1.5.7 [December 15, 2011]\n *\n * This code is released under the libpng license.\n * For conditions of distribution and use, see the disclaimer\n * and license in png.h\n */\n\n/* The symbols declared in this file (including the functions declared\n * as PNG_EXTERN) are PRIVATE.  They are not part of the libpng public\n * interface, and are not recommended for use by regular applications.\n * Some of them may become public in the future; others may stay private,\n * change in an incompatible way, or even disappear.\n * Although the libpng users are not forbidden to include this header,\n * they should be well aware of the issues that may arise from doing so.\n */\n\n#ifndef PNGPRIV_H\n#define PNGPRIV_H\n\n/* Feature Test Macros.  The following are defined here to ensure that correctly\n * implemented libraries reveal the APIs libpng needs to build and hide those\n * that are not needed and potentially damaging to the compilation.\n *\n * Feature Test Macros must be defined before any system header is included (see\n * POSIX 1003.1 2.8.2 \"POSIX Symbols.\"\n *\n * These macros only have an effect if the operating system supports either\n * POSIX 1003.1 or C99, or both.  On other operating systems (particularly\n * Windows/Visual Studio) there is no effect; the OS specific tests below are\n * still required (as of 2011-05-02.)\n */\n#define _POSIX_SOURCE 1 /* Just the POSIX 1003.1 and C89 APIs */\n\n/* This is required for the definition of abort(), used as a last ditch\n * error handler when all else fails.\n */\n#include <stdlib.h>\n\n/* This is used to find 'offsetof', used below for alignment tests. */\n#include <stddef.h>\n\n#define PNGLIB_BUILD /*libpng is being built, not used*/\n\n#ifdef PNG_USER_CONFIG\n#  include \"pngusr.h\"\n   /* These should have been defined in pngusr.h */\n#  ifndef PNG_USER_PRIVATEBUILD\n#    define PNG_USER_PRIVATEBUILD \"Custom libpng build\"\n#  endif\n#  ifndef PNG_USER_DLLFNAME_POSTFIX\n#    define PNG_USER_DLLFNAME_POSTFIX \"Cb\"\n#  endif\n#endif\n\n/* Is this a build of a DLL where compilation of the object modules requires\n * different preprocessor settings to those required for a simple library?  If\n * so PNG_BUILD_DLL must be set.\n *\n * If libpng is used inside a DLL but that DLL does not export the libpng APIs\n * PNG_BUILD_DLL must not be set.  To avoid the code below kicking in build a\n * static library of libpng then link the DLL against that.\n */\n#ifndef PNG_BUILD_DLL\n#  ifdef DLL_EXPORT\n      /* This is set by libtool when files are compiled for a DLL; libtool\n       * always compiles twice, even on systems where it isn't necessary.  Set\n       * PNG_BUILD_DLL in case it is necessary:\n       */\n#     define PNG_BUILD_DLL\n#  else\n#     ifdef _WINDLL\n         /* This is set by the Microsoft Visual Studio IDE in projects that\n          * build a DLL.  It can't easily be removed from those projects (it\n          * isn't visible in the Visual Studio UI) so it is a fairly reliable\n          * indication that PNG_IMPEXP needs to be set to the DLL export\n          * attributes.\n          */\n#        define PNG_BUILD_DLL\n#     else\n#        ifdef __DLL__\n            /* This is set by the Borland C system when compiling for a DLL\n             * (as above.)\n             */\n#           define PNG_BUILD_DLL\n#        else\n            /* Add additional compiler cases here. */\n#        endif\n#     endif\n#  endif\n#endif /* Setting PNG_BUILD_DLL if required */\n\n/* See pngconf.h for more details: the builder of the library may set this on\n * the command line to the right thing for the specific compilation system or it\n * may be automagically set above (at present we know of no system where it does\n * need to be set on the command line.)\n *\n * PNG_IMPEXP must be set here when building the library to prevent pngconf.h\n * setting it to the \"import\" setting for a DLL build.\n */\n#ifndef PNG_IMPEXP\n#  ifdef PNG_BUILD_DLL\n#     define PNG_IMPEXP PNG_DLL_EXPORT\n#  else\n      /* Not building a DLL, or the DLL doesn't require specific export\n       * definitions.\n       */\n#     define PNG_IMPEXP\n#  endif\n#endif\n\n/* No warnings for private or deprecated functions in the build: */\n#ifndef PNG_DEPRECATED\n#  define PNG_DEPRECATED\n#endif\n#ifndef PNG_PRIVATE\n#  define PNG_PRIVATE\n#endif\n\n#include \"png.h\"\n#include \"pnginfo.h\"\n#include \"pngstruct.h\"\n\n/* pngconf.h does not set PNG_DLL_EXPORT unless it is required, so: */\n#ifndef PNG_DLL_EXPORT\n#  define PNG_DLL_EXPORT\n#endif\n\n/* This is used for 16 bit gamma tables - only the top level pointers are const,\n * this could be changed:\n */\ntypedef PNG_CONST png_uint_16p FAR * png_const_uint_16pp;\n\n/* Added at libpng-1.2.9 */\n/* Moved to pngpriv.h at libpng-1.5.0 */\n\n/* config.h is created by and PNG_CONFIGURE_LIBPNG is set by the \"configure\"\n * script.  We may need it here to get the correct configuration on things\n * like limits.\n */\n#ifdef PNG_CONFIGURE_LIBPNG\n#  ifdef HAVE_CONFIG_H\n#    include \"config.h\"\n#  endif\n#endif\n\n/* Moved to pngpriv.h at libpng-1.5.0 */\n/* NOTE: some of these may have been used in external applications as\n * these definitions were exposed in pngconf.h prior to 1.5.\n */\n\n/* If you are running on a machine where you cannot allocate more\n * than 64K of memory at once, uncomment this.  While libpng will not\n * normally need that much memory in a chunk (unless you load up a very\n * large file), zlib needs to know how big of a chunk it can use, and\n * libpng thus makes sure to check any memory allocation to verify it\n * will fit into memory.\n *\n * zlib provides 'MAXSEG_64K' which, if defined, indicates the\n * same limit and pngconf.h (already included) sets the limit\n * if certain operating systems are detected.\n */\n#if defined(MAXSEG_64K) && !defined(PNG_MAX_MALLOC_64K)\n#  define PNG_MAX_MALLOC_64K\n#endif\n\n#ifndef PNG_UNUSED\n/* Unused formal parameter warnings are silenced using the following macro\n * which is expected to have no bad effects on performance (optimizing\n * compilers will probably remove it entirely).  Note that if you replace\n * it with something other than whitespace, you must include the terminating\n * semicolon.\n */\n#  define PNG_UNUSED(param) (void)param;\n#endif\n\n/* Just a little check that someone hasn't tried to define something\n * contradictory.\n */\n#if (PNG_ZBUF_SIZE > 65536L) && defined(PNG_MAX_MALLOC_64K)\n#  undef PNG_ZBUF_SIZE\n#  define PNG_ZBUF_SIZE 65536L\n#endif\n\n/* PNG_STATIC is used to mark internal file scope functions if they need to be\n * accessed for implementation tests (see the code in tests/?*).\n */\n#ifndef PNG_STATIC\n#   define PNG_STATIC static\n#endif\n\n/* C99 restrict is used where possible, to do this 'restrict' is defined as\n * empty if we can't be sure it is supported.  configure builds have already\n * done this work.\n */\n#ifdef PNG_CONFIGURE_LIBPNG\n#  define PNG_RESTRICT restrict\n#else\n   /* Modern compilers support restrict, but assume not for anything not\n    * recognized here:\n    */\n#  if defined __GNUC__ || defined _MSC_VER || defined __WATCOMC__\n#     define PNG_RESTRICT restrict\n#  else\n#     define PNG_RESTRICT\n#  endif\n#endif\n\n/* If warnings or errors are turned off the code is disabled or redirected here.\n * From 1.5.4 functions have been added to allow very limited formatting of\n * error and warning messages - this code will also be disabled here.\n */\n#ifdef PNG_WARNINGS_SUPPORTED\n#  define PNG_WARNING_PARAMETERS(p) png_warning_parameters p;\n#else\n#  define png_warning(s1,s2) ((void)(s1))\n#  define png_chunk_warning(s1,s2) ((void)(s1))\n#  define png_warning_parameter(p,number,string) ((void)0)\n#  define png_warning_parameter_unsigned(p,number,format,value) ((void)0)\n#  define png_warning_parameter_signed(p,number,format,value) ((void)0)\n#  define png_formatted_warning(pp,p,message) ((void)(pp))\n#  define PNG_WARNING_PARAMETERS(p)\n#endif\n#ifndef PNG_ERROR_TEXT_SUPPORTED\n#  define png_error(s1,s2) png_err(s1)\n#  define png_chunk_error(s1,s2) png_err(s1)\n#  define png_fixed_error(s1,s2) png_err(s1)\n#endif\n\n/* C allows up-casts from (void*) to any pointer and (const void*) to any\n * pointer to a const object.  C++ regards this as a type error and requires an\n * explicit, static, cast and provides the static_cast<> rune to ensure that\n * const is not cast away.\n */\n#ifdef __cplusplus\n#  define png_voidcast(type, value) static_cast<type>(value)\n#else\n#  define png_voidcast(type, value) (value)\n#endif /* __cplusplus */\n\n#ifndef PNG_EXTERN\n/* The functions exported by PNG_EXTERN are internal functions, which\n * aren't usually used outside the library (as far as I know), so it is\n * debatable if they should be exported at all.  In the future, when it\n * is possible to have run-time registry of chunk-handling functions,\n * some of these might be made available again.\n *\n * 1.5.7: turned the use of 'extern' back on, since it is localized to pngpriv.h\n * it should be safe now (it is unclear why it was turned off.)\n */\n#  define PNG_EXTERN extern\n#endif\n\n/* Some fixed point APIs are still required even if not exported because\n * they get used by the corresponding floating point APIs.  This magic\n * deals with this:\n */\n#ifdef PNG_FIXED_POINT_SUPPORTED\n#  define PNGFAPI PNGAPI\n#else\n#  define PNGFAPI /* PRIVATE */\n#endif\n\n/* Other defines specific to compilers can go here.  Try to keep\n * them inside an appropriate ifdef/endif pair for portability.\n */\n#if defined(PNG_FLOATING_POINT_SUPPORTED) ||\\\n    defined(PNG_FLOATING_ARITHMETIC_SUPPORTED)\n   /* png.c requires the following ANSI-C constants if the conversion of\n    * floating point to ASCII is implemented therein:\n    *\n    *  DBL_DIG  Maximum number of decimal digits (can be set to any constant)\n    *  DBL_MIN  Smallest normalized fp number (can be set to an arbitrary value)\n    *  DBL_MAX  Maximum floating point number (can be set to an arbitrary value)\n    */\n#  include <float.h>\n\n#  if (defined(__MWERKS__) && defined(macintosh)) || defined(applec) || \\\n    defined(THINK_C) || defined(__SC__) || defined(TARGET_OS_MAC)\n     /* We need to check that <math.h> hasn't already been included earlier\n      * as it seems it doesn't agree with <fp.h>, yet we should really use\n      * <fp.h> if possible.\n      */\n#    if !defined(__MATH_H__) && !defined(__MATH_H) && !defined(__cmath__)\n#      include <fp.h>\n#    endif\n#  else\n#    include <math.h>\n#  endif\n#  if defined(_AMIGA) && defined(__SASC) && defined(_M68881)\n     /* Amiga SAS/C: We must include builtin FPU functions when compiling using\n      * MATH=68881\n      */\n#    include <m68881.h>\n#  endif\n#endif\n\n/* This provides the non-ANSI (far) memory allocation routines. */\n#if defined(__TURBOC__) && defined(__MSDOS__)\n#  include <mem.h>\n#  include <alloc.h>\n#endif\n\n#if defined(WIN32) || defined(_Windows) || defined(_WINDOWS) || \\\n    defined(_WIN32) || defined(__WIN32__)\n#  include <windows.h>  /* defines _WINDOWS_ macro */\n#endif\n\n/* Moved here around 1.5.0beta36 from pngconf.h */\n/* Users may want to use these so they are not private.  Any library\n * functions that are passed far data must be model-independent.\n */\n\n/* Memory model/platform independent fns */\n#ifndef PNG_ABORT\n#  ifdef _WINDOWS_\n#    define PNG_ABORT() ExitProcess(0)\n#  else\n#    define PNG_ABORT() abort()\n#  endif\n#endif\n\n#ifdef USE_FAR_KEYWORD\n/* Use this to make far-to-near assignments */\n#  define CHECK   1\n#  define NOCHECK 0\n#  define CVT_PTR(ptr) (png_far_to_near(png_ptr,ptr,CHECK))\n#  define CVT_PTR_NOCHECK(ptr) (png_far_to_near(png_ptr,ptr,NOCHECK))\n#  define png_strlen  _fstrlen\n#  define png_memcmp  _fmemcmp    /* SJT: added */\n#  define png_memcpy  _fmemcpy\n#  define png_memset  _fmemset\n#else\n#  ifdef _WINDOWS_  /* Favor Windows over C runtime fns */\n#    define CVT_PTR(ptr)         (ptr)\n#    define CVT_PTR_NOCHECK(ptr) (ptr)\n#    define png_strlen  lstrlenA\n#    define png_memcmp  memcmp\n#    define png_memcpy  CopyMemory\n#    define png_memset  memset\n#  else\n#    define CVT_PTR(ptr)         (ptr)\n#    define CVT_PTR_NOCHECK(ptr) (ptr)\n#    define png_strlen  strlen\n#    define png_memcmp  memcmp      /* SJT: added */\n#    define png_memcpy  memcpy\n#    define png_memset  memset\n#  endif\n#endif\n\n/* These macros may need to be architecture dependent. */\n#define PNG_ALIGN_NONE   0 /* do not use data alignment */\n#define PNG_ALIGN_ALWAYS 1 /* assume unaligned accesses are OK */\n#ifdef offsetof\n#  define PNG_ALIGN_OFFSET 2 /* use offsetof to determine alignment */\n#else\n#  define PNG_ALIGN_OFFSET -1 /* prevent the use of this */\n#endif\n#define PNG_ALIGN_SIZE   3 /* use sizeof to determine alignment */\n\n#ifndef PNG_ALIGN_TYPE\n   /* Default to using aligned access optimizations and requiring alignment to a\n    * multiple of the data type size.  Override in a compiler specific fashion\n    * if necessary by inserting tests here:\n    */\n#  define PNG_ALIGN_TYPE PNG_ALIGN_SIZE\n#endif\n\n#if PNG_ALIGN_TYPE == PNG_ALIGN_SIZE\n   /* This is used because in some compiler implementations non-aligned\n    * structure members are supported, so the offsetof approach below fails.\n    * Set PNG_ALIGN_TO_SIZE=0 for compiler combinations where unaligned access\n    * is good for performance.  Do not do this unless you have tested the result\n    * and understand it.\n    */\n#  define png_alignof(type) (sizeof (type))\n#else\n#  if PNG_ALIGN_TYPE == PNG_ALIGN_OFFSET\n#     define png_alignof(type) offsetof(struct{char c; type t;}, t)\n#  else\n#     if PNG_ALIGN_TYPE == PNG_ALIGN_ALWAYS\n#        define png_alignof(type) (1)\n#     endif\n      /* Else leave png_alignof undefined to prevent use thereof */\n#  endif\n#endif\n\n/* This implicitly assumes alignment is always to a power of 2. */\n#ifdef png_alignof\n#  define png_isaligned(ptr, type)\\\n   ((((const char*)ptr-(const char*)0) & (png_alignof(type)-1)) == 0)\n#else\n#  define png_isaligned(ptr, type) 0\n#endif\n\n/* End of memory model/platform independent support */\n/* End of 1.5.0beta36 move from pngconf.h */\n\n/* CONSTANTS and UTILITY MACROS\n * These are used internally by libpng and not exposed in the API\n */\n\n/* Various modes of operation.  Note that after an init, mode is set to\n * zero automatically when the structure is created.  Three of these\n * are defined in png.h because they need to be visible to applications\n * that call png_set_unknown_chunk().\n */\n/* #define PNG_HAVE_IHDR            0x01 (defined in png.h) */\n/* #define PNG_HAVE_PLTE            0x02 (defined in png.h) */\n#define PNG_HAVE_IDAT               0x04\n/* #define PNG_AFTER_IDAT           0x08 (defined in png.h) */\n#define PNG_HAVE_IEND               0x10\n#define PNG_HAVE_gAMA               0x20\n#define PNG_HAVE_cHRM               0x40\n#define PNG_HAVE_sRGB               0x80\n#define PNG_HAVE_CHUNK_HEADER      0x100\n#define PNG_WROTE_tIME             0x200\n#define PNG_WROTE_INFO_BEFORE_PLTE 0x400\n#define PNG_BACKGROUND_IS_GRAY     0x800\n#define PNG_HAVE_PNG_SIGNATURE    0x1000\n#define PNG_HAVE_CHUNK_AFTER_IDAT 0x2000 /* Have another chunk after IDAT */\n\n/* Flags for the transformations the PNG library does on the image data */\n#define PNG_BGR                 0x0001\n#define PNG_INTERLACE           0x0002\n#define PNG_PACK                0x0004\n#define PNG_SHIFT               0x0008\n#define PNG_SWAP_BYTES          0x0010\n#define PNG_INVERT_MONO         0x0020\n#define PNG_QUANTIZE            0x0040\n#define PNG_COMPOSE             0x0080     /* Was PNG_BACKGROUND */\n#define PNG_BACKGROUND_EXPAND   0x0100\n#define PNG_EXPAND_16           0x0200     /* Added to libpng 1.5.2 */\n#define PNG_16_TO_8             0x0400     /* Becomes 'chop' in 1.5.4 */\n#define PNG_RGBA                0x0800\n#define PNG_EXPAND              0x1000\n#define PNG_GAMMA               0x2000\n#define PNG_GRAY_TO_RGB         0x4000\n#define PNG_FILLER              0x8000\n#define PNG_PACKSWAP           0x10000\n#define PNG_SWAP_ALPHA         0x20000\n#define PNG_STRIP_ALPHA        0x40000\n#define PNG_INVERT_ALPHA       0x80000\n#define PNG_USER_TRANSFORM    0x100000\n#define PNG_RGB_TO_GRAY_ERR   0x200000\n#define PNG_RGB_TO_GRAY_WARN  0x400000\n#define PNG_RGB_TO_GRAY       0x600000 /* two bits, RGB_TO_GRAY_ERR|WARN */\n#define PNG_ENCODE_ALPHA      0x800000 /* Added to libpng-1.5.4 */\n#define PNG_ADD_ALPHA         0x1000000 /* Added to libpng-1.2.7 */\n#define PNG_EXPAND_tRNS       0x2000000 /* Added to libpng-1.2.9 */\n#define PNG_SCALE_16_TO_8     0x4000000 /* Added to libpng-1.5.4 */\n                       /*   0x8000000 unused */\n                       /*  0x10000000 unused */\n                       /*  0x20000000 unused */\n                       /*  0x40000000 unused */\n/* Flags for png_create_struct */\n#define PNG_STRUCT_PNG   0x0001\n#define PNG_STRUCT_INFO  0x0002\n\n/* Scaling factor for filter heuristic weighting calculations */\n#define PNG_WEIGHT_FACTOR (1<<(PNG_WEIGHT_SHIFT))\n#define PNG_COST_FACTOR (1<<(PNG_COST_SHIFT))\n\n/* Flags for the png_ptr->flags rather than declaring a byte for each one */\n#define PNG_FLAG_ZLIB_CUSTOM_STRATEGY     0x0001\n#define PNG_FLAG_ZLIB_CUSTOM_LEVEL        0x0002\n#define PNG_FLAG_ZLIB_CUSTOM_MEM_LEVEL    0x0004\n#define PNG_FLAG_ZLIB_CUSTOM_WINDOW_BITS  0x0008\n#define PNG_FLAG_ZLIB_CUSTOM_METHOD       0x0010\n#define PNG_FLAG_ZLIB_FINISHED            0x0020\n#define PNG_FLAG_ROW_INIT                 0x0040\n#define PNG_FLAG_FILLER_AFTER             0x0080\n#define PNG_FLAG_CRC_ANCILLARY_USE        0x0100\n#define PNG_FLAG_CRC_ANCILLARY_NOWARN     0x0200\n#define PNG_FLAG_CRC_CRITICAL_USE         0x0400\n#define PNG_FLAG_CRC_CRITICAL_IGNORE      0x0800\n#define PNG_FLAG_ASSUME_sRGB              0x1000  /* Added to libpng-1.5.4 */\n#define PNG_FLAG_OPTIMIZE_ALPHA           0x2000  /* Added to libpng-1.5.4 */\n#define PNG_FLAG_DETECT_UNINITIALIZED     0x4000  /* Added to libpng-1.5.4 */\n#define PNG_FLAG_KEEP_UNKNOWN_CHUNKS      0x8000\n#define PNG_FLAG_KEEP_UNSAFE_CHUNKS       0x10000\n#define PNG_FLAG_LIBRARY_MISMATCH         0x20000\n#define PNG_FLAG_STRIP_ERROR_NUMBERS      0x40000\n#define PNG_FLAG_STRIP_ERROR_TEXT         0x80000\n#define PNG_FLAG_MALLOC_NULL_MEM_OK       0x100000\n                                  /*      0x200000  unused */\n                                  /*      0x400000  unused */\n#define PNG_FLAG_BENIGN_ERRORS_WARN       0x800000  /* Added to libpng-1.4.0 */\n#define PNG_FLAG_ZTXT_CUSTOM_STRATEGY    0x1000000  /* 5 lines added */\n#define PNG_FLAG_ZTXT_CUSTOM_LEVEL       0x2000000  /* to libpng-1.5.4 */\n#define PNG_FLAG_ZTXT_CUSTOM_MEM_LEVEL   0x4000000\n#define PNG_FLAG_ZTXT_CUSTOM_WINDOW_BITS 0x8000000\n#define PNG_FLAG_ZTXT_CUSTOM_METHOD      0x10000000\n                                  /*     0x20000000  unused */\n                                  /*     0x40000000  unused */\n\n#define PNG_FLAG_CRC_ANCILLARY_MASK (PNG_FLAG_CRC_ANCILLARY_USE | \\\n                                     PNG_FLAG_CRC_ANCILLARY_NOWARN)\n\n#define PNG_FLAG_CRC_CRITICAL_MASK  (PNG_FLAG_CRC_CRITICAL_USE | \\\n                                     PNG_FLAG_CRC_CRITICAL_IGNORE)\n\n#define PNG_FLAG_CRC_MASK           (PNG_FLAG_CRC_ANCILLARY_MASK | \\\n                                     PNG_FLAG_CRC_CRITICAL_MASK)\n\n/* zlib.h declares a magic type 'uInt' that limits the amount of data that zlib\n * can handle at once.  This type need be no larger than 16 bits (so maximum of\n * 65535), this define allows us to discover how big it is, but limited by the\n * maximuum for png_size_t.  The value can be overriden in a library build\n * (pngusr.h, or set it in CPPFLAGS) and it works to set it to a considerably\n * lower value (e.g. 255 works).  A lower value may help memory usage (slightly)\n * and may even improve performance on some systems (and degrade it on others.)\n */\n#ifndef ZLIB_IO_MAX\n#  define ZLIB_IO_MAX ((uInt)-1)\n#endif\n\n/* Save typing and make code easier to understand */\n\n#define PNG_COLOR_DIST(c1, c2) (abs((int)((c1).red) - (int)((c2).red)) + \\\n   abs((int)((c1).green) - (int)((c2).green)) + \\\n   abs((int)((c1).blue) - (int)((c2).blue)))\n\n/* Added to libpng-1.2.6 JB */\n#define PNG_ROWBYTES(pixel_bits, width) \\\n    ((pixel_bits) >= 8 ? \\\n    ((png_size_t)(width) * (((png_size_t)(pixel_bits)) >> 3)) : \\\n    (( ((png_size_t)(width) * ((png_size_t)(pixel_bits))) + 7) >> 3) )\n\n/* PNG_OUT_OF_RANGE returns true if value is outside the range\n * ideal-delta..ideal+delta.  Each argument is evaluated twice.\n * \"ideal\" and \"delta\" should be constants, normally simple\n * integers, \"value\" a variable. Added to libpng-1.2.6 JB\n */\n#define PNG_OUT_OF_RANGE(value, ideal, delta) \\\n   ( (value) < (ideal)-(delta) || (value) > (ideal)+(delta) )\n\n/* Conversions between fixed and floating point, only defined if\n * required (to make sure the code doesn't accidentally use float\n * when it is supposedly disabled.)\n */\n#ifdef PNG_FLOATING_POINT_SUPPORTED\n/* The floating point conversion can't overflow, though it can and\n * does lose accuracy relative to the original fixed point value.\n * In practice this doesn't matter because png_fixed_point only\n * stores numbers with very low precision.  The png_ptr and s\n * arguments are unused by default but are there in case error\n * checking becomes a requirement.\n */\n#define png_float(png_ptr, fixed, s) (.00001 * (fixed))\n\n/* The fixed point conversion performs range checking and evaluates\n * its argument multiple times, so must be used with care.  The\n * range checking uses the PNG specification values for a signed\n * 32 bit fixed point value except that the values are deliberately\n * rounded-to-zero to an integral value - 21474 (21474.83 is roughly\n * (2^31-1) * 100000). 's' is a string that describes the value being\n * converted.\n *\n * NOTE: this macro will raise a png_error if the range check fails,\n * therefore it is normally only appropriate to use this on values\n * that come from API calls or other sources where an out of range\n * error indicates a programming error, not a data error!\n *\n * NOTE: by default this is off - the macro is not used - because the\n * function call saves a lot of code.\n */\n#ifdef PNG_FIXED_POINT_MACRO_SUPPORTED\n#define png_fixed(png_ptr, fp, s) ((fp) <= 21474 && (fp) >= -21474 ?\\\n    ((png_fixed_point)(100000 * (fp))) : (png_fixed_error(png_ptr, s),0))\n#else\nPNG_EXTERN png_fixed_point png_fixed PNGARG((png_structp png_ptr, double fp,\n   png_const_charp text));\n#endif\n#endif\n\n/* Constants for known chunk types.  If you need to add a chunk, define the name\n * here.  For historical reasons these constants have the form png_<name>; i.e.\n * the prefix is lower case.  Please use decimal values as the parameters to\n * match the ISO PNG specification and to avoid relying on the C locale\n * interpretation of character values.\n *\n * Prior to 1.5.6 these constants were strings, as of 1.5.6 png_uint_32 values\n * are computed and a new macro (PNG_STRING_FROM_CHUNK) added to allow a string\n * to be generated if required.\n *\n * PNG_32b correctly produces a value shifted by up to 24 bits, even on\n * architectures where (int) is only 16 bits.\n */\n#define PNG_32b(b,s) ((png_uint_32)(b) << (s))\n#define PNG_CHUNK(b1,b2,b3,b4) \\\n   (PNG_32b(b1,24) | PNG_32b(b2,16) | PNG_32b(b3,8) | PNG_32b(b4,0))\n\n#define png_IHDR PNG_CHUNK( 73,  72,  68,  82)\n#define png_IDAT PNG_CHUNK( 73,  68,  65,  84)\n#define png_IEND PNG_CHUNK( 73,  69,  78,  68)\n#define png_PLTE PNG_CHUNK( 80,  76,  84,  69)\n#define png_bKGD PNG_CHUNK( 98,  75,  71,  68)\n#define png_cHRM PNG_CHUNK( 99,  72,  82,  77)\n#define png_gAMA PNG_CHUNK(103,  65,  77,  65)\n#define png_hIST PNG_CHUNK(104,  73,  83,  84)\n#define png_iCCP PNG_CHUNK(105,  67,  67,  80)\n#define png_iTXt PNG_CHUNK(105,  84,  88, 116)\n#define png_oFFs PNG_CHUNK(111,  70,  70, 115)\n#define png_pCAL PNG_CHUNK(112,  67,  65,  76)\n#define png_sCAL PNG_CHUNK(115,  67,  65,  76)\n#define png_pHYs PNG_CHUNK(112,  72,  89, 115)\n#define png_sBIT PNG_CHUNK(115,  66,  73,  84)\n#define png_sPLT PNG_CHUNK(115,  80,  76,  84)\n#define png_sRGB PNG_CHUNK(115,  82,  71,  66)\n#define png_sTER PNG_CHUNK(115,  84,  69,  82)\n#define png_tEXt PNG_CHUNK(116,  69,  88, 116)\n#define png_tIME PNG_CHUNK(116,  73,  77,  69)\n#define png_tRNS PNG_CHUNK(116,  82,  78,  83)\n#define png_zTXt PNG_CHUNK(122,  84,  88, 116)\n\n/* The following will work on (signed char*) strings, whereas the get_uint_32\n * macro will fail on top-bit-set values because of the sign extension.\n */\n#define PNG_CHUNK_FROM_STRING(s)\\\n   PNG_CHUNK(0xff&(s)[0], 0xff&(s)[1], 0xff&(s)[2], 0xff&(s)[3])\n\n/* This uses (char), not (png_byte) to avoid warnings on systems where (char) is\n * signed and the argument is a (char[])  This macro will fail miserably on\n * systems where (char) is more than 8 bits.\n */\n#define PNG_STRING_FROM_CHUNK(s,c)\\\n   (void)(((char*)(s))[0]=(char)((c)>>24), ((char*)(s))[1]=(char)((c)>>16),\\\n   ((char*)(s))[2]=(char)((c)>>8), ((char*)(s))[3]=(char)((c)))\n\n/* Do the same but terminate with a null character. */\n#define PNG_CSTRING_FROM_CHUNK(s,c)\\\n   (void)(PNG_STRING_FROM_CHUNK(s,c), ((char*)(s))[4] = 0)\n\n/* Test on flag values as defined in the spec (section 5.4): */\n#define PNG_CHUNK_ANCILLIARY(c)   (1 & ((c) >> 29))\n#define PNG_CHUNK_CRITICAL(c)     (!PNG_CHUNK_ANCILLIARY(c))\n#define PNG_CHUNK_PRIVATE(c)      (1 & ((c) >> 21))\n#define PNG_CHUNK_RESERVED(c)     (1 & ((c) >> 13))\n#define PNG_CHUNK_SAFE_TO_COPY(c) (1 & ((c) >>  5))\n\n/* Gamma values (new at libpng-1.5.4): */\n#define PNG_GAMMA_MAC_OLD 151724  /* Assume '1.8' is really 2.2/1.45! */\n#define PNG_GAMMA_MAC_INVERSE 65909\n#define PNG_GAMMA_sRGB_INVERSE 45455\n\n\n/* Inhibit C++ name-mangling for libpng functions but not for system calls. */\n#ifdef __cplusplus\nextern \"C\" {\n#endif /* __cplusplus */\n\n/* These functions are used internally in the code.  They generally\n * shouldn't be used unless you are writing code to add or replace some\n * functionality in libpng.  More information about most functions can\n * be found in the files where the functions are located.\n */\n\n/* Check the user version string for compatibility, returns false if the version\n * numbers aren't compatible.\n */\nPNG_EXTERN int png_user_version_check(png_structp png_ptr,\n   png_const_charp user_png_ver);\n\n/* Allocate memory for an internal libpng struct */\nPNG_EXTERN PNG_FUNCTION(png_voidp,png_create_struct,PNGARG((int type)),\n   PNG_ALLOCATED);\n\n/* Free memory from internal libpng struct */\nPNG_EXTERN void png_destroy_struct PNGARG((png_voidp struct_ptr));\n\nPNG_EXTERN PNG_FUNCTION(png_voidp,png_create_struct_2,\n   PNGARG((int type, png_malloc_ptr malloc_fn, png_voidp mem_ptr)),\n   PNG_ALLOCATED);\nPNG_EXTERN void png_destroy_struct_2 PNGARG((png_voidp struct_ptr,\n    png_free_ptr free_fn, png_voidp mem_ptr));\n\n/* Free any memory that info_ptr points to and reset struct. */\nPNG_EXTERN void png_info_destroy PNGARG((png_structp png_ptr,\n    png_infop info_ptr));\n\n/* Function to allocate memory for zlib.  PNGAPI is disallowed. */\nPNG_EXTERN PNG_FUNCTION(voidpf,png_zalloc,PNGARG((voidpf png_ptr, uInt items,\n   uInt size)),PNG_ALLOCATED);\n\n/* Function to free memory for zlib.  PNGAPI is disallowed. */\nPNG_EXTERN void png_zfree PNGARG((voidpf png_ptr, voidpf ptr));\n\n/* Next four functions are used internally as callbacks.  PNGCBAPI is required\n * but not PNG_EXPORT.  PNGAPI added at libpng version 1.2.3, changed to\n * PNGCBAPI at 1.5.0\n */\n\nPNG_EXTERN void PNGCBAPI png_default_read_data PNGARG((png_structp png_ptr,\n    png_bytep data, png_size_t length));\n\n#ifdef PNG_PROGRESSIVE_READ_SUPPORTED\nPNG_EXTERN void PNGCBAPI png_push_fill_buffer PNGARG((png_structp png_ptr,\n    png_bytep buffer, png_size_t length));\n#endif\n\nPNG_EXTERN void PNGCBAPI png_default_write_data PNGARG((png_structp png_ptr,\n    png_bytep data, png_size_t length));\n\n#ifdef PNG_WRITE_FLUSH_SUPPORTED\n#  ifdef PNG_STDIO_SUPPORTED\nPNG_EXTERN void PNGCBAPI png_default_flush PNGARG((png_structp png_ptr));\n#  endif\n#endif\n\n/* Reset the CRC variable */\nPNG_EXTERN void png_reset_crc PNGARG((png_structp png_ptr));\n\n/* Write the \"data\" buffer to whatever output you are using */\nPNG_EXTERN void png_write_data PNGARG((png_structp png_ptr,\n    png_const_bytep data, png_size_t length));\n\n/* Read and check the PNG file signature */\nPNG_EXTERN void png_read_sig PNGARG((png_structp png_ptr, png_infop info_ptr));\n\n/* Read the chunk header (length + type name) */\nPNG_EXTERN png_uint_32 png_read_chunk_header PNGARG((png_structp png_ptr));\n\n/* Read data from whatever input you are using into the \"data\" buffer */\nPNG_EXTERN void png_read_data PNGARG((png_structp png_ptr, png_bytep data,\n    png_size_t length));\n\n/* Read bytes into buf, and update png_ptr->crc */\nPNG_EXTERN void png_crc_read PNGARG((png_structp png_ptr, png_bytep buf,\n    png_size_t length));\n\n/* Decompress data in a chunk that uses compression */\n#if defined(PNG_READ_COMPRESSED_TEXT_SUPPORTED)\nPNG_EXTERN void png_decompress_chunk PNGARG((png_structp png_ptr,\n    int comp_type, png_size_t chunklength, png_size_t prefix_length,\n    png_size_t *data_length));\n#endif\n\n/* Read \"skip\" bytes, read the file crc, and (optionally) verify png_ptr->crc */\nPNG_EXTERN int png_crc_finish PNGARG((png_structp png_ptr, png_uint_32 skip));\n\n/* Read the CRC from the file and compare it to the libpng calculated CRC */\nPNG_EXTERN int png_crc_error PNGARG((png_structp png_ptr));\n\n/* Calculate the CRC over a section of data.  Note that we are only\n * passing a maximum of 64K on systems that have this as a memory limit,\n * since this is the maximum buffer size we can specify.\n */\nPNG_EXTERN void png_calculate_crc PNGARG((png_structp png_ptr,\n    png_const_bytep ptr, png_size_t length));\n\n#ifdef PNG_WRITE_FLUSH_SUPPORTED\nPNG_EXTERN void png_flush PNGARG((png_structp png_ptr));\n#endif\n\n/* Write various chunks */\n\n/* Write the IHDR chunk, and update the png_struct with the necessary\n * information.\n */\nPNG_EXTERN void png_write_IHDR PNGARG((png_structp png_ptr, png_uint_32 width,\n    png_uint_32 height,\n    int bit_depth, int color_type, int compression_method, int filter_method,\n    int interlace_method));\n\nPNG_EXTERN void png_write_PLTE PNGARG((png_structp png_ptr,\n    png_const_colorp palette, png_uint_32 num_pal));\n\nPNG_EXTERN void png_write_IDAT PNGARG((png_structp png_ptr, png_bytep data,\n    png_size_t length));\n\nPNG_EXTERN void png_write_IEND PNGARG((png_structp png_ptr));\n\n#ifdef PNG_WRITE_gAMA_SUPPORTED\n#  ifdef PNG_FLOATING_POINT_SUPPORTED\nPNG_EXTERN void png_write_gAMA PNGARG((png_structp png_ptr, double file_gamma));\n#  endif\n#  ifdef PNG_FIXED_POINT_SUPPORTED\nPNG_EXTERN void png_write_gAMA_fixed PNGARG((png_structp png_ptr,\n    png_fixed_point file_gamma));\n#  endif\n#endif\n\n#ifdef PNG_WRITE_sBIT_SUPPORTED\nPNG_EXTERN void png_write_sBIT PNGARG((png_structp png_ptr,\n    png_const_color_8p sbit, int color_type));\n#endif\n\n#ifdef PNG_WRITE_cHRM_SUPPORTED\n#  ifdef PNG_FLOATING_POINT_SUPPORTED\nPNG_EXTERN void png_write_cHRM PNGARG((png_structp png_ptr,\n    double white_x, double white_y,\n    double red_x, double red_y, double green_x, double green_y,\n    double blue_x, double blue_y));\n#  endif\nPNG_EXTERN void png_write_cHRM_fixed PNGARG((png_structp png_ptr,\n    png_fixed_point int_white_x, png_fixed_point int_white_y,\n    png_fixed_point int_red_x, png_fixed_point int_red_y, png_fixed_point\n    int_green_x, png_fixed_point int_green_y, png_fixed_point int_blue_x,\n    png_fixed_point int_blue_y));\n#endif\n\n#ifdef PNG_WRITE_sRGB_SUPPORTED\nPNG_EXTERN void png_write_sRGB PNGARG((png_structp png_ptr,\n    int intent));\n#endif\n\n#ifdef PNG_WRITE_iCCP_SUPPORTED\nPNG_EXTERN void png_write_iCCP PNGARG((png_structp png_ptr,\n    png_const_charp name, int compression_type,\n    png_const_charp profile, int proflen));\n   /* Note to maintainer: profile should be png_bytep */\n#endif\n\n#ifdef PNG_WRITE_sPLT_SUPPORTED\nPNG_EXTERN void png_write_sPLT PNGARG((png_structp png_ptr,\n    png_const_sPLT_tp palette));\n#endif\n\n#ifdef PNG_WRITE_tRNS_SUPPORTED\nPNG_EXTERN void png_write_tRNS PNGARG((png_structp png_ptr,\n    png_const_bytep trans, png_const_color_16p values, int number,\n    int color_type));\n#endif\n\n#ifdef PNG_WRITE_bKGD_SUPPORTED\nPNG_EXTERN void png_write_bKGD PNGARG((png_structp png_ptr,\n    png_const_color_16p values, int color_type));\n#endif\n\n#ifdef PNG_WRITE_hIST_SUPPORTED\nPNG_EXTERN void png_write_hIST PNGARG((png_structp png_ptr,\n    png_const_uint_16p hist, int num_hist));\n#endif\n\n/* Chunks that have keywords */\n#if defined(PNG_WRITE_TEXT_SUPPORTED) || defined(PNG_WRITE_pCAL_SUPPORTED) || \\\n    defined(PNG_WRITE_iCCP_SUPPORTED) || defined(PNG_WRITE_sPLT_SUPPORTED)\nPNG_EXTERN png_size_t png_check_keyword PNGARG((png_structp png_ptr,\n    png_const_charp key, png_charpp new_key));\n#endif\n\n#ifdef PNG_WRITE_tEXt_SUPPORTED\nPNG_EXTERN void png_write_tEXt PNGARG((png_structp png_ptr, png_const_charp key,\n    png_const_charp text, png_size_t text_len));\n#endif\n\n#ifdef PNG_WRITE_zTXt_SUPPORTED\nPNG_EXTERN void png_write_zTXt PNGARG((png_structp png_ptr, png_const_charp key,\n    png_const_charp text, png_size_t text_len, int compression));\n#endif\n\n#ifdef PNG_WRITE_iTXt_SUPPORTED\nPNG_EXTERN void png_write_iTXt PNGARG((png_structp png_ptr,\n    int compression, png_const_charp key, png_const_charp lang,\n    png_const_charp lang_key, png_const_charp text));\n#endif\n\n#ifdef PNG_TEXT_SUPPORTED  /* Added at version 1.0.14 and 1.2.4 */\nPNG_EXTERN int png_set_text_2 PNGARG((png_structp png_ptr,\n    png_infop info_ptr, png_const_textp text_ptr, int num_text));\n#endif\n\n#ifdef PNG_WRITE_oFFs_SUPPORTED\nPNG_EXTERN void png_write_oFFs PNGARG((png_structp png_ptr,\n    png_int_32 x_offset, png_int_32 y_offset, int unit_type));\n#endif\n\n#ifdef PNG_WRITE_pCAL_SUPPORTED\nPNG_EXTERN void png_write_pCAL PNGARG((png_structp png_ptr, png_charp purpose,\n    png_int_32 X0, png_int_32 X1, int type, int nparams,\n    png_const_charp units, png_charpp params));\n#endif\n\n#ifdef PNG_WRITE_pHYs_SUPPORTED\nPNG_EXTERN void png_write_pHYs PNGARG((png_structp png_ptr,\n    png_uint_32 x_pixels_per_unit, png_uint_32 y_pixels_per_unit,\n    int unit_type));\n#endif\n\n#ifdef PNG_WRITE_tIME_SUPPORTED\nPNG_EXTERN void png_write_tIME PNGARG((png_structp png_ptr,\n    png_const_timep mod_time));\n#endif\n\n#ifdef PNG_WRITE_sCAL_SUPPORTED\nPNG_EXTERN void png_write_sCAL_s PNGARG((png_structp png_ptr,\n    int unit, png_const_charp width, png_const_charp height));\n#endif\n\n/* Called when finished processing a row of data */\nPNG_EXTERN void png_write_finish_row PNGARG((png_structp png_ptr));\n\n/* Internal use only.   Called before first row of data */\nPNG_EXTERN void png_write_start_row PNGARG((png_structp png_ptr));\n\n/* Combine a row of data, dealing with alpha, etc. if requested.  'row' is an\n * array of png_ptr->width pixels.  If the image is not interlaced or this\n * is the final pass this just does a png_memcpy, otherwise the \"display\" flag\n * is used to determine whether to copy pixels that are not in the current pass.\n *\n * Because 'png_do_read_interlace' (below) replicates pixels this allows this\n * function to achieve the documented 'blocky' appearance during interlaced read\n * if display is 1 and the 'sparkle' appearance, where existing pixels in 'row'\n * are not changed if they are not in the current pass, when display is 0.\n *\n * 'display' must be 0 or 1, otherwise the memcpy will be done regardless.\n *\n * The API always reads from the png_struct row buffer and always assumes that\n * it is full width (png_do_read_interlace has already been called.)\n *\n * This function is only ever used to write to row buffers provided by the\n * caller of the relevant libpng API and the row must have already been\n * transformed by the read transformations.\n *\n * The PNG_USE_COMPILE_TIME_MASKS option causes generation of pre-computed\n * bitmasks for use within the code, otherwise runtime generated masks are used.\n * The default is compile time masks.\n */\n#ifndef PNG_USE_COMPILE_TIME_MASKS\n#  define PNG_USE_COMPILE_TIME_MASKS 1\n#endif\nPNG_EXTERN void png_combine_row PNGARG((png_structp png_ptr, png_bytep row,\n    int display));\n\n#ifdef PNG_READ_INTERLACING_SUPPORTED\n/* Expand an interlaced row: the 'row_info' describes the pass data that has\n * been read in and must correspond to the pixels in 'row', the pixels are\n * expanded (moved apart) in 'row' to match the final layout, when doing this\n * the pixels are *replicated* to the intervening space.  This is essential for\n * the correct operation of png_combine_row, above.\n */\nPNG_EXTERN void png_do_read_interlace PNGARG((png_row_infop row_info,\n    png_bytep row, int pass, png_uint_32 transformations));\n#endif\n\n/* GRR TO DO (2.0 or whenever):  simplify other internal calling interfaces */\n\n#ifdef PNG_WRITE_INTERLACING_SUPPORTED\n/* Grab pixels out of a row for an interlaced pass */\nPNG_EXTERN void png_do_write_interlace PNGARG((png_row_infop row_info,\n    png_bytep row, int pass));\n#endif\n\n/* Unfilter a row: check the filter value before calling this, there is no point\n * calling it for PNG_FILTER_VALUE_NONE.\n */\nPNG_EXTERN void png_read_filter_row PNGARG((png_structp pp, png_row_infop row_info,\n    png_bytep row, png_const_bytep prev_row, int filter));\n\nPNG_EXTERN void png_read_filter_row_up_neon PNGARG((png_row_infop row_info,\n    png_bytep row, png_const_bytep prev_row));\nPNG_EXTERN void png_read_filter_row_sub3_neon PNGARG((png_row_infop row_info,\n    png_bytep row, png_const_bytep prev_row));\nPNG_EXTERN void png_read_filter_row_sub4_neon PNGARG((png_row_infop row_info,\n    png_bytep row, png_const_bytep prev_row));\nPNG_EXTERN void png_read_filter_row_avg3_neon PNGARG((png_row_infop row_info,\n    png_bytep row, png_const_bytep prev_row));\nPNG_EXTERN void png_read_filter_row_avg4_neon PNGARG((png_row_infop row_info,\n    png_bytep row, png_const_bytep prev_row));\nPNG_EXTERN void png_read_filter_row_paeth3_neon PNGARG((png_row_infop row_info,\n    png_bytep row, png_const_bytep prev_row));\nPNG_EXTERN void png_read_filter_row_paeth4_neon PNGARG((png_row_infop row_info,\n    png_bytep row, png_const_bytep prev_row));\n\n/* Choose the best filter to use and filter the row data */\nPNG_EXTERN void png_write_find_filter PNGARG((png_structp png_ptr,\n    png_row_infop row_info));\n\n/* Finish a row while reading, dealing with interlacing passes, etc. */\nPNG_EXTERN void png_read_finish_row PNGARG((png_structp png_ptr));\n\n/* Initialize the row buffers, etc. */\nPNG_EXTERN void png_read_start_row PNGARG((png_structp png_ptr));\n\n#ifdef PNG_READ_TRANSFORMS_SUPPORTED\n/* Optional call to update the users info structure */\nPNG_EXTERN void png_read_transform_info PNGARG((png_structp png_ptr,\n    png_infop info_ptr));\n#endif\n\n/* These are the functions that do the transformations */\n#ifdef PNG_READ_FILLER_SUPPORTED\nPNG_EXTERN void png_do_read_filler PNGARG((png_row_infop row_info,\n    png_bytep row, png_uint_32 filler, png_uint_32 flags));\n#endif\n\n#ifdef PNG_READ_SWAP_ALPHA_SUPPORTED\nPNG_EXTERN void png_do_read_swap_alpha PNGARG((png_row_infop row_info,\n    png_bytep row));\n#endif\n\n#ifdef PNG_WRITE_SWAP_ALPHA_SUPPORTED\nPNG_EXTERN void png_do_write_swap_alpha PNGARG((png_row_infop row_info,\n    png_bytep row));\n#endif\n\n#ifdef PNG_READ_INVERT_ALPHA_SUPPORTED\nPNG_EXTERN void png_do_read_invert_alpha PNGARG((png_row_infop row_info,\n    png_bytep row));\n#endif\n\n#ifdef PNG_WRITE_INVERT_ALPHA_SUPPORTED\nPNG_EXTERN void png_do_write_invert_alpha PNGARG((png_row_infop row_info,\n    png_bytep row));\n#endif\n\n#if defined(PNG_WRITE_FILLER_SUPPORTED) || \\\n    defined(PNG_READ_STRIP_ALPHA_SUPPORTED)\nPNG_EXTERN void png_do_strip_channel PNGARG((png_row_infop row_info,\n    png_bytep row, int at_start));\n#endif\n\n#ifdef PNG_16BIT_SUPPORTED\n#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED)\nPNG_EXTERN void png_do_swap PNGARG((png_row_infop row_info,\n    png_bytep row));\n#endif\n#endif\n\n#if defined(PNG_READ_PACKSWAP_SUPPORTED) || \\\n    defined(PNG_WRITE_PACKSWAP_SUPPORTED)\nPNG_EXTERN void png_do_packswap PNGARG((png_row_infop row_info,\n    png_bytep row));\n#endif\n\n#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED\nPNG_EXTERN int png_do_rgb_to_gray PNGARG((png_structp png_ptr,\n    png_row_infop row_info, png_bytep row));\n#endif\n\n#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED\nPNG_EXTERN void png_do_gray_to_rgb PNGARG((png_row_infop row_info,\n    png_bytep row));\n#endif\n\n#ifdef PNG_READ_PACK_SUPPORTED\nPNG_EXTERN void png_do_unpack PNGARG((png_row_infop row_info,\n    png_bytep row));\n#endif\n\n#ifdef PNG_READ_SHIFT_SUPPORTED\nPNG_EXTERN void png_do_unshift PNGARG((png_row_infop row_info,\n    png_bytep row, png_const_color_8p sig_bits));\n#endif\n\n#if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED)\nPNG_EXTERN void png_do_invert PNGARG((png_row_infop row_info,\n    png_bytep row));\n#endif\n\n#ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED\nPNG_EXTERN void png_do_scale_16_to_8 PNGARG((png_row_infop row_info,\n    png_bytep row));\n#endif\n\n#ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED\nPNG_EXTERN void png_do_chop PNGARG((png_row_infop row_info,\n    png_bytep row));\n#endif\n\n#ifdef PNG_READ_QUANTIZE_SUPPORTED\nPNG_EXTERN void png_do_quantize PNGARG((png_row_infop row_info,\n    png_bytep row, png_const_bytep palette_lookup,\n    png_const_bytep quantize_lookup));\n\n#  ifdef PNG_CORRECT_PALETTE_SUPPORTED\nPNG_EXTERN void png_correct_palette PNGARG((png_structp png_ptr,\n    png_colorp palette, int num_palette));\n#  endif\n#endif\n\n#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED)\nPNG_EXTERN void png_do_bgr PNGARG((png_row_infop row_info,\n    png_bytep row));\n#endif\n\n#ifdef PNG_WRITE_PACK_SUPPORTED\nPNG_EXTERN void png_do_pack PNGARG((png_row_infop row_info,\n   png_bytep row, png_uint_32 bit_depth));\n#endif\n\n#ifdef PNG_WRITE_SHIFT_SUPPORTED\nPNG_EXTERN void png_do_shift PNGARG((png_row_infop row_info,\n    png_bytep row, png_const_color_8p bit_depth));\n#endif\n\n#if defined(PNG_READ_BACKGROUND_SUPPORTED) ||\\\n    defined(PNG_READ_ALPHA_MODE_SUPPORTED)\nPNG_EXTERN void png_do_compose PNGARG((png_row_infop row_info,\n    png_bytep row, png_structp png_ptr));\n#endif\n\n#ifdef PNG_READ_GAMMA_SUPPORTED\nPNG_EXTERN void png_do_gamma PNGARG((png_row_infop row_info,\n    png_bytep row, png_structp png_ptr));\n#endif\n\n#ifdef PNG_READ_ALPHA_MODE_SUPPORTED\nPNG_EXTERN void png_do_encode_alpha PNGARG((png_row_infop row_info,\n   png_bytep row, png_structp png_ptr));\n#endif\n\n#ifdef PNG_READ_EXPAND_SUPPORTED\nPNG_EXTERN void png_do_expand_palette PNGARG((png_row_infop row_info,\n    png_bytep row, png_const_colorp palette, png_const_bytep trans,\n    int num_trans));\nPNG_EXTERN void png_do_expand PNGARG((png_row_infop row_info,\n    png_bytep row, png_const_color_16p trans_color));\n#endif\n\n#ifdef PNG_READ_EXPAND_16_SUPPORTED\nPNG_EXTERN void png_do_expand_16 PNGARG((png_row_infop row_info,\n    png_bytep row));\n#endif\n\n/* The following decodes the appropriate chunks, and does error correction,\n * then calls the appropriate callback for the chunk if it is valid.\n */\n\n/* Decode the IHDR chunk */\nPNG_EXTERN void png_handle_IHDR PNGARG((png_structp png_ptr, png_infop info_ptr,\n    png_uint_32 length));\nPNG_EXTERN void png_handle_PLTE PNGARG((png_structp png_ptr, png_infop info_ptr,\n    png_uint_32 length));\nPNG_EXTERN void png_handle_IEND PNGARG((png_structp png_ptr, png_infop info_ptr,\n    png_uint_32 length));\n\n#ifdef PNG_READ_bKGD_SUPPORTED\nPNG_EXTERN void png_handle_bKGD PNGARG((png_structp png_ptr, png_infop info_ptr,\n    png_uint_32 length));\n#endif\n\n#ifdef PNG_READ_cHRM_SUPPORTED\nPNG_EXTERN void png_handle_cHRM PNGARG((png_structp png_ptr, png_infop info_ptr,\n    png_uint_32 length));\n#endif\n\n#ifdef PNG_READ_gAMA_SUPPORTED\nPNG_EXTERN void png_handle_gAMA PNGARG((png_structp png_ptr, png_infop info_ptr,\n    png_uint_32 length));\n#endif\n\n#ifdef PNG_READ_hIST_SUPPORTED\nPNG_EXTERN void png_handle_hIST PNGARG((png_structp png_ptr, png_infop info_ptr,\n    png_uint_32 length));\n#endif\n\n#ifdef PNG_READ_iCCP_SUPPORTED\nPNG_EXTERN void png_handle_iCCP PNGARG((png_structp png_ptr, png_infop info_ptr,\n    png_uint_32 length));\n#endif /* PNG_READ_iCCP_SUPPORTED */\n\n#ifdef PNG_READ_iTXt_SUPPORTED\nPNG_EXTERN void png_handle_iTXt PNGARG((png_structp png_ptr, png_infop info_ptr,\n    png_uint_32 length));\n#endif\n\n#ifdef PNG_READ_oFFs_SUPPORTED\nPNG_EXTERN void png_handle_oFFs PNGARG((png_structp png_ptr, png_infop info_ptr,\n    png_uint_32 length));\n#endif\n\n#ifdef PNG_READ_pCAL_SUPPORTED\nPNG_EXTERN void png_handle_pCAL PNGARG((png_structp png_ptr, png_infop info_ptr,\n    png_uint_32 length));\n#endif\n\n#ifdef PNG_READ_pHYs_SUPPORTED\nPNG_EXTERN void png_handle_pHYs PNGARG((png_structp png_ptr, png_infop info_ptr,\n    png_uint_32 length));\n#endif\n\n#ifdef PNG_READ_sBIT_SUPPORTED\nPNG_EXTERN void png_handle_sBIT PNGARG((png_structp png_ptr, png_infop info_ptr,\n    png_uint_32 length));\n#endif\n\n#ifdef PNG_READ_sCAL_SUPPORTED\nPNG_EXTERN void png_handle_sCAL PNGARG((png_structp png_ptr, png_infop info_ptr,\n    png_uint_32 length));\n#endif\n\n#ifdef PNG_READ_sPLT_SUPPORTED\nPNG_EXTERN void png_handle_sPLT PNGARG((png_structp png_ptr, png_infop info_ptr,\n    png_uint_32 length));\n#endif /* PNG_READ_sPLT_SUPPORTED */\n\n#ifdef PNG_READ_sRGB_SUPPORTED\nPNG_EXTERN void png_handle_sRGB PNGARG((png_structp png_ptr, png_infop info_ptr,\n    png_uint_32 length));\n#endif\n\n#ifdef PNG_READ_tEXt_SUPPORTED\nPNG_EXTERN void png_handle_tEXt PNGARG((png_structp png_ptr, png_infop info_ptr,\n    png_uint_32 length));\n#endif\n\n#ifdef PNG_READ_tIME_SUPPORTED\nPNG_EXTERN void png_handle_tIME PNGARG((png_structp png_ptr, png_infop info_ptr,\n    png_uint_32 length));\n#endif\n\n#ifdef PNG_READ_tRNS_SUPPORTED\nPNG_EXTERN void png_handle_tRNS PNGARG((png_structp png_ptr, png_infop info_ptr,\n    png_uint_32 length));\n#endif\n\n#ifdef PNG_READ_zTXt_SUPPORTED\nPNG_EXTERN void png_handle_zTXt PNGARG((png_structp png_ptr, png_infop info_ptr,\n    png_uint_32 length));\n#endif\n\n#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED\nPNG_EXTERN void png_handle_unknown PNGARG((png_structp png_ptr,\n    png_infop info_ptr, png_uint_32 length));\n#endif\n\nPNG_EXTERN void png_check_chunk_name PNGARG((png_structp png_ptr,\n    png_uint_32 chunk_name));\n\n#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED\n/* Exactly as png_handle_as_unknown() except that the argument is a 32-bit chunk\n * name, not a string.\n */\nPNG_EXTERN int png_chunk_unknown_handling PNGARG((png_structp png_ptr,\n    png_uint_32 chunk_name));\n#endif\n\n/* Handle the transformations for reading and writing */\n#ifdef PNG_READ_TRANSFORMS_SUPPORTED\nPNG_EXTERN void png_do_read_transformations PNGARG((png_structp png_ptr,\n   png_row_infop row_info));\n#endif\n#ifdef PNG_WRITE_TRANSFORMS_SUPPORTED\nPNG_EXTERN void png_do_write_transformations PNGARG((png_structp png_ptr,\n   png_row_infop row_info));\n#endif\n\n#ifdef PNG_READ_TRANSFORMS_SUPPORTED\nPNG_EXTERN void png_init_read_transformations PNGARG((png_structp png_ptr));\n#endif\n\n#ifdef PNG_PROGRESSIVE_READ_SUPPORTED\nPNG_EXTERN void png_push_read_chunk PNGARG((png_structp png_ptr,\n    png_infop info_ptr));\nPNG_EXTERN void png_push_read_sig PNGARG((png_structp png_ptr,\n    png_infop info_ptr));\nPNG_EXTERN void png_push_check_crc PNGARG((png_structp png_ptr));\nPNG_EXTERN void png_push_crc_skip PNGARG((png_structp png_ptr,\n    png_uint_32 length));\nPNG_EXTERN void png_push_crc_finish PNGARG((png_structp png_ptr));\nPNG_EXTERN void png_push_save_buffer PNGARG((png_structp png_ptr));\nPNG_EXTERN void png_push_restore_buffer PNGARG((png_structp png_ptr,\n    png_bytep buffer, png_size_t buffer_length));\nPNG_EXTERN void png_push_read_IDAT PNGARG((png_structp png_ptr));\nPNG_EXTERN void png_process_IDAT_data PNGARG((png_structp png_ptr,\n    png_bytep buffer, png_size_t buffer_length));\nPNG_EXTERN void png_push_process_row PNGARG((png_structp png_ptr));\nPNG_EXTERN void png_push_handle_unknown PNGARG((png_structp png_ptr,\n   png_infop info_ptr, png_uint_32 length));\nPNG_EXTERN void png_push_have_info PNGARG((png_structp png_ptr,\n   png_infop info_ptr));\nPNG_EXTERN void png_push_have_end PNGARG((png_structp png_ptr,\n   png_infop info_ptr));\nPNG_EXTERN void png_push_have_row PNGARG((png_structp png_ptr, png_bytep row));\nPNG_EXTERN void png_push_read_end PNGARG((png_structp png_ptr,\n    png_infop info_ptr));\nPNG_EXTERN void png_process_some_data PNGARG((png_structp png_ptr,\n    png_infop info_ptr));\nPNG_EXTERN void png_read_push_finish_row PNGARG((png_structp png_ptr));\n#  ifdef PNG_READ_tEXt_SUPPORTED\nPNG_EXTERN void png_push_handle_tEXt PNGARG((png_structp png_ptr,\n    png_infop info_ptr, png_uint_32 length));\nPNG_EXTERN void png_push_read_tEXt PNGARG((png_structp png_ptr,\n    png_infop info_ptr));\n#  endif\n#  ifdef PNG_READ_zTXt_SUPPORTED\nPNG_EXTERN void png_push_handle_zTXt PNGARG((png_structp png_ptr,\n    png_infop info_ptr, png_uint_32 length));\nPNG_EXTERN void png_push_read_zTXt PNGARG((png_structp png_ptr,\n    png_infop info_ptr));\n#  endif\n#  ifdef PNG_READ_iTXt_SUPPORTED\nPNG_EXTERN void png_push_handle_iTXt PNGARG((png_structp png_ptr,\n    png_infop info_ptr, png_uint_32 length));\nPNG_EXTERN void png_push_read_iTXt PNGARG((png_structp png_ptr,\n    png_infop info_ptr));\n#  endif\n\n#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */\n\n#ifdef PNG_MNG_FEATURES_SUPPORTED\nPNG_EXTERN void png_do_read_intrapixel PNGARG((png_row_infop row_info,\n    png_bytep row));\nPNG_EXTERN void png_do_write_intrapixel PNGARG((png_row_infop row_info,\n    png_bytep row));\n#endif\n\n/* Added at libpng version 1.4.0 */\n#ifdef PNG_CHECK_cHRM_SUPPORTED\nPNG_EXTERN int png_check_cHRM_fixed PNGARG((png_structp png_ptr,\n    png_fixed_point int_white_x, png_fixed_point int_white_y,\n    png_fixed_point int_red_x, png_fixed_point int_red_y, png_fixed_point\n    int_green_x, png_fixed_point int_green_y, png_fixed_point int_blue_x,\n    png_fixed_point int_blue_y));\n#endif\n\n#ifdef PNG_CHECK_cHRM_SUPPORTED\n/* Added at libpng version 1.2.34 and 1.4.0 */\n/* Currently only used by png_check_cHRM_fixed */\nPNG_EXTERN void png_64bit_product PNGARG((long v1, long v2,\n    unsigned long *hi_product, unsigned long *lo_product));\n#endif\n\n#ifdef PNG_cHRM_SUPPORTED\n/* Added at libpng version 1.5.5 */\ntypedef struct png_xy\n{\n   png_fixed_point redx, redy;\n   png_fixed_point greenx, greeny;\n   png_fixed_point bluex, bluey;\n   png_fixed_point whitex, whitey;\n} png_xy;\n\ntypedef struct png_XYZ\n{\n   png_fixed_point redX, redY, redZ;\n   png_fixed_point greenX, greenY, greenZ;\n   png_fixed_point blueX, blueY, blueZ;\n} png_XYZ;\n\n/* The conversion APIs return 0 on success, non-zero on a parameter error. They\n * allow conversion between the above representations of a color encoding.  When\n * converting from XYZ end points to chromaticities the absolute magnitude of\n * the end points is lost, when converting back the sum of the Y values of the\n * three end points will be 1.0\n */\nPNG_EXTERN int png_xy_from_XYZ PNGARG((png_xy *xy, png_XYZ XYZ));\nPNG_EXTERN int png_XYZ_from_xy PNGARG((png_XYZ *XYZ, png_xy xy));\nPNG_EXTERN int png_XYZ_from_xy_checked PNGARG((png_structp png_ptr,\n   png_XYZ *XYZ, png_xy xy));\n#endif\n\n/* Added at libpng version 1.4.0 */\nPNG_EXTERN void png_check_IHDR PNGARG((png_structp png_ptr,\n    png_uint_32 width, png_uint_32 height, int bit_depth,\n    int color_type, int interlace_type, int compression_type,\n    int filter_type));\n\n/* Free all memory used by the read (old method - NOT DLL EXPORTED) */\nPNG_EXTERN void png_read_destroy PNGARG((png_structp png_ptr,\n    png_infop info_ptr, png_infop end_info_ptr));\n\n/* Free any memory used in png_ptr struct (old method - NOT DLL EXPORTED) */\nPNG_EXTERN void png_write_destroy PNGARG((png_structp png_ptr));\n\n#ifdef USE_FAR_KEYWORD  /* memory model conversion function */\nPNG_EXTERN void *png_far_to_near PNGARG((png_structp png_ptr, png_voidp ptr,\n    int check));\n#endif /* USE_FAR_KEYWORD */\n\n#if defined(PNG_FLOATING_POINT_SUPPORTED) && defined(PNG_ERROR_TEXT_SUPPORTED)\nPNG_EXTERN PNG_FUNCTION(void, png_fixed_error, (png_structp png_ptr,\n   png_const_charp name),PNG_NORETURN);\n#endif\n\n/* Puts 'string' into 'buffer' at buffer[pos], taking care never to overwrite\n * the end.  Always leaves the buffer nul terminated.  Never errors out (and\n * there is no error code.)\n */\nPNG_EXTERN size_t png_safecat(png_charp buffer, size_t bufsize, size_t pos,\n    png_const_charp string);\n\n/* Various internal functions to handle formatted warning messages, currently\n * only implemented for warnings.\n */\n#if defined(PNG_WARNINGS_SUPPORTED) || defined(PNG_TIME_RFC1123_SUPPORTED)\n/* Utility to dump an unsigned value into a buffer, given a start pointer and\n * and end pointer (which should point just *beyond* the end of the buffer!)\n * Returns the pointer to the start of the formatted string.  This utility only\n * does unsigned values.\n */\nPNG_EXTERN png_charp png_format_number(png_const_charp start, png_charp end,\n   int format, png_alloc_size_t number);\n\n/* Convenience macro that takes an array: */\n#define PNG_FORMAT_NUMBER(buffer,format,number) \\\n   png_format_number(buffer, buffer + (sizeof buffer), format, number)\n\n/* Suggested size for a number buffer (enough for 64 bits and a sign!) */\n#define PNG_NUMBER_BUFFER_SIZE 24\n\n/* These are the integer formats currently supported, the name is formed from\n * the standard printf(3) format string.\n */\n#define PNG_NUMBER_FORMAT_u     1 /* chose unsigned API! */\n#define PNG_NUMBER_FORMAT_02u   2\n#define PNG_NUMBER_FORMAT_d     1 /* chose signed API! */\n#define PNG_NUMBER_FORMAT_02d   2\n#define PNG_NUMBER_FORMAT_x     3\n#define PNG_NUMBER_FORMAT_02x   4\n#define PNG_NUMBER_FORMAT_fixed 5 /* choose the signed API */\n#endif\n\n#ifdef PNG_WARNINGS_SUPPORTED\n/* New defines and members adding in libpng-1.5.4 */\n#  define PNG_WARNING_PARAMETER_SIZE 32\n#  define PNG_WARNING_PARAMETER_COUNT 8\n\n/* An l-value of this type has to be passed to the APIs below to cache the\n * values of the parameters to a formatted warning message.\n */\ntypedef char png_warning_parameters[PNG_WARNING_PARAMETER_COUNT][\n   PNG_WARNING_PARAMETER_SIZE];\n\nPNG_EXTERN void png_warning_parameter(png_warning_parameters p, int number,\n    png_const_charp string);\n    /* Parameters are limited in size to PNG_WARNING_PARAMETER_SIZE characters,\n     * including the trailing '\\0'.\n     */\nPNG_EXTERN void png_warning_parameter_unsigned(png_warning_parameters p,\n    int number, int format, png_alloc_size_t value);\n    /* Use png_alloc_size_t because it is an unsigned type as big as any we\n     * need to output.  Use the following for a signed value.\n     */\nPNG_EXTERN void png_warning_parameter_signed(png_warning_parameters p,\n    int number, int format, png_int_32 value);\n\nPNG_EXTERN void png_formatted_warning(png_structp png_ptr,\n    png_warning_parameters p, png_const_charp message);\n    /* 'message' follows the X/Open approach of using @1, @2 to insert\n     * parameters previously supplied using the above functions.  Errors in\n     * specifying the paramters will simple result in garbage substitutions.\n     */\n#endif\n\n/* ASCII to FP interfaces, currently only implemented if sCAL\n * support is required.\n */\n#if defined(PNG_READ_sCAL_SUPPORTED)\n/* MAX_DIGITS is actually the maximum number of characters in an sCAL\n * width or height, derived from the precision (number of significant\n * digits - a build time settable option) and assumpitions about the\n * maximum ridiculous exponent.\n */\n#define PNG_sCAL_MAX_DIGITS (PNG_sCAL_PRECISION+1/*.*/+1/*E*/+10/*exponent*/)\n\n#ifdef PNG_FLOATING_POINT_SUPPORTED\nPNG_EXTERN void png_ascii_from_fp PNGARG((png_structp png_ptr, png_charp ascii,\n    png_size_t size, double fp, unsigned int precision));\n#endif /* FLOATING_POINT */\n\n#ifdef PNG_FIXED_POINT_SUPPORTED\nPNG_EXTERN void png_ascii_from_fixed PNGARG((png_structp png_ptr,\n    png_charp ascii, png_size_t size, png_fixed_point fp));\n#endif /* FIXED_POINT */\n#endif /* READ_sCAL */\n\n#if defined(PNG_sCAL_SUPPORTED) || defined(PNG_pCAL_SUPPORTED)\n/* An internal API to validate the format of a floating point number.\n * The result is the index of the next character.  If the number is\n * not valid it will be the index of a character in the supposed number.\n *\n * The format of a number is defined in the PNG extensions specification\n * and this API is strictly conformant to that spec, not anyone elses!\n *\n * The format as a regular expression is:\n *\n * [+-]?[0-9]+.?([Ee][+-]?[0-9]+)?\n *\n * or:\n *\n * [+-]?.[0-9]+(.[0-9]+)?([Ee][+-]?[0-9]+)?\n *\n * The complexity is that either integer or fraction must be present and the\n * fraction is permitted to have no digits only if the integer is present.\n *\n * NOTE: The dangling E problem.\n *   There is a PNG valid floating point number in the following:\n *\n *       PNG floating point numb1.ers are not greedy.\n *\n *   Working this out requires *TWO* character lookahead (because of the\n *   sign), the parser does not do this - it will fail at the 'r' - this\n *   doesn't matter for PNG sCAL chunk values, but it requires more care\n *   if the value were ever to be embedded in something more complex.  Use\n *   ANSI-C strtod if you need the lookahead.\n */\n/* State table for the parser. */\n#define PNG_FP_INTEGER    0  /* before or in integer */\n#define PNG_FP_FRACTION   1  /* before or in fraction */\n#define PNG_FP_EXPONENT   2  /* before or in exponent */\n#define PNG_FP_STATE      3  /* mask for the above */\n#define PNG_FP_SAW_SIGN   4  /* Saw +/- in current state */\n#define PNG_FP_SAW_DIGIT  8  /* Saw a digit in current state */\n#define PNG_FP_SAW_DOT   16  /* Saw a dot in current state */\n#define PNG_FP_SAW_E     32  /* Saw an E (or e) in current state */\n#define PNG_FP_SAW_ANY   60  /* Saw any of the above 4 */\n\n/* These three values don't affect the parser.  They are set but not used.\n */\n#define PNG_FP_WAS_VALID 64  /* Preceding substring is a valid fp number */\n#define PNG_FP_NEGATIVE 128  /* A negative number, including \"-0\" */\n#define PNG_FP_NONZERO  256  /* A non-zero value */\n#define PNG_FP_STICKY   448  /* The above three flags */\n\n/* This is available for the caller to store in 'state' if required.  Do not\n * call the parser after setting it (the parser sometimes clears it.)\n */\n#define PNG_FP_INVALID  512  /* Available for callers as a distinct value */\n\n/* Result codes for the parser (boolean - true meants ok, false means\n * not ok yet.)\n */\n#define PNG_FP_MAYBE      0  /* The number may be valid in the future */\n#define PNG_FP_OK         1  /* The number is valid */\n\n/* Tests on the sticky non-zero and negative flags.  To pass these checks\n * the state must also indicate that the whole number is valid - this is\n * achieved by testing PNG_FP_SAW_DIGIT (see the implementation for why this\n * is equivalent to PNG_FP_OK above.)\n */\n#define PNG_FP_NZ_MASK (PNG_FP_SAW_DIGIT | PNG_FP_NEGATIVE | PNG_FP_NONZERO)\n   /* NZ_MASK: the string is valid and a non-zero negative value */\n#define PNG_FP_Z_MASK (PNG_FP_SAW_DIGIT | PNG_FP_NONZERO)\n   /* Z MASK: the string is valid and a non-zero value. */\n   /* PNG_FP_SAW_DIGIT: the string is valid. */\n#define PNG_FP_IS_ZERO(state) (((state) & PNG_FP_Z_MASK) == PNG_FP_SAW_DIGIT)\n#define PNG_FP_IS_POSITIVE(state) (((state) & PNG_FP_NZ_MASK) == PNG_FP_Z_MASK)\n#define PNG_FP_IS_NEGATIVE(state) (((state) & PNG_FP_NZ_MASK) == PNG_FP_NZ_MASK)\n \n/* The actual parser.  This can be called repeatedly, it updates\n * the index into the string and the state variable (which must\n * be initialzed to 0).  It returns a result code, as above.  There\n * is no point calling the parser any more if it fails to advance to\n * the end of the string - it is stuck on an invalid character (or\n * terminated by '\\0').\n *\n * Note that the pointer will consume an E or even an E+ then leave\n * a 'maybe' state even though a preceding integer.fraction is valid.\n * The PNG_FP_WAS_VALID flag indicates that a preceding substring was\n * a valid number.  It's possible to recover from this by calling\n * the parser again (from the start, with state 0) but with a string\n * that omits the last character (i.e. set the size to the index of\n * the problem character.)  This has not been tested within libpng.\n */\nPNG_EXTERN int png_check_fp_number PNGARG((png_const_charp string,\n    png_size_t size, int *statep, png_size_tp whereami));\n\n/* This is the same but it checks a complete string and returns true\n * only if it just contains a floating point number.  As of 1.5.4 this\n * function also returns the state at the end of parsing the number if\n * it was valid (otherwise it returns 0.)  This can be used for testing\n * for negative or zero values using the sticky flag.\n */\nPNG_EXTERN int png_check_fp_string PNGARG((png_const_charp string,\n    png_size_t size));\n#endif /* pCAL || sCAL */\n\n#if defined(PNG_READ_GAMMA_SUPPORTED) ||\\\n    defined(PNG_INCH_CONVERSIONS_SUPPORTED) || defined(PNG_READ_pHYs_SUPPORTED)\n/* Added at libpng version 1.5.0 */\n/* This is a utility to provide a*times/div (rounded) and indicate\n * if there is an overflow.  The result is a boolean - false (0)\n * for overflow, true (1) if no overflow, in which case *res\n * holds the result.\n */\nPNG_EXTERN int png_muldiv PNGARG((png_fixed_point_p res, png_fixed_point a,\n    png_int_32 multiplied_by, png_int_32 divided_by));\n#endif\n\n#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_INCH_CONVERSIONS_SUPPORTED)\n/* Same deal, but issue a warning on overflow and return 0. */\nPNG_EXTERN png_fixed_point png_muldiv_warn PNGARG((png_structp png_ptr,\n    png_fixed_point a, png_int_32 multiplied_by, png_int_32 divided_by));\n#endif\n\n#ifdef PNG_READ_GAMMA_SUPPORTED\n/* Calculate a reciprocal - used for gamma values.  This returns\n * 0 if the argument is 0 in order to maintain an undefined value,\n * there are no warnings.\n */\nPNG_EXTERN png_fixed_point png_reciprocal PNGARG((png_fixed_point a));\n\n/* The same but gives a reciprocal of the product of two fixed point\n * values.  Accuracy is suitable for gamma calculations but this is\n * not exact - use png_muldiv for that.\n */\nPNG_EXTERN png_fixed_point png_reciprocal2 PNGARG((png_fixed_point a,\n    png_fixed_point b));\n#endif\n\n#ifdef PNG_READ_GAMMA_SUPPORTED\n/* Internal fixed point gamma correction.  These APIs are called as\n * required to convert single values - they don't need to be fast,\n * they are not used when processing image pixel values.\n *\n * While the input is an 'unsigned' value it must actually be the\n * correct bit value - 0..255 or 0..65535 as required.\n */\nPNG_EXTERN png_uint_16 png_gamma_correct PNGARG((png_structp png_ptr,\n    unsigned int value, png_fixed_point gamma_value));\nPNG_EXTERN int png_gamma_significant PNGARG((png_fixed_point gamma_value));\nPNG_EXTERN png_uint_16 png_gamma_16bit_correct PNGARG((unsigned int value,\n    png_fixed_point gamma_value));\nPNG_EXTERN png_byte png_gamma_8bit_correct PNGARG((unsigned int value,\n    png_fixed_point gamma_value));\nPNG_EXTERN void png_destroy_gamma_table(png_structp png_ptr);\nPNG_EXTERN void png_build_gamma_table PNGARG((png_structp png_ptr,\n    int bit_depth));\n#endif\n\n/* Maintainer: Put new private prototypes here ^ and in libpngpf.3 */\n\n#include \"pngdebug.h\"\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* PNGPRIV_H */\n"
  },
  {
    "path": "Projects/Tools/PNGAlphaPremultiplier/Native/Source/LibPng/pngread.c",
    "content": "\n/* pngread.c - read a PNG file\n *\n * Last changed in libpng 1.5.7 [December 15, 2011]\n * Copyright (c) 1998-2011 Glenn Randers-Pehrson\n * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)\n * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)\n *\n * This code is released under the libpng license.\n * For conditions of distribution and use, see the disclaimer\n * and license in png.h\n *\n * This file contains routines that an application calls directly to\n * read a PNG file or stream.\n */\n\n#include \"pngpriv.h\"\n\n#ifdef PNG_READ_SUPPORTED\n\n/* Create a PNG structure for reading, and allocate any memory needed. */\nPNG_FUNCTION(png_structp,PNGAPI\npng_create_read_struct,(png_const_charp user_png_ver, png_voidp error_ptr,\n    png_error_ptr error_fn, png_error_ptr warn_fn),PNG_ALLOCATED)\n{\n\n#ifdef PNG_USER_MEM_SUPPORTED\n   return (png_create_read_struct_2(user_png_ver, error_ptr, error_fn,\n       warn_fn, NULL, NULL, NULL));\n}\n\n/* Alternate create PNG structure for reading, and allocate any memory\n * needed.\n */\nPNG_FUNCTION(png_structp,PNGAPI\npng_create_read_struct_2,(png_const_charp user_png_ver, png_voidp error_ptr,\n    png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr,\n    png_malloc_ptr malloc_fn, png_free_ptr free_fn),PNG_ALLOCATED)\n{\n#endif /* PNG_USER_MEM_SUPPORTED */\n\n#ifdef PNG_SETJMP_SUPPORTED\n   volatile\n#endif\n   png_structp png_ptr;\n   volatile int png_cleanup_needed = 0;\n\n#ifdef PNG_SETJMP_SUPPORTED\n#ifdef USE_FAR_KEYWORD\n   jmp_buf tmp_jmpbuf;\n#endif\n#endif\n\n   png_debug(1, \"in png_create_read_struct\");\n\n#ifdef PNG_USER_MEM_SUPPORTED\n   png_ptr = (png_structp)png_create_struct_2(PNG_STRUCT_PNG,\n       malloc_fn, mem_ptr);\n#else\n   png_ptr = (png_structp)png_create_struct(PNG_STRUCT_PNG);\n#endif\n   if (png_ptr == NULL)\n      return (NULL);\n\n   /* Added at libpng-1.2.6 */\n#ifdef PNG_USER_LIMITS_SUPPORTED\n   png_ptr->user_width_max = PNG_USER_WIDTH_MAX;\n   png_ptr->user_height_max = PNG_USER_HEIGHT_MAX;\n\n#  ifdef PNG_USER_CHUNK_CACHE_MAX\n   /* Added at libpng-1.2.43 and 1.4.0 */\n   png_ptr->user_chunk_cache_max = PNG_USER_CHUNK_CACHE_MAX;\n#  endif\n\n#  ifdef PNG_SET_USER_CHUNK_MALLOC_MAX\n   /* Added at libpng-1.2.43 and 1.4.1 */\n   png_ptr->user_chunk_malloc_max = PNG_USER_CHUNK_MALLOC_MAX;\n#  endif\n#endif\n\n#ifdef PNG_SETJMP_SUPPORTED\n/* Applications that neglect to set up their own setjmp() and then\n * encounter a png_error() will longjmp here.  Since the jmpbuf is\n * then meaningless we abort instead of returning.\n */\n#ifdef USE_FAR_KEYWORD\n   if (setjmp(tmp_jmpbuf))\n#else\n   if (setjmp(png_jmpbuf(png_ptr))) /* Sets longjmp to match setjmp */\n#endif\n      PNG_ABORT();\n#ifdef USE_FAR_KEYWORD\n   png_memcpy(png_jmpbuf(png_ptr), tmp_jmpbuf, png_sizeof(jmp_buf));\n#endif\n#endif /* PNG_SETJMP_SUPPORTED */\n\n#ifdef PNG_USER_MEM_SUPPORTED\n   png_set_mem_fn(png_ptr, mem_ptr, malloc_fn, free_fn);\n#endif\n\n   png_set_error_fn(png_ptr, error_ptr, error_fn, warn_fn);\n\n   /* Call the general version checker (shared with read and write code): */\n   if (!png_user_version_check(png_ptr, user_png_ver))\n      png_cleanup_needed = 1;\n\n   if (!png_cleanup_needed)\n   {\n   /* Initialize zbuf - compression buffer */\n   png_ptr->zbuf_size = PNG_ZBUF_SIZE;\n   png_ptr->zbuf = (png_bytep)png_malloc_warn(png_ptr, png_ptr->zbuf_size);\n\n   if (png_ptr->zbuf == NULL)\n      png_cleanup_needed = 1;\n   }\n\n   png_ptr->zstream.zalloc = png_zalloc;\n   png_ptr->zstream.zfree = png_zfree;\n   png_ptr->zstream.opaque = (voidpf)png_ptr;\n\n   if (!png_cleanup_needed)\n   {\n      switch (inflateInit(&png_ptr->zstream))\n      {\n         case Z_OK:\n            break; /* Do nothing */\n\n         case Z_MEM_ERROR:\n            png_warning(png_ptr, \"zlib memory error\");\n            png_cleanup_needed = 1;\n            break;\n\n         case Z_STREAM_ERROR:\n            png_warning(png_ptr, \"zlib stream error\");\n            png_cleanup_needed = 1;\n            break;\n\n         case Z_VERSION_ERROR:\n            png_warning(png_ptr, \"zlib version error\");\n            png_cleanup_needed = 1;\n            break;\n\n         default: png_warning(png_ptr, \"Unknown zlib error\");\n            png_cleanup_needed = 1;\n      }\n   }\n\n   if (png_cleanup_needed)\n   {\n      /* Clean up PNG structure and deallocate any memory. */\n      png_free(png_ptr, png_ptr->zbuf);\n      png_ptr->zbuf = NULL;\n#ifdef PNG_USER_MEM_SUPPORTED\n      png_destroy_struct_2((png_voidp)png_ptr,\n          (png_free_ptr)free_fn, (png_voidp)mem_ptr);\n#else\n      png_destroy_struct((png_voidp)png_ptr);\n#endif\n      return (NULL);\n   }\n\n   png_ptr->zstream.next_out = png_ptr->zbuf;\n   png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size;\n\n   png_set_read_fn(png_ptr, NULL, NULL);\n\n\n   return (png_ptr);\n}\n\n\n#ifdef PNG_SEQUENTIAL_READ_SUPPORTED\n/* Read the information before the actual image data.  This has been\n * changed in v0.90 to allow reading a file that already has the magic\n * bytes read from the stream.  You can tell libpng how many bytes have\n * been read from the beginning of the stream (up to the maximum of 8)\n * via png_set_sig_bytes(), and we will only check the remaining bytes\n * here.  The application can then have access to the signature bytes we\n * read if it is determined that this isn't a valid PNG file.\n */\nvoid PNGAPI\npng_read_info(png_structp png_ptr, png_infop info_ptr)\n{\n   png_debug(1, \"in png_read_info\");\n\n   if (png_ptr == NULL || info_ptr == NULL)\n      return;\n\n   /* Read and check the PNG file signature. */\n   png_read_sig(png_ptr, info_ptr);\n\n   for (;;)\n   {\n      png_uint_32 length = png_read_chunk_header(png_ptr);\n      png_uint_32 chunk_name = png_ptr->chunk_name;\n\n      /* This should be a binary subdivision search or a hash for\n       * matching the chunk name rather than a linear search.\n       */\n      if (chunk_name == png_IDAT)\n         if (png_ptr->mode & PNG_AFTER_IDAT)\n            png_ptr->mode |= PNG_HAVE_CHUNK_AFTER_IDAT;\n\n      if (chunk_name == png_IHDR)\n         png_handle_IHDR(png_ptr, info_ptr, length);\n\n      else if (chunk_name == png_IEND)\n         png_handle_IEND(png_ptr, info_ptr, length);\n\n#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED\n      else if (png_chunk_unknown_handling(png_ptr, chunk_name) !=\n         PNG_HANDLE_CHUNK_AS_DEFAULT)\n      {\n         if (chunk_name == png_IDAT)\n            png_ptr->mode |= PNG_HAVE_IDAT;\n\n         png_handle_unknown(png_ptr, info_ptr, length);\n\n         if (chunk_name == png_PLTE)\n            png_ptr->mode |= PNG_HAVE_PLTE;\n\n         else if (chunk_name == png_IDAT)\n         {\n            if (!(png_ptr->mode & PNG_HAVE_IHDR))\n               png_error(png_ptr, \"Missing IHDR before IDAT\");\n\n            else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE &&\n                !(png_ptr->mode & PNG_HAVE_PLTE))\n               png_error(png_ptr, \"Missing PLTE before IDAT\");\n\n            break;\n         }\n      }\n#endif\n      else if (chunk_name == png_PLTE)\n         png_handle_PLTE(png_ptr, info_ptr, length);\n\n      else if (chunk_name == png_IDAT)\n      {\n         if (!(png_ptr->mode & PNG_HAVE_IHDR))\n            png_error(png_ptr, \"Missing IHDR before IDAT\");\n\n         else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE &&\n             !(png_ptr->mode & PNG_HAVE_PLTE))\n            png_error(png_ptr, \"Missing PLTE before IDAT\");\n\n         png_ptr->idat_size = length;\n         png_ptr->mode |= PNG_HAVE_IDAT;\n         break;\n      }\n\n#ifdef PNG_READ_bKGD_SUPPORTED\n      else if (chunk_name == png_bKGD)\n         png_handle_bKGD(png_ptr, info_ptr, length);\n#endif\n\n#ifdef PNG_READ_cHRM_SUPPORTED\n      else if (chunk_name == png_cHRM)\n         png_handle_cHRM(png_ptr, info_ptr, length);\n#endif\n\n#ifdef PNG_READ_gAMA_SUPPORTED\n      else if (chunk_name == png_gAMA)\n         png_handle_gAMA(png_ptr, info_ptr, length);\n#endif\n\n#ifdef PNG_READ_hIST_SUPPORTED\n      else if (chunk_name == png_hIST)\n         png_handle_hIST(png_ptr, info_ptr, length);\n#endif\n\n#ifdef PNG_READ_oFFs_SUPPORTED\n      else if (chunk_name == png_oFFs)\n         png_handle_oFFs(png_ptr, info_ptr, length);\n#endif\n\n#ifdef PNG_READ_pCAL_SUPPORTED\n      else if (chunk_name == png_pCAL)\n         png_handle_pCAL(png_ptr, info_ptr, length);\n#endif\n\n#ifdef PNG_READ_sCAL_SUPPORTED\n      else if (chunk_name == png_sCAL)\n         png_handle_sCAL(png_ptr, info_ptr, length);\n#endif\n\n#ifdef PNG_READ_pHYs_SUPPORTED\n      else if (chunk_name == png_pHYs)\n         png_handle_pHYs(png_ptr, info_ptr, length);\n#endif\n\n#ifdef PNG_READ_sBIT_SUPPORTED\n      else if (chunk_name == png_sBIT)\n         png_handle_sBIT(png_ptr, info_ptr, length);\n#endif\n\n#ifdef PNG_READ_sRGB_SUPPORTED\n      else if (chunk_name == png_sRGB)\n         png_handle_sRGB(png_ptr, info_ptr, length);\n#endif\n\n#ifdef PNG_READ_iCCP_SUPPORTED\n      else if (chunk_name == png_iCCP)\n         png_handle_iCCP(png_ptr, info_ptr, length);\n#endif\n\n#ifdef PNG_READ_sPLT_SUPPORTED\n      else if (chunk_name == png_sPLT)\n         png_handle_sPLT(png_ptr, info_ptr, length);\n#endif\n\n#ifdef PNG_READ_tEXt_SUPPORTED\n      else if (chunk_name == png_tEXt)\n         png_handle_tEXt(png_ptr, info_ptr, length);\n#endif\n\n#ifdef PNG_READ_tIME_SUPPORTED\n      else if (chunk_name == png_tIME)\n         png_handle_tIME(png_ptr, info_ptr, length);\n#endif\n\n#ifdef PNG_READ_tRNS_SUPPORTED\n      else if (chunk_name == png_tRNS)\n         png_handle_tRNS(png_ptr, info_ptr, length);\n#endif\n\n#ifdef PNG_READ_zTXt_SUPPORTED\n      else if (chunk_name == png_zTXt)\n         png_handle_zTXt(png_ptr, info_ptr, length);\n#endif\n\n#ifdef PNG_READ_iTXt_SUPPORTED\n      else if (chunk_name == png_iTXt)\n         png_handle_iTXt(png_ptr, info_ptr, length);\n#endif\n\n      else\n         png_handle_unknown(png_ptr, info_ptr, length);\n   }\n}\n#endif /* PNG_SEQUENTIAL_READ_SUPPORTED */\n\n/* Optional call to update the users info_ptr structure */\nvoid PNGAPI\npng_read_update_info(png_structp png_ptr, png_infop info_ptr)\n{\n   png_debug(1, \"in png_read_update_info\");\n\n   if (png_ptr == NULL)\n      return;\n\n   png_read_start_row(png_ptr);\n\n#ifdef PNG_READ_TRANSFORMS_SUPPORTED\n   png_read_transform_info(png_ptr, info_ptr);\n#else\n   PNG_UNUSED(info_ptr)\n#endif\n}\n\n#ifdef PNG_SEQUENTIAL_READ_SUPPORTED\n/* Initialize palette, background, etc, after transformations\n * are set, but before any reading takes place.  This allows\n * the user to obtain a gamma-corrected palette, for example.\n * If the user doesn't call this, we will do it ourselves.\n */\nvoid PNGAPI\npng_start_read_image(png_structp png_ptr)\n{\n   png_debug(1, \"in png_start_read_image\");\n\n   if (png_ptr != NULL)\n     png_read_start_row(png_ptr);\n}\n#endif /* PNG_SEQUENTIAL_READ_SUPPORTED */\n\n#ifdef PNG_SEQUENTIAL_READ_SUPPORTED\nvoid PNGAPI\npng_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)\n{\n   int ret;\n\n   png_row_info row_info;\n\n   if (png_ptr == NULL)\n      return;\n\n   png_debug2(1, \"in png_read_row (row %lu, pass %d)\",\n       (unsigned long)png_ptr->row_number, png_ptr->pass);\n\n   /* png_read_start_row sets the information (in particular iwidth) for this\n    * interlace pass.\n    */\n   if (!(png_ptr->flags & PNG_FLAG_ROW_INIT))\n      png_read_start_row(png_ptr);\n\n   /* 1.5.6: row_info moved out of png_struct to a local here. */\n   row_info.width = png_ptr->iwidth; /* NOTE: width of current interlaced row */\n   row_info.color_type = png_ptr->color_type;\n   row_info.bit_depth = png_ptr->bit_depth;\n   row_info.channels = png_ptr->channels;\n   row_info.pixel_depth = png_ptr->pixel_depth;\n   row_info.rowbytes = PNG_ROWBYTES(row_info.pixel_depth, row_info.width);\n\n   if (png_ptr->row_number == 0 && png_ptr->pass == 0)\n   {\n   /* Check for transforms that have been set but were defined out */\n#if defined(PNG_WRITE_INVERT_SUPPORTED) && !defined(PNG_READ_INVERT_SUPPORTED)\n   if (png_ptr->transformations & PNG_INVERT_MONO)\n      png_warning(png_ptr, \"PNG_READ_INVERT_SUPPORTED is not defined\");\n#endif\n\n#if defined(PNG_WRITE_FILLER_SUPPORTED) && !defined(PNG_READ_FILLER_SUPPORTED)\n   if (png_ptr->transformations & PNG_FILLER)\n      png_warning(png_ptr, \"PNG_READ_FILLER_SUPPORTED is not defined\");\n#endif\n\n#if defined(PNG_WRITE_PACKSWAP_SUPPORTED) && \\\n    !defined(PNG_READ_PACKSWAP_SUPPORTED)\n   if (png_ptr->transformations & PNG_PACKSWAP)\n      png_warning(png_ptr, \"PNG_READ_PACKSWAP_SUPPORTED is not defined\");\n#endif\n\n#if defined(PNG_WRITE_PACK_SUPPORTED) && !defined(PNG_READ_PACK_SUPPORTED)\n   if (png_ptr->transformations & PNG_PACK)\n      png_warning(png_ptr, \"PNG_READ_PACK_SUPPORTED is not defined\");\n#endif\n\n#if defined(PNG_WRITE_SHIFT_SUPPORTED) && !defined(PNG_READ_SHIFT_SUPPORTED)\n   if (png_ptr->transformations & PNG_SHIFT)\n      png_warning(png_ptr, \"PNG_READ_SHIFT_SUPPORTED is not defined\");\n#endif\n\n#if defined(PNG_WRITE_BGR_SUPPORTED) && !defined(PNG_READ_BGR_SUPPORTED)\n   if (png_ptr->transformations & PNG_BGR)\n      png_warning(png_ptr, \"PNG_READ_BGR_SUPPORTED is not defined\");\n#endif\n\n#if defined(PNG_WRITE_SWAP_SUPPORTED) && !defined(PNG_READ_SWAP_SUPPORTED)\n   if (png_ptr->transformations & PNG_SWAP_BYTES)\n      png_warning(png_ptr, \"PNG_READ_SWAP_SUPPORTED is not defined\");\n#endif\n   }\n\n#ifdef PNG_READ_INTERLACING_SUPPORTED\n   /* If interlaced and we do not need a new row, combine row and return.\n    * Notice that the pixels we have from previous rows have been transformed\n    * already; we can only combine like with like (transformed or\n    * untransformed) and, because of the libpng API for interlaced images, this\n    * means we must transform before de-interlacing.\n    */\n   if (png_ptr->interlaced && (png_ptr->transformations & PNG_INTERLACE))\n   {\n      switch (png_ptr->pass)\n      {\n         case 0:\n            if (png_ptr->row_number & 0x07)\n            {\n               if (dsp_row != NULL)\n                  png_combine_row(png_ptr, dsp_row, 1/*display*/);\n               png_read_finish_row(png_ptr);\n               return;\n            }\n            break;\n\n         case 1:\n            if ((png_ptr->row_number & 0x07) || png_ptr->width < 5)\n            {\n               if (dsp_row != NULL)\n                  png_combine_row(png_ptr, dsp_row, 1/*display*/);\n\n               png_read_finish_row(png_ptr);\n               return;\n            }\n            break;\n\n         case 2:\n            if ((png_ptr->row_number & 0x07) != 4)\n            {\n               if (dsp_row != NULL && (png_ptr->row_number & 4))\n                  png_combine_row(png_ptr, dsp_row, 1/*display*/);\n\n               png_read_finish_row(png_ptr);\n               return;\n            }\n            break;\n\n         case 3:\n            if ((png_ptr->row_number & 3) || png_ptr->width < 3)\n            {\n               if (dsp_row != NULL)\n                  png_combine_row(png_ptr, dsp_row, 1/*display*/);\n\n               png_read_finish_row(png_ptr);\n               return;\n            }\n            break;\n\n         case 4:\n            if ((png_ptr->row_number & 3) != 2)\n            {\n               if (dsp_row != NULL && (png_ptr->row_number & 2))\n                  png_combine_row(png_ptr, dsp_row, 1/*display*/);\n\n               png_read_finish_row(png_ptr);\n               return;\n            }\n            break;\n         case 5:\n            if ((png_ptr->row_number & 1) || png_ptr->width < 2)\n            {\n               if (dsp_row != NULL)\n                  png_combine_row(png_ptr, dsp_row, 1/*display*/);\n\n               png_read_finish_row(png_ptr);\n               return;\n            }\n            break;\n\n         default:\n         case 6:\n            if (!(png_ptr->row_number & 1))\n            {\n               png_read_finish_row(png_ptr);\n               return;\n            }\n            break;\n      }\n   }\n#endif\n\n   if (!(png_ptr->mode & PNG_HAVE_IDAT))\n      png_error(png_ptr, \"Invalid attempt to read row data\");\n\n   png_ptr->zstream.next_out = png_ptr->row_buf;\n   png_ptr->zstream.avail_out =\n       (uInt)(PNG_ROWBYTES(png_ptr->pixel_depth,\n       png_ptr->iwidth) + 1);\n\n   do\n   {\n      if (!(png_ptr->zstream.avail_in))\n      {\n         while (!png_ptr->idat_size)\n         {\n            png_crc_finish(png_ptr, 0);\n\n            png_ptr->idat_size = png_read_chunk_header(png_ptr);\n            if (png_ptr->chunk_name != png_IDAT)\n               png_error(png_ptr, \"Not enough image data\");\n         }\n         png_ptr->zstream.avail_in = (uInt)png_ptr->zbuf_size;\n         png_ptr->zstream.next_in = png_ptr->zbuf;\n         if (png_ptr->zbuf_size > png_ptr->idat_size)\n            png_ptr->zstream.avail_in = (uInt)png_ptr->idat_size;\n         png_crc_read(png_ptr, png_ptr->zbuf,\n             (png_size_t)png_ptr->zstream.avail_in);\n         png_ptr->idat_size -= png_ptr->zstream.avail_in;\n      }\n\n      ret = inflate(&png_ptr->zstream, Z_PARTIAL_FLUSH);\n\n      if (ret == Z_STREAM_END)\n      {\n         if (png_ptr->zstream.avail_out || png_ptr->zstream.avail_in ||\n            png_ptr->idat_size)\n            png_benign_error(png_ptr, \"Extra compressed data\");\n         png_ptr->mode |= PNG_AFTER_IDAT;\n         png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED;\n         break;\n      }\n\n      if (ret != Z_OK)\n         png_error(png_ptr, png_ptr->zstream.msg ? png_ptr->zstream.msg :\n             \"Decompression error\");\n\n   } while (png_ptr->zstream.avail_out);\n\n   if (png_ptr->row_buf[0] > PNG_FILTER_VALUE_NONE)\n   {\n      if (png_ptr->row_buf[0] < PNG_FILTER_VALUE_LAST)\n         png_read_filter_row(png_ptr, &row_info, png_ptr->row_buf + 1,\n            png_ptr->prev_row + 1, png_ptr->row_buf[0]);\n      else\n         png_error(png_ptr, \"bad adaptive filter value\");\n   }\n\n   /* libpng 1.5.6: the following line was copying png_ptr->rowbytes before\n    * 1.5.6, while the buffer really is this big in current versions of libpng\n    * it may not be in the future, so this was changed just to copy the\n    * interlaced count:\n    */\n   png_memcpy(png_ptr->prev_row, png_ptr->row_buf, row_info.rowbytes + 1);\n\n#ifdef PNG_MNG_FEATURES_SUPPORTED\n   if ((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) &&\n       (png_ptr->filter_type == PNG_INTRAPIXEL_DIFFERENCING))\n   {\n      /* Intrapixel differencing */\n      png_do_read_intrapixel(&row_info, png_ptr->row_buf + 1);\n   }\n#endif\n\n\n#ifdef PNG_READ_TRANSFORMS_SUPPORTED\n   if (png_ptr->transformations)\n      png_do_read_transformations(png_ptr, &row_info);\n#endif\n\n   /* The transformed pixel depth should match the depth now in row_info. */\n   if (png_ptr->transformed_pixel_depth == 0)\n   {\n      png_ptr->transformed_pixel_depth = row_info.pixel_depth;\n      if (row_info.pixel_depth > png_ptr->maximum_pixel_depth)\n         png_error(png_ptr, \"sequential row overflow\");\n   }\n\n   else if (png_ptr->transformed_pixel_depth != row_info.pixel_depth)\n      png_error(png_ptr, \"internal sequential row size calculation error\");\n\n#ifdef PNG_READ_INTERLACING_SUPPORTED\n   /* Blow up interlaced rows to full size */\n   if (png_ptr->interlaced &&\n      (png_ptr->transformations & PNG_INTERLACE))\n   {\n      if (png_ptr->pass < 6)\n         png_do_read_interlace(&row_info, png_ptr->row_buf + 1, png_ptr->pass,\n            png_ptr->transformations);\n\n      if (dsp_row != NULL)\n         png_combine_row(png_ptr, dsp_row, 1/*display*/);\n\n      if (row != NULL)\n         png_combine_row(png_ptr, row, 0/*row*/);\n   }\n\n   else\n#endif\n   {\n      if (row != NULL)\n         png_combine_row(png_ptr, row, -1/*ignored*/);\n\n      if (dsp_row != NULL)\n         png_combine_row(png_ptr, dsp_row, -1/*ignored*/);\n   }\n   png_read_finish_row(png_ptr);\n\n   if (png_ptr->read_row_fn != NULL)\n      (*(png_ptr->read_row_fn))(png_ptr, png_ptr->row_number, png_ptr->pass);\n}\n#endif /* PNG_SEQUENTIAL_READ_SUPPORTED */\n\n#ifdef PNG_SEQUENTIAL_READ_SUPPORTED\n/* Read one or more rows of image data.  If the image is interlaced,\n * and png_set_interlace_handling() has been called, the rows need to\n * contain the contents of the rows from the previous pass.  If the\n * image has alpha or transparency, and png_handle_alpha()[*] has been\n * called, the rows contents must be initialized to the contents of the\n * screen.\n *\n * \"row\" holds the actual image, and pixels are placed in it\n * as they arrive.  If the image is displayed after each pass, it will\n * appear to \"sparkle\" in.  \"display_row\" can be used to display a\n * \"chunky\" progressive image, with finer detail added as it becomes\n * available.  If you do not want this \"chunky\" display, you may pass\n * NULL for display_row.  If you do not want the sparkle display, and\n * you have not called png_handle_alpha(), you may pass NULL for rows.\n * If you have called png_handle_alpha(), and the image has either an\n * alpha channel or a transparency chunk, you must provide a buffer for\n * rows.  In this case, you do not have to provide a display_row buffer\n * also, but you may.  If the image is not interlaced, or if you have\n * not called png_set_interlace_handling(), the display_row buffer will\n * be ignored, so pass NULL to it.\n *\n * [*] png_handle_alpha() does not exist yet, as of this version of libpng\n */\n\nvoid PNGAPI\npng_read_rows(png_structp png_ptr, png_bytepp row,\n    png_bytepp display_row, png_uint_32 num_rows)\n{\n   png_uint_32 i;\n   png_bytepp rp;\n   png_bytepp dp;\n\n   png_debug(1, \"in png_read_rows\");\n\n   if (png_ptr == NULL)\n      return;\n\n   rp = row;\n   dp = display_row;\n   if (rp != NULL && dp != NULL)\n      for (i = 0; i < num_rows; i++)\n      {\n         png_bytep rptr = *rp++;\n         png_bytep dptr = *dp++;\n\n         png_read_row(png_ptr, rptr, dptr);\n      }\n\n   else if (rp != NULL)\n      for (i = 0; i < num_rows; i++)\n      {\n         png_bytep rptr = *rp;\n         png_read_row(png_ptr, rptr, NULL);\n         rp++;\n      }\n\n   else if (dp != NULL)\n      for (i = 0; i < num_rows; i++)\n      {\n         png_bytep dptr = *dp;\n         png_read_row(png_ptr, NULL, dptr);\n         dp++;\n      }\n}\n#endif /* PNG_SEQUENTIAL_READ_SUPPORTED */\n\n#ifdef PNG_SEQUENTIAL_READ_SUPPORTED\n/* Read the entire image.  If the image has an alpha channel or a tRNS\n * chunk, and you have called png_handle_alpha()[*], you will need to\n * initialize the image to the current image that PNG will be overlaying.\n * We set the num_rows again here, in case it was incorrectly set in\n * png_read_start_row() by a call to png_read_update_info() or\n * png_start_read_image() if png_set_interlace_handling() wasn't called\n * prior to either of these functions like it should have been.  You can\n * only call this function once.  If you desire to have an image for\n * each pass of a interlaced image, use png_read_rows() instead.\n *\n * [*] png_handle_alpha() does not exist yet, as of this version of libpng\n */\nvoid PNGAPI\npng_read_image(png_structp png_ptr, png_bytepp image)\n{\n   png_uint_32 i, image_height;\n   int pass, j;\n   png_bytepp rp;\n\n   png_debug(1, \"in png_read_image\");\n\n   if (png_ptr == NULL)\n      return;\n\n#ifdef PNG_READ_INTERLACING_SUPPORTED\n   if (!(png_ptr->flags & PNG_FLAG_ROW_INIT))\n   {\n      pass = png_set_interlace_handling(png_ptr);\n      /* And make sure transforms are initialized. */\n      png_start_read_image(png_ptr);\n   }\n   else\n   {\n      if (png_ptr->interlaced && !(png_ptr->transformations & PNG_INTERLACE))\n      {\n         /* Caller called png_start_read_image or png_read_update_info without\n          * first turning on the PNG_INTERLACE transform.  We can fix this here,\n          * but the caller should do it!\n          */\n         png_warning(png_ptr, \"Interlace handling should be turned on when \"\n            \"using png_read_image\");\n         /* Make sure this is set correctly */\n         png_ptr->num_rows = png_ptr->height;\n      }\n\n      /* Obtain the pass number, which also turns on the PNG_INTERLACE flag in\n       * the above error case.\n       */\n      pass = png_set_interlace_handling(png_ptr);\n   }\n#else\n   if (png_ptr->interlaced)\n      png_error(png_ptr,\n          \"Cannot read interlaced image -- interlace handler disabled\");\n\n   pass = 1;\n#endif\n\n   image_height=png_ptr->height;\n\n   for (j = 0; j < pass; j++)\n   {\n      rp = image;\n      for (i = 0; i < image_height; i++)\n      {\n         png_read_row(png_ptr, *rp, NULL);\n         rp++;\n      }\n   }\n}\n#endif /* PNG_SEQUENTIAL_READ_SUPPORTED */\n\n#ifdef PNG_SEQUENTIAL_READ_SUPPORTED\n/* Read the end of the PNG file.  Will not read past the end of the\n * file, will verify the end is accurate, and will read any comments\n * or time information at the end of the file, if info is not NULL.\n */\nvoid PNGAPI\npng_read_end(png_structp png_ptr, png_infop info_ptr)\n{\n   png_debug(1, \"in png_read_end\");\n\n   if (png_ptr == NULL)\n      return;\n\n   png_crc_finish(png_ptr, 0); /* Finish off CRC from last IDAT chunk */\n\n   do\n   {\n      png_uint_32 length = png_read_chunk_header(png_ptr);\n      png_uint_32 chunk_name = png_ptr->chunk_name;\n\n      if (chunk_name == png_IHDR)\n         png_handle_IHDR(png_ptr, info_ptr, length);\n\n      else if (chunk_name == png_IEND)\n         png_handle_IEND(png_ptr, info_ptr, length);\n\n#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED\n      else if (png_chunk_unknown_handling(png_ptr, chunk_name) !=\n         PNG_HANDLE_CHUNK_AS_DEFAULT)\n      {\n         if (chunk_name == png_IDAT)\n         {\n            if ((length > 0) || (png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT))\n               png_benign_error(png_ptr, \"Too many IDATs found\");\n         }\n         png_handle_unknown(png_ptr, info_ptr, length);\n         if (chunk_name == png_PLTE)\n            png_ptr->mode |= PNG_HAVE_PLTE;\n      }\n#endif\n\n      else if (chunk_name == png_IDAT)\n      {\n         /* Zero length IDATs are legal after the last IDAT has been\n          * read, but not after other chunks have been read.\n          */\n         if ((length > 0) || (png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT))\n            png_benign_error(png_ptr, \"Too many IDATs found\");\n\n         png_crc_finish(png_ptr, length);\n      }\n      else if (chunk_name == png_PLTE)\n         png_handle_PLTE(png_ptr, info_ptr, length);\n\n#ifdef PNG_READ_bKGD_SUPPORTED\n      else if (chunk_name == png_bKGD)\n         png_handle_bKGD(png_ptr, info_ptr, length);\n#endif\n\n#ifdef PNG_READ_cHRM_SUPPORTED\n      else if (chunk_name == png_cHRM)\n         png_handle_cHRM(png_ptr, info_ptr, length);\n#endif\n\n#ifdef PNG_READ_gAMA_SUPPORTED\n      else if (chunk_name == png_gAMA)\n         png_handle_gAMA(png_ptr, info_ptr, length);\n#endif\n\n#ifdef PNG_READ_hIST_SUPPORTED\n      else if (chunk_name == png_hIST)\n         png_handle_hIST(png_ptr, info_ptr, length);\n#endif\n\n#ifdef PNG_READ_oFFs_SUPPORTED\n      else if (chunk_name == png_oFFs)\n         png_handle_oFFs(png_ptr, info_ptr, length);\n#endif\n\n#ifdef PNG_READ_pCAL_SUPPORTED\n      else if (chunk_name == png_pCAL)\n         png_handle_pCAL(png_ptr, info_ptr, length);\n#endif\n\n#ifdef PNG_READ_sCAL_SUPPORTED\n      else if (chunk_name == png_sCAL)\n         png_handle_sCAL(png_ptr, info_ptr, length);\n#endif\n\n#ifdef PNG_READ_pHYs_SUPPORTED\n      else if (chunk_name == png_pHYs)\n         png_handle_pHYs(png_ptr, info_ptr, length);\n#endif\n\n#ifdef PNG_READ_sBIT_SUPPORTED\n      else if (chunk_name == png_sBIT)\n         png_handle_sBIT(png_ptr, info_ptr, length);\n#endif\n\n#ifdef PNG_READ_sRGB_SUPPORTED\n      else if (chunk_name == png_sRGB)\n         png_handle_sRGB(png_ptr, info_ptr, length);\n#endif\n\n#ifdef PNG_READ_iCCP_SUPPORTED\n      else if (chunk_name == png_iCCP)\n         png_handle_iCCP(png_ptr, info_ptr, length);\n#endif\n\n#ifdef PNG_READ_sPLT_SUPPORTED\n      else if (chunk_name == png_sPLT)\n         png_handle_sPLT(png_ptr, info_ptr, length);\n#endif\n\n#ifdef PNG_READ_tEXt_SUPPORTED\n      else if (chunk_name == png_tEXt)\n         png_handle_tEXt(png_ptr, info_ptr, length);\n#endif\n\n#ifdef PNG_READ_tIME_SUPPORTED\n      else if (chunk_name == png_tIME)\n         png_handle_tIME(png_ptr, info_ptr, length);\n#endif\n\n#ifdef PNG_READ_tRNS_SUPPORTED\n      else if (chunk_name == png_tRNS)\n         png_handle_tRNS(png_ptr, info_ptr, length);\n#endif\n\n#ifdef PNG_READ_zTXt_SUPPORTED\n      else if (chunk_name == png_zTXt)\n         png_handle_zTXt(png_ptr, info_ptr, length);\n#endif\n\n#ifdef PNG_READ_iTXt_SUPPORTED\n      else if (chunk_name == png_iTXt)\n         png_handle_iTXt(png_ptr, info_ptr, length);\n#endif\n\n      else\n         png_handle_unknown(png_ptr, info_ptr, length);\n   } while (!(png_ptr->mode & PNG_HAVE_IEND));\n}\n#endif /* PNG_SEQUENTIAL_READ_SUPPORTED */\n\n/* Free all memory used by the read */\nvoid PNGAPI\npng_destroy_read_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr,\n    png_infopp end_info_ptr_ptr)\n{\n   png_structp png_ptr = NULL;\n   png_infop info_ptr = NULL, end_info_ptr = NULL;\n#ifdef PNG_USER_MEM_SUPPORTED\n   png_free_ptr free_fn = NULL;\n   png_voidp mem_ptr = NULL;\n#endif\n\n   png_debug(1, \"in png_destroy_read_struct\");\n\n   if (png_ptr_ptr != NULL)\n      png_ptr = *png_ptr_ptr;\n   if (png_ptr == NULL)\n      return;\n\n#ifdef PNG_USER_MEM_SUPPORTED\n   free_fn = png_ptr->free_fn;\n   mem_ptr = png_ptr->mem_ptr;\n#endif\n\n   if (info_ptr_ptr != NULL)\n      info_ptr = *info_ptr_ptr;\n\n   if (end_info_ptr_ptr != NULL)\n      end_info_ptr = *end_info_ptr_ptr;\n\n   png_read_destroy(png_ptr, info_ptr, end_info_ptr);\n\n   if (info_ptr != NULL)\n   {\n#ifdef PNG_TEXT_SUPPORTED\n      png_free_data(png_ptr, info_ptr, PNG_FREE_TEXT, -1);\n#endif\n\n#ifdef PNG_USER_MEM_SUPPORTED\n      png_destroy_struct_2((png_voidp)info_ptr, (png_free_ptr)free_fn,\n          (png_voidp)mem_ptr);\n#else\n      png_destroy_struct((png_voidp)info_ptr);\n#endif\n      *info_ptr_ptr = NULL;\n   }\n\n   if (end_info_ptr != NULL)\n   {\n#ifdef PNG_READ_TEXT_SUPPORTED\n      png_free_data(png_ptr, end_info_ptr, PNG_FREE_TEXT, -1);\n#endif\n#ifdef PNG_USER_MEM_SUPPORTED\n      png_destroy_struct_2((png_voidp)end_info_ptr, (png_free_ptr)free_fn,\n          (png_voidp)mem_ptr);\n#else\n      png_destroy_struct((png_voidp)end_info_ptr);\n#endif\n      *end_info_ptr_ptr = NULL;\n   }\n\n   if (png_ptr != NULL)\n   {\n#ifdef PNG_USER_MEM_SUPPORTED\n      png_destroy_struct_2((png_voidp)png_ptr, (png_free_ptr)free_fn,\n          (png_voidp)mem_ptr);\n#else\n      png_destroy_struct((png_voidp)png_ptr);\n#endif\n      *png_ptr_ptr = NULL;\n   }\n}\n\n/* Free all memory used by the read (old method) */\nvoid /* PRIVATE */\npng_read_destroy(png_structp png_ptr, png_infop info_ptr,\n    png_infop end_info_ptr)\n{\n#ifdef PNG_SETJMP_SUPPORTED\n   jmp_buf tmp_jmp;\n#endif\n   png_error_ptr error_fn;\n#ifdef PNG_WARNINGS_SUPPORTED\n   png_error_ptr warning_fn;\n#endif\n   png_voidp error_ptr;\n#ifdef PNG_USER_MEM_SUPPORTED\n   png_free_ptr free_fn;\n#endif\n\n   png_debug(1, \"in png_read_destroy\");\n\n   if (info_ptr != NULL)\n      png_info_destroy(png_ptr, info_ptr);\n\n   if (end_info_ptr != NULL)\n      png_info_destroy(png_ptr, end_info_ptr);\n\n#ifdef PNG_READ_GAMMA_SUPPORTED\n   png_destroy_gamma_table(png_ptr);\n#endif\n\n   png_free(png_ptr, png_ptr->zbuf);\n   png_free(png_ptr, png_ptr->big_row_buf);\n   png_free(png_ptr, png_ptr->big_prev_row);\n   png_free(png_ptr, png_ptr->chunkdata);\n\n#ifdef PNG_READ_QUANTIZE_SUPPORTED\n   png_free(png_ptr, png_ptr->palette_lookup);\n   png_free(png_ptr, png_ptr->quantize_index);\n#endif\n\n   if (png_ptr->free_me & PNG_FREE_PLTE)\n      png_zfree(png_ptr, png_ptr->palette);\n   png_ptr->free_me &= ~PNG_FREE_PLTE;\n\n#if defined(PNG_tRNS_SUPPORTED) || \\\n    defined(PNG_READ_EXPAND_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)\n   if (png_ptr->free_me & PNG_FREE_TRNS)\n      png_free(png_ptr, png_ptr->trans_alpha);\n   png_ptr->free_me &= ~PNG_FREE_TRNS;\n#endif\n\n#ifdef PNG_READ_hIST_SUPPORTED\n   if (png_ptr->free_me & PNG_FREE_HIST)\n      png_free(png_ptr, png_ptr->hist);\n   png_ptr->free_me &= ~PNG_FREE_HIST;\n#endif\n\n   inflateEnd(&png_ptr->zstream);\n\n#ifdef PNG_PROGRESSIVE_READ_SUPPORTED\n   png_free(png_ptr, png_ptr->save_buffer);\n#endif\n\n#ifdef PNG_PROGRESSIVE_READ_SUPPORTED\n#ifdef PNG_TEXT_SUPPORTED\n   png_free(png_ptr, png_ptr->current_text);\n#endif /* PNG_TEXT_SUPPORTED */\n#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */\n\n   /* Save the important info out of the png_struct, in case it is\n    * being used again.\n    */\n#ifdef PNG_SETJMP_SUPPORTED\n   png_memcpy(tmp_jmp, png_ptr->longjmp_buffer, png_sizeof(jmp_buf));\n#endif\n\n   error_fn = png_ptr->error_fn;\n#ifdef PNG_WARNINGS_SUPPORTED\n   warning_fn = png_ptr->warning_fn;\n#endif\n   error_ptr = png_ptr->error_ptr;\n#ifdef PNG_USER_MEM_SUPPORTED\n   free_fn = png_ptr->free_fn;\n#endif\n\n   png_memset(png_ptr, 0, png_sizeof(png_struct));\n\n   png_ptr->error_fn = error_fn;\n#ifdef PNG_WARNINGS_SUPPORTED\n   png_ptr->warning_fn = warning_fn;\n#endif\n   png_ptr->error_ptr = error_ptr;\n#ifdef PNG_USER_MEM_SUPPORTED\n   png_ptr->free_fn = free_fn;\n#endif\n\n#ifdef PNG_SETJMP_SUPPORTED\n   png_memcpy(png_ptr->longjmp_buffer, tmp_jmp, png_sizeof(jmp_buf));\n#endif\n\n}\n\nvoid PNGAPI\npng_set_read_status_fn(png_structp png_ptr, png_read_status_ptr read_row_fn)\n{\n   if (png_ptr == NULL)\n      return;\n\n   png_ptr->read_row_fn = read_row_fn;\n}\n\n\n#ifdef PNG_SEQUENTIAL_READ_SUPPORTED\n#ifdef PNG_INFO_IMAGE_SUPPORTED\nvoid PNGAPI\npng_read_png(png_structp png_ptr, png_infop info_ptr,\n                           int transforms,\n                           voidp params)\n{\n   int row;\n\n   if (png_ptr == NULL || info_ptr == NULL)\n      return;\n\n   /* png_read_info() gives us all of the information from the\n    * PNG file before the first IDAT (image data chunk).\n    */\n   png_read_info(png_ptr, info_ptr);\n   if (info_ptr->height > PNG_UINT_32_MAX/png_sizeof(png_bytep))\n      png_error(png_ptr, \"Image is too high to process with png_read_png()\");\n\n   /* -------------- image transformations start here ------------------- */\n\n#ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED\n   /* Tell libpng to strip 16-bit/color files down to 8 bits per color.\n    */\n   if (transforms & PNG_TRANSFORM_SCALE_16)\n   {\n     /* Added at libpng-1.5.4. \"strip_16\" produces the same result that it\n      * did in earlier versions, while \"scale_16\" is now more accurate.\n      */\n      png_set_scale_16(png_ptr);\n   }\n#endif\n\n#ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED\n   /* If both SCALE and STRIP are required pngrtran will effectively cancel the\n    * latter by doing SCALE first.  This is ok and allows apps not to check for\n    * which is supported to get the right answer.\n    */\n   if (transforms & PNG_TRANSFORM_STRIP_16)\n      png_set_strip_16(png_ptr);\n#endif\n\n#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED\n   /* Strip alpha bytes from the input data without combining with\n    * the background (not recommended).\n    */\n   if (transforms & PNG_TRANSFORM_STRIP_ALPHA)\n      png_set_strip_alpha(png_ptr);\n#endif\n\n#if defined(PNG_READ_PACK_SUPPORTED) && !defined(PNG_READ_EXPAND_SUPPORTED)\n   /* Extract multiple pixels with bit depths of 1, 2, or 4 from a single\n    * byte into separate bytes (useful for paletted and grayscale images).\n    */\n   if (transforms & PNG_TRANSFORM_PACKING)\n      png_set_packing(png_ptr);\n#endif\n\n#ifdef PNG_READ_PACKSWAP_SUPPORTED\n   /* Change the order of packed pixels to least significant bit first\n    * (not useful if you are using png_set_packing).\n    */\n   if (transforms & PNG_TRANSFORM_PACKSWAP)\n      png_set_packswap(png_ptr);\n#endif\n\n#ifdef PNG_READ_EXPAND_SUPPORTED\n   /* Expand paletted colors into true RGB triplets\n    * Expand grayscale images to full 8 bits from 1, 2, or 4 bits/pixel\n    * Expand paletted or RGB images with transparency to full alpha\n    * channels so the data will be available as RGBA quartets.\n    */\n   if (transforms & PNG_TRANSFORM_EXPAND)\n      if ((png_ptr->bit_depth < 8) ||\n          (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) ||\n          (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)))\n         png_set_expand(png_ptr);\n#endif\n\n   /* We don't handle background color or gamma transformation or quantizing.\n    */\n\n#ifdef PNG_READ_INVERT_SUPPORTED\n   /* Invert monochrome files to have 0 as white and 1 as black\n    */\n   if (transforms & PNG_TRANSFORM_INVERT_MONO)\n      png_set_invert_mono(png_ptr);\n#endif\n\n#ifdef PNG_READ_SHIFT_SUPPORTED\n   /* If you want to shift the pixel values from the range [0,255] or\n    * [0,65535] to the original [0,7] or [0,31], or whatever range the\n    * colors were originally in:\n    */\n   if ((transforms & PNG_TRANSFORM_SHIFT)\n       && png_get_valid(png_ptr, info_ptr, PNG_INFO_sBIT))\n   {\n      png_color_8p sig_bit;\n\n      png_get_sBIT(png_ptr, info_ptr, &sig_bit);\n      png_set_shift(png_ptr, sig_bit);\n   }\n#endif\n\n#ifdef PNG_READ_BGR_SUPPORTED\n   /* Flip the RGB pixels to BGR (or RGBA to BGRA) */\n   if (transforms & PNG_TRANSFORM_BGR)\n      png_set_bgr(png_ptr);\n#endif\n\n#ifdef PNG_READ_SWAP_ALPHA_SUPPORTED\n   /* Swap the RGBA or GA data to ARGB or AG (or BGRA to ABGR) */\n   if (transforms & PNG_TRANSFORM_SWAP_ALPHA)\n      png_set_swap_alpha(png_ptr);\n#endif\n\n#ifdef PNG_READ_SWAP_SUPPORTED\n   /* Swap bytes of 16-bit files to least significant byte first */\n   if (transforms & PNG_TRANSFORM_SWAP_ENDIAN)\n      png_set_swap(png_ptr);\n#endif\n\n/* Added at libpng-1.2.41 */\n#ifdef PNG_READ_INVERT_ALPHA_SUPPORTED\n   /* Invert the alpha channel from opacity to transparency */\n   if (transforms & PNG_TRANSFORM_INVERT_ALPHA)\n      png_set_invert_alpha(png_ptr);\n#endif\n\n/* Added at libpng-1.2.41 */\n#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED\n   /* Expand grayscale image to RGB */\n   if (transforms & PNG_TRANSFORM_GRAY_TO_RGB)\n      png_set_gray_to_rgb(png_ptr);\n#endif\n\n/* Added at libpng-1.5.4 */\n#ifdef PNG_READ_EXPAND_16_SUPPORTED\n   if (transforms & PNG_TRANSFORM_EXPAND_16)\n      png_set_expand_16(png_ptr);\n#endif\n\n   /* We don't handle adding filler bytes */\n\n   /* We use png_read_image and rely on that for interlace handling, but we also\n    * call png_read_update_info therefore must turn on interlace handling now:\n    */\n   (void)png_set_interlace_handling(png_ptr);\n\n   /* Optional call to gamma correct and add the background to the palette\n    * and update info structure.  REQUIRED if you are expecting libpng to\n    * update the palette for you (i.e., you selected such a transform above).\n    */\n   png_read_update_info(png_ptr, info_ptr);\n\n   /* -------------- image transformations end here ------------------- */\n\n   png_free_data(png_ptr, info_ptr, PNG_FREE_ROWS, 0);\n   if (info_ptr->row_pointers == NULL)\n   {\n      png_uint_32 iptr;\n\n      info_ptr->row_pointers = (png_bytepp)png_malloc(png_ptr,\n          info_ptr->height * png_sizeof(png_bytep));\n      for (iptr=0; iptr<info_ptr->height; iptr++)\n         info_ptr->row_pointers[iptr] = NULL;\n\n      info_ptr->free_me |= PNG_FREE_ROWS;\n\n      for (row = 0; row < (int)info_ptr->height; row++)\n         info_ptr->row_pointers[row] = (png_bytep)png_malloc(png_ptr,\n            png_get_rowbytes(png_ptr, info_ptr));\n   }\n\n   png_read_image(png_ptr, info_ptr->row_pointers);\n   info_ptr->valid |= PNG_INFO_IDAT;\n\n   /* Read rest of file, and get additional chunks in info_ptr - REQUIRED */\n   png_read_end(png_ptr, info_ptr);\n\n   PNG_UNUSED(transforms)   /* Quiet compiler warnings */\n   PNG_UNUSED(params)\n\n}\n#endif /* PNG_INFO_IMAGE_SUPPORTED */\n#endif /* PNG_SEQUENTIAL_READ_SUPPORTED */\n#endif /* PNG_READ_SUPPORTED */\n"
  },
  {
    "path": "Projects/Tools/PNGAlphaPremultiplier/Native/Source/LibPng/pngrio.c",
    "content": "\n/* pngrio.c - functions for data input\n *\n * Last changed in libpng 1.5.0 [January 6, 2011]\n * Copyright (c) 1998-2011 Glenn Randers-Pehrson\n * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)\n * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)\n *\n * This code is released under the libpng license.\n * For conditions of distribution and use, see the disclaimer\n * and license in png.h\n *\n * This file provides a location for all input.  Users who need\n * special handling are expected to write a function that has the same\n * arguments as this and performs a similar function, but that possibly\n * has a different input method.  Note that you shouldn't change this\n * function, but rather write a replacement function and then make\n * libpng use it at run time with png_set_read_fn(...).\n */\n\n#include \"pngpriv.h\"\n\n#ifdef PNG_READ_SUPPORTED\n\n/* Read the data from whatever input you are using.  The default routine\n * reads from a file pointer.  Note that this routine sometimes gets called\n * with very small lengths, so you should implement some kind of simple\n * buffering if you are using unbuffered reads.  This should never be asked\n * to read more then 64K on a 16 bit machine.\n */\nvoid /* PRIVATE */\npng_read_data(png_structp png_ptr, png_bytep data, png_size_t length)\n{\n   png_debug1(4, \"reading %d bytes\", (int)length);\n\n   if (png_ptr->read_data_fn != NULL)\n      (*(png_ptr->read_data_fn))(png_ptr, data, length);\n\n   else\n      png_error(png_ptr, \"Call to NULL read function\");\n}\n\n#ifdef PNG_STDIO_SUPPORTED\n/* This is the function that does the actual reading of data.  If you are\n * not reading from a standard C stream, you should create a replacement\n * read_data function and use it at run time with png_set_read_fn(), rather\n * than changing the library.\n */\n#  ifndef USE_FAR_KEYWORD\nvoid PNGCBAPI\npng_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)\n{\n   png_size_t check;\n\n   if (png_ptr == NULL)\n      return;\n\n   /* fread() returns 0 on error, so it is OK to store this in a png_size_t\n    * instead of an int, which is what fread() actually returns.\n    */\n   check = fread(data, 1, length, (png_FILE_p)png_ptr->io_ptr);\n\n   if (check != length)\n      png_error(png_ptr, \"Read Error\");\n}\n#  else\n/* This is the model-independent version. Since the standard I/O library\n   can't handle far buffers in the medium and small models, we have to copy\n   the data.\n*/\n\n#define NEAR_BUF_SIZE 1024\n#define MIN(a,b) (a <= b ? a : b)\n\nstatic void PNGCBAPI\npng_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)\n{\n   png_size_t check;\n   png_byte *n_data;\n   png_FILE_p io_ptr;\n\n   if (png_ptr == NULL)\n      return;\n\n   /* Check if data really is near. If so, use usual code. */\n   n_data = (png_byte *)CVT_PTR_NOCHECK(data);\n   io_ptr = (png_FILE_p)CVT_PTR(png_ptr->io_ptr);\n\n   if ((png_bytep)n_data == data)\n   {\n      check = fread(n_data, 1, length, io_ptr);\n   }\n\n   else\n   {\n      png_byte buf[NEAR_BUF_SIZE];\n      png_size_t read, remaining, err;\n      check = 0;\n      remaining = length;\n\n      do\n      {\n         read = MIN(NEAR_BUF_SIZE, remaining);\n         err = fread(buf, 1, read, io_ptr);\n         png_memcpy(data, buf, read); /* copy far buffer to near buffer */\n\n         if (err != read)\n            break;\n\n         else\n            check += err;\n\n         data += read;\n         remaining -= read;\n      }\n      while (remaining != 0);\n   }\n\n   if ((png_uint_32)check != (png_uint_32)length)\n      png_error(png_ptr, \"read Error\");\n}\n#  endif\n#endif\n\n/* This function allows the application to supply a new input function\n * for libpng if standard C streams aren't being used.\n *\n * This function takes as its arguments:\n *\n * png_ptr      - pointer to a png input data structure\n *\n * io_ptr       - pointer to user supplied structure containing info about\n *                the input functions.  May be NULL.\n *\n * read_data_fn - pointer to a new input function that takes as its\n *                arguments a pointer to a png_struct, a pointer to\n *                a location where input data can be stored, and a 32-bit\n *                unsigned int that is the number of bytes to be read.\n *                To exit and output any fatal error messages the new write\n *                function should call png_error(png_ptr, \"Error msg\").\n *                May be NULL, in which case libpng's default function will\n *                be used.\n */\nvoid PNGAPI\npng_set_read_fn(png_structp png_ptr, png_voidp io_ptr,\n   png_rw_ptr read_data_fn)\n{\n   if (png_ptr == NULL)\n      return;\n\n   png_ptr->io_ptr = io_ptr;\n\n#ifdef PNG_STDIO_SUPPORTED\n   if (read_data_fn != NULL)\n      png_ptr->read_data_fn = read_data_fn;\n\n   else\n      png_ptr->read_data_fn = png_default_read_data;\n#else\n   png_ptr->read_data_fn = read_data_fn;\n#endif\n\n   /* It is an error to write to a read device */\n   if (png_ptr->write_data_fn != NULL)\n   {\n      png_ptr->write_data_fn = NULL;\n      png_warning(png_ptr,\n          \"Can't set both read_data_fn and write_data_fn in the\"\n          \" same structure\");\n   }\n\n#ifdef PNG_WRITE_FLUSH_SUPPORTED\n   png_ptr->output_flush_fn = NULL;\n#endif\n}\n#endif /* PNG_READ_SUPPORTED */\n"
  },
  {
    "path": "Projects/Tools/PNGAlphaPremultiplier/Native/Source/LibPng/pngrtran.c",
    "content": "\n/* pngrtran.c - transforms the data in a row for PNG readers\n *\n * Last changed in libpng 1.5.7 [December 15, 2011]\n * Copyright (c) 1998-2011 Glenn Randers-Pehrson\n * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)\n * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)\n *\n * This code is released under the libpng license.\n * For conditions of distribution and use, see the disclaimer\n * and license in png.h\n *\n * This file contains functions optionally called by an application\n * in order to tell libpng how to handle data when reading a PNG.\n * Transformations that are used in both reading and writing are\n * in pngtrans.c.\n */\n\n#include \"pngpriv.h\"\n\n#ifdef PNG_READ_SUPPORTED\n\n/* Set the action on getting a CRC error for an ancillary or critical chunk. */\nvoid PNGAPI\npng_set_crc_action(png_structp png_ptr, int crit_action, int ancil_action)\n{\n   png_debug(1, \"in png_set_crc_action\");\n\n   if (png_ptr == NULL)\n      return;\n\n   /* Tell libpng how we react to CRC errors in critical chunks */\n   switch (crit_action)\n   {\n      case PNG_CRC_NO_CHANGE:                        /* Leave setting as is */\n         break;\n\n      case PNG_CRC_WARN_USE:                               /* Warn/use data */\n         png_ptr->flags &= ~PNG_FLAG_CRC_CRITICAL_MASK;\n         png_ptr->flags |= PNG_FLAG_CRC_CRITICAL_USE;\n         break;\n\n      case PNG_CRC_QUIET_USE:                             /* Quiet/use data */\n         png_ptr->flags &= ~PNG_FLAG_CRC_CRITICAL_MASK;\n         png_ptr->flags |= PNG_FLAG_CRC_CRITICAL_USE |\n                           PNG_FLAG_CRC_CRITICAL_IGNORE;\n         break;\n\n      case PNG_CRC_WARN_DISCARD:    /* Not a valid action for critical data */\n         png_warning(png_ptr,\n            \"Can't discard critical data on CRC error\");\n      case PNG_CRC_ERROR_QUIT:                                /* Error/quit */\n\n      case PNG_CRC_DEFAULT:\n      default:\n         png_ptr->flags &= ~PNG_FLAG_CRC_CRITICAL_MASK;\n         break;\n   }\n\n   /* Tell libpng how we react to CRC errors in ancillary chunks */\n   switch (ancil_action)\n   {\n      case PNG_CRC_NO_CHANGE:                       /* Leave setting as is */\n         break;\n\n      case PNG_CRC_WARN_USE:                              /* Warn/use data */\n         png_ptr->flags &= ~PNG_FLAG_CRC_ANCILLARY_MASK;\n         png_ptr->flags |= PNG_FLAG_CRC_ANCILLARY_USE;\n         break;\n\n      case PNG_CRC_QUIET_USE:                            /* Quiet/use data */\n         png_ptr->flags &= ~PNG_FLAG_CRC_ANCILLARY_MASK;\n         png_ptr->flags |= PNG_FLAG_CRC_ANCILLARY_USE |\n                           PNG_FLAG_CRC_ANCILLARY_NOWARN;\n         break;\n\n      case PNG_CRC_ERROR_QUIT:                               /* Error/quit */\n         png_ptr->flags &= ~PNG_FLAG_CRC_ANCILLARY_MASK;\n         png_ptr->flags |= PNG_FLAG_CRC_ANCILLARY_NOWARN;\n         break;\n\n      case PNG_CRC_WARN_DISCARD:                      /* Warn/discard data */\n\n      case PNG_CRC_DEFAULT:\n      default:\n         png_ptr->flags &= ~PNG_FLAG_CRC_ANCILLARY_MASK;\n         break;\n   }\n}\n\n#ifdef PNG_READ_BACKGROUND_SUPPORTED\n/* Handle alpha and tRNS via a background color */\nvoid PNGFAPI\npng_set_background_fixed(png_structp png_ptr,\n    png_const_color_16p background_color, int background_gamma_code,\n    int need_expand, png_fixed_point background_gamma)\n{\n   png_debug(1, \"in png_set_background_fixed\");\n\n   if (png_ptr == NULL)\n      return;\n\n   if (background_gamma_code == PNG_BACKGROUND_GAMMA_UNKNOWN)\n   {\n      png_warning(png_ptr, \"Application must supply a known background gamma\");\n      return;\n   }\n\n   png_ptr->transformations |= PNG_COMPOSE | PNG_STRIP_ALPHA;\n   png_ptr->transformations &= ~PNG_ENCODE_ALPHA;\n   png_ptr->flags &= ~PNG_FLAG_OPTIMIZE_ALPHA;\n\n   png_memcpy(&(png_ptr->background), background_color,\n      png_sizeof(png_color_16));\n   png_ptr->background_gamma = background_gamma;\n   png_ptr->background_gamma_type = (png_byte)(background_gamma_code);\n   if (need_expand)\n      png_ptr->transformations |= PNG_BACKGROUND_EXPAND;\n   else\n      png_ptr->transformations &= ~PNG_BACKGROUND_EXPAND;\n}\n\n#  ifdef PNG_FLOATING_POINT_SUPPORTED\nvoid PNGAPI\npng_set_background(png_structp png_ptr,\n    png_const_color_16p background_color, int background_gamma_code,\n    int need_expand, double background_gamma)\n{\n   png_set_background_fixed(png_ptr, background_color, background_gamma_code,\n      need_expand, png_fixed(png_ptr, background_gamma, \"png_set_background\"));\n}\n#  endif  /* FLOATING_POINT */\n#endif /* READ_BACKGROUND */\n\n/* Scale 16-bit depth files to 8-bit depth.  If both of these are set then the\n * one that pngrtran does first (scale) happens.  This is necessary to allow the\n * TRANSFORM and API behavior to be somewhat consistent, and it's simpler.\n */\n#ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED\nvoid PNGAPI\npng_set_scale_16(png_structp png_ptr)\n{\n   png_debug(1, \"in png_set_scale_16\");\n\n   if (png_ptr == NULL)\n      return;\n\n   png_ptr->transformations |= PNG_SCALE_16_TO_8;\n}\n#endif\n\n#ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED\n/* Chop 16-bit depth files to 8-bit depth */\nvoid PNGAPI\npng_set_strip_16(png_structp png_ptr)\n{\n   png_debug(1, \"in png_set_strip_16\");\n\n   if (png_ptr == NULL)\n      return;\n\n   png_ptr->transformations |= PNG_16_TO_8;\n}\n#endif\n\n#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED\nvoid PNGAPI\npng_set_strip_alpha(png_structp png_ptr)\n{\n   png_debug(1, \"in png_set_strip_alpha\");\n\n   if (png_ptr == NULL)\n      return;\n\n   png_ptr->transformations |= PNG_STRIP_ALPHA;\n}\n#endif\n\n#if defined(PNG_READ_ALPHA_MODE_SUPPORTED) || defined(PNG_READ_GAMMA_SUPPORTED)\nstatic png_fixed_point\ntranslate_gamma_flags(png_structp png_ptr, png_fixed_point output_gamma,\n   int is_screen)\n{\n   /* Check for flag values.  The main reason for having the old Mac value as a\n    * flag is that it is pretty near impossible to work out what the correct\n    * value is from Apple documentation - a working Mac system is needed to\n    * discover the value!\n    */\n   if (output_gamma == PNG_DEFAULT_sRGB ||\n      output_gamma == PNG_FP_1 / PNG_DEFAULT_sRGB)\n   {\n      /* If there is no sRGB support this just sets the gamma to the standard\n       * sRGB value.  (This is a side effect of using this function!)\n       */\n#     ifdef PNG_READ_sRGB_SUPPORTED\n         png_ptr->flags |= PNG_FLAG_ASSUME_sRGB;\n#     endif\n      if (is_screen)\n         output_gamma = PNG_GAMMA_sRGB;\n      else\n         output_gamma = PNG_GAMMA_sRGB_INVERSE;\n   }\n\n   else if (output_gamma == PNG_GAMMA_MAC_18 ||\n      output_gamma == PNG_FP_1 / PNG_GAMMA_MAC_18)\n   {\n      if (is_screen)\n         output_gamma = PNG_GAMMA_MAC_OLD;\n      else\n         output_gamma = PNG_GAMMA_MAC_INVERSE;\n   }\n\n   return output_gamma;\n}\n\n#  ifdef PNG_FLOATING_POINT_SUPPORTED\nstatic png_fixed_point\nconvert_gamma_value(png_structp png_ptr, double output_gamma)\n{\n   /* The following silently ignores cases where fixed point (times 100,000)\n    * gamma values are passed to the floating point API.  This is safe and it\n    * means the fixed point constants work just fine with the floating point\n    * API.  The alternative would just lead to undetected errors and spurious\n    * bug reports.  Negative values fail inside the _fixed API unless they\n    * correspond to the flag values.\n    */\n   if (output_gamma > 0 && output_gamma < 128)\n      output_gamma *= PNG_FP_1;\n\n   /* This preserves -1 and -2 exactly: */\n   output_gamma = floor(output_gamma + .5);\n\n   if (output_gamma > PNG_FP_MAX || output_gamma < PNG_FP_MIN)\n      png_fixed_error(png_ptr, \"gamma value\");\n\n   return (png_fixed_point)output_gamma;\n}\n#  endif\n#endif /* READ_ALPHA_MODE || READ_GAMMA */\n\n#ifdef PNG_READ_ALPHA_MODE_SUPPORTED\nvoid PNGFAPI\npng_set_alpha_mode_fixed(png_structp png_ptr, int mode,\n   png_fixed_point output_gamma)\n{\n   int compose = 0;\n   png_fixed_point file_gamma;\n\n   png_debug(1, \"in png_set_alpha_mode\");\n\n   if (png_ptr == NULL)\n      return;\n\n   output_gamma = translate_gamma_flags(png_ptr, output_gamma, 1/*screen*/);\n\n   /* Validate the value to ensure it is in a reasonable range. The value\n    * is expected to be 1 or greater, but this range test allows for some\n    * viewing correction values.  The intent is to weed out users of this API\n    * who use the inverse of the gamma value accidentally!  Since some of these\n    * values are reasonable this may have to be changed.\n    */\n   if (output_gamma < 70000 || output_gamma > 300000)\n      png_error(png_ptr, \"output gamma out of expected range\");\n\n   /* The default file gamma is the inverse of the output gamma; the output\n    * gamma may be changed below so get the file value first:\n    */\n   file_gamma = png_reciprocal(output_gamma);\n\n   /* There are really 8 possibilities here, composed of any combination\n    * of:\n    *\n    *    premultiply the color channels\n    *    do not encode non-opaque pixels\n    *    encode the alpha as well as the color channels\n    *\n    * The differences disappear if the input/output ('screen') gamma is 1.0,\n    * because then the encoding is a no-op and there is only the choice of\n    * premultiplying the color channels or not.\n    *\n    * png_set_alpha_mode and png_set_background interact because both use\n    * png_compose to do the work.  Calling both is only useful when\n    * png_set_alpha_mode is used to set the default mode - PNG_ALPHA_PNG - along\n    * with a default gamma value.  Otherwise PNG_COMPOSE must not be set.\n    */\n   switch (mode)\n   {\n      case PNG_ALPHA_PNG:        /* default: png standard */\n         /* No compose, but it may be set by png_set_background! */\n         png_ptr->transformations &= ~PNG_ENCODE_ALPHA;\n         png_ptr->flags &= ~PNG_FLAG_OPTIMIZE_ALPHA;\n         break;\n\n      case PNG_ALPHA_ASSOCIATED: /* color channels premultiplied */\n         compose = 1;\n         png_ptr->transformations &= ~PNG_ENCODE_ALPHA;\n         png_ptr->flags &= ~PNG_FLAG_OPTIMIZE_ALPHA;\n         /* The output is linear: */\n         output_gamma = PNG_FP_1;\n         break;\n\n      case PNG_ALPHA_OPTIMIZED:  /* associated, non-opaque pixels linear */\n         compose = 1;\n         png_ptr->transformations &= ~PNG_ENCODE_ALPHA;\n         png_ptr->flags |= PNG_FLAG_OPTIMIZE_ALPHA;\n         /* output_gamma records the encoding of opaque pixels! */\n         break;\n\n      case PNG_ALPHA_BROKEN:     /* associated, non-linear, alpha encoded */\n         compose = 1;\n         png_ptr->transformations |= PNG_ENCODE_ALPHA;\n         png_ptr->flags &= ~PNG_FLAG_OPTIMIZE_ALPHA;\n         break;\n\n      default:\n         png_error(png_ptr, \"invalid alpha mode\");\n   }\n\n   /* Only set the default gamma if the file gamma has not been set (this has\n    * the side effect that the gamma in a second call to png_set_alpha_mode will\n    * be ignored.)\n    */\n   if (png_ptr->gamma == 0)\n      png_ptr->gamma = file_gamma;\n\n   /* But always set the output gamma: */\n   png_ptr->screen_gamma = output_gamma;\n\n   /* Finally, if pre-multiplying, set the background fields to achieve the\n    * desired result.\n    */\n   if (compose)\n   {\n      /* And obtain alpha pre-multiplication by composing on black: */\n      png_memset(&png_ptr->background, 0, sizeof png_ptr->background);\n      png_ptr->background_gamma = png_ptr->gamma; /* just in case */\n      png_ptr->background_gamma_type = PNG_BACKGROUND_GAMMA_FILE;\n      png_ptr->transformations &= ~PNG_BACKGROUND_EXPAND;\n\n      if (png_ptr->transformations & PNG_COMPOSE)\n         png_error(png_ptr,\n            \"conflicting calls to set alpha mode and background\");\n\n      png_ptr->transformations |= PNG_COMPOSE;\n   }\n\n   /* New API, make sure apps call the correct initializers: */\n   png_ptr->flags |= PNG_FLAG_DETECT_UNINITIALIZED;\n}\n\n#  ifdef PNG_FLOATING_POINT_SUPPORTED\nvoid PNGAPI\npng_set_alpha_mode(png_structp png_ptr, int mode, double output_gamma)\n{\n   png_set_alpha_mode_fixed(png_ptr, mode, convert_gamma_value(png_ptr,\n      output_gamma));\n}\n#  endif\n#endif\n\n#ifdef PNG_READ_QUANTIZE_SUPPORTED\n/* Dither file to 8-bit.  Supply a palette, the current number\n * of elements in the palette, the maximum number of elements\n * allowed, and a histogram if possible.  If the current number\n * of colors is greater then the maximum number, the palette will be\n * modified to fit in the maximum number.  \"full_quantize\" indicates\n * whether we need a quantizing cube set up for RGB images, or if we\n * simply are reducing the number of colors in a paletted image.\n */\n\ntypedef struct png_dsort_struct\n{\n   struct png_dsort_struct FAR * next;\n   png_byte left;\n   png_byte right;\n} png_dsort;\ntypedef png_dsort FAR *       png_dsortp;\ntypedef png_dsort FAR * FAR * png_dsortpp;\n\nvoid PNGAPI\npng_set_quantize(png_structp png_ptr, png_colorp palette,\n    int num_palette, int maximum_colors, png_const_uint_16p histogram,\n    int full_quantize)\n{\n   png_debug(1, \"in png_set_quantize\");\n\n   if (png_ptr == NULL)\n      return;\n\n   png_ptr->transformations |= PNG_QUANTIZE;\n\n   if (!full_quantize)\n   {\n      int i;\n\n      png_ptr->quantize_index = (png_bytep)png_malloc(png_ptr,\n          (png_uint_32)(num_palette * png_sizeof(png_byte)));\n      for (i = 0; i < num_palette; i++)\n         png_ptr->quantize_index[i] = (png_byte)i;\n   }\n\n   if (num_palette > maximum_colors)\n   {\n      if (histogram != NULL)\n      {\n         /* This is easy enough, just throw out the least used colors.\n          * Perhaps not the best solution, but good enough.\n          */\n\n         int i;\n\n         /* Initialize an array to sort colors */\n         png_ptr->quantize_sort = (png_bytep)png_malloc(png_ptr,\n             (png_uint_32)(num_palette * png_sizeof(png_byte)));\n\n         /* Initialize the quantize_sort array */\n         for (i = 0; i < num_palette; i++)\n            png_ptr->quantize_sort[i] = (png_byte)i;\n\n         /* Find the least used palette entries by starting a\n          * bubble sort, and running it until we have sorted\n          * out enough colors.  Note that we don't care about\n          * sorting all the colors, just finding which are\n          * least used.\n          */\n\n         for (i = num_palette - 1; i >= maximum_colors; i--)\n         {\n            int done; /* To stop early if the list is pre-sorted */\n            int j;\n\n            done = 1;\n            for (j = 0; j < i; j++)\n            {\n               if (histogram[png_ptr->quantize_sort[j]]\n                   < histogram[png_ptr->quantize_sort[j + 1]])\n               {\n                  png_byte t;\n\n                  t = png_ptr->quantize_sort[j];\n                  png_ptr->quantize_sort[j] = png_ptr->quantize_sort[j + 1];\n                  png_ptr->quantize_sort[j + 1] = t;\n                  done = 0;\n               }\n            }\n\n            if (done)\n               break;\n         }\n\n         /* Swap the palette around, and set up a table, if necessary */\n         if (full_quantize)\n         {\n            int j = num_palette;\n\n            /* Put all the useful colors within the max, but don't\n             * move the others.\n             */\n            for (i = 0; i < maximum_colors; i++)\n            {\n               if ((int)png_ptr->quantize_sort[i] >= maximum_colors)\n               {\n                  do\n                     j--;\n                  while ((int)png_ptr->quantize_sort[j] >= maximum_colors);\n\n                  palette[i] = palette[j];\n               }\n            }\n         }\n         else\n         {\n            int j = num_palette;\n\n            /* Move all the used colors inside the max limit, and\n             * develop a translation table.\n             */\n            for (i = 0; i < maximum_colors; i++)\n            {\n               /* Only move the colors we need to */\n               if ((int)png_ptr->quantize_sort[i] >= maximum_colors)\n               {\n                  png_color tmp_color;\n\n                  do\n                     j--;\n                  while ((int)png_ptr->quantize_sort[j] >= maximum_colors);\n\n                  tmp_color = palette[j];\n                  palette[j] = palette[i];\n                  palette[i] = tmp_color;\n                  /* Indicate where the color went */\n                  png_ptr->quantize_index[j] = (png_byte)i;\n                  png_ptr->quantize_index[i] = (png_byte)j;\n               }\n            }\n\n            /* Find closest color for those colors we are not using */\n            for (i = 0; i < num_palette; i++)\n            {\n               if ((int)png_ptr->quantize_index[i] >= maximum_colors)\n               {\n                  int min_d, k, min_k, d_index;\n\n                  /* Find the closest color to one we threw out */\n                  d_index = png_ptr->quantize_index[i];\n                  min_d = PNG_COLOR_DIST(palette[d_index], palette[0]);\n                  for (k = 1, min_k = 0; k < maximum_colors; k++)\n                  {\n                     int d;\n\n                     d = PNG_COLOR_DIST(palette[d_index], palette[k]);\n\n                     if (d < min_d)\n                     {\n                        min_d = d;\n                        min_k = k;\n                     }\n                  }\n                  /* Point to closest color */\n                  png_ptr->quantize_index[i] = (png_byte)min_k;\n               }\n            }\n         }\n         png_free(png_ptr, png_ptr->quantize_sort);\n         png_ptr->quantize_sort = NULL;\n      }\n      else\n      {\n         /* This is much harder to do simply (and quickly).  Perhaps\n          * we need to go through a median cut routine, but those\n          * don't always behave themselves with only a few colors\n          * as input.  So we will just find the closest two colors,\n          * and throw out one of them (chosen somewhat randomly).\n          * [We don't understand this at all, so if someone wants to\n          *  work on improving it, be our guest - AED, GRP]\n          */\n         int i;\n         int max_d;\n         int num_new_palette;\n         png_dsortp t;\n         png_dsortpp hash;\n\n         t = NULL;\n\n         /* Initialize palette index arrays */\n         png_ptr->index_to_palette = (png_bytep)png_malloc(png_ptr,\n             (png_uint_32)(num_palette * png_sizeof(png_byte)));\n         png_ptr->palette_to_index = (png_bytep)png_malloc(png_ptr,\n             (png_uint_32)(num_palette * png_sizeof(png_byte)));\n\n         /* Initialize the sort array */\n         for (i = 0; i < num_palette; i++)\n         {\n            png_ptr->index_to_palette[i] = (png_byte)i;\n            png_ptr->palette_to_index[i] = (png_byte)i;\n         }\n\n         hash = (png_dsortpp)png_calloc(png_ptr, (png_uint_32)(769 *\n             png_sizeof(png_dsortp)));\n\n         num_new_palette = num_palette;\n\n         /* Initial wild guess at how far apart the farthest pixel\n          * pair we will be eliminating will be.  Larger\n          * numbers mean more areas will be allocated, Smaller\n          * numbers run the risk of not saving enough data, and\n          * having to do this all over again.\n          *\n          * I have not done extensive checking on this number.\n          */\n         max_d = 96;\n\n         while (num_new_palette > maximum_colors)\n         {\n            for (i = 0; i < num_new_palette - 1; i++)\n            {\n               int j;\n\n               for (j = i + 1; j < num_new_palette; j++)\n               {\n                  int d;\n\n                  d = PNG_COLOR_DIST(palette[i], palette[j]);\n\n                  if (d <= max_d)\n                  {\n\n                     t = (png_dsortp)png_malloc_warn(png_ptr,\n                         (png_uint_32)(png_sizeof(png_dsort)));\n\n                     if (t == NULL)\n                         break;\n\n                     t->next = hash[d];\n                     t->left = (png_byte)i;\n                     t->right = (png_byte)j;\n                     hash[d] = t;\n                  }\n               }\n               if (t == NULL)\n                  break;\n            }\n\n            if (t != NULL)\n            for (i = 0; i <= max_d; i++)\n            {\n               if (hash[i] != NULL)\n               {\n                  png_dsortp p;\n\n                  for (p = hash[i]; p; p = p->next)\n                  {\n                     if ((int)png_ptr->index_to_palette[p->left]\n                         < num_new_palette &&\n                         (int)png_ptr->index_to_palette[p->right]\n                         < num_new_palette)\n                     {\n                        int j, next_j;\n\n                        if (num_new_palette & 0x01)\n                        {\n                           j = p->left;\n                           next_j = p->right;\n                        }\n                        else\n                        {\n                           j = p->right;\n                           next_j = p->left;\n                        }\n\n                        num_new_palette--;\n                        palette[png_ptr->index_to_palette[j]]\n                            = palette[num_new_palette];\n                        if (!full_quantize)\n                        {\n                           int k;\n\n                           for (k = 0; k < num_palette; k++)\n                           {\n                              if (png_ptr->quantize_index[k] ==\n                                  png_ptr->index_to_palette[j])\n                                 png_ptr->quantize_index[k] =\n                                     png_ptr->index_to_palette[next_j];\n\n                              if ((int)png_ptr->quantize_index[k] ==\n                                  num_new_palette)\n                                 png_ptr->quantize_index[k] =\n                                     png_ptr->index_to_palette[j];\n                           }\n                        }\n\n                        png_ptr->index_to_palette[png_ptr->palette_to_index\n                            [num_new_palette]] = png_ptr->index_to_palette[j];\n\n                        png_ptr->palette_to_index[png_ptr->index_to_palette[j]]\n                            = png_ptr->palette_to_index[num_new_palette];\n\n                        png_ptr->index_to_palette[j] =\n                            (png_byte)num_new_palette;\n\n                        png_ptr->palette_to_index[num_new_palette] =\n                            (png_byte)j;\n                     }\n                     if (num_new_palette <= maximum_colors)\n                        break;\n                  }\n                  if (num_new_palette <= maximum_colors)\n                     break;\n               }\n            }\n\n            for (i = 0; i < 769; i++)\n            {\n               if (hash[i] != NULL)\n               {\n                  png_dsortp p = hash[i];\n                  while (p)\n                  {\n                     t = p->next;\n                     png_free(png_ptr, p);\n                     p = t;\n                  }\n               }\n               hash[i] = 0;\n            }\n            max_d += 96;\n         }\n         png_free(png_ptr, hash);\n         png_free(png_ptr, png_ptr->palette_to_index);\n         png_free(png_ptr, png_ptr->index_to_palette);\n         png_ptr->palette_to_index = NULL;\n         png_ptr->index_to_palette = NULL;\n      }\n      num_palette = maximum_colors;\n   }\n   if (png_ptr->palette == NULL)\n   {\n      png_ptr->palette = palette;\n   }\n   png_ptr->num_palette = (png_uint_16)num_palette;\n\n   if (full_quantize)\n   {\n      int i;\n      png_bytep distance;\n      int total_bits = PNG_QUANTIZE_RED_BITS + PNG_QUANTIZE_GREEN_BITS +\n          PNG_QUANTIZE_BLUE_BITS;\n      int num_red = (1 << PNG_QUANTIZE_RED_BITS);\n      int num_green = (1 << PNG_QUANTIZE_GREEN_BITS);\n      int num_blue = (1 << PNG_QUANTIZE_BLUE_BITS);\n      png_size_t num_entries = ((png_size_t)1 << total_bits);\n\n      png_ptr->palette_lookup = (png_bytep)png_calloc(png_ptr,\n          (png_uint_32)(num_entries * png_sizeof(png_byte)));\n\n      distance = (png_bytep)png_malloc(png_ptr, (png_uint_32)(num_entries *\n          png_sizeof(png_byte)));\n\n      png_memset(distance, 0xff, num_entries * png_sizeof(png_byte));\n\n      for (i = 0; i < num_palette; i++)\n      {\n         int ir, ig, ib;\n         int r = (palette[i].red >> (8 - PNG_QUANTIZE_RED_BITS));\n         int g = (palette[i].green >> (8 - PNG_QUANTIZE_GREEN_BITS));\n         int b = (palette[i].blue >> (8 - PNG_QUANTIZE_BLUE_BITS));\n\n         for (ir = 0; ir < num_red; ir++)\n         {\n            /* int dr = abs(ir - r); */\n            int dr = ((ir > r) ? ir - r : r - ir);\n            int index_r = (ir << (PNG_QUANTIZE_BLUE_BITS +\n                PNG_QUANTIZE_GREEN_BITS));\n\n            for (ig = 0; ig < num_green; ig++)\n            {\n               /* int dg = abs(ig - g); */\n               int dg = ((ig > g) ? ig - g : g - ig);\n               int dt = dr + dg;\n               int dm = ((dr > dg) ? dr : dg);\n               int index_g = index_r | (ig << PNG_QUANTIZE_BLUE_BITS);\n\n               for (ib = 0; ib < num_blue; ib++)\n               {\n                  int d_index = index_g | ib;\n                  /* int db = abs(ib - b); */\n                  int db = ((ib > b) ? ib - b : b - ib);\n                  int dmax = ((dm > db) ? dm : db);\n                  int d = dmax + dt + db;\n\n                  if (d < (int)distance[d_index])\n                  {\n                     distance[d_index] = (png_byte)d;\n                     png_ptr->palette_lookup[d_index] = (png_byte)i;\n                  }\n               }\n            }\n         }\n      }\n\n      png_free(png_ptr, distance);\n   }\n}\n#endif /* PNG_READ_QUANTIZE_SUPPORTED */\n\n#ifdef PNG_READ_GAMMA_SUPPORTED\nvoid PNGFAPI\npng_set_gamma_fixed(png_structp png_ptr, png_fixed_point scrn_gamma,\n   png_fixed_point file_gamma)\n{\n   png_debug(1, \"in png_set_gamma_fixed\");\n\n   if (png_ptr == NULL)\n      return;\n\n   /* New in libpng-1.5.4 - reserve particular negative values as flags. */\n   scrn_gamma = translate_gamma_flags(png_ptr, scrn_gamma, 1/*screen*/);\n   file_gamma = translate_gamma_flags(png_ptr, file_gamma, 0/*file*/);\n\n#if PNG_LIBPNG_VER >= 10600\n   /* Checking the gamma values for being >0 was added in 1.5.4 along with the\n    * premultiplied alpha support; this actually hides an undocumented feature\n    * of the previous implementation which allowed gamma processing to be\n    * disabled in background handling.  There is no evidence (so far) that this\n    * was being used; however, png_set_background itself accepted and must still\n    * accept '0' for the gamma value it takes, because it isn't always used.\n    *\n    * Since this is an API change (albeit a very minor one that removes an\n    * undocumented API feature) it will not be made until libpng-1.6.0.\n    */\n   if (file_gamma <= 0)\n      png_error(png_ptr, \"invalid file gamma in png_set_gamma\");\n\n   if (scrn_gamma <= 0)\n      png_error(png_ptr, \"invalid screen gamma in png_set_gamma\");\n#endif\n\n   /* Set the gamma values unconditionally - this overrides the value in the PNG\n    * file if a gAMA chunk was present.  png_set_alpha_mode provides a\n    * different, easier, way to default the file gamma.\n    */\n   png_ptr->gamma = file_gamma;\n   png_ptr->screen_gamma = scrn_gamma;\n}\n\n#  ifdef PNG_FLOATING_POINT_SUPPORTED\nvoid PNGAPI\npng_set_gamma(png_structp png_ptr, double scrn_gamma, double file_gamma)\n{\n   png_set_gamma_fixed(png_ptr, convert_gamma_value(png_ptr, scrn_gamma),\n      convert_gamma_value(png_ptr, file_gamma));\n}\n#  endif /* FLOATING_POINT_SUPPORTED */\n#endif /* READ_GAMMA */\n\n#ifdef PNG_READ_EXPAND_SUPPORTED\n/* Expand paletted images to RGB, expand grayscale images of\n * less than 8-bit depth to 8-bit depth, and expand tRNS chunks\n * to alpha channels.\n */\nvoid PNGAPI\npng_set_expand(png_structp png_ptr)\n{\n   png_debug(1, \"in png_set_expand\");\n\n   if (png_ptr == NULL)\n      return;\n\n   png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS);\n   png_ptr->flags &= ~PNG_FLAG_ROW_INIT;\n}\n\n/* GRR 19990627:  the following three functions currently are identical\n *  to png_set_expand().  However, it is entirely reasonable that someone\n *  might wish to expand an indexed image to RGB but *not* expand a single,\n *  fully transparent palette entry to a full alpha channel--perhaps instead\n *  convert tRNS to the grayscale/RGB format (16-bit RGB value), or replace\n *  the transparent color with a particular RGB value, or drop tRNS entirely.\n *  IOW, a future version of the library may make the transformations flag\n *  a bit more fine-grained, with separate bits for each of these three\n *  functions.\n *\n *  More to the point, these functions make it obvious what libpng will be\n *  doing, whereas \"expand\" can (and does) mean any number of things.\n *\n *  GRP 20060307: In libpng-1.2.9, png_set_gray_1_2_4_to_8() was modified\n *  to expand only the sample depth but not to expand the tRNS to alpha\n *  and its name was changed to png_set_expand_gray_1_2_4_to_8().\n */\n\n/* Expand paletted images to RGB. */\nvoid PNGAPI\npng_set_palette_to_rgb(png_structp png_ptr)\n{\n   png_debug(1, \"in png_set_palette_to_rgb\");\n\n   if (png_ptr == NULL)\n      return;\n\n   png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS);\n   png_ptr->flags &= ~PNG_FLAG_ROW_INIT;\n}\n\n/* Expand grayscale images of less than 8-bit depth to 8 bits. */\nvoid PNGAPI\npng_set_expand_gray_1_2_4_to_8(png_structp png_ptr)\n{\n   png_debug(1, \"in png_set_expand_gray_1_2_4_to_8\");\n\n   if (png_ptr == NULL)\n      return;\n\n   png_ptr->transformations |= PNG_EXPAND;\n   png_ptr->flags &= ~PNG_FLAG_ROW_INIT;\n}\n\n\n\n/* Expand tRNS chunks to alpha channels. */\nvoid PNGAPI\npng_set_tRNS_to_alpha(png_structp png_ptr)\n{\n   png_debug(1, \"in png_set_tRNS_to_alpha\");\n\n   png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS);\n   png_ptr->flags &= ~PNG_FLAG_ROW_INIT;\n}\n#endif /* defined(PNG_READ_EXPAND_SUPPORTED) */\n\n#ifdef PNG_READ_EXPAND_16_SUPPORTED\n/* Expand to 16-bit channels, expand the tRNS chunk too (because otherwise\n * it may not work correctly.)\n */\nvoid PNGAPI\npng_set_expand_16(png_structp png_ptr)\n{\n   png_debug(1, \"in png_set_expand_16\");\n\n   if (png_ptr == NULL)\n      return;\n\n   png_ptr->transformations |= (PNG_EXPAND_16 | PNG_EXPAND | PNG_EXPAND_tRNS);\n   png_ptr->flags &= ~PNG_FLAG_ROW_INIT;\n\n   /* New API, make sure apps call the correct initializers: */\n   png_ptr->flags |= PNG_FLAG_DETECT_UNINITIALIZED;\n}\n#endif\n\n#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED\nvoid PNGAPI\npng_set_gray_to_rgb(png_structp png_ptr)\n{\n   png_debug(1, \"in png_set_gray_to_rgb\");\n\n   if (png_ptr != NULL)\n   {\n      /* Because rgb must be 8 bits or more: */\n      png_set_expand_gray_1_2_4_to_8(png_ptr);\n      png_ptr->transformations |= PNG_GRAY_TO_RGB;\n      png_ptr->flags &= ~PNG_FLAG_ROW_INIT;\n   }\n}\n#endif\n\n#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED\nvoid PNGFAPI\npng_set_rgb_to_gray_fixed(png_structp png_ptr, int error_action,\n    png_fixed_point red, png_fixed_point green)\n{\n   png_debug(1, \"in png_set_rgb_to_gray\");\n\n   if (png_ptr == NULL)\n      return;\n\n   switch(error_action)\n   {\n      case PNG_ERROR_ACTION_NONE:\n         png_ptr->transformations |= PNG_RGB_TO_GRAY;\n         break;\n\n      case PNG_ERROR_ACTION_WARN:\n         png_ptr->transformations |= PNG_RGB_TO_GRAY_WARN;\n         break;\n\n      case PNG_ERROR_ACTION_ERROR:\n         png_ptr->transformations |= PNG_RGB_TO_GRAY_ERR;\n         break;\n\n      default:\n         png_error(png_ptr, \"invalid error action to rgb_to_gray\");\n         break;\n   }\n   if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)\n#ifdef PNG_READ_EXPAND_SUPPORTED\n      png_ptr->transformations |= PNG_EXPAND;\n#else\n   {\n      png_warning(png_ptr,\n        \"Cannot do RGB_TO_GRAY without EXPAND_SUPPORTED\");\n\n      png_ptr->transformations &= ~PNG_RGB_TO_GRAY;\n   }\n#endif\n   {\n      if (red >= 0 && green >= 0 && red + green <= PNG_FP_1)\n      {\n         png_uint_16 red_int, green_int;\n\n         /* NOTE: this calculation does not round, but this behavior is retained\n          * for consistency, the inaccuracy is very small.  The code here always\n          * overwrites the coefficients, regardless of whether they have been\n          * defaulted or set already.\n          */\n         red_int = (png_uint_16)(((png_uint_32)red*32768)/100000);\n         green_int = (png_uint_16)(((png_uint_32)green*32768)/100000);\n\n         png_ptr->rgb_to_gray_red_coeff   = red_int;\n         png_ptr->rgb_to_gray_green_coeff = green_int;\n         png_ptr->rgb_to_gray_coefficients_set = 1;\n      }\n\n      else\n      {\n         if (red >= 0 && green >= 0)\n            png_warning(png_ptr,\n               \"ignoring out of range rgb_to_gray coefficients\");\n\n         /* Use the defaults, from the cHRM chunk if set, else the historical\n          * values which are close to the sRGB/HDTV/ITU-Rec 709 values.  See\n          * png_do_rgb_to_gray for more discussion of the values.  In this case\n          * the coefficients are not marked as 'set' and are not overwritten if\n          * something has already provided a default.\n          */\n         if (png_ptr->rgb_to_gray_red_coeff == 0 &&\n            png_ptr->rgb_to_gray_green_coeff == 0)\n         {\n            png_ptr->rgb_to_gray_red_coeff   = 6968;\n            png_ptr->rgb_to_gray_green_coeff = 23434;\n            /* png_ptr->rgb_to_gray_blue_coeff  = 2366; */\n         }\n      }\n   }\n}\n\n#ifdef PNG_FLOATING_POINT_SUPPORTED\n/* Convert a RGB image to a grayscale of the same width.  This allows us,\n * for example, to convert a 24 bpp RGB image into an 8 bpp grayscale image.\n */\n\nvoid PNGAPI\npng_set_rgb_to_gray(png_structp png_ptr, int error_action, double red,\n   double green)\n{\n   if (png_ptr == NULL)\n      return;\n\n   png_set_rgb_to_gray_fixed(png_ptr, error_action,\n      png_fixed(png_ptr, red, \"rgb to gray red coefficient\"),\n      png_fixed(png_ptr, green, \"rgb to gray green coefficient\"));\n}\n#endif /* FLOATING POINT */\n\n#endif\n\n#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \\\n    defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)\nvoid PNGAPI\npng_set_read_user_transform_fn(png_structp png_ptr, png_user_transform_ptr\n    read_user_transform_fn)\n{\n   png_debug(1, \"in png_set_read_user_transform_fn\");\n\n   if (png_ptr == NULL)\n      return;\n\n#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED\n   png_ptr->transformations |= PNG_USER_TRANSFORM;\n   png_ptr->read_user_transform_fn = read_user_transform_fn;\n#endif\n}\n#endif\n\n#ifdef PNG_READ_TRANSFORMS_SUPPORTED\n#ifdef PNG_READ_GAMMA_SUPPORTED\n/* In the case of gamma transformations only do transformations on images where\n * the [file] gamma and screen_gamma are not close reciprocals, otherwise it\n * slows things down slightly, and also needlessly introduces small errors.\n */\nstatic int /* PRIVATE */\npng_gamma_threshold(png_fixed_point screen_gamma, png_fixed_point file_gamma)\n{\n   /* PNG_GAMMA_THRESHOLD is the threshold for performing gamma\n    * correction as a difference of the overall transform from 1.0\n    *\n    * We want to compare the threshold with s*f - 1, if we get\n    * overflow here it is because of wacky gamma values so we\n    * turn on processing anyway.\n    */\n   png_fixed_point gtest;\n   return !png_muldiv(&gtest, screen_gamma, file_gamma, PNG_FP_1) ||\n       png_gamma_significant(gtest);\n}\n#endif\n\n/* Initialize everything needed for the read.  This includes modifying\n * the palette.\n */\n\n/*For the moment 'png_init_palette_transformations' and\n * 'png_init_rgb_transformations' only do some flag canceling optimizations.\n * The intent is that these two routines should have palette or rgb operations\n * extracted from 'png_init_read_transformations'.\n */\nstatic void /* PRIVATE */\npng_init_palette_transformations(png_structp png_ptr)\n{\n   /* Called to handle the (input) palette case.  In png_do_read_transformations\n    * the first step is to expand the palette if requested, so this code must\n    * take care to only make changes that are invariant with respect to the\n    * palette expansion, or only do them if there is no expansion.\n    *\n    * STRIP_ALPHA has already been handled in the caller (by setting num_trans\n    * to 0.)\n    */\n   int input_has_alpha = 0;\n   int input_has_transparency = 0;\n\n   if (png_ptr->num_trans > 0)\n   {\n      int i;\n\n      /* Ignore if all the entries are opaque (unlikely!) */\n      for (i=0; i<png_ptr->num_trans; ++i)\n         if (png_ptr->trans_alpha[i] == 255)\n            continue;\n         else if (png_ptr->trans_alpha[i] == 0)\n            input_has_transparency = 1;\n         else\n            input_has_alpha = 1;\n   }\n\n   /* If no alpha we can optimize. */\n   if (!input_has_alpha)\n   {\n      /* Any alpha means background and associative alpha processing is\n       * required, however if the alpha is 0 or 1 throughout OPTIIMIZE_ALPHA\n       * and ENCODE_ALPHA are irrelevant.\n       */\n      png_ptr->transformations &= ~PNG_ENCODE_ALPHA;\n      png_ptr->flags &= ~PNG_FLAG_OPTIMIZE_ALPHA;\n\n      if (!input_has_transparency)\n         png_ptr->transformations &= ~(PNG_COMPOSE | PNG_BACKGROUND_EXPAND);\n   }\n\n#if defined(PNG_READ_EXPAND_SUPPORTED) && defined(PNG_READ_BACKGROUND_SUPPORTED)\n   /* png_set_background handling - deals with the complexity of whether the\n    * background color is in the file format or the screen format in the case\n    * where an 'expand' will happen.\n    */\n\n   /* The following code cannot be entered in the alpha pre-multiplication case\n    * because PNG_BACKGROUND_EXPAND is cancelled below.\n    */\n   if ((png_ptr->transformations & PNG_BACKGROUND_EXPAND) &&\n       (png_ptr->transformations & PNG_EXPAND))\n   {\n      {\n         png_ptr->background.red   =\n             png_ptr->palette[png_ptr->background.index].red;\n         png_ptr->background.green =\n             png_ptr->palette[png_ptr->background.index].green;\n         png_ptr->background.blue  =\n             png_ptr->palette[png_ptr->background.index].blue;\n\n#ifdef PNG_READ_INVERT_ALPHA_SUPPORTED\n        if (png_ptr->transformations & PNG_INVERT_ALPHA)\n        {\n           if (!(png_ptr->transformations & PNG_EXPAND_tRNS))\n           {\n              /* Invert the alpha channel (in tRNS) unless the pixels are\n               * going to be expanded, in which case leave it for later\n               */\n              int i, istop = png_ptr->num_trans;\n\n              for (i=0; i<istop; i++)\n                 png_ptr->trans_alpha[i] = (png_byte)(255 -\n                    png_ptr->trans_alpha[i]);\n           }\n        }\n#endif /* PNG_READ_INVERT_ALPHA_SUPPORTED */\n      }\n   } /* background expand and (therefore) no alpha association. */\n#endif /* PNG_READ_EXPAND_SUPPORTED && PNG_READ_BACKGROUND_SUPPORTED */\n}\n\nstatic void /* PRIVATE */\npng_init_rgb_transformations(png_structp png_ptr)\n{\n   /* Added to libpng-1.5.4: check the color type to determine whether there\n    * is any alpha or transparency in the image and simply cancel the\n    * background and alpha mode stuff if there isn't.\n    */\n   int input_has_alpha = (png_ptr->color_type & PNG_COLOR_MASK_ALPHA) != 0;\n   int input_has_transparency = png_ptr->num_trans > 0;\n\n   /* If no alpha we can optimize. */\n   if (!input_has_alpha)\n   {\n      /* Any alpha means background and associative alpha processing is\n       * required, however if the alpha is 0 or 1 throughout OPTIIMIZE_ALPHA\n       * and ENCODE_ALPHA are irrelevant.\n       */\n#     ifdef PNG_READ_ALPHA_MODE_SUPPORTED\n         png_ptr->transformations &= ~PNG_ENCODE_ALPHA;\n         png_ptr->flags &= ~PNG_FLAG_OPTIMIZE_ALPHA;\n#     endif\n\n      if (!input_has_transparency)\n         png_ptr->transformations &= ~(PNG_COMPOSE | PNG_BACKGROUND_EXPAND);\n   }\n\n#if defined(PNG_READ_EXPAND_SUPPORTED) && defined(PNG_READ_BACKGROUND_SUPPORTED)\n   /* png_set_background handling - deals with the complexity of whether the\n    * background color is in the file format or the screen format in the case\n    * where an 'expand' will happen.\n    */\n\n   /* The following code cannot be entered in the alpha pre-multiplication case\n    * because PNG_BACKGROUND_EXPAND is cancelled below.\n    */\n   if ((png_ptr->transformations & PNG_BACKGROUND_EXPAND) &&\n       (png_ptr->transformations & PNG_EXPAND) &&\n       !(png_ptr->color_type & PNG_COLOR_MASK_COLOR))\n       /* i.e., GRAY or GRAY_ALPHA */\n   {\n      {\n         /* Expand background and tRNS chunks */\n         int gray = png_ptr->background.gray;\n         int trans_gray = png_ptr->trans_color.gray;\n\n         switch (png_ptr->bit_depth)\n         {\n            case 1:\n               gray *= 0xff;\n               trans_gray *= 0xff;\n               break;\n\n            case 2:\n               gray *= 0x55;\n               trans_gray *= 0x55;\n               break;\n\n            case 4:\n               gray *= 0x11;\n               trans_gray *= 0x11;\n               break;\n\n            default:\n\n            case 8:\n               /* Already 8 bits, fall through */\n\n            case 16:\n               /* Already a full 16 bits */\n               break;\n         }\n\n         png_ptr->background.red = png_ptr->background.green =\n            png_ptr->background.blue = (png_uint_16)gray;\n\n         if (!(png_ptr->transformations & PNG_EXPAND_tRNS))\n         {\n            png_ptr->trans_color.red = png_ptr->trans_color.green =\n               png_ptr->trans_color.blue = (png_uint_16)trans_gray;\n         }\n      }\n   } /* background expand and (therefore) no alpha association. */\n#endif /* PNG_READ_EXPAND_SUPPORTED && PNG_READ_BACKGROUND_SUPPORTED */\n}\n\nvoid /* PRIVATE */\npng_init_read_transformations(png_structp png_ptr)\n{\n   png_debug(1, \"in png_init_read_transformations\");\n\n   /* This internal function is called from png_read_start_row in pngrutil.c\n    * and it is called before the 'rowbytes' calculation is done, so the code\n    * in here can change or update the transformations flags.\n    *\n    * First do updates that do not depend on the details of the PNG image data\n    * being processed.\n    */\n\n#ifdef PNG_READ_GAMMA_SUPPORTED\n   /* Prior to 1.5.4 these tests were performed from png_set_gamma, 1.5.4 adds\n    * png_set_alpha_mode and this is another source for a default file gamma so\n    * the test needs to be performed later - here.  In addition prior to 1.5.4\n    * the tests were repeated for the PALETTE color type here - this is no\n    * longer necessary (and doesn't seem to have been necessary before.)\n    */\n   {\n      /* The following temporary indicates if overall gamma correction is\n       * required.\n       */\n      int gamma_correction = 0;\n\n      if (png_ptr->gamma != 0) /* has been set */\n      {\n         if (png_ptr->screen_gamma != 0) /* screen set too */\n            gamma_correction = png_gamma_threshold(png_ptr->gamma,\n               png_ptr->screen_gamma);\n\n         else\n            /* Assume the output matches the input; a long time default behavior\n             * of libpng, although the standard has nothing to say about this.\n             */\n            png_ptr->screen_gamma = png_reciprocal(png_ptr->gamma);\n      }\n\n      else if (png_ptr->screen_gamma != 0)\n         /* The converse - assume the file matches the screen, note that this\n          * perhaps undesireable default can (from 1.5.4) be changed by calling\n          * png_set_alpha_mode (even if the alpha handling mode isn't required\n          * or isn't changed from the default.)\n          */\n         png_ptr->gamma = png_reciprocal(png_ptr->screen_gamma);\n\n      else /* neither are set */\n         /* Just in case the following prevents any processing - file and screen\n          * are both assumed to be linear and there is no way to introduce a\n          * third gamma value other than png_set_background with 'UNIQUE', and,\n          * prior to 1.5.4\n          */\n         png_ptr->screen_gamma = png_ptr->gamma = PNG_FP_1;\n\n      /* Now turn the gamma transformation on or off as appropriate.  Notice\n       * that PNG_GAMMA just refers to the file->screen correction.  Alpha\n       * composition may independently cause gamma correction because it needs\n       * linear data (e.g. if the file has a gAMA chunk but the screen gamma\n       * hasn't been specified.)  In any case this flag may get turned off in\n       * the code immediately below if the transform can be handled outside the\n       * row loop.\n       */\n      if (gamma_correction)\n         png_ptr->transformations |= PNG_GAMMA;\n\n      else\n         png_ptr->transformations &= ~PNG_GAMMA;\n   }\n#endif\n\n   /* Certain transformations have the effect of preventing other\n    * transformations that happen afterward in png_do_read_transformations,\n    * resolve the interdependencies here.  From the code of\n    * png_do_read_transformations the order is:\n    *\n    *  1) PNG_EXPAND (including PNG_EXPAND_tRNS)\n    *  2) PNG_STRIP_ALPHA (if no compose)\n    *  3) PNG_RGB_TO_GRAY\n    *  4) PNG_GRAY_TO_RGB iff !PNG_BACKGROUND_IS_GRAY\n    *  5) PNG_COMPOSE\n    *  6) PNG_GAMMA\n    *  7) PNG_STRIP_ALPHA (if compose)\n    *  8) PNG_ENCODE_ALPHA\n    *  9) PNG_SCALE_16_TO_8\n    * 10) PNG_16_TO_8\n    * 11) PNG_QUANTIZE (converts to palette)\n    * 12) PNG_EXPAND_16\n    * 13) PNG_GRAY_TO_RGB iff PNG_BACKGROUND_IS_GRAY\n    * 14) PNG_INVERT_MONO\n    * 15) PNG_SHIFT\n    * 16) PNG_PACK\n    * 17) PNG_BGR\n    * 18) PNG_PACKSWAP\n    * 19) PNG_FILLER (includes PNG_ADD_ALPHA)\n    * 20) PNG_INVERT_ALPHA\n    * 21) PNG_SWAP_ALPHA\n    * 22) PNG_SWAP_BYTES\n    * 23) PNG_USER_TRANSFORM [must be last]\n    */\n#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED\n   if ((png_ptr->transformations & PNG_STRIP_ALPHA) &&\n      !(png_ptr->transformations & PNG_COMPOSE))\n   {\n      /* Stripping the alpha channel happens immediately after the 'expand'\n       * transformations, before all other transformation, so it cancels out\n       * the alpha handling.  It has the side effect negating the effect of\n       * PNG_EXPAND_tRNS too:\n       */\n      png_ptr->transformations &= ~(PNG_BACKGROUND_EXPAND | PNG_ENCODE_ALPHA |\n         PNG_EXPAND_tRNS);\n      png_ptr->flags &= ~PNG_FLAG_OPTIMIZE_ALPHA;\n\n      /* Kill the tRNS chunk itself too.  Prior to 1.5.4 this did not happen\n       * so transparency information would remain just so long as it wasn't\n       * expanded.  This produces unexpected API changes if the set of things\n       * that do PNG_EXPAND_tRNS changes (perfectly possible given the\n       * documentation - which says ask for what you want, accept what you\n       * get.)  This makes the behavior consistent from 1.5.4:\n       */\n      png_ptr->num_trans = 0;\n   }\n#endif /* STRIP_ALPHA supported, no COMPOSE */\n\n#ifdef PNG_READ_ALPHA_MODE_SUPPORTED\n   /* If the screen gamma is about 1.0 then the OPTIMIZE_ALPHA and ENCODE_ALPHA\n    * settings will have no effect.\n    */\n   if (!png_gamma_significant(png_ptr->screen_gamma))\n   {\n      png_ptr->transformations &= ~PNG_ENCODE_ALPHA;\n      png_ptr->flags &= ~PNG_FLAG_OPTIMIZE_ALPHA;\n   }\n#endif\n\n#if defined(PNG_READ_EXPAND_SUPPORTED) && \\\n   defined(PNG_READ_BACKGROUND_SUPPORTED) && \\\n   defined(PNG_READ_GRAY_TO_RGB_SUPPORTED)\n   /* Detect gray background and attempt to enable optimization for\n    * gray --> RGB case.\n    *\n    * Note:  if PNG_BACKGROUND_EXPAND is set and color_type is either RGB or\n    * RGB_ALPHA (in which case need_expand is superfluous anyway), the\n    * background color might actually be gray yet not be flagged as such.\n    * This is not a problem for the current code, which uses\n    * PNG_BACKGROUND_IS_GRAY only to decide when to do the\n    * png_do_gray_to_rgb() transformation.\n    *\n    * TODO: this code needs to be revised to avoid the complexity and\n    * interdependencies.  The color type of the background should be recorded in\n    * png_set_background, along with the bit depth, then the code has a record\n    * of exactly what color space the background is currently in.\n    */\n   if (png_ptr->transformations & PNG_BACKGROUND_EXPAND)\n   {\n      /* PNG_BACKGROUND_EXPAND: the background is in the file color space, so if\n       * the file was grayscale the background value is gray.\n       */\n      if (!(png_ptr->color_type & PNG_COLOR_MASK_COLOR))\n         png_ptr->mode |= PNG_BACKGROUND_IS_GRAY;\n   }\n\n   else if (png_ptr->transformations & PNG_COMPOSE)\n   {\n      /* PNG_COMPOSE: png_set_background was called with need_expand false,\n       * so the color is in the color space of the output or png_set_alpha_mode\n       * was called and the color is black.  Ignore RGB_TO_GRAY because that\n       * happens before GRAY_TO_RGB.\n       */\n      if (png_ptr->transformations & PNG_GRAY_TO_RGB)\n      {\n         if (png_ptr->background.red == png_ptr->background.green &&\n             png_ptr->background.red == png_ptr->background.blue)\n         {\n            png_ptr->mode |= PNG_BACKGROUND_IS_GRAY;\n            png_ptr->background.gray = png_ptr->background.red;\n         }\n      }\n   }\n#endif /* PNG_READ_GRAY_TO_RGB_SUPPORTED (etc) */\n\n   /* For indexed PNG data (PNG_COLOR_TYPE_PALETTE) many of the transformations\n    * can be performed directly on the palette, and some (such as rgb to gray)\n    * can be optimized inside the palette.  This is particularly true of the\n    * composite (background and alpha) stuff, which can be pretty much all done\n    * in the palette even if the result is expanded to RGB or gray afterward.\n    *\n    * NOTE: this is Not Yet Implemented, the code behaves as in 1.5.1 and\n    * earlier and the palette stuff is actually handled on the first row.  This\n    * leads to the reported bug that the palette returned by png_get_PLTE is not\n    * updated.\n    */\n   if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)\n      png_init_palette_transformations(png_ptr);\n\n   else\n      png_init_rgb_transformations(png_ptr);\n\n#if defined(PNG_READ_BACKGROUND_SUPPORTED) && \\\n   defined(PNG_READ_EXPAND_16_SUPPORTED)\n   if ((png_ptr->transformations & PNG_EXPAND_16) &&\n      (png_ptr->transformations & PNG_COMPOSE) &&\n      !(png_ptr->transformations & PNG_BACKGROUND_EXPAND) &&\n      png_ptr->bit_depth != 16)\n   {\n      /* TODO: fix this.  Because the expand_16 operation is after the compose\n       * handling the background color must be 8, not 16, bits deep, but the\n       * application will supply a 16-bit value so reduce it here.\n       *\n       * The PNG_BACKGROUND_EXPAND code above does not expand to 16 bits at\n       * present, so that case is ok (until do_expand_16 is moved.)\n       *\n       * NOTE: this discards the low 16 bits of the user supplied background\n       * color, but until expand_16 works properly there is no choice!\n       */\n#     define CHOP(x) (x)=((png_uint_16)(((png_uint_32)(x)*255+32895) >> 16))\n      CHOP(png_ptr->background.red);\n      CHOP(png_ptr->background.green);\n      CHOP(png_ptr->background.blue);\n      CHOP(png_ptr->background.gray);\n#     undef CHOP\n   }\n#endif /* PNG_READ_BACKGROUND_SUPPORTED && PNG_READ_EXPAND_16_SUPPORTED */\n\n#if defined(PNG_READ_BACKGROUND_SUPPORTED) && \\\n   (defined(PNG_READ_SCALE_16_TO_8_SUPPORTED) || \\\n   defined(PNG_READ_STRIP_16_TO_8_SUPPORTED))\n   if ((png_ptr->transformations & (PNG_16_TO_8|PNG_SCALE_16_TO_8)) &&\n      (png_ptr->transformations & PNG_COMPOSE) &&\n      !(png_ptr->transformations & PNG_BACKGROUND_EXPAND) &&\n      png_ptr->bit_depth == 16)\n   {\n      /* On the other hand, if a 16-bit file is to be reduced to 8-bits per\n       * component this will also happen after PNG_COMPOSE and so the background\n       * color must be pre-expanded here.\n       *\n       * TODO: fix this too.\n       */\n      png_ptr->background.red = (png_uint_16)(png_ptr->background.red * 257);\n      png_ptr->background.green =\n         (png_uint_16)(png_ptr->background.green * 257);\n      png_ptr->background.blue = (png_uint_16)(png_ptr->background.blue * 257);\n      png_ptr->background.gray = (png_uint_16)(png_ptr->background.gray * 257);\n   }\n#endif\n\n   /* NOTE: below 'PNG_READ_ALPHA_MODE_SUPPORTED' is presumed to also enable the\n    * background support (see the comments in scripts/pnglibconf.dfa), this\n    * allows pre-multiplication of the alpha channel to be implemented as\n    * compositing on black.  This is probably sub-optimal and has been done in\n    * 1.5.4 betas simply to enable external critique and testing (i.e. to\n    * implement the new API quickly, without lots of internal changes.)\n    */\n\n#ifdef PNG_READ_GAMMA_SUPPORTED\n#  ifdef PNG_READ_BACKGROUND_SUPPORTED\n      /* Includes ALPHA_MODE */\n      png_ptr->background_1 = png_ptr->background;\n#  endif\n\n   /* This needs to change - in the palette image case a whole set of tables are\n    * built when it would be quicker to just calculate the correct value for\n    * each palette entry directly.  Also, the test is too tricky - why check\n    * PNG_RGB_TO_GRAY if PNG_GAMMA is not set?  The answer seems to be that\n    * PNG_GAMMA is cancelled even if the gamma is known?  The test excludes the\n    * PNG_COMPOSE case, so apparently if there is no *overall* gamma correction\n    * the gamma tables will not be built even if composition is required on a\n    * gamma encoded value.\n    *\n    * In 1.5.4 this is addressed below by an additional check on the individual\n    * file gamma - if it is not 1.0 both RGB_TO_GRAY and COMPOSE need the\n    * tables.\n    */\n   if ((png_ptr->transformations & PNG_GAMMA)\n      || ((png_ptr->transformations & PNG_RGB_TO_GRAY)\n         && (png_gamma_significant(png_ptr->gamma) ||\n            png_gamma_significant(png_ptr->screen_gamma)))\n      || ((png_ptr->transformations & PNG_COMPOSE)\n         && (png_gamma_significant(png_ptr->gamma)\n            || png_gamma_significant(png_ptr->screen_gamma)\n#  ifdef PNG_READ_BACKGROUND_SUPPORTED\n            || (png_ptr->background_gamma_type == PNG_BACKGROUND_GAMMA_UNIQUE\n               && png_gamma_significant(png_ptr->background_gamma))\n#  endif\n      )) || ((png_ptr->transformations & PNG_ENCODE_ALPHA)\n         && png_gamma_significant(png_ptr->screen_gamma))\n      )\n   {\n      png_build_gamma_table(png_ptr, png_ptr->bit_depth);\n\n#ifdef PNG_READ_BACKGROUND_SUPPORTED\n      if (png_ptr->transformations & PNG_COMPOSE)\n      {\n         /* Issue a warning about this combination: because RGB_TO_GRAY is\n          * optimized to do the gamma transform if present yet do_background has\n          * to do the same thing if both options are set a\n          * double-gamma-correction happens.  This is true in all versions of\n          * libpng to date.\n          */\n         if (png_ptr->transformations & PNG_RGB_TO_GRAY)\n            png_warning(png_ptr,\n               \"libpng does not support gamma+background+rgb_to_gray\");\n\n         if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)\n         {\n            /* We don't get to here unless there is a tRNS chunk with non-opaque\n             * entries - see the checking code at the start of this function.\n             */\n            png_color back, back_1;\n            png_colorp palette = png_ptr->palette;\n            int num_palette = png_ptr->num_palette;\n            int i;\n            if (png_ptr->background_gamma_type == PNG_BACKGROUND_GAMMA_FILE)\n            {\n\n               back.red = png_ptr->gamma_table[png_ptr->background.red];\n               back.green = png_ptr->gamma_table[png_ptr->background.green];\n               back.blue = png_ptr->gamma_table[png_ptr->background.blue];\n\n               back_1.red = png_ptr->gamma_to_1[png_ptr->background.red];\n               back_1.green = png_ptr->gamma_to_1[png_ptr->background.green];\n               back_1.blue = png_ptr->gamma_to_1[png_ptr->background.blue];\n            }\n            else\n            {\n               png_fixed_point g, gs;\n\n               switch (png_ptr->background_gamma_type)\n               {\n                  case PNG_BACKGROUND_GAMMA_SCREEN:\n                     g = (png_ptr->screen_gamma);\n                     gs = PNG_FP_1;\n                     break;\n\n                  case PNG_BACKGROUND_GAMMA_FILE:\n                     g = png_reciprocal(png_ptr->gamma);\n                     gs = png_reciprocal2(png_ptr->gamma,\n                        png_ptr->screen_gamma);\n                     break;\n\n                  case PNG_BACKGROUND_GAMMA_UNIQUE:\n                     g = png_reciprocal(png_ptr->background_gamma);\n                     gs = png_reciprocal2(png_ptr->background_gamma,\n                        png_ptr->screen_gamma);\n                     break;\n                  default:\n                     g = PNG_FP_1;    /* back_1 */\n                     gs = PNG_FP_1;   /* back */\n                     break;\n               }\n\n               if (png_gamma_significant(gs))\n               {\n                  back.red = png_gamma_8bit_correct(png_ptr->background.red,\n                      gs);\n                  back.green = png_gamma_8bit_correct(png_ptr->background.green,\n                      gs);\n                  back.blue = png_gamma_8bit_correct(png_ptr->background.blue,\n                      gs);\n               }\n\n               else\n               {\n                  back.red   = (png_byte)png_ptr->background.red;\n                  back.green = (png_byte)png_ptr->background.green;\n                  back.blue  = (png_byte)png_ptr->background.blue;\n               }\n\n               if (png_gamma_significant(g))\n               {\n                  back_1.red = png_gamma_8bit_correct(png_ptr->background.red,\n                     g);\n                  back_1.green = png_gamma_8bit_correct(\n                     png_ptr->background.green, g);\n                  back_1.blue = png_gamma_8bit_correct(png_ptr->background.blue,\n                     g);\n               }\n\n               else\n               {\n                  back_1.red   = (png_byte)png_ptr->background.red;\n                  back_1.green = (png_byte)png_ptr->background.green;\n                  back_1.blue  = (png_byte)png_ptr->background.blue;\n               }\n            }\n\n            for (i = 0; i < num_palette; i++)\n            {\n               if (i < (int)png_ptr->num_trans &&\n                   png_ptr->trans_alpha[i] != 0xff)\n               {\n                  if (png_ptr->trans_alpha[i] == 0)\n                  {\n                     palette[i] = back;\n                  }\n                  else /* if (png_ptr->trans_alpha[i] != 0xff) */\n                  {\n                     png_byte v, w;\n\n                     v = png_ptr->gamma_to_1[palette[i].red];\n                     png_composite(w, v, png_ptr->trans_alpha[i], back_1.red);\n                     palette[i].red = png_ptr->gamma_from_1[w];\n\n                     v = png_ptr->gamma_to_1[palette[i].green];\n                     png_composite(w, v, png_ptr->trans_alpha[i], back_1.green);\n                     palette[i].green = png_ptr->gamma_from_1[w];\n\n                     v = png_ptr->gamma_to_1[palette[i].blue];\n                     png_composite(w, v, png_ptr->trans_alpha[i], back_1.blue);\n                     palette[i].blue = png_ptr->gamma_from_1[w];\n                  }\n               }\n               else\n               {\n                  palette[i].red = png_ptr->gamma_table[palette[i].red];\n                  palette[i].green = png_ptr->gamma_table[palette[i].green];\n                  palette[i].blue = png_ptr->gamma_table[palette[i].blue];\n               }\n            }\n\n            /* Prevent the transformations being done again.\n             *\n             * NOTE: this is highly dubious; it removes the transformations in\n             * place.  This seems inconsistent with the general treatment of the\n             * transformations elsewhere.\n             */\n            png_ptr->transformations &= ~(PNG_COMPOSE | PNG_GAMMA);\n         } /* color_type == PNG_COLOR_TYPE_PALETTE */\n\n         /* if (png_ptr->background_gamma_type!=PNG_BACKGROUND_GAMMA_UNKNOWN) */\n         else /* color_type != PNG_COLOR_TYPE_PALETTE */\n         {\n            int gs_sig, g_sig;\n            png_fixed_point g = PNG_FP_1;  /* Correction to linear */\n            png_fixed_point gs = PNG_FP_1; /* Correction to screen */\n\n            switch (png_ptr->background_gamma_type)\n            {\n               case PNG_BACKGROUND_GAMMA_SCREEN:\n                  g = png_ptr->screen_gamma;\n                  /* gs = PNG_FP_1; */\n                  break;\n\n               case PNG_BACKGROUND_GAMMA_FILE:\n                  g = png_reciprocal(png_ptr->gamma);\n                  gs = png_reciprocal2(png_ptr->gamma, png_ptr->screen_gamma);\n                  break;\n\n               case PNG_BACKGROUND_GAMMA_UNIQUE:\n                  g = png_reciprocal(png_ptr->background_gamma);\n                  gs = png_reciprocal2(png_ptr->background_gamma,\n                      png_ptr->screen_gamma);\n                  break;\n\n               default:\n                  png_error(png_ptr, \"invalid background gamma type\");\n            }\n\n            g_sig = png_gamma_significant(g);\n            gs_sig = png_gamma_significant(gs);\n\n            if (g_sig)\n               png_ptr->background_1.gray = png_gamma_correct(png_ptr,\n                   png_ptr->background.gray, g);\n\n            if (gs_sig)\n               png_ptr->background.gray = png_gamma_correct(png_ptr,\n                   png_ptr->background.gray, gs);\n\n            if ((png_ptr->background.red != png_ptr->background.green) ||\n                (png_ptr->background.red != png_ptr->background.blue) ||\n                (png_ptr->background.red != png_ptr->background.gray))\n            {\n               /* RGB or RGBA with color background */\n               if (g_sig)\n               {\n                  png_ptr->background_1.red = png_gamma_correct(png_ptr,\n                      png_ptr->background.red, g);\n\n                  png_ptr->background_1.green = png_gamma_correct(png_ptr,\n                      png_ptr->background.green, g);\n\n                  png_ptr->background_1.blue = png_gamma_correct(png_ptr,\n                      png_ptr->background.blue, g);\n               }\n\n               if (gs_sig)\n               {\n                  png_ptr->background.red = png_gamma_correct(png_ptr,\n                      png_ptr->background.red, gs);\n\n                  png_ptr->background.green = png_gamma_correct(png_ptr,\n                      png_ptr->background.green, gs);\n\n                  png_ptr->background.blue = png_gamma_correct(png_ptr,\n                      png_ptr->background.blue, gs);\n               }\n            }\n\n            else\n            {\n               /* GRAY, GRAY ALPHA, RGB, or RGBA with gray background */\n               png_ptr->background_1.red = png_ptr->background_1.green\n                   = png_ptr->background_1.blue = png_ptr->background_1.gray;\n\n               png_ptr->background.red = png_ptr->background.green\n                   = png_ptr->background.blue = png_ptr->background.gray;\n            }\n\n            /* The background is now in screen gamma: */\n            png_ptr->background_gamma_type = PNG_BACKGROUND_GAMMA_SCREEN;\n         } /* color_type != PNG_COLOR_TYPE_PALETTE */\n      }/* png_ptr->transformations & PNG_BACKGROUND */\n\n      else\n      /* Transformation does not include PNG_BACKGROUND */\n#endif /* PNG_READ_BACKGROUND_SUPPORTED */\n      if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE\n#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED\n         /* RGB_TO_GRAY needs to have non-gamma-corrected values! */\n         && ((png_ptr->transformations & PNG_EXPAND) == 0 ||\n         (png_ptr->transformations & PNG_RGB_TO_GRAY) == 0)\n#endif\n         )\n      {\n         png_colorp palette = png_ptr->palette;\n         int num_palette = png_ptr->num_palette;\n         int i;\n\n         /*NOTE: there are other transformations that should probably be in here\n          * too.\n          */\n         for (i = 0; i < num_palette; i++)\n         {\n            palette[i].red = png_ptr->gamma_table[palette[i].red];\n            palette[i].green = png_ptr->gamma_table[palette[i].green];\n            palette[i].blue = png_ptr->gamma_table[palette[i].blue];\n         }\n\n         /* Done the gamma correction. */\n         png_ptr->transformations &= ~PNG_GAMMA;\n      } /* color_type == PALETTE && !PNG_BACKGROUND transformation */\n   }\n#ifdef PNG_READ_BACKGROUND_SUPPORTED\n   else\n#endif\n#endif /* PNG_READ_GAMMA_SUPPORTED */\n\n#ifdef PNG_READ_BACKGROUND_SUPPORTED\n   /* No GAMMA transformation (see the hanging else 4 lines above) */\n   if ((png_ptr->transformations & PNG_COMPOSE) &&\n       (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE))\n   {\n      int i;\n      int istop = (int)png_ptr->num_trans;\n      png_color back;\n      png_colorp palette = png_ptr->palette;\n\n      back.red   = (png_byte)png_ptr->background.red;\n      back.green = (png_byte)png_ptr->background.green;\n      back.blue  = (png_byte)png_ptr->background.blue;\n\n      for (i = 0; i < istop; i++)\n      {\n         if (png_ptr->trans_alpha[i] == 0)\n         {\n            palette[i] = back;\n         }\n\n         else if (png_ptr->trans_alpha[i] != 0xff)\n         {\n            /* The png_composite() macro is defined in png.h */\n            png_composite(palette[i].red, palette[i].red,\n                png_ptr->trans_alpha[i], back.red);\n\n            png_composite(palette[i].green, palette[i].green,\n                png_ptr->trans_alpha[i], back.green);\n\n            png_composite(palette[i].blue, palette[i].blue,\n                png_ptr->trans_alpha[i], back.blue);\n         }\n      }\n\n      png_ptr->transformations &= ~PNG_COMPOSE;\n   }\n#endif /* PNG_READ_BACKGROUND_SUPPORTED */\n\n#ifdef PNG_READ_SHIFT_SUPPORTED\n   if ((png_ptr->transformations & PNG_SHIFT) &&\n       (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE))\n   {\n      int i;\n      int istop = png_ptr->num_palette;\n      int shift = 8 - png_ptr->sig_bit.red;\n\n      /* significant bits can be in the range 1 to 7 for a meaninful result, if\n       * the number of significant bits is 0 then no shift is done (this is an\n       * error condition which is silently ignored.)\n       */\n      if (shift > 0 && shift < 8) for (i=0; i<istop; ++i)\n      {\n         int component = png_ptr->palette[i].red;\n\n         component >>= shift;\n         png_ptr->palette[i].red = (png_byte)component;\n      }\n\n      shift = 8 - png_ptr->sig_bit.green;\n      if (shift > 0 && shift < 8) for (i=0; i<istop; ++i)\n      {\n         int component = png_ptr->palette[i].green;\n\n         component >>= shift;\n         png_ptr->palette[i].green = (png_byte)component;\n      }\n\n      shift = 8 - png_ptr->sig_bit.blue;\n      if (shift > 0 && shift < 8) for (i=0; i<istop; ++i)\n      {\n         int component = png_ptr->palette[i].blue;\n\n         component >>= shift;\n         png_ptr->palette[i].blue = (png_byte)component;\n      }\n   }\n#endif  /* PNG_READ_SHIFT_SUPPORTED */\n}\n\n/* Modify the info structure to reflect the transformations.  The\n * info should be updated so a PNG file could be written with it,\n * assuming the transformations result in valid PNG data.\n */\nvoid /* PRIVATE */\npng_read_transform_info(png_structp png_ptr, png_infop info_ptr)\n{\n   png_debug(1, \"in png_read_transform_info\");\n\n#ifdef PNG_READ_EXPAND_SUPPORTED\n   if (png_ptr->transformations & PNG_EXPAND)\n   {\n      if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)\n      {\n         /* This check must match what actually happens in\n          * png_do_expand_palette; if it ever checks the tRNS chunk to see if\n          * it is all opaque we must do the same (at present it does not.)\n          */\n         if (png_ptr->num_trans > 0)\n            info_ptr->color_type = PNG_COLOR_TYPE_RGB_ALPHA;\n\n         else\n            info_ptr->color_type = PNG_COLOR_TYPE_RGB;\n\n         info_ptr->bit_depth = 8;\n         info_ptr->num_trans = 0;\n      }\n      else\n      {\n         if (png_ptr->num_trans)\n         {\n            if (png_ptr->transformations & PNG_EXPAND_tRNS)\n               info_ptr->color_type |= PNG_COLOR_MASK_ALPHA;\n         }\n         if (info_ptr->bit_depth < 8)\n            info_ptr->bit_depth = 8;\n\n         info_ptr->num_trans = 0;\n      }\n   }\n#endif\n\n#if defined(PNG_READ_BACKGROUND_SUPPORTED) ||\\\n   defined(PNG_READ_ALPHA_MODE_SUPPORTED)\n   /* The following is almost certainly wrong unless the background value is in\n    * the screen space!\n    */\n   if (png_ptr->transformations & PNG_COMPOSE)\n      info_ptr->background = png_ptr->background;\n#endif\n\n#ifdef PNG_READ_GAMMA_SUPPORTED\n   /* The following used to be conditional on PNG_GAMMA (prior to 1.5.4),\n    * however it seems that the code in png_init_read_transformations, which has\n    * been called before this from png_read_update_info->png_read_start_row\n    * sometimes does the gamma transform and cancels the flag.\n    */\n   info_ptr->gamma = png_ptr->gamma;\n#endif\n\n   if (info_ptr->bit_depth == 16)\n   {\n#  ifdef PNG_READ_16BIT_SUPPORTED\n#     ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED\n         if (png_ptr->transformations & PNG_SCALE_16_TO_8)\n            info_ptr->bit_depth = 8;\n#     endif\n\n#     ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED\n         if (png_ptr->transformations & PNG_16_TO_8)\n            info_ptr->bit_depth = 8;\n#     endif\n\n#  else\n      /* No 16 bit support: force chopping 16-bit input down to 8, in this case\n       * the app program can chose if both APIs are available by setting the\n       * correct scaling to use.\n       */\n#     ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED\n         /* For compatibility with previous versions use the strip method by\n          * default.  This code works because if PNG_SCALE_16_TO_8 is already\n          * set the code below will do that in preference to the chop.\n          */\n         png_ptr->transformations |= PNG_16_TO_8;\n         info_ptr->bit_depth = 8;\n#     else\n\n#        ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED\n            png_ptr->transformations |= PNG_SCALE_16_TO_8;\n            info_ptr->bit_depth = 8;\n#        else\n\n            CONFIGURATION ERROR: you must enable at least one 16 to 8 method\n#        endif\n#    endif\n#endif /* !READ_16BIT_SUPPORTED */\n   }\n\n#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED\n   if (png_ptr->transformations & PNG_GRAY_TO_RGB)\n      info_ptr->color_type = (png_byte)(info_ptr->color_type |\n         PNG_COLOR_MASK_COLOR);\n#endif\n\n#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED\n   if (png_ptr->transformations & PNG_RGB_TO_GRAY)\n      info_ptr->color_type = (png_byte)(info_ptr->color_type &\n         ~PNG_COLOR_MASK_COLOR);\n#endif\n\n#ifdef PNG_READ_QUANTIZE_SUPPORTED\n   if (png_ptr->transformations & PNG_QUANTIZE)\n   {\n      if (((info_ptr->color_type == PNG_COLOR_TYPE_RGB) ||\n          (info_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA)) &&\n          png_ptr->palette_lookup && info_ptr->bit_depth == 8)\n      {\n         info_ptr->color_type = PNG_COLOR_TYPE_PALETTE;\n      }\n   }\n#endif\n\n#ifdef PNG_READ_EXPAND_16_SUPPORTED\n   if (png_ptr->transformations & PNG_EXPAND_16 && info_ptr->bit_depth == 8 &&\n      info_ptr->color_type != PNG_COLOR_TYPE_PALETTE)\n   {\n      info_ptr->bit_depth = 16;\n   }\n#endif\n\n#ifdef PNG_READ_PACK_SUPPORTED\n   if ((png_ptr->transformations & PNG_PACK) && (info_ptr->bit_depth < 8))\n      info_ptr->bit_depth = 8;\n#endif\n\n   if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)\n      info_ptr->channels = 1;\n\n   else if (info_ptr->color_type & PNG_COLOR_MASK_COLOR)\n      info_ptr->channels = 3;\n\n   else\n      info_ptr->channels = 1;\n\n#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED\n   if (png_ptr->transformations & PNG_STRIP_ALPHA)\n   {\n      info_ptr->color_type = (png_byte)(info_ptr->color_type &\n         ~PNG_COLOR_MASK_ALPHA);\n      info_ptr->num_trans = 0;\n   }\n#endif\n\n   if (info_ptr->color_type & PNG_COLOR_MASK_ALPHA)\n      info_ptr->channels++;\n\n#ifdef PNG_READ_FILLER_SUPPORTED\n   /* STRIP_ALPHA and FILLER allowed:  MASK_ALPHA bit stripped above */\n   if ((png_ptr->transformations & PNG_FILLER) &&\n       ((info_ptr->color_type == PNG_COLOR_TYPE_RGB) ||\n       (info_ptr->color_type == PNG_COLOR_TYPE_GRAY)))\n   {\n      info_ptr->channels++;\n      /* If adding a true alpha channel not just filler */\n      if (png_ptr->transformations & PNG_ADD_ALPHA)\n         info_ptr->color_type |= PNG_COLOR_MASK_ALPHA;\n   }\n#endif\n\n#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) && \\\ndefined(PNG_READ_USER_TRANSFORM_SUPPORTED)\n   if (png_ptr->transformations & PNG_USER_TRANSFORM)\n   {\n      if (info_ptr->bit_depth < png_ptr->user_transform_depth)\n         info_ptr->bit_depth = png_ptr->user_transform_depth;\n\n      if (info_ptr->channels < png_ptr->user_transform_channels)\n         info_ptr->channels = png_ptr->user_transform_channels;\n   }\n#endif\n\n   info_ptr->pixel_depth = (png_byte)(info_ptr->channels *\n       info_ptr->bit_depth);\n\n   info_ptr->rowbytes = PNG_ROWBYTES(info_ptr->pixel_depth, info_ptr->width);\n\n   /* Adding in 1.5.4: cache the above value in png_struct so that we can later\n    * check in png_rowbytes that the user buffer won't get overwritten.  Note\n    * that the field is not always set - if png_read_update_info isn't called\n    * the application has to either not do any transforms or get the calculation\n    * right itself.\n    */\n   png_ptr->info_rowbytes = info_ptr->rowbytes;\n\n#ifndef PNG_READ_EXPAND_SUPPORTED\n   if (png_ptr)\n      return;\n#endif\n}\n\n/* Transform the row.  The order of transformations is significant,\n * and is very touchy.  If you add a transformation, take care to\n * decide how it fits in with the other transformations here.\n */\nvoid /* PRIVATE */\npng_do_read_transformations(png_structp png_ptr, png_row_infop row_info)\n{\n   png_debug(1, \"in png_do_read_transformations\");\n\n   if (png_ptr->row_buf == NULL)\n   {\n      /* Prior to 1.5.4 this output row/pass where the NULL pointer is, but this\n       * error is incredibly rare and incredibly easy to debug without this\n       * information.\n       */\n      png_error(png_ptr, \"NULL row buffer\");\n   }\n\n   /* The following is debugging; prior to 1.5.4 the code was never compiled in;\n    * in 1.5.4 PNG_FLAG_DETECT_UNINITIALIZED was added and the macro\n    * PNG_WARN_UNINITIALIZED_ROW removed.  In 1.5 the new flag is set only for\n    * selected new APIs to ensure that there is no API change.\n    */\n   if ((png_ptr->flags & PNG_FLAG_DETECT_UNINITIALIZED) != 0 &&\n      !(png_ptr->flags & PNG_FLAG_ROW_INIT))\n   {\n      /* Application has failed to call either png_read_start_image() or\n       * png_read_update_info() after setting transforms that expand pixels.\n       * This check added to libpng-1.2.19 (but not enabled until 1.5.4).\n       */\n      png_error(png_ptr, \"Uninitialized row\");\n   }\n\n#ifdef PNG_READ_EXPAND_SUPPORTED\n   if (png_ptr->transformations & PNG_EXPAND)\n   {\n      if (row_info->color_type == PNG_COLOR_TYPE_PALETTE)\n      {\n         png_do_expand_palette(row_info, png_ptr->row_buf + 1,\n             png_ptr->palette, png_ptr->trans_alpha, png_ptr->num_trans);\n      }\n\n      else\n      {\n         if (png_ptr->num_trans &&\n             (png_ptr->transformations & PNG_EXPAND_tRNS))\n            png_do_expand(row_info, png_ptr->row_buf + 1,\n                &(png_ptr->trans_color));\n\n         else\n            png_do_expand(row_info, png_ptr->row_buf + 1,\n                NULL);\n      }\n   }\n#endif\n\n#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED\n   if ((png_ptr->transformations & PNG_STRIP_ALPHA) &&\n      !(png_ptr->transformations & PNG_COMPOSE) &&\n      (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA ||\n      row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA))\n      png_do_strip_channel(row_info, png_ptr->row_buf + 1,\n         0 /* at_start == false, because SWAP_ALPHA happens later */);\n#endif\n\n#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED\n   if (png_ptr->transformations & PNG_RGB_TO_GRAY)\n   {\n      int rgb_error =\n          png_do_rgb_to_gray(png_ptr, row_info,\n              png_ptr->row_buf + 1);\n\n      if (rgb_error)\n      {\n         png_ptr->rgb_to_gray_status=1;\n         if ((png_ptr->transformations & PNG_RGB_TO_GRAY) ==\n             PNG_RGB_TO_GRAY_WARN)\n            png_warning(png_ptr, \"png_do_rgb_to_gray found nongray pixel\");\n\n         if ((png_ptr->transformations & PNG_RGB_TO_GRAY) ==\n             PNG_RGB_TO_GRAY_ERR)\n            png_error(png_ptr, \"png_do_rgb_to_gray found nongray pixel\");\n      }\n   }\n#endif\n\n/* From Andreas Dilger e-mail to png-implement, 26 March 1998:\n *\n *   In most cases, the \"simple transparency\" should be done prior to doing\n *   gray-to-RGB, or you will have to test 3x as many bytes to check if a\n *   pixel is transparent.  You would also need to make sure that the\n *   transparency information is upgraded to RGB.\n *\n *   To summarize, the current flow is:\n *   - Gray + simple transparency -> compare 1 or 2 gray bytes and composite\n *                                   with background \"in place\" if transparent,\n *                                   convert to RGB if necessary\n *   - Gray + alpha -> composite with gray background and remove alpha bytes,\n *                                   convert to RGB if necessary\n *\n *   To support RGB backgrounds for gray images we need:\n *   - Gray + simple transparency -> convert to RGB + simple transparency,\n *                                   compare 3 or 6 bytes and composite with\n *                                   background \"in place\" if transparent\n *                                   (3x compare/pixel compared to doing\n *                                   composite with gray bkgrnd)\n *   - Gray + alpha -> convert to RGB + alpha, composite with background and\n *                                   remove alpha bytes (3x float\n *                                   operations/pixel compared with composite\n *                                   on gray background)\n *\n *  Greg's change will do this.  The reason it wasn't done before is for\n *  performance, as this increases the per-pixel operations.  If we would check\n *  in advance if the background was gray or RGB, and position the gray-to-RGB\n *  transform appropriately, then it would save a lot of work/time.\n */\n\n#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED\n   /* If gray -> RGB, do so now only if background is non-gray; else do later\n    * for performance reasons\n    */\n   if ((png_ptr->transformations & PNG_GRAY_TO_RGB) &&\n       !(png_ptr->mode & PNG_BACKGROUND_IS_GRAY))\n      png_do_gray_to_rgb(row_info, png_ptr->row_buf + 1);\n#endif\n\n#if (defined PNG_READ_BACKGROUND_SUPPORTED) ||\\\n   (defined PNG_READ_ALPHA_MODE_SUPPORTED)\n   if (png_ptr->transformations & PNG_COMPOSE)\n      png_do_compose(row_info, png_ptr->row_buf + 1, png_ptr);\n#endif\n\n#ifdef PNG_READ_GAMMA_SUPPORTED\n   if ((png_ptr->transformations & PNG_GAMMA) &&\n#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED\n      /* Because RGB_TO_GRAY does the gamma transform. */\n      !(png_ptr->transformations & PNG_RGB_TO_GRAY) &&\n#endif\n#if (defined PNG_READ_BACKGROUND_SUPPORTED) ||\\\n   (defined PNG_READ_ALPHA_MODE_SUPPORTED)\n      /* Because PNG_COMPOSE does the gamma transform if there is something to\n       * do (if there is an alpha channel or transparency.)\n       */\n       !((png_ptr->transformations & PNG_COMPOSE) &&\n       ((png_ptr->num_trans != 0) ||\n       (png_ptr->color_type & PNG_COLOR_MASK_ALPHA))) &&\n#endif\n      /* Because png_init_read_transformations transforms the palette, unless\n       * RGB_TO_GRAY will do the transform.\n       */\n       (png_ptr->color_type != PNG_COLOR_TYPE_PALETTE))\n      png_do_gamma(row_info, png_ptr->row_buf + 1, png_ptr);\n#endif\n\n#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED\n   if ((png_ptr->transformations & PNG_STRIP_ALPHA) &&\n      (png_ptr->transformations & PNG_COMPOSE) &&\n      (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA ||\n      row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA))\n      png_do_strip_channel(row_info, png_ptr->row_buf + 1,\n         0 /* at_start == false, because SWAP_ALPHA happens later */);\n#endif\n\n#ifdef PNG_READ_ALPHA_MODE_SUPPORTED\n   if ((png_ptr->transformations & PNG_ENCODE_ALPHA) &&\n      (row_info->color_type & PNG_COLOR_MASK_ALPHA))\n      png_do_encode_alpha(row_info, png_ptr->row_buf + 1, png_ptr);\n#endif\n\n#ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED\n   if (png_ptr->transformations & PNG_SCALE_16_TO_8)\n      png_do_scale_16_to_8(row_info, png_ptr->row_buf + 1);\n#endif\n\n#ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED\n   /* There is no harm in doing both of these because only one has any effect,\n    * by putting the 'scale' option first if the app asks for scale (either by\n    * calling the API or in a TRANSFORM flag) this is what happens.\n    */\n   if (png_ptr->transformations & PNG_16_TO_8)\n      png_do_chop(row_info, png_ptr->row_buf + 1);\n#endif\n\n#ifdef PNG_READ_QUANTIZE_SUPPORTED\n   if (png_ptr->transformations & PNG_QUANTIZE)\n   {\n      png_do_quantize(row_info, png_ptr->row_buf + 1,\n          png_ptr->palette_lookup, png_ptr->quantize_index);\n\n      if (row_info->rowbytes == 0)\n         png_error(png_ptr, \"png_do_quantize returned rowbytes=0\");\n   }\n#endif /* PNG_READ_QUANTIZE_SUPPORTED */\n\n#ifdef PNG_READ_EXPAND_16_SUPPORTED\n   /* Do the expansion now, after all the arithmetic has been done.  Notice\n    * that previous transformations can handle the PNG_EXPAND_16 flag if this\n    * is efficient (particularly true in the case of gamma correction, where\n    * better accuracy results faster!)\n    */\n   if (png_ptr->transformations & PNG_EXPAND_16)\n      png_do_expand_16(row_info, png_ptr->row_buf + 1);\n#endif\n\n#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED\n   /*NOTE: moved here in 1.5.4 (from much later in this list.) */\n   if ((png_ptr->transformations & PNG_GRAY_TO_RGB) &&\n       (png_ptr->mode & PNG_BACKGROUND_IS_GRAY))\n      png_do_gray_to_rgb(row_info, png_ptr->row_buf + 1);\n#endif\n\n#ifdef PNG_READ_INVERT_SUPPORTED\n   if (png_ptr->transformations & PNG_INVERT_MONO)\n      png_do_invert(row_info, png_ptr->row_buf + 1);\n#endif\n\n#ifdef PNG_READ_SHIFT_SUPPORTED\n   if (png_ptr->transformations & PNG_SHIFT)\n      png_do_unshift(row_info, png_ptr->row_buf + 1,\n          &(png_ptr->shift));\n#endif\n\n#ifdef PNG_READ_PACK_SUPPORTED\n   if (png_ptr->transformations & PNG_PACK)\n      png_do_unpack(row_info, png_ptr->row_buf + 1);\n#endif\n\n#ifdef PNG_READ_BGR_SUPPORTED\n   if (png_ptr->transformations & PNG_BGR)\n      png_do_bgr(row_info, png_ptr->row_buf + 1);\n#endif\n\n#ifdef PNG_READ_PACKSWAP_SUPPORTED\n   if (png_ptr->transformations & PNG_PACKSWAP)\n      png_do_packswap(row_info, png_ptr->row_buf + 1);\n#endif\n\n#ifdef PNG_READ_FILLER_SUPPORTED\n   if (png_ptr->transformations & PNG_FILLER)\n      png_do_read_filler(row_info, png_ptr->row_buf + 1,\n          (png_uint_32)png_ptr->filler, png_ptr->flags);\n#endif\n\n#ifdef PNG_READ_INVERT_ALPHA_SUPPORTED\n   if (png_ptr->transformations & PNG_INVERT_ALPHA)\n      png_do_read_invert_alpha(row_info, png_ptr->row_buf + 1);\n#endif\n\n#ifdef PNG_READ_SWAP_ALPHA_SUPPORTED\n   if (png_ptr->transformations & PNG_SWAP_ALPHA)\n      png_do_read_swap_alpha(row_info, png_ptr->row_buf + 1);\n#endif\n\n#ifdef PNG_READ_16BIT_SUPPORTED\n#ifdef PNG_READ_SWAP_SUPPORTED\n   if (png_ptr->transformations & PNG_SWAP_BYTES)\n      png_do_swap(row_info, png_ptr->row_buf + 1);\n#endif\n#endif\n\n#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED\n   if (png_ptr->transformations & PNG_USER_TRANSFORM)\n    {\n      if (png_ptr->read_user_transform_fn != NULL)\n         (*(png_ptr->read_user_transform_fn)) /* User read transform function */\n             (png_ptr,     /* png_ptr */\n             row_info,     /* row_info: */\n                /*  png_uint_32 width;       width of row */\n                /*  png_size_t rowbytes;     number of bytes in row */\n                /*  png_byte color_type;     color type of pixels */\n                /*  png_byte bit_depth;      bit depth of samples */\n                /*  png_byte channels;       number of channels (1-4) */\n                /*  png_byte pixel_depth;    bits per pixel (depth*channels) */\n             png_ptr->row_buf + 1);    /* start of pixel data for row */\n#ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED\n      if (png_ptr->user_transform_depth)\n         row_info->bit_depth = png_ptr->user_transform_depth;\n\n      if (png_ptr->user_transform_channels)\n         row_info->channels = png_ptr->user_transform_channels;\n#endif\n      row_info->pixel_depth = (png_byte)(row_info->bit_depth *\n          row_info->channels);\n\n      row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, row_info->width);\n   }\n#endif\n}\n\n#ifdef PNG_READ_PACK_SUPPORTED\n/* Unpack pixels of 1, 2, or 4 bits per pixel into 1 byte per pixel,\n * without changing the actual values.  Thus, if you had a row with\n * a bit depth of 1, you would end up with bytes that only contained\n * the numbers 0 or 1.  If you would rather they contain 0 and 255, use\n * png_do_shift() after this.\n */\nvoid /* PRIVATE */\npng_do_unpack(png_row_infop row_info, png_bytep row)\n{\n   png_debug(1, \"in png_do_unpack\");\n\n   if (row_info->bit_depth < 8)\n   {\n      png_uint_32 i;\n      png_uint_32 row_width=row_info->width;\n\n      switch (row_info->bit_depth)\n      {\n         case 1:\n         {\n            png_bytep sp = row + (png_size_t)((row_width - 1) >> 3);\n            png_bytep dp = row + (png_size_t)row_width - 1;\n            png_uint_32 shift = 7 - (int)((row_width + 7) & 0x07);\n            for (i = 0; i < row_width; i++)\n            {\n               *dp = (png_byte)((*sp >> shift) & 0x01);\n\n               if (shift == 7)\n               {\n                  shift = 0;\n                  sp--;\n               }\n\n               else\n                  shift++;\n\n               dp--;\n            }\n            break;\n         }\n\n         case 2:\n         {\n\n            png_bytep sp = row + (png_size_t)((row_width - 1) >> 2);\n            png_bytep dp = row + (png_size_t)row_width - 1;\n            png_uint_32 shift = (int)((3 - ((row_width + 3) & 0x03)) << 1);\n            for (i = 0; i < row_width; i++)\n            {\n               *dp = (png_byte)((*sp >> shift) & 0x03);\n\n               if (shift == 6)\n               {\n                  shift = 0;\n                  sp--;\n               }\n\n               else\n                  shift += 2;\n\n               dp--;\n            }\n            break;\n         }\n\n         case 4:\n         {\n            png_bytep sp = row + (png_size_t)((row_width - 1) >> 1);\n            png_bytep dp = row + (png_size_t)row_width - 1;\n            png_uint_32 shift = (int)((1 - ((row_width + 1) & 0x01)) << 2);\n            for (i = 0; i < row_width; i++)\n            {\n               *dp = (png_byte)((*sp >> shift) & 0x0f);\n\n               if (shift == 4)\n               {\n                  shift = 0;\n                  sp--;\n               }\n\n               else\n                  shift = 4;\n\n               dp--;\n            }\n            break;\n         }\n\n         default:\n            break;\n      }\n      row_info->bit_depth = 8;\n      row_info->pixel_depth = (png_byte)(8 * row_info->channels);\n      row_info->rowbytes = row_width * row_info->channels;\n   }\n}\n#endif\n\n#ifdef PNG_READ_SHIFT_SUPPORTED\n/* Reverse the effects of png_do_shift.  This routine merely shifts the\n * pixels back to their significant bits values.  Thus, if you have\n * a row of bit depth 8, but only 5 are significant, this will shift\n * the values back to 0 through 31.\n */\nvoid /* PRIVATE */\npng_do_unshift(png_row_infop row_info, png_bytep row,\n    png_const_color_8p sig_bits)\n{\n   int color_type;\n\n   png_debug(1, \"in png_do_unshift\");\n\n   /* The palette case has already been handled in the _init routine. */\n   color_type = row_info->color_type;\n\n   if (color_type != PNG_COLOR_TYPE_PALETTE)\n   {\n      int shift[4];\n      int channels = 0;\n      int bit_depth = row_info->bit_depth;\n\n      if (color_type & PNG_COLOR_MASK_COLOR)\n      {\n         shift[channels++] = bit_depth - sig_bits->red;\n         shift[channels++] = bit_depth - sig_bits->green;\n         shift[channels++] = bit_depth - sig_bits->blue;\n      }\n\n      else\n      {\n         shift[channels++] = bit_depth - sig_bits->gray;\n      }\n\n      if (color_type & PNG_COLOR_MASK_ALPHA)\n      {\n         shift[channels++] = bit_depth - sig_bits->alpha;\n      }\n\n      {\n         int c, have_shift;\n\n         for (c = have_shift = 0; c < channels; ++c)\n         {\n            /* A shift of more than the bit depth is an error condition but it\n             * gets ignored here.\n             */\n            if (shift[c] <= 0 || shift[c] >= bit_depth)\n               shift[c] = 0;\n\n            else\n               have_shift = 1;\n         }\n\n         if (!have_shift)\n            return;\n      }\n\n      switch (bit_depth)\n      {\n         default:\n         /* Must be 1bpp gray: should not be here! */\n            /* NOTREACHED */\n            break;\n\n         case 2:\n         /* Must be 2bpp gray */\n         /* assert(channels == 1 && shift[0] == 1) */\n         {\n            png_bytep bp = row;\n            png_bytep bp_end = bp + row_info->rowbytes;\n\n            while (bp < bp_end)\n            {\n               int b = (*bp >> 1) & 0x55;\n               *bp++ = (png_byte)b;\n            }\n            break;\n         }\n\n         case 4:\n         /* Must be 4bpp gray */\n         /* assert(channels == 1) */\n         {\n            png_bytep bp = row;\n            png_bytep bp_end = bp + row_info->rowbytes;\n            int gray_shift = shift[0];\n            int mask =  0xf >> gray_shift;\n\n            mask |= mask << 4;\n\n            while (bp < bp_end)\n            {\n               int b = (*bp >> gray_shift) & mask;\n               *bp++ = (png_byte)b;\n            }\n            break;\n         }\n\n         case 8:\n         /* Single byte components, G, GA, RGB, RGBA */\n         {\n            png_bytep bp = row;\n            png_bytep bp_end = bp + row_info->rowbytes;\n            int channel = 0;\n\n            while (bp < bp_end)\n            {\n               int b = *bp >> shift[channel];\n               if (++channel >= channels)\n                  channel = 0;\n               *bp++ = (png_byte)b;\n            }\n            break;\n         }\n\n#ifdef PNG_READ_16BIT_SUPPORTED\n         case 16:\n         /* Double byte components, G, GA, RGB, RGBA */\n         {\n            png_bytep bp = row;\n            png_bytep bp_end = bp + row_info->rowbytes;\n            int channel = 0;\n\n            while (bp < bp_end)\n            {\n               int value = (bp[0] << 8) + bp[1];\n\n               value >>= shift[channel];\n               if (++channel >= channels)\n                  channel = 0;\n               *bp++ = (png_byte)(value >> 8);\n               *bp++ = (png_byte)(value & 0xff);\n            }\n            break;\n         }\n#endif\n      }\n   }\n}\n#endif\n\n#ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED\n/* Scale rows of bit depth 16 down to 8 accurately */\nvoid /* PRIVATE */\npng_do_scale_16_to_8(png_row_infop row_info, png_bytep row)\n{\n   png_debug(1, \"in png_do_scale_16_to_8\");\n\n   if (row_info->bit_depth == 16)\n   {\n      png_bytep sp = row; /* source */\n      png_bytep dp = row; /* destination */\n      png_bytep ep = sp + row_info->rowbytes; /* end+1 */\n\n      while (sp < ep)\n      {\n         /* The input is an array of 16 bit components, these must be scaled to\n          * 8 bits each.  For a 16 bit value V the required value (from the PNG\n          * specification) is:\n          *\n          *    (V * 255) / 65535\n          *\n          * This reduces to round(V / 257), or floor((V + 128.5)/257)\n          *\n          * Represent V as the two byte value vhi.vlo.  Make a guess that the\n          * result is the top byte of V, vhi, then the correction to this value\n          * is:\n          *\n          *    error = floor(((V-vhi.vhi) + 128.5) / 257)\n          *          = floor(((vlo-vhi) + 128.5) / 257)\n          *\n          * This can be approximated using integer arithmetic (and a signed\n          * shift):\n          *\n          *    error = (vlo-vhi+128) >> 8;\n          *\n          * The approximate differs from the exact answer only when (vlo-vhi) is\n          * 128; it then gives a correction of +1 when the exact correction is\n          * 0.  This gives 128 errors.  The exact answer (correct for all 16 bit\n          * input values) is:\n          *\n          *    error = (vlo-vhi+128)*65535 >> 24;\n          *\n          * An alternative arithmetic calculation which also gives no errors is:\n          *\n          *    (V * 255 + 32895) >> 16\n          */\n\n         png_int_32 tmp = *sp++; /* must be signed! */\n         tmp += (((int)*sp++ - tmp + 128) * 65535) >> 24;\n         *dp++ = (png_byte)tmp;\n      }\n\n      row_info->bit_depth = 8;\n      row_info->pixel_depth = (png_byte)(8 * row_info->channels);\n      row_info->rowbytes = row_info->width * row_info->channels;\n   }\n}\n#endif\n\n#ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED\nvoid /* PRIVATE */\n/* Simply discard the low byte.  This was the default behavior prior\n * to libpng-1.5.4.\n */\npng_do_chop(png_row_infop row_info, png_bytep row)\n{\n   png_debug(1, \"in png_do_chop\");\n\n   if (row_info->bit_depth == 16)\n   {\n      png_bytep sp = row; /* source */\n      png_bytep dp = row; /* destination */\n      png_bytep ep = sp + row_info->rowbytes; /* end+1 */\n\n      while (sp < ep)\n      {\n         *dp++ = *sp;\n         sp += 2; /* skip low byte */\n      }\n\n      row_info->bit_depth = 8;\n      row_info->pixel_depth = (png_byte)(8 * row_info->channels);\n      row_info->rowbytes = row_info->width * row_info->channels;\n   }\n}\n#endif\n\n#ifdef PNG_READ_SWAP_ALPHA_SUPPORTED\nvoid /* PRIVATE */\npng_do_read_swap_alpha(png_row_infop row_info, png_bytep row)\n{\n   png_debug(1, \"in png_do_read_swap_alpha\");\n\n   {\n      png_uint_32 row_width = row_info->width;\n      if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)\n      {\n         /* This converts from RGBA to ARGB */\n         if (row_info->bit_depth == 8)\n         {\n            png_bytep sp = row + row_info->rowbytes;\n            png_bytep dp = sp;\n            png_byte save;\n            png_uint_32 i;\n\n            for (i = 0; i < row_width; i++)\n            {\n               save = *(--sp);\n               *(--dp) = *(--sp);\n               *(--dp) = *(--sp);\n               *(--dp) = *(--sp);\n               *(--dp) = save;\n            }\n         }\n\n#ifdef PNG_READ_16BIT_SUPPORTED\n         /* This converts from RRGGBBAA to AARRGGBB */\n         else\n         {\n            png_bytep sp = row + row_info->rowbytes;\n            png_bytep dp = sp;\n            png_byte save[2];\n            png_uint_32 i;\n\n            for (i = 0; i < row_width; i++)\n            {\n               save[0] = *(--sp);\n               save[1] = *(--sp);\n               *(--dp) = *(--sp);\n               *(--dp) = *(--sp);\n               *(--dp) = *(--sp);\n               *(--dp) = *(--sp);\n               *(--dp) = *(--sp);\n               *(--dp) = *(--sp);\n               *(--dp) = save[0];\n               *(--dp) = save[1];\n            }\n         }\n#endif\n      }\n\n      else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)\n      {\n         /* This converts from GA to AG */\n         if (row_info->bit_depth == 8)\n         {\n            png_bytep sp = row + row_info->rowbytes;\n            png_bytep dp = sp;\n            png_byte save;\n            png_uint_32 i;\n\n            for (i = 0; i < row_width; i++)\n            {\n               save = *(--sp);\n               *(--dp) = *(--sp);\n               *(--dp) = save;\n            }\n         }\n\n#ifdef PNG_READ_16BIT_SUPPORTED\n         /* This converts from GGAA to AAGG */\n         else\n         {\n            png_bytep sp = row + row_info->rowbytes;\n            png_bytep dp = sp;\n            png_byte save[2];\n            png_uint_32 i;\n\n            for (i = 0; i < row_width; i++)\n            {\n               save[0] = *(--sp);\n               save[1] = *(--sp);\n               *(--dp) = *(--sp);\n               *(--dp) = *(--sp);\n               *(--dp) = save[0];\n               *(--dp) = save[1];\n            }\n         }\n#endif\n      }\n   }\n}\n#endif\n\n#ifdef PNG_READ_INVERT_ALPHA_SUPPORTED\nvoid /* PRIVATE */\npng_do_read_invert_alpha(png_row_infop row_info, png_bytep row)\n{\n   png_uint_32 row_width;\n   png_debug(1, \"in png_do_read_invert_alpha\");\n\n   row_width = row_info->width;\n   if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)\n   {\n      if (row_info->bit_depth == 8)\n      {\n         /* This inverts the alpha channel in RGBA */\n         png_bytep sp = row + row_info->rowbytes;\n         png_bytep dp = sp;\n         png_uint_32 i;\n\n         for (i = 0; i < row_width; i++)\n         {\n            *(--dp) = (png_byte)(255 - *(--sp));\n\n/*          This does nothing:\n            *(--dp) = *(--sp);\n            *(--dp) = *(--sp);\n            *(--dp) = *(--sp);\n            We can replace it with:\n*/\n            sp-=3;\n            dp=sp;\n         }\n      }\n\n#ifdef PNG_READ_16BIT_SUPPORTED\n      /* This inverts the alpha channel in RRGGBBAA */\n      else\n      {\n         png_bytep sp = row + row_info->rowbytes;\n         png_bytep dp = sp;\n         png_uint_32 i;\n\n         for (i = 0; i < row_width; i++)\n         {\n            *(--dp) = (png_byte)(255 - *(--sp));\n            *(--dp) = (png_byte)(255 - *(--sp));\n\n/*          This does nothing:\n            *(--dp) = *(--sp);\n            *(--dp) = *(--sp);\n            *(--dp) = *(--sp);\n            *(--dp) = *(--sp);\n            *(--dp) = *(--sp);\n            *(--dp) = *(--sp);\n            We can replace it with:\n*/\n            sp-=6;\n            dp=sp;\n         }\n      }\n#endif\n   }\n   else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)\n   {\n      if (row_info->bit_depth == 8)\n      {\n         /* This inverts the alpha channel in GA */\n         png_bytep sp = row + row_info->rowbytes;\n         png_bytep dp = sp;\n         png_uint_32 i;\n\n         for (i = 0; i < row_width; i++)\n         {\n            *(--dp) = (png_byte)(255 - *(--sp));\n            *(--dp) = *(--sp);\n         }\n      }\n\n#ifdef PNG_READ_16BIT_SUPPORTED\n      else\n      {\n         /* This inverts the alpha channel in GGAA */\n         png_bytep sp  = row + row_info->rowbytes;\n         png_bytep dp = sp;\n         png_uint_32 i;\n\n         for (i = 0; i < row_width; i++)\n         {\n            *(--dp) = (png_byte)(255 - *(--sp));\n            *(--dp) = (png_byte)(255 - *(--sp));\n/*\n            *(--dp) = *(--sp);\n            *(--dp) = *(--sp);\n*/\n            sp-=2;\n            dp=sp;\n         }\n      }\n#endif\n   }\n}\n#endif\n\n#ifdef PNG_READ_FILLER_SUPPORTED\n/* Add filler channel if we have RGB color */\nvoid /* PRIVATE */\npng_do_read_filler(png_row_infop row_info, png_bytep row,\n    png_uint_32 filler, png_uint_32 flags)\n{\n   png_uint_32 i;\n   png_uint_32 row_width = row_info->width;\n\n#ifdef PNG_READ_16BIT_SUPPORTED\n   png_byte hi_filler = (png_byte)((filler>>8) & 0xff);\n#endif\n   png_byte lo_filler = (png_byte)(filler & 0xff);\n\n   png_debug(1, \"in png_do_read_filler\");\n\n   if (\n       row_info->color_type == PNG_COLOR_TYPE_GRAY)\n   {\n      if (row_info->bit_depth == 8)\n      {\n         if (flags & PNG_FLAG_FILLER_AFTER)\n         {\n            /* This changes the data from G to GX */\n            png_bytep sp = row + (png_size_t)row_width;\n            png_bytep dp =  sp + (png_size_t)row_width;\n            for (i = 1; i < row_width; i++)\n            {\n               *(--dp) = lo_filler;\n               *(--dp) = *(--sp);\n            }\n            *(--dp) = lo_filler;\n            row_info->channels = 2;\n            row_info->pixel_depth = 16;\n            row_info->rowbytes = row_width * 2;\n         }\n\n         else\n         {\n            /* This changes the data from G to XG */\n            png_bytep sp = row + (png_size_t)row_width;\n            png_bytep dp = sp  + (png_size_t)row_width;\n            for (i = 0; i < row_width; i++)\n            {\n               *(--dp) = *(--sp);\n               *(--dp) = lo_filler;\n            }\n            row_info->channels = 2;\n            row_info->pixel_depth = 16;\n            row_info->rowbytes = row_width * 2;\n         }\n      }\n\n#ifdef PNG_READ_16BIT_SUPPORTED\n      else if (row_info->bit_depth == 16)\n      {\n         if (flags & PNG_FLAG_FILLER_AFTER)\n         {\n            /* This changes the data from GG to GGXX */\n            png_bytep sp = row + (png_size_t)row_width * 2;\n            png_bytep dp = sp  + (png_size_t)row_width * 2;\n            for (i = 1; i < row_width; i++)\n            {\n               *(--dp) = hi_filler;\n               *(--dp) = lo_filler;\n               *(--dp) = *(--sp);\n               *(--dp) = *(--sp);\n            }\n            *(--dp) = hi_filler;\n            *(--dp) = lo_filler;\n            row_info->channels = 2;\n            row_info->pixel_depth = 32;\n            row_info->rowbytes = row_width * 4;\n         }\n\n         else\n         {\n            /* This changes the data from GG to XXGG */\n            png_bytep sp = row + (png_size_t)row_width * 2;\n            png_bytep dp = sp  + (png_size_t)row_width * 2;\n            for (i = 0; i < row_width; i++)\n            {\n               *(--dp) = *(--sp);\n               *(--dp) = *(--sp);\n               *(--dp) = hi_filler;\n               *(--dp) = lo_filler;\n            }\n            row_info->channels = 2;\n            row_info->pixel_depth = 32;\n            row_info->rowbytes = row_width * 4;\n         }\n      }\n#endif\n   } /* COLOR_TYPE == GRAY */\n   else if (row_info->color_type == PNG_COLOR_TYPE_RGB)\n   {\n      if (row_info->bit_depth == 8)\n      {\n         if (flags & PNG_FLAG_FILLER_AFTER)\n         {\n            /* This changes the data from RGB to RGBX */\n            png_bytep sp = row + (png_size_t)row_width * 3;\n            png_bytep dp = sp  + (png_size_t)row_width;\n            for (i = 1; i < row_width; i++)\n            {\n               *(--dp) = lo_filler;\n               *(--dp) = *(--sp);\n               *(--dp) = *(--sp);\n               *(--dp) = *(--sp);\n            }\n            *(--dp) = lo_filler;\n            row_info->channels = 4;\n            row_info->pixel_depth = 32;\n            row_info->rowbytes = row_width * 4;\n         }\n\n         else\n         {\n            /* This changes the data from RGB to XRGB */\n            png_bytep sp = row + (png_size_t)row_width * 3;\n            png_bytep dp = sp + (png_size_t)row_width;\n            for (i = 0; i < row_width; i++)\n            {\n               *(--dp) = *(--sp);\n               *(--dp) = *(--sp);\n               *(--dp) = *(--sp);\n               *(--dp) = lo_filler;\n            }\n            row_info->channels = 4;\n            row_info->pixel_depth = 32;\n            row_info->rowbytes = row_width * 4;\n         }\n      }\n\n#ifdef PNG_READ_16BIT_SUPPORTED\n      else if (row_info->bit_depth == 16)\n      {\n         if (flags & PNG_FLAG_FILLER_AFTER)\n         {\n            /* This changes the data from RRGGBB to RRGGBBXX */\n            png_bytep sp = row + (png_size_t)row_width * 6;\n            png_bytep dp = sp  + (png_size_t)row_width * 2;\n            for (i = 1; i < row_width; i++)\n            {\n               *(--dp) = hi_filler;\n               *(--dp) = lo_filler;\n               *(--dp) = *(--sp);\n               *(--dp) = *(--sp);\n               *(--dp) = *(--sp);\n               *(--dp) = *(--sp);\n               *(--dp) = *(--sp);\n               *(--dp) = *(--sp);\n            }\n            *(--dp) = hi_filler;\n            *(--dp) = lo_filler;\n            row_info->channels = 4;\n            row_info->pixel_depth = 64;\n            row_info->rowbytes = row_width * 8;\n         }\n\n         else\n         {\n            /* This changes the data from RRGGBB to XXRRGGBB */\n            png_bytep sp = row + (png_size_t)row_width * 6;\n            png_bytep dp = sp  + (png_size_t)row_width * 2;\n            for (i = 0; i < row_width; i++)\n            {\n               *(--dp) = *(--sp);\n               *(--dp) = *(--sp);\n               *(--dp) = *(--sp);\n               *(--dp) = *(--sp);\n               *(--dp) = *(--sp);\n               *(--dp) = *(--sp);\n               *(--dp) = hi_filler;\n               *(--dp) = lo_filler;\n            }\n\n            row_info->channels = 4;\n            row_info->pixel_depth = 64;\n            row_info->rowbytes = row_width * 8;\n         }\n      }\n#endif\n   } /* COLOR_TYPE == RGB */\n}\n#endif\n\n#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED\n/* Expand grayscale files to RGB, with or without alpha */\nvoid /* PRIVATE */\npng_do_gray_to_rgb(png_row_infop row_info, png_bytep row)\n{\n   png_uint_32 i;\n   png_uint_32 row_width = row_info->width;\n\n   png_debug(1, \"in png_do_gray_to_rgb\");\n\n   if (row_info->bit_depth >= 8 &&\n       !(row_info->color_type & PNG_COLOR_MASK_COLOR))\n   {\n      if (row_info->color_type == PNG_COLOR_TYPE_GRAY)\n      {\n         if (row_info->bit_depth == 8)\n         {\n            /* This changes G to RGB */\n            png_bytep sp = row + (png_size_t)row_width - 1;\n            png_bytep dp = sp  + (png_size_t)row_width * 2;\n            for (i = 0; i < row_width; i++)\n            {\n               *(dp--) = *sp;\n               *(dp--) = *sp;\n               *(dp--) = *(sp--);\n            }\n         }\n\n         else\n         {\n            /* This changes GG to RRGGBB */\n            png_bytep sp = row + (png_size_t)row_width * 2 - 1;\n            png_bytep dp = sp  + (png_size_t)row_width * 4;\n            for (i = 0; i < row_width; i++)\n            {\n               *(dp--) = *sp;\n               *(dp--) = *(sp - 1);\n               *(dp--) = *sp;\n               *(dp--) = *(sp - 1);\n               *(dp--) = *(sp--);\n               *(dp--) = *(sp--);\n            }\n         }\n      }\n\n      else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)\n      {\n         if (row_info->bit_depth == 8)\n         {\n            /* This changes GA to RGBA */\n            png_bytep sp = row + (png_size_t)row_width * 2 - 1;\n            png_bytep dp = sp  + (png_size_t)row_width * 2;\n            for (i = 0; i < row_width; i++)\n            {\n               *(dp--) = *(sp--);\n               *(dp--) = *sp;\n               *(dp--) = *sp;\n               *(dp--) = *(sp--);\n            }\n         }\n\n         else\n         {\n            /* This changes GGAA to RRGGBBAA */\n            png_bytep sp = row + (png_size_t)row_width * 4 - 1;\n            png_bytep dp = sp  + (png_size_t)row_width * 4;\n            for (i = 0; i < row_width; i++)\n            {\n               *(dp--) = *(sp--);\n               *(dp--) = *(sp--);\n               *(dp--) = *sp;\n               *(dp--) = *(sp - 1);\n               *(dp--) = *sp;\n               *(dp--) = *(sp - 1);\n               *(dp--) = *(sp--);\n               *(dp--) = *(sp--);\n            }\n         }\n      }\n      row_info->channels = (png_byte)(row_info->channels + 2);\n      row_info->color_type |= PNG_COLOR_MASK_COLOR;\n      row_info->pixel_depth = (png_byte)(row_info->channels *\n          row_info->bit_depth);\n      row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, row_width);\n   }\n}\n#endif\n\n#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED\n/* Reduce RGB files to grayscale, with or without alpha\n * using the equation given in Poynton's ColorFAQ of 1998-01-04 at\n * <http://www.inforamp.net/~poynton/>  (THIS LINK IS DEAD June 2008 but\n * versions dated 1998 through November 2002 have been archived at\n * http://web.archive.org/web/20000816232553/http://www.inforamp.net/\n * ~poynton/notes/colour_and_gamma/ColorFAQ.txt )\n * Charles Poynton poynton at poynton.com\n *\n *     Y = 0.212671 * R + 0.715160 * G + 0.072169 * B\n *\n *  which can be expressed with integers as\n *\n *     Y = (6969 * R + 23434 * G + 2365 * B)/32768\n *\n * Poynton's current link (as of January 2003 through July 2011):\n * <http://www.poynton.com/notes/colour_and_gamma/>\n * has changed the numbers slightly:\n *\n *     Y = 0.2126*R + 0.7152*G + 0.0722*B\n *\n *  which can be expressed with integers as\n *\n *     Y = (6966 * R + 23436 * G + 2366 * B)/32768\n *\n *  Historically, however, libpng uses numbers derived from the ITU-R Rec 709\n *  end point chromaticities and the D65 white point.  Depending on the\n *  precision used for the D65 white point this produces a variety of different\n *  numbers, however if the four decimal place value used in ITU-R Rec 709 is\n *  used (0.3127,0.3290) the Y calculation would be:\n *\n *     Y = (6968 * R + 23435 * G + 2366 * B)/32768\n *\n *  While this is correct the rounding results in an overflow for white, because\n *  the sum of the rounded coefficients is 32769, not 32768.  Consequently\n *  libpng uses, instead, the closest non-overflowing approximation:\n *\n *     Y = (6968 * R + 23434 * G + 2366 * B)/32768\n *\n *  Starting with libpng-1.5.5, if the image being converted has a cHRM chunk\n *  (including an sRGB chunk) then the chromaticities are used to calculate the\n *  coefficients.  See the chunk handling in pngrutil.c for more information.\n *\n *  In all cases the calculation is to be done in a linear colorspace.  If no\n *  gamma information is available to correct the encoding of the original RGB\n *  values this results in an implicit assumption that the original PNG RGB\n *  values were linear.\n *\n *  Other integer coefficents can be used via png_set_rgb_to_gray().  Because\n *  the API takes just red and green coefficients the blue coefficient is\n *  calculated to make the sum 32768.  This will result in different rounding\n *  to that used above.\n */\nint /* PRIVATE */\npng_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row)\n\n{\n   int rgb_error = 0;\n\n   png_debug(1, \"in png_do_rgb_to_gray\");\n\n   if (!(row_info->color_type & PNG_COLOR_MASK_PALETTE) &&\n       (row_info->color_type & PNG_COLOR_MASK_COLOR))\n   {\n      PNG_CONST png_uint_32 rc = png_ptr->rgb_to_gray_red_coeff;\n      PNG_CONST png_uint_32 gc = png_ptr->rgb_to_gray_green_coeff;\n      PNG_CONST png_uint_32 bc = 32768 - rc - gc;\n      PNG_CONST png_uint_32 row_width = row_info->width;\n      PNG_CONST int have_alpha =\n         (row_info->color_type & PNG_COLOR_MASK_ALPHA) != 0;\n\n      if (row_info->bit_depth == 8)\n      {\n#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)\n         /* Notice that gamma to/from 1 are not necessarily inverses (if\n          * there is an overall gamma correction).  Prior to 1.5.5 this code\n          * checked the linearized values for equality; this doesn't match\n          * the documentation, the original values must be checked.\n          */\n         if (png_ptr->gamma_from_1 != NULL && png_ptr->gamma_to_1 != NULL)\n         {\n            png_bytep sp = row;\n            png_bytep dp = row;\n            png_uint_32 i;\n\n            for (i = 0; i < row_width; i++)\n            {\n               png_byte red   = *(sp++);\n               png_byte green = *(sp++);\n               png_byte blue  = *(sp++);\n\n               if (red != green || red != blue)\n               {\n                  red = png_ptr->gamma_to_1[red];\n                  green = png_ptr->gamma_to_1[green];\n                  blue = png_ptr->gamma_to_1[blue];\n\n                  rgb_error |= 1;\n                  *(dp++) = png_ptr->gamma_from_1[\n                      (rc*red + gc*green + bc*blue + 16384)>>15];\n               }\n\n               else\n               {\n                  /* If there is no overall correction the table will not be\n                   * set.\n                   */\n                  if (png_ptr->gamma_table != NULL)\n                     red = png_ptr->gamma_table[red];\n\n                  *(dp++) = red;\n               }\n\n               if (have_alpha)\n                  *(dp++) = *(sp++);\n            }\n         }\n         else\n#endif\n         {\n            png_bytep sp = row;\n            png_bytep dp = row;\n            png_uint_32 i;\n\n            for (i = 0; i < row_width; i++)\n            {\n               png_byte red   = *(sp++);\n               png_byte green = *(sp++);\n               png_byte blue  = *(sp++);\n\n               if (red != green || red != blue)\n               {\n                  rgb_error |= 1;\n                  /*NOTE: this is the historical approach which simply\n                   * truncates the results.\n                   */\n                  *(dp++) = (png_byte)((rc*red + gc*green + bc*blue)>>15);\n               }\n\n               else\n                  *(dp++) = red;\n\n               if (have_alpha)\n                  *(dp++) = *(sp++);\n            }\n         }\n      }\n\n      else /* RGB bit_depth == 16 */\n      {\n#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)\n         if (png_ptr->gamma_16_to_1 != NULL && png_ptr->gamma_16_from_1 != NULL)\n         {\n            png_bytep sp = row;\n            png_bytep dp = row;\n            png_uint_32 i;\n\n            for (i = 0; i < row_width; i++)\n            {\n               png_uint_16 red, green, blue, w;\n\n               red   = (png_uint_16)(((*(sp))<<8) | *(sp + 1)); sp += 2;\n               green = (png_uint_16)(((*(sp))<<8) | *(sp + 1)); sp += 2;\n               blue  = (png_uint_16)(((*(sp))<<8) | *(sp + 1)); sp += 2;\n\n               if (red == green && red == blue)\n               {\n                  if (png_ptr->gamma_16_table != NULL)\n                     w = png_ptr->gamma_16_table[(red&0xff)\n                         >> png_ptr->gamma_shift][red>>8];\n\n                  else\n                     w = red;\n               }\n\n               else\n               {\n                  png_uint_16 red_1   = png_ptr->gamma_16_to_1[(red&0xff)\n                      >> png_ptr->gamma_shift][red>>8];\n                  png_uint_16 green_1 =\n                      png_ptr->gamma_16_to_1[(green&0xff) >>\n                      png_ptr->gamma_shift][green>>8];\n                  png_uint_16 blue_1  = png_ptr->gamma_16_to_1[(blue&0xff)\n                      >> png_ptr->gamma_shift][blue>>8];\n                  png_uint_16 gray16  = (png_uint_16)((rc*red_1 + gc*green_1\n                      + bc*blue_1 + 16384)>>15);\n                  w = png_ptr->gamma_16_from_1[(gray16&0xff) >>\n                      png_ptr->gamma_shift][gray16 >> 8];\n                  rgb_error |= 1;\n               }\n\n               *(dp++) = (png_byte)((w>>8) & 0xff);\n               *(dp++) = (png_byte)(w & 0xff);\n\n               if (have_alpha)\n               {\n                  *(dp++) = *(sp++);\n                  *(dp++) = *(sp++);\n               }\n            }\n         }\n         else\n#endif\n         {\n            png_bytep sp = row;\n            png_bytep dp = row;\n            png_uint_32 i;\n\n            for (i = 0; i < row_width; i++)\n            {\n               png_uint_16 red, green, blue, gray16;\n\n               red   = (png_uint_16)(((*(sp))<<8) | *(sp + 1)); sp += 2;\n               green = (png_uint_16)(((*(sp))<<8) | *(sp + 1)); sp += 2;\n               blue  = (png_uint_16)(((*(sp))<<8) | *(sp + 1)); sp += 2;\n\n               if (red != green || red != blue)\n                  rgb_error |= 1;\n\n               /* From 1.5.5 in the 16 bit case do the accurate conversion even\n                * in the 'fast' case - this is because this is where the code\n                * ends up when handling linear 16 bit data.\n                */\n               gray16  = (png_uint_16)((rc*red + gc*green + bc*blue + 16384) >>\n                  15);\n               *(dp++) = (png_byte)((gray16>>8) & 0xff);\n               *(dp++) = (png_byte)(gray16 & 0xff);\n\n               if (have_alpha)\n               {\n                  *(dp++) = *(sp++);\n                  *(dp++) = *(sp++);\n               }\n            }\n         }\n      }\n\n      row_info->channels = (png_byte)(row_info->channels - 2);\n      row_info->color_type = (png_byte)(row_info->color_type &\n          ~PNG_COLOR_MASK_COLOR);\n      row_info->pixel_depth = (png_byte)(row_info->channels *\n          row_info->bit_depth);\n      row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, row_width);\n   }\n   return rgb_error;\n}\n#endif\n#endif /* PNG_READ_TRANSFORMS_SUPPORTED */\n\n#ifdef PNG_BUILD_GRAYSCALE_PALETTE_SUPPORTED\n/* Build a grayscale palette.  Palette is assumed to be 1 << bit_depth\n * large of png_color.  This lets grayscale images be treated as\n * paletted.  Most useful for gamma correction and simplification\n * of code.  This API is not used internally.\n */\nvoid PNGAPI\npng_build_grayscale_palette(int bit_depth, png_colorp palette)\n{\n   int num_palette;\n   int color_inc;\n   int i;\n   int v;\n\n   png_debug(1, \"in png_do_build_grayscale_palette\");\n\n   if (palette == NULL)\n      return;\n\n   switch (bit_depth)\n   {\n      case 1:\n         num_palette = 2;\n         color_inc = 0xff;\n         break;\n\n      case 2:\n         num_palette = 4;\n         color_inc = 0x55;\n         break;\n\n      case 4:\n         num_palette = 16;\n         color_inc = 0x11;\n         break;\n\n      case 8:\n         num_palette = 256;\n         color_inc = 1;\n         break;\n\n      default:\n         num_palette = 0;\n         color_inc = 0;\n         break;\n   }\n\n   for (i = 0, v = 0; i < num_palette; i++, v += color_inc)\n   {\n      palette[i].red = (png_byte)v;\n      palette[i].green = (png_byte)v;\n      palette[i].blue = (png_byte)v;\n   }\n}\n#endif\n\n\n#ifdef PNG_READ_TRANSFORMS_SUPPORTED\n#if (defined PNG_READ_BACKGROUND_SUPPORTED) ||\\\n   (defined PNG_READ_ALPHA_MODE_SUPPORTED)\n/* Replace any alpha or transparency with the supplied background color.\n * \"background\" is already in the screen gamma, while \"background_1\" is\n * at a gamma of 1.0.  Paletted files have already been taken care of.\n */\nvoid /* PRIVATE */\npng_do_compose(png_row_infop row_info, png_bytep row, png_structp png_ptr)\n{\n#ifdef PNG_READ_GAMMA_SUPPORTED\n   png_const_bytep gamma_table = png_ptr->gamma_table;\n   png_const_bytep gamma_from_1 = png_ptr->gamma_from_1;\n   png_const_bytep gamma_to_1 = png_ptr->gamma_to_1;\n   png_const_uint_16pp gamma_16 = png_ptr->gamma_16_table;\n   png_const_uint_16pp gamma_16_from_1 = png_ptr->gamma_16_from_1;\n   png_const_uint_16pp gamma_16_to_1 = png_ptr->gamma_16_to_1;\n   int gamma_shift = png_ptr->gamma_shift;\n#endif\n\n   png_bytep sp;\n   png_uint_32 i;\n   png_uint_32 row_width = row_info->width;\n   int optimize = (png_ptr->flags & PNG_FLAG_OPTIMIZE_ALPHA) != 0;\n   int shift;\n\n   png_debug(1, \"in png_do_compose\");\n\n   {\n      switch (row_info->color_type)\n      {\n         case PNG_COLOR_TYPE_GRAY:\n         {\n            switch (row_info->bit_depth)\n            {\n               case 1:\n               {\n                  sp = row;\n                  shift = 7;\n                  for (i = 0; i < row_width; i++)\n                  {\n                     if ((png_uint_16)((*sp >> shift) & 0x01)\n                        == png_ptr->trans_color.gray)\n                     {\n                        *sp &= (png_byte)((0x7f7f >> (7 - shift)) & 0xff);\n                        *sp |= (png_byte)(png_ptr->background.gray << shift);\n                     }\n\n                     if (!shift)\n                     {\n                        shift = 7;\n                        sp++;\n                     }\n\n                     else\n                        shift--;\n                  }\n                  break;\n               }\n\n               case 2:\n               {\n#ifdef PNG_READ_GAMMA_SUPPORTED\n                  if (gamma_table != NULL)\n                  {\n                     sp = row;\n                     shift = 6;\n                     for (i = 0; i < row_width; i++)\n                     {\n                        if ((png_uint_16)((*sp >> shift) & 0x03)\n                            == png_ptr->trans_color.gray)\n                        {\n                           *sp &= (png_byte)((0x3f3f >> (6 - shift)) & 0xff);\n                           *sp |= (png_byte)(png_ptr->background.gray << shift);\n                        }\n\n                        else\n                        {\n                           png_byte p = (png_byte)((*sp >> shift) & 0x03);\n                           png_byte g = (png_byte)((gamma_table [p | (p << 2) |\n                               (p << 4) | (p << 6)] >> 6) & 0x03);\n                           *sp &= (png_byte)((0x3f3f >> (6 - shift)) & 0xff);\n                           *sp |= (png_byte)(g << shift);\n                        }\n\n                        if (!shift)\n                        {\n                           shift = 6;\n                           sp++;\n                        }\n\n                        else\n                           shift -= 2;\n                     }\n                  }\n\n                  else\n#endif\n                  {\n                     sp = row;\n                     shift = 6;\n                     for (i = 0; i < row_width; i++)\n                     {\n                        if ((png_uint_16)((*sp >> shift) & 0x03)\n                            == png_ptr->trans_color.gray)\n                        {\n                           *sp &= (png_byte)((0x3f3f >> (6 - shift)) & 0xff);\n                           *sp |= (png_byte)(png_ptr->background.gray << shift);\n                        }\n\n                        if (!shift)\n                        {\n                           shift = 6;\n                           sp++;\n                        }\n\n                        else\n                           shift -= 2;\n                     }\n                  }\n                  break;\n               }\n\n               case 4:\n               {\n#ifdef PNG_READ_GAMMA_SUPPORTED\n                  if (gamma_table != NULL)\n                  {\n                     sp = row;\n                     shift = 4;\n                     for (i = 0; i < row_width; i++)\n                     {\n                        if ((png_uint_16)((*sp >> shift) & 0x0f)\n                            == png_ptr->trans_color.gray)\n                        {\n                           *sp &= (png_byte)((0xf0f >> (4 - shift)) & 0xff);\n                           *sp |= (png_byte)(png_ptr->background.gray << shift);\n                        }\n\n                        else\n                        {\n                           png_byte p = (png_byte)((*sp >> shift) & 0x0f);\n                           png_byte g = (png_byte)((gamma_table[p |\n                               (p << 4)] >> 4) & 0x0f);\n                           *sp &= (png_byte)((0xf0f >> (4 - shift)) & 0xff);\n                           *sp |= (png_byte)(g << shift);\n                        }\n\n                        if (!shift)\n                        {\n                           shift = 4;\n                           sp++;\n                        }\n\n                        else\n                           shift -= 4;\n                     }\n                  }\n\n                  else\n#endif\n                  {\n                     sp = row;\n                     shift = 4;\n                     for (i = 0; i < row_width; i++)\n                     {\n                        if ((png_uint_16)((*sp >> shift) & 0x0f)\n                            == png_ptr->trans_color.gray)\n                        {\n                           *sp &= (png_byte)((0xf0f >> (4 - shift)) & 0xff);\n                           *sp |= (png_byte)(png_ptr->background.gray << shift);\n                        }\n\n                        if (!shift)\n                        {\n                           shift = 4;\n                           sp++;\n                        }\n\n                        else\n                           shift -= 4;\n                     }\n                  }\n                  break;\n               }\n\n               case 8:\n               {\n#ifdef PNG_READ_GAMMA_SUPPORTED\n                  if (gamma_table != NULL)\n                  {\n                     sp = row;\n                     for (i = 0; i < row_width; i++, sp++)\n                     {\n                        if (*sp == png_ptr->trans_color.gray)\n                           *sp = (png_byte)png_ptr->background.gray;\n\n                        else\n                           *sp = gamma_table[*sp];\n                     }\n                  }\n                  else\n#endif\n                  {\n                     sp = row;\n                     for (i = 0; i < row_width; i++, sp++)\n                     {\n                        if (*sp == png_ptr->trans_color.gray)\n                           *sp = (png_byte)png_ptr->background.gray;\n                     }\n                  }\n                  break;\n               }\n\n               case 16:\n               {\n#ifdef PNG_READ_GAMMA_SUPPORTED\n                  if (gamma_16 != NULL)\n                  {\n                     sp = row;\n                     for (i = 0; i < row_width; i++, sp += 2)\n                     {\n                        png_uint_16 v;\n\n                        v = (png_uint_16)(((*sp) << 8) + *(sp + 1));\n\n                        if (v == png_ptr->trans_color.gray)\n                        {\n                           /* Background is already in screen gamma */\n                           *sp = (png_byte)((png_ptr->background.gray >> 8) & 0xff);\n                           *(sp + 1) = (png_byte)(png_ptr->background.gray & 0xff);\n                        }\n\n                        else\n                        {\n                           v = gamma_16[*(sp + 1) >> gamma_shift][*sp];\n                           *sp = (png_byte)((v >> 8) & 0xff);\n                           *(sp + 1) = (png_byte)(v & 0xff);\n                        }\n                     }\n                  }\n                  else\n#endif\n                  {\n                     sp = row;\n                     for (i = 0; i < row_width; i++, sp += 2)\n                     {\n                        png_uint_16 v;\n\n                        v = (png_uint_16)(((*sp) << 8) + *(sp + 1));\n\n                        if (v == png_ptr->trans_color.gray)\n                        {\n                           *sp = (png_byte)((png_ptr->background.gray >> 8) & 0xff);\n                           *(sp + 1) = (png_byte)(png_ptr->background.gray & 0xff);\n                        }\n                     }\n                  }\n                  break;\n               }\n\n               default:\n                  break;\n            }\n            break;\n         }\n\n         case PNG_COLOR_TYPE_RGB:\n         {\n            if (row_info->bit_depth == 8)\n            {\n#ifdef PNG_READ_GAMMA_SUPPORTED\n               if (gamma_table != NULL)\n               {\n                  sp = row;\n                  for (i = 0; i < row_width; i++, sp += 3)\n                  {\n                     if (*sp == png_ptr->trans_color.red &&\n                         *(sp + 1) == png_ptr->trans_color.green &&\n                         *(sp + 2) == png_ptr->trans_color.blue)\n                     {\n                        *sp = (png_byte)png_ptr->background.red;\n                        *(sp + 1) = (png_byte)png_ptr->background.green;\n                        *(sp + 2) = (png_byte)png_ptr->background.blue;\n                     }\n\n                     else\n                     {\n                        *sp = gamma_table[*sp];\n                        *(sp + 1) = gamma_table[*(sp + 1)];\n                        *(sp + 2) = gamma_table[*(sp + 2)];\n                     }\n                  }\n               }\n               else\n#endif\n               {\n                  sp = row;\n                  for (i = 0; i < row_width; i++, sp += 3)\n                  {\n                     if (*sp == png_ptr->trans_color.red &&\n                         *(sp + 1) == png_ptr->trans_color.green &&\n                         *(sp + 2) == png_ptr->trans_color.blue)\n                     {\n                        *sp = (png_byte)png_ptr->background.red;\n                        *(sp + 1) = (png_byte)png_ptr->background.green;\n                        *(sp + 2) = (png_byte)png_ptr->background.blue;\n                     }\n                  }\n               }\n            }\n            else /* if (row_info->bit_depth == 16) */\n            {\n#ifdef PNG_READ_GAMMA_SUPPORTED\n               if (gamma_16 != NULL)\n               {\n                  sp = row;\n                  for (i = 0; i < row_width; i++, sp += 6)\n                  {\n                     png_uint_16 r = (png_uint_16)(((*sp) << 8) + *(sp + 1));\n\n                     png_uint_16 g = (png_uint_16)(((*(sp + 2)) << 8)\n                         + *(sp + 3));\n\n                     png_uint_16 b = (png_uint_16)(((*(sp + 4)) << 8)\n                         + *(sp + 5));\n\n                     if (r == png_ptr->trans_color.red &&\n                         g == png_ptr->trans_color.green &&\n                         b == png_ptr->trans_color.blue)\n                     {\n                        /* Background is already in screen gamma */\n                        *sp = (png_byte)((png_ptr->background.red >> 8) & 0xff);\n                        *(sp + 1) = (png_byte)(png_ptr->background.red & 0xff);\n                        *(sp + 2) = (png_byte)((png_ptr->background.green >> 8) & 0xff);\n                        *(sp + 3) = (png_byte)(png_ptr->background.green & 0xff);\n                        *(sp + 4) = (png_byte)((png_ptr->background.blue >> 8) & 0xff);\n                        *(sp + 5) = (png_byte)(png_ptr->background.blue & 0xff);\n                     }\n\n                     else\n                     {\n                        png_uint_16 v = gamma_16[*(sp + 1) >> gamma_shift][*sp];\n                        *sp = (png_byte)((v >> 8) & 0xff);\n                        *(sp + 1) = (png_byte)(v & 0xff);\n\n                        v = gamma_16[*(sp + 3) >> gamma_shift][*(sp + 2)];\n                        *(sp + 2) = (png_byte)((v >> 8) & 0xff);\n                        *(sp + 3) = (png_byte)(v & 0xff);\n\n                        v = gamma_16[*(sp + 5) >> gamma_shift][*(sp + 4)];\n                        *(sp + 4) = (png_byte)((v >> 8) & 0xff);\n                        *(sp + 5) = (png_byte)(v & 0xff);\n                     }\n                  }\n               }\n\n               else\n#endif\n               {\n                  sp = row;\n                  for (i = 0; i < row_width; i++, sp += 6)\n                  {\n                     png_uint_16 r = (png_uint_16)(((*sp) << 8) + *(sp + 1));\n\n                     png_uint_16 g = (png_uint_16)(((*(sp + 2)) << 8)\n                         + *(sp + 3));\n\n                     png_uint_16 b = (png_uint_16)(((*(sp + 4)) << 8)\n                         + *(sp + 5));\n\n                     if (r == png_ptr->trans_color.red &&\n                         g == png_ptr->trans_color.green &&\n                         b == png_ptr->trans_color.blue)\n                     {\n                        *sp = (png_byte)((png_ptr->background.red >> 8) & 0xff);\n                        *(sp + 1) = (png_byte)(png_ptr->background.red & 0xff);\n                        *(sp + 2) = (png_byte)((png_ptr->background.green >> 8) & 0xff);\n                        *(sp + 3) = (png_byte)(png_ptr->background.green & 0xff);\n                        *(sp + 4) = (png_byte)((png_ptr->background.blue >> 8) & 0xff);\n                        *(sp + 5) = (png_byte)(png_ptr->background.blue & 0xff);\n                     }\n                  }\n               }\n            }\n            break;\n         }\n\n         case PNG_COLOR_TYPE_GRAY_ALPHA:\n         {\n            if (row_info->bit_depth == 8)\n            {\n#ifdef PNG_READ_GAMMA_SUPPORTED\n               if (gamma_to_1 != NULL && gamma_from_1 != NULL &&\n                   gamma_table != NULL)\n               {\n                  sp = row;\n                  for (i = 0; i < row_width; i++, sp += 2)\n                  {\n                     png_uint_16 a = *(sp + 1);\n\n                     if (a == 0xff)\n                        *sp = gamma_table[*sp];\n\n                     else if (a == 0)\n                     {\n                        /* Background is already in screen gamma */\n                        *sp = (png_byte)png_ptr->background.gray;\n                     }\n\n                     else\n                     {\n                        png_byte v, w;\n\n                        v = gamma_to_1[*sp];\n                        png_composite(w, v, a, png_ptr->background_1.gray);\n                        if (!optimize)\n                           w = gamma_from_1[w];\n                        *sp = w;\n                     }\n                  }\n               }\n               else\n#endif\n               {\n                  sp = row;\n                  for (i = 0; i < row_width; i++, sp += 2)\n                  {\n                     png_byte a = *(sp + 1);\n\n                     if (a == 0)\n                        *sp = (png_byte)png_ptr->background.gray;\n\n                     else if (a < 0xff)\n                        png_composite(*sp, *sp, a, png_ptr->background_1.gray);\n                  }\n               }\n            }\n            else /* if (png_ptr->bit_depth == 16) */\n            {\n#ifdef PNG_READ_GAMMA_SUPPORTED\n               if (gamma_16 != NULL && gamma_16_from_1 != NULL &&\n                   gamma_16_to_1 != NULL)\n               {\n                  sp = row;\n                  for (i = 0; i < row_width; i++, sp += 4)\n                  {\n                     png_uint_16 a = (png_uint_16)(((*(sp + 2)) << 8)\n                         + *(sp + 3));\n\n                     if (a == (png_uint_16)0xffff)\n                     {\n                        png_uint_16 v;\n\n                        v = gamma_16[*(sp + 1) >> gamma_shift][*sp];\n                        *sp = (png_byte)((v >> 8) & 0xff);\n                        *(sp + 1) = (png_byte)(v & 0xff);\n                     }\n\n                     else if (a == 0)\n                     {\n                        /* Background is already in screen gamma */\n                        *sp = (png_byte)((png_ptr->background.gray >> 8) & 0xff);\n                        *(sp + 1) = (png_byte)(png_ptr->background.gray & 0xff);\n                     }\n\n                     else\n                     {\n                        png_uint_16 g, v, w;\n\n                        g = gamma_16_to_1[*(sp + 1) >> gamma_shift][*sp];\n                        png_composite_16(v, g, a, png_ptr->background_1.gray);\n                        if (optimize)\n                           w = v;\n                        else\n                           w = gamma_16_from_1[(v&0xff) >> gamma_shift][v >> 8];\n                        *sp = (png_byte)((w >> 8) & 0xff);\n                        *(sp + 1) = (png_byte)(w & 0xff);\n                     }\n                  }\n               }\n               else\n#endif\n               {\n                  sp = row;\n                  for (i = 0; i < row_width; i++, sp += 4)\n                  {\n                     png_uint_16 a = (png_uint_16)(((*(sp + 2)) << 8)\n                         + *(sp + 3));\n\n                     if (a == 0)\n                     {\n                        *sp = (png_byte)((png_ptr->background.gray >> 8) & 0xff);\n                        *(sp + 1) = (png_byte)(png_ptr->background.gray & 0xff);\n                     }\n\n                     else if (a < 0xffff)\n                     {\n                        png_uint_16 g, v;\n\n                        g = (png_uint_16)(((*sp) << 8) + *(sp + 1));\n                        png_composite_16(v, g, a, png_ptr->background_1.gray);\n                        *sp = (png_byte)((v >> 8) & 0xff);\n                        *(sp + 1) = (png_byte)(v & 0xff);\n                     }\n                  }\n               }\n            }\n            break;\n         }\n\n         case PNG_COLOR_TYPE_RGB_ALPHA:\n         {\n            if (row_info->bit_depth == 8)\n            {\n#ifdef PNG_READ_GAMMA_SUPPORTED\n               if (gamma_to_1 != NULL && gamma_from_1 != NULL &&\n                   gamma_table != NULL)\n               {\n                  sp = row;\n                  for (i = 0; i < row_width; i++, sp += 4)\n                  {\n                     png_byte a = *(sp + 3);\n\n                     if (a == 0xff)\n                     {\n                        *sp = gamma_table[*sp];\n                        *(sp + 1) = gamma_table[*(sp + 1)];\n                        *(sp + 2) = gamma_table[*(sp + 2)];\n                     }\n\n                     else if (a == 0)\n                     {\n                        /* Background is already in screen gamma */\n                        *sp = (png_byte)png_ptr->background.red;\n                        *(sp + 1) = (png_byte)png_ptr->background.green;\n                        *(sp + 2) = (png_byte)png_ptr->background.blue;\n                     }\n\n                     else\n                     {\n                        png_byte v, w;\n\n                        v = gamma_to_1[*sp];\n                        png_composite(w, v, a, png_ptr->background_1.red);\n                        if (!optimize) w = gamma_from_1[w];\n                        *sp = w;\n\n                        v = gamma_to_1[*(sp + 1)];\n                        png_composite(w, v, a, png_ptr->background_1.green);\n                        if (!optimize) w = gamma_from_1[w];\n                        *(sp + 1) = w;\n\n                        v = gamma_to_1[*(sp + 2)];\n                        png_composite(w, v, a, png_ptr->background_1.blue);\n                        if (!optimize) w = gamma_from_1[w];\n                        *(sp + 2) = w;\n                     }\n                  }\n               }\n               else\n#endif\n               {\n                  sp = row;\n                  for (i = 0; i < row_width; i++, sp += 4)\n                  {\n                     png_byte a = *(sp + 3);\n\n                     if (a == 0)\n                     {\n                        *sp = (png_byte)png_ptr->background.red;\n                        *(sp + 1) = (png_byte)png_ptr->background.green;\n                        *(sp + 2) = (png_byte)png_ptr->background.blue;\n                     }\n\n                     else if (a < 0xff)\n                     {\n                        png_composite(*sp, *sp, a, png_ptr->background.red);\n\n                        png_composite(*(sp + 1), *(sp + 1), a,\n                            png_ptr->background.green);\n\n                        png_composite(*(sp + 2), *(sp + 2), a,\n                            png_ptr->background.blue);\n                     }\n                  }\n               }\n            }\n            else /* if (row_info->bit_depth == 16) */\n            {\n#ifdef PNG_READ_GAMMA_SUPPORTED\n               if (gamma_16 != NULL && gamma_16_from_1 != NULL &&\n                   gamma_16_to_1 != NULL)\n               {\n                  sp = row;\n                  for (i = 0; i < row_width; i++, sp += 8)\n                  {\n                     png_uint_16 a = (png_uint_16)(((png_uint_16)(*(sp + 6))\n                         << 8) + (png_uint_16)(*(sp + 7)));\n\n                     if (a == (png_uint_16)0xffff)\n                     {\n                        png_uint_16 v;\n\n                        v = gamma_16[*(sp + 1) >> gamma_shift][*sp];\n                        *sp = (png_byte)((v >> 8) & 0xff);\n                        *(sp + 1) = (png_byte)(v & 0xff);\n\n                        v = gamma_16[*(sp + 3) >> gamma_shift][*(sp + 2)];\n                        *(sp + 2) = (png_byte)((v >> 8) & 0xff);\n                        *(sp + 3) = (png_byte)(v & 0xff);\n\n                        v = gamma_16[*(sp + 5) >> gamma_shift][*(sp + 4)];\n                        *(sp + 4) = (png_byte)((v >> 8) & 0xff);\n                        *(sp + 5) = (png_byte)(v & 0xff);\n                     }\n\n                     else if (a == 0)\n                     {\n                        /* Background is already in screen gamma */\n                        *sp = (png_byte)((png_ptr->background.red >> 8) & 0xff);\n                        *(sp + 1) = (png_byte)(png_ptr->background.red & 0xff);\n                        *(sp + 2) = (png_byte)((png_ptr->background.green >> 8) & 0xff);\n                        *(sp + 3) = (png_byte)(png_ptr->background.green & 0xff);\n                        *(sp + 4) = (png_byte)((png_ptr->background.blue >> 8) & 0xff);\n                        *(sp + 5) = (png_byte)(png_ptr->background.blue & 0xff);\n                     }\n\n                     else\n                     {\n                        png_uint_16 v, w;\n\n                        v = gamma_16_to_1[*(sp + 1) >> gamma_shift][*sp];\n                        png_composite_16(w, v, a, png_ptr->background_1.red);\n                        if (!optimize)\n                           w = gamma_16_from_1[((w&0xff) >> gamma_shift)][w >> 8];\n                        *sp = (png_byte)((w >> 8) & 0xff);\n                        *(sp + 1) = (png_byte)(w & 0xff);\n\n                        v = gamma_16_to_1[*(sp + 3) >> gamma_shift][*(sp + 2)];\n                        png_composite_16(w, v, a, png_ptr->background_1.green);\n                        if (!optimize)\n                           w = gamma_16_from_1[((w&0xff) >> gamma_shift)][w >> 8];\n\n                        *(sp + 2) = (png_byte)((w >> 8) & 0xff);\n                        *(sp + 3) = (png_byte)(w & 0xff);\n\n                        v = gamma_16_to_1[*(sp + 5) >> gamma_shift][*(sp + 4)];\n                        png_composite_16(w, v, a, png_ptr->background_1.blue);\n                        if (!optimize)\n                           w = gamma_16_from_1[((w&0xff) >> gamma_shift)][w >> 8];\n\n                        *(sp + 4) = (png_byte)((w >> 8) & 0xff);\n                        *(sp + 5) = (png_byte)(w & 0xff);\n                     }\n                  }\n               }\n\n               else\n#endif\n               {\n                  sp = row;\n                  for (i = 0; i < row_width; i++, sp += 8)\n                  {\n                     png_uint_16 a = (png_uint_16)(((png_uint_16)(*(sp + 6))\n                         << 8) + (png_uint_16)(*(sp + 7)));\n\n                     if (a == 0)\n                     {\n                        *sp = (png_byte)((png_ptr->background.red >> 8) & 0xff);\n                        *(sp + 1) = (png_byte)(png_ptr->background.red & 0xff);\n                        *(sp + 2) = (png_byte)((png_ptr->background.green >> 8) & 0xff);\n                        *(sp + 3) = (png_byte)(png_ptr->background.green & 0xff);\n                        *(sp + 4) = (png_byte)((png_ptr->background.blue >> 8) & 0xff);\n                        *(sp + 5) = (png_byte)(png_ptr->background.blue & 0xff);\n                     }\n\n                     else if (a < 0xffff)\n                     {\n                        png_uint_16 v;\n\n                        png_uint_16 r = (png_uint_16)(((*sp) << 8) + *(sp + 1));\n                        png_uint_16 g = (png_uint_16)(((*(sp + 2)) << 8)\n                            + *(sp + 3));\n                        png_uint_16 b = (png_uint_16)(((*(sp + 4)) << 8)\n                            + *(sp + 5));\n\n                        png_composite_16(v, r, a, png_ptr->background.red);\n                        *sp = (png_byte)((v >> 8) & 0xff);\n                        *(sp + 1) = (png_byte)(v & 0xff);\n\n                        png_composite_16(v, g, a, png_ptr->background.green);\n                        *(sp + 2) = (png_byte)((v >> 8) & 0xff);\n                        *(sp + 3) = (png_byte)(v & 0xff);\n\n                        png_composite_16(v, b, a, png_ptr->background.blue);\n                        *(sp + 4) = (png_byte)((v >> 8) & 0xff);\n                        *(sp + 5) = (png_byte)(v & 0xff);\n                     }\n                  }\n               }\n            }\n            break;\n         }\n\n         default:\n            break;\n      }\n   }\n}\n#endif /* PNG_READ_BACKGROUND_SUPPORTED || PNG_READ_ALPHA_MODE_SUPPORTED */\n\n#ifdef PNG_READ_GAMMA_SUPPORTED\n/* Gamma correct the image, avoiding the alpha channel.  Make sure\n * you do this after you deal with the transparency issue on grayscale\n * or RGB images. If your bit depth is 8, use gamma_table, if it\n * is 16, use gamma_16_table and gamma_shift.  Build these with\n * build_gamma_table().\n */\nvoid /* PRIVATE */\npng_do_gamma(png_row_infop row_info, png_bytep row, png_structp png_ptr)\n{\n   png_const_bytep gamma_table = png_ptr->gamma_table;\n   png_const_uint_16pp gamma_16_table = png_ptr->gamma_16_table;\n   int gamma_shift = png_ptr->gamma_shift;\n\n   png_bytep sp;\n   png_uint_32 i;\n   png_uint_32 row_width=row_info->width;\n\n   png_debug(1, \"in png_do_gamma\");\n\n   if (((row_info->bit_depth <= 8 && gamma_table != NULL) ||\n       (row_info->bit_depth == 16 && gamma_16_table != NULL)))\n   {\n      switch (row_info->color_type)\n      {\n         case PNG_COLOR_TYPE_RGB:\n         {\n            if (row_info->bit_depth == 8)\n            {\n               sp = row;\n               for (i = 0; i < row_width; i++)\n               {\n                  *sp = gamma_table[*sp];\n                  sp++;\n                  *sp = gamma_table[*sp];\n                  sp++;\n                  *sp = gamma_table[*sp];\n                  sp++;\n               }\n            }\n\n            else /* if (row_info->bit_depth == 16) */\n            {\n               sp = row;\n               for (i = 0; i < row_width; i++)\n               {\n                  png_uint_16 v;\n\n                  v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp];\n                  *sp = (png_byte)((v >> 8) & 0xff);\n                  *(sp + 1) = (png_byte)(v & 0xff);\n                  sp += 2;\n\n                  v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp];\n                  *sp = (png_byte)((v >> 8) & 0xff);\n                  *(sp + 1) = (png_byte)(v & 0xff);\n                  sp += 2;\n\n                  v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp];\n                  *sp = (png_byte)((v >> 8) & 0xff);\n                  *(sp + 1) = (png_byte)(v & 0xff);\n                  sp += 2;\n               }\n            }\n            break;\n         }\n\n         case PNG_COLOR_TYPE_RGB_ALPHA:\n         {\n            if (row_info->bit_depth == 8)\n            {\n               sp = row;\n               for (i = 0; i < row_width; i++)\n               {\n                  *sp = gamma_table[*sp];\n                  sp++;\n\n                  *sp = gamma_table[*sp];\n                  sp++;\n\n                  *sp = gamma_table[*sp];\n                  sp++;\n\n                  sp++;\n               }\n            }\n\n            else /* if (row_info->bit_depth == 16) */\n            {\n               sp = row;\n               for (i = 0; i < row_width; i++)\n               {\n                  png_uint_16 v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp];\n                  *sp = (png_byte)((v >> 8) & 0xff);\n                  *(sp + 1) = (png_byte)(v & 0xff);\n                  sp += 2;\n\n                  v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp];\n                  *sp = (png_byte)((v >> 8) & 0xff);\n                  *(sp + 1) = (png_byte)(v & 0xff);\n                  sp += 2;\n\n                  v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp];\n                  *sp = (png_byte)((v >> 8) & 0xff);\n                  *(sp + 1) = (png_byte)(v & 0xff);\n                  sp += 4;\n               }\n            }\n            break;\n         }\n\n         case PNG_COLOR_TYPE_GRAY_ALPHA:\n         {\n            if (row_info->bit_depth == 8)\n            {\n               sp = row;\n               for (i = 0; i < row_width; i++)\n               {\n                  *sp = gamma_table[*sp];\n                  sp += 2;\n               }\n            }\n\n            else /* if (row_info->bit_depth == 16) */\n            {\n               sp = row;\n               for (i = 0; i < row_width; i++)\n               {\n                  png_uint_16 v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp];\n                  *sp = (png_byte)((v >> 8) & 0xff);\n                  *(sp + 1) = (png_byte)(v & 0xff);\n                  sp += 4;\n               }\n            }\n            break;\n         }\n\n         case PNG_COLOR_TYPE_GRAY:\n         {\n            if (row_info->bit_depth == 2)\n            {\n               sp = row;\n               for (i = 0; i < row_width; i += 4)\n               {\n                  int a = *sp & 0xc0;\n                  int b = *sp & 0x30;\n                  int c = *sp & 0x0c;\n                  int d = *sp & 0x03;\n\n                  *sp = (png_byte)(\n                      ((((int)gamma_table[a|(a>>2)|(a>>4)|(a>>6)])   ) & 0xc0)|\n                      ((((int)gamma_table[(b<<2)|b|(b>>2)|(b>>4)])>>2) & 0x30)|\n                      ((((int)gamma_table[(c<<4)|(c<<2)|c|(c>>2)])>>4) & 0x0c)|\n                      ((((int)gamma_table[(d<<6)|(d<<4)|(d<<2)|d])>>6) ));\n                  sp++;\n               }\n            }\n\n            if (row_info->bit_depth == 4)\n            {\n               sp = row;\n               for (i = 0; i < row_width; i += 2)\n               {\n                  int msb = *sp & 0xf0;\n                  int lsb = *sp & 0x0f;\n\n                  *sp = (png_byte)((((int)gamma_table[msb | (msb >> 4)]) & 0xf0)\n                      | (((int)gamma_table[(lsb << 4) | lsb]) >> 4));\n                  sp++;\n               }\n            }\n\n            else if (row_info->bit_depth == 8)\n            {\n               sp = row;\n               for (i = 0; i < row_width; i++)\n               {\n                  *sp = gamma_table[*sp];\n                  sp++;\n               }\n            }\n\n            else if (row_info->bit_depth == 16)\n            {\n               sp = row;\n               for (i = 0; i < row_width; i++)\n               {\n                  png_uint_16 v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp];\n                  *sp = (png_byte)((v >> 8) & 0xff);\n                  *(sp + 1) = (png_byte)(v & 0xff);\n                  sp += 2;\n               }\n            }\n            break;\n         }\n\n         default:\n            break;\n      }\n   }\n}\n#endif\n\n#ifdef PNG_READ_ALPHA_MODE_SUPPORTED\n/* Encode the alpha channel to the output gamma (the input channel is always\n * linear.)  Called only with color types that have an alpha channel.  Needs the\n * from_1 tables.\n */\nvoid /* PRIVATE */\npng_do_encode_alpha(png_row_infop row_info, png_bytep row, png_structp png_ptr)\n{\n   png_uint_32 row_width = row_info->width;\n\n   png_debug(1, \"in png_do_encode_alpha\");\n\n   if (row_info->color_type & PNG_COLOR_MASK_ALPHA)\n   {\n      if (row_info->bit_depth == 8)\n      {\n         PNG_CONST png_bytep table = png_ptr->gamma_from_1;\n\n         if (table != NULL)\n         {\n            PNG_CONST int step =\n               (row_info->color_type & PNG_COLOR_MASK_COLOR) ? 4 : 2;\n\n            /* The alpha channel is the last component: */\n            row += step - 1;\n\n            for (; row_width > 0; --row_width, row += step)\n               *row = table[*row];\n\n            return;\n         }\n      }\n\n      else if (row_info->bit_depth == 16)\n      {\n         PNG_CONST png_uint_16pp table = png_ptr->gamma_16_from_1;\n         PNG_CONST int gamma_shift = png_ptr->gamma_shift;\n\n         if (table != NULL)\n         {\n            PNG_CONST int step =\n               (row_info->color_type & PNG_COLOR_MASK_COLOR) ? 8 : 4;\n\n            /* The alpha channel is the last component: */\n            row += step - 2;\n\n            for (; row_width > 0; --row_width, row += step)\n            {\n               png_uint_16 v;\n\n               v = table[*(row + 1) >> gamma_shift][*row];\n               *row = (png_byte)((v >> 8) & 0xff);\n               *(row + 1) = (png_byte)(v & 0xff);\n            }\n\n            return;\n         }\n      }\n   }\n\n   /* Only get to here if called with a weird row_info; no harm has been done,\n    * so just issue a warning.\n    */\n   png_warning(png_ptr, \"png_do_encode_alpha: unexpected call\");\n}\n#endif\n\n#ifdef PNG_READ_EXPAND_SUPPORTED\n/* Expands a palette row to an RGB or RGBA row depending\n * upon whether you supply trans and num_trans.\n */\nvoid /* PRIVATE */\npng_do_expand_palette(png_row_infop row_info, png_bytep row,\n   png_const_colorp palette, png_const_bytep trans_alpha, int num_trans)\n{\n   int shift, value;\n   png_bytep sp, dp;\n   png_uint_32 i;\n   png_uint_32 row_width=row_info->width;\n\n   png_debug(1, \"in png_do_expand_palette\");\n\n   if (row_info->color_type == PNG_COLOR_TYPE_PALETTE)\n   {\n      if (row_info->bit_depth < 8)\n      {\n         switch (row_info->bit_depth)\n         {\n            case 1:\n            {\n               sp = row + (png_size_t)((row_width - 1) >> 3);\n               dp = row + (png_size_t)row_width - 1;\n               shift = 7 - (int)((row_width + 7) & 0x07);\n               for (i = 0; i < row_width; i++)\n               {\n                  if ((*sp >> shift) & 0x01)\n                     *dp = 1;\n\n                  else\n                     *dp = 0;\n\n                  if (shift == 7)\n                  {\n                     shift = 0;\n                     sp--;\n                  }\n\n                  else\n                     shift++;\n\n                  dp--;\n               }\n               break;\n            }\n\n            case 2:\n            {\n               sp = row + (png_size_t)((row_width - 1) >> 2);\n               dp = row + (png_size_t)row_width - 1;\n               shift = (int)((3 - ((row_width + 3) & 0x03)) << 1);\n               for (i = 0; i < row_width; i++)\n               {\n                  value = (*sp >> shift) & 0x03;\n                  *dp = (png_byte)value;\n                  if (shift == 6)\n                  {\n                     shift = 0;\n                     sp--;\n                  }\n\n                  else\n                     shift += 2;\n\n                  dp--;\n               }\n               break;\n            }\n\n            case 4:\n            {\n               sp = row + (png_size_t)((row_width - 1) >> 1);\n               dp = row + (png_size_t)row_width - 1;\n               shift = (int)((row_width & 0x01) << 2);\n               for (i = 0; i < row_width; i++)\n               {\n                  value = (*sp >> shift) & 0x0f;\n                  *dp = (png_byte)value;\n                  if (shift == 4)\n                  {\n                     shift = 0;\n                     sp--;\n                  }\n\n                  else\n                     shift += 4;\n\n                  dp--;\n               }\n               break;\n            }\n\n            default:\n               break;\n         }\n         row_info->bit_depth = 8;\n         row_info->pixel_depth = 8;\n         row_info->rowbytes = row_width;\n      }\n\n      if (row_info->bit_depth == 8)\n      {\n         {\n            if (num_trans > 0)\n            {\n               sp = row + (png_size_t)row_width - 1;\n               dp = row + (png_size_t)(row_width << 2) - 1;\n\n               for (i = 0; i < row_width; i++)\n               {\n                  if ((int)(*sp) >= num_trans)\n                     *dp-- = 0xff;\n\n                  else\n                     *dp-- = trans_alpha[*sp];\n\n                  *dp-- = palette[*sp].blue;\n                  *dp-- = palette[*sp].green;\n                  *dp-- = palette[*sp].red;\n                  sp--;\n               }\n               row_info->bit_depth = 8;\n               row_info->pixel_depth = 32;\n               row_info->rowbytes = row_width * 4;\n               row_info->color_type = 6;\n               row_info->channels = 4;\n            }\n\n            else\n            {\n               sp = row + (png_size_t)row_width - 1;\n               dp = row + (png_size_t)(row_width * 3) - 1;\n\n               for (i = 0; i < row_width; i++)\n               {\n                  *dp-- = palette[*sp].blue;\n                  *dp-- = palette[*sp].green;\n                  *dp-- = palette[*sp].red;\n                  sp--;\n               }\n\n               row_info->bit_depth = 8;\n               row_info->pixel_depth = 24;\n               row_info->rowbytes = row_width * 3;\n               row_info->color_type = 2;\n               row_info->channels = 3;\n            }\n         }\n      }\n   }\n}\n\n/* If the bit depth < 8, it is expanded to 8.  Also, if the already\n * expanded transparency value is supplied, an alpha channel is built.\n */\nvoid /* PRIVATE */\npng_do_expand(png_row_infop row_info, png_bytep row,\n    png_const_color_16p trans_color)\n{\n   int shift, value;\n   png_bytep sp, dp;\n   png_uint_32 i;\n   png_uint_32 row_width=row_info->width;\n\n   png_debug(1, \"in png_do_expand\");\n\n   {\n      if (row_info->color_type == PNG_COLOR_TYPE_GRAY)\n      {\n         png_uint_16 gray = (png_uint_16)(trans_color ? trans_color->gray : 0);\n\n         if (row_info->bit_depth < 8)\n         {\n            switch (row_info->bit_depth)\n            {\n               case 1:\n               {\n                  gray = (png_uint_16)((gray & 0x01) * 0xff);\n                  sp = row + (png_size_t)((row_width - 1) >> 3);\n                  dp = row + (png_size_t)row_width - 1;\n                  shift = 7 - (int)((row_width + 7) & 0x07);\n                  for (i = 0; i < row_width; i++)\n                  {\n                     if ((*sp >> shift) & 0x01)\n                        *dp = 0xff;\n\n                     else\n                        *dp = 0;\n\n                     if (shift == 7)\n                     {\n                        shift = 0;\n                        sp--;\n                     }\n\n                     else\n                        shift++;\n\n                     dp--;\n                  }\n                  break;\n               }\n\n               case 2:\n               {\n                  gray = (png_uint_16)((gray & 0x03) * 0x55);\n                  sp = row + (png_size_t)((row_width - 1) >> 2);\n                  dp = row + (png_size_t)row_width - 1;\n                  shift = (int)((3 - ((row_width + 3) & 0x03)) << 1);\n                  for (i = 0; i < row_width; i++)\n                  {\n                     value = (*sp >> shift) & 0x03;\n                     *dp = (png_byte)(value | (value << 2) | (value << 4) |\n                        (value << 6));\n                     if (shift == 6)\n                     {\n                        shift = 0;\n                        sp--;\n                     }\n\n                     else\n                        shift += 2;\n\n                     dp--;\n                  }\n                  break;\n               }\n\n               case 4:\n               {\n                  gray = (png_uint_16)((gray & 0x0f) * 0x11);\n                  sp = row + (png_size_t)((row_width - 1) >> 1);\n                  dp = row + (png_size_t)row_width - 1;\n                  shift = (int)((1 - ((row_width + 1) & 0x01)) << 2);\n                  for (i = 0; i < row_width; i++)\n                  {\n                     value = (*sp >> shift) & 0x0f;\n                     *dp = (png_byte)(value | (value << 4));\n                     if (shift == 4)\n                     {\n                        shift = 0;\n                        sp--;\n                     }\n\n                     else\n                        shift = 4;\n\n                     dp--;\n                  }\n                  break;\n               }\n\n               default:\n                  break;\n            }\n\n            row_info->bit_depth = 8;\n            row_info->pixel_depth = 8;\n            row_info->rowbytes = row_width;\n         }\n\n         if (trans_color != NULL)\n         {\n            if (row_info->bit_depth == 8)\n            {\n               gray = gray & 0xff;\n               sp = row + (png_size_t)row_width - 1;\n               dp = row + (png_size_t)(row_width << 1) - 1;\n\n               for (i = 0; i < row_width; i++)\n               {\n                  if (*sp == gray)\n                     *dp-- = 0;\n\n                  else\n                     *dp-- = 0xff;\n\n                  *dp-- = *sp--;\n               }\n            }\n\n            else if (row_info->bit_depth == 16)\n            {\n               png_byte gray_high = (png_byte)((gray >> 8) & 0xff);\n               png_byte gray_low = (png_byte)(gray & 0xff);\n               sp = row + row_info->rowbytes - 1;\n               dp = row + (row_info->rowbytes << 1) - 1;\n               for (i = 0; i < row_width; i++)\n               {\n                  if (*(sp - 1) == gray_high && *(sp) == gray_low)\n                  {\n                     *dp-- = 0;\n                     *dp-- = 0;\n                  }\n\n                  else\n                  {\n                     *dp-- = 0xff;\n                     *dp-- = 0xff;\n                  }\n\n                  *dp-- = *sp--;\n                  *dp-- = *sp--;\n               }\n            }\n\n            row_info->color_type = PNG_COLOR_TYPE_GRAY_ALPHA;\n            row_info->channels = 2;\n            row_info->pixel_depth = (png_byte)(row_info->bit_depth << 1);\n            row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,\n               row_width);\n         }\n      }\n      else if (row_info->color_type == PNG_COLOR_TYPE_RGB && trans_color)\n      {\n         if (row_info->bit_depth == 8)\n         {\n            png_byte red = (png_byte)(trans_color->red & 0xff);\n            png_byte green = (png_byte)(trans_color->green & 0xff);\n            png_byte blue = (png_byte)(trans_color->blue & 0xff);\n            sp = row + (png_size_t)row_info->rowbytes - 1;\n            dp = row + (png_size_t)(row_width << 2) - 1;\n            for (i = 0; i < row_width; i++)\n            {\n               if (*(sp - 2) == red && *(sp - 1) == green && *(sp) == blue)\n                  *dp-- = 0;\n\n               else\n                  *dp-- = 0xff;\n\n               *dp-- = *sp--;\n               *dp-- = *sp--;\n               *dp-- = *sp--;\n            }\n         }\n         else if (row_info->bit_depth == 16)\n         {\n            png_byte red_high = (png_byte)((trans_color->red >> 8) & 0xff);\n            png_byte green_high = (png_byte)((trans_color->green >> 8) & 0xff);\n            png_byte blue_high = (png_byte)((trans_color->blue >> 8) & 0xff);\n            png_byte red_low = (png_byte)(trans_color->red & 0xff);\n            png_byte green_low = (png_byte)(trans_color->green & 0xff);\n            png_byte blue_low = (png_byte)(trans_color->blue & 0xff);\n            sp = row + row_info->rowbytes - 1;\n            dp = row + (png_size_t)(row_width << 3) - 1;\n            for (i = 0; i < row_width; i++)\n            {\n               if (*(sp - 5) == red_high &&\n                   *(sp - 4) == red_low &&\n                   *(sp - 3) == green_high &&\n                   *(sp - 2) == green_low &&\n                   *(sp - 1) == blue_high &&\n                   *(sp    ) == blue_low)\n               {\n                  *dp-- = 0;\n                  *dp-- = 0;\n               }\n\n               else\n               {\n                  *dp-- = 0xff;\n                  *dp-- = 0xff;\n               }\n\n               *dp-- = *sp--;\n               *dp-- = *sp--;\n               *dp-- = *sp--;\n               *dp-- = *sp--;\n               *dp-- = *sp--;\n               *dp-- = *sp--;\n            }\n         }\n         row_info->color_type = PNG_COLOR_TYPE_RGB_ALPHA;\n         row_info->channels = 4;\n         row_info->pixel_depth = (png_byte)(row_info->bit_depth << 2);\n         row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, row_width);\n      }\n   }\n}\n#endif\n\n#ifdef PNG_READ_EXPAND_16_SUPPORTED\n/* If the bit depth is 8 and the color type is not a palette type expand the\n * whole row to 16 bits.  Has no effect otherwise.\n */\nvoid /* PRIVATE */\npng_do_expand_16(png_row_infop row_info, png_bytep row)\n{\n   if (row_info->bit_depth == 8 &&\n      row_info->color_type != PNG_COLOR_TYPE_PALETTE)\n   {\n      /* The row have a sequence of bytes containing [0..255] and we need\n       * to turn it into another row containing [0..65535], to do this we\n       * calculate:\n       *\n       *  (input / 255) * 65535\n       *\n       *  Which happens to be exactly input * 257 and this can be achieved\n       *  simply by byte replication in place (copying backwards).\n       */\n      png_byte *sp = row + row_info->rowbytes; /* source, last byte + 1 */\n      png_byte *dp = sp + row_info->rowbytes;  /* destination, end + 1 */\n      while (dp > sp)\n         dp[-2] = dp[-1] = *--sp, dp -= 2;\n\n      row_info->rowbytes *= 2;\n      row_info->bit_depth = 16;\n      row_info->pixel_depth = (png_byte)(row_info->channels * 16);\n   }\n}\n#endif\n\n#ifdef PNG_READ_QUANTIZE_SUPPORTED\nvoid /* PRIVATE */\npng_do_quantize(png_row_infop row_info, png_bytep row,\n    png_const_bytep palette_lookup, png_const_bytep quantize_lookup)\n{\n   png_bytep sp, dp;\n   png_uint_32 i;\n   png_uint_32 row_width=row_info->width;\n\n   png_debug(1, \"in png_do_quantize\");\n\n   if (row_info->bit_depth == 8)\n   {\n      if (row_info->color_type == PNG_COLOR_TYPE_RGB && palette_lookup)\n      {\n         int r, g, b, p;\n         sp = row;\n         dp = row;\n         for (i = 0; i < row_width; i++)\n         {\n            r = *sp++;\n            g = *sp++;\n            b = *sp++;\n\n            /* This looks real messy, but the compiler will reduce\n             * it down to a reasonable formula.  For example, with\n             * 5 bits per color, we get:\n             * p = (((r >> 3) & 0x1f) << 10) |\n             *    (((g >> 3) & 0x1f) << 5) |\n             *    ((b >> 3) & 0x1f);\n             */\n            p = (((r >> (8 - PNG_QUANTIZE_RED_BITS)) &\n                ((1 << PNG_QUANTIZE_RED_BITS) - 1)) <<\n                (PNG_QUANTIZE_GREEN_BITS + PNG_QUANTIZE_BLUE_BITS)) |\n                (((g >> (8 - PNG_QUANTIZE_GREEN_BITS)) &\n                ((1 << PNG_QUANTIZE_GREEN_BITS) - 1)) <<\n                (PNG_QUANTIZE_BLUE_BITS)) |\n                ((b >> (8 - PNG_QUANTIZE_BLUE_BITS)) &\n                ((1 << PNG_QUANTIZE_BLUE_BITS) - 1));\n\n            *dp++ = palette_lookup[p];\n         }\n\n         row_info->color_type = PNG_COLOR_TYPE_PALETTE;\n         row_info->channels = 1;\n         row_info->pixel_depth = row_info->bit_depth;\n         row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, row_width);\n      }\n\n      else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA &&\n         palette_lookup != NULL)\n      {\n         int r, g, b, p;\n         sp = row;\n         dp = row;\n         for (i = 0; i < row_width; i++)\n         {\n            r = *sp++;\n            g = *sp++;\n            b = *sp++;\n            sp++;\n\n            p = (((r >> (8 - PNG_QUANTIZE_RED_BITS)) &\n                ((1 << PNG_QUANTIZE_RED_BITS) - 1)) <<\n                (PNG_QUANTIZE_GREEN_BITS + PNG_QUANTIZE_BLUE_BITS)) |\n                (((g >> (8 - PNG_QUANTIZE_GREEN_BITS)) &\n                ((1 << PNG_QUANTIZE_GREEN_BITS) - 1)) <<\n                (PNG_QUANTIZE_BLUE_BITS)) |\n                ((b >> (8 - PNG_QUANTIZE_BLUE_BITS)) &\n                ((1 << PNG_QUANTIZE_BLUE_BITS) - 1));\n\n            *dp++ = palette_lookup[p];\n         }\n\n         row_info->color_type = PNG_COLOR_TYPE_PALETTE;\n         row_info->channels = 1;\n         row_info->pixel_depth = row_info->bit_depth;\n         row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, row_width);\n      }\n\n      else if (row_info->color_type == PNG_COLOR_TYPE_PALETTE &&\n         quantize_lookup)\n      {\n         sp = row;\n\n         for (i = 0; i < row_width; i++, sp++)\n         {\n            *sp = quantize_lookup[*sp];\n         }\n      }\n   }\n}\n#endif /* PNG_READ_QUANTIZE_SUPPORTED */\n#endif /* PNG_READ_TRANSFORMS_SUPPORTED */\n\n#ifdef PNG_MNG_FEATURES_SUPPORTED\n/* Undoes intrapixel differencing  */\nvoid /* PRIVATE */\npng_do_read_intrapixel(png_row_infop row_info, png_bytep row)\n{\n   png_debug(1, \"in png_do_read_intrapixel\");\n\n   if (\n       (row_info->color_type & PNG_COLOR_MASK_COLOR))\n   {\n      int bytes_per_pixel;\n      png_uint_32 row_width = row_info->width;\n\n      if (row_info->bit_depth == 8)\n      {\n         png_bytep rp;\n         png_uint_32 i;\n\n         if (row_info->color_type == PNG_COLOR_TYPE_RGB)\n            bytes_per_pixel = 3;\n\n         else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)\n            bytes_per_pixel = 4;\n\n         else\n            return;\n\n         for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel)\n         {\n            *(rp) = (png_byte)((256 + *rp + *(rp + 1)) & 0xff);\n            *(rp+2) = (png_byte)((256 + *(rp + 2) + *(rp + 1)) & 0xff);\n         }\n      }\n      else if (row_info->bit_depth == 16)\n      {\n         png_bytep rp;\n         png_uint_32 i;\n\n         if (row_info->color_type == PNG_COLOR_TYPE_RGB)\n            bytes_per_pixel = 6;\n\n         else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)\n            bytes_per_pixel = 8;\n\n         else\n            return;\n\n         for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel)\n         {\n            png_uint_32 s0   = (*(rp    ) << 8) | *(rp + 1);\n            png_uint_32 s1   = (*(rp + 2) << 8) | *(rp + 3);\n            png_uint_32 s2   = (*(rp + 4) << 8) | *(rp + 5);\n            png_uint_32 red  = (s0 + s1 + 65536) & 0xffff;\n            png_uint_32 blue = (s2 + s1 + 65536) & 0xffff;\n            *(rp    ) = (png_byte)((red >> 8) & 0xff);\n            *(rp + 1) = (png_byte)(red & 0xff);\n            *(rp + 4) = (png_byte)((blue >> 8) & 0xff);\n            *(rp + 5) = (png_byte)(blue & 0xff);\n         }\n      }\n   }\n}\n#endif /* PNG_MNG_FEATURES_SUPPORTED */\n#endif /* PNG_READ_SUPPORTED */\n"
  },
  {
    "path": "Projects/Tools/PNGAlphaPremultiplier/Native/Source/LibPng/pngrutil.c",
    "content": "\n/* pngrutil.c - utilities to read a PNG file\n *\n * Last changed in libpng 1.5.9 [February 18, 2012]\n * Copyright (c) 1998-2012 Glenn Randers-Pehrson\n * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)\n * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)\n *\n * This code is released under the libpng license.\n * For conditions of distribution and use, see the disclaimer\n * and license in png.h\n *\n * This file contains routines that are only called from within\n * libpng itself during the course of reading an image.\n */\n\n#include \"pngpriv.h\"\n\n#ifdef PNG_READ_SUPPORTED\n\n#define png_strtod(p,a,b) strtod(a,b)\n\npng_uint_32 PNGAPI\npng_get_uint_31(png_structp png_ptr, png_const_bytep buf)\n{\n   png_uint_32 uval = png_get_uint_32(buf);\n\n   if (uval > PNG_UINT_31_MAX)\n      png_error(png_ptr, \"PNG unsigned integer out of range\");\n\n   return (uval);\n}\n\n#if defined(PNG_READ_gAMA_SUPPORTED) || defined(PNG_READ_cHRM_SUPPORTED)\n/* The following is a variation on the above for use with the fixed\n * point values used for gAMA and cHRM.  Instead of png_error it\n * issues a warning and returns (-1) - an invalid value because both\n * gAMA and cHRM use *unsigned* integers for fixed point values.\n */\n#define PNG_FIXED_ERROR (-1)\n\nstatic png_fixed_point /* PRIVATE */\npng_get_fixed_point(png_structp png_ptr, png_const_bytep buf)\n{\n   png_uint_32 uval = png_get_uint_32(buf);\n\n   if (uval <= PNG_UINT_31_MAX)\n      return (png_fixed_point)uval; /* known to be in range */\n\n   /* The caller can turn off the warning by passing NULL. */\n   if (png_ptr != NULL)\n      png_warning(png_ptr, \"PNG fixed point integer out of range\");\n\n   return PNG_FIXED_ERROR;\n}\n#endif\n\n#ifdef PNG_READ_INT_FUNCTIONS_SUPPORTED\n/* NOTE: the read macros will obscure these definitions, so that if\n * PNG_USE_READ_MACROS is set the library will not use them internally,\n * but the APIs will still be available externally.\n *\n * The parentheses around \"PNGAPI function_name\" in the following three\n * functions are necessary because they allow the macros to co-exist with\n * these (unused but exported) functions.\n */\n\n/* Grab an unsigned 32-bit integer from a buffer in big-endian format. */\npng_uint_32 (PNGAPI\npng_get_uint_32)(png_const_bytep buf)\n{\n   png_uint_32 uval =\n       ((png_uint_32)(*(buf    )) << 24) +\n       ((png_uint_32)(*(buf + 1)) << 16) +\n       ((png_uint_32)(*(buf + 2)) <<  8) +\n       ((png_uint_32)(*(buf + 3))      ) ;\n\n   return uval;\n}\n\n/* Grab a signed 32-bit integer from a buffer in big-endian format.  The\n * data is stored in the PNG file in two's complement format and there\n * is no guarantee that a 'png_int_32' is exactly 32 bits, therefore\n * the following code does a two's complement to native conversion.\n */\npng_int_32 (PNGAPI\npng_get_int_32)(png_const_bytep buf)\n{\n   png_uint_32 uval = png_get_uint_32(buf);\n   if ((uval & 0x80000000) == 0) /* non-negative */\n      return uval;\n\n   uval = (uval ^ 0xffffffff) + 1;  /* 2's complement: -x = ~x+1 */\n   return -(png_int_32)uval;\n}\n\n/* Grab an unsigned 16-bit integer from a buffer in big-endian format. */\npng_uint_16 (PNGAPI\npng_get_uint_16)(png_const_bytep buf)\n{\n   /* ANSI-C requires an int value to accomodate at least 16 bits so this\n    * works and allows the compiler not to worry about possible narrowing\n    * on 32 bit systems.  (Pre-ANSI systems did not make integers smaller\n    * than 16 bits either.)\n    */\n   unsigned int val =\n       ((unsigned int)(*buf) << 8) +\n       ((unsigned int)(*(buf + 1)));\n\n   return (png_uint_16)val;\n}\n\n#endif /* PNG_READ_INT_FUNCTIONS_SUPPORTED */\n\n/* Read and check the PNG file signature */\nvoid /* PRIVATE */\npng_read_sig(png_structp png_ptr, png_infop info_ptr)\n{\n   png_size_t num_checked, num_to_check;\n\n   /* Exit if the user application does not expect a signature. */\n   if (png_ptr->sig_bytes >= 8)\n      return;\n\n   num_checked = png_ptr->sig_bytes;\n   num_to_check = 8 - num_checked;\n\n#ifdef PNG_IO_STATE_SUPPORTED\n   png_ptr->io_state = PNG_IO_READING | PNG_IO_SIGNATURE;\n#endif\n\n   /* The signature must be serialized in a single I/O call. */\n   png_read_data(png_ptr, &(info_ptr->signature[num_checked]), num_to_check);\n   png_ptr->sig_bytes = 8;\n\n   if (png_sig_cmp(info_ptr->signature, num_checked, num_to_check))\n   {\n      if (num_checked < 4 &&\n          png_sig_cmp(info_ptr->signature, num_checked, num_to_check - 4))\n         png_error(png_ptr, \"Not a PNG file\");\n      else\n         png_error(png_ptr, \"PNG file corrupted by ASCII conversion\");\n   }\n   if (num_checked < 3)\n      png_ptr->mode |= PNG_HAVE_PNG_SIGNATURE;\n}\n\n/* Read the chunk header (length + type name).\n * Put the type name into png_ptr->chunk_name, and return the length.\n */\npng_uint_32 /* PRIVATE */\npng_read_chunk_header(png_structp png_ptr)\n{\n   png_byte buf[8];\n   png_uint_32 length;\n\n#ifdef PNG_IO_STATE_SUPPORTED\n   png_ptr->io_state = PNG_IO_READING | PNG_IO_CHUNK_HDR;\n#endif\n\n   /* Read the length and the chunk name.\n    * This must be performed in a single I/O call.\n    */\n   png_read_data(png_ptr, buf, 8);\n   length = png_get_uint_31(png_ptr, buf);\n\n   /* Put the chunk name into png_ptr->chunk_name. */\n   png_ptr->chunk_name = PNG_CHUNK_FROM_STRING(buf+4);\n\n   png_debug2(0, \"Reading %lx chunk, length = %lu\",\n       (unsigned long)png_ptr->chunk_name, (unsigned long)length);\n\n   /* Reset the crc and run it over the chunk name. */\n   png_reset_crc(png_ptr);\n   png_calculate_crc(png_ptr, buf + 4, 4);\n\n   /* Check to see if chunk name is valid. */\n   png_check_chunk_name(png_ptr, png_ptr->chunk_name);\n\n#ifdef PNG_IO_STATE_SUPPORTED\n   png_ptr->io_state = PNG_IO_READING | PNG_IO_CHUNK_DATA;\n#endif\n\n   return length;\n}\n\n/* Read data, and (optionally) run it through the CRC. */\nvoid /* PRIVATE */\npng_crc_read(png_structp png_ptr, png_bytep buf, png_size_t length)\n{\n   if (png_ptr == NULL)\n      return;\n\n   png_read_data(png_ptr, buf, length);\n   png_calculate_crc(png_ptr, buf, length);\n}\n\n/* Optionally skip data and then check the CRC.  Depending on whether we\n * are reading a ancillary or critical chunk, and how the program has set\n * things up, we may calculate the CRC on the data and print a message.\n * Returns '1' if there was a CRC error, '0' otherwise.\n */\nint /* PRIVATE */\npng_crc_finish(png_structp png_ptr, png_uint_32 skip)\n{\n   png_size_t i;\n   png_size_t istop = png_ptr->zbuf_size;\n\n   for (i = (png_size_t)skip; i > istop; i -= istop)\n   {\n      png_crc_read(png_ptr, png_ptr->zbuf, png_ptr->zbuf_size);\n   }\n\n   if (i)\n   {\n      png_crc_read(png_ptr, png_ptr->zbuf, i);\n   }\n\n   if (png_crc_error(png_ptr))\n   {\n      if (PNG_CHUNK_ANCILLIARY(png_ptr->chunk_name) ?\n          !(png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_NOWARN) :\n          (png_ptr->flags & PNG_FLAG_CRC_CRITICAL_USE))\n      {\n         png_chunk_warning(png_ptr, \"CRC error\");\n      }\n\n      else\n      {\n         png_chunk_benign_error(png_ptr, \"CRC error\");\n         return (0);\n      }\n\n      return (1);\n   }\n\n   return (0);\n}\n\n/* Compare the CRC stored in the PNG file with that calculated by libpng from\n * the data it has read thus far.\n */\nint /* PRIVATE */\npng_crc_error(png_structp png_ptr)\n{\n   png_byte crc_bytes[4];\n   png_uint_32 crc;\n   int need_crc = 1;\n\n   if (PNG_CHUNK_ANCILLIARY(png_ptr->chunk_name))\n   {\n      if ((png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_MASK) ==\n          (PNG_FLAG_CRC_ANCILLARY_USE | PNG_FLAG_CRC_ANCILLARY_NOWARN))\n         need_crc = 0;\n   }\n\n   else /* critical */\n   {\n      if (png_ptr->flags & PNG_FLAG_CRC_CRITICAL_IGNORE)\n         need_crc = 0;\n   }\n\n#ifdef PNG_IO_STATE_SUPPORTED\n   png_ptr->io_state = PNG_IO_READING | PNG_IO_CHUNK_CRC;\n#endif\n\n   /* The chunk CRC must be serialized in a single I/O call. */\n   png_read_data(png_ptr, crc_bytes, 4);\n\n   if (need_crc)\n   {\n      crc = png_get_uint_32(crc_bytes);\n      return ((int)(crc != png_ptr->crc));\n   }\n\n   else\n      return (0);\n}\n\n#ifdef PNG_READ_COMPRESSED_TEXT_SUPPORTED\nstatic png_size_t\npng_inflate(png_structp png_ptr, png_bytep data, png_size_t size,\n    png_bytep output, png_size_t output_size)\n{\n   png_size_t count = 0;\n\n   /* zlib can't necessarily handle more than 65535 bytes at once (i.e. it can't\n    * even necessarily handle 65536 bytes) because the type uInt is \"16 bits or\n    * more\".  Consequently it is necessary to chunk the input to zlib.  This\n    * code uses ZLIB_IO_MAX, from pngpriv.h, as the maximum (the maximum value\n    * that can be stored in a uInt.)  It is possible to set ZLIB_IO_MAX to a\n    * lower value in pngpriv.h and this may sometimes have a performance\n    * advantage, because it forces access of the input data to be separated from\n    * at least some of the use by some period of time.\n    */\n   png_ptr->zstream.next_in = data;\n   /* avail_in is set below from 'size' */\n   png_ptr->zstream.avail_in = 0;\n\n   while (1)\n   {\n      int ret, avail;\n\n      /* The setting of 'avail_in' used to be outside the loop; by setting it\n       * inside it is possible to chunk the input to zlib and simply rely on\n       * zlib to advance the 'next_in' pointer.  This allows arbitrary amounts o\n       * data to be passed through zlib at the unavoidable cost of requiring a\n       * window save (memcpy of up to 32768 output bytes) every ZLIB_IO_MAX\n       * input bytes.\n       */\n      if (png_ptr->zstream.avail_in == 0 && size > 0)\n      {\n         if (size <= ZLIB_IO_MAX)\n         {\n            /* The value is less than ZLIB_IO_MAX so the cast is safe: */\n            png_ptr->zstream.avail_in = (uInt)size;\n            size = 0;\n         }\n\n         else\n         {\n            png_ptr->zstream.avail_in = ZLIB_IO_MAX;\n            size -= ZLIB_IO_MAX;\n         }\n      }\n\n      /* Reset the output buffer each time round - we empty it\n       * after every inflate call.\n       */\n      png_ptr->zstream.next_out = png_ptr->zbuf;\n      png_ptr->zstream.avail_out = png_ptr->zbuf_size;\n\n      ret = inflate(&png_ptr->zstream, Z_NO_FLUSH);\n      avail = png_ptr->zbuf_size - png_ptr->zstream.avail_out;\n\n      /* First copy/count any new output - but only if we didn't\n       * get an error code.\n       */\n      if ((ret == Z_OK || ret == Z_STREAM_END) && avail > 0)\n      {\n         png_size_t space = avail; /* > 0, see above */\n\n         if (output != 0 && output_size > count)\n         {\n            png_size_t copy = output_size - count;\n\n            if (space < copy)\n               copy = space;\n\n            png_memcpy(output + count, png_ptr->zbuf, copy);\n         }\n         count += space;\n      }\n\n      if (ret == Z_OK)\n         continue;\n\n      /* Termination conditions - always reset the zstream, it\n       * must be left in inflateInit state.\n       */\n      png_ptr->zstream.avail_in = 0;\n      inflateReset(&png_ptr->zstream);\n\n      if (ret == Z_STREAM_END)\n         return count; /* NOTE: may be zero. */\n\n      /* Now handle the error codes - the API always returns 0\n       * and the error message is dumped into the uncompressed\n       * buffer if available.\n       */\n#     ifdef PNG_WARNINGS_SUPPORTED\n      {\n         png_const_charp msg;\n\n         if (png_ptr->zstream.msg != 0)\n            msg = png_ptr->zstream.msg;\n\n         else switch (ret)\n         {\n            case Z_BUF_ERROR:\n               msg = \"Buffer error in compressed datastream\";\n               break;\n\n            case Z_DATA_ERROR:\n               msg = \"Data error in compressed datastream\";\n               break;\n\n            default:\n               msg = \"Incomplete compressed datastream\";\n               break;\n         }\n\n         png_chunk_warning(png_ptr, msg);\n      }\n#     endif\n\n      /* 0 means an error - notice that this code simply ignores\n       * zero length compressed chunks as a result.\n       */\n      return 0;\n   }\n}\n\n/*\n * Decompress trailing data in a chunk.  The assumption is that chunkdata\n * points at an allocated area holding the contents of a chunk with a\n * trailing compressed part.  What we get back is an allocated area\n * holding the original prefix part and an uncompressed version of the\n * trailing part (the malloc area passed in is freed).\n */\nvoid /* PRIVATE */\npng_decompress_chunk(png_structp png_ptr, int comp_type,\n    png_size_t chunklength,\n    png_size_t prefix_size, png_size_t *newlength)\n{\n   /* The caller should guarantee this */\n   if (prefix_size > chunklength)\n   {\n      /* The recovery is to delete the chunk. */\n      png_warning(png_ptr, \"invalid chunklength\");\n      prefix_size = 0; /* To delete everything */\n   }\n\n   else if (comp_type == PNG_COMPRESSION_TYPE_BASE)\n   {\n      png_size_t expanded_size = png_inflate(png_ptr,\n          (png_bytep)(png_ptr->chunkdata + prefix_size),\n          chunklength - prefix_size,\n          0,            /* output */\n          0);           /* output size */\n\n      /* Now check the limits on this chunk - if the limit fails the\n       * compressed data will be removed, the prefix will remain.\n       */\n      if (prefix_size >= (~(png_size_t)0) - 1 ||\n         expanded_size >= (~(png_size_t)0) - 1 - prefix_size\n#ifdef PNG_SET_CHUNK_MALLOC_LIMIT_SUPPORTED\n         || (png_ptr->user_chunk_malloc_max &&\n          (prefix_size + expanded_size >= png_ptr->user_chunk_malloc_max - 1))\n#else\n#  ifdef PNG_USER_CHUNK_MALLOC_MAX\n         || ((PNG_USER_CHUNK_MALLOC_MAX > 0) &&\n          prefix_size + expanded_size >= PNG_USER_CHUNK_MALLOC_MAX - 1)\n#  endif\n#endif\n         )\n         png_warning(png_ptr, \"Exceeded size limit while expanding chunk\");\n\n      /* If the size is zero either there was an error and a message\n       * has already been output (warning) or the size really is zero\n       * and we have nothing to do - the code will exit through the\n       * error case below.\n       */\n      else if (expanded_size > 0)\n      {\n         /* Success (maybe) - really uncompress the chunk. */\n         png_size_t new_size = 0;\n         png_charp text = (png_charp)png_malloc_warn(png_ptr,\n             prefix_size + expanded_size + 1);\n\n         if (text != NULL)\n         {\n            png_memcpy(text, png_ptr->chunkdata, prefix_size);\n            new_size = png_inflate(png_ptr,\n                (png_bytep)(png_ptr->chunkdata + prefix_size),\n                chunklength - prefix_size,\n                (png_bytep)(text + prefix_size), expanded_size);\n            text[prefix_size + expanded_size] = 0; /* just in case */\n\n            if (new_size == expanded_size)\n            {\n               png_free(png_ptr, png_ptr->chunkdata);\n               png_ptr->chunkdata = text;\n               *newlength = prefix_size + expanded_size;\n               return; /* The success return! */\n            }\n\n            png_warning(png_ptr, \"png_inflate logic error\");\n            png_free(png_ptr, text);\n         }\n\n         else\n            png_warning(png_ptr, \"Not enough memory to decompress chunk\");\n      }\n   }\n\n   else /* if (comp_type != PNG_COMPRESSION_TYPE_BASE) */\n   {\n      PNG_WARNING_PARAMETERS(p)\n      png_warning_parameter_signed(p, 1, PNG_NUMBER_FORMAT_d, comp_type);\n      png_formatted_warning(png_ptr, p, \"Unknown compression type @1\");\n\n      /* The recovery is to simply drop the data. */\n   }\n\n   /* Generic error return - leave the prefix, delete the compressed\n    * data, reallocate the chunkdata to remove the potentially large\n    * amount of compressed data.\n    */\n   {\n      png_charp text = (png_charp)png_malloc_warn(png_ptr, prefix_size + 1);\n\n      if (text != NULL)\n      {\n         if (prefix_size > 0)\n            png_memcpy(text, png_ptr->chunkdata, prefix_size);\n\n         png_free(png_ptr, png_ptr->chunkdata);\n         png_ptr->chunkdata = text;\n\n         /* This is an extra zero in the 'uncompressed' part. */\n         *(png_ptr->chunkdata + prefix_size) = 0x00;\n      }\n      /* Ignore a malloc error here - it is safe. */\n   }\n\n   *newlength = prefix_size;\n}\n#endif /* PNG_READ_COMPRESSED_TEXT_SUPPORTED */\n\n/* Read and check the IDHR chunk */\nvoid /* PRIVATE */\npng_handle_IHDR(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)\n{\n   png_byte buf[13];\n   png_uint_32 width, height;\n   int bit_depth, color_type, compression_type, filter_type;\n   int interlace_type;\n\n   png_debug(1, \"in png_handle_IHDR\");\n\n   if (png_ptr->mode & PNG_HAVE_IHDR)\n      png_error(png_ptr, \"Out of place IHDR\");\n\n   /* Check the length */\n   if (length != 13)\n      png_error(png_ptr, \"Invalid IHDR chunk\");\n\n   png_ptr->mode |= PNG_HAVE_IHDR;\n\n   png_crc_read(png_ptr, buf, 13);\n   png_crc_finish(png_ptr, 0);\n\n   width = png_get_uint_31(png_ptr, buf);\n   height = png_get_uint_31(png_ptr, buf + 4);\n   bit_depth = buf[8];\n   color_type = buf[9];\n   compression_type = buf[10];\n   filter_type = buf[11];\n   interlace_type = buf[12];\n\n   /* Set internal variables */\n   png_ptr->width = width;\n   png_ptr->height = height;\n   png_ptr->bit_depth = (png_byte)bit_depth;\n   png_ptr->interlaced = (png_byte)interlace_type;\n   png_ptr->color_type = (png_byte)color_type;\n#ifdef PNG_MNG_FEATURES_SUPPORTED\n   png_ptr->filter_type = (png_byte)filter_type;\n#endif\n   png_ptr->compression_type = (png_byte)compression_type;\n\n   /* Find number of channels */\n   switch (png_ptr->color_type)\n   {\n      default: /* invalid, png_set_IHDR calls png_error */\n      case PNG_COLOR_TYPE_GRAY:\n      case PNG_COLOR_TYPE_PALETTE:\n         png_ptr->channels = 1;\n         break;\n\n      case PNG_COLOR_TYPE_RGB:\n         png_ptr->channels = 3;\n         break;\n\n      case PNG_COLOR_TYPE_GRAY_ALPHA:\n         png_ptr->channels = 2;\n         break;\n\n      case PNG_COLOR_TYPE_RGB_ALPHA:\n         png_ptr->channels = 4;\n         break;\n   }\n\n   /* Set up other useful info */\n   png_ptr->pixel_depth = (png_byte)(png_ptr->bit_depth *\n   png_ptr->channels);\n   png_ptr->rowbytes = PNG_ROWBYTES(png_ptr->pixel_depth, png_ptr->width);\n   png_debug1(3, \"bit_depth = %d\", png_ptr->bit_depth);\n   png_debug1(3, \"channels = %d\", png_ptr->channels);\n   png_debug1(3, \"rowbytes = %lu\", (unsigned long)png_ptr->rowbytes);\n   png_set_IHDR(png_ptr, info_ptr, width, height, bit_depth,\n       color_type, interlace_type, compression_type, filter_type);\n}\n\n/* Read and check the palette */\nvoid /* PRIVATE */\npng_handle_PLTE(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)\n{\n   png_color palette[PNG_MAX_PALETTE_LENGTH];\n   int num, i;\n#ifdef PNG_POINTER_INDEXING_SUPPORTED\n   png_colorp pal_ptr;\n#endif\n\n   png_debug(1, \"in png_handle_PLTE\");\n\n   if (!(png_ptr->mode & PNG_HAVE_IHDR))\n      png_error(png_ptr, \"Missing IHDR before PLTE\");\n\n   else if (png_ptr->mode & PNG_HAVE_IDAT)\n   {\n      png_warning(png_ptr, \"Invalid PLTE after IDAT\");\n      png_crc_finish(png_ptr, length);\n      return;\n   }\n\n   else if (png_ptr->mode & PNG_HAVE_PLTE)\n      png_error(png_ptr, \"Duplicate PLTE chunk\");\n\n   png_ptr->mode |= PNG_HAVE_PLTE;\n\n   if (!(png_ptr->color_type&PNG_COLOR_MASK_COLOR))\n   {\n      png_warning(png_ptr,\n          \"Ignoring PLTE chunk in grayscale PNG\");\n      png_crc_finish(png_ptr, length);\n      return;\n   }\n\n#ifndef PNG_READ_OPT_PLTE_SUPPORTED\n   if (png_ptr->color_type != PNG_COLOR_TYPE_PALETTE)\n   {\n      png_crc_finish(png_ptr, length);\n      return;\n   }\n#endif\n\n   if (length > 3*PNG_MAX_PALETTE_LENGTH || length % 3)\n   {\n      if (png_ptr->color_type != PNG_COLOR_TYPE_PALETTE)\n      {\n         png_warning(png_ptr, \"Invalid palette chunk\");\n         png_crc_finish(png_ptr, length);\n         return;\n      }\n\n      else\n      {\n         png_error(png_ptr, \"Invalid palette chunk\");\n      }\n   }\n\n   num = (int)length / 3;\n\n#ifdef PNG_POINTER_INDEXING_SUPPORTED\n   for (i = 0, pal_ptr = palette; i < num; i++, pal_ptr++)\n   {\n      png_byte buf[3];\n\n      png_crc_read(png_ptr, buf, 3);\n      pal_ptr->red = buf[0];\n      pal_ptr->green = buf[1];\n      pal_ptr->blue = buf[2];\n   }\n#else\n   for (i = 0; i < num; i++)\n   {\n      png_byte buf[3];\n\n      png_crc_read(png_ptr, buf, 3);\n      /* Don't depend upon png_color being any order */\n      palette[i].red = buf[0];\n      palette[i].green = buf[1];\n      palette[i].blue = buf[2];\n   }\n#endif\n\n   /* If we actually need the PLTE chunk (ie for a paletted image), we do\n    * whatever the normal CRC configuration tells us.  However, if we\n    * have an RGB image, the PLTE can be considered ancillary, so\n    * we will act as though it is.\n    */\n#ifndef PNG_READ_OPT_PLTE_SUPPORTED\n   if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)\n#endif\n   {\n      png_crc_finish(png_ptr, 0);\n   }\n\n#ifndef PNG_READ_OPT_PLTE_SUPPORTED\n   else if (png_crc_error(png_ptr))  /* Only if we have a CRC error */\n   {\n      /* If we don't want to use the data from an ancillary chunk,\n       * we have two options: an error abort, or a warning and we\n       * ignore the data in this chunk (which should be OK, since\n       * it's considered ancillary for a RGB or RGBA image).\n       */\n      if (!(png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_USE))\n      {\n         if (png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_NOWARN)\n         {\n            png_chunk_benign_error(png_ptr, \"CRC error\");\n         }\n\n         else\n         {\n            png_chunk_warning(png_ptr, \"CRC error\");\n            return;\n         }\n      }\n\n      /* Otherwise, we (optionally) emit a warning and use the chunk. */\n      else if (!(png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_NOWARN))\n      {\n         png_chunk_warning(png_ptr, \"CRC error\");\n      }\n   }\n#endif\n\n   png_set_PLTE(png_ptr, info_ptr, palette, num);\n\n#ifdef PNG_READ_tRNS_SUPPORTED\n   if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)\n   {\n      if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS))\n      {\n         if (png_ptr->num_trans > (png_uint_16)num)\n         {\n            png_warning(png_ptr, \"Truncating incorrect tRNS chunk length\");\n            png_ptr->num_trans = (png_uint_16)num;\n         }\n\n         if (info_ptr->num_trans > (png_uint_16)num)\n         {\n            png_warning(png_ptr, \"Truncating incorrect info tRNS chunk length\");\n            info_ptr->num_trans = (png_uint_16)num;\n         }\n      }\n   }\n#endif\n\n}\n\nvoid /* PRIVATE */\npng_handle_IEND(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)\n{\n   png_debug(1, \"in png_handle_IEND\");\n\n   if (!(png_ptr->mode & PNG_HAVE_IHDR) || !(png_ptr->mode & PNG_HAVE_IDAT))\n   {\n      png_error(png_ptr, \"No image in file\");\n   }\n\n   png_ptr->mode |= (PNG_AFTER_IDAT | PNG_HAVE_IEND);\n\n   if (length != 0)\n   {\n      png_warning(png_ptr, \"Incorrect IEND chunk length\");\n   }\n\n   png_crc_finish(png_ptr, length);\n\n   PNG_UNUSED(info_ptr) /* Quiet compiler warnings about unused info_ptr */\n}\n\n#ifdef PNG_READ_gAMA_SUPPORTED\nvoid /* PRIVATE */\npng_handle_gAMA(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)\n{\n   png_fixed_point igamma;\n   png_byte buf[4];\n\n   png_debug(1, \"in png_handle_gAMA\");\n\n   if (!(png_ptr->mode & PNG_HAVE_IHDR))\n      png_error(png_ptr, \"Missing IHDR before gAMA\");\n\n   else if (png_ptr->mode & PNG_HAVE_IDAT)\n   {\n      png_warning(png_ptr, \"Invalid gAMA after IDAT\");\n      png_crc_finish(png_ptr, length);\n      return;\n   }\n\n   else if (png_ptr->mode & PNG_HAVE_PLTE)\n      /* Should be an error, but we can cope with it */\n      png_warning(png_ptr, \"Out of place gAMA chunk\");\n\n   if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA)\n#ifdef PNG_READ_sRGB_SUPPORTED\n       && !(info_ptr->valid & PNG_INFO_sRGB)\n#endif\n       )\n   {\n      png_warning(png_ptr, \"Duplicate gAMA chunk\");\n      png_crc_finish(png_ptr, length);\n      return;\n   }\n\n   if (length != 4)\n   {\n      png_warning(png_ptr, \"Incorrect gAMA chunk length\");\n      png_crc_finish(png_ptr, length);\n      return;\n   }\n\n   png_crc_read(png_ptr, buf, 4);\n\n   if (png_crc_finish(png_ptr, 0))\n      return;\n\n   igamma = png_get_fixed_point(NULL, buf);\n\n   /* Check for zero gamma or an error. */\n   if (igamma <= 0)\n   {\n      png_warning(png_ptr,\n          \"Ignoring gAMA chunk with out of range gamma\");\n\n      return;\n   }\n\n#  ifdef PNG_READ_sRGB_SUPPORTED\n   if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_sRGB))\n   {\n      if (PNG_OUT_OF_RANGE(igamma, 45500, 500))\n      {\n         PNG_WARNING_PARAMETERS(p)\n         png_warning_parameter_signed(p, 1, PNG_NUMBER_FORMAT_fixed, igamma);\n         png_formatted_warning(png_ptr, p,\n             \"Ignoring incorrect gAMA value @1 when sRGB is also present\");\n         return;\n      }\n   }\n#  endif /* PNG_READ_sRGB_SUPPORTED */\n\n#  ifdef PNG_READ_GAMMA_SUPPORTED\n   /* Gamma correction on read is supported. */\n   png_ptr->gamma = igamma;\n#  endif\n   /* And set the 'info' structure members. */\n   png_set_gAMA_fixed(png_ptr, info_ptr, igamma);\n}\n#endif\n\n#ifdef PNG_READ_sBIT_SUPPORTED\nvoid /* PRIVATE */\npng_handle_sBIT(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)\n{\n   png_size_t truelen;\n   png_byte buf[4];\n\n   png_debug(1, \"in png_handle_sBIT\");\n\n   buf[0] = buf[1] = buf[2] = buf[3] = 0;\n\n   if (!(png_ptr->mode & PNG_HAVE_IHDR))\n      png_error(png_ptr, \"Missing IHDR before sBIT\");\n\n   else if (png_ptr->mode & PNG_HAVE_IDAT)\n   {\n      png_warning(png_ptr, \"Invalid sBIT after IDAT\");\n      png_crc_finish(png_ptr, length);\n      return;\n   }\n\n   else if (png_ptr->mode & PNG_HAVE_PLTE)\n   {\n      /* Should be an error, but we can cope with it */\n      png_warning(png_ptr, \"Out of place sBIT chunk\");\n   }\n\n   if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_sBIT))\n   {\n      png_warning(png_ptr, \"Duplicate sBIT chunk\");\n      png_crc_finish(png_ptr, length);\n      return;\n   }\n\n   if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)\n      truelen = 3;\n\n   else\n      truelen = (png_size_t)png_ptr->channels;\n\n   if (length != truelen || length > 4)\n   {\n      png_warning(png_ptr, \"Incorrect sBIT chunk length\");\n      png_crc_finish(png_ptr, length);\n      return;\n   }\n\n   png_crc_read(png_ptr, buf, truelen);\n\n   if (png_crc_finish(png_ptr, 0))\n      return;\n\n   if (png_ptr->color_type & PNG_COLOR_MASK_COLOR)\n   {\n      png_ptr->sig_bit.red = buf[0];\n      png_ptr->sig_bit.green = buf[1];\n      png_ptr->sig_bit.blue = buf[2];\n      png_ptr->sig_bit.alpha = buf[3];\n   }\n\n   else\n   {\n      png_ptr->sig_bit.gray = buf[0];\n      png_ptr->sig_bit.red = buf[0];\n      png_ptr->sig_bit.green = buf[0];\n      png_ptr->sig_bit.blue = buf[0];\n      png_ptr->sig_bit.alpha = buf[1];\n   }\n\n   png_set_sBIT(png_ptr, info_ptr, &(png_ptr->sig_bit));\n}\n#endif\n\n#ifdef PNG_READ_cHRM_SUPPORTED\nvoid /* PRIVATE */\npng_handle_cHRM(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)\n{\n   png_byte buf[32];\n   png_fixed_point x_white, y_white, x_red, y_red, x_green, y_green, x_blue,\n      y_blue;\n\n   png_debug(1, \"in png_handle_cHRM\");\n\n   if (!(png_ptr->mode & PNG_HAVE_IHDR))\n      png_error(png_ptr, \"Missing IHDR before cHRM\");\n\n   else if (png_ptr->mode & PNG_HAVE_IDAT)\n   {\n      png_warning(png_ptr, \"Invalid cHRM after IDAT\");\n      png_crc_finish(png_ptr, length);\n      return;\n   }\n\n   else if (png_ptr->mode & PNG_HAVE_PLTE)\n      /* Should be an error, but we can cope with it */\n      png_warning(png_ptr, \"Out of place cHRM chunk\");\n\n   if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM)\n#  ifdef PNG_READ_sRGB_SUPPORTED\n       && !(info_ptr->valid & PNG_INFO_sRGB)\n#  endif\n      )\n   {\n      png_warning(png_ptr, \"Duplicate cHRM chunk\");\n      png_crc_finish(png_ptr, length);\n      return;\n   }\n\n   if (length != 32)\n   {\n      png_warning(png_ptr, \"Incorrect cHRM chunk length\");\n      png_crc_finish(png_ptr, length);\n      return;\n   }\n\n   png_crc_read(png_ptr, buf, 32);\n\n   if (png_crc_finish(png_ptr, 0))\n      return;\n\n   x_white = png_get_fixed_point(NULL, buf);\n   y_white = png_get_fixed_point(NULL, buf + 4);\n   x_red   = png_get_fixed_point(NULL, buf + 8);\n   y_red   = png_get_fixed_point(NULL, buf + 12);\n   x_green = png_get_fixed_point(NULL, buf + 16);\n   y_green = png_get_fixed_point(NULL, buf + 20);\n   x_blue  = png_get_fixed_point(NULL, buf + 24);\n   y_blue  = png_get_fixed_point(NULL, buf + 28);\n\n   if (x_white == PNG_FIXED_ERROR ||\n       y_white == PNG_FIXED_ERROR ||\n       x_red   == PNG_FIXED_ERROR ||\n       y_red   == PNG_FIXED_ERROR ||\n       x_green == PNG_FIXED_ERROR ||\n       y_green == PNG_FIXED_ERROR ||\n       x_blue  == PNG_FIXED_ERROR ||\n       y_blue  == PNG_FIXED_ERROR)\n   {\n      png_warning(png_ptr, \"Ignoring cHRM chunk with negative chromaticities\");\n      return;\n   }\n\n#ifdef PNG_READ_sRGB_SUPPORTED\n   if ((info_ptr != NULL) && (info_ptr->valid & PNG_INFO_sRGB))\n   {\n      if (PNG_OUT_OF_RANGE(x_white, 31270,  1000) ||\n          PNG_OUT_OF_RANGE(y_white, 32900,  1000) ||\n          PNG_OUT_OF_RANGE(x_red,   64000,  1000) ||\n          PNG_OUT_OF_RANGE(y_red,   33000,  1000) ||\n          PNG_OUT_OF_RANGE(x_green, 30000,  1000) ||\n          PNG_OUT_OF_RANGE(y_green, 60000,  1000) ||\n          PNG_OUT_OF_RANGE(x_blue,  15000,  1000) ||\n          PNG_OUT_OF_RANGE(y_blue,   6000,  1000))\n      {\n         PNG_WARNING_PARAMETERS(p)\n\n         png_warning_parameter_signed(p, 1, PNG_NUMBER_FORMAT_fixed, x_white);\n         png_warning_parameter_signed(p, 2, PNG_NUMBER_FORMAT_fixed, y_white);\n         png_warning_parameter_signed(p, 3, PNG_NUMBER_FORMAT_fixed, x_red);\n         png_warning_parameter_signed(p, 4, PNG_NUMBER_FORMAT_fixed, y_red);\n         png_warning_parameter_signed(p, 5, PNG_NUMBER_FORMAT_fixed, x_green);\n         png_warning_parameter_signed(p, 6, PNG_NUMBER_FORMAT_fixed, y_green);\n         png_warning_parameter_signed(p, 7, PNG_NUMBER_FORMAT_fixed, x_blue);\n         png_warning_parameter_signed(p, 8, PNG_NUMBER_FORMAT_fixed, y_blue);\n\n         png_formatted_warning(png_ptr, p,\n             \"Ignoring incorrect cHRM white(@1,@2) r(@3,@4)g(@5,@6)b(@7,@8) \"\n             \"when sRGB is also present\");\n      }\n      return;\n   }\n#endif /* PNG_READ_sRGB_SUPPORTED */\n\n#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED\n   /* Store the _white values as default coefficients for the rgb to gray\n    * operation if it is supported.  Check if the transform is already set to\n    * avoid destroying the transform values.\n    */\n   if (!png_ptr->rgb_to_gray_coefficients_set)\n   {\n      /* png_set_background has not been called and we haven't seen an sRGB\n       * chunk yet.  Find the XYZ of the three end points.\n       */\n      png_XYZ XYZ;\n      png_xy xy;\n\n      xy.redx = x_red;\n      xy.redy = y_red;\n      xy.greenx = x_green;\n      xy.greeny = y_green;\n      xy.bluex = x_blue;\n      xy.bluey = y_blue;\n      xy.whitex = x_white;\n      xy.whitey = y_white;\n\n      if (png_XYZ_from_xy_checked(png_ptr, &XYZ, xy))\n      {\n         /* The success case, because XYZ_from_xy normalises to a reference\n          * white Y of 1.0 we just need to scale the numbers.  This should\n          * always work just fine. It is an internal error if this overflows.\n          */\n         {\n            png_fixed_point r, g, b;\n            if (png_muldiv(&r, XYZ.redY, 32768, PNG_FP_1) &&\n               r >= 0 && r <= 32768 &&\n               png_muldiv(&g, XYZ.greenY, 32768, PNG_FP_1) &&\n               g >= 0 && g <= 32768 &&\n               png_muldiv(&b, XYZ.blueY, 32768, PNG_FP_1) &&\n               b >= 0 && b <= 32768 &&\n               r+g+b <= 32769)\n            {\n               /* We allow 0 coefficients here.  r+g+b may be 32769 if two or\n                * all of the coefficients were rounded up.  Handle this by\n                * reducing the *largest* coefficient by 1; this matches the\n                * approach used for the default coefficients in pngrtran.c\n                */\n               int add = 0;\n\n               if (r+g+b > 32768)\n                  add = -1;\n               else if (r+g+b < 32768)\n                  add = 1;\n\n               if (add != 0)\n               {\n                  if (g >= r && g >= b)\n                     g += add;\n                  else if (r >= g && r >= b)\n                     r += add;\n                  else\n                     b += add;\n               }\n\n               /* Check for an internal error. */\n               if (r+g+b != 32768)\n                  png_error(png_ptr,\n                     \"internal error handling cHRM coefficients\");\n\n               png_ptr->rgb_to_gray_red_coeff   = (png_uint_16)r;\n               png_ptr->rgb_to_gray_green_coeff = (png_uint_16)g;\n            }\n\n            /* This is a png_error at present even though it could be ignored -\n             * it should never happen, but it is important that if it does, the\n             * bug is fixed.\n             */\n            else\n               png_error(png_ptr, \"internal error handling cHRM->XYZ\");\n         }\n      }\n   }\n#endif\n\n   png_set_cHRM_fixed(png_ptr, info_ptr, x_white, y_white, x_red, y_red,\n      x_green, y_green, x_blue, y_blue);\n}\n#endif\n\n#ifdef PNG_READ_sRGB_SUPPORTED\nvoid /* PRIVATE */\npng_handle_sRGB(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)\n{\n   int intent;\n   png_byte buf[1];\n\n   png_debug(1, \"in png_handle_sRGB\");\n\n   if (!(png_ptr->mode & PNG_HAVE_IHDR))\n      png_error(png_ptr, \"Missing IHDR before sRGB\");\n\n   else if (png_ptr->mode & PNG_HAVE_IDAT)\n   {\n      png_warning(png_ptr, \"Invalid sRGB after IDAT\");\n      png_crc_finish(png_ptr, length);\n      return;\n   }\n\n   else if (png_ptr->mode & PNG_HAVE_PLTE)\n      /* Should be an error, but we can cope with it */\n      png_warning(png_ptr, \"Out of place sRGB chunk\");\n\n   if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_sRGB))\n   {\n      png_warning(png_ptr, \"Duplicate sRGB chunk\");\n      png_crc_finish(png_ptr, length);\n      return;\n   }\n\n   if (length != 1)\n   {\n      png_warning(png_ptr, \"Incorrect sRGB chunk length\");\n      png_crc_finish(png_ptr, length);\n      return;\n   }\n\n   png_crc_read(png_ptr, buf, 1);\n\n   if (png_crc_finish(png_ptr, 0))\n      return;\n\n   intent = buf[0];\n\n   /* Check for bad intent */\n   if (intent >= PNG_sRGB_INTENT_LAST)\n   {\n      png_warning(png_ptr, \"Unknown sRGB intent\");\n      return;\n   }\n\n#if defined(PNG_READ_gAMA_SUPPORTED) && defined(PNG_READ_GAMMA_SUPPORTED)\n   if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA))\n   {\n      if (PNG_OUT_OF_RANGE(info_ptr->gamma, 45500, 500))\n      {\n         PNG_WARNING_PARAMETERS(p)\n\n         png_warning_parameter_signed(p, 1, PNG_NUMBER_FORMAT_fixed,\n            info_ptr->gamma);\n\n         png_formatted_warning(png_ptr, p,\n             \"Ignoring incorrect gAMA value @1 when sRGB is also present\");\n      }\n   }\n#endif /* PNG_READ_gAMA_SUPPORTED */\n\n#ifdef PNG_READ_cHRM_SUPPORTED\n   if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM))\n      if (PNG_OUT_OF_RANGE(info_ptr->x_white, 31270,  1000) ||\n          PNG_OUT_OF_RANGE(info_ptr->y_white, 32900,  1000) ||\n          PNG_OUT_OF_RANGE(info_ptr->x_red,   64000,  1000) ||\n          PNG_OUT_OF_RANGE(info_ptr->y_red,   33000,  1000) ||\n          PNG_OUT_OF_RANGE(info_ptr->x_green, 30000,  1000) ||\n          PNG_OUT_OF_RANGE(info_ptr->y_green, 60000,  1000) ||\n          PNG_OUT_OF_RANGE(info_ptr->x_blue,  15000,  1000) ||\n          PNG_OUT_OF_RANGE(info_ptr->y_blue,   6000,  1000))\n      {\n         png_warning(png_ptr,\n             \"Ignoring incorrect cHRM value when sRGB is also present\");\n      }\n#endif /* PNG_READ_cHRM_SUPPORTED */\n\n   /* This is recorded for use when handling the cHRM chunk above.  An sRGB\n    * chunk unconditionally overwrites the coefficients for grayscale conversion\n    * too.\n    */\n   png_ptr->is_sRGB = 1;\n\n#  ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED\n      /* Don't overwrite user supplied values: */\n      if (!png_ptr->rgb_to_gray_coefficients_set)\n      {\n         /* These numbers come from the sRGB specification (or, since one has to\n          * pay much money to get a copy, the wikipedia sRGB page) the\n          * chromaticity values quoted have been inverted to get the reverse\n          * transformation from RGB to XYZ and the 'Y' coefficients scaled by\n          * 32768 (then rounded).\n          *\n          * sRGB and ITU Rec-709 both truncate the values for the D65 white\n          * point to four digits and, even though it actually stores five\n          * digits, the PNG spec gives the truncated value.\n          *\n          * This means that when the chromaticities are converted back to XYZ\n          * end points we end up with (6968,23435,2366), which, as described in\n          * pngrtran.c, would overflow.  If the five digit precision and up is\n          * used we get, instead:\n          *\n          *    6968*R + 23435*G + 2365*B\n          *\n          * (Notice that this rounds the blue coefficient down, rather than the\n          * choice used in pngrtran.c which is to round the green one down.)\n          */\n         png_ptr->rgb_to_gray_red_coeff   =  6968; /* 0.212639005871510 */\n         png_ptr->rgb_to_gray_green_coeff = 23434; /* 0.715168678767756 */\n         /* png_ptr->rgb_to_gray_blue_coeff  =  2366; 0.072192315360734\t*/\n\n         /* The following keeps the cHRM chunk from destroying the\n          * coefficients again in the event that it follows the sRGB chunk.\n          */\n         png_ptr->rgb_to_gray_coefficients_set = 1;\n      }\n#  endif\n\n   png_set_sRGB_gAMA_and_cHRM(png_ptr, info_ptr, intent);\n}\n#endif /* PNG_READ_sRGB_SUPPORTED */\n\n#ifdef PNG_READ_iCCP_SUPPORTED\nvoid /* PRIVATE */\npng_handle_iCCP(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)\n/* Note: this does not properly handle chunks that are > 64K under DOS */\n{\n   png_byte compression_type;\n   png_bytep pC;\n   png_charp profile;\n   png_uint_32 skip = 0;\n   png_uint_32 profile_size;\n   png_alloc_size_t profile_length;\n   png_size_t slength, prefix_length, data_length;\n\n   png_debug(1, \"in png_handle_iCCP\");\n\n   if (!(png_ptr->mode & PNG_HAVE_IHDR))\n      png_error(png_ptr, \"Missing IHDR before iCCP\");\n\n   else if (png_ptr->mode & PNG_HAVE_IDAT)\n   {\n      png_warning(png_ptr, \"Invalid iCCP after IDAT\");\n      png_crc_finish(png_ptr, length);\n      return;\n   }\n\n   else if (png_ptr->mode & PNG_HAVE_PLTE)\n      /* Should be an error, but we can cope with it */\n      png_warning(png_ptr, \"Out of place iCCP chunk\");\n\n   if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_iCCP))\n   {\n      png_warning(png_ptr, \"Duplicate iCCP chunk\");\n      png_crc_finish(png_ptr, length);\n      return;\n   }\n\n#ifdef PNG_MAX_MALLOC_64K\n   if (length > (png_uint_32)65535L)\n   {\n      png_warning(png_ptr, \"iCCP chunk too large to fit in memory\");\n      skip = length - (png_uint_32)65535L;\n      length = (png_uint_32)65535L;\n   }\n#endif\n\n   png_free(png_ptr, png_ptr->chunkdata);\n   png_ptr->chunkdata = (png_charp)png_malloc(png_ptr, length + 1);\n   slength = length;\n   png_crc_read(png_ptr, (png_bytep)png_ptr->chunkdata, slength);\n\n   if (png_crc_finish(png_ptr, skip))\n   {\n      png_free(png_ptr, png_ptr->chunkdata);\n      png_ptr->chunkdata = NULL;\n      return;\n   }\n\n   png_ptr->chunkdata[slength] = 0x00;\n\n   for (profile = png_ptr->chunkdata; *profile; profile++)\n      /* Empty loop to find end of name */ ;\n\n   ++profile;\n\n   /* There should be at least one zero (the compression type byte)\n    * following the separator, and we should be on it\n    */\n   if (profile >= png_ptr->chunkdata + slength - 1)\n   {\n      png_free(png_ptr, png_ptr->chunkdata);\n      png_ptr->chunkdata = NULL;\n      png_warning(png_ptr, \"Malformed iCCP chunk\");\n      return;\n   }\n\n   /* Compression_type should always be zero */\n   compression_type = *profile++;\n\n   if (compression_type)\n   {\n      png_warning(png_ptr, \"Ignoring nonzero compression type in iCCP chunk\");\n      compression_type = 0x00;  /* Reset it to zero (libpng-1.0.6 through 1.0.8\n                                 wrote nonzero) */\n   }\n\n   prefix_length = profile - png_ptr->chunkdata;\n   png_decompress_chunk(png_ptr, compression_type,\n       slength, prefix_length, &data_length);\n\n   profile_length = data_length - prefix_length;\n\n   if (prefix_length > data_length || profile_length < 4)\n   {\n      png_free(png_ptr, png_ptr->chunkdata);\n      png_ptr->chunkdata = NULL;\n      png_warning(png_ptr, \"Profile size field missing from iCCP chunk\");\n      return;\n   }\n\n   /* Check the profile_size recorded in the first 32 bits of the ICC profile */\n   pC = (png_bytep)(png_ptr->chunkdata + prefix_length);\n   profile_size = ((*(pC    )) << 24) |\n                  ((*(pC + 1)) << 16) |\n                  ((*(pC + 2)) <<  8) |\n                  ((*(pC + 3))      );\n\n   /* NOTE: the following guarantees that 'profile_length' fits into 32 bits,\n    * because profile_size is a 32 bit value.\n    */\n   if (profile_size < profile_length)\n      profile_length = profile_size;\n\n   /* And the following guarantees that profile_size == profile_length. */\n   if (profile_size > profile_length)\n   {\n      PNG_WARNING_PARAMETERS(p)\n\n      png_free(png_ptr, png_ptr->chunkdata);\n      png_ptr->chunkdata = NULL;\n\n      png_warning_parameter_unsigned(p, 1, PNG_NUMBER_FORMAT_u, profile_size);\n      png_warning_parameter_unsigned(p, 2, PNG_NUMBER_FORMAT_u, profile_length);\n      png_formatted_warning(png_ptr, p,\n         \"Ignoring iCCP chunk with declared size = @1 and actual length = @2\");\n      return;\n   }\n\n   png_set_iCCP(png_ptr, info_ptr, png_ptr->chunkdata,\n       compression_type, (png_bytep)png_ptr->chunkdata + prefix_length,\n       profile_size);\n   png_free(png_ptr, png_ptr->chunkdata);\n   png_ptr->chunkdata = NULL;\n}\n#endif /* PNG_READ_iCCP_SUPPORTED */\n\n#ifdef PNG_READ_sPLT_SUPPORTED\nvoid /* PRIVATE */\npng_handle_sPLT(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)\n/* Note: this does not properly handle chunks that are > 64K under DOS */\n{\n   png_bytep entry_start;\n   png_sPLT_t new_palette;\n   png_sPLT_entryp pp;\n   png_uint_32 data_length;\n   int entry_size, i;\n   png_uint_32 skip = 0;\n   png_size_t slength;\n   png_uint_32 dl;\n   png_size_t max_dl;\n\n   png_debug(1, \"in png_handle_sPLT\");\n\n#ifdef PNG_USER_LIMITS_SUPPORTED\n\n   if (png_ptr->user_chunk_cache_max != 0)\n   {\n      if (png_ptr->user_chunk_cache_max == 1)\n      {\n         png_crc_finish(png_ptr, length);\n         return;\n      }\n\n      if (--png_ptr->user_chunk_cache_max == 1)\n      {\n         png_warning(png_ptr, \"No space in chunk cache for sPLT\");\n         png_crc_finish(png_ptr, length);\n         return;\n      }\n   }\n#endif\n\n   if (!(png_ptr->mode & PNG_HAVE_IHDR))\n      png_error(png_ptr, \"Missing IHDR before sPLT\");\n\n   else if (png_ptr->mode & PNG_HAVE_IDAT)\n   {\n      png_warning(png_ptr, \"Invalid sPLT after IDAT\");\n      png_crc_finish(png_ptr, length);\n      return;\n   }\n\n#ifdef PNG_MAX_MALLOC_64K\n   if (length > (png_uint_32)65535L)\n   {\n      png_warning(png_ptr, \"sPLT chunk too large to fit in memory\");\n      skip = length - (png_uint_32)65535L;\n      length = (png_uint_32)65535L;\n   }\n#endif\n\n   png_free(png_ptr, png_ptr->chunkdata);\n   png_ptr->chunkdata = (png_charp)png_malloc(png_ptr, length + 1);\n\n   /* WARNING: this may break if size_t is less than 32 bits; it is assumed\n    * that the PNG_MAX_MALLOC_64K test is enabled in this case, but this is a\n    * potential breakage point if the types in pngconf.h aren't exactly right.\n    */\n   slength = length;\n   png_crc_read(png_ptr, (png_bytep)png_ptr->chunkdata, slength);\n\n   if (png_crc_finish(png_ptr, skip))\n   {\n      png_free(png_ptr, png_ptr->chunkdata);\n      png_ptr->chunkdata = NULL;\n      return;\n   }\n\n   png_ptr->chunkdata[slength] = 0x00;\n\n   for (entry_start = (png_bytep)png_ptr->chunkdata; *entry_start;\n       entry_start++)\n      /* Empty loop to find end of name */ ;\n\n   ++entry_start;\n\n   /* A sample depth should follow the separator, and we should be on it  */\n   if (entry_start > (png_bytep)png_ptr->chunkdata + slength - 2)\n   {\n      png_free(png_ptr, png_ptr->chunkdata);\n      png_ptr->chunkdata = NULL;\n      png_warning(png_ptr, \"malformed sPLT chunk\");\n      return;\n   }\n\n   new_palette.depth = *entry_start++;\n   entry_size = (new_palette.depth == 8 ? 6 : 10);\n   /* This must fit in a png_uint_32 because it is derived from the original\n    * chunk data length (and use 'length', not 'slength' here for clarity -\n    * they are guaranteed to be the same, see the tests above.)\n    */\n   data_length = length - (png_uint_32)(entry_start -\n      (png_bytep)png_ptr->chunkdata);\n\n   /* Integrity-check the data length */\n   if (data_length % entry_size)\n   {\n      png_free(png_ptr, png_ptr->chunkdata);\n      png_ptr->chunkdata = NULL;\n      png_warning(png_ptr, \"sPLT chunk has bad length\");\n      return;\n   }\n\n   dl = (png_int_32)(data_length / entry_size);\n   max_dl = PNG_SIZE_MAX / png_sizeof(png_sPLT_entry);\n\n   if (dl > max_dl)\n   {\n       png_warning(png_ptr, \"sPLT chunk too long\");\n       return;\n   }\n\n   new_palette.nentries = (png_int_32)(data_length / entry_size);\n\n   new_palette.entries = (png_sPLT_entryp)png_malloc_warn(\n       png_ptr, new_palette.nentries * png_sizeof(png_sPLT_entry));\n\n   if (new_palette.entries == NULL)\n   {\n       png_warning(png_ptr, \"sPLT chunk requires too much memory\");\n       return;\n   }\n\n#ifdef PNG_POINTER_INDEXING_SUPPORTED\n   for (i = 0; i < new_palette.nentries; i++)\n   {\n      pp = new_palette.entries + i;\n\n      if (new_palette.depth == 8)\n      {\n         pp->red = *entry_start++;\n         pp->green = *entry_start++;\n         pp->blue = *entry_start++;\n         pp->alpha = *entry_start++;\n      }\n\n      else\n      {\n         pp->red   = png_get_uint_16(entry_start); entry_start += 2;\n         pp->green = png_get_uint_16(entry_start); entry_start += 2;\n         pp->blue  = png_get_uint_16(entry_start); entry_start += 2;\n         pp->alpha = png_get_uint_16(entry_start); entry_start += 2;\n      }\n\n      pp->frequency = png_get_uint_16(entry_start); entry_start += 2;\n   }\n#else\n   pp = new_palette.entries;\n\n   for (i = 0; i < new_palette.nentries; i++)\n   {\n\n      if (new_palette.depth == 8)\n      {\n         pp[i].red   = *entry_start++;\n         pp[i].green = *entry_start++;\n         pp[i].blue  = *entry_start++;\n         pp[i].alpha = *entry_start++;\n      }\n\n      else\n      {\n         pp[i].red   = png_get_uint_16(entry_start); entry_start += 2;\n         pp[i].green = png_get_uint_16(entry_start); entry_start += 2;\n         pp[i].blue  = png_get_uint_16(entry_start); entry_start += 2;\n         pp[i].alpha = png_get_uint_16(entry_start); entry_start += 2;\n      }\n\n      pp[i].frequency = png_get_uint_16(entry_start); entry_start += 2;\n   }\n#endif\n\n   /* Discard all chunk data except the name and stash that */\n   new_palette.name = png_ptr->chunkdata;\n\n   png_set_sPLT(png_ptr, info_ptr, &new_palette, 1);\n\n   png_free(png_ptr, png_ptr->chunkdata);\n   png_ptr->chunkdata = NULL;\n   png_free(png_ptr, new_palette.entries);\n}\n#endif /* PNG_READ_sPLT_SUPPORTED */\n\n#ifdef PNG_READ_tRNS_SUPPORTED\nvoid /* PRIVATE */\npng_handle_tRNS(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)\n{\n   png_byte readbuf[PNG_MAX_PALETTE_LENGTH];\n\n   png_debug(1, \"in png_handle_tRNS\");\n\n   if (!(png_ptr->mode & PNG_HAVE_IHDR))\n      png_error(png_ptr, \"Missing IHDR before tRNS\");\n\n   else if (png_ptr->mode & PNG_HAVE_IDAT)\n   {\n      png_warning(png_ptr, \"Invalid tRNS after IDAT\");\n      png_crc_finish(png_ptr, length);\n      return;\n   }\n\n   else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS))\n   {\n      png_warning(png_ptr, \"Duplicate tRNS chunk\");\n      png_crc_finish(png_ptr, length);\n      return;\n   }\n\n   if (png_ptr->color_type == PNG_COLOR_TYPE_GRAY)\n   {\n      png_byte buf[2];\n\n      if (length != 2)\n      {\n         png_warning(png_ptr, \"Incorrect tRNS chunk length\");\n         png_crc_finish(png_ptr, length);\n         return;\n      }\n\n      png_crc_read(png_ptr, buf, 2);\n      png_ptr->num_trans = 1;\n      png_ptr->trans_color.gray = png_get_uint_16(buf);\n   }\n\n   else if (png_ptr->color_type == PNG_COLOR_TYPE_RGB)\n   {\n      png_byte buf[6];\n\n      if (length != 6)\n      {\n         png_warning(png_ptr, \"Incorrect tRNS chunk length\");\n         png_crc_finish(png_ptr, length);\n         return;\n      }\n\n      png_crc_read(png_ptr, buf, (png_size_t)length);\n      png_ptr->num_trans = 1;\n      png_ptr->trans_color.red = png_get_uint_16(buf);\n      png_ptr->trans_color.green = png_get_uint_16(buf + 2);\n      png_ptr->trans_color.blue = png_get_uint_16(buf + 4);\n   }\n\n   else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)\n   {\n      if (!(png_ptr->mode & PNG_HAVE_PLTE))\n      {\n         /* Should be an error, but we can cope with it. */\n         png_warning(png_ptr, \"Missing PLTE before tRNS\");\n      }\n\n      if (length > (png_uint_32)png_ptr->num_palette ||\n          length > PNG_MAX_PALETTE_LENGTH)\n      {\n         png_warning(png_ptr, \"Incorrect tRNS chunk length\");\n         png_crc_finish(png_ptr, length);\n         return;\n      }\n\n      if (length == 0)\n      {\n         png_warning(png_ptr, \"Zero length tRNS chunk\");\n         png_crc_finish(png_ptr, length);\n         return;\n      }\n\n      png_crc_read(png_ptr, readbuf, (png_size_t)length);\n      png_ptr->num_trans = (png_uint_16)length;\n   }\n\n   else\n   {\n      png_warning(png_ptr, \"tRNS chunk not allowed with alpha channel\");\n      png_crc_finish(png_ptr, length);\n      return;\n   }\n\n   if (png_crc_finish(png_ptr, 0))\n   {\n      png_ptr->num_trans = 0;\n      return;\n   }\n\n   png_set_tRNS(png_ptr, info_ptr, readbuf, png_ptr->num_trans,\n       &(png_ptr->trans_color));\n}\n#endif\n\n#ifdef PNG_READ_bKGD_SUPPORTED\nvoid /* PRIVATE */\npng_handle_bKGD(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)\n{\n   png_size_t truelen;\n   png_byte buf[6];\n   png_color_16 background;\n\n   png_debug(1, \"in png_handle_bKGD\");\n\n   if (!(png_ptr->mode & PNG_HAVE_IHDR))\n      png_error(png_ptr, \"Missing IHDR before bKGD\");\n\n   else if (png_ptr->mode & PNG_HAVE_IDAT)\n   {\n      png_warning(png_ptr, \"Invalid bKGD after IDAT\");\n      png_crc_finish(png_ptr, length);\n      return;\n   }\n\n   else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE &&\n       !(png_ptr->mode & PNG_HAVE_PLTE))\n   {\n      png_warning(png_ptr, \"Missing PLTE before bKGD\");\n      png_crc_finish(png_ptr, length);\n      return;\n   }\n\n   else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_bKGD))\n   {\n      png_warning(png_ptr, \"Duplicate bKGD chunk\");\n      png_crc_finish(png_ptr, length);\n      return;\n   }\n\n   if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)\n      truelen = 1;\n\n   else if (png_ptr->color_type & PNG_COLOR_MASK_COLOR)\n      truelen = 6;\n\n   else\n      truelen = 2;\n\n   if (length != truelen)\n   {\n      png_warning(png_ptr, \"Incorrect bKGD chunk length\");\n      png_crc_finish(png_ptr, length);\n      return;\n   }\n\n   png_crc_read(png_ptr, buf, truelen);\n\n   if (png_crc_finish(png_ptr, 0))\n      return;\n\n   /* We convert the index value into RGB components so that we can allow\n    * arbitrary RGB values for background when we have transparency, and\n    * so it is easy to determine the RGB values of the background color\n    * from the info_ptr struct.\n    */\n   if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)\n   {\n      background.index = buf[0];\n\n      if (info_ptr && info_ptr->num_palette)\n      {\n         if (buf[0] >= info_ptr->num_palette)\n         {\n            png_warning(png_ptr, \"Incorrect bKGD chunk index value\");\n            return;\n         }\n\n         background.red = (png_uint_16)png_ptr->palette[buf[0]].red;\n         background.green = (png_uint_16)png_ptr->palette[buf[0]].green;\n         background.blue = (png_uint_16)png_ptr->palette[buf[0]].blue;\n      }\n\n      else\n         background.red = background.green = background.blue = 0;\n\n      background.gray = 0;\n   }\n\n   else if (!(png_ptr->color_type & PNG_COLOR_MASK_COLOR)) /* GRAY */\n   {\n      background.index = 0;\n      background.red =\n      background.green =\n      background.blue =\n      background.gray = png_get_uint_16(buf);\n   }\n\n   else\n   {\n      background.index = 0;\n      background.red = png_get_uint_16(buf);\n      background.green = png_get_uint_16(buf + 2);\n      background.blue = png_get_uint_16(buf + 4);\n      background.gray = 0;\n   }\n\n   png_set_bKGD(png_ptr, info_ptr, &background);\n}\n#endif\n\n#ifdef PNG_READ_hIST_SUPPORTED\nvoid /* PRIVATE */\npng_handle_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)\n{\n   unsigned int num, i;\n   png_uint_16 readbuf[PNG_MAX_PALETTE_LENGTH];\n\n   png_debug(1, \"in png_handle_hIST\");\n\n   if (!(png_ptr->mode & PNG_HAVE_IHDR))\n      png_error(png_ptr, \"Missing IHDR before hIST\");\n\n   else if (png_ptr->mode & PNG_HAVE_IDAT)\n   {\n      png_warning(png_ptr, \"Invalid hIST after IDAT\");\n      png_crc_finish(png_ptr, length);\n      return;\n   }\n\n   else if (!(png_ptr->mode & PNG_HAVE_PLTE))\n   {\n      png_warning(png_ptr, \"Missing PLTE before hIST\");\n      png_crc_finish(png_ptr, length);\n      return;\n   }\n\n   else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_hIST))\n   {\n      png_warning(png_ptr, \"Duplicate hIST chunk\");\n      png_crc_finish(png_ptr, length);\n      return;\n   }\n\n   num = length / 2 ;\n\n   if (num != (unsigned int)png_ptr->num_palette || num >\n       (unsigned int)PNG_MAX_PALETTE_LENGTH)\n   {\n      png_warning(png_ptr, \"Incorrect hIST chunk length\");\n      png_crc_finish(png_ptr, length);\n      return;\n   }\n\n   for (i = 0; i < num; i++)\n   {\n      png_byte buf[2];\n\n      png_crc_read(png_ptr, buf, 2);\n      readbuf[i] = png_get_uint_16(buf);\n   }\n\n   if (png_crc_finish(png_ptr, 0))\n      return;\n\n   png_set_hIST(png_ptr, info_ptr, readbuf);\n}\n#endif\n\n#ifdef PNG_READ_pHYs_SUPPORTED\nvoid /* PRIVATE */\npng_handle_pHYs(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)\n{\n   png_byte buf[9];\n   png_uint_32 res_x, res_y;\n   int unit_type;\n\n   png_debug(1, \"in png_handle_pHYs\");\n\n   if (!(png_ptr->mode & PNG_HAVE_IHDR))\n      png_error(png_ptr, \"Missing IHDR before pHYs\");\n\n   else if (png_ptr->mode & PNG_HAVE_IDAT)\n   {\n      png_warning(png_ptr, \"Invalid pHYs after IDAT\");\n      png_crc_finish(png_ptr, length);\n      return;\n   }\n\n   else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))\n   {\n      png_warning(png_ptr, \"Duplicate pHYs chunk\");\n      png_crc_finish(png_ptr, length);\n      return;\n   }\n\n   if (length != 9)\n   {\n      png_warning(png_ptr, \"Incorrect pHYs chunk length\");\n      png_crc_finish(png_ptr, length);\n      return;\n   }\n\n   png_crc_read(png_ptr, buf, 9);\n\n   if (png_crc_finish(png_ptr, 0))\n      return;\n\n   res_x = png_get_uint_32(buf);\n   res_y = png_get_uint_32(buf + 4);\n   unit_type = buf[8];\n   png_set_pHYs(png_ptr, info_ptr, res_x, res_y, unit_type);\n}\n#endif\n\n#ifdef PNG_READ_oFFs_SUPPORTED\nvoid /* PRIVATE */\npng_handle_oFFs(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)\n{\n   png_byte buf[9];\n   png_int_32 offset_x, offset_y;\n   int unit_type;\n\n   png_debug(1, \"in png_handle_oFFs\");\n\n   if (!(png_ptr->mode & PNG_HAVE_IHDR))\n      png_error(png_ptr, \"Missing IHDR before oFFs\");\n\n   else if (png_ptr->mode & PNG_HAVE_IDAT)\n   {\n      png_warning(png_ptr, \"Invalid oFFs after IDAT\");\n      png_crc_finish(png_ptr, length);\n      return;\n   }\n\n   else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs))\n   {\n      png_warning(png_ptr, \"Duplicate oFFs chunk\");\n      png_crc_finish(png_ptr, length);\n      return;\n   }\n\n   if (length != 9)\n   {\n      png_warning(png_ptr, \"Incorrect oFFs chunk length\");\n      png_crc_finish(png_ptr, length);\n      return;\n   }\n\n   png_crc_read(png_ptr, buf, 9);\n\n   if (png_crc_finish(png_ptr, 0))\n      return;\n\n   offset_x = png_get_int_32(buf);\n   offset_y = png_get_int_32(buf + 4);\n   unit_type = buf[8];\n   png_set_oFFs(png_ptr, info_ptr, offset_x, offset_y, unit_type);\n}\n#endif\n\n#ifdef PNG_READ_pCAL_SUPPORTED\n/* Read the pCAL chunk (described in the PNG Extensions document) */\nvoid /* PRIVATE */\npng_handle_pCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)\n{\n   png_int_32 X0, X1;\n   png_byte type, nparams;\n   png_charp buf, units, endptr;\n   png_charpp params;\n   png_size_t slength;\n   int i;\n\n   png_debug(1, \"in png_handle_pCAL\");\n\n   if (!(png_ptr->mode & PNG_HAVE_IHDR))\n      png_error(png_ptr, \"Missing IHDR before pCAL\");\n\n   else if (png_ptr->mode & PNG_HAVE_IDAT)\n   {\n      png_warning(png_ptr, \"Invalid pCAL after IDAT\");\n      png_crc_finish(png_ptr, length);\n      return;\n   }\n\n   else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_pCAL))\n   {\n      png_warning(png_ptr, \"Duplicate pCAL chunk\");\n      png_crc_finish(png_ptr, length);\n      return;\n   }\n\n   png_debug1(2, \"Allocating and reading pCAL chunk data (%u bytes)\",\n       length + 1);\n   png_free(png_ptr, png_ptr->chunkdata);\n   png_ptr->chunkdata = (png_charp)png_malloc_warn(png_ptr, length + 1);\n\n   if (png_ptr->chunkdata == NULL)\n   {\n      png_warning(png_ptr, \"No memory for pCAL purpose\");\n      return;\n   }\n\n   slength = length;\n   png_crc_read(png_ptr, (png_bytep)png_ptr->chunkdata, slength);\n\n   if (png_crc_finish(png_ptr, 0))\n   {\n      png_free(png_ptr, png_ptr->chunkdata);\n      png_ptr->chunkdata = NULL;\n      return;\n   }\n\n   png_ptr->chunkdata[slength] = 0x00; /* Null terminate the last string */\n\n   png_debug(3, \"Finding end of pCAL purpose string\");\n   for (buf = png_ptr->chunkdata; *buf; buf++)\n      /* Empty loop */ ;\n\n   endptr = png_ptr->chunkdata + slength;\n\n   /* We need to have at least 12 bytes after the purpose string\n    * in order to get the parameter information.\n    */\n   if (endptr <= buf + 12)\n   {\n      png_warning(png_ptr, \"Invalid pCAL data\");\n      png_free(png_ptr, png_ptr->chunkdata);\n      png_ptr->chunkdata = NULL;\n      return;\n   }\n\n   png_debug(3, \"Reading pCAL X0, X1, type, nparams, and units\");\n   X0 = png_get_int_32((png_bytep)buf+1);\n   X1 = png_get_int_32((png_bytep)buf+5);\n   type = buf[9];\n   nparams = buf[10];\n   units = buf + 11;\n\n   png_debug(3, \"Checking pCAL equation type and number of parameters\");\n   /* Check that we have the right number of parameters for known\n    * equation types.\n    */\n   if ((type == PNG_EQUATION_LINEAR && nparams != 2) ||\n       (type == PNG_EQUATION_BASE_E && nparams != 3) ||\n       (type == PNG_EQUATION_ARBITRARY && nparams != 3) ||\n       (type == PNG_EQUATION_HYPERBOLIC && nparams != 4))\n   {\n      png_warning(png_ptr, \"Invalid pCAL parameters for equation type\");\n      png_free(png_ptr, png_ptr->chunkdata);\n      png_ptr->chunkdata = NULL;\n      return;\n   }\n\n   else if (type >= PNG_EQUATION_LAST)\n   {\n      png_warning(png_ptr, \"Unrecognized equation type for pCAL chunk\");\n   }\n\n   for (buf = units; *buf; buf++)\n      /* Empty loop to move past the units string. */ ;\n\n   png_debug(3, \"Allocating pCAL parameters array\");\n\n   params = (png_charpp)png_malloc_warn(png_ptr,\n       (png_size_t)(nparams * png_sizeof(png_charp)));\n\n   if (params == NULL)\n   {\n      png_free(png_ptr, png_ptr->chunkdata);\n      png_ptr->chunkdata = NULL;\n      png_warning(png_ptr, \"No memory for pCAL params\");\n      return;\n   }\n\n   /* Get pointers to the start of each parameter string. */\n   for (i = 0; i < (int)nparams; i++)\n   {\n      buf++; /* Skip the null string terminator from previous parameter. */\n\n      png_debug1(3, \"Reading pCAL parameter %d\", i);\n\n      for (params[i] = buf; buf <= endptr && *buf != 0x00; buf++)\n         /* Empty loop to move past each parameter string */ ;\n\n      /* Make sure we haven't run out of data yet */\n      if (buf > endptr)\n      {\n         png_warning(png_ptr, \"Invalid pCAL data\");\n         png_free(png_ptr, png_ptr->chunkdata);\n         png_ptr->chunkdata = NULL;\n         png_free(png_ptr, params);\n         return;\n      }\n   }\n\n   png_set_pCAL(png_ptr, info_ptr, png_ptr->chunkdata, X0, X1, type, nparams,\n      units, params);\n\n   png_free(png_ptr, png_ptr->chunkdata);\n   png_ptr->chunkdata = NULL;\n   png_free(png_ptr, params);\n}\n#endif\n\n#ifdef PNG_READ_sCAL_SUPPORTED\n/* Read the sCAL chunk */\nvoid /* PRIVATE */\npng_handle_sCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)\n{\n   png_size_t slength, i;\n   int state;\n\n   png_debug(1, \"in png_handle_sCAL\");\n\n   if (!(png_ptr->mode & PNG_HAVE_IHDR))\n      png_error(png_ptr, \"Missing IHDR before sCAL\");\n\n   else if (png_ptr->mode & PNG_HAVE_IDAT)\n   {\n      png_warning(png_ptr, \"Invalid sCAL after IDAT\");\n      png_crc_finish(png_ptr, length);\n      return;\n   }\n\n   else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_sCAL))\n   {\n      png_warning(png_ptr, \"Duplicate sCAL chunk\");\n      png_crc_finish(png_ptr, length);\n      return;\n   }\n\n   /* Need unit type, width, \\0, height: minimum 4 bytes */\n   else if (length < 4)\n   {\n      png_warning(png_ptr, \"sCAL chunk too short\");\n      png_crc_finish(png_ptr, length);\n      return;\n   }\n\n   png_debug1(2, \"Allocating and reading sCAL chunk data (%u bytes)\",\n      length + 1);\n\n   png_ptr->chunkdata = (png_charp)png_malloc_warn(png_ptr, length + 1);\n\n   if (png_ptr->chunkdata == NULL)\n   {\n      png_warning(png_ptr, \"Out of memory while processing sCAL chunk\");\n      png_crc_finish(png_ptr, length);\n      return;\n   }\n\n   slength = length;\n   png_crc_read(png_ptr, (png_bytep)png_ptr->chunkdata, slength);\n   png_ptr->chunkdata[slength] = 0x00; /* Null terminate the last string */\n\n   if (png_crc_finish(png_ptr, 0))\n   {\n      png_free(png_ptr, png_ptr->chunkdata);\n      png_ptr->chunkdata = NULL;\n      return;\n   }\n\n   /* Validate the unit. */\n   if (png_ptr->chunkdata[0] != 1 && png_ptr->chunkdata[0] != 2)\n   {\n      png_warning(png_ptr, \"Invalid sCAL ignored: invalid unit\");\n      png_free(png_ptr, png_ptr->chunkdata);\n      png_ptr->chunkdata = NULL;\n      return;\n   }\n\n   /* Validate the ASCII numbers, need two ASCII numbers separated by\n    * a '\\0' and they need to fit exactly in the chunk data.\n    */\n   i = 1;\n   state = 0;\n\n   if (!png_check_fp_number(png_ptr->chunkdata, slength, &state, &i) ||\n       i >= slength || png_ptr->chunkdata[i++] != 0)\n      png_warning(png_ptr, \"Invalid sCAL chunk ignored: bad width format\");\n\n   else if (!PNG_FP_IS_POSITIVE(state))\n      png_warning(png_ptr, \"Invalid sCAL chunk ignored: non-positive width\");\n\n   else\n   {\n      png_size_t heighti = i;\n\n      state = 0;\n      if (!png_check_fp_number(png_ptr->chunkdata, slength, &state, &i) ||\n          i != slength)\n         png_warning(png_ptr, \"Invalid sCAL chunk ignored: bad height format\");\n\n      else if (!PNG_FP_IS_POSITIVE(state))\n         png_warning(png_ptr,\n            \"Invalid sCAL chunk ignored: non-positive height\");\n\n      else\n         /* This is the (only) success case. */\n         png_set_sCAL_s(png_ptr, info_ptr, png_ptr->chunkdata[0],\n            png_ptr->chunkdata+1, png_ptr->chunkdata+heighti);\n   }\n\n   /* Clean up - just free the temporarily allocated buffer. */\n   png_free(png_ptr, png_ptr->chunkdata);\n   png_ptr->chunkdata = NULL;\n}\n#endif\n\n#ifdef PNG_READ_tIME_SUPPORTED\nvoid /* PRIVATE */\npng_handle_tIME(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)\n{\n   png_byte buf[7];\n   png_time mod_time;\n\n   png_debug(1, \"in png_handle_tIME\");\n\n   if (!(png_ptr->mode & PNG_HAVE_IHDR))\n      png_error(png_ptr, \"Out of place tIME chunk\");\n\n   else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_tIME))\n   {\n      png_warning(png_ptr, \"Duplicate tIME chunk\");\n      png_crc_finish(png_ptr, length);\n      return;\n   }\n\n   if (png_ptr->mode & PNG_HAVE_IDAT)\n      png_ptr->mode |= PNG_AFTER_IDAT;\n\n   if (length != 7)\n   {\n      png_warning(png_ptr, \"Incorrect tIME chunk length\");\n      png_crc_finish(png_ptr, length);\n      return;\n   }\n\n   png_crc_read(png_ptr, buf, 7);\n\n   if (png_crc_finish(png_ptr, 0))\n      return;\n\n   mod_time.second = buf[6];\n   mod_time.minute = buf[5];\n   mod_time.hour = buf[4];\n   mod_time.day = buf[3];\n   mod_time.month = buf[2];\n   mod_time.year = png_get_uint_16(buf);\n\n   png_set_tIME(png_ptr, info_ptr, &mod_time);\n}\n#endif\n\n#ifdef PNG_READ_tEXt_SUPPORTED\n/* Note: this does not properly handle chunks that are > 64K under DOS */\nvoid /* PRIVATE */\npng_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)\n{\n   png_textp text_ptr;\n   png_charp key;\n   png_charp text;\n   png_uint_32 skip = 0;\n   png_size_t slength;\n   int ret;\n\n   png_debug(1, \"in png_handle_tEXt\");\n\n#ifdef PNG_USER_LIMITS_SUPPORTED\n   if (png_ptr->user_chunk_cache_max != 0)\n   {\n      if (png_ptr->user_chunk_cache_max == 1)\n      {\n         png_crc_finish(png_ptr, length);\n         return;\n      }\n\n      if (--png_ptr->user_chunk_cache_max == 1)\n      {\n         png_warning(png_ptr, \"No space in chunk cache for tEXt\");\n         png_crc_finish(png_ptr, length);\n         return;\n      }\n   }\n#endif\n\n   if (!(png_ptr->mode & PNG_HAVE_IHDR))\n      png_error(png_ptr, \"Missing IHDR before tEXt\");\n\n   if (png_ptr->mode & PNG_HAVE_IDAT)\n      png_ptr->mode |= PNG_AFTER_IDAT;\n\n#ifdef PNG_MAX_MALLOC_64K\n   if (length > (png_uint_32)65535L)\n   {\n      png_warning(png_ptr, \"tEXt chunk too large to fit in memory\");\n      skip = length - (png_uint_32)65535L;\n      length = (png_uint_32)65535L;\n   }\n#endif\n\n   png_free(png_ptr, png_ptr->chunkdata);\n\n   png_ptr->chunkdata = (png_charp)png_malloc_warn(png_ptr, length + 1);\n\n   if (png_ptr->chunkdata == NULL)\n   {\n     png_warning(png_ptr, \"No memory to process text chunk\");\n     return;\n   }\n\n   slength = length;\n   png_crc_read(png_ptr, (png_bytep)png_ptr->chunkdata, slength);\n\n   if (png_crc_finish(png_ptr, skip))\n   {\n      png_free(png_ptr, png_ptr->chunkdata);\n      png_ptr->chunkdata = NULL;\n      return;\n   }\n\n   key = png_ptr->chunkdata;\n\n   key[slength] = 0x00;\n\n   for (text = key; *text; text++)\n      /* Empty loop to find end of key */ ;\n\n   if (text != key + slength)\n      text++;\n\n   text_ptr = (png_textp)png_malloc_warn(png_ptr,\n       png_sizeof(png_text));\n\n   if (text_ptr == NULL)\n   {\n      png_warning(png_ptr, \"Not enough memory to process text chunk\");\n      png_free(png_ptr, png_ptr->chunkdata);\n      png_ptr->chunkdata = NULL;\n      return;\n   }\n\n   text_ptr->compression = PNG_TEXT_COMPRESSION_NONE;\n   text_ptr->key = key;\n   text_ptr->lang = NULL;\n   text_ptr->lang_key = NULL;\n   text_ptr->itxt_length = 0;\n   text_ptr->text = text;\n   text_ptr->text_length = png_strlen(text);\n\n   ret = png_set_text_2(png_ptr, info_ptr, text_ptr, 1);\n\n   png_free(png_ptr, png_ptr->chunkdata);\n   png_ptr->chunkdata = NULL;\n   png_free(png_ptr, text_ptr);\n\n   if (ret)\n      png_warning(png_ptr, \"Insufficient memory to process text chunk\");\n}\n#endif\n\n#ifdef PNG_READ_zTXt_SUPPORTED\n/* Note: this does not correctly handle chunks that are > 64K under DOS */\nvoid /* PRIVATE */\npng_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)\n{\n   png_textp text_ptr;\n   png_charp text;\n   int comp_type;\n   int ret;\n   png_size_t slength, prefix_len, data_len;\n\n   png_debug(1, \"in png_handle_zTXt\");\n\n#ifdef PNG_USER_LIMITS_SUPPORTED\n   if (png_ptr->user_chunk_cache_max != 0)\n   {\n      if (png_ptr->user_chunk_cache_max == 1)\n      {\n         png_crc_finish(png_ptr, length);\n         return;\n      }\n\n      if (--png_ptr->user_chunk_cache_max == 1)\n      {\n         png_warning(png_ptr, \"No space in chunk cache for zTXt\");\n         png_crc_finish(png_ptr, length);\n         return;\n      }\n   }\n#endif\n\n   if (!(png_ptr->mode & PNG_HAVE_IHDR))\n      png_error(png_ptr, \"Missing IHDR before zTXt\");\n\n   if (png_ptr->mode & PNG_HAVE_IDAT)\n      png_ptr->mode |= PNG_AFTER_IDAT;\n\n#ifdef PNG_MAX_MALLOC_64K\n   /* We will no doubt have problems with chunks even half this size, but\n    * there is no hard and fast rule to tell us where to stop.\n    */\n   if (length > (png_uint_32)65535L)\n   {\n      png_warning(png_ptr, \"zTXt chunk too large to fit in memory\");\n      png_crc_finish(png_ptr, length);\n      return;\n   }\n#endif\n\n   png_free(png_ptr, png_ptr->chunkdata);\n   png_ptr->chunkdata = (png_charp)png_malloc_warn(png_ptr, length + 1);\n\n   if (png_ptr->chunkdata == NULL)\n   {\n      png_warning(png_ptr, \"Out of memory processing zTXt chunk\");\n      return;\n   }\n\n   slength = length;\n   png_crc_read(png_ptr, (png_bytep)png_ptr->chunkdata, slength);\n\n   if (png_crc_finish(png_ptr, 0))\n   {\n      png_free(png_ptr, png_ptr->chunkdata);\n      png_ptr->chunkdata = NULL;\n      return;\n   }\n\n   png_ptr->chunkdata[slength] = 0x00;\n\n   for (text = png_ptr->chunkdata; *text; text++)\n      /* Empty loop */ ;\n\n   /* zTXt must have some text after the chunkdataword */\n   if (text >= png_ptr->chunkdata + slength - 2)\n   {\n      png_warning(png_ptr, \"Truncated zTXt chunk\");\n      png_free(png_ptr, png_ptr->chunkdata);\n      png_ptr->chunkdata = NULL;\n      return;\n   }\n\n   else\n   {\n       comp_type = *(++text);\n\n       if (comp_type != PNG_TEXT_COMPRESSION_zTXt)\n       {\n          png_warning(png_ptr, \"Unknown compression type in zTXt chunk\");\n          comp_type = PNG_TEXT_COMPRESSION_zTXt;\n       }\n\n       text++;        /* Skip the compression_method byte */\n   }\n\n   prefix_len = text - png_ptr->chunkdata;\n\n   png_decompress_chunk(png_ptr, comp_type,\n       (png_size_t)length, prefix_len, &data_len);\n\n   text_ptr = (png_textp)png_malloc_warn(png_ptr,\n       png_sizeof(png_text));\n\n   if (text_ptr == NULL)\n   {\n      png_warning(png_ptr, \"Not enough memory to process zTXt chunk\");\n      png_free(png_ptr, png_ptr->chunkdata);\n      png_ptr->chunkdata = NULL;\n      return;\n   }\n\n   text_ptr->compression = comp_type;\n   text_ptr->key = png_ptr->chunkdata;\n   text_ptr->lang = NULL;\n   text_ptr->lang_key = NULL;\n   text_ptr->itxt_length = 0;\n   text_ptr->text = png_ptr->chunkdata + prefix_len;\n   text_ptr->text_length = data_len;\n\n   ret = png_set_text_2(png_ptr, info_ptr, text_ptr, 1);\n\n   png_free(png_ptr, text_ptr);\n   png_free(png_ptr, png_ptr->chunkdata);\n   png_ptr->chunkdata = NULL;\n\n   if (ret)\n      png_error(png_ptr, \"Insufficient memory to store zTXt chunk\");\n}\n#endif\n\n#ifdef PNG_READ_iTXt_SUPPORTED\n/* Note: this does not correctly handle chunks that are > 64K under DOS */\nvoid /* PRIVATE */\npng_handle_iTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)\n{\n   png_textp text_ptr;\n   png_charp key, lang, text, lang_key;\n   int comp_flag;\n   int comp_type = 0;\n   int ret;\n   png_size_t slength, prefix_len, data_len;\n\n   png_debug(1, \"in png_handle_iTXt\");\n\n#ifdef PNG_USER_LIMITS_SUPPORTED\n   if (png_ptr->user_chunk_cache_max != 0)\n   {\n      if (png_ptr->user_chunk_cache_max == 1)\n      {\n         png_crc_finish(png_ptr, length);\n         return;\n      }\n\n      if (--png_ptr->user_chunk_cache_max == 1)\n      {\n         png_warning(png_ptr, \"No space in chunk cache for iTXt\");\n         png_crc_finish(png_ptr, length);\n         return;\n      }\n   }\n#endif\n\n   if (!(png_ptr->mode & PNG_HAVE_IHDR))\n      png_error(png_ptr, \"Missing IHDR before iTXt\");\n\n   if (png_ptr->mode & PNG_HAVE_IDAT)\n      png_ptr->mode |= PNG_AFTER_IDAT;\n\n#ifdef PNG_MAX_MALLOC_64K\n   /* We will no doubt have problems with chunks even half this size, but\n    * there is no hard and fast rule to tell us where to stop.\n    */\n   if (length > (png_uint_32)65535L)\n   {\n      png_warning(png_ptr, \"iTXt chunk too large to fit in memory\");\n      png_crc_finish(png_ptr, length);\n      return;\n   }\n#endif\n\n   png_free(png_ptr, png_ptr->chunkdata);\n   png_ptr->chunkdata = (png_charp)png_malloc_warn(png_ptr, length + 1);\n\n   if (png_ptr->chunkdata == NULL)\n   {\n      png_warning(png_ptr, \"No memory to process iTXt chunk\");\n      return;\n   }\n\n   slength = length;\n   png_crc_read(png_ptr, (png_bytep)png_ptr->chunkdata, slength);\n\n   if (png_crc_finish(png_ptr, 0))\n   {\n      png_free(png_ptr, png_ptr->chunkdata);\n      png_ptr->chunkdata = NULL;\n      return;\n   }\n\n   png_ptr->chunkdata[slength] = 0x00;\n\n   for (lang = png_ptr->chunkdata; *lang; lang++)\n      /* Empty loop */ ;\n\n   lang++;        /* Skip NUL separator */\n\n   /* iTXt must have a language tag (possibly empty), two compression bytes,\n    * translated keyword (possibly empty), and possibly some text after the\n    * keyword\n    */\n\n   if (lang >= png_ptr->chunkdata + slength - 3)\n   {\n      png_warning(png_ptr, \"Truncated iTXt chunk\");\n      png_free(png_ptr, png_ptr->chunkdata);\n      png_ptr->chunkdata = NULL;\n      return;\n   }\n\n   else\n   {\n      comp_flag = *lang++;\n      comp_type = *lang++;\n   }\n\n   if (comp_type || (comp_flag && comp_flag != PNG_TEXT_COMPRESSION_zTXt))\n   {\n      png_warning(png_ptr, \"Unknown iTXt compression type or method\");\n      png_free(png_ptr, png_ptr->chunkdata);\n      png_ptr->chunkdata = NULL;\n      return;\n   }\n\n   for (lang_key = lang; *lang_key; lang_key++)\n      /* Empty loop */ ;\n\n   lang_key++;        /* Skip NUL separator */\n\n   if (lang_key >= png_ptr->chunkdata + slength)\n   {\n      png_warning(png_ptr, \"Truncated iTXt chunk\");\n      png_free(png_ptr, png_ptr->chunkdata);\n      png_ptr->chunkdata = NULL;\n      return;\n   }\n\n   for (text = lang_key; *text; text++)\n      /* Empty loop */ ;\n\n   text++;        /* Skip NUL separator */\n\n   if (text >= png_ptr->chunkdata + slength)\n   {\n      png_warning(png_ptr, \"Malformed iTXt chunk\");\n      png_free(png_ptr, png_ptr->chunkdata);\n      png_ptr->chunkdata = NULL;\n      return;\n   }\n\n   prefix_len = text - png_ptr->chunkdata;\n\n   key=png_ptr->chunkdata;\n\n   if (comp_flag)\n      png_decompress_chunk(png_ptr, comp_type,\n          (size_t)length, prefix_len, &data_len);\n\n   else\n      data_len = png_strlen(png_ptr->chunkdata + prefix_len);\n\n   text_ptr = (png_textp)png_malloc_warn(png_ptr,\n       png_sizeof(png_text));\n\n   if (text_ptr == NULL)\n   {\n      png_warning(png_ptr, \"Not enough memory to process iTXt chunk\");\n      png_free(png_ptr, png_ptr->chunkdata);\n      png_ptr->chunkdata = NULL;\n      return;\n   }\n\n   text_ptr->compression = (int)comp_flag + 1;\n   text_ptr->lang_key = png_ptr->chunkdata + (lang_key - key);\n   text_ptr->lang = png_ptr->chunkdata + (lang - key);\n   text_ptr->itxt_length = data_len;\n   text_ptr->text_length = 0;\n   text_ptr->key = png_ptr->chunkdata;\n   text_ptr->text = png_ptr->chunkdata + prefix_len;\n\n   ret = png_set_text_2(png_ptr, info_ptr, text_ptr, 1);\n\n   png_free(png_ptr, text_ptr);\n   png_free(png_ptr, png_ptr->chunkdata);\n   png_ptr->chunkdata = NULL;\n\n   if (ret)\n      png_error(png_ptr, \"Insufficient memory to store iTXt chunk\");\n}\n#endif\n\n/* This function is called when we haven't found a handler for a\n * chunk.  If there isn't a problem with the chunk itself (ie bad\n * chunk name, CRC, or a critical chunk), the chunk is silently ignored\n * -- unless the PNG_FLAG_UNKNOWN_CHUNKS_SUPPORTED flag is on in which\n * case it will be saved away to be written out later.\n */\nvoid /* PRIVATE */\npng_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)\n{\n   png_uint_32 skip = 0;\n\n   png_debug(1, \"in png_handle_unknown\");\n\n#ifdef PNG_USER_LIMITS_SUPPORTED\n   if (png_ptr->user_chunk_cache_max != 0)\n   {\n      if (png_ptr->user_chunk_cache_max == 1)\n      {\n         png_crc_finish(png_ptr, length);\n         return;\n      }\n\n      if (--png_ptr->user_chunk_cache_max == 1)\n      {\n         png_warning(png_ptr, \"No space in chunk cache for unknown chunk\");\n         png_crc_finish(png_ptr, length);\n         return;\n      }\n   }\n#endif\n\n   if (png_ptr->mode & PNG_HAVE_IDAT)\n   {\n      if (png_ptr->chunk_name != png_IDAT)\n         png_ptr->mode |= PNG_AFTER_IDAT;\n   }\n\n   if (PNG_CHUNK_CRITICAL(png_ptr->chunk_name))\n   {\n#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED\n      if (png_chunk_unknown_handling(png_ptr, png_ptr->chunk_name) !=\n          PNG_HANDLE_CHUNK_ALWAYS\n#ifdef PNG_READ_USER_CHUNKS_SUPPORTED\n          && png_ptr->read_user_chunk_fn == NULL\n#endif\n          )\n#endif\n         png_chunk_error(png_ptr, \"unknown critical chunk\");\n   }\n\n#ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED\n   if ((png_ptr->flags & PNG_FLAG_KEEP_UNKNOWN_CHUNKS)\n#ifdef PNG_READ_USER_CHUNKS_SUPPORTED\n       || (png_ptr->read_user_chunk_fn != NULL)\n#endif\n       )\n   {\n#ifdef PNG_MAX_MALLOC_64K\n      if (length > 65535)\n      {\n         png_warning(png_ptr, \"unknown chunk too large to fit in memory\");\n         skip = length - 65535;\n         length = 65535;\n      }\n#endif\n\n      /* TODO: this code is very close to the unknown handling in pngpread.c,\n       * maybe it can be put into a common utility routine?\n       * png_struct::unknown_chunk is just used as a temporary variable, along\n       * with the data into which the chunk is read.  These can be eliminated.\n       */\n      PNG_CSTRING_FROM_CHUNK(png_ptr->unknown_chunk.name, png_ptr->chunk_name);\n      png_ptr->unknown_chunk.size = (png_size_t)length;\n\n      if (length == 0)\n         png_ptr->unknown_chunk.data = NULL;\n\n      else\n      {\n         png_ptr->unknown_chunk.data = (png_bytep)png_malloc(png_ptr, length);\n         png_crc_read(png_ptr, png_ptr->unknown_chunk.data, length);\n      }\n\n#ifdef PNG_READ_USER_CHUNKS_SUPPORTED\n      if (png_ptr->read_user_chunk_fn != NULL)\n      {\n         /* Callback to user unknown chunk handler */\n         int ret;\n\n         ret = (*(png_ptr->read_user_chunk_fn))\n             (png_ptr, &png_ptr->unknown_chunk);\n\n         if (ret < 0)\n            png_chunk_error(png_ptr, \"error in user chunk\");\n\n         if (ret == 0)\n         {\n            if (PNG_CHUNK_CRITICAL(png_ptr->chunk_name))\n            {\n#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED\n               if (png_chunk_unknown_handling(png_ptr, png_ptr->chunk_name) !=\n                   PNG_HANDLE_CHUNK_ALWAYS)\n#endif\n                  png_chunk_error(png_ptr, \"unknown critical chunk\");\n            }\n\n            png_set_unknown_chunks(png_ptr, info_ptr,\n                &png_ptr->unknown_chunk, 1);\n         }\n      }\n\n      else\n#endif\n         png_set_unknown_chunks(png_ptr, info_ptr, &png_ptr->unknown_chunk, 1);\n\n      png_free(png_ptr, png_ptr->unknown_chunk.data);\n      png_ptr->unknown_chunk.data = NULL;\n   }\n\n   else\n#endif\n      skip = length;\n\n   png_crc_finish(png_ptr, skip);\n\n#ifndef PNG_READ_USER_CHUNKS_SUPPORTED\n   PNG_UNUSED(info_ptr) /* Quiet compiler warnings about unused info_ptr */\n#endif\n}\n\n/* This function is called to verify that a chunk name is valid.\n * This function can't have the \"critical chunk check\" incorporated\n * into it, since in the future we will need to be able to call user\n * functions to handle unknown critical chunks after we check that\n * the chunk name itself is valid.\n */\n\n/* Bit hacking: the test for an invalid byte in the 4 byte chunk name is:\n *\n * ((c) < 65 || (c) > 122 || ((c) > 90 && (c) < 97))\n */\n\nvoid /* PRIVATE */\npng_check_chunk_name(png_structp png_ptr, png_uint_32 chunk_name)\n{\n   int i;\n\n   png_debug(1, \"in png_check_chunk_name\");\n\n   for (i=1; i<=4; ++i)\n   {\n      int c = chunk_name & 0xff;\n\n      if (c < 65 || c > 122 || (c > 90 && c < 97))\n         png_chunk_error(png_ptr, \"invalid chunk type\");\n\n      chunk_name >>= 8;\n   }\n}\n\n/* Combines the row recently read in with the existing pixels in the row.  This\n * routine takes care of alpha and transparency if requested.  This routine also\n * handles the two methods of progressive display of interlaced images,\n * depending on the 'display' value; if 'display' is true then the whole row\n * (dp) is filled from the start by replicating the available pixels.  If\n * 'display' is false only those pixels present in the pass are filled in.\n */\nvoid /* PRIVATE */\npng_combine_row(png_structp png_ptr, png_bytep dp, int display)\n{\n   unsigned int pixel_depth = png_ptr->transformed_pixel_depth;\n   png_const_bytep sp = png_ptr->row_buf + 1;\n   png_uint_32 row_width = png_ptr->width;\n   unsigned int pass = png_ptr->pass;\n   png_bytep end_ptr = 0;\n   png_byte end_byte = 0;\n   unsigned int end_mask;\n\n   png_debug(1, \"in png_combine_row\");\n\n   /* Added in 1.5.6: it should not be possible to enter this routine until at\n    * least one row has been read from the PNG data and transformed.\n    */\n   if (pixel_depth == 0)\n      png_error(png_ptr, \"internal row logic error\");\n\n   /* Added in 1.5.4: the pixel depth should match the information returned by\n    * any call to png_read_update_info at this point.  Do not continue if we got\n    * this wrong.\n    */\n   if (png_ptr->info_rowbytes != 0 && png_ptr->info_rowbytes !=\n          PNG_ROWBYTES(pixel_depth, row_width))\n      png_error(png_ptr, \"internal row size calculation error\");\n\n   /* Don't expect this to ever happen: */\n   if (row_width == 0)\n      png_error(png_ptr, \"internal row width error\");\n\n   /* Preserve the last byte in cases where only part of it will be overwritten,\n    * the multiply below may overflow, we don't care because ANSI-C guarantees\n    * we get the low bits.\n    */\n   end_mask = (pixel_depth * row_width) & 7;\n   if (end_mask != 0)\n   {\n      /* end_ptr == NULL is a flag to say do nothing */\n      end_ptr = dp + PNG_ROWBYTES(pixel_depth, row_width) - 1;\n      end_byte = *end_ptr;\n#     ifdef PNG_READ_PACKSWAP_SUPPORTED\n         if (png_ptr->transformations & PNG_PACKSWAP) /* little-endian byte */\n            end_mask = 0xff << end_mask;\n\n         else /* big-endian byte */\n#     endif\n         end_mask = 0xff >> end_mask;\n      /* end_mask is now the bits to *keep* from the destination row */\n   }\n\n   /* For non-interlaced images this reduces to a png_memcpy(). A png_memcpy()\n    * will also happen if interlacing isn't supported or if the application\n    * does not call png_set_interlace_handling().  In the latter cases the\n    * caller just gets a sequence of the unexpanded rows from each interlace\n    * pass.\n    */\n#ifdef PNG_READ_INTERLACING_SUPPORTED\n   if (png_ptr->interlaced && (png_ptr->transformations & PNG_INTERLACE) &&\n      pass < 6 && (display == 0 ||\n      /* The following copies everything for 'display' on passes 0, 2 and 4. */\n      (display == 1 && (pass & 1) != 0)))\n   {\n      /* Narrow images may have no bits in a pass; the caller should handle\n       * this, but this test is cheap:\n       */\n      if (row_width <= PNG_PASS_START_COL(pass))\n         return;\n\n      if (pixel_depth < 8)\n      {\n         /* For pixel depths up to 4 bpp the 8-pixel mask can be expanded to fit\n          * into 32 bits, then a single loop over the bytes using the four byte\n          * values in the 32-bit mask can be used.  For the 'display' option the\n          * expanded mask may also not require any masking within a byte.  To\n          * make this work the PACKSWAP option must be taken into account - it\n          * simply requires the pixels to be reversed in each byte.\n          *\n          * The 'regular' case requires a mask for each of the first 6 passes,\n          * the 'display' case does a copy for the even passes in the range\n          * 0..6.  This has already been handled in the test above.\n          *\n          * The masks are arranged as four bytes with the first byte to use in\n          * the lowest bits (little-endian) regardless of the order (PACKSWAP or\n          * not) of the pixels in each byte.\n          *\n          * NOTE: the whole of this logic depends on the caller of this function\n          * only calling it on rows appropriate to the pass.  This function only\n          * understands the 'x' logic; the 'y' logic is handled by the caller.\n          *\n          * The following defines allow generation of compile time constant bit\n          * masks for each pixel depth and each possibility of swapped or not\n          * swapped bytes.  Pass 'p' is in the range 0..6; 'x', a pixel index,\n          * is in the range 0..7; and the result is 1 if the pixel is to be\n          * copied in the pass, 0 if not.  'S' is for the sparkle method, 'B'\n          * for the block method.\n          *\n          * With some compilers a compile time expression of the general form:\n          *\n          *    (shift >= 32) ? (a >> (shift-32)) : (b >> shift)\n          *\n          * Produces warnings with values of 'shift' in the range 33 to 63\n          * because the right hand side of the ?: expression is evaluated by\n          * the compiler even though it isn't used.  Microsoft Visual C (various\n          * versions) and the Intel C compiler are known to do this.  To avoid\n          * this the following macros are used in 1.5.6.  This is a temporary\n          * solution to avoid destabilizing the code during the release process.\n          */\n#        if PNG_USE_COMPILE_TIME_MASKS\n#           define PNG_LSR(x,s) ((x)>>((s) & 0x1f))\n#           define PNG_LSL(x,s) ((x)<<((s) & 0x1f))\n#        else\n#           define PNG_LSR(x,s) ((x)>>(s))\n#           define PNG_LSL(x,s) ((x)<<(s))\n#        endif\n#        define S_COPY(p,x) (((p)<4 ? PNG_LSR(0x80088822,(3-(p))*8+(7-(x))) :\\\n           PNG_LSR(0xaa55ff00,(7-(p))*8+(7-(x)))) & 1)\n#        define B_COPY(p,x) (((p)<4 ? PNG_LSR(0xff0fff33,(3-(p))*8+(7-(x))) :\\\n           PNG_LSR(0xff55ff00,(7-(p))*8+(7-(x)))) & 1)\n\n         /* Return a mask for pass 'p' pixel 'x' at depth 'd'.  The mask is\n          * little endian - the first pixel is at bit 0 - however the extra\n          * parameter 's' can be set to cause the mask position to be swapped\n          * within each byte, to match the PNG format.  This is done by XOR of\n          * the shift with 7, 6 or 4 for bit depths 1, 2 and 4.\n          */\n#        define PIXEL_MASK(p,x,d,s) \\\n            (PNG_LSL(((PNG_LSL(1U,(d)))-1),(((x)*(d))^((s)?8-(d):0))))\n\n         /* Hence generate the appropriate 'block' or 'sparkle' pixel copy mask.\n          */\n#        define S_MASKx(p,x,d,s) (S_COPY(p,x)?PIXEL_MASK(p,x,d,s):0)\n#        define B_MASKx(p,x,d,s) (B_COPY(p,x)?PIXEL_MASK(p,x,d,s):0)\n\n         /* Combine 8 of these to get the full mask.  For the 1-bpp and 2-bpp\n          * cases the result needs replicating, for the 4-bpp case the above\n          * generates a full 32 bits.\n          */\n#        define MASK_EXPAND(m,d) ((m)*((d)==1?0x01010101:((d)==2?0x00010001:1)))\n\n#        define S_MASK(p,d,s) MASK_EXPAND(S_MASKx(p,0,d,s) + S_MASKx(p,1,d,s) +\\\n            S_MASKx(p,2,d,s) + S_MASKx(p,3,d,s) + S_MASKx(p,4,d,s) +\\\n            S_MASKx(p,5,d,s) + S_MASKx(p,6,d,s) + S_MASKx(p,7,d,s), d)\n\n#        define B_MASK(p,d,s) MASK_EXPAND(B_MASKx(p,0,d,s) + B_MASKx(p,1,d,s) +\\\n            B_MASKx(p,2,d,s) + B_MASKx(p,3,d,s) + B_MASKx(p,4,d,s) +\\\n            B_MASKx(p,5,d,s) + B_MASKx(p,6,d,s) + B_MASKx(p,7,d,s), d)\n\n#if PNG_USE_COMPILE_TIME_MASKS\n         /* Utility macros to construct all the masks for a depth/swap\n          * combination.  The 's' parameter says whether the format is PNG\n          * (big endian bytes) or not.  Only the three odd-numbered passes are\n          * required for the display/block algorithm.\n          */\n#        define S_MASKS(d,s) { S_MASK(0,d,s), S_MASK(1,d,s), S_MASK(2,d,s),\\\n            S_MASK(3,d,s), S_MASK(4,d,s), S_MASK(5,d,s) }\n\n#        define B_MASKS(d,s) { B_MASK(1,d,s), S_MASK(3,d,s), S_MASK(5,d,s) }\n\n#        define DEPTH_INDEX(d) ((d)==1?0:((d)==2?1:2))\n\n         /* Hence the pre-compiled masks indexed by PACKSWAP (or not), depth and\n          * then pass:\n          */\n         static PNG_CONST png_uint_32 row_mask[2/*PACKSWAP*/][3/*depth*/][6] =\n         {\n            /* Little-endian byte masks for PACKSWAP */\n            { S_MASKS(1,0), S_MASKS(2,0), S_MASKS(4,0) },\n            /* Normal (big-endian byte) masks - PNG format */\n            { S_MASKS(1,1), S_MASKS(2,1), S_MASKS(4,1) }\n         };\n\n         /* display_mask has only three entries for the odd passes, so index by\n          * pass>>1.\n          */\n         static PNG_CONST png_uint_32 display_mask[2][3][3] =\n         {\n            /* Little-endian byte masks for PACKSWAP */\n            { B_MASKS(1,0), B_MASKS(2,0), B_MASKS(4,0) },\n            /* Normal (big-endian byte) masks - PNG format */\n            { B_MASKS(1,1), B_MASKS(2,1), B_MASKS(4,1) }\n         };\n\n#        define MASK(pass,depth,display,png)\\\n            ((display)?display_mask[png][DEPTH_INDEX(depth)][pass>>1]:\\\n               row_mask[png][DEPTH_INDEX(depth)][pass])\n\n#else /* !PNG_USE_COMPILE_TIME_MASKS */\n         /* This is the runtime alternative: it seems unlikely that this will\n          * ever be either smaller or faster than the compile time approach.\n          */\n#        define MASK(pass,depth,display,png)\\\n            ((display)?B_MASK(pass,depth,png):S_MASK(pass,depth,png))\n#endif /* !PNG_USE_COMPILE_TIME_MASKS */\n\n         /* Use the appropriate mask to copy the required bits.  In some cases\n          * the byte mask will be 0 or 0xff, optimize these cases.  row_width is\n          * the number of pixels, but the code copies bytes, so it is necessary\n          * to special case the end.\n          */\n         png_uint_32 pixels_per_byte = 8 / pixel_depth;\n         png_uint_32 mask;\n\n#        ifdef PNG_READ_PACKSWAP_SUPPORTED\n            if (png_ptr->transformations & PNG_PACKSWAP)\n               mask = MASK(pass, pixel_depth, display, 0);\n\n            else\n#        endif\n            mask = MASK(pass, pixel_depth, display, 1);\n\n         for (;;)\n         {\n            png_uint_32 m;\n\n            /* It doesn't matter in the following if png_uint_32 has more than\n             * 32 bits because the high bits always match those in m<<24; it is,\n             * however, essential to use OR here, not +, because of this.\n             */\n            m = mask;\n            mask = (m >> 8) | (m << 24); /* rotate right to good compilers */\n            m &= 0xff;\n\n            if (m != 0) /* something to copy */\n            {\n               if (m != 0xff)\n                  *dp = (png_byte)((*dp & ~m) | (*sp & m));\n               else\n                  *dp = *sp;\n            }\n\n            /* NOTE: this may overwrite the last byte with garbage if the image\n             * is not an exact number of bytes wide; libpng has always done\n             * this.\n             */\n            if (row_width <= pixels_per_byte)\n               break; /* May need to restore part of the last byte */\n\n            row_width -= pixels_per_byte;\n            ++dp;\n            ++sp;\n         }\n      }\n\n      else /* pixel_depth >= 8 */\n      {\n         unsigned int bytes_to_copy, bytes_to_jump;\n\n         /* Validate the depth - it must be a multiple of 8 */\n         if (pixel_depth & 7)\n            png_error(png_ptr, \"invalid user transform pixel depth\");\n\n         pixel_depth >>= 3; /* now in bytes */\n         row_width *= pixel_depth;\n\n         /* Regardless of pass number the Adam 7 interlace always results in a\n          * fixed number of pixels to copy then to skip.  There may be a\n          * different number of pixels to skip at the start though.\n          */\n         {\n            unsigned int offset = PNG_PASS_START_COL(pass) * pixel_depth;\n\n            row_width -= offset;\n            dp += offset;\n            sp += offset;\n         }\n\n         /* Work out the bytes to copy. */\n         if (display)\n         {\n            /* When doing the 'block' algorithm the pixel in the pass gets\n             * replicated to adjacent pixels.  This is why the even (0,2,4,6)\n             * passes are skipped above - the entire expanded row is copied.\n             */\n            bytes_to_copy = (1<<((6-pass)>>1)) * pixel_depth;\n\n            /* But don't allow this number to exceed the actual row width. */\n            if (bytes_to_copy > row_width)\n               bytes_to_copy = row_width;\n         }\n\n         else /* normal row; Adam7 only ever gives us one pixel to copy. */\n            bytes_to_copy = pixel_depth;\n\n         /* In Adam7 there is a constant offset between where the pixels go. */\n         bytes_to_jump = PNG_PASS_COL_OFFSET(pass) * pixel_depth;\n\n         /* And simply copy these bytes.  Some optimization is possible here,\n          * depending on the value of 'bytes_to_copy'.  Special case the low\n          * byte counts, which we know to be frequent.\n          *\n          * Notice that these cases all 'return' rather than 'break' - this\n          * avoids an unnecessary test on whether to restore the last byte\n          * below.\n          */\n         switch (bytes_to_copy)\n         {\n            case 1:\n               for (;;)\n               {\n                  *dp = *sp;\n\n                  if (row_width <= bytes_to_jump)\n                     return;\n\n                  dp += bytes_to_jump;\n                  sp += bytes_to_jump;\n                  row_width -= bytes_to_jump;\n               }\n\n            case 2:\n               /* There is a possibility of a partial copy at the end here; this\n                * slows the code down somewhat.\n                */\n               do\n               {\n                  dp[0] = sp[0], dp[1] = sp[1];\n\n                  if (row_width <= bytes_to_jump)\n                     return;\n\n                  sp += bytes_to_jump;\n                  dp += bytes_to_jump;\n                  row_width -= bytes_to_jump;\n               }\n               while (row_width > 1);\n\n               /* And there can only be one byte left at this point: */\n               *dp = *sp;\n               return;\n\n            case 3:\n               /* This can only be the RGB case, so each copy is exactly one\n                * pixel and it is not necessary to check for a partial copy.\n                */\n               for(;;)\n               {\n                  dp[0] = sp[0], dp[1] = sp[1], dp[2] = sp[2];\n\n                  if (row_width <= bytes_to_jump)\n                     return;\n\n                  sp += bytes_to_jump;\n                  dp += bytes_to_jump;\n                  row_width -= bytes_to_jump;\n               }\n\n            default:\n#if PNG_ALIGN_TYPE != PNG_ALIGN_NONE\n               /* Check for double byte alignment and, if possible, use a\n                * 16-bit copy.  Don't attempt this for narrow images - ones that\n                * are less than an interlace panel wide.  Don't attempt it for\n                * wide bytes_to_copy either - use the png_memcpy there.\n                */\n               if (bytes_to_copy < 16 /*else use png_memcpy*/ &&\n                  png_isaligned(dp, png_uint_16) &&\n                  png_isaligned(sp, png_uint_16) &&\n                  bytes_to_copy % sizeof (png_uint_16) == 0 &&\n                  bytes_to_jump % sizeof (png_uint_16) == 0)\n               {\n                  /* Everything is aligned for png_uint_16 copies, but try for\n                   * png_uint_32 first.\n                   */\n                  if (png_isaligned(dp, png_uint_32) &&\n                     png_isaligned(sp, png_uint_32) &&\n                     bytes_to_copy % sizeof (png_uint_32) == 0 &&\n                     bytes_to_jump % sizeof (png_uint_32) == 0)\n                  {\n                     png_uint_32p dp32 = (png_uint_32p)dp;\n                     png_const_uint_32p sp32 = (png_const_uint_32p)sp;\n                     unsigned int skip = (bytes_to_jump-bytes_to_copy) /\n                        sizeof (png_uint_32);\n\n                     do\n                     {\n                        size_t c = bytes_to_copy;\n                        do\n                        {\n                           *dp32++ = *sp32++;\n                           c -= sizeof (png_uint_32);\n                        }\n                        while (c > 0);\n\n                        if (row_width <= bytes_to_jump)\n                           return;\n\n                        dp32 += skip;\n                        sp32 += skip;\n                        row_width -= bytes_to_jump;\n                     }\n                     while (bytes_to_copy <= row_width);\n\n                     /* Get to here when the row_width truncates the final copy.\n                      * There will be 1-3 bytes left to copy, so don't try the\n                      * 16-bit loop below.\n                      */\n                     dp = (png_bytep)dp32;\n                     sp = (png_const_bytep)sp32;\n                     do\n                        *dp++ = *sp++;\n                     while (--row_width > 0);\n                     return;\n                  }\n\n                  /* Else do it in 16-bit quantities, but only if the size is\n                   * not too large.\n                   */\n                  else\n                  {\n                     png_uint_16p dp16 = (png_uint_16p)dp;\n                     png_const_uint_16p sp16 = (png_const_uint_16p)sp;\n                     unsigned int skip = (bytes_to_jump-bytes_to_copy) /\n                        sizeof (png_uint_16);\n\n                     do\n                     {\n                        size_t c = bytes_to_copy;\n                        do\n                        {\n                           *dp16++ = *sp16++;\n                           c -= sizeof (png_uint_16);\n                        }\n                        while (c > 0);\n\n                        if (row_width <= bytes_to_jump)\n                           return;\n\n                        dp16 += skip;\n                        sp16 += skip;\n                        row_width -= bytes_to_jump;\n                     }\n                     while (bytes_to_copy <= row_width);\n\n                     /* End of row - 1 byte left, bytes_to_copy > row_width: */\n                     dp = (png_bytep)dp16;\n                     sp = (png_const_bytep)sp16;\n                     do\n                        *dp++ = *sp++;\n                     while (--row_width > 0);\n                     return;\n                  }\n               }\n#endif /* PNG_ALIGN_ code */\n\n               /* The true default - use a png_memcpy: */\n               for (;;)\n               {\n                  png_memcpy(dp, sp, bytes_to_copy);\n\n                  if (row_width <= bytes_to_jump)\n                     return;\n\n                  sp += bytes_to_jump;\n                  dp += bytes_to_jump;\n                  row_width -= bytes_to_jump;\n                  if (bytes_to_copy > row_width)\n                     bytes_to_copy = row_width;\n               }\n         }\n\n         /* NOT REACHED*/\n      } /* pixel_depth >= 8 */\n\n      /* Here if pixel_depth < 8 to check 'end_ptr' below. */\n   }\n   else\n#endif\n\n   /* If here then the switch above wasn't used so just png_memcpy the whole row\n    * from the temporary row buffer (notice that this overwrites the end of the\n    * destination row if it is a partial byte.)\n    */\n   png_memcpy(dp, sp, PNG_ROWBYTES(pixel_depth, row_width));\n\n   /* Restore the overwritten bits from the last byte if necessary. */\n   if (end_ptr != NULL)\n      *end_ptr = (png_byte)((end_byte & end_mask) | (*end_ptr & ~end_mask));\n}\n\n#ifdef PNG_READ_INTERLACING_SUPPORTED\nvoid /* PRIVATE */\npng_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,\n   png_uint_32 transformations /* Because these may affect the byte layout */)\n{\n   /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */\n   /* Offset to next interlace block */\n   static PNG_CONST int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};\n\n   png_debug(1, \"in png_do_read_interlace\");\n   if (row != NULL && row_info != NULL)\n   {\n      png_uint_32 final_width;\n\n      final_width = row_info->width * png_pass_inc[pass];\n\n      switch (row_info->pixel_depth)\n      {\n         case 1:\n         {\n            png_bytep sp = row + (png_size_t)((row_info->width - 1) >> 3);\n            png_bytep dp = row + (png_size_t)((final_width - 1) >> 3);\n            int sshift, dshift;\n            int s_start, s_end, s_inc;\n            int jstop = png_pass_inc[pass];\n            png_byte v;\n            png_uint_32 i;\n            int j;\n\n#ifdef PNG_READ_PACKSWAP_SUPPORTED\n            if (transformations & PNG_PACKSWAP)\n            {\n                sshift = (int)((row_info->width + 7) & 0x07);\n                dshift = (int)((final_width + 7) & 0x07);\n                s_start = 7;\n                s_end = 0;\n                s_inc = -1;\n            }\n\n            else\n#endif\n            {\n                sshift = 7 - (int)((row_info->width + 7) & 0x07);\n                dshift = 7 - (int)((final_width + 7) & 0x07);\n                s_start = 0;\n                s_end = 7;\n                s_inc = 1;\n            }\n\n            for (i = 0; i < row_info->width; i++)\n            {\n               v = (png_byte)((*sp >> sshift) & 0x01);\n               for (j = 0; j < jstop; j++)\n               {\n                  *dp &= (png_byte)((0x7f7f >> (7 - dshift)) & 0xff);\n                  *dp |= (png_byte)(v << dshift);\n\n                  if (dshift == s_end)\n                  {\n                     dshift = s_start;\n                     dp--;\n                  }\n\n                  else\n                     dshift += s_inc;\n               }\n\n               if (sshift == s_end)\n               {\n                  sshift = s_start;\n                  sp--;\n               }\n\n               else\n                  sshift += s_inc;\n            }\n            break;\n         }\n\n         case 2:\n         {\n            png_bytep sp = row + (png_uint_32)((row_info->width - 1) >> 2);\n            png_bytep dp = row + (png_uint_32)((final_width - 1) >> 2);\n            int sshift, dshift;\n            int s_start, s_end, s_inc;\n            int jstop = png_pass_inc[pass];\n            png_uint_32 i;\n\n#ifdef PNG_READ_PACKSWAP_SUPPORTED\n            if (transformations & PNG_PACKSWAP)\n            {\n               sshift = (int)(((row_info->width + 3) & 0x03) << 1);\n               dshift = (int)(((final_width + 3) & 0x03) << 1);\n               s_start = 6;\n               s_end = 0;\n               s_inc = -2;\n            }\n\n            else\n#endif\n            {\n               sshift = (int)((3 - ((row_info->width + 3) & 0x03)) << 1);\n               dshift = (int)((3 - ((final_width + 3) & 0x03)) << 1);\n               s_start = 0;\n               s_end = 6;\n               s_inc = 2;\n            }\n\n            for (i = 0; i < row_info->width; i++)\n            {\n               png_byte v;\n               int j;\n\n               v = (png_byte)((*sp >> sshift) & 0x03);\n               for (j = 0; j < jstop; j++)\n               {\n                  *dp &= (png_byte)((0x3f3f >> (6 - dshift)) & 0xff);\n                  *dp |= (png_byte)(v << dshift);\n\n                  if (dshift == s_end)\n                  {\n                     dshift = s_start;\n                     dp--;\n                  }\n\n                  else\n                     dshift += s_inc;\n               }\n\n               if (sshift == s_end)\n               {\n                  sshift = s_start;\n                  sp--;\n               }\n\n               else\n                  sshift += s_inc;\n            }\n            break;\n         }\n\n         case 4:\n         {\n            png_bytep sp = row + (png_size_t)((row_info->width - 1) >> 1);\n            png_bytep dp = row + (png_size_t)((final_width - 1) >> 1);\n            int sshift, dshift;\n            int s_start, s_end, s_inc;\n            png_uint_32 i;\n            int jstop = png_pass_inc[pass];\n\n#ifdef PNG_READ_PACKSWAP_SUPPORTED\n            if (transformations & PNG_PACKSWAP)\n            {\n               sshift = (int)(((row_info->width + 1) & 0x01) << 2);\n               dshift = (int)(((final_width + 1) & 0x01) << 2);\n               s_start = 4;\n               s_end = 0;\n               s_inc = -4;\n            }\n\n            else\n#endif\n            {\n               sshift = (int)((1 - ((row_info->width + 1) & 0x01)) << 2);\n               dshift = (int)((1 - ((final_width + 1) & 0x01)) << 2);\n               s_start = 0;\n               s_end = 4;\n               s_inc = 4;\n            }\n\n            for (i = 0; i < row_info->width; i++)\n            {\n               png_byte v = (png_byte)((*sp >> sshift) & 0x0f);\n               int j;\n\n               for (j = 0; j < jstop; j++)\n               {\n                  *dp &= (png_byte)((0xf0f >> (4 - dshift)) & 0xff);\n                  *dp |= (png_byte)(v << dshift);\n\n                  if (dshift == s_end)\n                  {\n                     dshift = s_start;\n                     dp--;\n                  }\n\n                  else\n                     dshift += s_inc;\n               }\n\n               if (sshift == s_end)\n               {\n                  sshift = s_start;\n                  sp--;\n               }\n\n               else\n                  sshift += s_inc;\n            }\n            break;\n         }\n\n         default:\n         {\n            png_size_t pixel_bytes = (row_info->pixel_depth >> 3);\n\n            png_bytep sp = row + (png_size_t)(row_info->width - 1)\n                * pixel_bytes;\n\n            png_bytep dp = row + (png_size_t)(final_width - 1) * pixel_bytes;\n\n            int jstop = png_pass_inc[pass];\n            png_uint_32 i;\n\n            for (i = 0; i < row_info->width; i++)\n            {\n               png_byte v[8];\n               int j;\n\n               png_memcpy(v, sp, pixel_bytes);\n\n               for (j = 0; j < jstop; j++)\n               {\n                  png_memcpy(dp, v, pixel_bytes);\n                  dp -= pixel_bytes;\n               }\n\n               sp -= pixel_bytes;\n            }\n            break;\n         }\n      }\n\n      row_info->width = final_width;\n      row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, final_width);\n   }\n#ifndef PNG_READ_PACKSWAP_SUPPORTED\n   PNG_UNUSED(transformations)  /* Silence compiler warning */\n#endif\n}\n#endif /* PNG_READ_INTERLACING_SUPPORTED */\n\nstatic void\npng_read_filter_row_sub(png_row_infop row_info, png_bytep row,\n   png_const_bytep prev_row)\n{\n   png_size_t i;\n   png_size_t istop = row_info->rowbytes;\n   unsigned int bpp = (row_info->pixel_depth + 7) >> 3;\n   png_bytep rp = row + bpp;\n\n   PNG_UNUSED(prev_row)\n\n   for (i = bpp; i < istop; i++)\n   {\n      *rp = (png_byte)(((int)(*rp) + (int)(*(rp-bpp))) & 0xff);\n      rp++;\n   }\n}\n\nstatic void\npng_read_filter_row_up(png_row_infop row_info, png_bytep row,\n   png_const_bytep prev_row)\n{\n   png_size_t i;\n   png_size_t istop = row_info->rowbytes;\n   png_bytep rp = row;\n   png_const_bytep pp = prev_row;\n\n   for (i = 0; i < istop; i++)\n   {\n      *rp = (png_byte)(((int)(*rp) + (int)(*pp++)) & 0xff);\n      rp++;\n   }\n}\n\nstatic void\npng_read_filter_row_avg(png_row_infop row_info, png_bytep row,\n   png_const_bytep prev_row)\n{\n   png_size_t i;\n   png_bytep rp = row;\n   png_const_bytep pp = prev_row;\n   unsigned int bpp = (row_info->pixel_depth + 7) >> 3;\n   png_size_t istop = row_info->rowbytes - bpp;\n\n   for (i = 0; i < bpp; i++)\n   {\n      *rp = (png_byte)(((int)(*rp) +\n         ((int)(*pp++) / 2 )) & 0xff);\n\n      rp++;\n   }\n\n   for (i = 0; i < istop; i++)\n   {\n      *rp = (png_byte)(((int)(*rp) +\n         (int)(*pp++ + *(rp-bpp)) / 2 ) & 0xff);\n\n      rp++;\n   }\n}\n\nstatic void\npng_read_filter_row_paeth_1byte_pixel(png_row_infop row_info, png_bytep row,\n   png_const_bytep prev_row)\n{\n   png_bytep rp_end = row + row_info->rowbytes;\n   int a, c;\n\n   /* First pixel/byte */\n   c = *prev_row++;\n   a = *row + c;\n   *row++ = (png_byte)a;\n\n   /* Remainder */\n   while (row < rp_end)\n   {\n      int b, pa, pb, pc, p;\n\n      a &= 0xff; /* From previous iteration or start */\n      b = *prev_row++;\n\n      p = b - c;\n      pc = a - c;\n\n#     ifdef PNG_USE_ABS\n         pa = abs(p);\n         pb = abs(pc);\n         pc = abs(p + pc);\n#     else\n         pa = p < 0 ? -p : p;\n         pb = pc < 0 ? -pc : pc;\n         pc = (p + pc) < 0 ? -(p + pc) : p + pc;\n#     endif\n\n      /* Find the best predictor, the least of pa, pb, pc favoring the earlier\n       * ones in the case of a tie.\n       */\n      if (pb < pa) pa = pb, a = b;\n      if (pc < pa) a = c;\n\n      /* Calculate the current pixel in a, and move the previous row pixel to c\n       * for the next time round the loop\n       */\n      c = b;\n      a += *row;\n      *row++ = (png_byte)a;\n   }\n}\n\nstatic void\npng_read_filter_row_paeth_multibyte_pixel(png_row_infop row_info, png_bytep row,\n   png_const_bytep prev_row)\n{\n   int bpp = (row_info->pixel_depth + 7) >> 3;\n   png_bytep rp_end = row + bpp;\n\n   /* Process the first pixel in the row completely (this is the same as 'up'\n    * because there is only one candidate predictor for the first row).\n    */\n   while (row < rp_end)\n   {\n      int a = *row + *prev_row++;\n      *row++ = (png_byte)a;\n   }\n\n   /* Remainder */\n   rp_end += row_info->rowbytes - bpp;\n\n   while (row < rp_end)\n   {\n      int a, b, c, pa, pb, pc, p;\n\n      c = *(prev_row - bpp);\n      a = *(row - bpp);\n      b = *prev_row++;\n\n      p = b - c;\n      pc = a - c;\n\n#     ifdef PNG_USE_ABS\n         pa = abs(p);\n         pb = abs(pc);\n         pc = abs(p + pc);\n#     else\n         pa = p < 0 ? -p : p;\n         pb = pc < 0 ? -pc : pc;\n         pc = (p + pc) < 0 ? -(p + pc) : p + pc;\n#     endif\n\n      if (pb < pa) pa = pb, a = b;\n      if (pc < pa) a = c;\n\n      c = b;\n      a += *row;\n      *row++ = (png_byte)a;\n   }\n}\n\n#ifdef PNG_ARM_NEON\n\n#ifdef __linux__\n#include <stdio.h>\n#include <elf.h>\n#include <asm/hwcap.h>\n\nstatic int png_have_hwcap(unsigned cap)\n{\n   FILE *f = fopen(\"/proc/self/auxv\", \"r\");\n   Elf32_auxv_t aux;\n   int have_cap = 0;\n\n   if (!f)\n      return 0;\n\n   while (fread(&aux, sizeof(aux), 1, f) > 0)\n   {\n      if (aux.a_type == AT_HWCAP &&\n          aux.a_un.a_val & cap)\n      {\n         have_cap = 1;\n         break;\n      }\n   }\n\n   fclose(f);\n\n   return have_cap;\n}\n#endif /* __linux__ */\n\nstatic void\npng_init_filter_functions_neon(png_structp pp, unsigned int bpp)\n{\n#ifdef __linux__\n   if (!png_have_hwcap(HWCAP_NEON))\n      return;\n#endif\n\n   pp->read_filter[PNG_FILTER_VALUE_UP-1] = png_read_filter_row_up_neon;\n\n   if (bpp == 3)\n   {\n      pp->read_filter[PNG_FILTER_VALUE_SUB-1] = png_read_filter_row_sub3_neon;\n      pp->read_filter[PNG_FILTER_VALUE_AVG-1] = png_read_filter_row_avg3_neon;\n      pp->read_filter[PNG_FILTER_VALUE_PAETH-1] = \n         png_read_filter_row_paeth3_neon;\n   }\n\n   else if (bpp == 4)\n   {\n      pp->read_filter[PNG_FILTER_VALUE_SUB-1] = png_read_filter_row_sub4_neon;\n      pp->read_filter[PNG_FILTER_VALUE_AVG-1] = png_read_filter_row_avg4_neon;\n      pp->read_filter[PNG_FILTER_VALUE_PAETH-1] =\n          png_read_filter_row_paeth4_neon;\n   }\n}\n#endif /* PNG_ARM_NEON */\n\nstatic void\npng_init_filter_functions(png_structp pp)\n{\n   unsigned int bpp = (pp->pixel_depth + 7) >> 3;\n\n   pp->read_filter[PNG_FILTER_VALUE_SUB-1] = png_read_filter_row_sub;\n   pp->read_filter[PNG_FILTER_VALUE_UP-1] = png_read_filter_row_up;\n   pp->read_filter[PNG_FILTER_VALUE_AVG-1] = png_read_filter_row_avg;\n   if (bpp == 1)\n      pp->read_filter[PNG_FILTER_VALUE_PAETH-1] =\n         png_read_filter_row_paeth_1byte_pixel;\n   else\n      pp->read_filter[PNG_FILTER_VALUE_PAETH-1] =\n         png_read_filter_row_paeth_multibyte_pixel;\n\n#ifdef PNG_ARM_NEON\n   png_init_filter_functions_neon(pp, bpp);\n#endif\n}\n\nvoid /* PRIVATE */\npng_read_filter_row(png_structp pp, png_row_infop row_info, png_bytep row,\n   png_const_bytep prev_row, int filter)\n{\n   if (pp->read_filter[0] == NULL)\n      png_init_filter_functions(pp);\n   if (filter > PNG_FILTER_VALUE_NONE && filter < PNG_FILTER_VALUE_LAST)\n      pp->read_filter[filter-1](row_info, row, prev_row);\n}\n\n#ifdef PNG_SEQUENTIAL_READ_SUPPORTED\nvoid /* PRIVATE */\npng_read_finish_row(png_structp png_ptr)\n{\n#ifdef PNG_READ_INTERLACING_SUPPORTED\n   /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */\n\n   /* Start of interlace block */\n   static PNG_CONST png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};\n\n   /* Offset to next interlace block */\n   static PNG_CONST png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};\n\n   /* Start of interlace block in the y direction */\n   static PNG_CONST png_byte png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1};\n\n   /* Offset to next interlace block in the y direction */\n   static PNG_CONST png_byte png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};\n#endif /* PNG_READ_INTERLACING_SUPPORTED */\n\n   png_debug(1, \"in png_read_finish_row\");\n   png_ptr->row_number++;\n   if (png_ptr->row_number < png_ptr->num_rows)\n      return;\n\n#ifdef PNG_READ_INTERLACING_SUPPORTED\n   if (png_ptr->interlaced)\n   {\n      png_ptr->row_number = 0;\n\n      /* TO DO: don't do this if prev_row isn't needed (requires\n       * read-ahead of the next row's filter byte.\n       */\n      png_memset(png_ptr->prev_row, 0, png_ptr->rowbytes + 1);\n\n      do\n      {\n         png_ptr->pass++;\n\n         if (png_ptr->pass >= 7)\n            break;\n\n         png_ptr->iwidth = (png_ptr->width +\n            png_pass_inc[png_ptr->pass] - 1 -\n            png_pass_start[png_ptr->pass]) /\n            png_pass_inc[png_ptr->pass];\n\n         if (!(png_ptr->transformations & PNG_INTERLACE))\n         {\n            png_ptr->num_rows = (png_ptr->height +\n                png_pass_yinc[png_ptr->pass] - 1 -\n                png_pass_ystart[png_ptr->pass]) /\n                png_pass_yinc[png_ptr->pass];\n         }\n\n         else  /* if (png_ptr->transformations & PNG_INTERLACE) */\n            break; /* libpng deinterlacing sees every row */\n\n      } while (png_ptr->num_rows == 0 || png_ptr->iwidth == 0);\n\n      if (png_ptr->pass < 7)\n         return;\n   }\n#endif /* PNG_READ_INTERLACING_SUPPORTED */\n\n   if (!(png_ptr->flags & PNG_FLAG_ZLIB_FINISHED))\n   {\n      char extra;\n      int ret;\n\n      png_ptr->zstream.next_out = (Byte *)&extra;\n      png_ptr->zstream.avail_out = (uInt)1;\n\n      for (;;)\n      {\n         if (!(png_ptr->zstream.avail_in))\n         {\n            while (!png_ptr->idat_size)\n            {\n               png_crc_finish(png_ptr, 0);\n               png_ptr->idat_size = png_read_chunk_header(png_ptr);\n               if (png_ptr->chunk_name != png_IDAT)\n                  png_error(png_ptr, \"Not enough image data\");\n            }\n\n            png_ptr->zstream.avail_in = (uInt)png_ptr->zbuf_size;\n            png_ptr->zstream.next_in = png_ptr->zbuf;\n\n            if (png_ptr->zbuf_size > png_ptr->idat_size)\n               png_ptr->zstream.avail_in = (uInt)png_ptr->idat_size;\n\n            png_crc_read(png_ptr, png_ptr->zbuf, png_ptr->zstream.avail_in);\n            png_ptr->idat_size -= png_ptr->zstream.avail_in;\n         }\n\n         ret = inflate(&png_ptr->zstream, Z_PARTIAL_FLUSH);\n\n         if (ret == Z_STREAM_END)\n         {\n            if (!(png_ptr->zstream.avail_out) || png_ptr->zstream.avail_in ||\n                png_ptr->idat_size)\n               png_warning(png_ptr, \"Extra compressed data\");\n\n            png_ptr->mode |= PNG_AFTER_IDAT;\n            png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED;\n            break;\n         }\n\n         if (ret != Z_OK)\n            png_error(png_ptr, png_ptr->zstream.msg ? png_ptr->zstream.msg :\n                \"Decompression Error\");\n\n         if (!(png_ptr->zstream.avail_out))\n         {\n            png_warning(png_ptr, \"Extra compressed data\");\n            png_ptr->mode |= PNG_AFTER_IDAT;\n            png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED;\n            break;\n         }\n\n      }\n      png_ptr->zstream.avail_out = 0;\n   }\n\n   if (png_ptr->idat_size || png_ptr->zstream.avail_in)\n      png_warning(png_ptr, \"Extra compression data\");\n\n   inflateReset(&png_ptr->zstream);\n\n   png_ptr->mode |= PNG_AFTER_IDAT;\n}\n#endif /* PNG_SEQUENTIAL_READ_SUPPORTED */\n\nvoid /* PRIVATE */\npng_read_start_row(png_structp png_ptr)\n{\n#ifdef PNG_READ_INTERLACING_SUPPORTED\n   /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */\n\n   /* Start of interlace block */\n   static PNG_CONST png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};\n\n   /* Offset to next interlace block */\n   static PNG_CONST png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};\n\n   /* Start of interlace block in the y direction */\n   static PNG_CONST png_byte png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1};\n\n   /* Offset to next interlace block in the y direction */\n   static PNG_CONST png_byte png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};\n#endif\n\n   int max_pixel_depth;\n   png_size_t row_bytes;\n\n   png_debug(1, \"in png_read_start_row\");\n   png_ptr->zstream.avail_in = 0;\n#ifdef PNG_READ_TRANSFORMS_SUPPORTED\n   png_init_read_transformations(png_ptr);\n#endif\n#ifdef PNG_READ_INTERLACING_SUPPORTED\n   if (png_ptr->interlaced)\n   {\n      if (!(png_ptr->transformations & PNG_INTERLACE))\n         png_ptr->num_rows = (png_ptr->height + png_pass_yinc[0] - 1 -\n             png_pass_ystart[0]) / png_pass_yinc[0];\n\n      else\n         png_ptr->num_rows = png_ptr->height;\n\n      png_ptr->iwidth = (png_ptr->width +\n          png_pass_inc[png_ptr->pass] - 1 -\n          png_pass_start[png_ptr->pass]) /\n          png_pass_inc[png_ptr->pass];\n   }\n\n   else\n#endif /* PNG_READ_INTERLACING_SUPPORTED */\n   {\n      png_ptr->num_rows = png_ptr->height;\n      png_ptr->iwidth = png_ptr->width;\n   }\n\n   max_pixel_depth = png_ptr->pixel_depth;\n\n   /* WARNING: * png_read_transform_info (pngrtran.c) performs a simpliar set of\n    * calculations to calculate the final pixel depth, then\n    * png_do_read_transforms actually does the transforms.  This means that the\n    * code which effectively calculates this value is actually repeated in three\n    * separate places.  They must all match.  Innocent changes to the order of\n    * transformations can and will break libpng in a way that causes memory\n    * overwrites.\n    *\n    * TODO: fix this.\n    */\n#ifdef PNG_READ_PACK_SUPPORTED\n   if ((png_ptr->transformations & PNG_PACK) && png_ptr->bit_depth < 8)\n      max_pixel_depth = 8;\n#endif\n\n#ifdef PNG_READ_EXPAND_SUPPORTED\n   if (png_ptr->transformations & PNG_EXPAND)\n   {\n      if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)\n      {\n         if (png_ptr->num_trans)\n            max_pixel_depth = 32;\n\n         else\n            max_pixel_depth = 24;\n      }\n\n      else if (png_ptr->color_type == PNG_COLOR_TYPE_GRAY)\n      {\n         if (max_pixel_depth < 8)\n            max_pixel_depth = 8;\n\n         if (png_ptr->num_trans)\n            max_pixel_depth *= 2;\n      }\n\n      else if (png_ptr->color_type == PNG_COLOR_TYPE_RGB)\n      {\n         if (png_ptr->num_trans)\n         {\n            max_pixel_depth *= 4;\n            max_pixel_depth /= 3;\n         }\n      }\n   }\n#endif\n\n#ifdef PNG_READ_EXPAND_16_SUPPORTED\n   if (png_ptr->transformations & PNG_EXPAND_16)\n   {\n#     ifdef PNG_READ_EXPAND_SUPPORTED\n         /* In fact it is an error if it isn't supported, but checking is\n          * the safe way.\n          */\n         if (png_ptr->transformations & PNG_EXPAND)\n         {\n            if (png_ptr->bit_depth < 16)\n               max_pixel_depth *= 2;\n         }\n         else\n#     endif\n         png_ptr->transformations &= ~PNG_EXPAND_16;\n   }\n#endif\n\n#ifdef PNG_READ_FILLER_SUPPORTED\n   if (png_ptr->transformations & (PNG_FILLER))\n   {\n      if (png_ptr->color_type == PNG_COLOR_TYPE_GRAY)\n      {\n         if (max_pixel_depth <= 8)\n            max_pixel_depth = 16;\n\n         else\n            max_pixel_depth = 32;\n      }\n\n      else if (png_ptr->color_type == PNG_COLOR_TYPE_RGB ||\n         png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)\n      {\n         if (max_pixel_depth <= 32)\n            max_pixel_depth = 32;\n\n         else\n            max_pixel_depth = 64;\n      }\n   }\n#endif\n\n#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED\n   if (png_ptr->transformations & PNG_GRAY_TO_RGB)\n   {\n      if (\n#ifdef PNG_READ_EXPAND_SUPPORTED\n          (png_ptr->num_trans && (png_ptr->transformations & PNG_EXPAND)) ||\n#endif\n#ifdef PNG_READ_FILLER_SUPPORTED\n          (png_ptr->transformations & (PNG_FILLER)) ||\n#endif\n          png_ptr->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)\n      {\n         if (max_pixel_depth <= 16)\n            max_pixel_depth = 32;\n\n         else\n            max_pixel_depth = 64;\n      }\n\n      else\n      {\n         if (max_pixel_depth <= 8)\n         {\n            if (png_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA)\n               max_pixel_depth = 32;\n\n            else\n               max_pixel_depth = 24;\n         }\n\n         else if (png_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA)\n            max_pixel_depth = 64;\n\n         else\n            max_pixel_depth = 48;\n      }\n   }\n#endif\n\n#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) && \\\ndefined(PNG_USER_TRANSFORM_PTR_SUPPORTED)\n   if (png_ptr->transformations & PNG_USER_TRANSFORM)\n   {\n      int user_pixel_depth = png_ptr->user_transform_depth *\n         png_ptr->user_transform_channels;\n\n      if (user_pixel_depth > max_pixel_depth)\n         max_pixel_depth = user_pixel_depth;\n   }\n#endif\n\n   /* This value is stored in png_struct and double checked in the row read\n    * code.\n    */\n   png_ptr->maximum_pixel_depth = (png_byte)max_pixel_depth;\n   png_ptr->transformed_pixel_depth = 0; /* calculated on demand */\n\n   /* Align the width on the next larger 8 pixels.  Mainly used\n    * for interlacing\n    */\n   row_bytes = ((png_ptr->width + 7) & ~((png_uint_32)7));\n   /* Calculate the maximum bytes needed, adding a byte and a pixel\n    * for safety's sake\n    */\n   row_bytes = PNG_ROWBYTES(max_pixel_depth, row_bytes) +\n       1 + ((max_pixel_depth + 7) >> 3);\n\n#ifdef PNG_MAX_MALLOC_64K\n   if (row_bytes > (png_uint_32)65536L)\n      png_error(png_ptr, \"This image requires a row greater than 64KB\");\n#endif\n\n   if (row_bytes + 48 > png_ptr->old_big_row_buf_size)\n   {\n     png_free(png_ptr, png_ptr->big_row_buf);\n     png_free(png_ptr, png_ptr->big_prev_row);\n\n     if (png_ptr->interlaced)\n        png_ptr->big_row_buf = (png_bytep)png_calloc(png_ptr,\n            row_bytes + 48);\n\n     else\n        png_ptr->big_row_buf = (png_bytep)png_malloc(png_ptr, row_bytes + 48);\n\n     png_ptr->big_prev_row = (png_bytep)png_malloc(png_ptr, row_bytes + 48);\n\n#ifdef PNG_ALIGNED_MEMORY_SUPPORTED\n     /* Use 16-byte aligned memory for row_buf with at least 16 bytes\n      * of padding before and after row_buf; treat prev_row similarly.\n      * NOTE: the alignment is to the start of the pixels, one beyond the start\n      * of the buffer, because of the filter byte.  Prior to libpng 1.5.6 this\n      * was incorrect; the filter byte was aligned, which had the exact\n      * opposite effect of that intended.\n      */\n     {\n        png_bytep temp = png_ptr->big_row_buf + 32;\n        int extra = (int)((temp - (png_bytep)0) & 0x0f);\n        png_ptr->row_buf = temp - extra - 1/*filter byte*/;\n\n        temp = png_ptr->big_prev_row + 32;\n        extra = (int)((temp - (png_bytep)0) & 0x0f);\n        png_ptr->prev_row = temp - extra - 1/*filter byte*/;\n     }\n\n#else\n     /* Use 31 bytes of padding before and 17 bytes after row_buf. */\n     png_ptr->row_buf = png_ptr->big_row_buf + 31;\n     png_ptr->prev_row = png_ptr->big_prev_row + 31;\n#endif\n     png_ptr->old_big_row_buf_size = row_bytes + 48;\n   }\n\n#ifdef PNG_MAX_MALLOC_64K\n   if (png_ptr->rowbytes > 65535)\n      png_error(png_ptr, \"This image requires a row greater than 64KB\");\n\n#endif\n   if (png_ptr->rowbytes > (PNG_SIZE_MAX - 1))\n      png_error(png_ptr, \"Row has too many bytes to allocate in memory\");\n\n   png_memset(png_ptr->prev_row, 0, png_ptr->rowbytes + 1);\n\n   png_debug1(3, \"width = %u,\", png_ptr->width);\n   png_debug1(3, \"height = %u,\", png_ptr->height);\n   png_debug1(3, \"iwidth = %u,\", png_ptr->iwidth);\n   png_debug1(3, \"num_rows = %u,\", png_ptr->num_rows);\n   png_debug1(3, \"rowbytes = %lu,\", (unsigned long)png_ptr->rowbytes);\n   png_debug1(3, \"irowbytes = %lu\",\n       (unsigned long)PNG_ROWBYTES(png_ptr->pixel_depth, png_ptr->iwidth) + 1);\n\n   png_ptr->flags |= PNG_FLAG_ROW_INIT;\n}\n#endif /* PNG_READ_SUPPORTED */\n"
  },
  {
    "path": "Projects/Tools/PNGAlphaPremultiplier/Native/Source/LibPng/pngset.c",
    "content": "\n/* pngset.c - storage of image information into info struct\n *\n * Last changed in libpng 1.5.7 [December 15, 2011]\n * Copyright (c) 1998-2011 Glenn Randers-Pehrson\n * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)\n * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)\n *\n * This code is released under the libpng license.\n * For conditions of distribution and use, see the disclaimer\n * and license in png.h\n *\n * The functions here are used during reads to store data from the file\n * into the info struct, and during writes to store application data\n * into the info struct for writing into the file.  This abstracts the\n * info struct and allows us to change the structure in the future.\n */\n\n#include \"pngpriv.h\"\n\n#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)\n\n#ifdef PNG_bKGD_SUPPORTED\nvoid PNGAPI\npng_set_bKGD(png_structp png_ptr, png_infop info_ptr,\n    png_const_color_16p background)\n{\n   png_debug1(1, \"in %s storage function\", \"bKGD\");\n\n   if (png_ptr == NULL || info_ptr == NULL)\n      return;\n\n   png_memcpy(&(info_ptr->background), background, png_sizeof(png_color_16));\n   info_ptr->valid |= PNG_INFO_bKGD;\n}\n#endif\n\n#ifdef PNG_cHRM_SUPPORTED\nvoid PNGFAPI\npng_set_cHRM_fixed(png_structp png_ptr, png_infop info_ptr,\n    png_fixed_point white_x, png_fixed_point white_y, png_fixed_point red_x,\n    png_fixed_point red_y, png_fixed_point green_x, png_fixed_point green_y,\n    png_fixed_point blue_x, png_fixed_point blue_y)\n{\n   png_debug1(1, \"in %s storage function\", \"cHRM fixed\");\n\n   if (png_ptr == NULL || info_ptr == NULL)\n      return;\n\n#  ifdef PNG_CHECK_cHRM_SUPPORTED\n   if (png_check_cHRM_fixed(png_ptr,\n       white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y))\n#  endif\n   {\n      info_ptr->x_white = white_x;\n      info_ptr->y_white = white_y;\n      info_ptr->x_red   = red_x;\n      info_ptr->y_red   = red_y;\n      info_ptr->x_green = green_x;\n      info_ptr->y_green = green_y;\n      info_ptr->x_blue  = blue_x;\n      info_ptr->y_blue  = blue_y;\n      info_ptr->valid |= PNG_INFO_cHRM;\n   }\n}\n\nvoid PNGFAPI\npng_set_cHRM_XYZ_fixed(png_structp png_ptr, png_infop info_ptr,\n    png_fixed_point int_red_X, png_fixed_point int_red_Y,\n    png_fixed_point int_red_Z, png_fixed_point int_green_X,\n    png_fixed_point int_green_Y, png_fixed_point int_green_Z,\n    png_fixed_point int_blue_X, png_fixed_point int_blue_Y,\n    png_fixed_point int_blue_Z)\n{\n   png_XYZ XYZ;\n   png_xy xy;\n\n   png_debug1(1, \"in %s storage function\", \"cHRM XYZ fixed\");\n\n   if (png_ptr == NULL || info_ptr == NULL)\n      return;\n\n   XYZ.redX = int_red_X;\n   XYZ.redY = int_red_Y;\n   XYZ.redZ = int_red_Z;\n   XYZ.greenX = int_green_X;\n   XYZ.greenY = int_green_Y;\n   XYZ.greenZ = int_green_Z;\n   XYZ.blueX = int_blue_X;\n   XYZ.blueY = int_blue_Y;\n   XYZ.blueZ = int_blue_Z;\n\n   if (png_xy_from_XYZ(&xy, XYZ))\n      png_error(png_ptr, \"XYZ values out of representable range\");\n\n   png_set_cHRM_fixed(png_ptr, info_ptr, xy.whitex, xy.whitey, xy.redx, xy.redy,\n      xy.greenx, xy.greeny, xy.bluex, xy.bluey);\n}\n\n#  ifdef PNG_FLOATING_POINT_SUPPORTED\nvoid PNGAPI\npng_set_cHRM(png_structp png_ptr, png_infop info_ptr,\n    double white_x, double white_y, double red_x, double red_y,\n    double green_x, double green_y, double blue_x, double blue_y)\n{\n   png_set_cHRM_fixed(png_ptr, info_ptr,\n      png_fixed(png_ptr, white_x, \"cHRM White X\"),\n      png_fixed(png_ptr, white_y, \"cHRM White Y\"),\n      png_fixed(png_ptr, red_x, \"cHRM Red X\"),\n      png_fixed(png_ptr, red_y, \"cHRM Red Y\"),\n      png_fixed(png_ptr, green_x, \"cHRM Green X\"),\n      png_fixed(png_ptr, green_y, \"cHRM Green Y\"),\n      png_fixed(png_ptr, blue_x, \"cHRM Blue X\"),\n      png_fixed(png_ptr, blue_y, \"cHRM Blue Y\"));\n}\n\nvoid PNGAPI\npng_set_cHRM_XYZ(png_structp png_ptr, png_infop info_ptr, double red_X,\n    double red_Y, double red_Z, double green_X, double green_Y, double green_Z,\n    double blue_X, double blue_Y, double blue_Z)\n{\n   png_set_cHRM_XYZ_fixed(png_ptr, info_ptr,\n      png_fixed(png_ptr, red_X, \"cHRM Red X\"),\n      png_fixed(png_ptr, red_Y, \"cHRM Red Y\"),\n      png_fixed(png_ptr, red_Z, \"cHRM Red Z\"),\n      png_fixed(png_ptr, green_X, \"cHRM Red X\"),\n      png_fixed(png_ptr, green_Y, \"cHRM Red Y\"),\n      png_fixed(png_ptr, green_Z, \"cHRM Red Z\"),\n      png_fixed(png_ptr, blue_X, \"cHRM Red X\"),\n      png_fixed(png_ptr, blue_Y, \"cHRM Red Y\"),\n      png_fixed(png_ptr, blue_Z, \"cHRM Red Z\"));\n}\n#  endif /* PNG_FLOATING_POINT_SUPPORTED */\n\n#endif /* PNG_cHRM_SUPPORTED */\n\n#ifdef PNG_gAMA_SUPPORTED\nvoid PNGFAPI\npng_set_gAMA_fixed(png_structp png_ptr, png_infop info_ptr, png_fixed_point\n    file_gamma)\n{\n   png_debug1(1, \"in %s storage function\", \"gAMA\");\n\n   if (png_ptr == NULL || info_ptr == NULL)\n      return;\n\n   /* Changed in libpng-1.5.4 to limit the values to ensure overflow can't\n    * occur.  Since the fixed point representation is assymetrical it is\n    * possible for 1/gamma to overflow the limit of 21474 and this means the\n    * gamma value must be at least 5/100000 and hence at most 20000.0.  For\n    * safety the limits here are a little narrower.  The values are 0.00016 to\n    * 6250.0, which are truly ridiculous gammma values (and will produce\n    * displays that are all black or all white.)\n    */\n   if (file_gamma < 16 || file_gamma > 625000000)\n      png_warning(png_ptr, \"Out of range gamma value ignored\");\n\n   else\n   {\n      info_ptr->gamma = file_gamma;\n      info_ptr->valid |= PNG_INFO_gAMA;\n   }\n}\n\n#  ifdef PNG_FLOATING_POINT_SUPPORTED\nvoid PNGAPI\npng_set_gAMA(png_structp png_ptr, png_infop info_ptr, double file_gamma)\n{\n   png_set_gAMA_fixed(png_ptr, info_ptr, png_fixed(png_ptr, file_gamma,\n       \"png_set_gAMA\"));\n}\n#  endif\n#endif\n\n#ifdef PNG_hIST_SUPPORTED\nvoid PNGAPI\npng_set_hIST(png_structp png_ptr, png_infop info_ptr, png_const_uint_16p hist)\n{\n   int i;\n\n   png_debug1(1, \"in %s storage function\", \"hIST\");\n\n   if (png_ptr == NULL || info_ptr == NULL)\n      return;\n\n   if (info_ptr->num_palette == 0 || info_ptr->num_palette\n       > PNG_MAX_PALETTE_LENGTH)\n   {\n      png_warning(png_ptr,\n          \"Invalid palette size, hIST allocation skipped\");\n\n      return;\n   }\n\n   png_free_data(png_ptr, info_ptr, PNG_FREE_HIST, 0);\n\n   /* Changed from info->num_palette to PNG_MAX_PALETTE_LENGTH in\n    * version 1.2.1\n    */\n   png_ptr->hist = (png_uint_16p)png_malloc_warn(png_ptr,\n       PNG_MAX_PALETTE_LENGTH * png_sizeof(png_uint_16));\n\n   if (png_ptr->hist == NULL)\n   {\n      png_warning(png_ptr, \"Insufficient memory for hIST chunk data\");\n      return;\n   }\n\n   for (i = 0; i < info_ptr->num_palette; i++)\n      png_ptr->hist[i] = hist[i];\n\n   info_ptr->hist = png_ptr->hist;\n   info_ptr->valid |= PNG_INFO_hIST;\n   info_ptr->free_me |= PNG_FREE_HIST;\n}\n#endif\n\nvoid PNGAPI\npng_set_IHDR(png_structp png_ptr, png_infop info_ptr,\n    png_uint_32 width, png_uint_32 height, int bit_depth,\n    int color_type, int interlace_type, int compression_type,\n    int filter_type)\n{\n   png_debug1(1, \"in %s storage function\", \"IHDR\");\n\n   if (png_ptr == NULL || info_ptr == NULL)\n      return;\n\n   info_ptr->width = width;\n   info_ptr->height = height;\n   info_ptr->bit_depth = (png_byte)bit_depth;\n   info_ptr->color_type = (png_byte)color_type;\n   info_ptr->compression_type = (png_byte)compression_type;\n   info_ptr->filter_type = (png_byte)filter_type;\n   info_ptr->interlace_type = (png_byte)interlace_type;\n\n   png_check_IHDR (png_ptr, info_ptr->width, info_ptr->height,\n       info_ptr->bit_depth, info_ptr->color_type, info_ptr->interlace_type,\n       info_ptr->compression_type, info_ptr->filter_type);\n\n   if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)\n      info_ptr->channels = 1;\n\n   else if (info_ptr->color_type & PNG_COLOR_MASK_COLOR)\n      info_ptr->channels = 3;\n\n   else\n      info_ptr->channels = 1;\n\n   if (info_ptr->color_type & PNG_COLOR_MASK_ALPHA)\n      info_ptr->channels++;\n\n   info_ptr->pixel_depth = (png_byte)(info_ptr->channels * info_ptr->bit_depth);\n\n   /* Check for potential overflow */\n   if (width >\n       (PNG_UINT_32_MAX >> 3)      /* 8-byte RRGGBBAA pixels */\n       - 48       /* bigrowbuf hack */\n       - 1        /* filter byte */\n       - 7*8      /* rounding of width to multiple of 8 pixels */\n       - 8)       /* extra max_pixel_depth pad */\n      info_ptr->rowbytes = 0;\n   else\n      info_ptr->rowbytes = PNG_ROWBYTES(info_ptr->pixel_depth, width);\n}\n\n#ifdef PNG_oFFs_SUPPORTED\nvoid PNGAPI\npng_set_oFFs(png_structp png_ptr, png_infop info_ptr,\n    png_int_32 offset_x, png_int_32 offset_y, int unit_type)\n{\n   png_debug1(1, \"in %s storage function\", \"oFFs\");\n\n   if (png_ptr == NULL || info_ptr == NULL)\n      return;\n\n   info_ptr->x_offset = offset_x;\n   info_ptr->y_offset = offset_y;\n   info_ptr->offset_unit_type = (png_byte)unit_type;\n   info_ptr->valid |= PNG_INFO_oFFs;\n}\n#endif\n\n#ifdef PNG_pCAL_SUPPORTED\nvoid PNGAPI\npng_set_pCAL(png_structp png_ptr, png_infop info_ptr,\n    png_const_charp purpose, png_int_32 X0, png_int_32 X1, int type,\n    int nparams, png_const_charp units, png_charpp params)\n{\n   png_size_t length;\n   int i;\n\n   png_debug1(1, \"in %s storage function\", \"pCAL\");\n\n   if (png_ptr == NULL || info_ptr == NULL)\n      return;\n\n   length = png_strlen(purpose) + 1;\n   png_debug1(3, \"allocating purpose for info (%lu bytes)\",\n       (unsigned long)length);\n\n   /* TODO: validate format of calibration name and unit name */\n\n   /* Check that the type matches the specification. */\n   if (type < 0 || type > 3)\n      png_error(png_ptr, \"Invalid pCAL equation type\");\n\n   /* Validate params[nparams] */\n   for (i=0; i<nparams; ++i)\n      if (!png_check_fp_string(params[i], png_strlen(params[i])))\n         png_error(png_ptr, \"Invalid format for pCAL parameter\");\n\n   info_ptr->pcal_purpose = (png_charp)png_malloc_warn(png_ptr, length);\n\n   if (info_ptr->pcal_purpose == NULL)\n   {\n      png_warning(png_ptr, \"Insufficient memory for pCAL purpose\");\n      return;\n   }\n\n   png_memcpy(info_ptr->pcal_purpose, purpose, length);\n\n   png_debug(3, \"storing X0, X1, type, and nparams in info\");\n   info_ptr->pcal_X0 = X0;\n   info_ptr->pcal_X1 = X1;\n   info_ptr->pcal_type = (png_byte)type;\n   info_ptr->pcal_nparams = (png_byte)nparams;\n\n   length = png_strlen(units) + 1;\n   png_debug1(3, \"allocating units for info (%lu bytes)\",\n     (unsigned long)length);\n\n   info_ptr->pcal_units = (png_charp)png_malloc_warn(png_ptr, length);\n\n   if (info_ptr->pcal_units == NULL)\n   {\n      png_warning(png_ptr, \"Insufficient memory for pCAL units\");\n      return;\n   }\n\n   png_memcpy(info_ptr->pcal_units, units, length);\n\n   info_ptr->pcal_params = (png_charpp)png_malloc_warn(png_ptr,\n       (png_size_t)((nparams + 1) * png_sizeof(png_charp)));\n\n   if (info_ptr->pcal_params == NULL)\n   {\n      png_warning(png_ptr, \"Insufficient memory for pCAL params\");\n      return;\n   }\n\n   png_memset(info_ptr->pcal_params, 0, (nparams + 1) * png_sizeof(png_charp));\n\n   for (i = 0; i < nparams; i++)\n   {\n      length = png_strlen(params[i]) + 1;\n      png_debug2(3, \"allocating parameter %d for info (%lu bytes)\", i,\n          (unsigned long)length);\n\n      info_ptr->pcal_params[i] = (png_charp)png_malloc_warn(png_ptr, length);\n\n      if (info_ptr->pcal_params[i] == NULL)\n      {\n         png_warning(png_ptr, \"Insufficient memory for pCAL parameter\");\n         return;\n      }\n\n      png_memcpy(info_ptr->pcal_params[i], params[i], length);\n   }\n\n   info_ptr->valid |= PNG_INFO_pCAL;\n   info_ptr->free_me |= PNG_FREE_PCAL;\n}\n#endif\n\n#ifdef PNG_sCAL_SUPPORTED\nvoid PNGAPI\npng_set_sCAL_s(png_structp png_ptr, png_infop info_ptr,\n    int unit, png_const_charp swidth, png_const_charp sheight)\n{\n   png_size_t lengthw = 0, lengthh = 0;\n\n   png_debug1(1, \"in %s storage function\", \"sCAL\");\n\n   if (png_ptr == NULL || info_ptr == NULL)\n      return;\n\n   /* Double check the unit (should never get here with an invalid\n    * unit unless this is an API call.)\n    */\n   if (unit != 1 && unit != 2)\n      png_error(png_ptr, \"Invalid sCAL unit\");\n\n   if (swidth == NULL || (lengthw = png_strlen(swidth)) == 0 ||\n       swidth[0] == 45 /* '-' */ || !png_check_fp_string(swidth, lengthw))\n      png_error(png_ptr, \"Invalid sCAL width\");\n\n   if (sheight == NULL || (lengthh = png_strlen(sheight)) == 0 ||\n       sheight[0] == 45 /* '-' */ || !png_check_fp_string(sheight, lengthh))\n      png_error(png_ptr, \"Invalid sCAL height\");\n\n   info_ptr->scal_unit = (png_byte)unit;\n\n   ++lengthw;\n\n   png_debug1(3, \"allocating unit for info (%u bytes)\", (unsigned int)lengthw);\n\n   info_ptr->scal_s_width = (png_charp)png_malloc_warn(png_ptr, lengthw);\n\n   if (info_ptr->scal_s_width == NULL)\n   {\n      png_warning(png_ptr, \"Memory allocation failed while processing sCAL\");\n      return;\n   }\n\n   png_memcpy(info_ptr->scal_s_width, swidth, lengthw);\n\n   ++lengthh;\n\n   png_debug1(3, \"allocating unit for info (%u bytes)\", (unsigned int)lengthh);\n\n   info_ptr->scal_s_height = (png_charp)png_malloc_warn(png_ptr, lengthh);\n\n   if (info_ptr->scal_s_height == NULL)\n   {\n      png_free (png_ptr, info_ptr->scal_s_width);\n      info_ptr->scal_s_width = NULL;\n\n      png_warning(png_ptr, \"Memory allocation failed while processing sCAL\");\n      return;\n   }\n\n   png_memcpy(info_ptr->scal_s_height, sheight, lengthh);\n\n   info_ptr->valid |= PNG_INFO_sCAL;\n   info_ptr->free_me |= PNG_FREE_SCAL;\n}\n\n#  ifdef PNG_FLOATING_POINT_SUPPORTED\nvoid PNGAPI\npng_set_sCAL(png_structp png_ptr, png_infop info_ptr, int unit, double width,\n    double height)\n{\n   png_debug1(1, \"in %s storage function\", \"sCAL\");\n\n   /* Check the arguments. */\n   if (width <= 0)\n      png_warning(png_ptr, \"Invalid sCAL width ignored\");\n\n   else if (height <= 0)\n      png_warning(png_ptr, \"Invalid sCAL height ignored\");\n\n   else\n   {\n      /* Convert 'width' and 'height' to ASCII. */\n      char swidth[PNG_sCAL_MAX_DIGITS+1];\n      char sheight[PNG_sCAL_MAX_DIGITS+1];\n\n      png_ascii_from_fp(png_ptr, swidth, sizeof swidth, width,\n         PNG_sCAL_PRECISION);\n      png_ascii_from_fp(png_ptr, sheight, sizeof sheight, height,\n         PNG_sCAL_PRECISION);\n\n      png_set_sCAL_s(png_ptr, info_ptr, unit, swidth, sheight);\n   }\n}\n#  endif\n\n#  ifdef PNG_FIXED_POINT_SUPPORTED\nvoid PNGAPI\npng_set_sCAL_fixed(png_structp png_ptr, png_infop info_ptr, int unit,\n    png_fixed_point width, png_fixed_point height)\n{\n   png_debug1(1, \"in %s storage function\", \"sCAL\");\n\n   /* Check the arguments. */\n   if (width <= 0)\n      png_warning(png_ptr, \"Invalid sCAL width ignored\");\n\n   else if (height <= 0)\n      png_warning(png_ptr, \"Invalid sCAL height ignored\");\n\n   else\n   {\n      /* Convert 'width' and 'height' to ASCII. */\n      char swidth[PNG_sCAL_MAX_DIGITS+1];\n      char sheight[PNG_sCAL_MAX_DIGITS+1];\n\n      png_ascii_from_fixed(png_ptr, swidth, sizeof swidth, width);\n      png_ascii_from_fixed(png_ptr, sheight, sizeof sheight, height);\n\n      png_set_sCAL_s(png_ptr, info_ptr, unit, swidth, sheight);\n   }\n}\n#  endif\n#endif\n\n#ifdef PNG_pHYs_SUPPORTED\nvoid PNGAPI\npng_set_pHYs(png_structp png_ptr, png_infop info_ptr,\n    png_uint_32 res_x, png_uint_32 res_y, int unit_type)\n{\n   png_debug1(1, \"in %s storage function\", \"pHYs\");\n\n   if (png_ptr == NULL || info_ptr == NULL)\n      return;\n\n   info_ptr->x_pixels_per_unit = res_x;\n   info_ptr->y_pixels_per_unit = res_y;\n   info_ptr->phys_unit_type = (png_byte)unit_type;\n   info_ptr->valid |= PNG_INFO_pHYs;\n}\n#endif\n\nvoid PNGAPI\npng_set_PLTE(png_structp png_ptr, png_infop info_ptr,\n    png_const_colorp palette, int num_palette)\n{\n\n   png_debug1(1, \"in %s storage function\", \"PLTE\");\n\n   if (png_ptr == NULL || info_ptr == NULL)\n      return;\n\n   if (num_palette < 0 || num_palette > PNG_MAX_PALETTE_LENGTH)\n   {\n      if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)\n         png_error(png_ptr, \"Invalid palette length\");\n\n      else\n      {\n         png_warning(png_ptr, \"Invalid palette length\");\n         return;\n      }\n   }\n\n   /* It may not actually be necessary to set png_ptr->palette here;\n    * we do it for backward compatibility with the way the png_handle_tRNS\n    * function used to do the allocation.\n    */\n   png_free_data(png_ptr, info_ptr, PNG_FREE_PLTE, 0);\n\n   /* Changed in libpng-1.2.1 to allocate PNG_MAX_PALETTE_LENGTH instead\n    * of num_palette entries, in case of an invalid PNG file that has\n    * too-large sample values.\n    */\n   png_ptr->palette = (png_colorp)png_calloc(png_ptr,\n       PNG_MAX_PALETTE_LENGTH * png_sizeof(png_color));\n\n   png_memcpy(png_ptr->palette, palette, num_palette * png_sizeof(png_color));\n   info_ptr->palette = png_ptr->palette;\n   info_ptr->num_palette = png_ptr->num_palette = (png_uint_16)num_palette;\n\n   info_ptr->free_me |= PNG_FREE_PLTE;\n\n   info_ptr->valid |= PNG_INFO_PLTE;\n}\n\n#ifdef PNG_sBIT_SUPPORTED\nvoid PNGAPI\npng_set_sBIT(png_structp png_ptr, png_infop info_ptr,\n    png_const_color_8p sig_bit)\n{\n   png_debug1(1, \"in %s storage function\", \"sBIT\");\n\n   if (png_ptr == NULL || info_ptr == NULL)\n      return;\n\n   png_memcpy(&(info_ptr->sig_bit), sig_bit, png_sizeof(png_color_8));\n   info_ptr->valid |= PNG_INFO_sBIT;\n}\n#endif\n\n#ifdef PNG_sRGB_SUPPORTED\nvoid PNGAPI\npng_set_sRGB(png_structp png_ptr, png_infop info_ptr, int srgb_intent)\n{\n   png_debug1(1, \"in %s storage function\", \"sRGB\");\n\n   if (png_ptr == NULL || info_ptr == NULL)\n      return;\n\n   info_ptr->srgb_intent = (png_byte)srgb_intent;\n   info_ptr->valid |= PNG_INFO_sRGB;\n}\n\nvoid PNGAPI\npng_set_sRGB_gAMA_and_cHRM(png_structp png_ptr, png_infop info_ptr,\n    int srgb_intent)\n{\n   png_debug1(1, \"in %s storage function\", \"sRGB_gAMA_and_cHRM\");\n\n   if (png_ptr == NULL || info_ptr == NULL)\n      return;\n\n   png_set_sRGB(png_ptr, info_ptr, srgb_intent);\n\n#  ifdef PNG_gAMA_SUPPORTED\n   png_set_gAMA_fixed(png_ptr, info_ptr, PNG_GAMMA_sRGB_INVERSE);\n#  endif\n\n#  ifdef PNG_cHRM_SUPPORTED\n   png_set_cHRM_fixed(png_ptr, info_ptr,\n      /* color      x       y */\n      /* white */ 31270, 32900,\n      /* red   */ 64000, 33000,\n      /* green */ 30000, 60000,\n      /* blue  */ 15000,  6000\n   );\n#  endif /* cHRM */\n}\n#endif /* sRGB */\n\n\n#ifdef PNG_iCCP_SUPPORTED\nvoid PNGAPI\npng_set_iCCP(png_structp png_ptr, png_infop info_ptr,\n    png_const_charp name, int compression_type,\n    png_const_bytep profile, png_uint_32 proflen)\n{\n   png_charp new_iccp_name;\n   png_bytep new_iccp_profile;\n   png_size_t length;\n\n   png_debug1(1, \"in %s storage function\", \"iCCP\");\n\n   if (png_ptr == NULL || info_ptr == NULL || name == NULL || profile == NULL)\n      return;\n\n   length = png_strlen(name)+1;\n   new_iccp_name = (png_charp)png_malloc_warn(png_ptr, length);\n\n   if (new_iccp_name == NULL)\n   {\n        png_warning(png_ptr, \"Insufficient memory to process iCCP chunk\");\n      return;\n   }\n\n   png_memcpy(new_iccp_name, name, length);\n   new_iccp_profile = (png_bytep)png_malloc_warn(png_ptr, proflen);\n\n   if (new_iccp_profile == NULL)\n   {\n      png_free (png_ptr, new_iccp_name);\n      png_warning(png_ptr,\n          \"Insufficient memory to process iCCP profile\");\n      return;\n   }\n\n   png_memcpy(new_iccp_profile, profile, (png_size_t)proflen);\n\n   png_free_data(png_ptr, info_ptr, PNG_FREE_ICCP, 0);\n\n   info_ptr->iccp_proflen = proflen;\n   info_ptr->iccp_name = new_iccp_name;\n   info_ptr->iccp_profile = new_iccp_profile;\n   /* Compression is always zero but is here so the API and info structure\n    * does not have to change if we introduce multiple compression types\n    */\n   info_ptr->iccp_compression = (png_byte)compression_type;\n   info_ptr->free_me |= PNG_FREE_ICCP;\n   info_ptr->valid |= PNG_INFO_iCCP;\n}\n#endif\n\n#ifdef PNG_TEXT_SUPPORTED\nvoid PNGAPI\npng_set_text(png_structp png_ptr, png_infop info_ptr, png_const_textp text_ptr,\n    int num_text)\n{\n   int ret;\n   ret = png_set_text_2(png_ptr, info_ptr, text_ptr, num_text);\n\n   if (ret)\n      png_error(png_ptr, \"Insufficient memory to store text\");\n}\n\nint /* PRIVATE */\npng_set_text_2(png_structp png_ptr, png_infop info_ptr,\n    png_const_textp text_ptr, int num_text)\n{\n   int i;\n\n   png_debug1(1, \"in %lx storage function\", png_ptr == NULL ? \"unexpected\" :\n      (unsigned long)png_ptr->chunk_name);\n\n   if (png_ptr == NULL || info_ptr == NULL || num_text == 0)\n      return(0);\n\n   /* Make sure we have enough space in the \"text\" array in info_struct\n    * to hold all of the incoming text_ptr objects.\n    */\n   if (info_ptr->num_text + num_text > info_ptr->max_text)\n   {\n      if (info_ptr->text != NULL)\n      {\n         png_textp old_text;\n         int old_max;\n\n         old_max = info_ptr->max_text;\n         info_ptr->max_text = info_ptr->num_text + num_text + 8;\n         old_text = info_ptr->text;\n         info_ptr->text = (png_textp)png_malloc_warn(png_ptr,\n            (png_size_t)(info_ptr->max_text * png_sizeof(png_text)));\n\n         if (info_ptr->text == NULL)\n         {\n            png_free(png_ptr, old_text);\n            return(1);\n         }\n\n         png_memcpy(info_ptr->text, old_text, (png_size_t)(old_max *\n             png_sizeof(png_text)));\n         png_free(png_ptr, old_text);\n      }\n\n      else\n      {\n         info_ptr->max_text = num_text + 8;\n         info_ptr->num_text = 0;\n         info_ptr->text = (png_textp)png_malloc_warn(png_ptr,\n             (png_size_t)(info_ptr->max_text * png_sizeof(png_text)));\n         if (info_ptr->text == NULL)\n            return(1);\n         info_ptr->free_me |= PNG_FREE_TEXT;\n      }\n\n      png_debug1(3, \"allocated %d entries for info_ptr->text\",\n          info_ptr->max_text);\n   }\n   for (i = 0; i < num_text; i++)\n   {\n      png_size_t text_length, key_len;\n      png_size_t lang_len, lang_key_len;\n      png_textp textp = &(info_ptr->text[info_ptr->num_text]);\n\n      if (text_ptr[i].key == NULL)\n          continue;\n\n      if (text_ptr[i].compression < PNG_TEXT_COMPRESSION_NONE ||\n          text_ptr[i].compression >= PNG_TEXT_COMPRESSION_LAST)\n      {\n         png_warning(png_ptr, \"text compression mode is out of range\");\n         continue;\n      }\n\n      key_len = png_strlen(text_ptr[i].key);\n\n      if (text_ptr[i].compression <= 0)\n      {\n         lang_len = 0;\n         lang_key_len = 0;\n      }\n\n      else\n#  ifdef PNG_iTXt_SUPPORTED\n      {\n         /* Set iTXt data */\n\n         if (text_ptr[i].lang != NULL)\n            lang_len = png_strlen(text_ptr[i].lang);\n\n         else\n            lang_len = 0;\n\n         if (text_ptr[i].lang_key != NULL)\n            lang_key_len = png_strlen(text_ptr[i].lang_key);\n\n         else\n            lang_key_len = 0;\n      }\n#  else /* PNG_iTXt_SUPPORTED */\n      {\n         png_warning(png_ptr, \"iTXt chunk not supported\");\n         continue;\n      }\n#  endif\n\n      if (text_ptr[i].text == NULL || text_ptr[i].text[0] == '\\0')\n      {\n         text_length = 0;\n#  ifdef PNG_iTXt_SUPPORTED\n         if (text_ptr[i].compression > 0)\n            textp->compression = PNG_ITXT_COMPRESSION_NONE;\n\n         else\n#  endif\n            textp->compression = PNG_TEXT_COMPRESSION_NONE;\n      }\n\n      else\n      {\n         text_length = png_strlen(text_ptr[i].text);\n         textp->compression = text_ptr[i].compression;\n      }\n\n      textp->key = (png_charp)png_malloc_warn(png_ptr,\n          (png_size_t)\n          (key_len + text_length + lang_len + lang_key_len + 4));\n\n      if (textp->key == NULL)\n         return(1);\n\n      png_debug2(2, \"Allocated %lu bytes at %p in png_set_text\",\n          (unsigned long)(png_uint_32)\n          (key_len + lang_len + lang_key_len + text_length + 4),\n          textp->key);\n\n      png_memcpy(textp->key, text_ptr[i].key,(png_size_t)(key_len));\n      *(textp->key + key_len) = '\\0';\n\n      if (text_ptr[i].compression > 0)\n      {\n         textp->lang = textp->key + key_len + 1;\n         png_memcpy(textp->lang, text_ptr[i].lang, lang_len);\n         *(textp->lang + lang_len) = '\\0';\n         textp->lang_key = textp->lang + lang_len + 1;\n         png_memcpy(textp->lang_key, text_ptr[i].lang_key, lang_key_len);\n         *(textp->lang_key + lang_key_len) = '\\0';\n         textp->text = textp->lang_key + lang_key_len + 1;\n      }\n\n      else\n      {\n         textp->lang=NULL;\n         textp->lang_key=NULL;\n         textp->text = textp->key + key_len + 1;\n      }\n\n      if (text_length)\n         png_memcpy(textp->text, text_ptr[i].text,\n             (png_size_t)(text_length));\n\n      *(textp->text + text_length) = '\\0';\n\n#  ifdef PNG_iTXt_SUPPORTED\n      if (textp->compression > 0)\n      {\n         textp->text_length = 0;\n         textp->itxt_length = text_length;\n      }\n\n      else\n#  endif\n      {\n         textp->text_length = text_length;\n         textp->itxt_length = 0;\n      }\n\n      info_ptr->num_text++;\n      png_debug1(3, \"transferred text chunk %d\", info_ptr->num_text);\n   }\n   return(0);\n}\n#endif\n\n#ifdef PNG_tIME_SUPPORTED\nvoid PNGAPI\npng_set_tIME(png_structp png_ptr, png_infop info_ptr, png_const_timep mod_time)\n{\n   png_debug1(1, \"in %s storage function\", \"tIME\");\n\n   if (png_ptr == NULL || info_ptr == NULL ||\n       (png_ptr->mode & PNG_WROTE_tIME))\n      return;\n\n   if (mod_time->month == 0   || mod_time->month > 12  ||\n       mod_time->day   == 0   || mod_time->day   > 31  ||\n       mod_time->hour  > 23   || mod_time->minute > 59 ||\n       mod_time->second > 60)\n   {\n      png_warning(png_ptr, \"Ignoring invalid time value\");\n      return;\n   }\n\n   png_memcpy(&(info_ptr->mod_time), mod_time, png_sizeof(png_time));\n   info_ptr->valid |= PNG_INFO_tIME;\n}\n#endif\n\n#ifdef PNG_tRNS_SUPPORTED\nvoid PNGAPI\npng_set_tRNS(png_structp png_ptr, png_infop info_ptr,\n    png_const_bytep trans_alpha, int num_trans, png_const_color_16p trans_color)\n{\n   png_debug1(1, \"in %s storage function\", \"tRNS\");\n\n   if (png_ptr == NULL || info_ptr == NULL)\n      return;\n\n   if (trans_alpha != NULL)\n   {\n       /* It may not actually be necessary to set png_ptr->trans_alpha here;\n        * we do it for backward compatibility with the way the png_handle_tRNS\n        * function used to do the allocation.\n        */\n\n       png_free_data(png_ptr, info_ptr, PNG_FREE_TRNS, 0);\n\n       /* Changed from num_trans to PNG_MAX_PALETTE_LENGTH in version 1.2.1 */\n       png_ptr->trans_alpha = info_ptr->trans_alpha =\n           (png_bytep)png_malloc(png_ptr, (png_size_t)PNG_MAX_PALETTE_LENGTH);\n\n       if (num_trans > 0 && num_trans <= PNG_MAX_PALETTE_LENGTH)\n          png_memcpy(info_ptr->trans_alpha, trans_alpha, (png_size_t)num_trans);\n   }\n\n   if (trans_color != NULL)\n   {\n      int sample_max = (1 << info_ptr->bit_depth);\n\n      if ((info_ptr->color_type == PNG_COLOR_TYPE_GRAY &&\n          (int)trans_color->gray > sample_max) ||\n          (info_ptr->color_type == PNG_COLOR_TYPE_RGB &&\n          ((int)trans_color->red > sample_max ||\n          (int)trans_color->green > sample_max ||\n          (int)trans_color->blue > sample_max)))\n         png_warning(png_ptr,\n            \"tRNS chunk has out-of-range samples for bit_depth\");\n\n      png_memcpy(&(info_ptr->trans_color), trans_color,\n         png_sizeof(png_color_16));\n\n      if (num_trans == 0)\n         num_trans = 1;\n   }\n\n   info_ptr->num_trans = (png_uint_16)num_trans;\n\n   if (num_trans != 0)\n   {\n      info_ptr->valid |= PNG_INFO_tRNS;\n      info_ptr->free_me |= PNG_FREE_TRNS;\n   }\n}\n#endif\n\n#ifdef PNG_sPLT_SUPPORTED\nvoid PNGAPI\npng_set_sPLT(png_structp png_ptr,\n    png_infop info_ptr, png_const_sPLT_tp entries, int nentries)\n/*\n *  entries        - array of png_sPLT_t structures\n *                   to be added to the list of palettes\n *                   in the info structure.\n *\n *  nentries       - number of palette structures to be\n *                   added.\n */\n{\n   png_sPLT_tp np;\n   int i;\n\n   if (png_ptr == NULL || info_ptr == NULL)\n      return;\n\n   np = (png_sPLT_tp)png_malloc_warn(png_ptr,\n       (info_ptr->splt_palettes_num + nentries) *\n       (png_size_t)png_sizeof(png_sPLT_t));\n\n   if (np == NULL)\n   {\n      png_warning(png_ptr, \"No memory for sPLT palettes\");\n      return;\n   }\n\n   png_memcpy(np, info_ptr->splt_palettes,\n       info_ptr->splt_palettes_num * png_sizeof(png_sPLT_t));\n\n   png_free(png_ptr, info_ptr->splt_palettes);\n   info_ptr->splt_palettes=NULL;\n\n   for (i = 0; i < nentries; i++)\n   {\n      png_sPLT_tp to = np + info_ptr->splt_palettes_num + i;\n      png_const_sPLT_tp from = entries + i;\n      png_size_t length;\n\n      length = png_strlen(from->name) + 1;\n      to->name = (png_charp)png_malloc_warn(png_ptr, length);\n\n      if (to->name == NULL)\n      {\n         png_warning(png_ptr,\n             \"Out of memory while processing sPLT chunk\");\n         continue;\n      }\n\n      png_memcpy(to->name, from->name, length);\n      to->entries = (png_sPLT_entryp)png_malloc_warn(png_ptr,\n          from->nentries * png_sizeof(png_sPLT_entry));\n\n      if (to->entries == NULL)\n      {\n         png_warning(png_ptr,\n             \"Out of memory while processing sPLT chunk\");\n         png_free(png_ptr, to->name);\n         to->name = NULL;\n         continue;\n      }\n\n      png_memcpy(to->entries, from->entries,\n          from->nentries * png_sizeof(png_sPLT_entry));\n\n      to->nentries = from->nentries;\n      to->depth = from->depth;\n   }\n\n   info_ptr->splt_palettes = np;\n   info_ptr->splt_palettes_num += nentries;\n   info_ptr->valid |= PNG_INFO_sPLT;\n   info_ptr->free_me |= PNG_FREE_SPLT;\n}\n#endif /* PNG_sPLT_SUPPORTED */\n\n#ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED\nvoid PNGAPI\npng_set_unknown_chunks(png_structp png_ptr,\n   png_infop info_ptr, png_const_unknown_chunkp unknowns, int num_unknowns)\n{\n   png_unknown_chunkp np;\n   int i;\n\n   if (png_ptr == NULL || info_ptr == NULL || num_unknowns == 0)\n      return;\n\n   np = (png_unknown_chunkp)png_malloc_warn(png_ptr,\n       (png_size_t)(info_ptr->unknown_chunks_num + num_unknowns) *\n       png_sizeof(png_unknown_chunk));\n\n   if (np == NULL)\n   {\n      png_warning(png_ptr,\n          \"Out of memory while processing unknown chunk\");\n      return;\n   }\n\n   png_memcpy(np, info_ptr->unknown_chunks,\n       (png_size_t)info_ptr->unknown_chunks_num *\n       png_sizeof(png_unknown_chunk));\n\n   png_free(png_ptr, info_ptr->unknown_chunks);\n   info_ptr->unknown_chunks = NULL;\n\n   for (i = 0; i < num_unknowns; i++)\n   {\n      png_unknown_chunkp to = np + info_ptr->unknown_chunks_num + i;\n      png_const_unknown_chunkp from = unknowns + i;\n\n      png_memcpy(to->name, from->name, png_sizeof(from->name));\n      to->name[png_sizeof(to->name)-1] = '\\0';\n      to->size = from->size;\n\n      /* Note our location in the read or write sequence */\n      to->location = (png_byte)(png_ptr->mode & 0xff);\n\n      if (from->size == 0)\n         to->data=NULL;\n\n      else\n      {\n         to->data = (png_bytep)png_malloc_warn(png_ptr,\n             (png_size_t)from->size);\n\n         if (to->data == NULL)\n         {\n            png_warning(png_ptr,\n                \"Out of memory while processing unknown chunk\");\n            to->size = 0;\n         }\n\n         else\n            png_memcpy(to->data, from->data, from->size);\n      }\n   }\n\n   info_ptr->unknown_chunks = np;\n   info_ptr->unknown_chunks_num += num_unknowns;\n   info_ptr->free_me |= PNG_FREE_UNKN;\n}\n\nvoid PNGAPI\npng_set_unknown_chunk_location(png_structp png_ptr, png_infop info_ptr,\n    int chunk, int location)\n{\n   if (png_ptr != NULL && info_ptr != NULL && chunk >= 0 && chunk <\n       info_ptr->unknown_chunks_num)\n      info_ptr->unknown_chunks[chunk].location = (png_byte)location;\n}\n#endif\n\n\n#ifdef PNG_MNG_FEATURES_SUPPORTED\npng_uint_32 PNGAPI\npng_permit_mng_features (png_structp png_ptr, png_uint_32 mng_features)\n{\n   png_debug(1, \"in png_permit_mng_features\");\n\n   if (png_ptr == NULL)\n      return (png_uint_32)0;\n\n   png_ptr->mng_features_permitted =\n       (png_byte)(mng_features & PNG_ALL_MNG_FEATURES);\n\n   return (png_uint_32)png_ptr->mng_features_permitted;\n}\n#endif\n\n#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED\nvoid PNGAPI\npng_set_keep_unknown_chunks(png_structp png_ptr, int keep, png_const_bytep\n    chunk_list, int num_chunks)\n{\n   png_bytep new_list, p;\n   int i, old_num_chunks;\n   if (png_ptr == NULL)\n      return;\n\n   if (num_chunks == 0)\n   {\n      if (keep == PNG_HANDLE_CHUNK_ALWAYS || keep == PNG_HANDLE_CHUNK_IF_SAFE)\n         png_ptr->flags |= PNG_FLAG_KEEP_UNKNOWN_CHUNKS;\n\n      else\n         png_ptr->flags &= ~PNG_FLAG_KEEP_UNKNOWN_CHUNKS;\n\n      if (keep == PNG_HANDLE_CHUNK_ALWAYS)\n         png_ptr->flags |= PNG_FLAG_KEEP_UNSAFE_CHUNKS;\n\n      else\n         png_ptr->flags &= ~PNG_FLAG_KEEP_UNSAFE_CHUNKS;\n\n      return;\n   }\n\n   if (chunk_list == NULL)\n      return;\n\n   old_num_chunks = png_ptr->num_chunk_list;\n   new_list=(png_bytep)png_malloc(png_ptr,\n       (png_size_t)(5*(num_chunks + old_num_chunks)));\n\n   if (png_ptr->chunk_list != NULL)\n   {\n      png_memcpy(new_list, png_ptr->chunk_list,\n          (png_size_t)(5*old_num_chunks));\n      png_free(png_ptr, png_ptr->chunk_list);\n      png_ptr->chunk_list=NULL;\n   }\n\n   png_memcpy(new_list + 5*old_num_chunks, chunk_list,\n       (png_size_t)(5*num_chunks));\n\n   for (p = new_list + 5*old_num_chunks + 4, i = 0; i<num_chunks; i++, p += 5)\n      *p=(png_byte)keep;\n\n   png_ptr->num_chunk_list = old_num_chunks + num_chunks;\n   png_ptr->chunk_list = new_list;\n   png_ptr->free_me |= PNG_FREE_LIST;\n}\n#endif\n\n#ifdef PNG_READ_USER_CHUNKS_SUPPORTED\nvoid PNGAPI\npng_set_read_user_chunk_fn(png_structp png_ptr, png_voidp user_chunk_ptr,\n    png_user_chunk_ptr read_user_chunk_fn)\n{\n   png_debug(1, \"in png_set_read_user_chunk_fn\");\n\n   if (png_ptr == NULL)\n      return;\n\n   png_ptr->read_user_chunk_fn = read_user_chunk_fn;\n   png_ptr->user_chunk_ptr = user_chunk_ptr;\n}\n#endif\n\n#ifdef PNG_INFO_IMAGE_SUPPORTED\nvoid PNGAPI\npng_set_rows(png_structp png_ptr, png_infop info_ptr, png_bytepp row_pointers)\n{\n   png_debug1(1, \"in %s storage function\", \"rows\");\n\n   if (png_ptr == NULL || info_ptr == NULL)\n      return;\n\n   if (info_ptr->row_pointers && (info_ptr->row_pointers != row_pointers))\n      png_free_data(png_ptr, info_ptr, PNG_FREE_ROWS, 0);\n\n   info_ptr->row_pointers = row_pointers;\n\n   if (row_pointers)\n      info_ptr->valid |= PNG_INFO_IDAT;\n}\n#endif\n\nvoid PNGAPI\npng_set_compression_buffer_size(png_structp png_ptr, png_size_t size)\n{\n    if (png_ptr == NULL)\n       return;\n\n    png_free(png_ptr, png_ptr->zbuf);\n\n    if (size > ZLIB_IO_MAX)\n    {\n       png_warning(png_ptr, \"Attempt to set buffer size beyond max ignored\");\n       png_ptr->zbuf_size = ZLIB_IO_MAX;\n       size = ZLIB_IO_MAX; /* must fit */\n    }\n\n    else\n       png_ptr->zbuf_size = (uInt)size;\n\n    png_ptr->zbuf = (png_bytep)png_malloc(png_ptr, size);\n\n    /* The following ensures a relatively safe failure if this gets called while\n     * the buffer is actually in use.\n     */\n    png_ptr->zstream.next_out = png_ptr->zbuf;\n    png_ptr->zstream.avail_out = 0;\n    png_ptr->zstream.avail_in = 0;\n}\n\nvoid PNGAPI\npng_set_invalid(png_structp png_ptr, png_infop info_ptr, int mask)\n{\n   if (png_ptr && info_ptr)\n      info_ptr->valid &= ~mask;\n}\n\n\n\n#ifdef PNG_SET_USER_LIMITS_SUPPORTED\n/* This function was added to libpng 1.2.6 */\nvoid PNGAPI\npng_set_user_limits (png_structp png_ptr, png_uint_32 user_width_max,\n    png_uint_32 user_height_max)\n{\n   /* Images with dimensions larger than these limits will be\n    * rejected by png_set_IHDR().  To accept any PNG datastream\n    * regardless of dimensions, set both limits to 0x7ffffffL.\n    */\n   if (png_ptr == NULL)\n      return;\n\n   png_ptr->user_width_max = user_width_max;\n   png_ptr->user_height_max = user_height_max;\n}\n\n/* This function was added to libpng 1.4.0 */\nvoid PNGAPI\npng_set_chunk_cache_max (png_structp png_ptr,\n   png_uint_32 user_chunk_cache_max)\n{\n    if (png_ptr)\n       png_ptr->user_chunk_cache_max = user_chunk_cache_max;\n}\n\n/* This function was added to libpng 1.4.1 */\nvoid PNGAPI\npng_set_chunk_malloc_max (png_structp png_ptr,\n    png_alloc_size_t user_chunk_malloc_max)\n{\n   if (png_ptr)\n      png_ptr->user_chunk_malloc_max = user_chunk_malloc_max;\n}\n#endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */\n\n\n#ifdef PNG_BENIGN_ERRORS_SUPPORTED\nvoid PNGAPI\npng_set_benign_errors(png_structp png_ptr, int allowed)\n{\n   png_debug(1, \"in png_set_benign_errors\");\n\n   if (allowed)\n      png_ptr->flags |= PNG_FLAG_BENIGN_ERRORS_WARN;\n\n   else\n      png_ptr->flags &= ~PNG_FLAG_BENIGN_ERRORS_WARN;\n}\n#endif /* PNG_BENIGN_ERRORS_SUPPORTED */\n#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */\n"
  },
  {
    "path": "Projects/Tools/PNGAlphaPremultiplier/Native/Source/LibPng/pngstruct.h",
    "content": "\n/* pngstruct.h - header file for PNG reference library\n *\n * Copyright (c) 1998-2011 Glenn Randers-Pehrson\n * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)\n * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)\n *\n * Last changed in libpng 1.5.9 [February 18, 2012]\n *\n * This code is released under the libpng license.\n * For conditions of distribution and use, see the disclaimer\n * and license in png.h\n */\n\n/* The structure that holds the information to read and write PNG files.\n * The only people who need to care about what is inside of this are the\n * people who will be modifying the library for their own special needs.\n * It should NOT be accessed directly by an application.\n */\n\n#ifndef PNGSTRUCT_H\n#define PNGSTRUCT_H\n/* zlib.h defines the structure z_stream, an instance of which is included\n * in this structure and is required for decompressing the LZ compressed\n * data in PNG files.\n */\n#include \"zlib.h\"\n\nstruct png_struct_def\n{\n#ifdef PNG_SETJMP_SUPPORTED\n   jmp_buf longjmp_buffer;    /* used in png_error */\n   png_longjmp_ptr longjmp_fn;/* setjmp non-local goto function. */\n#endif\n   png_error_ptr error_fn;    /* function for printing errors and aborting */\n#ifdef PNG_WARNINGS_SUPPORTED\n   png_error_ptr warning_fn;  /* function for printing warnings */\n#endif\n   png_voidp error_ptr;       /* user supplied struct for error functions */\n   png_rw_ptr write_data_fn;  /* function for writing output data */\n   png_rw_ptr read_data_fn;   /* function for reading input data */\n   png_voidp io_ptr;          /* ptr to application struct for I/O functions */\n\n#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED\n   png_user_transform_ptr read_user_transform_fn; /* user read transform */\n#endif\n\n#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED\n   png_user_transform_ptr write_user_transform_fn; /* user write transform */\n#endif\n\n/* These were added in libpng-1.0.2 */\n#ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED\n#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \\\n    defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)\n   png_voidp user_transform_ptr; /* user supplied struct for user transform */\n   png_byte user_transform_depth;    /* bit depth of user transformed pixels */\n   png_byte user_transform_channels; /* channels in user transformed pixels */\n#endif\n#endif\n\n   png_uint_32 mode;          /* tells us where we are in the PNG file */\n   png_uint_32 flags;         /* flags indicating various things to libpng */\n   png_uint_32 transformations; /* which transformations to perform */\n\n   z_stream zstream;          /* pointer to decompression structure (below) */\n   png_bytep zbuf;            /* buffer for zlib */\n   uInt zbuf_size;            /* size of zbuf (typically 65536) */\n#ifdef PNG_WRITE_SUPPORTED\n\n/* Added in 1.5.4: state to keep track of whether the zstream has been\n * initialized and if so whether it is for IDAT or some other chunk.\n */\n#define PNG_ZLIB_UNINITIALIZED 0\n#define PNG_ZLIB_FOR_IDAT      1\n#define PNG_ZLIB_FOR_TEXT      2 /* anything other than IDAT */\n#define PNG_ZLIB_USE_MASK      3 /* bottom two bits */\n#define PNG_ZLIB_IN_USE        4 /* a flag value */\n\n   png_uint_32 zlib_state;       /* State of zlib initialization */\n/* End of material added at libpng 1.5.4 */\n\n   int zlib_level;            /* holds zlib compression level */\n   int zlib_method;           /* holds zlib compression method */\n   int zlib_window_bits;      /* holds zlib compression window bits */\n   int zlib_mem_level;        /* holds zlib compression memory level */\n   int zlib_strategy;         /* holds zlib compression strategy */\n#endif\n/* Added at libpng 1.5.4 */\n#if defined(PNG_WRITE_COMPRESSED_TEXT_SUPPORTED) || \\\n    defined(PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED)\n   int zlib_text_level;            /* holds zlib compression level */\n   int zlib_text_method;           /* holds zlib compression method */\n   int zlib_text_window_bits;      /* holds zlib compression window bits */\n   int zlib_text_mem_level;        /* holds zlib compression memory level */\n   int zlib_text_strategy;         /* holds zlib compression strategy */\n#endif\n/* End of material added at libpng 1.5.4 */\n\n   png_uint_32 width;         /* width of image in pixels */\n   png_uint_32 height;        /* height of image in pixels */\n   png_uint_32 num_rows;      /* number of rows in current pass */\n   png_uint_32 usr_width;     /* width of row at start of write */\n   png_size_t rowbytes;       /* size of row in bytes */\n   png_uint_32 iwidth;        /* width of current interlaced row in pixels */\n   png_uint_32 row_number;    /* current row in interlace pass */\n   png_uint_32 chunk_name;    /* PNG_CHUNK() id of current chunk */\n   png_bytep prev_row;        /* buffer to save previous (unfiltered) row.\n                               * This is a pointer into big_prev_row\n                               */\n   png_bytep row_buf;         /* buffer to save current (unfiltered) row.\n                               * This is a pointer into big_row_buf\n                               */\n   png_bytep sub_row;         /* buffer to save \"sub\" row when filtering */\n   png_bytep up_row;          /* buffer to save \"up\" row when filtering */\n   png_bytep avg_row;         /* buffer to save \"avg\" row when filtering */\n   png_bytep paeth_row;       /* buffer to save \"Paeth\" row when filtering */\n   png_size_t info_rowbytes;  /* Added in 1.5.4: cache of updated row bytes */\n\n   png_uint_32 idat_size;     /* current IDAT size for read */\n   png_uint_32 crc;           /* current chunk CRC value */\n   png_colorp palette;        /* palette from the input file */\n   png_uint_16 num_palette;   /* number of color entries in palette */\n   png_uint_16 num_trans;     /* number of transparency values */\n   png_byte compression;      /* file compression type (always 0) */\n   png_byte filter;           /* file filter type (always 0) */\n   png_byte interlaced;       /* PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */\n   png_byte pass;             /* current interlace pass (0 - 6) */\n   png_byte do_filter;        /* row filter flags (see PNG_FILTER_ below ) */\n   png_byte color_type;       /* color type of file */\n   png_byte bit_depth;        /* bit depth of file */\n   png_byte usr_bit_depth;    /* bit depth of users row: write only */\n   png_byte pixel_depth;      /* number of bits per pixel */\n   png_byte channels;         /* number of channels in file */\n   png_byte usr_channels;     /* channels at start of write: write only */\n   png_byte sig_bytes;        /* magic bytes read/written from start of file */\n   png_byte maximum_pixel_depth;\n                              /* pixel depth used for the row buffers */\n   png_byte transformed_pixel_depth;\n                              /* pixel depth after read/write transforms */\n   png_byte io_chunk_string[5];\n                              /* string name of chunk */\n\n#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED)\n   png_uint_16 filler;           /* filler bytes for pixel expansion */\n#endif\n\n#if defined(PNG_bKGD_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) ||\\\n   defined(PNG_READ_ALPHA_MODE_SUPPORTED)\n   png_byte background_gamma_type;\n   png_fixed_point background_gamma;\n   png_color_16 background;   /* background color in screen gamma space */\n#ifdef PNG_READ_GAMMA_SUPPORTED\n   png_color_16 background_1; /* background normalized to gamma 1.0 */\n#endif\n#endif /* PNG_bKGD_SUPPORTED */\n\n#ifdef PNG_WRITE_FLUSH_SUPPORTED\n   png_flush_ptr output_flush_fn; /* Function for flushing output */\n   png_uint_32 flush_dist;    /* how many rows apart to flush, 0 - no flush */\n   png_uint_32 flush_rows;    /* number of rows written since last flush */\n#endif\n\n#ifdef PNG_READ_GAMMA_SUPPORTED\n   int gamma_shift;      /* number of \"insignificant\" bits in 16-bit gamma */\n   png_fixed_point gamma;        /* file gamma value */\n   png_fixed_point screen_gamma; /* screen gamma value (display_exponent) */\n\n   png_bytep gamma_table;     /* gamma table for 8-bit depth files */\n   png_uint_16pp gamma_16_table; /* gamma table for 16-bit depth files */\n#if defined(PNG_READ_BACKGROUND_SUPPORTED) || \\\n   defined(PNG_READ_ALPHA_MODE_SUPPORTED) || \\\n   defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)\n   png_bytep gamma_from_1;    /* converts from 1.0 to screen */\n   png_bytep gamma_to_1;      /* converts from file to 1.0 */\n   png_uint_16pp gamma_16_from_1; /* converts from 1.0 to screen */\n   png_uint_16pp gamma_16_to_1; /* converts from file to 1.0 */\n#endif /* READ_BACKGROUND || READ_ALPHA_MODE || RGB_TO_GRAY */\n#endif\n\n#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_sBIT_SUPPORTED)\n   png_color_8 sig_bit;       /* significant bits in each available channel */\n#endif\n\n#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED)\n   png_color_8 shift;         /* shift for significant bit tranformation */\n#endif\n\n#if defined(PNG_tRNS_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) \\\n || defined(PNG_READ_EXPAND_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)\n   png_bytep trans_alpha;           /* alpha values for paletted files */\n   png_color_16 trans_color;  /* transparent color for non-paletted files */\n#endif\n\n   png_read_status_ptr read_row_fn;   /* called after each row is decoded */\n   png_write_status_ptr write_row_fn; /* called after each row is encoded */\n#ifdef PNG_PROGRESSIVE_READ_SUPPORTED\n   png_progressive_info_ptr info_fn; /* called after header data fully read */\n   png_progressive_row_ptr row_fn;   /* called after a prog. row is decoded */\n   png_progressive_end_ptr end_fn;   /* called after image is complete */\n   png_bytep save_buffer_ptr;        /* current location in save_buffer */\n   png_bytep save_buffer;            /* buffer for previously read data */\n   png_bytep current_buffer_ptr;     /* current location in current_buffer */\n   png_bytep current_buffer;         /* buffer for recently used data */\n   png_uint_32 push_length;          /* size of current input chunk */\n   png_uint_32 skip_length;          /* bytes to skip in input data */\n   png_size_t save_buffer_size;      /* amount of data now in save_buffer */\n   png_size_t save_buffer_max;       /* total size of save_buffer */\n   png_size_t buffer_size;           /* total amount of available input data */\n   png_size_t current_buffer_size;   /* amount of data now in current_buffer */\n   int process_mode;                 /* what push library is currently doing */\n   int cur_palette;                  /* current push library palette index */\n\n#  ifdef PNG_TEXT_SUPPORTED\n     png_size_t current_text_size;   /* current size of text input data */\n     png_size_t current_text_left;   /* how much text left to read in input */\n     png_charp current_text;         /* current text chunk buffer */\n     png_charp current_text_ptr;     /* current location in current_text */\n#  endif /* PNG_PROGRESSIVE_READ_SUPPORTED && PNG_TEXT_SUPPORTED */\n\n#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */\n\n#if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__)\n/* For the Borland special 64K segment handler */\n   png_bytepp offset_table_ptr;\n   png_bytep offset_table;\n   png_uint_16 offset_table_number;\n   png_uint_16 offset_table_count;\n   png_uint_16 offset_table_count_free;\n#endif\n\n#ifdef PNG_READ_QUANTIZE_SUPPORTED\n   png_bytep palette_lookup; /* lookup table for quantizing */\n   png_bytep quantize_index; /* index translation for palette files */\n#endif\n\n#if defined(PNG_READ_QUANTIZE_SUPPORTED) || defined(PNG_hIST_SUPPORTED)\n   png_uint_16p hist;                /* histogram */\n#endif\n\n#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED\n   png_byte heuristic_method;        /* heuristic for row filter selection */\n   png_byte num_prev_filters;        /* number of weights for previous rows */\n   png_bytep prev_filters;           /* filter type(s) of previous row(s) */\n   png_uint_16p filter_weights;      /* weight(s) for previous line(s) */\n   png_uint_16p inv_filter_weights;  /* 1/weight(s) for previous line(s) */\n   png_uint_16p filter_costs;        /* relative filter calculation cost */\n   png_uint_16p inv_filter_costs;    /* 1/relative filter calculation cost */\n#endif\n\n#ifdef PNG_TIME_RFC1123_SUPPORTED\n   char time_buffer[29]; /* String to hold RFC 1123 time text */\n#endif\n\n/* New members added in libpng-1.0.6 */\n\n   png_uint_32 free_me;    /* flags items libpng is responsible for freeing */\n\n#ifdef PNG_USER_CHUNKS_SUPPORTED\n   png_voidp user_chunk_ptr;\n   png_user_chunk_ptr read_user_chunk_fn; /* user read chunk handler */\n#endif\n\n#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED\n   int num_chunk_list;\n   png_bytep chunk_list;\n#endif\n\n#ifdef PNG_READ_sRGB_SUPPORTED\n   /* Added in 1.5.5 to record an sRGB chunk in the png. */\n   png_byte is_sRGB;\n#endif\n\n/* New members added in libpng-1.0.3 */\n#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED\n   png_byte rgb_to_gray_status;\n   /* Added in libpng 1.5.5 to record setting of coefficients: */\n   png_byte rgb_to_gray_coefficients_set;\n   /* These were changed from png_byte in libpng-1.0.6 */\n   png_uint_16 rgb_to_gray_red_coeff;\n   png_uint_16 rgb_to_gray_green_coeff;\n   /* deleted in 1.5.5: rgb_to_gray_blue_coeff; */\n#endif\n\n/* New member added in libpng-1.0.4 (renamed in 1.0.9) */\n#if defined(PNG_MNG_FEATURES_SUPPORTED)\n/* Changed from png_byte to png_uint_32 at version 1.2.0 */\n   png_uint_32 mng_features_permitted;\n#endif\n\n/* New member added in libpng-1.0.9, ifdef'ed out in 1.0.12, enabled in 1.2.0 */\n#ifdef PNG_MNG_FEATURES_SUPPORTED\n   png_byte filter_type;\n#endif\n\n/* New members added in libpng-1.2.0 */\n\n/* New members added in libpng-1.0.2 but first enabled by default in 1.2.0 */\n#ifdef PNG_USER_MEM_SUPPORTED\n   png_voidp mem_ptr;             /* user supplied struct for mem functions */\n   png_malloc_ptr malloc_fn;      /* function for allocating memory */\n   png_free_ptr free_fn;          /* function for freeing memory */\n#endif\n\n/* New member added in libpng-1.0.13 and 1.2.0 */\n   png_bytep big_row_buf;         /* buffer to save current (unfiltered) row */\n\n#ifdef PNG_READ_QUANTIZE_SUPPORTED\n/* The following three members were added at version 1.0.14 and 1.2.4 */\n   png_bytep quantize_sort;          /* working sort array */\n   png_bytep index_to_palette;       /* where the original index currently is\n                                        in the palette */\n   png_bytep palette_to_index;       /* which original index points to this\n                                         palette color */\n#endif\n\n/* New members added in libpng-1.0.16 and 1.2.6 */\n   png_byte compression_type;\n\n#ifdef PNG_USER_LIMITS_SUPPORTED\n   png_uint_32 user_width_max;\n   png_uint_32 user_height_max;\n\n   /* Added in libpng-1.4.0: Total number of sPLT, text, and unknown\n    * chunks that can be stored (0 means unlimited).\n    */\n   png_uint_32 user_chunk_cache_max;\n\n   /* Total memory that a zTXt, sPLT, iTXt, iCCP, or unknown chunk\n    * can occupy when decompressed.  0 means unlimited.\n    */\n   png_alloc_size_t user_chunk_malloc_max;\n#endif\n\n/* New member added in libpng-1.0.25 and 1.2.17 */\n#ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED\n   /* Storage for unknown chunk that the library doesn't recognize. */\n   png_unknown_chunk unknown_chunk;\n#endif\n\n/* New member added in libpng-1.2.26 */\n  png_size_t old_big_row_buf_size;\n\n/* New member added in libpng-1.2.30 */\n  png_charp chunkdata;  /* buffer for reading chunk data */\n\n#ifdef PNG_IO_STATE_SUPPORTED\n/* New member added in libpng-1.4.0 */\n   png_uint_32 io_state;\n#endif\n\n/* New member added in libpng-1.5.6 */\n   png_bytep big_prev_row;\n\n   void (*read_filter[PNG_FILTER_VALUE_LAST-1])(png_row_infop row_info,\n      png_bytep row, png_const_bytep prev_row);\n};\n#endif /* PNGSTRUCT_H */\n"
  },
  {
    "path": "Projects/Tools/PNGAlphaPremultiplier/Native/Source/LibPng/pngtest.c",
    "content": "\n/* pngtest.c - a simple test program to test libpng\n *\n * Last changed in libpng 1.5.6 [November 3, 2011]\n * Copyright (c) 1998-2011 Glenn Randers-Pehrson\n * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)\n * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)\n *\n * This code is released under the libpng license.\n * For conditions of distribution and use, see the disclaimer\n * and license in png.h\n *\n * This program reads in a PNG image, writes it out again, and then\n * compares the two files.  If the files are identical, this shows that\n * the basic chunk handling, filtering, and (de)compression code is working\n * properly.  It does not currently test all of the transforms, although\n * it probably should.\n *\n * The program will report \"FAIL\" in certain legitimate cases:\n * 1) when the compression level or filter selection method is changed.\n * 2) when the maximum IDAT size (PNG_ZBUF_SIZE in pngconf.h) is not 8192.\n * 3) unknown unsafe-to-copy ancillary chunks or unknown critical chunks\n *    exist in the input file.\n * 4) others not listed here...\n * In these cases, it is best to check with another tool such as \"pngcheck\"\n * to see what the differences between the two files are.\n *\n * If a filename is given on the command-line, then this file is used\n * for the input, rather than the default \"pngtest.png\".  This allows\n * testing a wide variety of files easily.  You can also test a number\n * of files at once by typing \"pngtest -m file1.png file2.png ...\"\n */\n\n#define _POSIX_SOURCE 1\n\n#include \"zlib.h\"\n#include \"png.h\"\n/* Copied from pngpriv.h but only used in error messages below. */\n#ifndef PNG_ZBUF_SIZE\n#  define PNG_ZBUF_SIZE 8192\n#endif\n#  include <stdio.h>\n#  include <stdlib.h>\n#  include <string.h>\n#  define FCLOSE(file) fclose(file)\n\n#ifndef PNG_STDIO_SUPPORTED\ntypedef FILE                * png_FILE_p;\n#endif\n\n/* Makes pngtest verbose so we can find problems. */\n#ifndef PNG_DEBUG\n#  define PNG_DEBUG 0\n#endif\n\n#if PNG_DEBUG > 1\n#  define pngtest_debug(m)        ((void)fprintf(stderr, m \"\\n\"))\n#  define pngtest_debug1(m,p1)    ((void)fprintf(stderr, m \"\\n\", p1))\n#  define pngtest_debug2(m,p1,p2) ((void)fprintf(stderr, m \"\\n\", p1, p2))\n#else\n#  define pngtest_debug(m)        ((void)0)\n#  define pngtest_debug1(m,p1)    ((void)0)\n#  define pngtest_debug2(m,p1,p2) ((void)0)\n#endif\n\n#if !PNG_DEBUG\n#  define SINGLE_ROWBUF_ALLOC  /* Makes buffer overruns easier to nail */\n#endif\n\n/* The code uses memcmp and memcpy on large objects (typically row pointers) so\n * it is necessary to do soemthing special on certain architectures, note that\n * the actual support for this was effectively removed in 1.4, so only the\n * memory remains in this program:\n */\n#define CVT_PTR(ptr)         (ptr)\n#define CVT_PTR_NOCHECK(ptr) (ptr)\n#define png_memcmp  memcmp\n#define png_memcpy  memcpy\n#define png_memset  memset\n\n/* Turn on CPU timing\n#define PNGTEST_TIMING\n*/\n\n#ifndef PNG_FLOATING_POINT_SUPPORTED\n#undef PNGTEST_TIMING\n#endif\n\n#ifdef PNGTEST_TIMING\nstatic float t_start, t_stop, t_decode, t_encode, t_misc;\n#include <time.h>\n#endif\n\n#ifdef PNG_TIME_RFC1123_SUPPORTED\n#define PNG_tIME_STRING_LENGTH 29\nstatic int tIME_chunk_present = 0;\nstatic char tIME_string[PNG_tIME_STRING_LENGTH] = \"tIME chunk is not present\";\n#endif\n\nstatic int verbose = 0;\nstatic int strict = 0;\n\nint test_one_file PNGARG((PNG_CONST char *inname, PNG_CONST char *outname));\n\n#ifdef __TURBOC__\n#include <mem.h>\n#endif\n\n/* Defined so I can write to a file on gui/windowing platforms */\n/*  #define STDERR stderr  */\n#define STDERR stdout   /* For DOS */\n\n/* Define png_jmpbuf() in case we are using a pre-1.0.6 version of libpng */\n#ifndef png_jmpbuf\n#  define png_jmpbuf(png_ptr) png_ptr->jmpbuf\n#endif\n\n/* Example of using row callbacks to make a simple progress meter */\nstatic int status_pass = 1;\nstatic int status_dots_requested = 0;\nstatic int status_dots = 1;\n\nvoid PNGCBAPI\nread_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass);\nvoid PNGCBAPI\nread_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass)\n{\n   if (png_ptr == NULL || row_number > PNG_UINT_31_MAX)\n      return;\n\n   if (status_pass != pass)\n   {\n      fprintf(stdout, \"\\n Pass %d: \", pass);\n      status_pass = pass;\n      status_dots = 31;\n   }\n\n   status_dots--;\n\n   if (status_dots == 0)\n   {\n      fprintf(stdout, \"\\n         \");\n      status_dots=30;\n   }\n\n   fprintf(stdout, \"r\");\n}\n\nvoid PNGCBAPI\nwrite_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass);\nvoid PNGCBAPI\nwrite_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass)\n{\n   if (png_ptr == NULL || row_number > PNG_UINT_31_MAX || pass > 7)\n      return;\n\n   fprintf(stdout, \"w\");\n}\n\n\n#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED\n/* Example of using user transform callback (we don't transform anything,\n * but merely examine the row filters.  We set this to 256 rather than\n * 5 in case illegal filter values are present.)\n */\nstatic png_uint_32 filters_used[256];\nvoid PNGCBAPI\ncount_filters(png_structp png_ptr, png_row_infop row_info, png_bytep data);\nvoid PNGCBAPI\ncount_filters(png_structp png_ptr, png_row_infop row_info, png_bytep data)\n{\n   if (png_ptr != NULL && row_info != NULL)\n      ++filters_used[*(data - 1)];\n}\n#endif\n\n#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED\n/* Example of using user transform callback (we don't transform anything,\n * but merely count the zero samples)\n */\n\nstatic png_uint_32 zero_samples;\n\nvoid PNGCBAPI\ncount_zero_samples(png_structp png_ptr, png_row_infop row_info, png_bytep data);\nvoid PNGCBAPI\ncount_zero_samples(png_structp png_ptr, png_row_infop row_info, png_bytep data)\n{\n   png_bytep dp = data;\n   if (png_ptr == NULL)\n      return;\n\n   /* Contents of row_info:\n    *  png_uint_32 width      width of row\n    *  png_uint_32 rowbytes   number of bytes in row\n    *  png_byte color_type    color type of pixels\n    *  png_byte bit_depth     bit depth of samples\n    *  png_byte channels      number of channels (1-4)\n    *  png_byte pixel_depth   bits per pixel (depth*channels)\n    */\n\n    /* Counts the number of zero samples (or zero pixels if color_type is 3 */\n\n    if (row_info->color_type == 0 || row_info->color_type == 3)\n    {\n       int pos = 0;\n       png_uint_32 n, nstop;\n\n       for (n = 0, nstop=row_info->width; n<nstop; n++)\n       {\n          if (row_info->bit_depth == 1)\n          {\n             if (((*dp << pos++ ) & 0x80) == 0)\n                zero_samples++;\n\n             if (pos == 8)\n             {\n                pos = 0;\n                dp++;\n             }\n          }\n\n          if (row_info->bit_depth == 2)\n          {\n             if (((*dp << (pos+=2)) & 0xc0) == 0)\n                zero_samples++;\n\n             if (pos == 8)\n             {\n                pos = 0;\n                dp++;\n             }\n          }\n\n          if (row_info->bit_depth == 4)\n          {\n             if (((*dp << (pos+=4)) & 0xf0) == 0)\n                zero_samples++;\n\n             if (pos == 8)\n             {\n                pos = 0;\n                dp++;\n             }\n          }\n\n          if (row_info->bit_depth == 8)\n             if (*dp++ == 0)\n                zero_samples++;\n\n          if (row_info->bit_depth == 16)\n          {\n             if ((*dp | *(dp+1)) == 0)\n                zero_samples++;\n             dp+=2;\n          }\n       }\n    }\n    else /* Other color types */\n    {\n       png_uint_32 n, nstop;\n       int channel;\n       int color_channels = row_info->channels;\n       if (row_info->color_type > 3)color_channels--;\n\n       for (n = 0, nstop=row_info->width; n<nstop; n++)\n       {\n          for (channel = 0; channel < color_channels; channel++)\n          {\n             if (row_info->bit_depth == 8)\n                if (*dp++ == 0)\n                   zero_samples++;\n\n             if (row_info->bit_depth == 16)\n             {\n                if ((*dp | *(dp+1)) == 0)\n                   zero_samples++;\n\n                dp+=2;\n             }\n          }\n          if (row_info->color_type > 3)\n          {\n             dp++;\n             if (row_info->bit_depth == 16)\n                dp++;\n          }\n       }\n    }\n}\n#endif /* PNG_WRITE_USER_TRANSFORM_SUPPORTED */\n\nstatic int wrote_question = 0;\n\n#ifndef PNG_STDIO_SUPPORTED\n/* START of code to validate stdio-free compilation */\n/* These copies of the default read/write functions come from pngrio.c and\n * pngwio.c.  They allow \"don't include stdio\" testing of the library.\n * This is the function that does the actual reading of data.  If you are\n * not reading from a standard C stream, you should create a replacement\n * read_data function and use it at run time with png_set_read_fn(), rather\n * than changing the library.\n */\n\n#ifdef PNG_IO_STATE_SUPPORTED\nvoid\npngtest_check_io_state(png_structp png_ptr, png_size_t data_length,\n   png_uint_32 io_op);\nvoid\npngtest_check_io_state(png_structp png_ptr, png_size_t data_length,\n   png_uint_32 io_op)\n{\n   png_uint_32 io_state = png_get_io_state(png_ptr);\n   int err = 0;\n\n   /* Check if the current operation (reading / writing) is as expected. */\n   if ((io_state & PNG_IO_MASK_OP) != io_op)\n      png_error(png_ptr, \"Incorrect operation in I/O state\");\n\n   /* Check if the buffer size specific to the current location\n    * (file signature / header / data / crc) is as expected.\n    */\n   switch (io_state & PNG_IO_MASK_LOC)\n   {\n   case PNG_IO_SIGNATURE:\n      if (data_length > 8)\n         err = 1;\n      break;\n   case PNG_IO_CHUNK_HDR:\n      if (data_length != 8)\n         err = 1;\n      break;\n   case PNG_IO_CHUNK_DATA:\n      break;  /* no restrictions here */\n   case PNG_IO_CHUNK_CRC:\n      if (data_length != 4)\n         err = 1;\n      break;\n   default:\n      err = 1;  /* uninitialized */\n   }\n   if (err)\n      png_error(png_ptr, \"Bad I/O state or buffer size\");\n}\n#endif\n\n#ifndef USE_FAR_KEYWORD\nstatic void PNGCBAPI\npngtest_read_data(png_structp png_ptr, png_bytep data, png_size_t length)\n{\n   png_size_t check = 0;\n   png_voidp io_ptr;\n\n   /* fread() returns 0 on error, so it is OK to store this in a png_size_t\n    * instead of an int, which is what fread() actually returns.\n    */\n   io_ptr = png_get_io_ptr(png_ptr);\n   if (io_ptr != NULL)\n   {\n      check = fread(data, 1, length, (png_FILE_p)io_ptr);\n   }\n\n   if (check != length)\n   {\n      png_error(png_ptr, \"Read Error\");\n   }\n\n#ifdef PNG_IO_STATE_SUPPORTED\n   pngtest_check_io_state(png_ptr, length, PNG_IO_READING);\n#endif\n}\n#else\n/* This is the model-independent version. Since the standard I/O library\n   can't handle far buffers in the medium and small models, we have to copy\n   the data.\n*/\n\n#define NEAR_BUF_SIZE 1024\n#define MIN(a,b) (a <= b ? a : b)\n\nstatic void PNGCBAPI\npngtest_read_data(png_structp png_ptr, png_bytep data, png_size_t length)\n{\n   png_size_t check;\n   png_byte *n_data;\n   png_FILE_p io_ptr;\n\n   /* Check if data really is near. If so, use usual code. */\n   n_data = (png_byte *)CVT_PTR_NOCHECK(data);\n   io_ptr = (png_FILE_p)CVT_PTR(png_get_io_ptr(png_ptr));\n   if ((png_bytep)n_data == data)\n   {\n      check = fread(n_data, 1, length, io_ptr);\n   }\n   else\n   {\n      png_byte buf[NEAR_BUF_SIZE];\n      png_size_t read, remaining, err;\n      check = 0;\n      remaining = length;\n\n      do\n      {\n         read = MIN(NEAR_BUF_SIZE, remaining);\n         err = fread(buf, 1, 1, io_ptr);\n         png_memcpy(data, buf, read); /* Copy far buffer to near buffer */\n         if (err != read)\n            break;\n         else\n            check += err;\n         data += read;\n         remaining -= read;\n      }\n      while (remaining != 0);\n   }\n\n   if (check != length)\n      png_error(png_ptr, \"Read Error\");\n\n#ifdef PNG_IO_STATE_SUPPORTED\n   pngtest_check_io_state(png_ptr, length, PNG_IO_READING);\n#endif\n}\n#endif /* USE_FAR_KEYWORD */\n\n#ifdef PNG_WRITE_FLUSH_SUPPORTED\nstatic void PNGCBAPI\npngtest_flush(png_structp png_ptr)\n{\n   /* Do nothing; fflush() is said to be just a waste of energy. */\n   PNG_UNUSED(png_ptr)   /* Stifle compiler warning */\n}\n#endif\n\n/* This is the function that does the actual writing of data.  If you are\n * not writing to a standard C stream, you should create a replacement\n * write_data function and use it at run time with png_set_write_fn(), rather\n * than changing the library.\n */\n#ifndef USE_FAR_KEYWORD\nstatic void PNGCBAPI\npngtest_write_data(png_structp png_ptr, png_bytep data, png_size_t length)\n{\n   png_size_t check;\n\n   check = fwrite(data, 1, length, (png_FILE_p)png_get_io_ptr(png_ptr));\n\n   if (check != length)\n   {\n      png_error(png_ptr, \"Write Error\");\n   }\n\n#ifdef PNG_IO_STATE_SUPPORTED\n   pngtest_check_io_state(png_ptr, length, PNG_IO_WRITING);\n#endif\n}\n#else\n/* This is the model-independent version. Since the standard I/O library\n   can't handle far buffers in the medium and small models, we have to copy\n   the data.\n*/\n\n#define NEAR_BUF_SIZE 1024\n#define MIN(a,b) (a <= b ? a : b)\n\nstatic void PNGCBAPI\npngtest_write_data(png_structp png_ptr, png_bytep data, png_size_t length)\n{\n   png_size_t check;\n   png_byte *near_data;  /* Needs to be \"png_byte *\" instead of \"png_bytep\" */\n   png_FILE_p io_ptr;\n\n   /* Check if data really is near. If so, use usual code. */\n   near_data = (png_byte *)CVT_PTR_NOCHECK(data);\n   io_ptr = (png_FILE_p)CVT_PTR(png_get_io_ptr(png_ptr));\n\n   if ((png_bytep)near_data == data)\n   {\n      check = fwrite(near_data, 1, length, io_ptr);\n   }\n\n   else\n   {\n      png_byte buf[NEAR_BUF_SIZE];\n      png_size_t written, remaining, err;\n      check = 0;\n      remaining = length;\n\n      do\n      {\n         written = MIN(NEAR_BUF_SIZE, remaining);\n         png_memcpy(buf, data, written); /* Copy far buffer to near buffer */\n         err = fwrite(buf, 1, written, io_ptr);\n         if (err != written)\n            break;\n         else\n            check += err;\n         data += written;\n         remaining -= written;\n      }\n      while (remaining != 0);\n   }\n\n   if (check != length)\n   {\n      png_error(png_ptr, \"Write Error\");\n   }\n\n#ifdef PNG_IO_STATE_SUPPORTED\n   pngtest_check_io_state(png_ptr, length, PNG_IO_WRITING);\n#endif\n}\n#endif /* USE_FAR_KEYWORD */\n\n/* This function is called when there is a warning, but the library thinks\n * it can continue anyway.  Replacement functions don't have to do anything\n * here if you don't want to.  In the default configuration, png_ptr is\n * not used, but it is passed in case it may be useful.\n */\nstatic void PNGCBAPI\npngtest_warning(png_structp png_ptr, png_const_charp message)\n{\n   PNG_CONST char *name = \"UNKNOWN (ERROR!)\";\n   char *test;\n   test = png_get_error_ptr(png_ptr);\n\n   if (test == NULL)\n     fprintf(STDERR, \"%s: libpng warning: %s\\n\", name, message);\n\n   else\n     fprintf(STDERR, \"%s: libpng warning: %s\\n\", test, message);\n}\n\n/* This is the default error handling function.  Note that replacements for\n * this function MUST NOT RETURN, or the program will likely crash.  This\n * function is used by default, or if the program supplies NULL for the\n * error function pointer in png_set_error_fn().\n */\nstatic void PNGCBAPI\npngtest_error(png_structp png_ptr, png_const_charp message)\n{\n   pngtest_warning(png_ptr, message);\n   /* We can return because png_error calls the default handler, which is\n    * actually OK in this case.\n    */\n}\n#endif /* !PNG_STDIO_SUPPORTED */\n/* END of code to validate stdio-free compilation */\n\n/* START of code to validate memory allocation and deallocation */\n#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG\n\n/* Allocate memory.  For reasonable files, size should never exceed\n * 64K.  However, zlib may allocate more then 64K if you don't tell\n * it not to.  See zconf.h and png.h for more information.  zlib does\n * need to allocate exactly 64K, so whatever you call here must\n * have the ability to do that.\n *\n * This piece of code can be compiled to validate max 64K allocations\n * by setting MAXSEG_64K in zlib zconf.h *or* PNG_MAX_MALLOC_64K.\n */\ntypedef struct memory_information\n{\n   png_alloc_size_t          size;\n   png_voidp                 pointer;\n   struct memory_information FAR *next;\n} memory_information;\ntypedef memory_information FAR *memory_infop;\n\nstatic memory_infop pinformation = NULL;\nstatic int current_allocation = 0;\nstatic int maximum_allocation = 0;\nstatic int total_allocation = 0;\nstatic int num_allocations = 0;\n\npng_voidp PNGCBAPI png_debug_malloc PNGARG((png_structp png_ptr,\n    png_alloc_size_t size));\nvoid PNGCBAPI png_debug_free PNGARG((png_structp png_ptr, png_voidp ptr));\n\npng_voidp\nPNGCBAPI png_debug_malloc(png_structp png_ptr, png_alloc_size_t size)\n{\n\n   /* png_malloc has already tested for NULL; png_create_struct calls\n    * png_debug_malloc directly, with png_ptr == NULL which is OK\n    */\n\n   if (size == 0)\n      return (NULL);\n\n   /* This calls the library allocator twice, once to get the requested\n      buffer and once to get a new free list entry. */\n   {\n      /* Disable malloc_fn and free_fn */\n      memory_infop pinfo;\n      png_set_mem_fn(png_ptr, NULL, NULL, NULL);\n      pinfo = (memory_infop)png_malloc(png_ptr,\n         png_sizeof(*pinfo));\n      pinfo->size = size;\n      current_allocation += size;\n      total_allocation += size;\n      num_allocations ++;\n\n      if (current_allocation > maximum_allocation)\n         maximum_allocation = current_allocation;\n\n      pinfo->pointer = png_malloc(png_ptr, size);\n      /* Restore malloc_fn and free_fn */\n\n      png_set_mem_fn(png_ptr,\n          NULL, png_debug_malloc, png_debug_free);\n\n      if (size != 0 && pinfo->pointer == NULL)\n      {\n         current_allocation -= size;\n         total_allocation -= size;\n         png_error(png_ptr,\n           \"out of memory in pngtest->png_debug_malloc\");\n      }\n\n      pinfo->next = pinformation;\n      pinformation = pinfo;\n      /* Make sure the caller isn't assuming zeroed memory. */\n      png_memset(pinfo->pointer, 0xdd, pinfo->size);\n\n      if (verbose)\n         printf(\"png_malloc %lu bytes at %p\\n\", (unsigned long)size,\n            pinfo->pointer);\n\n      return (png_voidp)(pinfo->pointer);\n   }\n}\n\n/* Free a pointer.  It is removed from the list at the same time. */\nvoid PNGCBAPI\npng_debug_free(png_structp png_ptr, png_voidp ptr)\n{\n   if (png_ptr == NULL)\n      fprintf(STDERR, \"NULL pointer to png_debug_free.\\n\");\n\n   if (ptr == 0)\n   {\n#if 0 /* This happens all the time. */\n      fprintf(STDERR, \"WARNING: freeing NULL pointer\\n\");\n#endif\n      return;\n   }\n\n   /* Unlink the element from the list. */\n   {\n      memory_infop FAR *ppinfo = &pinformation;\n\n      for (;;)\n      {\n         memory_infop pinfo = *ppinfo;\n\n         if (pinfo->pointer == ptr)\n         {\n            *ppinfo = pinfo->next;\n            current_allocation -= pinfo->size;\n            if (current_allocation < 0)\n               fprintf(STDERR, \"Duplicate free of memory\\n\");\n            /* We must free the list element too, but first kill\n               the memory that is to be freed. */\n            png_memset(ptr, 0x55, pinfo->size);\n            png_free_default(png_ptr, pinfo);\n            pinfo = NULL;\n            break;\n         }\n\n         if (pinfo->next == NULL)\n         {\n            fprintf(STDERR, \"Pointer %x not found\\n\", (unsigned int)ptr);\n            break;\n         }\n\n         ppinfo = &pinfo->next;\n      }\n   }\n\n   /* Finally free the data. */\n   if (verbose)\n      printf(\"Freeing %p\\n\", ptr);\n\n   png_free_default(png_ptr, ptr);\n   ptr = NULL;\n}\n#endif /* PNG_USER_MEM_SUPPORTED && PNG_DEBUG */\n/* END of code to test memory allocation/deallocation */\n\n\n/* Demonstration of user chunk support of the sTER and vpAg chunks */\n#ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED\n\n/* (sTER is a public chunk not yet known by libpng.  vpAg is a private\nchunk used in ImageMagick to store \"virtual page\" size).  */\n\nstatic png_uint_32 user_chunk_data[4];\n\n    /* 0: sTER mode + 1\n     * 1: vpAg width\n     * 2: vpAg height\n     * 3: vpAg units\n     */\n\nstatic int PNGCBAPI read_user_chunk_callback(png_struct *png_ptr,\n   png_unknown_chunkp chunk)\n{\n   png_uint_32\n     *my_user_chunk_data;\n\n   /* Return one of the following:\n    *    return (-n);  chunk had an error\n    *    return (0);  did not recognize\n    *    return (n);  success\n    *\n    * The unknown chunk structure contains the chunk data:\n    * png_byte name[5];\n    * png_byte *data;\n    * png_size_t size;\n    *\n    * Note that libpng has already taken care of the CRC handling.\n    */\n\n   if (chunk->name[0] == 115 && chunk->name[1] ==  84 &&     /* s  T */\n       chunk->name[2] ==  69 && chunk->name[3] ==  82)       /* E  R */\n      {\n         /* Found sTER chunk */\n         if (chunk->size != 1)\n            return (-1); /* Error return */\n\n         if (chunk->data[0] != 0 && chunk->data[0] != 1)\n            return (-1);  /* Invalid mode */\n\n         my_user_chunk_data=(png_uint_32 *) png_get_user_chunk_ptr(png_ptr);\n         my_user_chunk_data[0]=chunk->data[0]+1;\n         return (1);\n      }\n\n   if (chunk->name[0] != 118 || chunk->name[1] != 112 ||    /* v  p */\n       chunk->name[2] !=  65 || chunk->name[3] != 103)      /* A  g */\n      return (0); /* Did not recognize */\n\n   /* Found ImageMagick vpAg chunk */\n\n   if (chunk->size != 9)\n      return (-1); /* Error return */\n\n   my_user_chunk_data=(png_uint_32 *) png_get_user_chunk_ptr(png_ptr);\n\n   my_user_chunk_data[1]=png_get_uint_31(png_ptr, chunk->data);\n   my_user_chunk_data[2]=png_get_uint_31(png_ptr, chunk->data + 4);\n   my_user_chunk_data[3]=(png_uint_32)chunk->data[8];\n\n   return (1);\n\n}\n#endif\n/* END of code to demonstrate user chunk support */\n\n/* Test one file */\nint\ntest_one_file(PNG_CONST char *inname, PNG_CONST char *outname)\n{\n   static png_FILE_p fpin;\n   static png_FILE_p fpout;  /* \"static\" prevents setjmp corruption */\n   png_structp read_ptr;\n   png_infop read_info_ptr, end_info_ptr;\n#ifdef PNG_WRITE_SUPPORTED\n   png_structp write_ptr;\n   png_infop write_info_ptr;\n   png_infop write_end_info_ptr;\n#else\n   png_structp write_ptr = NULL;\n   png_infop write_info_ptr = NULL;\n   png_infop write_end_info_ptr = NULL;\n#endif\n   png_bytep row_buf;\n   png_uint_32 y;\n   png_uint_32 width, height;\n   int num_pass, pass;\n   int bit_depth, color_type;\n#ifdef PNG_SETJMP_SUPPORTED\n#ifdef USE_FAR_KEYWORD\n   jmp_buf tmp_jmpbuf;\n#endif\n#endif\n\n   char inbuf[256], outbuf[256];\n\n   row_buf = NULL;\n\n   if ((fpin = fopen(inname, \"rb\")) == NULL)\n   {\n      fprintf(STDERR, \"Could not find input file %s\\n\", inname);\n      return (1);\n   }\n\n   if ((fpout = fopen(outname, \"wb\")) == NULL)\n   {\n      fprintf(STDERR, \"Could not open output file %s\\n\", outname);\n      FCLOSE(fpin);\n      return (1);\n   }\n\n   pngtest_debug(\"Allocating read and write structures\");\n#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG\n   read_ptr =\n      png_create_read_struct_2(PNG_LIBPNG_VER_STRING, NULL,\n      NULL, NULL, NULL, png_debug_malloc, png_debug_free);\n#else\n   read_ptr =\n      png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);\n#endif\n#ifndef PNG_STDIO_SUPPORTED\n   png_set_error_fn(read_ptr, (png_voidp)inname, pngtest_error,\n       pngtest_warning);\n#endif\n\n#ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED\n   user_chunk_data[0] = 0;\n   user_chunk_data[1] = 0;\n   user_chunk_data[2] = 0;\n   user_chunk_data[3] = 0;\n   png_set_read_user_chunk_fn(read_ptr, user_chunk_data,\n     read_user_chunk_callback);\n\n#endif\n#ifdef PNG_WRITE_SUPPORTED\n#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG\n   write_ptr =\n      png_create_write_struct_2(PNG_LIBPNG_VER_STRING, NULL,\n      NULL, NULL, NULL, png_debug_malloc, png_debug_free);\n#else\n   write_ptr =\n      png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);\n#endif\n#ifndef PNG_STDIO_SUPPORTED\n   png_set_error_fn(write_ptr, (png_voidp)inname, pngtest_error,\n       pngtest_warning);\n#endif\n#endif\n   pngtest_debug(\"Allocating read_info, write_info and end_info structures\");\n   read_info_ptr = png_create_info_struct(read_ptr);\n   end_info_ptr = png_create_info_struct(read_ptr);\n#ifdef PNG_WRITE_SUPPORTED\n   write_info_ptr = png_create_info_struct(write_ptr);\n   write_end_info_ptr = png_create_info_struct(write_ptr);\n#endif\n\n#ifdef PNG_SETJMP_SUPPORTED\n   pngtest_debug(\"Setting jmpbuf for read struct\");\n#ifdef USE_FAR_KEYWORD\n   if (setjmp(tmp_jmpbuf))\n#else\n   if (setjmp(png_jmpbuf(read_ptr)))\n#endif\n   {\n      fprintf(STDERR, \"%s -> %s: libpng read error\\n\", inname, outname);\n      png_free(read_ptr, row_buf);\n      row_buf = NULL;\n      png_destroy_read_struct(&read_ptr, &read_info_ptr, &end_info_ptr);\n#ifdef PNG_WRITE_SUPPORTED\n      png_destroy_info_struct(write_ptr, &write_end_info_ptr);\n      png_destroy_write_struct(&write_ptr, &write_info_ptr);\n#endif\n      FCLOSE(fpin);\n      FCLOSE(fpout);\n      return (1);\n   }\n#ifdef USE_FAR_KEYWORD\n   png_memcpy(png_jmpbuf(read_ptr), tmp_jmpbuf, png_sizeof(jmp_buf));\n#endif\n\n#ifdef PNG_WRITE_SUPPORTED\n   pngtest_debug(\"Setting jmpbuf for write struct\");\n#ifdef USE_FAR_KEYWORD\n\n   if (setjmp(tmp_jmpbuf))\n#else\n   if (setjmp(png_jmpbuf(write_ptr)))\n#endif\n   {\n      fprintf(STDERR, \"%s -> %s: libpng write error\\n\", inname, outname);\n      png_destroy_read_struct(&read_ptr, &read_info_ptr, &end_info_ptr);\n      png_destroy_info_struct(write_ptr, &write_end_info_ptr);\n#ifdef PNG_WRITE_SUPPORTED\n      png_destroy_write_struct(&write_ptr, &write_info_ptr);\n#endif\n      FCLOSE(fpin);\n      FCLOSE(fpout);\n      return (1);\n   }\n\n#ifdef USE_FAR_KEYWORD\n   png_memcpy(png_jmpbuf(write_ptr), tmp_jmpbuf, png_sizeof(jmp_buf));\n#endif\n#endif\n#endif\n\n   pngtest_debug(\"Initializing input and output streams\");\n#ifdef PNG_STDIO_SUPPORTED\n   png_init_io(read_ptr, fpin);\n#  ifdef PNG_WRITE_SUPPORTED\n   png_init_io(write_ptr, fpout);\n#  endif\n#else\n   png_set_read_fn(read_ptr, (png_voidp)fpin, pngtest_read_data);\n#  ifdef PNG_WRITE_SUPPORTED\n   png_set_write_fn(write_ptr, (png_voidp)fpout,  pngtest_write_data,\n#    ifdef PNG_WRITE_FLUSH_SUPPORTED\n      pngtest_flush);\n#    else\n      NULL);\n#    endif\n#  endif\n#endif\n\n#ifdef PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED\n   /* Normally one would use Z_DEFAULT_STRATEGY for text compression.\n    * This is here just to make pngtest replicate the results from libpng\n    * versions prior to 1.5.4, and to test this new API.\n    */\n   png_set_text_compression_strategy(write_ptr, Z_FILTERED);\n#endif\n\n   if (status_dots_requested == 1)\n   {\n#ifdef PNG_WRITE_SUPPORTED\n      png_set_write_status_fn(write_ptr, write_row_callback);\n#endif\n      png_set_read_status_fn(read_ptr, read_row_callback);\n   }\n\n   else\n   {\n#ifdef PNG_WRITE_SUPPORTED\n      png_set_write_status_fn(write_ptr, NULL);\n#endif\n      png_set_read_status_fn(read_ptr, NULL);\n   }\n\n#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED\n   {\n      int i;\n\n      for (i = 0; i<256; i++)\n         filters_used[i] = 0;\n\n      png_set_read_user_transform_fn(read_ptr, count_filters);\n   }\n#endif\n#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED\n   zero_samples = 0;\n   png_set_write_user_transform_fn(write_ptr, count_zero_samples);\n#endif\n\n#ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED\n#  ifndef PNG_HANDLE_CHUNK_ALWAYS\n#    define PNG_HANDLE_CHUNK_ALWAYS       3\n#  endif\n   png_set_keep_unknown_chunks(read_ptr, PNG_HANDLE_CHUNK_ALWAYS,\n      NULL, 0);\n#endif\n#ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED\n#  ifndef PNG_HANDLE_CHUNK_IF_SAFE\n#    define PNG_HANDLE_CHUNK_IF_SAFE      2\n#  endif\n   png_set_keep_unknown_chunks(write_ptr, PNG_HANDLE_CHUNK_IF_SAFE,\n      NULL, 0);\n#endif\n\n   pngtest_debug(\"Reading info struct\");\n   png_read_info(read_ptr, read_info_ptr);\n\n   pngtest_debug(\"Transferring info struct\");\n   {\n      int interlace_type, compression_type, filter_type;\n\n      if (png_get_IHDR(read_ptr, read_info_ptr, &width, &height, &bit_depth,\n          &color_type, &interlace_type, &compression_type, &filter_type))\n      {\n         png_set_IHDR(write_ptr, write_info_ptr, width, height, bit_depth,\n#ifdef PNG_WRITE_INTERLACING_SUPPORTED\n            color_type, interlace_type, compression_type, filter_type);\n#else\n            color_type, PNG_INTERLACE_NONE, compression_type, filter_type);\n#endif\n      }\n   }\n#ifdef PNG_FIXED_POINT_SUPPORTED\n#ifdef PNG_cHRM_SUPPORTED\n   {\n      png_fixed_point white_x, white_y, red_x, red_y, green_x, green_y, blue_x,\n         blue_y;\n\n      if (png_get_cHRM_fixed(read_ptr, read_info_ptr, &white_x, &white_y,\n         &red_x, &red_y, &green_x, &green_y, &blue_x, &blue_y))\n      {\n         png_set_cHRM_fixed(write_ptr, write_info_ptr, white_x, white_y, red_x,\n            red_y, green_x, green_y, blue_x, blue_y);\n      }\n   }\n#endif\n#ifdef PNG_gAMA_SUPPORTED\n   {\n      png_fixed_point gamma;\n\n      if (png_get_gAMA_fixed(read_ptr, read_info_ptr, &gamma))\n         png_set_gAMA_fixed(write_ptr, write_info_ptr, gamma);\n   }\n#endif\n#else /* Use floating point versions */\n#ifdef PNG_FLOATING_POINT_SUPPORTED\n#ifdef PNG_cHRM_SUPPORTED\n   {\n      double white_x, white_y, red_x, red_y, green_x, green_y, blue_x,\n         blue_y;\n\n      if (png_get_cHRM(read_ptr, read_info_ptr, &white_x, &white_y, &red_x,\n         &red_y, &green_x, &green_y, &blue_x, &blue_y))\n      {\n         png_set_cHRM(write_ptr, write_info_ptr, white_x, white_y, red_x,\n            red_y, green_x, green_y, blue_x, blue_y);\n      }\n   }\n#endif\n#ifdef PNG_gAMA_SUPPORTED\n   {\n      double gamma;\n\n      if (png_get_gAMA(read_ptr, read_info_ptr, &gamma))\n         png_set_gAMA(write_ptr, write_info_ptr, gamma);\n   }\n#endif\n#endif /* Floating point */\n#endif /* Fixed point */\n#ifdef PNG_iCCP_SUPPORTED\n   {\n      png_charp name;\n      png_bytep profile;\n      png_uint_32 proflen;\n      int compression_type;\n\n      if (png_get_iCCP(read_ptr, read_info_ptr, &name, &compression_type,\n                      &profile, &proflen))\n      {\n         png_set_iCCP(write_ptr, write_info_ptr, name, compression_type,\n                      profile, proflen);\n      }\n   }\n#endif\n#ifdef PNG_sRGB_SUPPORTED\n   {\n      int intent;\n\n      if (png_get_sRGB(read_ptr, read_info_ptr, &intent))\n         png_set_sRGB(write_ptr, write_info_ptr, intent);\n   }\n#endif\n   {\n      png_colorp palette;\n      int num_palette;\n\n      if (png_get_PLTE(read_ptr, read_info_ptr, &palette, &num_palette))\n         png_set_PLTE(write_ptr, write_info_ptr, palette, num_palette);\n   }\n#ifdef PNG_bKGD_SUPPORTED\n   {\n      png_color_16p background;\n\n      if (png_get_bKGD(read_ptr, read_info_ptr, &background))\n      {\n         png_set_bKGD(write_ptr, write_info_ptr, background);\n      }\n   }\n#endif\n#ifdef PNG_hIST_SUPPORTED\n   {\n      png_uint_16p hist;\n\n      if (png_get_hIST(read_ptr, read_info_ptr, &hist))\n         png_set_hIST(write_ptr, write_info_ptr, hist);\n   }\n#endif\n#ifdef PNG_oFFs_SUPPORTED\n   {\n      png_int_32 offset_x, offset_y;\n      int unit_type;\n\n      if (png_get_oFFs(read_ptr, read_info_ptr, &offset_x, &offset_y,\n          &unit_type))\n      {\n         png_set_oFFs(write_ptr, write_info_ptr, offset_x, offset_y, unit_type);\n      }\n   }\n#endif\n#ifdef PNG_pCAL_SUPPORTED\n   {\n      png_charp purpose, units;\n      png_charpp params;\n      png_int_32 X0, X1;\n      int type, nparams;\n\n      if (png_get_pCAL(read_ptr, read_info_ptr, &purpose, &X0, &X1, &type,\n         &nparams, &units, &params))\n      {\n         png_set_pCAL(write_ptr, write_info_ptr, purpose, X0, X1, type,\n            nparams, units, params);\n      }\n   }\n#endif\n#ifdef PNG_pHYs_SUPPORTED\n   {\n      png_uint_32 res_x, res_y;\n      int unit_type;\n\n      if (png_get_pHYs(read_ptr, read_info_ptr, &res_x, &res_y, &unit_type))\n         png_set_pHYs(write_ptr, write_info_ptr, res_x, res_y, unit_type);\n   }\n#endif\n#ifdef PNG_sBIT_SUPPORTED\n   {\n      png_color_8p sig_bit;\n\n      if (png_get_sBIT(read_ptr, read_info_ptr, &sig_bit))\n         png_set_sBIT(write_ptr, write_info_ptr, sig_bit);\n   }\n#endif\n#ifdef PNG_sCAL_SUPPORTED\n#ifdef PNG_FLOATING_POINT_SUPPORTED\n   {\n      int unit;\n      double scal_width, scal_height;\n\n      if (png_get_sCAL(read_ptr, read_info_ptr, &unit, &scal_width,\n         &scal_height))\n      {\n         png_set_sCAL(write_ptr, write_info_ptr, unit, scal_width, scal_height);\n      }\n   }\n#else\n#ifdef PNG_FIXED_POINT_SUPPORTED\n   {\n      int unit;\n      png_charp scal_width, scal_height;\n\n      if (png_get_sCAL_s(read_ptr, read_info_ptr, &unit, &scal_width,\n          &scal_height))\n      {\n         png_set_sCAL_s(write_ptr, write_info_ptr, unit, scal_width,\n             scal_height);\n      }\n   }\n#endif\n#endif\n#endif\n#ifdef PNG_TEXT_SUPPORTED\n   {\n      png_textp text_ptr;\n      int num_text;\n\n      if (png_get_text(read_ptr, read_info_ptr, &text_ptr, &num_text) > 0)\n      {\n         pngtest_debug1(\"Handling %d iTXt/tEXt/zTXt chunks\", num_text);\n\n         if (verbose)\n            printf(\"\\n Text compression=%d\\n\", text_ptr->compression);\n\n         png_set_text(write_ptr, write_info_ptr, text_ptr, num_text);\n      }\n   }\n#endif\n#ifdef PNG_tIME_SUPPORTED\n   {\n      png_timep mod_time;\n\n      if (png_get_tIME(read_ptr, read_info_ptr, &mod_time))\n      {\n         png_set_tIME(write_ptr, write_info_ptr, mod_time);\n#ifdef PNG_TIME_RFC1123_SUPPORTED\n         /* We have to use png_memcpy instead of \"=\" because the string\n          * pointed to by png_convert_to_rfc1123() gets free'ed before\n          * we use it.\n          */\n         png_memcpy(tIME_string,\n                    png_convert_to_rfc1123(read_ptr, mod_time),\n                    png_sizeof(tIME_string));\n\n         tIME_string[png_sizeof(tIME_string) - 1] = '\\0';\n         tIME_chunk_present++;\n#endif /* PNG_TIME_RFC1123_SUPPORTED */\n      }\n   }\n#endif\n#ifdef PNG_tRNS_SUPPORTED\n   {\n      png_bytep trans_alpha;\n      int num_trans;\n      png_color_16p trans_color;\n\n      if (png_get_tRNS(read_ptr, read_info_ptr, &trans_alpha, &num_trans,\n         &trans_color))\n      {\n         int sample_max = (1 << bit_depth);\n         /* libpng doesn't reject a tRNS chunk with out-of-range samples */\n         if (!((color_type == PNG_COLOR_TYPE_GRAY &&\n             (int)trans_color->gray > sample_max) ||\n             (color_type == PNG_COLOR_TYPE_RGB &&\n             ((int)trans_color->red > sample_max ||\n             (int)trans_color->green > sample_max ||\n             (int)trans_color->blue > sample_max))))\n            png_set_tRNS(write_ptr, write_info_ptr, trans_alpha, num_trans,\n               trans_color);\n      }\n   }\n#endif\n#ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED\n   {\n      png_unknown_chunkp unknowns;\n      int num_unknowns = png_get_unknown_chunks(read_ptr, read_info_ptr,\n         &unknowns);\n\n      if (num_unknowns)\n      {\n         int i;\n         png_set_unknown_chunks(write_ptr, write_info_ptr, unknowns,\n           num_unknowns);\n         /* Copy the locations from the read_info_ptr.  The automatically\n          * generated locations in write_info_ptr are wrong because we\n          * haven't written anything yet.\n          */\n         for (i = 0; i < num_unknowns; i++)\n           png_set_unknown_chunk_location(write_ptr, write_info_ptr, i,\n             unknowns[i].location);\n      }\n   }\n#endif\n\n#ifdef PNG_WRITE_SUPPORTED\n   pngtest_debug(\"Writing info struct\");\n\n/* If we wanted, we could write info in two steps:\n * png_write_info_before_PLTE(write_ptr, write_info_ptr);\n */\n   png_write_info(write_ptr, write_info_ptr);\n\n#ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED\n   if (user_chunk_data[0] != 0)\n   {\n      png_byte png_sTER[5] = {115,  84,  69,  82, '\\0'};\n\n      unsigned char\n        ster_chunk_data[1];\n\n      if (verbose)\n         fprintf(STDERR, \"\\n stereo mode = %lu\\n\",\n           (unsigned long)(user_chunk_data[0] - 1));\n\n      ster_chunk_data[0]=(unsigned char)(user_chunk_data[0] - 1);\n      png_write_chunk(write_ptr, png_sTER, ster_chunk_data, 1);\n   }\n\n   if (user_chunk_data[1] != 0 || user_chunk_data[2] != 0)\n   {\n      png_byte png_vpAg[5] = {118, 112,  65, 103, '\\0'};\n\n      unsigned char\n        vpag_chunk_data[9];\n\n      if (verbose)\n         fprintf(STDERR, \" vpAg = %lu x %lu, units = %lu\\n\",\n           (unsigned long)user_chunk_data[1],\n           (unsigned long)user_chunk_data[2],\n           (unsigned long)user_chunk_data[3]);\n\n      png_save_uint_32(vpag_chunk_data, user_chunk_data[1]);\n      png_save_uint_32(vpag_chunk_data + 4, user_chunk_data[2]);\n      vpag_chunk_data[8] = (unsigned char)(user_chunk_data[3] & 0xff);\n      png_write_chunk(write_ptr, png_vpAg, vpag_chunk_data, 9);\n   }\n\n#endif\n#endif\n\n#ifdef SINGLE_ROWBUF_ALLOC\n   pngtest_debug(\"Allocating row buffer...\");\n   row_buf = (png_bytep)png_malloc(read_ptr,\n      png_get_rowbytes(read_ptr, read_info_ptr));\n\n   pngtest_debug1(\"\\t0x%08lx\", (unsigned long)row_buf);\n#endif /* SINGLE_ROWBUF_ALLOC */\n   pngtest_debug(\"Writing row data\");\n\n#if defined(PNG_READ_INTERLACING_SUPPORTED) || \\\n  defined(PNG_WRITE_INTERLACING_SUPPORTED)\n   num_pass = png_set_interlace_handling(read_ptr);\n#  ifdef PNG_WRITE_SUPPORTED\n   png_set_interlace_handling(write_ptr);\n#  endif\n#else\n   num_pass = 1;\n#endif\n\n#ifdef PNGTEST_TIMING\n   t_stop = (float)clock();\n   t_misc += (t_stop - t_start);\n   t_start = t_stop;\n#endif\n   for (pass = 0; pass < num_pass; pass++)\n   {\n      pngtest_debug1(\"Writing row data for pass %d\", pass);\n      for (y = 0; y < height; y++)\n      {\n#ifndef SINGLE_ROWBUF_ALLOC\n         pngtest_debug2(\"Allocating row buffer (pass %d, y = %u)...\", pass, y);\n         row_buf = (png_bytep)png_malloc(read_ptr,\n            png_get_rowbytes(read_ptr, read_info_ptr));\n\n         pngtest_debug2(\"\\t0x%08lx (%u bytes)\", (unsigned long)row_buf,\n            png_get_rowbytes(read_ptr, read_info_ptr));\n\n#endif /* !SINGLE_ROWBUF_ALLOC */\n         png_read_rows(read_ptr, (png_bytepp)&row_buf, NULL, 1);\n\n#ifdef PNG_WRITE_SUPPORTED\n#ifdef PNGTEST_TIMING\n         t_stop = (float)clock();\n         t_decode += (t_stop - t_start);\n         t_start = t_stop;\n#endif\n         png_write_rows(write_ptr, (png_bytepp)&row_buf, 1);\n#ifdef PNGTEST_TIMING\n         t_stop = (float)clock();\n         t_encode += (t_stop - t_start);\n         t_start = t_stop;\n#endif\n#endif /* PNG_WRITE_SUPPORTED */\n\n#ifndef SINGLE_ROWBUF_ALLOC\n         pngtest_debug2(\"Freeing row buffer (pass %d, y = %u)\", pass, y);\n         png_free(read_ptr, row_buf);\n         row_buf = NULL;\n#endif /* !SINGLE_ROWBUF_ALLOC */\n      }\n   }\n\n#ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED\n   png_free_data(read_ptr, read_info_ptr, PNG_FREE_UNKN, -1);\n#endif\n#ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED\n   png_free_data(write_ptr, write_info_ptr, PNG_FREE_UNKN, -1);\n#endif\n\n   pngtest_debug(\"Reading and writing end_info data\");\n\n   png_read_end(read_ptr, end_info_ptr);\n#ifdef PNG_TEXT_SUPPORTED\n   {\n      png_textp text_ptr;\n      int num_text;\n\n      if (png_get_text(read_ptr, end_info_ptr, &text_ptr, &num_text) > 0)\n      {\n         pngtest_debug1(\"Handling %d iTXt/tEXt/zTXt chunks\", num_text);\n         png_set_text(write_ptr, write_end_info_ptr, text_ptr, num_text);\n      }\n   }\n#endif\n#ifdef PNG_tIME_SUPPORTED\n   {\n      png_timep mod_time;\n\n      if (png_get_tIME(read_ptr, end_info_ptr, &mod_time))\n      {\n         png_set_tIME(write_ptr, write_end_info_ptr, mod_time);\n#ifdef PNG_TIME_RFC1123_SUPPORTED\n         /* We have to use png_memcpy instead of \"=\" because the string\n            pointed to by png_convert_to_rfc1123() gets free'ed before\n            we use it */\n         png_memcpy(tIME_string,\n                    png_convert_to_rfc1123(read_ptr, mod_time),\n                    png_sizeof(tIME_string));\n\n         tIME_string[png_sizeof(tIME_string) - 1] = '\\0';\n         tIME_chunk_present++;\n#endif /* PNG_TIME_RFC1123_SUPPORTED */\n      }\n   }\n#endif\n#ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED\n   {\n      png_unknown_chunkp unknowns;\n      int num_unknowns = png_get_unknown_chunks(read_ptr, end_info_ptr,\n         &unknowns);\n\n      if (num_unknowns)\n      {\n         int i;\n         png_set_unknown_chunks(write_ptr, write_end_info_ptr, unknowns,\n           num_unknowns);\n         /* Copy the locations from the read_info_ptr.  The automatically\n          * generated locations in write_end_info_ptr are wrong because we\n          * haven't written the end_info yet.\n          */\n         for (i = 0; i < num_unknowns; i++)\n           png_set_unknown_chunk_location(write_ptr, write_end_info_ptr, i,\n             unknowns[i].location);\n      }\n   }\n#endif\n#ifdef PNG_WRITE_SUPPORTED\n   png_write_end(write_ptr, write_end_info_ptr);\n#endif\n\n#ifdef PNG_EASY_ACCESS_SUPPORTED\n   if (verbose)\n   {\n      png_uint_32 iwidth, iheight;\n      iwidth = png_get_image_width(write_ptr, write_info_ptr);\n      iheight = png_get_image_height(write_ptr, write_info_ptr);\n      fprintf(STDERR, \"\\n Image width = %lu, height = %lu\\n\",\n         (unsigned long)iwidth, (unsigned long)iheight);\n   }\n#endif\n\n   pngtest_debug(\"Destroying data structs\");\n#ifdef SINGLE_ROWBUF_ALLOC\n   pngtest_debug(\"destroying row_buf for read_ptr\");\n   png_free(read_ptr, row_buf);\n   row_buf = NULL;\n#endif /* SINGLE_ROWBUF_ALLOC */\n   pngtest_debug(\"destroying read_ptr, read_info_ptr, end_info_ptr\");\n   png_destroy_read_struct(&read_ptr, &read_info_ptr, &end_info_ptr);\n#ifdef PNG_WRITE_SUPPORTED\n   pngtest_debug(\"destroying write_end_info_ptr\");\n   png_destroy_info_struct(write_ptr, &write_end_info_ptr);\n   pngtest_debug(\"destroying write_ptr, write_info_ptr\");\n   png_destroy_write_struct(&write_ptr, &write_info_ptr);\n#endif\n   pngtest_debug(\"Destruction complete.\");\n\n   FCLOSE(fpin);\n   FCLOSE(fpout);\n\n   pngtest_debug(\"Opening files for comparison\");\n   if ((fpin = fopen(inname, \"rb\")) == NULL)\n   {\n      fprintf(STDERR, \"Could not find file %s\\n\", inname);\n      return (1);\n   }\n\n   if ((fpout = fopen(outname, \"rb\")) == NULL)\n   {\n      fprintf(STDERR, \"Could not find file %s\\n\", outname);\n      FCLOSE(fpin);\n      return (1);\n   }\n\n   for (;;)\n   {\n      png_size_t num_in, num_out;\n\n         num_in = fread(inbuf, 1, 1, fpin);\n         num_out = fread(outbuf, 1, 1, fpout);\n\n      if (num_in != num_out)\n      {\n         fprintf(STDERR, \"\\nFiles %s and %s are of a different size\\n\",\n                 inname, outname);\n\n         if (wrote_question == 0)\n         {\n            fprintf(STDERR,\n         \"   Was %s written with the same maximum IDAT chunk size (%d bytes),\",\n              inname, PNG_ZBUF_SIZE);\n            fprintf(STDERR,\n              \"\\n   filtering heuristic (libpng default), compression\");\n            fprintf(STDERR,\n              \" level (zlib default),\\n   and zlib version (%s)?\\n\\n\",\n              ZLIB_VERSION);\n            wrote_question = 1;\n         }\n\n         FCLOSE(fpin);\n         FCLOSE(fpout);\n\n         if (strict != 0)\n           return (1);\n\n         else\n           return (0);\n      }\n\n      if (!num_in)\n         break;\n\n      if (png_memcmp(inbuf, outbuf, num_in))\n      {\n         fprintf(STDERR, \"\\nFiles %s and %s are different\\n\", inname, outname);\n\n         if (wrote_question == 0)\n         {\n            fprintf(STDERR,\n         \"   Was %s written with the same maximum IDAT chunk size (%d bytes),\",\n                 inname, PNG_ZBUF_SIZE);\n            fprintf(STDERR,\n              \"\\n   filtering heuristic (libpng default), compression\");\n            fprintf(STDERR,\n              \" level (zlib default),\\n   and zlib version (%s)?\\n\\n\",\n              ZLIB_VERSION);\n            wrote_question = 1;\n         }\n\n         FCLOSE(fpin);\n         FCLOSE(fpout);\n\n         if (strict != 0)\n           return (1);\n\n         else\n           return (0);\n      }\n   }\n\n   FCLOSE(fpin);\n   FCLOSE(fpout);\n\n   return (0);\n}\n\n/* Input and output filenames */\n#ifdef RISCOS\nstatic PNG_CONST char *inname = \"pngtest/png\";\nstatic PNG_CONST char *outname = \"pngout/png\";\n#else\nstatic PNG_CONST char *inname = \"pngtest.png\";\nstatic PNG_CONST char *outname = \"pngout.png\";\n#endif\n\nint\nmain(int argc, char *argv[])\n{\n   int multiple = 0;\n   int ierror = 0;\n\n   fprintf(STDERR, \"\\n Testing libpng version %s\\n\", PNG_LIBPNG_VER_STRING);\n   fprintf(STDERR, \"   with zlib   version %s\\n\", ZLIB_VERSION);\n   fprintf(STDERR, \"%s\", png_get_copyright(NULL));\n   /* Show the version of libpng used in building the library */\n   fprintf(STDERR, \" library (%lu):%s\",\n      (unsigned long)png_access_version_number(),\n      png_get_header_version(NULL));\n\n   /* Show the version of libpng used in building the application */\n   fprintf(STDERR, \" pngtest (%lu):%s\", (unsigned long)PNG_LIBPNG_VER,\n      PNG_HEADER_VERSION_STRING);\n\n   /* Do some consistency checking on the memory allocation settings, I'm\n    * not sure this matters, but it is nice to know, the first of these\n    * tests should be impossible because of the way the macros are set\n    * in pngconf.h\n    */\n#if defined(MAXSEG_64K) && !defined(PNG_MAX_MALLOC_64K)\n      fprintf(STDERR, \" NOTE: Zlib compiled for max 64k, libpng not\\n\");\n#endif\n   /* I think the following can happen. */\n#if !defined(MAXSEG_64K) && defined(PNG_MAX_MALLOC_64K)\n      fprintf(STDERR, \" NOTE: libpng compiled for max 64k, zlib not\\n\");\n#endif\n\n   if (strcmp(png_libpng_ver, PNG_LIBPNG_VER_STRING))\n   {\n      fprintf(STDERR,\n         \"Warning: versions are different between png.h and png.c\\n\");\n      fprintf(STDERR, \"  png.h version: %s\\n\", PNG_LIBPNG_VER_STRING);\n      fprintf(STDERR, \"  png.c version: %s\\n\\n\", png_libpng_ver);\n      ++ierror;\n   }\n\n   if (argc > 1)\n   {\n      if (strcmp(argv[1], \"-m\") == 0)\n      {\n         multiple = 1;\n         status_dots_requested = 0;\n      }\n\n      else if (strcmp(argv[1], \"-mv\") == 0 ||\n               strcmp(argv[1], \"-vm\") == 0 )\n      {\n         multiple = 1;\n         verbose = 1;\n         status_dots_requested = 1;\n      }\n\n      else if (strcmp(argv[1], \"-v\") == 0)\n      {\n         verbose = 1;\n         status_dots_requested = 1;\n         inname = argv[2];\n      }\n\n      else if (strcmp(argv[1], \"--strict\") == 0)\n      {\n         status_dots_requested = 0;\n         verbose = 1;\n         inname = argv[2];\n         strict++;\n      }\n\n      else\n      {\n         inname = argv[1];\n         status_dots_requested = 0;\n      }\n   }\n\n   if (!multiple && argc == 3 + verbose)\n     outname = argv[2 + verbose];\n\n   if ((!multiple && argc > 3 + verbose) || (multiple && argc < 2))\n   {\n     fprintf(STDERR,\n       \"usage: %s [infile.png] [outfile.png]\\n\\t%s -m {infile.png}\\n\",\n        argv[0], argv[0]);\n     fprintf(STDERR,\n       \"  reads/writes one PNG file (without -m) or multiple files (-m)\\n\");\n     fprintf(STDERR,\n       \"  with -m %s is used as a temporary file\\n\", outname);\n     exit(1);\n   }\n\n   if (multiple)\n   {\n      int i;\n#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG\n      int allocation_now = current_allocation;\n#endif\n      for (i=2; i<argc; ++i)\n      {\n         int kerror;\n         fprintf(STDERR, \"\\n Testing %s:\", argv[i]);\n         kerror = test_one_file(argv[i], outname);\n         if (kerror == 0)\n         {\n#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED\n            int k;\n#endif\n#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED\n            fprintf(STDERR, \"\\n PASS (%lu zero samples)\\n\",\n               (unsigned long)zero_samples);\n#else\n            fprintf(STDERR, \" PASS\\n\");\n#endif\n#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED\n            for (k = 0; k<256; k++)\n               if (filters_used[k])\n                  fprintf(STDERR, \" Filter %d was used %lu times\\n\",\n                     k, (unsigned long)filters_used[k]);\n#endif\n#ifdef PNG_TIME_RFC1123_SUPPORTED\n         if (tIME_chunk_present != 0)\n            fprintf(STDERR, \" tIME = %s\\n\", tIME_string);\n\n         tIME_chunk_present = 0;\n#endif /* PNG_TIME_RFC1123_SUPPORTED */\n         }\n\n         else\n         {\n            fprintf(STDERR, \" FAIL\\n\");\n            ierror += kerror;\n         }\n#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG\n         if (allocation_now != current_allocation)\n            fprintf(STDERR, \"MEMORY ERROR: %d bytes lost\\n\",\n               current_allocation - allocation_now);\n\n         if (current_allocation != 0)\n         {\n            memory_infop pinfo = pinformation;\n\n            fprintf(STDERR, \"MEMORY ERROR: %d bytes still allocated\\n\",\n               current_allocation);\n\n            while (pinfo != NULL)\n            {\n               fprintf(STDERR, \" %lu bytes at %x\\n\",\n                 (unsigned long)pinfo->size,\n                 (unsigned int)pinfo->pointer);\n               pinfo = pinfo->next;\n            }\n         }\n#endif\n      }\n#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG\n         fprintf(STDERR, \" Current memory allocation: %10d bytes\\n\",\n            current_allocation);\n         fprintf(STDERR, \" Maximum memory allocation: %10d bytes\\n\",\n            maximum_allocation);\n         fprintf(STDERR, \" Total   memory allocation: %10d bytes\\n\",\n            total_allocation);\n         fprintf(STDERR, \"     Number of allocations: %10d\\n\",\n            num_allocations);\n#endif\n   }\n\n   else\n   {\n      int i;\n      for (i = 0; i<3; ++i)\n      {\n         int kerror;\n#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG\n         int allocation_now = current_allocation;\n#endif\n         if (i == 1)\n            status_dots_requested = 1;\n\n         else if (verbose == 0)\n            status_dots_requested = 0;\n\n         if (i == 0 || verbose == 1 || ierror != 0)\n            fprintf(STDERR, \"\\n Testing %s:\", inname);\n\n         kerror = test_one_file(inname, outname);\n\n         if (kerror == 0)\n         {\n            if (verbose == 1 || i == 2)\n            {\n#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED\n                int k;\n#endif\n#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED\n                fprintf(STDERR, \"\\n PASS (%lu zero samples)\\n\",\n                   (unsigned long)zero_samples);\n#else\n                fprintf(STDERR, \" PASS\\n\");\n#endif\n#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED\n                for (k = 0; k<256; k++)\n                   if (filters_used[k])\n                      fprintf(STDERR, \" Filter %d was used %lu times\\n\",\n                         k, (unsigned long)filters_used[k]);\n#endif\n#ifdef PNG_TIME_RFC1123_SUPPORTED\n             if (tIME_chunk_present != 0)\n                fprintf(STDERR, \" tIME = %s\\n\", tIME_string);\n#endif /* PNG_TIME_RFC1123_SUPPORTED */\n            }\n         }\n\n         else\n         {\n            if (verbose == 0 && i != 2)\n               fprintf(STDERR, \"\\n Testing %s:\", inname);\n\n            fprintf(STDERR, \" FAIL\\n\");\n            ierror += kerror;\n         }\n#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG\n         if (allocation_now != current_allocation)\n             fprintf(STDERR, \"MEMORY ERROR: %d bytes lost\\n\",\n               current_allocation - allocation_now);\n\n         if (current_allocation != 0)\n         {\n             memory_infop pinfo = pinformation;\n\n             fprintf(STDERR, \"MEMORY ERROR: %d bytes still allocated\\n\",\n                current_allocation);\n\n             while (pinfo != NULL)\n             {\n                fprintf(STDERR, \" %lu bytes at %x\\n\",\n                   (unsigned long)pinfo->size, (unsigned int)pinfo->pointer);\n                pinfo = pinfo->next;\n             }\n          }\n#endif\n       }\n#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG\n       fprintf(STDERR, \" Current memory allocation: %10d bytes\\n\",\n          current_allocation);\n       fprintf(STDERR, \" Maximum memory allocation: %10d bytes\\n\",\n          maximum_allocation);\n       fprintf(STDERR, \" Total   memory allocation: %10d bytes\\n\",\n          total_allocation);\n       fprintf(STDERR, \"     Number of allocations: %10d\\n\",\n            num_allocations);\n#endif\n   }\n\n#ifdef PNGTEST_TIMING\n   t_stop = (float)clock();\n   t_misc += (t_stop - t_start);\n   t_start = t_stop;\n   fprintf(STDERR, \" CPU time used = %.3f seconds\",\n      (t_misc+t_decode+t_encode)/(float)CLOCKS_PER_SEC);\n   fprintf(STDERR, \" (decoding %.3f,\\n\",\n      t_decode/(float)CLOCKS_PER_SEC);\n   fprintf(STDERR, \"        encoding %.3f ,\",\n      t_encode/(float)CLOCKS_PER_SEC);\n   fprintf(STDERR, \" other %.3f seconds)\\n\\n\",\n      t_misc/(float)CLOCKS_PER_SEC);\n#endif\n\n   if (ierror == 0)\n      fprintf(STDERR, \" libpng passes test\\n\");\n\n   else\n      fprintf(STDERR, \" libpng FAILS test\\n\");\n\n   return (int)(ierror != 0);\n}\n\n/* Generate a compiler error if there is an old png.h in the search path. */\ntypedef png_libpng_version_1_5_9 Your_png_h_is_not_version_1_5_9;\n"
  },
  {
    "path": "Projects/Tools/PNGAlphaPremultiplier/Native/Source/LibPng/pngtrans.c",
    "content": "\n/* pngtrans.c - transforms the data in a row (used by both readers and writers)\n *\n * Last changed in libpng 1.5.4 [July 7, 2011]\n * Copyright (c) 1998-2011 Glenn Randers-Pehrson\n * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)\n * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)\n *\n * This code is released under the libpng license.\n * For conditions of distribution and use, see the disclaimer\n * and license in png.h\n */\n\n#include \"pngpriv.h\"\n\n#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)\n\n#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED)\n/* Turn on BGR-to-RGB mapping */\nvoid PNGAPI\npng_set_bgr(png_structp png_ptr)\n{\n   png_debug(1, \"in png_set_bgr\");\n\n   if (png_ptr == NULL)\n      return;\n\n   png_ptr->transformations |= PNG_BGR;\n}\n#endif\n\n#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED)\n/* Turn on 16 bit byte swapping */\nvoid PNGAPI\npng_set_swap(png_structp png_ptr)\n{\n   png_debug(1, \"in png_set_swap\");\n\n   if (png_ptr == NULL)\n      return;\n\n   if (png_ptr->bit_depth == 16)\n      png_ptr->transformations |= PNG_SWAP_BYTES;\n}\n#endif\n\n#if defined(PNG_READ_PACK_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED)\n/* Turn on pixel packing */\nvoid PNGAPI\npng_set_packing(png_structp png_ptr)\n{\n   png_debug(1, \"in png_set_packing\");\n\n   if (png_ptr == NULL)\n      return;\n\n   if (png_ptr->bit_depth < 8)\n   {\n      png_ptr->transformations |= PNG_PACK;\n      png_ptr->usr_bit_depth = 8;\n   }\n}\n#endif\n\n#if defined(PNG_READ_PACKSWAP_SUPPORTED)||defined(PNG_WRITE_PACKSWAP_SUPPORTED)\n/* Turn on packed pixel swapping */\nvoid PNGAPI\npng_set_packswap(png_structp png_ptr)\n{\n   png_debug(1, \"in png_set_packswap\");\n\n   if (png_ptr == NULL)\n      return;\n\n   if (png_ptr->bit_depth < 8)\n      png_ptr->transformations |= PNG_PACKSWAP;\n}\n#endif\n\n#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED)\nvoid PNGAPI\npng_set_shift(png_structp png_ptr, png_const_color_8p true_bits)\n{\n   png_debug(1, \"in png_set_shift\");\n\n   if (png_ptr == NULL)\n      return;\n\n   png_ptr->transformations |= PNG_SHIFT;\n   png_ptr->shift = *true_bits;\n}\n#endif\n\n#if defined(PNG_READ_INTERLACING_SUPPORTED) || \\\n    defined(PNG_WRITE_INTERLACING_SUPPORTED)\nint PNGAPI\npng_set_interlace_handling(png_structp png_ptr)\n{\n   png_debug(1, \"in png_set_interlace handling\");\n\n   if (png_ptr && png_ptr->interlaced)\n   {\n      png_ptr->transformations |= PNG_INTERLACE;\n      return (7);\n   }\n\n   return (1);\n}\n#endif\n\n#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED)\n/* Add a filler byte on read, or remove a filler or alpha byte on write.\n * The filler type has changed in v0.95 to allow future 2-byte fillers\n * for 48-bit input data, as well as to avoid problems with some compilers\n * that don't like bytes as parameters.\n */\nvoid PNGAPI\npng_set_filler(png_structp png_ptr, png_uint_32 filler, int filler_loc)\n{\n   png_debug(1, \"in png_set_filler\");\n\n   if (png_ptr == NULL)\n      return;\n\n   png_ptr->transformations |= PNG_FILLER;\n   png_ptr->filler = (png_uint_16)filler;\n\n   if (filler_loc == PNG_FILLER_AFTER)\n      png_ptr->flags |= PNG_FLAG_FILLER_AFTER;\n\n   else\n      png_ptr->flags &= ~PNG_FLAG_FILLER_AFTER;\n\n   /* This should probably go in the \"do_read_filler\" routine.\n    * I attempted to do that in libpng-1.0.1a but that caused problems\n    * so I restored it in libpng-1.0.2a\n   */\n\n   if (png_ptr->color_type == PNG_COLOR_TYPE_RGB)\n   {\n      png_ptr->usr_channels = 4;\n   }\n\n   /* Also I added this in libpng-1.0.2a (what happens when we expand\n    * a less-than-8-bit grayscale to GA?) */\n\n   if (png_ptr->color_type == PNG_COLOR_TYPE_GRAY && png_ptr->bit_depth >= 8)\n   {\n      png_ptr->usr_channels = 2;\n   }\n}\n\n/* Added to libpng-1.2.7 */\nvoid PNGAPI\npng_set_add_alpha(png_structp png_ptr, png_uint_32 filler, int filler_loc)\n{\n   png_debug(1, \"in png_set_add_alpha\");\n\n   if (png_ptr == NULL)\n      return;\n\n   png_set_filler(png_ptr, filler, filler_loc);\n   png_ptr->transformations |= PNG_ADD_ALPHA;\n}\n\n#endif\n\n#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) || \\\n    defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED)\nvoid PNGAPI\npng_set_swap_alpha(png_structp png_ptr)\n{\n   png_debug(1, \"in png_set_swap_alpha\");\n\n   if (png_ptr == NULL)\n      return;\n\n   png_ptr->transformations |= PNG_SWAP_ALPHA;\n}\n#endif\n\n#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) || \\\n    defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED)\nvoid PNGAPI\npng_set_invert_alpha(png_structp png_ptr)\n{\n   png_debug(1, \"in png_set_invert_alpha\");\n\n   if (png_ptr == NULL)\n      return;\n\n   png_ptr->transformations |= PNG_INVERT_ALPHA;\n}\n#endif\n\n#if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED)\nvoid PNGAPI\npng_set_invert_mono(png_structp png_ptr)\n{\n   png_debug(1, \"in png_set_invert_mono\");\n\n   if (png_ptr == NULL)\n      return;\n\n   png_ptr->transformations |= PNG_INVERT_MONO;\n}\n\n/* Invert monochrome grayscale data */\nvoid /* PRIVATE */\npng_do_invert(png_row_infop row_info, png_bytep row)\n{\n   png_debug(1, \"in png_do_invert\");\n\n  /* This test removed from libpng version 1.0.13 and 1.2.0:\n   *   if (row_info->bit_depth == 1 &&\n   */\n   if (row_info->color_type == PNG_COLOR_TYPE_GRAY)\n   {\n      png_bytep rp = row;\n      png_size_t i;\n      png_size_t istop = row_info->rowbytes;\n\n      for (i = 0; i < istop; i++)\n      {\n         *rp = (png_byte)(~(*rp));\n         rp++;\n      }\n   }\n\n   else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA &&\n      row_info->bit_depth == 8)\n   {\n      png_bytep rp = row;\n      png_size_t i;\n      png_size_t istop = row_info->rowbytes;\n\n      for (i = 0; i < istop; i += 2)\n      {\n         *rp = (png_byte)(~(*rp));\n         rp += 2;\n      }\n   }\n\n#ifdef PNG_16BIT_SUPPORTED\n   else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA &&\n      row_info->bit_depth == 16)\n   {\n      png_bytep rp = row;\n      png_size_t i;\n      png_size_t istop = row_info->rowbytes;\n\n      for (i = 0; i < istop; i += 4)\n      {\n         *rp = (png_byte)(~(*rp));\n         *(rp + 1) = (png_byte)(~(*(rp + 1)));\n         rp += 4;\n      }\n   }\n#endif\n}\n#endif\n\n#ifdef PNG_16BIT_SUPPORTED\n#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED)\n/* Swaps byte order on 16 bit depth images */\nvoid /* PRIVATE */\npng_do_swap(png_row_infop row_info, png_bytep row)\n{\n   png_debug(1, \"in png_do_swap\");\n\n   if (row_info->bit_depth == 16)\n   {\n      png_bytep rp = row;\n      png_uint_32 i;\n      png_uint_32 istop= row_info->width * row_info->channels;\n\n      for (i = 0; i < istop; i++, rp += 2)\n      {\n         png_byte t = *rp;\n         *rp = *(rp + 1);\n         *(rp + 1) = t;\n      }\n   }\n}\n#endif\n#endif\n\n#if defined(PNG_READ_PACKSWAP_SUPPORTED)||defined(PNG_WRITE_PACKSWAP_SUPPORTED)\nstatic PNG_CONST png_byte onebppswaptable[256] = {\n   0x00, 0x80, 0x40, 0xC0, 0x20, 0xA0, 0x60, 0xE0,\n   0x10, 0x90, 0x50, 0xD0, 0x30, 0xB0, 0x70, 0xF0,\n   0x08, 0x88, 0x48, 0xC8, 0x28, 0xA8, 0x68, 0xE8,\n   0x18, 0x98, 0x58, 0xD8, 0x38, 0xB8, 0x78, 0xF8,\n   0x04, 0x84, 0x44, 0xC4, 0x24, 0xA4, 0x64, 0xE4,\n   0x14, 0x94, 0x54, 0xD4, 0x34, 0xB4, 0x74, 0xF4,\n   0x0C, 0x8C, 0x4C, 0xCC, 0x2C, 0xAC, 0x6C, 0xEC,\n   0x1C, 0x9C, 0x5C, 0xDC, 0x3C, 0xBC, 0x7C, 0xFC,\n   0x02, 0x82, 0x42, 0xC2, 0x22, 0xA2, 0x62, 0xE2,\n   0x12, 0x92, 0x52, 0xD2, 0x32, 0xB2, 0x72, 0xF2,\n   0x0A, 0x8A, 0x4A, 0xCA, 0x2A, 0xAA, 0x6A, 0xEA,\n   0x1A, 0x9A, 0x5A, 0xDA, 0x3A, 0xBA, 0x7A, 0xFA,\n   0x06, 0x86, 0x46, 0xC6, 0x26, 0xA6, 0x66, 0xE6,\n   0x16, 0x96, 0x56, 0xD6, 0x36, 0xB6, 0x76, 0xF6,\n   0x0E, 0x8E, 0x4E, 0xCE, 0x2E, 0xAE, 0x6E, 0xEE,\n   0x1E, 0x9E, 0x5E, 0xDE, 0x3E, 0xBE, 0x7E, 0xFE,\n   0x01, 0x81, 0x41, 0xC1, 0x21, 0xA1, 0x61, 0xE1,\n   0x11, 0x91, 0x51, 0xD1, 0x31, 0xB1, 0x71, 0xF1,\n   0x09, 0x89, 0x49, 0xC9, 0x29, 0xA9, 0x69, 0xE9,\n   0x19, 0x99, 0x59, 0xD9, 0x39, 0xB9, 0x79, 0xF9,\n   0x05, 0x85, 0x45, 0xC5, 0x25, 0xA5, 0x65, 0xE5,\n   0x15, 0x95, 0x55, 0xD5, 0x35, 0xB5, 0x75, 0xF5,\n   0x0D, 0x8D, 0x4D, 0xCD, 0x2D, 0xAD, 0x6D, 0xED,\n   0x1D, 0x9D, 0x5D, 0xDD, 0x3D, 0xBD, 0x7D, 0xFD,\n   0x03, 0x83, 0x43, 0xC3, 0x23, 0xA3, 0x63, 0xE3,\n   0x13, 0x93, 0x53, 0xD3, 0x33, 0xB3, 0x73, 0xF3,\n   0x0B, 0x8B, 0x4B, 0xCB, 0x2B, 0xAB, 0x6B, 0xEB,\n   0x1B, 0x9B, 0x5B, 0xDB, 0x3B, 0xBB, 0x7B, 0xFB,\n   0x07, 0x87, 0x47, 0xC7, 0x27, 0xA7, 0x67, 0xE7,\n   0x17, 0x97, 0x57, 0xD7, 0x37, 0xB7, 0x77, 0xF7,\n   0x0F, 0x8F, 0x4F, 0xCF, 0x2F, 0xAF, 0x6F, 0xEF,\n   0x1F, 0x9F, 0x5F, 0xDF, 0x3F, 0xBF, 0x7F, 0xFF\n};\n\nstatic PNG_CONST png_byte twobppswaptable[256] = {\n   0x00, 0x40, 0x80, 0xC0, 0x10, 0x50, 0x90, 0xD0,\n   0x20, 0x60, 0xA0, 0xE0, 0x30, 0x70, 0xB0, 0xF0,\n   0x04, 0x44, 0x84, 0xC4, 0x14, 0x54, 0x94, 0xD4,\n   0x24, 0x64, 0xA4, 0xE4, 0x34, 0x74, 0xB4, 0xF4,\n   0x08, 0x48, 0x88, 0xC8, 0x18, 0x58, 0x98, 0xD8,\n   0x28, 0x68, 0xA8, 0xE8, 0x38, 0x78, 0xB8, 0xF8,\n   0x0C, 0x4C, 0x8C, 0xCC, 0x1C, 0x5C, 0x9C, 0xDC,\n   0x2C, 0x6C, 0xAC, 0xEC, 0x3C, 0x7C, 0xBC, 0xFC,\n   0x01, 0x41, 0x81, 0xC1, 0x11, 0x51, 0x91, 0xD1,\n   0x21, 0x61, 0xA1, 0xE1, 0x31, 0x71, 0xB1, 0xF1,\n   0x05, 0x45, 0x85, 0xC5, 0x15, 0x55, 0x95, 0xD5,\n   0x25, 0x65, 0xA5, 0xE5, 0x35, 0x75, 0xB5, 0xF5,\n   0x09, 0x49, 0x89, 0xC9, 0x19, 0x59, 0x99, 0xD9,\n   0x29, 0x69, 0xA9, 0xE9, 0x39, 0x79, 0xB9, 0xF9,\n   0x0D, 0x4D, 0x8D, 0xCD, 0x1D, 0x5D, 0x9D, 0xDD,\n   0x2D, 0x6D, 0xAD, 0xED, 0x3D, 0x7D, 0xBD, 0xFD,\n   0x02, 0x42, 0x82, 0xC2, 0x12, 0x52, 0x92, 0xD2,\n   0x22, 0x62, 0xA2, 0xE2, 0x32, 0x72, 0xB2, 0xF2,\n   0x06, 0x46, 0x86, 0xC6, 0x16, 0x56, 0x96, 0xD6,\n   0x26, 0x66, 0xA6, 0xE6, 0x36, 0x76, 0xB6, 0xF6,\n   0x0A, 0x4A, 0x8A, 0xCA, 0x1A, 0x5A, 0x9A, 0xDA,\n   0x2A, 0x6A, 0xAA, 0xEA, 0x3A, 0x7A, 0xBA, 0xFA,\n   0x0E, 0x4E, 0x8E, 0xCE, 0x1E, 0x5E, 0x9E, 0xDE,\n   0x2E, 0x6E, 0xAE, 0xEE, 0x3E, 0x7E, 0xBE, 0xFE,\n   0x03, 0x43, 0x83, 0xC3, 0x13, 0x53, 0x93, 0xD3,\n   0x23, 0x63, 0xA3, 0xE3, 0x33, 0x73, 0xB3, 0xF3,\n   0x07, 0x47, 0x87, 0xC7, 0x17, 0x57, 0x97, 0xD7,\n   0x27, 0x67, 0xA7, 0xE7, 0x37, 0x77, 0xB7, 0xF7,\n   0x0B, 0x4B, 0x8B, 0xCB, 0x1B, 0x5B, 0x9B, 0xDB,\n   0x2B, 0x6B, 0xAB, 0xEB, 0x3B, 0x7B, 0xBB, 0xFB,\n   0x0F, 0x4F, 0x8F, 0xCF, 0x1F, 0x5F, 0x9F, 0xDF,\n   0x2F, 0x6F, 0xAF, 0xEF, 0x3F, 0x7F, 0xBF, 0xFF\n};\n\nstatic PNG_CONST png_byte fourbppswaptable[256] = {\n   0x00, 0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70,\n   0x80, 0x90, 0xA0, 0xB0, 0xC0, 0xD0, 0xE0, 0xF0,\n   0x01, 0x11, 0x21, 0x31, 0x41, 0x51, 0x61, 0x71,\n   0x81, 0x91, 0xA1, 0xB1, 0xC1, 0xD1, 0xE1, 0xF1,\n   0x02, 0x12, 0x22, 0x32, 0x42, 0x52, 0x62, 0x72,\n   0x82, 0x92, 0xA2, 0xB2, 0xC2, 0xD2, 0xE2, 0xF2,\n   0x03, 0x13, 0x23, 0x33, 0x43, 0x53, 0x63, 0x73,\n   0x83, 0x93, 0xA3, 0xB3, 0xC3, 0xD3, 0xE3, 0xF3,\n   0x04, 0x14, 0x24, 0x34, 0x44, 0x54, 0x64, 0x74,\n   0x84, 0x94, 0xA4, 0xB4, 0xC4, 0xD4, 0xE4, 0xF4,\n   0x05, 0x15, 0x25, 0x35, 0x45, 0x55, 0x65, 0x75,\n   0x85, 0x95, 0xA5, 0xB5, 0xC5, 0xD5, 0xE5, 0xF5,\n   0x06, 0x16, 0x26, 0x36, 0x46, 0x56, 0x66, 0x76,\n   0x86, 0x96, 0xA6, 0xB6, 0xC6, 0xD6, 0xE6, 0xF6,\n   0x07, 0x17, 0x27, 0x37, 0x47, 0x57, 0x67, 0x77,\n   0x87, 0x97, 0xA7, 0xB7, 0xC7, 0xD7, 0xE7, 0xF7,\n   0x08, 0x18, 0x28, 0x38, 0x48, 0x58, 0x68, 0x78,\n   0x88, 0x98, 0xA8, 0xB8, 0xC8, 0xD8, 0xE8, 0xF8,\n   0x09, 0x19, 0x29, 0x39, 0x49, 0x59, 0x69, 0x79,\n   0x89, 0x99, 0xA9, 0xB9, 0xC9, 0xD9, 0xE9, 0xF9,\n   0x0A, 0x1A, 0x2A, 0x3A, 0x4A, 0x5A, 0x6A, 0x7A,\n   0x8A, 0x9A, 0xAA, 0xBA, 0xCA, 0xDA, 0xEA, 0xFA,\n   0x0B, 0x1B, 0x2B, 0x3B, 0x4B, 0x5B, 0x6B, 0x7B,\n   0x8B, 0x9B, 0xAB, 0xBB, 0xCB, 0xDB, 0xEB, 0xFB,\n   0x0C, 0x1C, 0x2C, 0x3C, 0x4C, 0x5C, 0x6C, 0x7C,\n   0x8C, 0x9C, 0xAC, 0xBC, 0xCC, 0xDC, 0xEC, 0xFC,\n   0x0D, 0x1D, 0x2D, 0x3D, 0x4D, 0x5D, 0x6D, 0x7D,\n   0x8D, 0x9D, 0xAD, 0xBD, 0xCD, 0xDD, 0xED, 0xFD,\n   0x0E, 0x1E, 0x2E, 0x3E, 0x4E, 0x5E, 0x6E, 0x7E,\n   0x8E, 0x9E, 0xAE, 0xBE, 0xCE, 0xDE, 0xEE, 0xFE,\n   0x0F, 0x1F, 0x2F, 0x3F, 0x4F, 0x5F, 0x6F, 0x7F,\n   0x8F, 0x9F, 0xAF, 0xBF, 0xCF, 0xDF, 0xEF, 0xFF\n};\n\n/* Swaps pixel packing order within bytes */\nvoid /* PRIVATE */\npng_do_packswap(png_row_infop row_info, png_bytep row)\n{\n   png_debug(1, \"in png_do_packswap\");\n\n   if (row_info->bit_depth < 8)\n   {\n      png_bytep rp;\n      png_const_bytep end, table;\n\n      end = row + row_info->rowbytes;\n\n      if (row_info->bit_depth == 1)\n         table = onebppswaptable;\n\n      else if (row_info->bit_depth == 2)\n         table = twobppswaptable;\n\n      else if (row_info->bit_depth == 4)\n         table = fourbppswaptable;\n\n      else\n         return;\n\n      for (rp = row; rp < end; rp++)\n         *rp = table[*rp];\n   }\n}\n#endif /* PNG_READ_PACKSWAP_SUPPORTED or PNG_WRITE_PACKSWAP_SUPPORTED */\n\n#if defined(PNG_WRITE_FILLER_SUPPORTED) || \\\n    defined(PNG_READ_STRIP_ALPHA_SUPPORTED)\n/* Remove a channel - this used to be 'png_do_strip_filler' but it used a\n * somewhat weird combination of flags to determine what to do.  All the calls\n * to png_do_strip_filler are changed in 1.5.2 to call this instead with the\n * correct arguments.\n *\n * The routine isn't general - the channel must be the channel at the start or\n * end (not in the middle) of each pixel.\n */\nvoid /* PRIVATE */\npng_do_strip_channel(png_row_infop row_info, png_bytep row, int at_start)\n{\n   png_bytep sp = row; /* source pointer */\n   png_bytep dp = row; /* destination pointer */\n   png_bytep ep = row + row_info->rowbytes; /* One beyond end of row */\n\n   /* At the start sp will point to the first byte to copy and dp to where\n    * it is copied to.  ep always points just beyond the end of the row, so\n    * the loop simply copies (channels-1) channels until sp reaches ep.\n    *\n    * at_start:        0 -- convert AG, XG, ARGB, XRGB, AAGG, XXGG, etc.\n    *            nonzero -- convert GA, GX, RGBA, RGBX, GGAA, RRGGBBXX, etc.\n    */\n\n   /* GA, GX, XG cases */\n   if (row_info->channels == 2)\n   {\n      if (row_info->bit_depth == 8)\n      {\n         if (at_start) /* Skip initial filler */\n            ++sp;\n         else          /* Skip initial channel and, for sp, the filler */\n            sp += 2, ++dp;\n\n         /* For a 1 pixel wide image there is nothing to do */\n         while (sp < ep)\n            *dp++ = *sp, sp += 2;\n\n         row_info->pixel_depth = 8;\n      }\n\n      else if (row_info->bit_depth == 16)\n      {\n         if (at_start) /* Skip initial filler */\n            sp += 2;\n         else          /* Skip initial channel and, for sp, the filler */\n            sp += 4, dp += 2;\n\n         while (sp < ep)\n            *dp++ = *sp++, *dp++ = *sp, sp += 3;\n\n         row_info->pixel_depth = 16;\n      }\n\n      else\n         return; /* bad bit depth */\n\n      row_info->channels = 1;\n\n      /* Finally fix the color type if it records an alpha channel */\n      if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)\n         row_info->color_type = PNG_COLOR_TYPE_GRAY;\n   }\n\n   /* RGBA, RGBX, XRGB cases */\n   else if (row_info->channels == 4)\n   {\n      if (row_info->bit_depth == 8)\n      {\n         if (at_start) /* Skip initial filler */\n            ++sp;\n         else          /* Skip initial channels and, for sp, the filler */\n            sp += 4, dp += 3;\n\n         /* Note that the loop adds 3 to dp and 4 to sp each time. */\n         while (sp < ep)\n            *dp++ = *sp++, *dp++ = *sp++, *dp++ = *sp, sp += 2;\n\n         row_info->pixel_depth = 24;\n      }\n\n      else if (row_info->bit_depth == 16)\n      {\n         if (at_start) /* Skip initial filler */\n            sp += 2;\n         else          /* Skip initial channels and, for sp, the filler */\n            sp += 8, dp += 6;\n\n         while (sp < ep)\n         {\n            /* Copy 6 bytes, skip 2 */\n            *dp++ = *sp++, *dp++ = *sp++;\n            *dp++ = *sp++, *dp++ = *sp++;\n            *dp++ = *sp++, *dp++ = *sp, sp += 3;\n         }\n\n         row_info->pixel_depth = 48;\n      }\n\n      else\n         return; /* bad bit depth */\n\n      row_info->channels = 3;\n\n      /* Finally fix the color type if it records an alpha channel */\n      if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)\n         row_info->color_type = PNG_COLOR_TYPE_RGB;\n   }\n\n   else\n      return; /* The filler channel has gone already */\n\n   /* Fix the rowbytes value. */\n   row_info->rowbytes = dp-row;\n}\n#endif\n\n#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED)\n/* Swaps red and blue bytes within a pixel */\nvoid /* PRIVATE */\npng_do_bgr(png_row_infop row_info, png_bytep row)\n{\n   png_debug(1, \"in png_do_bgr\");\n\n   if ((row_info->color_type & PNG_COLOR_MASK_COLOR))\n   {\n      png_uint_32 row_width = row_info->width;\n      if (row_info->bit_depth == 8)\n      {\n         if (row_info->color_type == PNG_COLOR_TYPE_RGB)\n         {\n            png_bytep rp;\n            png_uint_32 i;\n\n            for (i = 0, rp = row; i < row_width; i++, rp += 3)\n            {\n               png_byte save = *rp;\n               *rp = *(rp + 2);\n               *(rp + 2) = save;\n            }\n         }\n\n         else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)\n         {\n            png_bytep rp;\n            png_uint_32 i;\n\n            for (i = 0, rp = row; i < row_width; i++, rp += 4)\n            {\n               png_byte save = *rp;\n               *rp = *(rp + 2);\n               *(rp + 2) = save;\n            }\n         }\n      }\n\n#ifdef PNG_16BIT_SUPPORTED\n      else if (row_info->bit_depth == 16)\n      {\n         if (row_info->color_type == PNG_COLOR_TYPE_RGB)\n         {\n            png_bytep rp;\n            png_uint_32 i;\n\n            for (i = 0, rp = row; i < row_width; i++, rp += 6)\n            {\n               png_byte save = *rp;\n               *rp = *(rp + 4);\n               *(rp + 4) = save;\n               save = *(rp + 1);\n               *(rp + 1) = *(rp + 5);\n               *(rp + 5) = save;\n            }\n         }\n\n         else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)\n         {\n            png_bytep rp;\n            png_uint_32 i;\n\n            for (i = 0, rp = row; i < row_width; i++, rp += 8)\n            {\n               png_byte save = *rp;\n               *rp = *(rp + 4);\n               *(rp + 4) = save;\n               save = *(rp + 1);\n               *(rp + 1) = *(rp + 5);\n               *(rp + 5) = save;\n            }\n         }\n      }\n#endif\n   }\n}\n#endif /* PNG_READ_BGR_SUPPORTED or PNG_WRITE_BGR_SUPPORTED */\n\n#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \\\n    defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)\n#ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED\nvoid PNGAPI\npng_set_user_transform_info(png_structp png_ptr, png_voidp\n   user_transform_ptr, int user_transform_depth, int user_transform_channels)\n{\n   png_debug(1, \"in png_set_user_transform_info\");\n\n   if (png_ptr == NULL)\n      return;\n   png_ptr->user_transform_ptr = user_transform_ptr;\n   png_ptr->user_transform_depth = (png_byte)user_transform_depth;\n   png_ptr->user_transform_channels = (png_byte)user_transform_channels;\n}\n#endif\n\n/* This function returns a pointer to the user_transform_ptr associated with\n * the user transform functions.  The application should free any memory\n * associated with this pointer before png_write_destroy and png_read_destroy\n * are called.\n */\n#ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED\npng_voidp PNGAPI\npng_get_user_transform_ptr(png_const_structp png_ptr)\n{\n   if (png_ptr == NULL)\n      return (NULL);\n\n   return ((png_voidp)png_ptr->user_transform_ptr);\n}\n#endif\n\n#ifdef PNG_USER_TRANSFORM_INFO_SUPPORTED\npng_uint_32 PNGAPI\npng_get_current_row_number(png_const_structp png_ptr)\n{\n   /* See the comments in png.h - this is the sub-image row when reading and\n    * interlaced image.\n    */\n   if (png_ptr != NULL)\n      return png_ptr->row_number;\n\n   return PNG_UINT_32_MAX; /* help the app not to fail silently */\n}\n\npng_byte PNGAPI\npng_get_current_pass_number(png_const_structp png_ptr)\n{\n   if (png_ptr != NULL)\n      return png_ptr->pass;\n   return 8; /* invalid */\n}\n#endif /* PNG_USER_TRANSFORM_INFO_SUPPORTED */\n#endif /* PNG_READ_USER_TRANSFORM_SUPPORTED ||\n          PNG_WRITE_USER_TRANSFORM_SUPPORTED */\n#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */\n"
  },
  {
    "path": "Projects/Tools/PNGAlphaPremultiplier/Native/Source/LibPng/pngwio.c",
    "content": "\n/* pngwio.c - functions for data output\n *\n * Last changed in libpng 1.5.0 [January 6, 2011]\n * Copyright (c) 1998-2011 Glenn Randers-Pehrson\n * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)\n * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)\n *\n * This code is released under the libpng license.\n * For conditions of distribution and use, see the disclaimer\n * and license in png.h\n *\n * This file provides a location for all output.  Users who need\n * special handling are expected to write functions that have the same\n * arguments as these and perform similar functions, but that possibly\n * use different output methods.  Note that you shouldn't change these\n * functions, but rather write replacement functions and then change\n * them at run time with png_set_write_fn(...).\n */\n\n#include \"pngpriv.h\"\n\n#ifdef PNG_WRITE_SUPPORTED\n\n/* Write the data to whatever output you are using.  The default routine\n * writes to a file pointer.  Note that this routine sometimes gets called\n * with very small lengths, so you should implement some kind of simple\n * buffering if you are using unbuffered writes.  This should never be asked\n * to write more than 64K on a 16 bit machine.\n */\n\nvoid /* PRIVATE */\npng_write_data(png_structp png_ptr, png_const_bytep data, png_size_t length)\n{\n   /* NOTE: write_data_fn must not change the buffer! */\n   if (png_ptr->write_data_fn != NULL )\n      (*(png_ptr->write_data_fn))(png_ptr, (png_bytep)data, length);\n\n   else\n      png_error(png_ptr, \"Call to NULL write function\");\n}\n\n#ifdef PNG_STDIO_SUPPORTED\n/* This is the function that does the actual writing of data.  If you are\n * not writing to a standard C stream, you should create a replacement\n * write_data function and use it at run time with png_set_write_fn(), rather\n * than changing the library.\n */\n#ifndef USE_FAR_KEYWORD\nvoid PNGCBAPI\npng_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length)\n{\n   png_size_t check;\n\n   if (png_ptr == NULL)\n      return;\n\n   check = fwrite(data, 1, length, (png_FILE_p)(png_ptr->io_ptr));\n\n   if (check != length)\n      png_error(png_ptr, \"Write Error\");\n}\n#else\n/* This is the model-independent version. Since the standard I/O library\n * can't handle far buffers in the medium and small models, we have to copy\n * the data.\n */\n\n#define NEAR_BUF_SIZE 1024\n#define MIN(a,b) (a <= b ? a : b)\n\nvoid PNGCBAPI\npng_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length)\n{\n   png_uint_32 check;\n   png_byte *near_data;  /* Needs to be \"png_byte *\" instead of \"png_bytep\" */\n   png_FILE_p io_ptr;\n\n   if (png_ptr == NULL)\n      return;\n\n   /* Check if data really is near. If so, use usual code. */\n   near_data = (png_byte *)CVT_PTR_NOCHECK(data);\n   io_ptr = (png_FILE_p)CVT_PTR(png_ptr->io_ptr);\n\n   if ((png_bytep)near_data == data)\n   {\n      check = fwrite(near_data, 1, length, io_ptr);\n   }\n\n   else\n   {\n      png_byte buf[NEAR_BUF_SIZE];\n      png_size_t written, remaining, err;\n      check = 0;\n      remaining = length;\n\n      do\n      {\n         written = MIN(NEAR_BUF_SIZE, remaining);\n         png_memcpy(buf, data, written); /* Copy far buffer to near buffer */\n         err = fwrite(buf, 1, written, io_ptr);\n\n         if (err != written)\n            break;\n\n         else\n            check += err;\n\n         data += written;\n         remaining -= written;\n      }\n      while (remaining != 0);\n   }\n\n   if (check != length)\n      png_error(png_ptr, \"Write Error\");\n}\n\n#endif\n#endif\n\n/* This function is called to output any data pending writing (normally\n * to disk).  After png_flush is called, there should be no data pending\n * writing in any buffers.\n */\n#ifdef PNG_WRITE_FLUSH_SUPPORTED\nvoid /* PRIVATE */\npng_flush(png_structp png_ptr)\n{\n   if (png_ptr->output_flush_fn != NULL)\n      (*(png_ptr->output_flush_fn))(png_ptr);\n}\n\n#  ifdef PNG_STDIO_SUPPORTED\nvoid PNGCBAPI\npng_default_flush(png_structp png_ptr)\n{\n   png_FILE_p io_ptr;\n\n   if (png_ptr == NULL)\n      return;\n\n   io_ptr = (png_FILE_p)CVT_PTR((png_ptr->io_ptr));\n   fflush(io_ptr);\n}\n#  endif\n#endif\n\n/* This function allows the application to supply new output functions for\n * libpng if standard C streams aren't being used.\n *\n * This function takes as its arguments:\n * png_ptr       - pointer to a png output data structure\n * io_ptr        - pointer to user supplied structure containing info about\n *                 the output functions.  May be NULL.\n * write_data_fn - pointer to a new output function that takes as its\n *                 arguments a pointer to a png_struct, a pointer to\n *                 data to be written, and a 32-bit unsigned int that is\n *                 the number of bytes to be written.  The new write\n *                 function should call png_error(png_ptr, \"Error msg\")\n *                 to exit and output any fatal error messages.  May be\n *                 NULL, in which case libpng's default function will\n *                 be used.\n * flush_data_fn - pointer to a new flush function that takes as its\n *                 arguments a pointer to a png_struct.  After a call to\n *                 the flush function, there should be no data in any buffers\n *                 or pending transmission.  If the output method doesn't do\n *                 any buffering of output, a function prototype must still be\n *                 supplied although it doesn't have to do anything.  If\n *                 PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng compile\n *                 time, output_flush_fn will be ignored, although it must be\n *                 supplied for compatibility.  May be NULL, in which case\n *                 libpng's default function will be used, if\n *                 PNG_WRITE_FLUSH_SUPPORTED is defined.  This is not\n *                 a good idea if io_ptr does not point to a standard\n *                 *FILE structure.\n */\nvoid PNGAPI\npng_set_write_fn(png_structp png_ptr, png_voidp io_ptr,\n    png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn)\n{\n   if (png_ptr == NULL)\n      return;\n\n   png_ptr->io_ptr = io_ptr;\n\n#ifdef PNG_STDIO_SUPPORTED\n   if (write_data_fn != NULL)\n      png_ptr->write_data_fn = write_data_fn;\n\n   else\n      png_ptr->write_data_fn = png_default_write_data;\n#else\n   png_ptr->write_data_fn = write_data_fn;\n#endif\n\n#ifdef PNG_WRITE_FLUSH_SUPPORTED\n#  ifdef PNG_STDIO_SUPPORTED\n\n   if (output_flush_fn != NULL)\n      png_ptr->output_flush_fn = output_flush_fn;\n\n   else\n      png_ptr->output_flush_fn = png_default_flush;\n\n#  else\n   png_ptr->output_flush_fn = output_flush_fn;\n#  endif\n#endif /* PNG_WRITE_FLUSH_SUPPORTED */\n\n   /* It is an error to read while writing a png file */\n   if (png_ptr->read_data_fn != NULL)\n   {\n      png_ptr->read_data_fn = NULL;\n\n      png_warning(png_ptr,\n          \"Can't set both read_data_fn and write_data_fn in the\"\n          \" same structure\");\n   }\n}\n\n#ifdef USE_FAR_KEYWORD\n#  ifdef _MSC_VER\nvoid *png_far_to_near(png_structp png_ptr, png_voidp ptr, int check)\n{\n   void *near_ptr;\n   void FAR *far_ptr;\n   FP_OFF(near_ptr) = FP_OFF(ptr);\n   far_ptr = (void FAR *)near_ptr;\n\n   if (check != 0)\n      if (FP_SEG(ptr) != FP_SEG(far_ptr))\n         png_error(png_ptr, \"segment lost in conversion\");\n\n   return(near_ptr);\n}\n#  else\nvoid *png_far_to_near(png_structp png_ptr, png_voidp ptr, int check)\n{\n   void *near_ptr;\n   void FAR *far_ptr;\n   near_ptr = (void FAR *)ptr;\n   far_ptr = (void FAR *)near_ptr;\n\n   if (check != 0)\n      if (far_ptr != ptr)\n         png_error(png_ptr, \"segment lost in conversion\");\n\n   return(near_ptr);\n}\n#  endif\n#endif\n#endif /* PNG_WRITE_SUPPORTED */\n"
  },
  {
    "path": "Projects/Tools/PNGAlphaPremultiplier/Native/Source/LibPng/pngwrite.c",
    "content": "\n/* pngwrite.c - general routines to write a PNG file\n *\n * Last changed in libpng 1.5.7 [December 15, 2011]\n * Copyright (c) 1998-2011 Glenn Randers-Pehrson\n * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)\n * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)\n *\n * This code is released under the libpng license.\n * For conditions of distribution and use, see the disclaimer\n * and license in png.h\n */\n\n#include \"pngpriv.h\"\n\n#ifdef PNG_WRITE_SUPPORTED\n\n/* Writes all the PNG information.  This is the suggested way to use the\n * library.  If you have a new chunk to add, make a function to write it,\n * and put it in the correct location here.  If you want the chunk written\n * after the image data, put it in png_write_end().  I strongly encourage\n * you to supply a PNG_INFO_ flag, and check info_ptr->valid before writing\n * the chunk, as that will keep the code from breaking if you want to just\n * write a plain PNG file.  If you have long comments, I suggest writing\n * them in png_write_end(), and compressing them.\n */\nvoid PNGAPI\npng_write_info_before_PLTE(png_structp png_ptr, png_infop info_ptr)\n{\n   png_debug(1, \"in png_write_info_before_PLTE\");\n\n   if (png_ptr == NULL || info_ptr == NULL)\n      return;\n\n   if (!(png_ptr->mode & PNG_WROTE_INFO_BEFORE_PLTE))\n   {\n   /* Write PNG signature */\n   png_write_sig(png_ptr);\n\n#ifdef PNG_MNG_FEATURES_SUPPORTED\n   if ((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE) && \\\n       (png_ptr->mng_features_permitted))\n   {\n      png_warning(png_ptr, \"MNG features are not allowed in a PNG datastream\");\n      png_ptr->mng_features_permitted = 0;\n   }\n#endif\n\n   /* Write IHDR information. */\n   png_write_IHDR(png_ptr, info_ptr->width, info_ptr->height,\n       info_ptr->bit_depth, info_ptr->color_type, info_ptr->compression_type,\n       info_ptr->filter_type,\n#ifdef PNG_WRITE_INTERLACING_SUPPORTED\n       info_ptr->interlace_type);\n#else\n       0);\n#endif\n   /* The rest of these check to see if the valid field has the appropriate\n    * flag set, and if it does, writes the chunk.\n    */\n#ifdef PNG_WRITE_gAMA_SUPPORTED\n   if (info_ptr->valid & PNG_INFO_gAMA)\n      png_write_gAMA_fixed(png_ptr, info_ptr->gamma);\n#endif\n#ifdef PNG_WRITE_sRGB_SUPPORTED\n   if (info_ptr->valid & PNG_INFO_sRGB)\n      png_write_sRGB(png_ptr, (int)info_ptr->srgb_intent);\n#endif\n\n#ifdef PNG_WRITE_iCCP_SUPPORTED\n   if (info_ptr->valid & PNG_INFO_iCCP)\n      png_write_iCCP(png_ptr, info_ptr->iccp_name, PNG_COMPRESSION_TYPE_BASE,\n          (png_charp)info_ptr->iccp_profile, (int)info_ptr->iccp_proflen);\n#endif\n#ifdef PNG_WRITE_sBIT_SUPPORTED\n   if (info_ptr->valid & PNG_INFO_sBIT)\n      png_write_sBIT(png_ptr, &(info_ptr->sig_bit), info_ptr->color_type);\n#endif\n#ifdef PNG_WRITE_cHRM_SUPPORTED\n   if (info_ptr->valid & PNG_INFO_cHRM)\n      png_write_cHRM_fixed(png_ptr,\n          info_ptr->x_white, info_ptr->y_white,\n          info_ptr->x_red, info_ptr->y_red,\n          info_ptr->x_green, info_ptr->y_green,\n          info_ptr->x_blue, info_ptr->y_blue);\n#endif\n\n#ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED\n   if (info_ptr->unknown_chunks_num)\n   {\n      png_unknown_chunk *up;\n\n      png_debug(5, \"writing extra chunks\");\n\n      for (up = info_ptr->unknown_chunks;\n           up < info_ptr->unknown_chunks + info_ptr->unknown_chunks_num;\n           up++)\n      {\n         int keep = png_handle_as_unknown(png_ptr, up->name);\n\n         if (keep != PNG_HANDLE_CHUNK_NEVER &&\n             up->location &&\n             !(up->location & PNG_HAVE_PLTE) &&\n             !(up->location & PNG_HAVE_IDAT) &&\n             !(up->location & PNG_AFTER_IDAT) &&\n             ((up->name[3] & 0x20) || keep == PNG_HANDLE_CHUNK_ALWAYS ||\n             (png_ptr->flags & PNG_FLAG_KEEP_UNSAFE_CHUNKS)))\n         {\n            if (up->size == 0)\n               png_warning(png_ptr, \"Writing zero-length unknown chunk\");\n\n            png_write_chunk(png_ptr, up->name, up->data, up->size);\n         }\n      }\n   }\n#endif\n      png_ptr->mode |= PNG_WROTE_INFO_BEFORE_PLTE;\n   }\n}\n\nvoid PNGAPI\npng_write_info(png_structp png_ptr, png_infop info_ptr)\n{\n#if defined(PNG_WRITE_TEXT_SUPPORTED) || defined(PNG_WRITE_sPLT_SUPPORTED)\n   int i;\n#endif\n\n   png_debug(1, \"in png_write_info\");\n\n   if (png_ptr == NULL || info_ptr == NULL)\n      return;\n\n   png_write_info_before_PLTE(png_ptr, info_ptr);\n\n   if (info_ptr->valid & PNG_INFO_PLTE)\n      png_write_PLTE(png_ptr, info_ptr->palette,\n          (png_uint_32)info_ptr->num_palette);\n\n   else if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)\n      png_error(png_ptr, \"Valid palette required for paletted images\");\n\n#ifdef PNG_WRITE_tRNS_SUPPORTED\n   if (info_ptr->valid & PNG_INFO_tRNS)\n   {\n#ifdef PNG_WRITE_INVERT_ALPHA_SUPPORTED\n      /* Invert the alpha channel (in tRNS) */\n      if ((png_ptr->transformations & PNG_INVERT_ALPHA) &&\n          info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)\n      {\n         int j;\n         for (j = 0; j<(int)info_ptr->num_trans; j++)\n            info_ptr->trans_alpha[j] =\n               (png_byte)(255 - info_ptr->trans_alpha[j]);\n      }\n#endif\n      png_write_tRNS(png_ptr, info_ptr->trans_alpha, &(info_ptr->trans_color),\n          info_ptr->num_trans, info_ptr->color_type);\n   }\n#endif\n#ifdef PNG_WRITE_bKGD_SUPPORTED\n   if (info_ptr->valid & PNG_INFO_bKGD)\n      png_write_bKGD(png_ptr, &(info_ptr->background), info_ptr->color_type);\n#endif\n\n#ifdef PNG_WRITE_hIST_SUPPORTED\n   if (info_ptr->valid & PNG_INFO_hIST)\n      png_write_hIST(png_ptr, info_ptr->hist, info_ptr->num_palette);\n#endif\n\n#ifdef PNG_WRITE_oFFs_SUPPORTED\n   if (info_ptr->valid & PNG_INFO_oFFs)\n      png_write_oFFs(png_ptr, info_ptr->x_offset, info_ptr->y_offset,\n          info_ptr->offset_unit_type);\n#endif\n\n#ifdef PNG_WRITE_pCAL_SUPPORTED\n   if (info_ptr->valid & PNG_INFO_pCAL)\n      png_write_pCAL(png_ptr, info_ptr->pcal_purpose, info_ptr->pcal_X0,\n          info_ptr->pcal_X1, info_ptr->pcal_type, info_ptr->pcal_nparams,\n          info_ptr->pcal_units, info_ptr->pcal_params);\n#endif\n\n#ifdef PNG_WRITE_sCAL_SUPPORTED\n   if (info_ptr->valid & PNG_INFO_sCAL)\n      png_write_sCAL_s(png_ptr, (int)info_ptr->scal_unit,\n          info_ptr->scal_s_width, info_ptr->scal_s_height);\n#endif /* sCAL */\n\n#ifdef PNG_WRITE_pHYs_SUPPORTED\n   if (info_ptr->valid & PNG_INFO_pHYs)\n      png_write_pHYs(png_ptr, info_ptr->x_pixels_per_unit,\n          info_ptr->y_pixels_per_unit, info_ptr->phys_unit_type);\n#endif /* pHYs */\n\n#ifdef PNG_WRITE_tIME_SUPPORTED\n   if (info_ptr->valid & PNG_INFO_tIME)\n   {\n      png_write_tIME(png_ptr, &(info_ptr->mod_time));\n      png_ptr->mode |= PNG_WROTE_tIME;\n   }\n#endif /* tIME */\n\n#ifdef PNG_WRITE_sPLT_SUPPORTED\n   if (info_ptr->valid & PNG_INFO_sPLT)\n      for (i = 0; i < (int)info_ptr->splt_palettes_num; i++)\n         png_write_sPLT(png_ptr, info_ptr->splt_palettes + i);\n#endif /* sPLT */\n\n#ifdef PNG_WRITE_TEXT_SUPPORTED\n   /* Check to see if we need to write text chunks */\n   for (i = 0; i < info_ptr->num_text; i++)\n   {\n      png_debug2(2, \"Writing header text chunk %d, type %d\", i,\n          info_ptr->text[i].compression);\n      /* An internationalized chunk? */\n      if (info_ptr->text[i].compression > 0)\n      {\n#ifdef PNG_WRITE_iTXt_SUPPORTED\n         /* Write international chunk */\n         png_write_iTXt(png_ptr,\n             info_ptr->text[i].compression,\n             info_ptr->text[i].key,\n             info_ptr->text[i].lang,\n             info_ptr->text[i].lang_key,\n             info_ptr->text[i].text);\n#else\n          png_warning(png_ptr, \"Unable to write international text\");\n#endif\n          /* Mark this chunk as written */\n          info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_NONE_WR;\n      }\n\n      /* If we want a compressed text chunk */\n      else if (info_ptr->text[i].compression == PNG_TEXT_COMPRESSION_zTXt)\n      {\n#ifdef PNG_WRITE_zTXt_SUPPORTED\n         /* Write compressed chunk */\n         png_write_zTXt(png_ptr, info_ptr->text[i].key,\n             info_ptr->text[i].text, 0,\n             info_ptr->text[i].compression);\n#else\n         png_warning(png_ptr, \"Unable to write compressed text\");\n#endif\n         /* Mark this chunk as written */\n         info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_zTXt_WR;\n      }\n\n      else if (info_ptr->text[i].compression == PNG_TEXT_COMPRESSION_NONE)\n      {\n#ifdef PNG_WRITE_tEXt_SUPPORTED\n         /* Write uncompressed chunk */\n         png_write_tEXt(png_ptr, info_ptr->text[i].key,\n             info_ptr->text[i].text,\n             0);\n         /* Mark this chunk as written */\n         info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_NONE_WR;\n#else\n         /* Can't get here */\n         png_warning(png_ptr, \"Unable to write uncompressed text\");\n#endif\n      }\n   }\n#endif /* tEXt */\n\n#ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED\n   if (info_ptr->unknown_chunks_num)\n   {\n      png_unknown_chunk *up;\n\n      png_debug(5, \"writing extra chunks\");\n\n      for (up = info_ptr->unknown_chunks;\n           up < info_ptr->unknown_chunks + info_ptr->unknown_chunks_num;\n           up++)\n      {\n         int keep = png_handle_as_unknown(png_ptr, up->name);\n         if (keep != PNG_HANDLE_CHUNK_NEVER &&\n             up->location &&\n             (up->location & PNG_HAVE_PLTE) &&\n             !(up->location & PNG_HAVE_IDAT) &&\n             !(up->location & PNG_AFTER_IDAT) &&\n             ((up->name[3] & 0x20) || keep == PNG_HANDLE_CHUNK_ALWAYS ||\n             (png_ptr->flags & PNG_FLAG_KEEP_UNSAFE_CHUNKS)))\n         {\n            png_write_chunk(png_ptr, up->name, up->data, up->size);\n         }\n      }\n   }\n#endif\n}\n\n/* Writes the end of the PNG file.  If you don't want to write comments or\n * time information, you can pass NULL for info.  If you already wrote these\n * in png_write_info(), do not write them again here.  If you have long\n * comments, I suggest writing them here, and compressing them.\n */\nvoid PNGAPI\npng_write_end(png_structp png_ptr, png_infop info_ptr)\n{\n   png_debug(1, \"in png_write_end\");\n\n   if (png_ptr == NULL)\n      return;\n\n   if (!(png_ptr->mode & PNG_HAVE_IDAT))\n      png_error(png_ptr, \"No IDATs written into file\");\n\n   /* See if user wants us to write information chunks */\n   if (info_ptr != NULL)\n   {\n#ifdef PNG_WRITE_TEXT_SUPPORTED\n      int i; /* local index variable */\n#endif\n#ifdef PNG_WRITE_tIME_SUPPORTED\n      /* Check to see if user has supplied a time chunk */\n      if ((info_ptr->valid & PNG_INFO_tIME) &&\n          !(png_ptr->mode & PNG_WROTE_tIME))\n         png_write_tIME(png_ptr, &(info_ptr->mod_time));\n\n#endif\n#ifdef PNG_WRITE_TEXT_SUPPORTED\n      /* Loop through comment chunks */\n      for (i = 0; i < info_ptr->num_text; i++)\n      {\n         png_debug2(2, \"Writing trailer text chunk %d, type %d\", i,\n            info_ptr->text[i].compression);\n         /* An internationalized chunk? */\n         if (info_ptr->text[i].compression > 0)\n         {\n#ifdef PNG_WRITE_iTXt_SUPPORTED\n            /* Write international chunk */\n            png_write_iTXt(png_ptr,\n                info_ptr->text[i].compression,\n                info_ptr->text[i].key,\n                info_ptr->text[i].lang,\n                info_ptr->text[i].lang_key,\n                info_ptr->text[i].text);\n#else\n            png_warning(png_ptr, \"Unable to write international text\");\n#endif\n            /* Mark this chunk as written */\n            info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_NONE_WR;\n         }\n\n         else if (info_ptr->text[i].compression >= PNG_TEXT_COMPRESSION_zTXt)\n         {\n#ifdef PNG_WRITE_zTXt_SUPPORTED\n            /* Write compressed chunk */\n            png_write_zTXt(png_ptr, info_ptr->text[i].key,\n                info_ptr->text[i].text, 0,\n                info_ptr->text[i].compression);\n#else\n            png_warning(png_ptr, \"Unable to write compressed text\");\n#endif\n            /* Mark this chunk as written */\n            info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_zTXt_WR;\n         }\n\n         else if (info_ptr->text[i].compression == PNG_TEXT_COMPRESSION_NONE)\n         {\n#ifdef PNG_WRITE_tEXt_SUPPORTED\n            /* Write uncompressed chunk */\n            png_write_tEXt(png_ptr, info_ptr->text[i].key,\n                info_ptr->text[i].text, 0);\n#else\n            png_warning(png_ptr, \"Unable to write uncompressed text\");\n#endif\n\n            /* Mark this chunk as written */\n            info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_NONE_WR;\n         }\n      }\n#endif\n#ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED\n   if (info_ptr->unknown_chunks_num)\n   {\n      png_unknown_chunk *up;\n\n      png_debug(5, \"writing extra chunks\");\n\n      for (up = info_ptr->unknown_chunks;\n           up < info_ptr->unknown_chunks + info_ptr->unknown_chunks_num;\n           up++)\n      {\n         int keep = png_handle_as_unknown(png_ptr, up->name);\n         if (keep != PNG_HANDLE_CHUNK_NEVER &&\n             up->location &&\n             (up->location & PNG_AFTER_IDAT) &&\n             ((up->name[3] & 0x20) || keep == PNG_HANDLE_CHUNK_ALWAYS ||\n             (png_ptr->flags & PNG_FLAG_KEEP_UNSAFE_CHUNKS)))\n         {\n            png_write_chunk(png_ptr, up->name, up->data, up->size);\n         }\n      }\n   }\n#endif\n   }\n\n   png_ptr->mode |= PNG_AFTER_IDAT;\n\n   /* Write end of PNG file */\n   png_write_IEND(png_ptr);\n   /* This flush, added in libpng-1.0.8, removed from libpng-1.0.9beta03,\n    * and restored again in libpng-1.2.30, may cause some applications that\n    * do not set png_ptr->output_flush_fn to crash.  If your application\n    * experiences a problem, please try building libpng with\n    * PNG_WRITE_FLUSH_AFTER_IEND_SUPPORTED defined, and report the event to\n    * png-mng-implement at lists.sf.net .\n    */\n#ifdef PNG_WRITE_FLUSH_SUPPORTED\n#  ifdef PNG_WRITE_FLUSH_AFTER_IEND_SUPPORTED\n   png_flush(png_ptr);\n#  endif\n#endif\n}\n\n#ifdef PNG_CONVERT_tIME_SUPPORTED\n/* \"tm\" structure is not supported on WindowsCE */\nvoid PNGAPI\npng_convert_from_struct_tm(png_timep ptime, PNG_CONST struct tm FAR * ttime)\n{\n   png_debug(1, \"in png_convert_from_struct_tm\");\n\n   ptime->year = (png_uint_16)(1900 + ttime->tm_year);\n   ptime->month = (png_byte)(ttime->tm_mon + 1);\n   ptime->day = (png_byte)ttime->tm_mday;\n   ptime->hour = (png_byte)ttime->tm_hour;\n   ptime->minute = (png_byte)ttime->tm_min;\n   ptime->second = (png_byte)ttime->tm_sec;\n}\n\nvoid PNGAPI\npng_convert_from_time_t(png_timep ptime, time_t ttime)\n{\n   struct tm *tbuf;\n\n   png_debug(1, \"in png_convert_from_time_t\");\n\n   tbuf = gmtime(&ttime);\n   png_convert_from_struct_tm(ptime, tbuf);\n}\n#endif\n\n/* Initialize png_ptr structure, and allocate any memory needed */\nPNG_FUNCTION(png_structp,PNGAPI\npng_create_write_struct,(png_const_charp user_png_ver, png_voidp error_ptr,\n    png_error_ptr error_fn, png_error_ptr warn_fn),PNG_ALLOCATED)\n{\n#ifdef PNG_USER_MEM_SUPPORTED\n   return (png_create_write_struct_2(user_png_ver, error_ptr, error_fn,\n       warn_fn, NULL, NULL, NULL));\n}\n\n/* Alternate initialize png_ptr structure, and allocate any memory needed */\nstatic void png_reset_filter_heuristics(png_structp png_ptr); /* forward decl */\n\nPNG_FUNCTION(png_structp,PNGAPI\npng_create_write_struct_2,(png_const_charp user_png_ver, png_voidp error_ptr,\n    png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr,\n    png_malloc_ptr malloc_fn, png_free_ptr free_fn),PNG_ALLOCATED)\n{\n#endif /* PNG_USER_MEM_SUPPORTED */\n   volatile int png_cleanup_needed = 0;\n#ifdef PNG_SETJMP_SUPPORTED\n   volatile\n#endif\n   png_structp png_ptr;\n#ifdef PNG_SETJMP_SUPPORTED\n#ifdef USE_FAR_KEYWORD\n   jmp_buf tmp_jmpbuf;\n#endif\n#endif\n\n   png_debug(1, \"in png_create_write_struct\");\n\n#ifdef PNG_USER_MEM_SUPPORTED\n   png_ptr = (png_structp)png_create_struct_2(PNG_STRUCT_PNG,\n       (png_malloc_ptr)malloc_fn, (png_voidp)mem_ptr);\n#else\n   png_ptr = (png_structp)png_create_struct(PNG_STRUCT_PNG);\n#endif /* PNG_USER_MEM_SUPPORTED */\n   if (png_ptr == NULL)\n      return (NULL);\n\n   /* Added at libpng-1.2.6 */\n#ifdef PNG_SET_USER_LIMITS_SUPPORTED\n   png_ptr->user_width_max = PNG_USER_WIDTH_MAX;\n   png_ptr->user_height_max = PNG_USER_HEIGHT_MAX;\n#endif\n\n#ifdef PNG_SETJMP_SUPPORTED\n/* Applications that neglect to set up their own setjmp() and then\n * encounter a png_error() will longjmp here.  Since the jmpbuf is\n * then meaningless we abort instead of returning.\n */\n#ifdef USE_FAR_KEYWORD\n   if (setjmp(tmp_jmpbuf))\n#else\n   if (setjmp(png_jmpbuf(png_ptr))) /* sets longjmp to match setjmp */\n#endif\n#ifdef USE_FAR_KEYWORD\n   png_memcpy(png_jmpbuf(png_ptr), tmp_jmpbuf, png_sizeof(jmp_buf));\n#endif\n      PNG_ABORT();\n#endif\n\n#ifdef PNG_USER_MEM_SUPPORTED\n   png_set_mem_fn(png_ptr, mem_ptr, malloc_fn, free_fn);\n#endif /* PNG_USER_MEM_SUPPORTED */\n   png_set_error_fn(png_ptr, error_ptr, error_fn, warn_fn);\n\n   if (!png_user_version_check(png_ptr, user_png_ver))\n      png_cleanup_needed = 1;\n\n   /* Initialize zbuf - compression buffer */\n   png_ptr->zbuf_size = PNG_ZBUF_SIZE;\n\n   if (!png_cleanup_needed)\n   {\n      png_ptr->zbuf = (png_bytep)png_malloc_warn(png_ptr,\n          png_ptr->zbuf_size);\n      if (png_ptr->zbuf == NULL)\n         png_cleanup_needed = 1;\n   }\n\n   if (png_cleanup_needed)\n   {\n       /* Clean up PNG structure and deallocate any memory. */\n       png_free(png_ptr, png_ptr->zbuf);\n       png_ptr->zbuf = NULL;\n#ifdef PNG_USER_MEM_SUPPORTED\n       png_destroy_struct_2((png_voidp)png_ptr,\n           (png_free_ptr)free_fn, (png_voidp)mem_ptr);\n#else\n       png_destroy_struct((png_voidp)png_ptr);\n#endif\n       return (NULL);\n   }\n\n   png_set_write_fn(png_ptr, NULL, NULL, NULL);\n\n#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED\n   png_reset_filter_heuristics(png_ptr);\n#endif\n\n   return (png_ptr);\n}\n\n\n/* Write a few rows of image data.  If the image is interlaced,\n * either you will have to write the 7 sub images, or, if you\n * have called png_set_interlace_handling(), you will have to\n * \"write\" the image seven times.\n */\nvoid PNGAPI\npng_write_rows(png_structp png_ptr, png_bytepp row,\n    png_uint_32 num_rows)\n{\n   png_uint_32 i; /* row counter */\n   png_bytepp rp; /* row pointer */\n\n   png_debug(1, \"in png_write_rows\");\n\n   if (png_ptr == NULL)\n      return;\n\n   /* Loop through the rows */\n   for (i = 0, rp = row; i < num_rows; i++, rp++)\n   {\n      png_write_row(png_ptr, *rp);\n   }\n}\n\n/* Write the image.  You only need to call this function once, even\n * if you are writing an interlaced image.\n */\nvoid PNGAPI\npng_write_image(png_structp png_ptr, png_bytepp image)\n{\n   png_uint_32 i; /* row index */\n   int pass, num_pass; /* pass variables */\n   png_bytepp rp; /* points to current row */\n\n   if (png_ptr == NULL)\n      return;\n\n   png_debug(1, \"in png_write_image\");\n\n#ifdef PNG_WRITE_INTERLACING_SUPPORTED\n   /* Initialize interlace handling.  If image is not interlaced,\n    * this will set pass to 1\n    */\n   num_pass = png_set_interlace_handling(png_ptr);\n#else\n   num_pass = 1;\n#endif\n   /* Loop through passes */\n   for (pass = 0; pass < num_pass; pass++)\n   {\n      /* Loop through image */\n      for (i = 0, rp = image; i < png_ptr->height; i++, rp++)\n      {\n         png_write_row(png_ptr, *rp);\n      }\n   }\n}\n\n/* Called by user to write a row of image data */\nvoid PNGAPI\npng_write_row(png_structp png_ptr, png_const_bytep row)\n{\n   /* 1.5.6: moved from png_struct to be a local structure: */\n   png_row_info row_info;\n\n   if (png_ptr == NULL)\n      return;\n\n   png_debug2(1, \"in png_write_row (row %u, pass %d)\",\n      png_ptr->row_number, png_ptr->pass);\n\n   /* Initialize transformations and other stuff if first time */\n   if (png_ptr->row_number == 0 && png_ptr->pass == 0)\n   {\n      /* Make sure we wrote the header info */\n      if (!(png_ptr->mode & PNG_WROTE_INFO_BEFORE_PLTE))\n         png_error(png_ptr,\n             \"png_write_info was never called before png_write_row\");\n\n      /* Check for transforms that have been set but were defined out */\n#if !defined(PNG_WRITE_INVERT_SUPPORTED) && defined(PNG_READ_INVERT_SUPPORTED)\n      if (png_ptr->transformations & PNG_INVERT_MONO)\n         png_warning(png_ptr, \"PNG_WRITE_INVERT_SUPPORTED is not defined\");\n#endif\n\n#if !defined(PNG_WRITE_FILLER_SUPPORTED) && defined(PNG_READ_FILLER_SUPPORTED)\n      if (png_ptr->transformations & PNG_FILLER)\n         png_warning(png_ptr, \"PNG_WRITE_FILLER_SUPPORTED is not defined\");\n#endif\n#if !defined(PNG_WRITE_PACKSWAP_SUPPORTED) && \\\n    defined(PNG_READ_PACKSWAP_SUPPORTED)\n      if (png_ptr->transformations & PNG_PACKSWAP)\n         png_warning(png_ptr,\n             \"PNG_WRITE_PACKSWAP_SUPPORTED is not defined\");\n#endif\n\n#if !defined(PNG_WRITE_PACK_SUPPORTED) && defined(PNG_READ_PACK_SUPPORTED)\n      if (png_ptr->transformations & PNG_PACK)\n         png_warning(png_ptr, \"PNG_WRITE_PACK_SUPPORTED is not defined\");\n#endif\n\n#if !defined(PNG_WRITE_SHIFT_SUPPORTED) && defined(PNG_READ_SHIFT_SUPPORTED)\n      if (png_ptr->transformations & PNG_SHIFT)\n         png_warning(png_ptr, \"PNG_WRITE_SHIFT_SUPPORTED is not defined\");\n#endif\n\n#if !defined(PNG_WRITE_BGR_SUPPORTED) && defined(PNG_READ_BGR_SUPPORTED)\n      if (png_ptr->transformations & PNG_BGR)\n         png_warning(png_ptr, \"PNG_WRITE_BGR_SUPPORTED is not defined\");\n#endif\n\n#if !defined(PNG_WRITE_SWAP_SUPPORTED) && defined(PNG_READ_SWAP_SUPPORTED)\n      if (png_ptr->transformations & PNG_SWAP_BYTES)\n         png_warning(png_ptr, \"PNG_WRITE_SWAP_SUPPORTED is not defined\");\n#endif\n\n      png_write_start_row(png_ptr);\n   }\n\n#ifdef PNG_WRITE_INTERLACING_SUPPORTED\n   /* If interlaced and not interested in row, return */\n   if (png_ptr->interlaced && (png_ptr->transformations & PNG_INTERLACE))\n   {\n      switch (png_ptr->pass)\n      {\n         case 0:\n            if (png_ptr->row_number & 0x07)\n            {\n               png_write_finish_row(png_ptr);\n               return;\n            }\n            break;\n\n         case 1:\n            if ((png_ptr->row_number & 0x07) || png_ptr->width < 5)\n            {\n               png_write_finish_row(png_ptr);\n               return;\n            }\n            break;\n\n         case 2:\n            if ((png_ptr->row_number & 0x07) != 4)\n            {\n               png_write_finish_row(png_ptr);\n               return;\n            }\n            break;\n\n         case 3:\n            if ((png_ptr->row_number & 0x03) || png_ptr->width < 3)\n            {\n               png_write_finish_row(png_ptr);\n               return;\n            }\n            break;\n\n         case 4:\n            if ((png_ptr->row_number & 0x03) != 2)\n            {\n               png_write_finish_row(png_ptr);\n               return;\n            }\n            break;\n\n         case 5:\n            if ((png_ptr->row_number & 0x01) || png_ptr->width < 2)\n            {\n               png_write_finish_row(png_ptr);\n               return;\n            }\n            break;\n\n         case 6:\n            if (!(png_ptr->row_number & 0x01))\n            {\n               png_write_finish_row(png_ptr);\n               return;\n            }\n            break;\n\n         default: /* error: ignore it */\n            break;\n      }\n   }\n#endif\n\n   /* Set up row info for transformations */\n   row_info.color_type = png_ptr->color_type;\n   row_info.width = png_ptr->usr_width;\n   row_info.channels = png_ptr->usr_channels;\n   row_info.bit_depth = png_ptr->usr_bit_depth;\n   row_info.pixel_depth = (png_byte)(row_info.bit_depth * row_info.channels);\n   row_info.rowbytes = PNG_ROWBYTES(row_info.pixel_depth, row_info.width);\n\n   png_debug1(3, \"row_info->color_type = %d\", row_info.color_type);\n   png_debug1(3, \"row_info->width = %u\", row_info.width);\n   png_debug1(3, \"row_info->channels = %d\", row_info.channels);\n   png_debug1(3, \"row_info->bit_depth = %d\", row_info.bit_depth);\n   png_debug1(3, \"row_info->pixel_depth = %d\", row_info.pixel_depth);\n   png_debug1(3, \"row_info->rowbytes = %lu\", (unsigned long)row_info.rowbytes);\n\n   /* Copy user's row into buffer, leaving room for filter byte. */\n   png_memcpy(png_ptr->row_buf + 1, row, row_info.rowbytes);\n\n#ifdef PNG_WRITE_INTERLACING_SUPPORTED\n   /* Handle interlacing */\n   if (png_ptr->interlaced && png_ptr->pass < 6 &&\n       (png_ptr->transformations & PNG_INTERLACE))\n   {\n      png_do_write_interlace(&row_info, png_ptr->row_buf + 1, png_ptr->pass);\n      /* This should always get caught above, but still ... */\n      if (!(row_info.width))\n      {\n         png_write_finish_row(png_ptr);\n         return;\n      }\n   }\n#endif\n\n#ifdef PNG_WRITE_TRANSFORMS_SUPPORTED\n   /* Handle other transformations */\n   if (png_ptr->transformations)\n      png_do_write_transformations(png_ptr, &row_info);\n#endif\n\n   /* At this point the row_info pixel depth must match the 'transformed' depth,\n    * which is also the output depth.\n    */\n   if (row_info.pixel_depth != png_ptr->pixel_depth ||\n      row_info.pixel_depth != png_ptr->transformed_pixel_depth)\n      png_error(png_ptr, \"internal write transform logic error\");\n\n#ifdef PNG_MNG_FEATURES_SUPPORTED\n   /* Write filter_method 64 (intrapixel differencing) only if\n    * 1. Libpng was compiled with PNG_MNG_FEATURES_SUPPORTED and\n    * 2. Libpng did not write a PNG signature (this filter_method is only\n    *    used in PNG datastreams that are embedded in MNG datastreams) and\n    * 3. The application called png_permit_mng_features with a mask that\n    *    included PNG_FLAG_MNG_FILTER_64 and\n    * 4. The filter_method is 64 and\n    * 5. The color_type is RGB or RGBA\n    */\n   if ((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) &&\n       (png_ptr->filter_type == PNG_INTRAPIXEL_DIFFERENCING))\n   {\n      /* Intrapixel differencing */\n      png_do_write_intrapixel(&row_info, png_ptr->row_buf + 1);\n   }\n#endif\n\n   /* Find a filter if necessary, filter the row and write it out. */\n   png_write_find_filter(png_ptr, &row_info);\n\n   if (png_ptr->write_row_fn != NULL)\n      (*(png_ptr->write_row_fn))(png_ptr, png_ptr->row_number, png_ptr->pass);\n}\n\n#ifdef PNG_WRITE_FLUSH_SUPPORTED\n/* Set the automatic flush interval or 0 to turn flushing off */\nvoid PNGAPI\npng_set_flush(png_structp png_ptr, int nrows)\n{\n   png_debug(1, \"in png_set_flush\");\n\n   if (png_ptr == NULL)\n      return;\n\n   png_ptr->flush_dist = (nrows < 0 ? 0 : nrows);\n}\n\n/* Flush the current output buffers now */\nvoid PNGAPI\npng_write_flush(png_structp png_ptr)\n{\n   int wrote_IDAT;\n\n   png_debug(1, \"in png_write_flush\");\n\n   if (png_ptr == NULL)\n      return;\n\n   /* We have already written out all of the data */\n   if (png_ptr->row_number >= png_ptr->num_rows)\n      return;\n\n   do\n   {\n      int ret;\n\n      /* Compress the data */\n      ret = deflate(&png_ptr->zstream, Z_SYNC_FLUSH);\n      wrote_IDAT = 0;\n\n      /* Check for compression errors */\n      if (ret != Z_OK)\n      {\n         if (png_ptr->zstream.msg != NULL)\n            png_error(png_ptr, png_ptr->zstream.msg);\n\n         else\n            png_error(png_ptr, \"zlib error\");\n      }\n\n      if (!(png_ptr->zstream.avail_out))\n      {\n         /* Write the IDAT and reset the zlib output buffer */\n         png_write_IDAT(png_ptr, png_ptr->zbuf, png_ptr->zbuf_size);\n         wrote_IDAT = 1;\n      }\n   } while (wrote_IDAT == 1);\n\n   /* If there is any data left to be output, write it into a new IDAT */\n   if (png_ptr->zbuf_size != png_ptr->zstream.avail_out)\n   {\n      /* Write the IDAT and reset the zlib output buffer */\n      png_write_IDAT(png_ptr, png_ptr->zbuf,\n          png_ptr->zbuf_size - png_ptr->zstream.avail_out);\n   }\n   png_ptr->flush_rows = 0;\n   png_flush(png_ptr);\n}\n#endif /* PNG_WRITE_FLUSH_SUPPORTED */\n\n/* Free all memory used by the write */\nvoid PNGAPI\npng_destroy_write_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr)\n{\n   png_structp png_ptr = NULL;\n   png_infop info_ptr = NULL;\n#ifdef PNG_USER_MEM_SUPPORTED\n   png_free_ptr free_fn = NULL;\n   png_voidp mem_ptr = NULL;\n#endif\n\n   png_debug(1, \"in png_destroy_write_struct\");\n\n   if (png_ptr_ptr != NULL)\n      png_ptr = *png_ptr_ptr;\n\n#ifdef PNG_USER_MEM_SUPPORTED\n   if (png_ptr != NULL)\n   {\n      free_fn = png_ptr->free_fn;\n      mem_ptr = png_ptr->mem_ptr;\n   }\n#endif\n\n   if (info_ptr_ptr != NULL)\n      info_ptr = *info_ptr_ptr;\n\n   if (info_ptr != NULL)\n   {\n      if (png_ptr != NULL)\n      {\n         png_free_data(png_ptr, info_ptr, PNG_FREE_ALL, -1);\n\n#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED\n         if (png_ptr->num_chunk_list)\n         {\n            png_free(png_ptr, png_ptr->chunk_list);\n            png_ptr->num_chunk_list = 0;\n         }\n#endif\n      }\n\n#ifdef PNG_USER_MEM_SUPPORTED\n      png_destroy_struct_2((png_voidp)info_ptr, (png_free_ptr)free_fn,\n          (png_voidp)mem_ptr);\n#else\n      png_destroy_struct((png_voidp)info_ptr);\n#endif\n      *info_ptr_ptr = NULL;\n   }\n\n   if (png_ptr != NULL)\n   {\n      png_write_destroy(png_ptr);\n#ifdef PNG_USER_MEM_SUPPORTED\n      png_destroy_struct_2((png_voidp)png_ptr, (png_free_ptr)free_fn,\n          (png_voidp)mem_ptr);\n#else\n      png_destroy_struct((png_voidp)png_ptr);\n#endif\n      *png_ptr_ptr = NULL;\n   }\n}\n\n\n/* Free any memory used in png_ptr struct (old method) */\nvoid /* PRIVATE */\npng_write_destroy(png_structp png_ptr)\n{\n#ifdef PNG_SETJMP_SUPPORTED\n   jmp_buf tmp_jmp; /* Save jump buffer */\n#endif\n   png_error_ptr error_fn;\n#ifdef PNG_WARNINGS_SUPPORTED\n   png_error_ptr warning_fn;\n#endif\n   png_voidp error_ptr;\n#ifdef PNG_USER_MEM_SUPPORTED\n   png_free_ptr free_fn;\n#endif\n\n   png_debug(1, \"in png_write_destroy\");\n\n   /* Free any memory zlib uses */\n   if (png_ptr->zlib_state != PNG_ZLIB_UNINITIALIZED)\n      deflateEnd(&png_ptr->zstream);\n\n   /* Free our memory.  png_free checks NULL for us. */\n   png_free(png_ptr, png_ptr->zbuf);\n   png_free(png_ptr, png_ptr->row_buf);\n#ifdef PNG_WRITE_FILTER_SUPPORTED\n   png_free(png_ptr, png_ptr->prev_row);\n   png_free(png_ptr, png_ptr->sub_row);\n   png_free(png_ptr, png_ptr->up_row);\n   png_free(png_ptr, png_ptr->avg_row);\n   png_free(png_ptr, png_ptr->paeth_row);\n#endif\n\n#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED\n   /* Use this to save a little code space, it doesn't free the filter_costs */\n   png_reset_filter_heuristics(png_ptr);\n   png_free(png_ptr, png_ptr->filter_costs);\n   png_free(png_ptr, png_ptr->inv_filter_costs);\n#endif\n\n#ifdef PNG_SETJMP_SUPPORTED\n   /* Reset structure */\n   png_memcpy(tmp_jmp, png_ptr->longjmp_buffer, png_sizeof(jmp_buf));\n#endif\n\n   error_fn = png_ptr->error_fn;\n#ifdef PNG_WARNINGS_SUPPORTED\n   warning_fn = png_ptr->warning_fn;\n#endif\n   error_ptr = png_ptr->error_ptr;\n#ifdef PNG_USER_MEM_SUPPORTED\n   free_fn = png_ptr->free_fn;\n#endif\n\n   png_memset(png_ptr, 0, png_sizeof(png_struct));\n\n   png_ptr->error_fn = error_fn;\n#ifdef PNG_WARNINGS_SUPPORTED\n   png_ptr->warning_fn = warning_fn;\n#endif\n   png_ptr->error_ptr = error_ptr;\n#ifdef PNG_USER_MEM_SUPPORTED\n   png_ptr->free_fn = free_fn;\n#endif\n\n#ifdef PNG_SETJMP_SUPPORTED\n   png_memcpy(png_ptr->longjmp_buffer, tmp_jmp, png_sizeof(jmp_buf));\n#endif\n}\n\n/* Allow the application to select one or more row filters to use. */\nvoid PNGAPI\npng_set_filter(png_structp png_ptr, int method, int filters)\n{\n   png_debug(1, \"in png_set_filter\");\n\n   if (png_ptr == NULL)\n      return;\n\n#ifdef PNG_MNG_FEATURES_SUPPORTED\n   if ((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) &&\n       (method == PNG_INTRAPIXEL_DIFFERENCING))\n      method = PNG_FILTER_TYPE_BASE;\n\n#endif\n   if (method == PNG_FILTER_TYPE_BASE)\n   {\n      switch (filters & (PNG_ALL_FILTERS | 0x07))\n      {\n#ifdef PNG_WRITE_FILTER_SUPPORTED\n         case 5:\n         case 6:\n         case 7: png_warning(png_ptr, \"Unknown row filter for method 0\");\n#endif /* PNG_WRITE_FILTER_SUPPORTED */\n         case PNG_FILTER_VALUE_NONE:\n            png_ptr->do_filter = PNG_FILTER_NONE; break;\n\n#ifdef PNG_WRITE_FILTER_SUPPORTED\n         case PNG_FILTER_VALUE_SUB:\n            png_ptr->do_filter = PNG_FILTER_SUB; break;\n\n         case PNG_FILTER_VALUE_UP:\n            png_ptr->do_filter = PNG_FILTER_UP; break;\n\n         case PNG_FILTER_VALUE_AVG:\n            png_ptr->do_filter = PNG_FILTER_AVG; break;\n\n         case PNG_FILTER_VALUE_PAETH:\n            png_ptr->do_filter = PNG_FILTER_PAETH; break;\n\n         default:\n            png_ptr->do_filter = (png_byte)filters; break;\n#else\n         default:\n            png_warning(png_ptr, \"Unknown row filter for method 0\");\n#endif /* PNG_WRITE_FILTER_SUPPORTED */\n      }\n\n      /* If we have allocated the row_buf, this means we have already started\n       * with the image and we should have allocated all of the filter buffers\n       * that have been selected.  If prev_row isn't already allocated, then\n       * it is too late to start using the filters that need it, since we\n       * will be missing the data in the previous row.  If an application\n       * wants to start and stop using particular filters during compression,\n       * it should start out with all of the filters, and then add and\n       * remove them after the start of compression.\n       */\n      if (png_ptr->row_buf != NULL)\n      {\n#ifdef PNG_WRITE_FILTER_SUPPORTED\n         if ((png_ptr->do_filter & PNG_FILTER_SUB) && png_ptr->sub_row == NULL)\n         {\n            png_ptr->sub_row = (png_bytep)png_malloc(png_ptr,\n                (png_ptr->rowbytes + 1));\n            png_ptr->sub_row[0] = PNG_FILTER_VALUE_SUB;\n         }\n\n         if ((png_ptr->do_filter & PNG_FILTER_UP) && png_ptr->up_row == NULL)\n         {\n            if (png_ptr->prev_row == NULL)\n            {\n               png_warning(png_ptr, \"Can't add Up filter after starting\");\n               png_ptr->do_filter = (png_byte)(png_ptr->do_filter &\n                   ~PNG_FILTER_UP);\n            }\n\n            else\n            {\n               png_ptr->up_row = (png_bytep)png_malloc(png_ptr,\n                   (png_ptr->rowbytes + 1));\n               png_ptr->up_row[0] = PNG_FILTER_VALUE_UP;\n            }\n         }\n\n         if ((png_ptr->do_filter & PNG_FILTER_AVG) && png_ptr->avg_row == NULL)\n         {\n            if (png_ptr->prev_row == NULL)\n            {\n               png_warning(png_ptr, \"Can't add Average filter after starting\");\n               png_ptr->do_filter = (png_byte)(png_ptr->do_filter &\n                   ~PNG_FILTER_AVG);\n            }\n\n            else\n            {\n               png_ptr->avg_row = (png_bytep)png_malloc(png_ptr,\n                   (png_ptr->rowbytes + 1));\n               png_ptr->avg_row[0] = PNG_FILTER_VALUE_AVG;\n            }\n         }\n\n         if ((png_ptr->do_filter & PNG_FILTER_PAETH) &&\n             png_ptr->paeth_row == NULL)\n         {\n            if (png_ptr->prev_row == NULL)\n            {\n               png_warning(png_ptr, \"Can't add Paeth filter after starting\");\n               png_ptr->do_filter &= (png_byte)(~PNG_FILTER_PAETH);\n            }\n\n            else\n            {\n               png_ptr->paeth_row = (png_bytep)png_malloc(png_ptr,\n                   (png_ptr->rowbytes + 1));\n               png_ptr->paeth_row[0] = PNG_FILTER_VALUE_PAETH;\n            }\n         }\n\n         if (png_ptr->do_filter == PNG_NO_FILTERS)\n#endif /* PNG_WRITE_FILTER_SUPPORTED */\n            png_ptr->do_filter = PNG_FILTER_NONE;\n      }\n   }\n   else\n      png_error(png_ptr, \"Unknown custom filter method\");\n}\n\n/* This allows us to influence the way in which libpng chooses the \"best\"\n * filter for the current scanline.  While the \"minimum-sum-of-absolute-\n * differences metric is relatively fast and effective, there is some\n * question as to whether it can be improved upon by trying to keep the\n * filtered data going to zlib more consistent, hopefully resulting in\n * better compression.\n */\n#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED      /* GRR 970116 */\n/* Convenience reset API. */\nstatic void\npng_reset_filter_heuristics(png_structp png_ptr)\n{\n   /* Clear out any old values in the 'weights' - this must be done because if\n    * the app calls set_filter_heuristics multiple times with different\n    * 'num_weights' values we would otherwise potentially have wrong sized\n    * arrays.\n    */\n   png_ptr->num_prev_filters = 0;\n   png_ptr->heuristic_method = PNG_FILTER_HEURISTIC_UNWEIGHTED;\n   if (png_ptr->prev_filters != NULL)\n   {\n      png_bytep old = png_ptr->prev_filters;\n      png_ptr->prev_filters = NULL;\n      png_free(png_ptr, old);\n   }\n   if (png_ptr->filter_weights != NULL)\n   {\n      png_uint_16p old = png_ptr->filter_weights;\n      png_ptr->filter_weights = NULL;\n      png_free(png_ptr, old);\n   }\n\n   if (png_ptr->inv_filter_weights != NULL)\n   {\n      png_uint_16p old = png_ptr->inv_filter_weights;\n      png_ptr->inv_filter_weights = NULL;\n      png_free(png_ptr, old);\n   }\n\n   /* Leave the filter_costs - this array is fixed size. */\n}\n\nstatic int\npng_init_filter_heuristics(png_structp png_ptr, int heuristic_method,\n   int num_weights)\n{\n   if (png_ptr == NULL)\n      return 0;\n\n   /* Clear out the arrays */\n   png_reset_filter_heuristics(png_ptr);\n\n   /* Check arguments; the 'reset' function makes the correct settings for the\n    * unweighted case, but we must handle the weight case by initializing the\n    * arrays for the caller.\n    */\n   if (heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED)\n   {\n      int i;\n\n      if (num_weights > 0)\n      {\n         png_ptr->prev_filters = (png_bytep)png_malloc(png_ptr,\n             (png_uint_32)(png_sizeof(png_byte) * num_weights));\n\n         /* To make sure that the weighting starts out fairly */\n         for (i = 0; i < num_weights; i++)\n         {\n            png_ptr->prev_filters[i] = 255;\n         }\n\n         png_ptr->filter_weights = (png_uint_16p)png_malloc(png_ptr,\n             (png_uint_32)(png_sizeof(png_uint_16) * num_weights));\n\n         png_ptr->inv_filter_weights = (png_uint_16p)png_malloc(png_ptr,\n             (png_uint_32)(png_sizeof(png_uint_16) * num_weights));\n\n         for (i = 0; i < num_weights; i++)\n         {\n            png_ptr->inv_filter_weights[i] =\n            png_ptr->filter_weights[i] = PNG_WEIGHT_FACTOR;\n         }\n\n         /* Safe to set this now */\n         png_ptr->num_prev_filters = (png_byte)num_weights;\n      }\n\n      /* If, in the future, there are other filter methods, this would\n       * need to be based on png_ptr->filter.\n       */\n      if (png_ptr->filter_costs == NULL)\n      {\n         png_ptr->filter_costs = (png_uint_16p)png_malloc(png_ptr,\n             (png_uint_32)(png_sizeof(png_uint_16) * PNG_FILTER_VALUE_LAST));\n\n         png_ptr->inv_filter_costs = (png_uint_16p)png_malloc(png_ptr,\n             (png_uint_32)(png_sizeof(png_uint_16) * PNG_FILTER_VALUE_LAST));\n      }\n\n      for (i = 0; i < PNG_FILTER_VALUE_LAST; i++)\n      {\n         png_ptr->inv_filter_costs[i] =\n         png_ptr->filter_costs[i] = PNG_COST_FACTOR;\n      }\n\n      /* All the arrays are inited, safe to set this: */\n      png_ptr->heuristic_method = PNG_FILTER_HEURISTIC_WEIGHTED;\n\n      /* Return the 'ok' code. */\n      return 1;\n   }\n   else if (heuristic_method == PNG_FILTER_HEURISTIC_DEFAULT ||\n      heuristic_method == PNG_FILTER_HEURISTIC_UNWEIGHTED)\n   {\n      return 1;\n   }\n   else\n   {\n      png_warning(png_ptr, \"Unknown filter heuristic method\");\n      return 0;\n   }\n}\n\n/* Provide floating and fixed point APIs */\n#ifdef PNG_FLOATING_POINT_SUPPORTED\nvoid PNGAPI\npng_set_filter_heuristics(png_structp png_ptr, int heuristic_method,\n    int num_weights, png_const_doublep filter_weights,\n    png_const_doublep filter_costs)\n{\n   png_debug(1, \"in png_set_filter_heuristics\");\n\n   /* The internal API allocates all the arrays and ensures that the elements of\n    * those arrays are set to the default value.\n    */\n   if (!png_init_filter_heuristics(png_ptr, heuristic_method, num_weights))\n      return;\n\n   /* If using the weighted method copy in the weights. */\n   if (heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED)\n   {\n      int i;\n      for (i = 0; i < num_weights; i++)\n      {\n         if (filter_weights[i] <= 0.0)\n         {\n            png_ptr->inv_filter_weights[i] =\n            png_ptr->filter_weights[i] = PNG_WEIGHT_FACTOR;\n         }\n\n         else\n         {\n            png_ptr->inv_filter_weights[i] =\n                (png_uint_16)(PNG_WEIGHT_FACTOR*filter_weights[i]+.5);\n\n            png_ptr->filter_weights[i] =\n                (png_uint_16)(PNG_WEIGHT_FACTOR/filter_weights[i]+.5);\n         }\n      }\n\n      /* Here is where we set the relative costs of the different filters.  We\n       * should take the desired compression level into account when setting\n       * the costs, so that Paeth, for instance, has a high relative cost at low\n       * compression levels, while it has a lower relative cost at higher\n       * compression settings.  The filter types are in order of increasing\n       * relative cost, so it would be possible to do this with an algorithm.\n       */\n      for (i = 0; i < PNG_FILTER_VALUE_LAST; i++) if (filter_costs[i] >= 1.0)\n      {\n         png_ptr->inv_filter_costs[i] =\n             (png_uint_16)(PNG_COST_FACTOR / filter_costs[i] + .5);\n\n         png_ptr->filter_costs[i] =\n             (png_uint_16)(PNG_COST_FACTOR * filter_costs[i] + .5);\n      }\n   }\n}\n#endif /* FLOATING_POINT */\n\n#ifdef PNG_FIXED_POINT_SUPPORTED\nvoid PNGAPI\npng_set_filter_heuristics_fixed(png_structp png_ptr, int heuristic_method,\n    int num_weights, png_const_fixed_point_p filter_weights,\n    png_const_fixed_point_p filter_costs)\n{\n   png_debug(1, \"in png_set_filter_heuristics_fixed\");\n\n   /* The internal API allocates all the arrays and ensures that the elements of\n    * those arrays are set to the default value.\n    */\n   if (!png_init_filter_heuristics(png_ptr, heuristic_method, num_weights))\n      return;\n\n   /* If using the weighted method copy in the weights. */\n   if (heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED)\n   {\n      int i;\n      for (i = 0; i < num_weights; i++)\n      {\n         if (filter_weights[i] <= 0)\n         {\n            png_ptr->inv_filter_weights[i] =\n            png_ptr->filter_weights[i] = PNG_WEIGHT_FACTOR;\n         }\n\n         else\n         {\n            png_ptr->inv_filter_weights[i] = (png_uint_16)\n               ((PNG_WEIGHT_FACTOR*filter_weights[i]+PNG_FP_HALF)/PNG_FP_1);\n\n            png_ptr->filter_weights[i] = (png_uint_16)((PNG_WEIGHT_FACTOR*\n               PNG_FP_1+(filter_weights[i]/2))/filter_weights[i]);\n         }\n      }\n\n      /* Here is where we set the relative costs of the different filters.  We\n       * should take the desired compression level into account when setting\n       * the costs, so that Paeth, for instance, has a high relative cost at low\n       * compression levels, while it has a lower relative cost at higher\n       * compression settings.  The filter types are in order of increasing\n       * relative cost, so it would be possible to do this with an algorithm.\n       */\n      for (i = 0; i < PNG_FILTER_VALUE_LAST; i++)\n         if (filter_costs[i] >= PNG_FP_1)\n      {\n         png_uint_32 tmp;\n\n         /* Use a 32 bit unsigned temporary here because otherwise the\n          * intermediate value will be a 32 bit *signed* integer (ANSI rules)\n          * and this will get the wrong answer on division.\n          */\n         tmp = PNG_COST_FACTOR*PNG_FP_1 + (filter_costs[i]/2);\n         tmp /= filter_costs[i];\n\n         png_ptr->inv_filter_costs[i] = (png_uint_16)tmp;\n\n         tmp = PNG_COST_FACTOR * filter_costs[i] + PNG_FP_HALF;\n         tmp /= PNG_FP_1;\n\n         png_ptr->filter_costs[i] = (png_uint_16)tmp;\n      }\n   }\n}\n#endif /* FIXED_POINT */\n#endif /* PNG_WRITE_WEIGHTED_FILTER_SUPPORTED */\n\nvoid PNGAPI\npng_set_compression_level(png_structp png_ptr, int level)\n{\n   png_debug(1, \"in png_set_compression_level\");\n\n   if (png_ptr == NULL)\n      return;\n\n   png_ptr->flags |= PNG_FLAG_ZLIB_CUSTOM_LEVEL;\n   png_ptr->zlib_level = level;\n}\n\nvoid PNGAPI\npng_set_compression_mem_level(png_structp png_ptr, int mem_level)\n{\n   png_debug(1, \"in png_set_compression_mem_level\");\n\n   if (png_ptr == NULL)\n      return;\n\n   png_ptr->flags |= PNG_FLAG_ZLIB_CUSTOM_MEM_LEVEL;\n   png_ptr->zlib_mem_level = mem_level;\n}\n\nvoid PNGAPI\npng_set_compression_strategy(png_structp png_ptr, int strategy)\n{\n   png_debug(1, \"in png_set_compression_strategy\");\n\n   if (png_ptr == NULL)\n      return;\n\n   png_ptr->flags |= PNG_FLAG_ZLIB_CUSTOM_STRATEGY;\n   png_ptr->zlib_strategy = strategy;\n}\n\n/* If PNG_WRITE_OPTIMIZE_CMF_SUPPORTED is defined, libpng will use a\n * smaller value of window_bits if it can do so safely.\n */\nvoid PNGAPI\npng_set_compression_window_bits(png_structp png_ptr, int window_bits)\n{\n   if (png_ptr == NULL)\n      return;\n\n   if (window_bits > 15)\n      png_warning(png_ptr, \"Only compression windows <= 32k supported by PNG\");\n\n   else if (window_bits < 8)\n      png_warning(png_ptr, \"Only compression windows >= 256 supported by PNG\");\n\n#ifndef WBITS_8_OK\n   /* Avoid libpng bug with 256-byte windows */\n   if (window_bits == 8)\n      {\n        png_warning(png_ptr, \"Compression window is being reset to 512\");\n        window_bits = 9;\n      }\n\n#endif\n   png_ptr->flags |= PNG_FLAG_ZLIB_CUSTOM_WINDOW_BITS;\n   png_ptr->zlib_window_bits = window_bits;\n}\n\nvoid PNGAPI\npng_set_compression_method(png_structp png_ptr, int method)\n{\n   png_debug(1, \"in png_set_compression_method\");\n\n   if (png_ptr == NULL)\n      return;\n\n   if (method != 8)\n      png_warning(png_ptr, \"Only compression method 8 is supported by PNG\");\n\n   png_ptr->flags |= PNG_FLAG_ZLIB_CUSTOM_METHOD;\n   png_ptr->zlib_method = method;\n}\n\n/* The following were added to libpng-1.5.4 */\n#ifdef PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED\nvoid PNGAPI\npng_set_text_compression_level(png_structp png_ptr, int level)\n{\n   png_debug(1, \"in png_set_text_compression_level\");\n\n   if (png_ptr == NULL)\n      return;\n\n   png_ptr->flags |= PNG_FLAG_ZTXT_CUSTOM_LEVEL;\n   png_ptr->zlib_text_level = level;\n}\n\nvoid PNGAPI\npng_set_text_compression_mem_level(png_structp png_ptr, int mem_level)\n{\n   png_debug(1, \"in png_set_text_compression_mem_level\");\n\n   if (png_ptr == NULL)\n      return;\n\n   png_ptr->flags |= PNG_FLAG_ZTXT_CUSTOM_MEM_LEVEL;\n   png_ptr->zlib_text_mem_level = mem_level;\n}\n\nvoid PNGAPI\npng_set_text_compression_strategy(png_structp png_ptr, int strategy)\n{\n   png_debug(1, \"in png_set_text_compression_strategy\");\n\n   if (png_ptr == NULL)\n      return;\n\n   png_ptr->flags |= PNG_FLAG_ZTXT_CUSTOM_STRATEGY;\n   png_ptr->zlib_text_strategy = strategy;\n}\n\n/* If PNG_WRITE_OPTIMIZE_CMF_SUPPORTED is defined, libpng will use a\n * smaller value of window_bits if it can do so safely.\n */\nvoid PNGAPI\npng_set_text_compression_window_bits(png_structp png_ptr, int window_bits)\n{\n   if (png_ptr == NULL)\n      return;\n\n   if (window_bits > 15)\n      png_warning(png_ptr, \"Only compression windows <= 32k supported by PNG\");\n\n   else if (window_bits < 8)\n      png_warning(png_ptr, \"Only compression windows >= 256 supported by PNG\");\n\n#ifndef WBITS_8_OK\n   /* Avoid libpng bug with 256-byte windows */\n   if (window_bits == 8)\n      {\n        png_warning(png_ptr, \"Text compression window is being reset to 512\");\n        window_bits = 9;\n      }\n\n#endif\n   png_ptr->flags |= PNG_FLAG_ZTXT_CUSTOM_WINDOW_BITS;\n   png_ptr->zlib_text_window_bits = window_bits;\n}\n\nvoid PNGAPI\npng_set_text_compression_method(png_structp png_ptr, int method)\n{\n   png_debug(1, \"in png_set_text_compression_method\");\n\n   if (png_ptr == NULL)\n      return;\n\n   if (method != 8)\n      png_warning(png_ptr, \"Only compression method 8 is supported by PNG\");\n\n   png_ptr->flags |= PNG_FLAG_ZTXT_CUSTOM_METHOD;\n   png_ptr->zlib_text_method = method;\n}\n#endif /* PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED */\n/* end of API added to libpng-1.5.4 */\n\nvoid PNGAPI\npng_set_write_status_fn(png_structp png_ptr, png_write_status_ptr write_row_fn)\n{\n   if (png_ptr == NULL)\n      return;\n\n   png_ptr->write_row_fn = write_row_fn;\n}\n\n#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED\nvoid PNGAPI\npng_set_write_user_transform_fn(png_structp png_ptr, png_user_transform_ptr\n    write_user_transform_fn)\n{\n   png_debug(1, \"in png_set_write_user_transform_fn\");\n\n   if (png_ptr == NULL)\n      return;\n\n   png_ptr->transformations |= PNG_USER_TRANSFORM;\n   png_ptr->write_user_transform_fn = write_user_transform_fn;\n}\n#endif\n\n\n#ifdef PNG_INFO_IMAGE_SUPPORTED\nvoid PNGAPI\npng_write_png(png_structp png_ptr, png_infop info_ptr,\n    int transforms, voidp params)\n{\n   if (png_ptr == NULL || info_ptr == NULL)\n      return;\n\n   /* Write the file header information. */\n   png_write_info(png_ptr, info_ptr);\n\n   /* ------ these transformations don't touch the info structure ------- */\n\n#ifdef PNG_WRITE_INVERT_SUPPORTED\n   /* Invert monochrome pixels */\n   if (transforms & PNG_TRANSFORM_INVERT_MONO)\n      png_set_invert_mono(png_ptr);\n#endif\n\n#ifdef PNG_WRITE_SHIFT_SUPPORTED\n   /* Shift the pixels up to a legal bit depth and fill in\n    * as appropriate to correctly scale the image.\n    */\n   if ((transforms & PNG_TRANSFORM_SHIFT)\n       && (info_ptr->valid & PNG_INFO_sBIT))\n      png_set_shift(png_ptr, &info_ptr->sig_bit);\n#endif\n\n#ifdef PNG_WRITE_PACK_SUPPORTED\n   /* Pack pixels into bytes */\n   if (transforms & PNG_TRANSFORM_PACKING)\n       png_set_packing(png_ptr);\n#endif\n\n#ifdef PNG_WRITE_SWAP_ALPHA_SUPPORTED\n   /* Swap location of alpha bytes from ARGB to RGBA */\n   if (transforms & PNG_TRANSFORM_SWAP_ALPHA)\n      png_set_swap_alpha(png_ptr);\n#endif\n\n#ifdef PNG_WRITE_FILLER_SUPPORTED\n   /* Pack XRGB/RGBX/ARGB/RGBA into RGB (4 channels -> 3 channels) */\n   if (transforms & PNG_TRANSFORM_STRIP_FILLER_AFTER)\n      png_set_filler(png_ptr, 0, PNG_FILLER_AFTER);\n\n   else if (transforms & PNG_TRANSFORM_STRIP_FILLER_BEFORE)\n      png_set_filler(png_ptr, 0, PNG_FILLER_BEFORE);\n#endif\n\n#ifdef PNG_WRITE_BGR_SUPPORTED\n   /* Flip BGR pixels to RGB */\n   if (transforms & PNG_TRANSFORM_BGR)\n      png_set_bgr(png_ptr);\n#endif\n\n#ifdef PNG_WRITE_SWAP_SUPPORTED\n   /* Swap bytes of 16-bit files to most significant byte first */\n   if (transforms & PNG_TRANSFORM_SWAP_ENDIAN)\n      png_set_swap(png_ptr);\n#endif\n\n#ifdef PNG_WRITE_PACKSWAP_SUPPORTED\n   /* Swap bits of 1, 2, 4 bit packed pixel formats */\n   if (transforms & PNG_TRANSFORM_PACKSWAP)\n      png_set_packswap(png_ptr);\n#endif\n\n#ifdef PNG_WRITE_INVERT_ALPHA_SUPPORTED\n   /* Invert the alpha channel from opacity to transparency */\n   if (transforms & PNG_TRANSFORM_INVERT_ALPHA)\n      png_set_invert_alpha(png_ptr);\n#endif\n\n   /* ----------------------- end of transformations ------------------- */\n\n   /* Write the bits */\n   if (info_ptr->valid & PNG_INFO_IDAT)\n       png_write_image(png_ptr, info_ptr->row_pointers);\n\n   /* It is REQUIRED to call this to finish writing the rest of the file */\n   png_write_end(png_ptr, info_ptr);\n\n   PNG_UNUSED(transforms)   /* Quiet compiler warnings */\n   PNG_UNUSED(params)\n}\n#endif\n#endif /* PNG_WRITE_SUPPORTED */\n"
  },
  {
    "path": "Projects/Tools/PNGAlphaPremultiplier/Native/Source/LibPng/pngwtran.c",
    "content": "\n/* pngwtran.c - transforms the data in a row for PNG writers\n *\n * Last changed in libpng 1.5.6 [November 3, 2011]\n * Copyright (c) 1998-2011 Glenn Randers-Pehrson\n * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)\n * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)\n *\n * This code is released under the libpng license.\n * For conditions of distribution and use, see the disclaimer\n * and license in png.h\n */\n\n#include \"pngpriv.h\"\n\n#ifdef PNG_WRITE_SUPPORTED\n\n#ifdef PNG_WRITE_TRANSFORMS_SUPPORTED\n/* Transform the data according to the user's wishes.  The order of\n * transformations is significant.\n */\nvoid /* PRIVATE */\npng_do_write_transformations(png_structp png_ptr, png_row_infop row_info)\n{\n   png_debug(1, \"in png_do_write_transformations\");\n\n   if (png_ptr == NULL)\n      return;\n\n#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED\n   if (png_ptr->transformations & PNG_USER_TRANSFORM)\n      if (png_ptr->write_user_transform_fn != NULL)\n         (*(png_ptr->write_user_transform_fn)) /* User write transform\n                                                 function */\n             (png_ptr,  /* png_ptr */\n             row_info,  /* row_info: */\n                /*  png_uint_32 width;       width of row */\n                /*  png_size_t rowbytes;     number of bytes in row */\n                /*  png_byte color_type;     color type of pixels */\n                /*  png_byte bit_depth;      bit depth of samples */\n                /*  png_byte channels;       number of channels (1-4) */\n                /*  png_byte pixel_depth;    bits per pixel (depth*channels) */\n             png_ptr->row_buf + 1);      /* start of pixel data for row */\n#endif\n\n#ifdef PNG_WRITE_FILLER_SUPPORTED\n   if (png_ptr->transformations & PNG_FILLER)\n      png_do_strip_channel(row_info, png_ptr->row_buf + 1,\n         !(png_ptr->flags & PNG_FLAG_FILLER_AFTER));\n#endif\n\n#ifdef PNG_WRITE_PACKSWAP_SUPPORTED\n   if (png_ptr->transformations & PNG_PACKSWAP)\n      png_do_packswap(row_info, png_ptr->row_buf + 1);\n#endif\n\n#ifdef PNG_WRITE_PACK_SUPPORTED\n   if (png_ptr->transformations & PNG_PACK)\n      png_do_pack(row_info, png_ptr->row_buf + 1,\n          (png_uint_32)png_ptr->bit_depth);\n#endif\n\n#ifdef PNG_WRITE_SWAP_SUPPORTED\n   if (png_ptr->transformations & PNG_SWAP_BYTES)\n      png_do_swap(row_info, png_ptr->row_buf + 1);\n#endif\n\n#ifdef PNG_WRITE_SHIFT_SUPPORTED\n   if (png_ptr->transformations & PNG_SHIFT)\n      png_do_shift(row_info, png_ptr->row_buf + 1,\n          &(png_ptr->shift));\n#endif\n\n#ifdef PNG_WRITE_SWAP_ALPHA_SUPPORTED\n   if (png_ptr->transformations & PNG_SWAP_ALPHA)\n      png_do_write_swap_alpha(row_info, png_ptr->row_buf + 1);\n#endif\n\n#ifdef PNG_WRITE_INVERT_ALPHA_SUPPORTED\n   if (png_ptr->transformations & PNG_INVERT_ALPHA)\n      png_do_write_invert_alpha(row_info, png_ptr->row_buf + 1);\n#endif\n\n#ifdef PNG_WRITE_BGR_SUPPORTED\n   if (png_ptr->transformations & PNG_BGR)\n      png_do_bgr(row_info, png_ptr->row_buf + 1);\n#endif\n\n#ifdef PNG_WRITE_INVERT_SUPPORTED\n   if (png_ptr->transformations & PNG_INVERT_MONO)\n      png_do_invert(row_info, png_ptr->row_buf + 1);\n#endif\n}\n\n#ifdef PNG_WRITE_PACK_SUPPORTED\n/* Pack pixels into bytes.  Pass the true bit depth in bit_depth.  The\n * row_info bit depth should be 8 (one pixel per byte).  The channels\n * should be 1 (this only happens on grayscale and paletted images).\n */\nvoid /* PRIVATE */\npng_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth)\n{\n   png_debug(1, \"in png_do_pack\");\n\n   if (row_info->bit_depth == 8 &&\n      row_info->channels == 1)\n   {\n      switch ((int)bit_depth)\n      {\n         case 1:\n         {\n            png_bytep sp, dp;\n            int mask, v;\n            png_uint_32 i;\n            png_uint_32 row_width = row_info->width;\n\n            sp = row;\n            dp = row;\n            mask = 0x80;\n            v = 0;\n\n            for (i = 0; i < row_width; i++)\n            {\n               if (*sp != 0)\n                  v |= mask;\n\n               sp++;\n\n               if (mask > 1)\n                  mask >>= 1;\n\n               else\n               {\n                  mask = 0x80;\n                  *dp = (png_byte)v;\n                  dp++;\n                  v = 0;\n               }\n            }\n\n            if (mask != 0x80)\n               *dp = (png_byte)v;\n\n            break;\n         }\n\n         case 2:\n         {\n            png_bytep sp, dp;\n            int shift, v;\n            png_uint_32 i;\n            png_uint_32 row_width = row_info->width;\n\n            sp = row;\n            dp = row;\n            shift = 6;\n            v = 0;\n\n            for (i = 0; i < row_width; i++)\n            {\n               png_byte value;\n\n               value = (png_byte)(*sp & 0x03);\n               v |= (value << shift);\n\n               if (shift == 0)\n               {\n                  shift = 6;\n                  *dp = (png_byte)v;\n                  dp++;\n                  v = 0;\n               }\n\n               else\n                  shift -= 2;\n\n               sp++;\n            }\n\n            if (shift != 6)\n               *dp = (png_byte)v;\n\n            break;\n         }\n\n         case 4:\n         {\n            png_bytep sp, dp;\n            int shift, v;\n            png_uint_32 i;\n            png_uint_32 row_width = row_info->width;\n\n            sp = row;\n            dp = row;\n            shift = 4;\n            v = 0;\n\n            for (i = 0; i < row_width; i++)\n            {\n               png_byte value;\n\n               value = (png_byte)(*sp & 0x0f);\n               v |= (value << shift);\n\n               if (shift == 0)\n               {\n                  shift = 4;\n                  *dp = (png_byte)v;\n                  dp++;\n                  v = 0;\n               }\n\n               else\n                  shift -= 4;\n\n               sp++;\n            }\n\n            if (shift != 4)\n               *dp = (png_byte)v;\n\n            break;\n         }\n\n         default:\n            break;\n      }\n\n      row_info->bit_depth = (png_byte)bit_depth;\n      row_info->pixel_depth = (png_byte)(bit_depth * row_info->channels);\n      row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,\n          row_info->width);\n   }\n}\n#endif\n\n#ifdef PNG_WRITE_SHIFT_SUPPORTED\n/* Shift pixel values to take advantage of whole range.  Pass the\n * true number of bits in bit_depth.  The row should be packed\n * according to row_info->bit_depth.  Thus, if you had a row of\n * bit depth 4, but the pixels only had values from 0 to 7, you\n * would pass 3 as bit_depth, and this routine would translate the\n * data to 0 to 15.\n */\nvoid /* PRIVATE */\npng_do_shift(png_row_infop row_info, png_bytep row,\n    png_const_color_8p bit_depth)\n{\n   png_debug(1, \"in png_do_shift\");\n\n   if (row_info->color_type != PNG_COLOR_TYPE_PALETTE)\n   {\n      int shift_start[4], shift_dec[4];\n      int channels = 0;\n\n      if (row_info->color_type & PNG_COLOR_MASK_COLOR)\n      {\n         shift_start[channels] = row_info->bit_depth - bit_depth->red;\n         shift_dec[channels] = bit_depth->red;\n         channels++;\n\n         shift_start[channels] = row_info->bit_depth - bit_depth->green;\n         shift_dec[channels] = bit_depth->green;\n         channels++;\n\n         shift_start[channels] = row_info->bit_depth - bit_depth->blue;\n         shift_dec[channels] = bit_depth->blue;\n         channels++;\n      }\n\n      else\n      {\n         shift_start[channels] = row_info->bit_depth - bit_depth->gray;\n         shift_dec[channels] = bit_depth->gray;\n         channels++;\n      }\n\n      if (row_info->color_type & PNG_COLOR_MASK_ALPHA)\n      {\n         shift_start[channels] = row_info->bit_depth - bit_depth->alpha;\n         shift_dec[channels] = bit_depth->alpha;\n         channels++;\n      }\n\n      /* With low row depths, could only be grayscale, so one channel */\n      if (row_info->bit_depth < 8)\n      {\n         png_bytep bp = row;\n         png_size_t i;\n         png_byte mask;\n         png_size_t row_bytes = row_info->rowbytes;\n\n         if (bit_depth->gray == 1 && row_info->bit_depth == 2)\n            mask = 0x55;\n\n         else if (row_info->bit_depth == 4 && bit_depth->gray == 3)\n            mask = 0x11;\n\n         else\n            mask = 0xff;\n\n         for (i = 0; i < row_bytes; i++, bp++)\n         {\n            png_uint_16 v;\n            int j;\n\n            v = *bp;\n            *bp = 0;\n\n            for (j = shift_start[0]; j > -shift_dec[0]; j -= shift_dec[0])\n            {\n               if (j > 0)\n                  *bp |= (png_byte)((v << j) & 0xff);\n\n               else\n                  *bp |= (png_byte)((v >> (-j)) & mask);\n            }\n         }\n      }\n\n      else if (row_info->bit_depth == 8)\n      {\n         png_bytep bp = row;\n         png_uint_32 i;\n         png_uint_32 istop = channels * row_info->width;\n\n         for (i = 0; i < istop; i++, bp++)\n         {\n\n            png_uint_16 v;\n            int j;\n            int c = (int)(i%channels);\n\n            v = *bp;\n            *bp = 0;\n\n            for (j = shift_start[c]; j > -shift_dec[c]; j -= shift_dec[c])\n            {\n               if (j > 0)\n                  *bp |= (png_byte)((v << j) & 0xff);\n\n               else\n                  *bp |= (png_byte)((v >> (-j)) & 0xff);\n            }\n         }\n      }\n\n      else\n      {\n         png_bytep bp;\n         png_uint_32 i;\n         png_uint_32 istop = channels * row_info->width;\n\n         for (bp = row, i = 0; i < istop; i++)\n         {\n            int c = (int)(i%channels);\n            png_uint_16 value, v;\n            int j;\n\n            v = (png_uint_16)(((png_uint_16)(*bp) << 8) + *(bp + 1));\n            value = 0;\n\n            for (j = shift_start[c]; j > -shift_dec[c]; j -= shift_dec[c])\n            {\n               if (j > 0)\n                  value |= (png_uint_16)((v << j) & (png_uint_16)0xffff);\n\n               else\n                  value |= (png_uint_16)((v >> (-j)) & (png_uint_16)0xffff);\n            }\n            *bp++ = (png_byte)(value >> 8);\n            *bp++ = (png_byte)(value & 0xff);\n         }\n      }\n   }\n}\n#endif\n\n#ifdef PNG_WRITE_SWAP_ALPHA_SUPPORTED\nvoid /* PRIVATE */\npng_do_write_swap_alpha(png_row_infop row_info, png_bytep row)\n{\n   png_debug(1, \"in png_do_write_swap_alpha\");\n\n   {\n      if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)\n      {\n         if (row_info->bit_depth == 8)\n         {\n            /* This converts from ARGB to RGBA */\n            png_bytep sp, dp;\n            png_uint_32 i;\n            png_uint_32 row_width = row_info->width;\n\n            for (i = 0, sp = dp = row; i < row_width; i++)\n            {\n               png_byte save = *(sp++);\n               *(dp++) = *(sp++);\n               *(dp++) = *(sp++);\n               *(dp++) = *(sp++);\n               *(dp++) = save;\n            }\n         }\n\n#ifdef PNG_WRITE_16BIT_SUPPORTED\n         else\n         {\n            /* This converts from AARRGGBB to RRGGBBAA */\n            png_bytep sp, dp;\n            png_uint_32 i;\n            png_uint_32 row_width = row_info->width;\n\n            for (i = 0, sp = dp = row; i < row_width; i++)\n            {\n               png_byte save[2];\n               save[0] = *(sp++);\n               save[1] = *(sp++);\n               *(dp++) = *(sp++);\n               *(dp++) = *(sp++);\n               *(dp++) = *(sp++);\n               *(dp++) = *(sp++);\n               *(dp++) = *(sp++);\n               *(dp++) = *(sp++);\n               *(dp++) = save[0];\n               *(dp++) = save[1];\n            }\n         }\n#endif /* PNG_WRITE_16BIT_SUPPORTED */\n      }\n\n      else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)\n      {\n         if (row_info->bit_depth == 8)\n         {\n            /* This converts from AG to GA */\n            png_bytep sp, dp;\n            png_uint_32 i;\n            png_uint_32 row_width = row_info->width;\n\n            for (i = 0, sp = dp = row; i < row_width; i++)\n            {\n               png_byte save = *(sp++);\n               *(dp++) = *(sp++);\n               *(dp++) = save;\n            }\n         }\n\n#ifdef PNG_WRITE_16BIT_SUPPORTED\n         else\n         {\n            /* This converts from AAGG to GGAA */\n            png_bytep sp, dp;\n            png_uint_32 i;\n            png_uint_32 row_width = row_info->width;\n\n            for (i = 0, sp = dp = row; i < row_width; i++)\n            {\n               png_byte save[2];\n               save[0] = *(sp++);\n               save[1] = *(sp++);\n               *(dp++) = *(sp++);\n               *(dp++) = *(sp++);\n               *(dp++) = save[0];\n               *(dp++) = save[1];\n            }\n         }\n#endif /* PNG_WRITE_16BIT_SUPPORTED */\n      }\n   }\n}\n#endif\n\n#ifdef PNG_WRITE_INVERT_ALPHA_SUPPORTED\nvoid /* PRIVATE */\npng_do_write_invert_alpha(png_row_infop row_info, png_bytep row)\n{\n   png_debug(1, \"in png_do_write_invert_alpha\");\n\n   {\n      if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)\n      {\n         if (row_info->bit_depth == 8)\n         {\n            /* This inverts the alpha channel in RGBA */\n            png_bytep sp, dp;\n            png_uint_32 i;\n            png_uint_32 row_width = row_info->width;\n\n            for (i = 0, sp = dp = row; i < row_width; i++)\n            {\n               /* Does nothing\n               *(dp++) = *(sp++);\n               *(dp++) = *(sp++);\n               *(dp++) = *(sp++);\n               */\n               sp+=3; dp = sp;\n               *(dp++) = (png_byte)(255 - *(sp++));\n            }\n         }\n\n#ifdef PNG_WRITE_16BIT_SUPPORTED\n         else\n         {\n            /* This inverts the alpha channel in RRGGBBAA */\n            png_bytep sp, dp;\n            png_uint_32 i;\n            png_uint_32 row_width = row_info->width;\n\n            for (i = 0, sp = dp = row; i < row_width; i++)\n            {\n               /* Does nothing\n               *(dp++) = *(sp++);\n               *(dp++) = *(sp++);\n               *(dp++) = *(sp++);\n               *(dp++) = *(sp++);\n               *(dp++) = *(sp++);\n               *(dp++) = *(sp++);\n               */\n               sp+=6; dp = sp;\n               *(dp++) = (png_byte)(255 - *(sp++));\n               *(dp++) = (png_byte)(255 - *(sp++));\n            }\n         }\n#endif /* PNG_WRITE_16BIT_SUPPORTED */\n      }\n\n      else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)\n      {\n         if (row_info->bit_depth == 8)\n         {\n            /* This inverts the alpha channel in GA */\n            png_bytep sp, dp;\n            png_uint_32 i;\n            png_uint_32 row_width = row_info->width;\n\n            for (i = 0, sp = dp = row; i < row_width; i++)\n            {\n               *(dp++) = *(sp++);\n               *(dp++) = (png_byte)(255 - *(sp++));\n            }\n         }\n\n#ifdef PNG_WRITE_16BIT_SUPPORTED\n         else\n         {\n            /* This inverts the alpha channel in GGAA */\n            png_bytep sp, dp;\n            png_uint_32 i;\n            png_uint_32 row_width = row_info->width;\n\n            for (i = 0, sp = dp = row; i < row_width; i++)\n            {\n               /* Does nothing\n               *(dp++) = *(sp++);\n               *(dp++) = *(sp++);\n               */\n               sp+=2; dp = sp;\n               *(dp++) = (png_byte)(255 - *(sp++));\n               *(dp++) = (png_byte)(255 - *(sp++));\n            }\n         }\n#endif /* PNG_WRITE_16BIT_SUPPORTED */\n      }\n   }\n}\n#endif\n#endif /* PNG_WRITE_TRANSFORMS_SUPPORTED */\n\n#ifdef PNG_MNG_FEATURES_SUPPORTED\n/* Undoes intrapixel differencing  */\nvoid /* PRIVATE */\npng_do_write_intrapixel(png_row_infop row_info, png_bytep row)\n{\n   png_debug(1, \"in png_do_write_intrapixel\");\n\n   if ((row_info->color_type & PNG_COLOR_MASK_COLOR))\n   {\n      int bytes_per_pixel;\n      png_uint_32 row_width = row_info->width;\n      if (row_info->bit_depth == 8)\n      {\n         png_bytep rp;\n         png_uint_32 i;\n\n         if (row_info->color_type == PNG_COLOR_TYPE_RGB)\n            bytes_per_pixel = 3;\n\n         else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)\n            bytes_per_pixel = 4;\n\n         else\n            return;\n\n         for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel)\n         {\n            *(rp)     = (png_byte)((*rp       - *(rp + 1)) & 0xff);\n            *(rp + 2) = (png_byte)((*(rp + 2) - *(rp + 1)) & 0xff);\n         }\n      }\n\n#ifdef PNG_WRITE_16BIT_SUPPORTED\n      else if (row_info->bit_depth == 16)\n      {\n         png_bytep rp;\n         png_uint_32 i;\n\n         if (row_info->color_type == PNG_COLOR_TYPE_RGB)\n            bytes_per_pixel = 6;\n\n         else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)\n            bytes_per_pixel = 8;\n\n         else\n            return;\n\n         for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel)\n         {\n            png_uint_32 s0   = (*(rp    ) << 8) | *(rp + 1);\n            png_uint_32 s1   = (*(rp + 2) << 8) | *(rp + 3);\n            png_uint_32 s2   = (*(rp + 4) << 8) | *(rp + 5);\n            png_uint_32 red  = (png_uint_32)((s0 - s1) & 0xffffL);\n            png_uint_32 blue = (png_uint_32)((s2 - s1) & 0xffffL);\n            *(rp    ) = (png_byte)((red >> 8) & 0xff);\n            *(rp + 1) = (png_byte)(red & 0xff);\n            *(rp + 4) = (png_byte)((blue >> 8) & 0xff);\n            *(rp + 5) = (png_byte)(blue & 0xff);\n         }\n      }\n#endif /* PNG_WRITE_16BIT_SUPPORTED */\n   }\n}\n#endif /* PNG_MNG_FEATURES_SUPPORTED */\n#endif /* PNG_WRITE_SUPPORTED */\n"
  },
  {
    "path": "Projects/Tools/PNGAlphaPremultiplier/Native/Source/LibPng/pngwutil.c",
    "content": "\n/* pngwutil.c - utilities to write a PNG file\n *\n * Last changed in libpng 1.5.6 [November 3, 2011]\n * Copyright (c) 1998-2011 Glenn Randers-Pehrson\n * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)\n * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)\n *\n * This code is released under the libpng license.\n * For conditions of distribution and use, see the disclaimer\n * and license in png.h\n */\n\n#include \"pngpriv.h\"\n\n#ifdef PNG_WRITE_SUPPORTED\n\n#ifdef PNG_WRITE_INT_FUNCTIONS_SUPPORTED\n/* Place a 32-bit number into a buffer in PNG byte order.  We work\n * with unsigned numbers for convenience, although one supported\n * ancillary chunk uses signed (two's complement) numbers.\n */\nvoid PNGAPI\npng_save_uint_32(png_bytep buf, png_uint_32 i)\n{\n   buf[0] = (png_byte)((i >> 24) & 0xff);\n   buf[1] = (png_byte)((i >> 16) & 0xff);\n   buf[2] = (png_byte)((i >> 8) & 0xff);\n   buf[3] = (png_byte)(i & 0xff);\n}\n\n#ifdef PNG_SAVE_INT_32_SUPPORTED\n/* The png_save_int_32 function assumes integers are stored in two's\n * complement format.  If this isn't the case, then this routine needs to\n * be modified to write data in two's complement format.  Note that,\n * the following works correctly even if png_int_32 has more than 32 bits\n * (compare the more complex code required on read for sign extention.)\n */\nvoid PNGAPI\npng_save_int_32(png_bytep buf, png_int_32 i)\n{\n   buf[0] = (png_byte)((i >> 24) & 0xff);\n   buf[1] = (png_byte)((i >> 16) & 0xff);\n   buf[2] = (png_byte)((i >> 8) & 0xff);\n   buf[3] = (png_byte)(i & 0xff);\n}\n#endif\n\n/* Place a 16-bit number into a buffer in PNG byte order.\n * The parameter is declared unsigned int, not png_uint_16,\n * just to avoid potential problems on pre-ANSI C compilers.\n */\nvoid PNGAPI\npng_save_uint_16(png_bytep buf, unsigned int i)\n{\n   buf[0] = (png_byte)((i >> 8) & 0xff);\n   buf[1] = (png_byte)(i & 0xff);\n}\n#endif\n\n/* Simple function to write the signature.  If we have already written\n * the magic bytes of the signature, or more likely, the PNG stream is\n * being embedded into another stream and doesn't need its own signature,\n * we should call png_set_sig_bytes() to tell libpng how many of the\n * bytes have already been written.\n */\nvoid PNGAPI\npng_write_sig(png_structp png_ptr)\n{\n   png_byte png_signature[8] = {137, 80, 78, 71, 13, 10, 26, 10};\n\n#ifdef PNG_IO_STATE_SUPPORTED\n   /* Inform the I/O callback that the signature is being written */\n   png_ptr->io_state = PNG_IO_WRITING | PNG_IO_SIGNATURE;\n#endif\n\n   /* Write the rest of the 8 byte signature */\n   png_write_data(png_ptr, &png_signature[png_ptr->sig_bytes],\n      (png_size_t)(8 - png_ptr->sig_bytes));\n\n   if (png_ptr->sig_bytes < 3)\n      png_ptr->mode |= PNG_HAVE_PNG_SIGNATURE;\n}\n\n/* Write the start of a PNG chunk.  The type is the chunk type.\n * The total_length is the sum of the lengths of all the data you will be\n * passing in png_write_chunk_data().\n */\nstatic void\npng_write_chunk_header(png_structp png_ptr, png_uint_32 chunk_name,\n    png_uint_32 length)\n{\n   png_byte buf[8];\n\n#if defined(PNG_DEBUG) && (PNG_DEBUG > 0)\n   PNG_CSTRING_FROM_CHUNK(buf, chunk_name);\n   png_debug2(0, \"Writing %s chunk, length = %lu\", buf, (unsigned long)length);\n#endif\n\n   if (png_ptr == NULL)\n      return;\n\n#ifdef PNG_IO_STATE_SUPPORTED\n   /* Inform the I/O callback that the chunk header is being written.\n    * PNG_IO_CHUNK_HDR requires a single I/O call.\n    */\n   png_ptr->io_state = PNG_IO_WRITING | PNG_IO_CHUNK_HDR;\n#endif\n\n   /* Write the length and the chunk name */\n   png_save_uint_32(buf, length);\n   png_save_uint_32(buf + 4, chunk_name);\n   png_write_data(png_ptr, buf, 8);\n\n   /* Put the chunk name into png_ptr->chunk_name */\n   png_ptr->chunk_name = chunk_name;\n\n   /* Reset the crc and run it over the chunk name */\n   png_reset_crc(png_ptr);\n\n   png_calculate_crc(png_ptr, buf + 4, 4);\n\n#ifdef PNG_IO_STATE_SUPPORTED\n   /* Inform the I/O callback that chunk data will (possibly) be written.\n    * PNG_IO_CHUNK_DATA does NOT require a specific number of I/O calls.\n    */\n   png_ptr->io_state = PNG_IO_WRITING | PNG_IO_CHUNK_DATA;\n#endif\n}\n\nvoid PNGAPI\npng_write_chunk_start(png_structp png_ptr, png_const_bytep chunk_string,\n    png_uint_32 length)\n{\n   png_write_chunk_header(png_ptr, PNG_CHUNK_FROM_STRING(chunk_string), length);\n}\n\n/* Write the data of a PNG chunk started with png_write_chunk_header().\n * Note that multiple calls to this function are allowed, and that the\n * sum of the lengths from these calls *must* add up to the total_length\n * given to png_write_chunk_header().\n */\nvoid PNGAPI\npng_write_chunk_data(png_structp png_ptr, png_const_bytep data,\n    png_size_t length)\n{\n   /* Write the data, and run the CRC over it */\n   if (png_ptr == NULL)\n      return;\n\n   if (data != NULL && length > 0)\n   {\n      png_write_data(png_ptr, data, length);\n\n      /* Update the CRC after writing the data,\n       * in case that the user I/O routine alters it.\n       */\n      png_calculate_crc(png_ptr, data, length);\n   }\n}\n\n/* Finish a chunk started with png_write_chunk_header(). */\nvoid PNGAPI\npng_write_chunk_end(png_structp png_ptr)\n{\n   png_byte buf[4];\n\n   if (png_ptr == NULL) return;\n\n#ifdef PNG_IO_STATE_SUPPORTED\n   /* Inform the I/O callback that the chunk CRC is being written.\n    * PNG_IO_CHUNK_CRC requires a single I/O function call.\n    */\n   png_ptr->io_state = PNG_IO_WRITING | PNG_IO_CHUNK_CRC;\n#endif\n\n   /* Write the crc in a single operation */\n   png_save_uint_32(buf, png_ptr->crc);\n\n   png_write_data(png_ptr, buf, (png_size_t)4);\n}\n\n/* Write a PNG chunk all at once.  The type is an array of ASCII characters\n * representing the chunk name.  The array must be at least 4 bytes in\n * length, and does not need to be null terminated.  To be safe, pass the\n * pre-defined chunk names here, and if you need a new one, define it\n * where the others are defined.  The length is the length of the data.\n * All the data must be present.  If that is not possible, use the\n * png_write_chunk_start(), png_write_chunk_data(), and png_write_chunk_end()\n * functions instead.\n */\nstatic void\npng_write_complete_chunk(png_structp png_ptr, png_uint_32 chunk_name,\n   png_const_bytep data, png_size_t length)\n{\n   if (png_ptr == NULL)\n      return;\n\n   /* On 64 bit architectures 'length' may not fit in a png_uint_32. */\n   if (length > PNG_UINT_32_MAX)\n      png_error(png_ptr, \"length exceeds PNG maxima\");\n\n   png_write_chunk_header(png_ptr, chunk_name, (png_uint_32)length);\n   png_write_chunk_data(png_ptr, data, length);\n   png_write_chunk_end(png_ptr);\n}\n\n/* This is the API that calls the internal function above. */\nvoid PNGAPI\npng_write_chunk(png_structp png_ptr, png_const_bytep chunk_string,\n   png_const_bytep data, png_size_t length)\n{\n   png_write_complete_chunk(png_ptr, PNG_CHUNK_FROM_STRING(chunk_string), data,\n      length);\n}\n\n/* Initialize the compressor for the appropriate type of compression. */\nstatic void\npng_zlib_claim(png_structp png_ptr, png_uint_32 state)\n{\n   if (!(png_ptr->zlib_state & PNG_ZLIB_IN_USE))\n   {\n      /* If already initialized for 'state' do not re-init. */\n      if (png_ptr->zlib_state != state)\n      {\n         int ret = Z_OK;\n         png_const_charp who = \"-\";\n\n         /* If actually initialized for another state do a deflateEnd. */\n         if (png_ptr->zlib_state != PNG_ZLIB_UNINITIALIZED)\n         {\n            ret = deflateEnd(&png_ptr->zstream);\n            who = \"end\";\n            png_ptr->zlib_state = PNG_ZLIB_UNINITIALIZED;\n         }\n\n         /* zlib itself detects an incomplete state on deflateEnd */\n         if (ret == Z_OK) switch (state)\n         {\n#           ifdef PNG_WRITE_COMPRESSED_TEXT_SUPPORTED\n               case PNG_ZLIB_FOR_TEXT:\n                  ret = deflateInit2(&png_ptr->zstream,\n                     png_ptr->zlib_text_level, png_ptr->zlib_text_method,\n                     png_ptr->zlib_text_window_bits,\n                     png_ptr->zlib_text_mem_level, png_ptr->zlib_text_strategy);\n                  who = \"text\";\n                  break;\n#           endif\n\n            case PNG_ZLIB_FOR_IDAT:\n               ret = deflateInit2(&png_ptr->zstream, png_ptr->zlib_level,\n                   png_ptr->zlib_method, png_ptr->zlib_window_bits,\n                   png_ptr->zlib_mem_level, png_ptr->zlib_strategy);\n               who = \"IDAT\";\n               break;\n\n            default:\n               png_error(png_ptr, \"invalid zlib state\");\n         }\n\n         if (ret == Z_OK)\n            png_ptr->zlib_state = state;\n\n         else /* an error in deflateEnd or deflateInit2 */\n         {\n            size_t pos = 0;\n            char msg[64];\n\n            pos = png_safecat(msg, sizeof msg, pos,\n               \"zlib failed to initialize compressor (\");\n            pos = png_safecat(msg, sizeof msg, pos, who);\n\n            switch (ret)\n            {\n               case Z_VERSION_ERROR:\n                  pos = png_safecat(msg, sizeof msg, pos, \") version error\");\n                  break;\n\n               case Z_STREAM_ERROR:\n                  pos = png_safecat(msg, sizeof msg, pos, \") stream error\");\n                  break;\n\n               case Z_MEM_ERROR:\n                  pos = png_safecat(msg, sizeof msg, pos, \") memory error\");\n                  break;\n\n               default:\n                  pos = png_safecat(msg, sizeof msg, pos, \") unknown error\");\n                  break;\n            }\n\n            png_error(png_ptr, msg);\n         }\n      }\n\n      /* Here on success, claim the zstream: */\n      png_ptr->zlib_state |= PNG_ZLIB_IN_USE;\n   }\n\n   else\n      png_error(png_ptr, \"zstream already in use (internal error)\");\n}\n\n/* The opposite: release the stream.  It is also reset, this API will warn on\n * error but will not fail.\n */\nstatic void\npng_zlib_release(png_structp png_ptr)\n{\n   if (png_ptr->zlib_state & PNG_ZLIB_IN_USE)\n   {\n      int ret = deflateReset(&png_ptr->zstream);\n\n      png_ptr->zlib_state &= ~PNG_ZLIB_IN_USE;\n\n      if (ret != Z_OK)\n      {\n         png_const_charp err;\n         PNG_WARNING_PARAMETERS(p)\n\n         switch (ret)\n         {\n            case Z_VERSION_ERROR:\n               err = \"version\";\n               break;\n\n            case Z_STREAM_ERROR:\n               err = \"stream\";\n               break;\n\n            case Z_MEM_ERROR:\n               err = \"memory\";\n               break;\n\n            default:\n               err = \"unknown\";\n               break;\n         }\n\n         png_warning_parameter_signed(p, 1, PNG_NUMBER_FORMAT_d, ret);\n         png_warning_parameter(p, 2, err);\n\n         if (png_ptr->zstream.msg)\n            err = png_ptr->zstream.msg;\n         else\n            err = \"[no zlib message]\";\n\n         png_warning_parameter(p, 3, err);\n\n         png_formatted_warning(png_ptr, p,\n            \"zlib failed to reset compressor: @1(@2): @3\");\n      }\n   }\n\n   else\n      png_warning(png_ptr, \"zstream not in use (internal error)\");\n}\n\n#ifdef PNG_WRITE_COMPRESSED_TEXT_SUPPORTED\n/* This pair of functions encapsulates the operation of (a) compressing a\n * text string, and (b) issuing it later as a series of chunk data writes.\n * The compression_state structure is shared context for these functions\n * set up by the caller in order to make the whole mess thread-safe.\n */\n\ntypedef struct\n{\n   png_const_bytep input;   /* The uncompressed input data */\n   png_size_t input_len;    /* Its length */\n   int num_output_ptr;      /* Number of output pointers used */\n   int max_output_ptr;      /* Size of output_ptr */\n   png_bytep *output_ptr;   /* Array of pointers to output */\n} compression_state;\n\n/* Compress given text into storage in the png_ptr structure */\nstatic int /* PRIVATE */\npng_text_compress(png_structp png_ptr,\n    png_const_charp text, png_size_t text_len, int compression,\n    compression_state *comp)\n{\n   int ret;\n\n   comp->num_output_ptr = 0;\n   comp->max_output_ptr = 0;\n   comp->output_ptr = NULL;\n   comp->input = NULL;\n   comp->input_len = text_len;\n\n   /* We may just want to pass the text right through */\n   if (compression == PNG_TEXT_COMPRESSION_NONE)\n   {\n      comp->input = (png_const_bytep)text;\n      return((int)text_len);\n   }\n\n   if (compression >= PNG_TEXT_COMPRESSION_LAST)\n   {\n      PNG_WARNING_PARAMETERS(p)\n\n      png_warning_parameter_signed(p, 1, PNG_NUMBER_FORMAT_d,\n         compression);\n      png_formatted_warning(png_ptr, p, \"Unknown compression type @1\");\n   }\n\n   /* We can't write the chunk until we find out how much data we have,\n    * which means we need to run the compressor first and save the\n    * output.  This shouldn't be a problem, as the vast majority of\n    * comments should be reasonable, but we will set up an array of\n    * malloc'd pointers to be sure.\n    *\n    * If we knew the application was well behaved, we could simplify this\n    * greatly by assuming we can always malloc an output buffer large\n    * enough to hold the compressed text ((1001 * text_len / 1000) + 12)\n    * and malloc this directly.  The only time this would be a bad idea is\n    * if we can't malloc more than 64K and we have 64K of random input\n    * data, or if the input string is incredibly large (although this\n    * wouldn't cause a failure, just a slowdown due to swapping).\n    */\n   png_zlib_claim(png_ptr, PNG_ZLIB_FOR_TEXT);\n\n   /* Set up the compression buffers */\n   /* TODO: the following cast hides a potential overflow problem. */\n   png_ptr->zstream.avail_in = (uInt)text_len;\n\n   /* NOTE: assume zlib doesn't overwrite the input */\n   png_ptr->zstream.next_in = (Bytef *)text;\n   png_ptr->zstream.avail_out = png_ptr->zbuf_size;\n   png_ptr->zstream.next_out = png_ptr->zbuf;\n\n   /* This is the same compression loop as in png_write_row() */\n   do\n   {\n      /* Compress the data */\n      ret = deflate(&png_ptr->zstream, Z_NO_FLUSH);\n\n      if (ret != Z_OK)\n      {\n         /* Error */\n         if (png_ptr->zstream.msg != NULL)\n            png_error(png_ptr, png_ptr->zstream.msg);\n\n         else\n            png_error(png_ptr, \"zlib error\");\n      }\n\n      /* Check to see if we need more room */\n      if (!(png_ptr->zstream.avail_out))\n      {\n         /* Make sure the output array has room */\n         if (comp->num_output_ptr >= comp->max_output_ptr)\n         {\n            int old_max;\n\n            old_max = comp->max_output_ptr;\n            comp->max_output_ptr = comp->num_output_ptr + 4;\n            if (comp->output_ptr != NULL)\n            {\n               png_bytepp old_ptr;\n\n               old_ptr = comp->output_ptr;\n\n               comp->output_ptr = (png_bytepp)png_malloc(png_ptr,\n                   (png_alloc_size_t)\n                   (comp->max_output_ptr * png_sizeof(png_charpp)));\n\n               png_memcpy(comp->output_ptr, old_ptr, old_max\n                   * png_sizeof(png_charp));\n\n               png_free(png_ptr, old_ptr);\n            }\n            else\n               comp->output_ptr = (png_bytepp)png_malloc(png_ptr,\n                   (png_alloc_size_t)\n                   (comp->max_output_ptr * png_sizeof(png_charp)));\n         }\n\n         /* Save the data */\n         comp->output_ptr[comp->num_output_ptr] =\n             (png_bytep)png_malloc(png_ptr,\n             (png_alloc_size_t)png_ptr->zbuf_size);\n\n         png_memcpy(comp->output_ptr[comp->num_output_ptr], png_ptr->zbuf,\n             png_ptr->zbuf_size);\n\n         comp->num_output_ptr++;\n\n         /* and reset the buffer */\n         png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size;\n         png_ptr->zstream.next_out = png_ptr->zbuf;\n      }\n   /* Continue until we don't have any more to compress */\n   } while (png_ptr->zstream.avail_in);\n\n   /* Finish the compression */\n   do\n   {\n      /* Tell zlib we are finished */\n      ret = deflate(&png_ptr->zstream, Z_FINISH);\n\n      if (ret == Z_OK)\n      {\n         /* Check to see if we need more room */\n         if (!(png_ptr->zstream.avail_out))\n         {\n            /* Check to make sure our output array has room */\n            if (comp->num_output_ptr >= comp->max_output_ptr)\n            {\n               int old_max;\n\n               old_max = comp->max_output_ptr;\n               comp->max_output_ptr = comp->num_output_ptr + 4;\n               if (comp->output_ptr != NULL)\n               {\n                  png_bytepp old_ptr;\n\n                  old_ptr = comp->output_ptr;\n\n                  /* This could be optimized to realloc() */\n                  comp->output_ptr = (png_bytepp)png_malloc(png_ptr,\n                      (png_alloc_size_t)(comp->max_output_ptr *\n                      png_sizeof(png_charp)));\n\n                  png_memcpy(comp->output_ptr, old_ptr,\n                      old_max * png_sizeof(png_charp));\n\n                  png_free(png_ptr, old_ptr);\n               }\n\n               else\n                  comp->output_ptr = (png_bytepp)png_malloc(png_ptr,\n                      (png_alloc_size_t)(comp->max_output_ptr *\n                      png_sizeof(png_charp)));\n            }\n\n            /* Save the data */\n            comp->output_ptr[comp->num_output_ptr] =\n                (png_bytep)png_malloc(png_ptr,\n                (png_alloc_size_t)png_ptr->zbuf_size);\n\n            png_memcpy(comp->output_ptr[comp->num_output_ptr], png_ptr->zbuf,\n                png_ptr->zbuf_size);\n\n            comp->num_output_ptr++;\n\n            /* and reset the buffer pointers */\n            png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size;\n            png_ptr->zstream.next_out = png_ptr->zbuf;\n         }\n      }\n      else if (ret != Z_STREAM_END)\n      {\n         /* We got an error */\n         if (png_ptr->zstream.msg != NULL)\n            png_error(png_ptr, png_ptr->zstream.msg);\n\n         else\n            png_error(png_ptr, \"zlib error\");\n      }\n   } while (ret != Z_STREAM_END);\n\n   /* Text length is number of buffers plus last buffer */\n   text_len = png_ptr->zbuf_size * comp->num_output_ptr;\n\n   if (png_ptr->zstream.avail_out < png_ptr->zbuf_size)\n      text_len += png_ptr->zbuf_size - (png_size_t)png_ptr->zstream.avail_out;\n\n   return((int)text_len);\n}\n\n/* Ship the compressed text out via chunk writes */\nstatic void /* PRIVATE */\npng_write_compressed_data_out(png_structp png_ptr, compression_state *comp)\n{\n   int i;\n\n   /* Handle the no-compression case */\n   if (comp->input)\n   {\n      png_write_chunk_data(png_ptr, comp->input, comp->input_len);\n\n      return;\n   }\n\n#ifdef PNG_WRITE_OPTIMIZE_CMF_SUPPORTED\n   /* The zbuf_size test is because the code below doesn't work if zbuf_size is\n    * '1'; simply skip it to avoid memory overwrite.\n    */\n   if (comp->input_len >= 2 && comp->input_len < 16384 && png_ptr->zbuf_size > 1)\n   {\n      unsigned int z_cmf;  /* zlib compression method and flags */\n\n      /* Optimize the CMF field in the zlib stream.  This hack of the zlib\n       * stream is compliant to the stream specification.\n       */\n\n      if (comp->num_output_ptr)\n        z_cmf = comp->output_ptr[0][0];\n      else\n        z_cmf = png_ptr->zbuf[0];\n\n      if ((z_cmf & 0x0f) == 8 && (z_cmf & 0xf0) <= 0x70)\n      {\n         unsigned int z_cinfo;\n         unsigned int half_z_window_size;\n         png_size_t uncompressed_text_size = comp->input_len;\n\n         z_cinfo = z_cmf >> 4;\n         half_z_window_size = 1 << (z_cinfo + 7);\n\n         while (uncompressed_text_size <= half_z_window_size &&\n             half_z_window_size >= 256)\n         {\n            z_cinfo--;\n            half_z_window_size >>= 1;\n         }\n\n         z_cmf = (z_cmf & 0x0f) | (z_cinfo << 4);\n\n         if (comp->num_output_ptr)\n         {\n\n           if (comp->output_ptr[0][0] != z_cmf)\n           {\n              int tmp;\n\n              comp->output_ptr[0][0] = (png_byte)z_cmf;\n              tmp = comp->output_ptr[0][1] & 0xe0;\n              tmp += 0x1f - ((z_cmf << 8) + tmp) % 0x1f;\n              comp->output_ptr[0][1] = (png_byte)tmp;\n           }\n         }\n         else\n         {\n            int tmp;\n\n            png_ptr->zbuf[0] = (png_byte)z_cmf;\n            tmp = png_ptr->zbuf[1] & 0xe0;\n            tmp += 0x1f - ((z_cmf << 8) + tmp) % 0x1f;\n            png_ptr->zbuf[1] = (png_byte)tmp;\n         }\n      }\n\n      else\n         png_error(png_ptr,\n             \"Invalid zlib compression method or flags in non-IDAT chunk\");\n   }\n#endif /* PNG_WRITE_OPTIMIZE_CMF_SUPPORTED */\n\n   /* Write saved output buffers, if any */\n   for (i = 0; i < comp->num_output_ptr; i++)\n   {\n      png_write_chunk_data(png_ptr, comp->output_ptr[i],\n          (png_size_t)png_ptr->zbuf_size);\n\n      png_free(png_ptr, comp->output_ptr[i]);\n   }\n\n   if (comp->max_output_ptr != 0)\n      png_free(png_ptr, comp->output_ptr);\n\n   /* Write anything left in zbuf */\n   if (png_ptr->zstream.avail_out < (png_uint_32)png_ptr->zbuf_size)\n      png_write_chunk_data(png_ptr, png_ptr->zbuf,\n          (png_size_t)(png_ptr->zbuf_size - png_ptr->zstream.avail_out));\n\n   /* Reset zlib for another zTXt/iTXt or image data */\n   png_zlib_release(png_ptr);\n}\n#endif /* PNG_WRITE_COMPRESSED_TEXT_SUPPORTED */\n\n/* Write the IHDR chunk, and update the png_struct with the necessary\n * information.  Note that the rest of this code depends upon this\n * information being correct.\n */\nvoid /* PRIVATE */\npng_write_IHDR(png_structp png_ptr, png_uint_32 width, png_uint_32 height,\n    int bit_depth, int color_type, int compression_type, int filter_type,\n    int interlace_type)\n{\n   png_byte buf[13]; /* Buffer to store the IHDR info */\n\n   png_debug(1, \"in png_write_IHDR\");\n\n   /* Check that we have valid input data from the application info */\n   switch (color_type)\n   {\n      case PNG_COLOR_TYPE_GRAY:\n         switch (bit_depth)\n         {\n            case 1:\n            case 2:\n            case 4:\n            case 8:\n#ifdef PNG_WRITE_16BIT_SUPPORTED\n            case 16:\n#endif\n               png_ptr->channels = 1; break;\n\n            default:\n               png_error(png_ptr,\n                   \"Invalid bit depth for grayscale image\");\n         }\n         break;\n\n      case PNG_COLOR_TYPE_RGB:\n#ifdef PNG_WRITE_16BIT_SUPPORTED\n         if (bit_depth != 8 && bit_depth != 16)\n#else\n         if (bit_depth != 8)\n#endif\n            png_error(png_ptr, \"Invalid bit depth for RGB image\");\n\n         png_ptr->channels = 3;\n         break;\n\n      case PNG_COLOR_TYPE_PALETTE:\n         switch (bit_depth)\n         {\n            case 1:\n            case 2:\n            case 4:\n            case 8:\n               png_ptr->channels = 1;\n               break;\n\n            default:\n               png_error(png_ptr, \"Invalid bit depth for paletted image\");\n         }\n         break;\n\n      case PNG_COLOR_TYPE_GRAY_ALPHA:\n         if (bit_depth != 8 && bit_depth != 16)\n            png_error(png_ptr, \"Invalid bit depth for grayscale+alpha image\");\n\n         png_ptr->channels = 2;\n         break;\n\n      case PNG_COLOR_TYPE_RGB_ALPHA:\n#ifdef PNG_WRITE_16BIT_SUPPORTED\n         if (bit_depth != 8 && bit_depth != 16)\n#else\n         if (bit_depth != 8)\n#endif\n            png_error(png_ptr, \"Invalid bit depth for RGBA image\");\n\n         png_ptr->channels = 4;\n         break;\n\n      default:\n         png_error(png_ptr, \"Invalid image color type specified\");\n   }\n\n   if (compression_type != PNG_COMPRESSION_TYPE_BASE)\n   {\n      png_warning(png_ptr, \"Invalid compression type specified\");\n      compression_type = PNG_COMPRESSION_TYPE_BASE;\n   }\n\n   /* Write filter_method 64 (intrapixel differencing) only if\n    * 1. Libpng was compiled with PNG_MNG_FEATURES_SUPPORTED and\n    * 2. Libpng did not write a PNG signature (this filter_method is only\n    *    used in PNG datastreams that are embedded in MNG datastreams) and\n    * 3. The application called png_permit_mng_features with a mask that\n    *    included PNG_FLAG_MNG_FILTER_64 and\n    * 4. The filter_method is 64 and\n    * 5. The color_type is RGB or RGBA\n    */\n   if (\n#ifdef PNG_MNG_FEATURES_SUPPORTED\n       !((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) &&\n       ((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE) == 0) &&\n       (color_type == PNG_COLOR_TYPE_RGB ||\n        color_type == PNG_COLOR_TYPE_RGB_ALPHA) &&\n       (filter_type == PNG_INTRAPIXEL_DIFFERENCING)) &&\n#endif\n       filter_type != PNG_FILTER_TYPE_BASE)\n   {\n      png_warning(png_ptr, \"Invalid filter type specified\");\n      filter_type = PNG_FILTER_TYPE_BASE;\n   }\n\n#ifdef PNG_WRITE_INTERLACING_SUPPORTED\n   if (interlace_type != PNG_INTERLACE_NONE &&\n       interlace_type != PNG_INTERLACE_ADAM7)\n   {\n      png_warning(png_ptr, \"Invalid interlace type specified\");\n      interlace_type = PNG_INTERLACE_ADAM7;\n   }\n#else\n   interlace_type=PNG_INTERLACE_NONE;\n#endif\n\n   /* Save the relevent information */\n   png_ptr->bit_depth = (png_byte)bit_depth;\n   png_ptr->color_type = (png_byte)color_type;\n   png_ptr->interlaced = (png_byte)interlace_type;\n#ifdef PNG_MNG_FEATURES_SUPPORTED\n   png_ptr->filter_type = (png_byte)filter_type;\n#endif\n   png_ptr->compression_type = (png_byte)compression_type;\n   png_ptr->width = width;\n   png_ptr->height = height;\n\n   png_ptr->pixel_depth = (png_byte)(bit_depth * png_ptr->channels);\n   png_ptr->rowbytes = PNG_ROWBYTES(png_ptr->pixel_depth, width);\n   /* Set the usr info, so any transformations can modify it */\n   png_ptr->usr_width = png_ptr->width;\n   png_ptr->usr_bit_depth = png_ptr->bit_depth;\n   png_ptr->usr_channels = png_ptr->channels;\n\n   /* Pack the header information into the buffer */\n   png_save_uint_32(buf, width);\n   png_save_uint_32(buf + 4, height);\n   buf[8] = (png_byte)bit_depth;\n   buf[9] = (png_byte)color_type;\n   buf[10] = (png_byte)compression_type;\n   buf[11] = (png_byte)filter_type;\n   buf[12] = (png_byte)interlace_type;\n\n   /* Write the chunk */\n   png_write_complete_chunk(png_ptr, png_IHDR, buf, (png_size_t)13);\n\n   /* Initialize zlib with PNG info */\n   png_ptr->zstream.zalloc = png_zalloc;\n   png_ptr->zstream.zfree = png_zfree;\n   png_ptr->zstream.opaque = (voidpf)png_ptr;\n\n   if (!(png_ptr->do_filter))\n   {\n      if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE ||\n          png_ptr->bit_depth < 8)\n         png_ptr->do_filter = PNG_FILTER_NONE;\n\n      else\n         png_ptr->do_filter = PNG_ALL_FILTERS;\n   }\n\n   if (!(png_ptr->flags & PNG_FLAG_ZLIB_CUSTOM_STRATEGY))\n   {\n      if (png_ptr->do_filter != PNG_FILTER_NONE)\n         png_ptr->zlib_strategy = Z_FILTERED;\n\n      else\n         png_ptr->zlib_strategy = Z_DEFAULT_STRATEGY;\n   }\n\n   if (!(png_ptr->flags & PNG_FLAG_ZLIB_CUSTOM_LEVEL))\n      png_ptr->zlib_level = Z_DEFAULT_COMPRESSION;\n\n   if (!(png_ptr->flags & PNG_FLAG_ZLIB_CUSTOM_MEM_LEVEL))\n      png_ptr->zlib_mem_level = 8;\n\n   if (!(png_ptr->flags & PNG_FLAG_ZLIB_CUSTOM_WINDOW_BITS))\n      png_ptr->zlib_window_bits = 15;\n\n   if (!(png_ptr->flags & PNG_FLAG_ZLIB_CUSTOM_METHOD))\n      png_ptr->zlib_method = 8;\n\n#ifdef PNG_WRITE_COMPRESSED_TEXT_SUPPORTED\n#ifdef PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED\n   if (!(png_ptr->flags & PNG_FLAG_ZTXT_CUSTOM_STRATEGY))\n      png_ptr->zlib_text_strategy = Z_DEFAULT_STRATEGY;\n\n   if (!(png_ptr->flags & PNG_FLAG_ZTXT_CUSTOM_LEVEL))\n      png_ptr->zlib_text_level = png_ptr->zlib_level;\n\n   if (!(png_ptr->flags & PNG_FLAG_ZTXT_CUSTOM_MEM_LEVEL))\n      png_ptr->zlib_text_mem_level = png_ptr->zlib_mem_level;\n\n   if (!(png_ptr->flags & PNG_FLAG_ZTXT_CUSTOM_WINDOW_BITS))\n      png_ptr->zlib_text_window_bits = png_ptr->zlib_window_bits;\n\n   if (!(png_ptr->flags & PNG_FLAG_ZTXT_CUSTOM_METHOD))\n      png_ptr->zlib_text_method = png_ptr->zlib_method;\n#else\n   png_ptr->zlib_text_strategy = Z_DEFAULT_STRATEGY;\n   png_ptr->zlib_text_level = png_ptr->zlib_level;\n   png_ptr->zlib_text_mem_level = png_ptr->zlib_mem_level;\n   png_ptr->zlib_text_window_bits = png_ptr->zlib_window_bits;\n   png_ptr->zlib_text_method = png_ptr->zlib_method;\n#endif /* PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED */\n#endif /* PNG_WRITE_COMPRESSED_TEXT_SUPPORTED */\n\n   /* Record that the compressor has not yet been initialized. */\n   png_ptr->zlib_state = PNG_ZLIB_UNINITIALIZED;\n\n   png_ptr->mode = PNG_HAVE_IHDR; /* not READY_FOR_ZTXT */\n}\n\n/* Write the palette.  We are careful not to trust png_color to be in the\n * correct order for PNG, so people can redefine it to any convenient\n * structure.\n */\nvoid /* PRIVATE */\npng_write_PLTE(png_structp png_ptr, png_const_colorp palette,\n    png_uint_32 num_pal)\n{\n   png_uint_32 i;\n   png_const_colorp pal_ptr;\n   png_byte buf[3];\n\n   png_debug(1, \"in png_write_PLTE\");\n\n   if ((\n#ifdef PNG_MNG_FEATURES_SUPPORTED\n       !(png_ptr->mng_features_permitted & PNG_FLAG_MNG_EMPTY_PLTE) &&\n#endif\n       num_pal == 0) || num_pal > 256)\n   {\n      if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)\n      {\n         png_error(png_ptr, \"Invalid number of colors in palette\");\n      }\n\n      else\n      {\n         png_warning(png_ptr, \"Invalid number of colors in palette\");\n         return;\n      }\n   }\n\n   if (!(png_ptr->color_type&PNG_COLOR_MASK_COLOR))\n   {\n      png_warning(png_ptr,\n          \"Ignoring request to write a PLTE chunk in grayscale PNG\");\n\n      return;\n   }\n\n   png_ptr->num_palette = (png_uint_16)num_pal;\n   png_debug1(3, \"num_palette = %d\", png_ptr->num_palette);\n\n   png_write_chunk_header(png_ptr, png_PLTE, (png_uint_32)(num_pal * 3));\n#ifdef PNG_POINTER_INDEXING_SUPPORTED\n\n   for (i = 0, pal_ptr = palette; i < num_pal; i++, pal_ptr++)\n   {\n      buf[0] = pal_ptr->red;\n      buf[1] = pal_ptr->green;\n      buf[2] = pal_ptr->blue;\n      png_write_chunk_data(png_ptr, buf, (png_size_t)3);\n   }\n\n#else\n   /* This is a little slower but some buggy compilers need to do this\n    * instead\n    */\n   pal_ptr=palette;\n\n   for (i = 0; i < num_pal; i++)\n   {\n      buf[0] = pal_ptr[i].red;\n      buf[1] = pal_ptr[i].green;\n      buf[2] = pal_ptr[i].blue;\n      png_write_chunk_data(png_ptr, buf, (png_size_t)3);\n   }\n\n#endif\n   png_write_chunk_end(png_ptr);\n   png_ptr->mode |= PNG_HAVE_PLTE;\n}\n\n/* Write an IDAT chunk */\nvoid /* PRIVATE */\npng_write_IDAT(png_structp png_ptr, png_bytep data, png_size_t length)\n{\n   png_debug(1, \"in png_write_IDAT\");\n\n#ifdef PNG_WRITE_OPTIMIZE_CMF_SUPPORTED\n   if (!(png_ptr->mode & PNG_HAVE_IDAT) &&\n       png_ptr->compression_type == PNG_COMPRESSION_TYPE_BASE)\n   {\n      /* Optimize the CMF field in the zlib stream.  This hack of the zlib\n       * stream is compliant to the stream specification.\n       */\n      unsigned int z_cmf = data[0];  /* zlib compression method and flags */\n\n      if ((z_cmf & 0x0f) == 8 && (z_cmf & 0xf0) <= 0x70)\n      {\n         /* Avoid memory underflows and multiplication overflows.\n          *\n          * The conditions below are practically always satisfied;\n          * however, they still must be checked.\n          */\n         if (length >= 2 &&\n             png_ptr->height < 16384 && png_ptr->width < 16384)\n         {\n            /* Compute the maximum possible length of the datastream */\n\n            /* Number of pixels, plus for each row a filter byte\n             * and possibly a padding byte, so increase the maximum\n             * size to account for these.\n             */\n            unsigned int z_cinfo;\n            unsigned int half_z_window_size;\n            png_uint_32 uncompressed_idat_size = png_ptr->height *\n                ((png_ptr->width *\n                png_ptr->channels * png_ptr->bit_depth + 15) >> 3);\n\n            /* If it's interlaced, each block of 8 rows is sent as up to\n             * 14 rows, i.e., 6 additional rows, each with a filter byte\n             * and possibly a padding byte\n             */\n            if (png_ptr->interlaced)\n               uncompressed_idat_size += ((png_ptr->height + 7)/8) *\n                   (png_ptr->bit_depth < 8 ? 12 : 6);\n\n            z_cinfo = z_cmf >> 4;\n            half_z_window_size = 1 << (z_cinfo + 7);\n\n            while (uncompressed_idat_size <= half_z_window_size &&\n                half_z_window_size >= 256)\n            {\n               z_cinfo--;\n               half_z_window_size >>= 1;\n            }\n\n            z_cmf = (z_cmf & 0x0f) | (z_cinfo << 4);\n\n            if (data[0] != z_cmf)\n            {\n               int tmp;\n               data[0] = (png_byte)z_cmf;\n               tmp = data[1] & 0xe0;\n               tmp += 0x1f - ((z_cmf << 8) + tmp) % 0x1f;\n               data[1] = (png_byte)tmp;\n            }\n         }\n      }\n\n      else\n         png_error(png_ptr,\n             \"Invalid zlib compression method or flags in IDAT\");\n   }\n#endif /* PNG_WRITE_OPTIMIZE_CMF_SUPPORTED */\n\n   png_write_complete_chunk(png_ptr, png_IDAT, data, length);\n   png_ptr->mode |= PNG_HAVE_IDAT;\n\n   /* Prior to 1.5.4 this code was replicated in every caller (except at the\n    * end, where it isn't technically necessary).  Since this function has\n    * flushed the data we can safely reset the zlib output buffer here.\n    */\n   png_ptr->zstream.next_out = png_ptr->zbuf;\n   png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size;\n}\n\n/* Write an IEND chunk */\nvoid /* PRIVATE */\npng_write_IEND(png_structp png_ptr)\n{\n   png_debug(1, \"in png_write_IEND\");\n\n   png_write_complete_chunk(png_ptr, png_IEND, NULL, (png_size_t)0);\n   png_ptr->mode |= PNG_HAVE_IEND;\n}\n\n#ifdef PNG_WRITE_gAMA_SUPPORTED\n/* Write a gAMA chunk */\nvoid /* PRIVATE */\npng_write_gAMA_fixed(png_structp png_ptr, png_fixed_point file_gamma)\n{\n   png_byte buf[4];\n\n   png_debug(1, \"in png_write_gAMA\");\n\n   /* file_gamma is saved in 1/100,000ths */\n   png_save_uint_32(buf, (png_uint_32)file_gamma);\n   png_write_complete_chunk(png_ptr, png_gAMA, buf, (png_size_t)4);\n}\n#endif\n\n#ifdef PNG_WRITE_sRGB_SUPPORTED\n/* Write a sRGB chunk */\nvoid /* PRIVATE */\npng_write_sRGB(png_structp png_ptr, int srgb_intent)\n{\n   png_byte buf[1];\n\n   png_debug(1, \"in png_write_sRGB\");\n\n   if (srgb_intent >= PNG_sRGB_INTENT_LAST)\n      png_warning(png_ptr,\n          \"Invalid sRGB rendering intent specified\");\n\n   buf[0]=(png_byte)srgb_intent;\n   png_write_complete_chunk(png_ptr, png_sRGB, buf, (png_size_t)1);\n}\n#endif\n\n#ifdef PNG_WRITE_iCCP_SUPPORTED\n/* Write an iCCP chunk */\nvoid /* PRIVATE */\npng_write_iCCP(png_structp png_ptr, png_const_charp name, int compression_type,\n    png_const_charp profile, int profile_len)\n{\n   png_size_t name_len;\n   png_charp new_name;\n   compression_state comp;\n   int embedded_profile_len = 0;\n\n   png_debug(1, \"in png_write_iCCP\");\n\n   comp.num_output_ptr = 0;\n   comp.max_output_ptr = 0;\n   comp.output_ptr = NULL;\n   comp.input = NULL;\n   comp.input_len = 0;\n\n   if ((name_len = png_check_keyword(png_ptr, name, &new_name)) == 0)\n      return;\n\n   if (compression_type != PNG_COMPRESSION_TYPE_BASE)\n      png_warning(png_ptr, \"Unknown compression type in iCCP chunk\");\n\n   if (profile == NULL)\n      profile_len = 0;\n\n   if (profile_len > 3)\n      embedded_profile_len =\n          ((*( (png_const_bytep)profile    ))<<24) |\n          ((*( (png_const_bytep)profile + 1))<<16) |\n          ((*( (png_const_bytep)profile + 2))<< 8) |\n          ((*( (png_const_bytep)profile + 3))    );\n\n   if (embedded_profile_len < 0)\n   {\n      png_warning(png_ptr,\n          \"Embedded profile length in iCCP chunk is negative\");\n\n      png_free(png_ptr, new_name);\n      return;\n   }\n\n   if (profile_len < embedded_profile_len)\n   {\n      png_warning(png_ptr,\n          \"Embedded profile length too large in iCCP chunk\");\n\n      png_free(png_ptr, new_name);\n      return;\n   }\n\n   if (profile_len > embedded_profile_len)\n   {\n      png_warning(png_ptr,\n          \"Truncating profile to actual length in iCCP chunk\");\n\n      profile_len = embedded_profile_len;\n   }\n\n   if (profile_len)\n      profile_len = png_text_compress(png_ptr, profile,\n          (png_size_t)profile_len, PNG_COMPRESSION_TYPE_BASE, &comp);\n\n   /* Make sure we include the NULL after the name and the compression type */\n   png_write_chunk_header(png_ptr, png_iCCP,\n       (png_uint_32)(name_len + profile_len + 2));\n\n   new_name[name_len + 1] = 0x00;\n\n   png_write_chunk_data(png_ptr, (png_bytep)new_name,\n       (png_size_t)(name_len + 2));\n\n   if (profile_len)\n   {\n      comp.input_len = profile_len;\n      png_write_compressed_data_out(png_ptr, &comp);\n   }\n\n   png_write_chunk_end(png_ptr);\n   png_free(png_ptr, new_name);\n}\n#endif\n\n#ifdef PNG_WRITE_sPLT_SUPPORTED\n/* Write a sPLT chunk */\nvoid /* PRIVATE */\npng_write_sPLT(png_structp png_ptr, png_const_sPLT_tp spalette)\n{\n   png_size_t name_len;\n   png_charp new_name;\n   png_byte entrybuf[10];\n   png_size_t entry_size = (spalette->depth == 8 ? 6 : 10);\n   png_size_t palette_size = entry_size * spalette->nentries;\n   png_sPLT_entryp ep;\n#ifndef PNG_POINTER_INDEXING_SUPPORTED\n   int i;\n#endif\n\n   png_debug(1, \"in png_write_sPLT\");\n\n   if ((name_len = png_check_keyword(png_ptr,spalette->name, &new_name))==0)\n      return;\n\n   /* Make sure we include the NULL after the name */\n   png_write_chunk_header(png_ptr, png_sPLT,\n       (png_uint_32)(name_len + 2 + palette_size));\n\n   png_write_chunk_data(png_ptr, (png_bytep)new_name,\n       (png_size_t)(name_len + 1));\n\n   png_write_chunk_data(png_ptr, &spalette->depth, (png_size_t)1);\n\n   /* Loop through each palette entry, writing appropriately */\n#ifdef PNG_POINTER_INDEXING_SUPPORTED\n   for (ep = spalette->entries; ep<spalette->entries + spalette->nentries; ep++)\n   {\n      if (spalette->depth == 8)\n      {\n         entrybuf[0] = (png_byte)ep->red;\n         entrybuf[1] = (png_byte)ep->green;\n         entrybuf[2] = (png_byte)ep->blue;\n         entrybuf[3] = (png_byte)ep->alpha;\n         png_save_uint_16(entrybuf + 4, ep->frequency);\n      }\n\n      else\n      {\n         png_save_uint_16(entrybuf + 0, ep->red);\n         png_save_uint_16(entrybuf + 2, ep->green);\n         png_save_uint_16(entrybuf + 4, ep->blue);\n         png_save_uint_16(entrybuf + 6, ep->alpha);\n         png_save_uint_16(entrybuf + 8, ep->frequency);\n      }\n\n      png_write_chunk_data(png_ptr, entrybuf, (png_size_t)entry_size);\n   }\n#else\n   ep=spalette->entries;\n   for (i = 0; i>spalette->nentries; i++)\n   {\n      if (spalette->depth == 8)\n      {\n         entrybuf[0] = (png_byte)ep[i].red;\n         entrybuf[1] = (png_byte)ep[i].green;\n         entrybuf[2] = (png_byte)ep[i].blue;\n         entrybuf[3] = (png_byte)ep[i].alpha;\n         png_save_uint_16(entrybuf + 4, ep[i].frequency);\n      }\n\n      else\n      {\n         png_save_uint_16(entrybuf + 0, ep[i].red);\n         png_save_uint_16(entrybuf + 2, ep[i].green);\n         png_save_uint_16(entrybuf + 4, ep[i].blue);\n         png_save_uint_16(entrybuf + 6, ep[i].alpha);\n         png_save_uint_16(entrybuf + 8, ep[i].frequency);\n      }\n\n      png_write_chunk_data(png_ptr, entrybuf, (png_size_t)entry_size);\n   }\n#endif\n\n   png_write_chunk_end(png_ptr);\n   png_free(png_ptr, new_name);\n}\n#endif\n\n#ifdef PNG_WRITE_sBIT_SUPPORTED\n/* Write the sBIT chunk */\nvoid /* PRIVATE */\npng_write_sBIT(png_structp png_ptr, png_const_color_8p sbit, int color_type)\n{\n   png_byte buf[4];\n   png_size_t size;\n\n   png_debug(1, \"in png_write_sBIT\");\n\n   /* Make sure we don't depend upon the order of PNG_COLOR_8 */\n   if (color_type & PNG_COLOR_MASK_COLOR)\n   {\n      png_byte maxbits;\n\n      maxbits = (png_byte)(color_type==PNG_COLOR_TYPE_PALETTE ? 8 :\n          png_ptr->usr_bit_depth);\n\n      if (sbit->red == 0 || sbit->red > maxbits ||\n          sbit->green == 0 || sbit->green > maxbits ||\n          sbit->blue == 0 || sbit->blue > maxbits)\n      {\n         png_warning(png_ptr, \"Invalid sBIT depth specified\");\n         return;\n      }\n\n      buf[0] = sbit->red;\n      buf[1] = sbit->green;\n      buf[2] = sbit->blue;\n      size = 3;\n   }\n\n   else\n   {\n      if (sbit->gray == 0 || sbit->gray > png_ptr->usr_bit_depth)\n      {\n         png_warning(png_ptr, \"Invalid sBIT depth specified\");\n         return;\n      }\n\n      buf[0] = sbit->gray;\n      size = 1;\n   }\n\n   if (color_type & PNG_COLOR_MASK_ALPHA)\n   {\n      if (sbit->alpha == 0 || sbit->alpha > png_ptr->usr_bit_depth)\n      {\n         png_warning(png_ptr, \"Invalid sBIT depth specified\");\n         return;\n      }\n\n      buf[size++] = sbit->alpha;\n   }\n\n   png_write_complete_chunk(png_ptr, png_sBIT, buf, size);\n}\n#endif\n\n#ifdef PNG_WRITE_cHRM_SUPPORTED\n/* Write the cHRM chunk */\nvoid /* PRIVATE */\npng_write_cHRM_fixed(png_structp png_ptr, png_fixed_point white_x,\n    png_fixed_point white_y, png_fixed_point red_x, png_fixed_point red_y,\n    png_fixed_point green_x, png_fixed_point green_y, png_fixed_point blue_x,\n    png_fixed_point blue_y)\n{\n   png_byte buf[32];\n\n   png_debug(1, \"in png_write_cHRM\");\n\n   /* Each value is saved in 1/100,000ths */\n#ifdef PNG_CHECK_cHRM_SUPPORTED\n   if (png_check_cHRM_fixed(png_ptr, white_x, white_y, red_x, red_y,\n       green_x, green_y, blue_x, blue_y))\n#endif\n   {\n      png_save_uint_32(buf, (png_uint_32)white_x);\n      png_save_uint_32(buf + 4, (png_uint_32)white_y);\n\n      png_save_uint_32(buf + 8, (png_uint_32)red_x);\n      png_save_uint_32(buf + 12, (png_uint_32)red_y);\n\n      png_save_uint_32(buf + 16, (png_uint_32)green_x);\n      png_save_uint_32(buf + 20, (png_uint_32)green_y);\n\n      png_save_uint_32(buf + 24, (png_uint_32)blue_x);\n      png_save_uint_32(buf + 28, (png_uint_32)blue_y);\n\n      png_write_complete_chunk(png_ptr, png_cHRM, buf, (png_size_t)32);\n   }\n}\n#endif\n\n#ifdef PNG_WRITE_tRNS_SUPPORTED\n/* Write the tRNS chunk */\nvoid /* PRIVATE */\npng_write_tRNS(png_structp png_ptr, png_const_bytep trans_alpha,\n    png_const_color_16p tran, int num_trans, int color_type)\n{\n   png_byte buf[6];\n\n   png_debug(1, \"in png_write_tRNS\");\n\n   if (color_type == PNG_COLOR_TYPE_PALETTE)\n   {\n      if (num_trans <= 0 || num_trans > (int)png_ptr->num_palette)\n      {\n         png_warning(png_ptr, \"Invalid number of transparent colors specified\");\n         return;\n      }\n\n      /* Write the chunk out as it is */\n      png_write_complete_chunk(png_ptr, png_tRNS, trans_alpha, (png_size_t)num_trans);\n   }\n\n   else if (color_type == PNG_COLOR_TYPE_GRAY)\n   {\n      /* One 16 bit value */\n      if (tran->gray >= (1 << png_ptr->bit_depth))\n      {\n         png_warning(png_ptr,\n             \"Ignoring attempt to write tRNS chunk out-of-range for bit_depth\");\n\n         return;\n      }\n\n      png_save_uint_16(buf, tran->gray);\n      png_write_complete_chunk(png_ptr, png_tRNS, buf, (png_size_t)2);\n   }\n\n   else if (color_type == PNG_COLOR_TYPE_RGB)\n   {\n      /* Three 16 bit values */\n      png_save_uint_16(buf, tran->red);\n      png_save_uint_16(buf + 2, tran->green);\n      png_save_uint_16(buf + 4, tran->blue);\n#ifdef PNG_WRITE_16BIT_SUPPORTED\n      if (png_ptr->bit_depth == 8 && (buf[0] | buf[2] | buf[4]))\n#else\n      if (buf[0] | buf[2] | buf[4])\n#endif\n      {\n         png_warning(png_ptr,\n           \"Ignoring attempt to write 16-bit tRNS chunk when bit_depth is 8\");\n         return;\n      }\n\n      png_write_complete_chunk(png_ptr, png_tRNS, buf, (png_size_t)6);\n   }\n\n   else\n   {\n      png_warning(png_ptr, \"Can't write tRNS with an alpha channel\");\n   }\n}\n#endif\n\n#ifdef PNG_WRITE_bKGD_SUPPORTED\n/* Write the background chunk */\nvoid /* PRIVATE */\npng_write_bKGD(png_structp png_ptr, png_const_color_16p back, int color_type)\n{\n   png_byte buf[6];\n\n   png_debug(1, \"in png_write_bKGD\");\n\n   if (color_type == PNG_COLOR_TYPE_PALETTE)\n   {\n      if (\n#ifdef PNG_MNG_FEATURES_SUPPORTED\n          (png_ptr->num_palette ||\n          (!(png_ptr->mng_features_permitted & PNG_FLAG_MNG_EMPTY_PLTE))) &&\n#endif\n         back->index >= png_ptr->num_palette)\n      {\n         png_warning(png_ptr, \"Invalid background palette index\");\n         return;\n      }\n\n      buf[0] = back->index;\n      png_write_complete_chunk(png_ptr, png_bKGD, buf, (png_size_t)1);\n   }\n\n   else if (color_type & PNG_COLOR_MASK_COLOR)\n   {\n      png_save_uint_16(buf, back->red);\n      png_save_uint_16(buf + 2, back->green);\n      png_save_uint_16(buf + 4, back->blue);\n#ifdef PNG_WRITE_16BIT_SUPPORTED\n      if (png_ptr->bit_depth == 8 && (buf[0] | buf[2] | buf[4]))\n#else\n      if (buf[0] | buf[2] | buf[4])\n#endif\n      {\n         png_warning(png_ptr,\n             \"Ignoring attempt to write 16-bit bKGD chunk when bit_depth is 8\");\n\n         return;\n      }\n\n      png_write_complete_chunk(png_ptr, png_bKGD, buf, (png_size_t)6);\n   }\n\n   else\n   {\n      if (back->gray >= (1 << png_ptr->bit_depth))\n      {\n         png_warning(png_ptr,\n             \"Ignoring attempt to write bKGD chunk out-of-range for bit_depth\");\n\n         return;\n      }\n\n      png_save_uint_16(buf, back->gray);\n      png_write_complete_chunk(png_ptr, png_bKGD, buf, (png_size_t)2);\n   }\n}\n#endif\n\n#ifdef PNG_WRITE_hIST_SUPPORTED\n/* Write the histogram */\nvoid /* PRIVATE */\npng_write_hIST(png_structp png_ptr, png_const_uint_16p hist, int num_hist)\n{\n   int i;\n   png_byte buf[3];\n\n   png_debug(1, \"in png_write_hIST\");\n\n   if (num_hist > (int)png_ptr->num_palette)\n   {\n      png_debug2(3, \"num_hist = %d, num_palette = %d\", num_hist,\n          png_ptr->num_palette);\n\n      png_warning(png_ptr, \"Invalid number of histogram entries specified\");\n      return;\n   }\n\n   png_write_chunk_header(png_ptr, png_hIST, (png_uint_32)(num_hist * 2));\n\n   for (i = 0; i < num_hist; i++)\n   {\n      png_save_uint_16(buf, hist[i]);\n      png_write_chunk_data(png_ptr, buf, (png_size_t)2);\n   }\n\n   png_write_chunk_end(png_ptr);\n}\n#endif\n\n#if defined(PNG_WRITE_TEXT_SUPPORTED) || defined(PNG_WRITE_pCAL_SUPPORTED) || \\\n    defined(PNG_WRITE_iCCP_SUPPORTED) || defined(PNG_WRITE_sPLT_SUPPORTED)\n/* Check that the tEXt or zTXt keyword is valid per PNG 1.0 specification,\n * and if invalid, correct the keyword rather than discarding the entire\n * chunk.  The PNG 1.0 specification requires keywords 1-79 characters in\n * length, forbids leading or trailing whitespace, multiple internal spaces,\n * and the non-break space (0x80) from ISO 8859-1.  Returns keyword length.\n *\n * The new_key is allocated to hold the corrected keyword and must be freed\n * by the calling routine.  This avoids problems with trying to write to\n * static keywords without having to have duplicate copies of the strings.\n */\npng_size_t /* PRIVATE */\npng_check_keyword(png_structp png_ptr, png_const_charp key, png_charpp new_key)\n{\n   png_size_t key_len;\n   png_const_charp ikp;\n   png_charp kp, dp;\n   int kflag;\n   int kwarn=0;\n\n   png_debug(1, \"in png_check_keyword\");\n\n   *new_key = NULL;\n\n   if (key == NULL || (key_len = png_strlen(key)) == 0)\n   {\n      png_warning(png_ptr, \"zero length keyword\");\n      return ((png_size_t)0);\n   }\n\n   png_debug1(2, \"Keyword to be checked is '%s'\", key);\n\n   *new_key = (png_charp)png_malloc_warn(png_ptr, (png_uint_32)(key_len + 2));\n\n   if (*new_key == NULL)\n   {\n      png_warning(png_ptr, \"Out of memory while procesing keyword\");\n      return ((png_size_t)0);\n   }\n\n   /* Replace non-printing characters with a blank and print a warning */\n   for (ikp = key, dp = *new_key; *ikp != '\\0'; ikp++, dp++)\n   {\n      if ((png_byte)*ikp < 0x20 ||\n         ((png_byte)*ikp > 0x7E && (png_byte)*ikp < 0xA1))\n      {\n         PNG_WARNING_PARAMETERS(p)\n\n         png_warning_parameter_unsigned(p, 1, PNG_NUMBER_FORMAT_02x,\n            (png_byte)*ikp);\n         png_formatted_warning(png_ptr, p, \"invalid keyword character 0x@1\");\n         *dp = ' ';\n      }\n\n      else\n      {\n         *dp = *ikp;\n      }\n   }\n   *dp = '\\0';\n\n   /* Remove any trailing white space. */\n   kp = *new_key + key_len - 1;\n   if (*kp == ' ')\n   {\n      png_warning(png_ptr, \"trailing spaces removed from keyword\");\n\n      while (*kp == ' ')\n      {\n         *(kp--) = '\\0';\n         key_len--;\n      }\n   }\n\n   /* Remove any leading white space. */\n   kp = *new_key;\n   if (*kp == ' ')\n   {\n      png_warning(png_ptr, \"leading spaces removed from keyword\");\n\n      while (*kp == ' ')\n      {\n         kp++;\n         key_len--;\n      }\n   }\n\n   png_debug1(2, \"Checking for multiple internal spaces in '%s'\", kp);\n\n   /* Remove multiple internal spaces. */\n   for (kflag = 0, dp = *new_key; *kp != '\\0'; kp++)\n   {\n      if (*kp == ' ' && kflag == 0)\n      {\n         *(dp++) = *kp;\n         kflag = 1;\n      }\n\n      else if (*kp == ' ')\n      {\n         key_len--;\n         kwarn = 1;\n      }\n\n      else\n      {\n         *(dp++) = *kp;\n         kflag = 0;\n      }\n   }\n   *dp = '\\0';\n   if (kwarn)\n      png_warning(png_ptr, \"extra interior spaces removed from keyword\");\n\n   if (key_len == 0)\n   {\n      png_free(png_ptr, *new_key);\n      png_warning(png_ptr, \"Zero length keyword\");\n   }\n\n   if (key_len > 79)\n   {\n      png_warning(png_ptr, \"keyword length must be 1 - 79 characters\");\n      (*new_key)[79] = '\\0';\n      key_len = 79;\n   }\n\n   return (key_len);\n}\n#endif\n\n#ifdef PNG_WRITE_tEXt_SUPPORTED\n/* Write a tEXt chunk */\nvoid /* PRIVATE */\npng_write_tEXt(png_structp png_ptr, png_const_charp key, png_const_charp text,\n    png_size_t text_len)\n{\n   png_size_t key_len;\n   png_charp new_key;\n\n   png_debug(1, \"in png_write_tEXt\");\n\n   if ((key_len = png_check_keyword(png_ptr, key, &new_key))==0)\n      return;\n\n   if (text == NULL || *text == '\\0')\n      text_len = 0;\n\n   else\n      text_len = png_strlen(text);\n\n   /* Make sure we include the 0 after the key */\n   png_write_chunk_header(png_ptr, png_tEXt,\n       (png_uint_32)(key_len + text_len + 1));\n   /*\n    * We leave it to the application to meet PNG-1.0 requirements on the\n    * contents of the text.  PNG-1.0 through PNG-1.2 discourage the use of\n    * any non-Latin-1 characters except for NEWLINE.  ISO PNG will forbid them.\n    * The NUL character is forbidden by PNG-1.0 through PNG-1.2 and ISO PNG.\n    */\n   png_write_chunk_data(png_ptr, (png_bytep)new_key,\n       (png_size_t)(key_len + 1));\n\n   if (text_len)\n      png_write_chunk_data(png_ptr, (png_const_bytep)text,\n          (png_size_t)text_len);\n\n   png_write_chunk_end(png_ptr);\n   png_free(png_ptr, new_key);\n}\n#endif\n\n#ifdef PNG_WRITE_zTXt_SUPPORTED\n/* Write a compressed text chunk */\nvoid /* PRIVATE */\npng_write_zTXt(png_structp png_ptr, png_const_charp key, png_const_charp text,\n    png_size_t text_len, int compression)\n{\n   png_size_t key_len;\n   png_byte buf;\n   png_charp new_key;\n   compression_state comp;\n\n   png_debug(1, \"in png_write_zTXt\");\n\n   comp.num_output_ptr = 0;\n   comp.max_output_ptr = 0;\n   comp.output_ptr = NULL;\n   comp.input = NULL;\n   comp.input_len = 0;\n\n   if ((key_len = png_check_keyword(png_ptr, key, &new_key)) == 0)\n   {\n      png_free(png_ptr, new_key);\n      return;\n   }\n\n   if (text == NULL || *text == '\\0' || compression==PNG_TEXT_COMPRESSION_NONE)\n   {\n      png_write_tEXt(png_ptr, new_key, text, (png_size_t)0);\n      png_free(png_ptr, new_key);\n      return;\n   }\n\n   text_len = png_strlen(text);\n\n   /* Compute the compressed data; do it now for the length */\n   text_len = png_text_compress(png_ptr, text, text_len, compression,\n       &comp);\n\n   /* Write start of chunk */\n   png_write_chunk_header(png_ptr, png_zTXt,\n       (png_uint_32)(key_len+text_len + 2));\n\n   /* Write key */\n   png_write_chunk_data(png_ptr, (png_bytep)new_key,\n       (png_size_t)(key_len + 1));\n\n   png_free(png_ptr, new_key);\n\n   buf = (png_byte)compression;\n\n   /* Write compression */\n   png_write_chunk_data(png_ptr, &buf, (png_size_t)1);\n\n   /* Write the compressed data */\n   comp.input_len = text_len;\n   png_write_compressed_data_out(png_ptr, &comp);\n\n   /* Close the chunk */\n   png_write_chunk_end(png_ptr);\n}\n#endif\n\n#ifdef PNG_WRITE_iTXt_SUPPORTED\n/* Write an iTXt chunk */\nvoid /* PRIVATE */\npng_write_iTXt(png_structp png_ptr, int compression, png_const_charp key,\n    png_const_charp lang, png_const_charp lang_key, png_const_charp text)\n{\n   png_size_t lang_len, key_len, lang_key_len, text_len;\n   png_charp new_lang;\n   png_charp new_key = NULL;\n   png_byte cbuf[2];\n   compression_state comp;\n\n   png_debug(1, \"in png_write_iTXt\");\n\n   comp.num_output_ptr = 0;\n   comp.max_output_ptr = 0;\n   comp.output_ptr = NULL;\n   comp.input = NULL;\n\n   if ((key_len = png_check_keyword(png_ptr, key, &new_key)) == 0)\n      return;\n\n   if ((lang_len = png_check_keyword(png_ptr, lang, &new_lang)) == 0)\n   {\n      png_warning(png_ptr, \"Empty language field in iTXt chunk\");\n      new_lang = NULL;\n      lang_len = 0;\n   }\n\n   if (lang_key == NULL)\n      lang_key_len = 0;\n\n   else\n      lang_key_len = png_strlen(lang_key);\n\n   if (text == NULL)\n      text_len = 0;\n\n   else\n      text_len = png_strlen(text);\n\n   /* Compute the compressed data; do it now for the length */\n   text_len = png_text_compress(png_ptr, text, text_len, compression - 2,\n       &comp);\n\n\n   /* Make sure we include the compression flag, the compression byte,\n    * and the NULs after the key, lang, and lang_key parts\n    */\n\n   png_write_chunk_header(png_ptr, png_iTXt, (png_uint_32)(\n        5 /* comp byte, comp flag, terminators for key, lang and lang_key */\n        + key_len\n        + lang_len\n        + lang_key_len\n        + text_len));\n\n   /* We leave it to the application to meet PNG-1.0 requirements on the\n    * contents of the text.  PNG-1.0 through PNG-1.2 discourage the use of\n    * any non-Latin-1 characters except for NEWLINE.  ISO PNG will forbid them.\n    * The NUL character is forbidden by PNG-1.0 through PNG-1.2 and ISO PNG.\n    */\n   png_write_chunk_data(png_ptr, (png_bytep)new_key, (png_size_t)(key_len + 1));\n\n   /* Set the compression flag */\n   if (compression == PNG_ITXT_COMPRESSION_NONE ||\n       compression == PNG_TEXT_COMPRESSION_NONE)\n      cbuf[0] = 0;\n\n   else /* compression == PNG_ITXT_COMPRESSION_zTXt */\n      cbuf[0] = 1;\n\n   /* Set the compression method */\n   cbuf[1] = 0;\n\n   png_write_chunk_data(png_ptr, cbuf, (png_size_t)2);\n\n   cbuf[0] = 0;\n   png_write_chunk_data(png_ptr, (new_lang ? (png_const_bytep)new_lang : cbuf),\n       (png_size_t)(lang_len + 1));\n\n   png_write_chunk_data(png_ptr, (lang_key ? (png_const_bytep)lang_key : cbuf),\n       (png_size_t)(lang_key_len + 1));\n\n   png_write_compressed_data_out(png_ptr, &comp);\n\n   png_write_chunk_end(png_ptr);\n\n   png_free(png_ptr, new_key);\n   png_free(png_ptr, new_lang);\n}\n#endif\n\n#ifdef PNG_WRITE_oFFs_SUPPORTED\n/* Write the oFFs chunk */\nvoid /* PRIVATE */\npng_write_oFFs(png_structp png_ptr, png_int_32 x_offset, png_int_32 y_offset,\n    int unit_type)\n{\n   png_byte buf[9];\n\n   png_debug(1, \"in png_write_oFFs\");\n\n   if (unit_type >= PNG_OFFSET_LAST)\n      png_warning(png_ptr, \"Unrecognized unit type for oFFs chunk\");\n\n   png_save_int_32(buf, x_offset);\n   png_save_int_32(buf + 4, y_offset);\n   buf[8] = (png_byte)unit_type;\n\n   png_write_complete_chunk(png_ptr, png_oFFs, buf, (png_size_t)9);\n}\n#endif\n#ifdef PNG_WRITE_pCAL_SUPPORTED\n/* Write the pCAL chunk (described in the PNG extensions document) */\nvoid /* PRIVATE */\npng_write_pCAL(png_structp png_ptr, png_charp purpose, png_int_32 X0,\n    png_int_32 X1, int type, int nparams, png_const_charp units,\n    png_charpp params)\n{\n   png_size_t purpose_len, units_len, total_len;\n   png_size_tp params_len;\n   png_byte buf[10];\n   png_charp new_purpose;\n   int i;\n\n   png_debug1(1, \"in png_write_pCAL (%d parameters)\", nparams);\n\n   if (type >= PNG_EQUATION_LAST)\n      png_warning(png_ptr, \"Unrecognized equation type for pCAL chunk\");\n\n   purpose_len = png_check_keyword(png_ptr, purpose, &new_purpose) + 1;\n   png_debug1(3, \"pCAL purpose length = %d\", (int)purpose_len);\n   units_len = png_strlen(units) + (nparams == 0 ? 0 : 1);\n   png_debug1(3, \"pCAL units length = %d\", (int)units_len);\n   total_len = purpose_len + units_len + 10;\n\n   params_len = (png_size_tp)png_malloc(png_ptr,\n       (png_alloc_size_t)(nparams * png_sizeof(png_size_t)));\n\n   /* Find the length of each parameter, making sure we don't count the\n    * null terminator for the last parameter.\n    */\n   for (i = 0; i < nparams; i++)\n   {\n      params_len[i] = png_strlen(params[i]) + (i == nparams - 1 ? 0 : 1);\n      png_debug2(3, \"pCAL parameter %d length = %lu\", i,\n          (unsigned long)params_len[i]);\n      total_len += params_len[i];\n   }\n\n   png_debug1(3, \"pCAL total length = %d\", (int)total_len);\n   png_write_chunk_header(png_ptr, png_pCAL, (png_uint_32)total_len);\n   png_write_chunk_data(png_ptr, (png_const_bytep)new_purpose, purpose_len);\n   png_save_int_32(buf, X0);\n   png_save_int_32(buf + 4, X1);\n   buf[8] = (png_byte)type;\n   buf[9] = (png_byte)nparams;\n   png_write_chunk_data(png_ptr, buf, (png_size_t)10);\n   png_write_chunk_data(png_ptr, (png_const_bytep)units, (png_size_t)units_len);\n\n   png_free(png_ptr, new_purpose);\n\n   for (i = 0; i < nparams; i++)\n   {\n      png_write_chunk_data(png_ptr, (png_const_bytep)params[i], params_len[i]);\n   }\n\n   png_free(png_ptr, params_len);\n   png_write_chunk_end(png_ptr);\n}\n#endif\n\n#ifdef PNG_WRITE_sCAL_SUPPORTED\n/* Write the sCAL chunk */\nvoid /* PRIVATE */\npng_write_sCAL_s(png_structp png_ptr, int unit, png_const_charp width,\n    png_const_charp height)\n{\n   png_byte buf[64];\n   png_size_t wlen, hlen, total_len;\n\n   png_debug(1, \"in png_write_sCAL_s\");\n\n   wlen = png_strlen(width);\n   hlen = png_strlen(height);\n   total_len = wlen + hlen + 2;\n\n   if (total_len > 64)\n   {\n      png_warning(png_ptr, \"Can't write sCAL (buffer too small)\");\n      return;\n   }\n\n   buf[0] = (png_byte)unit;\n   png_memcpy(buf + 1, width, wlen + 1);      /* Append the '\\0' here */\n   png_memcpy(buf + wlen + 2, height, hlen);  /* Do NOT append the '\\0' here */\n\n   png_debug1(3, \"sCAL total length = %u\", (unsigned int)total_len);\n   png_write_complete_chunk(png_ptr, png_sCAL, buf, total_len);\n}\n#endif\n\n#ifdef PNG_WRITE_pHYs_SUPPORTED\n/* Write the pHYs chunk */\nvoid /* PRIVATE */\npng_write_pHYs(png_structp png_ptr, png_uint_32 x_pixels_per_unit,\n    png_uint_32 y_pixels_per_unit,\n    int unit_type)\n{\n   png_byte buf[9];\n\n   png_debug(1, \"in png_write_pHYs\");\n\n   if (unit_type >= PNG_RESOLUTION_LAST)\n      png_warning(png_ptr, \"Unrecognized unit type for pHYs chunk\");\n\n   png_save_uint_32(buf, x_pixels_per_unit);\n   png_save_uint_32(buf + 4, y_pixels_per_unit);\n   buf[8] = (png_byte)unit_type;\n\n   png_write_complete_chunk(png_ptr, png_pHYs, buf, (png_size_t)9);\n}\n#endif\n\n#ifdef PNG_WRITE_tIME_SUPPORTED\n/* Write the tIME chunk.  Use either png_convert_from_struct_tm()\n * or png_convert_from_time_t(), or fill in the structure yourself.\n */\nvoid /* PRIVATE */\npng_write_tIME(png_structp png_ptr, png_const_timep mod_time)\n{\n   png_byte buf[7];\n\n   png_debug(1, \"in png_write_tIME\");\n\n   if (mod_time->month  > 12 || mod_time->month  < 1 ||\n       mod_time->day    > 31 || mod_time->day    < 1 ||\n       mod_time->hour   > 23 || mod_time->second > 60)\n   {\n      png_warning(png_ptr, \"Invalid time specified for tIME chunk\");\n      return;\n   }\n\n   png_save_uint_16(buf, mod_time->year);\n   buf[2] = mod_time->month;\n   buf[3] = mod_time->day;\n   buf[4] = mod_time->hour;\n   buf[5] = mod_time->minute;\n   buf[6] = mod_time->second;\n\n   png_write_complete_chunk(png_ptr, png_tIME, buf, (png_size_t)7);\n}\n#endif\n\n/* Initializes the row writing capability of libpng */\nvoid /* PRIVATE */\npng_write_start_row(png_structp png_ptr)\n{\n#ifdef PNG_WRITE_INTERLACING_SUPPORTED\n   /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */\n\n   /* Start of interlace block */\n   static PNG_CONST png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};\n\n   /* Offset to next interlace block */\n   static PNG_CONST png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};\n\n   /* Start of interlace block in the y direction */\n   static PNG_CONST png_byte png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1};\n\n   /* Offset to next interlace block in the y direction */\n   static PNG_CONST png_byte png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};\n#endif\n\n   png_alloc_size_t buf_size;\n   int usr_pixel_depth;\n\n   png_debug(1, \"in png_write_start_row\");\n\n   usr_pixel_depth = png_ptr->usr_channels * png_ptr->usr_bit_depth;\n   buf_size = PNG_ROWBYTES(usr_pixel_depth, png_ptr->width) + 1;\n\n   /* 1.5.6: added to allow checking in the row write code. */\n   png_ptr->transformed_pixel_depth = png_ptr->pixel_depth;\n   png_ptr->maximum_pixel_depth = (png_byte)usr_pixel_depth;\n\n   /* Set up row buffer */\n   png_ptr->row_buf = (png_bytep)png_malloc(png_ptr, buf_size);\n\n   png_ptr->row_buf[0] = PNG_FILTER_VALUE_NONE;\n\n#ifdef PNG_WRITE_FILTER_SUPPORTED\n   /* Set up filtering buffer, if using this filter */\n   if (png_ptr->do_filter & PNG_FILTER_SUB)\n   {\n      png_ptr->sub_row = (png_bytep)png_malloc(png_ptr, png_ptr->rowbytes + 1);\n\n      png_ptr->sub_row[0] = PNG_FILTER_VALUE_SUB;\n   }\n\n   /* We only need to keep the previous row if we are using one of these. */\n   if (png_ptr->do_filter & (PNG_FILTER_AVG | PNG_FILTER_UP | PNG_FILTER_PAETH))\n   {\n      /* Set up previous row buffer */\n      png_ptr->prev_row = (png_bytep)png_calloc(png_ptr, buf_size);\n\n      if (png_ptr->do_filter & PNG_FILTER_UP)\n      {\n         png_ptr->up_row = (png_bytep)png_malloc(png_ptr,\n            png_ptr->rowbytes + 1);\n\n         png_ptr->up_row[0] = PNG_FILTER_VALUE_UP;\n      }\n\n      if (png_ptr->do_filter & PNG_FILTER_AVG)\n      {\n         png_ptr->avg_row = (png_bytep)png_malloc(png_ptr,\n             png_ptr->rowbytes + 1);\n\n         png_ptr->avg_row[0] = PNG_FILTER_VALUE_AVG;\n      }\n\n      if (png_ptr->do_filter & PNG_FILTER_PAETH)\n      {\n         png_ptr->paeth_row = (png_bytep)png_malloc(png_ptr,\n             png_ptr->rowbytes + 1);\n\n         png_ptr->paeth_row[0] = PNG_FILTER_VALUE_PAETH;\n      }\n   }\n#endif /* PNG_WRITE_FILTER_SUPPORTED */\n\n#ifdef PNG_WRITE_INTERLACING_SUPPORTED\n   /* If interlaced, we need to set up width and height of pass */\n   if (png_ptr->interlaced)\n   {\n      if (!(png_ptr->transformations & PNG_INTERLACE))\n      {\n         png_ptr->num_rows = (png_ptr->height + png_pass_yinc[0] - 1 -\n             png_pass_ystart[0]) / png_pass_yinc[0];\n\n         png_ptr->usr_width = (png_ptr->width + png_pass_inc[0] - 1 -\n             png_pass_start[0]) / png_pass_inc[0];\n      }\n\n      else\n      {\n         png_ptr->num_rows = png_ptr->height;\n         png_ptr->usr_width = png_ptr->width;\n      }\n   }\n\n   else\n#endif\n   {\n      png_ptr->num_rows = png_ptr->height;\n      png_ptr->usr_width = png_ptr->width;\n   }\n\n   png_zlib_claim(png_ptr, PNG_ZLIB_FOR_IDAT);\n   png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size;\n   png_ptr->zstream.next_out = png_ptr->zbuf;\n}\n\n/* Internal use only.  Called when finished processing a row of data. */\nvoid /* PRIVATE */\npng_write_finish_row(png_structp png_ptr)\n{\n#ifdef PNG_WRITE_INTERLACING_SUPPORTED\n   /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */\n\n   /* Start of interlace block */\n   static PNG_CONST png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};\n\n   /* Offset to next interlace block */\n   static PNG_CONST png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};\n\n   /* Start of interlace block in the y direction */\n   static PNG_CONST png_byte png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1};\n\n   /* Offset to next interlace block in the y direction */\n   static PNG_CONST png_byte png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};\n#endif\n\n   int ret;\n\n   png_debug(1, \"in png_write_finish_row\");\n\n   /* Next row */\n   png_ptr->row_number++;\n\n   /* See if we are done */\n   if (png_ptr->row_number < png_ptr->num_rows)\n      return;\n\n#ifdef PNG_WRITE_INTERLACING_SUPPORTED\n   /* If interlaced, go to next pass */\n   if (png_ptr->interlaced)\n   {\n      png_ptr->row_number = 0;\n      if (png_ptr->transformations & PNG_INTERLACE)\n      {\n         png_ptr->pass++;\n      }\n\n      else\n      {\n         /* Loop until we find a non-zero width or height pass */\n         do\n         {\n            png_ptr->pass++;\n\n            if (png_ptr->pass >= 7)\n               break;\n\n            png_ptr->usr_width = (png_ptr->width +\n                png_pass_inc[png_ptr->pass] - 1 -\n                png_pass_start[png_ptr->pass]) /\n                png_pass_inc[png_ptr->pass];\n\n            png_ptr->num_rows = (png_ptr->height +\n                png_pass_yinc[png_ptr->pass] - 1 -\n                png_pass_ystart[png_ptr->pass]) /\n                png_pass_yinc[png_ptr->pass];\n\n            if (png_ptr->transformations & PNG_INTERLACE)\n               break;\n\n         } while (png_ptr->usr_width == 0 || png_ptr->num_rows == 0);\n\n      }\n\n      /* Reset the row above the image for the next pass */\n      if (png_ptr->pass < 7)\n      {\n         if (png_ptr->prev_row != NULL)\n            png_memset(png_ptr->prev_row, 0,\n                (png_size_t)(PNG_ROWBYTES(png_ptr->usr_channels*\n                png_ptr->usr_bit_depth, png_ptr->width)) + 1);\n\n         return;\n      }\n   }\n#endif\n\n   /* If we get here, we've just written the last row, so we need\n      to flush the compressor */\n   do\n   {\n      /* Tell the compressor we are done */\n      ret = deflate(&png_ptr->zstream, Z_FINISH);\n\n      /* Check for an error */\n      if (ret == Z_OK)\n      {\n         /* Check to see if we need more room */\n         if (!(png_ptr->zstream.avail_out))\n         {\n            png_write_IDAT(png_ptr, png_ptr->zbuf, png_ptr->zbuf_size);\n            png_ptr->zstream.next_out = png_ptr->zbuf;\n            png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size;\n         }\n      }\n\n      else if (ret != Z_STREAM_END)\n      {\n         if (png_ptr->zstream.msg != NULL)\n            png_error(png_ptr, png_ptr->zstream.msg);\n\n         else\n            png_error(png_ptr, \"zlib error\");\n      }\n   } while (ret != Z_STREAM_END);\n\n   /* Write any extra space */\n   if (png_ptr->zstream.avail_out < png_ptr->zbuf_size)\n   {\n      png_write_IDAT(png_ptr, png_ptr->zbuf, png_ptr->zbuf_size -\n          png_ptr->zstream.avail_out);\n   }\n\n   png_zlib_release(png_ptr);\n   png_ptr->zstream.data_type = Z_BINARY;\n}\n\n#ifdef PNG_WRITE_INTERLACING_SUPPORTED\n/* Pick out the correct pixels for the interlace pass.\n * The basic idea here is to go through the row with a source\n * pointer and a destination pointer (sp and dp), and copy the\n * correct pixels for the pass.  As the row gets compacted,\n * sp will always be >= dp, so we should never overwrite anything.\n * See the default: case for the easiest code to understand.\n */\nvoid /* PRIVATE */\npng_do_write_interlace(png_row_infop row_info, png_bytep row, int pass)\n{\n   /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */\n\n   /* Start of interlace block */\n   static PNG_CONST png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};\n\n   /* Offset to next interlace block */\n   static PNG_CONST png_byte  png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};\n\n   png_debug(1, \"in png_do_write_interlace\");\n\n   /* We don't have to do anything on the last pass (6) */\n   if (pass < 6)\n   {\n      /* Each pixel depth is handled separately */\n      switch (row_info->pixel_depth)\n      {\n         case 1:\n         {\n            png_bytep sp;\n            png_bytep dp;\n            int shift;\n            int d;\n            int value;\n            png_uint_32 i;\n            png_uint_32 row_width = row_info->width;\n\n            dp = row;\n            d = 0;\n            shift = 7;\n\n            for (i = png_pass_start[pass]; i < row_width;\n               i += png_pass_inc[pass])\n            {\n               sp = row + (png_size_t)(i >> 3);\n               value = (int)(*sp >> (7 - (int)(i & 0x07))) & 0x01;\n               d |= (value << shift);\n\n               if (shift == 0)\n               {\n                  shift = 7;\n                  *dp++ = (png_byte)d;\n                  d = 0;\n               }\n\n               else\n                  shift--;\n\n            }\n            if (shift != 7)\n               *dp = (png_byte)d;\n\n            break;\n         }\n\n         case 2:\n         {\n            png_bytep sp;\n            png_bytep dp;\n            int shift;\n            int d;\n            int value;\n            png_uint_32 i;\n            png_uint_32 row_width = row_info->width;\n\n            dp = row;\n            shift = 6;\n            d = 0;\n\n            for (i = png_pass_start[pass]; i < row_width;\n               i += png_pass_inc[pass])\n            {\n               sp = row + (png_size_t)(i >> 2);\n               value = (*sp >> ((3 - (int)(i & 0x03)) << 1)) & 0x03;\n               d |= (value << shift);\n\n               if (shift == 0)\n               {\n                  shift = 6;\n                  *dp++ = (png_byte)d;\n                  d = 0;\n               }\n\n               else\n                  shift -= 2;\n            }\n            if (shift != 6)\n               *dp = (png_byte)d;\n\n            break;\n         }\n\n         case 4:\n         {\n            png_bytep sp;\n            png_bytep dp;\n            int shift;\n            int d;\n            int value;\n            png_uint_32 i;\n            png_uint_32 row_width = row_info->width;\n\n            dp = row;\n            shift = 4;\n            d = 0;\n            for (i = png_pass_start[pass]; i < row_width;\n                i += png_pass_inc[pass])\n            {\n               sp = row + (png_size_t)(i >> 1);\n               value = (*sp >> ((1 - (int)(i & 0x01)) << 2)) & 0x0f;\n               d |= (value << shift);\n\n               if (shift == 0)\n               {\n                  shift = 4;\n                  *dp++ = (png_byte)d;\n                  d = 0;\n               }\n\n               else\n                  shift -= 4;\n            }\n            if (shift != 4)\n               *dp = (png_byte)d;\n\n            break;\n         }\n\n         default:\n         {\n            png_bytep sp;\n            png_bytep dp;\n            png_uint_32 i;\n            png_uint_32 row_width = row_info->width;\n            png_size_t pixel_bytes;\n\n            /* Start at the beginning */\n            dp = row;\n\n            /* Find out how many bytes each pixel takes up */\n            pixel_bytes = (row_info->pixel_depth >> 3);\n\n            /* Loop through the row, only looking at the pixels that matter */\n            for (i = png_pass_start[pass]; i < row_width;\n               i += png_pass_inc[pass])\n            {\n               /* Find out where the original pixel is */\n               sp = row + (png_size_t)i * pixel_bytes;\n\n               /* Move the pixel */\n               if (dp != sp)\n                  png_memcpy(dp, sp, pixel_bytes);\n\n               /* Next pixel */\n               dp += pixel_bytes;\n            }\n            break;\n         }\n      }\n      /* Set new row width */\n      row_info->width = (row_info->width +\n          png_pass_inc[pass] - 1 -\n          png_pass_start[pass]) /\n          png_pass_inc[pass];\n\n      row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,\n          row_info->width);\n   }\n}\n#endif\n\n/* This filters the row, chooses which filter to use, if it has not already\n * been specified by the application, and then writes the row out with the\n * chosen filter.\n */\nstatic void png_write_filtered_row(png_structp png_ptr, png_bytep filtered_row,\n   png_size_t row_bytes);\n\n#define PNG_MAXSUM (((png_uint_32)(-1)) >> 1)\n#define PNG_HISHIFT 10\n#define PNG_LOMASK ((png_uint_32)0xffffL)\n#define PNG_HIMASK ((png_uint_32)(~PNG_LOMASK >> PNG_HISHIFT))\nvoid /* PRIVATE */\npng_write_find_filter(png_structp png_ptr, png_row_infop row_info)\n{\n   png_bytep best_row;\n#ifdef PNG_WRITE_FILTER_SUPPORTED\n   png_bytep prev_row, row_buf;\n   png_uint_32 mins, bpp;\n   png_byte filter_to_do = png_ptr->do_filter;\n   png_size_t row_bytes = row_info->rowbytes;\n#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED\n   int num_p_filters = png_ptr->num_prev_filters;\n#endif\n\n   png_debug(1, \"in png_write_find_filter\");\n\n#ifndef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED\n  if (png_ptr->row_number == 0 && filter_to_do == PNG_ALL_FILTERS)\n  {\n     /* These will never be selected so we need not test them. */\n     filter_to_do &= ~(PNG_FILTER_UP | PNG_FILTER_PAETH);\n  }\n#endif\n\n   /* Find out how many bytes offset each pixel is */\n   bpp = (row_info->pixel_depth + 7) >> 3;\n\n   prev_row = png_ptr->prev_row;\n#endif\n   best_row = png_ptr->row_buf;\n#ifdef PNG_WRITE_FILTER_SUPPORTED\n   row_buf = best_row;\n   mins = PNG_MAXSUM;\n\n   /* The prediction method we use is to find which method provides the\n    * smallest value when summing the absolute values of the distances\n    * from zero, using anything >= 128 as negative numbers.  This is known\n    * as the \"minimum sum of absolute differences\" heuristic.  Other\n    * heuristics are the \"weighted minimum sum of absolute differences\"\n    * (experimental and can in theory improve compression), and the \"zlib\n    * predictive\" method (not implemented yet), which does test compressions\n    * of lines using different filter methods, and then chooses the\n    * (series of) filter(s) that give minimum compressed data size (VERY\n    * computationally expensive).\n    *\n    * GRR 980525:  consider also\n    *\n    *   (1) minimum sum of absolute differences from running average (i.e.,\n    *       keep running sum of non-absolute differences & count of bytes)\n    *       [track dispersion, too?  restart average if dispersion too large?]\n    *\n    *  (1b) minimum sum of absolute differences from sliding average, probably\n    *       with window size <= deflate window (usually 32K)\n    *\n    *   (2) minimum sum of squared differences from zero or running average\n    *       (i.e., ~ root-mean-square approach)\n    */\n\n\n   /* We don't need to test the 'no filter' case if this is the only filter\n    * that has been chosen, as it doesn't actually do anything to the data.\n    */\n   if ((filter_to_do & PNG_FILTER_NONE) && filter_to_do != PNG_FILTER_NONE)\n   {\n      png_bytep rp;\n      png_uint_32 sum = 0;\n      png_size_t i;\n      int v;\n\n      for (i = 0, rp = row_buf + 1; i < row_bytes; i++, rp++)\n      {\n         v = *rp;\n         sum += (v < 128) ? v : 256 - v;\n      }\n\n#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED\n      if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED)\n      {\n         png_uint_32 sumhi, sumlo;\n         int j;\n         sumlo = sum & PNG_LOMASK;\n         sumhi = (sum >> PNG_HISHIFT) & PNG_HIMASK; /* Gives us some footroom */\n\n         /* Reduce the sum if we match any of the previous rows */\n         for (j = 0; j < num_p_filters; j++)\n         {\n            if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_NONE)\n            {\n               sumlo = (sumlo * png_ptr->filter_weights[j]) >>\n                   PNG_WEIGHT_SHIFT;\n\n               sumhi = (sumhi * png_ptr->filter_weights[j]) >>\n                   PNG_WEIGHT_SHIFT;\n            }\n         }\n\n         /* Factor in the cost of this filter (this is here for completeness,\n          * but it makes no sense to have a \"cost\" for the NONE filter, as\n          * it has the minimum possible computational cost - none).\n          */\n         sumlo = (sumlo * png_ptr->filter_costs[PNG_FILTER_VALUE_NONE]) >>\n             PNG_COST_SHIFT;\n\n         sumhi = (sumhi * png_ptr->filter_costs[PNG_FILTER_VALUE_NONE]) >>\n             PNG_COST_SHIFT;\n\n         if (sumhi > PNG_HIMASK)\n            sum = PNG_MAXSUM;\n\n         else\n            sum = (sumhi << PNG_HISHIFT) + sumlo;\n      }\n#endif\n      mins = sum;\n   }\n\n   /* Sub filter */\n   if (filter_to_do == PNG_FILTER_SUB)\n   /* It's the only filter so no testing is needed */\n   {\n      png_bytep rp, lp, dp;\n      png_size_t i;\n\n      for (i = 0, rp = row_buf + 1, dp = png_ptr->sub_row + 1; i < bpp;\n           i++, rp++, dp++)\n      {\n         *dp = *rp;\n      }\n\n      for (lp = row_buf + 1; i < row_bytes;\n         i++, rp++, lp++, dp++)\n      {\n         *dp = (png_byte)(((int)*rp - (int)*lp) & 0xff);\n      }\n\n      best_row = png_ptr->sub_row;\n   }\n\n   else if (filter_to_do & PNG_FILTER_SUB)\n   {\n      png_bytep rp, dp, lp;\n      png_uint_32 sum = 0, lmins = mins;\n      png_size_t i;\n      int v;\n\n#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED\n      /* We temporarily increase the \"minimum sum\" by the factor we\n       * would reduce the sum of this filter, so that we can do the\n       * early exit comparison without scaling the sum each time.\n       */\n      if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED)\n      {\n         int j;\n         png_uint_32 lmhi, lmlo;\n         lmlo = lmins & PNG_LOMASK;\n         lmhi = (lmins >> PNG_HISHIFT) & PNG_HIMASK;\n\n         for (j = 0; j < num_p_filters; j++)\n         {\n            if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_SUB)\n            {\n               lmlo = (lmlo * png_ptr->inv_filter_weights[j]) >>\n                   PNG_WEIGHT_SHIFT;\n\n               lmhi = (lmhi * png_ptr->inv_filter_weights[j]) >>\n                   PNG_WEIGHT_SHIFT;\n            }\n         }\n\n         lmlo = (lmlo * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_SUB]) >>\n             PNG_COST_SHIFT;\n\n         lmhi = (lmhi * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_SUB]) >>\n             PNG_COST_SHIFT;\n\n         if (lmhi > PNG_HIMASK)\n            lmins = PNG_MAXSUM;\n\n         else\n            lmins = (lmhi << PNG_HISHIFT) + lmlo;\n      }\n#endif\n\n      for (i = 0, rp = row_buf + 1, dp = png_ptr->sub_row + 1; i < bpp;\n           i++, rp++, dp++)\n      {\n         v = *dp = *rp;\n\n         sum += (v < 128) ? v : 256 - v;\n      }\n\n      for (lp = row_buf + 1; i < row_bytes;\n         i++, rp++, lp++, dp++)\n      {\n         v = *dp = (png_byte)(((int)*rp - (int)*lp) & 0xff);\n\n         sum += (v < 128) ? v : 256 - v;\n\n         if (sum > lmins)  /* We are already worse, don't continue. */\n            break;\n      }\n\n#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED\n      if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED)\n      {\n         int j;\n         png_uint_32 sumhi, sumlo;\n         sumlo = sum & PNG_LOMASK;\n         sumhi = (sum >> PNG_HISHIFT) & PNG_HIMASK;\n\n         for (j = 0; j < num_p_filters; j++)\n         {\n            if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_SUB)\n            {\n               sumlo = (sumlo * png_ptr->inv_filter_weights[j]) >>\n                   PNG_WEIGHT_SHIFT;\n\n               sumhi = (sumhi * png_ptr->inv_filter_weights[j]) >>\n                   PNG_WEIGHT_SHIFT;\n            }\n         }\n\n         sumlo = (sumlo * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_SUB]) >>\n             PNG_COST_SHIFT;\n\n         sumhi = (sumhi * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_SUB]) >>\n             PNG_COST_SHIFT;\n\n         if (sumhi > PNG_HIMASK)\n            sum = PNG_MAXSUM;\n\n         else\n            sum = (sumhi << PNG_HISHIFT) + sumlo;\n      }\n#endif\n\n      if (sum < mins)\n      {\n         mins = sum;\n         best_row = png_ptr->sub_row;\n      }\n   }\n\n   /* Up filter */\n   if (filter_to_do == PNG_FILTER_UP)\n   {\n      png_bytep rp, dp, pp;\n      png_size_t i;\n\n      for (i = 0, rp = row_buf + 1, dp = png_ptr->up_row + 1,\n          pp = prev_row + 1; i < row_bytes;\n          i++, rp++, pp++, dp++)\n      {\n         *dp = (png_byte)(((int)*rp - (int)*pp) & 0xff);\n      }\n\n      best_row = png_ptr->up_row;\n   }\n\n   else if (filter_to_do & PNG_FILTER_UP)\n   {\n      png_bytep rp, dp, pp;\n      png_uint_32 sum = 0, lmins = mins;\n      png_size_t i;\n      int v;\n\n\n#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED\n      if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED)\n      {\n         int j;\n         png_uint_32 lmhi, lmlo;\n         lmlo = lmins & PNG_LOMASK;\n         lmhi = (lmins >> PNG_HISHIFT) & PNG_HIMASK;\n\n         for (j = 0; j < num_p_filters; j++)\n         {\n            if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_UP)\n            {\n               lmlo = (lmlo * png_ptr->inv_filter_weights[j]) >>\n                   PNG_WEIGHT_SHIFT;\n\n               lmhi = (lmhi * png_ptr->inv_filter_weights[j]) >>\n                   PNG_WEIGHT_SHIFT;\n            }\n         }\n\n         lmlo = (lmlo * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_UP]) >>\n             PNG_COST_SHIFT;\n\n         lmhi = (lmhi * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_UP]) >>\n             PNG_COST_SHIFT;\n\n         if (lmhi > PNG_HIMASK)\n            lmins = PNG_MAXSUM;\n\n         else\n            lmins = (lmhi << PNG_HISHIFT) + lmlo;\n      }\n#endif\n\n      for (i = 0, rp = row_buf + 1, dp = png_ptr->up_row + 1,\n          pp = prev_row + 1; i < row_bytes; i++)\n      {\n         v = *dp++ = (png_byte)(((int)*rp++ - (int)*pp++) & 0xff);\n\n         sum += (v < 128) ? v : 256 - v;\n\n         if (sum > lmins)  /* We are already worse, don't continue. */\n            break;\n      }\n\n#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED\n      if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED)\n      {\n         int j;\n         png_uint_32 sumhi, sumlo;\n         sumlo = sum & PNG_LOMASK;\n         sumhi = (sum >> PNG_HISHIFT) & PNG_HIMASK;\n\n         for (j = 0; j < num_p_filters; j++)\n         {\n            if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_UP)\n            {\n               sumlo = (sumlo * png_ptr->filter_weights[j]) >>\n                   PNG_WEIGHT_SHIFT;\n\n               sumhi = (sumhi * png_ptr->filter_weights[j]) >>\n                   PNG_WEIGHT_SHIFT;\n            }\n         }\n\n         sumlo = (sumlo * png_ptr->filter_costs[PNG_FILTER_VALUE_UP]) >>\n             PNG_COST_SHIFT;\n\n         sumhi = (sumhi * png_ptr->filter_costs[PNG_FILTER_VALUE_UP]) >>\n             PNG_COST_SHIFT;\n\n         if (sumhi > PNG_HIMASK)\n            sum = PNG_MAXSUM;\n\n         else\n            sum = (sumhi << PNG_HISHIFT) + sumlo;\n      }\n#endif\n\n      if (sum < mins)\n      {\n         mins = sum;\n         best_row = png_ptr->up_row;\n      }\n   }\n\n   /* Avg filter */\n   if (filter_to_do == PNG_FILTER_AVG)\n   {\n      png_bytep rp, dp, pp, lp;\n      png_uint_32 i;\n\n      for (i = 0, rp = row_buf + 1, dp = png_ptr->avg_row + 1,\n           pp = prev_row + 1; i < bpp; i++)\n      {\n         *dp++ = (png_byte)(((int)*rp++ - ((int)*pp++ / 2)) & 0xff);\n      }\n\n      for (lp = row_buf + 1; i < row_bytes; i++)\n      {\n         *dp++ = (png_byte)(((int)*rp++ - (((int)*pp++ + (int)*lp++) / 2))\n                 & 0xff);\n      }\n      best_row = png_ptr->avg_row;\n   }\n\n   else if (filter_to_do & PNG_FILTER_AVG)\n   {\n      png_bytep rp, dp, pp, lp;\n      png_uint_32 sum = 0, lmins = mins;\n      png_size_t i;\n      int v;\n\n#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED\n      if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED)\n      {\n         int j;\n         png_uint_32 lmhi, lmlo;\n         lmlo = lmins & PNG_LOMASK;\n         lmhi = (lmins >> PNG_HISHIFT) & PNG_HIMASK;\n\n         for (j = 0; j < num_p_filters; j++)\n         {\n            if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_AVG)\n            {\n               lmlo = (lmlo * png_ptr->inv_filter_weights[j]) >>\n                   PNG_WEIGHT_SHIFT;\n\n               lmhi = (lmhi * png_ptr->inv_filter_weights[j]) >>\n                   PNG_WEIGHT_SHIFT;\n            }\n         }\n\n         lmlo = (lmlo * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_AVG]) >>\n             PNG_COST_SHIFT;\n\n         lmhi = (lmhi * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_AVG]) >>\n             PNG_COST_SHIFT;\n\n         if (lmhi > PNG_HIMASK)\n            lmins = PNG_MAXSUM;\n\n         else\n            lmins = (lmhi << PNG_HISHIFT) + lmlo;\n      }\n#endif\n\n      for (i = 0, rp = row_buf + 1, dp = png_ptr->avg_row + 1,\n           pp = prev_row + 1; i < bpp; i++)\n      {\n         v = *dp++ = (png_byte)(((int)*rp++ - ((int)*pp++ / 2)) & 0xff);\n\n         sum += (v < 128) ? v : 256 - v;\n      }\n\n      for (lp = row_buf + 1; i < row_bytes; i++)\n      {\n         v = *dp++ =\n             (png_byte)(((int)*rp++ - (((int)*pp++ + (int)*lp++) / 2)) & 0xff);\n\n         sum += (v < 128) ? v : 256 - v;\n\n         if (sum > lmins)  /* We are already worse, don't continue. */\n            break;\n      }\n\n#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED\n      if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED)\n      {\n         int j;\n         png_uint_32 sumhi, sumlo;\n         sumlo = sum & PNG_LOMASK;\n         sumhi = (sum >> PNG_HISHIFT) & PNG_HIMASK;\n\n         for (j = 0; j < num_p_filters; j++)\n         {\n            if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_NONE)\n            {\n               sumlo = (sumlo * png_ptr->filter_weights[j]) >>\n                   PNG_WEIGHT_SHIFT;\n\n               sumhi = (sumhi * png_ptr->filter_weights[j]) >>\n                   PNG_WEIGHT_SHIFT;\n            }\n         }\n\n         sumlo = (sumlo * png_ptr->filter_costs[PNG_FILTER_VALUE_AVG]) >>\n             PNG_COST_SHIFT;\n\n         sumhi = (sumhi * png_ptr->filter_costs[PNG_FILTER_VALUE_AVG]) >>\n             PNG_COST_SHIFT;\n\n         if (sumhi > PNG_HIMASK)\n            sum = PNG_MAXSUM;\n\n         else\n            sum = (sumhi << PNG_HISHIFT) + sumlo;\n      }\n#endif\n\n      if (sum < mins)\n      {\n         mins = sum;\n         best_row = png_ptr->avg_row;\n      }\n   }\n\n   /* Paeth filter */\n   if (filter_to_do == PNG_FILTER_PAETH)\n   {\n      png_bytep rp, dp, pp, cp, lp;\n      png_size_t i;\n\n      for (i = 0, rp = row_buf + 1, dp = png_ptr->paeth_row + 1,\n          pp = prev_row + 1; i < bpp; i++)\n      {\n         *dp++ = (png_byte)(((int)*rp++ - (int)*pp++) & 0xff);\n      }\n\n      for (lp = row_buf + 1, cp = prev_row + 1; i < row_bytes; i++)\n      {\n         int a, b, c, pa, pb, pc, p;\n\n         b = *pp++;\n         c = *cp++;\n         a = *lp++;\n\n         p = b - c;\n         pc = a - c;\n\n#ifdef PNG_USE_ABS\n         pa = abs(p);\n         pb = abs(pc);\n         pc = abs(p + pc);\n#else\n         pa = p < 0 ? -p : p;\n         pb = pc < 0 ? -pc : pc;\n         pc = (p + pc) < 0 ? -(p + pc) : p + pc;\n#endif\n\n         p = (pa <= pb && pa <=pc) ? a : (pb <= pc) ? b : c;\n\n         *dp++ = (png_byte)(((int)*rp++ - p) & 0xff);\n      }\n      best_row = png_ptr->paeth_row;\n   }\n\n   else if (filter_to_do & PNG_FILTER_PAETH)\n   {\n      png_bytep rp, dp, pp, cp, lp;\n      png_uint_32 sum = 0, lmins = mins;\n      png_size_t i;\n      int v;\n\n#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED\n      if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED)\n      {\n         int j;\n         png_uint_32 lmhi, lmlo;\n         lmlo = lmins & PNG_LOMASK;\n         lmhi = (lmins >> PNG_HISHIFT) & PNG_HIMASK;\n\n         for (j = 0; j < num_p_filters; j++)\n         {\n            if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_PAETH)\n            {\n               lmlo = (lmlo * png_ptr->inv_filter_weights[j]) >>\n                   PNG_WEIGHT_SHIFT;\n\n               lmhi = (lmhi * png_ptr->inv_filter_weights[j]) >>\n                   PNG_WEIGHT_SHIFT;\n            }\n         }\n\n         lmlo = (lmlo * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_PAETH]) >>\n             PNG_COST_SHIFT;\n\n         lmhi = (lmhi * png_ptr->inv_filter_costs[PNG_FILTER_VALUE_PAETH]) >>\n             PNG_COST_SHIFT;\n\n         if (lmhi > PNG_HIMASK)\n            lmins = PNG_MAXSUM;\n\n         else\n            lmins = (lmhi << PNG_HISHIFT) + lmlo;\n      }\n#endif\n\n      for (i = 0, rp = row_buf + 1, dp = png_ptr->paeth_row + 1,\n          pp = prev_row + 1; i < bpp; i++)\n      {\n         v = *dp++ = (png_byte)(((int)*rp++ - (int)*pp++) & 0xff);\n\n         sum += (v < 128) ? v : 256 - v;\n      }\n\n      for (lp = row_buf + 1, cp = prev_row + 1; i < row_bytes; i++)\n      {\n         int a, b, c, pa, pb, pc, p;\n\n         b = *pp++;\n         c = *cp++;\n         a = *lp++;\n\n#ifndef PNG_SLOW_PAETH\n         p = b - c;\n         pc = a - c;\n#ifdef PNG_USE_ABS\n         pa = abs(p);\n         pb = abs(pc);\n         pc = abs(p + pc);\n#else\n         pa = p < 0 ? -p : p;\n         pb = pc < 0 ? -pc : pc;\n         pc = (p + pc) < 0 ? -(p + pc) : p + pc;\n#endif\n         p = (pa <= pb && pa <=pc) ? a : (pb <= pc) ? b : c;\n#else /* PNG_SLOW_PAETH */\n         p = a + b - c;\n         pa = abs(p - a);\n         pb = abs(p - b);\n         pc = abs(p - c);\n\n         if (pa <= pb && pa <= pc)\n            p = a;\n\n         else if (pb <= pc)\n            p = b;\n\n         else\n            p = c;\n#endif /* PNG_SLOW_PAETH */\n\n         v = *dp++ = (png_byte)(((int)*rp++ - p) & 0xff);\n\n         sum += (v < 128) ? v : 256 - v;\n\n         if (sum > lmins)  /* We are already worse, don't continue. */\n            break;\n      }\n\n#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED\n      if (png_ptr->heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED)\n      {\n         int j;\n         png_uint_32 sumhi, sumlo;\n         sumlo = sum & PNG_LOMASK;\n         sumhi = (sum >> PNG_HISHIFT) & PNG_HIMASK;\n\n         for (j = 0; j < num_p_filters; j++)\n         {\n            if (png_ptr->prev_filters[j] == PNG_FILTER_VALUE_PAETH)\n            {\n               sumlo = (sumlo * png_ptr->filter_weights[j]) >>\n                   PNG_WEIGHT_SHIFT;\n\n               sumhi = (sumhi * png_ptr->filter_weights[j]) >>\n                   PNG_WEIGHT_SHIFT;\n            }\n         }\n\n         sumlo = (sumlo * png_ptr->filter_costs[PNG_FILTER_VALUE_PAETH]) >>\n             PNG_COST_SHIFT;\n\n         sumhi = (sumhi * png_ptr->filter_costs[PNG_FILTER_VALUE_PAETH]) >>\n             PNG_COST_SHIFT;\n\n         if (sumhi > PNG_HIMASK)\n            sum = PNG_MAXSUM;\n\n         else\n            sum = (sumhi << PNG_HISHIFT) + sumlo;\n      }\n#endif\n\n      if (sum < mins)\n      {\n         best_row = png_ptr->paeth_row;\n      }\n   }\n#endif /* PNG_WRITE_FILTER_SUPPORTED */\n\n   /* Do the actual writing of the filtered row data from the chosen filter. */\n   png_write_filtered_row(png_ptr, best_row, row_info->rowbytes+1);\n\n#ifdef PNG_WRITE_FILTER_SUPPORTED\n#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED\n   /* Save the type of filter we picked this time for future calculations */\n   if (png_ptr->num_prev_filters > 0)\n   {\n      int j;\n\n      for (j = 1; j < num_p_filters; j++)\n      {\n         png_ptr->prev_filters[j] = png_ptr->prev_filters[j - 1];\n      }\n\n      png_ptr->prev_filters[j] = best_row[0];\n   }\n#endif\n#endif /* PNG_WRITE_FILTER_SUPPORTED */\n}\n\n\n/* Do the actual writing of a previously filtered row. */\nstatic void\npng_write_filtered_row(png_structp png_ptr, png_bytep filtered_row,\n   png_size_t avail/*includes filter byte*/)\n{\n   png_debug(1, \"in png_write_filtered_row\");\n\n   png_debug1(2, \"filter = %d\", filtered_row[0]);\n   /* Set up the zlib input buffer */\n\n   png_ptr->zstream.next_in = filtered_row;\n   png_ptr->zstream.avail_in = 0;\n   /* Repeat until we have compressed all the data */\n   do\n   {\n      int ret; /* Return of zlib */\n\n      /* Record the number of bytes available - zlib supports at least 65535\n       * bytes at one step, depending on the size of the zlib type 'uInt', the\n       * maximum size zlib can write at once is ZLIB_IO_MAX (from pngpriv.h).\n       * Use this because on 16 bit systems 'rowbytes' can be up to 65536 (i.e.\n       * one more than 16 bits) and, in this case 'rowbytes+1' can overflow a\n       * uInt.  ZLIB_IO_MAX can be safely reduced to cause zlib to be called\n       * with smaller chunks of data.\n       */\n      if (png_ptr->zstream.avail_in == 0)\n      {\n         if (avail > ZLIB_IO_MAX)\n         {\n            png_ptr->zstream.avail_in  = ZLIB_IO_MAX;\n            avail -= ZLIB_IO_MAX;\n         }\n\n         else\n         {\n            /* So this will fit in the available uInt space: */\n            png_ptr->zstream.avail_in = (uInt)avail;\n            avail = 0;\n         }\n      }\n\n      /* Compress the data */\n      ret = deflate(&png_ptr->zstream, Z_NO_FLUSH);\n\n      /* Check for compression errors */\n      if (ret != Z_OK)\n      {\n         if (png_ptr->zstream.msg != NULL)\n            png_error(png_ptr, png_ptr->zstream.msg);\n\n         else\n            png_error(png_ptr, \"zlib error\");\n      }\n\n      /* See if it is time to write another IDAT */\n      if (!(png_ptr->zstream.avail_out))\n      {\n         /* Write the IDAT and reset the zlib output buffer */\n         png_write_IDAT(png_ptr, png_ptr->zbuf, png_ptr->zbuf_size);\n      }\n   /* Repeat until all data has been compressed */\n   } while (avail > 0 || png_ptr->zstream.avail_in > 0);\n\n   /* Swap the current and previous rows */\n   if (png_ptr->prev_row != NULL)\n   {\n      png_bytep tptr;\n\n      tptr = png_ptr->prev_row;\n      png_ptr->prev_row = png_ptr->row_buf;\n      png_ptr->row_buf = tptr;\n   }\n\n   /* Finish row - updates counters and flushes zlib if last row */\n   png_write_finish_row(png_ptr);\n\n#ifdef PNG_WRITE_FLUSH_SUPPORTED\n   png_ptr->flush_rows++;\n\n   if (png_ptr->flush_dist > 0 &&\n       png_ptr->flush_rows >= png_ptr->flush_dist)\n   {\n      png_write_flush(png_ptr);\n   }\n#endif\n}\n#endif /* PNG_WRITE_SUPPORTED */\n"
  },
  {
    "path": "Projects/Tools/PNGAlphaPremultiplier/Native/Source/Logging.cpp",
    "content": "//\r\n//  Logging.cpp\r\n//  ChilliSource\r\n//  Created by Ian Copland on 15/03/2012.\r\n//\r\n//  The MIT License (MIT)\r\n//\r\n//  Copyright (c) 2012 Tag Games Limited\r\n//\r\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\r\n//  of this software and associated documentation files (the \"Software\"), to deal\r\n//  in the Software without restriction, including without limitation the rights\r\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\n//  copies of the Software, and to permit persons to whom the Software is\r\n//  furnished to do so, subject to the following conditions:\r\n//\r\n//  The above copyright notice and this permission notice shall be included in\r\n//  all copies or substantial portions of the Software.\r\n//\r\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r\n//  THE SOFTWARE.\r\n//\r\n \r\n#include \"Logging.h\"\r\n\r\n#include \"StringUtils.h\"\r\n\r\n#include <iostream>\r\n#include <cstdlib>\r\n \r\nnamespace Logging\r\n{\r\n\tnamespace\r\n\t{\r\n\t\tLoggingLevel g_loggingLevel = LoggingLevel::k_warning;\r\n\t\tint g_warningCount = 0;\r\n\t\tint g_errorCount = 0;\r\n\t\tbool g_loggingEnabled = false;\r\n\r\n\t\t//-------------------------------------------------\r\n\t\t/// Prints a message on the standard output stream.\r\n\t\t///\r\n\t\t/// @author Ian Copland\r\n\t\t///\r\n\t\t/// @param The message to print.\r\n\t\t//-------------------------------------------------\r\n\t\tvoid PrintStandard(std::string instrMessage)\r\n\t\t{\r\n\t\t\tstd::cout << instrMessage << std::endl;\r\n\t\t}\r\n\t\t//-------------------------------------------------\r\n\t\t/// Prints a message on the error output stream.\r\n\t\t///\r\n\t\t/// @author Ian Copland\r\n\t\t///\r\n\t\t/// @param The message to print.\r\n\t\t//-------------------------------------------------\r\n\t\tvoid PrintError(std::string instrMessage)\r\n\t\t{\r\n\t\t\tstd::clog << instrMessage << std::endl;\r\n\t\t}\r\n\t}\r\n\t//-------------------------------------------------\r\n\t//-------------------------------------------------\r\n\tvoid Start(int in_argCount, char* in_arguments[])\r\n\t{\r\n\t\tif (g_loggingEnabled == false)\r\n\t\t{\r\n\t\t\tg_loggingEnabled = true;\r\n\r\n\t\t\tfor (int i = 0; i < in_argCount; ++i)\r\n\t\t\t{\r\n\t\t\t\tstd::string strArgument(in_arguments[i]);\r\n\t\t\t\t\r\n\t\t\t\t//logging level param\r\n\t\t\t\tif (strArgument == k_paramLoggingLevel || strArgument == k_paramLoggingLevelShort)\r\n\t\t\t\t{\r\n\t\t\t\t\tif (i + 1 < in_argCount)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tstd::string strValue(in_arguments[i+1]);\r\n\t\t\t\t\t\tif (strValue == k_loggingLevelNone)\t\t\t\t\r\n\t\t\t\t\t\t\tSetLoggingLevel(LoggingLevel::k_none);\r\n\t\t\t\t\t\telse if (strValue == k_loggingLevelFatal)\t\t\r\n\t\t\t\t\t\t\tSetLoggingLevel(LoggingLevel::k_fatal);\r\n\t\t\t\t\t\telse if (strValue == k_loggingLevelError)\t\t\r\n\t\t\t\t\t\t\tSetLoggingLevel(LoggingLevel::k_error);\r\n\t\t\t\t\t\telse if (strValue == k_loggingLevelWarning)\t\t\r\n\t\t\t\t\t\t\tSetLoggingLevel(LoggingLevel::k_warning);\r\n\t\t\t\t\t\telse if (strValue == k_loggingLevelVerbose)\t\t\r\n\t\t\t\t\t\t\tSetLoggingLevel(LoggingLevel::k_verbose);\r\n\t\t\t\t\t\telse\r\n\t\t\t\t\t\t\tLogFatal(\"Invalid logging level: \" + strArgument);\r\n\t\t\t\t\t}\r\n\t\t\t\t\telse\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tLogFatal(\"No logging level provided!\");\r\n\t\t\t\t\t}\r\n\t\t\t\t\ti++;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\t//-------------------------------------------------\r\n\t//-------------------------------------------------\r\n\tvoid SetLoggingLevel(LoggingLevel in_loggingLevel)\r\n\t{\r\n\t\tg_loggingLevel = in_loggingLevel;\r\n\t}\r\n\t//-------------------------------------------------\r\n\t//-------------------------------------------------\r\n\tvoid LogVerbose(const std::string& in_message)\r\n\t{\r\n\t\tif (g_loggingEnabled && ((int)g_loggingLevel) >= ((int)LoggingLevel::k_verbose))\r\n\t\t{\r\n\t\t\tPrintStandard(in_message);\r\n\t\t}\r\n\t}\r\n\t//-------------------------------------------------\r\n\t//-------------------------------------------------\r\n\tvoid LogWarning(const std::string& in_message)\r\n\t{\r\n\t\tif (g_loggingEnabled && ((int)g_loggingLevel) >= ((int)LoggingLevel::k_warning))\r\n\t\t{\r\n\t\t\t++g_warningCount;\r\n\t\t\tPrintError(\"WARNING: \" + in_message);\r\n\t\t}\r\n\t}\r\n\t//-------------------------------------------------\r\n\t//-------------------------------------------------\r\n\tvoid LogError(const std::string& in_message)\r\n\t{\r\n\t\tif (g_loggingEnabled && ((int)g_loggingLevel) >= ((int)LoggingLevel::k_error))\r\n\t\t{\r\n\t\t\t++g_errorCount;\r\n\t\t\tPrintError(\"ERROR: \" + in_message);\r\n\t\t}\r\n\t}\r\n\t//-------------------------------------------------\r\n\t//-------------------------------------------------\r\n\tvoid LogFatal(const std::string& in_message)\r\n\t{\r\n\t\tif (g_loggingEnabled && ((int)g_loggingLevel) >= ((int)LoggingLevel::k_fatal))\r\n\t\t{\r\n\t\t\t++g_errorCount;\r\n\t\t\tPrintError(\"FATAL: \" + in_message);\r\n\t\t\tFinish();\r\n\t\t}\r\n\t\t\r\n\t\texit(5);\r\n\t}\r\n\t//-------------------------------------------------\r\n\t//-------------------------------------------------\r\n\tvoid Finish()\r\n\t{\r\n\t\tif (g_loggingEnabled)\r\n\t\t{\r\n\t\t\tif (((int)g_loggingLevel) >= ((int)LoggingLevel::k_fatal))\r\n\t\t\t{\r\n\t\t\t\tif (((int)g_loggingLevel) >= ((int)LoggingLevel::k_verbose) || g_warningCount != 0 || g_errorCount != 0)\r\n\t\t\t\t{\r\n\t\t\t\t\tPrintStandard(StringUtils::StringCast(g_warningCount) +\" Warnings found.\");\r\n\t\t\t\t\tPrintStandard(StringUtils::StringCast(g_errorCount) + \" Errors found.\");\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tg_loggingEnabled = false;\r\n\t\t}\r\n\t}\r\n}\r\n"
  },
  {
    "path": "Projects/Tools/PNGAlphaPremultiplier/Native/Source/Logging.h",
    "content": "//\r\n//  Logging.h\r\n//  ChilliSource\r\n//  Created by Ian Copland on 15/03/2012.\r\n//\r\n//  The MIT License (MIT)\r\n//\r\n//  Copyright (c) 2012 Tag Games Limited\r\n//\r\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\r\n//  of this software and associated documentation files (the \"Software\"), to deal\r\n//  in the Software without restriction, including without limitation the rights\r\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\n//  copies of the Software, and to permit persons to whom the Software is\r\n//  furnished to do so, subject to the following conditions:\r\n//\r\n//  The above copyright notice and this permission notice shall be included in\r\n//  all copies or substantial portions of the Software.\r\n//\r\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r\n//  THE SOFTWARE.\r\n//\r\n\r\n#ifndef _PNGALPHAPREMULTIPLIER_LOGGING_H_\r\n#define _PNGALPHAPREMULTIPLIER_LOGGING_H_\r\n \r\n#include <vector>\r\n#include <string>\r\n\r\n//------------------------------------------------------------\r\n/// A collection of convenience methods for logging. All logging\r\n/// must occur between calls to Start and Finish.\r\n///\r\n/// @author Ian Copland\r\n//------------------------------------------------------------\r\nnamespace Logging\r\n{\r\n\tstatic std::string k_paramLoggingLevel = \"--logginglevel\";\r\n\tstatic std::string k_paramLoggingLevelShort = \"-ll\";\r\n\tstatic std::string k_loggingLevelNone = \"none\";\r\n\tstatic std::string k_loggingLevelFatal = \"fatal\";\r\n\tstatic std::string k_loggingLevelError = \"error\";\r\n\tstatic std::string k_loggingLevelWarning = \"warning\";\r\n\tstatic std::string k_loggingLevelVerbose = \"verbose\";\r\n\t//-------------------------------------------------\r\n\t/// The level of message that should be displayed.\r\n\t///\r\n\t/// @author Ian Copland\r\n\t//-------------------------------------------------\r\n\tenum class LoggingLevel\r\n\t{\r\n\t\tk_none,\r\n\t\tk_fatal,\r\n\t\tk_error,\r\n\t\tk_warning,\r\n\t\tk_verbose\r\n\t};\r\n\t//-------------------------------------------------\r\n\t/// Checks the input parameters for logger params\r\n\t/// and updates the logger accordingly.\r\n\t///\r\n\t/// @author Ian Copland\r\n\t///\r\n\t/// @param the input pararmeters.\r\n\t//-------------------------------------------------\r\n\tvoid Start(int in_argCount, char* in_arguments[]);\r\n\t//-------------------------------------------------\r\n\t/// Sets the level of message that should be logged.\r\n\t///\r\n\t/// @author Ian Copland\r\n\t/// \r\n\t/// @param the logging level.\r\n\t//-------------------------------------------------\r\n\tvoid SetLoggingLevel(LoggingLevel in_loggingLevel);\r\n\t//-------------------------------------------------\r\n\t/// Logs a message if logging level is set to\r\n\t///\tverbose.\r\n\t///\r\n\t/// @author Ian Copland\r\n\t///\r\n\t/// @param The message to display.\r\n\t//-------------------------------------------------\r\n\tvoid LogVerbose(const std::string& in_message);\r\n\t//-------------------------------------------------\r\n\t/// Logs a warning if the logging level is set to\r\n\t/// warning or higher.\r\n\t///\r\n\t/// @author Ian Copland\r\n\t///\r\n\t/// @param the warning message.\r\n\t//-------------------------------------------------\r\n\tvoid LogWarning(const std::string& in_message);\r\n\t//-------------------------------------------------\r\n\t/// Logs an error if the logging level is set to\r\n\t/// error or higher.\r\n\t///\r\n\t/// @author Ian Copland\r\n\t///\r\n\t/// @param the error message.\r\n\t//-------------------------------------------------\r\n\tvoid LogError(const std::string& in_message);\r\n\t//-------------------------------------------------\r\n\t/// This will log a fatal error message then exit\r\n\t/// the application.\r\n\t///\r\n\t/// @author Ian Copland\r\n\t///\r\n\t/// @param the fatal error message to display.\r\n\t//-------------------------------------------------\r\n\tvoid LogFatal(const std::string& in_message);\r\n\t//-------------------------------------------------\r\n\t/// Finishes logging.\r\n\t///\r\n\t/// @author Ian Copland\r\n\t//-------------------------------------------------\r\n\tvoid Finish();\r\n}\r\n\r\n#endif\r\n"
  },
  {
    "path": "Projects/Tools/PNGAlphaPremultiplier/Native/Source/Main.cpp",
    "content": "//\n//  Main.cpp\n//  ChilliSource\n//  Created by Ian Copland on 28/03/2012.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2012 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include \"Logging.h\"\n#include \"PNGAlphaPremultiplier.h\"\n#include \"StringUtils.h\"\n\n//-------------------------------------------------\n/// Displays the help messages.\n///\n/// @author Ian Copland\n//-------------------------------------------------\nvoid DisplayHelp()\n{\n\tLogging::SetLoggingLevel(Logging::LoggingLevel::k_verbose);\n\tLogging::LogVerbose(\"Usage: --input <filename> --output <filename> [\" + Logging::k_paramLoggingLevel + \" <level>] [--help]\");\n\tLogging::LogVerbose(\"Parameters\");\n\tLogging::LogVerbose(\" --input(-i): The input filename.\");\n\tLogging::LogVerbose(\" --output(-o): The output filename.\");\n\tLogging::LogVerbose(\" \" + Logging::k_paramLoggingLevel + \"(\" + Logging::k_paramLoggingLevelShort + \"): The logging level.\");\n\tLogging::LogVerbose(\" --help(-h): Display this help message.\");\n\tLogging::LogVerbose(\"Logging Levels:\");\n\tLogging::LogVerbose(\" \" + Logging::k_loggingLevelNone + \": No logging.\");\n\tLogging::LogVerbose(\" \" + Logging::k_loggingLevelFatal + \": Only log fatal errors.\");\n\tLogging::LogVerbose(\" \" + Logging::k_loggingLevelError + \": Only log errors.\");\n\tLogging::LogVerbose(\" \" + Logging::k_loggingLevelWarning + \": Log errors and warnings.\");\n\tLogging::LogVerbose(\" \" + Logging::k_loggingLevelVerbose + \": Log all messages.\");\n}\n//-------------------------------------------------\n/// The entry point into the application.\n///\n/// @author Ian Copland\n//-------------------------------------------------\nint main(int in_argCount, char* in_arguments[])\n{\n\t//initialise the logger\n\tLogging::Start(in_argCount, in_arguments);\n\n\t//if no params have been passed, display the help message.\n\tif (in_argCount < 2)\n\t{\n\t\tDisplayHelp();\n\t\treturn 0;\n\t}\n\n\t//collect parameters\n\tstd::string strInputFilename;\n\tstd::string strOutputFilename;\n\tfor (int i = 1; i < in_argCount; ++i)\n\t{\n\t\tstd::string strArgument(in_arguments[i]);\n\t\t\n\t\t//input param\n\t\tif (strArgument == \"-i\" || strArgument == \"--input\")\n\t\t{\n\t\t\tif (i + 1 < in_argCount)\n\t\t\t\tstrInputFilename = in_arguments[i + 1];\n\t\t\telse\n\t\t\t\tLogging::LogFatal(\"No input filename provided!\");\n\t\t\ti++;\n\t\t}\n\t\t\n\t\t//output param\n\t\telse if (strArgument == \"-o\" || strArgument == \"--output\")\n\t\t{\n\t\t\tif (i + 1 < in_argCount)\n\t\t\t\tstrOutputFilename = in_arguments[i + 1];\n\t\t\telse\n\t\t\t\tLogging::LogFatal(\"No output filename provided!\");\n\t\t\ti++;\n\t\t}\n\n\t\t//help\n\t\telse if (strArgument == \"-h\" || strArgument == \"--help\")\n\t\t{\n\t\t\tDisplayHelp();\n\t\t\treturn 0;\n\t\t}\n\n\t\t//skip logging level\n\t\telse if (strArgument == Logging::k_paramLoggingLevelShort || strArgument == Logging::k_paramLoggingLevel)\n\t\t{\n\t\t\ti++;\n\t\t}\n\n\t\t//failure\n\t\telse \n\t\t{\n\t\t\tLogging::LogFatal(\"Invalid argument found: \" + strArgument);\n\t\t}\n\t}\n\t\n\t//check that the required params have been provided.\n\tif (strInputFilename == \"\")\n\t\tLogging::LogFatal(\"No input provided!\");\n\tif (strOutputFilename == \"\")\n\t\tLogging::LogFatal(\"No output provided!\");\n\t\t\n\t//ensure input paths are in the correct format\n\tstrInputFilename = StringUtils::StandardisePath(strInputFilename);\n\tstrOutputFilename = StringUtils::StandardisePath(strOutputFilename);\n\n\t//check the params are valid\n\tif (StringUtils::EndsWith(StringUtils::ToLowerCase(strInputFilename), \".png\") == false)\n\t\tLogging::LogFatal(\"Input is not a png.\");\n\tif (StringUtils::EndsWith(StringUtils::ToLowerCase(strOutputFilename), \".png\") == false)\n\t\tLogging::LogFatal(\"Output is not a png.\");\n\t\t\n\t//Convert\n\tconvert(strInputFilename.c_str(), strOutputFilename.c_str());\n\t\n\t//output any errors or warnings reported and exit happily\n\tLogging::Finish();\n\treturn 0;\n}\n"
  },
  {
    "path": "Projects/Tools/PNGAlphaPremultiplier/Native/Source/PNGAlphaPremultiplier.c",
    "content": "/*\n * Copyright 2002-2010 Based on a libpng example writtent by Guillaume\n * Cottenceau. Modified by Maxime Biais to transform it to a\n * non-premultiplied alpha TO premultiplied alpha converter.\n * http://twitter.com/maximeb\n *\n * This software may be freely redistributed under the terms\n * of the X11 license.\n *\n */\n\n/*\n Modified for use in the ChilliSource engine.\n 03/02/2012, Ian Copland: Added premultiplication of palettised pngs\n 25/06/2014, Ian Copland: Minor tidy up changes.\n */\n \n/*\n Defines\n*/\n#define PNG_DEBUG 3\n#define DEFAULT_PALETTE_SIZE (256)\n#define DEFAULT_COLOUR_PALETTE_SIZE (DEFAULT_PALETTE_SIZE*3)\n#define DEFAULT_ALPHA_PALETTE_SIZE DEFAULT_PALETTE_SIZE\n#define SAFE_ALLOCATE(pointer, size, type) if(pointer!=NULL){abort_(\"trying to reallocate an already allocated pointer!\");}else{pointer=(type)malloc(size);}\n#define SAFE_DELETE(pointer) if (pointer!=NULL){free(pointer);pointer=NULL;}\n#define IN_ILOOP_RED (i*3+0)\n#define IN_ILOOP_GREEN (i*3+1)\n#define IN_ILOOP_BLUE (i*3+2)\n#define IN_ILOOP_ALPHA (i)\n\n/*\n Includes\n*/\n#include <stdlib.h>\n#include <stdio.h>\n#include <string.h>\n#include <stdarg.h>\n#include \"LibPng/png.h\"\n#include \"PNGAlphaPremultiplier.h\"\n#include \"CLogging.h\"\n/*\n Global vars\n*/\nconst char* in_filename;\nint x, y;\nint width, height;\npng_byte color_type;\npng_byte bit_depth;\n\npng_structp png_ptr;\npng_infop info_ptr;\nint number_of_passes;\npng_bytep *row_pointers;\n\n/*palettised thingies*/\nint i = 0; \nunsigned char* colour_palette = NULL;\nunsigned char* alpha_palette = NULL;\nint palette_size = 0;\npng_color_16p trans_colour;\n\nint dwNumAlpha = 0;\n\n/*\n Abort:\n Bails from the application with and error message.\n*/\nvoid abort_(const char * s, ...) \n{\n  va_list args;\n  va_start(args, s);\n  char abyMessage[1024];\n  vsprintf(abyMessage, s, args);\n  LogFatal(abyMessage);\n  va_end(args);\n}\n\n/*\nPrint Message:\nPrints out a message to std out.\n*/\nvoid print_message(const char * s, ...) \n{\n  va_list args;\n  va_start(args, s);\n  char abyMessage[1024];\n  vsprintf(abyMessage, s, args);\n  LogVerbose(abyMessage);\n  va_end(args);\n}\n\n/*\nPrint Warning:\nPrints out a warning\n*/\nvoid print_warning(const char * s, ...) \n{\n  va_list args;\n  va_start(args, s);\n  char abyMessage[1024];\n  vsprintf(abyMessage, s, args);\n  LogWarning(abyMessage);\n  va_end(args);\n}\n\n/*\n Read PNG File:\n Reads any png file.\n*/\nvoid read_png_file(const char* file_name) \n{\n  char header[8];    /*8 is the maximum size that can be checked*/\n\n  /* open file and test for it being a png */\n  FILE *fp = fopen(file_name, \"rb\");\n  if (!fp)\n\tabort_(\"[read_png_file] File %s could not be opened for reading\", file_name);\n  fread(header, 1, 8, fp);\n  if (png_sig_cmp((png_byte*)header, 0, 8))\n\tabort_(\"[read_png_file] File %s is not recognized as a PNG file\", file_name);\n\n\n  /* initialize stuff */\n  png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);\n\n  if (!png_ptr)\n\tabort_(\"[read_png_file] png_create_read_struct failed\");\n\n  info_ptr = png_create_info_struct(png_ptr);\n  if (!info_ptr)\n\tabort_(\"[read_png_file] png_create_info_struct failed\");\n\n  if (setjmp(png_jmpbuf(png_ptr)))\n\tabort_(\"[read_png_file] Error during init_io\");\n\n  png_init_io(png_ptr, fp);\n  png_set_sig_bytes(png_ptr, 8);\n\n  png_read_info(png_ptr, info_ptr);\n\n  width = png_get_image_width(png_ptr, info_ptr);\n  height = png_get_image_height(png_ptr, info_ptr);\n  color_type = png_get_color_type(png_ptr, info_ptr);\n  bit_depth = png_get_bit_depth(png_ptr, info_ptr);\n\n  number_of_passes = png_set_interlace_handling(png_ptr);\n  png_read_update_info(png_ptr, info_ptr);\n\n\n  /* read file */\n  if (setjmp(png_jmpbuf(png_ptr)))\n\tabort_(\"[read_png_file] Error during read_image\");\n\n  row_pointers = (png_bytep*) malloc(sizeof(png_bytep) * height);\n  for (y=0; y<height; y++)\n\trow_pointers[y] = (png_byte*) malloc(png_get_rowbytes(png_ptr,info_ptr));\n\n  png_read_image(png_ptr, row_pointers);\n\n  fclose(fp);\n}\n/*\n Write PNG File:\n Outputs a normal pre-multipled png.\n*/\nvoid write_png_file(const char* file_name) \n{\n  /* create file */\n  FILE *fp = fopen(file_name, \"wb\");\n  if (!fp)\n\tabort_(\"[write_png_file] File %s could not be opened for writing\", file_name);\n\n\n  /* initialize stuff */\n  png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);\n\n  if (!png_ptr)\n\tabort_(\"[write_png_file] png_create_write_struct failed\");\n\n  info_ptr = png_create_info_struct(png_ptr);\n  if (!info_ptr)\n\tabort_(\"[write_png_file] png_create_info_struct failed\");\n\n  if (setjmp(png_jmpbuf(png_ptr)))\n\tabort_(\"[write_png_file] Error during init_io\");\n\n  png_init_io(png_ptr, fp);\n\n\n  /* write header */\n  if (setjmp(png_jmpbuf(png_ptr)))\n\tabort_(\"[write_png_file] Error during writing header\");\n\n  png_set_IHDR(png_ptr, info_ptr, width, height,\n\t\t\t   bit_depth, color_type, PNG_INTERLACE_NONE,\n\t\t\t   PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);\n\n  png_write_info(png_ptr, info_ptr);\n\n\n  /* write bytes */\n  if (setjmp(png_jmpbuf(png_ptr)))\n\tabort_(\"[write_png_file] Error during writing bytes\");\n\n  png_write_image(png_ptr, row_pointers);\n\n\n  /* end write */\n  if (setjmp(png_jmpbuf(png_ptr)))\n\tabort_(\"[write_png_file] Error during end of write\");\n\n  png_write_end(png_ptr, NULL);\n\n  /* cleanup heap allocation */\n  for (y=0; y<height; y++)\n\tfree(row_pointers[y]);\n  free(row_pointers);\n\n  fclose(fp);\n}\n/*\n Check Is Premultiplied:\n Checks whether or not a normal png is already premultiplied\n*/\nint check_is_premultiplied() \n{\t   \n  for (y = 0; y < height; y++) \n  {\n\tpng_byte* row = row_pointers[y];\n\tfor (x = 0; x < width; x++) \n\t{\n\t  png_byte* ptr = &(row[x*4]);\n\t  if ((ptr[3] != 255) && (ptr[0] > ptr[3] || ptr[1] > ptr[3] \\\n\t\t\t\t\t\t\t  || ptr[2] > ptr[3]))\n\t\t  return 0;\n\t}\n  }\n  \n  return 1;\n}\n/*\n Convert File:\n Conversion to pre-multiplied alpha for normal pngs\n*/\nvoid convert_file() \n{\n  for (y = 0; y < height; y++) \n  {\n\tpng_byte* row = row_pointers[y];\n\tfor (x = 0; x < width; x++) \n\t{\n\t  png_byte* ptr = &(row[x*4]);\n\t  ptr[0] = ptr[0] * (ptr[3] / 255.);\n\t  ptr[1] = ptr[1] * (ptr[3] / 255.);\n\t  ptr[2] = ptr[2] * (ptr[3] / 255.);\n\t}\n  }\n}\n/*\n Write PNG File Palettised:\n Outputs a palettised pre-multipled png.\n*/\nvoid write_png_file_palettised(const char* file_name) \n{\n  \t/* create file */\n  \tFILE *fp = fopen(file_name, \"wb\");\n  \tif (!fp)\n\t\tabort_(\"[write_png_file] File %s could not be opened for writing\", file_name);\n\n\n \t /* initialize stuff */\n  \tpng_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);\n  \n  \tif (!png_ptr)\n\t\tabort_(\"[write_png_file] png_create_write_struct failed\");\n\n  \tinfo_ptr = png_create_info_struct(png_ptr);\n  \tif (!info_ptr)\n\t\tabort_(\"[write_png_file] png_create_info_struct failed\");\n\n \tif (setjmp(png_jmpbuf(png_ptr)))\n\t\tabort_(\"[write_png_file] Error during init_io\");\n\n \t png_init_io(png_ptr, fp);\n\n\n  \t/* write header */\n  \tif (setjmp(png_jmpbuf(png_ptr)))\n\t\tabort_(\"[write_png_file] Error during writing header\");\n\n  \tpng_set_IHDR(png_ptr, info_ptr, width, height,\n\t\t\t   \tbit_depth, color_type, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);\n\n\t/*set colour palette*/\n\tpng_colorp palette = NULL;\n\tSAFE_ALLOCATE(palette, DEFAULT_PALETTE_SIZE*sizeof(png_color), png_colorp);\n\tfor(i = 0; i < DEFAULT_PALETTE_SIZE; i++)\n\t{\n\t\tpalette[i].red   = colour_palette[IN_ILOOP_RED];\n\t\tpalette[i].green = colour_palette[IN_ILOOP_GREEN];\n\t\tpalette[i].blue  = colour_palette[IN_ILOOP_BLUE];\n\t}\n\tpng_set_PLTE(png_ptr, info_ptr, palette, DEFAULT_PALETTE_SIZE);\n\t\n\t/*set alpha palette*/\n\tpng_bytep alpha_ptr = NULL;\n\tSAFE_ALLOCATE(alpha_ptr, dwNumAlpha, png_bytep);\n\tfor(i = 0; i < dwNumAlpha; i++)\n\t{\n\t\t alpha_ptr[i] = alpha_palette[IN_ILOOP_ALPHA];\n\t}\n\tpng_set_tRNS(png_ptr, info_ptr, alpha_ptr, dwNumAlpha, NULL);\n\t\n\t/*write info*/\n  \tpng_write_info(png_ptr, info_ptr);\n\n  \t/* write bytes */\n  \tif (setjmp(png_jmpbuf(png_ptr)))\n\t\tabort_(\"[write_png_file] Error during writing bytes\");\n\n  \tpng_write_image(png_ptr, row_pointers);\n\n\t/* end write */\n  \tif (setjmp(png_jmpbuf(png_ptr)))\n\t\tabort_(\"[write_png_file] Error during end of write\");\n\n  \tpng_write_end(png_ptr, NULL);\n\n  \t/* cleanup heap allocation */\n  \tfor (y=0; y<height; y++)\n\t\tfree(row_pointers[y]);\n  \tfree(row_pointers);\n\n  \t/*cleanup palette data*/\n  \tSAFE_DELETE(colour_palette);\n  \tSAFE_DELETE(alpha_palette);\n\tSAFE_DELETE(alpha_ptr);\n\tSAFE_DELETE(palette);\n\n  \tfclose(fp);\n}\n/*\n Check Is Premultiplied Palettised:\n Checks whether or not a palettised png is already premultiplied\n*/\nint check_is_premultiplied_palettised() \n{\t  \n\tfor (i = 0; i < palette_size; i++) \n\t{\n\t\tunsigned char r = colour_palette[IN_ILOOP_RED];\n\t\tunsigned char g = colour_palette[IN_ILOOP_GREEN];\n\t\tunsigned char b = colour_palette[IN_ILOOP_BLUE];\n\t\tunsigned char a = alpha_palette[IN_ILOOP_ALPHA];\n\t\tif ((a != 255) && (r > a || g > a || b > a))\n\t\t\treturn 0;\n\t}\n  \n  \treturn 1;\n}\n/*\n Convert File Palettised:\n Conversion to pre-multiplied alpha for palettised pngs\n*/\nvoid convert_file_palettised() \n{\n    for (i = 0; i < palette_size; i++) \n  \t{\n\t  \tcolour_palette[IN_ILOOP_RED] = colour_palette[IN_ILOOP_RED] * (alpha_palette[IN_ILOOP_ALPHA] / 255.);\n\t  \tcolour_palette[IN_ILOOP_GREEN] = colour_palette[IN_ILOOP_GREEN] * (alpha_palette[IN_ILOOP_ALPHA] / 255.);\n\t  \tcolour_palette[IN_ILOOP_BLUE] = colour_palette[IN_ILOOP_BLUE] * (alpha_palette[IN_ILOOP_ALPHA] / 255.);\n  \t}\n}\n/*\n Read Palette:\n Reads the additional palette data.\n*/\nint read_palette()\n{\n\tpng_bytep alpha_ptr;\n\tpng_colorp palette;\n\t\n\t/*Create the palette date*/\n\tSAFE_ALLOCATE(colour_palette, DEFAULT_COLOUR_PALETTE_SIZE, unsigned char*);\n\tpng_get_PLTE(png_ptr, info_ptr, &palette, &palette_size);\n\tfor(i = 0; i < palette_size; i++)\n\t{\n\t\tcolour_palette[IN_ILOOP_RED] = palette[i].red;\n\t\tcolour_palette[IN_ILOOP_GREEN] = palette[i].green;\n\t\tcolour_palette[IN_ILOOP_BLUE] = palette[i].blue;\n\t}\n\t\t\t\t\n\t/*If there is transparency data, then get it too. if theres not, we have a problem...*/\n\tif (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS))\n\t{\n\t\tpng_get_tRNS(png_ptr, info_ptr, &alpha_ptr, &dwNumAlpha, &trans_colour);\n\n\t\tSAFE_ALLOCATE(alpha_palette, dwNumAlpha, unsigned char*);\n\t\t\n\t\tint dwSizeMismatch = 0;\n\t\tif (palette_size != dwNumAlpha)\n\t\t{\n\t\t\tprint_warning(\"%s does not have a supported alpha palette size. Output will be identical input.\", in_filename);\n\t\t\tdwSizeMismatch = 1;\n\t\t}\n\t\t\t\n\t\tfor(i = 0; i < dwNumAlpha; i++)\n\t\t{\n\t\t\talpha_palette[IN_ILOOP_ALPHA] = alpha_ptr[i];\t\n\t\t}\t\n\n\t\tif(dwSizeMismatch == 1)\n\t\t\treturn 0;\n\t}\n\telse\n\t{\n\t\tSAFE_DELETE(colour_palette);\n\t\tprint_warning(\"%s does not have an alpha channel. Output will be identical input.\", in_filename);\n\t\treturn 0;\n\t}\n\t\n\treturn 1;\n}\n/*\n convert\n entry point for the conversion\n*/\nvoid convert(const char* input, const char* output) \n{\n\tin_filename = input;\n\n\t/*load the png*/\n  \tread_png_file(in_filename);\n  \t\n  \t/*check that the png of a type we can use*/\n  \tint type = png_get_color_type(png_ptr, info_ptr);\n  \t\n  \t/*perform different conversions based on the type*/\n  \tswitch(type)\n  \t{\n  \t\tcase PNG_COLOR_TYPE_RGBA:\n\t\t\tif (check_is_premultiplied() != 0)\n\t\t\t\tprint_warning(\"%s is already pre-multiplied. Output will be identical to input.\", in_filename);\n\t\t\telse\n\t\t\t\tconvert_file();\n  \t\t\twrite_png_file(output);\n  \t\t\tbreak;\n\t\tcase PNG_COLOR_TYPE_RGB:\n\t\t\twrite_png_file(output);\n\t\t\tbreak;\n\t\tcase PNG_COLOR_TYPE_PALETTE:\n  \t\t\tif (read_palette() != 0)\n\t\t\t{\n\t\t\t\tif (check_is_premultiplied_palettised() != 0)\n\t\t\t\t\tprint_warning(\"%s is already pre-multiplied. Output will be identical to input.\", in_filename);\n\t\t\t\telse\n\t\t\t\t\tconvert_file_palettised();\n\t\t\t}\n  \t\t\twrite_png_file_palettised(output);\n  \t\t\tbreak;\n  \t\tdefault:\n  \t\t\tprint_warning(\"%s is in an unsupported format. Output will be identical to input.\", in_filename);\n\t\t\twrite_png_file(output);\n  \t\t\tbreak;\n  \t}\n}\n"
  },
  {
    "path": "Projects/Tools/PNGAlphaPremultiplier/Native/Source/PNGAlphaPremultiplier.h",
    "content": "/**\n * PNGAlphaPremultiplier.h\n * ChilliSource\n * Created by Ian Copland on 20/06/2014.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2014 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\n#ifndef _PNGALPHAPREMULTIPLIER_PNGALPHAPREMULTIPLIER_H_\n#define _PNGALPHAPREMULTIPLIER_PNGALPHAPREMULTIPLIER_H_\n\n#ifdef __cplusplus\nextern \"C\" \n{\n#endif \n\n/**\n * Loads the given input file, premultiplies the alpha and saves\n * as the given output file.\n * \n * @param The input file path.\n * @param The output file path.\n */\nvoid convert(const char* input, const char* output);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "Projects/Tools/PNGAlphaPremultiplier/Native/Source/StringUtils.cpp",
    "content": "//\r\n//  StringUtils.cpp\r\n//  ChilliSource\r\n//  Created by Ian Copland on 16/03/2012.\r\n//\r\n//  The MIT License (MIT)\r\n//\r\n//  Copyright (c) 2012 Tag Games Limited\r\n//\r\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\r\n//  of this software and associated documentation files (the \"Software\"), to deal\r\n//  in the Software without restriction, including without limitation the rights\r\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\n//  copies of the Software, and to permit persons to whom the Software is\r\n//  furnished to do so, subject to the following conditions:\r\n//\r\n//  The above copyright notice and this permission notice shall be included in\r\n//  all copies or substantial portions of the Software.\r\n//\r\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r\n//  THE SOFTWARE.\r\n//\r\n\r\n#include \"StringUtils.h\"\r\n\r\n#include <algorithm>\r\n\r\nnamespace StringUtils\r\n{\r\n\t//--------------------------------------------------------\r\n\t//--------------------------------------------------------\r\n\tstd::string StandardisePath(const std::string& in_path)\r\n\t{\r\n\t\tstd::string strPath = in_path;\r\n\t\tstd::replace( strPath.begin(), strPath.end(), '\\\\', '/' );\r\n\t\tstrPath = ReplaceAll(strPath, \"//\", \"/\");\r\n\r\n        if(strPath.find('.') == std::string::npos)\r\n        {\r\n            if( strPath.length() != 0 && strPath[strPath.length() - 1] != '/' )\r\n                strPath += '/';\r\n        }\r\n\t\t\r\n\t\treturn strPath;\r\n\t}\r\n\t//--------------------------------------------------------\r\n\t//--------------------------------------------------------\r\n\tstd::string ToLowerCase(const std::string& in_string)\r\n\t{\r\n\t\tstd::string strOutput = in_string;\r\n\t\tstd::transform(strOutput.begin(), strOutput.end(), strOutput.begin(), tolower);\r\n\t\treturn strOutput;\r\n\t}\r\n\t//--------------------------------------------------------\r\n\t//--------------------------------------------------------\r\n\tstd::string ToUpperCase(const std::string& in_string)\r\n\t{\r\n\t\tstd::string strOutput = in_string;\r\n\t\tstd::transform(strOutput.begin(), strOutput.end(), strOutput.begin(), toupper);\r\n\t\treturn strOutput;\r\n\t}\r\n\t//--------------------------------------------------------\r\n\t//--------------------------------------------------------\r\n\tbool StartsWith(const std::string& in_string, const std::string& in_pattern)\r\n\t{\r\n\t\tsize_t thisLen = in_string.length();\r\n\t\tsize_t patternLen = in_pattern.length();\r\n\t\tif (thisLen < patternLen || patternLen == 0)\r\n\t\t\treturn false;\r\n\t\t\r\n\t\tstd::string startOfThis = in_string.substr(0, patternLen);\r\n        std::string strPattern = in_pattern;\r\n\t\t\r\n\t\treturn (startOfThis == strPattern);\r\n\t}\r\n\t//--------------------------------------------------------\r\n\t//--------------------------------------------------------\r\n\tbool EndsWith(const std::string& in_string, const std::string& in_pattern)\r\n\t{\r\n\t\tsize_t thisLen = in_string.length();\r\n\t\tsize_t patternLen = in_pattern.length();\r\n\t\tif (thisLen < patternLen || patternLen == 0)\r\n\t\t\treturn false;\r\n\t\t\r\n\t\tstd::string endOfThis = in_string.substr(thisLen - patternLen, patternLen);\r\n        std::string strPattern = in_pattern;\r\n\r\n\t\treturn (endOfThis == strPattern);\r\n\t}\r\n\t//--------------------------------------------------------\r\n\t//--------------------------------------------------------\r\n    std::string ReplaceAll(const std::string& in_source, const std::string& in_replaceWhat, const std::string& in_replaceWithWhat)\r\n    {\r\n    \tstd::string result = in_source;\r\n        while(1)\r\n        {\r\n            std::string::size_type pos = result.find(in_replaceWhat);\r\n            if (pos == std::string::npos) break;\r\n            result.replace(pos,in_replaceWhat.size(),in_replaceWithWhat);\r\n        }\r\n        return result;\r\n    }\r\n\t//--------------------------------------------------------\r\n\t//--------------------------------------------------------\r\n\ttemplate<> std::string StringCast<>(bool in_value)\r\n\t{\r\n\t\tif (in_value == true)\r\n\t\t{\r\n\t\t\treturn \"true\";\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\treturn \"false\";\r\n\t\t}\r\n\t}\r\n}\r\n"
  },
  {
    "path": "Projects/Tools/PNGAlphaPremultiplier/Native/Source/StringUtils.h",
    "content": "//\r\n//  StringUtils.h\r\n//  ChilliSource\r\n//  Created by Ian Copland on 16/03/2012.\r\n//\r\n//  The MIT License (MIT)\r\n//\r\n//  Copyright (c) 2012 Tag Games Limited\r\n//\r\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\r\n//  of this software and associated documentation files (the \"Software\"), to deal\r\n//  in the Software without restriction, including without limitation the rights\r\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\n//  copies of the Software, and to permit persons to whom the Software is\r\n//  furnished to do so, subject to the following conditions:\r\n//\r\n//  The above copyright notice and this permission notice shall be included in\r\n//  all copies or substantial portions of the Software.\r\n//\r\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r\n//  THE SOFTWARE.\r\n//\r\n\r\n#ifndef _PNGALPHAPREMULTIPLIER_STRINGUTILS_H_\r\n#define _PNGALPHAPREMULTIPLIER_STRINGUTILS_H_\r\n \r\n#include <string>\r\n#include <sstream>\r\n\r\n//---------------------------------------------------------------\r\n/// A collection of convenience functions for working with strings.\r\n///\r\n/// @author Ian Copland\r\n//---------------------------------------------------------------\r\nnamespace StringUtils\r\n{\r\n\t//--------------------------------------------------------\r\n\t/// Ensures a filepath is in the correct format. This will\r\n\t/// ensure \"/\" is used, remove preceeding \"/\" and append\r\n\t/// \"/\" to the end if the path does not contain a \".\"\r\n\t///\r\n\t/// @author Ian Copland\r\n\t///\r\n\t/// @param the original path.\r\n\t///\r\n\t/// @return the standardised path.\r\n\t//--------------------------------------------------------\r\n\tstd::string StandardisePath(const std::string& in_path);\r\n\t//--------------------------------------------------------\r\n\t/// Returns the equivalent string in all lower case.\r\n\t///\r\n\t/// @author Ian Copland\r\n\t///\r\n\t/// @param the input string.\r\n\t///\r\n\t/// @return the output string.\r\n\t//--------------------------------------------------------\r\n\tstd::string ToLowerCase(const std::string& in_string);\r\n\t//--------------------------------------------------------\r\n\t/// Returns the equivalent string in all upper case.\r\n\t///\r\n\t/// @author Ian Copland\r\n\t///\r\n\t/// @param the input string.\r\n\t///\r\n\t/// @param the output string.\r\n\t//--------------------------------------------------------\r\n\tstd::string ToUpperCase(const std::string& in_string);\r\n\t//--------------------------------------------------------\r\n\t/// Returns whether the string begins with the pattern \r\n\t/// passed in.\r\n\t///\r\n\t/// @author Ian Copland\r\n\t///\r\n\t/// @param The input string.\r\n\t/// @param The pattern to compare with.\r\n\t///\r\n\t/// @return Whether or not the pattern matches.\r\n\t//--------------------------------------------------------\r\n\tbool StartsWith(const std::string& in_string, const std::string& in_pattern);\r\n\t//--------------------------------------------------------\r\n\t/// Returns whether the string ends with the pattern passed \r\n\t/// in.\r\n\t///\r\n\t/// @author Ian Copland\r\n\t///\r\n\t/// @param The input string.\r\n\t/// @param The pattern to compare with.\r\n\t///\r\n\t/// @return Whether or not the pattern matches.\r\n\t//--------------------------------------------------------\r\n\tbool EndsWith(const std::string& in_string, const std::string& in_pattern);\r\n\t//--------------------------------------------------------\r\n\t/// Replaces all instances of a string \"replaceWhat\" with\r\n\t/// string \"replaceWithWhat\" in the source string.\r\n\t///\r\n\t/// @author Ian Copland\r\n\t///\r\n\t/// @param The source string.\r\n\t/// @param The string to replace.\r\n\t/// @param The string to replace with.\r\n\t///\r\n\t/// @return The output string.\r\n\t//--------------------------------------------------------\r\n    std::string ReplaceAll(const std::string& in_source, const std::string& in_replaceWhat, const std::string& in_replaceWithWhat);\r\n\t//--------------------------------------------------------\r\n\t/// Converts a value to a string.\r\n\t///\r\n\t/// @author Ian Copland\r\n\t///\r\n\t/// @param the value.\r\n\t///\r\n\t/// @return the string.\r\n\t//--------------------------------------------------------\r\n\ttemplate<class T> std::string StringCast(T in_value)\r\n\t{\r\n\t\tstd::stringstream stream;\r\n\t\tstream << in_value;\r\n\t\treturn stream.str();\r\n\t}\r\n\t//--------------------------------------------------------\r\n\t/// Casts a bool to a string.\r\n\t///\r\n\t/// @author Ian Copland\r\n\t///\r\n\t/// @param the bool.\r\n\t///\r\n\t/// @return the string.\r\n\t//--------------------------------------------------------\r\n\ttemplate<> std::string StringCast<>(bool in_value);\r\n\t//--------------------------------------------------------\r\n\t/// Parses the content of a string to a base type.\r\n\t///\r\n\t/// @author Ian Copland\r\n\t///\r\n\t/// @param The string.\r\n\t///\r\n\t/// @return the value.\r\n\t//--------------------------------------------------------\r\n\ttemplate<class T> T ParseString(const std::string& in_string)\r\n\t{\r\n\t\tstd::istringstream stream(in_string);\r\n\t\tT output;\r\n\t\tstream >> output;\r\n\t\treturn output;\r\n\t}\r\n}\r\n\r\n#endif\r\n"
  },
  {
    "path": "Projects/Tools/PNGAlphaPremultiplier/Native/Source/ZLib/adler32.c",
    "content": "/* adler32.c -- compute the Adler-32 checksum of a data stream\n * Copyright (C) 1995-2011 Mark Adler\n * For conditions of distribution and use, see copyright notice in zlib.h\n */\n\n/* @(#) $Id$ */\n\n#include \"zutil.h\"\n\n#define local static\n\nlocal uLong adler32_combine_ OF((uLong adler1, uLong adler2, z_off64_t len2));\n\n#define BASE 65521      /* largest prime smaller than 65536 */\n#define NMAX 5552\n/* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */\n\n#define DO1(buf,i)  {adler += (buf)[i]; sum2 += adler;}\n#define DO2(buf,i)  DO1(buf,i); DO1(buf,i+1);\n#define DO4(buf,i)  DO2(buf,i); DO2(buf,i+2);\n#define DO8(buf,i)  DO4(buf,i); DO4(buf,i+4);\n#define DO16(buf)   DO8(buf,0); DO8(buf,8);\n\n/* use NO_DIVIDE if your processor does not do division in hardware --\n   try it both ways to see which is faster */\n#ifdef NO_DIVIDE\n/* note that this assumes BASE is 65521, where 65536 % 65521 == 15\n   (thank you to John Reiser for pointing this out) */\n#  define CHOP(a) \\\n    do { \\\n        unsigned long tmp = a >> 16; \\\n        a &= 0xffffUL; \\\n        a += (tmp << 4) - tmp; \\\n    } while (0)\n#  define MOD28(a) \\\n    do { \\\n        CHOP(a); \\\n        if (a >= BASE) a -= BASE; \\\n    } while (0)\n#  define MOD(a) \\\n    do { \\\n        CHOP(a); \\\n        MOD28(a); \\\n    } while (0)\n#  define MOD63(a) \\\n    do { /* this assumes a is not negative */ \\\n        z_off64_t tmp = a >> 32; \\\n        a &= 0xffffffffL; \\\n        a += (tmp << 8) - (tmp << 5) + tmp; \\\n        tmp = a >> 16; \\\n        a &= 0xffffL; \\\n        a += (tmp << 4) - tmp; \\\n        tmp = a >> 16; \\\n        a &= 0xffffL; \\\n        a += (tmp << 4) - tmp; \\\n        if (a >= BASE) a -= BASE; \\\n    } while (0)\n#else\n#  define MOD(a) a %= BASE\n#  define MOD28(a) a %= BASE\n#  define MOD63(a) a %= BASE\n#endif\n\n/* ========================================================================= */\nuLong ZEXPORT adler32(adler, buf, len)\n    uLong adler;\n    const Bytef *buf;\n    uInt len;\n{\n    unsigned long sum2;\n    unsigned n;\n\n    /* split Adler-32 into component sums */\n    sum2 = (adler >> 16) & 0xffff;\n    adler &= 0xffff;\n\n    /* in case user likes doing a byte at a time, keep it fast */\n    if (len == 1) {\n        adler += buf[0];\n        if (adler >= BASE)\n            adler -= BASE;\n        sum2 += adler;\n        if (sum2 >= BASE)\n            sum2 -= BASE;\n        return adler | (sum2 << 16);\n    }\n\n    /* initial Adler-32 value (deferred check for len == 1 speed) */\n    if (buf == Z_NULL)\n        return 1L;\n\n    /* in case short lengths are provided, keep it somewhat fast */\n    if (len < 16) {\n        while (len--) {\n            adler += *buf++;\n            sum2 += adler;\n        }\n        if (adler >= BASE)\n            adler -= BASE;\n        MOD28(sum2);            /* only added so many BASE's */\n        return adler | (sum2 << 16);\n    }\n\n    /* do length NMAX blocks -- requires just one modulo operation */\n    while (len >= NMAX) {\n        len -= NMAX;\n        n = NMAX / 16;          /* NMAX is divisible by 16 */\n        do {\n            DO16(buf);          /* 16 sums unrolled */\n            buf += 16;\n        } while (--n);\n        MOD(adler);\n        MOD(sum2);\n    }\n\n    /* do remaining bytes (less than NMAX, still just one modulo) */\n    if (len) {                  /* avoid modulos if none remaining */\n        while (len >= 16) {\n            len -= 16;\n            DO16(buf);\n            buf += 16;\n        }\n        while (len--) {\n            adler += *buf++;\n            sum2 += adler;\n        }\n        MOD(adler);\n        MOD(sum2);\n    }\n\n    /* return recombined sums */\n    return adler | (sum2 << 16);\n}\n\n/* ========================================================================= */\nlocal uLong adler32_combine_(adler1, adler2, len2)\n    uLong adler1;\n    uLong adler2;\n    z_off64_t len2;\n{\n    unsigned long sum1;\n    unsigned long sum2;\n    unsigned rem;\n\n    /* for negative len, return invalid adler32 as a clue for debugging */\n    if (len2 < 0)\n        return 0xffffffffUL;\n\n    /* the derivation of this formula is left as an exercise for the reader */\n    MOD63(len2);                /* assumes len2 >= 0 */\n    rem = (unsigned)len2;\n    sum1 = adler1 & 0xffff;\n    sum2 = rem * sum1;\n    MOD(sum2);\n    sum1 += (adler2 & 0xffff) + BASE - 1;\n    sum2 += ((adler1 >> 16) & 0xffff) + ((adler2 >> 16) & 0xffff) + BASE - rem;\n    if (sum1 >= BASE) sum1 -= BASE;\n    if (sum1 >= BASE) sum1 -= BASE;\n    if (sum2 >= (BASE << 1)) sum2 -= (BASE << 1);\n    if (sum2 >= BASE) sum2 -= BASE;\n    return sum1 | (sum2 << 16);\n}\n\n/* ========================================================================= */\nuLong ZEXPORT adler32_combine(adler1, adler2, len2)\n    uLong adler1;\n    uLong adler2;\n    z_off_t len2;\n{\n    return adler32_combine_(adler1, adler2, len2);\n}\n\nuLong ZEXPORT adler32_combine64(adler1, adler2, len2)\n    uLong adler1;\n    uLong adler2;\n    z_off64_t len2;\n{\n    return adler32_combine_(adler1, adler2, len2);\n}\n"
  },
  {
    "path": "Projects/Tools/PNGAlphaPremultiplier/Native/Source/ZLib/compress.c",
    "content": "/* compress.c -- compress a memory buffer\n * Copyright (C) 1995-2005 Jean-loup Gailly.\n * For conditions of distribution and use, see copyright notice in zlib.h\n */\n\n/* @(#) $Id$ */\n\n#define ZLIB_INTERNAL\n#include \"zlib.h\"\n\n/* ===========================================================================\n     Compresses the source buffer into the destination buffer. The level\n   parameter has the same meaning as in deflateInit.  sourceLen is the byte\n   length of the source buffer. Upon entry, destLen is the total size of the\n   destination buffer, which must be at least 0.1% larger than sourceLen plus\n   12 bytes. Upon exit, destLen is the actual size of the compressed buffer.\n\n     compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough\n   memory, Z_BUF_ERROR if there was not enough room in the output buffer,\n   Z_STREAM_ERROR if the level parameter is invalid.\n*/\nint ZEXPORT compress2 (dest, destLen, source, sourceLen, level)\n    Bytef *dest;\n    uLongf *destLen;\n    const Bytef *source;\n    uLong sourceLen;\n    int level;\n{\n    z_stream stream;\n    int err;\n\n    stream.next_in = (Bytef*)source;\n    stream.avail_in = (uInt)sourceLen;\n#ifdef MAXSEG_64K\n    /* Check for source > 64K on 16-bit machine: */\n    if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR;\n#endif\n    stream.next_out = dest;\n    stream.avail_out = (uInt)*destLen;\n    if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR;\n\n    stream.zalloc = (alloc_func)0;\n    stream.zfree = (free_func)0;\n    stream.opaque = (voidpf)0;\n\n    err = deflateInit(&stream, level);\n    if (err != Z_OK) return err;\n\n    err = deflate(&stream, Z_FINISH);\n    if (err != Z_STREAM_END) {\n        deflateEnd(&stream);\n        return err == Z_OK ? Z_BUF_ERROR : err;\n    }\n    *destLen = stream.total_out;\n\n    err = deflateEnd(&stream);\n    return err;\n}\n\n/* ===========================================================================\n */\nint ZEXPORT compress (dest, destLen, source, sourceLen)\n    Bytef *dest;\n    uLongf *destLen;\n    const Bytef *source;\n    uLong sourceLen;\n{\n    return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION);\n}\n\n/* ===========================================================================\n     If the default memLevel or windowBits for deflateInit() is changed, then\n   this function needs to be updated.\n */\nuLong ZEXPORT compressBound (sourceLen)\n    uLong sourceLen;\n{\n    return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) +\n           (sourceLen >> 25) + 13;\n}\n"
  },
  {
    "path": "Projects/Tools/PNGAlphaPremultiplier/Native/Source/ZLib/crc32.c",
    "content": "/* crc32.c -- compute the CRC-32 of a data stream\n * Copyright (C) 1995-2006, 2010, 2011 Mark Adler\n * For conditions of distribution and use, see copyright notice in zlib.h\n *\n * Thanks to Rodney Brown <rbrown64@csc.com.au> for his contribution of faster\n * CRC methods: exclusive-oring 32 bits of data at a time, and pre-computing\n * tables for updating the shift register in one step with three exclusive-ors\n * instead of four steps with four exclusive-ors.  This results in about a\n * factor of two increase in speed on a Power PC G4 (PPC7455) using gcc -O3.\n */\n\n/* @(#) $Id$ */\n\n/*\n  Note on the use of DYNAMIC_CRC_TABLE: there is no mutex or semaphore\n  protection on the static variables used to control the first-use generation\n  of the crc tables.  Therefore, if you #define DYNAMIC_CRC_TABLE, you should\n  first call get_crc_table() to initialize the tables before allowing more than\n  one thread to use crc32().\n\n  DYNAMIC_CRC_TABLE and MAKECRCH can be #defined to write out crc32.h.\n */\n\n#ifdef MAKECRCH\n#  include <stdio.h>\n#  ifndef DYNAMIC_CRC_TABLE\n#    define DYNAMIC_CRC_TABLE\n#  endif /* !DYNAMIC_CRC_TABLE */\n#endif /* MAKECRCH */\n\n#include \"zutil.h\"      /* for STDC and FAR definitions */\n\n#define local static\n\n/* Find a four-byte integer type for crc32_little() and crc32_big(). */\n#ifndef NOBYFOUR\n#  ifdef STDC           /* need ANSI C limits.h to determine sizes */\n#    include <limits.h>\n#    define BYFOUR\n#    if (UINT_MAX == 0xffffffffUL)\n       typedef unsigned int u4;\n#    else\n#      if (ULONG_MAX == 0xffffffffUL)\n         typedef unsigned long u4;\n#      else\n#        if (USHRT_MAX == 0xffffffffUL)\n           typedef unsigned short u4;\n#        else\n#          undef BYFOUR     /* can't find a four-byte integer type! */\n#        endif\n#      endif\n#    endif\n#  endif /* STDC */\n#endif /* !NOBYFOUR */\n\n/* Definitions for doing the crc four data bytes at a time. */\n#ifdef BYFOUR\n   typedef u4 crc_table_t;\n#  define REV(w) ((((w)>>24)&0xff)+(((w)>>8)&0xff00)+ \\\n                (((w)&0xff00)<<8)+(((w)&0xff)<<24))\n   local unsigned long crc32_little OF((unsigned long,\n                        const unsigned char FAR *, unsigned));\n   local unsigned long crc32_big OF((unsigned long,\n                        const unsigned char FAR *, unsigned));\n#  define TBLS 8\n#else\n   typedef unsigned long crc_table_t;\n#  define TBLS 1\n#endif /* BYFOUR */\n\n/* Local functions for crc concatenation */\nlocal unsigned long gf2_matrix_times OF((unsigned long *mat,\n                                         unsigned long vec));\nlocal void gf2_matrix_square OF((unsigned long *square, unsigned long *mat));\nlocal uLong crc32_combine_ OF((uLong crc1, uLong crc2, z_off64_t len2));\n\n\n#ifdef DYNAMIC_CRC_TABLE\n\nlocal volatile int crc_table_empty = 1;\nlocal crc_table_t FAR crc_table[TBLS][256];\nlocal void make_crc_table OF((void));\n#ifdef MAKECRCH\n   local void write_table OF((FILE *, const crc_table_t FAR *));\n#endif /* MAKECRCH */\n/*\n  Generate tables for a byte-wise 32-bit CRC calculation on the polynomial:\n  x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x+1.\n\n  Polynomials over GF(2) are represented in binary, one bit per coefficient,\n  with the lowest powers in the most significant bit.  Then adding polynomials\n  is just exclusive-or, and multiplying a polynomial by x is a right shift by\n  one.  If we call the above polynomial p, and represent a byte as the\n  polynomial q, also with the lowest power in the most significant bit (so the\n  byte 0xb1 is the polynomial x^7+x^3+x+1), then the CRC is (q*x^32) mod p,\n  where a mod b means the remainder after dividing a by b.\n\n  This calculation is done using the shift-register method of multiplying and\n  taking the remainder.  The register is initialized to zero, and for each\n  incoming bit, x^32 is added mod p to the register if the bit is a one (where\n  x^32 mod p is p+x^32 = x^26+...+1), and the register is multiplied mod p by\n  x (which is shifting right by one and adding x^32 mod p if the bit shifted\n  out is a one).  We start with the highest power (least significant bit) of\n  q and repeat for all eight bits of q.\n\n  The first table is simply the CRC of all possible eight bit values.  This is\n  all the information needed to generate CRCs on data a byte at a time for all\n  combinations of CRC register values and incoming bytes.  The remaining tables\n  allow for word-at-a-time CRC calculation for both big-endian and little-\n  endian machines, where a word is four bytes.\n*/\nlocal void make_crc_table()\n{\n    crc_table_t c;\n    int n, k;\n    crc_table_t poly;                   /* polynomial exclusive-or pattern */\n    /* terms of polynomial defining this crc (except x^32): */\n    static volatile int first = 1;      /* flag to limit concurrent making */\n    static const unsigned char p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26};\n\n    /* See if another task is already doing this (not thread-safe, but better\n       than nothing -- significantly reduces duration of vulnerability in\n       case the advice about DYNAMIC_CRC_TABLE is ignored) */\n    if (first) {\n        first = 0;\n\n        /* make exclusive-or pattern from polynomial (0xedb88320UL) */\n        poly = 0;\n        for (n = 0; n < (int)(sizeof(p)/sizeof(unsigned char)); n++)\n            poly |= (crc_table_t)1 << (31 - p[n]);\n\n        /* generate a crc for every 8-bit value */\n        for (n = 0; n < 256; n++) {\n            c = (crc_table_t)n;\n            for (k = 0; k < 8; k++)\n                c = c & 1 ? poly ^ (c >> 1) : c >> 1;\n            crc_table[0][n] = c;\n        }\n\n#ifdef BYFOUR\n        /* generate crc for each value followed by one, two, and three zeros,\n           and then the byte reversal of those as well as the first table */\n        for (n = 0; n < 256; n++) {\n            c = crc_table[0][n];\n            crc_table[4][n] = REV(c);\n            for (k = 1; k < 4; k++) {\n                c = crc_table[0][c & 0xff] ^ (c >> 8);\n                crc_table[k][n] = c;\n                crc_table[k + 4][n] = REV(c);\n            }\n        }\n#endif /* BYFOUR */\n\n        crc_table_empty = 0;\n    }\n    else {      /* not first */\n        /* wait for the other guy to finish (not efficient, but rare) */\n        while (crc_table_empty)\n            ;\n    }\n\n#ifdef MAKECRCH\n    /* write out CRC tables to crc32.h */\n    {\n        FILE *out;\n\n        out = fopen(\"crc32.h\", \"w\");\n        if (out == NULL) return;\n        fprintf(out, \"/* crc32.h -- tables for rapid CRC calculation\\n\");\n        fprintf(out, \" * Generated automatically by crc32.c\\n */\\n\\n\");\n        fprintf(out, \"local const crc_table_t FAR \");\n        fprintf(out, \"crc_table[TBLS][256] =\\n{\\n  {\\n\");\n        write_table(out, crc_table[0]);\n#  ifdef BYFOUR\n        fprintf(out, \"#ifdef BYFOUR\\n\");\n        for (k = 1; k < 8; k++) {\n            fprintf(out, \"  },\\n  {\\n\");\n            write_table(out, crc_table[k]);\n        }\n        fprintf(out, \"#endif\\n\");\n#  endif /* BYFOUR */\n        fprintf(out, \"  }\\n};\\n\");\n        fclose(out);\n    }\n#endif /* MAKECRCH */\n}\n\n#ifdef MAKECRCH\nlocal void write_table(out, table)\n    FILE *out;\n    const crc_table_t FAR *table;\n{\n    int n;\n\n    for (n = 0; n < 256; n++)\n        fprintf(out, \"%s0x%08lxUL%s\", n % 5 ? \"\" : \"    \",\n                (unsigned long)(table[n]),\n                n == 255 ? \"\\n\" : (n % 5 == 4 ? \",\\n\" : \", \"));\n}\n#endif /* MAKECRCH */\n\n#else /* !DYNAMIC_CRC_TABLE */\n/* ========================================================================\n * Tables of CRC-32s of all single-byte values, made by make_crc_table().\n */\n#include \"crc32.h\"\n#endif /* DYNAMIC_CRC_TABLE */\n\n/* =========================================================================\n * This function can be used by asm versions of crc32()\n */\nconst unsigned long FAR * ZEXPORT get_crc_table()\n{\n#ifdef DYNAMIC_CRC_TABLE\n    if (crc_table_empty)\n        make_crc_table();\n#endif /* DYNAMIC_CRC_TABLE */\n    return (const unsigned long FAR *)crc_table;\n}\n\n/* ========================================================================= */\n#define DO1 crc = crc_table[0][((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8)\n#define DO8 DO1; DO1; DO1; DO1; DO1; DO1; DO1; DO1\n\n/* ========================================================================= */\nunsigned long ZEXPORT crc32(crc, buf, len)\n    unsigned long crc;\n    const unsigned char FAR *buf;\n    uInt len;\n{\n    if (buf == Z_NULL) return 0UL;\n\n#ifdef DYNAMIC_CRC_TABLE\n    if (crc_table_empty)\n        make_crc_table();\n#endif /* DYNAMIC_CRC_TABLE */\n\n#ifdef BYFOUR\n    if (sizeof(void *) == sizeof(ptrdiff_t)) {\n        u4 endian;\n\n        endian = 1;\n        if (*((unsigned char *)(&endian)))\n            return crc32_little(crc, buf, len);\n        else\n            return crc32_big(crc, buf, len);\n    }\n#endif /* BYFOUR */\n    crc = crc ^ 0xffffffffUL;\n    while (len >= 8) {\n        DO8;\n        len -= 8;\n    }\n    if (len) do {\n        DO1;\n    } while (--len);\n    return crc ^ 0xffffffffUL;\n}\n\n#ifdef BYFOUR\n\n/* ========================================================================= */\n#define DOLIT4 c ^= *buf4++; \\\n        c = crc_table[3][c & 0xff] ^ crc_table[2][(c >> 8) & 0xff] ^ \\\n            crc_table[1][(c >> 16) & 0xff] ^ crc_table[0][c >> 24]\n#define DOLIT32 DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4\n\n/* ========================================================================= */\nlocal unsigned long crc32_little(crc, buf, len)\n    unsigned long crc;\n    const unsigned char FAR *buf;\n    unsigned len;\n{\n    register u4 c;\n    register const u4 FAR *buf4;\n\n    c = (u4)crc;\n    c = ~c;\n    while (len && ((ptrdiff_t)buf & 3)) {\n        c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8);\n        len--;\n    }\n\n    buf4 = (const u4 FAR *)(const void FAR *)buf;\n    while (len >= 32) {\n        DOLIT32;\n        len -= 32;\n    }\n    while (len >= 4) {\n        DOLIT4;\n        len -= 4;\n    }\n    buf = (const unsigned char FAR *)buf4;\n\n    if (len) do {\n        c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8);\n    } while (--len);\n    c = ~c;\n    return (unsigned long)c;\n}\n\n/* ========================================================================= */\n#define DOBIG4 c ^= *++buf4; \\\n        c = crc_table[4][c & 0xff] ^ crc_table[5][(c >> 8) & 0xff] ^ \\\n            crc_table[6][(c >> 16) & 0xff] ^ crc_table[7][c >> 24]\n#define DOBIG32 DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4\n\n/* ========================================================================= */\nlocal unsigned long crc32_big(crc, buf, len)\n    unsigned long crc;\n    const unsigned char FAR *buf;\n    unsigned len;\n{\n    register u4 c;\n    register const u4 FAR *buf4;\n\n    c = REV((u4)crc);\n    c = ~c;\n    while (len && ((ptrdiff_t)buf & 3)) {\n        c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8);\n        len--;\n    }\n\n    buf4 = (const u4 FAR *)(const void FAR *)buf;\n    buf4--;\n    while (len >= 32) {\n        DOBIG32;\n        len -= 32;\n    }\n    while (len >= 4) {\n        DOBIG4;\n        len -= 4;\n    }\n    buf4++;\n    buf = (const unsigned char FAR *)buf4;\n\n    if (len) do {\n        c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8);\n    } while (--len);\n    c = ~c;\n    return (unsigned long)(REV(c));\n}\n\n#endif /* BYFOUR */\n\n#define GF2_DIM 32      /* dimension of GF(2) vectors (length of CRC) */\n\n/* ========================================================================= */\nlocal unsigned long gf2_matrix_times(mat, vec)\n    unsigned long *mat;\n    unsigned long vec;\n{\n    unsigned long sum;\n\n    sum = 0;\n    while (vec) {\n        if (vec & 1)\n            sum ^= *mat;\n        vec >>= 1;\n        mat++;\n    }\n    return sum;\n}\n\n/* ========================================================================= */\nlocal void gf2_matrix_square(square, mat)\n    unsigned long *square;\n    unsigned long *mat;\n{\n    int n;\n\n    for (n = 0; n < GF2_DIM; n++)\n        square[n] = gf2_matrix_times(mat, mat[n]);\n}\n\n/* ========================================================================= */\nlocal uLong crc32_combine_(crc1, crc2, len2)\n    uLong crc1;\n    uLong crc2;\n    z_off64_t len2;\n{\n    int n;\n    unsigned long row;\n    unsigned long even[GF2_DIM];    /* even-power-of-two zeros operator */\n    unsigned long odd[GF2_DIM];     /* odd-power-of-two zeros operator */\n\n    /* degenerate case (also disallow negative lengths) */\n    if (len2 <= 0)\n        return crc1;\n\n    /* put operator for one zero bit in odd */\n    odd[0] = 0xedb88320UL;          /* CRC-32 polynomial */\n    row = 1;\n    for (n = 1; n < GF2_DIM; n++) {\n        odd[n] = row;\n        row <<= 1;\n    }\n\n    /* put operator for two zero bits in even */\n    gf2_matrix_square(even, odd);\n\n    /* put operator for four zero bits in odd */\n    gf2_matrix_square(odd, even);\n\n    /* apply len2 zeros to crc1 (first square will put the operator for one\n       zero byte, eight zero bits, in even) */\n    do {\n        /* apply zeros operator for this bit of len2 */\n        gf2_matrix_square(even, odd);\n        if (len2 & 1)\n            crc1 = gf2_matrix_times(even, crc1);\n        len2 >>= 1;\n\n        /* if no more bits set, then done */\n        if (len2 == 0)\n            break;\n\n        /* another iteration of the loop with odd and even swapped */\n        gf2_matrix_square(odd, even);\n        if (len2 & 1)\n            crc1 = gf2_matrix_times(odd, crc1);\n        len2 >>= 1;\n\n        /* if no more bits set, then done */\n    } while (len2 != 0);\n\n    /* return combined crc */\n    crc1 ^= crc2;\n    return crc1;\n}\n\n/* ========================================================================= */\nuLong ZEXPORT crc32_combine(crc1, crc2, len2)\n    uLong crc1;\n    uLong crc2;\n    z_off_t len2;\n{\n    return crc32_combine_(crc1, crc2, len2);\n}\n\nuLong ZEXPORT crc32_combine64(crc1, crc2, len2)\n    uLong crc1;\n    uLong crc2;\n    z_off64_t len2;\n{\n    return crc32_combine_(crc1, crc2, len2);\n}\n"
  },
  {
    "path": "Projects/Tools/PNGAlphaPremultiplier/Native/Source/ZLib/crc32.h",
    "content": "/* crc32.h -- tables for rapid CRC calculation\n * Generated automatically by crc32.c\n */\n\nlocal const crc_table_t FAR crc_table[TBLS][256] =\n{\n  {\n    0x00000000UL, 0x77073096UL, 0xee0e612cUL, 0x990951baUL, 0x076dc419UL,\n    0x706af48fUL, 0xe963a535UL, 0x9e6495a3UL, 0x0edb8832UL, 0x79dcb8a4UL,\n    0xe0d5e91eUL, 0x97d2d988UL, 0x09b64c2bUL, 0x7eb17cbdUL, 0xe7b82d07UL,\n    0x90bf1d91UL, 0x1db71064UL, 0x6ab020f2UL, 0xf3b97148UL, 0x84be41deUL,\n    0x1adad47dUL, 0x6ddde4ebUL, 0xf4d4b551UL, 0x83d385c7UL, 0x136c9856UL,\n    0x646ba8c0UL, 0xfd62f97aUL, 0x8a65c9ecUL, 0x14015c4fUL, 0x63066cd9UL,\n    0xfa0f3d63UL, 0x8d080df5UL, 0x3b6e20c8UL, 0x4c69105eUL, 0xd56041e4UL,\n    0xa2677172UL, 0x3c03e4d1UL, 0x4b04d447UL, 0xd20d85fdUL, 0xa50ab56bUL,\n    0x35b5a8faUL, 0x42b2986cUL, 0xdbbbc9d6UL, 0xacbcf940UL, 0x32d86ce3UL,\n    0x45df5c75UL, 0xdcd60dcfUL, 0xabd13d59UL, 0x26d930acUL, 0x51de003aUL,\n    0xc8d75180UL, 0xbfd06116UL, 0x21b4f4b5UL, 0x56b3c423UL, 0xcfba9599UL,\n    0xb8bda50fUL, 0x2802b89eUL, 0x5f058808UL, 0xc60cd9b2UL, 0xb10be924UL,\n    0x2f6f7c87UL, 0x58684c11UL, 0xc1611dabUL, 0xb6662d3dUL, 0x76dc4190UL,\n    0x01db7106UL, 0x98d220bcUL, 0xefd5102aUL, 0x71b18589UL, 0x06b6b51fUL,\n    0x9fbfe4a5UL, 0xe8b8d433UL, 0x7807c9a2UL, 0x0f00f934UL, 0x9609a88eUL,\n    0xe10e9818UL, 0x7f6a0dbbUL, 0x086d3d2dUL, 0x91646c97UL, 0xe6635c01UL,\n    0x6b6b51f4UL, 0x1c6c6162UL, 0x856530d8UL, 0xf262004eUL, 0x6c0695edUL,\n    0x1b01a57bUL, 0x8208f4c1UL, 0xf50fc457UL, 0x65b0d9c6UL, 0x12b7e950UL,\n    0x8bbeb8eaUL, 0xfcb9887cUL, 0x62dd1ddfUL, 0x15da2d49UL, 0x8cd37cf3UL,\n    0xfbd44c65UL, 0x4db26158UL, 0x3ab551ceUL, 0xa3bc0074UL, 0xd4bb30e2UL,\n    0x4adfa541UL, 0x3dd895d7UL, 0xa4d1c46dUL, 0xd3d6f4fbUL, 0x4369e96aUL,\n    0x346ed9fcUL, 0xad678846UL, 0xda60b8d0UL, 0x44042d73UL, 0x33031de5UL,\n    0xaa0a4c5fUL, 0xdd0d7cc9UL, 0x5005713cUL, 0x270241aaUL, 0xbe0b1010UL,\n    0xc90c2086UL, 0x5768b525UL, 0x206f85b3UL, 0xb966d409UL, 0xce61e49fUL,\n    0x5edef90eUL, 0x29d9c998UL, 0xb0d09822UL, 0xc7d7a8b4UL, 0x59b33d17UL,\n    0x2eb40d81UL, 0xb7bd5c3bUL, 0xc0ba6cadUL, 0xedb88320UL, 0x9abfb3b6UL,\n    0x03b6e20cUL, 0x74b1d29aUL, 0xead54739UL, 0x9dd277afUL, 0x04db2615UL,\n    0x73dc1683UL, 0xe3630b12UL, 0x94643b84UL, 0x0d6d6a3eUL, 0x7a6a5aa8UL,\n    0xe40ecf0bUL, 0x9309ff9dUL, 0x0a00ae27UL, 0x7d079eb1UL, 0xf00f9344UL,\n    0x8708a3d2UL, 0x1e01f268UL, 0x6906c2feUL, 0xf762575dUL, 0x806567cbUL,\n    0x196c3671UL, 0x6e6b06e7UL, 0xfed41b76UL, 0x89d32be0UL, 0x10da7a5aUL,\n    0x67dd4accUL, 0xf9b9df6fUL, 0x8ebeeff9UL, 0x17b7be43UL, 0x60b08ed5UL,\n    0xd6d6a3e8UL, 0xa1d1937eUL, 0x38d8c2c4UL, 0x4fdff252UL, 0xd1bb67f1UL,\n    0xa6bc5767UL, 0x3fb506ddUL, 0x48b2364bUL, 0xd80d2bdaUL, 0xaf0a1b4cUL,\n    0x36034af6UL, 0x41047a60UL, 0xdf60efc3UL, 0xa867df55UL, 0x316e8eefUL,\n    0x4669be79UL, 0xcb61b38cUL, 0xbc66831aUL, 0x256fd2a0UL, 0x5268e236UL,\n    0xcc0c7795UL, 0xbb0b4703UL, 0x220216b9UL, 0x5505262fUL, 0xc5ba3bbeUL,\n    0xb2bd0b28UL, 0x2bb45a92UL, 0x5cb36a04UL, 0xc2d7ffa7UL, 0xb5d0cf31UL,\n    0x2cd99e8bUL, 0x5bdeae1dUL, 0x9b64c2b0UL, 0xec63f226UL, 0x756aa39cUL,\n    0x026d930aUL, 0x9c0906a9UL, 0xeb0e363fUL, 0x72076785UL, 0x05005713UL,\n    0x95bf4a82UL, 0xe2b87a14UL, 0x7bb12baeUL, 0x0cb61b38UL, 0x92d28e9bUL,\n    0xe5d5be0dUL, 0x7cdcefb7UL, 0x0bdbdf21UL, 0x86d3d2d4UL, 0xf1d4e242UL,\n    0x68ddb3f8UL, 0x1fda836eUL, 0x81be16cdUL, 0xf6b9265bUL, 0x6fb077e1UL,\n    0x18b74777UL, 0x88085ae6UL, 0xff0f6a70UL, 0x66063bcaUL, 0x11010b5cUL,\n    0x8f659effUL, 0xf862ae69UL, 0x616bffd3UL, 0x166ccf45UL, 0xa00ae278UL,\n    0xd70dd2eeUL, 0x4e048354UL, 0x3903b3c2UL, 0xa7672661UL, 0xd06016f7UL,\n    0x4969474dUL, 0x3e6e77dbUL, 0xaed16a4aUL, 0xd9d65adcUL, 0x40df0b66UL,\n    0x37d83bf0UL, 0xa9bcae53UL, 0xdebb9ec5UL, 0x47b2cf7fUL, 0x30b5ffe9UL,\n    0xbdbdf21cUL, 0xcabac28aUL, 0x53b39330UL, 0x24b4a3a6UL, 0xbad03605UL,\n    0xcdd70693UL, 0x54de5729UL, 0x23d967bfUL, 0xb3667a2eUL, 0xc4614ab8UL,\n    0x5d681b02UL, 0x2a6f2b94UL, 0xb40bbe37UL, 0xc30c8ea1UL, 0x5a05df1bUL,\n    0x2d02ef8dUL\n#ifdef BYFOUR\n  },\n  {\n    0x00000000UL, 0x191b3141UL, 0x32366282UL, 0x2b2d53c3UL, 0x646cc504UL,\n    0x7d77f445UL, 0x565aa786UL, 0x4f4196c7UL, 0xc8d98a08UL, 0xd1c2bb49UL,\n    0xfaefe88aUL, 0xe3f4d9cbUL, 0xacb54f0cUL, 0xb5ae7e4dUL, 0x9e832d8eUL,\n    0x87981ccfUL, 0x4ac21251UL, 0x53d92310UL, 0x78f470d3UL, 0x61ef4192UL,\n    0x2eaed755UL, 0x37b5e614UL, 0x1c98b5d7UL, 0x05838496UL, 0x821b9859UL,\n    0x9b00a918UL, 0xb02dfadbUL, 0xa936cb9aUL, 0xe6775d5dUL, 0xff6c6c1cUL,\n    0xd4413fdfUL, 0xcd5a0e9eUL, 0x958424a2UL, 0x8c9f15e3UL, 0xa7b24620UL,\n    0xbea97761UL, 0xf1e8e1a6UL, 0xe8f3d0e7UL, 0xc3de8324UL, 0xdac5b265UL,\n    0x5d5daeaaUL, 0x44469febUL, 0x6f6bcc28UL, 0x7670fd69UL, 0x39316baeUL,\n    0x202a5aefUL, 0x0b07092cUL, 0x121c386dUL, 0xdf4636f3UL, 0xc65d07b2UL,\n    0xed705471UL, 0xf46b6530UL, 0xbb2af3f7UL, 0xa231c2b6UL, 0x891c9175UL,\n    0x9007a034UL, 0x179fbcfbUL, 0x0e848dbaUL, 0x25a9de79UL, 0x3cb2ef38UL,\n    0x73f379ffUL, 0x6ae848beUL, 0x41c51b7dUL, 0x58de2a3cUL, 0xf0794f05UL,\n    0xe9627e44UL, 0xc24f2d87UL, 0xdb541cc6UL, 0x94158a01UL, 0x8d0ebb40UL,\n    0xa623e883UL, 0xbf38d9c2UL, 0x38a0c50dUL, 0x21bbf44cUL, 0x0a96a78fUL,\n    0x138d96ceUL, 0x5ccc0009UL, 0x45d73148UL, 0x6efa628bUL, 0x77e153caUL,\n    0xbabb5d54UL, 0xa3a06c15UL, 0x888d3fd6UL, 0x91960e97UL, 0xded79850UL,\n    0xc7cca911UL, 0xece1fad2UL, 0xf5facb93UL, 0x7262d75cUL, 0x6b79e61dUL,\n    0x4054b5deUL, 0x594f849fUL, 0x160e1258UL, 0x0f152319UL, 0x243870daUL,\n    0x3d23419bUL, 0x65fd6ba7UL, 0x7ce65ae6UL, 0x57cb0925UL, 0x4ed03864UL,\n    0x0191aea3UL, 0x188a9fe2UL, 0x33a7cc21UL, 0x2abcfd60UL, 0xad24e1afUL,\n    0xb43fd0eeUL, 0x9f12832dUL, 0x8609b26cUL, 0xc94824abUL, 0xd05315eaUL,\n    0xfb7e4629UL, 0xe2657768UL, 0x2f3f79f6UL, 0x362448b7UL, 0x1d091b74UL,\n    0x04122a35UL, 0x4b53bcf2UL, 0x52488db3UL, 0x7965de70UL, 0x607eef31UL,\n    0xe7e6f3feUL, 0xfefdc2bfUL, 0xd5d0917cUL, 0xcccba03dUL, 0x838a36faUL,\n    0x9a9107bbUL, 0xb1bc5478UL, 0xa8a76539UL, 0x3b83984bUL, 0x2298a90aUL,\n    0x09b5fac9UL, 0x10aecb88UL, 0x5fef5d4fUL, 0x46f46c0eUL, 0x6dd93fcdUL,\n    0x74c20e8cUL, 0xf35a1243UL, 0xea412302UL, 0xc16c70c1UL, 0xd8774180UL,\n    0x9736d747UL, 0x8e2de606UL, 0xa500b5c5UL, 0xbc1b8484UL, 0x71418a1aUL,\n    0x685abb5bUL, 0x4377e898UL, 0x5a6cd9d9UL, 0x152d4f1eUL, 0x0c367e5fUL,\n    0x271b2d9cUL, 0x3e001cddUL, 0xb9980012UL, 0xa0833153UL, 0x8bae6290UL,\n    0x92b553d1UL, 0xddf4c516UL, 0xc4eff457UL, 0xefc2a794UL, 0xf6d996d5UL,\n    0xae07bce9UL, 0xb71c8da8UL, 0x9c31de6bUL, 0x852aef2aUL, 0xca6b79edUL,\n    0xd37048acUL, 0xf85d1b6fUL, 0xe1462a2eUL, 0x66de36e1UL, 0x7fc507a0UL,\n    0x54e85463UL, 0x4df36522UL, 0x02b2f3e5UL, 0x1ba9c2a4UL, 0x30849167UL,\n    0x299fa026UL, 0xe4c5aeb8UL, 0xfdde9ff9UL, 0xd6f3cc3aUL, 0xcfe8fd7bUL,\n    0x80a96bbcUL, 0x99b25afdUL, 0xb29f093eUL, 0xab84387fUL, 0x2c1c24b0UL,\n    0x350715f1UL, 0x1e2a4632UL, 0x07317773UL, 0x4870e1b4UL, 0x516bd0f5UL,\n    0x7a468336UL, 0x635db277UL, 0xcbfad74eUL, 0xd2e1e60fUL, 0xf9ccb5ccUL,\n    0xe0d7848dUL, 0xaf96124aUL, 0xb68d230bUL, 0x9da070c8UL, 0x84bb4189UL,\n    0x03235d46UL, 0x1a386c07UL, 0x31153fc4UL, 0x280e0e85UL, 0x674f9842UL,\n    0x7e54a903UL, 0x5579fac0UL, 0x4c62cb81UL, 0x8138c51fUL, 0x9823f45eUL,\n    0xb30ea79dUL, 0xaa1596dcUL, 0xe554001bUL, 0xfc4f315aUL, 0xd7626299UL,\n    0xce7953d8UL, 0x49e14f17UL, 0x50fa7e56UL, 0x7bd72d95UL, 0x62cc1cd4UL,\n    0x2d8d8a13UL, 0x3496bb52UL, 0x1fbbe891UL, 0x06a0d9d0UL, 0x5e7ef3ecUL,\n    0x4765c2adUL, 0x6c48916eUL, 0x7553a02fUL, 0x3a1236e8UL, 0x230907a9UL,\n    0x0824546aUL, 0x113f652bUL, 0x96a779e4UL, 0x8fbc48a5UL, 0xa4911b66UL,\n    0xbd8a2a27UL, 0xf2cbbce0UL, 0xebd08da1UL, 0xc0fdde62UL, 0xd9e6ef23UL,\n    0x14bce1bdUL, 0x0da7d0fcUL, 0x268a833fUL, 0x3f91b27eUL, 0x70d024b9UL,\n    0x69cb15f8UL, 0x42e6463bUL, 0x5bfd777aUL, 0xdc656bb5UL, 0xc57e5af4UL,\n    0xee530937UL, 0xf7483876UL, 0xb809aeb1UL, 0xa1129ff0UL, 0x8a3fcc33UL,\n    0x9324fd72UL\n  },\n  {\n    0x00000000UL, 0x01c26a37UL, 0x0384d46eUL, 0x0246be59UL, 0x0709a8dcUL,\n    0x06cbc2ebUL, 0x048d7cb2UL, 0x054f1685UL, 0x0e1351b8UL, 0x0fd13b8fUL,\n    0x0d9785d6UL, 0x0c55efe1UL, 0x091af964UL, 0x08d89353UL, 0x0a9e2d0aUL,\n    0x0b5c473dUL, 0x1c26a370UL, 0x1de4c947UL, 0x1fa2771eUL, 0x1e601d29UL,\n    0x1b2f0bacUL, 0x1aed619bUL, 0x18abdfc2UL, 0x1969b5f5UL, 0x1235f2c8UL,\n    0x13f798ffUL, 0x11b126a6UL, 0x10734c91UL, 0x153c5a14UL, 0x14fe3023UL,\n    0x16b88e7aUL, 0x177ae44dUL, 0x384d46e0UL, 0x398f2cd7UL, 0x3bc9928eUL,\n    0x3a0bf8b9UL, 0x3f44ee3cUL, 0x3e86840bUL, 0x3cc03a52UL, 0x3d025065UL,\n    0x365e1758UL, 0x379c7d6fUL, 0x35dac336UL, 0x3418a901UL, 0x3157bf84UL,\n    0x3095d5b3UL, 0x32d36beaUL, 0x331101ddUL, 0x246be590UL, 0x25a98fa7UL,\n    0x27ef31feUL, 0x262d5bc9UL, 0x23624d4cUL, 0x22a0277bUL, 0x20e69922UL,\n    0x2124f315UL, 0x2a78b428UL, 0x2bbade1fUL, 0x29fc6046UL, 0x283e0a71UL,\n    0x2d711cf4UL, 0x2cb376c3UL, 0x2ef5c89aUL, 0x2f37a2adUL, 0x709a8dc0UL,\n    0x7158e7f7UL, 0x731e59aeUL, 0x72dc3399UL, 0x7793251cUL, 0x76514f2bUL,\n    0x7417f172UL, 0x75d59b45UL, 0x7e89dc78UL, 0x7f4bb64fUL, 0x7d0d0816UL,\n    0x7ccf6221UL, 0x798074a4UL, 0x78421e93UL, 0x7a04a0caUL, 0x7bc6cafdUL,\n    0x6cbc2eb0UL, 0x6d7e4487UL, 0x6f38fadeUL, 0x6efa90e9UL, 0x6bb5866cUL,\n    0x6a77ec5bUL, 0x68315202UL, 0x69f33835UL, 0x62af7f08UL, 0x636d153fUL,\n    0x612bab66UL, 0x60e9c151UL, 0x65a6d7d4UL, 0x6464bde3UL, 0x662203baUL,\n    0x67e0698dUL, 0x48d7cb20UL, 0x4915a117UL, 0x4b531f4eUL, 0x4a917579UL,\n    0x4fde63fcUL, 0x4e1c09cbUL, 0x4c5ab792UL, 0x4d98dda5UL, 0x46c49a98UL,\n    0x4706f0afUL, 0x45404ef6UL, 0x448224c1UL, 0x41cd3244UL, 0x400f5873UL,\n    0x4249e62aUL, 0x438b8c1dUL, 0x54f16850UL, 0x55330267UL, 0x5775bc3eUL,\n    0x56b7d609UL, 0x53f8c08cUL, 0x523aaabbUL, 0x507c14e2UL, 0x51be7ed5UL,\n    0x5ae239e8UL, 0x5b2053dfUL, 0x5966ed86UL, 0x58a487b1UL, 0x5deb9134UL,\n    0x5c29fb03UL, 0x5e6f455aUL, 0x5fad2f6dUL, 0xe1351b80UL, 0xe0f771b7UL,\n    0xe2b1cfeeUL, 0xe373a5d9UL, 0xe63cb35cUL, 0xe7fed96bUL, 0xe5b86732UL,\n    0xe47a0d05UL, 0xef264a38UL, 0xeee4200fUL, 0xeca29e56UL, 0xed60f461UL,\n    0xe82fe2e4UL, 0xe9ed88d3UL, 0xebab368aUL, 0xea695cbdUL, 0xfd13b8f0UL,\n    0xfcd1d2c7UL, 0xfe976c9eUL, 0xff5506a9UL, 0xfa1a102cUL, 0xfbd87a1bUL,\n    0xf99ec442UL, 0xf85cae75UL, 0xf300e948UL, 0xf2c2837fUL, 0xf0843d26UL,\n    0xf1465711UL, 0xf4094194UL, 0xf5cb2ba3UL, 0xf78d95faUL, 0xf64fffcdUL,\n    0xd9785d60UL, 0xd8ba3757UL, 0xdafc890eUL, 0xdb3ee339UL, 0xde71f5bcUL,\n    0xdfb39f8bUL, 0xddf521d2UL, 0xdc374be5UL, 0xd76b0cd8UL, 0xd6a966efUL,\n    0xd4efd8b6UL, 0xd52db281UL, 0xd062a404UL, 0xd1a0ce33UL, 0xd3e6706aUL,\n    0xd2241a5dUL, 0xc55efe10UL, 0xc49c9427UL, 0xc6da2a7eUL, 0xc7184049UL,\n    0xc25756ccUL, 0xc3953cfbUL, 0xc1d382a2UL, 0xc011e895UL, 0xcb4dafa8UL,\n    0xca8fc59fUL, 0xc8c97bc6UL, 0xc90b11f1UL, 0xcc440774UL, 0xcd866d43UL,\n    0xcfc0d31aUL, 0xce02b92dUL, 0x91af9640UL, 0x906dfc77UL, 0x922b422eUL,\n    0x93e92819UL, 0x96a63e9cUL, 0x976454abUL, 0x9522eaf2UL, 0x94e080c5UL,\n    0x9fbcc7f8UL, 0x9e7eadcfUL, 0x9c381396UL, 0x9dfa79a1UL, 0x98b56f24UL,\n    0x99770513UL, 0x9b31bb4aUL, 0x9af3d17dUL, 0x8d893530UL, 0x8c4b5f07UL,\n    0x8e0de15eUL, 0x8fcf8b69UL, 0x8a809decUL, 0x8b42f7dbUL, 0x89044982UL,\n    0x88c623b5UL, 0x839a6488UL, 0x82580ebfUL, 0x801eb0e6UL, 0x81dcdad1UL,\n    0x8493cc54UL, 0x8551a663UL, 0x8717183aUL, 0x86d5720dUL, 0xa9e2d0a0UL,\n    0xa820ba97UL, 0xaa6604ceUL, 0xaba46ef9UL, 0xaeeb787cUL, 0xaf29124bUL,\n    0xad6fac12UL, 0xacadc625UL, 0xa7f18118UL, 0xa633eb2fUL, 0xa4755576UL,\n    0xa5b73f41UL, 0xa0f829c4UL, 0xa13a43f3UL, 0xa37cfdaaUL, 0xa2be979dUL,\n    0xb5c473d0UL, 0xb40619e7UL, 0xb640a7beUL, 0xb782cd89UL, 0xb2cddb0cUL,\n    0xb30fb13bUL, 0xb1490f62UL, 0xb08b6555UL, 0xbbd72268UL, 0xba15485fUL,\n    0xb853f606UL, 0xb9919c31UL, 0xbcde8ab4UL, 0xbd1ce083UL, 0xbf5a5edaUL,\n    0xbe9834edUL\n  },\n  {\n    0x00000000UL, 0xb8bc6765UL, 0xaa09c88bUL, 0x12b5afeeUL, 0x8f629757UL,\n    0x37def032UL, 0x256b5fdcUL, 0x9dd738b9UL, 0xc5b428efUL, 0x7d084f8aUL,\n    0x6fbde064UL, 0xd7018701UL, 0x4ad6bfb8UL, 0xf26ad8ddUL, 0xe0df7733UL,\n    0x58631056UL, 0x5019579fUL, 0xe8a530faUL, 0xfa109f14UL, 0x42acf871UL,\n    0xdf7bc0c8UL, 0x67c7a7adUL, 0x75720843UL, 0xcdce6f26UL, 0x95ad7f70UL,\n    0x2d111815UL, 0x3fa4b7fbUL, 0x8718d09eUL, 0x1acfe827UL, 0xa2738f42UL,\n    0xb0c620acUL, 0x087a47c9UL, 0xa032af3eUL, 0x188ec85bUL, 0x0a3b67b5UL,\n    0xb28700d0UL, 0x2f503869UL, 0x97ec5f0cUL, 0x8559f0e2UL, 0x3de59787UL,\n    0x658687d1UL, 0xdd3ae0b4UL, 0xcf8f4f5aUL, 0x7733283fUL, 0xeae41086UL,\n    0x525877e3UL, 0x40edd80dUL, 0xf851bf68UL, 0xf02bf8a1UL, 0x48979fc4UL,\n    0x5a22302aUL, 0xe29e574fUL, 0x7f496ff6UL, 0xc7f50893UL, 0xd540a77dUL,\n    0x6dfcc018UL, 0x359fd04eUL, 0x8d23b72bUL, 0x9f9618c5UL, 0x272a7fa0UL,\n    0xbafd4719UL, 0x0241207cUL, 0x10f48f92UL, 0xa848e8f7UL, 0x9b14583dUL,\n    0x23a83f58UL, 0x311d90b6UL, 0x89a1f7d3UL, 0x1476cf6aUL, 0xaccaa80fUL,\n    0xbe7f07e1UL, 0x06c36084UL, 0x5ea070d2UL, 0xe61c17b7UL, 0xf4a9b859UL,\n    0x4c15df3cUL, 0xd1c2e785UL, 0x697e80e0UL, 0x7bcb2f0eUL, 0xc377486bUL,\n    0xcb0d0fa2UL, 0x73b168c7UL, 0x6104c729UL, 0xd9b8a04cUL, 0x446f98f5UL,\n    0xfcd3ff90UL, 0xee66507eUL, 0x56da371bUL, 0x0eb9274dUL, 0xb6054028UL,\n    0xa4b0efc6UL, 0x1c0c88a3UL, 0x81dbb01aUL, 0x3967d77fUL, 0x2bd27891UL,\n    0x936e1ff4UL, 0x3b26f703UL, 0x839a9066UL, 0x912f3f88UL, 0x299358edUL,\n    0xb4446054UL, 0x0cf80731UL, 0x1e4da8dfUL, 0xa6f1cfbaUL, 0xfe92dfecUL,\n    0x462eb889UL, 0x549b1767UL, 0xec277002UL, 0x71f048bbUL, 0xc94c2fdeUL,\n    0xdbf98030UL, 0x6345e755UL, 0x6b3fa09cUL, 0xd383c7f9UL, 0xc1366817UL,\n    0x798a0f72UL, 0xe45d37cbUL, 0x5ce150aeUL, 0x4e54ff40UL, 0xf6e89825UL,\n    0xae8b8873UL, 0x1637ef16UL, 0x048240f8UL, 0xbc3e279dUL, 0x21e91f24UL,\n    0x99557841UL, 0x8be0d7afUL, 0x335cb0caUL, 0xed59b63bUL, 0x55e5d15eUL,\n    0x47507eb0UL, 0xffec19d5UL, 0x623b216cUL, 0xda874609UL, 0xc832e9e7UL,\n    0x708e8e82UL, 0x28ed9ed4UL, 0x9051f9b1UL, 0x82e4565fUL, 0x3a58313aUL,\n    0xa78f0983UL, 0x1f336ee6UL, 0x0d86c108UL, 0xb53aa66dUL, 0xbd40e1a4UL,\n    0x05fc86c1UL, 0x1749292fUL, 0xaff54e4aUL, 0x322276f3UL, 0x8a9e1196UL,\n    0x982bbe78UL, 0x2097d91dUL, 0x78f4c94bUL, 0xc048ae2eUL, 0xd2fd01c0UL,\n    0x6a4166a5UL, 0xf7965e1cUL, 0x4f2a3979UL, 0x5d9f9697UL, 0xe523f1f2UL,\n    0x4d6b1905UL, 0xf5d77e60UL, 0xe762d18eUL, 0x5fdeb6ebUL, 0xc2098e52UL,\n    0x7ab5e937UL, 0x680046d9UL, 0xd0bc21bcUL, 0x88df31eaUL, 0x3063568fUL,\n    0x22d6f961UL, 0x9a6a9e04UL, 0x07bda6bdUL, 0xbf01c1d8UL, 0xadb46e36UL,\n    0x15080953UL, 0x1d724e9aUL, 0xa5ce29ffUL, 0xb77b8611UL, 0x0fc7e174UL,\n    0x9210d9cdUL, 0x2aacbea8UL, 0x38191146UL, 0x80a57623UL, 0xd8c66675UL,\n    0x607a0110UL, 0x72cfaefeUL, 0xca73c99bUL, 0x57a4f122UL, 0xef189647UL,\n    0xfdad39a9UL, 0x45115eccUL, 0x764dee06UL, 0xcef18963UL, 0xdc44268dUL,\n    0x64f841e8UL, 0xf92f7951UL, 0x41931e34UL, 0x5326b1daUL, 0xeb9ad6bfUL,\n    0xb3f9c6e9UL, 0x0b45a18cUL, 0x19f00e62UL, 0xa14c6907UL, 0x3c9b51beUL,\n    0x842736dbUL, 0x96929935UL, 0x2e2efe50UL, 0x2654b999UL, 0x9ee8defcUL,\n    0x8c5d7112UL, 0x34e11677UL, 0xa9362eceUL, 0x118a49abUL, 0x033fe645UL,\n    0xbb838120UL, 0xe3e09176UL, 0x5b5cf613UL, 0x49e959fdUL, 0xf1553e98UL,\n    0x6c820621UL, 0xd43e6144UL, 0xc68bceaaUL, 0x7e37a9cfUL, 0xd67f4138UL,\n    0x6ec3265dUL, 0x7c7689b3UL, 0xc4caeed6UL, 0x591dd66fUL, 0xe1a1b10aUL,\n    0xf3141ee4UL, 0x4ba87981UL, 0x13cb69d7UL, 0xab770eb2UL, 0xb9c2a15cUL,\n    0x017ec639UL, 0x9ca9fe80UL, 0x241599e5UL, 0x36a0360bUL, 0x8e1c516eUL,\n    0x866616a7UL, 0x3eda71c2UL, 0x2c6fde2cUL, 0x94d3b949UL, 0x090481f0UL,\n    0xb1b8e695UL, 0xa30d497bUL, 0x1bb12e1eUL, 0x43d23e48UL, 0xfb6e592dUL,\n    0xe9dbf6c3UL, 0x516791a6UL, 0xccb0a91fUL, 0x740cce7aUL, 0x66b96194UL,\n    0xde0506f1UL\n  },\n  {\n    0x00000000UL, 0x96300777UL, 0x2c610eeeUL, 0xba510999UL, 0x19c46d07UL,\n    0x8ff46a70UL, 0x35a563e9UL, 0xa395649eUL, 0x3288db0eUL, 0xa4b8dc79UL,\n    0x1ee9d5e0UL, 0x88d9d297UL, 0x2b4cb609UL, 0xbd7cb17eUL, 0x072db8e7UL,\n    0x911dbf90UL, 0x6410b71dUL, 0xf220b06aUL, 0x4871b9f3UL, 0xde41be84UL,\n    0x7dd4da1aUL, 0xebe4dd6dUL, 0x51b5d4f4UL, 0xc785d383UL, 0x56986c13UL,\n    0xc0a86b64UL, 0x7af962fdUL, 0xecc9658aUL, 0x4f5c0114UL, 0xd96c0663UL,\n    0x633d0ffaUL, 0xf50d088dUL, 0xc8206e3bUL, 0x5e10694cUL, 0xe44160d5UL,\n    0x727167a2UL, 0xd1e4033cUL, 0x47d4044bUL, 0xfd850dd2UL, 0x6bb50aa5UL,\n    0xfaa8b535UL, 0x6c98b242UL, 0xd6c9bbdbUL, 0x40f9bcacUL, 0xe36cd832UL,\n    0x755cdf45UL, 0xcf0dd6dcUL, 0x593dd1abUL, 0xac30d926UL, 0x3a00de51UL,\n    0x8051d7c8UL, 0x1661d0bfUL, 0xb5f4b421UL, 0x23c4b356UL, 0x9995bacfUL,\n    0x0fa5bdb8UL, 0x9eb80228UL, 0x0888055fUL, 0xb2d90cc6UL, 0x24e90bb1UL,\n    0x877c6f2fUL, 0x114c6858UL, 0xab1d61c1UL, 0x3d2d66b6UL, 0x9041dc76UL,\n    0x0671db01UL, 0xbc20d298UL, 0x2a10d5efUL, 0x8985b171UL, 0x1fb5b606UL,\n    0xa5e4bf9fUL, 0x33d4b8e8UL, 0xa2c90778UL, 0x34f9000fUL, 0x8ea80996UL,\n    0x18980ee1UL, 0xbb0d6a7fUL, 0x2d3d6d08UL, 0x976c6491UL, 0x015c63e6UL,\n    0xf4516b6bUL, 0x62616c1cUL, 0xd8306585UL, 0x4e0062f2UL, 0xed95066cUL,\n    0x7ba5011bUL, 0xc1f40882UL, 0x57c40ff5UL, 0xc6d9b065UL, 0x50e9b712UL,\n    0xeab8be8bUL, 0x7c88b9fcUL, 0xdf1ddd62UL, 0x492dda15UL, 0xf37cd38cUL,\n    0x654cd4fbUL, 0x5861b24dUL, 0xce51b53aUL, 0x7400bca3UL, 0xe230bbd4UL,\n    0x41a5df4aUL, 0xd795d83dUL, 0x6dc4d1a4UL, 0xfbf4d6d3UL, 0x6ae96943UL,\n    0xfcd96e34UL, 0x468867adUL, 0xd0b860daUL, 0x732d0444UL, 0xe51d0333UL,\n    0x5f4c0aaaUL, 0xc97c0dddUL, 0x3c710550UL, 0xaa410227UL, 0x10100bbeUL,\n    0x86200cc9UL, 0x25b56857UL, 0xb3856f20UL, 0x09d466b9UL, 0x9fe461ceUL,\n    0x0ef9de5eUL, 0x98c9d929UL, 0x2298d0b0UL, 0xb4a8d7c7UL, 0x173db359UL,\n    0x810db42eUL, 0x3b5cbdb7UL, 0xad6cbac0UL, 0x2083b8edUL, 0xb6b3bf9aUL,\n    0x0ce2b603UL, 0x9ad2b174UL, 0x3947d5eaUL, 0xaf77d29dUL, 0x1526db04UL,\n    0x8316dc73UL, 0x120b63e3UL, 0x843b6494UL, 0x3e6a6d0dUL, 0xa85a6a7aUL,\n    0x0bcf0ee4UL, 0x9dff0993UL, 0x27ae000aUL, 0xb19e077dUL, 0x44930ff0UL,\n    0xd2a30887UL, 0x68f2011eUL, 0xfec20669UL, 0x5d5762f7UL, 0xcb676580UL,\n    0x71366c19UL, 0xe7066b6eUL, 0x761bd4feUL, 0xe02bd389UL, 0x5a7ada10UL,\n    0xcc4add67UL, 0x6fdfb9f9UL, 0xf9efbe8eUL, 0x43beb717UL, 0xd58eb060UL,\n    0xe8a3d6d6UL, 0x7e93d1a1UL, 0xc4c2d838UL, 0x52f2df4fUL, 0xf167bbd1UL,\n    0x6757bca6UL, 0xdd06b53fUL, 0x4b36b248UL, 0xda2b0dd8UL, 0x4c1b0aafUL,\n    0xf64a0336UL, 0x607a0441UL, 0xc3ef60dfUL, 0x55df67a8UL, 0xef8e6e31UL,\n    0x79be6946UL, 0x8cb361cbUL, 0x1a8366bcUL, 0xa0d26f25UL, 0x36e26852UL,\n    0x95770cccUL, 0x03470bbbUL, 0xb9160222UL, 0x2f260555UL, 0xbe3bbac5UL,\n    0x280bbdb2UL, 0x925ab42bUL, 0x046ab35cUL, 0xa7ffd7c2UL, 0x31cfd0b5UL,\n    0x8b9ed92cUL, 0x1daede5bUL, 0xb0c2649bUL, 0x26f263ecUL, 0x9ca36a75UL,\n    0x0a936d02UL, 0xa906099cUL, 0x3f360eebUL, 0x85670772UL, 0x13570005UL,\n    0x824abf95UL, 0x147ab8e2UL, 0xae2bb17bUL, 0x381bb60cUL, 0x9b8ed292UL,\n    0x0dbed5e5UL, 0xb7efdc7cUL, 0x21dfdb0bUL, 0xd4d2d386UL, 0x42e2d4f1UL,\n    0xf8b3dd68UL, 0x6e83da1fUL, 0xcd16be81UL, 0x5b26b9f6UL, 0xe177b06fUL,\n    0x7747b718UL, 0xe65a0888UL, 0x706a0fffUL, 0xca3b0666UL, 0x5c0b0111UL,\n    0xff9e658fUL, 0x69ae62f8UL, 0xd3ff6b61UL, 0x45cf6c16UL, 0x78e20aa0UL,\n    0xeed20dd7UL, 0x5483044eUL, 0xc2b30339UL, 0x612667a7UL, 0xf71660d0UL,\n    0x4d476949UL, 0xdb776e3eUL, 0x4a6ad1aeUL, 0xdc5ad6d9UL, 0x660bdf40UL,\n    0xf03bd837UL, 0x53aebca9UL, 0xc59ebbdeUL, 0x7fcfb247UL, 0xe9ffb530UL,\n    0x1cf2bdbdUL, 0x8ac2bacaUL, 0x3093b353UL, 0xa6a3b424UL, 0x0536d0baUL,\n    0x9306d7cdUL, 0x2957de54UL, 0xbf67d923UL, 0x2e7a66b3UL, 0xb84a61c4UL,\n    0x021b685dUL, 0x942b6f2aUL, 0x37be0bb4UL, 0xa18e0cc3UL, 0x1bdf055aUL,\n    0x8def022dUL\n  },\n  {\n    0x00000000UL, 0x41311b19UL, 0x82623632UL, 0xc3532d2bUL, 0x04c56c64UL,\n    0x45f4777dUL, 0x86a75a56UL, 0xc796414fUL, 0x088ad9c8UL, 0x49bbc2d1UL,\n    0x8ae8effaUL, 0xcbd9f4e3UL, 0x0c4fb5acUL, 0x4d7eaeb5UL, 0x8e2d839eUL,\n    0xcf1c9887UL, 0x5112c24aUL, 0x1023d953UL, 0xd370f478UL, 0x9241ef61UL,\n    0x55d7ae2eUL, 0x14e6b537UL, 0xd7b5981cUL, 0x96848305UL, 0x59981b82UL,\n    0x18a9009bUL, 0xdbfa2db0UL, 0x9acb36a9UL, 0x5d5d77e6UL, 0x1c6c6cffUL,\n    0xdf3f41d4UL, 0x9e0e5acdUL, 0xa2248495UL, 0xe3159f8cUL, 0x2046b2a7UL,\n    0x6177a9beUL, 0xa6e1e8f1UL, 0xe7d0f3e8UL, 0x2483dec3UL, 0x65b2c5daUL,\n    0xaaae5d5dUL, 0xeb9f4644UL, 0x28cc6b6fUL, 0x69fd7076UL, 0xae6b3139UL,\n    0xef5a2a20UL, 0x2c09070bUL, 0x6d381c12UL, 0xf33646dfUL, 0xb2075dc6UL,\n    0x715470edUL, 0x30656bf4UL, 0xf7f32abbUL, 0xb6c231a2UL, 0x75911c89UL,\n    0x34a00790UL, 0xfbbc9f17UL, 0xba8d840eUL, 0x79dea925UL, 0x38efb23cUL,\n    0xff79f373UL, 0xbe48e86aUL, 0x7d1bc541UL, 0x3c2ade58UL, 0x054f79f0UL,\n    0x447e62e9UL, 0x872d4fc2UL, 0xc61c54dbUL, 0x018a1594UL, 0x40bb0e8dUL,\n    0x83e823a6UL, 0xc2d938bfUL, 0x0dc5a038UL, 0x4cf4bb21UL, 0x8fa7960aUL,\n    0xce968d13UL, 0x0900cc5cUL, 0x4831d745UL, 0x8b62fa6eUL, 0xca53e177UL,\n    0x545dbbbaUL, 0x156ca0a3UL, 0xd63f8d88UL, 0x970e9691UL, 0x5098d7deUL,\n    0x11a9ccc7UL, 0xd2fae1ecUL, 0x93cbfaf5UL, 0x5cd76272UL, 0x1de6796bUL,\n    0xdeb55440UL, 0x9f844f59UL, 0x58120e16UL, 0x1923150fUL, 0xda703824UL,\n    0x9b41233dUL, 0xa76bfd65UL, 0xe65ae67cUL, 0x2509cb57UL, 0x6438d04eUL,\n    0xa3ae9101UL, 0xe29f8a18UL, 0x21cca733UL, 0x60fdbc2aUL, 0xafe124adUL,\n    0xeed03fb4UL, 0x2d83129fUL, 0x6cb20986UL, 0xab2448c9UL, 0xea1553d0UL,\n    0x29467efbUL, 0x687765e2UL, 0xf6793f2fUL, 0xb7482436UL, 0x741b091dUL,\n    0x352a1204UL, 0xf2bc534bUL, 0xb38d4852UL, 0x70de6579UL, 0x31ef7e60UL,\n    0xfef3e6e7UL, 0xbfc2fdfeUL, 0x7c91d0d5UL, 0x3da0cbccUL, 0xfa368a83UL,\n    0xbb07919aUL, 0x7854bcb1UL, 0x3965a7a8UL, 0x4b98833bUL, 0x0aa99822UL,\n    0xc9fab509UL, 0x88cbae10UL, 0x4f5def5fUL, 0x0e6cf446UL, 0xcd3fd96dUL,\n    0x8c0ec274UL, 0x43125af3UL, 0x022341eaUL, 0xc1706cc1UL, 0x804177d8UL,\n    0x47d73697UL, 0x06e62d8eUL, 0xc5b500a5UL, 0x84841bbcUL, 0x1a8a4171UL,\n    0x5bbb5a68UL, 0x98e87743UL, 0xd9d96c5aUL, 0x1e4f2d15UL, 0x5f7e360cUL,\n    0x9c2d1b27UL, 0xdd1c003eUL, 0x120098b9UL, 0x533183a0UL, 0x9062ae8bUL,\n    0xd153b592UL, 0x16c5f4ddUL, 0x57f4efc4UL, 0x94a7c2efUL, 0xd596d9f6UL,\n    0xe9bc07aeUL, 0xa88d1cb7UL, 0x6bde319cUL, 0x2aef2a85UL, 0xed796bcaUL,\n    0xac4870d3UL, 0x6f1b5df8UL, 0x2e2a46e1UL, 0xe136de66UL, 0xa007c57fUL,\n    0x6354e854UL, 0x2265f34dUL, 0xe5f3b202UL, 0xa4c2a91bUL, 0x67918430UL,\n    0x26a09f29UL, 0xb8aec5e4UL, 0xf99fdefdUL, 0x3accf3d6UL, 0x7bfde8cfUL,\n    0xbc6ba980UL, 0xfd5ab299UL, 0x3e099fb2UL, 0x7f3884abUL, 0xb0241c2cUL,\n    0xf1150735UL, 0x32462a1eUL, 0x73773107UL, 0xb4e17048UL, 0xf5d06b51UL,\n    0x3683467aUL, 0x77b25d63UL, 0x4ed7facbUL, 0x0fe6e1d2UL, 0xccb5ccf9UL,\n    0x8d84d7e0UL, 0x4a1296afUL, 0x0b238db6UL, 0xc870a09dUL, 0x8941bb84UL,\n    0x465d2303UL, 0x076c381aUL, 0xc43f1531UL, 0x850e0e28UL, 0x42984f67UL,\n    0x03a9547eUL, 0xc0fa7955UL, 0x81cb624cUL, 0x1fc53881UL, 0x5ef42398UL,\n    0x9da70eb3UL, 0xdc9615aaUL, 0x1b0054e5UL, 0x5a314ffcUL, 0x996262d7UL,\n    0xd85379ceUL, 0x174fe149UL, 0x567efa50UL, 0x952dd77bUL, 0xd41ccc62UL,\n    0x138a8d2dUL, 0x52bb9634UL, 0x91e8bb1fUL, 0xd0d9a006UL, 0xecf37e5eUL,\n    0xadc26547UL, 0x6e91486cUL, 0x2fa05375UL, 0xe836123aUL, 0xa9070923UL,\n    0x6a542408UL, 0x2b653f11UL, 0xe479a796UL, 0xa548bc8fUL, 0x661b91a4UL,\n    0x272a8abdUL, 0xe0bccbf2UL, 0xa18dd0ebUL, 0x62defdc0UL, 0x23efe6d9UL,\n    0xbde1bc14UL, 0xfcd0a70dUL, 0x3f838a26UL, 0x7eb2913fUL, 0xb924d070UL,\n    0xf815cb69UL, 0x3b46e642UL, 0x7a77fd5bUL, 0xb56b65dcUL, 0xf45a7ec5UL,\n    0x370953eeUL, 0x763848f7UL, 0xb1ae09b8UL, 0xf09f12a1UL, 0x33cc3f8aUL,\n    0x72fd2493UL\n  },\n  {\n    0x00000000UL, 0x376ac201UL, 0x6ed48403UL, 0x59be4602UL, 0xdca80907UL,\n    0xebc2cb06UL, 0xb27c8d04UL, 0x85164f05UL, 0xb851130eUL, 0x8f3bd10fUL,\n    0xd685970dUL, 0xe1ef550cUL, 0x64f91a09UL, 0x5393d808UL, 0x0a2d9e0aUL,\n    0x3d475c0bUL, 0x70a3261cUL, 0x47c9e41dUL, 0x1e77a21fUL, 0x291d601eUL,\n    0xac0b2f1bUL, 0x9b61ed1aUL, 0xc2dfab18UL, 0xf5b56919UL, 0xc8f23512UL,\n    0xff98f713UL, 0xa626b111UL, 0x914c7310UL, 0x145a3c15UL, 0x2330fe14UL,\n    0x7a8eb816UL, 0x4de47a17UL, 0xe0464d38UL, 0xd72c8f39UL, 0x8e92c93bUL,\n    0xb9f80b3aUL, 0x3cee443fUL, 0x0b84863eUL, 0x523ac03cUL, 0x6550023dUL,\n    0x58175e36UL, 0x6f7d9c37UL, 0x36c3da35UL, 0x01a91834UL, 0x84bf5731UL,\n    0xb3d59530UL, 0xea6bd332UL, 0xdd011133UL, 0x90e56b24UL, 0xa78fa925UL,\n    0xfe31ef27UL, 0xc95b2d26UL, 0x4c4d6223UL, 0x7b27a022UL, 0x2299e620UL,\n    0x15f32421UL, 0x28b4782aUL, 0x1fdeba2bUL, 0x4660fc29UL, 0x710a3e28UL,\n    0xf41c712dUL, 0xc376b32cUL, 0x9ac8f52eUL, 0xada2372fUL, 0xc08d9a70UL,\n    0xf7e75871UL, 0xae591e73UL, 0x9933dc72UL, 0x1c259377UL, 0x2b4f5176UL,\n    0x72f11774UL, 0x459bd575UL, 0x78dc897eUL, 0x4fb64b7fUL, 0x16080d7dUL,\n    0x2162cf7cUL, 0xa4748079UL, 0x931e4278UL, 0xcaa0047aUL, 0xfdcac67bUL,\n    0xb02ebc6cUL, 0x87447e6dUL, 0xdefa386fUL, 0xe990fa6eUL, 0x6c86b56bUL,\n    0x5bec776aUL, 0x02523168UL, 0x3538f369UL, 0x087faf62UL, 0x3f156d63UL,\n    0x66ab2b61UL, 0x51c1e960UL, 0xd4d7a665UL, 0xe3bd6464UL, 0xba032266UL,\n    0x8d69e067UL, 0x20cbd748UL, 0x17a11549UL, 0x4e1f534bUL, 0x7975914aUL,\n    0xfc63de4fUL, 0xcb091c4eUL, 0x92b75a4cUL, 0xa5dd984dUL, 0x989ac446UL,\n    0xaff00647UL, 0xf64e4045UL, 0xc1248244UL, 0x4432cd41UL, 0x73580f40UL,\n    0x2ae64942UL, 0x1d8c8b43UL, 0x5068f154UL, 0x67023355UL, 0x3ebc7557UL,\n    0x09d6b756UL, 0x8cc0f853UL, 0xbbaa3a52UL, 0xe2147c50UL, 0xd57ebe51UL,\n    0xe839e25aUL, 0xdf53205bUL, 0x86ed6659UL, 0xb187a458UL, 0x3491eb5dUL,\n    0x03fb295cUL, 0x5a456f5eUL, 0x6d2fad5fUL, 0x801b35e1UL, 0xb771f7e0UL,\n    0xeecfb1e2UL, 0xd9a573e3UL, 0x5cb33ce6UL, 0x6bd9fee7UL, 0x3267b8e5UL,\n    0x050d7ae4UL, 0x384a26efUL, 0x0f20e4eeUL, 0x569ea2ecUL, 0x61f460edUL,\n    0xe4e22fe8UL, 0xd388ede9UL, 0x8a36abebUL, 0xbd5c69eaUL, 0xf0b813fdUL,\n    0xc7d2d1fcUL, 0x9e6c97feUL, 0xa90655ffUL, 0x2c101afaUL, 0x1b7ad8fbUL,\n    0x42c49ef9UL, 0x75ae5cf8UL, 0x48e900f3UL, 0x7f83c2f2UL, 0x263d84f0UL,\n    0x115746f1UL, 0x944109f4UL, 0xa32bcbf5UL, 0xfa958df7UL, 0xcdff4ff6UL,\n    0x605d78d9UL, 0x5737bad8UL, 0x0e89fcdaUL, 0x39e33edbUL, 0xbcf571deUL,\n    0x8b9fb3dfUL, 0xd221f5ddUL, 0xe54b37dcUL, 0xd80c6bd7UL, 0xef66a9d6UL,\n    0xb6d8efd4UL, 0x81b22dd5UL, 0x04a462d0UL, 0x33cea0d1UL, 0x6a70e6d3UL,\n    0x5d1a24d2UL, 0x10fe5ec5UL, 0x27949cc4UL, 0x7e2adac6UL, 0x494018c7UL,\n    0xcc5657c2UL, 0xfb3c95c3UL, 0xa282d3c1UL, 0x95e811c0UL, 0xa8af4dcbUL,\n    0x9fc58fcaUL, 0xc67bc9c8UL, 0xf1110bc9UL, 0x740744ccUL, 0x436d86cdUL,\n    0x1ad3c0cfUL, 0x2db902ceUL, 0x4096af91UL, 0x77fc6d90UL, 0x2e422b92UL,\n    0x1928e993UL, 0x9c3ea696UL, 0xab546497UL, 0xf2ea2295UL, 0xc580e094UL,\n    0xf8c7bc9fUL, 0xcfad7e9eUL, 0x9613389cUL, 0xa179fa9dUL, 0x246fb598UL,\n    0x13057799UL, 0x4abb319bUL, 0x7dd1f39aUL, 0x3035898dUL, 0x075f4b8cUL,\n    0x5ee10d8eUL, 0x698bcf8fUL, 0xec9d808aUL, 0xdbf7428bUL, 0x82490489UL,\n    0xb523c688UL, 0x88649a83UL, 0xbf0e5882UL, 0xe6b01e80UL, 0xd1dadc81UL,\n    0x54cc9384UL, 0x63a65185UL, 0x3a181787UL, 0x0d72d586UL, 0xa0d0e2a9UL,\n    0x97ba20a8UL, 0xce0466aaUL, 0xf96ea4abUL, 0x7c78ebaeUL, 0x4b1229afUL,\n    0x12ac6fadUL, 0x25c6adacUL, 0x1881f1a7UL, 0x2feb33a6UL, 0x765575a4UL,\n    0x413fb7a5UL, 0xc429f8a0UL, 0xf3433aa1UL, 0xaafd7ca3UL, 0x9d97bea2UL,\n    0xd073c4b5UL, 0xe71906b4UL, 0xbea740b6UL, 0x89cd82b7UL, 0x0cdbcdb2UL,\n    0x3bb10fb3UL, 0x620f49b1UL, 0x55658bb0UL, 0x6822d7bbUL, 0x5f4815baUL,\n    0x06f653b8UL, 0x319c91b9UL, 0xb48adebcUL, 0x83e01cbdUL, 0xda5e5abfUL,\n    0xed3498beUL\n  },\n  {\n    0x00000000UL, 0x6567bcb8UL, 0x8bc809aaUL, 0xeeafb512UL, 0x5797628fUL,\n    0x32f0de37UL, 0xdc5f6b25UL, 0xb938d79dUL, 0xef28b4c5UL, 0x8a4f087dUL,\n    0x64e0bd6fUL, 0x018701d7UL, 0xb8bfd64aUL, 0xddd86af2UL, 0x3377dfe0UL,\n    0x56106358UL, 0x9f571950UL, 0xfa30a5e8UL, 0x149f10faUL, 0x71f8ac42UL,\n    0xc8c07bdfUL, 0xada7c767UL, 0x43087275UL, 0x266fcecdUL, 0x707fad95UL,\n    0x1518112dUL, 0xfbb7a43fUL, 0x9ed01887UL, 0x27e8cf1aUL, 0x428f73a2UL,\n    0xac20c6b0UL, 0xc9477a08UL, 0x3eaf32a0UL, 0x5bc88e18UL, 0xb5673b0aUL,\n    0xd00087b2UL, 0x6938502fUL, 0x0c5fec97UL, 0xe2f05985UL, 0x8797e53dUL,\n    0xd1878665UL, 0xb4e03addUL, 0x5a4f8fcfUL, 0x3f283377UL, 0x8610e4eaUL,\n    0xe3775852UL, 0x0dd8ed40UL, 0x68bf51f8UL, 0xa1f82bf0UL, 0xc49f9748UL,\n    0x2a30225aUL, 0x4f579ee2UL, 0xf66f497fUL, 0x9308f5c7UL, 0x7da740d5UL,\n    0x18c0fc6dUL, 0x4ed09f35UL, 0x2bb7238dUL, 0xc518969fUL, 0xa07f2a27UL,\n    0x1947fdbaUL, 0x7c204102UL, 0x928ff410UL, 0xf7e848a8UL, 0x3d58149bUL,\n    0x583fa823UL, 0xb6901d31UL, 0xd3f7a189UL, 0x6acf7614UL, 0x0fa8caacUL,\n    0xe1077fbeUL, 0x8460c306UL, 0xd270a05eUL, 0xb7171ce6UL, 0x59b8a9f4UL,\n    0x3cdf154cUL, 0x85e7c2d1UL, 0xe0807e69UL, 0x0e2fcb7bUL, 0x6b4877c3UL,\n    0xa20f0dcbUL, 0xc768b173UL, 0x29c70461UL, 0x4ca0b8d9UL, 0xf5986f44UL,\n    0x90ffd3fcUL, 0x7e5066eeUL, 0x1b37da56UL, 0x4d27b90eUL, 0x284005b6UL,\n    0xc6efb0a4UL, 0xa3880c1cUL, 0x1ab0db81UL, 0x7fd76739UL, 0x9178d22bUL,\n    0xf41f6e93UL, 0x03f7263bUL, 0x66909a83UL, 0x883f2f91UL, 0xed589329UL,\n    0x546044b4UL, 0x3107f80cUL, 0xdfa84d1eUL, 0xbacff1a6UL, 0xecdf92feUL,\n    0x89b82e46UL, 0x67179b54UL, 0x027027ecUL, 0xbb48f071UL, 0xde2f4cc9UL,\n    0x3080f9dbUL, 0x55e74563UL, 0x9ca03f6bUL, 0xf9c783d3UL, 0x176836c1UL,\n    0x720f8a79UL, 0xcb375de4UL, 0xae50e15cUL, 0x40ff544eUL, 0x2598e8f6UL,\n    0x73888baeUL, 0x16ef3716UL, 0xf8408204UL, 0x9d273ebcUL, 0x241fe921UL,\n    0x41785599UL, 0xafd7e08bUL, 0xcab05c33UL, 0x3bb659edUL, 0x5ed1e555UL,\n    0xb07e5047UL, 0xd519ecffUL, 0x6c213b62UL, 0x094687daUL, 0xe7e932c8UL,\n    0x828e8e70UL, 0xd49eed28UL, 0xb1f95190UL, 0x5f56e482UL, 0x3a31583aUL,\n    0x83098fa7UL, 0xe66e331fUL, 0x08c1860dUL, 0x6da63ab5UL, 0xa4e140bdUL,\n    0xc186fc05UL, 0x2f294917UL, 0x4a4ef5afUL, 0xf3762232UL, 0x96119e8aUL,\n    0x78be2b98UL, 0x1dd99720UL, 0x4bc9f478UL, 0x2eae48c0UL, 0xc001fdd2UL,\n    0xa566416aUL, 0x1c5e96f7UL, 0x79392a4fUL, 0x97969f5dUL, 0xf2f123e5UL,\n    0x05196b4dUL, 0x607ed7f5UL, 0x8ed162e7UL, 0xebb6de5fUL, 0x528e09c2UL,\n    0x37e9b57aUL, 0xd9460068UL, 0xbc21bcd0UL, 0xea31df88UL, 0x8f566330UL,\n    0x61f9d622UL, 0x049e6a9aUL, 0xbda6bd07UL, 0xd8c101bfUL, 0x366eb4adUL,\n    0x53090815UL, 0x9a4e721dUL, 0xff29cea5UL, 0x11867bb7UL, 0x74e1c70fUL,\n    0xcdd91092UL, 0xa8beac2aUL, 0x46111938UL, 0x2376a580UL, 0x7566c6d8UL,\n    0x10017a60UL, 0xfeaecf72UL, 0x9bc973caUL, 0x22f1a457UL, 0x479618efUL,\n    0xa939adfdUL, 0xcc5e1145UL, 0x06ee4d76UL, 0x6389f1ceUL, 0x8d2644dcUL,\n    0xe841f864UL, 0x51792ff9UL, 0x341e9341UL, 0xdab12653UL, 0xbfd69aebUL,\n    0xe9c6f9b3UL, 0x8ca1450bUL, 0x620ef019UL, 0x07694ca1UL, 0xbe519b3cUL,\n    0xdb362784UL, 0x35999296UL, 0x50fe2e2eUL, 0x99b95426UL, 0xfcdee89eUL,\n    0x12715d8cUL, 0x7716e134UL, 0xce2e36a9UL, 0xab498a11UL, 0x45e63f03UL,\n    0x208183bbUL, 0x7691e0e3UL, 0x13f65c5bUL, 0xfd59e949UL, 0x983e55f1UL,\n    0x2106826cUL, 0x44613ed4UL, 0xaace8bc6UL, 0xcfa9377eUL, 0x38417fd6UL,\n    0x5d26c36eUL, 0xb389767cUL, 0xd6eecac4UL, 0x6fd61d59UL, 0x0ab1a1e1UL,\n    0xe41e14f3UL, 0x8179a84bUL, 0xd769cb13UL, 0xb20e77abUL, 0x5ca1c2b9UL,\n    0x39c67e01UL, 0x80fea99cUL, 0xe5991524UL, 0x0b36a036UL, 0x6e511c8eUL,\n    0xa7166686UL, 0xc271da3eUL, 0x2cde6f2cUL, 0x49b9d394UL, 0xf0810409UL,\n    0x95e6b8b1UL, 0x7b490da3UL, 0x1e2eb11bUL, 0x483ed243UL, 0x2d596efbUL,\n    0xc3f6dbe9UL, 0xa6916751UL, 0x1fa9b0ccUL, 0x7ace0c74UL, 0x9461b966UL,\n    0xf10605deUL\n#endif\n  }\n};\n"
  },
  {
    "path": "Projects/Tools/PNGAlphaPremultiplier/Native/Source/ZLib/deflate.c",
    "content": "/* deflate.c -- compress data using the deflation algorithm\n * Copyright (C) 1995-2012 Jean-loup Gailly and Mark Adler\n * For conditions of distribution and use, see copyright notice in zlib.h\n */\n\n/*\n *  ALGORITHM\n *\n *      The \"deflation\" process depends on being able to identify portions\n *      of the input text which are identical to earlier input (within a\n *      sliding window trailing behind the input currently being processed).\n *\n *      The most straightforward technique turns out to be the fastest for\n *      most input files: try all possible matches and select the longest.\n *      The key feature of this algorithm is that insertions into the string\n *      dictionary are very simple and thus fast, and deletions are avoided\n *      completely. Insertions are performed at each input character, whereas\n *      string matches are performed only when the previous match ends. So it\n *      is preferable to spend more time in matches to allow very fast string\n *      insertions and avoid deletions. The matching algorithm for small\n *      strings is inspired from that of Rabin & Karp. A brute force approach\n *      is used to find longer strings when a small match has been found.\n *      A similar algorithm is used in comic (by Jan-Mark Wams) and freeze\n *      (by Leonid Broukhis).\n *         A previous version of this file used a more sophisticated algorithm\n *      (by Fiala and Greene) which is guaranteed to run in linear amortized\n *      time, but has a larger average cost, uses more memory and is patented.\n *      However the F&G algorithm may be faster for some highly redundant\n *      files if the parameter max_chain_length (described below) is too large.\n *\n *  ACKNOWLEDGEMENTS\n *\n *      The idea of lazy evaluation of matches is due to Jan-Mark Wams, and\n *      I found it in 'freeze' written by Leonid Broukhis.\n *      Thanks to many people for bug reports and testing.\n *\n *  REFERENCES\n *\n *      Deutsch, L.P.,\"DEFLATE Compressed Data Format Specification\".\n *      Available in http://tools.ietf.org/html/rfc1951\n *\n *      A description of the Rabin and Karp algorithm is given in the book\n *         \"Algorithms\" by R. Sedgewick, Addison-Wesley, p252.\n *\n *      Fiala,E.R., and Greene,D.H.\n *         Data Compression with Finite Windows, Comm.ACM, 32,4 (1989) 490-595\n *\n */\n\n/* @(#) $Id$ */\n\n#include \"deflate.h\"\n\nconst char deflate_copyright[] =\n   \" deflate 1.2.6 Copyright 1995-2012 Jean-loup Gailly and Mark Adler \";\n/*\n  If you use the zlib library in a product, an acknowledgment is welcome\n  in the documentation of your product. If for some reason you cannot\n  include such an acknowledgment, I would appreciate that you keep this\n  copyright string in the executable of your product.\n */\n\n/* ===========================================================================\n *  Function prototypes.\n */\ntypedef enum {\n    need_more,      /* block not completed, need more input or more output */\n    block_done,     /* block flush performed */\n    finish_started, /* finish started, need only more output at next deflate */\n    finish_done     /* finish done, accept no more input or output */\n} block_state;\n\ntypedef block_state (*compress_func) OF((deflate_state *s, int flush));\n/* Compression function. Returns the block state after the call. */\n\nlocal void fill_window    OF((deflate_state *s));\nlocal block_state deflate_stored OF((deflate_state *s, int flush));\nlocal block_state deflate_fast   OF((deflate_state *s, int flush));\n#ifndef FASTEST\nlocal block_state deflate_slow   OF((deflate_state *s, int flush));\n#endif\nlocal block_state deflate_rle    OF((deflate_state *s, int flush));\nlocal block_state deflate_huff   OF((deflate_state *s, int flush));\nlocal void lm_init        OF((deflate_state *s));\nlocal void putShortMSB    OF((deflate_state *s, uInt b));\nlocal void flush_pending  OF((z_streamp strm));\nlocal int read_buf        OF((z_streamp strm, Bytef *buf, unsigned size));\n#ifdef ASMV\n      void match_init OF((void)); /* asm code initialization */\n      uInt longest_match  OF((deflate_state *s, IPos cur_match));\n#else\nlocal uInt longest_match  OF((deflate_state *s, IPos cur_match));\n#endif\n\n#ifdef DEBUG\nlocal  void check_match OF((deflate_state *s, IPos start, IPos match,\n                            int length));\n#endif\n\n/* ===========================================================================\n * Local data\n */\n\n#define NIL 0\n/* Tail of hash chains */\n\n#ifndef TOO_FAR\n#  define TOO_FAR 4096\n#endif\n/* Matches of length 3 are discarded if their distance exceeds TOO_FAR */\n\n/* Values for max_lazy_match, good_match and max_chain_length, depending on\n * the desired pack level (0..9). The values given below have been tuned to\n * exclude worst case performance for pathological files. Better values may be\n * found for specific files.\n */\ntypedef struct config_s {\n   ush good_length; /* reduce lazy search above this match length */\n   ush max_lazy;    /* do not perform lazy search above this match length */\n   ush nice_length; /* quit search above this match length */\n   ush max_chain;\n   compress_func func;\n} config;\n\n#ifdef FASTEST\nlocal const config configuration_table[2] = {\n/*      good lazy nice chain */\n/* 0 */ {0,    0,  0,    0, deflate_stored},  /* store only */\n/* 1 */ {4,    4,  8,    4, deflate_fast}}; /* max speed, no lazy matches */\n#else\nlocal const config configuration_table[10] = {\n/*      good lazy nice chain */\n/* 0 */ {0,    0,  0,    0, deflate_stored},  /* store only */\n/* 1 */ {4,    4,  8,    4, deflate_fast}, /* max speed, no lazy matches */\n/* 2 */ {4,    5, 16,    8, deflate_fast},\n/* 3 */ {4,    6, 32,   32, deflate_fast},\n\n/* 4 */ {4,    4, 16,   16, deflate_slow},  /* lazy matches */\n/* 5 */ {8,   16, 32,   32, deflate_slow},\n/* 6 */ {8,   16, 128, 128, deflate_slow},\n/* 7 */ {8,   32, 128, 256, deflate_slow},\n/* 8 */ {32, 128, 258, 1024, deflate_slow},\n/* 9 */ {32, 258, 258, 4096, deflate_slow}}; /* max compression */\n#endif\n\n/* Note: the deflate() code requires max_lazy >= MIN_MATCH and max_chain >= 4\n * For deflate_fast() (levels <= 3) good is ignored and lazy has a different\n * meaning.\n */\n\n#define EQUAL 0\n/* result of memcmp for equal strings */\n\n#ifndef NO_DUMMY_DECL\nstruct static_tree_desc_s {int dummy;}; /* for buggy compilers */\n#endif\n\n/* rank Z_BLOCK between Z_NO_FLUSH and Z_PARTIAL_FLUSH */\n#define RANK(f) (((f) << 1) - ((f) > 4 ? 9 : 0))\n\n/* ===========================================================================\n * Update a hash value with the given input byte\n * IN  assertion: all calls to to UPDATE_HASH are made with consecutive\n *    input characters, so that a running hash key can be computed from the\n *    previous key instead of complete recalculation each time.\n */\n#define UPDATE_HASH(s,h,c) (h = (((h)<<s->hash_shift) ^ (c)) & s->hash_mask)\n\n\n/* ===========================================================================\n * Insert string str in the dictionary and set match_head to the previous head\n * of the hash chain (the most recent string with same hash key). Return\n * the previous length of the hash chain.\n * If this file is compiled with -DFASTEST, the compression level is forced\n * to 1, and no hash chains are maintained.\n * IN  assertion: all calls to to INSERT_STRING are made with consecutive\n *    input characters and the first MIN_MATCH bytes of str are valid\n *    (except for the last MIN_MATCH-1 bytes of the input file).\n */\n#ifdef FASTEST\n#define INSERT_STRING(s, str, match_head) \\\n   (UPDATE_HASH(s, s->ins_h, s->window[(str) + (MIN_MATCH-1)]), \\\n    match_head = s->head[s->ins_h], \\\n    s->head[s->ins_h] = (Pos)(str))\n#else\n#define INSERT_STRING(s, str, match_head) \\\n   (UPDATE_HASH(s, s->ins_h, s->window[(str) + (MIN_MATCH-1)]), \\\n    match_head = s->prev[(str) & s->w_mask] = s->head[s->ins_h], \\\n    s->head[s->ins_h] = (Pos)(str))\n#endif\n\n/* ===========================================================================\n * Initialize the hash table (avoiding 64K overflow for 16 bit systems).\n * prev[] will be initialized on the fly.\n */\n#define CLEAR_HASH(s) \\\n    s->head[s->hash_size-1] = NIL; \\\n    zmemzero((Bytef *)s->head, (unsigned)(s->hash_size-1)*sizeof(*s->head));\n\n/* ========================================================================= */\nint ZEXPORT deflateInit_(strm, level, version, stream_size)\n    z_streamp strm;\n    int level;\n    const char *version;\n    int stream_size;\n{\n    return deflateInit2_(strm, level, Z_DEFLATED, MAX_WBITS, DEF_MEM_LEVEL,\n                         Z_DEFAULT_STRATEGY, version, stream_size);\n    /* To do: ignore strm->next_in if we use it as window */\n}\n\n/* ========================================================================= */\nint ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy,\n                  version, stream_size)\n    z_streamp strm;\n    int  level;\n    int  method;\n    int  windowBits;\n    int  memLevel;\n    int  strategy;\n    const char *version;\n    int stream_size;\n{\n    deflate_state *s;\n    int wrap = 1;\n    static const char my_version[] = ZLIB_VERSION;\n\n    ushf *overlay;\n    /* We overlay pending_buf and d_buf+l_buf. This works since the average\n     * output size for (length,distance) codes is <= 24 bits.\n     */\n\n    if (version == Z_NULL || version[0] != my_version[0] ||\n        stream_size != sizeof(z_stream)) {\n        return Z_VERSION_ERROR;\n    }\n    if (strm == Z_NULL) return Z_STREAM_ERROR;\n\n    strm->msg = Z_NULL;\n    if (strm->zalloc == (alloc_func)0) {\n#ifdef Z_SOLO\n        return Z_STREAM_ERROR;\n#else\n        strm->zalloc = zcalloc;\n        strm->opaque = (voidpf)0;\n#endif\n    }\n    if (strm->zfree == (free_func)0)\n#ifdef Z_SOLO\n        return Z_STREAM_ERROR;\n#else\n        strm->zfree = zcfree;\n#endif\n\n#ifdef FASTEST\n    if (level != 0) level = 1;\n#else\n    if (level == Z_DEFAULT_COMPRESSION) level = 6;\n#endif\n\n    if (windowBits < 0) { /* suppress zlib wrapper */\n        wrap = 0;\n        windowBits = -windowBits;\n    }\n#ifdef GZIP\n    else if (windowBits > 15) {\n        wrap = 2;       /* write gzip wrapper instead */\n        windowBits -= 16;\n    }\n#endif\n    if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || method != Z_DEFLATED ||\n        windowBits < 8 || windowBits > 15 || level < 0 || level > 9 ||\n        strategy < 0 || strategy > Z_FIXED) {\n        return Z_STREAM_ERROR;\n    }\n    if (windowBits == 8) windowBits = 9;  /* until 256-byte window bug fixed */\n    s = (deflate_state *) ZALLOC(strm, 1, sizeof(deflate_state));\n    if (s == Z_NULL) return Z_MEM_ERROR;\n    strm->state = (struct internal_state FAR *)s;\n    s->strm = strm;\n\n    s->wrap = wrap;\n    s->gzhead = Z_NULL;\n    s->w_bits = windowBits;\n    s->w_size = 1 << s->w_bits;\n    s->w_mask = s->w_size - 1;\n\n    s->hash_bits = memLevel + 7;\n    s->hash_size = 1 << s->hash_bits;\n    s->hash_mask = s->hash_size - 1;\n    s->hash_shift =  ((s->hash_bits+MIN_MATCH-1)/MIN_MATCH);\n\n    s->window = (Bytef *) ZALLOC(strm, s->w_size, 2*sizeof(Byte));\n    s->prev   = (Posf *)  ZALLOC(strm, s->w_size, sizeof(Pos));\n    s->head   = (Posf *)  ZALLOC(strm, s->hash_size, sizeof(Pos));\n\n    s->high_water = 0;      /* nothing written to s->window yet */\n\n    s->lit_bufsize = 1 << (memLevel + 6); /* 16K elements by default */\n\n    overlay = (ushf *) ZALLOC(strm, s->lit_bufsize, sizeof(ush)+2);\n    s->pending_buf = (uchf *) overlay;\n    s->pending_buf_size = (ulg)s->lit_bufsize * (sizeof(ush)+2L);\n\n    if (s->window == Z_NULL || s->prev == Z_NULL || s->head == Z_NULL ||\n        s->pending_buf == Z_NULL) {\n        s->status = FINISH_STATE;\n        strm->msg = (char*)ERR_MSG(Z_MEM_ERROR);\n        deflateEnd (strm);\n        return Z_MEM_ERROR;\n    }\n    s->d_buf = overlay + s->lit_bufsize/sizeof(ush);\n    s->l_buf = s->pending_buf + (1+sizeof(ush))*s->lit_bufsize;\n\n    s->level = level;\n    s->strategy = strategy;\n    s->method = (Byte)method;\n\n    return deflateReset(strm);\n}\n\n/* ========================================================================= */\nint ZEXPORT deflateSetDictionary (strm, dictionary, dictLength)\n    z_streamp strm;\n    const Bytef *dictionary;\n    uInt  dictLength;\n{\n    deflate_state *s;\n    uInt str, n;\n    int wrap;\n    unsigned avail;\n    unsigned char *next;\n\n    if (strm == Z_NULL || strm->state == Z_NULL || dictionary == Z_NULL)\n        return Z_STREAM_ERROR;\n    s = strm->state;\n    wrap = s->wrap;\n    if (wrap == 2 || (wrap == 1 && s->status != INIT_STATE) || s->lookahead)\n        return Z_STREAM_ERROR;\n\n    /* when using zlib wrappers, compute Adler-32 for provided dictionary */\n    if (wrap == 1)\n        strm->adler = adler32(strm->adler, dictionary, dictLength);\n    s->wrap = 0;                    /* avoid computing Adler-32 in read_buf */\n\n    /* if dictionary would fill window, just replace the history */\n    if (dictLength >= s->w_size) {\n        if (wrap == 0) {            /* already empty otherwise */\n            CLEAR_HASH(s);\n            s->strstart = 0;\n            s->block_start = 0L;\n            s->insert = 0;\n        }\n        dictionary += dictLength - s->w_size;  /* use the tail */\n        dictLength = s->w_size;\n    }\n\n    /* insert dictionary into window and hash */\n    avail = strm->avail_in;\n    next = strm->next_in;\n    strm->avail_in = dictLength;\n    strm->next_in = (Bytef *)dictionary;\n    fill_window(s);\n    while (s->lookahead >= MIN_MATCH) {\n        str = s->strstart;\n        n = s->lookahead - (MIN_MATCH-1);\n        do {\n            UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]);\n#ifndef FASTEST\n            s->prev[str & s->w_mask] = s->head[s->ins_h];\n#endif\n            s->head[s->ins_h] = (Pos)str;\n            str++;\n        } while (--n);\n        s->strstart = str;\n        s->lookahead = MIN_MATCH-1;\n        fill_window(s);\n    }\n    s->strstart += s->lookahead;\n    s->block_start = (long)s->strstart;\n    s->insert = s->lookahead;\n    s->lookahead = 0;\n    s->match_length = s->prev_length = MIN_MATCH-1;\n    s->match_available = 0;\n    strm->next_in = next;\n    strm->avail_in = avail;\n    s->wrap = wrap;\n    return Z_OK;\n}\n\n/* ========================================================================= */\nint ZEXPORT deflateResetKeep (strm)\n    z_streamp strm;\n{\n    deflate_state *s;\n\n    if (strm == Z_NULL || strm->state == Z_NULL ||\n        strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0) {\n        return Z_STREAM_ERROR;\n    }\n\n    strm->total_in = strm->total_out = 0;\n    strm->msg = Z_NULL; /* use zfree if we ever allocate msg dynamically */\n    strm->data_type = Z_UNKNOWN;\n\n    s = (deflate_state *)strm->state;\n    s->pending = 0;\n    s->pending_out = s->pending_buf;\n\n    if (s->wrap < 0) {\n        s->wrap = -s->wrap; /* was made negative by deflate(..., Z_FINISH); */\n    }\n    s->status = s->wrap ? INIT_STATE : BUSY_STATE;\n    strm->adler =\n#ifdef GZIP\n        s->wrap == 2 ? crc32(0L, Z_NULL, 0) :\n#endif\n        adler32(0L, Z_NULL, 0);\n    s->last_flush = Z_NO_FLUSH;\n\n    _tr_init(s);\n\n    return Z_OK;\n}\n\n/* ========================================================================= */\nint ZEXPORT deflateReset (strm)\n    z_streamp strm;\n{\n    int ret;\n\n    ret = deflateResetKeep(strm);\n    if (ret == Z_OK)\n        lm_init(strm->state);\n    return ret;\n}\n\n/* ========================================================================= */\nint ZEXPORT deflateSetHeader (strm, head)\n    z_streamp strm;\n    gz_headerp head;\n{\n    if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;\n    if (strm->state->wrap != 2) return Z_STREAM_ERROR;\n    strm->state->gzhead = head;\n    return Z_OK;\n}\n\n/* ========================================================================= */\nint ZEXPORT deflatePending (strm, pending, bits)\n    unsigned *pending;\n    int *bits;\n    z_streamp strm;\n{\n    if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;\n    if (pending != Z_NULL)\n        *pending = strm->state->pending;\n    if (bits != Z_NULL)\n        *bits = strm->state->bi_valid;\n    return Z_OK;\n}\n\n/* ========================================================================= */\nint ZEXPORT deflatePrime (strm, bits, value)\n    z_streamp strm;\n    int bits;\n    int value;\n{\n    deflate_state *s;\n    int put;\n\n    if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;\n    s = strm->state;\n    if ((Bytef *)(s->d_buf) < s->pending_out + ((Buf_size + 7) >> 3))\n        return Z_BUF_ERROR;\n    do {\n        put = Buf_size - s->bi_valid;\n        if (put > bits)\n            put = bits;\n        s->bi_buf |= (ush)((value & ((1 << put) - 1)) << s->bi_valid);\n        s->bi_valid += put;\n        _tr_flush_bits(s);\n        value >>= put;\n        bits -= put;\n    } while (bits);\n    return Z_OK;\n}\n\n/* ========================================================================= */\nint ZEXPORT deflateParams(strm, level, strategy)\n    z_streamp strm;\n    int level;\n    int strategy;\n{\n    deflate_state *s;\n    compress_func func;\n    int err = Z_OK;\n\n    if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;\n    s = strm->state;\n\n#ifdef FASTEST\n    if (level != 0) level = 1;\n#else\n    if (level == Z_DEFAULT_COMPRESSION) level = 6;\n#endif\n    if (level < 0 || level > 9 || strategy < 0 || strategy > Z_FIXED) {\n        return Z_STREAM_ERROR;\n    }\n    func = configuration_table[s->level].func;\n\n    if ((strategy != s->strategy || func != configuration_table[level].func) &&\n        strm->total_in != 0) {\n        /* Flush the last buffer: */\n        err = deflate(strm, Z_BLOCK);\n    }\n    if (s->level != level) {\n        s->level = level;\n        s->max_lazy_match   = configuration_table[level].max_lazy;\n        s->good_match       = configuration_table[level].good_length;\n        s->nice_match       = configuration_table[level].nice_length;\n        s->max_chain_length = configuration_table[level].max_chain;\n    }\n    s->strategy = strategy;\n    return err;\n}\n\n/* ========================================================================= */\nint ZEXPORT deflateTune(strm, good_length, max_lazy, nice_length, max_chain)\n    z_streamp strm;\n    int good_length;\n    int max_lazy;\n    int nice_length;\n    int max_chain;\n{\n    deflate_state *s;\n\n    if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;\n    s = strm->state;\n    s->good_match = good_length;\n    s->max_lazy_match = max_lazy;\n    s->nice_match = nice_length;\n    s->max_chain_length = max_chain;\n    return Z_OK;\n}\n\n/* =========================================================================\n * For the default windowBits of 15 and memLevel of 8, this function returns\n * a close to exact, as well as small, upper bound on the compressed size.\n * They are coded as constants here for a reason--if the #define's are\n * changed, then this function needs to be changed as well.  The return\n * value for 15 and 8 only works for those exact settings.\n *\n * For any setting other than those defaults for windowBits and memLevel,\n * the value returned is a conservative worst case for the maximum expansion\n * resulting from using fixed blocks instead of stored blocks, which deflate\n * can emit on compressed data for some combinations of the parameters.\n *\n * This function could be more sophisticated to provide closer upper bounds for\n * every combination of windowBits and memLevel.  But even the conservative\n * upper bound of about 14% expansion does not seem onerous for output buffer\n * allocation.\n */\nuLong ZEXPORT deflateBound(strm, sourceLen)\n    z_streamp strm;\n    uLong sourceLen;\n{\n    deflate_state *s;\n    uLong complen, wraplen;\n    Bytef *str;\n\n    /* conservative upper bound for compressed data */\n    complen = sourceLen +\n              ((sourceLen + 7) >> 3) + ((sourceLen + 63) >> 6) + 5;\n\n    /* if can't get parameters, return conservative bound plus zlib wrapper */\n    if (strm == Z_NULL || strm->state == Z_NULL)\n        return complen + 6;\n\n    /* compute wrapper length */\n    s = strm->state;\n    switch (s->wrap) {\n    case 0:                                 /* raw deflate */\n        wraplen = 0;\n        break;\n    case 1:                                 /* zlib wrapper */\n        wraplen = 6 + (s->strstart ? 4 : 0);\n        break;\n    case 2:                                 /* gzip wrapper */\n        wraplen = 18;\n        if (s->gzhead != Z_NULL) {          /* user-supplied gzip header */\n            if (s->gzhead->extra != Z_NULL)\n                wraplen += 2 + s->gzhead->extra_len;\n            str = s->gzhead->name;\n            if (str != Z_NULL)\n                do {\n                    wraplen++;\n                } while (*str++);\n            str = s->gzhead->comment;\n            if (str != Z_NULL)\n                do {\n                    wraplen++;\n                } while (*str++);\n            if (s->gzhead->hcrc)\n                wraplen += 2;\n        }\n        break;\n    default:                                /* for compiler happiness */\n        wraplen = 6;\n    }\n\n    /* if not default parameters, return conservative bound */\n    if (s->w_bits != 15 || s->hash_bits != 8 + 7)\n        return complen + wraplen;\n\n    /* default settings: return tight bound for that case */\n    return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) +\n           (sourceLen >> 25) + 13 - 6 + wraplen;\n}\n\n/* =========================================================================\n * Put a short in the pending buffer. The 16-bit value is put in MSB order.\n * IN assertion: the stream state is correct and there is enough room in\n * pending_buf.\n */\nlocal void putShortMSB (s, b)\n    deflate_state *s;\n    uInt b;\n{\n    put_byte(s, (Byte)(b >> 8));\n    put_byte(s, (Byte)(b & 0xff));\n}\n\n/* =========================================================================\n * Flush as much pending output as possible. All deflate() output goes\n * through this function so some applications may wish to modify it\n * to avoid allocating a large strm->next_out buffer and copying into it.\n * (See also read_buf()).\n */\nlocal void flush_pending(strm)\n    z_streamp strm;\n{\n    unsigned len;\n    deflate_state *s = strm->state;\n\n    _tr_flush_bits(s);\n    len = s->pending;\n    if (len > strm->avail_out) len = strm->avail_out;\n    if (len == 0) return;\n\n    zmemcpy(strm->next_out, s->pending_out, len);\n    strm->next_out  += len;\n    s->pending_out  += len;\n    strm->total_out += len;\n    strm->avail_out  -= len;\n    s->pending -= len;\n    if (s->pending == 0) {\n        s->pending_out = s->pending_buf;\n    }\n}\n\n/* ========================================================================= */\nint ZEXPORT deflate (strm, flush)\n    z_streamp strm;\n    int flush;\n{\n    int old_flush; /* value of flush param for previous deflate call */\n    deflate_state *s;\n\n    if (strm == Z_NULL || strm->state == Z_NULL ||\n        flush > Z_BLOCK || flush < 0) {\n        return Z_STREAM_ERROR;\n    }\n    s = strm->state;\n\n    if (strm->next_out == Z_NULL ||\n        (strm->next_in == Z_NULL && strm->avail_in != 0) ||\n        (s->status == FINISH_STATE && flush != Z_FINISH)) {\n        ERR_RETURN(strm, Z_STREAM_ERROR);\n    }\n    if (strm->avail_out == 0) ERR_RETURN(strm, Z_BUF_ERROR);\n\n    s->strm = strm; /* just in case */\n    old_flush = s->last_flush;\n    s->last_flush = flush;\n\n    /* Write the header */\n    if (s->status == INIT_STATE) {\n#ifdef GZIP\n        if (s->wrap == 2) {\n            strm->adler = crc32(0L, Z_NULL, 0);\n            put_byte(s, 31);\n            put_byte(s, 139);\n            put_byte(s, 8);\n            if (s->gzhead == Z_NULL) {\n                put_byte(s, 0);\n                put_byte(s, 0);\n                put_byte(s, 0);\n                put_byte(s, 0);\n                put_byte(s, 0);\n                put_byte(s, s->level == 9 ? 2 :\n                            (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ?\n                             4 : 0));\n                put_byte(s, OS_CODE);\n                s->status = BUSY_STATE;\n            }\n            else {\n                put_byte(s, (s->gzhead->text ? 1 : 0) +\n                            (s->gzhead->hcrc ? 2 : 0) +\n                            (s->gzhead->extra == Z_NULL ? 0 : 4) +\n                            (s->gzhead->name == Z_NULL ? 0 : 8) +\n                            (s->gzhead->comment == Z_NULL ? 0 : 16)\n                        );\n                put_byte(s, (Byte)(s->gzhead->time & 0xff));\n                put_byte(s, (Byte)((s->gzhead->time >> 8) & 0xff));\n                put_byte(s, (Byte)((s->gzhead->time >> 16) & 0xff));\n                put_byte(s, (Byte)((s->gzhead->time >> 24) & 0xff));\n                put_byte(s, s->level == 9 ? 2 :\n                            (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ?\n                             4 : 0));\n                put_byte(s, s->gzhead->os & 0xff);\n                if (s->gzhead->extra != Z_NULL) {\n                    put_byte(s, s->gzhead->extra_len & 0xff);\n                    put_byte(s, (s->gzhead->extra_len >> 8) & 0xff);\n                }\n                if (s->gzhead->hcrc)\n                    strm->adler = crc32(strm->adler, s->pending_buf,\n                                        s->pending);\n                s->gzindex = 0;\n                s->status = EXTRA_STATE;\n            }\n        }\n        else\n#endif\n        {\n            uInt header = (Z_DEFLATED + ((s->w_bits-8)<<4)) << 8;\n            uInt level_flags;\n\n            if (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2)\n                level_flags = 0;\n            else if (s->level < 6)\n                level_flags = 1;\n            else if (s->level == 6)\n                level_flags = 2;\n            else\n                level_flags = 3;\n            header |= (level_flags << 6);\n            if (s->strstart != 0) header |= PRESET_DICT;\n            header += 31 - (header % 31);\n\n            s->status = BUSY_STATE;\n            putShortMSB(s, header);\n\n            /* Save the adler32 of the preset dictionary: */\n            if (s->strstart != 0) {\n                putShortMSB(s, (uInt)(strm->adler >> 16));\n                putShortMSB(s, (uInt)(strm->adler & 0xffff));\n            }\n            strm->adler = adler32(0L, Z_NULL, 0);\n        }\n    }\n#ifdef GZIP\n    if (s->status == EXTRA_STATE) {\n        if (s->gzhead->extra != Z_NULL) {\n            uInt beg = s->pending;  /* start of bytes to update crc */\n\n            while (s->gzindex < (s->gzhead->extra_len & 0xffff)) {\n                if (s->pending == s->pending_buf_size) {\n                    if (s->gzhead->hcrc && s->pending > beg)\n                        strm->adler = crc32(strm->adler, s->pending_buf + beg,\n                                            s->pending - beg);\n                    flush_pending(strm);\n                    beg = s->pending;\n                    if (s->pending == s->pending_buf_size)\n                        break;\n                }\n                put_byte(s, s->gzhead->extra[s->gzindex]);\n                s->gzindex++;\n            }\n            if (s->gzhead->hcrc && s->pending > beg)\n                strm->adler = crc32(strm->adler, s->pending_buf + beg,\n                                    s->pending - beg);\n            if (s->gzindex == s->gzhead->extra_len) {\n                s->gzindex = 0;\n                s->status = NAME_STATE;\n            }\n        }\n        else\n            s->status = NAME_STATE;\n    }\n    if (s->status == NAME_STATE) {\n        if (s->gzhead->name != Z_NULL) {\n            uInt beg = s->pending;  /* start of bytes to update crc */\n            int val;\n\n            do {\n                if (s->pending == s->pending_buf_size) {\n                    if (s->gzhead->hcrc && s->pending > beg)\n                        strm->adler = crc32(strm->adler, s->pending_buf + beg,\n                                            s->pending - beg);\n                    flush_pending(strm);\n                    beg = s->pending;\n                    if (s->pending == s->pending_buf_size) {\n                        val = 1;\n                        break;\n                    }\n                }\n                val = s->gzhead->name[s->gzindex++];\n                put_byte(s, val);\n            } while (val != 0);\n            if (s->gzhead->hcrc && s->pending > beg)\n                strm->adler = crc32(strm->adler, s->pending_buf + beg,\n                                    s->pending - beg);\n            if (val == 0) {\n                s->gzindex = 0;\n                s->status = COMMENT_STATE;\n            }\n        }\n        else\n            s->status = COMMENT_STATE;\n    }\n    if (s->status == COMMENT_STATE) {\n        if (s->gzhead->comment != Z_NULL) {\n            uInt beg = s->pending;  /* start of bytes to update crc */\n            int val;\n\n            do {\n                if (s->pending == s->pending_buf_size) {\n                    if (s->gzhead->hcrc && s->pending > beg)\n                        strm->adler = crc32(strm->adler, s->pending_buf + beg,\n                                            s->pending - beg);\n                    flush_pending(strm);\n                    beg = s->pending;\n                    if (s->pending == s->pending_buf_size) {\n                        val = 1;\n                        break;\n                    }\n                }\n                val = s->gzhead->comment[s->gzindex++];\n                put_byte(s, val);\n            } while (val != 0);\n            if (s->gzhead->hcrc && s->pending > beg)\n                strm->adler = crc32(strm->adler, s->pending_buf + beg,\n                                    s->pending - beg);\n            if (val == 0)\n                s->status = HCRC_STATE;\n        }\n        else\n            s->status = HCRC_STATE;\n    }\n    if (s->status == HCRC_STATE) {\n        if (s->gzhead->hcrc) {\n            if (s->pending + 2 > s->pending_buf_size)\n                flush_pending(strm);\n            if (s->pending + 2 <= s->pending_buf_size) {\n                put_byte(s, (Byte)(strm->adler & 0xff));\n                put_byte(s, (Byte)((strm->adler >> 8) & 0xff));\n                strm->adler = crc32(0L, Z_NULL, 0);\n                s->status = BUSY_STATE;\n            }\n        }\n        else\n            s->status = BUSY_STATE;\n    }\n#endif\n\n    /* Flush as much pending output as possible */\n    if (s->pending != 0) {\n        flush_pending(strm);\n        if (strm->avail_out == 0) {\n            /* Since avail_out is 0, deflate will be called again with\n             * more output space, but possibly with both pending and\n             * avail_in equal to zero. There won't be anything to do,\n             * but this is not an error situation so make sure we\n             * return OK instead of BUF_ERROR at next call of deflate:\n             */\n            s->last_flush = -1;\n            return Z_OK;\n        }\n\n    /* Make sure there is something to do and avoid duplicate consecutive\n     * flushes. For repeated and useless calls with Z_FINISH, we keep\n     * returning Z_STREAM_END instead of Z_BUF_ERROR.\n     */\n    } else if (strm->avail_in == 0 && RANK(flush) <= RANK(old_flush) &&\n               flush != Z_FINISH) {\n        ERR_RETURN(strm, Z_BUF_ERROR);\n    }\n\n    /* User must not provide more input after the first FINISH: */\n    if (s->status == FINISH_STATE && strm->avail_in != 0) {\n        ERR_RETURN(strm, Z_BUF_ERROR);\n    }\n\n    /* Start a new block or continue the current one.\n     */\n    if (strm->avail_in != 0 || s->lookahead != 0 ||\n        (flush != Z_NO_FLUSH && s->status != FINISH_STATE)) {\n        block_state bstate;\n\n        bstate = s->strategy == Z_HUFFMAN_ONLY ? deflate_huff(s, flush) :\n                    (s->strategy == Z_RLE ? deflate_rle(s, flush) :\n                        (*(configuration_table[s->level].func))(s, flush));\n\n        if (bstate == finish_started || bstate == finish_done) {\n            s->status = FINISH_STATE;\n        }\n        if (bstate == need_more || bstate == finish_started) {\n            if (strm->avail_out == 0) {\n                s->last_flush = -1; /* avoid BUF_ERROR next call, see above */\n            }\n            return Z_OK;\n            /* If flush != Z_NO_FLUSH && avail_out == 0, the next call\n             * of deflate should use the same flush parameter to make sure\n             * that the flush is complete. So we don't have to output an\n             * empty block here, this will be done at next call. This also\n             * ensures that for a very small output buffer, we emit at most\n             * one empty block.\n             */\n        }\n        if (bstate == block_done) {\n            if (flush == Z_PARTIAL_FLUSH) {\n                _tr_align(s);\n            } else if (flush != Z_BLOCK) { /* FULL_FLUSH or SYNC_FLUSH */\n                _tr_stored_block(s, (char*)0, 0L, 0);\n                /* For a full flush, this empty block will be recognized\n                 * as a special marker by inflate_sync().\n                 */\n                if (flush == Z_FULL_FLUSH) {\n                    CLEAR_HASH(s);             /* forget history */\n                    if (s->lookahead == 0) {\n                        s->strstart = 0;\n                        s->block_start = 0L;\n                        s->insert = 0;\n                    }\n                }\n            }\n            flush_pending(strm);\n            if (strm->avail_out == 0) {\n              s->last_flush = -1; /* avoid BUF_ERROR at next call, see above */\n              return Z_OK;\n            }\n        }\n    }\n    Assert(strm->avail_out > 0, \"bug2\");\n\n    if (flush != Z_FINISH) return Z_OK;\n    if (s->wrap <= 0) return Z_STREAM_END;\n\n    /* Write the trailer */\n#ifdef GZIP\n    if (s->wrap == 2) {\n        put_byte(s, (Byte)(strm->adler & 0xff));\n        put_byte(s, (Byte)((strm->adler >> 8) & 0xff));\n        put_byte(s, (Byte)((strm->adler >> 16) & 0xff));\n        put_byte(s, (Byte)((strm->adler >> 24) & 0xff));\n        put_byte(s, (Byte)(strm->total_in & 0xff));\n        put_byte(s, (Byte)((strm->total_in >> 8) & 0xff));\n        put_byte(s, (Byte)((strm->total_in >> 16) & 0xff));\n        put_byte(s, (Byte)((strm->total_in >> 24) & 0xff));\n    }\n    else\n#endif\n    {\n        putShortMSB(s, (uInt)(strm->adler >> 16));\n        putShortMSB(s, (uInt)(strm->adler & 0xffff));\n    }\n    flush_pending(strm);\n    /* If avail_out is zero, the application will call deflate again\n     * to flush the rest.\n     */\n    if (s->wrap > 0) s->wrap = -s->wrap; /* write the trailer only once! */\n    return s->pending != 0 ? Z_OK : Z_STREAM_END;\n}\n\n/* ========================================================================= */\nint ZEXPORT deflateEnd (strm)\n    z_streamp strm;\n{\n    int status;\n\n    if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;\n\n    status = strm->state->status;\n    if (status != INIT_STATE &&\n        status != EXTRA_STATE &&\n        status != NAME_STATE &&\n        status != COMMENT_STATE &&\n        status != HCRC_STATE &&\n        status != BUSY_STATE &&\n        status != FINISH_STATE) {\n      return Z_STREAM_ERROR;\n    }\n\n    /* Deallocate in reverse order of allocations: */\n    TRY_FREE(strm, strm->state->pending_buf);\n    TRY_FREE(strm, strm->state->head);\n    TRY_FREE(strm, strm->state->prev);\n    TRY_FREE(strm, strm->state->window);\n\n    ZFREE(strm, strm->state);\n    strm->state = Z_NULL;\n\n    return status == BUSY_STATE ? Z_DATA_ERROR : Z_OK;\n}\n\n/* =========================================================================\n * Copy the source state to the destination state.\n * To simplify the source, this is not supported for 16-bit MSDOS (which\n * doesn't have enough memory anyway to duplicate compression states).\n */\nint ZEXPORT deflateCopy (dest, source)\n    z_streamp dest;\n    z_streamp source;\n{\n#ifdef MAXSEG_64K\n    return Z_STREAM_ERROR;\n#else\n    deflate_state *ds;\n    deflate_state *ss;\n    ushf *overlay;\n\n\n    if (source == Z_NULL || dest == Z_NULL || source->state == Z_NULL) {\n        return Z_STREAM_ERROR;\n    }\n\n    ss = source->state;\n\n    zmemcpy((voidpf)dest, (voidpf)source, sizeof(z_stream));\n\n    ds = (deflate_state *) ZALLOC(dest, 1, sizeof(deflate_state));\n    if (ds == Z_NULL) return Z_MEM_ERROR;\n    dest->state = (struct internal_state FAR *) ds;\n    zmemcpy((voidpf)ds, (voidpf)ss, sizeof(deflate_state));\n    ds->strm = dest;\n\n    ds->window = (Bytef *) ZALLOC(dest, ds->w_size, 2*sizeof(Byte));\n    ds->prev   = (Posf *)  ZALLOC(dest, ds->w_size, sizeof(Pos));\n    ds->head   = (Posf *)  ZALLOC(dest, ds->hash_size, sizeof(Pos));\n    overlay = (ushf *) ZALLOC(dest, ds->lit_bufsize, sizeof(ush)+2);\n    ds->pending_buf = (uchf *) overlay;\n\n    if (ds->window == Z_NULL || ds->prev == Z_NULL || ds->head == Z_NULL ||\n        ds->pending_buf == Z_NULL) {\n        deflateEnd (dest);\n        return Z_MEM_ERROR;\n    }\n    /* following zmemcpy do not work for 16-bit MSDOS */\n    zmemcpy(ds->window, ss->window, ds->w_size * 2 * sizeof(Byte));\n    zmemcpy((voidpf)ds->prev, (voidpf)ss->prev, ds->w_size * sizeof(Pos));\n    zmemcpy((voidpf)ds->head, (voidpf)ss->head, ds->hash_size * sizeof(Pos));\n    zmemcpy(ds->pending_buf, ss->pending_buf, (uInt)ds->pending_buf_size);\n\n    ds->pending_out = ds->pending_buf + (ss->pending_out - ss->pending_buf);\n    ds->d_buf = overlay + ds->lit_bufsize/sizeof(ush);\n    ds->l_buf = ds->pending_buf + (1+sizeof(ush))*ds->lit_bufsize;\n\n    ds->l_desc.dyn_tree = ds->dyn_ltree;\n    ds->d_desc.dyn_tree = ds->dyn_dtree;\n    ds->bl_desc.dyn_tree = ds->bl_tree;\n\n    return Z_OK;\n#endif /* MAXSEG_64K */\n}\n\n/* ===========================================================================\n * Read a new buffer from the current input stream, update the adler32\n * and total number of bytes read.  All deflate() input goes through\n * this function so some applications may wish to modify it to avoid\n * allocating a large strm->next_in buffer and copying from it.\n * (See also flush_pending()).\n */\nlocal int read_buf(strm, buf, size)\n    z_streamp strm;\n    Bytef *buf;\n    unsigned size;\n{\n    unsigned len = strm->avail_in;\n\n    if (len > size) len = size;\n    if (len == 0) return 0;\n\n    strm->avail_in  -= len;\n\n    zmemcpy(buf, strm->next_in, len);\n    if (strm->state->wrap == 1) {\n        strm->adler = adler32(strm->adler, buf, len);\n    }\n#ifdef GZIP\n    else if (strm->state->wrap == 2) {\n        strm->adler = crc32(strm->adler, buf, len);\n    }\n#endif\n    strm->next_in  += len;\n    strm->total_in += len;\n\n    return (int)len;\n}\n\n/* ===========================================================================\n * Initialize the \"longest match\" routines for a new zlib stream\n */\nlocal void lm_init (s)\n    deflate_state *s;\n{\n    s->window_size = (ulg)2L*s->w_size;\n\n    CLEAR_HASH(s);\n\n    /* Set the default configuration parameters:\n     */\n    s->max_lazy_match   = configuration_table[s->level].max_lazy;\n    s->good_match       = configuration_table[s->level].good_length;\n    s->nice_match       = configuration_table[s->level].nice_length;\n    s->max_chain_length = configuration_table[s->level].max_chain;\n\n    s->strstart = 0;\n    s->block_start = 0L;\n    s->lookahead = 0;\n    s->insert = 0;\n    s->match_length = s->prev_length = MIN_MATCH-1;\n    s->match_available = 0;\n    s->ins_h = 0;\n#ifndef FASTEST\n#ifdef ASMV\n    match_init(); /* initialize the asm code */\n#endif\n#endif\n}\n\n#ifndef FASTEST\n/* ===========================================================================\n * Set match_start to the longest match starting at the given string and\n * return its length. Matches shorter or equal to prev_length are discarded,\n * in which case the result is equal to prev_length and match_start is\n * garbage.\n * IN assertions: cur_match is the head of the hash chain for the current\n *   string (strstart) and its distance is <= MAX_DIST, and prev_length >= 1\n * OUT assertion: the match length is not greater than s->lookahead.\n */\n#ifndef ASMV\n/* For 80x86 and 680x0, an optimized version will be provided in match.asm or\n * match.S. The code will be functionally equivalent.\n */\nlocal uInt longest_match(s, cur_match)\n    deflate_state *s;\n    IPos cur_match;                             /* current match */\n{\n    unsigned chain_length = s->max_chain_length;/* max hash chain length */\n    register Bytef *scan = s->window + s->strstart; /* current string */\n    register Bytef *match;                       /* matched string */\n    register int len;                           /* length of current match */\n    int best_len = s->prev_length;              /* best match length so far */\n    int nice_match = s->nice_match;             /* stop if match long enough */\n    IPos limit = s->strstart > (IPos)MAX_DIST(s) ?\n        s->strstart - (IPos)MAX_DIST(s) : NIL;\n    /* Stop when cur_match becomes <= limit. To simplify the code,\n     * we prevent matches with the string of window index 0.\n     */\n    Posf *prev = s->prev;\n    uInt wmask = s->w_mask;\n\n#ifdef UNALIGNED_OK\n    /* Compare two bytes at a time. Note: this is not always beneficial.\n     * Try with and without -DUNALIGNED_OK to check.\n     */\n    register Bytef *strend = s->window + s->strstart + MAX_MATCH - 1;\n    register ush scan_start = *(ushf*)scan;\n    register ush scan_end   = *(ushf*)(scan+best_len-1);\n#else\n    register Bytef *strend = s->window + s->strstart + MAX_MATCH;\n    register Byte scan_end1  = scan[best_len-1];\n    register Byte scan_end   = scan[best_len];\n#endif\n\n    /* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16.\n     * It is easy to get rid of this optimization if necessary.\n     */\n    Assert(s->hash_bits >= 8 && MAX_MATCH == 258, \"Code too clever\");\n\n    /* Do not waste too much time if we already have a good match: */\n    if (s->prev_length >= s->good_match) {\n        chain_length >>= 2;\n    }\n    /* Do not look for matches beyond the end of the input. This is necessary\n     * to make deflate deterministic.\n     */\n    if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead;\n\n    Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, \"need lookahead\");\n\n    do {\n        Assert(cur_match < s->strstart, \"no future\");\n        match = s->window + cur_match;\n\n        /* Skip to next match if the match length cannot increase\n         * or if the match length is less than 2.  Note that the checks below\n         * for insufficient lookahead only occur occasionally for performance\n         * reasons.  Therefore uninitialized memory will be accessed, and\n         * conditional jumps will be made that depend on those values.\n         * However the length of the match is limited to the lookahead, so\n         * the output of deflate is not affected by the uninitialized values.\n         */\n#if (defined(UNALIGNED_OK) && MAX_MATCH == 258)\n        /* This code assumes sizeof(unsigned short) == 2. Do not use\n         * UNALIGNED_OK if your compiler uses a different size.\n         */\n        if (*(ushf*)(match+best_len-1) != scan_end ||\n            *(ushf*)match != scan_start) continue;\n\n        /* It is not necessary to compare scan[2] and match[2] since they are\n         * always equal when the other bytes match, given that the hash keys\n         * are equal and that HASH_BITS >= 8. Compare 2 bytes at a time at\n         * strstart+3, +5, ... up to strstart+257. We check for insufficient\n         * lookahead only every 4th comparison; the 128th check will be made\n         * at strstart+257. If MAX_MATCH-2 is not a multiple of 8, it is\n         * necessary to put more guard bytes at the end of the window, or\n         * to check more often for insufficient lookahead.\n         */\n        Assert(scan[2] == match[2], \"scan[2]?\");\n        scan++, match++;\n        do {\n        } while (*(ushf*)(scan+=2) == *(ushf*)(match+=2) &&\n                 *(ushf*)(scan+=2) == *(ushf*)(match+=2) &&\n                 *(ushf*)(scan+=2) == *(ushf*)(match+=2) &&\n                 *(ushf*)(scan+=2) == *(ushf*)(match+=2) &&\n                 scan < strend);\n        /* The funny \"do {}\" generates better code on most compilers */\n\n        /* Here, scan <= window+strstart+257 */\n        Assert(scan <= s->window+(unsigned)(s->window_size-1), \"wild scan\");\n        if (*scan == *match) scan++;\n\n        len = (MAX_MATCH - 1) - (int)(strend-scan);\n        scan = strend - (MAX_MATCH-1);\n\n#else /* UNALIGNED_OK */\n\n        if (match[best_len]   != scan_end  ||\n            match[best_len-1] != scan_end1 ||\n            *match            != *scan     ||\n            *++match          != scan[1])      continue;\n\n        /* The check at best_len-1 can be removed because it will be made\n         * again later. (This heuristic is not always a win.)\n         * It is not necessary to compare scan[2] and match[2] since they\n         * are always equal when the other bytes match, given that\n         * the hash keys are equal and that HASH_BITS >= 8.\n         */\n        scan += 2, match++;\n        Assert(*scan == *match, \"match[2]?\");\n\n        /* We check for insufficient lookahead only every 8th comparison;\n         * the 256th check will be made at strstart+258.\n         */\n        do {\n        } while (*++scan == *++match && *++scan == *++match &&\n                 *++scan == *++match && *++scan == *++match &&\n                 *++scan == *++match && *++scan == *++match &&\n                 *++scan == *++match && *++scan == *++match &&\n                 scan < strend);\n\n        Assert(scan <= s->window+(unsigned)(s->window_size-1), \"wild scan\");\n\n        len = MAX_MATCH - (int)(strend - scan);\n        scan = strend - MAX_MATCH;\n\n#endif /* UNALIGNED_OK */\n\n        if (len > best_len) {\n            s->match_start = cur_match;\n            best_len = len;\n            if (len >= nice_match) break;\n#ifdef UNALIGNED_OK\n            scan_end = *(ushf*)(scan+best_len-1);\n#else\n            scan_end1  = scan[best_len-1];\n            scan_end   = scan[best_len];\n#endif\n        }\n    } while ((cur_match = prev[cur_match & wmask]) > limit\n             && --chain_length != 0);\n\n    if ((uInt)best_len <= s->lookahead) return (uInt)best_len;\n    return s->lookahead;\n}\n#endif /* ASMV */\n\n#else /* FASTEST */\n\n/* ---------------------------------------------------------------------------\n * Optimized version for FASTEST only\n */\nlocal uInt longest_match(s, cur_match)\n    deflate_state *s;\n    IPos cur_match;                             /* current match */\n{\n    register Bytef *scan = s->window + s->strstart; /* current string */\n    register Bytef *match;                       /* matched string */\n    register int len;                           /* length of current match */\n    register Bytef *strend = s->window + s->strstart + MAX_MATCH;\n\n    /* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16.\n     * It is easy to get rid of this optimization if necessary.\n     */\n    Assert(s->hash_bits >= 8 && MAX_MATCH == 258, \"Code too clever\");\n\n    Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, \"need lookahead\");\n\n    Assert(cur_match < s->strstart, \"no future\");\n\n    match = s->window + cur_match;\n\n    /* Return failure if the match length is less than 2:\n     */\n    if (match[0] != scan[0] || match[1] != scan[1]) return MIN_MATCH-1;\n\n    /* The check at best_len-1 can be removed because it will be made\n     * again later. (This heuristic is not always a win.)\n     * It is not necessary to compare scan[2] and match[2] since they\n     * are always equal when the other bytes match, given that\n     * the hash keys are equal and that HASH_BITS >= 8.\n     */\n    scan += 2, match += 2;\n    Assert(*scan == *match, \"match[2]?\");\n\n    /* We check for insufficient lookahead only every 8th comparison;\n     * the 256th check will be made at strstart+258.\n     */\n    do {\n    } while (*++scan == *++match && *++scan == *++match &&\n             *++scan == *++match && *++scan == *++match &&\n             *++scan == *++match && *++scan == *++match &&\n             *++scan == *++match && *++scan == *++match &&\n             scan < strend);\n\n    Assert(scan <= s->window+(unsigned)(s->window_size-1), \"wild scan\");\n\n    len = MAX_MATCH - (int)(strend - scan);\n\n    if (len < MIN_MATCH) return MIN_MATCH - 1;\n\n    s->match_start = cur_match;\n    return (uInt)len <= s->lookahead ? (uInt)len : s->lookahead;\n}\n\n#endif /* FASTEST */\n\n#ifdef DEBUG\n/* ===========================================================================\n * Check that the match at match_start is indeed a match.\n */\nlocal void check_match(s, start, match, length)\n    deflate_state *s;\n    IPos start, match;\n    int length;\n{\n    /* check that the match is indeed a match */\n    if (zmemcmp(s->window + match,\n                s->window + start, length) != EQUAL) {\n        fprintf(stderr, \" start %u, match %u, length %d\\n\",\n                start, match, length);\n        do {\n            fprintf(stderr, \"%c%c\", s->window[match++], s->window[start++]);\n        } while (--length != 0);\n        z_error(\"invalid match\");\n    }\n    if (z_verbose > 1) {\n        fprintf(stderr,\"\\\\[%d,%d]\", start-match, length);\n        do { putc(s->window[start++], stderr); } while (--length != 0);\n    }\n}\n#else\n#  define check_match(s, start, match, length)\n#endif /* DEBUG */\n\n/* ===========================================================================\n * Fill the window when the lookahead becomes insufficient.\n * Updates strstart and lookahead.\n *\n * IN assertion: lookahead < MIN_LOOKAHEAD\n * OUT assertions: strstart <= window_size-MIN_LOOKAHEAD\n *    At least one byte has been read, or avail_in == 0; reads are\n *    performed for at least two bytes (required for the zip translate_eol\n *    option -- not supported here).\n */\nlocal void fill_window(s)\n    deflate_state *s;\n{\n    register unsigned n, m;\n    register Posf *p;\n    unsigned more;    /* Amount of free space at the end of the window. */\n    uInt wsize = s->w_size;\n\n    Assert(s->lookahead < MIN_LOOKAHEAD, \"already enough lookahead\");\n\n    do {\n        more = (unsigned)(s->window_size -(ulg)s->lookahead -(ulg)s->strstart);\n\n        /* Deal with !@#$% 64K limit: */\n        if (sizeof(int) <= 2) {\n            if (more == 0 && s->strstart == 0 && s->lookahead == 0) {\n                more = wsize;\n\n            } else if (more == (unsigned)(-1)) {\n                /* Very unlikely, but possible on 16 bit machine if\n                 * strstart == 0 && lookahead == 1 (input done a byte at time)\n                 */\n                more--;\n            }\n        }\n\n        /* If the window is almost full and there is insufficient lookahead,\n         * move the upper half to the lower one to make room in the upper half.\n         */\n        if (s->strstart >= wsize+MAX_DIST(s)) {\n\n            zmemcpy(s->window, s->window+wsize, (unsigned)wsize);\n            s->match_start -= wsize;\n            s->strstart    -= wsize; /* we now have strstart >= MAX_DIST */\n            s->block_start -= (long) wsize;\n\n            /* Slide the hash table (could be avoided with 32 bit values\n               at the expense of memory usage). We slide even when level == 0\n               to keep the hash table consistent if we switch back to level > 0\n               later. (Using level 0 permanently is not an optimal usage of\n               zlib, so we don't care about this pathological case.)\n             */\n            n = s->hash_size;\n            p = &s->head[n];\n            do {\n                m = *--p;\n                *p = (Pos)(m >= wsize ? m-wsize : NIL);\n            } while (--n);\n\n            n = wsize;\n#ifndef FASTEST\n            p = &s->prev[n];\n            do {\n                m = *--p;\n                *p = (Pos)(m >= wsize ? m-wsize : NIL);\n                /* If n is not on any hash chain, prev[n] is garbage but\n                 * its value will never be used.\n                 */\n            } while (--n);\n#endif\n            more += wsize;\n        }\n        if (s->strm->avail_in == 0) break;\n\n        /* If there was no sliding:\n         *    strstart <= WSIZE+MAX_DIST-1 && lookahead <= MIN_LOOKAHEAD - 1 &&\n         *    more == window_size - lookahead - strstart\n         * => more >= window_size - (MIN_LOOKAHEAD-1 + WSIZE + MAX_DIST-1)\n         * => more >= window_size - 2*WSIZE + 2\n         * In the BIG_MEM or MMAP case (not yet supported),\n         *   window_size == input_size + MIN_LOOKAHEAD  &&\n         *   strstart + s->lookahead <= input_size => more >= MIN_LOOKAHEAD.\n         * Otherwise, window_size == 2*WSIZE so more >= 2.\n         * If there was sliding, more >= WSIZE. So in all cases, more >= 2.\n         */\n        Assert(more >= 2, \"more < 2\");\n\n        n = read_buf(s->strm, s->window + s->strstart + s->lookahead, more);\n        s->lookahead += n;\n\n        /* Initialize the hash value now that we have some input: */\n        if (s->lookahead + s->insert >= MIN_MATCH) {\n            uInt str = s->strstart - s->insert;\n            s->ins_h = s->window[str];\n            UPDATE_HASH(s, s->ins_h, s->window[str + 1]);\n#if MIN_MATCH != 3\n            Call UPDATE_HASH() MIN_MATCH-3 more times\n#endif\n            while (s->insert) {\n                UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]);\n#ifndef FASTEST\n                s->prev[str & s->w_mask] = s->head[s->ins_h];\n#endif\n                s->head[s->ins_h] = (Pos)str;\n                str++;\n                s->insert--;\n                if (s->lookahead + s->insert < MIN_MATCH)\n                    break;\n            }\n        }\n        /* If the whole input has less than MIN_MATCH bytes, ins_h is garbage,\n         * but this is not important since only literal bytes will be emitted.\n         */\n\n    } while (s->lookahead < MIN_LOOKAHEAD && s->strm->avail_in != 0);\n\n    /* If the WIN_INIT bytes after the end of the current data have never been\n     * written, then zero those bytes in order to avoid memory check reports of\n     * the use of uninitialized (or uninitialised as Julian writes) bytes by\n     * the longest match routines.  Update the high water mark for the next\n     * time through here.  WIN_INIT is set to MAX_MATCH since the longest match\n     * routines allow scanning to strstart + MAX_MATCH, ignoring lookahead.\n     */\n    if (s->high_water < s->window_size) {\n        ulg curr = s->strstart + (ulg)(s->lookahead);\n        ulg init;\n\n        if (s->high_water < curr) {\n            /* Previous high water mark below current data -- zero WIN_INIT\n             * bytes or up to end of window, whichever is less.\n             */\n            init = s->window_size - curr;\n            if (init > WIN_INIT)\n                init = WIN_INIT;\n            zmemzero(s->window + curr, (unsigned)init);\n            s->high_water = curr + init;\n        }\n        else if (s->high_water < (ulg)curr + WIN_INIT) {\n            /* High water mark at or above current data, but below current data\n             * plus WIN_INIT -- zero out to current data plus WIN_INIT, or up\n             * to end of window, whichever is less.\n             */\n            init = (ulg)curr + WIN_INIT - s->high_water;\n            if (init > s->window_size - s->high_water)\n                init = s->window_size - s->high_water;\n            zmemzero(s->window + s->high_water, (unsigned)init);\n            s->high_water += init;\n        }\n    }\n\n    Assert((ulg)s->strstart <= s->window_size - MIN_LOOKAHEAD,\n           \"not enough room for search\");\n}\n\n/* ===========================================================================\n * Flush the current block, with given end-of-file flag.\n * IN assertion: strstart is set to the end of the current match.\n */\n#define FLUSH_BLOCK_ONLY(s, last) { \\\n   _tr_flush_block(s, (s->block_start >= 0L ? \\\n                   (charf *)&s->window[(unsigned)s->block_start] : \\\n                   (charf *)Z_NULL), \\\n                (ulg)((long)s->strstart - s->block_start), \\\n                (last)); \\\n   s->block_start = s->strstart; \\\n   flush_pending(s->strm); \\\n   Tracev((stderr,\"[FLUSH]\")); \\\n}\n\n/* Same but force premature exit if necessary. */\n#define FLUSH_BLOCK(s, last) { \\\n   FLUSH_BLOCK_ONLY(s, last); \\\n   if (s->strm->avail_out == 0) return (last) ? finish_started : need_more; \\\n}\n\n/* ===========================================================================\n * Copy without compression as much as possible from the input stream, return\n * the current block state.\n * This function does not insert new strings in the dictionary since\n * uncompressible data is probably not useful. This function is used\n * only for the level=0 compression option.\n * NOTE: this function should be optimized to avoid extra copying from\n * window to pending_buf.\n */\nlocal block_state deflate_stored(s, flush)\n    deflate_state *s;\n    int flush;\n{\n    /* Stored blocks are limited to 0xffff bytes, pending_buf is limited\n     * to pending_buf_size, and each stored block has a 5 byte header:\n     */\n    ulg max_block_size = 0xffff;\n    ulg max_start;\n\n    if (max_block_size > s->pending_buf_size - 5) {\n        max_block_size = s->pending_buf_size - 5;\n    }\n\n    /* Copy as much as possible from input to output: */\n    for (;;) {\n        /* Fill the window as much as possible: */\n        if (s->lookahead <= 1) {\n\n            Assert(s->strstart < s->w_size+MAX_DIST(s) ||\n                   s->block_start >= (long)s->w_size, \"slide too late\");\n\n            fill_window(s);\n            if (s->lookahead == 0 && flush == Z_NO_FLUSH) return need_more;\n\n            if (s->lookahead == 0) break; /* flush the current block */\n        }\n        Assert(s->block_start >= 0L, \"block gone\");\n\n        s->strstart += s->lookahead;\n        s->lookahead = 0;\n\n        /* Emit a stored block if pending_buf will be full: */\n        max_start = s->block_start + max_block_size;\n        if (s->strstart == 0 || (ulg)s->strstart >= max_start) {\n            /* strstart == 0 is possible when wraparound on 16-bit machine */\n            s->lookahead = (uInt)(s->strstart - max_start);\n            s->strstart = (uInt)max_start;\n            FLUSH_BLOCK(s, 0);\n        }\n        /* Flush if we may have to slide, otherwise block_start may become\n         * negative and the data will be gone:\n         */\n        if (s->strstart - (uInt)s->block_start >= MAX_DIST(s)) {\n            FLUSH_BLOCK(s, 0);\n        }\n    }\n    s->insert = 0;\n    if (flush == Z_FINISH) {\n        FLUSH_BLOCK(s, 1);\n        return finish_done;\n    }\n    if ((long)s->strstart > s->block_start)\n        FLUSH_BLOCK(s, 0);\n    return block_done;\n}\n\n/* ===========================================================================\n * Compress as much as possible from the input stream, return the current\n * block state.\n * This function does not perform lazy evaluation of matches and inserts\n * new strings in the dictionary only for unmatched strings or for short\n * matches. It is used only for the fast compression options.\n */\nlocal block_state deflate_fast(s, flush)\n    deflate_state *s;\n    int flush;\n{\n    IPos hash_head;       /* head of the hash chain */\n    int bflush;           /* set if current block must be flushed */\n\n    for (;;) {\n        /* Make sure that we always have enough lookahead, except\n         * at the end of the input file. We need MAX_MATCH bytes\n         * for the next match, plus MIN_MATCH bytes to insert the\n         * string following the next match.\n         */\n        if (s->lookahead < MIN_LOOKAHEAD) {\n            fill_window(s);\n            if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) {\n                return need_more;\n            }\n            if (s->lookahead == 0) break; /* flush the current block */\n        }\n\n        /* Insert the string window[strstart .. strstart+2] in the\n         * dictionary, and set hash_head to the head of the hash chain:\n         */\n        hash_head = NIL;\n        if (s->lookahead >= MIN_MATCH) {\n            INSERT_STRING(s, s->strstart, hash_head);\n        }\n\n        /* Find the longest match, discarding those <= prev_length.\n         * At this point we have always match_length < MIN_MATCH\n         */\n        if (hash_head != NIL && s->strstart - hash_head <= MAX_DIST(s)) {\n            /* To simplify the code, we prevent matches with the string\n             * of window index 0 (in particular we have to avoid a match\n             * of the string with itself at the start of the input file).\n             */\n            s->match_length = longest_match (s, hash_head);\n            /* longest_match() sets match_start */\n        }\n        if (s->match_length >= MIN_MATCH) {\n            check_match(s, s->strstart, s->match_start, s->match_length);\n\n            _tr_tally_dist(s, s->strstart - s->match_start,\n                           s->match_length - MIN_MATCH, bflush);\n\n            s->lookahead -= s->match_length;\n\n            /* Insert new strings in the hash table only if the match length\n             * is not too large. This saves time but degrades compression.\n             */\n#ifndef FASTEST\n            if (s->match_length <= s->max_insert_length &&\n                s->lookahead >= MIN_MATCH) {\n                s->match_length--; /* string at strstart already in table */\n                do {\n                    s->strstart++;\n                    INSERT_STRING(s, s->strstart, hash_head);\n                    /* strstart never exceeds WSIZE-MAX_MATCH, so there are\n                     * always MIN_MATCH bytes ahead.\n                     */\n                } while (--s->match_length != 0);\n                s->strstart++;\n            } else\n#endif\n            {\n                s->strstart += s->match_length;\n                s->match_length = 0;\n                s->ins_h = s->window[s->strstart];\n                UPDATE_HASH(s, s->ins_h, s->window[s->strstart+1]);\n#if MIN_MATCH != 3\n                Call UPDATE_HASH() MIN_MATCH-3 more times\n#endif\n                /* If lookahead < MIN_MATCH, ins_h is garbage, but it does not\n                 * matter since it will be recomputed at next deflate call.\n                 */\n            }\n        } else {\n            /* No match, output a literal byte */\n            Tracevv((stderr,\"%c\", s->window[s->strstart]));\n            _tr_tally_lit (s, s->window[s->strstart], bflush);\n            s->lookahead--;\n            s->strstart++;\n        }\n        if (bflush) FLUSH_BLOCK(s, 0);\n    }\n    s->insert = s->strstart < MIN_MATCH-1 ? s->strstart : MIN_MATCH-1;\n    if (flush == Z_FINISH) {\n        FLUSH_BLOCK(s, 1);\n        return finish_done;\n    }\n    if (s->last_lit)\n        FLUSH_BLOCK(s, 0);\n    return block_done;\n}\n\n#ifndef FASTEST\n/* ===========================================================================\n * Same as above, but achieves better compression. We use a lazy\n * evaluation for matches: a match is finally adopted only if there is\n * no better match at the next window position.\n */\nlocal block_state deflate_slow(s, flush)\n    deflate_state *s;\n    int flush;\n{\n    IPos hash_head;          /* head of hash chain */\n    int bflush;              /* set if current block must be flushed */\n\n    /* Process the input block. */\n    for (;;) {\n        /* Make sure that we always have enough lookahead, except\n         * at the end of the input file. We need MAX_MATCH bytes\n         * for the next match, plus MIN_MATCH bytes to insert the\n         * string following the next match.\n         */\n        if (s->lookahead < MIN_LOOKAHEAD) {\n            fill_window(s);\n            if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) {\n                return need_more;\n            }\n            if (s->lookahead == 0) break; /* flush the current block */\n        }\n\n        /* Insert the string window[strstart .. strstart+2] in the\n         * dictionary, and set hash_head to the head of the hash chain:\n         */\n        hash_head = NIL;\n        if (s->lookahead >= MIN_MATCH) {\n            INSERT_STRING(s, s->strstart, hash_head);\n        }\n\n        /* Find the longest match, discarding those <= prev_length.\n         */\n        s->prev_length = s->match_length, s->prev_match = s->match_start;\n        s->match_length = MIN_MATCH-1;\n\n        if (hash_head != NIL && s->prev_length < s->max_lazy_match &&\n            s->strstart - hash_head <= MAX_DIST(s)) {\n            /* To simplify the code, we prevent matches with the string\n             * of window index 0 (in particular we have to avoid a match\n             * of the string with itself at the start of the input file).\n             */\n            s->match_length = longest_match (s, hash_head);\n            /* longest_match() sets match_start */\n\n            if (s->match_length <= 5 && (s->strategy == Z_FILTERED\n#if TOO_FAR <= 32767\n                || (s->match_length == MIN_MATCH &&\n                    s->strstart - s->match_start > TOO_FAR)\n#endif\n                )) {\n\n                /* If prev_match is also MIN_MATCH, match_start is garbage\n                 * but we will ignore the current match anyway.\n                 */\n                s->match_length = MIN_MATCH-1;\n            }\n        }\n        /* If there was a match at the previous step and the current\n         * match is not better, output the previous match:\n         */\n        if (s->prev_length >= MIN_MATCH && s->match_length <= s->prev_length) {\n            uInt max_insert = s->strstart + s->lookahead - MIN_MATCH;\n            /* Do not insert strings in hash table beyond this. */\n\n            check_match(s, s->strstart-1, s->prev_match, s->prev_length);\n\n            _tr_tally_dist(s, s->strstart -1 - s->prev_match,\n                           s->prev_length - MIN_MATCH, bflush);\n\n            /* Insert in hash table all strings up to the end of the match.\n             * strstart-1 and strstart are already inserted. If there is not\n             * enough lookahead, the last two strings are not inserted in\n             * the hash table.\n             */\n            s->lookahead -= s->prev_length-1;\n            s->prev_length -= 2;\n            do {\n                if (++s->strstart <= max_insert) {\n                    INSERT_STRING(s, s->strstart, hash_head);\n                }\n            } while (--s->prev_length != 0);\n            s->match_available = 0;\n            s->match_length = MIN_MATCH-1;\n            s->strstart++;\n\n            if (bflush) FLUSH_BLOCK(s, 0);\n\n        } else if (s->match_available) {\n            /* If there was no match at the previous position, output a\n             * single literal. If there was a match but the current match\n             * is longer, truncate the previous match to a single literal.\n             */\n            Tracevv((stderr,\"%c\", s->window[s->strstart-1]));\n            _tr_tally_lit(s, s->window[s->strstart-1], bflush);\n            if (bflush) {\n                FLUSH_BLOCK_ONLY(s, 0);\n            }\n            s->strstart++;\n            s->lookahead--;\n            if (s->strm->avail_out == 0) return need_more;\n        } else {\n            /* There is no previous match to compare with, wait for\n             * the next step to decide.\n             */\n            s->match_available = 1;\n            s->strstart++;\n            s->lookahead--;\n        }\n    }\n    Assert (flush != Z_NO_FLUSH, \"no flush?\");\n    if (s->match_available) {\n        Tracevv((stderr,\"%c\", s->window[s->strstart-1]));\n        _tr_tally_lit(s, s->window[s->strstart-1], bflush);\n        s->match_available = 0;\n    }\n    s->insert = s->strstart < MIN_MATCH-1 ? s->strstart : MIN_MATCH-1;\n    if (flush == Z_FINISH) {\n        FLUSH_BLOCK(s, 1);\n        return finish_done;\n    }\n    if (s->last_lit)\n        FLUSH_BLOCK(s, 0);\n    return block_done;\n}\n#endif /* FASTEST */\n\n/* ===========================================================================\n * For Z_RLE, simply look for runs of bytes, generate matches only of distance\n * one.  Do not maintain a hash table.  (It will be regenerated if this run of\n * deflate switches away from Z_RLE.)\n */\nlocal block_state deflate_rle(s, flush)\n    deflate_state *s;\n    int flush;\n{\n    int bflush;             /* set if current block must be flushed */\n    uInt prev;              /* byte at distance one to match */\n    Bytef *scan, *strend;   /* scan goes up to strend for length of run */\n\n    for (;;) {\n        /* Make sure that we always have enough lookahead, except\n         * at the end of the input file. We need MAX_MATCH bytes\n         * for the longest run, plus one for the unrolled loop.\n         */\n        if (s->lookahead <= MAX_MATCH) {\n            fill_window(s);\n            if (s->lookahead <= MAX_MATCH && flush == Z_NO_FLUSH) {\n                return need_more;\n            }\n            if (s->lookahead == 0) break; /* flush the current block */\n        }\n\n        /* See how many times the previous byte repeats */\n        s->match_length = 0;\n        if (s->lookahead >= MIN_MATCH && s->strstart > 0) {\n            scan = s->window + s->strstart - 1;\n            prev = *scan;\n            if (prev == *++scan && prev == *++scan && prev == *++scan) {\n                strend = s->window + s->strstart + MAX_MATCH;\n                do {\n                } while (prev == *++scan && prev == *++scan &&\n                         prev == *++scan && prev == *++scan &&\n                         prev == *++scan && prev == *++scan &&\n                         prev == *++scan && prev == *++scan &&\n                         scan < strend);\n                s->match_length = MAX_MATCH - (int)(strend - scan);\n                if (s->match_length > s->lookahead)\n                    s->match_length = s->lookahead;\n            }\n            Assert(scan <= s->window+(uInt)(s->window_size-1), \"wild scan\");\n        }\n\n        /* Emit match if have run of MIN_MATCH or longer, else emit literal */\n        if (s->match_length >= MIN_MATCH) {\n            check_match(s, s->strstart, s->strstart - 1, s->match_length);\n\n            _tr_tally_dist(s, 1, s->match_length - MIN_MATCH, bflush);\n\n            s->lookahead -= s->match_length;\n            s->strstart += s->match_length;\n            s->match_length = 0;\n        } else {\n            /* No match, output a literal byte */\n            Tracevv((stderr,\"%c\", s->window[s->strstart]));\n            _tr_tally_lit (s, s->window[s->strstart], bflush);\n            s->lookahead--;\n            s->strstart++;\n        }\n        if (bflush) FLUSH_BLOCK(s, 0);\n    }\n    s->insert = 0;\n    if (flush == Z_FINISH) {\n        FLUSH_BLOCK(s, 1);\n        return finish_done;\n    }\n    if (s->last_lit)\n        FLUSH_BLOCK(s, 0);\n    return block_done;\n}\n\n/* ===========================================================================\n * For Z_HUFFMAN_ONLY, do not look for matches.  Do not maintain a hash table.\n * (It will be regenerated if this run of deflate switches away from Huffman.)\n */\nlocal block_state deflate_huff(s, flush)\n    deflate_state *s;\n    int flush;\n{\n    int bflush;             /* set if current block must be flushed */\n\n    for (;;) {\n        /* Make sure that we have a literal to write. */\n        if (s->lookahead == 0) {\n            fill_window(s);\n            if (s->lookahead == 0) {\n                if (flush == Z_NO_FLUSH)\n                    return need_more;\n                break;      /* flush the current block */\n            }\n        }\n\n        /* Output a literal byte */\n        s->match_length = 0;\n        Tracevv((stderr,\"%c\", s->window[s->strstart]));\n        _tr_tally_lit (s, s->window[s->strstart], bflush);\n        s->lookahead--;\n        s->strstart++;\n        if (bflush) FLUSH_BLOCK(s, 0);\n    }\n    s->insert = 0;\n    if (flush == Z_FINISH) {\n        FLUSH_BLOCK(s, 1);\n        return finish_done;\n    }\n    if (s->last_lit)\n        FLUSH_BLOCK(s, 0);\n    return block_done;\n}\n"
  },
  {
    "path": "Projects/Tools/PNGAlphaPremultiplier/Native/Source/ZLib/deflate.h",
    "content": "/* deflate.h -- internal compression state\n * Copyright (C) 1995-2012 Jean-loup Gailly\n * For conditions of distribution and use, see copyright notice in zlib.h\n */\n\n/* WARNING: this file should *not* be used by applications. It is\n   part of the implementation of the compression library and is\n   subject to change. Applications should only use zlib.h.\n */\n\n/* @(#) $Id$ */\n\n#ifndef DEFLATE_H\n#define DEFLATE_H\n\n#include \"zutil.h\"\n\n/* define NO_GZIP when compiling if you want to disable gzip header and\n   trailer creation by deflate().  NO_GZIP would be used to avoid linking in\n   the crc code when it is not needed.  For shared libraries, gzip encoding\n   should be left enabled. */\n#ifndef NO_GZIP\n#  define GZIP\n#endif\n\n/* ===========================================================================\n * Internal compression state.\n */\n\n#define LENGTH_CODES 29\n/* number of length codes, not counting the special END_BLOCK code */\n\n#define LITERALS  256\n/* number of literal bytes 0..255 */\n\n#define L_CODES (LITERALS+1+LENGTH_CODES)\n/* number of Literal or Length codes, including the END_BLOCK code */\n\n#define D_CODES   30\n/* number of distance codes */\n\n#define BL_CODES  19\n/* number of codes used to transfer the bit lengths */\n\n#define HEAP_SIZE (2*L_CODES+1)\n/* maximum heap size */\n\n#define MAX_BITS 15\n/* All codes must not exceed MAX_BITS bits */\n\n#define Buf_size 16\n/* size of bit buffer in bi_buf */\n\n#define INIT_STATE    42\n#define EXTRA_STATE   69\n#define NAME_STATE    73\n#define COMMENT_STATE 91\n#define HCRC_STATE   103\n#define BUSY_STATE   113\n#define FINISH_STATE 666\n/* Stream status */\n\n\n/* Data structure describing a single value and its code string. */\ntypedef struct ct_data_s {\n    union {\n        ush  freq;       /* frequency count */\n        ush  code;       /* bit string */\n    } fc;\n    union {\n        ush  dad;        /* father node in Huffman tree */\n        ush  len;        /* length of bit string */\n    } dl;\n} FAR ct_data;\n\n#define Freq fc.freq\n#define Code fc.code\n#define Dad  dl.dad\n#define Len  dl.len\n\ntypedef struct static_tree_desc_s  static_tree_desc;\n\ntypedef struct tree_desc_s {\n    ct_data *dyn_tree;           /* the dynamic tree */\n    int     max_code;            /* largest code with non zero frequency */\n    static_tree_desc *stat_desc; /* the corresponding static tree */\n} FAR tree_desc;\n\ntypedef ush Pos;\ntypedef Pos FAR Posf;\ntypedef unsigned IPos;\n\n/* A Pos is an index in the character window. We use short instead of int to\n * save space in the various tables. IPos is used only for parameter passing.\n */\n\ntypedef struct internal_state {\n    z_streamp strm;      /* pointer back to this zlib stream */\n    int   status;        /* as the name implies */\n    Bytef *pending_buf;  /* output still pending */\n    ulg   pending_buf_size; /* size of pending_buf */\n    Bytef *pending_out;  /* next pending byte to output to the stream */\n    uInt   pending;      /* nb of bytes in the pending buffer */\n    int   wrap;          /* bit 0 true for zlib, bit 1 true for gzip */\n    gz_headerp  gzhead;  /* gzip header information to write */\n    uInt   gzindex;      /* where in extra, name, or comment */\n    Byte  method;        /* STORED (for zip only) or DEFLATED */\n    int   last_flush;    /* value of flush param for previous deflate call */\n\n                /* used by deflate.c: */\n\n    uInt  w_size;        /* LZ77 window size (32K by default) */\n    uInt  w_bits;        /* log2(w_size)  (8..16) */\n    uInt  w_mask;        /* w_size - 1 */\n\n    Bytef *window;\n    /* Sliding window. Input bytes are read into the second half of the window,\n     * and move to the first half later to keep a dictionary of at least wSize\n     * bytes. With this organization, matches are limited to a distance of\n     * wSize-MAX_MATCH bytes, but this ensures that IO is always\n     * performed with a length multiple of the block size. Also, it limits\n     * the window size to 64K, which is quite useful on MSDOS.\n     * To do: use the user input buffer as sliding window.\n     */\n\n    ulg window_size;\n    /* Actual size of window: 2*wSize, except when the user input buffer\n     * is directly used as sliding window.\n     */\n\n    Posf *prev;\n    /* Link to older string with same hash index. To limit the size of this\n     * array to 64K, this link is maintained only for the last 32K strings.\n     * An index in this array is thus a window index modulo 32K.\n     */\n\n    Posf *head; /* Heads of the hash chains or NIL. */\n\n    uInt  ins_h;          /* hash index of string to be inserted */\n    uInt  hash_size;      /* number of elements in hash table */\n    uInt  hash_bits;      /* log2(hash_size) */\n    uInt  hash_mask;      /* hash_size-1 */\n\n    uInt  hash_shift;\n    /* Number of bits by which ins_h must be shifted at each input\n     * step. It must be such that after MIN_MATCH steps, the oldest\n     * byte no longer takes part in the hash key, that is:\n     *   hash_shift * MIN_MATCH >= hash_bits\n     */\n\n    long block_start;\n    /* Window position at the beginning of the current output block. Gets\n     * negative when the window is moved backwards.\n     */\n\n    uInt match_length;           /* length of best match */\n    IPos prev_match;             /* previous match */\n    int match_available;         /* set if previous match exists */\n    uInt strstart;               /* start of string to insert */\n    uInt match_start;            /* start of matching string */\n    uInt lookahead;              /* number of valid bytes ahead in window */\n\n    uInt prev_length;\n    /* Length of the best match at previous step. Matches not greater than this\n     * are discarded. This is used in the lazy match evaluation.\n     */\n\n    uInt max_chain_length;\n    /* To speed up deflation, hash chains are never searched beyond this\n     * length.  A higher limit improves compression ratio but degrades the\n     * speed.\n     */\n\n    uInt max_lazy_match;\n    /* Attempt to find a better match only when the current match is strictly\n     * smaller than this value. This mechanism is used only for compression\n     * levels >= 4.\n     */\n#   define max_insert_length  max_lazy_match\n    /* Insert new strings in the hash table only if the match length is not\n     * greater than this length. This saves time but degrades compression.\n     * max_insert_length is used only for compression levels <= 3.\n     */\n\n    int level;    /* compression level (1..9) */\n    int strategy; /* favor or force Huffman coding*/\n\n    uInt good_match;\n    /* Use a faster search when the previous match is longer than this */\n\n    int nice_match; /* Stop searching when current match exceeds this */\n\n                /* used by trees.c: */\n    /* Didn't use ct_data typedef below to suppress compiler warning */\n    struct ct_data_s dyn_ltree[HEAP_SIZE];   /* literal and length tree */\n    struct ct_data_s dyn_dtree[2*D_CODES+1]; /* distance tree */\n    struct ct_data_s bl_tree[2*BL_CODES+1];  /* Huffman tree for bit lengths */\n\n    struct tree_desc_s l_desc;               /* desc. for literal tree */\n    struct tree_desc_s d_desc;               /* desc. for distance tree */\n    struct tree_desc_s bl_desc;              /* desc. for bit length tree */\n\n    ush bl_count[MAX_BITS+1];\n    /* number of codes at each bit length for an optimal tree */\n\n    int heap[2*L_CODES+1];      /* heap used to build the Huffman trees */\n    int heap_len;               /* number of elements in the heap */\n    int heap_max;               /* element of largest frequency */\n    /* The sons of heap[n] are heap[2*n] and heap[2*n+1]. heap[0] is not used.\n     * The same heap array is used to build all trees.\n     */\n\n    uch depth[2*L_CODES+1];\n    /* Depth of each subtree used as tie breaker for trees of equal frequency\n     */\n\n    uchf *l_buf;          /* buffer for literals or lengths */\n\n    uInt  lit_bufsize;\n    /* Size of match buffer for literals/lengths.  There are 4 reasons for\n     * limiting lit_bufsize to 64K:\n     *   - frequencies can be kept in 16 bit counters\n     *   - if compression is not successful for the first block, all input\n     *     data is still in the window so we can still emit a stored block even\n     *     when input comes from standard input.  (This can also be done for\n     *     all blocks if lit_bufsize is not greater than 32K.)\n     *   - if compression is not successful for a file smaller than 64K, we can\n     *     even emit a stored file instead of a stored block (saving 5 bytes).\n     *     This is applicable only for zip (not gzip or zlib).\n     *   - creating new Huffman trees less frequently may not provide fast\n     *     adaptation to changes in the input data statistics. (Take for\n     *     example a binary file with poorly compressible code followed by\n     *     a highly compressible string table.) Smaller buffer sizes give\n     *     fast adaptation but have of course the overhead of transmitting\n     *     trees more frequently.\n     *   - I can't count above 4\n     */\n\n    uInt last_lit;      /* running index in l_buf */\n\n    ushf *d_buf;\n    /* Buffer for distances. To simplify the code, d_buf and l_buf have\n     * the same number of elements. To use different lengths, an extra flag\n     * array would be necessary.\n     */\n\n    ulg opt_len;        /* bit length of current block with optimal trees */\n    ulg static_len;     /* bit length of current block with static trees */\n    uInt matches;       /* number of string matches in current block */\n    uInt insert;        /* bytes at end of window left to insert */\n\n#ifdef DEBUG\n    ulg compressed_len; /* total bit length of compressed file mod 2^32 */\n    ulg bits_sent;      /* bit length of compressed data sent mod 2^32 */\n#endif\n\n    ush bi_buf;\n    /* Output buffer. bits are inserted starting at the bottom (least\n     * significant bits).\n     */\n    int bi_valid;\n    /* Number of valid bits in bi_buf.  All bits above the last valid bit\n     * are always zero.\n     */\n\n    ulg high_water;\n    /* High water mark offset in window for initialized bytes -- bytes above\n     * this are set to zero in order to avoid memory check warnings when\n     * longest match routines access bytes past the input.  This is then\n     * updated to the new high water mark.\n     */\n\n} FAR deflate_state;\n\n/* Output a byte on the stream.\n * IN assertion: there is enough room in pending_buf.\n */\n#define put_byte(s, c) {s->pending_buf[s->pending++] = (c);}\n\n\n#define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1)\n/* Minimum amount of lookahead, except at the end of the input file.\n * See deflate.c for comments about the MIN_MATCH+1.\n */\n\n#define MAX_DIST(s)  ((s)->w_size-MIN_LOOKAHEAD)\n/* In order to simplify the code, particularly on 16 bit machines, match\n * distances are limited to MAX_DIST instead of WSIZE.\n */\n\n#define WIN_INIT MAX_MATCH\n/* Number of bytes after end of data in window to initialize in order to avoid\n   memory checker errors from longest match routines */\n\n        /* in trees.c */\nvoid ZLIB_INTERNAL _tr_init OF((deflate_state *s));\nint ZLIB_INTERNAL _tr_tally OF((deflate_state *s, unsigned dist, unsigned lc));\nvoid ZLIB_INTERNAL _tr_flush_block OF((deflate_state *s, charf *buf,\n                        ulg stored_len, int last));\nvoid ZLIB_INTERNAL _tr_flush_bits OF((deflate_state *s));\nvoid ZLIB_INTERNAL _tr_align OF((deflate_state *s));\nvoid ZLIB_INTERNAL _tr_stored_block OF((deflate_state *s, charf *buf,\n                        ulg stored_len, int last));\n\n#define d_code(dist) \\\n   ((dist) < 256 ? _dist_code[dist] : _dist_code[256+((dist)>>7)])\n/* Mapping from a distance to a distance code. dist is the distance - 1 and\n * must not have side effects. _dist_code[256] and _dist_code[257] are never\n * used.\n */\n\n#ifndef DEBUG\n/* Inline versions of _tr_tally for speed: */\n\n#if defined(GEN_TREES_H) || !defined(STDC)\n  extern uch ZLIB_INTERNAL _length_code[];\n  extern uch ZLIB_INTERNAL _dist_code[];\n#else\n  extern const uch ZLIB_INTERNAL _length_code[];\n  extern const uch ZLIB_INTERNAL _dist_code[];\n#endif\n\n# define _tr_tally_lit(s, c, flush) \\\n  { uch cc = (c); \\\n    s->d_buf[s->last_lit] = 0; \\\n    s->l_buf[s->last_lit++] = cc; \\\n    s->dyn_ltree[cc].Freq++; \\\n    flush = (s->last_lit == s->lit_bufsize-1); \\\n   }\n# define _tr_tally_dist(s, distance, length, flush) \\\n  { uch len = (length); \\\n    ush dist = (distance); \\\n    s->d_buf[s->last_lit] = dist; \\\n    s->l_buf[s->last_lit++] = len; \\\n    dist--; \\\n    s->dyn_ltree[_length_code[len]+LITERALS+1].Freq++; \\\n    s->dyn_dtree[d_code(dist)].Freq++; \\\n    flush = (s->last_lit == s->lit_bufsize-1); \\\n  }\n#else\n# define _tr_tally_lit(s, c, flush) flush = _tr_tally(s, 0, c)\n# define _tr_tally_dist(s, distance, length, flush) \\\n              flush = _tr_tally(s, distance, length)\n#endif\n\n#endif /* DEFLATE_H */\n"
  },
  {
    "path": "Projects/Tools/PNGAlphaPremultiplier/Native/Source/ZLib/gzclose.c",
    "content": "/* gzclose.c -- zlib gzclose() function\n * Copyright (C) 2004, 2010 Mark Adler\n * For conditions of distribution and use, see copyright notice in zlib.h\n */\n\n#include \"gzguts.h\"\n\n/* gzclose() is in a separate file so that it is linked in only if it is used.\n   That way the other gzclose functions can be used instead to avoid linking in\n   unneeded compression or decompression routines. */\nint ZEXPORT gzclose(file)\n    gzFile file;\n{\n#ifndef NO_GZCOMPRESS\n    gz_statep state;\n\n    if (file == NULL)\n        return Z_STREAM_ERROR;\n    state = (gz_statep)file;\n\n    return state->mode == GZ_READ ? gzclose_r(file) : gzclose_w(file);\n#else\n    return gzclose_r(file);\n#endif\n}\n"
  },
  {
    "path": "Projects/Tools/PNGAlphaPremultiplier/Native/Source/ZLib/gzguts.h",
    "content": "/* gzguts.h -- zlib internal header definitions for gz* operations\n * Copyright (C) 2004, 2005, 2010, 2011, 2012 Mark Adler\n * For conditions of distribution and use, see copyright notice in zlib.h\n */\n\n#ifdef _LARGEFILE64_SOURCE\n#  ifndef _LARGEFILE_SOURCE\n#    define _LARGEFILE_SOURCE 1\n#  endif\n#  ifdef _FILE_OFFSET_BITS\n#    undef _FILE_OFFSET_BITS\n#  endif\n#endif\n\n#if ((__GNUC__-0) * 10 + __GNUC_MINOR__-0 >= 33) && !defined(NO_VIZ)\n#  define ZLIB_INTERNAL __attribute__((visibility (\"hidden\")))\n#else\n#  define ZLIB_INTERNAL\n#endif\n\n#include <stdio.h>\n#include \"zlib.h\"\n#ifdef STDC\n#  include <string.h>\n#  include <stdlib.h>\n#  include <limits.h>\n#endif\n#include <fcntl.h>\n\n#ifdef __TURBOC__\n#  include <io.h>\n#endif\n\n#ifdef NO_DEFLATE       /* for compatibility with old definition */\n#  define NO_GZCOMPRESS\n#endif\n\n#if defined(STDC99) || (defined(__TURBOC__) && __TURBOC__ >= 0x550)\n#  ifndef HAVE_VSNPRINTF\n#    define HAVE_VSNPRINTF\n#  endif\n#endif\n\n#if defined(__CYGWIN__)\n#  ifndef HAVE_VSNPRINTF\n#    define HAVE_VSNPRINTF\n#  endif\n#endif\n\n#if defined(MSDOS) && defined(__BORLANDC__) && (BORLANDC > 0x410)\n#  ifndef HAVE_VSNPRINTF\n#    define HAVE_VSNPRINTF\n#  endif\n#endif\n\n#ifndef HAVE_VSNPRINTF\n#  ifdef MSDOS\n/* vsnprintf may exist on some MS-DOS compilers (DJGPP?),\n but for now we just assume it doesn't. */\n#    define NO_vsnprintf\n#  endif\n#  ifdef __TURBOC__\n#    define NO_vsnprintf\n#  endif\n#  ifdef WIN32\n/* In Win32, vsnprintf is available as the \"non-ANSI\" _vsnprintf. */\n#    if !defined(vsnprintf) && !defined(NO_vsnprintf)\n#      if !defined(_MSC_VER) || ( defined(_MSC_VER) && _MSC_VER < 1500 )\n#         include <io.h>\n#         define vsnprintf _vsnprintf\n#      endif\n#    endif\n#  endif\n#  ifdef __SASC\n#    define NO_vsnprintf\n#  endif\n#  ifdef VMS\n#    define NO_vsnprintf\n#  endif\n#  ifdef __OS400__\n#    define NO_vsnprintf\n#  endif\n#  ifdef __MVS__\n#    define NO_vsnprintf\n#  endif\n#endif\n\n#ifndef local\n#  define local static\n#endif\n/* compile with -Dlocal if your debugger can't find static symbols */\n\n/* gz* functions always use library allocation functions */\n#ifndef STDC\n  extern voidp  malloc OF((uInt size));\n  extern void   free   OF((voidpf ptr));\n#endif\n\n/* get errno and strerror definition */\n#if defined UNDER_CE\n#  include <windows.h>\n#  define zstrerror() gz_strwinerror((DWORD)GetLastError())\n#else\n#  ifdef STDC\n#    include <errno.h>\n#    define zstrerror() strerror(errno)\n#  else\n#    define zstrerror() \"stdio error (consult errno)\"\n#  endif\n#endif\n\n/* provide prototypes for these when building zlib without LFS */\n#if !defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0\n    ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *));\n    ZEXTERN z_off64_t ZEXPORT gzseek64 OF((gzFile, z_off64_t, int));\n    ZEXTERN z_off64_t ZEXPORT gztell64 OF((gzFile));\n    ZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile));\n#endif\n\n/* default memLevel */\n#if MAX_MEM_LEVEL >= 8\n#  define DEF_MEM_LEVEL 8\n#else\n#  define DEF_MEM_LEVEL  MAX_MEM_LEVEL\n#endif\n\n/* default i/o buffer size -- double this for output when reading */\n#define GZBUFSIZE 8192\n\n/* gzip modes, also provide a little integrity check on the passed structure */\n#define GZ_NONE 0\n#define GZ_READ 7247\n#define GZ_WRITE 31153\n#define GZ_APPEND 1     /* mode set to GZ_WRITE after the file is opened */\n\n/* values for gz_state how */\n#define LOOK 0      /* look for a gzip header */\n#define COPY 1      /* copy input directly */\n#define GZIP 2      /* decompress a gzip stream */\n\n/* internal gzip file state data structure */\ntypedef struct {\n        /* exposed contents for gzgetc() macro */\n    struct gzFile_s x;      /* \"x\" for exposed */\n                            /* x.have: number of bytes available at x.next */\n                            /* x.next: next output data to deliver or write */\n                            /* x.pos: current position in uncompressed data */\n        /* used for both reading and writing */\n    int mode;               /* see gzip modes above */\n    int fd;                 /* file descriptor */\n    char *path;             /* path or fd for error messages */\n    unsigned size;          /* buffer size, zero if not allocated yet */\n    unsigned want;          /* requested buffer size, default is GZBUFSIZE */\n    unsigned char *in;      /* input buffer */\n    unsigned char *out;     /* output buffer (double-sized when reading) */\n    int direct;             /* 0 if processing gzip, 1 if transparent */\n        /* just for reading */\n    int how;                /* 0: get header, 1: copy, 2: decompress */\n    z_off64_t start;        /* where the gzip data started, for rewinding */\n    int eof;                /* true if end of input file reached */\n    int past;               /* true if read requested past end */\n        /* just for writing */\n    int level;              /* compression level */\n    int strategy;           /* compression strategy */\n        /* seek request */\n    z_off64_t skip;         /* amount to skip (already rewound if backwards) */\n    int seek;               /* true if seek request pending */\n        /* error information */\n    int err;                /* error code */\n    char *msg;              /* error message */\n        /* zlib inflate or deflate stream */\n    z_stream strm;          /* stream structure in-place (not a pointer) */\n} gz_state;\ntypedef gz_state FAR *gz_statep;\n\n/* shared functions */\nvoid ZLIB_INTERNAL gz_error OF((gz_statep, int, const char *));\n#if defined UNDER_CE\nchar ZLIB_INTERNAL *gz_strwinerror OF((DWORD error));\n#endif\n\n/* GT_OFF(x), where x is an unsigned value, is true if x > maximum z_off64_t\n   value -- needed when comparing unsigned to z_off64_t, which is signed\n   (possible z_off64_t types off_t, off64_t, and long are all signed) */\n#ifdef INT_MAX\n#  define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > INT_MAX)\n#else\nunsigned ZLIB_INTERNAL gz_intmax OF((void));\n#  define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > gz_intmax())\n#endif\n"
  },
  {
    "path": "Projects/Tools/PNGAlphaPremultiplier/Native/Source/ZLib/gzlib.c",
    "content": "/* gzlib.c -- zlib functions common to reading and writing gzip files\n * Copyright (C) 2004, 2010, 2011 Mark Adler\n * For conditions of distribution and use, see copyright notice in zlib.h\n */\n\n#include \"gzguts.h\"\n\n#if defined(_WIN32) && !defined(__BORLANDC__)\n#  define LSEEK _lseeki64\n#else\n#if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0\n#  define LSEEK lseek64\n#else\n#  define LSEEK lseek\n#endif\n#endif\n\n/* Local functions */\nlocal void gz_reset OF((gz_statep));\nlocal gzFile gz_open OF((const char *, int, const char *));\n\n#if defined UNDER_CE\n\n/* Map the Windows error number in ERROR to a locale-dependent error message\n   string and return a pointer to it.  Typically, the values for ERROR come\n   from GetLastError.\n\n   The string pointed to shall not be modified by the application, but may be\n   overwritten by a subsequent call to gz_strwinerror\n\n   The gz_strwinerror function does not change the current setting of\n   GetLastError. */\nchar ZLIB_INTERNAL *gz_strwinerror (error)\n     DWORD error;\n{\n    static char buf[1024];\n\n    wchar_t *msgbuf;\n    DWORD lasterr = GetLastError();\n    DWORD chars = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM\n        | FORMAT_MESSAGE_ALLOCATE_BUFFER,\n        NULL,\n        error,\n        0, /* Default language */\n        (LPVOID)&msgbuf,\n        0,\n        NULL);\n    if (chars != 0) {\n        /* If there is an \\r\\n appended, zap it.  */\n        if (chars >= 2\n            && msgbuf[chars - 2] == '\\r' && msgbuf[chars - 1] == '\\n') {\n            chars -= 2;\n            msgbuf[chars] = 0;\n        }\n\n        if (chars > sizeof (buf) - 1) {\n            chars = sizeof (buf) - 1;\n            msgbuf[chars] = 0;\n        }\n\n        wcstombs(buf, msgbuf, chars + 1);\n        LocalFree(msgbuf);\n    }\n    else {\n        sprintf(buf, \"unknown win32 error (%ld)\", error);\n    }\n\n    SetLastError(lasterr);\n    return buf;\n}\n\n#endif /* UNDER_CE */\n\n/* Reset gzip file state */\nlocal void gz_reset(state)\n    gz_statep state;\n{\n    state->x.have = 0;              /* no output data available */\n    if (state->mode == GZ_READ) {   /* for reading ... */\n        state->eof = 0;             /* not at end of file */\n        state->past = 0;            /* have not read past end yet */\n        state->how = LOOK;          /* look for gzip header */\n    }\n    state->seek = 0;                /* no seek request pending */\n    gz_error(state, Z_OK, NULL);    /* clear error */\n    state->x.pos = 0;               /* no uncompressed data yet */\n    state->strm.avail_in = 0;       /* no input data yet */\n}\n\n/* Open a gzip file either by name or file descriptor. */\nlocal gzFile gz_open(path, fd, mode)\n    const char *path;\n    int fd;\n    const char *mode;\n{\n    gz_statep state;\n\n    /* check input */\n    if (path == NULL)\n        return NULL;\n\n    /* allocate gzFile structure to return */\n    state = malloc(sizeof(gz_state));\n    if (state == NULL)\n        return NULL;\n    state->size = 0;            /* no buffers allocated yet */\n    state->want = GZBUFSIZE;    /* requested buffer size */\n    state->msg = NULL;          /* no error message yet */\n\n    /* interpret mode */\n    state->mode = GZ_NONE;\n    state->level = Z_DEFAULT_COMPRESSION;\n    state->strategy = Z_DEFAULT_STRATEGY;\n    state->direct = 0;\n    while (*mode) {\n        if (*mode >= '0' && *mode <= '9')\n            state->level = *mode - '0';\n        else\n            switch (*mode) {\n            case 'r':\n                state->mode = GZ_READ;\n                break;\n#ifndef NO_GZCOMPRESS\n            case 'w':\n                state->mode = GZ_WRITE;\n                break;\n            case 'a':\n                state->mode = GZ_APPEND;\n                break;\n#endif\n            case '+':       /* can't read and write at the same time */\n                free(state);\n                return NULL;\n            case 'b':       /* ignore -- will request binary anyway */\n                break;\n            case 'f':\n                state->strategy = Z_FILTERED;\n                break;\n            case 'h':\n                state->strategy = Z_HUFFMAN_ONLY;\n                break;\n            case 'R':\n                state->strategy = Z_RLE;\n                break;\n            case 'F':\n                state->strategy = Z_FIXED;\n            case 'T':\n                state->direct = 1;\n            default:        /* could consider as an error, but just ignore */\n                ;\n            }\n        mode++;\n    }\n\n    /* must provide an \"r\", \"w\", or \"a\" */\n    if (state->mode == GZ_NONE) {\n        free(state);\n        return NULL;\n    }\n\n    /* can't force transparent read */\n    if (state->mode == GZ_READ) {\n        if (state->direct) {\n            free(state);\n            return NULL;\n        }\n        state->direct = 1;      /* for empty file */\n    }\n\n    /* save the path name for error messages */\n    state->path = malloc(strlen(path) + 1);\n    if (state->path == NULL) {\n        free(state);\n        return NULL;\n    }\n    strcpy(state->path, path);\n\n    /* open the file with the appropriate mode (or just use fd) */\n    state->fd = fd != -1 ? fd :\n        open(path,\n#ifdef O_LARGEFILE\n            O_LARGEFILE |\n#endif\n#ifdef O_BINARY\n            O_BINARY |\n#endif\n            (state->mode == GZ_READ ?\n                O_RDONLY :\n                (O_WRONLY | O_CREAT | (\n                    state->mode == GZ_WRITE ?\n                        O_TRUNC :\n                        O_APPEND))),\n            0666);\n    if (state->fd == -1) {\n        free(state->path);\n        free(state);\n        return NULL;\n    }\n    if (state->mode == GZ_APPEND)\n        state->mode = GZ_WRITE;         /* simplify later checks */\n\n    /* save the current position for rewinding (only if reading) */\n    if (state->mode == GZ_READ) {\n        state->start = LSEEK(state->fd, 0, SEEK_CUR);\n        if (state->start == -1) state->start = 0;\n    }\n\n    /* initialize stream */\n    gz_reset(state);\n\n    /* return stream */\n    return (gzFile)state;\n}\n\n/* -- see zlib.h -- */\ngzFile ZEXPORT gzopen(path, mode)\n    const char *path;\n    const char *mode;\n{\n    return gz_open(path, -1, mode);\n}\n\n/* -- see zlib.h -- */\ngzFile ZEXPORT gzopen64(path, mode)\n    const char *path;\n    const char *mode;\n{\n    return gz_open(path, -1, mode);\n}\n\n/* -- see zlib.h -- */\ngzFile ZEXPORT gzdopen(fd, mode)\n    int fd;\n    const char *mode;\n{\n    char *path;         /* identifier for error messages */\n    gzFile gz;\n\n    if (fd == -1 || (path = malloc(7 + 3 * sizeof(int))) == NULL)\n        return NULL;\n    sprintf(path, \"<fd:%d>\", fd);   /* for debugging */\n    gz = gz_open(path, fd, mode);\n    free(path);\n    return gz;\n}\n\n/* -- see zlib.h -- */\nint ZEXPORT gzbuffer(file, size)\n    gzFile file;\n    unsigned size;\n{\n    gz_statep state;\n\n    /* get internal structure and check integrity */\n    if (file == NULL)\n        return -1;\n    state = (gz_statep)file;\n    if (state->mode != GZ_READ && state->mode != GZ_WRITE)\n        return -1;\n\n    /* make sure we haven't already allocated memory */\n    if (state->size != 0)\n        return -1;\n\n    /* check and set requested size */\n    if (size < 2)\n        size = 2;               /* need two bytes to check magic header */\n    state->want = size;\n    return 0;\n}\n\n/* -- see zlib.h -- */\nint ZEXPORT gzrewind(file)\n    gzFile file;\n{\n    gz_statep state;\n\n    /* get internal structure */\n    if (file == NULL)\n        return -1;\n    state = (gz_statep)file;\n\n    /* check that we're reading and that there's no error */\n    if (state->mode != GZ_READ ||\n            (state->err != Z_OK && state->err != Z_BUF_ERROR))\n        return -1;\n\n    /* back up and start over */\n    if (LSEEK(state->fd, state->start, SEEK_SET) == -1)\n        return -1;\n    gz_reset(state);\n    return 0;\n}\n\n/* -- see zlib.h -- */\nz_off64_t ZEXPORT gzseek64(file, offset, whence)\n    gzFile file;\n    z_off64_t offset;\n    int whence;\n{\n    unsigned n;\n    z_off64_t ret;\n    gz_statep state;\n\n    /* get internal structure and check integrity */\n    if (file == NULL)\n        return -1;\n    state = (gz_statep)file;\n    if (state->mode != GZ_READ && state->mode != GZ_WRITE)\n        return -1;\n\n    /* check that there's no error */\n    if (state->err != Z_OK && state->err != Z_BUF_ERROR)\n        return -1;\n\n    /* can only seek from start or relative to current position */\n    if (whence != SEEK_SET && whence != SEEK_CUR)\n        return -1;\n\n    /* normalize offset to a SEEK_CUR specification */\n    if (whence == SEEK_SET)\n        offset -= state->x.pos;\n    else if (state->seek)\n        offset += state->skip;\n    state->seek = 0;\n\n    /* if within raw area while reading, just go there */\n    if (state->mode == GZ_READ && state->how == COPY &&\n            state->x.pos + offset >= 0) {\n        ret = LSEEK(state->fd, offset - state->x.have, SEEK_CUR);\n        if (ret == -1)\n            return -1;\n        state->x.have = 0;\n        state->eof = 0;\n        state->past = 0;\n        state->seek = 0;\n        gz_error(state, Z_OK, NULL);\n        state->strm.avail_in = 0;\n        state->x.pos += offset;\n        return state->x.pos;\n    }\n\n    /* calculate skip amount, rewinding if needed for back seek when reading */\n    if (offset < 0) {\n        if (state->mode != GZ_READ)         /* writing -- can't go backwards */\n            return -1;\n        offset += state->x.pos;\n        if (offset < 0)                     /* before start of file! */\n            return -1;\n        if (gzrewind(file) == -1)           /* rewind, then skip to offset */\n            return -1;\n    }\n\n    /* if reading, skip what's in output buffer (one less gzgetc() check) */\n    if (state->mode == GZ_READ) {\n        n = GT_OFF(state->x.have) || (z_off64_t)state->x.have > offset ?\n            (unsigned)offset : state->x.have;\n        state->x.have -= n;\n        state->x.next += n;\n        state->x.pos += n;\n        offset -= n;\n    }\n\n    /* request skip (if not zero) */\n    if (offset) {\n        state->seek = 1;\n        state->skip = offset;\n    }\n    return state->x.pos + offset;\n}\n\n/* -- see zlib.h -- */\nz_off_t ZEXPORT gzseek(file, offset, whence)\n    gzFile file;\n    z_off_t offset;\n    int whence;\n{\n    z_off64_t ret;\n\n    ret = gzseek64(file, (z_off64_t)offset, whence);\n    return ret == (z_off_t)ret ? (z_off_t)ret : -1;\n}\n\n/* -- see zlib.h -- */\nz_off64_t ZEXPORT gztell64(file)\n    gzFile file;\n{\n    gz_statep state;\n\n    /* get internal structure and check integrity */\n    if (file == NULL)\n        return -1;\n    state = (gz_statep)file;\n    if (state->mode != GZ_READ && state->mode != GZ_WRITE)\n        return -1;\n\n    /* return position */\n    return state->x.pos + (state->seek ? state->skip : 0);\n}\n\n/* -- see zlib.h -- */\nz_off_t ZEXPORT gztell(file)\n    gzFile file;\n{\n    z_off64_t ret;\n\n    ret = gztell64(file);\n    return ret == (z_off_t)ret ? (z_off_t)ret : -1;\n}\n\n/* -- see zlib.h -- */\nz_off64_t ZEXPORT gzoffset64(file)\n    gzFile file;\n{\n    z_off64_t offset;\n    gz_statep state;\n\n    /* get internal structure and check integrity */\n    if (file == NULL)\n        return -1;\n    state = (gz_statep)file;\n    if (state->mode != GZ_READ && state->mode != GZ_WRITE)\n        return -1;\n\n    /* compute and return effective offset in file */\n    offset = LSEEK(state->fd, 0, SEEK_CUR);\n    if (offset == -1)\n        return -1;\n    if (state->mode == GZ_READ)             /* reading */\n        offset -= state->strm.avail_in;     /* don't count buffered input */\n    return offset;\n}\n\n/* -- see zlib.h -- */\nz_off_t ZEXPORT gzoffset(file)\n    gzFile file;\n{\n    z_off64_t ret;\n\n    ret = gzoffset64(file);\n    return ret == (z_off_t)ret ? (z_off_t)ret : -1;\n}\n\n/* -- see zlib.h -- */\nint ZEXPORT gzeof(file)\n    gzFile file;\n{\n    gz_statep state;\n\n    /* get internal structure and check integrity */\n    if (file == NULL)\n        return 0;\n    state = (gz_statep)file;\n    if (state->mode != GZ_READ && state->mode != GZ_WRITE)\n        return 0;\n\n    /* return end-of-file state */\n    return state->mode == GZ_READ ? state->past : 0;\n}\n\n/* -- see zlib.h -- */\nconst char * ZEXPORT gzerror(file, errnum)\n    gzFile file;\n    int *errnum;\n{\n    gz_statep state;\n\n    /* get internal structure and check integrity */\n    if (file == NULL)\n        return NULL;\n    state = (gz_statep)file;\n    if (state->mode != GZ_READ && state->mode != GZ_WRITE)\n        return NULL;\n\n    /* return error information */\n    if (errnum != NULL)\n        *errnum = state->err;\n    return state->msg == NULL ? \"\" : state->msg;\n}\n\n/* -- see zlib.h -- */\nvoid ZEXPORT gzclearerr(file)\n    gzFile file;\n{\n    gz_statep state;\n\n    /* get internal structure and check integrity */\n    if (file == NULL)\n        return;\n    state = (gz_statep)file;\n    if (state->mode != GZ_READ && state->mode != GZ_WRITE)\n        return;\n\n    /* clear error and end-of-file */\n    if (state->mode == GZ_READ) {\n        state->eof = 0;\n        state->past = 0;\n    }\n    gz_error(state, Z_OK, NULL);\n}\n\n/* Create an error message in allocated memory and set state->err and\n   state->msg accordingly.  Free any previous error message already there.  Do\n   not try to free or allocate space if the error is Z_MEM_ERROR (out of\n   memory).  Simply save the error message as a static string.  If there is an\n   allocation failure constructing the error message, then convert the error to\n   out of memory. */\nvoid ZLIB_INTERNAL gz_error(state, err, msg)\n    gz_statep state;\n    int err;\n    const char *msg;\n{\n    /* free previously allocated message and clear */\n    if (state->msg != NULL) {\n        if (state->err != Z_MEM_ERROR)\n            free(state->msg);\n        state->msg = NULL;\n    }\n\n    /* if fatal, set state->x.have to 0 so that the gzgetc() macro fails */\n    if (err != Z_OK && err != Z_BUF_ERROR)\n        state->x.have = 0;\n\n    /* set error code, and if no message, then done */\n    state->err = err;\n    if (msg == NULL)\n        return;\n\n    /* for an out of memory error, save as static string */\n    if (err == Z_MEM_ERROR) {\n        state->msg = (char *)msg;\n        return;\n    }\n\n    /* construct error message with path */\n    if ((state->msg = malloc(strlen(state->path) + strlen(msg) + 3)) == NULL) {\n        state->err = Z_MEM_ERROR;\n        state->msg = (char *)\"out of memory\";\n        return;\n    }\n    strcpy(state->msg, state->path);\n    strcat(state->msg, \": \");\n    strcat(state->msg, msg);\n    return;\n}\n\n#ifndef INT_MAX\n/* portably return maximum value for an int (when limits.h presumed not\n   available) -- we need to do this to cover cases where 2's complement not\n   used, since C standard permits 1's complement and sign-bit representations,\n   otherwise we could just use ((unsigned)-1) >> 1 */\nunsigned ZLIB_INTERNAL gz_intmax()\n{\n    unsigned p, q;\n\n    p = 1;\n    do {\n        q = p;\n        p <<= 1;\n        p++;\n    } while (p > q);\n    return q >> 1;\n}\n#endif\n"
  },
  {
    "path": "Projects/Tools/PNGAlphaPremultiplier/Native/Source/ZLib/gzread.c",
    "content": "/* gzread.c -- zlib functions for reading gzip files\n * Copyright (C) 2004, 2005, 2010, 2011 Mark Adler\n * For conditions of distribution and use, see copyright notice in zlib.h\n */\n\n#include \"gzguts.h\"\n\n/* Local functions */\nlocal int gz_load OF((gz_statep, unsigned char *, unsigned, unsigned *));\nlocal int gz_avail OF((gz_statep));\nlocal int gz_look OF((gz_statep));\nlocal int gz_decomp OF((gz_statep));\nlocal int gz_fetch OF((gz_statep));\nlocal int gz_skip OF((gz_statep, z_off64_t));\n\n/* Use read() to load a buffer -- return -1 on error, otherwise 0.  Read from\n   state->fd, and update state->eof, state->err, and state->msg as appropriate.\n   This function needs to loop on read(), since read() is not guaranteed to\n   read the number of bytes requested, depending on the type of descriptor. */\nlocal int gz_load(state, buf, len, have)\n    gz_statep state;\n    unsigned char *buf;\n    unsigned len;\n    unsigned *have;\n{\n    int ret;\n\n    *have = 0;\n    do {\n        ret = read(state->fd, buf + *have, len - *have);\n        if (ret <= 0)\n            break;\n        *have += ret;\n    } while (*have < len);\n    if (ret < 0) {\n        gz_error(state, Z_ERRNO, zstrerror());\n        return -1;\n    }\n    if (ret == 0)\n        state->eof = 1;\n    return 0;\n}\n\n/* Load up input buffer and set eof flag if last data loaded -- return -1 on\n   error, 0 otherwise.  Note that the eof flag is set when the end of the input\n   file is reached, even though there may be unused data in the buffer.  Once\n   that data has been used, no more attempts will be made to read the file.\n   If strm->avail_in != 0, then the current data is moved to the beginning of\n   the input buffer, and then the remainder of the buffer is loaded with the\n   available data from the input file. */\nlocal int gz_avail(state)\n    gz_statep state;\n{\n    unsigned got;\n    z_streamp strm = &(state->strm);\n\n    if (state->err != Z_OK && state->err != Z_BUF_ERROR)\n        return -1;\n    if (state->eof == 0) {\n        if (strm->avail_in)\n            memmove(state->in, strm->next_in, strm->avail_in);\n        if (gz_load(state, state->in + strm->avail_in,\n                    state->size - strm->avail_in, &got) == -1)\n            return -1;\n        strm->avail_in += got;\n        strm->next_in = state->in;\n    }\n    return 0;\n}\n\n/* Look for gzip header, set up for inflate or copy.  state->x.have must be 0.\n   If this is the first time in, allocate required memory.  state->how will be\n   left unchanged if there is no more input data available, will be set to COPY\n   if there is no gzip header and direct copying will be performed, or it will\n   be set to GZIP for decompression.  If direct copying, then leftover input\n   data from the input buffer will be copied to the output buffer.  In that\n   case, all further file reads will be directly to either the output buffer or\n   a user buffer.  If decompressing, the inflate state will be initialized.\n   gz_look() will return 0 on success or -1 on failure. */\nlocal int gz_look(state)\n    gz_statep state;\n{\n    z_streamp strm = &(state->strm);\n\n    /* allocate read buffers and inflate memory */\n    if (state->size == 0) {\n        /* allocate buffers */\n        state->in = malloc(state->want);\n        state->out = malloc(state->want << 1);\n        if (state->in == NULL || state->out == NULL) {\n            if (state->out != NULL)\n                free(state->out);\n            if (state->in != NULL)\n                free(state->in);\n            gz_error(state, Z_MEM_ERROR, \"out of memory\");\n            return -1;\n        }\n        state->size = state->want;\n\n        /* allocate inflate memory */\n        state->strm.zalloc = Z_NULL;\n        state->strm.zfree = Z_NULL;\n        state->strm.opaque = Z_NULL;\n        state->strm.avail_in = 0;\n        state->strm.next_in = Z_NULL;\n        if (inflateInit2(&(state->strm), 15 + 16) != Z_OK) {    /* gunzip */\n            free(state->out);\n            free(state->in);\n            state->size = 0;\n            gz_error(state, Z_MEM_ERROR, \"out of memory\");\n            return -1;\n        }\n    }\n\n    /* get at least the magic bytes in the input buffer */\n    if (strm->avail_in < 2) {\n        if (gz_avail(state) == -1)\n            return -1;\n        if (strm->avail_in == 0)\n            return 0;\n    }\n\n    /* look for gzip magic bytes -- if there, do gzip decoding (note: there is\n       a logical dilemma here when considering the case of a partially written\n       gzip file, to wit, if a single 31 byte is written, then we cannot tell\n       whether this is a single-byte file, or just a partially written gzip\n       file -- for here we assume that if a gzip file is being written, then\n       the header will be written in a single operation, so that reading a\n       single byte is sufficient indication that it is not a gzip file) */\n    if (strm->avail_in > 1 &&\n            strm->next_in[0] == 31 && strm->next_in[1] == 139) {\n        inflateReset(strm);\n        state->how = GZIP;\n        state->direct = 0;\n        return 0;\n    }\n\n    /* no gzip header -- if we were decoding gzip before, then this is trailing\n       garbage.  Ignore the trailing garbage and finish. */\n    if (state->direct == 0) {\n        strm->avail_in = 0;\n        state->eof = 1;\n        state->x.have = 0;\n        return 0;\n    }\n\n    /* doing raw i/o, copy any leftover input to output -- this assumes that\n       the output buffer is larger than the input buffer, which also assures\n       space for gzungetc() */\n    state->x.next = state->out;\n    if (strm->avail_in) {\n        memcpy(state->x.next, strm->next_in, strm->avail_in);\n        state->x.have = strm->avail_in;\n        strm->avail_in = 0;\n    }\n    state->how = COPY;\n    state->direct = 1;\n    return 0;\n}\n\n/* Decompress from input to the provided next_out and avail_out in the state.\n   On return, state->x.have and state->x.next point to the just decompressed\n   data.  If the gzip stream completes, state->how is reset to LOOK to look for\n   the next gzip stream or raw data, once state->x.have is depleted.  Returns 0\n   on success, -1 on failure. */\nlocal int gz_decomp(state)\n    gz_statep state;\n{\n    int ret = Z_OK;\n    unsigned had;\n    z_streamp strm = &(state->strm);\n\n    /* fill output buffer up to end of deflate stream */\n    had = strm->avail_out;\n    do {\n        /* get more input for inflate() */\n        if (strm->avail_in == 0 && gz_avail(state) == -1)\n            return -1;\n        if (strm->avail_in == 0) {\n            gz_error(state, Z_BUF_ERROR, \"unexpected end of file\");\n            break;\n        }\n\n        /* decompress and handle errors */\n        ret = inflate(strm, Z_NO_FLUSH);\n        if (ret == Z_STREAM_ERROR || ret == Z_NEED_DICT) {\n            gz_error(state, Z_STREAM_ERROR,\n                     \"internal error: inflate stream corrupt\");\n            return -1;\n        }\n        if (ret == Z_MEM_ERROR) {\n            gz_error(state, Z_MEM_ERROR, \"out of memory\");\n            return -1;\n        }\n        if (ret == Z_DATA_ERROR) {              /* deflate stream invalid */\n            gz_error(state, Z_DATA_ERROR,\n                     strm->msg == NULL ? \"compressed data error\" : strm->msg);\n            return -1;\n        }\n    } while (strm->avail_out && ret != Z_STREAM_END);\n\n    /* update available output */\n    state->x.have = had - strm->avail_out;\n    state->x.next = strm->next_out - state->x.have;\n\n    /* if the gzip stream completed successfully, look for another */\n    if (ret == Z_STREAM_END)\n        state->how = LOOK;\n\n    /* good decompression */\n    return 0;\n}\n\n/* Fetch data and put it in the output buffer.  Assumes state->x.have is 0.\n   Data is either copied from the input file or decompressed from the input\n   file depending on state->how.  If state->how is LOOK, then a gzip header is\n   looked for to determine whether to copy or decompress.  Returns -1 on error,\n   otherwise 0.  gz_fetch() will leave state->how as COPY or GZIP unless the\n   end of the input file has been reached and all data has been processed.  */\nlocal int gz_fetch(state)\n    gz_statep state;\n{\n    z_streamp strm = &(state->strm);\n\n    do {\n        switch(state->how) {\n        case LOOK:      /* -> LOOK, COPY (only if never GZIP), or GZIP */\n            if (gz_look(state) == -1)\n                return -1;\n            if (state->how == LOOK)\n                return 0;\n            break;\n        case COPY:      /* -> COPY */\n            if (gz_load(state, state->out, state->size << 1, &(state->x.have))\n                    == -1)\n                return -1;\n            state->x.next = state->out;\n            return 0;\n        case GZIP:      /* -> GZIP or LOOK (if end of gzip stream) */\n            strm->avail_out = state->size << 1;\n            strm->next_out = state->out;\n            if (gz_decomp(state) == -1)\n                return -1;\n        }\n    } while (state->x.have == 0 && (!state->eof || strm->avail_in));\n    return 0;\n}\n\n/* Skip len uncompressed bytes of output.  Return -1 on error, 0 on success. */\nlocal int gz_skip(state, len)\n    gz_statep state;\n    z_off64_t len;\n{\n    unsigned n;\n\n    /* skip over len bytes or reach end-of-file, whichever comes first */\n    while (len)\n        /* skip over whatever is in output buffer */\n        if (state->x.have) {\n            n = GT_OFF(state->x.have) || (z_off64_t)state->x.have > len ?\n                (unsigned)len : state->x.have;\n            state->x.have -= n;\n            state->x.next += n;\n            state->x.pos += n;\n            len -= n;\n        }\n\n        /* output buffer empty -- return if we're at the end of the input */\n        else if (state->eof && state->strm.avail_in == 0)\n            break;\n\n        /* need more data to skip -- load up output buffer */\n        else {\n            /* get more output, looking for header if required */\n            if (gz_fetch(state) == -1)\n                return -1;\n        }\n    return 0;\n}\n\n/* -- see zlib.h -- */\nint ZEXPORT gzread(file, buf, len)\n    gzFile file;\n    voidp buf;\n    unsigned len;\n{\n    unsigned got, n;\n    gz_statep state;\n    z_streamp strm;\n\n    /* get internal structure */\n    if (file == NULL)\n        return -1;\n    state = (gz_statep)file;\n    strm = &(state->strm);\n\n    /* check that we're reading and that there's no (serious) error */\n    if (state->mode != GZ_READ ||\n            (state->err != Z_OK && state->err != Z_BUF_ERROR))\n        return -1;\n\n    /* since an int is returned, make sure len fits in one, otherwise return\n       with an error (this avoids the flaw in the interface) */\n    if ((int)len < 0) {\n        gz_error(state, Z_DATA_ERROR, \"requested length does not fit in int\");\n        return -1;\n    }\n\n    /* if len is zero, avoid unnecessary operations */\n    if (len == 0)\n        return 0;\n\n    /* process a skip request */\n    if (state->seek) {\n        state->seek = 0;\n        if (gz_skip(state, state->skip) == -1)\n            return -1;\n    }\n\n    /* get len bytes to buf, or less than len if at the end */\n    got = 0;\n    do {\n        /* first just try copying data from the output buffer */\n        if (state->x.have) {\n            n = state->x.have > len ? len : state->x.have;\n            memcpy(buf, state->x.next, n);\n            state->x.next += n;\n            state->x.have -= n;\n        }\n\n        /* output buffer empty -- return if we're at the end of the input */\n        else if (state->eof && strm->avail_in == 0) {\n            state->past = 1;        /* tried to read past end */\n            break;\n        }\n\n        /* need output data -- for small len or new stream load up our output\n           buffer */\n        else if (state->how == LOOK || len < (state->size << 1)) {\n            /* get more output, looking for header if required */\n            if (gz_fetch(state) == -1)\n                return -1;\n            continue;       /* no progress yet -- go back to memcpy() above */\n            /* the copy above assures that we will leave with space in the\n               output buffer, allowing at least one gzungetc() to succeed */\n        }\n\n        /* large len -- read directly into user buffer */\n        else if (state->how == COPY) {      /* read directly */\n            if (gz_load(state, buf, len, &n) == -1)\n                return -1;\n        }\n\n        /* large len -- decompress directly into user buffer */\n        else {  /* state->how == GZIP */\n            strm->avail_out = len;\n            strm->next_out = buf;\n            if (gz_decomp(state) == -1)\n                return -1;\n            n = state->x.have;\n            state->x.have = 0;\n        }\n\n        /* update progress */\n        len -= n;\n        buf = (char *)buf + n;\n        got += n;\n        state->x.pos += n;\n    } while (len);\n\n    /* return number of bytes read into user buffer (will fit in int) */\n    return (int)got;\n}\n\n/* -- see zlib.h -- */\nint ZEXPORT gzgetc_(file)\n    gzFile file;\n{\n    int ret;\n    unsigned char buf[1];\n    gz_statep state;\n\n    /* get internal structure */\n    if (file == NULL)\n        return -1;\n    state = (gz_statep)file;\n\n    /* check that we're reading and that there's no (serious) error */\n    if (state->mode != GZ_READ ||\n        (state->err != Z_OK && state->err != Z_BUF_ERROR))\n        return -1;\n\n    /* try output buffer (no need to check for skip request) */\n    if (state->x.have) {\n        state->x.have--;\n        state->x.pos++;\n        return *(state->x.next)++;\n    }\n\n    /* nothing there -- try gzread() */\n    ret = gzread(file, buf, 1);\n    return ret < 1 ? -1 : buf[0];\n}\n\n#undef gzgetc\nint ZEXPORT gzgetc(file)\ngzFile file;\n{\n    return gzgetc_(file);\n}    \n\n/* -- see zlib.h -- */\nint ZEXPORT gzungetc(c, file)\n    int c;\n    gzFile file;\n{\n    gz_statep state;\n\n    /* get internal structure */\n    if (file == NULL)\n        return -1;\n    state = (gz_statep)file;\n\n    /* check that we're reading and that there's no (serious) error */\n    if (state->mode != GZ_READ ||\n        (state->err != Z_OK && state->err != Z_BUF_ERROR))\n        return -1;\n\n    /* process a skip request */\n    if (state->seek) {\n        state->seek = 0;\n        if (gz_skip(state, state->skip) == -1)\n            return -1;\n    }\n\n    /* can't push EOF */\n    if (c < 0)\n        return -1;\n\n    /* if output buffer empty, put byte at end (allows more pushing) */\n    if (state->x.have == 0) {\n        state->x.have = 1;\n        state->x.next = state->out + (state->size << 1) - 1;\n        state->x.next[0] = c;\n        state->x.pos--;\n        state->past = 0;\n        return c;\n    }\n\n    /* if no room, give up (must have already done a gzungetc()) */\n    if (state->x.have == (state->size << 1)) {\n        gz_error(state, Z_DATA_ERROR, \"out of room to push characters\");\n        return -1;\n    }\n\n    /* slide output data if needed and insert byte before existing data */\n    if (state->x.next == state->out) {\n        unsigned char *src = state->out + state->x.have;\n        unsigned char *dest = state->out + (state->size << 1);\n        while (src > state->out)\n            *--dest = *--src;\n        state->x.next = dest;\n    }\n    state->x.have++;\n    state->x.next--;\n    state->x.next[0] = c;\n    state->x.pos--;\n    state->past = 0;\n    return c;\n}\n\n/* -- see zlib.h -- */\nchar * ZEXPORT gzgets(file, buf, len)\n    gzFile file;\n    char *buf;\n    int len;\n{\n    unsigned left, n;\n    char *str;\n    unsigned char *eol;\n    gz_statep state;\n\n    /* check parameters and get internal structure */\n    if (file == NULL || buf == NULL || len < 1)\n        return NULL;\n    state = (gz_statep)file;\n\n    /* check that we're reading and that there's no (serious) error */\n    if (state->mode != GZ_READ ||\n        (state->err != Z_OK && state->err != Z_BUF_ERROR))\n        return NULL;\n\n    /* process a skip request */\n    if (state->seek) {\n        state->seek = 0;\n        if (gz_skip(state, state->skip) == -1)\n            return NULL;\n    }\n\n    /* copy output bytes up to new line or len - 1, whichever comes first --\n       append a terminating zero to the string (we don't check for a zero in\n       the contents, let the user worry about that) */\n    str = buf;\n    left = (unsigned)len - 1;\n    if (left) do {\n        /* assure that something is in the output buffer */\n        if (state->x.have == 0 && gz_fetch(state) == -1)\n            return NULL;                /* error */\n        if (state->x.have == 0) {       /* end of file */\n            state->past = 1;            /* read past end */\n            break;                      /* return what we have */\n        }\n\n        /* look for end-of-line in current output buffer */\n        n = state->x.have > left ? left : state->x.have;\n        eol = memchr(state->x.next, '\\n', n);\n        if (eol != NULL)\n            n = (unsigned)(eol - state->x.next) + 1;\n\n        /* copy through end-of-line, or remainder if not found */\n        memcpy(buf, state->x.next, n);\n        state->x.have -= n;\n        state->x.next += n;\n        state->x.pos += n;\n        left -= n;\n        buf += n;\n    } while (left && eol == NULL);\n\n    /* return terminated string, or if nothing, end of file */\n    if (buf == str)\n        return NULL;\n    buf[0] = 0;\n    return str;\n}\n\n/* -- see zlib.h -- */\nint ZEXPORT gzdirect(file)\n    gzFile file;\n{\n    gz_statep state;\n\n    /* get internal structure */\n    if (file == NULL)\n        return 0;\n    state = (gz_statep)file;\n\n    /* if the state is not known, but we can find out, then do so (this is\n       mainly for right after a gzopen() or gzdopen()) */\n    if (state->mode == GZ_READ && state->how == LOOK && state->x.have == 0)\n        (void)gz_look(state);\n\n    /* return 1 if transparent, 0 if processing a gzip stream */\n    return state->direct;\n}\n\n/* -- see zlib.h -- */\nint ZEXPORT gzclose_r(file)\n    gzFile file;\n{\n    int ret, err;\n    gz_statep state;\n\n    /* get internal structure */\n    if (file == NULL)\n        return Z_STREAM_ERROR;\n    state = (gz_statep)file;\n\n    /* check that we're reading */\n    if (state->mode != GZ_READ)\n        return Z_STREAM_ERROR;\n\n    /* free memory and close file */\n    if (state->size) {\n        inflateEnd(&(state->strm));\n        free(state->out);\n        free(state->in);\n    }\n    err = state->err == Z_BUF_ERROR ? Z_BUF_ERROR : Z_OK;\n    gz_error(state, Z_OK, NULL);\n    free(state->path);\n    ret = close(state->fd);\n    free(state);\n    return ret ? Z_ERRNO : err;\n}\n"
  },
  {
    "path": "Projects/Tools/PNGAlphaPremultiplier/Native/Source/ZLib/gzwrite.c",
    "content": "/* gzwrite.c -- zlib functions for writing gzip files\n * Copyright (C) 2004, 2005, 2010, 2011, 2012 Mark Adler\n * For conditions of distribution and use, see copyright notice in zlib.h\n */\n\n#include \"gzguts.h\"\n\n/* Local functions */\nlocal int gz_init OF((gz_statep));\nlocal int gz_comp OF((gz_statep, int));\nlocal int gz_zero OF((gz_statep, z_off64_t));\n\n/* Initialize state for writing a gzip file.  Mark initialization by setting\n   state->size to non-zero.  Return -1 on failure or 0 on success. */\nlocal int gz_init(state)\n    gz_statep state;\n{\n    int ret;\n    z_streamp strm = &(state->strm);\n\n    /* allocate input buffer */\n    state->in = malloc(state->want);\n    if (state->in == NULL) {\n        gz_error(state, Z_MEM_ERROR, \"out of memory\");\n        return -1;\n    }\n\n    /* only need output buffer and deflate state if compressing */\n    if (!state->direct) {\n        /* allocate output buffer */\n        state->out = malloc(state->want);\n        if (state->out == NULL) {\n            free(state->in);\n            gz_error(state, Z_MEM_ERROR, \"out of memory\");\n            return -1;\n        }\n\n        /* allocate deflate memory, set up for gzip compression */\n        strm->zalloc = Z_NULL;\n        strm->zfree = Z_NULL;\n        strm->opaque = Z_NULL;\n        ret = deflateInit2(strm, state->level, Z_DEFLATED,\n                           MAX_WBITS + 16, DEF_MEM_LEVEL, state->strategy);\n        if (ret != Z_OK) {\n            free(state->out);\n            free(state->in);\n            gz_error(state, Z_MEM_ERROR, \"out of memory\");\n            return -1;\n        }\n    }\n\n    /* mark state as initialized */\n    state->size = state->want;\n\n    /* initialize write buffer if compressing */\n    if (!state->direct) {\n        strm->avail_out = state->size;\n        strm->next_out = state->out;\n        state->x.next = strm->next_out;\n    }\n    return 0;\n}\n\n/* Compress whatever is at avail_in and next_in and write to the output file.\n   Return -1 if there is an error writing to the output file, otherwise 0.\n   flush is assumed to be a valid deflate() flush value.  If flush is Z_FINISH,\n   then the deflate() state is reset to start a new gzip stream.  If gz->direct\n   is true, then simply write to the output file without compressing, and\n   ignore flush. */\nlocal int gz_comp(state, flush)\n    gz_statep state;\n    int flush;\n{\n    int ret, got;\n    unsigned have;\n    z_streamp strm = &(state->strm);\n\n    /* allocate memory if this is the first time through */\n    if (state->size == 0 && gz_init(state) == -1)\n        return -1;\n\n    /* write directly if requested */\n    if (state->direct) {\n        got = write(state->fd, strm->next_in, strm->avail_in);\n        if (got < 0 || (unsigned)got != strm->avail_in) {\n            gz_error(state, Z_ERRNO, zstrerror());\n            return -1;\n        }\n        strm->avail_in = 0;\n        return 0;\n    }\n\n    /* run deflate() on provided input until it produces no more output */\n    ret = Z_OK;\n    do {\n        /* write out current buffer contents if full, or if flushing, but if\n           doing Z_FINISH then don't write until we get to Z_STREAM_END */\n        if (strm->avail_out == 0 || (flush != Z_NO_FLUSH &&\n            (flush != Z_FINISH || ret == Z_STREAM_END))) {\n            have = (unsigned)(strm->next_out - state->x.next);\n            if (have && ((got = write(state->fd, state->x.next, have)) < 0 ||\n                         (unsigned)got != have)) {\n                gz_error(state, Z_ERRNO, zstrerror());\n                return -1;\n            }\n            if (strm->avail_out == 0) {\n                strm->avail_out = state->size;\n                strm->next_out = state->out;\n            }\n            state->x.next = strm->next_out;\n        }\n\n        /* compress */\n        have = strm->avail_out;\n        ret = deflate(strm, flush);\n        if (ret == Z_STREAM_ERROR) {\n            gz_error(state, Z_STREAM_ERROR,\n                      \"internal error: deflate stream corrupt\");\n            return -1;\n        }\n        have -= strm->avail_out;\n    } while (have);\n\n    /* if that completed a deflate stream, allow another to start */\n    if (flush == Z_FINISH)\n        deflateReset(strm);\n\n    /* all done, no errors */\n    return 0;\n}\n\n/* Compress len zeros to output.  Return -1 on error, 0 on success. */\nlocal int gz_zero(state, len)\n    gz_statep state;\n    z_off64_t len;\n{\n    int first;\n    unsigned n;\n    z_streamp strm = &(state->strm);\n\n    /* consume whatever's left in the input buffer */\n    if (strm->avail_in && gz_comp(state, Z_NO_FLUSH) == -1)\n        return -1;\n\n    /* compress len zeros (len guaranteed > 0) */\n    first = 1;\n    while (len) {\n        n = GT_OFF(state->size) || (z_off64_t)state->size > len ?\n            (unsigned)len : state->size;\n        if (first) {\n            memset(state->in, 0, n);\n            first = 0;\n        }\n        strm->avail_in = n;\n        strm->next_in = state->in;\n        state->x.pos += n;\n        if (gz_comp(state, Z_NO_FLUSH) == -1)\n            return -1;\n        len -= n;\n    }\n    return 0;\n}\n\n/* -- see zlib.h -- */\nint ZEXPORT gzwrite(file, buf, len)\n    gzFile file;\n    voidpc buf;\n    unsigned len;\n{\n    unsigned put = len;\n    unsigned n;\n    gz_statep state;\n    z_streamp strm;\n\n    /* get internal structure */\n    if (file == NULL)\n        return 0;\n    state = (gz_statep)file;\n    strm = &(state->strm);\n\n    /* check that we're writing and that there's no error */\n    if (state->mode != GZ_WRITE || state->err != Z_OK)\n        return 0;\n\n    /* since an int is returned, make sure len fits in one, otherwise return\n       with an error (this avoids the flaw in the interface) */\n    if ((int)len < 0) {\n        gz_error(state, Z_DATA_ERROR, \"requested length does not fit in int\");\n        return 0;\n    }\n\n    /* if len is zero, avoid unnecessary operations */\n    if (len == 0)\n        return 0;\n\n    /* allocate memory if this is the first time through */\n    if (state->size == 0 && gz_init(state) == -1)\n        return 0;\n\n    /* check for seek request */\n    if (state->seek) {\n        state->seek = 0;\n        if (gz_zero(state, state->skip) == -1)\n            return 0;\n    }\n\n    /* for small len, copy to input buffer, otherwise compress directly */\n    if (len < state->size) {\n        /* copy to input buffer, compress when full */\n        do {\n            if (strm->avail_in == 0)\n                strm->next_in = state->in;\n            n = state->size - strm->avail_in;\n            if (n > len)\n                n = len;\n            memcpy(strm->next_in + strm->avail_in, buf, n);\n            strm->avail_in += n;\n            state->x.pos += n;\n            buf = (char *)buf + n;\n            len -= n;\n            if (len && gz_comp(state, Z_NO_FLUSH) == -1)\n                return 0;\n        } while (len);\n    }\n    else {\n        /* consume whatever's left in the input buffer */\n        if (strm->avail_in && gz_comp(state, Z_NO_FLUSH) == -1)\n            return 0;\n\n        /* directly compress user buffer to file */\n        strm->avail_in = len;\n        strm->next_in = (voidp)buf;\n        state->x.pos += len;\n        if (gz_comp(state, Z_NO_FLUSH) == -1)\n            return 0;\n    }\n\n    /* input was all buffered or compressed (put will fit in int) */\n    return (int)put;\n}\n\n/* -- see zlib.h -- */\nint ZEXPORT gzputc(file, c)\n    gzFile file;\n    int c;\n{\n    unsigned char buf[1];\n    gz_statep state;\n    z_streamp strm;\n\n    /* get internal structure */\n    if (file == NULL)\n        return -1;\n    state = (gz_statep)file;\n    strm = &(state->strm);\n\n    /* check that we're writing and that there's no error */\n    if (state->mode != GZ_WRITE || state->err != Z_OK)\n        return -1;\n\n    /* check for seek request */\n    if (state->seek) {\n        state->seek = 0;\n        if (gz_zero(state, state->skip) == -1)\n            return -1;\n    }\n\n    /* try writing to input buffer for speed (state->size == 0 if buffer not\n       initialized) */\n    if (strm->avail_in < state->size) {\n        if (strm->avail_in == 0)\n            strm->next_in = state->in;\n        strm->next_in[strm->avail_in++] = c;\n        state->x.pos++;\n        return c & 0xff;\n    }\n\n    /* no room in buffer or not initialized, use gz_write() */\n    buf[0] = c;\n    if (gzwrite(file, buf, 1) != 1)\n        return -1;\n    return c & 0xff;\n}\n\n/* -- see zlib.h -- */\nint ZEXPORT gzputs(file, str)\n    gzFile file;\n    const char *str;\n{\n    int ret;\n    unsigned len;\n\n    /* write string */\n    len = (unsigned)strlen(str);\n    ret = gzwrite(file, str, len);\n    return ret == 0 && len != 0 ? -1 : ret;\n}\n\n#if defined(STDC) || defined(Z_HAVE_STDARG_H)\n#include <stdarg.h>\n\n/* -- see zlib.h -- */\nint ZEXPORTVA gzprintf (gzFile file, const char *format, ...)\n{\n    int size, len;\n    gz_statep state;\n    z_streamp strm;\n    va_list va;\n\n    /* get internal structure */\n    if (file == NULL)\n        return -1;\n    state = (gz_statep)file;\n    strm = &(state->strm);\n\n    /* check that we're writing and that there's no error */\n    if (state->mode != GZ_WRITE || state->err != Z_OK)\n        return 0;\n\n    /* make sure we have some buffer space */\n    if (state->size == 0 && gz_init(state) == -1)\n        return 0;\n\n    /* check for seek request */\n    if (state->seek) {\n        state->seek = 0;\n        if (gz_zero(state, state->skip) == -1)\n            return 0;\n    }\n\n    /* consume whatever's left in the input buffer */\n    if (strm->avail_in && gz_comp(state, Z_NO_FLUSH) == -1)\n        return 0;\n\n    /* do the printf() into the input buffer, put length in len */\n    size = (int)(state->size);\n    state->in[size - 1] = 0;\n    va_start(va, format);\n#ifdef NO_vsnprintf\n#  ifdef HAS_vsprintf_void\n    (void)vsprintf(state->in, format, va);\n    va_end(va);\n    for (len = 0; len < size; len++)\n        if (state->in[len] == 0) break;\n#  else\n    len = vsprintf(state->in, format, va);\n    va_end(va);\n#  endif\n#else\n#  ifdef HAS_vsnprintf_void\n    (void)vsnprintf(state->in, size, format, va);\n    va_end(va);\n    len = strlen(state->in);\n#  else\n    len = vsnprintf((char *)(state->in), size, format, va);\n    va_end(va);\n#  endif\n#endif\n\n    /* check that printf() results fit in buffer */\n    if (len <= 0 || len >= (int)size || state->in[size - 1] != 0)\n        return 0;\n\n    /* update buffer and position, defer compression until needed */\n    strm->avail_in = (unsigned)len;\n    strm->next_in = state->in;\n    state->x.pos += len;\n    return len;\n}\n\n#else /* !STDC && !Z_HAVE_STDARG_H */\n\n/* -- see zlib.h -- */\nint ZEXPORTVA gzprintf (file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,\n                       a11, a12, a13, a14, a15, a16, a17, a18, a19, a20)\n    gzFile file;\n    const char *format;\n    int a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,\n        a11, a12, a13, a14, a15, a16, a17, a18, a19, a20;\n{\n    int size, len;\n    gz_statep state;\n    z_streamp strm;\n\n    /* get internal structure */\n    if (file == NULL)\n        return -1;\n    state = (gz_statep)file;\n    strm = &(state->strm);\n\n    /* check that can really pass pointer in ints */\n    if (sizeof(int) != sizeof(void *))\n        return 0;\n\n    /* check that we're writing and that there's no error */\n    if (state->mode != GZ_WRITE || state->err != Z_OK)\n        return 0;\n\n    /* make sure we have some buffer space */\n    if (state->size == 0 && gz_init(state) == -1)\n        return 0;\n\n    /* check for seek request */\n    if (state->seek) {\n        state->seek = 0;\n        if (gz_zero(state, state->skip) == -1)\n            return 0;\n    }\n\n    /* consume whatever's left in the input buffer */\n    if (strm->avail_in && gz_comp(state, Z_NO_FLUSH) == -1)\n        return 0;\n\n    /* do the printf() into the input buffer, put length in len */\n    size = (int)(state->size);\n    state->in[size - 1] = 0;\n#ifdef NO_snprintf\n#  ifdef HAS_sprintf_void\n    sprintf(state->in, format, a1, a2, a3, a4, a5, a6, a7, a8,\n            a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);\n    for (len = 0; len < size; len++)\n        if (state->in[len] == 0) break;\n#  else\n    len = sprintf(state->in, format, a1, a2, a3, a4, a5, a6, a7, a8,\n                a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);\n#  endif\n#else\n#  ifdef HAS_snprintf_void\n    snprintf(state->in, size, format, a1, a2, a3, a4, a5, a6, a7, a8,\n             a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);\n    len = strlen(state->in);\n#  else\n    len = snprintf(state->in, size, format, a1, a2, a3, a4, a5, a6, a7, a8,\n                 a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);\n#  endif\n#endif\n\n    /* check that printf() results fit in buffer */\n    if (len <= 0 || len >= (int)size || state->in[size - 1] != 0)\n        return 0;\n\n    /* update buffer and position, defer compression until needed */\n    strm->avail_in = (unsigned)len;\n    strm->next_in = state->in;\n    state->x.pos += len;\n    return len;\n}\n\n#endif\n\n/* -- see zlib.h -- */\nint ZEXPORT gzflush(file, flush)\n    gzFile file;\n    int flush;\n{\n    gz_statep state;\n\n    /* get internal structure */\n    if (file == NULL)\n        return -1;\n    state = (gz_statep)file;\n\n    /* check that we're writing and that there's no error */\n    if (state->mode != GZ_WRITE || state->err != Z_OK)\n        return Z_STREAM_ERROR;\n\n    /* check flush parameter */\n    if (flush < 0 || flush > Z_FINISH)\n        return Z_STREAM_ERROR;\n\n    /* check for seek request */\n    if (state->seek) {\n        state->seek = 0;\n        if (gz_zero(state, state->skip) == -1)\n            return -1;\n    }\n\n    /* compress remaining data with requested flush */\n    gz_comp(state, flush);\n    return state->err;\n}\n\n/* -- see zlib.h -- */\nint ZEXPORT gzsetparams(file, level, strategy)\n    gzFile file;\n    int level;\n    int strategy;\n{\n    gz_statep state;\n    z_streamp strm;\n\n    /* get internal structure */\n    if (file == NULL)\n        return Z_STREAM_ERROR;\n    state = (gz_statep)file;\n    strm = &(state->strm);\n\n    /* check that we're writing and that there's no error */\n    if (state->mode != GZ_WRITE || state->err != Z_OK)\n        return Z_STREAM_ERROR;\n\n    /* if no change is requested, then do nothing */\n    if (level == state->level && strategy == state->strategy)\n        return Z_OK;\n\n    /* check for seek request */\n    if (state->seek) {\n        state->seek = 0;\n        if (gz_zero(state, state->skip) == -1)\n            return -1;\n    }\n\n    /* change compression parameters for subsequent input */\n    if (state->size) {\n        /* flush previous input with previous parameters before changing */\n        if (strm->avail_in && gz_comp(state, Z_PARTIAL_FLUSH) == -1)\n            return state->err;\n        deflateParams(strm, level, strategy);\n    }\n    state->level = level;\n    state->strategy = strategy;\n    return Z_OK;\n}\n\n/* -- see zlib.h -- */\nint ZEXPORT gzclose_w(file)\n    gzFile file;\n{\n    int ret = Z_OK;\n    gz_statep state;\n\n    /* get internal structure */\n    if (file == NULL)\n        return Z_STREAM_ERROR;\n    state = (gz_statep)file;\n\n    /* check that we're writing */\n    if (state->mode != GZ_WRITE)\n        return Z_STREAM_ERROR;\n\n    /* check for seek request */\n    if (state->seek) {\n        state->seek = 0;\n        if (gz_zero(state, state->skip) == -1)\n            ret = state->err;\n    }\n\n    /* flush, free memory, and close file */\n    if (gz_comp(state, Z_FINISH) == -1)\n        ret = state->err;\n    if (!state->direct) {\n        (void)deflateEnd(&(state->strm));\n        free(state->out);\n    }\n    free(state->in);\n    gz_error(state, Z_OK, NULL);\n    free(state->path);\n    if (close(state->fd) == -1)\n        ret = Z_ERRNO;\n    free(state);\n    return ret;\n}\n\n/* used by zlibVersion() to get the vsnprintf story from the horse's mouth */\nunsigned long ZEXPORT gzflags()\n{\n    unsigned long flags = 0;\n#if defined(STDC) || defined(Z_HAVE_STDARG_H)\n#  ifdef NO_vsnprintf\n    flags += 1L << 25;\n#    ifdef HAS_vsprintf_void\n    flags += 1L << 26;\n#    endif\n#  else\n#    ifdef HAS_vsnprintf_void\n    flags += 1L << 26;\n#    endif\n#  endif\n#else\n    flags += 1L << 24;\n#  ifdef NO_snprintf\n    flags += 1L << 25;\n#    ifdef HAS_sprintf_void\n    flags += 1L << 26;\n#    endif\n#  else\n#    ifdef HAS_snprintf_void\n    flags += 1L << 26;\n#    endif\n#  endif\n#endif\n    return flags;\n}\n"
  },
  {
    "path": "Projects/Tools/PNGAlphaPremultiplier/Native/Source/ZLib/infback.c",
    "content": "/* infback.c -- inflate using a call-back interface\n * Copyright (C) 1995-2011 Mark Adler\n * For conditions of distribution and use, see copyright notice in zlib.h\n */\n\n/*\n   This code is largely copied from inflate.c.  Normally either infback.o or\n   inflate.o would be linked into an application--not both.  The interface\n   with inffast.c is retained so that optimized assembler-coded versions of\n   inflate_fast() can be used with either inflate.c or infback.c.\n */\n\n#include \"zutil.h\"\n#include \"inftrees.h\"\n#include \"inflate.h\"\n#include \"inffast.h\"\n\n/* function prototypes */\nlocal void fixedtables OF((struct inflate_state FAR *state));\n\n/*\n   strm provides memory allocation functions in zalloc and zfree, or\n   Z_NULL to use the library memory allocation functions.\n\n   windowBits is in the range 8..15, and window is a user-supplied\n   window and output buffer that is 2**windowBits bytes.\n */\nint ZEXPORT inflateBackInit_(strm, windowBits, window, version, stream_size)\nz_streamp strm;\nint windowBits;\nunsigned char FAR *window;\nconst char *version;\nint stream_size;\n{\n    struct inflate_state FAR *state;\n\n    if (version == Z_NULL || version[0] != ZLIB_VERSION[0] ||\n        stream_size != (int)(sizeof(z_stream)))\n        return Z_VERSION_ERROR;\n    if (strm == Z_NULL || window == Z_NULL ||\n        windowBits < 8 || windowBits > 15)\n        return Z_STREAM_ERROR;\n    strm->msg = Z_NULL;                 /* in case we return an error */\n    if (strm->zalloc == (alloc_func)0) {\n#ifdef Z_SOLO\n        return Z_STREAM_ERROR;\n#else\n        strm->zalloc = zcalloc;\n        strm->opaque = (voidpf)0;\n#endif\n    }\n    if (strm->zfree == (free_func)0)\n#ifdef Z_SOLO\n        return Z_STREAM_ERROR;\n#else\n    strm->zfree = zcfree;\n#endif\n    state = (struct inflate_state FAR *)ZALLOC(strm, 1,\n                                               sizeof(struct inflate_state));\n    if (state == Z_NULL) return Z_MEM_ERROR;\n    Tracev((stderr, \"inflate: allocated\\n\"));\n    strm->state = (struct internal_state FAR *)state;\n    state->dmax = 32768U;\n    state->wbits = windowBits;\n    state->wsize = 1U << windowBits;\n    state->window = window;\n    state->wnext = 0;\n    state->whave = 0;\n    return Z_OK;\n}\n\n/*\n   Return state with length and distance decoding tables and index sizes set to\n   fixed code decoding.  Normally this returns fixed tables from inffixed.h.\n   If BUILDFIXED is defined, then instead this routine builds the tables the\n   first time it's called, and returns those tables the first time and\n   thereafter.  This reduces the size of the code by about 2K bytes, in\n   exchange for a little execution time.  However, BUILDFIXED should not be\n   used for threaded applications, since the rewriting of the tables and virgin\n   may not be thread-safe.\n */\nlocal void fixedtables(state)\nstruct inflate_state FAR *state;\n{\n#ifdef BUILDFIXED\n    static int virgin = 1;\n    static code *lenfix, *distfix;\n    static code fixed[544];\n\n    /* build fixed huffman tables if first call (may not be thread safe) */\n    if (virgin) {\n        unsigned sym, bits;\n        static code *next;\n\n        /* literal/length table */\n        sym = 0;\n        while (sym < 144) state->lens[sym++] = 8;\n        while (sym < 256) state->lens[sym++] = 9;\n        while (sym < 280) state->lens[sym++] = 7;\n        while (sym < 288) state->lens[sym++] = 8;\n        next = fixed;\n        lenfix = next;\n        bits = 9;\n        inflate_table(LENS, state->lens, 288, &(next), &(bits), state->work);\n\n        /* distance table */\n        sym = 0;\n        while (sym < 32) state->lens[sym++] = 5;\n        distfix = next;\n        bits = 5;\n        inflate_table(DISTS, state->lens, 32, &(next), &(bits), state->work);\n\n        /* do this just once */\n        virgin = 0;\n    }\n#else /* !BUILDFIXED */\n#   include \"inffixed.h\"\n#endif /* BUILDFIXED */\n    state->lencode = lenfix;\n    state->lenbits = 9;\n    state->distcode = distfix;\n    state->distbits = 5;\n}\n\n/* Macros for inflateBack(): */\n\n/* Load returned state from inflate_fast() */\n#define LOAD() \\\n    do { \\\n        put = strm->next_out; \\\n        left = strm->avail_out; \\\n        next = strm->next_in; \\\n        have = strm->avail_in; \\\n        hold = state->hold; \\\n        bits = state->bits; \\\n    } while (0)\n\n/* Set state from registers for inflate_fast() */\n#define RESTORE() \\\n    do { \\\n        strm->next_out = put; \\\n        strm->avail_out = left; \\\n        strm->next_in = next; \\\n        strm->avail_in = have; \\\n        state->hold = hold; \\\n        state->bits = bits; \\\n    } while (0)\n\n/* Clear the input bit accumulator */\n#define INITBITS() \\\n    do { \\\n        hold = 0; \\\n        bits = 0; \\\n    } while (0)\n\n/* Assure that some input is available.  If input is requested, but denied,\n   then return a Z_BUF_ERROR from inflateBack(). */\n#define PULL() \\\n    do { \\\n        if (have == 0) { \\\n            have = in(in_desc, &next); \\\n            if (have == 0) { \\\n                next = Z_NULL; \\\n                ret = Z_BUF_ERROR; \\\n                goto inf_leave; \\\n            } \\\n        } \\\n    } while (0)\n\n/* Get a byte of input into the bit accumulator, or return from inflateBack()\n   with an error if there is no input available. */\n#define PULLBYTE() \\\n    do { \\\n        PULL(); \\\n        have--; \\\n        hold += (unsigned long)(*next++) << bits; \\\n        bits += 8; \\\n    } while (0)\n\n/* Assure that there are at least n bits in the bit accumulator.  If there is\n   not enough available input to do that, then return from inflateBack() with\n   an error. */\n#define NEEDBITS(n) \\\n    do { \\\n        while (bits < (unsigned)(n)) \\\n            PULLBYTE(); \\\n    } while (0)\n\n/* Return the low n bits of the bit accumulator (n < 16) */\n#define BITS(n) \\\n    ((unsigned)hold & ((1U << (n)) - 1))\n\n/* Remove n bits from the bit accumulator */\n#define DROPBITS(n) \\\n    do { \\\n        hold >>= (n); \\\n        bits -= (unsigned)(n); \\\n    } while (0)\n\n/* Remove zero to seven bits as needed to go to a byte boundary */\n#define BYTEBITS() \\\n    do { \\\n        hold >>= bits & 7; \\\n        bits -= bits & 7; \\\n    } while (0)\n\n/* Assure that some output space is available, by writing out the window\n   if it's full.  If the write fails, return from inflateBack() with a\n   Z_BUF_ERROR. */\n#define ROOM() \\\n    do { \\\n        if (left == 0) { \\\n            put = state->window; \\\n            left = state->wsize; \\\n            state->whave = left; \\\n            if (out(out_desc, put, left)) { \\\n                ret = Z_BUF_ERROR; \\\n                goto inf_leave; \\\n            } \\\n        } \\\n    } while (0)\n\n/*\n   strm provides the memory allocation functions and window buffer on input,\n   and provides information on the unused input on return.  For Z_DATA_ERROR\n   returns, strm will also provide an error message.\n\n   in() and out() are the call-back input and output functions.  When\n   inflateBack() needs more input, it calls in().  When inflateBack() has\n   filled the window with output, or when it completes with data in the\n   window, it calls out() to write out the data.  The application must not\n   change the provided input until in() is called again or inflateBack()\n   returns.  The application must not change the window/output buffer until\n   inflateBack() returns.\n\n   in() and out() are called with a descriptor parameter provided in the\n   inflateBack() call.  This parameter can be a structure that provides the\n   information required to do the read or write, as well as accumulated\n   information on the input and output such as totals and check values.\n\n   in() should return zero on failure.  out() should return non-zero on\n   failure.  If either in() or out() fails, than inflateBack() returns a\n   Z_BUF_ERROR.  strm->next_in can be checked for Z_NULL to see whether it\n   was in() or out() that caused in the error.  Otherwise,  inflateBack()\n   returns Z_STREAM_END on success, Z_DATA_ERROR for an deflate format\n   error, or Z_MEM_ERROR if it could not allocate memory for the state.\n   inflateBack() can also return Z_STREAM_ERROR if the input parameters\n   are not correct, i.e. strm is Z_NULL or the state was not initialized.\n */\nint ZEXPORT inflateBack(strm, in, in_desc, out, out_desc)\nz_streamp strm;\nin_func in;\nvoid FAR *in_desc;\nout_func out;\nvoid FAR *out_desc;\n{\n    struct inflate_state FAR *state;\n    unsigned char FAR *next;    /* next input */\n    unsigned char FAR *put;     /* next output */\n    unsigned have, left;        /* available input and output */\n    unsigned long hold;         /* bit buffer */\n    unsigned bits;              /* bits in bit buffer */\n    unsigned copy;              /* number of stored or match bytes to copy */\n    unsigned char FAR *from;    /* where to copy match bytes from */\n    code here;                  /* current decoding table entry */\n    code last;                  /* parent table entry */\n    unsigned len;               /* length to copy for repeats, bits to drop */\n    int ret;                    /* return code */\n    static const unsigned short order[19] = /* permutation of code lengths */\n        {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};\n\n    /* Check that the strm exists and that the state was initialized */\n    if (strm == Z_NULL || strm->state == Z_NULL)\n        return Z_STREAM_ERROR;\n    state = (struct inflate_state FAR *)strm->state;\n\n    /* Reset the state */\n    strm->msg = Z_NULL;\n    state->mode = TYPE;\n    state->last = 0;\n    state->whave = 0;\n    next = strm->next_in;\n    have = next != Z_NULL ? strm->avail_in : 0;\n    hold = 0;\n    bits = 0;\n    put = state->window;\n    left = state->wsize;\n\n    /* Inflate until end of block marked as last */\n    for (;;)\n        switch (state->mode) {\n        case TYPE:\n            /* determine and dispatch block type */\n            if (state->last) {\n                BYTEBITS();\n                state->mode = DONE;\n                break;\n            }\n            NEEDBITS(3);\n            state->last = BITS(1);\n            DROPBITS(1);\n            switch (BITS(2)) {\n            case 0:                             /* stored block */\n                Tracev((stderr, \"inflate:     stored block%s\\n\",\n                        state->last ? \" (last)\" : \"\"));\n                state->mode = STORED;\n                break;\n            case 1:                             /* fixed block */\n                fixedtables(state);\n                Tracev((stderr, \"inflate:     fixed codes block%s\\n\",\n                        state->last ? \" (last)\" : \"\"));\n                state->mode = LEN;              /* decode codes */\n                break;\n            case 2:                             /* dynamic block */\n                Tracev((stderr, \"inflate:     dynamic codes block%s\\n\",\n                        state->last ? \" (last)\" : \"\"));\n                state->mode = TABLE;\n                break;\n            case 3:\n                strm->msg = (char *)\"invalid block type\";\n                state->mode = BAD;\n            }\n            DROPBITS(2);\n            break;\n\n        case STORED:\n            /* get and verify stored block length */\n            BYTEBITS();                         /* go to byte boundary */\n            NEEDBITS(32);\n            if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) {\n                strm->msg = (char *)\"invalid stored block lengths\";\n                state->mode = BAD;\n                break;\n            }\n            state->length = (unsigned)hold & 0xffff;\n            Tracev((stderr, \"inflate:       stored length %u\\n\",\n                    state->length));\n            INITBITS();\n\n            /* copy stored block from input to output */\n            while (state->length != 0) {\n                copy = state->length;\n                PULL();\n                ROOM();\n                if (copy > have) copy = have;\n                if (copy > left) copy = left;\n                zmemcpy(put, next, copy);\n                have -= copy;\n                next += copy;\n                left -= copy;\n                put += copy;\n                state->length -= copy;\n            }\n            Tracev((stderr, \"inflate:       stored end\\n\"));\n            state->mode = TYPE;\n            break;\n\n        case TABLE:\n            /* get dynamic table entries descriptor */\n            NEEDBITS(14);\n            state->nlen = BITS(5) + 257;\n            DROPBITS(5);\n            state->ndist = BITS(5) + 1;\n            DROPBITS(5);\n            state->ncode = BITS(4) + 4;\n            DROPBITS(4);\n#ifndef PKZIP_BUG_WORKAROUND\n            if (state->nlen > 286 || state->ndist > 30) {\n                strm->msg = (char *)\"too many length or distance symbols\";\n                state->mode = BAD;\n                break;\n            }\n#endif\n            Tracev((stderr, \"inflate:       table sizes ok\\n\"));\n\n            /* get code length code lengths (not a typo) */\n            state->have = 0;\n            while (state->have < state->ncode) {\n                NEEDBITS(3);\n                state->lens[order[state->have++]] = (unsigned short)BITS(3);\n                DROPBITS(3);\n            }\n            while (state->have < 19)\n                state->lens[order[state->have++]] = 0;\n            state->next = state->codes;\n            state->lencode = (code const FAR *)(state->next);\n            state->lenbits = 7;\n            ret = inflate_table(CODES, state->lens, 19, &(state->next),\n                                &(state->lenbits), state->work);\n            if (ret) {\n                strm->msg = (char *)\"invalid code lengths set\";\n                state->mode = BAD;\n                break;\n            }\n            Tracev((stderr, \"inflate:       code lengths ok\\n\"));\n\n            /* get length and distance code code lengths */\n            state->have = 0;\n            while (state->have < state->nlen + state->ndist) {\n                for (;;) {\n                    here = state->lencode[BITS(state->lenbits)];\n                    if ((unsigned)(here.bits) <= bits) break;\n                    PULLBYTE();\n                }\n                if (here.val < 16) {\n                    DROPBITS(here.bits);\n                    state->lens[state->have++] = here.val;\n                }\n                else {\n                    if (here.val == 16) {\n                        NEEDBITS(here.bits + 2);\n                        DROPBITS(here.bits);\n                        if (state->have == 0) {\n                            strm->msg = (char *)\"invalid bit length repeat\";\n                            state->mode = BAD;\n                            break;\n                        }\n                        len = (unsigned)(state->lens[state->have - 1]);\n                        copy = 3 + BITS(2);\n                        DROPBITS(2);\n                    }\n                    else if (here.val == 17) {\n                        NEEDBITS(here.bits + 3);\n                        DROPBITS(here.bits);\n                        len = 0;\n                        copy = 3 + BITS(3);\n                        DROPBITS(3);\n                    }\n                    else {\n                        NEEDBITS(here.bits + 7);\n                        DROPBITS(here.bits);\n                        len = 0;\n                        copy = 11 + BITS(7);\n                        DROPBITS(7);\n                    }\n                    if (state->have + copy > state->nlen + state->ndist) {\n                        strm->msg = (char *)\"invalid bit length repeat\";\n                        state->mode = BAD;\n                        break;\n                    }\n                    while (copy--)\n                        state->lens[state->have++] = (unsigned short)len;\n                }\n            }\n\n            /* handle error breaks in while */\n            if (state->mode == BAD) break;\n\n            /* check for end-of-block code (better have one) */\n            if (state->lens[256] == 0) {\n                strm->msg = (char *)\"invalid code -- missing end-of-block\";\n                state->mode = BAD;\n                break;\n            }\n\n            /* build code tables -- note: do not change the lenbits or distbits\n               values here (9 and 6) without reading the comments in inftrees.h\n               concerning the ENOUGH constants, which depend on those values */\n            state->next = state->codes;\n            state->lencode = (code const FAR *)(state->next);\n            state->lenbits = 9;\n            ret = inflate_table(LENS, state->lens, state->nlen, &(state->next),\n                                &(state->lenbits), state->work);\n            if (ret) {\n                strm->msg = (char *)\"invalid literal/lengths set\";\n                state->mode = BAD;\n                break;\n            }\n            state->distcode = (code const FAR *)(state->next);\n            state->distbits = 6;\n            ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist,\n                            &(state->next), &(state->distbits), state->work);\n            if (ret) {\n                strm->msg = (char *)\"invalid distances set\";\n                state->mode = BAD;\n                break;\n            }\n            Tracev((stderr, \"inflate:       codes ok\\n\"));\n            state->mode = LEN;\n\n        case LEN:\n            /* use inflate_fast() if we have enough input and output */\n            if (have >= 6 && left >= 258) {\n                RESTORE();\n                if (state->whave < state->wsize)\n                    state->whave = state->wsize - left;\n                inflate_fast(strm, state->wsize);\n                LOAD();\n                break;\n            }\n\n            /* get a literal, length, or end-of-block code */\n            for (;;) {\n                here = state->lencode[BITS(state->lenbits)];\n                if ((unsigned)(here.bits) <= bits) break;\n                PULLBYTE();\n            }\n            if (here.op && (here.op & 0xf0) == 0) {\n                last = here;\n                for (;;) {\n                    here = state->lencode[last.val +\n                            (BITS(last.bits + last.op) >> last.bits)];\n                    if ((unsigned)(last.bits + here.bits) <= bits) break;\n                    PULLBYTE();\n                }\n                DROPBITS(last.bits);\n            }\n            DROPBITS(here.bits);\n            state->length = (unsigned)here.val;\n\n            /* process literal */\n            if (here.op == 0) {\n                Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?\n                        \"inflate:         literal '%c'\\n\" :\n                        \"inflate:         literal 0x%02x\\n\", here.val));\n                ROOM();\n                *put++ = (unsigned char)(state->length);\n                left--;\n                state->mode = LEN;\n                break;\n            }\n\n            /* process end of block */\n            if (here.op & 32) {\n                Tracevv((stderr, \"inflate:         end of block\\n\"));\n                state->mode = TYPE;\n                break;\n            }\n\n            /* invalid code */\n            if (here.op & 64) {\n                strm->msg = (char *)\"invalid literal/length code\";\n                state->mode = BAD;\n                break;\n            }\n\n            /* length code -- get extra bits, if any */\n            state->extra = (unsigned)(here.op) & 15;\n            if (state->extra != 0) {\n                NEEDBITS(state->extra);\n                state->length += BITS(state->extra);\n                DROPBITS(state->extra);\n            }\n            Tracevv((stderr, \"inflate:         length %u\\n\", state->length));\n\n            /* get distance code */\n            for (;;) {\n                here = state->distcode[BITS(state->distbits)];\n                if ((unsigned)(here.bits) <= bits) break;\n                PULLBYTE();\n            }\n            if ((here.op & 0xf0) == 0) {\n                last = here;\n                for (;;) {\n                    here = state->distcode[last.val +\n                            (BITS(last.bits + last.op) >> last.bits)];\n                    if ((unsigned)(last.bits + here.bits) <= bits) break;\n                    PULLBYTE();\n                }\n                DROPBITS(last.bits);\n            }\n            DROPBITS(here.bits);\n            if (here.op & 64) {\n                strm->msg = (char *)\"invalid distance code\";\n                state->mode = BAD;\n                break;\n            }\n            state->offset = (unsigned)here.val;\n\n            /* get distance extra bits, if any */\n            state->extra = (unsigned)(here.op) & 15;\n            if (state->extra != 0) {\n                NEEDBITS(state->extra);\n                state->offset += BITS(state->extra);\n                DROPBITS(state->extra);\n            }\n            if (state->offset > state->wsize - (state->whave < state->wsize ?\n                                                left : 0)) {\n                strm->msg = (char *)\"invalid distance too far back\";\n                state->mode = BAD;\n                break;\n            }\n            Tracevv((stderr, \"inflate:         distance %u\\n\", state->offset));\n\n            /* copy match from window to output */\n            do {\n                ROOM();\n                copy = state->wsize - state->offset;\n                if (copy < left) {\n                    from = put + copy;\n                    copy = left - copy;\n                }\n                else {\n                    from = put - state->offset;\n                    copy = left;\n                }\n                if (copy > state->length) copy = state->length;\n                state->length -= copy;\n                left -= copy;\n                do {\n                    *put++ = *from++;\n                } while (--copy);\n            } while (state->length != 0);\n            break;\n\n        case DONE:\n            /* inflate stream terminated properly -- write leftover output */\n            ret = Z_STREAM_END;\n            if (left < state->wsize) {\n                if (out(out_desc, state->window, state->wsize - left))\n                    ret = Z_BUF_ERROR;\n            }\n            goto inf_leave;\n\n        case BAD:\n            ret = Z_DATA_ERROR;\n            goto inf_leave;\n\n        default:                /* can't happen, but makes compilers happy */\n            ret = Z_STREAM_ERROR;\n            goto inf_leave;\n        }\n\n    /* Return unused input */\n  inf_leave:\n    strm->next_in = next;\n    strm->avail_in = have;\n    return ret;\n}\n\nint ZEXPORT inflateBackEnd(strm)\nz_streamp strm;\n{\n    if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0)\n        return Z_STREAM_ERROR;\n    ZFREE(strm, strm->state);\n    strm->state = Z_NULL;\n    Tracev((stderr, \"inflate: end\\n\"));\n    return Z_OK;\n}\n"
  },
  {
    "path": "Projects/Tools/PNGAlphaPremultiplier/Native/Source/ZLib/inffast.c",
    "content": "/* inffast.c -- fast decoding\n * Copyright (C) 1995-2008, 2010 Mark Adler\n * For conditions of distribution and use, see copyright notice in zlib.h\n */\n\n#include \"zutil.h\"\n#include \"inftrees.h\"\n#include \"inflate.h\"\n#include \"inffast.h\"\n\n#ifndef ASMINF\n\n/* Allow machine dependent optimization for post-increment or pre-increment.\n   Based on testing to date,\n   Pre-increment preferred for:\n   - PowerPC G3 (Adler)\n   - MIPS R5000 (Randers-Pehrson)\n   Post-increment preferred for:\n   - none\n   No measurable difference:\n   - Pentium III (Anderson)\n   - M68060 (Nikl)\n */\n#ifdef POSTINC\n#  define OFF 0\n#  define PUP(a) *(a)++\n#else\n#  define OFF 1\n#  define PUP(a) *++(a)\n#endif\n\n/*\n   Decode literal, length, and distance codes and write out the resulting\n   literal and match bytes until either not enough input or output is\n   available, an end-of-block is encountered, or a data error is encountered.\n   When large enough input and output buffers are supplied to inflate(), for\n   example, a 16K input buffer and a 64K output buffer, more than 95% of the\n   inflate execution time is spent in this routine.\n\n   Entry assumptions:\n\n        state->mode == LEN\n        strm->avail_in >= 6\n        strm->avail_out >= 258\n        start >= strm->avail_out\n        state->bits < 8\n\n   On return, state->mode is one of:\n\n        LEN -- ran out of enough output space or enough available input\n        TYPE -- reached end of block code, inflate() to interpret next block\n        BAD -- error in block data\n\n   Notes:\n\n    - The maximum input bits used by a length/distance pair is 15 bits for the\n      length code, 5 bits for the length extra, 15 bits for the distance code,\n      and 13 bits for the distance extra.  This totals 48 bits, or six bytes.\n      Therefore if strm->avail_in >= 6, then there is enough input to avoid\n      checking for available input while decoding.\n\n    - The maximum bytes that a single length/distance pair can output is 258\n      bytes, which is the maximum length that can be coded.  inflate_fast()\n      requires strm->avail_out >= 258 for each loop to avoid checking for\n      output space.\n */\nvoid ZLIB_INTERNAL inflate_fast(strm, start)\nz_streamp strm;\nunsigned start;         /* inflate()'s starting value for strm->avail_out */\n{\n    struct inflate_state FAR *state;\n    unsigned char FAR *in;      /* local strm->next_in */\n    unsigned char FAR *last;    /* while in < last, enough input available */\n    unsigned char FAR *out;     /* local strm->next_out */\n    unsigned char FAR *beg;     /* inflate()'s initial strm->next_out */\n    unsigned char FAR *end;     /* while out < end, enough space available */\n#ifdef INFLATE_STRICT\n    unsigned dmax;              /* maximum distance from zlib header */\n#endif\n    unsigned wsize;             /* window size or zero if not using window */\n    unsigned whave;             /* valid bytes in the window */\n    unsigned wnext;             /* window write index */\n    unsigned char FAR *window;  /* allocated sliding window, if wsize != 0 */\n    unsigned long hold;         /* local strm->hold */\n    unsigned bits;              /* local strm->bits */\n    code const FAR *lcode;      /* local strm->lencode */\n    code const FAR *dcode;      /* local strm->distcode */\n    unsigned lmask;             /* mask for first level of length codes */\n    unsigned dmask;             /* mask for first level of distance codes */\n    code here;                  /* retrieved table entry */\n    unsigned op;                /* code bits, operation, extra bits, or */\n                                /*  window position, window bytes to copy */\n    unsigned len;               /* match length, unused bytes */\n    unsigned dist;              /* match distance */\n    unsigned char FAR *from;    /* where to copy match from */\n\n    /* copy state to local variables */\n    state = (struct inflate_state FAR *)strm->state;\n    in = strm->next_in - OFF;\n    last = in + (strm->avail_in - 5);\n    out = strm->next_out - OFF;\n    beg = out - (start - strm->avail_out);\n    end = out + (strm->avail_out - 257);\n#ifdef INFLATE_STRICT\n    dmax = state->dmax;\n#endif\n    wsize = state->wsize;\n    whave = state->whave;\n    wnext = state->wnext;\n    window = state->window;\n    hold = state->hold;\n    bits = state->bits;\n    lcode = state->lencode;\n    dcode = state->distcode;\n    lmask = (1U << state->lenbits) - 1;\n    dmask = (1U << state->distbits) - 1;\n\n    /* decode literals and length/distances until end-of-block or not enough\n       input data or output space */\n    do {\n        if (bits < 15) {\n            hold += (unsigned long)(PUP(in)) << bits;\n            bits += 8;\n            hold += (unsigned long)(PUP(in)) << bits;\n            bits += 8;\n        }\n        here = lcode[hold & lmask];\n      dolen:\n        op = (unsigned)(here.bits);\n        hold >>= op;\n        bits -= op;\n        op = (unsigned)(here.op);\n        if (op == 0) {                          /* literal */\n            Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?\n                    \"inflate:         literal '%c'\\n\" :\n                    \"inflate:         literal 0x%02x\\n\", here.val));\n            PUP(out) = (unsigned char)(here.val);\n        }\n        else if (op & 16) {                     /* length base */\n            len = (unsigned)(here.val);\n            op &= 15;                           /* number of extra bits */\n            if (op) {\n                if (bits < op) {\n                    hold += (unsigned long)(PUP(in)) << bits;\n                    bits += 8;\n                }\n                len += (unsigned)hold & ((1U << op) - 1);\n                hold >>= op;\n                bits -= op;\n            }\n            Tracevv((stderr, \"inflate:         length %u\\n\", len));\n            if (bits < 15) {\n                hold += (unsigned long)(PUP(in)) << bits;\n                bits += 8;\n                hold += (unsigned long)(PUP(in)) << bits;\n                bits += 8;\n            }\n            here = dcode[hold & dmask];\n          dodist:\n            op = (unsigned)(here.bits);\n            hold >>= op;\n            bits -= op;\n            op = (unsigned)(here.op);\n            if (op & 16) {                      /* distance base */\n                dist = (unsigned)(here.val);\n                op &= 15;                       /* number of extra bits */\n                if (bits < op) {\n                    hold += (unsigned long)(PUP(in)) << bits;\n                    bits += 8;\n                    if (bits < op) {\n                        hold += (unsigned long)(PUP(in)) << bits;\n                        bits += 8;\n                    }\n                }\n                dist += (unsigned)hold & ((1U << op) - 1);\n#ifdef INFLATE_STRICT\n                if (dist > dmax) {\n                    strm->msg = (char *)\"invalid distance too far back\";\n                    state->mode = BAD;\n                    break;\n                }\n#endif\n                hold >>= op;\n                bits -= op;\n                Tracevv((stderr, \"inflate:         distance %u\\n\", dist));\n                op = (unsigned)(out - beg);     /* max distance in output */\n                if (dist > op) {                /* see if copy from window */\n                    op = dist - op;             /* distance back in window */\n                    if (op > whave) {\n                        if (state->sane) {\n                            strm->msg =\n                                (char *)\"invalid distance too far back\";\n                            state->mode = BAD;\n                            break;\n                        }\n#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR\n                        if (len <= op - whave) {\n                            do {\n                                PUP(out) = 0;\n                            } while (--len);\n                            continue;\n                        }\n                        len -= op - whave;\n                        do {\n                            PUP(out) = 0;\n                        } while (--op > whave);\n                        if (op == 0) {\n                            from = out - dist;\n                            do {\n                                PUP(out) = PUP(from);\n                            } while (--len);\n                            continue;\n                        }\n#endif\n                    }\n                    from = window - OFF;\n                    if (wnext == 0) {           /* very common case */\n                        from += wsize - op;\n                        if (op < len) {         /* some from window */\n                            len -= op;\n                            do {\n                                PUP(out) = PUP(from);\n                            } while (--op);\n                            from = out - dist;  /* rest from output */\n                        }\n                    }\n                    else if (wnext < op) {      /* wrap around window */\n                        from += wsize + wnext - op;\n                        op -= wnext;\n                        if (op < len) {         /* some from end of window */\n                            len -= op;\n                            do {\n                                PUP(out) = PUP(from);\n                            } while (--op);\n                            from = window - OFF;\n                            if (wnext < len) {  /* some from start of window */\n                                op = wnext;\n                                len -= op;\n                                do {\n                                    PUP(out) = PUP(from);\n                                } while (--op);\n                                from = out - dist;      /* rest from output */\n                            }\n                        }\n                    }\n                    else {                      /* contiguous in window */\n                        from += wnext - op;\n                        if (op < len) {         /* some from window */\n                            len -= op;\n                            do {\n                                PUP(out) = PUP(from);\n                            } while (--op);\n                            from = out - dist;  /* rest from output */\n                        }\n                    }\n                    while (len > 2) {\n                        PUP(out) = PUP(from);\n                        PUP(out) = PUP(from);\n                        PUP(out) = PUP(from);\n                        len -= 3;\n                    }\n                    if (len) {\n                        PUP(out) = PUP(from);\n                        if (len > 1)\n                            PUP(out) = PUP(from);\n                    }\n                }\n                else {\n                    from = out - dist;          /* copy direct from output */\n                    do {                        /* minimum length is three */\n                        PUP(out) = PUP(from);\n                        PUP(out) = PUP(from);\n                        PUP(out) = PUP(from);\n                        len -= 3;\n                    } while (len > 2);\n                    if (len) {\n                        PUP(out) = PUP(from);\n                        if (len > 1)\n                            PUP(out) = PUP(from);\n                    }\n                }\n            }\n            else if ((op & 64) == 0) {          /* 2nd level distance code */\n                here = dcode[here.val + (hold & ((1U << op) - 1))];\n                goto dodist;\n            }\n            else {\n                strm->msg = (char *)\"invalid distance code\";\n                state->mode = BAD;\n                break;\n            }\n        }\n        else if ((op & 64) == 0) {              /* 2nd level length code */\n            here = lcode[here.val + (hold & ((1U << op) - 1))];\n            goto dolen;\n        }\n        else if (op & 32) {                     /* end-of-block */\n            Tracevv((stderr, \"inflate:         end of block\\n\"));\n            state->mode = TYPE;\n            break;\n        }\n        else {\n            strm->msg = (char *)\"invalid literal/length code\";\n            state->mode = BAD;\n            break;\n        }\n    } while (in < last && out < end);\n\n    /* return unused bytes (on entry, bits < 8, so in won't go too far back) */\n    len = bits >> 3;\n    in -= len;\n    bits -= len << 3;\n    hold &= (1U << bits) - 1;\n\n    /* update state and return */\n    strm->next_in = in + OFF;\n    strm->next_out = out + OFF;\n    strm->avail_in = (unsigned)(in < last ? 5 + (last - in) : 5 - (in - last));\n    strm->avail_out = (unsigned)(out < end ?\n                                 257 + (end - out) : 257 - (out - end));\n    state->hold = hold;\n    state->bits = bits;\n    return;\n}\n\n/*\n   inflate_fast() speedups that turned out slower (on a PowerPC G3 750CXe):\n   - Using bit fields for code structure\n   - Different op definition to avoid & for extra bits (do & for table bits)\n   - Three separate decoding do-loops for direct, window, and wnext == 0\n   - Special case for distance > 1 copies to do overlapped load and store copy\n   - Explicit branch predictions (based on measured branch probabilities)\n   - Deferring match copy and interspersed it with decoding subsequent codes\n   - Swapping literal/length else\n   - Swapping window/direct else\n   - Larger unrolled copy loops (three is about right)\n   - Moving len -= 3 statement into middle of loop\n */\n\n#endif /* !ASMINF */\n"
  },
  {
    "path": "Projects/Tools/PNGAlphaPremultiplier/Native/Source/ZLib/inffast.h",
    "content": "/* inffast.h -- header to use inffast.c\n * Copyright (C) 1995-2003, 2010 Mark Adler\n * For conditions of distribution and use, see copyright notice in zlib.h\n */\n\n/* WARNING: this file should *not* be used by applications. It is\n   part of the implementation of the compression library and is\n   subject to change. Applications should only use zlib.h.\n */\n\nvoid ZLIB_INTERNAL inflate_fast OF((z_streamp strm, unsigned start));\n"
  },
  {
    "path": "Projects/Tools/PNGAlphaPremultiplier/Native/Source/ZLib/inffixed.h",
    "content": "    /* inffixed.h -- table for decoding fixed codes\n     * Generated automatically by makefixed().\n     */\n\n    /* WARNING: this file should *not* be used by applications.\n       It is part of the implementation of this library and is\n       subject to change. Applications should only use zlib.h.\n     */\n\n    static const code lenfix[512] = {\n        {96,7,0},{0,8,80},{0,8,16},{20,8,115},{18,7,31},{0,8,112},{0,8,48},\n        {0,9,192},{16,7,10},{0,8,96},{0,8,32},{0,9,160},{0,8,0},{0,8,128},\n        {0,8,64},{0,9,224},{16,7,6},{0,8,88},{0,8,24},{0,9,144},{19,7,59},\n        {0,8,120},{0,8,56},{0,9,208},{17,7,17},{0,8,104},{0,8,40},{0,9,176},\n        {0,8,8},{0,8,136},{0,8,72},{0,9,240},{16,7,4},{0,8,84},{0,8,20},\n        {21,8,227},{19,7,43},{0,8,116},{0,8,52},{0,9,200},{17,7,13},{0,8,100},\n        {0,8,36},{0,9,168},{0,8,4},{0,8,132},{0,8,68},{0,9,232},{16,7,8},\n        {0,8,92},{0,8,28},{0,9,152},{20,7,83},{0,8,124},{0,8,60},{0,9,216},\n        {18,7,23},{0,8,108},{0,8,44},{0,9,184},{0,8,12},{0,8,140},{0,8,76},\n        {0,9,248},{16,7,3},{0,8,82},{0,8,18},{21,8,163},{19,7,35},{0,8,114},\n        {0,8,50},{0,9,196},{17,7,11},{0,8,98},{0,8,34},{0,9,164},{0,8,2},\n        {0,8,130},{0,8,66},{0,9,228},{16,7,7},{0,8,90},{0,8,26},{0,9,148},\n        {20,7,67},{0,8,122},{0,8,58},{0,9,212},{18,7,19},{0,8,106},{0,8,42},\n        {0,9,180},{0,8,10},{0,8,138},{0,8,74},{0,9,244},{16,7,5},{0,8,86},\n        {0,8,22},{64,8,0},{19,7,51},{0,8,118},{0,8,54},{0,9,204},{17,7,15},\n        {0,8,102},{0,8,38},{0,9,172},{0,8,6},{0,8,134},{0,8,70},{0,9,236},\n        {16,7,9},{0,8,94},{0,8,30},{0,9,156},{20,7,99},{0,8,126},{0,8,62},\n        {0,9,220},{18,7,27},{0,8,110},{0,8,46},{0,9,188},{0,8,14},{0,8,142},\n        {0,8,78},{0,9,252},{96,7,0},{0,8,81},{0,8,17},{21,8,131},{18,7,31},\n        {0,8,113},{0,8,49},{0,9,194},{16,7,10},{0,8,97},{0,8,33},{0,9,162},\n        {0,8,1},{0,8,129},{0,8,65},{0,9,226},{16,7,6},{0,8,89},{0,8,25},\n        {0,9,146},{19,7,59},{0,8,121},{0,8,57},{0,9,210},{17,7,17},{0,8,105},\n        {0,8,41},{0,9,178},{0,8,9},{0,8,137},{0,8,73},{0,9,242},{16,7,4},\n        {0,8,85},{0,8,21},{16,8,258},{19,7,43},{0,8,117},{0,8,53},{0,9,202},\n        {17,7,13},{0,8,101},{0,8,37},{0,9,170},{0,8,5},{0,8,133},{0,8,69},\n        {0,9,234},{16,7,8},{0,8,93},{0,8,29},{0,9,154},{20,7,83},{0,8,125},\n        {0,8,61},{0,9,218},{18,7,23},{0,8,109},{0,8,45},{0,9,186},{0,8,13},\n        {0,8,141},{0,8,77},{0,9,250},{16,7,3},{0,8,83},{0,8,19},{21,8,195},\n        {19,7,35},{0,8,115},{0,8,51},{0,9,198},{17,7,11},{0,8,99},{0,8,35},\n        {0,9,166},{0,8,3},{0,8,131},{0,8,67},{0,9,230},{16,7,7},{0,8,91},\n        {0,8,27},{0,9,150},{20,7,67},{0,8,123},{0,8,59},{0,9,214},{18,7,19},\n        {0,8,107},{0,8,43},{0,9,182},{0,8,11},{0,8,139},{0,8,75},{0,9,246},\n        {16,7,5},{0,8,87},{0,8,23},{64,8,0},{19,7,51},{0,8,119},{0,8,55},\n        {0,9,206},{17,7,15},{0,8,103},{0,8,39},{0,9,174},{0,8,7},{0,8,135},\n        {0,8,71},{0,9,238},{16,7,9},{0,8,95},{0,8,31},{0,9,158},{20,7,99},\n        {0,8,127},{0,8,63},{0,9,222},{18,7,27},{0,8,111},{0,8,47},{0,9,190},\n        {0,8,15},{0,8,143},{0,8,79},{0,9,254},{96,7,0},{0,8,80},{0,8,16},\n        {20,8,115},{18,7,31},{0,8,112},{0,8,48},{0,9,193},{16,7,10},{0,8,96},\n        {0,8,32},{0,9,161},{0,8,0},{0,8,128},{0,8,64},{0,9,225},{16,7,6},\n        {0,8,88},{0,8,24},{0,9,145},{19,7,59},{0,8,120},{0,8,56},{0,9,209},\n        {17,7,17},{0,8,104},{0,8,40},{0,9,177},{0,8,8},{0,8,136},{0,8,72},\n        {0,9,241},{16,7,4},{0,8,84},{0,8,20},{21,8,227},{19,7,43},{0,8,116},\n        {0,8,52},{0,9,201},{17,7,13},{0,8,100},{0,8,36},{0,9,169},{0,8,4},\n        {0,8,132},{0,8,68},{0,9,233},{16,7,8},{0,8,92},{0,8,28},{0,9,153},\n        {20,7,83},{0,8,124},{0,8,60},{0,9,217},{18,7,23},{0,8,108},{0,8,44},\n        {0,9,185},{0,8,12},{0,8,140},{0,8,76},{0,9,249},{16,7,3},{0,8,82},\n        {0,8,18},{21,8,163},{19,7,35},{0,8,114},{0,8,50},{0,9,197},{17,7,11},\n        {0,8,98},{0,8,34},{0,9,165},{0,8,2},{0,8,130},{0,8,66},{0,9,229},\n        {16,7,7},{0,8,90},{0,8,26},{0,9,149},{20,7,67},{0,8,122},{0,8,58},\n        {0,9,213},{18,7,19},{0,8,106},{0,8,42},{0,9,181},{0,8,10},{0,8,138},\n        {0,8,74},{0,9,245},{16,7,5},{0,8,86},{0,8,22},{64,8,0},{19,7,51},\n        {0,8,118},{0,8,54},{0,9,205},{17,7,15},{0,8,102},{0,8,38},{0,9,173},\n        {0,8,6},{0,8,134},{0,8,70},{0,9,237},{16,7,9},{0,8,94},{0,8,30},\n        {0,9,157},{20,7,99},{0,8,126},{0,8,62},{0,9,221},{18,7,27},{0,8,110},\n        {0,8,46},{0,9,189},{0,8,14},{0,8,142},{0,8,78},{0,9,253},{96,7,0},\n        {0,8,81},{0,8,17},{21,8,131},{18,7,31},{0,8,113},{0,8,49},{0,9,195},\n        {16,7,10},{0,8,97},{0,8,33},{0,9,163},{0,8,1},{0,8,129},{0,8,65},\n        {0,9,227},{16,7,6},{0,8,89},{0,8,25},{0,9,147},{19,7,59},{0,8,121},\n        {0,8,57},{0,9,211},{17,7,17},{0,8,105},{0,8,41},{0,9,179},{0,8,9},\n        {0,8,137},{0,8,73},{0,9,243},{16,7,4},{0,8,85},{0,8,21},{16,8,258},\n        {19,7,43},{0,8,117},{0,8,53},{0,9,203},{17,7,13},{0,8,101},{0,8,37},\n        {0,9,171},{0,8,5},{0,8,133},{0,8,69},{0,9,235},{16,7,8},{0,8,93},\n        {0,8,29},{0,9,155},{20,7,83},{0,8,125},{0,8,61},{0,9,219},{18,7,23},\n        {0,8,109},{0,8,45},{0,9,187},{0,8,13},{0,8,141},{0,8,77},{0,9,251},\n        {16,7,3},{0,8,83},{0,8,19},{21,8,195},{19,7,35},{0,8,115},{0,8,51},\n        {0,9,199},{17,7,11},{0,8,99},{0,8,35},{0,9,167},{0,8,3},{0,8,131},\n        {0,8,67},{0,9,231},{16,7,7},{0,8,91},{0,8,27},{0,9,151},{20,7,67},\n        {0,8,123},{0,8,59},{0,9,215},{18,7,19},{0,8,107},{0,8,43},{0,9,183},\n        {0,8,11},{0,8,139},{0,8,75},{0,9,247},{16,7,5},{0,8,87},{0,8,23},\n        {64,8,0},{19,7,51},{0,8,119},{0,8,55},{0,9,207},{17,7,15},{0,8,103},\n        {0,8,39},{0,9,175},{0,8,7},{0,8,135},{0,8,71},{0,9,239},{16,7,9},\n        {0,8,95},{0,8,31},{0,9,159},{20,7,99},{0,8,127},{0,8,63},{0,9,223},\n        {18,7,27},{0,8,111},{0,8,47},{0,9,191},{0,8,15},{0,8,143},{0,8,79},\n        {0,9,255}\n    };\n\n    static const code distfix[32] = {\n        {16,5,1},{23,5,257},{19,5,17},{27,5,4097},{17,5,5},{25,5,1025},\n        {21,5,65},{29,5,16385},{16,5,3},{24,5,513},{20,5,33},{28,5,8193},\n        {18,5,9},{26,5,2049},{22,5,129},{64,5,0},{16,5,2},{23,5,385},\n        {19,5,25},{27,5,6145},{17,5,7},{25,5,1537},{21,5,97},{29,5,24577},\n        {16,5,4},{24,5,769},{20,5,49},{28,5,12289},{18,5,13},{26,5,3073},\n        {22,5,193},{64,5,0}\n    };\n"
  },
  {
    "path": "Projects/Tools/PNGAlphaPremultiplier/Native/Source/ZLib/inflate.c",
    "content": "/* inflate.c -- zlib decompression\n * Copyright (C) 1995-2011 Mark Adler\n * For conditions of distribution and use, see copyright notice in zlib.h\n */\n\n/*\n * Change history:\n *\n * 1.2.beta0    24 Nov 2002\n * - First version -- complete rewrite of inflate to simplify code, avoid\n *   creation of window when not needed, minimize use of window when it is\n *   needed, make inffast.c even faster, implement gzip decoding, and to\n *   improve code readability and style over the previous zlib inflate code\n *\n * 1.2.beta1    25 Nov 2002\n * - Use pointers for available input and output checking in inffast.c\n * - Remove input and output counters in inffast.c\n * - Change inffast.c entry and loop from avail_in >= 7 to >= 6\n * - Remove unnecessary second byte pull from length extra in inffast.c\n * - Unroll direct copy to three copies per loop in inffast.c\n *\n * 1.2.beta2    4 Dec 2002\n * - Change external routine names to reduce potential conflicts\n * - Correct filename to inffixed.h for fixed tables in inflate.c\n * - Make hbuf[] unsigned char to match parameter type in inflate.c\n * - Change strm->next_out[-state->offset] to *(strm->next_out - state->offset)\n *   to avoid negation problem on Alphas (64 bit) in inflate.c\n *\n * 1.2.beta3    22 Dec 2002\n * - Add comments on state->bits assertion in inffast.c\n * - Add comments on op field in inftrees.h\n * - Fix bug in reuse of allocated window after inflateReset()\n * - Remove bit fields--back to byte structure for speed\n * - Remove distance extra == 0 check in inflate_fast()--only helps for lengths\n * - Change post-increments to pre-increments in inflate_fast(), PPC biased?\n * - Add compile time option, POSTINC, to use post-increments instead (Intel?)\n * - Make MATCH copy in inflate() much faster for when inflate_fast() not used\n * - Use local copies of stream next and avail values, as well as local bit\n *   buffer and bit count in inflate()--for speed when inflate_fast() not used\n *\n * 1.2.beta4    1 Jan 2003\n * - Split ptr - 257 statements in inflate_table() to avoid compiler warnings\n * - Move a comment on output buffer sizes from inffast.c to inflate.c\n * - Add comments in inffast.c to introduce the inflate_fast() routine\n * - Rearrange window copies in inflate_fast() for speed and simplification\n * - Unroll last copy for window match in inflate_fast()\n * - Use local copies of window variables in inflate_fast() for speed\n * - Pull out common wnext == 0 case for speed in inflate_fast()\n * - Make op and len in inflate_fast() unsigned for consistency\n * - Add FAR to lcode and dcode declarations in inflate_fast()\n * - Simplified bad distance check in inflate_fast()\n * - Added inflateBackInit(), inflateBack(), and inflateBackEnd() in new\n *   source file infback.c to provide a call-back interface to inflate for\n *   programs like gzip and unzip -- uses window as output buffer to avoid\n *   window copying\n *\n * 1.2.beta5    1 Jan 2003\n * - Improved inflateBack() interface to allow the caller to provide initial\n *   input in strm.\n * - Fixed stored blocks bug in inflateBack()\n *\n * 1.2.beta6    4 Jan 2003\n * - Added comments in inffast.c on effectiveness of POSTINC\n * - Typecasting all around to reduce compiler warnings\n * - Changed loops from while (1) or do {} while (1) to for (;;), again to\n *   make compilers happy\n * - Changed type of window in inflateBackInit() to unsigned char *\n *\n * 1.2.beta7    27 Jan 2003\n * - Changed many types to unsigned or unsigned short to avoid warnings\n * - Added inflateCopy() function\n *\n * 1.2.0        9 Mar 2003\n * - Changed inflateBack() interface to provide separate opaque descriptors\n *   for the in() and out() functions\n * - Changed inflateBack() argument and in_func typedef to swap the length\n *   and buffer address return values for the input function\n * - Check next_in and next_out for Z_NULL on entry to inflate()\n *\n * The history for versions after 1.2.0 are in ChangeLog in zlib distribution.\n */\n\n#include \"zutil.h\"\n#include \"inftrees.h\"\n#include \"inflate.h\"\n#include \"inffast.h\"\n\n#ifdef MAKEFIXED\n#  ifndef BUILDFIXED\n#    define BUILDFIXED\n#  endif\n#endif\n\n/* function prototypes */\nlocal void fixedtables OF((struct inflate_state FAR *state));\nlocal int updatewindow OF((z_streamp strm, unsigned out));\n#ifdef BUILDFIXED\n   void makefixed OF((void));\n#endif\nlocal unsigned syncsearch OF((unsigned FAR *have, unsigned char FAR *buf,\n                              unsigned len));\n\nint ZEXPORT inflateResetKeep(strm)\nz_streamp strm;\n{\n    struct inflate_state FAR *state;\n\n    if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;\n    state = (struct inflate_state FAR *)strm->state;\n    strm->total_in = strm->total_out = state->total = 0;\n    strm->msg = Z_NULL;\n    if (state->wrap)        /* to support ill-conceived Java test suite */\n        strm->adler = state->wrap & 1;\n    state->mode = HEAD;\n    state->last = 0;\n    state->havedict = 0;\n    state->dmax = 32768U;\n    state->head = Z_NULL;\n    state->hold = 0;\n    state->bits = 0;\n    state->lencode = state->distcode = state->next = state->codes;\n    state->sane = 1;\n    state->back = -1;\n    Tracev((stderr, \"inflate: reset\\n\"));\n    return Z_OK;\n}\n\nint ZEXPORT inflateReset(strm)\nz_streamp strm;\n{\n    struct inflate_state FAR *state;\n\n    if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;\n    state = (struct inflate_state FAR *)strm->state;\n    state->wsize = 0;\n    state->whave = 0;\n    state->wnext = 0;\n    return inflateResetKeep(strm);\n}\n\nint ZEXPORT inflateReset2(strm, windowBits)\nz_streamp strm;\nint windowBits;\n{\n    int wrap;\n    struct inflate_state FAR *state;\n\n    /* get the state */\n    if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;\n    state = (struct inflate_state FAR *)strm->state;\n\n    /* extract wrap request from windowBits parameter */\n    if (windowBits < 0) {\n        wrap = 0;\n        windowBits = -windowBits;\n    }\n    else {\n        wrap = (windowBits >> 4) + 1;\n#ifdef GUNZIP\n        if (windowBits < 48)\n            windowBits &= 15;\n#endif\n    }\n\n    /* set number of window bits, free window if different */\n    if (windowBits && (windowBits < 8 || windowBits > 15))\n        return Z_STREAM_ERROR;\n    if (state->window != Z_NULL && state->wbits != (unsigned)windowBits) {\n        ZFREE(strm, state->window);\n        state->window = Z_NULL;\n    }\n\n    /* update state and reset the rest of it */\n    state->wrap = wrap;\n    state->wbits = (unsigned)windowBits;\n    return inflateReset(strm);\n}\n\nint ZEXPORT inflateInit2_(strm, windowBits, version, stream_size)\nz_streamp strm;\nint windowBits;\nconst char *version;\nint stream_size;\n{\n    int ret;\n    struct inflate_state FAR *state;\n\n    if (version == Z_NULL || version[0] != ZLIB_VERSION[0] ||\n        stream_size != (int)(sizeof(z_stream)))\n        return Z_VERSION_ERROR;\n    if (strm == Z_NULL) return Z_STREAM_ERROR;\n    strm->msg = Z_NULL;                 /* in case we return an error */\n    if (strm->zalloc == (alloc_func)0) {\n#ifdef Z_SOLO\n        return Z_STREAM_ERROR;\n#else\n        strm->zalloc = zcalloc;\n        strm->opaque = (voidpf)0;\n#endif\n    }\n    if (strm->zfree == (free_func)0)\n#ifdef Z_SOLO\n        return Z_STREAM_ERROR;\n#else\n        strm->zfree = zcfree;\n#endif\n    state = (struct inflate_state FAR *)\n            ZALLOC(strm, 1, sizeof(struct inflate_state));\n    if (state == Z_NULL) return Z_MEM_ERROR;\n    Tracev((stderr, \"inflate: allocated\\n\"));\n    strm->state = (struct internal_state FAR *)state;\n    state->window = Z_NULL;\n    ret = inflateReset2(strm, windowBits);\n    if (ret != Z_OK) {\n        ZFREE(strm, state);\n        strm->state = Z_NULL;\n    }\n    return ret;\n}\n\nint ZEXPORT inflateInit_(strm, version, stream_size)\nz_streamp strm;\nconst char *version;\nint stream_size;\n{\n    return inflateInit2_(strm, DEF_WBITS, version, stream_size);\n}\n\nint ZEXPORT inflatePrime(strm, bits, value)\nz_streamp strm;\nint bits;\nint value;\n{\n    struct inflate_state FAR *state;\n\n    if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;\n    state = (struct inflate_state FAR *)strm->state;\n    if (bits < 0) {\n        state->hold = 0;\n        state->bits = 0;\n        return Z_OK;\n    }\n    if (bits > 16 || state->bits + bits > 32) return Z_STREAM_ERROR;\n    value &= (1L << bits) - 1;\n    state->hold += value << state->bits;\n    state->bits += bits;\n    return Z_OK;\n}\n\n/*\n   Return state with length and distance decoding tables and index sizes set to\n   fixed code decoding.  Normally this returns fixed tables from inffixed.h.\n   If BUILDFIXED is defined, then instead this routine builds the tables the\n   first time it's called, and returns those tables the first time and\n   thereafter.  This reduces the size of the code by about 2K bytes, in\n   exchange for a little execution time.  However, BUILDFIXED should not be\n   used for threaded applications, since the rewriting of the tables and virgin\n   may not be thread-safe.\n */\nlocal void fixedtables(state)\nstruct inflate_state FAR *state;\n{\n#ifdef BUILDFIXED\n    static int virgin = 1;\n    static code *lenfix, *distfix;\n    static code fixed[544];\n\n    /* build fixed huffman tables if first call (may not be thread safe) */\n    if (virgin) {\n        unsigned sym, bits;\n        static code *next;\n\n        /* literal/length table */\n        sym = 0;\n        while (sym < 144) state->lens[sym++] = 8;\n        while (sym < 256) state->lens[sym++] = 9;\n        while (sym < 280) state->lens[sym++] = 7;\n        while (sym < 288) state->lens[sym++] = 8;\n        next = fixed;\n        lenfix = next;\n        bits = 9;\n        inflate_table(LENS, state->lens, 288, &(next), &(bits), state->work);\n\n        /* distance table */\n        sym = 0;\n        while (sym < 32) state->lens[sym++] = 5;\n        distfix = next;\n        bits = 5;\n        inflate_table(DISTS, state->lens, 32, &(next), &(bits), state->work);\n\n        /* do this just once */\n        virgin = 0;\n    }\n#else /* !BUILDFIXED */\n#   include \"inffixed.h\"\n#endif /* BUILDFIXED */\n    state->lencode = lenfix;\n    state->lenbits = 9;\n    state->distcode = distfix;\n    state->distbits = 5;\n}\n\n#ifdef MAKEFIXED\n#include <stdio.h>\n\n/*\n   Write out the inffixed.h that is #include'd above.  Defining MAKEFIXED also\n   defines BUILDFIXED, so the tables are built on the fly.  makefixed() writes\n   those tables to stdout, which would be piped to inffixed.h.  A small program\n   can simply call makefixed to do this:\n\n    void makefixed(void);\n\n    int main(void)\n    {\n        makefixed();\n        return 0;\n    }\n\n   Then that can be linked with zlib built with MAKEFIXED defined and run:\n\n    a.out > inffixed.h\n */\nvoid makefixed()\n{\n    unsigned low, size;\n    struct inflate_state state;\n\n    fixedtables(&state);\n    puts(\"    /* inffixed.h -- table for decoding fixed codes\");\n    puts(\"     * Generated automatically by makefixed().\");\n    puts(\"     */\");\n    puts(\"\");\n    puts(\"    /* WARNING: this file should *not* be used by applications.\");\n    puts(\"       It is part of the implementation of this library and is\");\n    puts(\"       subject to change. Applications should only use zlib.h.\");\n    puts(\"     */\");\n    puts(\"\");\n    size = 1U << 9;\n    printf(\"    static const code lenfix[%u] = {\", size);\n    low = 0;\n    for (;;) {\n        if ((low % 7) == 0) printf(\"\\n        \");\n        printf(\"{%u,%u,%d}\", (low & 127) == 99 ? 64 : state.lencode[low].op,\n               state.lencode[low].bits, state.lencode[low].val);\n        if (++low == size) break;\n        putchar(',');\n    }\n    puts(\"\\n    };\");\n    size = 1U << 5;\n    printf(\"\\n    static const code distfix[%u] = {\", size);\n    low = 0;\n    for (;;) {\n        if ((low % 6) == 0) printf(\"\\n        \");\n        printf(\"{%u,%u,%d}\", state.distcode[low].op, state.distcode[low].bits,\n               state.distcode[low].val);\n        if (++low == size) break;\n        putchar(',');\n    }\n    puts(\"\\n    };\");\n}\n#endif /* MAKEFIXED */\n\n/*\n   Update the window with the last wsize (normally 32K) bytes written before\n   returning.  If window does not exist yet, create it.  This is only called\n   when a window is already in use, or when output has been written during this\n   inflate call, but the end of the deflate stream has not been reached yet.\n   It is also called to create a window for dictionary data when a dictionary\n   is loaded.\n\n   Providing output buffers larger than 32K to inflate() should provide a speed\n   advantage, since only the last 32K of output is copied to the sliding window\n   upon return from inflate(), and since all distances after the first 32K of\n   output will fall in the output data, making match copies simpler and faster.\n   The advantage may be dependent on the size of the processor's data caches.\n */\nlocal int updatewindow(strm, out)\nz_streamp strm;\nunsigned out;\n{\n    struct inflate_state FAR *state;\n    unsigned copy, dist;\n\n    state = (struct inflate_state FAR *)strm->state;\n\n    /* if it hasn't been done already, allocate space for the window */\n    if (state->window == Z_NULL) {\n        state->window = (unsigned char FAR *)\n                        ZALLOC(strm, 1U << state->wbits,\n                               sizeof(unsigned char));\n        if (state->window == Z_NULL) return 1;\n    }\n\n    /* if window not in use yet, initialize */\n    if (state->wsize == 0) {\n        state->wsize = 1U << state->wbits;\n        state->wnext = 0;\n        state->whave = 0;\n    }\n\n    /* copy state->wsize or less output bytes into the circular window */\n    copy = out - strm->avail_out;\n    if (copy >= state->wsize) {\n        zmemcpy(state->window, strm->next_out - state->wsize, state->wsize);\n        state->wnext = 0;\n        state->whave = state->wsize;\n    }\n    else {\n        dist = state->wsize - state->wnext;\n        if (dist > copy) dist = copy;\n        zmemcpy(state->window + state->wnext, strm->next_out - copy, dist);\n        copy -= dist;\n        if (copy) {\n            zmemcpy(state->window, strm->next_out - copy, copy);\n            state->wnext = copy;\n            state->whave = state->wsize;\n        }\n        else {\n            state->wnext += dist;\n            if (state->wnext == state->wsize) state->wnext = 0;\n            if (state->whave < state->wsize) state->whave += dist;\n        }\n    }\n    return 0;\n}\n\n/* Macros for inflate(): */\n\n/* check function to use adler32() for zlib or crc32() for gzip */\n#ifdef GUNZIP\n#  define UPDATE(check, buf, len) \\\n    (state->flags ? crc32(check, buf, len) : adler32(check, buf, len))\n#else\n#  define UPDATE(check, buf, len) adler32(check, buf, len)\n#endif\n\n/* check macros for header crc */\n#ifdef GUNZIP\n#  define CRC2(check, word) \\\n    do { \\\n        hbuf[0] = (unsigned char)(word); \\\n        hbuf[1] = (unsigned char)((word) >> 8); \\\n        check = crc32(check, hbuf, 2); \\\n    } while (0)\n\n#  define CRC4(check, word) \\\n    do { \\\n        hbuf[0] = (unsigned char)(word); \\\n        hbuf[1] = (unsigned char)((word) >> 8); \\\n        hbuf[2] = (unsigned char)((word) >> 16); \\\n        hbuf[3] = (unsigned char)((word) >> 24); \\\n        check = crc32(check, hbuf, 4); \\\n    } while (0)\n#endif\n\n/* Load registers with state in inflate() for speed */\n#define LOAD() \\\n    do { \\\n        put = strm->next_out; \\\n        left = strm->avail_out; \\\n        next = strm->next_in; \\\n        have = strm->avail_in; \\\n        hold = state->hold; \\\n        bits = state->bits; \\\n    } while (0)\n\n/* Restore state from registers in inflate() */\n#define RESTORE() \\\n    do { \\\n        strm->next_out = put; \\\n        strm->avail_out = left; \\\n        strm->next_in = next; \\\n        strm->avail_in = have; \\\n        state->hold = hold; \\\n        state->bits = bits; \\\n    } while (0)\n\n/* Clear the input bit accumulator */\n#define INITBITS() \\\n    do { \\\n        hold = 0; \\\n        bits = 0; \\\n    } while (0)\n\n/* Get a byte of input into the bit accumulator, or return from inflate()\n   if there is no input available. */\n#define PULLBYTE() \\\n    do { \\\n        if (have == 0) goto inf_leave; \\\n        have--; \\\n        hold += (unsigned long)(*next++) << bits; \\\n        bits += 8; \\\n    } while (0)\n\n/* Assure that there are at least n bits in the bit accumulator.  If there is\n   not enough available input to do that, then return from inflate(). */\n#define NEEDBITS(n) \\\n    do { \\\n        while (bits < (unsigned)(n)) \\\n            PULLBYTE(); \\\n    } while (0)\n\n/* Return the low n bits of the bit accumulator (n < 16) */\n#define BITS(n) \\\n    ((unsigned)hold & ((1U << (n)) - 1))\n\n/* Remove n bits from the bit accumulator */\n#define DROPBITS(n) \\\n    do { \\\n        hold >>= (n); \\\n        bits -= (unsigned)(n); \\\n    } while (0)\n\n/* Remove zero to seven bits as needed to go to a byte boundary */\n#define BYTEBITS() \\\n    do { \\\n        hold >>= bits & 7; \\\n        bits -= bits & 7; \\\n    } while (0)\n\n/* Reverse the bytes in a 32-bit value */\n#define REVERSE(q) \\\n    ((((q) >> 24) & 0xff) + (((q) >> 8) & 0xff00) + \\\n     (((q) & 0xff00) << 8) + (((q) & 0xff) << 24))\n\n/*\n   inflate() uses a state machine to process as much input data and generate as\n   much output data as possible before returning.  The state machine is\n   structured roughly as follows:\n\n    for (;;) switch (state) {\n    ...\n    case STATEn:\n        if (not enough input data or output space to make progress)\n            return;\n        ... make progress ...\n        state = STATEm;\n        break;\n    ...\n    }\n\n   so when inflate() is called again, the same case is attempted again, and\n   if the appropriate resources are provided, the machine proceeds to the\n   next state.  The NEEDBITS() macro is usually the way the state evaluates\n   whether it can proceed or should return.  NEEDBITS() does the return if\n   the requested bits are not available.  The typical use of the BITS macros\n   is:\n\n        NEEDBITS(n);\n        ... do something with BITS(n) ...\n        DROPBITS(n);\n\n   where NEEDBITS(n) either returns from inflate() if there isn't enough\n   input left to load n bits into the accumulator, or it continues.  BITS(n)\n   gives the low n bits in the accumulator.  When done, DROPBITS(n) drops\n   the low n bits off the accumulator.  INITBITS() clears the accumulator\n   and sets the number of available bits to zero.  BYTEBITS() discards just\n   enough bits to put the accumulator on a byte boundary.  After BYTEBITS()\n   and a NEEDBITS(8), then BITS(8) would return the next byte in the stream.\n\n   NEEDBITS(n) uses PULLBYTE() to get an available byte of input, or to return\n   if there is no input available.  The decoding of variable length codes uses\n   PULLBYTE() directly in order to pull just enough bytes to decode the next\n   code, and no more.\n\n   Some states loop until they get enough input, making sure that enough\n   state information is maintained to continue the loop where it left off\n   if NEEDBITS() returns in the loop.  For example, want, need, and keep\n   would all have to actually be part of the saved state in case NEEDBITS()\n   returns:\n\n    case STATEw:\n        while (want < need) {\n            NEEDBITS(n);\n            keep[want++] = BITS(n);\n            DROPBITS(n);\n        }\n        state = STATEx;\n    case STATEx:\n\n   As shown above, if the next state is also the next case, then the break\n   is omitted.\n\n   A state may also return if there is not enough output space available to\n   complete that state.  Those states are copying stored data, writing a\n   literal byte, and copying a matching string.\n\n   When returning, a \"goto inf_leave\" is used to update the total counters,\n   update the check value, and determine whether any progress has been made\n   during that inflate() call in order to return the proper return code.\n   Progress is defined as a change in either strm->avail_in or strm->avail_out.\n   When there is a window, goto inf_leave will update the window with the last\n   output written.  If a goto inf_leave occurs in the middle of decompression\n   and there is no window currently, goto inf_leave will create one and copy\n   output to the window for the next call of inflate().\n\n   In this implementation, the flush parameter of inflate() only affects the\n   return code (per zlib.h).  inflate() always writes as much as possible to\n   strm->next_out, given the space available and the provided input--the effect\n   documented in zlib.h of Z_SYNC_FLUSH.  Furthermore, inflate() always defers\n   the allocation of and copying into a sliding window until necessary, which\n   provides the effect documented in zlib.h for Z_FINISH when the entire input\n   stream available.  So the only thing the flush parameter actually does is:\n   when flush is set to Z_FINISH, inflate() cannot return Z_OK.  Instead it\n   will return Z_BUF_ERROR if it has not reached the end of the stream.\n */\n\nint ZEXPORT inflate(strm, flush)\nz_streamp strm;\nint flush;\n{\n    struct inflate_state FAR *state;\n    unsigned char FAR *next;    /* next input */\n    unsigned char FAR *put;     /* next output */\n    unsigned have, left;        /* available input and output */\n    unsigned long hold;         /* bit buffer */\n    unsigned bits;              /* bits in bit buffer */\n    unsigned in, out;           /* save starting available input and output */\n    unsigned copy;              /* number of stored or match bytes to copy */\n    unsigned char FAR *from;    /* where to copy match bytes from */\n    code here;                  /* current decoding table entry */\n    code last;                  /* parent table entry */\n    unsigned len;               /* length to copy for repeats, bits to drop */\n    int ret;                    /* return code */\n#ifdef GUNZIP\n    unsigned char hbuf[4];      /* buffer for gzip header crc calculation */\n#endif\n    static const unsigned short order[19] = /* permutation of code lengths */\n        {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};\n\n    if (strm == Z_NULL || strm->state == Z_NULL || strm->next_out == Z_NULL ||\n        (strm->next_in == Z_NULL && strm->avail_in != 0))\n        return Z_STREAM_ERROR;\n\n    state = (struct inflate_state FAR *)strm->state;\n    if (state->mode == TYPE) state->mode = TYPEDO;      /* skip check */\n    LOAD();\n    in = have;\n    out = left;\n    ret = Z_OK;\n    for (;;)\n        switch (state->mode) {\n        case HEAD:\n            if (state->wrap == 0) {\n                state->mode = TYPEDO;\n                break;\n            }\n            NEEDBITS(16);\n#ifdef GUNZIP\n            if ((state->wrap & 2) && hold == 0x8b1f) {  /* gzip header */\n                state->check = crc32(0L, Z_NULL, 0);\n                CRC2(state->check, hold);\n                INITBITS();\n                state->mode = FLAGS;\n                break;\n            }\n            state->flags = 0;           /* expect zlib header */\n            if (state->head != Z_NULL)\n                state->head->done = -1;\n            if (!(state->wrap & 1) ||   /* check if zlib header allowed */\n#else\n            if (\n#endif\n                ((BITS(8) << 8) + (hold >> 8)) % 31) {\n                strm->msg = (char *)\"incorrect header check\";\n                state->mode = BAD;\n                break;\n            }\n            if (BITS(4) != Z_DEFLATED) {\n                strm->msg = (char *)\"unknown compression method\";\n                state->mode = BAD;\n                break;\n            }\n            DROPBITS(4);\n            len = BITS(4) + 8;\n            if (state->wbits == 0)\n                state->wbits = len;\n            else if (len > state->wbits) {\n                strm->msg = (char *)\"invalid window size\";\n                state->mode = BAD;\n                break;\n            }\n            state->dmax = 1U << len;\n            Tracev((stderr, \"inflate:   zlib header ok\\n\"));\n            strm->adler = state->check = adler32(0L, Z_NULL, 0);\n            state->mode = hold & 0x200 ? DICTID : TYPE;\n            INITBITS();\n            break;\n#ifdef GUNZIP\n        case FLAGS:\n            NEEDBITS(16);\n            state->flags = (int)(hold);\n            if ((state->flags & 0xff) != Z_DEFLATED) {\n                strm->msg = (char *)\"unknown compression method\";\n                state->mode = BAD;\n                break;\n            }\n            if (state->flags & 0xe000) {\n                strm->msg = (char *)\"unknown header flags set\";\n                state->mode = BAD;\n                break;\n            }\n            if (state->head != Z_NULL)\n                state->head->text = (int)((hold >> 8) & 1);\n            if (state->flags & 0x0200) CRC2(state->check, hold);\n            INITBITS();\n            state->mode = TIME;\n        case TIME:\n            NEEDBITS(32);\n            if (state->head != Z_NULL)\n                state->head->time = hold;\n            if (state->flags & 0x0200) CRC4(state->check, hold);\n            INITBITS();\n            state->mode = OS;\n        case OS:\n            NEEDBITS(16);\n            if (state->head != Z_NULL) {\n                state->head->xflags = (int)(hold & 0xff);\n                state->head->os = (int)(hold >> 8);\n            }\n            if (state->flags & 0x0200) CRC2(state->check, hold);\n            INITBITS();\n            state->mode = EXLEN;\n        case EXLEN:\n            if (state->flags & 0x0400) {\n                NEEDBITS(16);\n                state->length = (unsigned)(hold);\n                if (state->head != Z_NULL)\n                    state->head->extra_len = (unsigned)hold;\n                if (state->flags & 0x0200) CRC2(state->check, hold);\n                INITBITS();\n            }\n            else if (state->head != Z_NULL)\n                state->head->extra = Z_NULL;\n            state->mode = EXTRA;\n        case EXTRA:\n            if (state->flags & 0x0400) {\n                copy = state->length;\n                if (copy > have) copy = have;\n                if (copy) {\n                    if (state->head != Z_NULL &&\n                        state->head->extra != Z_NULL) {\n                        len = state->head->extra_len - state->length;\n                        zmemcpy(state->head->extra + len, next,\n                                len + copy > state->head->extra_max ?\n                                state->head->extra_max - len : copy);\n                    }\n                    if (state->flags & 0x0200)\n                        state->check = crc32(state->check, next, copy);\n                    have -= copy;\n                    next += copy;\n                    state->length -= copy;\n                }\n                if (state->length) goto inf_leave;\n            }\n            state->length = 0;\n            state->mode = NAME;\n        case NAME:\n            if (state->flags & 0x0800) {\n                if (have == 0) goto inf_leave;\n                copy = 0;\n                do {\n                    len = (unsigned)(next[copy++]);\n                    if (state->head != Z_NULL &&\n                            state->head->name != Z_NULL &&\n                            state->length < state->head->name_max)\n                        state->head->name[state->length++] = len;\n                } while (len && copy < have);\n                if (state->flags & 0x0200)\n                    state->check = crc32(state->check, next, copy);\n                have -= copy;\n                next += copy;\n                if (len) goto inf_leave;\n            }\n            else if (state->head != Z_NULL)\n                state->head->name = Z_NULL;\n            state->length = 0;\n            state->mode = COMMENT;\n        case COMMENT:\n            if (state->flags & 0x1000) {\n                if (have == 0) goto inf_leave;\n                copy = 0;\n                do {\n                    len = (unsigned)(next[copy++]);\n                    if (state->head != Z_NULL &&\n                            state->head->comment != Z_NULL &&\n                            state->length < state->head->comm_max)\n                        state->head->comment[state->length++] = len;\n                } while (len && copy < have);\n                if (state->flags & 0x0200)\n                    state->check = crc32(state->check, next, copy);\n                have -= copy;\n                next += copy;\n                if (len) goto inf_leave;\n            }\n            else if (state->head != Z_NULL)\n                state->head->comment = Z_NULL;\n            state->mode = HCRC;\n        case HCRC:\n            if (state->flags & 0x0200) {\n                NEEDBITS(16);\n                if (hold != (state->check & 0xffff)) {\n                    strm->msg = (char *)\"header crc mismatch\";\n                    state->mode = BAD;\n                    break;\n                }\n                INITBITS();\n            }\n            if (state->head != Z_NULL) {\n                state->head->hcrc = (int)((state->flags >> 9) & 1);\n                state->head->done = 1;\n            }\n            strm->adler = state->check = crc32(0L, Z_NULL, 0);\n            state->mode = TYPE;\n            break;\n#endif\n        case DICTID:\n            NEEDBITS(32);\n            strm->adler = state->check = REVERSE(hold);\n            INITBITS();\n            state->mode = DICT;\n        case DICT:\n            if (state->havedict == 0) {\n                RESTORE();\n                return Z_NEED_DICT;\n            }\n            strm->adler = state->check = adler32(0L, Z_NULL, 0);\n            state->mode = TYPE;\n        case TYPE:\n            if (flush == Z_BLOCK || flush == Z_TREES) goto inf_leave;\n        case TYPEDO:\n            if (state->last) {\n                BYTEBITS();\n                state->mode = CHECK;\n                break;\n            }\n            NEEDBITS(3);\n            state->last = BITS(1);\n            DROPBITS(1);\n            switch (BITS(2)) {\n            case 0:                             /* stored block */\n                Tracev((stderr, \"inflate:     stored block%s\\n\",\n                        state->last ? \" (last)\" : \"\"));\n                state->mode = STORED;\n                break;\n            case 1:                             /* fixed block */\n                fixedtables(state);\n                Tracev((stderr, \"inflate:     fixed codes block%s\\n\",\n                        state->last ? \" (last)\" : \"\"));\n                state->mode = LEN_;             /* decode codes */\n                if (flush == Z_TREES) {\n                    DROPBITS(2);\n                    goto inf_leave;\n                }\n                break;\n            case 2:                             /* dynamic block */\n                Tracev((stderr, \"inflate:     dynamic codes block%s\\n\",\n                        state->last ? \" (last)\" : \"\"));\n                state->mode = TABLE;\n                break;\n            case 3:\n                strm->msg = (char *)\"invalid block type\";\n                state->mode = BAD;\n            }\n            DROPBITS(2);\n            break;\n        case STORED:\n            BYTEBITS();                         /* go to byte boundary */\n            NEEDBITS(32);\n            if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) {\n                strm->msg = (char *)\"invalid stored block lengths\";\n                state->mode = BAD;\n                break;\n            }\n            state->length = (unsigned)hold & 0xffff;\n            Tracev((stderr, \"inflate:       stored length %u\\n\",\n                    state->length));\n            INITBITS();\n            state->mode = COPY_;\n            if (flush == Z_TREES) goto inf_leave;\n        case COPY_:\n            state->mode = COPY;\n        case COPY:\n            copy = state->length;\n            if (copy) {\n                if (copy > have) copy = have;\n                if (copy > left) copy = left;\n                if (copy == 0) goto inf_leave;\n                zmemcpy(put, next, copy);\n                have -= copy;\n                next += copy;\n                left -= copy;\n                put += copy;\n                state->length -= copy;\n                break;\n            }\n            Tracev((stderr, \"inflate:       stored end\\n\"));\n            state->mode = TYPE;\n            break;\n        case TABLE:\n            NEEDBITS(14);\n            state->nlen = BITS(5) + 257;\n            DROPBITS(5);\n            state->ndist = BITS(5) + 1;\n            DROPBITS(5);\n            state->ncode = BITS(4) + 4;\n            DROPBITS(4);\n#ifndef PKZIP_BUG_WORKAROUND\n            if (state->nlen > 286 || state->ndist > 30) {\n                strm->msg = (char *)\"too many length or distance symbols\";\n                state->mode = BAD;\n                break;\n            }\n#endif\n            Tracev((stderr, \"inflate:       table sizes ok\\n\"));\n            state->have = 0;\n            state->mode = LENLENS;\n        case LENLENS:\n            while (state->have < state->ncode) {\n                NEEDBITS(3);\n                state->lens[order[state->have++]] = (unsigned short)BITS(3);\n                DROPBITS(3);\n            }\n            while (state->have < 19)\n                state->lens[order[state->have++]] = 0;\n            state->next = state->codes;\n            state->lencode = (code const FAR *)(state->next);\n            state->lenbits = 7;\n            ret = inflate_table(CODES, state->lens, 19, &(state->next),\n                                &(state->lenbits), state->work);\n            if (ret) {\n                strm->msg = (char *)\"invalid code lengths set\";\n                state->mode = BAD;\n                break;\n            }\n            Tracev((stderr, \"inflate:       code lengths ok\\n\"));\n            state->have = 0;\n            state->mode = CODELENS;\n        case CODELENS:\n            while (state->have < state->nlen + state->ndist) {\n                for (;;) {\n                    here = state->lencode[BITS(state->lenbits)];\n                    if ((unsigned)(here.bits) <= bits) break;\n                    PULLBYTE();\n                }\n                if (here.val < 16) {\n                    DROPBITS(here.bits);\n                    state->lens[state->have++] = here.val;\n                }\n                else {\n                    if (here.val == 16) {\n                        NEEDBITS(here.bits + 2);\n                        DROPBITS(here.bits);\n                        if (state->have == 0) {\n                            strm->msg = (char *)\"invalid bit length repeat\";\n                            state->mode = BAD;\n                            break;\n                        }\n                        len = state->lens[state->have - 1];\n                        copy = 3 + BITS(2);\n                        DROPBITS(2);\n                    }\n                    else if (here.val == 17) {\n                        NEEDBITS(here.bits + 3);\n                        DROPBITS(here.bits);\n                        len = 0;\n                        copy = 3 + BITS(3);\n                        DROPBITS(3);\n                    }\n                    else {\n                        NEEDBITS(here.bits + 7);\n                        DROPBITS(here.bits);\n                        len = 0;\n                        copy = 11 + BITS(7);\n                        DROPBITS(7);\n                    }\n                    if (state->have + copy > state->nlen + state->ndist) {\n                        strm->msg = (char *)\"invalid bit length repeat\";\n                        state->mode = BAD;\n                        break;\n                    }\n                    while (copy--)\n                        state->lens[state->have++] = (unsigned short)len;\n                }\n            }\n\n            /* handle error breaks in while */\n            if (state->mode == BAD) break;\n\n            /* check for end-of-block code (better have one) */\n            if (state->lens[256] == 0) {\n                strm->msg = (char *)\"invalid code -- missing end-of-block\";\n                state->mode = BAD;\n                break;\n            }\n\n            /* build code tables -- note: do not change the lenbits or distbits\n               values here (9 and 6) without reading the comments in inftrees.h\n               concerning the ENOUGH constants, which depend on those values */\n            state->next = state->codes;\n            state->lencode = (code const FAR *)(state->next);\n            state->lenbits = 9;\n            ret = inflate_table(LENS, state->lens, state->nlen, &(state->next),\n                                &(state->lenbits), state->work);\n            if (ret) {\n                strm->msg = (char *)\"invalid literal/lengths set\";\n                state->mode = BAD;\n                break;\n            }\n            state->distcode = (code const FAR *)(state->next);\n            state->distbits = 6;\n            ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist,\n                            &(state->next), &(state->distbits), state->work);\n            if (ret) {\n                strm->msg = (char *)\"invalid distances set\";\n                state->mode = BAD;\n                break;\n            }\n            Tracev((stderr, \"inflate:       codes ok\\n\"));\n            state->mode = LEN_;\n            if (flush == Z_TREES) goto inf_leave;\n        case LEN_:\n            state->mode = LEN;\n        case LEN:\n            if (have >= 6 && left >= 258) {\n                RESTORE();\n                inflate_fast(strm, out);\n                LOAD();\n                if (state->mode == TYPE)\n                    state->back = -1;\n                break;\n            }\n            state->back = 0;\n            for (;;) {\n                here = state->lencode[BITS(state->lenbits)];\n                if ((unsigned)(here.bits) <= bits) break;\n                PULLBYTE();\n            }\n            if (here.op && (here.op & 0xf0) == 0) {\n                last = here;\n                for (;;) {\n                    here = state->lencode[last.val +\n                            (BITS(last.bits + last.op) >> last.bits)];\n                    if ((unsigned)(last.bits + here.bits) <= bits) break;\n                    PULLBYTE();\n                }\n                DROPBITS(last.bits);\n                state->back += last.bits;\n            }\n            DROPBITS(here.bits);\n            state->back += here.bits;\n            state->length = (unsigned)here.val;\n            if ((int)(here.op) == 0) {\n                Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?\n                        \"inflate:         literal '%c'\\n\" :\n                        \"inflate:         literal 0x%02x\\n\", here.val));\n                state->mode = LIT;\n                break;\n            }\n            if (here.op & 32) {\n                Tracevv((stderr, \"inflate:         end of block\\n\"));\n                state->back = -1;\n                state->mode = TYPE;\n                break;\n            }\n            if (here.op & 64) {\n                strm->msg = (char *)\"invalid literal/length code\";\n                state->mode = BAD;\n                break;\n            }\n            state->extra = (unsigned)(here.op) & 15;\n            state->mode = LENEXT;\n        case LENEXT:\n            if (state->extra) {\n                NEEDBITS(state->extra);\n                state->length += BITS(state->extra);\n                DROPBITS(state->extra);\n                state->back += state->extra;\n            }\n            Tracevv((stderr, \"inflate:         length %u\\n\", state->length));\n            state->was = state->length;\n            state->mode = DIST;\n        case DIST:\n            for (;;) {\n                here = state->distcode[BITS(state->distbits)];\n                if ((unsigned)(here.bits) <= bits) break;\n                PULLBYTE();\n            }\n            if ((here.op & 0xf0) == 0) {\n                last = here;\n                for (;;) {\n                    here = state->distcode[last.val +\n                            (BITS(last.bits + last.op) >> last.bits)];\n                    if ((unsigned)(last.bits + here.bits) <= bits) break;\n                    PULLBYTE();\n                }\n                DROPBITS(last.bits);\n                state->back += last.bits;\n            }\n            DROPBITS(here.bits);\n            state->back += here.bits;\n            if (here.op & 64) {\n                strm->msg = (char *)\"invalid distance code\";\n                state->mode = BAD;\n                break;\n            }\n            state->offset = (unsigned)here.val;\n            state->extra = (unsigned)(here.op) & 15;\n            state->mode = DISTEXT;\n        case DISTEXT:\n            if (state->extra) {\n                NEEDBITS(state->extra);\n                state->offset += BITS(state->extra);\n                DROPBITS(state->extra);\n                state->back += state->extra;\n            }\n#ifdef INFLATE_STRICT\n            if (state->offset > state->dmax) {\n                strm->msg = (char *)\"invalid distance too far back\";\n                state->mode = BAD;\n                break;\n            }\n#endif\n            Tracevv((stderr, \"inflate:         distance %u\\n\", state->offset));\n            state->mode = MATCH;\n        case MATCH:\n            if (left == 0) goto inf_leave;\n            copy = out - left;\n            if (state->offset > copy) {         /* copy from window */\n                copy = state->offset - copy;\n                if (copy > state->whave) {\n                    if (state->sane) {\n                        strm->msg = (char *)\"invalid distance too far back\";\n                        state->mode = BAD;\n                        break;\n                    }\n#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR\n                    Trace((stderr, \"inflate.c too far\\n\"));\n                    copy -= state->whave;\n                    if (copy > state->length) copy = state->length;\n                    if (copy > left) copy = left;\n                    left -= copy;\n                    state->length -= copy;\n                    do {\n                        *put++ = 0;\n                    } while (--copy);\n                    if (state->length == 0) state->mode = LEN;\n                    break;\n#endif\n                }\n                if (copy > state->wnext) {\n                    copy -= state->wnext;\n                    from = state->window + (state->wsize - copy);\n                }\n                else\n                    from = state->window + (state->wnext - copy);\n                if (copy > state->length) copy = state->length;\n            }\n            else {                              /* copy from output */\n                from = put - state->offset;\n                copy = state->length;\n            }\n            if (copy > left) copy = left;\n            left -= copy;\n            state->length -= copy;\n            do {\n                *put++ = *from++;\n            } while (--copy);\n            if (state->length == 0) state->mode = LEN;\n            break;\n        case LIT:\n            if (left == 0) goto inf_leave;\n            *put++ = (unsigned char)(state->length);\n            left--;\n            state->mode = LEN;\n            break;\n        case CHECK:\n            if (state->wrap) {\n                NEEDBITS(32);\n                out -= left;\n                strm->total_out += out;\n                state->total += out;\n                if (out)\n                    strm->adler = state->check =\n                        UPDATE(state->check, put - out, out);\n                out = left;\n                if ((\n#ifdef GUNZIP\n                     state->flags ? hold :\n#endif\n                     REVERSE(hold)) != state->check) {\n                    strm->msg = (char *)\"incorrect data check\";\n                    state->mode = BAD;\n                    break;\n                }\n                INITBITS();\n                Tracev((stderr, \"inflate:   check matches trailer\\n\"));\n            }\n#ifdef GUNZIP\n            state->mode = LENGTH;\n        case LENGTH:\n            if (state->wrap && state->flags) {\n                NEEDBITS(32);\n                if (hold != (state->total & 0xffffffffUL)) {\n                    strm->msg = (char *)\"incorrect length check\";\n                    state->mode = BAD;\n                    break;\n                }\n                INITBITS();\n                Tracev((stderr, \"inflate:   length matches trailer\\n\"));\n            }\n#endif\n            state->mode = DONE;\n        case DONE:\n            ret = Z_STREAM_END;\n            goto inf_leave;\n        case BAD:\n            ret = Z_DATA_ERROR;\n            goto inf_leave;\n        case MEM:\n            return Z_MEM_ERROR;\n        case SYNC:\n        default:\n            return Z_STREAM_ERROR;\n        }\n\n    /*\n       Return from inflate(), updating the total counts and the check value.\n       If there was no progress during the inflate() call, return a buffer\n       error.  Call updatewindow() to create and/or update the window state.\n       Note: a memory error from inflate() is non-recoverable.\n     */\n  inf_leave:\n    RESTORE();\n    if (state->wsize || (out != strm->avail_out && state->mode < BAD &&\n            (state->mode < CHECK || flush != Z_FINISH)))\n        if (updatewindow(strm, out)) {\n            state->mode = MEM;\n            return Z_MEM_ERROR;\n        }\n    in -= strm->avail_in;\n    out -= strm->avail_out;\n    strm->total_in += in;\n    strm->total_out += out;\n    state->total += out;\n    if (state->wrap && out)\n        strm->adler = state->check =\n            UPDATE(state->check, strm->next_out - out, out);\n    strm->data_type = state->bits + (state->last ? 64 : 0) +\n                      (state->mode == TYPE ? 128 : 0) +\n                      (state->mode == LEN_ || state->mode == COPY_ ? 256 : 0);\n    if (((in == 0 && out == 0) || flush == Z_FINISH) && ret == Z_OK)\n        ret = Z_BUF_ERROR;\n    return ret;\n}\n\nint ZEXPORT inflateEnd(strm)\nz_streamp strm;\n{\n    struct inflate_state FAR *state;\n    if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0)\n        return Z_STREAM_ERROR;\n    state = (struct inflate_state FAR *)strm->state;\n    if (state->window != Z_NULL) ZFREE(strm, state->window);\n    ZFREE(strm, strm->state);\n    strm->state = Z_NULL;\n    Tracev((stderr, \"inflate: end\\n\"));\n    return Z_OK;\n}\n\nint ZEXPORT inflateSetDictionary(strm, dictionary, dictLength)\nz_streamp strm;\nconst Bytef *dictionary;\nuInt dictLength;\n{\n    struct inflate_state FAR *state;\n    unsigned long id;\n    unsigned char *next;\n    unsigned avail;\n    int ret;\n\n    /* check state */\n    if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;\n    state = (struct inflate_state FAR *)strm->state;\n    if (state->wrap != 0 && state->mode != DICT)\n        return Z_STREAM_ERROR;\n\n    /* check for correct dictionary id */\n    if (state->mode == DICT) {\n        id = adler32(0L, Z_NULL, 0);\n        id = adler32(id, dictionary, dictLength);\n        if (id != state->check)\n            return Z_DATA_ERROR;\n    }\n\n    /* copy dictionary to window using updatewindow(), which will amend the\n       existing dictionary if appropriate */\n    next = strm->next_out;\n    avail = strm->avail_out;\n    strm->next_out = (Bytef *)dictionary + dictLength;\n    strm->avail_out = 0;\n    ret = updatewindow(strm, dictLength);\n    strm->avail_out = avail;\n    strm->next_out = next;\n    if (ret) {\n        state->mode = MEM;\n        return Z_MEM_ERROR;\n    }\n    state->havedict = 1;\n    Tracev((stderr, \"inflate:   dictionary set\\n\"));\n    return Z_OK;\n}\n\nint ZEXPORT inflateGetHeader(strm, head)\nz_streamp strm;\ngz_headerp head;\n{\n    struct inflate_state FAR *state;\n\n    /* check state */\n    if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;\n    state = (struct inflate_state FAR *)strm->state;\n    if ((state->wrap & 2) == 0) return Z_STREAM_ERROR;\n\n    /* save header structure */\n    state->head = head;\n    head->done = 0;\n    return Z_OK;\n}\n\n/*\n   Search buf[0..len-1] for the pattern: 0, 0, 0xff, 0xff.  Return when found\n   or when out of input.  When called, *have is the number of pattern bytes\n   found in order so far, in 0..3.  On return *have is updated to the new\n   state.  If on return *have equals four, then the pattern was found and the\n   return value is how many bytes were read including the last byte of the\n   pattern.  If *have is less than four, then the pattern has not been found\n   yet and the return value is len.  In the latter case, syncsearch() can be\n   called again with more data and the *have state.  *have is initialized to\n   zero for the first call.\n */\nlocal unsigned syncsearch(have, buf, len)\nunsigned FAR *have;\nunsigned char FAR *buf;\nunsigned len;\n{\n    unsigned got;\n    unsigned next;\n\n    got = *have;\n    next = 0;\n    while (next < len && got < 4) {\n        if ((int)(buf[next]) == (got < 2 ? 0 : 0xff))\n            got++;\n        else if (buf[next])\n            got = 0;\n        else\n            got = 4 - got;\n        next++;\n    }\n    *have = got;\n    return next;\n}\n\nint ZEXPORT inflateSync(strm)\nz_streamp strm;\n{\n    unsigned len;               /* number of bytes to look at or looked at */\n    unsigned long in, out;      /* temporary to save total_in and total_out */\n    unsigned char buf[4];       /* to restore bit buffer to byte string */\n    struct inflate_state FAR *state;\n\n    /* check parameters */\n    if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;\n    state = (struct inflate_state FAR *)strm->state;\n    if (strm->avail_in == 0 && state->bits < 8) return Z_BUF_ERROR;\n\n    /* if first time, start search in bit buffer */\n    if (state->mode != SYNC) {\n        state->mode = SYNC;\n        state->hold <<= state->bits & 7;\n        state->bits -= state->bits & 7;\n        len = 0;\n        while (state->bits >= 8) {\n            buf[len++] = (unsigned char)(state->hold);\n            state->hold >>= 8;\n            state->bits -= 8;\n        }\n        state->have = 0;\n        syncsearch(&(state->have), buf, len);\n    }\n\n    /* search available input */\n    len = syncsearch(&(state->have), strm->next_in, strm->avail_in);\n    strm->avail_in -= len;\n    strm->next_in += len;\n    strm->total_in += len;\n\n    /* return no joy or set up to restart inflate() on a new block */\n    if (state->have != 4) return Z_DATA_ERROR;\n    in = strm->total_in;  out = strm->total_out;\n    inflateReset(strm);\n    strm->total_in = in;  strm->total_out = out;\n    state->mode = TYPE;\n    return Z_OK;\n}\n\n/*\n   Returns true if inflate is currently at the end of a block generated by\n   Z_SYNC_FLUSH or Z_FULL_FLUSH. This function is used by one PPP\n   implementation to provide an additional safety check. PPP uses\n   Z_SYNC_FLUSH but removes the length bytes of the resulting empty stored\n   block. When decompressing, PPP checks that at the end of input packet,\n   inflate is waiting for these length bytes.\n */\nint ZEXPORT inflateSyncPoint(strm)\nz_streamp strm;\n{\n    struct inflate_state FAR *state;\n\n    if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;\n    state = (struct inflate_state FAR *)strm->state;\n    return state->mode == STORED && state->bits == 0;\n}\n\nint ZEXPORT inflateCopy(dest, source)\nz_streamp dest;\nz_streamp source;\n{\n    struct inflate_state FAR *state;\n    struct inflate_state FAR *copy;\n    unsigned char FAR *window;\n    unsigned wsize;\n\n    /* check input */\n    if (dest == Z_NULL || source == Z_NULL || source->state == Z_NULL ||\n        source->zalloc == (alloc_func)0 || source->zfree == (free_func)0)\n        return Z_STREAM_ERROR;\n    state = (struct inflate_state FAR *)source->state;\n\n    /* allocate space */\n    copy = (struct inflate_state FAR *)\n           ZALLOC(source, 1, sizeof(struct inflate_state));\n    if (copy == Z_NULL) return Z_MEM_ERROR;\n    window = Z_NULL;\n    if (state->window != Z_NULL) {\n        window = (unsigned char FAR *)\n                 ZALLOC(source, 1U << state->wbits, sizeof(unsigned char));\n        if (window == Z_NULL) {\n            ZFREE(source, copy);\n            return Z_MEM_ERROR;\n        }\n    }\n\n    /* copy state */\n    zmemcpy((voidpf)dest, (voidpf)source, sizeof(z_stream));\n    zmemcpy((voidpf)copy, (voidpf)state, sizeof(struct inflate_state));\n    if (state->lencode >= state->codes &&\n        state->lencode <= state->codes + ENOUGH - 1) {\n        copy->lencode = copy->codes + (state->lencode - state->codes);\n        copy->distcode = copy->codes + (state->distcode - state->codes);\n    }\n    copy->next = copy->codes + (state->next - state->codes);\n    if (window != Z_NULL) {\n        wsize = 1U << state->wbits;\n        zmemcpy(window, state->window, wsize);\n    }\n    copy->window = window;\n    dest->state = (struct internal_state FAR *)copy;\n    return Z_OK;\n}\n\nint ZEXPORT inflateUndermine(strm, subvert)\nz_streamp strm;\nint subvert;\n{\n    struct inflate_state FAR *state;\n\n    if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;\n    state = (struct inflate_state FAR *)strm->state;\n    state->sane = !subvert;\n#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR\n    return Z_OK;\n#else\n    state->sane = 1;\n    return Z_DATA_ERROR;\n#endif\n}\n\nlong ZEXPORT inflateMark(strm)\nz_streamp strm;\n{\n    struct inflate_state FAR *state;\n\n    if (strm == Z_NULL || strm->state == Z_NULL) return -1L << 16;\n    state = (struct inflate_state FAR *)strm->state;\n    return ((long)(state->back) << 16) +\n        (state->mode == COPY ? state->length :\n            (state->mode == MATCH ? state->was - state->length : 0));\n}\n"
  },
  {
    "path": "Projects/Tools/PNGAlphaPremultiplier/Native/Source/ZLib/inflate.h",
    "content": "/* inflate.h -- internal inflate state definition\n * Copyright (C) 1995-2009 Mark Adler\n * For conditions of distribution and use, see copyright notice in zlib.h\n */\n\n/* WARNING: this file should *not* be used by applications. It is\n   part of the implementation of the compression library and is\n   subject to change. Applications should only use zlib.h.\n */\n\n/* define NO_GZIP when compiling if you want to disable gzip header and\n   trailer decoding by inflate().  NO_GZIP would be used to avoid linking in\n   the crc code when it is not needed.  For shared libraries, gzip decoding\n   should be left enabled. */\n#ifndef NO_GZIP\n#  define GUNZIP\n#endif\n\n/* Possible inflate modes between inflate() calls */\ntypedef enum {\n    HEAD,       /* i: waiting for magic header */\n    FLAGS,      /* i: waiting for method and flags (gzip) */\n    TIME,       /* i: waiting for modification time (gzip) */\n    OS,         /* i: waiting for extra flags and operating system (gzip) */\n    EXLEN,      /* i: waiting for extra length (gzip) */\n    EXTRA,      /* i: waiting for extra bytes (gzip) */\n    NAME,       /* i: waiting for end of file name (gzip) */\n    COMMENT,    /* i: waiting for end of comment (gzip) */\n    HCRC,       /* i: waiting for header crc (gzip) */\n    DICTID,     /* i: waiting for dictionary check value */\n    DICT,       /* waiting for inflateSetDictionary() call */\n        TYPE,       /* i: waiting for type bits, including last-flag bit */\n        TYPEDO,     /* i: same, but skip check to exit inflate on new block */\n        STORED,     /* i: waiting for stored size (length and complement) */\n        COPY_,      /* i/o: same as COPY below, but only first time in */\n        COPY,       /* i/o: waiting for input or output to copy stored block */\n        TABLE,      /* i: waiting for dynamic block table lengths */\n        LENLENS,    /* i: waiting for code length code lengths */\n        CODELENS,   /* i: waiting for length/lit and distance code lengths */\n            LEN_,       /* i: same as LEN below, but only first time in */\n            LEN,        /* i: waiting for length/lit/eob code */\n            LENEXT,     /* i: waiting for length extra bits */\n            DIST,       /* i: waiting for distance code */\n            DISTEXT,    /* i: waiting for distance extra bits */\n            MATCH,      /* o: waiting for output space to copy string */\n            LIT,        /* o: waiting for output space to write literal */\n    CHECK,      /* i: waiting for 32-bit check value */\n    LENGTH,     /* i: waiting for 32-bit length (gzip) */\n    DONE,       /* finished check, done -- remain here until reset */\n    BAD,        /* got a data error -- remain here until reset */\n    MEM,        /* got an inflate() memory error -- remain here until reset */\n    SYNC        /* looking for synchronization bytes to restart inflate() */\n} inflate_mode;\n\n/*\n    State transitions between above modes -\n\n    (most modes can go to BAD or MEM on error -- not shown for clarity)\n\n    Process header:\n        HEAD -> (gzip) or (zlib) or (raw)\n        (gzip) -> FLAGS -> TIME -> OS -> EXLEN -> EXTRA -> NAME -> COMMENT ->\n                  HCRC -> TYPE\n        (zlib) -> DICTID or TYPE\n        DICTID -> DICT -> TYPE\n        (raw) -> TYPEDO\n    Read deflate blocks:\n            TYPE -> TYPEDO -> STORED or TABLE or LEN_ or CHECK\n            STORED -> COPY_ -> COPY -> TYPE\n            TABLE -> LENLENS -> CODELENS -> LEN_\n            LEN_ -> LEN\n    Read deflate codes in fixed or dynamic block:\n                LEN -> LENEXT or LIT or TYPE\n                LENEXT -> DIST -> DISTEXT -> MATCH -> LEN\n                LIT -> LEN\n    Process trailer:\n        CHECK -> LENGTH -> DONE\n */\n\n/* state maintained between inflate() calls.  Approximately 10K bytes. */\nstruct inflate_state {\n    inflate_mode mode;          /* current inflate mode */\n    int last;                   /* true if processing last block */\n    int wrap;                   /* bit 0 true for zlib, bit 1 true for gzip */\n    int havedict;               /* true if dictionary provided */\n    int flags;                  /* gzip header method and flags (0 if zlib) */\n    unsigned dmax;              /* zlib header max distance (INFLATE_STRICT) */\n    unsigned long check;        /* protected copy of check value */\n    unsigned long total;        /* protected copy of output count */\n    gz_headerp head;            /* where to save gzip header information */\n        /* sliding window */\n    unsigned wbits;             /* log base 2 of requested window size */\n    unsigned wsize;             /* window size or zero if not using window */\n    unsigned whave;             /* valid bytes in the window */\n    unsigned wnext;             /* window write index */\n    unsigned char FAR *window;  /* allocated sliding window, if needed */\n        /* bit accumulator */\n    unsigned long hold;         /* input bit accumulator */\n    unsigned bits;              /* number of bits in \"in\" */\n        /* for string and stored block copying */\n    unsigned length;            /* literal or length of data to copy */\n    unsigned offset;            /* distance back to copy string from */\n        /* for table and code decoding */\n    unsigned extra;             /* extra bits needed */\n        /* fixed and dynamic code tables */\n    code const FAR *lencode;    /* starting table for length/literal codes */\n    code const FAR *distcode;   /* starting table for distance codes */\n    unsigned lenbits;           /* index bits for lencode */\n    unsigned distbits;          /* index bits for distcode */\n        /* dynamic table building */\n    unsigned ncode;             /* number of code length code lengths */\n    unsigned nlen;              /* number of length code lengths */\n    unsigned ndist;             /* number of distance code lengths */\n    unsigned have;              /* number of code lengths in lens[] */\n    code FAR *next;             /* next available space in codes[] */\n    unsigned short lens[320];   /* temporary storage for code lengths */\n    unsigned short work[288];   /* work area for code table building */\n    code codes[ENOUGH];         /* space for code tables */\n    int sane;                   /* if false, allow invalid distance too far */\n    int back;                   /* bits back of last unprocessed length/lit */\n    unsigned was;               /* initial length of match */\n};\n"
  },
  {
    "path": "Projects/Tools/PNGAlphaPremultiplier/Native/Source/ZLib/inftrees.c",
    "content": "/* inftrees.c -- generate Huffman trees for efficient decoding\n * Copyright (C) 1995-2012 Mark Adler\n * For conditions of distribution and use, see copyright notice in zlib.h\n */\n\n#include \"zutil.h\"\n#include \"inftrees.h\"\n\n#define MAXBITS 15\n\nconst char inflate_copyright[] =\n   \" inflate 1.2.6 Copyright 1995-2012 Mark Adler \";\n/*\n  If you use the zlib library in a product, an acknowledgment is welcome\n  in the documentation of your product. If for some reason you cannot\n  include such an acknowledgment, I would appreciate that you keep this\n  copyright string in the executable of your product.\n */\n\n/*\n   Build a set of tables to decode the provided canonical Huffman code.\n   The code lengths are lens[0..codes-1].  The result starts at *table,\n   whose indices are 0..2^bits-1.  work is a writable array of at least\n   lens shorts, which is used as a work area.  type is the type of code\n   to be generated, CODES, LENS, or DISTS.  On return, zero is success,\n   -1 is an invalid code, and +1 means that ENOUGH isn't enough.  table\n   on return points to the next available entry's address.  bits is the\n   requested root table index bits, and on return it is the actual root\n   table index bits.  It will differ if the request is greater than the\n   longest code or if it is less than the shortest code.\n */\nint ZLIB_INTERNAL inflate_table(type, lens, codes, table, bits, work)\ncodetype type;\nunsigned short FAR *lens;\nunsigned codes;\ncode FAR * FAR *table;\nunsigned FAR *bits;\nunsigned short FAR *work;\n{\n    unsigned len;               /* a code's length in bits */\n    unsigned sym;               /* index of code symbols */\n    unsigned min, max;          /* minimum and maximum code lengths */\n    unsigned root;              /* number of index bits for root table */\n    unsigned curr;              /* number of index bits for current table */\n    unsigned drop;              /* code bits to drop for sub-table */\n    int left;                   /* number of prefix codes available */\n    unsigned used;              /* code entries in table used */\n    unsigned huff;              /* Huffman code */\n    unsigned incr;              /* for incrementing code, index */\n    unsigned fill;              /* index for replicating entries */\n    unsigned low;               /* low bits for current root entry */\n    unsigned mask;              /* mask for low root bits */\n    code here;                  /* table entry for duplication */\n    code FAR *next;             /* next available space in table */\n    const unsigned short FAR *base;     /* base value table to use */\n    const unsigned short FAR *extra;    /* extra bits table to use */\n    int end;                    /* use base and extra for symbol > end */\n    unsigned short count[MAXBITS+1];    /* number of codes of each length */\n    unsigned short offs[MAXBITS+1];     /* offsets in table for each length */\n    static const unsigned short lbase[31] = { /* Length codes 257..285 base */\n        3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,\n        35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};\n    static const unsigned short lext[31] = { /* Length codes 257..285 extra */\n        16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,\n        19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 203, 69};\n    static const unsigned short dbase[32] = { /* Distance codes 0..29 base */\n        1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,\n        257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,\n        8193, 12289, 16385, 24577, 0, 0};\n    static const unsigned short dext[32] = { /* Distance codes 0..29 extra */\n        16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22,\n        23, 23, 24, 24, 25, 25, 26, 26, 27, 27,\n        28, 28, 29, 29, 64, 64};\n\n    /*\n       Process a set of code lengths to create a canonical Huffman code.  The\n       code lengths are lens[0..codes-1].  Each length corresponds to the\n       symbols 0..codes-1.  The Huffman code is generated by first sorting the\n       symbols by length from short to long, and retaining the symbol order\n       for codes with equal lengths.  Then the code starts with all zero bits\n       for the first code of the shortest length, and the codes are integer\n       increments for the same length, and zeros are appended as the length\n       increases.  For the deflate format, these bits are stored backwards\n       from their more natural integer increment ordering, and so when the\n       decoding tables are built in the large loop below, the integer codes\n       are incremented backwards.\n\n       This routine assumes, but does not check, that all of the entries in\n       lens[] are in the range 0..MAXBITS.  The caller must assure this.\n       1..MAXBITS is interpreted as that code length.  zero means that that\n       symbol does not occur in this code.\n\n       The codes are sorted by computing a count of codes for each length,\n       creating from that a table of starting indices for each length in the\n       sorted table, and then entering the symbols in order in the sorted\n       table.  The sorted table is work[], with that space being provided by\n       the caller.\n\n       The length counts are used for other purposes as well, i.e. finding\n       the minimum and maximum length codes, determining if there are any\n       codes at all, checking for a valid set of lengths, and looking ahead\n       at length counts to determine sub-table sizes when building the\n       decoding tables.\n     */\n\n    /* accumulate lengths for codes (assumes lens[] all in 0..MAXBITS) */\n    for (len = 0; len <= MAXBITS; len++)\n        count[len] = 0;\n    for (sym = 0; sym < codes; sym++)\n        count[lens[sym]]++;\n\n    /* bound code lengths, force root to be within code lengths */\n    root = *bits;\n    for (max = MAXBITS; max >= 1; max--)\n        if (count[max] != 0) break;\n    if (root > max) root = max;\n    if (max == 0) {                     /* no symbols to code at all */\n        here.op = (unsigned char)64;    /* invalid code marker */\n        here.bits = (unsigned char)1;\n        here.val = (unsigned short)0;\n        *(*table)++ = here;             /* make a table to force an error */\n        *(*table)++ = here;\n        *bits = 1;\n        return 0;     /* no symbols, but wait for decoding to report error */\n    }\n    for (min = 1; min < max; min++)\n        if (count[min] != 0) break;\n    if (root < min) root = min;\n\n    /* check for an over-subscribed or incomplete set of lengths */\n    left = 1;\n    for (len = 1; len <= MAXBITS; len++) {\n        left <<= 1;\n        left -= count[len];\n        if (left < 0) return -1;        /* over-subscribed */\n    }\n    if (left > 0 && (type == CODES || max != 1))\n        return -1;                      /* incomplete set */\n\n    /* generate offsets into symbol table for each length for sorting */\n    offs[1] = 0;\n    for (len = 1; len < MAXBITS; len++)\n        offs[len + 1] = offs[len] + count[len];\n\n    /* sort symbols by length, by symbol order within each length */\n    for (sym = 0; sym < codes; sym++)\n        if (lens[sym] != 0) work[offs[lens[sym]]++] = (unsigned short)sym;\n\n    /*\n       Create and fill in decoding tables.  In this loop, the table being\n       filled is at next and has curr index bits.  The code being used is huff\n       with length len.  That code is converted to an index by dropping drop\n       bits off of the bottom.  For codes where len is less than drop + curr,\n       those top drop + curr - len bits are incremented through all values to\n       fill the table with replicated entries.\n\n       root is the number of index bits for the root table.  When len exceeds\n       root, sub-tables are created pointed to by the root entry with an index\n       of the low root bits of huff.  This is saved in low to check for when a\n       new sub-table should be started.  drop is zero when the root table is\n       being filled, and drop is root when sub-tables are being filled.\n\n       When a new sub-table is needed, it is necessary to look ahead in the\n       code lengths to determine what size sub-table is needed.  The length\n       counts are used for this, and so count[] is decremented as codes are\n       entered in the tables.\n\n       used keeps track of how many table entries have been allocated from the\n       provided *table space.  It is checked for LENS and DIST tables against\n       the constants ENOUGH_LENS and ENOUGH_DISTS to guard against changes in\n       the initial root table size constants.  See the comments in inftrees.h\n       for more information.\n\n       sym increments through all symbols, and the loop terminates when\n       all codes of length max, i.e. all codes, have been processed.  This\n       routine permits incomplete codes, so another loop after this one fills\n       in the rest of the decoding tables with invalid code markers.\n     */\n\n    /* set up for code type */\n    switch (type) {\n    case CODES:\n        base = extra = work;    /* dummy value--not used */\n        end = 19;\n        break;\n    case LENS:\n        base = lbase;\n        base -= 257;\n        extra = lext;\n        extra -= 257;\n        end = 256;\n        break;\n    default:            /* DISTS */\n        base = dbase;\n        extra = dext;\n        end = -1;\n    }\n\n    /* initialize state for loop */\n    huff = 0;                   /* starting code */\n    sym = 0;                    /* starting code symbol */\n    len = min;                  /* starting code length */\n    next = *table;              /* current table to fill in */\n    curr = root;                /* current table index bits */\n    drop = 0;                   /* current bits to drop from code for index */\n    low = (unsigned)(-1);       /* trigger new sub-table when len > root */\n    used = 1U << root;          /* use root table entries */\n    mask = used - 1;            /* mask for comparing low */\n\n    /* check available table space */\n    if ((type == LENS && used >= ENOUGH_LENS) ||\n        (type == DISTS && used >= ENOUGH_DISTS))\n        return 1;\n\n    /* process all codes and make table entries */\n    for (;;) {\n        /* create table entry */\n        here.bits = (unsigned char)(len - drop);\n        if ((int)(work[sym]) < end) {\n            here.op = (unsigned char)0;\n            here.val = work[sym];\n        }\n        else if ((int)(work[sym]) > end) {\n            here.op = (unsigned char)(extra[work[sym]]);\n            here.val = base[work[sym]];\n        }\n        else {\n            here.op = (unsigned char)(32 + 64);         /* end of block */\n            here.val = 0;\n        }\n\n        /* replicate for those indices with low len bits equal to huff */\n        incr = 1U << (len - drop);\n        fill = 1U << curr;\n        min = fill;                 /* save offset to next table */\n        do {\n            fill -= incr;\n            next[(huff >> drop) + fill] = here;\n        } while (fill != 0);\n\n        /* backwards increment the len-bit code huff */\n        incr = 1U << (len - 1);\n        while (huff & incr)\n            incr >>= 1;\n        if (incr != 0) {\n            huff &= incr - 1;\n            huff += incr;\n        }\n        else\n            huff = 0;\n\n        /* go to next symbol, update count, len */\n        sym++;\n        if (--(count[len]) == 0) {\n            if (len == max) break;\n            len = lens[work[sym]];\n        }\n\n        /* create new sub-table if needed */\n        if (len > root && (huff & mask) != low) {\n            /* if first time, transition to sub-tables */\n            if (drop == 0)\n                drop = root;\n\n            /* increment past last table */\n            next += min;            /* here min is 1 << curr */\n\n            /* determine length of next table */\n            curr = len - drop;\n            left = (int)(1 << curr);\n            while (curr + drop < max) {\n                left -= count[curr + drop];\n                if (left <= 0) break;\n                curr++;\n                left <<= 1;\n            }\n\n            /* check for enough space */\n            used += 1U << curr;\n            if ((type == LENS && used >= ENOUGH_LENS) ||\n                (type == DISTS && used >= ENOUGH_DISTS))\n                return 1;\n\n            /* point entry in root table to sub-table */\n            low = huff & mask;\n            (*table)[low].op = (unsigned char)curr;\n            (*table)[low].bits = (unsigned char)root;\n            (*table)[low].val = (unsigned short)(next - *table);\n        }\n    }\n\n    /* fill in remaining table entry if code is incomplete (guaranteed to have\n       at most one remaining entry, since if the code is incomplete, the\n       maximum code length that was allowed to get this far is one bit) */\n    if (huff != 0) {\n        here.op = (unsigned char)64;            /* invalid code marker */\n        here.bits = (unsigned char)(len - drop);\n        here.val = (unsigned short)0;\n        next[huff] = here;\n    }\n\n    /* set return parameters */\n    *table += used;\n    *bits = root;\n    return 0;\n}\n"
  },
  {
    "path": "Projects/Tools/PNGAlphaPremultiplier/Native/Source/ZLib/inftrees.h",
    "content": "/* inftrees.h -- header to use inftrees.c\n * Copyright (C) 1995-2005, 2010 Mark Adler\n * For conditions of distribution and use, see copyright notice in zlib.h\n */\n\n/* WARNING: this file should *not* be used by applications. It is\n   part of the implementation of the compression library and is\n   subject to change. Applications should only use zlib.h.\n */\n\n/* Structure for decoding tables.  Each entry provides either the\n   information needed to do the operation requested by the code that\n   indexed that table entry, or it provides a pointer to another\n   table that indexes more bits of the code.  op indicates whether\n   the entry is a pointer to another table, a literal, a length or\n   distance, an end-of-block, or an invalid code.  For a table\n   pointer, the low four bits of op is the number of index bits of\n   that table.  For a length or distance, the low four bits of op\n   is the number of extra bits to get after the code.  bits is\n   the number of bits in this code or part of the code to drop off\n   of the bit buffer.  val is the actual byte to output in the case\n   of a literal, the base length or distance, or the offset from\n   the current table to the next table.  Each entry is four bytes. */\ntypedef struct {\n    unsigned char op;           /* operation, extra bits, table bits */\n    unsigned char bits;         /* bits in this part of the code */\n    unsigned short val;         /* offset in table or code value */\n} code;\n\n/* op values as set by inflate_table():\n    00000000 - literal\n    0000tttt - table link, tttt != 0 is the number of table index bits\n    0001eeee - length or distance, eeee is the number of extra bits\n    01100000 - end of block\n    01000000 - invalid code\n */\n\n/* Maximum size of the dynamic table.  The maximum number of code structures is\n   1444, which is the sum of 852 for literal/length codes and 592 for distance\n   codes.  These values were found by exhaustive searches using the program\n   examples/enough.c found in the zlib distribtution.  The arguments to that\n   program are the number of symbols, the initial root table size, and the\n   maximum bit length of a code.  \"enough 286 9 15\" for literal/length codes\n   returns returns 852, and \"enough 30 6 15\" for distance codes returns 592.\n   The initial root table size (9 or 6) is found in the fifth argument of the\n   inflate_table() calls in inflate.c and infback.c.  If the root table size is\n   changed, then these maximum sizes would be need to be recalculated and\n   updated. */\n#define ENOUGH_LENS 852\n#define ENOUGH_DISTS 592\n#define ENOUGH (ENOUGH_LENS+ENOUGH_DISTS)\n\n/* Type of code to build for inflate_table() */\ntypedef enum {\n    CODES,\n    LENS,\n    DISTS\n} codetype;\n\nint ZLIB_INTERNAL inflate_table OF((codetype type, unsigned short FAR *lens,\n                             unsigned codes, code FAR * FAR *table,\n                             unsigned FAR *bits, unsigned short FAR *work));\n"
  },
  {
    "path": "Projects/Tools/PNGAlphaPremultiplier/Native/Source/ZLib/trees.c",
    "content": "/* trees.c -- output deflated data using Huffman coding\n * Copyright (C) 1995-2012 Jean-loup Gailly\n * detect_data_type() function provided freely by Cosmin Truta, 2006\n * For conditions of distribution and use, see copyright notice in zlib.h\n */\n\n/*\n *  ALGORITHM\n *\n *      The \"deflation\" process uses several Huffman trees. The more\n *      common source values are represented by shorter bit sequences.\n *\n *      Each code tree is stored in a compressed form which is itself\n * a Huffman encoding of the lengths of all the code strings (in\n * ascending order by source values).  The actual code strings are\n * reconstructed from the lengths in the inflate process, as described\n * in the deflate specification.\n *\n *  REFERENCES\n *\n *      Deutsch, L.P.,\"'Deflate' Compressed Data Format Specification\".\n *      Available in ftp.uu.net:/pub/archiving/zip/doc/deflate-1.1.doc\n *\n *      Storer, James A.\n *          Data Compression:  Methods and Theory, pp. 49-50.\n *          Computer Science Press, 1988.  ISBN 0-7167-8156-5.\n *\n *      Sedgewick, R.\n *          Algorithms, p290.\n *          Addison-Wesley, 1983. ISBN 0-201-06672-6.\n */\n\n/* @(#) $Id$ */\n\n/* #define GEN_TREES_H */\n\n#include \"deflate.h\"\n\n#ifdef DEBUG\n#  include <ctype.h>\n#endif\n\n/* ===========================================================================\n * Constants\n */\n\n#define MAX_BL_BITS 7\n/* Bit length codes must not exceed MAX_BL_BITS bits */\n\n#define END_BLOCK 256\n/* end of block literal code */\n\n#define REP_3_6      16\n/* repeat previous bit length 3-6 times (2 bits of repeat count) */\n\n#define REPZ_3_10    17\n/* repeat a zero length 3-10 times  (3 bits of repeat count) */\n\n#define REPZ_11_138  18\n/* repeat a zero length 11-138 times  (7 bits of repeat count) */\n\nlocal const int extra_lbits[LENGTH_CODES] /* extra bits for each length code */\n   = {0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0};\n\nlocal const int extra_dbits[D_CODES] /* extra bits for each distance code */\n   = {0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13};\n\nlocal const int extra_blbits[BL_CODES]/* extra bits for each bit length code */\n   = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7};\n\nlocal const uch bl_order[BL_CODES]\n   = {16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15};\n/* The lengths of the bit length codes are sent in order of decreasing\n * probability, to avoid transmitting the lengths for unused bit length codes.\n */\n\n/* ===========================================================================\n * Local data. These are initialized only once.\n */\n\n#define DIST_CODE_LEN  512 /* see definition of array dist_code below */\n\n#if defined(GEN_TREES_H) || !defined(STDC)\n/* non ANSI compilers may not accept trees.h */\n\nlocal ct_data static_ltree[L_CODES+2];\n/* The static literal tree. Since the bit lengths are imposed, there is no\n * need for the L_CODES extra codes used during heap construction. However\n * The codes 286 and 287 are needed to build a canonical tree (see _tr_init\n * below).\n */\n\nlocal ct_data static_dtree[D_CODES];\n/* The static distance tree. (Actually a trivial tree since all codes use\n * 5 bits.)\n */\n\nuch _dist_code[DIST_CODE_LEN];\n/* Distance codes. The first 256 values correspond to the distances\n * 3 .. 258, the last 256 values correspond to the top 8 bits of\n * the 15 bit distances.\n */\n\nuch _length_code[MAX_MATCH-MIN_MATCH+1];\n/* length code for each normalized match length (0 == MIN_MATCH) */\n\nlocal int base_length[LENGTH_CODES];\n/* First normalized length for each code (0 = MIN_MATCH) */\n\nlocal int base_dist[D_CODES];\n/* First normalized distance for each code (0 = distance of 1) */\n\n#else\n#  include \"trees.h\"\n#endif /* GEN_TREES_H */\n\nstruct static_tree_desc_s {\n    const ct_data *static_tree;  /* static tree or NULL */\n    const intf *extra_bits;      /* extra bits for each code or NULL */\n    int     extra_base;          /* base index for extra_bits */\n    int     elems;               /* max number of elements in the tree */\n    int     max_length;          /* max bit length for the codes */\n};\n\nlocal static_tree_desc  static_l_desc =\n{static_ltree, extra_lbits, LITERALS+1, L_CODES, MAX_BITS};\n\nlocal static_tree_desc  static_d_desc =\n{static_dtree, extra_dbits, 0,          D_CODES, MAX_BITS};\n\nlocal static_tree_desc  static_bl_desc =\n{(const ct_data *)0, extra_blbits, 0,   BL_CODES, MAX_BL_BITS};\n\n/* ===========================================================================\n * Local (static) routines in this file.\n */\n\nlocal void tr_static_init OF((void));\nlocal void init_block     OF((deflate_state *s));\nlocal void pqdownheap     OF((deflate_state *s, ct_data *tree, int k));\nlocal void gen_bitlen     OF((deflate_state *s, tree_desc *desc));\nlocal void gen_codes      OF((ct_data *tree, int max_code, ushf *bl_count));\nlocal void build_tree     OF((deflate_state *s, tree_desc *desc));\nlocal void scan_tree      OF((deflate_state *s, ct_data *tree, int max_code));\nlocal void send_tree      OF((deflate_state *s, ct_data *tree, int max_code));\nlocal int  build_bl_tree  OF((deflate_state *s));\nlocal void send_all_trees OF((deflate_state *s, int lcodes, int dcodes,\n                              int blcodes));\nlocal void compress_block OF((deflate_state *s, ct_data *ltree,\n                              ct_data *dtree));\nlocal int  detect_data_type OF((deflate_state *s));\nlocal unsigned bi_reverse OF((unsigned value, int length));\nlocal void bi_windup      OF((deflate_state *s));\nlocal void bi_flush       OF((deflate_state *s));\nlocal void copy_block     OF((deflate_state *s, charf *buf, unsigned len,\n                              int header));\n\n#ifdef GEN_TREES_H\nlocal void gen_trees_header OF((void));\n#endif\n\n#ifndef DEBUG\n#  define send_code(s, c, tree) send_bits(s, tree[c].Code, tree[c].Len)\n   /* Send a code of the given tree. c and tree must not have side effects */\n\n#else /* DEBUG */\n#  define send_code(s, c, tree) \\\n     { if (z_verbose>2) fprintf(stderr,\"\\ncd %3d \",(c)); \\\n       send_bits(s, tree[c].Code, tree[c].Len); }\n#endif\n\n/* ===========================================================================\n * Output a short LSB first on the stream.\n * IN assertion: there is enough room in pendingBuf.\n */\n#define put_short(s, w) { \\\n    put_byte(s, (uch)((w) & 0xff)); \\\n    put_byte(s, (uch)((ush)(w) >> 8)); \\\n}\n\n/* ===========================================================================\n * Send a value on a given number of bits.\n * IN assertion: length <= 16 and value fits in length bits.\n */\n#ifdef DEBUG\nlocal void send_bits      OF((deflate_state *s, int value, int length));\n\nlocal void send_bits(s, value, length)\n    deflate_state *s;\n    int value;  /* value to send */\n    int length; /* number of bits */\n{\n    Tracevv((stderr,\" l %2d v %4x \", length, value));\n    Assert(length > 0 && length <= 15, \"invalid length\");\n    s->bits_sent += (ulg)length;\n\n    /* If not enough room in bi_buf, use (valid) bits from bi_buf and\n     * (16 - bi_valid) bits from value, leaving (width - (16-bi_valid))\n     * unused bits in value.\n     */\n    if (s->bi_valid > (int)Buf_size - length) {\n        s->bi_buf |= (ush)value << s->bi_valid;\n        put_short(s, s->bi_buf);\n        s->bi_buf = (ush)value >> (Buf_size - s->bi_valid);\n        s->bi_valid += length - Buf_size;\n    } else {\n        s->bi_buf |= (ush)value << s->bi_valid;\n        s->bi_valid += length;\n    }\n}\n#else /* !DEBUG */\n\n#define send_bits(s, value, length) \\\n{ int len = length;\\\n  if (s->bi_valid > (int)Buf_size - len) {\\\n    int val = value;\\\n    s->bi_buf |= (ush)val << s->bi_valid;\\\n    put_short(s, s->bi_buf);\\\n    s->bi_buf = (ush)val >> (Buf_size - s->bi_valid);\\\n    s->bi_valid += len - Buf_size;\\\n  } else {\\\n    s->bi_buf |= (ush)(value) << s->bi_valid;\\\n    s->bi_valid += len;\\\n  }\\\n}\n#endif /* DEBUG */\n\n\n/* the arguments must not have side effects */\n\n/* ===========================================================================\n * Initialize the various 'constant' tables.\n */\nlocal void tr_static_init()\n{\n#if defined(GEN_TREES_H) || !defined(STDC)\n    static int static_init_done = 0;\n    int n;        /* iterates over tree elements */\n    int bits;     /* bit counter */\n    int length;   /* length value */\n    int code;     /* code value */\n    int dist;     /* distance index */\n    ush bl_count[MAX_BITS+1];\n    /* number of codes at each bit length for an optimal tree */\n\n    if (static_init_done) return;\n\n    /* For some embedded targets, global variables are not initialized: */\n#ifdef NO_INIT_GLOBAL_POINTERS\n    static_l_desc.static_tree = static_ltree;\n    static_l_desc.extra_bits = extra_lbits;\n    static_d_desc.static_tree = static_dtree;\n    static_d_desc.extra_bits = extra_dbits;\n    static_bl_desc.extra_bits = extra_blbits;\n#endif\n\n    /* Initialize the mapping length (0..255) -> length code (0..28) */\n    length = 0;\n    for (code = 0; code < LENGTH_CODES-1; code++) {\n        base_length[code] = length;\n        for (n = 0; n < (1<<extra_lbits[code]); n++) {\n            _length_code[length++] = (uch)code;\n        }\n    }\n    Assert (length == 256, \"tr_static_init: length != 256\");\n    /* Note that the length 255 (match length 258) can be represented\n     * in two different ways: code 284 + 5 bits or code 285, so we\n     * overwrite length_code[255] to use the best encoding:\n     */\n    _length_code[length-1] = (uch)code;\n\n    /* Initialize the mapping dist (0..32K) -> dist code (0..29) */\n    dist = 0;\n    for (code = 0 ; code < 16; code++) {\n        base_dist[code] = dist;\n        for (n = 0; n < (1<<extra_dbits[code]); n++) {\n            _dist_code[dist++] = (uch)code;\n        }\n    }\n    Assert (dist == 256, \"tr_static_init: dist != 256\");\n    dist >>= 7; /* from now on, all distances are divided by 128 */\n    for ( ; code < D_CODES; code++) {\n        base_dist[code] = dist << 7;\n        for (n = 0; n < (1<<(extra_dbits[code]-7)); n++) {\n            _dist_code[256 + dist++] = (uch)code;\n        }\n    }\n    Assert (dist == 256, \"tr_static_init: 256+dist != 512\");\n\n    /* Construct the codes of the static literal tree */\n    for (bits = 0; bits <= MAX_BITS; bits++) bl_count[bits] = 0;\n    n = 0;\n    while (n <= 143) static_ltree[n++].Len = 8, bl_count[8]++;\n    while (n <= 255) static_ltree[n++].Len = 9, bl_count[9]++;\n    while (n <= 279) static_ltree[n++].Len = 7, bl_count[7]++;\n    while (n <= 287) static_ltree[n++].Len = 8, bl_count[8]++;\n    /* Codes 286 and 287 do not exist, but we must include them in the\n     * tree construction to get a canonical Huffman tree (longest code\n     * all ones)\n     */\n    gen_codes((ct_data *)static_ltree, L_CODES+1, bl_count);\n\n    /* The static distance tree is trivial: */\n    for (n = 0; n < D_CODES; n++) {\n        static_dtree[n].Len = 5;\n        static_dtree[n].Code = bi_reverse((unsigned)n, 5);\n    }\n    static_init_done = 1;\n\n#  ifdef GEN_TREES_H\n    gen_trees_header();\n#  endif\n#endif /* defined(GEN_TREES_H) || !defined(STDC) */\n}\n\n/* ===========================================================================\n * Genererate the file trees.h describing the static trees.\n */\n#ifdef GEN_TREES_H\n#  ifndef DEBUG\n#    include <stdio.h>\n#  endif\n\n#  define SEPARATOR(i, last, width) \\\n      ((i) == (last)? \"\\n};\\n\\n\" :    \\\n       ((i) % (width) == (width)-1 ? \",\\n\" : \", \"))\n\nvoid gen_trees_header()\n{\n    FILE *header = fopen(\"trees.h\", \"w\");\n    int i;\n\n    Assert (header != NULL, \"Can't open trees.h\");\n    fprintf(header,\n            \"/* header created automatically with -DGEN_TREES_H */\\n\\n\");\n\n    fprintf(header, \"local const ct_data static_ltree[L_CODES+2] = {\\n\");\n    for (i = 0; i < L_CODES+2; i++) {\n        fprintf(header, \"{{%3u},{%3u}}%s\", static_ltree[i].Code,\n                static_ltree[i].Len, SEPARATOR(i, L_CODES+1, 5));\n    }\n\n    fprintf(header, \"local const ct_data static_dtree[D_CODES] = {\\n\");\n    for (i = 0; i < D_CODES; i++) {\n        fprintf(header, \"{{%2u},{%2u}}%s\", static_dtree[i].Code,\n                static_dtree[i].Len, SEPARATOR(i, D_CODES-1, 5));\n    }\n\n    fprintf(header, \"const uch ZLIB_INTERNAL _dist_code[DIST_CODE_LEN] = {\\n\");\n    for (i = 0; i < DIST_CODE_LEN; i++) {\n        fprintf(header, \"%2u%s\", _dist_code[i],\n                SEPARATOR(i, DIST_CODE_LEN-1, 20));\n    }\n\n    fprintf(header,\n        \"const uch ZLIB_INTERNAL _length_code[MAX_MATCH-MIN_MATCH+1]= {\\n\");\n    for (i = 0; i < MAX_MATCH-MIN_MATCH+1; i++) {\n        fprintf(header, \"%2u%s\", _length_code[i],\n                SEPARATOR(i, MAX_MATCH-MIN_MATCH, 20));\n    }\n\n    fprintf(header, \"local const int base_length[LENGTH_CODES] = {\\n\");\n    for (i = 0; i < LENGTH_CODES; i++) {\n        fprintf(header, \"%1u%s\", base_length[i],\n                SEPARATOR(i, LENGTH_CODES-1, 20));\n    }\n\n    fprintf(header, \"local const int base_dist[D_CODES] = {\\n\");\n    for (i = 0; i < D_CODES; i++) {\n        fprintf(header, \"%5u%s\", base_dist[i],\n                SEPARATOR(i, D_CODES-1, 10));\n    }\n\n    fclose(header);\n}\n#endif /* GEN_TREES_H */\n\n/* ===========================================================================\n * Initialize the tree data structures for a new zlib stream.\n */\nvoid ZLIB_INTERNAL _tr_init(s)\n    deflate_state *s;\n{\n    tr_static_init();\n\n    s->l_desc.dyn_tree = s->dyn_ltree;\n    s->l_desc.stat_desc = &static_l_desc;\n\n    s->d_desc.dyn_tree = s->dyn_dtree;\n    s->d_desc.stat_desc = &static_d_desc;\n\n    s->bl_desc.dyn_tree = s->bl_tree;\n    s->bl_desc.stat_desc = &static_bl_desc;\n\n    s->bi_buf = 0;\n    s->bi_valid = 0;\n#ifdef DEBUG\n    s->compressed_len = 0L;\n    s->bits_sent = 0L;\n#endif\n\n    /* Initialize the first block of the first file: */\n    init_block(s);\n}\n\n/* ===========================================================================\n * Initialize a new block.\n */\nlocal void init_block(s)\n    deflate_state *s;\n{\n    int n; /* iterates over tree elements */\n\n    /* Initialize the trees. */\n    for (n = 0; n < L_CODES;  n++) s->dyn_ltree[n].Freq = 0;\n    for (n = 0; n < D_CODES;  n++) s->dyn_dtree[n].Freq = 0;\n    for (n = 0; n < BL_CODES; n++) s->bl_tree[n].Freq = 0;\n\n    s->dyn_ltree[END_BLOCK].Freq = 1;\n    s->opt_len = s->static_len = 0L;\n    s->last_lit = s->matches = 0;\n}\n\n#define SMALLEST 1\n/* Index within the heap array of least frequent node in the Huffman tree */\n\n\n/* ===========================================================================\n * Remove the smallest element from the heap and recreate the heap with\n * one less element. Updates heap and heap_len.\n */\n#define pqremove(s, tree, top) \\\n{\\\n    top = s->heap[SMALLEST]; \\\n    s->heap[SMALLEST] = s->heap[s->heap_len--]; \\\n    pqdownheap(s, tree, SMALLEST); \\\n}\n\n/* ===========================================================================\n * Compares to subtrees, using the tree depth as tie breaker when\n * the subtrees have equal frequency. This minimizes the worst case length.\n */\n#define smaller(tree, n, m, depth) \\\n   (tree[n].Freq < tree[m].Freq || \\\n   (tree[n].Freq == tree[m].Freq && depth[n] <= depth[m]))\n\n/* ===========================================================================\n * Restore the heap property by moving down the tree starting at node k,\n * exchanging a node with the smallest of its two sons if necessary, stopping\n * when the heap property is re-established (each father smaller than its\n * two sons).\n */\nlocal void pqdownheap(s, tree, k)\n    deflate_state *s;\n    ct_data *tree;  /* the tree to restore */\n    int k;               /* node to move down */\n{\n    int v = s->heap[k];\n    int j = k << 1;  /* left son of k */\n    while (j <= s->heap_len) {\n        /* Set j to the smallest of the two sons: */\n        if (j < s->heap_len &&\n            smaller(tree, s->heap[j+1], s->heap[j], s->depth)) {\n            j++;\n        }\n        /* Exit if v is smaller than both sons */\n        if (smaller(tree, v, s->heap[j], s->depth)) break;\n\n        /* Exchange v with the smallest son */\n        s->heap[k] = s->heap[j];  k = j;\n\n        /* And continue down the tree, setting j to the left son of k */\n        j <<= 1;\n    }\n    s->heap[k] = v;\n}\n\n/* ===========================================================================\n * Compute the optimal bit lengths for a tree and update the total bit length\n * for the current block.\n * IN assertion: the fields freq and dad are set, heap[heap_max] and\n *    above are the tree nodes sorted by increasing frequency.\n * OUT assertions: the field len is set to the optimal bit length, the\n *     array bl_count contains the frequencies for each bit length.\n *     The length opt_len is updated; static_len is also updated if stree is\n *     not null.\n */\nlocal void gen_bitlen(s, desc)\n    deflate_state *s;\n    tree_desc *desc;    /* the tree descriptor */\n{\n    ct_data *tree        = desc->dyn_tree;\n    int max_code         = desc->max_code;\n    const ct_data *stree = desc->stat_desc->static_tree;\n    const intf *extra    = desc->stat_desc->extra_bits;\n    int base             = desc->stat_desc->extra_base;\n    int max_length       = desc->stat_desc->max_length;\n    int h;              /* heap index */\n    int n, m;           /* iterate over the tree elements */\n    int bits;           /* bit length */\n    int xbits;          /* extra bits */\n    ush f;              /* frequency */\n    int overflow = 0;   /* number of elements with bit length too large */\n\n    for (bits = 0; bits <= MAX_BITS; bits++) s->bl_count[bits] = 0;\n\n    /* In a first pass, compute the optimal bit lengths (which may\n     * overflow in the case of the bit length tree).\n     */\n    tree[s->heap[s->heap_max]].Len = 0; /* root of the heap */\n\n    for (h = s->heap_max+1; h < HEAP_SIZE; h++) {\n        n = s->heap[h];\n        bits = tree[tree[n].Dad].Len + 1;\n        if (bits > max_length) bits = max_length, overflow++;\n        tree[n].Len = (ush)bits;\n        /* We overwrite tree[n].Dad which is no longer needed */\n\n        if (n > max_code) continue; /* not a leaf node */\n\n        s->bl_count[bits]++;\n        xbits = 0;\n        if (n >= base) xbits = extra[n-base];\n        f = tree[n].Freq;\n        s->opt_len += (ulg)f * (bits + xbits);\n        if (stree) s->static_len += (ulg)f * (stree[n].Len + xbits);\n    }\n    if (overflow == 0) return;\n\n    Trace((stderr,\"\\nbit length overflow\\n\"));\n    /* This happens for example on obj2 and pic of the Calgary corpus */\n\n    /* Find the first bit length which could increase: */\n    do {\n        bits = max_length-1;\n        while (s->bl_count[bits] == 0) bits--;\n        s->bl_count[bits]--;      /* move one leaf down the tree */\n        s->bl_count[bits+1] += 2; /* move one overflow item as its brother */\n        s->bl_count[max_length]--;\n        /* The brother of the overflow item also moves one step up,\n         * but this does not affect bl_count[max_length]\n         */\n        overflow -= 2;\n    } while (overflow > 0);\n\n    /* Now recompute all bit lengths, scanning in increasing frequency.\n     * h is still equal to HEAP_SIZE. (It is simpler to reconstruct all\n     * lengths instead of fixing only the wrong ones. This idea is taken\n     * from 'ar' written by Haruhiko Okumura.)\n     */\n    for (bits = max_length; bits != 0; bits--) {\n        n = s->bl_count[bits];\n        while (n != 0) {\n            m = s->heap[--h];\n            if (m > max_code) continue;\n            if ((unsigned) tree[m].Len != (unsigned) bits) {\n                Trace((stderr,\"code %d bits %d->%d\\n\", m, tree[m].Len, bits));\n                s->opt_len += ((long)bits - (long)tree[m].Len)\n                              *(long)tree[m].Freq;\n                tree[m].Len = (ush)bits;\n            }\n            n--;\n        }\n    }\n}\n\n/* ===========================================================================\n * Generate the codes for a given tree and bit counts (which need not be\n * optimal).\n * IN assertion: the array bl_count contains the bit length statistics for\n * the given tree and the field len is set for all tree elements.\n * OUT assertion: the field code is set for all tree elements of non\n *     zero code length.\n */\nlocal void gen_codes (tree, max_code, bl_count)\n    ct_data *tree;             /* the tree to decorate */\n    int max_code;              /* largest code with non zero frequency */\n    ushf *bl_count;            /* number of codes at each bit length */\n{\n    ush next_code[MAX_BITS+1]; /* next code value for each bit length */\n    ush code = 0;              /* running code value */\n    int bits;                  /* bit index */\n    int n;                     /* code index */\n\n    /* The distribution counts are first used to generate the code values\n     * without bit reversal.\n     */\n    for (bits = 1; bits <= MAX_BITS; bits++) {\n        next_code[bits] = code = (code + bl_count[bits-1]) << 1;\n    }\n    /* Check that the bit counts in bl_count are consistent. The last code\n     * must be all ones.\n     */\n    Assert (code + bl_count[MAX_BITS]-1 == (1<<MAX_BITS)-1,\n            \"inconsistent bit counts\");\n    Tracev((stderr,\"\\ngen_codes: max_code %d \", max_code));\n\n    for (n = 0;  n <= max_code; n++) {\n        int len = tree[n].Len;\n        if (len == 0) continue;\n        /* Now reverse the bits */\n        tree[n].Code = bi_reverse(next_code[len]++, len);\n\n        Tracecv(tree != static_ltree, (stderr,\"\\nn %3d %c l %2d c %4x (%x) \",\n             n, (isgraph(n) ? n : ' '), len, tree[n].Code, next_code[len]-1));\n    }\n}\n\n/* ===========================================================================\n * Construct one Huffman tree and assigns the code bit strings and lengths.\n * Update the total bit length for the current block.\n * IN assertion: the field freq is set for all tree elements.\n * OUT assertions: the fields len and code are set to the optimal bit length\n *     and corresponding code. The length opt_len is updated; static_len is\n *     also updated if stree is not null. The field max_code is set.\n */\nlocal void build_tree(s, desc)\n    deflate_state *s;\n    tree_desc *desc; /* the tree descriptor */\n{\n    ct_data *tree         = desc->dyn_tree;\n    const ct_data *stree  = desc->stat_desc->static_tree;\n    int elems             = desc->stat_desc->elems;\n    int n, m;          /* iterate over heap elements */\n    int max_code = -1; /* largest code with non zero frequency */\n    int node;          /* new node being created */\n\n    /* Construct the initial heap, with least frequent element in\n     * heap[SMALLEST]. The sons of heap[n] are heap[2*n] and heap[2*n+1].\n     * heap[0] is not used.\n     */\n    s->heap_len = 0, s->heap_max = HEAP_SIZE;\n\n    for (n = 0; n < elems; n++) {\n        if (tree[n].Freq != 0) {\n            s->heap[++(s->heap_len)] = max_code = n;\n            s->depth[n] = 0;\n        } else {\n            tree[n].Len = 0;\n        }\n    }\n\n    /* The pkzip format requires that at least one distance code exists,\n     * and that at least one bit should be sent even if there is only one\n     * possible code. So to avoid special checks later on we force at least\n     * two codes of non zero frequency.\n     */\n    while (s->heap_len < 2) {\n        node = s->heap[++(s->heap_len)] = (max_code < 2 ? ++max_code : 0);\n        tree[node].Freq = 1;\n        s->depth[node] = 0;\n        s->opt_len--; if (stree) s->static_len -= stree[node].Len;\n        /* node is 0 or 1 so it does not have extra bits */\n    }\n    desc->max_code = max_code;\n\n    /* The elements heap[heap_len/2+1 .. heap_len] are leaves of the tree,\n     * establish sub-heaps of increasing lengths:\n     */\n    for (n = s->heap_len/2; n >= 1; n--) pqdownheap(s, tree, n);\n\n    /* Construct the Huffman tree by repeatedly combining the least two\n     * frequent nodes.\n     */\n    node = elems;              /* next internal node of the tree */\n    do {\n        pqremove(s, tree, n);  /* n = node of least frequency */\n        m = s->heap[SMALLEST]; /* m = node of next least frequency */\n\n        s->heap[--(s->heap_max)] = n; /* keep the nodes sorted by frequency */\n        s->heap[--(s->heap_max)] = m;\n\n        /* Create a new node father of n and m */\n        tree[node].Freq = tree[n].Freq + tree[m].Freq;\n        s->depth[node] = (uch)((s->depth[n] >= s->depth[m] ?\n                                s->depth[n] : s->depth[m]) + 1);\n        tree[n].Dad = tree[m].Dad = (ush)node;\n#ifdef DUMP_BL_TREE\n        if (tree == s->bl_tree) {\n            fprintf(stderr,\"\\nnode %d(%d), sons %d(%d) %d(%d)\",\n                    node, tree[node].Freq, n, tree[n].Freq, m, tree[m].Freq);\n        }\n#endif\n        /* and insert the new node in the heap */\n        s->heap[SMALLEST] = node++;\n        pqdownheap(s, tree, SMALLEST);\n\n    } while (s->heap_len >= 2);\n\n    s->heap[--(s->heap_max)] = s->heap[SMALLEST];\n\n    /* At this point, the fields freq and dad are set. We can now\n     * generate the bit lengths.\n     */\n    gen_bitlen(s, (tree_desc *)desc);\n\n    /* The field len is now set, we can generate the bit codes */\n    gen_codes ((ct_data *)tree, max_code, s->bl_count);\n}\n\n/* ===========================================================================\n * Scan a literal or distance tree to determine the frequencies of the codes\n * in the bit length tree.\n */\nlocal void scan_tree (s, tree, max_code)\n    deflate_state *s;\n    ct_data *tree;   /* the tree to be scanned */\n    int max_code;    /* and its largest code of non zero frequency */\n{\n    int n;                     /* iterates over all tree elements */\n    int prevlen = -1;          /* last emitted length */\n    int curlen;                /* length of current code */\n    int nextlen = tree[0].Len; /* length of next code */\n    int count = 0;             /* repeat count of the current code */\n    int max_count = 7;         /* max repeat count */\n    int min_count = 4;         /* min repeat count */\n\n    if (nextlen == 0) max_count = 138, min_count = 3;\n    tree[max_code+1].Len = (ush)0xffff; /* guard */\n\n    for (n = 0; n <= max_code; n++) {\n        curlen = nextlen; nextlen = tree[n+1].Len;\n        if (++count < max_count && curlen == nextlen) {\n            continue;\n        } else if (count < min_count) {\n            s->bl_tree[curlen].Freq += count;\n        } else if (curlen != 0) {\n            if (curlen != prevlen) s->bl_tree[curlen].Freq++;\n            s->bl_tree[REP_3_6].Freq++;\n        } else if (count <= 10) {\n            s->bl_tree[REPZ_3_10].Freq++;\n        } else {\n            s->bl_tree[REPZ_11_138].Freq++;\n        }\n        count = 0; prevlen = curlen;\n        if (nextlen == 0) {\n            max_count = 138, min_count = 3;\n        } else if (curlen == nextlen) {\n            max_count = 6, min_count = 3;\n        } else {\n            max_count = 7, min_count = 4;\n        }\n    }\n}\n\n/* ===========================================================================\n * Send a literal or distance tree in compressed form, using the codes in\n * bl_tree.\n */\nlocal void send_tree (s, tree, max_code)\n    deflate_state *s;\n    ct_data *tree; /* the tree to be scanned */\n    int max_code;       /* and its largest code of non zero frequency */\n{\n    int n;                     /* iterates over all tree elements */\n    int prevlen = -1;          /* last emitted length */\n    int curlen;                /* length of current code */\n    int nextlen = tree[0].Len; /* length of next code */\n    int count = 0;             /* repeat count of the current code */\n    int max_count = 7;         /* max repeat count */\n    int min_count = 4;         /* min repeat count */\n\n    /* tree[max_code+1].Len = -1; */  /* guard already set */\n    if (nextlen == 0) max_count = 138, min_count = 3;\n\n    for (n = 0; n <= max_code; n++) {\n        curlen = nextlen; nextlen = tree[n+1].Len;\n        if (++count < max_count && curlen == nextlen) {\n            continue;\n        } else if (count < min_count) {\n            do { send_code(s, curlen, s->bl_tree); } while (--count != 0);\n\n        } else if (curlen != 0) {\n            if (curlen != prevlen) {\n                send_code(s, curlen, s->bl_tree); count--;\n            }\n            Assert(count >= 3 && count <= 6, \" 3_6?\");\n            send_code(s, REP_3_6, s->bl_tree); send_bits(s, count-3, 2);\n\n        } else if (count <= 10) {\n            send_code(s, REPZ_3_10, s->bl_tree); send_bits(s, count-3, 3);\n\n        } else {\n            send_code(s, REPZ_11_138, s->bl_tree); send_bits(s, count-11, 7);\n        }\n        count = 0; prevlen = curlen;\n        if (nextlen == 0) {\n            max_count = 138, min_count = 3;\n        } else if (curlen == nextlen) {\n            max_count = 6, min_count = 3;\n        } else {\n            max_count = 7, min_count = 4;\n        }\n    }\n}\n\n/* ===========================================================================\n * Construct the Huffman tree for the bit lengths and return the index in\n * bl_order of the last bit length code to send.\n */\nlocal int build_bl_tree(s)\n    deflate_state *s;\n{\n    int max_blindex;  /* index of last bit length code of non zero freq */\n\n    /* Determine the bit length frequencies for literal and distance trees */\n    scan_tree(s, (ct_data *)s->dyn_ltree, s->l_desc.max_code);\n    scan_tree(s, (ct_data *)s->dyn_dtree, s->d_desc.max_code);\n\n    /* Build the bit length tree: */\n    build_tree(s, (tree_desc *)(&(s->bl_desc)));\n    /* opt_len now includes the length of the tree representations, except\n     * the lengths of the bit lengths codes and the 5+5+4 bits for the counts.\n     */\n\n    /* Determine the number of bit length codes to send. The pkzip format\n     * requires that at least 4 bit length codes be sent. (appnote.txt says\n     * 3 but the actual value used is 4.)\n     */\n    for (max_blindex = BL_CODES-1; max_blindex >= 3; max_blindex--) {\n        if (s->bl_tree[bl_order[max_blindex]].Len != 0) break;\n    }\n    /* Update opt_len to include the bit length tree and counts */\n    s->opt_len += 3*(max_blindex+1) + 5+5+4;\n    Tracev((stderr, \"\\ndyn trees: dyn %ld, stat %ld\",\n            s->opt_len, s->static_len));\n\n    return max_blindex;\n}\n\n/* ===========================================================================\n * Send the header for a block using dynamic Huffman trees: the counts, the\n * lengths of the bit length codes, the literal tree and the distance tree.\n * IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4.\n */\nlocal void send_all_trees(s, lcodes, dcodes, blcodes)\n    deflate_state *s;\n    int lcodes, dcodes, blcodes; /* number of codes for each tree */\n{\n    int rank;                    /* index in bl_order */\n\n    Assert (lcodes >= 257 && dcodes >= 1 && blcodes >= 4, \"not enough codes\");\n    Assert (lcodes <= L_CODES && dcodes <= D_CODES && blcodes <= BL_CODES,\n            \"too many codes\");\n    Tracev((stderr, \"\\nbl counts: \"));\n    send_bits(s, lcodes-257, 5); /* not +255 as stated in appnote.txt */\n    send_bits(s, dcodes-1,   5);\n    send_bits(s, blcodes-4,  4); /* not -3 as stated in appnote.txt */\n    for (rank = 0; rank < blcodes; rank++) {\n        Tracev((stderr, \"\\nbl code %2d \", bl_order[rank]));\n        send_bits(s, s->bl_tree[bl_order[rank]].Len, 3);\n    }\n    Tracev((stderr, \"\\nbl tree: sent %ld\", s->bits_sent));\n\n    send_tree(s, (ct_data *)s->dyn_ltree, lcodes-1); /* literal tree */\n    Tracev((stderr, \"\\nlit tree: sent %ld\", s->bits_sent));\n\n    send_tree(s, (ct_data *)s->dyn_dtree, dcodes-1); /* distance tree */\n    Tracev((stderr, \"\\ndist tree: sent %ld\", s->bits_sent));\n}\n\n/* ===========================================================================\n * Send a stored block\n */\nvoid ZLIB_INTERNAL _tr_stored_block(s, buf, stored_len, last)\n    deflate_state *s;\n    charf *buf;       /* input block */\n    ulg stored_len;   /* length of input block */\n    int last;         /* one if this is the last block for a file */\n{\n    send_bits(s, (STORED_BLOCK<<1)+last, 3);    /* send block type */\n#ifdef DEBUG\n    s->compressed_len = (s->compressed_len + 3 + 7) & (ulg)~7L;\n    s->compressed_len += (stored_len + 4) << 3;\n#endif\n    copy_block(s, buf, (unsigned)stored_len, 1); /* with header */\n}\n\n/* ===========================================================================\n * Flush the bits in the bit buffer to pending output (leaves at most 7 bits)\n */\nvoid ZLIB_INTERNAL _tr_flush_bits(s)\n    deflate_state *s;\n{\n    bi_flush(s);\n}\n\n/* ===========================================================================\n * Send one empty static block to give enough lookahead for inflate.\n * This takes 10 bits, of which 7 may remain in the bit buffer.\n */\nvoid ZLIB_INTERNAL _tr_align(s)\n    deflate_state *s;\n{\n    send_bits(s, STATIC_TREES<<1, 3);\n    send_code(s, END_BLOCK, static_ltree);\n#ifdef DEBUG\n    s->compressed_len += 10L; /* 3 for block type, 7 for EOB */\n#endif\n    bi_flush(s);\n}\n\n/* ===========================================================================\n * Determine the best encoding for the current block: dynamic trees, static\n * trees or store, and output the encoded block to the zip file.\n */\nvoid ZLIB_INTERNAL _tr_flush_block(s, buf, stored_len, last)\n    deflate_state *s;\n    charf *buf;       /* input block, or NULL if too old */\n    ulg stored_len;   /* length of input block */\n    int last;         /* one if this is the last block for a file */\n{\n    ulg opt_lenb, static_lenb; /* opt_len and static_len in bytes */\n    int max_blindex = 0;  /* index of last bit length code of non zero freq */\n\n    /* Build the Huffman trees unless a stored block is forced */\n    if (s->level > 0) {\n\n        /* Check if the file is binary or text */\n        if (s->strm->data_type == Z_UNKNOWN)\n            s->strm->data_type = detect_data_type(s);\n\n        /* Construct the literal and distance trees */\n        build_tree(s, (tree_desc *)(&(s->l_desc)));\n        Tracev((stderr, \"\\nlit data: dyn %ld, stat %ld\", s->opt_len,\n                s->static_len));\n\n        build_tree(s, (tree_desc *)(&(s->d_desc)));\n        Tracev((stderr, \"\\ndist data: dyn %ld, stat %ld\", s->opt_len,\n                s->static_len));\n        /* At this point, opt_len and static_len are the total bit lengths of\n         * the compressed block data, excluding the tree representations.\n         */\n\n        /* Build the bit length tree for the above two trees, and get the index\n         * in bl_order of the last bit length code to send.\n         */\n        max_blindex = build_bl_tree(s);\n\n        /* Determine the best encoding. Compute the block lengths in bytes. */\n        opt_lenb = (s->opt_len+3+7)>>3;\n        static_lenb = (s->static_len+3+7)>>3;\n\n        Tracev((stderr, \"\\nopt %lu(%lu) stat %lu(%lu) stored %lu lit %u \",\n                opt_lenb, s->opt_len, static_lenb, s->static_len, stored_len,\n                s->last_lit));\n\n        if (static_lenb <= opt_lenb) opt_lenb = static_lenb;\n\n    } else {\n        Assert(buf != (char*)0, \"lost buf\");\n        opt_lenb = static_lenb = stored_len + 5; /* force a stored block */\n    }\n\n#ifdef FORCE_STORED\n    if (buf != (char*)0) { /* force stored block */\n#else\n    if (stored_len+4 <= opt_lenb && buf != (char*)0) {\n                       /* 4: two words for the lengths */\n#endif\n        /* The test buf != NULL is only necessary if LIT_BUFSIZE > WSIZE.\n         * Otherwise we can't have processed more than WSIZE input bytes since\n         * the last block flush, because compression would have been\n         * successful. If LIT_BUFSIZE <= WSIZE, it is never too late to\n         * transform a block into a stored block.\n         */\n        _tr_stored_block(s, buf, stored_len, last);\n\n#ifdef FORCE_STATIC\n    } else if (static_lenb >= 0) { /* force static trees */\n#else\n    } else if (s->strategy == Z_FIXED || static_lenb == opt_lenb) {\n#endif\n        send_bits(s, (STATIC_TREES<<1)+last, 3);\n        compress_block(s, (ct_data *)static_ltree, (ct_data *)static_dtree);\n#ifdef DEBUG\n        s->compressed_len += 3 + s->static_len;\n#endif\n    } else {\n        send_bits(s, (DYN_TREES<<1)+last, 3);\n        send_all_trees(s, s->l_desc.max_code+1, s->d_desc.max_code+1,\n                       max_blindex+1);\n        compress_block(s, (ct_data *)s->dyn_ltree, (ct_data *)s->dyn_dtree);\n#ifdef DEBUG\n        s->compressed_len += 3 + s->opt_len;\n#endif\n    }\n    Assert (s->compressed_len == s->bits_sent, \"bad compressed size\");\n    /* The above check is made mod 2^32, for files larger than 512 MB\n     * and uLong implemented on 32 bits.\n     */\n    init_block(s);\n\n    if (last) {\n        bi_windup(s);\n#ifdef DEBUG\n        s->compressed_len += 7;  /* align on byte boundary */\n#endif\n    }\n    Tracev((stderr,\"\\ncomprlen %lu(%lu) \", s->compressed_len>>3,\n           s->compressed_len-7*last));\n}\n\n/* ===========================================================================\n * Save the match info and tally the frequency counts. Return true if\n * the current block must be flushed.\n */\nint ZLIB_INTERNAL _tr_tally (s, dist, lc)\n    deflate_state *s;\n    unsigned dist;  /* distance of matched string */\n    unsigned lc;    /* match length-MIN_MATCH or unmatched char (if dist==0) */\n{\n    s->d_buf[s->last_lit] = (ush)dist;\n    s->l_buf[s->last_lit++] = (uch)lc;\n    if (dist == 0) {\n        /* lc is the unmatched char */\n        s->dyn_ltree[lc].Freq++;\n    } else {\n        s->matches++;\n        /* Here, lc is the match length - MIN_MATCH */\n        dist--;             /* dist = match distance - 1 */\n        Assert((ush)dist < (ush)MAX_DIST(s) &&\n               (ush)lc <= (ush)(MAX_MATCH-MIN_MATCH) &&\n               (ush)d_code(dist) < (ush)D_CODES,  \"_tr_tally: bad match\");\n\n        s->dyn_ltree[_length_code[lc]+LITERALS+1].Freq++;\n        s->dyn_dtree[d_code(dist)].Freq++;\n    }\n\n#ifdef TRUNCATE_BLOCK\n    /* Try to guess if it is profitable to stop the current block here */\n    if ((s->last_lit & 0x1fff) == 0 && s->level > 2) {\n        /* Compute an upper bound for the compressed length */\n        ulg out_length = (ulg)s->last_lit*8L;\n        ulg in_length = (ulg)((long)s->strstart - s->block_start);\n        int dcode;\n        for (dcode = 0; dcode < D_CODES; dcode++) {\n            out_length += (ulg)s->dyn_dtree[dcode].Freq *\n                (5L+extra_dbits[dcode]);\n        }\n        out_length >>= 3;\n        Tracev((stderr,\"\\nlast_lit %u, in %ld, out ~%ld(%ld%%) \",\n               s->last_lit, in_length, out_length,\n               100L - out_length*100L/in_length));\n        if (s->matches < s->last_lit/2 && out_length < in_length/2) return 1;\n    }\n#endif\n    return (s->last_lit == s->lit_bufsize-1);\n    /* We avoid equality with lit_bufsize because of wraparound at 64K\n     * on 16 bit machines and because stored blocks are restricted to\n     * 64K-1 bytes.\n     */\n}\n\n/* ===========================================================================\n * Send the block data compressed using the given Huffman trees\n */\nlocal void compress_block(s, ltree, dtree)\n    deflate_state *s;\n    ct_data *ltree; /* literal tree */\n    ct_data *dtree; /* distance tree */\n{\n    unsigned dist;      /* distance of matched string */\n    int lc;             /* match length or unmatched char (if dist == 0) */\n    unsigned lx = 0;    /* running index in l_buf */\n    unsigned code;      /* the code to send */\n    int extra;          /* number of extra bits to send */\n\n    if (s->last_lit != 0) do {\n        dist = s->d_buf[lx];\n        lc = s->l_buf[lx++];\n        if (dist == 0) {\n            send_code(s, lc, ltree); /* send a literal byte */\n            Tracecv(isgraph(lc), (stderr,\" '%c' \", lc));\n        } else {\n            /* Here, lc is the match length - MIN_MATCH */\n            code = _length_code[lc];\n            send_code(s, code+LITERALS+1, ltree); /* send the length code */\n            extra = extra_lbits[code];\n            if (extra != 0) {\n                lc -= base_length[code];\n                send_bits(s, lc, extra);       /* send the extra length bits */\n            }\n            dist--; /* dist is now the match distance - 1 */\n            code = d_code(dist);\n            Assert (code < D_CODES, \"bad d_code\");\n\n            send_code(s, code, dtree);       /* send the distance code */\n            extra = extra_dbits[code];\n            if (extra != 0) {\n                dist -= base_dist[code];\n                send_bits(s, dist, extra);   /* send the extra distance bits */\n            }\n        } /* literal or match pair ? */\n\n        /* Check that the overlay between pending_buf and d_buf+l_buf is ok: */\n        Assert((uInt)(s->pending) < s->lit_bufsize + 2*lx,\n               \"pendingBuf overflow\");\n\n    } while (lx < s->last_lit);\n\n    send_code(s, END_BLOCK, ltree);\n}\n\n/* ===========================================================================\n * Check if the data type is TEXT or BINARY, using the following algorithm:\n * - TEXT if the two conditions below are satisfied:\n *    a) There are no non-portable control characters belonging to the\n *       \"black list\" (0..6, 14..25, 28..31).\n *    b) There is at least one printable character belonging to the\n *       \"white list\" (9 {TAB}, 10 {LF}, 13 {CR}, 32..255).\n * - BINARY otherwise.\n * - The following partially-portable control characters form a\n *   \"gray list\" that is ignored in this detection algorithm:\n *   (7 {BEL}, 8 {BS}, 11 {VT}, 12 {FF}, 26 {SUB}, 27 {ESC}).\n * IN assertion: the fields Freq of dyn_ltree are set.\n */\nlocal int detect_data_type(s)\n    deflate_state *s;\n{\n    /* black_mask is the bit mask of black-listed bytes\n     * set bits 0..6, 14..25, and 28..31\n     * 0xf3ffc07f = binary 11110011111111111100000001111111\n     */\n    unsigned long black_mask = 0xf3ffc07fUL;\n    int n;\n\n    /* Check for non-textual (\"black-listed\") bytes. */\n    for (n = 0; n <= 31; n++, black_mask >>= 1)\n        if ((black_mask & 1) && (s->dyn_ltree[n].Freq != 0))\n            return Z_BINARY;\n\n    /* Check for textual (\"white-listed\") bytes. */\n    if (s->dyn_ltree[9].Freq != 0 || s->dyn_ltree[10].Freq != 0\n            || s->dyn_ltree[13].Freq != 0)\n        return Z_TEXT;\n    for (n = 32; n < LITERALS; n++)\n        if (s->dyn_ltree[n].Freq != 0)\n            return Z_TEXT;\n\n    /* There are no \"black-listed\" or \"white-listed\" bytes:\n     * this stream either is empty or has tolerated (\"gray-listed\") bytes only.\n     */\n    return Z_BINARY;\n}\n\n/* ===========================================================================\n * Reverse the first len bits of a code, using straightforward code (a faster\n * method would use a table)\n * IN assertion: 1 <= len <= 15\n */\nlocal unsigned bi_reverse(code, len)\n    unsigned code; /* the value to invert */\n    int len;       /* its bit length */\n{\n    register unsigned res = 0;\n    do {\n        res |= code & 1;\n        code >>= 1, res <<= 1;\n    } while (--len > 0);\n    return res >> 1;\n}\n\n/* ===========================================================================\n * Flush the bit buffer, keeping at most 7 bits in it.\n */\nlocal void bi_flush(s)\n    deflate_state *s;\n{\n    if (s->bi_valid == 16) {\n        put_short(s, s->bi_buf);\n        s->bi_buf = 0;\n        s->bi_valid = 0;\n    } else if (s->bi_valid >= 8) {\n        put_byte(s, (Byte)s->bi_buf);\n        s->bi_buf >>= 8;\n        s->bi_valid -= 8;\n    }\n}\n\n/* ===========================================================================\n * Flush the bit buffer and align the output on a byte boundary\n */\nlocal void bi_windup(s)\n    deflate_state *s;\n{\n    if (s->bi_valid > 8) {\n        put_short(s, s->bi_buf);\n    } else if (s->bi_valid > 0) {\n        put_byte(s, (Byte)s->bi_buf);\n    }\n    s->bi_buf = 0;\n    s->bi_valid = 0;\n#ifdef DEBUG\n    s->bits_sent = (s->bits_sent+7) & ~7;\n#endif\n}\n\n/* ===========================================================================\n * Copy a stored block, storing first the length and its\n * one's complement if requested.\n */\nlocal void copy_block(s, buf, len, header)\n    deflate_state *s;\n    charf    *buf;    /* the input data */\n    unsigned len;     /* its length */\n    int      header;  /* true if block header must be written */\n{\n    bi_windup(s);        /* align on byte boundary */\n\n    if (header) {\n        put_short(s, (ush)len);\n        put_short(s, (ush)~len);\n#ifdef DEBUG\n        s->bits_sent += 2*16;\n#endif\n    }\n#ifdef DEBUG\n    s->bits_sent += (ulg)len<<3;\n#endif\n    while (len--) {\n        put_byte(s, *buf++);\n    }\n}\n"
  },
  {
    "path": "Projects/Tools/PNGAlphaPremultiplier/Native/Source/ZLib/trees.h",
    "content": "/* header created automatically with -DGEN_TREES_H */\n\nlocal const ct_data static_ltree[L_CODES+2] = {\n{{ 12},{  8}}, {{140},{  8}}, {{ 76},{  8}}, {{204},{  8}}, {{ 44},{  8}},\n{{172},{  8}}, {{108},{  8}}, {{236},{  8}}, {{ 28},{  8}}, {{156},{  8}},\n{{ 92},{  8}}, {{220},{  8}}, {{ 60},{  8}}, {{188},{  8}}, {{124},{  8}},\n{{252},{  8}}, {{  2},{  8}}, {{130},{  8}}, {{ 66},{  8}}, {{194},{  8}},\n{{ 34},{  8}}, {{162},{  8}}, {{ 98},{  8}}, {{226},{  8}}, {{ 18},{  8}},\n{{146},{  8}}, {{ 82},{  8}}, {{210},{  8}}, {{ 50},{  8}}, {{178},{  8}},\n{{114},{  8}}, {{242},{  8}}, {{ 10},{  8}}, {{138},{  8}}, {{ 74},{  8}},\n{{202},{  8}}, {{ 42},{  8}}, {{170},{  8}}, {{106},{  8}}, {{234},{  8}},\n{{ 26},{  8}}, {{154},{  8}}, {{ 90},{  8}}, {{218},{  8}}, {{ 58},{  8}},\n{{186},{  8}}, {{122},{  8}}, {{250},{  8}}, {{  6},{  8}}, {{134},{  8}},\n{{ 70},{  8}}, {{198},{  8}}, {{ 38},{  8}}, {{166},{  8}}, {{102},{  8}},\n{{230},{  8}}, {{ 22},{  8}}, {{150},{  8}}, {{ 86},{  8}}, {{214},{  8}},\n{{ 54},{  8}}, {{182},{  8}}, {{118},{  8}}, {{246},{  8}}, {{ 14},{  8}},\n{{142},{  8}}, {{ 78},{  8}}, {{206},{  8}}, {{ 46},{  8}}, {{174},{  8}},\n{{110},{  8}}, {{238},{  8}}, {{ 30},{  8}}, {{158},{  8}}, {{ 94},{  8}},\n{{222},{  8}}, {{ 62},{  8}}, {{190},{  8}}, {{126},{  8}}, {{254},{  8}},\n{{  1},{  8}}, {{129},{  8}}, {{ 65},{  8}}, {{193},{  8}}, {{ 33},{  8}},\n{{161},{  8}}, {{ 97},{  8}}, {{225},{  8}}, {{ 17},{  8}}, {{145},{  8}},\n{{ 81},{  8}}, {{209},{  8}}, {{ 49},{  8}}, {{177},{  8}}, {{113},{  8}},\n{{241},{  8}}, {{  9},{  8}}, {{137},{  8}}, {{ 73},{  8}}, {{201},{  8}},\n{{ 41},{  8}}, {{169},{  8}}, {{105},{  8}}, {{233},{  8}}, {{ 25},{  8}},\n{{153},{  8}}, {{ 89},{  8}}, {{217},{  8}}, {{ 57},{  8}}, {{185},{  8}},\n{{121},{  8}}, {{249},{  8}}, {{  5},{  8}}, {{133},{  8}}, {{ 69},{  8}},\n{{197},{  8}}, {{ 37},{  8}}, {{165},{  8}}, {{101},{  8}}, {{229},{  8}},\n{{ 21},{  8}}, {{149},{  8}}, {{ 85},{  8}}, {{213},{  8}}, {{ 53},{  8}},\n{{181},{  8}}, {{117},{  8}}, {{245},{  8}}, {{ 13},{  8}}, {{141},{  8}},\n{{ 77},{  8}}, {{205},{  8}}, {{ 45},{  8}}, {{173},{  8}}, {{109},{  8}},\n{{237},{  8}}, {{ 29},{  8}}, {{157},{  8}}, {{ 93},{  8}}, {{221},{  8}},\n{{ 61},{  8}}, {{189},{  8}}, {{125},{  8}}, {{253},{  8}}, {{ 19},{  9}},\n{{275},{  9}}, {{147},{  9}}, {{403},{  9}}, {{ 83},{  9}}, {{339},{  9}},\n{{211},{  9}}, {{467},{  9}}, {{ 51},{  9}}, {{307},{  9}}, {{179},{  9}},\n{{435},{  9}}, {{115},{  9}}, {{371},{  9}}, {{243},{  9}}, {{499},{  9}},\n{{ 11},{  9}}, {{267},{  9}}, {{139},{  9}}, {{395},{  9}}, {{ 75},{  9}},\n{{331},{  9}}, {{203},{  9}}, {{459},{  9}}, {{ 43},{  9}}, {{299},{  9}},\n{{171},{  9}}, {{427},{  9}}, {{107},{  9}}, {{363},{  9}}, {{235},{  9}},\n{{491},{  9}}, {{ 27},{  9}}, {{283},{  9}}, {{155},{  9}}, {{411},{  9}},\n{{ 91},{  9}}, {{347},{  9}}, {{219},{  9}}, {{475},{  9}}, {{ 59},{  9}},\n{{315},{  9}}, {{187},{  9}}, {{443},{  9}}, {{123},{  9}}, {{379},{  9}},\n{{251},{  9}}, {{507},{  9}}, {{  7},{  9}}, {{263},{  9}}, {{135},{  9}},\n{{391},{  9}}, {{ 71},{  9}}, {{327},{  9}}, {{199},{  9}}, {{455},{  9}},\n{{ 39},{  9}}, {{295},{  9}}, {{167},{  9}}, {{423},{  9}}, {{103},{  9}},\n{{359},{  9}}, {{231},{  9}}, {{487},{  9}}, {{ 23},{  9}}, {{279},{  9}},\n{{151},{  9}}, {{407},{  9}}, {{ 87},{  9}}, {{343},{  9}}, {{215},{  9}},\n{{471},{  9}}, {{ 55},{  9}}, {{311},{  9}}, {{183},{  9}}, {{439},{  9}},\n{{119},{  9}}, {{375},{  9}}, {{247},{  9}}, {{503},{  9}}, {{ 15},{  9}},\n{{271},{  9}}, {{143},{  9}}, {{399},{  9}}, {{ 79},{  9}}, {{335},{  9}},\n{{207},{  9}}, {{463},{  9}}, {{ 47},{  9}}, {{303},{  9}}, {{175},{  9}},\n{{431},{  9}}, {{111},{  9}}, {{367},{  9}}, {{239},{  9}}, {{495},{  9}},\n{{ 31},{  9}}, {{287},{  9}}, {{159},{  9}}, {{415},{  9}}, {{ 95},{  9}},\n{{351},{  9}}, {{223},{  9}}, {{479},{  9}}, {{ 63},{  9}}, {{319},{  9}},\n{{191},{  9}}, {{447},{  9}}, {{127},{  9}}, {{383},{  9}}, {{255},{  9}},\n{{511},{  9}}, {{  0},{  7}}, {{ 64},{  7}}, {{ 32},{  7}}, {{ 96},{  7}},\n{{ 16},{  7}}, {{ 80},{  7}}, {{ 48},{  7}}, {{112},{  7}}, {{  8},{  7}},\n{{ 72},{  7}}, {{ 40},{  7}}, {{104},{  7}}, {{ 24},{  7}}, {{ 88},{  7}},\n{{ 56},{  7}}, {{120},{  7}}, {{  4},{  7}}, {{ 68},{  7}}, {{ 36},{  7}},\n{{100},{  7}}, {{ 20},{  7}}, {{ 84},{  7}}, {{ 52},{  7}}, {{116},{  7}},\n{{  3},{  8}}, {{131},{  8}}, {{ 67},{  8}}, {{195},{  8}}, {{ 35},{  8}},\n{{163},{  8}}, {{ 99},{  8}}, {{227},{  8}}\n};\n\nlocal const ct_data static_dtree[D_CODES] = {\n{{ 0},{ 5}}, {{16},{ 5}}, {{ 8},{ 5}}, {{24},{ 5}}, {{ 4},{ 5}},\n{{20},{ 5}}, {{12},{ 5}}, {{28},{ 5}}, {{ 2},{ 5}}, {{18},{ 5}},\n{{10},{ 5}}, {{26},{ 5}}, {{ 6},{ 5}}, {{22},{ 5}}, {{14},{ 5}},\n{{30},{ 5}}, {{ 1},{ 5}}, {{17},{ 5}}, {{ 9},{ 5}}, {{25},{ 5}},\n{{ 5},{ 5}}, {{21},{ 5}}, {{13},{ 5}}, {{29},{ 5}}, {{ 3},{ 5}},\n{{19},{ 5}}, {{11},{ 5}}, {{27},{ 5}}, {{ 7},{ 5}}, {{23},{ 5}}\n};\n\nconst uch ZLIB_INTERNAL _dist_code[DIST_CODE_LEN] = {\n 0,  1,  2,  3,  4,  4,  5,  5,  6,  6,  6,  6,  7,  7,  7,  7,  8,  8,  8,  8,\n 8,  8,  8,  8,  9,  9,  9,  9,  9,  9,  9,  9, 10, 10, 10, 10, 10, 10, 10, 10,\n10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,\n11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,\n12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13,\n13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,\n13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,\n14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,\n14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,\n14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15,\n15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,\n15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,\n15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,  0,  0, 16, 17,\n18, 18, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22,\n23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,\n24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,\n26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,\n26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27,\n27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,\n27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,\n28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,\n28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,\n28, 28, 28, 28, 28, 28, 28, 28, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,\n29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,\n29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,\n29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29\n};\n\nconst uch ZLIB_INTERNAL _length_code[MAX_MATCH-MIN_MATCH+1]= {\n 0,  1,  2,  3,  4,  5,  6,  7,  8,  8,  9,  9, 10, 10, 11, 11, 12, 12, 12, 12,\n13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16,\n17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19,\n19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,\n21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22,\n22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23,\n23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,\n24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,\n25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,\n25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 26, 26, 26,\n26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,\n26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,\n27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28\n};\n\nlocal const int base_length[LENGTH_CODES] = {\n0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 20, 24, 28, 32, 40, 48, 56,\n64, 80, 96, 112, 128, 160, 192, 224, 0\n};\n\nlocal const int base_dist[D_CODES] = {\n    0,     1,     2,     3,     4,     6,     8,    12,    16,    24,\n   32,    48,    64,    96,   128,   192,   256,   384,   512,   768,\n 1024,  1536,  2048,  3072,  4096,  6144,  8192, 12288, 16384, 24576\n};\n\n"
  },
  {
    "path": "Projects/Tools/PNGAlphaPremultiplier/Native/Source/ZLib/uncompr.c",
    "content": "/* uncompr.c -- decompress a memory buffer\n * Copyright (C) 1995-2003, 2010 Jean-loup Gailly.\n * For conditions of distribution and use, see copyright notice in zlib.h\n */\n\n/* @(#) $Id$ */\n\n#define ZLIB_INTERNAL\n#include \"zlib.h\"\n\n/* ===========================================================================\n     Decompresses the source buffer into the destination buffer.  sourceLen is\n   the byte length of the source buffer. Upon entry, destLen is the total\n   size of the destination buffer, which must be large enough to hold the\n   entire uncompressed data. (The size of the uncompressed data must have\n   been saved previously by the compressor and transmitted to the decompressor\n   by some mechanism outside the scope of this compression library.)\n   Upon exit, destLen is the actual size of the compressed buffer.\n\n     uncompress returns Z_OK if success, Z_MEM_ERROR if there was not\n   enough memory, Z_BUF_ERROR if there was not enough room in the output\n   buffer, or Z_DATA_ERROR if the input data was corrupted.\n*/\nint ZEXPORT uncompress (dest, destLen, source, sourceLen)\n    Bytef *dest;\n    uLongf *destLen;\n    const Bytef *source;\n    uLong sourceLen;\n{\n    z_stream stream;\n    int err;\n\n    stream.next_in = (Bytef*)source;\n    stream.avail_in = (uInt)sourceLen;\n    /* Check for source > 64K on 16-bit machine: */\n    if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR;\n\n    stream.next_out = dest;\n    stream.avail_out = (uInt)*destLen;\n    if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR;\n\n    stream.zalloc = (alloc_func)0;\n    stream.zfree = (free_func)0;\n\n    err = inflateInit(&stream);\n    if (err != Z_OK) return err;\n\n    err = inflate(&stream, Z_FINISH);\n    if (err != Z_STREAM_END) {\n        inflateEnd(&stream);\n        if (err == Z_NEED_DICT || (err == Z_BUF_ERROR && stream.avail_in == 0))\n            return Z_DATA_ERROR;\n        return err;\n    }\n    *destLen = stream.total_out;\n\n    err = inflateEnd(&stream);\n    return err;\n}\n"
  },
  {
    "path": "Projects/Tools/PNGAlphaPremultiplier/Native/Source/ZLib/zconf.h",
    "content": "/* zconf.h -- configuration of the zlib compression library\n * Copyright (C) 1995-2011 Jean-loup Gailly.\n * For conditions of distribution and use, see copyright notice in zlib.h\n */\n\n/* @(#) $Id$ */\n\n#ifndef ZCONF_H\n#define ZCONF_H\n\n/*\n * If you *really* need a unique prefix for all types and library functions,\n * compile with -DZ_PREFIX. The \"standard\" zlib should be compiled without it.\n * Even better than compiling with -DZ_PREFIX would be to use configure to set\n * this permanently in zconf.h using \"./configure --zprefix\".\n */\n#ifdef Z_PREFIX     /* may be set to #if 1 by ./configure */\n#  define Z_PREFIX_SET\n\n/* all linked symbols */\n#  define _dist_code            z__dist_code\n#  define _length_code          z__length_code\n#  define _tr_align             z__tr_align\n#  define _tr_flush_block       z__tr_flush_block\n#  define _tr_init              z__tr_init\n#  define _tr_stored_block      z__tr_stored_block\n#  define _tr_tally             z__tr_tally\n#  define adler32               z_adler32\n#  define adler32_combine       z_adler32_combine\n#  define adler32_combine64     z_adler32_combine64\n#  ifndef Z_SOLO\n#    define compress              z_compress\n#    define compress2             z_compress2\n#    define compressBound         z_compressBound\n#  endif\n#  define crc32                 z_crc32\n#  define crc32_combine         z_crc32_combine\n#  define crc32_combine64       z_crc32_combine64\n#  define deflate               z_deflate\n#  define deflateBound          z_deflateBound\n#  define deflateCopy           z_deflateCopy\n#  define deflateEnd            z_deflateEnd\n#  define deflateInit2_         z_deflateInit2_\n#  define deflateInit_          z_deflateInit_\n#  define deflateParams         z_deflateParams\n#  define deflatePending        z_deflatePending\n#  define deflatePrime          z_deflatePrime\n#  define deflateReset          z_deflateReset\n#  define deflateResetKeep      z_deflateResetKeep\n#  define deflateSetDictionary  z_deflateSetDictionary\n#  define deflateSetHeader      z_deflateSetHeader\n#  define deflateTune           z_deflateTune\n#  define deflate_copyright     z_deflate_copyright\n#  define get_crc_table         z_get_crc_table\n#  ifndef Z_SOLO\n#    define gz_error              z_gz_error\n#    define gz_intmax             z_gz_intmax\n#    define gz_strwinerror        z_gz_strwinerror\n#    define gzbuffer              z_gzbuffer\n#    define gzclearerr            z_gzclearerr\n#    define gzclose               z_gzclose\n#    define gzclose_r             z_gzclose_r\n#    define gzclose_w             z_gzclose_w\n#    define gzdirect              z_gzdirect\n#    define gzdopen               z_gzdopen\n#    define gzeof                 z_gzeof\n#    define gzerror               z_gzerror\n#    define gzflags               z_gzflags\n#    define gzflush               z_gzflush\n#    define gzgetc                z_gzgetc\n#    define gzgetc_               z_gzgetc_\n#    define gzgets                z_gzgets\n#    define gzoffset              z_gzoffset\n#    define gzoffset64            z_gzoffset64\n#    define gzopen                z_gzopen\n#    define gzopen64              z_gzopen64\n#    define gzprintf              z_gzprintf\n#    define gzputc                z_gzputc\n#    define gzputs                z_gzputs\n#    define gzread                z_gzread\n#    define gzrewind              z_gzrewind\n#    define gzseek                z_gzseek\n#    define gzseek64              z_gzseek64\n#    define gzsetparams           z_gzsetparams\n#    define gztell                z_gztell\n#    define gztell64              z_gztell64\n#    define gzungetc              z_gzungetc\n#    define gzwrite               z_gzwrite\n#  endif\n#  define inflate               z_inflate\n#  define inflateBack           z_inflateBack\n#  define inflateBackEnd        z_inflateBackEnd\n#  define inflateBackInit_      z_inflateBackInit_\n#  define inflateCopy           z_inflateCopy\n#  define inflateEnd            z_inflateEnd\n#  define inflateGetHeader      z_inflateGetHeader\n#  define inflateInit2_         z_inflateInit2_\n#  define inflateInit_          z_inflateInit_\n#  define inflateMark           z_inflateMark\n#  define inflatePrime          z_inflatePrime\n#  define inflateReset          z_inflateReset\n#  define inflateReset2         z_inflateReset2\n#  define inflateSetDictionary  z_inflateSetDictionary\n#  define inflateSync           z_inflateSync\n#  define inflateSyncPoint      z_inflateSyncPoint\n#  define inflateUndermine      z_inflateUndermine\n#  define inflateResetKeep      z_inflateResetKeep\n#  define inflate_copyright     z_inflate_copyright\n#  define inflate_fast          z_inflate_fast\n#  define inflate_table         z_inflate_table\n#  ifndef Z_SOLO\n#    define uncompress            z_uncompress\n#  endif\n#  define zError                z_zError\n#  ifndef Z_SOLO\n#    define zcalloc               z_zcalloc\n#    define zcfree                z_zcfree\n#  endif\n#  define zlibCompileFlags      z_zlibCompileFlags\n#  define zlibVersion           z_zlibVersion\n\n/* all zlib typedefs in zlib.h and zconf.h */\n#  define Byte                  z_Byte\n#  define Bytef                 z_Bytef\n#  define alloc_func            z_alloc_func\n#  define charf                 z_charf\n#  define free_func             z_free_func\n#  ifndef Z_SOLO\n#    define gzFile                z_gzFile\n#    define gz_header             z_gz_header\n#    define gz_headerp            z_gz_headerp\n#  endif\n#  define in_func               z_in_func\n#  define intf                  z_intf\n#  define out_func              z_out_func\n#  define uInt                  z_uInt\n#  define uIntf                 z_uIntf\n#  define uLong                 z_uLong\n#  define uLongf                z_uLongf\n#  define voidp                 z_voidp\n#  define voidpc                z_voidpc\n#  define voidpf                z_voidpf\n\n/* all zlib structs in zlib.h and zconf.h */\n#  ifndef Z_SOLO\n#    define gz_header_s           z_gz_header_s\n#  endif\n#  define internal_state        z_internal_state\n\n#endif\n\n#if defined(__MSDOS__) && !defined(MSDOS)\n#  define MSDOS\n#endif\n#if (defined(OS_2) || defined(__OS2__)) && !defined(OS2)\n#  define OS2\n#endif\n#if defined(_WINDOWS) && !defined(WINDOWS)\n#  define WINDOWS\n#endif\n#if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__)\n#  ifndef WIN32\n#    define WIN32\n#  endif\n#endif\n#if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32)\n#  if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__)\n#    ifndef SYS16BIT\n#      define SYS16BIT\n#    endif\n#  endif\n#endif\n\n/*\n * Compile with -DMAXSEG_64K if the alloc function cannot allocate more\n * than 64k bytes at a time (needed on systems with 16-bit int).\n */\n#ifdef SYS16BIT\n#  define MAXSEG_64K\n#endif\n#ifdef MSDOS\n#  define UNALIGNED_OK\n#endif\n\n#ifdef __STDC_VERSION__\n#  ifndef STDC\n#    define STDC\n#  endif\n#  if __STDC_VERSION__ >= 199901L\n#    ifndef STDC99\n#      define STDC99\n#    endif\n#  endif\n#endif\n#if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus))\n#  define STDC\n#endif\n#if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__))\n#  define STDC\n#endif\n#if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32))\n#  define STDC\n#endif\n#if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__))\n#  define STDC\n#endif\n\n#if defined(__OS400__) && !defined(STDC)    /* iSeries (formerly AS/400). */\n#  define STDC\n#endif\n\n#ifndef STDC\n#  ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */\n#    define const       /* note: need a more gentle solution here */\n#  endif\n#endif\n\n#if defined(ZLIB_CONST) && !defined(z_const)\n#  define z_const const\n#else\n#  define z_const\n#endif\n\n/* Some Mac compilers merge all .h files incorrectly: */\n#if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__)\n#  define NO_DUMMY_DECL\n#endif\n\n/* Maximum value for memLevel in deflateInit2 */\n#ifndef MAX_MEM_LEVEL\n#  ifdef MAXSEG_64K\n#    define MAX_MEM_LEVEL 8\n#  else\n#    define MAX_MEM_LEVEL 9\n#  endif\n#endif\n\n/* Maximum value for windowBits in deflateInit2 and inflateInit2.\n * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files\n * created by gzip. (Files created by minigzip can still be extracted by\n * gzip.)\n */\n#ifndef MAX_WBITS\n#  define MAX_WBITS   15 /* 32K LZ77 window */\n#endif\n\n/* The memory requirements for deflate are (in bytes):\n            (1 << (windowBits+2)) +  (1 << (memLevel+9))\n that is: 128K for windowBits=15  +  128K for memLevel = 8  (default values)\n plus a few kilobytes for small objects. For example, if you want to reduce\n the default memory requirements from 256K to 128K, compile with\n     make CFLAGS=\"-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7\"\n Of course this will generally degrade compression (there's no free lunch).\n\n   The memory requirements for inflate are (in bytes) 1 << windowBits\n that is, 32K for windowBits=15 (default value) plus a few kilobytes\n for small objects.\n*/\n\n                        /* Type declarations */\n\n#ifndef OF /* function prototypes */\n#  ifdef STDC\n#    define OF(args)  args\n#  else\n#    define OF(args)  ()\n#  endif\n#endif\n\n#ifndef Z_ARG /* function prototypes for stdarg */\n#  if defined(STDC) || defined(Z_HAVE_STDARG_H)\n#    define Z_ARG(args)  args\n#  else\n#    define Z_ARG(args)  ()\n#  endif\n#endif\n\n/* The following definitions for FAR are needed only for MSDOS mixed\n * model programming (small or medium model with some far allocations).\n * This was tested only with MSC; for other MSDOS compilers you may have\n * to define NO_MEMCPY in zutil.h.  If you don't need the mixed model,\n * just define FAR to be empty.\n */\n#ifdef SYS16BIT\n#  if defined(M_I86SM) || defined(M_I86MM)\n     /* MSC small or medium model */\n#    define SMALL_MEDIUM\n#    ifdef _MSC_VER\n#      define FAR _far\n#    else\n#      define FAR far\n#    endif\n#  endif\n#  if (defined(__SMALL__) || defined(__MEDIUM__))\n     /* Turbo C small or medium model */\n#    define SMALL_MEDIUM\n#    ifdef __BORLANDC__\n#      define FAR _far\n#    else\n#      define FAR far\n#    endif\n#  endif\n#endif\n\n#if defined(WINDOWS) || defined(WIN32)\n   /* If building or using zlib as a DLL, define ZLIB_DLL.\n    * This is not mandatory, but it offers a little performance increase.\n    */\n#  ifdef ZLIB_DLL\n#    if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500))\n#      ifdef ZLIB_INTERNAL\n#        define ZEXTERN extern __declspec(dllexport)\n#      else\n#        define ZEXTERN extern __declspec(dllimport)\n#      endif\n#    endif\n#  endif  /* ZLIB_DLL */\n   /* If building or using zlib with the WINAPI/WINAPIV calling convention,\n    * define ZLIB_WINAPI.\n    * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI.\n    */\n#  ifdef ZLIB_WINAPI\n#    ifdef FAR\n#      undef FAR\n#    endif\n#    include <windows.h>\n     /* No need for _export, use ZLIB.DEF instead. */\n     /* For complete Windows compatibility, use WINAPI, not __stdcall. */\n#    define ZEXPORT WINAPI\n#    ifdef WIN32\n#      define ZEXPORTVA WINAPIV\n#    else\n#      define ZEXPORTVA FAR CDECL\n#    endif\n#  endif\n#endif\n\n#if defined (__BEOS__)\n#  ifdef ZLIB_DLL\n#    ifdef ZLIB_INTERNAL\n#      define ZEXPORT   __declspec(dllexport)\n#      define ZEXPORTVA __declspec(dllexport)\n#    else\n#      define ZEXPORT   __declspec(dllimport)\n#      define ZEXPORTVA __declspec(dllimport)\n#    endif\n#  endif\n#endif\n\n#ifndef ZEXTERN\n#  define ZEXTERN extern\n#endif\n#ifndef ZEXPORT\n#  define ZEXPORT\n#endif\n#ifndef ZEXPORTVA\n#  define ZEXPORTVA\n#endif\n\n#ifndef FAR\n#  define FAR\n#endif\n\n#if !defined(__MACTYPES__)\ntypedef unsigned char  Byte;  /* 8 bits */\n#endif\ntypedef unsigned int   uInt;  /* 16 bits or more */\ntypedef unsigned long  uLong; /* 32 bits or more */\n\n#ifdef SMALL_MEDIUM\n   /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */\n#  define Bytef Byte FAR\n#else\n   typedef Byte  FAR Bytef;\n#endif\ntypedef char  FAR charf;\ntypedef int   FAR intf;\ntypedef uInt  FAR uIntf;\ntypedef uLong FAR uLongf;\n\n#ifdef STDC\n   typedef void const *voidpc;\n   typedef void FAR   *voidpf;\n   typedef void       *voidp;\n#else\n   typedef Byte const *voidpc;\n   typedef Byte FAR   *voidpf;\n   typedef Byte       *voidp;\n#endif\n\n#ifdef HAVE_UNISTD_H    /* may be set to #if 1 by ./configure */\n#  define Z_HAVE_UNISTD_H\n#endif\n\n#ifdef HAVE_STDARG_H    /* may be set to #if 1 by ./configure */\n#  define Z_HAVE_STDARG_H\n#endif\n\n#ifdef STDC\n#  ifndef Z_SOLO\n#    include <sys/types.h>      /* for off_t */\n#  endif\n#endif\n\n/* a little trick to accommodate both \"#define _LARGEFILE64_SOURCE\" and\n * \"#define _LARGEFILE64_SOURCE 1\" as requesting 64-bit operations, (even\n * though the former does not conform to the LFS document), but considering\n * both \"#undef _LARGEFILE64_SOURCE\" and \"#define _LARGEFILE64_SOURCE 0\" as\n * equivalently requesting no 64-bit operations\n */\n#if -_LARGEFILE64_SOURCE - -1 == 1\n#  undef _LARGEFILE64_SOURCE\n#endif\n\n#if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0\n#  define Z_LARGE\n#endif\n\n#if (defined(Z_HAVE_UNISTD_H) || defined(Z_LARGE)) && !defined(Z_SOLO)\n#  include <unistd.h>       /* for SEEK_* and off_t */\n#  ifdef VMS\n#    include <unixio.h>     /* for off_t */\n#  endif\n#  ifndef z_off_t\n#    define z_off_t off_t\n#  endif\n#endif\n\n#if !defined(SEEK_SET) && !defined(Z_SOLO)\n#  define SEEK_SET        0       /* Seek from beginning of file.  */\n#  define SEEK_CUR        1       /* Seek from current position.  */\n#  define SEEK_END        2       /* Set file pointer to EOF plus \"offset\" */\n#endif\n\n#ifndef z_off_t\n#  define z_off_t long\n#endif\n\n#if !defined(_WIN32) && (defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0)\n#  define z_off64_t off64_t\n#else\n#  if defined(_WIN32)\n#    define z_off64_t __int64\n#  else\n#  define z_off64_t z_off_t\n#endif\n#endif\n\n/* MVS linker does not support external names larger than 8 bytes */\n#if defined(__MVS__)\n  #pragma map(deflateInit_,\"DEIN\")\n  #pragma map(deflateInit2_,\"DEIN2\")\n  #pragma map(deflateEnd,\"DEEND\")\n  #pragma map(deflateBound,\"DEBND\")\n  #pragma map(inflateInit_,\"ININ\")\n  #pragma map(inflateInit2_,\"ININ2\")\n  #pragma map(inflateEnd,\"INEND\")\n  #pragma map(inflateSync,\"INSY\")\n  #pragma map(inflateSetDictionary,\"INSEDI\")\n  #pragma map(compressBound,\"CMBND\")\n  #pragma map(inflate_table,\"INTABL\")\n  #pragma map(inflate_fast,\"INFA\")\n  #pragma map(inflate_copyright,\"INCOPY\")\n#endif\n\n#endif /* ZCONF_H */\n"
  },
  {
    "path": "Projects/Tools/PNGAlphaPremultiplier/Native/Source/ZLib/zlib.h",
    "content": "/* zlib.h -- interface of the 'zlib' general purpose compression library\n  version 1.2.6, January 29th, 2012\n\n  Copyright (C) 1995-2012 Jean-loup Gailly and Mark Adler\n\n  This software is provided 'as-is', without any express or implied\n  warranty.  In no event will the authors be held liable for any damages\n  arising from the use of this software.\n\n  Permission is granted to anyone to use this software for any purpose,\n  including commercial applications, and to alter it and redistribute it\n  freely, subject to the following restrictions:\n\n  1. The origin of this software must not be misrepresented; you must not\n     claim that you wrote the original software. If you use this software\n     in a product, an acknowledgment in the product documentation would be\n     appreciated but is not required.\n  2. Altered source versions must be plainly marked as such, and must not be\n     misrepresented as being the original software.\n  3. This notice may not be removed or altered from any source distribution.\n\n  Jean-loup Gailly        Mark Adler\n  jloup@gzip.org          madler@alumni.caltech.edu\n\n\n  The data format used by the zlib library is described by RFCs (Request for\n  Comments) 1950 to 1952 in the files http://tools.ietf.org/html/rfc1950\n  (zlib format), rfc1951 (deflate format) and rfc1952 (gzip format).\n*/\n\n#ifndef ZLIB_H\n#define ZLIB_H\n\n#include \"zconf.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#define ZLIB_VERSION \"1.2.6\"\n#define ZLIB_VERNUM 0x1260\n#define ZLIB_VER_MAJOR 1\n#define ZLIB_VER_MINOR 2\n#define ZLIB_VER_REVISION 6\n#define ZLIB_VER_SUBREVISION 0\n\n/*\n    The 'zlib' compression library provides in-memory compression and\n  decompression functions, including integrity checks of the uncompressed data.\n  This version of the library supports only one compression method (deflation)\n  but other algorithms will be added later and will have the same stream\n  interface.\n\n    Compression can be done in a single step if the buffers are large enough,\n  or can be done by repeated calls of the compression function.  In the latter\n  case, the application must provide more input and/or consume the output\n  (providing more output space) before each call.\n\n    The compressed data format used by default by the in-memory functions is\n  the zlib format, which is a zlib wrapper documented in RFC 1950, wrapped\n  around a deflate stream, which is itself documented in RFC 1951.\n\n    The library also supports reading and writing files in gzip (.gz) format\n  with an interface similar to that of stdio using the functions that start\n  with \"gz\".  The gzip format is different from the zlib format.  gzip is a\n  gzip wrapper, documented in RFC 1952, wrapped around a deflate stream.\n\n    This library can optionally read and write gzip streams in memory as well.\n\n    The zlib format was designed to be compact and fast for use in memory\n  and on communications channels.  The gzip format was designed for single-\n  file compression on file systems, has a larger header than zlib to maintain\n  directory information, and uses a different, slower check method than zlib.\n\n    The library does not install any signal handler.  The decoder checks\n  the consistency of the compressed data, so the library should never crash\n  even in case of corrupted input.\n*/\n\ntypedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size));\ntypedef void   (*free_func)  OF((voidpf opaque, voidpf address));\n\nstruct internal_state;\n\ntypedef struct z_stream_s {\n    z_const Bytef *next_in;     /* next input byte */\n    uInt     avail_in;  /* number of bytes available at next_in */\n    uLong    total_in;  /* total number of input bytes read so far */\n\n    Bytef    *next_out; /* next output byte should be put there */\n    uInt     avail_out; /* remaining free space at next_out */\n    uLong    total_out; /* total number of bytes output so far */\n\n    z_const char *msg;  /* last error message, NULL if no error */\n    struct internal_state FAR *state; /* not visible by applications */\n\n    alloc_func zalloc;  /* used to allocate the internal state */\n    free_func  zfree;   /* used to free the internal state */\n    voidpf     opaque;  /* private data object passed to zalloc and zfree */\n\n    int     data_type;  /* best guess about the data type: binary or text */\n    uLong   adler;      /* adler32 value of the uncompressed data */\n    uLong   reserved;   /* reserved for future use */\n} z_stream;\n\ntypedef z_stream FAR *z_streamp;\n\n/*\n     gzip header information passed to and from zlib routines.  See RFC 1952\n  for more details on the meanings of these fields.\n*/\ntypedef struct gz_header_s {\n    int     text;       /* true if compressed data believed to be text */\n    uLong   time;       /* modification time */\n    int     xflags;     /* extra flags (not used when writing a gzip file) */\n    int     os;         /* operating system */\n    Bytef   *extra;     /* pointer to extra field or Z_NULL if none */\n    uInt    extra_len;  /* extra field length (valid if extra != Z_NULL) */\n    uInt    extra_max;  /* space at extra (only when reading header) */\n    Bytef   *name;      /* pointer to zero-terminated file name or Z_NULL */\n    uInt    name_max;   /* space at name (only when reading header) */\n    Bytef   *comment;   /* pointer to zero-terminated comment or Z_NULL */\n    uInt    comm_max;   /* space at comment (only when reading header) */\n    int     hcrc;       /* true if there was or will be a header crc */\n    int     done;       /* true when done reading gzip header (not used\n                           when writing a gzip file) */\n} gz_header;\n\ntypedef gz_header FAR *gz_headerp;\n\n/*\n     The application must update next_in and avail_in when avail_in has dropped\n   to zero.  It must update next_out and avail_out when avail_out has dropped\n   to zero.  The application must initialize zalloc, zfree and opaque before\n   calling the init function.  All other fields are set by the compression\n   library and must not be updated by the application.\n\n     The opaque value provided by the application will be passed as the first\n   parameter for calls of zalloc and zfree.  This can be useful for custom\n   memory management.  The compression library attaches no meaning to the\n   opaque value.\n\n     zalloc must return Z_NULL if there is not enough memory for the object.\n   If zlib is used in a multi-threaded application, zalloc and zfree must be\n   thread safe.\n\n     On 16-bit systems, the functions zalloc and zfree must be able to allocate\n   exactly 65536 bytes, but will not be required to allocate more than this if\n   the symbol MAXSEG_64K is defined (see zconf.h).  WARNING: On MSDOS, pointers\n   returned by zalloc for objects of exactly 65536 bytes *must* have their\n   offset normalized to zero.  The default allocation function provided by this\n   library ensures this (see zutil.c).  To reduce memory requirements and avoid\n   any allocation of 64K objects, at the expense of compression ratio, compile\n   the library with -DMAX_WBITS=14 (see zconf.h).\n\n     The fields total_in and total_out can be used for statistics or progress\n   reports.  After compression, total_in holds the total size of the\n   uncompressed data and may be saved for use in the decompressor (particularly\n   if the decompressor wants to decompress everything in a single step).\n*/\n\n                        /* constants */\n\n#define Z_NO_FLUSH      0\n#define Z_PARTIAL_FLUSH 1\n#define Z_SYNC_FLUSH    2\n#define Z_FULL_FLUSH    3\n#define Z_FINISH        4\n#define Z_BLOCK         5\n#define Z_TREES         6\n/* Allowed flush values; see deflate() and inflate() below for details */\n\n#define Z_OK            0\n#define Z_STREAM_END    1\n#define Z_NEED_DICT     2\n#define Z_ERRNO        (-1)\n#define Z_STREAM_ERROR (-2)\n#define Z_DATA_ERROR   (-3)\n#define Z_MEM_ERROR    (-4)\n#define Z_BUF_ERROR    (-5)\n#define Z_VERSION_ERROR (-6)\n/* Return codes for the compression/decompression functions. Negative values\n * are errors, positive values are used for special but normal events.\n */\n\n#define Z_NO_COMPRESSION         0\n#define Z_BEST_SPEED             1\n#define Z_BEST_COMPRESSION       9\n#define Z_DEFAULT_COMPRESSION  (-1)\n/* compression levels */\n\n#define Z_FILTERED            1\n#define Z_HUFFMAN_ONLY        2\n#define Z_RLE                 3\n#define Z_FIXED               4\n#define Z_DEFAULT_STRATEGY    0\n/* compression strategy; see deflateInit2() below for details */\n\n#define Z_BINARY   0\n#define Z_TEXT     1\n#define Z_ASCII    Z_TEXT   /* for compatibility with 1.2.2 and earlier */\n#define Z_UNKNOWN  2\n/* Possible values of the data_type field (though see inflate()) */\n\n#define Z_DEFLATED   8\n/* The deflate compression method (the only one supported in this version) */\n\n#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */\n\n#define zlib_version zlibVersion()\n/* for compatibility with versions < 1.0.2 */\n\n\n                        /* basic functions */\n\nZEXTERN const char * ZEXPORT zlibVersion OF((void));\n/* The application can compare zlibVersion and ZLIB_VERSION for consistency.\n   If the first character differs, the library code actually used is not\n   compatible with the zlib.h header file used by the application.  This check\n   is automatically made by deflateInit and inflateInit.\n */\n\n/*\nZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level));\n\n     Initializes the internal stream state for compression.  The fields\n   zalloc, zfree and opaque must be initialized before by the caller.  If\n   zalloc and zfree are set to Z_NULL, deflateInit updates them to use default\n   allocation functions.\n\n     The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9:\n   1 gives best speed, 9 gives best compression, 0 gives no compression at all\n   (the input data is simply copied a block at a time).  Z_DEFAULT_COMPRESSION\n   requests a default compromise between speed and compression (currently\n   equivalent to level 6).\n\n     deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough\n   memory, Z_STREAM_ERROR if level is not a valid compression level, or\n   Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible\n   with the version assumed by the caller (ZLIB_VERSION).  msg is set to null\n   if there is no error message.  deflateInit does not perform any compression:\n   this will be done by deflate().\n*/\n\n\nZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush));\n/*\n    deflate compresses as much data as possible, and stops when the input\n  buffer becomes empty or the output buffer becomes full.  It may introduce\n  some output latency (reading input without producing any output) except when\n  forced to flush.\n\n    The detailed semantics are as follows.  deflate performs one or both of the\n  following actions:\n\n  - Compress more input starting at next_in and update next_in and avail_in\n    accordingly.  If not all input can be processed (because there is not\n    enough room in the output buffer), next_in and avail_in are updated and\n    processing will resume at this point for the next call of deflate().\n\n  - Provide more output starting at next_out and update next_out and avail_out\n    accordingly.  This action is forced if the parameter flush is non zero.\n    Forcing flush frequently degrades the compression ratio, so this parameter\n    should be set only when necessary (in interactive applications).  Some\n    output may be provided even if flush is not set.\n\n    Before the call of deflate(), the application should ensure that at least\n  one of the actions is possible, by providing more input and/or consuming more\n  output, and updating avail_in or avail_out accordingly; avail_out should\n  never be zero before the call.  The application can consume the compressed\n  output when it wants, for example when the output buffer is full (avail_out\n  == 0), or after each call of deflate().  If deflate returns Z_OK and with\n  zero avail_out, it must be called again after making room in the output\n  buffer because there might be more output pending.\n\n    Normally the parameter flush is set to Z_NO_FLUSH, which allows deflate to\n  decide how much data to accumulate before producing output, in order to\n  maximize compression.\n\n    If the parameter flush is set to Z_SYNC_FLUSH, all pending output is\n  flushed to the output buffer and the output is aligned on a byte boundary, so\n  that the decompressor can get all input data available so far.  (In\n  particular avail_in is zero after the call if enough output space has been\n  provided before the call.) Flushing may degrade compression for some\n  compression algorithms and so it should be used only when necessary.  This\n  completes the current deflate block and follows it with an empty stored block\n  that is three bits plus filler bits to the next byte, followed by four bytes\n  (00 00 ff ff).\n\n    If flush is set to Z_PARTIAL_FLUSH, all pending output is flushed to the\n  output buffer, but the output is not aligned to a byte boundary.  All of the\n  input data so far will be available to the decompressor, as for Z_SYNC_FLUSH.\n  This completes the current deflate block and follows it with an empty fixed\n  codes block that is 10 bits long.  This assures that enough bytes are output\n  in order for the decompressor to finish the block before the empty fixed code\n  block.\n\n    If flush is set to Z_BLOCK, a deflate block is completed and emitted, as\n  for Z_SYNC_FLUSH, but the output is not aligned on a byte boundary, and up to\n  seven bits of the current block are held to be written as the next byte after\n  the next deflate block is completed.  In this case, the decompressor may not\n  be provided enough bits at this point in order to complete decompression of\n  the data provided so far to the compressor.  It may need to wait for the next\n  block to be emitted.  This is for advanced applications that need to control\n  the emission of deflate blocks.\n\n    If flush is set to Z_FULL_FLUSH, all output is flushed as with\n  Z_SYNC_FLUSH, and the compression state is reset so that decompression can\n  restart from this point if previous compressed data has been damaged or if\n  random access is desired.  Using Z_FULL_FLUSH too often can seriously degrade\n  compression.\n\n    If deflate returns with avail_out == 0, this function must be called again\n  with the same value of the flush parameter and more output space (updated\n  avail_out), until the flush is complete (deflate returns with non-zero\n  avail_out).  In the case of a Z_FULL_FLUSH or Z_SYNC_FLUSH, make sure that\n  avail_out is greater than six to avoid repeated flush markers due to\n  avail_out == 0 on return.\n\n    If the parameter flush is set to Z_FINISH, pending input is processed,\n  pending output is flushed and deflate returns with Z_STREAM_END if there was\n  enough output space; if deflate returns with Z_OK, this function must be\n  called again with Z_FINISH and more output space (updated avail_out) but no\n  more input data, until it returns with Z_STREAM_END or an error.  After\n  deflate has returned Z_STREAM_END, the only possible operations on the stream\n  are deflateReset or deflateEnd.\n\n    Z_FINISH can be used immediately after deflateInit if all the compression\n  is to be done in a single step.  In this case, avail_out must be at least the\n  value returned by deflateBound (see below).  Then deflate is guaranteed to\n  return Z_STREAM_END.  If not enough output space is provided, deflate will\n  not return Z_STREAM_END, and it must be called again as described above.\n\n    deflate() sets strm->adler to the adler32 checksum of all input read\n  so far (that is, total_in bytes).\n\n    deflate() may update strm->data_type if it can make a good guess about\n  the input data type (Z_BINARY or Z_TEXT).  In doubt, the data is considered\n  binary.  This field is only for information purposes and does not affect the\n  compression algorithm in any manner.\n\n    deflate() returns Z_OK if some progress has been made (more input\n  processed or more output produced), Z_STREAM_END if all input has been\n  consumed and all output has been produced (only when flush is set to\n  Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example\n  if next_in or next_out was Z_NULL), Z_BUF_ERROR if no progress is possible\n  (for example avail_in or avail_out was zero).  Note that Z_BUF_ERROR is not\n  fatal, and deflate() can be called again with more input and more output\n  space to continue compressing.\n*/\n\n\nZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm));\n/*\n     All dynamically allocated data structures for this stream are freed.\n   This function discards any unprocessed input and does not flush any pending\n   output.\n\n     deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the\n   stream state was inconsistent, Z_DATA_ERROR if the stream was freed\n   prematurely (some input or output was discarded).  In the error case, msg\n   may be set but then points to a static string (which must not be\n   deallocated).\n*/\n\n\n/*\nZEXTERN int ZEXPORT inflateInit OF((z_streamp strm));\n\n     Initializes the internal stream state for decompression.  The fields\n   next_in, avail_in, zalloc, zfree and opaque must be initialized before by\n   the caller.  If next_in is not Z_NULL and avail_in is large enough (the\n   exact value depends on the compression method), inflateInit determines the\n   compression method from the zlib header and allocates all data structures\n   accordingly; otherwise the allocation will be deferred to the first call of\n   inflate.  If zalloc and zfree are set to Z_NULL, inflateInit updates them to\n   use default allocation functions.\n\n     inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough\n   memory, Z_VERSION_ERROR if the zlib library version is incompatible with the\n   version assumed by the caller, or Z_STREAM_ERROR if the parameters are\n   invalid, such as a null pointer to the structure.  msg is set to null if\n   there is no error message.  inflateInit does not perform any decompression\n   apart from possibly reading the zlib header if present: actual decompression\n   will be done by inflate().  (So next_in and avail_in may be modified, but\n   next_out and avail_out are unused and unchanged.) The current implementation\n   of inflateInit() does not process any header information -- that is deferred\n   until inflate() is called.\n*/\n\n\nZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush));\n/*\n    inflate decompresses as much data as possible, and stops when the input\n  buffer becomes empty or the output buffer becomes full.  It may introduce\n  some output latency (reading input without producing any output) except when\n  forced to flush.\n\n  The detailed semantics are as follows.  inflate performs one or both of the\n  following actions:\n\n  - Decompress more input starting at next_in and update next_in and avail_in\n    accordingly.  If not all input can be processed (because there is not\n    enough room in the output buffer), next_in is updated and processing will\n    resume at this point for the next call of inflate().\n\n  - Provide more output starting at next_out and update next_out and avail_out\n    accordingly.  inflate() provides as much output as possible, until there is\n    no more input data or no more space in the output buffer (see below about\n    the flush parameter).\n\n    Before the call of inflate(), the application should ensure that at least\n  one of the actions is possible, by providing more input and/or consuming more\n  output, and updating the next_* and avail_* values accordingly.  The\n  application can consume the uncompressed output when it wants, for example\n  when the output buffer is full (avail_out == 0), or after each call of\n  inflate().  If inflate returns Z_OK and with zero avail_out, it must be\n  called again after making room in the output buffer because there might be\n  more output pending.\n\n    The flush parameter of inflate() can be Z_NO_FLUSH, Z_SYNC_FLUSH, Z_FINISH,\n  Z_BLOCK, or Z_TREES.  Z_SYNC_FLUSH requests that inflate() flush as much\n  output as possible to the output buffer.  Z_BLOCK requests that inflate()\n  stop if and when it gets to the next deflate block boundary.  When decoding\n  the zlib or gzip format, this will cause inflate() to return immediately\n  after the header and before the first block.  When doing a raw inflate,\n  inflate() will go ahead and process the first block, and will return when it\n  gets to the end of that block, or when it runs out of data.\n\n    The Z_BLOCK option assists in appending to or combining deflate streams.\n  Also to assist in this, on return inflate() will set strm->data_type to the\n  number of unused bits in the last byte taken from strm->next_in, plus 64 if\n  inflate() is currently decoding the last block in the deflate stream, plus\n  128 if inflate() returned immediately after decoding an end-of-block code or\n  decoding the complete header up to just before the first byte of the deflate\n  stream.  The end-of-block will not be indicated until all of the uncompressed\n  data from that block has been written to strm->next_out.  The number of\n  unused bits may in general be greater than seven, except when bit 7 of\n  data_type is set, in which case the number of unused bits will be less than\n  eight.  data_type is set as noted here every time inflate() returns for all\n  flush options, and so can be used to determine the amount of currently\n  consumed input in bits.\n\n    The Z_TREES option behaves as Z_BLOCK does, but it also returns when the\n  end of each deflate block header is reached, before any actual data in that\n  block is decoded.  This allows the caller to determine the length of the\n  deflate block header for later use in random access within a deflate block.\n  256 is added to the value of strm->data_type when inflate() returns\n  immediately after reaching the end of the deflate block header.\n\n    inflate() should normally be called until it returns Z_STREAM_END or an\n  error.  However if all decompression is to be performed in a single step (a\n  single call of inflate), the parameter flush should be set to Z_FINISH.  In\n  this case all pending input is processed and all pending output is flushed;\n  avail_out must be large enough to hold all the uncompressed data.  (The size\n  of the uncompressed data may have been saved by the compressor for this\n  purpose.) The next operation on this stream must be inflateEnd to deallocate\n  the decompression state.  The use of Z_FINISH is not required to perform an\n  inflation in one step.  However it may be used to inform inflate that a\n  faster approach can be used for the single inflate() call.  Z_FINISH also\n  informs inflate to not maintain a sliding window if the stream completes,\n  which reduces inflate's memory footprint.\n\n     In this implementation, inflate() always flushes as much output as\n  possible to the output buffer, and always uses the faster approach on the\n  first call.  So the effects of the flush parameter in this implementation are\n  on the return value of inflate() as noted below, when inflate() returns early\n  when Z_BLOCK or Z_TREES is used, and when inflate() avoids the allocation of\n  memory for a sliding window when Z_FINISH is used.\n\n     If a preset dictionary is needed after this call (see inflateSetDictionary\n  below), inflate sets strm->adler to the Adler-32 checksum of the dictionary\n  chosen by the compressor and returns Z_NEED_DICT; otherwise it sets\n  strm->adler to the Adler-32 checksum of all output produced so far (that is,\n  total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as described\n  below.  At the end of the stream, inflate() checks that its computed adler32\n  checksum is equal to that saved by the compressor and returns Z_STREAM_END\n  only if the checksum is correct.\n\n    inflate() can decompress and check either zlib-wrapped or gzip-wrapped\n  deflate data.  The header type is detected automatically, if requested when\n  initializing with inflateInit2().  Any information contained in the gzip\n  header is not retained, so applications that need that information should\n  instead use raw inflate, see inflateInit2() below, or inflateBack() and\n  perform their own processing of the gzip header and trailer.  When processing\n  gzip-wrapped deflate data, strm->adler32 is set to the CRC-32 of the output\n  producted so far.  The CRC-32 is checked against the gzip trailer.\n\n    inflate() returns Z_OK if some progress has been made (more input processed\n  or more output produced), Z_STREAM_END if the end of the compressed data has\n  been reached and all uncompressed output has been produced, Z_NEED_DICT if a\n  preset dictionary is needed at this point, Z_DATA_ERROR if the input data was\n  corrupted (input stream not conforming to the zlib format or incorrect check\n  value), Z_STREAM_ERROR if the stream structure was inconsistent (for example\n  next_in or next_out was Z_NULL), Z_MEM_ERROR if there was not enough memory,\n  Z_BUF_ERROR if no progress is possible or if there was not enough room in the\n  output buffer when Z_FINISH is used.  Note that Z_BUF_ERROR is not fatal, and\n  inflate() can be called again with more input and more output space to\n  continue decompressing.  If Z_DATA_ERROR is returned, the application may\n  then call inflateSync() to look for a good compression block if a partial\n  recovery of the data is desired.\n*/\n\n\nZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm));\n/*\n     All dynamically allocated data structures for this stream are freed.\n   This function discards any unprocessed input and does not flush any pending\n   output.\n\n     inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state\n   was inconsistent.  In the error case, msg may be set but then points to a\n   static string (which must not be deallocated).\n*/\n\n\n                        /* Advanced functions */\n\n/*\n    The following functions are needed only in some special applications.\n*/\n\n/*\nZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm,\n                                     int  level,\n                                     int  method,\n                                     int  windowBits,\n                                     int  memLevel,\n                                     int  strategy));\n\n     This is another version of deflateInit with more compression options.  The\n   fields next_in, zalloc, zfree and opaque must be initialized before by the\n   caller.\n\n     The method parameter is the compression method.  It must be Z_DEFLATED in\n   this version of the library.\n\n     The windowBits parameter is the base two logarithm of the window size\n   (the size of the history buffer).  It should be in the range 8..15 for this\n   version of the library.  Larger values of this parameter result in better\n   compression at the expense of memory usage.  The default value is 15 if\n   deflateInit is used instead.\n\n     windowBits can also be -8..-15 for raw deflate.  In this case, -windowBits\n   determines the window size.  deflate() will then generate raw deflate data\n   with no zlib header or trailer, and will not compute an adler32 check value.\n\n     windowBits can also be greater than 15 for optional gzip encoding.  Add\n   16 to windowBits to write a simple gzip header and trailer around the\n   compressed data instead of a zlib wrapper.  The gzip header will have no\n   file name, no extra data, no comment, no modification time (set to zero), no\n   header crc, and the operating system will be set to 255 (unknown).  If a\n   gzip stream is being written, strm->adler is a crc32 instead of an adler32.\n\n     The memLevel parameter specifies how much memory should be allocated\n   for the internal compression state.  memLevel=1 uses minimum memory but is\n   slow and reduces compression ratio; memLevel=9 uses maximum memory for\n   optimal speed.  The default value is 8.  See zconf.h for total memory usage\n   as a function of windowBits and memLevel.\n\n     The strategy parameter is used to tune the compression algorithm.  Use the\n   value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a\n   filter (or predictor), Z_HUFFMAN_ONLY to force Huffman encoding only (no\n   string match), or Z_RLE to limit match distances to one (run-length\n   encoding).  Filtered data consists mostly of small values with a somewhat\n   random distribution.  In this case, the compression algorithm is tuned to\n   compress them better.  The effect of Z_FILTERED is to force more Huffman\n   coding and less string matching; it is somewhat intermediate between\n   Z_DEFAULT_STRATEGY and Z_HUFFMAN_ONLY.  Z_RLE is designed to be almost as\n   fast as Z_HUFFMAN_ONLY, but give better compression for PNG image data.  The\n   strategy parameter only affects the compression ratio but not the\n   correctness of the compressed output even if it is not set appropriately.\n   Z_FIXED prevents the use of dynamic Huffman codes, allowing for a simpler\n   decoder for special applications.\n\n     deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough\n   memory, Z_STREAM_ERROR if any parameter is invalid (such as an invalid\n   method), or Z_VERSION_ERROR if the zlib library version (zlib_version) is\n   incompatible with the version assumed by the caller (ZLIB_VERSION).  msg is\n   set to null if there is no error message.  deflateInit2 does not perform any\n   compression: this will be done by deflate().\n*/\n\nZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm,\n                                             const Bytef *dictionary,\n                                             uInt  dictLength));\n/*\n     Initializes the compression dictionary from the given byte sequence\n   without producing any compressed output.  When using the zlib format, this\n   function must be called immediately after deflateInit, deflateInit2 or\n   deflateReset, and before any call of deflate.  When doing raw deflate, this\n   function must be called either before any call of deflate, or immediately\n   after the completion of a deflate block, i.e. after all input has been\n   consumed and all output has been delivered when using any of the flush\n   options Z_BLOCK, Z_PARTIAL_FLUSH, Z_SYNC_FLUSH, or Z_FULL_FLUSH.  The\n   compressor and decompressor must use exactly the same dictionary (see\n   inflateSetDictionary).\n\n     The dictionary should consist of strings (byte sequences) that are likely\n   to be encountered later in the data to be compressed, with the most commonly\n   used strings preferably put towards the end of the dictionary.  Using a\n   dictionary is most useful when the data to be compressed is short and can be\n   predicted with good accuracy; the data can then be compressed better than\n   with the default empty dictionary.\n\n     Depending on the size of the compression data structures selected by\n   deflateInit or deflateInit2, a part of the dictionary may in effect be\n   discarded, for example if the dictionary is larger than the window size\n   provided in deflateInit or deflateInit2.  Thus the strings most likely to be\n   useful should be put at the end of the dictionary, not at the front.  In\n   addition, the current implementation of deflate will use at most the window\n   size minus 262 bytes of the provided dictionary.\n\n     Upon return of this function, strm->adler is set to the adler32 value\n   of the dictionary; the decompressor may later use this value to determine\n   which dictionary has been used by the compressor.  (The adler32 value\n   applies to the whole dictionary even if only a subset of the dictionary is\n   actually used by the compressor.) If a raw deflate was requested, then the\n   adler32 value is not computed and strm->adler is not set.\n\n     deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a\n   parameter is invalid (e.g.  dictionary being Z_NULL) or the stream state is\n   inconsistent (for example if deflate has already been called for this stream\n   or if not at a block boundary for raw deflate).  deflateSetDictionary does\n   not perform any compression: this will be done by deflate().\n*/\n\nZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest,\n                                    z_streamp source));\n/*\n     Sets the destination stream as a complete copy of the source stream.\n\n     This function can be useful when several compression strategies will be\n   tried, for example when there are several ways of pre-processing the input\n   data with a filter.  The streams that will be discarded should then be freed\n   by calling deflateEnd.  Note that deflateCopy duplicates the internal\n   compression state which can be quite large, so this strategy is slow and can\n   consume lots of memory.\n\n     deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not\n   enough memory, Z_STREAM_ERROR if the source stream state was inconsistent\n   (such as zalloc being Z_NULL).  msg is left unchanged in both source and\n   destination.\n*/\n\nZEXTERN int ZEXPORT deflateReset OF((z_streamp strm));\n/*\n     This function is equivalent to deflateEnd followed by deflateInit,\n   but does not free and reallocate all the internal compression state.  The\n   stream will keep the same compression level and any other attributes that\n   may have been set by deflateInit2.\n\n     deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source\n   stream state was inconsistent (such as zalloc or state being Z_NULL).\n*/\n\nZEXTERN int ZEXPORT deflateParams OF((z_streamp strm,\n                                      int level,\n                                      int strategy));\n/*\n     Dynamically update the compression level and compression strategy.  The\n   interpretation of level and strategy is as in deflateInit2.  This can be\n   used to switch between compression and straight copy of the input data, or\n   to switch to a different kind of input data requiring a different strategy.\n   If the compression level is changed, the input available so far is\n   compressed with the old level (and may be flushed); the new level will take\n   effect only at the next call of deflate().\n\n     Before the call of deflateParams, the stream state must be set as for\n   a call of deflate(), since the currently available input may have to be\n   compressed and flushed.  In particular, strm->avail_out must be non-zero.\n\n     deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source\n   stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR if\n   strm->avail_out was zero.\n*/\n\nZEXTERN int ZEXPORT deflateTune OF((z_streamp strm,\n                                    int good_length,\n                                    int max_lazy,\n                                    int nice_length,\n                                    int max_chain));\n/*\n     Fine tune deflate's internal compression parameters.  This should only be\n   used by someone who understands the algorithm used by zlib's deflate for\n   searching for the best matching string, and even then only by the most\n   fanatic optimizer trying to squeeze out the last compressed bit for their\n   specific input data.  Read the deflate.c source code for the meaning of the\n   max_lazy, good_length, nice_length, and max_chain parameters.\n\n     deflateTune() can be called after deflateInit() or deflateInit2(), and\n   returns Z_OK on success, or Z_STREAM_ERROR for an invalid deflate stream.\n */\n\nZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm,\n                                       uLong sourceLen));\n/*\n     deflateBound() returns an upper bound on the compressed size after\n   deflation of sourceLen bytes.  It must be called after deflateInit() or\n   deflateInit2(), and after deflateSetHeader(), if used.  This would be used\n   to allocate an output buffer for deflation in a single pass, and so would be\n   called before deflate().  If that first deflate() call is provided the\n   sourceLen input bytes, an output buffer allocated to the size returned by\n   deflateBound(), and the flush value Z_FINISH, then deflate() is guaranteed\n   to return Z_STREAM_END.  Note that it is possible for the compressed size to\n   be larger than the value returned by deflateBound() if flush options other\n   than Z_FINISH or Z_NO_FLUSH are used.\n*/\n\nZEXTERN int ZEXPORT deflatePending OF((z_streamp strm,\n                                       unsigned *pending,\n                                       int *bits));\n/*\n     deflatePending() returns the number of bytes and bits of output that have\n   been generated, but not yet provided in the available output.  The bytes not\n   provided would be due to the available output space having being consumed.\n   The number of bits of output not provided are between 0 and 7, where they\n   await more bits to join them in order to fill out a full byte.  If pending\n   or bits are Z_NULL, then those values are not set.\n\n     deflatePending returns Z_OK if success, or Z_STREAM_ERROR if the source\n   stream state was inconsistent.\n */\n\nZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm,\n                                     int bits,\n                                     int value));\n/*\n     deflatePrime() inserts bits in the deflate output stream.  The intent\n   is that this function is used to start off the deflate output with the bits\n   leftover from a previous deflate stream when appending to it.  As such, this\n   function can only be used for raw deflate, and must be used before the first\n   deflate() call after a deflateInit2() or deflateReset().  bits must be less\n   than or equal to 16, and that many of the least significant bits of value\n   will be inserted in the output.\n\n     deflatePrime returns Z_OK if success, Z_BUF_ERROR if there was not enough\n   room in the internal buffer to insert the bits, or Z_STREAM_ERROR if the\n   source stream state was inconsistent.\n*/\n\nZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm,\n                                         gz_headerp head));\n/*\n     deflateSetHeader() provides gzip header information for when a gzip\n   stream is requested by deflateInit2().  deflateSetHeader() may be called\n   after deflateInit2() or deflateReset() and before the first call of\n   deflate().  The text, time, os, extra field, name, and comment information\n   in the provided gz_header structure are written to the gzip header (xflag is\n   ignored -- the extra flags are set according to the compression level).  The\n   caller must assure that, if not Z_NULL, name and comment are terminated with\n   a zero byte, and that if extra is not Z_NULL, that extra_len bytes are\n   available there.  If hcrc is true, a gzip header crc is included.  Note that\n   the current versions of the command-line version of gzip (up through version\n   1.3.x) do not support header crc's, and will report that it is a \"multi-part\n   gzip file\" and give up.\n\n     If deflateSetHeader is not used, the default gzip header has text false,\n   the time set to zero, and os set to 255, with no extra, name, or comment\n   fields.  The gzip header is returned to the default state by deflateReset().\n\n     deflateSetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source\n   stream state was inconsistent.\n*/\n\n/*\nZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm,\n                                     int  windowBits));\n\n     This is another version of inflateInit with an extra parameter.  The\n   fields next_in, avail_in, zalloc, zfree and opaque must be initialized\n   before by the caller.\n\n     The windowBits parameter is the base two logarithm of the maximum window\n   size (the size of the history buffer).  It should be in the range 8..15 for\n   this version of the library.  The default value is 15 if inflateInit is used\n   instead.  windowBits must be greater than or equal to the windowBits value\n   provided to deflateInit2() while compressing, or it must be equal to 15 if\n   deflateInit2() was not used.  If a compressed stream with a larger window\n   size is given as input, inflate() will return with the error code\n   Z_DATA_ERROR instead of trying to allocate a larger window.\n\n     windowBits can also be zero to request that inflate use the window size in\n   the zlib header of the compressed stream.\n\n     windowBits can also be -8..-15 for raw inflate.  In this case, -windowBits\n   determines the window size.  inflate() will then process raw deflate data,\n   not looking for a zlib or gzip header, not generating a check value, and not\n   looking for any check values for comparison at the end of the stream.  This\n   is for use with other formats that use the deflate compressed data format\n   such as zip.  Those formats provide their own check values.  If a custom\n   format is developed using the raw deflate format for compressed data, it is\n   recommended that a check value such as an adler32 or a crc32 be applied to\n   the uncompressed data as is done in the zlib, gzip, and zip formats.  For\n   most applications, the zlib format should be used as is.  Note that comments\n   above on the use in deflateInit2() applies to the magnitude of windowBits.\n\n     windowBits can also be greater than 15 for optional gzip decoding.  Add\n   32 to windowBits to enable zlib and gzip decoding with automatic header\n   detection, or add 16 to decode only the gzip format (the zlib format will\n   return a Z_DATA_ERROR).  If a gzip stream is being decoded, strm->adler is a\n   crc32 instead of an adler32.\n\n     inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough\n   memory, Z_VERSION_ERROR if the zlib library version is incompatible with the\n   version assumed by the caller, or Z_STREAM_ERROR if the parameters are\n   invalid, such as a null pointer to the structure.  msg is set to null if\n   there is no error message.  inflateInit2 does not perform any decompression\n   apart from possibly reading the zlib header if present: actual decompression\n   will be done by inflate().  (So next_in and avail_in may be modified, but\n   next_out and avail_out are unused and unchanged.) The current implementation\n   of inflateInit2() does not process any header information -- that is\n   deferred until inflate() is called.\n*/\n\nZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm,\n                                             const Bytef *dictionary,\n                                             uInt  dictLength));\n/*\n     Initializes the decompression dictionary from the given uncompressed byte\n   sequence.  This function must be called immediately after a call of inflate,\n   if that call returned Z_NEED_DICT.  The dictionary chosen by the compressor\n   can be determined from the adler32 value returned by that call of inflate.\n   The compressor and decompressor must use exactly the same dictionary (see\n   deflateSetDictionary).  For raw inflate, this function can be called at any\n   time to set the dictionary.  If the provided dictionary is smaller than the\n   window and there is already data in the window, then the provided dictionary\n   will amend what's there.  The application must insure that the dictionary\n   that was used for compression is provided.\n\n     inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a\n   parameter is invalid (e.g.  dictionary being Z_NULL) or the stream state is\n   inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the\n   expected one (incorrect adler32 value).  inflateSetDictionary does not\n   perform any decompression: this will be done by subsequent calls of\n   inflate().\n*/\n\nZEXTERN int ZEXPORT inflateSync OF((z_streamp strm));\n/*\n     Skips invalid compressed data until a possible full flush point (see above\n   for the description of deflate with Z_FULL_FLUSH) can be found, or until all\n   available input is skipped.  No output is provided.\n\n     inflateSync searches for a 00 00 FF FF pattern in the compressed data.\n   All full flush points have this pattern, but not all occurences of this\n   pattern are full flush points.\n\n     inflateSync returns Z_OK if a possible full flush point has been found,\n   Z_BUF_ERROR if no more input was provided, Z_DATA_ERROR if no flush point\n   has been found, or Z_STREAM_ERROR if the stream structure was inconsistent.\n   In the success case, the application may save the current current value of\n   total_in which indicates where valid compressed data was found.  In the\n   error case, the application may repeatedly call inflateSync, providing more\n   input each time, until success or end of the input data.\n*/\n\nZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest,\n                                    z_streamp source));\n/*\n     Sets the destination stream as a complete copy of the source stream.\n\n     This function can be useful when randomly accessing a large stream.  The\n   first pass through the stream can periodically record the inflate state,\n   allowing restarting inflate at those points when randomly accessing the\n   stream.\n\n     inflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not\n   enough memory, Z_STREAM_ERROR if the source stream state was inconsistent\n   (such as zalloc being Z_NULL).  msg is left unchanged in both source and\n   destination.\n*/\n\nZEXTERN int ZEXPORT inflateReset OF((z_streamp strm));\n/*\n     This function is equivalent to inflateEnd followed by inflateInit,\n   but does not free and reallocate all the internal decompression state.  The\n   stream will keep attributes that may have been set by inflateInit2.\n\n     inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source\n   stream state was inconsistent (such as zalloc or state being Z_NULL).\n*/\n\nZEXTERN int ZEXPORT inflateReset2 OF((z_streamp strm,\n                                      int windowBits));\n/*\n     This function is the same as inflateReset, but it also permits changing\n   the wrap and window size requests.  The windowBits parameter is interpreted\n   the same as it is for inflateInit2.\n\n     inflateReset2 returns Z_OK if success, or Z_STREAM_ERROR if the source\n   stream state was inconsistent (such as zalloc or state being Z_NULL), or if\n   the windowBits parameter is invalid.\n*/\n\nZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm,\n                                     int bits,\n                                     int value));\n/*\n     This function inserts bits in the inflate input stream.  The intent is\n   that this function is used to start inflating at a bit position in the\n   middle of a byte.  The provided bits will be used before any bytes are used\n   from next_in.  This function should only be used with raw inflate, and\n   should be used before the first inflate() call after inflateInit2() or\n   inflateReset().  bits must be less than or equal to 16, and that many of the\n   least significant bits of value will be inserted in the input.\n\n     If bits is negative, then the input stream bit buffer is emptied.  Then\n   inflatePrime() can be called again to put bits in the buffer.  This is used\n   to clear out bits leftover after feeding inflate a block description prior\n   to feeding inflate codes.\n\n     inflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source\n   stream state was inconsistent.\n*/\n\nZEXTERN long ZEXPORT inflateMark OF((z_streamp strm));\n/*\n     This function returns two values, one in the lower 16 bits of the return\n   value, and the other in the remaining upper bits, obtained by shifting the\n   return value down 16 bits.  If the upper value is -1 and the lower value is\n   zero, then inflate() is currently decoding information outside of a block.\n   If the upper value is -1 and the lower value is non-zero, then inflate is in\n   the middle of a stored block, with the lower value equaling the number of\n   bytes from the input remaining to copy.  If the upper value is not -1, then\n   it is the number of bits back from the current bit position in the input of\n   the code (literal or length/distance pair) currently being processed.  In\n   that case the lower value is the number of bytes already emitted for that\n   code.\n\n     A code is being processed if inflate is waiting for more input to complete\n   decoding of the code, or if it has completed decoding but is waiting for\n   more output space to write the literal or match data.\n\n     inflateMark() is used to mark locations in the input data for random\n   access, which may be at bit positions, and to note those cases where the\n   output of a code may span boundaries of random access blocks.  The current\n   location in the input stream can be determined from avail_in and data_type\n   as noted in the description for the Z_BLOCK flush parameter for inflate.\n\n     inflateMark returns the value noted above or -1 << 16 if the provided\n   source stream state was inconsistent.\n*/\n\nZEXTERN int ZEXPORT inflateGetHeader OF((z_streamp strm,\n                                         gz_headerp head));\n/*\n     inflateGetHeader() requests that gzip header information be stored in the\n   provided gz_header structure.  inflateGetHeader() may be called after\n   inflateInit2() or inflateReset(), and before the first call of inflate().\n   As inflate() processes the gzip stream, head->done is zero until the header\n   is completed, at which time head->done is set to one.  If a zlib stream is\n   being decoded, then head->done is set to -1 to indicate that there will be\n   no gzip header information forthcoming.  Note that Z_BLOCK or Z_TREES can be\n   used to force inflate() to return immediately after header processing is\n   complete and before any actual data is decompressed.\n\n     The text, time, xflags, and os fields are filled in with the gzip header\n   contents.  hcrc is set to true if there is a header CRC.  (The header CRC\n   was valid if done is set to one.) If extra is not Z_NULL, then extra_max\n   contains the maximum number of bytes to write to extra.  Once done is true,\n   extra_len contains the actual extra field length, and extra contains the\n   extra field, or that field truncated if extra_max is less than extra_len.\n   If name is not Z_NULL, then up to name_max characters are written there,\n   terminated with a zero unless the length is greater than name_max.  If\n   comment is not Z_NULL, then up to comm_max characters are written there,\n   terminated with a zero unless the length is greater than comm_max.  When any\n   of extra, name, or comment are not Z_NULL and the respective field is not\n   present in the header, then that field is set to Z_NULL to signal its\n   absence.  This allows the use of deflateSetHeader() with the returned\n   structure to duplicate the header.  However if those fields are set to\n   allocated memory, then the application will need to save those pointers\n   elsewhere so that they can be eventually freed.\n\n     If inflateGetHeader is not used, then the header information is simply\n   discarded.  The header is always checked for validity, including the header\n   CRC if present.  inflateReset() will reset the process to discard the header\n   information.  The application would need to call inflateGetHeader() again to\n   retrieve the header from the next gzip stream.\n\n     inflateGetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source\n   stream state was inconsistent.\n*/\n\n/*\nZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits,\n                                        unsigned char FAR *window));\n\n     Initialize the internal stream state for decompression using inflateBack()\n   calls.  The fields zalloc, zfree and opaque in strm must be initialized\n   before the call.  If zalloc and zfree are Z_NULL, then the default library-\n   derived memory allocation routines are used.  windowBits is the base two\n   logarithm of the window size, in the range 8..15.  window is a caller\n   supplied buffer of that size.  Except for special applications where it is\n   assured that deflate was used with small window sizes, windowBits must be 15\n   and a 32K byte window must be supplied to be able to decompress general\n   deflate streams.\n\n     See inflateBack() for the usage of these routines.\n\n     inflateBackInit will return Z_OK on success, Z_STREAM_ERROR if any of\n   the parameters are invalid, Z_MEM_ERROR if the internal state could not be\n   allocated, or Z_VERSION_ERROR if the version of the library does not match\n   the version of the header file.\n*/\n\ntypedef unsigned (*in_func) OF((void FAR *, unsigned char FAR * FAR *));\ntypedef int (*out_func) OF((void FAR *, unsigned char FAR *, unsigned));\n\nZEXTERN int ZEXPORT inflateBack OF((z_streamp strm,\n                                    in_func in, void FAR *in_desc,\n                                    out_func out, void FAR *out_desc));\n/*\n     inflateBack() does a raw inflate with a single call using a call-back\n   interface for input and output.  This is more efficient than inflate() for\n   file i/o applications in that it avoids copying between the output and the\n   sliding window by simply making the window itself the output buffer.  This\n   function trusts the application to not change the output buffer passed by\n   the output function, at least until inflateBack() returns.\n\n     inflateBackInit() must be called first to allocate the internal state\n   and to initialize the state with the user-provided window buffer.\n   inflateBack() may then be used multiple times to inflate a complete, raw\n   deflate stream with each call.  inflateBackEnd() is then called to free the\n   allocated state.\n\n     A raw deflate stream is one with no zlib or gzip header or trailer.\n   This routine would normally be used in a utility that reads zip or gzip\n   files and writes out uncompressed files.  The utility would decode the\n   header and process the trailer on its own, hence this routine expects only\n   the raw deflate stream to decompress.  This is different from the normal\n   behavior of inflate(), which expects either a zlib or gzip header and\n   trailer around the deflate stream.\n\n     inflateBack() uses two subroutines supplied by the caller that are then\n   called by inflateBack() for input and output.  inflateBack() calls those\n   routines until it reads a complete deflate stream and writes out all of the\n   uncompressed data, or until it encounters an error.  The function's\n   parameters and return types are defined above in the in_func and out_func\n   typedefs.  inflateBack() will call in(in_desc, &buf) which should return the\n   number of bytes of provided input, and a pointer to that input in buf.  If\n   there is no input available, in() must return zero--buf is ignored in that\n   case--and inflateBack() will return a buffer error.  inflateBack() will call\n   out(out_desc, buf, len) to write the uncompressed data buf[0..len-1].  out()\n   should return zero on success, or non-zero on failure.  If out() returns\n   non-zero, inflateBack() will return with an error.  Neither in() nor out()\n   are permitted to change the contents of the window provided to\n   inflateBackInit(), which is also the buffer that out() uses to write from.\n   The length written by out() will be at most the window size.  Any non-zero\n   amount of input may be provided by in().\n\n     For convenience, inflateBack() can be provided input on the first call by\n   setting strm->next_in and strm->avail_in.  If that input is exhausted, then\n   in() will be called.  Therefore strm->next_in must be initialized before\n   calling inflateBack().  If strm->next_in is Z_NULL, then in() will be called\n   immediately for input.  If strm->next_in is not Z_NULL, then strm->avail_in\n   must also be initialized, and then if strm->avail_in is not zero, input will\n   initially be taken from strm->next_in[0 ..  strm->avail_in - 1].\n\n     The in_desc and out_desc parameters of inflateBack() is passed as the\n   first parameter of in() and out() respectively when they are called.  These\n   descriptors can be optionally used to pass any information that the caller-\n   supplied in() and out() functions need to do their job.\n\n     On return, inflateBack() will set strm->next_in and strm->avail_in to\n   pass back any unused input that was provided by the last in() call.  The\n   return values of inflateBack() can be Z_STREAM_END on success, Z_BUF_ERROR\n   if in() or out() returned an error, Z_DATA_ERROR if there was a format error\n   in the deflate stream (in which case strm->msg is set to indicate the nature\n   of the error), or Z_STREAM_ERROR if the stream was not properly initialized.\n   In the case of Z_BUF_ERROR, an input or output error can be distinguished\n   using strm->next_in which will be Z_NULL only if in() returned an error.  If\n   strm->next_in is not Z_NULL, then the Z_BUF_ERROR was due to out() returning\n   non-zero.  (in() will always be called before out(), so strm->next_in is\n   assured to be defined if out() returns non-zero.) Note that inflateBack()\n   cannot return Z_OK.\n*/\n\nZEXTERN int ZEXPORT inflateBackEnd OF((z_streamp strm));\n/*\n     All memory allocated by inflateBackInit() is freed.\n\n     inflateBackEnd() returns Z_OK on success, or Z_STREAM_ERROR if the stream\n   state was inconsistent.\n*/\n\nZEXTERN uLong ZEXPORT zlibCompileFlags OF((void));\n/* Return flags indicating compile-time options.\n\n    Type sizes, two bits each, 00 = 16 bits, 01 = 32, 10 = 64, 11 = other:\n     1.0: size of uInt\n     3.2: size of uLong\n     5.4: size of voidpf (pointer)\n     7.6: size of z_off_t\n\n    Compiler, assembler, and debug options:\n     8: DEBUG\n     9: ASMV or ASMINF -- use ASM code\n     10: ZLIB_WINAPI -- exported functions use the WINAPI calling convention\n     11: 0 (reserved)\n\n    One-time table building (smaller code, but not thread-safe if true):\n     12: BUILDFIXED -- build static block decoding tables when needed\n     13: DYNAMIC_CRC_TABLE -- build CRC calculation tables when needed\n     14,15: 0 (reserved)\n\n    Library content (indicates missing functionality):\n     16: NO_GZCOMPRESS -- gz* functions cannot compress (to avoid linking\n                          deflate code when not needed)\n     17: NO_GZIP -- deflate can't write gzip streams, and inflate can't detect\n                    and decode gzip streams (to avoid linking crc code)\n     18-19: 0 (reserved)\n\n    Operation variations (changes in library functionality):\n     20: PKZIP_BUG_WORKAROUND -- slightly more permissive inflate\n     21: FASTEST -- deflate algorithm with only one, lowest compression level\n     22,23: 0 (reserved)\n\n    The sprintf variant used by gzprintf (zero is best):\n     24: 0 = vs*, 1 = s* -- 1 means limited to 20 arguments after the format\n     25: 0 = *nprintf, 1 = *printf -- 1 means gzprintf() not secure!\n     26: 0 = returns value, 1 = void -- 1 means inferred string length returned\n\n    Remainder:\n     27-31: 0 (reserved)\n */\n\n#ifndef Z_SOLO\n\n                        /* utility functions */\n\n/*\n     The following utility functions are implemented on top of the basic\n   stream-oriented functions.  To simplify the interface, some default options\n   are assumed (compression level and memory usage, standard memory allocation\n   functions).  The source code of these utility functions can be modified if\n   you need special options.\n*/\n\nZEXTERN int ZEXPORT compress OF((Bytef *dest,   uLongf *destLen,\n                                 const Bytef *source, uLong sourceLen));\n/*\n     Compresses the source buffer into the destination buffer.  sourceLen is\n   the byte length of the source buffer.  Upon entry, destLen is the total size\n   of the destination buffer, which must be at least the value returned by\n   compressBound(sourceLen).  Upon exit, destLen is the actual size of the\n   compressed buffer.\n\n     compress returns Z_OK if success, Z_MEM_ERROR if there was not\n   enough memory, Z_BUF_ERROR if there was not enough room in the output\n   buffer.\n*/\n\nZEXTERN int ZEXPORT compress2 OF((Bytef *dest,   uLongf *destLen,\n                                  const Bytef *source, uLong sourceLen,\n                                  int level));\n/*\n     Compresses the source buffer into the destination buffer.  The level\n   parameter has the same meaning as in deflateInit.  sourceLen is the byte\n   length of the source buffer.  Upon entry, destLen is the total size of the\n   destination buffer, which must be at least the value returned by\n   compressBound(sourceLen).  Upon exit, destLen is the actual size of the\n   compressed buffer.\n\n     compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough\n   memory, Z_BUF_ERROR if there was not enough room in the output buffer,\n   Z_STREAM_ERROR if the level parameter is invalid.\n*/\n\nZEXTERN uLong ZEXPORT compressBound OF((uLong sourceLen));\n/*\n     compressBound() returns an upper bound on the compressed size after\n   compress() or compress2() on sourceLen bytes.  It would be used before a\n   compress() or compress2() call to allocate the destination buffer.\n*/\n\nZEXTERN int ZEXPORT uncompress OF((Bytef *dest,   uLongf *destLen,\n                                   const Bytef *source, uLong sourceLen));\n/*\n     Decompresses the source buffer into the destination buffer.  sourceLen is\n   the byte length of the source buffer.  Upon entry, destLen is the total size\n   of the destination buffer, which must be large enough to hold the entire\n   uncompressed data.  (The size of the uncompressed data must have been saved\n   previously by the compressor and transmitted to the decompressor by some\n   mechanism outside the scope of this compression library.) Upon exit, destLen\n   is the actual size of the uncompressed buffer.\n\n     uncompress returns Z_OK if success, Z_MEM_ERROR if there was not\n   enough memory, Z_BUF_ERROR if there was not enough room in the output\n   buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete.  In\n   the case where there is not enough room, uncompress() will fill the output\n   buffer with the uncompressed data up to that point.\n*/\n\n                        /* gzip file access functions */\n\n/*\n     This library supports reading and writing files in gzip (.gz) format with\n   an interface similar to that of stdio, using the functions that start with\n   \"gz\".  The gzip format is different from the zlib format.  gzip is a gzip\n   wrapper, documented in RFC 1952, wrapped around a deflate stream.\n*/\n\ntypedef struct gzFile_s *gzFile;    /* semi-opaque gzip file descriptor */\n\n/*\nZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode));\n\n     Opens a gzip (.gz) file for reading or writing.  The mode parameter is as\n   in fopen (\"rb\" or \"wb\") but can also include a compression level (\"wb9\") or\n   a strategy: 'f' for filtered data as in \"wb6f\", 'h' for Huffman-only\n   compression as in \"wb1h\", 'R' for run-length encoding as in \"wb1R\", or 'F'\n   for fixed code compression as in \"wb9F\".  (See the description of\n   deflateInit2 for more information about the strategy parameter.)  'T' will\n   request transparent writing or appending with no compression and not using\n   the gzip format.\n\n     \"a\" can be used instead of \"w\" to request that the gzip stream that will\n   be written be appended to the file.  \"+\" will result in an error, since\n   reading and writing to the same gzip file is not supported.\n\n     These functions, as well as gzip, will read and decode a sequence of gzip\n   streams in a file.  The append function of gzopen() can be used to create\n   such a file.  (Also see gzflush() for another way to do this.)  When\n   appending, gzopen does not test whether the file begins with a gzip stream,\n   nor does it look for the end of the gzip streams to begin appending.  gzopen\n   will simply append a gzip stream to the existing file.\n\n     gzopen can be used to read a file which is not in gzip format; in this\n   case gzread will directly read from the file without decompression.  When\n   reading, this will be detected automatically by looking for the magic two-\n   byte gzip header.\n\n     gzopen returns NULL if the file could not be opened, if there was\n   insufficient memory to allocate the gzFile state, or if an invalid mode was\n   specified (an 'r', 'w', or 'a' was not provided, or '+' was provided).\n   errno can be checked to determine if the reason gzopen failed was that the\n   file could not be opened.\n*/\n\nZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode));\n/*\n     gzdopen associates a gzFile with the file descriptor fd.  File descriptors\n   are obtained from calls like open, dup, creat, pipe or fileno (if the file\n   has been previously opened with fopen).  The mode parameter is as in gzopen.\n\n     The next call of gzclose on the returned gzFile will also close the file\n   descriptor fd, just like fclose(fdopen(fd, mode)) closes the file descriptor\n   fd.  If you want to keep fd open, use fd = dup(fd_keep); gz = gzdopen(fd,\n   mode);.  The duplicated descriptor should be saved to avoid a leak, since\n   gzdopen does not close fd if it fails.  If you are using fileno() to get the\n   file descriptor from a FILE *, then you will have to use dup() to avoid\n   double-close()ing the file descriptor.  Both gzclose() and fclose() will\n   close the associated file descriptor, so they need to have different file\n   descriptors.\n\n     gzdopen returns NULL if there was insufficient memory to allocate the\n   gzFile state, if an invalid mode was specified (an 'r', 'w', or 'a' was not\n   provided, or '+' was provided), or if fd is -1.  The file descriptor is not\n   used until the next gz* read, write, seek, or close operation, so gzdopen\n   will not detect if fd is invalid (unless fd is -1).\n*/\n\nZEXTERN int ZEXPORT gzbuffer OF((gzFile file, unsigned size));\n/*\n     Set the internal buffer size used by this library's functions.  The\n   default buffer size is 8192 bytes.  This function must be called after\n   gzopen() or gzdopen(), and before any other calls that read or write the\n   file.  The buffer memory allocation is always deferred to the first read or\n   write.  Two buffers are allocated, either both of the specified size when\n   writing, or one of the specified size and the other twice that size when\n   reading.  A larger buffer size of, for example, 64K or 128K bytes will\n   noticeably increase the speed of decompression (reading).\n\n     The new buffer size also affects the maximum length for gzprintf().\n\n     gzbuffer() returns 0 on success, or -1 on failure, such as being called\n   too late.\n*/\n\nZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy));\n/*\n     Dynamically update the compression level or strategy.  See the description\n   of deflateInit2 for the meaning of these parameters.\n\n     gzsetparams returns Z_OK if success, or Z_STREAM_ERROR if the file was not\n   opened for writing.\n*/\n\nZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len));\n/*\n     Reads the given number of uncompressed bytes from the compressed file.  If\n   the input file is not in gzip format, gzread copies the given number of\n   bytes into the buffer directly from the file.\n\n     After reaching the end of a gzip stream in the input, gzread will continue\n   to read, looking for another gzip stream.  Any number of gzip streams may be\n   concatenated in the input file, and will all be decompressed by gzread().\n   If something other than a gzip stream is encountered after a gzip stream,\n   that remaining trailing garbage is ignored (and no error is returned).\n\n     gzread can be used to read a gzip file that is being concurrently written.\n   Upon reaching the end of the input, gzread will return with the available\n   data.  If the error code returned by gzerror is Z_OK or Z_BUF_ERROR, then\n   gzclearerr can be used to clear the end of file indicator in order to permit\n   gzread to be tried again.  Z_OK indicates that a gzip stream was completed\n   on the last gzread.  Z_BUF_ERROR indicates that the input file ended in the\n   middle of a gzip stream.  Note that gzread does not return -1 in the event\n   of an incomplete gzip stream.  This error is deferred until gzclose(), which\n   will return Z_BUF_ERROR if the last gzread ended in the middle of a gzip\n   stream.  Alternatively, gzerror can be used before gzclose to detect this\n   case.\n\n     gzread returns the number of uncompressed bytes actually read, less than\n   len for end of file, or -1 for error.\n*/\n\nZEXTERN int ZEXPORT gzwrite OF((gzFile file,\n                                voidpc buf, unsigned len));\n/*\n     Writes the given number of uncompressed bytes into the compressed file.\n   gzwrite returns the number of uncompressed bytes written or 0 in case of\n   error.\n*/\n\nZEXTERN int ZEXPORTVA gzprintf Z_ARG((gzFile file, const char *format, ...));\n/*\n     Converts, formats, and writes the arguments to the compressed file under\n   control of the format string, as in fprintf.  gzprintf returns the number of\n   uncompressed bytes actually written, or 0 in case of error.  The number of\n   uncompressed bytes written is limited to 8191, or one less than the buffer\n   size given to gzbuffer().  The caller should assure that this limit is not\n   exceeded.  If it is exceeded, then gzprintf() will return an error (0) with\n   nothing written.  In this case, there may also be a buffer overflow with\n   unpredictable consequences, which is possible only if zlib was compiled with\n   the insecure functions sprintf() or vsprintf() because the secure snprintf()\n   or vsnprintf() functions were not available.  This can be determined using\n   zlibCompileFlags().\n*/\n\nZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s));\n/*\n     Writes the given null-terminated string to the compressed file, excluding\n   the terminating null character.\n\n     gzputs returns the number of characters written, or -1 in case of error.\n*/\n\nZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len));\n/*\n     Reads bytes from the compressed file until len-1 characters are read, or a\n   newline character is read and transferred to buf, or an end-of-file\n   condition is encountered.  If any characters are read or if len == 1, the\n   string is terminated with a null character.  If no characters are read due\n   to an end-of-file or len < 1, then the buffer is left untouched.\n\n     gzgets returns buf which is a null-terminated string, or it returns NULL\n   for end-of-file or in case of error.  If there was an error, the contents at\n   buf are indeterminate.\n*/\n\nZEXTERN int ZEXPORT gzputc OF((gzFile file, int c));\n/*\n     Writes c, converted to an unsigned char, into the compressed file.  gzputc\n   returns the value that was written, or -1 in case of error.\n*/\n\nZEXTERN int ZEXPORT gzgetc OF((gzFile file));\n/*\n     Reads one byte from the compressed file.  gzgetc returns this byte or -1\n   in case of end of file or error.  This is implemented as a macro for speed.\n   As such, it does not do all of the checking the other functions do.  I.e.\n   it does not check to see if file is NULL, nor whether the structure file\n   points to has been clobbered or not.\n*/\n\nZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file));\n/*\n     Push one character back onto the stream to be read as the first character\n   on the next read.  At least one character of push-back is allowed.\n   gzungetc() returns the character pushed, or -1 on failure.  gzungetc() will\n   fail if c is -1, and may fail if a character has been pushed but not read\n   yet.  If gzungetc is used immediately after gzopen or gzdopen, at least the\n   output buffer size of pushed characters is allowed.  (See gzbuffer above.)\n   The pushed character will be discarded if the stream is repositioned with\n   gzseek() or gzrewind().\n*/\n\nZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush));\n/*\n     Flushes all pending output into the compressed file.  The parameter flush\n   is as in the deflate() function.  The return value is the zlib error number\n   (see function gzerror below).  gzflush is only permitted when writing.\n\n     If the flush parameter is Z_FINISH, the remaining data is written and the\n   gzip stream is completed in the output.  If gzwrite() is called again, a new\n   gzip stream will be started in the output.  gzread() is able to read such\n   concatented gzip streams.\n\n     gzflush should be called only when strictly necessary because it will\n   degrade compression if called too often.\n*/\n\n/*\nZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file,\n                                   z_off_t offset, int whence));\n\n     Sets the starting position for the next gzread or gzwrite on the given\n   compressed file.  The offset represents a number of bytes in the\n   uncompressed data stream.  The whence parameter is defined as in lseek(2);\n   the value SEEK_END is not supported.\n\n     If the file is opened for reading, this function is emulated but can be\n   extremely slow.  If the file is opened for writing, only forward seeks are\n   supported; gzseek then compresses a sequence of zeroes up to the new\n   starting position.\n\n     gzseek returns the resulting offset location as measured in bytes from\n   the beginning of the uncompressed stream, or -1 in case of error, in\n   particular if the file is opened for writing and the new starting position\n   would be before the current position.\n*/\n\nZEXTERN int ZEXPORT    gzrewind OF((gzFile file));\n/*\n     Rewinds the given file. This function is supported only for reading.\n\n     gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET)\n*/\n\n/*\nZEXTERN z_off_t ZEXPORT    gztell OF((gzFile file));\n\n     Returns the starting position for the next gzread or gzwrite on the given\n   compressed file.  This position represents a number of bytes in the\n   uncompressed data stream, and is zero when starting, even if appending or\n   reading a gzip stream from the middle of a file using gzdopen().\n\n     gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR)\n*/\n\n/*\nZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile file));\n\n     Returns the current offset in the file being read or written.  This offset\n   includes the count of bytes that precede the gzip stream, for example when\n   appending or when using gzdopen() for reading.  When reading, the offset\n   does not include as yet unused buffered input.  This information can be used\n   for a progress indicator.  On error, gzoffset() returns -1.\n*/\n\nZEXTERN int ZEXPORT gzeof OF((gzFile file));\n/*\n     Returns true (1) if the end-of-file indicator has been set while reading,\n   false (0) otherwise.  Note that the end-of-file indicator is set only if the\n   read tried to go past the end of the input, but came up short.  Therefore,\n   just like feof(), gzeof() may return false even if there is no more data to\n   read, in the event that the last read request was for the exact number of\n   bytes remaining in the input file.  This will happen if the input file size\n   is an exact multiple of the buffer size.\n\n     If gzeof() returns true, then the read functions will return no more data,\n   unless the end-of-file indicator is reset by gzclearerr() and the input file\n   has grown since the previous end of file was detected.\n*/\n\nZEXTERN int ZEXPORT gzdirect OF((gzFile file));\n/*\n     Returns true (1) if file is being copied directly while reading, or false\n   (0) if file is a gzip stream being decompressed.\n\n     If the input file is empty, gzdirect() will return true, since the input\n   does not contain a gzip stream.\n\n     If gzdirect() is used immediately after gzopen() or gzdopen() it will\n   cause buffers to be allocated to allow reading the file to determine if it\n   is a gzip file.  Therefore if gzbuffer() is used, it should be called before\n   gzdirect().\n\n     When writing, gzdirect() returns true (1) if transparent writing was\n   requested (\"wT\" for the gzopen() mode), or false (0) otherwise.  (Note:\n   gzdirect() is not needed when writing.  Transparent writing must be\n   explicitly requested, so the application already knows the answer.  When\n   linking statically, using gzdirect() will include all of the zlib code for\n   gzip file reading and decompression, which may not be desired.)\n*/\n\nZEXTERN int ZEXPORT    gzclose OF((gzFile file));\n/*\n     Flushes all pending output if necessary, closes the compressed file and\n   deallocates the (de)compression state.  Note that once file is closed, you\n   cannot call gzerror with file, since its structures have been deallocated.\n   gzclose must not be called more than once on the same file, just as free\n   must not be called more than once on the same allocation.\n\n     gzclose will return Z_STREAM_ERROR if file is not valid, Z_ERRNO on a\n   file operation error, Z_MEM_ERROR if out of memory, Z_BUF_ERROR if the\n   last read ended in the middle of a gzip stream, or Z_OK on success.\n*/\n\nZEXTERN int ZEXPORT gzclose_r OF((gzFile file));\nZEXTERN int ZEXPORT gzclose_w OF((gzFile file));\n/*\n     Same as gzclose(), but gzclose_r() is only for use when reading, and\n   gzclose_w() is only for use when writing or appending.  The advantage to\n   using these instead of gzclose() is that they avoid linking in zlib\n   compression or decompression code that is not used when only reading or only\n   writing respectively.  If gzclose() is used, then both compression and\n   decompression code will be included the application when linking to a static\n   zlib library.\n*/\n\nZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum));\n/*\n     Returns the error message for the last error which occurred on the given\n   compressed file.  errnum is set to zlib error number.  If an error occurred\n   in the file system and not in the compression library, errnum is set to\n   Z_ERRNO and the application may consult errno to get the exact error code.\n\n     The application must not modify the returned string.  Future calls to\n   this function may invalidate the previously returned string.  If file is\n   closed, then the string previously returned by gzerror will no longer be\n   available.\n\n     gzerror() should be used to distinguish errors from end-of-file for those\n   functions above that do not distinguish those cases in their return values.\n*/\n\nZEXTERN void ZEXPORT gzclearerr OF((gzFile file));\n/*\n     Clears the error and end-of-file flags for file.  This is analogous to the\n   clearerr() function in stdio.  This is useful for continuing to read a gzip\n   file that is being written concurrently.\n*/\n\n#endif /* !Z_SOLO */\n\n                        /* checksum functions */\n\n/*\n     These functions are not related to compression but are exported\n   anyway because they might be useful in applications using the compression\n   library.\n*/\n\nZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len));\n/*\n     Update a running Adler-32 checksum with the bytes buf[0..len-1] and\n   return the updated checksum.  If buf is Z_NULL, this function returns the\n   required initial value for the checksum.\n\n     An Adler-32 checksum is almost as reliable as a CRC32 but can be computed\n   much faster.\n\n   Usage example:\n\n     uLong adler = adler32(0L, Z_NULL, 0);\n\n     while (read_buffer(buffer, length) != EOF) {\n       adler = adler32(adler, buffer, length);\n     }\n     if (adler != original_adler) error();\n*/\n\n/*\nZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2,\n                                          z_off_t len2));\n\n     Combine two Adler-32 checksums into one.  For two sequences of bytes, seq1\n   and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for\n   each, adler1 and adler2.  adler32_combine() returns the Adler-32 checksum of\n   seq1 and seq2 concatenated, requiring only adler1, adler2, and len2.  Note\n   that the z_off_t type (like off_t) is a signed integer.  If len2 is\n   negative, the result has no meaning or utility.\n*/\n\nZEXTERN uLong ZEXPORT crc32   OF((uLong crc, const Bytef *buf, uInt len));\n/*\n     Update a running CRC-32 with the bytes buf[0..len-1] and return the\n   updated CRC-32.  If buf is Z_NULL, this function returns the required\n   initial value for the for the crc.  Pre- and post-conditioning (one's\n   complement) is performed within this function so it shouldn't be done by the\n   application.\n\n   Usage example:\n\n     uLong crc = crc32(0L, Z_NULL, 0);\n\n     while (read_buffer(buffer, length) != EOF) {\n       crc = crc32(crc, buffer, length);\n     }\n     if (crc != original_crc) error();\n*/\n\n/*\nZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2));\n\n     Combine two CRC-32 check values into one.  For two sequences of bytes,\n   seq1 and seq2 with lengths len1 and len2, CRC-32 check values were\n   calculated for each, crc1 and crc2.  crc32_combine() returns the CRC-32\n   check value of seq1 and seq2 concatenated, requiring only crc1, crc2, and\n   len2.\n*/\n\n\n                        /* various hacks, don't look :) */\n\n/* deflateInit and inflateInit are macros to allow checking the zlib version\n * and the compiler's view of z_stream:\n */\nZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level,\n                                     const char *version, int stream_size));\nZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm,\n                                     const char *version, int stream_size));\nZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int  level, int  method,\n                                      int windowBits, int memLevel,\n                                      int strategy, const char *version,\n                                      int stream_size));\nZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int  windowBits,\n                                      const char *version, int stream_size));\nZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits,\n                                         unsigned char FAR *window,\n                                         const char *version,\n                                         int stream_size));\n#define deflateInit(strm, level) \\\n        deflateInit_((strm), (level), ZLIB_VERSION, (int)sizeof(z_stream))\n#define inflateInit(strm) \\\n        inflateInit_((strm), ZLIB_VERSION, (int)sizeof(z_stream))\n#define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \\\n        deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\\\n                      (strategy), ZLIB_VERSION, (int)sizeof(z_stream))\n#define inflateInit2(strm, windowBits) \\\n        inflateInit2_((strm), (windowBits), ZLIB_VERSION, \\\n                      (int)sizeof(z_stream))\n#define inflateBackInit(strm, windowBits, window) \\\n        inflateBackInit_((strm), (windowBits), (window), \\\n                      ZLIB_VERSION, (int)sizeof(z_stream))\n\n#ifndef Z_SOLO\n\n/* gzgetc() macro and its supporting function and exposed data structure.  Note\n * that the real internal state is much larger than the exposed structure.\n * This abbreviated structure exposes just enough for the gzgetc() macro.  The\n * user should not mess with these exposed elements, since their names or\n * behavior could change in the future, perhaps even capriciously.  They can\n * only be used by the gzgetc() macro.  You have been warned.\n */\nstruct gzFile_s {\n    unsigned have;\n    unsigned char *next;\n    z_off64_t pos;\n};\nZEXTERN int ZEXPORT gzgetc_ OF((gzFile file));\n#define gzgetc(g) \\\n    ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : gzgetc_(g))\n\n/* provide 64-bit offset functions if _LARGEFILE64_SOURCE defined, and/or\n * change the regular functions to 64 bits if _FILE_OFFSET_BITS is 64 (if\n * both are true, the application gets the *64 functions, and the regular\n * functions are changed to 64 bits) -- in case these are set on systems\n * without large file support, _LFS64_LARGEFILE must also be true\n */\n#if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0\n   ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *));\n   ZEXTERN z_off64_t ZEXPORT gzseek64 OF((gzFile, z_off64_t, int));\n   ZEXTERN z_off64_t ZEXPORT gztell64 OF((gzFile));\n   ZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile));\n   ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off64_t));\n   ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off64_t));\n#endif\n\n#if !defined(ZLIB_INTERNAL) && _FILE_OFFSET_BITS-0 == 64 && _LFS64_LARGEFILE-0\n#  ifdef Z_PREFIX_SET\n#    define z_gzopen z_gzopen64\n#    define z_gzseek z_gzseek64\n#    define z_gztell z_gztell64\n#    define z_gzoffset z_gzoffset64\n#    define z_adler32_combine z_adler32_combine64\n#    define z_crc32_combine z_crc32_combine64\n#  else\n#    define gzopen gzopen64\n#    define gzseek gzseek64\n#    define gztell gztell64\n#    define gzoffset gzoffset64\n#    define adler32_combine adler32_combine64\n#    define crc32_combine crc32_combine64\n#  endif\n#  ifndef _LARGEFILE64_SOURCE\n     ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *));\n     ZEXTERN z_off_t ZEXPORT gzseek64 OF((gzFile, z_off_t, int));\n     ZEXTERN z_off_t ZEXPORT gztell64 OF((gzFile));\n     ZEXTERN z_off_t ZEXPORT gzoffset64 OF((gzFile));\n     ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t));\n     ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t));\n#  endif\n#else\n   ZEXTERN gzFile ZEXPORT gzopen OF((const char *, const char *));\n   ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile, z_off_t, int));\n   ZEXTERN z_off_t ZEXPORT gztell OF((gzFile));\n   ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile));\n   ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t));\n   ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t));\n#endif\n\n#else /* Z_SOLO */\n\n   ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t));\n   ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t));\n\n#endif /* !Z_SOLO */\n\n/* hack for buggy compilers */\n#if !defined(ZUTIL_H) && !defined(NO_DUMMY_DECL)\n    struct internal_state {int dummy;};\n#endif\n\n/* undocumented functions */\nZEXTERN const char   * ZEXPORT zError           OF((int));\nZEXTERN int            ZEXPORT inflateSyncPoint OF((z_streamp));\nZEXTERN const uLongf * ZEXPORT get_crc_table    OF((void));\nZEXTERN int            ZEXPORT inflateUndermine OF((z_streamp, int));\nZEXTERN int            ZEXPORT inflateResetKeep OF((z_streamp));\nZEXTERN int            ZEXPORT deflateResetKeep OF((z_streamp));\n#ifndef Z_SOLO\n  ZEXTERN unsigned long  ZEXPORT gzflags          OF((void));\n#endif\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* ZLIB_H */\n"
  },
  {
    "path": "Projects/Tools/PNGAlphaPremultiplier/Native/Source/ZLib/zutil.c",
    "content": "/* zutil.c -- target dependent utility functions for the compression library\n * Copyright (C) 1995-2005, 2010, 2011 Jean-loup Gailly.\n * For conditions of distribution and use, see copyright notice in zlib.h\n */\n\n/* @(#) $Id$ */\n\n#include \"zutil.h\"\n\n#ifndef NO_DUMMY_DECL\nstruct internal_state      {int dummy;}; /* for buggy compilers */\n#endif\n\nconst char * const z_errmsg[10] = {\n\"need dictionary\",     /* Z_NEED_DICT       2  */\n\"stream end\",          /* Z_STREAM_END      1  */\n\"\",                    /* Z_OK              0  */\n\"file error\",          /* Z_ERRNO         (-1) */\n\"stream error\",        /* Z_STREAM_ERROR  (-2) */\n\"data error\",          /* Z_DATA_ERROR    (-3) */\n\"insufficient memory\", /* Z_MEM_ERROR     (-4) */\n\"buffer error\",        /* Z_BUF_ERROR     (-5) */\n\"incompatible version\",/* Z_VERSION_ERROR (-6) */\n\"\"};\n\n\nconst char * ZEXPORT zlibVersion()\n{\n    return ZLIB_VERSION;\n}\n\nuLong ZEXPORT zlibCompileFlags()\n{\n    uLong flags;\n\n    flags = 0;\n    switch ((int)(sizeof(uInt))) {\n    case 2:     break;\n    case 4:     flags += 1;     break;\n    case 8:     flags += 2;     break;\n    default:    flags += 3;\n    }\n    switch ((int)(sizeof(uLong))) {\n    case 2:     break;\n    case 4:     flags += 1 << 2;        break;\n    case 8:     flags += 2 << 2;        break;\n    default:    flags += 3 << 2;\n    }\n    switch ((int)(sizeof(voidpf))) {\n    case 2:     break;\n    case 4:     flags += 1 << 4;        break;\n    case 8:     flags += 2 << 4;        break;\n    default:    flags += 3 << 4;\n    }\n    switch ((int)(sizeof(z_off_t))) {\n    case 2:     break;\n    case 4:     flags += 1 << 6;        break;\n    case 8:     flags += 2 << 6;        break;\n    default:    flags += 3 << 6;\n    }\n#ifdef DEBUG\n    flags += 1 << 8;\n#endif\n#if defined(ASMV) || defined(ASMINF)\n    flags += 1 << 9;\n#endif\n#ifdef ZLIB_WINAPI\n    flags += 1 << 10;\n#endif\n#ifdef BUILDFIXED\n    flags += 1 << 12;\n#endif\n#ifdef DYNAMIC_CRC_TABLE\n    flags += 1 << 13;\n#endif\n#ifdef NO_GZCOMPRESS\n    flags += 1L << 16;\n#endif\n#ifdef NO_GZIP\n    flags += 1L << 17;\n#endif\n#ifdef PKZIP_BUG_WORKAROUND\n    flags += 1L << 20;\n#endif\n#ifdef FASTEST\n    flags += 1L << 21;\n#endif\n#ifdef Z_SOLO\n    return flags;\n#else\n    return flags + gzflags();\n#endif\n}\n\n#ifdef DEBUG\n\n#  ifndef verbose\n#    define verbose 0\n#  endif\nint ZLIB_INTERNAL z_verbose = verbose;\n\nvoid ZLIB_INTERNAL z_error (m)\n    char *m;\n{\n    fprintf(stderr, \"%s\\n\", m);\n    exit(1);\n}\n#endif\n\n/* exported to allow conversion of error code to string for compress() and\n * uncompress()\n */\nconst char * ZEXPORT zError(err)\n    int err;\n{\n    return ERR_MSG(err);\n}\n\n#if defined(_WIN32_WCE)\n    /* The Microsoft C Run-Time Library for Windows CE doesn't have\n     * errno.  We define it as a global variable to simplify porting.\n     * Its value is always 0 and should not be used.\n     */\n    int errno = 0;\n#endif\n\n#ifndef HAVE_MEMCPY\n\nvoid ZLIB_INTERNAL zmemcpy(dest, source, len)\n    Bytef* dest;\n    const Bytef* source;\n    uInt  len;\n{\n    if (len == 0) return;\n    do {\n        *dest++ = *source++; /* ??? to be unrolled */\n    } while (--len != 0);\n}\n\nint ZLIB_INTERNAL zmemcmp(s1, s2, len)\n    const Bytef* s1;\n    const Bytef* s2;\n    uInt  len;\n{\n    uInt j;\n\n    for (j = 0; j < len; j++) {\n        if (s1[j] != s2[j]) return 2*(s1[j] > s2[j])-1;\n    }\n    return 0;\n}\n\nvoid ZLIB_INTERNAL zmemzero(dest, len)\n    Bytef* dest;\n    uInt  len;\n{\n    if (len == 0) return;\n    do {\n        *dest++ = 0;  /* ??? to be unrolled */\n    } while (--len != 0);\n}\n#endif\n\n#ifndef Z_SOLO\n\n#ifdef SYS16BIT\n\n#ifdef __TURBOC__\n/* Turbo C in 16-bit mode */\n\n#  define MY_ZCALLOC\n\n/* Turbo C malloc() does not allow dynamic allocation of 64K bytes\n * and farmalloc(64K) returns a pointer with an offset of 8, so we\n * must fix the pointer. Warning: the pointer must be put back to its\n * original form in order to free it, use zcfree().\n */\n\n#define MAX_PTR 10\n/* 10*64K = 640K */\n\nlocal int next_ptr = 0;\n\ntypedef struct ptr_table_s {\n    voidpf org_ptr;\n    voidpf new_ptr;\n} ptr_table;\n\nlocal ptr_table table[MAX_PTR];\n/* This table is used to remember the original form of pointers\n * to large buffers (64K). Such pointers are normalized with a zero offset.\n * Since MSDOS is not a preemptive multitasking OS, this table is not\n * protected from concurrent access. This hack doesn't work anyway on\n * a protected system like OS/2. Use Microsoft C instead.\n */\n\nvoidpf ZLIB_INTERNAL zcalloc (voidpf opaque, unsigned items, unsigned size)\n{\n    voidpf buf = opaque; /* just to make some compilers happy */\n    ulg bsize = (ulg)items*size;\n\n    /* If we allocate less than 65520 bytes, we assume that farmalloc\n     * will return a usable pointer which doesn't have to be normalized.\n     */\n    if (bsize < 65520L) {\n        buf = farmalloc(bsize);\n        if (*(ush*)&buf != 0) return buf;\n    } else {\n        buf = farmalloc(bsize + 16L);\n    }\n    if (buf == NULL || next_ptr >= MAX_PTR) return NULL;\n    table[next_ptr].org_ptr = buf;\n\n    /* Normalize the pointer to seg:0 */\n    *((ush*)&buf+1) += ((ush)((uch*)buf-0) + 15) >> 4;\n    *(ush*)&buf = 0;\n    table[next_ptr++].new_ptr = buf;\n    return buf;\n}\n\nvoid ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr)\n{\n    int n;\n    if (*(ush*)&ptr != 0) { /* object < 64K */\n        farfree(ptr);\n        return;\n    }\n    /* Find the original pointer */\n    for (n = 0; n < next_ptr; n++) {\n        if (ptr != table[n].new_ptr) continue;\n\n        farfree(table[n].org_ptr);\n        while (++n < next_ptr) {\n            table[n-1] = table[n];\n        }\n        next_ptr--;\n        return;\n    }\n    ptr = opaque; /* just to make some compilers happy */\n    Assert(0, \"zcfree: ptr not found\");\n}\n\n#endif /* __TURBOC__ */\n\n\n#ifdef M_I86\n/* Microsoft C in 16-bit mode */\n\n#  define MY_ZCALLOC\n\n#if (!defined(_MSC_VER) || (_MSC_VER <= 600))\n#  define _halloc  halloc\n#  define _hfree   hfree\n#endif\n\nvoidpf ZLIB_INTERNAL zcalloc (voidpf opaque, uInt items, uInt size)\n{\n    if (opaque) opaque = 0; /* to make compiler happy */\n    return _halloc((long)items, size);\n}\n\nvoid ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr)\n{\n    if (opaque) opaque = 0; /* to make compiler happy */\n    _hfree(ptr);\n}\n\n#endif /* M_I86 */\n\n#endif /* SYS16BIT */\n\n\n#ifndef MY_ZCALLOC /* Any system without a special alloc function */\n\n#ifndef STDC\nextern voidp  malloc OF((uInt size));\nextern voidp  calloc OF((uInt items, uInt size));\nextern void   free   OF((voidpf ptr));\n#endif\n\nvoidpf ZLIB_INTERNAL zcalloc (opaque, items, size)\n    voidpf opaque;\n    unsigned items;\n    unsigned size;\n{\n    if (opaque) items += size - size; /* make compiler happy */\n    return sizeof(uInt) > 2 ? (voidpf)malloc(items * size) :\n                              (voidpf)calloc(items, size);\n}\n\nvoid ZLIB_INTERNAL zcfree (opaque, ptr)\n    voidpf opaque;\n    voidpf ptr;\n{\n    free(ptr);\n    if (opaque) return; /* make compiler happy */\n}\n\n#endif /* MY_ZCALLOC */\n\n#endif /* !Z_SOLO */\n"
  },
  {
    "path": "Projects/Tools/PNGAlphaPremultiplier/Native/Source/ZLib/zutil.h",
    "content": "/* zutil.h -- internal interface and configuration of the compression library\n * Copyright (C) 1995-2011 Jean-loup Gailly.\n * For conditions of distribution and use, see copyright notice in zlib.h\n */\n\n/* WARNING: this file should *not* be used by applications. It is\n   part of the implementation of the compression library and is\n   subject to change. Applications should only use zlib.h.\n */\n\n/* @(#) $Id$ */\n\n#ifndef ZUTIL_H\n#define ZUTIL_H\n\n#if ((__GNUC__-0) * 10 + __GNUC_MINOR__-0 >= 33) && !defined(NO_VIZ)\n#  define ZLIB_INTERNAL __attribute__((visibility (\"hidden\")))\n#else\n#  define ZLIB_INTERNAL\n#endif\n\n#include \"zlib.h\"\n\n#if defined(STDC) && !defined(Z_SOLO)\n#  if !(defined(_WIN32_WCE) && defined(_MSC_VER))\n#    include <stddef.h>\n#  endif\n#  include <string.h>\n#  include <stdlib.h>\n#endif\n\n#ifdef Z_SOLO\n   typedef long ptrdiff_t;  /* guess -- will be caught if guess is wrong */\n#endif\n\n#ifndef local\n#  define local static\n#endif\n/* compile with -Dlocal if your debugger can't find static symbols */\n\ntypedef unsigned char  uch;\ntypedef uch FAR uchf;\ntypedef unsigned short ush;\ntypedef ush FAR ushf;\ntypedef unsigned long  ulg;\n\nextern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */\n/* (size given to avoid silly warnings with Visual C++) */\n\n#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)]\n\n#define ERR_RETURN(strm,err) \\\n  return (strm->msg = (char*)ERR_MSG(err), (err))\n/* To be used only when the state is known to be valid */\n\n        /* common constants */\n\n#ifndef DEF_WBITS\n#  define DEF_WBITS MAX_WBITS\n#endif\n/* default windowBits for decompression. MAX_WBITS is for compression only */\n\n#if MAX_MEM_LEVEL >= 8\n#  define DEF_MEM_LEVEL 8\n#else\n#  define DEF_MEM_LEVEL  MAX_MEM_LEVEL\n#endif\n/* default memLevel */\n\n#define STORED_BLOCK 0\n#define STATIC_TREES 1\n#define DYN_TREES    2\n/* The three kinds of block type */\n\n#define MIN_MATCH  3\n#define MAX_MATCH  258\n/* The minimum and maximum match lengths */\n\n#define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */\n\n        /* target dependencies */\n\n#if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32))\n#  define OS_CODE  0x00\n#  ifndef Z_SOLO\n#    if defined(__TURBOC__) || defined(__BORLANDC__)\n#      if (__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__))\n         /* Allow compilation with ANSI keywords only enabled */\n         void _Cdecl farfree( void *block );\n         void *_Cdecl farmalloc( unsigned long nbytes );\n#      else\n#        include <alloc.h>\n#      endif\n#    else /* MSC or DJGPP */\n#      include <malloc.h>\n#    endif\n#  endif\n#endif\n\n#ifdef AMIGA\n#  define OS_CODE  0x01\n#endif\n\n#if defined(VAXC) || defined(VMS)\n#  define OS_CODE  0x02\n#  define F_OPEN(name, mode) \\\n     fopen((name), (mode), \"mbc=60\", \"ctx=stm\", \"rfm=fix\", \"mrs=512\")\n#endif\n\n#if defined(ATARI) || defined(atarist)\n#  define OS_CODE  0x05\n#endif\n\n#ifdef OS2\n#  define OS_CODE  0x06\n#  if defined(M_I86) && !defined(Z_SOLO)\n#    include <malloc.h>\n#  endif\n#endif\n\n#if defined(MACOS) || defined(TARGET_OS_MAC)\n#  define OS_CODE  0x07\n#  ifndef Z_SOLO\n#    if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os\n#      include <unix.h> /* for fdopen */\n#    else\n#      ifndef fdopen\n#        define fdopen(fd,mode) NULL /* No fdopen() */\n#      endif\n#    endif\n#  endif\n#endif\n\n#ifdef TOPS20\n#  define OS_CODE  0x0a\n#endif\n\n#ifdef WIN32\n#  ifndef __CYGWIN__  /* Cygwin is Unix, not Win32 */\n#    define OS_CODE  0x0b\n#  endif\n#endif\n\n#ifdef __50SERIES /* Prime/PRIMOS */\n#  define OS_CODE  0x0f\n#endif\n\n#if defined(_BEOS_) || defined(RISCOS)\n#  define fdopen(fd,mode) NULL /* No fdopen() */\n#endif\n\n#if (defined(_MSC_VER) && (_MSC_VER > 600)) && !defined __INTERIX\n#  if defined(_WIN32_WCE)\n#    define fdopen(fd,mode) NULL /* No fdopen() */\n#    ifndef _PTRDIFF_T_DEFINED\n       typedef int ptrdiff_t;\n#      define _PTRDIFF_T_DEFINED\n#    endif\n#  else\n#    define fdopen(fd,type)  _fdopen(fd,type)\n#  endif\n#endif\n\n#if defined(__BORLANDC__) && !defined(MSDOS)\n  #pragma warn -8004\n  #pragma warn -8008\n  #pragma warn -8066\n#endif\n\n/* provide prototypes for these when building zlib without LFS */\n#if !defined(_WIN32) && (!defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0)\n    ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t));\n    ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t));\n#endif\n\n        /* common defaults */\n\n#ifndef OS_CODE\n#  define OS_CODE  0x03  /* assume Unix */\n#endif\n\n#ifndef F_OPEN\n#  define F_OPEN(name, mode) fopen((name), (mode))\n#endif\n\n         /* functions */\n\n#if defined(pyr) || defined(Z_SOLO)\n#  define NO_MEMCPY\n#endif\n#if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__)\n /* Use our own functions for small and medium model with MSC <= 5.0.\n  * You may have to use the same strategy for Borland C (untested).\n  * The __SC__ check is for Symantec.\n  */\n#  define NO_MEMCPY\n#endif\n#if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY)\n#  define HAVE_MEMCPY\n#endif\n#ifdef HAVE_MEMCPY\n#  ifdef SMALL_MEDIUM /* MSDOS small or medium model */\n#    define zmemcpy _fmemcpy\n#    define zmemcmp _fmemcmp\n#    define zmemzero(dest, len) _fmemset(dest, 0, len)\n#  else\n#    define zmemcpy memcpy\n#    define zmemcmp memcmp\n#    define zmemzero(dest, len) memset(dest, 0, len)\n#  endif\n#else\n   void ZLIB_INTERNAL zmemcpy OF((Bytef* dest, const Bytef* source, uInt len));\n   int ZLIB_INTERNAL zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len));\n   void ZLIB_INTERNAL zmemzero OF((Bytef* dest, uInt len));\n#endif\n\n/* Diagnostic functions */\n#ifdef DEBUG\n#  include <stdio.h>\n   extern int ZLIB_INTERNAL z_verbose;\n   extern void ZLIB_INTERNAL z_error OF((char *m));\n#  define Assert(cond,msg) {if(!(cond)) z_error(msg);}\n#  define Trace(x) {if (z_verbose>=0) fprintf x ;}\n#  define Tracev(x) {if (z_verbose>0) fprintf x ;}\n#  define Tracevv(x) {if (z_verbose>1) fprintf x ;}\n#  define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;}\n#  define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;}\n#else\n#  define Assert(cond,msg)\n#  define Trace(x)\n#  define Tracev(x)\n#  define Tracevv(x)\n#  define Tracec(c,x)\n#  define Tracecv(c,x)\n#endif\n\n#ifndef Z_SOLO\n   voidpf ZLIB_INTERNAL zcalloc OF((voidpf opaque, unsigned items,\n                                    unsigned size));\n   void ZLIB_INTERNAL zcfree  OF((voidpf opaque, voidpf ptr));\n#endif\n\n#define ZALLOC(strm, items, size) \\\n           (*((strm)->zalloc))((strm)->opaque, (items), (size))\n#define ZFREE(strm, addr)  (*((strm)->zfree))((strm)->opaque, (voidpf)(addr))\n#define TRY_FREE(s, p) {if (p) ZFREE(s, p);}\n\n#endif /* ZUTIL_H */\n"
  },
  {
    "path": "Projects/Tools/PNGAlphaPremultiplier/src/com/chilliworks/chillisource/pngalphapremultiplier/Main.java",
    "content": "/**\n * Main.java\n * ChilliSource\n * Created by Ian Copland on 30/01/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.pngalphapremultiplier;\n\nimport com.chilliworks.chillisource.coreutils.Logging;\nimport com.chilliworks.chillisource.coreutils.Logging.LoggingLevel;\n\npublic class Main \n{\n\t//------------------------------------------------------\n\t/// Main\n\t///\n\t/// The entry point for the application. This processes\n\t/// the inputs and relays them onto the rest of the\n\t/// application.\n\t///\n\t/// @param The array of input strings.\n\t//------------------------------------------------------\n\tpublic static void main(String[] inastrArgs) throws Exception \n\t{\t\n\t\t//setup the logger.\n\t\tString[] arguments = Logging.start(inastrArgs);\n\t\t\n\t\t//check the number of arguments make sense.\n\t\tif (arguments.length == 0)\n\t\t{\n\t\t\tPrintHelpText();\n\t\t\treturn;\n\t\t}\n\t\t\n\t\t//gather up commands\n\t\tPremultiplicationOptions options = new PremultiplicationOptions();\n\t\tfor (int i = 0; i < arguments.length; ++i)\n\t\t{\n\t\t\t//Input param\n\t\t\tif (arguments[i].equalsIgnoreCase(\"-i\") == true || arguments[i].equalsIgnoreCase(\"--input\") == true)\n\t\t\t{\n\t\t\t\tif (i+1 < arguments.length)\n\t\t\t\t\toptions.strInputFilename = arguments[i+1];\n\t\t\t\telse\n\t\t\t\t\tLogging.logFatal(\"No input file provided!\");\n\t\t\t\ti++;\n\t\t\t}\n\t\t\t\n\t\t\t//output param\n\t\t\telse if (arguments[i].equalsIgnoreCase(\"-o\") == true || arguments[i].equalsIgnoreCase(\"--output\") == true)\n\t\t\t{\n\t\t\t\tif (i+1 < arguments.length)\n\t\t\t\t\toptions.strOutputFilename = arguments[i+1];\n\t\t\t\telse\n\t\t\t\t\tLogging.logFatal(\"No output file provided!\");\n\t\t\t\ti++;\n\t\t\t}\n\t\t\t\n\t\t\t//help param\n\t\t\telse if (arguments[i].equalsIgnoreCase(\"-h\") == true || arguments[i].equalsIgnoreCase(\"--help\") == true)\n\t\t\t{\n\t\t\t\tPrintHelpText();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t\n\t\t\t//failure\n\t\t\telse\n\t\t\t{\n\t\t\t\tLogging.logFatal(\"Invalid argument found: \" + arguments[i]);\n\t\t\t}\n\t\t}\n\t\t\n\t\t//confirm that the params are valid.\n\t\tif (options.strInputFilename.length() == 0)\n\t\t\tLogging.logFatal(\"No input filename provided.\");\n\t\tif (options.strOutputFilename.length() == 0)\n\t\t\tLogging.logFatal(\"No output filename provided.\");\n\t\t\n\t\t//now that the options have been gathered, perform the png pre-multiplying!\n\t\tPngPremultiplier.Premultiply(options);\n\n\t\tLogging.finish();\n\t}\n\t//------------------------------------------------------\n\t/// Print Help Text\n\t///\n\t/// Prints out instructions on how to use this tool.\n\t//------------------------------------------------------\n\tprivate static void PrintHelpText()\n\t{\n\t\tLogging.setLoggingLevel(LoggingLevel.VERBOSE);\n\t\tLogging.logVerbose(\"Usage: java -jar PNGAlphaPremultiplier.jar --input <filepath> --output <filepath> [--logginglevel <level>] [--displayerrors <errordisplay>] [--help]\");\n\t\tLogging.logVerbose(\"Parameters:\");\n\t\tLogging.logVerbose(\" --input(-i): The input filepath.\");\n\t\tLogging.logVerbose(\" --output(-o): The output filepath.\");\n\t\tLogging.logVerbose(\" \" + Logging.PARAM_LOGGING_LEVEL + \"(\" + Logging.SHORT_PARAM_LOGGING_LEVEL + \"): Sets the logging level.\");\n\t\tLogging.logVerbose(\" --help(-h): Displays this help message.\");\n\t\tLogging.logVerbose(\"Logging Levels:\");\n\t\tLogging.logVerbose(\" \" + Logging.LOGGING_LEVEL_NONE + \": No logging.\");\n\t\tLogging.logVerbose(\" \" + Logging.LOGGING_LEVEL_FATAL + \": Only log fatal errors.\");\n\t\tLogging.logVerbose(\" \" + Logging.LOGGING_LEVEL_ERROR + \": Only log errors.\");\n\t\tLogging.logVerbose(\" \" + Logging.LOGGING_LEVEL_WARNING + \": Log errors and warnings.\");\n\t\tLogging.logVerbose(\" \" + Logging.LOGGING_LEVEL_VERBOSE + \": Log all messages.\");\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/PNGAlphaPremultiplier/src/com/chilliworks/chillisource/pngalphapremultiplier/PngPremultiplier.java",
    "content": "/**\n * PngPremultiplier.java\n * ChilliSource\n * Created by Ian Copland on 30/01/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.pngalphapremultiplier;\n\nimport java.io.BufferedReader;\nimport java.io.File;\nimport java.io.InputStream;\nimport java.io.InputStreamReader;\nimport java.net.URISyntaxException;\nimport java.security.CodeSource;\nimport java.util.LinkedList;\n\nimport com.chilliworks.chillisource.coreutils.Logging;\nimport com.chilliworks.chillisource.coreutils.StringUtils;\n\npublic class PngPremultiplier \n{\n\t//-------------------------------------------------\n\t/// Premultiply\n\t///\n\t/// This uses the native tool to pre-multiply the\n\t/// pngs and keeps caches the png if requested.\n\t///\n\t/// @param the pre-multiplication options.\n\t//-------------------------------------------------\n\tpublic static void Premultiply(PremultiplicationOptions insOptions)\n\t{\n\t\ttry\n\t\t{\t\n\t\t\tString strInput = StringUtils.standardiseFilePath(insOptions.strInputFilename);\n\t\t\tString strOutput = StringUtils.standardiseFilePath(insOptions.strOutputFilename);\n\t\t\t\n\t\t\t//build the command list\n\t\t\tLinkedList<String> astrCommands = new LinkedList<String>();\n\t\t\tastrCommands.add(GetExecutableName());\n\t\t\tastrCommands.add(\"--input\");\n\t\t\tastrCommands.add(strInput);\n\t\t\tastrCommands.add(\"--output\");\n\t\t\tastrCommands.add(strOutput);\n\t\t\t\n\t\t\t//add the logging level to the command list\n\t\t\tswitch (Logging.getLoggingLevel())\n\t\t\t{\n\t\t\tcase NONE:\n\t\t\t\tastrCommands.add(\"--logginglevel\");\n\t\t\t\tastrCommands.add(\"none\");\n\t\t\t\tbreak;\n\t\t\tcase FATAL:\n\t\t\t\tastrCommands.add(\"--logginglevel\");\n\t\t\t\tastrCommands.add(\"fatal\");\n\t\t\t\tbreak;\n\t\t\tcase ERROR:\n\t\t\t\tastrCommands.add(\"--logginglevel\");\n\t\t\t\tastrCommands.add(\"error\");\n\t\t\t\tbreak;\n\t\t\tcase WARNING:\n\t\t\t\tastrCommands.add(\"--logginglevel\");\n\t\t\t\tastrCommands.add(\"warning\");\n\t\t\t\tbreak;\n\t\t\tcase VERBOSE:\n\t\t\t\tastrCommands.add(\"--logginglevel\");\n\t\t\t\tastrCommands.add(\"warning\");\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t\n\t\t\tLogging.logVerbose(\"Premultiplying \" + strInput);\n\t\t\t\n\t\t\t//run the application\n\t\t\tfinal Process process = new ProcessBuilder(astrCommands).start();\n\t\n\t\t\t//create runnables for polling the error streams.\n\t\t\tRunnable errorRunnable = new Runnable()\n\t\t\t{\n\t\t\t\t@Override public void run() \n\t\t\t\t{\n\t\t\t\t\tReadErrorStream(process);\n\t\t\t\t}\n\t\t\t};\n\t\t\t\n\t\t\t//start these runnables.\n\t\t\tThread errorThread = new Thread(errorRunnable);\n\t\t\terrorThread.start();\n\t\t\t\n\t\t\t//wait for the threads to finish\n\t\t\terrorThread.join();\n\t\t\t\n\t\t\t//end the process\n\t\t\tprocess.destroy();\n\t\t}\n\t\tcatch (Exception e)\n\t\t{\n\t\t\tLogging.logFatal(\"Exception occurred in Premultiply(): \\n\" + StringUtils.convertExceptionToString(e));\n\t\t}\n\t}\n\t/**\n\t * Get the directory path that contains this jar file\n\t * \n\t * @author S Downie\n\t * \n\t * @return Directory path to jar folder\n\t */\n\tprivate static String getJarDirectoryPath()\n\t{\n\t\tString jarDir = \"\";\n\t\t\n\t\tCodeSource codeSource = PngPremultiplier.class.getProtectionDomain().getCodeSource();\n\t\tFile jarFile;\n\t\ttry \n\t\t{\n\t\t\tjarFile = new File(codeSource.getLocation().toURI().getPath());\n\t\t\tjarDir = jarFile.getParentFile().getPath() + File.separator;\n\t\t} \n\t\tcatch (URISyntaxException e) \n\t\t{\n\t\t\te.printStackTrace();\n\t\t}\n\t\t \n\t\treturn jarDir;\n\t}\n\t//------------------------------------------------------\n\t/// GetExecutableName\n\t///\n\t/// @return returns the name of the executable that\n\t/// should be used for this platform.\n\t//------------------------------------------------------\n\tprivate static String GetExecutableName()\n\t{\n\t\tString strExecutableName = \"\";\n\t\t\n\t\ttry\n\t\t{\n\t\t\t//get the path to the jar\n\t\t\tString strPathToHere = getJarDirectoryPath();\n\t\t\t\n\t\t\t//get which version of the executable should be used.\n\t\t\tString strOS = System.getProperty(\"os.name\");\n\t\t\t\n\t\t\tif (strOS.startsWith(\"Windows\") == true)\n\t\t\t\tstrExecutableName = strPathToHere + \"PNGAlphaPremultiplier\\\\PNGAlphaPremultiplierWindows.exe\";\n\t\t\telse if (strOS.startsWith(\"Mac\") == true)\n\t\t\t\tstrExecutableName = strPathToHere + \"PNGAlphaPremultiplier/PNGAlphaPremultiplierOSX\";\n\t\t\telse if (strOS.startsWith(\"Linux\") == true)\n\t\t\t\tstrExecutableName = strPathToHere + \"PNGAlphaPremultiplier/PNGAlphaPremultiplierLinux\";\n\t\t\telse\n\t\t\t\tLogging.logFatal(\"This platform is not supported!\");\n\t\t}\n\t\tcatch (Exception e)\n\t\t{\n\t\t\tLogging.logFatal(\"Exception occurred in GetExecutableName(): \\n\" + StringUtils.convertExceptionToString(e));\n\t\t}\n\t\t\n\t\treturn strExecutableName;\n\t}\n\t//------------------------------------------------------\n\t/// Read Error Stream\n\t///\n\t/// reads and outputs the processes error stream.\n\t///\n\t/// @param the process that owns the error stream.\n\t//------------------------------------------------------\n\tprivate static void ReadErrorStream(Process inProcess)\n\t{\n\t\ttry\n\t\t{\n\t\t\tInputStream errorStream = inProcess.getErrorStream();\n\t\t\tInputStreamReader errorStreamReader = new InputStreamReader(errorStream);\n\t\t\tBufferedReader bufferedErrorReader = new BufferedReader(errorStreamReader);\n\t\t\t\n\t\t\tString errorLine = null;\n\t\t\tdo\n\t\t\t{\n\t\t\t\terrorLine = bufferedErrorReader.readLine();\n\t\t\t\tif (errorLine != null)\n\t\t\t\t{\n\t\t\t\t\tif (errorLine.startsWith(\"WARNING:\") == true)\n\t\t\t\t\t{\n\t\t\t\t\t\tLogging.logWarning(errorLine.substring(8));\n\t\t\t\t\t}\n\t\t\t\t\telse if (errorLine.startsWith(\"ERROR:\") == true)\n\t\t\t\t\t{\n\t\t\t\t\t\tLogging.logError(errorLine.substring(6));\n\t\t\t\t\t}\n\t\t\t\t\telse if (errorLine.startsWith(\"FATAL:\") == true)\n\t\t\t\t\t{\n\t\t\t\t\t\tLogging.logFatal(errorLine.substring(6));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\twhile (errorLine != null);\n\t\t}\n\t\tcatch (Exception e)\n\t\t{\n\t\t\tLogging.logFatal(\"Something has gone wrong while reading the error stream!\\n\" + StringUtils.convertExceptionToString(e));\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/PNGAlphaPremultiplier/src/com/chilliworks/chillisource/pngalphapremultiplier/PremultiplicationOptions.java",
    "content": "/**\n * PremultiplicationOptions.java\n * ChilliSource\n * Created by Ian Copland on 30/01/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.pngalphapremultiplier;\n\npublic class PremultiplicationOptions \n{\n\tpublic String strInputFilename;\n\tpublic String strOutputFilename;\n\t\n\t//---------------------------------------------\n\t/// Constructor\n\t//---------------------------------------------\n\tpublic PremultiplicationOptions()\n\t{\n\t\tstrInputFilename = new String();\n\t\tstrOutputFilename = new String();\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/PNGToCSImage/.classpath",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<classpath>\n\t<classpathentry kind=\"src\" path=\"src\"/>\n\t<classpathentry kind=\"con\" path=\"org.eclipse.jdt.launching.JRE_CONTAINER\"/>\n\t<classpathentry combineaccessrules=\"false\" kind=\"src\" path=\"/CoreUtils\"/>\n\t<classpathentry kind=\"output\" path=\"bin\"/>\n</classpath>\n"
  },
  {
    "path": "Projects/Tools/PNGToCSImage/.gitignore",
    "content": "bin\n\n"
  },
  {
    "path": "Projects/Tools/PNGToCSImage/.project",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<projectDescription>\n\t<name>PNGToCSImage</name>\n\t<comment></comment>\n\t<projects>\n\t</projects>\n\t<buildSpec>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.jdt.core.javabuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t</buildSpec>\n\t<natures>\n\t\t<nature>org.eclipse.jdt.core.javanature</nature>\n\t</natures>\n</projectDescription>\n"
  },
  {
    "path": "Projects/Tools/PNGToCSImage/Manifest/Manifest.txt",
    "content": "Manifest-Version: 1.0\r\nMain-Class: com.chillisource.pngtocsimage.Main\r\n\r\n"
  },
  {
    "path": "Projects/Tools/PNGToCSImage/src/com/chilliworks/chillisource/pngtocsimage/ImageContainer.java",
    "content": "/**\n * ImageContainer.java\n * ChilliSource\n * Created by Ian Copland on 30/10/2012\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2012 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.pngtocsimage;\n\n//========================================================================\n/// ImageContainer\n///\n/// Holds the loaded image data. All data is converted to RGBA format.\n//========================================================================\npublic class ImageContainer\n{\n\tpublic int[] adwImageData = null;\n\tpublic int dwWidth = 0;\n\tpublic int dwHeight = 0;\n\tpublic int dwType = 0;\n\tpublic boolean bHasAlpha = false;\n}\n"
  },
  {
    "path": "Projects/Tools/PNGToCSImage/src/com/chilliworks/chillisource/pngtocsimage/Main.java",
    "content": "/**\n * Main.java\n * ChilliSource\n * Created by Ian Copland on 26/10/2012\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2012 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.pngtocsimage;\n\nimport com.chilliworks.chillisource.coreutils.CSException;\nimport com.chilliworks.chillisource.coreutils.Logging;\nimport com.chilliworks.chillisource.coreutils.Logging.LoggingLevel;\nimport com.chilliworks.chillisource.coreutils.StringUtils;\n\npublic class Main \n{\n\t//------------------------------------------------------\n\t/// Main\n\t///\n\t/// The entry point for the application. This processes\n\t/// the inputs and relays them onto the rest of the\n\t/// application.\n\t///\n\t/// @param The array of input strings.\n\t//------------------------------------------------------\n\tpublic static void main(String inastrArgs[]) throws Exception \n\t{\t\n\t\t//setup the logger.\n\t\tString[] arguments = Logging.start(inastrArgs);\n\t\t\n\t\t//check the number of arguments make sense.\n\t\tif(arguments.length < 2)\n\t\t{\n\t\t\tPrintHelpText();\n\t\t\treturn;\n\t\t}\n\t\t\n\t\t//Collect params\n\t\tPNGToCSImageOptions options = new PNGToCSImageOptions();\n\t\tfor(int i = 0; i < arguments.length; ++i)\n\t\t{\n\t\t\t//input\n\t\t\tif(arguments[i].equalsIgnoreCase(\"-i\") == true || arguments[i].equalsIgnoreCase(\"--input\") == true)\n\t\t\t{\n\t\t\t\tif (i + 1 < arguments.length)\n\t\t\t\t\toptions.strInputFilename = arguments[i + 1];\n\t\t\t\telse\n\t\t\t\t\tLogging.logFatal(\"No input path provided!\");\n\t\t\t\ti++;\n\t\t\t}\n\t\t\t\n\t\t\t//output\n\t\t\telse if(arguments[i].equalsIgnoreCase(\"-o\") == true || arguments[i].equalsIgnoreCase(\"--output\") == true)\n\t\t\t{\n\t\t\t\tif (i + 1 < arguments.length)\n\t\t\t\t\toptions.strOutputFilename = arguments[i + 1];\n\t\t\t\telse\n\t\t\t\t\tLogging.logFatal(\"No output file provided!\");\n\t\t\t\ti++;\n\t\t\t}\n\t\t\t\n\t\t\t//convert\n\t\t\telse if(arguments[i].equalsIgnoreCase(\"-ct\") == true || arguments[i].equalsIgnoreCase(\"--convert\") == true)\n\t\t\t{\n\t\t\t\tif (i + 1 < arguments.length)\n\t\t\t\t\toptions.eConversionType = PNGToCSImage.convertStringToConversionFormat(arguments[i + 1]);\n\t\t\t\telse\n\t\t\t\t\tLogging.logFatal(\"No conversion type provided!\");\n\t\t\t\ti++;\n\t\t\t}\n\t\t\t\n\t\t\t//convertalpha\n\t\t\telse if(arguments[i].equalsIgnoreCase(\"-cta\") == true || arguments[i].equalsIgnoreCase(\"--convertalpha\") == true)\n\t\t\t{\n\t\t\t\tif (i + 1 < arguments.length)\n\t\t\t\t\toptions.eConversionAlphaType = PNGToCSImage.convertStringToConversionFormat(arguments[i + 1]);\n\t\t\t\telse\n\t\t\t\t\tLogging.logFatal(\"No conversion type provided!\");\n\t\t\t\ti++;\n\t\t\t}\n\t\t\t\n\t\t\t//convertnoalpha\n\t\t\telse if(arguments[i].equalsIgnoreCase(\"-ctna\") == true || arguments[i].equalsIgnoreCase(\"--convertnoalpha\") == true)\n\t\t\t{\n\t\t\t\tif (i + 1 < arguments.length)\n\t\t\t\t\toptions.eConversionNoAlphaType = PNGToCSImage.convertStringToConversionFormat(arguments[i + 1]);\n\t\t\t\telse\n\t\t\t\t\tLogging.logFatal(\"No conversion type provided!\");\n\t\t\t\ti++;\n\t\t\t}\n\t\t\t\n\t\t\t//compression\n\t\t\telse if(arguments[i].equalsIgnoreCase(\"-cn\") == true || arguments[i].equalsIgnoreCase(\"--compression\") == true)\n\t\t\t{\n\t\t\t\tif (i + 1 < arguments.length)\n\t\t\t\t\toptions.eCompressionType = PNGToCSImage.convertStringToCompressionFormat(arguments[i + 1]);\n\t\t\t\telse\n\t\t\t\t\tLogging.logFatal(\"No compression type provided!\");\n\t\t\t\ti++;\n\t\t\t}\n\t\t\t\n\t\t\t//disable premultiplied alpha\n\t\t\telse if(arguments[i].equalsIgnoreCase(\"-dpa\") == true || arguments[i].equalsIgnoreCase(\"--disablepremultipliedalpha\") == true)\n\t\t\t{\n\t\t\t\toptions.bPremultiply = false;\n\t\t\t}\n\t\t\t\n\t\t\t//dither\n\t\t\telse if(arguments[i].equalsIgnoreCase(\"-d\") == true || arguments[i].equalsIgnoreCase(\"--dither\") == true)\n\t\t\t{\n\t\t\t\toptions.bDither = true;\n\t\t\t}\n\t\t\t\n\t\t\t//help\n\t\t\telse if(arguments[i].equalsIgnoreCase(\"-h\") == true || arguments[i].equalsIgnoreCase(\"--help\") == true)\n\t\t\t{\n\t\t\t\tPrintHelpText();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t\n\t\t\t//failure\n\t\t\telse\n\t\t\t{\n\t\t\t\tLogging.logFatal(\"Invalid argument found: \" + arguments[i]);\n\t\t\t}\n\t\t}\n\t\t\n\t\t// Confirm that the paramaters are valid.\n\t\tif(options.strInputFilename.equals(\"\"))\n\t\t\tLogging.logFatal(\"No input path provided.\");\n\t\tif (options.strOutputFilename.equals(\"\"))\n\t\t\tLogging.logFatal(\"No output file provided.\");\n\t\t\n\t\ttry\n\t\t{\n\t\t\tPNGToCSImage.run(options);\n\t\t}\n\t\tcatch (CSException e)\n\t\t{\n\t\t\tLogging.logFatal(e.getMessage());\n\t\t}\n\t\tcatch (Exception e)\n\t\t{\n\t\t\tLogging.logFatal(StringUtils.convertExceptionToString(e));\n\t\t}\n\n\t\tLogging.finish();\n\t}\n\t//------------------------------------------------------\n\t/// Print Help Text\n\t///\n\t/// Prints out instructions on how to use this tool.\n\t//------------------------------------------------------\n\tprivate static void PrintHelpText()\n\t{\n\t\tLogging.setLoggingLevel(LoggingLevel.VERBOSE);\n\t\tLogging.logVerbose(\"Usage: java -jar PNGToCSImage.jar --input <filename> --output <filename> [--convert <type>] [--convertalpha <type>] [--convertnoalpha <type>] [--compression <type>] [--disablepremultipliedalpha] [--dither] [\" + Logging.PARAM_LOGGING_LEVEL + \" <level>] [--help]\");\n\t\tLogging.logVerbose(\"Parameters:\");\n\t\tLogging.logVerbose(\" --input(-i): The path to the source image PNG.\");\n\t\tLogging.logVerbose(\" --output(-o): The path to the output image csimage.\");\n\t\tLogging.logVerbose(\" --convert(-ct): [Optional] The type to convert to.\");\n\t\tLogging.logVerbose(\" --convertalpha(-cta): [Optional] The type to convert images with alpha to.\");\n\t\tLogging.logVerbose(\" --convertnoalpha(-ctna): [Optional] The type to convert images without alpha to.\");\n\t\tLogging.logVerbose(\" --compression(-cn): [Optional] The compression type. The default is zlib compression.\");\n\t\tLogging.logVerbose(\" --disablepremultipliedalpha(-dpa): [Optional] If set the output image will not have it's alpha premultiplied.\");\n\t\tLogging.logVerbose(\" --dither(-d): [Optional] Whether or not to dither if converting to a smaller image format.\");\n\t\tLogging.logVerbose(\" \" + Logging.PARAM_LOGGING_LEVEL + \"(\" + Logging.SHORT_PARAM_LOGGING_LEVEL + \"): [Optional] Sets the level of message to log.\");\n\t\tLogging.logVerbose(\" --help(-h): [Optional] Display this help message.\");\n\t\tLogging.logVerbose(\"Conversion Types:\");\n\t\tLogging.logVerbose(\" L8\");\n\t\tLogging.logVerbose(\" LA88\");\n\t\tLogging.logVerbose(\" RGB565\");\n\t\tLogging.logVerbose(\" RGBA4444\");\n\t\tLogging.logVerbose(\" RGB888\");\n\t\tLogging.logVerbose(\" RGBA8888\");\n\t\tLogging.logVerbose(\"Compression Types:\");\n\t\tLogging.logVerbose(\" None\");\n\t\tLogging.logVerbose(\" Default\");\n\t\tLogging.logVerbose(\"Logging Levels:\");\n\t\tLogging.logVerbose(\" \" + Logging.LOGGING_LEVEL_NONE + \": No logging.\");\n\t\tLogging.logVerbose(\" \" + Logging.LOGGING_LEVEL_FATAL + \": Only log fatal errors.\");\n\t\tLogging.logVerbose(\" \" + Logging.LOGGING_LEVEL_ERROR + \": Only log errors.\");\n\t\tLogging.logVerbose(\" \" + Logging.LOGGING_LEVEL_WARNING + \": Log errors and warnings.\");\n\t\tLogging.logVerbose(\" \" + Logging.LOGGING_LEVEL_VERBOSE + \": Log all messages.\");\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/PNGToCSImage/src/com/chilliworks/chillisource/pngtocsimage/PNGToCSImage.java",
    "content": "/**\n * PNGToMoImage.java\n * ChilliSource\n * Created by Scott Downie on 26/10/2012\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2012 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.pngtocsimage;\nimport java.awt.image.BufferedImage;\nimport java.io.ByteArrayOutputStream;\nimport java.io.File;\nimport java.io.FileOutputStream;\nimport java.io.IOException;\nimport java.util.zip.CRC32;\nimport java.util.zip.Deflater;\n\nimport javax.imageio.ImageIO;\n\nimport com.chilliworks.chillisource.coreutils.CSException;\nimport com.chilliworks.chillisource.coreutils.Logging;\n\n//============================================================================\n/// PNG To MoImage\n///\n/// Handles all png conversions to the various csimage formats.\n///\n/// Version History\n///\n/// 2 - First release version, no comporession @auther SDownie\n/// 3 - Added default zlib comporession @author RHenning\n//============================================================================\npublic class PNGToCSImage \n{\n\t//------------------------------------------------------------------------\n\t/// Constants\n\t//------------------------------------------------------------------------\n\tprivate final static int kdwVersion = 3;\n\t\n\tprivate static long mPNGFileSize = 0;\n\t\n\t//------------------------------------------------------\n\t/// Convert String To Conversion Format\n\t///\n\t/// @return the Conversion Format equivalent to the given\n\t/// string.\n\t//------------------------------------------------------\n\tpublic static PNGToCSImageOptions.OUTPUT_FORMAT convertStringToConversionFormat(String instrString)\n\t{\n\t\tif (instrString.equalsIgnoreCase(\"L8\") == true)\n\t\t\treturn PNGToCSImageOptions.OUTPUT_FORMAT.L8;\n\t\tif (instrString.equalsIgnoreCase(\"LA88\") == true)\n\t\t\treturn PNGToCSImageOptions.OUTPUT_FORMAT.LA88;\n\t\tif (instrString.equalsIgnoreCase(\"RGB565\") == true)\n\t\t\treturn PNGToCSImageOptions.OUTPUT_FORMAT.RGB565;\n\t\tif (instrString.equalsIgnoreCase(\"RGBA4444\") == true)\n\t\t\treturn PNGToCSImageOptions.OUTPUT_FORMAT.RGBA4444;\n\t\tif (instrString.equalsIgnoreCase(\"RGB888\") == true)\n\t\t\treturn PNGToCSImageOptions.OUTPUT_FORMAT.RGB888;\n\t\tif (instrString.equalsIgnoreCase(\"RGBA8888\") == true)\n\t\t\treturn PNGToCSImageOptions.OUTPUT_FORMAT.RGBA8888;\n\t\t\n\t\tLogging.logWarning(\"No valid conversion format found. Will default to the image's format.\");\n\t\treturn PNGToCSImageOptions.OUTPUT_FORMAT.NONE;\n\t}\n\t//------------------------------------------------------\n\t/// Convert String To Compression Format\n\t///\n\t/// @return the Conversion Format equivalent to the given\n\t/// string.\n\t//------------------------------------------------------\n\tpublic static PNGToCSImageOptions.COMPRESSION_FORMAT convertStringToCompressionFormat(String instrString)\n\t{\n\t\tif (instrString.equalsIgnoreCase(\"Default\"))\n\t\t\treturn PNGToCSImageOptions.COMPRESSION_FORMAT.DEFAULT_ZLIB;\n\t\telse if (instrString.equalsIgnoreCase(\"None\"))\n\t\t\treturn PNGToCSImageOptions.COMPRESSION_FORMAT.NONE;\n\t\t\n\t\tLogging.logWarning(\"No valid compression format found. Image will not be compressed.\");\n\t\treturn PNGToCSImageOptions.COMPRESSION_FORMAT.NONE;\n\t}\n\t//------------------------------------------------------------------------\n\t/// Run\n\t///\n\t/// Converts a PNG to MoImage format based upon the given options.\n\t//------------------------------------------------------------------------\n\tpublic static void run(PNGToCSImageOptions inOptions) throws IOException, CSException\n\t{\n\t\tlong ddwCRC = 0;\n\t\tint dwOriginalDataSize = 0;\n\t\t\n\t\t//Open the png\n\t\tImageContainer image = null;\n\t\ttry \n\t\t{\n\t\t\tLogging.logVerbose(\"Loading PNG...\");\n\t\t\tString strInputFile = inOptions.strInputFilename;\n\t\t\tLogging.logVerbose(\"Input File: \" + strInputFile);\n\t\t\timage = LoadPNG(strInputFile);\n\t\t\tLogging.logVerbose(\"Loading PNG Complete\");\n\t\t} \n\t\tcatch (IOException e) \n\t\t{\n\t\t\tString ioErrorMessage = e.getMessage();\n\t\t\tif (ioErrorMessage != null)\n\t\t\t{\n\t\t\t    throw new CSException(\"Cannot load PNG file: \" + ioErrorMessage, e);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t    throw new CSException(\"Cannot load PNG file.\", e);\n\t\t\t}\n\t\t}\n\t\t\n\t\t//pre multiply data if required\n\t\tboolean bPreMultiply = inOptions.bPremultiply;\n\t\tif(image.bHasAlpha && bPreMultiply == true)\n\t\t{\n\t\t\tLogging.logVerbose(\"Premultiplying Alpha...\");\n\t\t\tPreMultiplyImage(image);\n\t\t\tLogging.logVerbose(\"Premultiplying Alpha Complete\");\n\t\t}\n\t\t\n\t\t//build the image data in the output format\n\t\tLogging.logVerbose(\"Building Image Data...\");\n\t\tPNGToCSImageOptions.OUTPUT_FORMAT imageFormat = GetOutputFormat(inOptions, image);\n\t\tboolean bDithering = inOptions.bDither;\n\t\tbyte[] outImageData = ConvertImageToFormat(image, imageFormat, bDithering);\n\t\tif(outImageData == null)\n\t\t{\n\t\t\tthrow new CSException(\"Cannot convert image to format: \" + inOptions.strInputFilename + \", \" + imageFormat);\n\t\t}\n\t\t\n\t\tdwOriginalDataSize = outImageData.length;\n\t\tLogging.logVerbose(\"Building Image Data Complete\");\n\n\t\t//Perform compression if required\n\t\tif (inOptions.eCompressionType != PNGToCSImageOptions.COMPRESSION_FORMAT.NONE)\n\t\t{\n\t\t\tCRC32 checksum = new CRC32();\n\t\t\tchecksum.update(outImageData);\n\t\t\tddwCRC = checksum.getValue();\n\t\t\t\n\t\t\tLogging.logVerbose(\"Compressing Image...\");\n\t\t\toutImageData = CompressImage(inOptions, outImageData);\n\t\t\tLogging.logVerbose(\"Compressing Image Complete\");\n\t\t}\n\t\t\n\t\t//Create header and output\n\t\ttry \n\t\t{\n\t\t\tLogging.logVerbose(\"Outputting CSImage...\");\n\t\t\tString strOutputFile = inOptions.strOutputFilename;\n\t\t\tLogging.logVerbose(\"Output File: \" + strOutputFile);\n\t\t\tOutputMoImage(outImageData, imageFormat, inOptions.eCompressionType, ddwCRC, dwOriginalDataSize, image.dwWidth, image.dwHeight, strOutputFile);\n\t\t\tLogging.logVerbose(\"Outputting CSImage Complete\");\n\t\t} \n\t\tcatch (IOException e) \n\t\t{\n\t\t\tString ioErrorMessage = e.getMessage();\n\t\t\tif (ioErrorMessage != null)\n\t\t\t{\n\t\t\t    throw new CSException(\"Cannot output csimage file: \" + ioErrorMessage, e);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t    throw new CSException(\"Cannot output csimage file.\", e);\n\t\t\t}\n\t\t}\n\t}\n\t//------------------------------------------------------------------------\n\t/// Load PNG\n\t///\n\t/// Loads the given PNG.\n\t//------------------------------------------------------------------------\n\tprivate static ImageContainer LoadPNG(String instrPath) throws IOException\n\t{\n\t\tif(instrPath == null)\n\t\t{\n\t\t\tthrow new IOException();\n\t\t}\n\n\t\tFile imageFile = new File(instrPath);\n\t\tmPNGFileSize = imageFile.length();\n\t\t\n\t\tBufferedImage image = ImageIO.read(imageFile);\n\t\tImageContainer imageContainer = new ImageContainer();\n\t\timageContainer.dwWidth = image.getWidth();\n\t\timageContainer.dwHeight = image.getHeight();\n\t\timageContainer.dwType = image.getType();\n\t\timageContainer.bHasAlpha = image.getColorModel().hasAlpha();\n\t\timageContainer.adwImageData = new int[imageContainer.dwWidth * imageContainer.dwHeight];\n\t\t\n\t\tswitch (imageContainer.dwType)\n\t\t{\n\t\tcase BufferedImage.TYPE_BYTE_GRAY:\n\t\t\tif (imageContainer.bHasAlpha == false)\n\t\t\t\tBuildImageL8(imageContainer, image);\n\t\t\telse\n\t\t\t\tBuildImageLA88(imageContainer, image);\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tBuildImageDefault(imageContainer, image);\t\n\t\t}\n\t\t\n\t\treturn imageContainer;\n\t}\n\t//------------------------------------------------------------------------\n\t/// Build Image Default\n\t///\n\t/// The default image builder. Simply uses getRGB() to get the image data\n\t//------------------------------------------------------------------------\n\tprivate static void BuildImageDefault(ImageContainer inImageContainer, BufferedImage inImage)\n\t{\n\t\tfor (int x = 0; x < inImageContainer.dwWidth; ++x)\n\t\t{\n\t\t\tfor (int y = 0; y < inImageContainer.dwHeight; ++y)\n\t\t\t{\n\t\t\t\tint dwIndex = x + y * inImageContainer.dwWidth;\n\t\t\t\tinImageContainer.adwImageData[dwIndex] = inImage.getRGB(x, y);\n\t\t\t}\n\t\t}\n\t}\n\t//------------------------------------------------------------------------\n\t/// Build Image L8\n\t///\n\t/// The default image builder. Simply uses getRGB() to get the image data\n\t//------------------------------------------------------------------------\n\tprivate static void BuildImageL8(ImageContainer inImageContainer, BufferedImage inImage)\n\t{\n\t\tfor (int x = 0; x < inImageContainer.dwWidth; ++x)\n\t\t{\n\t\t\tfor (int y = 0; y < inImageContainer.dwHeight; ++y)\n\t\t\t{\n\t\t\t\tint dwIndex = x + y * inImageContainer.dwWidth;\n\t\t\t\tint dwL = inImage.getRaster().getSample(x, y, 0);\n\t\t\t\tint dwCombined \t = (dwL << 0);\n\t\t\t\tdwCombined \t\t|= (dwL << 8);\n\t\t\t\tdwCombined \t\t|= (dwL << 16);\n\t\t\t\tdwCombined \t\t|= (0xFF << 24);\n\t\t\t\tinImageContainer.adwImageData[dwIndex] = dwCombined;\n\t\t\t}\n\t\t}\n\t}\n\t//------------------------------------------------------------------------\n\t/// Build Image LA88\n\t///\n\t/// The default image builder. Simply uses getRGB() to get the image data\n\t//------------------------------------------------------------------------\n\tprivate static void BuildImageLA88(ImageContainer inImageContainer, BufferedImage inImage)\n\t{\n\t\tfor (int x = 0; x < inImageContainer.dwWidth; ++x)\n\t\t{\n\t\t\tfor (int y = 0; y < inImageContainer.dwHeight; ++y)\n\t\t\t{\n\t\t\t\tint dwIndex = x + y * inImageContainer.dwWidth;\n\t\t\t\tint dwL = inImage.getRaster().getSample(x, y, 0);\n\t\t\t\tint dwA = inImage.getRaster().getSample(x, y, 1);\n\t\t\t\tint dwCombined \t = (dwL << 0);\n\t\t\t\tdwCombined \t\t|= (dwL << 8);\n\t\t\t\tdwCombined \t\t|= (dwL << 16);\n\t\t\t\tdwCombined \t\t|= (dwA << 24);\n\t\t\t\tinImageContainer.adwImageData[dwIndex] = dwCombined;\n\t\t\t}\n\t\t}\n\t}\n\t//------------------------------------------------------------------------\n\t/// Get Output Format\n\t///\n\t/// @return the output format, based upon the given params and the type\n\t/// of the given image.\n\t//------------------------------------------------------------------------\n\tprivate static PNGToCSImageOptions.OUTPUT_FORMAT GetOutputFormat(PNGToCSImageOptions inOptions, ImageContainer inImage)\n\t{\n\t\t//if it has conversion type format, force output to this.\n\t\tif (inOptions.eConversionType != PNGToCSImageOptions.OUTPUT_FORMAT.NONE)\n\t\t\treturn inOptions.eConversionType;\n\t\t\n\t\t//if it has alpha and a alpha image conversion type then use this type.\n\t\tif (inImage.bHasAlpha == true && inOptions.eConversionAlphaType != PNGToCSImageOptions.OUTPUT_FORMAT.NONE)\n\t\t\treturn inOptions.eConversionAlphaType;\n\t\t\t\t\t\n\t\t//if it has no alpha and a no alpha image conversion type then use this type.\n\t\tif (inImage.bHasAlpha == false && inOptions.eConversionNoAlphaType != PNGToCSImageOptions.OUTPUT_FORMAT.NONE)\n\t\t\treturn inOptions.eConversionNoAlphaType;\n\n\t\t//otherwise fall back on the type the image already is.\n\t\tswitch (inImage.dwType)\n\t\t{\n\t\tcase BufferedImage.TYPE_BYTE_GRAY:\n\t\t\tif (inImage.bHasAlpha == false)\n\t\t\t\treturn PNGToCSImageOptions.OUTPUT_FORMAT.L8;\n\t\t\telse\n\t\t\t\treturn PNGToCSImageOptions.OUTPUT_FORMAT.LA88;\n\t\tcase BufferedImage.TYPE_BYTE_BINARY:\n\t\tcase BufferedImage.TYPE_3BYTE_BGR:\n\t\tcase BufferedImage.TYPE_4BYTE_ABGR:\n\t\tcase BufferedImage.TYPE_BYTE_INDEXED:\n\t\tcase BufferedImage.TYPE_INT_ARGB:\n\t\tcase BufferedImage.TYPE_INT_ARGB_PRE:\n\t\tcase BufferedImage.TYPE_INT_BGR:\n\t\tcase BufferedImage.TYPE_INT_RGB:\n\t\t\tif (inImage.bHasAlpha == false)\n\t\t\t\treturn PNGToCSImageOptions.OUTPUT_FORMAT.RGB888;\n\t\t\telse\n\t\t\t\treturn PNGToCSImageOptions.OUTPUT_FORMAT.RGBA8888;\n\t\tdefault:\n\t\t\treturn PNGToCSImageOptions.OUTPUT_FORMAT.NONE;\t\n\t\t}\n\t}\n\t//------------------------------------------------------------------------\n\t/// PreMultiply Image\n\t///\n\t/// Pre multiplies the alpha of the given image.\n\t//------------------------------------------------------------------------\n\tprivate static void PreMultiplyImage(ImageContainer inImage)\n\t{\n\t\tint numPixels = inImage.dwWidth * inImage.dwHeight; \n\n\t\tfor(int pixel=0; pixel<numPixels; ++pixel)\n\t\t{\n\t\t\tint rgba = inImage.adwImageData[pixel];\n\t\t\t\n\t\t\tfinal int A = (rgba >>> 24 \t& 0xFF); \n\t\t\tfinal int R = CalculatePremultipliedAlpha(rgba >>> 16 & 0xFF, A); \n\t\t\tfinal int G = CalculatePremultipliedAlpha(rgba >>>  8 & 0xFF, A); \n\t\t\tfinal int B = CalculatePremultipliedAlpha(rgba >>>  0 & 0xFF, A);\n\t\t\t\n\t\t\trgba = \t(A & 0xFF) << 24 |\n\t\t\t\t\t(R & 0xFF) << 16 |\n\t\t\t\t\t(G & 0xFF) << 8  | \n\t\t\t\t\t(B & 0xFF);\n\t\t\t\n\t\t\tinImage.adwImageData[pixel] = rgba;\n\t\t}\n\t}\n\t//------------------------------------------------------------------------\n\t/// Convert Image To Format\n\t///\n\t/// Converts the image to the  requested output format.\n\t//------------------------------------------------------------------------\n\tprivate static byte[] ConvertImageToFormat(ImageContainer inImage, PNGToCSImageOptions.OUTPUT_FORMAT inFormatFlag, boolean inbDither)\n\t{\n\t\tswitch (inFormatFlag)\n\t\t{\n\t\tcase L8:\n\t\t\treturn ConvertToL8(inImage);\n\t\tcase LA88:\n\t\t\treturn ConvertToLA88(inImage);\n\t\tcase RGB565:\n\t\t\tif(inImage.dwWidth % 2 > 0)\n\t\t\t{\n\t\t\t\tLogging.logError(\"Cannot convert an image that is not divisible by 2 to RGB565 Format.\");\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\treturn ConvertToRGB565(inImage, inbDither);\n\t\tcase RGBA4444:\n\t\t\tif(inImage.dwWidth % 2 > 0)\n\t\t\t{\n\t\t\t\tLogging.logError(\"Cannot convert an image that is not divisible by 2 to RGBA4444 Format.\");\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\treturn ConvertToRGBA4444(inImage, inbDither);\n\t\tcase RGB888:\n\t\t\treturn ConvertToRGB888(inImage); \n\t\tcase RGBA8888:\n\t\t\treturn ConvertToRGBA8888(inImage);\n\t\tcase NONE:\n\t\tdefault:\n\t\t\tLogging.logError(\"Invalid output format.\");\n\t\t\treturn null;\n\t\t}\n\t}\n\t//------------------------------------------------------------------------\n\t/// Convert To RGBA8888\n\t///\n\t/// Converts to csimage format RGBA8888.\n\t//------------------------------------------------------------------------\n\tprivate static byte[] ConvertToRGBA8888(ImageContainer inImage)\n\t{\n\t\tLogging.logVerbose(\"Converting to RGBA8888\");\n\n\t\tint area = inImage.dwHeight * inImage.dwWidth;\n\t\tbyte[] outByteData = new byte[area * 4];\n\n\t\tint i = 0;\n\t\tfor(int pixel=0; pixel<area; i+=4, ++pixel)\n\t\t{\n\t\t\tfinal int rgba = inImage.adwImageData[pixel];\n\t\n\t\t\toutByteData[i+0] = (byte)(rgba >>> 16 & 0xFF); \n\t\t\toutByteData[i+1] = (byte)(rgba >>>  8 & 0xFF); \n\t\t\toutByteData[i+2] = (byte)(rgba >>>  0 & 0xFF);\n\t\t\toutByteData[i+3] = (byte)(rgba >>> 24 & 0xFF); \n\t\t}\n\n\t\treturn outByteData;\n\t}\n\t//------------------------------------------------------------------------\n\t/// Convert To RGB888\n\t///\n\t/// Converts to csimage format RGB888.\n\t//------------------------------------------------------------------------\n\tprivate static byte[] ConvertToRGB888(ImageContainer inImage)\n\t{\n\t\tLogging.logVerbose(\"Converting to RGB888\");\n\n\t\tint area = inImage.dwHeight * inImage.dwWidth;\n\t\tbyte[] outByteData = new byte[area * 3];\n\n\t\tint i = 0;\n\t\tfor(int pixel=0; pixel<area; i+=3, ++pixel)\n\t\t{\n\t\t\tfinal int rgba = inImage.adwImageData[pixel];\n\n\t\t\toutByteData[i]   = (byte)(rgba >>> 16\t& 0xFF);\n\t\t\toutByteData[i+1] = (byte)(rgba >>> 8  \t& 0xFF);\n\t\t\toutByteData[i+2] = (byte)(rgba >>> 0 \t& 0xFF);\n\t\t}\n\n\t\treturn outByteData;\n\t}\n\t//------------------------------------------------------------------------\n\t/// Convert To L8\n\t///\n\t/// Converts to csimage format L8.\n\t//------------------------------------------------------------------------\n\tprivate static byte[] ConvertToL8(ImageContainer inImage)\n\t{\n\t\tLogging.logVerbose(\"Converting to L8\");\n\t\tint area = inImage.dwHeight * inImage.dwWidth;\n\t\tbyte[] outByteData = new byte[area];\n\n\t\tint i = 0;\n\t\tfor(int pixel=0; pixel<area; i++, ++pixel)\n\t\t{\n\t\t\tfinal int rgba = inImage.adwImageData[pixel];\n\t\t\tint byR = (int)(rgba >>> 16\t& 0xFF);\n\t\t\tint byG = (int)(rgba >>> 8  & 0xFF);\n\t\t\tint byB = (int)(rgba >>> 0 \t& 0xFF);\n\t\t\tint dwSum = byR + byG + byB;\n\t\t\toutByteData[i] = (byte)(dwSum / 3);\n\t\t}\n\n\t\treturn outByteData;\n\t}\n\t//------------------------------------------------------------------------\n\t/// Convert To LA88\n\t///\n\t/// Converts to csimage format LA88.\n\t//------------------------------------------------------------------------\n\tprivate static byte[] ConvertToLA88(ImageContainer inImage)\n\t{\n\t\tLogging.logVerbose(\"Converting to LA88\");\n\n\t\tint area = inImage.dwHeight * inImage.dwWidth;\n\t\tbyte[] outByteData = new byte[area * 2];\n\n\t\tint i = 0;\n\t\tfor(int pixel=0; pixel<area; i+=2, ++pixel)\n\t\t{\n\t\t\tfinal int rgba = inImage.adwImageData[pixel];\n\t\n\t\t\tint byR = (int)(rgba >>> 16 & 0xFF); \n\t\t\tint byG = (int)(rgba >>>  8 & 0xFF); \n\t\t\tint byB = (int)(rgba >>>  0 & 0xFF);\n\t\t\tint byA = (int)(rgba >>> 24 & 0xFF); \n\t\t\tint dwSum =  ((int)byR) + ((int)byG) + ((int)byB);\n\t\t\toutByteData[i + 0] = (byte)(dwSum / 3);\n\t\t\toutByteData[i + 1] = (byte)byA;\n\t\t}\n\n\t\treturn outByteData;\n\t}\n\t//------------------------------------------------------------------------\n\t/// Convert To RGB565\n\t///\n\t/// Converts to csimage format RGB565.\n\t//------------------------------------------------------------------------\n\tprivate static byte[] ConvertToRGB565(ImageContainer inImage, boolean inDither)\n\t{\n\t\tLogging.logVerbose(\"Converting to RGB565\");\n\t\t\n\t\tif(inDither)\n\t\t{\n\t\t\tLogging.logVerbose(\"Dithering...\");\n\t\t}\n\n\t\tint area = inImage.dwHeight * inImage.dwWidth;\n\t\tbyte[] outByteData = new byte[area * 2];\n\n\t\tint i = 0;\n\t\tfor(int pixel=0; pixel<area; i+=2, ++pixel)\n\t\t{\n\t\t\tfinal int rgba =inImage.adwImageData[pixel];\n\t\t\t\n\t\t\tint oR = (rgba >>> 16 & 0xFF);\n\t\t\tint oG = (rgba >>>  8 & 0xFF);\n\t\t\tint oB = (rgba >>>  0 & 0xFF);\n\t\t\t\n\t\t\tint R = oR >>> 3;\n\t\t\tint G = oG >>> 2;\n\t\t\tint B = oB >>> 3;\n\t\t\t\n\t\t\tif(inDither)\n\t\t\t{\n\t\t\t\tDitherSierraLite(inImage, pixel % inImage.dwWidth, pixel / inImage.dwWidth, oR - (R<<3), oG - (G<<2), oB - (B<<3), 0);\n\t\t\t}\n\n\t\t\tshort combined = (short) \n\t\t\t\t\t(\n\t\t\t\t\t\t(R << 11) | \n\t\t\t\t\t\t(G << 5)  | \n\t\t\t\t\t\t(B << 0)\n\t\t\t\t\t);\n\n\t\t\toutByteData[i]\t = (byte)(combined >>> 0  & 0xFF);\n\t\t\toutByteData[i+1] = (byte)(combined >>> 8  & 0xFF);\n\t\t}\n\n\t\treturn outByteData;\n\t}\n\t//------------------------------------------------------------------------\n\t/// Convert To RGBA4444\n\t///\n\t/// Converts to csimage format RGBA4444.\n\t//------------------------------------------------------------------------\n\tprivate static byte[] ConvertToRGBA4444(ImageContainer inImage, boolean inDither)\n\t{\n\t\tLogging.logVerbose(\"Converting to RGBA4444\");\n\t\t\n\t\tif(inDither)\n\t\t{\n\t\t\tLogging.logVerbose(\"Dithering...\");\n\t\t}\n\n\t\tfinal int area = inImage.dwHeight * inImage.dwWidth;\n\t\tbyte[] outByteData = new byte[area * 2];\n\n\t\tint i = 0;\n\t\tfor(int pixel=0; pixel<area; i+=2, ++pixel)\n\t\t{\n\t\t\tint rgba = inImage.adwImageData[pixel];\n\n\t\t\tint oR = (rgba >>> 16 & 0xFF);\n\t\t\tint oG = (rgba >>>  8 & 0xFF);\n\t\t\tint oB = (rgba >>>  0 & 0xFF);\n\t\t\tint oA = (rgba >>> 24 & 0xFF);\n\n\t\t\tint R = oR >>> 4;\n\t\t\tint G = oG >>> 4;\n\t\t\tint B = oB >>> 4;\n\t\t\tint A = oA >>> 4;\n\t\t\t\n\t\t\tif(inDither)\n\t\t\t{\n\t\t\t\tDitherSierraLite(inImage, pixel % inImage.dwWidth, pixel / inImage.dwWidth, oR - (R<<4), oG - (G<<4), oB - (B<<4), oA - (A<<4));\n\t\t\t}\n\n\t\t\tshort combined = \n\t\t\t\t\t(short) \n\t\t\t\t\t(\n\t\t\t\t\t\t(R << 12)| \n\t\t\t\t\t\t(G << 8) | \n\t\t\t\t\t\t(B << 4) | \n\t\t\t\t\t\t(A << 0)\n\t\t\t\t\t); \n\n\t\t\toutByteData[i]\t = (byte)(combined >>> 0  & 0xFF);\n\t\t\toutByteData[i+1] = (byte)(combined >>> 8  & 0xFF);\n\t\t}\n\n\t\treturn outByteData;\n\t}\n\t//------------------------------------------------------------------------\n\t/// Apply Error\n\t//------------------------------------------------------------------------\n\tprivate static int ApplyError(int rgba, float factor, int errorR, int errorG, int errorB, int errorA)\n\t{\n\t\tint a = (rgba >>> 24 & 0xFF);\n\t\tint r = (rgba >>> 16 & 0xFF); \n\t\tint g = (rgba >>> 8 & 0xFF); \n\t\tint b = (rgba \t\t& 0xFF);\n\t\t\n\n\t\tr+= (errorR * factor);\n\t\tr = r < 0 ? 0 : r;\n\t\tr = r > 255? 255 : r;\n\n\t\tg+= (errorG * factor);\n\t\tg = g < 0 ? 0 : g;\n\t\tg = g > 255? 255 : g;\n\n\t\tb+= (errorB * factor); \n\t\tb = b < 0 ? 0 : b;\n\t\tb = b > 255? 255 : b;\n\n\t\ta+= (errorA * factor);\n\t\ta = a < 0 ? 0 : a;\n\t\ta = a > 255? 255 : a;\n\n\t\treturn \t(a & 0xFF) << 24 |\n\t\t\t\t(r & 0xFF) << 16 |\n\t\t\t\t(g & 0xFF) << 8  | \n\t\t\t\t(b & 0xFF);\n\n\t}\n\t//------------------------------------------------------------------------\n\t/// Dither Sierra Lite\n\t//------------------------------------------------------------------------\n\tprivate static void DitherSierraLite(ImageContainer inImage, int x, int y, int errorR, int errorG, int errorB, int errorA )\n\t{\n\t\t//        *   2                          The Sierra-2-4A filter\n\t\t//    1   1               (1/4)\n\t\t\n\t\tif(x < inImage.dwWidth - 1)\n\t\t{\n\t\t\tint dwIndex = (x+1) + (y+0) * inImage.dwWidth;\n\t\t\tint rgba = inImage.adwImageData[dwIndex];\n\t\t\trgba = ApplyError(rgba, 2.0f/ 4.0f, errorR, errorG, errorB, errorA);\n\t\t\tinImage.adwImageData[dwIndex] = rgba;\n\t\t}\n\t\tif(y < inImage.dwHeight - 1)\n\t\t{\n\t\t\tint dwIndex = (x+0) + (y+1) * inImage.dwWidth;\n\t\t\tint rgba = inImage.adwImageData[dwIndex];\n\t\t\trgba = ApplyError(rgba, 1.0f/ 4.0f, errorR, errorG, errorB, errorA);\n\t\t\tinImage.adwImageData[dwIndex] = rgba;\n\t\t\t\n\t\t\tif(x > 0)\n\t\t\t{\n\t\t\t\tdwIndex = (x-1) + (y+1) * inImage.dwWidth;\n\t\t\t\trgba = inImage.adwImageData[dwIndex];\n\t\t\t\trgba = ApplyError(rgba, 1.0f/ 4.0f, errorR, errorG, errorB, errorA);\n\t\t\t\tinImage.adwImageData[dwIndex] = rgba;\n\t\t\t}\n\t\t}\n\t}\n\t//------------------------------------------------------------------------\n\t/// Calculate Premultiplied Alpha\n\t///\n\t/// @return the premultiplied alpha value for the given pixel.\n\t//------------------------------------------------------------------------\n\tprivate static int CalculatePremultipliedAlpha(int inCol, int inAlpha)\n\t{\n\t\treturn (inCol*inAlpha)/255;\n\t}\n\t//------------------------------------------------------------------------\n\t/// Compress Image\n\t///\n\t/// @return compresses the image with the requested compression algorithm.\n\t//------------------------------------------------------------------------\n\tprivate static byte[] CompressImage(PNGToCSImageOptions inOptions, byte[] inImageData) throws IOException\n\t{\n\t\tif(inOptions.eCompressionType != PNGToCSImageOptions.COMPRESSION_FORMAT.DEFAULT_ZLIB)\n\t\t{\n\t\t\tLogging.logFatal(\"Unsupported compression. Image will not be compressed\");\n\t\t\treturn inImageData;\n\t\t}\n\t\t\n\t\t// Compression using zlib\n\t\tDeflater compresser = new Deflater();\n\t\tcompresser.setInput(inImageData);\n\t\tcompresser.finish();\n\n\t\tByteArrayOutputStream out = new ByteArrayOutputStream(inImageData.length);\n\t\tbyte[] byBuffer = new byte[8192]; // Write in 8K chunks\n\t\twhile(!compresser.finished())\n\t\t{\n\t\t\tint dwCompressedBytes = compresser.deflate(byBuffer);\n\t\t\tout.write(byBuffer, 0, dwCompressedBytes);\n\t\t}\n\t\tout.close();\n\n\t\tbyte[] abyCompressedImge = out.toByteArray();\n\n\t\treturn abyCompressedImge;\n\t}\n\t//------------------------------------------------------------------------\n\t/// Output MoImage\n\t///\n\t/// Outputs the generated csimage data to file.\n\t//------------------------------------------------------------------------\n\tprivate static void OutputMoImage(byte[] inImageData,\n\t\t\t\t\t\t\t\t\t  PNGToCSImageOptions.OUTPUT_FORMAT inFormat,\n\t\t\t\t\t\t\t\t\t  PNGToCSImageOptions.COMPRESSION_FORMAT inCompression,\n\t\t\t\t\t\t\t\t\t  long inddwChecksum, int indwOriginalSize,\n\t\t\t\t\t\t\t\t\t  int inWidth, int inHeight,\n\t\t\t\t\t\t\t\t\t  String instrOutputFile) throws IOException\n\t{\n\t\tif(instrOutputFile == null)\n\t\t{\n\t\t\tthrow new IOException();\n\t\t}\n\n\t\t///Apply the header\n\t\t// Byte order check - int\n\t\t// Version - int\n\t\t// Width - int\n\t\t// Height - int\n\t\t// Format - int\n\t\t// Compression - int\n\t\t// Checksum (CRC32)\n\t\t// Uncompressed data size\n\t\t// Final data size - int\n\t\tint byteOrderCheck = 123456;\n\t\tint version = kdwVersion;\n\t\tint compression = 0;\n\t\tif(inCompression == PNGToCSImageOptions.COMPRESSION_FORMAT.DEFAULT_ZLIB)\n\t\t\tcompression = 1;\n\t\t\n\t\t//Write out the data\n\t\tFileOutputStream fileStream = new FileOutputStream(instrOutputFile);\n\t\tWriteInt(fileStream, byteOrderCheck);\n\t\tWriteInt(fileStream, version);\n\t\tWriteInt(fileStream, inWidth);\n\t\tWriteInt(fileStream, inHeight);\n\t\tWriteInt(fileStream, inFormat.ordinal());\n\t\tWriteInt(fileStream, compression);\n\t\tWriteLong(fileStream, inddwChecksum);\n\t\tWriteInt(fileStream, indwOriginalSize);\n\t\tWriteInt(fileStream, inImageData.length);\n\t\t\n\t\tLogging.logVerbose(\"Completed writting file with header:\\n\\tOrderCheck:\"+byteOrderCheck\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t+\"\\n\\tVersion:\"+version\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t+\"\\n\\tWidth:\"+inWidth\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t+\"\\n\\tHeight:\"+inHeight\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t+\"\\n\\tFormat:\"+inFormat.ordinal()\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t+\"\\n\\tCompression:\"+compression\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t+\"\\n\\tChecksum:\"+inddwChecksum\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t+\"\\n\\tOriginalSize:\"+indwOriginalSize\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t+\"\\n\\tFinalSize:\"+inImageData.length);\n\t\t\n\t\tfileStream.write(inImageData);\n\t\tfileStream.close();\n\t\t\n\t\tFile imageFile = new File(instrOutputFile);\n\t\tLogging.logVerbose(\"CSImage: \" + instrOutputFile);\n\t\tLogging.logVerbose(\"PNG File Size: \" + Math.ceil((float)mPNGFileSize / (float)1024) + \" KB\");\n\t\tLogging.logVerbose(\"CSImage Uncompressed Size: \" + Math.ceil((float)indwOriginalSize / (float)1024) + \" KB\");\n\t\tLogging.logVerbose(\"CSImage File Size: \" + Math.ceil((float)imageFile.length() / (float)1024) + \" KB\");\n\t\tLogging.logVerbose(\"\");\n\t}\n\t//-------------------------------------------------------\n\t/// Write Integer\n\t///\n\t/// Writes a single Integer to the output stream.\n\t///\n\t/// @param the integer.\n\t//-------------------------------------------------------\n\tprivate static void WriteInt(FileOutputStream inStream, int indwData) throws IOException\n\t{\n\t\tinStream.write((byte)(indwData \t\t\t& 0xFF));\n\t\tinStream.write((byte)(indwData >>> 8 \t& 0xFF));\n\t\tinStream.write((byte)(indwData >>> 16 \t& 0xFF));\n\t\tinStream.write((byte)(indwData >>> 24\t& 0xFF));\n\t}\n\t//-------------------------------------------------------\n\t/// Write Long Integer\n\t///\n\t/// Writes a single Integer to the output stream.\n\t///\n\t/// @param the integer.\n\t//-------------------------------------------------------\n\tprivate static void WriteLong(FileOutputStream inStream, long indwData) throws IOException\n\t{\n\t\tinStream.write((byte)(indwData \t\t\t& 0xFF));\n\t\tinStream.write((byte)(indwData >>> 8 \t& 0xFF));\n\t\tinStream.write((byte)(indwData >>> 16 \t& 0xFF));\n\t\tinStream.write((byte)(indwData >>> 24\t& 0xFF));\n\t\tinStream.write((byte)(indwData >>> 32\t& 0xFF));\n\t\tinStream.write((byte)(indwData >>> 40\t& 0xFF));\n\t\tinStream.write((byte)(indwData >>> 48 \t& 0xFF));\n\t\tinStream.write((byte)(indwData >>> 56\t& 0xFF));\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/PNGToCSImage/src/com/chilliworks/chillisource/pngtocsimage/PNGToCSImageOptions.java",
    "content": "/**\n * Main.java\n * ChilliSource\n * Created by Ian Copland on 26/10/2012\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2012 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.pngtocsimage;\n\npublic class PNGToCSImageOptions \n{\n\t//--------------------------------------------------------------\n\t/// Image Format\n\t//--------------------------------------------------------------\n\tpublic enum OUTPUT_FORMAT\n\t{\n\t\tNONE,\n\t\tL8,\n\t\tLA88,\n\t\tRGB565,\n\t\tRGBA4444,\n\t\tRGB888,\n\t\tRGBA8888\n\t}\n\t//--------------------------------------------------------------\n\t/// Image Format\n\t//--------------------------------------------------------------\n\tpublic enum COMPRESSION_FORMAT\n\t{\n\t\tNONE,\n\t\tDEFAULT_ZLIB,\n\t}\n\t\n\tpublic String strInputFilename = new String();\n\tpublic String strOutputFilename = new String();\n\tpublic OUTPUT_FORMAT eConversionType = OUTPUT_FORMAT.NONE;\n\tpublic OUTPUT_FORMAT eConversionAlphaType = OUTPUT_FORMAT.NONE;\n\tpublic OUTPUT_FORMAT eConversionNoAlphaType = OUTPUT_FORMAT.NONE;\n\tpublic COMPRESSION_FORMAT eCompressionType = COMPRESSION_FORMAT.DEFAULT_ZLIB;\n\tpublic boolean bPremultiply = true;\n\tpublic boolean bDither = false;\n}\n"
  },
  {
    "path": "Projects/Tools/TGAToCSImage/.classpath",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<classpath>\n\t<classpathentry kind=\"src\" path=\"src\"/>\n\t<classpathentry kind=\"con\" path=\"org.eclipse.jdt.launching.JRE_CONTAINER\"/>\n\t<classpathentry kind=\"lib\" path=\"com.realityinteractive.imageio.tga.jar\"/>\n\t<classpathentry combineaccessrules=\"false\" kind=\"src\" path=\"/CoreUtils\"/>\n\t<classpathentry kind=\"output\" path=\"bin\"/>\n</classpath>\n"
  },
  {
    "path": "Projects/Tools/TGAToCSImage/.project",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<projectDescription>\n\t<name>TGAToCSImage</name>\n\t<comment></comment>\n\t<projects>\n\t</projects>\n\t<buildSpec>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.jdt.core.javabuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t</buildSpec>\n\t<natures>\n\t\t<nature>org.eclipse.jdt.core.javanature</nature>\n\t</natures>\n</projectDescription>\n"
  },
  {
    "path": "Projects/Tools/TGAToCSImage/Manifest/Manifest.txt",
    "content": "Manifest-Version: 1.0\r\nMain-Class: com.chillisource.tgatocsimage.Main\r\n\r\n"
  },
  {
    "path": "Projects/Tools/TGAToCSImage/src/com/chilliworks/chillisource/tgatocsimage/ImageContainer.java",
    "content": "/**\n * ImageContainer.java\n * ChilliSource\n * Created by Ian Copland on 30/10/2012\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2012 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.tgatocsimage;\n\n//========================================================================\n/// ImageContainer\n///\n/// Holds the loaded image data. All data is converted to RGBA format.\n//========================================================================\npublic class ImageContainer\n{\n\tpublic int[] adwImageData = null;\n\tpublic int dwWidth = 0;\n\tpublic int dwHeight = 0;\n\tpublic int dwType = 0;\n\tpublic boolean bHasAlpha = false;\n}\n"
  },
  {
    "path": "Projects/Tools/TGAToCSImage/src/com/chilliworks/chillisource/tgatocsimage/Main.java",
    "content": "/**\n * Main.java\n * ChilliSource\n * Created by Ian Copland on 26/10/2012\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2012 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.tgatocsimage;\n\nimport com.chilliworks.chillisource.coreutils.Logging;\nimport com.chilliworks.chillisource.coreutils.Logging.LoggingLevel;\n\npublic class Main \n{\n\t//------------------------------------------------------\n\t/// Main\n\t///\n\t/// The entry point for the application. This processes\n\t/// the inputs and relays them onto the rest of the\n\t/// application.\n\t///\n\t/// @param The array of input strings.\n\t//------------------------------------------------------\n\tpublic static void main(String inastrArgs[]) throws Exception \n\t{\t\n\t\t//setup the logger.\n\t\tString[] arguments = Logging.start(inastrArgs);\n\t\t\n\t\t//check the number of arguments make sense.\n\t\tif(arguments.length < 2)\n\t\t{\n\t\t\tPrintHelpText();\n\t\t\treturn;\n\t\t}\n\t\t\n\t\t//Collect params\n\t\tTGAToCSImageOptions options = new TGAToCSImageOptions();\n\t\tfor(int i = 0; i < arguments.length; ++i)\n\t\t{\n\t\t\t//input\n\t\t\tif(arguments[i].equalsIgnoreCase(\"-i\") == true || arguments[i].equalsIgnoreCase(\"--input\") == true)\n\t\t\t{\n\t\t\t\tif (i + 1 < arguments.length)\n\t\t\t\t\toptions.strInputFilename = arguments[i + 1];\n\t\t\t\telse\n\t\t\t\t\tLogging.logFatal(\"No input path provided!\");\n\t\t\t\ti++;\n\t\t\t}\n\t\t\t\n\t\t\t//output\n\t\t\telse if(arguments[i].equalsIgnoreCase(\"-o\") == true || arguments[i].equalsIgnoreCase(\"--output\") == true)\n\t\t\t{\n\t\t\t\tif (i + 1 < arguments.length)\n\t\t\t\t\toptions.strOutputFilename = arguments[i + 1];\n\t\t\t\telse\n\t\t\t\t\tLogging.logFatal(\"No output file provided!\");\n\t\t\t\ti++;\n\t\t\t}\n\t\t\t\n\t\t\t//convert\n\t\t\telse if(arguments[i].equalsIgnoreCase(\"-ct\") == true || arguments[i].equalsIgnoreCase(\"--convert\") == true)\n\t\t\t{\n\t\t\t\tif (i + 1 < arguments.length)\n\t\t\t\t\toptions.eConversionType = ConvertStringToConversionFormat(arguments[i + 1]);\n\t\t\t\telse\n\t\t\t\t\tLogging.logFatal(\"No conversion type provided!\");\n\t\t\t\ti++;\n\t\t\t}\n\t\t\t\n\t\t\t//convertalpha\n\t\t\telse if(arguments[i].equalsIgnoreCase(\"-cta\") == true || arguments[i].equalsIgnoreCase(\"--convertalpha\") == true)\n\t\t\t{\n\t\t\t\tif (i + 1 < arguments.length)\n\t\t\t\t\toptions.eConversionAlphaType = ConvertStringToConversionFormat(arguments[i + 1]);\n\t\t\t\telse\n\t\t\t\t\tLogging.logFatal(\"No conversion type provided!\");\n\t\t\t\ti++;\n\t\t\t}\n\t\t\t\n\t\t\t//convertnoalpha\n\t\t\telse if(arguments[i].equalsIgnoreCase(\"-ctna\") == true || arguments[i].equalsIgnoreCase(\"--convertnoalpha\") == true)\n\t\t\t{\n\t\t\t\tif (i + 1 < arguments.length)\n\t\t\t\t\toptions.eConversionNoAlphaType = ConvertStringToConversionFormat(arguments[i + 1]);\n\t\t\t\telse\n\t\t\t\t\tLogging.logFatal(\"No conversion type provided!\");\n\t\t\t\ti++;\n\t\t\t}\n\t\t\t\n\t\t\t//compression\n\t\t\telse if(arguments[i].equalsIgnoreCase(\"-cn\") == true || arguments[i].equalsIgnoreCase(\"--compression\") == true)\n\t\t\t{\n\t\t\t\tif (i + 1 < arguments.length)\n\t\t\t\t\toptions.eCompressionType = ConvertStringToCompressionFormat(arguments[i + 1]);\n\t\t\t\telse\n\t\t\t\t\tLogging.logFatal(\"No compression type provided!\");\n\t\t\t\ti++;\n\t\t\t}\n\t\t\t\n\t\t\t//disable premultiplied alpha\n\t\t\telse if(arguments[i].equalsIgnoreCase(\"-dpa\") == true || arguments[i].equalsIgnoreCase(\"--disablepremultipliedalpha\") == true)\n\t\t\t{\n\t\t\t\toptions.bPremultiply = false;\n\t\t\t}\n\t\t\t\n\t\t\t//dither\n\t\t\telse if(arguments[i].equalsIgnoreCase(\"-d\") == true || arguments[i].equalsIgnoreCase(\"--dither\") == true)\n\t\t\t{\n\t\t\t\toptions.bDither = true;\n\t\t\t}\n\n\t\t\t//failure\n\t\t\telse\n\t\t\t{\n\t\t\t\tLogging.logFatal(\"Invalid parameter found: \" + arguments[i]);\n\t\t\t}\n\t\t}\n\t\t\n\t\t// Confirm that the paramaters are valid.\n\t\tif(options.strInputFilename.equals(\"\"))\n\t\t\tLogging.logFatal(\"No input path provided.\");\n\t\tif (options.strOutputFilename.equals(\"\"))\n\t\t\tLogging.logFatal(\"No output file provided.\");\n\t\t\n\t\tTGAToCSImage.Run(options);\n\n\t\tLogging.finish();\n\t}\n\t//------------------------------------------------------\n\t/// Print Help Text\n\t///\n\t/// Prints out instructions on how to use this tool.\n\t//------------------------------------------------------\n\tprivate static void PrintHelpText()\n\t{\n\t\tLogging.setLoggingLevel(LoggingLevel.VERBOSE);\n\t\tLogging.logVerbose(\"Usage: java -jar TGAToCSImage.jar --input <filename> --output <filename> [--convert <type>] [--convertalpha <type>] [--convertnoalpha <type>] [--compression <type>] [--disablepremultipliedalpha] [--dither] [\" + Logging.PARAM_LOGGING_LEVEL + \" <level>] [--help]\");\n\t\tLogging.logVerbose(\" --input(-i): The path to the source image TGA.\");\n\t\tLogging.logVerbose(\" --output(-o): The path to the output image csimage.\");\n\t\tLogging.logVerbose(\" --convert(-ct): [Optional] The type to convert to.\");\n\t\tLogging.logVerbose(\" --convertalpha(-cta): [Optional] The type to convert images with alpha to.\");\n\t\tLogging.logVerbose(\" --convertnoalpha(-ctna): [Optional] The type to convert images without alpha to.\");\n\t\tLogging.logVerbose(\" --compression(-cn): [Optional] The compression type. The default is zlib compression.\");\n\t\tLogging.logVerbose(\" --disablepremultipliedalpha(-dpa): [Optional] If set the output image will not have it's alpha premultiplied.\");\n\t\tLogging.logVerbose(\" --dither('-d'): [Optional] Whether or not to dither if converting to a smaller image format.\");\n\t\tLogging.logVerbose(\" \" + Logging.PARAM_LOGGING_LEVEL + \"(\" + Logging.SHORT_PARAM_LOGGING_LEVEL + \"): [Optional] Sets the level of message to log.\");\n\t\tLogging.logVerbose(\" --help(-h): [Optional] Display this help message.\");\n\t\tLogging.logVerbose(\"Conversion Types:\");\n\t\tLogging.logVerbose(\" L8\");\n\t\tLogging.logVerbose(\" LA88\");\n\t\tLogging.logVerbose(\" RGB565\");\n\t\tLogging.logVerbose(\" RGBA4444\");\n\t\tLogging.logVerbose(\" RGB888\");\n\t\tLogging.logVerbose(\" RGBA8888\");\n\t\tLogging.logVerbose(\"Compression Types:\");\n\t\tLogging.logVerbose(\" None\");\n\t\tLogging.logVerbose(\" Default\");\n\t\tLogging.logVerbose(\"Logging Levels:\");\n\t\tLogging.logVerbose(\" \" + Logging.LOGGING_LEVEL_NONE + \": No logging.\");\n\t\tLogging.logVerbose(\" \" + Logging.LOGGING_LEVEL_FATAL + \": Only log fatal errors.\");\n\t\tLogging.logVerbose(\" \" + Logging.LOGGING_LEVEL_ERROR + \": Only log errors.\");\n\t\tLogging.logVerbose(\" \" + Logging.LOGGING_LEVEL_WARNING + \": Log errors and warnings.\");\n\t\tLogging.logVerbose(\" \" + Logging.LOGGING_LEVEL_VERBOSE + \": Log all messages.\");\n\t}\n\t//------------------------------------------------------\n\t/// Convert String To Conversion Format\n\t///\n\t/// @return the Conversion Format equivalent to the given\n\t/// string.\n\t//------------------------------------------------------\n\tpublic static TGAToCSImageOptions.OUTPUT_FORMAT ConvertStringToConversionFormat(String instrString)\n\t{\n\t\tif (instrString.equalsIgnoreCase(\"L8\") == true)\n\t\t\treturn TGAToCSImageOptions.OUTPUT_FORMAT.L8;\n\t\tif (instrString.equalsIgnoreCase(\"LA88\") == true)\n\t\t\treturn TGAToCSImageOptions.OUTPUT_FORMAT.LA88;\n\t\tif (instrString.equalsIgnoreCase(\"RGB565\") == true)\n\t\t\treturn TGAToCSImageOptions.OUTPUT_FORMAT.RGB565;\n\t\tif (instrString.equalsIgnoreCase(\"RGBA4444\") == true)\n\t\t\treturn TGAToCSImageOptions.OUTPUT_FORMAT.RGBA4444;\n\t\tif (instrString.equalsIgnoreCase(\"RGB888\") == true)\n\t\t\treturn TGAToCSImageOptions.OUTPUT_FORMAT.RGB888;\n\t\tif (instrString.equalsIgnoreCase(\"RGBA8888\") == true)\n\t\t\treturn TGAToCSImageOptions.OUTPUT_FORMAT.RGBA8888;\n\t\t\n\t\tLogging.logWarning(\"No valid conversion format found. Will default to the image's format.\");\n\t\treturn TGAToCSImageOptions.OUTPUT_FORMAT.NONE;\n\t}\n\t//------------------------------------------------------\n\t/// Convert String To Compression Format\n\t///\n\t/// @return the Conversion Format equivalent to the given\n\t/// string.\n\t//------------------------------------------------------\n\tpublic static TGAToCSImageOptions.COMPRESSION_FORMAT ConvertStringToCompressionFormat(String instrString)\n\t{\n\t\tif (instrString.equalsIgnoreCase(\"Default\"))\n\t\t\treturn TGAToCSImageOptions.COMPRESSION_FORMAT.DEFAULT_ZLIB;\n\t\telse if (instrString.equalsIgnoreCase(\"None\"))\n\t\t\treturn TGAToCSImageOptions.COMPRESSION_FORMAT.NONE;\n\t\t\n\t\tLogging.logWarning(\"No valid compression format found. Image will not be compressed.\");\n\t\treturn TGAToCSImageOptions.COMPRESSION_FORMAT.NONE;\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/TGAToCSImage/src/com/chilliworks/chillisource/tgatocsimage/TGAToCSImage.java",
    "content": "/**\n * TGAToMoImage.java\n * ChilliSource\n * Created by Scott Downie on 26/10/2012\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2012 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.tgatocsimage;\nimport java.awt.image.BufferedImage;\nimport java.io.ByteArrayOutputStream;\nimport java.io.File;\nimport java.io.FileOutputStream;\nimport java.io.IOException;\nimport java.util.zip.CRC32;\nimport java.util.zip.Deflater;\n\nimport javax.imageio.ImageIO;\nimport javax.imageio.spi.IIORegistry;\n\nimport com.chilliworks.chillisource.coreutils.Logging;\n\n//============================================================================\n/// TGA To MoImage\n///\n/// Handles all tga conversions to the various csimage formats.\n///\n/// Version History\n///\n/// 2 - First release version, no comporession @auther SDownie\n/// 3 - Added default zlib comporession @author RHenning\n//============================================================================\npublic class TGAToCSImage \n{\n\t//------------------------------------------------------------------------\n\t/// Constants\n\t//------------------------------------------------------------------------\n\tprivate final static int kdwVersion = 3;\n\t\n\tprivate static long mTGAFileSize = 0;\n\t\n\t//------------------------------------------------------------------------\n\t/// Run\n\t///\n\t/// Converts a TGA to MoImage format based upon the given options.\n\t//------------------------------------------------------------------------\n\tpublic static void Run(TGAToCSImageOptions inOptions) throws IOException\n\t{\n\t\tIIORegistry registry = IIORegistry.getDefaultInstance();\n\t\tregistry.registerServiceProvider(new com.realityinteractive.imageio.tga.TGAImageReaderSpi());\n\t\t\n\t\tlong ddwCRC = 0;\n\t\tint dwOriginalDataSize = 0;\n\t\t\n\t\t//Open the tga\n\t\tImageContainer image = null;\n\t\ttry \n\t\t{\n\t\t\tLogging.logVerbose(\"Loading TGA...\");\n\t\t\tString strInputFile = inOptions.strInputFilename;\n\t\t\tLogging.logVerbose(\"Input File: \" + strInputFile);\n\t\t\timage = LoadTGA(strInputFile);\n\t\t\tLogging.logVerbose(\"Loading TGA Complete\");\n\t\t} \n\t\tcatch (IOException e) \n\t\t{\n\t\t\tLogging.logVerbose(\"Cannot load TGA file\");\n\t\t\te.printStackTrace();\n\t\t\treturn;\n\t\t}\n\t\t\n\t\t//pre multiply data if required\n\t\tboolean bPreMultiply = inOptions.bPremultiply;\n\t\tif(image.bHasAlpha && bPreMultiply == true)\n\t\t{\n\t\t\tLogging.logVerbose(\"Premultiplying Alpha...\");\n\t\t\tPreMultiplyImage(image);\n\t\t\tLogging.logVerbose(\"Premultiplying Alpha Complete\");\n\t\t}\n\t\t\n\t\t//build the image data in the output format\n\t\tLogging.logVerbose(\"Building Image Data...\");\n\t\tTGAToCSImageOptions.OUTPUT_FORMAT imageFormat = GetOutputFormat(inOptions, image);\n\t\tboolean bDithering = inOptions.bDither;\n\t\tbyte[] outImageData = ConvertImageToFormat(image, imageFormat, bDithering);\n\t\tif(outImageData == null)\n\t\t{\n\t\t\treturn;\n\t\t}\n\t\tdwOriginalDataSize = outImageData.length;\n\t\tLogging.logVerbose(\"Building Image Data Complete\");\n\n\t\t//Perform compression if required\n\t\tif (inOptions.eCompressionType != TGAToCSImageOptions.COMPRESSION_FORMAT.NONE)\n\t\t{\n\t\t\tCRC32 checksum = new CRC32();\n\t\t\tchecksum.update(outImageData);\n\t\t\tddwCRC = checksum.getValue();\n\t\t\t\n\t\t\tLogging.logVerbose(\"Compressing Image...\");\n\t\t\toutImageData = CompressImage(inOptions, outImageData);\n\t\t\tLogging.logVerbose(\"Compressing Image Complete\");\n\t\t}\n\t\t\n\t\t//Create header and output\n\t\ttry \n\t\t{\n\t\t\tLogging.logVerbose(\"Outputting MoImage...\");\n\t\t\tString strOutputFile = inOptions.strOutputFilename;\n\t\t\tLogging.logVerbose(\"Output File: \" + strOutputFile);\n\t\t\tOutputMoImage(outImageData, imageFormat, inOptions.eCompressionType, ddwCRC, dwOriginalDataSize, image.dwWidth, image.dwHeight, strOutputFile);\n\t\t\tLogging.logVerbose(\"Outputting MoImage Complete\");\n\t\t} \n\t\tcatch (IOException e) \n\t\t{\n\t\t\tLogging.logVerbose(\"Cannot output moimage file\");\n\t\t\te.printStackTrace();\n\t\t\treturn;\n\t\t}\n\t}\n\t//------------------------------------------------------------------------\n\t/// Load TGA\n\t///\n\t/// Loads the given TGA.\n\t//------------------------------------------------------------------------\n\tprivate static ImageContainer LoadTGA(String instrPath) throws IOException\n\t{\n\t\tif(instrPath == null)\n\t\t{\n\t\t\tthrow new IOException();\n\t\t}\n\n\t\tFile imageFile = new File(instrPath);\n\t\tmTGAFileSize = imageFile.length();\n\t\t\n\t\tBufferedImage image = ImageIO.read(imageFile);\n\t\tImageContainer imageContainer = new ImageContainer();\n\t\timageContainer.dwWidth = image.getWidth();\n\t\timageContainer.dwHeight = image.getHeight();\n\t\timageContainer.dwType = image.getType();\n\t\timageContainer.bHasAlpha = image.getColorModel().hasAlpha();\n\t\timageContainer.adwImageData = new int[imageContainer.dwWidth * imageContainer.dwHeight];\n\t\t\n\t\tswitch (imageContainer.dwType)\n\t\t{\n\t\tcase BufferedImage.TYPE_BYTE_GRAY:\n\t\t\tif (imageContainer.bHasAlpha == false)\n\t\t\t\tBuildImageL8(imageContainer, image);\n\t\t\telse\n\t\t\t\tBuildImageLA88(imageContainer, image);\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tBuildImageDefault(imageContainer, image);\t\n\t\t}\n\t\t\n\t\treturn imageContainer;\n\t}\n\t//------------------------------------------------------------------------\n\t/// Build Image Default\n\t///\n\t/// The default image builder. Simply uses getRGB() to get the image data\n\t//------------------------------------------------------------------------\n\tprivate static void BuildImageDefault(ImageContainer inImageContainer, BufferedImage inImage)\n\t{\n\t\tfor (int x = 0; x < inImageContainer.dwWidth; ++x)\n\t\t{\n\t\t\tfor (int y = 0; y < inImageContainer.dwHeight; ++y)\n\t\t\t{\n\t\t\t\tint dwIndex = x + y * inImageContainer.dwWidth;\n\t\t\t\tinImageContainer.adwImageData[dwIndex] = inImage.getRGB(x, y);\n\t\t\t}\n\t\t}\n\t}\n\t//------------------------------------------------------------------------\n\t/// Build Image L8\n\t///\n\t/// The default image builder. Simply uses getRGB() to get the image data\n\t//------------------------------------------------------------------------\n\tprivate static void BuildImageL8(ImageContainer inImageContainer, BufferedImage inImage)\n\t{\n\t\tfor (int x = 0; x < inImageContainer.dwWidth; ++x)\n\t\t{\n\t\t\tfor (int y = 0; y < inImageContainer.dwHeight; ++y)\n\t\t\t{\n\t\t\t\tint dwIndex = x + y * inImageContainer.dwWidth;\n\t\t\t\tint dwL = inImage.getRaster().getSample(x, y, 0);\n\t\t\t\tint dwCombined \t = (dwL << 0);\n\t\t\t\tdwCombined \t\t|= (dwL << 8);\n\t\t\t\tdwCombined \t\t|= (dwL << 16);\n\t\t\t\tdwCombined \t\t|= (0xFF << 24);\n\t\t\t\tinImageContainer.adwImageData[dwIndex] = dwCombined;\n\t\t\t}\n\t\t}\n\t}\n\t//------------------------------------------------------------------------\n\t/// Build Image LA88\n\t///\n\t/// The default image builder. Simply uses getRGB() to get the image data\n\t//------------------------------------------------------------------------\n\tprivate static void BuildImageLA88(ImageContainer inImageContainer, BufferedImage inImage)\n\t{\n\t\tfor (int x = 0; x < inImageContainer.dwWidth; ++x)\n\t\t{\n\t\t\tfor (int y = 0; y < inImageContainer.dwHeight; ++y)\n\t\t\t{\n\t\t\t\tint dwIndex = x + y * inImageContainer.dwWidth;\n\t\t\t\tint dwL = inImage.getRaster().getSample(x, y, 0);\n\t\t\t\tint dwA = inImage.getRaster().getSample(x, y, 1);\n\t\t\t\tint dwCombined \t = (dwL << 0);\n\t\t\t\tdwCombined \t\t|= (dwL << 8);\n\t\t\t\tdwCombined \t\t|= (dwL << 16);\n\t\t\t\tdwCombined \t\t|= (dwA << 24);\n\t\t\t\tinImageContainer.adwImageData[dwIndex] = dwCombined;\n\t\t\t}\n\t\t}\n\t}\n\t//------------------------------------------------------------------------\n\t/// Get Output Format\n\t///\n\t/// @return the output format, based upon the given params and the type\n\t/// of the given image.\n\t//------------------------------------------------------------------------\n\tprivate static TGAToCSImageOptions.OUTPUT_FORMAT GetOutputFormat(TGAToCSImageOptions inOptions, ImageContainer inImage)\n\t{\n\t\t//if it has conversion type format, force output to this.\n\t\tif (inOptions.eConversionType != TGAToCSImageOptions.OUTPUT_FORMAT.NONE)\n\t\t\treturn inOptions.eConversionType;\n\t\t\n\t\t//if it has alpha and a alpha image conversion type then use this type.\n\t\tif (inImage.bHasAlpha == true && inOptions.eConversionAlphaType != TGAToCSImageOptions.OUTPUT_FORMAT.NONE)\n\t\t\treturn inOptions.eConversionAlphaType;\n\t\t\t\t\t\n\t\t//if it has no alpha and a no alpha image conversion type then use this type.\n\t\tif (inImage.bHasAlpha == false && inOptions.eConversionNoAlphaType != TGAToCSImageOptions.OUTPUT_FORMAT.NONE)\n\t\t\treturn inOptions.eConversionNoAlphaType;\n\n\t\t//otherwise fall back on the type the image already is.\n\t\tswitch (inImage.dwType)\n\t\t{\n\t\tcase BufferedImage.TYPE_BYTE_GRAY:\n\t\t\tif (inImage.bHasAlpha == false)\n\t\t\t\treturn TGAToCSImageOptions.OUTPUT_FORMAT.L8;\n\t\t\telse\n\t\t\t\treturn TGAToCSImageOptions.OUTPUT_FORMAT.LA88;\n\t\tcase BufferedImage.TYPE_BYTE_BINARY:\n\t\tcase BufferedImage.TYPE_3BYTE_BGR:\n\t\tcase BufferedImage.TYPE_4BYTE_ABGR:\n\t\tcase BufferedImage.TYPE_BYTE_INDEXED:\n\t\tcase BufferedImage.TYPE_INT_ARGB:\n\t\tcase BufferedImage.TYPE_INT_ARGB_PRE:\n\t\tcase BufferedImage.TYPE_INT_BGR:\n\t\tcase BufferedImage.TYPE_INT_RGB:\n\t\tcase BufferedImage.TYPE_CUSTOM:\n\t\t\tif (inImage.bHasAlpha == false)\n\t\t\t\treturn TGAToCSImageOptions.OUTPUT_FORMAT.RGB888;\n\t\t\telse\n\t\t\t\treturn TGAToCSImageOptions.OUTPUT_FORMAT.RGBA8888;\n\t\tdefault:\n\t\t\treturn TGAToCSImageOptions.OUTPUT_FORMAT.NONE;\t\n\t\t}\n\t}\n\t//------------------------------------------------------------------------\n\t/// PreMultiply Image\n\t///\n\t/// Pre multiplies the alpha of the given image.\n\t//------------------------------------------------------------------------\n\tprivate static void PreMultiplyImage(ImageContainer inImage)\n\t{\n\t\tint numPixels = inImage.dwWidth * inImage.dwHeight; \n\n\t\tfor(int pixel=0; pixel<numPixels; ++pixel)\n\t\t{\n\t\t\tint rgba = inImage.adwImageData[pixel];\n\t\t\t\n\t\t\tfinal int A = (rgba >>> 24 \t& 0xFF); \n\t\t\tfinal int R = CalculatePremultipliedAlpha(rgba >>> 16 & 0xFF, A); \n\t\t\tfinal int G = CalculatePremultipliedAlpha(rgba >>>  8 & 0xFF, A); \n\t\t\tfinal int B = CalculatePremultipliedAlpha(rgba >>>  0 & 0xFF, A);\n\t\t\t\n\t\t\trgba = \t(A & 0xFF) << 24 |\n\t\t\t\t\t(R & 0xFF) << 16 |\n\t\t\t\t\t(G & 0xFF) << 8  | \n\t\t\t\t\t(B & 0xFF);\n\t\t\t\n\t\t\tinImage.adwImageData[pixel] = rgba;\n\t\t}\n\t}\n\t//------------------------------------------------------------------------\n\t/// Convert Image To Format\n\t///\n\t/// Converts the image to the  requested output format.\n\t//------------------------------------------------------------------------\n\tprivate static byte[] ConvertImageToFormat(ImageContainer inImage, TGAToCSImageOptions.OUTPUT_FORMAT inFormatFlag, boolean inbDither)\n\t{\n\t\tswitch (inFormatFlag)\n\t\t{\n\t\tcase L8:\n\t\t\treturn ConvertToL8(inImage);\n\t\tcase LA88:\n\t\t\treturn ConvertToLA88(inImage);\n\t\tcase RGB565:\n\t\t\tif(inImage.dwWidth % 2 > 0)\n\t\t\t{\n\t\t\t\tLogging.logError(\"Cannot convert an image that is not divisible by 2 to RGB565 Format.\");\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\treturn ConvertToRGB565(inImage, inbDither);\n\t\tcase RGBA4444:\n\t\t\tif(inImage.dwWidth % 2 > 0)\n\t\t\t{\n\t\t\t\tLogging.logError(\"Cannot convert an image that is not divisible by 2 to RGBA4444 Format.\");\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\treturn ConvertToRGBA4444(inImage, inbDither);\n\t\tcase RGB888:\n\t\t\treturn ConvertToRGB888(inImage); \n\t\tcase RGBA8888:\n\t\t\treturn ConvertToRGBA8888(inImage);\n\t\tcase NONE:\n\t\tdefault:\n\t\t\tLogging.logError(\"Invalid output format.\");\n\t\t\treturn null;\n\t\t}\n\t}\n\t//------------------------------------------------------------------------\n\t/// Convert To RGBA8888\n\t///\n\t/// Converts to format RGBA8888.\n\t//------------------------------------------------------------------------\n\tprivate static byte[] ConvertToRGBA8888(ImageContainer inImage)\n\t{\n\t\tLogging.logVerbose(\"Converting to RGBA8888\");\n\n\t\tint area = inImage.dwHeight * inImage.dwWidth;\n\t\tbyte[] outByteData = new byte[area * 4];\n\n\t\tint i = 0;\n\t\tfor(int pixel=0; pixel<area; i+=4, ++pixel)\n\t\t{\n\t\t\tfinal int rgba = inImage.adwImageData[pixel];\n\t\n\t\t\toutByteData[i+0] = (byte)(rgba >>> 16 & 0xFF); \n\t\t\toutByteData[i+1] = (byte)(rgba >>>  8 & 0xFF); \n\t\t\toutByteData[i+2] = (byte)(rgba >>>  0 & 0xFF);\n\t\t\toutByteData[i+3] = (byte)(rgba >>> 24 & 0xFF); \n\t\t}\n\n\t\treturn outByteData;\n\t}\n\t//------------------------------------------------------------------------\n\t/// Convert To RGB888\n\t///\n\t/// Converts to format RGB888.\n\t//------------------------------------------------------------------------\n\tprivate static byte[] ConvertToRGB888(ImageContainer inImage)\n\t{\n\t\tLogging.logVerbose(\"Converting to RGB888\");\n\n\t\tint area = inImage.dwHeight * inImage.dwWidth;\n\t\tbyte[] outByteData = new byte[area * 3];\n\n\t\tint i = 0;\n\t\tfor(int pixel=0; pixel<area; i+=3, ++pixel)\n\t\t{\n\t\t\tfinal int rgba = inImage.adwImageData[pixel];\n\n\t\t\toutByteData[i]   = (byte)(rgba >>> 16\t& 0xFF);\n\t\t\toutByteData[i+1] = (byte)(rgba >>> 8  \t& 0xFF);\n\t\t\toutByteData[i+2] = (byte)(rgba >>> 0 \t& 0xFF);\n\t\t}\n\n\t\treturn outByteData;\n\t}\n\t//------------------------------------------------------------------------\n\t/// Convert To L8\n\t///\n\t/// Converts to format L8.\n\t//------------------------------------------------------------------------\n\tprivate static byte[] ConvertToL8(ImageContainer inImage)\n\t{\n\t\tLogging.logVerbose(\"Converting to L8\");\n\t\tint area = inImage.dwHeight * inImage.dwWidth;\n\t\tbyte[] outByteData = new byte[area];\n\n\t\tint i = 0;\n\t\tfor(int pixel=0; pixel<area; i++, ++pixel)\n\t\t{\n\t\t\tfinal int rgba = inImage.adwImageData[pixel];\n\t\t\tint byR = (int)(rgba >>> 16\t& 0xFF);\n\t\t\tint byG = (int)(rgba >>> 8  & 0xFF);\n\t\t\tint byB = (int)(rgba >>> 0 \t& 0xFF);\n\t\t\tint dwSum = byR + byG + byB;\n\t\t\toutByteData[i] = (byte)(dwSum / 3);\n\t\t}\n\n\t\treturn outByteData;\n\t}\n\t//------------------------------------------------------------------------\n\t/// Convert To LA88\n\t///\n\t/// Converts to format LA88.\n\t//------------------------------------------------------------------------\n\tprivate static byte[] ConvertToLA88(ImageContainer inImage)\n\t{\n\t\tLogging.logVerbose(\"Converting to LA88\");\n\n\t\tint area = inImage.dwHeight * inImage.dwWidth;\n\t\tbyte[] outByteData = new byte[area * 2];\n\n\t\tint i = 0;\n\t\tfor(int pixel=0; pixel<area; i+=2, ++pixel)\n\t\t{\n\t\t\tfinal int rgba = inImage.adwImageData[pixel];\n\t\n\t\t\tint byR = (int)(rgba >>> 16 & 0xFF); \n\t\t\tint byG = (int)(rgba >>>  8 & 0xFF); \n\t\t\tint byB = (int)(rgba >>>  0 & 0xFF);\n\t\t\tint byA = (int)(rgba >>> 24 & 0xFF); \n\t\t\tint dwSum =  ((int)byR) + ((int)byG) + ((int)byB);\n\t\t\toutByteData[i + 0] = (byte)(dwSum / 3);\n\t\t\toutByteData[i + 1] = (byte)byA;\n\t\t}\n\n\t\treturn outByteData;\n\t}\n\t//------------------------------------------------------------------------\n\t/// Convert To RGB565\n\t///\n\t/// Converts to format RGB565.\n\t//------------------------------------------------------------------------\n\tprivate static byte[] ConvertToRGB565(ImageContainer inImage, boolean inDither)\n\t{\n\t\tLogging.logVerbose(\"Converting to RGB565\");\n\t\t\n\t\tif(inDither)\n\t\t{\n\t\t\tLogging.logVerbose(\"Dithering...\");\n\t\t}\n\n\t\tint area = inImage.dwHeight * inImage.dwWidth;\n\t\tbyte[] outByteData = new byte[area * 2];\n\n\t\tint i = 0;\n\t\tfor(int pixel=0; pixel<area; i+=2, ++pixel)\n\t\t{\n\t\t\tfinal int rgba =inImage.adwImageData[pixel];\n\t\t\t\n\t\t\tint oR = (rgba >>> 16 & 0xFF);\n\t\t\tint oG = (rgba >>>  8 & 0xFF);\n\t\t\tint oB = (rgba >>>  0 & 0xFF);\n\t\t\t\n\t\t\tint R = oR >>> 3;\n\t\t\tint G = oG >>> 2;\n\t\t\tint B = oB >>> 3;\n\t\t\t\n\t\t\tif(inDither)\n\t\t\t{\n\t\t\t\tDitherSierraLite(inImage, pixel % inImage.dwWidth, pixel / inImage.dwWidth, oR - (R<<3), oG - (G<<2), oB - (B<<3), 0);\n\t\t\t\t//DitherSierra3(inImage, pixel % inImage.getWidth(), pixel / inImage.getWidth(), oR - (R<<3), oG - (G<<2), oB - (B<<3), 0);\n\t\t\t}\n\n\t\t\tshort combined = (short) \n\t\t\t\t\t(\n\t\t\t\t\t\t(R << 11) | \n\t\t\t\t\t\t(G << 5)  | \n\t\t\t\t\t\t(B << 0)\n\t\t\t\t\t);\n\n\t\t\toutByteData[i]\t = (byte)(combined >>> 0  & 0xFF);\n\t\t\toutByteData[i+1] = (byte)(combined >>> 8  & 0xFF);\n\t\t}\n\n\t\treturn outByteData;\n\t}\n\t//------------------------------------------------------------------------\n\t/// Convert To RGBA4444\n\t///\n\t/// Converts to format RGBA4444.\n\t//------------------------------------------------------------------------\n\tprivate static byte[] ConvertToRGBA4444(ImageContainer inImage, boolean inDither)\n\t{\n\t\tLogging.logVerbose(\"Converting to RGBA4444\");\n\t\t\n\t\tif(inDither)\n\t\t{\n\t\t\tLogging.logVerbose(\"Dithering...\");\n\t\t}\n\n\t\tfinal int area = inImage.dwHeight * inImage.dwWidth;\n\t\tbyte[] outByteData = new byte[area * 2];\n\n\t\tint i = 0;\n\t\tfor(int pixel=0; pixel<area; i+=2, ++pixel)\n\t\t{\n\t\t\tint rgba = inImage.adwImageData[pixel];\n\n\t\t\tint oR = (rgba >>> 16 & 0xFF);\n\t\t\tint oG = (rgba >>>  8 & 0xFF);\n\t\t\tint oB = (rgba >>>  0 & 0xFF);\n\t\t\tint oA = (rgba >>> 24 & 0xFF);\n\n\t\t\tint R = oR >>> 4;\n\t\t\tint G = oG >>> 4;\n\t\t\tint B = oB >>> 4;\n\t\t\tint A = oA >>> 4;\n\t\t\t\n\t\t\tif(inDither)\n\t\t\t{\n\t\t\t\tDitherSierraLite(inImage, pixel % inImage.dwWidth, pixel / inImage.dwWidth, oR - (R<<4), oG - (G<<4), oB - (B<<4), oA - (A<<4));\n\t\t\t\t//DitherSierra3(inImage, pixel % inImage.getWidth(), pixel / inImage.getWidth(), oR - (R<<4), oG - (G<<4), oB - (B<<4), oA - (A<<4));\n\t\t\t}\n\n\t\t\tshort combined = \n\t\t\t\t\t(short) \n\t\t\t\t\t(\n\t\t\t\t\t\t(R << 12)| \n\t\t\t\t\t\t(G << 8) | \n\t\t\t\t\t\t(B << 4) | \n\t\t\t\t\t\t(A << 0)\n\t\t\t\t\t); \n\n\t\t\toutByteData[i]\t = (byte)(combined >>> 0  & 0xFF);\n\t\t\toutByteData[i+1] = (byte)(combined >>> 8  & 0xFF);\n\t\t}\n\n\t\treturn outByteData;\n\t}\n\t//------------------------------------------------------------------------\n\t/// Apply Error\n\t//------------------------------------------------------------------------\n\tprivate static int ApplyError(int rgba, float factor, int errorR, int errorG, int errorB, int errorA)\n\t{\n\t\tint a = (rgba >>> 24 & 0xFF);\n\t\tint r = (rgba >>> 16 & 0xFF); \n\t\tint g = (rgba >>> 8 & 0xFF); \n\t\tint b = (rgba \t\t& 0xFF);\n\t\t\n\n\t\tr+= (errorR * factor);\n\t\tr = r < 0 ? 0 : r;\n\t\tr = r > 255? 255 : r;\n\n\t\tg+= (errorG * factor);\n\t\tg = g < 0 ? 0 : g;\n\t\tg = g > 255? 255 : g;\n\n\t\tb+= (errorB * factor); \n\t\tb = b < 0 ? 0 : b;\n\t\tb = b > 255? 255 : b;\n\n\t\ta+= (errorA * factor);\n\t\ta = a < 0 ? 0 : a;\n\t\ta = a > 255? 255 : a;\n\n\t\treturn \t(a & 0xFF) << 24 |\n\t\t\t\t(r & 0xFF) << 16 |\n\t\t\t\t(g & 0xFF) << 8  | \n\t\t\t\t(b & 0xFF);\n\n\t}\n\t//------------------------------------------------------------------------\n\t/// Dither Sierra Lite\n\t//------------------------------------------------------------------------\n\tprivate static void DitherSierraLite(ImageContainer inImage, int x, int y, int errorR, int errorG, int errorB, int errorA )\n\t{\n\t\t//        *   2                          The Sierra-2-4A filter\n\t\t//    1   1               (1/4)\n\t\t\n\t\tif(x < inImage.dwWidth - 1)\n\t\t{\n\t\t\tint dwIndex = (x+1) + (y+0) * inImage.dwWidth;\n\t\t\tint rgba = inImage.adwImageData[dwIndex];\n\t\t\trgba = ApplyError(rgba, 2.0f/ 4.0f, errorR, errorG, errorB, errorA);\n\t\t\tinImage.adwImageData[dwIndex] = rgba;\n\t\t}\n\t\tif(y < inImage.dwHeight - 1)\n\t\t{\n\t\t\tint dwIndex = (x+0) + (y+1) * inImage.dwWidth;\n\t\t\tint rgba = inImage.adwImageData[dwIndex];\n\t\t\trgba = ApplyError(rgba, 1.0f/ 4.0f, errorR, errorG, errorB, errorA);\n\t\t\tinImage.adwImageData[dwIndex] = rgba;\n\t\t\t\n\t\t\tif(x > 0)\n\t\t\t{\n\t\t\t\tdwIndex = (x-1) + (y+1) * inImage.dwWidth;\n\t\t\t\trgba = inImage.adwImageData[dwIndex];\n\t\t\t\trgba = ApplyError(rgba, 1.0f/ 4.0f, errorR, errorG, errorB, errorA);\n\t\t\t\tinImage.adwImageData[dwIndex] = rgba;\n\t\t\t}\n\t\t}\n\t}\n//\t//------------------------------------------------------------------------\n//\t/// Dither Sierra 3\n//\t//------------------------------------------------------------------------\n//\tprivate static void DitherSierra3(BufferedImage inImage, int x, int y, int errorR, int errorG, int errorB, int errorA)\n//\t{\n//\t\t//        *   5   3                  The Sierra3 filter\n//\t\t//2   4   5   4   2\n//\t\t//    2   3   2       (1/32)\n//\t\t\n//\t\tif(x < inImage.getWidth() - 1)\n//\t\t{\n//\t\t\tint rgba = inImage.getRGB(x+1, y);\n//\t\t\trgba = ApplyError(rgba, 5.0f/ 32.0f, errorR, errorG, errorB, errorA);\n//\t\t\tinImage.setRGB(x+1, y, rgba);\n//\t\t\t\n//\t\t\tif(x < inImage.getWidth() - 2)\n//\t\t\t{\n//\t\t\t\trgba = inImage.getRGB(x+2, y);\n//\t\t\t\trgba = ApplyError(rgba, 3.0f/ 32.0f, errorR, errorG, errorB, errorA);\n//\t\t\t\tinImage.setRGB(x+2, y, rgba);\n//\t\t\t}\n//\t\t}\n//\t\t\n//\t\tif(y < inImage.getHeight() - 1)\n//\t\t{\n//\t\t\tint rgba = inImage.getRGB(x, y+1);\n//\t\t\trgba = ApplyError(rgba, 5.0f/ 32.0f, errorR, errorG, errorB, errorA);\n//\t\t\tinImage.setRGB(x, y+1, rgba);\n//\t\t\t\n//\t\t\tif(y < inImage.getHeight() - 2)\n//\t\t\t{\n//\t\t\t\trgba = inImage.getRGB(x, y+2);\n//\t\t\t\trgba = ApplyError(rgba, 3.0f/ 32.0f, errorR, errorG, errorB, errorA);\n//\t\t\t\tinImage.setRGB(x, y+2, rgba);\n//\t\t\t\t\n//\t\t\t\tif(x > 0)\n//\t\t\t\t{\n//\t\t\t\t\trgba = inImage.getRGB(x-1, y+2);\n//\t\t\t\t\trgba = ApplyError(rgba, 2.0f/ 32.0f, errorR, errorG, errorB, errorA);\n//\t\t\t\t\tinImage.setRGB(x-1, y+2, rgba);\n//\t\t\t\t}\n//\t\t\t\t\n//\t\t\t\tif(x < inImage.getWidth() - 1)\n//\t\t\t\t{\n//\t\t\t\t\trgba = inImage.getRGB(x+1, y+2);\n//\t\t\t\t\trgba = ApplyError(rgba, 2.0f/ 32.0f, errorR, errorG, errorB, errorA);\n//\t\t\t\t\tinImage.setRGB(x+1, y+2, rgba);\n//\t\t\t\t}\n//\t\t\t}\n//\t\t\t\n//\t\t\tif(x > 0)\n//\t\t\t{\n//\t\t\t\trgba = inImage.getRGB(x-1, y+1);\n//\t\t\t\trgba = ApplyError(rgba, 4.0f/ 32.0f, errorR, errorG, errorB, errorA);\n//\t\t\t\tinImage.setRGB(x-1, y+1, rgba);\n//\t\t\t}\n//\t\t\t\n//\t\t\tif(x > 1)\n//\t\t\t{\n//\t\t\t\trgba = inImage.getRGB(x-2, y+1);\n//\t\t\t\trgba = ApplyError(rgba, 2.0f/ 32.0f, errorR, errorG, errorB, errorA);\n//\t\t\t\tinImage.setRGB(x-2, y+1, rgba);\n//\t\t\t}\n//\t\t\t\n//\t\t\tif(x < inImage.getWidth() - 1)\n//\t\t\t{\n//\t\t\t\trgba = inImage.getRGB(x+1, y+1);\n//\t\t\t\trgba = ApplyError(rgba, 4.0f/ 32.0f, errorR, errorG, errorB, errorA);\n//\t\t\t\tinImage.setRGB(x+1, y+1, rgba);\n//\t\t\t}\n//\t\t\t\n//\t\t\tif(x < inImage.getWidth() - 2)\n//\t\t\t{\n//\t\t\t\trgba = inImage.getRGB(x+2, y+1);\n//\t\t\t\trgba = ApplyError(rgba, 2.0f/ 32.0f, errorR, errorG, errorB, errorA);\n//\t\t\t\tinImage.setRGB(x+2, y+1, rgba);\n//\t\t\t}\n//\t\t}\n//\t}\n\t//------------------------------------------------------------------------\n\t/// Calculate Premultiplied Alpha\n\t///\n\t/// @return the premultiplied alpha value for the given pixel.\n\t//------------------------------------------------------------------------\n\tprivate static int CalculatePremultipliedAlpha(int inCol, int inAlpha)\n\t{\n\t\treturn (inCol*inAlpha)/255;\n\t}\n\t//------------------------------------------------------------------------\n\t/// Compress Image\n\t///\n\t/// @return compresses the image with the requested compression algorithm.\n\t//------------------------------------------------------------------------\n\tprivate static byte[] CompressImage(TGAToCSImageOptions inOptions, byte[] inImageData) throws IOException\n\t{\n\t\tif(inOptions.eCompressionType != TGAToCSImageOptions.COMPRESSION_FORMAT.DEFAULT_ZLIB)\n\t\t{\n\t\t\tLogging.logFatal(\"Unsupported compression. Image will not be compressed\");\n\t\t\treturn inImageData;\n\t\t}\n\t\t\n\t\t// Compression using zlib\n\t\tDeflater compresser = new Deflater();\n\t\tcompresser.setInput(inImageData);\n\t\tcompresser.finish();\n\n\t\tByteArrayOutputStream out = new ByteArrayOutputStream(inImageData.length);\n\t\tbyte[] byBuffer = new byte[8192]; // Write in 8K chunks\n\t\twhile(!compresser.finished())\n\t\t{\n\t\t\tint dwCompressedBytes = compresser.deflate(byBuffer);\n\t\t\tout.write(byBuffer, 0, dwCompressedBytes);\n\t\t}\n\t\tout.close();\n\n\t\tbyte[] abyCompressedImge = out.toByteArray();\n\n\t\treturn abyCompressedImge;\n\t}\n\t//------------------------------------------------------------------------\n\t/// Output MoImage\n\t///\n\t/// Outputs the generated csimage data to file.\n\t//------------------------------------------------------------------------\n\tprivate static void OutputMoImage(byte[] inImageData,\n\t\t\t\t\t\t\t\t\t  TGAToCSImageOptions.OUTPUT_FORMAT inFormat,\n\t\t\t\t\t\t\t\t\t  TGAToCSImageOptions.COMPRESSION_FORMAT inCompression,\n\t\t\t\t\t\t\t\t\t  long inddwChecksum, int indwOriginalSize,\n\t\t\t\t\t\t\t\t\t  int inWidth, int inHeight,\n\t\t\t\t\t\t\t\t\t  String instrOutputFile) throws IOException\n\t{\n\t\tif(instrOutputFile == null)\n\t\t{\n\t\t\tthrow new IOException();\n\t\t}\n\n\t\t///Apply the header\n\t\t// Byte order check - int\n\t\t// Version - int\n\t\t// Width - int\n\t\t// Height - int\n\t\t// Format - int\n\t\t// Compression - int\n\t\t// Checksum (CRC32)\n\t\t// Uncompressed data size\n\t\t// Final data size - int\n\t\tint byteOrderCheck = 123456;\n\t\tint version = kdwVersion;\n\t\tint compression = 0;\n\t\tif(inCompression == TGAToCSImageOptions.COMPRESSION_FORMAT.DEFAULT_ZLIB)\n\t\t\tcompression = 1;\n\t\t\n\t\t//Write out the data\n\t\tFileOutputStream fileStream = new FileOutputStream(instrOutputFile);\n\t\tWriteInt(fileStream, byteOrderCheck);\n\t\tWriteInt(fileStream, version);\n\t\tWriteInt(fileStream, inWidth);\n\t\tWriteInt(fileStream, inHeight);\n\t\tWriteInt(fileStream, inFormat.ordinal());\n\t\tWriteInt(fileStream, compression);\n\t\tWriteLong(fileStream, inddwChecksum);\n\t\tWriteInt(fileStream, indwOriginalSize);\n\t\tWriteInt(fileStream, inImageData.length);\n\t\t\n\t\tLogging.logVerbose(\"Completed writting file with header:\\n\\tOrderCheck:\"+byteOrderCheck\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t+\"\\n\\tVersion:\"+version\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t+\"\\n\\tWidth:\"+inWidth\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t+\"\\n\\tHeight:\"+inHeight\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t+\"\\n\\tFormat:\"+inFormat.ordinal()\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t+\"\\n\\tCompression:\"+compression\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t+\"\\n\\tChecksum:\"+inddwChecksum\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t+\"\\n\\tOriginalSize:\"+indwOriginalSize\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t+\"\\n\\tFinalSize:\"+inImageData.length);\n\t\t\n\t\tfileStream.write(inImageData);\n\t\tfileStream.close();\n\t\t\n\t\tFile imageFile = new File(instrOutputFile);\n\t\tLogging.logVerbose(\"MoImage: \" + instrOutputFile);\n\t\tLogging.logVerbose(\"TGA File Size: \" + Math.ceil((float)mTGAFileSize / (float)1024) + \" KB\");\n\t\tLogging.logVerbose(\"MoImage Uncompressed Size: \" + Math.ceil((float)indwOriginalSize / (float)1024) + \" KB\");\n\t\tLogging.logVerbose(\"MoImage File Size: \" + Math.ceil((float)imageFile.length() / (float)1024) + \" KB\");\n\t\tLogging.logVerbose(\"\");\n\t}\n\t//-------------------------------------------------------\n\t/// Write Integer\n\t///\n\t/// Writes a single Integer to the output stream.\n\t///\n\t/// @param the integer.\n\t//-------------------------------------------------------\n\tprivate static void WriteInt(FileOutputStream inStream, int indwData) throws IOException\n\t{\n\t\tinStream.write((byte)(indwData \t\t\t& 0xFF));\n\t\tinStream.write((byte)(indwData >>> 8 \t& 0xFF));\n\t\tinStream.write((byte)(indwData >>> 16 \t& 0xFF));\n\t\tinStream.write((byte)(indwData >>> 24\t& 0xFF));\n\t}\n\t//-------------------------------------------------------\n\t/// Write Long Integer\n\t///\n\t/// Writes a single Integer to the output stream.\n\t///\n\t/// @param the integer.\n\t//-------------------------------------------------------\n\tprivate static void WriteLong(FileOutputStream inStream, long indwData) throws IOException\n\t{\n\t\tinStream.write((byte)(indwData \t\t\t& 0xFF));\n\t\tinStream.write((byte)(indwData >>> 8 \t& 0xFF));\n\t\tinStream.write((byte)(indwData >>> 16 \t& 0xFF));\n\t\tinStream.write((byte)(indwData >>> 24\t& 0xFF));\n\t\tinStream.write((byte)(indwData >>> 32\t& 0xFF));\n\t\tinStream.write((byte)(indwData >>> 40\t& 0xFF));\n\t\tinStream.write((byte)(indwData >>> 48 \t& 0xFF));\n\t\tinStream.write((byte)(indwData >>> 56\t& 0xFF));\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/TGAToCSImage/src/com/chilliworks/chillisource/tgatocsimage/TGAToCSImageOptions.java",
    "content": "/**\n * Main.java\n * ChilliSource\n * Created by Ian Copland on 26/10/2012\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2012 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.tgatocsimage;\n\npublic class TGAToCSImageOptions \n{\n\t//--------------------------------------------------------------\n\t/// Image Format\n\t//--------------------------------------------------------------\n\tpublic enum OUTPUT_FORMAT\n\t{\n\t\tNONE,\n\t\tL8,\n\t\tLA88,\n\t\tRGB565,\n\t\tRGBA4444,\n\t\tRGB888,\n\t\tRGBA8888\n\t}\n\t//--------------------------------------------------------------\n\t/// Image Format\n\t//--------------------------------------------------------------\n\tpublic enum COMPRESSION_FORMAT\n\t{\n\t\tNONE,\n\t\tDEFAULT_ZLIB,\n\t}\n\t\n\tpublic String strInputFilename = new String();\n\tpublic String strOutputFilename = new String();\n\tpublic OUTPUT_FORMAT eConversionType = OUTPUT_FORMAT.NONE;\n\tpublic OUTPUT_FORMAT eConversionAlphaType = OUTPUT_FORMAT.NONE;\n\tpublic OUTPUT_FORMAT eConversionNoAlphaType = OUTPUT_FORMAT.NONE;\n\tpublic COMPRESSION_FORMAT eCompressionType = COMPRESSION_FORMAT.DEFAULT_ZLIB;\n\tpublic boolean bPremultiply = true;\n\tpublic boolean bDither = false;\n}\n"
  },
  {
    "path": "Projects/Tools/TexturePackerUtils/.classpath",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<classpath>\n\t<classpathentry kind=\"src\" path=\"src\"/>\n\t<classpathentry kind=\"con\" path=\"org.eclipse.jdt.launching.JRE_CONTAINER\"/>\n\t<classpathentry combineaccessrules=\"false\" kind=\"src\" path=\"/CoreUtils\"/>\n\t<classpathentry kind=\"output\" path=\"bin\"/>\n</classpath>\n"
  },
  {
    "path": "Projects/Tools/TexturePackerUtils/.gitignore",
    "content": "bin\n"
  },
  {
    "path": "Projects/Tools/TexturePackerUtils/.project",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<projectDescription>\n\t<name>TexturePackerUtils</name>\n\t<comment></comment>\n\t<projects>\n\t</projects>\n\t<buildSpec>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.jdt.core.javabuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t</buildSpec>\n\t<natures>\n\t\t<nature>org.eclipse.jdt.core.javanature</nature>\n\t</natures>\n</projectDescription>\n"
  },
  {
    "path": "Projects/Tools/TexturePackerUtils/src/com/chilliworks/chillisource/texturepackerutils/CollisionGrid.java",
    "content": "/**\n *  CollisionGrid.java\n *  ChilliSource\n *  Created by Robert Henning on 17/06/2014.\n *\n *  The MIT License (MIT)\n *\n *  Copyright (c) 2014 Tag Games Limited\n *\n *  Permission is hereby granted, free of charge, to any person obtaining a copy\n *  of this software and associated documentation files (the \"Software\"), to deal\n *  in the Software without restriction, including without limitation the rights\n *  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n *  copies of the Software, and to permit persons to whom the Software is\n *  furnished to do so, subject to the following conditions:\n *\n *  The above copyright notice and this permission notice shall be included in\n *  all copies or substantial portions of the Software.\n *\n *  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n *  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n *  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n *  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n *  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n *  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n *  THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.texturepackerutils;\n\nimport java.util.ArrayList;\nimport java.util.HashMap;\n\n/**\n * Simple class to implement a collision grid that uses spatial hashing\n * to reduce collision checks\n * Defaults to 64x64 grid sizes\n * \n * @author S McGaw\n */\npublic class CollisionGrid\n{\n\tCollisionGrid(int inGridSize)\n\t{\n\t\tmGridSize = inGridSize;\n\t}\n\n\tpublic void AddRectangle(Rectangle inRect)\n\t{\n\t\tint xStart = inRect.left() / mGridSize;\n\t\tint xEnd = (inRect.right() + mGridSize-1)/mGridSize;\n\n\t\tint yStart = inRect.top() / mGridSize;\n\t\tint yEnd = (inRect.bottom() + mGridSize-1)/mGridSize;\n\n\t\tfor(int y = yStart; y < yEnd; y++)\n\t\t\tfor(int x = xStart; x < xEnd; x++)\n\t\t\t{\n\t\t\t\tint hash = y <<16 | x;\n\t\t\t\tArrayList<Rectangle> list = null;\n\t\t\t\tif(mapGridSections.containsKey(hash ) == false)\n\t\t\t\t{\n\t\t\t\t\tlist = new ArrayList<Rectangle>();\n\t\t\t\t\tmapGridSections.put(hash, list);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t\tlist = mapGridSections.get(hash);\n\n\t\t\t\tlist.add(inRect);\n\t\t\t}\n\t}\n\n\tpublic boolean GetIntersecting(Rectangle inRect, ArrayList<Rectangle> outCollisions)\n\t{\n\t\tint xStart = inRect.left() / mGridSize;\n\t\tint xEnd = (inRect.right() + mGridSize-1)/mGridSize;\n\n\t\tint yStart = inRect.top() / mGridSize;\n\t\tint yEnd = (inRect.bottom() + mGridSize-1)/mGridSize;\n\n\t\tfor(int y = yStart; y < yEnd; y++)\n\t\t\tfor(int x = xStart; x < xEnd; x++)\n\t\t\t{\n\t\t\t\tint hash = y <<16 | x;\n\t\t\t\tArrayList<Rectangle> list = mapGridSections.get(hash);\n\n\t\t\t\tif(list == null)\n\t\t\t\t\tcontinue;\n\n\t\t\t\tfor(Rectangle test : list)\n\t\t\t\t\tif(inRect.intersects(test))\n\t\t\t\t\t\toutCollisions.add(test);\n\t\t\t}\n\n\t\treturn outCollisions.isEmpty() == false;\n\t} \n\n\tpublic void Clear()\n\t{\n\t\tmapGridSections.clear();\n\t}\n\n\tHashMap<Integer, ArrayList<Rectangle> > mapGridSections = new HashMap<Integer, ArrayList<Rectangle> >() ;\n\tint mGridSize = 64;\n}\n"
  },
  {
    "path": "Projects/Tools/TexturePackerUtils/src/com/chilliworks/chillisource/texturepackerutils/PackedTexture.java",
    "content": "/**\n *  PackedTexture.java\n *  ChilliSource\n *  Created by Robert Henning on 17/06/2014.\n *\n *  The MIT License (MIT)\n *\n *  Copyright (c) 2014 Tag Games Limited\n *\n *  Permission is hereby granted, free of charge, to any person obtaining a copy\n *  of this software and associated documentation files (the \"Software\"), to deal\n *  in the Software without restriction, including without limitation the rights\n *  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n *  copies of the Software, and to permit persons to whom the Software is\n *  furnished to do so, subject to the following conditions:\n *\n *  The above copyright notice and this permission notice shall be included in\n *  all copies or substantial portions of the Software.\n *\n *  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n *  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n *  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n *  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n *  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n *  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n *  THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.texturepackerutils;\n\nimport java.awt.image.BufferedImage;\nimport java.io.File;\n\n/**\n * Holds the result of the texture packing process\n * \n * @author R Henning\n */\npublic class PackedTexture \n{\n\tprivate int m_numImages = 0;\n\tprivate int m_packedWidth = 0;\n\tprivate int m_packedHeight = 0;\n\tprivate BufferedImage m_image = null;\n\t\n\tprivate int m_originalImageHeights[];\n\tprivate int m_originalImageWidths[];\n\tprivate int m_croppedImageHeights[];\n\tprivate int m_croppedImageWidths[];\n\tprivate int m_imageOffsetXs[];\n\tprivate int m_imageOffsetYs[];\n\tprivate Rectangle m_imageRects[];\n\tprivate File[] m_files;\n\tprivate int m_dataOrderKeys[];\n\tprivate int m_nameOrderKeys[];\n\t\n\t/**\n\t * Constructor\n\t * \n\t * @author S Downie\n\t * \n\t * @param Image\n\t * @param Num images\n\t * @param Packed width\n\t * @param Packed height\n\t * @param Widths\n\t * @param Heights\n\t * @param Cropped widths\n\t * @param Cropped heights\n\t * @param X offsets\n\t * @param Y offsets\n\t * @param Rects\n\t * @param Files\n\t * @param Data order keys\n\t * @param File order keys\n\t */\n\tpublic PackedTexture(BufferedImage in_image, int in_numImages, int in_packedWidth, int in_packedHeight, \n\t\t\tint[] in_originalWidths, int[] in_originalHeights, int[] in_cropWidths, int[] in_cropHeights, \n\t\t\tint[] in_offsetsX, int[] in_offsetsY,\n\t\t\tRectangle[] in_imageRects,\n\t\t\tFile[] in_files, \n\t\t\tint[] in_dataOrderKeys, int[] in_nameOrderKeys)\n\t{\n\t\tm_image = in_image;\n\t\tm_numImages = in_numImages;\n\t\tm_packedWidth = in_packedWidth;\n\t\tm_packedHeight = in_packedHeight;\n\t\tm_originalImageWidths = in_originalWidths;\n\t\tm_originalImageHeights = in_originalHeights;\n\t\tm_croppedImageWidths = in_cropWidths;\n\t\tm_croppedImageHeights = in_cropHeights;\n\t\tm_imageOffsetXs = in_offsetsX;\n\t\tm_imageOffsetYs = in_offsetsY;\n\t\tm_imageRects = in_imageRects;\n\t\tm_files = in_files;\n\t\tm_dataOrderKeys = in_dataOrderKeys;\n\t\tm_nameOrderKeys = in_nameOrderKeys;\n\t}\n\t/**\n\t* @author S Downie\n\t*\n\t* @return Num packed images\n\t*/\n\tpublic int getNumImages()\n\t{\n\t\treturn m_numImages;\n\t}\n\t/**\n\t* @author S Downie\n\t*\n\t* @return Width of packed image\n\t*/\n\tpublic int getPackedWidth()\n\t{\n\t\treturn m_packedWidth;\n\t}\n\t/**\n\t* @author S Downie\n\t*\n\t* @return Height of packed image\n\t*/\n\tpublic int getPackedHeight()\n\t{\n\t\treturn m_packedHeight;\n\t}\n\t/**\n\t* @author S Downie\n\t*\n\t* @return Packed image\n\t*/\n\tpublic BufferedImage getPackedTexture()\n\t{\n\t\treturn m_image;\n\t}\n\t/**\n\t* @author S Downie\n\t*\n\t* @param Image index\n\t* \n\t* @return X offset for image at index\n\t*/\n\tpublic int getOffsetX(int in_index)\n\t{\n\t\treturn m_imageOffsetXs[m_dataOrderKeys[in_index]];\n\t}\n\t/**\n\t* @author S Downie\n\t*\n\t* @param Image index\n\t* \n\t* @return Y offset for image at index\n\t*/\n\tpublic int getOffsetY(int in_index)\n\t{\n\t\treturn m_imageOffsetYs[m_dataOrderKeys[in_index]];\n\t}\n\t/**\n\t* @author S Downie\n\t*\n\t* @param Image index\n\t* \n\t* @return Width of cropped image at index\n\t*/\n\tpublic int getCroppedWidth(int in_index)\n\t{\n\t\treturn m_croppedImageWidths[m_dataOrderKeys[in_index]];\n\t}\n\t/**\n\t* @author S Downie\n\t*\n\t* @param Image index\n\t* \n\t* @return Height of cropped image at index\n\t*/\n\tpublic int getCroppedHeight(int in_index)\n\t{\n\t\treturn m_croppedImageHeights[m_dataOrderKeys[in_index]];\n\t}\n\t/**\n\t* @author S Downie\n\t*\n\t* @param Image index\n\t* \n\t* @return Width of original image at index\n\t*/\n\tpublic int getOriginalWidth(int in_index)\n\t{\n\t\treturn m_originalImageWidths[m_dataOrderKeys[in_index]];\n\t}\n\t/**\n\t* @author S Downie\n\t*\n\t* @param Image index\n\t* \n\t* @return Height of original image at index\n\t*/\n\tpublic int getOriginalHeight(int in_index)\n\t{\n\t\treturn m_originalImageHeights[m_dataOrderKeys[in_index]];\n\t}\n\t/**\n\t* @author S Downie\n\t*\n\t* @param Image index\n\t* \n\t* @return X origin (left) of image at index\n\t*/\n\tpublic int getOriginX(int in_index)\n\t{\n\t\treturn m_imageRects[m_dataOrderKeys[in_index]].x;\n\t}\n\t/**\n\t* @author S Downie\n\t*\n\t* @param Image index\n\t* \n\t* @return Y origin (top) of image at index\n\t*/\n\tpublic int getOriginY(int in_index)\n\t{\n\t\treturn m_imageRects[m_dataOrderKeys[in_index]].y;\n\t}\n\t/**\n\t* @author S Downie\n\t*\n\t* @param Image index\n\t* \n\t* @return Original file for image at index\n\t*/\n\tpublic File getOriginalFile(int in_index)\n\t{\n\t\treturn m_files[m_nameOrderKeys[in_index]];\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/TexturePackerUtils/src/com/chilliworks/chillisource/texturepackerutils/PackerInfo.java",
    "content": "/**\n *  PackerInfo.java\n *  ChilliSource\n *  Created by Hugh McLaughlin on 21/08/2014.\n *\n *  The MIT License (MIT)\n *\n *  Copyright (c) 2014 Tag Games Limited\n *\n *  Permission is hereby granted, free of charge, to any person obtaining a copy\n *  of this software and associated documentation files (the \"Software\"), to deal\n *  in the Software without restriction, including without limitation the rights\n *  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n *  copies of the Software, and to permit persons to whom the Software is\n *  furnished to do so, subject to the following conditions:\n *\n *  The above copyright notice and this permission notice shall be included in\n *  all copies or substantial portions of the Software.\n *\n *  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n *  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n *  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n *  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n *  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n *  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n *  THE SOFTWARE.\n */\npackage com.chilliworks.chillisource.texturepackerutils;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\n/**\n * Class to allow the return of some error information \n * \n * @author HMcLaughlin\n */\npublic final class PackerInfo\n{\n\tpublic List<String> m_unfittingImages = new ArrayList<String>();//List of images that could not be fit on the 1 spritesheet\n\tpublic int m_requiredWidth;\n\tpublic int m_requiredHeight;\n}\n"
  },
  {
    "path": "Projects/Tools/TexturePackerUtils/src/com/chilliworks/chillisource/texturepackerutils/Rectangle.java",
    "content": "/**\n *  Rectangle.java\n *  ChilliSource\n *  Created by Robert Henning on 17/06/2014.\n *\n *  The MIT License (MIT)\n *\n *  Copyright (c) 2014 Tag Games Limited\n *\n *  Permission is hereby granted, free of charge, to any person obtaining a copy\n *  of this software and associated documentation files (the \"Software\"), to deal\n *  in the Software without restriction, including without limitation the rights\n *  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n *  copies of the Software, and to permit persons to whom the Software is\n *  furnished to do so, subject to the following conditions:\n *\n *  The above copyright notice and this permission notice shall be included in\n *  all copies or substantial portions of the Software.\n *\n *  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n *  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n *  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n *  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n *  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n *  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n *  THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.texturepackerutils;\n\n/**\n * Container that represents a rectangle with origin\n * at top left\n * \n * @author R Henning\n */\npublic class Rectangle\n{\n\tpublic int x = 0;\n\tpublic int y = 0;\n\tpublic int width = 0;\n\tpublic int height = 0;\n\n\t/**\n\t * Constructor\n\t * \n\t * @author R Henning\n\t */\n\tpublic Rectangle()\n\t{\n\n\t}\n\t/**\n\t * Constructor\n\t * \n\t * @author R Henning\n\t * \n\t * @param Left edge\n\t * @param Top edge\n\t * @param Width\n\t * @param Height\n\t */\n\tpublic Rectangle(int in_x, int in_y, int in_width, int in_height)\n\t{\n\t\tthis.x = in_x;\n\t\tthis.y = in_y;\n\t\tthis.width = in_width;\n\t\tthis.height = in_height;\n\t}\n\t/**\n\t * Copy constructor\n\t * \n\t * @author Ian Copland.\n\t */\n\tpublic Rectangle(Rectangle in_rectangle)\n\t{\n\t\tthis.x = in_rectangle.x;\n\t\tthis.y = in_rectangle.y;\n\t\tthis.width = in_rectangle.width;\n\t\tthis.height = in_rectangle.height;\n\t}\n\t/**\n\t * @author R Henning\n\t * \n\t * @return Left edge of the rectangle\n\t */\n\tpublic int left()\n\t{\n\t\treturn x;\n\t}\n\t/**\n\t * @author R Henning\n\t * \n\t * @return Right edge of the rectangle\n\t */\n\tpublic int right()\n\t{\n\t\treturn x + width;\n\t}\n\t/**\n\t * @author R Henning\n\t * \n\t * @return Top edge of the rectangle\n\t */\n\tpublic int top()\n\t{\n\t\treturn y;\n\t}\n\t/**\n\t * @author R Henning\n\t * \n\t * @return Bottom edge of the rectangle\n\t */\n\tpublic int bottom()\n\t{\n\t\treturn y + height;\n\t}\n\t/**\n\t * Tests if one rectangle intersects another\n\t * \n\t * @param Rectangle to test against\n\t * \n\t * @return Whether given rect intersects this one\n\t */\n\tpublic boolean intersects(Rectangle in_other)\n\t{\n\t\treturn !((in_other.left() >= this.right()) ||\n\t\t\t\t(in_other.right() <= this.left()) ||\n\t\t\t\t(in_other.top() >= this.bottom()) ||\n\t\t\t\t(in_other.bottom() <= this.top()));\n\t}\n}\n\n"
  },
  {
    "path": "Projects/Tools/TexturePackerUtils/src/com/chilliworks/chillisource/texturepackerutils/TexturePacker.java",
    "content": "/**\n *  TextureAtlasUtils.java\n *  ChilliSource\n *  Created by Robert Henning on 17/06/2014.\n *\n *  The MIT License (MIT)\n *\n *  Copyright (c) 2014 Tag Games Limited\n *\n *  Permission is hereby granted, free of charge, to any person obtaining a copy\n *  of this software and associated documentation files (the \"Software\"), to deal\n *  in the Software without restriction, including without limitation the rights\n *  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n *  copies of the Software, and to permit persons to whom the Software is\n *  furnished to do so, subject to the following conditions:\n *\n *  The above copyright notice and this permission notice shall be included in\n *  all copies or substantial portions of the Software.\n *\n *  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n *  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n *  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n *  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n *  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n *  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n *  THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.texturepackerutils;\n\nimport java.awt.image.BufferedImage;\nimport java.io.File;\nimport java.io.FileInputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.math.BigInteger;\nimport java.security.MessageDigest;\nimport java.util.ArrayList;\nimport java.util.Collections;\nimport java.util.HashMap;\nimport java.util.HashSet;\n\nimport javax.imageio.ImageIO;\n\nimport com.chilliworks.chillisource.coreutils.CSException;\nimport com.chilliworks.chillisource.coreutils.Logging;\n\n/**\n * Class that holds utility methos for packing images onto a single image to use the minimum\n * amount of space\n * \n * @author R Henning\n */\npublic class TexturePacker \n{\n\t/**\n\t * Predicates for choosing best placement point for a sprite out of two possibles\n\t * \n\t * @param The first placement point\n\t * @param The second placement point\n\t * \n\t * @returns True if first is better than second, false otherwise\n\t *\n\t */\n\tpublic enum PlacementHeuristic\n\t{\n\t\tTOPLEFT {\n\t\t\tpublic boolean ChooseBest(Rectangle inA, Rectangle inB )\n\t\t\t{\n\t\t\t\tint aLen = inA.left() * inA.left() + inA.top() * inA.top();\n\t\t\t\tint bLen = inB.left() * inB.left() + inB.top() * inB.top();\n\t\t\t\treturn aLen < bLen;\n\t\t\t}\n\t\t},\n\t\tBOTTOMRIGHT {\n\t\t\tpublic boolean ChooseBest(Rectangle inA, Rectangle inB )\n\t\t\t{\n\t\t\t\tint aLen = inA.right() * inA.right() + inA.bottom() * inA.bottom();\n\t\t\t\tint bLen = inB.right() * inB.right() + inB.bottom() * inB.bottom();\n\t\t\t\treturn aLen < bLen;\n\t\t\t}\n\t\t};\n\n\t\tabstract boolean ChooseBest(Rectangle inA, Rectangle inB );\n\t}\n\n\tint originalImageHeights[];\n\tint originalImageWidths[];\n\tint croppedImageHeights[];\n\tint croppedImageWidths[];\n\tint croppedImageArea[];\n\tint imageOffsetXs[];\n\tint imageOffsetYs[];\n\tint useGraphics[]; // Some indirections\n\tboolean matchFound[];\n\tBufferedImage[] imageFiles;\n\tint numPlacedImages=0;\n\tRectangle placedSpriteRects[];\n\tint combinedImageHeight;\n\tint combinedImageWidth;\n\tint numSourceImages = 0;\n\tFile[] sourceImageFiles;\n\tint namePointers[];\n\n\tHashSet<Rectangle> setSeenColliders = new HashSet<Rectangle>();\n\tCollisionGrid\t   gridCheck = new CollisionGrid(64);\n\t\n\tint fixedHeight = -1;\n\tint fixedWidth = -1;\n\tint validHeights[];\n\tint validWidths[];\n\tint numValidH = -1;\n\tint numValidW = -1;\n\tint maxWidth = -1;\n\tint maxHeight = -1;\n\tint minAreaWidth = -1;\n\tint minAreaHeight = -1;\n\tint divisibleBy = -1;\n\tint numPixelsPadding = 0;\n\tint innerPadding = 0;\n\tint extrude = 0;\n\tboolean cropImages = true;\t// When true we crop transparencies in the image\n\tPlacementHeuristic eBestPlacement = PlacementHeuristic.BOTTOMRIGHT;\n\t\n\tboolean m_ignoreFatalLogs = false;\n\t\n\tpublic TexturePacker setOuterPadding(int in_padding)\n\t{\n\t\tnumPixelsPadding = in_padding;\n\t\treturn this;\n\t}\n\t\n\tpublic TexturePacker setInnerPadding(int in_padding)\n\t{\n\t\tinnerPadding = in_padding;\n\t\treturn this;\n\t}\n\t\n\tpublic TexturePacker setExtrusion(int in_extrusion)\n\t{\n\t\textrude = in_extrusion;\n\t\treturn this;\n\t}\n\t\n\tpublic TexturePacker enableCropping(boolean in_enable)\n\t{\n\t\tcropImages = in_enable;\n\t\treturn this;\n\t}\n\t\n\tpublic TexturePacker setHeuristic(PlacementHeuristic in_heuristic)\n\t{\n\t\teBestPlacement = in_heuristic;\n\t\treturn this;\n\t}\n\t\n\tpublic TexturePacker setMaxWidth(int in_maxWidth)\n\t{\n\t\tmaxWidth = in_maxWidth;\n\t\treturn this;\n\t}\n\t\n\tpublic TexturePacker setMaxHeight(int in_maxHeight)\n\t{\n\t\tmaxHeight = in_maxHeight;\n\t\treturn this;\n\t}\n\t\n\tpublic TexturePacker setFixedWidth(int in_width)\n\t{\n\t\tfixedWidth = in_width;\n\t\treturn this;\n\t}\n\t\n\tpublic TexturePacker setFixedHeight(int in_height)\n\t{\n\t\tfixedHeight = in_height;\n\t\treturn this;\n\t}\n\t\n\tpublic TexturePacker setValidWidths(int[] in_widths)\n\t{\n\t\tif(in_widths != null)\n\t\t{\n\t\t\tvalidWidths = in_widths;\n\t\t\tnumValidW = in_widths.length;\n\t\t}\n\t\treturn this;\n\t}\n\t\n\tpublic TexturePacker setValidHeights(int[] in_heights)\n\t{\n\t\tif(in_heights != null)\n\t\t{\n\t\t\tvalidHeights = in_heights;\n\t\t\tnumValidH = in_heights.length;\n\t\t}\n\t\treturn this;\n\t}\n\t\n\tpublic TexturePacker setDivisibleBy(int in_divBy)\n\t{\n\t\tdivisibleBy = in_divBy;\n\t\treturn this;\n\t}\n\t/**\n\t * Set to ignore cases that would usually lead to a fatal assert when packing, used to test if atlasOptions will result in a valid\n\t * Spritesheet \n\t * \n\t * @author HMcLaughlin\n\t * \n\t * @param in_ignore Whether to ignore or not\n\t * \n\t * @return this instance\n\t */\n\tpublic TexturePacker disableFatalLogs()\n\t{\n\t\tm_ignoreFatalLogs = true;\n\t\treturn this;\n\t}\n\t\n\t/**\n\t * Packs the given images into a single image\n\t * \n\t * @author S Downie\n\t * \n\t * @param List of files to pack\n\t * @param out_errorInfo Info object to be populated if an error occurs, can be null\n\t * \n\t * @return Packed image data\n\t * \n\t * @throws IOException\n\t * @throws CSException\n\t */\n\tpublic PackedTexture pack(ArrayList<File> in_imageFiles, PackerInfo out_errorInfo) throws IOException, CSException\n\t{\n\t\t//as extruding, \"extrudes\" into the padding, we need to make sure we have at least enough padding for extruding.\n\t\tif (extrude > 0 && numPixelsPadding < extrude)\n\t\t{\n\t\t\tnumPixelsPadding = extrude;\n\t\t}\n\t\t\n\t\tnumSourceImages = in_imageFiles.size();\n\n\t\toriginalImageWidths = new int[numSourceImages];\n\t\toriginalImageHeights = new int[numSourceImages];\n\t\tcroppedImageWidths = new int[numSourceImages];\n\t\tcroppedImageHeights = new int[numSourceImages];\n\t\tcroppedImageArea = new int[numSourceImages];\n\t\timageOffsetXs = new int[numSourceImages];\n\t\timageOffsetYs = new int[numSourceImages];\n\t\tuseGraphics = new int[numSourceImages];\n\t\tmatchFound = new boolean[numSourceImages];\n\t\tnamePointers = new int[numSourceImages];\n\t\tsourceImageFiles = in_imageFiles.toArray(new File[1]);\n\n\t\t// find the width, height and offsets for each image\n\t\tloadImageFileInformation();\n\n\t\tLogging.logVerbose(\"Processing...\");\n\t\tint[] sortedOrder = new int[numSourceImages];\n\t\tfor (int i = 0; i < numSourceImages; i++)\n\t\t{\n\t\t\tsortedOrder[i] = i;\n\t\t}\n\n\t\t// Bubble sort! For N^2 fun. \n\t\tfor (int i = 0; i < numSourceImages; i++)\n\t\t{\n\t\t\tfor (int j = i + 1; j < numSourceImages; j++)\n\t\t\t{\n\t\t\t\tif (imagePriorityHeuristic(sortedOrder[i], sortedOrder[j]))\n\t\t\t\t{\n\t\t\t\t\tint tempSwap = sortedOrder[j];\n\t\t\t\t\tsortedOrder[j] = sortedOrder[i];\n\t\t\t\t\tsortedOrder[i] = tempSwap;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Check if any of our loaded images are duplicates of each other.\n\t\tfor(int i = 0; i < numSourceImages; i++)\n\t\t{\n\t\t\tfor(int j = i + 1; j < numSourceImages; j++)\n\t\t\t{\n\t\t\t\tint cur = sortedOrder[i];\n\t\t\t\tint comp = sortedOrder[j];\n\n\t\t\t\tif (croppedImageWidths[cur] == croppedImageWidths[comp] && croppedImageHeights[cur] == croppedImageHeights[comp])\n\t\t\t\t{\n\t\t\t\t\tboolean match = imagesAreEqual(cur, comp);\n\t\t\t\t\tif((match) && (!matchFound[comp]))\n\t\t\t\t\t{\n\t\t\t\t\t\tuseGraphics[comp] = cur;\n\t\t\t\t\t\tmatchFound[comp] = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif((maxWidth != -1) && (maxHeight != -1))\n\t\t{\n\t\t\tint maxWidth = -1;\n\t\t\tint maxHeight = -1;\n\t\t\tfor(int i = 0; i < numSourceImages; i++)\n\t\t\t{\n\t\t\t\t// TK: Determine the maximum width and height \n\t\t\t\tif (croppedImageWidths[i] > maxWidth)\n\t\t\t\t\tmaxWidth = croppedImageWidths[i];\n\t\t\t\tif (croppedImageHeights[i] > maxHeight)\n\t\t\t\t\tmaxHeight = croppedImageHeights[i];\n\t\t\t}\n\t\t\tminAreaWidth = maxWidth;\n\t\t\tminAreaHeight = maxHeight;\n\n\t\t\tif(out_errorInfo != null)\n\t\t\t{\n\t\t\t\tout_errorInfo.m_requiredWidth = minAreaWidth;\n\t\t\t\tout_errorInfo.m_requiredHeight = minAreaHeight;\n\t\t\t}\n\t\t\t\n\t\t\tLogging.logVerbose(\"Minimum area required is \"+minAreaWidth+\"x\"+minAreaHeight);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tmaxWidth = -1;\n\t\t\tmaxHeight = -1;\n\t\t}\n\n\t\tif (!layoutSpritesForSheet(sortedOrder, out_errorInfo))\n\t\t{\n\t\t\tthrow new CSException(\"Images will not fit in any of the allowed output sizes.\");\n\t\t}\n\n\t\t// Ok re-sort the output so that the files are processed in\n\t\t// the order they came in...\n\n\t\tint outputOrder[] = new int[numSourceImages];\n\t\tfor (int i = 0; i < numSourceImages; i++)\n\t\t{\n\t\t\toutputOrder[i] = i;\n\t\t}\n\n\t\tBufferedImage outputImage = buildCombinedImage(outputOrder);\n\n\t\t//if we have reason to, then add extruded pixels to the output image.\n\t\tif (extrude > 0)\n\t\t{\n\t\t\textrudeCombinedImage(outputOrder, outputImage);\n\t\t}\n\t\t\n\t\tfor(int i=0; i<numSourceImages; ++i)\n\t\t{\n\t\t\tplacedSpriteRects[outputOrder[i]].x = placedSpriteRects[outputOrder[i]].x + numPixelsPadding;\n\t\t\tplacedSpriteRects[outputOrder[i]].y = placedSpriteRects[outputOrder[i]].y + numPixelsPadding;\n\t\t};\n\t\t\n\t\tPackedTexture pt = new PackedTexture(outputImage, numSourceImages, combinedImageWidth, combinedImageHeight, \n\t\t\t\toriginalImageWidths, originalImageHeights, croppedImageWidths, croppedImageHeights,\n\t\t\t\timageOffsetXs, imageOffsetYs,\n\t\t\t\tplacedSpriteRects,\n\t\t\t\tsourceImageFiles,\n\t\t\t\toutputOrder, namePointers);\n\t\treturn pt;\n\t}\n\n\t/**\n\t * @param outputOrder Order to pack images\n\t * \n\t * @return BufferImage containing packed sprites\n\t * \n\t * @throws IOException\n\t * @throws CSException\n\t */\n\tprivate BufferedImage buildCombinedImage(int[] outputOrder) throws IOException, CSException\n\t{\n\t\tBufferedImage combinedImage = new BufferedImage(combinedImageWidth, combinedImageHeight, BufferedImage.TYPE_INT_ARGB);\n\t\tfor (int y = 0; y < combinedImageHeight; y++)\n\t\t{\n\t\t\tfor (int x = 0; x < combinedImageWidth; x++)\n\t\t\t{\n\t\t\t\tcombinedImage.setRGB(x, y, 0);\n\t\t\t}\n\t\t}\n\n\t\tfor (int i = 0; i < numSourceImages; i++)\n\t\t{\n\t\t\tBufferedImage I = imageFiles[i];\n\t\t\tint ix = imageOffsetXs[i];\n\t\t\tint iy = imageOffsetYs[i];\n\n\t\t\tint ox = placedSpriteRects[outputOrder[i]].x;\n\t\t\tint oy = placedSpriteRects[outputOrder[i]].y;\n\t\t\tint width = croppedImageWidths[i];\n\t\t\tint height = croppedImageHeights[i];\n\t\t\tint iw = originalImageWidths[i];\n\t\t\tint ih = originalImageHeights[i];\n\n\t\t\tLogging.logVerbose(\"Writing pixels from:\"+sourceImageFiles[namePointers[i]].getName()+\" at x:\"+ox+\", y:\"+oy+\", width:\"+width+\", height:\"+height);\n\n\t\t\tfor (int y = 0; y < height; y++)\n\t\t\t{\n\t\t\t\tfor (int x = 0; x < width; x++)\n\t\t\t\t{\n\t\t\t\t\tint pixel = 0;\n\n\t\t\t\t\tif ((ix + x) < iw && (iy + y) < ih)\n\t\t\t\t\t{\n\t\t\t\t\t\tpixel = I.getRGB(ix + x, iy + y);\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t    throw new CSException(\"input out of range:\" + (ix + x) + \",\" + (iy + y));\n\t\t\t\t\t}\n\n\t\t\t\t\tif ((ox + x) < combinedImageWidth && (oy + y) < combinedImageHeight)\n\t\t\t\t\t{\n\t\t\t\t\t\tcombinedImage.setRGB(ox + x + numPixelsPadding, oy + y + numPixelsPadding, pixel);\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t    throw new CSException(\"Pixel out of range:\" + (ox + x) + \",\" + (oy + y));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn combinedImage;\n\t}\n\n\t/**\n\t * @param outputOrder Order to pack images\n\t * @param combinedImage Image to write extruded images into\n\t * \n\t * @throws IOException\n\t */\n\tprivate void extrudeCombinedImage(int[] outputOrder, BufferedImage combinedImage) throws IOException\n\t{\n\t\tfor (int i = 0; i < numSourceImages; i++)\n\t\t{\n\t\t\tBufferedImage I = imageFiles[i];\n\t\t\tint ix = imageOffsetXs[i];\n\t\t\tint iy = imageOffsetYs[i];\n\t\t\tint ox = placedSpriteRects[outputOrder[i]].x;\n\t\t\tint oy = placedSpriteRects[outputOrder[i]].y;\n\t\t\tint width = croppedImageWidths[i];\n\t\t\tint height = croppedImageHeights[i];\n\t\t\tLogging.logVerbose(\"Extruding pixels from:\"+sourceImageFiles[namePointers[i]].getName()+\" at x:\"+ox+\", y:\"+oy+\", width:\"+width+\", height:\"+height);\n\n\t\t\t//For each of the sides, iterate along it and add the extruded pixel colours. The existing padding should mean that the pixels are free to be coloured as we wish.\n\t\t\t//top\n\t\t\tfor (int j = 0; j < width; ++j)\n\t\t\t{\n\t\t\t\tint x = j;\n\t\t\t\tint y = 0;\n\t\t\t\tint pixelColour = I.getRGB(ix + x, iy + y);\n\t\t\t\tfor (int k = 0; k < extrude; ++k)\n\t\t\t\t{\n\t\t\t\t\tint extrudeDistance = -(k + 1);\n\t\t\t\t\tcombinedImage.setRGB(ox + x + numPixelsPadding, oy + y + numPixelsPadding + extrudeDistance, pixelColour);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t//bottom\n\t\t\tfor (int j = 0; j < width; ++j)\n\t\t\t{\n\t\t\t\tint x = j;\n\t\t\t\tint y = height - 1;\n\t\t\t\tint pixelColour = I.getRGB(ix + x, iy + y);\n\t\t\t\tfor (int k = 0; k < extrude; ++k)\n\t\t\t\t{\n\t\t\t\t\tint extrudeDistance = (k + 1);\n\t\t\t\t\tcombinedImage.setRGB(ox + x + numPixelsPadding, oy + y + numPixelsPadding + extrudeDistance, pixelColour);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t//left\n\t\t\tfor (int j = 0; j < height; ++j)\n\t\t\t{\n\t\t\t\tint x = 0;\n\t\t\t\tint y = j;\n\t\t\t\tint pixelColour = I.getRGB(ix + x, iy + y);\n\t\t\t\tfor (int k = 0; k < extrude; ++k)\n\t\t\t\t{\n\t\t\t\t\tint extrudeDistance = -(k + 1);\n\t\t\t\t\tcombinedImage.setRGB(ox + x + numPixelsPadding + extrudeDistance, oy + y + numPixelsPadding, pixelColour);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t//right\n\t\t\tfor (int j = 0; j < height; ++j)\n\t\t\t{\n\t\t\t\tint x = width - 1;\n\t\t\t\tint y = j;\n\t\t\t\tint pixelColour = I.getRGB(ix + x, iy + y);\n\t\t\t\tfor (int k = 0; k < extrude; ++k)\n\t\t\t\t{\n\t\t\t\t\tint extrudeDistance = (k + 1);\n\t\t\t\t\tcombinedImage.setRGB(ox + x + numPixelsPadding + extrudeDistance, oy + y + numPixelsPadding, pixelColour);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t//Now handle the corners\n\t\t\t//top left\n\t\t\tfor (int j = 0; j < extrude; ++j)\n\t\t\t{\n\t\t\t\tfor (int k = 0; k < extrude; ++k)\n\t\t\t\t{\n\t\t\t\t\tint pixelColour = I.getRGB(ix + 0, iy + 0);\n\t\t\t\t\tint x = -(j + 1);\n\t\t\t\t\tint y = -(k + 1);\n\t\t\t\t\tcombinedImage.setRGB(ox + x + numPixelsPadding, oy + y + numPixelsPadding, pixelColour);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t//top right\n\t\t\tfor (int j = 0; j < extrude; ++j)\n\t\t\t{\n\t\t\t\tfor (int k = 0; k < extrude; ++k)\n\t\t\t\t{\n\t\t\t\t\tint pixelColour = I.getRGB(ix + width - 1, iy + 0);\n\t\t\t\t\tint x = width + j;\n\t\t\t\t\tint y = -(k + 1);\n\t\t\t\t\tcombinedImage.setRGB(ox + x + numPixelsPadding, oy + y + numPixelsPadding, pixelColour);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t//bottom left\n\t\t\tfor (int j = 0; j < extrude; ++j)\n\t\t\t{\n\t\t\t\tfor (int k = 0; k < extrude; ++k)\n\t\t\t\t{\n\t\t\t\t\tint pixelColour = I.getRGB(ix + 0, iy + height - 1);\n\t\t\t\t\tint x = -(j + 1);\n\t\t\t\t\tint y = height + k;\n\t\t\t\t\tcombinedImage.setRGB(ox + x + numPixelsPadding, oy + y + numPixelsPadding, pixelColour);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t//bottom right\n\t\t\tfor (int j = 0; j < extrude; ++j)\n\t\t\t{\n\t\t\t\tfor (int k = 0; k < extrude; ++k)\n\t\t\t\t{\n\t\t\t\t\tint pixelColour = I.getRGB(ix + width - 1, iy + height - 1);\n\t\t\t\t\tint x = width + j;\n\t\t\t\t\tint y = height + k;\n\t\t\t\t\tcombinedImage.setRGB(ox + x + numPixelsPadding, oy + y + numPixelsPadding, pixelColour);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * @param imageIndex2 Index of image to test\n\t * @param imageIndex1 Index of image to test\n\t * \n\t * @return True if images are the same\n\t */\n\tprivate boolean imagesAreEqual(int imageIndex2, int imageIndex1) \n\t{\n\t\tint image1 = namePointers[imageIndex1];\n\t\tint image2 = namePointers[imageIndex2];\n\n\t\tFile f1 = sourceImageFiles[image1];\n\t\tFile f2 = sourceImageFiles[image2];\n\t\tBufferedImage I1 = imageFiles[image1];\n\t\tBufferedImage I2 = imageFiles[image2];\n\n\t\tif(I1 == I2)\n\t\t{\n\t\t\tLogging.logVerbose(\"Hash match found:\" + f1.getName() + \" and \" + f2.getName());\n\t\t\treturn true;\n\t\t}\n\n\t\tint w = croppedImageWidths[imageIndex2];\n\t\tint h = croppedImageHeights[imageIndex2];\n\t\tint xoff1 = imageOffsetXs[imageIndex1];\n\t\tint yoff1 = imageOffsetYs[imageIndex1];\n\t\tint xoff2 = imageOffsetXs[imageIndex2];\n\t\tint yoff2 = imageOffsetYs[imageIndex2];\n\t\tint y = 0;\n\n\t\twhile (y < h)\n\t\t{\n\t\t\tint x = 0;\n\t\t\twhile (x < w)\n\t\t\t{\n\t\t\t\tif (!(I1.getRGB(xoff1 + x, yoff1 + y) == I2.getRGB(xoff2 + x,yoff2 + y)))\n\t\t\t\t\treturn false;\n\t\t\t\tx++;\n\t\t\t}\n\t\t\ty++;\n\t\t}\n\n\t\tLogging.logVerbose(\"Match found:\" + f1.getName() + \" and \" + f2.getName());\n\n\t\treturn true;\n\t}\n\n\t/**\n\t * @param indwLeft Index of image to test\n\t * @param indwRight Index of image to test\n\t * \n\t * @return True if the 'left' image is smaller than the 'right' image\n\t */\n\tprivate boolean imagePriorityHeuristic(int indwLeft, int indwRight)\n\t{\n\t\tint LeftSide = croppedImageHeights[indwLeft] > croppedImageWidths[indwLeft] ? croppedImageHeights[indwLeft] : croppedImageWidths[indwLeft];\n\t\tint RightSide = croppedImageHeights[indwRight] > croppedImageWidths[indwRight] ? croppedImageHeights[indwRight] : croppedImageWidths[indwRight];\n\t\treturn (croppedImageArea[indwLeft] + LeftSide * LeftSide) < (croppedImageArea[indwRight] + RightSide * RightSide);\n\t}\n\n\t/**\n\t * @return Estimated height for final image\n\t */\n\tint guessOutputHeight()\n\t{\n\t\tif(minAreaHeight == -1)\n\t\t{\n\t\t\t//Super simple heuristic, can't be shorter than our tallest image\n\t\t\tint maxHeight = 0;\n\n\t\t\tfor(int y : croppedImageHeights)\n\t\t\t{\n\t\t\t\tmaxHeight = (y > maxHeight) ? y : maxHeight;\n\t\t\t}\n\n\t\t\treturn maxHeight;\n\t\t}\n\n\t\treturn minAreaHeight;\n\t}\n\n\t/**\n\t * @return Estimated width for final image \n\t */\n\tint guessOutputWidth()\n\t{\n\t\tif(minAreaWidth == -1)\n\t\t{\n\t\t\tArrayList<Integer> widths = new ArrayList<Integer>();\n\n\t\t\tfor(int w: croppedImageWidths)\n\t\t\t{\n\t\t\t\twidths.add(new Integer(w + 2 * numPixelsPadding));\n\t\t\t}\n\n\t\t\tCollections.sort(widths);\n\n\t\t\t// Extract the maximum and median widths.\n\t\t\tint maxWidth = widths.get(widths.size() - 1);\n\t\t\tint medianWidth = widths.get(widths.size() / 2);\n\n\t\t\t// Heuristic assumes an NxN grid of median sized sprites.\n\t\t\tint width = medianWidth * (int)Math.round(Math.sqrt(widths.size()));\n\n\t\t\t// Make sure we never choose anything smaller than our largest sprite.\n\t\t\treturn Math.max(width, maxWidth);\n\t\t}\n\n\t\treturn minAreaWidth;\n\t}\n\n\t/**\n\t * @param h Height to get nearest allowed height for\n\t * \n\t * @return Nearest allowed height for give height\n\t */\n\tint nextAllowedHeight(int h)\n\t{\n\t\t// Fixed height always return same size\n\t\tif (fixedHeight != -1)\n\t\t{\n\t\t\treturn fixedHeight;\n\t\t}\n\t\t// Bounded only by max height\n\t\telse if (maxHeight != -1)\n\t\t{\n\t\t\tif(h < minAreaHeight)\n\t\t\t\treturn minAreaHeight;\n\t\t\telse\n\t\t\t{\n\t\t\t\tint nextHeight = h;\n\t\t\t\tif(nextHeight > maxHeight)\n\t\t\t\t\tnextHeight = maxHeight;\n\t\t\t\tif(divisibleBy != -1)\n\t\t\t\t{\n\t\t\t\t\tif((nextHeight % divisibleBy) != 0)\n\t\t\t\t\t\tnextHeight = (((nextHeight / divisibleBy) + 1) * divisibleBy);\n\t\t\t\t}\n\t\t\t\treturn nextHeight;\n\t\t\t}\n\t\t}\n\t\t// Bounded by a list of valid sizes\n\t\telse\n\t\t{\n\t\t\tint n = 0;\n\t\t\twhile (validHeights[n] <= h && n < numValidH)\n\t\t\t\tn++;\n\n\t\t\treturn validHeights[n];\n\t\t}\n\t}\n\n\t/**\n     * @param w Height to get nearest allowed width for\n     * \n     * @return Nearest allowed width for give width\n     */\n\tint nextAllowedWidth(int w)\n\t{\n\t\t// Fixed widths always return same size\n\t\tif (fixedWidth != -1)\n\t\t{\n\t\t\treturn fixedWidth;\n\t\t}\n\t\t// Bounded only by max widths\n\t\telse if (maxWidth != -1)\n\t\t{\n\t\t\tif(w < minAreaWidth)\n\t\t\t\treturn minAreaWidth;\n\t\t\telse\n\t\t\t{\n\t\t\t\tint nextWidth = w ;\n\t\t\t\tif(nextWidth > maxWidth)\n\t\t\t\t\tnextWidth = maxWidth;\n\t\t\t\tif(divisibleBy != -1)\n\t\t\t\t{\n\t\t\t\t\tif((nextWidth % divisibleBy) != 0)\n\t\t\t\t\t\tnextWidth = (((nextWidth / divisibleBy) + 1) * divisibleBy);\n\t\t\t\t}\n\t\t\t\treturn nextWidth;\n\t\t\t}\n\t\t}\n\t\t// Bounded by a list of valid sizes\n\t\telse\n\t\t{\n\t\t\tint n = 0;\n\t\t\twhile (validWidths[n] <= w && n < numValidW)\n\t\t\t\tn++;\n\n\t\t\treturn validWidths[n];\n\t\t}\n\t}\n\t\n\t/**\n\t * Checks for intersections with other placed sprites\n\t * \n\t * @param inSprite Sprite to check for intersections with\n\t * \n\t * @return The intersecting sprite or null if there was no intersection\n\t */\n\tprivate Rectangle findIntersectingSprite(Rectangle inSprite)\n\t{\n\t\tArrayList<Rectangle> Intersecting = new ArrayList<Rectangle>();\n\n\t\t// Use our collision grid to get collisions\n\t\tgridCheck.GetIntersecting(inSprite, Intersecting);\n\n\t\t// We might hit more than one placed sprite\n\t\t// so we should check for the best one to use (which is usually the most topleft)\n\t\t// as the basis for moving our new sprite\n\t\tRectangle bestHit = null;\n\t\tfor(Rectangle hit: Intersecting)\n\t\t{\n\t\t\tif(bestHit == null)\n\t\t\t\tbestHit = hit;\n\t\t\telse\n\t\t\t{\n\t\t\t\tif(PlacementHeuristic.TOPLEFT.ChooseBest(hit, bestHit))\n\t\t\t\t\tbestHit = hit;\n\t\t\t}\n\t\t}\n\n\t\treturn bestHit;\n\t}\n\t\n\t/**\n\t * Checks if a sprite fits within specified bounds\n\t * \n\t * @param inSprite Sprite to check against bounds\n\t * @param inWidth Bounding width\n\t * @param inHeight Bounding height\n\t * \n\t * @return If sprite fits\n\t */\n\tprivate boolean spriteFitsArea(Rectangle inSprite, int inWidth, int inHeight)\n\t{\n\t\treturn (inSprite.x >=0 && inSprite.y >=0) && (inSprite.bottom() <= inHeight && inSprite.right() <= inWidth);\n\t}\n\t\n\t/**\n\t * Checks if a sprite will fit into our spritesheet if the spritesheet can be resized\n\t * \n\t * @param inSprite Sprite to check \n\t * \n\t * @return If sprite fits (with resizing)\n\t */\n\tprivate boolean spriteFitsWithResize(Rectangle inSprite)\n\t{\n\t\tint newWidth = nextAllowedWidth(inSprite.right());\n\t\tint newHeight = nextAllowedHeight(inSprite.bottom());\n\n\t\tboolean bFits = spriteFitsArea(inSprite, newWidth, newHeight);\n\n\t\treturn bFits;\n\t}\n\t\n\t/**\n\t * Resizes our sprite sheet to fit a passed in sprite\n\t * \n\t * @param inSprite The sprite to fit on to our sprite sheet\n\t * \n\t * @return If it was possible to resize to fit the sprite\n\t */\n\tprivate boolean resizeToFitSprite(Rectangle inSprite)\n\t{\n\t\tif(spriteFitsArea(inSprite, combinedImageWidth, combinedImageHeight))\n\t\t\treturn true;\n\t\tif(spriteFitsWithResize(inSprite) == false)\n\t\t\treturn false;\n\n\t\tint newWidth = nextAllowedWidth(inSprite.right());\n\t\tint newHeight = nextAllowedHeight(inSprite.bottom());\n\n\t\tif(combinedImageWidth < newWidth)\n\t\t\tcombinedImageWidth = newWidth;\n\t\tif(combinedImageHeight < newHeight)\n\t\t\tcombinedImageHeight = newHeight;\n\n\t\tLogging.logVerbose(\"Trying next image size of \"+combinedImageWidth+\"x\"+combinedImageHeight);\n\n\t\treturn true;\n\t}\n\t\n\t/**\n\t * Attempts to place a sprite on our spritesheet, expanding when necessary\n\t * \n\t * @param inSprite The sprite to fit\n\t * @return The position of the fitted sprite or null if it was not possible to fit\n\t */\n\tprivate Rectangle findSpaceForSprite(Rectangle inSprite)\n\t{\n\t\tif(!spriteFitsWithResize(inSprite))\n\t\t\treturn null;\n\n\t\tRectangle result = null;\n\t\tRectangle collider = findIntersectingSprite(inSprite);\n\n\t\t// No collisions so see if it fits on the image\n\t\tif(collider == null)\n\t\t{\n\t\t\tresult = inSprite;\n\t\t}\n\t\telse\n\t\t{\n\t\t\t// We dont want to go over a collider we've seen before\n\t\t\tif(setSeenColliders.contains(collider))\n\t\t\t\treturn null;\n\n\t\t\tsetSeenColliders.add(collider);\n\n\t\t\t// check down\n\n\t\t\t// Try to bump left our rect to be more compact\n\t\t\tint newX = inSprite.x;\n\t\t\tif(inSprite.x > collider.x)\n\t\t\t\tnewX = collider.x;\n\n\t\t\tRectangle down = new Rectangle(newX, collider.bottom(), inSprite.width, inSprite.height);\n\t\t\tdown= findSpaceForSprite(down);\n\n\t\t\t// check right \n\n\t\t\t// Try to bump up our rect to be more compact\n\t\t\tint newY =inSprite.y;\n\t\t\tif(inSprite.y > collider.y)\n\t\t\t\tnewY = collider.y;\n\n\t\t\tRectangle right = new Rectangle(collider.right(), newY, inSprite.width, inSprite.height);\n\t\t\tright = findSpaceForSprite(right);\n\n\t\t\tif(right!= null && down!= null)\n\t\t\t{\n\t\t\t\t// Prefer one that doesn't need resizing\n\t\t\t\tboolean bDownResize = spriteFitsArea(down, combinedImageWidth, combinedImageHeight) == false;\n\t\t\t\tboolean bRightResize = spriteFitsArea(right, combinedImageWidth, combinedImageHeight) == false;\n\n\t\t\t\t// Either so further checks\n\t\t\t\tif(bDownResize == bRightResize)\n\t\t\t\t{\n\t\t\t\t\t// prefer the most top left one\n\t\t\t\t\tif(eBestPlacement.ChooseBest(right, down))\n\t\t\t\t\t\tresult = right;\n\t\t\t\t\telse\n\t\t\t\t\t\tresult = down;\t\t\t\t\t\n\t\t\t\t}\n\t\t\t\telse if(bRightResize)\n\t\t\t\t\tresult = down;\n\t\t\t\telse\n\t\t\t\t\tresult = right;\n\n\t\t\t}\n\t\t\telse if(right != null)\n\t\t\t\tresult = right;\n\t\t\telse\n\t\t\t\tresult = down;\n\n\t\t}\t\n\t\treturn result;\n\t}\n\t\n\t/**\n\t * Places a sprite down on the spritesheet\n\t * \n\t * @param sortedIndex The index of the sprite to place\n\t * @param sortedOrder The list of original sprite indices\n\t * \n\t * @return If it was possible to place the sprite on the sheet\n\t */\n\tprivate boolean placeSprite(int sortedIndex, int[] sortedOrder)\n\t{\n\t\tint imageIndex = sortedOrder[sortedIndex];\n\n\t\tRectangle toBePlaced = new Rectangle(0,0,croppedImageWidths[imageIndex] + (numPixelsPadding * 2), croppedImageHeights[imageIndex] + (numPixelsPadding * 2));\n\n\t\tsetSeenColliders.clear();\n\t\tRectangle foundSpace = findSpaceForSprite(toBePlaced);\n\t\tif(foundSpace != null)\n\t\t{\n\t\t\tresizeToFitSprite(foundSpace);\n\t\t\tplacedSpriteRects[imageIndex] = foundSpace;\n\t\t\t// Add the placed sprite to our collision grid\n\t\t\tgridCheck.AddRectangle(foundSpace);\n\t\t\treturn true;\n\t\t}\n\t\telse\n\t\t\treturn false;\n\t}\n\n\t/**\n\t * @param inSpriteNo Index of sprite\n\t * \n\t * @param inSprites List of sprites\n\t * \n\t * @return True if the sprite can be placed in the final image\n\t */\n\tprivate boolean TryToLayoutSprite(int inSpriteNo, int[] inSprites)\n\t{\n\t\tint[] sortedOrder = inSprites;\n\n\t\tint nOriginalIndex = sortedOrder[inSpriteNo];\n\n\t\t//Because of the way the sprites have been sorted we will always have placed the original graphics version of this\n\t\t//before we place the \n\t\tif (useGraphics[nOriginalIndex] != nOriginalIndex)\n\t\t{\n\t\t\tRectangle copy = new Rectangle(placedSpriteRects[useGraphics[nOriginalIndex]]);\n\t\t\tplacedSpriteRects[nOriginalIndex] = copy;\n\t\t\treturn true;\n\t\t}\n\t\telse\n\t\t{\n\t\t\treturn placeSprite(inSpriteNo, sortedOrder);\n\t\t}\n\t}\n\n\t/**\n\t* Layout all sprites\n\t* \n\t* @param in_sortedOrder List of sprite indices in best order to try placement\n\t* @param out_errorInfo error struct to store any error information, can be null\n\t* \n\t* @returns if it was possible to fit all sprites\n\t* \n\t* @throws CSException\n\t*/\n\tprivate boolean layoutSpritesForSheet(int[] in_sortedOrder, PackerInfo out_errorInfo) throws CSException\n\t{\n\t\tplacedSpriteRects = new Rectangle[in_sortedOrder.length];\n\n\t\tcombinedImageHeight = nextAllowedHeight(guessOutputHeight());\n\t\tcombinedImageWidth = nextAllowedWidth(guessOutputWidth());\n\n\t\t// Clear our collision grid\n\t\tgridCheck.Clear();\n\n\t\tboolean success = true;\n\t\t\n\t\tfor (int nSprite = 0; nSprite < numSourceImages; nSprite++)\n\t\t{\n\t\t\tif(TryToLayoutSprite(nSprite, in_sortedOrder) ==false)\n\t\t\t{\n\t\t\t\tint originalID = in_sortedOrder[nSprite];\n\t\t\t\t\n\t\t\t\tif(out_errorInfo != null)\n\t\t\t\t{\n\t\t\t\t\t//If were populating the error info, we want to know how many of all the images wouldn't fit on this spritesheet\n\t\t\t\t\tout_errorInfo.m_unfittingImages.add(sourceImageFiles[originalID].getAbsolutePath());\n\t\t\t\t\tsuccess = false;\n\t\t\t\t}\n\t\t\t\telse \n\t\t\t\t{\n\t\t\t\t    throw new CSException(\"Could not fit sprite:\" + sourceImageFiles[originalID].getAbsolutePath());\n\t\t\t\t}\n\t\t\t}\n\t\t\tnumPlacedImages++;\n\n\t\t}\n\n\t\treturn success;\n\t}\n\n\t/**\n\t * Generates an md5 hash for any given file\n\t * \n\t * @param inFile File to be hashed\n\t * @return The md5 hash (as a hex string) of the file's contents\n\t */\n\tprivate String GetFileHash(File inFile)\n\t{\n\t\tString strHash = null;\n\t\tInputStream fIn = null;\n\t\tbyte[] buffer = new byte[1024];\n\t\tint numRead;\n\t\ttry\n\t\t{\n\t\t\tMessageDigest md = MessageDigest.getInstance(\"MD5\");\n\t\t\tfIn = new FileInputStream(inFile);\n\n\t\t\tdo \n\t\t\t{\n\t\t\t\tnumRead = fIn.read(buffer);\n\t\t\t\tif (numRead > 0) {\n\t\t\t\t\tmd.update(buffer, 0, numRead);\n\t\t\t\t}\n\t\t\t} while (numRead != -1);\n\t\t\tfIn.close();\n\n\t\t\tstrHash = new BigInteger(1,md.digest()).toString(16);\n\t\t}\n\t\tcatch (Exception e)\n\t\t{\n\n\t\t}\n\n\t\treturn strHash;\n\t}\n\n\t/**\n\t * @throws IOException\n\t */\n\tprivate void loadImageFileInformation() throws IOException\n\t{\n\t\timageFiles = new BufferedImage[numSourceImages];\n\n\t\t// hold all hashes of files we load\n\t\tHashMap<String, Integer> mapUniques = new HashMap<String, Integer>();\n\n\t\tfor (int i = 0; i < numSourceImages; i++)\n\t\t{\n\t\t\tuseGraphics[i] = i;\n\t\t\tmatchFound[i] = false;\n\t\t\t{\n\t\t\t\tLogging.logVerbose(\"Scanning File:\" + sourceImageFiles[i].getName());\n\n\t\t\t\tFile f = sourceImageFiles[i];\n\t\t\t\tif (!f.exists())\n\t\t\t\t{\n\t\t\t\t\tLogging.logError(f.getPath() + \"does not exist in chosen directory\");\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\t// Check if we've loaded an identical file \n\t\t\t\tString fileHash = GetFileHash(f);\n\n\t\t\t\tInteger intMatch = mapUniques.get(fileHash);\n\t\t\t\t// We've already loaded a file with the same contents \n\t\t\t\tif(intMatch != null)\n\t\t\t\t{\t\n\t\t\t\t\t// We don't need to figure out its size\t\t\t\t\n\t\t\t\t\toriginalImageWidths[i] = originalImageWidths[intMatch];\n\t\t\t\t\toriginalImageHeights[i] =originalImageHeights[intMatch];\n\n\t\t\t\t\t// We can also just use the previously loaded image file\n\t\t\t\t\t// to save memory\n\t\t\t\t\timageFiles[i] = imageFiles[intMatch];\n\t\t\t\t\tcroppedImageWidths[i] = croppedImageWidths[intMatch];\n\t\t\t\t\tcroppedImageHeights[i] = croppedImageHeights[intMatch];\n\n\t\t\t\t\timageOffsetXs[i] = imageOffsetXs[intMatch];\n\t\t\t\t\timageOffsetYs[i] = imageOffsetYs[intMatch];\n\t\t\t\t\tcroppedImageArea[i] = croppedImageArea[intMatch];\n\n\t\t\t\t\t// Still need to keep the original name though\n\t\t\t\t\tnamePointers[i] = i;\n\n\t\t\t\t\t// Move on to the next image\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\telse // Store for future checks\n\t\t\t\t\tmapUniques.put(fileHash, i);\n\n\t\t\t\tBufferedImage I = ImageIO.read(f);\n\t\t\t\tint width = I.getWidth();\n\t\t\t\tint height = I.getHeight();\n\t\t\t\tLogging.logVerbose(\" width:\" + width + \" height:\" + height);\n\t\t\t\toriginalImageWidths[i] = width;\n\t\t\t\toriginalImageHeights[i] = height;\n\n\t\t\t\tint maxx = 0, minx = width - 1;\n\t\t\t\tint maxy = 0, miny = height - 1;\n\t\t\t\tboolean blankImage = true;\n\n\t\t\t\tif (cropImages)\n\t\t\t\t{\n\t\t\t\t\t// Crop completely transparent pixels\n\t\t\t\t\tfor (int x = 0; x < width; x++)\n\t\t\t\t\t{\n\t\t\t\t\t\tfor (int y = 0; y < height; y++)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tint a = I.getRGB(x, y);\n\n\t\t\t\t\t\t\tif ((a & 0xFF000000) != 0)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tblankImage = false;\n\t\t\t\t\t\t\t\tif (x < minx)\n\t\t\t\t\t\t\t\t\tminx = x;\n\t\t\t\t\t\t\t\tif (x > maxx)\n\t\t\t\t\t\t\t\t\tmaxx = x;\n\t\t\t\t\t\t\t\tif (y < miny)\n\t\t\t\t\t\t\t\t\tminy = y;\n\t\t\t\t\t\t\t\tif (y > maxy)\n\t\t\t\t\t\t\t\t\tmaxy = y;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\touterloop:\n\t\t\t\t\t\tfor (int x = 0; x < width; x++)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tfor (int y = 0; y < height; y++)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tint a = I.getRGB(x, y);\n\n\t\t\t\t\t\t\t\tif ((a & 0xFF000000) != 0)\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tblankImage = false;\n\t\t\t\t\t\t\t\t\tbreak outerloop;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\tminx= 0;\n\t\t\t\tmaxx = width - 1;\n\t\t\t\tminy = 0;\n\t\t\t\tmaxy = height - 1;\n\t\t\t\t}\n\n\t\t\t\tif (blankImage)\n\t\t\t\t{\n\t\t\t\t\t// force output of whole image.\n\t\t\t\t\tminx = 0;\n\t\t\t\t\tmaxx = width;\n\t\t\t\t\tminy = 0;\n\t\t\t\t\tmaxy = height;\n\t\t\t\t}\n\n\t\t\t\timageFiles[i] = I;\n\t\t\t\tnamePointers[i] = i;\n\t\t\t\t// Try to retain innerPadding\n\t\t\t\tminx = Math.max(0, minx - innerPadding);\n\t\t\t\tminy = Math.max(0, miny - innerPadding);\n\t\t\t\tmaxx = Math.min(width - 1, maxx + innerPadding);\n\t\t\t\tmaxy = Math.min(height - 1, maxy + innerPadding);\n\n\t\t\t\tcroppedImageWidths[i] = ((maxx - minx) + 1); // inclusive box\n\t\t\t\tcroppedImageHeights[i] = ((maxy - miny) + 1); // inclusive box\n\n\t\t\t\tif (croppedImageWidths[i] > width)\n\t\t\t\t\tcroppedImageWidths[i] = width;\n\t\t\t\tif (croppedImageHeights[i] > height)\n\t\t\t\t\tcroppedImageHeights[i] = height;\n\t\t\t\timageOffsetXs[i] = minx;\n\t\t\t\timageOffsetYs[i] = miny;\n\t\t\t\tcroppedImageArea[i] = croppedImageWidths[i] * croppedImageHeights[i];\n\t\t\t\tLogging.logVerbose(\" clipped area:\" + minx + \",\" + maxx + \":\" + miny + \",\" + maxy);\n\t\t\t}\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/Zip/.classpath",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<classpath>\n\t<classpathentry kind=\"src\" path=\"src\"/>\n\t<classpathentry kind=\"con\" path=\"org.eclipse.jdt.launching.JRE_CONTAINER\"/>\n\t<classpathentry combineaccessrules=\"false\" kind=\"src\" path=\"/CoreUtils\"/>\n\t<classpathentry kind=\"output\" path=\"bin\"/>\n</classpath>\n"
  },
  {
    "path": "Projects/Tools/Zip/.project",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<projectDescription>\n\t<name>Zip</name>\n\t<comment></comment>\n\t<projects>\n\t</projects>\n\t<buildSpec>\n\t\t<buildCommand>\n\t\t\t<name>org.eclipse.jdt.core.javabuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t</buildSpec>\n\t<natures>\n\t\t<nature>org.eclipse.jdt.core.javanature</nature>\n\t</natures>\n</projectDescription>\n"
  },
  {
    "path": "Projects/Tools/Zip/src/com/chilliworks/chillisource/zip/Main.java",
    "content": "/**\n * Main.java\n * ChilliSource\n * Created by Ian Copland on 01/07/2015.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2015 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.zip;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\nimport com.chilliworks.chillisource.coreutils.CSException;\nimport com.chilliworks.chillisource.coreutils.Logging;\nimport com.chilliworks.chillisource.coreutils.StringUtils;\nimport com.chilliworks.chillisource.coreutils.Logging.LoggingLevel;\n\n/**\n * The entry point into the application.\n * \n * @author Ian Copland\n */\npublic final class Main \n{\n\tprivate static final String PARAM_NAME_INPUT = \"--input\";\n\tprivate static final String PARAM_NAME_OUTPUT = \"--output\";\n\tprivate static final String PARAM_NAME_UNCOMPRESSED_EXTENSIONS = \"--uncompressedext\";\n\tprivate static final String PARAM_NAME_HELP = \"--help\";\n\tprivate static final String SHORT_PARAM_NAME_INPUT = \"-i\";\n\tprivate static final String SHORT_PARAM_NAME_OUTPUT = \"-o\";\n\tprivate static final String SHORT_PARAM_NAME_UNCOMPRESSED_EXTENSIONS = \"-ue\";\n\tprivate static final String SHORT_PARAM_NAME_HELP = \"-h\";\n\n\t/**\n\t * Entry point for the application. This parses and validates the input arguments for the tool\n\t * then passes them into the Zipper.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param The input arguments.\n\t */\n\tpublic static void main(String[] in_args) throws Exception \n\t{\n\t\t//setup the logger.\n\t\tString[] arguments = Logging.start(in_args);\n\t\t\n\t\t//check the number of arguments make sense.\n\t\tif (arguments.length == 0)\n\t\t{\n\t\t\tprintHelpText();\n\t\t\treturn;\n\t\t}\n\t\t\n\t\t//gather up commands\n\t\tZipOptions params = new ZipOptions();\n\t\tfor (int i = 0; i < arguments.length; ++i)\n\t\t{\n\t\t\t//input\n\t\t\tif (arguments[i].equalsIgnoreCase(PARAM_NAME_INPUT) == true || arguments[i].equalsIgnoreCase(SHORT_PARAM_NAME_INPUT) == true)\n\t\t\t{\n\t\t\t\tif (i+1 < arguments.length)\n\t\t\t\t\tparams.m_inputDirectoryPath = StringUtils.standardiseDirectoryPath(arguments[i+1]);\n\t\t\t\telse\n\t\t\t\t\tLogging.logFatal(\"No input file provided!\");\n\t\t\t\ti++;\n\t\t\t}\n\t\t\t\n\t\t\t//output\n\t\t\telse if (arguments[i].equalsIgnoreCase(PARAM_NAME_OUTPUT) == true || arguments[i].equalsIgnoreCase(SHORT_PARAM_NAME_OUTPUT) == true)\n\t\t\t{\n\t\t\t\tif (i+1 < arguments.length)\n\t\t\t\t\tparams.m_outputFilePath = StringUtils.standardiseFilePath(arguments[i+1]);\n\t\t\t\telse\n\t\t\t\t\tLogging.logFatal(\"No output file provided!\");\n\t\t\t\ti++;\n\t\t\t}\n\t\t\t\n\t\t\t//uncompressed extensions\n\t\t\telse if (arguments[i].equalsIgnoreCase(PARAM_NAME_UNCOMPRESSED_EXTENSIONS) == true || arguments[i].equalsIgnoreCase(SHORT_PARAM_NAME_UNCOMPRESSED_EXTENSIONS) == true)\n\t\t\t{\n\t\t\t\tif (i+1 < arguments.length)\n\t\t\t\t\tparams.m_uncompressedExtensions = parseExtensionList(arguments[i+1]);\n\t\t\t\telse\n\t\t\t\t\tLogging.logFatal(\"No extension list provided!\");\n\t\t\t\ti++;\n\t\t\t}\n\t\t\t\n\t\t\t//help\n\t\t\telse if (arguments[i].equalsIgnoreCase(PARAM_NAME_HELP) == true || arguments[i].equalsIgnoreCase(SHORT_PARAM_NAME_HELP) == true)\n\t\t\t{\n\t\t\t\tprintHelpText();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t\n\t\t\t//Failure\n\t\t\telse\n\t\t\t{\n\t\t\t\tLogging.logFatal(\"Invalid parameter found: \" + arguments[i]);\n\t\t\t}\n\t\t}\n\t\t\n\t\tif (params.m_inputDirectoryPath.length() == 0 || params.m_outputFilePath.length() == 0)\n\t\t{\n\t\t\tLogging.logFatal(\"Must provide an input directory path and an output file path.\");\n\t\t}\n\t\t\n\t\ttry\n\t\t{\n\t\t\tZipper.zip(params);\n\t\t}\n\t\tcatch (CSException e)\n\t\t{\n\t\t\tLogging.logFatal(e.getMessage());\n\t\t}\n\t\t\n\t\tLogging.finish();\n\t}\n\t/**\n\t * Parses a string containing a comma separated list of extensions. Extensions may optionally contain\n\t * a leading full stop (\".\"). Trailing and leading whitespace around the entries is also valid, but\n\t * extensions cannot contain whitespace.\n\t * \n\t * Any trailing or leading whitespace will be removed from output entries, and any missing leading\n\t * full stops will be added.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param in_extensionList - A comma separated list of extensions. Whitespace and full stops may be\n\t * included.\n\t * \n\t * @return The output list of extensions. Entries will not have leading or trailing whitespace and\n\t * will have a leading full stop.\n\t */\n\tprivate static List<String> parseExtensionList(String in_extensionList)\n\t{\t\t\n\t\tString[] splitList;\n\t\tif (in_extensionList.contains(\",\") == true)\n\t\t{\n\t\t\tsplitList = in_extensionList.split(\",\");\n\t\t}\n\t\telse\n\t\t{\n\t\t\tsplitList = new String[1];\n\t\t\tsplitList[0] = in_extensionList;\n\t\t}\n\t\t\n\t\tList<String> output = new ArrayList<>();\n\t\tfor (String extension : splitList)\n\t\t{\n\t\t\textension = extension.trim();\n\n\t\t\tif (extension.isEmpty() == true)\n\t\t\t{\n\t\t\t\tLogging.logFatal(\"Extension list cannot contain empty extensions.\");\n\t\t\t}\n\t\t\t\n\t\t\tif (extension.equals(\".\") == true)\n\t\t\t{\n\t\t\t\tLogging.logFatal(\"Invalid extension '\" + extension + \"'\");\n\t\t\t}\n\t\t\t\n\t\t\tif (extension.startsWith(\".\") == false)\n\t\t\t{\n\t\t\t\textension = \".\" + extension;\n\t\t\t}\n\t\t\t\n\t\t\tif (StringUtils.containsWhitespace(extension) == true)\n\t\t\t{\n\t\t\t\tLogging.logFatal(\"Invalid extension '\" + extension + \"' contains whitespace.\");\n\t\t\t}\n\t\t\t\n\t\t\toutput.add(extension);\n\t\t}\n\t\t\n\t\treturn output;\n\t}\n\t/**\n\t * Prints out instructions on how to use this tool. This will print regardless\n\t * of the logging level.\n\t * \n\t * @author Ian Copland\n\t */\n\tprivate static void printHelpText()\n\t{\n\t\tLogging.setLoggingLevel(LoggingLevel.VERBOSE);\n\t\tLogging.logVerbose(\"Usage: java -jar ColladaToCSAnim.jar \" + PARAM_NAME_INPUT + \" <file path> \" + PARAM_NAME_OUTPUT + \" <file path> [\" + PARAM_NAME_UNCOMPRESSED_EXTENSIONS + \"] [\" \n\t\t\t\t+ PARAM_NAME_HELP + \"] [\" + Logging.PARAM_LOGGING_LEVEL + \" <level>]\");\n\t\tLogging.logVerbose(\"Parameters:\");\n\t\tLogging.logVerbose(\" \" + PARAM_NAME_INPUT + \"(\" + SHORT_PARAM_NAME_INPUT + \"): The input directory path. This directory will not be included in the zip, only its contents.\");\n\t\tLogging.logVerbose(\" \" + PARAM_NAME_OUTPUT + \"(\" + SHORT_PARAM_NAME_OUTPUT + \"): The output zip file name.\");\n\t\tLogging.logVerbose(\" \" + PARAM_NAME_UNCOMPRESSED_EXTENSIONS + \"(\" + SHORT_PARAM_NAME_UNCOMPRESSED_EXTENSIONS + \"): [Optional] A comma separated list of extensions which should be left \"\n\t\t\t\t+ \"uncompressed in the zip. Extensions may optionally contain a leading full stop ('.'). Trailing and leading whitespace around the entries is also valid, but \"\n\t\t\t\t+ \"extensions cannot contain whitespace.\");\n\t\tLogging.logVerbose(\" \" + PARAM_NAME_HELP + \"(\" + SHORT_PARAM_NAME_HELP + \"): [Optional] Display this help message.\");\n\t\tLogging.logVerbose(\" \" + Logging.PARAM_LOGGING_LEVEL + \"(\" + Logging.SHORT_PARAM_LOGGING_LEVEL + \"): [Optional] The level of messages to log.\");\n\t\tLogging.logVerbose(\"Logging Levels:\");\n\t\tLogging.logVerbose(\" \" + Logging.LOGGING_LEVEL_NONE + \": No logging.\");\n\t\tLogging.logVerbose(\" \" + Logging.LOGGING_LEVEL_FATAL + \": Only log fatal errors.\");\n\t\tLogging.logVerbose(\" \" + Logging.LOGGING_LEVEL_ERROR + \": Only log errors.\");\n\t\tLogging.logVerbose(\" \" + Logging.LOGGING_LEVEL_WARNING + \": Log errors and warnings.\");\n\t\tLogging.logVerbose(\" \" + Logging.LOGGING_LEVEL_VERBOSE + \": Log all messages.\");\n\t}\n}\n"
  },
  {
    "path": "Projects/Tools/Zip/src/com/chilliworks/chillisource/zip/ZipOptions.java",
    "content": "/**\n * ZipOptions.java\n * ChilliSource\n * Created by Ian Copland on 01/07/2015.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2015 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.zip;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\n/**\n * A container for the input settings for the tool.\n * \n * @author Ian Copland\n */\npublic final class ZipOptions\n{\n\tpublic String m_inputDirectoryPath = \"\";\n\tpublic String m_outputFilePath = \"\";\n\tpublic List<String> m_uncompressedExtensions = new ArrayList<>();\n}\n"
  },
  {
    "path": "Projects/Tools/Zip/src/com/chilliworks/chillisource/zip/Zipper.java",
    "content": "/**\n * Zipper.java\n * ChilliSource\n * Created by Ian Copland on 01/07/2015.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2015 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.zip;\n\nimport java.io.IOException;\n\nimport com.chilliworks.chillisource.coreutils.CSException;\nimport com.chilliworks.chillisource.coreutils.Logging;\nimport com.chilliworks.chillisource.coreutils.ZipUtils;\n\n/**\n * Provides the ability to zip the contents of the given directory path. Optionally\n * extensions can be provided which should remain uncompressed inside the zip.\n * \n * @author Ian Copland\n */\npublic final class Zipper\n{\n\t/**\n\t * Zips the contents of the directory specified in the options to the given output\n\t * zip file. Optionally extensions can be provided which should remain uncompressed \n\t * inside the zip.\n\t * \n\t * @param in_options - The zip options.\n\t * \n\t * @throws CSException - This is thrown if any fatal errors occur during the process\n\t * of zipping.\n\t */\n\tpublic static void zip(ZipOptions in_options) throws CSException\n\t{\n\t\ttry\n\t\t{\n\t\t\tZipUtils.zip(in_options.m_inputDirectoryPath, in_options.m_outputFilePath, in_options.m_uncompressedExtensions);\n\t\t}\n\t\tcatch (IOException e)\n\t\t{\n\t\t\te.printStackTrace();\n\t\t\t\n\t\t\tLogging.logFatal(e.getMessage());\n\t\t\t\n\t\t\tthrow new CSException(\"Could not create the zip file '\" + in_options.m_outputFilePath + \"' from the contents of '\" + in_options.m_inputDirectoryPath + \"'.\");\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "Projects/Windows/ChilliSource.vcxproj",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Project DefaultTargets=\"Build\" ToolsVersion=\"14.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\r\n  <ItemGroup Label=\"ProjectConfigurations\">\r\n    <ProjectConfiguration Include=\"Debug|Win32\">\r\n      <Configuration>Debug</Configuration>\r\n      <Platform>Win32</Platform>\r\n    </ProjectConfiguration>\r\n    <ProjectConfiguration Include=\"Release|Win32\">\r\n      <Configuration>Release</Configuration>\r\n      <Platform>Win32</Platform>\r\n    </ProjectConfiguration>\r\n    <ProjectConfiguration Include=\"Debug|x64\">\r\n      <Configuration>Debug</Configuration>\r\n      <Platform>x64</Platform>\r\n    </ProjectConfiguration>\r\n    <ProjectConfiguration Include=\"Release|x64\">\r\n      <Configuration>Release</Configuration>\r\n      <Platform>x64</Platform>\r\n    </ProjectConfiguration>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Audio\\CricketAudio\\CkAudioPlayer.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Audio\\CricketAudio\\CkBank.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Audio\\CricketAudio\\CkBankProvider.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Audio\\CricketAudio\\CkSound.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Audio\\CricketAudio\\CricketAudioSystem.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Base\\AppConfig.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Base\\Application.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Base\\ByteBuffer.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Base\\ByteColour.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Base\\Colour.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Base\\ColourUtils.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Base\\Device.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Base\\DeviceInfo.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Base\\LifecycleManager.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Base\\Logging.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Base\\PlatformSystem.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Base\\RenderInfo.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Base\\Screen.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Base\\ScreenInfo.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Base\\SystemInfo.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Base\\Utils.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Container\\ParamDictionary.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Container\\ParamDictionarySerialiser.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Container\\Property\\PropertyMap.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Container\\Property\\PropertyTypes.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Cryptographic\\AESEncrypt.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Cryptographic\\BaseEncoding.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Cryptographic\\HashCRC32.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Cryptographic\\HashMD5.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Cryptographic\\HashSHA1.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Cryptographic\\HashSHA256.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Cryptographic\\OAuth.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\DialogueBox\\DialogueBoxSystem.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Entity\\Component.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Entity\\Entity.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Entity\\PrimitiveEntityFactory.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Entity\\Transform.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Event\\EventConnection.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\File\\AppDataStore.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\File\\CSBinaryChunk.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\File\\CSBinaryInputStream.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\File\\FileStream\\BinaryInputStream.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\File\\FileStream\\BinaryOutputStream.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\File\\FileStream\\FileWriteMode.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\File\\FileStream\\TextInputStream.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\File\\FileStream\\TextOutputStream.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\File\\FileSystem.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\File\\TaggedFilePathResolver.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Image\\CSImageProvider.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Image\\ETC1ImageProvider.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Image\\Image.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Image\\ImageFormatConverter.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Image\\PNGImageProvider.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Image\\PVRImageProvider.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Json\\JsonUtils.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Localisation\\LocalisedText.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Localisation\\LocalisedTextProvider.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Math\\Geometry\\ShapeIntersection.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Math\\Geometry\\Shapes.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Math\\Interpolate.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Math\\MathUtils.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Math\\Random.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Math\\UnifiedCoordinates.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Memory\\LinearAllocator.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Memory\\PagedLinearAllocator.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Notification\\AppNotificationSystem.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Notification\\LocalNotificationSystem.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Notification\\NotificationManager.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Notification\\RemoteNotificationSystem.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Resource\\Resource.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Resource\\ResourcePool.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Resource\\ResourceProvider.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Scene\\Scene.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\State\\State.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\State\\StateManager.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\String\\MarkupDef.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\String\\StringMarkupParser.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\String\\StringParser.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\String\\StringUtils.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\String\\ToString.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\String\\UTF8StringUtils.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\System\\StateSystem.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Threading\\SingleThreadTaskPool.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Threading\\TaskContext.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Threading\\TaskPool.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Threading\\TaskScheduler.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Time\\CoreTimer.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Time\\PerformanceTimer.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Time\\Timer.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Volume\\VolumeComponent.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\XML\\XML.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\XML\\XMLUtils.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Input\\Accelerometer\\Accelerometer.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Input\\Base\\InputFilter.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Input\\DeviceButtons\\DeviceButtonSystem.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Input\\Gamepad\\Gamepad.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Input\\Gamepad\\GamepadSystem.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Input\\Gesture\\DragGesture.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Input\\Gesture\\Gesture.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Input\\Gesture\\GestureSystem.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Input\\Gesture\\HoldGesture.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Input\\Gesture\\PinchGesture.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Input\\Gesture\\RotationGesture.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Input\\Gesture\\TapGesture.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Input\\Gyroscope\\Gyroscope.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Input\\Keyboard\\Keyboard.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Input\\Keyboard\\KeyCode.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Input\\Pointer\\Pointer.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Input\\Pointer\\PointerSystem.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Input\\TextEntry\\TextEntry.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Input\\TextEntry\\TextEntryCapitalisation.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Input\\TextEntry\\TextEntryType.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Networking\\ContentDownload\\ContentManagementSystem.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Networking\\ContentDownload\\MoContentDownloader.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Networking\\Http\\HttpRequestSystem.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Networking\\Http\\HttpResponse.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Networking\\IAP\\IAPSystem.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\AlignmentAnchors.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\AspectRatioUtils.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\CameraRenderPassGroup.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\CanvasDrawMode.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\CanvasMaterialPool.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\CanvasRenderer.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\ForwardRenderPassCompiler.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\FrameAllocatorQueue.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\HorizontalTextJustification.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\IRenderCommandProcessor.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\RenderCapabilities.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\RenderCommandBufferManager.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\RenderCommandCompiler.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\Renderer.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\RenderFrame.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\RenderFrameCompiler.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\RenderFrameData.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\RenderObject.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\RenderPass.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\RenderPassObject.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\RenderPassObjectSorter.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\RenderPassVisibilityChecker.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\RenderSnapshot.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\SizePolicy.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\TargetRenderPassGroup.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\VerticalTextJustification.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Camera\\CameraComponent.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Camera\\OrthographicCameraComponent.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Camera\\PerspectiveCameraComponent.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Camera\\RenderCamera.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Font\\Font.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Font\\FontProvider.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Lighting\\AmbientLightComponent.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Lighting\\AmbientRenderLight.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Lighting\\DirectionalLightComponent.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Lighting\\DirectionalRenderLight.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Lighting\\PointLightComponent.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Lighting\\PointRenderLight.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Material\\ForwardRenderMaterialGroupManager.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Material\\Material.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Material\\MaterialFactory.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Material\\MaterialProvider.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Material\\RenderMaterial.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Material\\RenderMaterialGroup.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Material\\RenderMaterialGroupManager.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Model\\AnimatedModelComponent.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Model\\CSAnimProvider.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Model\\CSModelProvider.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Model\\IndexFormat.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Model\\MeshDesc.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Model\\Model.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Model\\ModelDesc.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Model\\PrimitiveModelFactory.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Model\\RenderDynamicMesh.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Model\\RenderMesh.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Model\\RenderMeshBatch.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Model\\RenderMeshManager.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Model\\RenderSkinnedAnimation.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Model\\Skeleton.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Model\\SkeletonDesc.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Model\\SkinnedAnimation.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Model\\SkinnedAnimationGroup.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Model\\SmallMeshBatcher.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Model\\StaticModelComponent.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Model\\VertexFormat.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Affector\\AccelerationParticleAffector.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Affector\\AccelerationParticleAffectorDef.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Affector\\AngularAccelerationParticleAffector.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Affector\\AngularAccelerationParticleAffectorDef.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Affector\\ColourOverLifetimeParticleAffector.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Affector\\ColourOverLifetimeParticleAffectorDef.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Affector\\ParticleAffector.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Affector\\ParticleAffectorDef.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Affector\\ParticleAffectorDefFactory.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Affector\\ScaleOverLifetimeParticleAffector.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Affector\\ScaleOverLifetimeParticleAffectorDef.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\ConcurrentParticleData.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\CSParticleProvider.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Drawable\\ParticleDrawable.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Drawable\\ParticleDrawableDef.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Drawable\\ParticleDrawableDefFactory.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Drawable\\StaticBillboardParticleDrawable.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Drawable\\StaticBillboardParticleDrawableDef.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Emitter\\CircleParticleEmitter.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Emitter\\CircleParticleEmitterDef.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Emitter\\Cone2DParticleEmitter.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Emitter\\Cone2DParticleEmitterDef.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Emitter\\ConeParticleEmitter.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Emitter\\ConeParticleEmitterDef.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Emitter\\ParticleEmitter.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Emitter\\ParticleEmitterDef.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Emitter\\ParticleEmitterDefFactory.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Emitter\\PointParticleEmitter.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Emitter\\PointParticleEmitterDef.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Emitter\\SphereParticleEmitter.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Emitter\\SphereParticleEmitterDef.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\ParticleEffect.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\ParticleEffectComponent.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Property\\ParticlePropertyFactoryImpl.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\ApplyAmbientLightRenderCommand.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\ApplyCameraRenderCommand.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\ApplyDirectionalLightRenderCommand.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\ApplyDynamicMeshRenderCommand.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\ApplyMaterialRenderCommand.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\ApplyMeshBatchRenderCommand.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\ApplyMeshRenderCommand.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\ApplyPointLightRenderCommand.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\ApplySkinnedAnimationRenderCommand.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\BeginRenderCommand.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\BeginWithTargetGroupRenderCommand.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\EndRenderCommand.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\LoadCubemapRenderCommand.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\LoadMaterialGroupRenderCommand.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\LoadMeshRenderCommand.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\LoadShaderRenderCommand.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\LoadTargetGroupRenderCommand.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\LoadTextureRenderCommand.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\RenderInstanceRenderCommand.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\RestoreCubemapRenderCommand.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\RestoreMeshRenderCommand.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\RestoreRenderTargetGroupCommand.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\RestoreTextureRenderCommand.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\UnloadCubemapRenderCommand.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\UnloadMaterialGroupRenderCommand.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\UnloadMeshRenderCommand.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\UnloadShaderRenderCommand.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\UnloadTargetGroupRenderCommand.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\UnloadTextureRenderCommand.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\RenderCommand.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\RenderCommandBuffer.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\RenderCommandList.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Shader\\CSShaderProvider.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Shader\\RenderShaderManager.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Shader\\RenderShaderVariables.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Shader\\Shader.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Skybox\\SkyboxComponent.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Sprite\\SpriteComponent.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Sprite\\SpriteMeshBuilder.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Target\\RenderTargetGroup.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Target\\RenderTargetGroupManager.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Target\\TargetGroup.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Texture\\Cubemap.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Texture\\CubemapProvider.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Texture\\CubemapResourceOptions.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Texture\\RenderTexture.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Texture\\RenderTextureManager.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Texture\\Texture.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Texture\\TextureAtlas.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Texture\\TextureAtlasProvider.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Texture\\TextureDesc.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Texture\\TextureProvider.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Texture\\TextureResourceOptions.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Texture\\UVs.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Social\\Communications\\EmailComposer.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\UI\\Base\\Canvas.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\UI\\Base\\CursorSystem.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\UI\\Base\\PropertyLink.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\UI\\Base\\PropertyTypes.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\UI\\Base\\UIComponent.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\UI\\Base\\UIComponentDesc.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\UI\\Base\\UIComponentFactory.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\UI\\Base\\Widget.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\UI\\Base\\WidgetDef.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\UI\\Base\\WidgetDefProvider.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\UI\\Base\\WidgetDesc.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\UI\\Base\\WidgetFactory.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\UI\\Base\\WidgetParserUtils.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\UI\\Base\\WidgetTemplate.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\UI\\Base\\WidgetTemplateProvider.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\UI\\Button\\HighlightUIComponent.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\UI\\Button\\ToggleHighlightUIComponent.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\UI\\Drawable\\DrawableUIComponent.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\UI\\Drawable\\NinePatchUIDrawable.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\UI\\Drawable\\NinePatchUIDrawableDef.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\UI\\Drawable\\StandardUIDrawable.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\UI\\Drawable\\StandardUIDrawableDef.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\UI\\Drawable\\ThreePatchUIDrawable.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\UI\\Drawable\\ThreePatchUIDrawableDef.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\UI\\Drawable\\UIDrawable.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\UI\\Drawable\\UIDrawableDef.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\UI\\Drawable\\UIDrawableUtils.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\UI\\Layout\\GridUILayout.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\UI\\Layout\\GridUILayoutDef.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\UI\\Layout\\HListUILayout.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\UI\\Layout\\HListUILayoutDef.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\UI\\Layout\\LayoutUIComponent.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\UI\\Layout\\UILayout.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\UI\\Layout\\UILayoutDef.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\UI\\Layout\\VListUILayout.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\UI\\Layout\\VListUILayoutDef.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\UI\\ProgressBar\\ProgressBarDirection.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\UI\\ProgressBar\\ProgressBarType.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\UI\\ProgressBar\\ProgressBarUIComponent.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\UI\\Slider\\SliderDirection.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\UI\\Slider\\SliderUIComponent.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\UI\\Text\\EditableTextUIComponent.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\UI\\Text\\TextIcon.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\UI\\Text\\TextUIComponent.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Video\\Base\\CSSubtitlesProvider.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Video\\Base\\Subtitles.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Video\\Base\\VideoPlayer.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Web\\Base\\WebView.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\CSBackend\\Platform\\Windows\\Core\\Base\\PlatformSystem.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\CSBackend\\Platform\\Windows\\Core\\Base\\Screen.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\CSBackend\\Platform\\Windows\\Core\\Base\\SystemInfoFactory.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\CSBackend\\Platform\\Windows\\Core\\DialogueBox\\DialogueBoxSystem.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\CSBackend\\Platform\\Windows\\Core\\File\\FileSystem.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\CSBackend\\Platform\\Windows\\Core\\File\\WindowsFileUtils.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\CSBackend\\Platform\\Windows\\Core\\Image\\PngImage.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\CSBackend\\Platform\\Windows\\Core\\Image\\PNGImageProvider.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\CSBackend\\Platform\\Windows\\Core\\String\\WindowsStringUtils.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\CSBackend\\Platform\\Windows\\Input\\DeviceButtons\\DeviceButtonSystem.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\CSBackend\\Platform\\Windows\\Input\\Gamepad\\GamepadSystem.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\CSBackend\\Platform\\Windows\\Input\\Keyboard\\Keyboard.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\CSBackend\\Platform\\Windows\\Input\\Pointer\\PointerSystem.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\CSBackend\\Platform\\Windows\\Input\\TextEntry\\TextEntry.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\CSBackend\\Platform\\Windows\\Main.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\CSBackend\\Platform\\Windows\\Networking\\Http\\HttpRequest.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\CSBackend\\Platform\\Windows\\Networking\\Http\\HttpRequestSystem.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\CSBackend\\Platform\\Windows\\SFML\\Base\\SFMLWindow.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\CSBackend\\Rendering\\OpenGL\\Base\\GLContextRestorer.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\CSBackend\\Rendering\\OpenGL\\Base\\GLError.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\CSBackend\\Rendering\\OpenGL\\Base\\GLExtensions.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\CSBackend\\Rendering\\OpenGL\\Base\\RenderCommandProcessor.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\CSBackend\\Rendering\\OpenGL\\Base\\RenderInfoFactory.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\CSBackend\\Rendering\\OpenGL\\Camera\\GLCamera.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\CSBackend\\Rendering\\OpenGL\\Lighting\\GLAmbientLight.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\CSBackend\\Rendering\\OpenGL\\Lighting\\GLDirectionalLight.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\CSBackend\\Rendering\\OpenGL\\Lighting\\GLPointLight.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\CSBackend\\Rendering\\OpenGL\\Material\\GLMaterial.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\CSBackend\\Rendering\\OpenGL\\Model\\GLDynamicMesh.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\CSBackend\\Rendering\\OpenGL\\Model\\GLMesh.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\CSBackend\\Rendering\\OpenGL\\Model\\GLMeshUtils.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\CSBackend\\Rendering\\OpenGL\\Model\\GLSkinnedAnimation.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\CSBackend\\Rendering\\OpenGL\\Shader\\GLShader.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\CSBackend\\Rendering\\OpenGL\\Target\\GLTargetGroup.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\CSBackend\\Rendering\\OpenGL\\Texture\\GLCubemap.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\CSBackend\\Rendering\\OpenGL\\Texture\\GLTexture.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\CSBackend\\Rendering\\OpenGL\\Texture\\GLTextureUnitManager.cpp\" />\r\n    <ClCompile Include=\"..\\..\\Source\\CSBackend\\Rendering\\OpenGL\\Texture\\GLTextureUtils.cpp\" />\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Audio\\CricketAudio.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Audio\\CricketAudio\\CkAudioPlayer.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Audio\\CricketAudio\\CkBank.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Audio\\CricketAudio\\CkBankProvider.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Audio\\CricketAudio\\CkForwardDeclarations.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Audio\\CricketAudio\\CkSound.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Audio\\CricketAudio\\CricketAudioSystem.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Audio\\ForwardDeclarations.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\ChilliSource.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Base.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Base\\AppConfig.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Base\\Application.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Base\\ByteBuffer.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Base\\ByteColour.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Base\\Colour.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Base\\ColourUtils.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Base\\ConstMethodCast.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Base\\CursorType.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Base\\Device.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Base\\DeviceInfo.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Base\\GenericFactory.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Base\\LifecycleManager.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Base\\Logging.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Base\\MakeSharedArray.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Base\\PlatformSystem.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Base\\QueryableInterface.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Base\\RenderInfo.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Base\\Screen.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Base\\ScreenInfo.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Base\\Singleton.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Base\\StandardMacros.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Base\\SystemInfo.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Base\\Utils.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Container.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Container\\concurrent_blocking_queue.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Container\\concurrent_vector.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Container\\concurrent_vector_const_forward_iterator.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Container\\concurrent_vector_const_reverse_iterator.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Container\\concurrent_vector_forward_iterator.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Container\\concurrent_vector_reverse_iterator.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Container\\dynamic_array.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Container\\HashedArray.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Container\\ParamDictionary.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Container\\ParamDictionarySerialiser.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Container\\Property\\IProperty.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Container\\Property\\IPropertyType.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Container\\Property\\Property.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Container\\Property\\PropertyMap.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Container\\Property\\PropertyType.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Container\\Property\\PropertyTypes.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Container\\Property\\ReferenceProperty.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Container\\Property\\ValueProperty.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Container\\random_access_iterator.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Container\\VectorUtils.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Cryptographic.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Cryptographic\\AESEncrypt.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Cryptographic\\BaseEncoding.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Cryptographic\\HashCRC32.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Cryptographic\\HashMD5.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Cryptographic\\HashSHA1.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Cryptographic\\HashSHA256.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Cryptographic\\OAuth.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Delegate.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Delegate\\ConnectableDelegate.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Delegate\\DelegateConnection.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Delegate\\MakeConnectableDelegate.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Delegate\\MakeDelegate.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\DialogueBox.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\DialogueBox\\DialogueBoxSystem.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Entity.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Entity\\Component.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Entity\\Entity.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Entity\\PrimitiveEntityFactory.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Entity\\Transform.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Event.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Event\\Event.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Event\\EventConnection.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Event\\IConnectableEvent.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Event\\IDisconnectableEvent.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\File.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\File\\AppDataStore.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\File\\CSBinaryChunk.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\File\\CSBinaryInputStream.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\File\\FileStream\\BinaryInputStream.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\File\\FileStream\\BinaryOutputStream.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\File\\FileStream\\FileWriteMode.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\File\\FileStream\\IBinaryInputStream.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\File\\FileStream\\ITextInputStream.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\File\\FileStream\\TextInputStream.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\File\\FileStream\\TextOutputStream.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\File\\FileSystem.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\File\\StorageLocation.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\File\\TaggedFilePathResolver.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\ForwardDeclarations.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Image.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Image\\CSImageProvider.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Image\\ETC1ImageProvider.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Image\\Image.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Image\\ImageCompression.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Image\\ImageFormat.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Image\\ImageFormatConverter.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Image\\PNGImageProvider.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Image\\PVRImageProvider.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Json.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Json\\JsonUtils.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Localisation.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Localisation\\LocalisedText.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Localisation\\LocalisedTextProvider.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Math.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Math\\Geometry\\Curves.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Math\\Geometry\\ShapeIntersection.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Math\\Geometry\\Shapes.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Math\\Interpolate.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Math\\MathUtils.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Math\\Matrix3.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Math\\Matrix4.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Math\\NumericLimits.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Math\\Quaternion.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Math\\Random.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Math\\RandomImpl.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Math\\UnifiedCoordinates.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Math\\Vector2.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Math\\Vector3.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Math\\Vector4.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Memory.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Memory\\IAllocator.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Memory\\LinearAllocator.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Memory\\MemoryUtils.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Memory\\MemoryUtilsImpl.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Memory\\ObjectPoolAllocator.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Memory\\PagedLinearAllocator.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Memory\\SharedPtr.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Memory\\SharedPtrImpl.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Memory\\UniquePtr.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Memory\\UniquePtrImpl.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Notification.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Notification\\AppNotificationSystem.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Notification\\LocalNotificationSystem.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Notification\\Notification.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Notification\\NotificationManager.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Notification\\RemoteNotificationSystem.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Resource.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Resource\\IResourceOptions.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Resource\\Resource.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Resource\\ResourcePool.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Resource\\ResourceProvider.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Scene.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Scene\\Scene.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\State.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\State\\State.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\State\\StateManager.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\String.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\String\\MarkupDef.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\String\\StringMarkupParser.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\String\\StringParser.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\String\\StringUtils.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\String\\ToString.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\String\\UTF8StringUtils.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\System.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\System\\AppSystem.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\System\\StateSystem.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Threading.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Threading\\SingleThreadTaskPool.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Threading\\Task.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Threading\\TaskContext.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Threading\\TaskPool.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Threading\\TaskScheduler.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Threading\\TaskType.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Time.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Time\\CoreTimer.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Time\\PerformanceTimer.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Time\\Timer.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Tween.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Tween\\EaseBack.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Tween\\EaseQuad.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Tween\\Linear.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Tween\\SmoothStep.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Tween\\Tween.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Volume.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Volume\\VolumeComponent.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\XML.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\XML\\XML.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\XML\\XMLUtils.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Input\\Accelerometer.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Input\\Accelerometer\\Accelerometer.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Input\\Base.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Input\\Base\\InputFilter.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Input\\DeviceButtons.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Input\\DeviceButtons\\DeviceButtonSystem.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Input\\ForwardDeclarations.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Input\\Gamepad.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Input\\Gamepad\\Gamepad.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Input\\Gamepad\\GamepadAxis.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Input\\Gamepad\\GamepadMappings.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Input\\Gamepad\\GamepadSystem.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Input\\Gesture.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Input\\Gesture\\DragGesture.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Input\\Gesture\\Gesture.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Input\\Gesture\\GestureSystem.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Input\\Gesture\\HoldGesture.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Input\\Gesture\\PinchGesture.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Input\\Gesture\\RotationGesture.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Input\\Gesture\\TapGesture.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Input\\Gyroscope\\Gyroscope.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Input\\Keyboard.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Input\\Keyboard\\Keyboard.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Input\\Keyboard\\KeyCode.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Input\\Keyboard\\ModifierKeyCode.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Input\\Pointer.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Input\\Pointer\\Pointer.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Input\\Pointer\\PointerSystem.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Input\\TextEntry.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Input\\TextEntry\\TextEntry.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Input\\TextEntry\\TextEntryCapitalisation.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Input\\TextEntry\\TextEntryType.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Networking\\ContentDownload.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Networking\\ContentDownload\\ContentManagementSystem.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Networking\\ContentDownload\\IContentDownloader.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Networking\\ContentDownload\\MoContentDownloader.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Networking\\ForwardDeclarations.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Networking\\Http.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Networking\\Http\\HttpRequest.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Networking\\Http\\HttpRequestSystem.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Networking\\Http\\HttpResponse.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Networking\\IAP.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Networking\\IAP\\IAPSystem.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\AlignmentAnchors.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\AspectRatioUtils.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\BlendMode.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\CameraRenderPassGroup.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\CanvasDrawMode.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\CanvasMaterialPool.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\CanvasRenderer.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\CullFace.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\DepthTestComparison.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\ForwardRenderPassCompiler.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\ForwardRenderPasses.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\FrameAllocatorQueue.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\HorizontalTextJustification.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\IRenderCommandProcessor.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\IRenderPassCompiler.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\RenderCapabilities.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\RenderCommandBufferManager.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\RenderCommandCompiler.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\Renderer.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\RenderFrame.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\RenderFrameCompiler.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\RenderFrameData.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\RenderLayer.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\RenderObject.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\RenderPass.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\RenderPassObject.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\RenderPassObjectSorter.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\RenderPassVisibilityChecker.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\RenderSnapshot.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\SizePolicy.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\StencilOp.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\SurfaceFormat.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\TargetRenderPassGroup.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\TargetType.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\TestFunc.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\VerticalTextJustification.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Camera.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Camera\\CameraComponent.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Camera\\OrthographicCameraComponent.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Camera\\PerspectiveCameraComponent.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Camera\\RenderCamera.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Font.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Font\\Font.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Font\\FontProvider.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\ForwardDeclarations.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Lighting.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Lighting\\AmbientLightComponent.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Lighting\\AmbientRenderLight.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Lighting\\DirectionalLightComponent.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Lighting\\DirectionalRenderLight.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Lighting\\PointLightComponent.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Lighting\\PointRenderLight.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Material.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Material\\ForwardRenderMaterialGroupManager.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Material\\Material.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Material\\MaterialFactory.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Material\\MaterialProvider.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Material\\RenderMaterial.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Material\\RenderMaterialGroup.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Material\\RenderMaterialGroupManager.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Model.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Model\\AnimatedModelComponent.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Model\\CSAnimProvider.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Model\\CSModelProvider.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Model\\IndexFormat.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Model\\MeshDesc.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Model\\Model.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Model\\ModelDesc.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Model\\PolygonType.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Model\\PrimitiveModelFactory.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Model\\RenderDynamicMesh.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Model\\RenderMesh.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Model\\RenderMeshBatch.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Model\\RenderMeshManager.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Model\\RenderSkinnedAnimation.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Model\\Skeleton.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Model\\SkeletonDesc.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Model\\SkinnedAnimation.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Model\\SkinnedAnimationGroup.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Model\\SmallMeshBatcher.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Model\\StaticModelComponent.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Model\\VertexFormat.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Affector\\AccelerationParticleAffector.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Affector\\AccelerationParticleAffectorDef.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Affector\\AngularAccelerationParticleAffector.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Affector\\AngularAccelerationParticleAffectorDef.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Affector\\ColourOverLifetimeParticleAffector.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Affector\\ColourOverLifetimeParticleAffectorDef.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Affector\\ParticleAffector.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Affector\\ParticleAffectorDef.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Affector\\ParticleAffectorDefFactory.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Affector\\ScaleOverLifetimeParticleAffector.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Affector\\ScaleOverLifetimeParticleAffectorDef.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\ConcurrentParticleData.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\CSParticleProvider.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Drawable\\ParticleDrawable.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Drawable\\ParticleDrawableDef.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Drawable\\ParticleDrawableDefFactory.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Drawable\\StaticBillboardParticleDrawable.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Drawable\\StaticBillboardParticleDrawableDef.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Emitter\\CircleParticleEmitter.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Emitter\\CircleParticleEmitterDef.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Emitter\\Cone2DParticleEmitter.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Emitter\\Cone2DParticleEmitterDef.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Emitter\\ConeParticleEmitter.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Emitter\\ConeParticleEmitterDef.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Emitter\\ParticleEmitter.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Emitter\\ParticleEmitterDef.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Emitter\\ParticleEmitterDefFactory.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Emitter\\PointParticleEmitter.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Emitter\\PointParticleEmitterDef.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Emitter\\SphereParticleEmitter.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Emitter\\SphereParticleEmitterDef.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Particle.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\ParticleEffect.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\ParticleEffectComponent.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Property\\ComponentwiseRandomConstantParticleProperty.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Property\\ComponentwiseRandomCurveParticleProperty.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Property\\ConstantParticleProperty.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Property\\CurveParticleProperty.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Property\\ParticleProperty.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Property\\ParticlePropertyFactory.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Property\\ParticlePropertyFactoryImpl.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Property\\RandomConstantParticleProperty.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Property\\RandomCurveParticleProperty.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\ApplyAmbientLightRenderCommand.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\ApplyCameraRenderCommand.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\ApplyDirectionalLightRenderCommand.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\ApplyDynamicMeshRenderCommand.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\ApplyMaterialRenderCommand.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\ApplyMeshBatchRenderCommand.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\ApplyMeshRenderCommand.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\ApplyPointLightRenderCommand.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\ApplySkinnedAnimationRenderCommand.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\BeginRenderCommand.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\BeginWithTargetGroupRenderCommand.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\EndRenderCommand.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\LoadCubemapRenderCommand.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\LoadMaterialGroupRenderCommand.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\LoadMeshRenderCommand.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\LoadShaderRenderCommand.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\LoadTargetGroupRenderCommand.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\LoadTextureRenderCommand.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\RenderInstanceRenderCommand.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\RestoreCubemapRenderCommand.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\RestoreMeshRenderCommand.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\RestoreRenderTargetGroupCommand.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\RestoreTextureRenderCommand.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\UnloadCubemapRenderCommand.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\UnloadMaterialGroupRenderCommand.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\UnloadMeshRenderCommand.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\UnloadShaderRenderCommand.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\UnloadTargetGroupRenderCommand.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\UnloadTextureRenderCommand.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\RenderCommand.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\RenderCommandBuffer.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\RenderCommandList.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Shader.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Shader\\CSShaderProvider.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Shader\\RenderShader.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Shader\\RenderShaderManager.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Shader\\RenderShaderVariables.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Shader\\Shader.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Skybox.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Skybox\\SkyboxComponent.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Sprite.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Sprite\\SpriteComponent.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Sprite\\SpriteMeshBuilder.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Target.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Target\\RenderTargetGroup.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Target\\RenderTargetGroupManager.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Target\\TargetGroup.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Texture.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Texture\\Cubemap.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Texture\\CubemapProvider.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Texture\\CubemapResourceOptions.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Texture\\RenderTexture.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Texture\\RenderTextureManager.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Texture\\Texture.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Texture\\TextureAtlas.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Texture\\TextureAtlasProvider.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Texture\\TextureDesc.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Texture\\TextureFilterMode.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Texture\\TextureProvider.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Texture\\TextureResourceOptions.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Texture\\TextureWrapMode.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Texture\\UVs.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Social\\Communications.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Social\\Communications\\EmailComposer.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Social\\ForwardDeclarations.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\Base.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\Base\\Canvas.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\Base\\CursorSystem.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\Base\\PropertyLink.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\Base\\PropertyTypes.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\Base\\UIComponent.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\Base\\UIComponentDesc.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\Base\\UIComponentFactory.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\Base\\Widget.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\Base\\WidgetDef.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\Base\\WidgetDefProvider.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\Base\\WidgetDesc.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\Base\\WidgetFactory.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\Base\\WidgetParserUtils.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\Base\\WidgetTemplate.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\Base\\WidgetTemplateProvider.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\Button.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\Button\\HighlightUIComponent.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\Button\\ToggleHighlightUIComponent.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\Drawable.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\Drawable\\DrawableUIComponent.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\Drawable\\NinePatchUIDrawable.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\Drawable\\NinePatchUIDrawableDef.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\Drawable\\StandardUIDrawable.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\Drawable\\StandardUIDrawableDef.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\Drawable\\ThreePatchUIDrawable.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\Drawable\\ThreePatchUIDrawableDef.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\Drawable\\UIDrawable.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\Drawable\\UIDrawableDef.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\Drawable\\UIDrawableUtils.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\ForwardDeclarations.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\Layout.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\Layout\\GridUILayout.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\Layout\\GridUILayoutDef.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\Layout\\HListUILayout.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\Layout\\HListUILayoutDef.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\Layout\\LayoutDef.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\Layout\\LayoutUIComponent.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\Layout\\UILayout.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\Layout\\UILayoutDef.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\Layout\\VListUILayout.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\Layout\\VListUILayoutDef.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\ProgressBar.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\ProgressBar\\ProgressBarDirection.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\ProgressBar\\ProgressBarType.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\ProgressBar\\ProgressBarUIComponent.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\Slider.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\Slider\\SliderDirection.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\Slider\\SliderUIComponent.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\Text.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\Text\\EditableTextUIComponent.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\Text\\TextComponent.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\Text\\TextIcon.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\Text\\TextUIComponent.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Video\\Base.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Video\\Base\\CSSubtitlesProvider.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Video\\Base\\Subtitles.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Video\\Base\\VideoPlayer.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Video\\ForwardDeclarations.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Web\\Base.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Web\\Base\\WebView.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Web\\ForwardDeclarations.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\CSBackend\\Platform\\Windows\\Core\\Base\\PlatformSystem.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\CSBackend\\Platform\\Windows\\Core\\Base\\Screen.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\CSBackend\\Platform\\Windows\\Core\\Base\\SystemInfoFactory.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\CSBackend\\Platform\\Windows\\Core\\DialogueBox\\DialogueBoxSystem.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\CSBackend\\Platform\\Windows\\Core\\File\\FileSystem.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\CSBackend\\Platform\\Windows\\Core\\File\\WindowsFileUtils.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\CSBackend\\Platform\\Windows\\Core\\Image\\PngImage.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\CSBackend\\Platform\\Windows\\Core\\Image\\PNGImageProvider.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\CSBackend\\Platform\\Windows\\Core\\String\\WindowsStringUtils.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\CSBackend\\Platform\\Windows\\ForwardDeclarations.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\CSBackend\\Platform\\Windows\\Input\\DeviceButtons\\DeviceButtonSystem.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\CSBackend\\Platform\\Windows\\Input\\Gamepad\\GamepadSystem.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\CSBackend\\Platform\\Windows\\Input\\Keyboard\\Keyboard.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\CSBackend\\Platform\\Windows\\Input\\Pointer\\PointerSystem.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\CSBackend\\Platform\\Windows\\Input\\TextEntry\\TextEntry.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\CSBackend\\Platform\\Windows\\Networking\\Http\\HttpRequest.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\CSBackend\\Platform\\Windows\\Networking\\Http\\HttpRequestSystem.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\CSBackend\\Platform\\Windows\\SFML\\Base\\SFMLWindow.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\CSBackend\\Rendering\\OpenGL\\Base\\GLContextRestorer.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\CSBackend\\Rendering\\OpenGL\\Base\\GLError.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\CSBackend\\Rendering\\OpenGL\\Base\\GLExtensions.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\CSBackend\\Rendering\\OpenGL\\Base\\GLIncludes.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\CSBackend\\Rendering\\OpenGL\\Base\\RenderCommandProcessor.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\CSBackend\\Rendering\\OpenGL\\Base\\RenderInfoFactory.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\CSBackend\\Rendering\\OpenGL\\Camera\\GLCamera.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\CSBackend\\Rendering\\OpenGL\\ForwardDeclarations.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\CSBackend\\Rendering\\OpenGL\\Lighting\\GLAmbientLight.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\CSBackend\\Rendering\\OpenGL\\Lighting\\GLDirectionalLight.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\CSBackend\\Rendering\\OpenGL\\Lighting\\GLLight.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\CSBackend\\Rendering\\OpenGL\\Lighting\\GLPointLight.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\CSBackend\\Rendering\\OpenGL\\Material\\GLMaterial.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\CSBackend\\Rendering\\OpenGL\\Model\\GLDynamicMesh.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\CSBackend\\Rendering\\OpenGL\\Model\\GLMesh.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\CSBackend\\Rendering\\OpenGL\\Model\\GLMeshUtils.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\CSBackend\\Rendering\\OpenGL\\Model\\GLSkinnedAnimation.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\CSBackend\\Rendering\\OpenGL\\Shader\\GLShader.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\CSBackend\\Rendering\\OpenGL\\Target\\GLTargetGroup.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\CSBackend\\Rendering\\OpenGL\\Texture\\GLCubemap.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\CSBackend\\Rendering\\OpenGL\\Texture\\GLTexture.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\CSBackend\\Rendering\\OpenGL\\Texture\\GLTextureUnitManager.h\" />\r\n    <ClInclude Include=\"..\\..\\Source\\CSBackend\\Rendering\\OpenGL\\Texture\\GLTextureUtils.h\" />\r\n  </ItemGroup>\r\n  <PropertyGroup Label=\"Globals\">\r\n    <ProjectGuid>{09108227-056C-4A6F-9A74-1C3ECA245C3F}</ProjectGuid>\r\n    <Keyword>Win32Proj</Keyword>\r\n    <RootNamespace>ChilliSource</RootNamespace>\r\n    <WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>\r\n  </PropertyGroup>\r\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.Default.props\" />\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\" Label=\"Configuration\">\r\n    <ConfigurationType>StaticLibrary</ConfigurationType>\r\n    <UseDebugLibraries>true</UseDebugLibraries>\r\n    <PlatformToolset>v140</PlatformToolset>\r\n    <CharacterSet>Unicode</CharacterSet>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\" Label=\"Configuration\">\r\n    <ConfigurationType>StaticLibrary</ConfigurationType>\r\n    <UseDebugLibraries>false</UseDebugLibraries>\r\n    <PlatformToolset>v140</PlatformToolset>\r\n    <WholeProgramOptimization>true</WholeProgramOptimization>\r\n    <CharacterSet>Unicode</CharacterSet>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\" Label=\"Configuration\">\r\n    <ConfigurationType>StaticLibrary</ConfigurationType>\r\n    <UseDebugLibraries>true</UseDebugLibraries>\r\n    <PlatformToolset>v140</PlatformToolset>\r\n    <CharacterSet>Unicode</CharacterSet>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\" Label=\"Configuration\">\r\n    <ConfigurationType>StaticLibrary</ConfigurationType>\r\n    <UseDebugLibraries>false</UseDebugLibraries>\r\n    <PlatformToolset>v140</PlatformToolset>\r\n    <WholeProgramOptimization>true</WholeProgramOptimization>\r\n    <CharacterSet>Unicode</CharacterSet>\r\n  </PropertyGroup>\r\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.props\" />\r\n  <ImportGroup Label=\"ExtensionSettings\">\r\n  </ImportGroup>\r\n  <ImportGroup Label=\"Shared\">\r\n  </ImportGroup>\r\n  <ImportGroup Label=\"PropertySheets\" Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n  </ImportGroup>\r\n  <ImportGroup Label=\"PropertySheets\" Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n  </ImportGroup>\r\n  <ImportGroup Label=\"PropertySheets\" Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n  </ImportGroup>\r\n  <ImportGroup Label=\"PropertySheets\" Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n  </ImportGroup>\r\n  <PropertyGroup Label=\"UserMacros\" />\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">\r\n    <OutDir>$(SolutionDir)Build\\$(ProjectName)\\Output\\$(Platform)\\$(Configuration)\\</OutDir>\r\n    <IntDir>$(SolutionDir)Build\\$(ProjectName)\\Intermediate\\$(Platform)\\$(Configuration)\\a\\b\\</IntDir>\r\n    <IncludePath>$(ProjectDir)..\\..\\Source;$(ProjectDir)..\\..\\Libraries\\Core\\Windows\\Headers;$(ProjectDir)..\\..\\Libraries\\CricketAudio\\Windows\\Headers;$(IncludePath)</IncludePath>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n    <OutDir>$(SolutionDir)Build\\$(ProjectName)\\Output\\$(Platform)\\$(Configuration)\\</OutDir>\r\n    <IntDir>$(SolutionDir)Build\\$(ProjectName)\\Intermediate\\$(Platform)\\$(Configuration)\\a\\b\\</IntDir>\r\n    <IncludePath>$(ProjectDir)..\\..\\Source;$(ProjectDir)..\\..\\Libraries\\Core\\Windows\\Headers;$(ProjectDir)..\\..\\Libraries\\CricketAudio\\Windows\\Headers;$(IncludePath)</IncludePath>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">\r\n    <OutDir>$(SolutionDir)Build\\$(ProjectName)\\Output\\$(Platform)\\$(Configuration)\\</OutDir>\r\n    <IntDir>$(SolutionDir)Build\\$(ProjectName)\\Intermediate\\$(Platform)\\$(Configuration)\\a\\b\\</IntDir>\r\n    <IncludePath>$(ProjectDir)..\\..\\Source;$(ProjectDir)..\\..\\Libraries\\Core\\Windows\\Headers;$(ProjectDir)..\\..\\Libraries\\CricketAudio\\Windows\\Headers;$(IncludePath)</IncludePath>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n    <OutDir>$(SolutionDir)Build\\$(ProjectName)\\Output\\$(Platform)\\$(Configuration)\\</OutDir>\r\n    <IntDir>$(SolutionDir)Build\\$(ProjectName)\\Intermediate\\$(Platform)\\$(Configuration)\\a\\b\\</IntDir>\r\n    <IncludePath>$(ProjectDir)..\\..\\Source;$(ProjectDir)..\\..\\Libraries\\Core\\Windows\\Headers;$(ProjectDir)..\\..\\Libraries\\CricketAudio\\Windows\\Headers;$(IncludePath)</IncludePath>\r\n  </PropertyGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">\r\n    <ClCompile>\r\n      <PrecompiledHeader>\r\n      </PrecompiledHeader>\r\n      <WarningLevel>Level3</WarningLevel>\r\n      <Optimization>Disabled</Optimization>\r\n      <PreprocessorDefinitions>WIN32;_DEBUG;_LIB;GLEW_STATIC;SFML_STATIC;CS_TARGETPLATFORM_WINDOWS;CS_ENABLE_DEBUG;CS_LOGLEVEL_VERBOSE;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <SDLCheck>true</SDLCheck>\r\n      <ObjectFileName>$(IntDir)%(RelativeDir)</ObjectFileName>\r\n      <MultiProcessorCompilation>true</MultiProcessorCompilation>\r\n      <MinimalRebuild>false</MinimalRebuild>\r\n    </ClCompile>\r\n    <Link>\r\n      <SubSystem>Windows</SubSystem>\r\n    </Link>\r\n  </ItemDefinitionGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\r\n    <ClCompile>\r\n      <PrecompiledHeader>\r\n      </PrecompiledHeader>\r\n      <WarningLevel>Level3</WarningLevel>\r\n      <Optimization>Disabled</Optimization>\r\n      <PreprocessorDefinitions>_DEBUG;_LIB;GLEW_STATIC;SFML_STATIC;CS_TARGETPLATFORM_WINDOWS;CS_ENABLE_DEBUG;CS_LOGLEVEL_VERBOSE;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <SDLCheck>true</SDLCheck>\r\n      <ObjectFileName>$(IntDir)%(RelativeDir)</ObjectFileName>\r\n      <MultiProcessorCompilation>true</MultiProcessorCompilation>\r\n      <MinimalRebuild>false</MinimalRebuild>\r\n    </ClCompile>\r\n    <Link>\r\n      <SubSystem>Windows</SubSystem>\r\n    </Link>\r\n  </ItemDefinitionGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">\r\n    <ClCompile>\r\n      <WarningLevel>Level3</WarningLevel>\r\n      <PrecompiledHeader>\r\n      </PrecompiledHeader>\r\n      <Optimization>MaxSpeed</Optimization>\r\n      <FunctionLevelLinking>true</FunctionLevelLinking>\r\n      <IntrinsicFunctions>true</IntrinsicFunctions>\r\n      <PreprocessorDefinitions>WIN32;NDEBUG;_LIB;GLEW_STATIC;SFML_STATIC;CS_TARGETPLATFORM_WINDOWS;CS_LOGLEVEL_WARNING;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <SDLCheck>true</SDLCheck>\r\n      <ObjectFileName>$(IntDir)%(RelativeDir)</ObjectFileName>\r\n      <MultiProcessorCompilation>true</MultiProcessorCompilation>\r\n    </ClCompile>\r\n    <Link>\r\n      <SubSystem>Windows</SubSystem>\r\n      <EnableCOMDATFolding>true</EnableCOMDATFolding>\r\n      <OptimizeReferences>true</OptimizeReferences>\r\n    </Link>\r\n  </ItemDefinitionGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\r\n    <ClCompile>\r\n      <WarningLevel>Level3</WarningLevel>\r\n      <PrecompiledHeader>\r\n      </PrecompiledHeader>\r\n      <Optimization>MaxSpeed</Optimization>\r\n      <FunctionLevelLinking>true</FunctionLevelLinking>\r\n      <IntrinsicFunctions>true</IntrinsicFunctions>\r\n      <PreprocessorDefinitions>NDEBUG;_LIB;GLEW_STATIC;SFML_STATIC;CS_TARGETPLATFORM_WINDOWS;CS_LOGLEVEL_WARNING;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <SDLCheck>true</SDLCheck>\r\n      <ObjectFileName>$(IntDir)%(RelativeDir)</ObjectFileName>\r\n      <MultiProcessorCompilation>true</MultiProcessorCompilation>\r\n    </ClCompile>\r\n    <Link>\r\n      <SubSystem>Windows</SubSystem>\r\n      <EnableCOMDATFolding>true</EnableCOMDATFolding>\r\n      <OptimizeReferences>true</OptimizeReferences>\r\n    </Link>\r\n  </ItemDefinitionGroup>\r\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.targets\" />\r\n  <ImportGroup Label=\"ExtensionTargets\">\r\n  </ImportGroup>\r\n</Project>"
  },
  {
    "path": "Projects/Windows/ChilliSource.vcxproj.filters",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Project ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\r\n  <ItemGroup>\r\n    <Filter Include=\"ChilliSource\">\r\n      <UniqueIdentifier>{371476a4-5968-40f7-a542-bcf052e51490}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"ChilliSource\\Audio\">\r\n      <UniqueIdentifier>{9a8e2223-cf7b-4fdb-a83f-121c789a504a}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"ChilliSource\\Core\">\r\n      <UniqueIdentifier>{2fff1ae1-4104-4d80-bc82-dca64ef34435}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"ChilliSource\\Input\">\r\n      <UniqueIdentifier>{7e8f1521-ef02-41ac-9409-8fa6a1fab897}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"ChilliSource\\Networking\">\r\n      <UniqueIdentifier>{9e7d893f-2ab2-44af-8a28-a7bfdbb4e132}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"ChilliSource\\Rendering\">\r\n      <UniqueIdentifier>{f2e9f3b3-d361-48f0-9265-45fa2f3e506d}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"ChilliSource\\Social\">\r\n      <UniqueIdentifier>{c54d3ad8-51b6-424c-aabd-439067eed23a}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"ChilliSource\\UI\">\r\n      <UniqueIdentifier>{992fa2db-1d8a-4e57-a808-8a7ebc36a178}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"ChilliSource\\Video\">\r\n      <UniqueIdentifier>{43e9021d-0003-46e4-a07e-462df41bd9c4}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"ChilliSource\\Web\">\r\n      <UniqueIdentifier>{3f01c7eb-bb80-4b47-92ca-76593a2f2629}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"ChilliSource\\Audio\\CricketAudio\">\r\n      <UniqueIdentifier>{37c2942b-7379-479e-9604-8633134950c7}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"ChilliSource\\Core\\Base\">\r\n      <UniqueIdentifier>{64eb1997-2376-46a3-889a-0f2a318079d3}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"ChilliSource\\Core\\Container\">\r\n      <UniqueIdentifier>{0cb4ce30-ecfb-4b81-965a-b813e61546fd}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"ChilliSource\\Core\\Cryptographic\">\r\n      <UniqueIdentifier>{8b69876d-e367-4542-8cbe-9f8ce2608273}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"ChilliSource\\Core\\Delegate\">\r\n      <UniqueIdentifier>{dfb98fd3-232f-4dba-baaa-bc109acbcf02}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"ChilliSource\\Core\\DialogueBox\">\r\n      <UniqueIdentifier>{5d97727f-8ccb-48b9-9bc6-ccf390a7083a}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"ChilliSource\\Core\\Entity\">\r\n      <UniqueIdentifier>{8eafec56-dbbb-4a90-80aa-045339b133c2}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"ChilliSource\\Core\\Event\">\r\n      <UniqueIdentifier>{6c6e0834-0e76-453b-9ebe-33de77b1e47f}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"ChilliSource\\Core\\File\">\r\n      <UniqueIdentifier>{298432cc-aa2c-4826-99fe-3382827f5494}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"ChilliSource\\Core\\Image\">\r\n      <UniqueIdentifier>{59b03770-8db1-4f43-91a4-14c2216a8f74}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"ChilliSource\\Core\\Json\">\r\n      <UniqueIdentifier>{7a27a4d0-ec66-4fd7-876d-107b2b70034c}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"ChilliSource\\Core\\Localisation\">\r\n      <UniqueIdentifier>{520db0a6-f2b0-4fb5-a697-c0b47aae1b06}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"ChilliSource\\Core\\Math\">\r\n      <UniqueIdentifier>{472ffcf5-7ebb-4413-b1b7-e0ebc72ee5f8}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"ChilliSource\\Core\\Notification\">\r\n      <UniqueIdentifier>{a44c7e2f-e4ae-4baa-9d74-3d72cc5df6ea}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"ChilliSource\\Core\\Resource\">\r\n      <UniqueIdentifier>{f813bfdf-8003-40a7-8871-fc5417f8831d}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"ChilliSource\\Core\\Scene\">\r\n      <UniqueIdentifier>{9d57c15b-5796-44b7-a6bc-964a9231c12f}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"ChilliSource\\Core\\State\">\r\n      <UniqueIdentifier>{fe242866-60bc-45f2-97c1-ff276d5f8320}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"ChilliSource\\Core\\String\">\r\n      <UniqueIdentifier>{6a25877b-090f-47c9-9491-2b7b87b96171}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"ChilliSource\\Core\\System\">\r\n      <UniqueIdentifier>{a1ca205c-33aa-43a3-aeda-9e89b5c2f85d}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"ChilliSource\\Core\\Threading\">\r\n      <UniqueIdentifier>{3548af16-7110-40be-89fa-720cd333e164}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"ChilliSource\\Core\\Time\">\r\n      <UniqueIdentifier>{00928029-ab60-4913-8297-3a9f06f4d5a0}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"ChilliSource\\Core\\Tween\">\r\n      <UniqueIdentifier>{7792aac1-4b65-4e7d-91bd-8d669cb4f279}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"ChilliSource\\Core\\Volume\">\r\n      <UniqueIdentifier>{6fd20dae-1562-4694-afb4-b7b5f3a95bb9}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"ChilliSource\\Core\\XML\">\r\n      <UniqueIdentifier>{64e041ef-6054-449e-9707-da083ee4d739}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"ChilliSource\\Core\\Container\\Property\">\r\n      <UniqueIdentifier>{4833f95e-541a-4158-bc02-d3a69fcedf82}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"ChilliSource\\Core\\Math\\Geometry\">\r\n      <UniqueIdentifier>{5af2ed2a-55a8-4b32-90c7-87a8e1ae6ea6}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"ChilliSource\\Input\\Accelerometer\">\r\n      <UniqueIdentifier>{5457d739-226e-458f-9388-fbdb7ca23410}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"ChilliSource\\Input\\Base\">\r\n      <UniqueIdentifier>{fe440359-8286-4b43-a394-b9ded2603aaf}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"ChilliSource\\Input\\DeviceButtons\">\r\n      <UniqueIdentifier>{f4254627-1ae8-4005-b7f0-f2203f7ad4d6}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"ChilliSource\\Input\\Gesture\">\r\n      <UniqueIdentifier>{958b5d24-dc5d-42e9-9b81-e022c246e01c}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"ChilliSource\\Input\\Keyboard\">\r\n      <UniqueIdentifier>{660c0090-3b3c-4512-a4c0-e0dd04e38278}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"ChilliSource\\Input\\Pointer\">\r\n      <UniqueIdentifier>{53723a8c-8dd4-4117-bb4d-0d5e1e60bbc3}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"ChilliSource\\Input\\TextEntry\">\r\n      <UniqueIdentifier>{04cb765e-6300-49d0-8a25-bc1a61ecad5c}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"ChilliSource\\Networking\\ContentDownload\">\r\n      <UniqueIdentifier>{71c6c250-b262-4566-829e-96c869c33fc7}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"ChilliSource\\Networking\\Http\">\r\n      <UniqueIdentifier>{321a4294-18b3-4da4-9d5a-93aa01aebbb9}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"ChilliSource\\Networking\\IAP\">\r\n      <UniqueIdentifier>{558da864-7fd3-405c-adfa-3670d8b41398}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"ChilliSource\\Web\\Base\">\r\n      <UniqueIdentifier>{9c050e54-e525-478a-ad12-6072698d1d10}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"ChilliSource\\Video\\Base\">\r\n      <UniqueIdentifier>{554188c5-6e35-4a58-b653-f866fce4e210}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"ChilliSource\\UI\\Base\">\r\n      <UniqueIdentifier>{6172a721-75c9-4b4d-bdfb-d9eae4ede984}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"ChilliSource\\UI\\Button\">\r\n      <UniqueIdentifier>{2d94ba2d-2d9f-4dda-9bf8-e0848a8805c0}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"ChilliSource\\UI\\Drawable\">\r\n      <UniqueIdentifier>{7550413c-3e33-4231-8a47-7ed6ab8b2e29}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"ChilliSource\\UI\\Layout\">\r\n      <UniqueIdentifier>{da61a963-c196-4186-a58c-44617223435f}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"ChilliSource\\UI\\ProgressBar\">\r\n      <UniqueIdentifier>{dad02184-0d89-48e9-8fb8-4c9c17f11575}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"ChilliSource\\UI\\Slider\">\r\n      <UniqueIdentifier>{a780c4c9-2dec-4050-bd8e-244dc4e25d18}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"ChilliSource\\UI\\Text\">\r\n      <UniqueIdentifier>{4b8db51b-3b7f-4aa9-81f7-0bbd648404ec}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"ChilliSource\\Social\\Communications\">\r\n      <UniqueIdentifier>{5b9932d7-d6e0-430c-b7db-3727a93bfce3}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"ChilliSource\\Rendering\\Base\">\r\n      <UniqueIdentifier>{037448da-61e0-4e5e-a50f-eae2f90ccff4}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"ChilliSource\\Rendering\\Camera\">\r\n      <UniqueIdentifier>{fd2b5a0c-8ab1-4ae9-aa59-6cb892409dc5}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"ChilliSource\\Rendering\\Font\">\r\n      <UniqueIdentifier>{f5666274-eb41-4a59-aa7b-59d46a528a7a}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"ChilliSource\\Rendering\\Lighting\">\r\n      <UniqueIdentifier>{b6e288c3-bd6f-4cfd-bc30-75ad554f3544}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"ChilliSource\\Rendering\\Material\">\r\n      <UniqueIdentifier>{73060a2b-f747-44ba-8917-20cbb634b425}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"ChilliSource\\Rendering\\Model\">\r\n      <UniqueIdentifier>{765af19e-7b31-4e28-9b8b-b73313af2ca2}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"ChilliSource\\Rendering\\Particle\">\r\n      <UniqueIdentifier>{986ce9d0-c5df-4763-9985-1ebe64bef5d6}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"ChilliSource\\Rendering\\Shader\">\r\n      <UniqueIdentifier>{184417e3-7e9f-41db-8c7a-bc705e25b91f}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"ChilliSource\\Rendering\\Sprite\">\r\n      <UniqueIdentifier>{f2857003-a3bb-41be-84f2-158dd6a8bc65}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"ChilliSource\\Rendering\\Texture\">\r\n      <UniqueIdentifier>{a9ea9e31-4a87-4edd-99b5-c5e306cebb5a}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"ChilliSource\\Rendering\\Particle\\Affector\">\r\n      <UniqueIdentifier>{9ea7e2c5-7a86-43fd-8ce1-d2424183f80c}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"ChilliSource\\Rendering\\Particle\\Drawable\">\r\n      <UniqueIdentifier>{ff04a469-ea04-4521-8f2f-7b46fa2a2423}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"ChilliSource\\Rendering\\Particle\\Emitter\">\r\n      <UniqueIdentifier>{c79eb542-2324-4f3a-adea-d0cd582a0360}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"ChilliSource\\Rendering\\Particle\\Property\">\r\n      <UniqueIdentifier>{4ea0a666-1638-470f-b8d6-7cde2b92d88a}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"CSBackend\">\r\n      <UniqueIdentifier>{f8e2e63f-2a37-483d-a975-8e1006578c9d}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"CSBackend\\Platform\">\r\n      <UniqueIdentifier>{96f2ddf6-fffb-4351-abbc-0c8266700fe2}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"CSBackend\\Platform\\Windows\">\r\n      <UniqueIdentifier>{0a9f903e-37d9-41cc-9de0-5991351d508a}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"CSBackend\\Platform\\Windows\\Core\">\r\n      <UniqueIdentifier>{f21ccb6d-b025-43fd-be4a-8388303c3a47}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"CSBackend\\Platform\\Windows\\Core\\Base\">\r\n      <UniqueIdentifier>{6bdfa2ef-26fe-4906-9fa6-52f337b66098}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"CSBackend\\Platform\\Windows\\Core\\DialogueBox\">\r\n      <UniqueIdentifier>{0d75b79a-be8c-4ad4-8e91-2c885f89b306}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"CSBackend\\Platform\\Windows\\Core\\File\">\r\n      <UniqueIdentifier>{ab48426d-4f31-424d-8d99-9b6e5d338a31}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"CSBackend\\Platform\\Windows\\Core\\Image\">\r\n      <UniqueIdentifier>{ffcf2e8a-d195-4e9a-a1a8-502f1a75feca}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"CSBackend\\Platform\\Windows\\Core\\String\">\r\n      <UniqueIdentifier>{a3e0d1e0-f28e-4b25-8262-1430a66579d9}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"CSBackend\\Rendering\">\r\n      <UniqueIdentifier>{49ca177a-f51d-46e0-8dc6-a82308585ffa}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"CSBackend\\Rendering\\OpenGL\">\r\n      <UniqueIdentifier>{dd6b40bb-ffa2-4e0e-93c4-2f2e42c481e4}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"CSBackend\\Platform\\Windows\\Input\">\r\n      <UniqueIdentifier>{c5df3d10-0cb1-444d-9275-1f30335136bc}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"CSBackend\\Platform\\Windows\\Input\\DeviceButtons\">\r\n      <UniqueIdentifier>{06aa8e2c-7116-4119-b307-9333b1cc3773}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"CSBackend\\Platform\\Windows\\Input\\Keyboard\">\r\n      <UniqueIdentifier>{80530fc6-06ee-40c3-a311-7820d099b5fe}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"CSBackend\\Platform\\Windows\\Input\\Pointer\">\r\n      <UniqueIdentifier>{66e9314e-7b5a-4cd2-a83a-e27c5886889d}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"CSBackend\\Platform\\Windows\\Input\\TextEntry\">\r\n      <UniqueIdentifier>{33470de3-5426-4de5-ae80-cbdee16bf47d}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"CSBackend\\Platform\\Windows\\Networking\">\r\n      <UniqueIdentifier>{c093ffeb-b1c0-4399-8c2e-47c1d05ca7bb}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"CSBackend\\Platform\\Windows\\Networking\\Http\">\r\n      <UniqueIdentifier>{731caab4-bfa2-41b9-8832-65ab66f98b9f}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"CSBackend\\Platform\\Windows\\SFML\">\r\n      <UniqueIdentifier>{39a2e315-2501-4d95-ae13-56e938d75668}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"CSBackend\\Platform\\Windows\\SFML\\Base\">\r\n      <UniqueIdentifier>{5676c136-6c42-40ce-af9d-4b4cd8208f41}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"CSBackend\\Rendering\\OpenGL\\Base\">\r\n      <UniqueIdentifier>{08762056-5867-44b3-9835-f4c7c835ae00}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"CSBackend\\Rendering\\OpenGL\\Texture\">\r\n      <UniqueIdentifier>{b9c298b4-86f6-42f4-b08b-cccf39ca0284}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"ChilliSource\\Rendering\\RenderCommand\">\r\n      <UniqueIdentifier>{aae3135a-a8b7-4dd6-9c9b-96d29c2c54a7}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"ChilliSource\\Rendering\\RenderCommand\\Commands\">\r\n      <UniqueIdentifier>{c2eb53b5-a623-49e1-806b-44d9d1f2417c}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"CSBackend\\Rendering\\OpenGL\\Model\">\r\n      <UniqueIdentifier>{408fa944-c114-41fa-847a-027e49dff283}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"CSBackend\\Rendering\\OpenGL\\Shader\">\r\n      <UniqueIdentifier>{6e3ada5f-5fe9-49f6-a37a-f815cbeef523}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"ChilliSource\\Core\\File\\FileStream\">\r\n      <UniqueIdentifier>{58b86741-22bf-4fee-a185-277889c92c94}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"CSBackend\\Rendering\\OpenGL\\Material\">\r\n      <UniqueIdentifier>{ac322408-c7ba-4202-b831-14661a51ed2a}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"CSBackend\\Rendering\\OpenGL\\Camera\">\r\n      <UniqueIdentifier>{8e88dc6e-d075-47ce-bc7e-dc460822f3a7}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"CSBackend\\Rendering\\OpenGL\\Target\">\r\n      <UniqueIdentifier>{109a90c2-eb9a-4708-acd9-a70e96d16822}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"ChilliSource\\Rendering\\Target\">\r\n      <UniqueIdentifier>{c35d03fc-4744-4127-8c2e-2f9aba86718e}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"CSBackend\\Rendering\\OpenGL\\Lighting\">\r\n      <UniqueIdentifier>{16a9f81a-57d5-40c8-ae06-05f83c347d78}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"ChilliSource\\Core\\Memory\">\r\n      <UniqueIdentifier>{d6135d70-2135-4b7d-9b0c-58ad8fd39986}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"ChilliSource\\Rendering\\Skybox\">\r\n      <UniqueIdentifier>{e7f2619c-3315-4d26-966e-a967895927c2}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"ChilliSource\\Input\\Gyroscope\">\r\n      <UniqueIdentifier>{9d7672e5-bc0b-4243-bab5-86dc856f73d6}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"ChilliSource\\Input\\Gamepad\">\r\n      <UniqueIdentifier>{54421406-d40e-4873-8694-f00c554cfc5c}</UniqueIdentifier>\r\n    </Filter>\r\n    <Filter Include=\"CSBackend\\Platform\\Windows\\Input\\Gamepad\">\r\n      <UniqueIdentifier>{818fe1c6-2582-4849-a48c-b18fe3e877d1}</UniqueIdentifier>\r\n    </Filter>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Audio\\CricketAudio\\CkAudioPlayer.cpp\">\r\n      <Filter>ChilliSource\\Audio\\CricketAudio</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Audio\\CricketAudio\\CkBank.cpp\">\r\n      <Filter>ChilliSource\\Audio\\CricketAudio</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Audio\\CricketAudio\\CkBankProvider.cpp\">\r\n      <Filter>ChilliSource\\Audio\\CricketAudio</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Audio\\CricketAudio\\CkSound.cpp\">\r\n      <Filter>ChilliSource\\Audio\\CricketAudio</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Audio\\CricketAudio\\CricketAudioSystem.cpp\">\r\n      <Filter>ChilliSource\\Audio\\CricketAudio</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Base\\AppConfig.cpp\">\r\n      <Filter>ChilliSource\\Core\\Base</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Base\\Application.cpp\">\r\n      <Filter>ChilliSource\\Core\\Base</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Base\\ByteColour.cpp\">\r\n      <Filter>ChilliSource\\Core\\Base</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Base\\Colour.cpp\">\r\n      <Filter>ChilliSource\\Core\\Base</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Base\\ColourUtils.cpp\">\r\n      <Filter>ChilliSource\\Core\\Base</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Base\\Device.cpp\">\r\n      <Filter>ChilliSource\\Core\\Base</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Base\\Logging.cpp\">\r\n      <Filter>ChilliSource\\Core\\Base</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Base\\PlatformSystem.cpp\">\r\n      <Filter>ChilliSource\\Core\\Base</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Base\\Screen.cpp\">\r\n      <Filter>ChilliSource\\Core\\Base</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Base\\Utils.cpp\">\r\n      <Filter>ChilliSource\\Core\\Base</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Container\\ParamDictionary.cpp\">\r\n      <Filter>ChilliSource\\Core\\Container</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Container\\ParamDictionarySerialiser.cpp\">\r\n      <Filter>ChilliSource\\Core\\Container</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Container\\Property\\PropertyMap.cpp\">\r\n      <Filter>ChilliSource\\Core\\Container\\Property</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Container\\Property\\PropertyTypes.cpp\">\r\n      <Filter>ChilliSource\\Core\\Container\\Property</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Cryptographic\\AESEncrypt.cpp\">\r\n      <Filter>ChilliSource\\Core\\Cryptographic</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Cryptographic\\BaseEncoding.cpp\">\r\n      <Filter>ChilliSource\\Core\\Cryptographic</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Cryptographic\\HashCRC32.cpp\">\r\n      <Filter>ChilliSource\\Core\\Cryptographic</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Cryptographic\\HashMD5.cpp\">\r\n      <Filter>ChilliSource\\Core\\Cryptographic</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Cryptographic\\HashSHA1.cpp\">\r\n      <Filter>ChilliSource\\Core\\Cryptographic</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Cryptographic\\OAuth.cpp\">\r\n      <Filter>ChilliSource\\Core\\Cryptographic</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\DialogueBox\\DialogueBoxSystem.cpp\">\r\n      <Filter>ChilliSource\\Core\\DialogueBox</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Entity\\Component.cpp\">\r\n      <Filter>ChilliSource\\Core\\Entity</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Entity\\Entity.cpp\">\r\n      <Filter>ChilliSource\\Core\\Entity</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Entity\\PrimitiveEntityFactory.cpp\">\r\n      <Filter>ChilliSource\\Core\\Entity</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Entity\\Transform.cpp\">\r\n      <Filter>ChilliSource\\Core\\Entity</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Event\\EventConnection.cpp\">\r\n      <Filter>ChilliSource\\Core\\Event</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\File\\AppDataStore.cpp\">\r\n      <Filter>ChilliSource\\Core\\File</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\File\\CSBinaryChunk.cpp\">\r\n      <Filter>ChilliSource\\Core\\File</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\File\\CSBinaryInputStream.cpp\">\r\n      <Filter>ChilliSource\\Core\\File</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\File\\FileSystem.cpp\">\r\n      <Filter>ChilliSource\\Core\\File</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\File\\TaggedFilePathResolver.cpp\">\r\n      <Filter>ChilliSource\\Core\\File</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Image\\CSImageProvider.cpp\">\r\n      <Filter>ChilliSource\\Core\\Image</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Image\\ETC1ImageProvider.cpp\">\r\n      <Filter>ChilliSource\\Core\\Image</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Image\\Image.cpp\">\r\n      <Filter>ChilliSource\\Core\\Image</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Image\\ImageFormatConverter.cpp\">\r\n      <Filter>ChilliSource\\Core\\Image</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Image\\PNGImageProvider.cpp\">\r\n      <Filter>ChilliSource\\Core\\Image</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Image\\PVRImageProvider.cpp\">\r\n      <Filter>ChilliSource\\Core\\Image</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Json\\JsonUtils.cpp\">\r\n      <Filter>ChilliSource\\Core\\Json</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Localisation\\LocalisedText.cpp\">\r\n      <Filter>ChilliSource\\Core\\Localisation</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Localisation\\LocalisedTextProvider.cpp\">\r\n      <Filter>ChilliSource\\Core\\Localisation</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Math\\Interpolate.cpp\">\r\n      <Filter>ChilliSource\\Core\\Math</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Math\\MathUtils.cpp\">\r\n      <Filter>ChilliSource\\Core\\Math</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Math\\Random.cpp\">\r\n      <Filter>ChilliSource\\Core\\Math</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Math\\UnifiedCoordinates.cpp\">\r\n      <Filter>ChilliSource\\Core\\Math</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Math\\Geometry\\ShapeIntersection.cpp\">\r\n      <Filter>ChilliSource\\Core\\Math\\Geometry</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Math\\Geometry\\Shapes.cpp\">\r\n      <Filter>ChilliSource\\Core\\Math\\Geometry</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\XML\\XML.cpp\">\r\n      <Filter>ChilliSource\\Core\\XML</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\XML\\XMLUtils.cpp\">\r\n      <Filter>ChilliSource\\Core\\XML</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Volume\\VolumeComponent.cpp\">\r\n      <Filter>ChilliSource\\Core\\Volume</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Time\\CoreTimer.cpp\">\r\n      <Filter>ChilliSource\\Core\\Time</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Time\\PerformanceTimer.cpp\">\r\n      <Filter>ChilliSource\\Core\\Time</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Time\\Timer.cpp\">\r\n      <Filter>ChilliSource\\Core\\Time</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\System\\StateSystem.cpp\">\r\n      <Filter>ChilliSource\\Core\\System</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\String\\MarkupDef.cpp\">\r\n      <Filter>ChilliSource\\Core\\String</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\String\\StringMarkupParser.cpp\">\r\n      <Filter>ChilliSource\\Core\\String</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\String\\StringParser.cpp\">\r\n      <Filter>ChilliSource\\Core\\String</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\String\\StringUtils.cpp\">\r\n      <Filter>ChilliSource\\Core\\String</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\String\\ToString.cpp\">\r\n      <Filter>ChilliSource\\Core\\String</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\String\\UTF8StringUtils.cpp\">\r\n      <Filter>ChilliSource\\Core\\String</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\State\\State.cpp\">\r\n      <Filter>ChilliSource\\Core\\State</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\State\\StateManager.cpp\">\r\n      <Filter>ChilliSource\\Core\\State</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Scene\\Scene.cpp\">\r\n      <Filter>ChilliSource\\Core\\Scene</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Resource\\Resource.cpp\">\r\n      <Filter>ChilliSource\\Core\\Resource</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Resource\\ResourcePool.cpp\">\r\n      <Filter>ChilliSource\\Core\\Resource</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Resource\\ResourceProvider.cpp\">\r\n      <Filter>ChilliSource\\Core\\Resource</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Notification\\AppNotificationSystem.cpp\">\r\n      <Filter>ChilliSource\\Core\\Notification</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Notification\\LocalNotificationSystem.cpp\">\r\n      <Filter>ChilliSource\\Core\\Notification</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Notification\\NotificationManager.cpp\">\r\n      <Filter>ChilliSource\\Core\\Notification</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Notification\\RemoteNotificationSystem.cpp\">\r\n      <Filter>ChilliSource\\Core\\Notification</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Input\\Accelerometer\\Accelerometer.cpp\">\r\n      <Filter>ChilliSource\\Input\\Accelerometer</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Input\\DeviceButtons\\DeviceButtonSystem.cpp\">\r\n      <Filter>ChilliSource\\Input\\DeviceButtons</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Input\\Gesture\\DragGesture.cpp\">\r\n      <Filter>ChilliSource\\Input\\Gesture</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Input\\Gesture\\Gesture.cpp\">\r\n      <Filter>ChilliSource\\Input\\Gesture</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Input\\Gesture\\GestureSystem.cpp\">\r\n      <Filter>ChilliSource\\Input\\Gesture</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Input\\Gesture\\HoldGesture.cpp\">\r\n      <Filter>ChilliSource\\Input\\Gesture</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Input\\Gesture\\PinchGesture.cpp\">\r\n      <Filter>ChilliSource\\Input\\Gesture</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Input\\Gesture\\RotationGesture.cpp\">\r\n      <Filter>ChilliSource\\Input\\Gesture</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Input\\Gesture\\TapGesture.cpp\">\r\n      <Filter>ChilliSource\\Input\\Gesture</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Input\\Keyboard\\Keyboard.cpp\">\r\n      <Filter>ChilliSource\\Input\\Keyboard</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Input\\TextEntry\\TextEntry.cpp\">\r\n      <Filter>ChilliSource\\Input\\TextEntry</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Input\\Pointer\\Pointer.cpp\">\r\n      <Filter>ChilliSource\\Input\\Pointer</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Input\\Pointer\\PointerSystem.cpp\">\r\n      <Filter>ChilliSource\\Input\\Pointer</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Networking\\ContentDownload\\ContentManagementSystem.cpp\">\r\n      <Filter>ChilliSource\\Networking\\ContentDownload</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Networking\\ContentDownload\\MoContentDownloader.cpp\">\r\n      <Filter>ChilliSource\\Networking\\ContentDownload</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Networking\\Http\\HttpRequestSystem.cpp\">\r\n      <Filter>ChilliSource\\Networking\\Http</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Networking\\Http\\HttpResponse.cpp\">\r\n      <Filter>ChilliSource\\Networking\\Http</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Networking\\IAP\\IAPSystem.cpp\">\r\n      <Filter>ChilliSource\\Networking\\IAP</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Web\\Base\\WebView.cpp\">\r\n      <Filter>ChilliSource\\Web\\Base</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Video\\Base\\CSSubtitlesProvider.cpp\">\r\n      <Filter>ChilliSource\\Video\\Base</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Video\\Base\\Subtitles.cpp\">\r\n      <Filter>ChilliSource\\Video\\Base</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Video\\Base\\VideoPlayer.cpp\">\r\n      <Filter>ChilliSource\\Video\\Base</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Social\\Communications\\EmailComposer.cpp\">\r\n      <Filter>ChilliSource\\Social\\Communications</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Camera\\CameraComponent.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Camera</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Camera\\OrthographicCameraComponent.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Camera</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Camera\\PerspectiveCameraComponent.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Camera</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Font\\Font.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Font</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Font\\FontProvider.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Font</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Lighting\\AmbientLightComponent.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Lighting</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Lighting\\DirectionalLightComponent.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Lighting</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Lighting\\PointLightComponent.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Lighting</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Material\\Material.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Material</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Material\\MaterialFactory.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Material</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Material\\MaterialProvider.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Material</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Texture\\Texture.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Texture</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Texture\\TextureAtlas.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Texture</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Texture\\TextureAtlasProvider.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Texture</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Texture\\TextureProvider.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Texture</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Texture\\TextureResourceOptions.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Texture</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Texture\\UVs.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Texture</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Sprite\\SpriteComponent.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Sprite</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Shader\\Shader.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Shader</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\ConcurrentParticleData.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Particle</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\CSParticleProvider.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Particle</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\ParticleEffect.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Particle</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\ParticleEffectComponent.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Particle</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Affector\\AccelerationParticleAffector.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Particle\\Affector</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Affector\\AccelerationParticleAffectorDef.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Particle\\Affector</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Affector\\AngularAccelerationParticleAffector.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Particle\\Affector</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Affector\\AngularAccelerationParticleAffectorDef.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Particle\\Affector</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Affector\\ColourOverLifetimeParticleAffector.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Particle\\Affector</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Affector\\ColourOverLifetimeParticleAffectorDef.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Particle\\Affector</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Affector\\ParticleAffector.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Particle\\Affector</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Affector\\ParticleAffectorDef.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Particle\\Affector</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Affector\\ParticleAffectorDefFactory.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Particle\\Affector</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Affector\\ScaleOverLifetimeParticleAffector.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Particle\\Affector</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Affector\\ScaleOverLifetimeParticleAffectorDef.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Particle\\Affector</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Drawable\\ParticleDrawable.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Particle\\Drawable</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Drawable\\ParticleDrawableDef.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Particle\\Drawable</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Drawable\\ParticleDrawableDefFactory.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Particle\\Drawable</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Drawable\\StaticBillboardParticleDrawable.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Particle\\Drawable</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Drawable\\StaticBillboardParticleDrawableDef.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Particle\\Drawable</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Emitter\\CircleParticleEmitter.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Particle\\Emitter</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Emitter\\CircleParticleEmitterDef.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Particle\\Emitter</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Emitter\\Cone2DParticleEmitter.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Particle\\Emitter</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Emitter\\Cone2DParticleEmitterDef.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Particle\\Emitter</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Emitter\\ConeParticleEmitter.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Particle\\Emitter</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Emitter\\ConeParticleEmitterDef.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Particle\\Emitter</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Emitter\\ParticleEmitter.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Particle\\Emitter</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Emitter\\ParticleEmitterDef.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Particle\\Emitter</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Emitter\\ParticleEmitterDefFactory.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Particle\\Emitter</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Emitter\\PointParticleEmitter.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Particle\\Emitter</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Emitter\\PointParticleEmitterDef.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Particle\\Emitter</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Emitter\\SphereParticleEmitter.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Particle\\Emitter</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Emitter\\SphereParticleEmitterDef.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Particle\\Emitter</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Property\\ParticlePropertyFactoryImpl.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Particle\\Property</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\CSBackend\\Platform\\Windows\\Main.cpp\">\r\n      <Filter>CSBackend\\Platform\\Windows</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\CSBackend\\Platform\\Windows\\Core\\Base\\PlatformSystem.cpp\">\r\n      <Filter>CSBackend\\Platform\\Windows\\Core\\Base</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\CSBackend\\Platform\\Windows\\Core\\Base\\Screen.cpp\">\r\n      <Filter>CSBackend\\Platform\\Windows\\Core\\Base</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\CSBackend\\Platform\\Windows\\Core\\DialogueBox\\DialogueBoxSystem.cpp\">\r\n      <Filter>CSBackend\\Platform\\Windows\\Core\\DialogueBox</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\CSBackend\\Platform\\Windows\\Core\\File\\FileSystem.cpp\">\r\n      <Filter>CSBackend\\Platform\\Windows\\Core\\File</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\CSBackend\\Platform\\Windows\\Core\\File\\WindowsFileUtils.cpp\">\r\n      <Filter>CSBackend\\Platform\\Windows\\Core\\File</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\CSBackend\\Platform\\Windows\\Core\\Image\\PngImage.cpp\">\r\n      <Filter>CSBackend\\Platform\\Windows\\Core\\Image</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\CSBackend\\Platform\\Windows\\Core\\Image\\PNGImageProvider.cpp\">\r\n      <Filter>CSBackend\\Platform\\Windows\\Core\\Image</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\CSBackend\\Platform\\Windows\\Core\\String\\WindowsStringUtils.cpp\">\r\n      <Filter>CSBackend\\Platform\\Windows\\Core\\String</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\CSBackend\\Platform\\Windows\\Input\\DeviceButtons\\DeviceButtonSystem.cpp\">\r\n      <Filter>CSBackend\\Platform\\Windows\\Input\\DeviceButtons</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\CSBackend\\Platform\\Windows\\Input\\Keyboard\\Keyboard.cpp\">\r\n      <Filter>CSBackend\\Platform\\Windows\\Input\\Keyboard</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\CSBackend\\Platform\\Windows\\Input\\TextEntry\\TextEntry.cpp\">\r\n      <Filter>CSBackend\\Platform\\Windows\\Input\\TextEntry</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\CSBackend\\Platform\\Windows\\Input\\Pointer\\PointerSystem.cpp\">\r\n      <Filter>CSBackend\\Platform\\Windows\\Input\\Pointer</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\CSBackend\\Platform\\Windows\\Networking\\Http\\HttpRequest.cpp\">\r\n      <Filter>CSBackend\\Platform\\Windows\\Networking\\Http</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\CSBackend\\Platform\\Windows\\Networking\\Http\\HttpRequestSystem.cpp\">\r\n      <Filter>CSBackend\\Platform\\Windows\\Networking\\Http</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\CSBackend\\Platform\\Windows\\SFML\\Base\\SFMLWindow.cpp\">\r\n      <Filter>CSBackend\\Platform\\Windows\\SFML\\Base</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\CSBackend\\Rendering\\OpenGL\\Base\\GLError.cpp\">\r\n      <Filter>CSBackend\\Rendering\\OpenGL\\Base</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Threading\\TaskContext.cpp\">\r\n      <Filter>ChilliSource\\Core\\Threading</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Threading\\TaskPool.cpp\">\r\n      <Filter>ChilliSource\\Core\\Threading</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Threading\\TaskScheduler.cpp\">\r\n      <Filter>ChilliSource\\Core\\Threading</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\UI\\Base\\Canvas.cpp\">\r\n      <Filter>ChilliSource\\UI\\Base</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\UI\\Base\\PropertyLink.cpp\">\r\n      <Filter>ChilliSource\\UI\\Base</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\UI\\Base\\PropertyTypes.cpp\">\r\n      <Filter>ChilliSource\\UI\\Base</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\UI\\Base\\UIComponent.cpp\">\r\n      <Filter>ChilliSource\\UI\\Base</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\UI\\Base\\UIComponentDesc.cpp\">\r\n      <Filter>ChilliSource\\UI\\Base</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\UI\\Base\\UIComponentFactory.cpp\">\r\n      <Filter>ChilliSource\\UI\\Base</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\UI\\Base\\Widget.cpp\">\r\n      <Filter>ChilliSource\\UI\\Base</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\UI\\Base\\WidgetDef.cpp\">\r\n      <Filter>ChilliSource\\UI\\Base</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\UI\\Base\\WidgetDefProvider.cpp\">\r\n      <Filter>ChilliSource\\UI\\Base</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\UI\\Base\\WidgetDesc.cpp\">\r\n      <Filter>ChilliSource\\UI\\Base</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\UI\\Base\\WidgetFactory.cpp\">\r\n      <Filter>ChilliSource\\UI\\Base</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\UI\\Base\\WidgetParserUtils.cpp\">\r\n      <Filter>ChilliSource\\UI\\Base</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\UI\\Base\\WidgetTemplate.cpp\">\r\n      <Filter>ChilliSource\\UI\\Base</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\UI\\Base\\WidgetTemplateProvider.cpp\">\r\n      <Filter>ChilliSource\\UI\\Base</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\UI\\Button\\HighlightUIComponent.cpp\">\r\n      <Filter>ChilliSource\\UI\\Button</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\UI\\Button\\ToggleHighlightUIComponent.cpp\">\r\n      <Filter>ChilliSource\\UI\\Button</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\UI\\Drawable\\DrawableUIComponent.cpp\">\r\n      <Filter>ChilliSource\\UI\\Drawable</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\UI\\Drawable\\NinePatchUIDrawable.cpp\">\r\n      <Filter>ChilliSource\\UI\\Drawable</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\UI\\Drawable\\NinePatchUIDrawableDef.cpp\">\r\n      <Filter>ChilliSource\\UI\\Drawable</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\UI\\Drawable\\StandardUIDrawable.cpp\">\r\n      <Filter>ChilliSource\\UI\\Drawable</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\UI\\Drawable\\StandardUIDrawableDef.cpp\">\r\n      <Filter>ChilliSource\\UI\\Drawable</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\UI\\Drawable\\ThreePatchUIDrawable.cpp\">\r\n      <Filter>ChilliSource\\UI\\Drawable</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\UI\\Drawable\\ThreePatchUIDrawableDef.cpp\">\r\n      <Filter>ChilliSource\\UI\\Drawable</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\UI\\Drawable\\UIDrawable.cpp\">\r\n      <Filter>ChilliSource\\UI\\Drawable</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\UI\\Drawable\\UIDrawableDef.cpp\">\r\n      <Filter>ChilliSource\\UI\\Drawable</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\UI\\Drawable\\UIDrawableUtils.cpp\">\r\n      <Filter>ChilliSource\\UI\\Drawable</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\UI\\Layout\\GridUILayout.cpp\">\r\n      <Filter>ChilliSource\\UI\\Layout</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\UI\\Layout\\GridUILayoutDef.cpp\">\r\n      <Filter>ChilliSource\\UI\\Layout</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\UI\\Layout\\HListUILayout.cpp\">\r\n      <Filter>ChilliSource\\UI\\Layout</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\UI\\Layout\\HListUILayoutDef.cpp\">\r\n      <Filter>ChilliSource\\UI\\Layout</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\UI\\Layout\\LayoutUIComponent.cpp\">\r\n      <Filter>ChilliSource\\UI\\Layout</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\UI\\Layout\\UILayout.cpp\">\r\n      <Filter>ChilliSource\\UI\\Layout</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\UI\\Layout\\UILayoutDef.cpp\">\r\n      <Filter>ChilliSource\\UI\\Layout</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\UI\\Layout\\VListUILayout.cpp\">\r\n      <Filter>ChilliSource\\UI\\Layout</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\UI\\Layout\\VListUILayoutDef.cpp\">\r\n      <Filter>ChilliSource\\UI\\Layout</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\UI\\ProgressBar\\ProgressBarDirection.cpp\">\r\n      <Filter>ChilliSource\\UI\\ProgressBar</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\UI\\ProgressBar\\ProgressBarType.cpp\">\r\n      <Filter>ChilliSource\\UI\\ProgressBar</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\UI\\ProgressBar\\ProgressBarUIComponent.cpp\">\r\n      <Filter>ChilliSource\\UI\\ProgressBar</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\UI\\Slider\\SliderDirection.cpp\">\r\n      <Filter>ChilliSource\\UI\\Slider</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\UI\\Slider\\SliderUIComponent.cpp\">\r\n      <Filter>ChilliSource\\UI\\Slider</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\UI\\Text\\TextIcon.cpp\">\r\n      <Filter>ChilliSource\\UI\\Text</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\UI\\Text\\TextUIComponent.cpp\">\r\n      <Filter>ChilliSource\\UI\\Text</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Input\\Base\\InputFilter.cpp\">\r\n      <Filter>ChilliSource\\Input\\Base</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Base\\LifecycleManager.cpp\">\r\n      <Filter>ChilliSource\\Core\\Base</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\AlignmentAnchors.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Base</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\AspectRatioUtils.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Base</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\CanvasMaterialPool.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Base</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\CanvasRenderer.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Base</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\HorizontalTextJustification.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Base</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\RenderCapabilities.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Base</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\Renderer.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Base</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\RenderFrame.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Base</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\RenderFrameCompiler.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Base</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\RenderObject.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Base</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\RenderSnapshot.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Base</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\SizePolicy.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Base</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\VerticalTextJustification.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Base</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Camera\\RenderCamera.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Camera</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Texture\\RenderTexture.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Texture</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Texture\\RenderTextureManager.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Texture</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Texture\\TextureDesc.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Texture</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\RenderCommand.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\RenderCommand</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\RenderCommandList.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\RenderCommand</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\LoadTextureRenderCommand.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\RenderCommand\\Commands</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\UnloadTextureRenderCommand.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\RenderCommand\\Commands</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Shader\\CSShaderProvider.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Shader</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Shader\\RenderShaderManager.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Shader</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\LoadShaderRenderCommand.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\RenderCommand\\Commands</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\UnloadShaderRenderCommand.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\RenderCommand\\Commands</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\LoadMeshRenderCommand.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\RenderCommand\\Commands</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\UnloadMeshRenderCommand.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\RenderCommand\\Commands</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Material\\RenderMaterial.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Material</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Material\\RenderMaterialGroup.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Material</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Material\\RenderMaterialGroupManager.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Material</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\LoadMaterialGroupRenderCommand.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\RenderCommand\\Commands</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\UnloadMaterialGroupRenderCommand.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\RenderCommand\\Commands</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\RenderPassObject.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Base</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\TargetRenderPassGroup.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Base</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\RenderPass.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Base</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\CameraRenderPassGroup.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Base</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Material\\ForwardRenderMaterialGroupManager.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Material</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Model\\CSAnimProvider.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Model</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Model\\CSModelProvider.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Model</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Model\\IndexFormat.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Model</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Model\\MeshDesc.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Model</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Model\\Model.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Model</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Model\\ModelDesc.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Model</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Model\\PrimitiveModelFactory.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Model</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Model\\RenderMesh.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Model</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Model\\RenderMeshManager.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Model</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Model\\Skeleton.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Model</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Model\\SkeletonDesc.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Model</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Model\\SkinnedAnimation.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Model</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Model\\SkinnedAnimationGroup.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Model</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Model\\StaticModelComponent.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Model</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Model\\VertexFormat.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Model</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\CSBackend\\Rendering\\OpenGL\\Model\\GLMesh.cpp\">\r\n      <Filter>CSBackend\\Rendering\\OpenGL\\Model</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\CSBackend\\Rendering\\OpenGL\\Shader\\GLShader.cpp\">\r\n      <Filter>CSBackend\\Rendering\\OpenGL\\Shader</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\CSBackend\\Rendering\\OpenGL\\Texture\\GLTexture.cpp\">\r\n      <Filter>CSBackend\\Rendering\\OpenGL\\Texture</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\CSBackend\\Rendering\\OpenGL\\Base\\RenderCommandProcessor.cpp\">\r\n      <Filter>CSBackend\\Rendering\\OpenGL\\Base</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\IRenderCommandProcessor.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Base</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Base\\ByteBuffer.cpp\">\r\n      <Filter>ChilliSource\\Core\\Base</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\File\\FileStream\\BinaryInputStream.cpp\">\r\n      <Filter>ChilliSource\\Core\\File\\FileStream</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\File\\FileStream\\BinaryOutputStream.cpp\">\r\n      <Filter>ChilliSource\\Core\\File\\FileStream</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\File\\FileStream\\FileWriteMode.cpp\">\r\n      <Filter>ChilliSource\\Core\\File\\FileStream</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\File\\FileStream\\TextInputStream.cpp\">\r\n      <Filter>ChilliSource\\Core\\File\\FileStream</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\File\\FileStream\\TextOutputStream.cpp\">\r\n      <Filter>ChilliSource\\Core\\File\\FileStream</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\ForwardRenderPassCompiler.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Base</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\RenderPassObjectSorter.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Base</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\RenderPassVisibilityChecker.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Base</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\RenderCommandCompiler.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Base</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\ApplyCameraRenderCommand.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\RenderCommand\\Commands</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\ApplyMaterialRenderCommand.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\RenderCommand\\Commands</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\ApplyMeshRenderCommand.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\RenderCommand\\Commands</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\BeginRenderCommand.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\RenderCommand\\Commands</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\EndRenderCommand.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\RenderCommand\\Commands</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\RenderInstanceRenderCommand.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\RenderCommand\\Commands</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\CSBackend\\Rendering\\OpenGL\\Material\\GLMaterial.cpp\">\r\n      <Filter>CSBackend\\Rendering\\OpenGL\\Material</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\CSBackend\\Rendering\\OpenGL\\Camera\\GLCamera.cpp\">\r\n      <Filter>CSBackend\\Rendering\\OpenGL\\Camera</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\RenderCommandBuffer.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\RenderCommand</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Sprite\\SpriteMeshBuilder.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Sprite</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\ApplyDynamicMeshRenderCommand.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\RenderCommand\\Commands</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Model\\RenderDynamicMesh.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Model</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\CSBackend\\Rendering\\OpenGL\\Model\\GLDynamicMesh.cpp\">\r\n      <Filter>CSBackend\\Rendering\\OpenGL\\Model</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\CSBackend\\Rendering\\OpenGL\\Model\\GLMeshUtils.cpp\">\r\n      <Filter>CSBackend\\Rendering\\OpenGL\\Model</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\CSBackend\\Rendering\\OpenGL\\Texture\\GLTextureUnitManager.cpp\">\r\n      <Filter>CSBackend\\Rendering\\OpenGL\\Texture</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\UI\\Text\\EditableTextUIComponent.cpp\">\r\n      <Filter>ChilliSource\\UI\\Text</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Input\\Keyboard\\KeyCode.cpp\">\r\n      <Filter>ChilliSource\\Input\\Keyboard</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Threading\\SingleThreadTaskPool.cpp\">\r\n      <Filter>ChilliSource\\Core\\Threading</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Input\\TextEntry\\TextEntryType.cpp\">\r\n      <Filter>ChilliSource\\Input\\TextEntry</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Input\\TextEntry\\TextEntryCapitalisation.cpp\">\r\n      <Filter>ChilliSource\\Input\\TextEntry</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\CSBackend\\Rendering\\OpenGL\\Base\\GLContextRestorer.cpp\">\r\n      <Filter>CSBackend\\Rendering\\OpenGL\\Base</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\RenderCommandBufferManager.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Base</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\RestoreTextureRenderCommand.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\RenderCommand\\Commands</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\RestoreMeshRenderCommand.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\RenderCommand\\Commands</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\CSBackend\\Rendering\\OpenGL\\Target\\GLTargetGroup.cpp\">\r\n      <Filter>CSBackend\\Rendering\\OpenGL\\Target</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Target\\RenderTargetGroup.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Target</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Target\\RenderTargetGroupManager.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Target</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\BeginWithTargetGroupRenderCommand.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\RenderCommand\\Commands</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\LoadTargetGroupRenderCommand.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\RenderCommand\\Commands</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\UnloadTargetGroupRenderCommand.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\RenderCommand\\Commands</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Lighting\\AmbientRenderLight.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Lighting</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Lighting\\DirectionalRenderLight.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Lighting</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Lighting\\PointRenderLight.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Lighting</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\ApplyAmbientLightRenderCommand.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\RenderCommand\\Commands</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\ApplyDirectionalLightRenderCommand.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\RenderCommand\\Commands</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\ApplyPointLightRenderCommand.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\RenderCommand\\Commands</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\CSBackend\\Rendering\\OpenGL\\Lighting\\GLAmbientLight.cpp\">\r\n      <Filter>CSBackend\\Rendering\\OpenGL\\Lighting</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\CSBackend\\Rendering\\OpenGL\\Lighting\\GLDirectionalLight.cpp\">\r\n      <Filter>CSBackend\\Rendering\\OpenGL\\Lighting</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\CSBackend\\Rendering\\OpenGL\\Lighting\\GLPointLight.cpp\">\r\n      <Filter>CSBackend\\Rendering\\OpenGL\\Lighting</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Memory\\LinearAllocator.cpp\">\r\n      <Filter>ChilliSource\\Core\\Memory</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Memory\\PagedLinearAllocator.cpp\">\r\n      <Filter>ChilliSource\\Core\\Memory</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\FrameAllocatorQueue.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Base</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\RestoreRenderTargetGroupCommand.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\RenderCommand\\Commands</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Target\\TargetGroup.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Target</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Model\\AnimatedModelComponent.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Model</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Model\\RenderSkinnedAnimation.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Model</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\ApplySkinnedAnimationRenderCommand.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\RenderCommand\\Commands</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\CSBackend\\Rendering\\OpenGL\\Model\\GLSkinnedAnimation.cpp\">\r\n      <Filter>CSBackend\\Rendering\\OpenGL\\Model</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\RenderFrameData.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Base</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Shader\\RenderShaderVariables.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Shader</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Base\\DeviceInfo.cpp\">\r\n      <Filter>ChilliSource\\Core\\Base</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Base\\SystemInfo.cpp\">\r\n      <Filter>ChilliSource\\Core\\Base</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\CSBackend\\Platform\\Windows\\Core\\Base\\SystemInfoFactory.cpp\">\r\n      <Filter>CSBackend\\Platform\\Windows\\Core\\Base</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Model\\RenderMeshBatch.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Model</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Model\\SmallMeshBatcher.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Model</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\ApplyMeshBatchRenderCommand.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\RenderCommand\\Commands</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Base\\ScreenInfo.cpp\">\r\n      <Filter>ChilliSource\\Core\\Base</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\CSBackend\\Rendering\\OpenGL\\Base\\RenderInfoFactory.cpp\">\r\n      <Filter>CSBackend\\Rendering\\OpenGL\\Base</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Base\\RenderInfo.cpp\">\r\n      <Filter>ChilliSource\\Core\\Base</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\CanvasDrawMode.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Base</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\CSBackend\\Rendering\\OpenGL\\Texture\\GLCubemap.cpp\">\r\n      <Filter>CSBackend\\Rendering\\OpenGL\\Texture</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\CSBackend\\Rendering\\OpenGL\\Texture\\GLTextureUtils.cpp\">\r\n      <Filter>CSBackend\\Rendering\\OpenGL\\Texture</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Texture\\Cubemap.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Texture</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Texture\\CubemapProvider.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Texture</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Texture\\CubemapResourceOptions.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Texture</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\LoadCubemapRenderCommand.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\RenderCommand\\Commands</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\RestoreCubemapRenderCommand.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\RenderCommand\\Commands</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\UnloadCubemapRenderCommand.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\RenderCommand\\Commands</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Skybox\\SkyboxComponent.cpp\">\r\n      <Filter>ChilliSource\\Rendering\\Skybox</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Input\\Gyroscope\\Gyroscope.cpp\">\r\n      <Filter>ChilliSource\\Input\\Gyroscope</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Core\\Cryptographic\\HashSHA256.cpp\">\r\n      <Filter>ChilliSource\\Core\\Cryptographic</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\CSBackend\\Rendering\\OpenGL\\Base\\GLExtensions.cpp\">\r\n      <Filter>CSBackend\\Rendering\\OpenGL\\Base</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\UI\\Base\\CursorSystem.cpp\">\r\n      <Filter>ChilliSource\\UI\\Base</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Input\\Gamepad\\Gamepad.cpp\">\r\n      <Filter>ChilliSource\\Input\\Gamepad</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\ChilliSource\\Input\\Gamepad\\GamepadSystem.cpp\">\r\n      <Filter>ChilliSource\\Input\\Gamepad</Filter>\r\n    </ClCompile>\r\n    <ClCompile Include=\"..\\..\\Source\\CSBackend\\Platform\\Windows\\Input\\Gamepad\\GamepadSystem.cpp\">\r\n      <Filter>CSBackend\\Platform\\Windows\\Input\\Gamepad</Filter>\r\n    </ClCompile>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Audio\\CricketAudio\\CkAudioPlayer.h\">\r\n      <Filter>ChilliSource\\Audio\\CricketAudio</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Audio\\CricketAudio\\CkBank.h\">\r\n      <Filter>ChilliSource\\Audio\\CricketAudio</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Audio\\CricketAudio\\CkBankProvider.h\">\r\n      <Filter>ChilliSource\\Audio\\CricketAudio</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Audio\\CricketAudio\\CkForwardDeclarations.h\">\r\n      <Filter>ChilliSource\\Audio\\CricketAudio</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Audio\\CricketAudio\\CkSound.h\">\r\n      <Filter>ChilliSource\\Audio\\CricketAudio</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Audio\\CricketAudio\\CricketAudioSystem.h\">\r\n      <Filter>ChilliSource\\Audio\\CricketAudio</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Audio\\CricketAudio.h\">\r\n      <Filter>ChilliSource\\Audio</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Audio\\ForwardDeclarations.h\">\r\n      <Filter>ChilliSource\\Audio</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Base.h\">\r\n      <Filter>ChilliSource\\Core</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Container.h\">\r\n      <Filter>ChilliSource\\Core</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Cryptographic.h\">\r\n      <Filter>ChilliSource\\Core</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Delegate.h\">\r\n      <Filter>ChilliSource\\Core</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\DialogueBox.h\">\r\n      <Filter>ChilliSource\\Core</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Entity.h\">\r\n      <Filter>ChilliSource\\Core</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Event.h\">\r\n      <Filter>ChilliSource\\Core</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\File.h\">\r\n      <Filter>ChilliSource\\Core</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\ForwardDeclarations.h\">\r\n      <Filter>ChilliSource\\Core</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Image.h\">\r\n      <Filter>ChilliSource\\Core</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Json.h\">\r\n      <Filter>ChilliSource\\Core</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Localisation.h\">\r\n      <Filter>ChilliSource\\Core</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Math.h\">\r\n      <Filter>ChilliSource\\Core</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Notification.h\">\r\n      <Filter>ChilliSource\\Core</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Resource.h\">\r\n      <Filter>ChilliSource\\Core</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Scene.h\">\r\n      <Filter>ChilliSource\\Core</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\State.h\">\r\n      <Filter>ChilliSource\\Core</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\String.h\">\r\n      <Filter>ChilliSource\\Core</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\System.h\">\r\n      <Filter>ChilliSource\\Core</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Threading.h\">\r\n      <Filter>ChilliSource\\Core</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Time.h\">\r\n      <Filter>ChilliSource\\Core</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Tween.h\">\r\n      <Filter>ChilliSource\\Core</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Volume.h\">\r\n      <Filter>ChilliSource\\Core</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\XML.h\">\r\n      <Filter>ChilliSource\\Core</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Base\\AppConfig.h\">\r\n      <Filter>ChilliSource\\Core\\Base</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Base\\Application.h\">\r\n      <Filter>ChilliSource\\Core\\Base</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Base\\ByteColour.h\">\r\n      <Filter>ChilliSource\\Core\\Base</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Base\\Colour.h\">\r\n      <Filter>ChilliSource\\Core\\Base</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Base\\ColourUtils.h\">\r\n      <Filter>ChilliSource\\Core\\Base</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Base\\ConstMethodCast.h\">\r\n      <Filter>ChilliSource\\Core\\Base</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Base\\Device.h\">\r\n      <Filter>ChilliSource\\Core\\Base</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Base\\GenericFactory.h\">\r\n      <Filter>ChilliSource\\Core\\Base</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Base\\Logging.h\">\r\n      <Filter>ChilliSource\\Core\\Base</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Base\\MakeSharedArray.h\">\r\n      <Filter>ChilliSource\\Core\\Base</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Base\\PlatformSystem.h\">\r\n      <Filter>ChilliSource\\Core\\Base</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Base\\QueryableInterface.h\">\r\n      <Filter>ChilliSource\\Core\\Base</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Base\\Screen.h\">\r\n      <Filter>ChilliSource\\Core\\Base</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Base\\Singleton.h\">\r\n      <Filter>ChilliSource\\Core\\Base</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Base\\StandardMacros.h\">\r\n      <Filter>ChilliSource\\Core\\Base</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Base\\Utils.h\">\r\n      <Filter>ChilliSource\\Core\\Base</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Container\\concurrent_blocking_queue.h\">\r\n      <Filter>ChilliSource\\Core\\Container</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Container\\concurrent_vector.h\">\r\n      <Filter>ChilliSource\\Core\\Container</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Container\\concurrent_vector_const_forward_iterator.h\">\r\n      <Filter>ChilliSource\\Core\\Container</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Container\\concurrent_vector_const_reverse_iterator.h\">\r\n      <Filter>ChilliSource\\Core\\Container</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Container\\concurrent_vector_forward_iterator.h\">\r\n      <Filter>ChilliSource\\Core\\Container</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Container\\concurrent_vector_reverse_iterator.h\">\r\n      <Filter>ChilliSource\\Core\\Container</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Container\\dynamic_array.h\">\r\n      <Filter>ChilliSource\\Core\\Container</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Container\\HashedArray.h\">\r\n      <Filter>ChilliSource\\Core\\Container</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Container\\ParamDictionary.h\">\r\n      <Filter>ChilliSource\\Core\\Container</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Container\\ParamDictionarySerialiser.h\">\r\n      <Filter>ChilliSource\\Core\\Container</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Container\\random_access_iterator.h\">\r\n      <Filter>ChilliSource\\Core\\Container</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Container\\VectorUtils.h\">\r\n      <Filter>ChilliSource\\Core\\Container</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Container\\Property\\IProperty.h\">\r\n      <Filter>ChilliSource\\Core\\Container\\Property</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Container\\Property\\IPropertyType.h\">\r\n      <Filter>ChilliSource\\Core\\Container\\Property</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Container\\Property\\Property.h\">\r\n      <Filter>ChilliSource\\Core\\Container\\Property</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Container\\Property\\PropertyMap.h\">\r\n      <Filter>ChilliSource\\Core\\Container\\Property</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Container\\Property\\PropertyType.h\">\r\n      <Filter>ChilliSource\\Core\\Container\\Property</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Container\\Property\\PropertyTypes.h\">\r\n      <Filter>ChilliSource\\Core\\Container\\Property</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Container\\Property\\ReferenceProperty.h\">\r\n      <Filter>ChilliSource\\Core\\Container\\Property</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Container\\Property\\ValueProperty.h\">\r\n      <Filter>ChilliSource\\Core\\Container\\Property</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Cryptographic\\AESEncrypt.h\">\r\n      <Filter>ChilliSource\\Core\\Cryptographic</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Cryptographic\\BaseEncoding.h\">\r\n      <Filter>ChilliSource\\Core\\Cryptographic</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Cryptographic\\HashCRC32.h\">\r\n      <Filter>ChilliSource\\Core\\Cryptographic</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Cryptographic\\HashMD5.h\">\r\n      <Filter>ChilliSource\\Core\\Cryptographic</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Cryptographic\\HashSHA1.h\">\r\n      <Filter>ChilliSource\\Core\\Cryptographic</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Cryptographic\\OAuth.h\">\r\n      <Filter>ChilliSource\\Core\\Cryptographic</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Delegate\\ConnectableDelegate.h\">\r\n      <Filter>ChilliSource\\Core\\Delegate</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Delegate\\DelegateConnection.h\">\r\n      <Filter>ChilliSource\\Core\\Delegate</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Delegate\\MakeConnectableDelegate.h\">\r\n      <Filter>ChilliSource\\Core\\Delegate</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Delegate\\MakeDelegate.h\">\r\n      <Filter>ChilliSource\\Core\\Delegate</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\DialogueBox\\DialogueBoxSystem.h\">\r\n      <Filter>ChilliSource\\Core\\DialogueBox</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Entity\\Component.h\">\r\n      <Filter>ChilliSource\\Core\\Entity</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Entity\\Entity.h\">\r\n      <Filter>ChilliSource\\Core\\Entity</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Entity\\PrimitiveEntityFactory.h\">\r\n      <Filter>ChilliSource\\Core\\Entity</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Entity\\Transform.h\">\r\n      <Filter>ChilliSource\\Core\\Entity</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Event\\Event.h\">\r\n      <Filter>ChilliSource\\Core\\Event</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Event\\EventConnection.h\">\r\n      <Filter>ChilliSource\\Core\\Event</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Event\\IConnectableEvent.h\">\r\n      <Filter>ChilliSource\\Core\\Event</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Event\\IDisconnectableEvent.h\">\r\n      <Filter>ChilliSource\\Core\\Event</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\File\\AppDataStore.h\">\r\n      <Filter>ChilliSource\\Core\\File</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\File\\CSBinaryChunk.h\">\r\n      <Filter>ChilliSource\\Core\\File</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\File\\CSBinaryInputStream.h\">\r\n      <Filter>ChilliSource\\Core\\File</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\File\\FileSystem.h\">\r\n      <Filter>ChilliSource\\Core\\File</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\File\\StorageLocation.h\">\r\n      <Filter>ChilliSource\\Core\\File</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\File\\TaggedFilePathResolver.h\">\r\n      <Filter>ChilliSource\\Core\\File</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Image\\CSImageProvider.h\">\r\n      <Filter>ChilliSource\\Core\\Image</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Image\\ETC1ImageProvider.h\">\r\n      <Filter>ChilliSource\\Core\\Image</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Image\\Image.h\">\r\n      <Filter>ChilliSource\\Core\\Image</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Image\\ImageCompression.h\">\r\n      <Filter>ChilliSource\\Core\\Image</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Image\\ImageFormat.h\">\r\n      <Filter>ChilliSource\\Core\\Image</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Image\\ImageFormatConverter.h\">\r\n      <Filter>ChilliSource\\Core\\Image</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Image\\PNGImageProvider.h\">\r\n      <Filter>ChilliSource\\Core\\Image</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Image\\PVRImageProvider.h\">\r\n      <Filter>ChilliSource\\Core\\Image</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Json\\JsonUtils.h\">\r\n      <Filter>ChilliSource\\Core\\Json</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Localisation\\LocalisedText.h\">\r\n      <Filter>ChilliSource\\Core\\Localisation</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Localisation\\LocalisedTextProvider.h\">\r\n      <Filter>ChilliSource\\Core\\Localisation</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Math\\Interpolate.h\">\r\n      <Filter>ChilliSource\\Core\\Math</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Math\\MathUtils.h\">\r\n      <Filter>ChilliSource\\Core\\Math</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Math\\Matrix3.h\">\r\n      <Filter>ChilliSource\\Core\\Math</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Math\\Matrix4.h\">\r\n      <Filter>ChilliSource\\Core\\Math</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Math\\NumericLimits.h\">\r\n      <Filter>ChilliSource\\Core\\Math</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Math\\Quaternion.h\">\r\n      <Filter>ChilliSource\\Core\\Math</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Math\\Random.h\">\r\n      <Filter>ChilliSource\\Core\\Math</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Math\\RandomImpl.h\">\r\n      <Filter>ChilliSource\\Core\\Math</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Math\\UnifiedCoordinates.h\">\r\n      <Filter>ChilliSource\\Core\\Math</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Math\\Vector2.h\">\r\n      <Filter>ChilliSource\\Core\\Math</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Math\\Vector3.h\">\r\n      <Filter>ChilliSource\\Core\\Math</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Math\\Vector4.h\">\r\n      <Filter>ChilliSource\\Core\\Math</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Math\\Geometry\\Curves.h\">\r\n      <Filter>ChilliSource\\Core\\Math\\Geometry</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Math\\Geometry\\ShapeIntersection.h\">\r\n      <Filter>ChilliSource\\Core\\Math\\Geometry</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Math\\Geometry\\Shapes.h\">\r\n      <Filter>ChilliSource\\Core\\Math\\Geometry</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\XML\\XML.h\">\r\n      <Filter>ChilliSource\\Core\\XML</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\XML\\XMLUtils.h\">\r\n      <Filter>ChilliSource\\Core\\XML</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Volume\\VolumeComponent.h\">\r\n      <Filter>ChilliSource\\Core\\Volume</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Tween\\EaseBack.h\">\r\n      <Filter>ChilliSource\\Core\\Tween</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Tween\\EaseQuad.h\">\r\n      <Filter>ChilliSource\\Core\\Tween</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Tween\\Linear.h\">\r\n      <Filter>ChilliSource\\Core\\Tween</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Tween\\SmoothStep.h\">\r\n      <Filter>ChilliSource\\Core\\Tween</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Tween\\Tween.h\">\r\n      <Filter>ChilliSource\\Core\\Tween</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Time\\CoreTimer.h\">\r\n      <Filter>ChilliSource\\Core\\Time</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Time\\PerformanceTimer.h\">\r\n      <Filter>ChilliSource\\Core\\Time</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Time\\Timer.h\">\r\n      <Filter>ChilliSource\\Core\\Time</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\System\\AppSystem.h\">\r\n      <Filter>ChilliSource\\Core\\System</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\System\\StateSystem.h\">\r\n      <Filter>ChilliSource\\Core\\System</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\String\\MarkupDef.h\">\r\n      <Filter>ChilliSource\\Core\\String</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\String\\StringMarkupParser.h\">\r\n      <Filter>ChilliSource\\Core\\String</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\String\\StringParser.h\">\r\n      <Filter>ChilliSource\\Core\\String</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\String\\StringUtils.h\">\r\n      <Filter>ChilliSource\\Core\\String</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\String\\ToString.h\">\r\n      <Filter>ChilliSource\\Core\\String</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\String\\UTF8StringUtils.h\">\r\n      <Filter>ChilliSource\\Core\\String</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\State\\State.h\">\r\n      <Filter>ChilliSource\\Core\\State</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\State\\StateManager.h\">\r\n      <Filter>ChilliSource\\Core\\State</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Scene\\Scene.h\">\r\n      <Filter>ChilliSource\\Core\\Scene</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Resource\\IResourceOptions.h\">\r\n      <Filter>ChilliSource\\Core\\Resource</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Resource\\Resource.h\">\r\n      <Filter>ChilliSource\\Core\\Resource</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Resource\\ResourcePool.h\">\r\n      <Filter>ChilliSource\\Core\\Resource</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Resource\\ResourceProvider.h\">\r\n      <Filter>ChilliSource\\Core\\Resource</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Notification\\AppNotificationSystem.h\">\r\n      <Filter>ChilliSource\\Core\\Notification</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Notification\\LocalNotificationSystem.h\">\r\n      <Filter>ChilliSource\\Core\\Notification</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Notification\\Notification.h\">\r\n      <Filter>ChilliSource\\Core\\Notification</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Notification\\NotificationManager.h\">\r\n      <Filter>ChilliSource\\Core\\Notification</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Notification\\RemoteNotificationSystem.h\">\r\n      <Filter>ChilliSource\\Core\\Notification</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\ChilliSource.h\">\r\n      <Filter>ChilliSource</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Input\\Accelerometer.h\">\r\n      <Filter>ChilliSource\\Input</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Input\\Base.h\">\r\n      <Filter>ChilliSource\\Input</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Input\\DeviceButtons.h\">\r\n      <Filter>ChilliSource\\Input</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Input\\ForwardDeclarations.h\">\r\n      <Filter>ChilliSource\\Input</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Input\\Gesture.h\">\r\n      <Filter>ChilliSource\\Input</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Input\\Keyboard.h\">\r\n      <Filter>ChilliSource\\Input</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Input\\Pointer.h\">\r\n      <Filter>ChilliSource\\Input</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Input\\TextEntry.h\">\r\n      <Filter>ChilliSource\\Input</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Input\\Accelerometer\\Accelerometer.h\">\r\n      <Filter>ChilliSource\\Input\\Accelerometer</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Input\\DeviceButtons\\DeviceButtonSystem.h\">\r\n      <Filter>ChilliSource\\Input\\DeviceButtons</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Input\\Gesture\\DragGesture.h\">\r\n      <Filter>ChilliSource\\Input\\Gesture</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Input\\Gesture\\Gesture.h\">\r\n      <Filter>ChilliSource\\Input\\Gesture</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Input\\Gesture\\GestureSystem.h\">\r\n      <Filter>ChilliSource\\Input\\Gesture</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Input\\Gesture\\HoldGesture.h\">\r\n      <Filter>ChilliSource\\Input\\Gesture</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Input\\Gesture\\PinchGesture.h\">\r\n      <Filter>ChilliSource\\Input\\Gesture</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Input\\Gesture\\RotationGesture.h\">\r\n      <Filter>ChilliSource\\Input\\Gesture</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Input\\Gesture\\TapGesture.h\">\r\n      <Filter>ChilliSource\\Input\\Gesture</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Input\\Keyboard\\Keyboard.h\">\r\n      <Filter>ChilliSource\\Input\\Keyboard</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Input\\Keyboard\\KeyCode.h\">\r\n      <Filter>ChilliSource\\Input\\Keyboard</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Input\\Keyboard\\ModifierKeyCode.h\">\r\n      <Filter>ChilliSource\\Input\\Keyboard</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Input\\TextEntry\\TextEntry.h\">\r\n      <Filter>ChilliSource\\Input\\TextEntry</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Input\\Pointer\\Pointer.h\">\r\n      <Filter>ChilliSource\\Input\\Pointer</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Input\\Pointer\\PointerSystem.h\">\r\n      <Filter>ChilliSource\\Input\\Pointer</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Networking\\ContentDownload.h\">\r\n      <Filter>ChilliSource\\Networking</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Networking\\ForwardDeclarations.h\">\r\n      <Filter>ChilliSource\\Networking</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Networking\\Http.h\">\r\n      <Filter>ChilliSource\\Networking</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Networking\\IAP.h\">\r\n      <Filter>ChilliSource\\Networking</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Networking\\ContentDownload\\ContentManagementSystem.h\">\r\n      <Filter>ChilliSource\\Networking\\ContentDownload</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Networking\\ContentDownload\\IContentDownloader.h\">\r\n      <Filter>ChilliSource\\Networking\\ContentDownload</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Networking\\ContentDownload\\MoContentDownloader.h\">\r\n      <Filter>ChilliSource\\Networking\\ContentDownload</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Networking\\Http\\HttpRequest.h\">\r\n      <Filter>ChilliSource\\Networking\\Http</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Networking\\Http\\HttpRequestSystem.h\">\r\n      <Filter>ChilliSource\\Networking\\Http</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Networking\\Http\\HttpResponse.h\">\r\n      <Filter>ChilliSource\\Networking\\Http</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Networking\\IAP\\IAPSystem.h\">\r\n      <Filter>ChilliSource\\Networking\\IAP</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Web\\Base.h\">\r\n      <Filter>ChilliSource\\Web</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Web\\ForwardDeclarations.h\">\r\n      <Filter>ChilliSource\\Web</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Web\\Base\\WebView.h\">\r\n      <Filter>ChilliSource\\Web\\Base</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Video\\Base.h\">\r\n      <Filter>ChilliSource\\Video</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Video\\ForwardDeclarations.h\">\r\n      <Filter>ChilliSource\\Video</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Video\\Base\\CSSubtitlesProvider.h\">\r\n      <Filter>ChilliSource\\Video\\Base</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Video\\Base\\Subtitles.h\">\r\n      <Filter>ChilliSource\\Video\\Base</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Video\\Base\\VideoPlayer.h\">\r\n      <Filter>ChilliSource\\Video\\Base</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\Base.h\">\r\n      <Filter>ChilliSource\\UI</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\Button.h\">\r\n      <Filter>ChilliSource\\UI</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\Drawable.h\">\r\n      <Filter>ChilliSource\\UI</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\ForwardDeclarations.h\">\r\n      <Filter>ChilliSource\\UI</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\Layout.h\">\r\n      <Filter>ChilliSource\\UI</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\ProgressBar.h\">\r\n      <Filter>ChilliSource\\UI</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\Slider.h\">\r\n      <Filter>ChilliSource\\UI</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\Text.h\">\r\n      <Filter>ChilliSource\\UI</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Social\\Communications.h\">\r\n      <Filter>ChilliSource\\Social</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Social\\ForwardDeclarations.h\">\r\n      <Filter>ChilliSource\\Social</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Social\\Communications\\EmailComposer.h\">\r\n      <Filter>ChilliSource\\Social\\Communications</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base.h\">\r\n      <Filter>ChilliSource\\Rendering</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Camera.h\">\r\n      <Filter>ChilliSource\\Rendering</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Font.h\">\r\n      <Filter>ChilliSource\\Rendering</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\ForwardDeclarations.h\">\r\n      <Filter>ChilliSource\\Rendering</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Lighting.h\">\r\n      <Filter>ChilliSource\\Rendering</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Material.h\">\r\n      <Filter>ChilliSource\\Rendering</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Model.h\">\r\n      <Filter>ChilliSource\\Rendering</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle.h\">\r\n      <Filter>ChilliSource\\Rendering</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Shader.h\">\r\n      <Filter>ChilliSource\\Rendering</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Sprite.h\">\r\n      <Filter>ChilliSource\\Rendering</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Texture.h\">\r\n      <Filter>ChilliSource\\Rendering</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Camera\\CameraComponent.h\">\r\n      <Filter>ChilliSource\\Rendering\\Camera</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Camera\\OrthographicCameraComponent.h\">\r\n      <Filter>ChilliSource\\Rendering\\Camera</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Camera\\PerspectiveCameraComponent.h\">\r\n      <Filter>ChilliSource\\Rendering\\Camera</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Font\\Font.h\">\r\n      <Filter>ChilliSource\\Rendering\\Font</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Font\\FontProvider.h\">\r\n      <Filter>ChilliSource\\Rendering\\Font</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Lighting\\AmbientLightComponent.h\">\r\n      <Filter>ChilliSource\\Rendering\\Lighting</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Lighting\\DirectionalLightComponent.h\">\r\n      <Filter>ChilliSource\\Rendering\\Lighting</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Lighting\\PointLightComponent.h\">\r\n      <Filter>ChilliSource\\Rendering\\Lighting</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Material\\Material.h\">\r\n      <Filter>ChilliSource\\Rendering\\Material</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Material\\MaterialFactory.h\">\r\n      <Filter>ChilliSource\\Rendering\\Material</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Material\\MaterialProvider.h\">\r\n      <Filter>ChilliSource\\Rendering\\Material</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Texture\\Texture.h\">\r\n      <Filter>ChilliSource\\Rendering\\Texture</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Texture\\TextureAtlas.h\">\r\n      <Filter>ChilliSource\\Rendering\\Texture</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Texture\\TextureAtlasProvider.h\">\r\n      <Filter>ChilliSource\\Rendering\\Texture</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Texture\\TextureProvider.h\">\r\n      <Filter>ChilliSource\\Rendering\\Texture</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Texture\\TextureResourceOptions.h\">\r\n      <Filter>ChilliSource\\Rendering\\Texture</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Texture\\UVs.h\">\r\n      <Filter>ChilliSource\\Rendering\\Texture</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Sprite\\SpriteComponent.h\">\r\n      <Filter>ChilliSource\\Rendering\\Sprite</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Shader\\Shader.h\">\r\n      <Filter>ChilliSource\\Rendering\\Shader</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\ConcurrentParticleData.h\">\r\n      <Filter>ChilliSource\\Rendering\\Particle</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\CSParticleProvider.h\">\r\n      <Filter>ChilliSource\\Rendering\\Particle</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Particle.h\">\r\n      <Filter>ChilliSource\\Rendering\\Particle</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\ParticleEffect.h\">\r\n      <Filter>ChilliSource\\Rendering\\Particle</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\ParticleEffectComponent.h\">\r\n      <Filter>ChilliSource\\Rendering\\Particle</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Affector\\AccelerationParticleAffector.h\">\r\n      <Filter>ChilliSource\\Rendering\\Particle\\Affector</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Affector\\AccelerationParticleAffectorDef.h\">\r\n      <Filter>ChilliSource\\Rendering\\Particle\\Affector</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Affector\\AngularAccelerationParticleAffector.h\">\r\n      <Filter>ChilliSource\\Rendering\\Particle\\Affector</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Affector\\AngularAccelerationParticleAffectorDef.h\">\r\n      <Filter>ChilliSource\\Rendering\\Particle\\Affector</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Affector\\ColourOverLifetimeParticleAffector.h\">\r\n      <Filter>ChilliSource\\Rendering\\Particle\\Affector</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Affector\\ColourOverLifetimeParticleAffectorDef.h\">\r\n      <Filter>ChilliSource\\Rendering\\Particle\\Affector</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Affector\\ParticleAffector.h\">\r\n      <Filter>ChilliSource\\Rendering\\Particle\\Affector</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Affector\\ParticleAffectorDef.h\">\r\n      <Filter>ChilliSource\\Rendering\\Particle\\Affector</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Affector\\ParticleAffectorDefFactory.h\">\r\n      <Filter>ChilliSource\\Rendering\\Particle\\Affector</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Affector\\ScaleOverLifetimeParticleAffector.h\">\r\n      <Filter>ChilliSource\\Rendering\\Particle\\Affector</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Affector\\ScaleOverLifetimeParticleAffectorDef.h\">\r\n      <Filter>ChilliSource\\Rendering\\Particle\\Affector</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Drawable\\ParticleDrawable.h\">\r\n      <Filter>ChilliSource\\Rendering\\Particle\\Drawable</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Drawable\\ParticleDrawableDef.h\">\r\n      <Filter>ChilliSource\\Rendering\\Particle\\Drawable</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Drawable\\ParticleDrawableDefFactory.h\">\r\n      <Filter>ChilliSource\\Rendering\\Particle\\Drawable</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Drawable\\StaticBillboardParticleDrawable.h\">\r\n      <Filter>ChilliSource\\Rendering\\Particle\\Drawable</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Drawable\\StaticBillboardParticleDrawableDef.h\">\r\n      <Filter>ChilliSource\\Rendering\\Particle\\Drawable</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Emitter\\CircleParticleEmitter.h\">\r\n      <Filter>ChilliSource\\Rendering\\Particle\\Emitter</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Emitter\\CircleParticleEmitterDef.h\">\r\n      <Filter>ChilliSource\\Rendering\\Particle\\Emitter</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Emitter\\Cone2DParticleEmitter.h\">\r\n      <Filter>ChilliSource\\Rendering\\Particle\\Emitter</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Emitter\\Cone2DParticleEmitterDef.h\">\r\n      <Filter>ChilliSource\\Rendering\\Particle\\Emitter</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Emitter\\ConeParticleEmitter.h\">\r\n      <Filter>ChilliSource\\Rendering\\Particle\\Emitter</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Emitter\\ConeParticleEmitterDef.h\">\r\n      <Filter>ChilliSource\\Rendering\\Particle\\Emitter</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Emitter\\ParticleEmitter.h\">\r\n      <Filter>ChilliSource\\Rendering\\Particle\\Emitter</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Emitter\\ParticleEmitterDef.h\">\r\n      <Filter>ChilliSource\\Rendering\\Particle\\Emitter</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Emitter\\ParticleEmitterDefFactory.h\">\r\n      <Filter>ChilliSource\\Rendering\\Particle\\Emitter</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Emitter\\PointParticleEmitter.h\">\r\n      <Filter>ChilliSource\\Rendering\\Particle\\Emitter</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Emitter\\PointParticleEmitterDef.h\">\r\n      <Filter>ChilliSource\\Rendering\\Particle\\Emitter</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Emitter\\SphereParticleEmitter.h\">\r\n      <Filter>ChilliSource\\Rendering\\Particle\\Emitter</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Emitter\\SphereParticleEmitterDef.h\">\r\n      <Filter>ChilliSource\\Rendering\\Particle\\Emitter</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Property\\ComponentwiseRandomConstantParticleProperty.h\">\r\n      <Filter>ChilliSource\\Rendering\\Particle\\Property</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Property\\ComponentwiseRandomCurveParticleProperty.h\">\r\n      <Filter>ChilliSource\\Rendering\\Particle\\Property</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Property\\ConstantParticleProperty.h\">\r\n      <Filter>ChilliSource\\Rendering\\Particle\\Property</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Property\\CurveParticleProperty.h\">\r\n      <Filter>ChilliSource\\Rendering\\Particle\\Property</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Property\\ParticleProperty.h\">\r\n      <Filter>ChilliSource\\Rendering\\Particle\\Property</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Property\\ParticlePropertyFactory.h\">\r\n      <Filter>ChilliSource\\Rendering\\Particle\\Property</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Property\\ParticlePropertyFactoryImpl.h\">\r\n      <Filter>ChilliSource\\Rendering\\Particle\\Property</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Property\\RandomConstantParticleProperty.h\">\r\n      <Filter>ChilliSource\\Rendering\\Particle\\Property</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Particle\\Property\\RandomCurveParticleProperty.h\">\r\n      <Filter>ChilliSource\\Rendering\\Particle\\Property</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\CSBackend\\Platform\\Windows\\ForwardDeclarations.h\">\r\n      <Filter>CSBackend\\Platform\\Windows</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\CSBackend\\Platform\\Windows\\Core\\Base\\PlatformSystem.h\">\r\n      <Filter>CSBackend\\Platform\\Windows\\Core\\Base</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\CSBackend\\Platform\\Windows\\Core\\Base\\Screen.h\">\r\n      <Filter>CSBackend\\Platform\\Windows\\Core\\Base</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\CSBackend\\Platform\\Windows\\Core\\DialogueBox\\DialogueBoxSystem.h\">\r\n      <Filter>CSBackend\\Platform\\Windows\\Core\\DialogueBox</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\CSBackend\\Platform\\Windows\\Core\\File\\FileSystem.h\">\r\n      <Filter>CSBackend\\Platform\\Windows\\Core\\File</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\CSBackend\\Platform\\Windows\\Core\\File\\WindowsFileUtils.h\">\r\n      <Filter>CSBackend\\Platform\\Windows\\Core\\File</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\CSBackend\\Platform\\Windows\\Core\\Image\\PngImage.h\">\r\n      <Filter>CSBackend\\Platform\\Windows\\Core\\Image</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\CSBackend\\Platform\\Windows\\Core\\Image\\PNGImageProvider.h\">\r\n      <Filter>CSBackend\\Platform\\Windows\\Core\\Image</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\CSBackend\\Platform\\Windows\\Core\\String\\WindowsStringUtils.h\">\r\n      <Filter>CSBackend\\Platform\\Windows\\Core\\String</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\CSBackend\\Platform\\Windows\\Input\\DeviceButtons\\DeviceButtonSystem.h\">\r\n      <Filter>CSBackend\\Platform\\Windows\\Input\\DeviceButtons</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\CSBackend\\Platform\\Windows\\Input\\Keyboard\\Keyboard.h\">\r\n      <Filter>CSBackend\\Platform\\Windows\\Input\\Keyboard</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\CSBackend\\Platform\\Windows\\Input\\TextEntry\\TextEntry.h\">\r\n      <Filter>CSBackend\\Platform\\Windows\\Input\\TextEntry</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\CSBackend\\Platform\\Windows\\Input\\Pointer\\PointerSystem.h\">\r\n      <Filter>CSBackend\\Platform\\Windows\\Input\\Pointer</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\CSBackend\\Platform\\Windows\\Networking\\Http\\HttpRequest.h\">\r\n      <Filter>CSBackend\\Platform\\Windows\\Networking\\Http</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\CSBackend\\Platform\\Windows\\Networking\\Http\\HttpRequestSystem.h\">\r\n      <Filter>CSBackend\\Platform\\Windows\\Networking\\Http</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\CSBackend\\Platform\\Windows\\SFML\\Base\\SFMLWindow.h\">\r\n      <Filter>CSBackend\\Platform\\Windows\\SFML\\Base</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\CSBackend\\Rendering\\OpenGL\\ForwardDeclarations.h\">\r\n      <Filter>CSBackend\\Rendering\\OpenGL</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\CSBackend\\Rendering\\OpenGL\\Base\\GLError.h\">\r\n      <Filter>CSBackend\\Rendering\\OpenGL\\Base</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\CSBackend\\Rendering\\OpenGL\\Base\\GLIncludes.h\">\r\n      <Filter>CSBackend\\Rendering\\OpenGL\\Base</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Threading\\TaskContext.h\">\r\n      <Filter>ChilliSource\\Core\\Threading</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Threading\\TaskPool.h\">\r\n      <Filter>ChilliSource\\Core\\Threading</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Threading\\TaskType.h\">\r\n      <Filter>ChilliSource\\Core\\Threading</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Threading\\TaskScheduler.h\">\r\n      <Filter>ChilliSource\\Core\\Threading</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Threading\\Task.h\">\r\n      <Filter>ChilliSource\\Core\\Threading</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\Base\\Canvas.h\">\r\n      <Filter>ChilliSource\\UI\\Base</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\Base\\PropertyLink.h\">\r\n      <Filter>ChilliSource\\UI\\Base</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\Base\\PropertyTypes.h\">\r\n      <Filter>ChilliSource\\UI\\Base</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\Base\\UIComponent.h\">\r\n      <Filter>ChilliSource\\UI\\Base</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\Base\\UIComponentDesc.h\">\r\n      <Filter>ChilliSource\\UI\\Base</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\Base\\UIComponentFactory.h\">\r\n      <Filter>ChilliSource\\UI\\Base</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\Base\\Widget.h\">\r\n      <Filter>ChilliSource\\UI\\Base</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\Base\\WidgetDef.h\">\r\n      <Filter>ChilliSource\\UI\\Base</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\Base\\WidgetDefProvider.h\">\r\n      <Filter>ChilliSource\\UI\\Base</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\Base\\WidgetDesc.h\">\r\n      <Filter>ChilliSource\\UI\\Base</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\Base\\WidgetFactory.h\">\r\n      <Filter>ChilliSource\\UI\\Base</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\Base\\WidgetParserUtils.h\">\r\n      <Filter>ChilliSource\\UI\\Base</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\Base\\WidgetTemplate.h\">\r\n      <Filter>ChilliSource\\UI\\Base</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\Base\\WidgetTemplateProvider.h\">\r\n      <Filter>ChilliSource\\UI\\Base</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\Button\\HighlightUIComponent.h\">\r\n      <Filter>ChilliSource\\UI\\Button</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\Button\\ToggleHighlightUIComponent.h\">\r\n      <Filter>ChilliSource\\UI\\Button</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\Drawable\\DrawableUIComponent.h\">\r\n      <Filter>ChilliSource\\UI\\Drawable</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\Drawable\\NinePatchUIDrawable.h\">\r\n      <Filter>ChilliSource\\UI\\Drawable</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\Drawable\\NinePatchUIDrawableDef.h\">\r\n      <Filter>ChilliSource\\UI\\Drawable</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\Drawable\\StandardUIDrawable.h\">\r\n      <Filter>ChilliSource\\UI\\Drawable</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\Drawable\\StandardUIDrawableDef.h\">\r\n      <Filter>ChilliSource\\UI\\Drawable</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\Drawable\\ThreePatchUIDrawable.h\">\r\n      <Filter>ChilliSource\\UI\\Drawable</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\Drawable\\ThreePatchUIDrawableDef.h\">\r\n      <Filter>ChilliSource\\UI\\Drawable</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\Drawable\\UIDrawable.h\">\r\n      <Filter>ChilliSource\\UI\\Drawable</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\Drawable\\UIDrawableDef.h\">\r\n      <Filter>ChilliSource\\UI\\Drawable</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\Drawable\\UIDrawableUtils.h\">\r\n      <Filter>ChilliSource\\UI\\Drawable</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\Layout\\GridUILayout.h\">\r\n      <Filter>ChilliSource\\UI\\Layout</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\Layout\\GridUILayoutDef.h\">\r\n      <Filter>ChilliSource\\UI\\Layout</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\Layout\\HListUILayout.h\">\r\n      <Filter>ChilliSource\\UI\\Layout</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\Layout\\HListUILayoutDef.h\">\r\n      <Filter>ChilliSource\\UI\\Layout</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\Layout\\LayoutDef.h\">\r\n      <Filter>ChilliSource\\UI\\Layout</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\Layout\\LayoutUIComponent.h\">\r\n      <Filter>ChilliSource\\UI\\Layout</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\Layout\\UILayout.h\">\r\n      <Filter>ChilliSource\\UI\\Layout</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\Layout\\UILayoutDef.h\">\r\n      <Filter>ChilliSource\\UI\\Layout</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\Layout\\VListUILayout.h\">\r\n      <Filter>ChilliSource\\UI\\Layout</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\Layout\\VListUILayoutDef.h\">\r\n      <Filter>ChilliSource\\UI\\Layout</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\ProgressBar\\ProgressBarDirection.h\">\r\n      <Filter>ChilliSource\\UI\\ProgressBar</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\ProgressBar\\ProgressBarType.h\">\r\n      <Filter>ChilliSource\\UI\\ProgressBar</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\ProgressBar\\ProgressBarUIComponent.h\">\r\n      <Filter>ChilliSource\\UI\\ProgressBar</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\Slider\\SliderDirection.h\">\r\n      <Filter>ChilliSource\\UI\\Slider</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\Slider\\SliderUIComponent.h\">\r\n      <Filter>ChilliSource\\UI\\Slider</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\Text\\TextComponent.h\">\r\n      <Filter>ChilliSource\\UI\\Text</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\Text\\TextIcon.h\">\r\n      <Filter>ChilliSource\\UI\\Text</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\Text\\TextUIComponent.h\">\r\n      <Filter>ChilliSource\\UI\\Text</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Input\\Base\\InputFilter.h\">\r\n      <Filter>ChilliSource\\Input\\Base</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Base\\LifecycleManager.h\">\r\n      <Filter>ChilliSource\\Core\\Base</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\AlignmentAnchors.h\">\r\n      <Filter>ChilliSource\\Rendering\\Base</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\AspectRatioUtils.h\">\r\n      <Filter>ChilliSource\\Rendering\\Base</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\BlendMode.h\">\r\n      <Filter>ChilliSource\\Rendering\\Base</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\CanvasMaterialPool.h\">\r\n      <Filter>ChilliSource\\Rendering\\Base</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\CanvasRenderer.h\">\r\n      <Filter>ChilliSource\\Rendering\\Base</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\CullFace.h\">\r\n      <Filter>ChilliSource\\Rendering\\Base</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\DepthTestComparison.h\">\r\n      <Filter>ChilliSource\\Rendering\\Base</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\HorizontalTextJustification.h\">\r\n      <Filter>ChilliSource\\Rendering\\Base</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\RenderCapabilities.h\">\r\n      <Filter>ChilliSource\\Rendering\\Base</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\Renderer.h\">\r\n      <Filter>ChilliSource\\Rendering\\Base</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\RenderFrame.h\">\r\n      <Filter>ChilliSource\\Rendering\\Base</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\RenderFrameCompiler.h\">\r\n      <Filter>ChilliSource\\Rendering\\Base</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\RenderObject.h\">\r\n      <Filter>ChilliSource\\Rendering\\Base</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\RenderSnapshot.h\">\r\n      <Filter>ChilliSource\\Rendering\\Base</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\SizePolicy.h\">\r\n      <Filter>ChilliSource\\Rendering\\Base</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\SurfaceFormat.h\">\r\n      <Filter>ChilliSource\\Rendering\\Base</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\VerticalTextJustification.h\">\r\n      <Filter>ChilliSource\\Rendering\\Base</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Camera\\RenderCamera.h\">\r\n      <Filter>ChilliSource\\Rendering\\Camera</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Texture\\RenderTexture.h\">\r\n      <Filter>ChilliSource\\Rendering\\Texture</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Texture\\RenderTextureManager.h\">\r\n      <Filter>ChilliSource\\Rendering\\Texture</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Texture\\TextureDesc.h\">\r\n      <Filter>ChilliSource\\Rendering\\Texture</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Texture\\TextureFilterMode.h\">\r\n      <Filter>ChilliSource\\Rendering\\Texture</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Texture\\TextureWrapMode.h\">\r\n      <Filter>ChilliSource\\Rendering\\Texture</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\RenderCommand.h\">\r\n      <Filter>ChilliSource\\Rendering\\RenderCommand</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\RenderCommandList.h\">\r\n      <Filter>ChilliSource\\Rendering\\RenderCommand</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\LoadTextureRenderCommand.h\">\r\n      <Filter>ChilliSource\\Rendering\\RenderCommand\\Commands</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\UnloadTextureRenderCommand.h\">\r\n      <Filter>ChilliSource\\Rendering\\RenderCommand\\Commands</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Shader\\CSShaderProvider.h\">\r\n      <Filter>ChilliSource\\Rendering\\Shader</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Shader\\RenderShader.h\">\r\n      <Filter>ChilliSource\\Rendering\\Shader</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Shader\\RenderShaderManager.h\">\r\n      <Filter>ChilliSource\\Rendering\\Shader</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\LoadShaderRenderCommand.h\">\r\n      <Filter>ChilliSource\\Rendering\\RenderCommand\\Commands</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\UnloadShaderRenderCommand.h\">\r\n      <Filter>ChilliSource\\Rendering\\RenderCommand\\Commands</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\LoadMeshRenderCommand.h\">\r\n      <Filter>ChilliSource\\Rendering\\RenderCommand\\Commands</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\UnloadMeshRenderCommand.h\">\r\n      <Filter>ChilliSource\\Rendering\\RenderCommand\\Commands</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Material\\RenderMaterial.h\">\r\n      <Filter>ChilliSource\\Rendering\\Material</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Material\\RenderMaterialGroup.h\">\r\n      <Filter>ChilliSource\\Rendering\\Material</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Material\\RenderMaterialGroupManager.h\">\r\n      <Filter>ChilliSource\\Rendering\\Material</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\LoadMaterialGroupRenderCommand.h\">\r\n      <Filter>ChilliSource\\Rendering\\RenderCommand\\Commands</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\UnloadMaterialGroupRenderCommand.h\">\r\n      <Filter>ChilliSource\\Rendering\\RenderCommand\\Commands</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\ForwardRenderPasses.h\">\r\n      <Filter>ChilliSource\\Rendering\\Base</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\TargetRenderPassGroup.h\">\r\n      <Filter>ChilliSource\\Rendering\\Base</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\RenderPass.h\">\r\n      <Filter>ChilliSource\\Rendering\\Base</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\CameraRenderPassGroup.h\">\r\n      <Filter>ChilliSource\\Rendering\\Base</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\IRenderPassCompiler.h\">\r\n      <Filter>ChilliSource\\Rendering\\Base</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\RenderPassObject.h\">\r\n      <Filter>ChilliSource\\Rendering\\Base</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Material\\ForwardRenderMaterialGroupManager.h\">\r\n      <Filter>ChilliSource\\Rendering\\Material</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Model\\CSAnimProvider.h\">\r\n      <Filter>ChilliSource\\Rendering\\Model</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Model\\CSModelProvider.h\">\r\n      <Filter>ChilliSource\\Rendering\\Model</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Model\\IndexFormat.h\">\r\n      <Filter>ChilliSource\\Rendering\\Model</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Model\\MeshDesc.h\">\r\n      <Filter>ChilliSource\\Rendering\\Model</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Model\\Model.h\">\r\n      <Filter>ChilliSource\\Rendering\\Model</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Model\\ModelDesc.h\">\r\n      <Filter>ChilliSource\\Rendering\\Model</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Model\\PolygonType.h\">\r\n      <Filter>ChilliSource\\Rendering\\Model</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Model\\PrimitiveModelFactory.h\">\r\n      <Filter>ChilliSource\\Rendering\\Model</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Model\\RenderMesh.h\">\r\n      <Filter>ChilliSource\\Rendering\\Model</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Model\\RenderMeshManager.h\">\r\n      <Filter>ChilliSource\\Rendering\\Model</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Model\\Skeleton.h\">\r\n      <Filter>ChilliSource\\Rendering\\Model</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Model\\SkeletonDesc.h\">\r\n      <Filter>ChilliSource\\Rendering\\Model</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Model\\SkinnedAnimation.h\">\r\n      <Filter>ChilliSource\\Rendering\\Model</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Model\\SkinnedAnimationGroup.h\">\r\n      <Filter>ChilliSource\\Rendering\\Model</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Model\\StaticModelComponent.h\">\r\n      <Filter>ChilliSource\\Rendering\\Model</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Model\\VertexFormat.h\">\r\n      <Filter>ChilliSource\\Rendering\\Model</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\CSBackend\\Rendering\\OpenGL\\Model\\GLMesh.h\">\r\n      <Filter>CSBackend\\Rendering\\OpenGL\\Model</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\CSBackend\\Rendering\\OpenGL\\Shader\\GLShader.h\">\r\n      <Filter>CSBackend\\Rendering\\OpenGL\\Shader</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\CSBackend\\Rendering\\OpenGL\\Texture\\GLTexture.h\">\r\n      <Filter>CSBackend\\Rendering\\OpenGL\\Texture</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\CSBackend\\Rendering\\OpenGL\\Base\\RenderCommandProcessor.h\">\r\n      <Filter>CSBackend\\Rendering\\OpenGL\\Base</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\IRenderCommandProcessor.h\">\r\n      <Filter>ChilliSource\\Rendering\\Base</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Base\\ByteBuffer.h\">\r\n      <Filter>ChilliSource\\Core\\Base</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\File\\FileStream\\BinaryInputStream.h\">\r\n      <Filter>ChilliSource\\Core\\File\\FileStream</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\File\\FileStream\\BinaryOutputStream.h\">\r\n      <Filter>ChilliSource\\Core\\File\\FileStream</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\File\\FileStream\\FileWriteMode.h\">\r\n      <Filter>ChilliSource\\Core\\File\\FileStream</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\File\\FileStream\\IBinaryInputStream.h\">\r\n      <Filter>ChilliSource\\Core\\File\\FileStream</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\File\\FileStream\\ITextInputStream.h\">\r\n      <Filter>ChilliSource\\Core\\File\\FileStream</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\File\\FileStream\\TextInputStream.h\">\r\n      <Filter>ChilliSource\\Core\\File\\FileStream</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\File\\FileStream\\TextOutputStream.h\">\r\n      <Filter>ChilliSource\\Core\\File\\FileStream</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\ForwardRenderPassCompiler.h\">\r\n      <Filter>ChilliSource\\Rendering\\Base</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\RenderPassObjectSorter.h\">\r\n      <Filter>ChilliSource\\Rendering\\Base</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\RenderPassVisibilityChecker.h\">\r\n      <Filter>ChilliSource\\Rendering\\Base</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\RenderCommandCompiler.h\">\r\n      <Filter>ChilliSource\\Rendering\\Base</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\ApplyCameraRenderCommand.h\">\r\n      <Filter>ChilliSource\\Rendering\\RenderCommand\\Commands</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\ApplyMaterialRenderCommand.h\">\r\n      <Filter>ChilliSource\\Rendering\\RenderCommand\\Commands</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\ApplyMeshRenderCommand.h\">\r\n      <Filter>ChilliSource\\Rendering\\RenderCommand\\Commands</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\BeginRenderCommand.h\">\r\n      <Filter>ChilliSource\\Rendering\\RenderCommand\\Commands</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\EndRenderCommand.h\">\r\n      <Filter>ChilliSource\\Rendering\\RenderCommand\\Commands</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\RenderInstanceRenderCommand.h\">\r\n      <Filter>ChilliSource\\Rendering\\RenderCommand\\Commands</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\CSBackend\\Rendering\\OpenGL\\Material\\GLMaterial.h\">\r\n      <Filter>CSBackend\\Rendering\\OpenGL\\Material</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\CSBackend\\Rendering\\OpenGL\\Camera\\GLCamera.h\">\r\n      <Filter>CSBackend\\Rendering\\OpenGL\\Camera</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\RenderCommandBuffer.h\">\r\n      <Filter>ChilliSource\\Rendering\\RenderCommand</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Sprite\\SpriteMeshBuilder.h\">\r\n      <Filter>ChilliSource\\Rendering\\Sprite</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\ApplyDynamicMeshRenderCommand.h\">\r\n      <Filter>ChilliSource\\Rendering\\RenderCommand\\Commands</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Model\\RenderDynamicMesh.h\">\r\n      <Filter>ChilliSource\\Rendering\\Model</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\CSBackend\\Rendering\\OpenGL\\Model\\GLDynamicMesh.h\">\r\n      <Filter>CSBackend\\Rendering\\OpenGL\\Model</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\CSBackend\\Rendering\\OpenGL\\Model\\GLMeshUtils.h\">\r\n      <Filter>CSBackend\\Rendering\\OpenGL\\Model</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\CSBackend\\Rendering\\OpenGL\\Texture\\GLTextureUnitManager.h\">\r\n      <Filter>CSBackend\\Rendering\\OpenGL\\Texture</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\RenderLayer.h\">\r\n      <Filter>ChilliSource\\Rendering\\Base</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\Text\\EditableTextUIComponent.h\">\r\n      <Filter>ChilliSource\\UI\\Text</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Threading\\SingleThreadTaskPool.h\">\r\n      <Filter>ChilliSource\\Core\\Threading</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Input\\TextEntry\\TextEntryType.h\">\r\n      <Filter>ChilliSource\\Input\\TextEntry</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Input\\TextEntry\\TextEntryCapitalisation.h\">\r\n      <Filter>ChilliSource\\Input\\TextEntry</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\CSBackend\\Rendering\\OpenGL\\Base\\GLContextRestorer.h\">\r\n      <Filter>CSBackend\\Rendering\\OpenGL\\Base</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\RenderCommandBufferManager.h\">\r\n      <Filter>ChilliSource\\Rendering\\Base</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\RestoreMeshRenderCommand.h\">\r\n      <Filter>ChilliSource\\Rendering\\RenderCommand\\Commands</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\RestoreTextureRenderCommand.h\">\r\n      <Filter>ChilliSource\\Rendering\\RenderCommand\\Commands</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\CSBackend\\Rendering\\OpenGL\\Target\\GLTargetGroup.h\">\r\n      <Filter>CSBackend\\Rendering\\OpenGL\\Target</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Target\\RenderTargetGroup.h\">\r\n      <Filter>ChilliSource\\Rendering\\Target</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Target\\RenderTargetGroupManager.h\">\r\n      <Filter>ChilliSource\\Rendering\\Target</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\BeginWithTargetGroupRenderCommand.h\">\r\n      <Filter>ChilliSource\\Rendering\\RenderCommand\\Commands</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\LoadTargetGroupRenderCommand.h\">\r\n      <Filter>ChilliSource\\Rendering\\RenderCommand\\Commands</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\UnloadTargetGroupRenderCommand.h\">\r\n      <Filter>ChilliSource\\Rendering\\RenderCommand\\Commands</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Lighting\\AmbientRenderLight.h\">\r\n      <Filter>ChilliSource\\Rendering\\Lighting</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Lighting\\DirectionalRenderLight.h\">\r\n      <Filter>ChilliSource\\Rendering\\Lighting</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Lighting\\PointRenderLight.h\">\r\n      <Filter>ChilliSource\\Rendering\\Lighting</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\ApplyAmbientLightRenderCommand.h\">\r\n      <Filter>ChilliSource\\Rendering\\RenderCommand\\Commands</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\ApplyDirectionalLightRenderCommand.h\">\r\n      <Filter>ChilliSource\\Rendering\\RenderCommand\\Commands</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\ApplyPointLightRenderCommand.h\">\r\n      <Filter>ChilliSource\\Rendering\\RenderCommand\\Commands</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\CSBackend\\Rendering\\OpenGL\\Lighting\\GLAmbientLight.h\">\r\n      <Filter>CSBackend\\Rendering\\OpenGL\\Lighting</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\CSBackend\\Rendering\\OpenGL\\Lighting\\GLDirectionalLight.h\">\r\n      <Filter>CSBackend\\Rendering\\OpenGL\\Lighting</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\CSBackend\\Rendering\\OpenGL\\Lighting\\GLLight.h\">\r\n      <Filter>CSBackend\\Rendering\\OpenGL\\Lighting</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\CSBackend\\Rendering\\OpenGL\\Lighting\\GLPointLight.h\">\r\n      <Filter>CSBackend\\Rendering\\OpenGL\\Lighting</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Memory\\IAllocator.h\">\r\n      <Filter>ChilliSource\\Core\\Memory</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Memory\\LinearAllocator.h\">\r\n      <Filter>ChilliSource\\Core\\Memory</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Memory\\MemoryUtils.h\">\r\n      <Filter>ChilliSource\\Core\\Memory</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Memory\\MemoryUtilsImpl.h\">\r\n      <Filter>ChilliSource\\Core\\Memory</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Memory\\PagedLinearAllocator.h\">\r\n      <Filter>ChilliSource\\Core\\Memory</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Memory\\SharedPtr.h\">\r\n      <Filter>ChilliSource\\Core\\Memory</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Memory\\SharedPtrImpl.h\">\r\n      <Filter>ChilliSource\\Core\\Memory</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Memory\\UniquePtr.h\">\r\n      <Filter>ChilliSource\\Core\\Memory</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Memory\\UniquePtrImpl.h\">\r\n      <Filter>ChilliSource\\Core\\Memory</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Memory.h\">\r\n      <Filter>ChilliSource\\Core</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand.h\">\r\n      <Filter>ChilliSource\\Rendering</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Target.h\">\r\n      <Filter>ChilliSource\\Rendering</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\FrameAllocatorQueue.h\">\r\n      <Filter>ChilliSource\\Rendering\\Base</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\RestoreRenderTargetGroupCommand.h\">\r\n      <Filter>ChilliSource\\Rendering\\RenderCommand\\Commands</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Target\\TargetGroup.h\">\r\n      <Filter>ChilliSource\\Rendering\\Target</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Model\\AnimatedModelComponent.h\">\r\n      <Filter>ChilliSource\\Rendering\\Model</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Model\\RenderSkinnedAnimation.h\">\r\n      <Filter>ChilliSource\\Rendering\\Model</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\ApplySkinnedAnimationRenderCommand.h\">\r\n      <Filter>ChilliSource\\Rendering\\RenderCommand\\Commands</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\CSBackend\\Rendering\\OpenGL\\Model\\GLSkinnedAnimation.h\">\r\n      <Filter>CSBackend\\Rendering\\OpenGL\\Model</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\RenderFrameData.h\">\r\n      <Filter>ChilliSource\\Rendering\\Base</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Shader\\RenderShaderVariables.h\">\r\n      <Filter>ChilliSource\\Rendering\\Shader</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Base\\SystemInfo.h\">\r\n      <Filter>ChilliSource\\Core\\Base</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Base\\DeviceInfo.h\">\r\n      <Filter>ChilliSource\\Core\\Base</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\CSBackend\\Platform\\Windows\\Core\\Base\\SystemInfoFactory.h\">\r\n      <Filter>CSBackend\\Platform\\Windows\\Core\\Base</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Model\\RenderMeshBatch.h\">\r\n      <Filter>ChilliSource\\Rendering\\Model</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Model\\SmallMeshBatcher.h\">\r\n      <Filter>ChilliSource\\Rendering\\Model</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\ApplyMeshBatchRenderCommand.h\">\r\n      <Filter>ChilliSource\\Rendering\\RenderCommand\\Commands</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Base\\ScreenInfo.h\">\r\n      <Filter>ChilliSource\\Core\\Base</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\CSBackend\\Rendering\\OpenGL\\Base\\RenderInfoFactory.h\">\r\n      <Filter>CSBackend\\Rendering\\OpenGL\\Base</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Base\\RenderInfo.h\">\r\n      <Filter>ChilliSource\\Core\\Base</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\StencilOp.h\">\r\n      <Filter>ChilliSource\\Rendering\\Base</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\TestFunc.h\">\r\n      <Filter>ChilliSource\\Rendering\\Base</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\CanvasDrawMode.h\">\r\n      <Filter>ChilliSource\\Rendering\\Base</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Base\\TargetType.h\">\r\n      <Filter>ChilliSource\\Rendering\\Base</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\CSBackend\\Rendering\\OpenGL\\Texture\\GLCubemap.h\">\r\n      <Filter>CSBackend\\Rendering\\OpenGL\\Texture</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\CSBackend\\Rendering\\OpenGL\\Texture\\GLTextureUtils.h\">\r\n      <Filter>CSBackend\\Rendering\\OpenGL\\Texture</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Texture\\Cubemap.h\">\r\n      <Filter>ChilliSource\\Rendering\\Texture</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Texture\\CubemapProvider.h\">\r\n      <Filter>ChilliSource\\Rendering\\Texture</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Texture\\CubemapResourceOptions.h\">\r\n      <Filter>ChilliSource\\Rendering\\Texture</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\LoadCubemapRenderCommand.h\">\r\n      <Filter>ChilliSource\\Rendering\\RenderCommand\\Commands</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\RestoreCubemapRenderCommand.h\">\r\n      <Filter>ChilliSource\\Rendering\\RenderCommand\\Commands</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\RenderCommand\\Commands\\UnloadCubemapRenderCommand.h\">\r\n      <Filter>ChilliSource\\Rendering\\RenderCommand\\Commands</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Skybox\\SkyboxComponent.h\">\r\n      <Filter>ChilliSource\\Rendering\\Skybox</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Rendering\\Skybox.h\">\r\n      <Filter>ChilliSource\\Rendering</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Input\\Gyroscope\\Gyroscope.h\">\r\n      <Filter>ChilliSource\\Input\\Gyroscope</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Memory\\ObjectPoolAllocator.h\">\r\n      <Filter>ChilliSource\\Core\\Memory</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Cryptographic\\HashSHA256.h\">\r\n      <Filter>ChilliSource\\Core\\Cryptographic</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\CSBackend\\Rendering\\OpenGL\\Base\\GLExtensions.h\">\r\n      <Filter>CSBackend\\Rendering\\OpenGL\\Base</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\UI\\Base\\CursorSystem.h\">\r\n      <Filter>ChilliSource\\UI\\Base</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Core\\Base\\CursorType.h\">\r\n      <Filter>ChilliSource\\Core\\Base</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Input\\Gamepad\\Gamepad.h\">\r\n      <Filter>ChilliSource\\Input\\Gamepad</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Input\\Gamepad\\GamepadSystem.h\">\r\n      <Filter>ChilliSource\\Input\\Gamepad</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Input\\Gamepad.h\">\r\n      <Filter>ChilliSource\\Input</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\CSBackend\\Platform\\Windows\\Input\\Gamepad\\GamepadSystem.h\">\r\n      <Filter>CSBackend\\Platform\\Windows\\Input\\Gamepad</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Input\\Gamepad\\GamepadAxis.h\">\r\n      <Filter>ChilliSource\\Input\\Gamepad</Filter>\r\n    </ClInclude>\r\n    <ClInclude Include=\"..\\..\\Source\\ChilliSource\\Input\\Gamepad\\GamepadMappings.h\">\r\n      <Filter>ChilliSource\\Input\\Gamepad</Filter>\r\n    </ClInclude>\r\n  </ItemGroup>\r\n</Project>"
  },
  {
    "path": "Projects/iOS/ChilliSource.xcodeproj/project.pbxproj",
    "content": "// !$*UTF8*$!\n{\n\tarchiveVersion = 1;\n\tclasses = {\n\t};\n\tobjectVersion = 46;\n\tobjects = {\n\n/* Begin PBXBuildFile section */\n\t\t27408C081D366C7A00A0B003 /* DeviceInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 27408C041D366C7A00A0B003 /* DeviceInfo.cpp */; };\n\t\t27408C091D366C7A00A0B003 /* SystemInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 27408C061D366C7A00A0B003 /* SystemInfo.cpp */; };\n\t\t27408C1C1D369F8D00A0B003 /* SystemInfoFactory.mm in Sources */ = {isa = PBXBuildFile; fileRef = 27408C1B1D369F8D00A0B003 /* SystemInfoFactory.mm */; };\n\t\t27408C291D36DCB600A0B003 /* ScreenInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 27408C271D36DCB600A0B003 /* ScreenInfo.cpp */; };\n\t\t2787EA6B1E30D4EC00E83458 /* Gyroscope.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2787EA6A1E30D4EC00E83458 /* Gyroscope.cpp */; };\n\t\t2787EA6E1E30D59200E83458 /* Gyroscope.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2787EA6D1E30D59200E83458 /* Gyroscope.mm */; };\n\t\t27B4258C1E6058A300E17750 /* HashSHA256.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 27B4258A1E6058A300E17750 /* HashSHA256.cpp */; };\n\t\t810C0C841D11B01100C32406 /* GLMesh.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 810C0C821D11B01100C32406 /* GLMesh.cpp */; };\n\t\t813BA9D81D379F6D00A3B091 /* RenderInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 813BA9D61D379F6D00A3B091 /* RenderInfo.cpp */; };\n\t\t813BA9DB1D37BE0600A3B091 /* RenderInfoFactory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 813BA9D91D37BE0600A3B091 /* RenderInfoFactory.cpp */; };\n\t\t814001A01E72D21F00388C2A /* GLExtensions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8140019F1E72D21F00388C2A /* GLExtensions.cpp */; };\n\t\t8151757A1E3F4E5C0024361A /* SkyboxComponent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 815175771E3F4E5C0024361A /* SkyboxComponent.cpp */; };\n\t\t81559AAF1E925F4C00A1B107 /* Gamepad.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81559AAB1E925F4C00A1B107 /* Gamepad.cpp */; };\n\t\t81559AB01E925F4C00A1B107 /* GamepadSystem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81559AAD1E925F4C00A1B107 /* GamepadSystem.cpp */; };\n\t\t8155F30C1E785B7700750A05 /* CursorSystem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8155F30A1E785B7700750A05 /* CursorSystem.cpp */; };\n\t\t8156124B1D2E5D41000DD01B /* GLTargetGroup.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 815612491D2E5D41000DD01B /* GLTargetGroup.cpp */; };\n\t\t8158F7C11C89D2AD00B13109 /* CSAppDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = 8158F59C1C89D2AD00B13109 /* CSAppDelegate.mm */; };\n\t\t8158F7C21C89D2AD00B13109 /* CSGLViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 8158F59E1C89D2AD00B13109 /* CSGLViewController.mm */; };\n\t\t8158F7C41C89D2AD00B13109 /* PlatformSystem.mm in Sources */ = {isa = PBXBuildFile; fileRef = 8158F5A21C89D2AD00B13109 /* PlatformSystem.mm */; };\n\t\t8158F7C51C89D2AD00B13109 /* Screen.mm in Sources */ = {isa = PBXBuildFile; fileRef = 8158F5A41C89D2AD00B13109 /* Screen.mm */; };\n\t\t8158F7C61C89D2AD00B13109 /* DialogueBoxListener.mm in Sources */ = {isa = PBXBuildFile; fileRef = 8158F5A71C89D2AD00B13109 /* DialogueBoxListener.mm */; };\n\t\t8158F7C71C89D2AD00B13109 /* DialogueBoxSystem.mm in Sources */ = {isa = PBXBuildFile; fileRef = 8158F5A91C89D2AD00B13109 /* DialogueBoxSystem.mm */; };\n\t\t8158F7C81C89D2AD00B13109 /* FileSystem.mm in Sources */ = {isa = PBXBuildFile; fileRef = 8158F5AC1C89D2AD00B13109 /* FileSystem.mm */; };\n\t\t8158F7C91C89D2AD00B13109 /* PNGImageProvider.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8158F5AE1C89D2AD00B13109 /* PNGImageProvider.cpp */; };\n\t\t8158F7CA1C89D2AD00B13109 /* RNGContainer.mm in Sources */ = {isa = PBXBuildFile; fileRef = 8158F5B21C89D2AD00B13109 /* RNGContainer.mm */; };\n\t\t8158F7CB1C89D2AD00B13109 /* LocalNotificationSystem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8158F5B41C89D2AD00B13109 /* LocalNotificationSystem.cpp */; };\n\t\t8158F7CC1C89D2AD00B13109 /* NSNotificationAdapter.mm in Sources */ = {isa = PBXBuildFile; fileRef = 8158F5B71C89D2AD00B13109 /* NSNotificationAdapter.mm */; };\n\t\t8158F7CD1C89D2AD00B13109 /* RemoteNotificationSystem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8158F5B81C89D2AD00B13109 /* RemoteNotificationSystem.cpp */; };\n\t\t8158F7CE1C89D2AD00B13109 /* NSStringUtils.mm in Sources */ = {isa = PBXBuildFile; fileRef = 8158F5BC1C89D2AD00B13109 /* NSStringUtils.mm */; };\n\t\t8158F7CF1C89D2AD00B13109 /* Accelerometer.mm in Sources */ = {isa = PBXBuildFile; fileRef = 8158F5C11C89D2AD00B13109 /* Accelerometer.mm */; };\n\t\t8158F7D01C89D2AD00B13109 /* DeviceButtonSystem.mm in Sources */ = {isa = PBXBuildFile; fileRef = 8158F5C41C89D2AD00B13109 /* DeviceButtonSystem.mm */; };\n\t\t8158F7D11C89D2AD00B13109 /* PointerSystem.mm in Sources */ = {isa = PBXBuildFile; fileRef = 8158F5C71C89D2AD00B13109 /* PointerSystem.mm */; };\n\t\t8158F7D21C89D2AD00B13109 /* TextEntry.mm in Sources */ = {isa = PBXBuildFile; fileRef = 8158F5CA1C89D2AD00B13109 /* TextEntry.mm */; };\n\t\t8158F7D31C89D2AD00B13109 /* TextEntryDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = 8158F5CC1C89D2AD00B13109 /* TextEntryDelegate.mm */; };\n\t\t8158F7D41C89D2AD00B13109 /* Main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8158F5CD1C89D2AD00B13109 /* Main.cpp */; };\n\t\t8158F7D51C89D2AD00B13109 /* HttpDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = 8158F5D11C89D2AD00B13109 /* HttpDelegate.mm */; };\n\t\t8158F7D61C89D2AD00B13109 /* HttpRequest.mm in Sources */ = {isa = PBXBuildFile; fileRef = 8158F5D31C89D2AD00B13109 /* HttpRequest.mm */; };\n\t\t8158F7D71C89D2AD00B13109 /* HttpRequestSystem.mm in Sources */ = {isa = PBXBuildFile; fileRef = 8158F5D51C89D2AD00B13109 /* HttpRequestSystem.mm */; };\n\t\t8158F7D81C89D2AD00B13109 /* IAPSystem.mm in Sources */ = {isa = PBXBuildFile; fileRef = 8158F5D81C89D2AD00B13109 /* IAPSystem.mm */; };\n\t\t8158F7D91C89D2AD00B13109 /* StoreKitIAPSystem.mm in Sources */ = {isa = PBXBuildFile; fileRef = 8158F5DA1C89D2AD00B13109 /* StoreKitIAPSystem.mm */; };\n\t\t8158F7DA1C89D2AD00B13109 /* EmailComposer.mm in Sources */ = {isa = PBXBuildFile; fileRef = 8158F5DE1C89D2AD00B13109 /* EmailComposer.mm */; };\n\t\t8158F7DB1C89D2AD00B13109 /* EmailComposerDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = 8158F5E01C89D2AD00B13109 /* EmailComposerDelegate.mm */; };\n\t\t8158F7E01C89D2AD00B13109 /* SubtitlesRenderer.mm in Sources */ = {isa = PBXBuildFile; fileRef = 8158F5EE1C89D2AD00B13109 /* SubtitlesRenderer.mm */; };\n\t\t8158F7E11C89D2AD00B13109 /* VideoOverlayView.mm in Sources */ = {isa = PBXBuildFile; fileRef = 8158F5F01C89D2AD00B13109 /* VideoOverlayView.mm */; };\n\t\t8158F7E21C89D2AD00B13109 /* VideoPlayer.mm in Sources */ = {isa = PBXBuildFile; fileRef = 8158F5F21C89D2AD00B13109 /* VideoPlayer.mm */; };\n\t\t8158F7E31C89D2AD00B13109 /* VideoPlayerTapListener.mm in Sources */ = {isa = PBXBuildFile; fileRef = 8158F5F41C89D2AD00B13109 /* VideoPlayerTapListener.mm */; };\n\t\t8158F7E41C89D2AD00B13109 /* WebView.mm in Sources */ = {isa = PBXBuildFile; fileRef = 8158F5F81C89D2AD00B13109 /* WebView.mm */; };\n\t\t8158F7E51C89D2AD00B13109 /* WebViewDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = 8158F5FA1C89D2AD00B13109 /* WebViewDelegate.mm */; };\n\t\t8158F7F81C89D2AD00B13109 /* GLError.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8158F6321C89D2AD00B13109 /* GLError.cpp */; };\n\t\t817255FD1E0A91FB00A65625 /* GLCubemap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 817255FB1E0A91FB00A65625 /* GLCubemap.cpp */; };\n\t\t817256001E0A958500A65625 /* GLTextureUtils.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 817255FE1E0A958500A65625 /* GLTextureUtils.cpp */; };\n\t\t817256071E0A9F2600A65625 /* LoadCubemapRenderCommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 817256011E0A9F2600A65625 /* LoadCubemapRenderCommand.cpp */; };\n\t\t817256081E0A9F2600A65625 /* RestoreCubemapRenderCommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 817256031E0A9F2600A65625 /* RestoreCubemapRenderCommand.cpp */; };\n\t\t817256091E0A9F2600A65625 /* UnloadCubemapRenderCommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 817256051E0A9F2600A65625 /* UnloadCubemapRenderCommand.cpp */; };\n\t\t8172560D1E0ABE1500A65625 /* Cubemap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8172560B1E0ABE1500A65625 /* Cubemap.cpp */; };\n\t\t817256101E0AC08100A65625 /* CubemapProvider.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8172560E1E0AC08100A65625 /* CubemapProvider.cpp */; };\n\t\t817256131E0AEF1F00A65625 /* CubemapResourceOptions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 817256111E0AEF1F00A65625 /* CubemapResourceOptions.cpp */; };\n\t\t81729FA41D1BE681005B8CC9 /* GLMaterial.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81729FA21D1BE681005B8CC9 /* GLMaterial.cpp */; };\n\t\t81729FA81D1BE92B005B8CC9 /* GLCamera.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81729FA61D1BE92B005B8CC9 /* GLCamera.cpp */; };\n\t\t81729FAB1D1BFF05005B8CC9 /* GLTextureUnitManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81729FA91D1BFF05005B8CC9 /* GLTextureUnitManager.cpp */; };\n\t\t817B8F8D1D2AE21300273F4B /* GLAmbientLight.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 817B8F891D2AE21300273F4B /* GLAmbientLight.cpp */; };\n\t\t8184614C1D3503E8004B0C46 /* CkAudioPlayer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845E0B1D3503E8004B0C46 /* CkAudioPlayer.cpp */; };\n\t\t8184614D1D3503E8004B0C46 /* CkBank.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845E0D1D3503E8004B0C46 /* CkBank.cpp */; };\n\t\t8184614E1D3503E8004B0C46 /* CkBankProvider.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845E0F1D3503E8004B0C46 /* CkBankProvider.cpp */; };\n\t\t8184614F1D3503E8004B0C46 /* CkSound.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845E121D3503E8004B0C46 /* CkSound.cpp */; };\n\t\t818461501D3503E8004B0C46 /* CricketAudioSystem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845E141D3503E8004B0C46 /* CricketAudioSystem.cpp */; };\n\t\t818461511D3503E8004B0C46 /* AppConfig.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845E1B1D3503E8004B0C46 /* AppConfig.cpp */; };\n\t\t818461521D3503E8004B0C46 /* Application.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845E1D1D3503E8004B0C46 /* Application.cpp */; };\n\t\t818461531D3503E8004B0C46 /* ByteBuffer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845E1F1D3503E8004B0C46 /* ByteBuffer.cpp */; };\n\t\t818461541D3503E8004B0C46 /* ByteColour.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845E211D3503E8004B0C46 /* ByteColour.cpp */; };\n\t\t818461551D3503E8004B0C46 /* Colour.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845E231D3503E8004B0C46 /* Colour.cpp */; };\n\t\t818461561D3503E8004B0C46 /* ColourUtils.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845E251D3503E8004B0C46 /* ColourUtils.cpp */; };\n\t\t818461571D3503E8004B0C46 /* Device.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845E281D3503E8004B0C46 /* Device.cpp */; };\n\t\t818461581D3503E8004B0C46 /* LifecycleManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845E2B1D3503E8004B0C46 /* LifecycleManager.cpp */; };\n\t\t818461591D3503E8004B0C46 /* Logging.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845E2D1D3503E8004B0C46 /* Logging.cpp */; };\n\t\t8184615A1D3503E8004B0C46 /* PlatformSystem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845E301D3503E8004B0C46 /* PlatformSystem.cpp */; };\n\t\t8184615B1D3503E8004B0C46 /* Screen.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845E331D3503E8004B0C46 /* Screen.cpp */; };\n\t\t8184615C1D3503E8004B0C46 /* Utils.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845E371D3503E8004B0C46 /* Utils.cpp */; };\n\t\t8184615D1D3503E8004B0C46 /* ParamDictionary.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845E431D3503E8004B0C46 /* ParamDictionary.cpp */; };\n\t\t8184615E1D3503E8004B0C46 /* ParamDictionarySerialiser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845E451D3503E8004B0C46 /* ParamDictionarySerialiser.cpp */; };\n\t\t8184615F1D3503E8004B0C46 /* PropertyMap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845E4B1D3503E8004B0C46 /* PropertyMap.cpp */; };\n\t\t818461601D3503E8004B0C46 /* PropertyTypes.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845E4E1D3503E8004B0C46 /* PropertyTypes.cpp */; };\n\t\t818461611D3503E8004B0C46 /* AESEncrypt.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845E561D3503E8004B0C46 /* AESEncrypt.cpp */; };\n\t\t818461621D3503E8004B0C46 /* BaseEncoding.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845E581D3503E8004B0C46 /* BaseEncoding.cpp */; };\n\t\t818461631D3503E8004B0C46 /* HashCRC32.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845E5A1D3503E8004B0C46 /* HashCRC32.cpp */; };\n\t\t818461641D3503E8004B0C46 /* HashMD5.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845E5C1D3503E8004B0C46 /* HashMD5.cpp */; };\n\t\t818461651D3503E8004B0C46 /* HashSHA1.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845E5E1D3503E8004B0C46 /* HashSHA1.cpp */; };\n\t\t818461661D3503E8004B0C46 /* OAuth.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845E601D3503E8004B0C46 /* OAuth.cpp */; };\n\t\t818461671D3503E8004B0C46 /* DialogueBoxSystem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845E6A1D3503E8004B0C46 /* DialogueBoxSystem.cpp */; };\n\t\t818461681D3503E8004B0C46 /* Component.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845E6E1D3503E8004B0C46 /* Component.cpp */; };\n\t\t818461691D3503E8004B0C46 /* Entity.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845E701D3503E8004B0C46 /* Entity.cpp */; };\n\t\t8184616A1D3503E8004B0C46 /* PrimitiveEntityFactory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845E721D3503E8004B0C46 /* PrimitiveEntityFactory.cpp */; };\n\t\t8184616B1D3503E8004B0C46 /* Transform.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845E741D3503E8004B0C46 /* Transform.cpp */; };\n\t\t8184616C1D3503E8004B0C46 /* EventConnection.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845E791D3503E8004B0C46 /* EventConnection.cpp */; };\n\t\t8184616D1D3503E8004B0C46 /* AppDataStore.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845E7F1D3503E8004B0C46 /* AppDataStore.cpp */; };\n\t\t8184616E1D3503E8004B0C46 /* CSBinaryChunk.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845E811D3503E8004B0C46 /* CSBinaryChunk.cpp */; };\n\t\t8184616F1D3503E8004B0C46 /* CSBinaryInputStream.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845E831D3503E8004B0C46 /* CSBinaryInputStream.cpp */; };\n\t\t818461701D3503E8004B0C46 /* BinaryInputStream.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845E861D3503E8004B0C46 /* BinaryInputStream.cpp */; };\n\t\t818461711D3503E8004B0C46 /* BinaryOutputStream.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845E881D3503E8004B0C46 /* BinaryOutputStream.cpp */; };\n\t\t818461721D3503E8004B0C46 /* FileWriteMode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845E8A1D3503E8004B0C46 /* FileWriteMode.cpp */; };\n\t\t818461731D3503E8004B0C46 /* TextInputStream.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845E8E1D3503E8004B0C46 /* TextInputStream.cpp */; };\n\t\t818461741D3503E8004B0C46 /* TextOutputStream.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845E901D3503E8004B0C46 /* TextOutputStream.cpp */; };\n\t\t818461751D3503E8004B0C46 /* FileSystem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845E921D3503E8004B0C46 /* FileSystem.cpp */; };\n\t\t818461761D3503E8004B0C46 /* TaggedFilePathResolver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845E951D3503E8004B0C46 /* TaggedFilePathResolver.cpp */; };\n\t\t818461771D3503E8004B0C46 /* CSImageProvider.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845E9A1D3503E8004B0C46 /* CSImageProvider.cpp */; };\n\t\t818461781D3503E8004B0C46 /* ETC1ImageProvider.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845E9C1D3503E8004B0C46 /* ETC1ImageProvider.cpp */; };\n\t\t818461791D3503E8004B0C46 /* Image.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845E9E1D3503E8004B0C46 /* Image.cpp */; };\n\t\t8184617A1D3503E8004B0C46 /* ImageFormatConverter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845EA21D3503E8004B0C46 /* ImageFormatConverter.cpp */; };\n\t\t8184617B1D3503E8004B0C46 /* PNGImageProvider.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845EA41D3503E8004B0C46 /* PNGImageProvider.cpp */; };\n\t\t8184617C1D3503E8004B0C46 /* PVRImageProvider.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845EA61D3503E8004B0C46 /* PVRImageProvider.cpp */; };\n\t\t8184617D1D3503E8004B0C46 /* JsonUtils.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845EAA1D3503E8004B0C46 /* JsonUtils.cpp */; };\n\t\t8184617E1D3503E8004B0C46 /* LocalisedText.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845EAE1D3503E8004B0C46 /* LocalisedText.cpp */; };\n\t\t8184617F1D3503E8004B0C46 /* LocalisedTextProvider.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845EB01D3503E8004B0C46 /* LocalisedTextProvider.cpp */; };\n\t\t818461801D3503E8004B0C46 /* ShapeIntersection.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845EB61D3503E8004B0C46 /* ShapeIntersection.cpp */; };\n\t\t818461811D3503E8004B0C46 /* Shapes.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845EB81D3503E8004B0C46 /* Shapes.cpp */; };\n\t\t818461821D3503E8004B0C46 /* Interpolate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845EBA1D3503E8004B0C46 /* Interpolate.cpp */; };\n\t\t818461831D3503E8004B0C46 /* MathUtils.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845EBC1D3503E8004B0C46 /* MathUtils.cpp */; };\n\t\t818461841D3503E8004B0C46 /* Random.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845EC21D3503E8004B0C46 /* Random.cpp */; };\n\t\t818461851D3503E8004B0C46 /* UnifiedCoordinates.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845EC51D3503E8004B0C46 /* UnifiedCoordinates.cpp */; };\n\t\t818461861D3503E8004B0C46 /* LinearAllocator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845ECD1D3503E8004B0C46 /* LinearAllocator.cpp */; };\n\t\t818461871D3503E8004B0C46 /* PagedLinearAllocator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845ED11D3503E8004B0C46 /* PagedLinearAllocator.cpp */; };\n\t\t818461881D3503E8004B0C46 /* AppNotificationSystem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845ED91D3503E8004B0C46 /* AppNotificationSystem.cpp */; };\n\t\t818461891D3503E8004B0C46 /* LocalNotificationSystem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845EDB1D3503E8004B0C46 /* LocalNotificationSystem.cpp */; };\n\t\t8184618A1D3503E8004B0C46 /* NotificationManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845EDE1D3503E8004B0C46 /* NotificationManager.cpp */; };\n\t\t8184618B1D3503E8004B0C46 /* RemoteNotificationSystem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845EE01D3503E8004B0C46 /* RemoteNotificationSystem.cpp */; };\n\t\t8184618C1D3503E8004B0C46 /* Resource.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845EE51D3503E8004B0C46 /* Resource.cpp */; };\n\t\t8184618D1D3503E8004B0C46 /* ResourcePool.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845EE71D3503E8004B0C46 /* ResourcePool.cpp */; };\n\t\t8184618E1D3503E8004B0C46 /* ResourceProvider.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845EE91D3503E8004B0C46 /* ResourceProvider.cpp */; };\n\t\t8184618F1D3503E8004B0C46 /* Scene.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845EED1D3503E8004B0C46 /* Scene.cpp */; };\n\t\t818461901D3503E8004B0C46 /* State.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845EF11D3503E8004B0C46 /* State.cpp */; };\n\t\t818461911D3503E8004B0C46 /* StateManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845EF31D3503E8004B0C46 /* StateManager.cpp */; };\n\t\t818461921D3503E8004B0C46 /* MarkupDef.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845EF71D3503E8004B0C46 /* MarkupDef.cpp */; };\n\t\t818461931D3503E8004B0C46 /* StringMarkupParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845EF91D3503E8004B0C46 /* StringMarkupParser.cpp */; };\n\t\t818461941D3503E8004B0C46 /* StringParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845EFB1D3503E8004B0C46 /* StringParser.cpp */; };\n\t\t818461951D3503E8004B0C46 /* StringUtils.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845EFD1D3503E8004B0C46 /* StringUtils.cpp */; };\n\t\t818461961D3503E8004B0C46 /* ToString.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845EFF1D3503E8004B0C46 /* ToString.cpp */; };\n\t\t818461971D3503E8004B0C46 /* UTF8StringUtils.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845F011D3503E8004B0C46 /* UTF8StringUtils.cpp */; };\n\t\t818461981D3503E8004B0C46 /* StateSystem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845F061D3503E8004B0C46 /* StateSystem.cpp */; };\n\t\t818461991D3503E8004B0C46 /* SingleThreadTaskPool.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845F0A1D3503E8004B0C46 /* SingleThreadTaskPool.cpp */; };\n\t\t8184619A1D3503E8004B0C46 /* TaskContext.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845F0D1D3503E8004B0C46 /* TaskContext.cpp */; };\n\t\t8184619B1D3503E8004B0C46 /* TaskPool.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845F0F1D3503E8004B0C46 /* TaskPool.cpp */; };\n\t\t8184619C1D3503E8004B0C46 /* TaskScheduler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845F111D3503E8004B0C46 /* TaskScheduler.cpp */; };\n\t\t8184619D1D3503E8004B0C46 /* CoreTimer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845F161D3503E8004B0C46 /* CoreTimer.cpp */; };\n\t\t8184619E1D3503E8004B0C46 /* PerformanceTimer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845F181D3503E8004B0C46 /* PerformanceTimer.cpp */; };\n\t\t8184619F1D3503E8004B0C46 /* Timer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845F1A1D3503E8004B0C46 /* Timer.cpp */; };\n\t\t818461A01D3503E8004B0C46 /* VolumeComponent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845F251D3503E8004B0C46 /* VolumeComponent.cpp */; };\n\t\t818461A11D3503E8004B0C46 /* XML.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845F291D3503E8004B0C46 /* XML.cpp */; };\n\t\t818461A21D3503E8004B0C46 /* XMLUtils.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845F2B1D3503E8004B0C46 /* XMLUtils.cpp */; };\n\t\t818461A31D3503E8004B0C46 /* Accelerometer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845F301D3503E8004B0C46 /* Accelerometer.cpp */; };\n\t\t818461A41D3503E8004B0C46 /* InputFilter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845F341D3503E8004B0C46 /* InputFilter.cpp */; };\n\t\t818461A51D3503E8004B0C46 /* DeviceButtonSystem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845F381D3503E8004B0C46 /* DeviceButtonSystem.cpp */; };\n\t\t818461A61D3503E8004B0C46 /* DragGesture.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845F3D1D3503E8004B0C46 /* DragGesture.cpp */; };\n\t\t818461A71D3503E8004B0C46 /* Gesture.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845F3F1D3503E8004B0C46 /* Gesture.cpp */; };\n\t\t818461A81D3503E8004B0C46 /* GestureSystem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845F411D3503E8004B0C46 /* GestureSystem.cpp */; };\n\t\t818461A91D3503E8004B0C46 /* HoldGesture.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845F431D3503E8004B0C46 /* HoldGesture.cpp */; };\n\t\t818461AA1D3503E8004B0C46 /* PinchGesture.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845F451D3503E8004B0C46 /* PinchGesture.cpp */; };\n\t\t818461AB1D3503E8004B0C46 /* RotationGesture.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845F471D3503E8004B0C46 /* RotationGesture.cpp */; };\n\t\t818461AC1D3503E8004B0C46 /* TapGesture.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845F491D3503E8004B0C46 /* TapGesture.cpp */; };\n\t\t818461AD1D3503E8004B0C46 /* Keyboard.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845F4D1D3503E8004B0C46 /* Keyboard.cpp */; };\n\t\t818461AE1D3503E8004B0C46 /* KeyCode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845F4F1D3503E8004B0C46 /* KeyCode.cpp */; };\n\t\t818461AF1D3503E8004B0C46 /* Pointer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845F541D3503E8004B0C46 /* Pointer.cpp */; };\n\t\t818461B01D3503E8004B0C46 /* PointerSystem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845F561D3503E8004B0C46 /* PointerSystem.cpp */; };\n\t\t818461B11D3503E8004B0C46 /* TextEntry.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845F5A1D3503E8004B0C46 /* TextEntry.cpp */; };\n\t\t818461B21D3503E8004B0C46 /* TextEntryCapitalisation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845F5C1D3503E8004B0C46 /* TextEntryCapitalisation.cpp */; };\n\t\t818461B31D3503E8004B0C46 /* TextEntryType.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845F5E1D3503E8004B0C46 /* TextEntryType.cpp */; };\n\t\t818461B41D3503E8004B0C46 /* ContentManagementSystem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845F631D3503E8004B0C46 /* ContentManagementSystem.cpp */; };\n\t\t818461B51D3503E8004B0C46 /* MoContentDownloader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845F661D3503E8004B0C46 /* MoContentDownloader.cpp */; };\n\t\t818461B61D3503E8004B0C46 /* HttpRequestSystem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845F6C1D3503E8004B0C46 /* HttpRequestSystem.cpp */; };\n\t\t818461B71D3503E8004B0C46 /* HttpResponse.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845F6E1D3503E8004B0C46 /* HttpResponse.cpp */; };\n\t\t818461B81D3503E8004B0C46 /* IAPSystem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845F721D3503E8004B0C46 /* IAPSystem.cpp */; };\n\t\t818461B91D3503E8004B0C46 /* AlignmentAnchors.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845F771D3503E8004B0C46 /* AlignmentAnchors.cpp */; };\n\t\t818461BA1D3503E8004B0C46 /* AspectRatioUtils.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845F791D3503E8004B0C46 /* AspectRatioUtils.cpp */; };\n\t\t818461BB1D3503E8004B0C46 /* CameraRenderPassGroup.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845F7C1D3503E8004B0C46 /* CameraRenderPassGroup.cpp */; };\n\t\t818461BC1D3503E8004B0C46 /* CanvasMaterialPool.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845F7E1D3503E8004B0C46 /* CanvasMaterialPool.cpp */; };\n\t\t818461BD1D3503E8004B0C46 /* CanvasRenderer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845F801D3503E8004B0C46 /* CanvasRenderer.cpp */; };\n\t\t818461BE1D3503E8004B0C46 /* ForwardRenderPassCompiler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845F841D3503E8004B0C46 /* ForwardRenderPassCompiler.cpp */; };\n\t\t818461BF1D3503E8004B0C46 /* FrameAllocatorQueue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845F871D3503E8004B0C46 /* FrameAllocatorQueue.cpp */; };\n\t\t818461C01D3503E8004B0C46 /* HorizontalTextJustification.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845F891D3503E8004B0C46 /* HorizontalTextJustification.cpp */; };\n\t\t818461C11D3503E8004B0C46 /* IRenderCommandProcessor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845F8B1D3503E8004B0C46 /* IRenderCommandProcessor.cpp */; };\n\t\t818461C21D3503E8004B0C46 /* RenderCapabilities.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845F8E1D3503E8004B0C46 /* RenderCapabilities.cpp */; };\n\t\t818461C31D3503E8004B0C46 /* RenderCommandBufferManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845F901D3503E8004B0C46 /* RenderCommandBufferManager.cpp */; };\n\t\t818461C41D3503E8004B0C46 /* RenderCommandCompiler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845F921D3503E8004B0C46 /* RenderCommandCompiler.cpp */; };\n\t\t818461C61D3503E8004B0C46 /* Renderer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845F961D3503E8004B0C46 /* Renderer.cpp */; };\n\t\t818461C71D3503E8004B0C46 /* RenderFrame.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845F981D3503E8004B0C46 /* RenderFrame.cpp */; };\n\t\t818461C81D3503E8004B0C46 /* RenderFrameCompiler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845F9A1D3503E8004B0C46 /* RenderFrameCompiler.cpp */; };\n\t\t818461C91D3503E8004B0C46 /* RenderFrameData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845F9C1D3503E8004B0C46 /* RenderFrameData.cpp */; };\n\t\t818461CA1D3503E8004B0C46 /* RenderObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845F9F1D3503E8004B0C46 /* RenderObject.cpp */; };\n\t\t818461CB1D3503E8004B0C46 /* RenderPass.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845FA11D3503E8004B0C46 /* RenderPass.cpp */; };\n\t\t818461CC1D3503E8004B0C46 /* RenderPassObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845FA31D3503E8004B0C46 /* RenderPassObject.cpp */; };\n\t\t818461CD1D3503E8004B0C46 /* RenderPassObjectSorter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845FA51D3503E8004B0C46 /* RenderPassObjectSorter.cpp */; };\n\t\t818461CE1D3503E8004B0C46 /* RenderPassVisibilityChecker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845FA71D3503E8004B0C46 /* RenderPassVisibilityChecker.cpp */; };\n\t\t818461CF1D3503E8004B0C46 /* RenderSnapshot.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845FA91D3503E8004B0C46 /* RenderSnapshot.cpp */; };\n\t\t818461D01D3503E8004B0C46 /* SizePolicy.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845FAB1D3503E8004B0C46 /* SizePolicy.cpp */; };\n\t\t818461D11D3503E8004B0C46 /* TargetRenderPassGroup.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845FAE1D3503E8004B0C46 /* TargetRenderPassGroup.cpp */; };\n\t\t818461D21D3503E8004B0C46 /* VerticalTextJustification.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845FB01D3503E8004B0C46 /* VerticalTextJustification.cpp */; };\n\t\t818461D31D3503E8004B0C46 /* CameraComponent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845FB41D3503E8004B0C46 /* CameraComponent.cpp */; };\n\t\t818461D41D3503E8004B0C46 /* OrthographicCameraComponent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845FB61D3503E8004B0C46 /* OrthographicCameraComponent.cpp */; };\n\t\t818461D51D3503E8004B0C46 /* PerspectiveCameraComponent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845FB81D3503E8004B0C46 /* PerspectiveCameraComponent.cpp */; };\n\t\t818461D61D3503E8004B0C46 /* RenderCamera.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845FBA1D3503E8004B0C46 /* RenderCamera.cpp */; };\n\t\t818461D71D3503E8004B0C46 /* Font.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845FBE1D3503E8004B0C46 /* Font.cpp */; };\n\t\t818461D81D3503E8004B0C46 /* FontProvider.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845FC01D3503E8004B0C46 /* FontProvider.cpp */; };\n\t\t818461D91D3503E8004B0C46 /* AmbientLightComponent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845FC51D3503E8004B0C46 /* AmbientLightComponent.cpp */; };\n\t\t818461DA1D3503E8004B0C46 /* AmbientRenderLight.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845FC71D3503E8004B0C46 /* AmbientRenderLight.cpp */; };\n\t\t818461DB1D3503E8004B0C46 /* DirectionalLightComponent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845FC91D3503E8004B0C46 /* DirectionalLightComponent.cpp */; };\n\t\t818461DC1D3503E8004B0C46 /* DirectionalRenderLight.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845FCB1D3503E8004B0C46 /* DirectionalRenderLight.cpp */; };\n\t\t818461DD1D3503E8004B0C46 /* PointLightComponent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845FCD1D3503E8004B0C46 /* PointLightComponent.cpp */; };\n\t\t818461DE1D3503E8004B0C46 /* PointRenderLight.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845FCF1D3503E8004B0C46 /* PointRenderLight.cpp */; };\n\t\t818461DF1D3503E8004B0C46 /* ForwardRenderMaterialGroupManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845FD31D3503E8004B0C46 /* ForwardRenderMaterialGroupManager.cpp */; };\n\t\t818461E01D3503E8004B0C46 /* Material.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845FD51D3503E8004B0C46 /* Material.cpp */; };\n\t\t818461E11D3503E8004B0C46 /* MaterialFactory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845FD71D3503E8004B0C46 /* MaterialFactory.cpp */; };\n\t\t818461E21D3503E8004B0C46 /* MaterialProvider.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845FD91D3503E8004B0C46 /* MaterialProvider.cpp */; };\n\t\t818461E31D3503E8004B0C46 /* RenderMaterial.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845FDB1D3503E8004B0C46 /* RenderMaterial.cpp */; };\n\t\t818461E41D3503E8004B0C46 /* RenderMaterialGroup.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845FDD1D3503E8004B0C46 /* RenderMaterialGroup.cpp */; };\n\t\t818461E51D3503E8004B0C46 /* RenderMaterialGroupManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845FDF1D3503E8004B0C46 /* RenderMaterialGroupManager.cpp */; };\n\t\t818461E61D3503E8004B0C46 /* AnimatedModelComponent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845FE31D3503E8004B0C46 /* AnimatedModelComponent.cpp */; };\n\t\t818461E71D3503E8004B0C46 /* CSAnimProvider.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845FE51D3503E8004B0C46 /* CSAnimProvider.cpp */; };\n\t\t818461E81D3503E8004B0C46 /* CSModelProvider.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845FE71D3503E8004B0C46 /* CSModelProvider.cpp */; };\n\t\t818461E91D3503E8004B0C46 /* IndexFormat.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845FE91D3503E8004B0C46 /* IndexFormat.cpp */; };\n\t\t818461EA1D3503E8004B0C46 /* MeshDesc.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845FEB1D3503E8004B0C46 /* MeshDesc.cpp */; };\n\t\t818461EB1D3503E8004B0C46 /* Model.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845FED1D3503E8004B0C46 /* Model.cpp */; };\n\t\t818461EC1D3503E8004B0C46 /* ModelDesc.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845FEF1D3503E8004B0C46 /* ModelDesc.cpp */; };\n\t\t818461ED1D3503E8004B0C46 /* PrimitiveModelFactory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845FF21D3503E8004B0C46 /* PrimitiveModelFactory.cpp */; };\n\t\t818461EE1D3503E8004B0C46 /* RenderDynamicMesh.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845FF41D3503E8004B0C46 /* RenderDynamicMesh.cpp */; };\n\t\t818461EF1D3503E8004B0C46 /* RenderMesh.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845FF61D3503E8004B0C46 /* RenderMesh.cpp */; };\n\t\t818461F01D3503E8004B0C46 /* RenderMeshManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845FF81D3503E8004B0C46 /* RenderMeshManager.cpp */; };\n\t\t818461F11D3503E8004B0C46 /* RenderSkinnedAnimation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845FFA1D3503E8004B0C46 /* RenderSkinnedAnimation.cpp */; };\n\t\t818461F21D3503E8004B0C46 /* Skeleton.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845FFC1D3503E8004B0C46 /* Skeleton.cpp */; };\n\t\t818461F31D3503E8004B0C46 /* SkeletonDesc.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81845FFE1D3503E8004B0C46 /* SkeletonDesc.cpp */; };\n\t\t818461F41D3503E8004B0C46 /* SkinnedAnimation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 818460001D3503E8004B0C46 /* SkinnedAnimation.cpp */; };\n\t\t818461F51D3503E8004B0C46 /* SkinnedAnimationGroup.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 818460021D3503E8004B0C46 /* SkinnedAnimationGroup.cpp */; };\n\t\t818461F61D3503E8004B0C46 /* StaticModelComponent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 818460041D3503E8004B0C46 /* StaticModelComponent.cpp */; };\n\t\t818461F71D3503E8004B0C46 /* VertexFormat.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 818460061D3503E8004B0C46 /* VertexFormat.cpp */; };\n\t\t818461F81D3503E8004B0C46 /* AccelerationParticleAffector.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8184600B1D3503E8004B0C46 /* AccelerationParticleAffector.cpp */; };\n\t\t818461F91D3503E8004B0C46 /* AccelerationParticleAffectorDef.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8184600D1D3503E8004B0C46 /* AccelerationParticleAffectorDef.cpp */; };\n\t\t818461FA1D3503E8004B0C46 /* AngularAccelerationParticleAffector.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8184600F1D3503E8004B0C46 /* AngularAccelerationParticleAffector.cpp */; };\n\t\t818461FB1D3503E8004B0C46 /* AngularAccelerationParticleAffectorDef.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 818460111D3503E8004B0C46 /* AngularAccelerationParticleAffectorDef.cpp */; };\n\t\t818461FC1D3503E8004B0C46 /* ColourOverLifetimeParticleAffector.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 818460131D3503E8004B0C46 /* ColourOverLifetimeParticleAffector.cpp */; };\n\t\t818461FD1D3503E8004B0C46 /* ColourOverLifetimeParticleAffectorDef.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 818460151D3503E8004B0C46 /* ColourOverLifetimeParticleAffectorDef.cpp */; };\n\t\t818461FE1D3503E8004B0C46 /* ParticleAffector.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 818460171D3503E8004B0C46 /* ParticleAffector.cpp */; };\n\t\t818461FF1D3503E8004B0C46 /* ParticleAffectorDef.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 818460191D3503E8004B0C46 /* ParticleAffectorDef.cpp */; };\n\t\t818462001D3503E8004B0C46 /* ParticleAffectorDefFactory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8184601B1D3503E8004B0C46 /* ParticleAffectorDefFactory.cpp */; };\n\t\t818462011D3503E8004B0C46 /* ScaleOverLifetimeParticleAffector.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8184601D1D3503E8004B0C46 /* ScaleOverLifetimeParticleAffector.cpp */; };\n\t\t818462021D3503E8004B0C46 /* ScaleOverLifetimeParticleAffectorDef.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8184601F1D3503E8004B0C46 /* ScaleOverLifetimeParticleAffectorDef.cpp */; };\n\t\t818462031D3503E8004B0C46 /* ConcurrentParticleData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 818460211D3503E8004B0C46 /* ConcurrentParticleData.cpp */; };\n\t\t818462041D3503E8004B0C46 /* CSParticleProvider.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 818460231D3503E8004B0C46 /* CSParticleProvider.cpp */; };\n\t\t818462051D3503E8004B0C46 /* ParticleDrawable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 818460261D3503E8004B0C46 /* ParticleDrawable.cpp */; };\n\t\t818462061D3503E8004B0C46 /* ParticleDrawableDef.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 818460281D3503E8004B0C46 /* ParticleDrawableDef.cpp */; };\n\t\t818462071D3503E8004B0C46 /* ParticleDrawableDefFactory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8184602A1D3503E8004B0C46 /* ParticleDrawableDefFactory.cpp */; };\n\t\t818462081D3503E8004B0C46 /* StaticBillboardParticleDrawable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8184602C1D3503E8004B0C46 /* StaticBillboardParticleDrawable.cpp */; };\n\t\t818462091D3503E8004B0C46 /* StaticBillboardParticleDrawableDef.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8184602E1D3503E8004B0C46 /* StaticBillboardParticleDrawableDef.cpp */; };\n\t\t8184620A1D3503E8004B0C46 /* CircleParticleEmitter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 818460311D3503E8004B0C46 /* CircleParticleEmitter.cpp */; };\n\t\t8184620B1D3503E8004B0C46 /* CircleParticleEmitterDef.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 818460331D3503E8004B0C46 /* CircleParticleEmitterDef.cpp */; };\n\t\t8184620C1D3503E8004B0C46 /* Cone2DParticleEmitter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 818460351D3503E8004B0C46 /* Cone2DParticleEmitter.cpp */; };\n\t\t8184620D1D3503E8004B0C46 /* Cone2DParticleEmitterDef.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 818460371D3503E8004B0C46 /* Cone2DParticleEmitterDef.cpp */; };\n\t\t8184620E1D3503E8004B0C46 /* ConeParticleEmitter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 818460391D3503E8004B0C46 /* ConeParticleEmitter.cpp */; };\n\t\t8184620F1D3503E8004B0C46 /* ConeParticleEmitterDef.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8184603B1D3503E8004B0C46 /* ConeParticleEmitterDef.cpp */; };\n\t\t818462101D3503E8004B0C46 /* ParticleEmitter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8184603D1D3503E8004B0C46 /* ParticleEmitter.cpp */; };\n\t\t818462111D3503E8004B0C46 /* ParticleEmitterDef.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8184603F1D3503E8004B0C46 /* ParticleEmitterDef.cpp */; };\n\t\t818462121D3503E8004B0C46 /* ParticleEmitterDefFactory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 818460411D3503E8004B0C46 /* ParticleEmitterDefFactory.cpp */; };\n\t\t818462131D3503E8004B0C46 /* PointParticleEmitter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 818460431D3503E8004B0C46 /* PointParticleEmitter.cpp */; };\n\t\t818462141D3503E8004B0C46 /* PointParticleEmitterDef.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 818460451D3503E8004B0C46 /* PointParticleEmitterDef.cpp */; };\n\t\t818462151D3503E8004B0C46 /* SphereParticleEmitter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 818460471D3503E8004B0C46 /* SphereParticleEmitter.cpp */; };\n\t\t818462161D3503E8004B0C46 /* SphereParticleEmitterDef.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 818460491D3503E8004B0C46 /* SphereParticleEmitterDef.cpp */; };\n\t\t818462171D3503E8004B0C46 /* ParticleEffect.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8184604C1D3503E8004B0C46 /* ParticleEffect.cpp */; };\n\t\t818462181D3503E8004B0C46 /* ParticleEffectComponent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8184604E1D3503E8004B0C46 /* ParticleEffectComponent.cpp */; };\n\t\t818462191D3503E8004B0C46 /* ParticlePropertyFactoryImpl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 818460571D3503E8004B0C46 /* ParticlePropertyFactoryImpl.cpp */; };\n\t\t8184621A1D3503E8004B0C46 /* ApplyAmbientLightRenderCommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8184605E1D3503E8004B0C46 /* ApplyAmbientLightRenderCommand.cpp */; };\n\t\t8184621B1D3503E8004B0C46 /* ApplyCameraRenderCommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 818460601D3503E8004B0C46 /* ApplyCameraRenderCommand.cpp */; };\n\t\t8184621C1D3503E8004B0C46 /* ApplyDirectionalLightRenderCommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 818460621D3503E8004B0C46 /* ApplyDirectionalLightRenderCommand.cpp */; };\n\t\t8184621D1D3503E8004B0C46 /* ApplyDynamicMeshRenderCommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 818460641D3503E8004B0C46 /* ApplyDynamicMeshRenderCommand.cpp */; };\n\t\t8184621E1D3503E8004B0C46 /* ApplyMaterialRenderCommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 818460661D3503E8004B0C46 /* ApplyMaterialRenderCommand.cpp */; };\n\t\t8184621F1D3503E8004B0C46 /* ApplyMeshRenderCommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 818460681D3503E8004B0C46 /* ApplyMeshRenderCommand.cpp */; };\n\t\t818462201D3503E8004B0C46 /* ApplyPointLightRenderCommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8184606A1D3503E8004B0C46 /* ApplyPointLightRenderCommand.cpp */; };\n\t\t818462211D3503E8004B0C46 /* ApplySkinnedAnimationRenderCommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8184606C1D3503E8004B0C46 /* ApplySkinnedAnimationRenderCommand.cpp */; };\n\t\t818462221D3503E8004B0C46 /* BeginRenderCommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8184606E1D3503E8004B0C46 /* BeginRenderCommand.cpp */; };\n\t\t818462231D3503E8004B0C46 /* BeginWithTargetGroupRenderCommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 818460701D3503E8004B0C46 /* BeginWithTargetGroupRenderCommand.cpp */; };\n\t\t818462241D3503E8004B0C46 /* EndRenderCommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 818460721D3503E8004B0C46 /* EndRenderCommand.cpp */; };\n\t\t818462251D3503E8004B0C46 /* LoadMaterialGroupRenderCommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 818460741D3503E8004B0C46 /* LoadMaterialGroupRenderCommand.cpp */; };\n\t\t818462261D3503E8004B0C46 /* LoadMeshRenderCommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 818460761D3503E8004B0C46 /* LoadMeshRenderCommand.cpp */; };\n\t\t818462271D3503E8004B0C46 /* LoadShaderRenderCommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 818460781D3503E8004B0C46 /* LoadShaderRenderCommand.cpp */; };\n\t\t818462281D3503E8004B0C46 /* LoadTargetGroupRenderCommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8184607A1D3503E8004B0C46 /* LoadTargetGroupRenderCommand.cpp */; };\n\t\t818462291D3503E8004B0C46 /* LoadTextureRenderCommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8184607C1D3503E8004B0C46 /* LoadTextureRenderCommand.cpp */; };\n\t\t8184622A1D3503E8004B0C46 /* RenderInstanceRenderCommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8184607E1D3503E8004B0C46 /* RenderInstanceRenderCommand.cpp */; };\n\t\t8184622B1D3503E8004B0C46 /* RestoreMeshRenderCommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 818460801D3503E8004B0C46 /* RestoreMeshRenderCommand.cpp */; };\n\t\t8184622C1D3503E8004B0C46 /* RestoreTextureRenderCommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 818460821D3503E8004B0C46 /* RestoreTextureRenderCommand.cpp */; };\n\t\t8184622D1D3503E8004B0C46 /* UnloadMaterialGroupRenderCommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 818460841D3503E8004B0C46 /* UnloadMaterialGroupRenderCommand.cpp */; };\n\t\t8184622E1D3503E8004B0C46 /* UnloadMeshRenderCommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 818460861D3503E8004B0C46 /* UnloadMeshRenderCommand.cpp */; };\n\t\t8184622F1D3503E8004B0C46 /* UnloadShaderRenderCommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 818460881D3503E8004B0C46 /* UnloadShaderRenderCommand.cpp */; };\n\t\t818462301D3503E8004B0C46 /* UnloadTargetGroupRenderCommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8184608A1D3503E8004B0C46 /* UnloadTargetGroupRenderCommand.cpp */; };\n\t\t818462311D3503E8004B0C46 /* UnloadTextureRenderCommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8184608C1D3503E8004B0C46 /* UnloadTextureRenderCommand.cpp */; };\n\t\t818462321D3503E8004B0C46 /* RenderCommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8184608E1D3503E8004B0C46 /* RenderCommand.cpp */; };\n\t\t818462331D3503E8004B0C46 /* RenderCommandBuffer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 818460901D3503E8004B0C46 /* RenderCommandBuffer.cpp */; };\n\t\t818462341D3503E8004B0C46 /* RenderCommandList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 818460921D3503E8004B0C46 /* RenderCommandList.cpp */; };\n\t\t818462351D3503E8004B0C46 /* CSShaderProvider.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 818460961D3503E8004B0C46 /* CSShaderProvider.cpp */; };\n\t\t818462361D3503E8004B0C46 /* RenderShaderManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 818460991D3503E8004B0C46 /* RenderShaderManager.cpp */; };\n\t\t818462371D3503E8004B0C46 /* RenderShaderVariables.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8184609B1D3503E8004B0C46 /* RenderShaderVariables.cpp */; };\n\t\t818462381D3503E8004B0C46 /* Shader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8184609D1D3503E8004B0C46 /* Shader.cpp */; };\n\t\t818462391D3503E8004B0C46 /* SpriteComponent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 818460A11D3503E8004B0C46 /* SpriteComponent.cpp */; };\n\t\t8184623A1D3503E8004B0C46 /* SpriteMeshBuilder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 818460A31D3503E8004B0C46 /* SpriteMeshBuilder.cpp */; };\n\t\t8184623B1D3503E8004B0C46 /* RenderTargetGroup.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 818460A71D3503E8004B0C46 /* RenderTargetGroup.cpp */; };\n\t\t8184623C1D3503E8004B0C46 /* RenderTargetGroupManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 818460A91D3503E8004B0C46 /* RenderTargetGroupManager.cpp */; };\n\t\t818462401D3503E8004B0C46 /* RenderTexture.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 818460B31D3503E8004B0C46 /* RenderTexture.cpp */; };\n\t\t818462411D3503E8004B0C46 /* RenderTextureManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 818460B51D3503E8004B0C46 /* RenderTextureManager.cpp */; };\n\t\t818462421D3503E8004B0C46 /* Texture.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 818460B71D3503E8004B0C46 /* Texture.cpp */; };\n\t\t818462431D3503E8004B0C46 /* TextureAtlas.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 818460B91D3503E8004B0C46 /* TextureAtlas.cpp */; };\n\t\t818462441D3503E8004B0C46 /* TextureAtlasProvider.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 818460BB1D3503E8004B0C46 /* TextureAtlasProvider.cpp */; };\n\t\t818462451D3503E8004B0C46 /* TextureDesc.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 818460BD1D3503E8004B0C46 /* TextureDesc.cpp */; };\n\t\t818462461D3503E8004B0C46 /* TextureProvider.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 818460C01D3503E8004B0C46 /* TextureProvider.cpp */; };\n\t\t818462471D3503E8004B0C46 /* TextureResourceOptions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 818460C21D3503E8004B0C46 /* TextureResourceOptions.cpp */; };\n\t\t818462481D3503E8004B0C46 /* UVs.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 818460C51D3503E8004B0C46 /* UVs.cpp */; };\n\t\t818462491D3503E8004B0C46 /* EmailComposer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 818460CA1D3503E8004B0C46 /* EmailComposer.cpp */; };\n\t\t8184624C1D3503E8004B0C46 /* Canvas.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 818460D61D3503E8004B0C46 /* Canvas.cpp */; };\n\t\t8184624D1D3503E8004B0C46 /* PropertyLink.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 818460D81D3503E8004B0C46 /* PropertyLink.cpp */; };\n\t\t8184624E1D3503E8004B0C46 /* PropertyTypes.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 818460DA1D3503E8004B0C46 /* PropertyTypes.cpp */; };\n\t\t8184624F1D3503E8004B0C46 /* UIComponent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 818460DC1D3503E8004B0C46 /* UIComponent.cpp */; };\n\t\t818462501D3503E8004B0C46 /* UIComponentDesc.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 818460DE1D3503E8004B0C46 /* UIComponentDesc.cpp */; };\n\t\t818462511D3503E8004B0C46 /* UIComponentFactory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 818460E01D3503E8004B0C46 /* UIComponentFactory.cpp */; };\n\t\t818462521D3503E8004B0C46 /* Widget.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 818460E21D3503E8004B0C46 /* Widget.cpp */; };\n\t\t818462531D3503E8004B0C46 /* WidgetDef.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 818460E41D3503E8004B0C46 /* WidgetDef.cpp */; };\n\t\t818462541D3503E8004B0C46 /* WidgetDefProvider.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 818460E61D3503E8004B0C46 /* WidgetDefProvider.cpp */; };\n\t\t818462551D3503E8004B0C46 /* WidgetDesc.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 818460E81D3503E8004B0C46 /* WidgetDesc.cpp */; };\n\t\t818462561D3503E8004B0C46 /* WidgetFactory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 818460EA1D3503E8004B0C46 /* WidgetFactory.cpp */; };\n\t\t818462571D3503E8004B0C46 /* WidgetParserUtils.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 818460EC1D3503E8004B0C46 /* WidgetParserUtils.cpp */; };\n\t\t818462581D3503E8004B0C46 /* WidgetTemplate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 818460EE1D3503E8004B0C46 /* WidgetTemplate.cpp */; };\n\t\t818462591D3503E8004B0C46 /* WidgetTemplateProvider.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 818460F01D3503E8004B0C46 /* WidgetTemplateProvider.cpp */; };\n\t\t8184625A1D3503E8004B0C46 /* HighlightUIComponent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 818460F41D3503E8004B0C46 /* HighlightUIComponent.cpp */; };\n\t\t8184625B1D3503E8004B0C46 /* ToggleHighlightUIComponent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 818460F61D3503E8004B0C46 /* ToggleHighlightUIComponent.cpp */; };\n\t\t8184625C1D3503E8004B0C46 /* DrawableUIComponent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 818460FA1D3503E8004B0C46 /* DrawableUIComponent.cpp */; };\n\t\t8184625D1D3503E8004B0C46 /* NinePatchUIDrawable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 818460FC1D3503E8004B0C46 /* NinePatchUIDrawable.cpp */; };\n\t\t8184625E1D3503E8004B0C46 /* NinePatchUIDrawableDef.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 818460FE1D3503E8004B0C46 /* NinePatchUIDrawableDef.cpp */; };\n\t\t8184625F1D3503E8004B0C46 /* StandardUIDrawable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 818461001D3503E8004B0C46 /* StandardUIDrawable.cpp */; };\n\t\t818462601D3503E8004B0C46 /* StandardUIDrawableDef.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 818461021D3503E8004B0C46 /* StandardUIDrawableDef.cpp */; };\n\t\t818462611D3503E8004B0C46 /* ThreePatchUIDrawable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 818461041D3503E8004B0C46 /* ThreePatchUIDrawable.cpp */; };\n\t\t818462621D3503E8004B0C46 /* ThreePatchUIDrawableDef.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 818461061D3503E8004B0C46 /* ThreePatchUIDrawableDef.cpp */; };\n\t\t818462631D3503E8004B0C46 /* UIDrawable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 818461081D3503E8004B0C46 /* UIDrawable.cpp */; };\n\t\t818462641D3503E8004B0C46 /* UIDrawableDef.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8184610A1D3503E8004B0C46 /* UIDrawableDef.cpp */; };\n\t\t818462651D3503E8004B0C46 /* UIDrawableUtils.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8184610C1D3503E8004B0C46 /* UIDrawableUtils.cpp */; };\n\t\t818462661D3503E8004B0C46 /* GridUILayout.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 818461111D3503E8004B0C46 /* GridUILayout.cpp */; };\n\t\t818462671D3503E8004B0C46 /* GridUILayoutDef.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 818461131D3503E8004B0C46 /* GridUILayoutDef.cpp */; };\n\t\t818462681D3503E8004B0C46 /* HListUILayout.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 818461151D3503E8004B0C46 /* HListUILayout.cpp */; };\n\t\t818462691D3503E8004B0C46 /* HListUILayoutDef.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 818461171D3503E8004B0C46 /* HListUILayoutDef.cpp */; };\n\t\t8184626A1D3503E8004B0C46 /* LayoutUIComponent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8184611A1D3503E8004B0C46 /* LayoutUIComponent.cpp */; };\n\t\t8184626B1D3503E8004B0C46 /* UILayout.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8184611C1D3503E8004B0C46 /* UILayout.cpp */; };\n\t\t8184626C1D3503E8004B0C46 /* UILayoutDef.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8184611E1D3503E8004B0C46 /* UILayoutDef.cpp */; };\n\t\t8184626D1D3503E8004B0C46 /* VListUILayout.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 818461201D3503E8004B0C46 /* VListUILayout.cpp */; };\n\t\t8184626E1D3503E8004B0C46 /* VListUILayoutDef.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 818461221D3503E8004B0C46 /* VListUILayoutDef.cpp */; };\n\t\t8184626F1D3503E8004B0C46 /* ProgressBarDirection.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 818461261D3503E8004B0C46 /* ProgressBarDirection.cpp */; };\n\t\t818462701D3503E8004B0C46 /* ProgressBarType.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 818461281D3503E8004B0C46 /* ProgressBarType.cpp */; };\n\t\t818462711D3503E8004B0C46 /* ProgressBarUIComponent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8184612A1D3503E8004B0C46 /* ProgressBarUIComponent.cpp */; };\n\t\t818462721D3503E8004B0C46 /* SliderDirection.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8184612E1D3503E8004B0C46 /* SliderDirection.cpp */; };\n\t\t818462731D3503E8004B0C46 /* SliderUIComponent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 818461301D3503E8004B0C46 /* SliderUIComponent.cpp */; };\n\t\t818462741D3503E8004B0C46 /* EditableTextUIComponent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 818461341D3503E8004B0C46 /* EditableTextUIComponent.cpp */; };\n\t\t818462751D3503E8004B0C46 /* TextIcon.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 818461371D3503E8004B0C46 /* TextIcon.cpp */; };\n\t\t818462761D3503E8004B0C46 /* TextUIComponent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 818461391D3503E8004B0C46 /* TextUIComponent.cpp */; };\n\t\t818462771D3503E8004B0C46 /* CSSubtitlesProvider.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8184613E1D3503E8004B0C46 /* CSSubtitlesProvider.cpp */; };\n\t\t818462781D3503E8004B0C46 /* Subtitles.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 818461401D3503E8004B0C46 /* Subtitles.cpp */; };\n\t\t818462791D3503E8004B0C46 /* VideoPlayer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 818461421D3503E8004B0C46 /* VideoPlayer.cpp */; };\n\t\t8184627A1D3503E8004B0C46 /* WebView.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 818461481D3503E8004B0C46 /* WebView.cpp */; };\n\t\t8184627D1D350409004B0C46 /* GLSkinnedAnimation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8184627B1D350409004B0C46 /* GLSkinnedAnimation.cpp */; };\n\t\t818463691D353765004B0C46 /* SmallMeshBatcher.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 818463671D353765004B0C46 /* SmallMeshBatcher.cpp */; };\n\t\t8184636C1D35493A004B0C46 /* ApplyMeshBatchRenderCommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8184636A1D35493A004B0C46 /* ApplyMeshBatchRenderCommand.cpp */; };\n\t\t8184636F1D357706004B0C46 /* RenderMeshBatch.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8184636D1D357706004B0C46 /* RenderMeshBatch.cpp */; };\n\t\t8184CE901D0EFF9100E35BE8 /* RenderCommandProcessor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8184CE8E1D0EFF9100E35BE8 /* RenderCommandProcessor.cpp */; };\n\t\t818639751D2BE97C00FE085B /* GLDirectionalLight.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 818639731D2BE97C00FE085B /* GLDirectionalLight.cpp */; };\n\t\t8186397C1D2C195D00FE085B /* GLPointLight.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8186397A1D2C195D00FE085B /* GLPointLight.cpp */; };\n\t\t818C150B1D22F8F4001D639B /* GLDynamicMesh.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 818C15091D22F8F4001D639B /* GLDynamicMesh.cpp */; };\n\t\t818C150E1D22FB70001D639B /* GLMeshUtils.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 818C150C1D22FB70001D639B /* GLMeshUtils.cpp */; };\n\t\t81A5AF5F1D11575A00307707 /* GLShader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81A5AF5D1D11575A00307707 /* GLShader.cpp */; };\n\t\t81A5AF671D1190FB00307707 /* GLTexture.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81A5AF651D1190FB00307707 /* GLTexture.cpp */; };\n\t\t81A616B11D357133007F7CC1 /* TargetGroup.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81A616AF1D357133007F7CC1 /* TargetGroup.cpp */; };\n\t\t81A616B41D357159007F7CC1 /* RestoreRenderTargetGroupCommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81A616B21D357159007F7CC1 /* RestoreRenderTargetGroupCommand.cpp */; };\n\t\t81B096051D2AB8CA00E72835 /* GLContextRestorer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81B096031D2AB8CA00E72835 /* GLContextRestorer.cpp */; };\n\t\t81C7FF8C1C89DD0600D306F9 /* libCSBase.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 81C7FE821C89DD0500D306F9 /* libCSBase.a */; };\n\t\t81C7FFA41C89DD0600D306F9 /* libck.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 81C7FF621C89DD0600D306F9 /* libck.a */; };\n\t\t81C7FFC21C89DDE300D306F9 /* Accounts.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 81C7FFAA1C89DDE300D306F9 /* Accounts.framework */; };\n\t\t81C7FFC31C89DDE300D306F9 /* AddressBook.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 81C7FFAB1C89DDE300D306F9 /* AddressBook.framework */; };\n\t\t81C7FFC41C89DDE300D306F9 /* AddressBookUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 81C7FFAC1C89DDE300D306F9 /* AddressBookUI.framework */; };\n\t\t81C7FFC51C89DDE300D306F9 /* AdSupport.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 81C7FFAD1C89DDE300D306F9 /* AdSupport.framework */; };\n\t\t81C7FFC61C89DDE300D306F9 /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 81C7FFAE1C89DDE300D306F9 /* AudioToolbox.framework */; };\n\t\t81C7FFC71C89DDE300D306F9 /* CFNetwork.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 81C7FFAF1C89DDE300D306F9 /* CFNetwork.framework */; };\n\t\t81C7FFC81C89DDE300D306F9 /* CoreAudio.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 81C7FFB01C89DDE300D306F9 /* CoreAudio.framework */; };\n\t\t81C7FFC91C89DDE300D306F9 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 81C7FFB11C89DDE300D306F9 /* CoreGraphics.framework */; };\n\t\t81C7FFCA1C89DDE300D306F9 /* CoreLocation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 81C7FFB21C89DDE300D306F9 /* CoreLocation.framework */; };\n\t\t81C7FFCB1C89DDE300D306F9 /* CoreMotion.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 81C7FFB31C89DDE300D306F9 /* CoreMotion.framework */; };\n\t\t81C7FFCC1C89DDE300D306F9 /* CoreTelephony.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 81C7FFB41C89DDE300D306F9 /* CoreTelephony.framework */; };\n\t\t81C7FFCD1C89DDE300D306F9 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 81C7FFB51C89DDE300D306F9 /* Foundation.framework */; };\n\t\t81C7FFCE1C89DDE300D306F9 /* GLKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 81C7FFB61C89DDE300D306F9 /* GLKit.framework */; };\n\t\t81C7FFCF1C89DDE300D306F9 /* MapKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 81C7FFB71C89DDE300D306F9 /* MapKit.framework */; };\n\t\t81C7FFD01C89DDE300D306F9 /* MediaPlayer.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 81C7FFB81C89DDE300D306F9 /* MediaPlayer.framework */; };\n\t\t81C7FFD11C89DDE300D306F9 /* MessageUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 81C7FFB91C89DDE300D306F9 /* MessageUI.framework */; };\n\t\t81C7FFD21C89DDE300D306F9 /* MobileCoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 81C7FFBA1C89DDE300D306F9 /* MobileCoreServices.framework */; };\n\t\t81C7FFD31C89DDE300D306F9 /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 81C7FFBB1C89DDE300D306F9 /* OpenGLES.framework */; };\n\t\t81C7FFD41C89DDE300D306F9 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 81C7FFBC1C89DDE300D306F9 /* QuartzCore.framework */; };\n\t\t81C7FFD51C89DDE300D306F9 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 81C7FFBD1C89DDE300D306F9 /* Security.framework */; };\n\t\t81C7FFD61C89DDE300D306F9 /* Social.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 81C7FFBE1C89DDE300D306F9 /* Social.framework */; };\n\t\t81C7FFD71C89DDE300D306F9 /* StoreKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 81C7FFBF1C89DDE300D306F9 /* StoreKit.framework */; };\n\t\t81C7FFD81C89DDE300D306F9 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 81C7FFC01C89DDE300D306F9 /* SystemConfiguration.framework */; };\n\t\t81C7FFD91C89DDE300D306F9 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 81C7FFC11C89DDE300D306F9 /* UIKit.framework */; };\n\t\t81EB41181D48B3E9005A7CE9 /* CanvasDrawMode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81EB41171D48B3E9005A7CE9 /* CanvasDrawMode.cpp */; };\n/* End PBXBuildFile section */\n\n/* Begin PBXCopyFilesBuildPhase section */\n\t\t8158F1E81C89D27300B13109 /* CopyFiles */ = {\n\t\t\tisa = PBXCopyFilesBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tdstPath = \"include/$(PRODUCT_NAME)\";\n\t\t\tdstSubfolderSpec = 16;\n\t\t\tfiles = (\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n/* End PBXCopyFilesBuildPhase section */\n\n/* Begin PBXFileReference section */\n\t\t27408C041D366C7A00A0B003 /* DeviceInfo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DeviceInfo.cpp; sourceTree = \"<group>\"; };\n\t\t27408C051D366C7A00A0B003 /* DeviceInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DeviceInfo.h; sourceTree = \"<group>\"; };\n\t\t27408C061D366C7A00A0B003 /* SystemInfo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SystemInfo.cpp; sourceTree = \"<group>\"; };\n\t\t27408C071D366C7A00A0B003 /* SystemInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SystemInfo.h; sourceTree = \"<group>\"; };\n\t\t27408C1A1D369F8D00A0B003 /* SystemInfoFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SystemInfoFactory.h; sourceTree = \"<group>\"; };\n\t\t27408C1B1D369F8D00A0B003 /* SystemInfoFactory.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SystemInfoFactory.mm; sourceTree = \"<group>\"; };\n\t\t27408C271D36DCB600A0B003 /* ScreenInfo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScreenInfo.cpp; sourceTree = \"<group>\"; };\n\t\t27408C281D36DCB600A0B003 /* ScreenInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScreenInfo.h; sourceTree = \"<group>\"; };\n\t\t2787EA681E30D3B300E83458 /* Gyroscope.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Gyroscope.h; sourceTree = \"<group>\"; };\n\t\t2787EA691E30D3F800E83458 /* Gyroscope.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = Gyroscope.h; path = Gyroscope/Gyroscope.h; sourceTree = \"<group>\"; };\n\t\t2787EA6A1E30D4EC00E83458 /* Gyroscope.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Gyroscope.cpp; path = Gyroscope/Gyroscope.cpp; sourceTree = \"<group>\"; };\n\t\t2787EA6D1E30D59200E83458 /* Gyroscope.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = Gyroscope.mm; path = Gyroscope/Gyroscope.mm; sourceTree = \"<group>\"; };\n\t\t2787EA6F1E30D5A000E83458 /* Gyroscope.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = Gyroscope.h; path = Gyroscope/Gyroscope.h; sourceTree = \"<group>\"; };\n\t\t27B4258A1E6058A300E17750 /* HashSHA256.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HashSHA256.cpp; sourceTree = \"<group>\"; };\n\t\t27B4258B1E6058A300E17750 /* HashSHA256.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HashSHA256.h; sourceTree = \"<group>\"; };\n\t\t27B4258F1E60590A00E17750 /* sha256.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = sha256.h; path = SHA256/sha256.h; sourceTree = \"<group>\"; };\n\t\t810C0C821D11B01100C32406 /* GLMesh.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GLMesh.cpp; sourceTree = \"<group>\"; };\n\t\t810C0C831D11B01100C32406 /* GLMesh.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GLMesh.h; sourceTree = \"<group>\"; };\n\t\t813291FE1D704EA300CA7612 /* TargetType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TargetType.h; sourceTree = \"<group>\"; };\n\t\t813BA9D61D379F6D00A3B091 /* RenderInfo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderInfo.cpp; sourceTree = \"<group>\"; };\n\t\t813BA9D71D379F6D00A3B091 /* RenderInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderInfo.h; sourceTree = \"<group>\"; };\n\t\t813BA9D91D37BE0600A3B091 /* RenderInfoFactory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderInfoFactory.cpp; sourceTree = \"<group>\"; };\n\t\t813BA9DA1D37BE0600A3B091 /* RenderInfoFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderInfoFactory.h; sourceTree = \"<group>\"; };\n\t\t8140019F1E72D21F00388C2A /* GLExtensions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GLExtensions.cpp; sourceTree = \"<group>\"; };\n\t\t814001A11E72D32F00388C2A /* GLExtensions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GLExtensions.h; sourceTree = \"<group>\"; };\n\t\t815175771E3F4E5C0024361A /* SkyboxComponent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SkyboxComponent.cpp; sourceTree = \"<group>\"; };\n\t\t815175781E3F4E5C0024361A /* SkyboxComponent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SkyboxComponent.h; sourceTree = \"<group>\"; };\n\t\t815175791E3F4E5C0024361A /* Skybox.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Skybox.h; sourceTree = \"<group>\"; };\n\t\t81559AAB1E925F4C00A1B107 /* Gamepad.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Gamepad.cpp; sourceTree = \"<group>\"; };\n\t\t81559AAC1E925F4C00A1B107 /* Gamepad.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Gamepad.h; sourceTree = \"<group>\"; };\n\t\t81559AAD1E925F4C00A1B107 /* GamepadSystem.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GamepadSystem.cpp; sourceTree = \"<group>\"; };\n\t\t81559AAE1E925F4C00A1B107 /* GamepadSystem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GamepadSystem.h; sourceTree = \"<group>\"; };\n\t\t81559AB11E925F5600A1B107 /* Gamepad.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Gamepad.h; sourceTree = \"<group>\"; };\n\t\t81559ABA1E93BAFF00A1B107 /* GamepadAxis.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GamepadAxis.h; sourceTree = \"<group>\"; };\n\t\t81559ABB1E93DC6700A1B107 /* GamepadMappings.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GamepadMappings.h; sourceTree = \"<group>\"; };\n\t\t8155F30A1E785B7700750A05 /* CursorSystem.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CursorSystem.cpp; sourceTree = \"<group>\"; };\n\t\t8155F30B1E785B7700750A05 /* CursorSystem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CursorSystem.h; sourceTree = \"<group>\"; };\n\t\t8155F30D1E797B9300750A05 /* CursorType.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CursorType.h; sourceTree = \"<group>\"; };\n\t\t815612491D2E5D41000DD01B /* GLTargetGroup.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GLTargetGroup.cpp; sourceTree = \"<group>\"; };\n\t\t8156124A1D2E5D41000DD01B /* GLTargetGroup.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GLTargetGroup.h; sourceTree = \"<group>\"; };\n\t\t8158F1EA1C89D27300B13109 /* libChilliSource.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libChilliSource.a; sourceTree = BUILT_PRODUCTS_DIR; };\n\t\t8158F59B1C89D2AD00B13109 /* CSAppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSAppDelegate.h; sourceTree = \"<group>\"; };\n\t\t8158F59C1C89D2AD00B13109 /* CSAppDelegate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CSAppDelegate.mm; sourceTree = \"<group>\"; };\n\t\t8158F59D1C89D2AD00B13109 /* CSGLViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSGLViewController.h; sourceTree = \"<group>\"; };\n\t\t8158F59E1C89D2AD00B13109 /* CSGLViewController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CSGLViewController.mm; sourceTree = \"<group>\"; };\n\t\t8158F5A11C89D2AD00B13109 /* PlatformSystem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlatformSystem.h; sourceTree = \"<group>\"; };\n\t\t8158F5A21C89D2AD00B13109 /* PlatformSystem.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PlatformSystem.mm; sourceTree = \"<group>\"; };\n\t\t8158F5A31C89D2AD00B13109 /* Screen.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Screen.h; sourceTree = \"<group>\"; };\n\t\t8158F5A41C89D2AD00B13109 /* Screen.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = Screen.mm; sourceTree = \"<group>\"; };\n\t\t8158F5A61C89D2AD00B13109 /* DialogueBoxListener.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DialogueBoxListener.h; sourceTree = \"<group>\"; };\n\t\t8158F5A71C89D2AD00B13109 /* DialogueBoxListener.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DialogueBoxListener.mm; sourceTree = \"<group>\"; };\n\t\t8158F5A81C89D2AD00B13109 /* DialogueBoxSystem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DialogueBoxSystem.h; sourceTree = \"<group>\"; };\n\t\t8158F5A91C89D2AD00B13109 /* DialogueBoxSystem.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DialogueBoxSystem.mm; sourceTree = \"<group>\"; };\n\t\t8158F5AB1C89D2AD00B13109 /* FileSystem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FileSystem.h; sourceTree = \"<group>\"; };\n\t\t8158F5AC1C89D2AD00B13109 /* FileSystem.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = FileSystem.mm; sourceTree = \"<group>\"; };\n\t\t8158F5AE1C89D2AD00B13109 /* PNGImageProvider.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PNGImageProvider.cpp; sourceTree = \"<group>\"; };\n\t\t8158F5AF1C89D2AD00B13109 /* PNGImageProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PNGImageProvider.h; sourceTree = \"<group>\"; };\n\t\t8158F5B11C89D2AD00B13109 /* RNGContainer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNGContainer.h; sourceTree = \"<group>\"; };\n\t\t8158F5B21C89D2AD00B13109 /* RNGContainer.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RNGContainer.mm; sourceTree = \"<group>\"; };\n\t\t8158F5B41C89D2AD00B13109 /* LocalNotificationSystem.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LocalNotificationSystem.cpp; sourceTree = \"<group>\"; };\n\t\t8158F5B51C89D2AD00B13109 /* LocalNotificationSystem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LocalNotificationSystem.h; sourceTree = \"<group>\"; };\n\t\t8158F5B61C89D2AD00B13109 /* NSNotificationAdapter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NSNotificationAdapter.h; sourceTree = \"<group>\"; };\n\t\t8158F5B71C89D2AD00B13109 /* NSNotificationAdapter.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = NSNotificationAdapter.mm; sourceTree = \"<group>\"; };\n\t\t8158F5B81C89D2AD00B13109 /* RemoteNotificationSystem.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RemoteNotificationSystem.cpp; sourceTree = \"<group>\"; };\n\t\t8158F5B91C89D2AD00B13109 /* RemoteNotificationSystem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RemoteNotificationSystem.h; sourceTree = \"<group>\"; };\n\t\t8158F5BB1C89D2AD00B13109 /* NSStringUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NSStringUtils.h; sourceTree = \"<group>\"; };\n\t\t8158F5BC1C89D2AD00B13109 /* NSStringUtils.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = NSStringUtils.mm; sourceTree = \"<group>\"; };\n\t\t8158F5BD1C89D2AD00B13109 /* ForwardDeclarations.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ForwardDeclarations.h; sourceTree = \"<group>\"; };\n\t\t8158F5C01C89D2AD00B13109 /* Accelerometer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Accelerometer.h; sourceTree = \"<group>\"; };\n\t\t8158F5C11C89D2AD00B13109 /* Accelerometer.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = Accelerometer.mm; sourceTree = \"<group>\"; };\n\t\t8158F5C31C89D2AD00B13109 /* DeviceButtonSystem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DeviceButtonSystem.h; sourceTree = \"<group>\"; };\n\t\t8158F5C41C89D2AD00B13109 /* DeviceButtonSystem.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DeviceButtonSystem.mm; sourceTree = \"<group>\"; };\n\t\t8158F5C61C89D2AD00B13109 /* PointerSystem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PointerSystem.h; sourceTree = \"<group>\"; };\n\t\t8158F5C71C89D2AD00B13109 /* PointerSystem.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PointerSystem.mm; sourceTree = \"<group>\"; };\n\t\t8158F5C91C89D2AD00B13109 /* TextEntry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextEntry.h; sourceTree = \"<group>\"; };\n\t\t8158F5CA1C89D2AD00B13109 /* TextEntry.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = TextEntry.mm; sourceTree = \"<group>\"; };\n\t\t8158F5CB1C89D2AD00B13109 /* TextEntryDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextEntryDelegate.h; sourceTree = \"<group>\"; };\n\t\t8158F5CC1C89D2AD00B13109 /* TextEntryDelegate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = TextEntryDelegate.mm; sourceTree = \"<group>\"; };\n\t\t8158F5CD1C89D2AD00B13109 /* Main.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Main.cpp; sourceTree = \"<group>\"; };\n\t\t8158F5D01C89D2AD00B13109 /* HttpDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HttpDelegate.h; sourceTree = \"<group>\"; };\n\t\t8158F5D11C89D2AD00B13109 /* HttpDelegate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = HttpDelegate.mm; sourceTree = \"<group>\"; };\n\t\t8158F5D21C89D2AD00B13109 /* HttpRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HttpRequest.h; sourceTree = \"<group>\"; };\n\t\t8158F5D31C89D2AD00B13109 /* HttpRequest.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = HttpRequest.mm; sourceTree = \"<group>\"; };\n\t\t8158F5D41C89D2AD00B13109 /* HttpRequestSystem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HttpRequestSystem.h; sourceTree = \"<group>\"; };\n\t\t8158F5D51C89D2AD00B13109 /* HttpRequestSystem.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = HttpRequestSystem.mm; sourceTree = \"<group>\"; };\n\t\t8158F5D71C89D2AD00B13109 /* IAPSystem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IAPSystem.h; sourceTree = \"<group>\"; };\n\t\t8158F5D81C89D2AD00B13109 /* IAPSystem.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = IAPSystem.mm; sourceTree = \"<group>\"; };\n\t\t8158F5D91C89D2AD00B13109 /* StoreKitIAPSystem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StoreKitIAPSystem.h; sourceTree = \"<group>\"; };\n\t\t8158F5DA1C89D2AD00B13109 /* StoreKitIAPSystem.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = StoreKitIAPSystem.mm; sourceTree = \"<group>\"; };\n\t\t8158F5DD1C89D2AD00B13109 /* EmailComposer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EmailComposer.h; sourceTree = \"<group>\"; };\n\t\t8158F5DE1C89D2AD00B13109 /* EmailComposer.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = EmailComposer.mm; sourceTree = \"<group>\"; };\n\t\t8158F5DF1C89D2AD00B13109 /* EmailComposerDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EmailComposerDelegate.h; sourceTree = \"<group>\"; };\n\t\t8158F5E01C89D2AD00B13109 /* EmailComposerDelegate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = EmailComposerDelegate.mm; sourceTree = \"<group>\"; };\n\t\t8158F5ED1C89D2AD00B13109 /* SubtitlesRenderer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SubtitlesRenderer.h; sourceTree = \"<group>\"; };\n\t\t8158F5EE1C89D2AD00B13109 /* SubtitlesRenderer.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SubtitlesRenderer.mm; sourceTree = \"<group>\"; };\n\t\t8158F5EF1C89D2AD00B13109 /* VideoOverlayView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VideoOverlayView.h; sourceTree = \"<group>\"; };\n\t\t8158F5F01C89D2AD00B13109 /* VideoOverlayView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = VideoOverlayView.mm; sourceTree = \"<group>\"; };\n\t\t8158F5F11C89D2AD00B13109 /* VideoPlayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VideoPlayer.h; sourceTree = \"<group>\"; };\n\t\t8158F5F21C89D2AD00B13109 /* VideoPlayer.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = VideoPlayer.mm; sourceTree = \"<group>\"; };\n\t\t8158F5F31C89D2AD00B13109 /* VideoPlayerTapListener.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VideoPlayerTapListener.h; sourceTree = \"<group>\"; };\n\t\t8158F5F41C89D2AD00B13109 /* VideoPlayerTapListener.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = VideoPlayerTapListener.mm; sourceTree = \"<group>\"; };\n\t\t8158F5F71C89D2AD00B13109 /* WebView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebView.h; sourceTree = \"<group>\"; };\n\t\t8158F5F81C89D2AD00B13109 /* WebView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebView.mm; sourceTree = \"<group>\"; };\n\t\t8158F5F91C89D2AD00B13109 /* WebViewDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebViewDelegate.h; sourceTree = \"<group>\"; };\n\t\t8158F5FA1C89D2AD00B13109 /* WebViewDelegate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebViewDelegate.mm; sourceTree = \"<group>\"; };\n\t\t8158F6321C89D2AD00B13109 /* GLError.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GLError.cpp; sourceTree = \"<group>\"; };\n\t\t8158F6331C89D2AD00B13109 /* GLError.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GLError.h; sourceTree = \"<group>\"; };\n\t\t8158F6341C89D2AD00B13109 /* GLIncludes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GLIncludes.h; sourceTree = \"<group>\"; };\n\t\t8158F63D1C89D2AD00B13109 /* ForwardDeclarations.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ForwardDeclarations.h; sourceTree = \"<group>\"; };\n\t\t816D4B141E5B012300CA66A1 /* ObjectPoolAllocator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ObjectPoolAllocator.h; sourceTree = \"<group>\"; };\n\t\t816D4B211E5DCDB300CA66A1 /* attenuationmode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = attenuationmode.h; sourceTree = \"<group>\"; };\n\t\t816D4B221E5DCDB300CA66A1 /* bank.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = bank.h; sourceTree = \"<group>\"; };\n\t\t816D4B231E5DCDB300CA66A1 /* ck.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ck.h; sourceTree = \"<group>\"; };\n\t\t816D4B241E5DCDB300CA66A1 /* config.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = config.h; sourceTree = \"<group>\"; };\n\t\t816D4B251E5DCDB300CA66A1 /* effect.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = effect.h; sourceTree = \"<group>\"; };\n\t\t816D4B261E5DCDB300CA66A1 /* effectbus.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = effectbus.h; sourceTree = \"<group>\"; };\n\t\t816D4B271E5DCDB300CA66A1 /* effectparam.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = effectparam.h; sourceTree = \"<group>\"; };\n\t\t816D4B281E5DCDB300CA66A1 /* effecttype.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = effecttype.h; sourceTree = \"<group>\"; };\n\t\t816D4B291E5DCDB300CA66A1 /* mixer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mixer.h; sourceTree = \"<group>\"; };\n\t\t816D4B2A1E5DCDB300CA66A1 /* pathtype.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pathtype.h; sourceTree = \"<group>\"; };\n\t\t816D4B2B1E5DCDB300CA66A1 /* platform.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = platform.h; sourceTree = \"<group>\"; };\n\t\t816D4B2C1E5DCDB300CA66A1 /* sound.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sound.h; sourceTree = \"<group>\"; };\n\t\t817255FA1E084F3400A65625 /* MaterialShadingType.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MaterialShadingType.h; sourceTree = \"<group>\"; };\n\t\t817255FB1E0A91FB00A65625 /* GLCubemap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GLCubemap.cpp; sourceTree = \"<group>\"; };\n\t\t817255FC1E0A91FB00A65625 /* GLCubemap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GLCubemap.h; sourceTree = \"<group>\"; };\n\t\t817255FE1E0A958500A65625 /* GLTextureUtils.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GLTextureUtils.cpp; sourceTree = \"<group>\"; };\n\t\t817255FF1E0A958500A65625 /* GLTextureUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GLTextureUtils.h; sourceTree = \"<group>\"; };\n\t\t817256011E0A9F2600A65625 /* LoadCubemapRenderCommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LoadCubemapRenderCommand.cpp; sourceTree = \"<group>\"; };\n\t\t817256021E0A9F2600A65625 /* LoadCubemapRenderCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LoadCubemapRenderCommand.h; sourceTree = \"<group>\"; };\n\t\t817256031E0A9F2600A65625 /* RestoreCubemapRenderCommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RestoreCubemapRenderCommand.cpp; sourceTree = \"<group>\"; };\n\t\t817256041E0A9F2600A65625 /* RestoreCubemapRenderCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RestoreCubemapRenderCommand.h; sourceTree = \"<group>\"; };\n\t\t817256051E0A9F2600A65625 /* UnloadCubemapRenderCommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UnloadCubemapRenderCommand.cpp; sourceTree = \"<group>\"; };\n\t\t817256061E0A9F2600A65625 /* UnloadCubemapRenderCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UnloadCubemapRenderCommand.h; sourceTree = \"<group>\"; };\n\t\t8172560A1E0ABBB000A65625 /* TextureType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextureType.h; sourceTree = \"<group>\"; };\n\t\t8172560B1E0ABE1500A65625 /* Cubemap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Cubemap.cpp; sourceTree = \"<group>\"; };\n\t\t8172560C1E0ABE1500A65625 /* Cubemap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Cubemap.h; sourceTree = \"<group>\"; };\n\t\t8172560E1E0AC08100A65625 /* CubemapProvider.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CubemapProvider.cpp; sourceTree = \"<group>\"; };\n\t\t8172560F1E0AC08100A65625 /* CubemapProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CubemapProvider.h; sourceTree = \"<group>\"; };\n\t\t817256111E0AEF1F00A65625 /* CubemapResourceOptions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CubemapResourceOptions.cpp; sourceTree = \"<group>\"; };\n\t\t817256121E0AEF1F00A65625 /* CubemapResourceOptions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CubemapResourceOptions.h; sourceTree = \"<group>\"; };\n\t\t81729FA21D1BE681005B8CC9 /* GLMaterial.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GLMaterial.cpp; sourceTree = \"<group>\"; };\n\t\t81729FA31D1BE681005B8CC9 /* GLMaterial.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GLMaterial.h; sourceTree = \"<group>\"; };\n\t\t81729FA61D1BE92B005B8CC9 /* GLCamera.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GLCamera.cpp; sourceTree = \"<group>\"; };\n\t\t81729FA71D1BE92B005B8CC9 /* GLCamera.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GLCamera.h; sourceTree = \"<group>\"; };\n\t\t81729FA91D1BFF05005B8CC9 /* GLTextureUnitManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GLTextureUnitManager.cpp; sourceTree = \"<group>\"; };\n\t\t81729FAA1D1BFF05005B8CC9 /* GLTextureUnitManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GLTextureUnitManager.h; sourceTree = \"<group>\"; };\n\t\t817B8F891D2AE21300273F4B /* GLAmbientLight.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GLAmbientLight.cpp; sourceTree = \"<group>\"; };\n\t\t817B8F8A1D2AE21300273F4B /* GLAmbientLight.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GLAmbientLight.h; sourceTree = \"<group>\"; };\n\t\t817B8F8C1D2AE21300273F4B /* GLLight.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GLLight.h; sourceTree = \"<group>\"; };\n\t\t81845E0B1D3503E8004B0C46 /* CkAudioPlayer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CkAudioPlayer.cpp; sourceTree = \"<group>\"; };\n\t\t81845E0C1D3503E8004B0C46 /* CkAudioPlayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CkAudioPlayer.h; sourceTree = \"<group>\"; };\n\t\t81845E0D1D3503E8004B0C46 /* CkBank.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CkBank.cpp; sourceTree = \"<group>\"; };\n\t\t81845E0E1D3503E8004B0C46 /* CkBank.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CkBank.h; sourceTree = \"<group>\"; };\n\t\t81845E0F1D3503E8004B0C46 /* CkBankProvider.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CkBankProvider.cpp; sourceTree = \"<group>\"; };\n\t\t81845E101D3503E8004B0C46 /* CkBankProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CkBankProvider.h; sourceTree = \"<group>\"; };\n\t\t81845E111D3503E8004B0C46 /* CkForwardDeclarations.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CkForwardDeclarations.h; sourceTree = \"<group>\"; };\n\t\t81845E121D3503E8004B0C46 /* CkSound.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CkSound.cpp; sourceTree = \"<group>\"; };\n\t\t81845E131D3503E8004B0C46 /* CkSound.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CkSound.h; sourceTree = \"<group>\"; };\n\t\t81845E141D3503E8004B0C46 /* CricketAudioSystem.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CricketAudioSystem.cpp; sourceTree = \"<group>\"; };\n\t\t81845E151D3503E8004B0C46 /* CricketAudioSystem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CricketAudioSystem.h; sourceTree = \"<group>\"; };\n\t\t81845E161D3503E8004B0C46 /* CricketAudio.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CricketAudio.h; sourceTree = \"<group>\"; };\n\t\t81845E171D3503E8004B0C46 /* ForwardDeclarations.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ForwardDeclarations.h; sourceTree = \"<group>\"; };\n\t\t81845E181D3503E8004B0C46 /* ChilliSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ChilliSource.h; sourceTree = \"<group>\"; };\n\t\t81845E1B1D3503E8004B0C46 /* AppConfig.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AppConfig.cpp; sourceTree = \"<group>\"; };\n\t\t81845E1C1D3503E8004B0C46 /* AppConfig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppConfig.h; sourceTree = \"<group>\"; };\n\t\t81845E1D1D3503E8004B0C46 /* Application.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Application.cpp; sourceTree = \"<group>\"; };\n\t\t81845E1E1D3503E8004B0C46 /* Application.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Application.h; sourceTree = \"<group>\"; };\n\t\t81845E1F1D3503E8004B0C46 /* ByteBuffer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ByteBuffer.cpp; sourceTree = \"<group>\"; };\n\t\t81845E201D3503E8004B0C46 /* ByteBuffer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ByteBuffer.h; sourceTree = \"<group>\"; };\n\t\t81845E211D3503E8004B0C46 /* ByteColour.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ByteColour.cpp; sourceTree = \"<group>\"; };\n\t\t81845E221D3503E8004B0C46 /* ByteColour.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ByteColour.h; sourceTree = \"<group>\"; };\n\t\t81845E231D3503E8004B0C46 /* Colour.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Colour.cpp; sourceTree = \"<group>\"; };\n\t\t81845E241D3503E8004B0C46 /* Colour.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Colour.h; sourceTree = \"<group>\"; };\n\t\t81845E251D3503E8004B0C46 /* ColourUtils.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ColourUtils.cpp; sourceTree = \"<group>\"; };\n\t\t81845E261D3503E8004B0C46 /* ColourUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ColourUtils.h; sourceTree = \"<group>\"; };\n\t\t81845E271D3503E8004B0C46 /* ConstMethodCast.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ConstMethodCast.h; sourceTree = \"<group>\"; };\n\t\t81845E281D3503E8004B0C46 /* Device.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Device.cpp; sourceTree = \"<group>\"; };\n\t\t81845E291D3503E8004B0C46 /* Device.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Device.h; sourceTree = \"<group>\"; };\n\t\t81845E2A1D3503E8004B0C46 /* GenericFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GenericFactory.h; sourceTree = \"<group>\"; };\n\t\t81845E2B1D3503E8004B0C46 /* LifecycleManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LifecycleManager.cpp; sourceTree = \"<group>\"; };\n\t\t81845E2C1D3503E8004B0C46 /* LifecycleManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LifecycleManager.h; sourceTree = \"<group>\"; };\n\t\t81845E2D1D3503E8004B0C46 /* Logging.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Logging.cpp; sourceTree = \"<group>\"; };\n\t\t81845E2E1D3503E8004B0C46 /* Logging.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Logging.h; sourceTree = \"<group>\"; };\n\t\t81845E2F1D3503E8004B0C46 /* MakeSharedArray.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MakeSharedArray.h; sourceTree = \"<group>\"; };\n\t\t81845E301D3503E8004B0C46 /* PlatformSystem.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PlatformSystem.cpp; sourceTree = \"<group>\"; };\n\t\t81845E311D3503E8004B0C46 /* PlatformSystem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlatformSystem.h; sourceTree = \"<group>\"; };\n\t\t81845E321D3503E8004B0C46 /* QueryableInterface.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QueryableInterface.h; sourceTree = \"<group>\"; };\n\t\t81845E331D3503E8004B0C46 /* Screen.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Screen.cpp; sourceTree = \"<group>\"; };\n\t\t81845E341D3503E8004B0C46 /* Screen.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Screen.h; sourceTree = \"<group>\"; };\n\t\t81845E351D3503E8004B0C46 /* Singleton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Singleton.h; sourceTree = \"<group>\"; };\n\t\t81845E361D3503E8004B0C46 /* StandardMacros.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StandardMacros.h; sourceTree = \"<group>\"; };\n\t\t81845E371D3503E8004B0C46 /* Utils.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Utils.cpp; sourceTree = \"<group>\"; };\n\t\t81845E381D3503E8004B0C46 /* Utils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Utils.h; sourceTree = \"<group>\"; };\n\t\t81845E391D3503E8004B0C46 /* Base.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Base.h; sourceTree = \"<group>\"; };\n\t\t81845E3B1D3503E8004B0C46 /* concurrent_blocking_queue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = concurrent_blocking_queue.h; sourceTree = \"<group>\"; };\n\t\t81845E3C1D3503E8004B0C46 /* concurrent_vector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = concurrent_vector.h; sourceTree = \"<group>\"; };\n\t\t81845E3D1D3503E8004B0C46 /* concurrent_vector_const_forward_iterator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = concurrent_vector_const_forward_iterator.h; sourceTree = \"<group>\"; };\n\t\t81845E3E1D3503E8004B0C46 /* concurrent_vector_const_reverse_iterator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = concurrent_vector_const_reverse_iterator.h; sourceTree = \"<group>\"; };\n\t\t81845E3F1D3503E8004B0C46 /* concurrent_vector_forward_iterator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = concurrent_vector_forward_iterator.h; sourceTree = \"<group>\"; };\n\t\t81845E401D3503E8004B0C46 /* concurrent_vector_reverse_iterator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = concurrent_vector_reverse_iterator.h; sourceTree = \"<group>\"; };\n\t\t81845E411D3503E8004B0C46 /* dynamic_array.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = dynamic_array.h; sourceTree = \"<group>\"; };\n\t\t81845E421D3503E8004B0C46 /* HashedArray.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HashedArray.h; sourceTree = \"<group>\"; };\n\t\t81845E431D3503E8004B0C46 /* ParamDictionary.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ParamDictionary.cpp; sourceTree = \"<group>\"; };\n\t\t81845E441D3503E8004B0C46 /* ParamDictionary.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ParamDictionary.h; sourceTree = \"<group>\"; };\n\t\t81845E451D3503E8004B0C46 /* ParamDictionarySerialiser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ParamDictionarySerialiser.cpp; sourceTree = \"<group>\"; };\n\t\t81845E461D3503E8004B0C46 /* ParamDictionarySerialiser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ParamDictionarySerialiser.h; sourceTree = \"<group>\"; };\n\t\t81845E481D3503E8004B0C46 /* IProperty.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IProperty.h; sourceTree = \"<group>\"; };\n\t\t81845E491D3503E8004B0C46 /* IPropertyType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IPropertyType.h; sourceTree = \"<group>\"; };\n\t\t81845E4A1D3503E8004B0C46 /* Property.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Property.h; sourceTree = \"<group>\"; };\n\t\t81845E4B1D3503E8004B0C46 /* PropertyMap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PropertyMap.cpp; sourceTree = \"<group>\"; };\n\t\t81845E4C1D3503E8004B0C46 /* PropertyMap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PropertyMap.h; sourceTree = \"<group>\"; };\n\t\t81845E4D1D3503E8004B0C46 /* PropertyType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PropertyType.h; sourceTree = \"<group>\"; };\n\t\t81845E4E1D3503E8004B0C46 /* PropertyTypes.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PropertyTypes.cpp; sourceTree = \"<group>\"; };\n\t\t81845E4F1D3503E8004B0C46 /* PropertyTypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PropertyTypes.h; sourceTree = \"<group>\"; };\n\t\t81845E501D3503E8004B0C46 /* ReferenceProperty.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ReferenceProperty.h; sourceTree = \"<group>\"; };\n\t\t81845E511D3503E8004B0C46 /* ValueProperty.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ValueProperty.h; sourceTree = \"<group>\"; };\n\t\t81845E521D3503E8004B0C46 /* random_access_iterator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = random_access_iterator.h; sourceTree = \"<group>\"; };\n\t\t81845E531D3503E8004B0C46 /* VectorUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VectorUtils.h; sourceTree = \"<group>\"; };\n\t\t81845E541D3503E8004B0C46 /* Container.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Container.h; sourceTree = \"<group>\"; };\n\t\t81845E561D3503E8004B0C46 /* AESEncrypt.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AESEncrypt.cpp; sourceTree = \"<group>\"; };\n\t\t81845E571D3503E8004B0C46 /* AESEncrypt.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AESEncrypt.h; sourceTree = \"<group>\"; };\n\t\t81845E581D3503E8004B0C46 /* BaseEncoding.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BaseEncoding.cpp; sourceTree = \"<group>\"; };\n\t\t81845E591D3503E8004B0C46 /* BaseEncoding.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BaseEncoding.h; sourceTree = \"<group>\"; };\n\t\t81845E5A1D3503E8004B0C46 /* HashCRC32.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HashCRC32.cpp; sourceTree = \"<group>\"; };\n\t\t81845E5B1D3503E8004B0C46 /* HashCRC32.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HashCRC32.h; sourceTree = \"<group>\"; };\n\t\t81845E5C1D3503E8004B0C46 /* HashMD5.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HashMD5.cpp; sourceTree = \"<group>\"; };\n\t\t81845E5D1D3503E8004B0C46 /* HashMD5.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HashMD5.h; sourceTree = \"<group>\"; };\n\t\t81845E5E1D3503E8004B0C46 /* HashSHA1.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HashSHA1.cpp; sourceTree = \"<group>\"; };\n\t\t81845E5F1D3503E8004B0C46 /* HashSHA1.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HashSHA1.h; sourceTree = \"<group>\"; };\n\t\t81845E601D3503E8004B0C46 /* OAuth.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OAuth.cpp; sourceTree = \"<group>\"; };\n\t\t81845E611D3503E8004B0C46 /* OAuth.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OAuth.h; sourceTree = \"<group>\"; };\n\t\t81845E621D3503E8004B0C46 /* Cryptographic.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Cryptographic.h; sourceTree = \"<group>\"; };\n\t\t81845E641D3503E8004B0C46 /* ConnectableDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ConnectableDelegate.h; sourceTree = \"<group>\"; };\n\t\t81845E651D3503E8004B0C46 /* DelegateConnection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DelegateConnection.h; sourceTree = \"<group>\"; };\n\t\t81845E661D3503E8004B0C46 /* MakeConnectableDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MakeConnectableDelegate.h; sourceTree = \"<group>\"; };\n\t\t81845E671D3503E8004B0C46 /* MakeDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MakeDelegate.h; sourceTree = \"<group>\"; };\n\t\t81845E681D3503E8004B0C46 /* Delegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Delegate.h; sourceTree = \"<group>\"; };\n\t\t81845E6A1D3503E8004B0C46 /* DialogueBoxSystem.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DialogueBoxSystem.cpp; sourceTree = \"<group>\"; };\n\t\t81845E6B1D3503E8004B0C46 /* DialogueBoxSystem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DialogueBoxSystem.h; sourceTree = \"<group>\"; };\n\t\t81845E6C1D3503E8004B0C46 /* DialogueBox.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DialogueBox.h; sourceTree = \"<group>\"; };\n\t\t81845E6E1D3503E8004B0C46 /* Component.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Component.cpp; sourceTree = \"<group>\"; };\n\t\t81845E6F1D3503E8004B0C46 /* Component.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Component.h; sourceTree = \"<group>\"; };\n\t\t81845E701D3503E8004B0C46 /* Entity.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Entity.cpp; sourceTree = \"<group>\"; };\n\t\t81845E711D3503E8004B0C46 /* Entity.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Entity.h; sourceTree = \"<group>\"; };\n\t\t81845E721D3503E8004B0C46 /* PrimitiveEntityFactory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PrimitiveEntityFactory.cpp; sourceTree = \"<group>\"; };\n\t\t81845E731D3503E8004B0C46 /* PrimitiveEntityFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PrimitiveEntityFactory.h; sourceTree = \"<group>\"; };\n\t\t81845E741D3503E8004B0C46 /* Transform.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Transform.cpp; sourceTree = \"<group>\"; };\n\t\t81845E751D3503E8004B0C46 /* Transform.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Transform.h; sourceTree = \"<group>\"; };\n\t\t81845E761D3503E8004B0C46 /* Entity.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Entity.h; sourceTree = \"<group>\"; };\n\t\t81845E781D3503E8004B0C46 /* Event.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Event.h; sourceTree = \"<group>\"; };\n\t\t81845E791D3503E8004B0C46 /* EventConnection.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EventConnection.cpp; sourceTree = \"<group>\"; };\n\t\t81845E7A1D3503E8004B0C46 /* EventConnection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EventConnection.h; sourceTree = \"<group>\"; };\n\t\t81845E7B1D3503E8004B0C46 /* IConnectableEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IConnectableEvent.h; sourceTree = \"<group>\"; };\n\t\t81845E7C1D3503E8004B0C46 /* IDisconnectableEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IDisconnectableEvent.h; sourceTree = \"<group>\"; };\n\t\t81845E7D1D3503E8004B0C46 /* Event.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Event.h; sourceTree = \"<group>\"; };\n\t\t81845E7F1D3503E8004B0C46 /* AppDataStore.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AppDataStore.cpp; sourceTree = \"<group>\"; };\n\t\t81845E801D3503E8004B0C46 /* AppDataStore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDataStore.h; sourceTree = \"<group>\"; };\n\t\t81845E811D3503E8004B0C46 /* CSBinaryChunk.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSBinaryChunk.cpp; sourceTree = \"<group>\"; };\n\t\t81845E821D3503E8004B0C46 /* CSBinaryChunk.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSBinaryChunk.h; sourceTree = \"<group>\"; };\n\t\t81845E831D3503E8004B0C46 /* CSBinaryInputStream.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSBinaryInputStream.cpp; sourceTree = \"<group>\"; };\n\t\t81845E841D3503E8004B0C46 /* CSBinaryInputStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSBinaryInputStream.h; sourceTree = \"<group>\"; };\n\t\t81845E861D3503E8004B0C46 /* BinaryInputStream.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BinaryInputStream.cpp; sourceTree = \"<group>\"; };\n\t\t81845E871D3503E8004B0C46 /* BinaryInputStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BinaryInputStream.h; sourceTree = \"<group>\"; };\n\t\t81845E881D3503E8004B0C46 /* BinaryOutputStream.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BinaryOutputStream.cpp; sourceTree = \"<group>\"; };\n\t\t81845E891D3503E8004B0C46 /* BinaryOutputStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BinaryOutputStream.h; sourceTree = \"<group>\"; };\n\t\t81845E8A1D3503E8004B0C46 /* FileWriteMode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FileWriteMode.cpp; sourceTree = \"<group>\"; };\n\t\t81845E8B1D3503E8004B0C46 /* FileWriteMode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FileWriteMode.h; sourceTree = \"<group>\"; };\n\t\t81845E8C1D3503E8004B0C46 /* IBinaryInputStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IBinaryInputStream.h; sourceTree = \"<group>\"; };\n\t\t81845E8D1D3503E8004B0C46 /* ITextInputStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ITextInputStream.h; sourceTree = \"<group>\"; };\n\t\t81845E8E1D3503E8004B0C46 /* TextInputStream.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextInputStream.cpp; sourceTree = \"<group>\"; };\n\t\t81845E8F1D3503E8004B0C46 /* TextInputStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextInputStream.h; sourceTree = \"<group>\"; };\n\t\t81845E901D3503E8004B0C46 /* TextOutputStream.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextOutputStream.cpp; sourceTree = \"<group>\"; };\n\t\t81845E911D3503E8004B0C46 /* TextOutputStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextOutputStream.h; sourceTree = \"<group>\"; };\n\t\t81845E921D3503E8004B0C46 /* FileSystem.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FileSystem.cpp; sourceTree = \"<group>\"; };\n\t\t81845E931D3503E8004B0C46 /* FileSystem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FileSystem.h; sourceTree = \"<group>\"; };\n\t\t81845E941D3503E8004B0C46 /* StorageLocation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StorageLocation.h; sourceTree = \"<group>\"; };\n\t\t81845E951D3503E8004B0C46 /* TaggedFilePathResolver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TaggedFilePathResolver.cpp; sourceTree = \"<group>\"; };\n\t\t81845E961D3503E8004B0C46 /* TaggedFilePathResolver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TaggedFilePathResolver.h; sourceTree = \"<group>\"; };\n\t\t81845E971D3503E8004B0C46 /* File.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = File.h; sourceTree = \"<group>\"; };\n\t\t81845E981D3503E8004B0C46 /* ForwardDeclarations.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ForwardDeclarations.h; sourceTree = \"<group>\"; };\n\t\t81845E9A1D3503E8004B0C46 /* CSImageProvider.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSImageProvider.cpp; sourceTree = \"<group>\"; };\n\t\t81845E9B1D3503E8004B0C46 /* CSImageProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSImageProvider.h; sourceTree = \"<group>\"; };\n\t\t81845E9C1D3503E8004B0C46 /* ETC1ImageProvider.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ETC1ImageProvider.cpp; sourceTree = \"<group>\"; };\n\t\t81845E9D1D3503E8004B0C46 /* ETC1ImageProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ETC1ImageProvider.h; sourceTree = \"<group>\"; };\n\t\t81845E9E1D3503E8004B0C46 /* Image.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Image.cpp; sourceTree = \"<group>\"; };\n\t\t81845E9F1D3503E8004B0C46 /* Image.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Image.h; sourceTree = \"<group>\"; };\n\t\t81845EA01D3503E8004B0C46 /* ImageCompression.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ImageCompression.h; sourceTree = \"<group>\"; };\n\t\t81845EA11D3503E8004B0C46 /* ImageFormat.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ImageFormat.h; sourceTree = \"<group>\"; };\n\t\t81845EA21D3503E8004B0C46 /* ImageFormatConverter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ImageFormatConverter.cpp; sourceTree = \"<group>\"; };\n\t\t81845EA31D3503E8004B0C46 /* ImageFormatConverter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ImageFormatConverter.h; sourceTree = \"<group>\"; };\n\t\t81845EA41D3503E8004B0C46 /* PNGImageProvider.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PNGImageProvider.cpp; sourceTree = \"<group>\"; };\n\t\t81845EA51D3503E8004B0C46 /* PNGImageProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PNGImageProvider.h; sourceTree = \"<group>\"; };\n\t\t81845EA61D3503E8004B0C46 /* PVRImageProvider.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PVRImageProvider.cpp; sourceTree = \"<group>\"; };\n\t\t81845EA71D3503E8004B0C46 /* PVRImageProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PVRImageProvider.h; sourceTree = \"<group>\"; };\n\t\t81845EA81D3503E8004B0C46 /* Image.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Image.h; sourceTree = \"<group>\"; };\n\t\t81845EAA1D3503E8004B0C46 /* JsonUtils.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JsonUtils.cpp; sourceTree = \"<group>\"; };\n\t\t81845EAB1D3503E8004B0C46 /* JsonUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JsonUtils.h; sourceTree = \"<group>\"; };\n\t\t81845EAC1D3503E8004B0C46 /* Json.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Json.h; sourceTree = \"<group>\"; };\n\t\t81845EAE1D3503E8004B0C46 /* LocalisedText.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LocalisedText.cpp; sourceTree = \"<group>\"; };\n\t\t81845EAF1D3503E8004B0C46 /* LocalisedText.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LocalisedText.h; sourceTree = \"<group>\"; };\n\t\t81845EB01D3503E8004B0C46 /* LocalisedTextProvider.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LocalisedTextProvider.cpp; sourceTree = \"<group>\"; };\n\t\t81845EB11D3503E8004B0C46 /* LocalisedTextProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LocalisedTextProvider.h; sourceTree = \"<group>\"; };\n\t\t81845EB21D3503E8004B0C46 /* Localisation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Localisation.h; sourceTree = \"<group>\"; };\n\t\t81845EB51D3503E8004B0C46 /* Curves.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Curves.h; sourceTree = \"<group>\"; };\n\t\t81845EB61D3503E8004B0C46 /* ShapeIntersection.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ShapeIntersection.cpp; sourceTree = \"<group>\"; };\n\t\t81845EB71D3503E8004B0C46 /* ShapeIntersection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ShapeIntersection.h; sourceTree = \"<group>\"; };\n\t\t81845EB81D3503E8004B0C46 /* Shapes.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Shapes.cpp; sourceTree = \"<group>\"; };\n\t\t81845EB91D3503E8004B0C46 /* Shapes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Shapes.h; sourceTree = \"<group>\"; };\n\t\t81845EBA1D3503E8004B0C46 /* Interpolate.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Interpolate.cpp; sourceTree = \"<group>\"; };\n\t\t81845EBB1D3503E8004B0C46 /* Interpolate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Interpolate.h; sourceTree = \"<group>\"; };\n\t\t81845EBC1D3503E8004B0C46 /* MathUtils.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MathUtils.cpp; sourceTree = \"<group>\"; };\n\t\t81845EBD1D3503E8004B0C46 /* MathUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MathUtils.h; sourceTree = \"<group>\"; };\n\t\t81845EBE1D3503E8004B0C46 /* Matrix3.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Matrix3.h; sourceTree = \"<group>\"; };\n\t\t81845EBF1D3503E8004B0C46 /* Matrix4.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Matrix4.h; sourceTree = \"<group>\"; };\n\t\t81845EC01D3503E8004B0C46 /* NumericLimits.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NumericLimits.h; sourceTree = \"<group>\"; };\n\t\t81845EC11D3503E8004B0C46 /* Quaternion.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Quaternion.h; sourceTree = \"<group>\"; };\n\t\t81845EC21D3503E8004B0C46 /* Random.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Random.cpp; sourceTree = \"<group>\"; };\n\t\t81845EC31D3503E8004B0C46 /* Random.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Random.h; sourceTree = \"<group>\"; };\n\t\t81845EC41D3503E8004B0C46 /* RandomImpl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RandomImpl.h; sourceTree = \"<group>\"; };\n\t\t81845EC51D3503E8004B0C46 /* UnifiedCoordinates.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UnifiedCoordinates.cpp; sourceTree = \"<group>\"; };\n\t\t81845EC61D3503E8004B0C46 /* UnifiedCoordinates.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UnifiedCoordinates.h; sourceTree = \"<group>\"; };\n\t\t81845EC71D3503E8004B0C46 /* Vector2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Vector2.h; sourceTree = \"<group>\"; };\n\t\t81845EC81D3503E8004B0C46 /* Vector3.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Vector3.h; sourceTree = \"<group>\"; };\n\t\t81845EC91D3503E8004B0C46 /* Vector4.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Vector4.h; sourceTree = \"<group>\"; };\n\t\t81845ECA1D3503E8004B0C46 /* Math.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Math.h; sourceTree = \"<group>\"; };\n\t\t81845ECC1D3503E8004B0C46 /* IAllocator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IAllocator.h; sourceTree = \"<group>\"; };\n\t\t81845ECD1D3503E8004B0C46 /* LinearAllocator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LinearAllocator.cpp; sourceTree = \"<group>\"; };\n\t\t81845ECE1D3503E8004B0C46 /* LinearAllocator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LinearAllocator.h; sourceTree = \"<group>\"; };\n\t\t81845ECF1D3503E8004B0C46 /* MemoryUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MemoryUtils.h; sourceTree = \"<group>\"; };\n\t\t81845ED01D3503E8004B0C46 /* MemoryUtilsImpl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MemoryUtilsImpl.h; sourceTree = \"<group>\"; };\n\t\t81845ED11D3503E8004B0C46 /* PagedLinearAllocator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PagedLinearAllocator.cpp; sourceTree = \"<group>\"; };\n\t\t81845ED21D3503E8004B0C46 /* PagedLinearAllocator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PagedLinearAllocator.h; sourceTree = \"<group>\"; };\n\t\t81845ED31D3503E8004B0C46 /* SharedPtr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SharedPtr.h; sourceTree = \"<group>\"; };\n\t\t81845ED41D3503E8004B0C46 /* SharedPtrImpl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SharedPtrImpl.h; sourceTree = \"<group>\"; };\n\t\t81845ED51D3503E8004B0C46 /* UniquePtr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UniquePtr.h; sourceTree = \"<group>\"; };\n\t\t81845ED61D3503E8004B0C46 /* UniquePtrImpl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UniquePtrImpl.h; sourceTree = \"<group>\"; };\n\t\t81845ED71D3503E8004B0C46 /* Memory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Memory.h; sourceTree = \"<group>\"; };\n\t\t81845ED91D3503E8004B0C46 /* AppNotificationSystem.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AppNotificationSystem.cpp; sourceTree = \"<group>\"; };\n\t\t81845EDA1D3503E8004B0C46 /* AppNotificationSystem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppNotificationSystem.h; sourceTree = \"<group>\"; };\n\t\t81845EDB1D3503E8004B0C46 /* LocalNotificationSystem.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LocalNotificationSystem.cpp; sourceTree = \"<group>\"; };\n\t\t81845EDC1D3503E8004B0C46 /* LocalNotificationSystem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LocalNotificationSystem.h; sourceTree = \"<group>\"; };\n\t\t81845EDD1D3503E8004B0C46 /* Notification.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Notification.h; sourceTree = \"<group>\"; };\n\t\t81845EDE1D3503E8004B0C46 /* NotificationManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NotificationManager.cpp; sourceTree = \"<group>\"; };\n\t\t81845EDF1D3503E8004B0C46 /* NotificationManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NotificationManager.h; sourceTree = \"<group>\"; };\n\t\t81845EE01D3503E8004B0C46 /* RemoteNotificationSystem.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RemoteNotificationSystem.cpp; sourceTree = \"<group>\"; };\n\t\t81845EE11D3503E8004B0C46 /* RemoteNotificationSystem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RemoteNotificationSystem.h; sourceTree = \"<group>\"; };\n\t\t81845EE21D3503E8004B0C46 /* Notification.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Notification.h; sourceTree = \"<group>\"; };\n\t\t81845EE41D3503E8004B0C46 /* IResourceOptions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IResourceOptions.h; sourceTree = \"<group>\"; };\n\t\t81845EE51D3503E8004B0C46 /* Resource.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Resource.cpp; sourceTree = \"<group>\"; };\n\t\t81845EE61D3503E8004B0C46 /* Resource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Resource.h; sourceTree = \"<group>\"; };\n\t\t81845EE71D3503E8004B0C46 /* ResourcePool.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ResourcePool.cpp; sourceTree = \"<group>\"; };\n\t\t81845EE81D3503E8004B0C46 /* ResourcePool.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ResourcePool.h; sourceTree = \"<group>\"; };\n\t\t81845EE91D3503E8004B0C46 /* ResourceProvider.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ResourceProvider.cpp; sourceTree = \"<group>\"; };\n\t\t81845EEA1D3503E8004B0C46 /* ResourceProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ResourceProvider.h; sourceTree = \"<group>\"; };\n\t\t81845EEB1D3503E8004B0C46 /* Resource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Resource.h; sourceTree = \"<group>\"; };\n\t\t81845EED1D3503E8004B0C46 /* Scene.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Scene.cpp; sourceTree = \"<group>\"; };\n\t\t81845EEE1D3503E8004B0C46 /* Scene.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Scene.h; sourceTree = \"<group>\"; };\n\t\t81845EEF1D3503E8004B0C46 /* Scene.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Scene.h; sourceTree = \"<group>\"; };\n\t\t81845EF11D3503E8004B0C46 /* State.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = State.cpp; sourceTree = \"<group>\"; };\n\t\t81845EF21D3503E8004B0C46 /* State.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = State.h; sourceTree = \"<group>\"; };\n\t\t81845EF31D3503E8004B0C46 /* StateManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StateManager.cpp; sourceTree = \"<group>\"; };\n\t\t81845EF41D3503E8004B0C46 /* StateManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StateManager.h; sourceTree = \"<group>\"; };\n\t\t81845EF51D3503E8004B0C46 /* State.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = State.h; sourceTree = \"<group>\"; };\n\t\t81845EF71D3503E8004B0C46 /* MarkupDef.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MarkupDef.cpp; sourceTree = \"<group>\"; };\n\t\t81845EF81D3503E8004B0C46 /* MarkupDef.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MarkupDef.h; sourceTree = \"<group>\"; };\n\t\t81845EF91D3503E8004B0C46 /* StringMarkupParser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StringMarkupParser.cpp; sourceTree = \"<group>\"; };\n\t\t81845EFA1D3503E8004B0C46 /* StringMarkupParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StringMarkupParser.h; sourceTree = \"<group>\"; };\n\t\t81845EFB1D3503E8004B0C46 /* StringParser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StringParser.cpp; sourceTree = \"<group>\"; };\n\t\t81845EFC1D3503E8004B0C46 /* StringParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StringParser.h; sourceTree = \"<group>\"; };\n\t\t81845EFD1D3503E8004B0C46 /* StringUtils.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StringUtils.cpp; sourceTree = \"<group>\"; };\n\t\t81845EFE1D3503E8004B0C46 /* StringUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StringUtils.h; sourceTree = \"<group>\"; };\n\t\t81845EFF1D3503E8004B0C46 /* ToString.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ToString.cpp; sourceTree = \"<group>\"; };\n\t\t81845F001D3503E8004B0C46 /* ToString.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ToString.h; sourceTree = \"<group>\"; };\n\t\t81845F011D3503E8004B0C46 /* UTF8StringUtils.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UTF8StringUtils.cpp; sourceTree = \"<group>\"; };\n\t\t81845F021D3503E8004B0C46 /* UTF8StringUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UTF8StringUtils.h; sourceTree = \"<group>\"; };\n\t\t81845F031D3503E8004B0C46 /* String.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = String.h; sourceTree = \"<group>\"; };\n\t\t81845F051D3503E8004B0C46 /* AppSystem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppSystem.h; sourceTree = \"<group>\"; };\n\t\t81845F061D3503E8004B0C46 /* StateSystem.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StateSystem.cpp; sourceTree = \"<group>\"; };\n\t\t81845F071D3503E8004B0C46 /* StateSystem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StateSystem.h; sourceTree = \"<group>\"; };\n\t\t81845F081D3503E8004B0C46 /* System.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = System.h; sourceTree = \"<group>\"; };\n\t\t81845F0A1D3503E8004B0C46 /* SingleThreadTaskPool.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SingleThreadTaskPool.cpp; sourceTree = \"<group>\"; };\n\t\t81845F0B1D3503E8004B0C46 /* SingleThreadTaskPool.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SingleThreadTaskPool.h; sourceTree = \"<group>\"; };\n\t\t81845F0C1D3503E8004B0C46 /* Task.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Task.h; sourceTree = \"<group>\"; };\n\t\t81845F0D1D3503E8004B0C46 /* TaskContext.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TaskContext.cpp; sourceTree = \"<group>\"; };\n\t\t81845F0E1D3503E8004B0C46 /* TaskContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TaskContext.h; sourceTree = \"<group>\"; };\n\t\t81845F0F1D3503E8004B0C46 /* TaskPool.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TaskPool.cpp; sourceTree = \"<group>\"; };\n\t\t81845F101D3503E8004B0C46 /* TaskPool.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TaskPool.h; sourceTree = \"<group>\"; };\n\t\t81845F111D3503E8004B0C46 /* TaskScheduler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TaskScheduler.cpp; sourceTree = \"<group>\"; };\n\t\t81845F121D3503E8004B0C46 /* TaskScheduler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TaskScheduler.h; sourceTree = \"<group>\"; };\n\t\t81845F131D3503E8004B0C46 /* TaskType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TaskType.h; sourceTree = \"<group>\"; };\n\t\t81845F141D3503E8004B0C46 /* Threading.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Threading.h; sourceTree = \"<group>\"; };\n\t\t81845F161D3503E8004B0C46 /* CoreTimer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CoreTimer.cpp; sourceTree = \"<group>\"; };\n\t\t81845F171D3503E8004B0C46 /* CoreTimer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CoreTimer.h; sourceTree = \"<group>\"; };\n\t\t81845F181D3503E8004B0C46 /* PerformanceTimer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PerformanceTimer.cpp; sourceTree = \"<group>\"; };\n\t\t81845F191D3503E8004B0C46 /* PerformanceTimer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PerformanceTimer.h; sourceTree = \"<group>\"; };\n\t\t81845F1A1D3503E8004B0C46 /* Timer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Timer.cpp; sourceTree = \"<group>\"; };\n\t\t81845F1B1D3503E8004B0C46 /* Timer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Timer.h; sourceTree = \"<group>\"; };\n\t\t81845F1C1D3503E8004B0C46 /* Time.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Time.h; sourceTree = \"<group>\"; };\n\t\t81845F1E1D3503E8004B0C46 /* EaseBack.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EaseBack.h; sourceTree = \"<group>\"; };\n\t\t81845F1F1D3503E8004B0C46 /* EaseQuad.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EaseQuad.h; sourceTree = \"<group>\"; };\n\t\t81845F201D3503E8004B0C46 /* Linear.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Linear.h; sourceTree = \"<group>\"; };\n\t\t81845F211D3503E8004B0C46 /* SmoothStep.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SmoothStep.h; sourceTree = \"<group>\"; };\n\t\t81845F221D3503E8004B0C46 /* Tween.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Tween.h; sourceTree = \"<group>\"; };\n\t\t81845F231D3503E8004B0C46 /* Tween.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Tween.h; sourceTree = \"<group>\"; };\n\t\t81845F251D3503E8004B0C46 /* VolumeComponent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = VolumeComponent.cpp; sourceTree = \"<group>\"; };\n\t\t81845F261D3503E8004B0C46 /* VolumeComponent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VolumeComponent.h; sourceTree = \"<group>\"; };\n\t\t81845F271D3503E8004B0C46 /* Volume.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Volume.h; sourceTree = \"<group>\"; };\n\t\t81845F291D3503E8004B0C46 /* XML.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = XML.cpp; sourceTree = \"<group>\"; };\n\t\t81845F2A1D3503E8004B0C46 /* XML.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XML.h; sourceTree = \"<group>\"; };\n\t\t81845F2B1D3503E8004B0C46 /* XMLUtils.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = XMLUtils.cpp; sourceTree = \"<group>\"; };\n\t\t81845F2C1D3503E8004B0C46 /* XMLUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XMLUtils.h; sourceTree = \"<group>\"; };\n\t\t81845F2D1D3503E8004B0C46 /* XML.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XML.h; sourceTree = \"<group>\"; };\n\t\t81845F301D3503E8004B0C46 /* Accelerometer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Accelerometer.cpp; sourceTree = \"<group>\"; };\n\t\t81845F311D3503E8004B0C46 /* Accelerometer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Accelerometer.h; sourceTree = \"<group>\"; };\n\t\t81845F321D3503E8004B0C46 /* Accelerometer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Accelerometer.h; sourceTree = \"<group>\"; };\n\t\t81845F341D3503E8004B0C46 /* InputFilter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InputFilter.cpp; sourceTree = \"<group>\"; };\n\t\t81845F351D3503E8004B0C46 /* InputFilter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InputFilter.h; sourceTree = \"<group>\"; };\n\t\t81845F361D3503E8004B0C46 /* Base.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Base.h; sourceTree = \"<group>\"; };\n\t\t81845F381D3503E8004B0C46 /* DeviceButtonSystem.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DeviceButtonSystem.cpp; sourceTree = \"<group>\"; };\n\t\t81845F391D3503E8004B0C46 /* DeviceButtonSystem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DeviceButtonSystem.h; sourceTree = \"<group>\"; };\n\t\t81845F3A1D3503E8004B0C46 /* DeviceButtons.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DeviceButtons.h; sourceTree = \"<group>\"; };\n\t\t81845F3B1D3503E8004B0C46 /* ForwardDeclarations.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ForwardDeclarations.h; sourceTree = \"<group>\"; };\n\t\t81845F3D1D3503E8004B0C46 /* DragGesture.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DragGesture.cpp; sourceTree = \"<group>\"; };\n\t\t81845F3E1D3503E8004B0C46 /* DragGesture.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DragGesture.h; sourceTree = \"<group>\"; };\n\t\t81845F3F1D3503E8004B0C46 /* Gesture.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Gesture.cpp; sourceTree = \"<group>\"; };\n\t\t81845F401D3503E8004B0C46 /* Gesture.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Gesture.h; sourceTree = \"<group>\"; };\n\t\t81845F411D3503E8004B0C46 /* GestureSystem.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GestureSystem.cpp; sourceTree = \"<group>\"; };\n\t\t81845F421D3503E8004B0C46 /* GestureSystem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GestureSystem.h; sourceTree = \"<group>\"; };\n\t\t81845F431D3503E8004B0C46 /* HoldGesture.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HoldGesture.cpp; sourceTree = \"<group>\"; };\n\t\t81845F441D3503E8004B0C46 /* HoldGesture.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HoldGesture.h; sourceTree = \"<group>\"; };\n\t\t81845F451D3503E8004B0C46 /* PinchGesture.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PinchGesture.cpp; sourceTree = \"<group>\"; };\n\t\t81845F461D3503E8004B0C46 /* PinchGesture.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PinchGesture.h; sourceTree = \"<group>\"; };\n\t\t81845F471D3503E8004B0C46 /* RotationGesture.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RotationGesture.cpp; sourceTree = \"<group>\"; };\n\t\t81845F481D3503E8004B0C46 /* RotationGesture.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RotationGesture.h; sourceTree = \"<group>\"; };\n\t\t81845F491D3503E8004B0C46 /* TapGesture.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TapGesture.cpp; sourceTree = \"<group>\"; };\n\t\t81845F4A1D3503E8004B0C46 /* TapGesture.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TapGesture.h; sourceTree = \"<group>\"; };\n\t\t81845F4B1D3503E8004B0C46 /* Gesture.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Gesture.h; sourceTree = \"<group>\"; };\n\t\t81845F4D1D3503E8004B0C46 /* Keyboard.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Keyboard.cpp; sourceTree = \"<group>\"; };\n\t\t81845F4E1D3503E8004B0C46 /* Keyboard.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Keyboard.h; sourceTree = \"<group>\"; };\n\t\t81845F4F1D3503E8004B0C46 /* KeyCode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = KeyCode.cpp; sourceTree = \"<group>\"; };\n\t\t81845F501D3503E8004B0C46 /* KeyCode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KeyCode.h; sourceTree = \"<group>\"; };\n\t\t81845F511D3503E8004B0C46 /* ModifierKeyCode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ModifierKeyCode.h; sourceTree = \"<group>\"; };\n\t\t81845F521D3503E8004B0C46 /* Keyboard.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Keyboard.h; sourceTree = \"<group>\"; };\n\t\t81845F541D3503E8004B0C46 /* Pointer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Pointer.cpp; sourceTree = \"<group>\"; };\n\t\t81845F551D3503E8004B0C46 /* Pointer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Pointer.h; sourceTree = \"<group>\"; };\n\t\t81845F561D3503E8004B0C46 /* PointerSystem.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PointerSystem.cpp; sourceTree = \"<group>\"; };\n\t\t81845F571D3503E8004B0C46 /* PointerSystem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PointerSystem.h; sourceTree = \"<group>\"; };\n\t\t81845F581D3503E8004B0C46 /* Pointer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Pointer.h; sourceTree = \"<group>\"; };\n\t\t81845F5A1D3503E8004B0C46 /* TextEntry.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextEntry.cpp; sourceTree = \"<group>\"; };\n\t\t81845F5B1D3503E8004B0C46 /* TextEntry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextEntry.h; sourceTree = \"<group>\"; };\n\t\t81845F5C1D3503E8004B0C46 /* TextEntryCapitalisation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextEntryCapitalisation.cpp; sourceTree = \"<group>\"; };\n\t\t81845F5D1D3503E8004B0C46 /* TextEntryCapitalisation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextEntryCapitalisation.h; sourceTree = \"<group>\"; };\n\t\t81845F5E1D3503E8004B0C46 /* TextEntryType.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextEntryType.cpp; sourceTree = \"<group>\"; };\n\t\t81845F5F1D3503E8004B0C46 /* TextEntryType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextEntryType.h; sourceTree = \"<group>\"; };\n\t\t81845F601D3503E8004B0C46 /* TextEntry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextEntry.h; sourceTree = \"<group>\"; };\n\t\t81845F631D3503E8004B0C46 /* ContentManagementSystem.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ContentManagementSystem.cpp; sourceTree = \"<group>\"; };\n\t\t81845F641D3503E8004B0C46 /* ContentManagementSystem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ContentManagementSystem.h; sourceTree = \"<group>\"; };\n\t\t81845F651D3503E8004B0C46 /* IContentDownloader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IContentDownloader.h; sourceTree = \"<group>\"; };\n\t\t81845F661D3503E8004B0C46 /* MoContentDownloader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MoContentDownloader.cpp; sourceTree = \"<group>\"; };\n\t\t81845F671D3503E8004B0C46 /* MoContentDownloader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MoContentDownloader.h; sourceTree = \"<group>\"; };\n\t\t81845F681D3503E8004B0C46 /* ContentDownload.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ContentDownload.h; sourceTree = \"<group>\"; };\n\t\t81845F691D3503E8004B0C46 /* ForwardDeclarations.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ForwardDeclarations.h; sourceTree = \"<group>\"; };\n\t\t81845F6B1D3503E8004B0C46 /* HttpRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HttpRequest.h; sourceTree = \"<group>\"; };\n\t\t81845F6C1D3503E8004B0C46 /* HttpRequestSystem.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HttpRequestSystem.cpp; sourceTree = \"<group>\"; };\n\t\t81845F6D1D3503E8004B0C46 /* HttpRequestSystem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HttpRequestSystem.h; sourceTree = \"<group>\"; };\n\t\t81845F6E1D3503E8004B0C46 /* HttpResponse.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HttpResponse.cpp; sourceTree = \"<group>\"; };\n\t\t81845F6F1D3503E8004B0C46 /* HttpResponse.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HttpResponse.h; sourceTree = \"<group>\"; };\n\t\t81845F701D3503E8004B0C46 /* Http.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Http.h; sourceTree = \"<group>\"; };\n\t\t81845F721D3503E8004B0C46 /* IAPSystem.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = IAPSystem.cpp; sourceTree = \"<group>\"; };\n\t\t81845F731D3503E8004B0C46 /* IAPSystem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IAPSystem.h; sourceTree = \"<group>\"; };\n\t\t81845F741D3503E8004B0C46 /* IAP.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IAP.h; sourceTree = \"<group>\"; };\n\t\t81845F771D3503E8004B0C46 /* AlignmentAnchors.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AlignmentAnchors.cpp; sourceTree = \"<group>\"; };\n\t\t81845F781D3503E8004B0C46 /* AlignmentAnchors.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AlignmentAnchors.h; sourceTree = \"<group>\"; };\n\t\t81845F791D3503E8004B0C46 /* AspectRatioUtils.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AspectRatioUtils.cpp; sourceTree = \"<group>\"; };\n\t\t81845F7A1D3503E8004B0C46 /* AspectRatioUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AspectRatioUtils.h; sourceTree = \"<group>\"; };\n\t\t81845F7B1D3503E8004B0C46 /* BlendMode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BlendMode.h; sourceTree = \"<group>\"; };\n\t\t81845F7C1D3503E8004B0C46 /* CameraRenderPassGroup.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CameraRenderPassGroup.cpp; sourceTree = \"<group>\"; };\n\t\t81845F7D1D3503E8004B0C46 /* CameraRenderPassGroup.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CameraRenderPassGroup.h; sourceTree = \"<group>\"; };\n\t\t81845F7E1D3503E8004B0C46 /* CanvasMaterialPool.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CanvasMaterialPool.cpp; sourceTree = \"<group>\"; };\n\t\t81845F7F1D3503E8004B0C46 /* CanvasMaterialPool.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CanvasMaterialPool.h; sourceTree = \"<group>\"; };\n\t\t81845F801D3503E8004B0C46 /* CanvasRenderer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CanvasRenderer.cpp; sourceTree = \"<group>\"; };\n\t\t81845F811D3503E8004B0C46 /* CanvasRenderer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CanvasRenderer.h; sourceTree = \"<group>\"; };\n\t\t81845F821D3503E8004B0C46 /* CullFace.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CullFace.h; sourceTree = \"<group>\"; };\n\t\t81845F841D3503E8004B0C46 /* ForwardRenderPassCompiler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ForwardRenderPassCompiler.cpp; sourceTree = \"<group>\"; };\n\t\t81845F851D3503E8004B0C46 /* ForwardRenderPassCompiler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ForwardRenderPassCompiler.h; sourceTree = \"<group>\"; };\n\t\t81845F861D3503E8004B0C46 /* RenderPasses.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderPasses.h; sourceTree = \"<group>\"; };\n\t\t81845F871D3503E8004B0C46 /* FrameAllocatorQueue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FrameAllocatorQueue.cpp; sourceTree = \"<group>\"; };\n\t\t81845F881D3503E8004B0C46 /* FrameAllocatorQueue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FrameAllocatorQueue.h; sourceTree = \"<group>\"; };\n\t\t81845F891D3503E8004B0C46 /* HorizontalTextJustification.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HorizontalTextJustification.cpp; sourceTree = \"<group>\"; };\n\t\t81845F8A1D3503E8004B0C46 /* HorizontalTextJustification.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HorizontalTextJustification.h; sourceTree = \"<group>\"; };\n\t\t81845F8B1D3503E8004B0C46 /* IRenderCommandProcessor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = IRenderCommandProcessor.cpp; sourceTree = \"<group>\"; };\n\t\t81845F8C1D3503E8004B0C46 /* IRenderCommandProcessor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IRenderCommandProcessor.h; sourceTree = \"<group>\"; };\n\t\t81845F8D1D3503E8004B0C46 /* IRenderPassCompiler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IRenderPassCompiler.h; sourceTree = \"<group>\"; };\n\t\t81845F8E1D3503E8004B0C46 /* RenderCapabilities.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderCapabilities.cpp; sourceTree = \"<group>\"; };\n\t\t81845F8F1D3503E8004B0C46 /* RenderCapabilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderCapabilities.h; sourceTree = \"<group>\"; };\n\t\t81845F901D3503E8004B0C46 /* RenderCommandBufferManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderCommandBufferManager.cpp; sourceTree = \"<group>\"; };\n\t\t81845F911D3503E8004B0C46 /* RenderCommandBufferManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderCommandBufferManager.h; sourceTree = \"<group>\"; };\n\t\t81845F921D3503E8004B0C46 /* RenderCommandCompiler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderCommandCompiler.cpp; sourceTree = \"<group>\"; };\n\t\t81845F931D3503E8004B0C46 /* RenderCommandCompiler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderCommandCompiler.h; sourceTree = \"<group>\"; };\n\t\t81845F961D3503E8004B0C46 /* Renderer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Renderer.cpp; sourceTree = \"<group>\"; };\n\t\t81845F971D3503E8004B0C46 /* Renderer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Renderer.h; sourceTree = \"<group>\"; };\n\t\t81845F981D3503E8004B0C46 /* RenderFrame.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderFrame.cpp; sourceTree = \"<group>\"; };\n\t\t81845F991D3503E8004B0C46 /* RenderFrame.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderFrame.h; sourceTree = \"<group>\"; };\n\t\t81845F9A1D3503E8004B0C46 /* RenderFrameCompiler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderFrameCompiler.cpp; sourceTree = \"<group>\"; };\n\t\t81845F9B1D3503E8004B0C46 /* RenderFrameCompiler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderFrameCompiler.h; sourceTree = \"<group>\"; };\n\t\t81845F9C1D3503E8004B0C46 /* RenderFrameData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderFrameData.cpp; sourceTree = \"<group>\"; };\n\t\t81845F9D1D3503E8004B0C46 /* RenderFrameData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderFrameData.h; sourceTree = \"<group>\"; };\n\t\t81845F9E1D3503E8004B0C46 /* RenderLayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderLayer.h; sourceTree = \"<group>\"; };\n\t\t81845F9F1D3503E8004B0C46 /* RenderObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderObject.cpp; sourceTree = \"<group>\"; };\n\t\t81845FA01D3503E8004B0C46 /* RenderObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderObject.h; sourceTree = \"<group>\"; };\n\t\t81845FA11D3503E8004B0C46 /* RenderPass.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderPass.cpp; sourceTree = \"<group>\"; };\n\t\t81845FA21D3503E8004B0C46 /* RenderPass.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderPass.h; sourceTree = \"<group>\"; };\n\t\t81845FA31D3503E8004B0C46 /* RenderPassObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderPassObject.cpp; sourceTree = \"<group>\"; };\n\t\t81845FA41D3503E8004B0C46 /* RenderPassObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderPassObject.h; sourceTree = \"<group>\"; };\n\t\t81845FA51D3503E8004B0C46 /* RenderPassObjectSorter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderPassObjectSorter.cpp; sourceTree = \"<group>\"; };\n\t\t81845FA61D3503E8004B0C46 /* RenderPassObjectSorter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderPassObjectSorter.h; sourceTree = \"<group>\"; };\n\t\t81845FA71D3503E8004B0C46 /* RenderPassVisibilityChecker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderPassVisibilityChecker.cpp; sourceTree = \"<group>\"; };\n\t\t81845FA81D3503E8004B0C46 /* RenderPassVisibilityChecker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderPassVisibilityChecker.h; sourceTree = \"<group>\"; };\n\t\t81845FA91D3503E8004B0C46 /* RenderSnapshot.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderSnapshot.cpp; sourceTree = \"<group>\"; };\n\t\t81845FAA1D3503E8004B0C46 /* RenderSnapshot.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderSnapshot.h; sourceTree = \"<group>\"; };\n\t\t81845FAB1D3503E8004B0C46 /* SizePolicy.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SizePolicy.cpp; sourceTree = \"<group>\"; };\n\t\t81845FAC1D3503E8004B0C46 /* SizePolicy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SizePolicy.h; sourceTree = \"<group>\"; };\n\t\t81845FAD1D3503E8004B0C46 /* SurfaceFormat.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SurfaceFormat.h; sourceTree = \"<group>\"; };\n\t\t81845FAE1D3503E8004B0C46 /* TargetRenderPassGroup.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TargetRenderPassGroup.cpp; sourceTree = \"<group>\"; };\n\t\t81845FAF1D3503E8004B0C46 /* TargetRenderPassGroup.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TargetRenderPassGroup.h; sourceTree = \"<group>\"; };\n\t\t81845FB01D3503E8004B0C46 /* VerticalTextJustification.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = VerticalTextJustification.cpp; sourceTree = \"<group>\"; };\n\t\t81845FB11D3503E8004B0C46 /* VerticalTextJustification.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VerticalTextJustification.h; sourceTree = \"<group>\"; };\n\t\t81845FB21D3503E8004B0C46 /* Base.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Base.h; sourceTree = \"<group>\"; };\n\t\t81845FB41D3503E8004B0C46 /* CameraComponent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CameraComponent.cpp; sourceTree = \"<group>\"; };\n\t\t81845FB51D3503E8004B0C46 /* CameraComponent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CameraComponent.h; sourceTree = \"<group>\"; };\n\t\t81845FB61D3503E8004B0C46 /* OrthographicCameraComponent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OrthographicCameraComponent.cpp; sourceTree = \"<group>\"; };\n\t\t81845FB71D3503E8004B0C46 /* OrthographicCameraComponent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OrthographicCameraComponent.h; sourceTree = \"<group>\"; };\n\t\t81845FB81D3503E8004B0C46 /* PerspectiveCameraComponent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PerspectiveCameraComponent.cpp; sourceTree = \"<group>\"; };\n\t\t81845FB91D3503E8004B0C46 /* PerspectiveCameraComponent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PerspectiveCameraComponent.h; sourceTree = \"<group>\"; };\n\t\t81845FBA1D3503E8004B0C46 /* RenderCamera.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderCamera.cpp; sourceTree = \"<group>\"; };\n\t\t81845FBB1D3503E8004B0C46 /* RenderCamera.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderCamera.h; sourceTree = \"<group>\"; };\n\t\t81845FBC1D3503E8004B0C46 /* Camera.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Camera.h; sourceTree = \"<group>\"; };\n\t\t81845FBE1D3503E8004B0C46 /* Font.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Font.cpp; sourceTree = \"<group>\"; };\n\t\t81845FBF1D3503E8004B0C46 /* Font.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Font.h; sourceTree = \"<group>\"; };\n\t\t81845FC01D3503E8004B0C46 /* FontProvider.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FontProvider.cpp; sourceTree = \"<group>\"; };\n\t\t81845FC11D3503E8004B0C46 /* FontProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FontProvider.h; sourceTree = \"<group>\"; };\n\t\t81845FC21D3503E8004B0C46 /* Font.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Font.h; sourceTree = \"<group>\"; };\n\t\t81845FC31D3503E8004B0C46 /* ForwardDeclarations.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ForwardDeclarations.h; sourceTree = \"<group>\"; };\n\t\t81845FC51D3503E8004B0C46 /* AmbientLightComponent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AmbientLightComponent.cpp; sourceTree = \"<group>\"; };\n\t\t81845FC61D3503E8004B0C46 /* AmbientLightComponent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AmbientLightComponent.h; sourceTree = \"<group>\"; };\n\t\t81845FC71D3503E8004B0C46 /* AmbientRenderLight.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AmbientRenderLight.cpp; sourceTree = \"<group>\"; };\n\t\t81845FC81D3503E8004B0C46 /* AmbientRenderLight.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AmbientRenderLight.h; sourceTree = \"<group>\"; };\n\t\t81845FC91D3503E8004B0C46 /* DirectionalLightComponent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DirectionalLightComponent.cpp; sourceTree = \"<group>\"; };\n\t\t81845FCA1D3503E8004B0C46 /* DirectionalLightComponent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DirectionalLightComponent.h; sourceTree = \"<group>\"; };\n\t\t81845FCB1D3503E8004B0C46 /* DirectionalRenderLight.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DirectionalRenderLight.cpp; sourceTree = \"<group>\"; };\n\t\t81845FCC1D3503E8004B0C46 /* DirectionalRenderLight.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DirectionalRenderLight.h; sourceTree = \"<group>\"; };\n\t\t81845FCD1D3503E8004B0C46 /* PointLightComponent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PointLightComponent.cpp; sourceTree = \"<group>\"; };\n\t\t81845FCE1D3503E8004B0C46 /* PointLightComponent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PointLightComponent.h; sourceTree = \"<group>\"; };\n\t\t81845FCF1D3503E8004B0C46 /* PointRenderLight.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PointRenderLight.cpp; sourceTree = \"<group>\"; };\n\t\t81845FD01D3503E8004B0C46 /* PointRenderLight.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PointRenderLight.h; sourceTree = \"<group>\"; };\n\t\t81845FD11D3503E8004B0C46 /* Lighting.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Lighting.h; sourceTree = \"<group>\"; };\n\t\t81845FD31D3503E8004B0C46 /* ForwardRenderMaterialGroupManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ForwardRenderMaterialGroupManager.cpp; sourceTree = \"<group>\"; };\n\t\t81845FD41D3503E8004B0C46 /* ForwardRenderMaterialGroupManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ForwardRenderMaterialGroupManager.h; sourceTree = \"<group>\"; };\n\t\t81845FD51D3503E8004B0C46 /* Material.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Material.cpp; sourceTree = \"<group>\"; };\n\t\t81845FD61D3503E8004B0C46 /* Material.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Material.h; sourceTree = \"<group>\"; };\n\t\t81845FD71D3503E8004B0C46 /* MaterialFactory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MaterialFactory.cpp; sourceTree = \"<group>\"; };\n\t\t81845FD81D3503E8004B0C46 /* MaterialFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MaterialFactory.h; sourceTree = \"<group>\"; };\n\t\t81845FD91D3503E8004B0C46 /* MaterialProvider.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MaterialProvider.cpp; sourceTree = \"<group>\"; };\n\t\t81845FDA1D3503E8004B0C46 /* MaterialProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MaterialProvider.h; sourceTree = \"<group>\"; };\n\t\t81845FDB1D3503E8004B0C46 /* RenderMaterial.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderMaterial.cpp; sourceTree = \"<group>\"; };\n\t\t81845FDC1D3503E8004B0C46 /* RenderMaterial.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderMaterial.h; sourceTree = \"<group>\"; };\n\t\t81845FDD1D3503E8004B0C46 /* RenderMaterialGroup.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderMaterialGroup.cpp; sourceTree = \"<group>\"; };\n\t\t81845FDE1D3503E8004B0C46 /* RenderMaterialGroup.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderMaterialGroup.h; sourceTree = \"<group>\"; };\n\t\t81845FDF1D3503E8004B0C46 /* RenderMaterialGroupManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderMaterialGroupManager.cpp; sourceTree = \"<group>\"; };\n\t\t81845FE01D3503E8004B0C46 /* RenderMaterialGroupManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderMaterialGroupManager.h; sourceTree = \"<group>\"; };\n\t\t81845FE11D3503E8004B0C46 /* Material.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Material.h; sourceTree = \"<group>\"; };\n\t\t81845FE31D3503E8004B0C46 /* AnimatedModelComponent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AnimatedModelComponent.cpp; sourceTree = \"<group>\"; };\n\t\t81845FE41D3503E8004B0C46 /* AnimatedModelComponent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AnimatedModelComponent.h; sourceTree = \"<group>\"; };\n\t\t81845FE51D3503E8004B0C46 /* CSAnimProvider.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSAnimProvider.cpp; sourceTree = \"<group>\"; };\n\t\t81845FE61D3503E8004B0C46 /* CSAnimProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSAnimProvider.h; sourceTree = \"<group>\"; };\n\t\t81845FE71D3503E8004B0C46 /* CSModelProvider.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSModelProvider.cpp; sourceTree = \"<group>\"; };\n\t\t81845FE81D3503E8004B0C46 /* CSModelProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSModelProvider.h; sourceTree = \"<group>\"; };\n\t\t81845FE91D3503E8004B0C46 /* IndexFormat.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = IndexFormat.cpp; sourceTree = \"<group>\"; };\n\t\t81845FEA1D3503E8004B0C46 /* IndexFormat.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IndexFormat.h; sourceTree = \"<group>\"; };\n\t\t81845FEB1D3503E8004B0C46 /* MeshDesc.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MeshDesc.cpp; sourceTree = \"<group>\"; };\n\t\t81845FEC1D3503E8004B0C46 /* MeshDesc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MeshDesc.h; sourceTree = \"<group>\"; };\n\t\t81845FED1D3503E8004B0C46 /* Model.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Model.cpp; sourceTree = \"<group>\"; };\n\t\t81845FEE1D3503E8004B0C46 /* Model.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Model.h; sourceTree = \"<group>\"; };\n\t\t81845FEF1D3503E8004B0C46 /* ModelDesc.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ModelDesc.cpp; sourceTree = \"<group>\"; };\n\t\t81845FF01D3503E8004B0C46 /* ModelDesc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ModelDesc.h; sourceTree = \"<group>\"; };\n\t\t81845FF11D3503E8004B0C46 /* PolygonType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PolygonType.h; sourceTree = \"<group>\"; };\n\t\t81845FF21D3503E8004B0C46 /* PrimitiveModelFactory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PrimitiveModelFactory.cpp; sourceTree = \"<group>\"; };\n\t\t81845FF31D3503E8004B0C46 /* PrimitiveModelFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PrimitiveModelFactory.h; sourceTree = \"<group>\"; };\n\t\t81845FF41D3503E8004B0C46 /* RenderDynamicMesh.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderDynamicMesh.cpp; sourceTree = \"<group>\"; };\n\t\t81845FF51D3503E8004B0C46 /* RenderDynamicMesh.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderDynamicMesh.h; sourceTree = \"<group>\"; };\n\t\t81845FF61D3503E8004B0C46 /* RenderMesh.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderMesh.cpp; sourceTree = \"<group>\"; };\n\t\t81845FF71D3503E8004B0C46 /* RenderMesh.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderMesh.h; sourceTree = \"<group>\"; };\n\t\t81845FF81D3503E8004B0C46 /* RenderMeshManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderMeshManager.cpp; sourceTree = \"<group>\"; };\n\t\t81845FF91D3503E8004B0C46 /* RenderMeshManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderMeshManager.h; sourceTree = \"<group>\"; };\n\t\t81845FFA1D3503E8004B0C46 /* RenderSkinnedAnimation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderSkinnedAnimation.cpp; sourceTree = \"<group>\"; };\n\t\t81845FFB1D3503E8004B0C46 /* RenderSkinnedAnimation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderSkinnedAnimation.h; sourceTree = \"<group>\"; };\n\t\t81845FFC1D3503E8004B0C46 /* Skeleton.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Skeleton.cpp; sourceTree = \"<group>\"; };\n\t\t81845FFD1D3503E8004B0C46 /* Skeleton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Skeleton.h; sourceTree = \"<group>\"; };\n\t\t81845FFE1D3503E8004B0C46 /* SkeletonDesc.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SkeletonDesc.cpp; sourceTree = \"<group>\"; };\n\t\t81845FFF1D3503E8004B0C46 /* SkeletonDesc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SkeletonDesc.h; sourceTree = \"<group>\"; };\n\t\t818460001D3503E8004B0C46 /* SkinnedAnimation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SkinnedAnimation.cpp; sourceTree = \"<group>\"; };\n\t\t818460011D3503E8004B0C46 /* SkinnedAnimation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SkinnedAnimation.h; sourceTree = \"<group>\"; };\n\t\t818460021D3503E8004B0C46 /* SkinnedAnimationGroup.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SkinnedAnimationGroup.cpp; sourceTree = \"<group>\"; };\n\t\t818460031D3503E8004B0C46 /* SkinnedAnimationGroup.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SkinnedAnimationGroup.h; sourceTree = \"<group>\"; };\n\t\t818460041D3503E8004B0C46 /* StaticModelComponent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StaticModelComponent.cpp; sourceTree = \"<group>\"; };\n\t\t818460051D3503E8004B0C46 /* StaticModelComponent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StaticModelComponent.h; sourceTree = \"<group>\"; };\n\t\t818460061D3503E8004B0C46 /* VertexFormat.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = VertexFormat.cpp; sourceTree = \"<group>\"; };\n\t\t818460071D3503E8004B0C46 /* VertexFormat.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VertexFormat.h; sourceTree = \"<group>\"; };\n\t\t818460081D3503E8004B0C46 /* Model.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Model.h; sourceTree = \"<group>\"; };\n\t\t8184600B1D3503E8004B0C46 /* AccelerationParticleAffector.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AccelerationParticleAffector.cpp; sourceTree = \"<group>\"; };\n\t\t8184600C1D3503E8004B0C46 /* AccelerationParticleAffector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AccelerationParticleAffector.h; sourceTree = \"<group>\"; };\n\t\t8184600D1D3503E8004B0C46 /* AccelerationParticleAffectorDef.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AccelerationParticleAffectorDef.cpp; sourceTree = \"<group>\"; };\n\t\t8184600E1D3503E8004B0C46 /* AccelerationParticleAffectorDef.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AccelerationParticleAffectorDef.h; sourceTree = \"<group>\"; };\n\t\t8184600F1D3503E8004B0C46 /* AngularAccelerationParticleAffector.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AngularAccelerationParticleAffector.cpp; sourceTree = \"<group>\"; };\n\t\t818460101D3503E8004B0C46 /* AngularAccelerationParticleAffector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AngularAccelerationParticleAffector.h; sourceTree = \"<group>\"; };\n\t\t818460111D3503E8004B0C46 /* AngularAccelerationParticleAffectorDef.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AngularAccelerationParticleAffectorDef.cpp; sourceTree = \"<group>\"; };\n\t\t818460121D3503E8004B0C46 /* AngularAccelerationParticleAffectorDef.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AngularAccelerationParticleAffectorDef.h; sourceTree = \"<group>\"; };\n\t\t818460131D3503E8004B0C46 /* ColourOverLifetimeParticleAffector.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ColourOverLifetimeParticleAffector.cpp; sourceTree = \"<group>\"; };\n\t\t818460141D3503E8004B0C46 /* ColourOverLifetimeParticleAffector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ColourOverLifetimeParticleAffector.h; sourceTree = \"<group>\"; };\n\t\t818460151D3503E8004B0C46 /* ColourOverLifetimeParticleAffectorDef.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ColourOverLifetimeParticleAffectorDef.cpp; sourceTree = \"<group>\"; };\n\t\t818460161D3503E8004B0C46 /* ColourOverLifetimeParticleAffectorDef.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ColourOverLifetimeParticleAffectorDef.h; sourceTree = \"<group>\"; };\n\t\t818460171D3503E8004B0C46 /* ParticleAffector.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ParticleAffector.cpp; sourceTree = \"<group>\"; };\n\t\t818460181D3503E8004B0C46 /* ParticleAffector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ParticleAffector.h; sourceTree = \"<group>\"; };\n\t\t818460191D3503E8004B0C46 /* ParticleAffectorDef.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ParticleAffectorDef.cpp; sourceTree = \"<group>\"; };\n\t\t8184601A1D3503E8004B0C46 /* ParticleAffectorDef.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ParticleAffectorDef.h; sourceTree = \"<group>\"; };\n\t\t8184601B1D3503E8004B0C46 /* ParticleAffectorDefFactory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ParticleAffectorDefFactory.cpp; sourceTree = \"<group>\"; };\n\t\t8184601C1D3503E8004B0C46 /* ParticleAffectorDefFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ParticleAffectorDefFactory.h; sourceTree = \"<group>\"; };\n\t\t8184601D1D3503E8004B0C46 /* ScaleOverLifetimeParticleAffector.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScaleOverLifetimeParticleAffector.cpp; sourceTree = \"<group>\"; };\n\t\t8184601E1D3503E8004B0C46 /* ScaleOverLifetimeParticleAffector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScaleOverLifetimeParticleAffector.h; sourceTree = \"<group>\"; };\n\t\t8184601F1D3503E8004B0C46 /* ScaleOverLifetimeParticleAffectorDef.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScaleOverLifetimeParticleAffectorDef.cpp; sourceTree = \"<group>\"; };\n\t\t818460201D3503E8004B0C46 /* ScaleOverLifetimeParticleAffectorDef.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScaleOverLifetimeParticleAffectorDef.h; sourceTree = \"<group>\"; };\n\t\t818460211D3503E8004B0C46 /* ConcurrentParticleData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ConcurrentParticleData.cpp; sourceTree = \"<group>\"; };\n\t\t818460221D3503E8004B0C46 /* ConcurrentParticleData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ConcurrentParticleData.h; sourceTree = \"<group>\"; };\n\t\t818460231D3503E8004B0C46 /* CSParticleProvider.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSParticleProvider.cpp; sourceTree = \"<group>\"; };\n\t\t818460241D3503E8004B0C46 /* CSParticleProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSParticleProvider.h; sourceTree = \"<group>\"; };\n\t\t818460261D3503E8004B0C46 /* ParticleDrawable.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ParticleDrawable.cpp; sourceTree = \"<group>\"; };\n\t\t818460271D3503E8004B0C46 /* ParticleDrawable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ParticleDrawable.h; sourceTree = \"<group>\"; };\n\t\t818460281D3503E8004B0C46 /* ParticleDrawableDef.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ParticleDrawableDef.cpp; sourceTree = \"<group>\"; };\n\t\t818460291D3503E8004B0C46 /* ParticleDrawableDef.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ParticleDrawableDef.h; sourceTree = \"<group>\"; };\n\t\t8184602A1D3503E8004B0C46 /* ParticleDrawableDefFactory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ParticleDrawableDefFactory.cpp; sourceTree = \"<group>\"; };\n\t\t8184602B1D3503E8004B0C46 /* ParticleDrawableDefFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ParticleDrawableDefFactory.h; sourceTree = \"<group>\"; };\n\t\t8184602C1D3503E8004B0C46 /* StaticBillboardParticleDrawable.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StaticBillboardParticleDrawable.cpp; sourceTree = \"<group>\"; };\n\t\t8184602D1D3503E8004B0C46 /* StaticBillboardParticleDrawable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StaticBillboardParticleDrawable.h; sourceTree = \"<group>\"; };\n\t\t8184602E1D3503E8004B0C46 /* StaticBillboardParticleDrawableDef.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StaticBillboardParticleDrawableDef.cpp; sourceTree = \"<group>\"; };\n\t\t8184602F1D3503E8004B0C46 /* StaticBillboardParticleDrawableDef.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StaticBillboardParticleDrawableDef.h; sourceTree = \"<group>\"; };\n\t\t818460311D3503E8004B0C46 /* CircleParticleEmitter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CircleParticleEmitter.cpp; sourceTree = \"<group>\"; };\n\t\t818460321D3503E8004B0C46 /* CircleParticleEmitter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CircleParticleEmitter.h; sourceTree = \"<group>\"; };\n\t\t818460331D3503E8004B0C46 /* CircleParticleEmitterDef.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CircleParticleEmitterDef.cpp; sourceTree = \"<group>\"; };\n\t\t818460341D3503E8004B0C46 /* CircleParticleEmitterDef.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CircleParticleEmitterDef.h; sourceTree = \"<group>\"; };\n\t\t818460351D3503E8004B0C46 /* Cone2DParticleEmitter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Cone2DParticleEmitter.cpp; sourceTree = \"<group>\"; };\n\t\t818460361D3503E8004B0C46 /* Cone2DParticleEmitter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Cone2DParticleEmitter.h; sourceTree = \"<group>\"; };\n\t\t818460371D3503E8004B0C46 /* Cone2DParticleEmitterDef.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Cone2DParticleEmitterDef.cpp; sourceTree = \"<group>\"; };\n\t\t818460381D3503E8004B0C46 /* Cone2DParticleEmitterDef.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Cone2DParticleEmitterDef.h; sourceTree = \"<group>\"; };\n\t\t818460391D3503E8004B0C46 /* ConeParticleEmitter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ConeParticleEmitter.cpp; sourceTree = \"<group>\"; };\n\t\t8184603A1D3503E8004B0C46 /* ConeParticleEmitter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ConeParticleEmitter.h; sourceTree = \"<group>\"; };\n\t\t8184603B1D3503E8004B0C46 /* ConeParticleEmitterDef.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ConeParticleEmitterDef.cpp; sourceTree = \"<group>\"; };\n\t\t8184603C1D3503E8004B0C46 /* ConeParticleEmitterDef.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ConeParticleEmitterDef.h; sourceTree = \"<group>\"; };\n\t\t8184603D1D3503E8004B0C46 /* ParticleEmitter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ParticleEmitter.cpp; sourceTree = \"<group>\"; };\n\t\t8184603E1D3503E8004B0C46 /* ParticleEmitter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ParticleEmitter.h; sourceTree = \"<group>\"; };\n\t\t8184603F1D3503E8004B0C46 /* ParticleEmitterDef.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ParticleEmitterDef.cpp; sourceTree = \"<group>\"; };\n\t\t818460401D3503E8004B0C46 /* ParticleEmitterDef.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ParticleEmitterDef.h; sourceTree = \"<group>\"; };\n\t\t818460411D3503E8004B0C46 /* ParticleEmitterDefFactory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ParticleEmitterDefFactory.cpp; sourceTree = \"<group>\"; };\n\t\t818460421D3503E8004B0C46 /* ParticleEmitterDefFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ParticleEmitterDefFactory.h; sourceTree = \"<group>\"; };\n\t\t818460431D3503E8004B0C46 /* PointParticleEmitter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PointParticleEmitter.cpp; sourceTree = \"<group>\"; };\n\t\t818460441D3503E8004B0C46 /* PointParticleEmitter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PointParticleEmitter.h; sourceTree = \"<group>\"; };\n\t\t818460451D3503E8004B0C46 /* PointParticleEmitterDef.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PointParticleEmitterDef.cpp; sourceTree = \"<group>\"; };\n\t\t818460461D3503E8004B0C46 /* PointParticleEmitterDef.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PointParticleEmitterDef.h; sourceTree = \"<group>\"; };\n\t\t818460471D3503E8004B0C46 /* SphereParticleEmitter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SphereParticleEmitter.cpp; sourceTree = \"<group>\"; };\n\t\t818460481D3503E8004B0C46 /* SphereParticleEmitter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SphereParticleEmitter.h; sourceTree = \"<group>\"; };\n\t\t818460491D3503E8004B0C46 /* SphereParticleEmitterDef.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SphereParticleEmitterDef.cpp; sourceTree = \"<group>\"; };\n\t\t8184604A1D3503E8004B0C46 /* SphereParticleEmitterDef.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SphereParticleEmitterDef.h; sourceTree = \"<group>\"; };\n\t\t8184604B1D3503E8004B0C46 /* Particle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Particle.h; sourceTree = \"<group>\"; };\n\t\t8184604C1D3503E8004B0C46 /* ParticleEffect.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ParticleEffect.cpp; sourceTree = \"<group>\"; };\n\t\t8184604D1D3503E8004B0C46 /* ParticleEffect.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ParticleEffect.h; sourceTree = \"<group>\"; };\n\t\t8184604E1D3503E8004B0C46 /* ParticleEffectComponent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ParticleEffectComponent.cpp; sourceTree = \"<group>\"; };\n\t\t8184604F1D3503E8004B0C46 /* ParticleEffectComponent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ParticleEffectComponent.h; sourceTree = \"<group>\"; };\n\t\t818460511D3503E8004B0C46 /* ComponentwiseRandomConstantParticleProperty.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ComponentwiseRandomConstantParticleProperty.h; sourceTree = \"<group>\"; };\n\t\t818460521D3503E8004B0C46 /* ComponentwiseRandomCurveParticleProperty.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ComponentwiseRandomCurveParticleProperty.h; sourceTree = \"<group>\"; };\n\t\t818460531D3503E8004B0C46 /* ConstantParticleProperty.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ConstantParticleProperty.h; sourceTree = \"<group>\"; };\n\t\t818460541D3503E8004B0C46 /* CurveParticleProperty.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CurveParticleProperty.h; sourceTree = \"<group>\"; };\n\t\t818460551D3503E8004B0C46 /* ParticleProperty.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ParticleProperty.h; sourceTree = \"<group>\"; };\n\t\t818460561D3503E8004B0C46 /* ParticlePropertyFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ParticlePropertyFactory.h; sourceTree = \"<group>\"; };\n\t\t818460571D3503E8004B0C46 /* ParticlePropertyFactoryImpl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ParticlePropertyFactoryImpl.cpp; sourceTree = \"<group>\"; };\n\t\t818460581D3503E8004B0C46 /* ParticlePropertyFactoryImpl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ParticlePropertyFactoryImpl.h; sourceTree = \"<group>\"; };\n\t\t818460591D3503E8004B0C46 /* RandomConstantParticleProperty.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RandomConstantParticleProperty.h; sourceTree = \"<group>\"; };\n\t\t8184605A1D3503E8004B0C46 /* RandomCurveParticleProperty.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RandomCurveParticleProperty.h; sourceTree = \"<group>\"; };\n\t\t8184605B1D3503E8004B0C46 /* Particle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Particle.h; sourceTree = \"<group>\"; };\n\t\t8184605E1D3503E8004B0C46 /* ApplyAmbientLightRenderCommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ApplyAmbientLightRenderCommand.cpp; sourceTree = \"<group>\"; };\n\t\t8184605F1D3503E8004B0C46 /* ApplyAmbientLightRenderCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ApplyAmbientLightRenderCommand.h; sourceTree = \"<group>\"; };\n\t\t818460601D3503E8004B0C46 /* ApplyCameraRenderCommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ApplyCameraRenderCommand.cpp; sourceTree = \"<group>\"; };\n\t\t818460611D3503E8004B0C46 /* ApplyCameraRenderCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ApplyCameraRenderCommand.h; sourceTree = \"<group>\"; };\n\t\t818460621D3503E8004B0C46 /* ApplyDirectionalLightRenderCommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ApplyDirectionalLightRenderCommand.cpp; sourceTree = \"<group>\"; };\n\t\t818460631D3503E8004B0C46 /* ApplyDirectionalLightRenderCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ApplyDirectionalLightRenderCommand.h; sourceTree = \"<group>\"; };\n\t\t818460641D3503E8004B0C46 /* ApplyDynamicMeshRenderCommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ApplyDynamicMeshRenderCommand.cpp; sourceTree = \"<group>\"; };\n\t\t818460651D3503E8004B0C46 /* ApplyDynamicMeshRenderCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ApplyDynamicMeshRenderCommand.h; sourceTree = \"<group>\"; };\n\t\t818460661D3503E8004B0C46 /* ApplyMaterialRenderCommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ApplyMaterialRenderCommand.cpp; sourceTree = \"<group>\"; };\n\t\t818460671D3503E8004B0C46 /* ApplyMaterialRenderCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ApplyMaterialRenderCommand.h; sourceTree = \"<group>\"; };\n\t\t818460681D3503E8004B0C46 /* ApplyMeshRenderCommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ApplyMeshRenderCommand.cpp; sourceTree = \"<group>\"; };\n\t\t818460691D3503E8004B0C46 /* ApplyMeshRenderCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ApplyMeshRenderCommand.h; sourceTree = \"<group>\"; };\n\t\t8184606A1D3503E8004B0C46 /* ApplyPointLightRenderCommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ApplyPointLightRenderCommand.cpp; sourceTree = \"<group>\"; };\n\t\t8184606B1D3503E8004B0C46 /* ApplyPointLightRenderCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ApplyPointLightRenderCommand.h; sourceTree = \"<group>\"; };\n\t\t8184606C1D3503E8004B0C46 /* ApplySkinnedAnimationRenderCommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ApplySkinnedAnimationRenderCommand.cpp; sourceTree = \"<group>\"; };\n\t\t8184606D1D3503E8004B0C46 /* ApplySkinnedAnimationRenderCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ApplySkinnedAnimationRenderCommand.h; sourceTree = \"<group>\"; };\n\t\t8184606E1D3503E8004B0C46 /* BeginRenderCommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BeginRenderCommand.cpp; sourceTree = \"<group>\"; };\n\t\t8184606F1D3503E8004B0C46 /* BeginRenderCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BeginRenderCommand.h; sourceTree = \"<group>\"; };\n\t\t818460701D3503E8004B0C46 /* BeginWithTargetGroupRenderCommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BeginWithTargetGroupRenderCommand.cpp; sourceTree = \"<group>\"; };\n\t\t818460711D3503E8004B0C46 /* BeginWithTargetGroupRenderCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BeginWithTargetGroupRenderCommand.h; sourceTree = \"<group>\"; };\n\t\t818460721D3503E8004B0C46 /* EndRenderCommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EndRenderCommand.cpp; sourceTree = \"<group>\"; };\n\t\t818460731D3503E8004B0C46 /* EndRenderCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EndRenderCommand.h; sourceTree = \"<group>\"; };\n\t\t818460741D3503E8004B0C46 /* LoadMaterialGroupRenderCommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LoadMaterialGroupRenderCommand.cpp; sourceTree = \"<group>\"; };\n\t\t818460751D3503E8004B0C46 /* LoadMaterialGroupRenderCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LoadMaterialGroupRenderCommand.h; sourceTree = \"<group>\"; };\n\t\t818460761D3503E8004B0C46 /* LoadMeshRenderCommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LoadMeshRenderCommand.cpp; sourceTree = \"<group>\"; };\n\t\t818460771D3503E8004B0C46 /* LoadMeshRenderCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LoadMeshRenderCommand.h; sourceTree = \"<group>\"; };\n\t\t818460781D3503E8004B0C46 /* LoadShaderRenderCommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LoadShaderRenderCommand.cpp; sourceTree = \"<group>\"; };\n\t\t818460791D3503E8004B0C46 /* LoadShaderRenderCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LoadShaderRenderCommand.h; sourceTree = \"<group>\"; };\n\t\t8184607A1D3503E8004B0C46 /* LoadTargetGroupRenderCommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LoadTargetGroupRenderCommand.cpp; sourceTree = \"<group>\"; };\n\t\t8184607B1D3503E8004B0C46 /* LoadTargetGroupRenderCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LoadTargetGroupRenderCommand.h; sourceTree = \"<group>\"; };\n\t\t8184607C1D3503E8004B0C46 /* LoadTextureRenderCommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LoadTextureRenderCommand.cpp; sourceTree = \"<group>\"; };\n\t\t8184607D1D3503E8004B0C46 /* LoadTextureRenderCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LoadTextureRenderCommand.h; sourceTree = \"<group>\"; };\n\t\t8184607E1D3503E8004B0C46 /* RenderInstanceRenderCommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderInstanceRenderCommand.cpp; sourceTree = \"<group>\"; };\n\t\t8184607F1D3503E8004B0C46 /* RenderInstanceRenderCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderInstanceRenderCommand.h; sourceTree = \"<group>\"; };\n\t\t818460801D3503E8004B0C46 /* RestoreMeshRenderCommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RestoreMeshRenderCommand.cpp; sourceTree = \"<group>\"; };\n\t\t818460811D3503E8004B0C46 /* RestoreMeshRenderCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RestoreMeshRenderCommand.h; sourceTree = \"<group>\"; };\n\t\t818460821D3503E8004B0C46 /* RestoreTextureRenderCommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RestoreTextureRenderCommand.cpp; sourceTree = \"<group>\"; };\n\t\t818460831D3503E8004B0C46 /* RestoreTextureRenderCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RestoreTextureRenderCommand.h; sourceTree = \"<group>\"; };\n\t\t818460841D3503E8004B0C46 /* UnloadMaterialGroupRenderCommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UnloadMaterialGroupRenderCommand.cpp; sourceTree = \"<group>\"; };\n\t\t818460851D3503E8004B0C46 /* UnloadMaterialGroupRenderCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UnloadMaterialGroupRenderCommand.h; sourceTree = \"<group>\"; };\n\t\t818460861D3503E8004B0C46 /* UnloadMeshRenderCommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UnloadMeshRenderCommand.cpp; sourceTree = \"<group>\"; };\n\t\t818460871D3503E8004B0C46 /* UnloadMeshRenderCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UnloadMeshRenderCommand.h; sourceTree = \"<group>\"; };\n\t\t818460881D3503E8004B0C46 /* UnloadShaderRenderCommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UnloadShaderRenderCommand.cpp; sourceTree = \"<group>\"; };\n\t\t818460891D3503E8004B0C46 /* UnloadShaderRenderCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UnloadShaderRenderCommand.h; sourceTree = \"<group>\"; };\n\t\t8184608A1D3503E8004B0C46 /* UnloadTargetGroupRenderCommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UnloadTargetGroupRenderCommand.cpp; sourceTree = \"<group>\"; };\n\t\t8184608B1D3503E8004B0C46 /* UnloadTargetGroupRenderCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UnloadTargetGroupRenderCommand.h; sourceTree = \"<group>\"; };\n\t\t8184608C1D3503E8004B0C46 /* UnloadTextureRenderCommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UnloadTextureRenderCommand.cpp; sourceTree = \"<group>\"; };\n\t\t8184608D1D3503E8004B0C46 /* UnloadTextureRenderCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UnloadTextureRenderCommand.h; sourceTree = \"<group>\"; };\n\t\t8184608E1D3503E8004B0C46 /* RenderCommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderCommand.cpp; sourceTree = \"<group>\"; };\n\t\t8184608F1D3503E8004B0C46 /* RenderCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderCommand.h; sourceTree = \"<group>\"; };\n\t\t818460901D3503E8004B0C46 /* RenderCommandBuffer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderCommandBuffer.cpp; sourceTree = \"<group>\"; };\n\t\t818460911D3503E8004B0C46 /* RenderCommandBuffer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderCommandBuffer.h; sourceTree = \"<group>\"; };\n\t\t818460921D3503E8004B0C46 /* RenderCommandList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderCommandList.cpp; sourceTree = \"<group>\"; };\n\t\t818460931D3503E8004B0C46 /* RenderCommandList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderCommandList.h; sourceTree = \"<group>\"; };\n\t\t818460941D3503E8004B0C46 /* RenderCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderCommand.h; sourceTree = \"<group>\"; };\n\t\t818460961D3503E8004B0C46 /* CSShaderProvider.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSShaderProvider.cpp; sourceTree = \"<group>\"; };\n\t\t818460971D3503E8004B0C46 /* CSShaderProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSShaderProvider.h; sourceTree = \"<group>\"; };\n\t\t818460981D3503E8004B0C46 /* RenderShader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderShader.h; sourceTree = \"<group>\"; };\n\t\t818460991D3503E8004B0C46 /* RenderShaderManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderShaderManager.cpp; sourceTree = \"<group>\"; };\n\t\t8184609A1D3503E8004B0C46 /* RenderShaderManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderShaderManager.h; sourceTree = \"<group>\"; };\n\t\t8184609B1D3503E8004B0C46 /* RenderShaderVariables.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderShaderVariables.cpp; sourceTree = \"<group>\"; };\n\t\t8184609C1D3503E8004B0C46 /* RenderShaderVariables.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderShaderVariables.h; sourceTree = \"<group>\"; };\n\t\t8184609D1D3503E8004B0C46 /* Shader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Shader.cpp; sourceTree = \"<group>\"; };\n\t\t8184609E1D3503E8004B0C46 /* Shader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Shader.h; sourceTree = \"<group>\"; };\n\t\t8184609F1D3503E8004B0C46 /* Shader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Shader.h; sourceTree = \"<group>\"; };\n\t\t818460A11D3503E8004B0C46 /* SpriteComponent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SpriteComponent.cpp; sourceTree = \"<group>\"; };\n\t\t818460A21D3503E8004B0C46 /* SpriteComponent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SpriteComponent.h; sourceTree = \"<group>\"; };\n\t\t818460A31D3503E8004B0C46 /* SpriteMeshBuilder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SpriteMeshBuilder.cpp; sourceTree = \"<group>\"; };\n\t\t818460A41D3503E8004B0C46 /* SpriteMeshBuilder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SpriteMeshBuilder.h; sourceTree = \"<group>\"; };\n\t\t818460A51D3503E8004B0C46 /* Sprite.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Sprite.h; sourceTree = \"<group>\"; };\n\t\t818460A71D3503E8004B0C46 /* RenderTargetGroup.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderTargetGroup.cpp; sourceTree = \"<group>\"; };\n\t\t818460A81D3503E8004B0C46 /* RenderTargetGroup.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderTargetGroup.h; sourceTree = \"<group>\"; };\n\t\t818460A91D3503E8004B0C46 /* RenderTargetGroupManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderTargetGroupManager.cpp; sourceTree = \"<group>\"; };\n\t\t818460AA1D3503E8004B0C46 /* RenderTargetGroupManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderTargetGroupManager.h; sourceTree = \"<group>\"; };\n\t\t818460AB1D3503E8004B0C46 /* Target.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Target.h; sourceTree = \"<group>\"; };\n\t\t818460B31D3503E8004B0C46 /* RenderTexture.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderTexture.cpp; sourceTree = \"<group>\"; };\n\t\t818460B41D3503E8004B0C46 /* RenderTexture.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderTexture.h; sourceTree = \"<group>\"; };\n\t\t818460B51D3503E8004B0C46 /* RenderTextureManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderTextureManager.cpp; sourceTree = \"<group>\"; };\n\t\t818460B61D3503E8004B0C46 /* RenderTextureManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderTextureManager.h; sourceTree = \"<group>\"; };\n\t\t818460B71D3503E8004B0C46 /* Texture.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Texture.cpp; sourceTree = \"<group>\"; };\n\t\t818460B81D3503E8004B0C46 /* Texture.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Texture.h; sourceTree = \"<group>\"; };\n\t\t818460B91D3503E8004B0C46 /* TextureAtlas.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextureAtlas.cpp; sourceTree = \"<group>\"; };\n\t\t818460BA1D3503E8004B0C46 /* TextureAtlas.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextureAtlas.h; sourceTree = \"<group>\"; };\n\t\t818460BB1D3503E8004B0C46 /* TextureAtlasProvider.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextureAtlasProvider.cpp; sourceTree = \"<group>\"; };\n\t\t818460BC1D3503E8004B0C46 /* TextureAtlasProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextureAtlasProvider.h; sourceTree = \"<group>\"; };\n\t\t818460BD1D3503E8004B0C46 /* TextureDesc.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextureDesc.cpp; sourceTree = \"<group>\"; };\n\t\t818460BE1D3503E8004B0C46 /* TextureDesc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextureDesc.h; sourceTree = \"<group>\"; };\n\t\t818460BF1D3503E8004B0C46 /* TextureFilterMode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextureFilterMode.h; sourceTree = \"<group>\"; };\n\t\t818460C01D3503E8004B0C46 /* TextureProvider.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextureProvider.cpp; sourceTree = \"<group>\"; };\n\t\t818460C11D3503E8004B0C46 /* TextureProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextureProvider.h; sourceTree = \"<group>\"; };\n\t\t818460C21D3503E8004B0C46 /* TextureResourceOptions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextureResourceOptions.cpp; sourceTree = \"<group>\"; };\n\t\t818460C31D3503E8004B0C46 /* TextureResourceOptions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextureResourceOptions.h; sourceTree = \"<group>\"; };\n\t\t818460C41D3503E8004B0C46 /* TextureWrapMode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextureWrapMode.h; sourceTree = \"<group>\"; };\n\t\t818460C51D3503E8004B0C46 /* UVs.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UVs.cpp; sourceTree = \"<group>\"; };\n\t\t818460C61D3503E8004B0C46 /* UVs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UVs.h; sourceTree = \"<group>\"; };\n\t\t818460C71D3503E8004B0C46 /* Texture.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Texture.h; sourceTree = \"<group>\"; };\n\t\t818460CA1D3503E8004B0C46 /* EmailComposer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EmailComposer.cpp; sourceTree = \"<group>\"; };\n\t\t818460CB1D3503E8004B0C46 /* EmailComposer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EmailComposer.h; sourceTree = \"<group>\"; };\n\t\t818460CC1D3503E8004B0C46 /* Communications.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Communications.h; sourceTree = \"<group>\"; };\n\t\t818460D31D3503E8004B0C46 /* ForwardDeclarations.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ForwardDeclarations.h; sourceTree = \"<group>\"; };\n\t\t818460D61D3503E8004B0C46 /* Canvas.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Canvas.cpp; sourceTree = \"<group>\"; };\n\t\t818460D71D3503E8004B0C46 /* Canvas.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Canvas.h; sourceTree = \"<group>\"; };\n\t\t818460D81D3503E8004B0C46 /* PropertyLink.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PropertyLink.cpp; sourceTree = \"<group>\"; };\n\t\t818460D91D3503E8004B0C46 /* PropertyLink.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PropertyLink.h; sourceTree = \"<group>\"; };\n\t\t818460DA1D3503E8004B0C46 /* PropertyTypes.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PropertyTypes.cpp; sourceTree = \"<group>\"; };\n\t\t818460DB1D3503E8004B0C46 /* PropertyTypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PropertyTypes.h; sourceTree = \"<group>\"; };\n\t\t818460DC1D3503E8004B0C46 /* UIComponent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UIComponent.cpp; sourceTree = \"<group>\"; };\n\t\t818460DD1D3503E8004B0C46 /* UIComponent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIComponent.h; sourceTree = \"<group>\"; };\n\t\t818460DE1D3503E8004B0C46 /* UIComponentDesc.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UIComponentDesc.cpp; sourceTree = \"<group>\"; };\n\t\t818460DF1D3503E8004B0C46 /* UIComponentDesc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIComponentDesc.h; sourceTree = \"<group>\"; };\n\t\t818460E01D3503E8004B0C46 /* UIComponentFactory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UIComponentFactory.cpp; sourceTree = \"<group>\"; };\n\t\t818460E11D3503E8004B0C46 /* UIComponentFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIComponentFactory.h; sourceTree = \"<group>\"; };\n\t\t818460E21D3503E8004B0C46 /* Widget.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Widget.cpp; sourceTree = \"<group>\"; };\n\t\t818460E31D3503E8004B0C46 /* Widget.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Widget.h; sourceTree = \"<group>\"; };\n\t\t818460E41D3503E8004B0C46 /* WidgetDef.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WidgetDef.cpp; sourceTree = \"<group>\"; };\n\t\t818460E51D3503E8004B0C46 /* WidgetDef.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WidgetDef.h; sourceTree = \"<group>\"; };\n\t\t818460E61D3503E8004B0C46 /* WidgetDefProvider.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WidgetDefProvider.cpp; sourceTree = \"<group>\"; };\n\t\t818460E71D3503E8004B0C46 /* WidgetDefProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WidgetDefProvider.h; sourceTree = \"<group>\"; };\n\t\t818460E81D3503E8004B0C46 /* WidgetDesc.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WidgetDesc.cpp; sourceTree = \"<group>\"; };\n\t\t818460E91D3503E8004B0C46 /* WidgetDesc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WidgetDesc.h; sourceTree = \"<group>\"; };\n\t\t818460EA1D3503E8004B0C46 /* WidgetFactory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WidgetFactory.cpp; sourceTree = \"<group>\"; };\n\t\t818460EB1D3503E8004B0C46 /* WidgetFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WidgetFactory.h; sourceTree = \"<group>\"; };\n\t\t818460EC1D3503E8004B0C46 /* WidgetParserUtils.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WidgetParserUtils.cpp; sourceTree = \"<group>\"; };\n\t\t818460ED1D3503E8004B0C46 /* WidgetParserUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WidgetParserUtils.h; sourceTree = \"<group>\"; };\n\t\t818460EE1D3503E8004B0C46 /* WidgetTemplate.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WidgetTemplate.cpp; sourceTree = \"<group>\"; };\n\t\t818460EF1D3503E8004B0C46 /* WidgetTemplate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WidgetTemplate.h; sourceTree = \"<group>\"; };\n\t\t818460F01D3503E8004B0C46 /* WidgetTemplateProvider.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WidgetTemplateProvider.cpp; sourceTree = \"<group>\"; };\n\t\t818460F11D3503E8004B0C46 /* WidgetTemplateProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WidgetTemplateProvider.h; sourceTree = \"<group>\"; };\n\t\t818460F21D3503E8004B0C46 /* Base.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Base.h; sourceTree = \"<group>\"; };\n\t\t818460F41D3503E8004B0C46 /* HighlightUIComponent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HighlightUIComponent.cpp; sourceTree = \"<group>\"; };\n\t\t818460F51D3503E8004B0C46 /* HighlightUIComponent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HighlightUIComponent.h; sourceTree = \"<group>\"; };\n\t\t818460F61D3503E8004B0C46 /* ToggleHighlightUIComponent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ToggleHighlightUIComponent.cpp; sourceTree = \"<group>\"; };\n\t\t818460F71D3503E8004B0C46 /* ToggleHighlightUIComponent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ToggleHighlightUIComponent.h; sourceTree = \"<group>\"; };\n\t\t818460F81D3503E8004B0C46 /* Button.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Button.h; sourceTree = \"<group>\"; };\n\t\t818460FA1D3503E8004B0C46 /* DrawableUIComponent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DrawableUIComponent.cpp; sourceTree = \"<group>\"; };\n\t\t818460FB1D3503E8004B0C46 /* DrawableUIComponent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DrawableUIComponent.h; sourceTree = \"<group>\"; };\n\t\t818460FC1D3503E8004B0C46 /* NinePatchUIDrawable.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NinePatchUIDrawable.cpp; sourceTree = \"<group>\"; };\n\t\t818460FD1D3503E8004B0C46 /* NinePatchUIDrawable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NinePatchUIDrawable.h; sourceTree = \"<group>\"; };\n\t\t818460FE1D3503E8004B0C46 /* NinePatchUIDrawableDef.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NinePatchUIDrawableDef.cpp; sourceTree = \"<group>\"; };\n\t\t818460FF1D3503E8004B0C46 /* NinePatchUIDrawableDef.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NinePatchUIDrawableDef.h; sourceTree = \"<group>\"; };\n\t\t818461001D3503E8004B0C46 /* StandardUIDrawable.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StandardUIDrawable.cpp; sourceTree = \"<group>\"; };\n\t\t818461011D3503E8004B0C46 /* StandardUIDrawable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StandardUIDrawable.h; sourceTree = \"<group>\"; };\n\t\t818461021D3503E8004B0C46 /* StandardUIDrawableDef.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StandardUIDrawableDef.cpp; sourceTree = \"<group>\"; };\n\t\t818461031D3503E8004B0C46 /* StandardUIDrawableDef.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StandardUIDrawableDef.h; sourceTree = \"<group>\"; };\n\t\t818461041D3503E8004B0C46 /* ThreePatchUIDrawable.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ThreePatchUIDrawable.cpp; sourceTree = \"<group>\"; };\n\t\t818461051D3503E8004B0C46 /* ThreePatchUIDrawable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ThreePatchUIDrawable.h; sourceTree = \"<group>\"; };\n\t\t818461061D3503E8004B0C46 /* ThreePatchUIDrawableDef.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ThreePatchUIDrawableDef.cpp; sourceTree = \"<group>\"; };\n\t\t818461071D3503E8004B0C46 /* ThreePatchUIDrawableDef.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ThreePatchUIDrawableDef.h; sourceTree = \"<group>\"; };\n\t\t818461081D3503E8004B0C46 /* UIDrawable.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UIDrawable.cpp; sourceTree = \"<group>\"; };\n\t\t818461091D3503E8004B0C46 /* UIDrawable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIDrawable.h; sourceTree = \"<group>\"; };\n\t\t8184610A1D3503E8004B0C46 /* UIDrawableDef.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UIDrawableDef.cpp; sourceTree = \"<group>\"; };\n\t\t8184610B1D3503E8004B0C46 /* UIDrawableDef.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIDrawableDef.h; sourceTree = \"<group>\"; };\n\t\t8184610C1D3503E8004B0C46 /* UIDrawableUtils.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UIDrawableUtils.cpp; sourceTree = \"<group>\"; };\n\t\t8184610D1D3503E8004B0C46 /* UIDrawableUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIDrawableUtils.h; sourceTree = \"<group>\"; };\n\t\t8184610E1D3503E8004B0C46 /* Drawable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Drawable.h; sourceTree = \"<group>\"; };\n\t\t8184610F1D3503E8004B0C46 /* ForwardDeclarations.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ForwardDeclarations.h; sourceTree = \"<group>\"; };\n\t\t818461111D3503E8004B0C46 /* GridUILayout.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GridUILayout.cpp; sourceTree = \"<group>\"; };\n\t\t818461121D3503E8004B0C46 /* GridUILayout.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GridUILayout.h; sourceTree = \"<group>\"; };\n\t\t818461131D3503E8004B0C46 /* GridUILayoutDef.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GridUILayoutDef.cpp; sourceTree = \"<group>\"; };\n\t\t818461141D3503E8004B0C46 /* GridUILayoutDef.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GridUILayoutDef.h; sourceTree = \"<group>\"; };\n\t\t818461151D3503E8004B0C46 /* HListUILayout.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HListUILayout.cpp; sourceTree = \"<group>\"; };\n\t\t818461161D3503E8004B0C46 /* HListUILayout.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HListUILayout.h; sourceTree = \"<group>\"; };\n\t\t818461171D3503E8004B0C46 /* HListUILayoutDef.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HListUILayoutDef.cpp; sourceTree = \"<group>\"; };\n\t\t818461181D3503E8004B0C46 /* HListUILayoutDef.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HListUILayoutDef.h; sourceTree = \"<group>\"; };\n\t\t818461191D3503E8004B0C46 /* LayoutDef.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LayoutDef.h; sourceTree = \"<group>\"; };\n\t\t8184611A1D3503E8004B0C46 /* LayoutUIComponent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LayoutUIComponent.cpp; sourceTree = \"<group>\"; };\n\t\t8184611B1D3503E8004B0C46 /* LayoutUIComponent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LayoutUIComponent.h; sourceTree = \"<group>\"; };\n\t\t8184611C1D3503E8004B0C46 /* UILayout.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UILayout.cpp; sourceTree = \"<group>\"; };\n\t\t8184611D1D3503E8004B0C46 /* UILayout.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UILayout.h; sourceTree = \"<group>\"; };\n\t\t8184611E1D3503E8004B0C46 /* UILayoutDef.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UILayoutDef.cpp; sourceTree = \"<group>\"; };\n\t\t8184611F1D3503E8004B0C46 /* UILayoutDef.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UILayoutDef.h; sourceTree = \"<group>\"; };\n\t\t818461201D3503E8004B0C46 /* VListUILayout.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = VListUILayout.cpp; sourceTree = \"<group>\"; };\n\t\t818461211D3503E8004B0C46 /* VListUILayout.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VListUILayout.h; sourceTree = \"<group>\"; };\n\t\t818461221D3503E8004B0C46 /* VListUILayoutDef.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = VListUILayoutDef.cpp; sourceTree = \"<group>\"; };\n\t\t818461231D3503E8004B0C46 /* VListUILayoutDef.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VListUILayoutDef.h; sourceTree = \"<group>\"; };\n\t\t818461241D3503E8004B0C46 /* Layout.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Layout.h; sourceTree = \"<group>\"; };\n\t\t818461261D3503E8004B0C46 /* ProgressBarDirection.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ProgressBarDirection.cpp; sourceTree = \"<group>\"; };\n\t\t818461271D3503E8004B0C46 /* ProgressBarDirection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProgressBarDirection.h; sourceTree = \"<group>\"; };\n\t\t818461281D3503E8004B0C46 /* ProgressBarType.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ProgressBarType.cpp; sourceTree = \"<group>\"; };\n\t\t818461291D3503E8004B0C46 /* ProgressBarType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProgressBarType.h; sourceTree = \"<group>\"; };\n\t\t8184612A1D3503E8004B0C46 /* ProgressBarUIComponent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ProgressBarUIComponent.cpp; sourceTree = \"<group>\"; };\n\t\t8184612B1D3503E8004B0C46 /* ProgressBarUIComponent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProgressBarUIComponent.h; sourceTree = \"<group>\"; };\n\t\t8184612C1D3503E8004B0C46 /* ProgressBar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProgressBar.h; sourceTree = \"<group>\"; };\n\t\t8184612E1D3503E8004B0C46 /* SliderDirection.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SliderDirection.cpp; sourceTree = \"<group>\"; };\n\t\t8184612F1D3503E8004B0C46 /* SliderDirection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SliderDirection.h; sourceTree = \"<group>\"; };\n\t\t818461301D3503E8004B0C46 /* SliderUIComponent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SliderUIComponent.cpp; sourceTree = \"<group>\"; };\n\t\t818461311D3503E8004B0C46 /* SliderUIComponent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SliderUIComponent.h; sourceTree = \"<group>\"; };\n\t\t818461321D3503E8004B0C46 /* Slider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Slider.h; sourceTree = \"<group>\"; };\n\t\t818461341D3503E8004B0C46 /* EditableTextUIComponent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EditableTextUIComponent.cpp; sourceTree = \"<group>\"; };\n\t\t818461351D3503E8004B0C46 /* EditableTextUIComponent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EditableTextUIComponent.h; sourceTree = \"<group>\"; };\n\t\t818461361D3503E8004B0C46 /* TextComponent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextComponent.h; sourceTree = \"<group>\"; };\n\t\t818461371D3503E8004B0C46 /* TextIcon.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextIcon.cpp; sourceTree = \"<group>\"; };\n\t\t818461381D3503E8004B0C46 /* TextIcon.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextIcon.h; sourceTree = \"<group>\"; };\n\t\t818461391D3503E8004B0C46 /* TextUIComponent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextUIComponent.cpp; sourceTree = \"<group>\"; };\n\t\t8184613A1D3503E8004B0C46 /* TextUIComponent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextUIComponent.h; sourceTree = \"<group>\"; };\n\t\t8184613B1D3503E8004B0C46 /* Text.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Text.h; sourceTree = \"<group>\"; };\n\t\t8184613E1D3503E8004B0C46 /* CSSubtitlesProvider.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSSubtitlesProvider.cpp; sourceTree = \"<group>\"; };\n\t\t8184613F1D3503E8004B0C46 /* CSSubtitlesProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSubtitlesProvider.h; sourceTree = \"<group>\"; };\n\t\t818461401D3503E8004B0C46 /* Subtitles.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Subtitles.cpp; sourceTree = \"<group>\"; };\n\t\t818461411D3503E8004B0C46 /* Subtitles.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Subtitles.h; sourceTree = \"<group>\"; };\n\t\t818461421D3503E8004B0C46 /* VideoPlayer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = VideoPlayer.cpp; sourceTree = \"<group>\"; };\n\t\t818461431D3503E8004B0C46 /* VideoPlayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VideoPlayer.h; sourceTree = \"<group>\"; };\n\t\t818461441D3503E8004B0C46 /* Base.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Base.h; sourceTree = \"<group>\"; };\n\t\t818461451D3503E8004B0C46 /* ForwardDeclarations.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ForwardDeclarations.h; sourceTree = \"<group>\"; };\n\t\t818461481D3503E8004B0C46 /* WebView.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebView.cpp; sourceTree = \"<group>\"; };\n\t\t818461491D3503E8004B0C46 /* WebView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebView.h; sourceTree = \"<group>\"; };\n\t\t8184614A1D3503E8004B0C46 /* Base.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Base.h; sourceTree = \"<group>\"; };\n\t\t8184614B1D3503E8004B0C46 /* ForwardDeclarations.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ForwardDeclarations.h; sourceTree = \"<group>\"; };\n\t\t8184627B1D350409004B0C46 /* GLSkinnedAnimation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GLSkinnedAnimation.cpp; sourceTree = \"<group>\"; };\n\t\t8184627C1D350409004B0C46 /* GLSkinnedAnimation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GLSkinnedAnimation.h; sourceTree = \"<group>\"; };\n\t\t818463671D353765004B0C46 /* SmallMeshBatcher.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SmallMeshBatcher.cpp; sourceTree = \"<group>\"; };\n\t\t818463681D353765004B0C46 /* SmallMeshBatcher.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SmallMeshBatcher.h; sourceTree = \"<group>\"; };\n\t\t8184636A1D35493A004B0C46 /* ApplyMeshBatchRenderCommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ApplyMeshBatchRenderCommand.cpp; sourceTree = \"<group>\"; };\n\t\t8184636B1D35493A004B0C46 /* ApplyMeshBatchRenderCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ApplyMeshBatchRenderCommand.h; sourceTree = \"<group>\"; };\n\t\t8184636D1D357706004B0C46 /* RenderMeshBatch.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderMeshBatch.cpp; sourceTree = \"<group>\"; };\n\t\t8184636E1D357706004B0C46 /* RenderMeshBatch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderMeshBatch.h; sourceTree = \"<group>\"; };\n\t\t8184CE8E1D0EFF9100E35BE8 /* RenderCommandProcessor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderCommandProcessor.cpp; sourceTree = \"<group>\"; };\n\t\t8184CE8F1D0EFF9100E35BE8 /* RenderCommandProcessor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderCommandProcessor.h; sourceTree = \"<group>\"; };\n\t\t818639731D2BE97C00FE085B /* GLDirectionalLight.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GLDirectionalLight.cpp; sourceTree = \"<group>\"; };\n\t\t818639741D2BE97C00FE085B /* GLDirectionalLight.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GLDirectionalLight.h; sourceTree = \"<group>\"; };\n\t\t8186397A1D2C195D00FE085B /* GLPointLight.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GLPointLight.cpp; sourceTree = \"<group>\"; };\n\t\t8186397B1D2C195D00FE085B /* GLPointLight.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GLPointLight.h; sourceTree = \"<group>\"; };\n\t\t818C15091D22F8F4001D639B /* GLDynamicMesh.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GLDynamicMesh.cpp; sourceTree = \"<group>\"; };\n\t\t818C150A1D22F8F4001D639B /* GLDynamicMesh.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GLDynamicMesh.h; sourceTree = \"<group>\"; };\n\t\t818C150C1D22FB70001D639B /* GLMeshUtils.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GLMeshUtils.cpp; sourceTree = \"<group>\"; };\n\t\t818C150D1D22FB70001D639B /* GLMeshUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GLMeshUtils.h; sourceTree = \"<group>\"; };\n\t\t81A5AF5D1D11575A00307707 /* GLShader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GLShader.cpp; sourceTree = \"<group>\"; };\n\t\t81A5AF5E1D11575A00307707 /* GLShader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GLShader.h; sourceTree = \"<group>\"; };\n\t\t81A5AF651D1190FB00307707 /* GLTexture.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GLTexture.cpp; sourceTree = \"<group>\"; };\n\t\t81A5AF661D1190FB00307707 /* GLTexture.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GLTexture.h; sourceTree = \"<group>\"; };\n\t\t81A616AF1D357133007F7CC1 /* TargetGroup.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TargetGroup.cpp; sourceTree = \"<group>\"; };\n\t\t81A616B01D357133007F7CC1 /* TargetGroup.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TargetGroup.h; sourceTree = \"<group>\"; };\n\t\t81A616B21D357159007F7CC1 /* RestoreRenderTargetGroupCommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RestoreRenderTargetGroupCommand.cpp; sourceTree = \"<group>\"; };\n\t\t81A616B31D357159007F7CC1 /* RestoreRenderTargetGroupCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RestoreRenderTargetGroupCommand.h; sourceTree = \"<group>\"; };\n\t\t81B096031D2AB8CA00E72835 /* GLContextRestorer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GLContextRestorer.cpp; sourceTree = \"<group>\"; };\n\t\t81B096041D2AB8CA00E72835 /* GLContextRestorer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GLContextRestorer.h; sourceTree = \"<group>\"; };\n\t\t81C7FE521C89DD0500D306F9 /* aes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = aes.h; sourceTree = \"<group>\"; };\n\t\t81C7FE541C89DD0500D306F9 /* base64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = base64.h; sourceTree = \"<group>\"; };\n\t\t81C7FE561C89DD0500D306F9 /* assertions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = assertions.h; sourceTree = \"<group>\"; };\n\t\t81C7FE571C89DD0500D306F9 /* autolink.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = autolink.h; sourceTree = \"<group>\"; };\n\t\t81C7FE581C89DD0500D306F9 /* config.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = config.h; sourceTree = \"<group>\"; };\n\t\t81C7FE591C89DD0500D306F9 /* features.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = features.h; sourceTree = \"<group>\"; };\n\t\t81C7FE5A1C89DD0500D306F9 /* forwards.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = forwards.h; sourceTree = \"<group>\"; };\n\t\t81C7FE5B1C89DD0500D306F9 /* json.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = json.h; sourceTree = \"<group>\"; };\n\t\t81C7FE5C1C89DD0500D306F9 /* json_batchallocator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = json_batchallocator.h; sourceTree = \"<group>\"; };\n\t\t81C7FE5D1C89DD0500D306F9 /* json_internalarray.inl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = json_internalarray.inl; sourceTree = \"<group>\"; };\n\t\t81C7FE5E1C89DD0500D306F9 /* json_internalmap.inl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = json_internalmap.inl; sourceTree = \"<group>\"; };\n\t\t81C7FE5F1C89DD0500D306F9 /* json_tool.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = json_tool.h; sourceTree = \"<group>\"; };\n\t\t81C7FE601C89DD0500D306F9 /* json_valueiterator.inl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = json_valueiterator.inl; sourceTree = \"<group>\"; };\n\t\t81C7FE611C89DD0500D306F9 /* reader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = reader.h; sourceTree = \"<group>\"; };\n\t\t81C7FE621C89DD0500D306F9 /* value.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = value.h; sourceTree = \"<group>\"; };\n\t\t81C7FE631C89DD0500D306F9 /* writer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = writer.h; sourceTree = \"<group>\"; };\n\t\t81C7FE651C89DD0500D306F9 /* md5.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = md5.h; sourceTree = \"<group>\"; };\n\t\t81C7FE671C89DD0500D306F9 /* additional.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = additional.h; sourceTree = \"<group>\"; };\n\t\t81C7FE681C89DD0500D306F9 /* crypt.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = crypt.h; sourceTree = \"<group>\"; };\n\t\t81C7FE691C89DD0500D306F9 /* ioapi.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ioapi.h; sourceTree = \"<group>\"; };\n\t\t81C7FE6A1C89DD0500D306F9 /* mztools.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mztools.h; sourceTree = \"<group>\"; };\n\t\t81C7FE6B1C89DD0500D306F9 /* unzip.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = unzip.h; sourceTree = \"<group>\"; };\n\t\t81C7FE6C1C89DD0500D306F9 /* zconf.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = zconf.h; sourceTree = \"<group>\"; };\n\t\t81C7FE6D1C89DD0500D306F9 /* zip.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = zip.h; sourceTree = \"<group>\"; };\n\t\t81C7FE6F1C89DD0500D306F9 /* png.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = png.h; sourceTree = \"<group>\"; };\n\t\t81C7FE701C89DD0500D306F9 /* pngconf.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pngconf.h; sourceTree = \"<group>\"; };\n\t\t81C7FE711C89DD0500D306F9 /* pngdebug.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pngdebug.h; sourceTree = \"<group>\"; };\n\t\t81C7FE721C89DD0500D306F9 /* pnginfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pnginfo.h; sourceTree = \"<group>\"; };\n\t\t81C7FE731C89DD0500D306F9 /* pnglibconf.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pnglibconf.h; sourceTree = \"<group>\"; };\n\t\t81C7FE741C89DD0500D306F9 /* pngpriv.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pngpriv.h; sourceTree = \"<group>\"; };\n\t\t81C7FE751C89DD0500D306F9 /* pngstruct.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pngstruct.h; sourceTree = \"<group>\"; };\n\t\t81C7FE771C89DD0500D306F9 /* rapidxml.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = rapidxml.hpp; sourceTree = \"<group>\"; };\n\t\t81C7FE781C89DD0500D306F9 /* rapidxml_iterators.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = rapidxml_iterators.hpp; sourceTree = \"<group>\"; };\n\t\t81C7FE791C89DD0500D306F9 /* rapidxml_print.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = rapidxml_print.hpp; sourceTree = \"<group>\"; };\n\t\t81C7FE7A1C89DD0500D306F9 /* rapidxml_utils.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = rapidxml_utils.hpp; sourceTree = \"<group>\"; };\n\t\t81C7FE7C1C89DD0500D306F9 /* CSReachability.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSReachability.h; sourceTree = \"<group>\"; };\n\t\t81C7FE7E1C89DD0500D306F9 /* HMAC_SHA1.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HMAC_SHA1.h; sourceTree = \"<group>\"; };\n\t\t81C7FE7F1C89DD0500D306F9 /* SHA1.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SHA1.h; sourceTree = \"<group>\"; };\n\t\t81C7FE811C89DD0500D306F9 /* FacebookSDK.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = FacebookSDK.framework; sourceTree = \"<group>\"; };\n\t\t81C7FE821C89DD0500D306F9 /* libCSBase.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libCSBase.a; sourceTree = \"<group>\"; };\n\t\t81C7FF521C89DD0600D306F9 /* attenuationmode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = attenuationmode.h; sourceTree = \"<group>\"; };\n\t\t81C7FF531C89DD0600D306F9 /* bank.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = bank.h; sourceTree = \"<group>\"; };\n\t\t81C7FF541C89DD0600D306F9 /* ck.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ck.h; sourceTree = \"<group>\"; };\n\t\t81C7FF551C89DD0600D306F9 /* config.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = config.h; sourceTree = \"<group>\"; };\n\t\t81C7FF561C89DD0600D306F9 /* customfile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = customfile.h; sourceTree = \"<group>\"; };\n\t\t81C7FF571C89DD0600D306F9 /* customstream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = customstream.h; sourceTree = \"<group>\"; };\n\t\t81C7FF581C89DD0600D306F9 /* effect.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = effect.h; sourceTree = \"<group>\"; };\n\t\t81C7FF591C89DD0600D306F9 /* effectbus.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = effectbus.h; sourceTree = \"<group>\"; };\n\t\t81C7FF5A1C89DD0600D306F9 /* effectparam.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = effectparam.h; sourceTree = \"<group>\"; };\n\t\t81C7FF5B1C89DD0600D306F9 /* effectprocessor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = effectprocessor.h; sourceTree = \"<group>\"; };\n\t\t81C7FF5C1C89DD0600D306F9 /* effecttype.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = effecttype.h; sourceTree = \"<group>\"; };\n\t\t81C7FF5D1C89DD0600D306F9 /* mixer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mixer.h; sourceTree = \"<group>\"; };\n\t\t81C7FF5E1C89DD0600D306F9 /* pathtype.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pathtype.h; sourceTree = \"<group>\"; };\n\t\t81C7FF5F1C89DD0600D306F9 /* platform.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = platform.h; sourceTree = \"<group>\"; };\n\t\t81C7FF601C89DD0600D306F9 /* sound.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sound.h; sourceTree = \"<group>\"; };\n\t\t81C7FF621C89DD0600D306F9 /* libck.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libck.a; sourceTree = \"<group>\"; };\n\t\t81C7FFAA1C89DDE300D306F9 /* Accounts.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Accounts.framework; path = System/Library/Frameworks/Accounts.framework; sourceTree = SDKROOT; };\n\t\t81C7FFAB1C89DDE300D306F9 /* AddressBook.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AddressBook.framework; path = System/Library/Frameworks/AddressBook.framework; sourceTree = SDKROOT; };\n\t\t81C7FFAC1C89DDE300D306F9 /* AddressBookUI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AddressBookUI.framework; path = System/Library/Frameworks/AddressBookUI.framework; sourceTree = SDKROOT; };\n\t\t81C7FFAD1C89DDE300D306F9 /* AdSupport.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AdSupport.framework; path = System/Library/Frameworks/AdSupport.framework; sourceTree = SDKROOT; };\n\t\t81C7FFAE1C89DDE300D306F9 /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = System/Library/Frameworks/AudioToolbox.framework; sourceTree = SDKROOT; };\n\t\t81C7FFAF1C89DDE300D306F9 /* CFNetwork.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CFNetwork.framework; path = System/Library/Frameworks/CFNetwork.framework; sourceTree = SDKROOT; };\n\t\t81C7FFB01C89DDE300D306F9 /* CoreAudio.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreAudio.framework; path = System/Library/Frameworks/CoreAudio.framework; sourceTree = SDKROOT; };\n\t\t81C7FFB11C89DDE300D306F9 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };\n\t\t81C7FFB21C89DDE300D306F9 /* CoreLocation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreLocation.framework; path = System/Library/Frameworks/CoreLocation.framework; sourceTree = SDKROOT; };\n\t\t81C7FFB31C89DDE300D306F9 /* CoreMotion.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreMotion.framework; path = System/Library/Frameworks/CoreMotion.framework; sourceTree = SDKROOT; };\n\t\t81C7FFB41C89DDE300D306F9 /* CoreTelephony.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreTelephony.framework; path = System/Library/Frameworks/CoreTelephony.framework; sourceTree = SDKROOT; };\n\t\t81C7FFB51C89DDE300D306F9 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };\n\t\t81C7FFB61C89DDE300D306F9 /* GLKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GLKit.framework; path = System/Library/Frameworks/GLKit.framework; sourceTree = SDKROOT; };\n\t\t81C7FFB71C89DDE300D306F9 /* MapKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MapKit.framework; path = System/Library/Frameworks/MapKit.framework; sourceTree = SDKROOT; };\n\t\t81C7FFB81C89DDE300D306F9 /* MediaPlayer.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MediaPlayer.framework; path = System/Library/Frameworks/MediaPlayer.framework; sourceTree = SDKROOT; };\n\t\t81C7FFB91C89DDE300D306F9 /* MessageUI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MessageUI.framework; path = System/Library/Frameworks/MessageUI.framework; sourceTree = SDKROOT; };\n\t\t81C7FFBA1C89DDE300D306F9 /* MobileCoreServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MobileCoreServices.framework; path = System/Library/Frameworks/MobileCoreServices.framework; sourceTree = SDKROOT; };\n\t\t81C7FFBB1C89DDE300D306F9 /* OpenGLES.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGLES.framework; path = System/Library/Frameworks/OpenGLES.framework; sourceTree = SDKROOT; };\n\t\t81C7FFBC1C89DDE300D306F9 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; };\n\t\t81C7FFBD1C89DDE300D306F9 /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = System/Library/Frameworks/Security.framework; sourceTree = SDKROOT; };\n\t\t81C7FFBE1C89DDE300D306F9 /* Social.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Social.framework; path = System/Library/Frameworks/Social.framework; sourceTree = SDKROOT; };\n\t\t81C7FFBF1C89DDE300D306F9 /* StoreKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = StoreKit.framework; path = System/Library/Frameworks/StoreKit.framework; sourceTree = SDKROOT; };\n\t\t81C7FFC01C89DDE300D306F9 /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = SDKROOT; };\n\t\t81C7FFC11C89DDE300D306F9 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };\n\t\t81EB410D1D460C99005A7CE9 /* StencilOp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StencilOp.h; sourceTree = \"<group>\"; };\n\t\t81EB410E1D461267005A7CE9 /* TestFunc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TestFunc.h; sourceTree = \"<group>\"; };\n\t\t81EB41161D48AEFD005A7CE9 /* CanvasDrawMode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CanvasDrawMode.h; sourceTree = \"<group>\"; };\n\t\t81EB41171D48B3E9005A7CE9 /* CanvasDrawMode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CanvasDrawMode.cpp; sourceTree = \"<group>\"; };\n/* End PBXFileReference section */\n\n/* Begin PBXFrameworksBuildPhase section */\n\t\t8158F1E71C89D27300B13109 /* Frameworks */ = {\n\t\t\tisa = PBXFrameworksBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t81C7FFC21C89DDE300D306F9 /* Accounts.framework in Frameworks */,\n\t\t\t\t81C7FFC31C89DDE300D306F9 /* AddressBook.framework in Frameworks */,\n\t\t\t\t81C7FFC41C89DDE300D306F9 /* AddressBookUI.framework in Frameworks */,\n\t\t\t\t81C7FFC51C89DDE300D306F9 /* AdSupport.framework in Frameworks */,\n\t\t\t\t81C7FFC61C89DDE300D306F9 /* AudioToolbox.framework in Frameworks */,\n\t\t\t\t81C7FFC71C89DDE300D306F9 /* CFNetwork.framework in Frameworks */,\n\t\t\t\t81C7FFC81C89DDE300D306F9 /* CoreAudio.framework in Frameworks */,\n\t\t\t\t81C7FFC91C89DDE300D306F9 /* CoreGraphics.framework in Frameworks */,\n\t\t\t\t81C7FFCA1C89DDE300D306F9 /* CoreLocation.framework in Frameworks */,\n\t\t\t\t81C7FFCB1C89DDE300D306F9 /* CoreMotion.framework in Frameworks */,\n\t\t\t\t81C7FFCC1C89DDE300D306F9 /* CoreTelephony.framework in Frameworks */,\n\t\t\t\t81C7FFCD1C89DDE300D306F9 /* Foundation.framework in Frameworks */,\n\t\t\t\t81C7FFCE1C89DDE300D306F9 /* GLKit.framework in Frameworks */,\n\t\t\t\t81C7FFCF1C89DDE300D306F9 /* MapKit.framework in Frameworks */,\n\t\t\t\t81C7FFD01C89DDE300D306F9 /* MediaPlayer.framework in Frameworks */,\n\t\t\t\t81C7FFD11C89DDE300D306F9 /* MessageUI.framework in Frameworks */,\n\t\t\t\t81C7FFD21C89DDE300D306F9 /* MobileCoreServices.framework in Frameworks */,\n\t\t\t\t81C7FFD31C89DDE300D306F9 /* OpenGLES.framework in Frameworks */,\n\t\t\t\t81C7FFD41C89DDE300D306F9 /* QuartzCore.framework in Frameworks */,\n\t\t\t\t81C7FFD51C89DDE300D306F9 /* Security.framework in Frameworks */,\n\t\t\t\t81C7FFD61C89DDE300D306F9 /* Social.framework in Frameworks */,\n\t\t\t\t81C7FFD71C89DDE300D306F9 /* StoreKit.framework in Frameworks */,\n\t\t\t\t81C7FFD81C89DDE300D306F9 /* SystemConfiguration.framework in Frameworks */,\n\t\t\t\t81C7FFD91C89DDE300D306F9 /* UIKit.framework in Frameworks */,\n\t\t\t\t81C7FFA41C89DD0600D306F9 /* libck.a in Frameworks */,\n\t\t\t\t81C7FF8C1C89DD0600D306F9 /* libCSBase.a in Frameworks */,\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n/* End PBXFrameworksBuildPhase section */\n\n/* Begin PBXGroup section */\n\t\t2787EA661E30D38A00E83458 /* Gyroscope */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t2787EA691E30D3F800E83458 /* Gyroscope.h */,\n\t\t\t\t2787EA6A1E30D4EC00E83458 /* Gyroscope.cpp */,\n\t\t\t);\n\t\t\tname = Gyroscope;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t2787EA6C1E30D57700E83458 /* Gyroscope */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t2787EA6D1E30D59200E83458 /* Gyroscope.mm */,\n\t\t\t\t2787EA6F1E30D5A000E83458 /* Gyroscope.h */,\n\t\t\t);\n\t\t\tname = Gyroscope;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t27B4258D1E6058F800E17750 /* SHA256 */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t27B4258F1E60590A00E17750 /* sha256.h */,\n\t\t\t);\n\t\t\tname = SHA256;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t810C0C811D11B01100C32406 /* Model */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t8184627B1D350409004B0C46 /* GLSkinnedAnimation.cpp */,\n\t\t\t\t8184627C1D350409004B0C46 /* GLSkinnedAnimation.h */,\n\t\t\t\t810C0C821D11B01100C32406 /* GLMesh.cpp */,\n\t\t\t\t810C0C831D11B01100C32406 /* GLMesh.h */,\n\t\t\t\t818C15091D22F8F4001D639B /* GLDynamicMesh.cpp */,\n\t\t\t\t818C150A1D22F8F4001D639B /* GLDynamicMesh.h */,\n\t\t\t\t818C150C1D22FB70001D639B /* GLMeshUtils.cpp */,\n\t\t\t\t818C150D1D22FB70001D639B /* GLMeshUtils.h */,\n\t\t\t);\n\t\t\tpath = Model;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t815175761E3F4E5C0024361A /* Skybox */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t815175771E3F4E5C0024361A /* SkyboxComponent.cpp */,\n\t\t\t\t815175781E3F4E5C0024361A /* SkyboxComponent.h */,\n\t\t\t);\n\t\t\tpath = Skybox;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t81559AAA1E925F4C00A1B107 /* Gamepad */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t81559AAB1E925F4C00A1B107 /* Gamepad.cpp */,\n\t\t\t\t81559AAC1E925F4C00A1B107 /* Gamepad.h */,\n\t\t\t\t81559ABA1E93BAFF00A1B107 /* GamepadAxis.h */,\n\t\t\t\t81559ABB1E93DC6700A1B107 /* GamepadMappings.h */,\n\t\t\t\t81559AAD1E925F4C00A1B107 /* GamepadSystem.cpp */,\n\t\t\t\t81559AAE1E925F4C00A1B107 /* GamepadSystem.h */,\n\t\t\t);\n\t\t\tpath = Gamepad;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t815612481D2E5D41000DD01B /* Target */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t815612491D2E5D41000DD01B /* GLTargetGroup.cpp */,\n\t\t\t\t8156124A1D2E5D41000DD01B /* GLTargetGroup.h */,\n\t\t\t);\n\t\t\tpath = Target;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t8158F1E11C89D27300B13109 = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t81845E081D3503E8004B0C46 /* ChilliSource */,\n\t\t\t\t8158F4941C89D2AD00B13109 /* CSBackend */,\n\t\t\t\t81C7FFA91C89DD3F00D306F9 /* Frameworks */,\n\t\t\t\t81C7FE121C89DD0500D306F9 /* Libraries */,\n\t\t\t\t8158F1EB1C89D27300B13109 /* Products */,\n\t\t\t);\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t8158F1EB1C89D27300B13109 /* Products */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t8158F1EA1C89D27300B13109 /* libChilliSource.a */,\n\t\t\t);\n\t\t\tname = Products;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t8158F4941C89D2AD00B13109 /* CSBackend */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t8158F4951C89D2AD00B13109 /* Platform */,\n\t\t\t\t8158F62D1C89D2AD00B13109 /* Rendering */,\n\t\t\t);\n\t\t\tname = CSBackend;\n\t\t\tpath = ../../Source/CSBackend;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t8158F4951C89D2AD00B13109 /* Platform */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t8158F5981C89D2AD00B13109 /* iOS */,\n\t\t\t);\n\t\t\tpath = Platform;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t8158F5981C89D2AD00B13109 /* iOS */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t8158F5991C89D2AD00B13109 /* Core */,\n\t\t\t\t8158F5BD1C89D2AD00B13109 /* ForwardDeclarations.h */,\n\t\t\t\t8158F5BE1C89D2AD00B13109 /* Input */,\n\t\t\t\t8158F5CD1C89D2AD00B13109 /* Main.cpp */,\n\t\t\t\t8158F5CE1C89D2AD00B13109 /* Networking */,\n\t\t\t\t8158F5DB1C89D2AD00B13109 /* Social */,\n\t\t\t\t8158F5EB1C89D2AD00B13109 /* Video */,\n\t\t\t\t8158F5F51C89D2AD00B13109 /* Web */,\n\t\t\t);\n\t\t\tpath = iOS;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t8158F5991C89D2AD00B13109 /* Core */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t8158F59A1C89D2AD00B13109 /* Base */,\n\t\t\t\t8158F5A51C89D2AD00B13109 /* DialogueBox */,\n\t\t\t\t8158F5AA1C89D2AD00B13109 /* File */,\n\t\t\t\t8158F5AD1C89D2AD00B13109 /* Image */,\n\t\t\t\t8158F5B01C89D2AD00B13109 /* Math */,\n\t\t\t\t8158F5B31C89D2AD00B13109 /* Notification */,\n\t\t\t\t8158F5BA1C89D2AD00B13109 /* String */,\n\t\t\t);\n\t\t\tpath = Core;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t8158F59A1C89D2AD00B13109 /* Base */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t27408C1A1D369F8D00A0B003 /* SystemInfoFactory.h */,\n\t\t\t\t27408C1B1D369F8D00A0B003 /* SystemInfoFactory.mm */,\n\t\t\t\t8158F59B1C89D2AD00B13109 /* CSAppDelegate.h */,\n\t\t\t\t8158F59C1C89D2AD00B13109 /* CSAppDelegate.mm */,\n\t\t\t\t8158F59D1C89D2AD00B13109 /* CSGLViewController.h */,\n\t\t\t\t8158F59E1C89D2AD00B13109 /* CSGLViewController.mm */,\n\t\t\t\t8158F5A11C89D2AD00B13109 /* PlatformSystem.h */,\n\t\t\t\t8158F5A21C89D2AD00B13109 /* PlatformSystem.mm */,\n\t\t\t\t8158F5A31C89D2AD00B13109 /* Screen.h */,\n\t\t\t\t8158F5A41C89D2AD00B13109 /* Screen.mm */,\n\t\t\t);\n\t\t\tpath = Base;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t8158F5A51C89D2AD00B13109 /* DialogueBox */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t8158F5A61C89D2AD00B13109 /* DialogueBoxListener.h */,\n\t\t\t\t8158F5A71C89D2AD00B13109 /* DialogueBoxListener.mm */,\n\t\t\t\t8158F5A81C89D2AD00B13109 /* DialogueBoxSystem.h */,\n\t\t\t\t8158F5A91C89D2AD00B13109 /* DialogueBoxSystem.mm */,\n\t\t\t);\n\t\t\tpath = DialogueBox;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t8158F5AA1C89D2AD00B13109 /* File */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t8158F5AB1C89D2AD00B13109 /* FileSystem.h */,\n\t\t\t\t8158F5AC1C89D2AD00B13109 /* FileSystem.mm */,\n\t\t\t);\n\t\t\tpath = File;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t8158F5AD1C89D2AD00B13109 /* Image */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t8158F5AE1C89D2AD00B13109 /* PNGImageProvider.cpp */,\n\t\t\t\t8158F5AF1C89D2AD00B13109 /* PNGImageProvider.h */,\n\t\t\t);\n\t\t\tpath = Image;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t8158F5B01C89D2AD00B13109 /* Math */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t8158F5B11C89D2AD00B13109 /* RNGContainer.h */,\n\t\t\t\t8158F5B21C89D2AD00B13109 /* RNGContainer.mm */,\n\t\t\t);\n\t\t\tpath = Math;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t8158F5B31C89D2AD00B13109 /* Notification */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t8158F5B41C89D2AD00B13109 /* LocalNotificationSystem.cpp */,\n\t\t\t\t8158F5B51C89D2AD00B13109 /* LocalNotificationSystem.h */,\n\t\t\t\t8158F5B61C89D2AD00B13109 /* NSNotificationAdapter.h */,\n\t\t\t\t8158F5B71C89D2AD00B13109 /* NSNotificationAdapter.mm */,\n\t\t\t\t8158F5B81C89D2AD00B13109 /* RemoteNotificationSystem.cpp */,\n\t\t\t\t8158F5B91C89D2AD00B13109 /* RemoteNotificationSystem.h */,\n\t\t\t);\n\t\t\tpath = Notification;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t8158F5BA1C89D2AD00B13109 /* String */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t8158F5BB1C89D2AD00B13109 /* NSStringUtils.h */,\n\t\t\t\t8158F5BC1C89D2AD00B13109 /* NSStringUtils.mm */,\n\t\t\t);\n\t\t\tpath = String;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t8158F5BE1C89D2AD00B13109 /* Input */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t2787EA6C1E30D57700E83458 /* Gyroscope */,\n\t\t\t\t8158F5BF1C89D2AD00B13109 /* Accelerometer */,\n\t\t\t\t8158F5C21C89D2AD00B13109 /* DeviceButtons */,\n\t\t\t\t8158F5C51C89D2AD00B13109 /* Pointer */,\n\t\t\t\t8158F5C81C89D2AD00B13109 /* TextEntry */,\n\t\t\t);\n\t\t\tpath = Input;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t8158F5BF1C89D2AD00B13109 /* Accelerometer */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t8158F5C01C89D2AD00B13109 /* Accelerometer.h */,\n\t\t\t\t8158F5C11C89D2AD00B13109 /* Accelerometer.mm */,\n\t\t\t);\n\t\t\tpath = Accelerometer;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t8158F5C21C89D2AD00B13109 /* DeviceButtons */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t8158F5C31C89D2AD00B13109 /* DeviceButtonSystem.h */,\n\t\t\t\t8158F5C41C89D2AD00B13109 /* DeviceButtonSystem.mm */,\n\t\t\t);\n\t\t\tpath = DeviceButtons;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t8158F5C51C89D2AD00B13109 /* Pointer */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t8158F5C61C89D2AD00B13109 /* PointerSystem.h */,\n\t\t\t\t8158F5C71C89D2AD00B13109 /* PointerSystem.mm */,\n\t\t\t);\n\t\t\tpath = Pointer;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t8158F5C81C89D2AD00B13109 /* TextEntry */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t8158F5C91C89D2AD00B13109 /* TextEntry.h */,\n\t\t\t\t8158F5CA1C89D2AD00B13109 /* TextEntry.mm */,\n\t\t\t\t8158F5CB1C89D2AD00B13109 /* TextEntryDelegate.h */,\n\t\t\t\t8158F5CC1C89D2AD00B13109 /* TextEntryDelegate.mm */,\n\t\t\t);\n\t\t\tpath = TextEntry;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t8158F5CE1C89D2AD00B13109 /* Networking */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t8158F5CF1C89D2AD00B13109 /* Http */,\n\t\t\t\t8158F5D61C89D2AD00B13109 /* IAP */,\n\t\t\t);\n\t\t\tpath = Networking;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t8158F5CF1C89D2AD00B13109 /* Http */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t8158F5D01C89D2AD00B13109 /* HttpDelegate.h */,\n\t\t\t\t8158F5D11C89D2AD00B13109 /* HttpDelegate.mm */,\n\t\t\t\t8158F5D21C89D2AD00B13109 /* HttpRequest.h */,\n\t\t\t\t8158F5D31C89D2AD00B13109 /* HttpRequest.mm */,\n\t\t\t\t8158F5D41C89D2AD00B13109 /* HttpRequestSystem.h */,\n\t\t\t\t8158F5D51C89D2AD00B13109 /* HttpRequestSystem.mm */,\n\t\t\t);\n\t\t\tpath = Http;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t8158F5D61C89D2AD00B13109 /* IAP */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t8158F5D71C89D2AD00B13109 /* IAPSystem.h */,\n\t\t\t\t8158F5D81C89D2AD00B13109 /* IAPSystem.mm */,\n\t\t\t\t8158F5D91C89D2AD00B13109 /* StoreKitIAPSystem.h */,\n\t\t\t\t8158F5DA1C89D2AD00B13109 /* StoreKitIAPSystem.mm */,\n\t\t\t);\n\t\t\tpath = IAP;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t8158F5DB1C89D2AD00B13109 /* Social */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t8158F5DC1C89D2AD00B13109 /* Communications */,\n\t\t\t);\n\t\t\tpath = Social;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t8158F5DC1C89D2AD00B13109 /* Communications */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t8158F5DD1C89D2AD00B13109 /* EmailComposer.h */,\n\t\t\t\t8158F5DE1C89D2AD00B13109 /* EmailComposer.mm */,\n\t\t\t\t8158F5DF1C89D2AD00B13109 /* EmailComposerDelegate.h */,\n\t\t\t\t8158F5E01C89D2AD00B13109 /* EmailComposerDelegate.mm */,\n\t\t\t);\n\t\t\tpath = Communications;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t8158F5EB1C89D2AD00B13109 /* Video */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t8158F5EC1C89D2AD00B13109 /* Base */,\n\t\t\t);\n\t\t\tpath = Video;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t8158F5EC1C89D2AD00B13109 /* Base */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t8158F5ED1C89D2AD00B13109 /* SubtitlesRenderer.h */,\n\t\t\t\t8158F5EE1C89D2AD00B13109 /* SubtitlesRenderer.mm */,\n\t\t\t\t8158F5EF1C89D2AD00B13109 /* VideoOverlayView.h */,\n\t\t\t\t8158F5F01C89D2AD00B13109 /* VideoOverlayView.mm */,\n\t\t\t\t8158F5F11C89D2AD00B13109 /* VideoPlayer.h */,\n\t\t\t\t8158F5F21C89D2AD00B13109 /* VideoPlayer.mm */,\n\t\t\t\t8158F5F31C89D2AD00B13109 /* VideoPlayerTapListener.h */,\n\t\t\t\t8158F5F41C89D2AD00B13109 /* VideoPlayerTapListener.mm */,\n\t\t\t);\n\t\t\tpath = Base;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t8158F5F51C89D2AD00B13109 /* Web */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t8158F5F61C89D2AD00B13109 /* Base */,\n\t\t\t);\n\t\t\tpath = Web;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t8158F5F61C89D2AD00B13109 /* Base */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t8158F5F71C89D2AD00B13109 /* WebView.h */,\n\t\t\t\t8158F5F81C89D2AD00B13109 /* WebView.mm */,\n\t\t\t\t8158F5F91C89D2AD00B13109 /* WebViewDelegate.h */,\n\t\t\t\t8158F5FA1C89D2AD00B13109 /* WebViewDelegate.mm */,\n\t\t\t);\n\t\t\tpath = Base;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t8158F62D1C89D2AD00B13109 /* Rendering */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t8158F62E1C89D2AD00B13109 /* OpenGL */,\n\t\t\t);\n\t\t\tpath = Rendering;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t8158F62E1C89D2AD00B13109 /* OpenGL */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t8158F62F1C89D2AD00B13109 /* Base */,\n\t\t\t\t81729FA51D1BE92B005B8CC9 /* Camera */,\n\t\t\t\t8158F63D1C89D2AD00B13109 /* ForwardDeclarations.h */,\n\t\t\t\t817B8F881D2AE21300273F4B /* Lighting */,\n\t\t\t\t81729FA11D1BE681005B8CC9 /* Material */,\n\t\t\t\t810C0C811D11B01100C32406 /* Model */,\n\t\t\t\t81A5AF5C1D11575A00307707 /* Shader */,\n\t\t\t\t815612481D2E5D41000DD01B /* Target */,\n\t\t\t\t81A5AF641D1190FB00307707 /* Texture */,\n\t\t\t);\n\t\t\tpath = OpenGL;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t8158F62F1C89D2AD00B13109 /* Base */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t81B096031D2AB8CA00E72835 /* GLContextRestorer.cpp */,\n\t\t\t\t81B096041D2AB8CA00E72835 /* GLContextRestorer.h */,\n\t\t\t\t8158F6321C89D2AD00B13109 /* GLError.cpp */,\n\t\t\t\t8158F6331C89D2AD00B13109 /* GLError.h */,\n\t\t\t\t8140019F1E72D21F00388C2A /* GLExtensions.cpp */,\n\t\t\t\t814001A11E72D32F00388C2A /* GLExtensions.h */,\n\t\t\t\t8158F6341C89D2AD00B13109 /* GLIncludes.h */,\n\t\t\t\t8184CE8E1D0EFF9100E35BE8 /* RenderCommandProcessor.cpp */,\n\t\t\t\t8184CE8F1D0EFF9100E35BE8 /* RenderCommandProcessor.h */,\n\t\t\t\t813BA9D91D37BE0600A3B091 /* RenderInfoFactory.cpp */,\n\t\t\t\t813BA9DA1D37BE0600A3B091 /* RenderInfoFactory.h */,\n\t\t\t);\n\t\t\tpath = Base;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t816D4B201E5DCDB300CA66A1 /* objc */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t816D4B211E5DCDB300CA66A1 /* attenuationmode.h */,\n\t\t\t\t816D4B221E5DCDB300CA66A1 /* bank.h */,\n\t\t\t\t816D4B231E5DCDB300CA66A1 /* ck.h */,\n\t\t\t\t816D4B241E5DCDB300CA66A1 /* config.h */,\n\t\t\t\t816D4B251E5DCDB300CA66A1 /* effect.h */,\n\t\t\t\t816D4B261E5DCDB300CA66A1 /* effectbus.h */,\n\t\t\t\t816D4B271E5DCDB300CA66A1 /* effectparam.h */,\n\t\t\t\t816D4B281E5DCDB300CA66A1 /* effecttype.h */,\n\t\t\t\t816D4B291E5DCDB300CA66A1 /* mixer.h */,\n\t\t\t\t816D4B2A1E5DCDB300CA66A1 /* pathtype.h */,\n\t\t\t\t816D4B2B1E5DCDB300CA66A1 /* platform.h */,\n\t\t\t\t816D4B2C1E5DCDB300CA66A1 /* sound.h */,\n\t\t\t);\n\t\t\tpath = objc;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t81729FA11D1BE681005B8CC9 /* Material */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t81729FA21D1BE681005B8CC9 /* GLMaterial.cpp */,\n\t\t\t\t81729FA31D1BE681005B8CC9 /* GLMaterial.h */,\n\t\t\t);\n\t\t\tpath = Material;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t81729FA51D1BE92B005B8CC9 /* Camera */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t81729FA61D1BE92B005B8CC9 /* GLCamera.cpp */,\n\t\t\t\t81729FA71D1BE92B005B8CC9 /* GLCamera.h */,\n\t\t\t);\n\t\t\tpath = Camera;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t817B8F881D2AE21300273F4B /* Lighting */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t817B8F891D2AE21300273F4B /* GLAmbientLight.cpp */,\n\t\t\t\t817B8F8A1D2AE21300273F4B /* GLAmbientLight.h */,\n\t\t\t\t817B8F8C1D2AE21300273F4B /* GLLight.h */,\n\t\t\t\t818639731D2BE97C00FE085B /* GLDirectionalLight.cpp */,\n\t\t\t\t818639741D2BE97C00FE085B /* GLDirectionalLight.h */,\n\t\t\t\t8186397A1D2C195D00FE085B /* GLPointLight.cpp */,\n\t\t\t\t8186397B1D2C195D00FE085B /* GLPointLight.h */,\n\t\t\t);\n\t\t\tpath = Lighting;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t81845E081D3503E8004B0C46 /* ChilliSource */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t81845E091D3503E8004B0C46 /* Audio */,\n\t\t\t\t81845E181D3503E8004B0C46 /* ChilliSource.h */,\n\t\t\t\t81845E191D3503E8004B0C46 /* Core */,\n\t\t\t\t81845F2E1D3503E8004B0C46 /* Input */,\n\t\t\t\t81845F611D3503E8004B0C46 /* Networking */,\n\t\t\t\t81845F751D3503E8004B0C46 /* Rendering */,\n\t\t\t\t818460C81D3503E8004B0C46 /* Social */,\n\t\t\t\t818460D41D3503E8004B0C46 /* UI */,\n\t\t\t\t8184613C1D3503E8004B0C46 /* Video */,\n\t\t\t\t818461461D3503E8004B0C46 /* Web */,\n\t\t\t);\n\t\t\tname = ChilliSource;\n\t\t\tpath = ../../Source/ChilliSource;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t81845E091D3503E8004B0C46 /* Audio */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t81845E0A1D3503E8004B0C46 /* CricketAudio */,\n\t\t\t\t81845E161D3503E8004B0C46 /* CricketAudio.h */,\n\t\t\t\t81845E171D3503E8004B0C46 /* ForwardDeclarations.h */,\n\t\t\t);\n\t\t\tpath = Audio;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t81845E0A1D3503E8004B0C46 /* CricketAudio */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t81845E0B1D3503E8004B0C46 /* CkAudioPlayer.cpp */,\n\t\t\t\t81845E0C1D3503E8004B0C46 /* CkAudioPlayer.h */,\n\t\t\t\t81845E0D1D3503E8004B0C46 /* CkBank.cpp */,\n\t\t\t\t81845E0E1D3503E8004B0C46 /* CkBank.h */,\n\t\t\t\t81845E0F1D3503E8004B0C46 /* CkBankProvider.cpp */,\n\t\t\t\t81845E101D3503E8004B0C46 /* CkBankProvider.h */,\n\t\t\t\t81845E111D3503E8004B0C46 /* CkForwardDeclarations.h */,\n\t\t\t\t81845E121D3503E8004B0C46 /* CkSound.cpp */,\n\t\t\t\t81845E131D3503E8004B0C46 /* CkSound.h */,\n\t\t\t\t81845E141D3503E8004B0C46 /* CricketAudioSystem.cpp */,\n\t\t\t\t81845E151D3503E8004B0C46 /* CricketAudioSystem.h */,\n\t\t\t);\n\t\t\tpath = CricketAudio;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t81845E191D3503E8004B0C46 /* Core */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t81845E1A1D3503E8004B0C46 /* Base */,\n\t\t\t\t81845E391D3503E8004B0C46 /* Base.h */,\n\t\t\t\t81845E3A1D3503E8004B0C46 /* Container */,\n\t\t\t\t81845E541D3503E8004B0C46 /* Container.h */,\n\t\t\t\t81845E551D3503E8004B0C46 /* Cryptographic */,\n\t\t\t\t81845E621D3503E8004B0C46 /* Cryptographic.h */,\n\t\t\t\t81845E631D3503E8004B0C46 /* Delegate */,\n\t\t\t\t81845E681D3503E8004B0C46 /* Delegate.h */,\n\t\t\t\t81845E691D3503E8004B0C46 /* DialogueBox */,\n\t\t\t\t81845E6C1D3503E8004B0C46 /* DialogueBox.h */,\n\t\t\t\t81845E6D1D3503E8004B0C46 /* Entity */,\n\t\t\t\t81845E761D3503E8004B0C46 /* Entity.h */,\n\t\t\t\t81845E771D3503E8004B0C46 /* Event */,\n\t\t\t\t81845E7D1D3503E8004B0C46 /* Event.h */,\n\t\t\t\t81845E7E1D3503E8004B0C46 /* File */,\n\t\t\t\t81845E971D3503E8004B0C46 /* File.h */,\n\t\t\t\t81845E981D3503E8004B0C46 /* ForwardDeclarations.h */,\n\t\t\t\t81845E991D3503E8004B0C46 /* Image */,\n\t\t\t\t81845EA81D3503E8004B0C46 /* Image.h */,\n\t\t\t\t81845EA91D3503E8004B0C46 /* Json */,\n\t\t\t\t81845EAC1D3503E8004B0C46 /* Json.h */,\n\t\t\t\t81845EAD1D3503E8004B0C46 /* Localisation */,\n\t\t\t\t81845EB21D3503E8004B0C46 /* Localisation.h */,\n\t\t\t\t81845EB31D3503E8004B0C46 /* Math */,\n\t\t\t\t81845ECA1D3503E8004B0C46 /* Math.h */,\n\t\t\t\t81845ECB1D3503E8004B0C46 /* Memory */,\n\t\t\t\t81845ED71D3503E8004B0C46 /* Memory.h */,\n\t\t\t\t81845ED81D3503E8004B0C46 /* Notification */,\n\t\t\t\t81845EE21D3503E8004B0C46 /* Notification.h */,\n\t\t\t\t81845EE31D3503E8004B0C46 /* Resource */,\n\t\t\t\t81845EEB1D3503E8004B0C46 /* Resource.h */,\n\t\t\t\t81845EEC1D3503E8004B0C46 /* Scene */,\n\t\t\t\t81845EEF1D3503E8004B0C46 /* Scene.h */,\n\t\t\t\t81845EF01D3503E8004B0C46 /* State */,\n\t\t\t\t81845EF51D3503E8004B0C46 /* State.h */,\n\t\t\t\t81845EF61D3503E8004B0C46 /* String */,\n\t\t\t\t81845F031D3503E8004B0C46 /* String.h */,\n\t\t\t\t81845F041D3503E8004B0C46 /* System */,\n\t\t\t\t81845F081D3503E8004B0C46 /* System.h */,\n\t\t\t\t81845F091D3503E8004B0C46 /* Threading */,\n\t\t\t\t81845F141D3503E8004B0C46 /* Threading.h */,\n\t\t\t\t81845F151D3503E8004B0C46 /* Time */,\n\t\t\t\t81845F1C1D3503E8004B0C46 /* Time.h */,\n\t\t\t\t81845F1D1D3503E8004B0C46 /* Tween */,\n\t\t\t\t81845F231D3503E8004B0C46 /* Tween.h */,\n\t\t\t\t81845F241D3503E8004B0C46 /* Volume */,\n\t\t\t\t81845F271D3503E8004B0C46 /* Volume.h */,\n\t\t\t\t81845F281D3503E8004B0C46 /* XML */,\n\t\t\t\t81845F2D1D3503E8004B0C46 /* XML.h */,\n\t\t\t);\n\t\t\tpath = Core;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t81845E1A1D3503E8004B0C46 /* Base */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t81845E1B1D3503E8004B0C46 /* AppConfig.cpp */,\n\t\t\t\t81845E1C1D3503E8004B0C46 /* AppConfig.h */,\n\t\t\t\t81845E1D1D3503E8004B0C46 /* Application.cpp */,\n\t\t\t\t81845E1E1D3503E8004B0C46 /* Application.h */,\n\t\t\t\t81845E1F1D3503E8004B0C46 /* ByteBuffer.cpp */,\n\t\t\t\t81845E201D3503E8004B0C46 /* ByteBuffer.h */,\n\t\t\t\t81845E211D3503E8004B0C46 /* ByteColour.cpp */,\n\t\t\t\t81845E221D3503E8004B0C46 /* ByteColour.h */,\n\t\t\t\t81845E231D3503E8004B0C46 /* Colour.cpp */,\n\t\t\t\t81845E241D3503E8004B0C46 /* Colour.h */,\n\t\t\t\t81845E251D3503E8004B0C46 /* ColourUtils.cpp */,\n\t\t\t\t81845E261D3503E8004B0C46 /* ColourUtils.h */,\n\t\t\t\t81845E271D3503E8004B0C46 /* ConstMethodCast.h */,\n\t\t\t\t8155F30D1E797B9300750A05 /* CursorType.h */,\n\t\t\t\t81845E281D3503E8004B0C46 /* Device.cpp */,\n\t\t\t\t81845E291D3503E8004B0C46 /* Device.h */,\n\t\t\t\t27408C041D366C7A00A0B003 /* DeviceInfo.cpp */,\n\t\t\t\t27408C051D366C7A00A0B003 /* DeviceInfo.h */,\n\t\t\t\t81845E2A1D3503E8004B0C46 /* GenericFactory.h */,\n\t\t\t\t81845E2B1D3503E8004B0C46 /* LifecycleManager.cpp */,\n\t\t\t\t81845E2C1D3503E8004B0C46 /* LifecycleManager.h */,\n\t\t\t\t81845E2D1D3503E8004B0C46 /* Logging.cpp */,\n\t\t\t\t81845E2E1D3503E8004B0C46 /* Logging.h */,\n\t\t\t\t81845E2F1D3503E8004B0C46 /* MakeSharedArray.h */,\n\t\t\t\t81845E301D3503E8004B0C46 /* PlatformSystem.cpp */,\n\t\t\t\t81845E311D3503E8004B0C46 /* PlatformSystem.h */,\n\t\t\t\t81845E321D3503E8004B0C46 /* QueryableInterface.h */,\n\t\t\t\t813BA9D61D379F6D00A3B091 /* RenderInfo.cpp */,\n\t\t\t\t813BA9D71D379F6D00A3B091 /* RenderInfo.h */,\n\t\t\t\t81845E331D3503E8004B0C46 /* Screen.cpp */,\n\t\t\t\t81845E341D3503E8004B0C46 /* Screen.h */,\n\t\t\t\t27408C271D36DCB600A0B003 /* ScreenInfo.cpp */,\n\t\t\t\t27408C281D36DCB600A0B003 /* ScreenInfo.h */,\n\t\t\t\t81845E351D3503E8004B0C46 /* Singleton.h */,\n\t\t\t\t81845E361D3503E8004B0C46 /* StandardMacros.h */,\n\t\t\t\t27408C061D366C7A00A0B003 /* SystemInfo.cpp */,\n\t\t\t\t27408C071D366C7A00A0B003 /* SystemInfo.h */,\n\t\t\t\t81845E371D3503E8004B0C46 /* Utils.cpp */,\n\t\t\t\t81845E381D3503E8004B0C46 /* Utils.h */,\n\t\t\t);\n\t\t\tpath = Base;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t81845E3A1D3503E8004B0C46 /* Container */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t81845E3B1D3503E8004B0C46 /* concurrent_blocking_queue.h */,\n\t\t\t\t81845E3C1D3503E8004B0C46 /* concurrent_vector.h */,\n\t\t\t\t81845E3D1D3503E8004B0C46 /* concurrent_vector_const_forward_iterator.h */,\n\t\t\t\t81845E3E1D3503E8004B0C46 /* concurrent_vector_const_reverse_iterator.h */,\n\t\t\t\t81845E3F1D3503E8004B0C46 /* concurrent_vector_forward_iterator.h */,\n\t\t\t\t81845E401D3503E8004B0C46 /* concurrent_vector_reverse_iterator.h */,\n\t\t\t\t81845E411D3503E8004B0C46 /* dynamic_array.h */,\n\t\t\t\t81845E421D3503E8004B0C46 /* HashedArray.h */,\n\t\t\t\t81845E431D3503E8004B0C46 /* ParamDictionary.cpp */,\n\t\t\t\t81845E441D3503E8004B0C46 /* ParamDictionary.h */,\n\t\t\t\t81845E451D3503E8004B0C46 /* ParamDictionarySerialiser.cpp */,\n\t\t\t\t81845E461D3503E8004B0C46 /* ParamDictionarySerialiser.h */,\n\t\t\t\t81845E471D3503E8004B0C46 /* Property */,\n\t\t\t\t81845E521D3503E8004B0C46 /* random_access_iterator.h */,\n\t\t\t\t81845E531D3503E8004B0C46 /* VectorUtils.h */,\n\t\t\t);\n\t\t\tpath = Container;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t81845E471D3503E8004B0C46 /* Property */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t81845E481D3503E8004B0C46 /* IProperty.h */,\n\t\t\t\t81845E491D3503E8004B0C46 /* IPropertyType.h */,\n\t\t\t\t81845E4A1D3503E8004B0C46 /* Property.h */,\n\t\t\t\t81845E4B1D3503E8004B0C46 /* PropertyMap.cpp */,\n\t\t\t\t81845E4C1D3503E8004B0C46 /* PropertyMap.h */,\n\t\t\t\t81845E4D1D3503E8004B0C46 /* PropertyType.h */,\n\t\t\t\t81845E4E1D3503E8004B0C46 /* PropertyTypes.cpp */,\n\t\t\t\t81845E4F1D3503E8004B0C46 /* PropertyTypes.h */,\n\t\t\t\t81845E501D3503E8004B0C46 /* ReferenceProperty.h */,\n\t\t\t\t81845E511D3503E8004B0C46 /* ValueProperty.h */,\n\t\t\t);\n\t\t\tpath = Property;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t81845E551D3503E8004B0C46 /* Cryptographic */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t81845E561D3503E8004B0C46 /* AESEncrypt.cpp */,\n\t\t\t\t81845E571D3503E8004B0C46 /* AESEncrypt.h */,\n\t\t\t\t81845E581D3503E8004B0C46 /* BaseEncoding.cpp */,\n\t\t\t\t81845E591D3503E8004B0C46 /* BaseEncoding.h */,\n\t\t\t\t81845E5A1D3503E8004B0C46 /* HashCRC32.cpp */,\n\t\t\t\t81845E5B1D3503E8004B0C46 /* HashCRC32.h */,\n\t\t\t\t81845E5C1D3503E8004B0C46 /* HashMD5.cpp */,\n\t\t\t\t81845E5D1D3503E8004B0C46 /* HashMD5.h */,\n\t\t\t\t81845E5E1D3503E8004B0C46 /* HashSHA1.cpp */,\n\t\t\t\t81845E5F1D3503E8004B0C46 /* HashSHA1.h */,\n\t\t\t\t81845E601D3503E8004B0C46 /* OAuth.cpp */,\n\t\t\t\t81845E611D3503E8004B0C46 /* OAuth.h */,\n\t\t\t\t27B4258A1E6058A300E17750 /* HashSHA256.cpp */,\n\t\t\t\t27B4258B1E6058A300E17750 /* HashSHA256.h */,\n\t\t\t);\n\t\t\tpath = Cryptographic;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t81845E631D3503E8004B0C46 /* Delegate */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t81845E641D3503E8004B0C46 /* ConnectableDelegate.h */,\n\t\t\t\t81845E651D3503E8004B0C46 /* DelegateConnection.h */,\n\t\t\t\t81845E661D3503E8004B0C46 /* MakeConnectableDelegate.h */,\n\t\t\t\t81845E671D3503E8004B0C46 /* MakeDelegate.h */,\n\t\t\t);\n\t\t\tpath = Delegate;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t81845E691D3503E8004B0C46 /* DialogueBox */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t81845E6A1D3503E8004B0C46 /* DialogueBoxSystem.cpp */,\n\t\t\t\t81845E6B1D3503E8004B0C46 /* DialogueBoxSystem.h */,\n\t\t\t);\n\t\t\tpath = DialogueBox;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t81845E6D1D3503E8004B0C46 /* Entity */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t81845E6E1D3503E8004B0C46 /* Component.cpp */,\n\t\t\t\t81845E6F1D3503E8004B0C46 /* Component.h */,\n\t\t\t\t81845E701D3503E8004B0C46 /* Entity.cpp */,\n\t\t\t\t81845E711D3503E8004B0C46 /* Entity.h */,\n\t\t\t\t81845E721D3503E8004B0C46 /* PrimitiveEntityFactory.cpp */,\n\t\t\t\t81845E731D3503E8004B0C46 /* PrimitiveEntityFactory.h */,\n\t\t\t\t81845E741D3503E8004B0C46 /* Transform.cpp */,\n\t\t\t\t81845E751D3503E8004B0C46 /* Transform.h */,\n\t\t\t);\n\t\t\tpath = Entity;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t81845E771D3503E8004B0C46 /* Event */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t81845E781D3503E8004B0C46 /* Event.h */,\n\t\t\t\t81845E791D3503E8004B0C46 /* EventConnection.cpp */,\n\t\t\t\t81845E7A1D3503E8004B0C46 /* EventConnection.h */,\n\t\t\t\t81845E7B1D3503E8004B0C46 /* IConnectableEvent.h */,\n\t\t\t\t81845E7C1D3503E8004B0C46 /* IDisconnectableEvent.h */,\n\t\t\t);\n\t\t\tpath = Event;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t81845E7E1D3503E8004B0C46 /* File */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t81845E7F1D3503E8004B0C46 /* AppDataStore.cpp */,\n\t\t\t\t81845E801D3503E8004B0C46 /* AppDataStore.h */,\n\t\t\t\t81845E811D3503E8004B0C46 /* CSBinaryChunk.cpp */,\n\t\t\t\t81845E821D3503E8004B0C46 /* CSBinaryChunk.h */,\n\t\t\t\t81845E831D3503E8004B0C46 /* CSBinaryInputStream.cpp */,\n\t\t\t\t81845E841D3503E8004B0C46 /* CSBinaryInputStream.h */,\n\t\t\t\t81845E851D3503E8004B0C46 /* FileStream */,\n\t\t\t\t81845E921D3503E8004B0C46 /* FileSystem.cpp */,\n\t\t\t\t81845E931D3503E8004B0C46 /* FileSystem.h */,\n\t\t\t\t81845E941D3503E8004B0C46 /* StorageLocation.h */,\n\t\t\t\t81845E951D3503E8004B0C46 /* TaggedFilePathResolver.cpp */,\n\t\t\t\t81845E961D3503E8004B0C46 /* TaggedFilePathResolver.h */,\n\t\t\t);\n\t\t\tpath = File;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t81845E851D3503E8004B0C46 /* FileStream */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t81845E861D3503E8004B0C46 /* BinaryInputStream.cpp */,\n\t\t\t\t81845E871D3503E8004B0C46 /* BinaryInputStream.h */,\n\t\t\t\t81845E881D3503E8004B0C46 /* BinaryOutputStream.cpp */,\n\t\t\t\t81845E891D3503E8004B0C46 /* BinaryOutputStream.h */,\n\t\t\t\t81845E8A1D3503E8004B0C46 /* FileWriteMode.cpp */,\n\t\t\t\t81845E8B1D3503E8004B0C46 /* FileWriteMode.h */,\n\t\t\t\t81845E8C1D3503E8004B0C46 /* IBinaryInputStream.h */,\n\t\t\t\t81845E8D1D3503E8004B0C46 /* ITextInputStream.h */,\n\t\t\t\t81845E8E1D3503E8004B0C46 /* TextInputStream.cpp */,\n\t\t\t\t81845E8F1D3503E8004B0C46 /* TextInputStream.h */,\n\t\t\t\t81845E901D3503E8004B0C46 /* TextOutputStream.cpp */,\n\t\t\t\t81845E911D3503E8004B0C46 /* TextOutputStream.h */,\n\t\t\t);\n\t\t\tpath = FileStream;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t81845E991D3503E8004B0C46 /* Image */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t81845E9A1D3503E8004B0C46 /* CSImageProvider.cpp */,\n\t\t\t\t81845E9B1D3503E8004B0C46 /* CSImageProvider.h */,\n\t\t\t\t81845E9C1D3503E8004B0C46 /* ETC1ImageProvider.cpp */,\n\t\t\t\t81845E9D1D3503E8004B0C46 /* ETC1ImageProvider.h */,\n\t\t\t\t81845E9E1D3503E8004B0C46 /* Image.cpp */,\n\t\t\t\t81845E9F1D3503E8004B0C46 /* Image.h */,\n\t\t\t\t81845EA01D3503E8004B0C46 /* ImageCompression.h */,\n\t\t\t\t81845EA11D3503E8004B0C46 /* ImageFormat.h */,\n\t\t\t\t81845EA21D3503E8004B0C46 /* ImageFormatConverter.cpp */,\n\t\t\t\t81845EA31D3503E8004B0C46 /* ImageFormatConverter.h */,\n\t\t\t\t81845EA41D3503E8004B0C46 /* PNGImageProvider.cpp */,\n\t\t\t\t81845EA51D3503E8004B0C46 /* PNGImageProvider.h */,\n\t\t\t\t81845EA61D3503E8004B0C46 /* PVRImageProvider.cpp */,\n\t\t\t\t81845EA71D3503E8004B0C46 /* PVRImageProvider.h */,\n\t\t\t);\n\t\t\tpath = Image;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t81845EA91D3503E8004B0C46 /* Json */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t81845EAA1D3503E8004B0C46 /* JsonUtils.cpp */,\n\t\t\t\t81845EAB1D3503E8004B0C46 /* JsonUtils.h */,\n\t\t\t);\n\t\t\tpath = Json;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t81845EAD1D3503E8004B0C46 /* Localisation */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t81845EAE1D3503E8004B0C46 /* LocalisedText.cpp */,\n\t\t\t\t81845EAF1D3503E8004B0C46 /* LocalisedText.h */,\n\t\t\t\t81845EB01D3503E8004B0C46 /* LocalisedTextProvider.cpp */,\n\t\t\t\t81845EB11D3503E8004B0C46 /* LocalisedTextProvider.h */,\n\t\t\t);\n\t\t\tpath = Localisation;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t81845EB31D3503E8004B0C46 /* Math */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t81845EB41D3503E8004B0C46 /* Geometry */,\n\t\t\t\t81845EBA1D3503E8004B0C46 /* Interpolate.cpp */,\n\t\t\t\t81845EBB1D3503E8004B0C46 /* Interpolate.h */,\n\t\t\t\t81845EBC1D3503E8004B0C46 /* MathUtils.cpp */,\n\t\t\t\t81845EBD1D3503E8004B0C46 /* MathUtils.h */,\n\t\t\t\t81845EBE1D3503E8004B0C46 /* Matrix3.h */,\n\t\t\t\t81845EBF1D3503E8004B0C46 /* Matrix4.h */,\n\t\t\t\t81845EC01D3503E8004B0C46 /* NumericLimits.h */,\n\t\t\t\t81845EC11D3503E8004B0C46 /* Quaternion.h */,\n\t\t\t\t81845EC21D3503E8004B0C46 /* Random.cpp */,\n\t\t\t\t81845EC31D3503E8004B0C46 /* Random.h */,\n\t\t\t\t81845EC41D3503E8004B0C46 /* RandomImpl.h */,\n\t\t\t\t81845EC51D3503E8004B0C46 /* UnifiedCoordinates.cpp */,\n\t\t\t\t81845EC61D3503E8004B0C46 /* UnifiedCoordinates.h */,\n\t\t\t\t81845EC71D3503E8004B0C46 /* Vector2.h */,\n\t\t\t\t81845EC81D3503E8004B0C46 /* Vector3.h */,\n\t\t\t\t81845EC91D3503E8004B0C46 /* Vector4.h */,\n\t\t\t);\n\t\t\tpath = Math;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t81845EB41D3503E8004B0C46 /* Geometry */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t81845EB51D3503E8004B0C46 /* Curves.h */,\n\t\t\t\t81845EB61D3503E8004B0C46 /* ShapeIntersection.cpp */,\n\t\t\t\t81845EB71D3503E8004B0C46 /* ShapeIntersection.h */,\n\t\t\t\t81845EB81D3503E8004B0C46 /* Shapes.cpp */,\n\t\t\t\t81845EB91D3503E8004B0C46 /* Shapes.h */,\n\t\t\t);\n\t\t\tpath = Geometry;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t81845ECB1D3503E8004B0C46 /* Memory */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t81845ECC1D3503E8004B0C46 /* IAllocator.h */,\n\t\t\t\t81845ECD1D3503E8004B0C46 /* LinearAllocator.cpp */,\n\t\t\t\t81845ECE1D3503E8004B0C46 /* LinearAllocator.h */,\n\t\t\t\t81845ECF1D3503E8004B0C46 /* MemoryUtils.h */,\n\t\t\t\t81845ED01D3503E8004B0C46 /* MemoryUtilsImpl.h */,\n\t\t\t\t816D4B141E5B012300CA66A1 /* ObjectPoolAllocator.h */,\n\t\t\t\t81845ED11D3503E8004B0C46 /* PagedLinearAllocator.cpp */,\n\t\t\t\t81845ED21D3503E8004B0C46 /* PagedLinearAllocator.h */,\n\t\t\t\t81845ED31D3503E8004B0C46 /* SharedPtr.h */,\n\t\t\t\t81845ED41D3503E8004B0C46 /* SharedPtrImpl.h */,\n\t\t\t\t81845ED51D3503E8004B0C46 /* UniquePtr.h */,\n\t\t\t\t81845ED61D3503E8004B0C46 /* UniquePtrImpl.h */,\n\t\t\t);\n\t\t\tpath = Memory;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t81845ED81D3503E8004B0C46 /* Notification */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t81845ED91D3503E8004B0C46 /* AppNotificationSystem.cpp */,\n\t\t\t\t81845EDA1D3503E8004B0C46 /* AppNotificationSystem.h */,\n\t\t\t\t81845EDB1D3503E8004B0C46 /* LocalNotificationSystem.cpp */,\n\t\t\t\t81845EDC1D3503E8004B0C46 /* LocalNotificationSystem.h */,\n\t\t\t\t81845EDD1D3503E8004B0C46 /* Notification.h */,\n\t\t\t\t81845EDE1D3503E8004B0C46 /* NotificationManager.cpp */,\n\t\t\t\t81845EDF1D3503E8004B0C46 /* NotificationManager.h */,\n\t\t\t\t81845EE01D3503E8004B0C46 /* RemoteNotificationSystem.cpp */,\n\t\t\t\t81845EE11D3503E8004B0C46 /* RemoteNotificationSystem.h */,\n\t\t\t);\n\t\t\tpath = Notification;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t81845EE31D3503E8004B0C46 /* Resource */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t81845EE41D3503E8004B0C46 /* IResourceOptions.h */,\n\t\t\t\t81845EE51D3503E8004B0C46 /* Resource.cpp */,\n\t\t\t\t81845EE61D3503E8004B0C46 /* Resource.h */,\n\t\t\t\t81845EE71D3503E8004B0C46 /* ResourcePool.cpp */,\n\t\t\t\t81845EE81D3503E8004B0C46 /* ResourcePool.h */,\n\t\t\t\t81845EE91D3503E8004B0C46 /* ResourceProvider.cpp */,\n\t\t\t\t81845EEA1D3503E8004B0C46 /* ResourceProvider.h */,\n\t\t\t);\n\t\t\tpath = Resource;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t81845EEC1D3503E8004B0C46 /* Scene */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t81845EED1D3503E8004B0C46 /* Scene.cpp */,\n\t\t\t\t81845EEE1D3503E8004B0C46 /* Scene.h */,\n\t\t\t);\n\t\t\tpath = Scene;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t81845EF01D3503E8004B0C46 /* State */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t81845EF11D3503E8004B0C46 /* State.cpp */,\n\t\t\t\t81845EF21D3503E8004B0C46 /* State.h */,\n\t\t\t\t81845EF31D3503E8004B0C46 /* StateManager.cpp */,\n\t\t\t\t81845EF41D3503E8004B0C46 /* StateManager.h */,\n\t\t\t);\n\t\t\tpath = State;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t81845EF61D3503E8004B0C46 /* String */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t81845EF71D3503E8004B0C46 /* MarkupDef.cpp */,\n\t\t\t\t81845EF81D3503E8004B0C46 /* MarkupDef.h */,\n\t\t\t\t81845EF91D3503E8004B0C46 /* StringMarkupParser.cpp */,\n\t\t\t\t81845EFA1D3503E8004B0C46 /* StringMarkupParser.h */,\n\t\t\t\t81845EFB1D3503E8004B0C46 /* StringParser.cpp */,\n\t\t\t\t81845EFC1D3503E8004B0C46 /* StringParser.h */,\n\t\t\t\t81845EFD1D3503E8004B0C46 /* StringUtils.cpp */,\n\t\t\t\t81845EFE1D3503E8004B0C46 /* StringUtils.h */,\n\t\t\t\t81845EFF1D3503E8004B0C46 /* ToString.cpp */,\n\t\t\t\t81845F001D3503E8004B0C46 /* ToString.h */,\n\t\t\t\t81845F011D3503E8004B0C46 /* UTF8StringUtils.cpp */,\n\t\t\t\t81845F021D3503E8004B0C46 /* UTF8StringUtils.h */,\n\t\t\t);\n\t\t\tpath = String;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t81845F041D3503E8004B0C46 /* System */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t81845F051D3503E8004B0C46 /* AppSystem.h */,\n\t\t\t\t81845F061D3503E8004B0C46 /* StateSystem.cpp */,\n\t\t\t\t81845F071D3503E8004B0C46 /* StateSystem.h */,\n\t\t\t);\n\t\t\tpath = System;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t81845F091D3503E8004B0C46 /* Threading */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t81845F0A1D3503E8004B0C46 /* SingleThreadTaskPool.cpp */,\n\t\t\t\t81845F0B1D3503E8004B0C46 /* SingleThreadTaskPool.h */,\n\t\t\t\t81845F0C1D3503E8004B0C46 /* Task.h */,\n\t\t\t\t81845F0D1D3503E8004B0C46 /* TaskContext.cpp */,\n\t\t\t\t81845F0E1D3503E8004B0C46 /* TaskContext.h */,\n\t\t\t\t81845F0F1D3503E8004B0C46 /* TaskPool.cpp */,\n\t\t\t\t81845F101D3503E8004B0C46 /* TaskPool.h */,\n\t\t\t\t81845F111D3503E8004B0C46 /* TaskScheduler.cpp */,\n\t\t\t\t81845F121D3503E8004B0C46 /* TaskScheduler.h */,\n\t\t\t\t81845F131D3503E8004B0C46 /* TaskType.h */,\n\t\t\t);\n\t\t\tpath = Threading;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t81845F151D3503E8004B0C46 /* Time */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t81845F161D3503E8004B0C46 /* CoreTimer.cpp */,\n\t\t\t\t81845F171D3503E8004B0C46 /* CoreTimer.h */,\n\t\t\t\t81845F181D3503E8004B0C46 /* PerformanceTimer.cpp */,\n\t\t\t\t81845F191D3503E8004B0C46 /* PerformanceTimer.h */,\n\t\t\t\t81845F1A1D3503E8004B0C46 /* Timer.cpp */,\n\t\t\t\t81845F1B1D3503E8004B0C46 /* Timer.h */,\n\t\t\t);\n\t\t\tpath = Time;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t81845F1D1D3503E8004B0C46 /* Tween */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t81845F1E1D3503E8004B0C46 /* EaseBack.h */,\n\t\t\t\t81845F1F1D3503E8004B0C46 /* EaseQuad.h */,\n\t\t\t\t81845F201D3503E8004B0C46 /* Linear.h */,\n\t\t\t\t81845F211D3503E8004B0C46 /* SmoothStep.h */,\n\t\t\t\t81845F221D3503E8004B0C46 /* Tween.h */,\n\t\t\t);\n\t\t\tpath = Tween;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t81845F241D3503E8004B0C46 /* Volume */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t81845F251D3503E8004B0C46 /* VolumeComponent.cpp */,\n\t\t\t\t81845F261D3503E8004B0C46 /* VolumeComponent.h */,\n\t\t\t);\n\t\t\tpath = Volume;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t81845F281D3503E8004B0C46 /* XML */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t81845F291D3503E8004B0C46 /* XML.cpp */,\n\t\t\t\t81845F2A1D3503E8004B0C46 /* XML.h */,\n\t\t\t\t81845F2B1D3503E8004B0C46 /* XMLUtils.cpp */,\n\t\t\t\t81845F2C1D3503E8004B0C46 /* XMLUtils.h */,\n\t\t\t);\n\t\t\tpath = XML;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t81845F2E1D3503E8004B0C46 /* Input */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t81845F2F1D3503E8004B0C46 /* Accelerometer */,\n\t\t\t\t81845F321D3503E8004B0C46 /* Accelerometer.h */,\n\t\t\t\t81845F331D3503E8004B0C46 /* Base */,\n\t\t\t\t81845F361D3503E8004B0C46 /* Base.h */,\n\t\t\t\t81845F371D3503E8004B0C46 /* DeviceButtons */,\n\t\t\t\t81845F3A1D3503E8004B0C46 /* DeviceButtons.h */,\n\t\t\t\t81845F3B1D3503E8004B0C46 /* ForwardDeclarations.h */,\n\t\t\t\t81559AAA1E925F4C00A1B107 /* Gamepad */,\n\t\t\t\t81559AB11E925F5600A1B107 /* Gamepad.h */,\n\t\t\t\t81845F3C1D3503E8004B0C46 /* Gesture */,\n\t\t\t\t81845F4B1D3503E8004B0C46 /* Gesture.h */,\n\t\t\t\t2787EA661E30D38A00E83458 /* Gyroscope */,\n\t\t\t\t2787EA681E30D3B300E83458 /* Gyroscope.h */,\n\t\t\t\t81845F4C1D3503E8004B0C46 /* Keyboard */,\n\t\t\t\t81845F521D3503E8004B0C46 /* Keyboard.h */,\n\t\t\t\t81845F531D3503E8004B0C46 /* Pointer */,\n\t\t\t\t81845F581D3503E8004B0C46 /* Pointer.h */,\n\t\t\t\t81845F591D3503E8004B0C46 /* TextEntry */,\n\t\t\t\t81845F601D3503E8004B0C46 /* TextEntry.h */,\n\t\t\t);\n\t\t\tpath = Input;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t81845F2F1D3503E8004B0C46 /* Accelerometer */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t81845F301D3503E8004B0C46 /* Accelerometer.cpp */,\n\t\t\t\t81845F311D3503E8004B0C46 /* Accelerometer.h */,\n\t\t\t);\n\t\t\tpath = Accelerometer;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t81845F331D3503E8004B0C46 /* Base */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t81845F341D3503E8004B0C46 /* InputFilter.cpp */,\n\t\t\t\t81845F351D3503E8004B0C46 /* InputFilter.h */,\n\t\t\t);\n\t\t\tpath = Base;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t81845F371D3503E8004B0C46 /* DeviceButtons */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t81845F381D3503E8004B0C46 /* DeviceButtonSystem.cpp */,\n\t\t\t\t81845F391D3503E8004B0C46 /* DeviceButtonSystem.h */,\n\t\t\t);\n\t\t\tpath = DeviceButtons;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t81845F3C1D3503E8004B0C46 /* Gesture */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t81845F3D1D3503E8004B0C46 /* DragGesture.cpp */,\n\t\t\t\t81845F3E1D3503E8004B0C46 /* DragGesture.h */,\n\t\t\t\t81845F3F1D3503E8004B0C46 /* Gesture.cpp */,\n\t\t\t\t81845F401D3503E8004B0C46 /* Gesture.h */,\n\t\t\t\t81845F411D3503E8004B0C46 /* GestureSystem.cpp */,\n\t\t\t\t81845F421D3503E8004B0C46 /* GestureSystem.h */,\n\t\t\t\t81845F431D3503E8004B0C46 /* HoldGesture.cpp */,\n\t\t\t\t81845F441D3503E8004B0C46 /* HoldGesture.h */,\n\t\t\t\t81845F451D3503E8004B0C46 /* PinchGesture.cpp */,\n\t\t\t\t81845F461D3503E8004B0C46 /* PinchGesture.h */,\n\t\t\t\t81845F471D3503E8004B0C46 /* RotationGesture.cpp */,\n\t\t\t\t81845F481D3503E8004B0C46 /* RotationGesture.h */,\n\t\t\t\t81845F491D3503E8004B0C46 /* TapGesture.cpp */,\n\t\t\t\t81845F4A1D3503E8004B0C46 /* TapGesture.h */,\n\t\t\t);\n\t\t\tpath = Gesture;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t81845F4C1D3503E8004B0C46 /* Keyboard */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t81845F4D1D3503E8004B0C46 /* Keyboard.cpp */,\n\t\t\t\t81845F4E1D3503E8004B0C46 /* Keyboard.h */,\n\t\t\t\t81845F4F1D3503E8004B0C46 /* KeyCode.cpp */,\n\t\t\t\t81845F501D3503E8004B0C46 /* KeyCode.h */,\n\t\t\t\t81845F511D3503E8004B0C46 /* ModifierKeyCode.h */,\n\t\t\t);\n\t\t\tpath = Keyboard;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t81845F531D3503E8004B0C46 /* Pointer */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t81845F541D3503E8004B0C46 /* Pointer.cpp */,\n\t\t\t\t81845F551D3503E8004B0C46 /* Pointer.h */,\n\t\t\t\t81845F561D3503E8004B0C46 /* PointerSystem.cpp */,\n\t\t\t\t81845F571D3503E8004B0C46 /* PointerSystem.h */,\n\t\t\t);\n\t\t\tpath = Pointer;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t81845F591D3503E8004B0C46 /* TextEntry */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t81845F5A1D3503E8004B0C46 /* TextEntry.cpp */,\n\t\t\t\t81845F5B1D3503E8004B0C46 /* TextEntry.h */,\n\t\t\t\t81845F5C1D3503E8004B0C46 /* TextEntryCapitalisation.cpp */,\n\t\t\t\t81845F5D1D3503E8004B0C46 /* TextEntryCapitalisation.h */,\n\t\t\t\t81845F5E1D3503E8004B0C46 /* TextEntryType.cpp */,\n\t\t\t\t81845F5F1D3503E8004B0C46 /* TextEntryType.h */,\n\t\t\t);\n\t\t\tpath = TextEntry;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t81845F611D3503E8004B0C46 /* Networking */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t81845F621D3503E8004B0C46 /* ContentDownload */,\n\t\t\t\t81845F681D3503E8004B0C46 /* ContentDownload.h */,\n\t\t\t\t81845F691D3503E8004B0C46 /* ForwardDeclarations.h */,\n\t\t\t\t81845F6A1D3503E8004B0C46 /* Http */,\n\t\t\t\t81845F701D3503E8004B0C46 /* Http.h */,\n\t\t\t\t81845F711D3503E8004B0C46 /* IAP */,\n\t\t\t\t81845F741D3503E8004B0C46 /* IAP.h */,\n\t\t\t);\n\t\t\tpath = Networking;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t81845F621D3503E8004B0C46 /* ContentDownload */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t81845F631D3503E8004B0C46 /* ContentManagementSystem.cpp */,\n\t\t\t\t81845F641D3503E8004B0C46 /* ContentManagementSystem.h */,\n\t\t\t\t81845F651D3503E8004B0C46 /* IContentDownloader.h */,\n\t\t\t\t81845F661D3503E8004B0C46 /* MoContentDownloader.cpp */,\n\t\t\t\t81845F671D3503E8004B0C46 /* MoContentDownloader.h */,\n\t\t\t);\n\t\t\tpath = ContentDownload;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t81845F6A1D3503E8004B0C46 /* Http */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t81845F6B1D3503E8004B0C46 /* HttpRequest.h */,\n\t\t\t\t81845F6C1D3503E8004B0C46 /* HttpRequestSystem.cpp */,\n\t\t\t\t81845F6D1D3503E8004B0C46 /* HttpRequestSystem.h */,\n\t\t\t\t81845F6E1D3503E8004B0C46 /* HttpResponse.cpp */,\n\t\t\t\t81845F6F1D3503E8004B0C46 /* HttpResponse.h */,\n\t\t\t);\n\t\t\tpath = Http;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t81845F711D3503E8004B0C46 /* IAP */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t81845F721D3503E8004B0C46 /* IAPSystem.cpp */,\n\t\t\t\t81845F731D3503E8004B0C46 /* IAPSystem.h */,\n\t\t\t);\n\t\t\tpath = IAP;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t81845F751D3503E8004B0C46 /* Rendering */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t81845F761D3503E8004B0C46 /* Base */,\n\t\t\t\t81845FB21D3503E8004B0C46 /* Base.h */,\n\t\t\t\t81845FB31D3503E8004B0C46 /* Camera */,\n\t\t\t\t81845FBC1D3503E8004B0C46 /* Camera.h */,\n\t\t\t\t81845FBD1D3503E8004B0C46 /* Font */,\n\t\t\t\t81845FC21D3503E8004B0C46 /* Font.h */,\n\t\t\t\t81845FC31D3503E8004B0C46 /* ForwardDeclarations.h */,\n\t\t\t\t81845FC41D3503E8004B0C46 /* Lighting */,\n\t\t\t\t81845FD11D3503E8004B0C46 /* Lighting.h */,\n\t\t\t\t81845FD21D3503E8004B0C46 /* Material */,\n\t\t\t\t81845FE11D3503E8004B0C46 /* Material.h */,\n\t\t\t\t81845FE21D3503E8004B0C46 /* Model */,\n\t\t\t\t818460081D3503E8004B0C46 /* Model.h */,\n\t\t\t\t818460091D3503E8004B0C46 /* Particle */,\n\t\t\t\t8184605B1D3503E8004B0C46 /* Particle.h */,\n\t\t\t\t8184605C1D3503E8004B0C46 /* RenderCommand */,\n\t\t\t\t818460941D3503E8004B0C46 /* RenderCommand.h */,\n\t\t\t\t818460951D3503E8004B0C46 /* Shader */,\n\t\t\t\t8184609F1D3503E8004B0C46 /* Shader.h */,\n\t\t\t\t815175761E3F4E5C0024361A /* Skybox */,\n\t\t\t\t815175791E3F4E5C0024361A /* Skybox.h */,\n\t\t\t\t818460A01D3503E8004B0C46 /* Sprite */,\n\t\t\t\t818460A51D3503E8004B0C46 /* Sprite.h */,\n\t\t\t\t818460A61D3503E8004B0C46 /* Target */,\n\t\t\t\t818460AB1D3503E8004B0C46 /* Target.h */,\n\t\t\t\t818460AC1D3503E8004B0C46 /* Texture */,\n\t\t\t\t818460C71D3503E8004B0C46 /* Texture.h */,\n\t\t\t);\n\t\t\tpath = Rendering;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t81845F761D3503E8004B0C46 /* Base */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t81845F771D3503E8004B0C46 /* AlignmentAnchors.cpp */,\n\t\t\t\t81845F781D3503E8004B0C46 /* AlignmentAnchors.h */,\n\t\t\t\t81845F791D3503E8004B0C46 /* AspectRatioUtils.cpp */,\n\t\t\t\t81845F7A1D3503E8004B0C46 /* AspectRatioUtils.h */,\n\t\t\t\t81845F7B1D3503E8004B0C46 /* BlendMode.h */,\n\t\t\t\t81845F7C1D3503E8004B0C46 /* CameraRenderPassGroup.cpp */,\n\t\t\t\t81845F7D1D3503E8004B0C46 /* CameraRenderPassGroup.h */,\n\t\t\t\t81EB41171D48B3E9005A7CE9 /* CanvasDrawMode.cpp */,\n\t\t\t\t81EB41161D48AEFD005A7CE9 /* CanvasDrawMode.h */,\n\t\t\t\t81845F7E1D3503E8004B0C46 /* CanvasMaterialPool.cpp */,\n\t\t\t\t81845F7F1D3503E8004B0C46 /* CanvasMaterialPool.h */,\n\t\t\t\t81845F801D3503E8004B0C46 /* CanvasRenderer.cpp */,\n\t\t\t\t81845F811D3503E8004B0C46 /* CanvasRenderer.h */,\n\t\t\t\t81845F821D3503E8004B0C46 /* CullFace.h */,\n\t\t\t\t81845F841D3503E8004B0C46 /* ForwardRenderPassCompiler.cpp */,\n\t\t\t\t81845F851D3503E8004B0C46 /* ForwardRenderPassCompiler.h */,\n\t\t\t\t81845F861D3503E8004B0C46 /* RenderPasses.h */,\n\t\t\t\t81845F871D3503E8004B0C46 /* FrameAllocatorQueue.cpp */,\n\t\t\t\t81845F881D3503E8004B0C46 /* FrameAllocatorQueue.h */,\n\t\t\t\t81845F891D3503E8004B0C46 /* HorizontalTextJustification.cpp */,\n\t\t\t\t81845F8A1D3503E8004B0C46 /* HorizontalTextJustification.h */,\n\t\t\t\t81845F8B1D3503E8004B0C46 /* IRenderCommandProcessor.cpp */,\n\t\t\t\t81845F8C1D3503E8004B0C46 /* IRenderCommandProcessor.h */,\n\t\t\t\t81845F8D1D3503E8004B0C46 /* IRenderPassCompiler.h */,\n\t\t\t\t81845F8E1D3503E8004B0C46 /* RenderCapabilities.cpp */,\n\t\t\t\t81845F8F1D3503E8004B0C46 /* RenderCapabilities.h */,\n\t\t\t\t81845F901D3503E8004B0C46 /* RenderCommandBufferManager.cpp */,\n\t\t\t\t81845F911D3503E8004B0C46 /* RenderCommandBufferManager.h */,\n\t\t\t\t81845F921D3503E8004B0C46 /* RenderCommandCompiler.cpp */,\n\t\t\t\t81845F931D3503E8004B0C46 /* RenderCommandCompiler.h */,\n\t\t\t\t81845F961D3503E8004B0C46 /* Renderer.cpp */,\n\t\t\t\t81845F971D3503E8004B0C46 /* Renderer.h */,\n\t\t\t\t81845F981D3503E8004B0C46 /* RenderFrame.cpp */,\n\t\t\t\t81845F991D3503E8004B0C46 /* RenderFrame.h */,\n\t\t\t\t81845F9A1D3503E8004B0C46 /* RenderFrameCompiler.cpp */,\n\t\t\t\t81845F9B1D3503E8004B0C46 /* RenderFrameCompiler.h */,\n\t\t\t\t81845F9C1D3503E8004B0C46 /* RenderFrameData.cpp */,\n\t\t\t\t81845F9D1D3503E8004B0C46 /* RenderFrameData.h */,\n\t\t\t\t81845F9E1D3503E8004B0C46 /* RenderLayer.h */,\n\t\t\t\t81845F9F1D3503E8004B0C46 /* RenderObject.cpp */,\n\t\t\t\t81845FA01D3503E8004B0C46 /* RenderObject.h */,\n\t\t\t\t81845FA11D3503E8004B0C46 /* RenderPass.cpp */,\n\t\t\t\t81845FA21D3503E8004B0C46 /* RenderPass.h */,\n\t\t\t\t81845FA31D3503E8004B0C46 /* RenderPassObject.cpp */,\n\t\t\t\t81845FA41D3503E8004B0C46 /* RenderPassObject.h */,\n\t\t\t\t81845FA51D3503E8004B0C46 /* RenderPassObjectSorter.cpp */,\n\t\t\t\t81845FA61D3503E8004B0C46 /* RenderPassObjectSorter.h */,\n\t\t\t\t81845FA71D3503E8004B0C46 /* RenderPassVisibilityChecker.cpp */,\n\t\t\t\t81845FA81D3503E8004B0C46 /* RenderPassVisibilityChecker.h */,\n\t\t\t\t81845FA91D3503E8004B0C46 /* RenderSnapshot.cpp */,\n\t\t\t\t81845FAA1D3503E8004B0C46 /* RenderSnapshot.h */,\n\t\t\t\t81845FAB1D3503E8004B0C46 /* SizePolicy.cpp */,\n\t\t\t\t81845FAC1D3503E8004B0C46 /* SizePolicy.h */,\n\t\t\t\t81EB410D1D460C99005A7CE9 /* StencilOp.h */,\n\t\t\t\t81845FAD1D3503E8004B0C46 /* SurfaceFormat.h */,\n\t\t\t\t81845FAE1D3503E8004B0C46 /* TargetRenderPassGroup.cpp */,\n\t\t\t\t81845FAF1D3503E8004B0C46 /* TargetRenderPassGroup.h */,\n\t\t\t\t813291FE1D704EA300CA7612 /* TargetType.h */,\n\t\t\t\t81EB410E1D461267005A7CE9 /* TestFunc.h */,\n\t\t\t\t81845FB01D3503E8004B0C46 /* VerticalTextJustification.cpp */,\n\t\t\t\t81845FB11D3503E8004B0C46 /* VerticalTextJustification.h */,\n\t\t\t);\n\t\t\tpath = Base;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t81845FB31D3503E8004B0C46 /* Camera */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t81845FB41D3503E8004B0C46 /* CameraComponent.cpp */,\n\t\t\t\t81845FB51D3503E8004B0C46 /* CameraComponent.h */,\n\t\t\t\t81845FB61D3503E8004B0C46 /* OrthographicCameraComponent.cpp */,\n\t\t\t\t81845FB71D3503E8004B0C46 /* OrthographicCameraComponent.h */,\n\t\t\t\t81845FB81D3503E8004B0C46 /* PerspectiveCameraComponent.cpp */,\n\t\t\t\t81845FB91D3503E8004B0C46 /* PerspectiveCameraComponent.h */,\n\t\t\t\t81845FBA1D3503E8004B0C46 /* RenderCamera.cpp */,\n\t\t\t\t81845FBB1D3503E8004B0C46 /* RenderCamera.h */,\n\t\t\t);\n\t\t\tpath = Camera;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t81845FBD1D3503E8004B0C46 /* Font */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t81845FBE1D3503E8004B0C46 /* Font.cpp */,\n\t\t\t\t81845FBF1D3503E8004B0C46 /* Font.h */,\n\t\t\t\t81845FC01D3503E8004B0C46 /* FontProvider.cpp */,\n\t\t\t\t81845FC11D3503E8004B0C46 /* FontProvider.h */,\n\t\t\t);\n\t\t\tpath = Font;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t81845FC41D3503E8004B0C46 /* Lighting */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t81845FC51D3503E8004B0C46 /* AmbientLightComponent.cpp */,\n\t\t\t\t81845FC61D3503E8004B0C46 /* AmbientLightComponent.h */,\n\t\t\t\t81845FC71D3503E8004B0C46 /* AmbientRenderLight.cpp */,\n\t\t\t\t81845FC81D3503E8004B0C46 /* AmbientRenderLight.h */,\n\t\t\t\t81845FC91D3503E8004B0C46 /* DirectionalLightComponent.cpp */,\n\t\t\t\t81845FCA1D3503E8004B0C46 /* DirectionalLightComponent.h */,\n\t\t\t\t81845FCB1D3503E8004B0C46 /* DirectionalRenderLight.cpp */,\n\t\t\t\t81845FCC1D3503E8004B0C46 /* DirectionalRenderLight.h */,\n\t\t\t\t81845FCD1D3503E8004B0C46 /* PointLightComponent.cpp */,\n\t\t\t\t81845FCE1D3503E8004B0C46 /* PointLightComponent.h */,\n\t\t\t\t81845FCF1D3503E8004B0C46 /* PointRenderLight.cpp */,\n\t\t\t\t81845FD01D3503E8004B0C46 /* PointRenderLight.h */,\n\t\t\t);\n\t\t\tpath = Lighting;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t81845FD21D3503E8004B0C46 /* Material */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t81845FD31D3503E8004B0C46 /* ForwardRenderMaterialGroupManager.cpp */,\n\t\t\t\t81845FD41D3503E8004B0C46 /* ForwardRenderMaterialGroupManager.h */,\n\t\t\t\t81845FD51D3503E8004B0C46 /* Material.cpp */,\n\t\t\t\t81845FD61D3503E8004B0C46 /* Material.h */,\n\t\t\t\t81845FD71D3503E8004B0C46 /* MaterialFactory.cpp */,\n\t\t\t\t81845FD81D3503E8004B0C46 /* MaterialFactory.h */,\n\t\t\t\t81845FD91D3503E8004B0C46 /* MaterialProvider.cpp */,\n\t\t\t\t81845FDA1D3503E8004B0C46 /* MaterialProvider.h */,\n\t\t\t\t817255FA1E084F3400A65625 /* MaterialShadingType.h */,\n\t\t\t\t81845FDB1D3503E8004B0C46 /* RenderMaterial.cpp */,\n\t\t\t\t81845FDC1D3503E8004B0C46 /* RenderMaterial.h */,\n\t\t\t\t81845FDD1D3503E8004B0C46 /* RenderMaterialGroup.cpp */,\n\t\t\t\t81845FDE1D3503E8004B0C46 /* RenderMaterialGroup.h */,\n\t\t\t\t81845FDF1D3503E8004B0C46 /* RenderMaterialGroupManager.cpp */,\n\t\t\t\t81845FE01D3503E8004B0C46 /* RenderMaterialGroupManager.h */,\n\t\t\t);\n\t\t\tpath = Material;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t81845FE21D3503E8004B0C46 /* Model */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t81845FE31D3503E8004B0C46 /* AnimatedModelComponent.cpp */,\n\t\t\t\t81845FE41D3503E8004B0C46 /* AnimatedModelComponent.h */,\n\t\t\t\t81845FE51D3503E8004B0C46 /* CSAnimProvider.cpp */,\n\t\t\t\t81845FE61D3503E8004B0C46 /* CSAnimProvider.h */,\n\t\t\t\t81845FE71D3503E8004B0C46 /* CSModelProvider.cpp */,\n\t\t\t\t81845FE81D3503E8004B0C46 /* CSModelProvider.h */,\n\t\t\t\t81845FE91D3503E8004B0C46 /* IndexFormat.cpp */,\n\t\t\t\t81845FEA1D3503E8004B0C46 /* IndexFormat.h */,\n\t\t\t\t81845FEB1D3503E8004B0C46 /* MeshDesc.cpp */,\n\t\t\t\t81845FEC1D3503E8004B0C46 /* MeshDesc.h */,\n\t\t\t\t81845FED1D3503E8004B0C46 /* Model.cpp */,\n\t\t\t\t81845FEE1D3503E8004B0C46 /* Model.h */,\n\t\t\t\t81845FEF1D3503E8004B0C46 /* ModelDesc.cpp */,\n\t\t\t\t81845FF01D3503E8004B0C46 /* ModelDesc.h */,\n\t\t\t\t81845FF11D3503E8004B0C46 /* PolygonType.h */,\n\t\t\t\t81845FF21D3503E8004B0C46 /* PrimitiveModelFactory.cpp */,\n\t\t\t\t81845FF31D3503E8004B0C46 /* PrimitiveModelFactory.h */,\n\t\t\t\t81845FF41D3503E8004B0C46 /* RenderDynamicMesh.cpp */,\n\t\t\t\t81845FF51D3503E8004B0C46 /* RenderDynamicMesh.h */,\n\t\t\t\t81845FF61D3503E8004B0C46 /* RenderMesh.cpp */,\n\t\t\t\t81845FF71D3503E8004B0C46 /* RenderMesh.h */,\n\t\t\t\t8184636D1D357706004B0C46 /* RenderMeshBatch.cpp */,\n\t\t\t\t8184636E1D357706004B0C46 /* RenderMeshBatch.h */,\n\t\t\t\t81845FF81D3503E8004B0C46 /* RenderMeshManager.cpp */,\n\t\t\t\t81845FF91D3503E8004B0C46 /* RenderMeshManager.h */,\n\t\t\t\t81845FFA1D3503E8004B0C46 /* RenderSkinnedAnimation.cpp */,\n\t\t\t\t81845FFB1D3503E8004B0C46 /* RenderSkinnedAnimation.h */,\n\t\t\t\t81845FFC1D3503E8004B0C46 /* Skeleton.cpp */,\n\t\t\t\t81845FFD1D3503E8004B0C46 /* Skeleton.h */,\n\t\t\t\t81845FFE1D3503E8004B0C46 /* SkeletonDesc.cpp */,\n\t\t\t\t81845FFF1D3503E8004B0C46 /* SkeletonDesc.h */,\n\t\t\t\t818460001D3503E8004B0C46 /* SkinnedAnimation.cpp */,\n\t\t\t\t818460011D3503E8004B0C46 /* SkinnedAnimation.h */,\n\t\t\t\t818460021D3503E8004B0C46 /* SkinnedAnimationGroup.cpp */,\n\t\t\t\t818460031D3503E8004B0C46 /* SkinnedAnimationGroup.h */,\n\t\t\t\t818463671D353765004B0C46 /* SmallMeshBatcher.cpp */,\n\t\t\t\t818463681D353765004B0C46 /* SmallMeshBatcher.h */,\n\t\t\t\t818460041D3503E8004B0C46 /* StaticModelComponent.cpp */,\n\t\t\t\t818460051D3503E8004B0C46 /* StaticModelComponent.h */,\n\t\t\t\t818460061D3503E8004B0C46 /* VertexFormat.cpp */,\n\t\t\t\t818460071D3503E8004B0C46 /* VertexFormat.h */,\n\t\t\t);\n\t\t\tpath = Model;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t818460091D3503E8004B0C46 /* Particle */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t8184600A1D3503E8004B0C46 /* Affector */,\n\t\t\t\t818460211D3503E8004B0C46 /* ConcurrentParticleData.cpp */,\n\t\t\t\t818460221D3503E8004B0C46 /* ConcurrentParticleData.h */,\n\t\t\t\t818460231D3503E8004B0C46 /* CSParticleProvider.cpp */,\n\t\t\t\t818460241D3503E8004B0C46 /* CSParticleProvider.h */,\n\t\t\t\t818460251D3503E8004B0C46 /* Drawable */,\n\t\t\t\t818460301D3503E8004B0C46 /* Emitter */,\n\t\t\t\t8184604B1D3503E8004B0C46 /* Particle.h */,\n\t\t\t\t8184604C1D3503E8004B0C46 /* ParticleEffect.cpp */,\n\t\t\t\t8184604D1D3503E8004B0C46 /* ParticleEffect.h */,\n\t\t\t\t8184604E1D3503E8004B0C46 /* ParticleEffectComponent.cpp */,\n\t\t\t\t8184604F1D3503E8004B0C46 /* ParticleEffectComponent.h */,\n\t\t\t\t818460501D3503E8004B0C46 /* Property */,\n\t\t\t);\n\t\t\tpath = Particle;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t8184600A1D3503E8004B0C46 /* Affector */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t8184600B1D3503E8004B0C46 /* AccelerationParticleAffector.cpp */,\n\t\t\t\t8184600C1D3503E8004B0C46 /* AccelerationParticleAffector.h */,\n\t\t\t\t8184600D1D3503E8004B0C46 /* AccelerationParticleAffectorDef.cpp */,\n\t\t\t\t8184600E1D3503E8004B0C46 /* AccelerationParticleAffectorDef.h */,\n\t\t\t\t8184600F1D3503E8004B0C46 /* AngularAccelerationParticleAffector.cpp */,\n\t\t\t\t818460101D3503E8004B0C46 /* AngularAccelerationParticleAffector.h */,\n\t\t\t\t818460111D3503E8004B0C46 /* AngularAccelerationParticleAffectorDef.cpp */,\n\t\t\t\t818460121D3503E8004B0C46 /* AngularAccelerationParticleAffectorDef.h */,\n\t\t\t\t818460131D3503E8004B0C46 /* ColourOverLifetimeParticleAffector.cpp */,\n\t\t\t\t818460141D3503E8004B0C46 /* ColourOverLifetimeParticleAffector.h */,\n\t\t\t\t818460151D3503E8004B0C46 /* ColourOverLifetimeParticleAffectorDef.cpp */,\n\t\t\t\t818460161D3503E8004B0C46 /* ColourOverLifetimeParticleAffectorDef.h */,\n\t\t\t\t818460171D3503E8004B0C46 /* ParticleAffector.cpp */,\n\t\t\t\t818460181D3503E8004B0C46 /* ParticleAffector.h */,\n\t\t\t\t818460191D3503E8004B0C46 /* ParticleAffectorDef.cpp */,\n\t\t\t\t8184601A1D3503E8004B0C46 /* ParticleAffectorDef.h */,\n\t\t\t\t8184601B1D3503E8004B0C46 /* ParticleAffectorDefFactory.cpp */,\n\t\t\t\t8184601C1D3503E8004B0C46 /* ParticleAffectorDefFactory.h */,\n\t\t\t\t8184601D1D3503E8004B0C46 /* ScaleOverLifetimeParticleAffector.cpp */,\n\t\t\t\t8184601E1D3503E8004B0C46 /* ScaleOverLifetimeParticleAffector.h */,\n\t\t\t\t8184601F1D3503E8004B0C46 /* ScaleOverLifetimeParticleAffectorDef.cpp */,\n\t\t\t\t818460201D3503E8004B0C46 /* ScaleOverLifetimeParticleAffectorDef.h */,\n\t\t\t);\n\t\t\tpath = Affector;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t818460251D3503E8004B0C46 /* Drawable */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t818460261D3503E8004B0C46 /* ParticleDrawable.cpp */,\n\t\t\t\t818460271D3503E8004B0C46 /* ParticleDrawable.h */,\n\t\t\t\t818460281D3503E8004B0C46 /* ParticleDrawableDef.cpp */,\n\t\t\t\t818460291D3503E8004B0C46 /* ParticleDrawableDef.h */,\n\t\t\t\t8184602A1D3503E8004B0C46 /* ParticleDrawableDefFactory.cpp */,\n\t\t\t\t8184602B1D3503E8004B0C46 /* ParticleDrawableDefFactory.h */,\n\t\t\t\t8184602C1D3503E8004B0C46 /* StaticBillboardParticleDrawable.cpp */,\n\t\t\t\t8184602D1D3503E8004B0C46 /* StaticBillboardParticleDrawable.h */,\n\t\t\t\t8184602E1D3503E8004B0C46 /* StaticBillboardParticleDrawableDef.cpp */,\n\t\t\t\t8184602F1D3503E8004B0C46 /* StaticBillboardParticleDrawableDef.h */,\n\t\t\t);\n\t\t\tpath = Drawable;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t818460301D3503E8004B0C46 /* Emitter */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t818460311D3503E8004B0C46 /* CircleParticleEmitter.cpp */,\n\t\t\t\t818460321D3503E8004B0C46 /* CircleParticleEmitter.h */,\n\t\t\t\t818460331D3503E8004B0C46 /* CircleParticleEmitterDef.cpp */,\n\t\t\t\t818460341D3503E8004B0C46 /* CircleParticleEmitterDef.h */,\n\t\t\t\t818460351D3503E8004B0C46 /* Cone2DParticleEmitter.cpp */,\n\t\t\t\t818460361D3503E8004B0C46 /* Cone2DParticleEmitter.h */,\n\t\t\t\t818460371D3503E8004B0C46 /* Cone2DParticleEmitterDef.cpp */,\n\t\t\t\t818460381D3503E8004B0C46 /* Cone2DParticleEmitterDef.h */,\n\t\t\t\t818460391D3503E8004B0C46 /* ConeParticleEmitter.cpp */,\n\t\t\t\t8184603A1D3503E8004B0C46 /* ConeParticleEmitter.h */,\n\t\t\t\t8184603B1D3503E8004B0C46 /* ConeParticleEmitterDef.cpp */,\n\t\t\t\t8184603C1D3503E8004B0C46 /* ConeParticleEmitterDef.h */,\n\t\t\t\t8184603D1D3503E8004B0C46 /* ParticleEmitter.cpp */,\n\t\t\t\t8184603E1D3503E8004B0C46 /* ParticleEmitter.h */,\n\t\t\t\t8184603F1D3503E8004B0C46 /* ParticleEmitterDef.cpp */,\n\t\t\t\t818460401D3503E8004B0C46 /* ParticleEmitterDef.h */,\n\t\t\t\t818460411D3503E8004B0C46 /* ParticleEmitterDefFactory.cpp */,\n\t\t\t\t818460421D3503E8004B0C46 /* ParticleEmitterDefFactory.h */,\n\t\t\t\t818460431D3503E8004B0C46 /* PointParticleEmitter.cpp */,\n\t\t\t\t818460441D3503E8004B0C46 /* PointParticleEmitter.h */,\n\t\t\t\t818460451D3503E8004B0C46 /* PointParticleEmitterDef.cpp */,\n\t\t\t\t818460461D3503E8004B0C46 /* PointParticleEmitterDef.h */,\n\t\t\t\t818460471D3503E8004B0C46 /* SphereParticleEmitter.cpp */,\n\t\t\t\t818460481D3503E8004B0C46 /* SphereParticleEmitter.h */,\n\t\t\t\t818460491D3503E8004B0C46 /* SphereParticleEmitterDef.cpp */,\n\t\t\t\t8184604A1D3503E8004B0C46 /* SphereParticleEmitterDef.h */,\n\t\t\t);\n\t\t\tpath = Emitter;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t818460501D3503E8004B0C46 /* Property */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t818460511D3503E8004B0C46 /* ComponentwiseRandomConstantParticleProperty.h */,\n\t\t\t\t818460521D3503E8004B0C46 /* ComponentwiseRandomCurveParticleProperty.h */,\n\t\t\t\t818460531D3503E8004B0C46 /* ConstantParticleProperty.h */,\n\t\t\t\t818460541D3503E8004B0C46 /* CurveParticleProperty.h */,\n\t\t\t\t818460551D3503E8004B0C46 /* ParticleProperty.h */,\n\t\t\t\t818460561D3503E8004B0C46 /* ParticlePropertyFactory.h */,\n\t\t\t\t818460571D3503E8004B0C46 /* ParticlePropertyFactoryImpl.cpp */,\n\t\t\t\t818460581D3503E8004B0C46 /* ParticlePropertyFactoryImpl.h */,\n\t\t\t\t818460591D3503E8004B0C46 /* RandomConstantParticleProperty.h */,\n\t\t\t\t8184605A1D3503E8004B0C46 /* RandomCurveParticleProperty.h */,\n\t\t\t);\n\t\t\tpath = Property;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t8184605C1D3503E8004B0C46 /* RenderCommand */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t8184605D1D3503E8004B0C46 /* Commands */,\n\t\t\t\t8184608E1D3503E8004B0C46 /* RenderCommand.cpp */,\n\t\t\t\t8184608F1D3503E8004B0C46 /* RenderCommand.h */,\n\t\t\t\t818460901D3503E8004B0C46 /* RenderCommandBuffer.cpp */,\n\t\t\t\t818460911D3503E8004B0C46 /* RenderCommandBuffer.h */,\n\t\t\t\t818460921D3503E8004B0C46 /* RenderCommandList.cpp */,\n\t\t\t\t818460931D3503E8004B0C46 /* RenderCommandList.h */,\n\t\t\t);\n\t\t\tpath = RenderCommand;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t8184605D1D3503E8004B0C46 /* Commands */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t8184605E1D3503E8004B0C46 /* ApplyAmbientLightRenderCommand.cpp */,\n\t\t\t\t8184605F1D3503E8004B0C46 /* ApplyAmbientLightRenderCommand.h */,\n\t\t\t\t818460601D3503E8004B0C46 /* ApplyCameraRenderCommand.cpp */,\n\t\t\t\t818460611D3503E8004B0C46 /* ApplyCameraRenderCommand.h */,\n\t\t\t\t818460621D3503E8004B0C46 /* ApplyDirectionalLightRenderCommand.cpp */,\n\t\t\t\t818460631D3503E8004B0C46 /* ApplyDirectionalLightRenderCommand.h */,\n\t\t\t\t818460641D3503E8004B0C46 /* ApplyDynamicMeshRenderCommand.cpp */,\n\t\t\t\t818460651D3503E8004B0C46 /* ApplyDynamicMeshRenderCommand.h */,\n\t\t\t\t818460661D3503E8004B0C46 /* ApplyMaterialRenderCommand.cpp */,\n\t\t\t\t818460671D3503E8004B0C46 /* ApplyMaterialRenderCommand.h */,\n\t\t\t\t8184636A1D35493A004B0C46 /* ApplyMeshBatchRenderCommand.cpp */,\n\t\t\t\t8184636B1D35493A004B0C46 /* ApplyMeshBatchRenderCommand.h */,\n\t\t\t\t818460681D3503E8004B0C46 /* ApplyMeshRenderCommand.cpp */,\n\t\t\t\t818460691D3503E8004B0C46 /* ApplyMeshRenderCommand.h */,\n\t\t\t\t8184606A1D3503E8004B0C46 /* ApplyPointLightRenderCommand.cpp */,\n\t\t\t\t8184606B1D3503E8004B0C46 /* ApplyPointLightRenderCommand.h */,\n\t\t\t\t8184606C1D3503E8004B0C46 /* ApplySkinnedAnimationRenderCommand.cpp */,\n\t\t\t\t8184606D1D3503E8004B0C46 /* ApplySkinnedAnimationRenderCommand.h */,\n\t\t\t\t8184606E1D3503E8004B0C46 /* BeginRenderCommand.cpp */,\n\t\t\t\t8184606F1D3503E8004B0C46 /* BeginRenderCommand.h */,\n\t\t\t\t818460701D3503E8004B0C46 /* BeginWithTargetGroupRenderCommand.cpp */,\n\t\t\t\t818460711D3503E8004B0C46 /* BeginWithTargetGroupRenderCommand.h */,\n\t\t\t\t818460721D3503E8004B0C46 /* EndRenderCommand.cpp */,\n\t\t\t\t818460731D3503E8004B0C46 /* EndRenderCommand.h */,\n\t\t\t\t817256011E0A9F2600A65625 /* LoadCubemapRenderCommand.cpp */,\n\t\t\t\t817256021E0A9F2600A65625 /* LoadCubemapRenderCommand.h */,\n\t\t\t\t818460741D3503E8004B0C46 /* LoadMaterialGroupRenderCommand.cpp */,\n\t\t\t\t818460751D3503E8004B0C46 /* LoadMaterialGroupRenderCommand.h */,\n\t\t\t\t818460761D3503E8004B0C46 /* LoadMeshRenderCommand.cpp */,\n\t\t\t\t818460771D3503E8004B0C46 /* LoadMeshRenderCommand.h */,\n\t\t\t\t818460781D3503E8004B0C46 /* LoadShaderRenderCommand.cpp */,\n\t\t\t\t818460791D3503E8004B0C46 /* LoadShaderRenderCommand.h */,\n\t\t\t\t8184607A1D3503E8004B0C46 /* LoadTargetGroupRenderCommand.cpp */,\n\t\t\t\t8184607B1D3503E8004B0C46 /* LoadTargetGroupRenderCommand.h */,\n\t\t\t\t8184607C1D3503E8004B0C46 /* LoadTextureRenderCommand.cpp */,\n\t\t\t\t8184607D1D3503E8004B0C46 /* LoadTextureRenderCommand.h */,\n\t\t\t\t8184607E1D3503E8004B0C46 /* RenderInstanceRenderCommand.cpp */,\n\t\t\t\t8184607F1D3503E8004B0C46 /* RenderInstanceRenderCommand.h */,\n\t\t\t\t817256031E0A9F2600A65625 /* RestoreCubemapRenderCommand.cpp */,\n\t\t\t\t817256041E0A9F2600A65625 /* RestoreCubemapRenderCommand.h */,\n\t\t\t\t818460801D3503E8004B0C46 /* RestoreMeshRenderCommand.cpp */,\n\t\t\t\t818460811D3503E8004B0C46 /* RestoreMeshRenderCommand.h */,\n\t\t\t\t81A616B21D357159007F7CC1 /* RestoreRenderTargetGroupCommand.cpp */,\n\t\t\t\t81A616B31D357159007F7CC1 /* RestoreRenderTargetGroupCommand.h */,\n\t\t\t\t818460821D3503E8004B0C46 /* RestoreTextureRenderCommand.cpp */,\n\t\t\t\t818460831D3503E8004B0C46 /* RestoreTextureRenderCommand.h */,\n\t\t\t\t817256051E0A9F2600A65625 /* UnloadCubemapRenderCommand.cpp */,\n\t\t\t\t817256061E0A9F2600A65625 /* UnloadCubemapRenderCommand.h */,\n\t\t\t\t818460841D3503E8004B0C46 /* UnloadMaterialGroupRenderCommand.cpp */,\n\t\t\t\t818460851D3503E8004B0C46 /* UnloadMaterialGroupRenderCommand.h */,\n\t\t\t\t818460861D3503E8004B0C46 /* UnloadMeshRenderCommand.cpp */,\n\t\t\t\t818460871D3503E8004B0C46 /* UnloadMeshRenderCommand.h */,\n\t\t\t\t818460881D3503E8004B0C46 /* UnloadShaderRenderCommand.cpp */,\n\t\t\t\t818460891D3503E8004B0C46 /* UnloadShaderRenderCommand.h */,\n\t\t\t\t8184608A1D3503E8004B0C46 /* UnloadTargetGroupRenderCommand.cpp */,\n\t\t\t\t8184608B1D3503E8004B0C46 /* UnloadTargetGroupRenderCommand.h */,\n\t\t\t\t8184608C1D3503E8004B0C46 /* UnloadTextureRenderCommand.cpp */,\n\t\t\t\t8184608D1D3503E8004B0C46 /* UnloadTextureRenderCommand.h */,\n\t\t\t);\n\t\t\tpath = Commands;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t818460951D3503E8004B0C46 /* Shader */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t818460961D3503E8004B0C46 /* CSShaderProvider.cpp */,\n\t\t\t\t818460971D3503E8004B0C46 /* CSShaderProvider.h */,\n\t\t\t\t818460981D3503E8004B0C46 /* RenderShader.h */,\n\t\t\t\t818460991D3503E8004B0C46 /* RenderShaderManager.cpp */,\n\t\t\t\t8184609A1D3503E8004B0C46 /* RenderShaderManager.h */,\n\t\t\t\t8184609B1D3503E8004B0C46 /* RenderShaderVariables.cpp */,\n\t\t\t\t8184609C1D3503E8004B0C46 /* RenderShaderVariables.h */,\n\t\t\t\t8184609D1D3503E8004B0C46 /* Shader.cpp */,\n\t\t\t\t8184609E1D3503E8004B0C46 /* Shader.h */,\n\t\t\t);\n\t\t\tpath = Shader;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t818460A01D3503E8004B0C46 /* Sprite */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t818460A11D3503E8004B0C46 /* SpriteComponent.cpp */,\n\t\t\t\t818460A21D3503E8004B0C46 /* SpriteComponent.h */,\n\t\t\t\t818460A31D3503E8004B0C46 /* SpriteMeshBuilder.cpp */,\n\t\t\t\t818460A41D3503E8004B0C46 /* SpriteMeshBuilder.h */,\n\t\t\t);\n\t\t\tpath = Sprite;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t818460A61D3503E8004B0C46 /* Target */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t81A616AF1D357133007F7CC1 /* TargetGroup.cpp */,\n\t\t\t\t81A616B01D357133007F7CC1 /* TargetGroup.h */,\n\t\t\t\t818460A71D3503E8004B0C46 /* RenderTargetGroup.cpp */,\n\t\t\t\t818460A81D3503E8004B0C46 /* RenderTargetGroup.h */,\n\t\t\t\t818460A91D3503E8004B0C46 /* RenderTargetGroupManager.cpp */,\n\t\t\t\t818460AA1D3503E8004B0C46 /* RenderTargetGroupManager.h */,\n\t\t\t);\n\t\t\tpath = Target;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t818460AC1D3503E8004B0C46 /* Texture */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t8172560B1E0ABE1500A65625 /* Cubemap.cpp */,\n\t\t\t\t8172560C1E0ABE1500A65625 /* Cubemap.h */,\n\t\t\t\t8172560E1E0AC08100A65625 /* CubemapProvider.cpp */,\n\t\t\t\t8172560F1E0AC08100A65625 /* CubemapProvider.h */,\n\t\t\t\t817256111E0AEF1F00A65625 /* CubemapResourceOptions.cpp */,\n\t\t\t\t817256121E0AEF1F00A65625 /* CubemapResourceOptions.h */,\n\t\t\t\t818460B31D3503E8004B0C46 /* RenderTexture.cpp */,\n\t\t\t\t818460B41D3503E8004B0C46 /* RenderTexture.h */,\n\t\t\t\t818460B51D3503E8004B0C46 /* RenderTextureManager.cpp */,\n\t\t\t\t818460B61D3503E8004B0C46 /* RenderTextureManager.h */,\n\t\t\t\t818460B71D3503E8004B0C46 /* Texture.cpp */,\n\t\t\t\t818460B81D3503E8004B0C46 /* Texture.h */,\n\t\t\t\t818460B91D3503E8004B0C46 /* TextureAtlas.cpp */,\n\t\t\t\t818460BA1D3503E8004B0C46 /* TextureAtlas.h */,\n\t\t\t\t818460BB1D3503E8004B0C46 /* TextureAtlasProvider.cpp */,\n\t\t\t\t818460BC1D3503E8004B0C46 /* TextureAtlasProvider.h */,\n\t\t\t\t818460BD1D3503E8004B0C46 /* TextureDesc.cpp */,\n\t\t\t\t818460BE1D3503E8004B0C46 /* TextureDesc.h */,\n\t\t\t\t818460BF1D3503E8004B0C46 /* TextureFilterMode.h */,\n\t\t\t\t818460C01D3503E8004B0C46 /* TextureProvider.cpp */,\n\t\t\t\t818460C11D3503E8004B0C46 /* TextureProvider.h */,\n\t\t\t\t818460C21D3503E8004B0C46 /* TextureResourceOptions.cpp */,\n\t\t\t\t818460C31D3503E8004B0C46 /* TextureResourceOptions.h */,\n\t\t\t\t8172560A1E0ABBB000A65625 /* TextureType.h */,\n\t\t\t\t818460C41D3503E8004B0C46 /* TextureWrapMode.h */,\n\t\t\t\t818460C51D3503E8004B0C46 /* UVs.cpp */,\n\t\t\t\t818460C61D3503E8004B0C46 /* UVs.h */,\n\t\t\t);\n\t\t\tpath = Texture;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t818460C81D3503E8004B0C46 /* Social */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t818460C91D3503E8004B0C46 /* Communications */,\n\t\t\t\t818460CC1D3503E8004B0C46 /* Communications.h */,\n\t\t\t\t818460D31D3503E8004B0C46 /* ForwardDeclarations.h */,\n\t\t\t);\n\t\t\tpath = Social;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t818460C91D3503E8004B0C46 /* Communications */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t818460CA1D3503E8004B0C46 /* EmailComposer.cpp */,\n\t\t\t\t818460CB1D3503E8004B0C46 /* EmailComposer.h */,\n\t\t\t);\n\t\t\tpath = Communications;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t818460D41D3503E8004B0C46 /* UI */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t818460D51D3503E8004B0C46 /* Base */,\n\t\t\t\t818460F21D3503E8004B0C46 /* Base.h */,\n\t\t\t\t818460F31D3503E8004B0C46 /* Button */,\n\t\t\t\t818460F81D3503E8004B0C46 /* Button.h */,\n\t\t\t\t818460F91D3503E8004B0C46 /* Drawable */,\n\t\t\t\t8184610E1D3503E8004B0C46 /* Drawable.h */,\n\t\t\t\t8184610F1D3503E8004B0C46 /* ForwardDeclarations.h */,\n\t\t\t\t818461101D3503E8004B0C46 /* Layout */,\n\t\t\t\t818461241D3503E8004B0C46 /* Layout.h */,\n\t\t\t\t818461251D3503E8004B0C46 /* ProgressBar */,\n\t\t\t\t8184612C1D3503E8004B0C46 /* ProgressBar.h */,\n\t\t\t\t8184612D1D3503E8004B0C46 /* Slider */,\n\t\t\t\t818461321D3503E8004B0C46 /* Slider.h */,\n\t\t\t\t818461331D3503E8004B0C46 /* Text */,\n\t\t\t\t8184613B1D3503E8004B0C46 /* Text.h */,\n\t\t\t);\n\t\t\tpath = UI;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t818460D51D3503E8004B0C46 /* Base */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t818460D61D3503E8004B0C46 /* Canvas.cpp */,\n\t\t\t\t818460D71D3503E8004B0C46 /* Canvas.h */,\n\t\t\t\t8155F30A1E785B7700750A05 /* CursorSystem.cpp */,\n\t\t\t\t8155F30B1E785B7700750A05 /* CursorSystem.h */,\n\t\t\t\t818460D81D3503E8004B0C46 /* PropertyLink.cpp */,\n\t\t\t\t818460D91D3503E8004B0C46 /* PropertyLink.h */,\n\t\t\t\t818460DA1D3503E8004B0C46 /* PropertyTypes.cpp */,\n\t\t\t\t818460DB1D3503E8004B0C46 /* PropertyTypes.h */,\n\t\t\t\t818460DC1D3503E8004B0C46 /* UIComponent.cpp */,\n\t\t\t\t818460DD1D3503E8004B0C46 /* UIComponent.h */,\n\t\t\t\t818460DE1D3503E8004B0C46 /* UIComponentDesc.cpp */,\n\t\t\t\t818460DF1D3503E8004B0C46 /* UIComponentDesc.h */,\n\t\t\t\t818460E01D3503E8004B0C46 /* UIComponentFactory.cpp */,\n\t\t\t\t818460E11D3503E8004B0C46 /* UIComponentFactory.h */,\n\t\t\t\t818460E21D3503E8004B0C46 /* Widget.cpp */,\n\t\t\t\t818460E31D3503E8004B0C46 /* Widget.h */,\n\t\t\t\t818460E41D3503E8004B0C46 /* WidgetDef.cpp */,\n\t\t\t\t818460E51D3503E8004B0C46 /* WidgetDef.h */,\n\t\t\t\t818460E61D3503E8004B0C46 /* WidgetDefProvider.cpp */,\n\t\t\t\t818460E71D3503E8004B0C46 /* WidgetDefProvider.h */,\n\t\t\t\t818460E81D3503E8004B0C46 /* WidgetDesc.cpp */,\n\t\t\t\t818460E91D3503E8004B0C46 /* WidgetDesc.h */,\n\t\t\t\t818460EA1D3503E8004B0C46 /* WidgetFactory.cpp */,\n\t\t\t\t818460EB1D3503E8004B0C46 /* WidgetFactory.h */,\n\t\t\t\t818460EC1D3503E8004B0C46 /* WidgetParserUtils.cpp */,\n\t\t\t\t818460ED1D3503E8004B0C46 /* WidgetParserUtils.h */,\n\t\t\t\t818460EE1D3503E8004B0C46 /* WidgetTemplate.cpp */,\n\t\t\t\t818460EF1D3503E8004B0C46 /* WidgetTemplate.h */,\n\t\t\t\t818460F01D3503E8004B0C46 /* WidgetTemplateProvider.cpp */,\n\t\t\t\t818460F11D3503E8004B0C46 /* WidgetTemplateProvider.h */,\n\t\t\t);\n\t\t\tpath = Base;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t818460F31D3503E8004B0C46 /* Button */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t818460F41D3503E8004B0C46 /* HighlightUIComponent.cpp */,\n\t\t\t\t818460F51D3503E8004B0C46 /* HighlightUIComponent.h */,\n\t\t\t\t818460F61D3503E8004B0C46 /* ToggleHighlightUIComponent.cpp */,\n\t\t\t\t818460F71D3503E8004B0C46 /* ToggleHighlightUIComponent.h */,\n\t\t\t);\n\t\t\tpath = Button;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t818460F91D3503E8004B0C46 /* Drawable */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t818460FA1D3503E8004B0C46 /* DrawableUIComponent.cpp */,\n\t\t\t\t818460FB1D3503E8004B0C46 /* DrawableUIComponent.h */,\n\t\t\t\t818460FC1D3503E8004B0C46 /* NinePatchUIDrawable.cpp */,\n\t\t\t\t818460FD1D3503E8004B0C46 /* NinePatchUIDrawable.h */,\n\t\t\t\t818460FE1D3503E8004B0C46 /* NinePatchUIDrawableDef.cpp */,\n\t\t\t\t818460FF1D3503E8004B0C46 /* NinePatchUIDrawableDef.h */,\n\t\t\t\t818461001D3503E8004B0C46 /* StandardUIDrawable.cpp */,\n\t\t\t\t818461011D3503E8004B0C46 /* StandardUIDrawable.h */,\n\t\t\t\t818461021D3503E8004B0C46 /* StandardUIDrawableDef.cpp */,\n\t\t\t\t818461031D3503E8004B0C46 /* StandardUIDrawableDef.h */,\n\t\t\t\t818461041D3503E8004B0C46 /* ThreePatchUIDrawable.cpp */,\n\t\t\t\t818461051D3503E8004B0C46 /* ThreePatchUIDrawable.h */,\n\t\t\t\t818461061D3503E8004B0C46 /* ThreePatchUIDrawableDef.cpp */,\n\t\t\t\t818461071D3503E8004B0C46 /* ThreePatchUIDrawableDef.h */,\n\t\t\t\t818461081D3503E8004B0C46 /* UIDrawable.cpp */,\n\t\t\t\t818461091D3503E8004B0C46 /* UIDrawable.h */,\n\t\t\t\t8184610A1D3503E8004B0C46 /* UIDrawableDef.cpp */,\n\t\t\t\t8184610B1D3503E8004B0C46 /* UIDrawableDef.h */,\n\t\t\t\t8184610C1D3503E8004B0C46 /* UIDrawableUtils.cpp */,\n\t\t\t\t8184610D1D3503E8004B0C46 /* UIDrawableUtils.h */,\n\t\t\t);\n\t\t\tpath = Drawable;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t818461101D3503E8004B0C46 /* Layout */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t818461111D3503E8004B0C46 /* GridUILayout.cpp */,\n\t\t\t\t818461121D3503E8004B0C46 /* GridUILayout.h */,\n\t\t\t\t818461131D3503E8004B0C46 /* GridUILayoutDef.cpp */,\n\t\t\t\t818461141D3503E8004B0C46 /* GridUILayoutDef.h */,\n\t\t\t\t818461151D3503E8004B0C46 /* HListUILayout.cpp */,\n\t\t\t\t818461161D3503E8004B0C46 /* HListUILayout.h */,\n\t\t\t\t818461171D3503E8004B0C46 /* HListUILayoutDef.cpp */,\n\t\t\t\t818461181D3503E8004B0C46 /* HListUILayoutDef.h */,\n\t\t\t\t818461191D3503E8004B0C46 /* LayoutDef.h */,\n\t\t\t\t8184611A1D3503E8004B0C46 /* LayoutUIComponent.cpp */,\n\t\t\t\t8184611B1D3503E8004B0C46 /* LayoutUIComponent.h */,\n\t\t\t\t8184611C1D3503E8004B0C46 /* UILayout.cpp */,\n\t\t\t\t8184611D1D3503E8004B0C46 /* UILayout.h */,\n\t\t\t\t8184611E1D3503E8004B0C46 /* UILayoutDef.cpp */,\n\t\t\t\t8184611F1D3503E8004B0C46 /* UILayoutDef.h */,\n\t\t\t\t818461201D3503E8004B0C46 /* VListUILayout.cpp */,\n\t\t\t\t818461211D3503E8004B0C46 /* VListUILayout.h */,\n\t\t\t\t818461221D3503E8004B0C46 /* VListUILayoutDef.cpp */,\n\t\t\t\t818461231D3503E8004B0C46 /* VListUILayoutDef.h */,\n\t\t\t);\n\t\t\tpath = Layout;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t818461251D3503E8004B0C46 /* ProgressBar */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t818461261D3503E8004B0C46 /* ProgressBarDirection.cpp */,\n\t\t\t\t818461271D3503E8004B0C46 /* ProgressBarDirection.h */,\n\t\t\t\t818461281D3503E8004B0C46 /* ProgressBarType.cpp */,\n\t\t\t\t818461291D3503E8004B0C46 /* ProgressBarType.h */,\n\t\t\t\t8184612A1D3503E8004B0C46 /* ProgressBarUIComponent.cpp */,\n\t\t\t\t8184612B1D3503E8004B0C46 /* ProgressBarUIComponent.h */,\n\t\t\t);\n\t\t\tpath = ProgressBar;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t8184612D1D3503E8004B0C46 /* Slider */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t8184612E1D3503E8004B0C46 /* SliderDirection.cpp */,\n\t\t\t\t8184612F1D3503E8004B0C46 /* SliderDirection.h */,\n\t\t\t\t818461301D3503E8004B0C46 /* SliderUIComponent.cpp */,\n\t\t\t\t818461311D3503E8004B0C46 /* SliderUIComponent.h */,\n\t\t\t);\n\t\t\tpath = Slider;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t818461331D3503E8004B0C46 /* Text */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t818461341D3503E8004B0C46 /* EditableTextUIComponent.cpp */,\n\t\t\t\t818461351D3503E8004B0C46 /* EditableTextUIComponent.h */,\n\t\t\t\t818461361D3503E8004B0C46 /* TextComponent.h */,\n\t\t\t\t818461371D3503E8004B0C46 /* TextIcon.cpp */,\n\t\t\t\t818461381D3503E8004B0C46 /* TextIcon.h */,\n\t\t\t\t818461391D3503E8004B0C46 /* TextUIComponent.cpp */,\n\t\t\t\t8184613A1D3503E8004B0C46 /* TextUIComponent.h */,\n\t\t\t);\n\t\t\tpath = Text;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t8184613C1D3503E8004B0C46 /* Video */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t8184613D1D3503E8004B0C46 /* Base */,\n\t\t\t\t818461441D3503E8004B0C46 /* Base.h */,\n\t\t\t\t818461451D3503E8004B0C46 /* ForwardDeclarations.h */,\n\t\t\t);\n\t\t\tpath = Video;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t8184613D1D3503E8004B0C46 /* Base */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t8184613E1D3503E8004B0C46 /* CSSubtitlesProvider.cpp */,\n\t\t\t\t8184613F1D3503E8004B0C46 /* CSSubtitlesProvider.h */,\n\t\t\t\t818461401D3503E8004B0C46 /* Subtitles.cpp */,\n\t\t\t\t818461411D3503E8004B0C46 /* Subtitles.h */,\n\t\t\t\t818461421D3503E8004B0C46 /* VideoPlayer.cpp */,\n\t\t\t\t818461431D3503E8004B0C46 /* VideoPlayer.h */,\n\t\t\t);\n\t\t\tpath = Base;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t818461461D3503E8004B0C46 /* Web */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t818461471D3503E8004B0C46 /* Base */,\n\t\t\t\t8184614A1D3503E8004B0C46 /* Base.h */,\n\t\t\t\t8184614B1D3503E8004B0C46 /* ForwardDeclarations.h */,\n\t\t\t);\n\t\t\tpath = Web;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t818461471D3503E8004B0C46 /* Base */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t818461481D3503E8004B0C46 /* WebView.cpp */,\n\t\t\t\t818461491D3503E8004B0C46 /* WebView.h */,\n\t\t\t);\n\t\t\tpath = Base;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t81A5AF5C1D11575A00307707 /* Shader */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t81A5AF5D1D11575A00307707 /* GLShader.cpp */,\n\t\t\t\t81A5AF5E1D11575A00307707 /* GLShader.h */,\n\t\t\t);\n\t\t\tpath = Shader;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t81A5AF641D1190FB00307707 /* Texture */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t817255FB1E0A91FB00A65625 /* GLCubemap.cpp */,\n\t\t\t\t817255FC1E0A91FB00A65625 /* GLCubemap.h */,\n\t\t\t\t81A5AF651D1190FB00307707 /* GLTexture.cpp */,\n\t\t\t\t81A5AF661D1190FB00307707 /* GLTexture.h */,\n\t\t\t\t81729FA91D1BFF05005B8CC9 /* GLTextureUnitManager.cpp */,\n\t\t\t\t81729FAA1D1BFF05005B8CC9 /* GLTextureUnitManager.h */,\n\t\t\t\t817255FE1E0A958500A65625 /* GLTextureUtils.cpp */,\n\t\t\t\t817255FF1E0A958500A65625 /* GLTextureUtils.h */,\n\t\t\t);\n\t\t\tpath = Texture;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t81C7FE121C89DD0500D306F9 /* Libraries */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t81C7FE131C89DD0500D306F9 /* Core */,\n\t\t\t\t81C7FF351C89DD0600D306F9 /* CricketAudio */,\n\t\t\t);\n\t\t\tname = Libraries;\n\t\t\tpath = ../../Libraries;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t81C7FE131C89DD0500D306F9 /* Core */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t81C7FE4F1C89DD0500D306F9 /* iOS */,\n\t\t\t);\n\t\t\tpath = Core;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t81C7FE4F1C89DD0500D306F9 /* iOS */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t81C7FE501C89DD0500D306F9 /* Headers */,\n\t\t\t\t81C7FE801C89DD0500D306F9 /* Libs */,\n\t\t\t);\n\t\t\tpath = iOS;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t81C7FE501C89DD0500D306F9 /* Headers */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t27B4258D1E6058F800E17750 /* SHA256 */,\n\t\t\t\t81C7FE511C89DD0500D306F9 /* aes */,\n\t\t\t\t81C7FE531C89DD0500D306F9 /* base64 */,\n\t\t\t\t81C7FE551C89DD0500D306F9 /* json */,\n\t\t\t\t81C7FE641C89DD0500D306F9 /* md5 */,\n\t\t\t\t81C7FE661C89DD0500D306F9 /* minizip */,\n\t\t\t\t81C7FE6E1C89DD0500D306F9 /* png */,\n\t\t\t\t81C7FE761C89DD0500D306F9 /* rapidxml */,\n\t\t\t\t81C7FE7B1C89DD0500D306F9 /* Reachability */,\n\t\t\t\t81C7FE7D1C89DD0500D306F9 /* SHA1 */,\n\t\t\t);\n\t\t\tpath = Headers;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t81C7FE511C89DD0500D306F9 /* aes */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t81C7FE521C89DD0500D306F9 /* aes.h */,\n\t\t\t);\n\t\t\tpath = aes;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t81C7FE531C89DD0500D306F9 /* base64 */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t81C7FE541C89DD0500D306F9 /* base64.h */,\n\t\t\t);\n\t\t\tpath = base64;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t81C7FE551C89DD0500D306F9 /* json */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t81C7FE561C89DD0500D306F9 /* assertions.h */,\n\t\t\t\t81C7FE571C89DD0500D306F9 /* autolink.h */,\n\t\t\t\t81C7FE581C89DD0500D306F9 /* config.h */,\n\t\t\t\t81C7FE591C89DD0500D306F9 /* features.h */,\n\t\t\t\t81C7FE5A1C89DD0500D306F9 /* forwards.h */,\n\t\t\t\t81C7FE5B1C89DD0500D306F9 /* json.h */,\n\t\t\t\t81C7FE5C1C89DD0500D306F9 /* json_batchallocator.h */,\n\t\t\t\t81C7FE5D1C89DD0500D306F9 /* json_internalarray.inl */,\n\t\t\t\t81C7FE5E1C89DD0500D306F9 /* json_internalmap.inl */,\n\t\t\t\t81C7FE5F1C89DD0500D306F9 /* json_tool.h */,\n\t\t\t\t81C7FE601C89DD0500D306F9 /* json_valueiterator.inl */,\n\t\t\t\t81C7FE611C89DD0500D306F9 /* reader.h */,\n\t\t\t\t81C7FE621C89DD0500D306F9 /* value.h */,\n\t\t\t\t81C7FE631C89DD0500D306F9 /* writer.h */,\n\t\t\t);\n\t\t\tpath = json;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t81C7FE641C89DD0500D306F9 /* md5 */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t81C7FE651C89DD0500D306F9 /* md5.h */,\n\t\t\t);\n\t\t\tpath = md5;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t81C7FE661C89DD0500D306F9 /* minizip */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t81C7FE671C89DD0500D306F9 /* additional.h */,\n\t\t\t\t81C7FE681C89DD0500D306F9 /* crypt.h */,\n\t\t\t\t81C7FE691C89DD0500D306F9 /* ioapi.h */,\n\t\t\t\t81C7FE6A1C89DD0500D306F9 /* mztools.h */,\n\t\t\t\t81C7FE6B1C89DD0500D306F9 /* unzip.h */,\n\t\t\t\t81C7FE6C1C89DD0500D306F9 /* zconf.h */,\n\t\t\t\t81C7FE6D1C89DD0500D306F9 /* zip.h */,\n\t\t\t);\n\t\t\tpath = minizip;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t81C7FE6E1C89DD0500D306F9 /* png */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t81C7FE6F1C89DD0500D306F9 /* png.h */,\n\t\t\t\t81C7FE701C89DD0500D306F9 /* pngconf.h */,\n\t\t\t\t81C7FE711C89DD0500D306F9 /* pngdebug.h */,\n\t\t\t\t81C7FE721C89DD0500D306F9 /* pnginfo.h */,\n\t\t\t\t81C7FE731C89DD0500D306F9 /* pnglibconf.h */,\n\t\t\t\t81C7FE741C89DD0500D306F9 /* pngpriv.h */,\n\t\t\t\t81C7FE751C89DD0500D306F9 /* pngstruct.h */,\n\t\t\t);\n\t\t\tpath = png;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t81C7FE761C89DD0500D306F9 /* rapidxml */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t81C7FE771C89DD0500D306F9 /* rapidxml.hpp */,\n\t\t\t\t81C7FE781C89DD0500D306F9 /* rapidxml_iterators.hpp */,\n\t\t\t\t81C7FE791C89DD0500D306F9 /* rapidxml_print.hpp */,\n\t\t\t\t81C7FE7A1C89DD0500D306F9 /* rapidxml_utils.hpp */,\n\t\t\t);\n\t\t\tpath = rapidxml;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t81C7FE7B1C89DD0500D306F9 /* Reachability */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t81C7FE7C1C89DD0500D306F9 /* CSReachability.h */,\n\t\t\t);\n\t\t\tpath = Reachability;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t81C7FE7D1C89DD0500D306F9 /* SHA1 */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t81C7FE7E1C89DD0500D306F9 /* HMAC_SHA1.h */,\n\t\t\t\t81C7FE7F1C89DD0500D306F9 /* SHA1.h */,\n\t\t\t);\n\t\t\tpath = SHA1;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t81C7FE801C89DD0500D306F9 /* Libs */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t81C7FE811C89DD0500D306F9 /* FacebookSDK.framework */,\n\t\t\t\t81C7FE821C89DD0500D306F9 /* libCSBase.a */,\n\t\t\t);\n\t\t\tpath = Libs;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t81C7FF351C89DD0600D306F9 /* CricketAudio */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t81C7FF4F1C89DD0600D306F9 /* iOS */,\n\t\t\t);\n\t\t\tpath = CricketAudio;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t81C7FF4F1C89DD0600D306F9 /* iOS */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t81C7FF501C89DD0600D306F9 /* Headers */,\n\t\t\t\t81C7FF611C89DD0600D306F9 /* Libs */,\n\t\t\t);\n\t\t\tpath = iOS;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t81C7FF501C89DD0600D306F9 /* Headers */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t81C7FF511C89DD0600D306F9 /* ck */,\n\t\t\t);\n\t\t\tpath = Headers;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t81C7FF511C89DD0600D306F9 /* ck */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t81C7FF521C89DD0600D306F9 /* attenuationmode.h */,\n\t\t\t\t81C7FF531C89DD0600D306F9 /* bank.h */,\n\t\t\t\t81C7FF541C89DD0600D306F9 /* ck.h */,\n\t\t\t\t81C7FF551C89DD0600D306F9 /* config.h */,\n\t\t\t\t81C7FF561C89DD0600D306F9 /* customfile.h */,\n\t\t\t\t81C7FF571C89DD0600D306F9 /* customstream.h */,\n\t\t\t\t81C7FF581C89DD0600D306F9 /* effect.h */,\n\t\t\t\t81C7FF591C89DD0600D306F9 /* effectbus.h */,\n\t\t\t\t81C7FF5A1C89DD0600D306F9 /* effectparam.h */,\n\t\t\t\t81C7FF5B1C89DD0600D306F9 /* effectprocessor.h */,\n\t\t\t\t81C7FF5C1C89DD0600D306F9 /* effecttype.h */,\n\t\t\t\t81C7FF5D1C89DD0600D306F9 /* mixer.h */,\n\t\t\t\t816D4B201E5DCDB300CA66A1 /* objc */,\n\t\t\t\t81C7FF5E1C89DD0600D306F9 /* pathtype.h */,\n\t\t\t\t81C7FF5F1C89DD0600D306F9 /* platform.h */,\n\t\t\t\t81C7FF601C89DD0600D306F9 /* sound.h */,\n\t\t\t);\n\t\t\tpath = ck;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t81C7FF611C89DD0600D306F9 /* Libs */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t81C7FF621C89DD0600D306F9 /* libck.a */,\n\t\t\t);\n\t\t\tpath = Libs;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t81C7FFA91C89DD3F00D306F9 /* Frameworks */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t81C7FFAA1C89DDE300D306F9 /* Accounts.framework */,\n\t\t\t\t81C7FFAB1C89DDE300D306F9 /* AddressBook.framework */,\n\t\t\t\t81C7FFAC1C89DDE300D306F9 /* AddressBookUI.framework */,\n\t\t\t\t81C7FFAD1C89DDE300D306F9 /* AdSupport.framework */,\n\t\t\t\t81C7FFAE1C89DDE300D306F9 /* AudioToolbox.framework */,\n\t\t\t\t81C7FFAF1C89DDE300D306F9 /* CFNetwork.framework */,\n\t\t\t\t81C7FFB01C89DDE300D306F9 /* CoreAudio.framework */,\n\t\t\t\t81C7FFB11C89DDE300D306F9 /* CoreGraphics.framework */,\n\t\t\t\t81C7FFB21C89DDE300D306F9 /* CoreLocation.framework */,\n\t\t\t\t81C7FFB31C89DDE300D306F9 /* CoreMotion.framework */,\n\t\t\t\t81C7FFB41C89DDE300D306F9 /* CoreTelephony.framework */,\n\t\t\t\t81C7FFB51C89DDE300D306F9 /* Foundation.framework */,\n\t\t\t\t81C7FFB61C89DDE300D306F9 /* GLKit.framework */,\n\t\t\t\t81C7FFB71C89DDE300D306F9 /* MapKit.framework */,\n\t\t\t\t81C7FFB81C89DDE300D306F9 /* MediaPlayer.framework */,\n\t\t\t\t81C7FFB91C89DDE300D306F9 /* MessageUI.framework */,\n\t\t\t\t81C7FFBA1C89DDE300D306F9 /* MobileCoreServices.framework */,\n\t\t\t\t81C7FFBB1C89DDE300D306F9 /* OpenGLES.framework */,\n\t\t\t\t81C7FFBC1C89DDE300D306F9 /* QuartzCore.framework */,\n\t\t\t\t81C7FFBD1C89DDE300D306F9 /* Security.framework */,\n\t\t\t\t81C7FFBE1C89DDE300D306F9 /* Social.framework */,\n\t\t\t\t81C7FFBF1C89DDE300D306F9 /* StoreKit.framework */,\n\t\t\t\t81C7FFC01C89DDE300D306F9 /* SystemConfiguration.framework */,\n\t\t\t\t81C7FFC11C89DDE300D306F9 /* UIKit.framework */,\n\t\t\t);\n\t\t\tname = Frameworks;\n\t\t\tpath = ../../Libraries;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n/* End PBXGroup section */\n\n/* Begin PBXNativeTarget section */\n\t\t8158F1E91C89D27300B13109 /* ChilliSource */ = {\n\t\t\tisa = PBXNativeTarget;\n\t\t\tbuildConfigurationList = 8158F1F31C89D27300B13109 /* Build configuration list for PBXNativeTarget \"ChilliSource\" */;\n\t\t\tbuildPhases = (\n\t\t\t\t8158F1E61C89D27300B13109 /* Sources */,\n\t\t\t\t8158F1E71C89D27300B13109 /* Frameworks */,\n\t\t\t\t8158F1E81C89D27300B13109 /* CopyFiles */,\n\t\t\t);\n\t\t\tbuildRules = (\n\t\t\t);\n\t\t\tdependencies = (\n\t\t\t);\n\t\t\tname = ChilliSource;\n\t\t\tproductName = ChilliSource;\n\t\t\tproductReference = 8158F1EA1C89D27300B13109 /* libChilliSource.a */;\n\t\t\tproductType = \"com.apple.product-type.library.static\";\n\t\t};\n/* End PBXNativeTarget section */\n\n/* Begin PBXProject section */\n\t\t8158F1E21C89D27300B13109 /* Project object */ = {\n\t\t\tisa = PBXProject;\n\t\t\tattributes = {\n\t\t\t\tLastUpgradeCheck = 0820;\n\t\t\t\tORGANIZATIONNAME = \"Tag Games\";\n\t\t\t\tTargetAttributes = {\n\t\t\t\t\t8158F1E91C89D27300B13109 = {\n\t\t\t\t\t\tCreatedOnToolsVersion = 7.2.1;\n\t\t\t\t\t};\n\t\t\t\t};\n\t\t\t};\n\t\t\tbuildConfigurationList = 8158F1E51C89D27300B13109 /* Build configuration list for PBXProject \"ChilliSource\" */;\n\t\t\tcompatibilityVersion = \"Xcode 3.2\";\n\t\t\tdevelopmentRegion = English;\n\t\t\thasScannedForEncodings = 0;\n\t\t\tknownRegions = (\n\t\t\t\ten,\n\t\t\t);\n\t\t\tmainGroup = 8158F1E11C89D27300B13109;\n\t\t\tproductRefGroup = 8158F1EB1C89D27300B13109 /* Products */;\n\t\t\tprojectDirPath = \"\";\n\t\t\tprojectRoot = \"\";\n\t\t\ttargets = (\n\t\t\t\t8158F1E91C89D27300B13109 /* ChilliSource */,\n\t\t\t);\n\t\t};\n/* End PBXProject section */\n\n/* Begin PBXSourcesBuildPhase section */\n\t\t8158F1E61C89D27300B13109 /* Sources */ = {\n\t\t\tisa = PBXSourcesBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t8184618B1D3503E8004B0C46 /* RemoteNotificationSystem.cpp in Sources */,\n\t\t\t\t818462031D3503E8004B0C46 /* ConcurrentParticleData.cpp in Sources */,\n\t\t\t\t8158F7CB1C89D2AD00B13109 /* LocalNotificationSystem.cpp in Sources */,\n\t\t\t\t8184617B1D3503E8004B0C46 /* PNGImageProvider.cpp in Sources */,\n\t\t\t\t818461551D3503E8004B0C46 /* Colour.cpp in Sources */,\n\t\t\t\t818461C61D3503E8004B0C46 /* Renderer.cpp in Sources */,\n\t\t\t\t818462481D3503E8004B0C46 /* UVs.cpp in Sources */,\n\t\t\t\t818462471D3503E8004B0C46 /* TextureResourceOptions.cpp in Sources */,\n\t\t\t\t818462071D3503E8004B0C46 /* ParticleDrawableDefFactory.cpp in Sources */,\n\t\t\t\t8184636F1D357706004B0C46 /* RenderMeshBatch.cpp in Sources */,\n\t\t\t\t818461721D3503E8004B0C46 /* FileWriteMode.cpp in Sources */,\n\t\t\t\t818461F21D3503E8004B0C46 /* Skeleton.cpp in Sources */,\n\t\t\t\t8184623A1D3503E8004B0C46 /* SpriteMeshBuilder.cpp in Sources */,\n\t\t\t\t818461AF1D3503E8004B0C46 /* Pointer.cpp in Sources */,\n\t\t\t\t8158F7D21C89D2AD00B13109 /* TextEntry.mm in Sources */,\n\t\t\t\t818461A71D3503E8004B0C46 /* Gesture.cpp in Sources */,\n\t\t\t\t8184618F1D3503E8004B0C46 /* Scene.cpp in Sources */,\n\t\t\t\t818461CB1D3503E8004B0C46 /* RenderPass.cpp in Sources */,\n\t\t\t\t818462171D3503E8004B0C46 /* ParticleEffect.cpp in Sources */,\n\t\t\t\t818462461D3503E8004B0C46 /* TextureProvider.cpp in Sources */,\n\t\t\t\t818C150B1D22F8F4001D639B /* GLDynamicMesh.cpp in Sources */,\n\t\t\t\t818461B01D3503E8004B0C46 /* PointerSystem.cpp in Sources */,\n\t\t\t\t818462321D3503E8004B0C46 /* RenderCommand.cpp in Sources */,\n\t\t\t\t8184625B1D3503E8004B0C46 /* ToggleHighlightUIComponent.cpp in Sources */,\n\t\t\t\t818461851D3503E8004B0C46 /* UnifiedCoordinates.cpp in Sources */,\n\t\t\t\t81A616B11D357133007F7CC1 /* TargetGroup.cpp in Sources */,\n\t\t\t\t813BA9DB1D37BE0600A3B091 /* RenderInfoFactory.cpp in Sources */,\n\t\t\t\t818462161D3503E8004B0C46 /* SphereParticleEmitterDef.cpp in Sources */,\n\t\t\t\t818462741D3503E8004B0C46 /* EditableTextUIComponent.cpp in Sources */,\n\t\t\t\t817255FD1E0A91FB00A65625 /* GLCubemap.cpp in Sources */,\n\t\t\t\t818461ED1D3503E8004B0C46 /* PrimitiveModelFactory.cpp in Sources */,\n\t\t\t\t8158F7D71C89D2AD00B13109 /* HttpRequestSystem.mm in Sources */,\n\t\t\t\t8184623B1D3503E8004B0C46 /* RenderTargetGroup.cpp in Sources */,\n\t\t\t\t818462651D3503E8004B0C46 /* UIDrawableUtils.cpp in Sources */,\n\t\t\t\t8184620D1D3503E8004B0C46 /* Cone2DParticleEmitterDef.cpp in Sources */,\n\t\t\t\t818462091D3503E8004B0C46 /* StaticBillboardParticleDrawableDef.cpp in Sources */,\n\t\t\t\t818461EE1D3503E8004B0C46 /* RenderDynamicMesh.cpp in Sources */,\n\t\t\t\t818461751D3503E8004B0C46 /* FileSystem.cpp in Sources */,\n\t\t\t\t818461A31D3503E8004B0C46 /* Accelerometer.cpp in Sources */,\n\t\t\t\t818462531D3503E8004B0C46 /* WidgetDef.cpp in Sources */,\n\t\t\t\t818462371D3503E8004B0C46 /* RenderShaderVariables.cpp in Sources */,\n\t\t\t\t8184615A1D3503E8004B0C46 /* PlatformSystem.cpp in Sources */,\n\t\t\t\t818462041D3503E8004B0C46 /* CSParticleProvider.cpp in Sources */,\n\t\t\t\t818461E11D3503E8004B0C46 /* MaterialFactory.cpp in Sources */,\n\t\t\t\t818461C41D3503E8004B0C46 /* RenderCommandCompiler.cpp in Sources */,\n\t\t\t\t818461A81D3503E8004B0C46 /* GestureSystem.cpp in Sources */,\n\t\t\t\t818462411D3503E8004B0C46 /* RenderTextureManager.cpp in Sources */,\n\t\t\t\t818461C91D3503E8004B0C46 /* RenderFrameData.cpp in Sources */,\n\t\t\t\t818461871D3503E8004B0C46 /* PagedLinearAllocator.cpp in Sources */,\n\t\t\t\t818462151D3503E8004B0C46 /* SphereParticleEmitter.cpp in Sources */,\n\t\t\t\t818461561D3503E8004B0C46 /* ColourUtils.cpp in Sources */,\n\t\t\t\t818462061D3503E8004B0C46 /* ParticleDrawableDef.cpp in Sources */,\n\t\t\t\t818461891D3503E8004B0C46 /* LocalNotificationSystem.cpp in Sources */,\n\t\t\t\t818461901D3503E8004B0C46 /* State.cpp in Sources */,\n\t\t\t\t818461B71D3503E8004B0C46 /* HttpResponse.cpp in Sources */,\n\t\t\t\t818462661D3503E8004B0C46 /* GridUILayout.cpp in Sources */,\n\t\t\t\t818462601D3503E8004B0C46 /* StandardUIDrawableDef.cpp in Sources */,\n\t\t\t\t818461571D3503E8004B0C46 /* Device.cpp in Sources */,\n\t\t\t\t818461DA1D3503E8004B0C46 /* AmbientRenderLight.cpp in Sources */,\n\t\t\t\t8184619B1D3503E8004B0C46 /* TaskPool.cpp in Sources */,\n\t\t\t\t818462381D3503E8004B0C46 /* Shader.cpp in Sources */,\n\t\t\t\t8184618C1D3503E8004B0C46 /* Resource.cpp in Sources */,\n\t\t\t\t8184615E1D3503E8004B0C46 /* ParamDictionarySerialiser.cpp in Sources */,\n\t\t\t\t27408C291D36DCB600A0B003 /* ScreenInfo.cpp in Sources */,\n\t\t\t\t27408C091D366C7A00A0B003 /* SystemInfo.cpp in Sources */,\n\t\t\t\t817256091E0A9F2600A65625 /* UnloadCubemapRenderCommand.cpp in Sources */,\n\t\t\t\t8184627D1D350409004B0C46 /* GLSkinnedAnimation.cpp in Sources */,\n\t\t\t\t818461FE1D3503E8004B0C46 /* ParticleAffector.cpp in Sources */,\n\t\t\t\t818461BD1D3503E8004B0C46 /* CanvasRenderer.cpp in Sources */,\n\t\t\t\t8184625F1D3503E8004B0C46 /* StandardUIDrawable.cpp in Sources */,\n\t\t\t\t8158F7E41C89D2AD00B13109 /* WebView.mm in Sources */,\n\t\t\t\t818461A41D3503E8004B0C46 /* InputFilter.cpp in Sources */,\n\t\t\t\t810C0C841D11B01100C32406 /* GLMesh.cpp in Sources */,\n\t\t\t\t818461EF1D3503E8004B0C46 /* RenderMesh.cpp in Sources */,\n\t\t\t\t8184636C1D35493A004B0C46 /* ApplyMeshBatchRenderCommand.cpp in Sources */,\n\t\t\t\t818462591D3503E8004B0C46 /* WidgetTemplateProvider.cpp in Sources */,\n\t\t\t\t818462391D3503E8004B0C46 /* SpriteComponent.cpp in Sources */,\n\t\t\t\t8184617A1D3503E8004B0C46 /* ImageFormatConverter.cpp in Sources */,\n\t\t\t\t818461781D3503E8004B0C46 /* ETC1ImageProvider.cpp in Sources */,\n\t\t\t\t8184620F1D3503E8004B0C46 /* ConeParticleEmitterDef.cpp in Sources */,\n\t\t\t\t818462641D3503E8004B0C46 /* UIDrawableDef.cpp in Sources */,\n\t\t\t\t818461711D3503E8004B0C46 /* BinaryOutputStream.cpp in Sources */,\n\t\t\t\t818461CA1D3503E8004B0C46 /* RenderObject.cpp in Sources */,\n\t\t\t\t818462011D3503E8004B0C46 /* ScaleOverLifetimeParticleAffector.cpp in Sources */,\n\t\t\t\t818462181D3503E8004B0C46 /* ParticleEffectComponent.cpp in Sources */,\n\t\t\t\t81559AB01E925F4C00A1B107 /* GamepadSystem.cpp in Sources */,\n\t\t\t\t818461671D3503E8004B0C46 /* DialogueBoxSystem.cpp in Sources */,\n\t\t\t\t818461841D3503E8004B0C46 /* Random.cpp in Sources */,\n\t\t\t\t818461A51D3503E8004B0C46 /* DeviceButtonSystem.cpp in Sources */,\n\t\t\t\t818461D81D3503E8004B0C46 /* FontProvider.cpp in Sources */,\n\t\t\t\t818461881D3503E8004B0C46 /* AppNotificationSystem.cpp in Sources */,\n\t\t\t\t818461DB1D3503E8004B0C46 /* DirectionalLightComponent.cpp in Sources */,\n\t\t\t\t818461BE1D3503E8004B0C46 /* ForwardRenderPassCompiler.cpp in Sources */,\n\t\t\t\t818461B31D3503E8004B0C46 /* TextEntryType.cpp in Sources */,\n\t\t\t\t8184619D1D3503E8004B0C46 /* CoreTimer.cpp in Sources */,\n\t\t\t\t818462331D3503E8004B0C46 /* RenderCommandBuffer.cpp in Sources */,\n\t\t\t\t818461B41D3503E8004B0C46 /* ContentManagementSystem.cpp in Sources */,\n\t\t\t\t8158F7CD1C89D2AD00B13109 /* RemoteNotificationSystem.cpp in Sources */,\n\t\t\t\t818461741D3503E8004B0C46 /* TextOutputStream.cpp in Sources */,\n\t\t\t\t813BA9D81D379F6D00A3B091 /* RenderInfo.cpp in Sources */,\n\t\t\t\t8158F7D91C89D2AD00B13109 /* StoreKitIAPSystem.mm in Sources */,\n\t\t\t\t8184615F1D3503E8004B0C46 /* PropertyMap.cpp in Sources */,\n\t\t\t\t818462191D3503E8004B0C46 /* ParticlePropertyFactoryImpl.cpp in Sources */,\n\t\t\t\t8158F7E21C89D2AD00B13109 /* VideoPlayer.mm in Sources */,\n\t\t\t\t8184622B1D3503E8004B0C46 /* RestoreMeshRenderCommand.cpp in Sources */,\n\t\t\t\t8184614F1D3503E8004B0C46 /* CkSound.cpp in Sources */,\n\t\t\t\t818462491D3503E8004B0C46 /* EmailComposer.cpp in Sources */,\n\t\t\t\t8158F7D11C89D2AD00B13109 /* PointerSystem.mm in Sources */,\n\t\t\t\t818461D11D3503E8004B0C46 /* TargetRenderPassGroup.cpp in Sources */,\n\t\t\t\t818462401D3503E8004B0C46 /* RenderTexture.cpp in Sources */,\n\t\t\t\t818461CF1D3503E8004B0C46 /* RenderSnapshot.cpp in Sources */,\n\t\t\t\t818462441D3503E8004B0C46 /* TextureAtlasProvider.cpp in Sources */,\n\t\t\t\t8151757A1E3F4E5C0024361A /* SkyboxComponent.cpp in Sources */,\n\t\t\t\t818462621D3503E8004B0C46 /* ThreePatchUIDrawableDef.cpp in Sources */,\n\t\t\t\t8184620B1D3503E8004B0C46 /* CircleParticleEmitterDef.cpp in Sources */,\n\t\t\t\t818461761D3503E8004B0C46 /* TaggedFilePathResolver.cpp in Sources */,\n\t\t\t\t818461C71D3503E8004B0C46 /* RenderFrame.cpp in Sources */,\n\t\t\t\t8184625E1D3503E8004B0C46 /* NinePatchUIDrawableDef.cpp in Sources */,\n\t\t\t\t817B8F8D1D2AE21300273F4B /* GLAmbientLight.cpp in Sources */,\n\t\t\t\t818461B91D3503E8004B0C46 /* AlignmentAnchors.cpp in Sources */,\n\t\t\t\t818461C01D3503E8004B0C46 /* HorizontalTextJustification.cpp in Sources */,\n\t\t\t\t8184625C1D3503E8004B0C46 /* DrawableUIComponent.cpp in Sources */,\n\t\t\t\t818461AD1D3503E8004B0C46 /* Keyboard.cpp in Sources */,\n\t\t\t\t818461D21D3503E8004B0C46 /* VerticalTextJustification.cpp in Sources */,\n\t\t\t\t818461931D3503E8004B0C46 /* StringMarkupParser.cpp in Sources */,\n\t\t\t\t8184626E1D3503E8004B0C46 /* VListUILayoutDef.cpp in Sources */,\n\t\t\t\t8184620C1D3503E8004B0C46 /* Cone2DParticleEmitter.cpp in Sources */,\n\t\t\t\t818462691D3503E8004B0C46 /* HListUILayoutDef.cpp in Sources */,\n\t\t\t\t8158F7E51C89D2AD00B13109 /* WebViewDelegate.mm in Sources */,\n\t\t\t\t8184619E1D3503E8004B0C46 /* PerformanceTimer.cpp in Sources */,\n\t\t\t\t818462671D3503E8004B0C46 /* GridUILayoutDef.cpp in Sources */,\n\t\t\t\t818461511D3503E8004B0C46 /* AppConfig.cpp in Sources */,\n\t\t\t\t818461611D3503E8004B0C46 /* AESEncrypt.cpp in Sources */,\n\t\t\t\t818461EC1D3503E8004B0C46 /* ModelDesc.cpp in Sources */,\n\t\t\t\t818461771D3503E8004B0C46 /* CSImageProvider.cpp in Sources */,\n\t\t\t\t81A5AF671D1190FB00307707 /* GLTexture.cpp in Sources */,\n\t\t\t\t27408C081D366C7A00A0B003 /* DeviceInfo.cpp in Sources */,\n\t\t\t\t8184619A1D3503E8004B0C46 /* TaskContext.cpp in Sources */,\n\t\t\t\t818462581D3503E8004B0C46 /* WidgetTemplate.cpp in Sources */,\n\t\t\t\t8184617F1D3503E8004B0C46 /* LocalisedTextProvider.cpp in Sources */,\n\t\t\t\t818461D91D3503E8004B0C46 /* AmbientLightComponent.cpp in Sources */,\n\t\t\t\t818462211D3503E8004B0C46 /* ApplySkinnedAnimationRenderCommand.cpp in Sources */,\n\t\t\t\t8158F7E01C89D2AD00B13109 /* SubtitlesRenderer.mm in Sources */,\n\t\t\t\t818461651D3503E8004B0C46 /* HashSHA1.cpp in Sources */,\n\t\t\t\t818461FD1D3503E8004B0C46 /* ColourOverLifetimeParticleAffectorDef.cpp in Sources */,\n\t\t\t\t818462201D3503E8004B0C46 /* ApplyPointLightRenderCommand.cpp in Sources */,\n\t\t\t\t818462281D3503E8004B0C46 /* LoadTargetGroupRenderCommand.cpp in Sources */,\n\t\t\t\t818461E81D3503E8004B0C46 /* CSModelProvider.cpp in Sources */,\n\t\t\t\t818461BB1D3503E8004B0C46 /* CameraRenderPassGroup.cpp in Sources */,\n\t\t\t\t817256081E0A9F2600A65625 /* RestoreCubemapRenderCommand.cpp in Sources */,\n\t\t\t\t8184614D1D3503E8004B0C46 /* CkBank.cpp in Sources */,\n\t\t\t\t8184615C1D3503E8004B0C46 /* Utils.cpp in Sources */,\n\t\t\t\t818462791D3503E8004B0C46 /* VideoPlayer.cpp in Sources */,\n\t\t\t\t818461AA1D3503E8004B0C46 /* PinchGesture.cpp in Sources */,\n\t\t\t\t818461D51D3503E8004B0C46 /* PerspectiveCameraComponent.cpp in Sources */,\n\t\t\t\t818461DF1D3503E8004B0C46 /* ForwardRenderMaterialGroupManager.cpp in Sources */,\n\t\t\t\t818461E31D3503E8004B0C46 /* RenderMaterial.cpp in Sources */,\n\t\t\t\t8184621B1D3503E8004B0C46 /* ApplyCameraRenderCommand.cpp in Sources */,\n\t\t\t\t818461CE1D3503E8004B0C46 /* RenderPassVisibilityChecker.cpp in Sources */,\n\t\t\t\t818462271D3503E8004B0C46 /* LoadShaderRenderCommand.cpp in Sources */,\n\t\t\t\t818462001D3503E8004B0C46 /* ParticleAffectorDefFactory.cpp in Sources */,\n\t\t\t\t818461541D3503E8004B0C46 /* ByteColour.cpp in Sources */,\n\t\t\t\t8184620E1D3503E8004B0C46 /* ConeParticleEmitter.cpp in Sources */,\n\t\t\t\t8172560D1E0ABE1500A65625 /* Cubemap.cpp in Sources */,\n\t\t\t\t818462361D3503E8004B0C46 /* RenderShaderManager.cpp in Sources */,\n\t\t\t\t818462721D3503E8004B0C46 /* SliderDirection.cpp in Sources */,\n\t\t\t\t818463691D353765004B0C46 /* SmallMeshBatcher.cpp in Sources */,\n\t\t\t\t8184616B1D3503E8004B0C46 /* Transform.cpp in Sources */,\n\t\t\t\t2787EA6B1E30D4EC00E83458 /* Gyroscope.cpp in Sources */,\n\t\t\t\t8158F7C61C89D2AD00B13109 /* DialogueBoxListener.mm in Sources */,\n\t\t\t\t818461831D3503E8004B0C46 /* MathUtils.cpp in Sources */,\n\t\t\t\t8155F30C1E785B7700750A05 /* CursorSystem.cpp in Sources */,\n\t\t\t\t8158F7DB1C89D2AD00B13109 /* EmailComposerDelegate.mm in Sources */,\n\t\t\t\t818461811D3503E8004B0C46 /* Shapes.cpp in Sources */,\n\t\t\t\t818461961D3503E8004B0C46 /* ToString.cpp in Sources */,\n\t\t\t\t81729FA41D1BE681005B8CC9 /* GLMaterial.cpp in Sources */,\n\t\t\t\t818461FC1D3503E8004B0C46 /* ColourOverLifetimeParticleAffector.cpp in Sources */,\n\t\t\t\t8184619F1D3503E8004B0C46 /* Timer.cpp in Sources */,\n\t\t\t\t818461581D3503E8004B0C46 /* LifecycleManager.cpp in Sources */,\n\t\t\t\t818462521D3503E8004B0C46 /* Widget.cpp in Sources */,\n\t\t\t\t818461E61D3503E8004B0C46 /* AnimatedModelComponent.cpp in Sources */,\n\t\t\t\t818462611D3503E8004B0C46 /* ThreePatchUIDrawable.cpp in Sources */,\n\t\t\t\t8158F7D01C89D2AD00B13109 /* DeviceButtonSystem.mm in Sources */,\n\t\t\t\t818461911D3503E8004B0C46 /* StateManager.cpp in Sources */,\n\t\t\t\t818462781D3503E8004B0C46 /* Subtitles.cpp in Sources */,\n\t\t\t\t8158F7C11C89D2AD00B13109 /* CSAppDelegate.mm in Sources */,\n\t\t\t\t818461A11D3503E8004B0C46 /* XML.cpp in Sources */,\n\t\t\t\t818461701D3503E8004B0C46 /* BinaryInputStream.cpp in Sources */,\n\t\t\t\t8184614C1D3503E8004B0C46 /* CkAudioPlayer.cpp in Sources */,\n\t\t\t\t81A5AF5F1D11575A00307707 /* GLShader.cpp in Sources */,\n\t\t\t\t818461821D3503E8004B0C46 /* Interpolate.cpp in Sources */,\n\t\t\t\t818461E91D3503E8004B0C46 /* IndexFormat.cpp in Sources */,\n\t\t\t\t8184614E1D3503E8004B0C46 /* CkBankProvider.cpp in Sources */,\n\t\t\t\t818461BF1D3503E8004B0C46 /* FrameAllocatorQueue.cpp in Sources */,\n\t\t\t\t818461A01D3503E8004B0C46 /* VolumeComponent.cpp in Sources */,\n\t\t\t\t8184CE901D0EFF9100E35BE8 /* RenderCommandProcessor.cpp in Sources */,\n\t\t\t\t818461D31D3503E8004B0C46 /* CameraComponent.cpp in Sources */,\n\t\t\t\t8158F7DA1C89D2AD00B13109 /* EmailComposer.mm in Sources */,\n\t\t\t\t818461D61D3503E8004B0C46 /* RenderCamera.cpp in Sources */,\n\t\t\t\t818461D01D3503E8004B0C46 /* SizePolicy.cpp in Sources */,\n\t\t\t\t818462551D3503E8004B0C46 /* WidgetDesc.cpp in Sources */,\n\t\t\t\t818462111D3503E8004B0C46 /* ParticleEmitterDef.cpp in Sources */,\n\t\t\t\t818462241D3503E8004B0C46 /* EndRenderCommand.cpp in Sources */,\n\t\t\t\t818461F51D3503E8004B0C46 /* SkinnedAnimationGroup.cpp in Sources */,\n\t\t\t\t818462081D3503E8004B0C46 /* StaticBillboardParticleDrawable.cpp in Sources */,\n\t\t\t\t8158F7D31C89D2AD00B13109 /* TextEntryDelegate.mm in Sources */,\n\t\t\t\t818462421D3503E8004B0C46 /* Texture.cpp in Sources */,\n\t\t\t\t818461E41D3503E8004B0C46 /* RenderMaterialGroup.cpp in Sources */,\n\t\t\t\t8158F7C51C89D2AD00B13109 /* Screen.mm in Sources */,\n\t\t\t\t8184623C1D3503E8004B0C46 /* RenderTargetGroupManager.cpp in Sources */,\n\t\t\t\t8186397C1D2C195D00FE085B /* GLPointLight.cpp in Sources */,\n\t\t\t\t818461521D3503E8004B0C46 /* Application.cpp in Sources */,\n\t\t\t\t8184617D1D3503E8004B0C46 /* JsonUtils.cpp in Sources */,\n\t\t\t\t8158F7C41C89D2AD00B13109 /* PlatformSystem.mm in Sources */,\n\t\t\t\t8184626B1D3503E8004B0C46 /* UILayout.cpp in Sources */,\n\t\t\t\t818462251D3503E8004B0C46 /* LoadMaterialGroupRenderCommand.cpp in Sources */,\n\t\t\t\t818461E01D3503E8004B0C46 /* Material.cpp in Sources */,\n\t\t\t\t818461951D3503E8004B0C46 /* StringUtils.cpp in Sources */,\n\t\t\t\t818462221D3503E8004B0C46 /* BeginRenderCommand.cpp in Sources */,\n\t\t\t\t818462681D3503E8004B0C46 /* HListUILayout.cpp in Sources */,\n\t\t\t\t818462631D3503E8004B0C46 /* UIDrawable.cpp in Sources */,\n\t\t\t\t8184622A1D3503E8004B0C46 /* RenderInstanceRenderCommand.cpp in Sources */,\n\t\t\t\t818461F91D3503E8004B0C46 /* AccelerationParticleAffectorDef.cpp in Sources */,\n\t\t\t\t81A616B41D357159007F7CC1 /* RestoreRenderTargetGroupCommand.cpp in Sources */,\n\t\t\t\t818461B51D3503E8004B0C46 /* MoContentDownloader.cpp in Sources */,\n\t\t\t\t818462561D3503E8004B0C46 /* WidgetFactory.cpp in Sources */,\n\t\t\t\t818461691D3503E8004B0C46 /* Entity.cpp in Sources */,\n\t\t\t\t8184624E1D3503E8004B0C46 /* PropertyTypes.cpp in Sources */,\n\t\t\t\t818461F11D3503E8004B0C46 /* RenderSkinnedAnimation.cpp in Sources */,\n\t\t\t\t818461CD1D3503E8004B0C46 /* RenderPassObjectSorter.cpp in Sources */,\n\t\t\t\t8184622D1D3503E8004B0C46 /* UnloadMaterialGroupRenderCommand.cpp in Sources */,\n\t\t\t\t8184626F1D3503E8004B0C46 /* ProgressBarDirection.cpp in Sources */,\n\t\t\t\t817256101E0AC08100A65625 /* CubemapProvider.cpp in Sources */,\n\t\t\t\t818462751D3503E8004B0C46 /* TextIcon.cpp in Sources */,\n\t\t\t\t8158F7D51C89D2AD00B13109 /* HttpDelegate.mm in Sources */,\n\t\t\t\t818461EB1D3503E8004B0C46 /* Model.cpp in Sources */,\n\t\t\t\t8158F7C81C89D2AD00B13109 /* FileSystem.mm in Sources */,\n\t\t\t\t8184624F1D3503E8004B0C46 /* UIComponent.cpp in Sources */,\n\t\t\t\t818461681D3503E8004B0C46 /* Component.cpp in Sources */,\n\t\t\t\t81729FA81D1BE92B005B8CC9 /* GLCamera.cpp in Sources */,\n\t\t\t\t818461FF1D3503E8004B0C46 /* ParticleAffectorDef.cpp in Sources */,\n\t\t\t\t818461C31D3503E8004B0C46 /* RenderCommandBufferManager.cpp in Sources */,\n\t\t\t\t818462431D3503E8004B0C46 /* TextureAtlas.cpp in Sources */,\n\t\t\t\t8184621A1D3503E8004B0C46 /* ApplyAmbientLightRenderCommand.cpp in Sources */,\n\t\t\t\t818462141D3503E8004B0C46 /* PointParticleEmitterDef.cpp in Sources */,\n\t\t\t\t8158F7E31C89D2AD00B13109 /* VideoPlayerTapListener.mm in Sources */,\n\t\t\t\t818461FA1D3503E8004B0C46 /* AngularAccelerationParticleAffector.cpp in Sources */,\n\t\t\t\t817256001E0A958500A65625 /* GLTextureUtils.cpp in Sources */,\n\t\t\t\t818461AE1D3503E8004B0C46 /* KeyCode.cpp in Sources */,\n\t\t\t\t8158F7C91C89D2AD00B13109 /* PNGImageProvider.cpp in Sources */,\n\t\t\t\t818462341D3503E8004B0C46 /* RenderCommandList.cpp in Sources */,\n\t\t\t\t818461A61D3503E8004B0C46 /* DragGesture.cpp in Sources */,\n\t\t\t\t8158F7D61C89D2AD00B13109 /* HttpRequest.mm in Sources */,\n\t\t\t\t818461621D3503E8004B0C46 /* BaseEncoding.cpp in Sources */,\n\t\t\t\t818462291D3503E8004B0C46 /* LoadTextureRenderCommand.cpp in Sources */,\n\t\t\t\t818462351D3503E8004B0C46 /* CSShaderProvider.cpp in Sources */,\n\t\t\t\t8158F7CF1C89D2AD00B13109 /* Accelerometer.mm in Sources */,\n\t\t\t\t8184621E1D3503E8004B0C46 /* ApplyMaterialRenderCommand.cpp in Sources */,\n\t\t\t\t818461DE1D3503E8004B0C46 /* PointRenderLight.cpp in Sources */,\n\t\t\t\t818639751D2BE97C00FE085B /* GLDirectionalLight.cpp in Sources */,\n\t\t\t\t818462511D3503E8004B0C46 /* UIComponentFactory.cpp in Sources */,\n\t\t\t\t818462501D3503E8004B0C46 /* UIComponentDesc.cpp in Sources */,\n\t\t\t\t81B096051D2AB8CA00E72835 /* GLContextRestorer.cpp in Sources */,\n\t\t\t\t818461A21D3503E8004B0C46 /* XMLUtils.cpp in Sources */,\n\t\t\t\t8184622E1D3503E8004B0C46 /* UnloadMeshRenderCommand.cpp in Sources */,\n\t\t\t\t8184617E1D3503E8004B0C46 /* LocalisedText.cpp in Sources */,\n\t\t\t\t8184620A1D3503E8004B0C46 /* CircleParticleEmitter.cpp in Sources */,\n\t\t\t\t8184624D1D3503E8004B0C46 /* PropertyLink.cpp in Sources */,\n\t\t\t\t8184625D1D3503E8004B0C46 /* NinePatchUIDrawable.cpp in Sources */,\n\t\t\t\t818461A91D3503E8004B0C46 /* HoldGesture.cpp in Sources */,\n\t\t\t\t814001A01E72D21F00388C2A /* GLExtensions.cpp in Sources */,\n\t\t\t\t818461971D3503E8004B0C46 /* UTF8StringUtils.cpp in Sources */,\n\t\t\t\t817256071E0A9F2600A65625 /* LoadCubemapRenderCommand.cpp in Sources */,\n\t\t\t\t8184619C1D3503E8004B0C46 /* TaskScheduler.cpp in Sources */,\n\t\t\t\t818462051D3503E8004B0C46 /* ParticleDrawable.cpp in Sources */,\n\t\t\t\t8184615B1D3503E8004B0C46 /* Screen.cpp in Sources */,\n\t\t\t\t818461E21D3503E8004B0C46 /* MaterialProvider.cpp in Sources */,\n\t\t\t\t8184624C1D3503E8004B0C46 /* Canvas.cpp in Sources */,\n\t\t\t\t818462121D3503E8004B0C46 /* ParticleEmitterDefFactory.cpp in Sources */,\n\t\t\t\t818462261D3503E8004B0C46 /* LoadMeshRenderCommand.cpp in Sources */,\n\t\t\t\t818461BA1D3503E8004B0C46 /* AspectRatioUtils.cpp in Sources */,\n\t\t\t\t818461B21D3503E8004B0C46 /* TextEntryCapitalisation.cpp in Sources */,\n\t\t\t\t818461B61D3503E8004B0C46 /* HttpRequestSystem.cpp in Sources */,\n\t\t\t\t8184626D1D3503E8004B0C46 /* VListUILayout.cpp in Sources */,\n\t\t\t\t818461801D3503E8004B0C46 /* ShapeIntersection.cpp in Sources */,\n\t\t\t\t8184626A1D3503E8004B0C46 /* LayoutUIComponent.cpp in Sources */,\n\t\t\t\t8184616F1D3503E8004B0C46 /* CSBinaryInputStream.cpp in Sources */,\n\t\t\t\t818461DD1D3503E8004B0C46 /* PointLightComponent.cpp in Sources */,\n\t\t\t\t27408C1C1D369F8D00A0B003 /* SystemInfoFactory.mm in Sources */,\n\t\t\t\t818461591D3503E8004B0C46 /* Logging.cpp in Sources */,\n\t\t\t\t818461631D3503E8004B0C46 /* HashCRC32.cpp in Sources */,\n\t\t\t\t818461531D3503E8004B0C46 /* ByteBuffer.cpp in Sources */,\n\t\t\t\t2787EA6E1E30D59200E83458 /* Gyroscope.mm in Sources */,\n\t\t\t\t8158F7E11C89D2AD00B13109 /* VideoOverlayView.mm in Sources */,\n\t\t\t\t818462301D3503E8004B0C46 /* UnloadTargetGroupRenderCommand.cpp in Sources */,\n\t\t\t\t8158F7D81C89D2AD00B13109 /* IAPSystem.mm in Sources */,\n\t\t\t\t8158F7F81C89D2AD00B13109 /* GLError.cpp in Sources */,\n\t\t\t\t818462541D3503E8004B0C46 /* WidgetDefProvider.cpp in Sources */,\n\t\t\t\t8184616C1D3503E8004B0C46 /* EventConnection.cpp in Sources */,\n\t\t\t\t818461601D3503E8004B0C46 /* PropertyTypes.cpp in Sources */,\n\t\t\t\t818461E71D3503E8004B0C46 /* CSAnimProvider.cpp in Sources */,\n\t\t\t\t8184616E1D3503E8004B0C46 /* CSBinaryChunk.cpp in Sources */,\n\t\t\t\t27B4258C1E6058A300E17750 /* HashSHA256.cpp in Sources */,\n\t\t\t\t8158F7D41C89D2AD00B13109 /* Main.cpp in Sources */,\n\t\t\t\t818461B81D3503E8004B0C46 /* IAPSystem.cpp in Sources */,\n\t\t\t\t818461FB1D3503E8004B0C46 /* AngularAccelerationParticleAffectorDef.cpp in Sources */,\n\t\t\t\t818461EA1D3503E8004B0C46 /* MeshDesc.cpp in Sources */,\n\t\t\t\t818462701D3503E8004B0C46 /* ProgressBarType.cpp in Sources */,\n\t\t\t\t818461641D3503E8004B0C46 /* HashMD5.cpp in Sources */,\n\t\t\t\t8184615D1D3503E8004B0C46 /* ParamDictionary.cpp in Sources */,\n\t\t\t\t818461F31D3503E8004B0C46 /* SkeletonDesc.cpp in Sources */,\n\t\t\t\t818462451D3503E8004B0C46 /* TextureDesc.cpp in Sources */,\n\t\t\t\t8184621F1D3503E8004B0C46 /* ApplyMeshRenderCommand.cpp in Sources */,\n\t\t\t\t818461861D3503E8004B0C46 /* LinearAllocator.cpp in Sources */,\n\t\t\t\t818461921D3503E8004B0C46 /* MarkupDef.cpp in Sources */,\n\t\t\t\t8184616A1D3503E8004B0C46 /* PrimitiveEntityFactory.cpp in Sources */,\n\t\t\t\t818461501D3503E8004B0C46 /* CricketAudioSystem.cpp in Sources */,\n\t\t\t\t818462101D3503E8004B0C46 /* ParticleEmitter.cpp in Sources */,\n\t\t\t\t818461CC1D3503E8004B0C46 /* RenderPassObject.cpp in Sources */,\n\t\t\t\t818461D71D3503E8004B0C46 /* Font.cpp in Sources */,\n\t\t\t\t8156124B1D2E5D41000DD01B /* GLTargetGroup.cpp in Sources */,\n\t\t\t\t8184618D1D3503E8004B0C46 /* ResourcePool.cpp in Sources */,\n\t\t\t\t818461E51D3503E8004B0C46 /* RenderMaterialGroupManager.cpp in Sources */,\n\t\t\t\t8158F7C71C89D2AD00B13109 /* DialogueBoxSystem.mm in Sources */,\n\t\t\t\t818462311D3503E8004B0C46 /* UnloadTextureRenderCommand.cpp in Sources */,\n\t\t\t\t81EB41181D48B3E9005A7CE9 /* CanvasDrawMode.cpp in Sources */,\n\t\t\t\t8158F7CA1C89D2AD00B13109 /* RNGContainer.mm in Sources */,\n\t\t\t\t818461731D3503E8004B0C46 /* TextInputStream.cpp in Sources */,\n\t\t\t\t818461F41D3503E8004B0C46 /* SkinnedAnimation.cpp in Sources */,\n\t\t\t\t8184626C1D3503E8004B0C46 /* UILayoutDef.cpp in Sources */,\n\t\t\t\t8184617C1D3503E8004B0C46 /* PVRImageProvider.cpp in Sources */,\n\t\t\t\t818462761D3503E8004B0C46 /* TextUIComponent.cpp in Sources */,\n\t\t\t\t817256131E0AEF1F00A65625 /* CubemapResourceOptions.cpp in Sources */,\n\t\t\t\t8184627A1D3503E8004B0C46 /* WebView.cpp in Sources */,\n\t\t\t\t818462571D3503E8004B0C46 /* WidgetParserUtils.cpp in Sources */,\n\t\t\t\t818462731D3503E8004B0C46 /* SliderUIComponent.cpp in Sources */,\n\t\t\t\t818461AC1D3503E8004B0C46 /* TapGesture.cpp in Sources */,\n\t\t\t\t818462131D3503E8004B0C46 /* PointParticleEmitter.cpp in Sources */,\n\t\t\t\t818461AB1D3503E8004B0C46 /* RotationGesture.cpp in Sources */,\n\t\t\t\t8184616D1D3503E8004B0C46 /* AppDataStore.cpp in Sources */,\n\t\t\t\t81729FAB1D1BFF05005B8CC9 /* GLTextureUnitManager.cpp in Sources */,\n\t\t\t\t818462021D3503E8004B0C46 /* ScaleOverLifetimeParticleAffectorDef.cpp in Sources */,\n\t\t\t\t8184618E1D3503E8004B0C46 /* ResourceProvider.cpp in Sources */,\n\t\t\t\t818462231D3503E8004B0C46 /* BeginWithTargetGroupRenderCommand.cpp in Sources */,\n\t\t\t\t8184625A1D3503E8004B0C46 /* HighlightUIComponent.cpp in Sources */,\n\t\t\t\t818461661D3503E8004B0C46 /* OAuth.cpp in Sources */,\n\t\t\t\t8184618A1D3503E8004B0C46 /* NotificationManager.cpp in Sources */,\n\t\t\t\t818C150E1D22FB70001D639B /* GLMeshUtils.cpp in Sources */,\n\t\t\t\t818462771D3503E8004B0C46 /* CSSubtitlesProvider.cpp in Sources */,\n\t\t\t\t8184622F1D3503E8004B0C46 /* UnloadShaderRenderCommand.cpp in Sources */,\n\t\t\t\t818461981D3503E8004B0C46 /* StateSystem.cpp in Sources */,\n\t\t\t\t8184621D1D3503E8004B0C46 /* ApplyDynamicMeshRenderCommand.cpp in Sources */,\n\t\t\t\t818461B11D3503E8004B0C46 /* TextEntry.cpp in Sources */,\n\t\t\t\t818462711D3503E8004B0C46 /* ProgressBarUIComponent.cpp in Sources */,\n\t\t\t\t8184622C1D3503E8004B0C46 /* RestoreTextureRenderCommand.cpp in Sources */,\n\t\t\t\t818461941D3503E8004B0C46 /* StringParser.cpp in Sources */,\n\t\t\t\t8158F7CE1C89D2AD00B13109 /* NSStringUtils.mm in Sources */,\n\t\t\t\t818461C21D3503E8004B0C46 /* RenderCapabilities.cpp in Sources */,\n\t\t\t\t818461F61D3503E8004B0C46 /* StaticModelComponent.cpp in Sources */,\n\t\t\t\t818461DC1D3503E8004B0C46 /* DirectionalRenderLight.cpp in Sources */,\n\t\t\t\t818461991D3503E8004B0C46 /* SingleThreadTaskPool.cpp in Sources */,\n\t\t\t\t818461C81D3503E8004B0C46 /* RenderFrameCompiler.cpp in Sources */,\n\t\t\t\t818461F71D3503E8004B0C46 /* VertexFormat.cpp in Sources */,\n\t\t\t\t818461BC1D3503E8004B0C46 /* CanvasMaterialPool.cpp in Sources */,\n\t\t\t\t81559AAF1E925F4C00A1B107 /* Gamepad.cpp in Sources */,\n\t\t\t\t818461F01D3503E8004B0C46 /* RenderMeshManager.cpp in Sources */,\n\t\t\t\t818461791D3503E8004B0C46 /* Image.cpp in Sources */,\n\t\t\t\t818461D41D3503E8004B0C46 /* OrthographicCameraComponent.cpp in Sources */,\n\t\t\t\t818461C11D3503E8004B0C46 /* IRenderCommandProcessor.cpp in Sources */,\n\t\t\t\t8158F7CC1C89D2AD00B13109 /* NSNotificationAdapter.mm in Sources */,\n\t\t\t\t818461F81D3503E8004B0C46 /* AccelerationParticleAffector.cpp in Sources */,\n\t\t\t\t8184621C1D3503E8004B0C46 /* ApplyDirectionalLightRenderCommand.cpp in Sources */,\n\t\t\t\t8158F7C21C89D2AD00B13109 /* CSGLViewController.mm in Sources */,\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n/* End PBXSourcesBuildPhase section */\n\n/* Begin XCBuildConfiguration section */\n\t\t8158F1F11C89D27300B13109 /* Debug */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tALWAYS_SEARCH_USER_PATHS = NO;\n\t\t\t\tCLANG_CXX_LANGUAGE_STANDARD = \"gnu++0x\";\n\t\t\t\tCLANG_CXX_LIBRARY = \"libc++\";\n\t\t\t\tCLANG_ENABLE_MODULES = YES;\n\t\t\t\tCLANG_ENABLE_OBJC_ARC = NO;\n\t\t\t\tCLANG_WARN_BOOL_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_CONSTANT_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;\n\t\t\t\tCLANG_WARN_EMPTY_BODY = YES;\n\t\t\t\tCLANG_WARN_ENUM_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_INFINITE_RECURSION = YES;\n\t\t\t\tCLANG_WARN_INT_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;\n\t\t\t\tCLANG_WARN_SUSPICIOUS_MOVE = YES;\n\t\t\t\tCLANG_WARN_UNREACHABLE_CODE = YES;\n\t\t\t\tCLANG_WARN__DUPLICATE_METHOD_MATCH = YES;\n\t\t\t\t\"CODE_SIGN_IDENTITY[sdk=iphoneos*]\" = \"iPhone Developer\";\n\t\t\t\tCOPY_PHASE_STRIP = NO;\n\t\t\t\tDEBUG_INFORMATION_FORMAT = dwarf;\n\t\t\t\tENABLE_STRICT_OBJC_MSGSEND = YES;\n\t\t\t\tENABLE_TESTABILITY = YES;\n\t\t\t\tFRAMEWORK_SEARCH_PATHS = \"$(PROJECT_DIR)/../../Libraries/Core/iOS/Libs\";\n\t\t\t\tGCC_C_LANGUAGE_STANDARD = gnu99;\n\t\t\t\tGCC_DYNAMIC_NO_PIC = NO;\n\t\t\t\tGCC_INPUT_FILETYPE = sourcecode.cpp.objcpp;\n\t\t\t\tGCC_NO_COMMON_BLOCKS = YES;\n\t\t\t\tGCC_OPTIMIZATION_LEVEL = 0;\n\t\t\t\tGCC_PREPROCESSOR_DEFINITIONS = (\n\t\t\t\t\t\"DEBUG=1\",\n\t\t\t\t\tCS_TARGETPLATFORM_IOS,\n\t\t\t\t\tCS_ENABLE_DEBUG,\n\t\t\t\t\tCS_LOGLEVEL_VERBOSE,\n\t\t\t\t\t\"$(inherited)\",\n\t\t\t\t);\n\t\t\t\tGCC_WARN_64_TO_32_BIT_CONVERSION = YES;\n\t\t\t\tGCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;\n\t\t\t\tGCC_WARN_UNDECLARED_SELECTOR = YES;\n\t\t\t\tGCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;\n\t\t\t\tGCC_WARN_UNUSED_FUNCTION = YES;\n\t\t\t\tGCC_WARN_UNUSED_VARIABLE = YES;\n\t\t\t\tHEADER_SEARCH_PATHS = (\n\t\t\t\t\t\"$(SRCROOT)/../../Libraries/Core/iOS/Headers\",\n\t\t\t\t\t\"$(SRCROOT)/../../Libraries/CricketAudio/iOS/Headers\",\n\t\t\t\t\t\"$(SRCROOT)/../../Source\",\n\t\t\t\t);\n\t\t\t\tIPHONEOS_DEPLOYMENT_TARGET = 8.0;\n\t\t\t\tLIBRARY_SEARCH_PATHS = (\n\t\t\t\t\t\"$(PROJECT_DIR)/../../Libraries/Core/iOS/Libs\",\n\t\t\t\t\t\"$(PROJECT_DIR)/../../Libraries/CricketAudio/iOS/Libs\",\n\t\t\t\t);\n\t\t\t\tMTL_ENABLE_DEBUG_INFO = YES;\n\t\t\t\tONLY_ACTIVE_ARCH = YES;\n\t\t\t\tSDKROOT = iphoneos;\n\t\t\t};\n\t\t\tname = Debug;\n\t\t};\n\t\t8158F1F21C89D27300B13109 /* Release */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tALWAYS_SEARCH_USER_PATHS = NO;\n\t\t\t\tCLANG_CXX_LANGUAGE_STANDARD = \"gnu++0x\";\n\t\t\t\tCLANG_CXX_LIBRARY = \"libc++\";\n\t\t\t\tCLANG_ENABLE_MODULES = YES;\n\t\t\t\tCLANG_ENABLE_OBJC_ARC = NO;\n\t\t\t\tCLANG_WARN_BOOL_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_CONSTANT_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;\n\t\t\t\tCLANG_WARN_EMPTY_BODY = YES;\n\t\t\t\tCLANG_WARN_ENUM_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_INFINITE_RECURSION = YES;\n\t\t\t\tCLANG_WARN_INT_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;\n\t\t\t\tCLANG_WARN_SUSPICIOUS_MOVE = YES;\n\t\t\t\tCLANG_WARN_UNREACHABLE_CODE = YES;\n\t\t\t\tCLANG_WARN__DUPLICATE_METHOD_MATCH = YES;\n\t\t\t\t\"CODE_SIGN_IDENTITY[sdk=iphoneos*]\" = \"iPhone Developer\";\n\t\t\t\tCOPY_PHASE_STRIP = NO;\n\t\t\t\tDEBUG_INFORMATION_FORMAT = \"dwarf-with-dsym\";\n\t\t\t\tENABLE_NS_ASSERTIONS = NO;\n\t\t\t\tENABLE_STRICT_OBJC_MSGSEND = YES;\n\t\t\t\tFRAMEWORK_SEARCH_PATHS = \"$(PROJECT_DIR)/../../Libraries/Core/iOS/Libs\";\n\t\t\t\tGCC_C_LANGUAGE_STANDARD = gnu99;\n\t\t\t\tGCC_INPUT_FILETYPE = sourcecode.cpp.objcpp;\n\t\t\t\tGCC_NO_COMMON_BLOCKS = YES;\n\t\t\t\tGCC_PREPROCESSOR_DEFINITIONS = (\n\t\t\t\t\tNDEBUG,\n\t\t\t\t\tCS_TARGETPLATFORM_IOS,\n\t\t\t\t\tCS_LOGLEVEL_WARNING,\n\t\t\t\t);\n\t\t\t\tGCC_WARN_64_TO_32_BIT_CONVERSION = YES;\n\t\t\t\tGCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;\n\t\t\t\tGCC_WARN_UNDECLARED_SELECTOR = YES;\n\t\t\t\tGCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;\n\t\t\t\tGCC_WARN_UNUSED_FUNCTION = YES;\n\t\t\t\tGCC_WARN_UNUSED_VARIABLE = YES;\n\t\t\t\tHEADER_SEARCH_PATHS = (\n\t\t\t\t\t\"$(SRCROOT)/../../Libraries/Core/iOS/Headers\",\n\t\t\t\t\t\"$(SRCROOT)/../../Libraries/CricketAudio/iOS/Headers\",\n\t\t\t\t\t\"$(SRCROOT)/../../Source\",\n\t\t\t\t);\n\t\t\t\tIPHONEOS_DEPLOYMENT_TARGET = 8.0;\n\t\t\t\tLIBRARY_SEARCH_PATHS = (\n\t\t\t\t\t\"$(PROJECT_DIR)/../../Libraries/Core/iOS/Libs\",\n\t\t\t\t\t\"$(PROJECT_DIR)/../../Libraries/CricketAudio/iOS/Libs\",\n\t\t\t\t);\n\t\t\t\tMTL_ENABLE_DEBUG_INFO = NO;\n\t\t\t\tSDKROOT = iphoneos;\n\t\t\t\tVALIDATE_PRODUCT = YES;\n\t\t\t};\n\t\t\tname = Release;\n\t\t};\n\t\t8158F1F41C89D27300B13109 /* Debug */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tIPHONEOS_DEPLOYMENT_TARGET = 8.0;\n\t\t\t\tOTHER_LDFLAGS = \"-ObjC\";\n\t\t\t\tPRODUCT_NAME = \"$(TARGET_NAME)\";\n\t\t\t\tSKIP_INSTALL = YES;\n\t\t\t};\n\t\t\tname = Debug;\n\t\t};\n\t\t8158F1F51C89D27300B13109 /* Release */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tIPHONEOS_DEPLOYMENT_TARGET = 8.0;\n\t\t\t\tOTHER_LDFLAGS = \"-ObjC\";\n\t\t\t\tPRODUCT_NAME = \"$(TARGET_NAME)\";\n\t\t\t\tSKIP_INSTALL = YES;\n\t\t\t};\n\t\t\tname = Release;\n\t\t};\n/* End XCBuildConfiguration section */\n\n/* Begin XCConfigurationList section */\n\t\t8158F1E51C89D27300B13109 /* Build configuration list for PBXProject \"ChilliSource\" */ = {\n\t\t\tisa = XCConfigurationList;\n\t\t\tbuildConfigurations = (\n\t\t\t\t8158F1F11C89D27300B13109 /* Debug */,\n\t\t\t\t8158F1F21C89D27300B13109 /* Release */,\n\t\t\t);\n\t\t\tdefaultConfigurationIsVisible = 0;\n\t\t\tdefaultConfigurationName = Release;\n\t\t};\n\t\t8158F1F31C89D27300B13109 /* Build configuration list for PBXNativeTarget \"ChilliSource\" */ = {\n\t\t\tisa = XCConfigurationList;\n\t\t\tbuildConfigurations = (\n\t\t\t\t8158F1F41C89D27300B13109 /* Debug */,\n\t\t\t\t8158F1F51C89D27300B13109 /* Release */,\n\t\t\t);\n\t\t\tdefaultConfigurationIsVisible = 0;\n\t\t\tdefaultConfigurationName = Release;\n\t\t};\n/* End XCConfigurationList section */\n\t};\n\trootObject = 8158F1E21C89D27300B13109 /* Project object */;\n}\n"
  },
  {
    "path": "Projects/iOS/ChilliSource.xcodeproj/project.xcworkspace/contents.xcworkspacedata",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Workspace\n   version = \"1.0\">\n   <FileRef\n      location = \"self:\">\n   </FileRef>\n</Workspace>\n"
  },
  {
    "path": "Projects/iOS/ChilliSource.xcodeproj/xcshareddata/xcschemes/ChilliSource.xcscheme",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Scheme\n   LastUpgradeVersion = \"0820\"\n   version = \"1.3\">\n   <BuildAction\n      parallelizeBuildables = \"YES\"\n      buildImplicitDependencies = \"YES\">\n      <BuildActionEntries>\n         <BuildActionEntry\n            buildForTesting = \"YES\"\n            buildForRunning = \"YES\"\n            buildForProfiling = \"YES\"\n            buildForArchiving = \"YES\"\n            buildForAnalyzing = \"YES\">\n            <BuildableReference\n               BuildableIdentifier = \"primary\"\n               BlueprintIdentifier = \"8158F1E91C89D27300B13109\"\n               BuildableName = \"libChilliSource.a\"\n               BlueprintName = \"ChilliSource\"\n               ReferencedContainer = \"container:ChilliSource.xcodeproj\">\n            </BuildableReference>\n         </BuildActionEntry>\n      </BuildActionEntries>\n   </BuildAction>\n   <TestAction\n      buildConfiguration = \"Debug\"\n      selectedDebuggerIdentifier = \"Xcode.DebuggerFoundation.Debugger.LLDB\"\n      selectedLauncherIdentifier = \"Xcode.DebuggerFoundation.Launcher.LLDB\"\n      shouldUseLaunchSchemeArgsEnv = \"YES\">\n      <Testables>\n      </Testables>\n      <AdditionalOptions>\n      </AdditionalOptions>\n   </TestAction>\n   <LaunchAction\n      buildConfiguration = \"Debug\"\n      selectedDebuggerIdentifier = \"Xcode.DebuggerFoundation.Debugger.LLDB\"\n      selectedLauncherIdentifier = \"Xcode.DebuggerFoundation.Launcher.LLDB\"\n      launchStyle = \"0\"\n      useCustomWorkingDirectory = \"NO\"\n      ignoresPersistentStateOnLaunch = \"NO\"\n      debugDocumentVersioning = \"YES\"\n      debugServiceExtension = \"internal\"\n      allowLocationSimulation = \"YES\">\n      <MacroExpansion>\n         <BuildableReference\n            BuildableIdentifier = \"primary\"\n            BlueprintIdentifier = \"8158F1E91C89D27300B13109\"\n            BuildableName = \"libChilliSource.a\"\n            BlueprintName = \"ChilliSource\"\n            ReferencedContainer = \"container:ChilliSource.xcodeproj\">\n         </BuildableReference>\n      </MacroExpansion>\n      <AdditionalOptions>\n      </AdditionalOptions>\n   </LaunchAction>\n   <ProfileAction\n      buildConfiguration = \"Release\"\n      shouldUseLaunchSchemeArgsEnv = \"YES\"\n      savedToolIdentifier = \"\"\n      useCustomWorkingDirectory = \"NO\"\n      debugDocumentVersioning = \"YES\">\n      <MacroExpansion>\n         <BuildableReference\n            BuildableIdentifier = \"primary\"\n            BlueprintIdentifier = \"8158F1E91C89D27300B13109\"\n            BuildableName = \"libChilliSource.a\"\n            BlueprintName = \"ChilliSource\"\n            ReferencedContainer = \"container:ChilliSource.xcodeproj\">\n         </BuildableReference>\n      </MacroExpansion>\n   </ProfileAction>\n   <AnalyzeAction\n      buildConfiguration = \"Debug\">\n   </AnalyzeAction>\n   <ArchiveAction\n      buildConfiguration = \"Release\"\n      revealArchiveInOrganizer = \"YES\">\n   </ArchiveAction>\n</Scheme>\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Amazon/JNI/ForwardDeclarations.h",
    "content": "//\n//  ForwardDeclarations.h\n//  ChilliSource\n//  Created by Ian Copland on 09/08/2012.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2012 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n\n#ifdef CS_ANDROIDFLAVOUR_AMAZON\n\n#ifndef _CSBACKEND_PLATFORM_ANDROID_AMAZON_JNI_FORWARDDECLARATIONS_H_\n#define _CSBACKEND_PLATFORM_ANDROID_AMAZON_JNI_FORWARDDECLARATIONS_H_\n\n#include <ChilliSource/Core/Base/StandardMacros.h>\n\n#include <memory>\n\nnamespace CSBackend\n{\n\tnamespace Android\n\t{\n\t\t//------------------------------------------------------\n\t\t/// Networking\n\t\t//------------------------------------------------------\n\t\tCS_FORWARDDECLARE_CLASS(AmazonIAPJavaInterface);\n\t\tCS_FORWARDDECLARE_CLASS(AmazonIAPSystem);\n\t}\n}\n\n#endif\n\n#endif\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Amazon/JNI/Networking/IAP/AmazonIAPJavaInterface.cpp",
    "content": "//\n//  AmazonIAPJavaInterface.cpp\n//  ChilliSource\n//  Created by Ian Copland on 10/12/2013.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2013 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n\n#ifdef CS_ANDROIDFLAVOUR_AMAZON\n\n#include <CSBackend/Platform/Android/Amazon/JNI/Networking/IAP/AmazonIAPJavaInterface.h>\n\n#include <CSBackend/Platform/Android/Main/JNI/Core/Java/JavaInterfaceManager.h>\n#include <CSBackend/Platform/Android/Main/JNI/Core/Java/JavaUtils.h>\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/Base/Utils.h>\n#include <ChilliSource/Core/Threading/TaskScheduler.h>\n\n#include <json/json.h>\n\n#include <jni.h>\n\nextern \"C\"\n{\n\t//--------------------------------------------------------------------------------------\n\t/// Called by Java when product descriptions request completes\n\t///\n\t/// @author Ian Copland\n\t///\n\t/// @param JNI Environment\n\t/// @param Pointer to the calling object\n\t/// @param Array of product IDs\n\t/// @param Array of product Names\n\t/// @param Array of product Descriptions\n\t/// @param Array of product Prices\n\t//--------------------------------------------------------------------------------------\n\tvoid Java_com_chilliworks_chillisource_networking_AmazonIAPNativeInterface_NativeOnProductsDescriptionsRequestComplete(JNIEnv* in_env, jobject in_this, jobjectArray in_productIds, jobjectArray in_names, jobjectArray in_descs, jobjectArray in_prices);\n\t//--------------------------------------------------------------------------------------\n\t/// Called by Java when a transaction status changes\n\t///\n\t/// @author Ian Copland\n\t///\n\t/// @param JNI Environment\n\t/// @param Pointer to the calling object\n\t/// @param Result\n\t/// @param Product ID\n\t/// @param Transaction ID\n\t/// @param Receipt\n\t//--------------------------------------------------------------------------------------\n\tvoid Java_com_chilliworks_chillisource_networking_AmazonIAPNativeInterface_NativeOnTransactionStatusUpdated(JNIEnv* in_env, jobject in_this, jint inudwResult, jstring in_productId, jstring in_transactionId, jstring in_receipt);\n\t//--------------------------------------------------------------------------------------\n\t/// Called by Java when a transaction complete request completes\n\t///\n\t/// @author Ian Copland\n\t///\n\t/// @param JNI Environment\n\t/// @param Pointer to the calling function\n\t//--------------------------------------------------------------------------------------\n\tvoid Java_com_chilliworks_chillisource_networking_AmazonIAPNativeInterface_NativeOnTransactionClosed(JNIEnv* in_env, jobject in_this, jstring in_productId, jstring in_transactionId);\n}\n\n//--------------------------------------------------------------------------------------\n//--------------------------------------------------------------------------------------\nvoid Java_com_chilliworks_chillisource_networking_AmazonIAPNativeInterface_NativeOnProductsDescriptionsRequestComplete(JNIEnv* in_env, jobject in_this, jobjectArray in_productIds, jobjectArray in_names, jobjectArray in_descs, jobjectArray in_prices)\n{\n\tCSBackend::Android::AmazonIAPJavaInterfaceSPtr javaInterface = CSBackend::Android::JavaInterfaceManager::GetSingletonPtr()->GetJavaInterface<CSBackend::Android::AmazonIAPJavaInterface>();\n\tif (javaInterface != nullptr)\n\t{\n\t\tu32 numProducts = in_env->GetArrayLength(in_productIds);\n\t\tstd::vector<ChilliSource::IAPSystem::ProductDesc> products;\n\t\tproducts.reserve(numProducts);\n\n\t\tfor(u32 i=0; i<numProducts; ++i)\n\t\t{\n\t\t\tChilliSource::IAPSystem::ProductDesc desc;\n\t\t\tjstring id = (jstring)in_env->GetObjectArrayElement(in_productIds, i);\n\t\t\tdesc.m_id = CSBackend::Android::JavaUtils::CreateSTDStringFromJString(id);\n\n\t\t\tjstring name = (jstring)in_env->GetObjectArrayElement(in_names, i);\n\t\t\tdesc.m_name = CSBackend::Android::JavaUtils::CreateSTDStringFromJString(name);\n\n\t\t\tjstring description = (jstring)in_env->GetObjectArrayElement(in_descs, i);\n\t\t\tdesc.m_description = CSBackend::Android::JavaUtils::CreateSTDStringFromJString(description);\n\n\t\t\tjstring price = (jstring)in_env->GetObjectArrayElement(in_prices, i);\n\t\t\tdesc.m_formattedPrice = CSBackend::Android::JavaUtils::CreateSTDStringFromJString(price);\n\n\t\t\tproducts.push_back(desc);\n\t\t}\n\n\t\tChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_mainThread, [=](const ChilliSource::TaskContext&)\n\t\t{\n\t\t\tjavaInterface->OnProductDescriptionsRequestComplete(products);\n\t\t});\n\t}\n}\n//--------------------------------------------------------------------------------------\n//--------------------------------------------------------------------------------------\nvoid Java_com_chilliworks_chillisource_networking_AmazonIAPNativeInterface_NativeOnTransactionStatusUpdated(JNIEnv* in_env, jobject in_this, jint in_result, jstring in_productId, jstring in_transactionId, jstring in_receipt)\n{\n\tCSBackend::Android::AmazonIAPJavaInterfaceSPtr javaInterface = CSBackend::Android::JavaInterfaceManager::GetSingletonPtr()->GetJavaInterface<CSBackend::Android::AmazonIAPJavaInterface>();\n\tif (javaInterface != nullptr)\n\t{\n\t\tChilliSource::IAPSystem::Transaction transaction;\n\t\ttransaction.m_productId = CSBackend::Android::JavaUtils::CreateSTDStringFromJString(in_productId);\n\t\ttransaction.m_transactionId = CSBackend::Android::JavaUtils::CreateSTDStringFromJString(in_transactionId);\n\t\ttransaction.m_receipt = CSBackend::Android::JavaUtils::CreateSTDStringFromJString(in_receipt);\n\n\t\tChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_mainThread, [=](const ChilliSource::TaskContext&)\n\t\t{\n\t\t\tjavaInterface->OnTransactionStatusUpdated(in_result, transaction);\n\t\t});\n\t}\n}\n//--------------------------------------------------------------------------------------\n//--------------------------------------------------------------------------------------\nvoid Java_com_chilliworks_chillisource_networking_AmazonIAPNativeInterface_NativeOnTransactionClosed(JNIEnv* in_env, jobject in_this, jstring in_productId, jstring in_transactionId)\n{\n\tCSBackend::Android::AmazonIAPJavaInterfaceSPtr javaInterface = CSBackend::Android::JavaInterfaceManager::GetSingletonPtr()->GetJavaInterface<CSBackend::Android::AmazonIAPJavaInterface>();\n\tif (javaInterface != nullptr)\n\t{\n\t\tstd::string productId = CSBackend::Android::JavaUtils::CreateSTDStringFromJString(in_productId);\n\t\tstd::string transactionId = CSBackend::Android::JavaUtils::CreateSTDStringFromJString(in_transactionId);\n\n\t\tChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_mainThread, [=](const ChilliSource::TaskContext&)\n\t\t{\n\t\t\tjavaInterface->OnTransactionClosed(productId, transactionId);\n\t\t});\n\t}\n}\n\nnamespace CSBackend\n{\n\tnamespace Android\n\t{\n\t\tCS_DEFINE_NAMEDTYPE(AmazonIAPJavaInterface);\n\t\t//--------------------------------------------------------------\n\t\t//--------------------------------------------------------------\n\t\tAmazonIAPJavaInterface::AmazonIAPJavaInterface(const std::string& in_privateKey, const std::string& in_udid)\n\t\t{\n\t\t\tCreateNativeInterface(\"com/chilliworks/chillisource/networking/AmazonIAPNativeInterface\");\n\t\t\tCreateMethodReference(\"Init\", \"(Ljava/lang/String;Ljava/lang/String;)V\");\n\t\t\tCreateMethodReference(\"IsPurchasingEnabled\", \"()Z\");\n\t\t\tCreateMethodReference(\"RequestProductDescriptions\", \"([Ljava/lang/String;)V\");\n\t\t\tCreateMethodReference(\"CancelProductDescriptionsRequest\", \"()V\");\n\t\t\tCreateMethodReference(\"RequestProductPurchase\", \"(Ljava/lang/String;)V\");\n\t\t\tCreateMethodReference(\"CloseTransaction\", \"(Ljava/lang/String;Ljava/lang/String;)V\");\n\t\t\tCreateMethodReference(\"RestoreManagedPurchases\", \"()V\");\n\t\t\tCreateMethodReference(\"StartListeningForTransactionUpdates\", \"()V\");\n\t\t\tCreateMethodReference(\"StopListeningForTransactionUpdates\", \"()V\");\n\n\t\t\t//initialise the system\n\t\t\tJNIEnv* env = JavaInterfaceManager::GetSingletonPtr()->GetJNIEnvironmentPtr();\n\t\t\tjstring privateKey = JavaUtils::CreateJStringFromSTDString(in_privateKey);\n\t\t\tjstring udid = JavaUtils::CreateJStringFromSTDString(in_udid);\n\t\t\tenv->CallVoidMethod(GetJavaObject(), GetMethodID(\"Init\"), privateKey, udid);\n\t\t\tenv->DeleteLocalRef(privateKey);\n\t\t\tenv->DeleteLocalRef(udid);\n\t\t}\n\t\t//--------------------------------------------------------------\n\t\t//--------------------------------------------------------------\n\t\tbool AmazonIAPJavaInterface::IsA(ChilliSource::InterfaceIDType in_interfaceId) const\n\t\t{\n\t\t\treturn in_interfaceId == AmazonIAPJavaInterface::InterfaceID;\n\t\t}\n        //---------------------------------------------------------------\n        //---------------------------------------------------------------\n        bool AmazonIAPJavaInterface::IsPurchasingEnabled()\n        {\n\t\t\tJNIEnv* env = JavaInterfaceManager::GetSingletonPtr()->GetJNIEnvironmentPtr();\n\t\t\treturn env->CallBooleanMethod(GetJavaObject(), GetMethodID(\"IsPurchasingEnabled\"));\n        }\n        //---------------------------------------------------------------\n        //---------------------------------------------------------------\n        void AmazonIAPJavaInterface::StartListeningForTransactionUpdates(const ChilliSource::IAPSystem::TransactionStatusDelegate& in_delegate)\n        {\n        \tCS_ASSERT(in_delegate != nullptr, \"Cannot have null transaction delegate\");\n\n        \tm_transactionStatusDelegate = in_delegate;\n\n        \tJNIEnv* env = JavaInterfaceManager::GetSingletonPtr()->GetJNIEnvironmentPtr();\n        \tenv->CallVoidMethod(GetJavaObject(), GetMethodID(\"StartListeningForTransactionUpdates\"));\n        }\n        //---------------------------------------------------------------\n        //---------------------------------------------------------------\n        void AmazonIAPJavaInterface::StopListeningForTransactionUpdates()\n        {\n        \tm_transactionStatusDelegate = nullptr;\n\n        \tJNIEnv* env = JavaInterfaceManager::GetSingletonPtr()->GetJNIEnvironmentPtr();\n        \tenv->CallVoidMethod(GetJavaObject(), GetMethodID(\"StopListeningForTransactionUpdates\"));\n        }\n        //---------------------------------------------------------------\n        //---------------------------------------------------------------\n        void AmazonIAPJavaInterface::RequestProductDescriptions(const std::vector<std::string>& in_productIds, const ChilliSource::IAPSystem::ProductDescDelegate& in_delegate)\n        {\n            CS_ASSERT(in_productIds.empty() == false, \"Cannot request no product descriptions\");\n            CS_ASSERT(in_delegate != nullptr, \"Cannot have null product description delegate\");\n            CS_ASSERT(m_productsRequestDelegate == nullptr, \"Only 1 product description request can be active at a time\");\n\n        \tm_productsRequestDelegate = in_delegate;\n\n        \tJNIEnv* env = JavaInterfaceManager::GetSingletonPtr()->GetJNIEnvironmentPtr();\n\n\t\t\tjstring jstrEmptyString = env->NewStringUTF(\"\");\n\t\t\tjclass jStringClass = env->FindClass(\"java/lang/String\");\n\n        \tjobjectArray productIDs = env->NewObjectArray(in_productIds.size(), jStringClass, jstrEmptyString);\n        \tu32 productIDIndex = 0;\n        \tfor(std::vector<std::string>::const_iterator it = in_productIds.begin(); it != in_productIds.end(); ++it)\n        \t{\n        \t\tjstring productID = JavaUtils::CreateJStringFromSTDString(*it);\n        \t\tenv->SetObjectArrayElement(productIDs, productIDIndex, productID);\n        \t\tenv->DeleteLocalRef(productID);\n        \t\tproductIDIndex++;\n        \t}\n\n        \tenv->CallVoidMethod(GetJavaObject(), GetMethodID(\"RequestProductDescriptions\"), productIDs);\n        \tenv->DeleteLocalRef(productIDs);\n\t\t\tenv->DeleteLocalRef(jstrEmptyString);\n\t\t\tenv->DeleteLocalRef(jStringClass);\n        }\n        //---------------------------------------------------------------\n        //---------------------------------------------------------------\n        void AmazonIAPJavaInterface::OnProductDescriptionsRequestComplete(const std::vector<ChilliSource::IAPSystem::ProductDesc>& in_products)\n        {\n        \tif(m_productsRequestDelegate != nullptr)\n        \t{\n        \t\tm_productsRequestDelegate(in_products);\n        \t\tm_productsRequestDelegate = nullptr;\n        \t}\n        }\n        //---------------------------------------------------------------\n        //---------------------------------------------------------------\n        void AmazonIAPJavaInterface::CancelProductDescriptionsRequest()\n        {\n\t\t\tJNIEnv* env = JavaInterfaceManager::GetSingletonPtr()->GetJNIEnvironmentPtr();\n\t\t\tenv->CallVoidMethod(GetJavaObject(), GetMethodID(\"CancelProductDescriptionsRequest\"));\n        }\n        //---------------------------------------------------------------\n        //---------------------------------------------------------------\n        void AmazonIAPJavaInterface::RequestProductPurchase(const std::string& in_productId)\n        {\n\t\t\tJNIEnv* env = JavaInterfaceManager::GetSingletonPtr()->GetJNIEnvironmentPtr();\n\t\t\tjstring productID = JavaUtils::CreateJStringFromSTDString(in_productId);\n\t\t\tenv->CallVoidMethod(GetJavaObject(), GetMethodID(\"RequestProductPurchase\"), productID);\n\t\t\tenv->DeleteLocalRef(productID);\n        }\n        //---------------------------------------------------------------\n        //---------------------------------------------------------------\n        void AmazonIAPJavaInterface::OnTransactionStatusUpdated(u32 in_statusId, const ChilliSource::IAPSystem::Transaction& in_transaction)\n        {\n        \tif(m_transactionStatusDelegate != nullptr)\n        \t{\n\t\t\t\tChilliSource::IAPSystem::Transaction::Status status = ChilliSource::IAPSystem::Transaction::Status::k_failed;\n\n\t\t\t\t//This requires a little bit of faith. These numbers correspond to the constants defined\n\t\t\t\t//in the java class CPurchaseTransaction\n\t\t\t\tconst u32 k_purchaseSucceeded = 0;\n\t\t\t\tconst u32 k_purchaseResumed = 1;\n\t\t\t\tconst u32 k_purchaseRestored = 2;\n\t\t\t\tconst u32 k_purchaseFailed = 3;\n\n\t\t\t\tswitch(in_statusId)\n\t\t\t\t{\n\t\t\t\t\tcase k_purchaseSucceeded:\n\t\t\t\t\t\tstatus = ChilliSource::IAPSystem::Transaction::Status::k_succeeded;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase k_purchaseResumed:\n\t\t\t\t\t\tstatus = ChilliSource::IAPSystem::Transaction::Status::k_resumed;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase k_purchaseRestored:\n\t\t\t\t\t\tstatus = ChilliSource::IAPSystem::Transaction::Status::k_restored;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase k_purchaseFailed:\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tstatus = ChilliSource::IAPSystem::Transaction::Status::k_failed;\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tChilliSource::IAPSystem::TransactionSPtr transaction(new ChilliSource::IAPSystem::Transaction());\n\t\t\t\ttransaction->m_productId = in_transaction.m_productId;\n\t\t\t\ttransaction->m_transactionId = in_transaction.m_transactionId;\n\t\t\t\ttransaction->m_receipt = in_transaction.m_receipt;\n\n\t\t\t\tm_transactionStatusDelegate(status, transaction);\n        \t}\n        }\n        //---------------------------------------------------------------\n        //---------------------------------------------------------------\n        void AmazonIAPJavaInterface::CloseTransaction(const std::string& in_productId, const std::string& in_transactionId, const ChilliSource::IAPSystem::TransactionCloseDelegate& in_delegate)\n        {\n        \tCS_ASSERT(in_delegate != nullptr, \"Cannot have null transaction close delegate\");\n        \tCS_ASSERT(m_transactionCloseDelegate == nullptr, \"Only 1 transaction can be closed at a time\");\n\n        \tm_transactionCloseDelegate = in_delegate;\n\n\t\t\tJNIEnv* env = JavaInterfaceManager::GetSingletonPtr()->GetJNIEnvironmentPtr();\n\t\t\tjstring productId = JavaUtils::CreateJStringFromSTDString(in_productId);\n\t\t\tjstring transactionId = JavaUtils::CreateJStringFromSTDString(in_transactionId);\n\t\t\tenv->CallVoidMethod(GetJavaObject(), GetMethodID(\"CloseTransaction\"), productId, transactionId);\n\t\t\tenv->DeleteLocalRef(productId);\n\t\t\tenv->DeleteLocalRef(transactionId);\n        }\n        //---------------------------------------------------------------\n        //---------------------------------------------------------------\n        void AmazonIAPJavaInterface::OnTransactionClosed(const std::string& in_productId, const std::string& in_transactionId)\n        {\n        \tif(m_transactionCloseDelegate != nullptr)\n        \t{\n        \t\tm_transactionCloseDelegate(in_productId, in_transactionId, true);\n        \t\tm_transactionCloseDelegate = nullptr;\n        \t}\n        }\n        //---------------------------------------------------------------\n        //---------------------------------------------------------------\n        void AmazonIAPJavaInterface::RestoreManagedPurchases()\n        {\n        \tJNIEnv* env = JavaInterfaceManager::GetSingletonPtr()->GetJNIEnvironmentPtr();\n        \tenv->CallVoidMethod(GetJavaObject(), GetMethodID(\"RestoreManagedPurchases\"));\n        }\n\t}\n}\n\n#endif\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Amazon/JNI/Networking/IAP/AmazonIAPJavaInterface.h",
    "content": "//\n//  AmazonIAPJavaInterface.h\n//  ChilliSource\n//  Created by Ian Copland on 10/12/2013.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2013 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n\n#ifdef CS_ANDROIDFLAVOUR_AMAZON\n\n#ifndef _CSBACKEND_PLATFORM_ANDROID__EXTENSIONS_AMAZON_AMAZONIAPJAVAINTERFACE_H_\n#define _CSBACKEND_PLATFORM_ANDROID__EXTENSIONS_AMAZON_AMAZONIAPJAVAINTERFACE_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Networking/IAP/IAPSystem.h>\n\n#include <CSBackend/Platform/Android/Amazon/JNI/ForwardDeclarations.h>\n#include <CSBackend/Platform/Android/Main/JNI/ForwardDeclarations.h>\n#include <CSBackend/Platform/Android/Main/JNI/Core/Java/JavaInterface.h>\n\nnamespace CSBackend\n{\n\tnamespace Android\n\t{\n\t\t//--------------------------------------------------------------\n\t\t/// Interface class that allows communication between the\n\t\t/// Amazon IAP system and the Java Amazon billing SDK\n\t\t///\n\t\t/// @author Ian Copland\n\t\t//--------------------------------------------------------------\n\t\tclass AmazonIAPJavaInterface final : public IJavaInterface\n\t\t{\n\t\tpublic:\n\t\t\tCS_DECLARE_NAMEDTYPE(AmazonIAPJavaInterface);\n\t\t\t//--------------------------------------------------------------\n\t\t\t/// Constructor\n\t\t\t///\n\t\t\t/// @author Ian Copland\n\t\t\t///\n\t\t\t/// @param The private key.\n\t\t\t/// @param The UDID\n\t\t\t//--------------------------------------------------------------\n\t\t\tAmazonIAPJavaInterface(const std::string& in_privateKey, const std::string& in_udid);\n\t\t\t//--------------------------------------------------------------\n\t\t\t/// @author Ian Copland\n\t\t\t///\n\t\t\t/// @param Interface ID\n\t\t\t///\n\t\t\t/// @return whether or not this object implements the given interface.\n\t\t\t//--------------------------------------------------------------\n\t\t\tbool IsA(ChilliSource::InterfaceIDType in_interfaceId) const override;\n            //---------------------------------------------------------------\n\t\t\t/// @author Ian Copland\n\t\t\t///\n\t\t\t/// @return Whether the purchasing is allowed by the device/OS\n            //---------------------------------------------------------------\n            bool IsPurchasingEnabled();\n            //---------------------------------------------------------------\n\t\t\t/// Calling this function will set the listener to which any\n            /// transaction events are directed. This is not necessarily\n            /// in response to a user action it may be previously outstanding\n            /// transactions.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param Delegate\n            //---------------------------------------------------------------\n            void StartListeningForTransactionUpdates(const ChilliSource::IAPSystem::TransactionStatusDelegate& in_delegate);\n            //---------------------------------------------------------------\n            /// Prevent any more transaction updates from being triggered.\n            ///\n            /// @author Ian Copland\n            //---------------------------------------------------------------\n            void StopListeningForTransactionUpdates();\n            //---------------------------------------------------------------\n            /// Starts a request to the store for details of the products.\n            /// These details are name, description and price\n            ///\n            /// @author Ian Copland\n            ///\n\t\t\t/// @param List of product IDs to request descriptions for\n            /// @param Delegate to invoke when the request completes\n            //---------------------------------------------------------------\n            void RequestProductDescriptions(const std::vector<std::string>& in_productIds, const ChilliSource::IAPSystem::ProductDescDelegate& in_delegate);\n            //---------------------------------------------------------------\n\t\t\t/// Prevent the completion delegate being called for\n            /// any pending product description requests and attempt to\n            /// cancel the request to the store.\n            ///\n            /// @author Ian Copland\n            //---------------------------------------------------------------\n            void CancelProductDescriptionsRequest();\n            //---------------------------------------------------------------\n\t\t\t/// Make a request to the store to purchase the item.\n            /// This will trigger a call to the transaction listener delegate\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param Product ID\n            //---------------------------------------------------------------\n            void RequestProductPurchase(const std::string& in_productId);\n            //---------------------------------------------------------------\n\t\t\t/// Tell the store to close the transaction as complete.\n            /// NOTE: This should only be called after the goods have been\n            /// awarded.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param Product ID\n            /// @param Transaction ID\n            /// @param Delegate to call when closed (either with success or failure)\n            //---------------------------------------------------------------\n            void CloseTransaction(const std::string& in_productId, const std::string& in_transactionId, const ChilliSource::IAPSystem::TransactionCloseDelegate& in_delegate);\n            //---------------------------------------------------------------\n            /// Request that the store trigger new purchase requests for\n            /// owned non-consumable items\n            ///\n            /// @author Ian Copland\n            //---------------------------------------------------------------\n            void RestoreManagedPurchases();\n\n            //---Only called by JNI - Otherwise would be private\n            //---------------------------------------------------------------\n    \t\t/// Called when product descriptions request completes\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param List of product descriptions\n            //---------------------------------------------------------------\n            void OnProductDescriptionsRequestComplete(const std::vector<ChilliSource::IAPSystem::ProductDesc>& in_products);\n            //---------------------------------------------------------------\n    \t\t/// Called when transaction status changes\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param Status ID\n            /// @param Transaction description\n            //---------------------------------------------------------------\n            void OnTransactionStatusUpdated(u32 in_statusId, const ChilliSource::IAPSystem::Transaction& in_transaction);\n            //---------------------------------------------------------------\n    \t\t/// Called when transaction close request completes\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param Product ID\n            /// @param Transaction ID\n            //---------------------------------------------------------------\n            void OnTransactionClosed(const std::string& in_productId, const std::string& in_transactionId);\n\n\t\tprivate:\n\n            ChilliSource::IAPSystem::ProductDescDelegate m_productsRequestDelegate;\n            ChilliSource::IAPSystem::TransactionStatusDelegate m_transactionStatusDelegate;\n            ChilliSource::IAPSystem::TransactionCloseDelegate m_transactionCloseDelegate;\n\t\t};\n\t}\n}\n\n#endif\n\n#endif\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Amazon/JNI/Networking/IAP/AmazonIAPSystem.cpp",
    "content": "//\n//  AmazonIAPSystem.cpp\n//  ChilliSource\n//  Created by Ian Copland on 10/12/2013.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2013 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n\n#ifdef CS_ANDROIDFLAVOUR_AMAZON\n\n#include <CSBackend/Platform/Android/Amazon/JNI/Networking/IAP/AmazonIAPSystem.h>\n\n#include <CSBackend/Platform/Android/Main/JNI/Core/Java/JavaInterfaceManager.h>\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/Base/Device.h>\n\nnamespace CSBackend\n{\n\tnamespace Android\n\t{\n\t\tnamespace\n\t\t{\n\t\t\tconst std::string k_amazonPrivateKeyKey(\"AmazonPrivateKey\");\n\n            //---------------------------------------------------------------\n            /// @author Ian Copland\n            ///\n            /// @param List of product registrations\n            /// @param Product Id to find\n            ///\n            /// @return Whether a product reg info exists in the list\n            /// with the given Id.\n            //---------------------------------------------------------------\n            bool ContainsProductId(const std::vector<ChilliSource::IAPSystem::ProductRegInfo>& in_productInfos, const std::string& in_productId)\n            {\n                for(u32 i=0; i<in_productInfos.size(); ++i)\n                {\n                    if(in_productInfos[i].m_id == in_productId)\n                    {\n                        return true;\n                    }\n                }\n\n                return false;\n            }\n\t\t}\n\n\t\tCS_DEFINE_NAMEDTYPE(AmazonIAPSystem);\n\n    \t//---------------------------------------------------------------\n    \t//---------------------------------------------------------------\n\t\tAmazonIAPSystem::AmazonIAPSystem(const ChilliSource::ParamDictionary& in_params)\n\t\t{\n\t\t\tCS_ASSERT(in_params.HasKey(k_amazonPrivateKeyKey) == true, \"Cannot create Amazon IAP system without store key - AmazonPrivateKey\");\n\t\t\tm_privateKey = in_params.GetValue(k_amazonPrivateKeyKey);\n\t\t}\n        //---------------------------------------------------------------\n        //---------------------------------------------------------------\n        bool AmazonIAPSystem::IsA(ChilliSource::InterfaceIDType in_interfaceId) const\n        {\n            return in_interfaceId == ChilliSource::IAPSystem::InterfaceID || in_interfaceId == AmazonIAPSystem::InterfaceID;\n        }\n        //---------------------------------------------------------------\n        //---------------------------------------------------------------\n        void AmazonIAPSystem::OnInit()\n        {\n\t\t\tm_javaInterface = JavaInterfaceManager::GetSingletonPtr()->GetJavaInterface<AmazonIAPJavaInterface>();\n\t\t\tif (m_javaInterface == nullptr)\n\t\t\t{\n\t\t\t\tChilliSource::Device* device = ChilliSource::Application::Get()->GetSystem<ChilliSource::Device>();\n\t\t\t\tm_javaInterface = AmazonIAPJavaInterfaceSPtr(new AmazonIAPJavaInterface(m_privateKey, device->GetUDID()));\n\t        \tJavaInterfaceManager::GetSingletonPtr()->AddJavaInterface(m_javaInterface);\n\t\t\t}\n        }\n        //---------------------------------------------------------------\n        //---------------------------------------------------------------\n        void AmazonIAPSystem::RegisterProducts(const std::vector<ProductRegInfo>& in_productInfos)\n        {\n        \tCS_ASSERT(in_productInfos.empty() == false, \"Must register at least one product\");\n            m_productRegInfos = in_productInfos;\n        }\n        //---------------------------------------------------------------\n        //---------------------------------------------------------------\n\t\tstd::string AmazonIAPSystem::GetProviderID() const\n\t\t{\n\t\t\treturn \"AmazonAppStore\";\n\t\t}\n        //---------------------------------------------------------------\n        //---------------------------------------------------------------\n        void AmazonIAPSystem::IsPurchasingEnabled(const PurchasingEnabledDelegate& in_delegate)\n        {\n            CS_ASSERT(in_delegate, \"Cannot have empty delegate\");\n        \tin_delegate(m_javaInterface->IsPurchasingEnabled());\n        }\n        //---------------------------------------------------------------\n        //---------------------------------------------------------------\n        void AmazonIAPSystem::StartListeningForTransactionUpdates(const TransactionStatusDelegate& in_delegate)\n        {\n        \tCS_ASSERT(in_delegate != nullptr, \"Cannot have null transaction delegate\");\n        \tm_javaInterface->StartListeningForTransactionUpdates(in_delegate);\n        }\n        //---------------------------------------------------------------\n        //---------------------------------------------------------------\n        void AmazonIAPSystem::StopListeningForTransactionUpdates()\n        {\n        \tm_javaInterface->StopListeningForTransactionUpdates();\n        }\n        //---------------------------------------------------------------\n        //---------------------------------------------------------------\n        void AmazonIAPSystem::RequestProductDescriptions(const std::vector<std::string>& in_productIds, const ProductDescDelegate& in_delegate)\n        {\n            CS_ASSERT(in_productIds.empty() == false, \"Cannot request no product descriptions\");\n            CS_ASSERT(in_delegate != nullptr, \"Cannot have null product description delegate\");\n        \tm_javaInterface->RequestProductDescriptions(in_productIds, in_delegate);\n        }\n        //---------------------------------------------------------------\n        //---------------------------------------------------------------\n        void AmazonIAPSystem::RequestAllProductDescriptions(const ProductDescDelegate& in_delegate)\n        {\n            std::vector<std::string> productIds;\n            productIds.reserve(m_productRegInfos.size());\n\n            for(u32 i=0; i<m_productRegInfos.size(); ++i)\n            {\n            \tproductIds.push_back(m_productRegInfos[i].m_id);\n            }\n\n            RequestProductDescriptions(productIds, in_delegate);\n        }\n        //---------------------------------------------------------------\n        //---------------------------------------------------------------\n        void AmazonIAPSystem::CancelProductDescriptionsRequest()\n        {\n        \tm_javaInterface->CancelProductDescriptionsRequest();\n        }\n        //---------------------------------------------------------------\n        //---------------------------------------------------------------\n        void AmazonIAPSystem::RequestProductPurchase(const std::string& in_productId)\n        {\n        \tCS_ASSERT(ContainsProductId(m_productRegInfos, in_productId), \"Products must be registered with the IAP system before purchasing\");\n        \tm_javaInterface->RequestProductPurchase(in_productId);\n        }\n        //---------------------------------------------------------------\n        //---------------------------------------------------------------\n        void AmazonIAPSystem::CloseTransaction(const TransactionSPtr& in_transaction, const TransactionCloseDelegate& in_delegate)\n        {\n        \tm_javaInterface->CloseTransaction(in_transaction->m_productId, in_transaction->m_transactionId, in_delegate);\n        }\n        //---------------------------------------------------------------\n        //---------------------------------------------------------------\n        void AmazonIAPSystem::RestoreManagedPurchases()\n        {\n        \tm_javaInterface->RestoreManagedPurchases();\n        }\n        //---------------------------------------------------------------\n        //---------------------------------------------------------------\n        void AmazonIAPSystem::OnDestroy()\n        {\n        \tm_javaInterface = nullptr;\n            m_productRegInfos.clear();\n            m_productRegInfos.shrink_to_fit();\n        }\n\t}\n}\n\n#endif\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Amazon/JNI/Networking/IAP/AmazonIAPSystem.h",
    "content": "//\n//  AmazonIAPSystem.h\n//  ChilliSource\n//  Created by Ian Copland on 10/12/2013.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2013 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n\n#ifdef CS_ANDROIDFLAVOUR_AMAZON\n\n#ifndef _CSBACKEND_PLATFORM_ANDROID_EXTENSIONS_AMAZON_AMAZONIAPSYSTEM_H_\n#define _CSBACKEND_PLATFORM_ANDROID_EXTENSIONS_AMAZON_AMAZONIAPSYSTEM_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Networking/IAP/IAPSystem.h>\n\n#include <CSBackend/Platform/Android/Amazon/JNI/ForwardDeclarations.h>\n#include <CSBackend/Platform/Android/Amazon/JNI/Networking/IAP/AmazonIAPJavaInterface.h>\n#include <CSBackend/Platform/Android/Main/JNI/ForwardDeclarations.h>\n\nnamespace CSBackend\n{\n\tnamespace Android\n\t{\n\t\t//----------------------------------------------------------------------------------\n\t\t/// System that allows purchasing of IAPs from\n\t\t/// the Amazon App Store. System allows product info\n\t\t/// to be requested in ordrer to build displays and then\n\t\t/// for products to be purchased. NOTE: Must StartListeningForTransactionUpdates()\n\t\t/// before any purchases are made as this can be called with previously incomplete\n\t\t/// transactions.\n\t\t///\n\t\t/// Note: The CS pre-processor flag CS_ANDROIDFLAVOUR_AMAZON should be set for this to be used.\n\t\t///\n\t\t/// @author Ian Copland\n\t\t//----------------------------------------------------------------------------------\n\t\tclass AmazonIAPSystem final : public ChilliSource::IAPSystem\n\t\t{\n\t\tpublic:\n\n\t\t\tCS_DECLARE_NAMEDTYPE(AmazonIAPSystem);\n\n            //---------------------------------------------------------------\n            /// @author Ian Copland\n            ///\n            /// @param Interface ID to compare\n            ///\n            /// @return Whether the class is of the given type\n            //---------------------------------------------------------------\n            bool IsA(ChilliSource::InterfaceIDType in_interfaceId) const override;\n            //---------------------------------------------------------------\n            /// Inform the system of which products are available for\n            /// purchase and whether they are managed or unmanaged\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param List of products\n            //---------------------------------------------------------------\n            void RegisterProducts(const std::vector<ProductRegInfo>& in_productInfos) override;\n            //---------------------------------------------------------------\n\t\t\t/// @author Ian Copland\n\t\t\t///\n\t\t\t/// @return The ID off the IAP provider as a string.\n            //---------------------------------------------------------------\n\t\t\tstd::string GetProviderID() const override;\n            //---------------------------------------------------------------\n\t\t\t/// @author Ian Copland\n\t\t\t///\n            /// @param Purchasing enabled delegate\n            //---------------------------------------------------------------\n            void IsPurchasingEnabled(const PurchasingEnabledDelegate& in_delegate) override;\n            //---------------------------------------------------------------\n\t\t\t/// Calling this function will set the listener to which any\n            /// transaction events are directed. This is not necessarily\n            /// in response to a user action it may be previously outstanding\n            /// transactions.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param Delegate\n            //---------------------------------------------------------------\n            void StartListeningForTransactionUpdates(const TransactionStatusDelegate& in_delegate) override;\n            //---------------------------------------------------------------\n            /// Prevent any more transaction uppdates from being triggered.\n            ///\n            /// @author Ian Copland\n            //---------------------------------------------------------------\n            void StopListeningForTransactionUpdates() override;\n            //---------------------------------------------------------------\n            /// Starts a request to the store for details of the products.\n            /// These details are name, description and price\n            ///\n            /// @author Ian Copland\n            ///\n\t\t\t/// @param List of product IDs to request descriptions for\n            /// @param Delegate to invoke when the request completes\n            //---------------------------------------------------------------\n            void RequestProductDescriptions(const std::vector<std::string>& in_productIds, const ProductDescDelegate& in_delegate) override;\n            //---------------------------------------------------------------\n            /// Starts a request to the store for details of all registered\n            /// products. These details are name, description and price\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param Delegate to invoke when the request completes\n            //---------------------------------------------------------------\n            void RequestAllProductDescriptions(const ProductDescDelegate& in_delegate) override;\n            //---------------------------------------------------------------\n\t\t\t/// Prevent the completion delegate being called for\n            /// any pending product description requests and attempt to\n            /// cancel the request to the store.\n            ///\n            /// @author Ian Copland\n            //---------------------------------------------------------------\n            void CancelProductDescriptionsRequest() override;\n            //---------------------------------------------------------------\n\t\t\t/// Make a request to the store to purchase the item.\n            /// This will trigger a call to the transaction listener delegate\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param Product ID\n            //---------------------------------------------------------------\n            void RequestProductPurchase(const std::string& in_productId) override;\n            //---------------------------------------------------------------\n            /// Tell the store to close the transaction as complete.\n            /// NOTE: This should only be called after the goods have been\n            /// awarded.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param Transaction to close\n            /// @param Delegate to call when closed (either with success or failure)\n            //---------------------------------------------------------------\n            void CloseTransaction(const TransactionSPtr& inpTransaction, const TransactionCloseDelegate& in_delegate) override;\n            //---------------------------------------------------------------\n            /// Request that the store trigger new purchase requests for\n            /// owned non-consumable items\n            ///\n            /// @author Ian Copland\n            //---------------------------------------------------------------\n            void RestoreManagedPurchases() override;\n\n\t\tprivate:\n\n            friend ChilliSource::IAPSystemUPtr ChilliSource::IAPSystem::Create(const ChilliSource::ParamDictionary&);\n            //---------------------------------------------------------------\n            /// Private constructor to enforce use of factory method\n            ///\n            /// @author Ian Copland\n\t\t\t///\n\t\t\t/// @param A dictionary of platform specific parameters. The\n\t\t\t/// parameters that relate to the Amazon IAP System are as\n\t\t\t/// follows:\n\t\t\t/// \tAmazonPrivateKey\tThe private key used to encrypt\n            ///\t\t\t\t\t\t\tthe on disk Amazon IAP cache.\n            //---------------------------------------------------------------\n\t\t\tAmazonIAPSystem(const ChilliSource::ParamDictionary& in_params);\n            //-------------------------------------------------------\n            /// Called when the system is created. Initialises\n            /// the StoreKit backend\n            ///\n            /// @author S Downie\n            //-------------------------------------------------------\n            void OnInit() override;\n            //-------------------------------------------------------\n            /// Called when the system is shutdown.\n            ///\n            /// @author S Downie\n            //-------------------------------------------------------\n            void OnDestroy() override;\n\n\t\tprivate:\n\n            std::vector<ProductRegInfo> m_productRegInfos;\n            std::string m_privateKey;\n            AmazonIAPJavaInterfaceSPtr m_javaInterface;\n\t\t};\n\t}\n}\n\n#endif\n\n#endif\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Amazon/Java/com/chilliworks/chillisource/core/PackageFileUtils.java",
    "content": "/**\n * PackageFileUtils.java\n * ChilliSource\n * Created by Ian Copland on 22/07/2015\n *\n * The MIT License (MIT)\n *\n * Copyright (c) 2015 Tag Games Limited\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.core;\n\nimport android.app.Activity;\n\n/**\n * A collection of convenience methods for reading files from the either the Apk or the Apk\n * expansion file, depending on the current product flavour. Google Play builds will refer to\n * the Apk expansion file, while Amazon builds will use the Apk.\n *\n * Note that package doesn't quite mean the same thing here as on the native side of the engine.\n * In the native side, package refers specifically to the AppResources/ directory inside either the\n * Apk Expansion file or Apk; this refers simply to root.\n *\n * @author Ian Copland\n */\npublic final class PackageFileUtils\n{\n    /**\n     * @author Ian Copland\n     *\n     * @param in_activity - The current activity.\n     * @param in_filePath - The file path inside either the Apk or the Apk Expansion file depending\n     * on the current product flavour.\n     *\n     * @return Whether or not the given file exists in either the Apk or the Apk Expansion file\n     * depending on the current product flavour.\n     */\n    public static boolean doesFileExist(Activity in_activity, String in_filePath)\n    {\n        return ApkFileUtils.doesFileExist(in_activity, in_filePath);\n    }\n    /**\n     * Reads the entire contents of a binary file from either the Apk or the Apk Expansion file\n     * depending on the current product flavour. The contents are returned as a byte array.\n     *\n     * @author Ian Copland\n     *\n     * @param in_activity - The activity\n     * @param in_filePath - The path to the file.\n     *\n     * @return The file contents.\n     */\n    public static byte[] readBinaryFile(Activity in_activity, String in_filePath)\n    {\n        return ApkFileUtils.readBinaryFile(in_activity, in_filePath);\n    }\n    /**\n     * Reads the entire contents of a text file from either the Apk or the Apk Expansion file\n     * depending on the current product flavour\n     *\n     * @author Ian Copland\n     *\n     * @param in_activity - The activity\n     * @param in_filePath - The path to the file.\n     *\n     * @return The file contents.\n     */\n    public static String readTextFile(Activity in_activity, String in_filePath)\n    {\n        return ApkFileUtils.readTextFile(in_activity, in_filePath);\n    }\n    /**\n     * Calculates the size of the given file located in either the Apk or the Apk Expansion file\n     * depending on the current product flavour.\n     *\n     * @author Ian Copland\n     *\n     * @param in_activity - The activity which is currently active.\n     * @param in_filePath - The path to the file which is to have its size calculated.\n     *\n     * @return The size of the file in bytes.\n     */\n    public static long getFileSize(Activity in_activity, String in_filePath)\n    {\n        return ApkFileUtils.getFileSize(in_activity, in_filePath);\n    }\n    /**\n     * Copies the requested file from either the Apk or the Apk Expansion file - depending on the c\n     * current product flavour - to external storage.\n     *\n     * @author Ian Copland\n     *\n     * @param in_activity - The activity which is currently active.\n     * @param in_sourceFilePath - The source file path inside either the Apk or the Apk Expansion\n     * file depending on the current product flavour.\n     * @param in_destFilePath - The destination file path in external storage.\n     *\n     * @return Whether or not the copy was successful.\n     */\n    public static boolean copyFile(Activity in_activity, String in_sourceFilePath, String in_destFilePath)\n    {\n        return ApkFileUtils.copyFile(in_activity, in_sourceFilePath, in_destFilePath);\n    }\n}\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Amazon/Java/com/chilliworks/chillisource/core/StartupActivityFactory.java",
    "content": "/**\n * StartupActivityFactory.java\n * ChilliSource\n * Created by Ian Copland on 01/06/2015.\n *\n * The MIT License (MIT)\n *\n * Copyright (c) 2015 Tag Games Limited\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.core;\n\nimport android.app.Activity;\n\n/**\n * A factory class for creating a flavour specific Activity which is presented prior to the\n * CSActivity. There is no start up activity for Amazon builds so no activity will be\n * created by this factory.\n *\n * @author Ian Copland\n */\npublic final class StartupActivityFactory\n{\n    /**\n     * Amazon builds do not require a start up activity, so this will never start an activity\n     * and will always return false.\n     *\n     * @author Ian Copland\n     *\n     * @param in_currentActivity - The currently active activity, typically the CSActivity.\n     *\n     * @return Always returns false.\n     */\n    public static boolean tryStartActivity(Activity in_currentActivity)\n    {\n        return false;\n    }\n}\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Amazon/Java/com/chilliworks/chillisource/networking/AmazonIAPNativeInterface.java",
    "content": "/**\n * AmazonIAPNativeInterface.java\n * ChilliSource\n * Created by Ian Copland on 10/12/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.networking;\n\nimport java.util.HashSet;\nimport java.util.LinkedList;\nimport java.util.Map;\nimport java.util.Set;\n\nimport org.json.JSONObject;\n\nimport com.amazon.inapp.purchasing.GetUserIdResponse;\nimport com.amazon.inapp.purchasing.Item;\nimport com.amazon.inapp.purchasing.Item.ItemType;\nimport com.amazon.inapp.purchasing.ItemDataResponse;\nimport com.amazon.inapp.purchasing.Offset;\nimport com.amazon.inapp.purchasing.PurchaseResponse;\nimport com.amazon.inapp.purchasing.PurchaseResponse.PurchaseRequestStatus;\nimport com.amazon.inapp.purchasing.PurchaseUpdatesResponse;\nimport com.amazon.inapp.purchasing.PurchasingManager;\nimport com.amazon.inapp.purchasing.Receipt;\nimport com.chilliworks.chillisource.networking.PurchaseTransaction.ProductType;\nimport com.chilliworks.chillisource.core.*;\n\n//===========================================================\n/// Amazon IAP Native Interface\n///\n/// A native interface for the Amazon IAP system. \n//===========================================================\npublic class AmazonIAPNativeInterface extends com.chilliworks.chillisource.core.System\n{\n\t//-----------------------------------------------------\n\t/// State\n\t///\n\t/// Describes the current state of the IAP system.\n\t//-----------------------------------------------------\n\tenum State\n\t{\n\t\tUNINITIALISED,\n\t\tREGISTERING_OBSERVER,\n\t\tGETTING_USER_ID,\n\t\tREADY,\n\t\tREQUESTING_PRODUCT_DESCRIPTIONS\n\t}\n\t//-----------------------------------------------------\n\t/// Constants\n\t//-----------------------------------------------------\n\tpublic static InterfaceId INTERFACE_ID = new InterfaceId();\n\tprivate static String kstrCacheNamePrefix = \"AmazonIAP-\";\n\tprivate static String kstrCacheExtension = \".iapcache\";\n\tprivate static String kstrReceiptUserIDKey = \"UserID\";\n\tprivate static String kstrReceiptTokenKey = \"Token\";\n\t//-----------------------------------------------------\n\t/// Member Data\n\t//-----------------------------------------------------\n\tprivate volatile State meState = State.UNINITIALISED;\n\tprivate volatile DataStore mDataStore = null;\n\tprivate boolean mbSandboxMode = false;\n\tprivate boolean mbListeningForPurchaseTransactions = false;\n\tprivate Set<String> mastrStartupProductDescSkuSet = null;\n\tprivate boolean mbCancellingProductDescRequest = false;\n\tprivate String mstrUserID = \"\";\n\tprivate String mstrPrivateKey = \"\";\n\tprivate String mstrUDID = \"\";\n\tprivate String mstrCurrentSKU = \"\";\n\t//-----------------------------------------------------\n\t/// Constructor\n\t//-----------------------------------------------------\n\tpublic AmazonIAPNativeInterface()\n\t{\n        init();\n\t}\n    /**\n     * Allows querying of whether or not the system implements the interface described by the\n     * given interface id.\n     *\n     * @author Ian Copland\n     *\n     * @param in_interfaceId - The interface id to check\n     *\n     * @return Whether the system implements the given interface\n     */\n    @Override public boolean isA(InterfaceId in_interfaceId)\n    {\n        return (in_interfaceId == INTERFACE_ID);\n    }\n\t//-----------------------------------------------------\n\t/// Init\n\t///\n\t/// Prepares and starts the IAP system. This should be \n\t/// the first method called and it should only be called \n\t/// once. \n\t/// \n\t/// @param The private key used to for encrypting the\n\t/// IAP cache files.\n\t/// @param The UDID.\n\t//-----------------------------------------------------\n\tpublic void Init(final String instrPrivateKey, final String instrUDID)\n\t{\n\t\tmstrPrivateKey = instrPrivateKey;\n\t\tmstrUDID = instrUDID;\n\t\t\n\t\tfinal AmazonIAPNativeInterface thisClass = this;\n\t\t\n\t\t//Run as a UI thread task as this will be constructed on the Render thread.\n\t\tRunnable task = new Runnable()\n\t\t{\n\t\t\t@Override public void run()\n\t\t\t{\n\t\t\t\tif (meState == State.UNINITIALISED)\n\t\t\t\t{\n\t\t\t\t\tmeState = State.REGISTERING_OBSERVER;\n\t\t\t\t\tPurchasingManager.registerObserver(new PurchasingObserver(CSApplication.get().getActivityContext(), thisClass));\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t\t\n\t\tCSApplication.get().scheduleUIThreadTask(task);\n\t}\n\t//-----------------------------------------------------\n\t/// On Resume\n\t///\n\t/// Called when the application is brought into the \n\t/// foreground. This requests an update to the users\n\t/// ID.\n\t//-----------------------------------------------------\n\t@Override synchronized public void onResume()\n\t{\n\t\t//if a user ID has already been requested it may now be out of date, so update it.\n\t\tif (meState != State.UNINITIALISED && meState != State.REGISTERING_OBSERVER)\n\t\t{\n\t\t\tmeState = State.GETTING_USER_ID;\n\t\t\tPurchasingManager.initiateGetUserIdRequest();\n\t\t}\n\t}\n\t//-----------------------------------------------------\n\t/// Is Initialised\n\t///\n\t/// @return whether or not the Amazon IAP system is\n\t/// finished initialising. The system is considered to\n\t/// be initialising if it is in any of the following\n\t/// states:\n\t///  - UNINITIALISED\n\t///  - REGISTERING_OBSERVER\n\t///  - GETTING_USER_ID\n\t//-----------------------------------------------------\n\tsynchronized public boolean IsInitialised() \n\t{\n\t\tif (meState == State.UNINITIALISED || meState == State.REGISTERING_OBSERVER || meState == State.GETTING_USER_ID)\n\t\t{\n\t\t\treturn false;\n\t\t}\n\t\treturn true;\n\t}\n    //-----------------------------------------------------\n\t/// Request Product Descriptions\n\t///\n\t/// Request the descriptions of the products on the \n\t/// store.\n\t///\n\t/// @param Array of product IDs\n\t//-----------------------------------------------------\n\tpublic synchronized void RequestProductDescriptions(final String[] inastrProductIDs)\n\t{\n\t\tif (meState == State.READY)\n\t\t{\n\t\t\tif (mbCancellingProductDescRequest == false)\n\t\t\t{\n\t\t\t\tmeState = State.REQUESTING_PRODUCT_DESCRIPTIONS;\n\t\t\t\t\n\t\t\t\tSet<String> astrSkuSet = new HashSet<String>();\n\t\t\t\tfor (String strProductID : inastrProductIDs)\n\t\t\t\t{\n\t\t\t\t\tastrSkuSet.add(strProductID);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tPurchasingManager.initiateItemDataRequest(astrSkuSet);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\t//This this will cause the system to received the previously requested product descriptions. This\n\t\t\t\t//means it will only work if the new request is identical to the previous one. \n\t\t\t\tmbCancellingProductDescRequest = false;\n\t\t\t\tmeState = State.REQUESTING_PRODUCT_DESCRIPTIONS;\n\t\t\t}\n\t\t}\n\t\telse if (IsInitialised() == false && mastrStartupProductDescSkuSet == null)\n\t\t{\n\t\t\tmastrStartupProductDescSkuSet = new HashSet<String>();\n\t\t\tfor (String strProductID : inastrProductIDs)\n\t\t\t{\n\t\t\t\tmastrStartupProductDescSkuSet.add(strProductID);\n\t\t\t}\n\t\t}\n    }\n    //-----------------------------------------------------\n    /// Cancel Product Descriptions Request\n    ///\n    /// Prevent the delegate being called with descriptions \n\t/// and attempt to cancel the pending request.\n    //-----------------------------------------------------\n    public synchronized void CancelProductDescriptionsRequest()\n    {\n    \tif (meState == State.REQUESTING_PRODUCT_DESCRIPTIONS)\n    \t{\n    \t\tmbCancellingProductDescRequest = true;\n    \t\tmeState = State.READY;\n    \t}\n    \telse if (IsInitialised() == false)\n    \t{\n    \t\tmastrStartupProductDescSkuSet = null;\n    \t}\n    }\n\t//-----------------------------------------------------\n\t/// Is Purchasing Enabled\n\t///\n\t/// @return whether or not IAP is supported on this \n    /// device/OS\n\t//-----------------------------------------------------\n\tpublic  synchronized boolean IsPurchasingEnabled()\n\t{\n\t\t//The amazon IAP interface doesn't expose a way of finding out if purchasing is\n\t\t//available so we are just returning true.\n\t\treturn true;\n\t}\n\t//-----------------------------------------------------\n\t/// Request Product Purchase\n\t///\n\t/// Start a transaction of an object with the given \n\t/// product ID. The transaction listener will receive \n\t/// updates on the transaction status.\n\t///\n\t/// @param Product ID\n\t//-----------------------------------------------------\n\tpublic synchronized void RequestProductPurchase(final String instrProductID)\n\t{\n\t\tif (meState == State.READY)\n\t\t{\n\t\t\tmstrCurrentSKU = instrProductID;\n\t\t\tPurchasingManager.initiatePurchaseRequest(instrProductID);\n\t\t}\n\t\telse\n\t\t{\n\t\t\t//if the system is not in a position to request purchases let the application know that it has failed.\n\t\t\tProcessPurchase(PurchaseTransaction.kdwPurchaseFailed, instrProductID, ItemType.CONSUMABLE, \"\", \"\", false);\n\t\t}\n\t}\n\t//-----------------------------------------------------\n\t/// Close Transaction\n\t///\n\t/// Consumes the transaction from the purchase list so \n\t/// that it may be purchased again.\n\t///\n\t/// @param Product ID\n\t/// @param Transaction ID\n\t//-----------------------------------------------------\n\tpublic synchronized void CloseTransaction(final String instrProductID, final String instrTransactionID)\n\t{\n\t\tmDataStore.RemovePendingPurchaseTransaction(instrProductID, instrTransactionID);\n\t\tNativeOnTransactionClosed(instrProductID, instrTransactionID);\n\t}\n\t//-----------------------------------------------------\n\t/// Restore Managed Purchases\n\t///\n\t/// Restores all previous managed purchase by injecting \n\t/// them as new transactions\n\t//-----------------------------------------------------\n\tpublic synchronized void RestoreManagedPurchases()\n\t{\n\t\tmDataStore.ClearEntitledSKUs();\n\t\tPurchasingManager.initiatePurchaseUpdatesRequest(Offset.BEGINNING);\n\t}\n\t//-----------------------------------------------------\n\t/// Start Listening For TransactionUpdates\n\t///\n\t/// Starts listening for purchase transactions. This\n\t/// means that purchase transactions will be passed down \n\t/// to the native side of the engine when received. This\n\t/// will also send any transactions currently in the\n\t/// purchase transaction cache.\n\t//-----------------------------------------------------\n\tpublic synchronized void StartListeningForTransactionUpdates()\n\t{\n\t\tif (mbListeningForPurchaseTransactions == false)\n\t\t{\n\t\t\tmbListeningForPurchaseTransactions = true;\n\t\t\t\n\t\t\t//there may be some transactions that have been cached while we were not listening, so these should now\n\t\t\t//be sent down to the application.\n\t\t\tProcessPendingTransactions();\n\t\t}\n\t}\n\t//-----------------------------------------------------\n\t/// Stop Listening For TransactionUpdates\n\t///\n\t/// Stops listening for purchase transactions. All\n\t/// purchase transactions received will no longer be\n\t/// passed down to the native side of the engine and will\n\t/// instead simply be added to the purchase transactions\n\t/// cache.\n\t//-----------------------------------------------------\n\tpublic synchronized void StopListeningForTransactionUpdates()\n\t{\n\t\tmbListeningForPurchaseTransactions = false;\n\t}\n\t//-----------------------------------------------------\n\t/// On SDK Available\n\t///\n\t/// This is called when the observer is registered.\n\t/// It provides information on whether the \n\t/// application is in sand box mode or not.\n\t///\n\t/// @param Whether or not this application is\n\t/// in sand box mode.\n\t//-----------------------------------------------------\n\tpublic synchronized void OnSDKAvailable(final boolean inbSandboxMode)\n\t{\n\t\tif (meState == State.REGISTERING_OBSERVER)\n\t\t{\n\t\t\tmbSandboxMode = inbSandboxMode;\n\t\t\tPurchasingManager.initiateGetUserIdRequest();\n\t\t\tmeState = State.GETTING_USER_ID;\n\t\t}\n\t}\t\n\t//-----------------------------------------------------\n\t/// On Get User ID Response\n\t///\n\t/// Called in response to a request for the users\n\t/// amazon store id. This is called on the UI Thread.\n\t///\n\t/// @param The response.\n\t//-----------------------------------------------------\n\tpublic synchronized void OnGetUserIdResponse(final GetUserIdResponse inResponse) \n\t{\n\t\tif (meState == State.GETTING_USER_ID)\n\t\t{\n\t\t\tif (inResponse.getUserIdRequestStatus() == GetUserIdResponse.GetUserIdRequestStatus.SUCCESSFUL) \n\t\t\t{\n\t\t\t\tmstrUserID = inResponse.getUserId();\n\t\t\t\tRefreshDataStore();\n\t\t\t\tmeState = State.READY;\n\t\t\t\t\n\t\t\t\t//Request an update on transactions for the current user.\n\t\t\t\tPurchasingManager.initiatePurchaseUpdatesRequest(mDataStore.GetPurchaseUpdateOffset());\n\t\t\t\t\n\t\t\t\t//if product descriptions were requested prior to the system finishing initialising the request should now be fired.\n\t\t\t\tif (mastrStartupProductDescSkuSet != null)\n\t\t\t\t{\n\t\t\t\t\tString[] astrIds = new String[mastrStartupProductDescSkuSet.size()];\n\t\t\t\t\tmastrStartupProductDescSkuSet.toArray(astrIds);\n\t\t\t\t\tRequestProductDescriptions(astrIds);\n\t\t\t\t\tmastrStartupProductDescSkuSet = null;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse \n\t\t\t{ \n\t\t\t\tLogging.logError(\"Amazon IAP System: failed to get the user ID.\");\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tLogging.logError(\"Amazon IAP System: User Id response received while not listening for one.\");\n\t\t}\n\t}\n\t//-----------------------------------------------------\n\t/// On Item Data Response\n\t///\n\t/// Called in response to a request for product descriptions.\n\t/// This is called on the UI Thread.\n\t///\n\t/// @param The response.\n\t//-----------------------------------------------------\n\tpublic synchronized void OnItemDataResponse(final ItemDataResponse inResponse) \n\t{\n\t\tif (meState == State.REQUESTING_PRODUCT_DESCRIPTIONS)\n\t\t{\n\t\t\tmeState = State.READY;\n\t\t\t\n\t\t\tswitch (inResponse.getItemDataRequestStatus()) \n\t\t\t{\n\t\t        case SUCCESSFUL_WITH_UNAVAILABLE_SKUS:\n\t\t        {\n\t\t            for (final String strSKU : inResponse.getUnavailableSkus()) \n\t\t            { \n\t\t            \tLogging.logError(\"Amazon IAP System: unavailable SKU '\" + strSKU + \"'\");\n\t\t            }\n\t\t            \n\t\t            //Fall through to the \"Successful\" block to pass down the valid SKUs.\n\t\t        }\n\t\t        case SUCCESSFUL:\n\t\t        {\n\t\t            final Map<String, Item> items = inResponse.getItemData();\n\t            \tString[] astrIDs = new String[items.size()];\n\t            \tString[] astrNames = new String[items.size()];\n\t            \tString[] astrDescriptions = new String[items.size()];\n\t            \tString[] astrFormattedPrices = new String[items.size()];\n\t            \tint dwCount = 0;\n\t\t            for (final String key : items.keySet()) \n\t\t            {\n\t\t                Item item = items.get(key);\n\t\t                astrIDs[dwCount] = item.getSku();\n\t\t                astrNames[dwCount] = item.getTitle();\n\t\t                astrDescriptions[dwCount] = item.getDescription();\n\t\t                astrFormattedPrices[dwCount] = item.getPrice();\n\t\t                dwCount++;\n\t\t            }\n\t\t            \n\t\t    \t\t//send event event down to the game code. It will be passed on to the render thread by the Java Interface, so no need to do it here.\n\t            \tfinal String[] kastrIDs = astrIDs;\n\t            \tfinal String[] kastrNames = astrNames;\n\t            \tfinal String[] kastrDescriptions = astrDescriptions;\n\t            \tfinal String[] kastrFormattedPrices = astrFormattedPrices;\n\t            \tNativeOnProductsDescriptionsRequestComplete(kastrIDs, kastrNames, kastrDescriptions, kastrFormattedPrices);\n\t\t            break;\n\t\t        }\n\t\t        case FAILED:\n\t\t        {\n\t\t        \t//The Amazon IAP documentation suggests that the application should disable IAPs if this fails. As the in app purchasing \n\t\t        \t//system requires this to send an event to proceed we can silently disable it by simply not firing it.\n\t\t        \tLogging.logError(\"Amazon IAP System: Request for item data failed! IAPs are now disabled.\");\n\t\t            break;\n\t\t        }\n\t\t\t}\n\t\t}\n\t\t\n\t\tmbCancellingProductDescRequest = false;\n\t}\n\t//-----------------------------------------------------\n\t/// On Purchase Response\n\t///\n\t/// Called in response to a purchase request. This is \n\t/// called on the UI Thread.\n\t///\n\t/// @param The response\n\t//-----------------------------------------------------\n\tpublic synchronized void OnPurchaseResponse(final PurchaseResponse inResponse)\n\t{\n\t\tfinal PurchaseRequestStatus eStatus = inResponse.getPurchaseRequestStatus();\n\t\tswitch (eStatus)\n        {\n\t        case SUCCESSFUL:\n\t        {\n\t            Receipt receipt = inResponse.getReceipt();\n\t            if (inResponse.getUserId().equals(mstrUserID) == true)\n\t            {\n\t            \tProcessPurchase(PurchaseTransaction.kdwPurchaseSuccessful, receipt.getSku(), receipt.getItemType(), inResponse.getRequestId(), receipt.getPurchaseToken(), true);\n\t            }\n\t            else\n\t            {\n\t            \tProcessPurchaseForUser(inResponse.getUserId(), PurchaseTransaction.kdwPurchaseSuccessful, receipt.getSku(), receipt.getItemType(), inResponse.getRequestId(), receipt.getPurchaseToken());\n\t            }\n\t            break;\n\t        }\n\t        default:\n\t        {\n\t        \tProcessPurchase(PurchaseTransaction.kdwPurchaseFailed, mstrCurrentSKU, ItemType.CONSUMABLE, \"\", \"\", false);\n\t        \tbreak;\n\t        }\n        }\n\t\t\n\t\tmstrCurrentSKU = \"\";\n\t}\n\t//-----------------------------------------------------\n\t/// On Item Data Response\n\t///\n\t/// Called in response to a request for an update on\n\t/// purchase receipts. This can occur in two cases.\n\t/// When the user is registered (on start up and on \n\t/// resume) transactions are updated from the point\n\t/// they were last updated. The user can also request\n\t/// a full update.\n\t/// \n\t/// @param The response.\n\t//-----------------------------------------------------\n\tpublic synchronized void OnPurchaseUpdatesResponse(final PurchaseUpdatesResponse inResponse) \n\t{\n\t\tswitch (inResponse.getPurchaseUpdatesRequestStatus())\n\t\t{\n\t\t\tcase SUCCESSFUL:\n\t\t\t{\n\t\t\t\t//check for existing managed purchases\n\t\t\t\tfor (final Receipt receipt : inResponse.getReceipts()) \n\t\t\t\t{\n                    switch (receipt.getItemType()) \n                    {\n                        case ENTITLED:\n                        {\n        \t\t            if (inResponse.getUserId().equals(mstrUserID) == true)\n        \t\t            {\n        \t\t            \tProcessPurchase(PurchaseTransaction.kdwPurchaseRestored, receipt.getSku(), receipt.getItemType(), inResponse.getRequestId(), receipt.getPurchaseToken(), false);\n        \t\t            }\n        \t\t            else\n        \t\t            {\n        \t\t            \tProcessPurchaseForUser(inResponse.getUserId(), PurchaseTransaction.kdwPurchaseRestored, receipt.getSku(), receipt.getItemType(), inResponse.getRequestId(), receipt.getPurchaseToken());\n        \t\t            }\n                        \tbreak;\n                        }\n                        default:\n                        \tbreak;\n                    }\n                }\n\t\t\t\t\n\t\t\t\t//update the transaction offset.\n\t\t\t\tfinal Offset newOffset = inResponse.getOffset();\n\t\t\t\tmDataStore.SetPurchaseUpdateOffset(newOffset);\n\t\t\t\tif (inResponse.isMore() == true)\n\t\t\t\t{\n\t\t\t\t\tPurchasingManager.initiatePurchaseUpdatesRequest(mDataStore.GetPurchaseUpdateOffset());\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase FAILED:\n\t\t\t{\n\t\t\t\tLogging.logError(\"Amazon IAP System: Failed to receive purchase updates response.\");\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\t//-----------------------------------------------------\n\t/// Refresh Data Store\n\t///\n\t/// Refreshes the data store, updating to a new user\n\t/// if it has changed.\n\t//-----------------------------------------------------\n\tprivate synchronized void RefreshDataStore()\n\t{\n\t\tString strUserIDHash = Integer.toString(Math.abs(HashCRC32.Generate(StringUtils.stringToUTF8Bytes(mstrUserID))));\n\t\tmDataStore = new DataStore(kstrCacheNamePrefix + strUserIDHash + kstrCacheExtension, mstrPrivateKey, mstrUDID, mstrUserID);\n\t}\n\t//-----------------------------------------------------\n\t/// Build Purchase Receipt\n\t///\n\t/// Builds JSON containing the user id that made the\n\t/// purchase and the purchase token. This is returned\n\t/// in string format.\n\t///\n\t/// @param The user ID.\n\t/// @param The Purchase Token.\n\t/// @return The receipt string.\n\t//-----------------------------------------------------\n\tprivate String BuildPurchaseReceipt(final String instrUserID, final String instrToken)\n\t{\n\t\tString strReceipt = \"\";\n\t\ttry\n\t\t{\n\t\t\tJSONObject root = new JSONObject();\n\t\t\troot.put(kstrReceiptUserIDKey, instrUserID);\n\t\t\troot.put(kstrReceiptTokenKey, instrToken);\n\t\t\tstrReceipt = root.toString();\n\t\t}\n\t\tcatch (Exception e)\n\t\t{\n\t\t\tLogging.logError(ExceptionUtils.convertToString(e));\n\t\t}\n\t\treturn strReceipt;\n\t}\n\t//-----------------------------------------------------\n\t/// Process Pending Transactions\n\t///\n\t/// Sends all pending transactions down to the native\n\t/// side of the engine.\n\t//-----------------------------------------------------\n\tprivate void ProcessPendingTransactions()\n\t{\n\t\tif (mbListeningForPurchaseTransactions == true)\n\t\t{\n\t\t\tfinal LinkedList<PurchaseTransaction> astrTransactions = mDataStore.GetPendingPurchaseTransactions();\n\t\t\tif (astrTransactions.size() > 0)\n\t\t\t{\n\t\t\t\tfor (final PurchaseTransaction transaction : astrTransactions)\n\t\t\t\t{\n\t\t\t\t\tint dwResult = transaction.GetResult();\n\t\t\t\t\t\n\t\t\t\t\t//if the transaction is a success, then change it to resumed to the application can tell that this is a successful\n\t\t\t\t\t//transaction from a previous attempt at purchasing.\n\t\t\t\t\tif (dwResult == PurchaseTransaction.kdwPurchaseSuccessful)\n\t\t\t\t\t{\n\t\t\t\t\t\tdwResult = PurchaseTransaction.kdwPurchaseResumed;\n\t\t\t\t\t}\n\t\t\t\t\tNativeOnTransactionStatusUpdated(dwResult, transaction.GetSKU(), transaction.GetTransactionID(), transaction.GetPurchaseReceipt());\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\t//-----------------------------------------------------\n\t/// Process Purchase\n\t///\n\t/// Processes a single purchase transaction. This will\n\t/// create a transaction, add it to the data store if\n\t/// it is not an error. It will then send it down to\n\t/// native if the application is currently listening\n\t/// for transactions. It will also add the sku to the\n\t/// entitled list if it is a managed purchase.\n\t///\n\t/// @param The result.\n\t/// @param The sku.\n\t/// @param The item type.\n\t/// @param The request id.\n\t/// @param The purchase token.\n\t/// @param Whether or not to send this event if the\n\t/// purchase has already been entitled.\n\t//-----------------------------------------------------\n\tprivate void ProcessPurchase(int indwResult, final String instrSKU, final ItemType ineItemType, final String instrRequestId, final String instrPurchaseToken, boolean inbEvenIfEntitled)\n\t{\n\t\tif (indwResult == PurchaseTransaction.kdwPurchaseSuccessful || indwResult == PurchaseTransaction.kdwPurchaseRestored)\n\t\t{\n\t\t\t//get the product type.\n\t\t\tProductType eProductType = ProductType.NONE;\n\t\t\tswitch (ineItemType)\n\t\t\t{\n\t\t\t\tcase CONSUMABLE:\n\t\t\t\t\teProductType = ProductType.CONSUMABLE;\n\t\t\t\t\tbreak;\n\t\t\t\tcase ENTITLED:\n\t\t\t\t\teProductType = ProductType.ENTITLEMENT;\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tLogging.logError(\"Amazon IAP System: Cannot process purchase, item type is unknown.\");\n\t\t\t\t\treturn;\n\t\t\t}\n\t         \n\t\t\t//get the purchase receipt\n\t\t\tString strReceipt = BuildPurchaseReceipt(mstrUserID, instrPurchaseToken);\n\n\t\t\tif (eProductType == ProductType.ENTITLEMENT)\n\t\t\t{\n\t\t\t\tif (inbEvenIfEntitled == false && mDataStore.IsEntitled(instrSKU) == true)\n\t\t\t\t{\n\t\t\t\t\t//Already entitled, so don't bother sending again.\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tmDataStore.AddEntitledSKU(instrSKU);\n\t\t\t}\n\t\t\t\n\t\t\tPurchaseTransaction transaction = new PurchaseTransaction(indwResult, instrSKU, eProductType, instrRequestId, strReceipt);\n\t     \tmDataStore.AddPendingPurchaseTransaction(transaction);\n\t     \t\n\t     \tif (mbListeningForPurchaseTransactions == true)\n\t     \t{\n\t     \t\tNativeOnTransactionStatusUpdated(transaction.GetResult(), transaction.GetSKU(), transaction.GetTransactionID(), transaction.GetPurchaseReceipt());\n\t     \t}\n\t\t}\n\t\telse if (indwResult == PurchaseTransaction.kdwPurchaseFailed && mbListeningForPurchaseTransactions == true)\n\t\t{\n\t     \tNativeOnTransactionStatusUpdated(indwResult, instrSKU, \"\", \"\");\n\t\t}\n\t}\n\t//-----------------------------------------------------\n\t/// Process Purchase For User\n\t///\n\t/// Processes a single purchase transaction for a user\n\t/// that is not currently logged in. This will store the\n\t/// information in the user specfic data store for\n\t/// resuming later.\n\t///\n\t/// This should never be called for the user that is\n\t/// currently logged in or the data store will become\n\t/// out of sync.\n\t///\n\t/// @param The \n\t//-----------------------------------------------------\n\tprivate void ProcessPurchaseForUser(final String instrUserID, int indwResult, final String instrSKU, final ItemType ineItemType, final String instrRequestId, final String instrPurchaseToken)\n\t{\n\t\tif (indwResult == PurchaseTransaction.kdwPurchaseSuccessful || indwResult == PurchaseTransaction.kdwPurchaseRestored)\n\t\t{\n\t\t\t//get the product type.\n\t\t\tProductType eProductType = ProductType.NONE;\n\t\t\tswitch (ineItemType)\n\t\t\t{\n\t\t\t\tcase CONSUMABLE:\n\t\t\t\t\teProductType = ProductType.CONSUMABLE;\n\t\t\t\t\tbreak;\n\t\t\t\tcase ENTITLED:\n\t\t\t\t\teProductType = ProductType.ENTITLEMENT;\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tLogging.logError(\"Amazon IAP System: Cannot process purchase, item type is unknown.\");\n\t\t\t\t\treturn;\n\t\t\t}\n\t\t\t\n\t\t\tString strUserIDHash = \"\" + Math.abs(HashCRC32.Generate(StringUtils.stringToUTF8Bytes(instrUserID)));\n\t\t\tDataStore dataStore = new DataStore(kstrCacheNamePrefix + strUserIDHash + kstrCacheExtension, mstrPrivateKey, mstrUDID, instrUserID);\n\t         \n\t\t\t//get the purchase receipt\n\t\t\tString strReceipt = BuildPurchaseReceipt(instrUserID, instrPurchaseToken);\n\n\t\t\tif (eProductType == ProductType.ENTITLEMENT)\n\t\t\t{\n\t\t\t\tif (dataStore.IsEntitled(instrSKU) == true)\n\t\t\t\t{\n\t\t\t\t\t//Already entitled, so don't bother sending again.\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tdataStore.AddEntitledSKU(instrSKU);\n\t\t\t}\n\t\t\t\n\t\t\tPurchaseTransaction transaction = new PurchaseTransaction(indwResult, instrSKU, eProductType, instrRequestId, strReceipt);\n\t\t\tdataStore.AddPendingPurchaseTransaction(transaction);\n\t\t}\n\t}\n\t//-----------------------------------------------------\n\t/// Native On Products Descriptions Request Complete\n\t///\n\t/// Calls down to native with information on each\n\t/// product as requested.\n\t///\n\t/// @param The array of product IDs.\n\t/// @param The array of product names.\n\t/// @param The array of product descriptions.\n\t/// @param The array of formatted prices.\n\t//-----------------------------------------------------\n\tprivate native void NativeOnProductsDescriptionsRequestComplete(final String[] inastrIDs, final String[] inastrNames, final String[] inastrDescriptions, final String[] inastrFormattedPrices);\n\t//-----------------------------------------------------\n\t/// Native On Transaction Status Updated\n\t///\n\t/// Calls down to native to update the status of a\n\t/// purchase transaction.\n\t///\n\t/// @param The transaction result. This possible values\n\t/// for this are defined as contants in CPurchaseTransaction\n\t/// @param The product ID.\n\t/// @param The transaction ID.\n\t/// @param The receipt.\n\t//-----------------------------------------------------\n\tprivate native void NativeOnTransactionStatusUpdated(int indwResult, final String instrProductID, final String instrTransactionID, final String instrReceipt);\n\t//-----------------------------------------------------\n\t/// Native On Transaction Closed\n\t///\n\t/// Calls down to native to confirm that the transaction\n\t/// was successfully closed.\n\t///\n\t/// @param The product ID.\n\t/// @param The transaction ID.\n\t//-----------------------------------------------------\n\tprivate native void NativeOnTransactionClosed(final String instrProductID, final String instrTransactionID);\n}\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Amazon/Java/com/chilliworks/chillisource/networking/DataStore.java",
    "content": "/**\n * DataStore.java\n * ChilliSource\n * Created by Ian Copland on 16/12/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.networking;\n\nimport java.util.HashSet;\nimport java.util.Iterator;\nimport java.util.LinkedList;\nimport java.util.Set;\n\nimport org.json.JSONArray;\nimport org.json.JSONObject;\n\nimport com.amazon.inapp.purchasing.Offset;\nimport com.chilliworks.chillisource.core.CSApplication;\nimport com.chilliworks.chillisource.core.InternalFileUtils;\nimport com.chilliworks.chillisource.networking.PurchaseTransaction.ProductType;\nimport com.chilliworks.chillisource.core.AESEncryption;\nimport com.chilliworks.chillisource.core.ExceptionUtils;\nimport com.chilliworks.chillisource.core.FileUtils;\nimport com.chilliworks.chillisource.core.HashSHA256;\nimport com.chilliworks.chillisource.core.Logging;\nimport com.chilliworks.chillisource.core.StringUtils;\n\n//====================================================\n/// Data Store\n///\n/// Contains persistent data for the amazon IAP system.\n/// This includes information on pending purchases,\n/// current entitlements and the current position update\n/// offset. This data is stored as encrypted JSON in\n/// application specfic internal storage.\n//====================================================\npublic class DataStore \n{\n\t//---------------------------------------------\n\t/// Constants\n\t//---------------------------------------------\n\tprivate final String kstrPurchaseUpdateOffsetKey = \"PurchaseUpdateOffset\";\n\tprivate final String kstrEntitledSKUsArrayKey = \"EntitledSKUs\";\n\tprivate final String kstrPendingPurchaseTransactionsArrayKey = \"PendingPuchaseTransactions\";\n\tprivate final String kstrResultKey = \"Result\";\n\tprivate final String kstrSKUKey = \"SKU\";\n\tprivate final String kstrProductTypeID = \"ProductType\";\n\tprivate final String kstrTransactionIDKey = \"TransactionID\";\n\tprivate final String kstrPurchaseTokenID = \"PurchaseToken\";\n\t//---------------------------------------------\n\t/// Member Data\n\t//---------------------------------------------\n\tprivate final String mstrCacheFilename;\n\tprivate String mstrPrivateKey = \"\";\n\tprivate String mstrUDID = \"\";\n\tprivate String mstrUserID = \"\";\n\tprivate Offset mPurchaseUpdateOffset = Offset.BEGINNING;\n\tprivate Set<String> mastrEntitledSKUs = new HashSet<String>();\n\tprivate LinkedList<PurchaseTransaction> maPendingPurchaseTransactions = new LinkedList<PurchaseTransaction>();\n\t//---------------------------------------------\n\t/// Constructor\n\t///\n\t/// @param The filename for the data store.\n\t/// @param The private key used for encrypting\n\t/// the data store.\n\t/// @param The device UDID. This is used as a\n\t/// salt in encryption.\n\t/// @param The amazon user ID. This is used as\n\t/// a salt in the encryption.\n\t//---------------------------------------------\n\tpublic DataStore(final String instrFilename, final String instrPrivateKey, final String instrUDID, final String instrUserID)\n\t{\n\t\tmstrCacheFilename = instrFilename;\n\t\tmstrPrivateKey = instrPrivateKey;\n\t\tmstrUDID = instrUDID;\n\t\tmstrUserID = instrUserID;\n\t\tReadCache();\n\t}\n\t//---------------------------------------------\n\t/// Get Purchase Update Offset\n\t///\n\t/// @return The current purchase update offset.\n\t//---------------------------------------------\n\tpublic final Offset GetPurchaseUpdateOffset()\n\t{\n\t\treturn mPurchaseUpdateOffset;\n\t}\n\t//---------------------------------------------\n\t/// Set Purchase Update Offset\n\t///\n\t/// @return The current purchase update offset.\n\t//---------------------------------------------\n\tpublic final void SetPurchaseUpdateOffset(final Offset inOffset)\n\t{\n\t\tmPurchaseUpdateOffset = inOffset;\n\t\tWriteCache();\n\t}\n\t//---------------------------------------------\n\t/// Add Entitled SKU\n\t///\n\t/// Adds a new SKU to the entitled list if it\n\t/// is not already there.\n\t///\n\t/// @param The SKU to add.\n\t//---------------------------------------------\n\tpublic void AddEntitledSKU(final String instrSKU)\n\t{\n\t\tif (mastrEntitledSKUs.contains(instrSKU) == false)\n\t\t{\n\t\t\tmastrEntitledSKUs.add(instrSKU);\n\t\t\tWriteCache();\n\t\t}\n\t}\n\t//---------------------------------------------\n\t/// Is Entitled\n\t///\n\t/// @return whether or not the given SKU is\n\t/// in the entitlement cache.\n\t//---------------------------------------------\n\tpublic boolean IsEntitled(final String instrSKU)\n\t{\n\t\treturn mastrEntitledSKUs.contains(instrSKU);\n\t}\n\t//---------------------------------------------\n\t/// Remove Entitled SKU\n\t///\n\t/// Removes the given SKU from the entitled list.\n\t///\n\t/// @param This returns true if the SKU was stored\n\t/// and has now been removed.\n\t//---------------------------------------------\n\tpublic boolean RemoveEntitledSKU(final String instrSKU)\n\t{\n\t\tif (mastrEntitledSKUs.contains(instrSKU) == false)\n\t\t{\n\t\t\tmastrEntitledSKUs.remove(instrSKU);\n\t\t\tWriteCache();\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\t//---------------------------------------------\n\t/// Clear Entitled SKUs\n\t///\n\t/// Removes all entitled SKUs from the data\n\t/// store.\n\t//---------------------------------------------\n\tpublic void ClearEntitledSKUs()\n\t{\n\t\tmastrEntitledSKUs.clear();\n\t\tWriteCache();\n\t}\n\t//---------------------------------------------\n\t/// Add Pending Purchase Transaction\n\t///\n\t/// Adds a new pending transaction to the data\n\t/// store.\n\t///\n\t/// @param The purchase transaction.\n\t//---------------------------------------------\n\tpublic void AddPendingPurchaseTransaction(PurchaseTransaction inPurchaseTransaction)\n\t{\n\t\tmaPendingPurchaseTransactions.add(inPurchaseTransaction);\n\t\tWriteCache();\n\t}\n\t//---------------------------------------------\n\t/// Get Pending Purchase Transactions\n\t///\n\t/// @return The pending purchase transaction \n\t/// list.\n\t//---------------------------------------------\n\tpublic final LinkedList<PurchaseTransaction> GetPendingPurchaseTransactions()\n\t{\n\t\treturn maPendingPurchaseTransactions;\n\t}\n\t//---------------------------------------------\n\t/// Remove Pending Purchase Transaction\n\t///\n\t/// Removes the purchase transaction with the\n\t/// given transaction ID and SKU from the cache.\n\t///\n\t/// @param The SKU.\n\t/// @param The transaction ID.\n\t/// @return Whether or not the transaction was\n\t/// successfully removed from the cache.\n\t//---------------------------------------------\n\tpublic boolean RemovePendingPurchaseTransaction(final String instrSKU, final String instrTransactionID)\n\t{\n\t\tboolean bSuccess = false;\n\t\tIterator<PurchaseTransaction> it = maPendingPurchaseTransactions.iterator();\n\t\twhile (it.hasNext())\n\t\t{\n\t\t\tPurchaseTransaction transaction = it.next();\n\t\t\tif (transaction.GetSKU().equals(instrSKU) == true && transaction.GetTransactionID().equals(instrTransactionID) == true)\n\t\t\t{\n\t\t\t\tit.remove();\n\t\t\t\tbSuccess = true;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\t\n\t\tif (bSuccess == true)\n\t\t{\n\t\t\tWriteCache();\n\t\t}\n\t\t\n\t\treturn bSuccess;\n\t}\n\t//---------------------------------------------\n\t/// Read Cache\n\t///\n\t/// Parses the contents of the cache file into\n\t/// a list of purchase transactions. The cache\n\t/// file is stored as encrypted JSON. \n\t//---------------------------------------------\n\tprivate void ReadCache()\n\t{\n\t\tmaPendingPurchaseTransactions.clear();\n\t\tmastrEntitledSKUs.clear();\n\t\t\n\t\ttry\n\t\t{\n\t\t\tbyte[] abyEncryptedJson = InternalFileUtils.readBinaryFile(CSApplication.get().getAppContext(), mstrCacheFilename);\n\t\t\tif (abyEncryptedJson != null && abyEncryptedJson.length > 0)\n\t\t\t{\n\t\t\t\tbyte[] abyJson = AESEncryption.Decrypt(abyEncryptedJson, CalculateSaltedPrivateKey());\n\t\t\t\tif (abyJson != null)\n\t\t\t\t{\n\t\t\t\t\tString strJson = StringUtils.utf8BytesToString(abyJson);\n\t\t\t\t\tJSONObject root = new JSONObject(strJson);\n\t\t\t\t\t\n\t\t\t\t\t//read the purchase update offset\n\t\t\t\t\tString strOffset = root.getString(kstrPurchaseUpdateOffsetKey);\n\t\t\t\t\tmPurchaseUpdateOffset = Offset.fromString(strOffset);\n\t\t\t\t\t\n\t\t\t\t\t//read the entitled SKUs\n\t\t\t\t\tJSONArray entitlementArray = root.getJSONArray(kstrEntitledSKUsArrayKey);\n\t\t\t\t\tfor (int i = 0; i < entitlementArray.length(); i++)\n\t\t\t\t\t{\n\t\t\t\t\t\tJSONObject entitlementObject = entitlementArray.getJSONObject(i);\n\t\t\t\t\t\tString strSKU = entitlementObject.getString(kstrSKUKey);\n\t\t\t\t\t\tmastrEntitledSKUs.add(strSKU);\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\t//read the pending purchases\n\t\t\t\t\tJSONArray transactionArray = root.getJSONArray(kstrPendingPurchaseTransactionsArrayKey);\n\t\t\t\t\tfor(int i = 0; i < transactionArray.length(); i++)\n\t\t\t\t\t{\n\t\t\t\t\t\tJSONObject transactionObject = transactionArray.getJSONObject(i);\n\t\t\t\t\t\tint dwResult = transactionObject.getInt(kstrResultKey);\n\t\t\t\t\t\tString strSKU = transactionObject.getString(kstrSKUKey);\n\t\t\t\t\t\tProductType eProductType = ProductType.valueOf(transactionObject.getString(kstrProductTypeID));\n\t\t\t\t\t\tString strTransactionID = transactionObject.getString(kstrTransactionIDKey);\n\t\t\t\t\t\tString strPurchaseToken = transactionObject.getString(kstrPurchaseTokenID);\n\t\t\t\t\t\tPurchaseTransaction transaction = new PurchaseTransaction(dwResult, strSKU, eProductType, strTransactionID, strPurchaseToken);\n\t\t\t\t\t\tmaPendingPurchaseTransactions.add(transaction);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tcatch (Exception e)\n\t\t{\n\t\t\tExceptionUtils.convertToString(e);\n\t\t}\n\t}\n\t//---------------------------------------------\n\t/// Write Cache\n\t///\n\t/// Writes the list of purchase transactions to\n\t/// the cache file. This file is stored as \n\t/// encrypted JSON.\n\t//---------------------------------------------\n\tprivate void WriteCache()\n\t{\n\t\ttry\n\t\t{\n\t\t\t//add the purchase update offset\n\t\t\tJSONObject root = new JSONObject();\n\t\t\troot.put(kstrPurchaseUpdateOffsetKey, mPurchaseUpdateOffset.toString());\n\t\t\t\n\t\t\t//add entitlement array\n\t\t\tJSONArray entitlementArray = new JSONArray();\n\t\t\tfor (String strSKU : mastrEntitledSKUs)\n\t\t\t{\n\t\t\t\tJSONObject entitlementObject = new JSONObject();\n\t\t\t\tentitlementObject.put(kstrSKUKey, strSKU);\n\t\t\t\tentitlementArray.put(entitlementObject);\n\t\t\t}\n\t\t\troot.put(kstrEntitledSKUsArrayKey, entitlementArray);\n\t\t\t\n\t\t\t//add transaction array\n\t\t\tJSONArray transactionArray = new JSONArray();\n\t\t\tfor (PurchaseTransaction transaction : maPendingPurchaseTransactions)\n\t\t\t{\n\t\t\t\tJSONObject transactionObject = new JSONObject();\n\t\t\t\ttransactionObject.put(kstrResultKey, transaction.GetResult());\n\t\t\t\ttransactionObject.put(kstrSKUKey, transaction.GetSKU());\n\t\t\t\ttransactionObject.put(kstrProductTypeID, transaction.GetProductType().name());\n\t\t\t\ttransactionObject.put(kstrTransactionIDKey, transaction.GetTransactionID());\n\t\t\t\ttransactionObject.put(kstrPurchaseTokenID, transaction.GetPurchaseReceipt());\n\t\t\t\ttransactionArray.put(transactionObject);\n\t\t\t}\n\t\t\troot.put(kstrPendingPurchaseTransactionsArrayKey, transactionArray);\n\t\t\t\n\t\t\tString strJson = root.toString();\n\t\t\tbyte[] abyEncryptedJson = AESEncryption.Encrypt(StringUtils.stringToUTF8Bytes(strJson), CalculateSaltedPrivateKey());\n\t\t\tif (abyEncryptedJson != null)\n\t\t\t{\n\n\t\t\t\tInternalFileUtils.writeBinaryFile(CSApplication.get().getAppContext(), mstrCacheFilename, abyEncryptedJson);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tLogging.logError(\"Purchase Transaction Cache: Failed to write encrpyted cache.\");\n\t\t\t}\n\t\t}\n\t\tcatch (Exception e)\n\t\t{\n\t\t\tExceptionUtils.convertToString(e);\n\t\t}\n\t}\n\t//---------------------------------------------\n\t/// Calculate Salted Private Key\n\t///\n\t/// Uses the private key,\n\t///\n\t/// @param The cache filename.\n\t/// @param The list of purchase transactions.\n\t//---------------------------------------------\n\tprivate byte[] CalculateSaltedPrivateKey()\n\t{\n\t\tbyte[] abySaltedPrivateKey = HashSHA256.Generate(StringUtils.stringToUTF8Bytes(mstrPrivateKey + mstrUDID + mstrUserID));\n\t\treturn abySaltedPrivateKey;\n\t}\n}\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Amazon/Java/com/chilliworks/chillisource/networking/PurchaseTransaction.java",
    "content": "/**\n * PurchaseTransaction.java\n * ChilliSource\n * Created by Ian Copland on 07/01/2014.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2014 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.networking;\n\n//============================================================\n/// Purchase Transaction\n///\n/// A container for data about a single purchase transaction.\n//============================================================\npublic class PurchaseTransaction \n{\n\t//---------------------------------------------------\n\t/// Product Type\n\t//---------------------------------------------------\n\tpublic enum ProductType\n\t{\n\t\tNONE,\n\t\tCONSUMABLE,\n\t\tENTITLEMENT\n\t}\n\t//---------------------------------------------------\n\t/// Constants\n\t//---------------------------------------------------\n\tpublic final static int kdwPurchaseSuccessful = 0;\n\tpublic final static int kdwPurchaseResumed = 1;\n\tpublic final static int kdwPurchaseRestored = 2;\n\tpublic final static int kdwPurchaseFailed = 3;\n\t//---------------------------------------------------\n\t/// Member Data\n\t//---------------------------------------------------\n\tprivate final int mdwResult;\n\tprivate final ProductType meProductType;\n\tprivate final String mstrSKU;\n\tprivate final String mstrTransactionID;\n\tprivate final String mstrPurchaseReceipt;\n\t//---------------------------------------------------\n\t/// Constructor\n\t///\n\t/// @param The result.\n\t/// @param The request ID.\n\t/// @param The purchase token.\n\t//---------------------------------------------------\n\tpublic PurchaseTransaction(int indwResult, final String instrSKU, final ProductType ineProductType, final String instrTransactionID, final String instrPurchaseReceipt)\n\t{\n\t\tmdwResult = indwResult;\n\t\tmstrSKU = instrSKU;\n\t\tmeProductType = ineProductType;\n\t\tmstrTransactionID = instrTransactionID;\n\t\tmstrPurchaseReceipt = instrPurchaseReceipt;\n\t}\n\t//---------------------------------------------------\n\t/// Get Result\n\t///\n\t/// @return An integer value representing the result\n\t/// of the purchase transaction. The possible values\n\t/// are defined as constants in this class.\n\t//---------------------------------------------------\n\tpublic int GetResult()\n\t{\n\t\treturn mdwResult;\n\t}\n\t//---------------------------------------------------\n\t/// Get SKU\n\t///\n\t/// @return The ID of the SKU this transaction was\n\t/// for.\n\t//---------------------------------------------------\n\tpublic final String GetSKU()\n\t{\n\t\treturn mstrSKU;\n\t}\n\t//---------------------------------------------------\n\t/// Get Product Type\n\t///\n\t/// @return The product type.\n\t//---------------------------------------------------\n\tpublic final ProductType GetProductType()\n\t{\n\t\treturn meProductType;\n\t}\n\t//---------------------------------------------------\n\t/// Get Transaction ID\n\t///\n\t/// @return The ID of the request.\n\t//---------------------------------------------------\n\tpublic final String GetTransactionID()\n\t{\n\t\treturn mstrTransactionID;\n\t}\n\t//---------------------------------------------------\n\t/// Get Purchase Receipt\n\t///\n\t/// @return The purchase reciept. This contains the\n\t/// user ID and the purchase token.\n\t//---------------------------------------------------\n\tpublic final String GetPurchaseReceipt()\n\t{\n\t\treturn mstrPurchaseReceipt;\n\t}\n}\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Amazon/Java/com/chilliworks/chillisource/networking/PurchasingObserver.java",
    "content": "/**\n * PurchasingObserver.java\n * ChilliSource\n * Created by Ian Copland on 10/12/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.networking;\n\nimport android.content.Context;\n\nimport com.amazon.inapp.purchasing.BasePurchasingObserver;\nimport com.amazon.inapp.purchasing.GetUserIdResponse;\nimport com.amazon.inapp.purchasing.ItemDataResponse;\nimport com.amazon.inapp.purchasing.PurchaseResponse;\nimport com.amazon.inapp.purchasing.PurchaseUpdatesResponse;\n\n//====================================================\n/// Purchasing Observer\n///\n/// An observer for receiving purchase events from the\n/// Amazon IAP system.\n//====================================================\npublic class PurchasingObserver extends BasePurchasingObserver\n{\n\t//----------------------------------------------\n\t/// Member data\n\t//----------------------------------------------\n\tAmazonIAPNativeInterface mAmazonNI = null;\n\t//----------------------------------------------\n\t/// Constructor\n\t///\n\t/// @param The context.\n\t/// @param The Amazon IAP native interface.\n\t//----------------------------------------------\n\tpublic PurchasingObserver(Context inContext, AmazonIAPNativeInterface inAmazonNI) \n\t{\n\t\tsuper(inContext);\n\t\tmAmazonNI = inAmazonNI;\n\t}\n\t//----------------------------------------------\n\t/// On Sdk Available\n\t///\n\t/// This is called when the observer is registered.\n\t/// It provides information on whether the \n\t/// application is in sandbox mode or not. This\n\t/// passes the event on to the Amazon IAP Native\n\t/// Interface.\n\t///\n\t/// @param Whether or not this application is\n\t/// in sandbox mode.\n\t//----------------------------------------------\n\t@Override public void onSdkAvailable(final boolean inbIsSandboxMode)\n\t{\n\t\tif (mAmazonNI != null)\n\t\t{\n\t\t\tmAmazonNI.OnSDKAvailable(inbIsSandboxMode);\n\t\t}\n\t}\n\t//----------------------------------------------\n\t/// On Get User ID Response\n\t///\n\t/// Called in response to a request for the users\n\t/// amazon store id. This passes the response\n\t/// on to the Amazon IAP Native Interface.\n\t/// \n\t/// @param The response.\n\t//----------------------------------------------\n\t@Override public void onGetUserIdResponse(final GetUserIdResponse inResponse) \n\t{\n\t\tif (mAmazonNI != null)\n\t\t{\n\t\t\tmAmazonNI.OnGetUserIdResponse(inResponse);\n\t\t}\n\t}\n\t//----------------------------------------------\n\t/// On Item Data Response\n\t///\n\t/// Called in response to a request for item\n\t/// data. This passes the response on to the Amazon \n\t/// IAP Native Interface.\n\t/// \n\t/// @param The response.\n\t//----------------------------------------------\n\t@Override public void onItemDataResponse(final ItemDataResponse inResponse) \n\t{\n\t\tif (mAmazonNI != null)\n\t\t{\n\t\t\tmAmazonNI.OnItemDataResponse(inResponse);\n\t\t}\n\t}\n\t//----------------------------------------------\n\t/// On Purchase Response\n\t///\n\t/// Called in response to a purchase request. \n\t/// This passes the response on to the Amazon IAP \n\t/// Native Interface.\n\t/// \n\t/// @param The response.\n\t//----------------------------------------------\n\t@Override public void onPurchaseResponse(final PurchaseResponse inResponse) \n\t{\n\t\tif (mAmazonNI != null)\n\t\t{\n\t\t\tmAmazonNI.OnPurchaseResponse(inResponse);\n\t\t}\n\t}\n\t//----------------------------------------------\n\t/// On Purchase Update Response\n\t///\n\t/// Called in response to a request for an update\n\t/// on purchases. This passes the response on to \n\t/// the Amazon IAP Native Interface.\n\t/// \n\t/// @param The response.\n\t//----------------------------------------------\n\t@Override public void onPurchaseUpdatesResponse(final PurchaseUpdatesResponse inResponse) \n\t{\n\t\tif (mAmazonNI != null)\n\t\t{\n\t\t\tmAmazonNI.OnPurchaseUpdatesResponse(inResponse);\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/GooglePlay/JNI/Core/Base/GooglePlayLicense.cpp",
    "content": "//\n//  GooglePlayLicense.cpp\n//  ChilliSource\n//  Created by Ian Copland on 27/05/2015.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2015 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n\n#ifdef CS_ANDROIDFLAVOUR_GOOGLEPLAY\n\n#include <ChilliSource/ChilliSource.h>\n\n#include <jni.h>\n\n//------------------------------------------------------------------------------\n/// Returns the Google Play Lvl Public Key. This must return an identical value\n/// every time it is called.\n///\n/// This may be called on any thread.\n///\n/// @author Ian Copland\n///\n/// @return The LVL public Key.\n//------------------------------------------------------------------------------\nextern std::string GetGooglePlayLvlPublicKey();\n\nextern \"C\"\n{\n    //------------------------------------------------------------------------------\n    /// A method called from java which will return the user supplied Google Play\n    /// LVL Public Key. This key is required by the various google play systems\n    /// which need to verify the the application was downloaded from the google\n    /// play store.\n    ///\n    /// @author Ian Copland\n    ///\n    /// @param in_environment - The JNI Environment.\n    /// @param in_this - The java object that called the method.\n    //------------------------------------------------------------------------------\n\tjstring Java_com_chilliworks_chillisource_core_GooglePlayLicensing_calcLvlPublicKey(JNIEnv* in_environment, jobject in_this);\n}\n\n//------------------------------------------------------------------------------\n//------------------------------------------------------------------------------\njstring Java_com_chilliworks_chillisource_core_GooglePlayLicensing_calcLvlPublicKey(JNIEnv* in_environment, jobject in_this)\n{\n    auto publicKey = GetGooglePlayLvlPublicKey();\n\n    //Convert to jstring directly using the environment rather than JavaUtils as JavaVirtualMachine, which JavaUtils relies on, may\n    //not be initialised at the point when this is called.\n    return in_environment->NewStringUTF(publicKey.c_str());\n}\n\n#endif\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/GooglePlay/JNI/ForwardDeclarations.h",
    "content": "//\n//  ForwardDeclarations.h\n//  ChilliSource\n//  Created by Ian Copland on 09/08/2012.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2012 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n\n#ifdef CS_ANDROIDFLAVOUR_GOOGLEPLAY\n\n#ifndef _CSBACKEND_PLATFORM_ANDROID_GOOGLEPLAY_JNI_FORWARDDECLARATIONS_H_\n#define _CSBACKEND_PLATFORM_ANDROID_GOOGLEPLAY_JNI_FORWARDDECLARATIONS_H_\n\n#include <ChilliSource/Core/Base/StandardMacros.h>\n\n#include <memory>\n\nnamespace CSBackend\n{\n\tnamespace Android\n\t{\n        //------------------------------------------------------------------------------\n        /// Networking\n        //------------------------------------------------------------------------------\n\t\tCS_FORWARDDECLARE_CLASS(GooglePlayIAPJavaInterface);\n\t\tCS_FORWARDDECLARE_CLASS(GooglePlayIAPSystem);\n\t}\n}\n\n#endif\n\n#endif\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/GooglePlay/JNI/Networking/IAP/GooglePlayIAPJavaInterface.cpp",
    "content": "//\n//  GooglePlayIAPJavaInterface.cpp\n//  ChilliSource\n//  Created by Scott Downie on 14/06/2013.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2013 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n\n#ifdef CS_ANDROIDFLAVOUR_GOOGLEPLAY\n\n#include <CSBackend/Platform/Android/GooglePlay/JNI/Networking/IAP/GooglePlayIAPJavaInterface.h>\n\n#include <CSBackend/Platform/Android/Main/JNI/ForwardDeclarations.h>\n#include <CSBackend/Platform/Android/Main/JNI/Core/Java/JavaInterfaceManager.h>\n#include <CSBackend/Platform/Android/Main/JNI/Core/Java/JavaUtils.h>\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/Base/Utils.h>\n#include <ChilliSource/Core/File/FileSystem.h>\n#include <ChilliSource/Core/Json/JsonUtils.h>\n#include <ChilliSource/Core/Threading/TaskScheduler.h>\n\n#include <json/json.h>\n\n#include <jni.h>\n\nextern \"C\"\n{\n\t//--------------------------------------------------------------------------------------\n\t/// Called by Java when the product descriptions have been fetched\n\t///\n\t/// @author S Downie\n\t///\n\t/// @param in_env - JNI environment\n\t/// @param in_this - Pointer to the calling function\n\t/// @param in_productIds - Array of product IDs\n\t/// @param in_names - Array of product Names\n\t/// @param in_descs - Array of product Descriptions\n\t/// @param in_prices - Array of product Prices\n\t/// @param in_currencyCodes - Array of currency codes\n\t/// @param in_unformattedPrices - Array of unformatted prices\n\t//--------------------------------------------------------------------------------------\n\tvoid Java_com_chilliworks_chillisource_networking_GooglePlayIAPNativeInterface_NativeOnProductsDescriptionsRequestComplete(JNIEnv* in_env, jobject in_this, jobjectArray in_productIds, jobjectArray in_names, jobjectArray in_descs, jobjectArray in_prices, jobjectArray in_currencyCodes, jobjectArray in_unformattedPrices);\n\t//--------------------------------------------------------------------------------------\n\t/// Called by Java when the transaction status updates\n\t///\n\t/// @author S Downie\n\t///\n\t/// @param in_env - JNI environment\n\t/// @param in_this - Pointer to the calling function\n\t/// @param in_result - Result (SUCCESS - 0, FAILED - 1)\n\t/// @param in_productId - Product ID\n\t/// @param in_transactionId - Transaction ID\n\t/// @param in_receipt - Receipt\n\t//--------------------------------------------------------------------------------------\n\tvoid Java_com_chilliworks_chillisource_networking_GooglePlayIAPNativeInterface_NativeOnTransactionStatusUpdated(JNIEnv* in_env, jobject in_this, jint in_result, jstring in_productId, jstring in_transactionId, jstring in_receipt);\n\t//--------------------------------------------------------------------------------------\n\t/// Called by Java when the transaction close result returns\n\t///\n\t/// @param in_env - JNI environment\n\t/// @param in_this - Pointer to the calling function\n\t/// @param in_productId - Product ID\n\t/// @param in_transactionId - Transaction ID\n\t/// @param in_success - Success or failure\n\t//--------------------------------------------------------------------------------------\n\tvoid Java_com_chilliworks_chillisource_networking_GooglePlayIAPNativeInterface_NativeOnTransactionClosed(JNIEnv* in_env, jobject in_this, jstring in_productId, jstring in_transactionId, jboolean in_success);\n}\n\n//--------------------------------------------------------------------------------------\n//--------------------------------------------------------------------------------------\nvoid Java_com_chilliworks_chillisource_networking_GooglePlayIAPNativeInterface_NativeOnProductsDescriptionsRequestComplete(JNIEnv* in_env, jobject in_this, jobjectArray in_productIds, jobjectArray in_names, jobjectArray in_descs, jobjectArray in_prices, jobjectArray in_currencyCodes, jobjectArray in_unformattedPrices)\n{\n\tCSBackend::Android::GooglePlayIAPJavaInterfaceSPtr javaInterface = CSBackend::Android::JavaInterfaceManager::GetSingletonPtr()->GetJavaInterface<CSBackend::Android::GooglePlayIAPJavaInterface>();\n\tif (javaInterface != nullptr)\n\t{\n\t\tu32 numProducts = in_env->GetArrayLength(in_productIds);\n\t\tstd::vector<ChilliSource::IAPSystem::ProductDesc> products;\n\t\tproducts.reserve(numProducts);\n\n        std::vector<std::string> currencyCodes;\n        currencyCodes.reserve(numProducts);\n\n        std::vector<std::string> unformattedPrices;\n        unformattedPrices.reserve(numProducts);\n\n\t\tfor(u32 i=0; i<numProducts; ++i)\n\t\t{\n\t\t\tChilliSource::IAPSystem::ProductDesc desc;\n\n\t\t\tjstring id = static_cast<jstring>(in_env->GetObjectArrayElement(in_productIds, i));\n\t\t\tdesc.m_id = CSBackend::Android::JavaUtils::CreateSTDStringFromJString(id);\n\n\t\t\tjstring name = static_cast<jstring>(in_env->GetObjectArrayElement(in_names, i));\n\t\t\tdesc.m_name = CSBackend::Android::JavaUtils::CreateSTDStringFromJString(name);\n\n\t\t\tjstring description = static_cast<jstring>(in_env->GetObjectArrayElement(in_descs, i));\n\t\t\tdesc.m_description = CSBackend::Android::JavaUtils::CreateSTDStringFromJString(description);\n\n\t\t\tjstring price = static_cast<jstring>(in_env->GetObjectArrayElement(in_prices, i));\n\t\t\tdesc.m_formattedPrice = CSBackend::Android::JavaUtils::CreateSTDStringFromJString(price);\n\n\t\t\tproducts.push_back(desc);\n\n\t\t\t// Populate the extra product information\n\t\t\tstd::string currencyCode = CSBackend::Android::JavaUtils::CreateSTDStringFromJString(static_cast<jstring>(in_env->GetObjectArrayElement(in_currencyCodes, i)));\n\t\t\tcurrencyCodes.push_back(currencyCode);\n\t\t\tstd::string unformattedPrice = CSBackend::Android::JavaUtils::CreateSTDStringFromJString(static_cast<jstring>(in_env->GetObjectArrayElement(in_unformattedPrices, i)));\n\t\t\tunformattedPrices.push_back(unformattedPrice);\n\t\t}\n\n\t\tChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_mainThread, [=](const ChilliSource::TaskContext&)\n\t\t{\n\t\t\tjavaInterface->OnProductDescriptionsRequestComplete(products, currencyCodes, unformattedPrices);\n\t\t});\n\t}\n}\n//--------------------------------------------------------------------------------------\n//--------------------------------------------------------------------------------------\nvoid Java_com_chilliworks_chillisource_networking_GooglePlayIAPNativeInterface_NativeOnTransactionStatusUpdated(JNIEnv* in_env, jobject in_this, jint in_result, jstring in_productId, jstring in_transactionId, jstring in_receipt)\n{\n\tCSBackend::Android::GooglePlayIAPJavaInterfaceSPtr javaInterface = CSBackend::Android::JavaInterfaceManager::GetSingletonPtr()->GetJavaInterface<CSBackend::Android::GooglePlayIAPJavaInterface>();\n\tif (javaInterface != nullptr)\n\t{\n\t\tChilliSource::IAPSystem::Transaction transaction;\n\t\ttransaction.m_productId = CSBackend::Android::JavaUtils::CreateSTDStringFromJString(in_productId);\n\t\ttransaction.m_transactionId = CSBackend::Android::JavaUtils::CreateSTDStringFromJString(in_transactionId);\n\t\ttransaction.m_receipt = CSBackend::Android::JavaUtils::CreateSTDStringFromJString(in_receipt);\n\n\t\tChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_mainThread, [=](const ChilliSource::TaskContext&)\n\t\t{\n\t\t\tjavaInterface->OnTransactionStatusUpdated(in_result, transaction);\n\t\t});\n\t}\n}\n//--------------------------------------------------------------------------------------\n//--------------------------------------------------------------------------------------\nvoid Java_com_chilliworks_chillisource_networking_GooglePlayIAPNativeInterface_NativeOnTransactionClosed(JNIEnv* in_env, jobject in_this, jstring in_productId, jstring in_transactionId, jboolean in_success)\n{\n\tCSBackend::Android::GooglePlayIAPJavaInterfaceSPtr javaInterface = CSBackend::Android::JavaInterfaceManager::GetSingletonPtr()->GetJavaInterface<CSBackend::Android::GooglePlayIAPJavaInterface>();\n\tif (javaInterface != nullptr)\n\t{\n\t\tstd::string productId = CSBackend::Android::JavaUtils::CreateSTDStringFromJString(in_productId);\n\t\tstd::string transactionId = CSBackend::Android::JavaUtils::CreateSTDStringFromJString(in_transactionId);\n\n\t\tChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_mainThread, [=](const ChilliSource::TaskContext&)\n\t\t{\n\t\t\tjavaInterface->OnTransactionClosed(productId, transactionId, in_success);\n\t\t});\n\t}\n}\n\nnamespace CSBackend\n{\n\tnamespace Android\n\t{\n\t\tnamespace\n\t\t{\n\t\t\tconst std::string k_pendingCacheFile(\"GoogleIAPPendingTransactions.json\");\n\n\t\t\t//---------------------------------------------------------------\n\t\t\t/// Adds the given transaction ID to the \"pending transaction\"\n\t\t\t/// cache.\n\t\t\t///\n\t\t\t/// @author S Downie\n\t\t\t///\n\t\t\t/// @param The transaction ID.\n\t\t\t//---------------------------------------------------------------\n\t\t\tvoid AddToPendingCache(const std::string& in_transactionId)\n\t\t\t{\n\t\t\t\tJson::Value jData;\n\t\t\t\tChilliSource::JsonUtils::ReadJson(ChilliSource::StorageLocation::k_cache, k_pendingCacheFile, jData);\n\t\t\t\tjData[in_transactionId] = 0;\n\t\t\t\tChilliSource::Utils::StringToFile(ChilliSource::StorageLocation::k_cache, k_pendingCacheFile, jData.toStyledString());\n\t\t\t}\n\t\t\t//---------------------------------------------------------------\n\t\t\t/// Removes the given transaction ID from the \"pending transaction\"\n\t\t\t/// cache.\n\t\t\t///\n\t\t\t/// @author S Downie\n\t\t\t///\n\t\t\t/// @param The transaction ID.\n\t\t\t//---------------------------------------------------------------\n\t\t\tvoid RemoveFromPendingCache(const std::string& in_transactionId)\n\t\t\t{\n\t\t\t\t//Remove the transaction from the pending cache\n\t\t\t\tJson::Value jData;\n\t\t\t\tif(ChilliSource::JsonUtils::ReadJson(ChilliSource::StorageLocation::k_cache, k_pendingCacheFile, jData))\n\t\t\t\t{\n\t\t\t\t\tjData.removeMember(in_transactionId);\n\t\t\t\t\tChilliSource::Utils::StringToFile(ChilliSource::StorageLocation::k_cache, k_pendingCacheFile, jData.toStyledString());\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tCS_DEFINE_NAMEDTYPE(GooglePlayIAPJavaInterface);\n\n\t\t//--------------------------------------------------------------\n\t\t//--------------------------------------------------------------\n\t\tGooglePlayIAPJavaInterface::GooglePlayIAPJavaInterface()\n\t\t{\n\t\t\tCreateNativeInterface(\"com/chilliworks/chillisource/networking/GooglePlayIAPNativeInterface\");\n\t\t\tCreateMethodReference(\"Init\", \"()V\");\n\t\t\tCreateMethodReference(\"IsPurchasingEnabled\", \"()Z\");\n\t\t\tCreateMethodReference(\"RequestProductDescriptions\", \"([Ljava/lang/String;)V\");\n\t\t\tCreateMethodReference(\"CancelProductDescriptionsRequest\", \"()V\");\n\t\t\tCreateMethodReference(\"RequestProductPurchase\", \"(Ljava/lang/String;I)V\");\n\t\t\tCreateMethodReference(\"CloseTransaction\", \"(Ljava/lang/String;Ljava/lang/String;)V\");\n\t\t\tCreateMethodReference(\"RestoreManagedPurchases\", \"()V\");\n\t\t\tCreateMethodReference(\"RestorePendingUnmanagedTransactions\", \"()V\");\n\t\t\tCreateMethodReference(\"RestorePendingManagedTransactions\", \"([Ljava/lang/String;)V\");\n\n\t\t\t//initialise the system\n\t\t\tJNIEnv* env = JavaInterfaceManager::GetSingletonPtr()->GetJNIEnvironmentPtr();\n\t\t\tenv->CallVoidMethod(GetJavaObject(), GetMethodID(\"Init\"));\n\t\t}\n\t\t//--------------------------------------------------------------\n\t\t//--------------------------------------------------------------\n\t\tbool GooglePlayIAPJavaInterface::IsA(ChilliSource::InterfaceIDType in_interfaceId) const\n\t\t{\n\t\t\treturn (in_interfaceId == GooglePlayIAPJavaInterface::InterfaceID);\n\t\t}\n        //---------------------------------------------------------------\n        //---------------------------------------------------------------\n        bool GooglePlayIAPJavaInterface::IsPurchasingEnabled()\n        {\n\t\t\tJNIEnv* env = JavaInterfaceManager::GetSingletonPtr()->GetJNIEnvironmentPtr();\n\t\t\treturn env->CallBooleanMethod(GetJavaObject(), GetMethodID(\"IsPurchasingEnabled\"));\n        }\n        //---------------------------------------------------------------\n        //---------------------------------------------------------------\n        void GooglePlayIAPJavaInterface::StartListeningForTransactionUpdates(const ChilliSource::IAPSystem::TransactionStatusDelegate& in_delegate)\n        {\n        \tCS_ASSERT(in_delegate != nullptr, \"Cannot have null transaction delegate\");\n\n        \tm_transactionStatusDelegate = in_delegate;\n\n        \tJNIEnv* env = JavaInterfaceManager::GetSingletonPtr()->GetJNIEnvironmentPtr();\n        \tenv->CallVoidMethod(GetJavaObject(), GetMethodID(\"RestorePendingUnmanagedTransactions\"));\n\n        \tJson::Value jData;\n        \tif(ChilliSource::JsonUtils::ReadJson(ChilliSource::StorageLocation::k_cache, k_pendingCacheFile, jData))\n        \t{\n        \t\tconst Json::Value::Members& members = jData.getMemberNames();\n        \t\tjobjectArray transactionIDs = env->NewObjectArray(members.size(), env->FindClass(\"java/lang/String\"), env->NewStringUTF(\"\"));\n\n        \t\tu32 index = 0;\n        \t\tfor(Json::Value::Members::const_iterator it = members.begin(); it != members.end(); ++it, ++index)\n        \t\t{\n    \t\t\t\tjstring jtransactionId = JavaUtils::CreateJStringFromSTDString(*it);\n    \t\t\t\tenv->SetObjectArrayElement(transactionIDs, index, jtransactionId);\n    \t\t\t\tenv->DeleteLocalRef(jtransactionId);\n        \t\t}\n\n            \tenv->CallVoidMethod(GetJavaObject(), GetMethodID(\"RestorePendingManagedTransactions\"), transactionIDs);\n            \tenv->DeleteLocalRef(transactionIDs);\n        \t}\n        }\n        //---------------------------------------------------------------\n        //---------------------------------------------------------------\n        void GooglePlayIAPJavaInterface::StopListeningForTransactionUpdates()\n        {\n        \tm_transactionStatusDelegate = nullptr;\n        }\n        //---------------------------------------------------------------\n        //---------------------------------------------------------------\n        void GooglePlayIAPJavaInterface::RequestProductDescriptions(const std::vector<std::string>& in_productIds, const OnProductDescriptionsRequestCompleteDelegate& in_delegate)\n        {\n            CS_ASSERT(in_productIds.empty() == false, \"Cannot request no product descriptions\");\n            CS_ASSERT(in_delegate != nullptr, \"Cannot have null product description delegate\");\n            CS_ASSERT(m_productsRequestDelegate == nullptr, \"Only 1 product description request can be active at a time\");\n\n        \tm_productsRequestDelegate = in_delegate;\n\n        \tJNIEnv* env = JavaInterfaceManager::GetSingletonPtr()->GetJNIEnvironmentPtr();\n\n\t\t\tjstring jstrEmptyString = env->NewStringUTF(\"\");\n\t\t\tjclass jStringClass = env->FindClass(\"java/lang/String\");\n\n\t\t\tjobjectArray productIDs = env->NewObjectArray(in_productIds.size(), jStringClass, jstrEmptyString);\n\n\t\t\tu32 productIDIndex = 0;\n\t\t\tfor(std::vector<std::string>::const_iterator it = in_productIds.begin(); it != in_productIds.end(); ++it)\n\t\t\t{\n\t\t\t\tjstring jproductId = JavaUtils::CreateJStringFromSTDString(*it);\n\t\t\t\tenv->SetObjectArrayElement(productIDs, productIDIndex, jproductId);\n\t\t\t\tenv->DeleteLocalRef(jproductId);\n\t\t\t\tproductIDIndex++;\n\t\t\t}\n\n\t\t\tenv->CallVoidMethod(GetJavaObject(), GetMethodID(\"RequestProductDescriptions\"), productIDs);\n\n\t\t\tenv->DeleteLocalRef(productIDs);\n\t\t\tenv->DeleteLocalRef(jstrEmptyString);\n\t\t\tenv->DeleteLocalRef(jStringClass);\n        }\n        //---------------------------------------------------------------\n        //---------------------------------------------------------------\n        void GooglePlayIAPJavaInterface::OnProductDescriptionsRequestComplete(const std::vector<ChilliSource::IAPSystem::ProductDesc>& in_products, const std::vector<std::string>& in_currencyCodes, const std::vector<std::string>& in_unformattedPrices)\n        {\n        \tif(m_productsRequestDelegate == nullptr)\n        \t{\n        \t\treturn;\n        \t}\n\n        \tm_productsRequestDelegate(in_products, in_currencyCodes, in_unformattedPrices);\n        \tm_productsRequestDelegate = nullptr;\n        }\n        //---------------------------------------------------------------\n        //---------------------------------------------------------------\n        void GooglePlayIAPJavaInterface::CancelProductDescriptionsRequest()\n        {\n\t\t\tJNIEnv* env = JavaInterfaceManager::GetSingletonPtr()->GetJNIEnvironmentPtr();\n\t\t\tenv->CallVoidMethod(GetJavaObject(), GetMethodID(\"CancelProductDescriptionsRequest\"));\n        }\n        //---------------------------------------------------------------\n        //---------------------------------------------------------------\n        void GooglePlayIAPJavaInterface::RequestProductPurchase(const std::string& in_productId, ChilliSource::IAPSystem::ProductRegInfo::Type in_type)\n        {\n        \tconst u32 k_managedType = 0;\n        \tconst u32 k_unManagedType = 1;\n        \tu32 type = k_unManagedType;\n\n        \tswitch(in_type)\n        \t{\n        \t\tcase ChilliSource::IAPSystem::ProductRegInfo::Type::k_managed:\n        \t\t\ttype = k_managedType;\n        \t\t\tbreak;\n        \t\tcase ChilliSource::IAPSystem::ProductRegInfo::Type::k_unmanaged:\n        \t\t\ttype = k_unManagedType;\n        \t\t\tbreak;\n        \t}\n\n\t\t\tJNIEnv* env = JavaInterfaceManager::GetSingletonPtr()->GetJNIEnvironmentPtr();\n\t\t\tjstring jproductId = JavaUtils::CreateJStringFromSTDString(in_productId);\n\t\t\tenv->CallVoidMethod(GetJavaObject(), GetMethodID(\"RequestProductPurchase\"), jproductId, type);\n\t\t\tenv->DeleteLocalRef(jproductId);\n        }\n        //---------------------------------------------------------------\n        //---------------------------------------------------------------\n        void GooglePlayIAPJavaInterface::OnTransactionStatusUpdated(u32 in_statusId, const ChilliSource::IAPSystem::Transaction& in_transaction)\n        {\n        \tif(m_transactionStatusDelegate == nullptr)\n        \t\treturn;\n\n        \tChilliSource::IAPSystem::Transaction::Status status = ChilliSource::IAPSystem::Transaction::Status::k_failed;\n\n        \t//This requires a little bit of faith. These numbers correspond to the constants defined\n        \t//in the java transaction description\n        \t//    \tpublic final static int SUCCEEDED = 0;\n        \t//    \tpublic final static int FAILED = 1;\n        \t//    \tpublic final static int CANCELLED = 2;\n    \t\t//\t\tpublic final static int RESTORED = 3;\n    \t\t//\t\tpublic final static int RESUMED = 4;\n        \t//\t\tpublic final static int REFUNDED = 5;\n        \tswitch(in_statusId)\n        \t{\n        \t\tcase 0:\n        \t\t\tstatus = ChilliSource::IAPSystem::Transaction::Status::k_succeeded;\n        \t\t\tAddToPendingCache(in_transaction.m_transactionId);\n        \t\t\tbreak;\n        \t\tcase 1:\n        \t\t\tstatus = ChilliSource::IAPSystem::Transaction::Status::k_failed;\n        \t\t\tbreak;\n        \t\tcase 2:\n        \t\t\tstatus = ChilliSource::IAPSystem::Transaction::Status::k_cancelled;\n        \t\t\tbreak;\n        \t\tcase 3:\n        \t\t\tstatus = ChilliSource::IAPSystem::Transaction::Status::k_restored;\n        \t\t\tbreak;\n        \t\tcase 4:\n        \t\t\tstatus = ChilliSource::IAPSystem::Transaction::Status::k_resumed;\n        \t\t\tbreak;\n           \t\tcase 5:\n           \t\t\tstatus = ChilliSource::IAPSystem::Transaction::Status::k_refunded;\n            \t\tbreak;\n        \t}\n\n        \tChilliSource::IAPSystem::TransactionSPtr transaction(new ChilliSource::IAPSystem::Transaction());\n        \ttransaction->m_productId = in_transaction.m_productId;\n        \ttransaction->m_transactionId = in_transaction.m_transactionId;\n        \ttransaction->m_receipt = in_transaction.m_receipt;\n\n        \tm_transactionStatusDelegate(status, transaction);\n        }\n        //---------------------------------------------------------------\n        //---------------------------------------------------------------\n        void GooglePlayIAPJavaInterface::CloseTransaction(const std::string& in_productId, const std::string& in_transactionId, const ChilliSource::IAPSystem::TransactionCloseDelegate& in_delegate)\n        {\n        \tCS_ASSERT(in_delegate != nullptr, \"Cannot have null transaction close delegate\");\n        \tCS_ASSERT(m_transactionCloseDelegate == nullptr, \"Only 1 transaction can be closed at a time\");\n\n        \tm_transactionCloseDelegate = in_delegate;\n\n\t\t\tJNIEnv* env = JavaInterfaceManager::GetSingletonPtr()->GetJNIEnvironmentPtr();\n\t\t\tjstring jproductId = JavaUtils::CreateJStringFromSTDString(in_productId);\n\t\t\tjstring jtransactionId = JavaUtils::CreateJStringFromSTDString(in_transactionId);\n\t\t\tenv->CallVoidMethod(GetJavaObject(), GetMethodID(\"CloseTransaction\"), jproductId, jtransactionId);\n\t\t\tenv->DeleteLocalRef(jproductId);\n\t\t\tenv->DeleteLocalRef(jtransactionId);\n\n\t\t\tRemoveFromPendingCache(in_transactionId);\n        }\n        //---------------------------------------------------------------\n        //---------------------------------------------------------------\n        void GooglePlayIAPJavaInterface::OnTransactionClosed(const std::string& in_productId, const std::string& in_transactionId, bool in_success)\n        {\n        \tif(m_transactionCloseDelegate)\n        \t{\n        \t\tm_transactionCloseDelegate(in_productId, in_transactionId, in_success);\n        \t\tm_transactionCloseDelegate = nullptr;\n        \t}\n        }\n        //---------------------------------------------------------------\n        //---------------------------------------------------------------\n        void GooglePlayIAPJavaInterface::RestoreManagedPurchases()\n        {\n        \tJNIEnv* env = JavaInterfaceManager::GetSingletonPtr()->GetJNIEnvironmentPtr();\n        \tenv->CallVoidMethod(GetJavaObject(), GetMethodID(\"RestoreManagedPurchases\"));\n        }\n\t}\n}\n\n#endif\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/GooglePlay/JNI/Networking/IAP/GooglePlayIAPJavaInterface.h",
    "content": "//\n//  GooglePlayIAPJavaInterface.h\n//  ChilliSource\n//  Created by Scott Downie on 14/06/2013.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2013 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n\n#ifdef CS_ANDROIDFLAVOUR_GOOGLEPLAY\n\n#ifndef _CSBACKEND_PLATFORM_ANDROID_EXTENSIONS_GOOGLEPLAY_NETWORKING_GOOGLEPLAYIAPJAVAINTERFACE_H_\n#define _CSBACKEND_PLATFORM_ANDROID_EXTENSIONS_GOOGLEPLAY_NETWORKING_GOOGLEPLAYIAPJAVAINTERFACE_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Networking/IAP/IAPSystem.h>\n\n#include <CSBackend/Platform/Android/GooglePlay/JNI/ForwardDeclarations.h>\n#include <CSBackend/Platform/Android/Main/JNI/ForwardDeclarations.h>\n#include <CSBackend/Platform/Android/Main/JNI/Core/Java/JavaInterface.h>\n\n\nnamespace CSBackend\n{\n\tnamespace Android\n\t{\n\t\t//--------------------------------------------------------------\n\t\t/// Interface class that allows communication between the\n\t\t/// Google Play IAP system and the Java Google Play billing SDK\n\t\t///\n\t\t/// @author S Downie\n\t\t//--------------------------------------------------------------\n\t\tclass GooglePlayIAPJavaInterface final : public IJavaInterface\n\t\t{\n\t\tpublic:\n\t\t\tCS_DECLARE_NAMEDTYPE(GooglePlayIAPJavaInterface);\n\n            //------------------------------------------------------\n            /// Delegate that is triggered when a request for product\n            /// informations completes.\n            ///\n            /// @author T Kane\n            ///\n            /// @param in_productDesc - List of product descriptions\n            /// @param in_currencyCodes - List of currency codes\n            ///         corresponding with each entry of in_productDesc\n            /// @param in_unformattedPrices - List of unformatted prices\n            ///         corresponding with each entry of in_productDesc\n            //------------------------------------------------------\n            using OnProductDescriptionsRequestCompleteDelegate = std::function<void(const std::vector<ChilliSource::IAPSystem::ProductDesc>& in_productDesc, const std::vector<std::string>& in_currencyCodes, const std::vector<std::string>& in_unformattedPrices)>;\n\n\t\t\t//--------------------------------------------------------------\n\t\t\t/// Constructor\n\t\t\t///\n\t\t\t/// @author S Downie\n\t\t\t///\n\t\t\t/// @param in_publicKey - Google Play Store public key\n\t\t\t//--------------------------------------------------------------\n\t\t\tGooglePlayIAPJavaInterface();\n\t\t\t//--------------------------------------------------------------\n\t\t\t/// @author S Downie\n\t\t\t///\n\t\t\t/// @param in_interfaceId - Interface ID\n\t\t\t///\n\t\t\t/// @return whether or not this object implements the given interface.\n\t\t\t//--------------------------------------------------------------\n\t\t\tbool IsA(ChilliSource::InterfaceIDType in_interfaceId) const override;\n            //---------------------------------------------------------------\n\t\t\t/// @author S Downie\n\t\t\t///\n\t\t\t/// @return Whether the purchasing is allowed by the device/OS\n            //---------------------------------------------------------------\n            bool IsPurchasingEnabled();\n            //---------------------------------------------------------------\n\t\t\t/// Calling this function will set the listener to which any\n            /// transaction events are directed. This is not necessarily\n            /// in response to a user action it may be previously outstanding\n            /// transactions.\n            ///\n            /// @author S Downie\n            ///\n            /// @param in_delegate - Delegate\n            //---------------------------------------------------------------\n            void StartListeningForTransactionUpdates(const ChilliSource::IAPSystem::TransactionStatusDelegate& in_delegate);\n            //---------------------------------------------------------------\n            /// Prevent any more transaction uppdates from being triggered.\n            ///\n            /// @author S Downie\n            //---------------------------------------------------------------\n            void StopListeningForTransactionUpdates();\n            //---------------------------------------------------------------\n            /// Starts a request to the store for details of the products.\n            /// These details are name, description and price\n            ///\n\t\t\t/// @param in_productIds - List of product IDs to request descriptions for\n            /// @param in_delegate - Delegate to invoke when the request completes\n            ///\n            /// @author S Downie\n            //---------------------------------------------------------------\n            void RequestProductDescriptions(const std::vector<std::string>& in_productIds, const OnProductDescriptionsRequestCompleteDelegate& in_delegate);\n            //---------------------------------------------------------------\n\t\t\t/// Prevent the completion delegate being called for\n            /// any pending product description requests and attempt to\n            /// cancel the request to the store.\n            ///\n            /// @author S Downie\n            //---------------------------------------------------------------\n            void CancelProductDescriptionsRequest();\n            //---------------------------------------------------------------\n\t\t\t/// Make a request to the store to purchase the item.\n            /// This will trigger a call to the transaction listener delegate\n            ///\n            /// @author S Downie\n            ///\n            /// @param in_productId - Product ID\n            /// @param in_type - Product type (managed, unmanaged)\n            //---------------------------------------------------------------\n            void RequestProductPurchase(const std::string& in_productId, ChilliSource::IAPSystem::ProductRegInfo::Type in_type);\n            //---------------------------------------------------------------\n\t\t\t/// Tell the store to close the transaction as complete.\n            /// NOTE: This should only be called after the goods have been\n            /// awarded.\n            ///\n            /// @author S Downie\n            ///\n            /// @param in_productId - Product ID\n            /// @param in_transactionId - Transaction ID\n            /// @param in_delegate - Delegate to call when closed successfully\n            //---------------------------------------------------------------\n            void CloseTransaction(const std::string& in_productId, const std::string& in_transactionId, const ChilliSource::IAPSystem::TransactionCloseDelegate& in_delegate);\n            //---------------------------------------------------------------\n            /// Request that the store trigger new purchase requests for\n            /// owned non-consumable items\n            ///\n            /// @author S Downie\n            //---------------------------------------------------------------\n            void RestoreManagedPurchases();\n\n            //---Only called by JNI - Otherwise would be private\n            //---------------------------------------------------------------\n    \t\t/// Called when product descriptions request complete\n            ///\n            /// @author S Downie\n            ///\n            /// @param in_products - List of product descriptions\n            /// @param in_currencyCodes - List of currency codes\n            /// @param in_unformattedPrices - List of unformatted prices\n            //---------------------------------------------------------------\n            void OnProductDescriptionsRequestComplete(const std::vector<ChilliSource::IAPSystem::ProductDesc>& in_products, const std::vector<std::string>& in_currencyCodes, const std::vector<std::string>& in_unformattedPrices);\n            //---------------------------------------------------------------\n    \t\t/// Called when transaction status changes\n            ///\n            /// @author S Downie\n            ///\n            /// @param in_statusId - Status ID\n            /// @param in_transaction - Transaction description\n            //---------------------------------------------------------------\n            void OnTransactionStatusUpdated(u32 in_statusId, const ChilliSource::IAPSystem::Transaction& in_transaction);\n            //---------------------------------------------------------------\n    \t\t/// Delegate called when the transaction is closed either\n            /// with success or failure\n            ///\n            /// @author S Downie\n            ///\n            /// @param in_productID - Product ID\n            /// @param in_transactionId - Transaction ID\n            /// @param in_success - Whether the closing of the transaction was successful\n            //---------------------------------------------------------------\n            void OnTransactionClosed(const std::string& in_productID, const std::string& in_transactionId, bool in_success);\n\n\t\tprivate:\n            OnProductDescriptionsRequestCompleteDelegate m_productsRequestDelegate;\n            ChilliSource::IAPSystem::TransactionStatusDelegate m_transactionStatusDelegate;\n            ChilliSource::IAPSystem::TransactionCloseDelegate m_transactionCloseDelegate;\n\t\t};\n\t}\n}\n\n#endif\n\n#endif\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/GooglePlay/JNI/Networking/IAP/GooglePlayIAPSystem.cpp",
    "content": "//\n//  GooglePlayIAPSystem.cpp\n//  ChilliSource\n//  Created by Scott Downie on 14/06/2013.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2013 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n\n#ifdef CS_ANDROIDFLAVOUR_GOOGLEPLAY\n\n#include <CSBackend/Platform/Android/GooglePlay/JNI/Networking/IAP/GooglePlayIAPSystem.h>\n\n#include <CSBackend/Platform/Android/Main/JNI/Core/Java/JavaInterfaceManager.h>\n\nnamespace CSBackend\n{\n\tnamespace Android\n\t{\n\t\tnamespace\n\t\t{\n\t\t\t//---------------------------------------------------------------\n\t\t\t/// Try and locate the product in the list and return its\n\t\t\t/// type - managed or unmanaged\n\t\t\t///\n\t\t\t/// @author S Downie\n\t\t\t///\n\t\t\t/// @param List of registered products\n\t\t\t/// @param Product ID to find\n\t\t\t/// @param [Out] Type if found\n\t\t\t///\n\t\t\t/// @return Whether product was found\n\t\t\t//---------------------------------------------------------------\n\t\t\tbool TryGetProductType(const std::vector<ChilliSource::IAPSystem::ProductRegInfo>& in_productInfos, const std::string& in_productId, ChilliSource::IAPSystem::ProductRegInfo::Type& out_type)\n\t\t\t{\n\t\t\t\tfor(std::vector<ChilliSource::IAPSystem::ProductRegInfo>::const_iterator it = in_productInfos.begin(); it != in_productInfos.end(); ++it)\n\t\t\t\t{\n\t\t\t\t\tif(it->m_id == in_productId)\n\t\t\t\t\t{\n\t\t\t\t\t\tout_type = it->m_type;\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\tCS_DEFINE_NAMEDTYPE(GooglePlayIAPSystem);\n\n        //---------------------------------------------------------------\n        //---------------------------------------------------------------\n\t\tGooglePlayIAPSystem::GooglePlayIAPSystem(const ChilliSource::ParamDictionary& in_params)\n\t\t{\n\t\t}\n        //---------------------------------------------------------------\n        //---------------------------------------------------------------\n        bool GooglePlayIAPSystem::IsA(ChilliSource::InterfaceIDType in_interfaceId) const\n        {\n            return in_interfaceId == ChilliSource::IAPSystem::InterfaceID || in_interfaceId == GooglePlayIAPSystem::InterfaceID;\n        }\n        //---------------------------------------------------------------\n        //---------------------------------------------------------------\n\t\tvoid GooglePlayIAPSystem::OnInit()\n\t\t{\n\t\t\tm_javaInterface = JavaInterfaceManager::GetSingletonPtr()->GetJavaInterface<GooglePlayIAPJavaInterface>();\n\t\t\tif(m_javaInterface == nullptr)\n\t\t\t{\n\t\t\t\tm_javaInterface = GooglePlayIAPJavaInterfaceSPtr(new GooglePlayIAPJavaInterface());\n\t\t\t\tJavaInterfaceManager::GetSingletonPtr()->AddJavaInterface(m_javaInterface);\n\t\t\t}\n\t\t}\n        //---------------------------------------------------------------\n        //---------------------------------------------------------------\n        void GooglePlayIAPSystem::RegisterProducts(const std::vector<ProductRegInfo>& in_productInfos)\n        {\n        \tCS_ASSERT(in_productInfos.empty() == false, \"Must register at least one product\");\n            m_productRegInfos = in_productInfos;\n        }\n        //---------------------------------------------------------------\n        //---------------------------------------------------------------\n\t\tstd::string GooglePlayIAPSystem::GetProviderID() const\n\t\t{\n\t\t\treturn \"GooglePlayV3\";\n\t\t}\n        //---------------------------------------------------------------\n        //---------------------------------------------------------------\n        void GooglePlayIAPSystem::IsPurchasingEnabled(const PurchasingEnabledDelegate& in_delegate)\n        {\n            CS_ASSERT(in_delegate, \"Cannot have empty delegate\");\n        \tin_delegate(m_javaInterface->IsPurchasingEnabled());\n        }\n        //---------------------------------------------------------------\n        //---------------------------------------------------------------\n        void GooglePlayIAPSystem::StartListeningForTransactionUpdates(const TransactionStatusDelegate& in_delegate)\n        {\n        \tCS_ASSERT(in_delegate != nullptr, \"Cannot listen for transactions with null delegate\");\n        \tm_javaInterface->StartListeningForTransactionUpdates(in_delegate);\n        }\n        //---------------------------------------------------------------\n        //---------------------------------------------------------------\n        void GooglePlayIAPSystem::StopListeningForTransactionUpdates()\n        {\n        \tm_javaInterface->StopListeningForTransactionUpdates();\n        }\n        //---------------------------------------------------------------\n        //---------------------------------------------------------------\n        void GooglePlayIAPSystem::RequestProductDescriptions(const std::vector<std::string>& in_productIds, const ProductDescDelegate& in_delegate)\n        {\n            CS_ASSERT(in_productIds.empty() == false, \"Cannot request no product descriptions\");\n            CS_ASSERT(in_delegate != nullptr, \"Cannot have null product description delegate\");\n\n        \tm_javaInterface->RequestProductDescriptions(in_productIds, [=](const std::vector<ChilliSource::IAPSystem::ProductDesc>& in_products, const std::vector<std::string>& in_currencyCodes, const std::vector<std::string>& in_unformattedPrices)\n        \t{\n        \t    CS_ASSERT(in_products.size() == in_currencyCodes.size() && in_products.size() == in_unformattedPrices.size(), \"Disparity betewen list sizes.\");\n\n                // Construct the extra products information from the supplied lists\n            \tm_extraProductsInfo.clear();\n        \t    for (u32 i = 0; i < (u32)in_products.size(); ++i)\n        \t    {\n        \t        ExtraProductInfo extraProductInfo;\n        \t        extraProductInfo.m_productId = in_products[i].m_id;\n        \t        extraProductInfo.m_currencyCode = in_currencyCodes[i];\n        \t        extraProductInfo.m_unformattedPrice = in_unformattedPrices[i];\n        \t        m_extraProductsInfo.push_back(extraProductInfo);\n        \t    }\n\n        \t    if (in_delegate)\n        \t    {\n            \t    in_delegate(in_products);\n        \t    }\n        \t});\n        }\n        //---------------------------------------------------------------\n        //---------------------------------------------------------------\n        void GooglePlayIAPSystem::RequestAllProductDescriptions(const ProductDescDelegate& in_delegate)\n        {\n            std::vector<std::string> productIds;\n            productIds.reserve(m_productRegInfos.size());\n\n            for(u32 i=0; i<m_productRegInfos.size(); ++i)\n            {\n            \tproductIds.push_back(m_productRegInfos[i].m_id);\n            }\n\n            RequestProductDescriptions(productIds, in_delegate);\n        }\n        //---------------------------------------------------------------\n        //---------------------------------------------------------------\n        void GooglePlayIAPSystem::CancelProductDescriptionsRequest()\n        {\n        \tm_javaInterface->CancelProductDescriptionsRequest();\n        }\n        //---------------------------------------------------------------\n        //---------------------------------------------------------------\n        void GooglePlayIAPSystem::RequestProductPurchase(const std::string& in_productId)\n        {\n        \tProductRegInfo::Type type;\n        \tif(!TryGetProductType(m_productRegInfos, in_productId, type))\n        \t{\n        \t\tCS_LOG_FATAL(\"Cannot find IAP product with ID \" + in_productId + \". Please register it\");\n        \t\treturn;\n        \t}\n\n        \tm_javaInterface->RequestProductPurchase(in_productId, type);\n        }\n        //---------------------------------------------------------------\n        //---------------------------------------------------------------\n        void GooglePlayIAPSystem::CloseTransaction(const TransactionSPtr& in_transaction, const TransactionCloseDelegate& in_delegate)\n        {\n        \tCS_ASSERT(in_delegate != nullptr, \"Cannot have null transaction close delegate\");\n\n        \tm_javaInterface->CloseTransaction(in_transaction->m_productId, in_transaction->m_transactionId, in_delegate);\n        }\n        //---------------------------------------------------------------\n        //---------------------------------------------------------------\n        void GooglePlayIAPSystem::RestoreManagedPurchases()\n        {\n        \tm_javaInterface->RestoreManagedPurchases();\n        }\n        //---------------------------------------------------------------\n        //---------------------------------------------------------------\n        void GooglePlayIAPSystem::OnDestroy()\n        {\n        \tm_javaInterface = nullptr;\n            m_productRegInfos.clear();\n            m_productRegInfos.shrink_to_fit();\n        }\n\t}\n}\n\n#endif\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/GooglePlay/JNI/Networking/IAP/GooglePlayIAPSystem.h",
    "content": "//\n//  GooglePlayIAPSystem.h\n//  ChilliSource\n//  Created by Scott Downie on 14/06/2013.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2013 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n\n#ifdef CS_ANDROIDFLAVOUR_GOOGLEPLAY\n\n#ifndef _CSBACKEND_PLATFORM_ANDROID_EXTENSIONS_GOOGLEPLAY_NETWORKING_GOOGLEPLAYIAPSYSTEM_H_\n#define _CSBACKEND_PLATFORM_ANDROID_EXTENSIONS_GOOGLEPLAY_NETWORKING_GOOGLEPLAYIAPSYSTEM_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Networking/IAP/IAPSystem.h>\n\n#include <CSBackend/Platform/Android/GooglePlay/JNI/ForwardDeclarations.h>\n#include <CSBackend/Platform/Android/GooglePlay/JNI/Networking/IAP/GooglePlayIAPJavaInterface.h>\n#include <CSBackend/Platform/Android/Main/JNI/ForwardDeclarations.h>\n\nnamespace CSBackend\n{\n\tnamespace Android\n\t{\n\t\t//----------------------------------------------------------------------------------\n\t\t/// System that allows purchasing of IAPs from\n\t\t/// the Google Play Store. System allows product info\n\t\t/// to be requested in ordrer to build displays and then\n\t\t/// for products to be purchased. NOTE: Must StartListeningForTransactionUpdates()\n\t\t/// before any purchases are made as this can be called with previously incomplete\n\t\t/// transactions.\n\t\t///\n\t\t/// Note: The CS pre-processor flag CS_ANDROIDFLAVOUR_GOOGLEPLAY should be set for this to be used.\n\t\t///\n\t\t/// @author S Downie\n\t\t//----------------------------------------------------------------------------------\n\t\tclass GooglePlayIAPSystem final : public ChilliSource::IAPSystem\n\t\t{\n\t\tpublic:\n\n            CS_DECLARE_NAMEDTYPE(GooglePlayIAPSystem);\n\n            //---------------------------------------------------------------\n            /// This defines platform-specific extra product information.\n            ///\n            /// @author T Kane\n            //---------------------------------------------------------------\n            struct ExtraProductInfo final\n            {\n                std::string m_productId;            // Platform-specific product ID\n                std::string m_unformattedPrice;     // Unformatted price e.g. 1.00\n                std::string m_currencyCode;         // ISO 4217 currency code, e.g. GBP, USD\n            };\n\n            //---------------------------------------------------------------\n            /// @author S Downie\n            ///\n            /// @param Interface ID to compare\n            ///\n            /// @return Whether the class is of the given type\n            //---------------------------------------------------------------\n            bool IsA(ChilliSource::InterfaceIDType in_interfaceId) const override;\n            //---------------------------------------------------------------\n            /// Inform the system of which products are available for\n            /// purchase and whether they are managed or unmanaged\n            ///\n            /// @author S Downie\n            ///\n            /// @param List of products\n            //---------------------------------------------------------------\n            void RegisterProducts(const std::vector<ProductRegInfo>& in_productInfos) override;\n            //---------------------------------------------------------------\n\t\t\t/// @author S Downie\n\t\t\t///\n\t\t\t/// @return The ID off the IAP provider as a string.\n            //---------------------------------------------------------------\n\t\t\tstd::string GetProviderID() const override;\n            //---------------------------------------------------------------\n\t\t\t/// @author S Downie\n\t\t\t///\n            /// @param Purchasing enabled delegate\n            //---------------------------------------------------------------\n            void IsPurchasingEnabled(const PurchasingEnabledDelegate& in_delegate) override;\n            //---------------------------------------------------------------\n\t\t\t/// Calling this function will set the listener to which any\n            /// transaction events are directed. This is not necessarily\n            /// in response to a user action it may be previously outstanding\n            /// transactions.\n            ///\n            /// @author S Downie\n            ///\n            /// @param Delegate\n            //---------------------------------------------------------------\n            void StartListeningForTransactionUpdates(const TransactionStatusDelegate& in_delegate) override;\n            //---------------------------------------------------------------\n            /// Prevent any more transaction uppdates from being triggered.\n            ///\n            /// @author S Downie\n            //---------------------------------------------------------------\n            void StopListeningForTransactionUpdates() override;\n            //---------------------------------------------------------------\n            /// Starts a request to the store for details of the products.\n            /// These details are name, description and price\n            ///\n            /// @author S Downie\n            ///\n\t\t\t/// @param List of product IDs to request descriptions for\n            /// @param Delegate to invoke when the request completes\n            //---------------------------------------------------------------\n            void RequestProductDescriptions(const std::vector<std::string>& in_productIds, const ProductDescDelegate& in_delegate) override;\n            //---------------------------------------------------------------\n            /// Starts a request to the store for details of all registered\n            /// products. These details are name, description and price\n            ///\n            /// @author S Downie\n            ///\n            /// @param Delegate to invoke when the request completes\n            //---------------------------------------------------------------\n            void RequestAllProductDescriptions(const ProductDescDelegate& in_delegate) override;\n            //---------------------------------------------------------------\n\t\t\t/// Prevent the completion delegate being called for\n            /// any pending product description requests and attempt to\n            /// cancel the request to the store.\n            ///\n            /// @author S Downie\n            //---------------------------------------------------------------\n            void CancelProductDescriptionsRequest() override;\n            //---------------------------------------------------------------\n\t\t\t/// Make a request to the store to purchase the item.\n            /// This will trigger a call to the transaction listener delegate\n            ///\n            /// @author S Downie\n            ///\n            /// @param Product ID\n            //---------------------------------------------------------------\n            void RequestProductPurchase(const std::string& in_productId) override;\n            //---------------------------------------------------------------\n            /// Tell the store to close the transaction as complete.\n            /// NOTE: This should only be called after the goods have been\n            /// awarded.\n            ///\n            /// @author S Downie\n            ///\n            /// @param Transaction to close\n            /// @param Delegate to call when closed (either with success or failure)\n            //---------------------------------------------------------------\n            void CloseTransaction(const TransactionSPtr& inpTransaction, const TransactionCloseDelegate& in_delegate) override;\n            //---------------------------------------------------------------\n            /// Request that the store trigger new purchase requests for\n            /// owned non-consumable items\n            ///\n            /// @author S Downie\n            //---------------------------------------------------------------\n            void RestoreManagedPurchases() override;\n            //---------------------------------------------------------------\n            /// @author T Kane\n            ///\n            /// @return A vector of extra product information, particular to\n            /// this platform. Note that products must be requested from the\n            /// store via RequestProductDescriptions or\n            /// RequestProductDescriptions before being available so there is\n            /// no guarantee that a particular product will be available. It is\n            /// the application's responsibility to ensure the correct data\n            /// has been requested up-front.\n            //---------------------------------------------------------------\n            const std::vector<GooglePlayIAPSystem::ExtraProductInfo>& GetExtraProductInfo() const { return m_extraProductsInfo; }\n\n\t\tprivate:\n            friend ChilliSource::IAPSystemUPtr ChilliSource::IAPSystem::Create(const ChilliSource::ParamDictionary&);\n            //---------------------------------------------------------------\n            /// Private constructor to force the use of the factory method\n            ///\n            /// @author S Downie\n\t\t\t///\n\t\t\t/// @param A dictionary of platform specific parameters. The\n\t\t\t/// parameters that relate to the Google Play IAP System are as\n\t\t\t/// follows:\n            /// \tGooglePlayPublicKey  \tThe public key used for connecting\n            ///\t\t\t\t\t\t\t\tto the Google Play store.\n            //---------------------------------------------------------------\n\t\t\tGooglePlayIAPSystem(const ChilliSource::ParamDictionary& in_params);\n            //-------------------------------------------------------\n            /// Called when the system is created. Initialises\n            /// the Java backend\n            ///\n            /// @author S Downie\n            //-------------------------------------------------------\n            void OnInit() override;\n            //-------------------------------------------------------\n            /// Called when the system is shutdown.\n            ///\n            /// @author S Downie\n            //-------------------------------------------------------\n            void OnDestroy() override;\n\n\t\tprivate:\n\n            std::vector<ProductRegInfo> m_productRegInfos;\n\n            GooglePlayIAPJavaInterfaceSPtr m_javaInterface;\n\n            std::string m_publicKey;\n\t\t    std::vector<ExtraProductInfo> m_extraProductsInfo;\n\t\t};\n\t}\n}\n\n#endif\n\n#endif\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/GooglePlay/Java/com/chilliworks/chillisource/core/ApkExpansionContentProvider.java",
    "content": "/**\n * ApkExpansionContentProvider.java\n * ChilliSource\n * Created by Ian Copland on 23/06/2015.\n *\n * The MIT License (MIT)\n *\n * Copyright (c) 2015 Tag Games Limited\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.core;\n\nimport android.content.ContentProvider;\nimport android.content.ContentValues;\nimport android.database.Cursor;\nimport android.net.Uri;\nimport android.os.Handler;\nimport android.os.ParcelFileDescriptor;\n\nimport java.io.File;\nimport java.io.FileNotFoundException;\nimport java.util.Random;\n\n/**\n * A content provider for accessing assets within the main Apk Expansion OBB file. The file will\n * first be extracted to a temporary location then deleted again when the relevant file descriptor\n * is closed. This is pretty inefficient, so it should only be used where absolutely necessary.\n *\n * @author Ian Copland\n */\npublic final class ApkExpansionContentProvider extends ContentProvider\n{\n    private static final String TEMP_DIRECTORY = \"_ApkExpansionContentProvider/\";\n\n    /**\n     * @author Ian Copland\n     *\n     * @return The prefix which all paths that this content provider relates to should have.\n     */\n    public static String getContentPathPrefix()\n    {\n        assert (CSApplication.get() != null && CSApplication.get().getActivity() != null) : \"Cannot get content path prefix before the application has been created.\";\n\n        return \"content://\" + CSApplication.get().getApplicationId() + \".apkexpansioncontentprovider/\";\n    }\n    /**\n     * Called when the provider is first created.\n     *\n     * @author Ian Copland\n     *\n     * @return Whether the provider was successfully loaded. Always true in this case.\n     */\n    @Override public boolean onCreate()\n    {\n        return true;\n    }\n    /**\n     * Returns the MIME type for the given URL.\n     *\n     * @author Ian Copland\n     *\n     * @param in_uri - The URI which should have its MIME type checked.\n     *\n     * @return The MIME Type. Currently this always returns null.\n     */\n    @Override public String getType(Uri in_uri)\n    {\n        return null;\n    }\n    /**\n     * Opens a descriptor for the file with the given URI. As this provides access to the contents\n     * of a zip file, the file is first extracted to a temporary location and it is this file that\n     * the descriptor describes. As the file is extracted, this is pretty inefficient and other\n     * methods should be preferred.\n     *\n     * @author Ian Copland\n     *\n     * @param in_uri - The URI to the requested file.\n     * @param in_mode - The file mode. Must be 'r'.\n     *\n     * @return The file descriptor. Will never be null.\n     *\n     * @throws FileNotFoundException - This is thrown if the file doesn't exist, the content prefix\n     * is incorrect or the read mode is anything other than 'r'.\n     */\n    @Override public ParcelFileDescriptor openFile(Uri in_uri, String in_mode) throws FileNotFoundException\n    {\n        assert (CSApplication.get() != null && CSApplication.get().getActivity() != null) : \"Cannot open asset file before the application has been created.\";\n\n        if (in_mode.equals(\"r\") == false)\n        {\n            throw new FileNotFoundException(\"This content provider only supports read operations.\");\n        }\n\n        String contentPathPrefix = getContentPathPrefix();\n\n        String uriString = in_uri.toString();\n        if (uriString.startsWith(contentPathPrefix) == false)\n        {\n            throw new FileNotFoundException(\"The content prefix is incorrect for this content provider.\");\n        }\n\n        String filePath = uriString.substring(contentPathPrefix.length());\n        String fileName = StringUtils.getFileName(filePath);\n\n        String tempDirectoryPath = FileUtils.getExternalCacheDirectory(CSApplication.get().getActivity().getPackageName()) + TEMP_DIRECTORY;\n        FileUtils.createDirectory(tempDirectoryPath);\n\n        Random random = new Random();\n        String tempFileName = StringUtils.removeExtension(fileName) + \"-\" + random.nextLong() + \".\" + StringUtils.getExtension(fileName);\n        final String tempFilePath = tempDirectoryPath + tempFileName;\n\n        if (ApkExpansionFileUtils.copyFile(filePath, tempFilePath) == false)\n        {\n            throw new FileNotFoundException(\"Failed to extract temp file '\" + tempFileName + \"'.\");\n        }\n\n        try\n        {\n            Handler uiThreadHandler = new Handler(CSApplication.get().getActivity().getMainLooper());\n            return new ListenableParcelFileDescriptor(new File(tempFilePath), ParcelFileDescriptor.MODE_READ_ONLY, new ListenableParcelFileDescriptor.OnClose()\n            {\n                @Override public void onClosed()\n                {\n                    FileUtils.removeFile(tempFilePath);\n                }\n            });\n        }\n        catch (Exception e)\n        {\n            FileUtils.removeFile(tempDirectoryPath);\n            throw new FileNotFoundException(\"Could not read the extracted temp file '\" + tempFileName + \"'.\");\n        }\n    }\n    /**\n     * Unsupported by this provider. Will throw an UnsupportedOperationException if called.\n     *\n     * @author Ian Copland\n     *\n     * @param in_uri - The URI\n     * @param in_projection - The project\n     * @param in_selection - The selection\n     * @param in_selectionArgs - The selection arguments\n     * @param in_sortOrder - The sort order\n     *\n     * @return Nothing will be returned as this always throws\n     */\n    @Override public Cursor query(Uri in_uri, String[] in_projection, String in_selection, String[] in_selectionArgs, String in_sortOrder)\n    {\n        throw new UnsupportedOperationException(\"This content provider only supports reading files from the Apk Expansion.\");\n    }\n    /**\n     * Unsupported by this provider. Will throw an UnsupportedOperationException if called.\n     *\n     * @author Ian Copland\n     *\n     * @param in_uri - The URI\n     * @param in_values - The values\n     *\n     * @return Nothing will be returned as this always throws.\n     */\n    @Override public Uri insert(Uri in_uri, ContentValues in_values)\n    {\n        throw new UnsupportedOperationException(\"This content provider only supports reading files from the Apk Expansion.\");\n    }\n    /**\n     * Unsupported by this provider. Will throw an UnsupportedOperationException if called.\n     *\n     * @author Ian Copland\n     *\n     * @param in_uri - The URI\n     * @param in_selection - The selection\n     * @param in_selectionArgs - The selection arguments\n     *\n     * @return Nothing will be returned as this always throws.\n     */\n    @Override public int delete(Uri in_uri, String in_selection, String[] in_selectionArgs)\n    {\n        throw new UnsupportedOperationException(\"This content provider only supports reading files from the Apk Expansion.\");\n    }\n    /**\n     * Unsupported by this provider. Will throw an UnsupportedOperationException if called.\n     *\n     * @author Ian Copland\n     *\n     * @param in_uri - The URI\n     * @param in_values - The values\n     * @param in_selection - The selection\n     * @param in_selectionArgs - The selection arguments\n     *\n     * @return Nothing will be returned as this always throws.\n     */\n    @Override public int update(Uri in_uri, ContentValues in_values, String in_selection, String[] in_selectionArgs)\n    {\n        throw new UnsupportedOperationException(\"This content provider only supports reading files from the Apk Expansion.\");\n    }\n}\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/GooglePlay/Java/com/chilliworks/chillisource/core/ApkExpansionFileUtils.java",
    "content": "/**\n * ApkExpansion.java\n * ChilliSource\n * Created by Ian Copland on 23/07/2015\n *\n * The MIT License (MIT)\n *\n * Copyright (c) 2015 Tag Games Limited\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.core;\n\nimport android.app.Activity;\nimport android.content.res.AssetFileDescriptor;\nimport android.content.res.AssetManager;\n\nimport java.io.BufferedInputStream;\nimport java.io.File;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.util.Arrays;\nimport java.util.Enumeration;\nimport java.util.List;\nimport java.util.zip.ZipEntry;\nimport java.util.zip.ZipFile;\n\n/**\n * A collection of convenience methods for reading files from the the Apk expansion.\n *\n * @author Ian Copland\n */\npublic final class ApkExpansionFileUtils\n{\n    /**\n     * @author Ian Copland\n     *\n     * @param in_filePath - The path to the file inside the Apk Expansion.\n     *\n     * @return Whether or not the given file exists in the Apk Expansion.\n     */\n    public static boolean doesFileExist(String in_filePath)\n    {\n        try\n        {\n            ZipFile zipFile = new ZipFile(ApkExpansionInfo.getFilePath());\n            try\n            {\n                Enumeration<? extends ZipEntry> entries = zipFile.entries();\n                while (entries.hasMoreElements())\n                {\n                    ZipEntry zipEntry = entries.nextElement();\n                    if (zipEntry.isDirectory() == false)\n                    {\n                        String zipEntryFilePath = StringUtils.standardiseFilePath(zipEntry.getName());\n                        if (in_filePath.equals(zipEntryFilePath) == true)\n                        {\n                            return true;\n                        }\n                    }\n                }\n            }\n            finally\n            {\n                zipFile.close();\n            }\n        }\n        catch (IOException e)\n        {\n            Logging.logVerbose(ExceptionUtils.convertToString(e));\n            Logging.logError(\"An error occurred while trying to check if file '\" + in_filePath + \"' exists inside the Apk expansion file.\");\n        }\n\n        return false;\n    }\n    /**\n     * Reads the entire contents of a binary file from the Apk Expansion. The contents are returned\n     * as a byte array.\n     *\n     * @author Ian Copland\n     *\n     * @param in_filePath - The path to the file inside the Apk Expansion.\n     *\n     * @return The file contents.\n     */\n    public static byte[] readBinaryFile(String in_filePath)\n    {\n        try\n        {\n            ZipFile zipFile = new ZipFile(ApkExpansionInfo.getFilePath());\n            try\n            {\n                Enumeration<? extends ZipEntry> entries = zipFile.entries();\n                while (entries.hasMoreElements())\n                {\n                    ZipEntry zipEntry = entries.nextElement();\n                    if (zipEntry.isDirectory() == false)\n                    {\n                        String zipEntryFilePath = StringUtils.standardiseFilePath(zipEntry.getName());\n                        if (in_filePath.equals(zipEntryFilePath) == true)\n                        {\n                            return readZipEntry(zipFile, zipEntry);\n                        }\n                    }\n                }\n            }\n            finally\n            {\n                zipFile.close();\n            }\n        }\n        catch (IOException e)\n        {\n            Logging.logVerbose(ExceptionUtils.convertToString(e));\n            Logging.logError(\"An error occurred while trying to check if file '\" + in_filePath + \"' exists inside the Apk expansion file.\");\n        }\n\n        return null;\n    }\n    /**\n     * Reads the entire contents of a text file from the Apk expansion.\n     *\n     * @author Ian Copland\n     *\n     * @param in_filePath - The path to the file inside the Apk Expansion.\n     *\n     * @return The file contents.\n     */\n    public static String readTextFile(String in_filePath)\n    {\n        byte[] contents = readBinaryFile(in_filePath);\n        if (contents == null)\n        {\n            return \"\";\n        }\n        return StringUtils.utf8BytesToString(contents);\n    }\n    /**\n     * Calculates the size of the given file located in the Apk Expansion\n     *\n     * @author Ian Copland\n     *\n     * @param in_filePath - The path to the file inside the Apk Expansion.\n     *\n     * @return The size of the file in bytes.\n     */\n    public static long getFileSize(String in_filePath)\n    {\n        try\n        {\n            ZipFile zipFile = new ZipFile(ApkExpansionInfo.getFilePath());\n            try\n            {\n                Enumeration<? extends ZipEntry> entries = zipFile.entries();\n                while (entries.hasMoreElements())\n                {\n                    ZipEntry zipEntry = entries.nextElement();\n                    if (zipEntry.isDirectory() == false)\n                    {\n                        return zipEntry.getSize();\n                    }\n                }\n            }\n            finally\n            {\n                zipFile.close();\n            }\n        }\n        catch (IOException e)\n        {\n            Logging.logVerbose(ExceptionUtils.convertToString(e));\n            Logging.logError(\"An error occurred while trying to check if file '\" + in_filePath + \"' exists inside the Apk expansion file.\");\n        }\n\n        return 0;\n    }\n    /**\n     * Copies the requested file from the Apk Expansion file to external storage.\n     *\n     * @author Ian Copland\n     *\n     * @param in_sourceFilePath - The source file path inside the Apk Expansion\n     * @param in_destFilePath - The destination file path in external storage.\n     *\n     * @return Whether or not the copy was successful.\n     */\n    public static boolean copyFile(String in_sourceFilePath, String in_destFilePath)\n    {\n        if (doesFileExist(in_sourceFilePath) == false)\n        {\n            return false;\n        }\n\n        byte[] fileContents = readBinaryFile(in_sourceFilePath);\n        if (fileContents == null)\n        {\n            return false;\n        }\n\n        return FileUtils.writeBinaryFile(in_destFilePath, fileContents);\n    }\n    /**\n     * Reads the contents of a the file described by the given zip entry from the given zip file.\n     *\n     * @author Ian Copland\n     *\n     * @param in_zipFile - The zip file.\n     * @param in_zipEntry - The zip entry.\n     *\n     * @throws IOException - This is thrown if the operation fails for any reason.\n     */\n    private static byte[] readZipEntry(ZipFile in_zipFile, ZipEntry in_zipEntry) throws IOException\n    {\n        final int k_bufferSize = 16 * 1024;\n        DynamicByteBuffer dynamicByteBuffer = new DynamicByteBuffer(k_bufferSize);\n\n        BufferedInputStream stream = new BufferedInputStream(in_zipFile.getInputStream(in_zipEntry));\n        try\n        {\n            byte[] buffer = new byte[k_bufferSize];\n            int numRead = 0;\n            while(numRead != -1)\n            {\n                numRead = stream.read(buffer, 0, k_bufferSize);\n                if (numRead > 0)\n                {\n                    dynamicByteBuffer.appendBytes(buffer, numRead);\n                }\n            }\n        }\n        finally\n        {\n            stream.close();\n        }\n\n        return dynamicByteBuffer.toByteArray();\n    }\n}\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/GooglePlay/Java/com/chilliworks/chillisource/core/ApkExpansionInfo.java",
    "content": "/**\n * ApkExpansionInfo.java\n * ChilliSource\n * Created by Ian Copland on 08/06/2015.\n *\n * The MIT License (MIT)\n *\n * Copyright (c) 2015 Tag Games Limited\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.core;\n\nimport android.app.Activity;\n\nimport com.google.android.vending.expansion.downloader.Helpers;\n\nimport org.json.JSONException;\nimport org.json.JSONObject;\n\n/**\n * A static class which provides a series of methods which provide information on the Apk\n * Expansion file.\n *\n * These methods are thread safe.\n *\n * @author Ian Copland\n */\npublic final class ApkExpansionInfo\n{\n    private static final String CACHE_VERSION_CODE_TAG = \"VersionCode\";\n    private static final String CACHE_FILE_SIZE_TAG = \"FileSize\";\n\n    private static boolean m_calculated = false;\n    private static String m_apkExpansionDirectoryPath = \"\";\n    private static String m_apkExpansionFilePath = \"\";\n    private static int m_versionCode = 0;\n    private static long m_fileSize = 0;\n\n    /**\n     * Reads the Apk Expansion config file, describing the intended version code and file size\n     * of the main Apk Expansion file.\n     *\n     * @author Ian Copland\n     *\n     * @param in_activity - Any of the applications activities.\n     */\n    public static synchronized void init(Activity in_activity)\n    {\n        assert (m_calculated == false) : \"Cannot re-calculate the expansion info.\";\n\n        String filePath = \"ApkExpansion.config\";\n        if (ApkFileUtils.doesFileExist(in_activity, filePath) == false)\n        {\n            Logging.logFatal(\"Apk Expansion config file '\" + filePath + \"' does not exist.\");\n        }\n\n        String fileContents = ApkFileUtils.readTextFile(in_activity, filePath);\n\n        try\n        {\n            JSONObject jsonRoot = new JSONObject(fileContents);\n            m_versionCode = jsonRoot.getInt(CACHE_VERSION_CODE_TAG);\n            m_fileSize = jsonRoot.getLong(CACHE_FILE_SIZE_TAG);\n        }\n        catch (JSONException e)\n        {\n            Logging.logFatal(ExceptionUtils.convertToString(e));\n        }\n\n        String expansionDirectory = Helpers.getSaveFilePath(in_activity);\n        m_apkExpansionDirectoryPath = StringUtils.standardiseDirectoryPath(expansionDirectory);\n\n        String expansionFileName = Helpers.getExpansionAPKFileName(in_activity, true, m_versionCode);\n        m_apkExpansionFilePath = m_apkExpansionDirectoryPath + expansionFileName;\n    }\n    /**\n     * Returns the path to the Apk Expansion directory. The Apk Expansion file doesn't necessarily\n     * exist yet.\n     *\n     * init() must have been called prior to this.\n     *\n     * This is thread safe.\n     *\n     * @author Ian Copland\n     *\n     * @return The directory which Apk Expansion files are stored in.\n     */\n    public static synchronized String getDirectoryPath()\n    {\n        assert (m_calculated == true) : \"Must calculate Apk Expansion info before it can be retrieved.\";\n\n        return m_apkExpansionDirectoryPath;\n    }\n    /**\n     * Returns the path to the main Apk Expansion file. The Apk Expansion file doesn't necessarily\n     * exist yet.\n     *\n     * init() must have been called prior to this.\n     *\n     * This is thread safe.\n     *\n     * @author Ian Copland\n     *\n     * @return The file path to the main apk expansion file.\n     */\n    public static synchronized String getFilePath()\n    {\n        assert (m_calculated == true) : \"Must calculate Apk Expansion info before it can be retrieved.\";\n\n        return m_apkExpansionFilePath;\n    }\n    /**\n     * Returns the versionCode of the main Apk Expansion file. TThe Apk Expansion file doesn't\n     * necessarily exist yet.\n     *\n     * init() must have been called prior to this.\n     *\n     * This is thread safe.\n     *\n     * @author Ian Copland\n     *\n     * @return The version code of the Apk Expansion file.\n     */\n    public static synchronized int getVersionCode()\n    {\n        assert (m_calculated == true) : \"Must calculate Apk Expansion info before it can be retrieved.\";\n\n        return m_versionCode;\n    }\n    /**\n     * Returns the file size of the main Apk Expansion file. TThe Apk Expansion file doesn't\n     * necessarily exist yet.\n     *\n     * init() must have been called prior to this.\n     *\n     * This is thread safe.\n     *\n     * @author Ian Copland\n     *\n     * @return The file size of the main Apk Expansion file.\n     */\n    public static synchronized long getFileSize()\n    {\n        assert (m_calculated == true) : \"Must calculate Apk Expansion info before it can be retrieved.\";\n\n        return m_fileSize;\n    }\n}\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/GooglePlay/Java/com/chilliworks/chillisource/core/GooglePlayLicensing.java",
    "content": "/**\n * GooglePlayLicensing.java\n * ChilliSource\n * Created by Ian Copland on 27/05/2015.\n *\n * The MIT License (MIT)\n *\n * Copyright (c) 2015 Tag Games Limited\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.core;\n\n/**\n * Provides a unified means for systems to access the Google Play LVL Public Key supplied by the\n * user of the engine.\n *\n * @author Ian Copland\n */\npublic final class GooglePlayLicensing\n{\n    static private volatile String s_publicKey = \"\";\n\n    /**\n     * This can be called on any thread.\n     *\n     * @author Ian Copland\n     *\n     * @return The Public Key used by each of the google play systems to verify the app license.\n     */\n    public static String getLvlPublicKey()\n    {\n        synchronized (s_publicKey)\n        {\n            if (s_publicKey.isEmpty() == true)\n            {\n                s_publicKey = calcLvlPublicKey();\n                assert (s_publicKey != \"\") : \"The google play public key has not been set!\";\n            }\n\n            return s_publicKey;\n        }\n    }\n\n\n    /**\n     * Gets the lvl public key from native.\n     *\n     * @author Ian Copland\n     *\n     * @return The Public Key used by each of the google play systems to verify the app license.\n     */\n    public static native String calcLvlPublicKey();\n}\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/GooglePlay/Java/com/chilliworks/chillisource/core/ListenableParcelFileDescriptor.java",
    "content": "/**\n * ApkExpansionFileDescriptor.java\n * ChilliSource\n * Created by Ian Copland on 23/06/2015.\n *\n * The MIT License (MIT)\n *\n * Copyright (c) 2015 Tag Games Limited\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.core;\n\nimport android.os.ParcelFileDescriptor;\n\nimport java.io.File;\nimport java.io.FileNotFoundException;\nimport java.io.IOException;\n\n/**\n * A parcel file descriptor which provides a means to by notified when the descriptor is closed.\n * This is the equivalent of using the ParcelFileDescriptor.OnCloseListener but is available prior\n * to API Level 19.\n *\n * @author Ian Copland\n */\npublic class ListenableParcelFileDescriptor extends ParcelFileDescriptor\n{\n    private OnClose m_listener;\n\n    /**\n     * An interface which can be implemented to be notified when the file descriptor is closed.\n     *\n     * @author Ian Copland\n     */\n    public interface OnClose\n    {\n        /**\n         * Called when the file descriptor is closed.\n         *\n         * @author Ian Copland\n         */\n        void onClosed();\n    }\n    /**\n     * Constructor.\n     *\n     * @author Ian Copland\n     *\n     * @param in_file - The file which this descriptor should point to.\n     * @param in_mode - The file mode.\n     * @param in_listener - The listener which should be notified of the closed event.\n     *\n     * @throws FileNotFoundException - Thrown if the file cannot be found. Note that this is the\n     * only case in which the closed event will not be fired.\n     */\n    public ListenableParcelFileDescriptor(File in_file, int in_mode, OnClose in_listener) throws FileNotFoundException\n    {\n        super(ParcelFileDescriptor.open(in_file, in_mode));\n\n        assert (in_listener != null) : \"Cannot create a ListenableParcelFileDescriptor without a listener.\";\n\n        m_listener = in_listener;\n    }\n    /**\n     * Calls the base classes close() then calls the closed listener. The listener will be called\n     * regardless of whether an IO exception occurs.\n     *\n     * @author Ian Copland\n     *\n     * @throws IOException - Will be thrown if the base class throws during close().\n     */\n    @Override public void close() throws IOException\n    {\n        try\n        {\n            super.close();\n        }\n        catch (Exception e)\n        {\n            m_listener.onClosed();\n            throw new IOException(e);\n        }\n\n        m_listener.onClosed();\n    }\n}\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/GooglePlay/Java/com/chilliworks/chillisource/core/PackageFileUtils.java",
    "content": "/**\n * PackageFileUtils.java\n * ChilliSource\n * Created by Ian Copland on 22/07/2015\n *\n * The MIT License (MIT)\n *\n * Copyright (c) 2015 Tag Games Limited\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.core;\n\nimport android.app.Activity;\nimport android.content.res.AssetFileDescriptor;\nimport android.content.res.AssetManager;\n\nimport java.io.BufferedInputStream;\nimport java.io.File;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.util.Arrays;\nimport java.util.Enumeration;\nimport java.util.List;\nimport java.util.zip.ZipEntry;\nimport java.util.zip.ZipFile;\n\n/**\n * A collection of convenience methods for reading files from the either the Apk or the Apk\n * expansion file, depending on the current product flavour. Google Play builds will refer to\n * the Apk expansion file, while Amazon builds will use the Apk.\n *\n * Note that package doesn't quite mean the same thing here as on the native side of the engine.\n * In the native side, package refers specifically to the AppResources/ directory inside either the\n * Apk Expansion file or Apk; this refers simply to root.\n *\n * @author Ian Copland\n */\npublic final class PackageFileUtils\n{\n    /**\n     * @author Ian Copland\n     *\n     * @param in_activity - The current activity.\n     * @param in_filePath - The file path inside either the Apk or the Apk Expansion file depending\n     * on the current product flavour.\n     *\n     * @return Whether or not the given file exists in either the Apk or the Apk Expansion file\n     * depending on the current product flavour.\n     */\n    public static boolean doesFileExist(Activity in_activity, String in_filePath)\n    {\n        return ApkExpansionFileUtils.doesFileExist(in_filePath);\n    }\n    /**\n     * Reads the entire contents of a binary file from either the Apk or the Apk Expansion file\n     * depending on the current product flavour. The contents are returned as a byte array.\n     *\n     * @author Ian Copland\n     *\n     * @param in_activity - The activity\n     * @param in_filePath - The path to the file.\n     *\n     * @return The file contents.\n     */\n    public static byte[] readBinaryFile(Activity in_activity, String in_filePath)\n    {\n        return ApkExpansionFileUtils.readBinaryFile(in_filePath);\n    }\n    /**\n     * Reads the entire contents of a text file from either the Apk or the Apk Expansion file\n     * depending on the current product flavour\n     *\n     * @author Ian Copland\n     *\n     * @param in_activity - The activity\n     * @param in_filePath - The path to the file.\n     *\n     * @return The file contents.\n     */\n    public static String readTextFile(Activity in_activity, String in_filePath)\n    {\n        return ApkExpansionFileUtils.readTextFile(in_filePath);\n    }\n    /**\n     * Calculates the size of the given file located in either the Apk or the Apk Expansion file\n     * depending on the current product flavour.\n     *\n     * @author Ian Copland\n     *\n     * @param in_activity - The activity which is currently active.\n     * @param in_filePath - The path to the file which is to have its size calculated.\n     *\n     * @return The size of the file in bytes.\n     */\n    public static long getFileSize(Activity in_activity, String in_filePath)\n    {\n        return ApkExpansionFileUtils.getFileSize(in_filePath);\n    }\n    /**\n     * Copies the requested file from either the Apk or the Apk Expansion file - depending on the c\n     * current product flavour - to external storage.\n     *\n     * @author Ian Copland\n     *\n     * @param in_activity - The activity which is currently active.\n     * @param in_sourceFilePath - The source file path inside either the Apk or the Apk Expansion\n     * file depending on the current product flavour.\n     * @param in_destFilePath - The destination file path in external storage.\n     *\n     * @return Whether or not the copy was successful.\n     */\n    public static boolean copyFile(Activity in_activity, String in_sourceFilePath, String in_destFilePath)\n    {\n        return ApkExpansionFileUtils.copyFile(in_sourceFilePath, in_destFilePath);\n    }\n}\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/GooglePlay/Java/com/chilliworks/chillisource/core/StartupActivityFactory.java",
    "content": "/**\n * StartupActivityFactory.java\n * ChilliSource\n * Created by Ian Copland on 01/06/2015.\n *\n * The MIT License (MIT)\n *\n * Copyright (c) 2015 Tag Games Limited\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.core;\n\nimport android.content.Intent;\n\nimport com.chilliworks.chillisource.networking.ApkExpansionDownloadActivity;\nimport com.chilliworks.chillisource.networking.ApkExpansionDownloadValidator;\n\n/**\n * A factory class for creating a flavour specific Activity which is presented prior to the\n * CSActivity. In this case the Google Play Apk expansion download activity will be presented\n * if the Apk expansion files don't exist.\n *\n * @author Ian Copland\n */\npublic final class StartupActivityFactory\n{\n    /**\n     * Creates the Apk Expansion Download Activity if the Apk Expansion files don't exist.\n     * Otherwise does nothing and returns false.\n     *\n     * @author Ian Copland\n     *\n     * @param in_currentActivity - The currently active activity, typically the CSActivity.\n     *\n     * @return Whether or not the activity was started.\n     */\n    public static boolean tryStartActivity(CSActivity in_currentActivity)\n    {\n        ApkExpansionInfo.init(in_currentActivity);\n\n        if (ApkExpansionDownloadValidator.isDownloadRequired(in_currentActivity) == true)\n        {\n            Intent in = new Intent(in_currentActivity, ApkExpansionDownloadActivity.class);\n            in_currentActivity.startActivity(in);\n            return true;\n        }\n\n        return false;\n    }\n}\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/GooglePlay/Java/com/chilliworks/chillisource/networking/ApkExpansionDownloadActivity.java",
    "content": "/**\n * ApkExpansionDownloadActivity.java\n * ChilliSource\n * Created by Ian Copland on 27/05/2015.\n *\n * The MIT License (MIT)\n *\n * Copyright (c) 2015 Tag Games Limited\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.networking;\n\nimport android.app.Activity;\nimport android.app.PendingIntent;\nimport android.content.Intent;\nimport android.content.pm.PackageManager;\nimport android.graphics.Color;\nimport android.os.Bundle;\nimport android.os.Messenger;\nimport android.view.Window;\nimport android.view.WindowManager;\n\nimport com.chilliworks.chillisource.core.CSActivity;\nimport com.chilliworks.chillisource.core.ExceptionUtils;\nimport com.chilliworks.chillisource.core.FileUtils;\nimport com.chilliworks.chillisource.core.Logging;\nimport com.chilliworks.chillisource.core.StringUtils;\nimport com.google.android.vending.expansion.downloader.DownloadProgressInfo;\nimport com.google.android.vending.expansion.downloader.DownloaderClientMarshaller;\nimport com.google.android.vending.expansion.downloader.DownloaderServiceMarshaller;\nimport com.google.android.vending.expansion.downloader.Helpers;\nimport com.google.android.vending.expansion.downloader.IDownloaderClient;\nimport com.google.android.vending.expansion.downloader.IDownloaderService;\nimport com.google.android.vending.expansion.downloader.IStub;\n\n/**\n * An activity which is presented prior to the CSActivity in Google Play builds which checks\n * if the Apk Expansion file is present. If it is, the CSActivity is pushed. If not, then this\n * will start the download.\n *\n * An ApkExpansionDownloaderView is used to present the user download progress. By default\n * a basic view is provided, but this can be overridden with an app specific implementation.\n *\n * @author Ian Copland\n */\npublic final class ApkExpansionDownloadActivity extends Activity implements IDownloaderClient\n{\n    private IStub m_downloaderClientStub = null;\n    private IDownloaderService m_remoteService = null;\n    private ApkExpansionDownloadView m_view = null;\n\n    /**\n     * Sets whether or not the download should be paused.\n     *\n     * This can only be called from the UI thread.\n     *\n     * @author Ian Copland\n     *\n     * @param in_pause - Whether to pause or un-pause the download.\n     */\n    public void setDownloadPaused(final boolean in_pause)\n    {\n        if (m_remoteService != null)\n        {\n            if (in_pause == true)\n            {\n                m_remoteService.requestPauseDownload();\n            }\n            else\n            {\n                m_remoteService.requestContinueDownload();\n            }\n        }\n    }\n    /**\n     * Called when the activity is first created.\n     *\n     * @author Ian Copland\n     *\n     * @param in_savedInstanceState - The saved instance state.\n     */\n    @Override protected void onCreate(Bundle in_savedInstanceState)\n    {\n        super.onCreate(in_savedInstanceState);\n\n        //enable full screen and no title.\n        requestWindowFeature(Window.FEATURE_NO_TITLE);\n        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);\n\n        //Set black background.\n        getWindow().getDecorView().setBackgroundColor(Color.BLACK);\n\n        if (ApkExpansionDownloadValidator.isDownloadRequired(this) == true)\n        {\n            startDownload();\n        }\n        else\n        {\n            startCSActivity();\n        }\n    }\n    /**\n     * Called when the application is resumed. The downloader client stub will be reconnected\n     * if appropriate.\n     *\n     * @author Ian Copland\n     */\n    @Override protected void onResume()\n    {\n        if (null != m_downloaderClientStub)\n        {\n            m_downloaderClientStub.connect(this);\n        }\n\n        super.onResume();\n    }\n    /**\n     * Called when the service is connected.\n     *\n     * @author Ian Copland\n     *\n     * @param in_messenger - The class which forwards on messages.\n     */\n    @Override public void onServiceConnected(Messenger in_messenger)\n    {\n        m_remoteService = DownloaderServiceMarshaller.CreateProxy(in_messenger);\n        m_remoteService.onClientUpdated(m_downloaderClientStub.getMessenger());\n    }\n    /**\n     * Called when the download state changes.\n     *\n     * @author Ian Copland\n     *\n     * @param in_newState - The state which the system has changed to.\n     */\n    @Override public void onDownloadStateChanged(int in_newState)\n    {\n        //ensure state changes are only received when expected.\n        if (m_remoteService == null)\n        {\n            return;\n        }\n\n        String stateString = getString(Helpers.getDownloaderStringResourceIDFromState(in_newState));\n\n        switch (in_newState)\n        {\n            case IDownloaderClient.STATE_DOWNLOADING:\n                m_view.onStateChanged(ApkExpansionDownloadState.DOWNLOADING, stateString);\n                break;\n            case IDownloaderClient.STATE_FAILED_CANCELED:\n            case IDownloaderClient.STATE_FAILED:\n            case IDownloaderClient.STATE_FAILED_FETCHING_URL:\n            case IDownloaderClient.STATE_FAILED_UNLICENSED:\n                m_view.onStateChanged(ApkExpansionDownloadState.FAILED, stateString);\n                cleanupClientStub();\n                break;\n            case IDownloaderClient.STATE_PAUSED_BY_REQUEST:\n                m_view.onStateChanged(ApkExpansionDownloadState.PAUSED, stateString);\n                break;\n            case IDownloaderClient.STATE_PAUSED_NEED_CELLULAR_PERMISSION:\n            case IDownloaderClient.STATE_PAUSED_WIFI_DISABLED_NEED_CELLULAR_PERMISSION:\n            case IDownloaderClient.STATE_PAUSED_ROAMING:\n                m_view.onStateChanged(ApkExpansionDownloadState.PAUSED_NO_WIFI, stateString);\n                break;\n            case IDownloaderClient.STATE_FAILED_SDCARD_FULL:\n            case IDownloaderClient.STATE_PAUSED_SDCARD_UNAVAILABLE:\n                m_view.onStateChanged(ApkExpansionDownloadState.FAILED_NO_STORAGE, stateString);\n                cleanupClientStub();\n                break;\n            case IDownloaderClient.STATE_COMPLETED:\n                m_view.onStateChanged(ApkExpansionDownloadState.COMPLETE, stateString);\n                cleanupClientStub();\n                destroyView();\n                startCSActivity();\n                break;\n        }\n    }\n    /**\n     * Called when download progress updates.\n     *\n     * @author Ian Copland\n     *\n     * @param in_progress - A container for information on the progress of the download.\n     */\n    @Override public void onDownloadProgress(DownloadProgressInfo in_progress)\n    {\n        double progress = ((double)in_progress.mOverallProgress / (double)in_progress.mOverallTotal);\n        m_view.onProgressUpdated(progress);\n    }\n    /**\n     * Called when the application resumes. Disconnects the downloader client stub where\n     * appropriate.\n     *\n     * @author Ian Copland\n     */\n    @Override public void onStop()\n    {\n        if (m_downloaderClientStub != null)\n        {\n            m_downloaderClientStub.disconnect(this);\n        }\n\n        super.onStop();\n    }\n    /**\n     * Starts the expansion downloader on the main thread. Prior to calling this,\n     * isDownloadRequired() should be called to check if the download is required.\n     *\n     * This can be called from any thread.\n     *\n     * @author Ian Copland\n     */\n    private void startDownload()\n    {\n        deleteExpansionDirectory();\n        createView();\n\n        Intent notifierIntent = new Intent(this, getClass());\n        notifierIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);\n        PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notifierIntent, PendingIntent.FLAG_UPDATE_CURRENT);\n\n        int startResult = 0;\n        try\n        {\n            startResult = DownloaderClientMarshaller.startDownloadServiceIfRequired(this, pendingIntent, ApkExpansionDownloadService.class);\n        }\n        catch (PackageManager.NameNotFoundException e)\n        {\n            Logging.logFatal(ExceptionUtils.convertToString(e));\n        }\n\n        if (startResult != DownloaderClientMarshaller.NO_DOWNLOAD_REQUIRED)\n        {\n            m_downloaderClientStub = DownloaderClientMarshaller.CreateStub(this, ApkExpansionDownloadService.class);\n        }\n        else\n        {\n            String stateString = getString(Helpers.getDownloaderStringResourceIDFromState(IDownloaderClient.STATE_COMPLETED));\n            m_view.onStateChanged(ApkExpansionDownloadState.COMPLETE, stateString);\n            cleanupClientStub();\n            destroyView();\n            startCSActivity();\n        }\n    }\n    /**\n     * Disconnects the client stub if appropriate and the sets to null.\n     *\n     * @author Ian Copland\n     */\n    private void cleanupClientStub()\n    {\n        if (m_downloaderClientStub != null)\n        {\n            m_downloaderClientStub.disconnect(this);\n            m_downloaderClientStub = null;\n        }\n\n        m_remoteService = null;\n    }\n    /**\n     * Deletes the expansion directory and its contents if it exists, to be sure that there won't\n     * end up being multiple expansion files after the download.\n     *\n     * @author Ian Copland\n     */\n    private void deleteExpansionDirectory()\n    {\n        String expansionDirectory = StringUtils.standardiseDirectoryPath(Helpers.getSaveFilePath(this));\n        if (FileUtils.doesDirectoryExist(expansionDirectory) == true)\n        {\n            boolean success = FileUtils.removeDirectory(expansionDirectory);\n            assert (success == true) : \"Failed to delete expansion directory.\";\n        }\n    }\n    /**\n     * Creates the view which will render download progress, and send it the onInit() event.\n     *\n     * @author Ian Copland\n     */\n    private void createView()\n    {\n        assert (m_view == null) : \"View already exists!\";\n\n        m_view = ApkExpansionDownloadViewFactory.createView(this);\n        m_view.onInit();\n    }\n    /**\n     * Destroys the view, sending the onDestroy() event and setting to null.\n     *\n     * @author Ian Copland\n     */\n    private void destroyView()\n    {\n        assert (m_view != null) : \"View already null!\";\n\n        m_view.onDestroy();\n        m_view = null;\n    }\n    /**\n     * Starts the CSActivity, which proceeds into the rest of the application.\n     *\n     * @author Ian Copland\n     */\n    public void startCSActivity()\n    {\n        Intent csActivityIntent = new Intent(this, CSActivity.class);\n        startActivity(csActivityIntent);\n    }\n}\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/GooglePlay/Java/com/chilliworks/chillisource/networking/ApkExpansionDownloadAlarmReceiver.java",
    "content": "/**\n * ApkExpansionDownloadAlarmReceiver.java\n * ChilliSource\n * Created by Ian Copland on 23/04/2015.\n *\n * The MIT License (MIT)\n *\n * Copyright (c) 2015 Tag Games Limited\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.networking;\n\nimport android.content.BroadcastReceiver;\nimport android.content.Context;\nimport android.content.Intent;\nimport android.content.pm.PackageManager;\n\nimport com.chilliworks.chillisource.core.ExceptionUtils;\nimport com.chilliworks.chillisource.core.Logging;\nimport com.google.android.vending.expansion.downloader.DownloaderClientMarshaller;\n\n/**\n * An alarm receiver for the Apk Expansion Downloader.\n *\n * @author Ian Copland\n */\npublic final class ApkExpansionDownloadAlarmReceiver extends BroadcastReceiver\n{\n    /**\n     * @author Ian Copland\n     *\n     * @param in_context - The context\n     * @param in_intent - The intent\n     */\n    @Override public void onReceive(Context in_context, Intent in_intent)\n    {\n        try\n        {\n            DownloaderClientMarshaller.startDownloadServiceIfRequired(in_context, in_intent, ApkExpansionDownloadService.class);\n        }\n        catch (PackageManager.NameNotFoundException e)\n        {\n            Logging.logFatal(ExceptionUtils.convertToString(e));\n        }\n    }\n}\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/GooglePlay/Java/com/chilliworks/chillisource/networking/ApkExpansionDownloadService.java",
    "content": "/**\n * ApkExpansionDownloadService.java\n * ChilliSource\n * Created by Ian Copland on 22/04/2015.\n *\n * The MIT License (MIT)\n *\n * Copyright (c) 2015 Tag Games Limited\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.networking;\n\nimport com.chilliworks.chillisource.core.GooglePlayLicensing;\nimport com.google.android.vending.expansion.downloader.impl.DownloaderService;\n\n/**\n * The APK expansion downloader service.\n *\n * @author Ian Copland\n */\npublic final class ApkExpansionDownloadService extends DownloaderService\n{\n    private static final byte[] SALT = new byte[]\n    {\n        1, 43, -12, -1, -34, 68, -16, -12, 43, 2, -8, -4, 9, 5, -106, 107, -36, 45, -10, 32\n    };\n\n    /**\n     * @author Ian Copland\n     *\n     * @return The public key.\n     */\n    @Override public String getPublicKey()\n    {\n        return GooglePlayLicensing.getLvlPublicKey();\n    }\n    /**\n     * @author Ian Copland\n     *\n     * @return The salt\n     */\n    @Override public byte[] getSALT()\n    {\n        return SALT;\n    }\n    /**\n     * @author Ian Copland\n     *\n     * @return The Alarm Receiver name.\n     */\n    @Override public String getAlarmReceiverClassName()\n    {\n        return ApkExpansionDownloadAlarmReceiver.class.getName();\n    }\n}\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/GooglePlay/Java/com/chilliworks/chillisource/networking/ApkExpansionDownloadState.java",
    "content": "/**\n * ApkExpansionDownloadState.java\n * ChilliSource\n * Created by Ian Copland on 22/04/2015.\n *\n * The MIT License (MIT)\n *\n * Copyright (c) 2015 Tag Games Limited\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\n\npackage com.chilliworks.chillisource.networking;\n\n/**\n * A basic enum describing the different states of the Apk Expansion Download.\n *\n * @author Ian Copland\n */\npublic enum ApkExpansionDownloadState\n{\n    DOWNLOADING,\n    COMPLETE,\n    FAILED,\n    FAILED_NO_STORAGE,\n    PAUSED,\n    PAUSED_NO_WIFI\n}\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/GooglePlay/Java/com/chilliworks/chillisource/networking/ApkExpansionDownloadValidator.java",
    "content": "/**\n * ApkExpansionDownloadUtils.java\n * ChilliSource\n * Created by Ian Copland on 29/05/2015.\n *\n * The MIT License (MIT)\n *\n * Copyright (c) 2015 Tag Games Limited\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.networking;\n\nimport android.app.Activity;\n\nimport com.chilliworks.chillisource.core.ApkExpansionInfo;\nimport com.chilliworks.chillisource.core.ExceptionUtils;\nimport com.chilliworks.chillisource.core.FileUtils;\nimport com.chilliworks.chillisource.core.Logging;\nimport com.chilliworks.chillisource.core.StringUtils;\nimport com.google.android.vending.expansion.downloader.Helpers;\n\nimport org.json.JSONException;\nimport org.json.JSONObject;\n\nimport java.io.File;\n\n/**\n * A collection of convenience functions for the Apk Expansion Download functionality.\n *\n * @author Ian Copland\n */\npublic final class ApkExpansionDownloadValidator\n{\n    private static final String MAIN_EXPANSION_PREFIX = \"main.\";\n\n    /**\n     * Reads the Apk Expansion Config file and checks its contents versus the Expansion file on\n     * disk. If they are the same, no download is required. No download is required if there is\n     * no Apk Expansion config file.\n     *\n     * This can be called from any thread.\n     *\n     * @author Ian Copland\n     *\n     * @param in_activity - Any of the applications activities.\n     *\n     * @return Returns whether or not the expansion files need to be downloaded.\n     */\n    public static boolean isDownloadRequired(Activity in_activity)\n    {\n        int versionCode = calcExpansionVersionCode(in_activity);\n        if (ApkExpansionInfo.getVersionCode() != versionCode)\n        {\n            return true;\n        }\n\n        long fileSize = calcExpansionFileSize(in_activity, versionCode);\n        if (ApkExpansionInfo.getFileSize() != fileSize)\n        {\n            return true;\n        }\n\n        return false;\n    }\n    /**\n     * @author Ian Copland\n     *\n     * @param in_activity - The active Activity.\n     *\n     * @return The version code of the current expansion file. If the file doesn't exist, then\n     * this will return -1.\n     */\n    private static int calcExpansionVersionCode(Activity in_activity)\n    {\n        File directory = new File(ApkExpansionInfo.getDirectoryPath());\n\n        if (directory.exists() == false)\n        {\n            return -1;\n        }\n\n        File[] contents = directory.listFiles();\n        if (contents.length != 1)\n        {\n            if (contents.length > 1)\n            {\n                Logging.logError(\"The Apk Expansion directory contains more than 1 file!\");\n            }\n            return -1;\n        }\n\n        if (contents[0].isFile() == false)\n        {\n            Logging.logError(\"The Apk Expansion directory contains a directory.\");\n            return -1;\n        }\n\n        String fileName = contents[0].getName();\n        if (isMainExpansionFileName(in_activity, fileName) == false)\n        {\n            Logging.logError(\"The Apk Expansion directory contains a file which is not the main expansion file.\");\n            return -1;\n        }\n\n        //this is safe becuase it wouldn't have passed the previous check otherwise.\n        String versionCodeString = fileName.substring(MAIN_EXPANSION_PREFIX.length(), fileName.indexOf(\".\", MAIN_EXPANSION_PREFIX.length()));\n        int versionCode = 0;\n        try\n        {\n            versionCode = Integer.parseInt(versionCodeString);\n        }\n        catch (NumberFormatException e)\n        {\n            Logging.logError(\"Could not parse Apk Expansion file version code.\");\n            return -1;\n        }\n\n        return versionCode;\n    }\n    /**\n     * @author Ian Copland\n     *\n     * @param in_activity - The active Activity.\n     * @param in_fileName - The file name.\n     *\n     * @return Whether or not the given file name is a valid name for main expansion file.\n     */\n    private static boolean isMainExpansionFileName(Activity in_activity, String in_fileName)\n    {\n        if (in_fileName.startsWith(MAIN_EXPANSION_PREFIX) == false)\n        {\n            return false;\n        }\n\n        int nextPeriod = in_fileName.indexOf(\".\", MAIN_EXPANSION_PREFIX.length());\n        if (nextPeriod == -1)\n        {\n            return false;\n        }\n\n        //check that the version code contains a valid integer.\n        String versionCodeString = in_fileName.substring(MAIN_EXPANSION_PREFIX.length(), nextPeriod);\n        if (versionCodeString.matches(\"^-?\\\\d+$\") == false)\n        {\n            return false;\n        }\n\n        if (in_fileName.length() <= nextPeriod + 1)\n        {\n            return false;\n        }\n\n        String suffix = in_fileName.substring(nextPeriod + 1);\n        String intendedSuffix = in_activity.getPackageName() + \".obb\";\n        if (suffix.equals(intendedSuffix) == false)\n        {\n            return false;\n        }\n\n        return true;\n    }\n    /**\n     * @author Ian Copland\n     *\n     * @param in_activity - Any of the applications activities.\n     * @param in_versionCode - The version code of the expansion file.\n     *\n     * @return The size of the expansion file in bytes. Zero is returned if the file doesn't exist.\n     */\n    private static long calcExpansionFileSize(Activity in_activity, int in_versionCode)\n    {\n        String filePath = ApkExpansionInfo.getFilePath();\n        return FileUtils.getFileSize(filePath);\n    }\n}\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/GooglePlay/Java/com/chilliworks/chillisource/networking/ApkExpansionDownloadView.java",
    "content": "/**\n * ApkExpansionDownloadView.java\n * ChilliSource\n * Created by Ian Copland on 28/05/2015.\n *\n * The MIT License (MIT)\n *\n * Copyright (c) 2015 Tag Games Limited\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.networking;\n\n/**\n * A base class for the Apk Expansion Download View. This receives events from the download\n * activity which can be used to render a download screen.\n *\n * @author Ian Copland\n */\npublic abstract class ApkExpansionDownloadView\n{\n    private ApkExpansionDownloadActivity m_activity = null;\n\n    /**\n     * @author Ian Copland\n     *\n     * @param in_activity - The Apk expansion download activity.\n     */\n    protected ApkExpansionDownloadView(ApkExpansionDownloadActivity in_activity)\n    {\n        m_activity = in_activity;\n        assert m_activity != null : \"Must supply a non-null Apk Expansion Download Activity.\";\n    }\n    /**\n     * @author Ian Copland\n     *\n     * @return The Apk expansion download activity.\n     */\n    protected ApkExpansionDownloadActivity getActivity()\n    {\n        return m_activity;\n    }\n    /**\n     * Called when the view is first presented. This should perform any initialisation of the\n     * view.\n     *\n     * @author Ian Copland\n     */\n    protected abstract void onInit();\n    /**\n     * Called whenever the download state changes. The implementing class can use this to\n     * update the view to reflect the state of the download, i.e display failure, or a pause\n     * screen.\n     *\n     * @author Ian Copland\n     *\n     * @param in_state - The new state of the download.\n     * @param in_stateDescription - A user presentable description of the current download state.\n     * This is typically used to present useful error messages to users.\n     */\n    protected abstract void onStateChanged(ApkExpansionDownloadState in_state, String in_stateDescription);\n    /**\n     * Called as the download progress updates.\n     *\n     * @author Ian Copland\n     *\n     * @param in_progress - The fraction of the download that has been downloaded.\n     */\n    protected abstract void onProgressUpdated(double in_progress);\n    /**\n     * Called when the view is dismissed. This should perform any cleanup required by the view.\n     *\n     * @author Ian Copland\n     */\n    protected abstract void onDestroy();\n}\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/GooglePlay/Java/com/chilliworks/chillisource/networking/ApkExpansionDownloadViewFactory.java",
    "content": "/**\n * ApkExpansionDownloadViewFactory.java\n * ChilliSource\n * Created by Ian Copland on 09/07/2015.\n *\n * The MIT License (MIT)\n *\n * Copyright (c) 2015 Tag Games Limited\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.networking;\n\nimport android.content.pm.ApplicationInfo;\nimport android.content.pm.PackageManager;\n\nimport com.chilliworks.chillisource.core.ExceptionUtils;\nimport com.chilliworks.chillisource.core.Logging;\n\nimport java.lang.reflect.Constructor;\nimport java.lang.reflect.InvocationTargetException;\n\n/**\n * Provides a means to create new instances of the ApkExpansionDownloadView. By default the\n * DefaultApKExpansionDownloadView is created, but the user can override this to provide thier\n * own custom download view.\n *\n * @author Ian Copland\n */\nfinal class ApkExpansionDownloadViewFactory\n{\n    private static final String CUSTOM_APK_EXPANSION_DOWNLOADER_VIEW_KEY = \"apkExpansionDownloadView\";\n\n    /**\n     * Creates a new instance of the ApkExpansionDownloadView. If the AndroidManifest contains\n     * meta data for the key described by CUSTOM_APK_EXPANSION_DOWNLOADER_VIEW_KEY then an instance\n     * of this class is created. Otherwise, a new instance of DefaultApkExpansionDownloadView is\n     * created. Note that the class described in meta data must be fully qualified.\n     *\n     * @author Ian Copland\n     *\n     * @param in_activity - The current Apk Expansion download activity.\n     *\n     * @return The new instance of ApkExpansionDownloadView.\n     */\n    protected static ApkExpansionDownloadView createView(ApkExpansionDownloadActivity in_activity)\n    {\n        //Try to create a custom view.\n        String customViewName = \"\";\n        try\n        {\n            ApplicationInfo applicationInfo = in_activity.getPackageManager().getApplicationInfo(in_activity.getPackageName(), PackageManager.GET_META_DATA);\n            customViewName = applicationInfo.metaData.getString(CUSTOM_APK_EXPANSION_DOWNLOADER_VIEW_KEY);\n            if (customViewName != null && customViewName.isEmpty() == false)\n            {\n                return createView(customViewName, in_activity);\n            }\n        }\n        catch (PackageManager.NameNotFoundException e)\n        {\n            //If this is thrown, we should just return the default view, so do nothing.\n        }\n        catch (ClassNotFoundException e)\n        {\n            Logging.logVerbose(ExceptionUtils.convertToString(e));\n            Logging.logFatal(\"Could not create custom Apk Expansion Download View '\" + customViewName + \"' because the class doesn't exist.\");\n        }\n        catch (Exception e)\n        {\n            Logging.logVerbose(ExceptionUtils.convertToString(e));\n            Logging.logFatal(\"Could not create custom Apk Expansion Download View '\" + customViewName + \"' becuase an exception occured during instantiation.\");\n        }\n\n        //failing that, simply return the default view.\n        return new DefaultApkExpansionDownloadView(in_activity);\n    }\n    /**\n     * Creates an instance of the ApkExpansionDownloadView with the given name using reflection.\n     * The created class must have a constructor which takes the ApkExpansionDownloadActivity as\n     * a single parameter.\n     *\n     * @author Ian Copland\n     *\n     * @param in_customViewName - The name of the custom view.\n     * @param in_activity - The current Apk Expansion download activity.\n     *\n     * @return The new download view.\n     *\n     * @throws ClassNotFoundException - Will be thrown if the class doesn't exist.\n     * @throws IllegalAccessException - Thrown if the constructor cannot be accessed.\n     * @throws InvocationTargetException - Thrown if the constructor throws and exception.\n     * @throws InstantiationException - If the class cannot be instantiated because it's abstract\n     * or there is no suitable constructor.\n     */\n    private static ApkExpansionDownloadView createView(String in_customViewName, ApkExpansionDownloadActivity in_activity) throws ClassNotFoundException, IllegalAccessException, InvocationTargetException, InstantiationException\n    {\n        Class<?> customViewClass = Class.forName(in_customViewName);\n\n        //find an appropriate constructor.\n        Constructor[] constructors = customViewClass.getDeclaredConstructors();\n        for (int i = 0; i < constructors.length; i++)\n        {\n            if (constructors[i].getParameterTypes().length == 1 && constructors[i].getParameterTypes()[0].equals(ApkExpansionDownloadActivity.class))\n            {\n                return (ApkExpansionDownloadView)constructors[i].newInstance(in_activity);\n            }\n        }\n\n        throw new InstantiationException(\"Couldn't create class '\" + in_customViewName + \"' as it doesn't have a constructor which takes ApkExpansionDownloadActivity as its only argument.\");\n    }\n}\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/GooglePlay/Java/com/chilliworks/chillisource/networking/Base64.java",
    "content": "// Portions copyright 2002, Google, Inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n//     http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\npackage com.chilliworks.chillisource.networking;\n\n// This code was converted from code at http://iharder.sourceforge.net/base64/\n// Lots of extraneous features were removed.\n/* The original code said:\n * <p>\n * I am placing this code in the Public Domain. Do with it as you will.\n * This software comes with no guarantees or warranties but with\n * plenty of well-wishing instead!\n * Please visit\n * <a href=\"http://iharder.net/xmlizable\">http://iharder.net/xmlizable</a>\n * periodically to check for updates or to contribute improvements.\n * </p>\n *\n * @author Robert Harder\n * @author rharder@usa.net\n * @version 1.3\n */\n\n/**\n * Base64 converter class. This code is not a complete MIME encoder;\n * it simply converts binary data to base64 data and back.\n *\n * <p>Note {@link CharBase64} is a GWT-compatible implementation of this\n * class.\n */\npublic class Base64 {\n    /** Specify encoding (value is {@code true}). */\n    public final static boolean ENCODE = true;\n\n    /** Specify decoding (value is {@code false}). */\n    public final static boolean DECODE = false;\n\n    /** The equals sign (=) as a byte. */\n    private final static byte EQUALS_SIGN = (byte) '=';\n\n    /** The new line character (\\n) as a byte. */\n    private final static byte NEW_LINE = (byte) '\\n';\n\n    /**\n     * The 64 valid Base64 values.\n     */\n    private final static byte[] ALPHABET =\n        {(byte) 'A', (byte) 'B', (byte) 'C', (byte) 'D', (byte) 'E', (byte) 'F',\n        (byte) 'G', (byte) 'H', (byte) 'I', (byte) 'J', (byte) 'K',\n        (byte) 'L', (byte) 'M', (byte) 'N', (byte) 'O', (byte) 'P',\n        (byte) 'Q', (byte) 'R', (byte) 'S', (byte) 'T', (byte) 'U',\n        (byte) 'V', (byte) 'W', (byte) 'X', (byte) 'Y', (byte) 'Z',\n        (byte) 'a', (byte) 'b', (byte) 'c', (byte) 'd', (byte) 'e',\n        (byte) 'f', (byte) 'g', (byte) 'h', (byte) 'i', (byte) 'j',\n        (byte) 'k', (byte) 'l', (byte) 'm', (byte) 'n', (byte) 'o',\n        (byte) 'p', (byte) 'q', (byte) 'r', (byte) 's', (byte) 't',\n        (byte) 'u', (byte) 'v', (byte) 'w', (byte) 'x', (byte) 'y',\n        (byte) 'z', (byte) '0', (byte) '1', (byte) '2', (byte) '3',\n        (byte) '4', (byte) '5', (byte) '6', (byte) '7', (byte) '8',\n        (byte) '9', (byte) '+', (byte) '/'};\n\n    /**\n     * The 64 valid web safe Base64 values.\n     */\n    private final static byte[] WEBSAFE_ALPHABET =\n        {(byte) 'A', (byte) 'B', (byte) 'C', (byte) 'D', (byte) 'E', (byte) 'F',\n        (byte) 'G', (byte) 'H', (byte) 'I', (byte) 'J', (byte) 'K',\n        (byte) 'L', (byte) 'M', (byte) 'N', (byte) 'O', (byte) 'P',\n        (byte) 'Q', (byte) 'R', (byte) 'S', (byte) 'T', (byte) 'U',\n        (byte) 'V', (byte) 'W', (byte) 'X', (byte) 'Y', (byte) 'Z',\n        (byte) 'a', (byte) 'b', (byte) 'c', (byte) 'd', (byte) 'e',\n        (byte) 'f', (byte) 'g', (byte) 'h', (byte) 'i', (byte) 'j',\n        (byte) 'k', (byte) 'l', (byte) 'm', (byte) 'n', (byte) 'o',\n        (byte) 'p', (byte) 'q', (byte) 'r', (byte) 's', (byte) 't',\n        (byte) 'u', (byte) 'v', (byte) 'w', (byte) 'x', (byte) 'y',\n        (byte) 'z', (byte) '0', (byte) '1', (byte) '2', (byte) '3',\n        (byte) '4', (byte) '5', (byte) '6', (byte) '7', (byte) '8',\n        (byte) '9', (byte) '-', (byte) '_'};\n\n    /**\n     * Translates a Base64 value to either its 6-bit reconstruction value\n     * or a negative number indicating some other meaning.\n     **/\n    private final static byte[] DECODABET = {-9, -9, -9, -9, -9, -9, -9, -9, -9, // Decimal  0 -  8\n        -5, -5, // Whitespace: Tab and Linefeed\n        -9, -9, // Decimal 11 - 12\n        -5, // Whitespace: Carriage Return\n        -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, // Decimal 14 - 26\n        -9, -9, -9, -9, -9, // Decimal 27 - 31\n        -5, // Whitespace: Space\n        -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, // Decimal 33 - 42\n        62, // Plus sign at decimal 43\n        -9, -9, -9, // Decimal 44 - 46\n        63, // Slash at decimal 47\n        52, 53, 54, 55, 56, 57, 58, 59, 60, 61, // Numbers zero through nine\n        -9, -9, -9, // Decimal 58 - 60\n        -1, // Equals sign at decimal 61\n        -9, -9, -9, // Decimal 62 - 64\n        0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, // Letters 'A' through 'N'\n        14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, // Letters 'O' through 'Z'\n        -9, -9, -9, -9, -9, -9, // Decimal 91 - 96\n        26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, // Letters 'a' through 'm'\n        39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, // Letters 'n' through 'z'\n        -9, -9, -9, -9, -9 // Decimal 123 - 127\n        /*  ,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,     // Decimal 128 - 139\n        -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,     // Decimal 140 - 152\n        -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,     // Decimal 153 - 165\n        -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,     // Decimal 166 - 178\n        -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,     // Decimal 179 - 191\n        -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,     // Decimal 192 - 204\n        -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,     // Decimal 205 - 217\n        -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,     // Decimal 218 - 230\n        -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,     // Decimal 231 - 243\n        -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9         // Decimal 244 - 255 */\n    };\n\n    /** The web safe decodabet */\n    private final static byte[] WEBSAFE_DECODABET =\n        {-9, -9, -9, -9, -9, -9, -9, -9, -9, // Decimal  0 -  8\n        -5, -5, // Whitespace: Tab and Linefeed\n        -9, -9, // Decimal 11 - 12\n        -5, // Whitespace: Carriage Return\n        -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, // Decimal 14 - 26\n        -9, -9, -9, -9, -9, // Decimal 27 - 31\n        -5, // Whitespace: Space\n        -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, // Decimal 33 - 44\n        62, // Dash '-' sign at decimal 45\n        -9, -9, // Decimal 46-47\n        52, 53, 54, 55, 56, 57, 58, 59, 60, 61, // Numbers zero through nine\n        -9, -9, -9, // Decimal 58 - 60\n        -1, // Equals sign at decimal 61\n        -9, -9, -9, // Decimal 62 - 64\n        0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, // Letters 'A' through 'N'\n        14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, // Letters 'O' through 'Z'\n        -9, -9, -9, -9, // Decimal 91-94\n        63, // Underscore '_' at decimal 95\n        -9, // Decimal 96\n        26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, // Letters 'a' through 'm'\n        39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, // Letters 'n' through 'z'\n        -9, -9, -9, -9, -9 // Decimal 123 - 127\n        /*  ,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,     // Decimal 128 - 139\n        -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,     // Decimal 140 - 152\n        -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,     // Decimal 153 - 165\n        -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,     // Decimal 166 - 178\n        -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,     // Decimal 179 - 191\n        -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,     // Decimal 192 - 204\n        -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,     // Decimal 205 - 217\n        -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,     // Decimal 218 - 230\n        -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,     // Decimal 231 - 243\n        -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9         // Decimal 244 - 255 */\n        };\n\n    // Indicates white space in encoding\n    private final static byte WHITE_SPACE_ENC = -5;\n    // Indicates equals sign in encoding\n    private final static byte EQUALS_SIGN_ENC = -1;\n\n    /** Defeats instantiation. */\n    private Base64() {\n    }\n\n    /* ********  E N C O D I N G   M E T H O D S  ******** */\n\n    /**\n     * Encodes up to three bytes of the array <var>source</var>\n     * and writes the resulting four Base64 bytes to <var>destination</var>.\n     * The source and destination arrays can be manipulated\n     * anywhere along their length by specifying\n     * <var>srcOffset</var> and <var>destOffset</var>.\n     * This method does not check to make sure your arrays\n     * are large enough to accommodate <var>srcOffset</var> + 3 for\n     * the <var>source</var> array or <var>destOffset</var> + 4 for\n     * the <var>destination</var> array.\n     * The actual number of significant bytes in your array is\n     * given by <var>numSigBytes</var>.\n     *\n     * @param source the array to convert\n     * @param srcOffset the index where conversion begins\n     * @param numSigBytes the number of significant bytes in your array\n     * @param destination the array to hold the conversion\n     * @param destOffset the index where output will be put\n     * @param alphabet is the encoding alphabet\n     * @return the <var>destination</var> array\n     * @since 1.3\n     */\n    private static byte[] encode3to4(byte[] source, int srcOffset,\n            int numSigBytes, byte[] destination, int destOffset, byte[] alphabet) {\n        //           1         2         3\n        // 01234567890123456789012345678901 Bit position\n        // --------000000001111111122222222 Array position from threeBytes\n        // --------|    ||    ||    ||    | Six bit groups to index alphabet\n        //          >>18  >>12  >> 6  >> 0  Right shift necessary\n        //                0x3f  0x3f  0x3f  Additional AND\n\n        // Create buffer with zero-padding if there are only one or two\n        // significant bytes passed in the array.\n        // We have to shift left 24 in order to flush out the 1's that appear\n        // when Java treats a value as negative that is cast from a byte to an int.\n        int inBuff =\n                (numSigBytes > 0 ? ((source[srcOffset] << 24) >>> 8) : 0)\n                | (numSigBytes > 1 ? ((source[srcOffset + 1] << 24) >>> 16) : 0)\n                | (numSigBytes > 2 ? ((source[srcOffset + 2] << 24) >>> 24) : 0);\n\n        switch (numSigBytes) {\n            case 3:\n                destination[destOffset] = alphabet[(inBuff >>> 18)];\n                destination[destOffset + 1] = alphabet[(inBuff >>> 12) & 0x3f];\n                destination[destOffset + 2] = alphabet[(inBuff >>> 6) & 0x3f];\n                destination[destOffset + 3] = alphabet[(inBuff) & 0x3f];\n                return destination;\n            case 2:\n                destination[destOffset] = alphabet[(inBuff >>> 18)];\n                destination[destOffset + 1] = alphabet[(inBuff >>> 12) & 0x3f];\n                destination[destOffset + 2] = alphabet[(inBuff >>> 6) & 0x3f];\n                destination[destOffset + 3] = EQUALS_SIGN;\n                return destination;\n            case 1:\n                destination[destOffset] = alphabet[(inBuff >>> 18)];\n                destination[destOffset + 1] = alphabet[(inBuff >>> 12) & 0x3f];\n                destination[destOffset + 2] = EQUALS_SIGN;\n                destination[destOffset + 3] = EQUALS_SIGN;\n                return destination;\n            default:\n                return destination;\n        } // end switch\n    } // end encode3to4\n\n    /**\n     * Encodes a byte array into Base64 notation.\n     * Equivalent to calling\n     * {@code encodeBytes(source, 0, source.length)}\n     *\n     * @param source The data to convert\n     * @since 1.4\n     */\n    public static String encode(byte[] source) {\n        return encode(source, 0, source.length, ALPHABET, true);\n    }\n\n    /**\n     * Encodes a byte array into web safe Base64 notation.\n     *\n     * @param source The data to convert\n     * @param doPadding is {@code true} to pad result with '=' chars\n     *        if it does not fall on 3 byte boundaries\n     */\n    public static String encodeWebSafe(byte[] source, boolean doPadding) {\n        return encode(source, 0, source.length, WEBSAFE_ALPHABET, doPadding);\n    }\n\n    /**\n     * Encodes a byte array into Base64 notation.\n     *\n     * @param source the data to convert\n     * @param off offset in array where conversion should begin\n     * @param len length of data to convert\n     * @param alphabet the encoding alphabet\n     * @param doPadding is {@code true} to pad result with '=' chars\n     * if it does not fall on 3 byte boundaries\n     * @since 1.4\n     */\n    public static String encode(byte[] source, int off, int len, byte[] alphabet,\n            boolean doPadding) {\n        byte[] outBuff = encode(source, off, len, alphabet, Integer.MAX_VALUE);\n        int outLen = outBuff.length;\n\n        // If doPadding is false, set length to truncate '='\n        // padding characters\n        while (doPadding == false && outLen > 0) {\n            if (outBuff[outLen - 1] != '=') {\n                break;\n            }\n            outLen -= 1;\n        }\n\n        return new String(outBuff, 0, outLen);\n    }\n\n    /**\n     * Encodes a byte array into Base64 notation.\n     *\n     * @param source the data to convert\n     * @param off offset in array where conversion should begin\n     * @param len length of data to convert\n     * @param alphabet is the encoding alphabet\n     * @param maxLineLength maximum length of one line.\n     * @return the BASE64-encoded byte array\n     */\n    public static byte[] encode(byte[] source, int off, int len, byte[] alphabet,\n            int maxLineLength) {\n        int lenDiv3 = (len + 2) / 3; // ceil(len / 3)\n        int len43 = lenDiv3 * 4;\n        byte[] outBuff = new byte[len43 // Main 4:3\n                                  + (len43 / maxLineLength)]; // New lines\n\n        int d = 0;\n        int e = 0;\n        int len2 = len - 2;\n        int lineLength = 0;\n        for (; d < len2; d += 3, e += 4) {\n\n            // The following block of code is the same as\n            // encode3to4( source, d + off, 3, outBuff, e, alphabet );\n            // but inlined for faster encoding (~20% improvement)\n            int inBuff =\n                    ((source[d + off] << 24) >>> 8)\n                    | ((source[d + 1 + off] << 24) >>> 16)\n                    | ((source[d + 2 + off] << 24) >>> 24);\n            outBuff[e] = alphabet[(inBuff >>> 18)];\n            outBuff[e + 1] = alphabet[(inBuff >>> 12) & 0x3f];\n            outBuff[e + 2] = alphabet[(inBuff >>> 6) & 0x3f];\n            outBuff[e + 3] = alphabet[(inBuff) & 0x3f];\n\n            lineLength += 4;\n            if (lineLength == maxLineLength) {\n                outBuff[e + 4] = NEW_LINE;\n                e++;\n                lineLength = 0;\n            } // end if: end of line\n        } // end for: each piece of array\n\n        if (d < len) {\n            encode3to4(source, d + off, len - d, outBuff, e, alphabet);\n\n            lineLength += 4;\n            if (lineLength == maxLineLength) {\n                // Add a last newline\n                outBuff[e + 4] = NEW_LINE;\n                e++;\n            }\n            e += 4;\n        }\n\n        assert (e == outBuff.length);\n        return outBuff;\n    }\n\n\n    /* ********  D E C O D I N G   M E T H O D S  ******** */\n\n\n    /**\n     * Decodes four bytes from array <var>source</var>\n     * and writes the resulting bytes (up to three of them)\n     * to <var>destination</var>.\n     * The source and destination arrays can be manipulated\n     * anywhere along their length by specifying\n     * <var>srcOffset</var> and <var>destOffset</var>.\n     * This method does not check to make sure your arrays\n     * are large enough to accommodate <var>srcOffset</var> + 4 for\n     * the <var>source</var> array or <var>destOffset</var> + 3 for\n     * the <var>destination</var> array.\n     * This method returns the actual number of bytes that\n     * were converted from the Base64 encoding.\n     *\n     *\n     * @param source the array to convert\n     * @param srcOffset the index where conversion begins\n     * @param destination the array to hold the conversion\n     * @param destOffset the index where output will be put\n     * @param decodabet the decodabet for decoding Base64 content\n     * @return the number of decoded bytes converted\n     * @since 1.3\n     */\n    private static int decode4to3(byte[] source, int srcOffset,\n            byte[] destination, int destOffset, byte[] decodabet) {\n        // Example: Dk==\n        if (source[srcOffset + 2] == EQUALS_SIGN) {\n            int outBuff =\n                    ((decodabet[source[srcOffset]] << 24) >>> 6)\n                    | ((decodabet[source[srcOffset + 1]] << 24) >>> 12);\n\n            destination[destOffset] = (byte) (outBuff >>> 16);\n            return 1;\n        } else if (source[srcOffset + 3] == EQUALS_SIGN) {\n            // Example: DkL=\n            int outBuff =\n                    ((decodabet[source[srcOffset]] << 24) >>> 6)\n                    | ((decodabet[source[srcOffset + 1]] << 24) >>> 12)\n                    | ((decodabet[source[srcOffset + 2]] << 24) >>> 18);\n\n            destination[destOffset] = (byte) (outBuff >>> 16);\n            destination[destOffset + 1] = (byte) (outBuff >>> 8);\n            return 2;\n        } else {\n            // Example: DkLE\n            int outBuff =\n                    ((decodabet[source[srcOffset]] << 24) >>> 6)\n                    | ((decodabet[source[srcOffset + 1]] << 24) >>> 12)\n                    | ((decodabet[source[srcOffset + 2]] << 24) >>> 18)\n                    | ((decodabet[source[srcOffset + 3]] << 24) >>> 24);\n\n            destination[destOffset] = (byte) (outBuff >> 16);\n            destination[destOffset + 1] = (byte) (outBuff >> 8);\n            destination[destOffset + 2] = (byte) (outBuff);\n            return 3;\n        }\n    } // end decodeToBytes\n\n\n    /**\n     * Decodes data from Base64 notation.\n     *\n     * @param s the string to decode (decoded in default encoding)\n     * @return the decoded data\n     * @since 1.4\n     */\n    public static byte[] decode(String s) throws Base64DecoderException {\n        byte[] bytes = s.getBytes();\n        return decode(bytes, 0, bytes.length);\n    }\n\n    /**\n     * Decodes data from web safe Base64 notation.\n     * Web safe encoding uses '-' instead of '+', '_' instead of '/'\n     *\n     * @param s the string to decode (decoded in default encoding)\n     * @return the decoded data\n     */\n    public static byte[] decodeWebSafe(String s) throws Base64DecoderException {\n        byte[] bytes = s.getBytes();\n        return decodeWebSafe(bytes, 0, bytes.length);\n    }\n\n    /**\n     * Decodes Base64 content in byte array format and returns\n     * the decoded byte array.\n     *\n     * @param source The Base64 encoded data\n     * @return decoded data\n     * @since 1.3\n     * @throws Base64DecoderException\n     */\n    public static byte[] decode(byte[] source) throws Base64DecoderException {\n        return decode(source, 0, source.length);\n    }\n\n    /**\n     * Decodes web safe Base64 content in byte array format and returns\n     * the decoded data.\n     * Web safe encoding uses '-' instead of '+', '_' instead of '/'\n     *\n     * @param source the string to decode (decoded in default encoding)\n     * @return the decoded data\n     */\n    public static byte[] decodeWebSafe(byte[] source)\n            throws Base64DecoderException {\n        return decodeWebSafe(source, 0, source.length);\n    }\n\n    /**\n     * Decodes Base64 content in byte array format and returns\n     * the decoded byte array.\n     *\n     * @param source the Base64 encoded data\n     * @param off    the offset of where to begin decoding\n     * @param len    the length of characters to decode\n     * @return decoded data\n     * @since 1.3\n     * @throws Base64DecoderException\n     */\n    public static byte[] decode(byte[] source, int off, int len)\n            throws Base64DecoderException {\n        return decode(source, off, len, DECODABET);\n    }\n\n    /**\n     * Decodes web safe Base64 content in byte array format and returns\n     * the decoded byte array.\n     * Web safe encoding uses '-' instead of '+', '_' instead of '/'\n     *\n     * @param source the Base64 encoded data\n     * @param off    the offset of where to begin decoding\n     * @param len    the length of characters to decode\n     * @return decoded data\n     */\n    public static byte[] decodeWebSafe(byte[] source, int off, int len)\n            throws Base64DecoderException {\n        return decode(source, off, len, WEBSAFE_DECODABET);\n    }\n\n    /**\n     * Decodes Base64 content using the supplied decodabet and returns\n     * the decoded byte array.\n     *\n     * @param source the Base64 encoded data\n     * @param off the offset of where to begin decoding\n     * @param len the length of characters to decode\n     * @param decodabet the decodabet for decoding Base64 content\n     * @return decoded data\n     */\n    public static byte[] decode(byte[] source, int off, int len, byte[] decodabet)\n            throws Base64DecoderException {\n        int len34 = len * 3 / 4;\n        byte[] outBuff = new byte[2 + len34]; // Upper limit on size of output\n        int outBuffPosn = 0;\n\n        byte[] b4 = new byte[4];\n        int b4Posn = 0;\n        int i = 0;\n        byte sbiCrop = 0;\n        byte sbiDecode = 0;\n        for (i = 0; i < len; i++) {\n            sbiCrop = (byte) (source[i + off] & 0x7f); // Only the low seven bits\n            sbiDecode = decodabet[sbiCrop];\n\n            if (sbiDecode >= WHITE_SPACE_ENC) { // White space Equals sign or better\n                if (sbiDecode >= EQUALS_SIGN_ENC) {\n                    // An equals sign (for padding) must not occur at position 0 or 1\n                    // and must be the last byte[s] in the encoded value\n                    if (sbiCrop == EQUALS_SIGN) {\n                        int bytesLeft = len - i;\n                        byte lastByte = (byte) (source[len - 1 + off] & 0x7f);\n                        if (b4Posn == 0 || b4Posn == 1) {\n                            throw new Base64DecoderException(\n                                    \"invalid padding byte '=' at byte offset \" + i);\n                        } else if ((b4Posn == 3 && bytesLeft > 2)\n                                || (b4Posn == 4 && bytesLeft > 1)) {\n                            throw new Base64DecoderException(\n                                    \"padding byte '=' falsely signals end of encoded value \"\n                                            + \"at offset \" + i);\n                        } else if (lastByte != EQUALS_SIGN && lastByte != NEW_LINE) {\n                            throw new Base64DecoderException(\n                                    \"encoded value has invalid trailing byte\");\n                        }\n                        break;\n                    }\n\n                    b4[b4Posn++] = sbiCrop;\n                    if (b4Posn == 4) {\n                        outBuffPosn += decode4to3(b4, 0, outBuff, outBuffPosn, decodabet);\n                        b4Posn = 0;\n                    }\n                }\n            } else {\n                throw new Base64DecoderException(\"Bad Base64 input character at \" + i\n                        + \": \" + source[i + off] + \"(decimal)\");\n            }\n        }\n\n        // Because web safe encoding allows non padding base64 encodes, we\n        // need to pad the rest of the b4 buffer with equal signs when\n        // b4Posn != 0.  There can be at most 2 equal signs at the end of\n        // four characters, so the b4 buffer must have two or three\n        // characters.  This also catches the case where the input is\n        // padded with EQUALS_SIGN\n        if (b4Posn != 0) {\n            if (b4Posn == 1) {\n                throw new Base64DecoderException(\"single trailing character at offset \"\n                        + (len - 1));\n            }\n            b4[b4Posn++] = EQUALS_SIGN;\n            outBuffPosn += decode4to3(b4, 0, outBuff, outBuffPosn, decodabet);\n        }\n\n        byte[] out = new byte[outBuffPosn];\n        System.arraycopy(outBuff, 0, out, 0, outBuffPosn);\n        return out;\n    }\n}\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/GooglePlay/Java/com/chilliworks/chillisource/networking/Base64DecoderException.java",
    "content": "// Copyright 2002, Google, Inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n//     http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\npackage com.chilliworks.chillisource.networking;\n\n/**\n * Exception thrown when encountering an invalid Base64 input character.\n *\n * @author nelson\n */\npublic class Base64DecoderException extends Exception {\n    public Base64DecoderException() {\n        super();\n    }\n\n    public Base64DecoderException(String s) {\n        super(s);\n    }\n\n    private static final long serialVersionUID = 1L;\n}\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/GooglePlay/Java/com/chilliworks/chillisource/networking/DefaultApkExpansionDownloadView.java",
    "content": "/**\n * DefaultApkExpansionDownloadView.java\n * ChilliSource\n * Created by Ian Copland on 28/05/2015.\n *\n * The MIT License (MIT)\n *\n * Copyright (c) 2015 Tag Games Limited\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.networking;\n\nimport android.view.Gravity;\nimport android.widget.ProgressBar;\nimport android.widget.RelativeLayout;\nimport android.widget.TextView;\n\n/**\n * A default, basic implementation of the Apk Expansion Download View. This simply presents a black\n * screen with a download progress bar. If an error occurs, the bar is replaced with error text.\n *\n * If something more sophisticated is required this can be overridden with a custom implementation\n * of ApkExpansionDownloadView.\n *\n * @author Ian Copland\n */\nfinal class DefaultApkExpansionDownloadView extends ApkExpansionDownloadView\n{\n    private RelativeLayout m_layout = null;\n    private ProgressBar m_progressBar = null;\n    private TextView m_textView = null;\n    private boolean m_hasFailed = false;\n\n    /**\n     * Constructor. Declared protected so only related classes can instantiate it.\n     *\n     * @author Ian Copland\n     *\n     * @param in_activity - The Apk expansion download activity.\n     */\n    protected DefaultApkExpansionDownloadView(ApkExpansionDownloadActivity in_activity)\n    {\n        super(in_activity);\n    }\n    /**\n     * Called when the view is first presented. Initialises the view.\n     *\n     * @author Ian Copland\n     */\n    @Override protected void onInit()\n    {\n        final float PROGRESS_BAR_MARGIN_PERCENTAGE = 0.25f;\n\n        //The following uses the deprecated method: getWidth(). This should be changed to getSize() when the minimum SDK target is changed to API Level 13 or higher.\n        @SuppressWarnings(\"deprecation\") float displayWidth = (float)getActivity().getWindowManager().getDefaultDisplay().getWidth();\n\n        int progressBarMargin = (int)Math.round(displayWidth * PROGRESS_BAR_MARGIN_PERCENTAGE);\n        RelativeLayout.LayoutParams progressBarLayoutParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT);\n        progressBarLayoutParams.addRule(RelativeLayout.CENTER_IN_PARENT);\n        progressBarLayoutParams.setMargins(progressBarMargin, 0, progressBarMargin, 0);\n\n        m_progressBar = new ProgressBar(getActivity(), null, android.R.attr.progressBarStyleHorizontal);\n        m_progressBar.setLayoutParams(progressBarLayoutParams);\n\n        final float TEXT_VIEW_MARGIN_PERCENTAGE = 0.1f;\n        int textViewMargin = (int)Math.round(displayWidth * TEXT_VIEW_MARGIN_PERCENTAGE);\n        RelativeLayout.LayoutParams textViewLayoutParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT);\n        textViewLayoutParams.addRule(RelativeLayout.CENTER_IN_PARENT);\n        textViewLayoutParams.setMargins(textViewMargin, 0, textViewMargin, 0);\n\n        m_textView = new TextView(getActivity());\n        m_textView.setGravity(Gravity.CENTER);\n        m_textView.setLayoutParams(textViewLayoutParams);\n\n        m_layout = new RelativeLayout(getActivity());\n        m_layout.addView(m_progressBar);\n        getActivity().setContentView(m_layout);\n\n        m_hasFailed = false;\n    }\n    /**\n     * Called whenever the download state changes.\n     *\n     * @author Ian Copland\n     *\n     * @param in_state - The new state of the download.\n     * @param in_stateDescription - A user presentable description of the current download state.\n     * This is typically used to present useful error messages to users.\n     */\n    @Override protected void onStateChanged(ApkExpansionDownloadState in_state, String in_stateDescription)\n    {\n        if (m_hasFailed == false && (in_state == ApkExpansionDownloadState.FAILED || in_state == ApkExpansionDownloadState.FAILED_NO_STORAGE))\n        {\n            m_textView.setText(in_stateDescription);\n\n            m_layout.removeView(m_progressBar);\n            m_layout.addView(m_textView);\n\n            m_hasFailed = true;\n        }\n    }\n    /**\n     * Called as the download progress updates.\n     *\n     * @author Ian Copland\n     *\n     * @param in_progress - The fraction of the download that has been downloaded.\n     */\n    @Override protected void onProgressUpdated(double in_progress)\n    {\n        m_progressBar.setProgress((int)(in_progress * 100.0f));\n    }\n    /**\n     * Called when the view is dismissed. Cleans up the view.\n     *\n     * @author Ian Copland\n     */\n    @Override protected void onDestroy()\n    {\n        if (m_hasFailed == false)\n        {\n            m_layout.removeView(m_progressBar);\n        }\n        else\n        {\n            m_layout.removeView(m_textView);\n        }\n\n        m_textView = null;\n        m_layout = null;\n        m_progressBar = null;\n    }\n}\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/GooglePlay/Java/com/chilliworks/chillisource/networking/GooglePlayIAPNativeInterface.java",
    "content": "/**\n * IAPSystemNativeInterface.java\n * ChilliSource\n * Created by Scott Downie on 12/06/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.networking;\n\nimport java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.List;\n\nimport org.json.JSONException;\nimport org.json.JSONObject;\n\nimport android.content.Intent;\n\nimport com.chilliworks.chillisource.core.*;\n\npublic class GooglePlayIAPNativeInterface  extends com.chilliworks.chillisource.core.System\n{\n\t//--------------------------------------------------------------\n\t/// Member data\n\t//--------------------------------------------------------------\n    public static InterfaceId INTERFACE_ID = new InterfaceId();\n\t\n\tprivate static final int k_maxProductIDsPerRequest = 20;\n\t\n\tprivate IabHelper m_IABHelper = null;\n\tprivate boolean m_cancelProductDescRequest = false;\n\tprivate boolean m_isPurchasingEnabled = false;\n\tprivate boolean m_requestDescriptionsInProgress = false;\n\tprivate List<Purchase> m_currentPendingTransactions = new ArrayList<Purchase>();\n\tprivate Inventory m_inventory = null;\n\t\n\t//---------------------------------------------------------------------\n\t/// Native Methods\n\t//---------------------------------------------------------------------\n\tpublic native void NativeOnProductsDescriptionsRequestComplete(String[] in_IDs, String[] in_names, String[] in_descriptions, String[] in_formattedPrices, String[] in_currencyCodes, String[] in_unformattedPrices);\n\tpublic native void NativeOnTransactionStatusUpdated(int in_result, String in_productID, String in_transactionID, String in_receipt);\n\tpublic native void NativeOnTransactionClosed(String in_productID, String in_transactionID, boolean in_success);\n\t\n\t/**\n\t * Constructor\n\t * \n\t * @author Scott Downie\n\t */\n\tpublic GooglePlayIAPNativeInterface()\n\t{\n        init();\n\t}\n    /**\n     * Allows querying of whether or not the system implements the interface described by the\n     * given interface id.\n     *\n     * @author Ian Copland\n     *\n     * @param in_interfaceId - The interface id to check\n     *\n     * @return Whether the system implements the given interface\n     */\n    @Override public boolean isA(InterfaceId in_interfaceId)\n    {\n        return (in_interfaceId == INTERFACE_ID);\n    }\n\t/**\n\t * Init\n\t * \n\t * Prepares and starts the IAB system. This should be the first method\n\t * called and it should only be called once. \n\t * \n\t * @author Scott Downie\n\t */\n\tpublic void Init()\n\t{\n\t\tm_IABHelper = new IabHelper(CSApplication.get().getActivityContext(), GooglePlayLicensing.getLvlPublicKey());\n\t\tm_IABHelper.startSetup(new IabHelper.OnIabSetupFinishedListener()\n\t\t{\n\t\t\t@Override public void onIabSetupFinished(IabResult result) \n\t\t\t{\n\t\t\t\tif(result.isSuccess())\n\t\t\t\t{\n\t\t\t\t\tm_isPurchasingEnabled = true;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tm_isPurchasingEnabled = false;\n\t\t\t\t\tLogging.logError(\"Cannot setup Google Play IAB: \" + result.getMessage());\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\t/**\n\t * Request Product Descriptions\n\t * \n\t * Request the descriptions of all the products on the store\n\t * \n\t * @author HMcLaughlin\n\t * \n\t * @param in_productIDs\n\t */\n\tpublic void RequestProductDescriptions(final String[] in_productIDs)\n\t{\n\t\tif(m_requestDescriptionsInProgress && m_cancelProductDescRequest) // previously requested cancel but new request incoming\n\t\t{\n\t\t\t//This this will cause the system to received the previously requested product descriptions. This\n\t\t\t//means it will only work if the new request is identical to the previous one. \n\t\t\tm_cancelProductDescRequest = false;\n\t\t\treturn;\n\t\t}\n\t\telse if(m_requestDescriptionsInProgress) // just called twice, bail\n\t\t\treturn;\n\t\t\n\t\t\n\t\tif(m_inventory != null)\n\t\t{\n\t\t\tOnProductsRequestComplete(m_inventory, in_productIDs);\n\t\t\treturn;\n\t\t}\n\t\t\n\t\t// default flags for new request\n\t\tm_cancelProductDescRequest = false;\n\t\tm_requestDescriptionsInProgress = true;\n\t\t\t\n\t\tThread descriptionRequestThread = new Thread(new Runnable()\n\t\t{\n\t\t\t@Override public void run() \n\t\t\t{\n\t\t\t\tList<String> productIDs = new ArrayList<String>(Arrays.asList(in_productIDs));\n\t\t\t\t\n\t\t\t\ttry \n\t\t\t\t{\n\t\t\t\t\tInventory itemsInventory = null;\n\t\t\t\t\t\n\t\t\t\t\twhile(productIDs.size() > 0)\n\t\t\t\t\t{\n\t\t\t\t\t\t//Gets a sublist of max size|listsize\n\t\t\t\t\t\tArrayList<String> idBatch = new ArrayList<String>(productIDs.subList(0, Math.min(k_maxProductIDsPerRequest, productIDs.size())));\n\t\t\t\t\t\t\n\t\t\t\t\t\t//Remove the sublist from the master list\n\t\t\t\t\t\tproductIDs.removeAll(idBatch);\n\t\t\t\t\t\t\n\t\t\t\t\t\t//Make request with the sublist, this is a blocking call\n\t\t\t\t\t\tInventory batchItems = m_IABHelper.queryInventory(true, idBatch);\n\t\t\t\t\t\t\n\t\t\t\t\t\tif(batchItems != null)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t//Merge the inventory contents\n\t\t\t\t\t\t\titemsInventory = MergeInventories(itemsInventory, batchItems);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse \n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tLogging.logError(\"Could not retrieve batch items - \" + idBatch);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tm_requestDescriptionsInProgress = false;\n\t\t\t\t\t\n\t\t\t\t\tif(m_cancelProductDescRequest)\n\t\t\t\t\t\treturn;\n\t\t\t\t\t\n\t\t\t\t\tm_inventory = itemsInventory;\n\t\t\t\t\t\n\t\t\t\t\tOnProductsRequestComplete(m_inventory, in_productIDs);\n\t\t\t\t} \n\t\t\t\tcatch (IabException in_exception) \n\t\t\t\t{\n\t\t\t\t\tLogging.logError(\"Cannot query Google IAB inventory: \" + in_exception.getMessage());\n\t\t\t\t\tOnProductsRequestComplete(null, in_productIDs);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\t\n\t\tdescriptionRequestThread.start();\n    }\n\t/**\n\t * Merges the contents of two Inventories\n\t * \n\t * @author HMcLaughlin\n\t * \n\t * @param Inventory to combine\n\t * @param Inventory to combine\n\t * \n\t * @return Merged Inventory\n\t */\n\tprivate Inventory MergeInventories(Inventory in_lhs, Inventory in_rhs)\n\t{\n\t\tInventory mergedInventory = new Inventory();\n\t\t\n\t\tif(in_lhs != null)\n\t\t{\n\t\t\tmergedInventory.mPurchaseMap.putAll(in_lhs.mPurchaseMap);\n\t\t\tmergedInventory.mSkuMap.putAll(in_lhs.mSkuMap);\n\t\t}\n\t\t\n\t\tif(in_rhs != null)\n\t\t{\n\t\t\tmergedInventory.mPurchaseMap.putAll(in_rhs.mPurchaseMap);\n\t\t\tmergedInventory.mSkuMap.putAll(in_rhs.mSkuMap);\n\t\t}\n\t\t\n\t\treturn mergedInventory;\n\t}\n\t/**\n\t * On Products Request Complete\n\t * \n\t * Triggered when the products description request completes\n\t * \n\t * @author Scott Downie\n\t * \n\t * @param Inventory\n\t * @param Product IDs\n\t */\n    public void OnProductsRequestComplete(Inventory in_inventory, final String[] in_productIDs) \n    {\n\t\tList<IAPProductDescription> results = new ArrayList<IAPProductDescription>();\n        List<String> currencyCodesList = new ArrayList<String>();\n        List<String> unformattedPricesList = new ArrayList<String>();\n\n\t\tif(m_inventory != null)\n\t\t{\n\t\t\tfor(int i=0; i<in_productIDs.length; ++i)\n\t\t\t{\n\t\t\t\tSkuDetails details = in_inventory.getSkuDetails(in_productIDs[i]);\n\t\t\t\tif(details != null)\n\t\t\t\t{\n\t\t\t\t\tIAPProductDescription desc = new IAPProductDescription();\n\t\t\t\t\tdesc.ID = details.getSku();\n\t\t\t\t\tdesc.Name = details.getTitle();\n\t\t\t\t\tdesc.Description = details.getDescription();\n\t\t\t\t\tdesc.FormattedPrice = details.getPrice();\n                    results.add(desc);\n\n                    String currencyCode = details.getPriceCurrencyCode();\n                    currencyCodesList.add(currencyCode);\n\n                    String unformattedPrice = Double.toString((double)details.getPriceAmountMicros() / 1000000.0);\n                    unformattedPricesList.add(unformattedPrice);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n        int resultsSize = results.size();\n    \tString[] ids = new String[resultsSize];\n    \tString[] names = new String[resultsSize];\n    \tString[] descriptions = new String[resultsSize];\n    \tString[] formattedPrices = new String[resultsSize];\n        String[] currencyCodes = new String[resultsSize];\n        String[] unformattedPrices = new String[resultsSize];\n\n    \tfor (int i = 0; i < resultsSize; ++i)\n    \t{\n    \t\tids[i] = results.get(i).ID;\n    \t\tnames[i] = results.get(i).Name;\n    \t\tdescriptions[i] = results.get(i).Description;\n            formattedPrices[i] = results.get(i).FormattedPrice;\n            currencyCodes[i] = currencyCodesList.get(i);\n            unformattedPrices[i] = unformattedPricesList.get(i);\n    \t}\n  \n    \tNativeOnProductsDescriptionsRequestComplete(ids, names, descriptions, formattedPrices, currencyCodes, unformattedPrices);\n    }\n    /**\n\t * Cancel Product Descriptions Request\n\t * \n\t * Prevent the delegate being called with descriptions and\n     * attempt to cancel the pending request\n\t * \n\t * @author Scott Downie\n\t */\n    public void CancelProductDescriptionsRequest()\n    {\n    \tm_cancelProductDescRequest = true;\n    }\n    /**\n\t * Is Purchasing Enabled\n\t * \n\t * @author Scott Downie\n\t * \n\t * @return whether or not IAB V3 is supported on this device/OS\n\t */\n\tpublic boolean IsPurchasingEnabled()\n\t{\n\t\treturn m_isPurchasingEnabled;\n\t}\n\t /**\n\t * Get Purchase From Inventory\n\t * \n\t * @author Scott Downie\n\t * \n\t * @param Product ID\n\t * \n\t * @return The product if owned by the user or null\n\t */\n\tprivate Purchase GetPurchaseFromInventory(String in_productID)\n\t{\n\t\tif(m_inventory == null)\n\t\t\treturn null;\n\t\t\n\t\treturn m_inventory.getPurchase(in_productID);\n\t}\n\t/**\n\t * Request Product Purchase\n\t * \n\t * Start a transaction of an object with the given product ID.\n\t * The transaction listener will receive updates on the transaction\n\t * status\n\t *  \n\t * @author Scott Downie\n\t * \n\t * @param Product ID\n\t * @param Type (managed = 0 or unmanaged = 1 (from java interface))\n\t */\n\tpublic void RequestProductPurchase(final String in_productID, final int in_type)\n\t{\n\t\tCSApplication.get().scheduleUIThreadTask(new Runnable()\n\t\t{\n\t\t\t@Override public void run() \n\t\t\t{\n\t\t\t\tIabHelper.OnIabPurchaseFinishedListener listener = new IabHelper.OnIabPurchaseFinishedListener()\n\t\t\t\t{\n\t\t\t\t\t@Override public void onIabPurchaseFinished(IabResult in_result, Purchase in_info) \n\t\t\t\t\t{\n\t\t\t\t\t\tint resultStatus = IAPTransactionDescription.SUCCEEDED;\n\n\t\t\t\t\t\tif(in_result.isFailure())\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tLogging.logError(\"Google IAB purchase error: \" + in_result.getMessage() + \" for product: \" + in_productID);\n\n\t\t\t\t\t\t\tswitch(in_result.getResponse())\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcase IabHelper.BILLING_RESPONSE_RESULT_USER_CANCELED:\n\t\t\t\t\t\t\tcase IabHelper.IABHELPER_USER_CANCELLED:\n\t\t\t\t\t\t\t\tresultStatus = IAPTransactionDescription.CANCELLED;\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\tcase IabHelper.BILLING_RESPONSE_RESULT_ITEM_ALREADY_OWNED:\n\t\t\t\t\t\t\t\tresultStatus = IAPTransactionDescription.FAILED;\n\t\t\t\t\t\t\t\tin_info = GetPurchaseFromInventory(in_productID);\n\n\t\t\t\t\t\t\t\tif(in_info != null)\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t//If this is a managed purchase then we are simply restoring the item\n\t\t\t\t\t\t\t\t\tif(in_info.getDeveloperPayload().compareTo(\"managed\") == 0)\n\t\t\t\t\t\t\t\t\t\tresultStatus = IAPTransactionDescription.RESTORED;\n\t\t\t\t\t\t\t\t\t//If this is unmanaged then we are resuming an incomplete purchase\n\t\t\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t\t\tresultStatus = IAPTransactionDescription.RESUMED;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\t\tresultStatus = IAPTransactionDescription.FAILED;\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tOnTransactionStatusUpdated(resultStatus, in_info, in_productID);\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t\t\n\t\t\t\t//This uses an arbitrary value because the Google docs tell me to. The value represents the request code\n\t\t\t\tfinal int MANAGED = 0;\n\t\t\t\tfinal int UNMANAGED = 1;\n\t\t\t\t\n\t\t\t\tString payload = \"unmanaged\";\n\t\t\t\tswitch(in_type)\n\t\t\t\t{\n\t\t\t\t\tcase MANAGED:\n\t\t\t\t\t\tpayload = \"managed\";\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase UNMANAGED:\n\t\t\t\t\t\tpayload = \"unmanaged\";\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tm_IABHelper.launchPurchaseFlow(CSApplication.get().getActivity(), in_productID, 250102680, listener, payload);\n\t\t\t}\n\t\t});\n\t}\n\t/**\n\t * On Transaction Status Updated\n\t * \n\t * Is triggered whenever the status of a transaction changes i.e.\n\t * completes or fails. This can be called at any point once the\n\t * listener is attached and can be used to push through older \n\t * outstanding transactions\n\t *  \n\t * @author Scott Downie\n\t * \n\t * @param Result\n\t * @param Purchase\n\t * @param Product ID\n\t */\n\tpublic void OnTransactionStatusUpdated(int in_result, Purchase in_purchase, String in_productID) \n\t{\n\t\tif(in_purchase != null)\n\t\t{\n\t\t\tm_currentPendingTransactions.add(in_purchase);\n\t\t\t\n\t\t\tJSONObject jsonSig = new JSONObject();\n        \ttry \n        \t{\n        \t\tjsonSig.put(\"SignedData\", in_purchase.getOriginalJson());\n\t\t\t\tjsonSig.put(\"Signature\", in_purchase.getSignature());\n\t\t\t}\n        \tcatch (JSONException e) \n\t\t\t{\n\t\t\t\te.printStackTrace();\n\t\t\t}\n     \n\t\t\tNativeOnTransactionStatusUpdated(in_result, in_productID, in_purchase.getOrderId(), jsonSig.toString());\n\t\t}\n\t\telse\n\t\t{\n\t\t\tNativeOnTransactionStatusUpdated(in_result, in_productID, \"\", \"\");\n\t\t}\n\t}\n\t/**\n\t * Close Transaction\n\t * \n\t * Consumes the transaction from the purchase list so that it may\n\t * be purchased again\n\t *  \n\t * @author Scott Downie\n\t * \n\t * @param Product ID\n\t * @param Transaction ID\n\t */\n\tpublic void CloseTransaction(final String in_productID, final String in_transactionID)\n\t{\n\t\tCSApplication.get().scheduleUIThreadTask(new Runnable()\n\t\t{\n\t\t\t@Override public void run() \n\t\t\t{\n\t\t\t\tint count = 0;\n\t\t\t\tfor(Purchase purchase : m_currentPendingTransactions)\n\t\t\t\t{\n\t\t\t\t\tif(purchase.getOrderId().compareTo(in_transactionID) == 0)\n\t\t\t\t\t{\n\t\t\t\t\t\t//Only consume consumables\n\t\t\t\t\t\tif(purchase.getDeveloperPayload().compareTo(\"unmanaged\") == 0)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tm_IABHelper.consumeAsync(purchase, new IabHelper.OnConsumeFinishedListener()\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t@Override public void onConsumeFinished(Purchase in_purchase, IabResult in_result) \n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tboolean success = in_result.isFailure() == false;\n\t\t\t\t\t\t\t\t\tif(success == false)\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tLogging.logError(\"Google IAB consume error: \" + in_result.getMessage() + \" for product: \" + in_purchase.getSku());\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\tNativeOnTransactionClosed(in_productID, in_transactionID, success);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tm_currentPendingTransactions.remove(count);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tNativeOnTransactionClosed(in_productID, in_transactionID, true);\n\t\t\t}\n\t\t});\n\t}\n\t/**\n\t * Restore Pending Managed Transactions\n\t * \n\t * Restore any pending transactions from the last session\n\t *  \n\t * @author Scott Downie\n\t * \n\t * @param List of managed pending transactions\n\t */\n\tpublic void RestorePendingManagedTransactions(final String[] in_pendingManagedTransactionIDs)\n\t{\n\t\tif(m_inventory == null)\n\t\t\treturn;\n\t\t\n\t\tfor(String transactionID : in_pendingManagedTransactionIDs)\n\t\t{\n\t\t\tList<Purchase> purchases = m_inventory.getAllPurchases();\n\t\t\t\n\t\t\tPurchase pendingPurchase = null;\n\t\t\t\n\t\t\tfor(Purchase purchase : purchases)\n\t\t\t{\n\t\t\t\tif((purchase.getDeveloperPayload().compareTo(\"managed\") == 0) && (purchase.getOrderId().compareTo(transactionID) == 0))\n\t\t\t\t{\n\t\t\t\t\tpendingPurchase = purchase;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tif(pendingPurchase != null)\n\t\t\t{\n\t\t\t\tOnTransactionStatusUpdated(IAPTransactionDescription.RESUMED, pendingPurchase, pendingPurchase.getSku());\n\t\t\t}\n\t\t}\n\t}\n\t/**\n\t * Restore Pending Unmanaged Transactions\n\t * \n\t * Restore any pending transactions from the last session\n\t *  \n\t * @author Scott Downie\n\t */\n\tpublic void RestorePendingUnmanagedTransactions()\n\t{\n\t\t//Loop through the purchase list and pass on any managed products as new transactions but with the original receipts\n\t\tif(m_inventory == null)\n\t\t\treturn;\n\t\t\n\t\tList<Purchase> purchases = m_inventory.getAllPurchases();\n\t\t\n\t\tfor(Purchase purchase : purchases)\n\t\t{\n\t\t\t//If any consumables are in the list then they have no been consumed and are pending\n\t\t\tif(purchase.getDeveloperPayload().compareTo(\"unmanaged\") == 0)\n\t\t\t{\n\t\t\t\tm_currentPendingTransactions.add(purchase);\n\n\t\t\t\t//Apparently 0 is good, 1 is cancelled and 2 is refunded\n\t\t\t\tswitch(purchase.getPurchaseState())\n\t\t\t\t{\n\t\t\t\tcase 0:\n\t\t\t\t\tOnTransactionStatusUpdated(IAPTransactionDescription.RESUMED, purchase, purchase.getSku());\n\t\t\t\t\tbreak;\n\t\t\t\tcase 1:\n\t\t\t\t\tOnTransactionStatusUpdated(IAPTransactionDescription.CANCELLED, purchase, purchase.getSku());\n\t\t\t\t\tbreak;\n\t\t\t\tcase 2:\n\t\t\t\t\tOnTransactionStatusUpdated(IAPTransactionDescription.REFUNDED, purchase, purchase.getSku());\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\t/**\n\t * Restore Managed Purchases\n\t * \n\t * Restores all previous managed purchase by injecting them as new\n\t * transactions\n\t *  \n\t * @author Scott Downie\n\t */\n\tpublic void RestoreManagedPurchases()\n\t{\n\t\t//Loop through the purchase list and pass on any managed products as new transactions but with the original receipts\n\t\tif(m_inventory == null)\n\t\t{\n\t\t\tLogging.logError(\"IAPSystem: Products must be registered and requested before any other actions\");\n\t\t\tthrow new NullPointerException(\"Products must be registered and requested before any other actions\");\n\t\t}\n\t\t\n\t\tList<Purchase> purchases = m_inventory.getAllPurchases();\n\t\t\n\t\tfor(Purchase purchase : purchases)\n\t\t{\n\t\t\tif(purchase.getDeveloperPayload().compareTo(\"managed\") == 0)\n\t\t\t{\n\t\t\t\t//Apparently 0 is good, 1 is cancelled and 2 is refunded\n\t\t\t\tswitch(purchase.getPurchaseState())\n\t\t\t\t{\n\t\t\t\tcase 0:\n\t\t\t\t\tOnTransactionStatusUpdated(IAPTransactionDescription.RESTORED, purchase, purchase.getSku());\n\t\t\t\t\tbreak;\n\t\t\t\tcase 1:\n\t\t\t\t\tOnTransactionStatusUpdated(IAPTransactionDescription.CANCELLED, purchase, purchase.getSku());\n\t\t\t\t\tbreak;\n\t\t\t\tcase 2:\n\t\t\t\t\tOnTransactionStatusUpdated(IAPTransactionDescription.REFUNDED, purchase, purchase.getSku());\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\t/**\n\t * On Destroy\n\t * \n\t * Called when the ChilliSource activity is destroyed.\n\t *  \n\t * @author Scott Downie\n\t */\n\t@Override public void onDestroy()\n\t{\n\t\tif(m_IABHelper != null)\n\t\t{\n\t\t\tm_IABHelper.dispose();\n\t\t\tm_IABHelper = null;\n\t\t}\n\t}\n\t/**\n\t * On Activity Result\n\t * \n\t * Called when the ChilliSource activity is \"onActivityResult\" is called.\n\t *  \n\t * @author Scott Downie\n\t */\n\t@Override public void onActivityResult(int requestCode, int resultCode, Intent data)\n\t{\n\t\tif(m_IABHelper != null)\n\t\t{\n\t\t\tm_IABHelper.handleActivityResult(requestCode, resultCode, data);\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/GooglePlay/Java/com/chilliworks/chillisource/networking/IabException.java",
    "content": "/* Copyright (c) 2012 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.chilliworks.chillisource.networking;\n\n/**\n * Exception thrown when something went wrong with in-app billing.\n * An IabException has an associated IabResult (an error).\n * To get the IAB result that caused this exception to be thrown,\n * call {@link #getResult()}.\n */\n@SuppressWarnings(\"serial\")\npublic class IabException extends Exception {\n    IabResult mResult;\n\n    public IabException(IabResult r) {\n        this(r, null);\n    }\n    public IabException(int response, String message) {\n        this(new IabResult(response, message));\n    }\n    public IabException(IabResult r, Exception cause) {\n        super(r.getMessage(), cause);\n        mResult = r;\n    }\n    public IabException(int response, String message, Exception cause) {\n        this(new IabResult(response, message), cause);\n    }\n\n    /** Returns the IAB result (error) that this exception signals. */\n    public IabResult getResult() { return mResult; }\n}"
  },
  {
    "path": "Source/CSBackend/Platform/Android/GooglePlay/Java/com/chilliworks/chillisource/networking/IabHelper.java",
    "content": "/* Copyright (c) 2012 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.chilliworks.chillisource.networking;\n\nimport android.app.Activity;\nimport android.app.PendingIntent;\nimport android.content.ComponentName;\nimport android.content.Context;\nimport android.content.Intent;\nimport android.content.IntentSender.SendIntentException;\nimport android.content.ServiceConnection;\nimport android.os.Bundle;\nimport android.os.Handler;\nimport android.os.IBinder;\nimport android.os.RemoteException;\nimport android.text.TextUtils;\nimport android.util.Log;\n\nimport com.android.vending.billing.IInAppBillingService;\n\nimport org.json.JSONException;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\n\n/**\n * Provides convenience methods for in-app billing. You can create one instance of this\n * class for your application and use it to process in-app billing operations.\n * It provides synchronous (blocking) and asynchronous (non-blocking) methods for\n * many common in-app billing operations, as well as automatic signature\n * verification.\n *\n * After instantiating, you must perform setup in order to start using the object.\n * To perform setup, call the {@link #startSetup} method and provide a listener;\n * that listener will be notified when setup is complete, after which (and not before)\n * you may call other methods.\n *\n * After setup is complete, you will typically want to request an inventory of owned\n * items and subscriptions. See {@link #queryInventory}, {@link #queryInventoryAsync}\n * and related methods.\n *\n * When you are done with this object, don't forget to call {@link #dispose}\n * to ensure proper cleanup. This object holds a binding to the in-app billing\n * service, which will leak unless you dispose of it correctly. If you created\n * the object on an Activity's onCreate method, then the recommended\n * place to dispose of it is the Activity's onDestroy method.\n *\n * A note about threading: When using this object from a background thread, you may\n * call the blocking versions of methods; when using from a UI thread, call\n * only the asynchronous versions and handle the results via callbacks.\n * Also, notice that you can only call one asynchronous operation at a time;\n * attempting to start a second asynchronous operation while the first one\n * has not yet completed will result in an exception being thrown.\n *\n * @author Bruno Oliveira (Google)\n *\n */\npublic class IabHelper {\n    // Is debug logging enabled?\n    boolean mDebugLog = false;\n    String mDebugTag = \"IabHelper\";\n\n    // Is setup done?\n    boolean mSetupDone = false;\n\n    // Has this object been disposed of? (If so, we should ignore callbacks, etc)\n    boolean mDisposed = false;\n\n    // Are subscriptions supported?\n    boolean mSubscriptionsSupported = false;\n\n    // Is an asynchronous operation in progress?\n    // (only one at a time can be in progress)\n    boolean mAsyncInProgress = false;\n\n    // (for logging/debugging)\n    // if mAsyncInProgress == true, what asynchronous operation is in progress?\n    String mAsyncOperation = \"\";\n\n    // Context we were passed during initialization\n    Context mContext;\n\n    // Connection to the service\n    IInAppBillingService mService;\n    ServiceConnection mServiceConn;\n\n    // The request code used to launch purchase flow\n    int mRequestCode = -1;\n\n    // The item type of the current purchase flow\n    String mPurchasingItemType;\n\n    // Public key for verifying signature, in base64 encoding\n    String mSignatureBase64 = null;\n\n    // Billing response codes\n    public static final int BILLING_RESPONSE_RESULT_OK = 0;\n    public static final int BILLING_RESPONSE_RESULT_USER_CANCELED = 1;\n    public static final int BILLING_RESPONSE_RESULT_BILLING_UNAVAILABLE = 3;\n    public static final int BILLING_RESPONSE_RESULT_ITEM_UNAVAILABLE = 4;\n    public static final int BILLING_RESPONSE_RESULT_DEVELOPER_ERROR = 5;\n    public static final int BILLING_RESPONSE_RESULT_ERROR = 6;\n    public static final int BILLING_RESPONSE_RESULT_ITEM_ALREADY_OWNED = 7;\n    public static final int BILLING_RESPONSE_RESULT_ITEM_NOT_OWNED = 8;\n\n    // IAB Helper error codes\n    public static final int IABHELPER_ERROR_BASE = -1000;\n    public static final int IABHELPER_REMOTE_EXCEPTION = -1001;\n    public static final int IABHELPER_BAD_RESPONSE = -1002;\n    public static final int IABHELPER_VERIFICATION_FAILED = -1003;\n    public static final int IABHELPER_SEND_INTENT_FAILED = -1004;\n    public static final int IABHELPER_USER_CANCELLED = -1005;\n    public static final int IABHELPER_UNKNOWN_PURCHASE_RESPONSE = -1006;\n    public static final int IABHELPER_MISSING_TOKEN = -1007;\n    public static final int IABHELPER_UNKNOWN_ERROR = -1008;\n    public static final int IABHELPER_SUBSCRIPTIONS_NOT_AVAILABLE = -1009;\n    public static final int IABHELPER_INVALID_CONSUMPTION = -1010;\n\n    // Keys for the responses from InAppBillingService\n    public static final String RESPONSE_CODE = \"RESPONSE_CODE\";\n    public static final String RESPONSE_GET_SKU_DETAILS_LIST = \"DETAILS_LIST\";\n    public static final String RESPONSE_BUY_INTENT = \"BUY_INTENT\";\n    public static final String RESPONSE_INAPP_PURCHASE_DATA = \"INAPP_PURCHASE_DATA\";\n    public static final String RESPONSE_INAPP_SIGNATURE = \"INAPP_DATA_SIGNATURE\";\n    public static final String RESPONSE_INAPP_ITEM_LIST = \"INAPP_PURCHASE_ITEM_LIST\";\n    public static final String RESPONSE_INAPP_PURCHASE_DATA_LIST = \"INAPP_PURCHASE_DATA_LIST\";\n    public static final String RESPONSE_INAPP_SIGNATURE_LIST = \"INAPP_DATA_SIGNATURE_LIST\";\n    public static final String INAPP_CONTINUATION_TOKEN = \"INAPP_CONTINUATION_TOKEN\";\n\n    // Item types\n    public static final String ITEM_TYPE_INAPP = \"inapp\";\n    public static final String ITEM_TYPE_SUBS = \"subs\";\n\n    // some fields on the getSkuDetails response bundle\n    public static final String GET_SKU_DETAILS_ITEM_LIST = \"ITEM_ID_LIST\";\n    public static final String GET_SKU_DETAILS_ITEM_TYPE_LIST = \"ITEM_TYPE_LIST\";\n\n    /**\n     * Creates an instance. After creation, it will not yet be ready to use. You must perform\n     * setup by calling {@link #startSetup} and wait for setup to complete. This constructor does not\n     * block and is safe to call from a UI thread.\n     *\n     * @param ctx Your application or Activity context. Needed to bind to the in-app billing service.\n     * @param base64PublicKey Your application's public key, encoded in base64.\n     *     This is used for verification of purchase signatures. You can find your app's base64-encoded\n     *     public key in your application's page on Google Play Developer Console. Note that this\n     *     is NOT your \"developer public key\".\n     */\n    public IabHelper(Context ctx, String base64PublicKey) {\n        mContext = ctx.getApplicationContext();\n        mSignatureBase64 = base64PublicKey;\n        logDebug(\"IAB helper created.\");\n    }\n\n    /**\n     * Enables or disable debug logging through LogCat.\n     */\n    public void enableDebugLogging(boolean enable, String tag) {\n        checkNotDisposed();\n        mDebugLog = enable;\n        mDebugTag = tag;\n    }\n\n    public void enableDebugLogging(boolean enable) {\n        checkNotDisposed();\n        mDebugLog = enable;\n    }\n\n    /**\n     * Callback for setup process. This listener's {@link #onIabSetupFinished} method is called\n     * when the setup process is complete.\n     */\n    public interface OnIabSetupFinishedListener {\n        /**\n         * Called to notify that setup is complete.\n         *\n         * @param result The result of the setup process.\n         */\n        public void onIabSetupFinished(IabResult result);\n    }\n\n    /**\n     * Starts the setup process. This will start up the setup process asynchronously.\n     * You will be notified through the listener when the setup process is complete.\n     * This method is safe to call from a UI thread.\n     *\n     * @param listener The listener to notify when the setup process is complete.\n     */\n    public void startSetup(final OnIabSetupFinishedListener listener) {\n        // If already set up, can't do it again.\n        checkNotDisposed();\n        if (mSetupDone) throw new IllegalStateException(\"IAB helper is already set up.\");\n\n        // Connection to IAB service\n        logDebug(\"Starting in-app billing setup.\");\n        mServiceConn = new ServiceConnection() {\n            @Override\n            public void onServiceDisconnected(ComponentName name) {\n                logDebug(\"Billing service disconnected.\");\n                mService = null;\n            }\n\n            @Override\n            public void onServiceConnected(ComponentName name, IBinder service) {\n                if (mDisposed) return;\n                logDebug(\"Billing service connected.\");\n                mService = IInAppBillingService.Stub.asInterface(service);\n                String packageName = mContext.getPackageName();\n                try {\n                    logDebug(\"Checking for in-app billing 3 support.\");\n\n                    // check for in-app billing v3 support\n                    int response = mService.isBillingSupported(3, packageName, ITEM_TYPE_INAPP);\n                    if (response != BILLING_RESPONSE_RESULT_OK) {\n                        if (listener != null) listener.onIabSetupFinished(new IabResult(response,\n                                \"Error checking for billing v3 support.\"));\n\n                        // if in-app purchases aren't supported, neither are subscriptions.\n                        mSubscriptionsSupported = false;\n                        return;\n                    }\n                    logDebug(\"In-app billing version 3 supported for \" + packageName);\n\n                    // check for v3 subscriptions support\n                    response = mService.isBillingSupported(3, packageName, ITEM_TYPE_SUBS);\n                    if (response == BILLING_RESPONSE_RESULT_OK) {\n                        logDebug(\"Subscriptions AVAILABLE.\");\n                        mSubscriptionsSupported = true;\n                    }\n                    else {\n                        logDebug(\"Subscriptions NOT AVAILABLE. Response: \" + response);\n                    }\n\n                    mSetupDone = true;\n                }\n                catch (RemoteException e) {\n                    if (listener != null) {\n                        listener.onIabSetupFinished(new IabResult(IABHELPER_REMOTE_EXCEPTION,\n                                                    \"RemoteException while setting up in-app billing.\"));\n                    }\n                    e.printStackTrace();\n                    return;\n                }\n\n                if (listener != null) {\n                    listener.onIabSetupFinished(new IabResult(BILLING_RESPONSE_RESULT_OK, \"Setup successful.\"));\n                }\n            }\n        };\n\n        Intent serviceIntent = new Intent(\"com.android.vending.billing.InAppBillingService.BIND\");\n        serviceIntent.setPackage(\"com.android.vending\");\n        if (!mContext.getPackageManager().queryIntentServices(serviceIntent, 0).isEmpty()) {\n            // service available to handle that Intent\n            mContext.bindService(serviceIntent, mServiceConn, Context.BIND_AUTO_CREATE);\n        }\n        else {\n            // no service available to handle that Intent\n            if (listener != null) {\n                listener.onIabSetupFinished(\n                        new IabResult(BILLING_RESPONSE_RESULT_BILLING_UNAVAILABLE,\n                        \"Billing service unavailable on device.\"));\n            }\n        }\n    }\n\n    /**\n     * Dispose of object, releasing resources. It's very important to call this\n     * method when you are done with this object. It will release any resources\n     * used by it such as service connections. Naturally, once the object is\n     * disposed of, it can't be used again.\n     */\n    public void dispose() {\n        logDebug(\"Disposing.\");\n        mSetupDone = false;\n        if (mServiceConn != null) {\n            logDebug(\"Unbinding from service.\");\n            if (mContext != null) mContext.unbindService(mServiceConn);\n        }\n        mDisposed = true;\n        mContext = null;\n        mServiceConn = null;\n        mService = null;\n        mPurchaseListener = null;\n    }\n\n    private void checkNotDisposed() {\n        if (mDisposed) throw new IllegalStateException(\"IabHelper was disposed of, so it cannot be used.\");\n    }\n\n    /** Returns whether subscriptions are supported. */\n    public boolean subscriptionsSupported() {\n        checkNotDisposed();\n        return mSubscriptionsSupported;\n    }\n\n\n    /**\n     * Callback that notifies when a purchase is finished.\n     */\n    public interface OnIabPurchaseFinishedListener {\n        /**\n         * Called to notify that an in-app purchase finished. If the purchase was successful,\n         * then the sku parameter specifies which item was purchased. If the purchase failed,\n         * the sku and extraData parameters may or may not be null, depending on how far the purchase\n         * process went.\n         *\n         * @param result The result of the purchase.\n         * @param info The purchase information (null if purchase failed)\n         */\n        public void onIabPurchaseFinished(IabResult result, Purchase info);\n    }\n\n    // The listener registered on launchPurchaseFlow, which we have to call back when\n    // the purchase finishes\n    OnIabPurchaseFinishedListener mPurchaseListener;\n\n    public void launchPurchaseFlow(Activity act, String sku, int requestCode, OnIabPurchaseFinishedListener listener) {\n        launchPurchaseFlow(act, sku, requestCode, listener, \"\");\n    }\n\n    public void launchPurchaseFlow(Activity act, String sku, int requestCode,\n            OnIabPurchaseFinishedListener listener, String extraData) {\n        launchPurchaseFlow(act, sku, ITEM_TYPE_INAPP, requestCode, listener, extraData);\n    }\n\n    public void launchSubscriptionPurchaseFlow(Activity act, String sku, int requestCode,\n            OnIabPurchaseFinishedListener listener) {\n        launchSubscriptionPurchaseFlow(act, sku, requestCode, listener, \"\");\n    }\n\n    public void launchSubscriptionPurchaseFlow(Activity act, String sku, int requestCode,\n            OnIabPurchaseFinishedListener listener, String extraData) {\n        launchPurchaseFlow(act, sku, ITEM_TYPE_SUBS, requestCode, listener, extraData);\n    }\n\n    /**\n     * Initiate the UI flow for an in-app purchase. Call this method to initiate an in-app purchase,\n     * which will involve bringing up the Google Play screen. The calling activity will be paused while\n     * the user interacts with Google Play, and the result will be delivered via the activity's\n     * {@link android.app.Activity#onActivityResult} method, at which point you must call\n     * this object's {@link #handleActivityResult} method to continue the purchase flow. This method\n     * MUST be called from the UI thread of the Activity.\n     *\n     * @param act The calling activity.\n     * @param sku The sku of the item to purchase.\n     * @param itemType indicates if it's a product or a subscription (ITEM_TYPE_INAPP or ITEM_TYPE_SUBS)\n     * @param requestCode A request code (to differentiate from other responses --\n     *     as in {@link android.app.Activity#startActivityForResult}).\n     * @param listener The listener to notify when the purchase process finishes\n     * @param extraData Extra data (developer payload), which will be returned with the purchase data\n     *     when the purchase completes. This extra data will be permanently bound to that purchase\n     *     and will always be returned when the purchase is queried.\n     */\n    public void launchPurchaseFlow(Activity act, String sku, String itemType, int requestCode,\n                        OnIabPurchaseFinishedListener listener, String extraData) {\n        checkNotDisposed();\n        checkSetupDone(\"launchPurchaseFlow\");\n        flagStartAsync(\"launchPurchaseFlow\");\n        IabResult result;\n\n        if (itemType.equals(ITEM_TYPE_SUBS) && !mSubscriptionsSupported) {\n            IabResult r = new IabResult(IABHELPER_SUBSCRIPTIONS_NOT_AVAILABLE,\n                    \"Subscriptions are not available.\");\n            flagEndAsync();\n            if (listener != null) listener.onIabPurchaseFinished(r, null);\n            return;\n        }\n\n        try {\n            logDebug(\"Constructing buy intent for \" + sku + \", item type: \" + itemType);\n            Bundle buyIntentBundle = mService.getBuyIntent(3, mContext.getPackageName(), sku, itemType, extraData);\n            int response = getResponseCodeFromBundle(buyIntentBundle);\n            if (response != BILLING_RESPONSE_RESULT_OK) {\n                logError(\"Unable to buy item, Error response: \" + getResponseDesc(response));\n                flagEndAsync();\n                result = new IabResult(response, \"Unable to buy item\");\n                if (listener != null) listener.onIabPurchaseFinished(result, null);\n                return;\n            }\n\n            PendingIntent pendingIntent = buyIntentBundle.getParcelable(RESPONSE_BUY_INTENT);\n            logDebug(\"Launching buy intent for \" + sku + \". Request code: \" + requestCode);\n            mRequestCode = requestCode;\n            mPurchaseListener = listener;\n            mPurchasingItemType = itemType;\n            act.startIntentSenderForResult(pendingIntent.getIntentSender(),\n                                           requestCode, new Intent(),\n                                           Integer.valueOf(0), Integer.valueOf(0),\n                                           Integer.valueOf(0));\n        }\n        catch (SendIntentException e) {\n            logError(\"SendIntentException while launching purchase flow for sku \" + sku);\n            e.printStackTrace();\n            flagEndAsync();\n\n            result = new IabResult(IABHELPER_SEND_INTENT_FAILED, \"Failed to send intent.\");\n            if (listener != null) listener.onIabPurchaseFinished(result, null);\n        }\n        catch (RemoteException e) {\n            logError(\"RemoteException while launching purchase flow for sku \" + sku);\n            e.printStackTrace();\n            flagEndAsync();\n\n            result = new IabResult(IABHELPER_REMOTE_EXCEPTION, \"Remote exception while starting purchase flow\");\n            if (listener != null) listener.onIabPurchaseFinished(result, null);\n        }\n    }\n\n    /**\n     * Handles an activity result that's part of the purchase flow in in-app billing. If you\n     * are calling {@link #launchPurchaseFlow}, then you must call this method from your\n     * Activity's {@link android.app.Activity@onActivityResult} method. This method\n     * MUST be called from the UI thread of the Activity.\n     *\n     * @param requestCode The requestCode as you received it.\n     * @param resultCode The resultCode as you received it.\n     * @param data The data (Intent) as you received it.\n     * @return Returns true if the result was related to a purchase flow and was handled;\n     *     false if the result was not related to a purchase, in which case you should\n     *     handle it normally.\n     */\n    public boolean handleActivityResult(int requestCode, int resultCode, Intent data) {\n        IabResult result;\n        if (requestCode != mRequestCode) return false;\n\n        checkNotDisposed();\n        checkSetupDone(\"handleActivityResult\");\n\n        // end of async purchase operation that started on launchPurchaseFlow\n        flagEndAsync();\n\n        if (data == null) {\n            logError(\"Null data in IAB activity result.\");\n            result = new IabResult(IABHELPER_BAD_RESPONSE, \"Null data in IAB result\");\n            if (mPurchaseListener != null) mPurchaseListener.onIabPurchaseFinished(result, null);\n            return true;\n        }\n\n        int responseCode = getResponseCodeFromIntent(data);\n        String purchaseData = data.getStringExtra(RESPONSE_INAPP_PURCHASE_DATA);\n        String dataSignature = data.getStringExtra(RESPONSE_INAPP_SIGNATURE);\n\n        if (resultCode == Activity.RESULT_OK && responseCode == BILLING_RESPONSE_RESULT_OK) {\n            logDebug(\"Successful resultcode from purchase activity.\");\n            logDebug(\"Purchase data: \" + purchaseData);\n            logDebug(\"Data signature: \" + dataSignature);\n            logDebug(\"Extras: \" + data.getExtras());\n            logDebug(\"Expected item type: \" + mPurchasingItemType);\n\n            if (purchaseData == null || dataSignature == null) {\n                logError(\"BUG: either purchaseData or dataSignature is null.\");\n                logDebug(\"Extras: \" + data.getExtras().toString());\n                result = new IabResult(IABHELPER_UNKNOWN_ERROR, \"IAB returned null purchaseData or dataSignature\");\n                if (mPurchaseListener != null) mPurchaseListener.onIabPurchaseFinished(result, null);\n                return true;\n            }\n\n            Purchase purchase = null;\n            try {\n                purchase = new Purchase(mPurchasingItemType, purchaseData, dataSignature);\n                String sku = purchase.getSku();\n\n                // Verify signature\n                if (!Security.verifyPurchase(mSignatureBase64, purchaseData, dataSignature)) {\n                    logError(\"Purchase signature verification FAILED for sku \" + sku);\n                    result = new IabResult(IABHELPER_VERIFICATION_FAILED, \"Signature verification failed for sku \" + sku);\n                    if (mPurchaseListener != null) mPurchaseListener.onIabPurchaseFinished(result, purchase);\n                    return true;\n                }\n                logDebug(\"Purchase signature successfully verified.\");\n            }\n            catch (JSONException e) {\n                logError(\"Failed to parse purchase data.\");\n                e.printStackTrace();\n                result = new IabResult(IABHELPER_BAD_RESPONSE, \"Failed to parse purchase data.\");\n                if (mPurchaseListener != null) mPurchaseListener.onIabPurchaseFinished(result, null);\n                return true;\n            }\n\n            if (mPurchaseListener != null) {\n                mPurchaseListener.onIabPurchaseFinished(new IabResult(BILLING_RESPONSE_RESULT_OK, \"Success\"), purchase);\n            }\n        }\n        else if (resultCode == Activity.RESULT_OK) {\n            // result code was OK, but in-app billing response was not OK.\n            logDebug(\"Result code was OK but in-app billing response was not OK: \" + getResponseDesc(responseCode));\n            if (mPurchaseListener != null) {\n                result = new IabResult(responseCode, \"Problem purchashing item.\");\n                mPurchaseListener.onIabPurchaseFinished(result, null);\n            }\n        }\n        else if (resultCode == Activity.RESULT_CANCELED) {\n            logDebug(\"Purchase canceled - Response: \" + getResponseDesc(responseCode));\n            result = new IabResult(IABHELPER_USER_CANCELLED, \"User canceled.\");\n            if (mPurchaseListener != null) mPurchaseListener.onIabPurchaseFinished(result, null);\n        }\n        else {\n            logError(\"Purchase failed. Result code: \" + Integer.toString(resultCode)\n                    + \". Response: \" + getResponseDesc(responseCode));\n            result = new IabResult(IABHELPER_UNKNOWN_PURCHASE_RESPONSE, \"Unknown purchase response.\");\n            if (mPurchaseListener != null) mPurchaseListener.onIabPurchaseFinished(result, null);\n        }\n        return true;\n    }\n\n    public Inventory queryInventory(boolean querySkuDetails, List<String> moreSkus) throws IabException {\n        return queryInventory(querySkuDetails, moreSkus, null);\n    }\n\n    /**\n     * Queries the inventory. This will query all owned items from the server, as well as\n     * information on additional skus, if specified. This method may block or take long to execute.\n     * Do not call from a UI thread. For that, use the non-blocking version {@link #refreshInventoryAsync}.\n     *\n     * @param querySkuDetails if true, SKU details (price, description, etc) will be queried as well\n     *     as purchase information.\n     * @param moreItemSkus additional PRODUCT skus to query information on, regardless of ownership.\n     *     Ignored if null or if querySkuDetails is false.\n     * @param moreSubsSkus additional SUBSCRIPTIONS skus to query information on, regardless of ownership.\n     *     Ignored if null or if querySkuDetails is false.\n     * @throws IabException if a problem occurs while refreshing the inventory.\n     */\n    public Inventory queryInventory(boolean querySkuDetails, List<String> moreItemSkus,\n                                        List<String> moreSubsSkus) throws IabException {\n        checkNotDisposed();\n        checkSetupDone(\"queryInventory\");\n        try {\n            Inventory inv = new Inventory();\n            int r = queryPurchases(inv, ITEM_TYPE_INAPP);\n            if (r != BILLING_RESPONSE_RESULT_OK) {\n                throw new IabException(r, \"Error refreshing inventory (querying owned items).\");\n            }\n\n            if (querySkuDetails) {\n                r = querySkuDetails(ITEM_TYPE_INAPP, inv, moreItemSkus);\n                if (r != BILLING_RESPONSE_RESULT_OK) {\n                    throw new IabException(r, \"Error refreshing inventory (querying prices of items).\");\n                }\n            }\n\n            // if subscriptions are supported, then also query for subscriptions\n            if (mSubscriptionsSupported) {\n                r = queryPurchases(inv, ITEM_TYPE_SUBS);\n                if (r != BILLING_RESPONSE_RESULT_OK) {\n                    throw new IabException(r, \"Error refreshing inventory (querying owned subscriptions).\");\n                }\n\n                if (querySkuDetails) {\n                    r = querySkuDetails(ITEM_TYPE_SUBS, inv, moreItemSkus);\n                    if (r != BILLING_RESPONSE_RESULT_OK) {\n                        throw new IabException(r, \"Error refreshing inventory (querying prices of subscriptions).\");\n                    }\n                }\n            }\n\n            return inv;\n        }\n        catch (RemoteException e) {\n            throw new IabException(IABHELPER_REMOTE_EXCEPTION, \"Remote exception while refreshing inventory.\", e);\n        }\n        catch (JSONException e) {\n            throw new IabException(IABHELPER_BAD_RESPONSE, \"Error parsing JSON response while refreshing inventory.\", e);\n        }\n    }\n\n    /**\n     * Listener that notifies when an inventory query operation completes.\n     */\n    public interface QueryInventoryFinishedListener {\n        /**\n         * Called to notify that an inventory query operation completed.\n         *\n         * @param result The result of the operation.\n         * @param inv The inventory.\n         */\n        public void onQueryInventoryFinished(IabResult result, Inventory inv);\n    }\n\n\n    /**\n     * Asynchronous wrapper for inventory query. This will perform an inventory\n     * query as described in {@link #queryInventory}, but will do so asynchronously\n     * and call back the specified listener upon completion. This method is safe to\n     * call from a UI thread.\n     *\n     * @param querySkuDetails as in {@link #queryInventory}\n     * @param moreSkus as in {@link #queryInventory}\n     * @param listener The listener to notify when the refresh operation completes.\n     */\n    public void queryInventoryAsync(final boolean querySkuDetails,\n                               final List<String> moreSkus,\n                               final QueryInventoryFinishedListener listener) {\n        final Handler handler = new Handler();\n        checkNotDisposed();\n        checkSetupDone(\"queryInventory\");\n        flagStartAsync(\"refresh inventory\");\n        (new Thread(new Runnable() {\n            public void run() {\n                IabResult result = new IabResult(BILLING_RESPONSE_RESULT_OK, \"Inventory refresh successful.\");\n                Inventory inv = null;\n                try {\n                    inv = queryInventory(querySkuDetails, moreSkus);\n                }\n                catch (IabException ex) {\n                    result = ex.getResult();\n                }\n\n                flagEndAsync();\n\n                final IabResult result_f = result;\n                final Inventory inv_f = inv;\n                if (!mDisposed && listener != null) {\n                    handler.post(new Runnable() {\n                        public void run() {\n                            listener.onQueryInventoryFinished(result_f, inv_f);\n                        }\n                    });\n                }\n            }\n        })).start();\n    }\n\n    public void queryInventoryAsync(QueryInventoryFinishedListener listener) {\n        queryInventoryAsync(true, null, listener);\n    }\n\n    public void queryInventoryAsync(boolean querySkuDetails, QueryInventoryFinishedListener listener) {\n        queryInventoryAsync(querySkuDetails, null, listener);\n    }\n\n\n    /**\n     * Consumes a given in-app product. Consuming can only be done on an item\n     * that's owned, and as a result of consumption, the user will no longer own it.\n     * This method may block or take long to return. Do not call from the UI thread.\n     * For that, see {@link #consumeAsync}.\n     *\n     * @param itemInfo The PurchaseInfo that represents the item to consume.\n     * @throws IabException if there is a problem during consumption.\n     */\n    void consume(Purchase itemInfo) throws IabException {\n        checkNotDisposed();\n        checkSetupDone(\"consume\");\n\n        if (!itemInfo.mItemType.equals(ITEM_TYPE_INAPP)) {\n            throw new IabException(IABHELPER_INVALID_CONSUMPTION,\n                    \"Items of type '\" + itemInfo.mItemType + \"' can't be consumed.\");\n        }\n\n        try {\n            String token = itemInfo.getToken();\n            String sku = itemInfo.getSku();\n            if (token == null || token.equals(\"\")) {\n               logError(\"Can't consume \"+ sku + \". No token.\");\n               throw new IabException(IABHELPER_MISSING_TOKEN, \"PurchaseInfo is missing token for sku: \"\n                   + sku + \" \" + itemInfo);\n            }\n\n            logDebug(\"Consuming sku: \" + sku + \", token: \" + token);\n            int response = mService.consumePurchase(3, mContext.getPackageName(), token);\n            if (response == BILLING_RESPONSE_RESULT_OK) {\n               logDebug(\"Successfully consumed sku: \" + sku);\n            }\n            else {\n               logDebug(\"Error consuming consuming sku \" + sku + \". \" + getResponseDesc(response));\n               throw new IabException(response, \"Error consuming sku \" + sku);\n            }\n        }\n        catch (RemoteException e) {\n            throw new IabException(IABHELPER_REMOTE_EXCEPTION, \"Remote exception while consuming. PurchaseInfo: \" + itemInfo, e);\n        }\n    }\n\n    /**\n     * Callback that notifies when a consumption operation finishes.\n     */\n    public interface OnConsumeFinishedListener {\n        /**\n         * Called to notify that a consumption has finished.\n         *\n         * @param purchase The purchase that was (or was to be) consumed.\n         * @param result The result of the consumption operation.\n         */\n        public void onConsumeFinished(Purchase purchase, IabResult result);\n    }\n\n    /**\n     * Callback that notifies when a multi-item consumption operation finishes.\n     */\n    public interface OnConsumeMultiFinishedListener {\n        /**\n         * Called to notify that a consumption of multiple items has finished.\n         *\n         * @param purchases The purchases that were (or were to be) consumed.\n         * @param results The results of each consumption operation, corresponding to each\n         *     sku.\n         */\n        public void onConsumeMultiFinished(List<Purchase> purchases, List<IabResult> results);\n    }\n\n    /**\n     * Asynchronous wrapper to item consumption. Works like {@link #consume}, but\n     * performs the consumption in the background and notifies completion through\n     * the provided listener. This method is safe to call from a UI thread.\n     *\n     * @param purchase The purchase to be consumed.\n     * @param listener The listener to notify when the consumption operation finishes.\n     */\n    public void consumeAsync(Purchase purchase, OnConsumeFinishedListener listener) {\n        checkNotDisposed();\n        checkSetupDone(\"consume\");\n        List<Purchase> purchases = new ArrayList<Purchase>();\n        purchases.add(purchase);\n        consumeAsyncInternal(purchases, listener, null);\n    }\n\n    /**\n     * Same as {@link consumeAsync}, but for multiple items at once.\n     * @param purchases The list of PurchaseInfo objects representing the purchases to consume.\n     * @param listener The listener to notify when the consumption operation finishes.\n     */\n    public void consumeAsync(List<Purchase> purchases, OnConsumeMultiFinishedListener listener) {\n        checkNotDisposed();\n        checkSetupDone(\"consume\");\n        consumeAsyncInternal(purchases, null, listener);\n    }\n\n    /**\n     * Returns a human-readable description for the given response code.\n     *\n     * @param code The response code\n     * @return A human-readable string explaining the result code.\n     *     It also includes the result code numerically.\n     */\n    public static String getResponseDesc(int code) {\n        String[] iab_msgs = (\"0:OK/1:User Canceled/2:Unknown/\" +\n                \"3:Billing Unavailable/4:Item unavailable/\" +\n                \"5:Developer Error/6:Error/7:Item Already Owned/\" +\n                \"8:Item not owned\").split(\"/\");\n        String[] iabhelper_msgs = (\"0:OK/-1001:Remote exception during initialization/\" +\n                                   \"-1002:Bad response received/\" +\n                                   \"-1003:Purchase signature verification failed/\" +\n                                   \"-1004:Send intent failed/\" +\n                                   \"-1005:User cancelled/\" +\n                                   \"-1006:Unknown purchase response/\" +\n                                   \"-1007:Missing token/\" +\n                                   \"-1008:Unknown error/\" +\n                                   \"-1009:Subscriptions not available/\" +\n                                   \"-1010:Invalid consumption attempt\").split(\"/\");\n\n        if (code <= IABHELPER_ERROR_BASE) {\n            int index = IABHELPER_ERROR_BASE - code;\n            if (index >= 0 && index < iabhelper_msgs.length) return iabhelper_msgs[index];\n            else return String.valueOf(code) + \":Unknown IAB Helper Error\";\n        }\n        else if (code < 0 || code >= iab_msgs.length)\n            return String.valueOf(code) + \":Unknown\";\n        else\n            return iab_msgs[code];\n    }\n\n\n    // Checks that setup was done; if not, throws an exception.\n    void checkSetupDone(String operation) {\n        if (!mSetupDone) {\n            logError(\"Illegal state for operation (\" + operation + \"): IAB helper is not set up.\");\n            throw new IllegalStateException(\"IAB helper is not set up. Can't perform operation: \" + operation);\n        }\n    }\n\n    // Workaround to bug where sometimes response codes come as Long instead of Integer\n    int getResponseCodeFromBundle(Bundle b) {\n        Object o = b.get(RESPONSE_CODE);\n        if (o == null) {\n            logDebug(\"Bundle with null response code, assuming OK (known issue)\");\n            return BILLING_RESPONSE_RESULT_OK;\n        }\n        else if (o instanceof Integer) return ((Integer)o).intValue();\n        else if (o instanceof Long) return (int)((Long)o).longValue();\n        else {\n            logError(\"Unexpected type for bundle response code.\");\n            logError(o.getClass().getName());\n            throw new RuntimeException(\"Unexpected type for bundle response code: \" + o.getClass().getName());\n        }\n    }\n\n    // Workaround to bug where sometimes response codes come as Long instead of Integer\n    int getResponseCodeFromIntent(Intent i) {\n        Object o = i.getExtras().get(RESPONSE_CODE);\n        if (o == null) {\n            logError(\"Intent with no response code, assuming OK (known issue)\");\n            return BILLING_RESPONSE_RESULT_OK;\n        }\n        else if (o instanceof Integer) return ((Integer)o).intValue();\n        else if (o instanceof Long) return (int)((Long)o).longValue();\n        else {\n            logError(\"Unexpected type for intent response code.\");\n            logError(o.getClass().getName());\n            throw new RuntimeException(\"Unexpected type for intent response code: \" + o.getClass().getName());\n        }\n    }\n\n    void flagStartAsync(String operation) {\n        if (mAsyncInProgress) throw new IllegalStateException(\"Can't start async operation (\" +\n                operation + \") because another async operation(\" + mAsyncOperation + \") is in progress.\");\n        mAsyncOperation = operation;\n        mAsyncInProgress = true;\n        logDebug(\"Starting async operation: \" + operation);\n    }\n\n    void flagEndAsync() {\n        logDebug(\"Ending async operation: \" + mAsyncOperation);\n        mAsyncOperation = \"\";\n        mAsyncInProgress = false;\n    }\n\n\n    int queryPurchases(Inventory inv, String itemType) throws JSONException, RemoteException {\n        // Query purchases\n        logDebug(\"Querying owned items, item type: \" + itemType);\n        logDebug(\"Package name: \" + mContext.getPackageName());\n        boolean verificationFailed = false;\n        String continueToken = null;\n\n        do {\n            logDebug(\"Calling getPurchases with continuation token: \" + continueToken);\n            Bundle ownedItems = mService.getPurchases(3, mContext.getPackageName(),\n                    itemType, continueToken);\n\n            int response = getResponseCodeFromBundle(ownedItems);\n            logDebug(\"Owned items response: \" + String.valueOf(response));\n            if (response != BILLING_RESPONSE_RESULT_OK) {\n                logDebug(\"getPurchases() failed: \" + getResponseDesc(response));\n                return response;\n            }\n            if (!ownedItems.containsKey(RESPONSE_INAPP_ITEM_LIST)\n                    || !ownedItems.containsKey(RESPONSE_INAPP_PURCHASE_DATA_LIST)\n                    || !ownedItems.containsKey(RESPONSE_INAPP_SIGNATURE_LIST)) {\n                logError(\"Bundle returned from getPurchases() doesn't contain required fields.\");\n                return IABHELPER_BAD_RESPONSE;\n            }\n\n            ArrayList<String> ownedSkus = ownedItems.getStringArrayList(\n                        RESPONSE_INAPP_ITEM_LIST);\n            ArrayList<String> purchaseDataList = ownedItems.getStringArrayList(\n                        RESPONSE_INAPP_PURCHASE_DATA_LIST);\n            ArrayList<String> signatureList = ownedItems.getStringArrayList(\n                        RESPONSE_INAPP_SIGNATURE_LIST);\n\n            for (int i = 0; i < purchaseDataList.size(); ++i) {\n                String purchaseData = purchaseDataList.get(i);\n                String signature = signatureList.get(i);\n                String sku = ownedSkus.get(i);\n                if (Security.verifyPurchase(mSignatureBase64, purchaseData, signature)) {\n                    logDebug(\"Sku is owned: \" + sku);\n                    Purchase purchase = new Purchase(itemType, purchaseData, signature);\n\n                    if (TextUtils.isEmpty(purchase.getToken())) {\n                        logWarn(\"BUG: empty/null token!\");\n                        logDebug(\"Purchase data: \" + purchaseData);\n                    }\n\n                    // Record ownership and token\n                    inv.addPurchase(purchase);\n                }\n                else {\n                    logWarn(\"Purchase signature verification **FAILED**. Not adding item.\");\n                    logDebug(\"   Purchase data: \" + purchaseData);\n                    logDebug(\"   Signature: \" + signature);\n                    verificationFailed = true;\n                }\n            }\n\n            continueToken = ownedItems.getString(INAPP_CONTINUATION_TOKEN);\n            logDebug(\"Continuation token: \" + continueToken);\n        } while (!TextUtils.isEmpty(continueToken));\n\n        return verificationFailed ? IABHELPER_VERIFICATION_FAILED : BILLING_RESPONSE_RESULT_OK;\n    }\n\n    int querySkuDetails(String itemType, Inventory inv, List<String> moreSkus)\n                                throws RemoteException, JSONException {\n        logDebug(\"Querying SKU details.\");\n        ArrayList<String> skuList = new ArrayList<String>();\n        skuList.addAll(inv.getAllOwnedSkus(itemType));\n        if (moreSkus != null) {\n            for (String sku : moreSkus) {\n                if (!skuList.contains(sku)) {\n                    skuList.add(sku);\n                }\n            }\n        }\n\n        if (skuList.size() == 0) {\n            logDebug(\"queryPrices: nothing to do because there are no SKUs.\");\n            return BILLING_RESPONSE_RESULT_OK;\n        }\n\n        Bundle querySkus = new Bundle();\n        querySkus.putStringArrayList(GET_SKU_DETAILS_ITEM_LIST, skuList);\n        Bundle skuDetails = mService.getSkuDetails(3, mContext.getPackageName(),\n                itemType, querySkus);\n\n        if (!skuDetails.containsKey(RESPONSE_GET_SKU_DETAILS_LIST)) {\n            int response = getResponseCodeFromBundle(skuDetails);\n            if (response != BILLING_RESPONSE_RESULT_OK) {\n                logDebug(\"getSkuDetails() failed: \" + getResponseDesc(response));\n                return response;\n            }\n            else {\n                logError(\"getSkuDetails() returned a bundle with neither an error nor a detail list.\");\n                return IABHELPER_BAD_RESPONSE;\n            }\n        }\n\n        ArrayList<String> responseList = skuDetails.getStringArrayList(\n                RESPONSE_GET_SKU_DETAILS_LIST);\n\n        for (String thisResponse : responseList) {\n            SkuDetails d = new SkuDetails(itemType, thisResponse);\n            logDebug(\"Got sku details: \" + d);\n            inv.addSkuDetails(d);\n        }\n        return BILLING_RESPONSE_RESULT_OK;\n    }\n\n\n    void consumeAsyncInternal(final List<Purchase> purchases,\n                              final OnConsumeFinishedListener singleListener,\n                              final OnConsumeMultiFinishedListener multiListener) {\n        final Handler handler = new Handler();\n        flagStartAsync(\"consume\");\n        (new Thread(new Runnable() {\n            public void run() {\n                final List<IabResult> results = new ArrayList<IabResult>();\n                for (Purchase purchase : purchases) {\n                    try {\n                        consume(purchase);\n                        results.add(new IabResult(BILLING_RESPONSE_RESULT_OK, \"Successful consume of sku \" + purchase.getSku()));\n                    }\n                    catch (IabException ex) {\n                        results.add(ex.getResult());\n                    }\n                }\n\n                flagEndAsync();\n                if (!mDisposed && singleListener != null) {\n                    handler.post(new Runnable() {\n                        public void run() {\n                            singleListener.onConsumeFinished(purchases.get(0), results.get(0));\n                        }\n                    });\n                }\n                if (!mDisposed && multiListener != null) {\n                    handler.post(new Runnable() {\n                        public void run() {\n                            multiListener.onConsumeMultiFinished(purchases, results);\n                        }\n                    });\n                }\n            }\n        })).start();\n    }\n\n    void logDebug(String msg) {\n        if (mDebugLog) Log.d(mDebugTag, msg);\n    }\n\n    void logError(String msg) {\n        Log.e(mDebugTag, \"In-app billing error: \" + msg);\n    }\n\n    void logWarn(String msg) {\n        Log.w(mDebugTag, \"In-app billing warning: \" + msg);\n    }\n}"
  },
  {
    "path": "Source/CSBackend/Platform/Android/GooglePlay/Java/com/chilliworks/chillisource/networking/IabResult.java",
    "content": "/* Copyright (c) 2012 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.chilliworks.chillisource.networking;\n\n/**\n * Represents the result of an in-app billing operation.\n * A result is composed of a response code (an integer) and possibly a\n * message (String). You can get those by calling\n * {@link #getResponse} and {@link #getMessage()}, respectively. You\n * can also inquire whether a result is a success or a failure by\n * calling {@link #isSuccess()} and {@link #isFailure()}.\n */\npublic class IabResult {\n    int mResponse;\n    String mMessage;\n\n    public IabResult(int response, String message) {\n        mResponse = response;\n        if (message == null || message.trim().length() == 0) {\n            mMessage = IabHelper.getResponseDesc(response);\n        }\n        else {\n            mMessage = message + \" (response: \" + IabHelper.getResponseDesc(response) + \")\";\n        }\n    }\n    public int getResponse() { return mResponse; }\n    public String getMessage() { return mMessage; }\n    public boolean isSuccess() { return mResponse == IabHelper.BILLING_RESPONSE_RESULT_OK; }\n    public boolean isFailure() { return !isSuccess(); }\n    public String toString() { return \"IabResult: \" + getMessage(); }\n}\n\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/GooglePlay/Java/com/chilliworks/chillisource/networking/Inventory.java",
    "content": "/* Copyright (c) 2012 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.chilliworks.chillisource.networking;\n\nimport java.util.ArrayList;\nimport java.util.HashMap;\nimport java.util.List;\nimport java.util.Map;\n\n/**\n * Represents a block of information about in-app items.\n * An Inventory is returned by such methods as {@link IabHelper#queryInventory}.\n */\npublic class Inventory {\n    Map<String,SkuDetails> mSkuMap = new HashMap<String,SkuDetails>();\n    Map<String,Purchase> mPurchaseMap = new HashMap<String,Purchase>();\n\n    Inventory() { }\n\n    /** Returns the listing details for an in-app product. */\n    public SkuDetails getSkuDetails(String sku) {\n        return mSkuMap.get(sku);\n    }\n\n    /** Returns purchase information for a given product, or null if there is no purchase. */\n    public Purchase getPurchase(String sku) {\n        return mPurchaseMap.get(sku);\n    }\n\n    /** Returns whether or not there exists a purchase of the given product. */\n    public boolean hasPurchase(String sku) {\n        return mPurchaseMap.containsKey(sku);\n    }\n\n    /** Return whether or not details about the given product are available. */\n    public boolean hasDetails(String sku) {\n        return mSkuMap.containsKey(sku);\n    }\n\n    /**\n     * Erase a purchase (locally) from the inventory, given its product ID. This just\n     * modifies the Inventory object locally and has no effect on the server! This is\n     * useful when you have an existing Inventory object which you know to be up to date,\n     * and you have just consumed an item successfully, which means that erasing its\n     * purchase data from the Inventory you already have is quicker than querying for\n     * a new Inventory.\n     */\n    public void erasePurchase(String sku) {\n        if (mPurchaseMap.containsKey(sku)) mPurchaseMap.remove(sku);\n    }\n\n    /** Returns a list of all owned product IDs. */\n    List<String> getAllOwnedSkus() {\n        return new ArrayList<String>(mPurchaseMap.keySet());\n    }\n    \n    /** Returns a list of all owned product IDs of a given type */\n    List<String> getAllOwnedSkus(String itemType) {\n        List<String> result = new ArrayList<String>();\n        for (Purchase p : mPurchaseMap.values()) {\n            if (p.getItemType().equals(itemType)) result.add(p.getSku());\n        }\n        return result;\n    }\n\n    /** Returns a list of all purchases. */\n    List<Purchase> getAllPurchases() {\n        return new ArrayList<Purchase>(mPurchaseMap.values());\n    }\n\n    void addSkuDetails(SkuDetails d) {\n        mSkuMap.put(d.getSku(), d);\n    }\n\n    void addPurchase(Purchase p) {\n        mPurchaseMap.put(p.getSku(), p);\n    }\n}\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/GooglePlay/Java/com/chilliworks/chillisource/networking/Purchase.java",
    "content": "/* Copyright (c) 2012 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.chilliworks.chillisource.networking;\n\nimport org.json.JSONException;\nimport org.json.JSONObject;\n\n/**\n * Represents an in-app billing purchase.\n */\npublic class Purchase {\n    String mItemType;  // ITEM_TYPE_INAPP or ITEM_TYPE_SUBS\n    String mOrderId;\n    String mPackageName;\n    String mSku;\n    long mPurchaseTime;\n    int mPurchaseState;\n    String mDeveloperPayload;\n    String mToken;\n    String mOriginalJson;\n    String mSignature;\n\n    public Purchase(String itemType, String jsonPurchaseInfo, String signature) throws JSONException {\n        mItemType = itemType;\n        mOriginalJson = jsonPurchaseInfo;\n        JSONObject o = new JSONObject(mOriginalJson);\n        mOrderId = o.optString(\"orderId\");\n        mPackageName = o.optString(\"packageName\");\n        mSku = o.optString(\"productId\");\n        mPurchaseTime = o.optLong(\"purchaseTime\");\n        mPurchaseState = o.optInt(\"purchaseState\");\n        mDeveloperPayload = o.optString(\"developerPayload\");\n        mToken = o.optString(\"token\", o.optString(\"purchaseToken\"));\n        mSignature = signature;\n    }\n\n    public String getItemType() { return mItemType; }\n    public String getOrderId() { return mOrderId; }\n    public String getPackageName() { return mPackageName; }\n    public String getSku() { return mSku; }\n    public long getPurchaseTime() { return mPurchaseTime; }\n    public int getPurchaseState() { return mPurchaseState; }\n    public String getDeveloperPayload() { return mDeveloperPayload; }\n    public String getToken() { return mToken; }\n    public String getOriginalJson() { return mOriginalJson; }\n    public String getSignature() { return mSignature; }\n\n    @Override\n    public String toString() { return \"PurchaseInfo(type:\" + mItemType + \"):\" + mOriginalJson; }\n}\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/GooglePlay/Java/com/chilliworks/chillisource/networking/Security.java",
    "content": "/* Copyright (c) 2012 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.chilliworks.chillisource.networking;\n\nimport android.text.TextUtils;\nimport android.util.Log;\n\nimport java.security.InvalidKeyException;\nimport java.security.KeyFactory;\nimport java.security.NoSuchAlgorithmException;\nimport java.security.PublicKey;\nimport java.security.Signature;\nimport java.security.SignatureException;\nimport java.security.spec.InvalidKeySpecException;\nimport java.security.spec.X509EncodedKeySpec;\n\n/**\n * Security-related methods. For a secure implementation, all of this code\n * should be implemented on a server that communicates with the\n * application on the device. For the sake of simplicity and clarity of this\n * example, this code is included here and is executed on the device. If you\n * must verify the purchases on the phone, you should obfuscate this code to\n * make it harder for an attacker to replace the code with stubs that treat all\n * purchases as verified.\n */\npublic class Security {\n    private static final String TAG = \"IABUtil/Security\";\n\n    private static final String KEY_FACTORY_ALGORITHM = \"RSA\";\n    private static final String SIGNATURE_ALGORITHM = \"SHA1withRSA\";\n\n    /**\n     * Verifies that the data was signed with the given signature, and returns\n     * the verified purchase. The data is in JSON format and signed\n     * with a private key. The data also contains the {@link PurchaseState}\n     * and product ID of the purchase.\n     * @param base64PublicKey the base64-encoded public key to use for verifying.\n     * @param signedData the signed JSON string (signed, not encrypted)\n     * @param signature the signature for the data, signed with the private key\n     */\n    public static boolean verifyPurchase(String base64PublicKey, String signedData, String signature) {\n        if (signedData == null) {\n            Log.e(TAG, \"data is null\");\n            return false;\n        }\n\n        boolean verified = false;\n        if (!TextUtils.isEmpty(signature)) {\n            PublicKey key = Security.generatePublicKey(base64PublicKey);\n            verified = Security.verify(key, signedData, signature);\n            if (!verified) {\n                Log.w(TAG, \"signature does not match data.\");\n                return false;\n            }\n        }\n        return true;\n    }\n\n    /**\n     * Generates a PublicKey instance from a string containing the\n     * Base64-encoded public key.\n     *\n     * @param encodedPublicKey Base64-encoded public key\n     * @throws IllegalArgumentException if encodedPublicKey is invalid\n     */\n    public static PublicKey generatePublicKey(String encodedPublicKey) {\n        try {\n            byte[] decodedKey = Base64.decode(encodedPublicKey);\n            KeyFactory keyFactory = KeyFactory.getInstance(KEY_FACTORY_ALGORITHM);\n            return keyFactory.generatePublic(new X509EncodedKeySpec(decodedKey));\n        } catch (NoSuchAlgorithmException e) {\n            throw new RuntimeException(e);\n        } catch (InvalidKeySpecException e) {\n            Log.e(TAG, \"Invalid key specification.\");\n            throw new IllegalArgumentException(e);\n        } catch (Base64DecoderException e) {\n            Log.e(TAG, \"Base64 decoding failed.\");\n            throw new IllegalArgumentException(e);\n        }\n    }\n\n    /**\n     * Verifies that the signature from the server matches the computed\n     * signature on the data.  Returns true if the data is correctly signed.\n     *\n     * @param publicKey public key associated with the developer account\n     * @param signedData signed data from server\n     * @param signature server signature\n     * @return true if the data and signature match\n     */\n    public static boolean verify(PublicKey publicKey, String signedData, String signature) {\n        Signature sig;\n        try {\n            sig = Signature.getInstance(SIGNATURE_ALGORITHM);\n            sig.initVerify(publicKey);\n            sig.update(signedData.getBytes());\n            if (!sig.verify(Base64.decode(signature))) {\n                Log.e(TAG, \"Signature verification failed.\");\n                return false;\n            }\n            return true;\n        } catch (NoSuchAlgorithmException e) {\n            Log.e(TAG, \"NoSuchAlgorithmException.\");\n        } catch (InvalidKeyException e) {\n            Log.e(TAG, \"Invalid key specification.\");\n        } catch (SignatureException e) {\n            Log.e(TAG, \"Signature exception.\");\n        } catch (Base64DecoderException e) {\n            Log.e(TAG, \"Base64 decoding failed.\");\n        }\n        return false;\n    }\n}\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/GooglePlay/Java/com/chilliworks/chillisource/networking/SkuDetails.java",
    "content": "/* Copyright (c) 2012 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npackage com.chilliworks.chillisource.networking;\n\nimport org.json.JSONException;\nimport org.json.JSONObject;\n\n/**\n * Represents an in-app product's listing details.\n */\npublic class SkuDetails {\n    String mItemType;\n    String mSku;\n    String mType;\n    String mPrice;\n    String mTitle;\n    String mDescription;\n    String mJson;\n    String mPriceCurrencyCode;\n    int mPriceAmountMicros;\n\n    public SkuDetails(String jsonSkuDetails) throws JSONException {\n        this(IabHelper.ITEM_TYPE_INAPP, jsonSkuDetails);\n    }\n    \n    public SkuDetails(String itemType, String jsonSkuDetails) throws JSONException {\n        mItemType = itemType;\n        mJson = jsonSkuDetails;\n        JSONObject o = new JSONObject(mJson);\n        mSku = o.optString(\"productId\");\n        mType = o.optString(\"type\");\n        mPrice = o.optString(\"price\");\n        mTitle = o.optString(\"title\");\n        mDescription = o.optString(\"description\");\n        mPriceCurrencyCode = o.optString(\"price_currency_code\");\n        mPriceAmountMicros = o.optInt(\"price_amount_micros\");\n    }\n\n    public String getSku() { return mSku; }\n    public String getType() { return mType; }\n    public String getPrice() { return mPrice; }\n    public String getPriceCurrencyCode() { return mPriceCurrencyCode; }\n    public int getPriceAmountMicros() { return mPriceAmountMicros; }\n    public String getTitle() { return mTitle; }\n    public String getDescription() { return mDescription; }\n\n    @Override\n    public String toString() {\n        return \"SkuDetails:\" + mJson;\n    }\n}\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/JNI/Audio/CricketAudio/ZippedCkBankLoader.cpp",
    "content": "//\n//  ForwardDeclarations.h\n//  ChilliSource\n//  Created by Ian Copland on 09/08/2012.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2012 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n\n#include <CSBackend/Platform/Android/Main/JNI/Audio/CricketAudio/ZippedCkBankLoader.h>\n\n#include <ChilliSource/Audio/CricketAudio/CkBank.h>\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/Threading/TaskScheduler.h>\n\n#include <ck/ck.h>\n#include <ck/bank.h>\n\nnamespace CSBackend\n{\n\tnamespace Android\n\t{\n\t\t//------------------------------------------------------------------------------\n\t\t//------------------------------------------------------------------------------\n\t\tvoid ZippedCkBankLoader::Load(ChilliSource::StorageLocation in_storageLocation, const std::string& in_filePath, const ChilliSource::ResourceSPtr& out_resource) const\n\t\t{\n\t\t\tCS_ASSERT(ChilliSource::Application::Get()->GetTaskScheduler()->IsMainThread() == true, \"Must be called from the main thread.\");\n\n\t\t\tauto fileSystem = ChilliSource::Application::Get()->GetFileSystem();\n\n\t\t\tauto stream = fileSystem->CreateBinaryInputStream(in_storageLocation, in_filePath);\n\t\t\tif (stream == nullptr)\n\t\t\t{\n\t\t\t\tout_resource->SetLoadState(ChilliSource::Resource::LoadState::k_failed);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tu32 length = stream->GetLength();\n\n\t\t\tstd::unique_ptr<u8[]> bankBuffer(new u8[length]);\n\t\t\tstream->Read(bankBuffer.get(), length);\n\t\t\tstream.reset();\n\n\t\t\t::CkBank* bank = ::CkBank::newBankFromMemory(reinterpret_cast<void*>(bankBuffer.get()), length);\n\t\t\tif (bank == nullptr)\n\t\t\t{\n\t\t\t\tout_resource->SetLoadState(ChilliSource::Resource::LoadState::k_failed);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tstatic_cast<ChilliSource::CkBank*>(out_resource.get())->Build(bank, std::move(bankBuffer));\n\t\t\tout_resource->SetLoadState(ChilliSource::Resource::LoadState::k_loaded);\n\t\t}\n\t\t//------------------------------------------------------------------------------\n\t\t//------------------------------------------------------------------------------\n\t\tvoid ZippedCkBankLoader::LoadAsync(ChilliSource::StorageLocation in_storageLocation, const std::string& in_filePath, const ChilliSource::ResourceProvider::AsyncLoadDelegate& in_delegate, const ChilliSource::ResourceSPtr& out_resource)\n\t\t{\n\t\t\tCS_ASSERT(ChilliSource::Application::Get()->GetTaskScheduler()->IsMainThread() == true, \"Must be called from the main thread.\");\n\n\t\t\tauto taskScheduler = ChilliSource::Application::Get()->GetTaskScheduler();\n\t\t\ttaskScheduler->ScheduleTask(ChilliSource::TaskType::k_file, [=](const ChilliSource::TaskContext&)\n\t\t\t{\n\t\t\t\tauto fileSystem = ChilliSource::Application::Get()->GetFileSystem();\n\t\t\t\tauto stream = fileSystem->CreateBinaryInputStream(in_storageLocation, in_filePath);\n\t\t\t\tif (stream == nullptr)\n\t\t\t\t{\n\t\t\t\t\ttaskScheduler->ScheduleTask(ChilliSource::TaskType::k_mainThread, [=](const ChilliSource::TaskContext&)\n\t\t\t\t\t{\n\t\t\t\t\t\tout_resource->SetLoadState(ChilliSource::Resource::LoadState::k_failed);\n\t\t\t\t\t\tin_delegate(out_resource);\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tu32 length = stream->GetLength();\n\n\t\t\t\tstd::unique_ptr<u8[]> bankBuffer(new u8[length]);\n\t\t\t\tstream->Read(bankBuffer.get(), length);\n\t\t\t\tstream.reset();\n\n\t\t\t\t//we cannot capture the unique pointer in the main thread task, so store it and\n\t\t\t\t//retain a handle to it so it can be retrieved later.\n\t\t\t\tu8* bufferHandle = bankBuffer.get();\n\t\t\t\tStoreBuffer(std::move(bankBuffer));\n\n\t\t\t\ttaskScheduler->ScheduleTask(ChilliSource::TaskType::k_mainThread, [=](const ChilliSource::TaskContext&)\n                {\n\t\t\t\t\tstd::unique_ptr<u8[]> retrievedBuffer = RetrieveBuffer(bufferHandle);\n\n\t\t\t\t\t::CkBank* bank = ::CkBank::newBankFromMemory(reinterpret_cast<void*>(retrievedBuffer.get()), length);\n\t\t\t\t\tif (bank != nullptr)\n\t\t\t\t\t{\n\t\t\t\t\t\tstatic_cast<ChilliSource::CkBank*>(out_resource.get())->Build(bank, std::move(retrievedBuffer));\n\t\t\t\t\t\tout_resource->SetLoadState(ChilliSource::Resource::LoadState::k_loaded);\n\t\t\t\t\t\tin_delegate(out_resource);\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tout_resource->SetLoadState(ChilliSource::Resource::LoadState::k_failed);\n\t\t\t\t\t\tin_delegate(out_resource);\n\t\t\t\t\t}\n                });\n\t\t\t});\n\t\t}\n\t\t//------------------------------------------------------------------------------\n\t\t//------------------------------------------------------------------------------\n\t\tvoid ZippedCkBankLoader::StoreBuffer(std::unique_ptr<u8[]> in_buffer)\n\t\t{\n\t\t\tstd::unique_lock<std::mutex> lock(m_mutex);\n\n\t\t\tm_bankBuffers.push_back(std::move(in_buffer));\n\t\t}\n\t\t//------------------------------------------------------------------------------\n\t\t//------------------------------------------------------------------------------\n\t\tstd::unique_ptr<u8[]> ZippedCkBankLoader::RetrieveBuffer(u8* in_bufferHandle)\n\t\t{\n\t\t\tstd::unique_lock<std::mutex> lock(m_mutex);\n\n\t\t\tauto it = std::find_if(m_bankBuffers.begin(), m_bankBuffers.end(), [=](const std::unique_ptr<u8[]>& in_buffer)\n\t\t\t{\n\t\t\t\treturn (in_buffer.get() == in_bufferHandle);\n\t\t\t});\n\n\t\t\tCS_ASSERT(it != m_bankBuffers.end(), \"The buffer wasn't stored.\");\n\n\t\t\tauto output = std::move(*it);\n\t\t\tm_bankBuffers.erase(it);\n\t\t\treturn output;\n\t\t}\n\t}\n}\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/JNI/Audio/CricketAudio/ZippedCkBankLoader.h",
    "content": "//\n//  ZippedCkBankLoader.h\n//  ChilliSource\n//  Created by Ian Copland on 16/06/2015.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2015 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n\n#ifndef _CSBACKEND_PLATFORM_ANDROID_MAIN_JNI_AUDIO_CRICKETAUDIO_H_\n#define _CSBACKEND_PLATFORM_ANDROID_MAIN_JNI_AUDIO_CRICKETAUDIO_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Resource/ResourceProvider.h>\n\n#include <CSBackend/Platform/Android/Main/JNI/ForwardDeclarations.h>\n\n#include <mutex>\n\nnamespace CSBackend\n{\n\tnamespace Android\n\t{\n\t\t//------------------------------------------------------------------------------\n\t\t/// Cricket Audio doesn't provide any means to load from within the OBB, only\n\t\t/// APK. To get around that, this can be used. The methods provided will\n\t\t/// load the entire file into memory and create a CkBank from memory.\n\t\t///\n\t\t/// @author Ian Copland\n\t\t//------------------------------------------------------------------------------\n\t\tclass ZippedCkBankLoader final\n\t\t{\n\t\tpublic:\n\t\t    CS_DECLARE_NOCOPY(ZippedCkBankLoader);\n            //------------------------------------------------------------------------------\n            /// Constructor\n            ///\n            /// @author Ian Copland\n            //------------------------------------------------------------------------------\n            ZippedCkBankLoader() = default;\n            //------------------------------------------------------------------------------\n            /// Loads the entire file from the zip into memory then creates the CkBank from\n            /// this memory buffer. This can technically be used for any of the storage\n            /// locations, but for the sake of performance should only be used for Package,\n            /// ChilliSource and DLC if not in Cached DLC on Android.\n            ///\n            /// This must be called from the main thread.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param in_storageLocation - The storage location of the file which will\n            /// be loaded into memory.\n            /// @param in_filePath - The file which should be loaded into memory.\n            /// @param out_resource - [Out] The output resource. If this was successful it\n            /// will have its load state set to loaded, otherwise it will be set to failed.\n            //------------------------------------------------------------------------------\n            void Load(ChilliSource::StorageLocation in_storageLocation, const std::string& in_filePath, const ChilliSource::ResourceSPtr& out_resource) const;\n            //------------------------------------------------------------------------------\n            /// Asynchronously loads the entire file from the zip into memory then creates\n            /// the CkBank from this memory buffer. This can technically be used for any of\n            /// the storage locations, but for the sake of performance should only be used\n            /// for Package, ChilliSource and DLC if not in Cached DLC on Android.\n            ///\n            /// This must be called from the main thread. The loaded delegate will be\n            /// called on the main thread.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param in_storageLocation - The storage location of the file which will\n            /// be loaded into memory.\n            /// @param in_filePath - The file which should be loaded into memory.\n            /// @param out_resource - [Out] The output resource. If this was successful it\n            /// will have its load state set to loaded, otherwise it will be set to failed.\n            //------------------------------------------------------------------------------\n            void LoadAsync(ChilliSource::StorageLocation in_storageLocation, const std::string& in_filePath, const ChilliSource::ResourceProvider::AsyncLoadDelegate& in_delegate,\n                const ChilliSource::ResourceSPtr& out_resource);\n\n\t\tprivate:\n            //------------------------------------------------------------------------------\n            /// Stores the given buffer for later retrieval. This is needed to get around\n            /// the fact that we cannot capture the unique pointer, instead it's stored\n            /// here and retrieved again after.\n            ///\n            /// This is thread safe.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param in_buffer - The buffer to store.\n            //------------------------------------------------------------------------------\n            void StoreBuffer(std::unique_ptr<u8[]> in_buffer);\n            //------------------------------------------------------------------------------\n            /// Retrieves previously stored buffers using the pointer as a handle. This will\n            /// assert if the buffer couldn't be found.\n            ///\n            /// This is thread safe.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param in_bufferHandle - The buffer to retrieve.\n            ///\n            /// @return The unique pointer to the buffer.\n            //------------------------------------------------------------------------------\n            std::unique_ptr<u8[]> RetrieveBuffer(u8* in_bufferHandle);\n\n            std::vector<std::unique_ptr<u8[]>> m_bankBuffers;\n            mutable std::mutex m_mutex;\n\t\t};\n\t}\n}\n\n#endif\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/JNI/Core/Base/CoreJavaInterface.cpp",
    "content": "//\n//  CoreJavaInterface.cpp\n//  ChilliSource\n//  Created by Ian Copland on 17/03/2011.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2011 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n\n#include <CSBackend/Platform/Android/Main/JNI/Core/Base/CoreJavaInterface.h>\n\n#include <CSBackend/Platform/Android/Main/JNI/ForwardDeclarations.h>\n#include <CSBackend/Platform/Android/Main/JNI/Core/Base/Screen.h>\n#include <CSBackend/Platform/Android/Main/JNI/Core/Base/SystemInfoFactory.h>\n#include <CSBackend/Platform/Android/Main/JNI/Core/DialogueBox/DialogueBoxSystem.h>\n#include <CSBackend/Platform/Android/Main/JNI/Core/Java/JavaInterfaceManager.h>\n#include <CSBackend/Platform/Android/Main/JNI/Core/Java/JavaUtils.h>\n#include <CSBackend/Platform/Android/Main/JNI/Core/Java/JavaVirtualMachine.h>\n#include <CSBackend/Platform/Android/Main/JNI/Input/Pointer/TouchInputJavaInterface.h>\n#include <CSBackend/Platform/Android/Main/JNI/Web/Base/WebViewJavaInterface.h>\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/Base/LifecycleManager.h>\n#include <ChilliSource/Core/Base/PlatformSystem.h>\n\n//--------------------------------------------------------------------------------------\n/// C function declarations\n//--------------------------------------------------------------------------------------\nextern \"C\"\n{\n\t//--------------------------------------------------------------------------------------\n\t/// Interface function called from java that forces creation of the core interface\n\t///\n\t/// @author Ian Copland\n\t///\n\t/// @param JNIEnv - The jni environment.\n\t/// @param jobject - the java object calling the function\n\t//--------------------------------------------------------------------------------------\n\tvoid Java_com_chilliworks_chillisource_core_CoreNativeInterface_create(JNIEnv* in_env, jobject in_this);\n\t//--------------------------------------------------------------------------------------\n\t/// Interface function called from java. This is called when the application is launched.\n\t///\n\t/// @author Ian Copland\n\t///\n\t/// @param JNIEnv - The jni environment.\n\t/// @param jobject - the java object calling the function\n\t//--------------------------------------------------------------------------------------\n\tvoid Java_com_chilliworks_chillisource_core_CoreNativeInterface_initApplication(JNIEnv* in_env, jobject in_this);\n\t//--------------------------------------------------------------------------------------\n\t/// Interface function called from java. This is called when the application is resumed.\n\t///\n\t/// @author Ian Copland\n\t///\n\t/// @param JNIEnv - The jni environment.\n\t/// @param jobject - the java object calling the function\n\t//--------------------------------------------------------------------------------------\n\tvoid Java_com_chilliworks_chillisource_core_CoreNativeInterface_resume(JNIEnv* in_env, jobject in_this);\n\t//--------------------------------------------------------------------------------------\n\t/// Interface function called from java. This is called when the application is pushed\n\t/// to the foreground\n\t///\n\t/// @author S Downie\n\t///\n\t/// @param JNIEnv - The jni environment.\n\t/// @param jobject - the java object calling the function\n\t//--------------------------------------------------------------------------------------\n\tvoid Java_com_chilliworks_chillisource_core_CoreNativeInterface_foreground(JNIEnv* in_env, jobject in_this);\n\t//--------------------------------------------------------------------------------------\n\t/// Interface function called from java. This is called when the application is pushed\n\t/// to the background\n\t///\n\t/// @author S Downie\n\t///\n\t/// @param JNIEnv - The jni environment.\n\t/// @param jobject - the java object calling the function\n\t//--------------------------------------------------------------------------------------\n\tvoid Java_com_chilliworks_chillisource_core_CoreNativeInterface_background(JNIEnv* in_env, jobject in_this);\n\t//--------------------------------------------------------------------------------------\n\t/// Interface function called from java. This is called when the application is suspended\n\t///\n\t/// @author Ian Copland\n\t///\n\t/// @param JNIEnv - The jni environment.\n\t/// @param jobject - the java object calling the function\n\t//--------------------------------------------------------------------------------------\n\tvoid Java_com_chilliworks_chillisource_core_CoreNativeInterface_suspend(JNIEnv* in_env, jobject in_this);\n\t//--------------------------------------------------------------------------------------\n\t/// Interface function called from java. This is called when the application is destroyed\n\t///\n\t/// @author Ian Copland\n\t///\n\t/// @param JNIEnv - The jni environment.\n\t/// @param jobject - the java object calling the function\n\t//--------------------------------------------------------------------------------------\n\tvoid Java_com_chilliworks_chillisource_core_CoreNativeInterface_destroyApplication(JNIEnv* in_env, jobject in_this);\n\t//--------------------------------------------------------------------------------------\n\t/// Interface function called from java. This is called when the application is updated\n\t///\n\t/// @author Ian Copland\n\t///\n\t/// @param JNIEnv - The jni environment.\n\t/// @param jobject - the java object calling the function\n\t/// @param the delta time.\n\t/// @param Elapsed app time\n\t//--------------------------------------------------------------------------------------\n\tvoid Java_com_chilliworks_chillisource_core_CoreNativeInterface_update(JNIEnv* in_env, jobject in_this, f32 in_deltaTime, s64 in_elapsedTime);\n\t//--------------------------------------------------------------------------------------\n\t/// Interface function called from java. This is called when the application is almost\n\t/// Out of memory.\n\t///\n\t/// @author Ian Copland\n\t///\n\t/// @param JNIEnv - The jni environment.\n\t/// @param jobject - the java object calling the function\n\t//--------------------------------------------------------------------------------------\n\tvoid Java_com_chilliworks_chillisource_core_CoreNativeInterface_memoryWarning(JNIEnv* in_env, jobject in_this);\n\t//--------------------------------------------------------------------------------------\n\t/// Interface function called from java. This is called when the resolution changes.\n\t///\n\t/// @author Ian Copland\n\t///\n\t/// @param The jni environment.\n\t/// @param the java object calling the function\n\t/// @param The new width.\n\t/// @param The new height.\n\t//--------------------------------------------------------------------------------------\n\tvoid Java_com_chilliworks_chillisource_core_CoreNativeInterface_onResolutionChanged(JNIEnv* in_env, jobject in_this, s32 in_width, s32 in_height);\n\t//--------------------------------------------------------------------------------------\n\t/// Application Did Receive Launching URL\n\t///\n\t///\n\t/// @param JNIEnv - The jni environment.\n\t/// @param jobject - the java object calling the function\n\t/// @param URL\n\t//--------------------------------------------------------------------------------------\n    void Java_com_chilliworks_chillisource_core_CoreNativeInterface_applicationDidReceiveLaunchingURL(JNIEnv* in_env, jobject in_this, jstring in_url);\n}\n\n//--------------------------------------------------------------------------------------\n//--------------------------------------------------------------------------------------\nvoid Java_com_chilliworks_chillisource_core_CoreNativeInterface_create(JNIEnv* in_env, jobject in_this)\n{\n\t//get the java VM and init the Java Interface Manager\n\tJavaVM* javaVM = nullptr;\n\tin_env->GetJavaVM(&javaVM);\n\tCSBackend::Android::JavaVirtualMachine::Create(javaVM);\n\tCSBackend::Android::JavaInterfaceManager::GetSingletonPtr()->Initialise(javaVM);\n\n\t//add the core native interface\n\tCSBackend::Android::JavaInterfaceManager::GetSingletonPtr()->AddJavaInterface(CSBackend::Android::IJavaInterfaceSPtr(new CSBackend::Android::CoreJavaInterface()));\n}\n//--------------------------------------------------------------------------------------\n//--------------------------------------------------------------------------------------\nvoid Java_com_chilliworks_chillisource_core_CoreNativeInterface_initApplication(JNIEnv* in_env, jobject in_this)\n{\n\t//setup legacy Java interface. Note: that all java interfaces are now legacy code, please use JavaClass instead.\n\tJavaVM* javaVM;\n\tin_env->GetJavaVM(&javaVM);\n\tCSBackend::Android::TouchInputJavaInterface::SetupJavaInterface(javaVM);\n\tCSBackend::Android::WebViewJavaInterface::SetupJavaInterface(javaVM);\n    \n\tauto coreJI = CSBackend::Android::JavaInterfaceManager::GetSingletonPtr()->GetJavaInterface<CSBackend::Android::CoreJavaInterface>();\n\tcoreJI->Init();\n}\n//--------------------------------------------------------------------------------------\n//--------------------------------------------------------------------------------------\nvoid Java_com_chilliworks_chillisource_core_CoreNativeInterface_resume(JNIEnv* in_env, jobject in_this)\n{\n\tauto coreJI = CSBackend::Android::JavaInterfaceManager::GetSingletonPtr()->GetJavaInterface<CSBackend::Android::CoreJavaInterface>();\n\tcoreJI->Resume();\n}\n//--------------------------------------------------------------------------------------\n//--------------------------------------------------------------------------------------\nvoid Java_com_chilliworks_chillisource_core_CoreNativeInterface_foreground(JNIEnv* in_env, jobject in_this)\n{\n\tauto coreJI = CSBackend::Android::JavaInterfaceManager::GetSingletonPtr()->GetJavaInterface<CSBackend::Android::CoreJavaInterface>();\n\tcoreJI->Foreground();\n}\n//--------------------------------------------------------------------------------------\n//--------------------------------------------------------------------------------------\nvoid Java_com_chilliworks_chillisource_core_CoreNativeInterface_background(JNIEnv* in_env, jobject in_this)\n{\n\tauto coreJI = CSBackend::Android::JavaInterfaceManager::GetSingletonPtr()->GetJavaInterface<CSBackend::Android::CoreJavaInterface>();\n\tcoreJI->Background();\n}\n//--------------------------------------------------------------------------------------\n//--------------------------------------------------------------------------------------\nvoid Java_com_chilliworks_chillisource_core_CoreNativeInterface_suspend(JNIEnv* in_env, jobject in_this)\n{\n\tauto coreJI = CSBackend::Android::JavaInterfaceManager::GetSingletonPtr()->GetJavaInterface<CSBackend::Android::CoreJavaInterface>();\n\tcoreJI->Suspend();\n}\n//--------------------------------------------------------------------------------------\n//--------------------------------------------------------------------------------------\nvoid Java_com_chilliworks_chillisource_core_CoreNativeInterface_destroyApplication(JNIEnv* in_env, jobject in_this)\n{\n\tauto coreJI = CSBackend::Android::JavaInterfaceManager::GetSingletonPtr()->GetJavaInterface<CSBackend::Android::CoreJavaInterface>();\n\tcoreJI->Destroy();\n\n\tCSBackend::Android::JavaVirtualMachine::Destroy();\n}\n//--------------------------------------------------------------------------------------\n//--------------------------------------------------------------------------------------\nvoid Java_com_chilliworks_chillisource_core_CoreNativeInterface_update(JNIEnv* in_env, jobject in_this, f32 in_deltaTime, s64 in_elapsedTime)\n{\n\tauto coreJI = CSBackend::Android::JavaInterfaceManager::GetSingletonPtr()->GetJavaInterface<CSBackend::Android::CoreJavaInterface>();\n\tcoreJI->SystemUpdate();\n\tcoreJI->Render();\n}\n//--------------------------------------------------------------------------------------\n//--------------------------------------------------------------------------------------\nvoid Java_com_chilliworks_chillisource_core_CoreNativeInterface_memoryWarning(JNIEnv* in_env, jobject in_this)\n{\n\tauto coreJI = CSBackend::Android::JavaInterfaceManager::GetSingletonPtr()->GetJavaInterface<CSBackend::Android::CoreJavaInterface>();\n\tcoreJI->MemoryWarning();\n}\n//--------------------------------------------------------------------------------------\n//--------------------------------------------------------------------------------------\nvoid Java_com_chilliworks_chillisource_core_CoreNativeInterface_onResolutionChanged(JNIEnv* in_env, jobject in_this, s32 in_width, s32 in_height)\n{\n\tCSBackend::Android::Screen* screen = ChilliSource::Application::Get()->GetSystem<CSBackend::Android::Screen>();\n\tCS_ASSERT(screen != nullptr, \"Cannot find required system: Screen.\");\n\tscreen->OnResolutionChanged(ChilliSource::Vector2((f32)in_width, (f32)in_height));\n}\n\nnamespace CSBackend\n{\n\tnamespace Android\n\t{\n\t\tCS_DEFINE_NAMEDTYPE(CoreJavaInterface);\n\n\t\t//--------------------------------------------------------------------------------------\n\t\t//--------------------------------------------------------------------------------------\n\t\tCoreJavaInterface::CoreJavaInterface()\n\t\t: m_application(nullptr), m_screenWidth(0), m_screenHeight(0), m_screenDensity(-0.1f), m_physicalScreenSize(-0.1f), m_isActive(false)\n\t\t{\n\t\t\tCreateNativeInterface(\"com/chilliworks/chillisource/core/CoreNativeInterface\");\n\t\t\tCreateMethodReference(\"getExternalStorageDirectory\", \"()Ljava/lang/String;\");\n\t\t\tCreateMethodReference(\"getApplicationName\", \"()Ljava/lang/String;\");\n\t\t\tCreateMethodReference(\"getApplicationVersionCode\", \"()I\");\n\t\t\tCreateMethodReference(\"getApplicationVersionName\", \"()Ljava/lang/String;\");\n\t\t\tCreateMethodReference(\"getPackageName\", \"()Ljava/lang/String;\");\n\t\t\tCreateMethodReference(\"getAPKDirectory\", \"()Ljava/lang/String;\");\n\t\t\tCreateMethodReference(\"getScreenWidth\", \"()I\");\n\t\t\tCreateMethodReference(\"getScreenHeight\", \"()I\");\n\t\t\tCreateMethodReference(\"getScreenDensity\", \"()F\");\n\t\t\tCreateMethodReference(\"forceQuit\", \"()V\");\n\t\t\tCreateMethodReference(\"setPreferredFPS\", \"(I)V\");\n\t\t\tCreateMethodReference(\"getActivity\", \"()Landroid/app/Activity;\");\n\t\t}\n\t\t//--------------------------------------------------------------------------------------\n\t\t//--------------------------------------------------------------------------------------\n\t\tbool CoreJavaInterface::IsA(ChilliSource::InterfaceIDType in_interfaceId) const\n\t\t{\n\t\t\treturn (in_interfaceId == CoreJavaInterface::InterfaceID);\n\t\t}\n\t\t//------------------------------------------------------------------------------\n\t\t//------------------------------------------------------------------------------\n\t\tjobject CoreJavaInterface::GetActivity() const\n\t\t{\n\t\t\tJNIEnv* pEnv = CSBackend::Android::JavaInterfaceManager::GetSingletonPtr()->GetJNIEnvironmentPtr();\n\t\t\treturn pEnv->CallObjectMethod(GetJavaObject(), GetMethodID(\"getActivity\"));\n\t\t}\n\t\t//-----------------------------------------\n\t\t//-----------------------------------------\n\t\tvoid CoreJavaInterface::SetPreferredFPS(u32 in_maxFPS)\n\t\t{\n\t\t\tJNIEnv* env = JavaInterfaceManager::GetSingletonPtr()->GetJNIEnvironmentPtr();\n\t\t\tenv->CallVoidMethod(GetJavaObject(), GetMethodID(\"setPreferredFPS\"), in_maxFPS);\n\t\t}\n\t\t//--------------------------------------------------------------------------------------\n\t\t//--------------------------------------------------------------------------------------\n\t\tstd::string CoreJavaInterface::GetExternalStorageDirectory()\n\t\t{\n\t\t\tstd::string sdCardRootPath = \"\";\n\t\t\tJNIEnv* env = JavaInterfaceManager::GetSingletonPtr()->GetJNIEnvironmentPtr();\n\t\t\tjstring externalStorageDir = static_cast<jstring>(env->CallObjectMethod(GetJavaObject(), GetMethodID(\"getExternalStorageDirectory\")));\n\t\t\tsdCardRootPath = JavaUtils::CreateSTDStringFromJString(externalStorageDir);\n\t\t\tenv->DeleteLocalRef(externalStorageDir);\n\t\t\treturn sdCardRootPath;\n\t\t}\n\t\t//--------------------------------------------------------------------------------------\n\t\t//--------------------------------------------------------------------------------------\n\t\tstd::string CoreJavaInterface::GetApplicationName()\n\t\t{\n\t\t\tstd::string appName = \"\";\n\t\t\tJNIEnv* env = JavaInterfaceManager::GetSingletonPtr()->GetJNIEnvironmentPtr();\n\t\t\tjstring jstrName = static_cast<jstring>(env->CallObjectMethod(GetJavaObject(), GetMethodID(\"getApplicationName\")));\n\t\t\tappName = JavaUtils::CreateSTDStringFromJString(jstrName);\n\t\t\tenv->DeleteLocalRef(jstrName);\n\t\t\treturn appName;\n\t\t}\n\t\t//--------------------------------------------------------------------------------------\n\t\t//--------------------------------------------------------------------------------------\n\t\tu32 CoreJavaInterface::GetApplicationVersionCode()\n\t\t{\n\t\t\tJNIEnv* env = JavaInterfaceManager::GetSingletonPtr()->GetJNIEnvironmentPtr();\n\t\t\treturn env->CallIntMethod(GetJavaObject(), GetMethodID(\"getApplicationVersionCode\"));\n\t\t}\n\t\t//--------------------------------------------------------------------------------------\n\t\t//--------------------------------------------------------------------------------------\n\t\tstd::string CoreJavaInterface::GetApplicationVersionName()\n\t\t{\n\t\t\tstd::string appVersion = \"\";\n\t\t\tJNIEnv* env = JavaInterfaceManager::GetSingletonPtr()->GetJNIEnvironmentPtr();\n\t\t\tjstring jstrName = static_cast<jstring>(env->CallObjectMethod(GetJavaObject(), GetMethodID(\"getApplicationVersionName\")));\n\t\t\tappVersion = JavaUtils::CreateSTDStringFromJString(jstrName);\n\t\t\tenv->DeleteLocalRef(jstrName);\n\t\t\treturn appVersion;\n\t\t}\n\t\t//--------------------------------------------------------------------------------------\n\t\t//--------------------------------------------------------------------------------------\n\t\tstd::string CoreJavaInterface::GetPackageName()\n\t\t{\n\t\t\tstd::string packageName = \"\";\n\t\t\tJNIEnv* env = JavaInterfaceManager::GetSingletonPtr()->GetJNIEnvironmentPtr();\n\t\t\tjstring jstrName = static_cast<jstring>(env->CallObjectMethod(GetJavaObject(), GetMethodID(\"getPackageName\")));\n\t\t\tpackageName = JavaUtils::CreateSTDStringFromJString(jstrName);\n\t\t\tenv->DeleteLocalRef(jstrName);\n\t\t\treturn packageName;\n\t\t}\n\t\t//--------------------------------------------------------------------------------------\n\t\t//--------------------------------------------------------------------------------------\n\t\tstd::string CoreJavaInterface::GetAPKDirectory()\n\t\t{\n\t\t\tstd::string apkRootPath = \" \";\n\t\t\tJNIEnv* env = JavaInterfaceManager::GetSingletonPtr()->GetJNIEnvironmentPtr();\n\t\t\tjstring jstrAkpPath = static_cast<jstring>(env->CallObjectMethod(GetJavaObject(), GetMethodID(\"getAPKDirectory\")));\n\t\t\tapkRootPath = JavaUtils::CreateSTDStringFromJString(jstrAkpPath);\n\t\t\tenv->DeleteLocalRef(jstrAkpPath);\n\t\t\treturn apkRootPath;\n\t\t}\n\t\t//--------------------------------------------------------------------------------------\n\t\t//--------------------------------------------------------------------------------------\n\t\ts32 CoreJavaInterface::GetScreenWidth()\n\t\t{\n\t\t\tif (m_screenWidth == 0)\n\t\t\t{\n\t\t\t\tJNIEnv* env = JavaInterfaceManager::GetSingletonPtr()->GetJNIEnvironmentPtr();\n\t\t\t\tm_screenWidth = env->CallIntMethod(GetJavaObject(), GetMethodID(\"getScreenWidth\"));\n\t\t\t}\n\t\t\treturn m_screenWidth;\n\t\t}\n\t\t//--------------------------------------------------------------------------------------\n\t\t//--------------------------------------------------------------------------------------\n\t\ts32 CoreJavaInterface::GetScreenHeight()\n\t\t{\n\t\t\tif (m_screenHeight == 0)\n\t\t\t{\n\t\t\t\tJNIEnv* env = JavaInterfaceManager::GetSingletonPtr()->GetJNIEnvironmentPtr();\n\t\t\t\tm_screenHeight = env->CallIntMethod(GetJavaObject(), GetMethodID(\"getScreenHeight\"));\n\t\t\t}\n\t\t\treturn m_screenHeight;\n\t\t}\n\t\t//--------------------------------------------------------------------------------------\n\t\t//--------------------------------------------------------------------------------------\n\t\tf32 CoreJavaInterface::GetScreenDensity()\n\t\t{\n\t\t\tif (m_screenDensity < 0.0f)\n\t\t\t{\n\t\t\t\tJNIEnv* env = JavaInterfaceManager::GetSingletonPtr()->GetJNIEnvironmentPtr();\n\t\t\t\tm_screenDensity = env->CallFloatMethod(GetJavaObject(), GetMethodID(\"getScreenDensity\"));\n\t\t\t}\n\t\t\treturn m_screenDensity;\n\t\t}\n        //-----------------------------------------------------------------------------------------------------\n        //-----------------------------------------------------------------------------------------------------\n        void CoreJavaInterface::ForceQuit()\n        {\n\t\t\tJNIEnv* env = JavaInterfaceManager::GetSingletonPtr()->GetJNIEnvironmentPtr();\n\t\t\tenv->CallVoidMethod(GetJavaObject(), GetMethodID(\"forceQuit\"));\n        }\n        //--------------------------------------------------------------------------------------\n        //--------------------------------------------------------------------------------------\n        void CoreJavaInterface::Init() noexcept\n        {\n            m_application = ChilliSource::ApplicationUPtr(CreateApplication(SystemInfoFactory::CreateSystemInfo()));\n            m_lifecycleManager = ChilliSource::LifecycleManagerUPtr(new ChilliSource::LifecycleManager(m_application.get()));\n        }\n        //--------------------------------------------------------------------------------------\n        //--------------------------------------------------------------------------------------\n        void CoreJavaInterface::Resume() noexcept\n        {\n            m_lifecycleManager->Resume();\n        \tm_isActive = true;\n        }\n        //--------------------------------------------------------------------------------------\n        //--------------------------------------------------------------------------------------\n        void CoreJavaInterface::Foreground() noexcept\n        {\n            m_lifecycleManager->Foreground();\n        }\n        //--------------------------------------------------------------------------------------\n        //--------------------------------------------------------------------------------------\n        void CoreJavaInterface::Render() noexcept\n        {\n        \tif (m_isActive)\n        \t{\n            \tm_lifecycleManager->Render();\n        \t}\n        }\n        //--------------------------------------------------------------------------------------\n        //--------------------------------------------------------------------------------------\n        void CoreJavaInterface::SystemUpdate() noexcept\n        {\n            m_lifecycleManager->SystemUpdate();\n        }\n        //--------------------------------------------------------------------------------------\n        //--------------------------------------------------------------------------------------\n        void CoreJavaInterface::Background() noexcept\n        {\n            m_lifecycleManager->Background();\n        }\n        //--------------------------------------------------------------------------------------\n        //--------------------------------------------------------------------------------------\n        void CoreJavaInterface::Suspend() noexcept\n        {\n        \tm_isActive = false;\n            m_lifecycleManager->Suspend();\n        }\n        //--------------------------------------------------------------------------------------\n        //--------------------------------------------------------------------------------------\n        void CoreJavaInterface::Destroy() noexcept\n        {\n            m_lifecycleManager.reset();\n            m_application.reset();\n        }\n\t\t//--------------------------------------------------------------------------------------\n\t\t//--------------------------------------------------------------------------------------\n\t\tvoid CoreJavaInterface::MemoryWarning() noexcept\n\t\t{\n\t\t\tm_lifecycleManager->MemoryWarning();\n\t\t}\n\t}\n}\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/JNI/Core/Base/CoreJavaInterface.h",
    "content": "//\n//  CoreJavaInterface.h\n//  ChilliSource\n//  Created by Ian Copland on 17/03/2011.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2011 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n\n#ifndef _CSBACKEND_PLATFORM_ANDROID_CORE_BASE_COREJAVAINTERFACE_H_\n#define _CSBACKEND_PLATFORM_ANDROID_CORE_BASE_COREJAVAINTERFACE_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <CSBackend/Platform/Android/Main/JNI/Core/Java/JavaInterface.h>\n\n#include <atomic>\n#include <jni.h>\n\nnamespace CSBackend\n{\n\tnamespace Android\n\t{\n\t    //--------------------------------------------------------------------------------------\n\t    /// This provides the main lifecycle events into an application, as well as some\n\t    /// important information on the application, such as screen size.\n\t    ///\n\t    /// Note this is in a legacy format and should be updated such that it doesn't\n\t    /// use IJavaInterface, and so that the lifecycle events and things such as screen\n\t    /// size are handled by different classes.\n\t    //--------------------------------------------------------------------------------------\n\t\tclass CoreJavaInterface : public IJavaInterface\n\t\t{\n\t\tpublic:\n\t\t\tCS_DECLARE_NAMEDTYPE(CoreJavaInterface);\n\n\t\t\tCoreJavaInterface();\n\t\t\t//--------------------------------------------------------------------------------------\n\t\t\t/// @author Ian Copland\n\t\t\t///\n\t\t\t/// @param Interface ID\n\t\t\t///\n\t\t\t/// @return Whether or not this object implements the given interface.\n\t\t\t//--------------------------------------------------------------------------------------\n\t\t\tbool IsA(ChilliSource::InterfaceIDType in_interfaceId) const override;\n\t\t\t//--------------------------------------------------------------------------------------\n\t\t\t/// @author Ian Copland\n\t\t\t///\n\t\t\t/// @return The current activity.\n\t\t\t//--------------------------------------------------------------------------------------\n\t\t\tjobject GetActivity() const;\n\t\t\t//--------------------------------------------------------------------------------------\n\t\t\t/// @author Ian Copland\n\t\t\t///\n\t\t\t/// @param The maximum frames per second to clamp to. This should be in multiples\n\t\t\t/// of 15 (15, 30, 60)\n\t\t\t//--------------------------------------------------------------------------------------\n\t\t\tvoid SetPreferredFPS(u32 in_maxFPS);\n\t\t\t//--------------------------------------------------------------------------------------\n\t\t\t/// @author Ian Copland\n\t\t\t///\n\t\t\t/// @return returns the External Storage Directory as acquired from the CoreNativeInterface\n\t\t\t/// Java class.\n\t\t\t//--------------------------------------------------------------------------------------\n\t\t\tstd::string GetExternalStorageDirectory();\n\t\t\t//--------------------------------------------------------------------------------------\n\t\t\t/// @author Ian Copland\n\t\t\t///\n\t\t\t/// @return returns the Application name as acquired from the CoreNativeInterface\n\t\t\t/// Java class.\n\t\t\t//--------------------------------------------------------------------------------------\n\t\t\tstd::string GetApplicationName();\n\t\t\t//--------------------------------------------------------------------------------------\n\t\t\t/// @author Ian Copland\n\t\t\t///\n\t\t\t/// @return returns the Application version code as acquired from the CoreNativeInterface\n\t\t\t/// Java class.\n\t\t\t//--------------------------------------------------------------------------------------\n\t\t\tu32 GetApplicationVersionCode();\n\t\t\t//--------------------------------------------------------------------------------------\n\t\t\t/// @author Ian Copland\n\t\t\t///\n\t\t\t/// @return returns the Application version name as acquired from the CoreNativeInterface\n\t\t\t/// Java class.\n\t\t\t//--------------------------------------------------------------------------------------\n\t\t\tstd::string GetApplicationVersionName();\n\t\t\t//--------------------------------------------------------------------------------------\n\t\t\t/// @author Ian Copland\n\t\t\t///\n\t\t\t/// @return returns the package name as acquired from the CoreNativeInterface\n\t\t\t/// Java class.\n\t\t\t//--------------------------------------------------------------------------------------\n\t\t\tstd::string GetPackageName();\n\t\t\t//--------------------------------------------------------------------------------------\n\t\t\t/// @author Ian Copland\n\t\t\t///\n\t\t\t/// @return returns the APK directory as acquired from the CoreNativeInterface\n\t\t\t/// Java class.\n\t\t\t//--------------------------------------------------------------------------------------\n\t\t\tstd::string GetAPKDirectory();\n\t\t\t//--------------------------------------------------------------------------------------\n\t\t\t/// @author Ian Copland\n\t\t\t///\n\t\t\t/// @return returns the screen width as acquired from the CoreNativeInterface\n\t\t\t/// Java class.\n\t\t\t//--------------------------------------------------------------------------------------\n\t\t\ts32 GetScreenWidth();\n\t\t\t//--------------------------------------------------------------------------------------\n\t\t\t/// @author Ian Copland\n\t\t\t///\n\t\t\t/// @return returns the screen height as acquired from the CoreNativeInterface\n\t\t\t/// Java class.\n\t\t\t//--------------------------------------------------------------------------------------\n\t\t\ts32 GetScreenHeight();\n\t\t\t//--------------------------------------------------------------------------------------\n\t\t\t/// @author Ian Copland\n\t\t\t///\n\t\t\t/// @return returns the screen density as acquired from the CoreNativeInterface\n\t\t\t/// Java class.\n\t\t\t//--------------------------------------------------------------------------------------\n\t\t\tf32 GetScreenDensity();\n            //--------------------------------------------------------------------------------------\n            /// @author Ian Copland\n            ///\n            /// Kill the application process\n            //--------------------------------------------------------------------------------------\n            void ForceQuit();\n            //--------------------------------------------------------------------------------------\n            /// Sends the init lifecycle event.\n            ///\n            /// @author Ian Copland\n            //--------------------------------------------------------------------------------------\n            void Init() noexcept;\n            //--------------------------------------------------------------------------------------\n            /// Sends the resume lifecycle event.\n            ///\n            /// @author Ian Copland\n            //--------------------------------------------------------------------------------------\n            void Resume() noexcept;\n            //--------------------------------------------------------------------------------------\n            /// Sends the foreground lifecycle event.\n            ///\n            /// @author Ian Copland\n            //--------------------------------------------------------------------------------------\n            void Foreground() noexcept;\n            //--------------------------------------------------------------------------------------\n            /// Sends the render lifecycle event.\n            ///\n            /// @author Ian Copland\n            //--------------------------------------------------------------------------------------\n            void Render() noexcept;\n            //--------------------------------------------------------------------------------------\n            /// Executes system thread tasks.\n            ///\n            /// @author Jordan Brown\n            //--------------------------------------------------------------------------------------\n            void SystemUpdate() noexcept;\n            //--------------------------------------------------------------------------------------\n            /// Sends the background lifecycle event.\n            ///\n            /// @author Ian Copland\n            //--------------------------------------------------------------------------------------\n            void Background() noexcept;\n            //--------------------------------------------------------------------------------------\n            /// Sends the suspend lifecycle event.\n            ///\n            /// @author Ian Copland\n            //--------------------------------------------------------------------------------------\n            void Suspend() noexcept;\n            //--------------------------------------------------------------------------------------\n            /// Sends the destroy lifecycle event.\n            ///\n            /// @author Ian Copland\n            //--------------------------------------------------------------------------------------\n            void Destroy() noexcept;\n            //--------------------------------------------------------------------------------------\n            /// Sends the memory warning lifecycle event.\n            ///\n            /// @author Ian Copland\n            //--------------------------------------------------------------------------------------\n            void MemoryWarning() noexcept;\n\t\tprivate:\n\n\t\t\tChilliSource::ApplicationUPtr m_application;\n\t\t\tChilliSource::LifecycleManagerUPtr m_lifecycleManager;\n\t\t\ts32 m_screenWidth;\n\t\t\ts32 m_screenHeight;\n\t\t\tf32 m_screenDensity;\n\t\t\tf32 m_physicalScreenSize;\n\n\t\t\tstd::atomic<bool> m_isActive;\n\t\t};\n\t}\n}\n\n#endif\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/JNI/Core/Base/DeviceJavaInterface.cpp",
    "content": "//\n//  DeviceJavaInterface.cpp\n//  ChilliSource\n//  Created by Scott Downie on 24/09/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n\n#include <CSBackend/Platform/Android/Main/JNI/Core/Base/DeviceJavaInterface.h>\n\n#include <CSBackend/Platform/Android/Main/JNI/ForwardDeclarations.h>\n#include <CSBackend/Platform/Android/Main/JNI/Core/Java/JavaInterfaceManager.h>\n#include <CSBackend/Platform/Android/Main/JNI/Core/Java/JavaUtils.h>\n\nnamespace CSBackend\n{\n\tnamespace Android\n\t{\n\t\tCS_DEFINE_NAMEDTYPE(DeviceJavaInterface);\n\n\t\t//--------------------------------------------------------------------------------------\n\t\t//--------------------------------------------------------------------------------------\n\t\tDeviceJavaInterface::DeviceJavaInterface()\n\t\t: m_OSVersionCode(-1), m_numberOfCores(-1)\n\t\t{\n\t\t\tCreateNativeInterface(\"com/chilliworks/chillisource/core/DeviceNativeInterface\");\n\t\t\tCreateMethodReference(\"getDefaultLocaleCode\", \"()Ljava/lang/String;\");\n\t\t\tCreateMethodReference(\"getDeviceModel\", \"()Ljava/lang/String;\");\n\t\t\tCreateMethodReference(\"getDeviceManufacturer\", \"()Ljava/lang/String;\");\n\t\t\tCreateMethodReference(\"getDeviceModelType\", \"()Ljava/lang/String;\");\n\t\t\tCreateMethodReference(\"getOSVersion\", \"()I\");\n\t\t\tCreateMethodReference(\"getNumberOfCores\", \"()I\");\n\t\t\tCreateMethodReference(\"getUniqueId\", \"()Ljava/lang/String;\");\n\t\t}\n\t\t//--------------------------------------------------------------------------------------\n\t\t//--------------------------------------------------------------------------------------\n\t\tbool DeviceJavaInterface::IsA(ChilliSource::InterfaceIDType in_interfaceId) const\n\t\t{\n\t\t\treturn (in_interfaceId == DeviceJavaInterface::InterfaceID);\n\t\t}\n\t\t//--------------------------------------------------------------------------------------\n\t\t//--------------------------------------------------------------------------------------\n\t\tstd::string DeviceJavaInterface::GetDefaultLocaleCode()\n\t\t{\n\t\t\tif (m_localeCode == \"\")\n\t\t\t{\n\t\t\t\tJNIEnv* env = JavaInterfaceManager::GetSingletonPtr()->GetJNIEnvironmentPtr();\n\t\t\t\tjstring jstrLocalCode = static_cast<jstring>(env->CallObjectMethod(GetJavaObject(), GetMethodID(\"getDefaultLocaleCode\")));\n\t\t\t\tm_localeCode = JavaUtils::CreateSTDStringFromJString(jstrLocalCode);\n\t\t\t\tenv->DeleteLocalRef(jstrLocalCode);\n\t\t\t}\n\t\t\treturn m_localeCode;\n\t\t}\n\t\t//--------------------------------------------------------------------------------------\n\t\t//--------------------------------------------------------------------------------------\n\t\tstd::string DeviceJavaInterface::GetDeviceModel()\n\t\t{\n\t\t\tif (m_deviceModel == \"\")\n\t\t\t{\n\t\t\t\tJNIEnv* env = JavaInterfaceManager::GetSingletonPtr()->GetJNIEnvironmentPtr();\n\t\t\t\tjstring jstrDeviceModel = static_cast<jstring>(env->CallObjectMethod(GetJavaObject(), GetMethodID(\"getDeviceModel\")));\n\t\t\t\tm_deviceModel = JavaUtils::CreateSTDStringFromJString(jstrDeviceModel);\n\t\t\t\tenv->DeleteLocalRef(jstrDeviceModel);\n\t\t\t}\n\t\t\treturn m_deviceModel;\n\t\t}\n\t\t//--------------------------------------------------------------------------------------\n\t\t//--------------------------------------------------------------------------------------\n\t\tstd::string DeviceJavaInterface::GetDeviceModelType()\n\t\t{\n\t\t\tif (m_deviceModelType == \"\")\n\t\t\t{\n\t\t\t\tJNIEnv* env = JavaInterfaceManager::GetSingletonPtr()->GetJNIEnvironmentPtr();\n\t\t\t\tjstring jstrDeviceModelType = static_cast<jstring>(env->CallObjectMethod(GetJavaObject(), GetMethodID(\"getDeviceModelType\")));\n\t\t\t\tm_deviceModelType = JavaUtils::CreateSTDStringFromJString(jstrDeviceModelType);\n\t\t\t\tenv->DeleteLocalRef(jstrDeviceModelType);\n\t\t\t}\n\t\t\treturn m_deviceModelType;\n\t\t}\n\t\t//--------------------------------------------------------------------------------------\n\t\t//--------------------------------------------------------------------------------------\n\t\tstd::string DeviceJavaInterface::GetDeviceManufacturer()\n\t\t{\n\t\t\tif (m_deviceManufacturer == \"\")\n\t\t\t{\n\t\t\t\tJNIEnv* env = JavaInterfaceManager::GetSingletonPtr()->GetJNIEnvironmentPtr();\n\t\t\t\tjstring jstrDeviceManufacturer = static_cast<jstring>(env->CallObjectMethod(GetJavaObject(), GetMethodID(\"getDeviceManufacturer\")));\n\t\t\t\tm_deviceManufacturer = JavaUtils::CreateSTDStringFromJString(jstrDeviceManufacturer);\n\t\t\t\tenv->DeleteLocalRef(jstrDeviceManufacturer);\n\t\t\t}\n\t\t\treturn m_deviceManufacturer;\n\t\t}\n\t\t//--------------------------------------------------------------------------------------\n\t\t//--------------------------------------------------------------------------------------\n\t\ts32 DeviceJavaInterface::GetOSVersionCode()\n\t\t{\n\t\t\tif (m_OSVersionCode == -1)\n\t\t\t{\n\t\t\t\tJNIEnv* env = JavaInterfaceManager::GetSingletonPtr()->GetJNIEnvironmentPtr();\n\t\t\t\tm_OSVersionCode = env->CallIntMethod(GetJavaObject(), GetMethodID(\"getOSVersion\"));\n\t\t\t}\n\t\t\treturn m_OSVersionCode;\n\t\t}\n\t\t//--------------------------------------------------------------------------------------\n\t\t//--------------------------------------------------------------------------------------\n\t\ts32 DeviceJavaInterface::GetNumberOfCores()\n\t\t{\n\t\t\tif (m_numberOfCores == -1)\n\t\t\t{\n\t\t\t\tJNIEnv* env = JavaInterfaceManager::GetSingletonPtr()->GetJNIEnvironmentPtr();\n\t\t\t\tm_numberOfCores = env->CallIntMethod(GetJavaObject(), GetMethodID(\"getNumberOfCores\"));\n\t\t\t}\n\t\t\treturn m_numberOfCores;\n\t\t}\n\t\t//--------------------------------------------------------------\n\t\t//--------------------------------------------------------------\n\t\tstd::string DeviceJavaInterface::GetUniqueId()\n\t\t{\n\t\t\tstd::string output = \"\";\n\t\t\tJNIEnv* env = JavaInterfaceManager::GetSingletonPtr()->GetJNIEnvironmentPtr();\n\t\t\tjstring adId = static_cast<jstring>(env->CallObjectMethod(GetJavaObject(), GetMethodID(\"getUniqueId\")));\n\t\t\toutput = JavaUtils::CreateSTDStringFromJString(adId);\n\t\t\tenv->DeleteLocalRef(adId);\n\t\t\treturn output;\n\t\t}\n\t}\n}\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/JNI/Core/Base/DeviceJavaInterface.h",
    "content": "//\n//  DeviceJavaInterface.h\n//  ChilliSource\n//  Created by Scott Downie on 24/09/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n\n#ifndef _CSBACKEND_PLATFORM_ANDROID_CORE_BASE_DEVICEJAVAINTERFACE_H_\n#define _CSBACKEND_PLATFORM_ANDROID_CORE_BASE_DEVICEJAVAINTERFACE_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <CSBackend/Platform/Android/Main/JNI/Core/Java/JavaInterface.h>\n\n#include <jni.h>\n\nnamespace CSBackend\n{\n\tnamespace Android\n\t{\n\t\t//--------------------------------------------------------------------------------------\n\t\t/// Allows device stats to be retrieved from the Android Java SDK\n\t\t///\n\t\t/// @author S Downie\n\t\t//--------------------------------------------------------------------------------------\n\t\tclass DeviceJavaInterface : public IJavaInterface\n\t\t{\n\t\tpublic:\n\t\t\tCS_DECLARE_NAMEDTYPE(DeviceJavaInterface);\n\t\t\t//--------------------------------------------------------------------------------------\n\t\t\t/// Constructor\n\t\t\t///\n\t\t\t/// @author S Downie\n\t\t\t//--------------------------------------------------------------------------------------\n\t\t\tDeviceJavaInterface();\n\t\t\t//--------------------------------------------------------------------------------------\n\t\t\t/// @author S Downie\n\t\t\t///\n\t\t\t/// @param Interface ID\n\t\t\t///\n\t\t\t/// @return Whether or not this object implements the given interface.\n\t\t\t//--------------------------------------------------------------------------------------\n\t\t\tbool IsA(ChilliSource::InterfaceIDType in_interfaceId) const override;\n\t\t\t//--------------------------------------------------------------------------------------\n\t\t\t/// @author S Downie\n\t\t\t///\n\t\t\t/// @return returns the default locale code as acquired from the CoreNativeInterface\n\t\t\t/// Java class.\n\t\t\t//--------------------------------------------------------------------------------------\n\t\t\tstd::string GetDefaultLocaleCode();\n\t\t\t//--------------------------------------------------------------------------------------\n\t\t\t/// @author S Downie\n\t\t\t///\n\t\t\t/// @return returns the device model as acquired from the CoreNativeInterface\n\t\t\t/// Java class.\n\t\t\t//--------------------------------------------------------------------------------------\n\t\t\tstd::string GetDeviceModel();\n\t\t\t//--------------------------------------------------------------------------------------\n\t\t\t/// @author S Downie\n\t\t\t///\n\t\t\t/// @return returns the device model type as acquired from the CoreNativeInterface\n\t\t\t/// Java class.\n\t\t\t//--------------------------------------------------------------------------------------\n\t\t\tstd::string GetDeviceModelType();\n\t\t\t//--------------------------------------------------------------------------------------\n\t\t\t/// @author S Downie\n\t\t\t///\n\t\t\t/// @return returns the device manufacturer as acquired from the CoreNativeInterface\n\t\t\t/// Java class.\n\t\t\t//--------------------------------------------------------------------------------------\n\t\t\tstd::string GetDeviceManufacturer();\n\t\t\t//--------------------------------------------------------------------------------------\n\t\t\t/// @author S Downie\n\t\t\t///\n\t\t\t/// @return returns the os version number as acquired from the CoreNativeInterface\n\t\t\t/// Java class.\n\t\t\t//--------------------------------------------------------------------------------------\n\t\t\ts32 GetOSVersionCode();\n\t\t\t//--------------------------------------------------------------------------------------\n\t\t\t/// @author S Downie\n\t\t\t///\n\t\t\t/// @return returns the number of cores as acquired from the CoreNativeInterface\n\t\t\t/// Java class.\n\t\t\t//--------------------------------------------------------------------------------------\n\t\t\ts32 GetNumberOfCores();\n\t\t\t//--------------------------------------------------------------\n\t\t\t/// @author S Downie\n\t\t\t///\n\t\t\t/// @return String containing the id or empty if none can be obtained\n\t\t\t//--------------------------------------------------------------\n\t\t\tstd::string GetUniqueId();\n            \n\t\tprivate:\n\n\t\t\tstd::string m_deviceModel;\n\t\t\tstd::string m_deviceModelType;\n\t\t\tstd::string m_deviceManufacturer;\n\t\t\tstd::string m_localeCode;\n\t\t\ts32 m_OSVersionCode;\n\t\t\ts32 m_numberOfCores;\n\t\t};\n\t}\n}\n\n#endif\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/JNI/Core/Base/PlatformSystem.cpp",
    "content": "//\n//  PlatformSystem.cpp\n//  ChilliSource\n//  Created by Ian Copland on 24/11/2010.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n\n#include <CSBackend/Platform/Android/Main/JNI/Core/Base/PlatformSystem.h>\n\n#include <CSBackend/Platform/Android/Main/JNI/Core/Base/CoreJavaInterface.h>\n#include <CSBackend/Platform/Android/Main/JNI/Core/Java/JavaInterfaceManager.h>\n\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/Image/ETC1ImageProvider.h>\n\nnamespace CSBackend \n{\n\tnamespace Android\n\t{\n\t\tCS_DEFINE_NAMEDTYPE(PlatformSystem);\n\t\t//-------------------------------------------------------\n\t\t//-------------------------------------------------------\n\t\tbool PlatformSystem::IsA(ChilliSource::InterfaceIDType in_interfaceId) const\n\t\t{\n\t\t\treturn (ChilliSource::PlatformSystem::InterfaceID == in_interfaceId || PlatformSystem::InterfaceID == in_interfaceId);\n\t\t}\n\t\t//-------------------------------------------------\n\t\t//-------------------------------------------------\n\t\tvoid PlatformSystem::CreateDefaultSystems(ChilliSource::Application* in_application)\n\t\t{\n\t\t\tin_application->CreateSystem<ChilliSource::ETC1ImageProvider>();\n\t\t}\n        //-----------------------------------------\n        //-----------------------------------------\n        void PlatformSystem::SetPreferredFPS(u32 in_fps)\n        {\n        \tJavaInterfaceManager::GetSingletonPtr()->GetJavaInterface<CoreJavaInterface>()->SetPreferredFPS(in_fps);\n        }\n\t\t//-----------------------------------------\n        //-----------------------------------------\n        void PlatformSystem::Quit()\n        {\n        \tJavaInterfaceManager::GetSingletonPtr()->GetJavaInterface<CoreJavaInterface>()->ForceQuit();\n        }\n\t}\n}\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/JNI/Core/Base/PlatformSystem.h",
    "content": "//\n//  PlatformSystem.h\n//  ChilliSource\n//  Created by Ian Copland on 24/11/2010.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n\n#ifndef _CSBACKEND_PLATFORM_ANDROID_CORE_BASE_PLATFORMSYSTEM_H_\n#define _CSBACKEND_PLATFORM_ANDROID_CORE_BASE_PLATFORMSYSTEM_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <CSBackend/Platform/Android/Main/JNI/ForwardDeclarations.h>\n#include <ChilliSource/Core/Base/PlatformSystem.h>\n\nnamespace CSBackend\n{\n\tnamespace Android\n\t{\n\t\t//---------------------------------------------------------------\n\t\t/// The Android backend for the platform system. This creates the\n\t\t/// Android specfic default systems and sets up the updater.\n\t\t///\n\t\t/// @author Ian Copland\n\t\t//---------------------------------------------------------------\n\t\tclass PlatformSystem final : public ChilliSource::PlatformSystem\n\t\t{\n\t\tpublic:\n\t\t\tCS_DECLARE_NAMEDTYPE(PlatformSystem);\n            //-------------------------------------------------------\n\t\t\t/// Queries whether or not this system implements the\n            /// interface with the given Id.\n\t\t\t///\n            /// @author Ian Copland\n            ///\n\t\t\t/// @param The interface Id.\n\t\t\t/// @param Whether system is of given type.\n\t\t\t//-------------------------------------------------------\n\t\t\tbool IsA(ChilliSource::InterfaceIDType in_interfaceId) const override;\n\t\t\t//-------------------------------------------------------\n\t\t\t/// Adds default systems to the applications system\n\t\t\t/// list.\n            ///\n            /// @author S Downie\n\t\t\t///\n\t\t\t/// @param Application instance to add the default\n            /// platform systems to.\n\t\t\t//-------------------------------------------------------\n\t\t\tvoid CreateDefaultSystems(ChilliSource::Application* in_application) override;\n\t\t\t//-------------------------------------------------------\n            /// Lock the frame rate to the given FPS\n\t\t\t///\n\t\t\t/// @author S Downie\n            ///\n            /// @param The maximum frames per second to clamp to.\n\t\t\t/// This should be in multiples of 15 (15, 30, 60)\n\t\t\t//-------------------------------------------------------\n            void SetPreferredFPS(u32 in_fps) override;\n            //---------------------------------------------------\n            /// NOTE: Not supported on Android\n            ///\n            /// @author S Downie\n            ///\n            /// @param Enable/Disable\n            //---------------------------------------------------\n            void SetVSyncEnabled(bool in_enabled) override {};\n            //-------------------------------------------------------\n            /// Terminate the app\n\t\t\t///\n\t\t\t/// @author S Downie\n            //-------------------------------------------------------\n            void Quit() override;\n            \n\t\tprivate:\n            friend ChilliSource::PlatformSystemUPtr ChilliSource::PlatformSystem::Create();\n            //-------------------------------------------------------\n            /// Private constructor to force use of factory method\n            ///\n            /// @author S Downie\n            //-------------------------------------------------------\n            PlatformSystem() = default;\n\t\t};\n\t}\n}\n\n#endif\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/JNI/Core/Base/Screen.cpp",
    "content": "//\n//  Screen.cpp\n//  ChilliSource\n//  Created by Ian Copland on 28/04/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n\n#include <CSBackend/Platform/Android/Main/JNI/Core/Base/Screen.h>\n\n#include <CSBackend/Platform/Android/Main/JNI/Core/Base/CoreJavaInterface.h>\n#include <CSBackend/Platform/Android/Main/JNI/Core/Java/JavaInterfaceManager.h>\n\nnamespace CSBackend\n{\n    namespace Android\n    {\n        CS_DEFINE_NAMEDTYPE(Screen);\n        //-------------------------------------------------------\n        //-------------------------------------------------------\n        Screen::Screen(const ChilliSource::ScreenInfo& screenInfo)\n            : m_screenInfo(screenInfo)\n        {\n            m_resolution = m_screenInfo.GetInitialResolution();\n        }\n        //-------------------------------------------------------\n        //-------------------------------------------------------\n        bool Screen::IsA(ChilliSource::InterfaceIDType in_interfaceId) const\n        {\n            return (ChilliSource::Screen::InterfaceID == in_interfaceId || Screen::InterfaceID == in_interfaceId);\n        }\n        //-----------------------------------------------------------\n        //-----------------------------------------------------------\n        const ChilliSource::Vector2& Screen::GetResolution() const\n        {\n            return m_resolution;\n        }\n        //-----------------------------------------------------------\n        //-----------------------------------------------------------\n        f32 Screen::GetDensityScale() const\n        {\n            return m_screenInfo.GetDensityScale();\n        }\n        //----------------------------------------------------------\n        //-----------------------------------------------------------\n        f32 Screen::GetInverseDensityScale() const\n        {\n            return m_screenInfo.GetInverseDensityScale();\n        }\n        //-----------------------------------------------------------\n        //-----------------------------------------------------------\n        ChilliSource::IConnectableEvent<Screen::ResolutionChangedDelegate>& Screen::GetResolutionChangedEvent()\n        {\n            return m_resolutionChangedEvent;\n        }\n        //-----------------------------------------------------------\n        //-----------------------------------------------------------\n        ChilliSource::IConnectableEvent<Screen::DisplayModeChangedDelegate>& Screen::GetDisplayModeChangedEvent()\n        {\n            return m_displayModeChangedEvent;\n        }\n        //----------------------------------------------------------\n\t\t//----------------------------------------------------------\n\t\tvoid Screen::SetResolution(const ChilliSource::Integer2& in_size)\n\t\t{\n\t\t\tCS_LOG_WARNING(\"Screen::SetResolution has no effect on Android\");\n\t\t}\n        //----------------------------------------------------------\n        //----------------------------------------------------------\n        void Screen::SetDisplayMode(DisplayMode in_mode)\n        {\n        \tCS_LOG_WARNING(\"Screen::SetDisplayMode has no effect on Android\");\n        }\n        //----------------------------------------------------------\n        //----------------------------------------------------------\n        std::vector<ChilliSource::Integer2> Screen::GetSupportedFullscreenResolutions() const\n        {\n            return m_screenInfo.GetSupportedFullscreenResolutions();\n        }\n        //-----------------------------------------------------------\n        //------------------------------------------------------------\n        void Screen::OnResolutionChanged(const ChilliSource::Vector2& in_resolution)\n        {\n        \tm_resolution = in_resolution;\n        \tm_resolutionChangedEvent.NotifyConnections(m_resolution);\n        }\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/JNI/Core/Base/Screen.h",
    "content": "//\n//  Screen.h\n//  ChilliSource\n//  Created by Ian Copland on 28/04/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n\n#ifndef _CSBACKEND_PLATFORM_ANDROID_CORE_BASE_SCREEN_H_\n#define _CSBACKEND_PLATFORM_ANDROID_CORE_BASE_SCREEN_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <CSBackend/Platform/Android/Main/JNI/ForwardDeclarations.h>\n#include <ChilliSource/Core/Base/Screen.h>\n#include <ChilliSource/Core/Base/ScreenInfo.h>\n#include <ChilliSource/Core/Event/Event.h>\n\nnamespace CSBackend\n{\n    namespace Android\n    {\n        //----------------------------------------------------------------\n        /// The Android backend for the screen. This provides information on\n        /// the include device's screen such as resolution and density scale.\n        ///\n        /// @author Ian Copland\n        //----------------------------------------------------------------\n\t\tclass Screen final : public ChilliSource::Screen\n\t\t{\n\t\tpublic:\n            CS_DECLARE_NAMEDTYPE(Screen);\n            //-------------------------------------------------------\n\t\t\t/// Queries whether or not this system implements the\n            /// interface with the given Id.\n\t\t\t///\n            /// @author Ian Copland\n            ///\n\t\t\t/// @param The interface Id.\n\t\t\t/// @param Whether system is of given type.\n\t\t\t//-------------------------------------------------------\n\t\t\tbool IsA(ChilliSource::InterfaceIDType in_interfaceId) const override;\n\t\t\t//-----------------------------------------------------------\n\t\t\t/// @author Ian Copland\n\t\t\t///\n\t\t\t/// @return Vector containing the width and height of screen\n            /// space available to the application. For a desktop app\n            /// this will be the current size of the window. For a mobile\n            /// application this will be full size of the screen.\n\t\t\t//-----------------------------------------------------------\n\t\t\tconst ChilliSource::Vector2& GetResolution() const override;\n            //-----------------------------------------------------------\n            /// The density scale factor as reported by the device. What\n            /// this factor relates to is platform dependant. On iOS it\n            /// is relative to a non-retina screen resolution. On Android\n            /// it is a factor that changes depending on whether the\n            /// screen is considered, low, medium, high or extra high\n            /// density.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @return The density scale factor of the screen\n            //-----------------------------------------------------------\n            f32 GetDensityScale() const override;\n            //-----------------------------------------------------------\n            /// @author Ian Copland\n            ///\n            /// @return The inverse of density scale factor of the screen\n            //-----------------------------------------------------------\n            f32 GetInverseDensityScale() const override;\n            //-----------------------------------------------------------\n            /// @author Ian Copland\n\t\t\t///\n\t\t\t/// @return An event that is called when the screen resolution\n            /// changes.\n\t\t\t//-----------------------------------------------------------\n            ChilliSource::IConnectableEvent<ResolutionChangedDelegate>& GetResolutionChangedEvent() override;\n            //-----------------------------------------------------------\n            /// @author S Downie\n\t\t\t///\n\t\t\t/// @return An event that is called when the screen display\n            /// mode changes.\n\t\t\t//-----------------------------------------------------------\n            ChilliSource::IConnectableEvent<DisplayModeChangedDelegate>& GetDisplayModeChangedEvent() override;\n            //----------------------------------------------------------\n            /// Does nothing on Android due to fixed screen size\n            ///\n            /// @author S Downie\n            ///\n\t\t\t/// @param Screen size in pixels\n\t\t\t//----------------------------------------------------------\n\t\t\tvoid SetResolution(const ChilliSource::Integer2& in_size) override;\n            //----------------------------------------------------------\n            /// Does nothing on Android due to fixed screen state\n            ///\n            /// @author S Downie\n            //----------------------------------------------------------\n            void SetDisplayMode(DisplayMode in_mode) override;\n            //----------------------------------------------------------\n            /// @author S Downie\n            ///\n            /// @return A list of resolutions supported by the display\n            //----------------------------------------------------------\n            std::vector<ChilliSource::Integer2> GetSupportedFullscreenResolutions() const override;\n            //-----------------------------------------------------------\n            /// Called when the screen resolution changes. This will update\n            /// the screen resolution and notify listeners that the resolution\n            /// has changed. This is for internal use and should not be\n            /// called manually.\n            ///\n\t\t\t/// @author Ian Copland\n            ///\n            /// @param The new resolution.\n\t\t\t//------------------------------------------------------------\n\t\t\tvoid OnResolutionChanged(const ChilliSource::Vector2& in_resolution);\n        private:\n            friend ChilliSource::ScreenUPtr ChilliSource::Screen::Create(const ChilliSource::ScreenInfo& screenInfo);\n            //-------------------------------------------------------\n\t\t\t/// Private constructor to force the use of the Create()\n            /// factory method.\n\t\t\t///\n            /// @author Ian Copland\n\t\t\t//-------------------------------------------------------\n\t\t\tScreen(const ChilliSource::ScreenInfo& screenInfo);\n\n            ChilliSource::ScreenInfo m_screenInfo;\n            ChilliSource::Vector2 m_resolution;\n\n            ChilliSource::Event<ResolutionChangedDelegate> m_resolutionChangedEvent;\n            ChilliSource::Event<DisplayModeChangedDelegate> m_displayModeChangedEvent;\n        };\n    }\n}\n\n#endif\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/JNI/Core/Base/SystemInfoFactory.cpp",
    "content": "//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n\n#include <ChilliSource/Core/Base/DeviceInfo.h>\n#include <ChilliSource/Core/Base/ScreenInfo.h>\n#include <ChilliSource/Core/Base/SystemInfo.h>\n\n#include <CSBackend/Platform/Android/Main/JNI/Core/Base/CoreJavaInterface.h>\n#include <CSBackend/Platform/Android/Main/JNI/Core/Base/DeviceJavaInterface.h>\n#include <CSBackend/Platform/Android/Main/JNI/Core/Base/SystemInfoFactory.h>\n#include <CSBackend/Platform/Android/Main/JNI/Core/Java/JavaInterfaceManager.h>\n#include <CSBackend/Rendering/OpenGL/Base/RenderInfoFactory.h>\n\n#include <vector>\n\nnamespace CSBackend\n{\n    namespace Android\n    {\n\t\tnamespace\n\t\t{\n\t\t\tconst std::string k_defaultLocale = \"en_US\";\n\t\t\tconst std::string k_defaultLanguage = \"en\";\n\n\t\t\t/// Returns the language portion of a locale code.\n\t\t\t///\n\t\t\t/// @param in_locale\n\t\t\t///         The locale code.\n\t\t\t///\n\t\t\t/// @return The language code.\n\t\t\t///\n\t\t\tstd::string ParseLanguageFromLocale(const std::string& in_locale) noexcept\n\t\t\t{\n\t\t\t\tstd::vector<std::string> strLocaleBrokenUp = ChilliSource::StringUtils::Split(in_locale, \"_\", 0);\n\n\t\t\t\tif (strLocaleBrokenUp.size() > 0)\n\t\t\t\t{\n\t\t\t\t\treturn strLocaleBrokenUp[0];\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\treturn k_defaultLanguage;\n\t\t\t\t}\n\t\t\t}\n\n\t\t}\n\n\t\t//---------------------------------------------------------\n\t\tChilliSource::SystemInfoCUPtr SystemInfoFactory::CreateSystemInfo() noexcept\n\t\t{\n\t\t    DeviceJavaInterfaceSPtr deviceJavaInterface(new DeviceJavaInterface());\n            JavaInterfaceManager::GetSingletonPtr()->AddJavaInterface(deviceJavaInterface);\n\n            CoreJavaInterfaceSPtr coreJavaInterface = JavaInterfaceManager::GetSingletonPtr()->GetJavaInterface<CoreJavaInterface>();\n            CS_ASSERT(coreJavaInterface != nullptr, \"Cannot get CoreJavaInterface!\");\n\n            // Create DeviceInfo.\n            ChilliSource::DeviceInfo deviceInfo(deviceJavaInterface->GetDeviceModel(), deviceJavaInterface->GetDeviceModelType(), deviceJavaInterface->GetDeviceManufacturer(), deviceJavaInterface->GetUniqueId(), deviceJavaInterface->GetDefaultLocaleCode(), ParseLanguageFromLocale(deviceJavaInterface->GetDefaultLocaleCode()), ChilliSource::ToString(deviceJavaInterface->GetOSVersionCode()), deviceJavaInterface->GetNumberOfCores());\n\n            // Create ScreenInfo.\n            ChilliSource::Vector2 currentResolution((f32)coreJavaInterface->GetScreenWidth(), (f32)coreJavaInterface->GetScreenHeight());\n            f32 screenDensity = coreJavaInterface->GetScreenDensity();\n            std::vector<ChilliSource::Integer2> supportedResolutions;\n            supportedResolutions.push_back(ChilliSource::Integer2((s32)currentResolution.x, (s32)currentResolution.y));\n            supportedResolutions.push_back(ChilliSource::Integer2((s32)currentResolution.y, (s32)currentResolution.x));\n\n            ChilliSource::RenderInfo renderInfo = OpenGL::RenderInfoFactory::CreateRenderInfo();\n            ChilliSource::ScreenInfo screenInfo(currentResolution, screenDensity, 1.0f / screenDensity, supportedResolutions);\n\n\t\t    // Create SystemInfo.\n\t\t    ChilliSource::SystemInfoUPtr systemInfo(new ChilliSource::SystemInfo(deviceInfo, screenInfo, renderInfo, coreJavaInterface->GetApplicationVersionName()));\n\n\t\t    return std::move(systemInfo);\n\t\t}\n    }\n}\n\n#endif"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/JNI/Core/Base/SystemInfoFactory.h",
    "content": "//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Base/SystemInfo.h>\n#include <CSBackend/Platform/Android/Main/JNI/ForwardDeclarations.h>\n\nnamespace CSBackend\n{\n    namespace Android\n    {\n        /// A factory for creating new instances of SystemInfo. This will query the\n        /// DeviceJavaInterface to gather information about the device.\n        ///\n        namespace SystemInfoFactory\n        {\n            /// This function creates the new SystemInfo instance.\n            /// @return The new instance.\n            ///\n            ChilliSource::SystemInfoCUPtr CreateSystemInfo() noexcept;\n        }\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/JNI/Core/DialogueBox/DialogueBoxJavaInterface.cpp",
    "content": "//\n//  DialogueBoxJavaInterface.cpp\n//  ChilliSource\n//  Created by Ian Copland on 04/03/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n\n#include <CSBackend/Platform/Android/Main/JNI/Core/DialogueBox/DialogueBoxJavaInterface.h>\n\n#include <CSBackend/Platform/Android/Main/JNI/Core/DialogueBox/DialogueBoxSystem.h>\n#include <CSBackend/Platform/Android/Main/JNI/Core/Java/JavaInterfaceManager.h>\n#include <CSBackend/Platform/Android/Main/JNI/Core/Java/JavaUtils.h>\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/Threading/TaskScheduler.h>\n\n#include <jni.h>\n\n//-------------------------------------------------\n/// C function declarations\n//-------------------------------------------------\nextern \"C\"\n{\n\tvoid Java_com_chilliworks_chillisource_core_DialogueBoxNativeInterface_onDialogueConfirmPressed(JNIEnv* in_env, jobject in_this, s32 in_id);\n\tvoid Java_com_chilliworks_chillisource_core_DialogueBoxNativeInterface_onDialogueCancelPressed(JNIEnv* in_env, jobject in_this, s32 in_id);\n}\n\n//-------------------------------------------------\n/// Interface function called from java. This is\n/// called when a system dialog has it's confirm\n/// option pressed.\n///\n/// @author Ian Copland\n///\n/// @param The jni environment.\n/// @param The java object calling the function\n/// @param Dialog ID\n//-------------------------------------------------\nvoid Java_com_chilliworks_chillisource_core_DialogueBoxNativeInterface_onDialogueConfirmPressed(JNIEnv* in_env, jobject in_this, s32 in_id)\n{\n    ChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(CS::TaskType::k_mainThread, [=](const CS::TaskContext& in_taskContext)\n    {\n        CSBackend::Android::DialogueBoxSystem* dialogueBoxSystem = ChilliSource::Application::Get()->GetSystem<CSBackend::Android::DialogueBoxSystem>();\n        if (dialogueBoxSystem != nullptr)\n        {\n            dialogueBoxSystem->OnSystemConfirmDialogueResult((u32)in_id, ChilliSource::DialogueBoxSystem::DialogueResult::k_confirm);\n        }\n    });\n}\n//-------------------------------------------------\n/// Interface function called from java. This is\n/// called when a system dialog has it's cancel\n/// option pressed\n///\n/// @author Ian Copland\n///\n/// @param The jni environment.\n/// @param The java object calling the function\n/// @param Dialog ID\n//------------------------------------------------\nvoid Java_com_chilliworks_chillisource_core_DialogueBoxNativeInterface_onDialogueCancelPressed(JNIEnv* in_env, jobject in_this, s32 in_id)\n{\n    ChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(CS::TaskType::k_mainThread, [=](const CS::TaskContext& in_taskContext)\n    {\n        CSBackend::Android::DialogueBoxSystem* dialogueBoxSystem = ChilliSource::Application::Get()->GetSystem<CSBackend::Android::DialogueBoxSystem>();\n        if (dialogueBoxSystem != nullptr)\n        {\n            dialogueBoxSystem->OnSystemConfirmDialogueResult((u32)in_id, ChilliSource::DialogueBoxSystem::DialogueResult::k_cancel);\n        }\n    });\n}\n\nnamespace CSBackend\n{\n\tnamespace Android\n\t{\n\t\tCS_DEFINE_NAMEDTYPE(DialogueBoxJavaInterface);\n\n\t\t//--------------------------------------------------\n\t\t//--------------------------------------------------\n\t\tDialogueBoxJavaInterface::DialogueBoxJavaInterface()\n\t\t{\n\t\t\tCreateNativeInterface(\"com/chilliworks/chillisource/core/DialogueBoxNativeInterface\");\n\t\t\tCreateMethodReference(\"makeToast\", \"(Ljava/lang/String;)V\");\n\t\t\tCreateMethodReference(\"showSystemConfirmDialogue\", \"(ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V\");\n\t\t\tCreateMethodReference(\"showSystemDialogue\", \"(ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;)V\");\n\t\t}\n\t\t//------------------------------------------------------\n\t\t//------------------------------------------------------\n\t\tbool DialogueBoxJavaInterface::IsA(ChilliSource::InterfaceIDType in_interfaceId) const\n\t\t{\n\t\t\treturn (in_interfaceId == DialogueBoxJavaInterface::InterfaceID);\n\t\t}\n        //------------------------------------------------------\n        //------------------------------------------------------\n        void DialogueBoxJavaInterface::MakeToast(const std::string& in_text)\n        {\n\t\t\tJNIEnv* env = JavaInterfaceManager::GetSingletonPtr()->GetJNIEnvironmentPtr();\n\t\t\tjstring message = JavaUtils::CreateJStringFromSTDString(in_text);\n\t\t\tenv->CallVoidMethod(GetJavaObject(), GetMethodID(\"makeToast\"), message);\n\t\t\tenv->DeleteLocalRef(message);\n        }\n        //------------------------------------------------------\n        //------------------------------------------------------\n        void DialogueBoxJavaInterface::ShowSystemConfirmDialogue(s32 in_dialogID, const std::string& in_title, const std::string& in_message, const std::string& in_confirm, const std::string& in_cancel)\n        {\n\t\t\tJNIEnv* env = JavaInterfaceManager::GetSingletonPtr()->GetJNIEnvironmentPtr();\n\t\t\tjstring title = JavaUtils::CreateJStringFromSTDString(in_title);\n\t\t\tjstring message = JavaUtils::CreateJStringFromSTDString(in_message);\n\t\t\tjstring confirm = JavaUtils::CreateJStringFromSTDString(in_confirm);\n\t\t\tjstring cancel = JavaUtils::CreateJStringFromSTDString(in_cancel);\n\t\t\tenv->CallVoidMethod(GetJavaObject(), GetMethodID(\"showSystemConfirmDialogue\"), in_dialogID, title, message, confirm, cancel);\n\t\t\tenv->DeleteLocalRef(title);\n\t\t\tenv->DeleteLocalRef(message);\n\t\t\tenv->DeleteLocalRef(confirm);\n\t\t\tenv->DeleteLocalRef(cancel);\n        }\n        //-----------------------------------------------------\n        //-----------------------------------------------------\n        void DialogueBoxJavaInterface::ShowSystemDialogue(s32 in_dialogID, const std::string& in_title, const std::string& in_message, const std::string& in_confirm)\n        {\n\t\t\tJNIEnv* env = JavaInterfaceManager::GetSingletonPtr()->GetJNIEnvironmentPtr();\n\t\t\tjstring title = JavaUtils::CreateJStringFromSTDString(in_title);\n\t\t\tjstring message = JavaUtils::CreateJStringFromSTDString(in_message);\n\t\t\tjstring confirm = JavaUtils::CreateJStringFromSTDString(in_confirm);\n\t\t\tenv->CallVoidMethod(GetJavaObject(), GetMethodID(\"showSystemDialogue\"), in_dialogID, title, message, confirm);\n\t\t\tenv->DeleteLocalRef(title);\n\t\t\tenv->DeleteLocalRef(message);\n\t\t\tenv->DeleteLocalRef(confirm);\n        }\n\t}\n}\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/JNI/Core/DialogueBox/DialogueBoxJavaInterface.h",
    "content": "//\n//  DialogueBoxJavaInterface.h\n//  ChilliSource\n//  Created by Ian Copland on 04/03/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n\n#ifndef _CSBACKEND_PLATFORM_ANDROID_CORE_DIALOGUEBOX_DIALOGUEBOXJAVAINTERFACE_H_\n#define _CSBACKEND_PLATFORM_ANDROID_CORE_DIALOGUEBOX_DIALOGUEBOXJAVAINTERFACE_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <CSBackend/Platform/Android/Main/JNI/ForwardDeclarations.h>\n\n#include <CSBackend/Platform/Android/Main/JNI/Core/Java/JavaInterface.h>\n\nnamespace CSBackend\n{\n\tnamespace Android\n\t{\n\t\t//-----------------------------------------------------\n\t\t/// An interface for communicating with Java system\n\t\t/// dialogue box functionality\n\t\t//-----------------------------------------------------\n\t\tclass DialogueBoxJavaInterface : public IJavaInterface\n\t\t{\n\t\tpublic:\n\t\t\tCS_DECLARE_NAMEDTYPE(DialogueBoxJavaInterface);\n\t\t\t//-----------------------------------------------\n\t\t\t/// Constructor\n\t\t\t///\n\t\t\t/// @author Ian Copland\n\t\t\t//-----------------------------------------------\n\t\t\tDialogueBoxJavaInterface();\n\t\t\t//-----------------------------------------------\n\t\t\t/// @author Ian Copland\n\t\t\t///\n\t\t\t/// @return whether or not this object implements\n\t\t\t/// the given interface.\n\t\t\t//-----------------------------------------------\n\t\t\tbool IsA(ChilliSource::InterfaceIDType in_interfaceId) const;\n            //-----------------------------------------------\n            /// Display the systems confirmation dialog\n            ///\n\t\t\t/// @author Ian Copland\n\t\t\t///\n            /// @param ID that is returned in pressed delegate\n            /// @param Title text (UTF-8)\n            /// @param Message text (UTF-8)\n            /// @param Confirm text (UTF-8)\n            /// @param Cancel text (UTF-8)\n            //-----------------------------------------------\n            void ShowSystemConfirmDialogue(s32 in_dialogID, const std::string& in_title, const std::string& in_message, const std::string& in_confirm, const std::string& in_cancel);\n            //-----------------------------------------------\n            /// Display the systems confirmation dialog\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param ID that is returned in pressed delegate\n            /// @param Title text (UTF-8)\n            /// @param Message text (UTF-8)\n            /// @param Confirm text (UTF-8)\n            //-----------------------------------------------\n            void ShowSystemDialogue(s32 in_dialogID, const std::string& in_title, const std::string& in_message, const std::string& in_confirm);\n            //-----------------------------------------------\n            /// Display a toast notification with the given text\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param Text (UTF-8)\n            //-----------------------------------------------\n            void MakeToast(const std::string& in_text);\n\t\t};\n\t}\n}\n\n#endif\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/JNI/Core/DialogueBox/DialogueBoxSystem.cpp",
    "content": "//\n//  DialogueBoxSystem.cpp\n//  ChilliSource\n//  Created by Ian Copland on 04/03/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n\n#include <CSBackend/Platform/Android/Main/JNI/Core/DialogueBox/DialogueBoxSystem.h>\n\n#include <CSBackend/Platform/Android/Main/JNI/Core/DialogueBox/DialogueBoxJavaInterface.h>\n#include <CSBackend/Platform/Android/Main/JNI/Core/Java/JavaInterfaceManager.h>\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/Base/PlatformSystem.h>\n#include <ChilliSource/Core/Threading/TaskScheduler.h>\n\nnamespace CSBackend\n{\n\tnamespace Android\n\t{\n        CS_DEFINE_NAMEDTYPE(DialogueBoxSystem);\n        //----------------------------------------------------\n        //----------------------------------------------------\n        DialogueBoxSystem::DialogueBoxSystem()\n        {\n        \tm_dialogueBoxJI = JavaInterfaceManager::GetSingletonPtr()->GetJavaInterface<DialogueBoxJavaInterface>();\n        \tif (m_dialogueBoxJI == nullptr)\n        \t{\n        \t\tm_dialogueBoxJI = std::make_shared<DialogueBoxJavaInterface>();\n        \t\tJavaInterfaceManager::GetSingletonPtr()->AddJavaInterface(m_dialogueBoxJI);\n        \t}\n        }\n        //----------------------------------------------------\n        //----------------------------------------------------\n        bool DialogueBoxSystem::IsA(ChilliSource::InterfaceIDType in_interfaceId) const\n        {\n            return (DialogueBoxSystem::InterfaceID == in_interfaceId || ChilliSource::DialogueBoxSystem::InterfaceID == in_interfaceId);\n        }\n        //-----------------------------------------------------\n        //-----------------------------------------------------\n        void DialogueBoxSystem::ShowSystemDialogue(u32 in_id, const ChilliSource::DialogueBoxSystem::DialogueDelegate& in_delegate, const std::string& in_title, const std::string& in_message, const std::string& in_confirm)\n        {\n            CS_ASSERT(ChilliSource::Application::Get()->GetTaskScheduler()->IsMainThread(), \"System Dialogue requested outside of main thread.\");\n            m_dialogueBoxJI->ShowSystemDialogue(in_id, in_title, in_message, in_confirm);\n            m_activeSysConfirmDelegate = in_delegate;\n        }\n        //-----------------------------------------------------\n        //-----------------------------------------------------\n        void DialogueBoxSystem::ShowSystemConfirmDialogue(u32 in_id, const ChilliSource::DialogueBoxSystem::DialogueDelegate& in_delegate, const std::string& in_title, const std::string& in_message, const std::string& in_confirm, const std::string& in_cancel)\n        {\n            CS_ASSERT(ChilliSource::Application::Get()->GetTaskScheduler()->IsMainThread(), \"System Confirm Dialogue requested outside of main thread.\");\n            m_dialogueBoxJI->ShowSystemConfirmDialogue(in_id, in_title, in_message, in_confirm, in_cancel);\n            m_activeSysConfirmDelegate = in_delegate;\n        }\n        //-----------------------------------------------------\n        //-----------------------------------------------------\n        void DialogueBoxSystem::MakeToast(const std::string& in_text)\n        {\n            CS_ASSERT(ChilliSource::Application::Get()->GetTaskScheduler()->IsMainThread(), \"Tried to make toast outside of main thread.\");\n            m_dialogueBoxJI->MakeToast(in_text);   \n        }\n        //------------------------------------------------------\n        //------------------------------------------------------\n        void DialogueBoxSystem::OnSystemConfirmDialogueResult(u32 in_id, ChilliSource::DialogueBoxSystem::DialogueResult in_result)\n        {\n            if (m_activeSysConfirmDelegate)\n            {\n                m_activeSysConfirmDelegate(in_id, in_result);\n                m_activeSysConfirmDelegate = nullptr;\n            }\n        }\n        //-----------------------------------------------------\n        //-----------------------------------------------------\n        DialogueBoxSystem::~DialogueBoxSystem()\n        {\n        }\n\t}\n}\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/JNI/Core/DialogueBox/DialogueBoxSystem.h",
    "content": "//\n//  DialogueBoxSystem.h\n//  ChilliSource\n//  Created by Ian Copland on 04/03/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n\n#ifndef _CSBACKEND_PLATFORM_ANDROID_CORE_DIALOGUE_DIALOGUESYSTEM_H_\n#define _CSBACKEND_PLATFORM_ANDROID_CORE_DIALOGUE_DIALOGUESYSTEM_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <CSBackend/Platform/Android/Main/JNI/ForwardDeclarations.h>\n#include <ChilliSource/Core/DialogueBox/DialogueBoxSystem.h>\n\nnamespace CSBackend\n{\n\tnamespace Android\n\t{\n\t\t//-----------------------------------------------------------\n\t\t/// A system used to display platform specific system\n        /// dialogue boxes.\n\t\t//-----------------------------------------------------------\n\t\tclass DialogueBoxSystem final : public ChilliSource::DialogueBoxSystem\n\t\t{\n\t\tpublic:\n            CS_DECLARE_NAMEDTYPE(DialogueBoxSystem);\n            //----------------------------------------------------\n            /// Is A\n            ///\n            /// @return Whether this implements the passed in\n            /// interface id.\n            //-----------------------------------------------------\n            bool IsA(ChilliSource::InterfaceIDType in_interfaceId) const override;\n            //-----------------------------------------------------\n            /// Display a system dialog with the given ID and delegate\n            ///\n            /// This isn't thread-safe and must be called on the main thread.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param ID\n            /// @param SystemConfirmDialogDelegate\n            /// @param Title text (UTF-8)\n            /// @param Message text (UTF-8)\n            /// @param Confirm text (UTF-8)\n            //------------------------------------------------------\n            void ShowSystemDialogue(u32 in_id, const ChilliSource::DialogueBoxSystem::DialogueDelegate& in_delegate, const std::string& in_title, const std::string& in_message, const std::string& in_confirm) override;\n            //-----------------------------------------------------\n            /// Display a system confirmation dialog with the given\n            /// ID and delegate.\n            ///\n            /// This isn't thread-safe and must be called on the main thread.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param ID\n            /// @param SystemConfirmDialogDelegate\n            /// @param Title text (UTF-8)\n            /// @param Message text (UTF-8)\n            /// @param Confirm text (UTF-8)\n            /// @param Cancel text (UTF-8)\n            //-----------------------------------------------------\n            void ShowSystemConfirmDialogue(u32 in_id, const ChilliSource::DialogueBoxSystem::DialogueDelegate& in_delegate, const std::string& in_title, const std::string& in_message, const std::string& in_confirm, const std::string& in_cancel) override;\n            //-----------------------------------------------------\n            /// Display a toast notification with the given text\n            ///\n            /// This isn't thread-safe and must be called on the main thread.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param The text to display (UTF-8).\n            //-----------------------------------------------------\n            void MakeToast(const std::string& in_text) override;\n            //------------------------------------------------------\n            /// Triggered from a system dialog confirmation event\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param ID\n            /// @param Result\n            //------------------------------------------------------\n            void OnSystemConfirmDialogueResult(u32 in_id, ChilliSource::DialogueBoxSystem::DialogueResult in_result);\n            //----------------------------------------------------\n\t\t\t/// Destructor.\n            ///\n            /// @author Ian Copland\n\t\t\t//----------------------------------------------------\n            ~DialogueBoxSystem();\n\n\t\tprivate:\n            friend ChilliSource::DialogueBoxSystemUPtr ChilliSource::DialogueBoxSystem::Create();\n            //-------------------------------------------------------\n            /// Private constructor to force use of factory method\n            ///\n            /// @author Ian Copland\n            //-------------------------------------------------------\n            DialogueBoxSystem();\n\n        private:\n            \n            DialogueBoxJavaInterfaceSPtr m_dialogueBoxJI;\n\t\t\tChilliSource::DialogueBoxSystem::DialogueDelegate m_activeSysConfirmDelegate;\n\t\t};\n\t}\n}\n\n#endif\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/JNI/Core/File/FileSystem.cpp",
    "content": "//\n//  FileSystem.cpp\n//  ChilliSource\n//  Created by Ian Copland on 25/03/2011.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2011 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n\n#include <CSBackend/Platform/Android/Main/JNI/Core/File/FileSystem.h>\n\n#include <CSBackend/Platform/Android/Main/JNI/Core/Base/CoreJavaInterface.h>\n#include <CSBackend/Platform/Android/Main/JNI/Core/File/VirtualTextInputStream.h>\n#include <CSBackend/Platform/Android/Main/JNI/Core/Java/JavaInterfaceManager.h>\n#include <CSBackend/Platform/Android/Main/JNI/Core/Java/JavaStaticClass.h>\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/String/StringUtils.h>\n\n#include <cstdio>\n#include <dirent.h>\n#include <errno.h>\n#include <sys/types.h>\n#include <sys/stat.h>\n#include <unistd.h>\n\nnamespace CSBackend\n{\n\tnamespace Android \n\t{\n\t\tnamespace\n\t\t{\n\t\t\tconst char k_assetsPath[] = \"assets/\";\n\t\t\tconst char k_saveDataPath[] = \"files/SaveData/\";\n\t\t\tconst char k_dlcPath[] = \"cache/DLC/\";\n\t\t\tconst char k_cachePath[] = \"cache/Cache/\";\n\t\t\tconst char k_packagePath[] = \"AppResources/\";\n\t\t\tconst char k_chilliSourcePath[] = \"CSResources/\";\n\n            //------------------------------------------------------------------------------\n\t\t\t/// @author Ian Copland\n\t\t\t///\n\t\t\t/// @return The file path to the zip. This is dependent on the current Android\n\t\t\t/// Flavour: Google Play builds will refer to the OBB file, while Amazon builds\n\t\t\t/// will refer to the the APK.\n\t\t\t//------------------------------------------------------------------------------\n\t\t\tstd::string GetZipFilePath()\n\t\t\t{\n#if defined(CS_ANDROIDFLAVOUR_GOOGLEPLAY)\n                JavaStaticClassDef apkExpansionInfoDef(\"com/chilliworks/chillisource/core/ApkExpansionInfo\");\n                apkExpansionInfoDef.AddMethod(\"getFilePath\", \"()Ljava/lang/String;\");\n                JavaStaticClass apkExpansionInfo(apkExpansionInfoDef);\n                return apkExpansionInfo.CallStringMethod(\"getFilePath\");\n#elif defined(CS_ANDROIDFLAVOUR_AMAZON)\n                auto coreJI = JavaInterfaceManager::GetSingletonPtr()->GetJavaInterface<CoreJavaInterface>();\n                return coreJI->GetAPKDirectory();\n#else\n                CS_LOG_FATAL(\"File System does not support this Android Flavour.\");\n                return \"\";\n#endif\n\t\t\t}\n\t\t\t//------------------------------------------------------------------------------\n\t\t\t/// @author Ian Copland\n\t\t\t///\n\t\t\t/// @return the directory within the zip file which will be used as the root.\n\t\t\t/// This is dependent on the Android Flavour: Google Play builds will use the\n\t\t\t/// root of the zip, while Amazon builds will use the assets/ directory.\n\t\t\t//------------------------------------------------------------------------------\n\t\t\tstd::string GetZipRootDirectory()\n\t\t\t{\n#if defined(CS_ANDROIDFLAVOUR_GOOGLEPLAY)\n\t\t\t\treturn \"\";\n#elif defined(CS_ANDROIDFLAVOUR_AMAZON)\n\t\t\t\treturn \"assets/\";\n#else\n\t\t\t\tCS_LOG_FATAL(\"File System does not support this Android Flavour.\");\n\t\t\t\treturn \"\";\n#endif\n\t\t\t}\n\t\t\t//------------------------------------------------------------------------------\n\t\t\t/// Creates a new directory at the given directory path.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param The directory path.\n            ///\n            /// @return Whether or not the creation succeeded.\n\t\t\t//------------------------------------------------------------------------------\n\t\t\tbool CreateDirectory(const std::string& in_directoryPath)\n\t\t\t{\n\t\t\t\ts32 error = mkdir(in_directoryPath.c_str(), 0777);\n\t\t\t\tif (error == -1)\n\t\t\t\t{\n\t\t\t\t\ts32 errorType = errno;\n\t\t\t\t\tif (errorType != EEXIST)\n\t\t\t\t\t{\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\t//------------------------------------------------------------------------------\n\t\t\t/// returns whether or not a file exists\n\t\t\t///\n\t\t\t/// @author Ian Copland\n\t\t\t///\n\t\t\t/// @param the filepath.\n\t\t\t///\n\t\t\t/// @return Whether or not it exists.\n\t\t\t//------------------------------------------------------------------------------\n    \t\tbool DoesFileExist(const std::string& in_path)\n    \t\t{\n    \t\t\tstruct stat itemStat;\n    \t\t\tif (stat(in_path.c_str(), &itemStat) == 0)\n    \t\t\t{\n    \t\t\t\tif (S_ISDIR(itemStat.st_mode) == false)\n    \t\t\t\t{\n    \t\t\t\t\treturn true;\n    \t\t\t\t}\n    \t\t\t}\n\n    \t\t\treturn false;\n    \t\t}\n\t\t\t//------------------------------------------------------------------------------\n\t\t\t/// returns whether or not a directory exists\n\t\t\t///\n\t\t\t/// @author Ian Copland\n\t\t\t///\n\t\t\t/// @param the directory path.\n\t\t\t///\n\t\t\t/// @return whether or not it exists.\n\t\t\t//------------------------------------------------------------------------------\n    \t\tbool DoesDirectoryExist(const std::string& in_path)\n    \t\t{\n    \t\t\tstruct stat itemStats;\n    \t\t\tif (stat(in_path.c_str(), &itemStats) == 0)\n    \t\t\t{\n    \t\t\t\tif (S_ISDIR(itemStats.st_mode) == true)\n    \t\t\t\t{\n    \t\t\t\t\treturn true;\n    \t\t\t\t}\n    \t\t\t}\n\n    \t\t\treturn false;\n    \t\t}\n\t\t\t//------------------------------------------------------------------------------\n\t\t\t/// Deletes a directory and all its contents.\n\t\t\t///\n\t\t\t/// @author Ian Copland\n\t\t\t///\n\t\t\t/// @param The directory path.\n\t\t\t///\n\t\t\t/// @return Whether or not the directory was successfully deleted.\n\t\t\t//------------------------------------------------------------------------------\n\t\t\tbool DeleteDirectory(const std::string& in_directoryPath)\n\t\t\t{\n\t\t\t\tstd::string directoryPath = ChilliSource::StringUtils::StandardiseDirectoryPath(in_directoryPath);\n\t\t\t\tif (DoesDirectoryExist(directoryPath) == false)\n\t\t\t\t{\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\tDIR* directory = opendir(directoryPath.c_str());\n\t\t\t\tif(directory == nullptr)\n\t\t\t\t{\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\tstruct dirent* directoryItem;\n\t\t\t\twhile ((directoryItem = readdir(directory)) != nullptr)\n\t\t\t\t{\n\t\t\t\t\tstd::string itemName = directoryItem->d_name;\n\t\t\t\t\tif (itemName == \".\" || itemName == \"..\")\n\t\t\t\t\t{\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tstruct stat itemStats;\n\t\t\t\t\tstd::string itemPath = directoryPath + itemName + \"\\0\";\n\t\t\t\t\tif (stat(itemPath.c_str(), &itemStats) != 0)\n\t\t\t\t\t{\n\t\t\t\t\t    return false;\n\t\t\t\t\t}\n\n                    if (S_ISDIR(itemStats.st_mode) == true)\n                    {\n                        if (DeleteDirectory(itemPath) == false)\n                        {\n                            return false;\n                        }\n                    }\n                    else\n                    {\n                        unlink(itemPath.c_str());\n                    }\n\t\t\t\t}\n\t\t\t\tclosedir(directory);\n\n\t\t\t\t//remove the directory\n\t\t\t\tif (rmdir(directoryPath.c_str()) != 0)\n\t\t\t\t{\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\treturn true;\n\t\t\t}\n            //------------------------------------------------------------------------------\n            /// Builds a list of either file or directories paths in the directory at the\n            /// given path, optionally recursing into sub-directories. Whether or not this\n            /// searched for files or directories is denoted by the in_searchForDirectories\n            /// flag.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param out_directoryPaths - [Output] The output directory path list. This\n            /// is not cleared prior to further informating being added, so care needs to\n            /// be taken to ensure the list is empty prior to calling.\n            /// @param in_directoryPath - The path to search for directories in.\n            /// @param in_searchForDirectories - Whether we are looking for directories\n            /// or files.\n            /// @param in_recursive - Whether or not to recurse into sub-directories.\n            /// @param in_relativeParentDirectory - [Optional] The path to be prefixed to\n            /// each path found in this directory. This is mostly used for recursion into\n            /// sub-directories and shouldn't otherwise be set.\n            ///\n            /// @return Whether or not this was successful.\n            //------------------------------------------------------------------------------\n\t\t\tbool GetPaths(std::vector<std::string>& out_directoryPaths, const std::string& in_directoryPath, bool in_searchForDirectories,\n\t\t\t    bool in_recursive, const std::string& in_relativeParentDirectory = \"\")\n\t\t\t{\n\t\t\t    std::string directoryPath = ChilliSource::StringUtils::StandardiseDirectoryPath(in_directoryPath);\n\t\t\t    std::string relativeParentDirectory = ChilliSource::StringUtils::StandardiseDirectoryPath(in_relativeParentDirectory);\n\n                DIR* directory = opendir(directoryPath.c_str());\n                if(directory == nullptr)\n                {\n                    return false;\n                }\n\n                bool success = true;\n                struct dirent* item;\n                while ((item = readdir(directory)) != nullptr && success == true)\n                {\n                    std::string itemName(item->d_name);\n                    std::string fullItemPath = directoryPath + itemName;\n\n                    if (itemName == \".\" || itemName == \"..\")\n                    {\n                        continue;\n                    }\n\n                    struct stat dirStats;\n                    if (stat(fullItemPath.c_str(), &dirStats) != 0)\n                    {\n                        success = false;\n                        break;\n                    }\n\n                    if (S_ISDIR(dirStats.st_mode) == true)\n                    {\n                        std::string relativeItemPath = relativeParentDirectory + ChilliSource::StringUtils::StandardiseDirectoryPath(itemName);\n                        if (in_searchForDirectories == true)\n                        {\n                            out_directoryPaths.push_back(relativeItemPath);\n                        }\n\n                        if (in_recursive == true)\n                        {\n                            fullItemPath = ChilliSource::StringUtils::StandardiseDirectoryPath(fullItemPath);\n                            if (GetPaths(out_directoryPaths, fullItemPath, in_searchForDirectories, true, relativeItemPath) == false)\n                            {\n                                success = false;\n                                break;\n                            }\n                        }\n                    }\n                    else if (in_searchForDirectories == false)\n                    {\n                        std::string relativeItemPath = relativeParentDirectory + ChilliSource::StringUtils::StandardiseFilePath(itemName);\n                        out_directoryPaths.push_back(relativeItemPath);\n                    }\n                }\n\n                closedir(directory);\n\n                return success;\n\t\t\t}\n\t\t}\n\n\t\tCS_DEFINE_NAMEDTYPE(FileSystem);\n\t\t//------------------------------------------------------------------------------\n\t\t//------------------------------------------------------------------------------\n\t\tFileSystem::FileSystem()\n\t\t{\n\t\t\tCoreJavaInterfaceSPtr coreJI = JavaInterfaceManager::GetSingletonPtr()->GetJavaInterface<CoreJavaInterface>();\n\n\t\t\tstd::string externalStorage = coreJI->GetExternalStorageDirectory();\n\t\t\tif (externalStorage == \"\")\n\t\t\t{\n\t\t\t\tCS_LOG_FATAL(\"File System: Cannot access External Storage.\");\n\t\t\t}\n\n\t\t\t//create the base directories\n\t\t\texternalStorage = ChilliSource::StringUtils::StandardiseDirectoryPath(externalStorage);\n\t\t\tm_storagePath = externalStorage + \"Android/data/\" + coreJI->GetPackageName() + \"/\";\n\n\t\t\tCSBackend::Android::CreateDirectory(externalStorage + \"Android/\");\n\t\t\tCSBackend::Android::CreateDirectory(externalStorage + \"Android/data/\");\n\t\t\tCSBackend::Android::CreateDirectory(externalStorage + \"Android/data/\" + coreJI->GetPackageName() + \"/\");\n\t\t\tCSBackend::Android::CreateDirectory(externalStorage + \"Android/data/\" + coreJI->GetPackageName() + \"/files/\");\n\t\t\tCSBackend::Android::CreateDirectory(externalStorage + \"Android/data/\" + coreJI->GetPackageName() + \"/cache/\");\n\n\t\t\tCSBackend::Android::CreateDirectory(GetAbsolutePathToStorageLocation(ChilliSource::StorageLocation::k_saveData));\n\t\t\tCS_ASSERT(CSBackend::Android::DoesDirectoryExist(GetAbsolutePathToStorageLocation(ChilliSource::StorageLocation::k_saveData)) == true, \"Could not create SaveData storage location.\");\n\n\t\t\tCSBackend::Android::CreateDirectory(GetAbsolutePathToStorageLocation(ChilliSource::StorageLocation::k_cache));\n\t\t\tCS_ASSERT(CSBackend::Android::DoesDirectoryExist(GetAbsolutePathToStorageLocation(ChilliSource::StorageLocation::k_cache)) == true, \"Could not create Cache storage location.\");\n\n\t\t\tCSBackend::Android::CreateDirectory(GetAbsolutePathToStorageLocation(ChilliSource::StorageLocation::k_DLC));\n\t\t\tCS_ASSERT(CSBackend::Android::DoesDirectoryExist(GetAbsolutePathToStorageLocation(ChilliSource::StorageLocation::k_DLC)) == true, \"Could not create DLC storage location.\");\n\n\t\t\tm_zipFilePath = CSBackend::Android::GetZipFilePath();\n            m_zippedFileSystem = ZippedFileSystemUPtr(new ZippedFileSystem(m_zipFilePath, GetZipRootDirectory()));\n            if (m_zippedFileSystem->IsValid() == false)\n            {\n            \tCS_LOG_FATAL(\"File system cannot read Package.\");\n            }\n\t\t}\n\t\t//------------------------------------------------------------------------------\n\t\t//------------------------------------------------------------------------------\n\t\tbool FileSystem::IsA(ChilliSource::InterfaceIDType in_interfaceId) const\n\t\t{\n\t\t\treturn (ChilliSource::FileSystem::InterfaceID == in_interfaceId || FileSystem::InterfaceID == in_interfaceId);\n\t\t}\n\t\t//--------------------------------------------------------------\n        //--------------------------------------------------------------\n        ChilliSource::ITextInputStreamUPtr FileSystem::CreateTextInputStream(ChilliSource::StorageLocation in_storageLocation, const std::string& in_filePath) const\n        {\n        \tChilliSource::ITextInputStreamUPtr textInputStream = nullptr;\n\n        \tswitch (in_storageLocation)\n\t\t\t{\n\t\t\t\tcase ChilliSource::StorageLocation::k_package:\n\t\t\t\tcase ChilliSource::StorageLocation::k_chilliSource:\n\t\t\t\t{\n\t\t\t\t\tauto absFilePath = GetAbsolutePathToStorageLocation(in_storageLocation) + ChilliSource::StringUtils::StandardiseFilePath(in_filePath);\n                    textInputStream = m_zippedFileSystem->CreateTextInputStream(absFilePath);\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase ChilliSource::StorageLocation::k_DLC:\n\t\t\t\t{\n\t\t\t\t\tif (DoesFileExistInCachedDLC(in_filePath) == true)\n\t\t\t\t\t{\n\t\t\t\t\t\tauto absFilePath = GetAbsolutePathToStorageLocation(in_storageLocation) + ChilliSource::StringUtils::StandardiseFilePath(in_filePath);\n\t\t\t\t\t\ttextInputStream = ChilliSource::ITextInputStreamUPtr(new ChilliSource::TextInputStream(absFilePath));\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tauto absFilePath = GetAbsolutePathToStorageLocation(ChilliSource::StorageLocation::k_package) + ChilliSource::StringUtils::StandardiseFilePath(in_filePath);\n                        textInputStream = m_zippedFileSystem->CreateTextInputStream(absFilePath);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tdefault:\n\t\t\t\t{\n\t\t\t\t\tauto absFilePath = GetAbsolutePathToStorageLocation(in_storageLocation) + ChilliSource::StringUtils::StandardiseFilePath(in_filePath);\n\t\t\t\t\ttextInputStream = ChilliSource::ITextInputStreamUPtr(new ChilliSource::TextInputStream(absFilePath));\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif(textInputStream != nullptr && textInputStream->IsValid())\n\t\t\t{\n\t\t\t\treturn textInputStream;\n\t\t\t}\n\t\t\telse \n\t\t\t{\n\t\t\t\treturn nullptr;\n\t\t\t}\n        }\n        //--------------------------------------------------------------\n        //--------------------------------------------------------------\n        ChilliSource::IBinaryInputStreamUPtr FileSystem::CreateBinaryInputStream(ChilliSource::StorageLocation in_storageLocation, const std::string& in_filePath) const\n        {\n        \tChilliSource::IBinaryInputStreamUPtr binaryInputStream = nullptr;\n\n        \tswitch (in_storageLocation)\n        \t{\n        \t\tcase ChilliSource::StorageLocation::k_package:\n        \t\tcase ChilliSource::StorageLocation::k_chilliSource:\n        \t\t{\n        \t\t\tauto absFilePath = GetAbsolutePathToStorageLocation(in_storageLocation) + ChilliSource::StringUtils::StandardiseFilePath(in_filePath);\n                    binaryInputStream = m_zippedFileSystem->CreateBinaryInputStream(absFilePath);\n        \t\t\tbreak;\n        \t\t}\n        \t\tcase ChilliSource::StorageLocation::k_DLC:\n        \t\t{\n        \t\t\tif (DoesFileExistInCachedDLC(in_filePath) == true)\n        \t\t\t{\n        \t\t\t\tauto absFilePath = GetAbsolutePathToStorageLocation(in_storageLocation) + ChilliSource::StringUtils::StandardiseFilePath(in_filePath);\n        \t\t\t\tbinaryInputStream = ChilliSource::IBinaryInputStreamUPtr(new ChilliSource::BinaryInputStream(absFilePath));\n        \t\t\t}\n        \t\t\telse\n        \t\t\t{\n        \t\t\t\tauto absFilePath = GetAbsolutePathToStorageLocation(ChilliSource::StorageLocation::k_package) + ChilliSource::StringUtils::StandardiseFilePath(in_filePath);\n                        binaryInputStream = m_zippedFileSystem->CreateBinaryInputStream(absFilePath);\n        \t\t\t}\n        \t\t\tbreak;\n        \t\t}\n        \t\tdefault:\n        \t\t{\n        \t\t\tauto absFilePath = GetAbsolutePathToStorageLocation(in_storageLocation) + ChilliSource::StringUtils::StandardiseFilePath(in_filePath);\n        \t\t\tbinaryInputStream = ChilliSource::IBinaryInputStreamUPtr(new ChilliSource::BinaryInputStream(absFilePath));\n        \t\t\tbreak;\n        \t\t}\n        \t}\n\n        \tif(binaryInputStream != nullptr && binaryInputStream->IsValid())\n        \t{\n        \t\treturn binaryInputStream;\n        \t}\n        \telse\n        \t{\n        \t\treturn nullptr;\n        \t}\n        }\n\t\t//------------------------------------------------------------------------------\n\t\t//------------------------------------------------------------------------------\n        ChilliSource::TextOutputStreamUPtr FileSystem::CreateTextOutputStream(ChilliSource::StorageLocation in_storageLocation, const std::string& in_filePath, ChilliSource::FileWriteMode in_fileMode) const\n        {\n        \tCS_ASSERT(IsStorageLocationWritable(in_storageLocation), \"File System: Trying to write to read only storage location.\");\n\n            if (IsStorageLocationWritable(in_storageLocation))\n            {\n            \tstd::string absFilePath = GetAbsolutePathToStorageLocation(in_storageLocation) + in_filePath;\n\n            \tChilliSource::TextOutputStreamUPtr output(new ChilliSource::TextOutputStream(absFilePath, in_fileMode));\n            \tif (output->IsValid() == true)\n            \t{\n            \t\treturn output;\n            \t}\n            }\n\n            return nullptr;\n        }\n\t\t//------------------------------------------------------------------------------\n\t\t//------------------------------------------------------------------------------\n        ChilliSource::BinaryOutputStreamUPtr FileSystem::CreateBinaryOutputStream(ChilliSource::StorageLocation in_storageLocation, const std::string& in_filePath, ChilliSource::FileWriteMode in_fileMode) const\n        {\n        \tCS_ASSERT(IsStorageLocationWritable(in_storageLocation), \"File System: Trying to write to read only storage location.\");\n\n            if (IsStorageLocationWritable(in_storageLocation))\n            {\n            \tstd::string absFilePath = GetAbsolutePathToStorageLocation(in_storageLocation) + in_filePath;\n\n            \tChilliSource::BinaryOutputStreamUPtr output(new ChilliSource::BinaryOutputStream(absFilePath, in_fileMode));\n            \tif (output->IsValid() == true)\n            \t{\n            \t\treturn output;\n            \t}\n            }\n\n            return nullptr;\n        }\n\t\t//------------------------------------------------------------------------------\n\t\t//------------------------------------------------------------------------------\n\t\tbool FileSystem::CreateDirectoryPath(ChilliSource::StorageLocation in_storageLocation, const std::string& in_directory) const\n\t\t{\n\t\t\tCS_ASSERT(IsStorageLocationWritable(in_storageLocation) == true, \"Cannot create directory in read-only storage location.\");\n\n            std::string path = GetAbsolutePathToStorageLocation(in_storageLocation);\n\n            //get each level of the new directory separately\n            std::string relativePath = ChilliSource::StringUtils::StandardiseDirectoryPath(in_directory);\n            std::vector<std::string> relativePathSections = ChilliSource::StringUtils::Split(relativePath, \"/\");\n\n            //iterate through each section of the path and try and create it.\n            for (const std::string& relativePathSection : relativePathSections)\n            {\n                path += relativePathSection + \"/\";\n\n                if (CSBackend::Android::CreateDirectory(path) == false)\n                {\n                    return false;\n                }\n            }\n\n            return true;\n\t\t}\n\t\t//------------------------------------------------------------------------------\n\t\t//------------------------------------------------------------------------------\n\t\tbool FileSystem::CopyFile(ChilliSource::StorageLocation in_sourceStorageLocation, const std::string& in_sourceFilePath,\n\t\t\t\t\t\t\t\t  ChilliSource::StorageLocation in_destinationStorageLocation, const std::string& in_destinationFilePath) const\n\t\t{\n\t\t    CS_ASSERT(IsStorageLocationWritable(in_destinationStorageLocation) == true, \"Cannot copy a file to a read-only storage location.\");\n\n            const s32 k_chunkSize = 32 * 1024;\n\n            auto sourceStream = CreateBinaryInputStream(in_sourceStorageLocation, in_sourceFilePath);\n            if (sourceStream == nullptr)\n            {\n                return false;\n            }\n\n            auto destinationStream = CreateBinaryOutputStream(in_destinationStorageLocation, in_destinationFilePath, ChilliSource::FileWriteMode::k_overwrite);\n            if (destinationStream == nullptr)\n            {\n                return false;\n            }\n\n            s32 length = sourceStream->GetLength();\n\n            s32 progress = 0;\n            u8 buffer[k_chunkSize];\n            while (progress < length)\n            {\n                s32 copySize = length - progress;\n                if (copySize > k_chunkSize)\n                {\n                    copySize = k_chunkSize;\n                }\n\n                sourceStream->Read(buffer, copySize);\n                destinationStream->Write(buffer, copySize);\n\n                progress += copySize;\n            }\n\n            return true;\n\t\t}\n\t\t//------------------------------------------------------------------------------\n\t\t//------------------------------------------------------------------------------\n\t\tbool FileSystem::CopyDirectory(ChilliSource::StorageLocation in_sourceStorageLocation, const std::string& in_sourceDirectoryPath,\n\t\t\t\t\t\t   ChilliSource::StorageLocation in_destinationStorageLocation, const std::string& in_destinationDirectoryPath) const\n\t\t{\n\t\t\tCS_ASSERT(IsStorageLocationWritable(in_destinationStorageLocation) == true, \"Cannot copy a directory to a read-only storage location.\");\n\n            std::string sourceDirectoryPath = ChilliSource::StringUtils::StandardiseDirectoryPath(in_sourceDirectoryPath);\n            std::string destinationDirectoryPath = ChilliSource::StringUtils::StandardiseDirectoryPath(in_destinationDirectoryPath);\n\n\t\t\t//create all of the required directories.\n\t\t\tCreateDirectoryPath(in_destinationStorageLocation, destinationDirectoryPath);\n\t\t\tstd::vector<std::string> subDirectoryPaths = GetDirectoryPaths(in_sourceStorageLocation, sourceDirectoryPath, true);\n\t\t\tfor (const auto& subDirectoryPath : subDirectoryPaths)\n\t\t\t{\n\t\t\t    CreateDirectoryPath(in_destinationStorageLocation, destinationDirectoryPath + subDirectoryPath);\n\t\t\t}\n\n\t\t\t//copy files\n\t\t\tstd::vector<std::string> filePaths = GetFilePaths(in_sourceStorageLocation, sourceDirectoryPath, true);\n\t\t\tswitch (in_sourceStorageLocation)\n\t\t\t{\n\t\t\t    case ChilliSource::StorageLocation::k_package:\n                case ChilliSource::StorageLocation::k_chilliSource:\n                {\n                    //This could be handled by simply calling CopyFile() for each of the required\n                    //files, however this is pretty inefficient when reading from the zip as it's\n                    //repeatedly opened and closed. For the sake of performance we use the batch\n                    //ExtractFiles() method when copying from the zip.\n\n                    std::string absSourceDirectoryPath = GetAbsolutePathToStorageLocation(in_sourceStorageLocation) + sourceDirectoryPath;\n                    std::vector<std::string> sourceFiles, destinationFiles;\n                    for (const auto& filePath : filePaths)\n                    {\n                        sourceFiles.push_back(absSourceDirectoryPath + filePath);\n                        destinationFiles.push_back(destinationDirectoryPath + filePath);\n                    }\n\n                    u32 index = 0;\n\t\t\t\t\treturn m_zippedFileSystem->ExtractFiles(sourceFiles, [&](const std::string& in_filePath, std::unique_ptr<const u8[]> in_fileContents, u32 in_fileSize) -> bool\n\t\t\t\t\t{\n                        const auto& destination = destinationFiles[index++];\n                        return WriteFile(in_destinationStorageLocation, destination, reinterpret_cast<const s8*>(in_fileContents.get()), in_fileSize);\n\t\t\t\t\t});\n                }\n                case ChilliSource::StorageLocation::k_DLC:\n                {\n                \t//As with the Package and ChilliSource storage locations this could be handled\n                \t//by simply calling CopyFile() for each, however it would be inefficient for\n                \t//files contained in the zip. Instead, the batch ExtractFiles() method is used.\n\n\t\t\t\t\tstd::string absPackageDLCPath = GetAbsolutePathToStorageLocation(ChilliSource::StorageLocation::k_package) + GetPackageDLCPath();\n                \tstd::vector<std::string> sourceFiles, destinationFiles;\n                    for (const auto& filePath : filePaths)\n                    {\n                        auto sourceFilePath = sourceDirectoryPath + filePath;\n                        auto destinationFilePath = destinationDirectoryPath + filePath;\n\n                    \tif (DoesFileExistInCachedDLC(sourceFilePath) == true)\n                    \t{\n                    \t\tif (CopyFile(in_sourceStorageLocation, sourceFilePath, in_destinationStorageLocation, destinationFilePath) == false)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t\t}\n                    \t}\n                    \telse\n                    \t{\n\t\t\t\t\t\t\tsourceFiles.push_back(absPackageDLCPath + sourceFilePath);\n\t\t\t\t\t\t\tdestinationFiles.push_back(destinationFilePath);\n                    \t}\n                    }\n\n                    if (sourceFiles.empty() == false)\n                    {\n\t\t\t\t\t\tu32 index = 0;\n\t\t\t\t\t\treturn m_zippedFileSystem->ExtractFiles(sourceFiles, [&](const std::string& in_filePath, std::unique_ptr<const u8[]> in_fileContents, u32 in_fileSize) -> bool\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tconst auto& destination = destinationFiles[index++];\n\t\t\t\t\t\t\treturn WriteFile(in_destinationStorageLocation, destination, reinterpret_cast<const s8*>(in_fileContents.get()), in_fileSize);\n\t\t\t\t\t\t});\n                    }\n\n                    return true;\n                }\n                default:\n                {\n                    for (const auto& filePath : filePaths)\n                    {\n                        if (CopyFile(in_sourceStorageLocation, sourceDirectoryPath + filePath, in_destinationStorageLocation, destinationDirectoryPath + filePath) == false)\n                        {\n                            return false;\n                        }\n                    }\n\n                    return true;\n                }\n\t\t\t}\n\t\t}\n\t\t//------------------------------------------------------------------------------\n\t\t//------------------------------------------------------------------------------\n\t\tbool FileSystem::DeleteFile(ChilliSource::StorageLocation in_storageLocation, const std::string& in_filePath) const\n\t\t{\n\t\t\tCS_ASSERT(IsStorageLocationWritable(in_storageLocation) == true, \"Cannot delete file from read-only storage location.\");\n\n            std::string filePath = GetAbsolutePathToStorageLocation(in_storageLocation) + ChilliSource::StringUtils::StandardiseFilePath(in_filePath);\n            s32 error = unlink(filePath.c_str());\n            if (error != 0)\n            {\n                return false;\n            }\n\n            return true;\n\t\t}\n\t\t//------------------------------------------------------------------------------\n\t\t//------------------------------------------------------------------------------\n\t\tbool FileSystem::DeleteDirectory(ChilliSource::StorageLocation in_storageLocation, const std::string& in_directoryPath) const\n\t\t{\n\t\t\tCS_ASSERT(IsStorageLocationWritable(in_storageLocation), \"Cannot delete directory from read-only storage location.\");\n\n            std::string directoryPath = GetAbsolutePathToStorageLocation(in_storageLocation) + ChilliSource::StringUtils::StandardiseDirectoryPath(in_directoryPath);\n            return CSBackend::Android::DeleteDirectory(directoryPath);\n\t\t}\n\t\t//------------------------------------------------------------------------------\n\t\t//------------------------------------------------------------------------------\n\t\tstd::vector<std::string> FileSystem::GetFilePaths(ChilliSource::StorageLocation in_storageLocation, const std::string& in_directoryPath, bool in_recursive) const\n\t\t{\n\t\t\tswitch (in_storageLocation)\n\t\t\t{\n\t\t\t    case ChilliSource::StorageLocation::k_package:\n\t\t\t    case ChilliSource::StorageLocation::k_chilliSource:\n\t\t\t    {\n\t\t\t        return m_zippedFileSystem->GetFilePaths(GetAbsolutePathToStorageLocation(in_storageLocation) + ChilliSource::StringUtils::StandardiseDirectoryPath(in_directoryPath), in_recursive);\n\t\t\t    }\n\t\t\t    case ChilliSource::StorageLocation::k_DLC:\n\t\t\t    {\n                    auto absPackageDirectoryPath = GetAbsolutePathToStorageLocation(ChilliSource::StorageLocation::k_package) + GetPackageDLCPath() + ChilliSource::StringUtils::StandardiseDirectoryPath(in_directoryPath);\n                    auto filePaths = m_zippedFileSystem->GetFilePaths(absPackageDirectoryPath, in_recursive);\n\n                    auto absCacheDirectoryPath = GetAbsolutePathToStorageLocation(in_storageLocation) + ChilliSource::StringUtils::StandardiseDirectoryPath(in_directoryPath);\n                    if (CSBackend::Android::DoesDirectoryExist(absCacheDirectoryPath) == true && GetPaths(filePaths, absCacheDirectoryPath, false, in_recursive) == false)\n                    {\n                        CS_LOG_ERROR(\"Failed to get file paths in directory '\" + in_directoryPath + \"' in storage location '\" + ChilliSource::ToString(in_storageLocation) + \"'\");\n                    }\n\n                    std::sort(filePaths.begin(), filePaths.end());\n                    auto it = std::unique(filePaths.begin(), filePaths.end());\n                    filePaths.resize(it - filePaths.begin());\n                    return filePaths;\n\t\t\t    }\n                default:\n                {\n                    std::vector<std::string> filePaths;\n                    if (GetPaths(filePaths, GetAbsolutePathToStorageLocation(in_storageLocation) + ChilliSource::StringUtils::StandardiseDirectoryPath(in_directoryPath), false, in_recursive) == false)\n                    {\n                        CS_LOG_ERROR(\"Failed to get file paths in directory '\" + in_directoryPath + \"' in storage location '\" + ChilliSource::ToString(in_storageLocation) + \"'\");\n                    }\n\n                    return filePaths;\n                }\n\t\t\t}\n\t\t}\n\t\t//------------------------------------------------------------------------------\n\t\t//------------------------------------------------------------------------------\n\t\tstd::vector<std::string> FileSystem::GetDirectoryPaths(ChilliSource::StorageLocation in_storageLocation, const std::string& in_directoryPath,  bool in_recursive) const\n\t\t{\n            switch (in_storageLocation)\n            {\n                case ChilliSource::StorageLocation::k_package:\n                case ChilliSource::StorageLocation::k_chilliSource:\n                {\n                    return m_zippedFileSystem->GetDirectoryPaths(GetAbsolutePathToStorageLocation(in_storageLocation) + ChilliSource::StringUtils::StandardiseDirectoryPath(in_directoryPath), in_recursive);\n                }\n                case ChilliSource::StorageLocation::k_DLC:\n                {\n                    auto absPackageDirectoryPath = GetAbsolutePathToStorageLocation(ChilliSource::StorageLocation::k_package) + GetPackageDLCPath() + ChilliSource::StringUtils::StandardiseDirectoryPath(in_directoryPath);\n                    auto subDirectoryPaths = m_zippedFileSystem->GetDirectoryPaths(absPackageDirectoryPath, in_recursive);\n\n                    auto absCacheDirectoryPath = GetAbsolutePathToStorageLocation(in_storageLocation) + ChilliSource::StringUtils::StandardiseDirectoryPath(in_directoryPath);\n                    if (CSBackend::Android::DoesDirectoryExist(absCacheDirectoryPath) == true && GetPaths(subDirectoryPaths, absCacheDirectoryPath, true, in_recursive) == false)\n                    {\n                        CS_LOG_ERROR(\"Failed to get directory paths in directory '\" + in_directoryPath + \"' in storage location '\" + ChilliSource::ToString(in_storageLocation) + \"'\");\n                    }\n\n                    std::sort(subDirectoryPaths.begin(), subDirectoryPaths.end());\n                    auto it = std::unique(subDirectoryPaths.begin(), subDirectoryPaths.end());\n                    subDirectoryPaths.resize(it - subDirectoryPaths.begin());\n                    return subDirectoryPaths;\n                }\n                default:\n                {\n                    std::vector<std::string> directoryPaths;\n                    if (GetPaths(directoryPaths, GetAbsolutePathToStorageLocation(in_storageLocation) + ChilliSource::StringUtils::StandardiseDirectoryPath(in_directoryPath), true, in_recursive) == false)\n                    {\n                        CS_LOG_ERROR(\"Failed to get directory paths in directory '\" + in_directoryPath + \"' in storage location '\" + ChilliSource::ToString(in_storageLocation) + \"'\");\n                    }\n\n                    return directoryPaths;\n                }\n            }\n\t\t}\n\t\t//------------------------------------------------------------------------------\n\t\t//------------------------------------------------------------------------------\n\t\tbool FileSystem::DoesFileExist(ChilliSource::StorageLocation in_storageLocation, const std::string& in_filePath) const\n\t\t{\n\t\t\tswitch (in_storageLocation)\n\t\t\t{\n\t\t\t\tcase ChilliSource::StorageLocation::k_package:\n\t\t\t\tcase ChilliSource::StorageLocation::k_chilliSource:\n\t\t\t\t{\n\t\t\t\t\treturn m_zippedFileSystem->DoesFileExist(GetAbsolutePathToStorageLocation(in_storageLocation) + ChilliSource::StringUtils::StandardiseFilePath(in_filePath));\n\t\t\t\t}\n\t\t\t\tcase ChilliSource::StorageLocation::k_DLC:\n\t\t\t\t{\n\t\t\t\t\treturn (DoesFileExistInCachedDLC(in_filePath) || DoesFileExistInPackageDLC(in_filePath));\n\t\t\t\t}\n\t\t\t\tdefault:\n\t\t\t\t{\n\t\t\t\t\treturn CSBackend::Android::DoesFileExist(GetAbsolutePathToStorageLocation(in_storageLocation) + ChilliSource::StringUtils::StandardiseFilePath(in_filePath));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t//------------------------------------------------------------------------------\n\t\t//------------------------------------------------------------------------------\n\t\tbool FileSystem::DoesFileExistInCachedDLC(const std::string& in_filePath) const\n\t\t{\n\t\t\treturn CSBackend::Android::DoesFileExist(GetAbsolutePathToStorageLocation(ChilliSource::StorageLocation::k_DLC) + ChilliSource::StringUtils::StandardiseFilePath(in_filePath));\n\t\t}\n\t\t//------------------------------------------------------------------------------\n\t\t//------------------------------------------------------------------------------\n\t\tbool FileSystem::DoesFileExistInPackageDLC(const std::string& in_filePath) const\n\t\t{\n\t\t\treturn DoesFileExist(ChilliSource::StorageLocation::k_package, GetPackageDLCPath() + in_filePath);\n\t\t}\n\t\t//------------------------------------------------------------------------------\n\t\t//------------------------------------------------------------------------------\n\t\tbool FileSystem::DoesDirectoryExist(ChilliSource::StorageLocation in_storageLocation, const std::string& in_directoryPath) const\n\t\t{\n\t\t\tswitch (in_storageLocation)\n\t\t\t{\n\t\t\t\tcase ChilliSource::StorageLocation::k_package:\n                case ChilliSource::StorageLocation::k_chilliSource:\n                {\n                \treturn m_zippedFileSystem->DoesDirectoryExist(GetAbsolutePathToStorageLocation(in_storageLocation) + ChilliSource::StringUtils::StandardiseDirectoryPath(in_directoryPath));\n                }\n                case ChilliSource::StorageLocation::k_DLC:\n                {\n                \treturn (DoesDirectoryExistInCachedDLC(in_directoryPath) || DoesDirectoryExistInPackageDLC(in_directoryPath));\n                }\n                default:\n                {\n                \treturn CSBackend::Android::DoesDirectoryExist(GetAbsolutePathToStorageLocation(in_storageLocation) + ChilliSource::StringUtils::StandardiseDirectoryPath(in_directoryPath));\n                }\n\t\t\t}\n\t\t}\n\t\t//------------------------------------------------------------------------------\n\t\t//------------------------------------------------------------------------------\n\t\tbool FileSystem::DoesDirectoryExistInCachedDLC(const std::string& in_directoryPath) const\n\t\t{\n\t\t\treturn CSBackend::Android::DoesDirectoryExist(GetAbsolutePathToStorageLocation(ChilliSource::StorageLocation::k_DLC) + ChilliSource::StringUtils::StandardiseFilePath(in_directoryPath));\n\t\t}\n\t\t//------------------------------------------------------------------------------\n\t\t//------------------------------------------------------------------------------\n\t\tbool FileSystem::DoesDirectoryExistInPackageDLC(const std::string& in_directoryPath) const\n\t\t{\n\t\t\treturn DoesDirectoryExist(ChilliSource::StorageLocation::k_package, GetPackageDLCPath() + in_directoryPath);\n\t\t}\n\t\t//------------------------------------------------------------------------------\n\t\t//------------------------------------------------------------------------------\n\t\tstd::string FileSystem::GetAbsolutePathToStorageLocation(ChilliSource::StorageLocation in_storageLocation) const\n\t\t{\n\t\t\t//get the storage location path\n\t\t\tstd::string storageLocationPath;\n\t\t\tswitch (in_storageLocation)\n\t\t\t{\n\t\t\t\tcase ChilliSource::StorageLocation::k_package:\n\t\t\t\t\tstorageLocationPath = k_packagePath;\n\t\t\t\t\tbreak;\n\t\t\t\tcase ChilliSource::StorageLocation::k_chilliSource:\n\t\t\t\t\tstorageLocationPath = k_chilliSourcePath;\n\t\t\t\t\tbreak;\n\t\t\t\tcase ChilliSource::StorageLocation::k_saveData:\n\t\t\t\t\tstorageLocationPath = m_storagePath + k_saveDataPath;\n\t\t\t\t\tbreak;\n\t\t\t\tcase ChilliSource::StorageLocation::k_cache:\n\t\t\t\t\tstorageLocationPath = m_storagePath + k_cachePath;\n\t\t\t\t\tbreak;\n\t\t\t\tcase ChilliSource::StorageLocation::k_DLC:\n\t\t\t\t\tstorageLocationPath = m_storagePath + k_dlcPath;\n\t\t\t\t\tbreak;\n\t\t\t\tcase ChilliSource::StorageLocation::k_root:\n\t\t\t\t\tstorageLocationPath = \"\";\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tCS_LOG_FATAL(\"File System: Requested storage location that does not exist on this platform.\");\n\t\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\treturn storageLocationPath;\n\t\t}\n\t\t//------------------------------------------------------------------------------\n\t\t//------------------------------------------------------------------------------\n\t\tconst std::string& FileSystem::GetZipFilePath() const\n\t\t{\n\t\t\treturn m_zipFilePath;\n\t\t}\n\t\t//------------------------------------------------------------------------------\n\t\t//------------------------------------------------------------------------------\n\t\tbool FileSystem::TryGetZippedFileInfo(ChilliSource::StorageLocation in_storageLocation, const std::string& in_filePath, ZippedFileInfo& out_zippedFileInfo) const\n\t\t{\n\t\t\tCS_ASSERT(in_storageLocation == ChilliSource::StorageLocation::k_package || in_storageLocation == ChilliSource::StorageLocation::k_chilliSource\n\t\t\t\t|| in_storageLocation == ChilliSource::StorageLocation::k_DLC, \"Invalid storage location.\");\n\n\t\t\tstd::string filePath;\n\t\t\tif (in_storageLocation == ChilliSource::StorageLocation::k_DLC)\n\t\t\t{\n\t\t\t\tfilePath = GetAbsolutePathToStorageLocation(ChilliSource::StorageLocation::k_package) + GetPackageDLCPath() + ChilliSource::StringUtils::StandardiseFilePath(in_filePath);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tfilePath = GetAbsolutePathToStorageLocation(in_storageLocation) + ChilliSource::StringUtils::StandardiseFilePath(in_filePath);\n\t\t\t}\n\n\t\t\tZippedFileSystem::FileInfo info;\n\t\t\tif (m_zippedFileSystem->TryGetFileInfo(filePath, info) == false)\n\t\t\t{\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tout_zippedFileInfo.m_offset = info.m_offset;\n\t\t\tout_zippedFileInfo.m_size = info.m_size;\n\t\t\tout_zippedFileInfo.m_uncompressedSize = info.m_uncompressedSize;\n\t\t\tout_zippedFileInfo.m_isCompressed = info.m_isCompressed;\n\t\t\treturn true;\n\t\t}\n\n\t}\n}\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/JNI/Core/File/FileSystem.h",
    "content": "//\n//  FileSystem.h\n//  ChilliSource\n//  Created by Ian Copland on 25/03/2011.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2011 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n\n#ifndef _CSBACKEND_PLATFORM_ANDROID_MAIN_JNI_CORE_FILE_FILESYSTEM_H_\n#define _CSBACKEND_PLATFORM_ANDROID_MAIN_JNI_CORE_FILE_FILESYSTEM_H_\n\n#include <CSBackend/Platform/Android/Main/JNI/ForwardDeclarations.h>\n#include <CSBackend/Platform/Android/Main/JNI/Core/File/ZippedFileSystem.h>\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/File/FileStream/BinaryInputStream.h>\n#include <ChilliSource/Core/File/FileStream/BinaryOutputStream.h>\n#include <ChilliSource/Core/File/FileStream/TextInputStream.h>\n#include <ChilliSource/Core/File/FileStream/TextOutputStream.h>\n#include <ChilliSource/Core/File/FileSystem.h>\n\nnamespace CSBackend\n{\n\tnamespace Android \n\t{\n\t\t//------------------------------------------------------------------------------\n\t\t/// The Android implementation of the file system.\n\t\t///\n\t\t/// The literal locations of the Package and ChilliSource storage locations\n\t\t/// differ depending on the Android Flavour. In both cases Package and\n\t\t/// ChilliSource are \"virtual\" storage locations, which are contained within\n\t\t/// zip files. Google Play builds use the main Apk Expansion file, and Amazon\n\t\t/// builds use the Apk.\n\t\t///\n\t\t/// This is thread-safe though care still needs to be taken when dealing with\n\t\t/// file streams as they are not. A file stream should be used and destroyed\n\t\t/// on the same thread it was created.\n\t\t///\n\t\t/// @author Ian Copland\n\t\t//------------------------------------------------------------------------------\n\t\tclass FileSystem final : public ChilliSource::FileSystem\n\t\t{\n\t\tpublic:\n\t\t\tCS_DECLARE_NAMEDTYPE(FileSystem);\n\t\t\t//------------------------------------------------------------------------------\n\t\t\t/// A struct containing information about the location of a single file within\n\t\t\t/// the zip. This can be used to manually access the zip data.\n\t\t\t///\n\t\t\t/// @author Ian Copland\n\t\t\t//------------------------------------------------------------------------------\n\t\t\tstruct ZippedFileInfo final\n\t\t\t{\n\t\t\t\tu32 m_offset = 0;\n\t\t\t\tu32 m_size = 0;\n\t\t\t\tu32 m_uncompressedSize = 0;\n\t\t\t\tbool m_isCompressed = false;\n\t\t\t};\n\t\t\t//------------------------------------------------------------------------------\n\t\t\t/// Queries whether or not this system implements the interface with the given\n\t\t\t/// Id.\n\t\t\t///\n\t\t\t/// @author Ian Copland\n\t\t\t///\n\t\t\t/// @param in_interfaceId - The interface Id.\n\t\t\t///\n\t\t\t/// @return Whether or not the interface is implemented.\n\t\t\t//------------------------------------------------------------------------------\n\t\t\tbool IsA(ChilliSource::InterfaceIDType in_interfaceId) const override;\n\t\t\t//------------------------------------------------------------------------------\n            /// Creates a new input text stream to the given file in the given storage location.\n            ///\n            /// @author HMcLaughlin\n            ///\n            /// @param in_storageLocation - The storage location.\n            /// @param in_filePath - The file path.\n            ///\n            /// @return The new file stream. If the stream cannot be created or is invalid,\n            /// null be returned.\n            //------------------------------------------------------------------------------\n            ChilliSource::ITextInputStreamUPtr CreateTextInputStream(ChilliSource::StorageLocation in_storageLocation, const std::string& in_filePath) const override;\n            //------------------------------------------------------------------------------\n            /// Creates a new input binary stream to the given file in the given storage location.\n            ///\n            /// @author HMcLaughlin\n            ///\n            /// @param in_storageLocation - The storage location.\n            /// @param in_filePath - The file path.\n            ///\n            /// @return The new file stream. If the stream cannot be created or is invalid,\n            /// null be returned.\n            //------------------------------------------------------------------------------\n            ChilliSource::IBinaryInputStreamUPtr CreateBinaryInputStream(ChilliSource::StorageLocation in_storageLocation, const std::string& in_filePath) const override;\n\t\t\t//------------------------------------------------------------------------------\n            /// Creates a new output text stream to the given file in the given storage location.\n            ///\n            /// @author HMcLaughlin\n            ///\n            /// @param in_storageLocation - The storage location.\n            /// @param in_filePath - The file path.\n            ///\n            /// @return The new file stream. If the stream cannot be created or is invalid,\n            /// null be returned.\n            //------------------------------------------------------------------------------\n            ChilliSource::TextOutputStreamUPtr CreateTextOutputStream(ChilliSource::StorageLocation in_storageLocation, const std::string& in_filePath, ChilliSource::FileWriteMode in_fileMode) const override;\n            //------------------------------------------------------------------------------\n            /// Creates a new output binary stream to the given file in the given storage location.\n            ///\n            /// @author HMcLaughlin\n            ///\n            /// @param in_storageLocation - The storage location.\n            /// @param in_filePath - The file path.\n            ///\n            /// @return The new file stream. If the stream cannot be created or is invalid,\n            /// null be returned.\n            //------------------------------------------------------------------------------\n            ChilliSource::BinaryOutputStreamUPtr CreateBinaryOutputStream(ChilliSource::StorageLocation in_storageLocation, const std::string& in_filePath, ChilliSource::FileWriteMode in_fileMode) const override;\n\t\t\t//------------------------------------------------------------------------------\n\t\t\t/// Creates the given directory. The full directory hierarchy will be created.\n            ///\n            /// This is thread-safe.\n\t\t\t///\n\t\t\t/// @author Ian Copland\n\t\t\t///\n\t\t\t/// @param in_storageLocation - The Storage Location\n\t\t\t/// @param in_directoryPath - The directory path.\n\t\t\t///\n\t\t\t/// @return Whether or not this was successful. Failure to create the directory\n\t\t\t/// because it already exists is considered a success.\n\t\t\t//------------------------------------------------------------------------------\n\t\t\tbool CreateDirectoryPath(ChilliSource::StorageLocation in_storageLocation, const std::string& in_directoryPath) const override;\n\t\t\t//------------------------------------------------------------------------------\n\t\t\t/// Copies a file from one location to another.\n            ///\n            /// This is thread-safe.\n\t\t\t///\n\t\t\t/// @author Ian Copland\n\t\t\t///\n\t\t\t/// @param in_sourceStorageLocation - The source storage location.\n\t\t\t/// @param in_sourceFilePath - The source directory.\n\t\t\t/// @param in_destinationStorageLocation - The destination storage location.\n\t\t\t/// @param in_destinationFilePath - The destination directory.\n\t\t\t///\n\t\t\t/// @return Whether or not the file was successfully copied.\n\t\t\t//------------------------------------------------------------------------------\n\t\t\tbool CopyFile(ChilliSource::StorageLocation in_sourceStorageLocation, const std::string& in_sourceFilePath,\n\t\t\t\t\t\t  ChilliSource::StorageLocation in_destinationStorageLocation, const std::string& in_destinationFilePath) const override;\n\t\t\t//------------------------------------------------------------------------------\n\t\t\t/// Copies a directory from one location to another. If the destination\n\t\t\t/// directory does not exist, it will be created.\n            ///\n            /// This is thread-safe.\n\t\t\t///\n\t\t\t/// @author Ian Copland\n\t\t\t///\n\t\t\t/// @param in_sourceStorageLocation - The source storage location.\n\t\t\t/// @param in_sourceDirectoryPath - The source directory.\n\t\t\t/// @param in_destinationStorageLocation - The destination storage location.\n\t\t\t/// @param in_destinationDirectoryPath - The destination directory.\n\t\t\t///\n\t\t\t/// @return Whether or not the files were successfully copied.\n\t\t\t//------------------------------------------------------------------------------\n\t\t\tbool CopyDirectory(ChilliSource::StorageLocation in_sourceStorageLocation, const std::string& in_sourceDirectoryPath,\n\t\t\t\t\t\t\t   ChilliSource::StorageLocation in_destinationStorageLocation, const std::string& in_destinationDirectoryPath) const override;\n\t\t\t//------------------------------------------------------------------------------\n\t\t\t/// Deletes the specified file.\n            ///\n            /// This is thread-safe.\n\t\t\t///\n\t\t\t/// @author Ian Copland\n\t\t\t///\n\t\t\t/// @param in_storageLocation - The storage location.\n\t\t\t/// @param in_filePath - The file path.\n\t\t\t///\n\t\t\t/// @return Whether or not the file was successfully deleted.\n\t\t\t//------------------------------------------------------------------------------\n\t\t\tbool DeleteFile(ChilliSource::StorageLocation in_storageLocation, const std::string& in_filePath) const override;\n\t\t\t//------------------------------------------------------------------------------\n\t\t\t/// Deletes a directory and all its contents.\n            ///\n            /// This is thread-safe.\n\t\t\t///\n\t\t\t/// @author Ian Copland\n\t\t\t///\n\t\t\t/// @param in_storageLocation - The storage location.\n\t\t\t/// @param in_directoryPath - The directory.\n\t\t\t///\n\t\t\t/// @return Whether or not the directory was successfully deleted.\n\t\t\t//------------------------------------------------------------------------------\n\t\t\tbool DeleteDirectory(ChilliSource::StorageLocation in_storageLocation, const std::string& in_directoryPath) const override;\n\t\t\t//------------------------------------------------------------------------------\n\t\t\t/// Creates a dynamic array containing the filenames of each file in the given\n\t\t\t/// directory. File paths will be relative to the input directory.\n            ///\n            /// This is thread-safe.\n\t\t\t///\n\t\t\t/// @author Ian Copland\n\t\t\t///\n\t\t\t/// @param in_storageLocation - The Storage Location\n\t\t\t/// @param in_directoryPath - The directory\n\t\t\t/// @param in_recursive - Flag to determine whether or not to recurse into sub\n\t\t\t/// directories\n\t\t\t///\n\t\t\t/// @return dynamic array containing the filenames.\n\t\t\t//------------------------------------------------------------------------------\n\t\t\tstd::vector<std::string> GetFilePaths(ChilliSource::StorageLocation in_storageLocation, const std::string& in_directoryPath,  bool in_recursive) const override;\n\t\t\t//------------------------------------------------------------------------------\n\t\t\t/// Creates a dynamic array containing the names of each directory in the given\n\t\t\t/// directory. Directory paths will be relative to the input directory.\n            ///\n            /// This is thread-safe.\n\t\t\t///\n\t\t\t/// @author Ian Copland\n\t\t\t///\n\t\t\t/// @param in_storageLocation - The Storage Location\n\t\t\t/// @param in_directoryPath - The directory\n\t\t\t/// @param in_recursive - Flag to determine whether or not to recurse into sub\n\t\t\t/// directories\n\t\t\t///\n\t\t\t/// @return Output dynamic array containing the dir names.\n\t\t\t//------------------------------------------------------------------------------\n\t\t\tstd::vector<std::string> GetDirectoryPaths(ChilliSource::StorageLocation in_storageLocation, const std::string& in_directoryPath,  bool in_recursive) const override;\n\t\t\t//------------------------------------------------------------------------------\n            /// This is thread-safe.\n            ///\n\t\t\t/// @author Ian Copland\n\t\t\t///\n\t\t\t/// @param in_storageLocation - The Storage Location\n\t\t\t/// @param in_filePath - The file path\n\t\t\t///\n\t\t\t/// @return Whether or not the described file exists.\n\t\t\t//------------------------------------------------------------------------------\n\t\t\tbool DoesFileExist(ChilliSource::StorageLocation in_storageLocation, const std::string& in_filePath) const override;\n\t\t\t//------------------------------------------------------------------------------\n            /// This is thread-safe.\n            ///\n\t\t\t/// @author Ian Copland\n\t\t\t///\n\t\t\t/// @param in_filePath - The file path.\n\t\t\t///\n\t\t\t/// @return Whether or not the given file path exists in the Cache DLC directory.\n\t\t\t//------------------------------------------------------------------------------\n\t\t\tbool DoesFileExistInCachedDLC(const std::string& in_filePath) const override;\n\t\t\t//------------------------------------------------------------------------------\n            /// This is thread-safe.\n            ///\n\t\t\t/// @author Ian Copland\n\t\t\t///\n\t\t\t/// @param in_filePath - The file path.\n\t\t\t///\n\t\t\t/// @return Whether or not the given file path exists in the Package DLC\n\t\t\t/// directory.\n\t\t\t//------------------------------------------------------------------------------\n\t\t\tbool DoesFileExistInPackageDLC(const std::string& in_filePath) const override;\n\t\t\t//------------------------------------------------------------------------------\n            /// This is thread-safe.\n            ///\n\t\t\t/// @author Ian Copland\n\t\t\t///\n\t\t\t/// @param in_storageLocation - The Storage Location\n\t\t\t/// @param in_directoryPath - The directory path\n\t\t\t///\n\t\t\t/// @return Whether or not the described directory exists.\n\t\t\t//------------------------------------------------------------------------------\n\t\t\tbool DoesDirectoryExist(ChilliSource::StorageLocation in_storageLocation, const std::string& in_directoryPath) const override;\n\t\t\t//------------------------------------------------------------------------------\n            /// This is thread-safe.\n            ///\n\t\t\t/// @author Ian Copland\n\t\t\t///\n\t\t\t/// @param in_directoryPath - The directory path.\n\t\t\t///\n\t\t\t/// @return Whether or not the directory exists in the Cache DLC directory.\n\t\t\t//------------------------------------------------------------------------------\n\t\t\tbool DoesDirectoryExistInCachedDLC(const std::string& in_directoryPath) const override;\n\t\t\t//------------------------------------------------------------------------------\n            /// This is thread-safe.\n            ///\n\t\t\t/// @author Ian Copland\n\t\t\t///\n\t\t\t/// @param in_directoryPath - The directory path.\n\t\t\t///\n\t\t\t/// @return Whether or not the directory exists in the Package DLC directory.\n\t\t\t//------------------------------------------------------------------------------\n\t\t\tbool DoesDirectoryExistInPackageDLC(const std::string& in_directoryPath) const override;\n\t\t\t//------------------------------------------------------------------------------\n\t\t\t/// Returns the absolute path to the given storage location. The value this\n\t\t\t/// returns is platform specific and use of this should be kept to a minimum in\n\t\t\t/// cross platform projects.\n\t\t\t///\n\t\t\t/// This is thread-safe.\n\t\t\t///\n\t\t\t/// @author Ian Copland\n\t\t\t///\n\t\t\t/// @param in_storageLocation - The source storage location.\n\t\t\t///\n\t\t\t/// @return The directory. returns an empty string if the location is not\n\t\t\t/// available.\n\t\t\t//------------------------------------------------------------------------------\n\t\t\tstd::string GetAbsolutePathToStorageLocation(ChilliSource::StorageLocation in_storageLocation) const override;\n\t\t\t//------------------------------------------------------------------------------\n\t\t\t/// This is thread-safe.\n\t\t\t///\n\t\t\t/// @author Ian Copland\n\t\t\t///\n\t\t\t/// @return The file path to the zip. The location of this is dependent on the\n\t\t\t/// current Android Flavour: Google Play builds will return the OBB file, while\n\t\t\t/// Amazon builds will simply return the APK. There aren't many cases where this\n\t\t\t/// zip file should be accessed directly, instead the cross platform file system\n\t\t\t/// methods should be used.\n\t\t\t//------------------------------------------------------------------------------\n\t\t\tconst std::string& GetZipFilePath() const;\n\t\t\t//------------------------------------------------------------------------------\n\t\t\t/// Calculates information on a file within the zipped file system. This applies\n\t\t\t/// to the Package, ChilliSource and DLC storage locations, passing other\n\t\t\t/// storage locations will cause this to assert. If DLC is passed, only files\n\t\t\t/// in the Package DLC directory will be checked.\n\t\t\t///\n\t\t\t/// This is thread-safe.\n\t\t\t///\n\t\t\t/// @author Ian Copland\n\t\t\t///\n\t\t\t/// @param in_storageLocation - The storage location. Must be package,\n\t\t\t/// ChilliSource or DLC.\n\t\t\t/// @param in_filePath - The path to the file.\n\t\t\t/// @param out_zippedFileInfo - [Out] Information on the zipped file. This is\n\t\t\t/// only set if the method is successful.\n\t\t\t///\n\t\t\t/// @return Whether or not this was successful.\n\t\t\t//------------------------------------------------------------------------------\n\t\t\tbool TryGetZippedFileInfo(ChilliSource::StorageLocation in_storageLocation, const std::string& in_filePath, ZippedFileInfo& out_zippedFileInfo) const;\n\t\tprivate:\n\t\t\tfriend ChilliSource::FileSystemUPtr ChilliSource::FileSystem::Create();\n            //------------------------------------------------------------------------------\n            /// Private constructor to force use of factory method.\n            ///\n            /// @author S Downie\n            //------------------------------------------------------------------------------\n            FileSystem();\n\n\t\t\tstd::string m_storagePath;\n\t\t\tstd::string m_zipFilePath;\n\t\t\tZippedFileSystemUPtr m_zippedFileSystem;\n\t\t};\n\t}\n}\n\n#endif\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/JNI/Core/File/VirtualBinaryInputStream.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright © 2016 Tag Games. All rights reserved.\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n\n#include <CSBackend/Platform/Android/Main/JNI/Core/File/VirtualBinaryInputStream.h>\n\nnamespace CSBackend\n{\n\tnamespace Android\n\t{\n        //------------------------------------------------------------------------------\n        VirtualBinaryInputStream::VirtualBinaryInputStream(std::unique_ptr<u8[]> buffer, u32 bufferSize) noexcept\n        {\n            CS_ASSERT(buffer != nullptr, \"Cannot create a virtual file stream with a null buffer.\");\n            CS_ASSERT(bufferSize > 0, \"Invalid buffer size.\");\n\n            m_buffer = std::move(buffer);\n            m_stream.rdbuf()->pubsetbuf(reinterpret_cast<s8*>(m_buffer.get()), bufferSize);\n\n            m_isValid = true;\n\n            m_length = bufferSize;\n        }\n        //------------------------------------------------------------------------------\n        bool VirtualBinaryInputStream::IsValid() const noexcept\n        {\n            return m_isValid;\n        }\n        //------------------------------------------------------------------------------\n        u64 VirtualBinaryInputStream::GetLength() const noexcept\n        {\n            CS_ASSERT(IsValid(), \"Trying to use an invalid FileStream.\");\n\n            return m_length;\n        }\n        //------------------------------------------------------------------------------\n        u64 VirtualBinaryInputStream::GetReadPosition() noexcept\n        {\n            CS_ASSERT(IsValid(), \"Trying to use an invalid FileStream.\");\n            return m_stream.tellg();\n        }\n        //------------------------------------------------------------------------------\n        void VirtualBinaryInputStream::SetReadPosition(u64 readPosition) noexcept\n        {\n            CS_ASSERT(IsValid(), \"Trying to use an invalid FileStream.\");\n            CS_ASSERT(readPosition <= GetLength(), \"Position out of bounds!\");\n\n            m_stream.seekg(readPosition);\n        }\n        //------------------------------------------------------------------------------\n        ChilliSource::ByteBufferUPtr VirtualBinaryInputStream::ReadAll() noexcept\n        {\n            CS_ASSERT(IsValid(), \"Trying to use an invalid FileStream.\");\n\n            //Reset the read position to the beginning\n            SetReadPosition(0);\n\n            return Read(m_length);\n        }\n        //------------------------------------------------------------------------------\n        bool VirtualBinaryInputStream::Read(u8* buffer, u64 length) noexcept\n        {\n            CS_ASSERT(IsValid(), \"Trying to use an invalid FileStream.\");\n\n            if(m_stream.eof())\n            {\n                return false;\n            }\n\n            //Ensure that we never overrun the file stream\n            const auto currentPosition = GetReadPosition();\n            const auto maxValidLength = std::min(m_length - currentPosition, length);\n\n            if(maxValidLength == 0)\n            {\n                return true;\n            }\n\n            m_stream.read(reinterpret_cast<s8*>(buffer), maxValidLength);\n\n            CS_ASSERT(!m_stream.fail(), \"Unexpected error occured in filestream\");\n\n            return true;\n        }\n        //------------------------------------------------------------------------------\n        ChilliSource::ByteBufferUPtr VirtualBinaryInputStream::Read(u64 length) noexcept\n        {\n            CS_ASSERT(IsValid(), \"Trying to use an invalid FileStream.\");\n\n            if(m_stream.eof())\n            {\n                return nullptr;\n            }\n\n            //Ensure that we never overrun the file stream\n            const auto currentPosition = GetReadPosition();\n            const auto maxValidLength = std::min(m_length - currentPosition, length);\n\n            if(maxValidLength == 0)\n            {\n                return nullptr;\n            }\n\n            s8* data = new s8[maxValidLength];\n            m_stream.read(data, maxValidLength);\n\n            CS_ASSERT(!m_stream.fail(), \"Unexpected error occured in filestream\");\n\n            std::unique_ptr<const u8[]> uniqueData(reinterpret_cast<u8*>(data));\n\n            return ChilliSource::ByteBufferUPtr(new ChilliSource::ByteBuffer(std::move(uniqueData), maxValidLength));\n        }\n        //------------------------------------------------------------------------------\n        VirtualBinaryInputStream::~VirtualBinaryInputStream() noexcept\n        {\n            if(IsValid() == true)\n            {\n                m_stream.str(std::string());\n                m_buffer.reset();\n            }\n        }\n\t}\n}\n\n#endif"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/JNI/Core/File/VirtualBinaryInputStream.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright © 2016 Tag Games. All rights reserved.\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n\n#ifndef _CSBACKEND_PLATFORM_ANDROID_MAIN_JNI_CORE_FILE_VIRTUALBINARYINPUTSTREAM_H_\n#define _CSBACKEND_PLATFORM_ANDROID_MAIN_JNI_CORE_FILE_VIRTUALBINARYINPUTSTREAM_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Base/ByteBuffer.h>\n#include <ChilliSource/Core/File/FileStream/IBinaryInputStream.h>\n\n#include <fstream>\n#include <sstream>\n\nnamespace CSBackend\n{\n\tnamespace Android\n\t{\n\t    /// Class to provide binary read functionality for a virtual file. A virtual\n\t    /// file in this case is simply a blob of memory that we treat as if it is coming\n\t    /// directly from file.\n        ///\n        /// VirtualBinaryInputStream is thread agnostic, but not thread-safe.\n        /// i.e. Instances can be used by one thread at a time. It doesn't matter\n        /// which thread as long as any previous threads are no longer accessing it\n        ///\n        class VirtualBinaryInputStream final : public ChilliSource::IBinaryInputStream\n        {\n            public:\n\n        \t\tCS_DECLARE_NOCOPY(VirtualBinaryInputStream);\n\n                /// Creates a new file stream into the given memory blob. This \"stream\" should\n                /// remain valid for an instances lifecycle.\n                ///\n                /// @param buffer\n                ///     The memory buffer which will be used as a \"virtual\" file.\n                /// @param bufferSize\n                ///     The size of the memory buffer.\n                ///\n                VirtualBinaryInputStream(std::unique_ptr<u8[]> buffer, u32 bufferSize) noexcept;\n\n                /// Checks the status of the stream, if this returns false then the stream\n                /// can no longer be accessed.\n                ///\n                /// @return If the stream is valid and available for use.\n                ///\n                bool IsValid() const noexcept override;\n\n                /// @return Length of stream in bytes.\n                ///\n                u64 GetLength() const noexcept override;\n\n                /// Gets the position from which the next read operation will begin. The position\n                /// is always specified relative to the start of the file\n                ///\n                /// @return The position from the start of the stream.\n                ///\n                u64 GetReadPosition() noexcept override;\n\n                /// Sets the position through the stream from which the next read operation will\n                /// begin. The position is always specified relative to the start of the file. This does\n                /// not affect the output of ReadAll().\n                ///\n                /// @param readPosition\n                ///     The position from the start of the stream.\n                ///\n                void SetReadPosition(u64 readPosition) noexcept override;\n\n                /// Reads in a number of characters from the current read position and puts them\n                /// into the passed buffer. If the length of the stream is overrun, the buffer\n                /// will contain everything up to that point.\n                ///\n                /// If the current read position is at the end of the file, this function will return\n                /// false.\n                ///\n                /// @param buffer\n                ///     The buffer to read into.\n                /// @param length\n                ///     The number of characters to read.\n                ///\n                /// @return If the read was successful\n                ///\n                bool Read(u8* buffer, u64 length) noexcept override;\n\n                /// @return The resulting read bytes wrapped in a BinaryStreamBuffer object. This\n                ///     will be nullptr for empty files\n                ///\n                ChilliSource::ByteBufferUPtr ReadAll() noexcept override;\n\n                /// Reads in a number of characters from the current read position and puts them\n                /// into a BinaryStreamBuffer. If the length of the stream is overrun, the buffer\n                /// will contain everything up to that point.\n                ///\n                /// If the current read position is at the end of the file, this function will return\n                /// nullptr.\n                ///\n                /// @param length\n                ///     The number of characters to read\n                ///\n                /// @return The resulting read bytes wrapped in a BinaryStreamBuffer object\n                ///\n                ChilliSource::ByteBufferUPtr Read(u64 length) noexcept override;\n\n                ~VirtualBinaryInputStream() noexcept;\n\n\t\tprivate:\n\n\t\t\tstd::unique_ptr<u8[]> m_buffer;\n\t\t\tstd::stringstream m_stream;\n\n            u64 m_length = 0;\n            bool m_isValid = false;\n        };\n    }\n}\n\n\n#endif\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/JNI/Core/File/VirtualTextInputStream.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright © 2016 Tag Games. All rights reserved.\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n\n#include <CSBackend/Platform/Android/Main/JNI/Core/File/VirtualTextInputStream.h>\n\nnamespace CSBackend\n{\n\tnamespace Android\n\t{\n        //------------------------------------------------------------------------------\n        VirtualTextInputStream::VirtualTextInputStream(std::unique_ptr<u8[]> buffer, u32 bufferSize) noexcept\n        {\n            CS_ASSERT(buffer != nullptr, \"Cannot create a virtual file stream with a null buffer.\");\n            CS_ASSERT(bufferSize > 0, \"Invalid buffer size.\");\n\n            m_buffer = std::move(buffer);\n            m_stream.rdbuf()->pubsetbuf(reinterpret_cast<s8*>(m_buffer.get()), bufferSize);\n\n            m_isValid = true;\n\n            m_length = bufferSize;\n        }\n        //------------------------------------------------------------------------------\n        bool VirtualTextInputStream::IsValid() const noexcept\n        {\n            return m_isValid;\n        }\n        //------------------------------------------------------------------------------\n        u64 VirtualTextInputStream::GetLength() const noexcept\n        {\n            CS_ASSERT(IsValid(), \"Trying to use an invalid FileStream.\");\n\n            return m_length;\n        }\n        //------------------------------------------------------------------------------\n        u64 VirtualTextInputStream::GetReadPosition() noexcept\n        {\n            CS_ASSERT(IsValid(), \"Trying to use an invalid FileStream.\");\n            return m_stream.tellg();\n        }\n        //------------------------------------------------------------------------------\n        void VirtualTextInputStream::SetReadPosition(u64 readPosition) noexcept\n        {\n            CS_ASSERT(IsValid(), \"Trying to use an invalid FileStream.\");\n            CS_ASSERT(readPosition <= GetLength(), \"Position out of bounds! - \" + ChilliSource::ToString(readPosition) + \",\" + ChilliSource::ToString(GetLength()));\n\n            m_stream.seekg(readPosition);\n        }\n        //------------------------------------------------------------------------------\n        std::string VirtualTextInputStream::ReadAll() noexcept\n        {\n            CS_ASSERT(IsValid(), \"Trying to use an invalid FileStream.\");\n\n            //Reset the read position to the beginning\n            SetReadPosition(0);\n\n            std::string fileContents = m_stream.str();\n\n            return fileContents;\n        }\n        //------------------------------------------------------------------------------\n        bool VirtualTextInputStream::ReadLine(std::string& line) noexcept\n        {\n            CS_ASSERT(IsValid(), \"Trying to use an invalid FileStream.\");\n\n            if(m_stream.eof())\n            {\n                return false;\n            }\n\n            std::getline(m_stream, line);\n\n            //Shouldn't check fail here as the fail bit will be set on a read overrun, which we handle\n            CS_ASSERT(!m_stream.bad(), \"Unexpected error occured in filestream\");\n\n            //Need to carry out another eof check here, as the check at the start of the function may\n            //not catch allcases. The EOF bit is only set when a read operation is attempted, not a seekg,\n            //so it may only be set after the above getline.\n            if(m_stream.eof())\n            {\n                return !line.empty();\n            }\n\n            return true;\n        }\n        //------------------------------------------------------------------------------\n        bool VirtualTextInputStream::Read(u64 length, std::string& readChars) noexcept\n        {\n            CS_ASSERT(IsValid(), \"Trying to use an invalid FileStream.\");\n\n            if(m_stream.eof())\n            {\n                return false;\n            }\n\n            readChars.resize(length);\n\n            //A string is guaranteed to be in contiguous memory in the c++11 standard, but not in c++03.\n            //this allows the below overwrite to work\n            m_stream.read(&readChars[0], length);\n\n            //Shouldn't check fail here as the fail bit will be set on a read overrun, which we handle\n            CS_ASSERT(!m_stream.bad(), \"Unexpected error occured in filestream\");\n\n            readChars.resize(m_stream.gcount());\n\n            //Need to carry out another eof check here, as the check at the start of the function may\n            //not catch allcases. The EOF bit is only set when a read operation is attempted, not a seekg,\n            //so it may only be set after the above read.\n            if(m_stream.eof())\n            {\n                return m_stream.gcount() != 0;\n            }\n\n            return true;\n        }\n        //------------------------------------------------------------------------------\n        VirtualTextInputStream::~VirtualTextInputStream() noexcept\n        {\n            if(IsValid() == true)\n            {\n                m_stream.str(std::string());\n                m_buffer.reset();\n            }\n        }\n\t}\n}\n\n#endif"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/JNI/Core/File/VirtualTextInputStream.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright © 2016 Tag Games. All rights reserved.\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n\n#ifndef _CSBACKEND_PLATFORM_ANDROID_MAIN_JNI_CORE_FILE_VIRTUALTEXTINPUTSTREAM_H_\n#define _CSBACKEND_PLATFORM_ANDROID_MAIN_JNI_CORE_FILE_VIRTUALTEXTINPUTSTREAM_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/File/FileStream/ITextInputStream.h>\n\n#include <fstream>\n#include <sstream>\n\nnamespace CSBackend\n{\n\tnamespace Android\n\t{\n\t    /// Class to provide textual read functionality for a virtual file. A virtual\n\t    /// file in this case is simply a blob of memory that we treat as if it is coming\n\t    /// directly from file.\n        ///\n        /// VirtualTextInputStream is thread agnostic, but not thread-safe.\n        /// i.e. Instances can be used by one thread at a time. It doesn't matter\n        /// which thread as long as any previous threads are no longer accessing it\n        ///\n        class VirtualTextInputStream final : public ChilliSource::ITextInputStream\n        {\n            public:\n\n        \t\tCS_DECLARE_NOCOPY(VirtualTextInputStream);\n\n                /// Creates a new file stream into the given memory blob. This \"stream\" should\n                /// remain valid for an instances lifecycle.\n                ///\n                /// @param buffer\n                ///     The memory buffer which will be used as a \"virtual\" file.\n                /// @param bufferSize\n                ///     The size of the memory buffer.\n                ///\n                VirtualTextInputStream(std::unique_ptr<u8[]> buffer, u32 bufferSize) noexcept;\n\n                /// Checks the status of the stream, if this returns false then the stream\n                /// can no longer be accessed.\n                ///\n                /// @return If the stream is valid and available for use\n                ///\n                bool IsValid() const noexcept override;\n\n                /// @return The Length of stream in bytes\n                ///\n                u64 GetLength() const noexcept override;\n\n                /// Gets the position from which the next read operation will begin. The position\n                /// is always specified relative to the start of the file\n                ///\n                /// @return The position from the start of the stream.\n                ///\n                u64 GetReadPosition() noexcept override;\n\n                /// Sets the position through the stream from which the next read operation will\n                /// begin. The position is always specified relative to the start of the file. This does\n                /// not affect the output of ReadAll().\n                ///\n                /// @param readPosition\n                ///     The position from the start of the stream.\n                ///\n                void SetReadPosition(u64 readPosition) noexcept override;\n\n                /// @return String containing the contents of the text file, including newlines\n                ///\n                std::string ReadAll() noexcept override;\n\n                /// Reads from the current read position until the newline character ('\\n') or EOF\n                /// is reached. If the current read position is at the end of the file on entrance\n                /// then this will return false\n                ///\n                /// @param line\n                ///     String buffer that will be populated, this will not contain newline characters\n                ///\n                /// @return If a line was read successfully\n                ///\n                bool ReadLine(std::string& line) noexcept override;\n\n                /// Reads in a number of characters from the current read position and puts them\n                /// into the passed in string. If the length of the stream is overrun, readChars\n                /// will contain everything up to that point.\n                ///\n                /// If the current read position is at the end of the file, this function will return\n                /// false.\n                ///\n                /// @param length\n                ///     The number of characters to read\n                ///\n                /// @param readChars\n                ///     A string to hold the read characters, including newlines\n                ///\n                /// @return If the read was successful\n                ///\n                bool Read(u64 length, std::string& readChars) noexcept override;\n\n                ~VirtualTextInputStream() noexcept;\n\n\t\tprivate:\n\n\t\t\tstd::unique_ptr<u8[]> m_buffer;\n\t\t\tstd::stringstream m_stream;\n\n            u64 m_length = 0;\n            bool m_isValid = false;\n        };\n    }\n}\n\n\n#endif\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/JNI/Core/File/ZippedFileSystem.cpp",
    "content": "//\n//  ZippedFileSystem.cpp\n//  ChilliSource\n//  Created by Ian Copland on 08/06/2015.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2015 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <CSBackend/Platform/Android/Main/JNI/Core/File/ZippedFileSystem.h>\n\n#include <CSBackend/Platform/Android/Main/JNI/Core/File/VirtualBinaryInputStream.h>\n#include <CSBackend/Platform/Android/Main/JNI/Core/File/VirtualTextInputStream.h>\n\n#include <ChilliSource/Core/File/FileStream/IBinaryInputStream.h>\n#include <ChilliSource/Core/File/FileStream/ITextInputStream.h>\n#include <ChilliSource/Core/String/StringUtils.h>\n#include <ChilliSource/Core/Cryptographic/HashCRC32.h>\n\n#include <algorithm>\n#include <sys/stat.h>\n\nnamespace CSBackend\n{\n    namespace Android\n    {\n        namespace\n        {\n            //------------------------------------------------------------------------------\n            /// Returns whether or not the given unz_file_info represents a file or a\n            /// directory. The struct doesn't directly contain this information (though it\n            /// can be present in 'external_fa', but only if the zip was created on a posix\n            /// based platform). To get around this, the uncompressed file size is used -\n            /// if 0 it's considered a directory. Obviously there is the possibility of\n            /// false negatives if the file has no size, but since this is contained in read\n            /// only storage and a zero-size file is almost useless it unlikely to be a\n            /// problem.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param in_fileInfo - The file info.\n            //------------------------------------------------------------------------------\n            bool IsFile(const unz_file_info& in_fileInfo)\n            {\n                return (in_fileInfo.uncompressed_size > 0);\n            }\n        }\n\n        //------------------------------------------------------------------------------\n        //------------------------------------------------------------------------------\n        ZippedFileSystem::ZippedFileSystem(const std::string& in_zipFilePath, const std::string& in_rootDirectoryPath)\n            : m_filePath(in_zipFilePath)\n        {\n            BuildManifest(in_rootDirectoryPath);\n        }\n        //------------------------------------------------------------------------------\n        //------------------------------------------------------------------------------\n        bool ZippedFileSystem::IsValid() const\n        {\n            return m_isValid;\n        }\n        //------------------------------------------------------------------------------\n        //------------------------------------------------------------------------------\n        ChilliSource::ITextInputStreamUPtr ZippedFileSystem::CreateTextInputStream(const std::string& filePath) const noexcept\n        {\n            CS_ASSERT(IsValid() == true, \"Calling into an invalid ZippedFileSystem.\");\n\n            u32 bytesRead = 0;\n            std::unique_ptr<u8[]> buffer = ReadZipFileContents(filePath, bytesRead);\n\n            if(buffer == nullptr || bytesRead == 0)\n            {\n                return nullptr;\n            }\n\n            auto output = ChilliSource::ITextInputStreamUPtr(new VirtualTextInputStream(std::move(buffer), bytesRead));\n            if (output->IsValid() == false)\n            {\n                output = nullptr;\n            }\n\n            return output;\n        }\n        //------------------------------------------------------------------------------\n        //------------------------------------------------------------------------------\n        ChilliSource::IBinaryInputStreamUPtr ZippedFileSystem::CreateBinaryInputStream(const std::string& filePath) const noexcept\n        {\n            CS_ASSERT(IsValid() == true, \"Calling into an invalid ZippedFileSystem.\");\n\n            u32 bytesRead = 0;\n            std::unique_ptr<u8[]> buffer = ReadZipFileContents(filePath, bytesRead);\n\n            if(buffer == nullptr || bytesRead == 0)\n            {\n                return nullptr;\n            }\n\n            auto output = ChilliSource::IBinaryInputStreamUPtr(new VirtualBinaryInputStream(std::move(buffer), bytesRead));\n            if (output->IsValid() == false)\n            {\n                output = nullptr;\n            }\n\n            return output;\n        }\n        //------------------------------------------------------------------------------\n        //------------------------------------------------------------------------------\n        std::unique_ptr<u8[]> ZippedFileSystem::ReadZipFileContents(const std::string& filePath, u32& numBytesRead) const noexcept\n        {\n            CS_ASSERT(IsValid() == true, \"Calling into an invalid ZippedFileSystem.\");\n\n            //Get the manifest item describing the location of the file within the zip.\n            ManifestItem item;\n            if (TryGetManifestItem(ChilliSource::StringUtils::StandardiseFilePath(filePath), item) == false)\n            {\n                return nullptr;\n            }\n\n            //confirm the item is a file, and not a directory.\n            if (item.m_isFile == false)\n            {\n                return nullptr;\n            }\n\n            //read the contents of the zip file.\n            std::unique_lock<std::mutex> lock(m_mutex);\n\n            unzFile unzipper = unzOpen(m_filePath.c_str());\n            if (unzipper == nullptr)\n            {\n                return nullptr;\n            }\n\n            s32 result = unzGoToFilePos(unzipper, &item.m_zipPosition);\n            if (result != UNZ_OK)\n            {\n                return nullptr;\n            }\n\n            unz_file_info info;\n            unzGetCurrentFileInfo(unzipper, &info, nullptr, 0, nullptr, 0, nullptr, 0);\n\n            result = unzOpenCurrentFile(unzipper);\n            if (result != UNZ_OK)\n            {\n                return nullptr;\n            }\n\n            numBytesRead = info.uncompressed_size;\n            std::unique_ptr<u8[]> buffer(new u8[numBytesRead]);\n\n            unzReadCurrentFile(unzipper, (voidp)buffer.get(), numBytesRead);\n            unzCloseCurrentFile(unzipper);\n            unzClose(unzipper);\n\n            return std::move(buffer);\n        }\n        //------------------------------------------------------------------------------\n        //------------------------------------------------------------------------------\n        bool ZippedFileSystem::ExtractFiles(const std::vector<std::string>& in_filePaths, const FileReadDelegate& in_delegate) const\n        {\n            CS_ASSERT(IsValid() == true, \"Calling into an invalid ZippedFileSystem.\");\n\n            std::unique_lock<std::mutex> lock(m_mutex);\n\n            unzFile unzipper = unzOpen(m_filePath.c_str());\n            if (unzipper == nullptr)\n            {\n                return false;\n            }\n\n            bool success = true;\n            ManifestItem item;\n            unz_file_info info;\n            for (const auto& unstandardisedFilePath : in_filePaths)\n            {\n                auto filePath = ChilliSource::StringUtils::StandardiseFilePath(unstandardisedFilePath);\n                if (TryGetManifestItem(filePath, item) == false)\n                {\n                    success = false;\n                    break;\n                }\n\n                if (item.m_isFile == false)\n                {\n                    success = false;\n                    break;\n                }\n\n                s32 result = unzGoToFilePos(unzipper, &item.m_zipPosition);\n                if (result != UNZ_OK)\n                {\n                    success = false;\n                    break;\n                }\n\n                unzGetCurrentFileInfo(unzipper, &info, nullptr, 0, nullptr, 0, nullptr, 0);\n\n                result = unzOpenCurrentFile(unzipper);\n                if (result != UNZ_OK)\n                {\n                    success = false;\n                    break;\n                }\n\n                std::unique_ptr<u8[]> buffer(new u8[info.uncompressed_size]);\n                unzReadCurrentFile(unzipper, (voidp)buffer.get(), info.uncompressed_size);\n                unzCloseCurrentFile(unzipper);\n\n                if (in_delegate(unstandardisedFilePath, std::move(buffer), info.uncompressed_size) == false)\n                {\n                    success = false;\n                    break;\n                }\n            }\n\n            unzClose(unzipper);\n\n            return success;\n        }\n        //------------------------------------------------------------------------------\n        //------------------------------------------------------------------------------\n        bool ZippedFileSystem::DoesFileExist(const std::string& in_filePath) const\n        {\n            CS_ASSERT(IsValid() == true, \"Calling into an invalid ZippedFileSystem.\");\n\n            ManifestItem item;\n            if (TryGetManifestItem(ChilliSource::StringUtils::StandardiseFilePath(in_filePath), item) == true)\n            {\n                if (item.m_isFile == true)\n                {\n                    return true;\n                }\n            }\n\n            return false;\n        }\n        //------------------------------------------------------------------------------\n        //------------------------------------------------------------------------------\n        bool ZippedFileSystem::DoesDirectoryExist(const std::string& in_directoryPath) const\n        {\n            CS_ASSERT(IsValid() == true, \"Calling into an invalid ZippedFileSystem.\");\n\n            ManifestItem item;\n            if (TryGetManifestItem(ChilliSource::StringUtils::StandardiseDirectoryPath(in_directoryPath), item) == true)\n            {\n                if (item.m_isFile == false)\n                {\n                    return true;\n                }\n            }\n\n            return false;\n        }\n        //------------------------------------------------------------------------------\n        //------------------------------------------------------------------------------\n        std::vector<std::string> ZippedFileSystem::GetFilePaths(const std::string& in_directoryPath, bool in_recursive) const\n        {\n            CS_ASSERT(IsValid() == true, \"Calling into an invalid ZippedFileSystem.\");\n\n            std::vector<std::string> output;\n            auto directoryPath = ChilliSource::StringUtils::StandardiseDirectoryPath(in_directoryPath);\n            for (const auto& item : m_manifestItems)\n            {\n                if (item.m_isFile == true && ChilliSource::StringUtils::StartsWith(item.m_path, directoryPath, false) == true)\n                {\n                    auto relativeFilePath = item.m_path.substr(directoryPath.length());\n                    if (in_recursive == true || relativeFilePath.find('/') == std::string::npos)\n                    {\n                        output.push_back(relativeFilePath);\n                    }\n                }\n            }\n\n            return output;\n        }\n        //------------------------------------------------------------------------------\n        //------------------------------------------------------------------------------\n        std::vector<std::string> ZippedFileSystem::GetDirectoryPaths(const std::string& in_directoryPath, bool in_recursive) const\n        {\n            CS_ASSERT(IsValid() == true, \"Calling into an invalid ZippedFileSystem.\");\n\n            std::vector<std::string> output;\n            auto directoryPath = ChilliSource::StringUtils::StandardiseDirectoryPath(in_directoryPath);\n            for (const auto& item : m_manifestItems)\n            {\n                if (item.m_isFile == false && item.m_path != directoryPath && ChilliSource::StringUtils::StartsWith(item.m_path, directoryPath, false) == true)\n                {\n                    auto relativeDirectoryPath = item.m_path.substr(directoryPath.length());\n                    if (in_recursive == true || relativeDirectoryPath.find('/') == relativeDirectoryPath.length() - 1)\n                    {\n                        output.push_back(relativeDirectoryPath);\n                    }\n                }\n            }\n\n            return output;\n        }\n        //------------------------------------------------------------------------------\n        //------------------------------------------------------------------------------\n        bool ZippedFileSystem::TryGetFileInfo(const std::string& in_filePath, FileInfo& out_fileInfo) const\n        {\n            CS_ASSERT(IsValid() == true, \"Calling into an invalid ZippedFileSystem.\");\n\n            //Get the manifest item describing the location of the file within the zip.\n            ManifestItem item;\n            if (TryGetManifestItem(ChilliSource::StringUtils::StandardiseFilePath(in_filePath), item) == false)\n            {\n                return false;\n            }\n\n            //confirm the item is a file, and not a directory.\n            if (item.m_isFile == false)\n            {\n                return false;\n            }\n\n            //read the contents of the zip file.\n            std::unique_lock<std::mutex> lock(m_mutex);\n\n            unzFile unzipper = unzOpen(m_filePath.c_str());\n            if (unzipper == nullptr)\n            {\n                return false;\n            }\n\n            s32 result = unzGoToFilePos(unzipper, &item.m_zipPosition);\n            if (result != UNZ_OK)\n            {\n                return false;\n            }\n\n            unz_file_info info;\n            unzGetCurrentFileInfo(unzipper, &info, nullptr, 0, nullptr, 0, nullptr, 0);\n\n            result = unzOpenCurrentFile(unzipper);\n            if (result != UNZ_OK)\n            {\n                return false;\n            }\n\n            out_fileInfo.m_offset = static_cast<u32>(unzGetCurrentFileZStreamPos64(unzipper));\n            out_fileInfo.m_size = static_cast<u32>(info.compressed_size);\n            out_fileInfo.m_uncompressedSize = static_cast<u32>(info.uncompressed_size);\n            out_fileInfo.m_isCompressed = (info.compression_method != 0);\n\n            unzCloseCurrentFile(unzipper);\n            unzClose(unzipper);\n\n            return true;\n        }\n        //------------------------------------------------------------------------------\n        //------------------------------------------------------------------------------\n        void ZippedFileSystem::BuildManifest(const std::string& in_rootDirectoryPath)\n        {\n            CS_ASSERT(m_isValid == false, \"Cannot re-build manifest.\");\n\n            static const u32 k_filePathLength = 32 * 1024;\n\n            unzFile unzipper = unzOpen(m_filePath.c_str());\n            if (unzipper == nullptr)\n            {\n                return;\n            }\n\n            char filePathBytes[k_filePathLength];\n            auto rootDirectoryPath = ChilliSource::StringUtils::StandardiseDirectoryPath(in_rootDirectoryPath);\n\n            s32 status = unzGoToFirstFile(unzipper);\n            while (status == UNZ_OK)\n            {\n                unz_file_info info;\n                unzGetCurrentFileInfo(unzipper, &info, filePathBytes, k_filePathLength, nullptr, 0, nullptr, 0);\n                std::string filePath = ChilliSource::StringUtils::StandardiseFilePath(filePathBytes);\n\n                if (in_rootDirectoryPath.empty() == true || ChilliSource::StringUtils::StartsWith(filePath, rootDirectoryPath, false) == true)\n                {\n                    if (rootDirectoryPath.empty() == false)\n                    {\n                        filePath = filePath.erase(0, rootDirectoryPath.size());\n                    }\n\n                    unz_file_pos filePos;\n                    unzGetFilePos(unzipper, &filePos);\n                    AddItemToManifest(filePath, filePos, IsFile(info));\n                }\n\n                status = unzGoToNextFile(unzipper);\n            }\n            unzClose(unzipper);\n\n            std::sort(m_manifestItems.begin(), m_manifestItems.end(), [](const ManifestItem& in_lhs, const ManifestItem& in_rhs)\n            {\n                return in_lhs.m_pathHash < in_rhs.m_pathHash;\n            });\n\n            m_isValid = true;\n        }\n        //------------------------------------------------------------------------------\n        //------------------------------------------------------------------------------\n        void ZippedFileSystem::AddItemToManifest(const std::string& in_filePath, unz_file_pos in_zipPosition, bool in_isFile)\n        {\n            std::string filePath = ChilliSource::StringUtils::StandardiseFilePath(in_filePath);\n\n            std::string directoryPath, fileName;\n            ChilliSource::StringUtils::SplitFilename(filePath, fileName, directoryPath);\n\n            std::vector<std::string> directoryPathSections = ChilliSource::StringUtils::Split(directoryPath, \"/\");\n            std::string currDirectoryPath;\n            for (const auto& directorySection : directoryPathSections)\n            {\n                currDirectoryPath += ChilliSource::StringUtils::StandardiseDirectoryPath(directorySection);\n                if (currDirectoryPath.empty() == false)\n                {\n                    u32 currDirectoryHash = ChilliSource::HashCRC32::GenerateHashCode(currDirectoryPath);\n\n                    //check to see if this directory has previously been seen. The usual\n                    auto it = std::find_if(m_manifestItems.begin(), m_manifestItems.end(), [=](const ManifestItem& in_item)\n                    {\n                        return (in_item.m_pathHash == currDirectoryHash && in_item.m_path == currDirectoryPath);\n                    });\n\n                    if (it == m_manifestItems.end())\n                    {\n                        ManifestItem item;\n                        item.m_path = currDirectoryPath;\n                        item.m_pathHash = currDirectoryHash;\n                        item.m_isFile = false;\n                        item.m_zipPosition = in_zipPosition;\n                        m_manifestItems.push_back(item);\n                    }\n                }\n            }\n\n\t\t\tManifestItem item;\n\t\t\titem.m_path = filePath;\n\t\t\titem.m_pathHash = ChilliSource::HashCRC32::GenerateHashCode(item.m_path);\n\t\t\titem.m_isFile = in_isFile;\n\t\t\titem.m_zipPosition = in_zipPosition;\n\t\t\tm_manifestItems.push_back(item);\n        }\n        //------------------------------------------------------------------------------\n        //------------------------------------------------------------------------------\n        bool ZippedFileSystem::TryGetManifestItem(const std::string& in_path, ManifestItem& out_manifestItem) const\n        {\n            CS_ASSERT(IsValid() == true, \"Cannot get manifest item before construction finishes as the manifest item list wont have been sorted yet.\");\n\n            ManifestItem searchItem;\n            searchItem.m_pathHash = ChilliSource::HashCRC32::GenerateHashCode(in_path);\n\n            auto it = std::lower_bound(m_manifestItems.begin(), m_manifestItems.end(), searchItem, [](const ManifestItem& in_lhs, const ManifestItem& in_rhs)\n            {\n                return in_lhs.m_pathHash < in_rhs.m_pathHash;\n            });\n\n            //Avoid collisions by iterating until we find the item with both the correct hash and correct path.\n            while (it != m_manifestItems.end() && it->m_pathHash == searchItem.m_pathHash)\n            {\n                if (it->m_path == in_path)\n                {\n                    out_manifestItem = *it;\n                    return true;\n                }\n\n                ++it;\n            }\n\n            return false;\n        }\n    }\n}"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/JNI/Core/File/ZippedFileSystem.h",
    "content": "//\n//  ZippedFileSystem.h\n//  ChilliSource\n//  Created by Ian Copland on 08/06/2015.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2015 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CSBACKEND_PLATFORM_ANDROID_MAIN_JNI_CORE_FILE_ZIPPEDFILESYSTEM_H_\n#define _CSBACKEND_PLATFORM_ANDROID_MAIN_JNI_CORE_FILE_ZIPPEDFILESYSTEM_H_\n\n#include <CSBackend/Platform/Android/Main/JNI/ForwardDeclarations.h>\n\n#include <ChilliSource/ChilliSource.h>\n\n#include <minizip/unzip.h>\n\n#include <mutex>\n#include <unordered_map>\n#include <vector>\n#include <utility>\n\nnamespace CSBackend\n{\n    namespace Android\n    {\n        //------------------------------------------------------------------------------\n        /// Performs various file system style operations on the contents of a zip file.\n        /// This includes operations such as creation of (virtual) file streams, copying\n        /// a file and listing the contents of a directory.\n        ///\n        /// This is thread-safe and many operations can be performed without locking.\n        /// This isn't possible for some operations, however, such as creating a file\n        /// stream or copying files. In these cases care needs to be taken to avoid\n        /// negatively hurting performance.\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------------------------------------\n        class ZippedFileSystem final\n        {\n        public:\n            CS_DECLARE_NOCOPY(ZippedFileSystem);\n            //------------------------------------------------------------------------------\n            /// A struct containing information about the location of a single file within\n            /// the zip. This can be used to manually access the zip data.\n            ///\n            /// @author Ian Copland\n            //------------------------------------------------------------------------------\n            struct FileInfo final\n            {\n                u32 m_offset = 0;\n                u32 m_size = 0;\n                u32 m_uncompressedSize = 0;\n                bool m_isCompressed = false;\n            };\n            //------------------------------------------------------------------------------\n            /// A delegate called by the ExtractFiles() method as each file is read from\n            /// the zip.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param in_fileName - The path to the file which this callback refers to.\n            /// @param in_fileContents - The entire contents of the file.\n            /// @param in_fileSize - The size of the file.\n            ///\n            /// @return False should be returned if an error has occurred and ExtractFiles()\n            /// should no longer continue.\n            //------------------------------------------------------------------------------\n            using FileReadDelegate = std::function<bool(const std::string& in_filePath, std::unique_ptr<const u8[]> in_fileContents, u32 in_fileSize)>;\n            //------------------------------------------------------------------------------\n            /// Opens the zip file and builds a manifest of its contents. This is then used\n            /// in all future operations for the sake of performance. This means that the\n            /// zip file cannot change while this is in use.\n            ///\n            /// If only a subset of the zip contents is needed then a root path can be\n            /// supplied. All operations are then relative to this root directory path.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param in_zipFilePath - The file path to the zip.\n            /// @param in_rootDirectoryPath - [Optional] The root directory inside the zip.\n            /// Defaults to the root of the zip file.\n            //------------------------------------------------------------------------------\n            ZippedFileSystem(const std::string& in_zipFilePath, const std::string& in_rootDirectoryPath = \"\");\n            //------------------------------------------------------------------------------\n            /// This should be checked prior to using any of the other methods. If this\n            /// returns false the ZippedFileSystem should be discarded.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @return Whether or not the zip has been successfully opened and is ready\n            /// for use.\n            //------------------------------------------------------------------------------\n            bool IsValid() const;\n            //------------------------------------------------------------------------------\n            /// Creates a new \"virtual\" input text stream to a file within the zip. The zipped\n            /// file is inflated in full and stored in memory. The \"virtual\" file stream\n            /// then treats this memory as if it were a file on disk.\n            ///\n            /// This can only be called by one thread at a time meaning others will block\n            /// until it is finished. This can be a slow operation if accessing a large\n            /// file, so care needs to be taken to ensure this doesn't cause visible\n            /// stutters on the main thread.\n            ///\n            /// @author HMcLaughlin\n            ///\n            /// @param filePath - The file path inside the zip, relative to the \"root\n            /// directory path\".\n            ///\n            /// @return The file stream.\n            //------------------------------------------------------------------------------\n            ChilliSource::ITextInputStreamUPtr CreateTextInputStream(const std::string& filePath) const noexcept;\n            //------------------------------------------------------------------------------\n            /// Creates a new \"virtual\" input binary stream to a file within the zip. The zipped\n            /// file is inflated in full and stored in memory. The \"virtual\" file stream\n            /// then treats this memory as if it were a file on disk.\n            ///\n            /// This can only be called by one thread at a time meaning others will block\n            /// until it is finished. This can be a slow operation if accessing a large\n            /// file, so care needs to be taken to ensure this doesn't cause visible\n            /// stutters on the main thread.\n            ///\n            /// @author HMcLaughlin\n            ///\n            /// @param filePath - The file path inside the zip, relative to the \"root\n            /// directory path\".\n            ///\n            /// @return The file stream.\n            //------------------------------------------------------------------------------\n            ChilliSource::IBinaryInputStreamUPtr CreateBinaryInputStream(const std::string& filePath) const noexcept;\n            //------------------------------------------------------------------------------\n            /// Opens a series of files one by one without closing the zip. The contents of\n            /// each file are returned via the FileReadDelegate.\n            ///\n            /// While each file could be loaded individually using CreateFileStream(), it\n            /// would involve repeatedly opening and closing the zip file. For bulk\n            /// operations - i.e copying a directory - that approach would be fairly\n            /// inefficient. This method doesn't close the zip after each file stream is\n            /// created and acts as a more efficient alternate.\n            ///\n            /// This can only be called by one thread at a time meaning others will block\n            /// until it is finished. This can be a slow operation if copying large files,\n            /// so care needs to be taken to ensure this doesn't cause visible stutters on\n            /// the main thread.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param in_filePaths - Pairs of file paths, the first being the source path\n            /// within the zip, the second being the destination path on disk.\n            /// @param in_delegate - The file read delegate. Called as each file is read.\n            ///\n            /// @return Whether or not this was successful. If any file fails to extract\n            /// this will return null.\n            //------------------------------------------------------------------------------\n            bool ExtractFiles(const std::vector<std::string>& in_filePaths, const FileReadDelegate& in_delegate) const;\n            //------------------------------------------------------------------------------\n            /// @author Ian Copland\n            ///\n            /// @param in_filePath - The file path inside the zip, relative to the \"root\n            /// directory path\".\n            ///\n            /// @return Whether or not the file path exists.\n            //------------------------------------------------------------------------------\n            bool DoesFileExist(const std::string& in_filePath) const;\n            //------------------------------------------------------------------------------\n            /// @author Ian Copland\n            ///\n            /// @param in_directoryPath - The directory path inside the zip, relative to the\n            /// \"root directory path\".\n            ///\n            /// @return Whether or not the directory path exists.\n            //------------------------------------------------------------------------------\n            bool DoesDirectoryExist(const std::string& in_directoryPath) const;\n            //------------------------------------------------------------------------------\n            /// @author Ian Copland\n            ///\n            /// @param in_directoryPath - The directory path inside the zip, relative to the\n            /// \"root directory path\".\n            /// @param in_recursive - Whether or not to recurse into sub-directories.\n            ///\n            /// @return A list of all files within the given directory path.\n            //------------------------------------------------------------------------------\n            std::vector<std::string> GetFilePaths(const std::string& in_directoryPath, bool in_recursive) const;\n            //------------------------------------------------------------------------------\n            /// @author Ian Copland\n            ///\n            /// @param in_directoryPath - The directory path inside the zip, relative to the\n            /// \"root directory path\".\n            /// @param in_recursive - Whether or not to recurse into sub-directories.\n            ///\n            /// @return A list of all directories within the given directory path.\n            //------------------------------------------------------------------------------\n            std::vector<std::string> GetDirectoryPaths(const std::string& in_directoryPath, bool in_recursive) const;\n            //------------------------------------------------------------------------------\n            /// Gets information on a single file within the zip. This information requires\n            /// the zip file to be opened and therefore requires a lock to remain thread\n            /// safe.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param in_filePath - The path to the file within the zip.\n            /// @param out_fileInfo - [Out] The output file info. This will only be set if\n            /// the request was successful.\n            ///\n            /// @return Whether or not this was successful.\n            //------------------------------------------------------------------------------\n            bool TryGetFileInfo(const std::string& in_filePath, FileInfo& out_fileInfo) const;\n\n        private:\n            //------------------------------------------------------------------------------\n            /// A container for the information on a item within the zip file.\n            ///\n            /// @author Ian Copland\n            //------------------------------------------------------------------------------\n            struct ManifestItem\n            {\n                u32 m_pathHash = 0;\n                std::string m_path;\n                bool m_isFile = false;\n                unz_file_pos m_zipPosition;\n            };\n            //------------------------------------------------------------------------------\n            /// Builds a manifest of the contents of the given root directory within the\n            /// zip file. If the entire zip is required then an empty root directory path\n            /// should be given.\n            ///\n            /// This *must* only be called from the constructor. The class needs to be\n            /// immutable after construction to allow lockless thread-safety on many of\n            /// the methods. Building the manifest after construction would violate this.\n            ///\n            /// @author Ian Copland\n            //------------------------------------------------------------------------------\n            void BuildManifest(const std::string& in_rootDirectoryPath);\n            //------------------------------------------------------------------------------\n            /// Adds a new item to the manifest. If the directory path the manifest is\n            /// located in (or any parent directories) doesn't exist in the manifest then\n            /// they will be added as well.\n            ///\n            /// This *must* only be called during construction. The class needs to be\n            /// immutable after construction to allow lockless thread-safety on many of\n            /// the methods. Building the manifest after construction would violate this.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param in_filePath - The file path which should be added to the manifest.\n            /// @param in_zipPosition - The position of the file inside the zip.\n            /// @param in_isFile - Whether or not the entry is a file.\n            //------------------------------------------------------------------------------\n            void AddItemToManifest(const std::string& in_filePath, unz_file_pos in_zipPosition, bool in_isFile);\n            //------------------------------------------------------------------------------\n            /// Searches the manifest item list for the manifest item with the given path.\n            /// If it is found true is returned and the output manifest item is set. If it\n            /// is not found false is returned and no value is set for the output manifest\n            /// item.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param in_path - The file or directory path to look up.\n            /// @param out_manifestItem - [Out] The manifest item if successful.\n            ///\n            /// @return Whether or not the look up was successful.\n            //------------------------------------------------------------------------------\n            bool TryGetManifestItem(const std::string& in_path, ManifestItem& out_manifestItem) const;\n            //------------------------------------------------------------------------------\n            /// Reads a zip files contents and returns, length of the file is stored in the numBytesRead\n            /// param. Returns nullptr if file is empty or the file doesn't exist.\n            ///\n            /// @author HMcLaughlin\n            ///\n            /// @param filePath - The zipped file to read.\n            /// @param numBytesRead - The number of bytes read from file.\n            ///\n            /// @return The data read.\n            //------------------------------------------------------------------------------\n            std::unique_ptr<u8[]> ReadZipFileContents(const std::string& filePath, u32& numBytesRead) const noexcept;\n\n            std::string m_filePath;\n            bool m_isValid = false;\n            std::vector<ManifestItem> m_manifestItems;\n\n            mutable std::mutex m_mutex;\n        };\n    }\n}\n\n#endif"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/JNI/Core/Image/PNGImageProvider.cpp",
    "content": "//\n//  PNGImageProvider.cpp\n//  ChilliSource\n//  Created by Ian Copland on 05/02/2011.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2011 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n\n#include <CSBackend/Platform/Android/Main/JNI/Core/Image/PNGImageProvider.h>\n\n#include <CSBackend/Platform/Android/Main/JNI/Core/Image/PngImage.h>\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/Image/Image.h>\n#include <ChilliSource/Core/Image/ImageCompression.h>\n#include <ChilliSource/Core/Image/ImageFormat.h>\n#include <ChilliSource/Core/String/StringUtils.h>\n#include <ChilliSource/Core/Threading/TaskScheduler.h>\n\nnamespace CSBackend\n{\n\tnamespace Android\n\t{\n\t\tnamespace\n\t\t{\n\t\t\tconst std::string k_pngExtension(\"png\");\n\n            //-----------------------------------------------------------\n            /// Performs the heavy lifting for the 2 create methods\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param The storage location.\n            /// @param The filepath.\n            /// @param Completion delegate\n            /// @param [Out] The output resource\n            //-----------------------------------------------------------\n\t\t\tvoid CreatePNGImageFromFile(ChilliSource::StorageLocation in_storageLocation, const std::string& in_filepath, const ChilliSource::ResourceProvider::AsyncLoadDelegate& in_delegate, const ChilliSource::ResourceSPtr& out_resource)\n\t\t\t{\n\t\t\t\tChilliSource::Image* imageResource = (ChilliSource::Image*)(out_resource.get());\n\n\t\t\t\t//load the png image\n\t\t\t\tPngImage image;\n\t\t\t\timage.Load(in_storageLocation, in_filepath);\n\n\t\t\t\t//check the image has loaded\n\t\t\t\tif(image.IsLoaded() == false)\n\t\t\t\t{\n\t\t\t\t\timage.Release();\n\t\t\t\t\tCS_LOG_ERROR(\"Failed to load image: \" + in_filepath);\n\t\t\t\t\timageResource->SetLoadState(ChilliSource::Resource::LoadState::k_failed);\n\t                if(in_delegate != nullptr)\n\t                {\n\t                    ChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_mainThread, [=](const ChilliSource::TaskContext&)\n\t                    {\n\t                    \tin_delegate(out_resource);\n\t                    });\n\t                }\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n                ChilliSource::Image::Descriptor desc;\n                desc.m_compression = ChilliSource::ImageCompression::k_none;\n                desc.m_format = image.GetImageFormat();\n                desc.m_width = image.GetWidth();\n                desc.m_height = image.GetHeight();\n                desc.m_dataSize = image.GetDataSize();\n                imageResource->Build(desc, ChilliSource::Image::ImageDataUPtr(image.GetImageData()));\n\n\t\t\t\t//release the png image without deallocating the image data\n\t\t\t\timage.Release(false);\n\n\t\t\t\timageResource->SetLoadState(ChilliSource::Resource::LoadState::k_loaded);\n                if(in_delegate != nullptr)\n                {\n                    ChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_mainThread, [=](const ChilliSource::TaskContext&)\n                    {\n                        in_delegate(out_resource);\n                    });\n                }\n\t\t\t}\n\t\t}\n\n\t\tCS_DEFINE_NAMEDTYPE(PNGImageProvider);\n\t\t//----------------------------------------------------------------\n\t\t//----------------------------------------------------------------\n\t\tbool PNGImageProvider::IsA(ChilliSource::InterfaceIDType in_interfaceId) const\n\t\t{\n\t\t\treturn (in_interfaceId == ChilliSource::ResourceProvider::InterfaceID || in_interfaceId == ChilliSource::PNGImageProvider::InterfaceID || in_interfaceId == PNGImageProvider::InterfaceID);\n\t\t}\n        //-------------------------------------------------------\n        //-------------------------------------------------------\n        ChilliSource::InterfaceIDType PNGImageProvider::GetResourceType() const\n        {\n            return ChilliSource::Image::InterfaceID;\n        }\n\t\t//----------------------------------------------------------------\n\t\t//----------------------------------------------------------------\n\t\tbool PNGImageProvider::CanCreateResourceWithFileExtension(const std::string& in_extension) const\n\t\t{\n\t\t\treturn (in_extension == k_pngExtension);\n\t\t}\n\t\t//----------------------------------------------------------------\n\t\t//----------------------------------------------------------------\n\t\tvoid PNGImageProvider::CreateResourceFromFile(ChilliSource::StorageLocation in_storageLocation, const std::string& in_filepath, const ChilliSource::IResourceOptionsBaseCSPtr& in_options, const ChilliSource::ResourceSPtr& out_resource)\n\t\t{\n\t\t\tCreatePNGImageFromFile(in_storageLocation, in_filepath, nullptr, out_resource);\n\t\t}\n\t\t//----------------------------------------------------\n\t\t//----------------------------------------------------\n\t\tvoid PNGImageProvider::CreateResourceFromFileAsync(ChilliSource::StorageLocation in_storageLocation, const std::string& in_filePath, const ChilliSource::IResourceOptionsBaseCSPtr& in_options, const ChilliSource::ResourceProvider::AsyncLoadDelegate& in_delegate, const ChilliSource::ResourceSPtr& out_resource)\n\t\t{\n            ChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_file, [=](const ChilliSource::TaskContext&)\n            {\n                CreatePNGImageFromFile(in_storageLocation, in_filePath, in_delegate, out_resource);\n            });\n\t\t}\n\t}\n}\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/JNI/Core/Image/PNGImageProvider.h",
    "content": "//\n//  PNGImageProvider.h\n//  ChilliSource\n//  Created by Ian Copland on 05/02/2011.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2011 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n\n#ifndef _CSBACKEND_PLATFORM_ANDROID_CORE_IMAGE_PNGIMAGEPROVIDER_H_\n#define _CSBACKEND_PLATFORM_ANDROID_CORE_IMAGE_PNGIMAGEPROVIDER_H_\n\n#include <ChilliSource/Core/Image/PNGImageProvider.h>\n#include <ChilliSource/Core/Image/Image.h>\n\nnamespace CSBackend\n{\n\tnamespace Android\n\t{\n\t\t//--------------------------------------------------------------\n\t\t/// The Android backend for the Image Provider. This loads\n\t\t/// PNG images from file.\n\t\t///\n\t\t/// @author Ian Copland\n\t\t//--------------------------------------------------------------\n\t\tclass PNGImageProvider final : public ChilliSource::PNGImageProvider\n\t\t{\n\t\tpublic:\n\t\t\tCS_DECLARE_NAMEDTYPE(PNGImageProvider);\n\t\t\t//----------------------------------------------------------\n\t\t\t/// Is the object of the given interface type\n            ///\n            /// @author Ian Copland\n            ///\n\t\t\t/// @param Interface type to query\n            ///\n\t\t\t/// @return Whether the object is of given type\n\t\t\t//----------------------------------------------------------\n\t\t\tbool IsA(ChilliSource::InterfaceIDType in_interfaceId) const override;\n            //-------------------------------------------------------\n            /// @author Ian Copland\n            ///\n            /// @return The resource type this provider can load\n            //-------------------------------------------------------\n            ChilliSource::InterfaceIDType GetResourceType() const override;\n\t\t\t//----------------------------------------------------------\n\t\t\t/// Whether or not the provider can create resources from\n            /// files with the given extension.\n            ///\n\t\t\t/// @author Ian Copland\n            ///\n\t\t\t/// @param Extension to compare against\n            ///\n\t\t\t/// @return Whether the object can load a resource with that\n            /// extension\n\t\t\t//----------------------------------------------------------\n\t\t\tbool CanCreateResourceWithFileExtension(const std::string& in_extension) const override;\n\t\t\t//----------------------------------------------------------\n\t\t\t/// Creates a new image resource from file. Check the\n            /// resource load state for success or failure\n\t\t\t///\n            /// @author Ian Copland\n            ///\n            /// @param The storage location to load from\n\t\t\t/// @param File path to resource\n\t\t\t/// @param Options to customise the creation\n\t\t\t/// @param [Out] Resource\n\t\t\t//-----------------------------------------------------------\n\t\t\tvoid CreateResourceFromFile(ChilliSource::StorageLocation in_storageLocation, const std::string& in_filePath, const ChilliSource::IResourceOptionsBaseCSPtr& in_options, const ChilliSource::ResourceSPtr& out_resource) override;\n            //----------------------------------------------------\n            /// Creates a new resource from file asynchronously.\n            /// Completion delegate is called when load is finished.\n            /// Check the resource load state for success or failure\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param The storage location.\n            /// @param The filepath.\n\t\t\t/// @param Options to customise the creation\n            /// @param Completion delegate\n            /// @param [Out] The output resource.\n            //----------------------------------------------------\n\t\t\tvoid CreateResourceFromFileAsync(ChilliSource::StorageLocation in_storageLocation, const std::string& in_filePath, const ChilliSource::IResourceOptionsBaseCSPtr& in_options, const ChilliSource::ResourceProvider::AsyncLoadDelegate& in_delegate, const ChilliSource::ResourceSPtr& out_resource) override;\n\t\tprivate:\n            friend ChilliSource::PNGImageProviderUPtr ChilliSource::PNGImageProvider::Create();\n            //-----------------------------------------------------------\n            /// Private constructor to force use of factory method\n            ///\n            /// @author Ian Copland\n            //-----------------------------------------------------------\n            PNGImageProvider() = default;\n\t\t};\n\t}\n}\n\n\n\n#endif\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/JNI/Core/Image/PngImage.cpp",
    "content": "//\n//  PngImage.cpp\n//  ChilliSource\n//  Created by Ian Copland on 06/04/2011.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2011 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n\n#include <CSBackend/Platform/Android/Main/JNI/Core/Image/PngImage.h>\n\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/Image/ImageFormat.h>\n\n#include <png/png.h>\n\nnamespace CSBackend\n{\n\tnamespace Android\n\t{\n\t\t//----------------------------------------------------------------------------------\n\t\t/// Read Png Data\n\t\t///\n\t\t/// A replacement for the default libPng file reading function. This is needed so\n\t\t/// the c style file io functions can be replaced with ChilliSource functions,\n\t\t/// enabling loading from the package.\n\t\t///\n\t\t/// @param The currently open Png decorder\n\t\t/// @param The output data.\n\t\t/// @param The length of the data.\n\t\t//----------------------------------------------------------------------------------\n\t\tvoid ReadPngData(png_structp inpPng, png_bytep inpData, png_size_t indwLength)\n\t\t{\n\t\t\tif (inpPng == nullptr)\n\t\t\t{\n\t\t\t\tCS_LOG_ERROR(\"ReadPngData() has failed because inpPng is nullptr :S\");\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tChilliSource::IBinaryInputStream* pStream = (ChilliSource::IBinaryInputStream*)png_get_io_ptr(inpPng);\n\t\t\tpStream->Read((u8*)inpData, indwLength);\n\t\t}\n\t\t//----------------------------------------------------------------------------------\n\t\t/// Constructor\n\t\t//----------------------------------------------------------------------------------\n\t\tPngImage::PngImage()\n\t\t{\n\t\t\tmbIsLoaded = false;\n\t\t\tmdwHeight = -1;\n\t\t\tmdwWidth = -1;\n\t\t\tmpData = nullptr;\n\t\t\tmeFormat = ChilliSource::ImageFormat::k_RGBA8888;\n\t\t}\n\t\t//----------------------------------------------------------------------------------\n\t\t/// Constructor\n\t\t//----------------------------------------------------------------------------------\n\t\tPngImage::PngImage(ChilliSource::StorageLocation ineStorageLocation, const std::string& instrFilename)\n\t\t{\n\t\t\tmbIsLoaded = false;\n\t\t\tmdwHeight = -1;\n\t\t\tmdwWidth = -1;\n\t\t\tmpData = nullptr;\n\t\t\tmeFormat = ChilliSource::ImageFormat::k_RGBA8888;\n\n\t\t\tLoad(ineStorageLocation, instrFilename);\n\t\t}\n\t\t//----------------------------------------------------------------------------------\n\t\t/// Destructor\n\t\t//----------------------------------------------------------------------------------\n\t\tPngImage::~PngImage()\n\t\t{\n\t\t\tif (mbIsLoaded == true)\n\t\t\t{\n\t\t\t\tRelease();\n\t\t\t}\n\t\t}\n\t\t//----------------------------------------------------------------------------------\n\t\t/// Load\n\t\t//----------------------------------------------------------------------------------\n\t\tvoid PngImage::Load(ChilliSource::StorageLocation ineStorageLocation, const std::string& instrFilename)\n\t\t{\n\t\t\t//create the file stream\n\t\t\tauto stream = ChilliSource::Application::Get()->GetFileSystem()->CreateBinaryInputStream(ineStorageLocation, instrFilename);\n\n\t\t\t//insure the stream is not broken\n\t\t\tif (stream == nullptr)\n\t\t\t{\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t//load from lib png\n\t\t\tif (LoadWithLibPng(stream) == true)\n\t\t\t{\n\t\t\t\tmbIsLoaded = true;\n\t\t\t}\n\t\t}\n\t\t//----------------------------------------------------------------------------------\n\t\t/// Release\n\t\t//----------------------------------------------------------------------------------\n\t\tvoid PngImage::Release(bool inReleaseImageData)\n\t\t{\n\t\t\tif (mbIsLoaded != false)\n\t\t\t{\n\t\t\t\tmbIsLoaded = false;\n\t\t\t\tmdwHeight = -1;\n\t\t\t\tmdwWidth = -1;\n\t\t\t\tif (inReleaseImageData)\n\t\t\t\t\tdelete[] mpData;\n\t\t\t\tmpData = (u8*)nullptr;\n\t\t\t}\n\t\t}\n\t\t//----------------------------------------------------------------------------------\n\t\t/// Is Loaded\n\t\t//----------------------------------------------------------------------------------\n\t\tbool PngImage::IsLoaded()\n\t\t{\n\t\t\treturn mbIsLoaded;\n\t\t}\n\t\t//----------------------------------------------------------------------------------\n\t\t/// Get Height\n\t\t//----------------------------------------------------------------------------------\n\t\ts32 PngImage::GetHeight()\n\t\t{\n\t\t\treturn mdwHeight;\n\t\t}\n\t\t//----------------------------------------------------------------------------------\n\t\t/// Get Width\n\t\t//----------------------------------------------------------------------------------\n\t\ts32 PngImage::GetWidth()\n\t\t{\n\t\t\treturn mdwWidth;\n\t\t}\n\t\t//----------------------------------------------------------------------------------\n\t\t/// Get Image Data\n\t\t//----------------------------------------------------------------------------------\n\t\tu8 * PngImage::GetImageData()\n\t\t{\n\t\t\treturn mpData;\n\t\t}\n\t\t//----------------------------------------------------------------------------------\n\t\t//----------------------------------------------------------------------------------\n\t\tu32 PngImage::GetDataSize() const\n\t\t{\n\t\t\treturn m_dataSize;\n\t\t}\n\t\t//----------------------------------------------------------------------------------\n\t\t/// Get Image Format\n\t\t//----------------------------------------------------------------------------------\n\t\tChilliSource::ImageFormat PngImage::GetImageFormat()\n\t\t{\n\t\t\treturn meFormat;\n\t\t}\n\t\t//----------------------------------------------------------------------------------\n\t\t/// Load with lib png\n\t\t//----------------------------------------------------------------------------------\n\t\tbool PngImage::LoadWithLibPng(const ChilliSource::IBinaryInputStreamUPtr& inStream)\n\t\t{\n\t\t\t//-------- Intialisation\n\t\t\t//read the header to insure it is indeed a png\n\t\t\ts32 dwHeaderSize = 8;\n\t\t\tu8 * ubyHeader = new u8[dwHeaderSize];\n\t\t\tinStream->Read(ubyHeader, dwHeaderSize);\n\t\t\tbool bIsPng = !png_sig_cmp(ubyHeader, 0, dwHeaderSize);\n\t\t\tdelete[] ubyHeader;\n\n\t\t\t//if its not a PNG return.\n\t\t\tif (bIsPng == false)\n\t\t\t{\n\t\t\t\tCS_LOG_ERROR(\"PNG header invalid.\");\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t//create the png structure\n\t\t\tpng_structp pPng = png_create_read_struct(PNG_LIBPNG_VER_STRING, nullptr, nullptr, nullptr);\n\t\t\tif (!pPng)\n\t\t\t{\n\t\t\t\tCS_LOG_ERROR(\"Could not create pPng\");\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t//create the png info\n\t\t\tpng_infop pInfo = png_create_info_struct(pPng);\n\t\t\tif (!pInfo)\n\t\t\t{\n\t\t\t\tCS_LOG_ERROR(\"Could not create pInfo\");\n\t\t\t\tpng_destroy_read_struct(&pPng, (png_infopp)nullptr, (png_infopp)nullptr);\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t//setup jump\n\t\t\tif (setjmp(png_jmpbuf(pPng)))\n\t\t\t{\n\t\t\t\tCS_LOG_ERROR(\"Error while loading PNG.\");\n\t\t\t\tpng_destroy_read_struct(&pPng, &pInfo, (png_infopp)nullptr);\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t//Setup the ReadPngData function for use within libPng\n\t\t\tpng_set_read_fn(pPng,(void*)inStream.get(), ReadPngData);\n\n\t\t\t//tell it that we've ready read 8 bytes of data\n\t\t\tpng_set_sig_bytes(pPng, dwHeaderSize);\n\n\t\t\t//read the chunks of data upto the actual image data\n\t\t\tpng_read_info(pPng, pInfo);\n\n\t\t\t//get the info thats just been read\n\t\t\tpng_uint_32 udwWidth = 0;\n\t\t\tpng_uint_32 udwHeight = 0;\n\t\t\tint dwBitDepth = -1;\n\t\t\tint dwColorType = -1;\n\t\t\tint dwInterlaceType = -1;\n\t\t\tint dwCompressionMethod = -1;\n\t\t\tint dwFilterMethod = -1;\n\t\t\tpng_get_IHDR(pPng, pInfo, &udwWidth, &udwHeight, &dwBitDepth, &dwColorType, &dwInterlaceType, &dwCompressionMethod, &dwFilterMethod);\n\n\t\t\t//-------- Image Transformations\n\t\t\t//turn palleted pngs into RGB\n\t\t\tif (dwColorType == PNG_COLOR_TYPE_PALETTE)\n\t\t\t\tpng_set_palette_to_rgb(pPng);\n\n\t\t\t//force greyscale images to 8 bit\n\t\t\tif (dwColorType == PNG_COLOR_TYPE_GRAY && dwBitDepth < 8)\n\t\t\t\tpng_set_expand_gray_1_2_4_to_8(pPng);\n\n\t\t\t//if there is compressed alpha data, expand into a full alpha channel\n\t\t\tif (png_get_valid(pPng, pInfo, PNG_INFO_tRNS)) png_set_tRNS_to_alpha(pPng);\n\n\t\t\t//strip 16bit per channel images down to 8 bit per channel (Note the possibilty of 16bit per channel images not working due to pngs using big endianness. This can\n\t\t\t//be fixed by using png_set_swap())\n\t\t\tif (dwBitDepth == 16)\n\t\t\t\tpng_set_strip_16(pPng);\n\n\t\t\t//insure bit depth is always 8.\n\t\t\tif (dwBitDepth < 8) png_set_packing(pPng);\n\n\t\t\t//-------- Read Image\n\t\t\t//tell libpng to handling interlacing\n\t\t\tint number_of_passes = png_set_interlace_handling(pPng);\n\n\t\t\t//after all these transformations, update the png info\n\t\t\tpng_read_update_info(pPng, pInfo);\n\n\t\t\t//read the image into the data buffer\n\t\t\tint dwRowBytes = png_get_rowbytes(pPng, pInfo);\n\t\t\tm_dataSize = dwRowBytes * udwHeight;\n\t\t\tmpData = new u8[m_dataSize];\n\n\t\t\tfor (u32 pass = 0; pass < number_of_passes; pass++)\n\t\t\t{\n\t\t\t\tfor (u32 y = 0; y < udwHeight; y += 1)\n\t\t\t\t{\n\t\t\t\t\tpng_bytep row = (mpData + y * dwRowBytes);\n\t\t\t\t\tpng_read_rows(pPng, &row, nullptr, 1);\n\t\t\t\t}\n\t\t\t}\n\t\t\t//store the width and height\n\t\t\tmdwWidth = (s32)udwWidth;\n\t\t\tmdwHeight = (s32)udwHeight;\n\n\t\t\t//-------- Get the image format\n\t\t\tpng_get_IHDR(pPng, pInfo, &udwWidth, &udwHeight, &dwBitDepth, &dwColorType, &dwInterlaceType, &dwCompressionMethod, &dwFilterMethod);\n\t\t\tswitch (dwColorType)\n\t\t\t{\n\t\t\tcase PNG_COLOR_TYPE_GRAY:\n\t\t\t\tmeFormat = ChilliSource::ImageFormat::k_Lum8;\n\t\t\t\tbreak;\n\t\t\tcase PNG_COLOR_TYPE_GRAY_ALPHA:\n\t\t\t\tmeFormat = ChilliSource::ImageFormat::k_LumA88;\n\t\t\t\tbreak;\n\t\t\tcase PNG_COLOR_TYPE_RGB:\n\t\t\t\tmeFormat = ChilliSource::ImageFormat::k_RGB888;\n\t\t\t\tbreak;\n\t\t\tcase PNG_COLOR_TYPE_RGB_ALPHA:\n\t\t\t\tmeFormat = ChilliSource::ImageFormat::k_RGBA8888;\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tCS_LOG_ERROR(\"Trying to load a PNG with an unknown colour format!\");\n\t\t\t\tpng_read_end(pPng, nullptr);\n\t\t\t\tpng_destroy_read_struct(&pPng, &pInfo, (png_infopp)nullptr);\n\t\t\t\treturn false;\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\t//end the read\n\t\t\tpng_read_end(pPng, nullptr);\n\n\t\t\t//deallocate everything\n\t\t\tpng_destroy_read_struct(&pPng, &pInfo, (png_infopp)nullptr);\n\n\t\t\treturn true;\n\t\t}\n\t}\n}\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/JNI/Core/Image/PngImage.h",
    "content": "//\n//  PngImage.h\n//  ChilliSource\n//  Created by Ian Copland on 06/04/2011.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2011 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n\n#ifndef _CHILLISOURCE_ANDROIDPLATFORM_IMAGELOADING_PNGIMAGE_\n#define _CHILLISOURCE_ANDROIDPLATFORM_IMAGELOADING_PNGIMAGE_\n\n#include <ChilliSource/Core/File/FileSystem.h>\n#include <ChilliSource/Core/Image/Image.h>\n\nnamespace CSBackend\n{\n\tnamespace Android\n\t{\n\t\t//=======================================\n\t\t/// PixelRGBA8888\n\t\t///\n\t\t/// Container for a single RGBA8888 pixel\n\t\t//=======================================\n\t\tstruct PixelRGBA8888\n\t\t{\n\t\t\tu8 mbyR;\n\t\t\tu8 mbyG;\n\t\t\tu8 mbyB;\n\t\t\tu8 mbyA;\n\t\t};\n\t\t//=======================================\n\t\t/// PixelRGB888\n\t\t///\n\t\t/// Container for a single RGB888 pixel\n\t\t//=======================================\n\t\tstruct PixelRGB888\n\t\t{\n\t\t\tu8 mbyR;\n\t\t\tu8 mbyG;\n\t\t\tu8 mbyB;\n\t\t};\n\t\t//=======================================\n\t\t/// PixelRGBA4444\n\t\t///\n\t\t/// Container for a single RGBA4444 pixel\n\t\t//=======================================\n\t\tstruct PixelRGBA4444\n\t\t{\n\t\t\tu8 mbyRG;\n\t\t\tu8 mbyBA;\n\t\t};\n\t\t//=======================================\n\t\t/// PixelRGB545\n\t\t///\n\t\t/// Container for a single RGB545 pixel\n\t\t//=======================================\n\t\tstruct PixelRGB545\n\t\t{\n\t\t\tu16 mwData;\n\t\t};\n\t\t//=======================================\n\t\t/// PixelLUMA88\n\t\t///\n\t\t/// Container for a single LUMA88 pixel\n\t\t//=======================================\n\t\tstruct PixelLUMA88\n\t\t{\n\t\t\tu8 mbyLum;\n\t\t\tu8 mbyA;\n\t\t};\n\t\t//=======================================\n\t\t/// PixelLUM8\n\t\t///\n\t\t/// Container for a single LUM8 pixel\n\t\t//=======================================\n\t\tstruct PixelLUM8\n\t\t{\n\t\t\tu8 mbyLum;\n\t\t};\n\n\t\tclass PngImage\n\t\t{\n\t\tpublic:\n\t\t\t//----------------------------------------------------------------------------------\n\t\t\t/// Constructor\n\t\t\t//----------------------------------------------------------------------------------\n\t\t\tPngImage();\n\t\t\t//----------------------------------------------------------------------------------\n\t\t\t/// Constructor\n\t\t\t//----------------------------------------------------------------------------------\n\t\t\tPngImage(ChilliSource::StorageLocation ineStorageLocation, const std::string& instrFilename);\n\t\t\t//----------------------------------------------------------------------------------\n\t\t\t/// Destructor\n\t\t\t//----------------------------------------------------------------------------------\n\t\t\tvirtual ~PngImage();\n\t\t\t//----------------------------------------------------------------------------------\n\t\t\t/// Load PNG\n\t\t\t///\n\t\t\t/// Loads a png from a file within documents or the package.\n\t\t\t///\n\t\t\t/// @param The storage location to load from.\n\t\t\t/// @param The file path.\n\t\t\t//----------------------------------------------------------------------------------\n\t\t\tvoid Load(ChilliSource::StorageLocation ineStorageLocation, const std::string& instrFilename);\n\t\t\t//----------------------------------------------------------------------------------\n\t\t\t/// Release\n\t\t\t///\n\t\t\t/// Releases the image data\n\t\t\t/// @param  Whether or not to release the image data.\n\t\t\t//----------------------------------------------------------------------------------\n\t\t\tvoid Release(bool inReleaseImageData = true);\n\t\t\t//----------------------------------------------------------------------------------\n\t\t\t/// Is Loaded\n\t\t\t///\n\t\t\t/// @return whether or not the image is loaded\n\t\t\t//----------------------------------------------------------------------------------\n\t\t\tbool IsLoaded();\n\t\t\t//----------------------------------------------------------------------------------\n\t\t\t/// Get Height\n\t\t\t///\n\t\t\t/// @return the height of the image\n\t\t\t//----------------------------------------------------------------------------------\n\t\t\ts32 GetHeight();\n\t\t\t//----------------------------------------------------------------------------------\n\t\t\t/// Get Width\n\t\t\t///\n\t\t\t/// @return the width of the image\n\t\t\t//----------------------------------------------------------------------------------\n\t\t\ts32 GetWidth();\n\t\t\t//----------------------------------------------------------------------------------\n\t\t\t/// Get Image Data\n\t\t\t///\n\t\t\t/// @return the image data.\n\t\t\t//----------------------------------------------------------------------------------\n\t\t\tu8 * GetImageData();\n\t\t\t//----------------------------------------------------------------------------------\n\t\t\t/// @author S Downie\n\t\t\t///\n\t\t\t/// @return Size of image data in bytes\n\t\t\t//----------------------------------------------------------------------------------\n\t\t\tu32 GetDataSize() const;\n\t\t\t//----------------------------------------------------------------------------------\n\t\t\t/// Get Image Format\n\t\t\t///\n\t\t\t/// @return the image format\n\t\t\t//----------------------------------------------------------------------------------\n\t\t\tChilliSource::ImageFormat GetImageFormat();\n\t\tprotected:\n\t\t\t//----------------------------------------------------------------------------------\n\t\t\t/// Load with lib png\n\t\t\t///\n\t\t\t/// Loads the png data using lib png\n\t\t\t///\n\t\t\t/// @param the stream lib png should use to read the data.\n\t\t\t//----------------------------------------------------------------------------------\n\t\t\tbool LoadWithLibPng(const ChilliSource::IBinaryInputStreamUPtr& inStream);\n\n\t\t\tbool mbIsLoaded;\n\t\t\ts32 mdwHeight;\n\t\t\ts32 mdwWidth;\n\t\t\tu8 * mpData;\n\t\t\tChilliSource::ImageFormat meFormat;\n\t\t\tu32 m_dataSize = 0;\n\t\t};\n\t}\n}\n\n#endif\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/JNI/Core/Java/BoxedPointer.cpp",
    "content": "//\n//  BoxedPointer\n//  ChilliSource\n//  Created by HMcLaughlin on 31/07/2015.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2015 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n\n#include <CSBackend/Platform/Android/Main/JNI/Core/Java/BoxedPointer.h>\n\nnamespace CSBackend\n{\n\tnamespace Android\n\t{\n        namespace BoxedPointer\n        {\n            //------------------------------------------------------------------------------\n            //------------------------------------------------------------------------------\n            JavaClassDef GetBoxedPointerClassDef()\n            {\n                JavaClassDef javaBoxedPointerClassDef(\"com/chilliworks/chillisource/core/BoxedPointer\", \"(JJ)V\");\n                javaBoxedPointerClassDef.AddMethod(\"getPointerAddress\", \"()J\");\n                javaBoxedPointerClassDef.AddMethod(\"getTypeHash\", \"()J\");\n                \n                return javaBoxedPointerClassDef;\n            }\n        }\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/JNI/Core/Java/BoxedPointer.h",
    "content": "//\n//  BoxedPointer\n//  ChilliSource\n//  Created by HMcLaughlin on 31/07/2015.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2015 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n\n#ifndef _CSBACKEND_PLATFORM_ANDROID_MAIN_JNI_CORE_JAVA_BOXEDPOINTER_H_\n#define _CSBACKEND_PLATFORM_ANDROID_MAIN_JNI_CORE_JAVA_BOXEDPOINTER_H_\n\n#include <ChilliSource/ChilliSource.h>\n\n#include <CSBackend/Platform/Android/Main/JNI/ForwardDeclarations.h>\n#include <CSBackend/Platform/Android/Main/JNI/Core/Java/JavaClass.h>\n#include <CSBackend/Platform/Android/Main/JNI/Core/Java/JavaClassDef.h>\n#include <CSBackend/Platform/Android/Main/JNI/Core/Java/JavaMethodSignature.h>\n#include <CSBackend/Platform/Android/Main/JNI/Core/Java/JavaUtils.h>\n#include <CSBackend/Platform/Android/Main/JNI/Core/Java/JavaVirtualMachine.h>\n\n#include <jni.h>\n\n#include <typeindex>\n#include <unordered_map>\n\nnamespace CSBackend\n{\n\tnamespace Android\n\t{\n        namespace BoxedPointer\n        {\n            //------------------------------------------------------------------------------\n            /// @author HMcLaughlin\n            ///\n            /// @return Definition for a java BoxedPointer class\n            //------------------------------------------------------------------------------\n            JavaClassDef GetBoxedPointerClassDef();\n            //------------------------------------------------------------------------------\n            /// Generates a unique number for a templated type\n            ///\n            /// @author HMcLaughlin\n            ///\n            /// @return Unique ID\n            //------------------------------------------------------------------------------\n            template <typename TType> s64 GenerateTypeHash();\n            //------------------------------------------------------------------------------\n            /// Wraps a native pointer in a java BoxedPointer container\n            ///\n            /// @author HMcLaughlin\n            ///\n            /// @param in_type - Object pointer\n            ///\n            /// @return Java Boxed Pointer containing pointer info\n            //------------------------------------------------------------------------------\n            template <typename TType> JavaClassUPtr Box(TType* in_type);\n            //------------------------------------------------------------------------------\n            /// Casts a java BoxedPointer back to a c++ pointer of the original type\n            ///\n            /// @author HMcLaughlin\n            ///\n            /// @param in_javaContainer - Java Object containing pointer info\n            ///\n            /// @return Native pointer\n            //------------------------------------------------------------------------------\n            template <typename TType> TType* Unbox(JavaClass* in_javaBoxedPointer);\n        }\n\n        namespace BoxedPointer\n        {\n            //------------------------------------------------------------------------------\n            //------------------------------------------------------------------------------\n            template <typename TType> s64 GenerateTypeHash()\n            {\n                auto typeIndex = std::type_index(typeid(TType));\n                return static_cast<s64>(typeIndex.hash_code());\n            }\n            //------------------------------------------------------------------------------\n            //------------------------------------------------------------------------------\n            template <typename TType> JavaClassUPtr Box(TType* in_type)\n            {\n                //Create a java NativePointer for this instance\n                JavaClassDef javaBoxedPointerClassDef = GetBoxedPointerClassDef();\n\n                s64 pointerAddress = (s64)in_type;\n                s64 pointerTypeHash = GenerateTypeHash<TType>();\n\n                JavaClassUPtr javaBoxedPointerClass = JavaClassUPtr(new JavaClass(javaBoxedPointerClassDef, pointerAddress, pointerTypeHash));\n                return javaBoxedPointerClass;\n            }\n            //------------------------------------------------------------------------------\n            //------------------------------------------------------------------------------\n            template <typename TType> TType* Unbox(JavaClass* in_javaBoxedPointer)\n            {\n                CS_ASSERT(in_javaBoxedPointer->GetClassName() == GetBoxedPointerClassDef().GetClassName(), \"Cannot convert '\" + in_javaBoxedPointer->GetClassName() + \"', only BoxedPointer\");\n\n                s64 pointerAddress = in_javaBoxedPointer->CallLongMethod(\"getPointerAddress\");\n\n                CS_ASSERT(in_javaBoxedPointer->CallLongMethod(\"getTypeHash\") == GenerateTypeHash<TType>(), \"Failed to cast Java pointer back to c pointer, type mismatch!\");\n\n                return reinterpret_cast<TType*>(pointerAddress);\n            }\n        }\n    }\n}\n\n#endif\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/JNI/Core/Java/JavaClass.cpp",
    "content": "//\n//  JavaClass.cpp\n//  ChilliSource\n//  Created by Ian Copland on 21/04/2015.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2015 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n\n#include <CSBackend/Platform/Android/Main/JNI/Core/Java/JavaClass.h>\n\n#include <ChilliSource/Core/String/StringUtils.h>\n\n#include <regex>\n\nnamespace CSBackend\n{\n\tnamespace Android\n\t{\n\t    //------------------------------------------------------------------------------\n        //------------------------------------------------------------------------------\n        JavaClass::JavaClass(jobject in_object, const JavaClassDef& in_javaClassDef)\n        {\n            auto jvm = JavaVirtualMachine::Get();\n            auto environment = jvm->GetJNIEnvironment();\n\n            //Get the class\n            m_className = in_javaClassDef.GetClassName();\n            jclass jClass = jvm->FindClass(m_className);\n\n            CS_ASSERT(jClass != nullptr, \"Could not find Java class: '\" + m_className + \"'\");\n\n            m_javaObject = environment->NewGlobalRef(in_object);\n\n            //setup the method references\n            for (const auto& method : in_javaClassDef.GetMethods())\n            {\n                CS_ASSERT(m_methods.find(method.first) == m_methods.end(), \"Method '\" + method.first + \"' has already been added to Java class '\" + m_className + \"'\");\n\n                MethodInfo info;\n                info.m_returnType = JavaMethodSignature::CalcReturnType(method.second);\n                info.m_numArguments = JavaMethodSignature::CalcNumArguments(method.second);\n                info.m_methodId = environment->GetMethodID(jClass, method.first.c_str(), method.second.c_str());\n\n                CS_ASSERT(info.m_methodId != nullptr, \"Could not find method '\" + method.first + \"' in Java Class '\" + m_className + \"'\");\n\n                m_methods.emplace(method.first, info);\n            }\n\n            environment->DeleteLocalRef(jClass);\n        }\n        //------------------------------------------------------------------------------\n        //------------------------------------------------------------------------------\n        jmethodID JavaClass::GetMethodId(const std::string& in_methodName, JavaMethodSignature::ReturnType in_returnType, u32 in_numArguments) const\n        {\n            auto methodInfoIt = m_methods.find(in_methodName);\n            if (methodInfoIt == m_methods.end())\n            {\n                CS_LOG_FATAL(\"Could not find method '\" + in_methodName + \"' in Java class '\" + m_className + \"'\");\n            }\n\n            CS_ASSERT(methodInfoIt->second.m_returnType == in_returnType, \"Cannot call method '\" + in_methodName + \"' in Java class '\" + m_className + \"' because the wrong return type was specified.\");\n            CS_ASSERT(methodInfoIt->second.m_numArguments == in_numArguments, \"Cannot call method '\" + in_methodName + \"' in Java class '\" + m_className + \"' because an incorrect number of arguments were supplied.\");\n\n            return methodInfoIt->second.m_methodId;\n        }\n        //------------------------------------------------------------------------------\n        //------------------------------------------------------------------------------\n        JavaClass::~JavaClass()\n        {\n            auto environment = JavaVirtualMachine::Get()->GetJNIEnvironment();\n            environment->DeleteGlobalRef(m_javaObject);\n            m_javaObject = nullptr;\n        }\n        //------------------------------------------------------------------------------\n        //------------------------------------------------------------------------------\n        jobject JavaClass::GetJavaObject() const\n        {\n            return m_javaObject;\n        }\n        //------------------------------------------------------------------------------\n        //------------------------------------------------------------------------------\n        const std::string& JavaClass::GetClassName() const\n        {\n            return m_className;\n        }\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/JNI/Core/Java/JavaClass.h",
    "content": "//\n//  JavaClass.h\n//  ChilliSource\n//  Created by Ian Copland on 21/04/2015.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2015 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n\n#ifndef _CSBACKEND_PLATFORM_ANDROID_MAIN_JNI_CORE_JAVA_JAVACLASS_H_\n#define _CSBACKEND_PLATFORM_ANDROID_MAIN_JNI_CORE_JAVA_JAVACLASS_H_\n\n#include <ChilliSource/ChilliSource.h>\n\n#include <CSBackend/Platform/Android/Main/JNI/ForwardDeclarations.h>\n#include <CSBackend/Platform/Android/Main/JNI/Core/Java/JavaClassDef.h>\n#include <CSBackend/Platform/Android/Main/JNI/Core/Java/JavaMethodSignature.h>\n#include <CSBackend/Platform/Android/Main/JNI/Core/Java/JavaUtils.h>\n#include <CSBackend/Platform/Android/Main/JNI/Core/Java/JavaVirtualMachine.h>\n\n#include <jni.h>\n\n#include <unordered_map>\n\nnamespace CSBackend\n{\n\tnamespace Android\n\t{\n\t\t//------------------------------------------------------------------------------\n\t\t/// Provides a means to create an instance of a class in java and call its\n\t\t/// methods.\n\t\t///\n\t\t/// This is essentially a wrapper around the JNI functions for calling methods\n\t\t/// on a class instance. Methods references are cached for the sake of\n\t\t/// performance and there are a number of sanity checks to assist debugging of\n\t\t/// issues including confirming that the correct number of parameters have\n\t\t/// been provided and that the method is being called with the correct return\n\t\t/// type. Exceptions are also checked for after every method call, avoiding\n\t\t/// difficult to debug issues where native execution continues until the next\n\t\t/// java call when an exception is thrown.\n\t\t///\n\t\t/// JavaClass is immutable after construction, meaning it can safely be called\n\t\t/// from multiple threads at the same time. Care still needs to be taken to\n\t\t/// ensure the Java and Native classes that are using it are thread-safe,\n\t\t/// however.\n\t\t///\n\t\t/// @author Ian Copland\n\t\t//------------------------------------------------------------------------------\n\t\tclass JavaClass final\n\t\t{\n\t\tpublic:\n            //------------------------------------------------------------------------------\n            /// Constructor. Instantiates the defined java class and prepares the methods\n            /// so that they can be called.\n            ///\n            /// The class and all methods will be checked to ensure they exist.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param in_javaClassDef - The definition for this java class.\n            /// @param ... - The arguments to the constructor.\n            //------------------------------------------------------------------------------\n            template <typename... TArgs> JavaClass(const JavaClassDef& in_javaClassDef, TArgs&&... in_args);\n            //------------------------------------------------------------------------------\n            /// Constructor. Creates the java class with an already\n            /// instantiated object and prepares the methods so that they can be called.\n            ///\n            /// The class and all methods will be checked to ensure they exist.\n            ///\n            /// @author HMcLaughlin\n            ///\n            /// @param in_object - Object instance whose type is defined by in_javaClassDef\n            /// @param in_javaClassDef - The definition for this java class.\n            //------------------------------------------------------------------------------\n            JavaClass(jobject in_object, const JavaClassDef& in_javaClassDef);\n            //------------------------------------------------------------------------------\n            /// Calls a void java method.\n            ///\n            /// The method will be checked to ensure the method type is correct. Exceptions\n            /// thrown from Java are treated as fatal errors and the application will be\n            /// terminated.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param in_methodName - The name of the method to call.\n            /// @param ... - The arguments to the method.\n            //------------------------------------------------------------------------------\n            template <typename... TArgs> void CallVoidMethod(const std::string& in_methodName, TArgs&&... in_args) const;\n            //------------------------------------------------------------------------------\n            /// Calls a boolean java method.\n            ///\n            /// The method will be checked to ensure the method type is correct. Exceptions\n            /// thrown from Java are treated as fatal errors and the application will be\n            /// terminated.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param in_methodName - The name of the method to call.\n            /// @param ... - The arguments to the method.\n            //------------------------------------------------------------------------------\n            template <typename... TArgs> bool CallBoolMethod(const std::string& in_methodName, TArgs&&... in_args) const;\n            //------------------------------------------------------------------------------\n            /// Calls a byte java method.\n            ///\n            /// The method will be checked to ensure the method type is correct. Exceptions\n            /// thrown from Java are treated as fatal errors and the application will be\n            /// terminated.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param in_methodName - The name of the method to call.\n            /// @param ... - The arguments to the method.\n            //------------------------------------------------------------------------------\n            template <typename... TArgs> u8 CallByteMethod(const std::string& in_methodName, TArgs&&... in_args) const;\n            //------------------------------------------------------------------------------\n            /// Calls a char java method.\n            ///\n            /// The method will be checked to ensure the method type is correct. Exceptions\n            /// thrown from Java are treated as fatal errors and the application will be\n            /// terminated.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param in_methodName - The name of the method to call.\n            /// @param ... - The arguments to the method.\n            //------------------------------------------------------------------------------\n            template <typename... TArgs> u16 CallCharMethod(const std::string& in_methodName, TArgs&&... in_args) const;\n            //------------------------------------------------------------------------------\n            /// Calls a short java method.\n            ///\n            /// The method will be checked to ensure the method type is correct. Exceptions\n            /// thrown from Java are treated as fatal errors and the application will be\n            /// terminated.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param in_methodName - The name of the method to call.\n            /// @param ... - The arguments to the method.\n            //------------------------------------------------------------------------------\n            template <typename... TArgs> s16 CallShortMethod(const std::string& in_methodName, TArgs&&... in_args) const;\n            //------------------------------------------------------------------------------\n            /// Calls an int java method.\n            ///\n            /// The method will be checked to ensure the method type is correct. Exceptions\n            /// thrown from Java are treated as fatal errors and the application will be\n            /// terminated.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param in_methodName - The name of the method to call.\n            /// @param ... - The arguments to the method.\n            //------------------------------------------------------------------------------\n            template <typename... TArgs> s32 CallIntMethod(const std::string& in_methodName, TArgs&&... in_args) const;\n            //------------------------------------------------------------------------------\n            /// Calls a long java method.\n            ///\n            /// The method will be checked to ensure the method type is correct. Exceptions\n            /// thrown from Java are treated as fatal errors and the application will be\n            /// terminated.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param in_methodName - The name of the method to call.\n            /// @param ... - The arguments to the method.\n            //------------------------------------------------------------------------------\n            template <typename... TArgs> s64 CallLongMethod(const std::string& in_methodName, TArgs&&... in_args) const;\n            //------------------------------------------------------------------------------\n            /// Calls a float java method.\n            ///\n            /// The method will be checked to ensure the method type is correct. Exceptions\n            /// thrown from Java are treated as fatal errors and the application will be\n            /// terminated.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param in_methodName - The name of the method to call.\n            /// @param ... - The arguments to the method.\n            //------------------------------------------------------------------------------\n            template <typename... TArgs> f32 CallFloatMethod(const std::string& in_methodName, TArgs&&... in_args) const;\n            //------------------------------------------------------------------------------\n            /// Calls a double java method.\n            ///\n            /// The method will be checked to ensure the method type is correct. Exceptions\n            /// thrown from Java are treated as fatal errors and the application will be\n            /// terminated.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param in_methodName - The name of the method to call.\n            /// @param ... - The arguments to the method.\n            //------------------------------------------------------------------------------\n            template <typename... TArgs> f64 CallDoubleMethod(const std::string& in_methodName, TArgs&&... in_args) const;\n            //------------------------------------------------------------------------------\n            /// Calls an object java method.\n            ///\n            /// The method will be checked to ensure the method type is correct. Exceptions\n            /// thrown from Java are treated as fatal errors and the application will be\n            /// terminated.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param in_methodName - The name of the method to call.\n            /// @param ... - The arguments to the method.\n            //------------------------------------------------------------------------------\n            template <typename... TArgs> jobject CallObjectMethod(const std::string& in_methodName, TArgs&&... in_args) const;\n            //------------------------------------------------------------------------------\n            /// Calls an string java method. This is a special case of CallObjectMethod()\n            ///\n            /// The method will be checked to ensure the method type is correct. Exceptions\n            /// thrown from Java are treated as fatal errors and the application will be\n            /// terminated.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param in_methodName - The name of the method to call.\n            /// @param ... - The arguments to the method.\n            //------------------------------------------------------------------------------\n            template <typename... TArgs> std::string CallStringMethod(const std::string& in_methodName, TArgs&&... in_args) const;\n            //------------------------------------------------------------------------------\n            /// Returns the java object for this\n            ///\n            /// @author HMcLaughlin\n            ///\n            /// @return Java object\n            //------------------------------------------------------------------------------\n            jobject GetJavaObject() const;\n            //------------------------------------------------------------------------------\n            /// Gets the class name\n            ///\n            /// @author HMcLaughlin\n            ///\n            /// @return Class Name of the java def\n            //------------------------------------------------------------------------------\n            const std::string& GetClassName() const;\n            //------------------------------------------------------------------------------\n            /// Destructor.\n            ///\n            /// @author Ian Copland\n            //------------------------------------------------------------------------------\n            ~JavaClass();\n\n        private:\n            //------------------------------------------------------------------------------\n            /// A struct containing information on a single Java method.\n            ///\n            /// @author Ian Copland\n            //------------------------------------------------------------------------------\n            struct MethodInfo\n            {\n                jmethodID m_methodId = nullptr;\n                JavaMethodSignature::ReturnType m_returnType = JavaMethodSignature::ReturnType::k_void;\n                u32 m_numArguments = 0;\n            };\n            //------------------------------------------------------------------------------\n            /// Finds the method with the given name and performs some checks to mitigate\n            /// mistakes when calling the JNI. This includes that the method has the\n            /// correct return type and has the correct number of arguments.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @return The method info for the given name, type and number of arguments.\n            ///\n            /// @param in_methodName - The name of the method.\n            /// @param in_returnType - The type of the method.\n            /// @param in_numArguments - The number of arguments the method should have.\n            ///\n            /// @return The method info.\n            //------------------------------------------------------------------------------\n            jmethodID GetMethodId(const std::string& in_methodName, JavaMethodSignature::ReturnType in_returnType, u32 in_numArguments) const;\n\n            std::string m_className;\n            jobject m_javaObject = nullptr;\n            std::unordered_map<std::string, MethodInfo> m_methods;\n\t\t};\n        //------------------------------------------------------------------------------\n        //------------------------------------------------------------------------------\n        template <typename... TArgs> JavaClass::JavaClass(const JavaClassDef& in_javaClassDef, TArgs&&... in_args)\n        {\n            auto jvm = JavaVirtualMachine::Get();\n            auto environment = JavaVirtualMachine::Get()->GetJNIEnvironment();\n\n            //Get the class\n            m_className = in_javaClassDef.GetClassName();\n            jclass jClass = jvm->FindClass(m_className);\n\n            CS_ASSERT(jClass != nullptr, \"Could not find Java class: '\" + m_className + \"'\");\n\n            //create an instance of the class\n            CS_ASSERT(JavaMethodSignature::CalcReturnType(in_javaClassDef.GetConstructorSignature()) == JavaMethodSignature::ReturnType::k_void, \"Cannot call constructor for Java class '\" + m_className + \"' because a non-void return type was specified.\");\n            CS_ASSERT(JavaMethodSignature::CalcNumArguments(in_javaClassDef.GetConstructorSignature()) == sizeof...(TArgs), \"Cannot call constructor for Java class '\" + m_className + \"' because an incorrect number of arguments were supplied.\");\n\n            jmethodID jConstructor = environment->GetMethodID(jClass, \"<init>\", in_javaClassDef.GetConstructorSignature().c_str());\n            CS_ASSERT(jConstructor != nullptr, \"Could not find constructor with signature '\" + in_javaClassDef.GetConstructorSignature()+ \"' in java class '\" + m_className + \"'\");\n            jobject jClassInstance = environment->NewObject(jClass, jConstructor, std::forward<TArgs>(in_args)...);\n\n            JavaUtils::CheckJavaExceptions(\"A java exception occurred during construction of Java class: '\" + m_className + \"'\");\n            CS_ASSERT(jClassInstance != nullptr, \"Could not create instance of Java class: '\" + m_className + \"'\");\n\n            m_javaObject = environment->NewGlobalRef(jClassInstance);\n\n            //setup the method references\n            for (const auto& method : in_javaClassDef.GetMethods())\n            {\n                CS_ASSERT(m_methods.find(method.first) == m_methods.end(), \"Method '\" + method.first + \"' has already been added to Java class '\" + m_className + \"'\");\n\n                MethodInfo info;\n                info.m_returnType = JavaMethodSignature::CalcReturnType(method.second);\n                info.m_numArguments = JavaMethodSignature::CalcNumArguments(method.second);\n                info.m_methodId = environment->GetMethodID(jClass, method.first.c_str(), method.second.c_str());\n\n                CS_ASSERT(info.m_methodId != nullptr, \"Could not find method '\" + method.first + \"' in Java Class '\" + m_className + \"'\");\n\n                m_methods.emplace(method.first, info);\n            }\n\n            environment->DeleteLocalRef(jClassInstance);\n            environment->DeleteLocalRef(jClass);\n        }\n        //------------------------------------------------------------------------------\n        //------------------------------------------------------------------------------\n        template <typename... TArgs> void JavaClass::CallVoidMethod(const std::string& in_methodName, TArgs&&... in_args) const\n        {\n            auto environment = JavaVirtualMachine::Get()->GetJNIEnvironment();\n            auto methodId = GetMethodId(in_methodName, JavaMethodSignature::ReturnType::k_void, sizeof...(TArgs));\n\n            environment->CallVoidMethod(m_javaObject, methodId, std::forward<TArgs>(in_args)...);\n            JavaUtils::CheckJavaExceptions(\"An exception was thrown while calling method '\" + in_methodName + \"' in Java class '\" + m_className + \"'.\");\n        }\n        //------------------------------------------------------------------------------\n        //------------------------------------------------------------------------------\n        template <typename... TArgs> bool JavaClass::CallBoolMethod(const std::string& in_methodName, TArgs&&... in_args) const\n        {\n            auto environment = JavaVirtualMachine::Get()->GetJNIEnvironment();\n            auto methodId = GetMethodId(in_methodName, JavaMethodSignature::ReturnType::k_bool, sizeof...(TArgs));\n\n            auto output = environment->CallBooleanMethod(m_javaObject, methodId, std::forward<TArgs>(in_args)...);\n            JavaUtils::CheckJavaExceptions(\"An exception was thrown while calling method '\" + in_methodName + \"' in Java class '\" + m_className + \"'.\");\n\n            return output;\n        }\n        //------------------------------------------------------------------------------\n        //------------------------------------------------------------------------------\n        template <typename... TArgs> u8 JavaClass::CallByteMethod(const std::string& in_methodName, TArgs&&... in_args) const\n        {\n            auto environment = JavaVirtualMachine::Get()->GetJNIEnvironment();\n            auto methodId = GetMethodId(in_methodName, JavaMethodSignature::ReturnType::k_byte, sizeof...(TArgs));\n\n            auto output = environment->CallByteMethod(m_javaObject, methodId, std::forward<TArgs>(in_args)...);\n            JavaUtils::CheckJavaExceptions(\"An exception was thrown while calling method '\" + in_methodName + \"' in Java class '\" + m_className + \"'.\");\n\n            return output;\n        }\n        //------------------------------------------------------------------------------\n        //------------------------------------------------------------------------------\n        template <typename... TArgs> u16 JavaClass::CallCharMethod(const std::string& in_methodName, TArgs&&... in_args) const\n        {\n            auto environment = JavaVirtualMachine::Get()->GetJNIEnvironment();\n            auto methodId = GetMethodId(in_methodName, JavaMethodSignature::ReturnType::k_char, sizeof...(TArgs));\n\n            auto output = environment->CallCharMethod(m_javaObject, methodId, std::forward<TArgs>(in_args)...);\n            JavaUtils::CheckJavaExceptions(\"An exception was thrown while calling method '\" + in_methodName + \"' in Java class '\" + m_className + \"'.\");\n\n            return output;\n        }\n        //------------------------------------------------------------------------------\n        //------------------------------------------------------------------------------\n        template <typename... TArgs> s16 JavaClass::CallShortMethod(const std::string& in_methodName, TArgs&&... in_args) const\n        {\n            auto environment = JavaVirtualMachine::Get()->GetJNIEnvironment();\n            auto methodId = GetMethodId(in_methodName, JavaMethodSignature::ReturnType::k_short, sizeof...(TArgs));\n\n            auto output = environment->CallShortMethod(m_javaObject, methodId, std::forward<TArgs>(in_args)...);\n            JavaUtils::CheckJavaExceptions(\"An exception was thrown while calling method '\" + in_methodName + \"' in Java class '\" + m_className + \"'.\");\n\n            return output;\n        }\n        //------------------------------------------------------------------------------\n        //------------------------------------------------------------------------------\n        template <typename... TArgs> s32 JavaClass::CallIntMethod(const std::string& in_methodName, TArgs&&... in_args) const\n        {\n            auto environment = JavaVirtualMachine::Get()->GetJNIEnvironment();\n            auto methodId = GetMethodId(in_methodName, JavaMethodSignature::ReturnType::k_int, sizeof...(TArgs));\n\n            auto output = environment->CallIntMethod(m_javaObject, methodId, std::forward<TArgs>(in_args)...);\n            JavaUtils::CheckJavaExceptions(\"An exception was thrown while calling method '\" + in_methodName + \"' in Java class '\" + m_className + \"'.\");\n\n            return output;\n        }\n        //------------------------------------------------------------------------------\n        //------------------------------------------------------------------------------\n        template <typename... TArgs> s64 JavaClass::CallLongMethod(const std::string& in_methodName, TArgs&&... in_args) const\n        {\n            auto environment = JavaVirtualMachine::Get()->GetJNIEnvironment();\n            auto methodId = GetMethodId(in_methodName, JavaMethodSignature::ReturnType::k_long, sizeof...(TArgs));\n\n            auto output = environment->CallLongMethod(m_javaObject, methodId, std::forward<TArgs>(in_args)...);\n            JavaUtils::CheckJavaExceptions(\"An exception was thrown while calling method '\" + in_methodName + \"' in Java class '\" + m_className + \"'.\");\n\n            return output;\n        }\n        //------------------------------------------------------------------------------\n        //------------------------------------------------------------------------------\n        template <typename... TArgs> f32 JavaClass::CallFloatMethod(const std::string& in_methodName, TArgs&&... in_args) const\n        {\n            auto environment = JavaVirtualMachine::Get()->GetJNIEnvironment();\n            auto methodId = GetMethodId(in_methodName, JavaMethodSignature::ReturnType::k_float, sizeof...(TArgs));\n\n            f32 output = environment->CallFloatMethod(m_javaObject, methodId, std::forward<TArgs>(in_args)...);\n            JavaUtils::CheckJavaExceptions(\"An exception was thrown while calling method '\" + in_methodName + \"' in Java class '\" + m_className + \"'.\");\n\n            return output;\n        }\n        //------------------------------------------------------------------------------\n        //------------------------------------------------------------------------------\n        template <typename... TArgs> f64 JavaClass::CallDoubleMethod(const std::string& in_methodName, TArgs&&... in_args) const\n        {\n            auto environment = JavaVirtualMachine::Get()->GetJNIEnvironment();\n            auto methodId = GetMethodId(in_methodName, JavaMethodSignature::ReturnType::k_double, sizeof...(TArgs));\n\n            auto output = environment->CallDoubleMethod(m_javaObject, methodId, std::forward<TArgs>(in_args)...);\n            JavaUtils::CheckJavaExceptions(\"An exception was thrown while calling method '\" + in_methodName + \"' in Java class '\" + m_className + \"'.\");\n\n            return output;\n        }\n        //------------------------------------------------------------------------------\n        //------------------------------------------------------------------------------\n        template <typename... TArgs> jobject JavaClass::CallObjectMethod(const std::string& in_methodName, TArgs&&... in_args) const\n        {\n            auto environment = JavaVirtualMachine::Get()->GetJNIEnvironment();\n            auto methodId = GetMethodId(in_methodName, JavaMethodSignature::ReturnType::k_object, sizeof...(TArgs));\n\n            auto output = environment->CallObjectMethod(m_javaObject, methodId, std::forward<TArgs>(in_args)...);\n            JavaUtils::CheckJavaExceptions(\"An exception was thrown while calling method '\" + in_methodName + \"' in Java class '\" + m_className + \"'.\");\n\n            return output;\n        }\n        //------------------------------------------------------------------------------\n        //------------------------------------------------------------------------------\n        template <typename... TArgs> std::string JavaClass::CallStringMethod(const std::string& in_methodName, TArgs&&... in_args) const\n        {\n            auto environment = JavaVirtualMachine::Get()->GetJNIEnvironment();\n            auto methodId = GetMethodId(in_methodName, JavaMethodSignature::ReturnType::k_string, sizeof...(TArgs));\n\n            auto jString = static_cast<jstring>(environment->CallObjectMethod(m_javaObject, methodId, std::forward<TArgs>(in_args)...));\n            JavaUtils::CheckJavaExceptions(\"An exception was thrown while calling method '\" + in_methodName + \"' in Java class '\" + m_className + \"'.\");\n\n            std::string output = JavaUtils::CreateSTDStringFromJString(jString);\n            environment->DeleteLocalRef(jString);\n\n            return output;\n        }\n\t}\n}\n\n#endif\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/JNI/Core/Java/JavaClassDef.cpp",
    "content": "//\n//  JavaClassDef.cpp\n//  ChilliSource\n//  Created by Ian Copland on 21/04/2015.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2015 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n\n#include <CSBackend/Platform/Android/Main/JNI/Core/Java/JavaClassDef.h>\n\nnamespace CSBackend\n{\n\tnamespace Android\n\t{\n        //------------------------------------------------------------------------------\n        //------------------------------------------------------------------------------\n        JavaClassDef::JavaClassDef(const std::string& in_className, const std::string& in_constructorSignature)\n            : m_className(in_className), m_constructorSignature(in_constructorSignature)\n        {\n        }\n        //------------------------------------------------------------------------------\n        //------------------------------------------------------------------------------\n        void JavaClassDef::AddMethod(const std::string& in_methodName, const std::string& in_methodSignature)\n        {\n            CS_ASSERT((m_methods.find(in_methodName) == m_methods.end()), \"Cannot add method '\" + in_methodName + \"' to class definition '\" + m_className + \"' because the method name already exists.\");\n\n            m_methods.emplace(in_methodName, in_methodSignature);\n        }\n        //------------------------------------------------------------------------------\n        //------------------------------------------------------------------------------\n        const std::string& JavaClassDef::GetClassName() const\n        {\n            return m_className;\n        }\n        //------------------------------------------------------------------------------\n        //------------------------------------------------------------------------------\n        const std::string& JavaClassDef::GetConstructorSignature() const\n        {\n            return m_constructorSignature;\n        }\n        //------------------------------------------------------------------------------\n        //------------------------------------------------------------------------------\n        const JavaClassDef::MethodMap& JavaClassDef::GetMethods() const\n        {\n            return m_methods;\n        }\n\t}\n}\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/JNI/Core/Java/JavaClassDef.h",
    "content": "//\n//  JavaClassDef.h\n//  ChilliSource\n//  Created by Ian Copland on 21/04/2015.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2015 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n\n#ifndef _CSBACKEND_PLATFORM_ANDROID_MAIN_JNI_CORE_JAVA_JAVACLASSDEF_H_\n#define _CSBACKEND_PLATFORM_ANDROID_MAIN_JNI_CORE_JAVA_JAVACLASSDEF_H_\n\n#include <ChilliSource/ChilliSource.h>\n\n#include <CSBackend/Platform/Android/Main/JNI/ForwardDeclarations.h>\n\n#include <unordered_map>\n\nnamespace CSBackend\n{\n\tnamespace Android\n\t{\n\t\t//------------------------------------------------------------------------------\n\t\t/// Defines the class which will be instantiated, and the methods which will\n\t\t/// be accessible when using JavaClass.\n\t\t///\n\t\t/// Although JavaClass uses this for setup, it isn't retained, so it can be\n\t\t/// further modified and passed to additional JavaClass instances.\n\t\t///\n\t\t/// @author Ian Copland\n\t\t//------------------------------------------------------------------------------\n\t\tclass JavaClassDef final\n\t\t{\n\t\tpublic:\n\t\t    using MethodMap = std::unordered_map<std::string, std::string>;\n            //------------------------------------------------------------------------------\n            /// Constructor.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param in_className - The fully qualified name of the class this refers to.\n            //------------------------------------------------------------------------------\n            JavaClassDef(const std::string& in_className, const std::string& in_constructorSignature = \"()V\");\n            //------------------------------------------------------------------------------\n            /// Adds a new method definition. Note that multiple overloaded methods are\n            /// not supported.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param in_methodName - The name of the method.\n            /// @param in_methodSignature - The signature of the method. This is in the\n            /// form described in the JNI documentation.\n            //------------------------------------------------------------------------------\n            void AddMethod(const std::string& in_methodName, const std::string& in_methodSignature);\n            //------------------------------------------------------------------------------\n            /// @author Ian Copland\n            ///\n            /// @return The fully qualified class name.\n            //------------------------------------------------------------------------------\n            const std::string& GetClassName() const;\n            //------------------------------------------------------------------------------\n            /// @author Ian Copland\n            ///\n            /// @return The constructor method signature.\n            //------------------------------------------------------------------------------\n            const std::string& GetConstructorSignature() const;\n            //------------------------------------------------------------------------------\n            /// @author Ian Copland\n            ///\n            /// @return The map of methods names and signatures.\n            //------------------------------------------------------------------------------\n            const MethodMap& GetMethods() const;\n\n        private:\n            const std::string m_className;\n            const std::string m_constructorSignature;\n            MethodMap m_methods;\n\t\t};\n\t}\n}\n\n#endif\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/JNI/Core/Java/JavaInterface.cpp",
    "content": "//\n//  JavaInterface.cpp\n//  ChilliSource\n//  Created by Ian Copland on 09/08/2012.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2012 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n\n#include <CSBackend/Platform/Android/Main/JNI/Core/Java/JavaInterface.h>\n\n#include <CSBackend/Platform/Android/Main/JNI/Core/Java/JavaInterfaceManager.h>\n#include <CSBackend/Platform/Android/Main/JNI/Core/Java/JavaVirtualMachine.h>\n\nnamespace CSBackend\n{\n\tnamespace Android\n\t{\n\t\t//--------------------------------------------------------\n\t\t/// Constructor\n\t\t//--------------------------------------------------------\n\t\tIJavaInterface::IJavaInterface()\n\t\t:mpJavaObject(nullptr)\n\t\t{\n\t\t}\n\t\t//--------------------------------------------------------\n\t\t/// Destructor\n\t\t//--------------------------------------------------------\n\t\tIJavaInterface::~IJavaInterface()\n\t\t{\n\t\t\tif (mpJavaObject == nullptr)\n\t\t\t{\n\t\t\t\tJNIEnv* pEnv = JavaInterfaceManager::GetSingletonPtr()->GetJNIEnvironmentPtr();\n\n\t\t\t\tpEnv->DeleteGlobalRef(mpJavaObject);\n\t\t\t}\n\t\t}\n\t\t//--------------------------------------------------------\n\t\t/// Create Native Interface\n\t\t//--------------------------------------------------------\n\t\tvoid IJavaInterface::CreateNativeInterface(const std::string& instrInterfaceName)\n\t\t{\n\t\t\tif (mpJavaObject == nullptr)\n\t\t\t{\n\t\t\t\tJNIEnv* pEnv = JavaInterfaceManager::GetSingletonPtr()->GetJNIEnvironmentPtr();\n\n\t\t\t\t//get the class type\n\t\t\t\tjclass jClassType = JavaVirtualMachine::Get()->FindClass(instrInterfaceName);\n\t\t\t\tif (jClassType == nullptr)\n\t\t\t\t{\n\t\t\t\t\tjthrowable exception = pEnv->ExceptionOccurred();\n\t\t\t\t\tif (exception != nullptr)\n\t\t\t\t\t{\n\t\t\t\t\t\tpEnv->ExceptionDescribe();\n\t\t\t\t\t\tpEnv->ExceptionClear();\n\t\t\t\t\t}\n\n\t\t\t\t\tCS_LOG_FATAL(\"Cannot find native interface class '\" + instrInterfaceName + \"'\");\n\t\t\t\t}\n\n\t\t\t\t//get the class instance\n\t\t\t\tjmethodID jConstructor = pEnv->GetMethodID(jClassType, \"<init>\", \"()V\");\n\t\t\t\tjobject jClassInstance = pEnv->NewObject(jClassType, jConstructor);\n\t\t\t\tif (jClassInstance == nullptr)\n\t\t\t\t{\n\t\t\t\t\tjthrowable exception = pEnv->ExceptionOccurred();\n\t\t\t\t\tif (exception != nullptr)\n\t\t\t\t\t{\n\t\t\t\t\t\tpEnv->ExceptionDescribe();\n\t\t\t\t\t\tpEnv->ExceptionClear();\n\t\t\t\t\t}\n\n\t\t\t\t\tCS_LOG_FATAL(\"Cannot create native interface instance '\" + instrInterfaceName + \"'\");\n\t\t\t\t}\n\n\t\t\t\t//create a global reference to the instance\n\t\t\t\tmpJavaObject = pEnv->NewGlobalRef(jClassInstance);\n\n\t\t\t\t//delete all the local references\n\t\t\t\tpEnv->DeleteLocalRef(jClassType);\n\t\t\t\tpEnv->DeleteLocalRef(jClassInstance);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tCS_LOG_FATAL(\"Cannot create native interface \" + instrInterfaceName + \", as it has already been created!\");\n\t\t\t}\n\t\t}\n\t\t//--------------------------------------------------------\n\t\t/// Create Method Reference\n\t\t//--------------------------------------------------------\n\t\tvoid IJavaInterface::CreateMethodReference(const std::string& instrMethodName, const std::string& instrMethodSignature)\n\t\t{\n\t\t\tif (mpJavaObject != nullptr)\n\t\t\t{\n\t\t\t\tJNIEnv* pEnv = JavaInterfaceManager::GetSingletonPtr()->GetJNIEnvironmentPtr();\n\n\t\t\t\t//get the method reference\n\t\t\t\tjclass jClassType = pEnv->GetObjectClass(mpJavaObject);\n\t\t\t\tjmethodID jMethod = pEnv->GetMethodID(jClassType, instrMethodName.c_str(), instrMethodSignature.c_str());\n\n\t\t\t\tif (jMethod != nullptr)\n\t\t\t\t{\n\t\t\t\t\t//add it to the method list\n\t\t\t\t\tif (mMethodReferenceMap.find(instrMethodName) == mMethodReferenceMap.end())\n\t\t\t\t\t{\n\t\t\t\t\t\tmMethodReferenceMap[instrMethodName] = jMethod;\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tCS_LOG_FATAL(\"Could not add method reference '\" + instrMethodName + \"' - method name already exists.\");\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tCS_LOG_FATAL(\"Could not create method reference '\" + instrMethodName + \"'\");\n\t\t\t\t}\n\n\t\t\t\t//delete local references\n\t\t\t\tpEnv->DeleteLocalRef(jClassType);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tCS_LOG_FATAL(\"Cannot create method reference as the native interface has not been created!\");\n\t\t\t}\n\t\t}\n\t\t//--------------------------------------------------------\n\t\t/// Get Java Object\n\t\t//--------------------------------------------------------\n\t\tjobject IJavaInterface::GetJavaObject() const\n\t\t{\n\t\t\treturn mpJavaObject;\n\t\t}\n\t\t//--------------------------------------------------------\n\t\t/// Get Method ID\n\t\t//--------------------------------------------------------\n\t\tjmethodID IJavaInterface::GetMethodID(const std::string& instrMethodName) const\n\t\t{\n\t\t\tstd::map<std::string, jmethodID>::const_iterator it = mMethodReferenceMap.find(instrMethodName);\n\t\t\tif (it != mMethodReferenceMap.end())\n\t\t\t{\n\t\t\t\treturn it->second;\n\t\t\t}\n\n\t\t\tCS_LOG_FATAL(\"Could not find method reference '\" + instrMethodName + \"', was it created?\");\n\t\t\treturn nullptr;\n\t\t}\n\t}\n}\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/JNI/Core/Java/JavaInterface.h",
    "content": "//\n//  JavaInterface.h\n//  ChilliSource\n//  Created by Ian Copland on 09/08/2012.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2012 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n\n#ifndef _CHILLISOURCE_PLATFORM_ANDROID_JAVAINTERFACE_JAVAINTERFACE_H_\n#define _CHILLISOURCE_PLATFORM_ANDROID_JAVAINTERFACE_JAVAINTERFACE_H_\n\n#include <CSBackend/Platform/Android/Main/JNI/ForwardDeclarations.h>\n#include <ChilliSource/Core/Base/QueryableInterface.h>\n\n#include <jni.h>\n\n#include <map>\n\nnamespace CSBackend\n{\n\tnamespace Android\n\t{\n\t\t//========================================================\n\t\t/// Java Interface Manager\n\t\t///\n\t\t/// Handles all of the java interfaces and provides an\n\t\t/// interface to access them.\n\t\t///\n\t\t/// This is deprecated in favour of JavaClass.\n\t\t//========================================================\n\t\tclass IJavaInterface : public ChilliSource::QueryableInterface\n\t\t{\n\t\tpublic:\n\t\t\t//--------------------------------------------------------\n\t\t\t/// Constructor\n\t\t\t//--------------------------------------------------------\n\t\t\tIJavaInterface();\n\t\t\t//--------------------------------------------------------\n\t\t\t/// Destructor\n\t\t\t//--------------------------------------------------------\n\t\t\tvirtual ~IJavaInterface();\n\t\tprotected:\n\t\t\t//--------------------------------------------------------\n\t\t\t/// Create Native Interface\n\t\t\t///\n\t\t\t/// Creates the Native Interface on the Java side.\n\t\t\t///\n\t\t\t/// @param the name of the native interface.\n\t\t\t//--------------------------------------------------------\n\t\t\tvoid CreateNativeInterface(const std::string& instrInterfaceName);\n\t\t\t//--------------------------------------------------------\n\t\t\t/// Create Method Reference\n\t\t\t///\n\t\t\t/// Creates a reference to a method in the created native\n\t\t\t/// interface.\n\t\t\t///\n\t\t\t/// @param the name of the native interface.\n\t\t\t//--------------------------------------------------------\n\t\t\tvoid CreateMethodReference(const std::string& instrMethodName, const std::string& instrMethodSignature);\n\t\t\t//--------------------------------------------------------\n\t\t\t/// Get Java Object\n\t\t\t///\n\t\t\t/// @return the Java Object\n\t\t\t//--------------------------------------------------------\n\t\t\tjobject GetJavaObject() const;\n\t\t\t//--------------------------------------------------------\n\t\t\t/// Get Method ID\n\t\t\t///\n\t\t\t/// @param the method name\n\t\t\t/// @return the method id.\n\t\t\t//--------------------------------------------------------\n\t\t\tjmethodID GetMethodID(const std::string& instrMethodName) const;\n\t\tprivate:\n\n\t\t\tjobject mpJavaObject;\n\t\t\tstd::map<std::string, jmethodID> mMethodReferenceMap;\n\t\t};\n\t}\n}\n\n#endif\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/JNI/Core/Java/JavaInterfaceManager.cpp",
    "content": "//\n//  JavaInterfaceManager.cpp\n//  ChilliSource\n//  Created by Ian Copland on 08/08/2012.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2012 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n\n#include <CSBackend/Platform/Android/Main/JNI/Core/Java/JavaInterfaceManager.h>\n\nnamespace CSBackend\n{\n\tnamespace Android\n\t{\n\t\tJavaInterfaceManager* JavaInterfaceManager::mpJavaInterfaceManagerSingleton = nullptr;\n\n\t\t//-------------------------------------------------------\n\t\t/// Get Singleton Ptr\n\t\t//-------------------------------------------------------\n\t\tJavaInterfaceManager* JavaInterfaceManager::GetSingletonPtr()\n\t\t{\n\t\t\tif (mpJavaInterfaceManagerSingleton == nullptr)\n\t\t\t{\n\t\t\t\tmpJavaInterfaceManagerSingleton = new JavaInterfaceManager();\n\t\t\t}\n\n\t\t\treturn mpJavaInterfaceManagerSingleton;\n\t\t}\n\t\t//--------------------------------------------------------\n\t\t/// Get Singleton\n\t\t//--------------------------------------------------------\n\t\tJavaInterfaceManager& JavaInterfaceManager::GetSingleton()\n\t\t{\n\t\t\treturn *GetSingletonPtr();\n\t\t}\n\t\t//--------------------------------------------------------\n\t\t/// Constructor\n\t\t//--------------------------------------------------------\n\t\tJavaInterfaceManager::JavaInterfaceManager()\n\t\t : mpJavaVM(nullptr)\n\t\t{\n\t\t}\n\t\t//--------------------------------------------------------\n\t\t/// Initialise\n\t\t//--------------------------------------------------------\n\t\tvoid JavaInterfaceManager::Initialise(JavaVM* inpJavaVM)\n\t\t{\n\t\t\tmpJavaVM = inpJavaVM;\n\t\t}\n\t\t//--------------------------------------------------------\n\t\t/// Get Java VM\n\t\t//--------------------------------------------------------\n\t\tJavaVM* JavaInterfaceManager::GetJavaVM()\n\t\t{\n\t\t\treturn mpJavaVM;\n\t\t}\n\t\t//--------------------------------------------------------\n\t\t/// Get JNI Environment Ptr\n\t\t//--------------------------------------------------------\n\t\tJNIEnv* JavaInterfaceManager::GetJNIEnvironmentPtr()\n\t\t{\n\t\t\tif (mpJavaVM != nullptr)\n\t\t\t{\n\t\t\t\tJNIEnv* env;\n\t\t\t\tmpJavaVM->AttachCurrentThread(&env, nullptr);\n\t\t\t\treturn env;\n\t\t\t}\n\n\t\t\treturn nullptr;\n\t\t}\n\t\t//--------------------------------------------------------\n\t\t/// Add Java Interface\n\t\t//--------------------------------------------------------\n\t\tvoid JavaInterfaceManager::AddJavaInterface(IJavaInterfaceSPtr inpJavaInterface)\n\t\t{\n\t\t\tmJavaInterfaces.push_back(inpJavaInterface);\n\t\t}\n\t\t//--------------------------------------------------------\n\t\t/// Get Java Interface\n\t\t//--------------------------------------------------------\n\t\tIJavaInterfaceSPtr JavaInterfaceManager::GetJavaInterface(ChilliSource::InterfaceIDType inInterfaceID)\n\t\t{\n\t\t\tfor (std::vector<IJavaInterfaceSPtr>::const_iterator it = mJavaInterfaces.begin(); it != mJavaInterfaces.end(); ++it)\n\t\t\t{\n\t\t\t\tif ((*it)->IsA(inInterfaceID))\n\t\t\t\t{\n\t\t\t\t\treturn (*it);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tCS_LOG_WARNING(\"JavaInterfaceManager cannot find a JavaInterface with the requested interface.\");\n\t\t\treturn IJavaInterfaceSPtr();\n\t\t}\n\t\t//--------------------------------------------------------\n\t\t/// Get Java Interfaces\n\t\t//--------------------------------------------------------\n\t\tvoid JavaInterfaceManager::GetJavaInterfaces(ChilliSource::InterfaceIDType inInterfaceID, std::vector<IJavaInterfaceSPtr>& outJavaInterfaces)\n\t\t{\n\t\t\toutJavaInterfaces.clear();\n\t\t\tfor (std::vector<IJavaInterfaceSPtr>::const_iterator it = mJavaInterfaces.begin(); it != mJavaInterfaces.end(); ++it)\n\t\t\t{\n\t\t\t\tif ((*it)->IsA(inInterfaceID))\n\t\t\t\t{\n\t\t\t\t\toutJavaInterfaces.push_back((*it));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t//--------------------------------------------------------\n\t\t/// Destructor\n\t\t//--------------------------------------------------------\n\t\tJavaInterfaceManager::~JavaInterfaceManager()\n\t\t{\n\t\t\tmJavaInterfaces.clear();\n\t\t}\n\t}\n}\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/JNI/Core/Java/JavaInterfaceManager.h",
    "content": "//\n//  JavaInterfaceManager.h\n//  ChilliSource\n//  Created by Ian Copland on 08/08/2012.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2012 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n\n#ifndef _CHILLISOURCE_PLATFORM_ANDROID_JAVAINTERFACE_JAVAINTERFACEMANAGER_H_\n#define _CHILLISOURCE_PLATFORM_ANDROID_JAVAINTERFACE_JAVAINTERFACEMANAGER_H_\n\n#include <CSBackend/Platform/Android/Main/JNI/ForwardDeclarations.h>\n#include <CSBackend/Platform/Android/Main/JNI/Core/Java/JavaInterface.h>\n\n#include <jni.h>\n\nnamespace CSBackend\n{\n\tnamespace Android\n\t{\n\t\t//========================================================\n\t\t/// Java Interface Manager\n\t\t///\n\t\t/// Handles all of the java interfaces and provides an\n\t\t/// interface to access them.\n\t\t///\n\t\t/// This is deprecated in favour of JavaClass and\n\t\t/// JavaVirtualMachine\n\t\t//========================================================\n\t\tclass JavaInterfaceManager\n\t\t{\n\t\tpublic:\n\t\t\t//--------------------------------------------------------\n\t\t\t/// Get Singleton Ptr\n\t\t\t///\n\t\t\t/// @return a pointer to the singleton instance.\n\t\t\t//--------------------------------------------------------\n\t\t\tstatic JavaInterfaceManager* GetSingletonPtr();\n\t\t\t//--------------------------------------------------------\n\t\t\t/// Get Singleton\n\t\t\t///\n\t\t\t/// @return a reference to the singleton instance.\n\t\t\t//--------------------------------------------------------\n\t\t\tstatic JavaInterfaceManager& GetSingleton();\n\t\t\t//--------------------------------------------------------\n\t\t\t/// Initialise\n\t\t\t///\n\t\t\t/// Initialises the Java Interface Manager\n\t\t\t///\n\t\t\t/// @param The JVM.\n\t\t\t//--------------------------------------------------------\n\t\t\tvoid Initialise(JavaVM* inpJavaVM);\n\t\t\t//--------------------------------------------------------\n\t\t\t/// Get Java VM\n\t\t\t///\n\t\t\t/// @return The Java VM.\n\t\t\t//--------------------------------------------------------\n\t\t\tJavaVM* GetJavaVM();\n\t\t\t//--------------------------------------------------------\n\t\t\t/// Get JNI Environment Ptr\n\t\t\t///\n\t\t\t///\treturns the jni enviroment pointer for the current\n\t\t\t/// thread. The value returned from this should NOT be stored\n\t\t\t/// as global or member data, as this will break thread safety\n\t\t\t///\n\t\t\t/// @return returns a pointer to the jni environment.\n\t\t\t//--------------------------------------------------------\n\t\t\tJNIEnv* GetJNIEnvironmentPtr();\n\t\t\t//--------------------------------------------------------\n\t\t\t/// Add Java Interface\n\t\t\t///\n\t\t\t/// Adds a new Java Interface. This should be called on\n\t\t\t/// creation of the system that uses the java interface.\n\t\t\t///\n\t\t\t/// @param The java interface.\n\t\t\t//--------------------------------------------------------\n\t\t\tvoid AddJavaInterface(IJavaInterfaceSPtr inpJavaInterface);\n\t\t\t//--------------------------------------------------------\n\t\t\t/// Get Java Interface\n\t\t\t///\n\t\t\t/// Looks for a java interface that implements the given interface.\n\t\t\t///\n\t\t\t/// @param The type ID of the java interface you wish to implement\n\t\t\t/// @return Java Interface that implements the given interface or nullptr if none\n\t\t\t//--------------------------------------------------------\n\t\t\tIJavaInterfaceSPtr GetJavaInterface(ChilliSource::InterfaceIDType inInterfaceID);\n\t\t\t//--------------------------------------------------------\n\t\t\t/// Get Java Interface\n\t\t\t///\n\t\t\t/// Looks for a java interface that implements the given interface.\n\t\t\t///\n\t\t\t/// @return Java Interface that implements the given interface or nullptr if none\n\t\t\t//--------------------------------------------------------\n\t\t\ttemplate <typename T> std::shared_ptr<T> GetJavaInterface();\n\t\t\t//--------------------------------------------------------\n\t\t\t/// Get Java Interface\n\t\t\t///\n\t\t\t/// Looks for a java interface that implements the given interface.\n\t\t\t///\n\t\t\t/// @return Java Interface that implements the given interface or nullptr if none\n\t\t\t//--------------------------------------------------------\n\t\t\ttemplate <typename T, typename U> std::shared_ptr<T> GetJavaInterface();\n\t\t\t//--------------------------------------------------------\n\t\t\t/// Get Java Interfaces\n\t\t\t///\n\t\t\t/// Looks for Java Interfaces that implement the given interface\n\t\t\t/// and fills an array with them.\n\t\t\t///\n\t\t\t/// @param The type ID of the Java Interface you wish to implement\n\t\t\t/// @param OUT: The array of java interfaces.\n\t\t\t//--------------------------------------------------------\n\t\t\tvoid GetJavaInterfaces(ChilliSource::InterfaceIDType inInterfaceID, std::vector<IJavaInterfaceSPtr>& outJavaInterfaces);\n\t\t\t//--------------------------------------------------------\n\t\t\t/// Get Java Interfaces\n\t\t\t///\n\t\t\t/// Looks for Java Interfaces that implement the given interface\n\t\t\t/// and fills an array with them.\n\t\t\t///\n\t\t\t/// @param OUT: The array of java interfaces.\n\t\t\t//--------------------------------------------------------\n\t\t\ttemplate <typename T> void GetJavaInterfaces(std::vector<std::shared_ptr<T> >& outJavaInterfaces);\n\t\t\t//--------------------------------------------------------\n\t\t\t/// Destructor\n\t\t\t//--------------------------------------------------------\n\t\t\t~JavaInterfaceManager();\n\t\tprivate:\n\t\t\t//--------------------------------------------------------\n\t\t\t/// Constructor\n\t\t\t//--------------------------------------------------------\n\t\t\tJavaInterfaceManager();\n\n\t\t\tstatic JavaInterfaceManager* mpJavaInterfaceManagerSingleton;\n\t\t\tstd::vector<IJavaInterfaceSPtr> mJavaInterfaces;\n\t\t\tJavaVM* mpJavaVM;\n\t\t};\n\t\t//========================================================\n\t\t/// Templated Definitions\n\t\t//========================================================\n\t\t//--------------------------------------------------------\n\t\t/// Get Java Interface\n\t\t//--------------------------------------------------------\n\t\ttemplate <typename T> std::shared_ptr<T> JavaInterfaceManager::GetJavaInterface()\n\t\t{\n\t\t\tIJavaInterfaceSPtr pJavaInterface = GetJavaInterface(T::InterfaceID);\n\n\t\t\tif (pJavaInterface != nullptr)\n\t\t\t{\n\t\t\t\treturn std::static_pointer_cast<T>(pJavaInterface);\n\t\t\t}\n\n\t\t\treturn std::shared_ptr<T>();\n\t\t}\n\t\t//--------------------------------------------------------\n\t\t/// Get Java Interface\n\t\t//--------------------------------------------------------\n\t\ttemplate <typename T, typename U> std::shared_ptr<T> JavaInterfaceManager::GetJavaInterface()\n\t\t{\n\t\t\tIJavaInterfaceSPtr pJavaInterface = GetJavaInterface(U::InterfaceID);\n\n\t\t\tif (pJavaInterface != nullptr)\n\t\t\t{\n\t\t\t\treturn std::static_pointer_cast<T>(pJavaInterface);\n\t\t\t}\n\n\t\t\treturn std::shared_ptr<T>();\n\t\t}\n\t\t//--------------------------------------------------------\n\t\t/// Get Java Interfaces\n\t\t//--------------------------------------------------------\n\t\ttemplate <typename T> void JavaInterfaceManager::GetJavaInterfaces(std::vector<std::shared_ptr<T> >& outJavaInterfaces)\n\t\t{\n\t\t\tfor (size_t nJavaInterface = 0; nJavaInterface < mJavaInterfaces.size(); nJavaInterface++)\n\t\t\t{\n\t\t\t\tif (mJavaInterfaces[nJavaInterface]->IsA(T::InterfaceID))\n\t\t\t\t{\n\t\t\t\t\toutJavaInterfaces.push_back(std::static_pointer_cast<T>(mJavaInterfaces[nJavaInterface]));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\n#endif\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/JNI/Core/Java/JavaMethodSignature.cpp",
    "content": "//\n//  JavaMethodSignature.cpp\n//  ChilliSource\n//  Created by Ian Copland on 09/06/2015.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2015 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n\n#include <CSBackend/Platform/Android/Main/JNI/Core/Java/JavaMethodSignature.h>\n\n#include <regex>\n\nnamespace CSBackend\n{\n\tnamespace Android\n\t{\n\t\tnamespace JavaMethodSignature\n\t\t{\n\t\t\t//------------------------------------------------------------------------------\n\t\t\t//------------------------------------------------------------------------------\n\t\t\tReturnType CalcReturnType(const std::string& in_methodSignature)\n\t\t\t{\n                std::regex argsExpression(\"\\\\([a-zA-Z0-9/;\\\\[]*\\\\)\");\n                auto outputType = std::regex_replace(in_methodSignature, argsExpression, \"\");\n\n                if (outputType == \"V\")\n                {\n                    return ReturnType::k_void;\n                }\n                else if (outputType == \"Z\")\n                {\n                    return ReturnType::k_bool;\n                }\n                else if (outputType == \"B\")\n                {\n                    return ReturnType::k_byte;\n                }\n                else if (outputType == \"C\")\n                {\n                    return ReturnType::k_char;\n                }\n                else if (outputType == \"S\")\n                {\n                    return ReturnType::k_short;\n                }\n                else if (outputType == \"I\")\n                {\n                    return ReturnType::k_int;\n                }\n                else if (outputType == \"J\")\n                {\n                    return ReturnType::k_long;\n                }\n                else if (outputType == \"F\")\n                {\n                    return ReturnType::k_float;\n                }\n                else if (outputType == \"D\")\n                {\n                    return ReturnType::k_double;\n                }\n                else if (outputType == \"Ljava/lang/String;\")\n                {\n                    return ReturnType::k_string;\n                }\n                else\n                {\n                    std::regex objectExpression(\"L[a-zA-Z0-9/]*;\");\n                    std::regex primitiveArrayExpression(\"\\\\[[ZBCSIJFD]\");\n                    std::regex objectArrayExpression(\"\\\\[L[a-zA-Z0-9/]*;\");\n\n                    if (std::regex_match(outputType, objectExpression) == true || std::regex_match(outputType, primitiveArrayExpression) == true ||\n                        std::regex_match(outputType, objectArrayExpression) == true)\n                    {\n                        return ReturnType::k_object;\n                    }\n                }\n\n                CS_LOG_FATAL(\"Could not determine return type for JavaStaticClass method signature: '\" + in_methodSignature + \"'\");\n                return ReturnType::k_void;\n\t\t\t}\n\t\t\t//------------------------------------------------------------------------------\n\t\t\t//------------------------------------------------------------------------------\n\t\t\tu32 CalcNumArguments(const std::string& in_methodSignature)\n\t\t\t{\n                std::smatch match;\n                std::regex argsExpression(\"\\\\([a-zA-Z0-9/;\\\\[]*\\\\)\");\n                std::regex_search(in_methodSignature, match, argsExpression);\n\n                std::regex bracketsExpression(\"\\\\(|\\\\)\");\n                auto arguments = std::regex_replace(match.str(), bracketsExpression, \"\");\n\n                u32 count = 0;\n                bool isClassName = false;\n                for (auto character : arguments)\n                {\n                    if (isClassName == false)\n                    {\n                        if (character == 'Z' || character == 'B' || character == 'C' || character == 'S' || character == 'I' || character == 'J' || character == 'F' || character == 'D')\n                        {\n                            ++count;\n                        }\n                        else if (character == 'L')\n                        {\n                            isClassName = true;\n                        }\n                        else if (character != '[')\n                        {\n                            CS_LOG_FATAL(\"Could not calculate number of arguments for JavaStaticClass method signature '\" + in_methodSignature + \"' due to invalid character: '\" + character + \"'\");\n                        }\n                    }\n                    else if (character == ';')\n                    {\n                        isClassName = false;\n                        ++count;\n                    }\n                }\n\n                return count;\n\t\t\t}\n\t\t}\n\t}\n}\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/JNI/Core/Java/JavaMethodSignature.h",
    "content": "//\n//  JavaMethodSignature.h\n//  ChilliSource\n//  Created by Ian Copland on 09/06/2015.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2015 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n\n#ifndef _CSBACKEND_PLATFORM_ANDROID_MAIN_JNI_CORE_JAVA_JAVAMETHODSIGNATURE_H_\n#define _CSBACKEND_PLATFORM_ANDROID_MAIN_JNI_CORE_JAVA_JAVAMETHODSIGNATURE_H_\n\n#include <ChilliSource/ChilliSource.h>\n\n#include <CSBackend/Platform/Android/Main/JNI/ForwardDeclarations.h>\n\nnamespace CSBackend\n{\n\tnamespace Android\n\t{\n\t    //------------------------------------------------------------------------------\n\t    /// A collection of methods for working with JNI method signatures.  This\n\t    /// includes methods for calculating the number of parameters a signature has\n\t    /// and a means to calculate the return type.\n\t    ///\n\t    /// @author Ian Copland\n\t    //------------------------------------------------------------------------------\n\t\tnamespace JavaMethodSignature\n\t\t{\n            //------------------------------------------------------------------------------\n            /// An enum describing the various return types for methods which can be called\n            /// through JavaClass.\n            ///\n            /// @author Ian Copland\n            //------------------------------------------------------------------------------\n            enum class ReturnType\n            {\n                k_void,\n                k_bool,\n                k_byte,\n                k_char,\n                k_short,\n                k_int,\n                k_long,\n                k_float,\n                k_double,\n                k_object,\n                k_string\n            };\n\t\t\t//------------------------------------------------------------------------------\n\t\t\t/// @author Ian Copland\n\t\t\t///\n\t\t\t/// @param in_methodSignature - A JNI method signature.\n\t\t\t///\n\t\t\t/// @return The return type of the given method signature.\n\t\t\t//------------------------------------------------------------------------------\n\t\t\tReturnType CalcReturnType(const std::string& in_methodSignature);\n\t\t\t//------------------------------------------------------------------------------\n\t\t\t/// @author Ian Copland\n\t\t\t///\n\t\t\t/// @param in_methodSignature - A JNI method signature.\n\t\t\t///\n\t\t\t/// @return The number of parameters the method described by the given signature\n\t\t\t/// takes.\n\t\t\t//------------------------------------------------------------------------------\n\t\t\tu32 CalcNumArguments(const std::string& in_methodSignature);\n\t\t}\n\t}\n}\n\n#endif\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/JNI/Core/Java/JavaStaticClass.cpp",
    "content": "//\n//  JavaClass.cpp\n//  ChilliSource\n//  Created by Ian Copland on 21/04/2015.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2015 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n\n#include <CSBackend/Platform/Android/Main/JNI/Core/Java/JavaStaticClass.h>\n\n#include <ChilliSource/Core/String/StringUtils.h>\n\nnamespace CSBackend\n{\n\tnamespace Android\n\t{\n        //------------------------------------------------------------------------------\n        //------------------------------------------------------------------------------\n        JavaStaticClass::JavaStaticClass(const JavaStaticClassDef& in_javaStaticClassDef)\n        {\n            auto jvm = JavaVirtualMachine::Get();\n            auto environment = jvm->GetJNIEnvironment();\n\n            //Get the class\n            m_className = in_javaStaticClassDef.GetClassName();\n            jclass jClass = jvm->FindClass(m_className);\n            CS_ASSERT(jClass != nullptr, \"Could not find Java class: '\" + m_className + \"'\");\n\n            m_javaClass = static_cast<jclass>(environment->NewGlobalRef(jClass));\n            environment->DeleteLocalRef(jClass);\n\n            //setup the method references\n            for (const auto& method : in_javaStaticClassDef.GetMethods())\n            {\n                CS_ASSERT(m_methods.find(method.first) == m_methods.end(), \"Method '\" + method.first + \"' has already been added to Java static class '\" + m_className + \"'\");\n\n                MethodInfo info;\n                info.m_returnType = JavaMethodSignature::CalcReturnType(method.second);\n                info.m_numArguments = JavaMethodSignature::CalcNumArguments(method.second);\n                info.m_methodId = environment->GetStaticMethodID(m_javaClass, method.first.c_str(), method.second.c_str());\n\n                CS_ASSERT(info.m_methodId != nullptr, \"Could not find method '\" + method.first + \"' in Java static class '\" + m_className + \"'\");\n\n                m_methods.emplace(method.first, info);\n            }\n        }\n        //------------------------------------------------------------------------------\n        //------------------------------------------------------------------------------\n        jmethodID JavaStaticClass::GetMethodId(const std::string& in_methodName, JavaMethodSignature::ReturnType in_returnType, u32 in_numArguments) const\n        {\n            auto methodInfoIt = m_methods.find(in_methodName);\n            if (methodInfoIt == m_methods.end())\n            {\n                CS_LOG_FATAL(\"Could not find method '\" + in_methodName + \"' in Java static class '\" + m_className + \"'\");\n            }\n\n            CS_ASSERT(methodInfoIt->second.m_returnType == in_returnType, \"Cannot call method '\" + in_methodName + \"' in Java static class '\" + m_className + \"' because the wrong return type was specified.\");\n            CS_ASSERT(methodInfoIt->second.m_numArguments == in_numArguments, \"Cannot call method '\" + in_methodName + \"' in Java static class '\" + m_className + \"' because an incorrect number of arguments were supplied.\");\n\n            return methodInfoIt->second.m_methodId;\n        }\n        //------------------------------------------------------------------------------\n        //------------------------------------------------------------------------------\n        JavaStaticClass::~JavaStaticClass()\n        {\n            auto environment = JavaVirtualMachine::Get()->GetJNIEnvironment();\n            environment->DeleteGlobalRef(m_javaClass);\n            m_javaClass = nullptr;\n        }\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/JNI/Core/Java/JavaStaticClass.h",
    "content": "//\n//  JavaStaticClass.h\n//  ChilliSource\n//  Created by Ian Copland on 08/06/2015.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2015 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n\n#ifndef _CSBACKEND_PLATFORM_ANDROID_MAIN_JNI_CORE_JAVA_JAVASTATICCLASS_H_\n#define _CSBACKEND_PLATFORM_ANDROID_MAIN_JNI_CORE_JAVA_JAVASTATICCLASS_H_\n\n#include <ChilliSource/ChilliSource.h>\n\n#include <CSBackend/Platform/Android/Main/JNI/ForwardDeclarations.h>\n#include <CSBackend/Platform/Android/Main/JNI/Core/Java/JavaMethodSignature.h>\n#include <CSBackend/Platform/Android/Main/JNI/Core/Java/JavaStaticClassDef.h>\n#include <CSBackend/Platform/Android/Main/JNI/Core/Java/JavaUtils.h>\n#include <CSBackend/Platform/Android/Main/JNI/Core/Java/JavaVirtualMachine.h>\n\n#include <jni.h>\n\n#include <unordered_map>\n\nnamespace CSBackend\n{\n\tnamespace Android\n\t{\n\t\t//------------------------------------------------------------------------------\n\t\t/// Provides a means to reference a static class in java and call its methods.\n\t\t///\n\t\t/// This is essentially a wrapper around the JNI functions for calling static\n\t\t/// methods java methods. Methods references are cached for the sake of\n\t\t/// performance and there are a number of sanity checks to assist debugging of\n\t\t/// issues including confirming that the correct number of parameters have\n\t\t/// been provided and that the method is being called with the correct return\n\t\t/// type. Exceptions are also checked for after every method call, avoiding\n\t\t/// difficult to debug issues where native execution continues until the next\n\t\t/// java call when an exception is thrown.\n\t\t///\n\t\t/// JavaStaticClass is immutable after construction, meaning it can safely be\n\t\t/// called from multiple threads at the same time. Care still needs to be taken\n\t\t/// to ensure the Java and Native classes that are using it are thread-safe,\n\t\t/// however.\n\t\t///\n\t\t/// @author Ian Copland\n\t\t//------------------------------------------------------------------------------\n\t\tclass JavaStaticClass final\n\t\t{\n\t\tpublic:\n            //------------------------------------------------------------------------------\n            /// Constructor. Prepares the static methods so that they can be called.\n            ///\n            /// The class and all methods will be checked to ensure they exist.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param in_javaStaticClassDef - The definition for this java static class.\n            //------------------------------------------------------------------------------\n            JavaStaticClass(const JavaStaticClassDef& in_javaStaticClassDef);\n            //------------------------------------------------------------------------------\n            /// Calls a void java static method.\n            ///\n            /// The method will be checked to ensure the method type is correct. Exceptions\n            /// thrown from Java are treated as fatal errors and the application will be\n            /// terminated.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param in_methodName - The name of the method to call.\n            /// @param ... - The arguments to the method.\n            //------------------------------------------------------------------------------\n            template <typename... TArgs> void CallVoidMethod(const std::string& in_methodName, TArgs&&... in_args) const;\n            //------------------------------------------------------------------------------\n            /// Calls a boolean java static method.\n            ///\n            /// The method will be checked to ensure the method type is correct. Exceptions\n            /// thrown from Java are treated as fatal errors and the application will be\n            /// terminated.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param in_methodName - The name of the method to call.\n            /// @param ... - The arguments to the method.\n            //------------------------------------------------------------------------------\n            template <typename... TArgs> bool CallBoolMethod(const std::string& in_methodName, TArgs&&... in_args) const;\n            //------------------------------------------------------------------------------\n            /// Calls a byte java static method.\n            ///\n            /// The method will be checked to ensure the method type is correct. Exceptions\n            /// thrown from Java are treated as fatal errors and the application will be\n            /// terminated.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param in_methodName - The name of the method to call.\n            /// @param ... - The arguments to the method.\n            //------------------------------------------------------------------------------\n            template <typename... TArgs> u8 CallByteMethod(const std::string& in_methodName, TArgs&&... in_args) const;\n            //------------------------------------------------------------------------------\n            /// Calls a char java static method.\n            ///\n            /// The method will be checked to ensure the method type is correct. Exceptions\n            /// thrown from Java are treated as fatal errors and the application will be\n            /// terminated.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param in_methodName - The name of the method to call.\n            /// @param ... - The arguments to the method.\n            //------------------------------------------------------------------------------\n            template <typename... TArgs> u16 CallCharMethod(const std::string& in_methodName, TArgs&&... in_args) const;\n            //------------------------------------------------------------------------------\n            /// Calls a short java static method.\n            ///\n            /// The method will be checked to ensure the method type is correct. Exceptions\n            /// thrown from Java are treated as fatal errors and the application will be\n            /// terminated.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param in_methodName - The name of the method to call.\n            /// @param ... - The arguments to the method.\n            //------------------------------------------------------------------------------\n            template <typename... TArgs> s16 CallShortMethod(const std::string& in_methodName, TArgs&&... in_args) const;\n            //------------------------------------------------------------------------------\n            /// Calls an int java static method.\n            ///\n            /// The method will be checked to ensure the method type is correct. Exceptions\n            /// thrown from Java are treated as fatal errors and the application will be\n            /// terminated.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param in_methodName - The name of the method to call.\n            /// @param ... - The arguments to the method.\n            //------------------------------------------------------------------------------\n            template <typename... TArgs> s32 CallIntMethod(const std::string& in_methodName, TArgs&&... in_args) const;\n            //------------------------------------------------------------------------------\n            /// Calls a long java static method.\n            ///\n            /// The method will be checked to ensure the method type is correct. Exceptions\n            /// thrown from Java are treated as fatal errors and the application will be\n            /// terminated.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param in_methodName - The name of the method to call.\n            /// @param ... - The arguments to the method.\n            //------------------------------------------------------------------------------\n            template <typename... TArgs> s64 CallLongMethod(const std::string& in_methodName, TArgs&&... in_args) const;\n            //------------------------------------------------------------------------------\n            /// Calls a float java static method.\n            ///\n            /// The method will be checked to ensure the method type is correct. Exceptions\n            /// thrown from Java are treated as fatal errors and the application will be\n            /// terminated.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param in_methodName - The name of the method to call.\n            /// @param ... - The arguments to the method.\n            //------------------------------------------------------------------------------\n            template <typename... TArgs> f32 CallFloatMethod(const std::string& in_methodName, TArgs&&... in_args) const;\n            //------------------------------------------------------------------------------\n            /// Calls a double java static method.\n            ///\n            /// The method will be checked to ensure the method type is correct. Exceptions\n            /// thrown from Java are treated as fatal errors and the application will be\n            /// terminated.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param in_methodName - The name of the method to call.\n            /// @param ... - The arguments to the method.\n            //------------------------------------------------------------------------------\n            template <typename... TArgs> f64 CallDoubleMethod(const std::string& in_methodName, TArgs&&... in_args) const;\n            //------------------------------------------------------------------------------\n            /// Calls an object java static method.\n            ///\n            /// The method will be checked to ensure the method type is correct. Exceptions\n            /// thrown from Java are treated as fatal errors and the application will be\n            /// terminated.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param in_methodName - The name of the method to call.\n            /// @param ... - The arguments to the method.\n            //------------------------------------------------------------------------------\n            template <typename... TArgs> jobject CallObjectMethod(const std::string& in_methodName, TArgs&&... in_args) const;\n            //------------------------------------------------------------------------------\n            /// Calls an string java static method. This is a special case of CallObjectMethod()\n            ///\n            /// The method will be checked to ensure the method type is correct. Exceptions\n            /// thrown from Java are treated as fatal errors and the application will be\n            /// terminated.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param in_methodName - The name of the method to call.\n            /// @param ... - The arguments to the method.\n            //------------------------------------------------------------------------------\n            template <typename... TArgs> std::string CallStringMethod(const std::string& in_methodName, TArgs&&... in_args) const;\n            //------------------------------------------------------------------------------\n            /// Destructor.\n            ///\n            /// @author Ian Copland\n            //------------------------------------------------------------------------------\n            ~JavaStaticClass();\n\n        private:\n            //------------------------------------------------------------------------------\n            /// A struct containing information on a single Java static method.\n            ///\n            /// @author Ian Copland\n            //------------------------------------------------------------------------------\n            struct MethodInfo\n            {\n                jmethodID m_methodId = nullptr;\n                JavaMethodSignature::ReturnType m_returnType = JavaMethodSignature::ReturnType::k_void;\n                u32 m_numArguments = 0;\n            };\n            //------------------------------------------------------------------------------\n            /// Finds the method with the given name and performs some checks to mitigate\n            /// mistakes when calling the JNI. This includes that the method has the\n            /// correct return type and has the correct number of arguments.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @return The method info for the given name, type and number of arguments.\n            ///\n            /// @param in_methodName - The name of the method.\n            /// @param in_returnType - The type of the method.\n            /// @param in_numArguments - The number of arguments the method should have.\n            ///\n            /// @return The method info.\n            //------------------------------------------------------------------------------\n            jmethodID GetMethodId(const std::string& in_methodName, JavaMethodSignature::ReturnType in_returnType, u32 in_numArguments) const;\n\n            std::string m_className;\n            jclass m_javaClass = nullptr;\n            std::unordered_map<std::string, MethodInfo> m_methods;\n\t\t};\n        //------------------------------------------------------------------------------\n        //------------------------------------------------------------------------------\n        template <typename... TArgs> void JavaStaticClass::CallVoidMethod(const std::string& in_methodName, TArgs&&... in_args) const\n        {\n            auto environment = JavaVirtualMachine::Get()->GetJNIEnvironment();\n            auto methodId = GetMethodId(in_methodName, JavaMethodSignature::ReturnType::k_void, sizeof...(TArgs));\n\n            environment->CallStaticVoidMethod(m_javaClass, methodId, std::forward<TArgs>(in_args)...);\n            JavaUtils::CheckJavaExceptions(\"An exception was thrown while calling method '\" + in_methodName + \"' in Java static class '\" + m_className + \"'.\");\n        }\n        //------------------------------------------------------------------------------\n        //------------------------------------------------------------------------------\n        template <typename... TArgs> bool JavaStaticClass::CallBoolMethod(const std::string& in_methodName, TArgs&&... in_args) const\n        {\n            auto environment = JavaVirtualMachine::Get()->GetJNIEnvironment();\n            auto methodId = GetMethodId(in_methodName, JavaMethodSignature::ReturnType::k_bool, sizeof...(TArgs));\n\n            auto output = environment->CallStaticBooleanMethod(m_javaClass, methodId, std::forward<TArgs>(in_args)...);\n            JavaUtils::CheckJavaExceptions(\"An exception was thrown while calling method '\" + in_methodName + \"' in Java static class '\" + m_className + \"'.\");\n\n            return output;\n        }\n        //------------------------------------------------------------------------------\n        //------------------------------------------------------------------------------\n        template <typename... TArgs> u8 JavaStaticClass::CallByteMethod(const std::string& in_methodName, TArgs&&... in_args) const\n        {\n            auto environment = JavaVirtualMachine::Get()->GetJNIEnvironment();\n            auto methodId = GetMethodId(in_methodName, JavaMethodSignature::ReturnType::k_byte, sizeof...(TArgs));\n\n            auto output = environment->CallStaticByteMethod(m_javaClass, methodId, std::forward<TArgs>(in_args)...);\n            JavaUtils::CheckJavaExceptions(\"An exception was thrown while calling method '\" + in_methodName + \"' in Java static class '\" + m_className + \"'.\");\n\n            return output;\n        }\n        //------------------------------------------------------------------------------\n        //------------------------------------------------------------------------------\n        template <typename... TArgs> u16 JavaStaticClass::CallCharMethod(const std::string& in_methodName, TArgs&&... in_args) const\n        {\n            auto environment = JavaVirtualMachine::Get()->GetJNIEnvironment();\n            auto methodId = GetMethodId(in_methodName, JavaMethodSignature::ReturnType::k_char, sizeof...(TArgs));\n\n            auto output = environment->CallStaticCharMethod(m_javaClass, methodId, std::forward<TArgs>(in_args)...);\n            JavaUtils::CheckJavaExceptions(\"An exception was thrown while calling method '\" + in_methodName + \"' in Java static class '\" + m_className + \"'.\");\n\n            return output;\n        }\n        //------------------------------------------------------------------------------\n        //------------------------------------------------------------------------------\n        template <typename... TArgs> s16 JavaStaticClass::CallShortMethod(const std::string& in_methodName, TArgs&&... in_args) const\n        {\n            auto environment = JavaVirtualMachine::Get()->GetJNIEnvironment();\n            auto methodId = GetMethodId(in_methodName, JavaMethodSignature::ReturnType::k_short, sizeof...(TArgs));\n\n            auto output = environment->CallStaticShortMethod(m_javaClass, methodId, std::forward<TArgs>(in_args)...);\n            JavaUtils::CheckJavaExceptions(\"An exception was thrown while calling method '\" + in_methodName + \"' in Java static class '\" + m_className + \"'.\");\n\n            return output;\n        }\n        //------------------------------------------------------------------------------\n        //------------------------------------------------------------------------------\n        template <typename... TArgs> s32 JavaStaticClass::CallIntMethod(const std::string& in_methodName, TArgs&&... in_args) const\n        {\n            auto environment = JavaVirtualMachine::Get()->GetJNIEnvironment();\n            auto methodId = GetMethodId(in_methodName, JavaMethodSignature::ReturnType::k_int, sizeof...(TArgs));\n\n            auto output = environment->CallStaticIntMethod(m_javaClass, methodId, std::forward<TArgs>(in_args)...);\n            JavaUtils::CheckJavaExceptions(\"An exception was thrown while calling method '\" + in_methodName + \"' in Java static class '\" + m_className + \"'.\");\n\n            return output;\n        }\n        //------------------------------------------------------------------------------\n        //------------------------------------------------------------------------------\n        template <typename... TArgs> s64 JavaStaticClass::CallLongMethod(const std::string& in_methodName, TArgs&&... in_args) const\n        {\n            auto environment = JavaVirtualMachine::Get()->GetJNIEnvironment();\n            auto methodId = GetMethodId(in_methodName, JavaMethodSignature::ReturnType::k_long, sizeof...(TArgs));\n\n            auto output = environment->CallStaticLongMethod(m_javaClass, methodId, std::forward<TArgs>(in_args)...);\n            JavaUtils::CheckJavaExceptions(\"An exception was thrown while calling method '\" + in_methodName + \"' in Java static class '\" + m_className + \"'.\");\n\n            return output;\n        }\n        //------------------------------------------------------------------------------\n        //------------------------------------------------------------------------------\n        template <typename... TArgs> f32 JavaStaticClass::CallFloatMethod(const std::string& in_methodName, TArgs&&... in_args) const\n        {\n            auto environment = JavaVirtualMachine::Get()->GetJNIEnvironment();\n            auto methodId = GetMethodId(in_methodName, JavaMethodSignature::ReturnType::k_float, sizeof...(TArgs));\n\n            f32 output = environment->CallStaticFloatMethod(m_javaClass, methodId, std::forward<TArgs>(in_args)...);\n            JavaUtils::CheckJavaExceptions(\"An exception was thrown while calling method '\" + in_methodName + \"' in Java static class '\" + m_className + \"'.\");\n\n            return output;\n        }\n        //------------------------------------------------------------------------------\n        //------------------------------------------------------------------------------\n        template <typename... TArgs> f64 JavaStaticClass::CallDoubleMethod(const std::string& in_methodName, TArgs&&... in_args) const\n        {\n            auto environment = JavaVirtualMachine::Get()->GetJNIEnvironment();\n            auto methodId = GetMethodId(in_methodName, JavaMethodSignature::ReturnType::k_double, sizeof...(TArgs));\n\n            auto output = environment->CallStaticDoubleMethod(m_javaClass, methodId, std::forward<TArgs>(in_args)...);\n            JavaUtils::CheckJavaExceptions(\"An exception was thrown while calling method '\" + in_methodName + \"' in Java static class '\" + m_className + \"'.\");\n\n            return output;\n        }\n        //------------------------------------------------------------------------------\n        //------------------------------------------------------------------------------\n        template <typename... TArgs> jobject JavaStaticClass::CallObjectMethod(const std::string& in_methodName, TArgs&&... in_args) const\n        {\n            auto environment = JavaVirtualMachine::Get()->GetJNIEnvironment();\n            auto methodId = GetMethodId(in_methodName, JavaMethodSignature::ReturnType::k_object, sizeof...(TArgs));\n\n            auto output = environment->CallStaticObjectMethod(m_javaClass, methodId, std::forward<TArgs>(in_args)...);\n            JavaUtils::CheckJavaExceptions(\"An exception was thrown while calling method '\" + in_methodName + \"' in Java static class '\" + m_className + \"'.\");\n\n            return output;\n        }\n        //------------------------------------------------------------------------------\n        //------------------------------------------------------------------------------\n        template <typename... TArgs> std::string JavaStaticClass::CallStringMethod(const std::string& in_methodName, TArgs&&... in_args) const\n        {\n            auto environment = JavaVirtualMachine::Get()->GetJNIEnvironment();\n            auto methodId = GetMethodId(in_methodName, JavaMethodSignature::ReturnType::k_string, sizeof...(TArgs));\n\n            auto jString = static_cast<jstring>(environment->CallStaticObjectMethod(m_javaClass, methodId, std::forward<TArgs>(in_args)...));\n            JavaUtils::CheckJavaExceptions(\"An exception was thrown while calling method '\" + in_methodName + \"' in Java static class '\" + m_className + \"'.\");\n\n            std::string output = JavaUtils::CreateSTDStringFromJString(jString);\n            environment->DeleteLocalRef(jString);\n\n            return output;\n        }\n\t}\n}\n\n#endif\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/JNI/Core/Java/JavaStaticClassDef.cpp",
    "content": "//\n//  JavaStaticClassDef.cpp\n//  ChilliSource\n//  Created by Ian Copland on 08/06/2015.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2015 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n\n#include <CSBackend/Platform/Android/Main/JNI/Core/Java/JavaStaticClassDef.h>\n\nnamespace CSBackend\n{\n\tnamespace Android\n\t{\n        //------------------------------------------------------------------------------\n        //------------------------------------------------------------------------------\n        JavaStaticClassDef::JavaStaticClassDef(const std::string& in_className)\n            : m_className(in_className)\n        {\n        }\n        //------------------------------------------------------------------------------\n        //------------------------------------------------------------------------------\n        void JavaStaticClassDef::AddMethod(const std::string& in_methodName, const std::string& in_methodSignature)\n        {\n            CS_ASSERT((m_methods.find(in_methodName) == m_methods.end()), \"Cannot add method '\" + in_methodName + \"' to static class definition '\" + m_className + \"' because the method name already exists.\");\n\n            m_methods.emplace(in_methodName, in_methodSignature);\n        }\n        //------------------------------------------------------------------------------\n        //------------------------------------------------------------------------------\n        const std::string& JavaStaticClassDef::GetClassName() const\n        {\n            return m_className;\n        }\n        //------------------------------------------------------------------------------\n        //------------------------------------------------------------------------------\n        const JavaStaticClassDef::MethodMap& JavaStaticClassDef::GetMethods() const\n        {\n            return m_methods;\n        }\n\t}\n}\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/JNI/Core/Java/JavaStaticClassDef.h",
    "content": "//\n//  JavaStaticClassDef.h\n//  ChilliSource\n//  Created by Ian Copland on 08/06/2015.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2015 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n\n#ifndef _CSBACKEND_PLATFORM_ANDROID_MAIN_JNI_CORE_JAVA_JAVASTATICCLASSDEF_H_\n#define _CSBACKEND_PLATFORM_ANDROID_MAIN_JNI_CORE_JAVA_JAVASTATICCLASSDEF_H_\n\n#include <ChilliSource/ChilliSource.h>\n\n#include <CSBackend/Platform/Android/Main/JNI/ForwardDeclarations.h>\n\n#include <unordered_map>\n\nnamespace CSBackend\n{\n\tnamespace Android\n\t{\n\t\t//------------------------------------------------------------------------------\n\t\t/// Defines the static class and the methods which will be accessible when\n\t\t/// using JavaStaticClass.\n\t\t///\n\t\t/// Although JavaStaticClass uses this for setup, it isn't retained, so it can\n\t\t/// be further modified and passed to additional JavaStaticClass instances.\n\t\t///\n\t\t/// @author Ian Copland\n\t\t//------------------------------------------------------------------------------\n\t\tclass JavaStaticClassDef final\n\t\t{\n\t\tpublic:\n\t\t    using MethodMap = std::unordered_map<std::string, std::string>;\n            //------------------------------------------------------------------------------\n            /// Constructor.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param in_className - The fully qualified name of the static class this\n            /// refers to.\n            //------------------------------------------------------------------------------\n            JavaStaticClassDef(const std::string& in_className);\n            //------------------------------------------------------------------------------\n            /// Adds a new method definition. Note that multiple overloaded methods are\n            /// not supported.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param in_methodName - The name of the method.\n            /// @param in_methodSignature - The signature of the method. This is in the\n            /// form described in the JNI documentation.\n            //------------------------------------------------------------------------------\n            void AddMethod(const std::string& in_methodName, const std::string& in_methodSignature);\n            //------------------------------------------------------------------------------\n            /// @author Ian Copland\n            ///\n            /// @return The fully qualified class name.\n            //------------------------------------------------------------------------------\n            const std::string& GetClassName() const;\n            //------------------------------------------------------------------------------\n            /// @author Ian Copland\n            ///\n            /// @return The map of methods names and signatures.\n            //------------------------------------------------------------------------------\n            const MethodMap& GetMethods() const;\n\n        private:\n            const std::string m_className;\n            MethodMap m_methods;\n\t\t};\n\t}\n}\n\n#endif\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/JNI/Core/Java/JavaSystem.cpp",
    "content": "//\n//  JavaSystem.cpp\n//  ChilliSource\n//  Created by Ian Copland on 21/04/2015.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2015 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n\n#include <CSBackend/Platform/Android/Main/JNI/Core/Java/JavaSystem.h>\n\n#include <CSBackend/Platform/Android/Main/JNI/Core/Java/JavaClassDef.h>\n\nnamespace CSBackend\n{\n\tnamespace Android\n\t{\n        //------------------------------------------------------------------------------\n        //------------------------------------------------------------------------------\n        JavaSystem::~JavaSystem()\n        {\n            m_javaClass->CallVoidMethod(\"destroy\");\n            m_javaClass.reset();\n        }\n        //------------------------------------------------------------------------------\n        //------------------------------------------------------------------------------\n        jobject JavaSystem::GetJavaObject() const\n        {\n            return m_javaClass->GetJavaObject();\n        }\n        //------------------------------------------------------------------------------\n        //------------------------------------------------------------------------------\n        const std::string& JavaSystem::GetClassName() const\n        {\n            return m_javaClass->GetClassName();\n        }\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/JNI/Core/Java/JavaSystem.h",
    "content": "//\n//  JavaSystem.h\n//  ChilliSource\n//  Created by Ian Copland on 23/04/2015.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2015 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n\n#ifndef _CSBACKEND_PLATFORM_ANDROID_MAIN_JNI_CORE_JAVA_JAVASYSTEM_H_\n#define _CSBACKEND_PLATFORM_ANDROID_MAIN_JNI_CORE_JAVA_JAVASYSTEM_H_\n\n#include <ChilliSource/ChilliSource.h>\n\n#include <CSBackend/Platform/Android/Main/JNI/ForwardDeclarations.h>\n#include <CSBackend/Platform/Android/Main/JNI/Core/Java/JavaClass.h>\n\n#include <jni.h>\n\nnamespace CSBackend\n{\n\tnamespace Android\n\t{\n\t\t//------------------------------------------------------------------------------\n\t\t/// A specialised version of JavaClass, specifically for accessing classes which\n\t\t/// extend System. This ensures the init() and destroy() methods will be called\n\t\t/// as appropriate for the system.\n\t\t///\n\t\t/// @author Ian Copland\n\t\t//------------------------------------------------------------------------------\n\t\tclass JavaSystem final\n\t\t{\n\t\tpublic:\n            //------------------------------------------------------------------------------\n            /// Constructor. Instantiates the underlying JavaSystem and calls the init()\n            /// method.\n            /// @author Ian Copland\n            ///\n            /// @param in_javaClassDef - The definition for this java system.\n            //------------------------------------------------------------------------------\n            template <typename... TArgs> JavaSystem(const JavaClassDef& in_javaClassDef, TArgs&&... in_args);\n            //------------------------------------------------------------------------------\n            /// Calls a void java method.\n            ///\n            /// The method will be checked to ensure the method type is correct. Exceptions\n            /// thrown from Java are treated as fatal errors and the application will be\n            /// terminated.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param in_methodName - The name of the method to call.\n            /// @param ... - The arguments to the method.\n            //------------------------------------------------------------------------------\n            template <typename... TArgs> void CallVoidMethod(const std::string& in_methodName, TArgs&&... in_args) const;\n            //------------------------------------------------------------------------------\n            /// Calls a boolean java method.\n            ///\n            /// The method will be checked to ensure the method type is correct. Exceptions\n            /// thrown from Java are treated as fatal errors and the application will be\n            /// terminated.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param in_methodName - The name of the method to call.\n            /// @param ... - The arguments to the method.\n            //------------------------------------------------------------------------------\n            template <typename... TArgs> bool CallBoolMethod(const std::string& in_methodName, TArgs&&... in_args) const;\n            //------------------------------------------------------------------------------\n            /// Calls a byte java method.\n            ///\n            /// The method will be checked to ensure the method type is correct. Exceptions\n            /// thrown from Java are treated as fatal errors and the application will be\n            /// terminated.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param in_methodName - The name of the method to call.\n            /// @param ... - The arguments to the method.\n            //------------------------------------------------------------------------------\n            template <typename... TArgs> u8 CallByteMethod(const std::string& in_methodName, TArgs&&... in_args) const;\n            //------------------------------------------------------------------------------\n            /// Calls a char java method.\n            ///\n            /// The method will be checked to ensure the method type is correct. Exceptions\n            /// thrown from Java are treated as fatal errors and the application will be\n            /// terminated.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param in_methodName - The name of the method to call.\n            /// @param ... - The arguments to the method.\n            //------------------------------------------------------------------------------\n            template <typename... TArgs> u16 CallCharMethod(const std::string& in_methodName, TArgs&&... in_args) const;\n            //------------------------------------------------------------------------------\n            /// Calls a short java method.\n            ///\n            /// The method will be checked to ensure the method type is correct. Exceptions\n            /// thrown from Java are treated as fatal errors and the application will be\n            /// terminated.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param in_methodName - The name of the method to call.\n            /// @param ... - The arguments to the method.\n            //------------------------------------------------------------------------------\n            template <typename... TArgs> s16 CallShortMethod(const std::string& in_methodName, TArgs&&... in_args) const;\n            //------------------------------------------------------------------------------\n            /// Calls an int java method.\n            ///\n            /// The method will be checked to ensure the method type is correct. Exceptions\n            /// thrown from Java are treated as fatal errors and the application will be\n            /// terminated.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param in_methodName - The name of the method to call.\n            /// @param ... - The arguments to the method.\n            //------------------------------------------------------------------------------\n            template <typename... TArgs> s32 CallIntMethod(const std::string& in_methodName, TArgs&&... in_args) const;\n            //------------------------------------------------------------------------------\n            /// Calls a long java method.\n            ///\n            /// The method will be checked to ensure the method type is correct. Exceptions\n            /// thrown from Java are treated as fatal errors and the application will be\n            /// terminated.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param in_methodName - The name of the method to call.\n            /// @param ... - The arguments to the method.\n            //------------------------------------------------------------------------------\n            template <typename... TArgs> s64 CallLongMethod(const std::string& in_methodName, TArgs&&... in_args) const;\n            //------------------------------------------------------------------------------\n            /// Calls a float java method.\n            ///\n            /// The method will be checked to ensure the method type is correct. Exceptions\n            /// thrown from Java are treated as fatal errors and the application will be\n            /// terminated.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param in_methodName - The name of the method to call.\n            /// @param ... - The arguments to the method.\n            //------------------------------------------------------------------------------\n            template <typename... TArgs> f32 CallFloatMethod(const std::string& in_methodName, TArgs&&... in_args) const;\n            //------------------------------------------------------------------------------\n            /// Calls a double java method.\n            ///\n            /// The method will be checked to ensure the method type is correct. Exceptions\n            /// thrown from Java are treated as fatal errors and the application will be\n            /// terminated.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param in_methodName - The name of the method to call.\n            /// @param ... - The arguments to the method.\n            //------------------------------------------------------------------------------\n            template <typename... TArgs> f64 CallDoubleMethod(const std::string& in_methodName, TArgs&&... in_args) const;\n            //------------------------------------------------------------------------------\n            /// Calls an object java method.\n            ///\n            /// The method will be checked to ensure the method type is correct. Exceptions\n            /// thrown from Java are treated as fatal errors and the application will be\n            /// terminated.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param in_methodName - The name of the method to call.\n            /// @param ... - The arguments to the method.\n            //------------------------------------------------------------------------------\n            template <typename... TArgs> jobject CallObjectMethod(const std::string& in_methodName, TArgs&&... in_args) const;\n            //------------------------------------------------------------------------------\n            /// Calls an string java method. This is a special case of CallObjectMethod()\n            ///\n            /// The method will be checked to ensure the method type is correct. Exceptions\n            /// thrown from Java are treated as fatal errors and the application will be\n            /// terminated.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param in_methodName - The name of the method to call.\n            /// @param ... - The arguments to the method.\n            //------------------------------------------------------------------------------\n            template <typename... TArgs> std::string CallStringMethod(const std::string& in_methodName, TArgs&&... in_args) const;\n            //------------------------------------------------------------------------------\n            /// Returns the java object for this\n            ///\n            /// @author HMcLaughlin\n            ///\n            /// @return Java object\n            //------------------------------------------------------------------------------\n            jobject GetJavaObject() const;\n            //------------------------------------------------------------------------------\n            /// Gets the class name\n            ///\n            /// @author HMcLaughlin\n            ///\n            /// @return Class Name of the java def\n            //------------------------------------------------------------------------------\n            const std::string& GetClassName() const;\n            //------------------------------------------------------------------------------\n            /// Destructor.\n            ///\n            /// @author Ian Copland\n            //------------------------------------------------------------------------------\n            ~JavaSystem();\n\n        private:\n\n            JavaClassUPtr m_javaClass;\n\t\t};\n        //------------------------------------------------------------------------------\n        //------------------------------------------------------------------------------\n        template <typename... TArgs> JavaSystem::JavaSystem(const JavaClassDef& in_javaClassDef, TArgs&&... in_args)\n        {\n            JavaClassDef updatedDef(in_javaClassDef.GetClassName(), in_javaClassDef.GetConstructorSignature());\n            updatedDef.AddMethod(\"init\", \"()V\");\n            updatedDef.AddMethod(\"destroy\", \"()V\");\n            for (const auto& methodInfo : in_javaClassDef.GetMethods())\n            {\n                updatedDef.AddMethod(methodInfo.first, methodInfo.second);\n            }\n            m_javaClass = JavaClassUPtr(new JavaClass(updatedDef, std::forward<TArgs>(in_args)...));\n\n            m_javaClass->CallVoidMethod(\"init\");\n        }\n        //------------------------------------------------------------------------------\n        //------------------------------------------------------------------------------\n        template <typename... TArgs> void JavaSystem::CallVoidMethod(const std::string& in_methodName, TArgs&&... in_args) const\n        {\n            m_javaClass->CallVoidMethod(in_methodName, std::forward<TArgs>(in_args)...);\n        }\n        //------------------------------------------------------------------------------\n        //------------------------------------------------------------------------------\n        template <typename... TArgs> bool JavaSystem::CallBoolMethod(const std::string& in_methodName, TArgs&&... in_args) const\n        {\n            return m_javaClass->CallBoolMethod(in_methodName, std::forward<TArgs>(in_args)...);\n        }\n        //------------------------------------------------------------------------------\n        //------------------------------------------------------------------------------\n        template <typename... TArgs> u8 JavaSystem::CallByteMethod(const std::string& in_methodName, TArgs&&... in_args) const\n        {\n            return m_javaClass->CallByteMethod(in_methodName, std::forward<TArgs>(in_args)...);\n        }\n        //------------------------------------------------------------------------------\n        //------------------------------------------------------------------------------\n        template <typename... TArgs> u16 JavaSystem::CallCharMethod(const std::string& in_methodName, TArgs&&... in_args) const\n        {\n            return m_javaClass->CallCharMethod(in_methodName, std::forward<TArgs>(in_args)...);\n        }\n        //------------------------------------------------------------------------------\n        //------------------------------------------------------------------------------\n        template <typename... TArgs> s16 JavaSystem::CallShortMethod(const std::string& in_methodName, TArgs&&... in_args) const\n        {\n            return m_javaClass->CallShortMethod(in_methodName, std::forward<TArgs>(in_args)...);\n        }\n        //------------------------------------------------------------------------------\n        //------------------------------------------------------------------------------\n        template <typename... TArgs> s32 JavaSystem::CallIntMethod(const std::string& in_methodName, TArgs&&... in_args) const\n        {\n            return m_javaClass->CallIntMethod(in_methodName, std::forward<TArgs>(in_args)...);\n        }\n        //------------------------------------------------------------------------------\n        //------------------------------------------------------------------------------\n        template <typename... TArgs> s64 JavaSystem::CallLongMethod(const std::string& in_methodName, TArgs&&... in_args) const\n        {\n            return m_javaClass->CallLongMethod(in_methodName, std::forward<TArgs>(in_args)...);\n        }\n        //------------------------------------------------------------------------------\n        //------------------------------------------------------------------------------\n        template <typename... TArgs> f32 JavaSystem::CallFloatMethod(const std::string& in_methodName, TArgs&&... in_args) const\n        {\n            return m_javaClass->CallFloatMethod(in_methodName, std::forward<TArgs>(in_args)...);\n        }\n        //------------------------------------------------------------------------------\n        //------------------------------------------------------------------------------\n        template <typename... TArgs> f64 JavaSystem::CallDoubleMethod(const std::string& in_methodName, TArgs&&... in_args) const\n        {\n            return m_javaClass->CallDoubleMethod(in_methodName, std::forward<TArgs>(in_args)...);\n        }\n        //------------------------------------------------------------------------------\n        //------------------------------------------------------------------------------\n        template <typename... TArgs> jobject JavaSystem::CallObjectMethod(const std::string& in_methodName, TArgs&&... in_args) const\n        {\n            return m_javaClass->CallObjectMethod(in_methodName, std::forward<TArgs>(in_args)...);\n        }\n        //------------------------------------------------------------------------------\n        //------------------------------------------------------------------------------\n        template <typename... TArgs> std::string JavaSystem::CallStringMethod(const std::string& in_methodName, TArgs&&... in_args) const\n        {\n            return m_javaClass->CallStringMethod(in_methodName, std::forward<TArgs>(in_args)...);\n        }\n\t}\n}\n\n#endif\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/JNI/Core/Java/JavaUtils.cpp",
    "content": "//\n//  JavaUtils.cpp\n//  ChilliSource\n//  Created by Ian Copland on 09/08/2012.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2012 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n\n#include <CSBackend/Platform/Android/Main/JNI/Core/Java/JavaUtils.h>\n\n#include <CSBackend/Platform/Android/Main/JNI/Core/Java/JavaVirtualMachine.h>\n\nnamespace CSBackend\n{\n\tnamespace Android\n\t{\n\t\tnamespace JavaUtils\n\t\t{\n\t\t\t//------------------------------------------------------------------------------\n\t\t\t//------------------------------------------------------------------------------\n\t\t\tjstring CreateJStringFromSTDString(const std::string& in_string)\n\t\t\t{\n\t\t\t\tauto environment = JavaVirtualMachine::Get()->GetJNIEnvironment();\n\t\t\t\tjstring output = environment->NewStringUTF(in_string.c_str());\n\t\t\t\treturn output;\n\t\t\t}\n\t\t\t//------------------------------------------------------------------------------\n\t\t\t//------------------------------------------------------------------------------\n\t\t\tstd::string CreateSTDStringFromJString(jstring in_jString)\n\t\t\t{\n\t\t\t    if (in_jString == nullptr)\n\t\t\t    {\n\t\t\t        return \"\";\n\t\t\t    }\n\n\t\t\t\tauto environment = JavaVirtualMachine::Get()->GetJNIEnvironment();\n                const char * cString = environment->GetStringUTFChars(in_jString, JNI_FALSE);\n                CS_ASSERT(cString != nullptr, \"String returned from GetStringUTFChars() cannot be null.\");\n\n                std::string output = std::string(cString);\n                environment->ReleaseStringUTFChars(in_jString, cString);\n\n                return output;\n\t\t\t}\n\t\t\t//------------------------------------------------------------------------------\n\t\t\t//------------------------------------------------------------------------------\n\t\t\tstd::string CreateSTDStringFromJByteArray(jbyteArray in_array, u32 in_length)\n\t\t\t{\n\t\t\t    if (in_array == nullptr || in_length == 0)\n\t\t\t    {\n\t\t\t        return \"\";\n\t\t\t    }\n\n\t\t\t\tauto environment = JavaVirtualMachine::Get()->GetJNIEnvironment();\n\n                jbyte* bytes = environment->GetByteArrayElements(in_array, JNI_FALSE);\n                CS_ASSERT(bytes != nullptr, \"Bytes returned by GetByteArrayElements() cannot be null.\");\n\n                std::string strOutput((const char*)bytes, in_length);\n                environment->ReleaseByteArrayElements(in_array, bytes, 0);\n\n                return strOutput;\n\t\t\t}\n\t\t\t//------------------------------------------------------------------------------\n\t\t\t//------------------------------------------------------------------------------\n\t\t\ts32 GetIntElementFromJArray(jintArray in_array, u32 in_index)\n\t\t\t{\n\t\t\t    CS_ASSERT(in_array != nullptr, \"Cannot get int element from null array.\");\n\n\t\t\t    auto environment = JavaVirtualMachine::Get()->GetJNIEnvironment();\n\n                jint* integers = environment->GetIntArrayElements(in_array, JNI_FALSE);\n                CS_ASSERT(integers != nullptr, \"Integers returned by GetIntArrayElements() cannot be null.\");\n\n                s32 output = integers[in_index];\n                environment->ReleaseIntArrayElements(in_array, integers, 0);\n\n                return output;\n\t\t\t}\n\t\t\t//------------------------------------------------------------------------------\n\t\t\t//------------------------------------------------------------------------------\n\t\t\tvoid CheckJavaExceptions(const std::string& in_errorMessage)\n\t\t\t{\n\t\t\t\tauto environment = JavaVirtualMachine::Get()->GetJNIEnvironment();\n\n\t\t\t\tjthrowable exception = environment->ExceptionOccurred();\n\t\t\t\tif (exception != nullptr)\n\t\t\t\t{\n\t\t\t\t\tenvironment->ExceptionDescribe();\n\t\t\t\t\tenvironment->ExceptionClear();\n\n\t\t\t\t\tCS_LOG_FATAL(in_errorMessage);\n\t\t\t\t}\n\t\t\t}\n\t\t\t//------------------------------------------------------------------------------\n\t\t\t//------------------------------------------------------------------------------\n\t\t\tvoid DeleteLocalRef(jobject in_localReference)\n\t\t\t{\n\t\t\t\tauto environment = JavaVirtualMachine::Get()->GetJNIEnvironment();\n\n\t\t\t\tenvironment->DeleteLocalRef(in_localReference);\n\t\t\t}\n\t\t}\n\t}\n}\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/JNI/Core/Java/JavaUtils.h",
    "content": "//\n//  JavaUtils.h\n//  ChilliSource\n//  Created by Ian Copland on 09/08/2012.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2012 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n\n#ifndef _CSBACKEND_PLATFORM_ANDROID_MAIN_JNI_CORE_JAVA_JAVAUTILS_H_\n#define _CSBACKEND_PLATFORM_ANDROID_MAIN_JNI_CORE_JAVA_JAVAUTILS_H_\n\n#include <ChilliSource/ChilliSource.h>\n\n#include <CSBackend/Platform/Android/Main/JNI/ForwardDeclarations.h>\n\n#include <jni.h>\n\n#include <string>\n\nnamespace CSBackend\n{\n\tnamespace Android\n\t{\n\t    //------------------------------------------------------------------------------\n\t    /// A series of convenience functions for working with Java from native.\n\t    ///\n\t    /// @author Ian Copland\n\t    //------------------------------------------------------------------------------\n\t\tnamespace JavaUtils\n\t\t{\n\t\t\t//------------------------------------------------------------------------------\n\t\t\t/// Converts a std string into a JString. The JString will need to be manually\n\t\t\t/// released with ReleaseLocalRef() once it has been finished with.\n\t\t\t///\n\t\t\t/// @author Ian Copland\n\t\t\t///\n\t\t\t/// @param in_string - the std::string\n\t\t\t///\n\t\t\t/// @return The new java string\n\t\t\t//------------------------------------------------------------------------------\n\t\t\tjstring CreateJStringFromSTDString(const std::string& in_string);\n\t\t\t//------------------------------------------------------------------------------\n\t\t\t/// Takes a java string and converts it to a std::string. If a null string is\n\t\t\t/// passed in, an empty string will be returned.\n\t\t\t///\n\t\t\t/// @author Ian Copland\n\t\t\t///\n\t\t\t/// @param in_jString - The java string\n\t\t\t///\n\t\t\t/// @return The new std::string\n\t\t\t//------------------------------------------------------------------------------\n\t\t\tstd::string CreateSTDStringFromJString(jstring in_jString);\n\t\t\t//------------------------------------------------------------------------------\n\t\t\t/// Takes a java byte array and converts it to a std::string. If a null array\n\t\t\t/// or an array of size 0 is passed in, an empty string is returned.\n\t\t\t///\n\t\t\t/// @author Ian Copland\n\t\t\t///\n\t\t\t/// @param in_array - the java byte array\n\t\t\t/// @param in_length - The length of the java byte array.\n\t\t\t///\n\t\t\t/// @return The new std::string\n\t\t\t//------------------------------------------------------------------------------\n\t\t\tstd::string CreateSTDStringFromJByteArray(jbyteArray in_array, u32 in_length);\n\t\t\t//------------------------------------------------------------------------------\n\t\t\t/// Returns the value at the requested index in the j-array\n\t\t\t///\n\t\t\t/// @author Ian Copland\n\t\t\t///\n\t\t\t/// @param in_array - the java array.\n\t\t\t/// @param in_index - the index.\n\t\t\t///\n\t\t\t/// @return The integer value.\n\t\t\t//------------------------------------------------------------------------------\n\t\t\ts32 GetIntElementFromJArray(jintArray in_array, u32 in_index);\n\t\t\t//------------------------------------------------------------------------------\n\t\t\t/// Checks for java exceptions. If an exception has occurred it is treated as\n\t\t\t/// a fatal error and the application will be terminated.\n\t\t\t///\n\t\t\t/// This rarely needs to be called manually as JavaClass and JavaStaticClass\n\t\t\t/// both call it internally immediately after every java call.\n\t\t\t///\n\t\t\t/// @author Ian Copland\n\t\t\t///\n\t\t\t/// @param in_errorMessage - The error message to print if an exception occurred.\n\t\t\t//------------------------------------------------------------------------------\n\t\t\tvoid CheckJavaExceptions(const std::string& in_errorMessage);\n\t\t\t//------------------------------------------------------------------------------\n\t\t\t/// Deletes a local reference. This is provided for convenience to save having\n\t\t\t/// to get the java environment when a reference was created through the other\n\t\t\t/// convenience methods provided here.\n\t\t\t///\n\t\t\t/// @author Ian Copland\n\t\t\t///\n\t\t\t/// @param in_localReference - The local java reference which should be deleted.\n\t\t\t//------------------------------------------------------------------------------\n\t\t\tvoid DeleteLocalRef(jobject in_localReference);\n\t\t}\n\t}\n}\n\n#endif\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/JNI/Core/Java/JavaVirtualMachine.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2015 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n\n#include <CSBackend/Platform/Android/Main/JNI/Core/Java/JavaVirtualMachine.h>\n#include <CSBackend/Platform/Android/Main/JNI/Core/Java/JavaUtils.h>\n\nnamespace CSBackend\n{\n\tnamespace Android\n\t{\n        //------------------------------------------------------------------------------\n        JavaVirtualMachine::JavaVirtualMachine(JavaVM* in_javaVirtualMachine) noexcept\n            : m_javaVirtualMachine(in_javaVirtualMachine)\n        {\n            constexpr char k_activityClassName[] = \"com/chilliworks/chillisource/core/CSActivity\";\n\n            CS_ASSERT(m_javaVirtualMachine != nullptr, \"The java virtual machine cannot be null.\");\n\n            auto environment = GetJNIEnvironment();\n\n            auto activityClass = environment->FindClass(k_activityClassName);\n            auto activityClassClass = environment->GetObjectClass(activityClass);\n            auto getClassLoaderMethod = environment->GetMethodID(activityClassClass, \"getClassLoader\", \"()Ljava/lang/ClassLoader;\");\n            auto classLoader = environment->CallObjectMethod(activityClass, getClassLoaderMethod);\n            m_classLoader = environment->NewGlobalRef(classLoader);\n\n            auto classLoaderClass = environment->GetObjectClass(m_classLoader);\n            m_findClassMethod = environment->GetMethodID(classLoaderClass, \"findClass\", \"(Ljava/lang/String;)Ljava/lang/Class;\");\n\n            environment->DeleteLocalRef(activityClass);\n            environment->DeleteLocalRef(activityClassClass);\n            environment->DeleteLocalRef(classLoader);\n            environment->DeleteLocalRef(classLoaderClass);\n        }\n\n        //------------------------------------------------------------------------------\n        void JavaVirtualMachine::AttachCurrentThread() noexcept\n        {\n            JNIEnv* environment = nullptr;\n            m_javaVirtualMachine->AttachCurrentThread(&environment, nullptr);\n        }\n\n        //------------------------------------------------------------------------------\n        JNIEnv* JavaVirtualMachine::GetJNIEnvironment() noexcept\n        {\n            CS_ASSERT(m_javaVirtualMachine != nullptr, \"The java virtual machine cannot be null.\");\n\n            JNIEnv* environment = nullptr;\n        \tm_javaVirtualMachine->AttachCurrentThread(&environment, nullptr);\n        \tCS_ASSERT(environment != nullptr, \"The jni environment cannot be null.\");\n\n        \treturn environment;\n        }\n\n        //------------------------------------------------------------------------------\n        void JavaVirtualMachine::DetachCurrentThread() noexcept\n        {\n            m_javaVirtualMachine->DetachCurrentThread();\n        }\n\n        //------------------------------------------------------------------------------\n        jclass JavaVirtualMachine::FindClass(const std::string& className) noexcept\n        {\n            auto environment = GetJNIEnvironment();\n\n            auto javaClassName = JavaUtils::CreateJStringFromSTDString(className);\n            auto outputClass = environment->CallObjectMethod(m_classLoader, m_findClassMethod, javaClassName);\n\n            JavaUtils::CheckJavaExceptions(\"An exception was thrown while finding Java class '\" + className + \"'.\");\n\n            environment->DeleteLocalRef(javaClassName);\n\n            return static_cast<jclass>(outputClass);\n        }\n\t}\n}\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/JNI/Core/Java/JavaVirtualMachine.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2015 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n\n#ifndef _CSBACKEND_PLATFORM_ANDROID_MAIN_JNI_CORE_JAVA_JAVAVIRTUALMACHINE_H_\n#define _CSBACKEND_PLATFORM_ANDROID_MAIN_JNI_CORE_JAVA_JAVAVIRTUALMACHINE_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Base/Singleton.h>\n\n#include <CSBackend/Platform/Android/Main/JNI/ForwardDeclarations.h>\n\n#include <jni.h>\n\nnamespace CSBackend\n{\n\tnamespace Android\n\t{\n\t\t/// A singleton which provides access to the java virtual machine. This is used\n\t\t/// to get the JNI Environment for the current thread, and lookup java classes.\n\t\t///\n\t\t/// This is thread-safe as long as it is accessed after the singleton is created.\n\t\t///\n\t\tclass JavaVirtualMachine final : public ChilliSource::Singleton<JavaVirtualMachine>\n\t\t{\n\t\tpublic:\n\t\t\t/// Attached the current thread to the JVM. If a background thread created in\n\t\t\t/// native might be calling up to Java this should be the first thing it calls.\n\t\t\t/// If this is called, DetachCurrentThread() must be called before the thread\n\t\t\t/// finishes or the JVM will crash.\n\t\t\t///\n\t\t\tvoid AttachCurrentThread() noexcept;\n\n\t\t\t/// Returns the pointer to the JNI Environment for the current thread. The\n\t\t\t/// thread will be attached to the JVM if it isn't already. This means that\n\t\t\t/// DetachCurrentThread will need to be called prior to the thread exiting if\n\t\t\t/// the thread was created in native.\n\t\t\t///\n\t\t\t/// @return The pointer to the JNI Environment for the current thread.\n\t\t\t///\n\t\t\tJNIEnv* GetJNIEnvironment() noexcept;\n\n\t\t\t/// Detaches the current thread from the JVM. This must be called for all\n\t\t\t/// natively created threads that have been attached to the JVM. This must not\n\t\t\t/// be called for threads which were created in Java.\n\t\t\t///\n\t\t\tvoid DetachCurrentThread() noexcept;\n\n\t\t\t/// Queries the JVM for the class with the given class name. This should be\n\t\t\t/// used instead of direct access using JNIEnv::FindClass as it can be called\n\t\t\t/// from threads which do not originate in Java.\n\t\t\t///\n\t\t\t/// @param className\n\t\t\t///\t\tThe full name of the java class, including package. A forward slash shoud\n\t\t\t///\t\tbe used as the package separator, for example 'com/java/String'.\n\t\t\t///\n\t\t\tjclass FindClass(const std::string& className) noexcept;\n\t\tprivate:\n\t\t    friend class ChilliSource::Singleton<JavaVirtualMachine>;\n\n\t\t\t/// @param in_javaVirtualMachine\n\t\t\t///\t\tThe pointer to the java virtual machine.\n\t\t\t///\n\t\t\tJavaVirtualMachine(JavaVM* in_javaVirtualMachine) noexcept;\n\n\t\t\tJavaVM* m_javaVirtualMachine;\n\t\t\tjobject m_classLoader;\n\t\t\tjmethodID m_findClassMethod;\n\t\t};\n\t}\n}\n\n#endif\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/JNI/Core/Java/_JavaInterface.cpp",
    "content": "//\n//  _JavaInterface.cpp\n//  ChilliSource\n//  Created by Ian Copland on 17/03/2011.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2011 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n\n//includes\n#include <CSBackend/Platform/Android/Main/JNI/Core/Java/_JavaInterface.h>\n\nnamespace CSBackend\n{\n\tnamespace Android\n\t{\n\t\t//declare private statics\n\t\tstd::map<std::string, MethodReference> _IJavaInterface::mStaticMethodRefMap;\n\t\tJavaVM* _IJavaInterface::mspJavaVM = nullptr;\n\n\t\t//--------------------------------------------------------------------------------------\n\t\t/// Get JNI Environment Ptr\n\t\t//--------------------------------------------------------------------------------------\n\t\tJNIEnv * _IJavaInterface::GetJNIEnvironmentPtr()\n\t\t{\n\t\t\tJNIEnv* env;\n\t\t\tmspJavaVM->AttachCurrentThread(&env, nullptr);\n\t\t\treturn env;\n\t\t}\n\t\t//--------------------------------------------------------------------------------------\n\t\t/// Get Java VM\n\t\t///\n\t\t/// @return VM\n\t\t//--------------------------------------------------------------------------------------\n\t\tJavaVM* _IJavaInterface::GetJavaVM()\n\t\t{\n\t\t\treturn mspJavaVM;\n\t\t}\n\t\t//--------------------------------------------------------------------------------------\n\t\t/// Init Callable Static Method\n\t\t//--------------------------------------------------------------------------------------\n\t\tvoid _IJavaInterface::InitCallableStaticMethod(std::string instrClassName, std::string instrMethodName, std::string instrSignature)\n\t\t{\n\t\t\tJNIEnv* pEnv = GetJNIEnvironmentPtr();\n\n\t\t\tMethodReference ref;\n\t\t\tjclass javaInterfaceClass = pEnv->FindClass(instrClassName.c_str());\n\t\t\tref.mClassID = static_cast<jclass>(pEnv->NewGlobalRef(javaInterfaceClass));\n\t\t\tref.mMethodID = pEnv->GetStaticMethodID(ref.mClassID, instrMethodName.c_str(), instrSignature.c_str());\n\t\t\tpEnv->DeleteLocalRef(javaInterfaceClass);\n\n\t\t\tif (ref.mMethodID == 0 || ref.mClassID == 0)\n\t\t\t\tCS_LOG_ERROR(\"Could not get method and class ID\\nClassname \\\"\"+instrClassName+\"\\\"\\nMethodname \\\"\"+instrMethodName+\"\\\"\\nSigniture \\\"\"+instrSignature+\"\\\"\");\n\n\t\t\tif (mStaticMethodRefMap.find(instrMethodName) == mStaticMethodRefMap.end())\n\t\t\t\tmStaticMethodRefMap[instrMethodName] = ref;\n\t\t\telse\n\t\t\t\tCS_LOG_ERROR(\"Could not add method reference - method name already exists.\");\n\t\t}\n\n\t\t//--------------------------------------------------------------------------------------\n\t\t/// Get Static Method Reference\n\t\t//--------------------------------------------------------------------------------------\n\t\tMethodReference _IJavaInterface::GetStaticMethodReference(std::string instrMethodName)\n\t\t{\n\t\t\tMethodReference ref;\n\t\t\tref.mClassID = 0;\n\t\t\tref.mMethodID = 0;\n\n\t\t\tif (mStaticMethodRefMap.find(instrMethodName) != mStaticMethodRefMap.end())\n\t\t\t\tref = mStaticMethodRefMap[instrMethodName];\n\t\t\telse\n\t\t\t\tCS_LOG_ERROR(\"Could not find method reference. Have you initialised it in the Java Interface?\");\n\n\t\t\treturn ref;\n\t\t}\n\t\t//--------------------------------------------------------------------------------------\n\t\t/// Create JString From STDString\n\t\t//--------------------------------------------------------------------------------------\n\t\tjstring _IJavaInterface::CreateJStringFromSTDString(std::string instrString)\n\t\t{\n\t\t\tJNIEnv* pEnv = GetJNIEnvironmentPtr();\n\t\t\tif (pEnv != nullptr)\n\t\t\t{\n\t\t\t\tjstring jstrNewString = pEnv->NewStringUTF(instrString.c_str());\n\t\t\t\treturn jstrNewString;\n\t\t\t}\n\t\t\treturn nullptr;\n\t\t}\n\t\t//--------------------------------------------------------------------------------------\n\t\t/// Create STDString From JString\n\t\t//--------------------------------------------------------------------------------------\n\t\tstd::string _IJavaInterface::CreateSTDStringFromJString(jstring injstrString)\n\t\t{\n\t\t\tJNIEnv* pEnv = GetJNIEnvironmentPtr();\n\t\t\tif (pEnv != nullptr && injstrString != nullptr)\n\t\t\t{\n\t\t\t\tconst char * cString = pEnv->GetStringUTFChars(injstrString, JNI_FALSE);\n\t\t\t\tif (cString != nullptr)\n\t\t\t\t{\n\t\t\t\t\tstd::string stdString = std::string(cString);\n\t\t\t\t\tpEnv->ReleaseStringUTFChars(injstrString, cString);\n\t\t\t\t\treturn stdString;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn \"\";\n\t\t}\n\t\t//--------------------------------------------------------------------------------------\n\t\t/// Create STDString From JByteArray\n\t\t//--------------------------------------------------------------------------------------\n\t\tstd::string _IJavaInterface::CreateSTDStringFromJByteArray(jbyteArray injabyArray, int indwLength)\n\t\t{\n\t\t\tif (injabyArray != nullptr && indwLength > 0)\n\t\t\t{\n\t\t\t\tJNIEnv* pEnv = GetJNIEnvironmentPtr();\n\t\t\t\tif (pEnv != nullptr)\n\t\t\t\t{\n\t\t\t\t\tjbyte* pBytes = pEnv->GetByteArrayElements(injabyArray, JNI_FALSE);\n\t\t\t\t\tif (pBytes != nullptr)\n\t\t\t\t\t{\n\t\t\t\t\t\tstd::string strOutput((const char*)pBytes, indwLength);\n\t\t\t\t\t\tpEnv->ReleaseByteArrayElements(injabyArray, pBytes, 0);\n\t\t\t\t\t\treturn strOutput;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn \"\";\n\t\t}\n\t\t//--------------------------------------------------------------------------------------\n\t\t/// Get Int Element From JArray\n\t\t//--------------------------------------------------------------------------------------\n\t\ts32 _IJavaInterface::GetIntElementFromJArray(jintArray injadwArray, u32 inudwIndex)\n\t\t{\n\t\t\tJNIEnv* pEnv = GetJNIEnvironmentPtr();\n\t\t\tif (pEnv != nullptr && injadwArray != nullptr)\n\t\t\t{\n\t\t\t\tjint* pIntegers = pEnv->GetIntArrayElements(injadwArray, JNI_FALSE);\n\t\t\t\tif (pIntegers != nullptr)\n\t\t\t\t{\n\t\t\t\t\ts32 dwOutput = pIntegers[inudwIndex];\n\t\t\t\t\tpEnv->ReleaseIntArrayElements(injadwArray, pIntegers, 0);\n\t\t\t\t\treturn dwOutput;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn -1;\n\t\t}\n\t}\n}\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/JNI/Core/Java/_JavaInterface.h",
    "content": "//\n//  _JavaInterface.h\n//  ChilliSource\n//  Created by Ian Copland on 17/03/2011.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2011 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n\n#ifndef _CHILLISOURCE_PLATFORM_ANDROID_JAVAINTERFACE__JAVAINTERFACE_\n#define _CHILLISOURCE_PLATFORM_ANDROID_JAVAINTERFACE__JAVAINTERFACE_\n\n#include <ChilliSource/ChilliSource.h>\n\n#include <jni.h>\n#include <map>\n\nnamespace CSBackend\n{\n\tnamespace Android\n\t{\n\t\tstruct MethodReference\n\t\t{\n\t\t\tjmethodID mMethodID;\n\t\t\tjclass mClassID;\n\t\t};\n\n        //--------------------------------------------------------------------------------------\n        /// This is deprecated in favour of JavaClass.\n        //--------------------------------------------------------------------------------------\n\t\tclass _IJavaInterface\n\t\t{\n\t\t\t_IJavaInterface();\n\t\tpublic:\n\t\t\tvirtual ~_IJavaInterface();\n\n\t\t\t//--------------------------------------------------------------------------------------\n\t\t\t/// Get JNI Environment Ptr\n\t\t\t///\n\t\t\t///\treturns the jni enviroment pointer for the current thread. The value returned from\n\t\t\t/// this should NOT be stored as global or member data, as this will break thread safety\n\t\t\t///\n\t\t\t/// @return JNIEnv* returns a pointer to the jni environment.\n\t\t\t//--------------------------------------------------------------------------------------\n\t\t\tstatic JNIEnv* GetJNIEnvironmentPtr();\n\t\t\t//--------------------------------------------------------------------------------------\n\t\t\t/// Get Java VM\n\t\t\t///\n\t\t\t/// @return VM\n\t\t\t//--------------------------------------------------------------------------------------\n\t\t\tstatic JavaVM* GetJavaVM();\n\t\t\t//--------------------------------------------------------------------------------------\n\t\t\t/// Get Static Method Reference\n\t\t\t///\n\t\t\t/// Returns the method id for the specfied java method name\n\t\t\t///\n\t\t\t/// @param std::string method name.\n\t\t\t/// @return the method reference.\n\t\t\t//--------------------------------------------------------------------------------------\n\t\t\tstatic MethodReference GetStaticMethodReference(std::string instrMethodName);\n\t\t\t//--------------------------------------------------------------------------------------\n\t\t\t/// Create JString From STDString\n\t\t\t///\n\t\t\t/// Converts a std string into a JString.\n\t\t\t///\n\t\t\t/// @param the std::string\n\t\t\t/// @return the new java string\n\t\t\t//--------------------------------------------------------------------------------------\n\t\t\tstatic jstring CreateJStringFromSTDString(std::string instrString);\n\t\t\t//--------------------------------------------------------------------------------------\n\t\t\t/// Create STDString From JString\n\t\t\t///\n\t\t\t/// Takes a java string and converts it to a std::string\n\t\t\t///\n\t\t\t/// @param the java string\n\t\t\t/// @return the new std::string\n\t\t\t//--------------------------------------------------------------------------------------\n\t\t\tstatic std::string CreateSTDStringFromJString(jstring injstrString);\n\t\t\t//--------------------------------------------------------------------------------------\n\t\t\t/// Create STDString From JByteArray\n\t\t\t///\n\t\t\t/// Takes a java byte array and converts it to a std::string\n\t\t\t///\n\t\t\t/// @param the java byte array\n\t\t\t/// @return the new std::string\n\t\t\t//--------------------------------------------------------------------------------------\n\t\t\tstatic std::string CreateSTDStringFromJByteArray(jbyteArray injabyArray, int indwLength);\n\t\t\t//--------------------------------------------------------------------------------------\n\t\t\t/// Get Int Element From JArray\n\t\t\t///\n\t\t\t/// Returns the value at the requested index in the j-array\n\t\t\t///\n\t\t\t/// @param the java array.\n\t\t\t/// @param the index.\n\t\t\t/// @return the integer value.\n\t\t\t//--------------------------------------------------------------------------------------\n\t\t\tstatic s32 GetIntElementFromJArray(jintArray injadwArray, u32 inudwIndex);\n\t\tprotected:\n\t\t\t//--------------------------------------------------------------------------------------\n\t\t\t/// Init Callable Static Method\n\t\t\t///\n\t\t\t/// Initialises a method such that it can be called easier later on. This also means\n\t\t\t/// That the performance hit from getting method IDs is not potentially taken at\n\t\t\t///\trun-time.\n\t\t\t///\n\t\t\t/// @param std::string class name.\n\t\t\t/// @param std::string method name.\n\t\t\t/// @param std::string the method signature\n\t\t\t//--------------------------------------------------------------------------------------\n\t\t\tstatic void InitCallableStaticMethod(std::string instrClassName, std::string instrMethodName, std::string instrSignature);\n\n\t\t\tstatic std::map<std::string, MethodReference> mStaticMethodRefMap;\n\t\t\tstatic JavaVM* mspJavaVM;\n\t\t};\n\t}\n}\n\n#endif\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/JNI/Core/Notification/LocalNotificationJavaInterface.cpp",
    "content": "//\n//  LocalNotificationJavaInterface.cpp\n//  ChilliSource\n//  Created by Steven Hendrie on 13/12/2011.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2011 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n\n#include <CSBackend/Platform/Android/Main/JNI/Core/Notification/LocalNotificationJavaInterface.h>\n\n#include <CSBackend/Platform/Android/Main/JNI/Core/Java/JavaInterfaceManager.h>\n#include <CSBackend/Platform/Android/Main/JNI/Core/Java/JavaUtils.h>\n#include <CSBackend/Platform/Android/Main/JNI/Core/Notification/LocalNotificationSystem.h>\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/Notification/Notification.h>\n#include <ChilliSource/Core/String/StringParser.h>\n#include <ChilliSource/Core/Threading/TaskScheduler.h>\n\n#include <jni.h>\n\nextern \"C\"\n{\n\tvoid Java_com_chilliworks_chillisource_core_LocalNotificationNativeInterface_nativeOnNotificationReceived(JNIEnv* in_environment, jobject in_this, s32 in_id, jobjectArray in_keys, jobjectArray in_values, s32 in_priority);\n}\n\nvoid Java_com_chilliworks_chillisource_core_LocalNotificationNativeInterface_nativeOnNotificationReceived(JNIEnv* in_environment, jobject in_this, s32 in_id, jobjectArray in_keys, jobjectArray in_values, s32 in_priority)\n{\n\tChilliSource::ParamDictionary params;\n\n\tu32 numParams = in_environment->GetArrayLength(in_keys);\n\tfor(u32 keyIndex = 0; keyIndex < numParams; ++keyIndex)\n\t{\n\t\tjstring keyJava = (jstring)in_environment->GetObjectArrayElement(in_keys, keyIndex);\n\t\tjstring valueJava =  (jstring)in_environment->GetObjectArrayElement(in_values, keyIndex);\n\n\t\tstd::string key = CSBackend::Android::JavaUtils::CreateSTDStringFromJString(keyJava);\n\t\tstd::string value = CSBackend::Android::JavaUtils::CreateSTDStringFromJString(valueJava);\n\n\t\tparams.SetValue(key, value);\n\n\t\tin_environment->DeleteLocalRef(keyJava);\n\t\tin_environment->DeleteLocalRef(valueJava);\n\t}\n\n\tChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_mainThread, [=](const ChilliSource::TaskContext&)\n\t{\n\t\tCSBackend::Android::LocalNotificationSystem* localNotificationSystem = ChilliSource::Application::Get()->GetSystem<CSBackend::Android::LocalNotificationSystem>();\n\t\tif (localNotificationSystem != nullptr)\n\t\t{\n\t\t\tlocalNotificationSystem->OnNotificationReceived(static_cast<ChilliSource::Notification::ID>(in_id), params, static_cast<ChilliSource::Notification::Priority>(in_priority));\n\t\t}\n\t});\n}\n\nnamespace CSBackend\n{\n\tnamespace Android\n\t{\n\t\tCS_DEFINE_NAMEDTYPE(LocalNotificationJavaInterface);\n\t\t//--------------------------------------------------------\n\t\t//--------------------------------------------------------\n\t\tLocalNotificationJavaInterface::LocalNotificationJavaInterface()\n\t\t{\n\t\t\tCreateNativeInterface(\"com/chilliworks/chillisource/core/LocalNotificationNativeInterface\");\n\t\t\tCreateMethodReference(\"scheduleNotificationForTime\", \"(I[Ljava/lang/String;[Ljava/lang/String;JI)V\");\n\t\t\tCreateMethodReference(\"getNotifications\", \"()[Lcom/chilliworks/chillisource/core/LocalNotification;\");\n\t\t\tCreateMethodReference(\"cancelByID\",\"(I)V\");\n\t\t\tCreateMethodReference(\"cancelAll\",\"()V\");\n\t\t}\n\t\t//--------------------------------------------------------\n\t\t//--------------------------------------------------------\n\t\tbool LocalNotificationJavaInterface::IsA(ChilliSource::InterfaceIDType in_interfaceId) const\n\t\t{\n\t\t\treturn (in_interfaceId == LocalNotificationJavaInterface::InterfaceID);\n\t\t}\n\t\t//--------------------------------------------------------\n\t\t//--------------------------------------------------------\n\t\tvoid LocalNotificationJavaInterface::ScheduleNotificationForTime(ChilliSource::Notification::ID in_id, const ChilliSource::ParamDictionary& in_params, TimeIntervalSecs in_time, ChilliSource::Notification::Priority in_priority)\n\t\t{\n\t\t\tJNIEnv* environment = JavaInterfaceManager::GetSingletonPtr()->GetJNIEnvironmentPtr();\n\n\t\t\t//Convert Trigger time from seconds to milliseconds as this is what will be used on the Android end;\n\t\t\tu64 triggerTime = in_time * 1000;\n\n\t\t\tu32 id = (u32)in_id;\n\t\t\tu32 priority = (u32)in_priority;\n\n\t\t\t//Create 2 arrays from ParamDictionary as this is easier to pass to Java\n\t\t\tjclass stringClass = environment->FindClass(\"java/lang/String\");\n\t\t\tjstring emptyString = environment->NewStringUTF(\"\");\n\t\t\tjobjectArray keys = environment->NewObjectArray(in_params.size(), stringClass, emptyString);\n\t\t\tjobjectArray values = environment->NewObjectArray(in_params.size(), stringClass, emptyString);\n\n\t\t\tu32 paramCount = 0;\n\t\t\tfor(auto it = in_params.begin(); it != in_params.end(); ++it)\n\t\t\t{\n\t\t\t\tjstring key = JavaUtils::CreateJStringFromSTDString(it->first);\n\t\t\t\tjstring value = JavaUtils::CreateJStringFromSTDString(it->second);\n\t\t\t\tenvironment->SetObjectArrayElement(keys, paramCount, key);\n\t\t\t\tenvironment->SetObjectArrayElement(values, paramCount, value);\n\t\t\t\tenvironment->DeleteLocalRef(key);\n\t\t\t\tenvironment->DeleteLocalRef(value);\n\t\t\t\tparamCount++;\n\t\t\t}\n\n\t\t\tenvironment->CallVoidMethod(GetJavaObject(), GetMethodID(\"scheduleNotificationForTime\"), id, keys, values, triggerTime, priority);\n\n\t\t\t//delete local references\n\t\t\tenvironment->DeleteLocalRef(stringClass);\n\t\t\tenvironment->DeleteLocalRef(emptyString);\n\t\t\tenvironment->DeleteLocalRef(keys);\n\t\t\tenvironment->DeleteLocalRef(values);\n\t\t}\n\t\t//--------------------------------------------------------\n\t\t//--------------------------------------------------------\n\t\tvoid LocalNotificationJavaInterface::GetScheduledNotifications(std::vector<ChilliSource::NotificationCSPtr>& out_notifications, TimeIntervalSecs in_time, TimeIntervalSecs in_period) const\n\t\t{\n\t\t\tJNIEnv* environment = JavaInterfaceManager::GetSingletonPtr()->GetJNIEnvironmentPtr();\n\t\t\tjobjectArray notificationsJNI = static_cast<jobjectArray>(environment->CallObjectMethod(GetJavaObject(), GetMethodID(\"getNotifications\")));\n\n\t\t\ts32 length = environment->GetArrayLength(notificationsJNI);\n\t\t\tfor (s32 notificationIndex = 0; notificationIndex < length; ++notificationIndex)\n\t\t\t{\n\t\t\t\tjobject notificationJNI = environment->GetObjectArrayElement(notificationsJNI, notificationIndex);\n\t\t\t\tjclass notificationClassJNI = environment->GetObjectClass(notificationJNI);\n\n\t\t\t\t//Time\n\t\t\t\tjmethodID timeMethodId = environment->GetMethodID(notificationClassJNI, \"getTime\", \"()J\");\n\t\t\t\tTimeIntervalSecs time = static_cast<TimeIntervalSecs>(environment->CallLongMethod(notificationJNI, timeMethodId) / 1000);\n\n\t\t\t\tif (time > in_time && time < in_time + in_period)\n\t\t\t\t{\n\t\t\t\t\tChilliSource::NotificationSPtr notification(new ChilliSource::Notification());\n\n\t\t\t\t\t//Notification Id\n\t\t\t\t\tjmethodID idMethodId = environment->GetMethodID(notificationClassJNI, \"getNotificationId\", \"()I\");\n\t\t\t\t\tnotification->m_id = static_cast<ChilliSource::Notification::ID>(environment->CallIntMethod(notificationJNI, idMethodId));\n\n\t\t\t\t\t//Priority\n\t\t\t\t\tjmethodID priorityMethodId = environment->GetMethodID(notificationClassJNI, \"getPriority\", \"()I\");\n\t\t\t\t\tnotification->m_priority = static_cast<ChilliSource::Notification::Priority>(environment->CallIntMethod(notificationJNI, priorityMethodId));\n\n\t\t\t\t\t//params length\n\t\t\t\t\tjmethodID paramsLengthMethodId = environment->GetMethodID(notificationClassJNI, \"getNumParams\", \"()I\");\n\t\t\t\t\ts32 paramsLength = environment->CallIntMethod(notificationJNI, paramsLengthMethodId);\n\n\t\t\t\t\t//params\n\t\t\t\t\tjclass stringClassJNI = environment->FindClass(\"java/lang/String\");\n\t\t\t\t\tjobjectArray keysJNI = environment->NewObjectArray(paramsLength, stringClassJNI, nullptr);\n\t\t\t\t\tjobjectArray valuesJNI = environment->NewObjectArray(paramsLength, stringClassJNI, nullptr);\n\t\t\t\t\tenvironment->DeleteLocalRef(stringClassJNI);\n\n\t\t\t\t\tjmethodID paramsMethodId = environment->GetMethodID(notificationClassJNI, \"getParams\", \"([Ljava/lang/String;[Ljava/lang/String;)V\");\n\t\t\t\t\tenvironment->CallVoidMethod(notificationJNI, paramsMethodId, keysJNI, valuesJNI);\n\n\t\t\t\t\t//convert the params to param dictionary\n\t\t\t\t\tfor (s32 paramIndex = 0; paramIndex < paramsLength; ++paramIndex)\n\t\t\t\t\t{\n\t\t\t\t\t\tjstring keyJNI = static_cast<jstring>(environment->GetObjectArrayElement(keysJNI, paramIndex));\n\t\t\t\t\t\tjstring valueJNI = static_cast<jstring>(environment->GetObjectArrayElement(valuesJNI, paramIndex));\n\n\t\t\t\t\t\tstd::string key = JavaUtils::CreateSTDStringFromJString(keyJNI);\n\t\t\t\t\t\tstd::string value = JavaUtils::CreateSTDStringFromJString(valueJNI);\n\n\t\t\t\t\t\tnotification->m_params.SetValue(key, value);\n\n\t\t\t\t\t\tenvironment->DeleteLocalRef(keyJNI);\n\t\t\t\t\t\tenvironment->DeleteLocalRef(valueJNI);\n\t\t\t\t\t}\n\n\t\t\t\t\tenvironment->DeleteLocalRef(keysJNI);\n\t\t\t\t\tenvironment->DeleteLocalRef(valuesJNI);\n\n\t\t\t\t\tout_notifications.push_back(notification);\n\t\t\t\t}\n\n\t\t\t\tenvironment->DeleteLocalRef(notificationClassJNI);\n\t\t\t\tenvironment->DeleteLocalRef(notificationJNI);\n\t\t\t}\n\n\t\t\tenvironment->DeleteLocalRef(notificationsJNI);\n\t\t}\n\t\t//--------------------------------------------------------\n\t\t//--------------------------------------------------------\n\t\tvoid LocalNotificationJavaInterface::CancelByID(u32 in_id)\n\t\t{\n\t\t\tJNIEnv* environment = JavaInterfaceManager::GetSingletonPtr()->GetJNIEnvironmentPtr();\n\t\t\tenvironment->CallVoidMethod(GetJavaObject(), GetMethodID(\"cancelByID\"), in_id);\n\t\t}\n\t\t//--------------------------------------------------------\n\t\t//--------------------------------------------------------\n\t\tvoid LocalNotificationJavaInterface::CancelAll()\n\t\t{\n\t\t\tJNIEnv* environment = JavaInterfaceManager::GetSingletonPtr()->GetJNIEnvironmentPtr();\n\t\t\tenvironment->CallVoidMethod(GetJavaObject(), GetMethodID(\"cancelAll\"));\n\t\t}\n\t}\n}\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/JNI/Core/Notification/LocalNotificationJavaInterface.h",
    "content": "//\n//  LocalNotificationJavaInterface.h\n//  ChilliSource\n//  Created by Steven Hendrie on 13/12/2011.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2011 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n\n#ifndef _CSBACKEND_PLATFORM_ANDROID_CORE_NOTIFICATION_LOCALNOTIFCATIONSJAVAINTERFACE_H_\n#define _CSBACKEND_PLATFORM_ANDROID_CORE_NOTIFICATION_LOCALNOTIFCATIONSJAVAINTERFACE_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <CSBackend/Platform/Android/Main/JNI/ForwardDeclarations.h>\n#include <CSBackend/Platform/Android/Main/JNI/Core/Java/JavaInterface.h>\n#include <ChilliSource/Core/Notification/Notification.h>\n\nnamespace CSBackend\n{\n\tnamespace Android\n\t{\n\t\t//---------------------------------------------------------\n\t\t/// A Java Interface for calls to the Alarm Manager.\n\t\t///\n\t\t/// @author Steven Hendrie\n\t\t//---------------------------------------------------------\n\t\tclass LocalNotificationJavaInterface : public IJavaInterface\n\t\t{\n\t\tpublic:\n\t\t\tCS_DECLARE_NAMEDTYPE(LocalNotificationJavaInterface);\n\t\t\t//---------------------------------------------------\n\t\t\t/// Constructor\n\t\t\t///\n\t\t\t/// @author Steven Hendrie\n\t\t\t//---------------------------------------------------\n\t\t\tLocalNotificationJavaInterface();\n\t\t\t//---------------------------------------------------\n\t\t\t/// @author Steven Hendrie\n\t\t\t///\n\t\t\t/// @param The interface ID to check against.\n\t\t\t/// @return whether or not this object implements the\n\t\t\t/// given interface.\n\t\t\t//---------------------------------------------------\n\t\t\tbool IsA(ChilliSource::InterfaceIDType in_interfaceId) const override;\n\t\t\t//---------------------------------------------------\n\t\t\t/// Schedules a notification to be displayed to the user\n\t\t\t///\n\t\t\t/// @author Steven Hendrie\n\t\t\t///\n\t\t\t/// @param The notification id\n\t\t\t/// @param The notification params.\n\t\t\t/// @param Time in seconds at which it should trigger.\n\t\t\t/// @param [Optional] The notification priority. Defaults\n\t\t\t/// to standard priority.\n\t\t\t//---------------------------------------------------\n\t\t\tvoid ScheduleNotificationForTime(ChilliSource::Notification::ID in_id, const ChilliSource::ParamDictionary& in_params, TimeIntervalSecs in_time, ChilliSource::Notification::Priority in_priority);\n\t\t\t//--------------------------------------------------------\n\t\t\t/// Builds a list of all notifications currently scheduled\n\t\t\t/// within the given time period.\n\t\t\t///\n\t\t\t/// @author Ian Copland\n\t\t\t///\n\t\t\t/// @param [Out] The list of notifications.\n\t\t\t/// @param The start time.\n\t\t\t/// @param The time period.\n\t\t\t//--------------------------------------------------------\n\t\t\tvoid GetScheduledNotifications(std::vector<ChilliSource::NotificationCSPtr>& out_notifications, TimeIntervalSecs in_time, TimeIntervalSecs in_period) const;\n\t\t\t//---------------------------------------------------\n\t\t\t/// Prevent any notifications with given ID type from\n\t\t\t/// firing\n\t\t\t///\n\t\t\t/// @author Steven Hendrie\n\t\t\t///\n\t\t\t/// @param ID type\n\t\t\t//---------------------------------------------------\n\t\t\tvoid CancelByID(ChilliSource::Notification::ID in_id);\n\t\t\t//---------------------------------------------------\n\t\t\t/// Terminate all currently scheduled notifications.\n\t\t\t///\n\t\t\t/// @author Steven Hendrie\n\t\t\t//---------------------------------------------------\n\t\t\tvoid CancelAll();\n\t\t};\n\t}\n}\n\n#endif\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/JNI/Core/Notification/LocalNotificationSystem.cpp",
    "content": "//\n//  LocalNotificationSystem.cpp\n//  ChilliSource\n//  Created by Steven Hendrie on 13/12/2011.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2011 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n\n#include <CSBackend/Platform/Android/Main/JNI/Core/Notification/LocalNotificationSystem.h>\n\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/Base/PlatformSystem.h>\n#include <ChilliSource/Core/Threading/TaskScheduler.h>\n#include <CSBackend/Platform/Android/Main/JNI/Core/Java/JavaInterfaceManager.h>\n#include <CSBackend/Platform/Android/Main/JNI/Core/Notification/LocalNotificationJavaInterface.h>\n\nnamespace CSBackend\n{\n\tnamespace Android\n\t{\n\t\tCS_DEFINE_NAMEDTYPE(LocalNotificationSystem);\n        //--------------------------------------------------\n        //--------------------------------------------------\n\t\tLocalNotificationSystem::LocalNotificationSystem()\n\t\t: m_enabled(true)\n\t\t{\n        \t//get the media player java interface or create it if it doesn't yet exist.\n\t\t\tm_localNotificationJI = JavaInterfaceManager::GetSingletonPtr()->GetJavaInterface<LocalNotificationJavaInterface>();\n        \tif (m_localNotificationJI == nullptr)\n        \t{\n        \t\tm_localNotificationJI = LocalNotificationJavaInterfaceSPtr(new LocalNotificationJavaInterface());\n        \t\tJavaInterfaceManager::GetSingletonPtr()->AddJavaInterface(m_localNotificationJI);\n        \t}\n\t\t}\n        //--------------------------------------------------\n        //--------------------------------------------------\n        bool LocalNotificationSystem::IsA(ChilliSource::InterfaceIDType in_interfaceId) const\n        {\n        \treturn (LocalNotificationSystem::InterfaceID == in_interfaceId || ChilliSource::LocalNotificationSystem::InterfaceID == in_interfaceId);\n        }\n\t\t//--------------------------------------------------\n\t\t//--------------------------------------------------\n\t\tvoid LocalNotificationSystem::SetEnabled(bool in_enabled)\n        {\n            CS_ASSERT(CS::Application::Get()->GetTaskScheduler()->IsMainThread(), \"Attempted to enable/disable notification system outside of main thread.\");\n            m_enabled = in_enabled;\n\n            if (m_enabled == false)\n            {\n                CancelAll();\n            }\n        }\n\t\t//--------------------------------------------------\n\t\t//--------------------------------------------------\n\t\tvoid LocalNotificationSystem::ScheduleNotificationForTime(ChilliSource::Notification::ID in_id, const ChilliSource::ParamDictionary& in_params, TimeIntervalSecs in_time, ChilliSource::Notification::Priority in_priority)\n        {\n            CS_ASSERT(CS::Application::Get()->GetTaskScheduler()->IsMainThread(), \"Attempted to schedule notification outside of main thread.\");\n            if (m_enabled == true)\n            {\n                m_localNotificationJI->ScheduleNotificationForTime(in_id, in_params, in_time, in_priority);\n            }\n        }\n\t\t//--------------------------------------------------\n\t\t//--------------------------------------------------\n\t\tvoid LocalNotificationSystem::GetScheduledNotifications(const GetScheduledNotificationsDelegate& in_delegate, TimeIntervalSecs in_time, TimeIntervalSecs in_period) const\n\t\t{\n            CS_ASSERT(CS::Application::Get()->GetTaskScheduler()->IsMainThread(), \"Attempted to retrieve scheduled notifications outside of main thread.\");\n            std::vector<ChilliSource::NotificationCSPtr> notificationList;\n            m_localNotificationJI->GetScheduledNotifications(notificationList, in_time, in_period);\n            in_delegate(notificationList);\n\t\t}\n\t\t//--------------------------------------------------\n\t\t//--------------------------------------------------\n\t\tvoid LocalNotificationSystem::CancelByID(ChilliSource::Notification::ID in_id)\n\t\t{\n            CS_ASSERT(CS::Application::Get()->GetTaskScheduler()->IsMainThread(), \"Attempted to cancel notification outside of main thread.\");\n            m_localNotificationJI->CancelByID(in_id);\n\t\t}\n\t\t//--------------------------------------------------\n\t\t//--------------------------------------------------\n\t\tvoid LocalNotificationSystem::CancelAll()\n\t\t{\n            CS_ASSERT(CS::Application::Get()->GetTaskScheduler()->IsMainThread(), \"Attempted to cancel all notifications outside of main thread.\");\n            m_localNotificationJI->CancelAll();\n\t\t}\n        //--------------------------------------------------\n        //--------------------------------------------------\n\t\tChilliSource::IConnectableEvent<ChilliSource::LocalNotificationSystem::ReceivedDelegate>& LocalNotificationSystem::GetReceivedEvent()\n\t\t{\n            CS_ASSERT(CS::Application::Get()->GetTaskScheduler()->IsMainThread(), \"Attempted to get received event outside of main thread.\");\n            return m_recievedEvent;\n\t\t}\n\t\t//--------------------------------------------------\n\t\t//--------------------------------------------------\n\t\tvoid LocalNotificationSystem::OnNotificationReceived(ChilliSource::Notification::ID in_id, const ChilliSource::ParamDictionary& in_params, ChilliSource::Notification::Priority in_priority)\n\t\t{\n            CS_ASSERT(CS::Application::Get()->GetTaskScheduler()->IsMainThread(), \"Attempted to handle received notification outside of main thread.\");\n            ChilliSource::NotificationSPtr notification = std::make_shared<ChilliSource::Notification>();\n            notification->m_id = in_id;\n            notification->m_params = in_params;\n            notification->m_priority = in_priority;\n            m_recievedEvent.NotifyConnections(notification);\n\t\t}\n\t}\n}\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/JNI/Core/Notification/LocalNotificationSystem.h",
    "content": "//\n//  LocalNotificationSystem.h\n//  ChilliSource\n//  Created by Steven Hendrie on 13/12/2011.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2011 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n\n#ifndef _CSBACKEND_PLATFORM_ANDROID_CORE_NOTIFICATION_LOCALNOTIFICATIONSYSTEM_H_\n#define _CSBACKEND_PLATFORM_ANDROID_CORE_NOTIFICATION_LOCALNOTIFICATIONSYSTEM_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Notification/LocalNotificationSystem.h>\n#include <CSBackend/Platform/Android/Main/JNI/ForwardDeclarations.h>\n\nnamespace CSBackend\n{\n\tnamespace Android\n\t{\n\t\t//--------------------------------------------------------\n\t\t/// Android backend for the local notification system\n\t\t///\n        /// The methods in this class aren't thread-safe, and \n        /// must be accessed from the main thread.\n        ///\n\t\t/// @author Steven Hendrie\n\t\t//--------------------------------------------------------\n\t\tclass LocalNotificationSystem : public ChilliSource::LocalNotificationSystem\n\t\t{\n\t\tpublic:\n\t\t\tCS_DECLARE_NAMEDTYPE(LocalNotificationSystem);\n            //---------------------------------------------------\n            /// @author Ian Copland\n            ///\n\t\t\t/// @param The interface ID to check against.\n            /// @return Whether this implements the passed in\n\t\t\t/// interface id.\n            //--------------------------------------------------\n            bool IsA(ChilliSource::InterfaceIDType in_interfaceId) const override;\n\t\t\t//--------------------------------------------------\n\t\t\t/// Enables and disables addition of local notifications.\n\t\t\t/// All existing notifications will be cancelled\n\t\t\t/// when this is disabled. This is enabled by default.\n            /// \n\t\t\t/// @author Ian Copland\n\t\t\t///\n\t\t\t/// @param Whether or not to enable the scheduling\n\t\t\t/// of app notifications.\n\t\t\t//---------------------------------------------------\n\t\t\tvoid SetEnabled(bool in_enabled) override;\n\t\t\t//---------------------------------------------------\n\t\t\t/// Schedules a Local Notifcation which should fire\n\t\t\t/// at the given time. A Local Notification uses\n\t\t\t/// the system specfic notification alarms and can\n\t\t\t/// be received even if it was scheduled during a\n\t\t\t/// previous instance of the application.\n\t\t\t///\n\t\t\t/// @author Ian Copland\n\t\t\t///\n\t\t\t/// @param The notification id\n\t\t\t/// @param The notification params.\n\t\t\t/// @param Time in seconds at which it should trigger.\n\t\t\t/// @param [Optional] The notification priority. Defaults\n\t\t\t/// to standard priority.\n\t\t\t//---------------------------------------------------\n\t\t\tvoid ScheduleNotificationForTime(ChilliSource::Notification::ID in_id, const ChilliSource::ParamDictionary& in_params, TimeIntervalSecs in_time, ChilliSource::Notification::Priority in_priority = ChilliSource::Notification::Priority::k_standard) override;\n            //--------------------------------------------------------\n            /// Generates a list of all notifications that are currently\n            /// scheduled. Because the list cannot be immediately\n            /// calculated, the result is returned through the provided\n            /// delegate when ready.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param The delegate function to execute.\n            /// @param [Optional] The start time.\n            /// @param [Optional] The end time.\n            //--------------------------------------------------------\n\t\t\tvoid GetScheduledNotifications(const GetScheduledNotificationsDelegate& in_delegate, TimeIntervalSecs in_time = 0, TimeIntervalSecs in_period = std::numeric_limits<TimeIntervalSecs>::max()) const override;\n\t\t\t//-------------------------------------------------------\n\t\t\t/// Prevent any notifications with given ID type from firing\n\t\t\t///\n\t\t\t/// @author Steven Hendrie\n\t\t\t///\n\t\t\t/// @param ID type\n\t\t\t//------------------------------------------------------\n\t\t\tvoid CancelByID(ChilliSource::Notification::ID in_id) override;\n\t\t\t//------------------------------------------------------\n\t\t\t/// @author Steven Hendrie\n\t\t\t///\n\t\t\t/// Terminate all currently scheduled notifications\n\t\t\t//-----------------------------------------------------\n\t\t\tvoid CancelAll() override;\n            //--------------------------------------------------\n            /// @author Ian Copland\n            ///\n            /// @return An event that can be used to listen for\n            /// new notifications being recieved.\n            //---------------------------------------------------\n            ChilliSource::IConnectableEvent<ReceivedDelegate>& GetReceivedEvent() override;\n\t\t\t//-----------------------------------------------------\n\t\t\t/// Called when game receives a local notification.\n\t\t\t///\n\t\t\t/// @author Steven Hendrie\n            ///\n            /// @param The notification ID\n            /// @param The notification params.\n            /// @param The notification priority.\n\t\t\t//----------------------------------------------------\n\t\t\tvoid OnNotificationReceived(ChilliSource::Notification::ID in_id, const ChilliSource::ParamDictionary& in_params, ChilliSource::Notification::Priority in_priority);\n\t\tprivate:\n            friend ChilliSource::LocalNotificationSystemUPtr ChilliSource::LocalNotificationSystem::Create();\n            //-------------------------------------------------------\n            /// Private constructor to force use of factory method\n            ///\n            /// @author S Downie\n            //-------------------------------------------------------\n            LocalNotificationSystem();\n\n\t\tprivate:\n            bool m_enabled;\n            ChilliSource::Event<ReceivedDelegate> m_recievedEvent;\n\t\t\tLocalNotificationJavaInterfaceSPtr m_localNotificationJI;\n\t\t};\n\t}\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/JNI/ForwardDeclarations.h",
    "content": "//\n//  ForwardDeclarations.h\n//  ChilliSource\n//  Created by Ian Copland on 09/08/2012.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2012 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n\n#ifndef _CSBACKEND_PLATFORM_ANDROID_FORWARDDECLARATIONS_H_\n#define _CSBACKEND_PLATFORM_ANDROID_FORWARDDECLARATIONS_H_\n\n#include <ChilliSource/Core/Base/StandardMacros.h>\n\n#include <memory>\n\nnamespace CSBackend\n{\n\tnamespace Android\n\t{\n\t\t//------------------------------------------------------\n\t\t/// Core\n\t\t//------------------------------------------------------\n\t\tCS_FORWARDDECLARE_CLASS(ZippedCkBankLoader);\n\t\t//------------------------------------------------------\n\t\t/// Core\n\t\t//------------------------------------------------------\n\t\tCS_FORWARDDECLARE_CLASS(JavaClass);\n\t\tCS_FORWARDDECLARE_CLASS(JavaClassDef);\n\t\tCS_FORWARDDECLARE_CLASS(JavaStaticClass);\n\t\tCS_FORWARDDECLARE_CLASS(JavaStaticClassDef);\n\t\tCS_FORWARDDECLARE_CLASS(JavaSystem);\n\t\tCS_FORWARDDECLARE_CLASS(JavaVirtualMachine);\n\t\tCS_FORWARDDECLARE_CLASS(JavaInterfaceManager);\n\t\tCS_FORWARDDECLARE_CLASS(IJavaInterface);\n\t\tCS_FORWARDDECLARE_CLASS(CoreJavaInterface);\n\t\tCS_FORWARDDECLARE_CLASS(DeviceJavaInterface);\n\t\tCS_FORWARDDECLARE_CLASS(PlatformSystem);\n\t\tCS_FORWARDDECLARE_CLASS(DialogueBoxJavaInterface);\n\t\tCS_FORWARDDECLARE_CLASS(DialogueBoxSystem);\n\t\tCS_FORWARDDECLARE_CLASS(FileSystem);\n\t\tCS_FORWARDDECLARE_CLASS(ZippedFileSystem);\n\t\tCS_FORWARDDECLARE_CLASS(PngImage);\n\t\tCS_FORWARDDECLARE_CLASS(PNGImageProvider);\n\t\tCS_FORWARDDECLARE_CLASS(LocalNotificationJavaInterface);\n\t\tCS_FORWARDDECLARE_CLASS(LocalNotificationScheduler);\n        CS_FORWARDDECLARE_CLASS(Screen);\n\t\t//------------------------------------------------------\n\t\t/// Input\n\t\t//------------------------------------------------------\n\t\tCS_FORWARDDECLARE_CLASS(Accelerometer);\n\t\tCS_FORWARDDECLARE_CLASS(AccelerometerJavaInterface);\n\t\tCS_FORWARDDECLARE_CLASS(DeviceButtonSystem);\n\t\tCS_FORWARDDECLARE_CLASS(DeviceButtonJavaInterface);\n\t\tCS_FORWARDDECLARE_CLASS(Gyroscope);\n\t\tCS_FORWARDDECLARE_CLASS(GyroscopeJavaInterface);\n\t\tCS_FORWARDDECLARE_CLASS(PointerSystem);\n        CS_FORWARDDECLARE_CLASS(TextEntry);\n\t\tCS_FORWARDDECLARE_CLASS(TextEntryJavaInterface);\n\t\tCS_FORWARDDECLARE_CLASS(TouchInputJavaInterface);\n\t\t//------------------------------------------------------\n\t\t/// Networking\n\t\t//------------------------------------------------------\n\t\tCS_FORWARDDECLARE_CLASS(HttpRequest);\n\t\tCS_FORWARDDECLARE_CLASS(HttpRequestSystem);\n\t\t//------------------------------------------------------\n\t\t/// Social\n\t\t//------------------------------------------------------\n\t\tCS_FORWARDDECLARE_CLASS(EmailComposer);\n\t\tCS_FORWARDDECLARE_CLASS(EmailComposerJavaInterface);\n\t\t//------------------------------------------------------\n\t\t/// Video\n\t\t//------------------------------------------------------\n\t\tCS_FORWARDDECLARE_CLASS(VideoPlayerJavaInterface);\n\t\tCS_FORWARDDECLARE_CLASS(VideoPlayerActivity);\n\t\t//------------------------------------------------------\n\t\t/// Web\n\t\t//------------------------------------------------------\n\t\tCS_FORWARDDECLARE_CLASS(WebViewJavaInterface);\n\t\tCS_FORWARDDECLARE_CLASS(WebView);\n\t}\n}\n\n#endif\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/JNI/Input/Accelerometer/Accelerometer.cpp",
    "content": "//\n//  Accelerometer.cpp\n//  ChilliSource\n//  Created by Ian Copland on 10/06/2013.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2013 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n\n#include <CSBackend/Platform/Android/Main/JNI/Input/Accelerometer/Accelerometer.h>\n\n#include <CSBackend/Platform/Android/Main/JNI/Core/Java/JavaInterfaceManager.h>\n#include <CSBackend/Platform/Android/Main/JNI/Input/Accelerometer/AccelerometerJavaInterface.h>\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/Delegate/MakeDelegate.h>\n#include <ChilliSource/Core/Threading/TaskScheduler.h>\n\nnamespace CSBackend\n{\n\tnamespace Android\n\t{\n\t\tCS_DEFINE_NAMEDTYPE(Accelerometer);\n\t\t//------------------------------------------------\n\t\t//------------------------------------------------\n\t\tAccelerometer::Accelerometer()\n\t\t\t: m_isUpdating(false)\n\t\t{\n\t\t}\n\t\t//------------------------------------------------\n\t\t//------------------------------------------------\n\t\tbool Accelerometer::IsA(ChilliSource::InterfaceIDType in_interfaceId) const\n\t\t{\n\t\t\treturn (in_interfaceId == ChilliSource::Accelerometer::InterfaceID || in_interfaceId == Accelerometer::InterfaceID);\n\t\t}\n\t\t//----------------------------------------------------\n\t\t//----------------------------------------------------\n\t\tbool Accelerometer::IsUpdating() const\n\t\t{\n            CS_ASSERT(CS::Application::Get()->GetTaskScheduler()->IsMainThread(), \"Attempted to check if accelerometer was updating outside of the main thread.\");\n\t\t\treturn m_isUpdating;\n\t\t}\n\t\t//----------------------------------------------------\n\t\t//----------------------------------------------------\n\t\tvoid Accelerometer::StartUpdating()\n\t\t{\n            CS_ASSERT(CS::Application::Get()->GetTaskScheduler()->IsMainThread(), \"Attempted to start the accelerometer outside of the main thread.\");\n\t\t\tif (false == m_isUpdating)\n\t\t\t{\n\t\t\t\tm_isUpdating = true;\n\t\t\t\tm_accelerometerJI->StartListening(ChilliSource::MakeDelegate(this, &Accelerometer::OnAccelerationChanged));\n\t\t\t}\n\t\t}\n\t\t//------------------------------------------------\n\t\t//------------------------------------------------\n\t\tChilliSource::Vector3 Accelerometer::GetAcceleration() const\n\t\t{\n            CS_ASSERT(CS::Application::Get()->GetTaskScheduler()->IsMainThread(), \"Attempted to read the accelerometer outside of the main thread.\");\n\t\t\treturn m_acceleration;\n\t\t}\n\t\t//----------------------------------------------------\n\t\t//----------------------------------------------------\n\t\tChilliSource::IConnectableEvent<Accelerometer::AccelerationUpdatedDelegate>& Accelerometer::GetAccelerationUpdatedEvent()\n\t\t{\n            CS_ASSERT(CS::Application::Get()->GetTaskScheduler()->IsMainThread(), \"Attempted to get acceleration update event outside of the main thread.\");\n\t\t\treturn m_accelerationUpdatedEvent;\n\t\t}\n\t\t//----------------------------------------------------\n\t\t//----------------------------------------------------\n\t\tvoid Accelerometer::StopUpdating()\n\t\t{\n            CS_ASSERT(CS::Application::Get()->GetTaskScheduler()->IsMainThread(), \"Attempted to stop the accelerometer outside of the main thread.\");\n\t\t\tif (true == m_isUpdating)\n\t\t\t{\n\t\t\t\tm_accelerometerJI->StopListening();\n\t\t\t\tm_isUpdating = false;\n\t\t\t}\n\t\t}\n        //----------------------------------------------------\n\t\t//----------------------------------------------------\n        void Accelerometer::OnInit()\n        {\n\t\t\tm_accelerometerJI = JavaInterfaceManager::GetSingletonPtr()->GetJavaInterface<AccelerometerJavaInterface>();\n\t\t\tif (m_accelerometerJI == nullptr)\n\t\t\t{\n\t\t\t\tm_accelerometerJI = AccelerometerJavaInterfaceSPtr(new AccelerometerJavaInterface());\n\t\t\t\tJavaInterfaceManager::GetSingletonPtr()->AddJavaInterface(m_accelerometerJI);\n\t\t\t}\n        }\n        //----------------------------------------------------\n\t\t//----------------------------------------------------\n        void Accelerometer::OnResume()\n        {\n        \t//Android continues to send accelerometer events even if\n        \t//the app is suspended so we may have had to manually stop this\n        \t//and now must restart listening\n        \tif(true == m_isUpdating)\n        \t{\n        \t\tm_accelerometerJI->StartListening(ChilliSource::MakeDelegate(this, &Accelerometer::OnAccelerationChanged));\n        \t}\n        }\n        //----------------------------------------------------\n\t\t//----------------------------------------------------\n        void Accelerometer::OnSuspend()\n        {\n        \t//Android continues to send accelerometer events even if\n        \t//the app is suspended. We don't want this\n        \tif(true == m_isUpdating)\n        \t{\n        \t\tm_accelerometerJI->StopListening();\n        \t}\n        }\n        //----------------------------------------------------\n\t\t//----------------------------------------------------\n        void Accelerometer::OnDestroy()\n        {\n        \tm_accelerometerJI.reset();\n        }\n\t\t//------------------------------------------------\n\t\t//------------------------------------------------\n\t\tvoid Accelerometer::OnAccelerationChanged(const ChilliSource::Vector3& in_acceleration)\n\t\t{\n            m_acceleration = in_acceleration;\n            ChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_mainThread, [=](const ChilliSource::TaskContext& taskContext)\n            {\n\t\t\t    m_accelerationUpdatedEvent.NotifyConnections(m_acceleration);\n\t\t\t});\n\t\t}\n\t}\n}\n\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/JNI/Input/Accelerometer/Accelerometer.h",
    "content": "//\n//  Accelerometer.h\n//  ChilliSource\n//  Created by Ian Copland on 10/06/2013.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2013 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n\n#ifndef _CSBACKEND_PLATFORM_ANDROID_INPUT_ACCELEROMETER_ACCELEROMETER_H_\n#define _CSBACKEND_PLATFORM_ANDROID_INPUT_ACCELEROMETER_ACCELEROMETER_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <CSBackend/Platform/Android/Main/JNI/ForwardDeclarations.h>\n#include <ChilliSource/Input/Accelerometer/Accelerometer.h>\n\nnamespace CSBackend\n{\n\tnamespace Android\n\t{\n\t\t//------------------------------------------------------------\n\t\t/// Listens to and stores the acceleration read from the\n\t\t/// hardware accelerometer.\n        ///\n        /// The methods in this class aren't thread-safe, and must\n        /// be accessed from the main thread.\n\t\t///\n\t\t/// @author Ian Copland\n\t\t//------------------------------------------------------------\n\t\tclass Accelerometer final : public ChilliSource::Accelerometer\n\t\t{\n\t\tpublic:\n\t\t\tCS_DECLARE_NAMEDTYPE(Accelerometer);\n\t\t\t//----------------------------------------------------\n\t\t\t/// @author Ian Copland\n\t\t\t///\n\t\t\t/// @return whether or not this object implements\n\t\t\t/// the given interface.\n\t\t\t//----------------------------------------------------\n\t\t\tbool IsA(ChilliSource::InterfaceIDType in_interfaceId) const override;\n\t\t\t//----------------------------------------------------\n\t\t\t/// @author Ian Copland\n\t\t\t///\n\t\t\t/// @return whether or not the accelerometer is\n            /// currently updating.\n\t\t\t//----------------------------------------------------\n\t\t\tbool IsUpdating() const override;\n\t\t\t//----------------------------------------------------\n\t\t\t/// Start listening for accelerometer changes.\n\t\t\t///\n\t\t\t/// @author Ian Copland\n\t\t\t//----------------------------------------------------\n\t\t\tvoid StartUpdating() override;\n\t\t\t//----------------------------------------------------\n\t\t\t/// @author Ian Copland\n\t\t\t///\n\t\t\t/// @return The acceleration applied to the device\n\t\t\t/// measured in \"G\"s.\n\t\t\t//----------------------------------------------------\n\t\t\tChilliSource::Vector3 GetAcceleration() const override;\n\t\t\t//----------------------------------------------------\n\t\t\t/// @author Ian Copland\n\t\t\t///\n\t\t\t/// @return An event that is invoked every time the\n\t\t\t/// acceleration is updated. The acceleration will not\n\t\t\t/// necessarily have changed between updates.\n\t\t\t//----------------------------------------------------\n\t\t\tChilliSource::IConnectableEvent<AccelerationUpdatedDelegate>& GetAccelerationUpdatedEvent() override;\n\t\t\t//----------------------------------------------------\n\t\t\t/// Stop listening for accelerometer changes.\n\t\t\t///\n\t\t\t/// @author Ian Copland\n\t\t\t//----------------------------------------------------\n\t\t\tvoid StopUpdating() override;\n\n\t\tprivate:\n            friend ChilliSource::AccelerometerUPtr ChilliSource::Accelerometer::Create();\n\t\t\t//----------------------------------------------------\n\t\t\t/// Constructor. Declared private to force the use of\n            /// the factory method.\n\t\t\t///\n\t\t\t/// @author Ian Copland\n\t\t\t//----------------------------------------------------\n\t\t\tAccelerometer();\n            //----------------------------------------------------\n\t\t\t/// Initialises the system. This is called at a time\n            /// when all systems have already been added.\n            ///\n            /// @author Ian Copland\n\t\t\t//----------------------------------------------------\n            void OnInit() override;\n            //----------------------------------------------------\n            /// Resume accelerometer events if enabled\n            ///\n            /// @author S Downie\n\t\t\t//----------------------------------------------------\n            void OnResume() override;\n            //----------------------------------------------------\n            /// Prevents accelerometer events when the app is\n            /// backgrounded\n            ///\n            /// @author S Downie\n\t\t\t//----------------------------------------------------\n            void OnSuspend() override;\n            //----------------------------------------------------\n\t\t\t/// Destroys the system immediately before systems\n            /// are removed from the application.\n            ///\n            /// @author Ian Copland\n\t\t\t//----------------------------------------------------\n            void OnDestroy() override;\n\t\t\t//------------------------------------------------\n\t\t\t/// Called whenever the acceleration changes.\n\t\t\t///\n\t\t\t/// @author Ian Copland\n\t\t\t///\n\t\t\t/// @param The new acceleration.\n\t\t\t//------------------------------------------------\n\t\t\tvoid OnAccelerationChanged(const ChilliSource::Vector3& in_acceleration);\n\n\t\t\tChilliSource::Vector3 m_acceleration;\n\t\t\tAccelerometerJavaInterfaceSPtr m_accelerometerJI;\n\t\t\tbool m_isUpdating;\n\t\t\tChilliSource::Event<AccelerationUpdatedDelegate> m_accelerationUpdatedEvent;\n\t\t};\n\t}\n}\n\n#endif\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/JNI/Input/Accelerometer/AccelerometerJavaInterface.cpp",
    "content": "//\n//  AccelerometerJavaInterface.cpp\n//  ChilliSource\n//  Created by Ian Copland on 10/06/2013.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2013 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n\n#include <CSBackend/Platform/Android/Main/JNI/Input/Accelerometer/AccelerometerJavaInterface.h>\n\n#include <CSBackend/Platform/Android/Main/JNI/ForwardDeclarations.h>\n#include <CSBackend/Platform/Android/Main/JNI/Core/Java/JavaInterfaceManager.h>\n#include <CSBackend/Platform/Android/Main/JNI/Core/Java/JavaUtils.h>\n#include <ChilliSource/Core/Math/Vector3.h>\n\n#include <jni.h>\n\n//------------------------------------------\n/// C function declarations\n//------------------------------------------\nextern \"C\"\n{\n\tvoid Java_com_chilliworks_chillisource_input_AccelerometerNativeInterface_UpdateAcceleration(JNIEnv* inpEnv, jobject inThis, f32 infAccelerationX, f32 infAccelerationY, f32 infAccelerationZ);\n}\n//-------------------------------------------\n/// Update Acceleration\n///\n/// Native implemention of the java CAccelerometerNativeInterface\n/// method UpdateAcceleration().\n///\n/// @param The jni environment.\n/// @param The java object calling the function.\n/// @param The X component of the acceleration.\n/// @param The Y component of the acceleration.\n/// @param The Z component of the acceleration.\n//-------------------------------------------\nvoid Java_com_chilliworks_chillisource_input_AccelerometerNativeInterface_UpdateAcceleration(JNIEnv* inpEnv, jobject inThis, f32 infAccelerationX, f32 infAccelerationY, f32 infAccelerationZ)\n{\n\tCSBackend::Android::AccelerometerJavaInterfaceSPtr pAccelerometerJI = CSBackend::Android::JavaInterfaceManager::GetSingletonPtr()->GetJavaInterface<CSBackend::Android::AccelerometerJavaInterface>();\n\tif (nullptr != pAccelerometerJI)\n\t{\n\t\tpAccelerometerJI->UpdateAcceleration(infAccelerationX, infAccelerationY, infAccelerationZ);\n\t}\n}\n\nnamespace CSBackend\n{\n\tnamespace Android\n\t{\n\t\tCS_DEFINE_NAMEDTYPE(AccelerometerJavaInterface);\n\t\t//-----------------------------------------------\n\t\t/// Constructor\n\t\t//-----------------------------------------------\n\t\tAccelerometerJavaInterface::AccelerometerJavaInterface()\n\t\t\t: mbListening(false)\n\t\t{\n\t\t\tCreateNativeInterface(\"com/chilliworks/chillisource/input/AccelerometerNativeInterface\");\n\t\t\tCreateMethodReference(\"IsAvailable\", \"()Z\");\n\t\t\tCreateMethodReference(\"StartListening\", \"()V\");\n\t\t\tCreateMethodReference(\"StopListening\", \"()V\");\n\t\t}\n\t\t//-----------------------------------------------\n\t\t/// Is A\n\t\t//-----------------------------------------------\n\t\tbool AccelerometerJavaInterface::IsA(ChilliSource::InterfaceIDType inInterfaceID) const\n\t\t{\n\t\t\treturn (inInterfaceID == AccelerometerJavaInterface::InterfaceID);\n\t\t}\n\t\t//------------------------------------------------\n\t\t/// Is Available\n\t\t//------------------------------------------------\n\t\tbool AccelerometerJavaInterface::IsAvailable()\n\t\t{\n\t\t\tJNIEnv* pEnv = JavaInterfaceManager::GetSingletonPtr()->GetJNIEnvironmentPtr();\n\t\t\treturn pEnv->CallBooleanMethod(GetJavaObject(), GetMethodID(\"IsAvailable\"));\n\t\t}\n\t\t//------------------------------------------------\n\t\t/// Start Listening\n\t\t//------------------------------------------------\n\t\tvoid AccelerometerJavaInterface::StartListening(const AccelerationChangedDelegate& inAccelerationChangedDelegate)\n\t\t{\n\t\t\tif (true == IsAvailable() && false == mbListening)\n\t\t\t{\n\t\t\t\tJNIEnv* pEnv = JavaInterfaceManager::GetSingletonPtr()->GetJNIEnvironmentPtr();\n\t\t\t\tpEnv->CallVoidMethod(GetJavaObject(), GetMethodID(\"StartListening\"));\n\n\t\t\t\tmAccelerationChangedDelegate = inAccelerationChangedDelegate;\n\t\t\t\tmbListening = true;\n\t\t\t}\n\t\t}\n\t\t//------------------------------------------------\n\t\t/// Stop Listening\n\t\t//------------------------------------------------\n\t\tvoid AccelerometerJavaInterface::StopListening()\n\t\t{\n\t\t\tif (true == mbListening)\n\t\t\t{\n\t\t\t\tmAccelerationChangedDelegate = nullptr;\n\t\t\t\tJNIEnv* pEnv = JavaInterfaceManager::GetSingletonPtr()->GetJNIEnvironmentPtr();\n\t\t\t\tpEnv->CallVoidMethod(GetJavaObject(), GetMethodID(\"StopListening\"));\n\t\t\t\tmbListening = false;\n\t\t\t}\n\t\t}\n\t\t//------------------------------------------------\n\t\t/// Update Acceleration\n\t\t//------------------------------------------------\n\t\tvoid AccelerometerJavaInterface::UpdateAcceleration(f32 infAccelerationX, f32 infAccelerationY, f32 infAccelerationZ)\n\t\t{\n\t\t\tif (true == mbListening && nullptr != mAccelerationChangedDelegate)\n\t\t\t{\n\t\t\t\tmAccelerationChangedDelegate(ChilliSource::Vector3(infAccelerationX, infAccelerationY, infAccelerationZ));\n\t\t\t}\n\t\t}\n\t}\n}\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/JNI/Input/Accelerometer/AccelerometerJavaInterface.h",
    "content": "//\n//  AccelerometerJavaInterface.h\n//  ChilliSource\n//  Created by Ian Copland on 10/06/2013.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2013 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n\n#ifndef _CHILLISOURCE_PLATFORM_ANDROID_JAVAINTERFACE_ACCELEROMETERJAVAINTERFACE_H\n#define _CHILLISOURCE_PLATFORM_ANDROID_JAVAINTERFACE_ACCELEROMETERJAVAINTERFACE_H\n\n#include <CSBackend/Platform/Android/Main/JNI/ForwardDeclarations.h>\n#include <CSBackend/Platform/Android/Main/JNI/Core/Java/JavaInterface.h>\n\nnamespace CSBackend\n{\n\tnamespace Android\n\t{\n\t\t//======================================================\n\t\t/// Accelerometer Java Interface\n\t\t///\n\t\t/// A Java Interface for communicating with the Android\n\t\t/// accelerometer.\n\t\t//======================================================\n\t\tclass AccelerometerJavaInterface : public IJavaInterface\n\t\t{\n\t\tpublic:\n\t\t\tCS_DECLARE_NAMEDTYPE();\n\t\t\t//------------------------------------------------\n\t\t\t/// Delegates\n\t\t\t//------------------------------------------------\n\t\t\ttypedef std::function<void(const ChilliSource::Vector3&)> AccelerationChangedDelegate;\n\t\t\t//------------------------------------------------\n\t\t\t/// Constructor\n\t\t\t//------------------------------------------------\n\t\t\tAccelerometerJavaInterface();\n\t\t\t//------------------------------------------------\n\t\t\t/// Is A\n\t\t\t///\n\t\t\t/// @return whether or not this object implements\n\t\t\t/// the given interface.\n\t\t\t//------------------------------------------------\n\t\t\tbool IsA(ChilliSource::InterfaceIDType inInterfaceID) const;\n\t\t\t//------------------------------------------------\n\t\t\t/// Is Available\n\t\t\t///\n\t\t\t/// @return whether or not the accelerometer is\n\t\t\t/// available on this device.\n\t\t\t//------------------------------------------------\n\t\t\tbool IsAvailable();\n\t\t\t//------------------------------------------------\n\t\t\t/// Start Listening\n\t\t\t///\n\t\t\t/// Start listening for acceleration changes from\n\t\t\t/// the accelerometer on device. If the accelerometer\n\t\t\t/// is not available this will do nothing.\n\t\t\t///\n\t\t\t/// @param The delegate which will receive the\n\t\t\t/// acceleration changes.\n\t\t\t//------------------------------------------------\n\t\t\tvoid StartListening(const AccelerationChangedDelegate& inAccelerationChangedDelegate);\n\t\t\t//------------------------------------------------\n\t\t\t/// Stop Listening\n\t\t\t///\n\t\t\t/// Stops listening for accelerations changes from\n\t\t\t/// the accelerometer.\n\t\t\t//------------------------------------------------\n\t\t\tvoid StopListening();\n\t\t\t//------------------------------------------------\n\t\t\t/// Update Acceleration\n\t\t\t///\n\t\t\t/// This is called by the Java Native Interface to\n\t\t\t/// inform of acceleration updates.\n\t\t\t///\n\t\t\t/// @param The x component of the acceleration.\n\t\t\t/// @param The y component of the acceleration.\n\t\t\t/// @param The z component of the acceleration.\n\t\t\t//------------------------------------------------\n\t\t\tvoid UpdateAcceleration(f32 infAccelerationX, f32 infAccelerationY, f32 infAccelerationZ);\n\t\tprivate:\n\t\t\tAccelerationChangedDelegate mAccelerationChangedDelegate;\n\t\t\tbool mbListening;\n\t\t};\n\t}\n}\n\n#endif\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/JNI/Input/DeviceButtons/DeviceButtonJavaInterface.cpp",
    "content": "//\n//  DeviceButtonJavaInterface.cpp\n//  ChilliSource\n//  Created by Ian Copland on 16/05/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n\n#include <CSBackend/Platform/Android/Main/JNI/Input/DeviceButtons/DeviceButtonJavaInterface.h>\n\n#include <CSBackend/Platform/Android/Main/JNI/Core/Java/JavaInterfaceManager.h>\n#include <CSBackend/Platform/Android/Main/JNI/Core/Java/JavaUtils.h>\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/Threading/TaskScheduler.h>\n\n#include <jni.h>\n\nextern \"C\"\n{\n\t//------------------------------------------------------\n\t/// Called from the java side of the engine when a\n\t/// device button event is received. This is potentially\n\t/// called on the UI thread.\n\t///\n\t/// @author Ian Copland\n\t///\n\t/// @param The jni environment.\n\t/// @param The java object calling the function.\n\t/// @param An integer representing the button pressed.\n\t//-----------------------------------------------------\n\tvoid Java_com_chilliworks_chillisource_input_DeviceButtonNativeInterface_onTriggered(JNIEnv* in_env, jobject in_this, s32 in_buttonPressed);\n}\n//-----------------------------------------------\n//-----------------------------------------------\nvoid Java_com_chilliworks_chillisource_input_DeviceButtonNativeInterface_onTriggered(JNIEnv* in_env, jobject in_this, s32 in_buttonPressed)\n{\n\tCSBackend::Android::DeviceButtonJavaInterfaceSPtr javaInterface = CSBackend::Android::JavaInterfaceManager::GetSingletonPtr()->GetJavaInterface<CSBackend::Android::DeviceButtonJavaInterface>();\n\tif (javaInterface != nullptr)\n\t{\n\t\tChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_mainThread, [=](const ChilliSource::TaskContext&)\n\t\t{\n\t\t\tjavaInterface->OnTriggered(in_buttonPressed);\n\t\t});\n\t}\n}\n\nnamespace CSBackend\n{\n\tnamespace Android\n\t{\n\t\tCS_DEFINE_NAMEDTYPE(DeviceButtonJavaInterface);\n\t\t//-----------------------------------------------\n\t\t//-----------------------------------------------\n\t\tDeviceButtonJavaInterface::DeviceButtonJavaInterface()\n\t\t{\n\t\t\tCreateNativeInterface(\"com/chilliworks/chillisource/input/DeviceButtonNativeInterface\");\n\t\t}\n\t\t//-----------------------------------------------\n\t\t//-----------------------------------------------\n\t\tbool DeviceButtonJavaInterface::IsA(ChilliSource::InterfaceIDType in_interfaceId) const\n\t\t{\n\t\t\treturn (DeviceButtonJavaInterface::InterfaceID == in_interfaceId);\n\t\t}\n\t\t//-----------------------------------------------\n\t\t//-----------------------------------------------\n\t\tvoid DeviceButtonJavaInterface::SetTriggeredDelegate(const TriggeredDelegate& in_delegate)\n\t\t{\n\t\t\tm_triggeredDelegate = in_delegate;\n\t\t}\n\t\t//-----------------------------------------------\n\t\t//-----------------------------------------------\n\t\tvoid DeviceButtonJavaInterface::OnTriggered(s32 in_button)\n\t\t{\n\t\t\tif (m_triggeredDelegate != nullptr)\n\t\t\t{\n\t\t\t\tm_triggeredDelegate(in_button);\n\t\t\t}\n\t\t}\n\t}\n}\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/JNI/Input/DeviceButtons/DeviceButtonJavaInterface.h",
    "content": "//\n//  DeviceButtonJavaInterface.h\n//  ChilliSource\n//  Created by Ian Copland on 16/05/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n\n#ifndef _CHILLISOURCE_PLATFORM_ANDROID_INPUT_DEVICEBUTTONS_DEVICEBUTTONJAVAINTERFACE_H_\n#define _CHILLISOURCE_PLATFORM_ANDROID_INPUT_DEVICEBUTTONS_DEVICEBUTTONJAVAINTERFACE_H_\n\n#include <CSBackend/Platform/Android/Main/JNI/ForwardDeclarations.h>\n#include <CSBackend/Platform/Android/Main/JNI/Core/Java/JavaInterface.h>\n\n#include <functional>\n\nnamespace CSBackend\n{\n\tnamespace Android\n\t{\n\t\t//----------------------------------------------------------------\n\t\t/// Provides access to information about Device Buttons on the\n\t\t/// java side of the engine.\n\t\t///\n\t\t/// @author Ian Copland\n\t\t//----------------------------------------------------------------\n\t\tclass DeviceButtonJavaInterface : public IJavaInterface\n\t\t{\n\t\tpublic:\n\t\t\tCS_DECLARE_NAMEDTYPE(DeviceButtonJavaInterface);\n\t\t\t//-----------------------------------------------\n\t\t\t/// A delegate called when the java side of the\n\t\t\t/// engine receives a device button pressed event.\n\t\t\t///\n\t\t\t/// @author Ian Copland\n\t\t\t///\n\t\t\t/// @param An integer representing the button\n\t\t\t/// pressed.\n\t\t\t//-----------------------------------------------\n\t\t\tusing TriggeredDelegate = std::function<void(s32)>;\n\t\t\t//-----------------------------------------------\n\t\t\t/// Constructor\n\t\t\t///\n\t\t\t/// @author Ian Copland\n\t\t\t//-----------------------------------------------\n\t\t\tDeviceButtonJavaInterface();\n            //----------------------------------------------------\n\t\t\t/// Queries whether or not this implements the interface\n\t\t\t/// with the given ID.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param The interface Id.\n            ///\n\t\t\t/// @return Whether or not the interface is implemented.\n\t\t\t//----------------------------------------------------\n\t\t\tbool IsA(ChilliSource::InterfaceIDType in_interfaceId) const;\n\t\t\t//-----------------------------------------------\n\t\t\t/// @author Ian Copland\n\t\t\t///\n\t\t\t/// @param The delegate that will be called when\n\t\t\t/// a device button triggered event is received.\n\t\t\t//-----------------------------------------------\n\t\t\tvoid SetTriggeredDelegate(const TriggeredDelegate& in_delegate);\n\t\t\t//-----------------------------------------------\n\t\t\t/// Called when a device button triggered event\n\t\t\t/// is received. This is for internal use and\n\t\t\t/// should not be called manually by the user.\n\t\t\t///\n\t\t\t/// @author Ian Copland\n\t\t\t///\n\t\t\t/// @param An integer representing the button\n\t\t\t/// triggered.\n\t\t\t//-----------------------------------------------\n\t\t\tvoid OnTriggered(s32 in_button);\n\t\tprivate:\n\t\t\tTriggeredDelegate m_triggeredDelegate;\n\t\t};\n\t}\n}\n\n#endif\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/JNI/Input/DeviceButtons/DeviceButtonSystem.cpp",
    "content": "//\n//  DeviceButtonSystem.cpp\n//  ChilliSource\n//  Created by Ian Copland on 16/05/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n\n#include <CSBackend/Platform/Android/Main/JNI/Input/DeviceButtons/DeviceButtonSystem.h>\n\n#include <CSBackend/Platform/Android/Main/JNI/Core/Java/JavaInterfaceManager.h>\n#include <CSBackend/Platform/Android/Main/JNI/Input/DeviceButtons/DeviceButtonJavaInterface.h>\n#include <ChilliSource/Core/Delegate/MakeDelegate.h>\n\nnamespace CSBackend\n{\n\tnamespace Android\n\t{\n\t\tnamespace\n\t\t{\n\t\t\t//----------------------------------------------------\n\t\t\t/// Converts from the integer received from java\n\t\t\t/// to the button enum.\n\t\t\t///\n\t\t\t/// @author Ian Copland\n\t\t\t///\n\t\t\t/// @param An integer representing the button.\n\t\t\t///\n\t\t\t/// @param The button.\n\t\t\t//----------------------------------------------------\n\t\t\tDeviceButtonSystem::DeviceButton IntegerToButton(s32 in_buttonInteger)\n\t\t\t{\n\t\t\t\tconst s32 k_backButton = 0;\n\n\t\t\t\tswitch (in_buttonInteger)\n\t\t\t\t{\n\t\t\t\tcase k_backButton:\n\t\t\t\t\treturn DeviceButtonSystem::DeviceButton::k_backButton;\n\t\t\t\tdefault:\n\t\t\t\t\tCS_LOG_ERROR(\"DeviceButtonSystem: Cannot convert from integer to button.\");\n\t\t\t\t\treturn DeviceButtonSystem::DeviceButton::k_backButton;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n        CS_DEFINE_NAMEDTYPE(DeviceButtonSystem);\n        //----------------------------------------------------\n        //----------------------------------------------------\n        bool DeviceButtonSystem::IsA(ChilliSource::InterfaceIDType in_interfaceID) const\n        {\n            return (in_interfaceID == ChilliSource::DeviceButtonSystem::InterfaceID || in_interfaceID == DeviceButtonSystem::InterfaceID);\n        }\n        //----------------------------------------------------\n        //----------------------------------------------------\n        ChilliSource::IConnectableEvent<DeviceButtonSystem::TriggeredDelegate>& DeviceButtonSystem::GetTriggeredEvent()\n        {\n            return m_triggeredEvent;\n        }\n        //------------------------------------------------\n        //------------------------------------------------\n        void DeviceButtonSystem::OnInit()\n        {\n        \tm_javaInterface = JavaInterfaceManager::GetSingletonPtr()->GetJavaInterface<CSBackend::Android::DeviceButtonJavaInterface>();\n        \tif (m_javaInterface == nullptr)\n        \t{\n        \t\tm_javaInterface = DeviceButtonJavaInterfaceSPtr(new DeviceButtonJavaInterface());\n        \t\tJavaInterfaceManager::GetSingletonPtr()->AddJavaInterface(m_javaInterface);\n        \t}\n\n        \tm_javaInterface->SetTriggeredDelegate(ChilliSource::MakeDelegate(this, &DeviceButtonSystem::OnTriggered));\n        }\n        //------------------------------------------------\n        //------------------------------------------------\n        void DeviceButtonSystem::OnTriggered(s32 in_button)\n        {\n        \tm_triggeredEvent.NotifyConnections(IntegerToButton(in_button));\n        }\n        //------------------------------------------------\n        //------------------------------------------------\n        void DeviceButtonSystem::OnDestroy()\n        {\n        \tm_javaInterface->SetTriggeredDelegate(nullptr);\n        \tm_javaInterface = nullptr;\n        }\n\t}\n}\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/JNI/Input/DeviceButtons/DeviceButtonSystem.h",
    "content": "//\n//  DeviceButtonSystem.h\n//  ChilliSource\n//  Created by Ian Copland on 16/05/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n\n#ifndef _CSBACKEND_PLATFORM_ANDROID_INPUT_DEVICEBUTTONS_DEVICEBUTTONSYSTEM_H_\n#define _CSBACKEND_PLATFORM_ANDROID_INPUT_DEVICEBUTTONS_DEVICEBUTTONSYSTEM_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <CSBackend/Platform/Android/Main/JNI/ForwardDeclarations.h>\n#include <ChilliSource/Input/DeviceButtons/DeviceButtonSystem.h>\n\nnamespace CSBackend\n{\n\tnamespace Android\n\t{\n        //------------------------------------------------------------\n        /// The Android backend implementation of the Device Button System.\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------------------\n\t\tclass DeviceButtonSystem final : public ChilliSource::DeviceButtonSystem\n\t\t{\n\t\tpublic:\n            CS_DECLARE_NAMEDTYPE(DeviceButtonSystem);\n            //----------------------------------------------------\n\t\t\t/// Queries whether or not this system implements the\n            /// interface with the given ID.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param The interface Id.\n            ///\n\t\t\t/// @return Whether or not the interface is implemented.\n\t\t\t//----------------------------------------------------\n            bool IsA(ChilliSource::InterfaceIDType in_interfaceId) const override;\n            //----------------------------------------------------\n\t\t\t/// @author Ian Copland\n            ///\n            /// @return An event that will be called whenever a\n            /// device button is pressed.\n\t\t\t//----------------------------------------------------\n            ChilliSource::IConnectableEvent<TriggeredDelegate>& GetTriggeredEvent() override;\n\t\tprivate:\n            friend ChilliSource::DeviceButtonSystemUPtr ChilliSource::DeviceButtonSystem::Create();\n            \n            //----------------------------------------------------\n\t\t\t/// Constructor. Declared private to force the use of\n            /// the factory method.\n            ///\n            /// @author Ian Copland\n\t\t\t//----------------------------------------------------\n\t\t\tDeviceButtonSystem() = default;\n            //------------------------------------------------\n            /// Initialisation method called at a time when\n            /// all App Systems have been created. System\n            /// initialisation occurs in the order they were\n            /// created.\n            ///\n            /// @author Ian Copland\n            //------------------------------------------------\n            void OnInit() override;\n            //------------------------------------------------\n            /// Called when a device button is triggered.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param An integer representing the triggered\n            /// button.\n            //------------------------------------------------\n            void OnTriggered(s32 in_button);\n            //------------------------------------------------\n            /// Called when the application is being destroyed.\n            /// This should be used to cleanup memory and\n            /// references to other systems. System destruction\n            /// occurs in the reverse order to which they\n            /// were created\n            ///\n            /// @author Ian Copland\n            //------------------------------------------------\n            void OnDestroy() override;\n\n            ChilliSource::Event<TriggeredDelegate> m_triggeredEvent;\n            DeviceButtonJavaInterfaceSPtr m_javaInterface;\n\t\t};\n\t}\n}\n\n#endif\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/JNI/Input/Gyroscope/Gyroscope.cpp",
    "content": "//\n//  Gyroscope.cpp\n//  ChilliSource\n//  Created by Jordan Brown on 20/01/2017\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2017 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n\n#include <CSBackend/Platform/Android/Main/JNI/Input/Gyroscope/Gyroscope.h>\n\n#include <CSBackend/Platform/Android/Main/JNI/Core/Java/JavaInterfaceManager.h>\n#include <CSBackend/Platform/Android/Main/JNI/Input/Gyroscope/GyroscopeJavaInterface.h>\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/Delegate/MakeDelegate.h>\n#include <ChilliSource/Core/Threading/TaskScheduler.h>\n\nnamespace CSBackend\n{\n\tnamespace Android\n\t{\n\t\tCS_DEFINE_NAMEDTYPE(Gyroscope);\n\t\t//------------------------------------------------\n\t\t//------------------------------------------------\n\t\tGyroscope::Gyroscope()\n\t\t\t: m_isUpdating(false)\n\t\t{\n\t\t}\n\t\t//------------------------------------------------\n\t\t//------------------------------------------------\n\t\tbool Gyroscope::IsA(ChilliSource::InterfaceIDType in_interfaceId) const\n\t\t{\n\t\t\treturn (in_interfaceId == ChilliSource::Gyroscope::InterfaceID || in_interfaceId == Gyroscope::InterfaceID);\n\t\t}\n\t\t//----------------------------------------------------\n\t\t//----------------------------------------------------\n\t\tbool Gyroscope::IsUpdating() const\n\t\t{\n            CS_ASSERT(CS::Application::Get()->GetTaskScheduler()->IsMainThread(), \"Attempted to check if gyroscope was updating outside of the main thread.\");\n\t\t\treturn m_isUpdating;\n\t\t}\n\t\t//----------------------------------------------------\n\t\t//----------------------------------------------------\n\t\tvoid Gyroscope::StartUpdating()\n\t\t{\n            CS_ASSERT(CS::Application::Get()->GetTaskScheduler()->IsMainThread(), \"Attempted to start the gyroscope outside of the main thread.\");\n\t\t\tif (false == m_isUpdating)\n\t\t\t{\n\t\t\t\tm_isUpdating = true;\n\t\t\t\tm_gyroscopeJI->StartListening(ChilliSource::MakeDelegate(this, &Gyroscope::OnOrientationChanged));\n\t\t\t}\n\t\t}\n\t\t//------------------------------------------------\n\t\t//------------------------------------------------\n\t\tChilliSource::Quaternion Gyroscope::GetOrientation() const\n\t\t{\n            CS_ASSERT(CS::Application::Get()->GetTaskScheduler()->IsMainThread(), \"Attempted to read the gyroscope outside of the main thread.\");\n\t\t\treturn m_orientation;\n\t\t}\n\t\t//----------------------------------------------------\n\t\t//----------------------------------------------------\n\t\tChilliSource::IConnectableEvent<Gyroscope::OrientationUpdatedDelegate>& Gyroscope::GetOrientationUpdatedEvent()\n\t\t{\n            CS_ASSERT(CS::Application::Get()->GetTaskScheduler()->IsMainThread(), \"Attempted to get orientation update event outside of the main thread.\");\n\t\t\treturn m_orientationUpdatedEvent;\n\t\t}\n\t\t//----------------------------------------------------\n\t\t//----------------------------------------------------\n\t\tvoid Gyroscope::StopUpdating()\n\t\t{\n            CS_ASSERT(CS::Application::Get()->GetTaskScheduler()->IsMainThread(), \"Attempted to stop the gyroscope outside of the main thread.\");\n\t\t\tif (true == m_isUpdating)\n\t\t\t{\n\t\t\t\tm_gyroscopeJI->StopListening();\n\t\t\t\tm_isUpdating = false;\n\t\t\t}\n\t\t}\n        //----------------------------------------------------\n\t\t//----------------------------------------------------\n        void Gyroscope::OnInit()\n        {\n\t\t\tm_gyroscopeJI = JavaInterfaceManager::GetSingletonPtr()->GetJavaInterface<GyroscopeJavaInterface>();\n\t\t\tif (m_gyroscopeJI == nullptr)\n\t\t\t{\n\t\t\t\tm_gyroscopeJI = GyroscopeJavaInterfaceSPtr(new GyroscopeJavaInterface());\n\t\t\t\tJavaInterfaceManager::GetSingletonPtr()->AddJavaInterface(m_gyroscopeJI);\n\t\t\t}\n        }\n        //----------------------------------------------------\n\t\t//----------------------------------------------------\n        void Gyroscope::OnResume()\n        {\n        \t//Android continues to send gyroscope events even if\n        \t//the app is suspended so we may have had to manually stop this\n        \t//and now must restart listening\n        \tif(true == m_isUpdating)\n        \t{\n        \t\tm_gyroscopeJI->StartListening(ChilliSource::MakeDelegate(this, &Gyroscope::OnOrientationChanged));\n        \t}\n        }\n        //----------------------------------------------------\n\t\t//----------------------------------------------------\n        void Gyroscope::OnSuspend()\n        {\n        \t//Android continues to send gyroscope events even if\n        \t//the app is suspended. We don't want this\n        \tif(true == m_isUpdating)\n        \t{\n        \t\tm_gyroscopeJI->StopListening();\n        \t}\n        }\n        //----------------------------------------------------\n\t\t//----------------------------------------------------\n        void Gyroscope::OnDestroy()\n        {\n        \tm_gyroscopeJI.reset();\n        }\n\t\t//------------------------------------------------\n\t\t//------------------------------------------------\n\t\tvoid Gyroscope::OnOrientationChanged(const ChilliSource::Quaternion& in_orientation)\n\t\t{\n            m_orientation = in_orientation;\n            ChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_mainThread, [=](const ChilliSource::TaskContext& taskContext)\n            {\n\t\t\t    m_orientationUpdatedEvent.NotifyConnections(m_orientation);\n\t\t\t});\n\t\t}\n\t}\n}\n\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/JNI/Input/Gyroscope/Gyroscope.h",
    "content": "//\n//  Gyroscope.h\n//  ChilliSource\n//  Created by Jordan Brown on 20/01/2017.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2017 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n\n#ifndef _CSBACKEND_PLATFORM_ANDROID_INPUT_GYROSCOPE_GYROSCOPE_H_\n#define _CSBACKEND_PLATFORM_ANDROID_INPUT_GYROSCOPE_GYROSCOPE_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <CSBackend/Platform/Android/Main/JNI/ForwardDeclarations.h>\n#include <ChilliSource/Input/Gyroscope/Gyroscope.h>\n\nnamespace CSBackend\n{\n\tnamespace Android\n\t{\n\t\t//------------------------------------------------------------\n\t\t/// Listens to and stores the acceleration read from the\n\t\t/// hardware gyroscope.\n        ///\n        /// The methods in this class aren't thread-safe, and must\n        /// be accessed from the main thread.\n\t\t///\n\t\t/// @author J Brown\n\t\t//------------------------------------------------------------\n\t\tclass Gyroscope final : public ChilliSource::Gyroscope\n\t\t{\n\t\tpublic:\n\t\t\tCS_DECLARE_NAMEDTYPE(Gyroscope);\n\t\t\t//----------------------------------------------------\n\t\t\t/// @author J Brown\n\t\t\t///\n\t\t\t/// @return whether or not this object implements\n\t\t\t/// the given interface.\n\t\t\t//----------------------------------------------------\n\t\t\tbool IsA(ChilliSource::InterfaceIDType in_interfaceId) const override;\n\t\t\t//----------------------------------------------------\n\t\t\t/// @author J Brown\n\t\t\t///\n\t\t\t/// @return whether or not the gyroscope is\n            /// currently updating.\n\t\t\t//----------------------------------------------------\n\t\t\tbool IsUpdating() const override;\n\t\t\t//----------------------------------------------------\n\t\t\t/// Start listening for gyroscope changes.\n\t\t\t///\n\t\t\t/// @author J Brown\n\t\t\t//----------------------------------------------------\n\t\t\tvoid StartUpdating() override;\n\t\t\t//----------------------------------------------------\n\t\t\t/// @author J Brown\n\t\t\t///\n\t\t\t/// @return The physical orientation of the device.\n\t\t\t//----------------------------------------------------\n\t\t\tChilliSource::Quaternion GetOrientation() const override;\n\t\t\t//----------------------------------------------------\n\t\t\t/// @author J Brown\n\t\t\t///\n\t\t\t/// @return An event that is invoked every time the\n\t\t\t/// orientation is updated. The orientation will not\n\t\t\t/// necessarily have changed between updates.\n\t\t\t//----------------------------------------------------\n\t\t\tChilliSource::IConnectableEvent<OrientationUpdatedDelegate>& GetOrientationUpdatedEvent() override;\n\t\t\t//----------------------------------------------------\n\t\t\t/// Stop listening for gyroscope changes.\n\t\t\t///\n\t\t\t/// @author J Brown\n\t\t\t//----------------------------------------------------\n\t\t\tvoid StopUpdating() override;\n\n\t\tprivate:\n            friend ChilliSource::GyroscopeUPtr ChilliSource::Gyroscope::Create();\n\t\t\t//----------------------------------------------------\n\t\t\t/// Constructor. Declared private to force the use of\n            /// the factory method.\n\t\t\t///\n\t\t\t/// @author J Brown\n\t\t\t//----------------------------------------------------\n\t\t\tGyroscope();\n            //----------------------------------------------------\n\t\t\t/// Initialises the system. This is called at a time\n            /// when all systems have already been added.\n            ///\n            /// @author J Brown\n\t\t\t//----------------------------------------------------\n            void OnInit() override;\n            //----------------------------------------------------\n            /// Resume gyroscope events if enabled\n            ///\n            /// @author J Brown\n\t\t\t//----------------------------------------------------\n            void OnResume() override;\n            //----------------------------------------------------\n            /// Prevents gyroscope events when the app is\n            /// backgrounded\n            ///\n            /// @author J Brown\n\t\t\t//----------------------------------------------------\n            void OnSuspend() override;\n            //----------------------------------------------------\n\t\t\t/// Destroys the system immediately before systems\n            /// are removed from the application.\n            ///\n            /// @author J Brown\n\t\t\t//----------------------------------------------------\n            void OnDestroy() override;\n\t\t\t//------------------------------------------------\n\t\t\t/// Called whenever the orientation changes.\n\t\t\t///\n\t\t\t/// @author J Brown\n\t\t\t///\n\t\t\t/// @param The new orientation.\n\t\t\t//------------------------------------------------\n\t\t\tvoid OnOrientationChanged(const ChilliSource::Quaternion& in_orientation);\n\n\t\t\tChilliSource::Quaternion m_orientation;\n\t\t\tGyroscopeJavaInterfaceSPtr m_gyroscopeJI;\n\t\t\tbool m_isUpdating;\n\t\t\tChilliSource::Event<OrientationUpdatedDelegate> m_orientationUpdatedEvent;\n\t\t};\n\t}\n}\n\n#endif\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/JNI/Input/Gyroscope/GyroscopeJavaInterface.cpp",
    "content": "//\n//  GyroscopeJavaInterface.cpp\n//  ChilliSource\n//  Created by Ian Copland on 10/06/2013.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2013 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n\n#include <CSBackend/Platform/Android/Main/JNI/Input/Gyroscope/GyroscopeJavaInterface.h>\n\n#include <CSBackend/Platform/Android/Main/JNI/ForwardDeclarations.h>\n#include <CSBackend/Platform/Android/Main/JNI/Core/Java/JavaInterfaceManager.h>\n#include <CSBackend/Platform/Android/Main/JNI/Core/Java/JavaUtils.h>\n#include <ChilliSource/Core/Math/Quaternion.h>\n\n#include <jni.h>\n\n//------------------------------------------\n/// C function declarations\n//------------------------------------------\nextern \"C\"\n{\n\tvoid Java_com_chilliworks_chillisource_input_GyroscopeNativeInterface_UpdateOrientation(JNIEnv* inpEnv, jobject inThis, f32 infOrientationX, f32 infOrientationY, f32 infOrientationZ, f32 infOrientationW);\n}\n//-------------------------------------------\n/// Update Orientation\n///\n/// Native implemention of the java CGyroscopeNativeInterface\n/// method UpdateOrientation().\n///\n/// @param The jni environment.\n/// @param The java object calling the function.\n/// @param The X component of the orientation.\n/// @param The Y component of the orientation.\n/// @param The Z component of the orientation.\n/// @param The W component of the orientation\n//-------------------------------------------\nvoid Java_com_chilliworks_chillisource_input_GyroscopeNativeInterface_UpdateOrientation(JNIEnv* inpEnv, jobject inThis, f32 infOrientationX, f32 infOrientationY, f32 infOrientationZ, f32 infOrientationW)\n{\n\tCSBackend::Android::GyroscopeJavaInterfaceSPtr pGyroscopeJI = CSBackend::Android::JavaInterfaceManager::GetSingletonPtr()->GetJavaInterface<CSBackend::Android::GyroscopeJavaInterface>();\n\tif (nullptr != pGyroscopeJI)\n\t{\n\t\tpGyroscopeJI->UpdateOrientation(infOrientationX, infOrientationY, infOrientationZ, infOrientationW);\n\t}\n}\n\nnamespace CSBackend\n{\n\tnamespace Android\n\t{\n\t\tCS_DEFINE_NAMEDTYPE(GyroscopeJavaInterface);\n\t\t//-----------------------------------------------\n\t\t/// Constructor\n\t\t//-----------------------------------------------\n\t\tGyroscopeJavaInterface::GyroscopeJavaInterface()\n\t\t\t: mbListening(false)\n\t\t{\n\t\t\tCreateNativeInterface(\"com/chilliworks/chillisource/input/GyroscopeNativeInterface\");\n\t\t\tCreateMethodReference(\"IsAvailable\", \"()Z\");\n\t\t\tCreateMethodReference(\"StartListening\", \"()V\");\n\t\t\tCreateMethodReference(\"StopListening\", \"()V\");\n\t\t}\n\t\t//-----------------------------------------------\n\t\t/// Is A\n\t\t//-----------------------------------------------\n\t\tbool GyroscopeJavaInterface::IsA(ChilliSource::InterfaceIDType inInterfaceID) const\n\t\t{\n\t\t\treturn (inInterfaceID == GyroscopeJavaInterface::InterfaceID);\n\t\t}\n\t\t//------------------------------------------------\n\t\t/// Is Available\n\t\t//------------------------------------------------\n\t\tbool GyroscopeJavaInterface::IsAvailable()\n\t\t{\n\t\t\tJNIEnv* pEnv = JavaInterfaceManager::GetSingletonPtr()->GetJNIEnvironmentPtr();\n\t\t\treturn pEnv->CallBooleanMethod(GetJavaObject(), GetMethodID(\"IsAvailable\"));\n\t\t}\n\t\t//------------------------------------------------\n\t\t/// Start Listening\n\t\t//------------------------------------------------\n\t\tvoid GyroscopeJavaInterface::StartListening(const OrientationChangedDelegate& inOrientationChangedDelegate)\n\t\t{\n\t\t\tif (true == IsAvailable() && false == mbListening)\n\t\t\t{\n\t\t\t\tJNIEnv* pEnv = JavaInterfaceManager::GetSingletonPtr()->GetJNIEnvironmentPtr();\n\t\t\t\tpEnv->CallVoidMethod(GetJavaObject(), GetMethodID(\"StartListening\"));\n\n\t\t\t\tmOrientationChangedDelegate = inOrientationChangedDelegate;\n\t\t\t\tmbListening = true;\n\t\t\t}\n\t\t}\n\t\t//------------------------------------------------\n\t\t/// Stop Listening\n\t\t//------------------------------------------------\n\t\tvoid GyroscopeJavaInterface::StopListening()\n\t\t{\n\t\t\tif (true == mbListening)\n\t\t\t{\n\t\t\t\tmOrientationChangedDelegate = nullptr;\n\t\t\t\tJNIEnv* pEnv = JavaInterfaceManager::GetSingletonPtr()->GetJNIEnvironmentPtr();\n\t\t\t\tpEnv->CallVoidMethod(GetJavaObject(), GetMethodID(\"StopListening\"));\n\t\t\t\tmbListening = false;\n\t\t\t}\n\t\t}\n\t\t//------------------------------------------------\n\t\t/// Update Orientation\n\t\t//------------------------------------------------\n\t\tvoid GyroscopeJavaInterface::UpdateOrientation(f32 infOrientationX, f32 infOrientationY, f32 infOrientationZ, f32 infOrientationW)\n\t\t{\n\t\t\tif (true == mbListening && nullptr != mOrientationChangedDelegate)\n\t\t\t{\n\t\t\t\tmOrientationChangedDelegate(ChilliSource::Quaternion(infOrientationX, infOrientationY, infOrientationZ, infOrientationW));\n\t\t\t}\n\t\t}\n\t}\n}\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/JNI/Input/Gyroscope/GyroscopeJavaInterface.h",
    "content": "//\n//  GyroscopeJavaInterface.h\n//  ChilliSource\n//  Created by Jordan Brown on 20/01/2017.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2017 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n\n#ifndef _CHILLISOURCE_PLATFORM_ANDROID_JAVAINTERFACE_GYROSCOPEJAVAINTERFACE_H\n#define _CHILLISOURCE_PLATFORM_ANDROID_JAVAINTERFACE_GYROSCOPEJAVAINTERFACE_H\n\n#include <CSBackend/Platform/Android/Main/JNI/ForwardDeclarations.h>\n#include <CSBackend/Platform/Android/Main/JNI/Core/Java/JavaInterface.h>\n\nnamespace CSBackend\n{\n\tnamespace Android\n\t{\n\t\t//======================================================\n\t\t/// Gyroscope Java Interface\n\t\t///\n\t\t/// A Java Interface for communicating with the Android\n\t\t/// gyroscope.\n\t\t//======================================================\n\t\tclass GyroscopeJavaInterface : public IJavaInterface\n\t\t{\n\t\tpublic:\n\t\t\tCS_DECLARE_NAMEDTYPE();\n\t\t\t//------------------------------------------------\n\t\t\t/// Delegates\n\t\t\t//------------------------------------------------\n\t\t\ttypedef std::function<void(const ChilliSource::Quaternion&)> OrientationChangedDelegate;\n\t\t\t//------------------------------------------------\n\t\t\t/// Constructor\n\t\t\t//------------------------------------------------\n\t\t\tGyroscopeJavaInterface();\n\t\t\t//------------------------------------------------\n\t\t\t/// Is A\n\t\t\t///\n\t\t\t/// @return whether or not this object implements\n\t\t\t/// the given interface.\n\t\t\t//------------------------------------------------\n\t\t\tbool IsA(ChilliSource::InterfaceIDType inInterfaceID) const;\n\t\t\t//------------------------------------------------\n\t\t\t/// Is Available\n\t\t\t///\n\t\t\t/// @return whether or not the gyroscope is\n\t\t\t/// available on this device.\n\t\t\t//------------------------------------------------\n\t\t\tbool IsAvailable();\n\t\t\t//------------------------------------------------\n\t\t\t/// Start Listening\n\t\t\t///\n\t\t\t/// Start listening for orientation changes from\n\t\t\t/// the gyroscope on device. If the gyroscope\n\t\t\t/// is not available this will do nothing.\n\t\t\t///\n\t\t\t/// @param The delegate which will receive the\n\t\t\t/// orientation changes.\n\t\t\t//------------------------------------------------\n\t\t\tvoid StartListening(const OrientationChangedDelegate& inOrientationChangedDelegate);\n\t\t\t//------------------------------------------------\n\t\t\t/// Stop Listening\n\t\t\t///\n\t\t\t/// Stops listening for orientations changes from\n\t\t\t/// the gyroscope.\n\t\t\t//------------------------------------------------\n\t\t\tvoid StopListening();\n\t\t\t//------------------------------------------------\n\t\t\t/// Update Orientation\n\t\t\t///\n\t\t\t/// This is called by the Java Native Interface to\n\t\t\t/// inform of orientation updates.\n\t\t\t///\n\t\t\t/// @param The x component of the orientation.\n\t\t\t/// @param The y component of the orientation.\n\t\t\t/// @param The z component of the orientation.\n\t\t\t/// @param The w component of the orientation\n\t\t\t//------------------------------------------------\n\t\t\tvoid UpdateOrientation(f32 infOrientationX, f32 infOrientationY, f32 infOrientationZ, f32 infOrientationW);\n\t\tprivate:\n\t\t\tOrientationChangedDelegate mOrientationChangedDelegate;\n\t\t\tbool mbListening;\n\t\t};\n\t}\n}\n\n#endif\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/JNI/Input/Pointer/PointerSystem.cpp",
    "content": "//\n//  PointerSystem.cpp\n//  ChilliSource\n//  Created by Ian Copland on 27/03/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n\n#include <CSBackend/Platform/Android/Main/JNI/Input/Pointer/PointerSystem.h>\n\n#include <CSBackend/Platform/Android/Main/JNI/Input/Pointer/TouchInputJavaInterface.h>\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/Base/Screen.h>\n#include <ChilliSource/Core/Threading/TaskScheduler.h>\n\nnamespace CSBackend\n{\n\tnamespace Android\n\t{\n\t\tCS_DEFINE_NAMEDTYPE(PointerSystem);\n\t\t//----------------------------------------------------\n\t\t//----------------------------------------------------\n\t\tbool PointerSystem::IsA(ChilliSource::InterfaceIDType in_interfaceId) const\n\t\t{\n\t\t\treturn (ChilliSource::PointerSystem::InterfaceID == in_interfaceId || PointerSystem::InterfaceID == in_interfaceId);\n\t\t}\n\t\t//----------------------------------------------------\n\t\t//----------------------------------------------------\n\t\tvoid PointerSystem::OnTouchDown(s32 in_systemId, const ChilliSource::Vector2& in_location)\n\t\t{\n\t\t\tChilliSource::Vector2 touchLocation(in_location.x, m_screen->GetResolution().y - in_location.y);\n\t\t\tChilliSource::Pointer::Id pointerId = AddPointerCreateEvent(touchLocation);\n\t\t\tAddPointerDownEvent(pointerId, ChilliSource::Pointer::InputType::k_touch);\n\t\t\tm_systemIdToPointerIdMap.emplace(in_systemId, pointerId);\n\t\t}\n\t\t//----------------------------------------------------\n\t\t//----------------------------------------------------\n\t\tvoid PointerSystem::OnTouchMoved(s32 in_systemId, const ChilliSource::Vector2& in_location)\n\t\t{\n\t\t\tauto it = m_systemIdToPointerIdMap.find(in_systemId);\n\t\t\tif (it != m_systemIdToPointerIdMap.end())\n\t\t\t{\n\t\t\t\tChilliSource::Vector2 touchLocation(in_location.x, m_screen->GetResolution().y - in_location.y);\n\t\t\t\tAddPointerMovedEvent(it->second, touchLocation);\n\t\t\t}\n\t\t}\n\t\t//----------------------------------------------------\n\t\t//----------------------------------------------------\n\t\tvoid PointerSystem::OnTouchUp(s32 in_systemId)\n\t\t{\n\t\t\tauto it = m_systemIdToPointerIdMap.find(in_systemId);\n\t\t\tif (it != m_systemIdToPointerIdMap.end())\n\t\t\t{\n\t\t\t\tAddPointerUpEvent(it->second, ChilliSource::Pointer::InputType::k_touch);\n\t\t\t\tAddPointerRemoveEvent(it->second);\n\t\t\t\tm_systemIdToPointerIdMap.erase(it);\n\t\t\t}\n\t\t}\n\t\t//------------------------------------------------\n\t\t//------------------------------------------------\n\t\tvoid PointerSystem::OnInit()\n\t\t{\n\t\t\tm_screen = ChilliSource::Application::Get()->GetSystem<ChilliSource::Screen>();\n\t\t\tCS_ASSERT(m_screen != nullptr, \"Cannot find required system for PointerSystem: Screen.\");\n\n\t\t\tTouchInputJavaInterface::SetPointerSystem(this);\n\t\t}\n\t\t//------------------------------------------------\n\t\t//------------------------------------------------\n\t\tvoid PointerSystem::OnDestroy()\n\t\t{\n\t\t\tTouchInputJavaInterface::SetPointerSystem(nullptr);\n\t\t\tRemoveAllPointers();\n\t\t\tm_screen = nullptr;\n\t\t}\n\t}\n}\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/JNI/Input/Pointer/PointerSystem.h",
    "content": "//\n//  PointerSystem.h\n//  ChilliSource\n//  Created by Ian Copland on 27/03/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n\n#ifndef _CSBACKEND_PLATFORM_ANDROID_INPUT_POINTER_POINTERSYSTEM_H_\n#define _CSBACKEND_PLATFORM_ANDROID_INPUT_POINTER_POINTERSYSTEM_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <CSBackend/Platform/Android/Main/JNI/ForwardDeclarations.h>\n#include <ChilliSource/Input/Pointer/PointerSystem.h>\n\n#include <unordered_map>\n\nnamespace CSBackend\n{\n    namespace Android\n    {\n        //------------------------------------------------------------\n        /// The Android backend for the pointer system. This provides\n        /// access to touch events.\n        ///\n        /// The methods in this class are not thread-safe and must be\n        /// accessed from the main thread.\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------------------\n        class PointerSystem final : public ChilliSource::PointerSystem\n        {\n        public:\n            CS_DECLARE_NAMEDTYPE(PointerSystem);\n            //----------------------------------------------------\n\t\t\t/// Queries whether or not this system implements the\n            /// interface with the given ID.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param The interface Id.\n            ///\n\t\t\t/// @return Whether or not the interface is implemented.\n\t\t\t//----------------------------------------------------\n            bool IsA(ChilliSource::InterfaceIDType in_interfaceId) const override;\n            //----------------------------------------------------\n\t\t\t/// Called when a touch down event is received.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param The system Id of the touch.\n            /// @param The touch location.\n\t\t\t//----------------------------------------------------\n            void OnTouchDown(s32 in_systemId, const ChilliSource::Vector2& in_location);\n            //----------------------------------------------------\n\t\t\t/// Called when a touch moved event is received.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param The system Id of the touch.\n            /// @param The touch location.\n\t\t\t//----------------------------------------------------\n\t\t\tvoid OnTouchMoved(s32 in_systemId, const ChilliSource::Vector2& in_location);\n            //----------------------------------------------------\n\t\t\t/// Called when a touch up event is received.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param The system Id of the touch.\n\t\t\t//----------------------------------------------------\n\t\t\tvoid OnTouchUp(s32 in_systemId);\n            //----------------------------------------------------\n            /// Android has no cursor so this does nothing\n            ///\n            /// @author S Downie\n            //----------------------------------------------------\n            void HideSystemCursor() override {};\n            //----------------------------------------------------\n            /// Android has no cursor so this does nothing\n            ///\n            /// @author S Downie\n            //----------------------------------------------------\n            void ShowSystemCursor() override {};\n        private:\n            friend class ChilliSource::PointerSystem;\n\n            //------------------------------------------------\n            /// Default constructor. Declared private to force\n            /// the use of the factory method.\n            ///\n            /// @author Ian Copland\n            //------------------------------------------------\n            PointerSystem() = default;\n            //------------------------------------------------\n            /// Initialisation method called at a time when\n            /// all App Systems have been created. System\n            /// initialisation occurs in the order they were\n            /// created.\n            ///\n            /// @author Ian Copland\n            //------------------------------------------------\n            void OnInit() override;\n            //------------------------------------------------\n            /// Called when the application is being destroyed.\n            /// This should be used to cleanup memory and\n            /// references to other systems. System destruction\n            /// occurs in the reverse order to which they\n            /// were created\n            ///\n            /// @author Ian Copland\n            //------------------------------------------------\n            void OnDestroy() override;\n\n            ChilliSource::Screen* m_screen = nullptr;\n            std::unordered_map<s32, ChilliSource::Pointer::Id> m_systemIdToPointerIdMap;\n        };\n    }\n}\n\n#endif\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/JNI/Input/Pointer/TouchInputJavaInterface.cpp",
    "content": "//\n//  TouchInputJavaInterface.cpp\n//  ChilliSource\n//  Created by Ian Copland on 05/05/2011.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2011 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n\n#include <CSBackend/Platform/Android/Main/JNI/Input/Pointer/TouchInputJavaInterface.h>\n\n#include <CSBackend/Platform/Android/Main/JNI/Core/Base/CoreJavaInterface.h>\n#include <CSBackend/Platform/Android/Main/JNI/Input/Pointer/PointerSystem.h>\n\nextern \"C\"\n{\n\t//-------------------------------------------------------\n\t/// Interface function called from java. This is called\n\t/// when a touch is first registered.\n\t///\n\t/// @author Ian Copland\n\t///\n\t/// @param The jni environment.\n\t/// @param the java object calling the function\n\t/// @param the touch id\n\t/// @param the x coordinate\n\t/// @param the y coordinate\n\t//-------------------------------------------------------\n\tvoid Java_com_chilliworks_chillisource_input_TouchInputNativeInterface_TouchDown(JNIEnv* in_environment, jobject in_this, s32 in_systemId, f32 in_x, f32 in_y);\n\t//-------------------------------------------------------\n\t/// Interface function called from java. This is called\n\t/// when a touch has moved.\n\t///\n\t/// @author Ian Copland\n\t///\n\t/// @param The jni environment.\n\t/// @param the java object calling the function\n\t/// @param the touch id\n\t/// @param the x coordinate\n\t/// @param the y coordinate\n\t//-------------------------------------------------------\n\tvoid Java_com_chilliworks_chillisource_input_TouchInputNativeInterface_TouchMoved(JNIEnv* in_environment, jobject in_this, s32 in_systemId, f32 in_x, f32 in_y);\n\t//-------------------------------------------------------\n\t/// Interface function called from java. This is called\n\t/// when a touch has finished.\n\t///\n\t/// @author Ian Copland\n\t///\n\t/// @param The jni environment.\n\t/// @param the java object calling the function\n\t/// @param the touch id\n\t/// @param the x coordinate\n\t/// @param the y coordinate\n\t//-------------------------------------------------------\n\tvoid Java_com_chilliworks_chillisource_input_TouchInputNativeInterface_TouchUp(JNIEnv* in_environment, jobject in_this, s32 in_systemId, f32 in_x, f32 in_y);\n}\n//-------------------------------------------------------\n//-------------------------------------------------------\nvoid Java_com_chilliworks_chillisource_input_TouchInputNativeInterface_TouchDown(JNIEnv* in_environment, jobject in_this, s32 in_systemId, f32 in_x, f32 in_y)\n{\n\tCSBackend::Android::PointerSystem* pointerSystem = CSBackend::Android::TouchInputJavaInterface::GetPointerSystem();\n\tCS_ASSERT(pointerSystem, \"Touch Input Java Interface: No pointer system!\");\n\tpointerSystem->OnTouchDown(in_systemId, ChilliSource::Vector2(in_x, in_y));\n}\n//-------------------------------------------------------\n//-------------------------------------------------------\nvoid Java_com_chilliworks_chillisource_input_TouchInputNativeInterface_TouchMoved(JNIEnv* in_environment, jobject in_this, s32 in_systemId, f32 in_x, f32 in_y)\n{\n\tCSBackend::Android::PointerSystem* pointerSystem = CSBackend::Android::TouchInputJavaInterface::GetPointerSystem();\n\tCS_ASSERT(pointerSystem, \"Touch Input Java Interface: No pointer system!\");\n\tpointerSystem->OnTouchMoved(in_systemId, ChilliSource::Vector2(in_x, in_y));\n}\n//-------------------------------------------------------\n//-------------------------------------------------------\nvoid Java_com_chilliworks_chillisource_input_TouchInputNativeInterface_TouchUp(JNIEnv* in_environment, jobject in_this, s32 in_systemId, f32 in_x, f32 in_y)\n{\n\tCSBackend::Android::PointerSystem* pointerSystem = CSBackend::Android::TouchInputJavaInterface::GetPointerSystem();\n\tCS_ASSERT(pointerSystem, \"Touch Input Java Interface: No pointer system!\");\n\tpointerSystem->OnTouchUp(in_systemId);\n}\n\nnamespace CSBackend\n{\n\tnamespace Android\n\t{\n\t\tPointerSystem* TouchInputJavaInterface::s_pointerSystem = nullptr;\n\t\t//--------------------------------------------------------------------------------------\n\t\t/// Setup Java Interface\n\t\t//--------------------------------------------------------------------------------------\n\t\tvoid TouchInputJavaInterface::SetupJavaInterface(JavaVM* inpJavaVM)\n\t\t{\n\t\t\tmspJavaVM = inpJavaVM;\n\t\t}\n\t\t//---------------------------------------------------\n\t\t//---------------------------------------------------\n\t\tvoid TouchInputJavaInterface::SetPointerSystem(PointerSystem* in_pointerSystem)\n\t\t{\n\t\t\ts_pointerSystem = in_pointerSystem;\n\t\t}\n\t\t//---------------------------------------------------\n\t\t//---------------------------------------------------\n\t\tPointerSystem* TouchInputJavaInterface::GetPointerSystem()\n\t\t{\n\t\t\treturn s_pointerSystem;\n\t\t}\n\t}\n}\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/JNI/Input/Pointer/TouchInputJavaInterface.h",
    "content": "//\n//  TouchInputJavaInterface.h\n//  ChilliSource\n//  Created by Ian Copland on 05/05/2011.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2011 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n\n#ifndef _CHILLISOURCE_PLATFORM_ANDROID_TOUCH_INPUT_JAVA_INTERFACE_JAVA_INTERFACE_\n#define _CHILLISOURCE_PLATFORM_ANDROID_TOUCH_INPUT_JAVA_INTERFACE_JAVA_INTERFACE_\n\n#include <ChilliSource/ChilliSource.h>\n#include <CSBackend/Platform/Android/Main/JNI/ForwardDeclarations.h>\n#include <CSBackend/Platform/Android/Main/JNI/Core/Java/_JavaInterface.h>\n\n#include <jni.h>\n#include <map>\n\nnamespace CSBackend\n{\n\tnamespace Android\n\t{\n\t\tclass TouchInputJavaInterface : public _IJavaInterface\n\t\t{\n\t\tpublic:\n\t\t\t//--------------------------------------------------------------------------------------\n\t\t\t/// Setup Java Interface\n\t\t\t///\n\t\t\t/// Sets up the java interface: stores the Virtual Machine, and Initialises any java\n\t\t\t/// methods callable from native.\n\t\t\t///\n\t\t\t/// @param a pointer to the virtual machine\n\t\t\t//--------------------------------------------------------------------------------------\n\t\t\tstatic void SetupJavaInterface(JavaVM* inpJavaVM);\n\t\t\t//---------------------------------------------------\n\t\t\t/// Sets the Pointer system that should be used. If\n\t\t\t/// null is passed to this, no pointer system will\n\t\t\t/// be used.\n\t\t\t///\n\t\t\t/// @author Ian Copland\n\t\t\t///\n\t\t\t/// @param The pointer system.\n\t\t\t//---------------------------------------------------\n\t\t\tstatic void SetPointerSystem(PointerSystem* in_pointerSystem);\n\t\t\t//---------------------------------------------------\n\t\t\t/// @author Ian Copland\n\t\t\t///\n\t\t\t/// @return The pointer system.\n\t\t\t//---------------------------------------------------\n\t\t\tstatic PointerSystem* GetPointerSystem();\n\t\tprivate:\n\t\t\tstatic PointerSystem* s_pointerSystem;\n\t\t};\n\t}\n}\n\n#endif\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/JNI/Input/TextEntry/TextEntry.cpp",
    "content": "//\n//  TextEntry.cpp\n//  ChilliSource\n//  Created by Scott Downie on 08/07/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n\n#include <CSBackend/Platform/Android/Main/JNI/Input/TextEntry/TextEntry.h>\n\n#include <CSBackend/Platform/Android/Main/JNI/Core/Java/JavaInterfaceManager.h>\n#include <CSBackend/Platform/Android/Main/JNI/Input/TextEntry/TextEntryJavaInterface.h>\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/Delegate/MakeDelegate.h>\n#include <ChilliSource/Core/Threading/TaskScheduler.h>\n\nnamespace CSBackend\n{\n\tnamespace Android\n\t{\n\t\tCS_DEFINE_NAMEDTYPE(TextEntry);\n\n\t\t//-------------------------------------------------------\n\t\t//-------------------------------------------------------\n\t\tTextEntry::TextEntry()\n\t\t{\n\t\t\tm_textEntryJI = JavaInterfaceManager::GetSingletonPtr()->GetJavaInterface<TextEntryJavaInterface>();\n\t\t\tif (m_textEntryJI == nullptr)\n\t\t\t{\n\t\t\t\tm_textEntryJI = TextEntryJavaInterfaceSPtr(new TextEntryJavaInterface());\n\t\t\t\tm_textEntryJI->SetTextChangedDelegate(ChilliSource::MakeDelegate(this, &TextEntry::OnTextChanged));\n\t\t\t\tm_textEntryJI->SetKeyboardDismissedDelegate(ChilliSource::MakeDelegate(this, &TextEntry::OnKeyboardDismissed));\n\t\t\t\tJavaInterfaceManager::GetSingletonPtr()->AddJavaInterface(m_textEntryJI);\n\t\t\t}\n\t\t}\n        //-------------------------------------------------------\n        //-------------------------------------------------------\n        bool TextEntry::IsA(ChilliSource::InterfaceIDType in_interfaceId) const\n        {\n            return in_interfaceId == ChilliSource::TextEntry::InterfaceID || in_interfaceId == TextEntry::InterfaceID;\n        }\n        //-------------------------------------------------------\n        //-------------------------------------------------------\n\t\tvoid TextEntry::Activate(const std::string& in_text, ChilliSource::TextEntryType in_type, ChilliSource::TextEntryCapitalisation in_capitalisation, const TextBufferChangedDelegate& in_changeDelegate, const TextInputDeactivatedDelegate& in_deactivateDelegate)\n\t\t{\n            CS_ASSERT(ChilliSource::Application::Get()->GetTaskScheduler()->IsMainThread(), \"Cannot activate system text entry outside of main thread.\");\n\t\t\tif (m_enabled == false)\n\t\t\t{\n\t\t\t\tm_textBufferChangedDelegate = in_changeDelegate;\n\t            m_textInputDeactivatedDelegate = in_deactivateDelegate;\n\t\t\t\tm_textEntryJI->SetCapitalisationMethod(in_capitalisation);\n\t\t\t\tm_textEntryJI->SetKeyboardType(in_type);\n\t\t\t\tm_textEntryJI->SetTextBuffer(in_text);\n\n\t\t\t\tm_textEntryJI->Activate();\n\t\t\t\tm_enabled = true;\n\t\t\t}\n\t\t}\n        //-------------------------------------------------------\n        //-------------------------------------------------------\n\t\tvoid TextEntry::Deactivate()\n\t\t{\n            CS_ASSERT(ChilliSource::Application::Get()->GetTaskScheduler()->IsMainThread(), \"Cannot deactivate system text entry outside of main thread.\");\n\t\t\tif (m_enabled == true)\n\t\t\t{\n\t\t\t\tm_textEntryJI->Deactivate();\n\t\t\t\tm_enabled = false;\n\n\t\t\t\tif(m_textInputDeactivatedDelegate != nullptr)\n\t\t\t\t{\n\t\t\t\t\tauto delegate = m_textInputDeactivatedDelegate;\n\t\t\t\t\tm_textInputDeactivatedDelegate = nullptr;\n\t\t\t\t\tdelegate();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t//-------------------------------------------------------\n\t\t//-------------------------------------------------------\n\t\tbool TextEntry::IsActive() const\n\t\t{\n            CS_ASSERT(ChilliSource::Application::Get()->GetTaskScheduler()->IsMainThread(), \"Cannot check system text entry activation status outside of main thread.\");\n\t\t\treturn m_enabled;\n\t\t}\n\t\t//-------------------------------------------------------\n\t\t//-------------------------------------------------------\n\t\tconst std::string& TextEntry::GetTextBuffer() const\n\t\t{\n            CS_ASSERT(ChilliSource::Application::Get()->GetTaskScheduler()->IsMainThread(), \"Cannot get system text entry buffer outside of main thread.\");\n            return m_text;\n\t\t}\n\t\t//-------------------------------------------------------\n\t\t//-------------------------------------------------------\n\t\tvoid TextEntry::SetTextBuffer(const std::string& in_text)\n\t\t{\n            CS_ASSERT(ChilliSource::Application::Get()->GetTaskScheduler()->IsMainThread(), \"Cannot set system text entry buffer outside of main thread.\");\n\t\t\tm_text = in_text;\n\t\t\tm_textEntryJI->SetTextBuffer(m_text);\n\t\t}\n\t\t//-------------------------------------------------------\n\t\t//-------------------------------------------------------\n\t\tvoid TextEntry::OnTextChanged(const std::string& in_text)\n\t\t{\n            CS_ASSERT(ChilliSource::Application::Get()->GetTaskScheduler()->IsMainThread(), \"Cannot handle system text entry callback outside of main thread.\");\n\t\t\tif(m_text == in_text)\n\t\t\t\treturn;\n\n            bool acceptText = true;\n\n            if(m_textBufferChangedDelegate != nullptr)\n            {\n                acceptText = m_textBufferChangedDelegate(in_text);\n            }\n\n            if(acceptText == true)\n            {\n                m_text = in_text;\n            }\n            else\n            {\n            \tm_textEntryJI->SetTextBuffer(m_text);\n            }\n\t\t}\n\t\t//-------------------------------------------------------\n\t\t//-------------------------------------------------------\n\t\tvoid TextEntry::OnKeyboardDismissed()\n\t\t{\n            CS_ASSERT(ChilliSource::Application::Get()->GetTaskScheduler()->IsMainThread(), \"Cannot handle keyboard dismissal outside of main thread.\");\n\t\t\tif (m_enabled == true)\n\t\t\t{\n\t\t\t\tm_enabled = false;\n\n\t\t\t\tif(m_textInputDeactivatedDelegate != nullptr)\n\t\t\t\t{\n\t\t\t\t\tauto delegate = m_textInputDeactivatedDelegate;\n\t\t\t\t\tm_textInputDeactivatedDelegate = nullptr;\n\t\t\t\t\tdelegate();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t//-------------------------------------------------------\n\t\t//-------------------------------------------------------\n\t\tTextEntry::~TextEntry()\n\t\t{\n\t\t\tm_textEntryJI->SetTextChangedDelegate(nullptr);\n\t\t\tm_textEntryJI->SetKeyboardDismissedDelegate(nullptr);\n\t\t\tm_textEntryJI->Deactivate();\n\t\t}\n\t}\n}\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/JNI/Input/TextEntry/TextEntry.h",
    "content": "//\n//  TextEntry.h\n//  ChilliSource\n//  Created by Scott Downie on 08/07/2014\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n\n#ifndef _CSBACKEND_PLATFORM_ANDROID_INPUT_TEXTENTRY_TEXTENTRY_H_\n#define _CSBACKEND_PLATFORM_ANDROID_INPUT_TEXTENTRY_TEXTENTRY_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <CSBackend/Platform/Android/Main/JNI/ForwardDeclarations.h>\n#include <ChilliSource/Input/TextEntry/TextEntry.h>\n#include <ChilliSource/Input/TextEntry/TextEntryCapitalisation.h>\n#include <ChilliSource/Input/TextEntry/TextEntryType.h>\n\n\nnamespace CSBackend\n{\n\tnamespace Android\n\t{\n\t\t//----------------------------------------------------------------\n\t\t/// The Android backend to the text entry system. This provides access\n\t\t/// to the Android virtual keyboard functionality.\n\t\t///\n        /// The methods in this class are not thread-safe and must be called\n        /// from the main thread.\n        ///\n\t\t/// @author Ian Copland\n\t\t//----------------------------------------------------------------\n\t\tclass TextEntry final : public ChilliSource::TextEntry\n\t\t{\n\t\tpublic:\n\n            CS_DECLARE_NAMEDTYPE(TextEntry);\n            //-------------------------------------------------------\n            /// @author S Downie\n            ///\n            /// @param Interface ID\n            ///\n            /// @return Whether this system implements the given inteface\n            //-------------------------------------------------------\n            bool IsA(ChilliSource::InterfaceIDType in_interfaceId) const override;\n            //-------------------------------------------------------\n            /// The system will now receive text input. This will also\n            /// show the virtual keyboard if required\n            ///\n            /// @author S Downie\n            ///\n            /// @param Initial buffer contents\n            /// @param Preferred keyboard type\n            /// @param Preferred capitalisation method\n            /// @param Text changed delegate\n            /// @param Deactivate delegate\n            //-------------------------------------------------------\n\t\t\tvoid Activate(const std::string& in_text, ChilliSource::TextEntryType in_type, ChilliSource::TextEntryCapitalisation in_capitalisation, const TextBufferChangedDelegate& in_changeDelegate, const TextInputDeactivatedDelegate& in_deactivateDelegate) override;\n            //-------------------------------------------------------\n            /// The system will no longer receive text input. This\n            /// will also hide the virtual keyboard if required\n            ///\n            /// @author S Downie\n            //-------------------------------------------------------\n\t\t\tvoid Deactivate() override;\n\t\t\t//-------------------------------------------------------\n\t\t\t/// @author Ian Copland\n\t\t\t///\n\t\t\t/// @return Whether or not text input is currently\n\t\t\t/// enabled.\n\t\t\t//-------------------------------------------------------\n\t\t\tbool IsActive() const override;\n\t\t\t//-------------------------------------------------------\n\t\t\t/// @author Ian Copland\n\t\t\t///\n\t\t\t/// @return The current text input buffer (UTF-8).\n\t\t\t//-------------------------------------------------------\n\t\t\tconst std::string& GetTextBuffer() const override;\n\t\t\t//-------------------------------------------------------\n\t\t\t/// @author Ian Copland\n\t\t\t///\n\t\t\t/// @param The new text input buffer (UTF-8).\n\t\t\t//-------------------------------------------------------\n\t\t\tvoid SetTextBuffer(const std::string& in_text) override;\n\t\t\t//-------------------------------------------------------\n\t\t\t/// Destructor.\n\t\t\t///\n\t\t\t/// @author S Downie\n\t\t\t//-------------------------------------------------------\n\t\t\t~TextEntry();\n\n\t\tprivate:\n\t\t\tfriend ChilliSource::TextEntryUPtr ChilliSource::TextEntry::Create();\n\n\t\t\t//-------------------------------------------------------\n\t\t\t/// Constructor. Declared private to force the use of the\n\t\t\t/// factory method.\n\t\t\t///\n\t\t\t/// @author Ian Copland\n\t\t\t//-------------------------------------------------------\n\t\t\tTextEntry();\n\t\t\t//-------------------------------------------------------\n\t\t\t/// Called when the text entry buffer has changed.\n\t\t\t///\n\t\t\t/// @author S Downie\n\t\t\t///\n\t\t\t/// @param The new text.\n\t\t\t//-------------------------------------------------------\n\t\t\tvoid OnTextChanged(const std::string& in_text);\n\t\t\t//-------------------------------------------------------\n\t\t\t/// Called when the keyboard is dismissed.\n\t\t\t///\n\t\t\t/// @author Ian Copland\n\t\t\t//-------------------------------------------------------\n\t\t\tvoid OnKeyboardDismissed();\n\n\t\t\tTextBufferChangedDelegate m_textBufferChangedDelegate;\n            TextInputDeactivatedDelegate m_textInputDeactivatedDelegate;\n\n\t\t\tbool m_enabled = false;\n\t\t\tstd::string m_text;\n\t\t\tTextEntryJavaInterfaceSPtr m_textEntryJI;\n\t\t};\n\t}\n}\n\n#endif\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/JNI/Input/TextEntry/TextEntryJavaInterface.cpp",
    "content": "//\n//  TextEntryJavaInterface.cpp\n//  ChilliSource\n//  Created by Ian Copland on 04/02/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n\n#include <CSBackend/Platform/Android/Main/JNI/Input/TextEntry/TextEntryJavaInterface.h>\n\n#include <CSBackend/Platform/Android/Main/JNI/Core/Java/JavaInterfaceManager.h>\n#include <CSBackend/Platform/Android/Main/JNI/Core/Java/JavaUtils.h>\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/Threading/TaskScheduler.h>\n\n#include <jni.h>\n\n//-----------------------------------------------\n/// C function declarations\n//-----------------------------------------------\nextern \"C\"\n{\n\t//-----------------------------------------------\n\t/// Called from java when the text buffer changes\n\t///\n\t/// @author S Downie\n\t///\n\t/// @param The jni environment.\n\t/// @param The java object calling the function.\n\t/// @param The new contents of the text buffer.\n\t//-----------------------------------------------\n\tvoid Java_com_chilliworks_chillisource_input_TextEntryNativeInterface_nativeOnTextChanged(JNIEnv* in_env, jobject in_this, jstring in_text);\n\t//-----------------------------------------------\n\t/// Native On Keyboard Dismissed\n\t///\n\t/// Called from java when the keyboard is dismissed.\n\t///\n\t/// @param The jni environment.\n\t/// @param The java object calling the function.\n\t//-----------------------------------------------\n\tvoid Java_com_chilliworks_chillisource_input_TextEntryNativeInterface_nativeOnKeyboardDismissed(JNIEnv* inpEnv, jobject inThis);\n}\n//-----------------------------------------------\n//-----------------------------------------------\nvoid Java_com_chilliworks_chillisource_input_TextEntryNativeInterface_nativeOnTextChanged(JNIEnv* in_env, jobject in_this, jstring in_text)\n{\n\tCSBackend::Android::TextEntryJavaInterfaceSPtr textEntryJI = CSBackend::Android::JavaInterfaceManager::GetSingletonPtr()->GetJavaInterface<CSBackend::Android::TextEntryJavaInterface>();\n\tif (textEntryJI != nullptr)\n\t{\n\t\tstd::string text = CSBackend::Android::JavaUtils::CreateSTDStringFromJString(in_text);\n\n\t\tChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_mainThread, [=](const ChilliSource::TaskContext&)\n\t\t{\n\t\t\ttextEntryJI->OnTextChanged(text);\n\t\t});\n\t}\n\tin_env->DeleteLocalRef(in_text);\n}\n//-----------------------------------------------\n//-----------------------------------------------\nvoid Java_com_chilliworks_chillisource_input_TextEntryNativeInterface_nativeOnKeyboardDismissed(JNIEnv* in_env, jobject in_this)\n{\n\tCSBackend::Android::TextEntryJavaInterfaceSPtr textEntryJI = CSBackend::Android::JavaInterfaceManager::GetSingletonPtr()->GetJavaInterface<CSBackend::Android::TextEntryJavaInterface>();\n\tif (textEntryJI != nullptr)\n\t{\n\t\tChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_mainThread, [=](const ChilliSource::TaskContext&)\n\t\t{\n\t\t\ttextEntryJI->OnKeyboardDismissed();\n\t\t});\n\t}\n}\n\nnamespace CSBackend\n{\n\tnamespace Android\n\t{\n\t\tnamespace\n\t\t{\n\t\t\t//-----------------------------------------------\n\t\t\t/// Keyboard Type To Integer\n\t\t\t///\n\t\t\t/// Converts from the keyboard type enum to an\n\t\t\t/// integer that can be passed on to the Java\n\t\t\t/// side of the engine.\n\t\t\t///\n\t\t\t/// @param The keyboard type to convert.\n\t\t\t/// @return The keyboard type in integer form.\n\t\t\t//-----------------------------------------------\n\t\t\ts32 KeyboardTypeToInteger(ChilliSource::TextEntryType ineKeyboardType)\n\t\t\t{\n\t\t\t\tswitch (ineKeyboardType)\n\t\t\t\t{\n\t\t\t\tcase ChilliSource::TextEntryType::k_text:\n\t\t\t\t\treturn 0;\n\t\t\t\tcase ChilliSource::TextEntryType::k_numeric:\n\t\t\t\t\treturn 1;\n\t\t\t\tdefault:\n\t\t\t\t\tCS_LOG_ERROR(\"Invalid keyboard type, cannot be converted.\");\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\t//-----------------------------------------------\n\t\t\t/// Keyboard Capitalisation To Integer\n\t\t\t///\n\t\t\t/// Converts from the Keyboard Capitalisation enum\n\t\t\t/// to an integer that can be passed on to the\n\t\t\t/// Java side of the engine.\n\t\t\t///\n\t\t\t/// @param The Keyboard Capitalisation to convert.\n\t\t\t/// @return The Keyboard Capitalisation in integer\n\t\t\t/// form.\n\t\t\t//-----------------------------------------------\n\t\t\ts32 KeyboardCapitalisationToInteger(ChilliSource::TextEntryCapitalisation ineKeyboardCapitalisation)\n\t\t\t{\n\t\t\t\tswitch (ineKeyboardCapitalisation)\n\t\t\t\t{\n\t\t\t\tcase ChilliSource::TextEntryCapitalisation::k_none:\n\t\t\t\t\treturn 0;\n\t\t\t\tcase ChilliSource::TextEntryCapitalisation::k_sentences:\n\t\t\t\t\treturn 1;\n\t\t\t\tcase ChilliSource::TextEntryCapitalisation::k_words:\n\t\t\t\t\treturn 2;\n\t\t\t\tcase ChilliSource::TextEntryCapitalisation::k_all:\n\t\t\t\t\treturn 3;\n\t\t\t\tdefault:\n\t\t\t\t\tCS_LOG_ERROR(\"Invalid keyboard capitalisation, cannot be converted.\");\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tCS_DEFINE_NAMEDTYPE(TextEntryJavaInterface);\n\t\t//-----------------------------------------------\n\t\t//-----------------------------------------------\n\t\tTextEntryJavaInterface::TextEntryJavaInterface()\n\t\t{\n\t\t\tCreateNativeInterface(\"com/chilliworks/chillisource/input/TextEntryNativeInterface\");\n\t\t\tCreateMethodReference(\"activate\", \"()V\");\n\t\t\tCreateMethodReference(\"deactivate\", \"()V\");\n\t\t\tCreateMethodReference(\"setKeyboardType\", \"(I)V\");\n\t\t\tCreateMethodReference(\"setCapitalisationMethod\", \"(I)V\");\n\t\t\tCreateMethodReference(\"setTextBuffer\", \"(Ljava/lang/String;)V\");\n\t\t}\n\t\t//-----------------------------------------------\n\t\t//-----------------------------------------------\n\t\tbool TextEntryJavaInterface::IsA(ChilliSource::InterfaceIDType inInterfaceID) const\n\t\t{\n\t\t\treturn (TextEntryJavaInterface::InterfaceID == inInterfaceID);\n\t\t}\n\t\t//-----------------------------------------------\n\t\t//-----------------------------------------------\n\t\tvoid TextEntryJavaInterface::SetTextChangedDelegate(const TextChangedDelegate& in_delegate)\n\t\t{\n\t\t\tm_textChangedDelegate = in_delegate;\n\t\t}\n\t\t//-----------------------------------------------\n\t\t//-----------------------------------------------\n\t\tvoid TextEntryJavaInterface::SetKeyboardDismissedDelegate(const KeyboardDismissedDelegate& inDelegate)\n\t\t{\n\t\t\tmKeyboardDismissedDelegate = inDelegate;\n\t\t}\n\t\t//-----------------------------------------------\n\t\t//-----------------------------------------------\n\t\tvoid TextEntryJavaInterface::Activate()\n\t\t{\n\t\t\tJNIEnv* pEnv = JavaInterfaceManager::GetSingletonPtr()->GetJNIEnvironmentPtr();\n\t\t\tpEnv->CallVoidMethod(GetJavaObject(), GetMethodID(\"activate\"));\n\t\t}\n\t\t//-----------------------------------------------\n\t\t//-----------------------------------------------\n\t\tvoid TextEntryJavaInterface::Deactivate()\n\t\t{\n\t\t\tJNIEnv* pEnv = JavaInterfaceManager::GetSingletonPtr()->GetJNIEnvironmentPtr();\n\t\t\tpEnv->CallVoidMethod(GetJavaObject(), GetMethodID(\"deactivate\"));\n\t\t}\n\t\t//-------------------------------------------------------\n\t\t//-------------------------------------------------------\n\t\tvoid TextEntryJavaInterface::SetTextBuffer(const std::string& in_text)\n\t\t{\n        \tJNIEnv* env = JavaInterfaceManager::GetSingletonPtr()->GetJNIEnvironmentPtr();\n        \tjstring text = JavaUtils::CreateJStringFromSTDString(in_text);\n        \tenv->CallVoidMethod(GetJavaObject(), GetMethodID(\"setTextBuffer\"), text);\n        \tenv->DeleteLocalRef(text);\n\t\t}\n\t\t//-------------------------------------------\n\t\t//-------------------------------------------\n        void TextEntryJavaInterface::SetKeyboardType(ChilliSource::TextEntryType ineKeyboardType)\n        {\n        \tJNIEnv* pEnv = JavaInterfaceManager::GetSingletonPtr()->GetJNIEnvironmentPtr();\n        \ts32 dwKeyboardType = KeyboardTypeToInteger(ineKeyboardType);\n        \tpEnv->CallVoidMethod(GetJavaObject(), GetMethodID(\"setKeyboardType\"), dwKeyboardType);\n        }\n\t\t//-------------------------------------------\n\t\t//-------------------------------------------\n        void TextEntryJavaInterface::SetCapitalisationMethod(ChilliSource::TextEntryCapitalisation ineKeyboardCapitalisation)\n        {\n        \tJNIEnv* pEnv = JavaInterfaceManager::GetSingletonPtr()->GetJNIEnvironmentPtr();\n        \ts32 dwKeyboardCapitalisation = KeyboardCapitalisationToInteger(ineKeyboardCapitalisation);\n        \tpEnv->CallVoidMethod(GetJavaObject(), GetMethodID(\"setCapitalisationMethod\"), dwKeyboardCapitalisation);\n        }\n\t\t//-----------------------------------------------\n\t\t//-----------------------------------------------\n\t\tvoid TextEntryJavaInterface::OnTextChanged(const std::string& in_text)\n\t\t{\n\t\t\tif (m_textChangedDelegate != nullptr)\n\t\t\t{\n\t\t\t\tm_textChangedDelegate(in_text);\n\t\t\t}\n\t\t}\n\t\t//-----------------------------------------------\n\t\t//-----------------------------------------------\n\t\tvoid TextEntryJavaInterface::OnKeyboardDismissed()\n\t\t{\n\t\t\tif (mKeyboardDismissedDelegate != nullptr)\n\t\t\t{\n\t\t\t\tmKeyboardDismissedDelegate();\n\t\t\t}\n\t\t}\n\t}\n}\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/JNI/Input/TextEntry/TextEntryJavaInterface.h",
    "content": "//\n//  TextEntryJavaInterface.h\n//  ChilliSource\n//  Created by Ian Copland on 04/02/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n\n#ifndef _CHILLISOURCE_PLATFORM_ANDROID_INPUT_TEXTENTRY_TEXTENTRYJAVAINTERFACE_H_\n#define _CHILLISOURCE_PLATFORM_ANDROID_INPUT_TEXTENTRY_TEXTENTRYJAVAINTERFACE_H_\n\n#include <CSBackend/Platform/Android/Main/JNI/ForwardDeclarations.h>\n#include <CSBackend/Platform/Android/Main/JNI/Core/Java/JavaInterface.h>\n#include <ChilliSource/Input/TextEntry/TextEntry.h>\n#include <ChilliSource/Input/TextEntry/TextEntryCapitalisation.h>\n#include <ChilliSource/Input/TextEntry/TextEntryType.h>\n\nnamespace CSBackend\n{\n\tnamespace Android\n\t{\n\t\t//=====================================================\n\t\t/// Text Entry Java Interface\n\t\t///\n\t\t/// A Java Interface for Android virtual keyboard input.\n\t\t//======================================================\n\t\tclass TextEntryJavaInterface : public IJavaInterface\n\t\t{\n\t\tpublic:\n\t\t\tCS_DECLARE_NAMEDTYPE(TextEntryJavaInterface);\n\t\t\t//-----------------------------------------------\n\t\t\t/// Events\n\t\t\t//-----------------------------------------------\n\t\t\ttypedef std::function<void(const std::string&)> TextChangedDelegate;\n\t\t\ttypedef std::function<void()> KeyboardDismissedDelegate;\n\t\t\t//-----------------------------------------------\n\t\t\t/// Constructor\n\t\t\t//-----------------------------------------------\n\t\t\tTextEntryJavaInterface();\n\t\t\t//-----------------------------------------------\n\t\t\t/// Is A\n\t\t\t///\n\t\t\t/// @return whether or not this object implements\n\t\t\t/// the given interface.\n\t\t\t//-----------------------------------------------\n\t\t\tbool IsA(ChilliSource::InterfaceIDType inInterfaceID) const;\n\t\t\t//-------------------------------------------------------\n\t\t\t/// @author Ian Copland\n\t\t\t///\n\t\t\t/// @param The new text input buffer (UTF-8).\n\t\t\t//-------------------------------------------------------\n\t\t\tvoid SetTextBuffer(const std::string& in_text);\n\t\t\t//-----------------------------------------------\n\t\t\t/// Set the delegate that is called whenever\n\t\t\t/// the text buffer changes\n\t\t\t///\n\t\t\t/// @author S Downie\n\t\t\t///\n\t\t\t/// @param Delegate\n\t\t\t//-----------------------------------------------\n\t\t\tvoid SetTextChangedDelegate(const TextChangedDelegate& inDelegate);\n\t\t\t//-----------------------------------------------\n\t\t\t/// Set Keyboard Dismissed Delegate\n\t\t\t///\n\t\t\t/// @param The delegate that will be called when\n\t\t\t/// the keyboard is dismissed.\n\t\t\t//-----------------------------------------------\n\t\t\tvoid SetKeyboardDismissedDelegate(const KeyboardDismissedDelegate& inDelegate);\n\t\t\t//-----------------------------------------------\n\t\t\t/// Activate\n\t\t\t///\n\t\t\t/// Displays the software keyboard and starts\n\t\t\t/// reading from the hardware keyboard if there\n\t\t\t/// is one.\n\t\t\t//-----------------------------------------------\n\t\t\tvoid Activate();\n\t\t\t//-----------------------------------------------\n\t\t\t/// Deactivate\n\t\t\t///\n\t\t\t/// Hides the software keyboard and stops reading\n\t\t\t/// from the hardware keyboard if there is one.\n\t\t\t//-----------------------------------------------\n\t\t\tvoid Deactivate();\n\t\t\t//-------------------------------------------\n\t\t\t/// Set Keyboard Type\n\t\t\t///\n\t\t\t/// @param The keyboard type to be used the\n\t\t\t/// next time the keyboard is displayed.\n\t\t\t//-------------------------------------------\n            void SetKeyboardType(ChilliSource::TextEntryType ineKeyboardType);\n\t\t\t//-------------------------------------------\n\t\t\t/// Set Capitalisation Method\n\t\t\t///\n\t\t\t/// @param The capitalisation method to be\n            /// used the next time the keyboard is\n            /// displayed.\n\t\t\t//-------------------------------------------\n            void SetCapitalisationMethod(ChilliSource::TextEntryCapitalisation ineKeyboardCapitalisation);\n\t\t\t//-----------------------------------------------\n\t\t\t/// Called when the contents of the text buffer\n            /// has changed\n            ///\n            /// @author S Downie\n\t\t\t///\n\t\t\t/// @param The new text (UTF-8).\n\t\t\t//-----------------------------------------------\n\t\t\tvoid OnTextChanged(const std::string& in_text);\n\t\t\t//-----------------------------------------------\n\t\t\t/// On Keyboard Dismissed\n\t\t\t///\n\t\t\t/// Called when the keyboard is dismissed.\n\t\t\t//-----------------------------------------------\n\t\t\tvoid OnKeyboardDismissed();\n\t\tprivate:\n\t\t\tTextChangedDelegate m_textChangedDelegate;\n\t\t\tKeyboardDismissedDelegate mKeyboardDismissedDelegate;\n\t\t};\n\t}\n}\n\n#endif\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/JNI/Networking/Http/HttpRequest.cpp",
    "content": "//\n//  HttpRequest.cpp\n//  ChilliSource\n//  Created by Ian Copland on 08/11/2011.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2011 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n\n#include <CSBackend/Platform/Android/Main/JNI/Networking/Http/HttpRequest.h>\n\n#include <CSBackend/Platform/Android/Main/JNI/Core/Java/JavaClass.h>\n#include <CSBackend/Platform/Android/Main/JNI/Core/Java/JavaClassDef.h>\n#include <CSBackend/Platform/Android/Main/JNI/Core/Java/JavaInterfaceManager.h>\n#include <CSBackend/Platform/Android/Main/JNI/Core/Java/JavaUtils.h>\n#include <CSBackend/Platform/Android/Main/JNI/Core/Java/BoxedPointer.h>\n\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/Threading/TaskScheduler.h>\n\n//------------------------------------------\n/// C function declarations\n//------------------------------------------\nextern \"C\"\n{\n\t//-----------------------------------------------------------------------\n\t/// Called when http request contents are flushed due to exceeding\n\t/// the buffer size\n    ///\n    /// @author HMcLaughlin\n\t///\n    /// @param in_env - The jni environment.\n    /// @param in_this - The java object calling the function.\n    /// @param in_objectPointer - BoxedPointer Java object\n    /// @param in_data - Partial Data\n    /// @param in_dataLength - Length of partial data\n    /// @param in_responseCode - Response code\n\t//-----------------------------------------------------------------------\n\tvoid Java_com_chilliworks_chillisource_networking_HttpRequest_onBufferFlushed(JNIEnv* in_env, jobject in_this, jobject in_objectPointer, jbyteArray in_data, jint in_dataLength, jint in_responseCode);\n\t//-----------------------------------------------------------------------\n    /// Called when the connection has finished\n    ///\n    /// @author HMcLaughlin\n    ///\n    /// @param in_env - The jni environment.\n    /// @param in_this - The java object calling the function.\n    /// @param in_objectPointer - BoxedPointer Java object\n    /// @param in_resultCode - Result code\n    /// @param in_data - Data\n    /// @param in_dataLength - Length of partial data\n    /// @param in_responseCode - Response code\n    //-----------------------------------------------------------------------\n    void Java_com_chilliworks_chillisource_networking_HttpRequest_onComplete(JNIEnv* in_env, jobject in_this, jobject in_objectPointer, jint in_resultCode, jbyteArray in_data, jint in_dataLength, jint in_responseCode);\n}\n//-----------------------------------------------------------------------\n//-----------------------------------------------------------------------\nvoid Java_com_chilliworks_chillisource_networking_HttpRequest_onBufferFlushed(JNIEnv* in_env, jobject in_this, jobject in_objectPointer, jbyteArray in_data, jint in_dataLength, jint in_responseCode)\n{\n\tCSBackend::Android::JavaClassSPtr javaBoxedPointer = CSBackend::Android::JavaClassSPtr(new CSBackend::Android::JavaClass(in_objectPointer, CSBackend::Android::BoxedPointer::GetBoxedPointerClassDef()));\n\n\tCSBackend::Android::HttpRequest* httpRequest = CSBackend::Android::BoxedPointer::Unbox<CSBackend::Android::HttpRequest>(javaBoxedPointer.get());\n\tstd::string data = CSBackend::Android::JavaUtils::CreateSTDStringFromJByteArray(in_data, in_dataLength);\n\n\tChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_mainThread, [=](const ChilliSource::TaskContext&)\n\t{\n\t\thttpRequest->OnFlushed(data, (u32)in_responseCode);\n\t});\n}\n//-----------------------------------------------------------------------\n//-----------------------------------------------------------------------\nvoid Java_com_chilliworks_chillisource_networking_HttpRequest_onComplete(JNIEnv* in_env, jobject in_this, jobject in_objectPointer, jint in_resultCode, jbyteArray in_data, jint in_dataLength, jint in_responseCode)\n{\n\tCSBackend::Android::JavaClassSPtr javaBoxedPointer = CSBackend::Android::JavaClassSPtr(new CSBackend::Android::JavaClass(in_objectPointer, CSBackend::Android::BoxedPointer::GetBoxedPointerClassDef()));\n\n\tCSBackend::Android::HttpRequest* httpRequest = CSBackend::Android::BoxedPointer::Unbox<CSBackend::Android::HttpRequest>(javaBoxedPointer.get());\n\tstd::string data = CSBackend::Android::JavaUtils::CreateSTDStringFromJByteArray(in_data, in_dataLength);\n\n\tChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_mainThread, [=](const ChilliSource::TaskContext&)\n\t{\n\t\thttpRequest->OnComplete((u32)in_resultCode, data, (u32)in_responseCode);\n\t});\n}\n\nnamespace CSBackend\n{\n\tnamespace Android\n\t{\n\t\t//------------------------------------------------------------------\n\t\t//------------------------------------------------------------------\n\t\tHttpRequest::HttpRequest(Type in_type, const std::string& in_url, const std::string& in_body, const ChilliSource::ParamDictionary& in_headers, u32 in_timeoutSecs, u32 in_maxBufferSize, const Delegate& in_delegate)\n\t    : m_type(in_type), m_url(in_url), m_body(in_body), m_headers(in_headers), m_completionDelegate(in_delegate), m_timeoutSecs(in_timeoutSecs), m_maxBufferSize(in_maxBufferSize)\n\t\t{\n\t\t\tCS_ASSERT(m_completionDelegate, \"Http request cannot have null delegate\");\n\n\t\t\t//Create a java BoxdPointer for this instance\n\t\t\tJavaClassUPtr boxedPointerClass = BoxedPointer::Box(this);\n\n\t\t\t//Create a java HttpRequest class definition\n\t\t\tJavaClassDef javaRequestClassDef(\"com/chilliworks/chillisource/networking/HttpRequest\", \"(Lcom/chilliworks/chillisource/core/BoxedPointer;)V\");\n\t\t\tjavaRequestClassDef.AddMethod(\"performHttpRequest\", \"(Ljava/lang/String;Z[Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;II)V\");\n\t\t\tjavaRequestClassDef.AddMethod(\"getDownloadedBytes\", \"()J\");\n\t\t\tjavaRequestClassDef.AddMethod(\"getExpectedSize\", \"()J\");\n\n\t\t\t//Create a java HttpRequest instance\n\t\t\tm_javaHttpRequest = JavaClassSPtr(new JavaClass(javaRequestClassDef, boxedPointerClass->GetJavaObject()));\n\n\t\t\t//Immediately make the request\n\t\t\tPerformRequest();\n\t\t}\n\t\t//------------------------------------------------------------------\n\t\t//------------------------------------------------------------------\n\t\tvoid HttpRequest::PerformRequest()\n\t\t{\n\t\t\tJNIEnv* env = JavaInterfaceManager::GetSingletonPtr()->GetJNIEnvironmentPtr();\n\n            //Create an array out headers ParamDictionary as this is easier to pass to Java\n            jstring emptyString = env->NewStringUTF(\"\");\n            jclass stringClass = env->FindClass(\"java/lang/String\");\n            jobjectArray keys = env->NewObjectArray(m_headers.size(), stringClass, emptyString);\n            jobjectArray values = env->NewObjectArray(m_headers.size(), stringClass, emptyString);\n\n            u32 paramCount = 0;\n            for(const auto& it : m_headers)\n            {\n            \tjstring first = JavaUtils::CreateJStringFromSTDString(it.first);\n            \tjstring second = JavaUtils::CreateJStringFromSTDString(it.second);\n            \tenv->SetObjectArrayElement(keys, paramCount, first);\n            \tenv->SetObjectArrayElement(values, paramCount, second);\n            \tenv->DeleteLocalRef(first);\n            \tenv->DeleteLocalRef(second);\n            \tparamCount++;\n            }\n\n            //create the strings\n            jstring url = JavaUtils::CreateJStringFromSTDString(m_url);\n            jstring body = JavaUtils::CreateJStringFromSTDString(m_body);\n\n            bool isPost = m_type == ChilliSource::HttpRequest::Type::k_post;\n\n\t\t\t//Finally call the java function\n\t\t\tm_javaHttpRequest->CallVoidMethod(\"performHttpRequest\", url, isPost, keys, values, body, m_timeoutSecs, m_maxBufferSize);\n\n            //delete all local references\n            env->DeleteLocalRef(url);\n            env->DeleteLocalRef(body);\n            env->DeleteLocalRef(keys);\n            env->DeleteLocalRef(values);\n            env->DeleteLocalRef(emptyString);\n            env->DeleteLocalRef(stringClass);\n\t\t}\n\t\t//--------------------------------------------------------------------------------------\n\t\t//--------------------------------------------------------------------------------------\n\t\tvoid HttpRequest::OnFlushed(const std::string& in_data, u32 in_responseCode)\n\t\t{\n\t\t\tm_completionDelegate(this, ChilliSource::HttpResponse(ChilliSource::HttpResponse::Result::k_flushed, in_responseCode, in_data));\n\t\t}\n\t\t//--------------------------------------------------------------------------------------\n\t\t//--------------------------------------------------------------------------------------\n\t\tvoid HttpRequest::OnComplete(u32 in_resultCode, const std::string& in_data, u32 in_responseCode)\n\t\t{\n\t\t\tif(m_isRequestCancelled == false && m_completionDelegate)\n\t\t\t{\n\t\t\t\tm_completionDelegate(this, ChilliSource::HttpResponse((ChilliSource::HttpResponse::Result)in_resultCode, in_responseCode, in_data));\n\t\t\t}\n\t\t}\n\t\t//----------------------------------------------------------------------------------------\n\t\t//----------------------------------------------------------------------------------------\n\t\tvoid HttpRequest::Cancel()\n\t\t{\n            m_shouldKillThread = true;\n            m_isRequestCancelled = true;\n\t\t}\n\t\t//----------------------------------------------------------------------------------------\n\t\t//----------------------------------------------------------------------------------------\n\t\tbool HttpRequest::HasCompleted() const\n\t\t{\n\t\t\treturn m_isRequestComplete;\n\t\t}\n        //----------------------------------------------------------------------------------------\n        //----------------------------------------------------------------------------------------\n        HttpRequest::Type HttpRequest::GetType() const\n        {\n            return m_type;\n        }\n        //----------------------------------------------------------------------------------------\n        //----------------------------------------------------------------------------------------\n        const std::string& HttpRequest::GetUrl() const\n        {\n            return m_url;\n        }\n        //----------------------------------------------------------------------------------------\n        //----------------------------------------------------------------------------------------\n        const std::string& HttpRequest::GetBody() const\n        {\n            return m_body;\n        }\n        //----------------------------------------------------------------------------------------\n        //----------------------------------------------------------------------------------------\n        const ChilliSource::ParamDictionary& HttpRequest::GetHeaders() const\n        {\n            return m_headers;\n        }\n        //----------------------------------------------------------------------------------------\n        //----------------------------------------------------------------------------------------\n        u64 HttpRequest::GetExpectedSize() const\n        {\n\t\t\treturn m_javaHttpRequest->CallLongMethod(\"getExpectedSize\");\n        }\n        //----------------------------------------------------------------------------------------\n        //----------------------------------------------------------------------------------------\n        u64 HttpRequest::GetDownloadedBytes() const\n        {\n\t\t\treturn m_javaHttpRequest->CallLongMethod(\"getDownloadedBytes\");\n        }\n\t}\n}\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/JNI/Networking/Http/HttpRequest.h",
    "content": "//\n//  HttpRequest.h\n//  ChilliSource\n//  Created by Ian Copland on 08/11/2011.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2011 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n\n#ifndef _CSBACKEND_PLATFORM_ANDROID_HTTP_HTTPREQUEST_H_\n#define _CSBACKEND_PLATFORM_ANDROID_HTTP_HTTPREQUEST_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <CSBackend/Platform/Android/Main/JNI/ForwardDeclarations.h>\n#include <ChilliSource/Networking/Http/HttpRequest.h>\n#include <ChilliSource/Networking/Http/HttpResponse.h>\n\nnamespace CSBackend\n{\n\tnamespace Android\n\t{\t\n\t\t//----------------------------------------------------------------------------------------\n\t\t/// Concrete implementation of Android http request using the Java HttpConnection library. Requests\n\t\t/// are performed on a background thread.\n\t\t///\n\t\t/// @author Ian Copland\n\t\t//----------------------------------------------------------------------------------------\n\t\tclass HttpRequest final : public ChilliSource::HttpRequest\n\t\t{\n\t\tpublic:\n            //----------------------------------------------------------------------------------------\n            /// @author S Downie\n            ///\n            /// @return The type of the request (POST or GET)\n            //----------------------------------------------------------------------------------------\n            Type GetType() const override;\n            //----------------------------------------------------------------------------------------\n            /// @author S Downie\n            ///\n            /// @return The original url to which the request was sent\n            //----------------------------------------------------------------------------------------\n            const std::string& GetUrl() const override;\n            //----------------------------------------------------------------------------------------\n            /// @author S Downie\n            ///\n            /// @return The body of the POST request (GET request will return empty)\n            //----------------------------------------------------------------------------------------\n            const std::string& GetBody() const override;\n            //----------------------------------------------------------------------------------------\n            /// @author S Downie\n            ///\n            /// @return The original headers of the request as keys/values\n            //----------------------------------------------------------------------------------------\n            const ChilliSource::ParamDictionary& GetHeaders() const override;\n            //----------------------------------------------------------------------------------------\n            /// @author HMcLaughlin\n            ///\n            /// @return The expected total size of the request\n            //----------------------------------------------------------------------------------------\n            u64 GetExpectedSize() const override;\n            //----------------------------------------------------------------------------------------\n            /// @author HMcLaughlin\n            ///\n            /// @return The current transferred size of the request\n            //----------------------------------------------------------------------------------------\n            u64 GetDownloadedBytes() const override;\n            //----------------------------------------------------------------------------------------\n            /// Close the request. Note: The completion delegate is not invoked\n            ///\n            /// @author Ian Copland\n            //----------------------------------------------------------------------------------------\n            void Cancel() override;\n\t\t\t//--------------------------------------------------------------------------------------\n\t\t\t/// Called by Java when the request contents exceed the max buffer size and are flushed.\n\t\t\t/// This is called on the main thread.\n\t\t\t///\n\t\t\t/// @author S Downie\n\t\t\t///\n\t\t\t/// @param in_data - Partial data\n\t\t\t/// @param in_responseCode - Response code\n\t\t\t//--------------------------------------------------------------------------------------\n\t\t\tvoid OnFlushed(const std::string& in_data, u32 in_responseCode);\n\t\t\t//--------------------------------------------------------------------------------------\n\t\t\t/// Called by Java when the request completes.\n\t\t\t/// This is called on the main thread.\n\t\t\t///\n\t\t\t/// @author HMcLaughlin\n\t\t\t///\n\t\t\t/// @param in_resultCode - Result code\n\t\t\t/// @param in_data - Data\n\t\t\t/// @param in_responseCode - Response code for request\n\t\t\t//--------------------------------------------------------------------------------------\n\t\t    void OnComplete(u32 in_resultCode, const std::string& in_data, u32 in_responseCode);\n\n\t\tprivate:\n\n            friend class HttpRequestSystem;\n\n            //------------------------------------------------------------------\n            /// Constructor. Can only be created via HttpRequestSystem\n            ///\n            /// @author S Downie\n            ///\n            /// @param Type (POST or GET)\n            /// @param Url to send request to\n            /// @param POST body\n            /// @param Headers\n            /// @param Timeout in seconds\n            /// @param Max buffer size in bytes\n            /// @param Completion delegate\n            //------------------------------------------------------------------\n            HttpRequest(Type in_type, const std::string& in_url, const std::string& in_body, const ChilliSource::ParamDictionary& in_headers, u32 in_timeoutSecs, u32 in_maxBufferSize, const Delegate& in_delegate);\n            //----------------------------------------------------------------------------------------\n            /// @author Ian Copland\n            ///\n            /// @return Whether the request has completed - regardless of success or failure\n            //----------------------------------------------------------------------------------------\n            bool HasCompleted() const;\n\t\t\t//------------------------------------------------------------------\n\t\t\t/// Perform Request\n\t\t\t///\n\t\t\t/// Sends the request\n\t\t\t//------------------------------------------------------------------\n\t\t\tvoid PerformRequest();\n\n\t\tprivate:\n\t\t\t\n            const Type m_type;\n            const std::string m_url;\n            const std::string m_body;\n            const ChilliSource::ParamDictionary m_headers;\n\t\t\tconst Delegate m_completionDelegate;\n\t\t\tconst u32 m_timeoutSecs;\n\t\t\tconst u32 m_maxBufferSize;\n\t\t\t\n\t\t\tbool m_shouldKillThread = false;\n\t\t\tbool m_isPollingComplete = false;\n\t\t\tbool m_isRequestComplete = false;\n\t\t\tbool m_isRequestCancelled = false;\n\n            JavaClassSPtr m_javaHttpRequest;\n\n\t\t\tstd::string m_responseData;\n\t\t\tChilliSource::HttpResponse::Result m_requestResult = ChilliSource::HttpResponse::Result::k_failed;\n\t\t\tu32 m_responseCode = 0;\n\t\t};\n\t}\n}\n\n#endif\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/JNI/Networking/Http/HttpRequestSystem.cpp",
    "content": "//\n//  HttpRequestSystem.cpp\n//  ChilliSource\n//  Created by Ian Copland on 08/11/2011.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2011 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n\n#include <CSBackend/Platform/Android/Main/JNI/Networking/Http/HttpRequestSystem.h>\n\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/Threading/TaskScheduler.h>\n\nnamespace CSBackend\n{\n\tnamespace Android\n\t{\n\t\tCS_DEFINE_NAMEDTYPE(HttpRequestSystem);\n\n\t\t//--------------------------------------------------------------------------------------------------\n\t\t//--------------------------------------------------------------------------------------------------\n\t\tbool HttpRequestSystem::IsA(ChilliSource::InterfaceIDType in_interfaceId) const\n\t\t{\n\t\t\treturn in_interfaceId == ChilliSource::HttpRequestSystem::InterfaceID || in_interfaceId == HttpRequestSystem::InterfaceID;\n\t\t}\n        //--------------------------------------------------------------------------------------------------\n        //--------------------------------------------------------------------------------------------------\n        HttpRequest* HttpRequestSystem::MakeGetRequest(const std::string& in_url, const HttpRequest::Delegate& in_delegate, u32 in_timeoutSecs)\n        {\n            return MakeRequest(HttpRequest::Type::k_get, in_url, \"\", ChilliSource::ParamDictionary(), in_delegate, in_timeoutSecs);\n        }\n        //--------------------------------------------------------------------------------------------------\n        //--------------------------------------------------------------------------------------------------\n        HttpRequest* HttpRequestSystem::MakeGetRequest(const std::string& in_url, const ChilliSource::ParamDictionary& in_headers, const HttpRequest::Delegate& in_delegate, u32 in_timeoutSecs)\n        {\n            return MakeRequest(HttpRequest::Type::k_get, in_url, \"\", in_headers, in_delegate, in_timeoutSecs);\n        }\n        //--------------------------------------------------------------------------------------------------\n        //--------------------------------------------------------------------------------------------------\n        HttpRequest* HttpRequestSystem::MakePostRequest(const std::string& in_url, const std::string& in_body, const HttpRequest::Delegate& in_delegate, u32 in_timeoutSecs)\n        {\n            return MakeRequest(HttpRequest::Type::k_post, in_url, in_body, ChilliSource::ParamDictionary(), in_delegate, in_timeoutSecs);\n        }\n        //--------------------------------------------------------------------------------------------------\n        //--------------------------------------------------------------------------------------------------\n        HttpRequest* HttpRequestSystem::MakePostRequest(const std::string& in_url, const std::string& in_body, const ChilliSource::ParamDictionary& in_headers, const HttpRequest::Delegate& in_delegate, u32 in_timeoutSecs)\n        {\n            return MakeRequest(HttpRequest::Type::k_post, in_url, in_body, in_headers, in_delegate, in_timeoutSecs);\n        }\n\t\t//--------------------------------------------------------------------------------------------------\n\t\t//--------------------------------------------------------------------------------------------------\n        HttpRequest* HttpRequestSystem::MakeRequest(HttpRequest::Type in_type, const std::string& in_url, const std::string& in_body, const ChilliSource::ParamDictionary& in_headers, const HttpRequest::Delegate& in_delegate, u32 in_timeoutSecs)\n        {\n        \tCS_ASSERT(ChilliSource::Application::Get()->GetTaskScheduler()->IsMainThread() == true, \"Http requests can currently only be made on the main thread\");\n        \tCS_ASSERT(in_delegate != nullptr, \"Cannot make an http request with a null delegate\");\n\t\t\tCS_ASSERT(in_url.empty() == false, \"Cannot make an http request to a blank url\");\n\n\t\t\tHttpRequest* request = new HttpRequest(in_type, in_url, in_body, in_headers, in_timeoutSecs, GetMaxBufferSize(), in_delegate);\n            \n\t\t\tm_requests.push_back(request);\n\t\t\treturn request;\n\t\t}\n\t\t//--------------------------------------------------------------------------------------------------\n\t\t//--------------------------------------------------------------------------------------------------\n\t\tvoid HttpRequestSystem::CancelAllRequests()\n        {\n\t\t\tCS_ASSERT(ChilliSource::Application::Get()->GetTaskScheduler()->IsMainThread() == true, \"Http requests can currently only be made on the main thread\");\n\n\t\t\tfor(u32 nRequest=0; nRequest<m_requests.size(); ++nRequest)\n            {\n\t\t\t\tm_requests[nRequest]->Cancel();\n\t\t\t}\n\t\t}\n        //--------------------------------------------------------------------------------------------------\n        //--------------------------------------------------------------------------------------------------\n        void HttpRequestSystem::CheckReachability(const ReachabilityResultDelegate& in_reachabilityDelegate) const\n        {\n            CS_ASSERT(in_reachabilityDelegate, \"The reachability delegate should not be null.\");\n            in_reachabilityDelegate(m_javaSystem->CallBoolMethod(\"isConnected\"));\n        }\n\t\t//--------------------------------------------------------------------------------------------------\n\t\t//--------------------------------------------------------------------------------------------------\n        void HttpRequestSystem::OnInit()\n        {\n            JavaClassDef classDef(\"com/chilliworks/chillisource/networking/HttpRequestSystem\");\n            classDef.AddMethod(\"isConnected\", \"()Z\");\n\n            m_javaSystem = JavaSystemUPtr(new JavaSystem(classDef));\n        }\n\t\t//--------------------------------------------------------------------------------------------------\n\t\t//--------------------------------------------------------------------------------------------------\n\t\tvoid HttpRequestSystem::OnUpdate(f32 in_timeSinceLastUpdate)\n\t\t{\n            for(auto it = m_requests.begin(); it != m_requests.end(); /*No increment*/)\n            {\n                if((*it)->HasCompleted())\n                {\n                    CS_SAFEDELETE(*it);\n                    it = m_requests.erase(it);\n                }\n                else\n                {\n                    ++it;\n                }\n\t\t\t}\n\t\t}\n        //--------------------------------------------------------------------------------------------------\n        //--------------------------------------------------------------------------------------------------\n        void HttpRequestSystem::OnDestroy()\n        {\n            CancelAllRequests();\n\n            for(auto it = m_requests.begin(); it != m_requests.end(); ++it)\n            {\n                CS_SAFEDELETE(*it);\n            }\n\n            m_requests.clear();\n            m_requests.shrink_to_fit();\n\n            m_javaSystem.reset();\n        }\n\t}\n}\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/JNI/Networking/Http/HttpRequestSystem.h",
    "content": "//\n//  HttpRequestSystem.h\n//  ChilliSource\n//  Created by Ian Copland on 08/11/2011.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2011 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n\n#ifndef _CSBACKEND_PLATFORM_ANDROID_HTTP_HTTPREQUESTSYSTEM_H_\n#define _CSBACKEND_PLATFORM_ANDROID_HTTP_HTTPREQUESTSYSTEM_H_\n\n#include <CSBackend/Platform/Android/Main/JNI/Core/Java/JavaSystem.h>\n#include <CSBackend/Platform/Android/Main/JNI/ForwardDeclarations.h>\n#include <CSBackend/Platform/Android/Main/JNI/Networking/Http/HttpRequest.h>\n#include <ChilliSource/Networking/Http/HttpRequestSystem.h>\n\n#include <vector>\n\nnamespace CSBackend\n{\n\tnamespace Android\n\t{\t\n\t\t//--------------------------------------------------------------------------------------------------\n\t\t/// Android implementation of the http connection system. Reponsible for making http requests to remote\n\t\t/// urls and managing the lifetime of the requests and the connections. Uses the Java\n\t\t/// HttpUrlConnection library\n\t\t///\n\t\t/// @author Ian Copland\n\t\t//--------------------------------------------------------------------------------------------------\n\t\tclass HttpRequestSystem final : public ChilliSource::HttpRequestSystem\n\t\t{\n\t\tpublic:\n\n\t\t\tCS_DECLARE_NAMEDTYPE(HttpRequestSystem);\n\n\t\t\t//--------------------------------------------------------------------------------------------------\n\t\t\t/// @author Ian Copland\n\t\t\t///\n\t\t\t/// @param Interface ID\n            ///\n\t\t\t/// @return Whether object if of argument type\n\t\t\t//--------------------------------------------------------------------------------------------------\n            bool IsA(ChilliSource::InterfaceIDType in_interfaceId) const override;\n            //--------------------------------------------------------------------------------------------------\n            /// Causes the system to issue an Http GET request.\n            ///\n            /// @author S Downie\n            ///\n            /// @param URL\n            /// @param Delegate that is called on request completed. Completion can be failure as well as success\n            /// @param Request timeout in seconds\n            ///\n            /// @return A pointer to the request. The system owns this pointer.\n            //--------------------------------------------------------------------------------------------------\n            HttpRequest* MakeGetRequest(const std::string& in_url, const HttpRequest::Delegate& in_delegate, u32 in_timeoutSecs = k_defaultTimeoutSecs) override;\n            //--------------------------------------------------------------------------------------------------\n            /// Causes the system to issue an Http GET request.\n            ///\n            /// @author S Downie\n            ///\n            /// @param URL\n            /// @param Key value headers to attach to the request\n            /// @param Delegate that is called on request completed. Completion can be failure as well as success\n            /// @param Request timeout in seconds\n            ///\n            /// @return A pointer to the request. The system owns this pointer.\n            //--------------------------------------------------------------------------------------------------\n            HttpRequest* MakeGetRequest(const std::string& in_url, const ChilliSource::ParamDictionary& in_headers, const HttpRequest::Delegate& in_delegate, u32 in_timeoutSecs = k_defaultTimeoutSecs) override;\n            //--------------------------------------------------------------------------------------------------\n            /// Causes the system to issue an Http POST request with the given body.\n            ///\n            /// @author S Downie\n            ///\n            /// @param URL\n            /// @param POST body\n            /// @param Delegate that is called on request completed. Completion can be failure as well as success\n            /// @param Request timeout in seconds\n            ///\n            /// @return A pointer to the request. The system owns this pointer.\n            //--------------------------------------------------------------------------------------------------\n            HttpRequest* MakePostRequest(const std::string& in_url, const std::string& in_body, const HttpRequest::Delegate& in_delegate, u32 in_timeoutSecs = k_defaultTimeoutSecs) override;\n            //--------------------------------------------------------------------------------------------------\n            /// Causes the system to issue an Http POST request with the given body.\n            ///\n            /// @author S Downie\n            ///\n            /// @param URL\n            /// @param POST body\n            /// @param Key value headers to attach to the request\n            /// @param Delegate that is called on request completed. Completion can be failure as well as success\n            /// @param Request timeout in seconds\n            ///\n            /// @return A pointer to the request. The system owns this pointer.\n            //--------------------------------------------------------------------------------------------------\n            HttpRequest* MakePostRequest(const std::string& in_url, const std::string& in_body, const ChilliSource::ParamDictionary& in_headers, const HttpRequest::Delegate& in_delegate, u32 in_timeoutSecs = k_defaultTimeoutSecs) override;\n\t\t\t//--------------------------------------------------------------------------------------------------\n            /// Equivalent to calling cancel on every incomplete request in progress.\n            ///\n            /// @author Ian Copland\n            //--------------------------------------------------------------------------------------------------\n            void CancelAllRequests() override;\n            //--------------------------------------------------------------------------------------------------\n            /// Checks if the device is internet ready\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param Delegate to call when reachability is determined\n            //--------------------------------------------------------------------------------------------------\n            void CheckReachability(const ReachabilityResultDelegate& in_reachabilityDelegate) const override;\n\n\t\tprivate:\n            friend ChilliSource::HttpRequestSystemUPtr ChilliSource::HttpRequestSystem::Create();\n            //--------------------------------------------------------------------------------------------------\n            /// Private constructor to fore use of factory method\n            ///\n            /// @author Ian Copland\n            //--------------------------------------------------------------------------------------------------\n            HttpRequestSystem() = default;\n            //------------------------------------------------------------------\n            /// Concrete method to which all MakeRequest overloads feed.\n            ///\n            /// @author S Downie\n            ///\n            /// @param Type (POST or GET)\n            /// @param Url\n            /// @param Body (POST only)\n            /// @param Headers\n            /// @param Completion delegate\n            /// @param Request timeout in seconds\n            ///\n            /// @return Request. Owned by the system.\n            //------------------------------------------------------------------\n            HttpRequest* MakeRequest(HttpRequest::Type in_type, const std::string& in_url, const std::string& in_body, const ChilliSource::ParamDictionary& in_headers, const HttpRequest::Delegate& in_delegate, u32 in_timeoutSecs);\n\t\t\t//--------------------------------------------------------------------------------------------------\n            /// Sets up the java HttpRequestSystem\n            ///\n            /// @author HMcLaughlin\n            //--------------------------------------------------------------------------------------------------\n            void OnInit() override;\n\t\t\t//--------------------------------------------------------------------------------------------------\n            /// Poll the connection on active requests\n            ///\n            /// @author Ian Copland\n\t\t\t///\n\t\t\t/// @param Time since last update in seconds\n\t\t\t//--------------------------------------------------------------------------------------------------\n            void OnUpdate(f32 in_timeSinceLastUpdate) override;\n            //--------------------------------------------------------------------------------------------------\n            /// Called when the system is destroyed. Cancels all pending requests\n            ///\n            /// @author Ian Copland\n\t\t\t//--------------------------------------------------------------------------------------------------\n            void OnDestroy() override;\n\n\t\tprivate:\n\n\t\t\tstd::vector<HttpRequest*> m_requests;\n\n            JavaSystemUPtr m_javaSystem;\n\t\t};\n\t}\n\n}\n\n#endif\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/JNI/Social/Communications/EmailComposer.cpp",
    "content": "//\n//  EmailComposer.cpp\n//  ChilliSource\n//  Created by Steven Hendrie on 20/01/2012.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2012 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n\n#include <CSBackend/Platform/Android/Main/JNI/Social/Communications/EmailComposer.h>\n\n#include <CSBackend/Platform/Android/Main/JNI/Core/Java/JavaInterfaceManager.h>\n#include <CSBackend/Platform/Android/Main/JNI/Social/Communications/EmailComposerJavaInterface.h>\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/Delegate/MakeDelegate.h>\n#include <ChilliSource/Core/File/FileSystem.h>\n#include <ChilliSource/Core/File/TaggedFilePathResolver.h>\n#include <ChilliSource/Core/Threading/TaskScheduler.h>\n\nnamespace CSBackend\n{\n\tnamespace Android\n\t{\n\t\tnamespace\n\t\t{\n\t\t\tconst std::string k_tempAttachmentDirectory = \"_AttachmentTemp/\";\n\t\t}\n\n\t\tCS_DEFINE_NAMEDTYPE(EmailComposer);\n\t\t//-------------------------------------------------------\n\t\t//-------------------------------------------------------\n\t\tEmailComposer::EmailComposer()\n\t\t\t: m_isPresented(false)\n\t\t{\n\t\t}\n        //-------------------------------------------------------\n\t\t//-------------------------------------------------------\n\t\tbool EmailComposer::IsA(ChilliSource::InterfaceIDType in_interfaceId) const\n\t\t{\n\t\t\treturn (in_interfaceId == ChilliSource::EmailComposer::InterfaceID || in_interfaceId == EmailComposer::InterfaceID);\n\t\t}\n        //-------------------------------------------------------\n        //-------------------------------------------------------\n\t\tvoid EmailComposer::Present(const std::vector<std::string>& in_recipientAddresses, const std::string& in_subject, const std::string& in_contents, ContentFormat in_contentFormat,\n\t\t\t\tconst SendResultDelegate& in_callback)\n\t\t{\n            CS_ASSERT(ChilliSource::Application::Get()->GetTaskScheduler()->IsMainThread(), \"Cannot present Email Composer on background threads.\");\n\t\t\tAttachment emptyAttachment;\n\t\t\temptyAttachment.m_storageLocation = ChilliSource::StorageLocation::k_none;\n\t\t\tPresentWithAttachment(in_recipientAddresses, in_subject, in_contents, in_contentFormat, emptyAttachment, in_callback);\n\t\t}\n\t\t//-------------------------------------------------------\n\t\t//-------------------------------------------------------\n\t\tvoid EmailComposer::PresentWithAttachment(const std::vector<std::string>& in_recipientAddresses, const std::string& in_subject, const std::string& in_contents,\n\t\t\t\tContentFormat in_contentFormat, const Attachment& in_attachment, const SendResultDelegate & in_callback)\n\t\t{\n            CS_ASSERT(ChilliSource::Application::Get()->GetTaskScheduler()->IsMainThread(), \"Cannot present Email Composer on background threads.\");\n\t\t\tCS_ASSERT(m_isPresented == false, \"Cannot present email composer while one is already presented.\");\n\n\t\t\tm_isPresented = true;\n\t\t\tm_resultDelegate = in_callback;\n\n\n\t\t\tstd::string attachmentAbsFilePath;\n\t\t\tif (in_attachment.m_filename.size() > 0)\n\t\t\t{\n\t\t\t    ChilliSource::FileSystem* fileSystem = ChilliSource::Application::Get()->GetFileSystem();\n\t\t\t    std::string attachmentTaggedFilePath = ChilliSource::Application::Get()->GetTaggedFilePathResolver()->ResolveFilePath(in_attachment.m_storageLocation, in_attachment.m_filename);\n\n\t\t\t\tif (in_attachment.m_storageLocation == ChilliSource::StorageLocation::k_package || in_attachment.m_storageLocation == ChilliSource::StorageLocation::k_chilliSource ||\n\t\t\t\t    (in_attachment.m_storageLocation == ChilliSource::StorageLocation::k_DLC && fileSystem->DoesFileExistInCachedDLC(attachmentTaggedFilePath) == false))\n\t\t\t\t{\n\t\t\t\t\tfileSystem->CreateDirectoryPath(ChilliSource::StorageLocation::k_cache, k_tempAttachmentDirectory);\n\t\t\t\t\tfileSystem->CopyFile(in_attachment.m_storageLocation, attachmentTaggedFilePath, ChilliSource::StorageLocation::k_cache, k_tempAttachmentDirectory + attachmentTaggedFilePath);\n\t\t\t\t\tattachmentAbsFilePath = fileSystem->GetAbsolutePathToStorageLocation(ChilliSource::StorageLocation::k_cache) + k_tempAttachmentDirectory + attachmentTaggedFilePath;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tattachmentAbsFilePath = fileSystem->GetAbsolutePathToStorageLocation(in_attachment.m_storageLocation) + attachmentTaggedFilePath;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tm_javaInterface->Present(in_recipientAddresses, in_subject, in_contents, (in_contentFormat == ContentFormat::k_html), attachmentAbsFilePath, ChilliSource::MakeDelegate(this, &EmailComposer::OnEmailClosed));\n\t\t}\n        //-------------------------------------------------------\n        //-------------------------------------------------------\n        bool EmailComposer::IsPresented()\n        {\n            return m_isPresented;\n        }\n        //-------------------------------------------------------\n        //-------------------------------------------------------\n\t\tvoid EmailComposer::OnEmailClosed(EmailComposerJavaInterface::Result in_result)\n\t\t{\n            CS_ASSERT(ChilliSource::Application::Get()->GetTaskScheduler()->IsMainThread(), \"Email closed callback not on main thread.\");\n\t\t\tif(m_javaInterface != nullptr)\n\t\t\t{\n\t\t\t\tEmailComposer::SendResult result = EmailComposer::SendResult::k_failed;\n\t\t\t\tswitch (in_result)\n\t\t\t\t{\n\t\t\t\t\tcase EmailComposerJavaInterface::Result::k_success:\n\t\t\t\t\t\tresult= EmailComposer::SendResult::k_succeed;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase EmailComposerJavaInterface::Result::k_cancelled:\n\t\t\t\t\t\tresult = EmailComposer::SendResult::k_cancelled;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tm_isPresented = false;\n\n\t\t\t\tSendResultDelegate delegate = m_resultDelegate;\n\t\t\t\tm_resultDelegate = nullptr;\n                delegate(result);\n\t\t\t}\n\t\t}\n        //------------------------------------------------------\n        //------------------------------------------------------\n        void EmailComposer::OnInit()\n        {\n        \tm_javaInterface = JavaInterfaceManager::GetSingletonPtr()->GetJavaInterface<EmailComposerJavaInterface>();\n\t\t\tif (m_javaInterface == nullptr)\n\t\t\t{\n\t\t\t\tm_javaInterface = EmailComposerJavaInterfaceSPtr(new EmailComposerJavaInterface());\n\t\t\t\tJavaInterfaceManager::GetSingletonPtr()->AddJavaInterface(m_javaInterface);\n\t\t\t}\n        }\n        //------------------------------------------------------\n        //------------------------------------------------------\n        void EmailComposer::OnDestroy()\n        {\n        \tChilliSource::Application::Get()->GetFileSystem()->DeleteDirectory(ChilliSource::StorageLocation::k_cache, k_tempAttachmentDirectory);\n        \tm_javaInterface.reset();\n        }\n\t}\n}\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/JNI/Social/Communications/EmailComposer.h",
    "content": "//\n//  EmailComposer.h\n//  ChilliSource\n//  Created by Steven Hendrie on 20/01/2012.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2012 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n\n#ifndef _CSBACKEND_PLATFORM_ANDROID_SOCIAL_COMMUNICATIONS_EMAILCOMPOSER_H_\n#define _CSBACKEND_PLATFORM_ANDROID_SOCIAL_COMMUNICATIONS_EMAILCOMPOSER_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <CSBackend/Platform/Android/Main/JNI/ForwardDeclarations.h>\n#include <CSBackend/Platform/Android/Main/JNI/Social/Communications/EmailComposerJavaInterface.h>\n#include <ChilliSource/Social/Communications/EmailComposer.h>\n\nnamespace CSBackend\n{\n\tnamespace Android\n\t{\n\t\t//---------------------------------------------------------------\n\t\t/// The Android backend for the Email Composer.\n\t\t///\n\t\t/// @author S Hendrie\n\t\t//---------------------------------------------------------------\n\t\tclass EmailComposer final : public ChilliSource::EmailComposer\n\t\t{\n\t\tpublic:\n\t\t\tCS_DECLARE_NAMEDTYPE(EmailComposer);\n            //-------------------------------------------------------\n\t\t\t/// Queries whether or not this system implements the\n            /// interface with the given Id.\n\t\t\t///\n            /// @author S Hendrie\n            ///\n\t\t\t/// @param The interface Id.\n\t\t\t/// @param Whether system is of given type.\n\t\t\t//-------------------------------------------------------\n\t\t\tbool IsA(ChilliSource::InterfaceIDType in_interfaceId) const override;\n            //-------------------------------------------------------\n            /// Displays the email activity with the given recipients,\n            /// subject and contents.\n            ///\n\t\t\t/// @author S Hendrie\n            ///\n            /// @param A list of recipients (UTF-8).\n            /// @param The subject (UTF-8).\n            /// @param The body of the email (UTF-8).\n            /// @param The format of the body of the email.\n            /// @param The callback describing the result of the email.\n            //-------------------------------------------------------\n\t\t\tvoid Present(const std::vector<std::string>& in_recipientAddresses, const std::string& in_subject, const std::string& in_contents, ContentFormat in_contentFormat, const SendResultDelegate& in_callback) override;\n\t\t\t//-------------------------------------------------------\n\t\t\t/// Displays the email activity with the given recipients,\n\t\t\t/// subject and contents, and adds a list of attachments\n\t\t\t/// to the email.\n            ///\n\t\t\t/// @author Ian Copland\n\t\t\t///\n\t\t\t/// @param A list of recipients (UTF-8).\n\t\t\t/// @param The subject (UTF-8).\n\t\t\t/// @param The body of the email (UTF-8).\n            /// @param The format of the body of the email.\n\t\t\t/// @param The attachment\n\t\t\t/// @param The callback describing the result of the email.\n\t\t\t//-------------------------------------------------------\n\t\t\tvoid PresentWithAttachment(const std::vector<std::string>& in_recipientAddresses, const std::string& in_subject, const std::string& in_contents, ContentFormat in_contentFormat,\n\t\t\t\t\tconst Attachment& in_attachment, const SendResultDelegate& in_callback) override;\n            //-------------------------------------------------------\n            /// Determines whether or not the composer is presented.\n            /// @author Jordan Brown\n            //-------------------------------------------------------\n            bool IsPresented() override;\n\t\tprivate:\n\t\t\tfriend ChilliSource::EmailComposerUPtr ChilliSource::EmailComposer::Create();\n            //----------------------------------------------------\n            /// Private constructor to force the use of the\n            /// factory method.\n            ///\n            /// @author Ian Copland\n            //----------------------------------------------------\n\t\t\tEmailComposer();\n            //------------------------------------------------------\n            /// Called when the the owning state is initialised.\n            ///\n            /// @author Ian Copland\n            //------------------------------------------------------\n            void OnInit() override;\n            //-------------------------------------------------------\n            /// Called when the email activity returns with a result.\n            ///\n            /// @author Ian Copland\n\t\t\t///\n\t\t\t/// @param The result.\n            //-------------------------------------------------------\n\t\t\tvoid OnEmailClosed(EmailComposerJavaInterface::Result in_result);\n            //------------------------------------------------------\n            /// Called when the the owning state is destroyed.\n            ///\n            /// @author Ian Copland\n            //------------------------------------------------------\n            void OnDestroy() override;\n\n            bool m_isPresented;\n\t\t\tEmailComposerJavaInterfaceSPtr m_javaInterface;\n\t\t\tSendResultDelegate m_resultDelegate;\n\t\t};\n\n\t}\n}\n\n#endif\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/JNI/Social/Communications/EmailComposerJavaInterface.cpp",
    "content": "//\n//  EmailComposerJavaInterface.cpp\n//  ChilliSource\n//  Created by Steven Hendrie on 20/01/2012.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2012 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n\n#include <CSBackend/Platform/Android/Main/JNI/Social/Communications/EmailComposerJavaInterface.h>\n\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/Threading/TaskScheduler.h>\n\n#include <CSBackend/Platform/Android/Main/JNI/Core/Java/JavaInterfaceManager.h>\n#include <CSBackend/Platform/Android/Main/JNI/Core/Java/JavaUtils.h>\n\n//function definitions\nextern \"C\"\n{\n\tvoid Java_com_chilliworks_chillisource_social_EmailComposerNativeInterface_OnEmailClosed(JNIEnv* inpEnv, jobject inpThis, s32 indwResultCode);\n}\n//--------------------------------------------------------------------------------------\n/// On Email Closed\n///\n/// Interface function called from java. This is called whenever the email activity\n/// returns a result.\n///\n/// @param The jni environment.\n/// @param the java object calling the function.\n/// @param The result code.\n//--------------------------------------------------------------------------------------\nvoid Java_com_chilliworks_chillisource_social_EmailComposerNativeInterface_OnEmailClosed(JNIEnv* inpEnv, jobject inpThis, s32 indwResultCode)\n{\n\tCSBackend::Android::EmailComposerJavaInterfaceSPtr pJavaInterface = CSBackend::Android::JavaInterfaceManager::GetSingletonPtr()->GetJavaInterface<CSBackend::Android::EmailComposerJavaInterface>();\n\tif (pJavaInterface != nullptr)\n\t{\n\t\tpJavaInterface->OnEmailClosed(indwResultCode);\n\t}\n}\n\nnamespace CSBackend\n{\n\tnamespace Android\n\t{\n\t\tnamespace\n\t\t{\n\t\t\t//--------------------------------------------------------------\n\t\t\t/// Converts the integer result returned from java to the\n\t\t\t/// Result enum.\n\t\t\t///\n\t\t\t/// @author Ian Copland\n\t\t\t///\n\t\t\t/// @param The result integer.\n\t\t\t///\n\t\t\t/// @return The result enum.\n\t\t\t//--------------------------------------------------------------\n\t\t\tEmailComposerJavaInterface::Result IntegerToResult(s32 in_result)\n\t\t\t{\n\t\t\t\tconst s32 k_resultSuccess = -1;\n\t\t\t\tconst s32 k_resultCancelled = 0;\n\n\t\t\t\tswitch (in_result)\n\t\t\t\t{\n\t\t\t\tcase k_resultSuccess:\n\t\t\t\t\treturn EmailComposerJavaInterface::Result::k_success;\n\t\t\t\tcase k_resultCancelled:\n\t\t\t\t\treturn EmailComposerJavaInterface::Result::k_cancelled;\n\t\t\t\tdefault:\n\t\t\t\t\treturn EmailComposerJavaInterface::Result::k_failed;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tCS_DEFINE_NAMEDTYPE(EmailComposerJavaInterface);\n\t\t//--------------------------------------------------------------\n\t\t/// Constructor\n\t\t//--------------------------------------------------------------\n\t\tEmailComposerJavaInterface::EmailComposerJavaInterface()\n\t\t{\n\t\t\tCreateNativeInterface(\"com/chilliworks/chillisource/social/EmailComposerNativeInterface\");\n\t\t\tCreateMethodReference(\"Present\", \"([Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZLjava/lang/String;)V\");\n\t\t}\n\t\t//--------------------------------------------------------------\n\t\t/// Is A\n\t\t//--------------------------------------------------------------\n\t\tbool EmailComposerJavaInterface::IsA(ChilliSource::InterfaceIDType inInterfaceID) const\n\t\t{\n\t\t\treturn (inInterfaceID == EmailComposerJavaInterface::InterfaceID);\n\t\t}\n\t\t//--------------------------------------------------------------\n\t\t/// Present\n\t\t//--------------------------------------------------------------\n\t\tvoid EmailComposerJavaInterface::Present(const std::vector<std::string>& inastrRecipientAddresses, const std::string& instrSubject, const std::string& instrContents,\n\t\t\t\tbool inbFormatAsHtml, const std::string& instrAttachmentFilename, const ResultDelegate& inDelegate)\n\t\t{\n\t\t\tmDelegate = inDelegate;\n\n\t\t\tJNIEnv* pEnv = JavaInterfaceManager::GetSingletonPtr()->GetJNIEnvironmentPtr();\n\n\t\t\t//build the recipient list\n\t\t\tu32 udwCount = 0;\n\t\t\tjobjectArray ajstrRecipients = pEnv->NewObjectArray(inastrRecipientAddresses.size(), pEnv->FindClass(\"java/lang/String\"), pEnv->NewStringUTF(\"\"));\n\t\t\tfor(auto it = inastrRecipientAddresses.begin(); it != inastrRecipientAddresses.end(); ++it)\n\t\t\t{\n\t\t\t\tjstring jstrRecipient = JavaUtils::CreateJStringFromSTDString(*it);\n\t\t\t\tpEnv->SetObjectArrayElement(ajstrRecipients,udwCount++, jstrRecipient);\n\t\t\t\tpEnv->DeleteLocalRef(jstrRecipient);\n\t\t\t}\n\n\t\t\tjstring jstrSubject = JavaUtils::CreateJStringFromSTDString(instrSubject);\n\t\t\tjstring jstrContents = JavaUtils::CreateJStringFromSTDString(instrContents);\n\t\t\tjstring jstrAttachmentFilename = JavaUtils::CreateJStringFromSTDString(instrAttachmentFilename);\n\n\t\t\t//call method\n\t\t\tpEnv->CallVoidMethod(GetJavaObject(), GetMethodID(\"Present\"), ajstrRecipients, jstrSubject, jstrContents, inbFormatAsHtml, jstrAttachmentFilename);\n\n\t\t\t//clean up\n\t\t\tpEnv->DeleteLocalRef(ajstrRecipients);\n\t\t\tpEnv->DeleteLocalRef(jstrSubject);\n\t\t\tpEnv->DeleteLocalRef(jstrContents);\n\t\t\tpEnv->DeleteLocalRef(jstrAttachmentFilename);\n\t\t}\n\t\t//--------------------------------------------------------------\n\t\t/// On Email Closed\n\t\t//--------------------------------------------------------------\n\t\tvoid EmailComposerJavaInterface::OnEmailClosed(s32 indwResultCode)\n\t\t{\n            ChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_mainThread, [=](const ChilliSource::TaskContext& taskContext)\n            {\n                if (mDelegate != nullptr)\n                {\n                    ResultDelegate delegate = mDelegate;\n                    mDelegate = nullptr;\n                    delegate(IntegerToResult(indwResultCode));\n                }\n            });\n\t\t}\n\t}\n}\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/JNI/Social/Communications/EmailComposerJavaInterface.h",
    "content": "//\n//  EmailCompositionJavaInterface.h\n//  ChilliSource\n//  Created by Steven Hendrie on 20/01/2012.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2012 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n\n#ifndef _CHILLISOURCE_PLATFORM_ANDROID_JAVAINTERFACE_EMAILCOMPOSITION_H\n#define _CHILLISOURCE_PLATFORM_ANDROID_JAVAINTERFACE_EMAILCOMPOSITION_H\n\n#include <CSBackend/Platform/Android/Main/JNI/Core/Java/JavaInterface.h>\n\n#include <CSBackend/Platform/Android/Main/JNI/ForwardDeclarations.h>\n\nnamespace CSBackend\n{\n\tnamespace Android\n\t{\n\t\tclass EmailComposerJavaInterface: public CSBackend::Android::IJavaInterface\n\t\t{\n\t\tpublic:\n\t\t\tCS_DECLARE_NAMEDTYPE(EmailCompositionJavaInterface);\n\n\t\t\t//--------------------------------------------------------------\n\t\t\t/// An enum describing the possible results from presenting the\n\t\t\t/// email composer.\n\t\t\t///\n\t\t\t/// @author Ian Copland\n\t\t\t//--------------------------------------------------------------\n\t\t\tenum class Result\n\t\t\t{\n\t\t\t\tk_success,\n\t\t\t\tk_cancelled,\n\t\t\t\tk_failed\n\t\t\t};\n\t\t\t//--------------------------------------------------------------\n\t\t\t/// Delegates\n\t\t\t//--------------------------------------------------------------\n\t\t\ttypedef std::function<void(Result)> ResultDelegate;\n\t\t\t//--------------------------------------------------------------\n\t\t\t/// Constructor\n\t\t\t//--------------------------------------------------------------\n\t\t\tEmailComposerJavaInterface();\n\t\t\t//--------------------------------------------------------------\n\t\t\t/// Is A\n\t\t\t///\n\t\t\t/// @return whether or not this object implements the given interface.\n\t\t\t//--------------------------------------------------------------\n\t\t\tbool IsA(ChilliSource::InterfaceIDType inInterfaceID) const;\n\t\t\t//--------------------------------------------------------------\n\t\t\t/// Present\n\t\t\t///\n\t\t\t/// Presents the user with the email interface.\n\t\t\t///\n\t\t\t/// @param vector of email addresses (UTF-8)\n\t\t\t/// @param subject line (UTF-8)\n\t\t\t/// @param content (UTF-8)\n\t\t\t/// @param bool if to format as html\n\t\t\t/// @param The attachment filename.\n\t\t\t/// @param result callback delegate\n\t\t\t//--------------------------------------------------------------\n\t\t\tvoid Present(const std::vector<std::string>& inastrRecipientAddresses, const std::string& instrSubject, const std::string& instrContents,\n\t\t\t\t\tbool inbFormatAsHtml, const std::string& instrAttachmentFilename, const ResultDelegate& inDelegate);\n\t\t\t//--------------------------------------------------------------\n\t\t\t/// On Email Closed\n\t\t\t///\n\t\t\t/// Called when a result is returned by the activity.\n\t\t\t///\n\t\t\t/// @param The result code.\n\t\t\t//--------------------------------------------------------------\n\t\t\tvoid OnEmailClosed(s32 indwResultCode);\n\t\tprivate:\n\t\t\tResultDelegate mDelegate;\n\t\t};\n\t}\n}\n\n#endif\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/JNI/Video/Base/VideoPlayer.cpp",
    "content": "//\n//  VideoPlayer.cpp\n//  ChilliSource\n//  Created by Ian Copland on 10/08/2012.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2012 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n\n#include <CSBackend/Platform/Android/Main/JNI/Video/Base/VideoPlayer.h>\n\n#include <CSBackend/Platform/Android/Main/JNI/Core/File/FileSystem.h>\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/Base/Screen.h>\n#include <ChilliSource/Core/Delegate/MakeDelegate.h>\n#include <ChilliSource/Core/File/TaggedFilePathResolver.h>\n#include <ChilliSource/Core/Localisation/LocalisedText.h>\n#include <ChilliSource/Core/Math/MathUtils.h>\n#include <ChilliSource/Core/String/StringUtils.h>\n#include <ChilliSource/Core/Threading/TaskScheduler.h>\n#include <ChilliSource/Video/Base/Subtitles.h>\n\nextern \"C\"\n{\n\t//------------------------------------------------------------------------------\n\t/// Called from java whenever subtitles are to be updated. This will occur every\n\t/// frame a video containing subtitles is running.\n\t///\n\t/// @author Ian Copland\n\t///\n\t/// @param in_env - The jni environment.\n\t/// @param in_this - The java object calling the function.\n\t//------------------------------------------------------------------------------\n\tvoid Java_com_chilliworks_chillisource_video_VideoPlayer_onUpdateSubtitles(JNIEnv* in_env, jobject in_this);\n\t//------------------------------------------------------------------------------\n    /// Called from java when the video has stopped.\n    ///\n    /// @author Ian Copland\n    ///\n    /// @param in_env - The jni environment.\n    /// @param in_this - The java object calling the function.\n    //------------------------------------------------------------------------------\n\tvoid Java_com_chilliworks_chillisource_video_VideoPlayer_onVideoComplete(JNIEnv* in_env, jobject in_this);\n}\n\nCSBackend::Android::VideoPlayer* g_activeVideoPlayer = nullptr;\n\n//------------------------------------------------------------------------------\n//------------------------------------------------------------------------------\nvoid Java_com_chilliworks_chillisource_video_VideoPlayer_onUpdateSubtitles(JNIEnv* in_env, jobject in_this)\n{\n\tCS_ASSERT(g_activeVideoPlayer != nullptr, \"No video player active!\");\n\n    // This must run on the UI thread!\n\tg_activeVideoPlayer->OnUpdateSubtitles();\n}\n//------------------------------------------------------------------------------\n//------------------------------------------------------------------------------\nvoid Java_com_chilliworks_chillisource_video_VideoPlayer_onVideoComplete(JNIEnv* in_env, jobject in_this)\n{\n\tCS_ASSERT(g_activeVideoPlayer != nullptr, \"No video player active!\");\n\n\tChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_mainThread, [=](const ChilliSource::TaskContext&)\n\t{\n\t\tg_activeVideoPlayer->OnVideoComplete();\n\t});\n}\n\nnamespace CSBackend\n{\n    namespace Android\n    {\n    \tnamespace\n    \t{\n\t\t\t//------------------------------------------------------------------------------\n\t\t\t/// Calculate the offset and size of the given size within the zip.\n\t\t\t///\n\t\t\t/// @author Ian Copland\n\t\t\t///\n\t\t\t/// @param in_storageLocation - The storage location.\n\t\t\t/// @param in_filePath - The path to the file in the zip.\n\t\t\t/// @param out_filePath - [Out] The output file path.\n\t\t\t/// @param out_fileOffset - [Out] The output file offset.\n\t\t\t/// @param out_fileLength - [Out] The output file length.\n\t\t\t//------------------------------------------------------------------------------\n    \t\tvoid CalcZippedVideoInfo(ChilliSource::StorageLocation in_storageLocation, const std::string& in_filePath, std::string& out_filePath, s32& out_fileOffset, s32& out_fileLength)\n    \t\t{\n    \t\t\tauto fileSystem = ChilliSource::Application::Get()->GetFileSystem()->Cast<FileSystem>();\n    \t\t\tCS_ASSERT(fileSystem != nullptr, \"Could not cast to android file system.\");\n\n    \t\t\tFileSystem::ZippedFileInfo zippedFileInfo;\n\t\t\t\tif (fileSystem->TryGetZippedFileInfo(in_storageLocation, in_filePath, zippedFileInfo) == false)\n\t\t\t\t{\n\t\t\t\t\tCS_LOG_FATAL(\"Couldn't get video file '\" + in_filePath + \"' from zip.\");\n\t\t\t\t}\n\n\t\t\t\tCS_ASSERT(zippedFileInfo.m_size > 0, \"Cannot stream a zero size video file: \" + in_filePath);\n\t\t\t\tCS_ASSERT(zippedFileInfo.m_isCompressed == false && zippedFileInfo.m_size == zippedFileInfo.m_uncompressedSize, \"Cannot stream video file '\" + in_filePath +\n\t\t\t\t\t\"' becuase it is compressed inside Apk or Apk expansion file.\");\n\n\t\t\t\tout_filePath = fileSystem->GetZipFilePath();\n\t\t\t\tout_fileOffset = zippedFileInfo.m_offset;\n\t\t\t\tout_fileLength = zippedFileInfo.m_size;\n    \t\t}\n    \t}\n\n    \tCS_DEFINE_NAMEDTYPE(VideoPlayer);\n\t\t//------------------------------------------------------------------------------\n\t\t//------------------------------------------------------------------------------\n\t\tbool VideoPlayer::IsA(ChilliSource::InterfaceIDType in_interfaceId) const\n\t\t{\n\t\t\treturn (in_interfaceId == ChilliSource::VideoPlayer::InterfaceID || in_interfaceId == VideoPlayer::InterfaceID);\n\t\t}\n\t\t//------------------------------------------------------------------------------\n\t\t//------------------------------------------------------------------------------\n        void VideoPlayer::Present(ChilliSource::StorageLocation in_storageLocation, const std::string& in_filePath, VideoCompleteDelegate::Connection&& in_delegateConnection, bool in_dismissWithTap,\n        \t\tconst ChilliSource::Colour& in_backgroundColour)\n        {\n        \tCS_ASSERT(g_activeVideoPlayer == nullptr, \"A video player is already active!\");\n        \tCS_ASSERT(m_isPlaying == false, \"Cannot present a video while one is already playing.\");\n\n        \tm_isPlaying = true;\n\t\t\tg_activeVideoPlayer = this;\n\n            m_completionDelegateConnection = std::move(in_delegateConnection);\n\n            auto fileSystem = ChilliSource::Application::Get()->GetFileSystem();\n            auto taggedFilePath = ChilliSource::Application::Get()->GetTaggedFilePathResolver()->ResolveFilePath(in_storageLocation, in_filePath);\n\n\t\t\tbool inApk = false;\n\t\t\tstd::string absFilePath = fileSystem->GetAbsolutePathToStorageLocation(in_storageLocation) + taggedFilePath;\n\t\t\ts32 fileOffset = -1;\n\t\t\ts32 fileLength = -1;\n            if (in_storageLocation == ChilliSource::StorageLocation::k_package || in_storageLocation == ChilliSource::StorageLocation::k_package)\n            {\n#if defined(CS_ANDROIDFLAVOUR_GOOGLEPLAY)\n\t\t\t\tCalcZippedVideoInfo(in_storageLocation, taggedFilePath, absFilePath, fileOffset, fileLength);\n#elif defined(CS_ANDROIDFLAVOUR_AMAZON)\n\t\t\t\tinApk = true;\n#else\n\t\t\t\tCS_LOG_FATAL(\"This Android Flavour cannot play videos from this storage location.\");\n#endif\n            }\n            else if (in_storageLocation == ChilliSource::StorageLocation::k_DLC && fileSystem->DoesFileExistInCachedDLC(taggedFilePath) == false)\n            {\n#if defined(CS_ANDROIDFLAVOUR_GOOGLEPLAY)\n\t\t\t\tCalcZippedVideoInfo(in_storageLocation, taggedFilePath, absFilePath, fileOffset, fileLength);\n#elif defined(CS_ANDROIDFLAVOUR_AMAZON)\n\t\t\t\tinApk = true;\n#else\n\t\t\t\tCS_LOG_FATAL(\"This Android Flavour cannot play videos from this storage location.\");\n#endif\n            }\n\n\t\t\tjstring jAbsFilePath = JavaUtils::CreateJStringFromSTDString(absFilePath);\n\n\t\t\tm_javaSystem->CallVoidMethod(\"present\", inApk, jAbsFilePath, fileOffset, fileLength, in_dismissWithTap, (m_subtitles != nullptr), in_backgroundColour.r, in_backgroundColour.g,\n\t\t\tin_backgroundColour.b, in_backgroundColour.a);\n\n\t\t\tJavaUtils::DeleteLocalRef(jAbsFilePath);\n        }\n\t\t//------------------------------------------------------------------------------\n\t\t//------------------------------------------------------------------------------\n\t\tvoid VideoPlayer::PresentWithSubtitles(ChilliSource::StorageLocation in_storageLocation, const std::string& in_filePath, const ChilliSource::SubtitlesCSPtr& in_subtitles, VideoCompleteDelegate::Connection&& in_delegateConnection,\n                bool in_dismissWithTap, const ChilliSource::Colour& in_backgroundColour)\n\t\t{\n\t\t\tm_subtitles = in_subtitles;\n\t\t\tPresent(in_storageLocation, in_filePath, std::move(in_delegateConnection), in_dismissWithTap, in_backgroundColour);\n\t\t}\n        //--------------------------------------------------------\n        //--------------------------------------------------------\n        bool VideoPlayer::IsPresented() const noexcept\n        {\n            return m_isPlaying;\n        }\n\t\t//------------------------------------------------------------------------------\n\t\t//------------------------------------------------------------------------------\n        void VideoPlayer::OnInit()\n        {\n\t\t\tJavaClassDef classDef(\"com/chilliworks/chillisource/video/VideoPlayer\");\n\t\t\tclassDef.AddMethod(\"present\", \"(ZLjava/lang/String;IIZZFFFF)V\");\n\t\t\tclassDef.AddMethod(\"getPlaybackPosition\", \"()F\");\n\t\t\tclassDef.AddMethod(\"createSubtitle\", \"(Ljava/lang/String;Ljava/lang/String;ILjava/lang/String;FFFF)J\");\n\t\t\tclassDef.AddMethod(\"setSubtitleColour\", \"(JFFFF)V\");\n\t\t\tclassDef.AddMethod(\"removeSubtitle\", \"(J)V\");\n\n        \tm_javaSystem = JavaSystemUPtr(new JavaSystem(classDef));\n        }\n\t\t//------------------------------------------------------------------------------\n\t\t//------------------------------------------------------------------------------\n        void VideoPlayer::OnVideoComplete()\n        {\n        \tm_subtitles.reset();\n        \tm_isPlaying = false;\n\t\t\tg_activeVideoPlayer = nullptr;\n\n            if (m_completionDelegateConnection != nullptr)\n            {\n                auto delegateConnection = std::move(m_completionDelegateConnection);\n                m_completionDelegateConnection = nullptr;\n                delegateConnection->Call();\n            }\n        }\n\t\t//------------------------------------------------------------------------------\n\t\t//------------------------------------------------------------------------------\n\t\tvoid VideoPlayer::OnUpdateSubtitles()\n\t\t{\n\t\t\t//only update if the position in the video has changed.\n\t\t\tf32 position = m_javaSystem->CallFloatMethod(\"getPlaybackPosition\");\n\t\t\tTimeIntervalMs currentTimeMS = (TimeIntervalMs)(position * 1000.0f);\n\t\t\tif (m_currentSubtitleTimeMS != currentTimeMS)\n\t\t\t{\n\t\t\t\tm_currentSubtitleTimeMS = currentTimeMS;\n\n\t\t\t\t//get the current subtitles\n\t\t\t\tauto subtitleArray = m_subtitles->GetSubtitlesAtTime(m_currentSubtitleTimeMS);\n\t\t\t\tauto localisedText = m_subtitles->GetLocalisedText().get();\n\n\t\t\t\t//add any new subtitles\n\t\t\t\tfor (auto it = subtitleArray.begin(); it != subtitleArray.end(); ++it)\n\t\t\t\t{\n\t\t\t\t\tauto mapEntry = m_subtitleMap.find(*it);\n\t\t\t\t\tif (mapEntry == m_subtitleMap.end())\n\t\t\t\t\t{\n\t\t\t\t\t\tconst std::string& text = localisedText->GetText((*it)->m_localisedTextId);\n\t\t\t\t\t\tconst ChilliSource::Subtitles::Style* style = m_subtitles->GetStyleWithName((*it)->m_styleName);\n\t\t\t\t\t\tauto alignment = ChilliSource::StringFromAlignmentAnchor(style->m_alignment);\n\n\t\t\t\t\t\tjstring jText = JavaUtils::CreateJStringFromSTDString(text);\n\t\t\t\t\t\tjstring jFontName = JavaUtils::CreateJStringFromSTDString(style->m_fontName);\n\t\t\t\t\t\tjstring jAlignment = JavaUtils::CreateJStringFromSTDString(alignment);\n\n\t\t\t\t\t\ts64 subtitleID = m_javaSystem->CallLongMethod(\"createSubtitle\", jText, jFontName, style->m_fontSize, jAlignment, style->m_bounds.vOrigin.x, style->m_bounds.vOrigin.y, style->m_bounds.vSize.x, style->m_bounds.vSize.y);\n\t\t\t\t\t\tm_javaSystem->CallVoidMethod(\"setSubtitleColour\", subtitleID, 0.0f, 0.0f, 0.0f, 0.0f);\n\n\t\t\t\t\t\tJavaUtils::DeleteLocalRef(jAlignment);\n\t\t\t\t\t\tJavaUtils::DeleteLocalRef(jFontName);\n\t\t\t\t\t\tJavaUtils::DeleteLocalRef(jText);\n\n\t\t\t\t\t\tm_subtitleMap.insert(std::make_pair(*it, subtitleID));\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t//update the current text views\n\t\t\t\tfor (auto it = m_subtitleMap.begin(); it != m_subtitleMap.end(); ++it)\n\t\t\t\t{\n\t\t\t\t\tUpdateSubtitle(it->first, it->second, m_currentSubtitleTimeMS);\n\t\t\t\t}\n\n\t\t\t\t//removes any text views that are no longer needed.\n\t\t\t\tfor (auto it = m_subtitlesToRemove.begin(); it != m_subtitlesToRemove.end(); ++it)\n\t\t\t\t{\n\t\t\t\t\tauto mapEntry = m_subtitleMap.find(*it);\n\t\t\t\t\tif (mapEntry != m_subtitleMap.end())\n\t\t\t\t\t{\n\t\t\t\t\t\tm_javaSystem->CallVoidMethod(\"removeSubtitle\", mapEntry->second);\n\t\t\t\t\t\tm_subtitleMap.erase(mapEntry);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tm_subtitlesToRemove.clear();\n\t\t\t}\n\t\t}\n\t\t//------------------------------------------------------------------------------\n\t\t//------------------------------------------------------------------------------\n\t\tvoid VideoPlayer::UpdateSubtitle(const ChilliSource::Subtitles::Subtitle* in_subtitle, s64 in_subtitleID, TimeIntervalMs in_timeMS)\n\t\t{\n\t\t\tconst ChilliSource::Subtitles::Style* style = m_subtitles->GetStyleWithName(in_subtitle->m_styleName);\n\n\t\t\tf32 fade = 0.0f;\n\t\t\ts64 relativeTime = ((s64)in_timeMS) - ((s64)in_subtitle->m_startTimeMS);\n\t\t\ts64 displayTime = ((s64)in_subtitle->m_endTimeMS) - ((s64)in_subtitle->m_startTimeMS);\n\n\t\t\t//subtitle should not be displayed yet so remove\n\t\t\tif (relativeTime < 0)\n\t\t\t{\n\t\t\t\tm_subtitlesToRemove.push_back(in_subtitle);\n\t\t\t}\n\n\t\t\t//fading in\n\t\t\telse if (relativeTime < style->m_fadeTimeMS)\n\t\t\t{\n\t\t\t\tfade = ((f32)relativeTime) / ((f32)style->m_fadeTimeMS);\n\t\t\t}\n\n\t\t\t//active\n\t\t\telse if (relativeTime < displayTime - style->m_fadeTimeMS)\n\t\t\t{\n\t\t\t\tfade = 1.0f;\n\t\t\t}\n\n\t\t\t//fading out\n\t\t\telse if (relativeTime < displayTime)\n\t\t\t{\n\t\t\t\tfade = 1.0f - (((f32)relativeTime - (displayTime - style->m_fadeTimeMS)) / ((f32)style->m_fadeTimeMS));\n\t\t\t}\n\n\t\t\t//should no longer be displayed so remove\n\t\t\telse if (relativeTime >= displayTime)\n\t\t\t{\n\t\t\t\tm_subtitlesToRemove.push_back(in_subtitle);\n\t\t\t}\n\n\t\t\tm_javaSystem->CallVoidMethod(\"setSubtitleColour\", in_subtitleID, style->m_colour.r, style->m_colour.g, style->m_colour.b, fade * style->m_colour.a);\n\t\t}\n\t\t//------------------------------------------------------------------------------\n\t\t//------------------------------------------------------------------------------\n        void VideoPlayer::OnDestroy()\n        {\n        \tm_javaSystem.reset();\n        }\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/JNI/Video/Base/VideoPlayer.h",
    "content": "//\n//  VideoPlayer.h\n//  ChilliSource\n//  Created by Ian Copland on 10/08/2012.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2012 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n\n#ifndef _CSBACKEND_PLATFORM_ANDROID_VIDEO_BASE_VIDEOPLAYER_H_\n#define _CSBACKEND_PLATFORM_ANDROID_VIDEO_BASE_VIDEOPLAYER_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Video/Base/Subtitles.h>\n#include <ChilliSource/Video/Base/VideoPlayer.h>\n\n#include <CSBackend/Platform/Android/Main/JNI/ForwardDeclarations.h>\n#include <CSBackend/Platform/Android/Main/JNI/Core/Java/JavaSystem.h>\n\n#include <unordered_map>\n#include <vector>\n\nnamespace CSBackend\n{\n    namespace Android\n    {\n    \t//------------------------------------------------------------------------------\n    \t/// The Android specific backend for the Video Player.\n    \t///\n    \t/// @author Ian Copland\n    \t//------------------------------------------------------------------------------\n        class VideoPlayer final : public ChilliSource::VideoPlayer\n        {\n        public:\n        \tCS_DECLARE_NAMEDTYPE(VideoPlayer);\n\t\t\t//------------------------------------------------------------------------------\n\t\t\t/// Queries whether or not this system implements the interface with the given\n\t\t\t/// Id.\n\t\t\t///\n            /// @author Ian Copland\n            ///\n\t\t\t/// @param in_interfaceId - The interface Id.\n\t\t\t///\n\t\t\t/// @return Whether system is of given type.\n\t\t\t//------------------------------------------------------------------------------\n\t\t\tbool IsA(ChilliSource::InterfaceIDType in_interfaceId) const override;\n            //------------------------------------------------------------------------------\n            /// Begin streaming the video from file\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param The storage location of the video.\n            /// @param The video file name.\n            /// @param Connection to complete delegate.\n            /// @param [Optional] Whether or not the video can be dismissed by tapping.\n            /// Defaults to true.\n            /// @param [Optional] The video background colour. Defaults to black.\n            //------------------------------------------------------------------------------\n            void Present(ChilliSource::StorageLocation in_storageLocation, const std::string& in_filePath, VideoCompleteDelegate::Connection&& in_delegateConnection, bool in_dismissWithTap = true,\n                         const ChilliSource::Colour& in_backgroundColour = ChilliSource::Colour::k_black) override;\n            //------------------------------------------------------------------------------\n            /// Begin streaming the video from file with subtitles.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param The storage location of the video.\n            /// @param The video file name.\n            /// @param The subtitles resource.\n            /// @param Connection to complete delegate.\n            /// @param [Optional] Whether or not the video can be dismissed by tapping.\n            /// Defaults to true.\n            /// @param [Optional] The video background colour. Defaults to black.\n            //------------------------------------------------------------------------------\n            void PresentWithSubtitles(ChilliSource::StorageLocation in_storageLocation, const std::string& in_filePath, const ChilliSource::SubtitlesCSPtr& in_subtitles, VideoCompleteDelegate::Connection&& in_delegateConnection,\n                                      bool in_dismissWithTap = true, const ChilliSource::Colour& in_backgroundColour = ChilliSource::Colour::k_black) override;\n            //------------------------------------------------------------------------------\n            /// Called from java when the video finishes. This is for internal use only\n            /// and should not be called by the user.\n            ///\n            /// @author Ian Copland\n            //------------------------------------------------------------------------------\n            void OnVideoComplete();\n            //------------------------------------------------------------------------------\n            /// Updates the subtitles. Note that this is called from the Android UI thread\n            /// rather than the main thread. This is for internal use only and should not\n            /// be called by the user.\n            ///\n            /// @author Ian Copland\n            //------------------------------------------------------------------------------\n            void OnUpdateSubtitles();\n            //-------------------------------------------------------\n            /// Returns whether or not the player is currently\n            /// presented.\n            ///\n            /// @author Jordan Brown\n            //-------------------------------------------------------\n            bool IsPresented() const noexcept override;\n        private:\n            friend ChilliSource::VideoPlayerUPtr ChilliSource::VideoPlayer::Create();\n            //------------------------------------------------------------------------------\n            /// Private constructor to force use of factory method\n            ///\n            /// @author S Downie\n            //------------------------------------------------------------------------------\n            VideoPlayer() = default;\n            //------------------------------------------------------------------------------\n            /// Called when the owning state is initialised.\n            ///\n            /// @author Ian Copland\n            //------------------------------------------------------------------------------\n            void OnInit() override;\n\t\t\t//------------------------------------------------------------------------------\n\t\t\t/// Updates a single subtitle.\n\t\t\t///\n\t\t\t/// @author Ian Copland\n\t\t\t///\n\t\t\t/// @param The subtitle\n\t\t\t/// @param The subtitle Id\n\t\t\t/// @param The time in milliseconds.\n\t\t\t//------------------------------------------------------------------------------\n\t\t\tvoid UpdateSubtitle(const ChilliSource::Subtitles::Subtitle* in_subtitle, s64 in_subtitleID, TimeIntervalMs in_timeMS);\n            //------------------------------------------------------------------------------\n            /// Called when the owning state is destroyed.\n            ///\n            /// @author Ian Copland\n            //------------------------------------------------------------------------------\n            void OnDestroy() override;\n\n            bool m_isPlaying = false;\n            VideoCompleteDelegate::Connection m_completionDelegateConnection;\n            ChilliSource::SubtitlesCSPtr m_subtitles;\n            std::unordered_map<const ChilliSource::Subtitles::Subtitle*, s64> m_subtitleMap;\n            std::vector<const ChilliSource::Subtitles::Subtitle*> m_subtitlesToRemove;\n            TimeIntervalMs m_currentSubtitleTimeMS = 0;\n\n            JavaSystemUPtr m_javaSystem;\n        };\n    }\n}\n\n#endif\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/JNI/Web/Base/WebView.cpp",
    "content": "//\n//  WebView.cpp\n//  ChilliSource\n//  Created by Steven Hendrie on 10/12/12.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2012 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n\n#include <CSBackend/Platform/Android/Main/JNI/Web/Base/WebView.h>\n\n#include <CSBackend/Platform/Android/Main/JNI/Core/File/FileSystem.h>\n#include <CSBackend/Platform/Android/Main/JNI/Web/Base/WebViewJavaInterface.h>\n\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/Base/Screen.h>\n#include <ChilliSource/Core/File/TaggedFilePathResolver.h>\n#include <ChilliSource/Core/String/StringUtils.h>\n#include <ChilliSource/Core/Threading/TaskScheduler.h>\n\nnamespace CSBackend\n{\n\tnamespace Android\n\t{\n\t\tnamespace\n\t\t{\n\t\t\t//--------------------------------------------------------------------------------------\n\t\t\t/// Breaks the given url path into the file path and anchor.\n\t\t\t///\n\t\t\t/// @author Ian Copland\n\t\t\t///\n\t\t\t/// @param in_combined - The URL.\n\t\t\t/// @param out_filePath - [Out] The file path.\n\t\t\t/// @param out_anchor - [Out] The anchor.\n\t\t\t//--------------------------------------------------------------------------------------\n\t\t\tvoid GetFilePathAndAnchor(const std::string& in_combined, std::string& out_filePath, std::string& out_anchor)\n\t\t\t{\n\t\t\t\tsize_t anchorStart = in_combined.find_last_of('#');\n\n\t\t\t\tif(anchorStart != std::string::npos)\n\t\t\t\t{\n\t\t\t\t\tout_anchor = in_combined.substr(anchorStart, in_combined.size() - anchorStart);\n\t\t\t\t\tout_filePath = in_combined.substr(0, anchorStart);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tout_anchor = \"\";\n\t\t\t\t\tout_filePath = in_combined;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\ts32 WebView::s_nextIndex = 1;\n\t\tstd::unordered_map<s32, WebView*> WebView::s_indexToWebViewMap;\n\n\t\tCS_DEFINE_NAMEDTYPE(WebView);\n\n\t\t//------------------------------------------------------------------------------\n\t\t//------------------------------------------------------------------------------\n\t\tvoid WebView::OnWebViewDismissed(s32 in_index)\n\t\t{\n\t\t\tauto webViewIt = s_indexToWebViewMap.find(in_index);\n\t\t\tif (webViewIt != s_indexToWebViewMap.end())\n\t\t\t{\n\t\t\t\twebViewIt->second->OnWebViewDismissed();\n\t\t\t}\n\t\t}\n\t\t//------------------------------------------------------------------------------\n\t\t//------------------------------------------------------------------------------\n        bool WebView::OnLinkClicked(s32 in_index, const std::string& in_url)\n        {\n\t\t\tauto webViewIt = s_indexToWebViewMap.find(in_index);\n            if (webViewIt != s_indexToWebViewMap.end())\n            {\n            \treturn webViewIt->second->OnLinkClicked(in_url);\n            }\n\n            return false;\n        }\n\t\t//------------------------------------------------------------------------------\n\t\t//------------------------------------------------------------------------------\n\t\tWebView::WebView()\n\t\t\t: m_index(s_nextIndex++), m_isPresented(false)\n\t\t{\n\t\t}\n\t\t//------------------------------------------------------------------------------\n\t\t//------------------------------------------------------------------------------\n\t\tbool WebView::IsA(ChilliSource::InterfaceIDType in_interfaceId) const\n\t\t{\n\t\t\treturn (ChilliSource::WebView::InterfaceID == in_interfaceId || WebView::InterfaceID == in_interfaceId);\n\t\t}\n\t\t//------------------------------------------------------------------------------\n\t\t//------------------------------------------------------------------------------\n\t\tvoid WebView::Present(const std::string& in_url, const ChilliSource::UnifiedVector2& in_size, f32 in_dismissButtonRelativeSize, const DismissedDelegate& in_delegate, const CustomLinkHandlerDelegate& in_customLinkHandler)\n\t\t{\n\t\t\tCS_ASSERT(m_isPresented == false, \"Cannot present a web view while one is already displayed.\");\n            CS_ASSERT(ChilliSource::Application::Get()->GetTaskScheduler()->IsMainThread(), \"Cannot present Web View on background threads.\");\n\n\t\t\tm_isPresented = true;\n\t\t\tm_delegate = in_delegate;\n\t\t\tm_customLinkHandlerDelegate = in_customLinkHandler;\n\n\t\t\tChilliSource::Vector2 absoluteSize = (m_screen->GetResolution() * in_size.GetRelative()) + in_size.GetAbsolute();\n\n\t\t\tWebViewJavaInterface::Present(m_index, in_url, absoluteSize, in_dismissButtonRelativeSize);\n\t\t}\n\t\t//------------------------------------------------------------------------------\n\t\t//------------------------------------------------------------------------------\n\t\tvoid WebView::PresentFromFile(ChilliSource::StorageLocation in_storageLocation, const std::string& in_filePath, const ChilliSource::UnifiedVector2& in_size, f32 in_dismissButtonRelativeSize, const DismissedDelegate& in_delegate, const CustomLinkHandlerDelegate& in_customLinkHandler)\n\t\t{\n\t\t\tCS_ASSERT(m_isPresented == false, \"Cannot present a web view while one is already displayed.\");\n            CS_ASSERT(ChilliSource::Application::Get()->GetTaskScheduler()->IsMainThread(), \"Cannot present Web View on background threads.\");\n\n\t\t\tauto fileSystem = static_cast<CSBackend::Android::FileSystem*>(ChilliSource::Application::Get()->GetFileSystem());\n\n\t\t\tstd::string anchor;\n\t\t\tstd::string filePath;\n\t\t\tGetFilePathAndAnchor(in_filePath, filePath, anchor);\n\t\t\tauto taggedFilePath = ChilliSource::Application::Get()->GetTaggedFilePathResolver()->ResolveFilePath(in_storageLocation, filePath);\n\n\t\t\tstd::string htmlFileContents;\n\t\t\tif (fileSystem->ReadFile(in_storageLocation, taggedFilePath, htmlFileContents) == false)\n\t\t\t{\n\t\t\t\tCS_LOG_ERROR(\"Could not open WebView: \" + taggedFilePath);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tstd::string fullFilePath;\n\t\t\tif (in_storageLocation == ChilliSource::StorageLocation::k_package || in_storageLocation == ChilliSource::StorageLocation::k_package ||\n            \t(in_storageLocation == ChilliSource::StorageLocation::k_DLC && fileSystem->DoesFileExistInCachedDLC(taggedFilePath) == false))\n\t\t\t{\n#ifdef CS_ANDROIDFLAVOUR_GOOGLEPLAY\n\t\t\t\tfullFilePath = m_contentProvider->CallStringMethod(\"getContentPathPrefix\") + fileSystem->GetAbsolutePathToStorageLocation(in_storageLocation) + taggedFilePath;\n#elif defined(CS_ANDROIDFLAVOUR_AMAZON)\n\t\t\t\tfullFilePath = \"file:///android_asset/\" + fileSystem->GetAbsolutePathToStorageLocation(in_storageLocation) + taggedFilePath;\n#else\n\t\t\t\tCS_LOG_FATAL(\"WebView doesn't support this Android flavour.\");\n#endif\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tfullFilePath = \"file://\" + fileSystem->GetAbsolutePathToStorageLocation(in_storageLocation) + taggedFilePath;\n\t\t\t}\n\n\t\t\t//Get the directory.\n\t\t\tu32 offset = fullFilePath.find_last_of(\"/\");\n\t\t\tif(offset != std::string::npos)\n\t\t\t{\n\t\t\t\tfullFilePath = fullFilePath.substr(0, offset) + \"/\";\n\t\t\t}\n\n\t\t\tm_isPresented = true;\n\t\t\tm_delegate = in_delegate;\n\t\t\tm_customLinkHandlerDelegate = in_customLinkHandler;\n\n\t\t\tChilliSource::Vector2 absoluteSize = (m_screen->GetResolution() * in_size.GetRelative()) + in_size.GetAbsolute();\n\t\t\tWebViewJavaInterface::PresentFromFile(m_index, htmlFileContents, absoluteSize, fullFilePath, anchor, in_dismissButtonRelativeSize);\n\t\t}\n\t\t//------------------------------------------------------------------------------\n\t\t//------------------------------------------------------------------------------\n\t\tvoid WebView::PresentInExternalBrowser(const std::string& in_url)\n\t\t{\n\t\t\tWebViewJavaInterface::PresentInExternalBrowser(in_url);\n\t\t}\n\t\t//------------------------------------------------------------------------------\n\t\t//------------------------------------------------------------------------------\n\t\tvoid WebView::Dismiss()\n\t\t{\n\t\t\tWebViewJavaInterface::Dismiss(m_index);\n\t\t}\n\t\t//------------------------------------------------------------------------------\n\t\t//------------------------------------------------------------------------------\n        bool WebView::IsPresented() const\n        {\n        \treturn m_isPresented;\n        }\n\t\t//------------------------------------------------------------------------------\n\t\t//------------------------------------------------------------------------------\n\t\tvoid WebView::OnInit()\n\t\t{\n\t\t\tm_screen = ChilliSource::Application::Get()->GetSystem<ChilliSource::Screen>();\n\t\t\ts_indexToWebViewMap.emplace(m_index, this);\n\n#ifdef CS_ANDROIDFLAVOUR_GOOGLEPLAY\n\t\t\tJavaStaticClassDef classDef(\"com/chilliworks/chillisource/core/ApkExpansionContentProvider\");\n\t\t\tclassDef.AddMethod(\"getContentPathPrefix\", \"()Ljava/lang/String;\");\n\t\t\tm_contentProvider = JavaStaticClassUPtr(new JavaStaticClass(classDef));\n#endif\n\t\t}\n\t\t//------------------------------------------------------------------------------\n\t\t//------------------------------------------------------------------------------\n        void WebView::OnWebViewDismissed()\n        {\n            CS_ASSERT(ChilliSource::Application::Get()->GetTaskScheduler()->IsMainThread(), \"Web View dismissal callback not on main thread.\");\n        \tm_isPresented = false;\n\n        \tif (m_delegate != nullptr)\n        \t{\n        \t\tDismissedDelegate delegate = m_delegate;\n        \t\tm_delegate = nullptr;\n        \t\tdelegate();\n        \t}\n        }\n\t\t//------------------------------------------------------------------------------\n\t\t//------------------------------------------------------------------------------\n        bool WebView::OnLinkClicked(const std::string& in_url)\n        {\n\t\t\tif(m_customLinkHandlerDelegate)\n\t\t\t{\n\t\t\t\treturn m_customLinkHandlerDelegate(in_url);\n\t\t\t}\n\n\t\t\treturn false;\n        }\n\t\t//------------------------------------------------------------------------------\n\t\t//------------------------------------------------------------------------------\n\t\tvoid WebView::OnDestroy()\n\t\t{\n\t\t\tif (IsPresented() == true)\n\t\t\t{\n\t\t\t\tDismiss();\n\t\t\t}\n\n\t\t\ts_indexToWebViewMap.erase(m_index);\n\t\t}\n\t}\n}\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/JNI/Web/Base/WebView.h",
    "content": "//\n//  WebView.h\n//  ChilliSource\n//  Created by Steven Hendrie on 10/12/12.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2012 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n\n#ifndef _CSBACKEND_PLATFORM_ANDROID_WEB_BASE_WEBVIEW_H_\n#define _CSBACKEND_PLATFORM_ANDROID_WEB_BASE_WEBVIEW_H_\n\n#include <CSBackend/Platform/Android/Main/JNI/Core/Java/JavaStaticClass.h>\n\n#include <ChilliSource/ChilliSource.h>\n#include <CSBackend/Platform/Android/Main/JNI/ForwardDeclarations.h>\n#include <ChilliSource/Core/Math/UnifiedCoordinates.h>\n#include <ChilliSource/Web/Base/WebView.h>\n\n#include <unordered_map>\n\nnamespace CSBackend\n{\n\tnamespace Android\n\t{\n\t\t//--------------------------------------------------------------------------------------\n\t\t/// The Android backend for the web view.\n\t\t///\n\t\t/// @author S Hendrie\n\t\t//--------------------------------------------------------------------------------------\n\t\tclass WebView final : public ChilliSource::WebView\n\t\t{\n\t\tpublic:\n            CS_DECLARE_NAMEDTYPE(WebView);\n\t\t\t//--------------------------------------------------------------------------------------\n\t\t\t/// Called when webview has been dismissed. This is for\n            /// internal use and should not be called manually by the\n            /// user.\n            ///\n            /// @author S Hendrie\n\t\t\t///\n\t\t\t/// @param index of webview\n            //--------------------------------------------------------------------------------------\n\t\t\tstatic void OnWebViewDismissed(s32 in_index);\n            //--------------------------------------------------------------------------------------\n            /// Called from the Java webview to inform the system\n            /// that a link on the webview has been clicked. This will\n            /// pass the link to any external handlers (if any) and\n            /// return based on whether it will be handled elsewhere\n            ///\n            /// This should not be called manually by the user.\n            ///\n            /// @author HMcLaughlin\n            ///\n            /// @param in_url - Index of webview\n            /// @param in_url - URL Clicked\n            ///\n            /// @return If this link will be handled elsewhere\n            //--------------------------------------------------------------------------------------\n            static bool OnLinkClicked(s32 in_index, const std::string& in_url);\n            //-------------------------------------------------------\n\t\t\t/// Queries whether or not this system implements the\n            /// interface with the given Id.\n\t\t\t///\n            /// @author S Hendrie\n            ///\n\t\t\t/// @param The interface Id.\n\t\t\t/// @param Whether system is of given type.\n\t\t\t//--------------------------------------------------------------------------------------\n\t\t\tbool IsA(ChilliSource::InterfaceIDType in_interfaceId) const override;\n            //--------------------------------------------------------------------------------------\n            /// Displays the website at the given URL in an in-app\n            /// web view.\n            ///\n            /// @author S Hendrie\n            ///\n            /// @param in_url - The Url.\n            /// @param in_size - The size of the webview in GUI coordinates.\n            /// @param in_dismissButtonRelativeSize - The relative size of the dismiss button.\n            /// @param in_delegate - The dismissed delegate.\n            /// @param in_customLinkHandler - The delegate to call when a link is clicked on\n            /// the displayed page\n            //--------------------------------------------------------------------------------------\n            void Present(const std::string& in_url, const ChilliSource::UnifiedVector2& in_size, f32 in_dismissButtonRelativeSize, const DismissedDelegate& in_delegate, const CustomLinkHandlerDelegate& in_customLinkHandler = nullptr) override;\n            //--------------------------------------------------------------------------------------\n            /// Displays the website at the given location on disk in\n            /// an in-app web view.\n            ///\n            /// @author S Hendrie\n            ///\n            /// @param in_storageLocation - The storage location.\n            /// @param in_filePath - The file path.\n            /// @param in_size - The size of the webview in GUI coordinates.\n            /// @param in_dismissButtonRelativeSize - The relative size of the dismiss button.\n            /// @param in_delegate - The dismissed delegate.\n            /// @param in_customLinkHandler - The delegate to call when a link is clicked on\n            /// the displayed page\n            //--------------------------------------------------------------------------------------\n            void PresentFromFile(ChilliSource::StorageLocation in_storageLocation, const std::string& in_filePath, const ChilliSource::UnifiedVector2& in_size, f32 in_dismissButtonRelativeSize, const DismissedDelegate& in_delegate, const CustomLinkHandlerDelegate& in_customLinkHandler = nullptr) override;\n            //--------------------------------------------------------------------------------------\n            /// Displays the website at the given Url in an external\n            /// browser.\n            ///\n            /// @author S Hendrie\n            ///\n            /// @param The Url.\n            //--------------------------------------------------------------------------------------\n            void PresentInExternalBrowser(const std::string& in_url) override;\n            //--------------------------------------------------------------------------------------\n            /// Dismiss the web view if it is currently presented.\n            ///\n            /// @author S Hendrie\n            //--------------------------------------------------------------------------------------\n            void Dismiss() override;\n            //--------------------------------------------------------------------------------------\n            /// @author S Hendrie\n            ///\n            /// @return Whether or not the web view is currently\n            /// presented.\n            //--------------------------------------------------------------------------------------\n            bool IsPresented() const override;\n\t\tprivate:\n            friend ChilliSource::WebViewUPtr ChilliSource::WebView::Create();\n            //--------------------------------------------------------------------------------------\n            /// Private constructor to force use of factory method\n            ///\n            /// @author S Downie\n            //--------------------------------------------------------------------------------------\n            WebView();\n            //--------------------------------------------------------------------------------------\n            /// Called when the the owning state is initialised.\n            ///\n            /// @author Ian Copland\n            //--------------------------------------------------------------------------------------\n\t\t\tvoid OnInit() override;\n            //--------------------------------------------------------------------------------------\n            /// Called when the webview is dismissed.\n            ///\n            /// @author Ian Copland\n            //--------------------------------------------------------------------------------------\n            void OnWebViewDismissed();\n            //--------------------------------------------------------------------------------------\n            /// Called from the Java webview to inform the system\n            /// that a link on the webview has been clicked. This will\n            /// pass the link to any external handlers (if any) and\n            /// return based on whether it will be handled elsewhere\n            ///\n            /// @author HMcLaughlin\n            ///\n            /// @param in_url - URL Clicked\n            ///\n            /// @return If this link will be handled elsewhere\n            //--------------------------------------------------------------------------------------\n            bool OnLinkClicked(const std::string& in_url);\n            //--------------------------------------------------------------------------------------\n            /// Called when the the owning state is destroyed.\n            ///\n            /// @author Ian Copland\n            //--------------------------------------------------------------------------------------\n\t\t\tvoid OnDestroy() override;\n\t\tprivate:\n\n\t\t\tChilliSource::Screen* m_screen;\n\n\t\t\tbool m_isPresented;\n\t\t\tconst s32 m_index;\n\n\t\t\tDismissedDelegate m_delegate;\n            CustomLinkHandlerDelegate m_customLinkHandlerDelegate;\n\n\t\t\tstatic s32 s_nextIndex;\n\t\t\tstatic std::unordered_map<s32, WebView*> s_indexToWebViewMap;\n\n#ifdef CS_ANDROIDFLAVOUR_GOOGLEPLAY\n            JavaStaticClassUPtr m_contentProvider;\n#endif\n\t\t};\n\n\t}\n}\n\n#endif\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/JNI/Web/Base/WebViewJavaInterface.cpp",
    "content": "//\n//  WebViewJavaInterface.cpp\n//  ChilliSource\n//  Created by Steven Hendrie on 10/12/2012.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2012 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n\n#include <CSBackend/Platform/Android/Main/JNI/Web/Base/WebViewJavaInterface.h>\n\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/Threading/TaskScheduler.h>\n\n#include <CSBackend/Platform/Android/Main/JNI/Core/Java/JavaUtils.h>\n#include <CSBackend/Platform/Android/Main/JNI/Web/Base/WebView.h>\n\n//function definitions\nextern \"C\"\n{\n\t//--------------------------------------------------------------------------------------\n\t/// Called when the webview is dismissed\n\t///\n\t/// @author HMcLaughlin\n\t///\n\t/// @param in_env - The jni environment.\n\t/// @param in_object - The java object calling the function\n\t/// @param in_index - The request index\n\t///\n\t/// @return whether or not the text was accepted.\n\t//--------------------------------------------------------------------------------------\n\tvoid Java_com_chilliworks_chillisource_web_WebViewNativeInterface_onWebviewDismissed(JNIEnv* in_env, jobject in_object, u32 in_index);\n\t//--------------------------------------------------------------------------------------\n\t/// Called when a link is clicked from an internal webview\n\t///\n\t/// @author HMcLaughlin\n\t///\n\t/// @param in_env - The jni environment.\n\t/// @param in_object - The java object calling the function\n\t/// @param in_index - The request index\n\t/// @param in_url - The request URL\n\t///\n\t/// @return whether or not the link was handled externally.\n\t//--------------------------------------------------------------------------------------\n\tbool Java_com_chilliworks_chillisource_web_WebViewNativeInterface_onLinkClicked(JNIEnv* in_env, jobject in_object, u32 in_index, jstring in_url);\n}\n//--------------------------------------------------------------------------------------\n//--------------------------------------------------------------------------------------\nvoid Java_com_chilliworks_chillisource_web_WebViewNativeInterface_onWebviewDismissed(JNIEnv* inpEnv, jobject thiz, u32 inudwIndex)\n{\n    ChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_mainThread, [=](const ChilliSource::TaskContext& in_taskContext)\n    {\n        CSBackend::Android::WebView::OnWebViewDismissed(inudwIndex);\n    });\n}\n//--------------------------------------------------------------------------------------\n//--------------------------------------------------------------------------------------\nbool Java_com_chilliworks_chillisource_web_WebViewNativeInterface_onLinkClicked(JNIEnv* in_env, jobject in_object, u32 in_index, jstring in_url)\n{\n\treturn CSBackend::Android::WebView::OnLinkClicked(in_index, CSBackend::Android::JavaUtils::CreateSTDStringFromJString(in_url));\n}\n\nnamespace CSBackend\n{\n\tnamespace Android\n\t{\n\t\tvoid WebViewJavaInterface::SetupJavaInterface(JavaVM* inpJavaVM)\n\t\t{\n\t\t\tmspJavaVM = inpJavaVM;\n\n\t\t\tInitCallableStaticMethod(\"com/chilliworks/chillisource/web/WebViewNativeInterface\",\"Present\", \"(ILjava/lang/String;IIF)V\");\n\t\t\tInitCallableStaticMethod(\"com/chilliworks/chillisource/web/WebViewNativeInterface\",\"PresentFromFile\", \"(ILjava/lang/String;IILjava/lang/String;Ljava/lang/String;F)V\");\n\t\t\tInitCallableStaticMethod(\"com/chilliworks/chillisource/web/WebViewNativeInterface\",\"PresentInExternalBrowser\", \"(Ljava/lang/String;)V\");\n\t\t\tInitCallableStaticMethod(\"com/chilliworks/chillisource/web/WebViewNativeInterface\",\"Dismiss\", \"(I)V\");\n\t\t}\n\t\tvoid WebViewJavaInterface::Present(u32 inudwIndex, const std::string& instrURL, const ChilliSource::Vector2& invSize, f32 in_dismissButtonRelativeSize)\n\t\t{\n\t\t\tMethodReference sdMethodRef = GetStaticMethodReference(\"Present\");\n\n\t\t\tif (sdMethodRef.mMethodID != 0 && sdMethodRef.mClassID != 0)\n\t\t\t{\n\t\t\t\tJNIEnv* env = GetJNIEnvironmentPtr();\n\t\t\t\tjstring jstrURL = CreateJStringFromSTDString(instrURL);\n\t\t\t\tu32 udwIndex = inudwIndex;\n\t\t\t\tu32 udwWidth = invSize.x;\n\t\t\t\tu32 udwHeight = invSize.y;\n\t\t\t\tenv->CallStaticVoidMethod(sdMethodRef.mClassID, sdMethodRef.mMethodID,udwIndex,jstrURL,udwWidth,udwHeight, in_dismissButtonRelativeSize);\n\n\t\t\t\t//delete local reference\n\t\t\t\tenv->DeleteLocalRef(jstrURL);\n\t\t\t}\n\t\t}\n\t\tvoid WebViewJavaInterface::PresentFromFile(u32 inudwIndex, const std::string& instrHTMLContent, const ChilliSource::Vector2& invSize, const std::string& instrBasePath, const std::string& instrAnchor, f32 in_dismissButtonRelativeSize)\n\t\t{\n\t\t\tMethodReference sdMethodRef = GetStaticMethodReference(\"PresentFromFile\");\n\n\t\t\tif (sdMethodRef.mMethodID != 0 && sdMethodRef.mClassID != 0)\n\t\t\t{\n\t\t\t\tJNIEnv* env = GetJNIEnvironmentPtr();\n\t\t\t\tjstring jstrContent = CreateJStringFromSTDString(instrHTMLContent);\n\t\t\t\tjstring jstrBasePath = CreateJStringFromSTDString(instrBasePath);\n\t\t\t\tjstring jstrAnchor = CreateJStringFromSTDString(instrAnchor);\n\t\t\t\tu32 udwIndex = inudwIndex;\n\t\t\t\tu32 udwWidth = invSize.x;\n\t\t\t\tu32 udwHeight = invSize.y;\n\t\t\t\tenv->CallStaticVoidMethod(sdMethodRef.mClassID, sdMethodRef.mMethodID, udwIndex, jstrContent, udwWidth, udwHeight, jstrBasePath, jstrAnchor, in_dismissButtonRelativeSize);\n\n\t\t\t\t//delete local reference\n\t\t\t\tenv->DeleteLocalRef(jstrContent);\n\t\t\t\tenv->DeleteLocalRef(jstrBasePath);\n\t\t\t\tenv->DeleteLocalRef(jstrAnchor);\n\t\t\t}\n\t\t}\n\t\tvoid WebViewJavaInterface::PresentInExternalBrowser(const std::string& instrURL)\n\t\t{\n\t\t\tMethodReference sdMethodRef = GetStaticMethodReference(\"PresentInExternalBrowser\");\n\n\t\t\tif (sdMethodRef.mMethodID != 0 && sdMethodRef.mClassID != 0)\n\t\t\t{\n\t\t\t\tJNIEnv* env = GetJNIEnvironmentPtr();\n\t\t\t\tjstring jstrContent = CreateJStringFromSTDString(instrURL);\n\t\t\t\tenv->CallStaticVoidMethod(sdMethodRef.mClassID, sdMethodRef.mMethodID,jstrContent);\n\n\t\t\t\t//delete local reference\n\t\t\t\tenv->DeleteLocalRef(jstrContent);\n\t\t\t}\n\t\t}\n\t\tvoid WebViewJavaInterface::Dismiss(u32 inudwIndex)\n\t\t{\n\t\t\tMethodReference sdMethodRef = GetStaticMethodReference(\"Dismiss\");\n\n\t\t\tif (sdMethodRef.mMethodID != 0 && sdMethodRef.mClassID != 0)\n\t\t\t{\n\t\t\t\tJNIEnv* env = GetJNIEnvironmentPtr();\n\t\t\t\tu32 udwIndex = inudwIndex;\n\t\t\t\tenv->CallStaticVoidMethod(sdMethodRef.mClassID, sdMethodRef.mMethodID, udwIndex);\n\t\t\t}\n\t\t}\n\t}\n}\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/JNI/Web/Base/WebViewJavaInterface.h",
    "content": "//\n//  WebViewJavaInterface.h\n//  ChilliSource\n//  Created by Steven Hendrie on 10/12/2012.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2012 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n\n#ifndef _CHILLISOURCE_PLATFORM_ANDROID_CORE_WEBVIEW_INTERFACE_\n#define _CHILLISOURCE_PLATFORM_ANDROID_CORE_WEBVIEW_INTERFACE_\n\n#include <CSBackend/Platform/Android/Main/JNI/Core/Java/_JavaInterface.h>\n\nnamespace CSBackend\n{\n\tnamespace Android\n\t{\n\t\tclass WebViewJavaInterface : public _IJavaInterface\n\t\t{\n\t\tpublic:\n\t\t\t//--------------------------------------------------------------------------------------\n\t\t\t/// Setup Java Interface\n\t\t\t///\n\t\t\t/// Sets up the java interface: stores the Virtual Machine, and Initialises any java\n\t\t\t/// methods callable from native.\n\t\t\t///\n\t\t\t/// @param a pointer to the virtual machine\n\t\t\t//--------------------------------------------------------------------------------------\n\t\t\tstatic void SetupJavaInterface(JavaVM* inpJavaVM);\n\t\t\t//-----------------------------------------------\n\t\t\t/// Present\n\t\t\t///\n\t\t\t/// Pass the url to the java interface to display\n\t\t\t///\n\t\t\t/// @param index of webview\n\t\t\t/// @param URL\n\t\t\t/// @param size of webview\n\t\t\t/// @param The relative size of the button.\n\t\t\t//-----------------------------------------------\n\t\t\tstatic void Present(u32 inudwIndex, const std::string& instrURL, const ChilliSource::Vector2& invSize, f32 in_dismissButtonRelativeSize);\n\t\t\t//-----------------------------------------------\n\t\t\t/// Present from file\n\t\t\t///\n\t\t\t/// Pass the html string to java interface to display\n\t\t\t///\n\t\t\t/// @param index of webview\n\t\t\t/// @param HTML content\n\t\t\t/// @param size of webview\n\t\t\t/// @param Base path of assets\n\t\t\t/// @param Anchor\n\t\t\t/// @param The relative size of the button.\n\t\t\t//-----------------------------------------------\n\t\t\tstatic void PresentFromFile(u32 inudwIndex, const std::string& instrHTMLContent, const ChilliSource::Vector2& invSize, const std::string& instrBasePath, const std::string& instrAnchor, f32 in_dismissButtonRelativeSize);\n\t\t\t//-----------------------------------------------\n\t\t\t/// Present from external browser\n\t\t\t///\n\t\t\t/// Display url in external default browser\n\t\t\t///\n\t\t\t/// @param URL\n\t\t\t//-----------------------------------------------\n\t\t\tstatic void PresentInExternalBrowser(const std::string& instrURL);\n\t\t\t//-----------------------------------------------\n\t\t\t/// Dismiss\n\t\t\t///\n\t\t\t/// Remove the specified webview from the screen\n\t\t\t///\n\t\t\t/// @param index of webview\n\t\t\t//-----------------------------------------------\n\t\t\tstatic void Dismiss(u32 inudwIndex);\n\t\t};\n\n\t}\n}\n\n#endif\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/Java/com/chilliworks/chillisource/core/AESEncryption.java",
    "content": "/**\n * AESEncryption.java\n * ChilliSource\n * Created by Ian Copland on 07/01/2014.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2014 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.core;\n\nimport javax.crypto.Cipher;\nimport javax.crypto.spec.SecretKeySpec;\n\n//==================================================================\n/// AES Encrpytion\n///\n/// A series of methods for use when using AES Encryption.\n//==================================================================\npublic class AESEncryption \n{\n\t//------------------------------------------------------------\n\t/// Encrypt\n\t///\n\t/// Encrypts the given data with AES Encryption.\n\t///\n\t/// @param The input data. This does not need to be padded.\n\t/// @param The private key.\n\t/// @return The encrypted data.\n\t//------------------------------------------------------------\n\tpublic static byte[] Encrypt(byte[] inabyData, byte[] inabyPrivateKey)\n\t{\n\t\tbyte[] abyOutput = null;\n\t\ttry\n\t\t{\n\t\t\tCipher cipher = Cipher.getInstance(\"AES\");\n\t        SecretKeySpec keySpec = new SecretKeySpec(inabyPrivateKey, \"AES\");\n\t        cipher.init(Cipher.ENCRYPT_MODE, keySpec);\n\t        abyOutput = cipher.doFinal(inabyData);\n\t\t}\n\t\tcatch (Exception e)\n\t\t{\n\t\t\tExceptionUtils.convertToString(e);\n\t\t}\n        return abyOutput;\n\t}\n\t//------------------------------------------------------------\n\t/// Decrypt\n\t///\n\t/// Decrypts the given data with AES Encryption.\n\t///\n\t/// @param The encrypted data.\n\t/// @param The private key.\n\t/// @return The data.\n\t//------------------------------------------------------------\n\tpublic static byte[] Decrypt(byte[] inabyEncryptedData, byte[] inabyPrivateKey)\n\t{\n\t\tbyte[] abyOutput = null;\n\t\ttry\n\t\t{\n\t\t\tCipher cipher = Cipher.getInstance(\"AES\");\n\t        SecretKeySpec keySpec = new SecretKeySpec(inabyPrivateKey, \"AES\");\n\t        cipher.init(Cipher.DECRYPT_MODE, keySpec);\n\t        abyOutput = cipher.doFinal(inabyEncryptedData);\n\t\t}\n\t\tcatch (Exception e)\n\t\t{\n\t\t\tExceptionUtils.convertToString(e);\n\t\t}\n        return abyOutput;\n\t}\n}\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/Java/com/chilliworks/chillisource/core/ApkFileUtils.java",
    "content": "/**\n * ApkFileUtils.java\n * ChilliSource\n * Created by Ian Copland on 22/07/2015\n *\n * The MIT License (MIT)\n *\n * Copyright (c) 2015 Tag Games Limited\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.core;\n\nimport android.app.Activity;\nimport android.content.res.AssetFileDescriptor;\nimport android.content.res.AssetManager;\n\nimport java.io.BufferedInputStream;\nimport java.io.File;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.util.Arrays;\nimport java.util.List;\n\n/**\n * A collection of convenience methods for reading files from the APK.\n *\n * @author Ian Copland\n */\npublic final class ApkFileUtils\n{\n    /**\n     * @author Ian Copland\n     *\n     * @param in_activity - The current activity.\n     * @param in_filePath - The file path inside the APK.\n     *\n     * @return Whether or not the given file exists in the APK.\n     */\n    public static boolean doesFileExist(Activity in_activity, String in_filePath)\n    {\n        try\n        {\n            File file = new File(in_filePath);\n\n            AssetManager assets = in_activity.getAssets();\n\n            String parentDirectoryPath = file.getParent();\n            if (parentDirectoryPath == null)\n            {\n                parentDirectoryPath = \"\";\n            }\n\n            String[] filesArray = assets.list(parentDirectoryPath);\n            if (filesArray != null && filesArray.length > 0)\n            {\n                List<String> filesList = Arrays.asList(filesArray);\n                return filesList.contains(file.getName());\n            }\n        }\n        catch (IOException e)\n        {\n            Logging.logVerbose(ExceptionUtils.convertToString(e));\n            Logging.logError(\"An error occurred while checking if file '\" + in_filePath + \"' exists: \" + e.getMessage());\n        }\n\n        return false;\n    }\n    /**\n     * Reads the entire contents of a binary file from the APK. The contents are returned as a\n     * byte array.\n     *\n     * @author Ian Copland\n     *\n     * @param in_activity - The activity\n     * @param in_filePath - The path to the file.\n     *\n     * @return The file contents.\n     */\n    public static byte[] readBinaryFile(Activity in_activity, String in_filePath)\n    {\n        try\n        {\n            if (doesFileExist(in_activity, in_filePath) == true)\n            {\n                final int k_bufferSize = 16 * 1024;\n                DynamicByteBuffer dynamicByteBuffer = new DynamicByteBuffer(k_bufferSize);\n\n                InputStream stream = new BufferedInputStream(in_activity.getAssets().open(in_filePath));\n                try\n                {\n                    byte[] buffer = new byte[k_bufferSize];\n                    int numRead = 0;\n                    while(numRead != -1)\n                    {\n                        numRead = stream.read(buffer, 0, k_bufferSize);\n                        if (numRead > 0)\n                        {\n                            dynamicByteBuffer.appendBytes(buffer, numRead);\n                        }\n                    }\n                }\n                finally\n                {\n                    stream.close();\n                }\n\n                return dynamicByteBuffer.toByteArray();\n            }\n        }\n        catch (IOException e)\n        {\n            Logging.logVerbose(ExceptionUtils.convertToString(e));\n            Logging.logError(\"An error occurred while reading file '\" + in_filePath + \"': \" + e.getMessage());\n        }\n\n        return null;\n    }\n    /**\n     * Reads the entire contents of a text file from the APK.\n     *\n     * @author Ian Copland\n     *\n     * @param in_activity - The activity\n     * @param in_filePath - The path to the file.\n     *\n     * @return The file contents.\n     */\n    public static String readTextFile(Activity in_activity, String in_filePath)\n    {\n        byte[] contents = readBinaryFile(in_activity, in_filePath);\n        if (contents == null)\n        {\n            return \"\";\n        }\n        return StringUtils.utf8BytesToString(contents);\n    }\n    /**\n     * Calculates the size of the given file located in the APK.\n     *\n     * @author Ian Copland\n     *\n     * @param in_activity - The activity which is currently active.\n     * @param in_filePath - The path to the file which is to have its size calculated.\n     *\n     * @return The size of the file in bytes.\n     */\n    public static long getFileSize(Activity in_activity, String in_filePath)\n    {\n        try\n        {\n            AssetFileDescriptor fileDesc = in_activity.getAssets().openFd(in_filePath);\n            if (fileDesc != null)\n            {\n                return fileDesc.getLength();\n            }\n        }\n        catch (IOException e)\n        {\n            Logging.logError(ExceptionUtils.convertToString(e));\n        }\n\n        return 0;\n    }\n    /**\n     * Copies the requested file from the Apk to external storage.\n     *\n     * @author Ian Copland\n     *\n     * @param in_activity - The activity which is currently active.\n     * @param in_sourceFilePath - The source file path inside the Apk.\n     * @param in_destFilePath - The destination file path in external storage.\n     *\n     * @return Whether or not the copy was successful.\n     */\n    public static boolean copyFile(Activity in_activity, String in_sourceFilePath, String in_destFilePath)\n    {\n        if (doesFileExist(in_activity, in_sourceFilePath) == false)\n        {\n            return false;\n        }\n\n        byte[] fileContents = readBinaryFile(in_activity, in_sourceFilePath);\n        if (fileContents == null)\n        {\n            return false;\n        }\n\n        return FileUtils.writeBinaryFile(in_destFilePath, fileContents);\n    }\n}\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/Java/com/chilliworks/chillisource/core/AppConfig.java",
    "content": "/**\n * AppConfig.java\n * ChilliSource\n * Created by Scott Downie on 23/09/2014.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2014 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.core;\n\nimport org.json.JSONObject;\n\nimport android.app.Activity;\n\n/**\n * Parses the App.config to obtain Android specific configuration properties\n * \n * @author S Downie\n */\npublic final class AppConfig \n{\n\tprivate final String k_configFilePath = \"AppResources/App.config\";\n\t\n\tprivate String m_surfaceFormat = \"rgb565_depth24\";\n\tprivate boolean m_requiresGooglePlayServices = false;\n\t\n\t/**\n\t * Constructor that parses the App.config\n\t * \n\t * @author S Downie\n\t * \n\t * @param Activity used to load file\n\t */\n\tAppConfig(Activity in_activity)\n\t{\n\t\tparse(in_activity);\n\t}\n\t/**\n\t * @author S Downie\n\t * \n\t * @return Config property representing surface format\n\t */\n\tpublic String getSurfaceFormat()\n\t{\n\t\treturn m_surfaceFormat;\n\t}\n\t/**\n\t * @author S Downie\n\t * \n\t * @return Whether Google play services is required allowing by the app\n\t */\n\tpublic boolean isGooglePlayServicesRequired()\n\t{\n\t\treturn m_requiresGooglePlayServices;\n\t}\n\t/**\n\t * Reads the properties from the App.config file.\n\t *\n\t * @author S Downie\n\t * \n\t * @param The activity\n\t */\n\tprivate void parse(Activity in_activity)\n\t{\n\t\tif (PackageFileUtils.doesFileExist(in_activity, k_configFilePath))\n\t\t{\n\t\t\tString stringContents = PackageFileUtils.readTextFile(in_activity, k_configFilePath);\n\t\t\t\n\t\t\ttry\n\t\t\t{\n\t\t\t\tJSONObject root = new JSONObject(stringContents);\n\t\t\t\tif (root.has(\"PreferredSurfaceFormat\") == true)\n\t\t\t\t{\n\t\t\t\t\tm_surfaceFormat = root.getString(\"PreferredSurfaceFormat\");\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif(root.has(\"Android\") == true)\n\t\t\t\t{\n\t\t\t\t\tJSONObject android = root.getJSONObject(\"Android\");\n\t\t\t\t\t\n\t\t\t\t\tif(android.has(\"PreferredSurfaceFormat\") == true)\n\t\t\t\t\t{\n\t\t\t\t\t\tm_surfaceFormat = android.getString(\"PreferredSurfaceFormat\");\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tif(android.has(\"GooglePlay\") == true)\n\t\t\t\t\t{\n\t\t\t\t\t\tJSONObject googlePlay = android.getJSONObject(\"GooglePlay\");\n\n\t\t\t\t\t\tif(googlePlay.has(\"RequiresGooglePlayServices\") == true)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tm_requiresGooglePlayServices = googlePlay.getBoolean(\"RequiresGooglePlayServices\");\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (Exception e)\n\t\t\t{\n\t\t\t\tLogging.logFatal(\"Could not load App.config!\");\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tLogging.logFatal(\"App.config does not exist!\");\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/Java/com/chilliworks/chillisource/core/BoxedPointer.java",
    "content": "/**\n * BoxedPointer.java\n * ChilliSource\n * Created by HMcLaughlin on 31/07/2015.\n *\n * The MIT License (MIT)\n *\n * Copyright (c) 2011 Tag Games Limited\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.core;\n\n/**\n * This can be used to wrap a c-pointer and type up in a java object.\n *\n * The BoxedPointer, native side, can be used to box (Wrap a c-pointer and type to java) and\n * Unbox (Unwrap the java object back to a c-pointer)\n *\n * @author HMcLaughlin\n */\npublic final class BoxedPointer\n{\n    final private long m_pointerAddress;\n    final private long m_typeHash;\n\n    /**\n     * Constructor\n     *\n     * @author HMcLaughlin\n     *\n     * @param in_pointerAddress\n     * @param in_typeHash\n     */\n    public BoxedPointer(long in_pointerAddress, long in_typeHash)\n    {\n        m_pointerAddress = in_pointerAddress;\n        m_typeHash = in_typeHash;\n    }\n    /**\n     * @author HMcLaughlin\n     *\n     * @return Pointer Address\n     */\n    public long getPointerAddress()\n    {\n        return m_pointerAddress;\n    }\n    /**\n     * @author HMcLaughlin\n     *\n     * @return Pointer type hash\n     */\n    public long getTypeHash()\n    {\n        return m_typeHash;\n    }\n}\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/Java/com/chilliworks/chillisource/core/CSActivity.java",
    "content": "/**\n * CSActivity.java\n * ChilliSource\n * Created by Ian Copland on 14/08/2012.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2012 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.core;\nimport android.app.Activity;\nimport android.content.Intent;\nimport android.content.res.Configuration;\nimport android.os.Bundle;\nimport android.view.Window;\nimport android.view.WindowManager;\n\nimport com.chilliworks.chillisource.input.DeviceButtonNativeInterface;\nimport com.chilliworks.chillisource.input.DeviceButtonNativeInterface.DeviceButton;\nimport com.chilliworks.chillisource.web.WebViewNativeInterface;\nimport com.google.android.gms.common.ConnectionResult;\nimport com.google.android.gms.common.GooglePlayServicesUtil;\n\n/**\n * The main activity for ChilliSource apps.\n * This feeds Android lifecycle events to the application\n *\n * @author Ian Copland\n */\npublic class CSActivity extends Activity \n{\n\tprivate static final int k_googlePlayServicesErrorDialogRequestCode = 7564568;\n\tprivate Surface m_surface;\n\tprivate AppConfig m_appConfig;\n\tprivate boolean m_initialised = false;\n\n\t/**\n\t * @author Ian Copland\n\t *\n\t * @return Activity surface\n\t */\n\tpublic Surface getSurface()\n\t{\n\t\treturn m_surface;\n\t}\n\t/**\n\t * Triggered when the activity is first created (i.e. on app launch).\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param in_savedInstanceState - Saved instance state (Not used)\n\t */\n    @Override public void onCreate(Bundle in_savedInstanceState)\n    {\t\n        super.onCreate(in_savedInstanceState);\n\n\t\t//go full screen!\n\t\trequestWindowFeature(Window.FEATURE_NO_TITLE);\n\t\tgetWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);\n\n\t\t//load the native libraries.\n\t\tNativeLibraryLoader.load(this);\n\n\t\tif (StartupActivityFactory.tryStartActivity(this) == false)\n\t\t{\n\t\t\tinit();\n\t\t}\n    }\n\t/**\n\t * Triggered when the activity becomes visible\n\t * \n\t * @author Ian Copland\n\t */\n    @Override protected void onResume() \n    {\n    \tsuper.onResume();\n\n        if (m_initialised == false)\n        {\n            if (StartupActivityFactory.tryStartActivity(this) == false)\n            {\n                init();\n            }\n        }\n\n        if (m_initialised == true)\n        {\n            m_surface.onResume();\n\n            CSApplication.get().resume();\n\n            if (m_appConfig.isGooglePlayServicesRequired() == true)\n            {\n                //We require Google Play Services so we need to check if they require installing\n                int gpsAvailableResult = GooglePlayServicesUtil.isGooglePlayServicesAvailable(CSApplication.get().getAppContext());\n\n                switch (gpsAvailableResult)\n                {\n                    case ConnectionResult.SUCCESS:\n                        break;\n                    case ConnectionResult.SERVICE_MISSING:\n                        //Kindle or unsupported device\n                        break;\n                    case ConnectionResult.SERVICE_DISABLED:\n                    case ConnectionResult.SERVICE_VERSION_UPDATE_REQUIRED:\n                        //Requires update\n                        GooglePlayServicesUtil.getErrorDialog(gpsAvailableResult, this, k_googlePlayServicesErrorDialogRequestCode).show();\n                        break;\n                }\n            }\n        }\n    }\n\t/**\n\t * Triggered when the window focus changes (i.e. the activity is no\n\t * longer the top of the view stack or becomes the top of the view stack).\n\t * The order of this in relation to resume and stop is not defined\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param in_hasFocus - Whether the window has focus or not\n\t */\n    @Override public void onWindowFocusChanged(boolean in_hasFocus)\n    {\n        if (m_initialised == true)\n        {\n            if (in_hasFocus == true)\n            {\n                super.onWindowFocusChanged(in_hasFocus);\n                CSApplication.get().foreground();\n            }\n            else\n            {\n                CSApplication.get().background();\n                super.onWindowFocusChanged(in_hasFocus);\n            }\n        }\n    }\n\t/**\n\t * Triggered when the activity is no longer wholly visible.\n\t * \n\t * @author Ian Copland\n\t */\n    @Override public void onPause() \n    {\n        if (m_initialised == true)\n        {\n            CSApplication.get().suspend();\n\n            m_surface.onPause();\n        }\n       \n        super.onPause();\n    }\n\t/**\n\t * Triggered when the activity is no longer visible.\n\t * \n\t * @author Ian Copland\n\t */\n    @Override public void onStop()\n    {\n\t    super.onStop();\n    }\n\t/**\n\t * Triggered when the activity is no active. This is the end of the app\n\t * \n\t * @author Ian Copland\n\t */\n    @Override public void onDestroy()\n    {\n        if (m_initialised == true)\n        {\n            CSApplication.get().destroy();\n        }\n\n\t    super.onDestroy();\n    }\n\t/**\n\t * Triggered when the activity receives a new intent either on launch\n\t * or by having it passed by another activity\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param in_intent - Intent\n\t */\n    @Override public void onNewIntent(Intent in_intent)\n    {\n    \tsetIntent(in_intent);\n\n        if (m_initialised == true)\n        {\n            CSApplication.get().activityIntent(in_intent);\n        }\n\n    \tsuper.onNewIntent(in_intent);\n    }\n\t/**\n\t * Triggered when the activity exits.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param in_requestCode - Request code that it started with\n\t * @param in_resultCode - Result code it returned\n\t * @param in_data - Any additional data returned\n\t */\n    @Override protected void onActivityResult(int in_requestCode, int in_resultCode, Intent in_data) \n    {\n        if (m_initialised == true)\n        {\n            if (in_requestCode != k_googlePlayServicesErrorDialogRequestCode)\n            {\n                CSApplication.get().activityResult(in_requestCode, in_resultCode, in_data);\n            }\n            else if (in_resultCode == RESULT_CANCELED)\n            {\n                //Terminate until downloaded\n                CSApplication.get().quit();\n            }\n        }\n    \tsuper.onActivityResult(in_requestCode, in_resultCode, in_data);\n\t}\n\t/**\n\t * Triggered when the activity config changes such as orientation,\n\t * hardware keyboards, etc.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param in_config - The new config\n\t */\n    @Override public void onConfigurationChanged(Configuration in_config) \n    {\n        if (m_initialised == true)\n        {\n            CSApplication.get().activityConfigurationChanged(in_config);\n        }\n\n    \tsuper.onConfigurationChanged(in_config);\n    }\n\t/**\n\t * Triggered when the activity receives an event from the hard-key back button.\n\t * This then forwards the event to the application\n\t * \n\t * @author Ian Copland\n\t */\n    @Override public void onBackPressed()\n    {\n        if (m_initialised == true)\n        {\n            DeviceButtonNativeInterface nativeInterface = (DeviceButtonNativeInterface) CSApplication.get().getSystem(DeviceButtonNativeInterface.INTERFACE_ID);\n            nativeInterface.onTriggered(DeviceButton.k_backButton);\n        }\n    }\n\t/**\n\t * Initialises the ChilliSource application and creates the OpenGL surface.\n\t *\n\t * @author Ian Copland\n\t */\n\tprivate void init()\n\t{\n        assert (m_initialised == false) : \"Cannot re-initialise CSActivity.\";\n\n\t\ttry\n\t\t{\n\t\t\tm_appConfig = new AppConfig(this);\n\n\t\t\tm_surface = new Surface(m_appConfig, this);\n\n\t\t\tCSApplication.create(this);\n\n\t\t\tCSApplication.get().activityIntent(getIntent());\n\n\t\t\t//initialise the old style native interfaces (These should be removed over time as each of these is changed over to the new system!)\n\t\t\tSharedPreferencesNativeInterface.Setup(this);\n\t\t\tWebViewNativeInterface.Setup(this);\n\t\t}\n\t\tcatch (Exception e)\n\t\t{\n            Logging.logError(\"Activity.init() has thrown an exception: \" + ExceptionUtils.convertToString(e));\n            Logging.logFatal(\"Could not initialise CSActivity.\");\n\t\t}\n\n        m_initialised = true;\n\t}\n}\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/Java/com/chilliworks/chillisource/core/CSApplication.java",
    "content": "/**\n * CSApplication.java\n * ChilliSource\n * Created by Scott Downie on 12/03/2014.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2014 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.core;\n\nimport java.util.ArrayList;\nimport java.util.ListIterator;\n\nimport android.app.Activity;\nimport android.content.Context;\nimport android.content.Intent;\nimport android.content.pm.ApplicationInfo;\nimport android.content.pm.PackageManager;\nimport android.content.res.Configuration;\nimport android.os.Bundle;\nimport android.view.View;\nimport android.widget.RelativeLayout;\n\n/**\n * Android application that mimics the ChilliSource application.\n * This holds all the Android systems and funnels the Android lifecycle\n * events\n * \n * @author S Downie\n */\npublic class CSApplication \n{\n\tenum LifecycleState\n\t{\n\t\tk_notInitialised,\n\t\tk_inactive,\n\t\tk_active,\n\t\tk_foreground\n\t}\n\t\n\tprivate static CSApplication m_singleton = null;\n\t\n\tprivate ArrayList<System> m_systems;\n\tprivate CSActivity m_activeActivity;\n\tprivate RelativeLayout m_rootViewContainer;\n\tprivate CoreNativeInterface m_coreSystem;\n\tprivate long m_milliSecsPerUpdate = 33;\n\tprivate long m_previousUpdateTime = 0;\n\tprivate long m_elapsedAppTime = 0;\n\tprivate boolean m_resetTimeSinceLastUpdate = false;\n\tprivate boolean m_isActive = false;\n    private boolean m_isForegrounded = false;\n\tprivate String m_packageName = \"\";\n\t\n\tprivate boolean m_initLifecycleEventOccurred = false;\n\tprivate boolean m_resumeLifecycleEventOccurred = false;\n\tprivate boolean m_foregroundLifecycleEventOccurred = false;\n\tprivate boolean m_backgroundLifecycleEventOccurred = false;\n\tprivate Intent m_receivedIntent = null;\n\t\n\tprivate LifecycleState m_currentAppLifecycleState = LifecycleState.k_notInitialised;\n\t\n\t/**\n\t * @author S Downie\n\t * \n\t * @return Singleton instance of the application. This is not lazily created\n\t * but is first created using by initialising the app\n\t */\n\tpublic static CSApplication get()\n\t{\n\t\treturn m_singleton;\n\t}\n\t/**\n\t * @author S Downie\n\t * \n\t * @return Whether the application has been initialised\n\t * or has been scheduled to do so\n\t */\n\tpublic boolean hasReceivedInit()\n\t{\n\t\treturn \tm_initLifecycleEventOccurred || (m_currentAppLifecycleState != LifecycleState.k_notInitialised);\n\t}\n\t/**\n\t * Triggered when the app is created\n\t * \n\t * @author S Downie\n\t * \n\t * @param in_activeActivity - ChilliSource activity\n\t */\n\tpublic static void create(CSActivity in_activeActivity)\n\t{\n\t\t//Cannot create app with a null activity\n\t\tassert in_activeActivity != null;\n\t\t\n\t\t//Cannot initApplication app more than once\n\t\tassert m_singleton == null;\n\t\t\n\t\tm_singleton = new CSApplication(in_activeActivity);\n\t}\n\t/**\n\t * Constructor. Private to enforce use of creation factory method\n\t * \n\t * @author S Downie\n\t * \n\t * @param in_activeActivity - ChilliSource activity\n\t */\n\tprivate CSApplication(CSActivity in_activeActivity)\n\t{\n\t\tm_activeActivity = in_activeActivity;\n\t\t\n\t\tm_systems = new ArrayList<System>();\n\t\t\n    \t//create the root view container that other Android UI is added to\n\t\t//and make it the root of the app activity\n\t\tm_rootViewContainer = new RelativeLayout(m_activeActivity);\n\t\tm_activeActivity.setContentView(m_rootViewContainer);\n\t\tm_rootViewContainer.addView(m_activeActivity.getSurface());\n\t\t\n\t\tm_currentAppLifecycleState = LifecycleState.k_notInitialised;\n\n\t\ttry\n\t\t{\n\t\t\tApplicationInfo ai = m_activeActivity.getPackageManager().getApplicationInfo(m_activeActivity.getPackageName(), PackageManager.GET_META_DATA);\n\t\t\tBundle bundle = ai.metaData;\n\t\t\tm_packageName = bundle.getString(\"packageName\");\n\t\t}\n\t\tcatch (Exception e)\n\t\t{\n\t\t\tLogging.logVerbose(ExceptionUtils.convertToString(e));\n\t\t\tLogging.logFatal(\"An exception was thrown while trying to read 'packageName' from AndroidManifest.xml: \" + e.getMessage());\n\t\t}\n\t}\n\t/**\n\t * Triggered when the app is launched\n\t * \n\t * @author S Downie\n\t */\n\tpublic void init()\n\t{\n\t\tm_initLifecycleEventOccurred = true;\n\t}\n\t/**\n\t * Triggered when the app is resumed after being invisible\n\t * \n\t * @author S Downie\n\t */\n\tpublic void resume()\n\t{\n\t\tm_isActive = true;\n\t\t\n\t\tm_resetTimeSinceLastUpdate = true;\n\t\tm_resumeLifecycleEventOccurred = true;\n\t\t\n\t\tsynchronized(m_systems)\n\t\t{\n\t\t\tfor (System system : m_systems)\n\t\t\t{\n\t\t\t\tsystem.onResume();\n\t\t\t}\n\t\t}\n\t}\n\t/**\n\t * Triggered when the app is resumed after being in the background\n\t * \n\t * @author S Downie\n\t */\n\tpublic void foreground()\n\t{\n        m_isForegrounded = true;\n\n\t\tm_foregroundLifecycleEventOccurred = true;\n\t\t\n\t\tsynchronized(m_systems)\n\t\t{\n\t\t\tfor (System system : m_systems)\n\t\t\t{\n\t\t\t\tsystem.onForeground();\n\t\t\t}\n\t\t}\n\t}\n\t/**\n\t * Triggered every frame when the app is active\n\t * \n\t * @author S Downie\n\t */\n\tpublic void update()\n\t{\n       \t//Ensure we are rendering at the required frame rate. This is achieved by checking\n    \t//how long a frame has taken and sleeping the app until the intended frame time \n    \t//has elapsed.\n    \ttry\n    \t{\n    \t\tlong currentTime = java.lang.System.currentTimeMillis();\n    \t\tlong elapsedTime = currentTime - m_previousUpdateTime;\n    \t\tif (elapsedTime < m_milliSecsPerUpdate)\n    \t\t{\n    \t\t\tThread.sleep(m_milliSecsPerUpdate - elapsedTime);\n    \t\t}\n    \t}\n    \tcatch(Exception e)\n    \t{\n    \t\te.printStackTrace();\n    \t}\n        \n    \t//if we are resuming, or this is the first frame then ensure the delta time will be 0.\n      \tif (m_resetTimeSinceLastUpdate  == true)\n        {\n      \t\tm_previousUpdateTime = java.lang.System.currentTimeMillis();\n      \t\tm_resetTimeSinceLastUpdate = false;\n        }\n    \t\n        //calculate delta time. Hopefully this will be kMillisecondsPerFrame in most \n    \t//circumstances.\n        long currentTime = java.lang.System.currentTimeMillis();\n    \tfloat deltaTime = ((float)(currentTime - m_previousUpdateTime)) * 0.001f;\n    \tm_elapsedAppTime += deltaTime;\n    \tm_previousUpdateTime = currentTime;\n    \t\n    \tprocessAppLifecycleEvents(deltaTime, m_elapsedAppTime);\n\t}\n\t/**\n\t * Application lifecycle events are deferred to the main thread and are\n\t * processed and notified from this method\n\t * \n\t * @author S Downie\n\t */\n\tprivate void processAppLifecycleEvents(float in_timeSinceLastUpdate, long in_appElapsedTime)\n\t{\n\t\tif(m_initLifecycleEventOccurred == true && m_currentAppLifecycleState == LifecycleState.k_notInitialised)\n\t\t{\n\t\t\tCoreNativeInterface.create();\n\t\t\tm_coreSystem = (CoreNativeInterface)getSystem(CoreNativeInterface.INTERFACE_ID);\n\t\t\tassert m_coreSystem != null;\n\t\t\tm_coreSystem.initApplication();\n\t\t\t\n\t\t\tm_initLifecycleEventOccurred = false;\n\t\t\tm_currentAppLifecycleState = LifecycleState.k_inactive;\n\t\t}\n\t\tif(m_resumeLifecycleEventOccurred == true && m_currentAppLifecycleState == LifecycleState.k_inactive)\n\t\t{\n\t\t\tm_coreSystem.resume();\n\t\t\tm_resumeLifecycleEventOccurred = false;\n\t\t\tm_currentAppLifecycleState = LifecycleState.k_active;\n\t\t}\n\t\tif(m_foregroundLifecycleEventOccurred == true && m_currentAppLifecycleState == LifecycleState.k_active)\n\t\t{\n\t\t\tm_coreSystem.foreground();\n\t\t\tm_foregroundLifecycleEventOccurred = false;\n\t\t\tm_currentAppLifecycleState = LifecycleState.k_foreground;\n\t\t}\n\t\tif(m_receivedIntent != null && m_currentAppLifecycleState == LifecycleState.k_foreground)\n\t\t{\n\t\t\tsynchronized(m_systems)\n\t\t\t{\n\t\t\t\tfor (System system : m_systems)\n\t\t\t\t{\n\t\t\t\t\tsystem.onLaunchIntentReceived(m_receivedIntent);\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tm_receivedIntent = null;\n\t\t}\n\t\t\n\t\tm_coreSystem.update(in_timeSinceLastUpdate, in_appElapsedTime);\n\t\t\n\t\tif(m_backgroundLifecycleEventOccurred == true && m_currentAppLifecycleState == LifecycleState.k_foreground)\n\t\t{\n\t\t\tm_coreSystem.background();\n\t\t\tm_backgroundLifecycleEventOccurred = false;\n\t\t\tm_currentAppLifecycleState = LifecycleState.k_active;\n\t\t}\n\t}\n\t/**\n\t * Triggered when the app is pushed back after being in the foreground\n\t * \n\t * @author S Downie\n\t */\n\tpublic void background()\n\t{\n\t\tif(m_currentAppLifecycleState == LifecycleState.k_foreground)\n\t\t{\n\t\t\tsynchronized(m_systems)\n\t\t\t{\n\t\t\t\tfor (ListIterator<System> iterator = m_systems.listIterator(m_systems.size()); iterator.hasPrevious();)\n\t\t\t\t{\n\t\t\t\t\tSystem system = iterator.previous();\n\t\t\t\t\tsystem.onBackground();\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tm_backgroundLifecycleEventOccurred = true;\n\t\t}\n\n        m_isForegrounded = false;\n\t}\n\t/**\n\t * Triggered when the app is no longer the active one\n\t * \n\t * @author S Downie\n\t */\n\tpublic void suspend()\n\t{\t\n\t\tfinal boolean shouldBackground = (m_currentAppLifecycleState == LifecycleState.k_foreground);\n\t\t\n\t\tif(shouldBackground == true)\n\t\t{\n\t\t\tsynchronized(m_systems)\n\t\t\t{\n\t\t\t\tfor (ListIterator<System> iterator = m_systems.listIterator(m_systems.size()); iterator.hasPrevious();)\n\t\t\t\t{\n\t\t\t\t\tSystem system = iterator.previous();\n\t\t\t\t\tsystem.onBackground();\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t//Often suspend is triggered by Android before background. So we handle backgrounding here and\n\t\t\t//prevent the regular backgrounding path from running.\n\t\t\tm_backgroundLifecycleEventOccurred = false;\n\t\t}\n\t\t\n\t\t//create the task to be run on the rendering thread\n\t\tRunnable task = new Runnable()\n\t\t{\n\t\t\t@Override public void run() \n\t\t\t{\n                if(shouldBackground)\n                {\n                    m_coreSystem.background();\n                    m_backgroundLifecycleEventOccurred = false;\n                    m_currentAppLifecycleState = LifecycleState.k_active;\n                }\n\n                m_coreSystem.suspend();\n                m_currentAppLifecycleState = LifecycleState.k_inactive;\n\n                synchronized(this)\n                {\n                    notifyAll();\n                }\n\t\t\t}\n\t\t};\n\t\t\n\t\t//run the task.\n\t\tm_activeActivity.getSurface().queueEvent(task);\n\t\t\n\t\t//wait for the task to finish before pausing the rendering thread.\n\t\ttry\n\t\t{\n\t\t\tsynchronized(task)\n\t\t\t{\n\t\t\t\ttask.wait();\n\t\t\t}\n\t\t}\n\t\tcatch (Exception e)\n\t\t{\n\t\t\tLogging.logError(e.getMessage());\n\t\t\te.printStackTrace();\n\t\t}\n\t\t\n\t\tsynchronized(m_systems)\n\t\t{\n\t\t\tfor (ListIterator<System> iterator = m_systems.listIterator(m_systems.size()); iterator.hasPrevious();)\n\t\t\t{\n\t\t\t\tSystem system = iterator.previous();\n\t\t\t\tsystem.onSuspend();\n\t\t\t}\n\t\t}\n\t\t\n\t\tm_isActive = false;\n\t}\n\t/**\n\t * Triggered when the app is terminated. This will destroyApplication the singleton application\n\t * \n\t * @author S Downie\n\t */\n\tpublic void destroy()\n\t{\n\t\t//Make sure the core system is handled first\n\t\tm_coreSystem.destroyApplication();\n\t\tm_currentAppLifecycleState = LifecycleState.k_notInitialised;\n\t\t\n\t\tsynchronized(m_systems)\n\t\t{\n\t\t\twhile (m_systems.size() > 0)\n\t\t\t{\n\t\t\t\tm_systems.get(m_systems.size() - 1).destroy();\n\t\t\t}\n\t\t}\n\t\t\n\t\tm_rootViewContainer = null;\n\t\tm_activeActivity = null;\n\t\tm_systems = null;\n\t\tm_receivedIntent = null;\n\t\tm_singleton = null;\n\t}\n\t/**\n\t * Triggered when the activity exits\n\t * \n\t * @author S Downie\n\t * \n\t * @param in_requestCode - Request code that it started with\n\t * @param in_resultCode - Result code it returned\n\t * @param in_data - Any additional data returned\n\t */\n\tpublic void activityResult(int in_requestCode, int in_resultCode, Intent in_data)\n\t{\n\t\tsynchronized(m_systems)\n\t\t{\n\t\t\tfor (System system : m_systems)\n\t\t\t{\n\t\t\t\tsystem.onActivityResult(in_requestCode, in_resultCode, in_data);\n\t\t\t}\n\t\t}\n\t}\n\t/**\n\t * Triggered when the activity config changes such as orientation,\n\t * hardware keyboards, etc.\n\t * \n\t * @author S Downie\n\t * \n\t * @param in_config- New config\n\t */\n    public void activityConfigurationChanged(Configuration in_config)\n    {\n\t\tsynchronized(m_systems)\n\t\t{\n\t\t\tfor (System system : m_systems)\n\t\t\t{\n\t\t\t\tsystem.onActivityConfigurationChanged(in_config);\n\t\t\t}\n\t\t}\n    }\n\t/**\n\t * Triggered when the activity receives an intent\n\t * \n\t * @author S Downie\n\t * \n\t * @param in_intent - Intent\n\t */\n\tpublic void activityIntent(Intent in_intent)\n\t{\n\t\tm_receivedIntent = in_intent;\n\t}\n\t/**\n\t * @author S Downie\n\t * \n\t * @param in_system - System\n\t */\n\tpublic void addSystem(final System in_system)\n\t{\n\t\tsynchronized(m_systems)\n\t\t{\n            assert (m_systems.contains(in_system) == false) : \"System already added to application!\";\n\t\t\tm_systems.add(in_system);\n\t\t}\n\n        scheduleUIThreadTask(new Runnable()\n        {\n            @Override public void run()\n            {\n                in_system.onInit();\n\n                if (m_isActive == true)\n                {\n                    in_system.onResume();\n\n                    if (m_isForegrounded == true)\n                    {\n                        in_system.onForeground();\n                    }\n                }\n            }\n        });\n\t}\n\t/**\n\t * @author S Downie\n\t * \n\t * @param in_interfaceId - Interface ID of system to find\n\t * \n\t * @return The first system that implements the given interface ID.\n\t */\n\tpublic System getSystem(InterfaceId in_interfaceId)\n\t{\n\t\tsynchronized(m_systems)\n\t\t{\n\t\t\tfor (System system : m_systems)\n\t\t\t{\n\t\t\t\tif (system.isA(in_interfaceId))\n\t\t\t\t{\n\t\t\t\t\treturn system;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\treturn null;\n\t}\n    /**\n     * Removes the system from the application.\n\t *\n\t * This is thread-safe, however calling this on a thread other than the UI thread will not\n\t * necessarily remove the system immediately.\n     *\n     * @author Ian Copland\n     *\n     * @param in_system - The system to remove.\n     */\n    public void removeSystem(final System in_system)\n    {\n        scheduleUIThreadTask(new Runnable()\n        {\n            @Override public void run()\n            {\n                if (m_isActive == true)\n                {\n                    if (m_isForegrounded == true)\n                    {\n                        in_system.onBackground();\n                    }\n\n                    in_system.onSuspend();\n                }\n\n                in_system.onDestroy();\n\n                synchronized(m_systems)\n                {\n                    assert (m_systems.contains(in_system) == false) : \"System doesn't exist in application!\";\n                    m_systems.remove(in_system);\n                }\n            }\n        });\n    }\n\t/**\n\t * @author S Downie\n\t * \n\t * @return Whether the application is \"active\" - i.e between the onResume() and onStop()\n\t * life cycle events.\n\t */\n\tpublic boolean isActive()\n\t{\n\t\treturn m_isActive;\n\t}\n\t/**\n\t * @author S Downie\n\t * \n\t * @return Android application context \n\t */\n\tpublic Context getAppContext()\n\t{\n\t\treturn m_activeActivity.getApplicationContext();\n\t}\n\t/**\n\t * We should look to ditch this function once we have established what \n\t * things should use appContext\n\t * \n\t * @author S Downie\n\t * \n\t * @return Android application context \n\t */\n\tpublic Context getActivityContext()\n\t{\n\t\treturn m_activeActivity;\n\t}\n\t/**\n\t * @author S Downie\n\t *\n\t * @return ChilliSource activity\n\t */\n\tpublic Activity getActivity()\n\t{\n\t\treturn m_activeActivity;\n\t}\n\t/**\n\t * @author Ian Copland\n\t *\n\t * @return The applicationId for the ChilliSource app. This will return the same value as\n\t * Activity.getPackageName().\n\t */\n\tpublic String getApplicationId()\n\t{\n\t\treturn m_activeActivity.getPackageName();\n\t}\n\t/**\n\t * @author Ian Copland\n\t *\n\t * @return The \"original\" packageName for the ChilliSource app, as specified in the\n\t * CSAndroidManifest.xml. This will potentiall differ from value that will be returned from\n\t * Activity.getPackageName().\n\t */\n\tpublic String getPackageName()\n\t{\n\t\treturn m_packageName;\n\t}\n\t/**\n\t * @author S Downie\n\t * \n\t * @param in_view - Android UI to add to app root view\n\t */\n\tpublic void addView(View in_view)\n\t{\n\t\tm_rootViewContainer.addView(in_view);\n\t}\n\t/**\n\t * @author S Downie\n\t * \n\t * @param in_view - Android UI to remove from app root view\n\t */\n\tpublic void removeView(View in_view)\n\t{\n\t\tm_rootViewContainer.removeView(in_view);\n\t}\n\t/**\n\t * @author S Downie\n\t * \n\t * @param in_maxFPS - Max update frequency in seconds\n\t */\n\tpublic void setPreferredFPS(int in_maxFPS)\n\t{\n\t\tm_milliSecsPerUpdate = (long) (1000.0f/(float)in_maxFPS);\n\t}\n\t/**\n\t * Schedule a task to run on the main update thread\n\t * \n\t * @author S Downie\n\t * \n\t * @param in_task - Task\n\t */\n\tpublic void scheduleMainThreadTask(Runnable in_task)\n\t{\n\t\tassert m_activeActivity != null;\n\t\t\n\t\tm_activeActivity.getSurface().queueEvent(in_task);\n\t}\n\t/**\n\t * Schedule a task to run on the UI thread\n\t * \n\t * @author S Downie\n\t * \n\t * @param in_task - Task\n\t */\n\tpublic void scheduleUIThreadTask(Runnable in_task)\n\t{\n\t\tassert m_activeActivity != null;\n\t\t\n\t\tm_activeActivity.runOnUiThread(in_task);\n\t}\n\t/**\n\t * Terminate the application\n\t * \n\t * @author S Downie\n\t */\n\tpublic void quit()\n\t{\n\t\tassert m_activeActivity != null;\n\t\t\n\t\tRunnable task = new Runnable()\n\t\t{\n\t\t\t@Override public void run()\n\t\t\t{\n\t\t\t\t//Stop the activity\n\t\t\t\tm_activeActivity.onPause();\n\t\t\t\tm_activeActivity.onStop();\n\t\t\t\tm_activeActivity.onDestroy();\n\t\t\t\tandroid.os.Process.killProcess(android.os.Process.myPid());\n\t\t\t\t\n\t\t\t\tnotifyAll();\n\t\t\t}\n\t\t};\n\n\t\tscheduleUIThreadTask(task);\n\t}\n}\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/Java/com/chilliworks/chillisource/core/ConfigChooser.java",
    "content": "/**\n * ConfigChooser.java\n * ChilliSource\n * Created by Ian Copland on 14/08/2012.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2012 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.core;\nimport javax.microedition.khronos.egl.EGL10;\nimport javax.microedition.khronos.egl.EGLConfig;\nimport javax.microedition.khronos.egl.EGLDisplay;\n\nimport android.opengl.GLSurfaceView;\n\n/**\n * A custom config builder for generating configs with a preferred depth size, but\n * able to fall back on a minimum.\n * \n * @author Ian Copland\n */\npublic final class ConfigChooser implements GLSurfaceView.EGLConfigChooser \n{\n    private static int EGL_OPENGL_ES2_BIT = 4;\n    private static int[] s_configAttribs2 =\n    {\n        EGL10.EGL_RED_SIZE, 4,\n        EGL10.EGL_GREEN_SIZE, 4,\n        EGL10.EGL_BLUE_SIZE, 4,\n        EGL10.EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,\n        EGL10.EGL_NONE\n    };\n\t\n    private int m_redSize;\n    private int m_greenSize;\n    private int m_blueSize;\n    private int m_alphaSize;\n    private int m_minDepthSize;\n    private int m_preferredDepthSize;\n    private int m_minStencilSize;\n    \n    /**\n     * Constructor.\n     * \n     * @author Ian Copland\n     * \n     * @param Size of the red channel.\n     * @param Size of the green channel.\n     * @param Size of the blue channel.\n     * @param Size of the alpha channel.\n     * @param Minimum depth buffer size.\n     * @param Preferred depth buffer size.\n     * @param The minimum stencil buffer size.\n     */\n    public ConfigChooser(int in_r, int in_g, int in_b, int in_a, int in_minDepth, int in_preferredDepth, int in_minStencil) \n    {\n        m_redSize = in_r;\n        m_greenSize = in_g;\n        m_blueSize = in_b;\n        m_alphaSize = in_a;\n        m_minDepthSize = in_minDepth;\n        m_preferredDepthSize = in_preferredDepth;\n        m_minStencilSize = in_minStencil;\n    }\n    /**\n     * Chooses the best config for the given parameters.\n     * \n     * @author Ian Copland\n     * \n     * @param The gl context.\n     * @param The display.\n     * \n     * @return The config.\n     */\n    public EGLConfig chooseConfig(EGL10 in_egl, EGLDisplay in_display) \n    {\n        //Get the number of minimally matching EGL configurations\n        int[] num_config = new int[1];\n        in_egl.eglChooseConfig(in_display, s_configAttribs2, null, 0, num_config);\n\n        int numConfigs = num_config[0];\n        if (numConfigs <= 0) \n        {\n            throw new IllegalArgumentException(\"No configs match configSpec\");\n        }\n\n        //Allocate then read the array of minimally matching EGL configs\n        EGLConfig[] configs = new EGLConfig[numConfigs];\n        in_egl.eglChooseConfig(in_display, s_configAttribs2, configs, numConfigs, num_config);\n\n        //Now return the \"best\" one\n        return chooseConfig(in_egl, in_display, configs);\n    }\n    /**\n     * Chooses the best config for the given parameters.\n     * \n     * @author Ian Copland\n     * \n     * @param The gl context\n     * @param The display\n     * @param The list of poddible configs.\n     * @param Whether or not to only look for preferred depth sizes.\n     * \n     * @return The config.\n     */\n    private EGLConfig chooseConfig(EGL10 in_egl, EGLDisplay in_display, EGLConfig[] in_configs) \n    {\n    \tint depthSize = m_preferredDepthSize;\n    \twhile (depthSize >= m_minDepthSize)\n    \t{\n\t        for(EGLConfig config : in_configs) \n\t        {\n\t            int d = findConfigAttrib(in_egl, in_display, config, EGL10.EGL_DEPTH_SIZE, 0);\n\t            int s = findConfigAttrib(in_egl, in_display, config, EGL10.EGL_STENCIL_SIZE, 0);\n\t\n\t            // We need at least mDepthSize and mStencilSize bits\n\t            if (d >= depthSize && s >= m_minStencilSize)\n\t            {\n\t            \t// We want an *exact* match for red/green/blue/alpha\n\t\t            int r = findConfigAttrib(in_egl, in_display, config, EGL10.EGL_RED_SIZE, 0);\n\t\t            int g = findConfigAttrib(in_egl, in_display, config, EGL10.EGL_GREEN_SIZE, 0);\n\t\t            int b = findConfigAttrib(in_egl, in_display, config, EGL10.EGL_BLUE_SIZE, 0);\n\t\t            int a = findConfigAttrib(in_egl, in_display, config, EGL10.EGL_ALPHA_SIZE, 0);\n\t\t\n\t\t            if (r == m_redSize && g == m_greenSize && b == m_blueSize && a == m_alphaSize)\n\t\t            {\n\t\t                return config;\n\t\t            }\n\t            }\n\t        }\n\t        \n\t        depthSize -= 8;\n    \t}\n        return null;\n    }\n    /**\n     * Get the value for a single attribute within the config.\n     * \n     * @author Ian Copland\n     * \n     * @param The gl context\n     * @param The display\n     * @param The config.\n     * @param The attribute.\n     * @param The default value.\n     * \n     * @return The value.\n     */\n    private int findConfigAttrib(EGL10 in_egl, EGLDisplay in_display, EGLConfig in_config, int in_attribute, int in_defaultValue) \n    {\n    \tint[] value = new int[1];\n        if (in_egl.eglGetConfigAttrib(in_display, in_config, in_attribute, value) == true) \n        {\n            return value[0];\n        }\n        \n        return in_defaultValue;\n    }\n}\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/Java/com/chilliworks/chillisource/core/ContextFactory.java",
    "content": "/**\n * ContextFactory.java\n * ChilliSource\n * Created by Ian Copland on 14/08/2012.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2012 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.core;\nimport javax.microedition.khronos.egl.EGL10;\nimport javax.microedition.khronos.egl.EGLConfig;\nimport javax.microedition.khronos.egl.EGLContext;\nimport javax.microedition.khronos.egl.EGLDisplay;\n\nimport android.opengl.GLSurfaceView;\n\nclass ContextFactory implements GLSurfaceView.EGLContextFactory\n{\n\tprivate static int EGL_CONTEXT_CLIENT_VERSION = 0x3098;\n\t\n\tpublic EGLContext createContext(EGL10 inEgl, EGLDisplay inDisplay, EGLConfig inEglConfig) \n    {\n        int[] adwAttribArray = \n        {\n    \t\tEGL_CONTEXT_CLIENT_VERSION, \n    \t\t2, \n    \t\tEGL10.EGL_NONE \n        };      \n        EGLContext context = inEgl.eglCreateContext(inDisplay, inEglConfig, EGL10.EGL_NO_CONTEXT, adwAttribArray);\n        return context;\n    }\n\n    public void destroyContext(EGL10 inEgl, EGLDisplay inDisplay, EGLContext inContext) \n    {\n        inEgl.eglDestroyContext(inDisplay, inContext);\n    }\n}\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/Java/com/chilliworks/chillisource/core/CoreNativeInterface.java",
    "content": "/**\n * CoreNativeInterface.java\n * ChilliSource\n * Created by Ian Copland on 09/08/2012.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2012 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.core;\n\nimport android.app.Activity;\nimport android.content.pm.PackageInfo;\nimport android.content.pm.PackageManager;\nimport android.content.pm.PackageManager.NameNotFoundException;\nimport android.util.DisplayMetrics;\n\n/**\n* Native interface for communicating core os features to native.\n* Also responsible for funneling lifecycle events to application\n* \n* @author Ian Copland\n*/\npublic class CoreNativeInterface extends System\n{\n\tpublic static InterfaceId INTERFACE_ID = new InterfaceId();\n\n\tprivate PackageInfo m_packageInfo;\n\n\t/**\n\t * Force the native interface to create this system\n\t * \n\t * @author S Downie\n\t */\n\tpublic static native void create();\n\t/**\n\t * Triggered when the application is launched\n\t * This doesn't override from System in\n\t * order to ensure that core is called after all other interfaces\n\t * \n\t * @author S Downie\n\t */\n\tpublic native void initApplication();\n\t/**\n\t * Triggered when the application is resumed after launch or suspension.\n\t * This doesn't override from System in\n\t * order to ensure that core is called before all other interfaces\n\t * \n\t * @author S Downie\n\t */\n\tpublic native void resume();\n\t/**\n\t * Triggered when the application is brought\n\t * to the foreground after being in the background.\n\t * This doesn't override from System in\n\t * order to ensure that core is called before all other interfaces\n\t * \n\t * @author S Downie\n\t */\n\tpublic native void foreground();\n\t/**\n\t * Updates the native application\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param Time in seconds since last update\n\t * @param Total elapsed time of app\n\t */\n\tpublic native void update(float in_timeSinceLastUpdate, long in_appElapsedTime);\n\t/**\n\t * Triggered when the application is sent\n\t * to the background after being in the foreground\n\t * This doesn't override from System in\n\t * order to ensure that core is called after all other interfaces\n\t * \n\t * @author S Downie\n\t */\n\tpublic native void background();\n\t/**\n\t * Triggered when the application is suspended\n\t * This doesn't override from System in\n\t * order to ensure that core is called after all other interfaces\n\t * \n\t * @author S Downie\n\t */\n\tpublic native void suspend();\n\t/**\n\t * Triggered when the application is terminated\n\t * This doesn't override from System in\n\t * order to ensure that core is called after all other interfaces\n\t * \n\t * @author S Downie\n\t */\n\tpublic native void destroyApplication();\n\t/**\n\t * Triggered when the app is low on memory to tell native\n\t * to clean itself up\n\t * \n\t * @author Ian Copland\n\t */\n\tpublic native void memoryWarning();\n\t/**\n\t * Triggered when the screen resolution changes\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param The new width.\n\t * @param The new height.\n\t */\n\tpublic native void onResolutionChanged(int in_width, int in_height);\n\t/**\n\t * Constructor\n\t * \n\t * @author Ian Copland\n\t */\n\tpublic CoreNativeInterface() throws NameNotFoundException\n\t{\n        init();\n\t\tm_packageInfo = CSApplication.get().getAppContext().getPackageManager().getPackageInfo(CSApplication.get().getActivityContext().getPackageName(), PackageManager.GET_ACTIVITIES);\n\t}\n    /**\n     * Allows querying of whether or not the system implements the interface described by the\n     * given interface id.\n     *\n     * @author Ian Copland\n     *\n     * @param in_interfaceId - The interface id to check\n     *\n     * @return Whether the system implements the given interface\n     */\n    @Override public boolean isA(InterfaceId in_interfaceId)\n    {\n        return (in_interfaceId == INTERFACE_ID);\n    }\n\t/**\n\t * @author Ian Copland\n\t * \n\t * @return The activity.\n\t */\n\tpublic Activity getActivity()\n\t{\n\t\treturn CSApplication.get().getActivity();\n\t}\n\t/**\n\t * @author Ian Copland\n\t * \n\t * @return Path to external storage\n\t */\n\tpublic String getExternalStorageDirectory()\n\t{\n\t\treturn FileUtils.getExternalStorageDirectory();\n\t}\n\t/**\n\t * @author Ian Copland\n\t * \n\t * @return Application name as specified by the project\n\t */\n\tpublic String getApplicationName()\n\t{\n\t\tif (m_packageInfo.applicationInfo != null)\n\t\t{\n\t\t\treturn CSApplication.get().getActivityContext().getPackageManager().getApplicationLabel(m_packageInfo.applicationInfo).toString();\n\t\t}\n\t\telse\n\t\t{\n\t\t\treturn \"ApplicationInfoWrong\";\n\t\t}\n\t}\n\t/**\n\t * @author Ian Copland\n\t * \n\t * @return Application version code as specified by the manifest\n\t */\n\tpublic int getApplicationVersionCode()\n\t{\n\t\ttry \n\t\t{\n\t\t\treturn CSApplication.get().getActivityContext().getPackageManager().getPackageInfo(CSApplication.get().getActivityContext().getPackageName(), 0).versionCode;\n\t\t} \n\t\tcatch (NameNotFoundException e) \n\t\t{\n\t\t\treturn 0;\n\t\t}\n\t}\n\t/**\n\t * @author Ian Copland\n\t * \n\t * @return Application version name as specified by the manifest\n\t */\n\tpublic String getApplicationVersionName()\n\t{\n\t\ttry \n\t\t{\n\t\t\treturn CSApplication.get().getActivityContext().getPackageManager().getPackageInfo(CSApplication.get().getActivityContext().getPackageName(), 0).versionName;\n\t\t} \n\t\tcatch (NameNotFoundException e) \n\t\t{\n\t\t\treturn \"\";\n\t\t}\n\t}\n\t/**\n\t * @author Ian Copland\n\t * \n\t * @return Application package name\n\t */\n\tpublic String getPackageName()\n\t{\n\t\treturn CSApplication.get().getActivityContext().getPackageName();\n\t}\n\t/**\n\t * @author Ian Copland\n\t * \n\t * @return Path to APK directory\n\t */\n\tpublic String getAPKDirectory()\n\t{\n\t\treturn m_packageInfo.applicationInfo.sourceDir;\n\t}\n\t/**\n\t * @author Ian Copland\n\t * \n\t * @return Screen width in pixels\n\t */\n\t@SuppressWarnings(\"deprecation\")\n\tpublic int getScreenWidth()\n\t{\n\t\treturn CSApplication.get().getActivity().getWindowManager().getDefaultDisplay().getWidth();\n\t}\n\t/**\n\t * @author Ian Copland\n\t * \n\t * @return Screen height in pixels\n\t */\n\t@SuppressWarnings(\"deprecation\")\n\tpublic int getScreenHeight()\n\t{\n\t\treturn CSApplication.get().getActivity().getWindowManager().getDefaultDisplay().getHeight();\n\t}\n\t/**\n\t * @author Ian Copland\n\t * \n\t * @return Density of screen in dpi\n\t */\n\tpublic float getScreenDensity()\n\t{\n\t\tDisplayMetrics metrics = new DisplayMetrics();\n\t\tCSApplication.get().getActivity().getWindowManager().getDefaultDisplay().getMetrics(metrics);\n\t\treturn metrics.density;\n\t}\n\t/**\n\t * @author S Downie\n\t * \n\t * @param Max FPS to limit device to\n\t */\n\tpublic void setPreferredFPS(int in_maxFPS)\n\t{\n\t\tCSApplication.get().setPreferredFPS(in_maxFPS);\n\t}\n\t/**\n\t * Terminate the activity and the app\n\t * \n\t * @author Ian Copland\n\t */\n    public void forceQuit()\n    {\n    \tCSApplication.get().quit();\n    }\n}\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/Java/com/chilliworks/chillisource/core/DeviceNativeInterface.java",
    "content": "/**\n * DeviceNativeInterface.java\n * ChilliSource\n * Created by Scott Downie on 24/09/2014.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2014 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.core;\n\nimport java.io.IOException;\nimport java.util.Locale;\nimport java.util.UUID;\n\nimport android.content.Context;\nimport android.net.wifi.WifiManager;\nimport android.os.Build;\nimport android.provider.Settings;\nimport android.telephony.TelephonyManager;\n\nimport com.google.android.gms.ads.identifier.AdvertisingIdClient;\nimport com.google.android.gms.common.ConnectionResult;\nimport com.google.android.gms.common.GooglePlayServicesNotAvailableException;\nimport com.google.android.gms.common.GooglePlayServicesRepairableException;\nimport com.google.android.gms.common.GoogleApiAvailability;\n\n/**\n * Holds functions to query information about the device.\n * \n * @author S Downie\n */\npublic final class DeviceNativeInterface extends System\n{\n    public static InterfaceId INTERFACE_ID = new InterfaceId();\n\n\tprivate static final String k_preferencesKey = \"CSPreferences\";\n\tprivate static final String k_udidKey = \"UDID\";\n\n    /**\n     * Constructor.\n     *\n     * @author Ian Copland\n     */\n    public DeviceNativeInterface()\n    {\n        init();\n    }\n    /**\n     * Allows querying of whether or not the system implements the interface described by the\n     * given interface id.\n     *\n     * @author Ian Copland\n     *\n     * @param in_interfaceId - The interface id to check\n     *\n     * @return Whether the system implements the given interface\n     */\n    @Override public boolean isA(InterfaceId in_interfaceId)\n    {\n        return (in_interfaceId == INTERFACE_ID);\n    }\n\t/**\n\t * @author Ian Copland\n\t * \n\t * @return Mode of device as a string\n\t */\n\tpublic String getDeviceModel()\n\t{\n\t\treturn Build.MODEL.toString();\n\t}\n\t/**\n\t * @author Ian Copland\n\t * \n\t * @return Manufacturer of device as a string\n\t */\n\tpublic String getDeviceManufacturer()\n\t{\n\t\treturn Build.MANUFACTURER.toString();\n\t}\n\t/**\n\t * @author Ian Copland\n\t * \n\t * @return Type of device as a string\n\t */\n\tpublic String getDeviceModelType()\n\t{\n\t\treturn Build.DEVICE.toString();\n\t}\n\t/**\n\t * @author Ian Copland\n\t * \n\t * @return OS version as number\n\t */\n\tpublic int getOSVersion()\n\t{\n\t\treturn Build.VERSION.SDK_INT;\n\t}\n\t/**\n\t * @author Ian Copland\n\t * \n\t * @return Num of CPU cores available\n\t */\n\tpublic int getNumberOfCores()\n\t{\n\t\treturn Runtime.getRuntime().availableProcessors();\n\t}\n\t/**\n\t * @author Ian Copland\n\t * \n\t * @return Locale code of device as a string\n\t */\n\tpublic String getDefaultLocaleCode()\n\t{\n\t\treturn Locale.getDefault().toString();\n\t}\n\t/**\n\t * Returns the UDID of this device if it can be obtained, otherwise returns an empty string\n\t * \n\t * @author S Downie\n\t *\n\t * @return UDID string\n\t */\n\tpublic String getUniqueId()\n\t{\n\t\t//--try the recommended Google advertising id\n\t\t\n\t\t//Google policy is that if the advertising id is available but the user has chosen not to\n\t\t//enable it then we cannot track the user by falling back on these other methods.\n        int gpsAvailableResult = GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(CSApplication.get().getAppContext());\n\t\t\n\t\t//If GPS is not potentially available i.e. Kindle etc then we can default to the older id types\n\t\t//If GPS is potentially available but the user has chosen not to install/update then we cannot fallback on\n\t\t//the older id types\n\n\t\tswitch(gpsAvailableResult)\n\t\t{\n\t\tcase ConnectionResult.SUCCESS:\n\t\t\tAdvertisingIdClient.Info advertisingIdInfo = getAdvertisingIdInfo();\n\t\t\t\n\t\t\tif(advertisingIdInfo.isLimitAdTrackingEnabled() == true)\n\t\t\t{\n\t\t\t\t//User has disabled the use of tracking\n\t\t\t\treturn \"\";\n\t\t\t}\n\n\t\t\tString advertisingId = advertisingIdInfo.getId();\n\t\t\tif(advertisingId.equals(\"\") == false)\n\t\t\t{\n\t\t\t\t//We cannot save this as the user is entitled to reset it\n\t\t\t\treturn advertisingId;\n\t\t\t}\n\t\t\t\n\t\t\tbreak;\n\t\tcase ConnectionResult.SERVICE_MISSING:\n\t\t\t//Fallback on other methods\n\t\t\tbreak;\n\t\tcase ConnectionResult.SERVICE_DISABLED:\n\t\tcase ConnectionResult.SERVICE_VERSION_UPDATE_REQUIRED:\n\t\tcase ConnectionResult.SERVICE_INVALID:\n\t\t\t//Cannot fallback\n\t\t\treturn \"\";\n\t\t}\n\t\t\n\t\t//Check and see if we have any other form of id stored\n\t\tString existingId = SharedPreferencesNativeInterface.GetString(k_preferencesKey, k_udidKey, \"\");\n\t\tif(existingId.equals(\"\") == false)\n\t\t{\n\t\t\treturn existingId;\n\t\t}\n\n\t\t//--try the mac address\n\t\tString macAddress = getMacAddress();\n\t\tif (macAddress.equals(\"\") == false)\n\t\t{\n\t\t\tmacAddress = HashMD5.generateHex(StringUtils.stringToUTF8Bytes(macAddress));\n\t\t\tSharedPreferencesNativeInterface.SetString(k_preferencesKey, k_udidKey, macAddress);\n\t\t\treturn macAddress;\n\t\t}\n\n\t\t//--try the Android ID\n\t\tString androidId = getAndroidID();\n\t\tif (androidId.equals(\"\") == false)\n\t\t{\n\t\t\tandroidId = HashMD5.generateHex(StringUtils.stringToUTF8Bytes(androidId));\n\t\t\tSharedPreferencesNativeInterface.SetString(k_preferencesKey, k_udidKey, androidId);\n\t\t\treturn androidId;\n\t\t}\n\n\t\t//--try the ID from the telephony manager\n\t\tString telephonyId = getTelephonyDeviceID();\n\t\tif (telephonyId.equals(\"\") == false)\n\t\t{\n\t\t\ttelephonyId = HashMD5.generateHex(StringUtils.stringToUTF8Bytes(telephonyId));\n\t\t\tSharedPreferencesNativeInterface.SetString(k_preferencesKey, k_udidKey, telephonyId);\n\t\t\treturn telephonyId;\n\t\t}\n\n\t\t//--if all this fails, fall back on generating a random hash.\n\t\tString randomId = HashMD5.generateHex(StringUtils.stringToUTF8Bytes(UUID.randomUUID().toString()));\n\t\tSharedPreferencesNativeInterface.SetString(k_preferencesKey, k_udidKey, randomId);\n\t\treturn randomId;\n\t}\n\t/**\n\t * Method that returns the Device ID\n\t * That can be acquired from TelephonyManager.getDeviceId().\n\t * This id is not accessable if the device does not contain a\n\t * sim card, or if the sim is unavailable (flight mode). If the \n\t * id is not accessable an empty string will be returned. This\n\t * Should not change on factory reset of a device, but it may\n\t * change if the sim card is changed.\n\t * \n\t * @author Ian Copland\n\t *\n\t * @return the telephony device ID or an empty string.\n\t*/\n\tprivate String getTelephonyDeviceID()\n\t{\n\t\tTelephonyManager phoneManager = (TelephonyManager) CSApplication.get().getActivityContext().getSystemService(Context.TELEPHONY_SERVICE);\n\t\tString strId = phoneManager.getDeviceId();\n\t\t\n\t\tif (strId == null)\n\t\t\treturn \"\";\n\t\treturn strId;\n\t}\n\t/**\n\t * Returns the mac address of the device. This may not be available\n\t * on some devices while wifi is turned off. This should not change\n\t * on factory reset of a device.\n\t * \n\t * @author Ian Copland\n\t *\n\t * @return mac address or an empty string.\n\t*/\n\tprivate String getMacAddress()\n\t{\n\t\tWifiManager wifiManager = (WifiManager)CSApplication.get().getActivityContext().getSystemService(Context.WIFI_SERVICE);\n\t\tString strMacAddress = wifiManager.getConnectionInfo().getMacAddress();\n\t\t\n\t\tif (strMacAddress == null)\n\t\t\treturn \"\";\n\t\treturn strMacAddress;\n\t}\n\t/**\n\t * Returns the android ID for this device. This should be unique\n\t * however a bug in 2.2 has lead to a large amount of devices\n\t * on 2.2 sharing the same ID (9774d56d682e549c). This ID is \n\t * checked for and, if found, is discarded. If the id is\n\t * unavailable or the duplicate ID is found, an empty string\n\t * will be returned. This value may change if the device is\n\t * factory reset.\n\t *\n\t * @author Ian Copland\n\t *\n\t * @return the unique Android ID or an empty string.\n\t*/\n\tprivate String getAndroidID()\n\t{\n\t\tString strID = Settings.Secure.getString(CSApplication.get().getActivityContext().getContentResolver(), Settings.Secure.ANDROID_ID);\n\t\t\n\t\tif (strID == null || strID.equalsIgnoreCase(\"9774d56d682e549c\"))\n\t\t\treturn \"\";\n\n\t\treturn strID;\n\t}\n\t/**\n\t * Google terms now state that the advertising id should be used in place of any other forms of id tracking (where available).\n\t * The advertising id can be enabled/disabled/reset by the user and therefore is not guaranteed. Retrieval of the id is dependent\n\t * on a certain version of the Google Play Store being installed (which means this id is Google only not Kindle).\n\t * \n\t * If the version of the Play Store is not high enough then calling this method will fail. This method relies on the fact that\n\t * the user has already been prompted to update to the latest Google Play Store.\n\t * \n\t * NOTE: This method must not be called on the Android UI thread.\n\t * \n\t * @author S Downie\n\t * \n\t * @return Object containing Id and whether we are allowed to use it (NOTE: This can be null)\n\t */\n\tprivate AdvertisingIdClient.Info getAdvertisingIdInfo()\n\t{\n\t\ttry \n\t\t{\n\t\t\treturn AdvertisingIdClient.getAdvertisingIdInfo(CSApplication.get().getAppContext());\n\t\t} \n\t\tcatch (IllegalStateException e) \n\t\t{\n\t\t\t\n\t\t} \n\t\tcatch (GooglePlayServicesRepairableException e) \n\t\t{\n\n\t\t} \n\t\tcatch (IOException e) \n\t\t{\n\n\t\t} \n\t\tcatch (GooglePlayServicesNotAvailableException e) \n\t\t{\n\n\t\t}\n\t\t\n\t\treturn null;\n\t}\n}\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/Java/com/chilliworks/chillisource/core/DialogueBoxNativeInterface.java",
    "content": "/**\n * DialogueBoxNativeInterface.java\n * ChilliSource\n * Created by Ian Copland on 06/03/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.core;\n\nimport android.app.AlertDialog;\nimport android.content.DialogInterface;\nimport android.widget.Toast;\n\n/**\n * A native interface for communication with native in reference\n * to system dialogue box functionality.\n */\npublic class DialogueBoxNativeInterface extends System\n{\n    public static InterfaceId INTERFACE_ID = new InterfaceId();\n\n    /**\n\t * Constructor\n\t *\n\t * @author Ian Copland\n\t */\n\tpublic DialogueBoxNativeInterface()\n\t{\n        init();\n\t}\n    /**\n     * Allows querying of whether or not the system implements the interface described by the\n     * given interface id.\n     *\n     * @author Ian Copland\n     *\n     * @param in_interfaceId - The interface id to check\n     *\n     * @return Whether the system implements the given interface\n     */\n    @Override public boolean isA(InterfaceId in_interfaceId)\n    {\n        return (in_interfaceId == INTERFACE_ID);\n    }\n\t/**\n\t * Display a toast notification with the given text\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param The text to display.\n\t */\n    public void makeToast(final String in_text)\n    {\n    \tCSApplication.get().scheduleUIThreadTask(new Runnable() \n        {\n\t\t    public void run() \n\t\t    {\n                Toast.makeText(CSApplication.get().getAppContext(), in_text, Toast.LENGTH_LONG).show();\n\t\t    }\n\t\t});\n    }\n    /**\n     * Display the systems confirmation dialog.\n     * \n     * @author Ian Copland\n     * \n     * @param ID that is returned in pressed delegate \n     * @param Title text\n     * @param Message text\n     * @param Confirm text\n     * @param Cancel text\n     */\n    public void showSystemConfirmDialogue(final int in_dialogID, final String in_title, final String in_message, final String in_confirm, final String in_cancel)\t\t\n    {\n    \tfinal DialogueBoxNativeInterface dialogueBoxNativeInterface = this;\n    \tCSApplication.get().scheduleUIThreadTask(new Runnable() \n        {\n        \tpublic void run()\n        \t{\n        \t\tnew AlertDialog.Builder(CSApplication.get().getActivityContext())\n        \t\t.setIcon(android.R.drawable.ic_dialog_alert)\n        \t\t.setTitle(in_title)\n        \t\t.setMessage(in_message)\n        \t\t.setPositiveButton(in_confirm, new DialogInterface.OnClickListener() \n        \t\t{\n        \t\t\t@Override public void onClick(DialogInterface dialog, int which) \n        \t\t\t{\n        \t\t\t\tdialogueBoxNativeInterface.onDialogueConfirmPressed(in_dialogID);\n        \t\t\t}\n        \t\t})\n        \t\t.setNegativeButton(in_cancel,new DialogInterface.OnClickListener() \n        \t\t{\n        \t\t\t@Override public void onClick(DialogInterface dialog, int which) \n        \t\t\t{\n        \t\t\t\tdialogueBoxNativeInterface.onDialogueCancelPressed(in_dialogID);\n        \t\t\t}\n        \t\t})\n        \t\t.show();\n        \t}\n        });\n    }\n    /**\n     * Display the systems dialog \n     * \n     * @author Ian Copland\n     * \n     * @param ID that is returned in pressed delegate \n     * @param Title text\n     * @param Message text\n     * @param Confirm text\n     */\n    public void showSystemDialogue(final int in_dialogID, final String in_title, final String in_message, final String in_confirm)\t\t\n    {\n    \tfinal DialogueBoxNativeInterface dialogueBoxNativeInterface = this;\n    \tCSApplication.get().scheduleUIThreadTask(new Runnable() \n        {\n        \tpublic void run()\n        \t{\n        \t\tnew AlertDialog.Builder(CSApplication.get().getActivityContext())\n        \t\t.setIcon(android.R.drawable.ic_dialog_alert)\n        \t\t.setTitle(in_title)\n        \t\t.setMessage(in_message)\n        \t\t.setPositiveButton(in_confirm, new DialogInterface.OnClickListener() \n        \t\t{\n        \t\t\t@Override public void onClick(DialogInterface dialog, int which) \n        \t\t\t{\n        \t\t\t\tdialogueBoxNativeInterface.onDialogueConfirmPressed(in_dialogID);\n        \t\t\t}\n        \t\t})\n        \t\t.show();\n        \t}\n        });\n    }\n\t/**\n\t * Calls back down to native on a dialog confirm button\n\t * press.\n\t * \n\t * @author Ian Copland \n\t * \n\t * @param The ID of the dialogue box.\n\t */\n\tprivate native void onDialogueConfirmPressed(int in_id);\n\t/**\n\t * Calls back down to native on a dialogue cancel button\n\t * press.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param The ID of the dialogue box.\n\t */\n\tprivate native void onDialogueCancelPressed(int in_id);\n}\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/Java/com/chilliworks/chillisource/core/DynamicByteBuffer.java",
    "content": "/**\n * DynamicByteBuffer.java\n * ChilliSource\n * Created by Ian Copland on 01/01/2013\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.core;\n\nimport java.util.Arrays;\n\n/**\n * A byte array buffer that will resize when it no longer has space to add\n * more data.\n * \n * @author Ian Copland\n *\n */\npublic class DynamicByteBuffer \n{\n\tprivate byte[] m_data;\n\tprivate int m_size;\n\tprivate int m_capacity;\n\t/**\n\t * Constructor\n\t * \n\t * @author Ian Copland\n\t */\n\tpublic DynamicByteBuffer()\n\t{\n\t\tm_capacity = 1;\n\t\tm_data = new byte[m_capacity];\n\t\tm_size = 0;\n\t}\n\t/**\n\t * Constructor\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param the default capacity for the buffer.\n\t */\n\tpublic DynamicByteBuffer(int in_defaultCapacity)\n\t{\n\t\tm_capacity = in_defaultCapacity;\n\t\tm_data = new byte[m_capacity];\n\t\tm_size = 0;\n\t}\n\t/**\n\t * @author Ian Copland\n\t * \n\t * @return The internal byte array buffer. Note that this will contain\n\t * additional data beyond the end of the added bytes. Use getSize() to\n\t * get the number of bytes added.\n\t */\n\tpublic byte[] toByteArray()\n\t{\n\t\treturn Arrays.copyOfRange(m_data, 0, m_size);\n\t}\n\t/**\n\t * @author Ian Copland\n\t * \n\t * @return The internal byte array buffer. Note that this will contain\n\t * additional data beyond the end of the added bytes. Use getSize() to\n\t * get the number of bytes added.\n\t */\n\tpublic byte[] getInternalBuffer()\n\t{\n\t\treturn m_data;\n\t}\n\t/**\n\t * @author Ian Copland\n\t * \n\t * @return The number of bytes added to the buffer.\n\t */\n\tpublic int getByteCount()\n\t{\n\t\treturn m_size;\n\t}\n\t/**\n\t * Add new bytes to the the buffer. If this has gone over the internal buffer\n\t * size it will be resized to fit the new data.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param The data.\n\t * @param The data count.\n\t */\n\tpublic void appendBytes(byte[] in_data, int in_count)\n\t{\n\t\tif (in_data != null)\n\t\t{\n\t\t\tcheckCapacity(in_count);\n\t\t\n\t\t\tfor (int i = 0; i < in_count; i++)\n\t\t\t{\n\t\t\t\tm_data[m_size + i] = in_data[i];\n\t\t\t}\n\t\t\t\n\t\t\tm_size += in_count;\n\t\t}\n\t}\n\t/**\n\t * Clears the current buffer so that its size is zero\n\t * \n\t * @author S Downie\n\t */\n\tpublic void clear()\n\t{\n\t\tm_size = 0;\n\t\tm_capacity = 1;\n\n\t\tm_data = new byte[m_capacity];\n\t}\n\t/**\n\t * This makes sure the capacity is always big enough to fit any new data \n\t * being added. Any time the size will not be enough this will simply \n\t * double the size.\n\t * \n\t * @param The additional data size.\n\t */\n\tprivate void checkCapacity(int in_additionalCount)\n\t{\n\t\tint requiredCapacity = m_size + in_additionalCount;\n\n\t\t//if its not big enough, then make sure it is.\n\t\tif (requiredCapacity > m_capacity)\n\t\t{\n\t\t\t//create the new buffer\n\t\t\tint dwNewCapacity = nextPowerOf2(requiredCapacity);\n\t\t\tbyte[] abyNewData = new byte[dwNewCapacity];\n\t\t\t\n\t\t\t//put the old data in the new buffer\n\t\t\tfor (int i = 0; i < m_size; i++)\n\t\t\t\tabyNewData[i] = m_data[i];\n\t\t\t\n\t\t\t//scap the old buffer\n\t\t\tm_data = abyNewData;\n\t\t\t\n\t\t\t//update the capacity\n\t\t\tint dwAmountIncreased = dwNewCapacity - m_capacity;\n\t\t\tm_capacity = dwNewCapacity;\n\t\t\t\n\t\t\t//recurse until it is indeed big enough! (hopefully this doesn't happen often...)\n\t\t\tcheckCapacity(in_additionalCount - dwAmountIncreased);\n\t\t}\n\t}\n\t/**\n\t * Returns the next power of two value after the input\n\t *\n\t * @author Ian Copland\n\t *\n\t * @param in_value - The value from which to find the next PO2\n\t */\n\tprivate static int nextPowerOf2(int in_value)\n\t{\n\t\tassert (in_value >= 0) : \"Value must be positive!\";\n\n\t\tint output = 1;\n\t\twhile (output < in_value)\n\t\t{\n\t\t\toutput <<= 1;\n\t\t}\n\n\t\treturn output;\n\t}\n}\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/Java/com/chilliworks/chillisource/core/ExceptionUtils.java",
    "content": "/**\n * ExceptionUtils.java\n * ChilliSource\n * Created by Ian Copland on 16/12/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.core;\n\n//=======================================================\n/// Exception Utils\n///\n/// A collection of convenience methods for working with \n/// exceptions.\n//=======================================================\npublic class ExceptionUtils\n{\n\t//------------------------------------------------\n\t/// Get Stack Trace\n\t///\n\t/// @param The exception\n\t/// @return A string array containing the stack\n\t/// trace.\n\t//------------------------------------------------\n\tpublic static String[] GetStackTrace(Exception inException)\n\t{\n\t\tString[] astrStackTrace = new String[inException.getStackTrace().length];\n\t\tfor (int i = 0; i < inException.getStackTrace().length; ++i)\n\t\t{\n\t\t\tStackTraceElement element = inException.getStackTrace()[i];\n\t\t\tastrStackTrace[i] = element.getFileName() + \" - \" + element.getClassName() + \" - \" + element.getMethodName() + \" - \" + element.getLineNumber();\n\t\t}\n\t\treturn astrStackTrace;\n\t}\n\t//-----------------------------------------------\n\t/// Convert To String\n\t///\n\t/// @param The exception\n\t/// @return The details of the exception in string \n\t/// format.\n\t//-----------------------------------------------\n\tpublic static String convertToString(Exception inException)\n\t{\n\t\tStringBuilder builder = new StringBuilder();\n\t\tbuilder.append(inException.getLocalizedMessage() + \"\\n\");\n\t\tString[] astrStackTrace = GetStackTrace(inException);\n\t\tfor (String strLine : astrStackTrace)\n\t\t{\t\n\t\t\tbuilder.append(\"\\t\" + strLine + \"\\n\");\n\t\t}\n\t\treturn builder.toString();\n\t}\n}\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/Java/com/chilliworks/chillisource/core/FileUtils.java",
    "content": "/**\n * FileUtils.java\n * ChilliSource\n * Created by Ian Copland on 16/12/2013\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.core;\n\nimport java.io.BufferedInputStream;\nimport java.io.BufferedOutputStream;\nimport java.io.File;\nimport java.io.FileInputStream;\nimport java.io.FileOutputStream;\nimport java.io.InputStream;\nimport java.io.OutputStream;\n\nimport android.os.Environment;\n\n/**\n * A collection of convenience methods for working with file input and output.\n * \n * @author Ian Copland\n */\npublic final class FileUtils\n{\n\t/**\n\t * @author Ian Copland\n\t * \n\t * @return the \"external storage\" directory.\n\t */\n\tpublic static String getExternalStorageDirectory()\n\t{\n\t\tString state = Environment.getExternalStorageState();\n\n\t\tif (Environment.MEDIA_MOUNTED.equals(state))\n\t\t{\n\t\t\treturn StringUtils.standardiseDirectoryPath(Environment.getExternalStorageDirectory().toString());\n\t\t}\n\n\t\tLogging.logFatal(\"No external storage mounted.\");\n\t\treturn \"\";\n\t}\n\t/**\n\t * This will return the path to the directory on external storage that important files should\n\t * be stored in for the application with the given package name. This directory will be:\n\t *\n\t *  \tAndroid/data/<PackageName>/files/\n\t *\n\t * @author Ian Copland\n\t *\n\t * @param in_packageName - The package name.\n\t *\n\t * @return The files directory.\n\t */\n\tpublic static String getExternalFilesDirectory(String in_packageName)\n\t{\n\t\treturn getExternalStorageDirectory() + \"Android/data/\" + in_packageName + \"/files/\";\n\t}\n\t/**\n\t * This will return the path to the directory on external storage that unimportant files which\n\t * can be lost and later recreated should be stored in for the application with the given\n\t * package name. This directory will be:\n\t *\n\t *  \tAndroid/data/<PackageName>/cache/\n\t *\n\t * @author Ian Copland\n\t *\n\t * @param in_packageName - The package name.\n\t *\n\t * @return The cache directory.\n\t */\n\tpublic static String getExternalCacheDirectory(String in_packageName)\n\t{\n\t\treturn getExternalStorageDirectory() + \"Android/data/\" + in_packageName + \"/cache/\";\n\t}\n    /**\n     * Returns the path to the directory used by the FileSystem which relates to the \"Save Data\"\n     * Storage Location.\n     *\n     * @author Ian Copland\n     *\n     * @param in_packageName - The package name of the application.\n     *\n     * @return The save data directory.\n     */\n    public static String getSaveDataDirectory(String in_packageName)\n\t{\n\t\treturn getExternalFilesDirectory(in_packageName) + \"SaveData/\";\n\t}\n\t/**\n\t * @author Ian Copland\n\t *\n\t * @param in_filePath - The file path.\n\t *\n\t * @return whether or not the given path exists.\n\t */\n\tpublic static boolean doesFileExist(String in_filePath)\n\t{\n\t\tFile file = new File(in_filePath);\n\t\tif (file.exists() == true && file.isFile() == true)\n\t\t{\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\t/**\n\t * @author Ian Copland\n\t *\n\t * @param in_directoryPath - The path to the directory to check.\n\t *\n\t * @return whether or not the given path exists.\n\t */\n\tpublic static boolean doesDirectoryExist(String in_directoryPath)\n\t{\n\t\tFile directory = new File(in_directoryPath);\n\t\tif (directory.exists() == true && directory.isDirectory() == true)\n\t\t{\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\t/**\n\t * Reads the entire contents of a binary file to a byte array.\n\t * \n\t * @author Ian Copland\n\t *\n\t * @param in_filePath - The path to the file.\n\t *\n\t * @return The file contents.\n\t */\n\tpublic static byte[] readBinaryFile(String in_filePath)\n\t{\n\t\ttry\n\t\t{\n\t\t\tif (doesFileExist(in_filePath) == true)\n\t\t\t{\n\t\t\t\tfinal int k_bufferSize = 16 * 1024;\n\t\t\t\tDynamicByteBuffer dynamicByteBuffer = new DynamicByteBuffer(k_bufferSize);\n\n\t\t\t\tFile file = new File(in_filePath);\n\t\t\t\tInputStream stream = new BufferedInputStream(new FileInputStream(file));\n\t\t\t\ttry\n\t\t\t\t{\n\t\t\t\t\tbyte[] buffer = new byte[k_bufferSize];\n\t\t\t\t\tint numRead = 0;\n\t\t\t\t\twhile(numRead != -1)\n\t\t\t\t\t{\n\t\t\t\t\t\tnumRead = stream.read(buffer, 0, k_bufferSize);\n\t\t\t\t\t\tif (numRead > 0)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tdynamicByteBuffer.appendBytes(buffer, numRead);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfinally\n\t\t\t\t{\n\t\t\t\t\tstream.close();\n\t\t\t\t}\n\n\t\t\t\treturn dynamicByteBuffer.toByteArray();\n\t\t\t}\n\t\t}\n\t\tcatch (Exception e)\n\t\t{\n\t\t\tLogging.logVerbose(ExceptionUtils.convertToString(e));\n\t\t\tLogging.logError(\"An error occurred while reading file '\" + in_filePath + \"': \" + e.getMessage());\n\t\t}\n\t\t\n\t\treturn null;\n\t}\n\t/**\n\t * Reads the entire contents of a text file.\n\t *\n\t * @author Ian Copland\n\t *\n\t * @param in_filePath - The path to the file.\n\t *\n\t * @return The file contents.\n\t */\n\tpublic static String readTextFile(String in_filePath)\n\t{\n\t\tbyte[] contents = readBinaryFile(in_filePath);\n\t\tif (contents == null)\n\t\t{\n\t\t\treturn \"\";\n\t\t}\n\t\treturn StringUtils.utf8BytesToString(contents);\n\t}\n\t/**\n\t * Writes a byte array to file.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param in_filePath - The filename.\n\t * @param in_fileContents - The data to be written to file.\n\t * \n\t * @return Whether or not the file was successfully written.\n\t */\n\tpublic static boolean writeBinaryFile(String in_filePath, byte[] in_fileContents)\n\t{\n\t\tboolean success = false;\n\t\ttry\n\t\t{\n\t\t\tFile file = new File(in_filePath);\n\t\t\tOutputStream stream = new BufferedOutputStream(new FileOutputStream(file));\n\t\t\ttry\n\t\t\t{\n\t\t\t\tstream.write(in_fileContents);\n\t\t\t\tsuccess = true;\n\t\t\t}\n\t\t\tfinally\n\t\t\t{\n\t\t\t\tstream.close();\n\t\t\t}\n\t\t}\n\t\tcatch (Exception e)\n\t\t{\n\t\t\tLogging.logVerbose(ExceptionUtils.convertToString(e));\n\t\t\tLogging.logError(\"An error occurred while writing file '\" + in_filePath + \"': \" + e.getMessage());\n\t\t}\n\t\treturn success;\n\t}\n\t/**\n\t * Writes text to file.\n\t *\n\t * @author Ian Copland\n\t *\n\t * @param in_filePath - The filename.\n\t * @param in_fileContents - The text to be written to file.\n\t *\n\t * @return Whether or not the file was successfully written.\n\t */\n\tpublic static boolean writeBinaryFile(String in_filePath, String in_fileContents)\n\t{\n\t\tbyte[] bytes = StringUtils.stringToUTF8Bytes(in_fileContents);\n\t\treturn writeBinaryFile(in_filePath, bytes);\n\t}\n\t/**\n\t * Creates a new directory at the given path. The path to the directory must already exist.\n\t * This will fail if the directory already exists.\n\t *\n\t * @author Ian Copland\n\t *\n\t * @param in_directoryPath - The path to the directory which should be created.\n\t *\n\t * @return Whether or not this was successful.\n\t */\n\tpublic static boolean createDirectory(String in_directoryPath)\n\t{\n\t\tFile file = new File(in_directoryPath);\n\t\treturn file.mkdir();\n\t}\n\t/**\n\t * Deletes the given file on disk if it exists. If the file doesn't exist this will return\n\t * an error.\n\t *\n\t * @author Ian Copland\n\t *\n\t * @param in_filePath - The filename.\n\t *\n\t * @return Whether or not this was successful.\n\t */\n\tpublic static boolean removeFile(String in_filePath)\n\t{\n\t\tif (doesFileExist(in_filePath) == false)\n\t\t{\n\t\t\treturn false;\n\t\t}\n\n\t\tFile file = new File(in_filePath);\n\t\treturn file.delete();\n\t}\n\t/**\n\t * Deletes the given directory and all of its contents on disk if it exists. If the directory\n\t * doesn't exist this will return an error.\n\t *\n\t * @author Ian Copland\n\t *\n\t * @param in_directoryPath - The path to the directory to remove.\n\t *\n\t * @return Whether or not this was successful.\n\t */\n\tpublic static boolean removeDirectory(String in_directoryPath)\n\t{\n\t\tString directoryPath = StringUtils.standardiseDirectoryPath(in_directoryPath);\n\n\t\tif (doesDirectoryExist(directoryPath) == false)\n\t\t{\n\t\t\treturn false;\n\t\t}\n\n\t\tFile directory = new File(directoryPath);\n\n\t\tString[] directoryContents = directory.list();\n\t\tfor (String directoryItemString : directoryContents)\n\t\t{\n\t\t\tFile directoryItem = new File(directoryPath + directoryItemString);\n\n\t\t\tif (directoryItem.isDirectory() == true)\n\t\t\t{\n\t\t\t\tif (removeDirectory(directoryItem.getPath()) == false)\n\t\t\t\t{\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (directoryItem.isFile() == true)\n\t\t\t{\n\t\t\t\tif (directoryItem.delete() == false)\n\t\t\t\t{\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\t//Unknown item in directory, return false.\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\treturn directory.delete();\n\t}\n    /**\n     * Returns the size of the given file in bytes.\n     *\n     * @author Ian Copland\n     *\n     * @param in_filePath - The path to the file which is to have its size calculated.\n     *\n     * @return The size of the file in bytes.\n     */\n\tpublic static long getFileSize(String in_filePath)\n    {\n        File file = new File(in_filePath);\n        return file.length();\n    }\n}\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/Java/com/chilliworks/chillisource/core/HashCRC32.java",
    "content": "/**\n * HashCRC32.java\n * ChilliSource\n * Created by Ian Copland on 09/01/2014.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2014 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.core;\n\nimport java.util.zip.CRC32;\n\n//===============================================================\n/// CHashCRC32\n///\n/// Static methods for hashing using CRC-32.\n//===============================================================\npublic class HashCRC32 \n{\n\t//-------------------------------------------------------\n\t/// Generate\n\t///\n\t/// The calculates the CRC-32 hash of the given byte\n\t/// array and returns it as an integer.\n\t///\n\t/// @param The data to hash.\n\t/// @return The integer hash.\n\t//-------------------------------------------------------\n\tpublic static int Generate(final byte[] inabyData)\n\t{\n        CRC32 crc32 = new CRC32();\n        crc32.update(inabyData);\n        return (int)crc32.getValue();\n\t}\n}\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/Java/com/chilliworks/chillisource/core/HashMD5.java",
    "content": "/**\n * HashMD5.java\n * ChilliSource\n * Created by Scott Downie on 23/09/2014.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2014 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.core;\n\nimport java.security.MessageDigest;\n\n/**\n * Static class for calculating an MD5 hash for a given data blob\n * \n * @author S Downie\n */\npublic class HashMD5\n{\n\t/**\n\t * Generate an MD5 hash for the given byte array\n\t * \n\t * @author S Downie\n\t * \n\t * @param Data to hash\n\t * \n\t * @return Hashed data\n\t */\n\tpublic static byte[] generate(byte[] in_data)\n\t{\n\t\tbyte[] output = null;\n\t    try\n\t    {\n\t        MessageDigest digest = MessageDigest.getInstance(\"MD5\");\n\t        digest.update(in_data, 0, in_data.length);\n\t        output = digest.digest();\n\t    }\n\t    catch (Exception e)\n\t    {\n\t    \tLogging.logError(ExceptionUtils.convertToString(e));\n\t    }\n\t    \n\t    return output;\n\t}\n\t/**\n\t * Generate an MD5 hash as a hexadecimal string\n\t * \n\t * @author S Downie\n\t * \n\t * @param Data to hash\n\t * \n\t * @return Hashed data as hex\n\t */\n\tpublic static String generateHex(byte[] in_data)\n\t{\n\t\tbyte[] preHex = generate(in_data);\n\n\t\t//converting byte array to Hexadecimal String\n\t\tStringBuilder sb = new StringBuilder(2 * preHex.length);\n\t\tfor(byte b : preHex)\n\t\t{\n\t\t\tsb.append(String.format(\"%02x\", b&0xff));\n\t\t}\n\n\t\treturn sb.toString();\n\t}\n}\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/Java/com/chilliworks/chillisource/core/HashSHA256.java",
    "content": "/**\n * HashSHA256.java\n * ChilliSource\n * Created by Ian Copland on 16/12/2014.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2014 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.core;\n\nimport java.security.MessageDigest;\n\n//===============================================================\n/// CHashSHA256\n///\n/// Static methods for hashing using SHA256.\n//===============================================================\npublic class HashSHA256 \n{\n\t//-------------------------------------------------------\n\t/// Generate\n\t///\n\t/// The calculates the SHA-256 hash of the given byte\n\t/// array and returns it as a 32 byte array.\n\t///\n\t/// @param The data to hash.\n\t/// @return The 32 byte array.\n\t//-------------------------------------------------------\n\tpublic static byte[] Generate(final byte[] inabyData)\n\t{\n\t\tbyte[] abyOutput = null;\n\t    try\n\t    {\n\t        MessageDigest digest = MessageDigest.getInstance(\"SHA-256\");\n\t        digest.update(inabyData, 0, inabyData.length);\n\t        abyOutput = digest.digest();\n\t    }\n\t    catch (Exception e)\n\t    {\n\t    \tLogging.logError(ExceptionUtils.convertToString(e));\n\t    }\n\t    \n\t    return abyOutput;\n\t}\n}\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/Java/com/chilliworks/chillisource/core/IQueryableInterface.java",
    "content": "/**\n * QueryableInterface.java\n * ChilliSource\n * Created by Ian Copland on 09/08/2012.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2012 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.core;\n\n/**\n * An interface for types that can have their type queried at runtime. This is an alternate\n * to using the instanceof keyword.\n *\n * Classes which implement this should provide a static, public instance of InterfaceID called\n * INTERFACE_ID which can be used to query the type.\n *\n * @author Ian Copland\n */\ninterface IQueryableInterface\n{\n    /**\n     * Allows querying of whether the class implements the interface associated with the\n     * given interface Id.\n     *\n     * @param in_interfaceId - The interface Id\n     *\n     * @return Whether or not the interface is implemented.\n     */\n\tboolean isA(InterfaceId in_interfaceId);\n}\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/Java/com/chilliworks/chillisource/core/InterfaceId.java",
    "content": "/**\n * InterfaceId.java\n * ChilliSource\n * Created by Ian Copland on 09/08/2012.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2014 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.core;\n\n/**\n * A simple type used to define a \"named type\" which is used to check the type of classes\n * which implement IQueryableInterface. A class implementing IQueryableInterface should\n * create a static instance of this which can be passed to the isA() method.\n *\n * @author Ian Copland\n */\npublic class InterfaceId\n{\n}\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/Java/com/chilliworks/chillisource/core/InternalFileUtils.java",
    "content": "/**\n * InternalFileUtils.java\n * ChilliSource\n * Created by Ian Copland on 22/07/2015\n *\n * The MIT License (MIT)\n *\n * Copyright (c) 2015 Tag Games Limited\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.core;\n\nimport android.content.Context;\n\nimport java.io.BufferedInputStream;\nimport java.io.BufferedOutputStream;\nimport java.io.File;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.OutputStream;\n\n/**\n * A collection of convenience methods for reading and writing files to internal storage.\n *\n * @author Ian Copland\n */\npublic class InternalFileUtils\n{\n    /**\n     * @author Ian Copland\n     *\n     * @param in_context - The current context.\n     * @param in_filePath - The file path.\n     *\n     * @return Whether or not the given file exists in internal storage.\n     */\n    public static boolean doesFileExist(Context in_context, String in_filePath)\n    {\n        File file = in_context.getFileStreamPath(in_filePath);\n        if (file.exists() == true && file.isFile() == true)\n        {\n            return true;\n        }\n        return false;\n    }\n    /**\n     * Reads the entire contents of a binary file from internal storage. The contents are\n     * returned as a byte array.\n     *\n     * @author Ian Copland\n     *\n     * @param in_filePath - The path to the file.\n     *\n     * @return The file contents.\n     */\n    public static byte[] readBinaryFile(Context in_context, String in_filePath)\n    {\n        try\n        {\n            if (doesFileExist(in_context, in_filePath) == true)\n            {\n                final int k_bufferSize = 16 * 1024;\n                DynamicByteBuffer dynamicByteBuffer = new DynamicByteBuffer(k_bufferSize);\n\n                File file = in_context.getFileStreamPath(in_filePath);\n                InputStream stream = new BufferedInputStream(in_context.openFileInput(in_filePath));\n                try\n                {\n                    byte[] buffer = new byte[k_bufferSize];\n                    int numRead = 0;\n                    while(numRead != -1)\n                    {\n                        numRead = stream.read(buffer, 0, k_bufferSize);\n                        if (numRead > 0)\n                        {\n                            dynamicByteBuffer.appendBytes(buffer, numRead);\n                        }\n                    }\n                }\n                finally\n                {\n                    stream.close();\n                }\n\n                return dynamicByteBuffer.toByteArray();\n            }\n        }\n        catch (Exception e)\n        {\n            Logging.logVerbose(ExceptionUtils.convertToString(e));\n            Logging.logError(\"An error occurred while reading file '\" + in_filePath + \"': \" + e.getMessage());\n        }\n\n        return null;\n    }\n    /**\n     * Reads the entire contents of a text file from internal storage.\n     *\n     * @author Ian Copland\n     *\n     * @param in_context - The active context.\n     * @param in_filePath - The path to the file.\n     *\n     * @return The file contents.\n     */\n    public static String readTextFile(Context in_context, String in_filePath)\n    {\n        byte[] contents = readBinaryFile(in_context, in_filePath);\n        if (contents == null)\n        {\n            return \"\";\n        }\n        return StringUtils.utf8BytesToString(contents);\n    }\n    /**\n     * Writes a byte array to a file on internal storage.\n     *\n     * @author Ian Copland\n     *\n     * @param in_context - The active context.\n     * @param in_filePath - The filename.\n     * @param in_fileContents - The data to be written to file.\n     *\n     * @return Whether or not the file was successfully written.\n     */\n    public static boolean writeBinaryFile(Context in_context, String in_filePath, byte[] in_fileContents)\n    {\n        boolean success = false;\n        try\n        {\n            OutputStream stream = new BufferedOutputStream(in_context.openFileOutput(in_filePath, CSActivity.MODE_PRIVATE));\n            try\n            {\n                stream.write(in_fileContents);\n                success = true;\n            }\n            finally\n            {\n                stream.close();\n            }\n        }\n        catch (IOException e)\n        {\n            Logging.logVerbose(ExceptionUtils.convertToString(e));\n            Logging.logError(\"An error occurred while writing file '\" + in_filePath + \"': \" + e.getMessage());\n        }\n        return success;\n    }\n    /**\n     * Writes text to file on internal storage.\n     *\n     * @author Ian Copland\n     *\n     * @param in_context - The active context.\n     * @param in_filePath - The filename.\n     * @param in_fileContents - The text to be written to file.\n     *\n     * @return Whether or not the file was successfully written.\n     */\n    public static boolean writeBinaryFile(Context in_context, String in_filePath, String in_fileContents)\n    {\n        byte[] bytes = StringUtils.stringToUTF8Bytes(in_fileContents);\n        return writeBinaryFile(in_context, in_filePath, bytes);\n    }\n    /**\n     * Deletes the given file from internal storage. If the file doesn't exist this will return\n     * an error.\n     *\n     * @author Ian Copland\n     *\n     * @param in_context - The active context.\n     * @param in_filePath - The file path\n     *\n     * @return Whether or not this was successful.\n     */\n    public static boolean removeFile(Context in_context, String in_filePath)\n    {\n        if (doesFileExist(in_context, in_filePath) == false)\n        {\n            return false;\n        }\n\n        return in_context.deleteFile(in_filePath);\n    }\n    /**\n     * Calculates the size of the given file located in internal storage.\n     *\n     * @author Ian Copland\n     *\n     * @param in_context - The active context.\n     * @param in_filePath - The path to the file which is to have its size calculated.\n     *\n     * @return The size of the file in bytes.\n     */\n    public static long getFileSize(Context in_context, String in_filePath)\n    {\n        File file = in_context.getFileStreamPath(in_filePath);\n        return file.length();\n    }\n}\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/Java/com/chilliworks/chillisource/core/LoadingView.java",
    "content": "/**\n * LoadingView.java\n * ChilliSource\n * Created by Scott Downie on 09/09/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.core;\n\nimport android.view.ViewGroup;\nimport android.view.WindowManager;\nimport android.widget.ImageView;\n\npublic class LoadingView \n{\n\tprivate static final String kstrDefaultImage = \"com_chillisource_default\";\n\tprivate volatile ImageView mLoadingView = null;\n\tprivate volatile boolean mbIsPresented = false;\n\n\t//---------------------------------------------------\n\t/// Present\n\t///\n\t/// Displays the loading view over other views.\n\t///\n\t/// @param The name of the resource to be presented\n\t/// if the resource does not exist the default\n\t/// com_chillisource_default will be displayed instead.\n\t//---------------------------------------------------\n\tpublic void Present(final String instrResource)\n\t{\n\t\tif(IsPresented())\n\t\t\treturn;\n\t\t\n\t\tmbIsPresented = true;\n\t\t\n\t\tCSApplication.get().scheduleUIThreadTask(new Runnable()\n\t\t{\n\t\t\t@Override \n\t\t\tpublic void run() \n\t\t\t{\n\t\t\t\tmLoadingView = new ImageView(CSApplication.get().getActivityContext());\n\t\t\t\tmLoadingView.setLayoutParams(new ViewGroup.LayoutParams(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT));\n\t\t\t\tif (R.doesExist(R.Type.DRAWABLE, instrResource) == true)\n\t\t\t\t{\n\t\t\t\t\tmLoadingView.setImageResource(R.getId(R.Type.DRAWABLE, instrResource));\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tmLoadingView.setImageResource(R.getId(R.Type.DRAWABLE, kstrDefaultImage));\n\t\t\t\t}\n\t\t\t\tmLoadingView.setScaleType(ImageView.ScaleType.CENTER_CROP);\n\t\t\t\tCSApplication.get().addView(mLoadingView);\n\t\t\t\tmLoadingView.bringToFront();\n\t\t\t}\n\t\t});\n\t}\n\t//---------------------------------------------------------------------\n\t/// Is Presented\n\t///\n\t/// @return Whether the view is presented or scheduled to be presented\n\t//---------------------------------------------------------------------\n\tpublic boolean IsPresented()\n\t{\n\t\treturn mbIsPresented;\n\t}\n\t//---------------------------------------------------\n\t/// Dismiss\n\t///\n\t/// Dismisses the loading view if it is currently\n\t/// displayed.\n\t//---------------------------------------------------\n\tpublic void Dismiss()\n\t{\n\t\tif(mLoadingView == null)\n\t\t\treturn;\n\t\t\n\t\tCSApplication.get().scheduleUIThreadTask(new Runnable()\n\t\t{\n\t\t\t@Override \n\t\t\tpublic void run() \n\t\t\t{\n\t\t\t\tCSApplication.get().removeView(mLoadingView);\n\t\t\t\tmLoadingView = null;\n\t\t\t\tmbIsPresented = false;\n\t\t\t}\n\t\t});\n\t}\n}\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/Java/com/chilliworks/chillisource/core/LocalNotification.java",
    "content": "/**\n * LocalNotification.java\n * ChilliSource\n * Created by Ian Copland on 11/07/2014.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2014 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.core;\n\nimport java.util.Collections;\nimport java.util.HashMap;\nimport java.util.Iterator;\nimport java.util.Map;\nimport java.util.Map.Entry;\n\nimport org.json.JSONException;\nimport org.json.JSONObject;\n\nimport android.content.Intent;\nimport android.os.Bundle;\n\n/**\n * A container for information on a single Local Notification. \n * Also provides means to convert the notification to JSON and\n * to an Intent.\n * \n * @author Ian Copland\n */\npublic final class LocalNotification\n{\n\tpublic final static String k_paramNameNotificationId = \"NotificationId\";\n\tpublic final static String k_paramNameIntentId = \"IntentId\";\n\tpublic final static String k_paramNamePriority = \"Priority\";\n\tpublic final static String k_paramNameTime = \"Time\";\n\t\n\tprivate final static String k_paramNameParams = \"Params\";\n\tprivate final static String k_intentAction = \"com.chilliworks.chillisource.core.ALARM_NOTIFICATION_INTENT\";\n\t\n\tprivate int m_intentId = 0;\n\tprivate int m_notificationId = 0;\n\tprivate int m_priority = 0;\n\tprivate long m_time = 0;\n\tprivate Map<String, String> m_params = new HashMap<String, String>();\n\t\n\t/**\n\t * Constructor.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param The intent Id.\n\t * @param The notification Id.\n\t * @param The priority.\n\t * @param The notification time.\n\t * @param The notification parameters.\n\t */\n\tpublic LocalNotification(int in_intentId, int in_notificationId, int in_priority, long in_time, Map<String, String> in_params)\n\t{\n\t\tm_intentId = in_intentId;\n\t\tm_notificationId = in_notificationId;\n\t\tm_priority = in_priority;\n\t\tm_time = in_time;\n\t\tm_params.putAll(in_params);\n\t}\n\t/**\n\t * Constructor. Creates a local notification from JSON.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param The json object describing the local notification.\n\t */\n\tpublic LocalNotification(JSONObject in_json)\n\t{\n\t\ttry\n\t\t{\n\t\t\tm_intentId = in_json.getInt(k_paramNameIntentId);\n\t\t\tm_notificationId = in_json.getInt(k_paramNameNotificationId);\n\t\t\tm_priority = in_json.getInt(k_paramNamePriority);\n\t\t\tm_time = in_json.getLong(k_paramNameTime);\n\t\t\t\n\t\t\tJSONObject jsonParams = in_json.getJSONObject(k_paramNameParams);\n\t\t\tIterator<String> it = jsonParams.keys();\n\t\t\twhile (it.hasNext())\n\t\t\t{\n\t\t\t\tString key = it.next();\n\t\t\t\tm_params.put(key, jsonParams.getString(key));\n\t\t\t}\n\t\t}\n\t\tcatch (Exception e)\n\t\t{\n\t\t\tLogging.logFatal(\"An exception occurred while building a Local Notification from JSON: \\n\" + ExceptionUtils.convertToString(e));\n\t\t}\n\t}\n\t/**\n\t * Constructor. Creates a local notification from an Intent.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param The intent describing the local notification.\n\t */\n\tpublic LocalNotification(Intent in_intent)\n\t{\n\t\tBundle params = in_intent.getExtras();\n\t\t\n\t\t//remove the extra data from the intent\n\t\tm_intentId = Integer.parseInt(params.getString(LocalNotification.k_paramNameIntentId));\n\t\tm_notificationId = Integer.parseInt(params.getString(LocalNotification.k_paramNameNotificationId));\n\t\tm_priority = Integer.parseInt(params.getString(LocalNotification.k_paramNamePriority));\n\t\tm_time = Long.parseLong(params.getString(LocalNotification.k_paramNameTime));\n\n\t\tIterator<String> iter = params.keySet().iterator();\n\t\twhile(iter.hasNext())\n\t\t{\n\t\t\tString key = iter.next();\t\t\t\n\t\t\tString value = params.get(key).toString();\n\t\t\tif (key.equals(LocalNotification.k_paramNameIntentId) == false && key.equals(LocalNotification.k_paramNameNotificationId) == false && \n\t\t\t\tkey.equals(LocalNotification.k_paramNamePriority) == false && key.equals(LocalNotification.k_paramNameTime) == false)\n\t\t\t{\n\t\t\t\tm_params.put(key, value);\n\t\t\t}\n\t\t}\n\t}\n\t/**\n\t * @author Ian Copland\n\t * \n\t * @return The intent Id.\n\t */\n\tpublic int getIntentId()\n\t{\n\t\treturn m_intentId;\n\t}\n\t/**\n\t * @author Ian Copland\n\t * \n\t * @return The notification Id.\n\t */\n\tpublic int getNotificationId()\n\t{\n\t\treturn m_notificationId;\n\t}\n\t/**\n\t * @author Ian Copland\n\t * \n\t * @return The priority.\n\t */\n\tpublic int getPriority()\n\t{\n\t\treturn m_priority;\n\t}\n\t/**\n\t * @author Ian Copland\n\t * \n\t * @return The notification time.\n\t */\n\tpublic long getTime()\n\t{\n\t\treturn m_time;\n\t}\n\t/**\n\t * @author Ian Copland\n\t * \n\t * @return An immutable copy of the parameters.\n\t */\n\tpublic Map<String, String> getParams()\n\t{\n\t\treturn Collections.unmodifiableMap(m_params);\n\t}\n\t/**\n\t * @author Ian Copland\n\t * \n\t * @return The number of parameters in the notification.\n\t */\n\tpublic int getNumParams()\n\t{\n\t\treturn m_params.size();\n\t}\n\t/**\n\t * Provides a method getting the parameters as arrays of keys and\n\t * values. The arrays must be allocated to be the correct size prior\n\t * before being passed in, otherwise an error will occur.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param [Out] The key array.\n\t * @param [Out] The value array.\n\t */\n\tpublic void getParams(String[] out_keys, String[] out_values)\n\t{\n\t\tif (out_keys.length < m_params.size() || out_values.length < m_params.size())\n\t\t{\n\t\t\tLogging.logFatal(\"Local Notification: cannot get params using array smaller than the param map.\");\n\t\t}\n\t\t\n\t\tint index = 0;\n\t\tfor (Entry<String, String> entry : m_params.entrySet()) \n\t\t{\n\t\t\tout_keys[index] = entry.getKey();\n\t\t\tout_values[index] = entry.getValue();\n\t\t\t++index;\n\t\t}\n\t}\n\t/**\n\t * @author Ian Copland\n\t * \n\t * @return The local notification in JSON form.\n\t */\n\tpublic JSONObject toJson()\n\t{\n\t\tJSONObject jsonRoot = new JSONObject();\n\t\ttry\n\t\t{\n\t\t\tjsonRoot.put(k_paramNameIntentId, m_intentId);\n\t\t\tjsonRoot.put(k_paramNameNotificationId, m_notificationId);\n\t\t\tjsonRoot.put(k_paramNamePriority, m_priority);\n\t\t\tjsonRoot.put(k_paramNameTime, m_time);\n\t\t\t\n\t\t\tJSONObject jsonParams = new JSONObject();\n\t\t\tfor (Entry<String, String> entry : m_params.entrySet()) \n\t\t\t{\n\t\t\t\tjsonParams.put(entry.getKey(), entry.getValue());\n\t\t\t}\n\t\t\tjsonRoot.put(k_paramNameParams, jsonParams);\n\t\t}\n\t\tcatch (JSONException e)\n\t\t{\n\t\t\tLogging.logFatal(\"An exception occurred while converting a local notification to JSON: \\n\" + ExceptionUtils.convertToString(e));\n\t\t}\n\t\t\n\t\treturn jsonRoot;\n\t}\n\t/**\n\t * @author Ian Copland\n\t * \n\t * @return The local notification as an Intent.\n\t */\n\tpublic Intent toIntent()\n\t{\n\t\tIntent intent = new Intent(CSApplication.get().getActivityContext(), LocalNotificationReceiver.class);\n\t\tintent.setAction(k_intentAction);\n\t\t\n\t\tfor (Entry<String, String> entry : m_params.entrySet()) \n\t\t{\n\t\t\tintent.putExtra(entry.getKey(), entry.getValue());\n\t\t}\n\t\t\n\t\tintent.putExtra(k_paramNameIntentId, m_intentId);\n\t\tintent.putExtra(k_paramNameNotificationId, m_notificationId);\n\t\tintent.putExtra(k_paramNamePriority, m_priority);\t\n\t\tintent.putExtra(k_paramNameTime, m_time);\n\t\t\n\t\treturn intent;\n\t}\n}\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/Java/com/chilliworks/chillisource/core/LocalNotificationNativeInterface.java",
    "content": "/**\n * LocalNotificationNativeInterface.java\n * ChilliSource\n * Created by Steven Hendrie on 28/09/2012.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2012 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.core;\n\nimport java.util.ArrayList;\nimport java.util.HashMap;\nimport java.util.List;\nimport java.util.Map;\nimport java.util.Map.Entry;\n\nimport android.app.AlarmManager;\nimport android.app.PendingIntent;\nimport android.content.Context;\nimport android.content.Intent;\n\n/**\n * A native interface for passing local notifications down\n * to the engine.\n * \n * @author Steven Hendrie\n */\npublic class LocalNotificationNativeInterface extends System\n{\n    public static InterfaceId INTERFACE_ID = new InterfaceId();\n\n\tprivate final static String k_sharedPrefsName = \"LocalNotifications\";\n\tprivate final static long k_notificationTimeLimitMs = 500 * 1000; \n\t\n\t/**\n\t * Members\n\t */\n\tprivate AlarmManager m_alarmManager = null;\n\tprivate LocalNotificationStore m_notificationStore = new LocalNotificationStore(k_sharedPrefsName);\n\t\n\t/**\n\t * Constructor\n\t * \n\t * @author Steven Hendrie\n\t */\n\tpublic LocalNotificationNativeInterface()\n\t{\n        init();\n\n\t\tm_alarmManager = (AlarmManager)CSApplication.get().getActivityContext().getSystemService(Context.ALARM_SERVICE);\n\t\tfreeOutOfDateIntentIDs();\n\t}\n\n    /**\n     * Allows querying of whether or not the system implements the interface described by the\n     * given interface id.\n     *\n     * @author Ian Copland\n     *\n     * @param in_interfaceId - The interface id to check\n     *\n     * @return Whether the system implements the given interface\n     */\n    @Override public boolean isA(InterfaceId in_interfaceId)\n    {\n        return (in_interfaceId == INTERFACE_ID);\n    }\n\t\n\t/**\n\t * method accessible from native for allowing System notifications to \n\t * be scheduled for specified time. This should only be called on the Main thread.\n\t * \n\t * @author Steven Hendrie\n\t * \n\t * @param notification ID\n\t * @param string array of keys for params (used to create param map)\n\t * @param string array of values for params (used to create param map) \n\t * @param the trigger time in milliseconds\n\t * @param The priority.\n\t */\n\tpublic void scheduleNotificationForTime(int in_notificationId, String[] in_keys, String[] in_values, long in_time, int in_priority)\n\t{\n\t\tfreeOutOfDateIntentIDs();\t\t\n\t\t\n\t\tint intentId = getNextIntentID();\n\t\tMap<String, String> params = new HashMap<String, String>();\n\t\tfor(int paramIndex = 0; paramIndex < in_keys.length; ++paramIndex)\n\t\t{\n\t\t\tparams.put(in_keys[paramIndex], in_values[paramIndex]);\n\t\t}\n\t\tLocalNotification notification = new LocalNotification(intentId, in_notificationId, in_priority, in_time, params);\n\t\tm_notificationStore.add(notification);\n\n\t\tPendingIntent pendingIntent = PendingIntent.getBroadcast(CSApplication.get().getActivityContext(), intentId , notification.toIntent(), PendingIntent.FLAG_UPDATE_CURRENT);\n\t\tm_alarmManager.set(AlarmManager.RTC_WAKEUP, in_time, pendingIntent);\n\t}\n\t\n\t/**\n\t * method accessible from native that returns all notifications.\n\t * This should only be called on the Main thread.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @return An array of all notifications.\n\t */\n\tpublic LocalNotification[] getNotifications()\n\t{\n\t\tList<LocalNotification> notificationList = m_notificationStore.getNotifications();\n\t\treturn notificationList.toArray(new LocalNotification[0]);\n\t}\n\t\n\t/**\n\t * method accessable from native for cancelling previously scheduled \n\t * notifications by id. This should only be called on the Main thread.\n\t * \n\t * @author Steven Hendrie\n\t * \n\t * @param The notification Id.\n\t */\n\tpublic void cancelByID(int in_notificationId)\n\t{\n\t\tList<LocalNotification> notifications = m_notificationStore.getNotifications();\n\t\tList<LocalNotification> cancelList = new ArrayList<LocalNotification>();\n\t\tfor (LocalNotification notification : notifications)\n\t\t{\n\t\t\tif (notification.getNotificationId() == in_notificationId)\n\t\t\t{\n\t\t\t\tcancelList.add(notification);\n\t\t\t}\n\t\t}\n\t\t\n\t\tfor(LocalNotification cancel : cancelList)\n\t\t{\n\t\t\tPendingIntent pendingIntent = PendingIntent.getBroadcast(CSApplication.get().getActivityContext(), cancel.getIntentId() , cancel.toIntent(), PendingIntent.FLAG_UPDATE_CURRENT);\n\t\t\tm_alarmManager.cancel(pendingIntent);\n\t\t\tm_notificationStore.remove(cancel);\n\t\t}\n\t}\n\t\n\t/**\n\t * Method accessable from native for canceling all previously \n\t * scheduled notifications. This should only be called on the Main thread.\n\t * \n\t * @author Steven Hendrie\n\t */\n\tpublic void cancelAll()\n\t{\n\t\tList<LocalNotification> notifications = m_notificationStore.getNotifications();\n\t\tList<LocalNotification> cancelList = new ArrayList<LocalNotification>();\n\t\tfor (LocalNotification notification : notifications)\n\t\t{\n\t\t\tcancelList.add(notification);\n\t\t}\n\t\t\n\t\tfor (LocalNotification notification : cancelList)\n\t\t{\n\t\t\tPendingIntent pendingIntent = PendingIntent.getBroadcast(CSApplication.get().getActivityContext(), notification.getIntentId(), notification.toIntent(), PendingIntent.FLAG_UPDATE_CURRENT);\n\t\t\tm_alarmManager.cancel(pendingIntent);\n\t\t\tm_notificationStore.remove(notification);\n\t\t}\n\t}\n\t\n\t/**\n\t * Called when a new notification intent is received. This can be called from\n\t * the UI thread.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param The received intent.\n\t */\n\tpublic void onNotificationReceived(Intent in_intent)\n\t{\n\t\tLocalNotification receivedNotification = new LocalNotification(in_intent);\n\t\t\n\t\tLocalNotification storedNotification = m_notificationStore.getNotificationWithIntentId(receivedNotification.getIntentId());\n\t\tif (storedNotification != null)\n\t\t{\n\t\t\tm_notificationStore.remove(storedNotification);\n\t\t\t\n\t\t\tMap<String, String> params = storedNotification.getParams();\n\t\t\tint paramSize = params.size();\n\t\t\tString[] keys = new String[paramSize];\n\t\t\tString[] values = new String[paramSize];\n\t\t\tint index = 0;\n\t\t\tfor (Entry<String, String> entry : params.entrySet()) \n\t\t\t{\n\t\t\t\tkeys[index] = entry.getKey();\n\t\t\t\tvalues[index] = entry.getValue();\n\t\t\t\t++index;\n\t\t\t}\n\t\t\t\n\t\t\tnativeOnNotificationReceived(storedNotification.getNotificationId(), keys, values, storedNotification.getPriority());\n\t\t}\n\t}\n\t\n\t/**\n\t * Determines the next free ID for intent that is passed to the the \n\t * alarm manager to use so that it will not overwrite previously \n\t * placed alarms.\n\t * \n\t * @author Steven Hendrie\n\t * \n\t * @return Unique ID for notification\n\t */\n\tprivate int getNextIntentID()\n\t{\n\t\tBoolean foundUniqueID = false;\n\t\tint count = 0;\n\t\twhile(!foundUniqueID)\n\t\t{\n\t\t\t//if no notification currently uses this ID\n\t\t\tif(m_notificationStore.getNotificationWithIntentId(count) != null)\n\t\t\t{\n\t\t\t\tcount++;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tfoundUniqueID = true;\n\t\t\t}\n\t\t}\n\t\treturn count;\n\t}\n\n\t/**\n\t * Goes through all currently placed intentIDs and checks the time \n\t * that they were fired. If they were over the defined time limit \n\t * then they will be removed allowing them to be overwritten. \n\t * This prevents preferences from getting too large\n\t * \n\t * @author Steven Hendrie\n\t */\n\tprivate void freeOutOfDateIntentIDs()\n\t{\n\t\tlong currentTime = java.lang.System.currentTimeMillis();\n\t\tList<LocalNotification> notifications = m_notificationStore.getNotifications();\n\t\tList<LocalNotification> removeList = new ArrayList<LocalNotification>();\n\t\tfor (LocalNotification notification : notifications)\n\t\t{\n\t\t\tif (currentTime > notification.getTime() + k_notificationTimeLimitMs)\n\t\t\t{\n\t\t\t\tremoveList.add(notification);\n\t\t\t}\n\t\t}\n\t\t\n\t\tfor (LocalNotification notification : removeList)\n\t\t{\n\t\t\tm_notificationStore.remove(notification);\n\t\t}\n\t}\n\t\n\t/**\n\t * Passes a received notification down to the native\n\t * side of the engine.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param The notification Id.\n\t * @param An array of the parameter keys.\n\t * @param An array of the parameter values.\n\t * @param The priority of the notification.\n\t */\n\tnative private void nativeOnNotificationReceived(int in_id, String[] in_keys, String[] in_values, int in_priority);\n}\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/Java/com/chilliworks/chillisource/core/LocalNotificationReceiver.java",
    "content": "/**\n * LocalNotificationReceiver.java\n * ChilliSource\n * Created by Steven Hendrie on 24/10/2012.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2012 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.core;\n\nimport java.util.Iterator;\n\nimport com.chilliworks.chillisource.core.R;\n\nimport android.app.Notification;\nimport android.app.NotificationManager;\nimport android.app.PendingIntent;\nimport android.content.BroadcastReceiver;\nimport android.content.Context;\nimport android.content.Intent;\nimport android.graphics.Bitmap;\nimport android.graphics.BitmapFactory;\nimport android.os.Bundle;\nimport android.os.PowerManager;\nimport android.support.v4.app.NotificationCompat;\nimport android.widget.Toast;\n\n/**\n * Receives all local notifications.\n * \n * @author Steven Hendrie\n */\npublic class LocalNotificationReceiver extends BroadcastReceiver \n{\n\t/**\n\t * Constants\n\t */\n\tprivate final static String k_appOpenedFromNotification = \"AppOpenedFromNotification\";\n\tprivate final static String k_arrayOfKeysName = \"kstrArrayOfKeysName\";\n\tprivate final static String k_arrayOfValuesName = \"kstrArrayOfValuesName\";\n\tprivate final static String k_paramNameTitle = \"Title\";\n\tprivate final static String k_paramNameBody = \"Body\";\n\t\n\t/**\n\t * Member Data\n\t */\n\tprivate static PowerManager.WakeLock s_wakeLock;\n\t\n\t/**\n\t * Called when a local notification broad cast is received. Funnels the notification\n\t * into the app if open or into the notification bar if not\n\t * \n\t * @author Steven Hendrie\n\t * \n\t * @param The context.\n\t * @param The intent.\n\t */\n\t@SuppressWarnings(\"deprecation\")\n\t@Override public void onReceive(Context in_context, Intent in_intent)\n\t{\n\t\t//evaluate whether or not the main engine activity is in the foreground\n\t\tboolean isAppInForeground = false;\n        if (CSApplication.get() != null && CSApplication.get().isActive() == true)\n        {\n        \tisAppInForeground = true;\n        }\n        \n        //if the main engine activity is in the foreground, simply pass the\n        //notification into it. Otherwise display a notification.\n\t\tif(isAppInForeground == true)\n\t\t{\n\t\t\tfinal Intent intent = new Intent(in_intent.getAction());\n\t        Bundle mapParams = in_intent.getExtras();\n\t        Iterator<String> iter = mapParams.keySet().iterator();\n\t        \n\t        while(iter.hasNext())\n\t        {\n\t        \tString strKey =  iter.next();\n\t        \tintent.putExtra(strKey, mapParams.get(strKey).toString());\n\t        }\n\t       \n\t        LocalNotificationNativeInterface localNotificationNI = (LocalNotificationNativeInterface)CSApplication.get().getSystem(LocalNotificationNativeInterface.INTERFACE_ID);\n\t        if (localNotificationNI != null)\n\t        {\n\t        \tlocalNotificationNI.onNotificationReceived(intent);\n\t        }\n\t\t}\n\t\telse\n\t\t{\n\t\t\t//aquire a wake lock\n\t\t\tif(s_wakeLock != null)\n\t\t\t{\n\t\t\t\ts_wakeLock.release();\n\t\t\t}\n\n\t\t\tPowerManager pm = (PowerManager) in_context.getSystemService(Context.POWER_SERVICE);\n\t\t\ts_wakeLock = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.ON_AFTER_RELEASE, \"NotificationWakeLock\");\n\t\t\ts_wakeLock.acquire();\n\n\t\t\t//pull out the information from the intent\n\t\t\tBundle params = in_intent.getExtras();\n\t\t\tCharSequence title = params.getString(k_paramNameTitle);\n\t\t\tCharSequence text =  params.getString(k_paramNameBody);\n\t\t\tint intentId = params.getInt(LocalNotification.k_paramNameNotificationId);\n\n\t\t\tint paramSize = params.size();\n\t\t\tString[] keys = new String[paramSize];\n\t\t\tString[] values = new String[paramSize];\n\t\t\tIterator<String> iter = params.keySet().iterator();\n\t\t\tint paramNumber = 0;\n\t\t\twhile(iter.hasNext())\n\t\t\t{\n\t\t\t\tkeys[paramNumber] = iter.next();\n\t\t\t\tvalues[paramNumber] = params.get(keys[paramNumber]).toString();\n\t\t\t\t++paramNumber;\n\t\t\t}\n\n\t\t\tIntent openAppIntent = new Intent(in_context, CSActivity.class);\n\t\t\topenAppIntent.setAction(\"android.intent.action.MAIN\");\n\t\t\topenAppIntent.addCategory(\"android.intent.category.LAUNCHER\");\n\t\t\topenAppIntent.putExtra(k_appOpenedFromNotification, true);\n\t\t\topenAppIntent.putExtra(k_arrayOfKeysName, keys);\n\t\t\topenAppIntent.putExtra(k_arrayOfValuesName, values);\n\t\t\topenAppIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);\n\t\t\tPendingIntent sContentIntent = PendingIntent.getActivity(in_context, intentId, openAppIntent, PendingIntent.FLAG_UPDATE_CURRENT);\n\n\t\t\tint smallIconId = 0;\n\t\t\tif (R.doesExist(in_context, R.Type.DRAWABLE, \"ic_stat_notify\") == true)\n\t\t\t{\n\t\t\t\tsmallIconId = R.getId(in_context, R.Type.DRAWABLE, \"ic_stat_notify\");\n\t\t\t}\n\n\t\t\tint largeIconId = smallIconId;\n\t\t\tif (R.doesExist(in_context, R.Type.DRAWABLE, \"ic_stat_notify_large\") == true)\n\t\t\t{\n\t\t\t\tlargeIconId = R.getId(in_context, R.Type.DRAWABLE, \"ic_stat_notify_large\");\n\t\t\t}\n\n\t\t\tBitmap largeIconBitmap = null;\n\t\t\tif(largeIconId > 0)\n\t\t\t{\n\t\t\t\tlargeIconBitmap = BitmapFactory.decodeResource(in_context.getResources(), largeIconId);\n\t\t\t}\n\n\t\t\tNotification notification = new NotificationCompat.Builder(in_context)\n\t\t\t\t.setContentTitle(title)\n\t\t\t\t.setContentText(text)\n\t\t\t\t.setSmallIcon(smallIconId)\n\t\t\t\t.setLargeIcon(largeIconBitmap)\n\t\t\t\t.setContentIntent(sContentIntent)\n\t\t\t\t.build();\n\n\t\t\tnotification.flags = Notification.DEFAULT_LIGHTS | Notification.FLAG_AUTO_CANCEL;\n\t\t\tNotificationManager notificationManager = (NotificationManager) in_context.getSystemService(Context.NOTIFICATION_SERVICE);\n\t\t\tnotificationManager.notify(intentId, notification);\n\t\t\tToast.makeText(in_context, text, Toast.LENGTH_LONG).show();\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/Java/com/chilliworks/chillisource/core/LocalNotificationStore.java",
    "content": "/**\n * LocalNotificationStore.java\n * ChilliSource\n * Created by Ian Copland on 11/07/2014.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2014 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.core;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\nimport org.json.JSONArray;\nimport org.json.JSONException;\nimport org.json.JSONObject;\n\nimport android.content.Context;\nimport android.content.SharedPreferences;\n\n/**\n * A container class for storing all currently pending Local Notifications.\n * Notifications are stored in Shared Preferences meaning they will persist\n * when the application is restarted.\n * \n * @author Ian Copland\n */\npublic final class LocalNotificationStore\n{\n\tprivate static final String k_notificationJsonKey = \"NotificationJson\";\n\tprivate static final String k_notificationArrayName = \"LocalNotifications\";\n\t\n\tprivate List<LocalNotification> m_notifications;\n\tprivate String m_sharedPreferenceName = \"\";\n\t\n\t/**\n\t * Constructor\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param The name of the shared preferences instance.\n\t */\n\tpublic LocalNotificationStore(String in_sharedPrefName)\n\t{\n\t\tm_sharedPreferenceName = in_sharedPrefName;\n\t\tm_notifications = readNotifications();\n\t}\n\t/**\n\t * Stores the given notification. This keeps a cached version of it and\n\t * also stores it in Shared Preferences so that it will persist when\n\t * restarting the application.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param The local notification.\n\t */\n\tpublic synchronized void add(LocalNotification in_notification)\n\t{\n\t\tm_notifications.add(in_notification);\n\t\twriteNotifications(m_notifications);\n\t}\n\t/**\n\t * @author Ian Copland\n\t * \n\t * @return A copy of the list of stored notifications.\n\t */\n\tpublic synchronized List<LocalNotification> getNotifications()\n\t{\n\t\tList<LocalNotification> output = new ArrayList<LocalNotification>();\n\t\toutput.addAll(m_notifications);\n\t\treturn output;\n\t}\n\t/**\n\t * @author Ian Copland\n\t * \n\t * @return The notification with the given intent Id. If none exists\n\t * then null will be returned.\n\t */\n\tpublic synchronized LocalNotification getNotificationWithIntentId(int in_intentId)\n\t{\n\t\tfor (LocalNotification notification : m_notifications)\n\t\t{\n\t\t\tif (notification.getIntentId() == in_intentId)\n\t\t\t{\n\t\t\t\treturn notification;\n\t\t\t}\n\t\t}\n\t\t\n\t\treturn null;\n\t}\n\t/**\n\t * Removes the given notification from both the cache and Shared\n\t * Preference.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param The local notification.\n\t */\n\tpublic synchronized void remove(LocalNotification in_notification)\n\t{\n\t\tm_notifications.remove(in_notification);\n\t\twriteNotifications(m_notifications);\n\t}\n\t/**\n\t * Read the notification list from json stored in the shared preferences.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @return The output notification list.\n\t */\n\tprivate List<LocalNotification> readNotifications()\n\t{\n\t\tSharedPreferences sharedPref = CSApplication.get().getAppContext().getSharedPreferences(m_sharedPreferenceName, Context.MODE_PRIVATE);\n\t\tString jsonString = sharedPref.getString(k_notificationJsonKey, \"\");\n\t\t\n\t\tList<LocalNotification> output = new ArrayList<LocalNotification>();\n\t\ttry\n\t\t{\n\t\t\tif (jsonString != \"\")\n\t\t\t{\n\t\t\t\tJSONObject jsonRoot = new JSONObject(jsonString);\n\t\t\t\tJSONArray jsonNotifications = jsonRoot.getJSONArray(k_notificationArrayName);\n\t\t\t\tfor (int i = 0; i < jsonNotifications.length(); ++i)\n\t\t\t\t{\n\t\t\t\t\tJSONObject notificationJson = jsonNotifications.getJSONObject(i);\n\t\t\t\t\tLocalNotification notification = new LocalNotification(notificationJson); \n\t\t\t\t\toutput.add(notification);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tcatch (JSONException e)\n\t\t{\n\t\t\tLogging.logFatal(\"An exception occurred while reading the local notification json: \\n\" + ExceptionUtils.convertToString(e));\n\t\t}\n\t\t\n\t\treturn output;\n\t}\n\t/**\n\t * Writes the notification list to the shared preferences in JSON form.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param The notifications list to write.\n\t */\n\tprivate void writeNotifications(List<LocalNotification> in_notifications)\n\t{\n\t\ttry\n\t\t{\n\t\t\tJSONArray jsonNotifications = new JSONArray();\n\t\t\tfor(LocalNotification notification : in_notifications)\n\t\t\t{\n\t\t\t\tjsonNotifications.put(notification.toJson());\n\t\t\t}\n\t\t\t\n\t\t\tJSONObject jsonRoot = new JSONObject();\n\t\t\tjsonRoot.put(k_notificationArrayName, jsonNotifications);\n\t\t\t\n\t\t\tSharedPreferences sharedPref = CSApplication.get().getAppContext().getSharedPreferences(m_sharedPreferenceName, Context.MODE_PRIVATE);\n\t\t\tSharedPreferences.Editor editor = sharedPref.edit();\n\t\t\teditor.putString(k_notificationJsonKey, jsonRoot.toString());\n\t\t\teditor.commit();\n\t\t}\n\t\tcatch (JSONException e)\n\t\t{\n\t\t\tLogging.logFatal(\"An exception occurred while writing the local notification Json: \\n\" + ExceptionUtils.convertToString(e));\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/Java/com/chilliworks/chillisource/core/Logging.java",
    "content": "/**\n * Logging.java\n * ChilliSource\n * Created by Scott Downie on 14/03/2014.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2014 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.core;\n\nimport android.util.Log;\n\n/**\n * Wrapper class around the Android logging system in order to abstract the tag.\n * \n * @author S Downie\n */\npublic class Logging \n{\n\t/**\n\t * Log message to LogCat under the \"verbose\" channel\n\t * \n\t * @author S Downie\n\t * \n\t * @param in_message - Message to display in LogCat\n\t */\n\tpublic static void logVerbose(String in_message)\n\t{\n\t\tLog.d(\"ChilliSource\", in_message);\n\t}\n\t/**\n\t * Log message to LogCat under the \"warning\" channel\n\t * \n\t * @author S Downie\n\t * \n\t * @param in_message - Message to display in LogCat\n\t */\n\tpublic static void logWarning(String in_message)\n\t{\n\t\tLog.w(\"ChilliSource\", in_message);\n\t}\n\t/**\n\t * Log message to LogCat under the \"error\" channel\n\t * \n\t * @author S Downie\n\t * \n\t * @param in_message - Message to display in LogCat\n\t */\n\tpublic static void logError(String in_message)\n\t{\n\t\tLog.e(\"ChilliSource\", in_message);\n\t}\n\t/**\n\t * Log message to LogCat under the \"error\" channel will also cause the application to assert\n\t * \n\t * @author S Downie\n\t * \n\t * @param in_message - Message to display in LogCat\n\t */\n\tpublic static void logFatal(String in_message)\n\t{\n\t\tLog.e(\"ChilliSource\", in_message);\n\t\tassert false;\n\t}\n}\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/Java/com/chilliworks/chillisource/core/NativeLibraryLoader.java",
    "content": "/**\n * NativeLibraryLoader.java\n * ChilliSource\n * Created by Scott Downie on 28/05/2015.\n *\n * The MIT License (MIT)\n *\n * Copyright (c) 2015 Tag Games Limited\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.core;\n\nimport android.app.Activity;\nimport android.content.pm.PackageManager;\nimport android.os.Bundle;\n\n/**\n * A static class which provides a means to load the native libraries which are used by this\n * application.\n *\n * @author Ian Copland\n */\npublic final class NativeLibraryLoader\n{\n    private static final String ADDITIONAL_LIBRARIES_KEY = \"AdditionalSharedLibraries\";\n    private static final String APPLICATION_LIBRARY = \"Application\";\n\n    private static boolean s_librariesLoaded = false;\n\n    /**\n     * Load the shared Java libraries required by the application. If the libraries are already\n     * loaded this will simply do nothing.\n     *\n     * By default this is just libApplication.so, however an application can add additional\n     * libraries by specifying meta-data with the key AdditionalSharedLibraries in\n     * AndroidManifest.xml. This is a space delimited list of libraries, and the 'lib' prefix and\n     * '.so' suffix should be omitted. For example to load both libLibraryOne.so and\n     * libLibraryTwo.so the following would be required:\n     *\n     * <meta-data android:name=\"AdditionalSharedLibraries\" android:value=\"LibraryOne LibraryTwo\" />\n     *\n     * All additional libraries will be loaded prior to libApplication.so.\n     *\n     * This can only be called on the UI thread.\n     *\n     * @author Ian Copland\n     *\n     * @param in_activity - Any Activity in the application. This is required to get the meta data.\n     */\n    public static void load(Activity in_activity)\n    {\n        assert in_activity != null : \"Cannot load libraries with a null activity.\";\n        assert s_librariesLoaded == false : \"Cannot initialise the libraries more than once.\";\n\n        s_librariesLoaded = true;\n\n        try\n        {\n            Bundle bundle = in_activity.getPackageManager().getApplicationInfo(in_activity.getPackageName(), PackageManager.GET_META_DATA).metaData;\n            String strAdditionalLibraries = bundle.getString(ADDITIONAL_LIBRARIES_KEY);\n            if (strAdditionalLibraries != null)\n            {\n                String[] astrAdditionalLibraries = strAdditionalLibraries.split(\" \");\n\n                for (String strAdditionalLibrary : astrAdditionalLibraries)\n                {\n                    java.lang.System.loadLibrary(strAdditionalLibrary);\n                }\n            }\n        }\n        catch (Exception e)\n        {\n            Logging.logFatal(\"Could not load additional libraries!\");\n        }\n\n        //load the default libraries\n        java.lang.System.loadLibrary(APPLICATION_LIBRARY);\n    }\n}\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/Java/com/chilliworks/chillisource/core/R.java",
    "content": "/**\n * R.java\n * ChilliSource\n * Created by Hugh McLaughlin on 04/07/2012.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2012 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.core;\n\nimport java.lang.reflect.Field;\n\nimport android.content.Context;\nimport android.content.pm.ApplicationInfo;\nimport android.content.pm.PackageManager;\nimport android.os.Bundle;\n\n/**\n * A series of convenience methods for accessing resources in res. This is useful in cases where\n * the R class cannot be directly included in a source file as it isn't part of the project. For\n * example, it allows code in ChilliSource to access resources included in the project.\n *\n * @author Hugh McLaughlin\n */\npublic final class R\n{\n\t/**\n\t * Helper enum to provide names for all possible resource types\n\t *\n\t * @author Hugh McLaughlin\n\t */\n    public enum Type\n    {\n    \tATTRIBUTE(\"attr\"),\n    \tSTRING(\"string\"),\n    \tDRAWABLE(\"drawable\"),\n    \tID(\"id\"),\n    \tLAYOUT(\"layout\"),\n    \tSTYLE(\"style\");\n    \t\n    \tprivate String m_name = \"\";\n\n\t\t/**\n\t\t * @author Hugh McLaughlin\n\t\t *\n\t\t * @param in_name - The name of this resource type.\n\t\t */\n    \tType(String in_name)\n    \t{\n\t\t\tm_name = in_name;\n    \t}\n\t\t/**\n\t\t * @author Hugh McLaughlin\n\t\t *\n\t\t * @return The name of this resource type.\n\t\t */\n    \tpublic String getName()\n    \t{\n    \t\treturn m_name;\n    \t}\n    }\n\t/**\n\t * Checks whether or not the resource with the given name and type exists in res for the\n\t * ChilliSource app.\n\t *\n\t * Instead of using the applicationId (as returned by Activity.getPackageName()), the \"original\"\n\t * packageName specified in the CSAndroidManifest.xml will be used.\n\t *\n\t * @author Ian Copland\n\t *\n\t * @param in_type - The type of the resource.\n\t * @param in_name - The name of the resource.\n\t *\n\t * @return Whether or not the resource with the given name exists.\n\t */\n    static public boolean doesExist(Type in_type, String in_name)\n    {\n    \treturn doesExist(CSApplication.get().getPackageName(), in_type, in_name);\n    }\n\t/**\n\t * Returns the resource with the given type and name from res for the ChilliSource app.\n\t *\n\t * Instead of using the applicationId - as returned by Activity.getPackageName() -  the\n\t * \"original\" packageName, specified in the CSAndroidManifest.xml will be used.\n\t *\n\t * @param in_type - The type of the resource.\n\t * @param in_name - The name of the resource.\n\t *\n\t * @return The Id of the requested resource.\n\t */\n    static public int getId(Type in_type, String in_name)\n    {\n    \treturn getId(CSApplication.get().getPackageName(), in_type, in_name);\n    }\n\t/**\n\t * Returns whether or not the resource with the given type and name exists in res for the\n\t * given context.\n\t *\n\t * If the manifest for the given context contains an \"packageName\" entry, this will be used,\n\t * otherwise, the applicationId - as returned by Application.getPackageName() - is used as the\n\t * package name.\n\t *\n\t * @author Hugh McLaughlin\n\t *\n\t * @param in_context - The context form which to get the applicationId.\n\t * @param in_type - The type of the resource.\n\t * @param in_name - The name of the resource.\n\t *\n\t * @return Whether or not the resource with the given name exists.\n\t */\n    static public boolean doesExist(Context in_context, Type in_type, String in_name)\n    {\n    \treturn doesExist(getPackageName(in_context), in_type, in_name);\n    }\n\t/**\n\t * Returns the id of the resource with the given type and name from res for the given context.\n\t *\n\t * If the manifest for the given context contains an \"packageName\" entry, this will be used,\n\t * otherwise, the applicationId - as returned by Application.getPackageName() - is used as the\n\t * package name.\n\t *\n\t * @author Hugh McLaughlin\n\t *\n\t * @param in_context - The context form which to get the applicationId.\n\t * @param in_type - The type of the resource.\n\t * @param in_name - The name of the resource.\n\t *\n\t * @return Whether or not the resource with the given name exists.\n\t */\n    static public int getId(Context in_context, Type in_type, String in_name)\n    {\n    \treturn getId(getPackageName(in_context), in_type, in_name);\n    }\n\t/**\n\t * Returns whether or not the resource with the given type and name exists in res for the\n\t * given packageName.\n\t *\n\t * @author Hugh McLaughlin\n\t *\n\t * @param in_packageName - The packageName which should be used.\n\t * @param in_type - The type of the resource.\n\t * @param in_name - The name of the resource.\n\t *\n\t * @return Whether or not the resource with the given name exists.\n\t */\n    static public boolean doesExist(String in_packageName, Type in_type, String in_name)\n    {\n    \tString className = in_packageName + \".R$\" + in_type.getName();\n    \ttry \n    \t{\n    \t\tfinal Class<?> resource = Class.forName(className);\n\t\t\tField field = resource.getField(in_name);\n\t\t\treturn (field != null);\n\t\t}\n\t\tcatch (NoSuchFieldException e)\n\t\t{\n\t\t\treturn false;\n\t\t}\n    \tcatch (ClassNotFoundException e)\n\t\t{\n\t\t\tLogging.logVerbose(ExceptionUtils.convertToString(e));\n\t\t\tLogging.logFatal(\"Failed to check if resource '\" + in_name + \"' exists in '\" + className+ \"' becuase class doesn't exist.\");\n\t\t}\n\t\tcatch (Exception e)\n\t\t{\n\t\t\tLogging.logVerbose(ExceptionUtils.convertToString(e));\n\t\t\tLogging.logFatal(\"Failed to check if resource '\" + in_name + \"' exists in '\" + className + \"' becuase an exception occurred: \" + e.getMessage());\n\t\t}\n    \t\n    \treturn false;\n    }\n\t/**\n\t * Returns the id of the resource with the given type and name from res for the given\n\t * packageName.\n\t *\n\t * @author Hugh McLaughlin\n\t *\n\t * @param in_packageName - The packageName which should be used.\n\t * @param in_type - The type of the resource.\n\t * @param in_name - The name of the resource.\n\t *\n\t * @return Whether or not the resource with the given name exists.\n\t */\n    static public int getId(String in_packageName, Type in_type, String in_name)\n    {\n    \tString className = in_packageName + \".R$\" + in_type.getName();\n    \ttry \n    \t{\n    \t\tfinal Class<?> resource = Class.forName(className);\n\t\t\tfinal Field field = resource.getField(in_name);\n\t\t\treturn field.getInt(null);\n\t\t}\n\t\tcatch (NoSuchFieldException e)\n\t\t{\n\t\t\tLogging.logVerbose(ExceptionUtils.convertToString(e));\n\t\t\tLogging.logFatal(\"Failed to get Id for resource '\" + in_name + \"' in '\" + className + \"' becuase the the resource name doesn't exist.\");\n\t\t}\n    \tcatch (ClassNotFoundException e) \n\t\t{\n\t\t\tLogging.logVerbose(ExceptionUtils.convertToString(e));\n\t\t\tLogging.logFatal(\"Failed to get Id for resource '\" + in_name + \"' in '\" + className + \"' becuase class doesn't exist.\");\n\t\t}\n\t\tcatch (Exception e)\n\t\t{\n\t\t\tLogging.logVerbose(ExceptionUtils.convertToString(e));\n\t\t\tLogging.logFatal(\"\\\"Failed to get Id for resource '\" + in_name + \"' in '\" + className + \"' becuase an exception occurred: \" + e.getMessage());\n\t\t}\n    \t\n    \treturn 0;\n    }\n\t/**\n\t * @author Ian Copland\n\t *\n\t * @param in_context - The context to generate a package name for.\n\t *\n\t * @return The package name which should be used by this context. If the manifest for the given\n\t * context contains an \"packageName\" entry, this will be used, otherwise, the applicationId -\n\t * as returned by Application.getPackageName() - is used as the package name.\n\t */\n\tprivate static String getPackageName(Context in_context)\n\t{\n\t\tString packageName = in_context.getPackageName();\n\t\ttry\n\t\t{\n\t\t\tApplicationInfo ai = in_context.getPackageManager().getApplicationInfo(in_context.getPackageName(), PackageManager.GET_META_DATA);\n\t\t\tBundle bundle = ai.metaData;\n\t\t\tif (bundle.containsKey(\"packageName\") == true)\n\t\t\t{\n\t\t\t\tpackageName = bundle.getString(\"packageName\");\n\t\t\t}\n\n\t\t}\n\t\tcatch (Exception e)\n\t\t{\n\t\t\tLogging.logVerbose(ExceptionUtils.convertToString(e));\n\t\t\tLogging.logFatal(\"An exception was thrown while trying to read 'packageName' from AndroidManifest.xml: \" + e.getMessage());\n\t\t}\n\t\treturn packageName;\n\t}\n}\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/Java/com/chilliworks/chillisource/core/Renderer.java",
    "content": "/**\n * Renderer.java\n * ChilliSource\n * Created by Ian Copland on 14/08/2012.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2012 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.core;\n\nimport javax.microedition.khronos.egl.EGLConfig;\nimport javax.microedition.khronos.opengles.GL10;\n\nimport android.opengl.GLSurfaceView;\n\n/**\n *  Implementation of the Android GL renderer.\n *  This actually pumps the main application update loop\n *  as the ChilliSource render thread is the main thread.\n *  \n *  @author Ian Copland\n */\npublic class Renderer implements GLSurfaceView.Renderer \n{\n\tprivate LoadingView m_loadingView = null;\n\tprivate int m_prepareFrameCount = 0;\n\t\n\t/**\n\t * Constructor\n\t * \n\t * @author S Downie\n\t */\n\tpublic Renderer()\n\t{\n\t\tm_loadingView = new LoadingView();\n\t}\n\t/**\n\t * Triggered every frame by the surface in order to render the GL context.\n\t * This actually runs the application update and render loop\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param GL Context\n\t */\n    @Override public void onDrawFrame(GL10 in_GlContext) \n    {\n\t\tif (m_prepareFrameCount <= 0 && CSApplication.get() != null && CSApplication.get().isActive() == true)\n    \t{\n    \t\tCSApplication.get().update();\n    \t\tm_loadingView.Dismiss();\n    \t}\n\t\telse\n\t\t{\n\t\t\t//The surface must issue at least one draw command per draw frame call. Even if \n\t\t\t//the application isn't active\n\t\t\tin_GlContext.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);\n\t\t\tin_GlContext.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT | GL10.GL_STENCIL_BUFFER_BIT);\n\t\t\t\n\t\t\t//Hacky state to allow the loading image to actually appear. Android seems to require that you draw\n\t\t\t//a few frames in order for this to appear\n\t\t\tif(m_prepareFrameCount > 0)\n\t\t\t{\n\t\t\t\tm_prepareFrameCount--;\n\t\t\t}\n\t\t}\n    }\n\t/**\n\t * Triggered when the surface changes (i.e. on resize, etc)\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param GL Context\n\t * @param Surface width\n\t * @param Surface height\n\t */\n    @Override public void onSurfaceChanged(GL10 in_GlContext, int in_width, int in_height) \n    {\n    \tCoreNativeInterface coreNI = (CoreNativeInterface)CSApplication.get().getSystem(CoreNativeInterface.INTERFACE_ID);\n    \tif (coreNI != null)\n    \t{\n    \t\tcoreNI.onResolutionChanged(in_width, in_height);\n    \t}\n    }\n\t/**\n\t * Triggered when the surface is created and ready for rendering\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param GL Context\n\t * @param Configuration\n\t */\n    @Override public void onSurfaceCreated(GL10 in_GlContext, EGLConfig in_config) \n    {\t\n    \tm_prepareFrameCount = 5;\n    \t\n    \tboolean isInitialised = CSApplication.get().hasReceivedInit();\n    \t\n    \tif(isInitialised == false)\n    \t{\n    \t\tm_loadingView.Present(\"com_chillisource_default\");\n    \t\t//App cannot be initialised prior to this point as OpenGL is not ready til now\n    \t\tCSApplication.get().init();\n    \t}\n    \telse\n    \t{\n    \t\tm_loadingView.Present(\"com_chillisource_resume\");\n    \t}\n    }\n}\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/Java/com/chilliworks/chillisource/core/SharedPreferencesNativeInterface.java",
    "content": "/**\n * SharedPreferencesNativeInterface.java\n * ChilliSource\n * Created by Ian Copland on 08/06/2011.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2011 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.core;\n\nimport android.app.Activity;\nimport android.content.SharedPreferences;\n\npublic class SharedPreferencesNativeInterface \n{\n\tstatic final int kDefaultPreferencesMode = 0;\n\t\n\tprivate static Activity msActivity;\n\t\n\t//-------------------------------------------------------------------\n\t/// Setup\n\t///\n\t/// Initialises the native interface.\n\t///\n\t/// @param The applications activity\n\t//-------------------------------------------------------------------\n\tpublic static void Setup(Activity inActivity)\n\t{\n\t\tmsActivity = inActivity;\n\t}\n\t//-------------------------------------------------------------------\n\t/// Key Exists\n\t/// \n\t/// method accessable from native for checking if a key exists in\n\t/// shared preferences\n\t///\n\t/// @param the shared preferences name.\n\t/// @param the key.\n\t/// @return whether or not the given key is available in the specified\n\t//\t\t\tshared preferences file. \n\t//-------------------------------------------------------------------\n\tpublic static boolean KeyExists(String instrName, String instrKey)\n\t{\n\t\tSharedPreferences prefs = msActivity.getSharedPreferences(instrName, kDefaultPreferencesMode);\n\t\treturn prefs.contains(instrKey);\n\t}\n\t//-------------------------------------------------------------------\n\t/// Remove Key\n\t/// \n\t/// method accessable from native for removing key from\n\t/// shared preferences\n\t///\n\t/// @param the shared preferences name.\n\t/// @param the key.\n\t/// @return whether or not the given key was available to be\n\t/// \t\tremoved\n\t//-------------------------------------------------------------------\n\tpublic static boolean RemoveKey(String instrName, String instrKey)\n\t{\n\t\tSharedPreferences prefs = msActivity.getSharedPreferences(instrName, kDefaultPreferencesMode);\n\t\tSharedPreferences.Editor editor = prefs.edit();\n\t\tif(KeyExists(instrName,instrKey))\n\t\t{\n\t\t\teditor.remove(instrKey);\n\t\t\teditor.commit();\n\t\t\treturn true;\n\t\t}else\n\t\t\treturn false;\n\t\t\n\t}\n\t//-------------------------------------------------------------------\n\t/// Get String\n\t///\n\t/// method accessable from native for getting a string from\n\t/// shared preferences\n\t///\n\t/// @param the shared preferences name.\n\t/// @param the key.\n\t/// @param default value to return if the key doesnt exist.\n\t/// @return the value for the given key.\n\t//-------------------------------------------------------------------\n\tpublic static String GetString(String instrName, String instrKey, String instrDefaultValue)\n\t{\n\t\tSharedPreferences prefs = msActivity.getSharedPreferences(instrName, kDefaultPreferencesMode);\n\t\treturn prefs.getString(instrKey, instrDefaultValue);\n\t}\n\t//-------------------------------------------------------------------\n\t/// Set String\n\t///\n\t/// method accessable from native for setting a string in\n\t/// shared preferences\n\t///\n\t/// @param the shared preferences name.\n\t/// @param the key.\n\t/// @param The value to write\n\t//-------------------------------------------------------------------\n\tpublic static void SetString(String instrName, String instrKey, String instrValue)\n\t{\n\t\tSharedPreferences prefs = msActivity.getSharedPreferences(instrName, kDefaultPreferencesMode);\n\t\tSharedPreferences.Editor editor = prefs.edit();\n\t\teditor.putString(instrKey, instrValue);\n\t\teditor.commit();\n\t}\n\t//-------------------------------------------------------------------\n\t/// Get Boolean\n\t///\n\t/// method accessable from native for getting a boolean from\n\t/// shared preferences\n\t///\n\t/// @param the shared preferences name.\n\t/// @param the key.\n\t/// @param default value to return if the key doesnt exist.\n\t/// @return the value for the given key.\n\t//-------------------------------------------------------------------\n\tpublic static boolean GetBoolean(String instrName, String instrKey, boolean inbDefaultValue)\n\t{\n\t\tSharedPreferences prefs = msActivity.getSharedPreferences(instrName, kDefaultPreferencesMode);\n\t\treturn prefs.getBoolean(instrKey, inbDefaultValue);\n\t}\n\t//-------------------------------------------------------------------\n\t/// Set Boolean\n\t///\n\t/// method accessable from native for setting a boolean in\n\t/// shared preferences\n\t///\n\t/// @param the shared preferences name.\n\t/// @param the key.\n\t/// @param The value to write\n\t//-------------------------------------------------------------------\n\tpublic static void SetBoolean(String instrName, String instrKey, boolean inbValue)\n\t{\n\t\tSharedPreferences prefs = msActivity.getSharedPreferences(instrName, kDefaultPreferencesMode);\n\t\tSharedPreferences.Editor editor = prefs.edit();\n\t\teditor.putBoolean(instrKey, inbValue);\n\t\teditor.commit();\n\t}\n\t//-------------------------------------------------------------------\n\t/// Get Int\n\t///\n\t/// method accessable from native for getting an int from\n\t/// shared preferences\n\t///\n\t/// @param the shared preferences name.\n\t/// @param the key.\n\t/// @param default value to return if the key doesnt exist.\n\t/// @return the value for the given key.\n\t//-------------------------------------------------------------------\n\tpublic static int GetInt(String instrName, String instrKey, int indwDefaultValue)\n\t{\n\t\tSharedPreferences prefs = msActivity.getSharedPreferences(instrName, kDefaultPreferencesMode);\n\t\treturn prefs.getInt(instrKey, indwDefaultValue);\n\t}\n\t//-------------------------------------------------------------------\n\t/// Set Int\n\t///\n\t/// method accessable from native for setting an int in\n\t/// shared preferences\n\t///\n\t/// @param the shared preferences name.\n\t/// @param the key.\n\t/// @param The value to write\n\t//-------------------------------------------------------------------\n\tpublic static void SetInt(String instrName, String instrKey, int indwValue)\n\t{\n\t\tSharedPreferences prefs = msActivity.getSharedPreferences(instrName, kDefaultPreferencesMode);\n\t\tSharedPreferences.Editor editor = prefs.edit();\n\t\teditor.putInt(instrKey, indwValue);\n\t\teditor.commit();\n\t}\n\t//-------------------------------------------------------------------\n\t/// Get Long\n\t///\n\t/// method accessable from native for getting an int from\n\t/// shared preferences\n\t///\n\t/// @param the shared preferences name.\n\t/// @param the key.\n\t/// @param default value to return if the key doesnt exist.\n\t/// @return the value for the given key.\n\t//-------------------------------------------------------------------\n\tpublic static long GetLong(String instrName, String instrKey, long inqwDefaultValue)\n\t{\n\t\tSharedPreferences prefs = msActivity.getSharedPreferences(instrName, kDefaultPreferencesMode);\n\t\treturn prefs.getLong(instrKey, inqwDefaultValue);\n\t}\n\t//-------------------------------------------------------------------\n\t/// Set Int\n\t///\n\t/// method accessable from native for setting an int in\n\t/// shared preferences\n\t///\n\t/// @param the shared preferences name.\n\t/// @param the key.\n\t/// @param The value to write\n\t//-------------------------------------------------------------------\n\tpublic static void SetLong(String instrName, String instrKey, long inqwValue)\n\t{\n\t\tSharedPreferences prefs = msActivity.getSharedPreferences(instrName, kDefaultPreferencesMode);\n\t\tSharedPreferences.Editor editor = prefs.edit();\n\t\teditor.putLong(instrKey, inqwValue);\n\t\teditor.commit();\n\t}\n}\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/Java/com/chilliworks/chillisource/core/StringUtils.java",
    "content": "/**\n * StringUtils.java\n * ChilliSource\n * Created by Ian Copland on 08/01/2014.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2014 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.core;\n\nimport java.nio.charset.Charset;\n\n/**\n * A collection of convenience methods for working with Strings.\n *\n * @author Ian Copland\n */\npublic class StringUtils\n{\n    private static final Charset UTF8_CHARSET = Charset.forName(\"UTF-8\");\n\n    /**\n     * Converts a string in UTF-16 format to a UTF8 byte array.\n     *\n     * @author Ian Copland\n     *\n     * @param in_string - The string to convert.\n     *\n     * @return The output byte array in UTF-8 format.\n     */\n    public static byte[] stringToUTF8Bytes(String in_string)\n    {\n        return in_string.getBytes(UTF8_CHARSET);\n    }\n    /**\n     * Converts UTF-8 byte array to a string in UTF-16 format.\n     *\n     * @param in_utf8Bytes - The byte array to convert.\n     *\n     * @return The output string.\n     */\n    public static String utf8BytesToString(final byte[] in_utf8Bytes)\n    {\n        return new String(in_utf8Bytes, UTF8_CHARSET);\n    }\n    /**\n     * Standardised the path to a file.\n     *\n     * @author Ian Copland\n     *\n     * @param in_filePath - The file path.\n     *\n     * @return The standardised file path.\n     */\n    public static String standardiseFilePath(String in_filePath)\n    {\n        String standardisedPath = in_filePath.replace(\"\\\\\", \"/\");\n        standardisedPath = standardisedPath.replace(\"//\", \"/\");\n        if (standardisedPath.endsWith(\"/\") == true)\n        {\n            standardisedPath = standardisedPath.substring(0, standardisedPath.length() - 1);\n        }\n        return standardisedPath;\n    }\n    /**\n     * Standardised the path to a file.\n     *\n     * @author Ian Copland\n     *\n     * @param in_directoryPath - The directory path.\n     *\n     * @return The standardised file path.\n     */\n    public static String standardiseDirectoryPath(String in_directoryPath)\n    {\n        String standardisedPath = in_directoryPath.replace(\"\\\\\", \"/\");\n        standardisedPath = in_directoryPath.replace(\"//\", \"/\");\n        if (standardisedPath.endsWith(\"/\") == false)\n        {\n            standardisedPath += \"/\";\n        }\n        return standardisedPath;\n    }\n    /**\n     * @author Ian Copland\n     *\n     * @param in_filePath - The file path.\n     *\n     * @return The extension of a file path string.\n     */\n    public static String getExtension(String in_filePath)\n    {\n        int dwIndex = in_filePath.lastIndexOf(\".\");\n        if (dwIndex != -1)\n            return in_filePath.substring(dwIndex + 1);\n        return \"\";\n    }\n    /**\n     * @author Ian Copland\n     *\n     * @param in_filePath - The file path.\n     *\n     * @return The file path without the extension.\n     */\n    public static String removeExtension(String in_filePath)\n    {\n        int index = in_filePath.lastIndexOf(\".\");\n\n        if (index != -1)\n        {\n            return in_filePath.substring(0, index);\n        }\n\n        return in_filePath;\n    }\n    /**\n     * @author Ian Copland\n     *\n     * @param in_filePath - The file path.\n     *\n     * @return The directory path part of the given file name.\n     * This will be standardised.\n     */\n    public static String getDirectory(String in_filePath)\n    {\n        String standardisedFilePath = StringUtils.standardiseFilePath(in_filePath);\n        int index = standardisedFilePath.lastIndexOf(\"/\");\n\n        if (index != -1)\n        {\n            return standardisedFilePath.substring(0, index + 1);\n        }\n\n        return \"\";\n    }\n    /**\n     * @author Ian Copland\n     *\n     * @param in_filePath - The file path.\n     *\n     * @return The file name part of the file path.\n     */\n    public static String getFileName(String in_filePath)\n    {\n        String standardisedFilePath = StringUtils.standardiseFilePath(in_filePath);\n        int index = standardisedFilePath.lastIndexOf(\"/\");\n\n        if (index != -1)\n        {\n            standardisedFilePath = standardisedFilePath.substring(index + 1);\n        }\n\n        return standardisedFilePath;\n    }\n    /**\n     * Removes all spaces, line returns and tabs from the given string.\n     *\n     * @author Ian Copland\n     *\n     * @param in_string - The input string with whitespace.\n     *\n     * @return The input string minus whitespace.\n     */\n    public static String removeWhitespace(String in_string)\n    {\n        String strOutput = new String(in_string);\n        strOutput = strOutput.replace(\" \", \"\");\n        strOutput = strOutput.replace(\"\\n\", \"\");\n        strOutput = strOutput.replace(\"\\r\", \"\");\n        strOutput = strOutput.replace(\"\\t\", \"\");\n        return strOutput;\n    }\n}\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/Java/com/chilliworks/chillisource/core/Surface.java",
    "content": "/**\n * Surface.java\n * ChilliSource\n * Created by Ian Copland on 14/08/2012.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2012 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.core;\n\nimport com.chilliworks.chillisource.input.TouchInputNativeInterface;\n\nimport android.app.Activity;\nimport android.opengl.GLSurfaceView;\nimport android.view.MotionEvent;\n\n/**\n * A surface is composited into the android view hierarchy and manages\n * Open GL and input events.\n *\n * @author Ian Copland\n */\npublic class Surface extends GLSurfaceView \n{\n\t/**\n\t * Constructor\n\t *\n\t * @author Ian Copland\n\t * \n\t * @param App config\n\t * @param Activity\n\t */\n\tpublic Surface(AppConfig in_appConfig, Activity in_activity) \n\t{\n\t\tsuper(in_activity);\n\t\t\n\t\t//create the context factory\n\t\tsetEGLContextFactory(new ContextFactory());\n\t\t\n\t\t//set the config\n\t\tsetEGLConfigChooser(createConfigChooser(in_appConfig));\n\t\t\n\t\t//create renderer\n\t\tsetRenderer(new com.chilliworks.chillisource.core.Renderer());\n    }\n\t/**\n\t * Creates a new config chooser with the params as defined in\n\t * the App.config file.\n\t *\n\t * @author Ian Copland\n\t * \n\t * @param The app config.\n\t * \n\t * @return The config chooser.\n\t */\n\tprivate ConfigChooser createConfigChooser(AppConfig in_config)\n\t{\n\t\tString surfaceFormat = in_config.getSurfaceFormat();\n\t\t\n\t\tif (surfaceFormat.equalsIgnoreCase(\"rgb565_depth24\") == true)\n\t\t{\n\t\t\treturn new ConfigChooser(5, 6, 5, 0, 16, 24, 0);\n\t\t}\n\t\telse if (surfaceFormat.equalsIgnoreCase(\"rgb565_depth32\") == true)\n\t\t{\n\t\t\treturn new ConfigChooser(5, 6, 5, 0, 16, 32, 0);\n\t\t}\n\t\telse if (surfaceFormat.equalsIgnoreCase(\"rgb888_depth24\") == true)\n\t\t{\n\t\t\treturn new ConfigChooser(8, 8, 8, 0, 16, 24, 0);\n\t\t}\n\t\telse if (surfaceFormat.equalsIgnoreCase(\"rgb888_depth32\") == true)\n\t\t{\n\t\t\treturn new ConfigChooser(8, 8, 8, 0, 16, 32, 0);\n\t\t}\n\t\telse if (surfaceFormat.equalsIgnoreCase(\"rgb565_depth24_stencil8\") == true)\n\t\t{\n\t\t\treturn new ConfigChooser(5, 6, 5, 0, 16, 24, 8);\n\t\t}\n\t\telse if (surfaceFormat.equalsIgnoreCase(\"rgb565_depth32_stencil8\") == true)\n\t\t{\n\t\t\treturn new ConfigChooser(5, 6, 5, 0, 16, 32, 8);\n\t\t}\n\t\telse if (surfaceFormat.equalsIgnoreCase(\"rgb888_depth24_stencil8\") == true)\n\t\t{\n\t\t\treturn new ConfigChooser(8, 8, 8, 0, 16, 24, 8);\n\t\t}\n\t\telse if (surfaceFormat.equalsIgnoreCase(\"rgb888_depth32_stencil8\") == true)\n\t\t{\n\t\t\treturn new ConfigChooser(8, 8, 8, 0, 16, 32, 8);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tLogging.logFatal(\"Surface: Invalid surface format.\");\n\t\t\treturn null;\n\t\t}\n\t}\n\t/**\n\t * Triggered when the surface receives a touch input event\n\t *\n\t * @author Ian Copland\n\t * \n\t * @param Input event\n\t * \n\t * @return Whether or not the surface consumes the event or\n\t * allows it to filter through to the next surface\n\t */\n\t@Override public boolean onTouchEvent(final MotionEvent event) \n\t{\t\n\t\t//get the action data.\n\t\tint actionData = event.getAction();\n\t\tint actionEvent = actionData & MotionEvent.ACTION_MASK;\n\n\t\t//ACTION_POINTER_ID_MASK and ACTION_POINTER_ID_SHIFT are now depreciated and have been replaced with ACTION_POINTER_INDEX_SHIFT\n\t\t//and ACTION_POINTER_INDEX_MASK in order to match the data they are used to retrieve. They are only available in API lv8 however, \n\t\t//so this will need to be updated when lv8 is our minimum target.\n\t\t@SuppressWarnings(\"deprecation\")\n\t\tint pointerIndex = (actionData & MotionEvent.ACTION_POINTER_ID_MASK) >> MotionEvent.ACTION_POINTER_ID_SHIFT;\n\t\tfinal int pointerID = event.getPointerId(pointerIndex);\n\n\t\t//get the x and y positions of the touch if possible\n\t\tfloat xPos = -1.0f;\n\t\tfloat yPos = -1.0f;\n\t\tif (pointerIndex != -1)\n\t\t{\n\t\t\txPos = event.getX(pointerIndex);\n\t\t\tyPos = event.getY(pointerIndex);\n\t\t}\n\n\t\tfinal float touchX = xPos;\n\t\tfinal float touchY = yPos;\n\n\t\tRunnable task = null;\n\t\t//pass the touch events on to the native side of the engine\n\t\tswitch (actionEvent)\n\t\t{\n\t\tcase MotionEvent.ACTION_POINTER_DOWN:\n\t\tcase MotionEvent.ACTION_DOWN:\n\t\t\ttask = new Runnable()\n\t\t\t{\n\t\t\t\t@Override public void run() \n\t\t\t\t{\n\t\t\t\t\tTouchInputNativeInterface.TouchDown(pointerID, touchX, touchY);\n\t\t\t\t}\n\t\t\t};\n\t\t\tqueueEvent(task);\n\t\t\tbreak;\n\t\tcase MotionEvent.ACTION_POINTER_UP:\n\t\tcase MotionEvent.ACTION_UP:\n\t\tcase MotionEvent.ACTION_CANCEL:\n\t\tcase MotionEvent.ACTION_OUTSIDE:\n\t\t\ttask = new Runnable()\n\t\t\t{\n\t\t\t\t@Override public void run() \n\t\t\t\t{\n\t\t\t\t\tTouchInputNativeInterface.TouchUp(pointerID, touchX, touchY);\n\t\t\t\t}\n\t\t\t};\n\t\t\tqueueEvent(task);\n\t\t\tbreak;\n\t\tcase MotionEvent.ACTION_MOVE:\n\t\t\t//in the case of moved events all touches need to be updated.\n\t\t\tfor (int i = 0; i < event.getPointerCount(); i++)\n\t\t\t{\n\t\t\t\tpointerIndex = i;\n\t\t\t\tfinal int movedPointerID = event.getPointerId(pointerIndex);\n\t\t\t\txPos = event.getX(pointerIndex);\n\t\t\t\tyPos = event.getY(pointerIndex);\n\n\t\t\t\tfinal float movedTouchX = xPos;\n\t\t\t\tfinal float movedTouchY = yPos;\n\n\t\t\t\ttask = new Runnable()\n\t\t\t\t{\n\t\t\t\t\t@Override public void run() \n\t\t\t\t\t{\n\t\t\t\t\t\tTouchInputNativeInterface.TouchMoved(movedPointerID, movedTouchX, movedTouchY);\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t\tqueueEvent(task);\n\t\t\t\t\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n        return true;\n    }\n}\n\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/Java/com/chilliworks/chillisource/core/System.java",
    "content": "/**\n * System.java\n * ChilliSource\n * Created by Ian Copland on 09/08/2012.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2014 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.core;\n\nimport android.content.Intent;\nimport android.content.res.Configuration;\n\nimport com.chilliworks.chillisource.core.IQueryableInterface;\n\n/**\n * Base class for Java systems. Allows systems to receive lifecycle events from\n * the application such as onResume() and onSuspend()\n *\n * @author S Downie\n */\npublic abstract class System implements IQueryableInterface\n{\n    /**\n     * Initialises the system, adding it to the application system list and calling appropriate\n     * lifecycle events. This *must* be the first method called on a System. Remember to call\n     * destroyApplication() once finished.\n     *\n     * This can be called from any thread.\n     *\n     * @author Ian Copland\n     */\n    public final void init()\n    {\n        CSApplication.get().addSystem(this);\n    }\n    /**\n     * Cleans up the system, calling appropriate life cycle events, then removes it from the\n     * application system list.\n     *\n     * This *must* be the last method called on the system.\n     *\n     * This can be called from any thread.\n     *\n     * @author Ian Copland\n     */\n    public final void destroy()\n    {\n        CSApplication.get().removeSystem(this);\n    }\n    /**\n     * Called when the entity has been added to the application.\n     *\n     * This is always called on the main thread.\n     *\n     * @author Ian Copland\n     */\n    protected void onInit() {}\n\t/**\n\t * Triggered when the activity is made visible after being suspended.\n     *\n     * This is always called on the UI thread.\n\t * \n\t * @author S Downie\n\t */\n    protected void onResume() {}\n\t/**\n\t * Triggered when the activity is brought to the foreground after being in the background.\n     *\n     * This is always called on the UI thread.\n\t * \n\t * @author S Downie\n\t */\n    protected void onForeground() {}\n\t/**\n\t * Triggered when the activity is sent to the background after being in the foreground.\n     *\n     * This is always called on the UI thread.\n\t * \n\t * @author S Downie\n\t */\n    protected void onBackground() {}\n\t/**\n\t * Triggered when the activity is closed and no longer active.\n     *\n     * This is always called on the UI thread.\n\t * \n\t * @author S Downie\n\t */\n    protected void onSuspend() {}\n\t/**\n\t * Called immediately before the System is removed from the Application.\n     *\n     * This is always called on the UI thread.\n\t * \n\t * @author Ian Copland\n\t */\n    protected void onDestroy() {}\n\t/**\n\t * Triggered when the activity receives a launch intent.\n     *\n     * This is always called on the UI thread.\n\t * \n\t * @author S Downie\n\t * \n\t * @param in_intent - Intent\n\t */\n    protected void onLaunchIntentReceived(Intent in_intent) {}\n\t/**\n\t * Triggered when the activity exits.\n     *\n     * This is always called on the UI thread.\n\t * \n\t * @author S Downie\n\t * \n\t * @param in_requestCode - Request code that it started with\n\t * @param in_resultCode - Result code it returned\n\t * @param in_data - Any additional data returned\n\t */\n    protected void onActivityResult(int in_requestCode, int in_resultCode, Intent in_data) {}\n\t/**\n\t * Triggered when the activity config changes such as orientation, hardware keyboards, etc..\n     *\n     * This is always called on the UI thread.\n\t * \n\t * @author S Downie\n\t * \n\t * @param in_config - New config\n\t */\n    protected void onActivityConfigurationChanged(Configuration in_config) {}\n}\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/Java/com/chilliworks/chillisource/input/AccelerometerNativeInterface.java",
    "content": "/**\n * AccelerometerJavaInterface.java\n * ChilliSource\n * Created by Ian Copland on 12/06/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.input;\n\nimport android.app.Activity;\nimport android.content.pm.PackageManager;\nimport android.hardware.Sensor;\nimport android.hardware.SensorEvent;\nimport android.hardware.SensorEventListener;\nimport android.hardware.SensorManager;\nimport android.view.WindowManager;\n\nimport com.chilliworks.chillisource.core.*;\nimport com.chilliworks.chillisource.core.System;\n\n//=============================================================\n/// Video Player Native Interface\n///\n/// A native interface for interfacing with the Android \n/// accelerometer from native code.\n//=============================================================\npublic class AccelerometerNativeInterface extends System implements SensorEventListener\n{\n\t//-----------------------------------------------------\n\t/// Axis Swap\n\t///\n\t/// Defines a container for information used when swapping\n\t/// from device accelerometer coordinates into screen\n\t/// coordiates.\n\t//-----------------------------------------------------\n\tclass AxisSwap\n\t{\n\t\tfinal int m_negateX;\n\t\tfinal int m_negateY;\n\t\tfinal int m_sourceX;\n\t\tfinal int m_sourceY;\n\t\t//-----------------------------------------------------\n\t\t/// Constructor\n\t\t//-----------------------------------------------------\n\t\tAxisSwap(int in_negateX, int in_negateY, int in_sourceX, int in_sourceY)\n\t\t{\n\t\t\tm_negateX = in_negateX;\n\t\t\tm_negateY = in_negateY;\n\t\t\tm_sourceX = in_sourceX;\n\t\t\tm_sourceY = in_sourceY;\n\t\t}\n\t};\n\t//-----------------------------------------------------\n\t/// Member data\n\t//-----------------------------------------------------\n    public static InterfaceId INTERFACE_ID = new InterfaceId();\n\n\tboolean mbListening = false;\n\tboolean mbHasAccelerometer = false;\n\tAxisSwap[] m_axisSwapForRotation = null;\n\t//-----------------------------------------------------\n\t/// Constructor\n\t//-----------------------------------------------------\n\tpublic AccelerometerNativeInterface()\n\t{\n        init();\n\n\t\tPackageManager manager = CSApplication.get().getActivityContext().getPackageManager();\n\t\tmbHasAccelerometer = manager.hasSystemFeature(PackageManager.FEATURE_SENSOR_ACCELEROMETER);\n\t\t\n\t\tm_axisSwapForRotation = new AxisSwap[]\n\t\t{\n\t\t\tnew AxisSwap( 1,-1, 0, 1),\t\t// ROTATION_0\n\t\t\tnew AxisSwap(-1,-1, 1, 0), \t\t// ROTATION_90\n\t\t\tnew AxisSwap(-1, 1, 0, 1), \t\t// ROTATION_180\n\t\t\tnew AxisSwap( 1, 1, 1, 0) \t\t// ROTATION_270\n\t\t}; \n\t}\n    /**\n     * Allows querying of whether or not the system implements the interface described by the\n     * given interface id.\n     *\n     * @author Ian Copland\n     *\n     * @param in_interfaceId - The interface id to check\n     *\n     * @return Whether the system implements the given interface\n     */\n    @Override public boolean isA(InterfaceId in_interfaceId)\n    {\n        return (in_interfaceId == INTERFACE_ID);\n    }\n\t//---------------------------------------------------\n\t/// Is Available\n\t///\n\t/// @return whether or not the accelerometer is\n\t/// available on this device.\n\t//---------------------------------------------------\n\tpublic boolean IsAvailable()\n\t{\n\t\treturn mbHasAccelerometer;\n\t}\n\t//---------------------------------------------------\n\t/// Start Listening\n\t///\n\t/// Starts listening for accelerometer events.\n\t//---------------------------------------------------\n\tpublic void StartListening()\n\t{\n\t\tif (true == mbHasAccelerometer && false == mbListening)\n\t\t{\n\t\t\tmbListening = true;\n\t\t\t\n\t\t\tfinal AccelerometerNativeInterface accelerometerNI = this;\n\t\t\tRunnable task = new Runnable()\n\t\t\t{ \n\t\t\t\t@Override public void run() \n\t\t\t\t{\n\t\t\t\t\tSensorManager sensorManager = (SensorManager)CSApplication.get().getActivityContext().getSystemService(Activity.SENSOR_SERVICE);\n\t\t\t\t\tsensorManager.registerListener(accelerometerNI, sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER), SensorManager.SENSOR_DELAY_GAME);\t\n\t\t\t\t}\n\t\t\t};\n\t\t\tCSApplication.get().scheduleUIThreadTask(task);\n\t\t};\n\t}\n\t//---------------------------------------------------\n\t/// On Accuracy Changed\n\t///\n\t/// Called when the accuracy of a sensor has changed.\n\t///\n\t/// @param The sensor that has had it's accuracy change.\n\t/// @param The new accuracy value.\n\t//---------------------------------------------------\n\t@Override public void onAccuracyChanged(Sensor sensor, int accuracy) \n\t{\n\t}\n\t//---------------------------------------------------\n\t/// On Sensor Changed\n\t///\n\t/// Called when sensor values have changed. NOTE: The\n\t/// application doesn't own the event object passed as \n\t/// a parameter and therefore cannot hold on to it. \n\t/// The object may be part of an internal pool and \n\t/// may be reused by the framework.\n\t///\n\t/// @param The sensor event.\n\t//---------------------------------------------------\n\t@Override public void onSensorChanged(SensorEvent event) \n\t{\n\t\tif (Sensor.TYPE_ACCELEROMETER == event.sensor.getType())\n\t\t{\n\t\t\t//The values provided from the accelerometer are always relative to the default screen orientation which can change\n\t\t\t//from device to device. To alleviate this we are converting into \"screen\" coordinates. This has been taken from\n\t\t\t//the nvidia accelerometer white paper which can be found at : http://developer.download.nvidia.com/tegra/docs/tegra_android_accelerometer_v5f.pdf\n\t\t\tActivity activity = CSApplication.get().getActivity();\n\t\t\tWindowManager windowManager = (WindowManager)activity.getSystemService(Activity.WINDOW_SERVICE);\n\t\t\tint rotationIndex = windowManager.getDefaultDisplay().getRotation();\n\t\t\tAxisSwap axisSwap = m_axisSwapForRotation[rotationIndex];\n\t\t\tfloat fScreenX = ((float)axisSwap.m_negateX) * event.values[axisSwap.m_sourceX];\n\t\t\tfloat fScreenY = ((float)axisSwap.m_negateY) * event.values[axisSwap.m_sourceY];\n\t\t\tfloat fScreenZ = event.values[2];\n\n\t\t\t//the values provided by android are in ms^-2. Accelerometer values are more typically given in\n\t\t\t//terms of \"g\"'s so we are converting here. We are also converting from a x, y and z positive in the\n\t\t\t//left, up and backward directions respectively to right, up and forward directions to be more consistent with iOS.\n\t\t\tfinal float k_gravity = 9.80665f;\n\t\t\tfinal float k_accelerationX = -fScreenX / k_gravity;\n\t\t\tfinal float k_accelerationY = fScreenY / k_gravity;\n\t\t\tfinal float k_accelerationZ = -fScreenZ / k_gravity;\n\t\t\t\n\t\t\t//update acceleration on main thread.\n\t\t\tRunnable task = new Runnable()\n\t\t\t{ \n\t\t\t\t@Override public void run() \n\t\t\t\t{\n\t\t\t\t\tif (true == mbHasAccelerometer && true == mbListening)\n\t\t\t\t\t{\n\t\t\t            UpdateAcceleration(k_accelerationX, k_accelerationY, k_accelerationZ);\n\t\t\t        }\n\t\t\t\t}\n\t\t\t};\n\t\t\tCSApplication.get().scheduleMainThreadTask(task);\n\t\t}\n\t}\n\t//---------------------------------------------------\n\t/// Update Acceleration\n\t///\n\t/// Calls down to native to update the acceleration.\n\t///\n\t/// @param The x component of the acceleration.\n\t/// @param The y component of the acceleration.\n\t/// @param The z component of the acceleration.\n\t//---------------------------------------------------\n\tprivate native void UpdateAcceleration(float infAccelerationX, float infAccelerationY, float infAccelerationZ);\n\t//---------------------------------------------------\n\t/// Stop Listening\n\t///\n\t/// Stops listening for accelerometer events.\n\t//---------------------------------------------------\n\tpublic void StopListening()\n\t{\n\t\tif (true == mbHasAccelerometer && true == mbListening)\n\t\t{\n\t\t\tmbListening = false;\n\t\t\t\n\t\t\tfinal AccelerometerNativeInterface accelerometerNI = this;\n\t\t\tRunnable task = new Runnable()\n\t\t\t{ \n\t\t\t\t@Override public void run() \n\t\t\t\t{\n\t\t\t\t\tSensorManager sensorManager = (SensorManager)CSApplication.get().getActivityContext().getSystemService(Activity.SENSOR_SERVICE);\n\t\t\t\t\tsensorManager.unregisterListener(accelerometerNI);\n\t\t\t\t}\n\t\t\t};\n\t\t\tCSApplication.get().scheduleUIThreadTask(task);\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/Java/com/chilliworks/chillisource/input/DeviceButtonNativeInterface.java",
    "content": "/**\n * DeviceButtonJavaInterface.h\n * ChilliSource\n * Created by Ian Copland on 16/06/2014.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2014 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.input;\n\nimport com.chilliworks.chillisource.core.InterfaceId;\nimport com.chilliworks.chillisource.core.System;\n\n/**\n * A native interface for passing information on physical device buttons\n * down to the native side of the engine. For example this passes on\n * back button events.\n * \n * @author Ian Copland\n */\npublic final class DeviceButtonNativeInterface extends System\n{\n    public static InterfaceId INTERFACE_ID = new InterfaceId();\n\t\n\t/**\n\t * An enum describing the different possible device buttons. This\n\t * should have a direct 1 to 1 mapping with the equivalent in the\n\t * DeviceButtonSystem.\n\t * \n\t * @author Ian Copland\n\t */\n\tpublic enum DeviceButton\n\t{\n\t\tk_backButton\n\t}\n    /**\n     * Constructor\n     *\n     * @author Ian Copland\n     */\n    public DeviceButtonNativeInterface()\n    {\n        init();\n    }\n    /**\n     * Allows querying of whether or not the system implements the interface described by the\n     * given interface id.\n     *\n     * @author Ian Copland\n     *\n     * @param in_interfaceId - The interface id to check\n     *\n     * @return Whether the system implements the given interface\n     */\n    @Override public boolean isA(InterfaceId in_interfaceId)\n    {\n        return (in_interfaceId == INTERFACE_ID);\n    }\n\t/**\n\t * Called when a device button triggered event is received.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param The button the event was received for.\n\t */\n\tpublic void onTriggered(DeviceButton in_button) \n\t{\n\t\tonTriggered(in_button.ordinal());\n\t}\n\t/**\n\t * Called when a device button triggered event is triggered.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param An integer representing the button.\n\t */\n\tprivate native void onTriggered(int in_button);\n}\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/Java/com/chilliworks/chillisource/input/GyroscopeNativeInterface.java",
    "content": "/**\n * GyroscopeJavaInterface.java\n * ChilliSource\n * Created by Jordan Brown on 20/01/2017.\n *\n * The MIT License (MIT)\n *\n * Copyright (c) 2017 Tag Games Limited\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.input;\n\nimport android.app.Activity;\nimport android.content.pm.PackageManager;\nimport android.hardware.Sensor;\nimport android.hardware.SensorEvent;\nimport android.hardware.SensorEventListener;\nimport android.hardware.SensorManager;\nimport android.view.WindowManager;\n\nimport com.chilliworks.chillisource.core.*;\nimport com.chilliworks.chillisource.core.System;\n\n//=============================================================\n/// Gyroscope Native Interface\n///\n/// A native interface for interfacing with the Android\n/// gyroscope from native code.\n//=============================================================\npublic class GyroscopeNativeInterface extends System implements SensorEventListener\n{\n\n    //-----------------------------------------------------\n    /// Member data\n    //-----------------------------------------------------\n    public static InterfaceId INTERFACE_ID = new InterfaceId();\n\n    boolean mbListening = false;\n    boolean mbHasGyroscope = false;\n\n    Runnable mRunTask;\n    float[] mQuaternion = new float[4];\n    //-----------------------------------------------------\n    /// Constructor\n    //-----------------------------------------------------\n    public GyroscopeNativeInterface()\n    {\n        init();\n\n        PackageManager manager = CSApplication.get().getActivityContext().getPackageManager();\n        mbHasGyroscope = manager.hasSystemFeature(PackageManager.FEATURE_SENSOR_GYROSCOPE);\n\n        mRunTask = new Runnable()\n        {\n            @Override public void run()\n            {\n                if(true == mbHasGyroscope && true == mbListening)\n                {\n                    // Android stores quaternions with the w-term first\n                    //                     X                Y               Z               W\n                    UpdateOrientation(mQuaternion[1], mQuaternion[2], mQuaternion[3], mQuaternion[0]);\n                }\n            }\n        };\n\n    }\n    /**\n     * Allows querying of whether or not the system implements the interface described by the\n     * given interface id.\n     *\n     * @author Ian Copland\n     *\n     * @param in_interfaceId - The interface id to check\n     *\n     * @return Whether the system implements the given interface\n     */\n    @Override public boolean isA(InterfaceId in_interfaceId)\n    {\n        return (in_interfaceId == INTERFACE_ID);\n    }\n    //---------------------------------------------------\n    /// Is Available\n    ///\n    /// @return whether or not the gyroscope is\n    /// available on this device.\n    //---------------------------------------------------\n    public boolean IsAvailable()\n    {\n        return mbHasGyroscope;\n    }\n    //---------------------------------------------------\n    /// Start Listening\n    ///\n    /// Starts listening for gyroscope events.\n    //---------------------------------------------------\n    public void StartListening()\n    {\n        if (true == mbHasGyroscope && false == mbListening)\n        {\n            mbListening = true;\n\n            final GyroscopeNativeInterface gyroscopeNI = this;\n            Runnable task = new Runnable()\n            {\n                @Override public void run()\n                {\n                    SensorManager sensorManager = (SensorManager)CSApplication.get().getActivityContext().getSystemService(Activity.SENSOR_SERVICE);\n                    sensorManager.registerListener(gyroscopeNI, sensorManager.getDefaultSensor(Sensor.TYPE_GAME_ROTATION_VECTOR), SensorManager.SENSOR_DELAY_FASTEST);\n                }\n            };\n            CSApplication.get().scheduleUIThreadTask(task);\n        };\n    }\n    //---------------------------------------------------\n    /// On Accuracy Changed\n    ///\n    /// Called when the accuracy of a sensor has changed.\n    ///\n    /// @param The sensor that has had it's accuracy change.\n    /// @param The new accuracy value.\n    //---------------------------------------------------\n    @Override public void onAccuracyChanged(Sensor sensor, int accuracy)\n    {\n    }\n    //---------------------------------------------------\n    /// On Sensor Changed\n    ///\n    /// Called when sensor values have changed. NOTE: The\n    /// application doesn't own the event object passed as\n    /// a parameter and therefore cannot hold on to it.\n    /// The object may be part of an internal pool and\n    /// may be reused by the framework.\n    ///\n    /// @param The sensor event.\n    //---------------------------------------------------\n    @Override public void onSensorChanged(SensorEvent event)\n    {\n        if (Sensor.TYPE_GAME_ROTATION_VECTOR == event.sensor.getType())\n        {\n            SensorManager.getQuaternionFromVector(mQuaternion, event.values);\n\n            // Run orientation update task\n            CSApplication.get().scheduleMainThreadTask(mRunTask);\n        }\n    }\n    //---------------------------------------------------\n    /// Update Orientation\n    ///\n    /// Calls down to native to update the orientation.\n    ///\n    /// @param The x component of the orientation.\n    /// @param The y component of the orientation.\n    /// @param The z component of the orientation.\n    //---------------------------------------------------\n    private native void UpdateOrientation(float infOrientationX, float infOrientationY, float infOrientationZ, float infOrientationW);\n    //---------------------------------------------------\n    /// Stop Listening\n    ///\n    /// Stops listening for gyroscope events.\n    //---------------------------------------------------\n    public void StopListening()\n    {\n        if (true == mbHasGyroscope && true == mbListening)\n        {\n            mbListening = false;\n\n            final GyroscopeNativeInterface gyroscopeNI = this;\n            Runnable task = new Runnable()\n            {\n                @Override public void run()\n                {\n                    SensorManager sensorManager = (SensorManager)CSApplication.get().getActivityContext().getSystemService(Activity.SENSOR_SERVICE);\n                    sensorManager.unregisterListener(gyroscopeNI);\n                }\n            };\n            CSApplication.get().scheduleUIThreadTask(task);\n        }\n    }\n}\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/Java/com/chilliworks/chillisource/input/TextEntryNativeInterface.java",
    "content": "/**\n * TextEntryNativeInterface.java\n * ChilliSource\n * Created by Scott Downie 08/07/2014.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2014 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.input;\n\nimport android.content.Context;\nimport android.text.Editable;\nimport android.text.InputType;\nimport android.text.TextWatcher;\nimport android.view.KeyEvent;\nimport android.view.ViewGroup;\nimport android.view.animation.AlphaAnimation;\nimport android.view.inputmethod.EditorInfo;\nimport android.view.inputmethod.InputMethodManager;\nimport android.widget.EditText;\nimport android.widget.TextView;\nimport android.widget.TextView.OnEditorActionListener;\n\nimport com.chilliworks.chillisource.core.CSApplication;\nimport com.chilliworks.chillisource.core.InterfaceId;\nimport com.chilliworks.chillisource.core.System;\nimport com.chilliworks.chillisource.core.Logging;\n\n/**\n * Native interface that wraps a single text entry entity. The system \n * will track user text entry and notify native about any changes to the\n * text buffer\n * \n * @author S Downie\n *\n */\npublic final class TextEntryNativeInterface extends System implements TextWatcher, OnEditorActionListener\n{\n    public static InterfaceId INTERFACE_ID = new InterfaceId();\n\n\tprivate int m_keyboardTypeFlags = 0;\n\tprivate int m_keyboardCapitalisationFlags = 0;\n\tprivate EditTextBackEvent m_textEntryView;\n\t\n\t/** \n\t * Constructor\n\t * \n\t * @author S Downie\n\t */\n\tTextEntryNativeInterface()\n\t{\n        init();\n\n\t\tfinal TextEntryNativeInterface finalThis = this;\n\t\t\n\t\tRunnable task = new Runnable() \n\t\t{\n\t\t\t@Override public void run() \n\t\t\t{\n\t\t\t\t//Doesn't matter what we set this to it's invisible\n\t\t\t\tm_textEntryView = new EditTextBackEvent(CSApplication.get().getActivityContext());\n\t\t\t\tm_textEntryView.setWidth(100);\n\t\t\t\tm_textEntryView.setHeight(100);\n\t\t\t\t//Actually setting the alpha doesn't come in til API 11 so we have to animate it to zero\n\t\t\t\tint sdk = android.os.Build.VERSION.SDK_INT;\n\t\t\t\tif(sdk < android.os.Build.VERSION_CODES.JELLY_BEAN)\n\t\t\t\t{\n\t\t\t\t\tAlphaAnimation alpha = new AlphaAnimation(0.0f, 0.0f);\n\t\t\t\t\talpha.setDuration(0);\n\t\t\t\t\talpha.setFillAfter(true);\n\t\t\t\t\tm_textEntryView.startAnimation(alpha);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tm_textEntryView.setAlpha(0.0f);\n\t\t\t\t}\n\t\t\t\tm_textEntryView.addTextChangedListener(finalThis);\n\t\t\t\tm_textEntryView.setOnEditorActionListener(finalThis);\n\t\t\t}\n\t\t};\n\t\tCSApplication.get().scheduleUIThreadTask(task);\n\t}\n    /**\n     * Allows querying of whether or not the system implements the interface described by the\n     * given interface id.\n     *\n     * @author Ian Copland\n     *\n     * @param in_interfaceId - The interface id to check\n     *\n     * @return Whether the system implements the given interface\n     */\n    @Override public boolean isA(InterfaceId in_interfaceId)\n    {\n        return (in_interfaceId == INTERFACE_ID);\n    }\n\t/**\n\t * Activate text entry. This will display the soft keyboard if required\n\t * \n\t * @author S Downie\n\t */\n\tpublic void activate()\n\t{\n\t\tRunnable task = new Runnable()\n\t\t{\n\t\t\t@Override public void run()\n\t\t\t{\n\t\t\t\tCSApplication.get().addView(m_textEntryView);\n\t\t\t\tm_textEntryView.requestFocus();\n\t\t\t\tm_textEntryView.setSelection(m_textEntryView.getText().length());\n\t\t\t\tInputMethodManager imm = (InputMethodManager)CSApplication.get().getAppContext().getSystemService(Context.INPUT_METHOD_SERVICE);\n\t\t\t\timm.showSoftInput(m_textEntryView, InputMethodManager.SHOW_FORCED);\n\t\t\t}\n\t\t};\n\t\tCSApplication.get().scheduleUIThreadTask(task);\n\t}\n\t/**\n\t * Deactivate text entry. This will hide the soft keyboard if required\n\t * \n\t * @author S Downie\n\t */\n\tpublic void deactivate()\n\t{\n\t\tRunnable task = new Runnable() \n\t\t{\n\t\t\t@Override public void run() \n\t\t\t{\n\t\t\t\tdismiss();\n\t\t\t}\n\t\t};\n\t\tCSApplication.get().scheduleUIThreadTask(task);\n\t}\n\t/**\n\t * Sets the keyboard type that should be used the next the keyboard is displayed.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param Type as an integer (so it can be passed from native)\n\t */\n    public void setKeyboardType(final int in_type)\n    {\n\t\tRunnable task = new Runnable() \n\t\t{\n\t\t\t@Override public void run() \n\t\t\t{\n\t\t    \tm_keyboardTypeFlags = integerToKeyboardType(in_type);\n\t\t    \tm_textEntryView.setInputType(m_keyboardTypeFlags | m_keyboardCapitalisationFlags);\n\t\t\t}\n\t\t};\n\t\tCSApplication.get().scheduleUIThreadTask(task);\n    }\n\t/**\n\t * Sets the capitalisation method of the text buffer.\n\t * \n\t * @author Ian Copland\n\t * \n\t * @param Type as an integer (so it can be passed from native)\n\t */\n    public void setCapitalisationMethod(final int in_method)\n    {\n\t\tRunnable task = new Runnable() \n\t\t{\n\t\t\t@Override public void run() \n\t\t\t{\n\t\t    \tm_keyboardCapitalisationFlags = integerToKeyboardCapitalisation(in_method);\n\t\t    \tm_textEntryView.setInputType(m_keyboardTypeFlags | m_keyboardCapitalisationFlags);\n\t\t\t}\n\t\t};\n\t\tCSApplication.get().scheduleUIThreadTask(task);\n    }\n\t/** \n\t * @author S Downie\n\t * \n\t * @param The contents of the text buffer\n\t */\n\tpublic void setTextBuffer(final String in_text)\n\t{\n\t\tRunnable task = new Runnable() \n\t\t{\n\t\t\t@Override public void run() \n\t\t\t{\n\t\t\t\tm_textEntryView.setText(in_text);\n\t\t\t}\n\t\t};\n\t\tCSApplication.get().scheduleUIThreadTask(task);\n\t}\n\t/**\n\t * Called when the text string of the given editable has\n\t * changed\n\t * \n\t * @author S Downie\n\t * \n\t * @param Editable that has changed\n\t */\n\t@Override public void afterTextChanged(Editable in_editable) \n\t{\n\n\t}\n\t/**\n\t * Called when the text string of the given editable is\n\t * about to change\n\t * \n\t * @author S Downie\n\t * \n\t * @param String that is about to change\n\t * @param First character index that is about to change\n\t * @param Number of characters to change from start\n\t * @param Length of string after change\n\t */\n\t@Override public void beforeTextChanged(CharSequence in_string, int in_start, int in_count, int in_newLength) \n\t{\n\n\t}\n\t/**\n\t * Called when the text string of the given editable is\n\t * about to change\n\t * \n\t * @author S Downie\n\t * \n\t * @param String that has changed\n\t * @param First character index that changed\n\t * @param Number of characters changed from start\n\t * @param Length of string after change\n\t */\n\t@Override public void onTextChanged(CharSequence in_string, int in_start, int in_count, int in_newLength) \n\t{\n\t\tnativeOnTextChanged(in_string.toString());\n\t}\n\t/**\n\t * Called when the an IME key event\n\t * \n\t * @author S Downie\n\t * \n\t * @param Text view on which action occurred\n\t * @param Action code\n\t * @param Key event\n\t * \n\t * @return Whether the event has been handled\n\t */\n\t@Override public boolean onEditorAction(TextView in_view, int in_actionId, KeyEvent in_event)\n\t{\n        if (in_actionId == EditorInfo.IME_ACTION_DONE || in_actionId == EditorInfo.IME_ACTION_GO || in_actionId == EditorInfo.IME_ACTION_NEXT)\n        {\n\t\t\tdismiss();\n        \tnativeOnKeyboardDismissed();\n        \treturn true;\n        }\n        \n\t\treturn false;\n\t}\n\t/**\n\t * @author Ian Copland\n\t *\n\t * @param The keyboard type as an CS integer \n\t *\n\t * @return The input type flag required by Android.\n\t */\n\tprivate int integerToKeyboardType(int in_type)\n\t{\n\t\tswitch (in_type)\n\t\t{\n\t\t\tcase 0:\n\t\t\t\treturn InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_NORMAL | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS;\n\t\t\tcase 1:\n\t\t\t\treturn InputType.TYPE_CLASS_NUMBER;\n\t\t\tdefault:\n\t\t\t\tLogging.logError(\"Invalid keyboard type integer, cannot be converted.\");\n\t\t\t\treturn InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_NORMAL | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS;\n\t\t}\n\t}\n\t/**\n\t * @author Ian Copland\n\t *\n\t * @param The capitalisation method as an CS integer \n\t *\n\t * @return The capitalisation input type flag required by Android.\n\t */\n\tprivate int integerToKeyboardCapitalisation(int in_method)\n\t{\n\t\tswitch (in_method)\n\t\t{\n\t\t\tcase 0:\n\t\t\t\treturn 0;\n\t\t\tcase 1:\n\t\t\t\treturn InputType.TYPE_TEXT_FLAG_CAP_SENTENCES;\n\t\t\tcase 2:\n\t\t\t\treturn InputType.TYPE_TEXT_FLAG_CAP_WORDS;\n\t\t\tcase 3:\n\t\t\t\treturn InputType.TYPE_TEXT_FLAG_CAP_CHARACTERS;\n\t\t\tdefault:\n\t\t\t\tLogging.logError(\"Invalid keyboard capitalisation integer, cannot be converted.\");\n\t\t\t\treturn 0;\n\t\t}\n\t}\n\t/**\n\t * Dismiss the keyboard (Must only be called on UI thread)\n\t * \n\t * @author S Downie\n\t */\n\tprivate void dismiss()\n\t{\n\t\tViewGroup parent = (ViewGroup)m_textEntryView.getParent();\n\t\tif (parent != null)\n\t\t{\n\t\t\tparent.removeView(m_textEntryView);\n\t\t\tInputMethodManager imm = (InputMethodManager)CSApplication.get().getAppContext().getSystemService(Context.INPUT_METHOD_SERVICE);\n\t\t\timm.toggleSoftInput(0, 0);\n\t\t}\n\t}\n\t/**\n\t * Tells the native app that text has changed\n\t * \n\t * @author S Downie\n\t * \n\t * @param New text\n\t */\n\tnative private void nativeOnTextChanged(String in_text);\n\t/**\n\t * A native call for passing the keyboard dismissed\n\t * event down to the native side of the engine.\n\t * \n\t * @author S Downie\n\t */\n\tnative private void nativeOnKeyboardDismissed();\n\t\n\t/**\n\t * Extends EditText in order to detect when the keyboard has been dismissed\n\t * \n\t * @author S Downie\n\t */\n\tprivate final class EditTextBackEvent extends EditText\n\t{\n\t\t/**\n\t\t * Constructor\n\t\t * \n\t\t * @author S Downie\n\t\t * \n\t\t * @param Context\n\t\t */\n\t\tpublic EditTextBackEvent(Context in_context) \n\t\t{\n\t\t\tsuper(in_context);\n\t\t}\n\t\t/**\n\t\t * Called when the keyboard key event occurs prior to any system being notified\n\t\t * \n\t\t * @author S Downie\n\t\t * \n\t\t * @param key code\n\t\t * @param key event\n\t\t * \n\t\t * @return Whether the event has been handled\n\t\t */\n        @Override public boolean onKeyPreIme(int in_keyCode, KeyEvent in_event)\n        {\n            if (in_event.getKeyCode() == KeyEvent.KEYCODE_BACK || in_event.getKeyCode() == KeyEvent.FLAG_EDITOR_ACTION || in_event.getKeyCode() == KeyEvent.KEYCODE_ENTER)\n            {\n\t\t\t\tdismiss();\n            \tnativeOnKeyboardDismissed();\n            \treturn true;\n            }\n            \n            return super.onKeyPreIme(in_keyCode, in_event);\n        }\n\t}\n}\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/Java/com/chilliworks/chillisource/input/TouchInputNativeInterface.java",
    "content": "/**\n * TouchInputNativeInterface.java\n * ChilliSource\n * Created by Ian Copland on 05/05/2011.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2011 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.input;\n\npublic class TouchInputNativeInterface \n{\n\tpublic static native void TouchDown(int indwID, float infX, float infY);\n\tpublic static native void TouchUp(int indwID, float infX, float infY);\n\tpublic static native void TouchMoved(int indwID, float infX, float infY);\n}\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/Java/com/chilliworks/chillisource/networking/HttpRequest.java",
    "content": "/**\n * HttpRequest.java\n * ChilliSource\n * Created by HMcLaughlin on 31/07/2015.\n *\n * The MIT License (MIT)\n *\n * Copyright (c) 2011 Tag Games Limited\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.networking;\n\nimport android.os.Build;\n\nimport com.chilliworks.chillisource.core.BoxedPointer;\nimport com.chilliworks.chillisource.core.DynamicByteBuffer;\nimport com.chilliworks.chillisource.core.Logging;\n\nimport java.io.BufferedInputStream;\nimport java.io.BufferedOutputStream;\nimport java.io.EOFException;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.OutputStream;\nimport java.net.HttpURLConnection;\nimport java.net.SocketTimeoutException;\nimport java.net.URL;\nimport java.net.UnknownHostException;\n\nimport javax.net.ssl.HostnameVerifier;\nimport javax.net.ssl.HttpsURLConnection;\nimport javax.net.ssl.SSLContext;\nimport javax.net.ssl.X509TrustManager;\n\n/**\n * Class used to handle Java http functionality\n *\n * @author HMcLaughlin\n */\npublic final class HttpRequest\n{\n    static final private int SUCCESS = 0;\n    static final private int FAILED = 1;\n    static final private int TIMEOUT = 2;\n    static final private int FLUSHED = 3;\n\n    private final int k_dataBlockSize = 128;\n    private final int k_readTimeoutMilliSecs = 60000;\n\n    private X509TrustManager[] m_trustManagers;\n    private HostnameVerifier m_hostnameVerifier;\n\n    private BoxedPointer m_owner;\n\n    private volatile int m_downloadedDataSize = 0;\n    private int m_downloadSize = 0;\n\n    /**\n     * Called when the max buffer size is exceeded by an http request causing it\n     * to flush the current buffer contents to the application\n     *\n     * @author HMcLaughlin\n     *\n     * @param in_data - The partial response data that has been flushed\n     * @param in_dataLength - The length of the partial response data\n     * @param in_responseCode - The http reponse code\n     * @param in_objectPointer - The pointer information of the owning native object\n     */\n    private static native void onBufferFlushed(BoxedPointer in_objectPointer, byte[] in_data, int in_dataLength, int in_responseCode);\n    /**\n     * Called when the connection has finished sending data\n     *\n     * @author HMcLaughlin\n     *\n     * @param in_resultCode - Result code\n     * @param in_data - The partial response data that has been flushed\n     * @param in_dataLength - The length of the partial response data\n     * @param in_responseCode - The http reponse code\n     * @param in_objectPointer - The pointer information of the owning native object\n     */\n    private static native void onComplete(BoxedPointer in_objectPointer, int in_resultCode, byte[] in_data, int in_dataLength, int in_responseCode);\n\n    /**\n     * Constructor\n     *\n     * @author HMcLaughlin\n     *\n     * @param in_owner - Result code\n     */\n    public HttpRequest(BoxedPointer in_owner)\n    {\n        m_owner = in_owner;\n\n        m_trustManagers = new X509TrustManager[] {new InsecureTrustManager()};\n        m_hostnameVerifier = new InsecureHostnameVerifier();\n\n        HttpURLConnection.setFollowRedirects(true);\n    }\n    /**\n     * Http Request with headers\n     *\n     * Method accessible from native for processing a HTTP request\n     * including additional headers.\n     *\n     * @author HMcLaughlin\n     *\n     * @param in_url - The url\n     * @param in_isPost - Whether or not its a post request\n     * @param in_headerKeys - Array of key strings for headers\n     * @param in_headerValues - Array of value strings for headers\n     * @param in_body - The post body. Not used if in_isPost is false\n     * @param in_timeout - The connection timeout in seconds\n     * @param in_maxBufferSize - Download bytes before flushing\n     */\n    public void performHttpRequest(final String in_url, final boolean in_isPost, final String[] in_headerKeys,\n                                   final String[] in_headerValues, final String in_body, final int in_timeout, final int in_maxBufferSize)\n    {\n        //Run the polling of the connection in a background thread\n        Runnable httpTask =  new Runnable()\n        {\n            @Override\n            public void run()\n            {\n                performHttpRequestTask(in_url, in_isPost, in_headerKeys, in_headerValues, in_body, in_timeout, in_maxBufferSize);\n            }\n        };\n\n        (new Thread(httpTask)).start();\n    }\n    /**\n     * Http Request with headers\n     *\n     * Method accessible from native for processing a HTTP request\n     * including additional headers.\n     *\n     * @author HMcLaughlin\n     *\n     * @param in_url - The url\n     * @param in_isPost - Whether or not its a post request\n     * @param in_headerKeys - Array of key strings for headers\n     * @param in_headerValues - Array of value strings for headers\n     * @param in_body - The post body. Not used if in_isPost is false\n     * @param in_timeout - The connection timeout in seconds\n     * @param in_maxBufferSize - Download bytes before flushing\n     */\n    private void performHttpRequestTask(final String in_url, final boolean in_isPost, final String[] in_headerKeys,\n                                   final String[] in_headerValues, final String in_body, final int in_timeout, final int in_maxBufferSize)\n    {\n        int connectionTimeoutMs = in_timeout * 1000;\n\n        boolean retry = false;\n\n        do\n        {\n            retry = false;\n\n            try\n            {\n                System.setProperty(\"http.keepAlive\", \"true\");\n\n                // In 2.2 and below keep-alive is bugged, so force it off.\n                // Otherwise keep-alives are enabled by default\n                if (Build.VERSION.SDK_INT < Build.VERSION_CODES.GINGERBREAD)\n                {\n                    System.setProperty(\"http.keepAlive\", \"false\");\n                }\n\n                HttpURLConnection urlConnection = (HttpURLConnection) new URL(in_url).openConnection();\n\n                try\n                {\n                    urlConnection.setReadTimeout(k_readTimeoutMilliSecs);\n                    urlConnection.setConnectTimeout(connectionTimeoutMs);\n\n                    //if the protocol is HTTPS then set that up.\n                    if (in_url.startsWith(\"https\") == true)\n                    {\n                        SSLContext context = SSLContext.getInstance(\"TLS\");\n                        context.init(null, m_trustManagers, null);\n                        ((HttpsURLConnection) urlConnection).setSSLSocketFactory(context.getSocketFactory());\n                        ((HttpsURLConnection) urlConnection).setHostnameVerifier(m_hostnameVerifier);\n                    }\n\n                    //If we are posting we need to set up the post before opening the connection\n                    if (in_isPost == true)\n                    {\n                        urlConnection.setDoOutput(true);\n                        urlConnection.setFixedLengthStreamingMode(in_body.getBytes().length);\n                    }\n\n                    //--Set headers\n                    if ((in_headerKeys != null) && (in_headerValues != null) && (in_headerKeys.length == in_headerValues.length))\n                    {\n                        // Headers are passed in as a key/value strings array\n                        for (int i = 0; i < in_headerKeys.length; i++)\n                        {\n                            urlConnection.setRequestProperty(in_headerKeys[i], in_headerValues[i]);\n                        }\n                    }\n\n                    urlConnection.connect();\n                    //if this is a post request then set the body\n                    if (in_isPost == true)\n                    {\n                        byte[] abyOutData = in_body.getBytes();\n                        OutputStream writer = new BufferedOutputStream(urlConnection.getOutputStream());\n                        writer.write(abyOutData);\n                        writer.flush();\n                        writer.close();\n                    }\n\n                    int dwResponseCode = urlConnection.getResponseCode();\n                    if (dwResponseCode == -1)\n                    {\n                        //If we've got this far and the response code is -1 then we've encountered the dreaded 2.2 bug!\n                        //In order to get around this, we should return a fake 503 error to force the client to try the call again.\n                        onFailed(FAILED, 503);\n                    }\n                    else\n                    {\n                        m_downloadSize = urlConnection.getContentLength();\n\n                        // Get the response (either by InputStream or ErrorStream)\n                        readStream(dwResponseCode, in_maxBufferSize, urlConnection);\n                    }\n                }\n                catch (UnknownHostException eUnknownHostException)\n                {\n                    onFailed(TIMEOUT, urlConnection.getResponseCode());\n                    Logging.logError(eUnknownHostException.getMessage());\n                }\n                catch (SocketTimeoutException timeoutException)\n                {\n                    onFailed(TIMEOUT, urlConnection.getResponseCode());\n                    Logging.logError(timeoutException.getMessage());\n                }\n                catch (EOFException eofException)\n                {\n                    onFailed(TIMEOUT, urlConnection.getResponseCode());\n                    Logging.logError(eofException.getMessage());\n                }\n                catch (Exception eConnectionException)\n                {\n                    onFailed(FAILED, urlConnection.getResponseCode());\n                    Logging.logError(eConnectionException.getMessage());\n                }\n                finally\n                {\n                    //Disconnect the url connection. Note, this does not necessarily close the connection, possibly simply returning it to a pool of open connections for reuse.\n                    urlConnection.disconnect();\n                }\n            }\n            catch (Exception eUrlException)\n            {\n                if (eUrlException.getMessage().contains(\"ECONNRESET\"))\n                {\n                    retry = true;\n                    continue;\n                }\n\n                onFailed(FAILED, 404);\n                Logging.logError(eUrlException.getMessage());\n            }\n\n        } while (retry);\n    }\n    /**\n     * @author HMcLaughlin\n     *\n     * @return Total size of the download, can be 0\n     */\n    public long getExpectedSize()\n    {\n        return m_downloadSize;\n    }\n    /**\n     * @author HMcLaughlin\n     *\n     * @return Total current downloaded size\n     */\n    public long getDownloadedBytes()\n    {\n        return m_downloadedDataSize;\n    }\n    /**\n     * Reads data from the url connection until complete/failed\n     *\n     * @author HMcLaughlin\n     *\n     * @param in_responseCode - Reponse Code\n     * @param in_maxBufferSize - Max buffer size\n     * @param in_connection - URL Connection\n     *\n     * @throws IOException\n     */\n    private void readStream(int in_responseCode, int in_maxBufferSize, HttpURLConnection in_connection) throws IOException\n    {\n        DynamicByteBuffer byteContainer = new DynamicByteBuffer(k_dataBlockSize);\n        byte[] byDataBlock = new byte[k_dataBlockSize];\n        byte[] abyOutputData = null;\n\n        int dwAmountRead = 0;\n        int currentBufferSize = 0;\n        InputStream reader = null;\n        try\n        {\n            // Check for http 200 or 301\n            if (in_responseCode == HttpURLConnection.HTTP_OK || in_responseCode == HttpURLConnection.HTTP_MOVED_PERM)\n            {\n                dwAmountRead = in_connection.getInputStream().read(byDataBlock);\n                reader = new BufferedInputStream(in_connection.getInputStream());\n            }\n            // Check for http 500\n            else if(in_responseCode == HttpsURLConnection.HTTP_INTERNAL_ERROR || in_responseCode == HttpsURLConnection.HTTP_UNAVAILABLE)\n            {\n                dwAmountRead = in_connection.getErrorStream().read(byDataBlock);\n                reader = new BufferedInputStream(in_connection.getErrorStream());\n            }\n\n            if(reader != null)\n            {\n                // Keep reading until the end has been found\n                while (dwAmountRead != -1)\n                {\n                    if(in_maxBufferSize > 0 && currentBufferSize + dwAmountRead >= in_maxBufferSize)\n                    {\n                        //Flush the buffer\n                        onBufferFlushed(m_owner, byteContainer.getInternalBuffer(), byteContainer.getByteCount(), in_responseCode);\n                        currentBufferSize = 0;\n                        byteContainer.clear();\n                    }\n\n                    addDownloadProgress(dwAmountRead);\n\n                    byteContainer.appendBytes(byDataBlock, dwAmountRead);\n                    currentBufferSize += dwAmountRead;\n                    dwAmountRead = reader.read(byDataBlock);\n                }\n\n                reader.close();\n            }\n\n            onComplete(m_owner, SUCCESS, byteContainer.getInternalBuffer(), byteContainer.getByteCount(), in_responseCode);\n        }\n        catch(IOException eIOException)\n        {\n            if(reader != null)\n                reader.close();\n\n            onFailed(FAILED, in_responseCode);\n        }\n    }\n    /**\n     * Called when the connection fails for any reason\n     *\n     * @author HMcLaughlin\n     *\n     * @param in_result - Result Code\n     * @param in_respose - Response Code\n     */\n    private void onFailed(int in_result, int in_respose)\n    {\n        onComplete(m_owner, in_result, null, 0, in_respose);\n    }\n    /**\n     * Used to safely append downloaded bytes to the total downloaded data\n     *\n     * @author HMcLaughlin\n     *\n     * @param in_downloadProgressBytes - Downloaded data size\n     */\n    private void addDownloadProgress(int in_downloadProgressBytes)\n    {\n        m_downloadedDataSize += in_downloadProgressBytes;\n    }\n}\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/Java/com/chilliworks/chillisource/networking/HttpRequestSystem.java",
    "content": "/**\n * HttpRequestSystem.java\n * ChilliSource\n * Created by HMcLaughlin on 04/08/2015.\n *\n * The MIT License (MIT)\n *\n * Copyright (c) 2015 Tag Games Limited\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.networking;\n\nimport android.app.Activity;\nimport android.content.Context;\nimport android.net.ConnectivityManager;\nimport android.net.NetworkInfo;\n\nimport com.chilliworks.chillisource.core.CSApplication;\nimport com.chilliworks.chillisource.core.InterfaceId;\nimport com.chilliworks.chillisource.core.System;\n\n/**\n * A system to handle HTTP connection related queries\n *\n * @author HMcLaughlin\n */\npublic final class HttpRequestSystem extends System\n{\n    public static InterfaceId INTERFACE_ID = new InterfaceId();\n\n    /**\n     * Constructor\n     *\n     * @author HMcLaughlin\n     */\n    public HttpRequestSystem()\n    {\n    }\n    /**\n     * Allows querying of whether or not the system implements the interface described by the\n     * given interface id.\n     *\n     * @author HMcLaughlin\n     *\n     * @param in_interfaceId - The interface id to check\n     *\n     * @return Whether the system implements the given interface\n     */\n    @Override public boolean isA(InterfaceId in_interfaceId)\n    {\n        return (in_interfaceId == INTERFACE_ID);\n    }\n    /**\n     * Function to test whether or not the device is connected to\n     * the Internet.\n     *\n     * @author HMcLaughlin\n     *\n     * @return Whether an network connection is available\n     */\n    public boolean isConnected()\n    {\n        Activity activity = CSApplication.get().getActivity();\n        ConnectivityManager cm = (ConnectivityManager) activity.getSystemService(Context.CONNECTIVITY_SERVICE);\n        NetworkInfo netInfo = cm.getActiveNetworkInfo();\n        if (netInfo != null && netInfo.isConnected())\n        {\n            return true;\n        }\n        return false;\n    }\n}\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/Java/com/chilliworks/chillisource/networking/IAPProductDescription.java",
    "content": "/**\n * IAPProductDescription.java\n * ChilliSource\n * Created by Ian Copland on 22/05/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.networking;\n\npublic class IAPProductDescription\n{\n\tpublic String ID;\n\tpublic String Name;\n\tpublic String Description;\n\tpublic String FormattedPrice;\n}\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/Java/com/chilliworks/chillisource/networking/IAPTransactionDescription.java",
    "content": "/**\n * IAPTransactionDescription.java\n * ChilliSource\n * Created by Ian Copland on 22/05/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.networking;\n\npublic class IAPTransactionDescription\n{\n\tpublic String ProductID;\n\tpublic String TransactionID;\n\tpublic String Receipt;\n\n\tpublic final static int SUCCEEDED = 0;\n\tpublic final static int FAILED = 1;\n\tpublic final static int CANCELLED = 2;\n\tpublic final static int RESTORED = 3;\n\tpublic final static int RESUMED = 4;\n\tpublic final static int REFUNDED = 5;\n}\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/Java/com/chilliworks/chillisource/networking/InsecureHostnameVerifier.java",
    "content": "/**\n * InsecureHostnameVerifier.java\n * ChilliSource\n * Created by Ian Copland on 01/09/2011.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2011 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.networking;\n\nimport javax.net.ssl.HostnameVerifier;\nimport javax.net.ssl.SSLSession;\n\n//===================================================================\n/// Insecure Hostname Verifier\n///\n/// a host name verifier than always confirms the hostname\n//===================================================================\npublic class InsecureHostnameVerifier implements HostnameVerifier \n{\n\t@Override\n\tpublic boolean verify(String hostname, SSLSession session) \n\t{\n\t\treturn true;\n\t}\n}\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/Java/com/chilliworks/chillisource/networking/InsecureTrustManager.java",
    "content": "/**\n * InsecureTrustManager.java\n * ChilliSource\n * Created by Ian Copland on 01/09/2011.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2011 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.networking;\n\nimport java.security.cert.CertificateException;\nimport java.security.cert.X509Certificate;\n\nimport javax.net.ssl.X509TrustManager;\n\n//===================================================================\n/// Insecure Trust Manager\n///\n/// a trust manager than \"trusts\" all certificates.\n//===================================================================\npublic class InsecureTrustManager implements X509TrustManager\n{\n\t@Override\n\tpublic void checkClientTrusted(X509Certificate[] arg0, String arg1) throws CertificateException \n\t{}\n\n\t@Override\n\tpublic void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException \n\t{}\n\n\t@Override\n\tpublic X509Certificate[] getAcceptedIssuers() \n\t{\n\t\treturn null;\n\t}\n}\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/Java/com/chilliworks/chillisource/social/EmailComposerNativeInterface.java",
    "content": "/**\n * EmailComposerNativeInterface.java\n * ChilliSource\n * Created by Steven Hendrie on 14/08/2012.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2012 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.social;\n\nimport java.io.File;\n\nimport com.chilliworks.chillisource.core.CSApplication;\nimport com.chilliworks.chillisource.core.InterfaceId;\nimport com.chilliworks.chillisource.core.System;\nimport com.chilliworks.chillisource.core.Logging;\n\nimport android.app.Activity;\nimport android.content.Intent;\nimport android.net.Uri;\nimport android.text.Html;\n\n//=============================================================\n/// Email Composition Native Interface\n///\n/// Native interface for sending email intents. This is capable\n/// of sending emails to multiple recipients and sending \n/// multiple attachments.\n//=============================================================\npublic class EmailComposerNativeInterface extends System\n{\n\t//--------------------------------------------------------------\n\t/// Member Data\n\t//--------------------------------------------------------------\n    public static InterfaceId INTERFACE_ID = new InterfaceId();\n\n\tprivate static final int EMAIL_RETURN_REQUEST = 0;\n\tprivate boolean mbActive = false;\n\t//--------------------------------------------------------------\n\t/// Constructor\n\t//--------------------------------------------------------------\n\tpublic EmailComposerNativeInterface()\n\t{\n        init();\n\t}\n    /**\n     * Allows querying of whether or not the system implements the interface described by the\n     * given interface id.\n     *\n     * @author Ian Copland\n     *\n     * @param in_interfaceId - The interface id to check\n     *\n     * @return Whether the system implements the given interface\n     */\n    @Override public boolean isA(InterfaceId in_interfaceId)\n    {\n        return (in_interfaceId == INTERFACE_ID);\n    }\n\t//-----------------------------------------------\n\t/// Present\n\t///\n\t/// Presents the user with the email interface\n\t///\n\t/// @param vector of email addresses\n\t/// @param subject line\n\t/// @param content\n\t/// @param The filename of the attachement if there is one.\n\t/// @param bool if to format as html\n\t//-----------------------------------------------\n\tpublic void Present(String[] inastrRecipientAddresses, String instrSubject, String instrContents, boolean inbFormatAsHtml, String instrAttachmentFilename)\n\t{  \n\t\tif (mbActive == false)\n\t\t{\n\t\t\tmbActive = true;\n\t\t\t\n\t\t\tIntent emailIntent = new Intent(android.content.Intent.ACTION_SEND); \n\t\t\t\n\t\t\temailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, inastrRecipientAddresses); \n\t\t\temailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, instrSubject);\n\t\t\t\n\t\t\tif(inbFormatAsHtml)\n\t\t\t{\n\t\t\t\temailIntent.setType(\"text/html\");\n\t\t\t\temailIntent.putExtra(android.content.Intent.EXTRA_TEXT, Html.fromHtml(instrContents));\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\temailIntent.setType(\"text/plain\");\n\t\t\t\temailIntent.putExtra(android.content.Intent.EXTRA_TEXT, instrContents);\n\t\t\t}\n\t\t\t\n\t\t\t//add attachment if there is one\n\t\t\tif (instrAttachmentFilename.length() > 0)\n\t\t\t{\n\t\t\t\ttry\n\t\t\t\t{\n\t\t\t\t\tUri uri = Uri.fromFile(new File(instrAttachmentFilename));\n\t\t\t\t\temailIntent.putExtra(android.content.Intent.EXTRA_STREAM, uri);\n\t\t\t\t}\n\t\t\t\tcatch (Exception e)\n\t\t\t\t{\n\t\t\t\t\tLogging.logError(\"Failed to attach file '\" + instrAttachmentFilename + \"' to Send intent!\");\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tCSApplication.get().getActivity().startActivityForResult(emailIntent, EMAIL_RETURN_REQUEST);\n\t\t}\n\t}\n\t//------------------------------------------------------\n\t/// On Activity Result\n\t///\n\t/// Called from the activity upon receiving\n\t/// an intent result\n\t///\n\t/// @param Request Code\n\t/// @param Result Code\n\t/// @param Intent\n\t//------------------------------------------------------\n\t@Override public void onActivityResult(int indwRequestCode, int indwResultCode, Intent inData)\n\t{\n\t\tif (mbActive == true && indwRequestCode == EmailComposerNativeInterface.EMAIL_RETURN_REQUEST)\n\t\t{\n\t\t\tmbActive = false;\n\t\t\t// We are hard coding the result code to OK because the email clients never return this code and\n\t\t\t// RESULT_CANCELED is chosen by default by the activity in the absence of actual code\n\t\t\t// We therefore can't detect if the email has ever been sent or cancelled. It is preferable to set it to sent in doubt\n\t\t\tOnEmailClosed(Activity.RESULT_OK); \n\t\t}\n\t}\n\t//--------------------------------------------\n\t/// On Email Closed\n\t///\n\t/// Receives when email client has been closed\n\t//--------------------------------------------\n\tnative public void OnEmailClosed(int indwResultCode);\n}\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/Java/com/chilliworks/chillisource/video/SubtitlesView.java",
    "content": "/**\n * SubtitlesView.java\n * ChilliSource\n * Created by Ian Copland on 25/02/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.video;\n\nimport java.util.HashMap;\nimport java.util.Map;\n\nimport com.chilliworks.chillisource.core.CSApplication;\nimport com.chilliworks.chillisource.core.Logging;\n\nimport android.content.Context;\nimport android.graphics.Canvas;\nimport android.graphics.Color;\nimport android.util.DisplayMetrics;\nimport android.view.Gravity;\nimport android.view.ViewGroup;\nimport android.widget.LinearLayout;\nimport android.widget.TextView;\n\n//=============================================================\n/// Subtitles View\n///\n/// A view for displaying subtitles. This is typically displayed\n/// over the video player view.\n//=============================================================\npublic class SubtitlesView extends ViewGroup\n{\t\n\t//----------------------------------------------------------\n\t/// Subtitle\n\t///\n\t/// All information required to display a single subtitle.\n\t//----------------------------------------------------------\n\tclass BoundsInfo\n\t{\n\t\tfloat fCentreX;\n\t\tfloat fCentreY;\n\t\tfloat fWidth;\n\t\tfloat fHeight;\n\t}\n\t//----------------------------------------------------------\n\t/// Member data\n\t//----------------------------------------------------------\n\tprivate VideoPlayer mVideoPlayer = null;\n\tprivate HashMap<Long, TextView> mTextViewMap = new HashMap<Long, TextView>();\n\tprivate HashMap<Long, BoundsInfo> mSubtitleMap = new HashMap<Long, BoundsInfo>();\n\tprivate long mlwNextID = 0;\n\t//----------------------------------------------------------\n\t/// Constructor\n\t//----------------------------------------------------------\n\tpublic SubtitlesView(Context context) \n\t{\n\t\tsuper(context);\n\t\tmVideoPlayer = (VideoPlayer)CSApplication.get().getSystem(VideoPlayer.INTERFACE_ID);\n\t\tif (mVideoPlayer == null)\n\t\t{\n\t\t\tLogging.logError(\"Could not get the video player native interface!\");\n\t\t}\n\t\t\n\t\tsetWillNotDraw(false);\n\t}\n\t//--------------------------------------------------------------\n\t/// Create Subtitle\n\t///\n\t/// Creates a new subtitle to be displayed over the video.\n\t///\n\t/// @param The subtitle text.\n\t/// @param The name of the font to be used.\n\t/// @param The font size.\n\t/// @param The text alignment.\n\t/// @param The X position.\n\t/// @param the Y position.\n\t/// @param The width.\n\t/// @param The height.\n\t/// @output the ID of the new subtitle.\n\t//--------------------------------------------------------------\n\tpublic long CreateSubtitle(String instrText, String instrFontName, int indwFontSize, String instrAlignment, float infCentreX, float infCentreY, float infWidth, float infHeight)\n\t{\n\t\tlong lwID = mlwNextID++;\n\t\t\n\t\t//create new subtitle info\n\t\tBoundsInfo info = new BoundsInfo();\n\t\tinfo.fCentreX = infCentreX;\n\t\tinfo.fCentreY = infCentreY;\n\t\tinfo.fWidth = infWidth;\n\t\tinfo.fHeight = infHeight;\n\t\tmSubtitleMap.put(lwID, info);\n\t\t\n\t\t//create a new text view\n\t\tDisplayMetrics metrics = new DisplayMetrics();\n\t\tVideoPlayerActivity.GetActivity().getWindowManager().getDefaultDisplay().getMetrics(metrics);\n\t\tTextView textView = new TextView(getContext());\n\t\ttextView.setText(instrText);\n\t\ttextView.setTextSize(indwFontSize);\n\t\ttextView.setTextColor(Color.TRANSPARENT);\n\t\tSetTextAlignment(textView, instrAlignment);\n\t\taddView(textView);\n\t\tmTextViewMap.put(lwID, textView);\n\t\treturn lwID;\n\t}\n\t//--------------------------------------------------------------\n\t/// Set Subtitle Colour\n\t///\n\t/// Changes the colour of a currently active subtitle.\n\t///\n\t/// @param The subtitle object.\n\t/// @param Red.\n\t/// @param Green.\n\t/// @param Blue.\n\t/// @param Alpha.\n\t//--------------------------------------------------------------\n\tpublic void SetSubtitleColour(long inlwSubtitleID, float infRed, float infGreen, float infBlue, float infAlpha) \n\t{\n\t\tTextView textView = mTextViewMap.get(inlwSubtitleID);\n\t\tif (textView != null)\n\t\t{\n\t\t\ttextView.setTextColor(Color.argb((int)(infAlpha * 255.0), (int)(infRed * 255.0), (int)(infGreen * 255.0), (int)(infBlue * 255.0)));\n\t\t}\n\t}\n\t//--------------------------------------------------------------\n\t/// Remove Subtitle\n\t///\n\t/// Removes the given subtitle from the video.\n\t///\n\t/// @param The subtitle object.\n\t//--------------------------------------------------------------\n\tpublic void RemoveSubtitle(long inlwSubtitleID) \n\t{\n\t\tTextView textView = mTextViewMap.get(inlwSubtitleID);\n\t\tif (textView != null)\n\t\t{\n\t\t\tremoveView(textView);\n\t\t\tmTextViewMap.remove(inlwSubtitleID);\n\t\t}\n\t}\n\t//--------------------------------------------------------------\n\t/// Draw\n\t///\n\t/// This is called every time the view is invalidated. To insure\n\t/// This happens every frame, this calls postInvalidate.\n\t//--------------------------------------------------------------\n\t@Override public void onDraw(Canvas inCanvas)\n\t{\n\t\tmVideoPlayer.updateSubtitles();\n\t\tpostInvalidate();\n\t}\n\t//--------------------------------------------------------------\n\t/// On Layout\n\t///\n\t/// Positions all subviews.\n\t//--------------------------------------------------------------\n\t@Override protected void onLayout(boolean inbChanged, int indwLeft, int indwTop, int indwRight, int indwBottom)\n\t{\n\t\tint dwWidth = indwRight - indwLeft;\n\t\tint dwHeight = indwBottom - indwTop;\n\t\tfor (Map.Entry<Long, TextView> textView : mTextViewMap.entrySet())\n\t\t{\n\t\t\tBoundsInfo boundsInfo = mSubtitleMap.get(textView.getKey());\n\n            // Converting from origin at bottom-left to top-left\n            float fRelativeLeft = boundsInfo.fCentreX - boundsInfo.fWidth * 0.5f;\n            float fRelativeTop = 1.0f - boundsInfo.fCentreY - boundsInfo.fHeight * 0.5f;\n            float fRelativeRight = boundsInfo.fCentreX + boundsInfo.fWidth * 0.5f;\n            float fRelativeBottom = 1.0f - boundsInfo.fCentreY + boundsInfo.fHeight * 0.5f;\n\n            int dwAbsoluteLeft = (int)(dwWidth * fRelativeLeft);\n\t\t\tint dwAbsoluteTop = (int)(dwHeight * fRelativeTop);\n            int dwAbsoluteRight = (int)(dwWidth * fRelativeRight);\n            int dwAbsoluteBottom = (int)(dwHeight * fRelativeBottom);\n\n\t\t\ttextView.getValue().measure(MeasureSpec.makeMeasureSpec(dwAbsoluteRight - dwAbsoluteLeft, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(dwAbsoluteBottom - dwAbsoluteTop, MeasureSpec.EXACTLY));\n\t\t\ttextView.getValue().layout(dwAbsoluteLeft, dwAbsoluteTop, dwAbsoluteRight, dwAbsoluteBottom);\n\t\t}\n\t}\n\t//--------------------------------------------------------------\n\t/// Set Text Alignment\n\t///\n\t/// Tests the alignment in the given text view.\n\t///\n\t/// @param The text view\n\t/// @param the alignment in string form.\n\t//--------------------------------------------------------------\n\tprivate void SetTextAlignment(TextView inTextView, String instrAlignment) \n\t{\n\t\tint dwGravity = Gravity.NO_GRAVITY;\n\t\tif (instrAlignment.equalsIgnoreCase(\"TopLeft\") == true)\n\t\t{\n\t\t\tdwGravity = Gravity.TOP | Gravity.LEFT;\n\t\t}\n\t\telse if (instrAlignment.equalsIgnoreCase(\"TopCentre\") == true)\n\t\t{\n\t\t\tdwGravity = Gravity.TOP | Gravity.CENTER_HORIZONTAL;\n\t\t}\n\t\telse if (instrAlignment.equalsIgnoreCase(\"TopRight\") == true)\n\t\t{\n\t\t\tdwGravity = Gravity.TOP | Gravity.RIGHT;\n\t\t}\n\t\telse if (instrAlignment.equalsIgnoreCase(\"MiddleLeft\") == true)\n\t\t{\n\t\t\tdwGravity = Gravity.CENTER_VERTICAL | Gravity.LEFT;\n\t\t}\n\t\telse if (instrAlignment.equalsIgnoreCase(\"MiddleCentre\") == true)\n\t\t{\n\t\t\tdwGravity = Gravity.CENTER;\n\t\t}\n\t\telse if (instrAlignment.equalsIgnoreCase(\"MiddleRight\") == true)\n\t\t{\n\t\t\tdwGravity = Gravity.CENTER_VERTICAL | Gravity.RIGHT;\n\t\t}\n\t\telse if (instrAlignment.equalsIgnoreCase(\"BottomLeft\") == true)\n\t\t{\n\t\t\tdwGravity = Gravity.BOTTOM | Gravity.LEFT;\n\t\t}\n\t\telse if (instrAlignment.equalsIgnoreCase(\"BottomCentre\") == true)\n\t\t{\n\t\t\tdwGravity = Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL;\n\t\t}\n\t\telse if (instrAlignment.equalsIgnoreCase(\"BottomRight\") == true)\n\t\t{\n\t\t\tdwGravity = Gravity.BOTTOM | Gravity.RIGHT;\n\t\t}\n\t\tinTextView.setGravity(dwGravity);\n        LinearLayout.LayoutParams newParameters = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);\n        newParameters.gravity = dwGravity;\n        inTextView.setLayoutParams(newParameters);\n\t}\n}\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/Java/com/chilliworks/chillisource/video/VideoPlayer.java",
    "content": "/**\n * VideoPlayer.java\n * ChilliSource\n * Created by Ian Copland on 10/08/2012.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2012 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.video;\n\nimport android.content.Intent;\n\nimport com.chilliworks.chillisource.core.CSApplication;\nimport com.chilliworks.chillisource.core.InterfaceId;\nimport com.chilliworks.chillisource.core.System;\n\n/**\n * A system which is used to present full screen video from native. This launches a new activity\n * over the OpenGL activity and uses this to play the video in a new view.\n *\n * @author Ian Copland\n */\npublic class VideoPlayer extends System\n{\n    public static InterfaceId INTERFACE_ID = new InterfaceId();\n\n\tprivate boolean m_updateSubtitlesEvent = false;\n\n    /**\n     * Allows querying of whether or not the system implements the interface described by the\n     * given interface id.\n     *\n     * @author Ian Copland\n     *\n     * @param in_interfaceId - The interface id to check\n     *\n     * @return Whether the system implements the given interface\n     */\n    @Override public boolean isA(InterfaceId in_interfaceId)\n    {\n        return (in_interfaceId == INTERFACE_ID);\n    }\n\t/**\n\t * Presents a video. Videos can be played from file in external storage, from inside the APK\n\t * or from inside another file. To play a file from within another (i.e from within a zip other\n\t * than the APK) the file offset and length should be set. If playing from a zip then the video\n\t * file must not be compressed.\n\t *\n\t * This is thread-safe.\n\t *\n\t * @param in_inApk - Whether or not the file is inside the APK.\n\t * @param in_filePath - The path to the video file or the file which contains the video file.\n\t * @param in_fileOffset - The offset into the file that the video file is located at. This should\n\t * be -1 if the file is a video file.\n\t * @param in_fileLength - The length of the video file. This should be -1 if the file is a video\n\t * file.\n\t * @param in_dismissWhenTapped - Whether or not the video activity can be dismissed by a tap.\n\t * @param in_hasSubtitles - Whether or not the video has subtitles.\n\t * @param in_bgColourR - the red component of the background colour.\n\t * @param in_bgColourG - the green component of the background colour.\n\t * @param in_bgColourB - the blue component of the background colour.\n\t * @param in_bgColourA - the alpha component of the background colour.\n\t */\n\tpublic void present(boolean in_inApk, String in_filePath, int in_fileOffset, int in_fileLength, boolean in_dismissWhenTapped, boolean in_hasSubtitles,\n\t\t\t\t\t\tfloat in_bgColourR, float in_bgColourG, float in_bgColourB, float in_bgColourA)\n\t{\n\t\tVideoPlayerActivity.setVideoInfo(in_inApk, in_filePath, in_fileOffset, in_fileLength, in_dismissWhenTapped, in_hasSubtitles, in_bgColourR, in_bgColourG, in_bgColourB, in_bgColourA);\n\t\tIntent mediaPlayerIntent = new Intent(CSApplication.get().getActivityContext(), VideoPlayerActivity.class);\n\t\tCSApplication.get().getActivityContext().startActivity(mediaPlayerIntent);\n\t}\n\t/**\n\t * This is thread-safe.\n\t *\n\t * @author Ian Copland\n\t *\n\t * @return The current playback position through the video, in seconds.\n\t */\n\tpublic float getPlaybackPosition()\n\t{\n\t\tVideoPlayerActivity activity = VideoPlayerActivity.GetActivity();\n\t\tif (activity != null)\n\t\t{\n\t\t\tVideoPlayerView view = activity.GetVideoPlayerView();\n\t\t\tif (view != null)\n\t\t\t{\n\t\t\t\treturn ((float)view.GetTime()) / 1000.0f;\n\t\t\t}\n\t\t}\n\t\treturn 0.0f;\n\t}\n\t/**\n\t * Creates a new subtitle which will be displayed over the playing video.\n\t *\n\t * This must be called during the \"Update Subtitles\" event.\n\t *\n\t * @author Ian Copland\n\t *\n\t * @param in_text - The subtitle text.\n\t * @param in_fontName - The name of the font to be used.\n\t * @param in_fontSize - The font size.\n\t * @param in_alignment - The text alignment.\n\t * @param in_x - The X position of the rect the text will be located in.\n\t * @param in_y - The Y position of the rect the text will be located in.\n\t * @param in_width - The width of the rect the text will be located in.\n\t * @param in_height - The height of the rect the text will be located in.\n\t *\n\t * @return The Id of the created subtitle.\n\t */\n\tpublic long createSubtitle(String in_text, String in_fontName, int in_fontSize, String in_alignment, float in_x, float in_y, float in_width, float in_height)\n\t{\n\t\tassert (m_updateSubtitlesEvent == true) : \"Cannot only be called during the Update Subtitles event.\";\n\n\t\tVideoPlayerActivity activity = VideoPlayerActivity.GetActivity();\n\t\tif (activity != null)\n\t\t{\n\t\t\tSubtitlesView view = activity.GetSubtitlesView();\n\t\t\tif (view != null)\n\t\t\t{\n\t\t\t\treturn view.CreateSubtitle(in_text, in_fontName, in_fontSize, in_alignment, in_x, in_y, in_width, in_height);\n\t\t\t}\n\t\t}\n\t\treturn -1;\n\t}\n\t/**\n\t * Sets the colour of the subtitle with the given Id.\n\t *\n\t * This must be called during the \"Update Subtitles\" event.\n\t *\n\t * @author Ian Copland\n\t *\n\t * @param in_subtitleId - The Id of the subtitle object.\n\t * @param in_red - The red component of the subtitle colour.\n\t * @param in_green - The red component of the subtitle colour.\n\t * @param in_blue - The red component of the subtitle colour.\n\t * @param in_alpha - The red component of the subtitle colour.\n\t */\n\tpublic void setSubtitleColour(long in_subtitleId, float in_red, float in_green, float in_blue, float in_alpha)\n\t{\n\t\tassert (m_updateSubtitlesEvent == true) : \"Cannot only be called during the Update Subtitles event.\";\n\n\t\tVideoPlayerActivity activity = VideoPlayerActivity.GetActivity();\n\t\tif (activity != null)\n\t\t{\n\t\t\tSubtitlesView view = activity.GetSubtitlesView();\n\t\t\tif (view != null)\n\t\t\t{\n\t\t\t\tview.SetSubtitleColour(in_subtitleId, in_red, in_green, in_blue, in_alpha);\n\t\t\t}\n\t\t}\n\t}\n\t/**\n\t * Removes the subtitle with the given Id.\n\t *\n\t * This must be called during the \"Update Subtitles\" event.\n\t *\n\t * @param in_subtitleId - The Id of the subtitle object which should be removed.\n\t */\n\tpublic void removeSubtitle(long in_subtitleId)\n\t{\n\t\tassert (m_updateSubtitlesEvent == true) : \"Cannot only be called during the Update Subtitles event.\";\n\n\t\tVideoPlayerActivity activity = VideoPlayerActivity.GetActivity();\n\t\tif (activity != null)\n\t\t{\n\t\t\tSubtitlesView view = activity.GetSubtitlesView();\n\t\t\tif (view != null)\n\t\t\t{\n\t\t\t\tview.RemoveSubtitle(in_subtitleId);\n\t\t\t}\n\t\t}\n\t}\n\t/**\n\t * Called by the Video Player Activity to send the update subtitles event to the native side of\n\t * the engine.\n\t *\n\t * This must be called on the UI thread.\n\t *\n\t * @author Ian Copland\n\t */\n\tprotected void updateSubtitles()\n\t{\n\t\tm_updateSubtitlesEvent = true;\n\t\tonUpdateSubtitles();\n\t\tm_updateSubtitlesEvent = false;\n\t}\n\t/**\n\t * Called by the Video Player Activity on completion to signal the native side of the engine.\n\t *\n\t * This must be called on the UI thread.\n\t *\n\t * @author Ian Copland\n\t */\n\tprotected void completeVideo()\n\t{\n\t\tonVideoComplete();\n\t}\n\t/**\n\t * Notifies the native side of the engine that it should update subtitles.\n\t *\n\t * @author Ian Copland\n\t */\n\tprivate native void onUpdateSubtitles();\n\t/**\n\t * Notifies the native side of the engine that video playback has completed.\n\t *\n\t * @author Ian Copland\n\t */\n\tprivate native void onVideoComplete();\n}\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/Java/com/chilliworks/chillisource/video/VideoPlayerActivity.java",
    "content": "/**\n * MediaPlayerActivity.java\n * ChilliSource\n * Created by Ian Copland on 15/08/2012.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2012 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.video;\n\nimport com.chilliworks.chillisource.core.CSApplication;\n\nimport android.app.Activity;\nimport android.graphics.Color;\nimport android.os.Bundle;\nimport android.view.Window;\nimport android.view.WindowManager;\nimport android.widget.RelativeLayout;\n\n//========================================================\n/// Media Player Activity\n///\n/// An Activity for displaying the media player.\n//========================================================\npublic class VideoPlayerActivity extends Activity\n{\n\tprivate static VideoPlayerActivity s_activityInstance = null;\n\tprivate static VideoInfo s_videoInfo = null;\n\n\tprivate RelativeLayout mViewContainer;\n\tpublic RelativeLayout mAspectViewContainer; //View that contains the video sized based on its aspect ratio\n\tprivate VideoPlayerView mVideoPlayerView;\n\tprivate SubtitlesView mSubtitlesView;\n\tprivate int mdwSeekPosition;\n\tprivate boolean mbHasFocusChangedEventOccurred = false;\n\tprivate boolean mbIsVideoResuming = false;\n\n\t/**\n\t * This is thread safe.\n\t *\n\t * @author Ian Copland\n\t *\n\t * @return The active video player activity. Will be null if no activity is active.\n\t */\n    public static synchronized VideoPlayerActivity GetActivity() \n    {\n    \treturn s_activityInstance;\n    }\n\n\t/**\n\t * Sets the info which will be used to play the video when this activty is started.\n\t *\n\t * This is thread safe.\n\t *\n\t * @author Ian Copland\n\t *\n\t * @param in_inApk - Whether or not the file is inside the Apk.\n\t * @param in_filePath - The path to the video file or file which contains the video data.\n\t * @param in_fileOffset - The offset into file where the video data starts. Should be -1 if the\n\t * file is a video file.\n\t * @param in_fileLength - The length of the video data. Should be -1 if the file is a video\n\t * file.\n\t * @param in_dismissedWithTap - Whether or not the video can be dismissed with a tap.\n\t * @param in_hasSubtitles - Whether or not the video has subtitles.\n\t * @param in_bgColourR - The red component of the background colour.\n\t * @param in_bgColourG - The green component of the background colour.\n\t * @param in_bgColourB - The blue component of the background colour.\n\t * @param in_bgColourA - The alpha component of the background colour.\n\t */\n    public static synchronized void setVideoInfo(boolean in_inApk, String in_filePath, int in_fileOffset, int in_fileLength, boolean in_dismissedWithTap, boolean in_hasSubtitles,\n    \t\t\t\t\t\t\t\t\t\t   float in_bgColourR, float in_bgColourG, float in_bgColourB, float in_bgColourA)\n    {\n    \tassert (s_videoInfo == null) : \"Video info is already set!\";\n\n\t\tint backgroundColour = Color.argb((int)(in_bgColourR * 255), (int)(in_bgColourG * 255), (int)(in_bgColourB * 255), (int)(in_bgColourA * 255));\n\t\ts_videoInfo = new VideoInfo(in_inApk, in_filePath, in_fileOffset, in_fileLength, in_dismissedWithTap, in_hasSubtitles, backgroundColour);\n    }\n\t//------------------------------------------------------------------------\n\t/// On Create\n\t///\n\t/// Creates the media player\n\t///\n\t/// @param the saved instance state. This is of no use to us.\n\t//------------------------------------------------------------------------\n    @Override public synchronized void onCreate(Bundle savedInstanceState) \n    {\n    \tsuper.onCreate(savedInstanceState);\n    \tsynchronized(VideoPlayerActivity.class)\n    \t{\n    \t\ts_activityInstance = this;\n    \t}\n    \t\n    \t//go full screen!\n    \trequestWindowFeature(Window.FEATURE_NO_TITLE);\n    \tgetWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);\n    \t\n    \t//create the view container\n    \tmViewContainer = new RelativeLayout(this);\n    \tsetContentView(mViewContainer);\n    \t\n    \tmViewContainer.setBackgroundColor(s_videoInfo.m_backgroundColour);\n    \tmAspectViewContainer = new RelativeLayout(this);\n    \tmViewContainer.addView(mAspectViewContainer);\n    \t\n    \tif (s_videoInfo.m_hasSubtitles == true)\n    \t{\n    \t\tmSubtitlesView = new SubtitlesView(this);\n    \t\tmAspectViewContainer.addView(mSubtitlesView);\n    \t}\n    \t\n    \tmdwSeekPosition = 0;\n    \tmbHasFocusChangedEventOccurred = false;\n    \tmbIsVideoResuming = false;\n    }\n    //------------------------------------------------------------------------\n  \t/// On Start\n  \t///\n  \t/// This is called whenever the activity is made visible.\n  \t//------------------------------------------------------------------------\n    @Override public synchronized void onStart()\n    {\n\t    super.onStart();\n    }\n    //------------------------------------------------------------------------\n  \t/// On Resume\n  \t///\n  \t/// This is called whenever the activity becomes the foreground activity.\n  \t//------------------------------------------------------------------------\n    @Override protected synchronized void onResume() \n    {\n    \t//If false then this is the part of the initialization of the video-activity and is not resuming from screen lock(or other) so create the player immediately \n    \tif(!mbHasFocusChangedEventOccurred)\n    \t{\n\t    \t//create and add the media player view.\n    \t\tShowVideoPlayer();\n    \t}\n    \telse //We are resuming the app from an unlock or other, we should only resume the video once we gain window focus (This is to prevent audio playing on lock-screen)\n    \t{\n    \t\tmbIsVideoResuming = true;\n    \t}\n    \t\n    \tsuper.onResume();\n    }\n  \t//------------------------------------------------------------------------\n  \t/// On Stop\n  \t///\n  \t/// This is called whenever the activity is no longer in the foreground\n  \t//------------------------------------------------------------------------\n    @Override protected synchronized void onPause() \n    {\n    \tif (mVideoPlayerView != null)\n    \t{\n    \t\tmdwSeekPosition = mVideoPlayerView.GetTime();\n    \t\tmVideoPlayerView.Cleanup();\n    \t\tmAspectViewContainer.removeView(mVideoPlayerView);\n    \t\tmVideoPlayerView = null;\n    \t}\n    \t\n        super.onPause();\n    }\n    //------------------------------------------------------------------------\n  \t/// On Stop\n  \t///\n  \t/// This is called whenever the activity is no longer visible.\n  \t//------------------------------------------------------------------------\n    @Override public synchronized void onStop()\n    {\n\t    super.onStop();\n    }\n  \t//------------------------------------------------------------------------\n  \t/// On Destroy\n  \t///\n  \t/// This is called when the lifecycle of the activty ends.\n  \t//------------------------------------------------------------------------\n    @Override protected synchronized void onDestroy()\n    {\n\t\ts_videoInfo = null;\n\n\t\tVideoPlayer mediaPlayerNI = (VideoPlayer)CSApplication.get().getSystem(VideoPlayer.INTERFACE_ID);\n\t\tif (mediaPlayerNI != null)\n\t\t{\n\t\t\tmediaPlayerNI.completeVideo();\n\t\t}\n\t\t\n    \tsynchronized(VideoPlayerActivity.class)\n    \t{\n    \t\ts_activityInstance = null;\n    \t}\n\t    super.onDestroy();\n    }\n  \t//------------------------------------------------------------------------\n  \t/// onWindowFocusChanged\n  \t///\n  \t/// This is called when any activity gains focus.\n  \t//------------------------------------------------------------------------\n    @Override public void onWindowFocusChanged(boolean inbHasFocus)\n    {\n    \t//We want to resume the video here if we are resuming the app and the app has focus\n    \tif(inbHasFocus && mbIsVideoResuming)\n    \t{\n    \t\tmbIsVideoResuming = false;\n    \t\t\n    \t\tShowVideoPlayer();\n    \t}\n    \t\n    \tmbHasFocusChangedEventOccurred = true;\n    \t\n    \tsuper.onWindowFocusChanged(inbHasFocus);\n    }\n  \t//------------------------------------------------------------------------\n  \t/// ShowVideoPlayer\n  \t//------------------------------------------------------------------------\n    private synchronized void ShowVideoPlayer()\n    {\n    \t//create and add the media player view.\n    \tif (mVideoPlayerView == null)\n    \t{\n    \t\tmVideoPlayerView = new VideoPlayerView(this, s_videoInfo.m_inApk, s_videoInfo.m_filePath, s_videoInfo.m_fileOffset, s_videoInfo.m_fileLength, s_videoInfo.m_dismissedWithTap, mdwSeekPosition);\n    \t\tmAspectViewContainer.addView(mVideoPlayerView);\n    \t\tif (mSubtitlesView != null)\n    \t\t{\n    \t\t\tmAspectViewContainer.bringChildToFront(mSubtitlesView);\n    \t\t}\n    \t}\n    }\n  \t//------------------------------------------------------------------------\n  \t/// Get Video Player View\n  \t///\n  \t/// @return the video player view.\n  \t//------------------------------------------------------------------------\n    public synchronized VideoPlayerView GetVideoPlayerView()\n    {\n    \treturn mVideoPlayerView;\n    }\n  \t//------------------------------------------------------------------------\n  \t/// Get Subtitles View\n  \t///\n  \t/// @return the subtitles view.\n  \t//------------------------------------------------------------------------\n    public synchronized SubtitlesView GetSubtitlesView()\n    {\n    \treturn mSubtitlesView;\n    }\n\t//---------------------------------------------------------------\n\t/// On Back Pressed\n    ///\n    /// Called whenever the back button is pressed while this activity\n    /// is active.\n\t//---------------------------------------------------------------\n\t@Override public void onBackPressed()\n\t{\n\t\tmVideoPlayerView.OnBackPressed();\n\t}\n\t/**\n\t * A container for information on the video which should be played by the activity.\n\t *\n\t * @author Ian Copland\n\t */\n\tprivate static class VideoInfo\n\t{\n\t\tpublic final boolean m_inApk;\n\t\tpublic final String m_filePath;\n\t\tpublic final int m_fileOffset;\n\t\tpublic final int m_fileLength;\n\t\tpublic final boolean m_dismissedWithTap;\n\t\tpublic final boolean m_hasSubtitles;\n\t\tpublic final int m_backgroundColour;\n\n\t\tpublic VideoInfo(boolean in_inApk, String in_filePath, int in_fileOffset, int in_fileLength, boolean in_dismissedWithTap, boolean in_hasSubtitles, int in_backgroundColour)\n\t\t{\n\t\t\tm_inApk = in_inApk;\n\t\t\tm_filePath = in_filePath;\n\t\t\tm_fileOffset = in_fileOffset;\n\t\t\tm_fileLength = in_fileLength;\n\t\t\tm_dismissedWithTap = in_dismissedWithTap;\n\t\t\tm_hasSubtitles = in_hasSubtitles;\n\t\t\tm_backgroundColour = in_backgroundColour;\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/Java/com/chilliworks/chillisource/video/VideoPlayerView.java",
    "content": "/**\n * VideoPlayerView.java\n * ChilliSource\n * Created by Ian Copland on 15/08/2012.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2012 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.video;\nimport com.chilliworks.chillisource.core.Logging;\n\nimport android.content.Context;\nimport android.content.res.AssetFileDescriptor;\nimport android.graphics.Point;\nimport android.media.AudioManager;\nimport android.media.MediaPlayer;\nimport android.media.MediaPlayer.OnCompletionListener;\nimport android.media.MediaPlayer.OnErrorListener;\nimport android.media.MediaPlayer.OnPreparedListener;\nimport android.view.Display;\nimport android.view.MotionEvent;\nimport android.view.SurfaceHolder;\nimport android.view.SurfaceView;\n\nimport java.io.File;\nimport java.io.FileDescriptor;\nimport java.io.FileInputStream;\n\n//========================================================\n/// Media Player View\n///\n/// A view for displaying the media player.\n//========================================================\npublic class VideoPlayerView extends SurfaceView implements OnPreparedListener, OnErrorListener, OnCompletionListener, SurfaceHolder.Callback\n{\t\n\t//------------------------------------------------------------------------\n\t/// Constants\n\t//------------------------------------------------------------------------\n\tprivate long kqwTapLengthInMS = 150;\n\t//------------------------------------------------------------------------\n\t/// Private Member Data\n\t//------------------------------------------------------------------------\n\tprivate boolean mbInAPK;\n\tprivate String m_filePath;\n\tprivate int m_fileOffset = -1;\n\tprivate int m_fileLength = -1;\n\tprivate boolean mbCanDismissWithTap;\n\tprivate MediaPlayer m_mediaPlayer;\n\tprivate int mdwSeekPosition;\n\tprivate VideoPlayerActivity mActivity;\n\tprivate long mqwTapTime;\n\t//------------------------------------------------------------------------\n\t/// Constructor\n\t//------------------------------------------------------------------------\n\t@SuppressWarnings(\"deprecation\")\n\tpublic VideoPlayerView(Context inContext, boolean inbInAPK, String instrFilename, int in_fileOffset, int in_fileLength, boolean inbCanDismissWithTap, int indwSeekPosition)\n\t{\n\t\tsuper(inContext);\n\t\tmActivity = VideoPlayerActivity.GetActivity();\n\n\t\tmbInAPK = inbInAPK;\n\t\tm_filePath = instrFilename;\n\t\tm_fileOffset = in_fileOffset;\n\t\tm_fileLength = in_fileLength;\n\t\tmbCanDismissWithTap = inbCanDismissWithTap;\n\t\tmdwSeekPosition = indwSeekPosition;\n\t\tmqwTapTime = 0;\n\t\t\n    \t//setup the holder\n\t\tgetHolder().setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);\n\t\tgetHolder().addCallback(this);\n\t}\n\t//--------------------------------------------------------------\n\t/// Get Time\n\t///\n\t/// @return the current position through the video.\n\t//--------------------------------------------------------------\n\tpublic synchronized int GetTime() \n\t{\n\t\tif (m_mediaPlayer != null)\n\t\t{\n\t\t\treturn m_mediaPlayer.getCurrentPosition();\n\t\t}\n\t\treturn 0;\n\t}\n\t//--------------------------------------------------------------\n\t/// Prepare Media Player\n\t///\n\t/// Prepares the media player for use.\n\t//--------------------------------------------------------------\n\tprivate synchronized void PrepareVideoPlayer() \n\t{\n\t\tif (m_mediaPlayer == null)\n\t\t{\n\t\t\ttry\n\t\t\t{\t\n\t\t\t\t//setup the media player\n\t\t\t\tm_mediaPlayer = new MediaPlayer();\n\t\t\t\tm_mediaPlayer.setOnPreparedListener(this);\n\t\t\t\tm_mediaPlayer.setOnErrorListener(this);\n\t\t\t\tm_mediaPlayer.setOnCompletionListener(this);\n\t\t\t\tm_mediaPlayer.setDisplay(getHolder());\n\t\t\t\tm_mediaPlayer.setScreenOnWhilePlaying(true);\n\t\t\t\tm_mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);\n\t\t\t\t\n\t\t\t\t//set the data source\n\t\t\t\tif (mbInAPK == true)\n\t\t\t\t{\n\t\t\t\t\tAssetFileDescriptor fileDesc = mActivity.getAssets().openFd(m_filePath);\n\n\t\t\t\t\tif (m_fileOffset == -1 && m_fileLength == -1)\n\t\t\t\t\t{\n\t\t\t\t\t\tm_mediaPlayer.setDataSource(fileDesc.getFileDescriptor(), fileDesc.getStartOffset(), fileDesc.getLength());\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tassert (m_fileLength > 0) : \"Cannot create 0 size stream\";\n\n\t\t\t\t\t\tm_mediaPlayer.setDataSource(fileDesc.getFileDescriptor(), fileDesc.getStartOffset() + m_fileOffset, m_fileLength);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tif (m_fileOffset == -1 && m_fileLength == -1)\n\t\t\t\t\t{\n\t\t\t\t\t\tm_mediaPlayer.setDataSource(m_filePath);\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tassert (m_fileLength > 0) : \"Cannot create 0 size stream\";\n\n\t\t\t\t\t\tFileInputStream stream = new FileInputStream(m_filePath);\n\t\t\t\t\t\tm_mediaPlayer.setDataSource(stream.getFD(), m_fileOffset, m_fileLength);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\t//prepare the media player asynchronously\n\t\t\t\tm_mediaPlayer.prepareAsync();\n\t\t\t}\n\t\t\tcatch (Exception e)\n\t\t\t{\n\t\t\t\tLogging.logError(\"Error trying to open video file: \" + m_filePath);\n\t\t\t\tonError(m_mediaPlayer, 0, 0);\n\t\t\t}\n\t\t}\n\t}\t\n\t//--------------------------------------------------------------\n\t/// Cleanup Video\n\t///\n\t/// Cleans up the video, releasing everything and setting back\n\t/// to initial state.\n\t//--------------------------------------------------------------\n\tpublic synchronized void Cleanup() \n\t{\n\t\t//clean up the video\n\t\tif (m_mediaPlayer != null)\n\t\t{\n\t\t\tif (m_mediaPlayer.isPlaying() == true)\n\t\t\t{\n\t\t\t\tm_mediaPlayer.stop();\n\t\t\t}\n\t\t\tm_mediaPlayer.release();\n\t\t\tm_mediaPlayer = null;\n\t\t}\n\t}\n\t//--------------------------------------------------------------\n\t/// surface Created\n\t///\n\t/// Called when the surface is created. Prepares the video for \n\t/// displaying in a background thread. Once the video has finished \n\t/// loading it will present the video and calls the OnVideoPrepared.\n\t/// \n\t/// @param the created holder.\n\t//--------------------------------------------------------------\n\t@Override public synchronized void surfaceCreated(SurfaceHolder inHolder) \n\t{\n\t\tif (getHolder() == inHolder)\n\t\t{\n\t\t\tPrepareVideoPlayer();\n\t\t}\n\t}\n\t//--------------------------------------------------------------\n\t/// surface Changed\n\t///\n\t/// called whenever the surface changes.\n\t/// \n\t/// @param the holder.\n\t/// @param the format.\n\t/// @param the width.\n\t/// @param the height.\n\t//--------------------------------------------------------------\n\t@Override public synchronized void surfaceChanged(SurfaceHolder inHolder, int indwFormat, int indwWidth, int indwHeight) \n\t{\n\t}\n\t//--------------------------------------------------------------\n\t/// surface Destroyed\n\t///\n\t/// called whenever the surface is destroyed.\n\t/// \n\t/// @param the holder.\n\t//--------------------------------------------------------------\n\t@Override public synchronized void surfaceDestroyed(SurfaceHolder inHolder) \n\t{\n\t}\n\t//--------------------------------------------------------------\n\t/// on Prepared\n\t///\n\t/// Called once the video is prepared. This will start the video\n\t/// playing and call OnVideoStarted.\n\t//--------------------------------------------------------------\n\t@SuppressWarnings(\"deprecation\")\n\t@Override public synchronized void onPrepared(MediaPlayer inMediaPlayer) \n\t{\n\t\tif (m_mediaPlayer == inMediaPlayer)\n\t\t{\t\n\t\t\t//Since the view were placing the video onto is normally full screen, we need to fit the \n\t\t\t//video by width aspect, i.e video is full width of screen but maintains height aspect\n\t\t\tint dwVideoHeight = m_mediaPlayer.getVideoHeight();\n\t\t\tint dwVideoWidth = m_mediaPlayer.getVideoWidth();\n\t\t\t\n\t\t\tint dwScreenWidth = 0;\n\t\t\tint dwScreenHeight = 0;\n\t\t\tDisplay display = mActivity.getWindowManager().getDefaultDisplay();\n\t\t\tif (android.os.Build.VERSION.SDK_INT < 13)\n\t\t\t{\n\t\t\t\tdwScreenWidth = display.getWidth();\n\t\t\t\tdwScreenHeight = display.getHeight();\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tPoint size = new Point();\n\t\t\t\tdisplay.getSize(size);\n\t\t\t\tdwScreenWidth = size.x;\n\t\t\t\tdwScreenHeight = size.y;\n\t\t\t}\n\t\t\t\n\t\t\n\t\t\tfloat fVideoAspectRatio = (float)dwVideoHeight / (float)dwVideoWidth;\n\t\t\t\n\t\t\tint dwDiffWidth = Math.abs(dwScreenWidth - dwVideoWidth);\n\t\t\tint dwDiffHeight = Math.abs(dwScreenHeight - dwVideoHeight);\n\t\t\t\n\t\t\tfloat fVideoViewWidth = 0.0f;\n\t\t\tfloat fVideoViewHeight = 0.0f;\n\t\t\t\n\t\t\tif(dwDiffWidth > dwDiffHeight)\n\t\t\t{\n\t\t\t\tfloat fWidthMultiplier = (float)dwScreenWidth / (float)dwVideoWidth;\n\t\t\t\tfloat fHeightMultiplier = fWidthMultiplier * fVideoAspectRatio;\n\t\t\t\tfVideoViewWidth = dwVideoWidth * fWidthMultiplier;\n\t\t\t\tfVideoViewHeight = dwVideoWidth * fHeightMultiplier;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tfloat fHeightMultiplier = (float)dwScreenHeight / (float)dwVideoHeight;\n\t\t\t\tfloat fWidthMultiplier = fHeightMultiplier * fVideoAspectRatio;\n\t\t\t\tfVideoViewHeight = dwVideoHeight * fHeightMultiplier;\n\t\t\t\tfVideoViewWidth = dwVideoHeight * fWidthMultiplier;\n\t\t\t}\n\t\t\t\n\t\t\tfloat fYPadding = dwScreenHeight - fVideoViewHeight; \n\t\t\tif(fYPadding < 0)\n\t\t\t\tfYPadding = 0;\n\t\t\t\n\t\t\tfloat fXPadding = dwScreenWidth - fVideoViewWidth; \n\t\t\tif(fXPadding < 0)\n\t\t\t\tfXPadding = 0;\n\t\t\t\n\t\t\t//We set the top and bottom padding on the viewContainer to difference in video / screen height * 0.5\n\t\t\tmActivity.mAspectViewContainer.setPadding(0, (int)(fYPadding * 0.5f), 0, (int)(fYPadding * 0.5f));\n\t\t\t\n\t\t\t//start the video\n\t\t\tm_mediaPlayer.seekTo(mdwSeekPosition);\n\t\t\tm_mediaPlayer.start();\n\t\t}\n\t}\n\t//--------------------------------------------------------------\n\t/// on Error\n\t///\n\t/// Called when the video preparation step fails. This clears up\n\t/// the video and calls onCompletion.\n\t//--------------------------------------------------------------\n\t@Override public synchronized boolean onError(MediaPlayer inMediaPlayer, int indwWhat, int indwExtra) \n\t{\n\t\tif (m_mediaPlayer == inMediaPlayer)\n\t\t{\n\t\t\tLogging.logError(\"Media player has encountered an error while preparing.\");\n\t\t\tonCompletion(inMediaPlayer);\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\t//--------------------------------------------------------------\n\t/// on Completion\n\t///\n\t/// Called when the video has finished playing. This tidies up \n\t/// the video player and calls OnVideoStopped.\n\t//--------------------------------------------------------------\n\t@Override public synchronized void onCompletion(MediaPlayer inMediaPlayer) \n\t{\n\t\tif (m_mediaPlayer == inMediaPlayer)\n\t\t{\n\t\t\tCleanup();\n\t\t\tmActivity.finish();\n\t\t}\n\t}\n\t//-----------------------------------------------------------------\n\t/// On Touch Event \n\t///\n\t/// This records all touch events that occur.\n\t///\n\t/// @param the motion event.\n\t/// @return whether or not this view wants to pass the touch event\n\t///\t\t\ton to the next applicable view.\n\t//-----------------------------------------------------------------\n\t@Override public synchronized boolean onTouchEvent(final MotionEvent event) \n\t{\t\n\t\tif (mbCanDismissWithTap == true)\n\t\t{\n\t\t\tint dwActionData = event.getAction();\n\t\t\tint dwActionEvent = dwActionData & MotionEvent.ACTION_MASK;\n\t\t\tif (dwActionEvent == MotionEvent.ACTION_DOWN)\n\t\t\t{\n\t\t\t\tmqwTapTime = System.currentTimeMillis();\n\t\t\t}\n\t\t\telse if (dwActionEvent == MotionEvent.ACTION_UP)\n\t\t\t{\n\t\t\t\tif (System.currentTimeMillis() - mqwTapTime <= kqwTapLengthInMS)\n\t\t\t\t{\n\t\t\t\t\tonCompletion(m_mediaPlayer);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n        return true;\n    }\n\t//---------------------------------------------------------------\n\t/// On Back Pressed\n\t///\n\t/// Called when the back button is pressed. This will dismiss\n\t/// the video if tap dismissal is enabled.\n\t//---------------------------------------------------------------\n\tpublic void OnBackPressed()\n\t{\n\t\tif (mbCanDismissWithTap == true)\n\t\t{\n\t\t\tonCompletion(m_mediaPlayer);\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/Java/com/chilliworks/chillisource/web/CSWebView.java",
    "content": "/**\n * CSWebView.java\n * ChilliSource\n * Created by Ian Copland on 16/09/2013.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2013 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.web;\n\nimport android.content.Context;\nimport android.view.KeyEvent;\nimport android.view.ViewGroup;\n\n/**\n * The ChilliSource implementation of a Web View. This differs\n * from a standard webview by allowing the back button to close\n * the webview.\n *\n * @author Steven Hendrie\n */\npublic class CSWebView extends android.webkit.WebView\n{\n\tprivate int m_indexID;\n\n\t/**\n\t * Constructor.\n\t *\n\t * @author Steven Hendrie\n\t *\n\t * @param in_context - The URI which should have its MIME type checked.\n\t * @param in_index - The MIME Type. Currently this always returns null.\n\t */\n\tpublic CSWebView(Context in_context, int in_index)\n\t{\n\t\tsuper(in_context);\n\n\t\tm_indexID = in_index;\n\t}\n\t/**\n\t * Gets the index of this WebView.\n\t *\n\t * @author HMcLaughlin\n\t *\n\t * @return The index id given to this instance.\n\t */\n\tpublic int getIndexID()\n\t{\n\t\treturn m_indexID;\n\t}\n\t/**\n\t * On Key Down.\n\t *\n\t * @author Steven Hendrie\n\t *\n\t * @param in_keyCode - The code for the given key.\n\t * @param in_keyEvent - The key event.\n\t *\n\t * @return Whether or not the key event should be consumed.\n\t */\n\t@Override public boolean onKeyDown(int in_keyCode, KeyEvent in_keyEvent)\n\t{\n\t\tif (in_keyCode == KeyEvent.KEYCODE_BACK)\n\t\t{\n\t\t\tViewGroup viewGroup = (ViewGroup)(getParent());\n\t\t\tif (viewGroup != null)\n\t\t\t{\n\t\t\t\tviewGroup.removeView(this);\n\t\t\t\tWebViewNativeInterface.Dismiss(m_indexID);\n\t\t\t}\n\t\t\treturn true;\n\t\t}\n\t\treturn super.onKeyDown(in_keyCode, in_keyEvent);\n\t}\n}\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/Java/com/chilliworks/chillisource/web/CSWebViewClient.java",
    "content": "/**\n * CSWebViewClient.java\n * ChilliSource\n * Created by Steven Hendrie on 15/12/2011.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2011 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.web;\n\nimport android.app.Activity;\nimport android.app.AlertDialog;\nimport android.content.DialogInterface;\nimport android.content.Intent;\nimport android.net.Uri;\nimport android.webkit.WebView;\n\nimport com.chilliworks.chillisource.core.CSApplication;\n\npublic class CSWebViewClient extends android.webkit.WebViewClient\n{\n\tfinal String kstrGooglePlayURLScheme = \"market\";\n\tfinal String kstrAmazonUrlScheme = \"amzn\";\n\tprivate String mAnchor;\n\tprivate CSWebView mWebView;\n\n\t/**\n\t * Is Store Deep Link\n\t *\n\t * @author Steven Hendrie\n\t *\n\t * @param in_url -The URL string.\n\t *\n\t * @return Whether or not it is a store deep link.\n\t */\n\tpublic boolean IsStoreDeepLink(final String in_url)\n\t{\n\t\tUri uri = Uri.parse(in_url);\n\t\tif (uri != null)\n\t\t{\n\t\t\tString strScheme = uri.getScheme();\n\t\t\tif (strScheme != null)\n\t\t\t{\n\t\t\t\treturn (strScheme.equalsIgnoreCase(kstrGooglePlayURLScheme) == true || strScheme.equalsIgnoreCase(kstrAmazonUrlScheme) == true);\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\t/**\n\t * This intercepts url clicks within the webview and\n\t * ensures they are not opened in an external browser.\n\t * It will also check if the link was a store deep link\n\t * and instead  open the store.\n\t *\n\t * @author Steven Hendrie\n\t *\n\t * @param in_view - WebView\n\t * @param in_url - The URL string.\n\t *\n\t * @return Whether or not we are handling the URL loading\n\t */\n\t@Override public boolean shouldOverrideUrlLoading(WebView in_view, String in_url)\n\t{\n\t\tActivity activity = CSApplication.get().getActivity();\n\t\tif (activity != null && IsStoreDeepLink(in_url) == true)\n\t\t{\n\t\t\tIntent intent = new Intent(Intent.ACTION_VIEW);\n\t\t\tintent.setData(Uri.parse(in_url));\n\t\t\tactivity.startActivity(intent);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tCSWebView webView = (CSWebView) in_view;\n\t\t\tif(webView != null)\n\t\t\t{\n\t\t\t\tboolean handledExternally = WebViewNativeInterface.onLinkClicked(webView.getIndexID(), in_url);\n\t\t\t\tif(handledExternally == false)\n\t\t\t\t{\n\t\t\t\t\tin_view.loadUrl(in_url);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t    return true;\n\t}\n\t/**\n\t * Called when a web page is finished loading\n\t *\n\t * @author Steven Hendrie\n\t *\n\t * @param in_view - WebView\n\t * @param in_url - The URL that finished loading.\n\t */\n\t@Override\n\tpublic void onPageFinished(WebView in_view, String in_url)\n\t{\n\t\tWebViewNativeInterface.RemoveActivityIndicator();\n\t\tWebViewNativeInterface.AddDismissButton();\n\t\t\n\t\tif(mAnchor.length() > 0)\n\t\t{\n\t\t\tmWebView.loadUrl(\"javascript:window.location.href = '\" + mAnchor + \"';\");\n\t\t\tmAnchor = \"\";\n\t\t}\n\t}\n\t/**\n\t * Called when a web page is finished loading\n\t *\n\t * @author Steven Hendrie\n\t *\n\t * @param in_view - WebView\n\t * @param in_errorCode - Error code reported\n\t * @param in_description - String description of the error\n\t * @param in_failingUrl - The URL that failed to load.\n\t */\n\t@Override\n\tpublic void onReceivedError(WebView in_view, int in_errorCode, String in_description, String in_failingUrl)\n\t{\n\t\tWebViewNativeInterface.RemoveActivityIndicator();\n\n\t\tfinal CSWebView webView = (CSWebView) in_view;\n\t\tassert (webView != null) : \"Should always be castable to CSWebView!\";\n\n\t\tif(webView != null)\n\t\t{\n\t\t\tAlertDialog.Builder builder = new AlertDialog.Builder(webView.getContext());\n\t\t\tbuilder.setMessage(in_description)\n\t\t\t\t\t.setCancelable(false)\n\t\t\t\t\t.setPositiveButton(\"OK\", new DialogInterface.OnClickListener()\n\t\t\t\t\t{\n\t\t\t\t\t\tpublic void onClick(DialogInterface dialog, int id)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tWebViewNativeInterface.onWebviewDismissed(webView.getIndexID());\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\n\t\t\tAlertDialog alert = builder.create();\n\t\t\talert.show();\n\t\t}\n\t}\n\t\n\tpublic void SetAnchor(String inAnchor)\n\t{\n\t\tmAnchor = inAnchor;\n\t}\n\t\n\tpublic void SetView(CSWebView inWebView)\n\t{\n\t\tmWebView = inWebView;\n\t}\n}\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/Java/com/chilliworks/chillisource/web/WebViewCloseButton.java",
    "content": "/**\n * WebViewCloseButton.java\n * ChilliSource\n * Created by Steven Hendrie on 16/12/2011.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2011 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.web;\n\nimport com.chilliworks.chillisource.core.R;\n\nimport android.content.Context;\nimport android.view.View;\nimport android.view.ViewGroup;\nimport android.widget.Button;\nimport android.widget.RelativeLayout;\n\npublic class WebViewCloseButton extends Button\n{\n\tfinal private int mudwIndex;\n\t\n\t//---------------------------------------------------------------------\n\t/// CCloseButton\n\t///\n\t/// Constructor for CCloseButton - sets layout and size of button.\n\t/// Override on click listener to remove views\n\t///\n\t/// @param Context\n\t/// @param index of webview that this will be associated with\n\t///\n\t//---------------------------------------------------------------------\n\tpublic WebViewCloseButton(Context context, int inudwIndex, float infSize)\n\t{\n\t\tsuper(context);\t\t\n\t\t\n\t\tmudwIndex = inudwIndex;\n\t\t\n\t\tif (R.doesExist(R.Type.DRAWABLE, \"com_chillisource_close_button\") == true)\n\t\t{\n\t\t\tsetBackgroundResource(R.getId(R.Type.DRAWABLE, \"com_chillisource_close_button\"));\n\t\t}\n\t\telse\n\t\t{\n\t\t\tsetText(\"X\");\n\t\t}\n\t\t\n\t\tRelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams((int)infSize, (int)infSize);\n\t\tparams.addRule(RelativeLayout.ALIGN_RIGHT, mudwIndex);\n\t\tparams.addRule(RelativeLayout.ALIGN_TOP, mudwIndex);\n\t\tsetLayoutParams(params);\n\t\t\n\t\tsetOnClickListener(new View.OnClickListener()\n\t\t{\n\t\t\t@Override\n\t\t\tpublic void onClick(View v) \n\t\t\t{\n\t\t\t\tViewGroup vg = (ViewGroup)(v.getParent());\n\t\t\t\tvg.removeView(v);\n\t\t\t\tWebViewNativeInterface.Dismiss(mudwIndex);\t\t\t\n\t\t\t}\n\t\t});\n\t}\n\t//---------------------------------------------------------------------\n\t/// Get Index\n\t///\n\t/// Get Index of webview associated with button\n\t///\n\t///\t@returns int of index\n\t///\n\t//---------------------------------------------------------------------\n\tpublic int GetIndex()\n\t{\n\t\treturn mudwIndex;\n\t}\n}\n"
  },
  {
    "path": "Source/CSBackend/Platform/Android/Main/Java/com/chilliworks/chillisource/web/WebViewNativeInterface.java",
    "content": "/**\n * WebViewNativeInterface.java\n * ChilliSource\n * Created by Steven Hendrie on 15/12/2011.\n * \n * The MIT License (MIT)\n * \n * Copyright (c) 2011 Tag Games Limited\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\npackage com.chilliworks.chillisource.web;\n\nimport android.annotation.SuppressLint;\n\nimport android.app.ProgressDialog;\nimport android.content.Intent;\nimport android.net.Uri;\nimport android.view.Gravity;\nimport android.view.ViewGroup.LayoutParams;\nimport android.widget.RelativeLayout;\n\nimport com.chilliworks.chillisource.core.CSActivity;\nimport com.chilliworks.chillisource.core.CSApplication;\nimport com.chilliworks.chillisource.core.R;\n\npublic class WebViewNativeInterface \n{\n\t/**\n\t * Called when a webview is dimissed\n\t *\n\t * @author Steven Hendrie\n\t *\n\t * @param in_index - WebView index.\n\t */\n\tnative public static void onWebviewDismissed(int in_index);\n\t/**\n\t * Called when a link is clicked on a webview\n\t *\n\t * @author Steven Hendrie\n\t *\n\t * @param in_index - WebView index.\n\t * @param in_linkURL - URL of the link to be handled.\n\t *\n\t * @return Whether the URL is handled externally.\n\t */\n\tnative public static boolean onLinkClicked(int in_index, String in_linkURL);\n\t\n\tprivate static CSActivity msActivity;\n\tprivate static RelativeLayout msWebviewHolder;\n\tprivate static ProgressDialog mActivityIndicator;\n\tprivate static WebViewCloseButton s_dismissButton;\n\tprivate static float s_dismissButtonSize = 0.0f;\n\tprivate static int s_currentIndex = 0;\n\tprivate static boolean s_active = false;\n\t//---------------------------------------------------------------------\n\t/// Initialise\n\t///\n\t/// Initialises the webview native interface\n\t///\n\t/// @param this applications main activity.\n\t/// @param the gl surface to attach the webview\n\t//---------------------------------------------------------------------\n\t@SuppressLint(\"UseSparseArrays\")\n\tpublic static void Setup(CSActivity inActivity)\n\t{\n\t\tmsActivity = inActivity;\t\n\t\tmsWebviewHolder = new RelativeLayout(msActivity);\t\n\t\tLayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);\n\t\tmsWebviewHolder.setLayoutParams(params);\n\t\tmsWebviewHolder.setGravity(Gravity.CENTER);\n\t\t\n\t\tCSApplication.get().addView(msWebviewHolder);\t\n\t}\n\t//---------------------------------------------------------------------\n\t/// Present\n\t///\n\t/// Load and add the webview to the screen\n\t///\n\t/// @param url string for the website to be displayed\n\t/// @param absolute value for width - determined in native \n\t/// @param absolute value for height - determined in native\n\t/// @param The relative size of the dismiss button\n\t//---------------------------------------------------------------------\n\tpublic static void Present(final int inudwIndex, final String instrURL, final int inudwXAbsolute, final int inudwYAbsolute, final float in_dismissButtonRelativeSize)\n\t{\n    \tCSApplication.get().scheduleUIThreadTask(new Runnable() \n        {\n\t\t    public void run() \n\t\t    {\t\t\n\t\t    \tsynchronized (msWebviewHolder) \n\t\t    \t{\n\t\t    \t\tCSWebView sWebView = CreateBlankWebView(inudwIndex, inudwXAbsolute, inudwYAbsolute, \"\");\n\t\t    \t\tsWebView.loadUrl(instrURL);\n\t\t    \t\tmsWebviewHolder.addView(sWebView);\n\t\t    \t\tsWebView.requestFocus();\n\t\t    \t\tAddActivityIndicator();\n\t\t    \t\t\n\t\t    \t\ts_dismissButtonSize = in_dismissButtonRelativeSize * inudwXAbsolute;\n\t\t    \t\ts_currentIndex = inudwIndex;\n\t\t    \t\ts_active = true;\n\t\t    \t}\n\t\t    }\n\t\t});\t\t\n\t}\n\t//---------------------------------------------------------------------\n\t/// Present From File\n\t///\n\t/// Load the webview from file and display\n\t///\n\t/// @param html contents\n\t/// @param absolute value for width - determined in native \n\t/// @param absolute value for height - determined in native\n\t/// @param base path\n\t/// @param The relative size of the dismiss button\n\t//---------------------------------------------------------------------\n\tpublic static void PresentFromFile(final int inudwIndex, final String instrHTMLContents, final int inudwXAbsolute, final int inudwYAbsolute, final String instrBasePath, final String instrAnchor, final float in_dismissButtonRelativeSize)\n\t{\n\t\tmsActivity.runOnUiThread(new Runnable() \n        {\n\t\t    public void run() \n\t\t    {\n\t\t    \tsynchronized (msWebviewHolder) \n\t\t    \t{\n\t\t    \t\tCSWebView sWebView = CreateBlankWebView(inudwIndex, inudwXAbsolute, inudwYAbsolute, instrAnchor);\n\t\t    \t\tsWebView.loadDataWithBaseURL(instrBasePath, instrHTMLContents, \"text/html\", \"utf-8\", null);\n\t\t    \t\tmsWebviewHolder.addView(sWebView);\n\t\t    \t\tsWebView.requestFocus();\n\t\t    \t\tAddActivityIndicator();\n\t\t    \t\t\n\t\t    \t\ts_dismissButtonSize = in_dismissButtonRelativeSize * inudwXAbsolute;\n\t\t    \t\ts_currentIndex = inudwIndex;\n\t\t    \t\ts_active = true;\n\t\t    \t}\n\t\t    }\n\t\t});\n\t}\n\t//---------------------------------------------------------------------\n\t/// Present In External Browser\n\t///\n\t/// Load the webview from file and display\n\t///\n\t/// @param url string for the website to be displayed\n\t/// @param absolute value for width - determined in native \n\t/// @param absolute value for height - determined in native\n\t//---------------------------------------------------------------------\n\tpublic static void PresentInExternalBrowser(String instrURL)\n\t{\n\t\tIntent i = new Intent(Intent.ACTION_VIEW);  \n\t\ti.setData(Uri.parse(instrURL));  \n\t\tmsActivity.startActivity(i);  \n\t}\n\t//---------------------------------------------------------------------\n\t/// Dismiss\n\t///\n\t/// Remove the webview from the screen.\n\t///\n\t/// @param index of webview to be removed (current removed)\n\t//---------------------------------------------------------------------\n\tpublic static void Dismiss(final int inudwIndex)\n\t{\n\t\tmsActivity.runOnUiThread(new Runnable() \n        {\n\t\t    public void run() \n\t\t    {\n\t\t    \tsynchronized (msWebviewHolder) \n\t\t    \t{\n\t\t    \t\tif(s_dismissButton != null) \n\t    \t\t\t{\n\t    \t\t\t\tmsWebviewHolder.removeView(s_dismissButton);\n\t    \t\t\t\ts_dismissButton = null;\n\t    \t\t\t}\n\t\t    \t\tmsWebviewHolder.removeView(msWebviewHolder.findViewById(inudwIndex));\n\t\t    \t\t\n\t\t    \t\ts_active = false;\n\t\t    \t}\n\t\t    }\n\t\t});\t\n\t\t\n\t\tWebViewNativeInterface.onWebviewDismissed(inudwIndex);\n\t}\n\t//---------------------------------------------------------------------\n\t/// Add Activity Indicator\n\t///\n\t//---------------------------------------------------------------------\n\tpublic static void AddActivityIndicator()\n\t{\n\t\tif(mActivityIndicator != null)\n\t\t\treturn;\n\t\t\n\t\tmActivityIndicator = new ProgressDialog(msActivity);\n\t\tif (R.doesExist(R.Type.STRING, \"com_chillisource_webview_loading\") == true)\n\t\t{\n\t\t\tint LoadingTextID = R.getId(R.Type.STRING, \"com_chillisource_webview_loading\");\n\t\t\tString strMessage = msActivity.getString(LoadingTextID);\n\t\t\tmActivityIndicator.setMessage(strMessage);\n\t\t}\n\t\tmActivityIndicator.show();\n\t}\n\t//---------------------------------------------------------------------\n\t/// Remove Activity Indicator\n\t///\n\t//---------------------------------------------------------------------\n\tpublic static void RemoveActivityIndicator()\n\t{\n\t\tif(mActivityIndicator != null)\n\t\t{\n\t\t\tmActivityIndicator.dismiss();\n\t    \tmActivityIndicator = null;\n\t\t}\n\t}\n\t//---------------------------------------------------------------------\n\t/// Add Dismiss Button\n\t///\n\t/// Add a button to the webview so that it can be removed\n\t///\n\t/// @param index of webview to be removed\n\t//---------------------------------------------------------------------\n\tpublic static void AddDismissButton()\n\t{\n\t\tmsActivity.runOnUiThread(new Runnable() \n        {\n\t\t    public void run() \n\t\t    {\t \n\t\t    \tsynchronized (msWebviewHolder) \n\t\t    \t{\n\t\t    \t\tif (s_active == true && s_dismissButton == null)\n\t\t    \t\t{\n\t\t    \t\t\ts_dismissButton = new WebViewCloseButton(msActivity, s_currentIndex, s_dismissButtonSize);\n\t\t    \t\t\tmsWebviewHolder.addView(s_dismissButton);\t\n\t\t    \t\t}\n\t\t    \t}\n\t\t    }\n\t\t});\t\t\n\t}\n\t//---------------------------------------------------------------------\n\t/// Create blank WebView\n\t///\n\t/// Creates a blank webview to be added with all necessary \n\t/// settings\n\t///\n\t/// @param index of webview to created\n\t/// @param width\n\t/// @param height\n\t/// @param Anchor\n\t/// @returns blank webview with settings\n\t//---------------------------------------------------------------------\n\t@SuppressLint(\"SetJavaScriptEnabled\")\n\tpublic static CSWebView CreateBlankWebView(int inudwIndex, int inudwXAbsolute, int inudwYAbsolute, String inAnchor)\n\t{\n\t\tCSWebView webView = new CSWebView(msActivity, inudwIndex);\n\t\twebView.setId(inudwIndex);\n    \t\n    \tCSWebViewClient client = new CSWebViewClient();\n    \tclient.SetAnchor(inAnchor);\n    \tclient.SetView(webView);\n    \t\n    \twebView.setWebViewClient(client);\n    \twebView.getSettings().setJavaScriptEnabled(true);\n    \t\n    \tRelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(inudwXAbsolute,inudwYAbsolute);\n\t\tparams.addRule(RelativeLayout.CENTER_IN_PARENT);\n\t\twebView.setLayoutParams(params);\n    \treturn webView;\n\t}\n}\n"
  },
  {
    "path": "Source/CSBackend/Platform/RPi/Core/Base/DispmanWindow.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2017 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_RPI\n\n#include <CSBackend/Platform/RPi/Core/Base/DispmanWindow.h>\n#include <CSBackend/Platform/RPi/Core/Base/SystemInfoFactory.h>\n#include <CSBackend/Platform/RPi/Core/Base/EGLConfigChooser.h>\n\n#include <ChilliSource/Core/Base/StandardMacros.h>\n#include <ChilliSource/Core/Base/AppConfig.h>\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/Base/LifecycleManager.h>\n#include <ChilliSource/Core/Base/SystemInfo.h>\n#include <ChilliSource/Core/Container/VectorUtils.h>\n#include <ChilliSource/Rendering/Base/SurfaceFormat.h>\n#include <ChilliSource/Core/String/StringParser.h>\n\n#include <X11/Xatom.h>\n#include <X11/XKBlib.h>\n\nnamespace CSBackend\n{\n\tnamespace RPi\n\t{\n\t\tnamespace\n\t\t{\n\t\t\t/// Reads the app.config file root into a Json object\n\t\t\t///\n\t\t\t/// @return App config as json object\n\t\t\t///\n\t\t\tinline Json::Value ReadAppConfig() noexcept\n\t\t\t{\n\t\t\t\t// Get current executable directory\n\t\t\t\tchar arg1[20];\n\t\t\t\tchar exepath[PATH_MAX + 1] = {0};\n\n\t\t\t\tsprintf(arg1, \"/proc/%d/exe\", getpid());\n\t\t\t\treadlink(arg1, exepath, 1024 );\n\n\t\t\t\tstd::string path = std::string(exepath);\n\t\t\t\tstd::string::size_type pos = path.find_last_of(\"/\");\n\t\t\t\tstd::string workingDir = ChilliSource::StringUtils::StandardiseDirectoryPath(path.substr(0, pos));\n\n\t\t\t\t//open the file\n\t\t\t\tstd::ifstream file(workingDir + \"assets/AppResources/App.config\");\n\n\t\t\t\tJson::Value root;\n\n\t\t\t\tif (file.good() == true)\n\t\t\t\t{\n\t\t\t\t\tstd::string contents((std::istreambuf_iterator<s8>(file)), std::istreambuf_iterator<s8>());\n\n\t\t\t\t\t//parse the json\n\t\t\t\t\tJson::Reader jReader;\n\t\t\t\t\tif (!jReader.parse(contents, root))\n\t\t\t\t\t{\n\t\t\t\t\t\tprintf(\"[ChilliSource] Could not parse App.config: %s \\n\", jReader.getFormattedErrorMessages().c_str());\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tprintf(\"[ChilliSource] Error reading App.config.\");\n\t\t\t\t}\n\n\t\t\t\treturn root;\n\t\t\t}\n\n\t\t\t/// Reads the surface format from the App.config file.\n\t\t\t///\n\t\t\t/// @param root\n\t\t\t///\t\tApp config Json root\n\t\t\t///\n\t\t\t/// @return The surface format.\n\t\t\t///\n\t\t\tinline ChilliSource::SurfaceFormat ReadSurfaceFormat(const Json::Value& root) noexcept\n\t\t\t{\n\t\t\t\tconst std::string k_defaultFormat = \"rgb565_depth24\";\n\t\t\t\tstd::string formatString = root.get(\"PreferredSurfaceFormat\", k_defaultFormat).asString();\n\n\t\t\t\tconst Json::Value& rpi = root[\"RPi\"];\n\t\t\t\tif (rpi.isNull() == false && rpi.isMember(\"PreferredSurfaceFormat\"))\n\t\t\t\t{\n\t\t\t\t\tformatString = rpi[\"PreferredSurfaceFormat\"].asString();\n\t\t\t\t}\n\n\t\t\t\treturn ChilliSource::ParseSurfaceFormat(formatString);\n\t\t\t}\n\n\t\t\t/// Reads the multisample format from the App.config file.\n\t\t\t///\n\t\t\t/// @param root\n\t\t\t///\t\tApp config Json root\n\t\t\t///\n\t\t\t/// @return Number times multisample 0x, 2x, 4x.\n\t\t\t///\n\t\t\tinline u32 ReadMultisampleFormat(const Json::Value& root) noexcept\n\t\t\t{\n\t\t\t\tstd::string stringFormat = root.get(\"Multisample\", \"None\").asString();\n\n\t\t\t\tconst Json::Value& rpi = root[\"RPi\"];\n\t\t\t\tif (rpi.isNull() == false && rpi.isMember(\"Multisample\"))\n\t\t\t\t{\n\t\t\t\t\tstringFormat = rpi[\"Multisample\"].asString();\n\t\t\t\t}\n\n\t\t\t\tChilliSource::StringUtils::ToLowerCase(stringFormat);\n\n\t\t\t\tif (stringFormat == \"none\")\n\t\t\t\t{\n\t\t\t\t\tprintf(\"[ChilliSource] WARNING: Multisampling is not yet supported on Raspberry Pi\\n\");\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t\telse if (stringFormat == \"2x\")\n\t\t\t\t{\n\t\t\t\t\tprintf(\"[ChilliSource] WARNING: Multisampling is not yet supported on Raspberry Pi\\n\");\n\t\t\t\t\treturn 2;\n\t\t\t\t}\n\t\t\t\telse if (stringFormat == \"4x\")\n\t\t\t\t{\n\t\t\t\t\treturn 4;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tprintf(\"[ChilliSource] Unknown multisample format : %s .Options are None, 2x or 4x\\n\", stringFormat.c_str());\n\t\t\t\t}\n\n\t\t\t\treturn 0;\n\t\t\t}\n\n\n\t\t\t/// Creates an EGLConfigChooser that will select the closest EGL config that\n\t\t\t/// matches the preferred configuration in the app.config\n\t\t\t///\n\t\t\t/// @param appConfigRoot\n\t\t\t///\t\tApp config json root\n\t\t\t///\n\t\t\t/// @return Config chooser that when executed will pick the closest supported config\n\t\t\t///\n\t\t\tinline EGLConfigChooser CreateConfigChooser(const Json::Value& appConfigRoot) noexcept\n\t\t\t{\n\t\t\t\tChilliSource::SurfaceFormat surfaceFormat = ReadSurfaceFormat(appConfigRoot);\n\n\t\t\t\tswitch(surfaceFormat)\n\t\t\t\t{\n\t\t\t\t\tcase ChilliSource::SurfaceFormat::k_rgb565_depth24:\n\t\t\t\t\t\treturn EGLConfigChooser(5, 6, 5, 0, 16, 24, 0);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase ChilliSource::SurfaceFormat::k_rgb565_depth32:\n\t\t\t\t\t\treturn EGLConfigChooser(5, 6, 5, 0, 16, 32, 0);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase ChilliSource::SurfaceFormat::k_rgb888_depth24:\n\t\t\t\t\t\treturn EGLConfigChooser(8, 8, 8, 0, 16, 24, 0);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase ChilliSource::SurfaceFormat::k_rgb888_depth32:\n\t\t\t\t\t\treturn EGLConfigChooser(8, 8, 8, 0, 16, 32, 0);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase ChilliSource::SurfaceFormat::k_rgb565_depth24_stencil8:\n\t\t\t\t\t\treturn EGLConfigChooser(5, 6, 5, 0, 16, 24, 8);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase ChilliSource::SurfaceFormat::k_rgb565_depth32_stencil8:\n\t\t\t\t\t\treturn EGLConfigChooser(5, 6, 5, 0, 16, 32, 8);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase ChilliSource::SurfaceFormat::k_rgb888_depth24_stencil8:\n\t\t\t\t\t\treturn EGLConfigChooser(8, 8, 8, 0, 16, 24, 8);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase ChilliSource::SurfaceFormat::k_rgb888_depth32_stencil8:\n\t\t\t\t\t\treturn EGLConfigChooser(8, 8, 8, 0, 16, 32, 8);\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\t// Default to k_rgb565_depth24.\n\t\t\t\tCS_LOG_WARNING(\"Couldn't get EGLConfig from App.config. Defaulting to RGB565_DEPTH24.\");\n\t\t\t\treturn EGLConfigChooser(5, 6, 5, 0, 16, 24, 0);\n\t\t\t}\n\n\t\t\t/// Reads the desired window title from the AppConfig.\n\t\t\t///\n\t\t\t/// @param appConfigRoot\n\t\t\t///\t\tApp config json root\n\t\t\t///\n\t\t\t/// @return Window title\n\t\t\t///\n\t\t\tinline std::string ReadDesiredTitle(const Json::Value& appConfigRoot) noexcept\n\t\t\t{\n\t\t\t\tstd::string titleString = \"Application\";\n\n\t\t\t\ttitleString = appConfigRoot.get(\"DisplayableName\", titleString).asString();\n\n\t\t\t\treturn titleString;\n\t\t\t}\n\n\t\t\t/// @param appConfigRoot\n\t\t\t///\t\tThe app config JSON\n\t\t\t/// @param fallbackResolution\n\t\t\t///\t\tWindow res to fallback on if none are specified\n\t\t\t///\n\t\t\t/// @return Inital window resolution as read from the config\n\t\t\t///\n\t\t\tinline ChilliSource::Integer2 ReadInitialWindowSize(const Json::Value& appConfigRoot, const ChilliSource::Integer2& fallbackResolution) noexcept\n\t\t\t{\n\t\t\t\tChilliSource::Integer2 res = fallbackResolution;\n\t\t\t\tconst Json::Value& resObj = appConfigRoot[\"WindowResolution\"];\n\t\t\t\tif(resObj.isNull() == false)\n\t\t\t\t{\n\t\t\t\t\tres = ChilliSource::ParseInteger2(resObj.asString());\n\t\t\t\t}\n\t\t\t\tconst Json::Value& platformObj = appConfigRoot[\"RPi\"];\n\t\t\t\tif(platformObj.isNull() == false)\n\t\t\t\t{\n\t\t\t\t\tconst Json::Value& resObjPlatform = platformObj[\"WindowResolution\"];\n\t\t\t\t\tif(resObjPlatform.isNull() == false)\n\t\t\t\t\t{\n\t\t\t\t\t\tres = ChilliSource::ParseInteger2(resObjPlatform.asString());\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn res;\n\t\t\t}\n\n\t\t\t/// @param appConfigRoot\n\t\t\t///\t\tThe app config JSON\n\t\t\t///\n\t\t\t/// @return Inital window mode as read from the config\n\t\t\t///\n\t\t\tinline ChilliSource::Screen::DisplayMode ReadInitialWindowMode(const Json::Value& appConfigRoot) noexcept\n\t\t\t{\n\t\t\t\tstd::string mode = appConfigRoot.get(\"WindowDisplayMode\", \"windowed\").asString();\n\t\t\t\tconst Json::Value& platformObj = appConfigRoot[\"RPi\"];\n\t\t\t\tif(platformObj.isNull() == false)\n\t\t\t\t{\n\t\t\t\t\tmode = platformObj.get(\"WindowDisplayMode\", mode.c_str()).asString();\n\t\t\t\t}\n\n\t\t\t\treturn ChilliSource::Screen::ParseDisplayMode(mode);\n\t\t\t}\n\t\t}\n\t\t\n\t\t//----------------------------------------------------------------------------------\n\t\tvoid DispmanWindow::Run() noexcept\n\t\t{\n\t\t\t//The display setup we use mimics Minecraft on the Raspberry Pi. Essentially we use a dispman display\n\t\t\t//to take advantage of hardware acceleration but we layer that on top of an X window which we use to listen\n\t\t\t//for events and to allow the user to control the size of the dispman display.\n\n\t\t\t//Start interfacing with Raspberry Pi.\n\t\t\tbcm_host_init();\n\n\t\t\tJson::Value appConfigRoot = ReadAppConfig();\n\n\t\t\tauto displayMode = ReadInitialWindowMode(appConfigRoot);\n\t\t\tReadMultisampleFormat(appConfigRoot);\n\n\t\t\tm_desktopSize = GetSupportedFullscreenResolutions()[0] - (GetSupportedFullscreenResolutions()[0] / 10);\n\t\t\tm_windowSize = ReadInitialWindowSize(appConfigRoot, displayMode == ChilliSource::Screen::DisplayMode::k_windowed ? m_desktopSize : GetSupportedFullscreenResolutions()[0]);\n\t\t\tm_windowPos = ChilliSource::Integer2::k_zero;\n\n\t\t\tInitXWindow(m_windowPos, m_windowSize, appConfigRoot);\n\t\t\tInitEGLDispmanWindow(m_windowPos, m_windowSize, appConfigRoot);\n\n\t\t\t//NOTE: We are creating ChilliSource here so no CS calls can be made prior to this including logging.\n\t\t\tChilliSource::ApplicationUPtr app = ChilliSource::ApplicationUPtr(CreateApplication(SystemInfoFactory::CreateSystemInfo()));\n\t\t\tm_lifecycleManager = ChilliSource::LifecycleManagerUPtr(new ChilliSource::LifecycleManager(app.get()));\n\t\t\tm_lifecycleManager->Resume();\n\n\t\t\tSetDisplayMode(displayMode);\n\n\t\t\tm_isRunning = true;\n\t\t\twhile(m_isRunning == true)\n\t\t\t{\n\t\t\t\tTick();\n\t\t\t}\n\t\t}\n\n\t\t//-----------------------------------------------------------------------------------\n\t\tvoid DispmanWindow::InitXWindow(const ChilliSource::Integer2& windowPos, const ChilliSource::Integer2& windowSize, const Json::Value& appConfigRoot) noexcept\n\t\t{\n\t\t\tm_xdisplay = XOpenDisplay(NULL);\n\t\t\tif(m_xdisplay == nullptr)\n\t\t\t{\n\t\t\t\tprintf(\"[ChilliSource] Failed to create X11 display. Exiting\");\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tm_xwindow = XCreateSimpleWindow(m_xdisplay, XDefaultRootWindow(m_xdisplay), windowPos.x, windowPos.y, windowSize.x, windowSize.y, 0, 0, 0);\n\n\t\t\tm_xinputMethod = XOpenIM(m_xdisplay, 0, 0, 0);\n\t\t\tm_xinputContext = XCreateIC(m_xinputMethod, XNClientWindow, m_xwindow, XNFocusWindow, m_xwindow, XNInputStyle, XIMPreeditNothing | XIMStatusNothing, 0);\n\n\t\t\t//Capture the window close message\n\t\t\tm_wmDeleteMessage = XInternAtom(m_xdisplay, \"WM_DELETE_WINDOW\", False);\n\t\t\tXSetWMProtocols(m_xdisplay, m_xwindow, &m_wmDeleteMessage, 1);\n\n\t\t\tXMapWindow(m_xdisplay, m_xwindow);\n\t\t\tXStoreName(m_xdisplay, m_xwindow, ReadDesiredTitle(appConfigRoot).c_str());\n\n\t\t\t//All the events we need to listen for\n\t\t\tXSelectInput(m_xdisplay, m_xwindow, PointerMotionMask | ButtonMotionMask | ButtonPressMask | ButtonReleaseMask | KeyPressMask | KeyReleaseMask | FocusChangeMask | StructureNotifyMask);\n\n\t\t\t//Sends all the commands to the X server.\n\t\t\tXFlush(m_xdisplay);\n\t\t}\n\n\t\t//-----------------------------------------------------------------------------------------\n\t\t//\n\t\t// /!\\ NOTE: The attribute below is used to instruct GCC not to optimize this function.\n\t\t//           This is required as optimizing here prevents the OpenGL context initializing.\n\t\t//\n\t\t//-----------------------------------------------------------------------------------------\n\t\tvoid __attribute__((optimize(\"O0\"))) DispmanWindow::InitEGLDispmanWindow(const ChilliSource::Integer2& windowPos, const ChilliSource::Integer2& windowSize, const Json::Value& appConfigRoot) noexcept\n\t\t{\n\t\t\t// Set up OpenGL context version (OpenGLES 2.0)\n\t\t\tstatic const EGLint contextAttributeList[] =\n\t\t\t{\n\t\t\t\tEGL_CONTEXT_CLIENT_VERSION, 2,\n\t\t\t\tEGL_NONE\n\t\t\t};\n\n\t\t\t// Setup the EGL display with the framebuffer config and the GL version\n\t\t\tm_eglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);\n\t\t\teglInitialize(m_eglDisplay, NULL, NULL);\n\n\t\t\t// Create ConfigChooser and choose an EGLConfig appropriately.\n\t\t\tEGLConfigChooser eglConfigChooser = CreateConfigChooser(appConfigRoot);\n\t\t\tm_eglConfig = eglConfigChooser.ChooseBestConfig(m_eglDisplay);\n\n\t\t\teglBindAPI(EGL_OPENGL_ES_API);\n\t\t\tm_eglContext = eglCreateContext(m_eglDisplay, m_eglConfig, EGL_NO_CONTEXT, contextAttributeList);\n\n\t\t\t// Set up blit rects.\n\t\t\tVC_RECT_T dstRect;\n\t\t\tvc_dispmanx_rect_set(&dstRect, windowPos.x, windowPos.y, windowSize.x, m_windowSize.y);\n\t\t\tVC_RECT_T srcRect;\n\t\t\tvc_dispmanx_rect_set(&srcRect, windowPos.x, windowPos.y, windowSize.x << 16, m_windowSize.y << 16);\n\n\t\t\t// Set up dispmanx\n\t\t\tm_displayManagerDisplay = vc_dispmanx_display_open(0);\n\t\t\tDISPMANX_UPDATE_HANDLE_T displayManagerUpdate = vc_dispmanx_update_start(0);\n\t\t\tm_displayManagerElement = vc_dispmanx_element_add(displayManagerUpdate, m_displayManagerDisplay, 0, &dstRect, 0, &srcRect, DISPMANX_PROTECTION_NONE, 0, 0, DISPMANX_NO_ROTATE);\n\n\t\t\t// Set up native window.\n\t\t\tm_nativeWindow.element = m_displayManagerElement;\n\t\t\tm_nativeWindow.width = windowSize.x;\n\t\t\tm_nativeWindow.height = windowSize.y;\n\n\t\t\t// Instruct VC chip to use this display manager to sync\n\t\t\tvc_dispmanx_update_submit_sync(displayManagerUpdate);\n\n\t\t\t// Set up EGL surface and connect the context to it\n\t\t\tm_eglSurface = eglCreateWindowSurface(m_eglDisplay, m_eglConfig, &m_nativeWindow, NULL);\n\t\t\teglMakeCurrent(m_eglDisplay, m_eglSurface, m_eglSurface, m_eglContext);\n\t\t}\n\n\t\t//-----------------------------------------------------------------------------------\n\t\tvoid DispmanWindow::Tick() noexcept\n\t\t{\n\t\t\twhile(XPending(m_xdisplay))\n\t\t\t{\n\t\t\t\tXEvent event;\n\t\t\t\tXNextEvent(m_xdisplay, &event);\n\n\t\t\t\tswitch (event.type)\n\t\t\t\t{\n\t\t\t\t\tcase FocusIn:\n\t\t\t\t\t{\n\t\t\t\t\t\tXSetICFocus(m_xinputContext);\n\t\t\t\t\t\tif(m_isFocused == false)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tm_isFocused = true;\n\t\t\t\t\t\t\tm_lifecycleManager->Foreground();\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase FocusOut:\n\t\t\t\t\t{\n\t\t\t\t\t\tXUnsetICFocus(m_xinputContext);\n\t\t\t\t\t\tif(m_isFocused == true)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tm_isFocused = false;\n\t\t\t\t\t\t\tm_lifecycleManager->Background();\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase ConfigureNotify:\n\t\t\t\t\t{\n\t\t\t\t\t\tbool resized = event.xconfigure.width != m_windowSize.x || event.xconfigure.height != m_windowSize.y;\n\t\t\t\t\t\tif(resized == true)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tm_windowSize.x = event.xconfigure.width;\n\t\t\t\t\t\t\tm_windowSize.y = event.xconfigure.height;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t//When resizing the window we receive a real event and a synthetic event. The real event has wrong\n\t\t\t\t\t\t//x, y coordinates so we must use the ones from the synthetic event. When moving the window we only\n\t\t\t\t\t\t//get the synthetic event.\n\t\t\t\t\t\tif(event.xconfigure.send_event == true)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tm_windowPos.x = event.xconfigure.x;\n\t\t\t\t\t\t\tm_windowPos.y = event.xconfigure.y;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t//Update the EGL window to match the xwindow's new size or position\n\t\t\t\t\t\tUpdateEGLWindow();\n\n\t\t\t\t\t\tstd::unique_lock<std::mutex> lock(m_windowMutex);\n\t\t\t\t\t\tif (resized && m_windowResizeDelegate)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tm_windowResizeDelegate(m_windowSize);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase MotionNotify:\n\t\t\t\t\t{\n\t\t\t\t\t\tstd::unique_lock<std::mutex> lock(m_mouseMutex);\n\t\t\t\t\t\tif (m_mouseMovedDelegate)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tm_mouseMovedDelegate(event.xbutton.x, event.xbutton.y);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase ButtonPress:\n\t\t\t\t\t{\n\t\t\t\t\t\tstd::unique_lock<std::mutex> lock(m_mouseMutex);\n\t\t\t\t\t\tif (m_mouseButtonDelegate)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tm_mouseButtonDelegate(event.xbutton.button, MouseButtonEvent::k_pressed);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase ButtonRelease:\n\t\t\t\t\t{\n\t\t\t\t\t\tstd::unique_lock<std::mutex> lock(m_mouseMutex);\n\t\t\t\t\t\tif (m_mouseButtonDelegate)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tm_mouseButtonDelegate(event.xbutton.button, MouseButtonEvent::k_released);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase KeyPress:\n\t\t\t\t\t{\n\t\t\t\t\t\tstd::unique_lock<std::mutex> keyLock(m_keyMutex);\n\t\t\t\t\t\tif(m_keyboardEventDelegate)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tm_keyboardEventDelegate(XkbKeycodeToKeysym(m_xdisplay, event.xkey.keycode, 0, 0), event.xkey.state, KeyboardEvent::k_pressed);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tkeyLock.unlock();\n\n\t\t\t\t\t\tstd::unique_lock<std::mutex> textLock(m_textMutex);\n\t\t\t\t\t\tif(m_textEntryEventDelegate)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tif(XFilterEvent(&event, m_xwindow) == false)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tStatus status;\n\t\t\t\t\t\t\t\tu8 keyBuffer[4] = {0};\n\t\t\t\t\t\t\t\tauto length = Xutf8LookupString(m_xinputContext, &event.xkey, (char*)keyBuffer, sizeof(keyBuffer), 0, &status);\n\t\t\t\t\t\t\t\tif(length > 0)\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tChilliSource::UTF8Char utf8Char = keyBuffer[0] | (keyBuffer[1] << 8) | (keyBuffer[2] << 16) | (keyBuffer[3] << 24);\n\t\t\t\t\t\t\t\t\tm_textEntryEventDelegate((u32)keyBuffer[0]);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase KeyRelease:\n\t\t\t\t\t{\n\t\t\t\t\t\tstd::unique_lock<std::mutex> lock(m_keyMutex);\n\t\t\t\t\t\tif(m_keyboardEventDelegate)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tm_keyboardEventDelegate(XkbKeycodeToKeysym(m_xdisplay, event.xkey.keycode, 0, 0), event.xkey.state, KeyboardEvent::k_released);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase ClientMessage:\n\t\t\t\t\t{\n            \t\t\tif (event.xclient.data.l[0] == m_wmDeleteMessage)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tQuit();\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t//Update, render and then flip display buffer\n\t\t\tm_lifecycleManager->SystemUpdate();\n\t\t\tm_lifecycleManager->Render();\n\n\t\t\t//NOTE: This enforces the VSync based on eglSwapInterval\n\t\t\teglSwapBuffers(m_eglDisplay, m_eglSurface);\n\n\t\t\tif(m_quitScheduled)\n\t\t\t{\n\t\t\t\tQuit();\n\t\t\t}\n\t\t}\n\n\t\t//-----------------------------------------------------------------------------------\n\t\tvoid DispmanWindow::SetPreferredFPS(u32 fps) noexcept\n\t\t{\n\t\t\teglSwapInterval(m_eglDisplay, 60u/fps);\n\t\t}\n\n\t\t//-----------------------------------------------------------------------------------\n\t\tvoid DispmanWindow::SetSize(const ChilliSource::Integer2& size) noexcept\n\t\t{\n\t\t\tif(size == m_windowSize)\n\t\t\t\treturn;\n\n\t\t\tif (m_displayMode == ChilliSource::Screen::DisplayMode::k_fullscreen)\n\t\t\t{\n\t\t\t\tCS_ASSERT(ChilliSource::VectorUtils::Contains(GetSupportedFullscreenResolutions(), size) == true, \"Resolution not supported in fullscreen mode (SetSize).\");\n\t\t\t}\n\n\t\t\tm_windowSize = size;\n\t\t\tXWindowChanges wc;\n\t\t\twc.x = m_windowPos.x;\n\t\t\twc.y = m_windowPos.y;\n\t\t\twc.width = size.x;\n\t\t\twc.height = size.y;\n\t\t\tXConfigureWindow(m_xdisplay, m_xwindow, CWX|CWY|CWWidth|CWHeight, &wc);\n\t\t\tXSync(m_xdisplay, False);\n\t\t}\n\n\t\t//-----------------------------------------------------------------------------------\n\t\tvoid DispmanWindow::SetDisplayMode(ChilliSource::Screen::DisplayMode mode) noexcept\n\t\t{\n\t\t\tif (mode == m_displayMode)\n\t\t\t\treturn;\n\n\t\t\tm_displayMode = mode;\n\n\t\t\tXEvent fullscreenEvent;\n\t\t\tAtom x11_state_atom\t= XInternAtom(m_xdisplay, \"_NET_WM_STATE\", False);\n\t\t\tAtom x11_fs_atom = XInternAtom(m_xdisplay, \"_NET_WM_STATE_FULLSCREEN\", False);\n\n\t\t\tfullscreenEvent.xclient.type = ClientMessage;\n\t\t\tfullscreenEvent.xclient.serial = 0;\n\t\t\tfullscreenEvent.xclient.send_event = True;\n\t\t\tfullscreenEvent.xclient.window = m_xwindow;\n\t\t\tfullscreenEvent.xclient.message_type = x11_state_atom;\n\t\t\tfullscreenEvent.xclient.format = 32;\n\t\t\tfullscreenEvent.xclient.data.l[1] = x11_fs_atom;\n\t\t\tfullscreenEvent.xclient.data.l[2] = 0;\n\n\t\t\tswitch (m_displayMode)\n\t\t\t{\n\t\t\t\tcase ChilliSource::Screen::DisplayMode::k_fullscreen:\n\t\t\t\t{\n\t\t\t\t\tCS_ASSERT(ChilliSource::VectorUtils::Contains(GetSupportedFullscreenResolutions(), m_windowSize) == true, \"Current resolution not supported in fullscreen mode.\");\n\n\t\t\t\t\tm_windowPosPreFullscreen = m_windowPos;\n\n\t\t\t\t\tfullscreenEvent.xclient.data.l[0] = 1;//_NET_WM_STATE_ADD;\n\n\t\t\t\t\tXSendEvent(m_xdisplay, XDefaultRootWindow(m_xdisplay), False, SubstructureRedirectMask | SubstructureNotifyMask, &fullscreenEvent);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase ChilliSource::Screen::DisplayMode::k_windowed:\n\t\t\t\t{\n\t\t\t\t\tm_windowPos = m_windowPosPreFullscreen;\n\n\t\t\t\t\tfullscreenEvent.xclient.data.l[0] = 0;//_NET_WM_STATE_REMOVE;\n\n\t\t\t\t\tXSendEvent(m_xdisplay, XDefaultRootWindow(m_xdisplay), False, SubstructureRedirectMask | SubstructureNotifyMask, &fullscreenEvent);\n\t\t\t\t\tSetSize(ChilliSource::Integer2::Min(m_windowSize, m_desktopSize));\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t//-----------------------------------------------------------------------------------\n\t\tvoid DispmanWindow::UpdateEGLWindow() noexcept\n\t\t{\n\t\t\tDISPMANX_UPDATE_HANDLE_T displayManagerUpdate = vc_dispmanx_update_start(0);\n\t\t\tVC_RECT_T dstRect;\n\t\t\tvc_dispmanx_rect_set(&dstRect, m_windowPos.x, m_windowPos.y, m_windowSize.x, m_windowSize.y);\n\t\t\tVC_RECT_T srcRect;\n\t\t\tvc_dispmanx_rect_set(&srcRect, m_windowPos.x, m_windowPos.y, m_windowSize.x << 16, m_windowSize.y << 16);\n\t\t\tvc_dispmanx_element_change_attributes(displayManagerUpdate, m_displayManagerElement, 0, 0, 0, &dstRect, &srcRect, 0, DISPMANX_NO_ROTATE);\n\n\t\t\tm_nativeWindow.width = m_windowSize.x;\n\t\t\tm_nativeWindow.height = m_windowSize.y;\n\n\t\t\tvc_dispmanx_update_submit_sync(displayManagerUpdate);\n\t\t}\n\n\t\t//-----------------------------------------------------------------------------------\n\t\tvoid DispmanWindow::SetWindowDelegates(WindowResizeDelegate windowResizeDelegate) noexcept\n\t\t{\n\t\t\tCS_ASSERT(windowResizeDelegate, \"Window resize delegate invalid.\");\n\t\t\tCS_ASSERT(!m_windowResizeDelegate, \"Window resize delegate already set.\");\n\n\t\t\tstd::unique_lock<std::mutex> lock(m_windowMutex);\n\t\t\tm_windowResizeDelegate = std::move(windowResizeDelegate);\n\t\t}\n\n\t\t//-----------------------------------------------------------------------------------\n\t\tvoid DispmanWindow::RemoveWindowDelegates() noexcept\n\t\t{\n\t\t\tstd::unique_lock<std::mutex> lock(m_windowMutex);\n\t\t\tm_windowResizeDelegate = nullptr;\n\t\t}\n\n\t\t//-----------------------------------------------------------------------------------\n\t\tvoid DispmanWindow::SetMouseDelegates(MouseButtonDelegate mouseButtonDelegate, MouseMovedDelegate mouseMovedDelegate) noexcept\n\t\t{\n\t\t\tstd::unique_lock<std::mutex> lock(m_mouseMutex);\n\n\t\t\tCS_ASSERT(mouseButtonDelegate, \"Mouse button event delegate invalid.\");\n\t\t\tCS_ASSERT(mouseMovedDelegate, \"Mouse moved delegate invalid.\");\n\t\t\tCS_ASSERT(!m_mouseButtonDelegate, \"Mouse button event delegate already set.\");\n\t\t\tCS_ASSERT(!m_mouseMovedDelegate, \"Mouse moved delegate already set.\");\n\n\t\t\tm_mouseButtonDelegate = std::move(mouseButtonDelegate);\n\t\t\tm_mouseMovedDelegate = std::move(mouseMovedDelegate);\n\t\t}\n\n\t\t//-----------------------------------------------------------------------------------\n\t\tvoid DispmanWindow::RemoveMouseDelegates() noexcept\n\t\t{\n\t\t\tstd::unique_lock<std::mutex> lock(m_mouseMutex);\n\t\t\tm_mouseButtonDelegate = nullptr;\n\t\t\tm_mouseMovedDelegate = nullptr;\n\t\t}\n\n\t\t//-----------------------------------------------------------------------------------\n\t\tChilliSource::Integer2 DispmanWindow::GetMousePosition() const noexcept\n\t\t{\n\t\t\tWindow root, child;\n\t\t\ts32 rootX, rootY, winX, winY;\n\t\t\tu32 buttonMask;\n\t\t\tXQueryPointer(m_xdisplay, m_xwindow, &root, &child, &rootX, &rootY, &winX, &winY, &buttonMask);\n\n\t\t\treturn ChilliSource::Integer2(winX, winY);\n\t\t}\n\n\t\t//-----------------------------------------------------------------------------------\n\t\tvoid DispmanWindow::SetKeyboardDelegates(KeyboardEventDelegate keyboardEventDelegate) noexcept\n\t\t{\n\t\t\tstd::unique_lock<std::mutex> lock(m_keyMutex);\n\n\t\t\tCS_ASSERT(keyboardEventDelegate, \"Keyboard event delegate invalid.\");\n\t\t\tCS_ASSERT(!m_keyboardEventDelegate, \"Keyboard event delegate already set.\");\n\n\t\t\tm_keyboardEventDelegate = std::move(keyboardEventDelegate);\n\t\t}\n\n\t\t//-----------------------------------------------------------------------------------\n\t\tvoid DispmanWindow::RemoveKeyboardDelegates() noexcept\n\t\t{\n\t\t\tstd::unique_lock<std::mutex> lock(m_keyMutex);\n\t\t\tm_keyboardEventDelegate = nullptr;\n\t\t}\n\n\t\t//-----------------------------------------------------------------------------------\n\t\tvoid DispmanWindow::SetTextEntryDelegates(TextEntryEventDelegate textEntryEventDelegate) noexcept\n\t\t{\n\t\t\tstd::unique_lock<std::mutex> lock(m_textMutex);\n\n\t\t\tCS_ASSERT(textEntryEventDelegate, \"Text entry event delegate invalid.\");\n\t\t\tCS_ASSERT(!m_textEntryEventDelegate, \"Text entry event delegate already set.\");\n\n\t\t\tm_textEntryEventDelegate = std::move(textEntryEventDelegate);\n\t\t}\n\n\t\t//-----------------------------------------------------------------------------------\n\t\tvoid DispmanWindow::RemoveTextEntryDelegates() noexcept\n\t\t{\n\t\t\tstd::unique_lock<std::mutex> lock(m_textMutex);\n\t\t\tm_textEntryEventDelegate = nullptr;\n\t\t}\n\n\t\t//-----------------------------------------------------------------------------------\n\t\tstd::vector<ChilliSource::Integer2> DispmanWindow::GetSupportedFullscreenResolutions() const noexcept\n\t\t{\n\t\t\tu32 width(0), height(0);\n\t\t\tgraphics_get_display_size(0, &width, &height);\n\t\t\treturn std::vector<ChilliSource::Integer2> { ChilliSource::Integer2((s32)width, (s32)height) };\n\t\t}\n\n\t\t//-----------------------------------------------------------------------------------\n\t\tvoid DispmanWindow::Quit() noexcept\n\t\t{\n\t\t\tif (m_isFocused == true)\n\t\t\t{\n\t\t\t\tm_lifecycleManager->Background();\n\t\t\t\tm_isFocused = false;\n\t\t\t}\n\n\t\t\tm_lifecycleManager->Suspend();\n\t\t\tm_lifecycleManager.reset();\n\n\t\t\tm_isRunning = false;\n\t\t}\n\n\t\t//-----------------------------------------------------------------------------------\n\t\tDispmanWindow::~DispmanWindow() noexcept\n\t\t{\n\t\t\tCS_ASSERT(!m_windowResizeDelegate, \"Window resize delegate not removed.\");\n\t\t\tCS_ASSERT(!m_mouseButtonDelegate, \"Mouse button event delegate not removed.\");\n\t\t\tCS_ASSERT(!m_mouseMovedDelegate, \"Mouse moved delegate not removed.\");\n\t\t\tCS_ASSERT(!m_keyboardEventDelegate, \"Keyboard event delegate not removed.\");\n\t\t\tCS_ASSERT(!m_textEntryEventDelegate, \"Text entry event delegate not removed\");\n\n\t\t\teglDestroyContext(m_eglDisplay, m_eglContext);\n\t\t\teglDestroySurface(m_eglDisplay, m_eglSurface);\n\t\t\teglTerminate(m_eglDisplay);\n\n\t\t\tif(m_xdisplay)\n\t\t\t{\n\t\t\t\tXDestroyIC(m_xinputContext);\n\t\t\t\tXCloseIM(m_xinputMethod);\n\t\t\t\tXDestroyWindow(m_xdisplay, m_xwindow);\n\t\t\t\tXCloseDisplay(m_xdisplay);\n\t\t\t}\n\n\t\t\tbcm_host_deinit();\n\t\t}\n\t}\n}\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/RPi/Core/Base/DispmanWindow.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2017 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_RPI\n\n#ifndef _CSBACKEND_PLATFORM_RPI_CORE_BASE_DISPMANWINDOW_H_\n#define _CSBACKEND_PLATFORM_RPI_CORE_BASE_DISPMANWINDOW_H_\n\n#include <CSBackend/Platform/RPi/ForwardDeclarations.h>\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Base/LifecycleManager.h>\n#include <ChilliSource/Core/Base/Singleton.h>\n#include <ChilliSource/Core/Base/Screen.h>\n#include <ChilliSource/Core/Math/Vector2.h>\n#include <ChilliSource/Core/String/UTF8StringUtils.h>\n\n#include <json/json.h>\n\n#include <bcm_host.h>\n#include <GLES2/gl2.h>\n#include <EGL/egl.h>\n#include <EGL/eglext.h>\n#include <X11/Xlib.h>\n#include <X11/keysym.h>\n\n#include <vector>\n#include <functional>\n#include <mutex>\n\nnamespace CSBackend\n{\n\tnamespace RPi\n\t{\n\t\t/// Class for interfacing with the Raspberry Pi's dispmanx library/video driver.\n\t\t///\n\t\t/// While some methods in this class are thread-safe, most should be called\n\t\t/// on the system thread.\n\t\t///\n\t\tclass DispmanWindow final : public ChilliSource::Singleton<DispmanWindow>\n\t\t{\n\t\tpublic:\n\n\t\t\t/// List of the events that can occur on a mouse button\n\t\t\t///\n\t\t\tenum class MouseButtonEvent\n\t\t\t{\n\t\t\t\tk_pressed,\n\t\t\t\tk_released\n\t\t\t};\n\n\t\t\t/// List of the events that can occur on a keyboard event\n\t\t\t///\n\t\t\tenum class KeyboardEvent\n\t\t\t{\n\t\t\t\tk_pressed,\n\t\t\t\tk_released\n\t\t\t};\n\n\t\t\t/// @param The new window size.\n\t\t\t///\n\t\t\tusing WindowResizeDelegate = std::function<void(const ChilliSource::Integer2&)>;\n\n\t\t\t/// @param Mouse button that the action occurred on\n\t\t\t/// @param The event type (Pressed/Released)\n\t\t\t///\n\t\t\tusing MouseButtonDelegate = std::function<void(u32, MouseButtonEvent)>;\n\n\t\t\t/// @param Mouse position X (in window coords)\n\t\t\t/// @param Mouse position Y (in window coords)\n\t\t\t///\n\t\t\tusing MouseMovedDelegate = std::function<void(s32, s32)>;\n\n\t\t\t/// @param X11 KeySym that the action occured on\n\t\t\t/// @param X11 Key modifier mask\n\t\t\t/// @param The event type (Pressed/Released)\n\t\t\t///\n\t\t\tusing KeyboardEventDelegate = std::function<void(u32, u32, KeyboardEvent)>;\n\n\t\t\t/// @param Utf-8 character\n\t\t\t///\n\t\t\tusing TextEntryEventDelegate = std::function<void(ChilliSource::UTF8Char)>;\n\n\t\t\t/// Create and run the application; this will update and render the app.\n\t\t\t///\n\t\t\tvoid Run() noexcept;\n\n\t\t\t/// Sets the vblank interval on OpenGL buffer swap\n\t\t\t///\n\t\t\t///\t@param fps\n\t\t\t///\t\tThe maximum frames per second to clamp to.\n\t\t\t///\t\tThis should be in multiples of 15 to match the behaviour of other platforms (e.g. 15, 30, 60)\n            ///\n\t\t\tvoid SetPreferredFPS(u32 fps) noexcept;\n\n\t\t\t/// @return Current resolution of the dispman window\n\t\t\t///\n\t\t\tChilliSource::Integer2 GetWindowSize() const noexcept { return m_windowSize; }\n\n\t\t\t/// @param size\n\t\t\t///\t\tSize to make window in pixels\n\t\t\t///\n\t\t\tvoid SetSize(const ChilliSource::Integer2& size) noexcept;\n\n\t\t\t/// Use to toggle between fullscreen and window\n\t\t\t///\n\t\t\t/// @param mode\n\t\t\t///\t\tWindowed or fullscreen\n\t\t\t///\n\t\t\tvoid SetDisplayMode(ChilliSource::Screen::DisplayMode mode) noexcept;\n\n\t\t\t/// @return List of the resolutions supported by the Raspberry Pi's video drivers\n\t\t\t///\n\t\t\tstd::vector<ChilliSource::Integer2> GetSupportedFullscreenResolutions() const noexcept;\n\n\t\t\t/// Set the delegates that are called when the window changes\n\t\t\t/// This method will assert if a given delegate is null or if the delegate has already been set.\n\t\t\t///\n\t\t\t/// This method is thread-safe.\n\t\t\t///\n\t\t\t/// @param windowResizeDelegate\n\t\t\t///\t\tThe delegate called when the window resizes\n\t\t\t///\n\t\t\tvoid SetWindowDelegates(WindowResizeDelegate windowResizeDelegate) noexcept;\n\n\t\t\t/// Remove the delegates that relate to window events.\n\t\t\t///\n\t\t\t/// This method is thread-safe.\n\t\t\t///\n\t\t\tvoid RemoveWindowDelegates() noexcept;\n\n\t\t\t/// Set the delegates that are called on the various mouse events (button, moved, scrolled)\n\t\t\t/// This method will assert if a given delegate is null or if the delegate has already been set.\n\t\t\t///\n\t\t\t/// This method is thread-safe.\n\t\t\t///\n\t\t\t/// @param mouseButtonDelegate\n\t\t\t///\t\tThe delegate called when a mouse button event occurs. In X11 the scroll wheel acts like a button getting pressed events for each tick\n\t\t\t/// @param mouseMovedDelegate\n\t\t\t///\t\tThe delegate called when the mouse is moved.\n\t\t\t///\n\t\t\tvoid SetMouseDelegates(MouseButtonDelegate mouseButtonDelegate, MouseMovedDelegate mouseMovedDelegate) noexcept;\n\n\t\t\t/// Remove the delegates that relate to mouse events.\n\t\t\t///\n\t\t\t/// This method is thread-safe.\n\t\t\t///\n\t\t\tvoid RemoveMouseDelegates() noexcept;\n\n\t\t\t/// @return The current window position of the mouse\n\t\t\t///\n\t\t\tChilliSource::Integer2 GetMousePosition() const noexcept;\n\n\t\t\t/// Set the delegates that are called on the various keyboard events (press/release)\n\t\t\t/// This method will assert if a given delegate is null or if the delegate has already been set.\n\t\t\t///\n\t\t\t/// This method is thread-safe.\n\t\t\t///\n\t\t\t/// @param keyboardEventDelegate\n\t\t\t///\t\tThe delegate called when a keyboard event occurs.\n\t\t\t///\n\t\t\tvoid SetKeyboardDelegates(KeyboardEventDelegate keyboardEventDelegate) noexcept;\n\n\t\t\t/// Remove the delegates that relate to keyboard events.\n\t\t\t///\n\t\t\t/// This method is thread-safe.\n\t\t\t///\n\t\t\tvoid RemoveKeyboardDelegates() noexcept;\n\n\t\t\t/// Sets the delegate called on text entry. This differs from keyboard events in that the modifier keys\n\t\t\t/// are applied and the key press is converted to a utf-8 character.\n\t\t\t///\n\t\t\t/// This method will assert if a given delegate is null or if the delegate has already been set.\n\t\t\t///\n\t\t\t/// This method is thread-safe.\n\t\t\t///\n\t\t\t/// @param textEntryEventDelegate\n\t\t\t///\t\tThe delegate called when a text entry event occurs.\n\t\t\t///\n\t\t\tvoid SetTextEntryDelegates(TextEntryEventDelegate textEntryEventDelegate) noexcept;\n\n\t\t\t/// Remove the delegates that relate to text entry events.\n\t\t\t///\n\t\t\t/// This method is thread-safe.\n\t\t\t///\n\t\t\tvoid RemoveTextEntryDelegates() noexcept;\n\n\t\t\t/// Tell the main loop to shutdown and the windows to close gracefull at the\n\t\t\t/// end of the next update\n\t\t\t///\n\t\t\tvoid ScheduleQuit() noexcept { m_quitScheduled = true; }\n\n            /// Destructor; makes sure that the BCM interface is\n            /// properly un-set.\n            ///\n            ~DispmanWindow() noexcept;\n\n\t    private:\n\n\t\t\t/// Initialise and display the X11 window and register for X events. The X11\n\t\t\t/// window is responsible for the size and position of the GL dispman window and for\n\t\t\t/// receiving mouse and keyboard events\n\t\t\t///\n\t\t\t/// @param windowPos\n\t\t\t///\t\tX, Y position of the window to create\n\t\t\t/// @param windowSize\n\t\t\t///\t\tSize of the window to create\n\t\t\t/// @param appConfigRoot\n\t\t\t///\t\tParsed JSON of the app config used to configure the window\n\t\t\t///\n\t\t\tvoid InitXWindow(const ChilliSource::Integer2& windowPos, const ChilliSource::Integer2& windowSize, const Json::Value& appConfigRoot) noexcept;\n\n\t\t\t/// Initialise the dispman window and OpenGLES based on the previously created XWindow.\n\t\t\t///\n\t\t\t/// @param windowPos\n\t\t\t///\t\tX, Y position of the window to create (should be created at the same pos as the X window)\n\t\t\t/// @param windowSize\n\t\t\t///\t\tSize of the window to create (should be created at the same size as the X window)\n\t\t\t/// @param appConfigRoot\n\t\t\t///\t\tParsed JSON of the app config used to configure the window\n\t\t\t///\n\t\t\tvoid InitEGLDispmanWindow(const ChilliSource::Integer2& windowPos, const ChilliSource::Integer2& windowSize, const Json::Value& appConfigRoot) noexcept;\n\n\t\t\t/// Single system loop responsible for X server events, rendering and display buffer swaps. The repeating main loop can be\n\t\t\t/// terminated by calling quit. This run loop can be optionally tied to vsync\n\t\t\t///\n\t\t\tvoid Tick() noexcept;\n\n\t\t\t/// Update the size and pos of the dispman EGL window\n\t\t\t///\n\t\t\tvoid UpdateEGLWindow() noexcept;\n\n\t\t\t/// Terminates the application loop gracefully.\n\t\t\t///\n\t\t\tvoid Quit() noexcept;\n\n\t\tprivate:\n\n\t\t\t/// EGL Objects needed for dispmanx.\n\t\t\tEGLDisplay m_eglDisplay;\n\t\t\tEGLConfig m_eglConfig;\n\t\t\tEGLSurface m_eglSurface;\n\t\t\tEGLContext m_eglContext;\n\t\t\tEGLint m_eglConfigNum;\n\n\t\t\t/// Dispmanx handles\n\t\t\tDISPMANX_ELEMENT_HANDLE_T m_displayManagerElement;\n\t\t\tDISPMANX_DISPLAY_HANDLE_T m_displayManagerDisplay;\n\n\t\t\t/// Dispmanx window\n\t\t\tEGL_DISPMANX_WINDOW_T m_nativeWindow;\n\n\t\t\t/// X11\n\t\t\tDisplay* m_xdisplay = nullptr;\n\t\t\tWindow m_xwindow;\n\t\t\tAtom m_wmDeleteMessage;\n\t\t\tXIM m_xinputMethod;\n\t\t\tXIC m_xinputContext;\n\n\t\t\t/// Program state stuff\n\t\t\tbool m_isRunning = false;\n\t\t\tbool m_isFocused = false;\n\t\t\tbool m_quitScheduled = false;\n\t\t\tChilliSource::Screen::DisplayMode m_displayMode = ChilliSource::Screen::DisplayMode::k_windowed;\n\t\t\tChilliSource::Integer2 m_desktopSize;\n\t\t\tChilliSource::Integer2 m_windowSize;\n\t\t\tChilliSource::Integer2 m_windowPos;\n\t\t\tChilliSource::Integer2 m_windowPosPreFullscreen;\n\n\t\t\t/// Event delegates\n\t\t\tstd::mutex m_mouseMutex;\n\t\t\tMouseButtonDelegate m_mouseButtonDelegate;\n\t\t\tMouseMovedDelegate m_mouseMovedDelegate;\n\n\t\t\tstd::mutex m_windowMutex;\n\t\t\tWindowResizeDelegate m_windowResizeDelegate;\n\n\t\t\tstd::mutex m_keyMutex;\n\t\t\tKeyboardEventDelegate m_keyboardEventDelegate;\n\n\t\t\tstd::mutex m_textMutex;\n\t\t\tTextEntryEventDelegate m_textEntryEventDelegate;\n\n\t\t\tChilliSource::LifecycleManagerUPtr m_lifecycleManager;\n\t\t};\n\t}\n}\n\n#endif\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/RPi/Core/Base/EGLConfigChooser.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2017 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_RPI\n\n#include <CSBackend/Platform/RPi/Core/Base/EGLConfigChooser.h>\n\nnamespace CSBackend\n{\n    namespace RPi\n    {\n        //---------------------------------------------------------------------\n        EGLConfigChooser::EGLConfigChooser(EGLint redSize, EGLint greenSize, EGLint blueSize, EGLint alphaSize, EGLint minDepthSize, EGLint preferredDepthSize, EGLint minStencilSize) noexcept\n        {\n            m_redSize = redSize;\n            m_greenSize = greenSize;\n            m_blueSize = blueSize;\n            m_alphaSize = alphaSize;\n            m_minDepthSize = minDepthSize;\n            m_preferredDepthSize = preferredDepthSize;\n            m_minStencilSize = minStencilSize;\n        }\n\n        //---------------------------------------------------------------------\n        EGLConfig EGLConfigChooser::ChooseBestConfig(EGLDisplay eglDisplay) noexcept\n        {\n            // Define the minimum-possible spec.\n            static const EGLint attributeList[] =\n            {\n                EGL_RED_SIZE, 4,\n                EGL_GREEN_SIZE, 4,\n                EGL_BLUE_SIZE, 4,\n                EGL_ALPHA_SIZE, 0,\n                EGL_DEPTH_SIZE, 0,\n                EGL_STENCIL_SIZE, 0,\n                EGL_SURFACE_TYPE, EGL_WINDOW_BIT,\n                EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,\n                EGL_NONE\n            };\n\n            // Find out how many configs satisfy this requirement.\n            EGLint numAvailableConfigs = 0;\n            eglChooseConfig(eglDisplay, attributeList, nullptr, 0, &numAvailableConfigs);\n\n            if(numAvailableConfigs <= 0)\n            {\n                CS_LOG_FATAL(\"Couldn't find any EGL Configurations that fit the minimum criteria; EGL possibly unsupported on device!\");\n            }\n\n            // Create a list with that size, and fill it.\n            EGLConfig* availableConfigs = new EGLConfig[numAvailableConfigs];\n            eglChooseConfig(eglDisplay, attributeList, availableConfigs, numAvailableConfigs, &numAvailableConfigs);\n\n            // Use this list with the Choose-From-List function.\n            EGLConfig bestConfig = ChooseBestConfigFromList(eglDisplay, availableConfigs, numAvailableConfigs);\n\n            // Clean up array.\n            delete[] availableConfigs;\n\n            return bestConfig;\n        }\n\n        //---------------------------------------------------------------------\n        EGLConfig EGLConfigChooser::ChooseBestConfigFromList(EGLDisplay eglDisplay, EGLConfig* eglConfigs, EGLint numConfigs) noexcept\n        {\n            u8 depthSize = m_preferredDepthSize;\n\n            // Loop through configs until we find one that matches or the depth\n            // size gets too small.\n            while(depthSize >= m_minDepthSize)\n            {\n                for(EGLint i = 0; i < numConfigs; i++)\n                {\n                    auto currentDepthSize = FindConfigAttribute(eglDisplay, eglConfigs[i], EGL_DEPTH_SIZE, 0);\n                    auto currentStencilSize = FindConfigAttribute(eglDisplay, eglConfigs[i], EGL_STENCIL_SIZE, 0);\n\n                    // We need >= minimum stencil/depth size.\n                    if(currentDepthSize >= depthSize && currentStencilSize >= m_minStencilSize)\n                    {\n                        // Need exact matches for colour depth.\n                        auto redSize = FindConfigAttribute(eglDisplay, eglConfigs[i], EGL_RED_SIZE, 0);\n                        auto greenSize = FindConfigAttribute(eglDisplay, eglConfigs[i], EGL_GREEN_SIZE, 0);\n                        auto blueSize = FindConfigAttribute(eglDisplay, eglConfigs[i], EGL_BLUE_SIZE, 0);\n                        auto alphaSize = FindConfigAttribute(eglDisplay, eglConfigs[i], EGL_ALPHA_SIZE, 0);\n\n                        if(redSize == m_redSize && greenSize == m_greenSize && blueSize == m_blueSize && alphaSize == m_alphaSize)\n                        {\n                            return eglConfigs[i];\n                        }\n                    }\n                }\n\n                depthSize -= 8;\n            }\n\n            return nullptr;\n        }\n\n        //---------------------------------------------------------------------\n        EGLint EGLConfigChooser::FindConfigAttribute(EGLDisplay eglDisplay, EGLConfig eglConfig, EGLint attribute, EGLint defaultValue) noexcept\n        {\n            EGLint* value = new EGLint[1];\n            if(eglGetConfigAttrib(eglDisplay, eglConfig, attribute, value) == true)\n            {\n                return value[0];\n            }\n\n            return defaultValue;\n        }\n    }\n}\n\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/RPi/Core/Base/EGLConfigChooser.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2017 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_RPI\n\n#ifndef _CSBACKEND_PLATFORM_RPI_CORE_BASE_EGLCONFIGCHOOSER_H_\n#define _CSBACKEND_PLATFORM_RPI_CORE_BASE_EGLCONFIGCHOOSER_H_\n\n#include <CSBackend/Platform/RPi/ForwardDeclarations.h>\n#include <ChilliSource/ChilliSource.h>\n\n#include <GLES2/gl2.h>\n#include <EGL/egl.h>\n#include <EGL/eglext.h>\n\nnamespace CSBackend\n{\n    namespace RPi\n    {\n        /// This class is used to pick an EGLConfig that matches as close as\n        /// possible with the specified attributes.\n        ///\n        class EGLConfigChooser final\n        {\n        public:\n\n            /// Constructs the ConfigChooser with the specified desired attributes.\n            ///\n            ///\n            EGLConfigChooser(EGLint redSize, EGLint greenSize, EGLint blueSize, EGLint alphaSize, EGLint minDepthSize, EGLint preferredDepthSize, EGLint minStencilSize) noexcept;\n\n            /// Picks the best EGLConfig using the specified desired attributes.\n            ///\n            /// @param The EGLDisplay to choose for.\n            EGLConfig ChooseBestConfig(EGLDisplay eglDisplay) noexcept;\n\n        private:\n            /// Picks the best EGLConfig out of the supplied config list.\n            ///\n            /// @param The EGLDisplay to choose for.\n            /// @param The array of EGLConfig objects to sort through.\n            /// @param The number of EGLConfig objects in that list.\n            EGLConfig ChooseBestConfigFromList(EGLDisplay eglDisplay, EGLConfig* eglConfigs, EGLint numConfigs) noexcept;\n\n            /// Finds a config attribute within a config, and returns its value.\n            /// If the value isn't found, returns the defaultValue parameter.\n            ///\n            /// @param The EGLDisplay to test against.\n            /// @param The EGLConfig to test against.\n            /// @param The EGLint representing the attribute to check for.\n            /// @param The default value of the attribute - returned if attribute isn't found in the config.\n            ///\n            EGLint FindConfigAttribute(EGLDisplay eglDisplay, EGLConfig eglConfig, EGLint attribute, EGLint defaultValue) noexcept;\n\n            EGLint m_redSize;\n            EGLint m_greenSize;\n            EGLint m_blueSize;\n            EGLint m_alphaSize;\n            EGLint m_minDepthSize;\n            EGLint m_preferredDepthSize;\n            EGLint m_minStencilSize;\n        };\n    }\n}\n\n#endif\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/RPi/Core/Base/PlatformSystem.cpp",
    "content": "//  The MIT License (MIT)\r\n//\r\n//  Copyright (c) 2017 Tag Games Limited\r\n//\r\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\r\n//  of this software and associated documentation files (the \"Software\"), to deal\r\n//  in the Software without restriction, including without limitation the rights\r\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\n//  copies of the Software, and to permit persons to whom the Software is\r\n//  furnished to do so, subject to the following conditions:\r\n//\r\n//  The above copyright notice and this permission notice shall be included in\r\n//  all copies or substantial portions of the Software.\r\n//\r\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r\n//  THE SOFTWARE.\r\n//\r\n\r\n#ifdef CS_TARGETPLATFORM_RPI\r\n\r\n#include <CSBackend/Platform/RPi/Core/Base/PlatformSystem.h>\r\n#include <ChilliSource/Core/Base/Application.h>\r\n#include <ChilliSource/Core/Threading/TaskScheduler.h>\r\n#include <CSBackend/Platform/RPi/Core/Base/DispmanWindow.h>\r\n#include <ChilliSource/UI/Base/CursorSystem.h>\r\n\r\nnamespace CSBackend\r\n{\r\n\tnamespace RPi\r\n\t{\r\n\t\tCS_DEFINE_NAMEDTYPE(PlatformSystem);\r\n\r\n\t\t//---------------------------------------------------------------------------------\r\n\t\tbool PlatformSystem::IsA(ChilliSource::InterfaceIDType interfaceId) const\r\n\t\t{\r\n\t\t\treturn (ChilliSource::PlatformSystem::InterfaceID == interfaceId || PlatformSystem::InterfaceID == interfaceId);\r\n\t\t}\r\n\r\n\t\t//---------------------------------------------------------------------------------\r\n\t\tvoid PlatformSystem::CreateDefaultSystems(ChilliSource::Application* application)\r\n\t\t{\r\n\t\t\tapplication->CreateSystem<ChilliSource::CursorSystem>();\r\n\t\t}\r\n\r\n\t\t//---------------------------------------------------------------------------------\r\n\t\tvoid PlatformSystem::SetPreferredFPS(u32 fps)\r\n\t\t{\r\n\t\t\tChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_system, [=](const ChilliSource::TaskContext& in_taskContext)\r\n\t\t\t{\r\n\t\t\t\tDispmanWindow::Get()->SetPreferredFPS(fps);\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\t//---------------------------------------------------------------------------------\r\n\t\tvoid PlatformSystem::Quit()\r\n\t\t{\r\n\t\t\tChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_system, [=](const ChilliSource::TaskContext& in_taskContext)\r\n\t\t\t{\r\n\t\t\t\tDispmanWindow::Get()->ScheduleQuit();\r\n\t\t\t});\r\n\t\t}\r\n\t}\r\n}\r\n\r\n#endif\r\n"
  },
  {
    "path": "Source/CSBackend/Platform/RPi/Core/Base/PlatformSystem.h",
    "content": "//\r\n//  The MIT License (MIT)\r\n//\r\n//  Copyright (c) 2017 Tag Games Limited\r\n//\r\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\r\n//  of this software and associated documentation files (the \"Software\"), to deal\r\n//  in the Software without restriction, including without limitation the rights\r\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\n//  copies of the Software, and to permit persons to whom the Software is\r\n//  furnished to do so, subject to the following conditions:\r\n//\r\n//  The above copyright notice and this permission notice shall be included in\r\n//  all copies or substantial portions of the Software.\r\n//\r\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r\n//  THE SOFTWARE.\r\n//\r\n\r\n#ifdef CS_TARGETPLATFORM_RPI\r\n\r\n#ifndef _CSBACKEND_PLATFORM_RPI_CORE_BASE_PLATFORMSYSTEM_H_\r\n#define _CSBACKEND_PLATFORM_RPI_CORE_BASE_PLATFORMSYSTEM_H_\r\n\r\n#include <ChilliSource/ChilliSource.h>\r\n#include <CSBackend/Platform/RPi/ForwardDeclarations.h>\r\n#include <ChilliSource/Core/Base/PlatformSystem.h>\r\n\r\nnamespace CSBackend\r\n{\r\n\tnamespace RPi\r\n\t{\r\n\t\t/// Raspberry Pi backend for the platform system.\r\n\t\t/// Mostly used for interfacing with the broadcom display system.\r\n\t\t///\r\n\t\tclass PlatformSystem final : public ChilliSource::PlatformSystem\r\n\t\t{\r\n\t\tpublic:\r\n\t\t\tCS_DECLARE_NAMEDTYPE(PlatformSystem);\r\n\r\n\t\t\t/// Queries whether or not this system implements the\r\n\t\t\t/// interface with the given Id.\r\n\t\t\t///\r\n\t\t\t/// @param interfaceId\r\n\t\t\t///\t\tThe id of the interface that we need to check if this system implements\r\n\t\t\t///\r\n\t\t\t/// @retrun TRUE if the system 'IsA' interface\r\n\t\t\t///\r\n\t\t\tbool IsA(ChilliSource::InterfaceIDType interfaceId) const override;\r\n\r\n\t\t\t/// Adds default systems for this platform to the default systems\r\n\t\t\t/// of the application\r\n\t\t\t///\r\n\t\t\t/// @param application\r\n\t\t\t///\t\tApplication to add systems to\r\n\t\t\t///\r\n\t\t\tvoid CreateDefaultSystems(ChilliSource::Application* application) override;\r\n\r\n            /// NOTE: The Raspberry Pi enforces VSync (like iOS) and therefore this just\r\n\t\t\t/// sets the vsync interval (e.g 60 = every vblank, 30 = every second vblank)\r\n\t\t\t///\r\n\t\t\t///\t@param fps\r\n\t\t\t///\t\tThe maximum frames per second to clamp to.\r\n\t\t\t///\t\tThis should be in multiples of 15 to match the behaviour of other platforms (e.g. 15, 30, 60)\r\n            ///\r\n\t\t\tvoid SetPreferredFPS(u32 fps) override;\r\n\r\n\t\t\t/// NOTE: Vsync cannot be disabled on RPi so this does nothing\r\n\t\t\t///\r\n\t\t\t/// @param enabled\r\n\t\t\t///\t\tTRUE to enable, FALSE to disable\r\n\t\t\t///\r\n\t\t\tvoid SetVSyncEnabled(bool enabled) override {}\r\n\r\n\t\t\t/// Stops the update loop causing the application\r\n\t\t\t/// to terminate.\r\n\t\t\t///\r\n\t\t\tvoid Quit() override;\r\n\r\n\t\tprivate:\r\n\t\t\tfriend ChilliSource::PlatformSystemUPtr ChilliSource::PlatformSystem::Create();\r\n\r\n\t\t\t///\r\n\t\t\tPlatformSystem() = default;\r\n\t\t};\r\n\t}\r\n}\r\n\r\n#endif\r\n\r\n#endif\r\n"
  },
  {
    "path": "Source/CSBackend/Platform/RPi/Core/Base/Screen.cpp",
    "content": "//\r\n//  The MIT License (MIT)\r\n//\r\n//  Copyright (c) 2017 Tag Games Limited\r\n//\r\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\r\n//  of this software and associated documentation files (the \"Software\"), to deal\r\n//  in the Software without restriction, including without limitation the rights\r\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\n//  copies of the Software, and to permit persons to whom the Software is\r\n//  furnished to do so, subject to the following conditions:\r\n//\r\n//  The above copyright notice and this permission notice shall be included in\r\n//  all copies or substantial portions of the Software.\r\n//\r\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r\n//  THE SOFTWARE.\r\n//\r\n\r\n#ifdef CS_TARGETPLATFORM_RPI\r\n\r\n#include <CSBackend/Platform/RPi/Core/Base/Screen.h>\r\n\r\n#include <ChilliSource/Core/Base/Application.h>\r\n#include <ChilliSource/Core/Delegate/MakeDelegate.h>\r\n#include <ChilliSource/Core/Threading/TaskScheduler.h>\r\n\r\nnamespace CSBackend\r\n{\r\n    namespace RPi\r\n    {\r\n        CS_DEFINE_NAMEDTYPE(Screen);\r\n\r\n        //---------------------------------------------------------------------------------\r\n        Screen::Screen(const ChilliSource::ScreenInfo& screenInfo) noexcept\r\n            : m_screenInfo(screenInfo)\r\n        {\r\n            m_resolution.x = screenInfo.GetInitialResolution().x;\r\n            m_resolution.y = screenInfo.GetInitialResolution().y;\r\n\r\n            DispmanWindow::Get()->SetWindowDelegates(ChilliSource::MakeDelegate(this, &Screen::OnResolutionChanged));\r\n        }\r\n\r\n        //---------------------------------------------------------------------------------\r\n        bool Screen::IsA(ChilliSource::InterfaceIDType in_interfaceId) const noexcept\r\n        {\r\n            return (ChilliSource::Screen::InterfaceID == in_interfaceId || Screen::InterfaceID == in_interfaceId);\r\n        }\r\n\r\n        //---------------------------------------------------------------------------------\r\n        const ChilliSource::Vector2& Screen::GetResolution() const noexcept\r\n        {\r\n            return m_resolution;\r\n        }\r\n\r\n        //---------------------------------------------------------------------------------\r\n        f32 Screen::GetDensityScale() const noexcept\r\n        {\r\n            return m_screenInfo.GetDensityScale();\r\n        }\r\n\r\n        //---------------------------------------------------------------------------------\r\n        f32 Screen::GetInverseDensityScale() const noexcept\r\n        {\r\n            return m_screenInfo.GetInverseDensityScale();\r\n        }\r\n\r\n        //---------------------------------------------------------------------------------\r\n        ChilliSource::IConnectableEvent<Screen::ResolutionChangedDelegate>& Screen::GetResolutionChangedEvent() noexcept\r\n        {\r\n            return m_resolutionChangedEvent;\r\n        }\r\n\r\n        //---------------------------------------------------------------------------------\r\n\t\tChilliSource::IConnectableEvent<Screen::DisplayModeChangedDelegate>& Screen::GetDisplayModeChangedEvent() noexcept\r\n\t\t{\r\n\t\t\treturn m_displayModeChangedEvent;\r\n\t\t}\r\n\r\n        //---------------------------------------------------------------------------------\r\n\t\tstd::vector<ChilliSource::Integer2> Screen::GetSupportedFullscreenResolutions() const noexcept\r\n\t\t{\r\n            return m_screenInfo.GetSupportedFullscreenResolutions();\r\n\t\t}\r\n\r\n        //---------------------------------------------------------------------------------\r\n        void Screen::SetResolution(const ChilliSource::Integer2& size) noexcept\r\n        {\r\n            ChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_system, [=](const ChilliSource::TaskContext& taskContext)\r\n            {\r\n                DispmanWindow::Get()->SetSize(size);\r\n                OnResolutionChanged(size);\r\n            });\r\n        }\r\n\r\n        //---------------------------------------------------------------------------------\r\n        void Screen::SetDisplayMode(DisplayMode mode) noexcept\r\n        {\r\n            ChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_system, [=](const ChilliSource::TaskContext& taskContext)\r\n            {\r\n                DispmanWindow::Get()->SetDisplayMode(mode);\r\n                OnDisplayModeChanged(mode);\r\n            });\r\n        }\r\n\r\n        //---------------------------------------------------------------------------------\r\n        void Screen::OnResolutionChanged(const ChilliSource::Integer2& resolution) noexcept\r\n        {\r\n            ChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_mainThread, [=](const ChilliSource::TaskContext& taskContext)\r\n            {\r\n                m_resolution.x = (f32)resolution.x;\r\n                m_resolution.y = (f32)resolution.y;\r\n\r\n                m_resolutionChangedEvent.NotifyConnections(m_resolution);\r\n            });\r\n        }\r\n\r\n        //---------------------------------------------------------------------------------\r\n        void Screen::OnDisplayModeChanged(DisplayMode mode) noexcept\r\n        {\r\n            ChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_mainThread, [=](const ChilliSource::TaskContext& taskContext)\r\n            {\r\n                m_displayModeChangedEvent.NotifyConnections(mode);\r\n            });\r\n        }\r\n\r\n        //---------------------------------------------------------------------------------\r\n        void Screen::OnDestroy() noexcept\r\n        {\r\n            DispmanWindow::Get()->RemoveWindowDelegates();\r\n        }\r\n    }\r\n}\r\n\r\n#endif\r\n"
  },
  {
    "path": "Source/CSBackend/Platform/RPi/Core/Base/Screen.h",
    "content": "//\r\n//  The MIT License (MIT)\r\n//\r\n//  Copyright (c) 2014 Tag Games Limited\r\n//\r\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\r\n//  of this software and associated documentation files (the \"Software\"), to deal\r\n//  in the Software without restriction, including without limitation the rights\r\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\n//  copies of the Software, and to permit persons to whom the Software is\r\n//  furnished to do so, subject to the following conditions:\r\n//\r\n//  The above copyright notice and this permission notice shall be included in\r\n//  all copies or substantial portions of the Software.\r\n//\r\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r\n//  THE SOFTWARE.\r\n//\r\n\r\n#ifdef CS_TARGETPLATFORM_RPI\r\n\r\n#ifndef _CSBACKEND_PLATFORM_RPI_CORE_BASE_SCREEN_H_\r\n#define _CSBACKEND_PLATFORM_RPI_CORE_BASE_SCREEN_H_\r\n\r\n#include <ChilliSource/ChilliSource.h>\r\n#include <ChilliSource/Core/Base/Screen.h>\r\n#include <ChilliSource/Core/Base/ScreenInfo.h>\r\n#include <ChilliSource/Core/Event/Event.h>\r\n#include <CSBackend/Platform/RPi/ForwardDeclarations.h>\r\n#include <CSBackend/Platform/RPi/Core/Base/DispmanWindow.h>\r\n\r\nnamespace CSBackend\r\n{\r\n    namespace RPi\r\n    {\r\n        /// The Raspberry Pi backend for the screen. This provides information on\r\n        /// the include device's screen such as resolution and density scale.\r\n        ///\r\n\t\tclass Screen final : public ChilliSource::Screen\r\n\t\t{\r\n\t\tpublic:\r\n            CS_DECLARE_NAMEDTYPE(Screen);\r\n\r\n            /// Queries whether or not this system implements the\r\n\t\t\t/// interface with the given Id.\r\n\t\t\t///\r\n\t\t\t/// @param interfaceId\r\n\t\t\t///\t\tThe id of the interface that we need to check if this system implements\r\n\t\t\t///\r\n\t\t\t/// @retrun TRUE if the system 'IsA' interface\r\n\t\t\t///\r\n\t\t\tbool IsA(ChilliSource::InterfaceIDType interfaceId) const noexcept override;\r\n\r\n\t\t\t/// @return Vector containing the width and height of screen\r\n            /// space available to the application. For the RPi we always run\r\n            /// in fullscreen mode so this will be the resolution of the display\r\n            ///\r\n\t\t\tconst ChilliSource::Vector2& GetResolution() const noexcept override;\r\n\r\n            /// @return The density scale factor of the screen\r\n            ///\r\n            f32 GetDensityScale() const noexcept override;\r\n\r\n            /// @return The reciprocal density scale factor of the screen\r\n            ///\r\n            f32 GetInverseDensityScale() const noexcept override;\r\n\r\n\t\t\t/// @return An event that is called when the screen resolution\r\n            /// changes (as we don't run windowed this will only be if the display changes).\r\n            ///\r\n            ChilliSource::IConnectableEvent<ResolutionChangedDelegate>& GetResolutionChangedEvent() noexcept override;\r\n\r\n            /// @return An event that is called when the screen display mode changes (we only run fullscreen on Pi so this won't change)\r\n            ///\r\n\t\t\tChilliSource::IConnectableEvent<DisplayModeChangedDelegate>& GetDisplayModeChangedEvent() noexcept override;\r\n\r\n            /// This has no effect on the Raspberry Pi as we always run fullscreen\r\n            ///\r\n            /// @param size\r\n            ///     Size to set the window to\r\n            ///\r\n\t\t\tvoid SetResolution(const ChilliSource::Integer2& size) noexcept override;\r\n\r\n            /// This has no effect on the Raspberry Pi as we always run fullscreen\r\n            ///\r\n            /// @param mode\r\n            ///     Display mode to use\r\n            ///\r\n\t\t\tvoid SetDisplayMode(DisplayMode mode) noexcept override;\r\n\r\n\t\t\t/// @return A list of resolutions supported by the display\r\n\t\t\t///\r\n\t\t\tstd::vector<ChilliSource::Integer2> GetSupportedFullscreenResolutions() const noexcept override;\r\n\r\n        private:\r\n            friend ChilliSource::ScreenUPtr ChilliSource::Screen::Create(const ChilliSource::ScreenInfo& screenInfo);\r\n\r\n            /// @param screenInfo\r\n            ///     Holds the information about the display\r\n            ///\r\n\t\t\tScreen(const ChilliSource::ScreenInfo& screenInfo) noexcept;\r\n\r\n            /// @param resolution\r\n            ///     New window size\r\n            ///\r\n            void OnResolutionChanged(const ChilliSource::Integer2& resolution) noexcept;\r\n\r\n            /// @param mode\r\n            ///     New window mode\r\n            ///\r\n            void OnDisplayModeChanged(DisplayMode mode) noexcept;\r\n\r\n            /// Stops listening for window events\r\n            ///\r\n            void OnDestroy() noexcept override;\r\n\r\n            ChilliSource::Vector2 m_resolution;\r\n            ChilliSource::ScreenInfo m_screenInfo;\r\n\r\n            ChilliSource::Event<ResolutionChangedDelegate> m_resolutionChangedEvent;\r\n\t\t\tChilliSource::Event<DisplayModeChangedDelegate> m_displayModeChangedEvent;\r\n\t\t\tChilliSource::EventConnectionUPtr m_windowResizeConnection;\r\n\t\t\tChilliSource::EventConnectionUPtr m_displayModeChangeConnection;\r\n        };\r\n    }\r\n}\r\n\r\n#endif\r\n\r\n#endif\r\n"
  },
  {
    "path": "Source/CSBackend/Platform/RPi/Core/Base/SystemInfoFactory.cpp",
    "content": "//  The MIT License (MIT)\n//\n//  Copyright (c) 2017 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_RPI\n\n#include <ChilliSource/Core/Base/DeviceInfo.h>\n#include <ChilliSource/Core/Base/ScreenInfo.h>\n#include <ChilliSource/Core/Base/SystemInfo.h>\n#include <ChilliSource/Core/String/StringUtils.h>\n\n#include <CSBackend/Platform/RPi/Core/Base/Screen.h>\n#include <CSBackend/Platform/RPi/Core/Base/SystemInfoFactory.h>\n#include <CSBackend/Platform/RPi/Core/Base/DispmanWindow.h>\n#include <CSBackend/Rendering/OpenGL/Base/RenderInfoFactory.h>\n\n#include <sys/sysinfo.h>\n#include <sys/utsname.h>\n\n#include <algorithm>\n#include <vector>\n\nnamespace CSBackend\n{\n    namespace RPi\n    {\n        namespace\n        {\n            const std::string k_deviceModel = \"Raspberry Pi\";\n            const std::string k_deviceManufacturer = \"Raspberry Pi Foundation\";\n            const std::string k_defaultLocale = \"en_US\";\n            const std::string k_deviceUdid = \"FAKE ID\";\n\n            /// Returns the language portion of a locale code.\n            ///\n            /// @param locale\n            ///     The local code to parse\n            ///\n            /// @return The language code.\n            ///\n            std::string ParseLanguageFromLocale(const std::string& locale) noexcept\n            {\n                std::vector<std::string> localeBrokenUp = ChilliSource::StringUtils::Split(locale, \"_\", 0);\n\n                if (localeBrokenUp.size() > 0)\n                {\n                    return localeBrokenUp[0];\n                }\n                else\n                {\n                    return k_defaultLocale;\n                }\n            }\n        }\n\n        //--------------------------------------------------------------------------------\n        ChilliSource::SystemInfoCUPtr SystemInfoFactory::CreateSystemInfo() noexcept\n        {\n            utsname info;\n            uname(&info);\n\n            std::string osVersion(info.release);\n            std::string machineType(info.machine);\n            std::locale globalLocale(\"\"); //Creating with the empty string will set it to the global locale\n\n            ChilliSource::DeviceInfo deviceInfo(k_deviceModel, machineType, k_deviceManufacturer, k_deviceUdid, globalLocale.name(), ParseLanguageFromLocale(globalLocale.name()), osVersion, get_nprocs());\n\n            auto screenSize = DispmanWindow::Get()->GetWindowSize();\n            ChilliSource::ScreenInfo screenInfo(ChilliSource::Vector2((f32)screenSize.x, (f32)screenSize.y), 1.0f, 1.0f, DispmanWindow::Get()->GetSupportedFullscreenResolutions());\n\n\t\t\tChilliSource::RenderInfo renderInfo = OpenGL::RenderInfoFactory::CreateRenderInfo();\n\n            ChilliSource::SystemInfoUPtr systemInfo(new ChilliSource::SystemInfo(deviceInfo, screenInfo, renderInfo, \"\"));\n\n            return std::move(systemInfo);\n        }\n\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/RPi/Core/Base/SystemInfoFactory.h",
    "content": "//  The MIT License (MIT)\n//\n//  Copyright (c) 2017 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_RPI\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Base/SystemInfo.h>\n#include <CSBackend/Platform/RPi/ForwardDeclarations.h>\n\nnamespace CSBackend\n{\n    namespace RPi\n    {\n        /// A factory for creating new instances of SystemInfo. This will query the Broadcom\n        /// API to gather information about the device and display.\n        ///\n        namespace SystemInfoFactory\n        {\n            /// This function creates the new SystemInfo instance.\n            /// @return The new instance.\n            ///\n            ChilliSource::SystemInfoCUPtr CreateSystemInfo() noexcept;\n        }\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/RPi/Core/File/FileSystem.cpp",
    "content": "//  The MIT License (MIT)\r\n//\r\n//  Copyright (c) 2017 Tag Games Limited\r\n//\r\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\r\n//  of this software and associated documentation files (the \"Software\"), to deal\r\n//  in the Software without restriction, including without limitation the rights\r\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\n//  copies of the Software, and to permit persons to whom the Software is\r\n//  furnished to do so, subject to the following conditions:\r\n//\r\n//  The above copyright notice and this permission notice shall be included in\r\n//  all copies or substantial portions of the Software.\r\n//\r\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r\n//  THE SOFTWARE.\r\n//\r\n\r\n#ifdef CS_TARGETPLATFORM_RPI\r\n\r\n#include <CSBackend/Platform/RPi/Core/File/FileSystem.h>\r\n\r\n#include <ChilliSource/Core/Base/Utils.h>\r\n#include <ChilliSource/Core/String/StringUtils.h>\r\n\r\n#include <fcntl.h>\r\n#include <unistd.h>\r\n#include <iostream>\r\n#include <cstdio>\r\n#include <dirent.h>\r\n#include <errno.h>\r\n#include <sys/types.h>\r\n#include <sys/stat.h>\r\n#include <sys/sendfile.h>\r\n#include <unistd.h>\r\n\r\nnamespace CSBackend\r\n{\r\n\tnamespace RPi\r\n\t{\r\n\t\tnamespace\r\n\t\t{\r\n\t\t\tconst char k_assetsPath[] = \"assets/\";\r\n\t\t\tconst char k_saveDataPath[] = \"SaveData/\";\r\n\t\t\tconst char k_dlcPath[] = \"DLC/\";\r\n\t\t\tconst char k_cachePath[] = \"Cache/\";\r\n\t\t\tconst char k_packagePath[] = \"AppResources/\";\r\n\t\t\tconst char k_chilliSourcePath[] = \"CSResources/\";\r\n\r\n\t\t\t/// Creates a new directory at the given path\r\n\t\t\t///\r\n            /// @param directoryPath\r\n\t\t\t///\t\tThe path to the directory to create\r\n            ///\r\n            /// @return Whether or not the creation succeeded.\r\n\t\t\t///\r\n\t\t\tbool CreateDirectory(const std::string& directoryPath)\r\n\t\t\t{\r\n\t\t\t\ts32 error = mkdir(directoryPath.c_str(), 0777);\r\n\t\t\t\tif (error == -1)\r\n\t\t\t\t{\r\n\t\t\t\t\ts32 errorType = errno;\r\n\t\t\t\t\tif (errorType != EEXIST)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\treturn false;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n\t\t\t\treturn true;\r\n\t\t\t}\r\n\r\n\t\t\t/// Use the linux file system to copy the file from src to dest.\r\n\t\t\t///\r\n\t\t\t/// @param srcPath\r\n\t\t\t///\t\tAbsolute path to copy from\r\n\t\t\t/// @param dstPath\r\n\t\t\t///\t\tAbsolute path to copy to\r\n\t\t\t///\r\n\t\t\t/// @return TRUE if success\r\n\t\t\t///\r\n\t\t\tbool CopyFile(const std::string& srcPath, const std::string& dstPath)\r\n\t\t\t{\r\n\t\t\t\tint read_fd;\r\n\t\t\t\tint write_fd;\r\n\t\t\t\tstruct stat stat_buf;\r\n\t\t\t\toff_t offset = 0;\r\n\r\n\t\t\t\t//Open the input file and grab its size\r\n\t\t\t\tread_fd = open (srcPath.c_str(), O_RDONLY);\r\n\t\t\t\tfstat (read_fd, &stat_buf);\r\n\r\n\t\t\t\t//Open the output file with the same permissions\r\n\t\t\t\twrite_fd = open (dstPath.c_str(), O_WRONLY | O_CREAT, stat_buf.st_mode);\r\n\r\n\t\t\t\t//Send the bytes to the new file\r\n\t\t\t\tssize_t sentBytes = sendfile (write_fd, read_fd, &offset, stat_buf.st_size);\r\n\r\n\t\t\t\tclose (read_fd);\r\n\t\t\t\tclose (write_fd);\r\n\r\n\t\t\t\treturn sentBytes == stat_buf.st_size;\r\n\t\t\t}\r\n\r\n\t\t\t/// @param path\r\n\t\t\t///\t\tThe file path to check\r\n\t\t\t///\r\n\t\t\t/// @return Whether or not the file at the given path exists.\r\n\t\t\t///\r\n    \t\tbool DoesFileExist(const std::string& path)\r\n    \t\t{\r\n    \t\t\tstruct stat itemStat;\r\n    \t\t\tif (stat(path.c_str(), &itemStat) == 0)\r\n    \t\t\t{\r\n    \t\t\t\tif (S_ISDIR(itemStat.st_mode) == false)\r\n    \t\t\t\t{\r\n    \t\t\t\t\treturn true;\r\n    \t\t\t\t}\r\n    \t\t\t}\r\n\r\n    \t\t\treturn false;\r\n    \t\t}\r\n\r\n\t\t\t/// @param path\r\n\t\t\t///\t\tThe directory path to check\r\n\t\t\t///\r\n\t\t\t/// @return Whether or not the directory at the given path exists.\r\n\t\t\t///\r\n    \t\tbool DoesDirectoryExist(const std::string& path)\r\n    \t\t{\r\n    \t\t\tstruct stat itemStats;\r\n    \t\t\tif (stat(path.c_str(), &itemStats) == 0)\r\n    \t\t\t{\r\n    \t\t\t\tif (S_ISDIR(itemStats.st_mode) == true)\r\n    \t\t\t\t{\r\n    \t\t\t\t\treturn true;\r\n    \t\t\t\t}\r\n    \t\t\t}\r\n\r\n    \t\t\treturn false;\r\n    \t\t}\r\n\r\n\t\t\t/// Deletes a directory and all its contents.\r\n\t\t\t///\r\n\t\t\t/// @param dirPath\r\n\t\t\t///\t\tPath of directory to delete\r\n\t\t\t///\r\n\t\t\t/// @return Whether or not the directory was successfully deleted.\r\n\t\t\t///\r\n\t\t\tbool DeleteDirectory(const std::string& dirPath)\r\n\t\t\t{\r\n\t\t\t\tstd::string directoryPath = ChilliSource::StringUtils::StandardiseDirectoryPath(dirPath);\r\n\t\t\t\tif (DoesDirectoryExist(directoryPath) == false)\r\n\t\t\t\t{\r\n\t\t\t\t\treturn false;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tDIR* directory = opendir(directoryPath.c_str());\r\n\t\t\t\tif(directory == nullptr)\r\n\t\t\t\t{\r\n\t\t\t\t\treturn false;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tstruct dirent* directoryItem;\r\n\t\t\t\twhile ((directoryItem = readdir(directory)) != nullptr)\r\n\t\t\t\t{\r\n\t\t\t\t\tstd::string itemName = directoryItem->d_name;\r\n\t\t\t\t\tif (itemName == \".\" || itemName == \"..\")\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tcontinue;\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tstruct stat itemStats;\r\n\t\t\t\t\tstd::string itemPath = directoryPath + itemName + \"\\0\";\r\n\t\t\t\t\tif (stat(itemPath.c_str(), &itemStats) != 0)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t    return false;\r\n\t\t\t\t\t}\r\n\r\n                    if (S_ISDIR(itemStats.st_mode) == true)\r\n                    {\r\n                        if (DeleteDirectory(itemPath) == false)\r\n                        {\r\n                            return false;\r\n                        }\r\n                    }\r\n                    else\r\n                    {\r\n                        unlink(itemPath.c_str());\r\n                    }\r\n\t\t\t\t}\r\n\t\t\t\tclosedir(directory);\r\n\r\n\t\t\t\t//remove the directory\r\n\t\t\t\tif (rmdir(directoryPath.c_str()) != 0)\r\n\t\t\t\t{\r\n\t\t\t\t\treturn false;\r\n\t\t\t\t}\r\n\r\n\t\t\t\treturn true;\r\n\t\t\t}\r\n\r\n            /// Builds a list of either file or directories paths in the directory at the\r\n            /// given path, optionally recursing into sub-directories. Whether or not this\r\n            /// searched for files or directories is denoted by the searchForDirectories\r\n            /// flag.\r\n    \t\t///\r\n            /// @param out_directoryPaths\r\n\t\t\t///\t\t[Output] The output directory path list. This is not cleared prior to further informating being added, so care needs to be taken to ensure the list is empty prior to calling.\r\n            /// @param dirPath\r\n\t\t\t///\t\tThe path to search for directories in.\r\n            /// @param searchForDirectories\r\n\t\t\t///\t\tWhether we are looking for directories or files.\r\n            /// @param recursive\r\n\t\t\t///\t\tWhether or not to recurse into sub-directories.\r\n            /// @param relativeParentDirectory\r\n\t\t\t///\t\t[Optional] The path to be prefixed to each path found in this directory. This is mostly used for recursion into sub-directories and shouldn't otherwise be set.\r\n            ///\r\n            /// @return Whether or not this was successful.\r\n            ///\r\n\t\t\tbool GetPaths(std::vector<std::string>& out_directoryPaths, const std::string& dirPath, bool searchForDirectories, bool recursive, const std::string& relativeParentDir = \"\")\r\n\t\t\t{\r\n\t\t\t    std::string directoryPath = ChilliSource::StringUtils::StandardiseDirectoryPath(dirPath);\r\n\t\t\t    std::string relativeParentDirectory = ChilliSource::StringUtils::StandardiseDirectoryPath(relativeParentDir);\r\n\r\n                DIR* directory = opendir(directoryPath.c_str());\r\n                if(directory == nullptr)\r\n                {\r\n                    return false;\r\n                }\r\n\r\n                bool success = true;\r\n                struct dirent* item;\r\n                while ((item = readdir(directory)) != nullptr && success == true)\r\n                {\r\n                    std::string itemName(item->d_name);\r\n                    std::string fullItemPath = directoryPath + itemName;\r\n\r\n                    if (itemName == \".\" || itemName == \"..\")\r\n                    {\r\n                        continue;\r\n                    }\r\n\r\n                    struct stat dirStats;\r\n                    if (stat(fullItemPath.c_str(), &dirStats) != 0)\r\n                    {\r\n                        success = false;\r\n                        break;\r\n                    }\r\n\r\n                    if (S_ISDIR(dirStats.st_mode) == true)\r\n                    {\r\n                        std::string relativeItemPath = relativeParentDirectory + ChilliSource::StringUtils::StandardiseDirectoryPath(itemName);\r\n                        if (searchForDirectories == true)\r\n                        {\r\n                            out_directoryPaths.push_back(relativeItemPath);\r\n                        }\r\n\r\n                        if (recursive == true)\r\n                        {\r\n                            fullItemPath = ChilliSource::StringUtils::StandardiseDirectoryPath(fullItemPath);\r\n                            if (GetPaths(out_directoryPaths, fullItemPath, searchForDirectories, true, relativeItemPath) == false)\r\n                            {\r\n                                success = false;\r\n                                break;\r\n                            }\r\n                        }\r\n                    }\r\n                    else if (searchForDirectories == false)\r\n                    {\r\n                        std::string relativeItemPath = relativeParentDirectory + ChilliSource::StringUtils::StandardiseFilePath(itemName);\r\n                        out_directoryPaths.push_back(relativeItemPath);\r\n                    }\r\n                }\r\n\r\n                closedir(directory);\r\n\r\n                return success;\r\n\t\t\t}\r\n\r\n\t\t\t/// @return Working directory of the application\r\n\t\t\t///\r\n\t\t\tstd::string GetWorkingDirectory()\r\n\t\t\t{\r\n\t\t\t\tchar arg1[20];\r\n\t\t\t\tchar exepath[PATH_MAX + 1] = {0};\r\n\r\n\t\t\t\tsprintf(arg1, \"/proc/%d/exe\", getpid());\r\n\t\t\t\treadlink(arg1, exepath, 1024 );\r\n\t\t\t\treturn std::string(exepath);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tCS_DEFINE_NAMEDTYPE(FileSystem);\r\n\r\n\t\t//---------------------------------------------------------------------------------\r\n\t\tFileSystem::FileSystem()\r\n\t\t{\r\n\t\t\tstd::string path = GetWorkingDirectory();\r\n\t\t\tstd::string::size_type pos = path.find_last_of(\"/\");\r\n\t\t\tstd::string workingDir = ChilliSource::StringUtils::StandardiseDirectoryPath(path.substr(0, pos));\r\n\r\n\t\t\tm_packagePath = workingDir + \"assets/\";\r\n\t\t\tm_documentsPath = workingDir + \"Documents/\";\r\n\r\n\t\t\tCSBackend::RPi::CreateDirectory(m_documentsPath);\r\n\t\t\tCS_ASSERT(CSBackend::RPi::DoesDirectoryExist(m_documentsPath), \"Could not create Documents directory.\");\r\n\r\n\t\t\tCSBackend::RPi::CreateDirectory(GetAbsolutePathToStorageLocation(ChilliSource::StorageLocation::k_saveData));\r\n\t\t\tCS_ASSERT(CSBackend::RPi::DoesDirectoryExist(GetAbsolutePathToStorageLocation(ChilliSource::StorageLocation::k_saveData)), \"Could not create SaveData storage location.\");\r\n\r\n\t\t\tCSBackend::RPi::CreateDirectory(GetAbsolutePathToStorageLocation(ChilliSource::StorageLocation::k_cache));\r\n\t\t\tCS_ASSERT(CSBackend::RPi::DoesDirectoryExist(GetAbsolutePathToStorageLocation(ChilliSource::StorageLocation::k_cache)), \"Could not create Cache storage location.\");\r\n\r\n\t\t\tCSBackend::RPi::CreateDirectory(GetAbsolutePathToStorageLocation(ChilliSource::StorageLocation::k_DLC));\r\n\t\t\tCS_ASSERT(CSBackend::RPi::DoesDirectoryExist(GetAbsolutePathToStorageLocation(ChilliSource::StorageLocation::k_DLC)), \"Could not create DLC storage location.\");\r\n\t\t}\r\n\r\n\t\t//---------------------------------------------------------------------------------\r\n\t\tbool FileSystem::IsA(ChilliSource::InterfaceIDType interfaceId) const\r\n\t\t{\r\n\t\t\treturn (ChilliSource::FileSystem::InterfaceID == interfaceId || FileSystem::InterfaceID == interfaceId);\r\n\t\t}\r\n\r\n\t\t//---------------------------------------------------------------------------------\r\n        ChilliSource::ITextInputStreamUPtr FileSystem::CreateTextInputStream(ChilliSource::StorageLocation storageLocation, const std::string& filePath) const\r\n        {\r\n        \tstd::string absFilePath = \"\";\r\n\t\t\tif (storageLocation == ChilliSource::StorageLocation::k_DLC && DoesFileExistInCachedDLC(filePath) == false)\r\n\t\t\t{\r\n\t\t\t\tabsFilePath = GetAbsolutePathToStorageLocation(ChilliSource::StorageLocation::k_package) + GetPackageDLCPath() + filePath;\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tabsFilePath = GetAbsolutePathToStorageLocation(storageLocation) + filePath;\r\n\t\t\t}\r\n\r\n\t\t\tChilliSource::ITextInputStreamUPtr output(new ChilliSource::TextInputStream(absFilePath));\r\n            if (output->IsValid() == true)\r\n            {\r\n                return output;\r\n            }\r\n            else\r\n            {\r\n                 return nullptr;\r\n            }\r\n        }\r\n\r\n\t\t//---------------------------------------------------------------------------------\r\n\t\tChilliSource::IBinaryInputStreamUPtr FileSystem::CreateBinaryInputStream(ChilliSource::StorageLocation storageLocation, const std::string& filePath) const\r\n\t\t{\r\n\t\t\tstd::string absFilePath = \"\";\r\n\t\t\tif (storageLocation == ChilliSource::StorageLocation::k_DLC && DoesFileExistInCachedDLC(filePath) == false)\r\n\t\t\t{\r\n\t\t\t\tabsFilePath = GetAbsolutePathToStorageLocation(ChilliSource::StorageLocation::k_package) + GetPackageDLCPath() + filePath;\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tabsFilePath = GetAbsolutePathToStorageLocation(storageLocation) + filePath;\r\n\t\t\t}\r\n\r\n\t\t\tChilliSource::IBinaryInputStreamUPtr output(new ChilliSource::BinaryInputStream(absFilePath));\r\n\t\t\tif (output->IsValid() == true)\r\n\t\t\t{\r\n\t\t\t\treturn output;\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t \treturn nullptr;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t//---------------------------------------------------------------------------------\r\n\t\tChilliSource::TextOutputStreamUPtr FileSystem::CreateTextOutputStream(ChilliSource::StorageLocation storageLocation, const std::string& filePath, ChilliSource::FileWriteMode fileMode) const\r\n\t\t{\r\n\t\t\tCS_ASSERT(IsStorageLocationWritable(storageLocation), \"File System: Trying to write to read only storage location.\");\r\n\r\n\t\t\tif (IsStorageLocationWritable(storageLocation))\r\n\t\t\t{\r\n\t\t\t\tstd::string absFilePath = GetAbsolutePathToStorageLocation(storageLocation) + filePath;\r\n\r\n\t\t\t\tChilliSource::TextOutputStreamUPtr output(new ChilliSource::TextOutputStream(absFilePath, fileMode));\r\n\t\t\t\tif (output->IsValid() == true)\r\n\t\t\t\t{\r\n\t\t\t\t\treturn output;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\treturn nullptr;\r\n\t\t}\r\n\r\n\t\t//---------------------------------------------------------------------------------\r\n\t\tChilliSource::BinaryOutputStreamUPtr FileSystem::CreateBinaryOutputStream(ChilliSource::StorageLocation storageLocation, const std::string& filePath, ChilliSource::FileWriteMode fileMode) const\r\n\t\t{\r\n\t\t\tCS_ASSERT(IsStorageLocationWritable(storageLocation), \"File System: Trying to write to read only storage location.\");\r\n\r\n\t\t\tif (IsStorageLocationWritable(storageLocation))\r\n\t\t\t{\r\n\t\t\t\tstd::string absFilePath = GetAbsolutePathToStorageLocation(storageLocation) + filePath;\r\n\r\n\t\t\t\tChilliSource::BinaryOutputStreamUPtr output(new ChilliSource::BinaryOutputStream(absFilePath, fileMode));\r\n\t\t\t\tif (output->IsValid() == true)\r\n\t\t\t\t{\r\n\t\t\t\t\treturn output;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\treturn nullptr;\r\n\t\t}\r\n\r\n\t\t//---------------------------------------------------------------------------------\r\n\t\tbool FileSystem::CreateDirectoryPath(ChilliSource::StorageLocation storageLocation, const std::string& directoryPath) const\r\n\t\t{\r\n\t\t\tCS_ASSERT(IsStorageLocationWritable(storageLocation), \"File System: Trying to write to read only storage location.\");\r\n\r\n\t\t\t//get each level of the new directory separately and then iterate though each creating it if it does not already exist.\r\n\t\t\tauto currentDirectoryPath = GetAbsolutePathToStorageLocation(storageLocation);\r\n\t\t\tauto relativePathSections = ChilliSource::StringUtils::Split(ChilliSource::StringUtils::StandardiseDirectoryPath(directoryPath), \"/\");\r\n\r\n\t\t\tfor (const auto& relativePathSection : relativePathSections)\r\n\t\t\t{\r\n\t\t\t\tcurrentDirectoryPath += ChilliSource::StringUtils::StandardiseDirectoryPath(relativePathSection);\r\n\t\t\t\tif (!CSBackend::RPi::DoesDirectoryExist(currentDirectoryPath))\r\n\t\t\t\t{\r\n\t\t\t\t\tif (!CSBackend::RPi::CreateDirectory(currentDirectoryPath))\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tCS_LOG_ERROR(\"File System: Failed to create directory '\" + directoryPath + \"'\");\r\n\t\t\t\t\t\treturn false;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\treturn true;\r\n\t\t}\r\n\r\n\t\t//---------------------------------------------------------------------------------\r\n\t\tbool FileSystem::CopyFile(ChilliSource::StorageLocation sourceLocation, const std::string& srcFilePath, ChilliSource::StorageLocation destLocation, const std::string& destFilePath) const\r\n\t\t{\r\n\t\t\tCS_ASSERT(IsStorageLocationWritable(destLocation), \"File System: Trying to write to read only storage location.\");\r\n\r\n\t\t\tstd::string sourceFilePath;\r\n\t\t\tif (sourceLocation == ChilliSource::StorageLocation::k_DLC && DoesFileExistInCachedDLC(srcFilePath) == false)\r\n\t\t\t{\r\n\t\t\t\tsourceFilePath = GetAbsolutePathToStorageLocation(ChilliSource::StorageLocation::k_package) + GetPackageDLCPath() + ChilliSource::StringUtils::StandardiseFilePath(srcFilePath);\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tsourceFilePath = GetAbsolutePathToStorageLocation(sourceLocation) + ChilliSource::StringUtils::StandardiseFilePath(srcFilePath);\r\n\t\t\t}\r\n\r\n\t\t\tif (CSBackend::RPi::DoesFileExist(sourceFilePath) == false)\r\n\t\t\t{\r\n\t\t\t\tCS_LOG_ERROR(\"File System: Trying to copy file '\" + srcFilePath + \"' but it does not exist.\");\r\n\t\t\t\treturn false;\r\n\t\t\t}\r\n\r\n            //get the path to the file\r\n\t\t\tstd::string destinationFileName, destinationDirectoryPath;\r\n\t\t\tChilliSource::StringUtils::SplitFilename(destFilePath, destinationFileName, destinationDirectoryPath);\r\n\r\n            //create the output directory\r\n\t\t\tCreateDirectoryPath(destLocation, destinationDirectoryPath);\r\n\r\n            //try and copy the files\r\n\t\t\tstd::string destPath = GetAbsolutePathToStorageLocation(destLocation) + destFilePath;\r\n\t\t\tif (CSBackend::RPi::CopyFile(sourceFilePath, destPath) == false)\r\n\t\t\t{\r\n\t\t\t\tCS_LOG_ERROR(\"File System: Failed to copy file '\" + srcFilePath + \"'\");\r\n\t\t\t\treturn false;\r\n\t\t\t}\r\n\r\n\t\t\treturn true;\r\n\t\t}\r\n\r\n\t\t//---------------------------------------------------------------------------------\r\n\t\tbool FileSystem::CopyDirectory(ChilliSource::StorageLocation sourceLocation, const std::string& sourceDirPath, ChilliSource::StorageLocation destLocation, const std::string& destDirPath) const\r\n\t\t{\r\n\t\t\tCS_ASSERT(IsStorageLocationWritable(destLocation), \"File System: Trying to write to read only storage location.\");\r\n\r\n\t\t\tif (DoesDirectoryExist(sourceLocation, sourceDirPath) == false)\r\n\t\t\t{\r\n\t\t\t\tCS_LOG_ERROR(\"File System: Trying to copy directory '\" + sourceDirPath + \"' but it doesn't exist.\");\r\n\t\t\t\treturn false;\r\n\t\t\t}\r\n\r\n\t\t\tstd::vector<std::string> filePaths = GetFilePaths(sourceLocation, sourceDirPath, true);\r\n\r\n\t\t\t//if the source directory is empty, just create the equivelent directory in the destination\r\n\t\t\tif (filePaths.size() == 0)\r\n\t\t\t{\r\n\t\t\t\tCreateDirectoryPath(destLocation, destDirPath);\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tstd::string sourceDirectoryPath = ChilliSource::StringUtils::StandardiseDirectoryPath(sourceDirPath);\r\n\t\t\t\tstd::string destinationDirectoryPath = ChilliSource::StringUtils::StandardiseDirectoryPath(destDirPath);\r\n\t\t\t\tfor (const std::string& filePath : filePaths)\r\n\t\t\t\t{\r\n\t\t\t\t\tif (CopyFile(sourceLocation, sourceDirectoryPath + filePath, destLocation, destinationDirectoryPath + filePath) == false)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tCS_LOG_ERROR(\"File System: Failed to copy directory '\" + sourceDirPath + \"'\");\r\n\t\t\t\t\t\treturn false;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\treturn true;\r\n\t\t}\r\n\r\n\t\t//---------------------------------------------------------------------------------\r\n\t\tbool FileSystem::DeleteFile(ChilliSource::StorageLocation storageLocation, const std::string& filePath) const\r\n\t\t{\r\n\t\t\tCS_ASSERT(IsStorageLocationWritable(storageLocation) == true, \"Cannot delete file from read-only storage location.\");\r\n\r\n            std::string absFilePath = GetAbsolutePathToStorageLocation(storageLocation) + ChilliSource::StringUtils::StandardiseFilePath(filePath);\r\n            s32 error = unlink(absFilePath.c_str());\r\n            if (error != 0)\r\n            {\r\n                return false;\r\n            }\r\n\r\n            return true;\r\n\t\t}\r\n\t\t//--------------------------------------------------------------\r\n\t\t//--------------------------------------------------------------\r\n\t\tbool FileSystem::DeleteDirectory(ChilliSource::StorageLocation storageLocation, const std::string& dirPath) const\r\n\t\t{\r\n\t\t\tCS_ASSERT(IsStorageLocationWritable(storageLocation), \"Cannot delete directory from read-only storage location.\");\r\n\r\n            std::string directoryPath = GetAbsolutePathToStorageLocation(storageLocation) + ChilliSource::StringUtils::StandardiseDirectoryPath(dirPath);\r\n            return CSBackend::RPi::DeleteDirectory(directoryPath);\r\n\r\n\t\t\treturn true;\r\n\t\t}\r\n\r\n\t\t//---------------------------------------------------------------------------------\r\n\t\tstd::vector<std::string> FileSystem::GetFilePaths(ChilliSource::StorageLocation storageLocation, const std::string& directoryPath, bool recursive) const\r\n\t\t{\r\n\t\t\tstd::vector<std::string> possibleDirectories = GetPossibleAbsoluteDirectoryPaths(storageLocation, directoryPath);\r\n\r\n\t\t\tstd::vector<std::string> output;\r\n\t\t\tstd::vector<std::string> filePaths;\r\n\t\t\tfor (const std::string& possibleDirectory : possibleDirectories)\r\n\t\t\t{\r\n\t\t\t\tfilePaths.clear();\r\n\r\n\t\t\t\tCSBackend::RPi::GetPaths(filePaths, possibleDirectory, false, recursive);\r\n\t\t\t\toutput.insert(output.end(), filePaths.begin(), filePaths.end());\r\n\t\t\t}\r\n\r\n\t\t\tstd::sort(output.begin(), output.end());\r\n\t\t\tstd::vector<std::string>::iterator it = std::unique(output.begin(), output.end());\r\n\t\t\toutput.resize(it - output.begin());\r\n\t\t\treturn output;\r\n\t\t}\r\n\r\n\t\t//---------------------------------------------------------------------------------\r\n\t\tstd::vector<std::string> FileSystem::GetDirectoryPaths(ChilliSource::StorageLocation storageLocation, const std::string& directoryPath, bool recursive) const\r\n\t\t{\r\n\t\t\tstd::vector<std::string> possibleDirectories = GetPossibleAbsoluteDirectoryPaths(storageLocation, directoryPath);\r\n\r\n\t\t\tstd::vector<std::string> output;\r\n\t\t\tstd::vector<std::string> directoryPaths;\r\n\t\t\tfor (const std::string& possibleDirectory : possibleDirectories)\r\n\t\t\t{\r\n\t\t\t\tdirectoryPaths.clear();\r\n\r\n\t\t\t\tCSBackend::RPi::GetPaths(directoryPaths, possibleDirectory, true, recursive);\r\n\t\t\t\toutput.insert(output.end(), directoryPaths.begin(), directoryPaths.end());\r\n\t\t\t}\r\n\r\n\t\t\tstd::sort(output.begin(), output.end());\r\n\t\t\tstd::vector<std::string>::iterator it = std::unique(output.begin(), output.end());\r\n\t\t\toutput.resize(it - output.begin());\r\n\t\t\treturn output;\r\n\t\t}\r\n\r\n\t\t//---------------------------------------------------------------------------------\r\n\t\tbool FileSystem::DoesFileExist(ChilliSource::StorageLocation storageLocation, const std::string& filePath) const\r\n\t\t{\r\n\t\t\tswitch (storageLocation)\r\n\t\t\t{\r\n\t\t\t\tcase ChilliSource::StorageLocation::k_DLC:\r\n\t\t\t\t{\r\n\t\t\t\t\tif (DoesItemExistInDLCCache(filePath, false) == true)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\treturn true;\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\treturn DoesFileExist(ChilliSource::StorageLocation::k_package, GetPackageDLCPath() + filePath);\r\n\t\t\t\t}\r\n\t\t\t\tdefault:\r\n\t\t\t\t{\r\n\t\t\t\t\tstd::string path = ChilliSource::StringUtils::StandardiseFilePath(GetAbsolutePathToStorageLocation(storageLocation) + filePath);\r\n\t\t\t\t\treturn CSBackend::RPi::DoesFileExist(path);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\treturn true;\r\n\t\t}\r\n\r\n\t\t//---------------------------------------------------------------------------------\r\n\t\tbool FileSystem::DoesFileExistInCachedDLC(const std::string& filePath) const\r\n\t\t{\r\n\t\t\treturn CSBackend::RPi::DoesFileExist(GetAbsolutePathToStorageLocation(ChilliSource::StorageLocation::k_DLC) + ChilliSource::StringUtils::StandardiseFilePath(filePath));\r\n\t\t}\r\n\r\n\t\t//---------------------------------------------------------------------------------\r\n\t\tbool FileSystem::DoesFileExistInPackageDLC(const std::string& filePath) const\r\n\t\t{\r\n\t\t\treturn DoesFileExist(ChilliSource::StorageLocation::k_package, GetPackageDLCPath() + filePath);\r\n\t\t}\r\n\r\n\t\t//---------------------------------------------------------------------------------\r\n\t\tbool FileSystem::DoesDirectoryExist(ChilliSource::StorageLocation storageLocation, const std::string& directoryPath) const\r\n\t\t{\r\n\t\t\tswitch (storageLocation)\r\n\t\t\t{\r\n\t\t\t\tcase ChilliSource::StorageLocation::k_DLC:\r\n\t\t\t\t{\r\n\t\t\t\t\tif (DoesItemExistInDLCCache(directoryPath, true) == true)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\treturn true;\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\treturn DoesDirectoryExist(ChilliSource::StorageLocation::k_package, GetPackageDLCPath() + directoryPath);\r\n\t\t\t\t}\r\n\t\t\t\tdefault:\r\n\t\t\t\t{\r\n\t\t\t\t\tstd::string path = ChilliSource::StringUtils::StandardiseDirectoryPath(GetAbsolutePathToStorageLocation(storageLocation) + directoryPath);\r\n\t\t\t\t\treturn CSBackend::RPi::DoesDirectoryExist(path);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\treturn true;\r\n\t\t}\r\n\r\n\t\t//---------------------------------------------------------------------------------\r\n\t\tbool FileSystem::DoesDirectoryExistInCachedDLC(const std::string& directoryPath) const\r\n\t\t{\r\n\t\t\treturn CSBackend::RPi::DoesDirectoryExist(GetAbsolutePathToStorageLocation(ChilliSource::StorageLocation::k_DLC) + ChilliSource::StringUtils::StandardiseFilePath(directoryPath));\r\n\t\t}\r\n\r\n\t\t//---------------------------------------------------------------------------------\r\n\t\tbool FileSystem::DoesDirectoryExistInPackageDLC(const std::string& directoryPath) const\r\n\t\t{\r\n\t\t\treturn DoesDirectoryExist(ChilliSource::StorageLocation::k_package, GetPackageDLCPath() + directoryPath);\r\n\t\t}\r\n\r\n\t\t//---------------------------------------------------------------------------------\r\n\t\tstd::string FileSystem::GetAbsolutePathToStorageLocation(ChilliSource::StorageLocation storageLocation) const\r\n\t\t{\r\n\t\t\tswitch (storageLocation)\r\n\t\t\t{\r\n\t\t\tcase ChilliSource::StorageLocation::k_package:\r\n\t\t\t\treturn m_packagePath + \"AppResources/\";\r\n\t\t\tcase ChilliSource::StorageLocation::k_chilliSource:\r\n\t\t\t\treturn m_packagePath + \"CSResources/\";\r\n\t\t\tcase ChilliSource::StorageLocation::k_saveData:\r\n\t\t\t\treturn m_documentsPath + k_saveDataPath;\r\n\t\t\tcase ChilliSource::StorageLocation::k_cache:\r\n\t\t\t\treturn m_documentsPath + k_cachePath;\r\n\t\t\tcase ChilliSource::StorageLocation::k_DLC:\r\n\t\t\t\treturn m_documentsPath + k_dlcPath;\r\n\t\t\tcase ChilliSource::StorageLocation::k_root:\r\n\t\t\t\treturn \"\";\r\n\t\t\t\tbreak;\r\n\t\t\tdefault:\r\n\t\t\t\tCS_LOG_ERROR(\"Storage Location not available on this platform!\");\r\n\t\t\t\treturn \"\";\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t//---------------------------------------------------------------------------------\r\n\t\tbool FileSystem::DoesItemExistInDLCCache(const std::string& path, bool isDirectory) const\r\n\t\t{\r\n\t\t\tstd::string fileOrDirPath = GetAbsolutePathToStorageLocation(ChilliSource::StorageLocation::k_DLC) + path;\r\n\t\t\tif (isDirectory == true)\r\n\t\t\t{\r\n\t\t\t\treturn CSBackend::RPi::DoesDirectoryExist(ChilliSource::StringUtils::StandardiseDirectoryPath(fileOrDirPath));\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\treturn CSBackend::RPi::DoesFileExist(ChilliSource::StringUtils::StandardiseFilePath(fileOrDirPath));\r\n\t\t\t}\r\n\t\t\treturn true;\r\n\t\t}\r\n\r\n\t\t//---------------------------------------------------------------------------------\r\n\t\tstd::vector<std::string> FileSystem::GetPossibleAbsoluteDirectoryPaths(ChilliSource::StorageLocation storageLocation, const std::string& path) const\r\n\t\t{\r\n\t\t\tstd::vector<std::string> output;\r\n\r\n\t\t\tswitch (storageLocation)\r\n\t\t\t{\r\n\t\t\t\tcase ChilliSource::StorageLocation::k_DLC:\r\n\t\t\t\t{\r\n\t\t\t\t\toutput.push_back(GetAbsolutePathToStorageLocation(ChilliSource::StorageLocation::k_package) + GetPackageDLCPath() + path);\r\n\t\t\t\t\toutput.push_back(GetAbsolutePathToStorageLocation(ChilliSource::StorageLocation::k_DLC) + path);\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\t\t\t\tdefault:\r\n\t\t\t\t{\r\n\t\t\t\t\toutput.push_back(GetAbsolutePathToStorageLocation(storageLocation) + path);\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\treturn output;\r\n\t\t}\r\n\t}\r\n}\r\n\r\n#endif\r\n"
  },
  {
    "path": "Source/CSBackend/Platform/RPi/Core/File/FileSystem.h",
    "content": "//\r\n//  The MIT License (MIT)\r\n//\r\n//  Copyright (c) 2017 Tag Games Limited\r\n//\r\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\r\n//  of this software and associated documentation files (the \"Software\"), to deal\r\n//  in the Software without restriction, including without limitation the rights\r\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\n//  copies of the Software, and to permit persons to whom the Software is\r\n//  furnished to do so, subject to the following conditions:\r\n//\r\n//  The above copyright notice and this permission notice shall be included in\r\n//  all copies or substantial portions of the Software.\r\n//\r\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r\n//  THE SOFTWARE.\r\n//\r\n\r\n#ifdef CS_TARGETPLATFORM_RPI\r\n\r\n#ifndef _CSBACKEND_RPI_CORE_FILE_FILESYSTEM_H_\r\n#define _CSBACKEND_RPI_CORE_FILE_FILESYSTEM_H_\r\n\r\n#include <CSBackend/Platform/RPi/ForwardDeclarations.h>\r\n#include <ChilliSource/Core/File/FileStream/BinaryInputStream.h>\r\n#include <ChilliSource/Core/File/FileStream/BinaryOutputStream.h>\r\n#include <ChilliSource/Core/File/FileStream/TextInputStream.h>\r\n#include <ChilliSource/Core/File/FileStream/TextOutputStream.h>\r\n#include <ChilliSource/Core/File/FileSystem.h>\r\n\r\n#include <string>\r\n\r\nnamespace CSBackend\r\n{\r\n\tnamespace RPi\r\n\t{\r\n\t\t/// The backend for the Raspberry Pi filesystem.\r\n\t\t/// The filesystem is responsible for all file manipulations\r\n\t\t/// including creating, copying, deleting, etc.\r\n\t\t///\r\n\t\tclass FileSystem final : public ChilliSource::FileSystem\r\n\t\t{\r\n\t\tpublic:\r\n\t\t\tCS_DECLARE_NAMEDTYPE(FileSystem);\r\n\r\n\t\t\t/// Queries whether or not this system implements the\r\n\t\t\t/// interface with the given Id.\r\n\t\t\t///\r\n\t\t\t/// @param interfaceId\r\n\t\t\t///\t\tThe id of the interface that we need to check if this system implements\r\n\t\t\t///\r\n\t\t\t/// @retrun TRUE if the system 'IsA' interface\r\n\t\t\t///\r\n\t\t\tbool IsA(ChilliSource::InterfaceIDType interfaceId) const override;\r\n\r\n            /// Creates a new \"read text stream to the given file in the given storage location.\r\n            ///\r\n            /// @param storageLocation\r\n\t\t\t///\t\tLocation to stream from\r\n            /// @param filePath\r\n\t\t\t/// \tFile path to stream from\r\n            ///\r\n            /// @return The new file stream. If the stream cannot be created or is invalid null will be returned.\r\n            ///\r\n            ChilliSource::ITextInputStreamUPtr CreateTextInputStream(ChilliSource::StorageLocation storageLocation, const std::string& filePath) const override;\r\n\r\n\t\t\t/// Creates a new \"read\" binary stream to the given file in the given storage location.\r\n            ///\r\n            /// @param storageLocation\r\n\t\t\t///\t\tLocation to stream from\r\n            /// @param filePath\r\n\t\t\t/// \tFile path to stream from\r\n            ///\r\n            /// @return The new file stream. If the stream cannot be created or is invalid null will be returned.\r\n            ///\r\n\t\t\tChilliSource::IBinaryInputStreamUPtr CreateBinaryInputStream(ChilliSource::StorageLocation storageLocation, const std::string& filePath) const override;\r\n\r\n\t\t\t/// Creates a new \"write\" text stream to the given file in the given storage location.\r\n\t\t\t///\r\n\t\t\t/// @param storageLocation\r\n\t\t\t///\t\tLocation to stream to\r\n            /// @param filePath\r\n\t\t\t/// \tFile path to stream to\r\n\t\t\t/// @param fileMode\r\n\t\t\t///\t\tWrite mode (i.e. whether to replace or append, etc)\r\n\t\t\t///\r\n\t\t\t/// @return The new file stream. If the stream cannot be created or is invalid null will be returned.\r\n\t\t\t///\r\n\t\t\tChilliSource::TextOutputStreamUPtr CreateTextOutputStream(ChilliSource::StorageLocation storageLocation, const std::string& filePath, ChilliSource::FileWriteMode fileMode) const override;\r\n\r\n\t\t\t/// Creates a new \"write\" binary stream to the given file in the given storage location.\r\n\t\t\t///\r\n\t\t\t/// @param storageLocation\r\n\t\t\t///\t\tLocation to stream to\r\n            /// @param filePath\r\n\t\t\t/// \tFile path to stream to\r\n\t\t\t/// @param fileMode\r\n\t\t\t///\t\tWrite mode (i.e. whether to replace or append, etc)\r\n\t\t\t///\r\n\t\t\t/// @return The new file stream. If the stream cannot be created or is invalid null will be returned.\r\n\t\t\t///\r\n\t\t\tChilliSource::BinaryOutputStreamUPtr CreateBinaryOutputStream(ChilliSource::StorageLocation storageLocation, const std::string& filePath, ChilliSource::FileWriteMode fileMode) const override;\r\n\r\n\t\t\t/// Creates the given directory. The full directory hierarchy will be created.\r\n\t\t\t///\r\n\t\t\t/// @param storageLocation\r\n\t\t\t///\t\tLocation in which to create the directory\r\n            /// @param directoryPath\r\n\t\t\t///\t\tThe path to new directory\r\n\t\t\t///\r\n            /// @return Whether or not this was successful. Failure to create the directory because it already exists is considered a success.\r\n\t\t\t///\r\n\t\t\tbool CreateDirectoryPath(ChilliSource::StorageLocation storageLocation, const std::string& directoryPath) const override;\r\n\r\n\t\t\t/// Copies a file from one location to another.\r\n\t\t\t///\r\n\t\t\t/// @param sourceLocation\r\n\t\t\t///\t\tLocation to copy from\r\n\t\t\t/// @param sourceFilePath\r\n\t\t\t///\t\tThe path to copy from\r\n\t\t\t/// @param destLocation\r\n\t\t\t///\t\tLocation to copy to\r\n\t\t\t/// @param destFilePath\r\n\t\t\t///\t\tThe path to copy to\r\n\t\t\t///\r\n\t\t\t/// @return Whether or not the file was successfully copied.\r\n\t\t\t///\r\n\t\t\tbool CopyFile(ChilliSource::StorageLocation sourceLocation, const std::string& sourceFilePath, ChilliSource::StorageLocation destLocation, const std::string& destFilePath) const override;\r\n\r\n\t\t\t/// Copies a directory and its contents from one location to another.\r\n\t\t\t///\r\n\t\t\t/// @param sourceLocation\r\n\t\t\t///\t\tLocation to copy from\r\n\t\t\t/// @param sourceDirPath\r\n\t\t\t///\t\tThe path to copy from\r\n\t\t\t/// @param destLocation\r\n\t\t\t///\t\tLocation to copy to\r\n\t\t\t/// @param destDirPath\r\n\t\t\t///\t\tThe path to copy to\r\n\t\t\t///\r\n\t\t\t/// @return Whether or not the directory was successfully copied.\r\n\t\t\t///\r\n\t\t\tbool CopyDirectory(ChilliSource::StorageLocation sourceLocation, const std::string& sourceDirPath, ChilliSource::StorageLocation destLocation, const std::string& destDirPath) const override;\r\n\r\n\t\t\t/// Deletes the specified file.\r\n\t\t\t///\r\n\t\t\t/// @param storageLocation\r\n\t\t\t///\t\tLocation of file to delete\r\n\t\t\t/// @param filePath\r\n\t\t\t/// \tPath to file to delete\r\n\t\t\t///\r\n\t\t\t/// @return Whether or not the file was successfully deleted.\r\n\t\t\t///\r\n\t\t\tbool DeleteFile(ChilliSource::StorageLocation storageLocation, const std::string& filePath) const override;\r\n\r\n\t\t\t/// Deletes the specified directory and all its contents.\r\n\t\t\t///\r\n\t\t\t/// @param storageLocation\r\n\t\t\t///\t\tLocation of dir to delete\r\n\t\t\t/// @param directoryPath\r\n\t\t\t/// \tPath to directory to delete\r\n\t\t\t///\r\n\t\t\t/// @return Whether or not the directory was successfully deleted.\r\n\t\t\t///\r\n\t\t\tbool DeleteDirectory(ChilliSource::StorageLocation storageLocation, const std::string& directoryPath) const override;\r\n\r\n\t\t\t/// Builds a list of all the files in the given directory. Paths are relative to the given directory\r\n\t\t\t///\r\n\t\t\t/// @param storageLocation\r\n\t\t\t///\t\tLocation of the directory to profile\r\n\t\t\t/// @param directoryPath\r\n\t\t\t///\t\tPath to the directory to profile\r\n\t\t\t/// @param recursive\r\n\t\t\t///\t\tIf TRUE all subfolders will be profiled, if FALSE only the given directory.\r\n\t\t\t///\r\n\t\t\t/// @return List of all filepaths in the given directory\r\n\t\t\t///\r\n\t\t\tstd::vector<std::string> GetFilePaths(ChilliSource::StorageLocation storageLocation, const std::string& directoryPath, bool recursive) const override;\r\n\r\n\t\t\t/// Builds a list of all the sub-dirs in the given directory. Paths are relative to the given directory\r\n\t\t\t///\r\n\t\t\t/// @param storageLocation\r\n\t\t\t///\t\tLocation of the directory to profile\r\n\t\t\t/// @param directoryPath\r\n\t\t\t///\t\tPath to the directory to profile\r\n\t\t\t/// @param recursive\r\n\t\t\t///\t\tIf TRUE all subfolders will be profiled, if FALSE only the given directory.\r\n\t\t\t///\r\n\t\t\t/// @return List of all directory paths in the given directory\r\n\t\t\t///\r\n\t\t\tstd::vector<std::string> GetDirectoryPaths(ChilliSource::StorageLocation storageLocation, const std::string& directoryPath, bool recursive) const override;\r\n\r\n\t\t\t/// @param storageLocation\r\n\t\t\t///\t\tLocation of file to check\r\n\t\t\t/// @param filePath\r\n\t\t\t/// \tPath to file to check\r\n\t\t\t///\r\n\t\t\t/// @return Whether or not the given file exists.\r\n\t\t\t///\r\n\t\t\tbool DoesFileExist(ChilliSource::StorageLocation storageLocation, const std::string& filePath) const override;\r\n\r\n\t\t\t/// @param filePath\r\n\t\t\t/// \tPath to file to check (relative to cached DLC directory)\r\n\t\t\t///\r\n\t\t\t/// @return Whether or not the given file exists in the cached DLC directory.\r\n\t\t\t///\r\n\t\t\tbool DoesFileExistInCachedDLC(const std::string& filePath) const override;\r\n\r\n\t\t\t/// @param filePath\r\n\t\t\t/// \tPath to file to check (relative to package DLC directory)\r\n\t\t\t///\r\n\t\t\t/// @return Whether or not the given file exists in the package DLC directory.\r\n\t\t\t///\r\n\t\t\tbool DoesFileExistInPackageDLC(const std::string& filePath) const override;\r\n\r\n\t\t\t/// @param storageLocation\r\n\t\t\t///\t\tLocation of directory to check\r\n\t\t\t/// @param directoryPath\r\n\t\t\t/// \tPath to dir to check\r\n\t\t\t///\r\n\t\t\t/// @return Whether or not the given directory exists.\r\n\t\t\t///\r\n\t\t\tbool DoesDirectoryExist(ChilliSource::StorageLocation storageLocation, const std::string& directoryPath) const override;\r\n\r\n\t\t\t/// @param directoryPath\r\n\t\t\t/// \tPath to dir to check (relative to cached DLC directory)\r\n\t\t\t///\r\n\t\t\t/// @return Whether or not the given directory exists in the cached DLC directory\r\n\t\t\t///\r\n\t\t\tbool DoesDirectoryExistInCachedDLC(const std::string& directoryPath) const override;\r\n\r\n\t\t\t/// @param directoryPath\r\n\t\t\t/// \tPath to dir to check (relative to package DLC directory)\r\n\t\t\t///\r\n\t\t\t/// @return Whether or not the given directory exists in the package DLC directory\r\n\t\t\t///\r\n\t\t\tbool DoesDirectoryExistInPackageDLC(const std::string& directoryPath) const override;\r\n\r\n\t\t\t/// Returns the absolute path to the given storage location. The\r\n\t\t\t/// value this returns is platform specific and use of this\r\n\t\t\t/// should be kept to a minimum in cross platform projects.\r\n\t\t\t///\r\n\t\t\t/// @param storageLocation\r\n\t\t\t///\t\tLocation to get the path to\r\n\t\t\t///\r\n\t\t\t/// @return Full path to the given storage location\r\n\t\t\t///\r\n\t\t\tstd::string GetAbsolutePathToStorageLocation(ChilliSource::StorageLocation storageLocation) const override;\r\n\r\n\t\tprivate:\r\n\t\t\tfriend ChilliSource::FileSystemUPtr ChilliSource::FileSystem::Create();\r\n\r\n\t\t\t///\r\n\t\t\tFileSystem();\r\n\r\n\t\t\t/// Returns whether or not a file or directory exists specifically\r\n\t\t\t/// in the DLC cache.\r\n\t\t\t///\r\n\t\t\t/// @param path\r\n\t\t\t///\t\tPath to file or directory to check\r\n\t\t\t/// @param isDirectory\r\n\t\t\t///\t\tIf TRUE path is considered to lead to a dir, otherwise a file.\r\n\t\t\t///\r\n\t\t\t/// @return whether or not it exists.\r\n\t\t\t///\r\n\t\t\tbool DoesItemExistInDLCCache(const std::string& path, bool isDirectory) const;\r\n\r\n\t\t\t/// Builds a list of all possible full paths that the given relative path might refer to.\r\n\t\t\t/// For example a path in location dlc might refer to either cached dlc or package dlc.\r\n\t\t\t///\r\n\t\t\t/// @param storageLocation\r\n\t\t\t///\t\tLocation to profile\r\n\t\t\t/// @param directoryPath\r\n\t\t\t///\t\tRelative directory path for which to build possible absolute paths.\r\n\t\t\t///\r\n\t\t\t/// @return All the paths for the given location\r\n\t\t\t///\r\n\t\t\tstd::vector<std::string> GetPossibleAbsoluteDirectoryPaths(ChilliSource::StorageLocation storageLocation, const std::string& directoryPath) const;\r\n\r\n\t\t\tstd::string m_packagePath;\r\n\t\t\tstd::string m_documentsPath;\r\n\t\t};\r\n\t}\r\n}\r\n\r\n#endif\r\n\r\n#endif\r\n"
  },
  {
    "path": "Source/CSBackend/Platform/RPi/Core/Image/PNGImageProvider.cpp",
    "content": "//\r\n//  The MIT License (MIT)\r\n//\r\n//  Copyright (c) 2017 Tag Games Limited\r\n//\r\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\r\n//  of this software and associated documentation files (the \"Software\"), to deal\r\n//  in the Software without restriction, including without limitation the rights\r\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\n//  copies of the Software, and to permit persons to whom the Software is\r\n//  furnished to do so, subject to the following conditions:\r\n//\r\n//  The above copyright notice and this permission notice shall be included in\r\n//  all copies or substantial portions of the Software.\r\n//\r\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r\n//  THE SOFTWARE.\r\n//\r\n\r\n#ifdef CS_TARGETPLATFORM_RPI\r\n\r\n#include <CSBackend/Platform/RPi/Core/Image/PNGImageProvider.h>\r\n\r\n#include <CSBackend/Platform/RPi/Core/Image/PngImage.h>\r\n#include <ChilliSource/Core/Base/Application.h>\r\n#include <ChilliSource/Core/Image/Image.h>\r\n#include <ChilliSource/Core/Image/ImageCompression.h>\r\n#include <ChilliSource/Core/Image/ImageFormat.h>\r\n#include <ChilliSource/Core/String/StringUtils.h>\r\n#include <ChilliSource/Core/Threading/TaskScheduler.h>\r\n\r\nnamespace CSBackend\r\n{\r\n\tnamespace RPi\r\n\t{\r\n\t\tnamespace\r\n\t\t{\r\n\t\t\tconst std::string k_pngExtension(\"png\");\r\n\r\n\t\t\t///\r\n\t\t\t/// Performs the heavy lifting for the 2 create methods\r\n\t\t\t///\r\n\t\t\t/// @author Ian Copland\r\n\t\t\t///\r\n\t\t\t/// @param storageLocation\r\n\t\t\t///\t\tThe storage location.\r\n\t\t\t/// @param filePath\r\n\t\t\t///\t\tThe filepath.\r\n\t\t\t/// @param delegate\r\n\t\t\t///\t\tCompletion delegate\r\n\t\t\t/// @param [Out] out_resource\r\n\t\t\t///\t\tThe output resource\r\n\t\t\t///\r\n\t\t\tvoid CreatePNGImageFromFile(ChilliSource::StorageLocation storageLocation, const std::string& filepath, const ChilliSource::ResourceProvider::AsyncLoadDelegate& delegate, const ChilliSource::ResourceSPtr& out_resource)\r\n\t\t\t{\r\n\t\t\t\tChilliSource::Image* imageResource = (ChilliSource::Image*)(out_resource.get());\r\n\r\n\t\t\t\t//load the png image\r\n\t\t\t\tPngImage image;\r\n\t\t\t\timage.Load(storageLocation, filepath);\r\n\r\n\t\t\t\t//check the image has loaded\r\n\t\t\t\tif (image.IsLoaded() == false)\r\n\t\t\t\t{\r\n\t\t\t\t\timage.Release();\r\n\t\t\t\t\tCS_LOG_ERROR(\"Failed to load image: \" + filepath);\r\n\t\t\t\t\timageResource->SetLoadState(ChilliSource::Resource::LoadState::k_failed);\r\n\t\t\t\t\tif (delegate != nullptr)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_mainThread, [=](const ChilliSource::TaskContext&)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tdelegate(out_resource);\r\n\t\t\t\t\t\t});\r\n\t\t\t\t\t}\r\n\t\t\t\t\treturn;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tChilliSource::Image::Descriptor desc;\r\n\t\t\t\tdesc.m_compression = ChilliSource::ImageCompression::k_none;\r\n\t\t\t\tdesc.m_format = image.GetImageFormat();\r\n\t\t\t\tdesc.m_width = image.GetWidth();\r\n\t\t\t\tdesc.m_height = image.GetHeight();\r\n\t\t\t\tdesc.m_dataSize = image.GetDataSize();\r\n\t\t\t\timageResource->Build(desc, ChilliSource::Image::ImageDataUPtr(image.GetImageData()));\r\n\r\n\t\t\t\t//release the png image without deallocating the image data\r\n\t\t\t\timage.Release(false);\r\n\r\n\t\t\t\timageResource->SetLoadState(ChilliSource::Resource::LoadState::k_loaded);\r\n\t\t\t\tif (delegate != nullptr)\r\n\t\t\t\t{\r\n\t\t\t\t\tChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_mainThread, [=](const ChilliSource::TaskContext&)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tdelegate(out_resource);\r\n\t\t\t\t\t});\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tCS_DEFINE_NAMEDTYPE(PNGImageProvider);\r\n\r\n\t\t//---------------------------------------------------------------------------------\r\n\t\tbool PNGImageProvider::IsA(ChilliSource::InterfaceIDType interfaceId) const\r\n\t\t{\r\n\t\t\treturn (interfaceId == ChilliSource::ResourceProvider::InterfaceID || interfaceId == ChilliSource::PNGImageProvider::InterfaceID || interfaceId == PNGImageProvider::InterfaceID);\r\n\t\t}\r\n\r\n\t\t//---------------------------------------------------------------------------------\r\n\t\tChilliSource::InterfaceIDType PNGImageProvider::GetResourceType() const\r\n\t\t{\r\n\t\t\treturn ChilliSource::Image::InterfaceID;\r\n\t\t}\r\n\r\n\t\t//---------------------------------------------------------------------------------\r\n\t\tbool PNGImageProvider::CanCreateResourceWithFileExtension(const std::string& extension) const\r\n\t\t{\r\n\t\t\treturn (extension == k_pngExtension);\r\n\t\t}\r\n\r\n\t\t//---------------------------------------------------------------------------------\r\n\t\tvoid PNGImageProvider::CreateResourceFromFile(ChilliSource::StorageLocation storageLocation, const std::string& filepath, const ChilliSource::IResourceOptionsBaseCSPtr& options, const ChilliSource::ResourceSPtr& out_resource)\r\n\t\t{\r\n\t\t\tCreatePNGImageFromFile(storageLocation, filepath, nullptr, out_resource);\r\n\t\t}\r\n\r\n\t\t//---------------------------------------------------------------------------------\r\n\t\tvoid PNGImageProvider::CreateResourceFromFileAsync(ChilliSource::StorageLocation storageLocation, const std::string& filePath, const ChilliSource::IResourceOptionsBaseCSPtr& options, const ChilliSource::ResourceProvider::AsyncLoadDelegate& delegate, const ChilliSource::ResourceSPtr& out_resource)\r\n\t\t{\r\n\t\t\tChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_file, [=](const ChilliSource::TaskContext&)\r\n\t\t\t{\r\n\t\t\t\tCreatePNGImageFromFile(storageLocation, filePath, delegate, out_resource);\r\n\t\t\t});\r\n\t\t}\r\n\t}\r\n}\r\n\r\n#endif\r\n"
  },
  {
    "path": "Source/CSBackend/Platform/RPi/Core/Image/PNGImageProvider.h",
    "content": "//\r\n//  The MIT License (MIT)\r\n//\r\n//  Copyright (c) 2017 Tag Games Limited\r\n//\r\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\r\n//  of this software and associated documentation files (the \"Software\"), to deal\r\n//  in the Software without restriction, including without limitation the rights\r\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\n//  copies of the Software, and to permit persons to whom the Software is\r\n//  furnished to do so, subject to the following conditions:\r\n//\r\n//  The above copyright notice and this permission notice shall be included in\r\n//  all copies or substantial portions of the Software.\r\n//\r\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r\n//  THE SOFTWARE.\r\n//\r\n\r\n#ifdef CS_TARGETPLATFORM_RPI\r\n\r\n#ifndef _CSBACKEND_PLATFORM_RPI_CORE_IMAGE_PNGIMAGEPROVIDER_H_\r\n#define _CSBACKEND_PLATFORM_RPI_CORE_IMAGE_PNGIMAGEPROVIDER_H_\r\n\r\n#include <CSBackend/Platform/RPi/ForwardDeclarations.h>\r\n#include <ChilliSource/Core/Image/Image.h>\r\n#include <ChilliSource/Core/Image/PNGImageProvider.h>\r\n\r\nnamespace CSBackend\r\n{\r\n\tnamespace RPi\r\n\t{\r\n\t\t/// The Raspberry Pi backend for the PNG Image Provider. This loads\r\n\t\t/// PNG images from file.\r\n\t\t///\r\n\t\tclass PNGImageProvider final : public ChilliSource::PNGImageProvider\r\n\t\t{\r\n\t\tpublic:\r\n\t\t\tCS_DECLARE_NAMEDTYPE(PNGImageProvider);\r\n\r\n\t\t\t/// Queries whether or not this system implements the\r\n\t\t\t/// interface with the given Id.\r\n\t\t\t///\r\n\t\t\t/// @param interfaceId\r\n\t\t\t///\t\tThe id of the interface that we need to check if this system implements\r\n\t\t\t///\r\n\t\t\t/// @retrun TRUE if the system 'IsA' interface\r\n\t\t\t///\r\n\t\t\tbool IsA(ChilliSource::InterfaceIDType iinterfaceId) const override;\r\n\r\n\t\t\t/// @return The resource type this provider can load\r\n\t\t\t///\r\n\t\t\tChilliSource::InterfaceIDType GetResourceType() const override;\r\n\r\n\t\t\t/// @param extension\r\n\t\t\t///\t\tExtension to check that the system can load\r\n\t\t\t///\r\n\t\t\t/// @return TRUE if the object can load a resource with given extension\r\n\t\t\t///\r\n\t\t\tbool CanCreateResourceWithFileExtension(const std::string& extension) const override;\r\n\r\n\t\t\t/// Creates a new image resource from file. Check the\r\n\t\t\t/// resource load state for success or failure\r\n\t\t\t///\r\n\t\t\t/// @param location\r\n\t\t\t///\t\tThe storage location to load from\r\n\t\t\t/// @param filePath\r\n\t\t\t///\t\tFile path to resource\r\n\t\t\t/// @param options\r\n\t\t\t///\t\tOptions to customise the creation\r\n\t\t\t/// @param [Out] out_resource\r\n\t\t\t///\t\tAssigned when the resource creation is finished\r\n\t\t\t///\r\n\t\t\tvoid CreateResourceFromFile(ChilliSource::StorageLocation location, const std::string& filePath, const ChilliSource::IResourceOptionsBaseCSPtr& options, const ChilliSource::ResourceSPtr& out_resource) override;\r\n\r\n\t\t\t/// Creates a new image resource from file asynchronously. Check the\r\n\t\t\t/// resource load state for success or failure. Delgate is called when creation\r\n\t\t\t/// is finished\r\n\t\t\t///\r\n\t\t\t/// @param location\r\n\t\t\t///\t\tThe storage location to load from\r\n\t\t\t/// @param filePath\r\n\t\t\t///\t\tFile path to resource\r\n\t\t\t/// @param options\r\n\t\t\t///\t\tOptions to customise the creation\r\n\t\t\t/// @param delegate\r\n\t\t\t///\t\tDelegate called when finished\r\n\t\t\t/// @param [Out] out_resource\r\n\t\t\t///\t\tAssigned when the resource creation is finished\r\n\t\t\t///\r\n\t\t\tvoid CreateResourceFromFileAsync(ChilliSource::StorageLocation location, const std::string& filePath, const ChilliSource::IResourceOptionsBaseCSPtr& options, const ChilliSource::ResourceProvider::AsyncLoadDelegate& delegate, const ChilliSource::ResourceSPtr& out_resource) override;\r\n\t\t\t\r\n\t\tprivate:\r\n\t\t\tfriend ChilliSource::PNGImageProviderUPtr ChilliSource::PNGImageProvider::Create();\r\n\t\t\t//-----------------------------------------------------------\r\n\t\t\t/// Private constructor to force use of factory method\r\n\t\t\t///\r\n\t\t\t/// @author Ian Copland\r\n\t\t\t//-----------------------------------------------------------\r\n\t\t\tPNGImageProvider() = default;\r\n\t\t};\r\n\t}\r\n}\r\n\r\n#endif\r\n\r\n#endif\r\n"
  },
  {
    "path": "Source/CSBackend/Platform/RPi/Core/Image/PngImage.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2017 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_RPI\n\n#include <CSBackend/Platform/RPi/Core/Image/PngImage.h>\n\n#include <png/png.h>\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/Image/ImageFormat.h>\n\n/// A replacement for the default libPng file reading function. This is needed so\n/// the c style file io functions can be replaced with ChilliSource functions,\n/// enabling loading from the package.\n///\n/// @param png_ptr\n///\t\tThe currently open Png decorder\n/// @param data\n//\t\t The output data.\n/// @param length\n///\t\tThe length of the data.\n///\nvoid ReadPngData(png_structp png_ptr, png_bytep data, png_size_t length)\n{\n\tif (png_ptr == nullptr)\n\t\treturn;\n\n\tChilliSource::IBinaryInputStream* pStream = (ChilliSource::IBinaryInputStream*)png_get_io_ptr(png_ptr);\n\tpStream->Read(reinterpret_cast<u8*>(data), s32(length));\n}\n\nnamespace CSBackend\n{\n\tnamespace RPi\n\t{\n\t\t//---------------------------------------------------------------------------------\n\t\tPngImage::PngImage()\n\t\t{\n\t\t\tmbIsLoaded = false;\n\t\t\tmdwHeight = -1;\n\t\t\tmdwWidth = -1;\n\t\t\tmpData = nullptr;\n\t\t}\n\n\t\t//---------------------------------------------------------------------------------\n\t\tPngImage::PngImage(ChilliSource::StorageLocation location, const std::string& filePath)\n\t\t{\n\t\t\tmbIsLoaded = false;\n\t\t\tmdwHeight = -1;\n\t\t\tmdwWidth = -1;\n\t\t\tmpData = nullptr;\n\n\t\t\tLoad(location, filePath);\n\t\t}\n\n\t\t//---------------------------------------------------------------------------------\n\t\tPngImage::~PngImage()\n\t\t{\n\t\t\tif (mbIsLoaded == true)\n\t\t\t{\n\t\t\t\tRelease();\n\t\t\t}\n\t\t}\n\n\t\t//---------------------------------------------------------------------------------\n\t\tvoid PngImage::Load(ChilliSource::StorageLocation location, const std::string& filePath)\n\t\t{\n\t\t\t//create the file stream\n\t\t\tauto stream = ChilliSource::Application::Get()->GetFileSystem()->CreateBinaryInputStream(location, filePath);\n\n\t\t\t//insure the stream is not broken\n\t\t\tif (stream == nullptr)\n\t\t\t{\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t//load from lib png\n\t\t\tif (LoadWithLibPng(stream) == true)\n\t\t\t{\n\t\t\t\tmbIsLoaded = true;\n\t\t\t}\n\t\t}\n\n\t\t//---------------------------------------------------------------------------------\n\t\tvoid PngImage::Release(bool releaseData)\n\t\t{\n\t\t\tif (mbIsLoaded != false)\n\t\t\t{\n\t\t\t\tmbIsLoaded = false;\n\t\t\t\tmdwHeight = -1;\n\t\t\t\tmdwWidth = -1;\n\t\t\t\tif (releaseData)\n\t\t\t\t\tdelete[] mpData;\n\t\t\t\tmpData = (u8*)nullptr;\n\t\t\t}\n\t\t}\n\n\t\t//---------------------------------------------------------------------------------\n\t\tbool PngImage::IsLoaded() const\n\t\t{\n\t\t\treturn mbIsLoaded;\n\t\t}\n\n\t\t//---------------------------------------------------------------------------------\n\t\ts32 PngImage::GetHeight() const\n\t\t{\n\t\t\treturn mdwHeight;\n\t\t}\n\n\t\t//---------------------------------------------------------------------------------\n\t\ts32 PngImage::GetWidth() const\n\t\t{\n\t\t\treturn mdwWidth;\n\t\t}\n\n\t\t//---------------------------------------------------------------------------------\n\t\tu8 * PngImage::GetImageData() const\n\t\t{\n\t\t\treturn mpData;\n\t\t}\n\n\t\t//---------------------------------------------------------------------------------\n\t\tu32 PngImage::GetDataSize() const\n\t\t{\n\t\t\treturn m_dataSize;\n\t\t}\n\n\t\t//---------------------------------------------------------------------------------\n\t\tChilliSource::ImageFormat PngImage::GetImageFormat() const\n\t\t{\n\t\t\treturn m_format;\n\t\t}\n\n\t\t//---------------------------------------------------------------------------------\n\t\tbool PngImage::LoadWithLibPng(const ChilliSource::IBinaryInputStreamUPtr& stream)\n\t\t{\n\t\t\t//insure that it is indeed a png\n\t\t\tconst s32 dwHeaderSize = 8;\n\t\t\tu8 ubyHeader[dwHeaderSize];\n\t\t\tstream->Read(ubyHeader, dwHeaderSize);\n\n\t\t\tif (png_sig_cmp(ubyHeader, 0, dwHeaderSize) > 0)\n\t\t\t{\n\t\t\t\tCS_LOG_ERROR(\"PNG header invalid.\");\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t//create the png structure\n\t\t\tpng_structp pPng = png_create_read_struct(PNG_LIBPNG_VER_STRING, nullptr, nullptr, nullptr);\n\t\t\tif (!pPng)\n\t\t\t{\n\t\t\t\tCS_LOG_ERROR(\"Could not create pPng\");\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t//create the png info\n\t\t\tpng_infop pInfo = png_create_info_struct(pPng);\n\t\t\tif (!pInfo)\n\t\t\t{\n\t\t\t\tCS_LOG_ERROR(\"Could not create pInfo\");\n\t\t\t\tpng_destroy_read_struct(&pPng, (png_infopp)nullptr, (png_infopp)nullptr);\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t//setup jump\n\t\t\tif (setjmp(png_jmpbuf(pPng)))\n\t\t\t{\n\t\t\t\tCS_LOG_ERROR(\"Error while loading PNG.\");\n\t\t\t\tpng_destroy_read_struct(&pPng, &pInfo, (png_infopp)nullptr);\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t//Setup the ReadPngData function for use within libPng\n\t\t\tpng_set_read_fn(pPng,(void*)stream.get(), ReadPngData);\n\n\t\t\t//tell it that we've ready read 8 bytes of data\n\t\t\tpng_set_sig_bytes(pPng, dwHeaderSize);\n\n\t\t\t//read the chunks of data upto the actual image data\n\t\t\tpng_read_info(pPng, pInfo);\n\n\t\t\t//get the info thats just been read\n\t\t\tpng_uint_32 udwWidth = 0;\n\t\t\tpng_uint_32 udwHeight = 0;\n\t\t\ts32 dwBitDepth = -1;\n\t\t\ts32 dwColorType = -1;\n\t\t\ts32 dwInterlaceType = -1;\n\t\t\ts32 dwCompressionMethod = -1;\n\t\t\ts32 dwFilterMethod = -1;\n\t\t\tpng_get_IHDR(pPng, pInfo, &udwWidth, &udwHeight, &dwBitDepth, &dwColorType, &dwInterlaceType, &dwCompressionMethod, &dwFilterMethod);\n\n\t\t\t//--transformations\n\t\t\t//sorts out grey scale images, probably not needed, but put in anyway\n\t\t\tif (dwColorType == PNG_COLOR_TYPE_PALETTE) png_set_palette_to_rgb(pPng);\n\t\t\tif (dwColorType == PNG_COLOR_TYPE_GRAY && dwBitDepth < 8) png_set_expand_gray_1_2_4_to_8(pPng);\n\t\t\tif (png_get_valid(pPng, pInfo, PNG_INFO_tRNS)) png_set_tRNS_to_alpha(pPng);\n\n\t\t\t//insure all files use 1 bit each for R,G,B and A\n\t\t\tif (dwBitDepth == 16) png_set_strip_16(pPng);\n\n\t\t\t//unpack compressed pixels\n\t\t\tif (dwBitDepth < 8) png_set_packing(pPng);\n\n\t\t\t//pack in an alpha value if there isn't one.\n\t\t\tif (dwColorType == PNG_COLOR_TYPE_RGB || dwColorType == PNG_COLOR_TYPE_GRAY)\n\t\t\t\tpng_set_add_alpha(pPng, (u8)255, PNG_FILLER_AFTER);\n\n\t\t\t//for the sake of simplicity, turn grey scale images into RGB\n\t\t\tif (dwColorType == PNG_COLOR_TYPE_GRAY || dwColorType == PNG_COLOR_TYPE_GRAY_ALPHA)\n\t\t\t\tpng_set_gray_to_rgb(pPng);\n\n\t\t\t//set to little endianness\n\t\t\tif (dwBitDepth == 16)\n\t\t\t\tpng_set_swap(pPng);\n\n\t\t\t//tell libpng to handling interlacing\n\t\t\ts32 number_of_passes = png_set_interlace_handling(pPng);\n\n\t\t\t//after all these transformations, update the png info\n\t\t\tpng_read_update_info(pPng, pInfo);\n\n\t\t\t//read the image into the data buffer\n\t\t\ts32 dwRowBytes = s32(png_get_rowbytes(pPng, pInfo));\n\t\t\tm_dataSize = dwRowBytes * udwHeight;\n\t\t\tmpData = new u8[m_dataSize];\n\n\t\t\tfor (s32 pass = 0; pass < number_of_passes; pass++)\n\t\t\t{\n\t\t\t\tfor (u32 y = 0; y < udwHeight; y += 1)\n\t\t\t\t{\n\t\t\t\t\tpng_bytep row = (mpData + y * dwRowBytes);\n\t\t\t\t\tpng_read_rows(pPng, &row, nullptr, 1);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t//store the width and height\n\t\t\tmdwWidth = (s32)udwWidth;\n\t\t\tmdwHeight = (s32)udwHeight;\n\n\t\t\t//-------- Get the image format\n\t\t\tpng_get_IHDR(pPng, pInfo, &udwWidth, &udwHeight, &dwBitDepth, &dwColorType, &dwInterlaceType, &dwCompressionMethod, &dwFilterMethod);\n\t\t\tswitch (dwColorType)\n\t\t\t{\n\t\t\tcase PNG_COLOR_TYPE_GRAY:\n\t\t\t\tm_format = ChilliSource::ImageFormat::k_Lum8;\n\t\t\t\tbreak;\n\t\t\tcase PNG_COLOR_TYPE_GRAY_ALPHA:\n\t\t\t\tm_format = ChilliSource::ImageFormat::k_LumA88;\n\t\t\t\tbreak;\n\t\t\tcase PNG_COLOR_TYPE_RGB:\n\t\t\t\tm_format = ChilliSource::ImageFormat::k_RGB888;\n\t\t\t\tbreak;\n\t\t\tcase PNG_COLOR_TYPE_RGB_ALPHA:\n\t\t\t\tm_format = ChilliSource::ImageFormat::k_RGBA8888;\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tCS_LOG_ERROR(\"Trying to load a PNG with an unknown colour format!\");\n\t\t\t\tpng_read_end(pPng, nullptr);\n\t\t\t\tpng_destroy_read_struct(&pPng, &pInfo, (png_infopp)nullptr);\n\t\t\t\treturn false;\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\t//end the read\n\t\t\tpng_read_end(pPng, nullptr);\n\n\t\t\t//deallocate everything\n\t\t\tpng_destroy_read_struct(&pPng, &pInfo, (png_infopp)nullptr);\n\t\t\treturn true;\n\t\t}\n\t}\n}\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/RPi/Core/Image/PngImage.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2011 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_RPI\n\n#ifndef _CSBACKEND_PLATFORM_RPI_CORE_IMAGE_PNGIMAGE_H_\n#define _CSBACKEND_PLATFORM_RPI_CORE_IMAGE_PNGIMAGE_H_\n\n#include <CSBackend/Platform/RPi/ForwardDeclarations.h>\n#include <ChilliSource/Core/File/FileSystem.h>\n\nnamespace CSBackend\n{\n\tnamespace RPi\n\t{\n\t\t/// Wrapper around libpng to load png images\n\t\t///\n\t\tclass PngImage final\n\t\t{\n\t\tpublic:\n\n\t\t\t///\n\t\t\tPngImage();\n\n\t\t\t/// Loads the image\n\t\t\t///\n\t\t\t///@param location\n\t\t\t///\t\tLocation to load from\n\t\t\t/// @param filePath\n\t\t\t///\t\tFile path to load from\n\t\t\t///\n\t\t\tPngImage(ChilliSource::StorageLocation location, const std::string& filePath);\n\n\t\t\t///\n\t\t\t~PngImage();\n\n\t\t\t/// Loads the image\n\t\t\t///\n\t\t\t/// @param location\n\t\t\t///\t\tLocation to load from\n\t\t\t/// @param filePath\n\t\t\t///\t\tFile path to load from\n\t\t\t///\n\t\t\tvoid Load(ChilliSource::StorageLocation location, const std::string& filePath);\n\n\t\t\t/// Destroy the image data. If the data has already been destroyed then pass\n\t\t\t/// false to reset.\n\t\t\t///\n\t\t\t/// @param releaseData\n\t\t\t///\t\tTRUE to destroy the data, FALSE to simply reset\n\t\t\t///\n\t\t\tvoid Release(bool releaseData = true);\n\n\t\t\t/// @return TRUE if loaded\n\t\t\t///\n\t\t\tbool IsLoaded() const;\n\n\t\t\t/// @return Height of the image in pixels\n\t\t\t///\n\t\t\ts32 GetHeight() const;\n\n\t\t\t/// @return Width of the image in pixels\n\t\t\t///\n\t\t\ts32 GetWidth() const;\n\n\t\t\t/// @return Image data\n\t\t\t///\n\t\t\tu8 * GetImageData() const;\n\n\t\t\t/// @return Size of the image data in bytes\n\t\t\t///\n\t\t\tu32 GetDataSize() const;\n\n\t\t\t/// @retrun Format of the image\n\t\t\t///\n\t\t\tChilliSource::ImageFormat GetImageFormat() const;\n\n\t\tprotected:\n\t\t\t/// Load with lib png\n\t\t\t/// @param stream\n\t\t\t///\t\tThe stream lib png should use to read the data.\n\t\t\t///\n\t\t\t/// @return TRUE if successful\n\t\t\t///\n\t\t\tbool LoadWithLibPng(const ChilliSource::IBinaryInputStreamUPtr& stream);\n\n\t\t\tbool mbIsLoaded;\n\t\t\ts32 mdwHeight;\n\t\t\ts32 mdwWidth;\n\t\t\tu8 * mpData;\n\t\t\tChilliSource::ImageFormat m_format;\n\t\t\tu32 m_dataSize = 0;\n\t\t};\n\t}\n}\n\n#endif\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/RPi/ForwardDeclarations.h",
    "content": "//\r\n//  The MIT License (MIT)\r\n//\r\n//  Copyright (c) 2017 Tag Games Limited\r\n//\r\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\r\n//  of this software and associated documentation files (the \"Software\"), to deal\r\n//  in the Software without restriction, including without limitation the rights\r\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\n//  copies of the Software, and to permit persons to whom the Software is\r\n//  furnished to do so, subject to the following conditions:\r\n//\r\n//  The above copyright notice and this permission notice shall be included in\r\n//  all copies or substantial portions of the Software.\r\n//\r\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r\n//  THE SOFTWARE.\r\n//\r\n\r\n#ifdef CS_TARGETPLATFORM_RPI\r\n\r\n#ifndef _CSBACKEND_PLATFORM_RPI_FORWARDDECLARATION_H_\r\n#define _CSBACKEND_PLATFORM_RPI_FORWARDDECLARATION_H_\r\n\r\n#include <ChilliSource/Core/Base/StandardMacros.h>\r\n\r\n#include <memory>\r\n\r\nnamespace CSBackend\r\n{\r\n\tnamespace RPi\r\n\t{\r\n\t\t//------------------------------------------------------\r\n\t\t/// Core\r\n\t\t//------------------------------------------------------\r\n\t\tCS_FORWARDDECLARE_CLASS(PlatformSystem);\r\n\t\tCS_FORWARDDECLARE_CLASS(FileSystem);\r\n\t\tCS_FORWARDDECLARE_CLASS(PNGImageProvider);\r\n\t\tCS_FORWARDDECLARE_CLASS(PngImage);\r\n        CS_FORWARDDECLARE_CLASS(Screen);\r\n\t\t//------------------------------------------------------\r\n\t\t/// Input\r\n\t\t//------------------------------------------------------\r\n        CS_FORWARDDECLARE_CLASS(DeviceButtonSystem);\r\n        CS_FORWARDDECLARE_CLASS(GamepadSystem);\r\n\t\tCS_FORWARDDECLARE_CLASS(Keyboard);\r\n\t\tCS_FORWARDDECLARE_CLASS(PointerSystem);\r\n\t\tCS_FORWARDDECLARE_CLASS(TextEntry);\r\n\t\t//------------------------------------------------------\r\n\t\t/// Networking\r\n\t\t//------------------------------------------------------\r\n\t\tCS_FORWARDDECLARE_CLASS(HttpRequest);\r\n\t\tCS_FORWARDDECLARE_CLASS(HttpRequestSystem);\r\n\t}\r\n}\r\n\r\n#endif\r\n\r\n#endif\r\n"
  },
  {
    "path": "Source/CSBackend/Platform/RPi/Input/Gamepad/GamepadSystem.cpp",
    "content": "//\r\n//  The MIT License (MIT)\r\n//\r\n//  Copyright (c) 2017 Tag Games Limited\r\n//\r\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\r\n//  of this software and associated documentation files (the \"Software\"), to deal\r\n//  in the Software without restriction, including without limitation the rights\r\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\n//  copies of the Software, and to permit persons to whom the Software is\r\n//  furnished to do so, subject to the following conditions:\r\n//\r\n//  The above copyright notice and this permission notice shall be included in\r\n//  all copies or substantial portions of the Software.\r\n//\r\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r\n//  THE SOFTWARE.\r\n//\r\n\r\n#ifdef CS_TARGETPLATFORM_RPI\r\n\r\n#include <CSBackend/Platform/RPi/Input/Gamepad/GamepadSystem.h>\r\n\r\n#include <ChilliSource/Core/Math/MathUtils.h>\r\n\r\n#include <fcntl.h>\r\n#include <unistd.h>\r\n#include <libevdev/libevdev.h>\r\n#include <libudev.h>\r\n\r\n#include <array>\r\n#include <cstring>\r\n\r\nnamespace CSBackend\r\n{\r\n\tnamespace RPi\r\n\t{\r\n\t\tCS_DEFINE_NAMEDTYPE(GamepadSystem);\r\n\r\n\t\tnamespace\r\n\t\t{\r\n\t\t\t//Matches SFML on Windows\r\n\t\t\tconst std::array<int, 10> k_axes = {{ABS_X, ABS_Y, ABS_Z, ABS_THROTTLE, ABS_RZ, ABS_RUDDER, ABS_RX, ABS_RY, ABS_HAT0X, ABS_HAT0Y}};\n\r\n\t\t\t/// @param monitorFd\n\t\t\t///\t\tMonitor to check\n\t\t\t///\n\t\t\t/// @return TRUE if there is a new monitoring event meaning a new device has been connected\n\t\t\t///\n\t\t\tbool HasUdevMonitorEvent(int monitorFd)\n\t\t\t{\n\t\t\t\tfd_set descriptorSet;\n\t\t\t\tFD_ZERO(&descriptorSet);\n\t\t\t\tFD_SET(monitorFd, &descriptorSet);\n\t\t\t\ttimeval timeout = {0, 0};\n\n\t\t\t\treturn (select(monitorFd + 1, &descriptorSet, NULL, NULL, &timeout) > 0) && FD_ISSET(monitorFd, &descriptorSet);\n\t\t\t}\n\n\t\t\t/// @param device\n\t\t\t///\t\tDevice to check\n\t\t\t///\n\t\t\t/// @return TRUE if device is a joystick\n\t\t\t///\n\t\t\tbool IsDeviceJoystick(udev_device* device)\n\t\t\t{\n\t\t\t\tconst char* devnode = udev_device_get_devnode(device);\n\t\t\t\treturn devnode != nullptr && std::strstr(devnode, \"event\") != nullptr && udev_device_get_property_value(device, \"ID_INPUT_JOYSTICK\");\n\t\t\t}\n\t\t}\r\n\r\n        //------------------------------------------------------------------------------\r\n\t\tbool GamepadSystem::IsA(ChilliSource::InterfaceIDType interfaceId) const noexcept\r\n\t\t{\r\n\t\t\treturn (ChilliSource::GamepadSystem::InterfaceID == interfaceId || GamepadSystem::InterfaceID == interfaceId);\r\n\t\t}\r\n\r\n\t\t//------------------------------------------------------------------------------\r\n\t\tvoid GamepadSystem::OnInit() noexcept\r\n\t\t{\n\t\t\tstd::fill(std::begin(m_gamepadConnections), std::end(m_gamepadConnections), GamepadData());\r\n\r\n\t\t\tm_udev = udev_new();\r\n\t\t\tCS_RELEASE_ASSERT(m_udev != nullptr, \"Cannot create udev\");\r\n\r\n\t\t\tm_udevMonitor = udev_monitor_new_from_netlink(m_udev, \"udev\");\r\n\t\t\tCS_RELEASE_ASSERT(m_udevMonitor != nullptr, \"Cannot create udev monitor\");\r\n\r\n\t\t\tauto result = udev_monitor_filter_add_match_subsystem_devtype(m_udevMonitor, \"input\", NULL);\r\n\t\t\tCS_RELEASE_ASSERT(result >= 0, \"Failed to add udev monitor filter\");\r\n\r\n\t\t\t//Start listening for new  device connections - NOTE: Monitoring needs to be enabled before enumeration according to the manual\r\n\t\t\tudev_monitor_enable_receiving(m_udevMonitor);\r\n\t\t\tm_monitorFd = udev_monitor_get_fd(m_udevMonitor);\r\n\r\n\t\t\t//Check for already connected devices\r\n\t\t\tCheckForExistingGamepadConnections();\r\n\t\t}\r\n\r\n\t\t//------------------------------------------------------------------------------\r\n\t\tvoid GamepadSystem::OnUpdate(f32 timeSinceLastUpdate) noexcept\r\n\t\t{\r\n\t\t\tCheckForNewGamepadConnections();\r\n\r\n\t\t\tfor(u32 i=0; i<ChilliSource::Gamepad::k_maxGamepads; ++i)\r\n\t\t\t{\r\n\t\t\t\tif(m_gamepadConnections[i].m_dev == nullptr)\r\n\t\t\t\t\tcontinue;\r\n\r\n\t\t\t\tint eventResult = LIBEVDEV_READ_STATUS_SYNC;\r\n\t\t\t\tdo\r\n\t\t\t\t{\r\n\t\t\t\t\tinput_event ev;\r\n\t\t\t\t\teventResult = libevdev_next_event(m_gamepadConnections[i].m_dev, LIBEVDEV_READ_FLAG_NORMAL, &ev);\r\n\r\n\t\t\t\t\tif(eventResult == LIBEVDEV_READ_STATUS_SUCCESS)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tswitch(ev.type)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tcase EV_ABS:\r\n\t\t\t\t\t\t\t\tProcessAxisEvent(ev, m_gamepadConnections[i]);\r\n\t\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t\tcase EV_KEY:\r\n\t\t\t\t\t\t\t\tProcessButtonEvent(ev, m_gamepadConnections[i]);\r\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t\telse if(eventResult == -ENODEV)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t//We have lost connection to the device.\r\n\t\t\t\t\t\tAddGamepadRemoveEvent(m_gamepadConnections[i].m_uid);\r\n\t\t\t\t\t\tclose(m_gamepadConnections[i].m_fileDescriptor);\r\n\t\t\t\t\t\tm_gamepadConnections[i] = GamepadData();\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\twhile(eventResult == LIBEVDEV_READ_STATUS_SYNC || eventResult == LIBEVDEV_READ_STATUS_SUCCESS);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t//------------------------------------------------------------------------------\r\n\t\tvoid GamepadSystem::CheckForExistingGamepadConnections() noexcept\r\n\t\t{\r\n\t\t\tudev_enumerate* enumerator = udev_enumerate_new(m_udev);\r\n\t\t\tCS_RELEASE_ASSERT(enumerator != nullptr, \"Cannot create udev enumerator\");\r\n\t\t\tauto result = udev_enumerate_add_match_subsystem(enumerator, \"input\");\r\n\t\t\tCS_RELEASE_ASSERT(result >= 0, \"Failed to add filter to udev enumerator\");\r\n\t\t\tresult = udev_enumerate_scan_devices(enumerator);\r\n\t\t\tCS_RELEASE_ASSERT(result >= 0, \"Failed to scan udev for devices\");\r\n\r\n\t\t\tudev_list_entry* devices = udev_enumerate_get_list_entry(enumerator);\r\n\t\t\tudev_list_entry* deviceEntry;\r\n\t\t\tudev_list_entry_foreach(deviceEntry, devices)\r\n\t\t\t{\r\n\t\t\t\tconst char* sysPath = udev_list_entry_get_name(deviceEntry);\r\n\t\t\t\tudev_device* device = udev_device_new_from_syspath(m_udev, sysPath);\r\n\t\t\t\tif(device != nullptr)\r\n\t\t\t\t{\r\n\t\t\t\t\tTryAddGamepadDevice(device);\r\n\t\t\t\t\tudev_device_unref(device);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tudev_enumerate_unref(enumerator);\r\n\t\t}\r\n\r\n\t\t//------------------------------------------------------------------------------\r\n\t\tvoid GamepadSystem::CheckForNewGamepadConnections() noexcept\r\n\t\t{\r\n\t\t\t//Check for new events\r\n\t\t\tif(HasUdevMonitorEvent(m_monitorFd) == false)\r\n\t\t\t\treturn;\r\n\r\n\t\t\t//Check if the device causing the event is a gamepad\r\n\t\t\tudev_device* device = udev_monitor_receive_device(m_udevMonitor);\r\n\t\t\tif(device == nullptr)\r\n\t\t\t{\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\r\n\t\t\t//Check to make sure it is a connected event\r\n\t\t\tconst char* action = udev_device_get_action(device);\r\n\t\t\tif(std::strcmp(action, \"add\") != 0)\r\n\t\t\t{\r\n\t\t\t\tudev_device_unref(device);\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\r\n\t\t\tTryAddGamepadDevice(device);\r\n\t\t\tudev_device_unref(device);\r\n\t\t}\r\n\r\n\t\t//------------------------------------------------------------------------------\r\n\t\tbool GamepadSystem::TryAddGamepadDevice(udev_device* device) noexcept\r\n\t\t{\r\n\t\t\tif(IsDeviceJoystick(device) == false)\r\n\t\t\t{\r\n\t\t\t\treturn false;\r\n\t\t\t}\r\n\r\n\t\t\t//Check if we can accomodate new gamepads\r\n\t\t\ts32 freeIndex = -1;\r\n\t\t\tfor(s32 i=0; i<(s32)ChilliSource::Gamepad::k_maxGamepads; ++i)\r\n\t\t\t{\r\n\t\t\t\tif(m_gamepadConnections[i].m_dev == nullptr)\r\n\t\t\t\t{\r\n\t\t\t\t\tfreeIndex = i;\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\t//Too many gamepads\r\n\t\t\tif(freeIndex == -1)\r\n\t\t\t{\r\n\t\t\t\treturn false;\r\n\t\t\t}\r\n\r\n\t\t\t//Get the file that the kernel writes gamepad events to and hand it to evdev to poll\r\n\t\t\tconst char* devNode = udev_device_get_devnode(device);\r\n\t\t\tauto fileDescriptor = open(devNode, O_RDONLY|O_NONBLOCK);\r\n\r\n\t\t\tstruct libevdev* dev = nullptr;\r\n\t\t\tauto result = libevdev_new_from_fd(fileDescriptor, &dev);\r\n\t\t\tif(result < 0)\r\n\t\t\t{\r\n\t\t\t\tCS_LOG_ERROR_FMT(\"Failed to init gamepad libevdev: %d\\n\", result);\r\n\t\t\t\tif(fileDescriptor != -1)\r\n\t\t\t\t{\r\n\t\t\t\t\tclose(fileDescriptor);\r\n\t\t\t\t}\r\n\t\t\t\treturn false;\r\n\t\t\t}\r\n\r\n\t\t\tGamepadData data;\r\n\r\n\t\t\t//We get device name using this method so we match the SFML implementation on Windows\r\n\t\t\tudev_device* deviceParent = udev_device_get_parent_with_subsystem_devtype(device, \"usb\", \"usb_device\");\r\n \t\t\tstd::string deviceName = udev_device_get_sysattr_value(deviceParent, \"product\");\r\n\r\n\t\t\t//Num buttons\r\n\t\t\tu32 numButtons = 0;\r\n\t\t\tfor(u32 i=0; i<k_maxButtons; ++i)\r\n\t\t\t{\r\n\t\t\t\tif(libevdev_has_event_code(dev, EV_KEY, BTN_TRIGGER + i))\r\n\t\t\t\t{\r\n\t\t\t\t\tdata.m_buttonIndexMappings[i] = numButtons;\r\n\t\t\t\t\t++numButtons;\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t{\r\n\t\t\t\t\tdata.m_buttonIndexMappings[i] = -1;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\t//Supported axes\r\n\t\t\tu32 supportedAxisFlags = 0;\r\n\t\t\tfor(std::size_t i=0; i<k_axes.size(); ++i)\r\n\t\t\t{\r\n\t\t\t\tif(libevdev_has_event_code(dev, EV_ABS, k_axes[i]))\r\n\t\t\t\t{\r\n\t\t\t\t\tu32 axesIndex = 0;\r\n\r\n\t\t\t\t\tswitch(k_axes[i])\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tcase ABS_X:\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tdata.m_axisMinValues[(u32)ChilliSource::GamepadAxis::k_x] = libevdev_get_abs_minimum(dev, k_axes[i]);\r\n\t\t\t\t\t\t\tdata.m_axisMaxValues[(u32)ChilliSource::GamepadAxis::k_x] = libevdev_get_abs_maximum(dev, k_axes[i]);\r\n\t\t\t\t\t\t\tsupportedAxisFlags |= (1u << (u32)ChilliSource::GamepadAxis::k_x);\r\n\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tcase ABS_Y:\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tdata.m_axisMinValues[(u32)ChilliSource::GamepadAxis::k_y] = libevdev_get_abs_minimum(dev, k_axes[i]);\r\n\t\t\t\t\t\t\tdata.m_axisMaxValues[(u32)ChilliSource::GamepadAxis::k_y] = libevdev_get_abs_maximum(dev, k_axes[i]);\r\n\t\t\t\t\t\t\tsupportedAxisFlags |= (1u << (u32)ChilliSource::GamepadAxis::k_y);\r\n\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tcase ABS_Z:\r\n\t\t\t\t\t\t\t//Fallthrough\r\n\t\t\t\t\t\tcase ABS_THROTTLE:\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tdata.m_axisMinValues[(u32)ChilliSource::GamepadAxis::k_z] = libevdev_get_abs_minimum(dev, k_axes[i]);\r\n\t\t\t\t\t\t\tdata.m_axisMaxValues[(u32)ChilliSource::GamepadAxis::k_z] = libevdev_get_abs_maximum(dev, k_axes[i]);\r\n\t\t\t\t\t\t\tsupportedAxisFlags |= (1u << (u32)ChilliSource::GamepadAxis::k_z);\r\n\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tcase ABS_RZ:\r\n\t\t\t\t\t\t\t//Fallthrough\r\n\t\t\t\t\t\tcase ABS_RUDDER:\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tdata.m_axisMinValues[(u32)ChilliSource::GamepadAxis::k_r] = libevdev_get_abs_minimum(dev, k_axes[i]);\r\n\t\t\t\t\t\t\tdata.m_axisMaxValues[(u32)ChilliSource::GamepadAxis::k_r] = libevdev_get_abs_maximum(dev, k_axes[i]);\r\n\t\t\t\t\t\t\tsupportedAxisFlags |= (1u << (u32)ChilliSource::GamepadAxis::k_r);\r\n\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tcase ABS_RX:\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tdata.m_axisMinValues[(u32)ChilliSource::GamepadAxis::k_u] = libevdev_get_abs_minimum(dev, k_axes[i]);\r\n\t\t\t\t\t\t\tdata.m_axisMaxValues[(u32)ChilliSource::GamepadAxis::k_u] = libevdev_get_abs_maximum(dev, k_axes[i]);\r\n\t\t\t\t\t\t\tsupportedAxisFlags |= (1u << (u32)ChilliSource::GamepadAxis::k_u);\r\n\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tcase ABS_RY:\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tdata.m_axisMinValues[(u32)ChilliSource::GamepadAxis::k_v] = libevdev_get_abs_minimum(dev, k_axes[i]);\r\n\t\t\t\t\t\t\tdata.m_axisMaxValues[(u32)ChilliSource::GamepadAxis::k_v] = libevdev_get_abs_maximum(dev, k_axes[i]);\r\n\t\t\t\t\t\t\tsupportedAxisFlags |= (1u << (u32)ChilliSource::GamepadAxis::k_v);\r\n\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tcase ABS_HAT0X:\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tdata.m_axisMinValues[(u32)ChilliSource::GamepadAxis::k_povX] = libevdev_get_abs_minimum(dev, k_axes[i]);\r\n\t\t\t\t\t\t\tdata.m_axisMaxValues[(u32)ChilliSource::GamepadAxis::k_povX] = libevdev_get_abs_maximum(dev, k_axes[i]);\r\n\t\t\t\t\t\t\tsupportedAxisFlags |= (1u << (u32)ChilliSource::GamepadAxis::k_povX);\r\n\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tcase ABS_HAT0Y:\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tdata.m_axisMinValues[(u32)ChilliSource::GamepadAxis::k_povY] = libevdev_get_abs_minimum(dev, k_axes[i]);\r\n\t\t\t\t\t\t\tdata.m_axisMaxValues[(u32)ChilliSource::GamepadAxis::k_povY] = libevdev_get_abs_maximum(dev, k_axes[i]);\r\n\t\t\t\t\t\t\tsupportedAxisFlags |= (1u << (u32)ChilliSource::GamepadAxis::k_povY);\r\n\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tCS_LOG_VERBOSE_FMT(\"Gamepad Connected: %s\\n\", deviceName.c_str());\r\n\r\n\t\t\tdata.m_uid = AddGamepadCreateEvent(std::move(deviceName), numButtons, supportedAxisFlags);\r\n\t\t\tdata.m_fileDescriptor = fileDescriptor;\r\n\t\t\tdata.m_dev = dev;\r\n\t\t\tm_gamepadConnections[freeIndex] = std::move(data);\r\n\r\n\t\t\treturn true;\r\n\t\t}\r\n\r\n\t\t//------------------------------------------------------------------------------\r\n\t\tvoid GamepadSystem::ProcessAxisEvent(const input_event& ev, const GamepadData& gamepadData) noexcept\r\n\t\t{\r\n\t\t\ts32 axis = -1;\r\n\t\t\tswitch(ev.code)\r\n\t\t\t{\r\n\t\t\t\tcase ABS_X:\r\n\t\t\t\t\taxis = (s32)ChilliSource::GamepadAxis::k_x;\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase ABS_Y:\r\n\t\t\t\t\taxis = (s32)ChilliSource::GamepadAxis::k_y;\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase ABS_Z:\r\n\t\t\t\t\t//Fallthrough\r\n\t\t\t\tcase ABS_THROTTLE:\r\n\t\t\t\t\taxis = (s32)ChilliSource::GamepadAxis::k_z;\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase ABS_RZ:\r\n\t\t\t\t\t//Fallthrough\r\n\t\t\t\tcase ABS_RUDDER:\r\n\t\t\t\t\taxis = (s32)ChilliSource::GamepadAxis::k_r;\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase ABS_RX:\r\n\t\t\t\t\taxis = (s32)ChilliSource::GamepadAxis::k_u;\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase ABS_RY:\r\n\t\t\t\t\taxis = (s32)ChilliSource::GamepadAxis::k_v;\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase ABS_HAT0X:\r\n\t\t\t\t\taxis = (s32)ChilliSource::GamepadAxis::k_povX;\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase ABS_HAT0Y:\r\n\t\t\t\t\taxis = (s32)ChilliSource::GamepadAxis::k_povY;\r\n\t\t\t\t\tbreak;\r\n\t\t\t}\r\n\r\n\t\t\tif(axis >= 0)\r\n\t\t\t{\r\n\t\t\t\tf32 normalised = ChilliSource::MathUtils::ConvertRange((f32)ev.value, gamepadData.m_axisMinValues[axis], gamepadData.m_axisMaxValues[axis], -1.0f, 1.0f);\r\n\t\t\t\tCS_LOG_VERBOSE_FMT(\"%d %f\\n\", ev.value, normalised);\r\n\t\t\t\tAddAxisPositionChangedEvent(gamepadData.m_uid, (ChilliSource::GamepadAxis)axis, normalised);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t//------------------------------------------------------------------------------\r\n\t\tvoid GamepadSystem::ProcessButtonEvent(const input_event& ev, const GamepadData& gamepadData) noexcept\r\n\t\t{\r\n\t\t\ts32 index = (s32)ev.code - (s32)BTN_TRIGGER;\r\n\t\t\tif(index >= 0 && index < gamepadData.m_buttonIndexMappings.size())\r\n\t\t\t{\r\n\t\t\t\ts32 buttonIndex = gamepadData.m_buttonIndexMappings[index];\r\n\t\t\t\tif(buttonIndex >= 0)\r\n\t\t\t\t{\r\n\t\t\t\t\tAddButtonPressureChangedEvent(gamepadData.m_uid, (u32)buttonIndex, (f32)ev.value);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t//------------------------------------------------------------------------------\r\n\t\tvoid GamepadSystem::OnDestroy() noexcept\r\n\t\t{\r\n\t\t\tfor(auto gamepadData : m_gamepadConnections)\r\n\t\t\t{\r\n\t\t\t\tif(gamepadData.m_dev == nullptr)\r\n\t\t\t\t\tcontinue;\r\n\r\n\t\t\t\tlibevdev_free(gamepadData.m_dev);\r\n\t\t\t\tclose(gamepadData.m_fileDescriptor);\r\n\t\t\t}\r\n\r\n\t\t\tudev_monitor_unref(m_udevMonitor);\r\n\t\t\tudev_unref(m_udev);\r\n\t\t}\r\n\t}\r\n}\r\n\r\n#endif\r\n"
  },
  {
    "path": "Source/CSBackend/Platform/RPi/Input/Gamepad/GamepadSystem.h",
    "content": "//\r\n//  The MIT License (MIT)\r\n//\r\n//  Copyright (c) 2017 Tag Games Limited\r\n//\r\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\r\n//  of this software and associated documentation files (the \"Software\"), to deal\r\n//  in the Software without restriction, including without limitation the rights\r\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\n//  copies of the Software, and to permit persons to whom the Software is\r\n//  furnished to do so, subject to the following conditions:\r\n//\r\n//  The above copyright notice and this permission notice shall be included in\r\n//  all copies or substantial portions of the Software.\r\n//\r\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r\n//  THE SOFTWARE.\r\n//\r\n\r\n#ifdef CS_TARGETPLATFORM_RPI\r\n\r\n#ifndef _CSBACKEND_PLATFORM_RPI_INPUT_GAMEPAD_GAMEPADSYSTEM_H_\r\n#define _CSBACKEND_PLATFORM_RPI_INPUT_GAMEPAD_GAMEPADSYSTEM_H_\r\n\r\n#include <ChilliSource/ChilliSource.h>\r\n#include <CSBackend/Platform/RPi/ForwardDeclarations.h>\r\n#include <ChilliSource/Input/Gamepad/GamepadSystem.h>\r\n\r\n#include <array>\r\n\r\nstruct libevdev;\r\nstruct input_event;\r\nstruct udev;\r\nstruct udev_monitor;\r\nstruct udev_device;\r\n\r\nnamespace CSBackend\r\n{\r\n\tnamespace RPi\r\n\t{\r\n\t\t/// The Raspberry Pi backend for the gamepad system.\r\n\t\t/// Uses libudev to check for new devices and libevdev to\r\n\t\t/// query the input files for changes to buttons and axes\r\n        ///\r\n\t\tclass GamepadSystem final : public ChilliSource::GamepadSystem\r\n\t\t{\r\n\t\tpublic:\r\n\t\t\tCS_DECLARE_NAMEDTYPE(GamepadSystem);\r\n\r\n            ///\r\n            bool IsA(ChilliSource::InterfaceIDType interfaceId) const noexcept override;\r\n\r\n\r\n\t\tprivate:\r\n\t\t\tfriend class ChilliSource::GamepadSystem;\r\n\r\n\t\t\tstatic const u32 k_maxButtons = 32;\r\n\r\n\t\t\t/// Clusters the unique id of the gamepad, with the file it is streaming from\r\n\t\t\t/// and the event handler that is polling the file\r\n\t\t\t///\r\n\t\t\tstruct GamepadData\r\n\t\t\t{\r\n\t\t\t\tstd::array<s32, k_maxButtons> m_buttonIndexMappings;\r\n\t\t\t\tstd::array<f32, (u32)ChilliSource::GamepadAxis::k_total> m_axisMinValues;\r\n\t\t\t\tstd::array<f32, (u32)ChilliSource::GamepadAxis::k_total> m_axisMaxValues;\r\n\t\t\t\tChilliSource::Gamepad::Id m_uid = 0;\r\n\t\t\t\tlibevdev* m_dev = nullptr;\r\n\t\t\t\tint m_fileDescriptor = 0;\r\n\t\t\t};\r\n\r\n            ///\r\n\t\t\tGamepadSystem() = default;\r\n\r\n\t\t\t///\r\n\t\t\tvoid OnInit() noexcept override;\r\n\r\n\t\t\t/// Checks for gamepad connections and disconnections and\r\n\t\t\t/// updates attached gamepad states\r\n\t\t\t///\r\n\t\t\t/// @param timeSinceLastUpdate\r\n\t\t\t///\t\tTime in seconds since last update\r\n\t\t\t///\r\n\t\t\tvoid OnUpdate(f32 timeSinceLastUpdate) noexcept override;\r\n\r\n\t\t\t/// On Linux gamepads are handled as files. We check for existing joypad event files to grab the file descriptor\r\n\t\t\t/// we then store this and use evdev to poll for state changes every update\r\n\t\t\t///\r\n\t\t\tvoid CheckForExistingGamepadConnections() noexcept;\r\n\r\n\t\t\t/// On Linux gamepads are handled as files. We use udev to check for new devices and to grab the file descriptor\r\n\t\t\t/// we then store this and use evdev to poll for state changes every update\r\n\t\t\t///\r\n\t\t\tvoid CheckForNewGamepadConnections() noexcept;\r\n\r\n\t\t\t/// Attempt to add the given device (must not be nullptr) as a gamepad if it meets the gamepad\r\n\t\t\t/// criteria.\r\n\t\t\t///\r\n\t\t\t/// @param device\r\n\t\t\t///\t\tDevice to check and add if gamepad\r\n\t\t\t///\r\n\t\t\t/// @return TRUE if added\r\n\t\t\t///\r\n\t\t\tbool TryAddGamepadDevice(udev_device* device) noexcept;\r\n\r\n\t\t\t/// Process the axis moved event forwarding it to the main CS application\r\n\t\t\t///\r\n\t\t\t/// @param ev\r\n\t\t\t///\t\tlibevdev input event of type EV_ABS\r\n\t\t\t/// @param gamepadData\r\n\t\t\t///\t\tHolds the uid of the gamepad, used for communicating with CS and the max and min for axis conversion\r\n\t\t\t/// @param device\r\n\t\t\t///\t\tDevice that received the vent used to perform axis normalisation\r\n\t\t\t///\r\n\t\t\tvoid ProcessAxisEvent(const input_event& ev, const GamepadData& gamepadData) noexcept;\r\n\r\n\t\t\t/// Process the button pressure changed event forwarding it to the main CS application\r\n\t\t\t///\r\n\t\t\t/// @param ev\r\n\t\t\t///\t\tlibevdev input event of type EV_KEY\r\n\t\t\t/// @param gamepadData\r\n\t\t\t///\t\tHolds the uid of the gamepad, used for communicating with CS and the button mapping to CS index\r\n\t\t\t///\r\n\t\t\tvoid ProcessButtonEvent(const input_event& ev, const GamepadData& gamepadData) noexcept;\r\n\r\n\t\t\t/// Close any open file connections to input files\r\n\t\t\t///\r\n\t\t\tvoid OnDestroy() noexcept override;\r\n\r\n\t\t\tstd::array<GamepadData, ChilliSource::Gamepad::k_maxGamepads> m_gamepadConnections;\r\n\r\n\t\t\tudev* m_udev;\r\n\t\t\tudev_monitor* m_udevMonitor;\r\n\t\t\tint m_monitorFd = -1;\r\n\t\t};\r\n\t}\r\n}\r\n\r\n#endif\r\n\r\n#endif\r\n"
  },
  {
    "path": "Source/CSBackend/Platform/RPi/Input/Keyboard/Keyboard.cpp",
    "content": "//\r\n//  The MIT License (MIT)\r\n//\r\n//  Copyright (c) 2017 Tag Games Limited\r\n//\r\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\r\n//  of this software and associated documentation files (the \"Software\"), to deal\r\n//  in the Software without restriction, including without limitation the rights\r\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\n//  copies of the Software, and to permit persons to whom the Software is\r\n//  furnished to do so, subject to the following conditions:\r\n//\r\n//  The above copyright notice and this permission notice shall be included in\r\n//  all copies or substantial portions of the Software.\r\n//\r\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r\n//  THE SOFTWARE.\r\n//\r\n\r\n#ifdef CS_TARGETPLATFORM_RPI\r\n\r\n#include <CSBackend/Platform/RPi/Input/Keyboard/Keyboard.h>\r\n\r\n#include <ChilliSource/Core/Base/Application.h>\r\n#include <ChilliSource/Core/Delegate/MakeDelegate.h>\r\n#include <ChilliSource/Core/Threading/TaskScheduler.h>\r\n#include <ChilliSource/Input/Keyboard/KeyCode.h>\r\n#include <ChilliSource/Input/Keyboard/ModifierKeyCode.h>\r\n\r\nnamespace CSBackend\r\n{\r\n\tnamespace RPi\r\n\t{\r\n\t\tCS_DEFINE_NAMEDTYPE(Keyboard);\r\n\r\n\t\tnamespace\r\n\t\t{\r\n\t\t\tconst u32 k_x11keyCodesMap[(u32)ChilliSource::KeyCode::k_total] =\r\n\t\t\t{\r\n\t\t\t\tXK_VoidSymbol,\r\n\t\t\t\tXK_a,\r\n\t\t\t\tXK_b,\r\n\t\t\t\tXK_c,\r\n\t\t\t\tXK_d,\r\n\t\t\t\tXK_e,\r\n\t\t\t\tXK_f,\r\n\t\t\t\tXK_g,\r\n\t\t\t\tXK_h,\r\n\t\t\t\tXK_i,\r\n\t\t\t\tXK_j,\r\n\t\t\t\tXK_k,\r\n\t\t\t\tXK_l,\r\n\t\t\t\tXK_m,\r\n\t\t\t\tXK_n,\r\n\t\t\t\tXK_o,\r\n\t\t\t\tXK_p,\r\n\t\t\t\tXK_q,\r\n\t\t\t\tXK_r,\r\n\t\t\t\tXK_s,\r\n\t\t\t\tXK_t,\r\n\t\t\t\tXK_u,\r\n\t\t\t\tXK_v,\r\n\t\t\t\tXK_w,\r\n\t\t\t\tXK_x,\r\n\t\t\t\tXK_y,\r\n\t\t\t\tXK_z,\r\n\t\t\t\tXK_0,\r\n\t\t\t\tXK_1,\r\n\t\t\t\tXK_2,\r\n\t\t\t\tXK_3,\r\n\t\t\t\tXK_4,\r\n\t\t\t\tXK_5,\r\n\t\t\t\tXK_6,\r\n\t\t\t\tXK_7,\r\n\t\t\t\tXK_8,\r\n\t\t\t\tXK_9,\r\n\t\t\t\tXK_Escape,\r\n\t\t\t\tXK_Control_L,\r\n\t\t\t\tXK_Shift_L,\r\n\t\t\t\tXK_Alt_L,\r\n\t\t\t\tXK_Super_L,\r\n\t\t\t\tXK_Control_R,\r\n\t\t\t\tXK_Shift_R,\r\n\t\t\t\tXK_Alt_R,\r\n\t\t\t\tXK_Super_R,\r\n\t\t\t\tXK_Menu,\r\n\t\t\t\tXK_bracketleft,\r\n\t\t\t\tXK_bracketright,\r\n\t\t\t\tXK_semicolon,\r\n\t\t\t\tXK_comma,\r\n\t\t\t\tXK_period,\r\n\t\t\t\tXK_apostrophe,\r\n\t\t\t\tXK_slash,\r\n\t\t\t\tXK_backslash,\r\n\t\t\t\tXK_asciitilde,\r\n\t\t\t\tXK_equal,\r\n\t\t\t\tXK_minus,\r\n\t\t\t\tXK_space,\r\n\t\t\t\tXK_Return,\r\n\t\t\t\tXK_BackSpace,\r\n\t\t\t\tXK_Tab,\r\n\t\t\t\tXK_Page_Up,\r\n\t\t\t\tXK_Page_Down,\r\n\t\t\t\tXK_End,\r\n\t\t\t\tXK_Home,\r\n\t\t\t\tXK_Insert,\r\n\t\t\t\tXK_Delete,\r\n\t\t\t\tXK_KP_Add,\r\n\t\t\t\tXK_KP_Subtract,\r\n\t\t\t\tXK_KP_Multiply,\r\n\t\t\t\tXK_KP_Divide,\r\n\t\t\t\tXK_Left,\r\n\t\t\t\tXK_Right,\r\n\t\t\t\tXK_Up,\r\n\t\t\t\tXK_Down,\r\n\t\t\t\tXK_KP_Insert, //XK_KP_0\r\n\t\t\t\tXK_KP_End, //XK_KP_1\r\n\t\t\t\tXK_KP_Down, //XK_KP_1\r\n\t\t\t\tXK_KP_Page_Down, //XK_KP_1\r\n\t\t\t\tXK_KP_Left, //XK_KP_1\r\n\t\t\t\tXK_KP_Begin, //XK_KP_1\r\n\t\t\t\tXK_KP_Right, //XK_KP_1\r\n\t\t\t\tXK_KP_Home, //XK_KP_1\r\n\t\t\t\tXK_KP_Up, //XK_KP_1\r\n\t\t\t\tXK_KP_Page_Up, //XK_KP_1\r\n\t\t\t\tXK_F1,\r\n\t\t\t\tXK_F2,\r\n\t\t\t\tXK_F3,\r\n\t\t\t\tXK_F4,\r\n\t\t\t\tXK_F5,\r\n\t\t\t\tXK_F6,\r\n\t\t\t\tXK_F7,\r\n\t\t\t\tXK_F8,\r\n\t\t\t\tXK_F9,\r\n\t\t\t\tXK_F10,\r\n\t\t\t\tXK_F11,\r\n\t\t\t\tXK_F12,\r\n\t\t\t\tXK_F13,\r\n\t\t\t\tXK_F14,\r\n\t\t\t\tXK_F15,\r\n\t\t\t\tXK_Pause\r\n\t\t\t};\r\n\r\n\t\t\tconst ChilliSource::KeyCode k_csKeyCodesMap[(u32)ChilliSource::KeyCode::k_total] =\r\n\t\t\t{\r\n\t\t\t\tChilliSource::KeyCode::k_a,\r\n\t\t\t\tChilliSource::KeyCode::k_b,\r\n\t\t\t\tChilliSource::KeyCode::k_c,\r\n\t\t\t\tChilliSource::KeyCode::k_d,\r\n\t\t\t\tChilliSource::KeyCode::k_e,\r\n\t\t\t\tChilliSource::KeyCode::k_f,\r\n\t\t\t\tChilliSource::KeyCode::k_g,\r\n\t\t\t\tChilliSource::KeyCode::k_h,\r\n\t\t\t\tChilliSource::KeyCode::k_i,\r\n\t\t\t\tChilliSource::KeyCode::k_j,\r\n\t\t\t\tChilliSource::KeyCode::k_k,\r\n\t\t\t\tChilliSource::KeyCode::k_l,\r\n\t\t\t\tChilliSource::KeyCode::k_m,\r\n\t\t\t\tChilliSource::KeyCode::k_n,\r\n\t\t\t\tChilliSource::KeyCode::k_o,\r\n\t\t\t\tChilliSource::KeyCode::k_p,\r\n\t\t\t\tChilliSource::KeyCode::k_q,\r\n\t\t\t\tChilliSource::KeyCode::k_r,\r\n\t\t\t\tChilliSource::KeyCode::k_s,\r\n\t\t\t\tChilliSource::KeyCode::k_t,\r\n\t\t\t\tChilliSource::KeyCode::k_u,\r\n\t\t\t\tChilliSource::KeyCode::k_v,\r\n\t\t\t\tChilliSource::KeyCode::k_w,\r\n\t\t\t\tChilliSource::KeyCode::k_x,\r\n\t\t\t\tChilliSource::KeyCode::k_y,\r\n\t\t\t\tChilliSource::KeyCode::k_z,\r\n\t\t\t\tChilliSource::KeyCode::k_num0,\r\n\t\t\t\tChilliSource::KeyCode::k_num1,\r\n\t\t\t\tChilliSource::KeyCode::k_num2,\r\n\t\t\t\tChilliSource::KeyCode::k_num3,\r\n\t\t\t\tChilliSource::KeyCode::k_num4,\r\n\t\t\t\tChilliSource::KeyCode::k_num5,\r\n\t\t\t\tChilliSource::KeyCode::k_num6,\r\n\t\t\t\tChilliSource::KeyCode::k_num7,\r\n\t\t\t\tChilliSource::KeyCode::k_num8,\r\n\t\t\t\tChilliSource::KeyCode::k_num9,\r\n\t\t\t\tChilliSource::KeyCode::k_escape,\r\n\t\t\t\tChilliSource::KeyCode::k_leftCtrl,\r\n\t\t\t\tChilliSource::KeyCode::k_leftShift,\r\n\t\t\t\tChilliSource::KeyCode::k_leftAlt,\r\n\t\t\t\tChilliSource::KeyCode::k_leftSystem,\r\n\t\t\t\tChilliSource::KeyCode::k_rightCtrl,\r\n\t\t\t\tChilliSource::KeyCode::k_rightShift,\r\n\t\t\t\tChilliSource::KeyCode::k_rightAlt,\r\n\t\t\t\tChilliSource::KeyCode::k_rightSystem,\r\n\t\t\t\tChilliSource::KeyCode::k_menu,\r\n\t\t\t\tChilliSource::KeyCode::k_leftBracket,\r\n\t\t\t\tChilliSource::KeyCode::k_rightBracket,\r\n\t\t\t\tChilliSource::KeyCode::k_semiColon,\r\n\t\t\t\tChilliSource::KeyCode::k_comma,\r\n\t\t\t\tChilliSource::KeyCode::k_period,\r\n\t\t\t\tChilliSource::KeyCode::k_quote,\r\n\t\t\t\tChilliSource::KeyCode::k_forwardSlash,\r\n\t\t\t\tChilliSource::KeyCode::k_backSlash,\r\n\t\t\t\tChilliSource::KeyCode::k_tilde,\r\n\t\t\t\tChilliSource::KeyCode::k_equals,\r\n\t\t\t\tChilliSource::KeyCode::k_hyphen,\r\n\t\t\t\tChilliSource::KeyCode::k_space,\r\n\t\t\t\tChilliSource::KeyCode::k_return,\r\n\t\t\t\tChilliSource::KeyCode::k_backSpace,\r\n\t\t\t\tChilliSource::KeyCode::k_tab,\r\n\t\t\t\tChilliSource::KeyCode::k_pageUp,\r\n\t\t\t\tChilliSource::KeyCode::k_pageDown,\r\n\t\t\t\tChilliSource::KeyCode::k_end,\r\n\t\t\t\tChilliSource::KeyCode::k_home,\r\n\t\t\t\tChilliSource::KeyCode::k_insert,\r\n\t\t\t\tChilliSource::KeyCode::k_delete,\r\n\t\t\t\tChilliSource::KeyCode::k_add,\r\n\t\t\t\tChilliSource::KeyCode::k_subtract,\r\n\t\t\t\tChilliSource::KeyCode::k_multiply,\r\n\t\t\t\tChilliSource::KeyCode::k_divide,\r\n\t\t\t\tChilliSource::KeyCode::k_left,\r\n\t\t\t\tChilliSource::KeyCode::k_right,\r\n\t\t\t\tChilliSource::KeyCode::k_up,\r\n\t\t\t\tChilliSource::KeyCode::k_down,\r\n\t\t\t\tChilliSource::KeyCode::k_numpad0,\r\n\t\t\t\tChilliSource::KeyCode::k_numpad1,\r\n\t\t\t\tChilliSource::KeyCode::k_numpad2,\r\n\t\t\t\tChilliSource::KeyCode::k_numpad3,\r\n\t\t\t\tChilliSource::KeyCode::k_numpad4,\r\n\t\t\t\tChilliSource::KeyCode::k_numpad5,\r\n\t\t\t\tChilliSource::KeyCode::k_numpad6,\r\n\t\t\t\tChilliSource::KeyCode::k_numpad7,\r\n\t\t\t\tChilliSource::KeyCode::k_numpad8,\r\n\t\t\t\tChilliSource::KeyCode::k_numpad9,\r\n\t\t\t\tChilliSource::KeyCode::k_f1,\r\n\t\t\t\tChilliSource::KeyCode::k_f2,\r\n\t\t\t\tChilliSource::KeyCode::k_f3,\r\n\t\t\t\tChilliSource::KeyCode::k_f4,\r\n\t\t\t\tChilliSource::KeyCode::k_f5,\r\n\t\t\t\tChilliSource::KeyCode::k_f6,\r\n\t\t\t\tChilliSource::KeyCode::k_f7,\r\n\t\t\t\tChilliSource::KeyCode::k_f8,\r\n\t\t\t\tChilliSource::KeyCode::k_f9,\r\n\t\t\t\tChilliSource::KeyCode::k_f10,\r\n\t\t\t\tChilliSource::KeyCode::k_f11,\r\n\t\t\t\tChilliSource::KeyCode::k_f12,\r\n\t\t\t\tChilliSource::KeyCode::k_f13,\r\n\t\t\t\tChilliSource::KeyCode::k_f14,\r\n\t\t\t\tChilliSource::KeyCode::k_f15,\r\n\t\t\t\tChilliSource::KeyCode::k_pause\r\n\t\t\t};\r\n\t\t}\r\n\r\n\t\t/// Convert from CS key code to X11 keysym\r\n\t\t///\r\n\t\t/// @param CS key code\r\n\t\t///\r\n\t\t/// @return X11 keysym\r\n\t\t///\r\n\t\tu32 CSKeyCodeToX11KeySym(ChilliSource::KeyCode in_code)\r\n\t\t{\r\n\t\t\treturn k_x11keyCodesMap[(u32)in_code];\r\n\t\t}\r\n\r\n\t\t/// Convert from X11 keysym to CS key code\r\n\t\t///\r\n\t\t/// @param X11 keysym\r\n\t\t///\r\n\t\t/// @return CS key code\r\n\t\t///\r\n\t\tChilliSource::KeyCode X11KeySymToCSKeyCode(u32 in_keysym)\r\n\t\t{\r\n\t\t\tu32 foundKey = (u32)ChilliSource::KeyCode::k_total;\r\n\r\n\t\t\tfor(u32 keysymIndex = 1; keysymIndex < (u32)ChilliSource::KeyCode::k_total; keysymIndex++)\r\n\t\t\t{\r\n\t\t\t\tif(k_x11keyCodesMap[keysymIndex] == in_keysym)\r\n\t\t\t\t{\r\n\t\t\t\t\tfoundKey = keysymIndex - 1;\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tif (in_keysym == XK_VoidSymbol || foundKey >= (u32)ChilliSource::KeyCode::k_total)\r\n\t\t\t{\r\n\t\t\t\treturn ChilliSource::KeyCode::k_unknown;\r\n\t\t\t}\r\n\r\n\t\t\treturn k_csKeyCodesMap[(u32)foundKey];\r\n\t\t}\r\n\r\n\t\t//---------------------------------------------------------------------------------\r\n\t\tbool Keyboard::IsA(ChilliSource::InterfaceIDType interfaceId) const\r\n\t\t{\r\n\t\t\treturn (ChilliSource::Keyboard::InterfaceID == interfaceId || Keyboard::InterfaceID == interfaceId);\r\n\t\t}\r\n\r\n\t\t//---------------------------------------------------------------------------------\r\n\t\tChilliSource::IConnectableEvent<Keyboard::KeyPressedDelegate>& Keyboard::GetKeyPressedEvent()\r\n\t\t{\r\n\t\t\treturn m_keyPressedEvent;\r\n\t\t}\r\n\r\n\t\t//---------------------------------------------------------------------------------\r\n\t\tChilliSource::IConnectableEvent<Keyboard::KeyReleasedDelegate>& Keyboard::GetKeyReleasedEvent()\r\n\t\t{\r\n\t\t\treturn m_keyReleasedEvent;\r\n\t\t}\r\n\r\n\t\t//---------------------------------------------------------------------------------\r\n\t\tvoid Keyboard::OnInit() noexcept\r\n\t\t{\r\n\t\t\t// Clear all key states\r\n\t\t\tfor(auto& flag : m_keysDown)\r\n\t\t\t{\r\n\t\t\t\tflag = false;\r\n\t\t\t}\r\n\r\n\t\t\tDispmanWindow::Get()->SetKeyboardDelegates(ChilliSource::MakeDelegate(this, &Keyboard::OnKeyEvent));\r\n\t\t}\r\n\r\n\t\t//-------------------------------------------------------\r\n\t\tbool Keyboard::IsKeyDown(ChilliSource::KeyCode in_code) const\r\n\t\t{\r\n\t\t\tCS_ASSERT(ChilliSource::Application::Get()->GetTaskScheduler()->IsMainThread(), \"Attempted to access held keys outside of the main thread.\");\r\n\t\t\treturn m_keysDown[static_cast<u32>(in_code)];\r\n\t\t}\r\n\r\n\t\t//----------------------------------------------------------------------------------\r\n\t\tvoid Keyboard::OnKeyEvent(u32 keyCode, u32 keyState, DispmanWindow::KeyboardEvent keyEvent) noexcept\r\n\t\t{\r\n\t\t\tChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_mainThread, [=](const ChilliSource::TaskContext& context)\r\n\t\t\t{\r\n\t\t\t\tauto csKeyCode = X11KeySymToCSKeyCode(keyCode);\r\n\r\n\t\t\t\tif(keyEvent == DispmanWindow::KeyboardEvent::k_pressed)\r\n\t\t\t\t{\r\n\t\t\t\t\tif (IsKeyDown(csKeyCode) == false)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tm_keysDown[static_cast<u32>(csKeyCode)] = true;\r\n\r\n\t\t\t\t\t\tstd::vector<ChilliSource::ModifierKeyCode> modifiers;\r\n\t\t\t\t\t\tmodifiers.reserve((u32)ChilliSource::ModifierKeyCode::k_total);\r\n\r\n\t\t\t\t\t\tif (keyState & Mod1Mask)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tmodifiers.push_back(ChilliSource::ModifierKeyCode::k_alt);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tif (keyState & ControlMask)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tmodifiers.push_back(ChilliSource::ModifierKeyCode::k_ctrl);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tif (keyState & ShiftMask)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tmodifiers.push_back(ChilliSource::ModifierKeyCode::k_shift);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tif (keyState & Mod4Mask)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tmodifiers.push_back(ChilliSource::ModifierKeyCode::k_system);\r\n\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\tm_keyPressedEvent.NotifyConnections(csKeyCode, std::move(modifiers));\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\telse if (IsKeyDown(csKeyCode) == true)\r\n\t\t\t\t{\r\n\t\t\t\t\tm_keysDown[static_cast<u32>(csKeyCode)] = false;\r\n\r\n\t\t\t\t\tm_keyReleasedEvent.NotifyConnections(csKeyCode);\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\t//---------------------------------------------------------------------------------\r\n\t\tvoid Keyboard::OnDestroy() noexcept\r\n\t\t{\r\n\t\t\tDispmanWindow::Get()->RemoveKeyboardDelegates();\r\n\t\t}\r\n\t}\r\n}\r\n\r\n#endif\r\n"
  },
  {
    "path": "Source/CSBackend/Platform/RPi/Input/Keyboard/Keyboard.h",
    "content": "//\r\n//  The MIT License (MIT)\r\n//\r\n//  Copyright (c) 2017 Tag Games Limited\r\n//\r\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\r\n//  of this software and associated documentation files (the \"Software\"), to deal\r\n//  in the Software without restriction, including without limitation the rights\r\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\n//  copies of the Software, and to permit persons to whom the Software is\r\n//  furnished to do so, subject to the following conditions:\r\n//\r\n//  The above copyright notice and this permission notice shall be included in\r\n//  all copies or substantial portions of the Software.\r\n//\r\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r\n//  THE SOFTWARE.\r\n//\r\n\r\n#ifdef CS_TARGETPLATFORM_RPI\r\n\r\n#ifndef _CSBACKEND_PLATFORM_RPI_INPUT_KEYBOARD_KEYBOARD_H_\r\n#define _CSBACKEND_PLATFORM_RPI_INPUT_KEYBOARD_KEYBOARD_H_\r\n\r\n#include <ChilliSource/ChilliSource.h>\r\n#include <CSBackend/Platform/RPi/ForwardDeclarations.h>\r\n#include <ChilliSource/Input/Keyboard/Keyboard.h>\r\n#include <ChilliSource/Input/Keyboard/KeyCode.h>\r\n#include <CSBackend/Platform/RPi/Core/Base/DispmanWindow.h>\r\n#include <X11/keysym.h>\r\n\r\nnamespace CSBackend\r\n{\r\n\tnamespace RPi\r\n\t{\r\n        /// A system for receiving input from the current keyboard via X11\r\n        ///\r\n        /// The methods in this class are not thread-safe and must be\r\n        /// accessed from the main thread.\r\n        ///\r\n\t\tclass Keyboard final : public ChilliSource::Keyboard\r\n\t\t{\r\n\t\tpublic:\r\n            CS_DECLARE_NAMEDTYPE(Keyboard);\r\n\r\n\t\t\t/// Queries whether or not this system implements the\r\n\t\t\t/// interface with the given Id.\r\n\t\t\t///\r\n\t\t\t/// @param interfaceId\r\n\t\t\t///\t\tThe id of the interface that we need to check if this system implements\r\n\t\t\t///\r\n\t\t\t/// @retrun TRUE if the system 'IsA' interface\r\n\t\t\t///\r\n\t\t\tbool IsA(ChilliSource::InterfaceIDType interfaceId) const override;\r\n\t\t\t\r\n\t\t\t/// @param code\r\n\t\t\t///\t\tCode of the key to check if down\r\n\t\t\t///\r\n\t\t\t/// @return TRUE if the given key is currently down.\r\n\t\t\t/// This is unbuffered so only checks the status of the key at the moment the function is called\r\n\t\t\t///\r\n\t\t\tbool IsKeyDown(ChilliSource::KeyCode code) const override;\r\n\r\n\t\t\t/// This event is guaranteed and should be used for low\r\n\t\t\t/// frequency events such as catching a confirm enter press.\r\n\t\t\t/// The polling \"IsDown\" method should be used for realtime\r\n\t\t\t/// events such as moving characters on arrow press, etc.\r\n\t\t\t///\r\n\t\t\t/// The event also returns the current state of the modifier\r\n\t\t\t/// keys (Ctrl, Alt, Shift, etc.)\r\n\t\t\t///\r\n\t\t\t/// @return Event to register for key presses\r\n\t\t\t///\r\n\t\t\tChilliSource::IConnectableEvent<KeyPressedDelegate>& GetKeyPressedEvent() override;\r\n\r\n\t\t\t/// This event is guaranteed and should be used for low\r\n\t\t\t/// frequency events. The polling \"IsUp\" method should be\r\n\t\t\t/// used for realtime events.\r\n\t\t\t///\r\n\t\t\t/// @return Event to register for key releases\r\n\t\t\t///\r\n\t\t\tChilliSource::IConnectableEvent<KeyReleasedDelegate>& GetKeyReleasedEvent() override;\r\n\r\n        private:\r\n\r\n\t\t\tfriend ChilliSource::KeyboardUPtr ChilliSource::Keyboard::Create();\r\n\r\n\t\t\t///\r\n\t\t\tKeyboard() = default;\r\n\r\n\t\t\t/// Starts listening for keyboard events.\r\n\t\t\t///\r\n\t\t\tvoid OnInit() noexcept override;\r\n\r\n\t\t\t/// Called when a keyboard event is generated by X11.\r\n\t\t\t///\r\n\t\t\tvoid OnKeyEvent(u32 keyCode, u32 keyState, DispmanWindow::KeyboardEvent keyEvent) noexcept;\r\n\r\n\t\t\t/// Stop listening for keyboard events\r\n\t\t\t///\r\n\t\t\tvoid OnDestroy() noexcept override;\r\n\r\n\r\n\t\tprivate:\r\n\r\n\t\t\tChilliSource::Event<KeyPressedDelegate> m_keyPressedEvent;\r\n\t\t\tChilliSource::Event<KeyReleasedDelegate> m_keyReleasedEvent;\r\n\r\n\t\t\tstd::array<bool, static_cast<u32>(ChilliSource::KeyCode::k_total)> m_keysDown;\r\n\t\t};\r\n\t}\r\n}\r\n\r\n#endif\r\n\r\n#endif\r\n"
  },
  {
    "path": "Source/CSBackend/Platform/RPi/Input/Pointer/PointerSystem.cpp",
    "content": "//\r\n//  The MIT License (MIT)\r\n//\r\n//  Copyright (c) 2017 Tag Games Limited\r\n//\r\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\r\n//  of this software and associated documentation files (the \"Software\"), to deal\r\n//  in the Software without restriction, including without limitation the rights\r\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\n//  copies of the Software, and to permit persons to whom the Software is\r\n//  furnished to do so, subject to the following conditions:\r\n//\r\n//  The above copyright notice and this permission notice shall be included in\r\n//  all copies or substantial portions of the Software.\r\n//\r\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r\n//  THE SOFTWARE.\r\n//\r\n\r\n#ifdef CS_TARGETPLATFORM_RPI\r\n\r\n#include <CSBackend/Platform/RPi/Input/Pointer/PointerSystem.h>\r\n\r\n#include <ChilliSource/Core/Base/Application.h>\r\n#include <ChilliSource/Core/Threading/TaskScheduler.h>\r\n#include <ChilliSource/Core/Delegate/MakeDelegate.h>\r\n\r\nnamespace CSBackend\r\n{\r\n\tnamespace RPi\r\n\t{\r\n\t\tnamespace\r\n\t\t{\r\n\t\t\t/// @param button\r\n\t\t\t///\t\tThe X11 button ID.\r\n\t\t\t///\r\n\t\t\t/// @return The equivelent Press Type for the button Id\r\n\t\t\t///\r\n\t\t\tChilliSource::Pointer::InputType ButtonIdToInputType(u32 button)\r\n\t\t\t{\r\n\t\t\t\tswitch (button)\r\n\t\t\t\t{\r\n\t\t\t\tcase 1:\r\n\t\t\t\t\treturn ChilliSource::Pointer::InputType::k_leftMouseButton;\r\n\t\t\t\tcase 2:\r\n\t\t\t\t\treturn ChilliSource::Pointer::InputType::k_middleMouseButton;\r\n\t\t\t\tcase 3:\r\n\t\t\t\t\treturn ChilliSource::Pointer::InputType::k_rightMouseButton;\r\n\t\t\t\tdefault:\r\n\t\t\t\t\treturn ChilliSource::Pointer::InputType::k_none;\r\n\t\t\t\t}\r\n\r\n\t\t\t\treturn ChilliSource::Pointer::InputType::k_none;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tCS_DEFINE_NAMEDTYPE(PointerSystem);\r\n\r\n\t\t//---------------------------------------------------------------------------------\r\n\t\tbool PointerSystem::IsA(ChilliSource::InterfaceIDType interfaceId) const noexcept\r\n\t\t{\r\n\t\t\treturn (ChilliSource::PointerSystem::InterfaceID == interfaceId || PointerSystem::InterfaceID == interfaceId);\r\n\t\t}\r\n\r\n\t\t//---------------------------------------------------------------------------------\r\n\t\tvoid PointerSystem::OnInit() noexcept\r\n\t\t{\r\n\t\t\tm_screen = ChilliSource::Application::Get()->GetSystem<ChilliSource::Screen>();\r\n\t\t\tCS_ASSERT(m_screen != nullptr, \"Cannot find system required by PointerSystem: Screen.\");\r\n\r\n\t\t\tauto screenResolution = m_screen->GetResolution();\r\n\r\n\t\t\t//TODO:check for mouse and only create when one is found.\r\n\r\n\t\t\tDispmanWindow::Get()->SetMouseDelegates(ChilliSource::MakeDelegate(this, &PointerSystem::OnMouseButtonEvent), ChilliSource::MakeDelegate(this, &PointerSystem::OnMouseMoved));\r\n\r\n\t\t\t//create the mouse pointer\r\n\t\t\tChilliSource::Integer2 mousePosi = DispmanWindow::Get()->GetMousePosition();\r\n\t\t\tChilliSource::Vector2 mousePos((f32)mousePosi.x, screenResolution.y - (f32)mousePosi.y);\r\n\r\n\t\t\tm_pointerId = AddPointerCreateEvent(mousePos);\r\n\t\t}\r\n\r\n\t\t//---------------------------------------------------------------------------------\r\n\t\tvoid PointerSystem::OnMouseButtonEvent(u32 button, DispmanWindow::MouseButtonEvent event) noexcept\r\n\t\t{\r\n\t\t\t//In X11 the scroll wheel acts like a button getting pressed events for each tick\r\n\t\t\tswitch(button)\r\n\t\t\t{\r\n\t\t\t\tcase 4:\r\n\t\t\t\t\tAddPointerScrollEvent(m_pointerId, ChilliSource::Vector2(0.0f, 1.0f));\r\n\t\t\t\t\treturn;\r\n\t\t\t\tcase 5:\r\n\t\t\t\t\tAddPointerScrollEvent(m_pointerId, ChilliSource::Vector2(0.0f, -1.0f));\r\n\t\t\t\t\treturn;\r\n\t\t\t}\r\n\r\n\t\t\t//If the button isn't one the scroll buttons then we are into regular button logic\r\n\t\t\tChilliSource::Pointer::InputType type = ButtonIdToInputType(button);\r\n\t\t\tif (type == ChilliSource::Pointer::InputType::k_none)\r\n\t\t\t{\r\n\t\t\t\tCS_LOG_WARNING_FMT(\"Unknown X11 mouse button: %d\\n\", button);\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\r\n\t\t\tswitch (event)\r\n\t\t\t{\r\n\t\t\tcase DispmanWindow::MouseButtonEvent::k_pressed:\r\n\t\t\t\tAddPointerDownEvent(m_pointerId, type);\r\n\t\t\t\tbreak;\r\n\t\t\tcase DispmanWindow::MouseButtonEvent::k_released:\r\n\t\t\t\tAddPointerUpEvent(m_pointerId, type);\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t//---------------------------------------------------------------------------------\r\n\t\tvoid PointerSystem::OnMouseMoved(s32 xPos, s32 yPos) noexcept\r\n\t\t{\r\n\t\t\tChilliSource::Vector2 touchLocation((f32)xPos, m_screen->GetResolution().y - (f32)yPos);\r\n\t\t\tAddPointerMovedEvent(m_pointerId, touchLocation);\r\n\t\t}\r\n\r\n\t\t//---------------------------------------------------------------------------------\r\n\t\tvoid PointerSystem::OnDestroy() noexcept\r\n\t\t{\r\n\t\t\tAddPointerRemoveEvent(m_pointerId);\r\n\r\n\t\t\tDispmanWindow::Get()->RemoveMouseDelegates();\r\n\r\n\t\t\tm_screen = nullptr;\r\n\t\t}\r\n\t}\r\n}\r\n\r\n#endif\r\n"
  },
  {
    "path": "Source/CSBackend/Platform/RPi/Input/Pointer/PointerSystem.h",
    "content": "//\r\n//  The MIT License (MIT)\r\n//\r\n//  Copyright (c) 2017 Tag Games Limited\r\n//\r\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\r\n//  of this software and associated documentation files (the \"Software\"), to deal\r\n//  in the Software without restriction, including without limitation the rights\r\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\n//  copies of the Software, and to permit persons to whom the Software is\r\n//  furnished to do so, subject to the following conditions:\r\n//\r\n//  The above copyright notice and this permission notice shall be included in\r\n//  all copies or substantial portions of the Software.\r\n//\r\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r\n//  THE SOFTWARE.\r\n//\r\n\r\n#ifdef CS_TARGETPLATFORM_RPI\r\n\r\n#ifndef _CSBACKEND_PLATFORM_RPI_INPUT_POINTER_POINTERSYSTEM_H_\r\n#define _CSBACKEND_PLATFORM_RPI_INPUT_POINTER_POINTERSYSTEM_H_\r\n\r\n#include <ChilliSource/ChilliSource.h>\r\n#include <CSBackend/Platform/RPi/ForwardDeclarations.h>\r\n#include <ChilliSource/Input/Pointer/PointerSystem.h>\r\n#include <CSBackend/Platform/RPi/Core/Base/DispmanWindow.h>\r\n\r\nnamespace CSBackend\r\n{\r\n\tnamespace RPi\r\n\t{\r\n\t\t/// Raspberry Pi mouse/pointer system. Access information on mouse state\r\n\t\t/// and location from X11\r\n\t\t///\r\n\t\t/// The methods in this class are not thread-safe and must be\r\n\t\t/// accessed from the main thread.\r\n\t\t///\r\n\t\tclass PointerSystem final : public ChilliSource::PointerSystem\r\n\t\t{\r\n\t\tpublic:\r\n\t\t\tCS_DECLARE_NAMEDTYPE(PointerSystem);\r\n\r\n\t\t\t/// Queries whether or not this system implements the\r\n\t\t\t/// interface with the given Id.\r\n\t\t\t///\r\n\t\t\t/// @param interfaceId\r\n\t\t\t///\t\tThe id of the interface that we need to check if this system implements\r\n\t\t\t///\r\n\t\t\t/// @retrun TRUE if the system 'IsA' interface\r\n\t\t\t///\r\n\t\t\tbool IsA(ChilliSource::InterfaceIDType interfaceId) const noexcept override;\r\n\r\n\t\t\t/// As X11 is behind the GL display our RPi implementation has no mouse cursor\r\n\t\t\t///\r\n\t\t\tvoid HideSystemCursor() noexcept override {}\r\n\r\n\t\t\t/// As X11 is behind the GL display our RPi implementation has no mouse cursor\r\n\t\t\t///\r\n\t\t\tvoid ShowSystemCursor() noexcept override {}\r\n\r\n\t\tprivate:\r\n\t\t\tfriend class ChilliSource::PointerSystem;\r\n\r\n\t\t\t///\r\n\t\t\tPointerSystem() = default;\r\n\r\n\t\t\t/// Starts listening for mouse events\r\n\t\t\t///\r\n\t\t\tvoid OnInit() noexcept override;\r\n\r\n\t\t\t/// @param xPos\r\n\t\t\t///\t\tCurrent position X in window coords\r\n\t\t\t/// @param yPos\r\n\t\t\t///\t\tCurrent position Y in window coords\r\n\t\t\t///\r\n\t\t\tvoid OnMouseMoved(s32 xPos, s32 yPos) noexcept;\r\n\r\n\t\t\t/// @param button\r\n\t\t\t///\t\tButton ID\r\n\t\t\t/// @param event\r\n\t\t\t///\t\tButton action (Press/Release)\r\n\t\t\t///\r\n\t\t\tvoid OnMouseButtonEvent(u32 button, DispmanWindow::MouseButtonEvent event) noexcept;\r\n\r\n\t\t\t/// @param delta\r\n\t\t\t///\t\tNumber of ticks scrolled in the y-axis\r\n\t\t\t///\r\n\t\t\tvoid OnMouseWheeled(s32 delta) noexcept;\r\n\r\n\t\t\t/// Stop listening for mouse events\r\n\t\t\t///\r\n\t\t\tvoid OnDestroy() noexcept override;\r\n\r\n\t\t\tChilliSource::Screen* m_screen;\r\n\t\t\tChilliSource::Pointer::Id m_pointerId;\r\n\t\t};\r\n\t}\r\n}\r\n\r\n#endif\r\n\r\n#endif\r\n"
  },
  {
    "path": "Source/CSBackend/Platform/RPi/Input/TextEntry/TextEntry.cpp",
    "content": "//\r\n//  The MIT License (MIT)\r\n//\r\n//  Copyright (c) 2017 Tag Games Limited\r\n//\r\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\r\n//  of this software and associated documentation files (the \"Software\"), to deal\r\n//  in the Software without restriction, including without limitation the rights\r\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\n//  copies of the Software, and to permit persons to whom the Software is\r\n//  furnished to do so, subject to the following conditions:\r\n//\r\n//  The above copyright notice and this permission notice shall be included in\r\n//  all copies or substantial portions of the Software.\r\n//\r\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r\n//  THE SOFTWARE.\r\n//\r\n\r\n#ifdef CS_TARGETPLATFORM_RPI\r\n\r\n#include <CSBackend/Platform/RPi/Input/TextEntry/TextEntry.h>\r\n\r\n#include <ChilliSource/Core/Base/Application.h>\r\n#include <ChilliSource/Core/Delegate/MakeDelegate.h>\r\n#include <ChilliSource/Core/Threading/TaskScheduler.h>\r\n#include <CSBackend/Platform/RPi/Core/Base/DispmanWindow.h>\r\n\r\n#include <X11/keysym.h>\r\n\r\nnamespace CSBackend\r\n{\r\n\tnamespace RPi\r\n\t{\r\n\t\tCS_DEFINE_NAMEDTYPE(TextEntry);\r\n\r\n\t\t//----------------------------------------------------------------------------------\r\n\t\tbool TextEntry::IsA(ChilliSource::InterfaceIDType interfaceId) const noexcept\r\n\t\t{\r\n\t\t\treturn interfaceId == ChilliSource::TextEntry::InterfaceID || interfaceId == TextEntry::InterfaceID;\r\n\t\t}\r\n\r\n\t\t//----------------------------------------------------------------------------------\r\n\t\tvoid TextEntry::Activate(const std::string& text, ChilliSource::TextEntryType type, ChilliSource::TextEntryCapitalisation capitalisation, const TextBufferChangedDelegate& changeDelegate, const TextInputDeactivatedDelegate& deactivateDelegate) noexcept\r\n\t\t{\r\n            CS_ASSERT(ChilliSource::Application::Get()->GetTaskScheduler()->IsMainThread(), \"Cannot activate system text entry outside of main thread.\");\r\n            CS_ASSERT(!m_active, \"Cannot activate TextEntry system while already active.\");\r\n\r\n            m_active = true;\r\n\t\t\tm_text = text;\r\n\t\t\tm_textBufferChangedDelegate = changeDelegate;\r\n\t\t\tm_textInputDeactivatedDelegate = deactivateDelegate;\r\n\t\t\tDispmanWindow::Get()->SetTextEntryDelegates(ChilliSource::MakeDelegate(this, &TextEntry::OnTextEntered));\r\n\t\t}\r\n\r\n\t\t//----------------------------------------------------------------------------------\r\n        void TextEntry::Deactivate() noexcept\r\n        {\r\n            CS_ASSERT(ChilliSource::Application::Get()->GetTaskScheduler()->IsMainThread(), \"Cannot deactivate system text entry outside of main thread.\");\r\n            CS_ASSERT(m_active, \"Cannot deactivate TextEntry system when not active.\");\r\n\r\n\t\t\tDispmanWindow::Get()->RemoveTextEntryDelegates();\r\n\r\n            m_active = false;\r\n\r\n            if (m_textInputDeactivatedDelegate != nullptr)\r\n            {\r\n                auto delegate = m_textInputDeactivatedDelegate;\r\n                m_textInputDeactivatedDelegate = nullptr;\r\n                delegate();\r\n            }\r\n\t\t}\r\n\r\n\t\t//----------------------------------------------------------------------------------\r\n        const std::string& TextEntry::GetTextBuffer() const noexcept\r\n        {\r\n            CS_ASSERT(ChilliSource::Application::Get()->GetTaskScheduler()->IsMainThread(), \"Cannot get system text entry buffer outside of main thread.\");\r\n            return m_text;\r\n        }\r\n\r\n\t\t//----------------------------------------------------------------------------------\r\n        void TextEntry::SetTextBuffer(const std::string& text) noexcept\r\n        {\r\n            CS_ASSERT(ChilliSource::Application::Get()->GetTaskScheduler()->IsMainThread(), \"Cannot set system text entry buffer outside of main thread.\");\r\n            m_text = text;\r\n        }\r\n\r\n\t\t//----------------------------------------------------------------------------------\r\n        void TextEntry::OnTextEntered(ChilliSource::UTF8Char character) noexcept\r\n        {\r\n            ChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_mainThread, [=](const ChilliSource::TaskContext& taskContext)\r\n            {\r\n                std::unique_lock<std::mutex> lock(m_mutex);\r\n\r\n                std::string text;\r\n\r\n\t\t\t\tconst ChilliSource::UTF8Char k_backspace = 8;\r\n                if (character != k_backspace)\r\n                {\r\n                    text = ChilliSource::UTF8StringUtils::AppendCopy(character, m_text);\r\n                }\r\n                else\r\n                {\r\n                    s32 length = (s32)ChilliSource::UTF8StringUtils::CalcLength(m_text.begin(), m_text.end());\r\n                    length = std::max(length - 1, 0);\r\n                    text = ChilliSource::UTF8StringUtils::SubString(m_text, 0, (u32)length);\r\n                }\r\n\r\n                bool acceptText = true;\r\n\r\n                if (m_textBufferChangedDelegate != nullptr)\r\n                {\r\n                    acceptText = m_textBufferChangedDelegate(text);\r\n                }\r\n\r\n                if (acceptText == true)\r\n                {\r\n                    m_text = std::move(text);\r\n                }\r\n            });\r\n        }\r\n\t}\r\n}\r\n\r\n#endif\r\n"
  },
  {
    "path": "Source/CSBackend/Platform/RPi/Input/TextEntry/TextEntry.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2017 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_RPI\n\n#ifndef _CSBACKEND_PLATFORM_RPI_INPUT_TEXTENTRY_TEXTENTRY_H_\n#define _CSBACKEND_PLATFORM_RPI_INPUT_TEXTENTRY_TEXTENTRY_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Event/EventConnection.h>\n#include <ChilliSource/Core/String/UTF8StringUtils.h>\n#include <ChilliSource/Input/TextEntry/TextEntry.h>\n#include <ChilliSource/Input/TextEntry/TextEntryCapitalisation.h>\n#include <ChilliSource/Input/TextEntry/TextEntryType.h>\n#include <CSBackend/Platform/RPi/ForwardDeclarations.h>\n\n#include <mutex>\n\nnamespace CSBackend\n{\n\tnamespace RPi\n\t{\n        /// The Raspberry Pi backend to the text entry system. Listens to X keyboard events\n\t\t/// and builds a buffer of text input.\n\t\t///\n\t\t/// NOTE: Does not use any of the capitalisation policies.\n        ///\n        /// The methods in this class are not thread-safe and must be called\n        /// from the main thread.\n        ///\n\t\tclass TextEntry final : public ChilliSource::TextEntry\n\t\t{\n\t\tpublic:\n\t\t\tCS_DECLARE_NAMEDTYPE(TextEntry);\n\n\t\t\t/// @param interfaceId\n\t\t\t///\t\t\tId of the interface that we wish to check if this class implements\n\t\t\t///\n\t\t\t/// @return TRUE if the class implements the given interface\n\t\t\t///\n\t\t\tbool IsA(ChilliSource::InterfaceIDType interfaceId) const noexcept override;\n\n\t\t\t/// Calling this will make the instance listen for text input. Changes to the\n\t\t\t/// input buffer are fed through the given delegate.\n\t\t\t///\n\t\t\t/// @param text\n\t\t\t///\t\tInitial buffer contents\n\t\t\t/// @param type\n\t\t\t///\t\tKeyboard type (not used on RPi)\n\t\t\t/// @param capitalisation\n\t\t\t///\t\tNot used on RPi\n\t\t\t/// @param changeDelegate\n\t\t\t///\t\tDelegate called when the text buffer changes\n\t\t\t/// @param deactivateDelegate\n\t\t\t/// \tCalled when text entry is ended\n\t\t\t///\n\t\t\tvoid Activate(const std::string& text, ChilliSource::TextEntryType type, ChilliSource::TextEntryCapitalisation capitalisation, const TextBufferChangedDelegate& changeDelegate, const TextInputDeactivatedDelegate& deactivateDelegate) noexcept override;\n\n\t\t\t/// Stops the instance receiving text input events from X server\n\t\t\t///\n\t\t\tvoid Deactivate() noexcept override;\n\n\t\t\t/// @return TRUE if text input is currently enabled\n\t\t\t///\n\t\t\tbool IsActive() const noexcept override { return m_active; }\n\n\t\t\t/// @return Current text input buffer (UTF-8)\n\t\t\t///\n\t\t\tconst std::string& GetTextBuffer() const noexcept override;\n\n\t\t\t/// @param text\n\t\t\t///\t\tText to override the current input buffer\n\t\t\t///\n            void SetTextBuffer(const std::string& text) noexcept override;\n\n\t\tprivate:\n            friend ChilliSource::TextEntryUPtr ChilliSource::TextEntry::Create();\n\n\t\t\t///\n\t\t\tTextEntry() = default;\n\n\t\t\t/// Called from X when keyboard input is received. Builds the input buffer.\n\t\t\t///\n\t\t\t/// @param character\n\t\t\t///\t\tUtf8-character\n\t\t\t///\n\t\t\tvoid OnTextEntered(ChilliSource::UTF8Char character) noexcept;\n\n\t\tprivate:\n\n            TextBufferChangedDelegate m_textBufferChangedDelegate;\n            TextInputDeactivatedDelegate m_textInputDeactivatedDelegate;\n\n            std::mutex m_mutex;\n\n            bool m_active = false;\n\t\t\tstd::string m_text;\n\t\t};\n\t}\n}\n\n#endif\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/RPi/Main.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2017 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_RPI\n\n#include <CSBackend/Platform/RPi/Core/Base/DispmanWindow.h>\n\n/// Main entry point for Raspberry Pi application. Sets up the broadcom display\n///\n/// @param argc\n///\t\tNumber of arguments\n/// @param argv\n///\t\tArgument list\n///\n/// @return Exit status\n///\nint main(int argc, const char** argv)\n{\n    CSBackend::RPi::DispmanWindow::Create();\n    CSBackend::RPi::DispmanWindow::Get()->Run();\n    CSBackend::RPi::DispmanWindow::Destroy();\n    return 0;\n}\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/RPi/Networking/Http/HttpRequest.cpp",
    "content": "//\r\n//  The MIT License (MIT)\r\n//\r\n//  Copyright (c) 2017 Tag Games Limited\r\n//\r\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\r\n//  of this software and associated documentation files (the \"Software\"), to deal\r\n//  in the Software without restriction, including without limitation the rights\r\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\n//  copies of the Software, and to permit persons to whom the Software is\r\n//  furnished to do so, subject to the following conditions:\r\n//\r\n//  The above copyright notice and this permission notice shall be included in\r\n//  all copies or substantial portions of the Software.\r\n//\r\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r\n//  THE SOFTWARE.\r\n//\r\n\r\n#ifdef CS_TARGETPLATFORM_RPI\r\n\r\n#include <CSBackend/Platform/RPi/Networking/Http/HttpRequest.h>\r\n\r\n#include <ChilliSource/Core/Base/Application.h>\r\n#include <ChilliSource/Core/Delegate/MakeDelegate.h>\r\n#include <ChilliSource/Core/Math/MathUtils.h>\r\n#include <ChilliSource/Core/String/StringUtils.h>\r\n#include <ChilliSource/Core/String/StringParser.h>\r\n#include <ChilliSource/Core/Threading/TaskScheduler.h>\r\n\r\nnamespace CSBackend\r\n{\r\n\tnamespace RPi\r\n\t{\r\n\t\tstd::list<std::shared_ptr<std::mutex>> HttpRequest::s_destroyingMutexes;\r\n\t\tstd::mutex HttpRequest::s_addingMutexesMutex;\r\n\t\tbool HttpRequest::s_isDestroying = false;\r\n\r\n\t\t/// Callback function used by curl to write data into our response buffer.\r\n\t\t/// Needs access to private method of HttpRequest so is a friend function\r\n\t\t///\r\n\t\t/// @param data\r\n\t\t///\t\tResponse data to write\r\n\t\t/// @param size\r\n\t\t///\t\tSize of response data element\r\n\t\t/// @param num\r\n\t\t///\t\tNumber of response data elements\r\n\t\t/// @param request\r\n\t\t///\t\tRequest to write the data to\r\n\t\t///\r\n\t\t/// @return Size of data read\r\n\t\t///\r\n\t\tstd::size_t CurlWriteResponseData(void* data, std::size_t size, std::size_t num, HttpRequest* request) noexcept\r\n\t\t{\r\n\t\t\t// If destroying then just abort\r\n\t\t\tif (HttpRequest::s_isDestroying == true || request->m_isRequestCancelled == true)\r\n\t\t\t\treturn 0;\r\n\r\n\t\t\tstd::size_t writeSize = size * num;\r\n\t\t\trequest->WriteResponseData((const char*)data, writeSize);\r\n\t\t\treturn writeSize;\r\n\t\t}\r\n\r\n\t\tnamespace\r\n\t\t{\r\n\t\t\t/// Convert our internal header storage into curl header storage. The curl headers\r\n\t\t\t/// must be manually released\r\n\t\t\t///\r\n\t\t\t/// @param headers\r\n\t\t\t///\t\tHeaders to convert\r\n\t\t\t///\r\n\t\t\t/// @return Ownership of the converted headers\r\n\t\t\t///\r\n\t\t\tcurl_slist* CreateHeaders(const ChilliSource::ParamDictionary& headers) noexcept\r\n\t\t\t{\r\n\t\t\t\tcurl_slist* chunk = nullptr;\r\n\r\n\t\t\t\tfor(const auto& header : headers)\r\n\t\t\t\t{\r\n\t\t\t\t\tstd::string formatted = header.first + \": \" + header.second;\r\n\t\t\t\t\tchunk = curl_slist_append(chunk, formatted.c_str());\r\n\t\t\t\t}\r\n\r\n\t\t\t\treturn chunk;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t//------------------------------------------------------------------\r\n\t\tHttpRequest::HttpRequest(Type type, std::string url, std::string body, ChilliSource::ParamDictionary headers, u32 timeoutSecs, CURL* curl, u32 bufferFlushSize, Delegate delegate) noexcept\r\n\t\t: m_url(std::move(url)), m_type(type), m_headers(std::move(headers)), m_body(std::move(body)), m_bufferFlushSize(bufferFlushSize), m_completionDelegate(std::move(delegate)), m_flushesPending(0), m_curl(curl)\r\n\t\t{\r\n\t\t\tCS_ASSERT(m_completionDelegate, \"Http request cannot have null delegate\");\r\n\r\n\t\t\tauto destroyingMutex = std::make_shared<std::mutex>();\r\n\t\t\tstd::unique_lock<std::mutex> lock(s_addingMutexesMutex);\r\n\t\t\ts_destroyingMutexes.push_back(destroyingMutex);\r\n\t\t\tlock.unlock();\r\n\r\n\t\t\tcurl_easy_setopt(curl, CURLOPT_URL, m_url.c_str());\r\n\t\t\tcurl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);\r\n\t\t\tcurl_easy_setopt(curl, CURLOPT_TIMEOUT, timeoutSecs);\r\n\t\t\tcurl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, CurlWriteResponseData);\r\n\t\t\tcurl_easy_setopt(curl, CURLOPT_WRITEDATA, this);\r\n\t\t\tcurl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);\r\n\r\n\t\t\tif(m_bufferFlushSize != 0)\r\n\t\t\t{\r\n\t\t\t\tcurl_easy_setopt(curl, CURLOPT_BUFFERSIZE, m_bufferFlushSize);\r\n\t\t\t}\r\n\r\n\t\t\tif(m_headers.size() > 0)\r\n\t\t\t{\r\n\t\t\t\tm_curlHeaders = CreateHeaders(m_headers);\r\n\t\t\t\tcurl_easy_setopt(curl, CURLOPT_HTTPHEADER, m_curlHeaders);\r\n\t\t\t}\r\n\r\n\t\t\tif(type == Type::k_post)\r\n\t\t\t{\r\n\t\t\t\tcurl_easy_setopt(curl, CURLOPT_POST, 1L);\r\n\t\t\t\tcurl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, m_body.size());\r\n\t\t\t\tcurl_easy_setopt(curl, CURLOPT_POSTFIELDS, m_body.c_str());\r\n\t\t\t}\r\n\r\n\t\t\t//TODO: This should probably be handled by a HTTP system specific thread, like the other platforms.\r\n\t\t\tm_taskScheduler = ChilliSource::Application::Get()->GetTaskScheduler();\r\n\t\t\tm_taskScheduler->ScheduleTask(ChilliSource::TaskType::k_large, [=](const ChilliSource::TaskContext&)\r\n\t\t\t{\r\n\t\t\t\tPerformRequest(destroyingMutex);\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\t//------------------------------------------------------------------\r\n\t\tvoid HttpRequest::Update(f32 timeSinceLastUpdate) noexcept\r\n\t\t{\r\n\t\t\t//Check if the data has finished streaming and invoke the completion delegate on the main thread\r\n\t\t\tif(m_isPollingComplete == true && m_flushesPending <= 0)\r\n\t\t\t{\r\n\t\t\t\tm_isRequestComplete = true;\r\n\r\n\t\t\t\tif (m_isRequestCancelled == false)\r\n\t\t\t\t{\r\n\t\t\t\t\tm_completionDelegate(this, ChilliSource::HttpResponse(m_requestResult, m_responseCode, m_responseData));\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t//------------------------------------------------------------------\r\n\t\tvoid HttpRequest::PerformRequest(std::shared_ptr<std::mutex> destroyingMutex) noexcept\r\n\t\t{\r\n\t\t\tstd::unique_lock<std::mutex> lock(*destroyingMutex);\r\n\r\n\t\t\tif (s_isDestroying == true)\r\n\t\t\t\treturn;\r\n\r\n\t\t\tlock.unlock();\r\n\r\n\t\t\t//Blocking call. Will call into the write callback which is responsible for reading the response data into the output buffer.\r\n\t\t\tCURLcode curlResult = curl_easy_perform(m_curl);\r\n\r\n\t\t\t//Fetch the response code\r\n\t\t\tlong httpCode = 0;\r\n\t\t\tcurl_easy_getinfo (m_curl, CURLINFO_RESPONSE_CODE, &httpCode);\r\n\t\t\tm_responseCode = (u32)httpCode;\r\n\r\n\t\t\tif(m_curlHeaders != nullptr)\r\n\t\t\t{\r\n\t\t\t\tcurl_slist_free_all(m_curlHeaders);\r\n\t\t\t\tm_curlHeaders = nullptr;\r\n\t\t\t}\r\n\r\n\t\t\tlock.lock();\r\n\r\n\t\t\tif (s_isDestroying == true)\r\n\t\t\t\treturn;\r\n\r\n\t\t\tswitch(curlResult)\r\n\t\t\t{\r\n\t\t\t\tcase CURLE_OK:\r\n\t\t\t\t\tm_requestResult = ChilliSource::HttpResponse::Result::k_completed;\r\n\t\t\t\t\tm_responseData = m_streamBuffer.str();\r\n\t\t\t\t\tm_streamBuffer.clear();\r\n\t\t\t\t\tm_streamBuffer.str(\"\");\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase CURLE_OPERATION_TIMEDOUT:\r\n\t\t\t\t\tm_requestResult = ChilliSource::HttpResponse::Result::k_timeout;\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tdefault:\r\n\t\t\t\t\tm_requestResult = ChilliSource::HttpResponse::Result::k_failed;\r\n\t\t\t\t\tCS_LOG_ERROR_FMT(\"Curl Error: %d\\n\", curlResult);\r\n\t\t\t\t\tbreak;\r\n\t\t\t}\r\n\r\n\t\t\tm_isPollingComplete = true;\r\n\t\t}\r\n\r\n\t\t//----------------------------------------------------------------------------------------\r\n\t\tvoid HttpRequest::WriteResponseData(const char* data, std::size_t dataSize) noexcept\r\n\t\t{\r\n\t\t\t//Once we have some response data we are able to fetch the content length from the headers\r\n\t\t\tif(m_expectedSize == 0)\r\n\t\t\t{\r\n\t\t\t\tdouble contentLength = 0;\r\n\t\t\t\tcurl_easy_getinfo(m_curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &contentLength);\r\n\t\t\t\tm_expectedSize = (u32)contentLength;\r\n\t\t\t}\r\n\r\n\t\t\tm_streamBuffer.write(data, dataSize);\r\n\t\t\tm_totalBytesRead += dataSize;\r\n\t\t\tm_totalBytesReadThisBlock += dataSize;\r\n\r\n\t\t\tif (m_bufferFlushSize != 0 && m_totalBytesReadThisBlock >= m_bufferFlushSize)\r\n\t\t\t{\r\n\t\t\t\tm_responseData = m_streamBuffer.str();\r\n\t\t\t\tm_requestResult = ChilliSource::HttpResponse::Result::k_flushed;\r\n\r\n\t\t\t\t++m_flushesPending;\r\n\t\t\t\tm_taskScheduler->ScheduleTask(ChilliSource::TaskType::k_mainThread, [=](const ChilliSource::TaskContext&)\r\n\t\t\t\t{\r\n\t\t\t\t\t--m_flushesPending;\r\n\t\t\t\t\tm_completionDelegate(this, ChilliSource::HttpResponse(m_requestResult, m_responseCode, m_responseData));\r\n\t\t\t\t});\r\n\r\n\t\t\t\tm_streamBuffer.clear();\r\n\t\t\t\tm_streamBuffer.str(\"\");\r\n\t\t\t\tm_totalBytesReadThisBlock = 0;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t//----------------------------------------------------------------------------------------\r\n\t\tvoid HttpRequest::Cancel() noexcept\r\n\t\t{\r\n\t\t\tm_isRequestCancelled = true;\r\n\t\t}\r\n\r\n\t\t//----------------------------------------------------------------------------------------\r\n\t\tvoid HttpRequest::Shutdown() noexcept\r\n\t\t{\r\n\t\t\tstd::unique_lock<std::mutex> mutexLock(s_addingMutexesMutex);\r\n\r\n\t\t\tstd::vector<std::unique_lock<std::mutex>> locks;\r\n\t\t\tlocks.reserve(s_destroyingMutexes.size());\r\n\r\n\t\t\tfor (auto& mutex : s_destroyingMutexes)\r\n\t\t\t{\r\n\t\t\t\tlocks.push_back(std::unique_lock<std::mutex>(*mutex));\r\n\t\t\t}\r\n\r\n\t\t\ts_isDestroying = true;\r\n\t\t}\r\n\t}\r\n}\r\n\r\n#endif\r\n"
  },
  {
    "path": "Source/CSBackend/Platform/RPi/Networking/Http/HttpRequest.h",
    "content": "//\r\n//  The MIT License (MIT)\r\n//\r\n//  Copyright (c) 2017 Tag Games Limited\r\n//\r\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\r\n//  of this software and associated documentation files (the \"Software\"), to deal\r\n//  in the Software without restriction, including without limitation the rights\r\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\n//  copies of the Software, and to permit persons to whom the Software is\r\n//  furnished to do so, subject to the following conditions:\r\n//\r\n//  The above copyright notice and this permission notice shall be included in\r\n//  all copies or substantial portions of the Software.\r\n//\r\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r\n//  THE SOFTWARE.\r\n//\r\n\r\n#ifdef CS_TARGETPLATFORM_RPI\r\n\r\n#ifndef _CSBACKEND_PLATFORM_RPI_HTTP_HTTPREQUEST_H_\r\n#define _CSBACKEND_PLATFORM_RPI_HTTP_HTTPREQUEST_H_\r\n\r\n#include <ChilliSource/ChilliSource.h>\r\n#include <CSBackend/Platform/RPi/ForwardDeclarations.h>\r\n#include <ChilliSource/Networking/Http/HttpRequest.h>\r\n#include <ChilliSource/Networking/Http/HttpResponse.h>\r\n\r\n#include <curl/curl.h>\r\n\r\n#include <atomic>\r\n#include <list>\r\n#include <mutex>\r\n#include <sstream>\r\n\r\nnamespace CSBackend\r\n{\r\n\tnamespace RPi\r\n\t{\r\n\t\t/// Concerete implementation of the Raspberry Pi http request using curl library. Requests are\r\n\t\t/// threaded to avoid blocking the main thread\r\n\t\t///\r\n\t\tclass HttpRequest final : public ChilliSource::HttpRequest\r\n\t\t{\r\n\t\tpublic:\r\n\r\n\t\t\t/// @return The type of the request (POST or GET)\r\n\t\t\t///\r\n\t\t\tType GetType() const noexcept override { return m_type; }\r\n\r\n\t\t\t/// @return The original url to which the request was sent\r\n\t\t\t///\r\n\t\t\tconst std::string& GetUrl() const noexcept override { return m_url; }\r\n\r\n\t\t\t/// @return The body of the POST request (GET request will return empty)\r\n\t\t\t///\r\n\t\t\tconst std::string& GetBody() const noexcept override { return m_body; }\r\n\r\n\t\t\t/// @return The original headers of the request as keys/values\r\n\t\t\t///\r\n\t\t\tconst ChilliSource::ParamDictionary& GetHeaders() const noexcept override { return m_headers; }\r\n\r\n\t\t\t/// Close the request.\r\n\t\t\t/// NOTE: The completion delegate is not invoked\r\n\t\t\t///\r\n\t\t\tvoid Cancel() noexcept override;\r\n\r\n\t\t\t/// @return the expected size in bytes of the response\r\n\t\t\t///\r\n\t\t\tu64 GetExpectedSize() const noexcept override { return m_expectedSize; }\r\n\r\n\t\t\t/// @return The size in bytes of the response that has already been downloaded\r\n\t\t\t///\r\n\t\t\tu64 GetDownloadedBytes() const noexcept override { return m_totalBytesRead; }\r\n\r\n\t\tprivate:\r\n\t\t\tfriend class HttpRequestSystem;\r\n\t\t\tfriend std::size_t CurlWriteResponseData(void*, std::size_t, std::size_t, HttpRequest*) noexcept;\r\n\r\n\t\t\t/// @param type\r\n\t\t\t///\t\tPOST or GET\r\n\t\t\t/// @param url\r\n\t\t\t///\t\tUrl of server to which to make the request\r\n\t\t\t/// @param body\r\n\t\t\t///\t\t POST only. The Http data to send to the server\r\n\t\t\t/// @param headers\r\n\t\t\t///\t\tHttp headers as key-values.\r\n\t\t\t/// @param timeoutSecs\r\n\t\t\t///\t\tRequest timeout in seconds\r\n\t\t\t/// @param curl\r\n\t\t\t///\t\tCurl instance on which to set options and perform the request (passed in so it can be reused for other requests)\r\n\t\t\t/// @param bufferFlushSize\r\n\t\t\t///\t\tMax size before the response buffer is flushed to the application\r\n\t\t\t/// @param delegate\r\n\t\t\t///\t\tCalled on success or fail\r\n\t\t\t///\r\n\t\t\tHttpRequest(Type type, std::string url, std::string body, ChilliSource::ParamDictionary headers, u32 timeoutSecs, CURL* curl, u32 bufferFlushSize, Delegate delegate) noexcept;\r\n\r\n\t\t\t/// Run on a background thread this function uses a pre-setup curl object to make an http request.\r\n\t\t\t/// It will store the response state and then terminate once finished. The completion event\r\n\t\t\t/// will be fired on the next update\r\n\t\t\t///\r\n\t\t\t/// @param destroyingMutex\r\n\t\t\t///\t\tMutex that manages the critical section of the HTTP system being shutdown\r\n\t\t\t///\r\n\t\t\tvoid PerformRequest(std::shared_ptr<std::mutex> destroyingMutex) noexcept;\r\n\r\n\t\t\t/// Called via curl with response data (partial or full). We then write\r\n\t\t\t/// to our response buffer and flush if we exceed the max buffer size\r\n\t\t\t///\r\n\t\t\t/// @param data\r\n\t\t\t///\t\tData to write\r\n\t\t\t/// @param dataSize\r\n\t\t\t///\t\tSize of data to write in bytes\r\n\t\t\t///\r\n\t\t\tvoid WriteResponseData(const char* data, std::size_t dataSize) noexcept;\r\n\r\n\t\t\t/// Polls for the request thread finishing and invokes the completion delegate\r\n\t\t\t///\r\n\t\t\t/// @param timeSinceLastUpdate\r\n\t\t\t///\t\tTime in seconds since last update\r\n\t\t\t///\r\n\t\t\tvoid Update(f32 timeSinceLastUpdate) noexcept;\r\n\r\n\t\t\t/// @return TRUE if the request is finished\r\n\t\t\t///\r\n\t\t\tbool HasCompleted() const noexcept { return m_isRequestComplete; }\r\n\r\n\t\t\t/// Inform the polling threads in a thread-safe manner that the system is shutting down\r\n\t\t\t///\r\n\t\t\tstatic void Shutdown() noexcept;\r\n\r\n\t\tprivate:\r\n\r\n\t\t\tstatic std::mutex s_addingMutexesMutex;\r\n\t\t\tstatic std::list<std::shared_ptr<std::mutex>> s_destroyingMutexes;\r\n\t\t\tstatic bool s_isDestroying;\r\n\r\n\t\t\tconst Type m_type;\r\n\t\t\tconst std::string m_url;\r\n\t\t\tconst std::string m_body;\r\n\t\t\tconst ChilliSource::ParamDictionary m_headers;\r\n\t\t\tconst Delegate m_completionDelegate;\r\n\t\t\tconst u32 m_bufferFlushSize;\r\n\r\n\t\t\tstd::string m_responseData;\r\n\t\t\tu32 m_responseCode = 0;\r\n\t\t\tChilliSource::HttpResponse::Result m_requestResult = ChilliSource::HttpResponse::Result::k_failed;\r\n\r\n\t\t\tu64 m_totalBytesRead = 0;\r\n\t\t\tu64 m_totalBytesReadThisBlock = 0;\r\n\t\t\tu64 m_expectedSize = 0;\r\n\r\n\t\t\tstd::stringstream m_streamBuffer;\r\n\t\t\tCURL* m_curl;\r\n\t\t\tcurl_slist* m_curlHeaders = nullptr;\r\n\r\n\t\t\tbool m_isPollingComplete = false;\r\n\t\t\tbool m_isRequestComplete = false;\r\n\t\t\tbool m_isRequestCancelled = false;\r\n\r\n\t\t\tstd::atomic_int m_flushesPending;\r\n\r\n\t\t\tChilliSource::TaskScheduler* m_taskScheduler;\r\n\t\t};\r\n\t}\r\n}\r\n\r\n#endif\r\n\r\n#endif\r\n"
  },
  {
    "path": "Source/CSBackend/Platform/RPi/Networking/Http/HttpRequestSystem.cpp",
    "content": "//\r\n//  The MIT License (MIT)\r\n//\r\n//  Copyright (c) 2017 Tag Games Limited\r\n//\r\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\r\n//  of this software and associated documentation files (the \"Software\"), to deal\r\n//  in the Software without restriction, including without limitation the rights\r\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\n//  copies of the Software, and to permit persons to whom the Software is\r\n//  furnished to do so, subject to the following conditions:\r\n//\r\n//  The above copyright notice and this permission notice shall be included in\r\n//  all copies or substantial portions of the Software.\r\n//\r\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r\n//  THE SOFTWARE.\r\n//\r\n\r\n#ifdef CS_TARGETPLATFORM_RPI\r\n\r\n#include <CSBackend/Platform/RPi/Networking/Http/HttpRequestSystem.h>\r\n\r\n#include <ChilliSource/Core/Base/Application.h>\r\n#include <ChilliSource/Core/Threading/TaskScheduler.h>\r\n\r\n#include <curl/curl.h>\r\n\r\nnamespace CSBackend\r\n{\r\n\tnamespace RPi\r\n\t{\r\n\t\tCS_DEFINE_NAMEDTYPE(HttpRequestSystem);\r\n\r\n\t\t//--------------------------------------------------------------------------------------------------\r\n\t\tvoid HttpRequestSystem::OnInit() noexcept\r\n\t\t{\r\n\t\t\tcurl_global_init(CURL_GLOBAL_SSL);\r\n\t\t}\r\n\r\n\t\t//--------------------------------------------------------------------------------------------------\r\n\t\tbool HttpRequestSystem::IsA(ChilliSource::InterfaceIDType interfaceId) const noexcept\r\n\t\t{\r\n\t\t\treturn interfaceId == ChilliSource::HttpRequestSystem::InterfaceID || interfaceId == HttpRequestSystem::InterfaceID;\r\n\t\t}\r\n\r\n\t\t//--------------------------------------------------------------------------------------------------\r\n\t\tHttpRequest* HttpRequestSystem::MakeGetRequest(const std::string& url, const HttpRequest::Delegate& delegate, u32 timeoutSecs) noexcept\r\n\t\t{\r\n\t\t\treturn MakeRequest(HttpRequest::Type::k_get, url, \"\", ChilliSource::ParamDictionary(), delegate, timeoutSecs);\r\n\t\t}\r\n\r\n\t\t//--------------------------------------------------------------------------------------------------\r\n\t\tHttpRequest* HttpRequestSystem::MakeGetRequest(const std::string& url, const ChilliSource::ParamDictionary& headers, const HttpRequest::Delegate& delegate, u32 timeoutSecs) noexcept\r\n\t\t{\r\n\t\t\treturn MakeRequest(HttpRequest::Type::k_get, url, \"\", headers, delegate, timeoutSecs);\r\n\t\t}\r\n\r\n\t\t//--------------------------------------------------------------------------------------------------\r\n\t\tHttpRequest* HttpRequestSystem::MakePostRequest(const std::string& url, const std::string& body, const HttpRequest::Delegate& delegate, u32 timeoutSecs) noexcept\r\n\t\t{\r\n\t\t\treturn MakeRequest(HttpRequest::Type::k_post, url, body, ChilliSource::ParamDictionary(), delegate, timeoutSecs);\r\n\t\t}\r\n\r\n\t\t//--------------------------------------------------------------------------------------------------\r\n\t\tHttpRequest* HttpRequestSystem::MakePostRequest(const std::string& url, const std::string& body, const ChilliSource::ParamDictionary& headers, const HttpRequest::Delegate& delegate, u32 timeoutSecs) noexcept\r\n\t\t{\r\n\t\t\treturn MakeRequest(HttpRequest::Type::k_post, url, body, headers, delegate, timeoutSecs);\r\n\t\t}\r\n\r\n\t\t//--------------------------------------------------------------------------------------------------\r\n\t\tHttpRequest* HttpRequestSystem::MakeRequest(HttpRequest::Type type, const std::string& url, const std::string& body, const ChilliSource::ParamDictionary& headers, const HttpRequest::Delegate& delegate, u32 timeoutSecs) noexcept\r\n\t\t{\r\n\t\t\tCS_ASSERT(ChilliSource::Application::Get()->GetTaskScheduler()->IsMainThread() == true, \"Http requests can currently only be made on the main thread\");\r\n\t\t\tCS_ASSERT(delegate != nullptr, \"Cannot make an http request with a null delegate\");\r\n\t\t\tCS_ASSERT(url.empty() == false, \"Cannot make an http request to a blank url\");\r\n\r\n\t\t\t//TODO: Persistent connections. Don't close the connection but instead check if the next request is to the same server\r\n\t\t\t//and reuse it. If not then close the connection and open a new one\r\n\t\t\tauto curl = curl_easy_init();\r\n\t\t\tHttpRequest* httpRequest = new HttpRequest(type, url, body, headers, timeoutSecs, curl, GetMaxBufferSize(), delegate);\r\n\t\t\tm_requests.push_back(httpRequest);\r\n\t\t\treturn httpRequest;\r\n\t\t}\r\n\r\n\t\t//--------------------------------------------------------------------------------------------------\r\n\t\tvoid HttpRequestSystem::CancelAllRequests() noexcept\r\n\t\t{\r\n\t\t\tCS_ASSERT(ChilliSource::Application::Get()->GetTaskScheduler()->IsMainThread() == true, \"Http requests can currently only be made on the main thread\");\r\n\r\n\t\t\tfor(auto request : m_requests)\r\n\t\t\t{\r\n\t\t\t\trequest->Cancel();\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t//--------------------------------------------------------------------------------------------------\r\n\t\tvoid HttpRequestSystem::CheckReachability(const ReachabilityResultDelegate& delegate) const noexcept\r\n\t\t{\r\n\t\t\t//TODO: RPi: Add reachability check if possible\r\n            CS_ASSERT(delegate, \"The reachability delegate should not be null.\");\r\n\t\t\tCS_LOG_WARNING(\"CheckReachability: Not implemented on Raspberry Pi\");\r\n\t\t\tdelegate(true);\r\n\t\t}\r\n\r\n\t\t//--------------------------------------------------------------------------------------------------\r\n\t\tvoid HttpRequestSystem::OnUpdate(f32 timeSinceLastUpdate) noexcept\r\n\t\t{\r\n\t\t\t//We should do this in two loops incase anyone tries to insert into the requests from the completion callback\r\n\t\t\tfor (u32 i=0; i<m_requests.size(); ++i)\r\n\t\t\t{\r\n\t\t\t\tm_requests[i]->Update(timeSinceLastUpdate);\r\n\t\t\t}\r\n\r\n\t\t\tfor (auto it = m_requests.begin(); it != m_requests.end(); /*No increment*/)\r\n\t\t\t{\r\n\t\t\t\tif((*it)->HasCompleted())\r\n\t\t\t\t{\r\n\t\t\t\t\t//...and remove the completed request\r\n\t\t\t\t\tcurl_easy_cleanup((*it)->m_curl);\r\n\t\t\t\t\tCS_SAFEDELETE(*it);\r\n\t\t\t\t\tit = m_requests.erase(it);\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t{\r\n\t\t\t\t\t++it;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t//--------------------------------------------------------------------------------------------------\r\n\t\tvoid HttpRequestSystem::OnDestroy() noexcept\r\n\t\t{\r\n\t\t\tCancelAllRequests();\r\n\r\n\t\t\tHttpRequest::Shutdown();\r\n\r\n\t\t\tfor (auto it = m_requests.begin(); it != m_requests.end(); ++it)\r\n\t\t\t{\r\n\t\t\t\tcurl_easy_cleanup((*it)->m_curl);\r\n\t\t\t\tCS_SAFEDELETE(*it);\r\n\t\t\t}\r\n\r\n\t\t\tm_requests.clear();\r\n\t\t\tm_requests.shrink_to_fit();\r\n\r\n\t\t\tcurl_global_cleanup();\r\n\t\t}\r\n\t}\r\n}\r\n\r\n#endif\r\n"
  },
  {
    "path": "Source/CSBackend/Platform/RPi/Networking/Http/HttpRequestSystem.h",
    "content": "//\r\n//  The MIT License (MIT)\r\n//\r\n//  Copyright (c) 2017 Tag Games Limited\r\n//\r\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\r\n//  of this software and associated documentation files (the \"Software\"), to deal\r\n//  in the Software without restriction, including without limitation the rights\r\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\n//  copies of the Software, and to permit persons to whom the Software is\r\n//  furnished to do so, subject to the following conditions:\r\n//\r\n//  The above copyright notice and this permission notice shall be included in\r\n//  all copies or substantial portions of the Software.\r\n//\r\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r\n//  THE SOFTWARE.\r\n//\r\n\r\n#ifdef CS_TARGETPLATFORM_RPI\r\n\r\n#ifndef _CSBACKEND_PLATFORM_RPI_HTTP_HTTPREQUESTSYSTEM_H_\r\n#define _CSBACKEND_PLATFORM_RPI_HTTP_HTTPREQUESTSYSTEM_H_\r\n\r\n#include <CSBackend/Platform/RPi/ForwardDeclarations.h>\r\n#include <CSBackend/Platform/RPi/Networking/Http/HttpRequest.h>\r\n#include <ChilliSource/Networking/Http/HttpRequestSystem.h>\r\n\r\n#include <vector>\r\n\r\nnamespace CSBackend\r\n{\r\n\tnamespace RPi\r\n\t{\r\n\t\t/// Raspberry Pi implementation of the Http connection system. Responsible for making http GET and POST\r\n\t\t/// requests to remote servers. Uses libCurl under the hood\r\n\t\t///\r\n\t\tclass HttpRequestSystem final : public ChilliSource::HttpRequestSystem\r\n\t\t{\r\n\t\tpublic:\r\n\r\n\t\t\tCS_DECLARE_NAMEDTYPE(HttpRequestSystem);\r\n\r\n\t\t\t///\r\n\t\t\tbool IsA(ChilliSource::InterfaceIDType interfaceId) const noexcept override;\r\n\r\n\t\t\t/// Issues an Http GET request to the given URL.\r\n\t\t\t///\r\n\t\t\t/// @param url\r\n\t\t\t///\t\tURL address of the server to make the request to.\r\n\t\t\t/// @param delegate\r\n\t\t\t///\t\tDelegate that is called when the request completes. Completion can be failure as well as success\r\n\t\t\t/// @param timeoutSecs\r\n\t\t\t///\t\tTimeout in seconds after which the request is abandonded.\r\n\t\t\t///\r\n\t\t\t/// @return Handle to the http request - this is owned by the system.\r\n\t\t\t///\r\n\t\t\tHttpRequest* MakeGetRequest(const std::string& url, const HttpRequest::Delegate& delegate, u32 timeoutSecs = k_defaultTimeoutSecs) noexcept override;\r\n\r\n\t\t\t/// Issues an Http GET request with the given headers to the given URL.\r\n\t\t\t///\r\n\t\t\t/// @param url\r\n\t\t\t///\t\tURL address of the server to make the request to.\r\n\t\t\t/// @param headers\r\n\t\t\t///\t\tHttp headers as key-values\r\n\t\t\t/// @param delegate\r\n\t\t\t///\t\tDelegate that is called when the request completes. Completion can be failure as well as success\r\n\t\t\t/// @param timeoutSecs\r\n\t\t\t///\t\tTimeout in seconds after which the request is abandonded.\r\n\t\t\t///\r\n\t\t\t/// @return Handle to the http request - this is owned by the system.\r\n\t\t\t///\r\n\t\t\tHttpRequest* MakeGetRequest(const std::string& url, const ChilliSource::ParamDictionary& headers, const HttpRequest::Delegate& delegate, u32 timeoutSecs = k_defaultTimeoutSecs) noexcept override;\r\n\r\n\t\t\t/// Issues an Http POST request with the given body to the given URL.\r\n\t\t\t///\r\n\t\t\t/// @param url\r\n\t\t\t///\t\tURL address of the server to make the request to.\r\n\t\t\t/// @param body\r\n\t\t\t///\t\tHttp POST body (i.e. data that is sent to the server).\r\n\t\t\t/// @param delegate\r\n\t\t\t///\t\tDelegate that is called when the request completes. Completion can be failure as well as success\r\n\t\t\t/// @param timeoutSecs\r\n\t\t\t///\t\tTimeout in seconds after which the request is abandonded.\r\n\t\t\t///\r\n\t\t\t/// @return Handle to the http request - this is owned by the system.\r\n\t\t\t///\r\n\t\t\tHttpRequest* MakePostRequest(const std::string& url, const std::string& body, const HttpRequest::Delegate& delegate, u32 timeoutSecs = k_defaultTimeoutSecs) noexcept override;\r\n\r\n\t\t\t/// Issues an Http POST request with the given body and headers to the given URL.\r\n\t\t\t///\r\n\t\t\t/// @param url\r\n\t\t\t///\t\tURL address of the server to make the request to.\r\n\t\t\t/// @param body\r\n\t\t\t///\t\tHttp POST body (i.e. data that is sent to the server).\r\n\t\t\t/// @param headers\r\n\t\t\t///\t\tHttp headers as key-values\r\n\t\t\t/// @param delegate\r\n\t\t\t///\t\tDelegate that is called when the request completes. Completion can be failure as well as success\r\n\t\t\t/// @param timeoutSecs\r\n\t\t\t///\t\tTimeout in seconds after which the request is abandonded.\r\n\t\t\t///\r\n\t\t\t/// @return Handle to the http request - this is owned by the system.\r\n\t\t\t///\r\n\t\t\tHttpRequest* MakePostRequest(const std::string& url, const std::string& body, const ChilliSource::ParamDictionary& headers, const HttpRequest::Delegate& delegate, u32 timeoutSecs = k_defaultTimeoutSecs) noexcept override;\r\n\r\n\t\t\t/// Equivalent to calling cancel on every incomplete request in progress.\r\n\t\t\t///\r\n\t\t\tvoid CancelAllRequests() noexcept override;\r\n\r\n\t\t\t/// Checks if the device is internet ready. Should be used only as a heuristic for informing the user and\r\n\t\t\t/// does ot guarantee the success of an individual request\r\n\t\t\t///\r\n\t\t\t/// @param delegate\r\n\t\t\t///\t\tCalled when reachability has been determined\r\n\t\t\t///\r\n\t\t\tvoid CheckReachability(const ReachabilityResultDelegate& delegate) const noexcept override;\r\n\r\n\t\tprivate:\r\n\t\t\tfriend ChilliSource::HttpRequestSystemUPtr ChilliSource::HttpRequestSystem::Create();\r\n\r\n\t\t\t///\r\n\t\t\tHttpRequestSystem() = default;\r\n\r\n\t\t\t/// Concrete method to which all MakeRequest overloads feed.\r\n\t\t\t///\r\n\t\t\t/// @param type\r\n\t\t\t///\t\tPOST or GET\r\n\t\t\t/// @param url\r\n\t\t\t///\t\tUrl of server to which to make the request\r\n\t\t\t/// @param body\r\n\t\t\t///\t\t POST only. The Http data to send to the server\r\n\t\t\t/// @param headers\r\n\t\t\t///\t\tHttp headers as key-values.\r\n\t\t\t/// @param delegate\r\n\t\t\t///\t\tCalled on success or fail\r\n\t\t\t/// @param timeoutSecs\r\n\t\t\t///\t\tRequest timeout in seconds\r\n\t\t\t///\r\n\t\t\t/// @return Request. Owned by the system.\r\n\t\t\t///\r\n\t\t\tHttpRequest* MakeRequest(HttpRequest::Type type, const std::string& url, const std::string& body, const ChilliSource::ParamDictionary& headers, const HttpRequest::Delegate& delegate, u32 timeoutSecs) noexcept;\r\n\r\n\t\t\t/// Initialise libCurl\r\n\t\t\t///\r\n\t\t\tvoid OnInit() noexcept override;\r\n\r\n\t\t\t/// Check for finished requests and invoke the delegates on the main thread\r\n\t\t\t///\r\n\t\t\t/// @param timeSinceLastUpdate\r\n\t\t\t///\t\tTime since last update in seconds\r\n\t\t\t///\r\n\t\t\tvoid OnUpdate(f32 timeSinceLastUpdate) noexcept override;\r\n\r\n\t\t\t/// Cleanup curl\r\n\t\t\t///\r\n\t\t\tvoid OnDestroy() noexcept override;\r\n\r\n\t\tprivate:\r\n\r\n\t\t\tstd::vector<HttpRequest*> m_requests;\r\n\t\t};\r\n\t}\r\n}\r\n\r\n#endif\r\n\r\n#endif\r\n"
  },
  {
    "path": "Source/CSBackend/Platform/Windows/Core/Base/PlatformSystem.cpp",
    "content": "//\r\n//  PlatformSystem.cpp\r\n//  ChilliSource\r\n//  Created by Scott Downie on 24/11/2010.\r\n//\r\n//  The MIT License (MIT)\r\n//\r\n//  Copyright (c) 2010 Tag Games Limited\r\n//\r\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\r\n//  of this software and associated documentation files (the \"Software\"), to deal\r\n//  in the Software without restriction, including without limitation the rights\r\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\n//  copies of the Software, and to permit persons to whom the Software is\r\n//  furnished to do so, subject to the following conditions:\r\n//\r\n//  The above copyright notice and this permission notice shall be included in\r\n//  all copies or substantial portions of the Software.\r\n//\r\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r\n//  THE SOFTWARE.\r\n//\r\n\r\n#ifdef CS_TARGETPLATFORM_WINDOWS\r\n\r\n#include <CSBackend/Platform/Windows/Core/Base/PlatformSystem.h>\r\n#include <CSBackend/Platform/Windows/SFML/Base/SFMLWindow.h>\r\n#include <ChilliSource/Core/Base/Application.h>\r\n#include <ChilliSource/Core/Threading/TaskScheduler.h>\r\n#include <ChilliSource/UI/Base/CursorSystem.h>\r\n\r\n#define WIN32_LEAN_AND_MEAN\r\n#include <windows.h>\r\n\r\nnamespace CSBackend\r\n{\r\n\tnamespace Windows\r\n\t{\r\n\t\tnamespace\r\n\t\t{\r\n\t\t\t//This is global as LARGE_INTEGER is defined in windows.h. Including windows.h in\r\n\t\t\t//PlatformSystem.h will cause compiler errors in FileSystem.h\r\n\t\t\tLARGE_INTEGER g_frequency;\r\n\t\t}\r\n\r\n\t\tCS_DEFINE_NAMEDTYPE(PlatformSystem);\r\n\t\t//-----------------------------------------\r\n\t\t//-----------------------------------------\r\n\t\tPlatformSystem::PlatformSystem()\r\n\t\t{\r\n\t\t\tQueryPerformanceFrequency(&g_frequency);\r\n\t\t}\r\n\t\t//--------------------------------------------------\r\n\t\t//--------------------------------------------------\r\n\t\tbool PlatformSystem::IsA(ChilliSource::InterfaceIDType in_interfaceId) const\r\n\t\t{\r\n\t\t\treturn (ChilliSource::PlatformSystem::InterfaceID == in_interfaceId || PlatformSystem::InterfaceID == in_interfaceId);\r\n\t\t}\r\n\t\t//-------------------------------------------------\r\n\t\t//-------------------------------------------------\r\n\t\tvoid PlatformSystem::CreateDefaultSystems(ChilliSource::Application* in_application)\r\n\t\t{\r\n\t\t\tin_application->CreateSystem<ChilliSource::CursorSystem>();\r\n\t\t}\r\n\t\t//-------------------------------------------------\r\n\t\t//-------------------------------------------------\r\n\t\tvoid PlatformSystem::SetPreferredFPS(u32 in_fps)\r\n\t\t{\r\n\t\t\tChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_system, [=](const ChilliSource::TaskContext& in_taskContext)\r\n\t\t\t{\r\n\t\t\t\tSFMLWindow::Get()->SetPreferredFPS(in_fps);\r\n\t\t\t});\r\n\t\t}\r\n\t\t//---------------------------------------------------\r\n\t\t//---------------------------------------------------\r\n\t\tvoid PlatformSystem::SetVSyncEnabled(bool in_enabled)\r\n\t\t{\r\n\t\t\tChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_system, [=](const ChilliSource::TaskContext& in_taskContext)\r\n\t\t\t{\r\n\t\t\t\tSFMLWindow::Get()->SetVSyncEnabled(in_enabled);\r\n\t\t\t});\r\n\t\t}\r\n\t\t//--------------------------------------------\r\n\t\t//--------------------------------------------\r\n\t\tvoid PlatformSystem::Quit()\r\n\t\t{\r\n\t\t\tChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_system, [=](const ChilliSource::TaskContext& in_taskContext)\r\n\t\t\t{\r\n\t\t\t\tSFMLWindow::Get()->ScheduleQuit();\r\n\t\t\t});\r\n\t\t}\r\n\t}\r\n}\r\n\r\n#endif\r\n"
  },
  {
    "path": "Source/CSBackend/Platform/Windows/Core/Base/PlatformSystem.h",
    "content": "//\r\n//  PlatformSystem.h\r\n//  ChilliSource\r\n//  Created by Scott Downie on 24/11/2010.\r\n//\r\n//  The MIT License (MIT)\r\n//\r\n//  Copyright (c) 2010 Tag Games Limited\r\n//\r\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\r\n//  of this software and associated documentation files (the \"Software\"), to deal\r\n//  in the Software without restriction, including without limitation the rights\r\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\n//  copies of the Software, and to permit persons to whom the Software is\r\n//  furnished to do so, subject to the following conditions:\r\n//\r\n//  The above copyright notice and this permission notice shall be included in\r\n//  all copies or substantial portions of the Software.\r\n//\r\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r\n//  THE SOFTWARE.\r\n//\r\n\r\n#ifdef CS_TARGETPLATFORM_WINDOWS\r\n\r\n#ifndef _CSBACKEND_PLATFORM_WINDOWS_CORE_BASE_PLATFORMSYSTEM_H_\r\n#define _CSBACKEND_PLATFORM_WINDOWS_CORE_BASE_PLATFORMSYSTEM_H_\r\n\r\n#include <ChilliSource/ChilliSource.h>\r\n#include <CSBackend/Platform/Windows/ForwardDeclarations.h>\r\n#include <ChilliSource/Core/Base/PlatformSystem.h>\r\n\r\nnamespace CSBackend\r\n{\r\n\tnamespace Windows\r\n\t{\r\n\t\tstruct GLFWwindow;\r\n\r\n\t\t//-------------------------------------------------------------\r\n\t\t/// The Windows backend for the platform system. This creates the\r\n\t\t/// Windows specfic default systems and sets up the updater.\r\n\t\t///\r\n\t\t/// @author S Downie\r\n\t\t//-------------------------------------------------------------\r\n\t\tclass PlatformSystem final : public ChilliSource::PlatformSystem\r\n\t\t{\r\n\t\tpublic:\r\n\t\t\tCS_DECLARE_NAMEDTYPE(PlatformSystem);\r\n\t\t\t//--------------------------------------------------\r\n\t\t\t/// Queries whether or not this system implements the\r\n\t\t\t/// interface with the given Id.\r\n\t\t\t///\r\n\t\t\t/// @author Ian Copland\r\n\t\t\t///\r\n\t\t\t/// @param The interface Id.\r\n\t\t\t/// @param Whether system is of given type.\r\n\t\t\t//--------------------------------------------------\r\n\t\t\tbool IsA(ChilliSource::InterfaceIDType in_interfaceId) const override;\r\n\t\t\t//-------------------------------------------------\r\n\t\t\t/// Adds default systems to the applications system\r\n\t\t\t/// list.\r\n\t\t\t///\r\n\t\t\t/// @author S Downie\r\n\t\t\t///\r\n\t\t\t/// @param the system list\r\n\t\t\t//-------------------------------------------------\r\n\t\t\tvoid CreateDefaultSystems(ChilliSource::Application* in_application) override;\r\n\t\t\t//-------------------------------------------------\r\n\t\t\t/// @author S Downie\r\n\t\t\t///\r\n            /// @param The maximum frames per second to clamp \r\n\t\t\t/// to. This should be in multiples of 15 \r\n\t\t\t/// (15, 30, 60)\r\n            //-------------------------------------------------\r\n\t\t\tvoid SetPreferredFPS(u32 in_fps) override;\r\n\t\t\t//---------------------------------------------------\r\n\t\t\t/// This will turn VSync on or off. \r\n\t\t\t/// NOTE: This will override the preferred FPS\r\n\t\t\t///\r\n\t\t\t/// @author S Downie\r\n\t\t\t///\r\n\t\t\t/// @param Enable/Disable\r\n\t\t\t//---------------------------------------------------\r\n\t\t\tvoid SetVSyncEnabled(bool in_enabled) override;\r\n\t\t\t//-------------------------------------------------\r\n\t\t\t/// Stops the update loop causing the application \r\n\t\t\t/// to terminate.\r\n\t\t\t///\r\n\t\t\t/// @author S Downie\r\n\t\t\t//-------------------------------------------------\r\n\t\t\tvoid Quit() override;\r\n\r\n\t\tprivate:\r\n\t\t\tfriend ChilliSource::PlatformSystemUPtr ChilliSource::PlatformSystem::Create();\r\n\t\t\t//--------------------------------------------------\r\n\t\t\t/// Private constructor to enforce use of create\r\n\t\t\t/// method.\r\n\t\t\t///\r\n\t\t\t/// @author S Downie\r\n\t\t\t//-------------------------------------------------\r\n\t\t\tPlatformSystem();\r\n\t\t};\r\n\t}\r\n}\r\n\r\n#endif\r\n\r\n#endif\r\n"
  },
  {
    "path": "Source/CSBackend/Platform/Windows/Core/Base/Screen.cpp",
    "content": "//\r\n//  Screen.cpp\r\n//  ChilliSource\r\n//  Created by Ian Copland on 28/04/2014.\r\n//\r\n//  The MIT License (MIT)\r\n//\r\n//  Copyright (c) 2014 Tag Games Limited\r\n//\r\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\r\n//  of this software and associated documentation files (the \"Software\"), to deal\r\n//  in the Software without restriction, including without limitation the rights\r\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\n//  copies of the Software, and to permit persons to whom the Software is\r\n//  furnished to do so, subject to the following conditions:\r\n//\r\n//  The above copyright notice and this permission notice shall be included in\r\n//  all copies or substantial portions of the Software.\r\n//\r\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r\n//  THE SOFTWARE.\r\n//\r\n\r\n#ifdef CS_TARGETPLATFORM_WINDOWS\r\n\r\n#include <CSBackend/Platform/Windows/Core/Base/Screen.h>\r\n\r\n#include <ChilliSource/Core/Base/Application.h>\r\n#include <ChilliSource/Core/Delegate/MakeDelegate.h>\r\n#include <ChilliSource/Core/Threading/TaskScheduler.h>\r\n\r\nnamespace CSBackend\r\n{\r\n    namespace Windows\r\n    {\r\n        CS_DEFINE_NAMEDTYPE(Screen);\r\n        //-------------------------------------------------------\r\n        //-------------------------------------------------------\r\n        Screen::Screen(const ChilliSource::ScreenInfo& screenInfo)\r\n            : m_screenInfo(screenInfo)\r\n        {\r\n            m_resolution.x = screenInfo.GetInitialResolution().x;\r\n            m_resolution.y = screenInfo.GetInitialResolution().y;\r\n\r\n            SFMLWindow::Get()->SetWindowDelegates(ChilliSource::MakeDelegate(this, &Screen::OnResolutionChanged), ChilliSource::MakeDelegate(this, &Screen::OnDisplayModeChanged));\r\n        }\r\n        //-------------------------------------------------------\r\n        //-------------------------------------------------------\r\n        bool Screen::IsA(ChilliSource::InterfaceIDType in_interfaceId) const\r\n        {\r\n            return (ChilliSource::Screen::InterfaceID == in_interfaceId || Screen::InterfaceID == in_interfaceId);\r\n        }\r\n        //-----------------------------------------------------------\r\n        //-----------------------------------------------------------\r\n        const ChilliSource::Vector2& Screen::GetResolution() const\r\n        {\r\n            return m_resolution;\r\n        }\r\n        //-----------------------------------------------------------\r\n        //-----------------------------------------------------------\r\n        f32 Screen::GetDensityScale() const\r\n        {\r\n            return m_screenInfo.GetDensityScale();\r\n        }\r\n        //----------------------------------------------------------\r\n        //-----------------------------------------------------------\r\n        f32 Screen::GetInverseDensityScale() const\r\n        {\r\n            return m_screenInfo.GetInverseDensityScale();\r\n        }\r\n        //-----------------------------------------------------------\r\n        //-----------------------------------------------------------\r\n        ChilliSource::IConnectableEvent<Screen::ResolutionChangedDelegate>& Screen::GetResolutionChangedEvent()\r\n        {\r\n            return m_resolutionChangedEvent;\r\n        }\r\n\t\t//-----------------------------------------------------------\r\n\t\t//-----------------------------------------------------------\r\n\t\tChilliSource::IConnectableEvent<Screen::DisplayModeChangedDelegate>& Screen::GetDisplayModeChangedEvent()\r\n\t\t{\r\n\t\t\treturn m_displayModeChangedEvent;\r\n\t\t}\r\n\t\t//----------------------------------------------------------\r\n\t\t//----------------------------------------------------------\r\n\t\tvoid Screen::SetResolution(const ChilliSource::Integer2& in_size)\r\n\t\t{\r\n            ChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_system, [=](const ChilliSource::TaskContext& taskContext)\r\n            {\r\n                SFMLWindow::Get()->SetSize(in_size);\r\n                OnResolutionChanged(in_size);\r\n            });\r\n\t\t}\r\n\t\t//----------------------------------------------------------\r\n\t\t//----------------------------------------------------------\r\n\t\tvoid Screen::SetDisplayMode(DisplayMode in_mode)\r\n\t\t{\r\n            ChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_system, [=](const ChilliSource::TaskContext& taskContext)\r\n            {\r\n\t\t\t\tSFMLWindow::Get()->SetDisplayMode(in_mode, SFMLWindow::Get()->GetWindowSize());\r\n            });\r\n\t\t}\r\n\t\t//----------------------------------------------------------\r\n\t\t//----------------------------------------------------------\r\n\t\tstd::vector<ChilliSource::Integer2> Screen::GetSupportedFullscreenResolutions() const\r\n\t\t{\r\n            return m_screenInfo.GetSupportedFullscreenResolutions();\r\n\t\t}\r\n        //-----------------------------------------------------------\r\n        //------------------------------------------------------------\r\n        void Screen::OnResolutionChanged(const ChilliSource::Integer2& in_resolution)\r\n        {\r\n            ChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_mainThread, [=](const ChilliSource::TaskContext& taskContext)\r\n            {\r\n                m_resolution.x = (f32)in_resolution.x;\r\n                m_resolution.y = (f32)in_resolution.y;\r\n\r\n                m_resolutionChangedEvent.NotifyConnections(m_resolution);\r\n            });\r\n        }\r\n\t\t//----------------------------------------------------------\r\n\t\t//----------------------------------------------------------\r\n\t\tvoid Screen::OnDisplayModeChanged(DisplayMode in_mode)\r\n\t\t{\r\n            ChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_mainThread, [=](const ChilliSource::TaskContext& taskContext)\r\n            {\r\n\t\t\t\tm_displayModeChangedEvent.NotifyConnections(in_mode);\r\n            });\r\n\t\t}\r\n\t\t//------------------------------------------------\r\n\t\t//------------------------------------------------\r\n\t\tvoid Screen::OnInit()\r\n\t\t{\r\n\t\t}\r\n\t\t//------------------------------------------------\r\n\t\t//------------------------------------------------\r\n\t\tvoid Screen::OnDestroy()\r\n\t\t{\r\n            SFMLWindow::Get()->RemoveWindowDelegates();\r\n\t\t}\r\n    }\r\n}\r\n\r\n#endif\r\n"
  },
  {
    "path": "Source/CSBackend/Platform/Windows/Core/Base/Screen.h",
    "content": "//\r\n//  Screen.h\r\n//  ChilliSource\r\n//  Created by Ian Copland on 28/04/2014.\r\n//\r\n//  The MIT License (MIT)\r\n//\r\n//  Copyright (c) 2014 Tag Games Limited\r\n//\r\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\r\n//  of this software and associated documentation files (the \"Software\"), to deal\r\n//  in the Software without restriction, including without limitation the rights\r\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\n//  copies of the Software, and to permit persons to whom the Software is\r\n//  furnished to do so, subject to the following conditions:\r\n//\r\n//  The above copyright notice and this permission notice shall be included in\r\n//  all copies or substantial portions of the Software.\r\n//\r\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r\n//  THE SOFTWARE.\r\n//\r\n\r\n#ifdef CS_TARGETPLATFORM_WINDOWS\r\n\r\n#ifndef _CSBACKEND_PLATFORM_WINDOWS_CORE_BASE_SCREEN_H_\r\n#define _CSBACKEND_PLATFORM_WINDOWS_CORE_BASE_SCREEN_H_\r\n\r\n#include <ChilliSource/ChilliSource.h>\r\n#include <ChilliSource/Core/Base/Screen.h>\r\n#include <ChilliSource/Core/Base/ScreenInfo.h>\r\n#include <ChilliSource/Core/Event/Event.h>\r\n#include <CSBackend/Platform/Windows/ForwardDeclarations.h>\r\n#include <CSBackend/Platform/Windows/SFML/Base/SFMLWindow.h>\r\n\r\nnamespace CSBackend\r\n{\r\n    namespace Windows\r\n    {\r\n        //----------------------------------------------------------------\r\n        /// The Windows backend for the screen. This provides information on\r\n        /// the include device's screen such as resolution and density scale.\r\n        ///\r\n        /// @author Ian Copland\r\n        //----------------------------------------------------------------\r\n\t\tclass Screen final : public ChilliSource::Screen\r\n\t\t{\r\n\t\tpublic:\r\n            CS_DECLARE_NAMEDTYPE(Screen);\r\n            //-------------------------------------------------------\r\n\t\t\t/// Queries whether or not this system implements the\r\n            /// interface with the given Id.\r\n\t\t\t///\r\n            /// @author Ian Copland\r\n            ///\r\n\t\t\t/// @param The interface Id.\r\n\t\t\t/// @param Whether system is of given type.\r\n\t\t\t//-------------------------------------------------------\r\n\t\t\tbool IsA(ChilliSource::InterfaceIDType in_interfaceId) const override;\r\n\t\t\t//-----------------------------------------------------------\r\n\t\t\t/// @author Ian Copland\r\n\t\t\t///\r\n\t\t\t/// @return Vector containing the width and height of screen\r\n            /// space available to the application. For a desktop app\r\n            /// this will be the current size of the window. For a mobile\r\n            /// application this will be full size of the screen.\r\n\t\t\t//-----------------------------------------------------------\r\n\t\t\tconst ChilliSource::Vector2& GetResolution() const override;\r\n            //-----------------------------------------------------------\r\n            /// The density scale factor as reported by the device. What\r\n            /// this factor relates to is platform dependant. On iOS it\r\n            /// is relative to a non-retina screen resolution. On Android\r\n            /// it is a factor that changes depending on whether the\r\n            /// screen is considered, low, medium, high or extra high\r\n            /// density.\r\n            ///\r\n            /// @author Ian Copland\r\n            ///\r\n            /// @return The density scale factor of the screen\r\n            //-----------------------------------------------------------\r\n            f32 GetDensityScale() const override;\r\n            //-----------------------------------------------------------\r\n            /// @author Ian Copland\r\n            ///\r\n            /// @return The inverse of density scale factor of the screen\r\n            //-----------------------------------------------------------\r\n            f32 GetInverseDensityScale() const override;\r\n            //-----------------------------------------------------------\r\n            /// @author Ian Copland\r\n\t\t\t///\r\n\t\t\t/// @return An event that is called when the screen resolution\r\n            /// changes.\r\n\t\t\t//-----------------------------------------------------------\r\n            ChilliSource::IConnectableEvent<ResolutionChangedDelegate>& GetResolutionChangedEvent() override;\r\n\t\t\t//-----------------------------------------------------------\r\n\t\t\t/// @author S Downie\r\n\t\t\t///\r\n\t\t\t/// @return An event that is called when the screen display\r\n\t\t\t/// mode changes.\r\n\t\t\t//-----------------------------------------------------------\r\n\t\t\tChilliSource::IConnectableEvent<DisplayModeChangedDelegate>& GetDisplayModeChangedEvent() override;\r\n\t\t\t//----------------------------------------------------------\r\n\t\t\t/// Changes the size of the application window\r\n\t\t\t///\r\n\t\t\t/// @author S Downie\r\n\t\t\t///\r\n\t\t\t/// @param Screen size in pixels\r\n\t\t\t//----------------------------------------------------------\r\n\t\t\tvoid SetResolution(const ChilliSource::Integer2& in_size) override;\r\n\t\t\t//----------------------------------------------------------\r\n\t\t\t/// Set the screen to fullscreen more or windowed mode\r\n\t\t\t/// on platforms where that is allowed. This will include the\r\n\t\t\t/// removal or addition of any status or menu bars\r\n\t\t\t///\r\n\t\t\t/// @author S Downie\r\n\t\t\t//----------------------------------------------------------\r\n\t\t\tvoid SetDisplayMode(DisplayMode in_mode) override;\r\n\t\t\t//----------------------------------------------------------\r\n\t\t\t/// @author S Downie\r\n\t\t\t///\r\n\t\t\t/// @return A list of resolutions supported by the display\r\n\t\t\t//----------------------------------------------------------\r\n\t\t\tstd::vector<ChilliSource::Integer2> GetSupportedFullscreenResolutions() const override;\r\n        private:\r\n            friend ChilliSource::ScreenUPtr ChilliSource::Screen::Create(const ChilliSource::ScreenInfo& screenInfo);\r\n            //-------------------------------------------------------\r\n\t\t\t/// Private constructor to force the use of the Create()\r\n            /// factory method.\r\n\t\t\t///\r\n            /// @author Ian Copland\r\n\t\t\t//-------------------------------------------------------\r\n\t\t\tScreen(const ChilliSource::ScreenInfo& screenInfo);\r\n\t\t\t//------------------------------------------------\r\n\t\t\t/// Initialisation method called at a time when\r\n\t\t\t/// all App Systems have been created. System\r\n\t\t\t/// initialisation occurs in the order they were\r\n\t\t\t/// created.\r\n\t\t\t///\r\n\t\t\t/// @author Ian Copland\r\n\t\t\t//------------------------------------------------\r\n\t\t\tvoid OnInit() override;\r\n\t\t\t//-----------------------------------------------------------\r\n\t\t\t/// Called when the screen resolution changes. This will update\r\n\t\t\t/// the screen resolution and notify listeners that the resolution\r\n\t\t\t/// has changed.\r\n\t\t\t///\r\n\t\t\t/// @author Ian Copland\r\n\t\t\t///\r\n\t\t\t/// @param The new resolution.\r\n\t\t\t//------------------------------------------------------------\r\n\t\t\tvoid OnResolutionChanged(const ChilliSource::Integer2& in_resolution);\r\n\t\t\t//----------------------------------------------------------\r\n\t\t\t/// Triggered when window display mode changes\r\n\t\t\t///\r\n\t\t\t/// @author S Downie\r\n\t\t\t///\r\n\t\t\t/// @param Display mode\r\n\t\t\t//----------------------------------------------------------\r\n\t\t\tvoid OnDisplayModeChanged(DisplayMode in_mode);\r\n\t\t\t//------------------------------------------------\r\n\t\t\t/// Called when the application is being destroyed.\r\n\t\t\t/// This should be used to cleanup memory and\r\n\t\t\t/// references to other systems. System destruction\r\n\t\t\t/// occurs in the reverse order to which they\r\n\t\t\t/// were created\r\n\t\t\t///\r\n\t\t\t/// @author Ian Copland\r\n\t\t\t//------------------------------------------------\r\n\t\t\tvoid OnDestroy() override;\r\n            \r\n            ChilliSource::Vector2 m_resolution;\r\n            ChilliSource::ScreenInfo m_screenInfo;\r\n\r\n            ChilliSource::Event<ResolutionChangedDelegate> m_resolutionChangedEvent;\r\n\t\t\tChilliSource::Event<DisplayModeChangedDelegate> m_displayModeChangedEvent;\r\n\t\t\tChilliSource::EventConnectionUPtr m_windowResizeConnection;\r\n\t\t\tChilliSource::EventConnectionUPtr m_displayModeChangeConnection;\r\n        };\r\n    }\r\n}\r\n\r\n#endif\r\n\r\n#endif\r\n"
  },
  {
    "path": "Source/CSBackend/Platform/Windows/Core/Base/SystemInfoFactory.cpp",
    "content": "//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_WINDOWS\n\n#include <ChilliSource/Core/Base/DeviceInfo.h>\n#include <ChilliSource/Core/Base/ScreenInfo.h>\n#include <ChilliSource/Core/Base/SystemInfo.h>\n#include <ChilliSource/Core/String/StringUtils.h>\n\n#include <CSBackend/Platform/Windows/Core/Base/Screen.h>\n#include <CSBackend/Platform/Windows/Core/Base/SystemInfoFactory.h>\n#include <CSBackend/Platform/Windows/Core/String/WindowsStringUtils.h>\r\n#include <CSBackend/Rendering/OpenGL/Base/RenderInfoFactory.h>\n\n#include <algorithm>\n#include <vector>\n\n//this needs to be included last\n#include <Windows.h>\n\n#pragma comment(lib, \"version.lib\" )\n\nnamespace CSBackend\n{\n    namespace Windows\n    {\n        namespace\n        {\n            const std::string k_defaultLocale = \"en_US\";\n            const std::string k_defaultLanguage = \"en\";\n            const std::string k_deviceModel = \"Windows\";\n            const std::string k_deviceModelType = \"PC\";\n            const std::string k_deviceManufacturer = \"Microsoft\";\n            const std::string k_deviceUdid = \"FAKE ID\";\n\n            /// This reads the version info of the \n            /// kernel32.dll system library and pulls the\n            /// OS version from it, as recommended by\n            /// MSDN:\n            ///\n            /// https://msdn.microsoft.com/en-us/library/windows/desktop/ms724429(v=vs.85).aspx\n            ///\n            /// @return The OS version number string.\n            ///\n            std::string GetOSVersion() noexcept\n            {\n                // This is based off the answer given by Chuck Walbourn here: http://stackoverflow.com/questions/22303824/warning-c4996-getversionexw-was-declared-deprecated\n\n                WCHAR path[_MAX_PATH];\n                if (!GetSystemDirectoryW(path, _MAX_PATH))\n                {\n                    CS_LOG_FATAL(\"Failed to get the system directory path.\");\n                }\n\n                wcscat_s(path, L\"\\\\kernel32.dll\");\n\n                DWORD handle;\n                DWORD len = GetFileVersionInfoSizeExW(FILE_VER_GET_NEUTRAL, path, &handle);\n                CS_ASSERT(len > 0, \"Failed to get the kernel32.dll file version info size.\");\n\n                std::unique_ptr<uint8_t> buff(new uint8_t[len]);\n                if (!GetFileVersionInfoExW(FILE_VER_GET_NEUTRAL, path, 0, len, buff.get()))\n                {\n                    CS_LOG_FATAL(\"Failed to get the kernel32.dll file version info.\");\n                }\n\n                VS_FIXEDFILEINFO *vInfo = nullptr;\n                UINT infoSize;\n\n                if (!VerQueryValueW(buff.get(), L\"\\\\\", reinterpret_cast<LPVOID*>(&vInfo), &infoSize))\n                {\n                    CS_LOG_FATAL(\"Failed to query version info.\");\n                }\n\n                if (infoSize == 0)\n                {\n                    CS_LOG_FATAL(\"Info size is 0.\");\n                }\n\n                return ChilliSource::ToString(HIWORD(vInfo->dwFileVersionMS)) + \".\" +\n                    ChilliSource::ToString(LOWORD(vInfo->dwFileVersionMS)) + \".\" +\n                    ChilliSource::ToString(HIWORD(vInfo->dwFileVersionLS)) + \".\" +\n                    ChilliSource::ToString(LOWORD(vInfo->dwFileVersionLS));\n            }\n\n            /// @return The current locale.\n            ///\n            std::string GetLocale() noexcept\n            {\n                wchar_t localeName[LOCALE_NAME_MAX_LENGTH * sizeof(wchar_t)] = { 0 };\n\n                if (GetUserDefaultLocaleName(localeName, LOCALE_NAME_MAX_LENGTH * sizeof(wchar_t)))\n                {\n                    std::wstring wideLocale(localeName);\n                    std::string locale = WindowsStringUtils::UTF16ToUTF8(wideLocale);\n                    std::replace(locale.begin(), locale.end(), '-', '_');\n                    return locale;\n                }\n\n                return k_defaultLocale;\n            }\n\n            /// Returns the language portion of a locale code.\n            ///\n            /// @param The locale code.\n            ///\n            /// @return The language code.\n            ///\n            std::string ParseLanguageFromLocale(const std::string& in_locale) noexcept\n            {\n                std::vector<std::string> strLocaleBrokenUp = ChilliSource::StringUtils::Split(in_locale, \"_\", 0);\n\n                if (strLocaleBrokenUp.size() > 0)\n                {\n                    return strLocaleBrokenUp[0];\n                }\n                else\n                {\n                    return k_defaultLanguage;\n                }\n            }\n\n            /// @return The number of cores.\n            ///\n            u32 GetNumberOfCPUCores() noexcept\n            {\n                SYSTEM_INFO SysInfo;\n                GetSystemInfo(&SysInfo);\n                return SysInfo.dwNumberOfProcessors;\n            }\n\n            /// @return The screen's current resolution.\n            ///\n            ChilliSource::Vector2 GetScreenResolution() noexcept\n            {\n                ChilliSource::Integer2 resolution = SFMLWindow::Get()->GetWindowSize();\n                return ChilliSource::Vector2((f32)resolution.x, (f32)resolution.y);\n            }\n\n            /// @return A list of resolutions supported by the display\n            ///\n            std::vector<ChilliSource::Integer2> GetSupportedFullscreenResolutions() noexcept\n            {\n                return SFMLWindow::Get()->GetSupportedFullscreenResolutions();\n            }\n\n        }\n\n        //--------------------------------------------------------------------------------\n        ChilliSource::SystemInfoCUPtr SystemInfoFactory::CreateSystemInfo() noexcept\n        {\n            // Create DeviceInfo.\n            ChilliSource::DeviceInfo deviceInfo(k_deviceModel, k_deviceModelType, k_deviceManufacturer, k_deviceUdid, GetLocale(), ParseLanguageFromLocale(GetLocale()), GetOSVersion(), GetNumberOfCPUCores());\n\n            // Create ScreenInfo.\n            ChilliSource::ScreenInfo screenInfo(GetScreenResolution(), 1.0f, 1.0f, GetSupportedFullscreenResolutions());\n\r\n\t\t\t//Create RenderInfo\r\n\t\t\tChilliSource::RenderInfo renderInfo = OpenGL::RenderInfoFactory::CreateRenderInfo();\n\n            // Create SystemInfo.\n            ChilliSource::SystemInfoUPtr systemInfo(new ChilliSource::SystemInfo(deviceInfo, screenInfo, renderInfo, \"\"));\n\n            return std::move(systemInfo);\n        }\n        \n    }\n}\n\n#endif"
  },
  {
    "path": "Source/CSBackend/Platform/Windows/Core/Base/SystemInfoFactory.h",
    "content": "//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_WINDOWS\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Base/SystemInfo.h>\n#include <CSBackend/Platform/Windows/ForwardDeclarations.h>\n\nnamespace CSBackend\n{\n    namespace Windows\n    {\n        /// A factory for creating new instances of SystemInfo. This will query the Windows\n        /// API to gather information about the device.\n        ///\n        namespace SystemInfoFactory\n        {\n            /// This function creates the new SystemInfo instance.\n            /// @return The new instance.\n            ///\n            ChilliSource::SystemInfoCUPtr CreateSystemInfo() noexcept;\n        }\n    }\n}\n\n#endif"
  },
  {
    "path": "Source/CSBackend/Platform/Windows/Core/DialogueBox/DialogueBoxSystem.cpp",
    "content": "//\r\n//  DialogueBoxSystem.cpp\r\n//  ChilliSource\r\n//  Created by Ian Copland on 04/03/2014.\r\n//\r\n//  The MIT License (MIT)\r\n//\r\n//  Copyright (c) 2014 Tag Games Limited\r\n//\r\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\r\n//  of this software and associated documentation files (the \"Software\"), to deal\r\n//  in the Software without restriction, including without limitation the rights\r\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\n//  copies of the Software, and to permit persons to whom the Software is\r\n//  furnished to do so, subject to the following conditions:\r\n//\r\n//  The above copyright notice and this permission notice shall be included in\r\n//  all copies or substantial portions of the Software.\r\n//\r\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r\n//  THE SOFTWARE.\r\n//\r\n\r\n#ifdef CS_TARGETPLATFORM_WINDOWS\r\n\r\n#include <CSBackend/Platform/Windows/Core/DialogueBox/DialogueBoxSystem.h>\r\n\r\n#include <ChilliSource/Core/Base/Application.h>\r\n#include <ChilliSource/Core/Base/PlatformSystem.h>\r\n#include <ChilliSource/Core/Threading/TaskScheduler.h>\r\n#include <CSBackend/Platform/Windows/Core/String/WindowsStringUtils.h>\r\n#include <CSBackend/Platform/Windows/SFML/Base/SFMLWindow.h>\r\n\r\n#include <windows.h>\r\n\r\nnamespace CSBackend\r\n{\r\n\tnamespace Windows\r\n\t{\r\n        CS_DEFINE_NAMEDTYPE(DialogueBoxSystem);\r\n        //----------------------------------------------------\r\n        //----------------------------------------------------\r\n        DialogueBoxSystem::DialogueBoxSystem()\r\n        {\r\n        }\r\n        //----------------------------------------------------\r\n        //----------------------------------------------------\r\n        bool DialogueBoxSystem::IsA(ChilliSource::InterfaceIDType in_interfaceId) const\r\n        {\r\n            return (DialogueBoxSystem::InterfaceID == in_interfaceId || ChilliSource::DialogueBoxSystem::InterfaceID == in_interfaceId);\r\n        }\r\n        //-----------------------------------------------------\r\n        //-----------------------------------------------------\r\n\t\tvoid DialogueBoxSystem::ShowSystemDialogue(u32 in_id, const ChilliSource::DialogueBoxSystem::DialogueDelegate& in_delegate, const std::string& in_title, const std::string& in_message, const std::string& in_confirm)\r\n        {\r\n            CS_ASSERT(ChilliSource::Application::Get()->GetTaskScheduler()->IsMainThread(), \"System Dialogue requested outside of main thread.\");\r\n            ChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(CS::TaskType::k_system, [=](const CS::TaskContext& in_taskContext)\r\n            {\r\n                MessageBox(SFMLWindow::Get()->GetWindowHandle(), WindowsStringUtils::UTF8ToUTF16(in_message).c_str(), WindowsStringUtils::UTF8ToUTF16(in_title).c_str(), MB_OK);\r\n                if (in_delegate)\r\n                {\r\n                    ChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(CS::TaskType::k_mainThread, [=](const CS::TaskContext& in_taskContext)\r\n                    {\r\n                        in_delegate(in_id, DialogueResult::k_confirm);\r\n                    });\r\n                }\r\n            });\r\n        }\r\n        //-----------------------------------------------------\r\n        //-----------------------------------------------------\r\n\t\tvoid DialogueBoxSystem::ShowSystemConfirmDialogue(u32 in_id, const ChilliSource::DialogueBoxSystem::DialogueDelegate& in_delegate, const std::string& in_title, const std::string& in_message, const std::string& in_confirm, const std::string& in_cancel)\r\n        {\r\n            CS_ASSERT(ChilliSource::Application::Get()->GetTaskScheduler()->IsMainThread(), \"System Confirm Dialogue requested outside of main thread.\");\r\n            ChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(CS::TaskType::k_system, [=](const CS::TaskContext& in_taskContext)\r\n            {\r\n\t\t\t    if (MessageBox(SFMLWindow::Get()->GetWindowHandle(), WindowsStringUtils::UTF8ToUTF16(in_message).c_str(), WindowsStringUtils::UTF8ToUTF16(in_title).c_str(), MB_OKCANCEL) == IDOK)\r\n\t\t\t    {\r\n\t\t\t\t    if (in_delegate)\r\n\t\t\t\t    {\r\n                        ChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(CS::TaskType::k_mainThread, [=](const CS::TaskContext& in_taskContext)\r\n                        {\r\n                            in_delegate(in_id, DialogueResult::k_confirm);\r\n                        });\r\n\t\t\t\t    }\r\n\t\t\t    }\r\n\t\t\t    else\r\n\t\t\t    {\r\n\t\t\t\t    if (in_delegate)\r\n\t\t\t\t    {\r\n                        ChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(CS::TaskType::k_mainThread, [=](const CS::TaskContext& in_taskContext)\r\n                        {\r\n                            in_delegate(in_id, DialogueResult::k_cancel);\r\n                        });\r\n\t\t\t\t    }\r\n\t\t\t    }\r\n            });\r\n        }\r\n        //-----------------------------------------------------\r\n        //-----------------------------------------------------\r\n\t\tvoid DialogueBoxSystem::MakeToast(const std::string& in_text)\r\n        {\r\n\t\t\tCS_LOG_WARNING(\"Toast not available on Windows\");\r\n        }\r\n        //-----------------------------------------------------\r\n        //-----------------------------------------------------\r\n        DialogueBoxSystem::~DialogueBoxSystem()\r\n        {\r\n        }\r\n\t}\r\n}\r\n\r\n#endif\r\n"
  },
  {
    "path": "Source/CSBackend/Platform/Windows/Core/DialogueBox/DialogueBoxSystem.h",
    "content": "//\r\n//  DialogueBoxSystem.h\r\n//  ChilliSource\r\n//  Created by Ian Copland on 04/03/2014.\r\n//\r\n//  The MIT License (MIT)\r\n//\r\n//  Copyright (c) 2014 Tag Games Limited\r\n//\r\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\r\n//  of this software and associated documentation files (the \"Software\"), to deal\r\n//  in the Software without restriction, including without limitation the rights\r\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\n//  copies of the Software, and to permit persons to whom the Software is\r\n//  furnished to do so, subject to the following conditions:\r\n//\r\n//  The above copyright notice and this permission notice shall be included in\r\n//  all copies or substantial portions of the Software.\r\n//\r\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r\n//  THE SOFTWARE.\r\n//\r\n\r\n#ifdef CS_TARGETPLATFORM_WINDOWS\r\n\r\n#ifndef _CSBACKEND_PLATFORM_WINDOWS_CORE_DIALOGUE_DIALOGUESYSTEM_H_\r\n#define _CSBACKEND_PLATFORM_WINDOWS_CORE_DIALOGUE_DIALOGUESYSTEM_H_\r\n\r\n#include <ChilliSource/ChilliSource.h>\r\n#include <CSBackend/Platform/iOS/ForwardDeclarations.h>\r\n#include <ChilliSource/Core/DialogueBox/DialogueBoxSystem.h>\r\n\r\nnamespace CSBackend\r\n{\r\n\tnamespace Windows\r\n\t{\r\n\t\t//-----------------------------------------------------------\r\n\t\t/// A system used to display platform specific system\r\n        /// dialogue boxes.\r\n\t\t//-----------------------------------------------------------\r\n\t\tclass DialogueBoxSystem final : public ChilliSource::DialogueBoxSystem\r\n\t\t{\r\n\t\tpublic:\r\n            CS_DECLARE_NAMEDTYPE(DialogueBoxSystem);\r\n            //----------------------------------------------------\r\n            /// Is A\r\n            ///\r\n            /// @return Whether this implements the passed in\r\n            /// interface id.\r\n            //-----------------------------------------------------\r\n            bool IsA(ChilliSource::InterfaceIDType in_interfaceId) const override;\r\n            //-----------------------------------------------------\r\n            /// Display a system dialog with the given ID and delegate\r\n            ///\r\n            /// This isn't thread-safe and must be called on the main thread.\r\n            ///\r\n            /// @author Ian Copland\r\n            ///\r\n            /// @param ID\r\n            /// @param SystemConfirmDialogDelegate\r\n            /// @param Title text (UTF-8)\r\n            /// @param Message text (UTF-8)\r\n            /// @param Confirm text (UTF-8)\r\n            //------------------------------------------------------\r\n\t\t\tvoid ShowSystemDialogue(u32 in_id, const ChilliSource::DialogueBoxSystem::DialogueDelegate& in_delegate, const std::string& in_title, const std::string& in_message, const std::string& in_confirm) override;\r\n            //-----------------------------------------------------\r\n            /// Display a system confirmation dialog with the given\r\n            /// ID and delegate.\r\n            ///\r\n            /// This isn't thread-safe and must be called on the main thread.\r\n            ///\r\n            /// @author Ian Copland\r\n            ///\r\n            /// @param ID\r\n            /// @param SystemConfirmDialogDelegate\r\n            /// @param Title text (UTF-8)\r\n            /// @param Message text (UTF-8)\r\n            /// @param Confirm text (UTF-8)\r\n            /// @param Cancel text (UTF-8)\r\n            //-----------------------------------------------------\r\n\t\t\tvoid ShowSystemConfirmDialogue(u32 in_id, const ChilliSource::DialogueBoxSystem::DialogueDelegate& in_delegate, const std::string& in_title, const std::string& in_message, const std::string& in_confirm, const std::string& in_cancel) override;\r\n            //-----------------------------------------------------\r\n            /// Display a toast notification with the given text\r\n            /// Note: this does nothing on Windows.\r\n            ///\r\n            /// @author Ian Copland\r\n            ///\r\n            /// @param The text to display (UTF-8).\r\n            //-----------------------------------------------------\r\n            void MakeToast(const std::string& in_text) override;\r\n            //----------------------------------------------------\r\n\t\t\t/// Destructor.\r\n            ///\r\n            /// @author Ian Copland\r\n\t\t\t//----------------------------------------------------\r\n            ~DialogueBoxSystem();\r\n        private:\r\n\t\t\tfriend ChilliSource::DialogueBoxSystemUPtr ChilliSource::DialogueBoxSystem::Create();\r\n\r\n\t\t\t//----------------------------------------------------\r\n\t\t\t/// Constructor\r\n\t\t\t///\r\n\t\t\t/// @author Ian Copland\r\n\t\t\t//----------------------------------------------------\r\n\t\t\tDialogueBoxSystem();\r\n\r\n\t\t};\r\n\t}\r\n}\r\n\r\n#endif\r\n\r\n#endif\r\n"
  },
  {
    "path": "Source/CSBackend/Platform/Windows/Core/File/FileSystem.cpp",
    "content": "//\r\n//  FileSystem.cpp\r\n//  ChilliSource\r\n//  Created by Ian Copland on 25/03/2011.\r\n//\r\n//  The MIT License (MIT)\r\n//\r\n//  Copyright (c) 2011 Tag Games Limited\r\n//\r\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\r\n//  of this software and associated documentation files (the \"Software\"), to deal\r\n//  in the Software without restriction, including without limitation the rights\r\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\n//  copies of the Software, and to permit persons to whom the Software is\r\n//  furnished to do so, subject to the following conditions:\r\n//\r\n//  The above copyright notice and this permission notice shall be included in\r\n//  all copies or substantial portions of the Software.\r\n//\r\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r\n//  THE SOFTWARE.\r\n//\r\n\r\n#ifdef CS_TARGETPLATFORM_WINDOWS\r\n\r\n#include <CSBackend/Platform/Windows/Core/File/FileSystem.h>\r\n\r\n#include <CSBackend/Platform/Windows/Core/String/WindowsStringUtils.h>\r\n#include <ChilliSource/Core/Base/Utils.h>\r\n#include <ChilliSource/Core/String/StringUtils.h>\r\n\r\n#include <iostream>\r\n#include <shlobj.h>\r\n#include <stack>\r\n\r\n//This includes windows so needs to come last, else it might cause problems with other includes\r\n#include <CSBackend/Platform/Windows/Core/File/WindowsFileUtils.h>\r\n\r\n//Undefine the windows file system functions that share names with ours.\r\n#undef CopyFile\r\n#undef DeleteFile\r\n#undef CreateDirectory\r\n\r\nnamespace CSBackend\r\n{\r\n\tnamespace Windows \r\n\t{\r\n\t\tnamespace\r\n\t\t{\r\n\t\t\tconst std::string k_saveDataPath = \"SaveData/\";\r\n\t\t\tconst std::string k_cachePath = \"Cache/\";\r\n\t\t\tconst std::string k_dlcPath = \"DLC/\";\r\n\r\n\t\t\t//--------------------------------------------------------------\r\n\t\t\t/// @author Ian Copland\r\n\t\t\t///\r\n\t\t\t/// @param The file path.\r\n\t\t\t///\r\n\t\t\t/// @return Whether or not the given file path exists.\r\n\t\t\t//--------------------------------------------------------------\r\n\t\t\tbool DoesFileExist(const std::string& in_filePath)\r\n\t\t\t{\r\n\t\t\t\tstd::wstring filePath = WindowsStringUtils::ConvertStandardPathToWindows(in_filePath);\r\n\t\t\t\tDWORD attributes = GetFileAttributes(filePath.c_str());\r\n\r\n\t\t\t\treturn (attributes != INVALID_FILE_ATTRIBUTES && !(attributes & FILE_ATTRIBUTE_DIRECTORY));\r\n\t\t\t}\r\n\t\t\t//--------------------------------------------------------------\r\n\t\t\t/// @author Ian Copland\r\n\t\t\t///\r\n\t\t\t/// @param The directory path.\r\n\t\t\t///\r\n\t\t\t/// @return Whether or not the given directory path exists.\r\n\t\t\t//--------------------------------------------------------------\r\n\t\t\tbool DoesDirectoryExist(const std::string& in_directoryPath)\r\n\t\t\t{\r\n\t\t\t\tstd::wstring directoryPath = WindowsStringUtils::ConvertStandardPathToWindows(in_directoryPath);\r\n\t\t\t\tDWORD attributes = GetFileAttributes(directoryPath.c_str());\r\n\r\n\t\t\t\treturn (attributes != INVALID_FILE_ATTRIBUTES && (attributes & FILE_ATTRIBUTE_DIRECTORY));\r\n\t\t\t}\r\n\t\t\t//--------------------------------------------------------------\r\n\t\t\t/// Creates a new directory at the given path. This will not\r\n\t\t\t/// create intermediate directories.\r\n\t\t\t///\r\n\t\t\t/// @author Ian Copland\r\n\t\t\t///\r\n\t\t\t/// @param The directory path.\r\n\t\t\t///\r\n\t\t\t/// @return Whether or not the directory was created. Returns\r\n\t\t\t/// false if the directory already existed.\r\n\t\t\t//--------------------------------------------------------------\r\n\t\t\tbool CreateDirectory(const std::string& in_directoryPath)\r\n\t\t\t{\r\n\t\t\t\tauto windowsDirectoryPath = WindowsStringUtils::ConvertStandardPathToWindows(in_directoryPath);\r\n\t\t\t\treturn (WindowsFileUtils::WindowsCreateDirectory(windowsDirectoryPath.c_str(), NULL) == TRUE);\r\n\t\t\t}\r\n\t\t\t//--------------------------------------------------------------\r\n\t\t\t/// @author Ian Copland\r\n\t\t\t///\r\n\t\t\t/// @param The directory path.\r\n\t\t\t///\r\n\t\t\t/// @return Whether or not the given directory path exists.\r\n\t\t\t//--------------------------------------------------------------\r\n\t\t\tbool DeleteDirectory(const std::string& in_directoryPath)\r\n\t\t\t{\r\n\t\t\t\tstd::wstring directoryQuery = WindowsStringUtils::ConvertStandardPathToWindows(in_directoryPath) + L\"\\\\*\";\r\n\r\n\t\t\t\tWIN32_FIND_DATA fileData;\r\n\t\t\t\tHANDLE fileHandle = WindowsFileUtils::WindowsFindFirstFile(directoryQuery.c_str(), &fileData);\r\n\t\t\t\tif (fileHandle == INVALID_HANDLE_VALUE)\r\n\t\t\t\t{\r\n\t\t\t\t\treturn false;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tdo\r\n\t\t\t\t{\r\n\t\t\t\t\tif (wcscmp(fileData.cFileName, L\".\") != 0 && wcscmp(fileData.cFileName, L\"..\") != 0)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tif (fileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tstd::string directoryName = WindowsStringUtils::UTF16ToUTF8(fileData.cFileName);\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\tif (DeleteDirectory(ChilliSource::StringUtils::StandardiseDirectoryPath(in_directoryPath + directoryName)) == false)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\treturn false;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\telse\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tstd::string fileName = WindowsStringUtils::UTF16ToUTF8(fileData.cFileName);\r\n\t\t\t\t\t\t\tstd::string filePath = ChilliSource::StringUtils::StandardiseFilePath(in_directoryPath + fileName);\r\n\t\t\t\t\t\t\tif (WindowsFileUtils::WindowsDeleteFile(WindowsStringUtils::ConvertStandardPathToWindows(filePath).c_str()) == FALSE)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\treturn false;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t} while (WindowsFileUtils::WindowsFindNextFile(fileHandle, &fileData) == TRUE);\r\n\r\n\t\t\t\tbool success = (GetLastError() == ERROR_NO_MORE_FILES);\r\n\t\t\t\tFindClose(fileHandle);\r\n\r\n\t\t\t\tif (success == false)\r\n\t\t\t\t{\r\n\t\t\t\t\treturn false;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif (WindowsFileUtils::WindowsRemoveDirectory(WindowsStringUtils::ConvertStandardPathToWindows(in_directoryPath).c_str()) == FALSE)\r\n\t\t\t\t{\r\n\t\t\t\t\treturn false;\r\n\t\t\t\t}\r\n\r\n\t\t\t\treturn true;\r\n\t\t\t}\r\n\t\t\t//--------------------------------------------------------------\r\n\t\t\t/// Lists all files and sub-directories inside the given directory.\r\n\t\t\t/// All paths will be relative to the given directory.\r\n\t\t\t///\r\n\t\t\t/// @author Ian Copland\r\n\t\t\t///\r\n\t\t\t/// @param The directory.\r\n\t\t\t/// @param Whether or not to recurse into sub directories.\r\n\t\t\t/// @param [Out] The sub directories.\r\n\t\t\t/// @param [Out] The files.\r\n\t\t\t/// @param [Optional] The relative directory path. This is used\r\n\t\t\t/// in recursion and shouldn't be set outside of this function.\r\n\t\t\t/// @return Whether or not this succeeded.\r\n\t\t\t//--------------------------------------------------------------\r\n\t\t\tbool ListDirectoryContents(const std::string& in_directoryPath, bool in_recursive, std::vector<std::string>& out_directoryPaths, std::vector<std::string>& out_filePaths, \r\n\t\t\t\tconst std::string& in_relativeDirectoryPath = \"\")\r\n\t\t\t{\r\n\t\t\t\tstd::wstring directoryQuery = WindowsStringUtils::ConvertStandardPathToWindows(in_directoryPath) + L\"\\\\*\";\r\n\r\n\t\t\t\tWIN32_FIND_DATA fileData;\r\n\t\t\t\tHANDLE fileHandle = WindowsFileUtils::WindowsFindFirstFile(directoryQuery.c_str(), &fileData);\r\n\t\t\t\tif (fileHandle == INVALID_HANDLE_VALUE)\r\n\t\t\t\t{\r\n\t\t\t\t\treturn false;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tdo\r\n\t\t\t\t{\r\n\t\t\t\t\tif (wcscmp(fileData.cFileName, L\".\") != 0 && wcscmp(fileData.cFileName, L\"..\") != 0)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tif (fileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tstd::string directoryName = WindowsStringUtils::UTF16ToUTF8(fileData.cFileName);\r\n\t\t\t\t\t\t\tstd::string relativeDirectoryPath = ChilliSource::StringUtils::StandardiseDirectoryPath(in_relativeDirectoryPath + directoryName);\r\n\t\t\t\t\t\t\tout_directoryPaths.push_back(relativeDirectoryPath);\r\n\r\n\t\t\t\t\t\t\tif (in_recursive == true)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tstd::string absoluteDirectoryPath = ChilliSource::StringUtils::StandardiseDirectoryPath(in_directoryPath + directoryName);\r\n\t\t\t\t\t\t\t\tif (ListDirectoryContents(absoluteDirectoryPath, true, out_directoryPaths, out_filePaths, relativeDirectoryPath) == false)\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\treturn false;\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\telse\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tstd::string fileName = WindowsStringUtils::UTF16ToUTF8(fileData.cFileName);\r\n\t\t\t\t\t\t\tstd::string relativeFilePath = ChilliSource::StringUtils::StandardiseFilePath(in_relativeDirectoryPath + fileName);\r\n\t\t\t\t\t\t\tout_filePaths.push_back(relativeFilePath);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t} \r\n\t\t\t\twhile (WindowsFileUtils::WindowsFindNextFile(fileHandle, &fileData) == TRUE);\r\n\r\n\t\t\t\tbool success = (GetLastError() == ERROR_NO_MORE_FILES);\r\n\t\t\t\tFindClose(fileHandle);\r\n\r\n\t\t\t\treturn success;\r\n\t\t\t}\r\n\t\t}\r\n\t\tCS_DEFINE_NAMEDTYPE(FileSystem);\r\n\t\t//--------------------------------------------------------------\r\n\t\t//--------------------------------------------------------------\r\n\t\tFileSystem::FileSystem()\r\n\t\t{\r\n\t\t\twchar_t pathChars[MAX_PATH];\r\n\t\t\tGetModuleFileName(nullptr, pathChars, MAX_PATH);\r\n\t\t\tstd::string path = WindowsStringUtils::ConvertWindowsFilePathToStandard(std::wstring(pathChars));\r\n\t\t\tstd::string::size_type pos = path.find_last_of(\"/\");\r\n\t\t\tstd::string strWorkingDir = ChilliSource::StringUtils::StandardiseDirectoryPath(path.substr(0, pos));\r\n\r\n\t\t\tm_packagePath = strWorkingDir + \"assets/\";\r\n\t\t\tm_documentsPath = strWorkingDir + \"Documents/\";\r\n\r\n\t\t\tCSBackend::Windows::CreateDirectory(m_documentsPath);\r\n\t\t\tCS_ASSERT(CSBackend::Windows::DoesDirectoryExist(m_documentsPath), \"Could not create Documents directory.\");\r\n\r\n\t\t\tCSBackend::Windows::CreateDirectory(GetAbsolutePathToStorageLocation(ChilliSource::StorageLocation::k_saveData));\r\n\t\t\tCS_ASSERT(CSBackend::Windows::DoesDirectoryExist(GetAbsolutePathToStorageLocation(ChilliSource::StorageLocation::k_saveData)), \"Could not create SaveData storage location.\");\r\n\r\n\t\t\tCSBackend::Windows::CreateDirectory(GetAbsolutePathToStorageLocation(ChilliSource::StorageLocation::k_cache));\r\n\t\t\tCS_ASSERT(CSBackend::Windows::DoesDirectoryExist(GetAbsolutePathToStorageLocation(ChilliSource::StorageLocation::k_cache)), \"Could not create Cache storage location.\");\r\n\r\n\t\t\tCSBackend::Windows::CreateDirectory(GetAbsolutePathToStorageLocation(ChilliSource::StorageLocation::k_DLC));\r\n\t\t\tCS_ASSERT(CSBackend::Windows::DoesDirectoryExist(GetAbsolutePathToStorageLocation(ChilliSource::StorageLocation::k_DLC)), \"Could not create DLC storage location.\");\r\n\t\t}\r\n\t\t//----------------------------------------------------------\r\n\t\t//----------------------------------------------------------\r\n\t\tbool FileSystem::IsA(ChilliSource::InterfaceIDType in_interfaceId) const\r\n\t\t{\r\n\t\t\treturn (ChilliSource::FileSystem::InterfaceID == in_interfaceId || FileSystem::InterfaceID == in_interfaceId);\r\n\t\t}\r\n\t\t//--------------------------------------------------------------\r\n        //--------------------------------------------------------------\r\n        ChilliSource::ITextInputStreamUPtr FileSystem::CreateTextInputStream(ChilliSource::StorageLocation in_storageLocation, const std::string& in_filePath) const\r\n        {\r\n        \tstd::string absFilePath = \"\";\r\n\t\t\tif (in_storageLocation == ChilliSource::StorageLocation::k_DLC && DoesFileExistInCachedDLC(in_filePath) == false)\r\n\t\t\t{\r\n\t\t\t\tabsFilePath = GetAbsolutePathToStorageLocation(ChilliSource::StorageLocation::k_package) + GetPackageDLCPath() + in_filePath;\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tabsFilePath = GetAbsolutePathToStorageLocation(in_storageLocation) + in_filePath;\r\n\t\t\t}\r\n\r\n\t\t\tChilliSource::ITextInputStreamUPtr output(new ChilliSource::TextInputStream(absFilePath));\r\n            if (output->IsValid() == true)\r\n            {\r\n                return output;\r\n            }\r\n            else\r\n            {\r\n                return nullptr;\r\n            }\r\n        }\r\n\t\t//--------------------------------------------------------------\r\n\t\t//--------------------------------------------------------------\r\n\t\tChilliSource::IBinaryInputStreamUPtr FileSystem::CreateBinaryInputStream(ChilliSource::StorageLocation in_storageLocation, const std::string& in_filePath) const\r\n\t\t{\r\n\t\t\tstd::string absFilePath = \"\";\r\n\t\t\tif (in_storageLocation == ChilliSource::StorageLocation::k_DLC && DoesFileExistInCachedDLC(in_filePath) == false)\r\n\t\t\t{\r\n\t\t\t\tabsFilePath = GetAbsolutePathToStorageLocation(ChilliSource::StorageLocation::k_package) + GetPackageDLCPath() + in_filePath;\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tabsFilePath = GetAbsolutePathToStorageLocation(in_storageLocation) + in_filePath;\r\n\t\t\t}\r\n\r\n\t\t\tChilliSource::IBinaryInputStreamUPtr output(new ChilliSource::BinaryInputStream(absFilePath));\r\n\t\t\tif (output->IsValid() == true)\r\n\t\t\t{\r\n\t\t\t\treturn output;\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\treturn nullptr;\r\n\t\t\t}\r\n\t\t}\r\n\t\t//--------------------------------------------------------------\r\n\t\t//--------------------------------------------------------------\r\n\t\tChilliSource::TextOutputStreamUPtr FileSystem::CreateTextOutputStream(ChilliSource::StorageLocation in_storageLocation, const std::string& in_filePath, ChilliSource::FileWriteMode in_fileMode) const\r\n\t\t{\r\n\t\t\tCS_ASSERT(IsStorageLocationWritable(in_storageLocation), \"File System: Trying to write to read only storage location.\");\r\n\r\n\t\t\tif (IsStorageLocationWritable(in_storageLocation))\r\n\t\t\t{\r\n\t\t\t\tstd::string absFilePath = GetAbsolutePathToStorageLocation(in_storageLocation) + in_filePath;\r\n\r\n\t\t\t\tChilliSource::TextOutputStreamUPtr output(new ChilliSource::TextOutputStream(absFilePath, in_fileMode));\r\n\t\t\t\tif (output->IsValid() == true)\r\n\t\t\t\t{\r\n\t\t\t\t\treturn output;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\treturn nullptr;\r\n\t\t}\r\n\t\t//--------------------------------------------------------------\r\n\t\t//--------------------------------------------------------------\r\n\t\tChilliSource::BinaryOutputStreamUPtr FileSystem::CreateBinaryOutputStream(ChilliSource::StorageLocation in_storageLocation, const std::string& in_filePath, ChilliSource::FileWriteMode in_fileMode) const\r\n\t\t{\r\n\t\t\tCS_ASSERT(IsStorageLocationWritable(in_storageLocation), \"File System: Trying to write to read only storage location.\");\r\n\r\n\t\t\tif (IsStorageLocationWritable(in_storageLocation))\r\n\t\t\t{\r\n\t\t\t\tstd::string absFilePath = GetAbsolutePathToStorageLocation(in_storageLocation) + in_filePath;\r\n\r\n\t\t\t\tChilliSource::BinaryOutputStreamUPtr output(new ChilliSource::BinaryOutputStream(absFilePath, in_fileMode));\r\n\t\t\t\tif (output->IsValid() == true)\r\n\t\t\t\t{\r\n\t\t\t\t\treturn output;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\treturn nullptr;\r\n\t\t}\r\n\t\t//--------------------------------------------------------------\r\n\t\t//--------------------------------------------------------------\r\n\t\tbool FileSystem::CreateDirectoryPath(ChilliSource::StorageLocation in_storageLocation, const std::string& in_directoryPath) const\r\n\t\t{\r\n\t\t\tCS_ASSERT(IsStorageLocationWritable(in_storageLocation), \"File System: Trying to write to read only storage location.\");\r\n\r\n\t\t\t//get each level of the new directory separately and then iterate though each creating it if it does not already exist.\r\n\t\t\tauto currentDirectoryPath = GetAbsolutePathToStorageLocation(in_storageLocation);\r\n\t\t\tauto relativePathSections = ChilliSource::StringUtils::Split(ChilliSource::StringUtils::StandardiseDirectoryPath(in_directoryPath), \"/\");\r\n\r\n\t\t\tfor (const auto& relativePathSection : relativePathSections)\r\n\t\t\t{\r\n\t\t\t\tcurrentDirectoryPath += ChilliSource::StringUtils::StandardiseDirectoryPath(relativePathSection);\r\n\t\t\t\tif (!CSBackend::Windows::DoesDirectoryExist(currentDirectoryPath))\r\n\t\t\t\t{\r\n\t\t\t\t\tif (!CSBackend::Windows::CreateDirectory(currentDirectoryPath))\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tCS_LOG_ERROR(\"File System: Failed to create directory '\" + in_directoryPath + \"'\");\r\n\t\t\t\t\t\treturn false;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\treturn true;\r\n\t\t}\r\n\t\t//--------------------------------------------------------------\r\n\t\t//--------------------------------------------------------------\r\n\t\tbool FileSystem::CopyFile(ChilliSource::StorageLocation in_sourceStorageLocation, const std::string& in_sourceFilePath, \r\n\t\t\tChilliSource::StorageLocation in_destinationStorageLocation, const std::string& in_destinationFilePath) const\r\n\t\t{\r\n\t\t\tCS_ASSERT(IsStorageLocationWritable(in_destinationStorageLocation), \"File System: Trying to write to read only storage location.\");\r\n            \r\n\t\t\tstd::string sourceFilePath;\r\n\t\t\tif (in_sourceStorageLocation == ChilliSource::StorageLocation::k_DLC && DoesFileExistInCachedDLC(in_sourceFilePath) == false)\r\n\t\t\t{\r\n\t\t\t\tsourceFilePath = GetAbsolutePathToStorageLocation(ChilliSource::StorageLocation::k_package) + GetPackageDLCPath() + ChilliSource::StringUtils::StandardiseFilePath(in_sourceFilePath);\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tsourceFilePath = GetAbsolutePathToStorageLocation(in_sourceStorageLocation) + ChilliSource::StringUtils::StandardiseFilePath(in_sourceFilePath);\r\n\t\t\t}\r\n\r\n\t\t\tif (CSBackend::Windows::DoesFileExist(sourceFilePath) == false)\r\n\t\t\t{\r\n\t\t\t\tCS_LOG_ERROR(\"File System: Trying to copy file '\" + in_sourceFilePath + \"' but it does not exist.\");\r\n\t\t\t\treturn false;\r\n\t\t\t}\r\n\r\n            //get the path to the file\r\n\t\t\tstd::string destinationFileName, destinationDirectoryPath;\r\n\t\t\tChilliSource::StringUtils::SplitFilename(in_destinationFilePath, destinationFileName, destinationDirectoryPath);\r\n            \r\n            //create the output directory\r\n\t\t\tCreateDirectoryPath(in_destinationStorageLocation, destinationDirectoryPath);\r\n            \r\n            //try and copy the files\r\n\t\t\tstd::wstring sourceWPath = WindowsStringUtils::ConvertStandardPathToWindows(sourceFilePath);\r\n\t\t\tstd::wstring destWPath = WindowsStringUtils::ConvertStandardPathToWindows(GetAbsolutePathToStorageLocation(in_destinationStorageLocation) + in_destinationFilePath);\r\n\t\t\tif (WindowsFileUtils::WindowsCopyFile(sourceWPath.c_str(), destWPath.c_str(), FALSE) == FALSE)\r\n\t\t\t{\r\n\t\t\t\tCS_LOG_ERROR(\"File System: Failed to copy file '\" + in_sourceFilePath + \"'\");\r\n\t\t\t\treturn false;\r\n\t\t\t}\r\n\r\n\t\t\treturn true;\r\n\t\t}\r\n\t\t//--------------------------------------------------------------\r\n\t\t//--------------------------------------------------------------\r\n\t\tbool FileSystem::CopyDirectory(ChilliSource::StorageLocation in_sourceStorageLocation, const std::string& in_sourceDirectoryPath, \r\n\t\t\tChilliSource::StorageLocation in_destinationStorageLocation, const std::string& in_destinationDirectoryPath) const\r\n\t\t{\r\n\t\t\tCS_ASSERT(IsStorageLocationWritable(in_destinationStorageLocation), \"File System: Trying to write to read only storage location.\");\r\n\r\n\t\t\tif (DoesDirectoryExist(in_sourceStorageLocation, in_sourceDirectoryPath) == false)\r\n\t\t\t{\r\n\t\t\t\tCS_LOG_ERROR(\"File System: Trying to copy directory '\" + in_sourceDirectoryPath + \"' but it doesn't exist.\");\r\n\t\t\t\treturn false;\r\n\t\t\t}\r\n\r\n\t\t\tstd::vector<std::string> filePaths = GetFilePaths(in_sourceStorageLocation, in_sourceDirectoryPath, true);\r\n\r\n\t\t\t//if the source directory is empty, just create the equivelent directory in the destination\r\n\t\t\tif (filePaths.size() == 0)\r\n\t\t\t{\r\n\t\t\t\tCreateDirectoryPath(in_destinationStorageLocation, in_destinationDirectoryPath);\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tstd::string sourceDirectoryPath = ChilliSource::StringUtils::StandardiseDirectoryPath(in_sourceDirectoryPath);\r\n\t\t\t\tstd::string destinationDirectoryPath = ChilliSource::StringUtils::StandardiseDirectoryPath(in_destinationDirectoryPath);\r\n\t\t\t\tfor (const std::string& filePath : filePaths)\r\n\t\t\t\t{\r\n\t\t\t\t\tif (CopyFile(in_sourceStorageLocation, sourceDirectoryPath + filePath, in_destinationStorageLocation, destinationDirectoryPath + filePath) == false)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tCS_LOG_ERROR(\"File System: Failed to copy directory '\" + in_sourceDirectoryPath + \"'\");\r\n\t\t\t\t\t\treturn false;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\treturn true;\r\n\t\t}\r\n\t\t//--------------------------------------------------------------\r\n\t\t//--------------------------------------------------------------\r\n\t\tbool FileSystem::DeleteFile(ChilliSource::StorageLocation in_storageLocation, const std::string& in_filePath) const\r\n\t\t{\r\n\t\t\tCS_ASSERT(IsStorageLocationWritable(in_storageLocation), \"File System: Trying to delete from a read only storage location.\");\r\n\r\n\t\t\tstd::wstring filePath = WindowsStringUtils::ConvertStandardPathToWindows(GetAbsolutePathToStorageLocation(in_storageLocation) + in_filePath);\r\n\t\t\tif (WindowsFileUtils::WindowsDeleteFile(filePath.c_str()) == FALSE)\r\n\t\t\t{\r\n\t\t\t\treturn false;\r\n\t\t\t}\r\n\r\n\t\t\treturn true;\r\n\t\t}\r\n\t\t//--------------------------------------------------------------\r\n\t\t//--------------------------------------------------------------\r\n\t\tbool FileSystem::DeleteDirectory(ChilliSource::StorageLocation in_storageLocation, const std::string& in_directoryPath) const\r\n\t\t{\r\n\t\t\tCS_ASSERT(IsStorageLocationWritable(in_storageLocation), \"File System: Trying to delete from a read only storage location.\");\r\n\r\n\t\t\tstd::string directoryPath = GetAbsolutePathToStorageLocation(in_storageLocation) + in_directoryPath;\r\n\t\t\tif (CSBackend::Windows::DeleteDirectory(directoryPath) == false)\r\n\t\t\t{\r\n\t\t\t\treturn false;\r\n\t\t\t}\r\n\r\n\t\t\treturn true;\r\n\t\t}\r\n\t\t//--------------------------------------------------------------\r\n\t\t//--------------------------------------------------------------\r\n\t\tstd::vector<std::string> FileSystem::GetFilePaths(ChilliSource::StorageLocation in_storageLocation, const std::string& in_directoryPath, bool in_recursive) const\r\n\t\t{\r\n\t\t\tstd::vector<std::string> possibleDirectories = GetPossibleAbsoluteDirectoryPaths(in_storageLocation, in_directoryPath);\r\n            \r\n\t\t\tstd::vector<std::string> output;\r\n\t\t\tstd::vector<std::string> filePaths;\r\n\t\t\tstd::vector<std::string> directoryPaths;\r\n\t\t\tfor (const std::string& possibleDirectory : possibleDirectories)\r\n\t\t\t{\r\n\t\t\t\tfilePaths.clear();\r\n\t\t\t\tdirectoryPaths.clear();\r\n\r\n\t\t\t\tListDirectoryContents(possibleDirectory, in_recursive, directoryPaths, filePaths);\r\n\t\t\t\toutput.insert(output.end(), filePaths.begin(), filePaths.end());\r\n\t\t\t}\r\n\r\n\t\t\tstd::sort(output.begin(), output.end());\r\n\t\t\tstd::vector<std::string>::iterator it = std::unique(output.begin(), output.end());\r\n\t\t\toutput.resize(it - output.begin());\r\n\t\t\treturn output;\r\n\t\t}\r\n\t\t//--------------------------------------------------------------\r\n\t\t//--------------------------------------------------------------\r\n\t\tstd::vector<std::string> FileSystem::GetDirectoryPaths(ChilliSource::StorageLocation in_storageLocation, const std::string& in_directoryPath, bool in_recursive) const\r\n\t\t{\r\n\t\t\tstd::vector<std::string> possibleDirectories = GetPossibleAbsoluteDirectoryPaths(in_storageLocation, in_directoryPath);\r\n\r\n\t\t\tstd::vector<std::string> output;\r\n\t\t\tstd::vector<std::string> filePaths;\r\n\t\t\tstd::vector<std::string> directoryPaths;\r\n\t\t\tfor (const std::string& possibleDirectory : possibleDirectories)\r\n\t\t\t{\r\n\t\t\t\tfilePaths.clear();\r\n\t\t\t\tdirectoryPaths.clear();\r\n\r\n\t\t\t\tListDirectoryContents(possibleDirectory, in_recursive, directoryPaths, filePaths);\r\n\t\t\t\toutput.insert(output.end(), directoryPaths.begin(), directoryPaths.end());\r\n\t\t\t}\r\n\r\n\t\t\tstd::sort(output.begin(), output.end());\r\n\t\t\tstd::vector<std::string>::iterator it = std::unique(output.begin(), output.end());\r\n\t\t\toutput.resize(it - output.begin());\r\n\t\t\treturn output;\r\n\t\t}\r\n\t\t//--------------------------------------------------------------\r\n\t\t//--------------------------------------------------------------\r\n\t\tbool FileSystem::DoesFileExist(ChilliSource::StorageLocation in_storageLocation, const std::string& in_filePath) const\r\n\t\t{\r\n\t\t\tswitch (in_storageLocation)\r\n\t\t\t{\r\n\t\t\t\tcase ChilliSource::StorageLocation::k_DLC:\r\n\t\t\t\t{\r\n\t\t\t\t\tif (DoesItemExistInDLCCache(in_filePath, false) == true)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\treturn true;\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\treturn DoesFileExist(ChilliSource::StorageLocation::k_package, GetPackageDLCPath() + in_filePath);\r\n\t\t\t\t}\r\n\t\t\t\tdefault:\r\n\t\t\t\t{\r\n\t\t\t\t\tstd::string path = ChilliSource::StringUtils::StandardiseFilePath(GetAbsolutePathToStorageLocation(in_storageLocation) + in_filePath);\r\n\t\t\t\t\treturn CSBackend::Windows::DoesFileExist(path);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\t//--------------------------------------------------------------\r\n\t\t//--------------------------------------------------------------\r\n\t\tbool FileSystem::DoesFileExistInCachedDLC(const std::string& in_filePath) const\r\n\t\t{\r\n\t\t\treturn DoesItemExistInDLCCache(in_filePath, false);\r\n\t\t}\r\n\t\t//--------------------------------------------------------------\r\n\t\t//--------------------------------------------------------------\r\n\t\tbool FileSystem::DoesFileExistInPackageDLC(const std::string& in_filePath) const\r\n\t\t{\r\n\t\t\treturn DoesFileExist(ChilliSource::StorageLocation::k_package, GetPackageDLCPath() + in_filePath);\r\n\t\t}\r\n\t\t//--------------------------------------------------------------\r\n\t\t//--------------------------------------------------------------\r\n\t\tbool FileSystem::DoesDirectoryExist(ChilliSource::StorageLocation in_storageLocation, const std::string& in_directoryPath) const\r\n\t\t{\r\n\t\t\tswitch (in_storageLocation)\r\n\t\t\t{\r\n\t\t\t\tcase ChilliSource::StorageLocation::k_DLC:\r\n\t\t\t\t{\r\n\t\t\t\t\tif (DoesItemExistInDLCCache(in_directoryPath, true) == true)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\treturn true;\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\treturn DoesDirectoryExist(ChilliSource::StorageLocation::k_package, GetPackageDLCPath() + in_directoryPath);\r\n\t\t\t\t}\r\n\t\t\t\tdefault:\r\n\t\t\t\t{\r\n\t\t\t\t\tstd::string path = ChilliSource::StringUtils::StandardiseDirectoryPath(GetAbsolutePathToStorageLocation(in_storageLocation) + in_directoryPath);\r\n\t\t\t\t\treturn CSBackend::Windows::DoesDirectoryExist(path);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\t//--------------------------------------------------------------\r\n\t\t//--------------------------------------------------------------\r\n\t\tbool FileSystem::DoesDirectoryExistInCachedDLC(const std::string& in_directoryPath) const\r\n\t\t{\r\n\t\t\treturn DoesItemExistInDLCCache(in_directoryPath, true);\r\n\t\t}\r\n\t\t//--------------------------------------------------------------\r\n\t\t//--------------------------------------------------------------\r\n\t\tbool FileSystem::DoesDirectoryExistInPackageDLC(const std::string& in_directoryPath) const\r\n\t\t{\r\n\t\t\treturn DoesDirectoryExist(ChilliSource::StorageLocation::k_package, GetPackageDLCPath() + in_directoryPath);\r\n\t\t}\r\n\t\t//--------------------------------------------------------------\r\n\t\t//--------------------------------------------------------------\r\n\t\tstd::string FileSystem::GetAbsolutePathToStorageLocation(ChilliSource::StorageLocation in_storageLocation) const\r\n\t\t{\r\n\t\t\tswitch (in_storageLocation)\r\n\t\t\t{\r\n\t\t\tcase ChilliSource::StorageLocation::k_package:\r\n\t\t\t\treturn m_packagePath + \"AppResources/\";\r\n\t\t\tcase ChilliSource::StorageLocation::k_chilliSource:\r\n\t\t\t\treturn m_packagePath + \"CSResources/\";\r\n\t\t\tcase ChilliSource::StorageLocation::k_saveData:\r\n\t\t\t\treturn m_documentsPath + k_saveDataPath;\r\n\t\t\tcase ChilliSource::StorageLocation::k_cache:\r\n\t\t\t\treturn m_documentsPath + k_cachePath;\r\n\t\t\tcase ChilliSource::StorageLocation::k_DLC:\r\n\t\t\t\treturn m_documentsPath + k_dlcPath;\r\n\t\t\tcase ChilliSource::StorageLocation::k_root:\r\n\t\t\t\treturn \"\";\r\n\t\t\t\tbreak;\r\n\t\t\tdefault:\r\n\t\t\t\tCS_LOG_ERROR(\"Storage Location not available on this platform!\");\r\n\t\t\t\treturn \"\";\r\n\t\t\t}\r\n\t\t}\r\n\t\t//--------------------------------------------------------------\r\n\t\t//--------------------------------------------------------------\r\n\t\tbool FileSystem::DoesItemExistInDLCCache(const std::string& in_path, bool in_isDirectory) const\r\n\t\t{\r\n\t\t\tstd::string path = GetAbsolutePathToStorageLocation(ChilliSource::StorageLocation::k_DLC) + in_path;\r\n\t\t\tif (in_isDirectory == true)\r\n\t\t\t{\r\n\t\t\t\treturn CSBackend::Windows::DoesDirectoryExist(ChilliSource::StringUtils::StandardiseDirectoryPath(path));\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\treturn CSBackend::Windows::DoesFileExist(ChilliSource::StringUtils::StandardiseFilePath(path));\r\n\t\t\t}\r\n\t\t}\r\n\t\t//------------------------------------------------------------\r\n\t\t//------------------------------------------------------------\r\n\t\tstd::vector<std::string> FileSystem::GetPossibleAbsoluteDirectoryPaths(ChilliSource::StorageLocation in_storageLocation, const std::string& in_path) const\r\n\t\t{\r\n\t\t\tstd::vector<std::string> output;\r\n\r\n\t\t\tswitch (in_storageLocation)\r\n\t\t\t{\r\n\t\t\t\tcase ChilliSource::StorageLocation::k_DLC:\r\n\t\t\t\t{\r\n\t\t\t\t\toutput.push_back(GetAbsolutePathToStorageLocation(ChilliSource::StorageLocation::k_package) + GetPackageDLCPath() + in_path);\r\n\t\t\t\t\toutput.push_back(GetAbsolutePathToStorageLocation(ChilliSource::StorageLocation::k_DLC) + in_path);\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\t\t\t\tdefault:\r\n\t\t\t\t{\r\n\t\t\t\t\toutput.push_back(GetAbsolutePathToStorageLocation(in_storageLocation) + in_path);\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\treturn output;\r\n\t\t}\r\n\t}\r\n}\r\n\r\n#endif\r\n"
  },
  {
    "path": "Source/CSBackend/Platform/Windows/Core/File/FileSystem.h",
    "content": "//\r\n//  FileSystem.h\r\n//  ChilliSource\r\n//  Created by Ian Copland on 25/03/2011.\r\n//\r\n//  The MIT License (MIT)\r\n//\r\n//  Copyright (c) 2011 Tag Games Limited\r\n//\r\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\r\n//  of this software and associated documentation files (the \"Software\"), to deal\r\n//  in the Software without restriction, including without limitation the rights\r\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\n//  copies of the Software, and to permit persons to whom the Software is\r\n//  furnished to do so, subject to the following conditions:\r\n//\r\n//  The above copyright notice and this permission notice shall be included in\r\n//  all copies or substantial portions of the Software.\r\n//\r\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r\n//  THE SOFTWARE.\r\n//\r\n\r\n#ifdef CS_TARGETPLATFORM_WINDOWS\r\n\r\n#ifndef _CSBACKEND_WINDOWS_CORE_FILE_FILESYSTEM_H_\r\n#define _CSBACKEND_WINDOWS_CORE_FILE_FILESYSTEM_H_\r\n\r\n#include <CSBackend/Platform/Windows/ForwardDeclarations.h>\r\n#include <ChilliSource/Core/File/FileStream/BinaryInputStream.h>\r\n#include <ChilliSource/Core/File/FileStream/BinaryOutputStream.h>\r\n#include <ChilliSource/Core/File/FileStream/TextInputStream.h>\r\n#include <ChilliSource/Core/File/FileStream/TextOutputStream.h>\r\n#include <ChilliSource/Core/File/FileSystem.h>\r\n\r\n#include <string>\r\n\r\nnamespace CSBackend\r\n{\r\n\tnamespace Windows \r\n\t{\r\n\t\t//-----------------------------------------------------------------\r\n\t\t/// The windows backend for the File System.\r\n\t\t///\r\n\t\t/// @author Ian Copland\r\n\t\t//-----------------------------------------------------------------\r\n\t\tclass FileSystem : public ChilliSource::FileSystem\r\n\t\t{\r\n\t\tpublic:\r\n\t\t\tCS_DECLARE_NAMEDTYPE(FileSystem);\r\n\t\t\t//----------------------------------------------------------\r\n\t\t\t/// Queries whether or not this system implements the\r\n\t\t\t/// interface with the given Id.\r\n\t\t\t///\r\n\t\t\t/// @author Ian Copland\r\n\t\t\t///\r\n\t\t\t/// @param The interface Id.\r\n\t\t\t///\r\n\t\t\t/// @return Whether or not the interface is implemented.\r\n\t\t\t//----------------------------------------------------------\r\n\t\t\tbool IsA(ChilliSource::InterfaceIDType in_interfaceId) const override;\r\n\t\t\t//------------------------------------------------------------------------------\r\n            /// Creates a new input text stream to the given file in the given storage location.\r\n            ///\r\n            /// @author HMcLaughlin\r\n            ///\r\n            /// @param in_storageLocation - The storage location.\r\n            /// @param in_filePath - The file path.\r\n            ///\r\n            /// @return The new file stream. If the stream cannot be created or is invalid,\r\n            /// null be returned.\r\n            //------------------------------------------------------------------------------\r\n            ChilliSource::ITextInputStreamUPtr CreateTextInputStream(ChilliSource::StorageLocation in_storageLocation, const std::string& in_filePath) const override;\r\n\t\t\t//------------------------------------------------------------------------------\r\n\t\t\t/// Creates a new input binary stream to the given file in the given storage location.\r\n\t\t\t///\r\n\t\t\t/// @author HMcLaughlin\r\n\t\t\t///\r\n\t\t\t/// @param in_storageLocation - The storage location.\r\n\t\t\t/// @param in_filePath - The file path.\r\n\t\t\t///\r\n\t\t\t/// @return The new file stream. If the stream cannot be created or is invalid,\r\n\t\t\t/// null be returned.\r\n\t\t\t//------------------------------------------------------------------------------\r\n\t\t\tChilliSource::IBinaryInputStreamUPtr CreateBinaryInputStream(ChilliSource::StorageLocation in_storageLocation, const std::string& in_filePath) const override;\r\n\t\t\t//------------------------------------------------------------------------------\r\n\t\t\t/// Creates a new output text stream to the given file in the given storage location.\r\n\t\t\t///\r\n\t\t\t/// @author HMcLaughlin\r\n\t\t\t///\r\n\t\t\t/// @param in_storageLocation - The storage location.\r\n\t\t\t/// @param in_filePath - The file path.\r\n\t\t\t///\r\n\t\t\t/// @return The new file stream. If the stream cannot be created or is invalid,\r\n\t\t\t/// null be returned.\r\n\t\t\t//------------------------------------------------------------------------------\r\n\t\t\tChilliSource::TextOutputStreamUPtr CreateTextOutputStream(ChilliSource::StorageLocation in_storageLocation, const std::string& in_filePath, ChilliSource::FileWriteMode in_fileMode) const override;\r\n\t\t\t//------------------------------------------------------------------------------\r\n\t\t\t/// Creates a new output binary stream to the given file in the given storage location.\r\n\t\t\t///\r\n\t\t\t/// @author HMcLaughlin\r\n\t\t\t///\r\n\t\t\t/// @param in_storageLocation - The storage location.\r\n\t\t\t/// @param in_filePath - The file path.\r\n\t\t\t///\r\n\t\t\t/// @return The new file stream. If the stream cannot be created or is invalid,\r\n\t\t\t/// null be returned.\r\n\t\t\t//------------------------------------------------------------------------------\r\n\t\t\tChilliSource::BinaryOutputStreamUPtr CreateBinaryOutputStream(ChilliSource::StorageLocation in_storageLocation, const std::string& in_filePath, ChilliSource::FileWriteMode in_fileMode) const override;\r\n\t\t\t//--------------------------------------------------------------\r\n\t\t\t/// Creates the given directory. The full directory hierarchy\r\n\t\t\t/// will be created.\r\n\t\t\t///\r\n\t\t\t/// @author Ian Copland\r\n\t\t\t///\r\n\t\t\t/// @param The Storage Location\r\n\t\t\t/// @param The directory path.\r\n\t\t\t///\r\n            /// @return Whether or not this was successful. Failure to\r\n            /// create the directory because it already exists is considered\r\n            /// a success.\r\n\t\t\t//--------------------------------------------------------------\r\n\t\t\tbool CreateDirectoryPath(ChilliSource::StorageLocation in_storageLocation, const std::string& in_directoryPath) const override;\r\n\t\t\t//--------------------------------------------------------------\r\n\t\t\t/// Copies a file from one location to another.\r\n\t\t\t///\r\n\t\t\t/// @author Ian Copland\r\n\t\t\t///\r\n\t\t\t/// @param The source storage location.\r\n\t\t\t/// @param The source directory.\r\n\t\t\t/// @param The destination storage location.\r\n\t\t\t/// @param The destination directory.\r\n\t\t\t///\r\n\t\t\t/// @return Whether or not the file was successfully copied.\r\n\t\t\t//--------------------------------------------------------------\r\n\t\t\tbool CopyFile(ChilliSource::StorageLocation in_sourceStorageLocation, const std::string& in_sourceFilePath,\r\n\t\t\t\tChilliSource::StorageLocation in_destinationStorageLocation, const std::string& in_destinationFilePath) const override;\r\n\t\t\t//--------------------------------------------------------------\r\n\t\t\t/// Copies a directory from one location to another. If the\r\n\t\t\t/// destination directory does not exist, it will be created.\r\n\t\t\t///\r\n\t\t\t/// @author Ian Copland\r\n\t\t\t///\r\n\t\t\t/// @param The source storage location.\r\n\t\t\t/// @param The source directory.\r\n\t\t\t/// @param The destination storage location.\r\n\t\t\t/// @param The destination directory.\r\n\t\t\t///\r\n\t\t\t/// @return Whether or not the files were successfully copied.\r\n\t\t\t//--------------------------------------------------------------\r\n\t\t\tbool CopyDirectory(ChilliSource::StorageLocation in_sourceStorageLocation, const std::string& in_sourceDirectoryPath,\r\n\t\t\t\tChilliSource::StorageLocation in_destinationStorageLocation, const std::string& in_destinationDirectoryPath) const override;\r\n\t\t\t//--------------------------------------------------------------\r\n\t\t\t/// Deletes the specified file.\r\n\t\t\t///\r\n\t\t\t/// @author Ian Copland\r\n\t\t\t///\r\n\t\t\t/// @param The storage location.\r\n\t\t\t/// @param The filepath.\r\n\t\t\t///\r\n\t\t\t/// @return Whether or not the file was successfully deleted.\r\n\t\t\t//--------------------------------------------------------------\r\n\t\t\tbool DeleteFile(ChilliSource::StorageLocation in_storageLocation, const std::string& in_filepath) const override;\r\n\t\t\t//--------------------------------------------------------------\r\n\t\t\t/// Deletes a directory and all its contents.\r\n\t\t\t///\r\n\t\t\t/// @author Ian Copland\r\n\t\t\t///\r\n\t\t\t/// @param The storage location.\r\n\t\t\t/// @param The directory.\r\n\t\t\t///\r\n\t\t\t/// @return Whether or not the directory was successfully deleted.\r\n\t\t\t//--------------------------------------------------------------\r\n\t\t\tbool DeleteDirectory(ChilliSource::StorageLocation in_storageLocation, const std::string& in_directoryPath) const override;\r\n\t\t\t//--------------------------------------------------------------\r\n\t\t\t/// Creates a dynamic array containing the filenames of each file\r\n\t\t\t/// in the given directory. File paths will be relative to the\r\n\t\t\t/// input directory.\r\n\t\t\t///\r\n\t\t\t/// @author Ian Copland\r\n\t\t\t///\r\n\t\t\t/// @param The Storage Location\r\n\t\t\t/// @param The directory\r\n\t\t\t/// @param Flag to determine whether or not to recurse into sub\r\n\t\t\t/// directories\r\n\t\t\t///\r\n\t\t\t/// @return dynamic array containing the filenames.\r\n\t\t\t//--------------------------------------------------------------\r\n\t\t\tstd::vector<std::string> GetFilePaths(ChilliSource::StorageLocation in_storageLocation, const std::string& in_directoryPath, bool in_recursive) const override;\r\n\t\t\t//--------------------------------------------------------------\r\n\t\t\t/// Creates a dynamic array containing the names of each directory\r\n\t\t\t/// in the given directory. Directory paths will be relative to\r\n\t\t\t/// the input directory.\r\n\t\t\t///\r\n\t\t\t/// @author Ian Copland\r\n\t\t\t///\r\n\t\t\t/// @param The Storage Location\r\n\t\t\t/// @param The directory\r\n\t\t\t/// @param Flag to determine whether or not to recurse into sub\r\n\t\t\t/// directories\r\n\t\t\t///\r\n\t\t\t/// @return Output dynamic array containing the dir names.\r\n\t\t\t//--------------------------------------------------------------\r\n\t\t\tstd::vector<std::string> GetDirectoryPaths(ChilliSource::StorageLocation in_storageLocation, const std::string& in_directoryPath, bool in_recursive) const override;\r\n\t\t\t//--------------------------------------------------------------\r\n\t\t\t/// returns whether or not the given file exists.\r\n\t\t\t///\r\n\t\t\t/// @author Ian Copland\r\n\t\t\t///\r\n\t\t\t/// @param The Storage Location\r\n\t\t\t/// @param The file path\r\n\t\t\t///\r\n\t\t\t/// @return Whether or not it exists.\r\n\t\t\t//--------------------------------------------------------------\r\n\t\t\tbool DoesFileExist(ChilliSource::StorageLocation in_storageLocation, const std::string& in_filePath) const override;\r\n\t\t\t//--------------------------------------------------------------\r\n\t\t\t/// Returns whether or not the file exists in the Cached DLC\r\n\t\t\t/// directory.\r\n\t\t\t///\r\n\t\t\t/// @author Ian Copland\r\n\t\t\t///\r\n\t\t\t/// @param The file path.\r\n\t\t\t///\r\n\t\t\t/// @return Whether or not it is in the cached DLC.\r\n\t\t\t//--------------------------------------------------------------\r\n\t\t\tbool DoesFileExistInCachedDLC(const std::string& in_filePath) const override;\r\n\t\t\t//--------------------------------------------------------------\r\n\t\t\t/// Returns whether or not the file exists in the package DLC\r\n\t\t\t/// directory.\r\n\t\t\t///\r\n\t\t\t/// @author Ian Copland\r\n\t\t\t///\r\n\t\t\t/// @param The file path.\r\n\t\t\t///\r\n\t\t\t/// @return Whether or not it is in the package DLC.\r\n\t\t\t//--------------------------------------------------------------\r\n\t\t\tbool DoesFileExistInPackageDLC(const std::string& in_filePath) const override;\r\n\t\t\t//--------------------------------------------------------------\r\n\t\t\t/// Returns whether or not the given directory exists.\r\n\t\t\t///\r\n\t\t\t/// @author Ian Copland\r\n\t\t\t///\r\n\t\t\t/// @param The Storage Location\r\n\t\t\t/// @param The directory path\r\n\t\t\t///\r\n\t\t\t/// @return Whether or not it exists.\r\n\t\t\t//--------------------------------------------------------------\r\n\t\t\tbool DoesDirectoryExist(ChilliSource::StorageLocation in_storageLocation, const std::string& in_directoryPath) const override;\r\n\t\t\t//--------------------------------------------------------------\r\n\t\t\t/// Returns whether or not the directory exists in the Cached\r\n\t\t\t/// DLC directory.\r\n\t\t\t///\r\n\t\t\t/// @author Ian Copland\r\n\t\t\t///\r\n\t\t\t/// @param in_directoryPath - The directory path.\r\n\t\t\t///\r\n\t\t\t/// @return Whether or not it is in the cached DLC.\r\n\t\t\t//--------------------------------------------------------------\r\n\t\t\tbool DoesDirectoryExistInCachedDLC(const std::string& in_directoryPath) const override;\r\n\t\t\t//--------------------------------------------------------------\r\n\t\t\t/// Returns whether or not the directory exists in the package\r\n\t\t\t/// DLC directory.\r\n\t\t\t///\r\n\t\t\t/// @author Ian Copland\r\n\t\t\t///\r\n\t\t\t/// @param in_directoryPath - The directory path.\r\n\t\t\t///\r\n\t\t\t/// @return Whether or not it is in the package DLC.\r\n\t\t\t//--------------------------------------------------------------\r\n\t\t\tbool DoesDirectoryExistInPackageDLC(const std::string& in_directoryPath) const override;\r\n\t\t\t//--------------------------------------------------------------\r\n\t\t\t/// Returns the absolute path to the given storage location. The\r\n\t\t\t/// value this returns is platform specific and use of this\r\n\t\t\t/// should be kept to a minimum in cross platform projects.\r\n\t\t\t///\r\n\t\t\t/// @author S Downie\r\n\t\t\t///\r\n\t\t\t/// @param The source storage location.\r\n\t\t\t///\r\n\t\t\t/// @return The directory. returns an empty string if the location\r\n\t\t\t/// is not available.\r\n\t\t\t//--------------------------------------------------------------\r\n\t\t\tstd::string GetAbsolutePathToStorageLocation(ChilliSource::StorageLocation in_storageLocation) const override;\r\n            \r\n\t\tprivate:\r\n\t\t\tfriend ChilliSource::FileSystemUPtr ChilliSource::FileSystem::Create();\r\n\t\t\t//--------------------------------------------------------------\r\n\t\t\t/// Private constructor to force use of the factory\r\n\t\t\t/// method.\r\n\t\t\t///\r\n\t\t\t/// @author Ian Copland\r\n\t\t\t//--------------------------------------------------------------\r\n\t\t\tFileSystem();\r\n\t\t\t//--------------------------------------------------------------\r\n\t\t\t/// Returns whether or not a file or directory exists specifically\r\n\t\t\t/// in the DCL cache.\r\n\t\t\t///\r\n\t\t\t/// @author Ian Copland\r\n\t\t\t///\r\n\t\t\t/// @param the filepath.\r\n\t\t\t///\r\n\t\t\t/// @return whether or not it exists.\r\n\t\t\t//--------------------------------------------------------------\r\n\t\t\tbool DoesItemExistInDLCCache(const std::string& in_path, bool in_isDirectory) const;\r\n\t\t\t//------------------------------------------------------------\r\n\t\t\t/// Builds a list of the paths that the given path might refer\r\n\t\t\t/// to in the given storage location. For example, a path in\r\n\t\t\t/// DLC might refer to the DLC cache or the Package DLC.\r\n\t\t\t///\r\n\t\t\t/// @author Ian Copland\r\n\t\t\t///\r\n\t\t\t/// @param Storage location\r\n\t\t\t/// @param File name to append\r\n\t\t\t///\r\n\t\t\t/// @return All the paths for the given location\r\n\t\t\t//------------------------------------------------------------\r\n\t\t\tstd::vector<std::string> GetPossibleAbsoluteDirectoryPaths(ChilliSource::StorageLocation in_storageLocation, const std::string& in_directoryPath) const;\r\n\r\n\t\t\tstd::string m_packagePath;\r\n\t\t\tstd::string m_documentsPath;\r\n\t\t};\r\n\t}\r\n}\r\n\r\n#endif\r\n\r\n#endif\r\n"
  },
  {
    "path": "Source/CSBackend/Platform/Windows/Core/File/WindowsFileUtils.cpp",
    "content": "//\n//  WindowsFileUtils.cpp\n//  ChilliSource\n//  Created by Ian Copland on 28/02/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_WINDOWS\n\n#include <CSBackend/Platform/Windows/Core/File/WindowsFileUtils.h>\n\nnamespace CSBackend\n{\n\tnamespace Windows\n\t{\n\t\tnamespace WindowsFileUtils\n\t\t{\n\t\t\t//--------------------------------------------------------\n\t\t\t//--------------------------------------------------------\n\t\t\tBOOL WindowsCreateDirectory(LPCTSTR in_directory, LPSECURITY_ATTRIBUTES in_securityAttributes)\n\t\t\t{\n\t\t\t\treturn CreateDirectory(in_directory, in_securityAttributes);\n\t\t\t}\n\t\t\t//--------------------------------------------------------\n\t\t\t//--------------------------------------------------------\n\t\t\tBOOL WindowsCopyFile(LPCTSTR in_sourceFilename, LPCTSTR in_destinationFilename, BOOL in_failIfExists)\n\t\t\t{\n\t\t\t\treturn CopyFile(in_sourceFilename, in_destinationFilename, in_failIfExists);\n\t\t\t}\n\t\t\t//--------------------------------------------------------\n\t\t\t//--------------------------------------------------------\n\t\t\tBOOL WindowsDeleteFile(LPCTSTR in_filename)\n\t\t\t{\n\t\t\t\treturn DeleteFile(in_filename);\n\t\t\t}\n\t\t\t//--------------------------------------------------------\n\t\t\t//--------------------------------------------------------\n\t\t\tBOOL WindowsRemoveDirectory(LPCTSTR in_directory)\n\t\t\t{\n\t\t\t\treturn RemoveDirectory(in_directory);\n\t\t\t}\n\t\t\t//--------------------------------------------------------\n\t\t\t//--------------------------------------------------------\n\t\t\tHANDLE WindowsFindFirstFile(LPCTSTR in_directory, LPWIN32_FIND_DATA in_findFileData)\n\t\t\t{\n\t\t\t\treturn FindFirstFile(in_directory, in_findFileData);\n\t\t\t}\n\t\t\t//--------------------------------------------------------\n\t\t\t//--------------------------------------------------------\n\t\t\tBOOL WindowsFindNextFile(HANDLE in_previousFile, LPWIN32_FIND_DATA in_findFileData)\n\t\t\t{\n\t\t\t\treturn FindNextFile(in_previousFile, in_findFileData);\n\t\t\t}\n\t\t}\n\t}\n}\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Windows/Core/File/WindowsFileUtils.h",
    "content": "//\n//  WindowsFileUtils.h\n//  ChilliSource\n//  Created by Ian Copland on 28/02/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_WINDOWS\n\n#ifndef _CSBACKEND_PLATFORM_WINDOWS_FILE_WINDOWSFILEUTILS_H_\n#define _CSBACKEND_PLATFORM_WINDOWS_FILE_WINDOWSFILEUTILS_H_\n\n#include <CSBackend/Platform/Windows/ForwardDeclarations.h>\n\n#include <windows.h>\n\nnamespace CSBackend\n{\n\tnamespace Windows\n\t{\n\t\t//----------------------------------------------------------------\n\t\t/// A wrapper for windows specfic file system functionality. This\n\t\t/// is required becuase windows has defined macros named similarly\n\t\t/// to methods in the engine, meaning we need to undefine them. To\n\t\t/// use them we then need to call though this wrapper.\n\t\t//----------------------------------------------------------------\n\t\tnamespace WindowsFileUtils\n\t\t{\n\t\t\t//--------------------------------------------------------\n\t\t\t/// Creates a new directory using the windows API.\n\t\t\t///\n\t\t\t/// @author Ian Copland\n\t\t\t///\n\t\t\t/// @param the directory to create.\n\t\t\t/// @param The security attributes. Can be null.\n\t\t\t/// @return Whether or not the directory was created.\n\t\t\t//--------------------------------------------------------\n\t\t\tBOOL WindowsCreateDirectory(LPCTSTR in_directory, LPSECURITY_ATTRIBUTES in_securityAttributes);\n\t\t\t//--------------------------------------------------------\n\t\t\t/// Copies a file using the windows API.\n\t\t\t///\n\t\t\t/// @author Ian Copland\n\t\t\t///\n\t\t\t/// @param the source location\n\t\t\t/// @param The destination location.\n\t\t\t/// @param Whether or not to fail if the file already\n\t\t\t/// exists.\n\t\t\t/// @return Whether or not the copy failed.\n\t\t\t//--------------------------------------------------------\n\t\t\tBOOL WindowsCopyFile(LPCTSTR in_sourceFilename, LPCTSTR in_destinationFilename, BOOL in_failIfExists);\n\t\t\t//--------------------------------------------------------\n\t\t\t/// Deletes a file using the windows API.\n\t\t\t///\n\t\t\t/// @author Ian Copland\n\t\t\t///\n\t\t\t/// @param the filename to delete.\n\t\t\t/// @return Whether or not the file was deleted.\n\t\t\t//--------------------------------------------------------\n\t\t\tBOOL WindowsDeleteFile(LPCTSTR in_filename);\n\t\t\t//--------------------------------------------------------\n\t\t\t/// Deletes a directory using the windows API.\n\t\t\t///\n\t\t\t/// @author Ian Copland\n\t\t\t///\n\t\t\t/// @param the directory to delete.\n\t\t\t/// @return Whether or not the directory was deleted.\n\t\t\t//--------------------------------------------------------\n\t\t\tBOOL WindowsRemoveDirectory(LPCTSTR in_directory);\n\t\t\t//--------------------------------------------------------\n\t\t\t/// Firsts the first file in the given directory. The\n\t\t\t/// directory can contain wildcard characters (* or ?).\n\t\t\t///\n\t\t\t/// @author Ian Copland\n\t\t\t///\n\t\t\t/// @param the directory to find.\n\t\t\t/// @param Out: Data on the found file.\n\t\t\t/// @return A handle to the first found file.\n\t\t\t//--------------------------------------------------------\n\t\t\tHANDLE WindowsFindFirstFile(LPCTSTR in_directory, LPWIN32_FIND_DATA in_findFileData);\n\t\t\t//--------------------------------------------------------\n\t\t\t/// Continues a file seach started using FileFirstFile. The\n\t\t\t/// directory can contain wildcard characters (* or ?).\n\t\t\t///\n\t\t\t/// @author Ian Copland\n\t\t\t///\n\t\t\t/// @param the directory to find.\n\t\t\t/// @param Out: Data on the found file.\n\t\t\t/// @return A handle to the first found file.\n\t\t\t//--------------------------------------------------------\n\t\t\tBOOL WindowsFindNextFile(HANDLE in_previousFile, LPWIN32_FIND_DATA in_findFileData);\n\t\t}\n\t}\n}\n\n#endif\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Windows/Core/Image/PNGImageProvider.cpp",
    "content": "//\r\n//  PNGImageProvider.cpp\r\n//  ChilliSource\r\n//  Created by Ian Copland on 05/02/2011.\r\n//\r\n//  The MIT License (MIT)\r\n//\r\n//  Copyright (c) 2011 Tag Games Limited\r\n//\r\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\r\n//  of this software and associated documentation files (the \"Software\"), to deal\r\n//  in the Software without restriction, including without limitation the rights\r\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\n//  copies of the Software, and to permit persons to whom the Software is\r\n//  furnished to do so, subject to the following conditions:\r\n//\r\n//  The above copyright notice and this permission notice shall be included in\r\n//  all copies or substantial portions of the Software.\r\n//\r\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r\n//  THE SOFTWARE.\r\n//\r\n\r\n#ifdef CS_TARGETPLATFORM_WINDOWS\r\n\r\n#include <CSBackend/Platform/Windows/Core/Image/PNGImageProvider.h>\r\n\r\n#include <CSBackend/Platform/Windows/Core/Image/PngImage.h>\r\n#include <ChilliSource/Core/Base/Application.h>\r\n#include <ChilliSource/Core/Image/Image.h>\r\n#include <ChilliSource/Core/Image/ImageCompression.h>\r\n#include <ChilliSource/Core/Image/ImageFormat.h>\r\n#include <ChilliSource/Core/String/StringUtils.h>\r\n#include <ChilliSource/Core/Threading/TaskScheduler.h>\r\n\r\nnamespace CSBackend\r\n{\r\n\tnamespace Windows\r\n\t{\r\n\t\tnamespace\r\n\t\t{\r\n\t\t\tconst std::string k_pngExtension(\"png\");\r\n\r\n\t\t\t//-----------------------------------------------------------\r\n\t\t\t/// Performs the heavy lifting for the 2 create methods\r\n\t\t\t///\r\n\t\t\t/// @author Ian Copland\r\n\t\t\t///\r\n\t\t\t/// @param The storage location.\r\n\t\t\t/// @param The filepath.\r\n\t\t\t/// @param Completion delegate\r\n\t\t\t/// @param [Out] The output resource\r\n\t\t\t//-----------------------------------------------------------\r\n\t\t\tvoid CreatePNGImageFromFile(ChilliSource::StorageLocation in_storageLocation, const std::string& in_filepath, const ChilliSource::ResourceProvider::AsyncLoadDelegate& in_delegate, const ChilliSource::ResourceSPtr& out_resource)\r\n\t\t\t{\r\n\t\t\t\tChilliSource::Image* imageResource = (ChilliSource::Image*)(out_resource.get());\r\n\r\n\t\t\t\t//load the png image\r\n\t\t\t\tPngImage image;\r\n\t\t\t\timage.Load(in_storageLocation, in_filepath);\r\n\r\n\t\t\t\t//check the image has loaded\r\n\t\t\t\tif (image.IsLoaded() == false)\r\n\t\t\t\t{\r\n\t\t\t\t\timage.Release();\r\n\t\t\t\t\tCS_LOG_ERROR(\"Failed to load image: \" + in_filepath);\r\n\t\t\t\t\timageResource->SetLoadState(ChilliSource::Resource::LoadState::k_failed);\r\n\t\t\t\t\tif (in_delegate != nullptr)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_mainThread, [=](const ChilliSource::TaskContext&)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tin_delegate(out_resource);\r\n\t\t\t\t\t\t});\r\n\t\t\t\t\t}\r\n\t\t\t\t\treturn;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tChilliSource::Image::Descriptor desc;\r\n\t\t\t\tdesc.m_compression = ChilliSource::ImageCompression::k_none;\r\n\t\t\t\tdesc.m_format = image.GetImageFormat();\r\n\t\t\t\tdesc.m_width = image.GetWidth();\r\n\t\t\t\tdesc.m_height = image.GetHeight();\r\n\t\t\t\tdesc.m_dataSize = image.GetDataSize();\r\n\t\t\t\timageResource->Build(desc, ChilliSource::Image::ImageDataUPtr(image.GetImageData()));\r\n\r\n\t\t\t\t//release the png image without deallocating the image data\r\n\t\t\t\timage.Release(false);\r\n\r\n\t\t\t\timageResource->SetLoadState(ChilliSource::Resource::LoadState::k_loaded);\r\n\t\t\t\tif (in_delegate != nullptr)\r\n\t\t\t\t{\r\n\t\t\t\t\tChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_mainThread, [=](const ChilliSource::TaskContext&)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tin_delegate(out_resource);\r\n\t\t\t\t\t});\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tCS_DEFINE_NAMEDTYPE(PNGImageProvider);\r\n\t\t//----------------------------------------------------------------\r\n\t\t//----------------------------------------------------------------\r\n\t\tbool PNGImageProvider::IsA(ChilliSource::InterfaceIDType in_interfaceId) const\r\n\t\t{\r\n\t\t\treturn (in_interfaceId == ChilliSource::ResourceProvider::InterfaceID || in_interfaceId == ChilliSource::PNGImageProvider::InterfaceID || in_interfaceId == PNGImageProvider::InterfaceID);\r\n\t\t}\r\n\t\t//-------------------------------------------------------\r\n\t\t//-------------------------------------------------------\r\n\t\tChilliSource::InterfaceIDType PNGImageProvider::GetResourceType() const\r\n\t\t{\r\n\t\t\treturn ChilliSource::Image::InterfaceID;\r\n\t\t}\r\n\t\t//----------------------------------------------------------------\r\n\t\t//----------------------------------------------------------------\r\n\t\tbool PNGImageProvider::CanCreateResourceWithFileExtension(const std::string& in_extension) const\r\n\t\t{\r\n\t\t\treturn (in_extension == k_pngExtension);\r\n\t\t}\r\n\t\t//----------------------------------------------------------------\r\n\t\t//----------------------------------------------------------------\r\n\t\tvoid PNGImageProvider::CreateResourceFromFile(ChilliSource::StorageLocation in_storageLocation, const std::string& in_filepath, const ChilliSource::IResourceOptionsBaseCSPtr& in_options, const ChilliSource::ResourceSPtr& out_resource)\r\n\t\t{\r\n\t\t\tCreatePNGImageFromFile(in_storageLocation, in_filepath, nullptr, out_resource);\r\n\t\t}\r\n\t\t//----------------------------------------------------\r\n\t\t//----------------------------------------------------\r\n\t\tvoid PNGImageProvider::CreateResourceFromFileAsync(ChilliSource::StorageLocation in_storageLocation, const std::string& in_filePath, const ChilliSource::IResourceOptionsBaseCSPtr& in_options, const ChilliSource::ResourceProvider::AsyncLoadDelegate& in_delegate, const ChilliSource::ResourceSPtr& out_resource)\r\n\t\t{\r\n\t\t\tChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_file, [=](const ChilliSource::TaskContext&)\r\n\t\t\t{\r\n\t\t\t\tCreatePNGImageFromFile(in_storageLocation, in_filePath, in_delegate, out_resource);\r\n\t\t\t});\r\n\t\t}\r\n\t}\r\n}\r\n\r\n#endif\r\n"
  },
  {
    "path": "Source/CSBackend/Platform/Windows/Core/Image/PNGImageProvider.h",
    "content": "//\r\n//  PNGImageProvider.h\r\n//  ChilliSource\r\n//  Created by Ian Copland on 05/02/2011.\r\n//\r\n//  The MIT License (MIT)\r\n//\r\n//  Copyright (c) 2011 Tag Games Limited\r\n//\r\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\r\n//  of this software and associated documentation files (the \"Software\"), to deal\r\n//  in the Software without restriction, including without limitation the rights\r\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\n//  copies of the Software, and to permit persons to whom the Software is\r\n//  furnished to do so, subject to the following conditions:\r\n//\r\n//  The above copyright notice and this permission notice shall be included in\r\n//  all copies or substantial portions of the Software.\r\n//\r\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r\n//  THE SOFTWARE.\r\n//\r\n\r\n#ifdef CS_TARGETPLATFORM_WINDOWS\r\n\r\n#ifndef _CSBACKEND_PLATFORM_WINDOWS_CORE_IMAGE_PNGIMAGEPROVIDER_H_\r\n#define _CSBACKEND_PLATFORM_WINDOWS_CORE_IMAGE_PNGIMAGEPROVIDER_H_\r\n\r\n#include <CSBackend/Platform/Windows/ForwardDeclarations.h>\r\n#include <ChilliSource/Core/Image/Image.h>\r\n#include <ChilliSource/Core/Image/PNGImageProvider.h>\r\n\r\nnamespace CSBackend\r\n{\r\n\tnamespace Windows\r\n\t{\r\n\t\t//--------------------------------------------------------------\r\n\t\t/// The windows backend for the PNG Image Provider. This loads\r\n\t\t/// PNG images from file.\r\n\t\t///\r\n\t\t/// @author Ian Copland\r\n\t\t//--------------------------------------------------------------\r\n\t\tclass PNGImageProvider final : public ChilliSource::PNGImageProvider\r\n\t\t{\r\n\t\tpublic:\r\n\t\t\tCS_DECLARE_NAMEDTYPE(PNGImageProvider);\r\n\t\t\t//----------------------------------------------------------\r\n\t\t\t/// Is the object of the given interface type\r\n\t\t\t///\r\n\t\t\t/// @author Ian Copland\r\n\t\t\t///\r\n\t\t\t/// @param Interface type to query\r\n\t\t\t///\r\n\t\t\t/// @return Whether the object is of given type\r\n\t\t\t//----------------------------------------------------------\r\n\t\t\tbool IsA(ChilliSource::InterfaceIDType in_interfaceId) const override;\r\n\t\t\t//-------------------------------------------------------\r\n\t\t\t/// @author Ian Copland\r\n\t\t\t///\r\n\t\t\t/// @return The resource type this provider can load\r\n\t\t\t//-------------------------------------------------------\r\n\t\t\tChilliSource::InterfaceIDType GetResourceType() const override;\r\n\t\t\t//----------------------------------------------------------\r\n\t\t\t/// Whether or not the provider can create resources from\r\n\t\t\t/// files with the given extension.\r\n\t\t\t///\r\n\t\t\t/// @author Ian Copland\r\n\t\t\t///\r\n\t\t\t/// @param Extension to compare against\r\n\t\t\t///\r\n\t\t\t/// @return Whether the object can load a resource with that\r\n\t\t\t/// extension\r\n\t\t\t//----------------------------------------------------------\r\n\t\t\tbool CanCreateResourceWithFileExtension(const std::string& in_extension) const override;\r\n\t\t\t//----------------------------------------------------------\r\n\t\t\t/// Creates a new image resource from file. Check the\r\n\t\t\t/// resource load state for success or failure\r\n\t\t\t///\r\n\t\t\t/// @author Ian Copland\r\n\t\t\t///\r\n\t\t\t/// @param The storage location to load from\r\n\t\t\t/// @param File path to resource\r\n\t\t\t/// @param Options to customise the creation\r\n\t\t\t/// @param [Out] Resource\r\n\t\t\t//-----------------------------------------------------------\r\n\t\t\tvoid CreateResourceFromFile(ChilliSource::StorageLocation in_storageLocation, const std::string& in_filePath, const ChilliSource::IResourceOptionsBaseCSPtr& in_options, const ChilliSource::ResourceSPtr& out_resource) override;\r\n\t\t\t//----------------------------------------------------\r\n\t\t\t/// Creates a new resource from file asynchronously.\r\n\t\t\t/// Completion delegate is called when load is finished.\r\n\t\t\t/// Check the resource load state for success or failure\r\n\t\t\t///\r\n\t\t\t/// @author Ian Copland\r\n\t\t\t///\r\n\t\t\t/// @param The storage location.\r\n\t\t\t/// @param The filepath.\r\n\t\t\t/// @param Options to customise the creation\r\n\t\t\t/// @param Completion delegate\r\n\t\t\t/// @param [Out] The output resource.\r\n\t\t\t//----------------------------------------------------\r\n\t\t\tvoid CreateResourceFromFileAsync(ChilliSource::StorageLocation in_storageLocation, const std::string& in_filePath, const ChilliSource::IResourceOptionsBaseCSPtr& in_options, const ChilliSource::ResourceProvider::AsyncLoadDelegate& in_delegate, const ChilliSource::ResourceSPtr& out_resource) override;\r\n\t\tprivate:\r\n\t\t\tfriend ChilliSource::PNGImageProviderUPtr ChilliSource::PNGImageProvider::Create();\r\n\t\t\t//-----------------------------------------------------------\r\n\t\t\t/// Private constructor to force use of factory method\r\n\t\t\t///\r\n\t\t\t/// @author Ian Copland\r\n\t\t\t//-----------------------------------------------------------\r\n\t\t\tPNGImageProvider() = default;\r\n\t\t};\r\n\t}\r\n}\r\n\r\n#endif\r\n\r\n#endif\r\n"
  },
  {
    "path": "Source/CSBackend/Platform/Windows/Core/Image/PngImage.cpp",
    "content": "//\n//  PngLoader.cpp\n//  ChilliSource\n//  Created by Ian Copland on 06/04/2011.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2011 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_WINDOWS\n\n#include <CSBackend/Platform/Windows/Core/Image/PngImage.h>\n\n#include <png/png.h>\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/Image/ImageFormat.h>\n\n//----------------------------------------------------------------------------------\n/// Read Png Data\n///\n/// A replacement for the default libPng file reading function. This is needed so\n/// the c style file io functions can be replaced with ChilliSource functions,\n/// enabling loading from the package.\n/// @param png_structp png_ptr - The currently open Png decorder\n/// @param png_bytep data - The output data.\n/// @param png_size_t length - The length of the data.\n//----------------------------------------------------------------------------------\nvoid ReadPngData(png_structp png_ptr, png_bytep data, png_size_t length)\n{\n\tif (png_ptr == nullptr)\n\t\treturn;\n\n\tChilliSource::IBinaryInputStream* pStream = (ChilliSource::IBinaryInputStream*)png_get_io_ptr(png_ptr);\n\tpStream->Read(reinterpret_cast<u8*>(data), s32(length));\n}\n\nnamespace CSBackend\n{\n\tnamespace Windows\n\t{\n\t\t//----------------------------------------------------------------------------------\n\t\t/// Constructor\n\t\t//----------------------------------------------------------------------------------\n\t\tPngImage::PngImage()\n\t\t{\n\t\t\tmbIsLoaded = false;\n\t\t\tmdwHeight = -1;\n\t\t\tmdwWidth = -1;\n\t\t\tmpData = nullptr;\n\t\t}\n\t\t//----------------------------------------------------------------------------------\n\t\t/// Constructor\n\t\t//----------------------------------------------------------------------------------\n\t\tPngImage::PngImage(ChilliSource::StorageLocation ineLocation, const std::string& instrFilename)\n\t\t{\n\t\t\tmbIsLoaded = false;\n\t\t\tmdwHeight = -1;\n\t\t\tmdwWidth = -1;\n\t\t\tmpData = nullptr;\n\n\t\t\tLoad(ineLocation, instrFilename);\n\t\t}\n\t\t//----------------------------------------------------------------------------------\n\t\t/// Destructor\n\t\t//----------------------------------------------------------------------------------\n\t\tPngImage::~PngImage()\n\t\t{\n\t\t\tif (mbIsLoaded == true)\n\t\t\t{\n\t\t\t\tRelease();\n\t\t\t}\n\t\t}\n\t\t//----------------------------------------------------------------------------------\n\t\t/// Load PNG\n\t\t///\n\t\t/// Loads a png from a file within documents or the package.\n\t\t/// @param Storgae location of the file\n\t\t/// @param std::string instrFilename - the path to the file relative to either\n\t\t///\t\t\t\t\t\t\t\t\t   documents or the package.\n\t\t//----------------------------------------------------------------------------------\n\t\tvoid PngImage::Load(ChilliSource::StorageLocation ineLocation, const std::string& instrFilename)\n\t\t{\n\t\t\t//create the file stream\n\t\t\tauto stream = ChilliSource::Application::Get()->GetFileSystem()->CreateBinaryInputStream(ineLocation, instrFilename);\n\n\t\t\t//insure the stream is not broken\n\t\t\tif (stream == nullptr)\n\t\t\t{\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t//load from lib png\n\t\t\tif (LoadWithLibPng(stream) == true)\n\t\t\t{\n\t\t\t\tmbIsLoaded = true;\n\t\t\t}\n\t\t}\n\t\t//----------------------------------------------------------------------------------\n\t\t/// Release\n\t\t///\n\t\t/// Releases the image data\n\t\t/// @param bool inReleaseImageData - Whether or not to release the image data\n\t\t//----------------------------------------------------------------------------------\n\t\tvoid PngImage::Release(bool inReleaseImageData)\n\t\t{\n\t\t\tif (mbIsLoaded != false)\n\t\t\t{\n\t\t\t\tmbIsLoaded = false;\n\t\t\t\tmdwHeight = -1;\n\t\t\t\tmdwWidth = -1;\n\t\t\t\tif (inReleaseImageData)\n\t\t\t\t\tdelete[] mpData;\n\t\t\t\tmpData = (u8*)nullptr;\n\t\t\t}\n\t\t}\n\t\t//----------------------------------------------------------------------------------\n\t\t/// Is Loaded\n\t\t///\n\t\t/// returns whether or not the image is loaded\n\t\t//----------------------------------------------------------------------------------\n\t\tbool PngImage::IsLoaded()\n\t\t{\n\t\t\treturn mbIsLoaded;\n\t\t}\n\t\t//----------------------------------------------------------------------------------\n\t\t/// Get Height\n\t\t///\n\t\t/// returns the height of the image\n\t\t//----------------------------------------------------------------------------------\n\t\ts32 PngImage::GetHeight()\n\t\t{\n\t\t\treturn mdwHeight;\n\t\t}\n\t\t//----------------------------------------------------------------------------------\n\t\t/// Get Width\n\t\t///\n\t\t/// returns the width of the image\n\t\t//----------------------------------------------------------------------------------\n\t\ts32 PngImage::GetWidth()\n\t\t{\n\t\t\treturn mdwWidth;\n\t\t}\n\t\t//----------------------------------------------------------------------------------\n\t\t/// Get Image Data\n\t\t///\n\t\t/// returns the image data.\n\t\t//----------------------------------------------------------------------------------\n\t\tu8 * PngImage::GetImageData()\n\t\t{\n\t\t\treturn mpData;\n\t\t}\n\t\t//----------------------------------------------------------------------------------\n\t\t//----------------------------------------------------------------------------------\n\t\tu32 PngImage::GetDataSize() const\n\t\t{\n\t\t\treturn m_dataSize;\n\t\t}\n\t\t//----------------------------------------------------------------------------------\n\t\t//----------------------------------------------------------------------------------\n\t\tChilliSource::ImageFormat PngImage::GetImageFormat() const\n\t\t{\n\t\t\treturn m_format;\n\t\t}\n\t\t//----------------------------------------------------------------------------------\n\t\t/// Load with lib png\n\t\t///\n\t\t/// Loads the png data using lib png\n\t\t/// @param FileStreamSPtr inStream - the steam lib png should use to read the data.\n\t\t//----------------------------------------------------------------------------------\n\t\tbool PngImage::LoadWithLibPng(const ChilliSource::IBinaryInputStreamUPtr& inStream)\n\t\t{\n\t\t\t//insure that it is indeed a png\n\t\t\tconst s32 dwHeaderSize = 8;\n\t\t\tu8 ubyHeader[dwHeaderSize];\n\t\t\tinStream->Read(ubyHeader, dwHeaderSize);\n\n\t\t\tif (png_sig_cmp(ubyHeader, 0, dwHeaderSize) > 0)\n\t\t\t{\n\t\t\t\tCS_LOG_ERROR(\"PNG header invalid.\");\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t//create the png structure\n\t\t\tpng_structp pPng = png_create_read_struct(PNG_LIBPNG_VER_STRING, nullptr, nullptr, nullptr);\n\t\t\tif (!pPng)\n\t\t\t{\n\t\t\t\tCS_LOG_ERROR(\"Could not create pPng\");\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t//create the png info\n\t\t\tpng_infop pInfo = png_create_info_struct(pPng);\n\t\t\tif (!pInfo)\n\t\t\t{\n\t\t\t\tCS_LOG_ERROR(\"Could not create pInfo\");\n\t\t\t\tpng_destroy_read_struct(&pPng, (png_infopp)nullptr, (png_infopp)nullptr);\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t//setup jump\n\t\t\tif (setjmp(png_jmpbuf(pPng)))\n\t\t\t{\n\t\t\t\tCS_LOG_ERROR(\"Error while loading PNG.\");\n\t\t\t\tpng_destroy_read_struct(&pPng, &pInfo, (png_infopp)nullptr);\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t//Setup the ReadPngData function for use within libPng\n\t\t\tpng_set_read_fn(pPng,(void*)inStream.get(), ReadPngData);\n\n\t\t\t//tell it that we've ready read 8 bytes of data\n\t\t\tpng_set_sig_bytes(pPng, dwHeaderSize);\n\n\t\t\t//read the chunks of data upto the actual image data\n\t\t\tpng_read_info(pPng, pInfo);\n\n\t\t\t//get the info thats just been read\n\t\t\tpng_uint_32 udwWidth = 0;\n\t\t\tpng_uint_32 udwHeight = 0;\n\t\t\ts32 dwBitDepth = -1;\n\t\t\ts32 dwColorType = -1;\n\t\t\ts32 dwInterlaceType = -1;\n\t\t\ts32 dwCompressionMethod = -1;\n\t\t\ts32 dwFilterMethod = -1;\n\t\t\tpng_get_IHDR(pPng, pInfo, &udwWidth, &udwHeight, &dwBitDepth, &dwColorType, &dwInterlaceType, &dwCompressionMethod, &dwFilterMethod);\n\n\t\t\t//--transformations\n\t\t\t//sorts out grey scale images, probably not needed, but put in anyway\n\t\t\tif (dwColorType == PNG_COLOR_TYPE_PALETTE) png_set_palette_to_rgb(pPng);\n\t\t\tif (dwColorType == PNG_COLOR_TYPE_GRAY && dwBitDepth < 8) png_set_expand_gray_1_2_4_to_8(pPng);\n\t\t\tif (png_get_valid(pPng, pInfo, PNG_INFO_tRNS)) png_set_tRNS_to_alpha(pPng);\n\n\t\t\t//insure all files use 1 bit each for R,G,B and A\n\t\t\tif (dwBitDepth == 16) png_set_strip_16(pPng);\n\n\t\t\t//unpack compressed pixels\n\t\t\tif (dwBitDepth < 8) png_set_packing(pPng);\n\n\t\t\t//pack in an alpha value if there isn't one.\n\t\t\tif (dwColorType == PNG_COLOR_TYPE_RGB || dwColorType == PNG_COLOR_TYPE_GRAY)\n\t\t\t\tpng_set_add_alpha(pPng, (u8)255, PNG_FILLER_AFTER);\n\n\t\t\t//for the sake of simplicity, turn grey scale images into RGB\n\t\t\tif (dwColorType == PNG_COLOR_TYPE_GRAY || dwColorType == PNG_COLOR_TYPE_GRAY_ALPHA)\n\t\t\t\tpng_set_gray_to_rgb(pPng);\n\n\t\t\t//set to little endianness\n\t\t\tif (dwBitDepth == 16)\n\t\t\t\tpng_set_swap(pPng);\n\n\t\t\t//tell libpng to handling interlacing\n\t\t\ts32 number_of_passes = png_set_interlace_handling(pPng);\n\n\t\t\t//after all these transformations, update the png info\n\t\t\tpng_read_update_info(pPng, pInfo);\n\n\t\t\t//read the image into the data buffer\n\t\t\ts32 dwRowBytes = s32(png_get_rowbytes(pPng, pInfo));\n\t\t\tm_dataSize = dwRowBytes * udwHeight;\n\t\t\tmpData = new u8[m_dataSize];\n\n\t\t\tfor (s32 pass = 0; pass < number_of_passes; pass++)\n\t\t\t{\n\t\t\t\tfor (u32 y = 0; y < udwHeight; y += 1)\n\t\t\t\t{\n\t\t\t\t\tpng_bytep row = (mpData + y * dwRowBytes);\n\t\t\t\t\tpng_read_rows(pPng, &row, nullptr, 1);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t//store the width and height\n\t\t\tmdwWidth = (s32)udwWidth;\n\t\t\tmdwHeight = (s32)udwHeight;\n\n\t\t\t//-------- Get the image format\n\t\t\tpng_get_IHDR(pPng, pInfo, &udwWidth, &udwHeight, &dwBitDepth, &dwColorType, &dwInterlaceType, &dwCompressionMethod, &dwFilterMethod);\n\t\t\tswitch (dwColorType)\n\t\t\t{\n\t\t\tcase PNG_COLOR_TYPE_GRAY:\n\t\t\t\tm_format = ChilliSource::ImageFormat::k_Lum8;\n\t\t\t\tbreak;\n\t\t\tcase PNG_COLOR_TYPE_GRAY_ALPHA:\n\t\t\t\tm_format = ChilliSource::ImageFormat::k_LumA88;\n\t\t\t\tbreak;\n\t\t\tcase PNG_COLOR_TYPE_RGB:\n\t\t\t\tm_format = ChilliSource::ImageFormat::k_RGB888;\n\t\t\t\tbreak;\n\t\t\tcase PNG_COLOR_TYPE_RGB_ALPHA:\n\t\t\t\tm_format = ChilliSource::ImageFormat::k_RGBA8888;\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tCS_LOG_ERROR(\"Trying to load a PNG with an unknown colour format!\");\n\t\t\t\tpng_read_end(pPng, nullptr);\n\t\t\t\tpng_destroy_read_struct(&pPng, &pInfo, (png_infopp)nullptr);\n\t\t\t\treturn false;\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\t//end the read\n\t\t\tpng_read_end(pPng, nullptr);\n\n\t\t\t//deallocate everything\n\t\t\tpng_destroy_read_struct(&pPng, &pInfo, (png_infopp)nullptr);\n\t\t\treturn true;\n\t\t}\n\t}\n}\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Windows/Core/Image/PngImage.h",
    "content": "//\n//  PngLoader.h\n//  ChilliSource\n//  Created by Ian Copland on 06/04/2011.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2011 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_WINDOWS\n\n#ifndef _CHILLISOURCE_WINDOWSPLATFORM_IMAGELOADING_PNGIMAGE_\n#define _CHILLISOURCE_WINDOWSPLATFORM_IMAGELOADING_PNGIMAGE_\n\n#include <CSBackend/Platform/Windows/ForwardDeclarations.h>\n#include <ChilliSource/Core/File/FileSystem.h>\n\nnamespace CSBackend\n{\n\tnamespace Windows\n\t{\n\t\tclass PngImage\n\t\t{\n\t\tpublic:\n\t\t\t//----------------------------------------------------------------------------------\n\t\t\t/// Constructor\n\t\t\t//----------------------------------------------------------------------------------\n\t\t\tPngImage();\n\t\t\t//----------------------------------------------------------------------------------\n\t\t\t/// Constructor\n\t\t\t//----------------------------------------------------------------------------------\n\t\t\tPngImage(ChilliSource::StorageLocation ineLocation, const std::string& instrFilename);\n\t\t\t//----------------------------------------------------------------------------------\n\t\t\t/// Destructor\n\t\t\t//----------------------------------------------------------------------------------\n\t\t\tvirtual ~PngImage();\n\t\t\t//----------------------------------------------------------------------------------\n\t\t\t/// Load PNG\n\t\t\t///\n\t\t\t/// Loads a png from a file within documents or the package.\n\t\t\t/// @param Storgae location of the file\n\t\t\t/// @param std::string instrFilename - the path to the file relative to either\n\t\t\t///\t\t\t\t\t\t\t\t\t   documents or the package.\n\t\t\t//----------------------------------------------------------------------------------\n\t\t\tvoid Load(ChilliSource::StorageLocation ineLocation, const std::string& instrFilename);\n\t\t\t//----------------------------------------------------------------------------------\n\t\t\t/// Release\n\t\t\t///\n\t\t\t/// Releases the image data\n\t\t\t/// @param bool inReleaseImageData - Whether or not to release the image data\n\t\t\t//----------------------------------------------------------------------------------\n\t\t\tvoid Release(bool inReleaseImageData = true);\n\t\t\t//----------------------------------------------------------------------------------\n\t\t\t/// Is Loaded\n\t\t\t///\n\t\t\t/// returns whether or not the image is loaded\n\t\t\t//----------------------------------------------------------------------------------\n\t\t\tbool IsLoaded();\n\t\t\t//----------------------------------------------------------------------------------\n\t\t\t/// Get Height\n\t\t\t///\n\t\t\t/// returns the height of the image\n\t\t\t//----------------------------------------------------------------------------------\n\t\t\ts32 GetHeight();\n\t\t\t//----------------------------------------------------------------------------------\n\t\t\t/// Get Width\n\t\t\t///\n\t\t\t/// returns the width of the image\n\t\t\t//----------------------------------------------------------------------------------\n\t\t\ts32 GetWidth();\n\t\t\t//----------------------------------------------------------------------------------\n\t\t\t/// Get Image Data\n\t\t\t///\n\t\t\t/// returns the image data.\n\t\t\t//----------------------------------------------------------------------------------\n\t\t\tu8 * GetImageData();\n\t\t\t//----------------------------------------------------------------------------------\n\t\t\t/// @author S Downie\n\t\t\t///\n\t\t\t/// @return Size of image data in bytes\n\t\t\t//----------------------------------------------------------------------------------\n\t\t\tu32 GetDataSize() const;\n\t\t\t//----------------------------------------------------------------------------------\n\t\t\t/// @author S Downie\n\t\t\t///\n\t\t\t/// @return the image format\n\t\t\t//----------------------------------------------------------------------------------\n\t\t\tChilliSource::ImageFormat GetImageFormat() const;\n\t\tprotected:\n\t\t\t//----------------------------------------------------------------------------------\n\t\t\t/// Load with lib png\n\t\t\t///\n\t\t\t/// Loads the png data using lib png\n\t\t\t/// @param FileStreamSPtr inStream - the stream lib png should use to read the data.\n\t\t\t//----------------------------------------------------------------------------------\n\t\t\tbool LoadWithLibPng(const ChilliSource::IBinaryInputStreamUPtr& inStream);\n\n\t\t\tbool mbIsLoaded;\n\t\t\ts32 mdwHeight;\n\t\t\ts32 mdwWidth;\n\t\t\tu8 * mpData;\n\t\t\tChilliSource::ImageFormat m_format;\n\t\t\tu32 m_dataSize = 0;\n\t\t};\n\t}\n}\n\n#endif\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Windows/Core/String/WindowsStringUtils.cpp",
    "content": "//\r\n//  WindowwsStringUtils.cpp\r\n//  ChilliSource\r\n//  Created by Ian Copland on 03/03/2011.\r\n//\r\n//  The MIT License (MIT)\r\n//\r\n//  Copyright (c) 2014 Tag Games Limited\r\n//\r\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\r\n//  of this software and associated documentation files (the \"Software\"), to deal\r\n//  in the Software without restriction, including without limitation the rights\r\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\n//  copies of the Software, and to permit persons to whom the Software is\r\n//  furnished to do so, subject to the following conditions:\r\n//\r\n//  The above copyright notice and this permission notice shall be included in\r\n//  all copies or substantial portions of the Software.\r\n//\r\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r\n//  THE SOFTWARE.\r\n//\r\n\r\n#ifdef CS_TARGETPLATFORM_WINDOWS\r\n\r\n#include <CSBackend/Platform/Windows/Core/String/WindowsStringUtils.h>\r\n\r\n#include <ChilliSource/Core/String/StringUtils.h>\r\n\r\n#include <algorithm>\r\n\r\nnamespace CSBackend\r\n{\r\n\tnamespace Windows\r\n\t{\r\n\t\tnamespace WindowsStringUtils\r\n\t\t{\r\n\t\t\t//------------------------------------------------------------\r\n\t\t\t//------------------------------------------------------------\r\n\t\t\tstd::wstring UTF8ToUTF16(const std::string& in_utf8String)\r\n\t\t\t{\r\n\t\t\t\tstd::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;\r\n\t\t\t\treturn converter.from_bytes(in_utf8String);\r\n\t\t\t}\r\n\t\t\t//------------------------------------------------------------\r\n\t\t\t//------------------------------------------------------------\r\n\t\t\tstd::string UTF16ToUTF8(const std::wstring& in_utf16String)\r\n\t\t\t{\r\n\t\t\t\tstd::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;\r\n\t\t\t\treturn converter.to_bytes(in_utf16String);\r\n\t\t\t}\r\n\t\t\t//------------------------------------------------------------\r\n\t\t\t//------------------------------------------------------------\r\n\t\t\tstd::wstring ConvertStandardPathToWindows(const std::string& in_standardPath)\r\n\t\t\t{\r\n\t\t\t\tstd::wstring path = UTF8ToUTF16(in_standardPath);\r\n\r\n\t\t\t\tstd::replace(path.begin(), path.end(), L'/', L'\\\\');\r\n\r\n\t\t\t\tif (path[path.size() - 1] == L'\\\\')\r\n\t\t\t\t{\r\n\t\t\t\t\tpath = path.substr(0, path.size() - 1);\r\n\t\t\t\t}\r\n\r\n\t\t\t\treturn path;\r\n\t\t\t}\r\n\t\t\t//------------------------------------------------------------\r\n\t\t\t//------------------------------------------------------------\r\n\t\t\tstd::string ConvertWindowsDirectoryPathToStandard(const std::wstring& in_windowsPath)\r\n\t\t\t{\r\n\t\t\t\treturn ChilliSource::StringUtils::StandardiseDirectoryPath(UTF16ToUTF8(in_windowsPath));\r\n\t\t\t}\r\n\t\t\t//------------------------------------------------------------\r\n\t\t\t//------------------------------------------------------------\r\n\t\t\tstd::string ConvertWindowsFilePathToStandard(const std::wstring& in_windowsPath)\r\n\t\t\t{\r\n\t\t\t\treturn ChilliSource::StringUtils::StandardiseFilePath(UTF16ToUTF8(in_windowsPath));\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\n\r\n#endif\r\n"
  },
  {
    "path": "Source/CSBackend/Platform/Windows/Core/String/WindowsStringUtils.h",
    "content": "//\r\n//  WindowwsStringUtils.h\r\n//  ChilliSource\r\n//  Created by Ian Copland on 03/03/2011.\r\n//\r\n//  The MIT License (MIT)\r\n//\r\n//  Copyright (c) 2014 Tag Games Limited\r\n//\r\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\r\n//  of this software and associated documentation files (the \"Software\"), to deal\r\n//  in the Software without restriction, including without limitation the rights\r\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\n//  copies of the Software, and to permit persons to whom the Software is\r\n//  furnished to do so, subject to the following conditions:\r\n//\r\n//  The above copyright notice and this permission notice shall be included in\r\n//  all copies or substantial portions of the Software.\r\n//\r\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r\n//  THE SOFTWARE.\r\n//\r\n\r\n#ifdef CS_TARGETPLATFORM_WINDOWS\r\n\r\n#ifndef _CSBACKEND_PLATFORM_WINDOWS_CORE_STRING_WINDOWSSTRINGUTILS_H_\r\n#define _CSBACKEND_PLATFORM_WINDOWS_CORE_STRING_WINDOWSSTRINGUTILS_H_\r\n\r\n#include <CSBackend/Platform/Windows/ForwardDeclarations.h>\r\n\r\n#include <codecvt>\r\n#include <locale>\r\n#include <string>\r\n\r\nnamespace CSBackend\r\n{\r\n\tnamespace Windows\r\n\t{\r\n\t\t//------------------------------------------------------------\r\n\t\t/// A collection of utility methods for using strings on windows.\r\n\t\t/// This is mostly methods for working with wstrings.\r\n\t\t//------------------------------------------------------------\r\n\t\tnamespace WindowsStringUtils\r\n\t\t{\r\n\t\t\t//------------------------------------------------------------\r\n\t\t\t/// Converts from a UTF-8 encoded string to a UTF-16 encoded\r\n\t\t\t/// wstring.\r\n\t\t\t///\r\n\t\t\t/// @author I Copland\r\n\t\t\t///\r\n\t\t\t/// @param The UTF-8 string.\r\n\t\t\t/// @return The UTF-16 wstring.\r\n\t\t\t//------------------------------------------------------------\r\n\t\t\tstd::wstring UTF8ToUTF16(const std::string& in_utf8String);\r\n\t\t\t//------------------------------------------------------------\r\n\t\t\t/// Converts from a UTF-16 encoded wstring to a UTF-8 encoded\r\n\t\t\t/// string.\r\n\t\t\t///\r\n\t\t\t/// @author I Copland\r\n\t\t\t///\r\n\t\t\t/// @param The UTF-16 wstring.\r\n\t\t\t/// @return The UTF-8 string.\r\n\t\t\t//------------------------------------------------------------\r\n\t\t\tstd::string UTF16ToUTF8(const std::wstring& in_utf16String);\r\n\t\t\t//------------------------------------------------------------\r\n\t\t\t/// Converts the given standard string to a windows format\r\n\t\t\t/// wide string.\r\n\t\t\t///\r\n\t\t\t/// @author I Copland\r\n\t\t\t///\r\n\t\t\t/// @param The standard path string.\r\n\t\t\t/// @return The same path in a windows format wide string.\r\n\t\t\t//------------------------------------------------------------\r\n\t\t\tstd::wstring ConvertStandardPathToWindows(const std::string& in_standardPath);\r\n\t\t\t//------------------------------------------------------------\r\n\t\t\t/// Converts the given directory path to windows format.\r\n\t\t\t///\r\n\t\t\t/// @author I Copland\r\n\t\t\t///\r\n\t\t\t/// @param The windows format wide string.\r\n\t\t\t/// @return The same path standardised in a string.\r\n\t\t\t//------------------------------------------------------------\r\n\t\t\tstd::string ConvertWindowsDirectoryPathToStandard(const std::wstring& in_windowsPath);\r\n\t\t\t//------------------------------------------------------------\r\n\t\t\t/// Converts the given file path to windows format.\r\n\t\t\t///\r\n\t\t\t/// @author S Downie\r\n\t\t\t///\r\n\t\t\t/// @param The windows format wide string.\r\n\t\t\t/// @return The same path standardised in a string.\r\n\t\t\t//------------------------------------------------------------\r\n\t\t\tstd::string ConvertWindowsFilePathToStandard(const std::wstring& in_windowsPath);\r\n\t\t}\r\n\t}\r\n}\r\n\r\n#endif\r\n\r\n#endif\r\n"
  },
  {
    "path": "Source/CSBackend/Platform/Windows/ForwardDeclarations.h",
    "content": "//\r\n//  ForwardDeclarations.h\r\n//  ChilliSource\r\n//  Created by Ian Copland on 03/03/2014.\r\n//\r\n//  The MIT License (MIT)\r\n//\r\n//  Copyright (c) 2014 Tag Games Limited\r\n//\r\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\r\n//  of this software and associated documentation files (the \"Software\"), to deal\r\n//  in the Software without restriction, including without limitation the rights\r\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\n//  copies of the Software, and to permit persons to whom the Software is\r\n//  furnished to do so, subject to the following conditions:\r\n//\r\n//  The above copyright notice and this permission notice shall be included in\r\n//  all copies or substantial portions of the Software.\r\n//\r\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r\n//  THE SOFTWARE.\r\n//\r\n\r\n#ifdef CS_TARGETPLATFORM_WINDOWS\r\n\r\n#ifndef _CSBACKEND_PLATFORM_WINDOWS_FORWARDDECLARATION_H_\r\n#define _CSBACKEND_PLATFORM_WINDOWS_FORWARDDECLARATION_H_\r\n\r\n#include <ChilliSource/Core/Base/StandardMacros.h>\r\n\r\n#include <memory>\r\n\r\nnamespace CSBackend\r\n{\r\n\tnamespace Windows\r\n\t{\r\n\t\t//------------------------------------------------------\r\n\t\t/// Core\r\n\t\t//------------------------------------------------------\r\n\t\tCS_FORWARDDECLARE_CLASS(PlatformSystem);\r\n\t\tCS_FORWARDDECLARE_CLASS(FileSystem);\r\n\t\tCS_FORWARDDECLARE_CLASS(PNGImageProvider);\r\n\t\tCS_FORWARDDECLARE_CLASS(PngImage);\r\n        CS_FORWARDDECLARE_CLASS(Screen);\r\n\t\t//------------------------------------------------------\r\n\t\t/// Input\r\n\t\t//------------------------------------------------------\r\n        CS_FORWARDDECLARE_CLASS(DeviceButtonSystem);\r\n        CS_FORWARDDECLARE_CLASS(GamepadSystem);\r\n\t\tCS_FORWARDDECLARE_CLASS(Keyboard);\r\n\t\tCS_FORWARDDECLARE_CLASS(PointerSystem);\r\n\t\tCS_FORWARDDECLARE_CLASS(TextEntry);\r\n\t\t//------------------------------------------------------\r\n\t\t/// Networking\r\n\t\t//------------------------------------------------------\r\n\t\tCS_FORWARDDECLARE_CLASS(HttpRequest);\r\n\t\tCS_FORWARDDECLARE_CLASS(HttpRequestSystem);\r\n\t}\r\n}\r\n\r\n#endif\r\n\r\n#endif\r\n"
  },
  {
    "path": "Source/CSBackend/Platform/Windows/Input/DeviceButtons/DeviceButtonSystem.cpp",
    "content": "//\n//  DeviceButtonSystem.cpp\n//  ChilliSource\n//  Created by Ian Copland on 16/05/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_WINDOWS\n\n#include <CSBackend/Platform/Windows/Input/DeviceButtons/DeviceButtonSystem.h>\n\nnamespace CSBackend\n{\n\tnamespace Windows\n\t{\n        CS_DEFINE_NAMEDTYPE(DeviceButtonSystem);\n        //----------------------------------------------------\n        //----------------------------------------------------\n        bool DeviceButtonSystem::IsA(ChilliSource::InterfaceIDType in_interfaceID) const\n        {\n            return (in_interfaceID == ChilliSource::DeviceButtonSystem::InterfaceID || in_interfaceID == DeviceButtonSystem::InterfaceID);\n        }\n        //----------------------------------------------------\n        //----------------------------------------------------\n        ChilliSource::IConnectableEvent<DeviceButtonSystem::TriggeredDelegate>& DeviceButtonSystem::GetTriggeredEvent()\n        {\n            return m_triggeredEvent;\n        }\n\t}\n}\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Windows/Input/DeviceButtons/DeviceButtonSystem.h",
    "content": "//\n//  DeviceButtonSystem.h\n//  ChilliSource\n//  Created by Ian Copland on 16/05/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_WINDOWS\n\n#ifndef _CSBACKEND_PLATFORM_WINDOWS_INPUT_DEVICEBUTTONS_DEVICEBUTTONSYSTEM_H_\n#define _CSBACKEND_PLATFORM_WINDOWS_INPUT_DEVICEBUTTONS_DEVICEBUTTONSYSTEM_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <CSBackend/Platform/Windows/ForwardDeclarations.h>\n#include <ChilliSource/Input/DeviceButtons/DeviceButtonSystem.h>\n\nnamespace CSBackend\n{\n\tnamespace Windows\n\t{\n        //------------------------------------------------------------\n        /// The Windows backend implementation of the Device Button System.\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------------------\n\t\tclass DeviceButtonSystem final : public ChilliSource::DeviceButtonSystem\n\t\t{\n\t\tpublic:\n            CS_DECLARE_NAMEDTYPE(DeviceButtonSystem);\n            //----------------------------------------------------\n\t\t\t/// Queries whether or not this system implements the\n            /// interface with the given ID.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param The interface Id.\n            ///\n\t\t\t/// @return Whether or not the interface is implemented.\n\t\t\t//----------------------------------------------------\n            bool IsA(ChilliSource::InterfaceIDType in_interfaceId) const override;\n            //----------------------------------------------------\n\t\t\t/// @author Ian Copland\n            ///\n            /// @return An event that will be called whenever a\n            /// device button is triggered.\n\t\t\t//----------------------------------------------------\n            ChilliSource::IConnectableEvent<TriggeredDelegate>& GetTriggeredEvent() override;\n\t\tprivate:\n            friend ChilliSource::DeviceButtonSystemUPtr ChilliSource::DeviceButtonSystem::Create();\n            \n            //----------------------------------------------------\n\t\t\t/// Constructor. Declared private to force the use of\n            /// the factory method.\n            ///\n            /// @author Ian Copland\n\t\t\t//----------------------------------------------------\n\t\t\tDeviceButtonSystem() = default;\n\n            ChilliSource::Event<TriggeredDelegate> m_triggeredEvent;\n\t\t};\n\t}\n}\n\n#endif\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Windows/Input/Gamepad/GamepadSystem.cpp",
    "content": "//\r\n//  The MIT License (MIT)\r\n//\r\n//  Copyright (c) 2017 Tag Games Limited\r\n//\r\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\r\n//  of this software and associated documentation files (the \"Software\"), to deal\r\n//  in the Software without restriction, including without limitation the rights\r\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\n//  copies of the Software, and to permit persons to whom the Software is\r\n//  furnished to do so, subject to the following conditions:\r\n//\r\n//  The above copyright notice and this permission notice shall be included in\r\n//  all copies or substantial portions of the Software.\r\n//\r\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r\n//  THE SOFTWARE.\r\n//\r\n\r\n#ifdef CS_TARGETPLATFORM_WINDOWS\r\n\r\n#include <CSBackend/Platform/Windows/Input/Gamepad/GamepadSystem.h>\r\n\r\n#include <ChilliSource/Core/Delegate/MakeDelegate.h>\r\n#include <ChilliSource/Input/Gamepad/GamepadAxis.h>\r\n\r\n#include <CSBackend/Platform/Windows/SFML/Base/SFMLWindow.h>\r\n\r\nnamespace CSBackend\r\n{\r\n\tnamespace Windows\r\n\t{\r\n\t\tCS_DEFINE_NAMEDTYPE(GamepadSystem);\r\n\r\n        //------------------------------------------------------------------------------\r\n\t\tbool GamepadSystem::IsA(ChilliSource::InterfaceIDType interfaceId) const noexcept\r\n\t\t{\r\n\t\t\treturn (ChilliSource::GamepadSystem::InterfaceID == interfaceId || GamepadSystem::InterfaceID == interfaceId);\r\n\t\t}\r\n\r\n\t\t//------------------------------------------------------------------------------\r\n\t\tvoid GamepadSystem::OnInit() noexcept\r\n\t\t{\r\n\t\t\tSFMLWindow::Get()->SetJoystickDelegates(ChilliSource::MakeDelegate(this, &GamepadSystem::OnJoystickConnected), ChilliSource::MakeDelegate(this, &GamepadSystem::OnJoystickDisconnected),\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tChilliSource::MakeDelegate(this, &GamepadSystem::OnButtonPressed), ChilliSource::MakeDelegate(this, &GamepadSystem::OnButtonReleased),\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tChilliSource::MakeDelegate(this, &GamepadSystem::OnAxisMoved));\r\n\r\n\t\t\tsf::Joystick::update();\r\n\t\t\t//SFML doesn't notify us about already connected joysticks.\r\n\t\t\tfor(u32 i=0; i<ChilliSource::Gamepad::k_maxGamepads; ++i)\r\n\t\t\t{\r\n\t\t\t\tif(sf::Joystick::isConnected(i))\r\n\t\t\t\t{\r\n\t\t\t\t\tOnJoystickConnected(i);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t//------------------------------------------------------------------------------\r\n\t\tvoid GamepadSystem::OnJoystickConnected(u32 index) noexcept\r\n\t\t{\r\n\t\t\tCS_LOG_VERBOSE_FMT(\"Gamepad Connected: %s\\n\", sf::Joystick::getIdentification(index).name.toAnsiString().c_str());\r\n\r\n\t\t\tu32 supportedAxisFlags = 0;\r\n\t\t\tfor(u32 i=0; i<=(u32)sf::Joystick::Axis::PovY; ++i)\r\n\t\t\t{\r\n\t\t\t\tif(sf::Joystick::hasAxis(index, (sf::Joystick::Axis)i))\r\n\t\t\t\t{\r\n\t\t\t\t\tsupportedAxisFlags |= (1u << i);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tm_mapSFMLToCSIds[index] = AddGamepadCreateEvent(sf::Joystick::getIdentification(index).name.toAnsiString(), sf::Joystick::getButtonCount(index), supportedAxisFlags);\r\n\t\t}\r\n\r\n\t\t//------------------------------------------------------------------------------\r\n\t\tvoid GamepadSystem::OnJoystickDisconnected(u32 index) noexcept\r\n\t\t{\r\n\t\t\tAddGamepadRemoveEvent(m_mapSFMLToCSIds[index]);\r\n\t\t}\r\n\r\n\t\t//------------------------------------------------------------------------------\r\n\t\tvoid GamepadSystem::OnButtonPressed(u32 joystickIndex, u32 buttonIndex) noexcept\r\n\t\t{\r\n\t\t\tAddButtonPressureChangedEvent(m_mapSFMLToCSIds[joystickIndex], buttonIndex, 1.0f);\r\n\t\t}\r\n\r\n\t\t//------------------------------------------------------------------------------\r\n\t\tvoid GamepadSystem::OnButtonReleased(u32 joystickIndex, u32 buttonIndex) noexcept\r\n\t\t{\r\n\t\t\tAddButtonPressureChangedEvent(m_mapSFMLToCSIds[joystickIndex], buttonIndex, 0.0f);\r\n\t\t}\r\n\r\n\t\t//------------------------------------------------------------------------------\r\n\t\tvoid GamepadSystem::OnAxisMoved(u32 joystickIndex, sf::Joystick::Axis axisId, f32 pos) noexcept\r\n\t\t{\r\n\t\t\tAddAxisPositionChangedEvent(m_mapSFMLToCSIds[joystickIndex], (ChilliSource::GamepadAxis)axisId, pos * 0.01f);\r\n\t\t}\r\n\r\n\t\t//------------------------------------------------------------------------------\r\n\t\tvoid GamepadSystem::OnDestroy() noexcept\r\n\t\t{\r\n            SFMLWindow::Get()->RemoveJoystickDelegates();\r\n\t\t}\r\n\t}\r\n}\r\n\r\n#endif\r\n"
  },
  {
    "path": "Source/CSBackend/Platform/Windows/Input/Gamepad/GamepadSystem.h",
    "content": "//\r\n//  The MIT License (MIT)\r\n//\r\n//  Copyright (c) 2017 Tag Games Limited\r\n//\r\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\r\n//  of this software and associated documentation files (the \"Software\"), to deal\r\n//  in the Software without restriction, including without limitation the rights\r\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\n//  copies of the Software, and to permit persons to whom the Software is\r\n//  furnished to do so, subject to the following conditions:\r\n//\r\n//  The above copyright notice and this permission notice shall be included in\r\n//  all copies or substantial portions of the Software.\r\n//\r\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r\n//  THE SOFTWARE.\r\n//\r\n\r\n#ifdef CS_TARGETPLATFORM_WINDOWS\r\n\r\n#ifndef _CSBACKEND_PLATFORM_WINDOWS_INPUT_GAMEPAD_GAMEPADSYSTEM_H_\r\n#define _CSBACKEND_PLATFORM_WINDOWS_INPUT_GAMEPAD_GAMEPADSYSTEM_H_\r\n\r\n#include <ChilliSource/ChilliSource.h>\r\n#include <CSBackend/Platform/Windows/ForwardDeclarations.h>\r\n#include <ChilliSource/Input/Gamepad/GamepadSystem.h>\r\n\r\n#include <SFML/Window/Joystick.hpp>\r\n\r\n#include <array>\r\n\r\nnamespace CSBackend\r\n{\r\n\tnamespace Windows\r\n\t{\r\n\t\t/// The Windows backend for the gamepad system. Uses SFML\r\n        /// to query the state of connected gamepads and forwards the information\r\n        /// to the application\r\n        ///\r\n\t\tclass GamepadSystem final : public ChilliSource::GamepadSystem\r\n\t\t{\r\n\t\tpublic:\r\n\t\t\tCS_DECLARE_NAMEDTYPE(GamepadSystem);\r\n\r\n            ///\r\n            bool IsA(ChilliSource::InterfaceIDType interfaceId) const noexcept override;\r\n\r\n\r\n\t\tprivate:\r\n\t\t\tfriend class ChilliSource::GamepadSystem;\r\n\r\n            ///\r\n\t\t\tGamepadSystem() = default;\r\n\r\n\t\t\t/// Start listening to SFML events\r\n\t\t\t///\r\n\t\t\tvoid OnInit() noexcept override;\r\n\r\n\t\t\t/// Called by SFML when a joystick is attached\r\n\t\t\t///\r\n\t\t\t/// @param index\r\n\t\t\t///\t\tIndex of joystick\r\n\t\t\t///\r\n\t\t\tvoid OnJoystickConnected(u32 index) noexcept;\r\n\r\n\t\t\t/// Called by SFML when a joystick is removed\r\n\t\t\t///\r\n\t\t\t/// @param index\r\n\t\t\t///\t\tIndex of joystick\r\n\t\t\t///\r\n\t\t\tvoid OnJoystickDisconnected(u32 index) noexcept;\r\n\r\n\t\t\t/// Called by SFML when a button is pressed\r\n\t\t\t///\r\n\t\t\t/// @param joystickIndex\r\n\t\t\t///\t\tIndex of joystick\r\n\t\t\t/// @param buttonIndex\r\n\t\t\t///\t\tIndex of button\r\n\t\t\t///\r\n\t\t\tvoid OnButtonPressed(u32 joystickIndex, u32 buttonIndex) noexcept;\r\n\r\n\t\t\t/// Called by SFML when a button is released\r\n\t\t\t///\r\n\t\t\t/// @param joystickIndex\r\n\t\t\t///\t\tIndex of joystick\r\n\t\t\t/// @param buttonIndex\r\n\t\t\t///\t\tIndex of button\r\n\t\t\t///\r\n\t\t\tvoid OnButtonReleased(u32 joystickIndex, u32 buttonIndex) noexcept;\r\n\r\n\t\t\t/// Called by SFML when an axis is moved on a connected joystick\r\n\t\t\t///\r\n\t\t\t/// @param joystickIndex\r\n\t\t\t///\t\tIndex of joystick\r\n\t\t\t/// @param axisId\r\n\t\t\t///\t\tIdentifier of the axis. SFML splits all axis into single floats\r\n\t\t\t/// @param pos\r\n\t\t\t///\t\tPosition of the axis along the line of the axis\r\n\t\t\t///\r\n\t\t\tvoid OnAxisMoved(u32 joystickIndex, sf::Joystick::Axis axisId, f32 pos) noexcept;\r\n\r\n\t\t\t/// Stop listening for SFML events\r\n\t\t\t///\r\n\t\t\tvoid OnDestroy() noexcept override;\r\n\r\n\t\t\t//SFML allows 8 joysticks\r\n\t\t\tstd::array<ChilliSource::Gamepad::Id, ChilliSource::Gamepad::k_maxGamepads> m_mapSFMLToCSIds;\r\n\t\t};\r\n\t}\r\n}\r\n\r\n#endif\r\n\r\n#endif\r\n"
  },
  {
    "path": "Source/CSBackend/Platform/Windows/Input/Keyboard/Keyboard.cpp",
    "content": "//\r\n//  Keyboard.cpp\r\n//  ChilliSource\r\n//  Created by Scott Downie on 09/07/2014\r\n//\r\n//  The MIT License (MIT)\r\n//\r\n//  Copyright (c) 2014 Tag Games Limited\r\n//\r\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\r\n//  of this software and associated documentation files (the \"Software\"), to deal\r\n//  in the Software without restriction, including without limitation the rights\r\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\n//  copies of the Software, and to permit persons to whom the Software is\r\n//  furnished to do so, subject to the following conditions:\r\n//\r\n//  The above copyright notice and this permission notice shall be included in\r\n//  all copies or substantial portions of the Software.\r\n//\r\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r\n//  THE SOFTWARE.\r\n//\r\n\r\n#ifdef CS_TARGETPLATFORM_WINDOWS\r\n\r\n#include <CSBackend/Platform/Windows/Input/Keyboard/Keyboard.h>\r\n\r\n#include <ChilliSource/Core/Base/Application.h>\r\n#include <ChilliSource/Core/Delegate/MakeDelegate.h>\r\n#include <ChilliSource/Core/Threading/TaskScheduler.h>\r\n#include <ChilliSource/Input/Keyboard/KeyCode.h>\r\n#include <ChilliSource/Input/Keyboard/ModifierKeyCode.h>\r\n\r\nnamespace CSBackend\r\n{\r\n\tnamespace Windows\r\n\t{\r\n\t\tCS_DEFINE_NAMEDTYPE(Keyboard);\r\n\r\n\t\tnamespace\r\n\t\t{\r\n\t\t\tconst sf::Keyboard::Key k_sfmlKeyCodesMap[(u32)ChilliSource::KeyCode::k_total] =\r\n\t\t\t{\r\n\t\t\t\tsf::Keyboard::Unknown,\r\n\t\t\t\tsf::Keyboard::A,\r\n\t\t\t\tsf::Keyboard::B,\r\n\t\t\t\tsf::Keyboard::C,\r\n\t\t\t\tsf::Keyboard::D,\r\n\t\t\t\tsf::Keyboard::E,\r\n\t\t\t\tsf::Keyboard::F,\r\n\t\t\t\tsf::Keyboard::G,\r\n\t\t\t\tsf::Keyboard::H,\r\n\t\t\t\tsf::Keyboard::I,\r\n\t\t\t\tsf::Keyboard::J,\r\n\t\t\t\tsf::Keyboard::K,\r\n\t\t\t\tsf::Keyboard::L,\r\n\t\t\t\tsf::Keyboard::M,\r\n\t\t\t\tsf::Keyboard::N,\r\n\t\t\t\tsf::Keyboard::O,\r\n\t\t\t\tsf::Keyboard::P,\r\n\t\t\t\tsf::Keyboard::Q,\r\n\t\t\t\tsf::Keyboard::R,\r\n\t\t\t\tsf::Keyboard::S,\r\n\t\t\t\tsf::Keyboard::T,\r\n\t\t\t\tsf::Keyboard::U,\r\n\t\t\t\tsf::Keyboard::V,\r\n\t\t\t\tsf::Keyboard::W,\r\n\t\t\t\tsf::Keyboard::X,\r\n\t\t\t\tsf::Keyboard::Y,\r\n\t\t\t\tsf::Keyboard::Z,\r\n\t\t\t\tsf::Keyboard::Num0,\r\n\t\t\t\tsf::Keyboard::Num1,\r\n\t\t\t\tsf::Keyboard::Num2,\r\n\t\t\t\tsf::Keyboard::Num3,\r\n\t\t\t\tsf::Keyboard::Num4,\r\n\t\t\t\tsf::Keyboard::Num5,\r\n\t\t\t\tsf::Keyboard::Num6,\r\n\t\t\t\tsf::Keyboard::Num7,\r\n\t\t\t\tsf::Keyboard::Num8,\r\n\t\t\t\tsf::Keyboard::Num9,\r\n\t\t\t\tsf::Keyboard::Escape,\r\n\t\t\t\tsf::Keyboard::LControl,\r\n\t\t\t\tsf::Keyboard::LShift,\r\n\t\t\t\tsf::Keyboard::LAlt,\r\n\t\t\t\tsf::Keyboard::LSystem,\r\n\t\t\t\tsf::Keyboard::RControl,\r\n\t\t\t\tsf::Keyboard::RShift,\r\n\t\t\t\tsf::Keyboard::RAlt,\r\n\t\t\t\tsf::Keyboard::RSystem,\r\n\t\t\t\tsf::Keyboard::Menu,\r\n\t\t\t\tsf::Keyboard::LBracket,\r\n\t\t\t\tsf::Keyboard::RBracket,\r\n\t\t\t\tsf::Keyboard::SemiColon,\r\n\t\t\t\tsf::Keyboard::Comma,\r\n\t\t\t\tsf::Keyboard::Period,\r\n\t\t\t\tsf::Keyboard::Quote,\r\n\t\t\t\tsf::Keyboard::Slash,\r\n\t\t\t\tsf::Keyboard::BackSlash,\r\n\t\t\t\tsf::Keyboard::Tilde,\r\n\t\t\t\tsf::Keyboard::Equal,\r\n\t\t\t\tsf::Keyboard::Dash,\r\n\t\t\t\tsf::Keyboard::Space,\r\n\t\t\t\tsf::Keyboard::Return,\r\n\t\t\t\tsf::Keyboard::BackSpace,\r\n\t\t\t\tsf::Keyboard::Tab,\r\n\t\t\t\tsf::Keyboard::PageUp,\r\n\t\t\t\tsf::Keyboard::PageDown,\r\n\t\t\t\tsf::Keyboard::End,\r\n\t\t\t\tsf::Keyboard::Home,\r\n\t\t\t\tsf::Keyboard::Insert,\r\n\t\t\t\tsf::Keyboard::Delete,\r\n\t\t\t\tsf::Keyboard::Add,\r\n\t\t\t\tsf::Keyboard::Subtract,\r\n\t\t\t\tsf::Keyboard::Multiply,\r\n\t\t\t\tsf::Keyboard::Divide,\r\n\t\t\t\tsf::Keyboard::Left,\r\n\t\t\t\tsf::Keyboard::Right,\r\n\t\t\t\tsf::Keyboard::Up,\r\n\t\t\t\tsf::Keyboard::Down,\r\n\t\t\t\tsf::Keyboard::Numpad0,\r\n\t\t\t\tsf::Keyboard::Numpad1,\r\n\t\t\t\tsf::Keyboard::Numpad2,\r\n\t\t\t\tsf::Keyboard::Numpad3,\r\n\t\t\t\tsf::Keyboard::Numpad4,\r\n\t\t\t\tsf::Keyboard::Numpad5,\r\n\t\t\t\tsf::Keyboard::Numpad6,\r\n\t\t\t\tsf::Keyboard::Numpad7,\r\n\t\t\t\tsf::Keyboard::Numpad8,\r\n\t\t\t\tsf::Keyboard::Numpad9,\r\n\t\t\t\tsf::Keyboard::F1,\r\n\t\t\t\tsf::Keyboard::F2,\r\n\t\t\t\tsf::Keyboard::F3,\r\n\t\t\t\tsf::Keyboard::F4,\r\n\t\t\t\tsf::Keyboard::F5,\r\n\t\t\t\tsf::Keyboard::F6,\r\n\t\t\t\tsf::Keyboard::F7,\r\n\t\t\t\tsf::Keyboard::F8,\r\n\t\t\t\tsf::Keyboard::F9,\r\n\t\t\t\tsf::Keyboard::F10,\r\n\t\t\t\tsf::Keyboard::F11,\r\n\t\t\t\tsf::Keyboard::F12,\r\n\t\t\t\tsf::Keyboard::F13,\r\n\t\t\t\tsf::Keyboard::F14,\r\n\t\t\t\tsf::Keyboard::F15,\r\n\t\t\t\tsf::Keyboard::Pause\r\n\t\t\t};\r\n\t\t\tconst ChilliSource::KeyCode k_csKeyCodesMap[(u32)sf::Keyboard::Key::KeyCount] =\r\n\t\t\t{\r\n\t\t\t\tChilliSource::KeyCode::k_a,\r\n\t\t\t\tChilliSource::KeyCode::k_b,\r\n\t\t\t\tChilliSource::KeyCode::k_c,\r\n\t\t\t\tChilliSource::KeyCode::k_d,\r\n\t\t\t\tChilliSource::KeyCode::k_e,\r\n\t\t\t\tChilliSource::KeyCode::k_f,\r\n\t\t\t\tChilliSource::KeyCode::k_g,\r\n\t\t\t\tChilliSource::KeyCode::k_h,\r\n\t\t\t\tChilliSource::KeyCode::k_i,\r\n\t\t\t\tChilliSource::KeyCode::k_j,\r\n\t\t\t\tChilliSource::KeyCode::k_k,\r\n\t\t\t\tChilliSource::KeyCode::k_l,\r\n\t\t\t\tChilliSource::KeyCode::k_m,\r\n\t\t\t\tChilliSource::KeyCode::k_n,\r\n\t\t\t\tChilliSource::KeyCode::k_o,\r\n\t\t\t\tChilliSource::KeyCode::k_p,\r\n\t\t\t\tChilliSource::KeyCode::k_q,\r\n\t\t\t\tChilliSource::KeyCode::k_r,\r\n\t\t\t\tChilliSource::KeyCode::k_s,\r\n\t\t\t\tChilliSource::KeyCode::k_t,\r\n\t\t\t\tChilliSource::KeyCode::k_u,\r\n\t\t\t\tChilliSource::KeyCode::k_v,\r\n\t\t\t\tChilliSource::KeyCode::k_w,\r\n\t\t\t\tChilliSource::KeyCode::k_x,\r\n\t\t\t\tChilliSource::KeyCode::k_y,\r\n\t\t\t\tChilliSource::KeyCode::k_z,\r\n\t\t\t\tChilliSource::KeyCode::k_num0,\r\n\t\t\t\tChilliSource::KeyCode::k_num1,\r\n\t\t\t\tChilliSource::KeyCode::k_num2,\r\n\t\t\t\tChilliSource::KeyCode::k_num3,\r\n\t\t\t\tChilliSource::KeyCode::k_num4,\r\n\t\t\t\tChilliSource::KeyCode::k_num5,\r\n\t\t\t\tChilliSource::KeyCode::k_num6,\r\n\t\t\t\tChilliSource::KeyCode::k_num7,\r\n\t\t\t\tChilliSource::KeyCode::k_num8,\r\n\t\t\t\tChilliSource::KeyCode::k_num9,\r\n\t\t\t\tChilliSource::KeyCode::k_escape,\r\n\t\t\t\tChilliSource::KeyCode::k_leftCtrl,\r\n\t\t\t\tChilliSource::KeyCode::k_leftShift,\r\n\t\t\t\tChilliSource::KeyCode::k_leftAlt,\r\n\t\t\t\tChilliSource::KeyCode::k_leftSystem,\r\n\t\t\t\tChilliSource::KeyCode::k_rightCtrl,\r\n\t\t\t\tChilliSource::KeyCode::k_rightShift,\r\n\t\t\t\tChilliSource::KeyCode::k_rightAlt,\r\n\t\t\t\tChilliSource::KeyCode::k_rightSystem,\r\n\t\t\t\tChilliSource::KeyCode::k_menu,\r\n\t\t\t\tChilliSource::KeyCode::k_leftBracket,\r\n\t\t\t\tChilliSource::KeyCode::k_rightBracket,\r\n\t\t\t\tChilliSource::KeyCode::k_semiColon,\r\n\t\t\t\tChilliSource::KeyCode::k_comma,\r\n\t\t\t\tChilliSource::KeyCode::k_period,\r\n\t\t\t\tChilliSource::KeyCode::k_quote,\r\n\t\t\t\tChilliSource::KeyCode::k_forwardSlash,\r\n\t\t\t\tChilliSource::KeyCode::k_backSlash,\r\n\t\t\t\tChilliSource::KeyCode::k_tilde,\r\n\t\t\t\tChilliSource::KeyCode::k_equals,\r\n\t\t\t\tChilliSource::KeyCode::k_hyphen,\r\n\t\t\t\tChilliSource::KeyCode::k_space,\r\n\t\t\t\tChilliSource::KeyCode::k_return,\r\n\t\t\t\tChilliSource::KeyCode::k_backSpace,\r\n\t\t\t\tChilliSource::KeyCode::k_tab,\r\n\t\t\t\tChilliSource::KeyCode::k_pageUp,\r\n\t\t\t\tChilliSource::KeyCode::k_pageDown,\r\n\t\t\t\tChilliSource::KeyCode::k_end,\r\n\t\t\t\tChilliSource::KeyCode::k_home,\r\n\t\t\t\tChilliSource::KeyCode::k_insert,\r\n\t\t\t\tChilliSource::KeyCode::k_delete,\r\n\t\t\t\tChilliSource::KeyCode::k_add,\r\n\t\t\t\tChilliSource::KeyCode::k_subtract,\r\n\t\t\t\tChilliSource::KeyCode::k_multiply,\r\n\t\t\t\tChilliSource::KeyCode::k_divide,\r\n\t\t\t\tChilliSource::KeyCode::k_left,\r\n\t\t\t\tChilliSource::KeyCode::k_right,\r\n\t\t\t\tChilliSource::KeyCode::k_up,\r\n\t\t\t\tChilliSource::KeyCode::k_down,\r\n\t\t\t\tChilliSource::KeyCode::k_numpad0,\r\n\t\t\t\tChilliSource::KeyCode::k_numpad1,\r\n\t\t\t\tChilliSource::KeyCode::k_numpad2,\r\n\t\t\t\tChilliSource::KeyCode::k_numpad3,\r\n\t\t\t\tChilliSource::KeyCode::k_numpad4,\r\n\t\t\t\tChilliSource::KeyCode::k_numpad5,\r\n\t\t\t\tChilliSource::KeyCode::k_numpad6,\r\n\t\t\t\tChilliSource::KeyCode::k_numpad7,\r\n\t\t\t\tChilliSource::KeyCode::k_numpad8,\r\n\t\t\t\tChilliSource::KeyCode::k_numpad9,\r\n\t\t\t\tChilliSource::KeyCode::k_f1,\r\n\t\t\t\tChilliSource::KeyCode::k_f2,\r\n\t\t\t\tChilliSource::KeyCode::k_f3,\r\n\t\t\t\tChilliSource::KeyCode::k_f4,\r\n\t\t\t\tChilliSource::KeyCode::k_f5,\r\n\t\t\t\tChilliSource::KeyCode::k_f6,\r\n\t\t\t\tChilliSource::KeyCode::k_f7,\r\n\t\t\t\tChilliSource::KeyCode::k_f8,\r\n\t\t\t\tChilliSource::KeyCode::k_f9,\r\n\t\t\t\tChilliSource::KeyCode::k_f10,\r\n\t\t\t\tChilliSource::KeyCode::k_f11,\r\n\t\t\t\tChilliSource::KeyCode::k_f12,\r\n\t\t\t\tChilliSource::KeyCode::k_f13,\r\n\t\t\t\tChilliSource::KeyCode::k_f14,\r\n\t\t\t\tChilliSource::KeyCode::k_f15,\r\n\t\t\t\tChilliSource::KeyCode::k_pause\r\n\t\t\t};\r\n\t\t\t//-------------------------------------------------------\r\n\t\t\t/// Convert from CS key code to SFML key code\r\n\t\t\t///\r\n\t\t\t/// @author S Downie\r\n\t\t\t///\r\n\t\t\t/// @param CS key code\r\n\t\t\t///\r\n\t\t\t/// @return SFML key code\r\n\t\t\t//-------------------------------------------------------\r\n\t\t\tsf::Keyboard::Key CSKeyCodeToSFMLKeyCode(ChilliSource::KeyCode in_code)\r\n\t\t\t{\r\n\t\t\t\treturn k_sfmlKeyCodesMap[(u32)in_code];\r\n\t\t\t}\r\n\t\t\t//-------------------------------------------------------\r\n\t\t\t/// Convert from SFML key code to CS key code\r\n\t\t\t///\r\n\t\t\t/// @author S Downie\r\n\t\t\t///\r\n\t\t\t/// @param SFML key code\r\n\t\t\t///\r\n\t\t\t/// @return CS key code\r\n\t\t\t//-------------------------------------------------------\r\n\t\t\tChilliSource::KeyCode SFMLKeyCodeToCSKeyCode(sf::Keyboard::Key in_code)\r\n\t\t\t{\r\n\t\t\t\tif (in_code == sf::Keyboard::Key::Unknown)\r\n\t\t\t\t{\r\n\t\t\t\t\treturn ChilliSource::KeyCode::k_unknown;\r\n\t\t\t\t}\r\n\r\n\t\t\t\treturn k_csKeyCodesMap[(u32)in_code];\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t//----------------------------------------------------\r\n\t\t//----------------------------------------------------\r\n\t\tbool Keyboard::IsA(ChilliSource::InterfaceIDType in_interfaceId) const\r\n\t\t{\r\n\t\t\treturn (ChilliSource::Keyboard::InterfaceID == in_interfaceId || Keyboard::InterfaceID == in_interfaceId);\r\n\t\t}\r\n\t\t//-------------------------------------------------------\r\n\t\t//-------------------------------------------------------\r\n\t\tvoid Keyboard::OnInit()\r\n\t\t{\r\n            for (auto& flag : m_keysDown)\r\n\t\t\t{\r\n\t\t\t\tflag = false;\r\n\t\t\t}\r\n\r\n\t\t\tSFMLWindow::Get()->SetKeyDelegates(ChilliSource::MakeDelegate(this, &Keyboard::OnKeyPressed), ChilliSource::MakeDelegate(this, &Keyboard::OnKeyReleased));\r\n\t\t}\r\n\t\t//-------------------------------------------------------\r\n\t\t//-------------------------------------------------------\r\n\t\tvoid Keyboard::OnKeyPressed(sf::Keyboard::Key in_code, const sf::Event::KeyEvent& in_event)\r\n\t\t{\r\n            ChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_mainThread, [=](const ChilliSource::TaskContext& context)\r\n            {\r\n                auto keyCode = SFMLKeyCodeToCSKeyCode(in_code);\r\n\r\n                if (IsKeyDown(keyCode) == false)\r\n                {\r\n                    m_keysDown[static_cast<u32>(keyCode)] = true;\r\n\r\n                    std::vector<ChilliSource::ModifierKeyCode> modifiers;\r\n                    modifiers.reserve((u32)ChilliSource::ModifierKeyCode::k_total);\r\n\r\n                    if (in_event.alt == true)\r\n                    {\r\n                        modifiers.push_back(ChilliSource::ModifierKeyCode::k_alt);\r\n                    }\r\n                    if (in_event.control == true)\r\n                    {\r\n                        modifiers.push_back(ChilliSource::ModifierKeyCode::k_ctrl);\r\n                    }\r\n                    if (in_event.shift == true)\r\n                    {\r\n                        modifiers.push_back(ChilliSource::ModifierKeyCode::k_shift);\r\n                    }\r\n                    if (in_event.system == true)\r\n                    {\r\n                        modifiers.push_back(ChilliSource::ModifierKeyCode::k_system);\r\n                    }\r\n\r\n                    m_keyPressedEvent.NotifyConnections(keyCode, std::move(modifiers));\r\n                }\r\n            });\r\n\t\t}\r\n\t\t//-------------------------------------------------------\r\n\t\t//-------------------------------------------------------\r\n\t\tvoid Keyboard::OnKeyReleased(sf::Keyboard::Key in_code)\r\n\t\t{\r\n            ChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_mainThread, [=](const ChilliSource::TaskContext& context)\r\n            {\r\n\t\t\t    auto keyCode = SFMLKeyCodeToCSKeyCode(in_code);\r\n\t\t\t    if (IsKeyDown(keyCode) == true)\r\n\t\t\t    {\r\n\t\t\t\t    m_keysDown[static_cast<u32>(keyCode)] = false;\r\n\r\n\t\t\t\t    m_keyReleasedEvent.NotifyConnections(keyCode);\r\n\t\t\t    }\r\n            });\r\n\t\t}\r\n\t\t//-------------------------------------------------------\r\n\t\t//-------------------------------------------------------\r\n\t\tbool Keyboard::IsKeyDown(ChilliSource::KeyCode in_code) const\r\n\t\t{\r\n            CS_ASSERT(ChilliSource::Application::Get()->GetTaskScheduler()->IsMainThread(), \"Attempted to access held keys outside of the main thread.\");\r\n\t\t\treturn m_keysDown[static_cast<u32>(in_code)];\r\n\t\t}\r\n\t\t//-------------------------------------------------------\r\n\t\t//-------------------------------------------------------\r\n\t\tChilliSource::IConnectableEvent<Keyboard::KeyPressedDelegate>& Keyboard::GetKeyPressedEvent()\r\n\t\t{\r\n\t\t\treturn m_keyPressedEvent;\r\n\t\t}\r\n\t\t//-------------------------------------------------------\r\n\t\t//-------------------------------------------------------\r\n\t\tChilliSource::IConnectableEvent<Keyboard::KeyReleasedDelegate>& Keyboard::GetKeyReleasedEvent()\r\n\t\t{\r\n\t\t\treturn m_keyReleasedEvent;\r\n\t\t}\r\n\t\t//-------------------------------------------------------\r\n\t\t//-------------------------------------------------------\r\n\t\tvoid Keyboard::OnDestroy()\r\n\t\t{\r\n            SFMLWindow::Get()->RemoveKeyDelegates();\r\n\r\n\t\t\tfor (auto& flag : m_keysDown)\r\n\t\t\t{\r\n\t\t\t\tflag = false;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\n\r\n#endif\r\n"
  },
  {
    "path": "Source/CSBackend/Platform/Windows/Input/Keyboard/Keyboard.h",
    "content": "//\r\n//  Keyboard.h\r\n//  ChilliSource\r\n//  Created by Scott Downie on 09/07/2014\r\n//\r\n//  The MIT License (MIT)\r\n//\r\n//  Copyright (c) 2014 Tag Games Limited\r\n//\r\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\r\n//  of this software and associated documentation files (the \"Software\"), to deal\r\n//  in the Software without restriction, including without limitation the rights\r\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\n//  copies of the Software, and to permit persons to whom the Software is\r\n//  furnished to do so, subject to the following conditions:\r\n//\r\n//  The above copyright notice and this permission notice shall be included in\r\n//  all copies or substantial portions of the Software.\r\n//\r\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r\n//  THE SOFTWARE.\r\n//\r\n\r\n#ifdef CS_TARGETPLATFORM_WINDOWS\r\n\r\n#ifndef _CSBACKEND_PLATFORM_WINDOWS_INPUT_KEYBOARD_KEYBOARD_H_\r\n#define _CSBACKEND_PLATFORM_WINDOWS_INPUT_KEYBOARD_KEYBOARD_H_\r\n\r\n#include <ChilliSource/Input/Keyboard/Keyboard.h>\r\n#include <ChilliSource/Input/Keyboard/KeyCode.h>\r\n#include <CSBackend/Platform/Windows/SFML/Base/SFMLWindow.h>\r\n\r\n#include <array>\r\n\r\nnamespace CSBackend\r\n{\r\n\tnamespace Windows\r\n\t{\r\n        //---------------------------------------------------------------\r\n        /// A system for receiving input from the current keyboard\r\n        ///\r\n        /// The methods in this class are not thread-safe and must be\r\n        /// accessed from the main thread.\r\n        ///\r\n        /// @author S Downie\r\n        //---------------------------------------------------------------\r\n\t\tclass Keyboard final : public ChilliSource::Keyboard\r\n\t\t{\r\n\t\tpublic:\r\n            CS_DECLARE_NAMEDTYPE(Keyboard);\r\n            \r\n\t\t\t//----------------------------------------------------\r\n\t\t\t/// Queries whether or not this system implements the\r\n\t\t\t/// interface with the given ID.\r\n\t\t\t///\r\n\t\t\t/// @author S Downie\r\n\t\t\t///\r\n\t\t\t/// @param The interface Id.\r\n\t\t\t///\r\n\t\t\t/// @return Whether or not the interface is implemented.\r\n\t\t\t//----------------------------------------------------\r\n\t\t\tbool IsA(ChilliSource::InterfaceIDType in_interfaceId) const override;\r\n            //-------------------------------------------------------\r\n            /// Check whether the key is currently down. This is\r\n            /// unbuffered so will only check the state of the key\r\n            /// at the moment in time when it is called\r\n            ///\r\n            /// @author S Downie\r\n            ///\r\n            /// @param Key code\r\n            ///\r\n            /// @return Whether the key is down\r\n            //-------------------------------------------------------\r\n\t\t\tbool IsKeyDown(ChilliSource::KeyCode in_code) const override;\r\n\t\t\t//-------------------------------------------------------\r\n\t\t\t/// Get the event that is triggered whenever a key is pressed.\r\n\t\t\t///\r\n\t\t\t/// This event is guaranteed and should be used for low\r\n\t\t\t/// frequency events such as catching a confirm enter press.\r\n\t\t\t/// The polling \"IsDown\" method should be used for realtime\r\n\t\t\t/// events such as moving characters on arrow press, etc.\r\n\t\t\t///\r\n\t\t\t/// The event also returns the current state of the modifier\r\n\t\t\t/// keys (Ctrl, Alt, Shift, etc.)\r\n\t\t\t///\r\n\t\t\t/// @author S Downie\r\n\t\t\t///\r\n\t\t\t/// @return Event to register for key presses\r\n\t\t\t//-------------------------------------------------------\r\n\t\t\tChilliSource::IConnectableEvent<KeyPressedDelegate>& GetKeyPressedEvent() override;\r\n\t\t\t//-------------------------------------------------------\r\n\t\t\t/// Get the event that is triggered whenever a key is released.\r\n\t\t\t///\r\n\t\t\t/// This event is guaranteed and should be used for low\r\n\t\t\t/// frequency events. The polling \"IsUp\" method should be\r\n\t\t\t/// used for realtime events.\r\n\t\t\t///\r\n\t\t\t/// @author S Downie\r\n\t\t\t///\r\n\t\t\t/// @return Event to register for key releases\r\n\t\t\t//-------------------------------------------------------\r\n\t\t\tChilliSource::IConnectableEvent<KeyReleasedDelegate>& GetKeyReleasedEvent() override;\r\n            \r\n        private:\r\n            \r\n\t\t\tfriend ChilliSource::KeyboardUPtr ChilliSource::Keyboard::Create();\r\n\t\t\t//-------------------------------------------------------\r\n\t\t\t/// Constructor\r\n\t\t\t/// \r\n\t\t\t/// @author S Downie\r\n\t\t\t//-------------------------------------------------------\r\n\t\t\tKeyboard() = default;\r\n\t\t\t//-------------------------------------------------------\r\n\t\t\t/// Called when the system is initialised and registers\r\n\t\t\t/// for SFML key events\r\n\t\t\t///\r\n\t\t\t/// @author S Downie\r\n\t\t\t//-------------------------------------------------------\r\n\t\t\tvoid OnInit() override;\r\n\t\t\t//-------------------------------------------------------\r\n\t\t\t/// Triggered by SFML when key is pressed\r\n\t\t\t///\r\n\t\t\t/// @param Key code\r\n\t\t\t/// @param Key event\r\n\t\t\t///\r\n\t\t\t/// @author S Downie\r\n\t\t\t//-------------------------------------------------------\r\n\t\t\tvoid OnKeyPressed(sf::Keyboard::Key in_code, const sf::Event::KeyEvent& in_event);\r\n\t\t\t//-------------------------------------------------------\r\n\t\t\t/// Triggered by SFML when key is released\r\n\t\t\t///\r\n\t\t\t/// @param Key code\r\n\t\t\t///\r\n\t\t\t/// @author S Downie\r\n\t\t\t//-------------------------------------------------------\r\n\t\t\tvoid OnKeyReleased(sf::Keyboard::Key in_code);\r\n\t\t\t//-------------------------------------------------------\r\n\t\t\t/// Called when the system is destroyed and unsubscribes\r\n\t\t\t/// from SFML key events\r\n\t\t\t///\r\n\t\t\t/// @author S Downie\r\n\t\t\t//-------------------------------------------------------\r\n\t\t\tvoid OnDestroy() override;\r\n\r\n\t\tprivate:\r\n\r\n\t\t\tChilliSource::Event<KeyPressedDelegate> m_keyPressedEvent;\r\n\t\t\tChilliSource::Event<KeyReleasedDelegate> m_keyReleasedEvent;\r\n\r\n\t\t\tstd::array<bool, static_cast<u32>(ChilliSource::KeyCode::k_total)> m_keysDown;\r\n\t\t};\r\n\t}\r\n}\r\n\r\n#endif\r\n\r\n#endif\r\n\r\n\r\n"
  },
  {
    "path": "Source/CSBackend/Platform/Windows/Input/Pointer/PointerSystem.cpp",
    "content": "//\r\n//  PointerSystem.cpp\r\n//  ChilliSource\r\n//  Created by Ian Copland on 27/03/2014.\r\n//\r\n//  The MIT License (MIT)\r\n//\r\n//  Copyright (c) 2014 Tag Games Limited\r\n//\r\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\r\n//  of this software and associated documentation files (the \"Software\"), to deal\r\n//  in the Software without restriction, including without limitation the rights\r\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\n//  copies of the Software, and to permit persons to whom the Software is\r\n//  furnished to do so, subject to the following conditions:\r\n//\r\n//  The above copyright notice and this permission notice shall be included in\r\n//  all copies or substantial portions of the Software.\r\n//\r\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r\n//  THE SOFTWARE.\r\n//\r\n\r\n#ifdef CS_TARGETPLATFORM_WINDOWS\r\n\r\n#include <CSBackend/Platform/Windows/Input/Pointer/PointerSystem.h>\r\n\r\n#include <ChilliSource/Core/Base/Application.h>\r\n#include <ChilliSource/Core/Base/AppConfig.h>\r\n#include <ChilliSource/Core/Base/Screen.h>\r\n#include <ChilliSource/Core/Threading/TaskScheduler.h>\r\n#include <ChilliSource/Core/Delegate/MakeDelegate.h>\r\n\r\nnamespace CSBackend\r\n{\r\n\tnamespace Windows\r\n\t{\r\n\t\tnamespace\r\n\t\t{\r\n\t\t\t//------------------------------------------------\r\n\t\t\t/// @author S Downie\r\n\t\t\t///\r\n\t\t\t/// @param The SFML button ID.\r\n\t\t\t///\r\n\t\t\t/// @return The equivelent Press Type for the\r\n\t\t\t/// button Id\r\n\t\t\t//------------------------------------------------\r\n\t\t\tChilliSource::Pointer::InputType ButtonIdToInputType(sf::Mouse::Button in_button)\r\n\t\t\t{\r\n\t\t\t\tswitch (in_button)\r\n\t\t\t\t{\r\n\t\t\t\tcase sf::Mouse::Button::Left:\r\n\t\t\t\t\treturn ChilliSource::Pointer::InputType::k_leftMouseButton;\r\n\t\t\t\tcase sf::Mouse::Button::Middle:\r\n\t\t\t\t\treturn ChilliSource::Pointer::InputType::k_middleMouseButton;\r\n\t\t\t\tcase sf::Mouse::Button::Right:\r\n\t\t\t\t\treturn ChilliSource::Pointer::InputType::k_rightMouseButton;\r\n\t\t\t\tdefault:\r\n\t\t\t\t\treturn ChilliSource::Pointer::InputType::k_none;\r\n\t\t\t\t}\r\n\r\n\t\t\t}\r\n\t\t}\r\n\t\tCS_DEFINE_NAMEDTYPE(PointerSystem);\r\n\t\t//----------------------------------------------------\r\n\t\t//----------------------------------------------------\r\n\t\tbool PointerSystem::IsA(ChilliSource::InterfaceIDType in_interfaceId) const\r\n\t\t{\r\n\t\t\treturn (ChilliSource::PointerSystem::InterfaceID == in_interfaceId || PointerSystem::InterfaceID == in_interfaceId);\r\n\t\t}\r\n\t\t//------------------------------------------------\r\n\t\t//------------------------------------------------\r\n\t\tvoid PointerSystem::OnInit()\r\n\t\t{\r\n\t\t\tm_screen = ChilliSource::Application::Get()->GetSystem<ChilliSource::Screen>();\r\n\t\t\tCS_ASSERT(m_screen != nullptr, \"Cannot find system required by PointerSystem: Screen.\");\r\n\r\n            auto screenResolution = m_screen->GetResolution();\r\n\r\n            SFMLWindow::Get()->SetMouseDelegates(ChilliSource::MakeDelegate(this, &PointerSystem::OnMouseButtonEvent), ChilliSource::MakeDelegate(this, &PointerSystem::OnMouseMoved), ChilliSource::MakeDelegate(this, &PointerSystem::OnMouseWheeled));\r\n\r\n            //create the mouse pointer\r\n            ChilliSource::Integer2 mousePosi = SFMLWindow::Get()->GetMousePosition();\r\n            ChilliSource::Vector2 mousePos((f32)mousePosi.x, screenResolution.y - (f32)mousePosi.y);\r\n\r\n            m_pointerId = AddPointerCreateEvent(mousePos);\r\n\r\n\t\t\tChilliSource::Application::Get()->GetAppConfig()->GetCursorType() == ChilliSource::CursorType::k_system ? ShowSystemCursor() : HideSystemCursor();\r\n\t\t}\r\n\t\t//----------------------------------------------------\r\n\t\t//----------------------------------------------------\r\n\t\tvoid PointerSystem::HideSystemCursor()\r\n\t\t{\r\n            CS_ASSERT(ChilliSource::Application::Get()->GetTaskScheduler()->IsMainThread(), \"Tried to hide mouse cursor outside of main thread.\");\r\n            ChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_system, [=](const ChilliSource::TaskContext& context)\r\n            {\r\n                SFMLWindow::Get()->HideSystemCursor();\r\n            });\r\n\t\t}\r\n\t\t//----------------------------------------------------\r\n\t\t//----------------------------------------------------\r\n\t\tvoid PointerSystem::ShowSystemCursor()\r\n\t\t{\r\n            CS_ASSERT(ChilliSource::Application::Get()->GetTaskScheduler()->IsMainThread(), \"Tried to show mouse cursor outside of main thread.\");\r\n            ChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_system, [=](const ChilliSource::TaskContext& context)\r\n            {\r\n                SFMLWindow::Get()->ShowSystemCursor();\r\n            });\r\n\t\t}\r\n\t\t//----------------------------------------------\r\n\t\t//----------------------------------------------\r\n\t\tvoid PointerSystem::OnMouseButtonEvent(sf::Mouse::Button in_button, SFMLWindow::MouseButtonEvent in_event, s32 in_xPos, s32 in_yPos)\r\n\t\t{\r\n            ChilliSource::Pointer::InputType type = ButtonIdToInputType(in_button);\r\n            if (type == ChilliSource::Pointer::InputType::k_none)\r\n            {\r\n                return;\r\n            }\r\n\r\n            switch (in_event)\r\n            {\r\n            case SFMLWindow::MouseButtonEvent::k_pressed:\r\n                AddPointerDownEvent(m_pointerId, type);\r\n                break;\r\n            case SFMLWindow::MouseButtonEvent::k_released:\r\n                AddPointerUpEvent(m_pointerId, type);\r\n                break;\r\n            }\r\n\t\t}\r\n\t\t//----------------------------------------------\r\n\t\t//----------------------------------------------\r\n\t\tvoid PointerSystem::OnMouseMoved(s32 in_xPos, s32 in_yPos)\r\n\t\t{\r\n            ChilliSource::Vector2 touchLocation((f32)in_xPos, m_screen->GetResolution().y - (f32)in_yPos);\r\n            AddPointerMovedEvent(m_pointerId, touchLocation);\r\n\t\t}\r\n\t\t//----------------------------------------------\r\n\t\t//----------------------------------------------\r\n\t\tvoid PointerSystem::OnMouseWheeled(s32 in_delta)\r\n\t\t{\r\n            ChilliSource::Vector2 delta(0.0f, (f32)in_delta);\r\n            AddPointerScrollEvent(m_pointerId, delta);\r\n\t\t}\r\n\t\t//------------------------------------------------\r\n\t\t//------------------------------------------------\r\n\t\tvoid PointerSystem::OnDestroy()\r\n\t\t{\r\n\t\t\tAddPointerRemoveEvent(m_pointerId);\r\n\r\n            SFMLWindow::Get()->RemoveMouseDelegates();\r\n\r\n\t\t\tm_screen = nullptr;\r\n\t\t}\r\n\t}\r\n}\r\n\r\n#endif\r\n"
  },
  {
    "path": "Source/CSBackend/Platform/Windows/Input/Pointer/PointerSystem.h",
    "content": "//\r\n//  PointerSystem.h\r\n//  ChilliSource\r\n//  Created by Ian Copland on 27/03/2014.\r\n//\r\n//  The MIT License (MIT)\r\n//\r\n//  Copyright (c) 2014 Tag Games Limited\r\n//\r\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\r\n//  of this software and associated documentation files (the \"Software\"), to deal\r\n//  in the Software without restriction, including without limitation the rights\r\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\n//  copies of the Software, and to permit persons to whom the Software is\r\n//  furnished to do so, subject to the following conditions:\r\n//\r\n//  The above copyright notice and this permission notice shall be included in\r\n//  all copies or substantial portions of the Software.\r\n//\r\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r\n//  THE SOFTWARE.\r\n//\r\n\r\n#ifdef CS_TARGETPLATFORM_WINDOWS\r\n\r\n#ifndef _CSBACKEND_PLATFORM_WINDOWS_INPUT_POINTER_POINTERSYSTEM_H_\r\n#define _CSBACKEND_PLATFORM_WINDOWS_INPUT_POINTER_POINTERSYSTEM_H_\r\n\r\n#include <ChilliSource/ChilliSource.h>\r\n#include <CSBackend/Platform/Windows/ForwardDeclarations.h>\r\n#include <CSBackend/Platform/Windows/SFML/Base/SFMLWindow.h>\r\n#include <ChilliSource/Input/Pointer/PointerSystem.h>\r\n\r\nstruct GLFWwindow;\r\n\r\nnamespace CSBackend\r\n{\r\n\tnamespace Windows\r\n\t{\r\n\t\t//------------------------------------------------------------\r\n\t\t/// The iOS backend for the pointer system. This provides\r\n\t\t/// access to touch events.\r\n\t\t///\r\n        /// The methods in this class are not thread-safe and must be\r\n        /// accessed from the main thread.\r\n        ///\r\n\t\t/// @author Ian Copland\r\n\t\t//------------------------------------------------------------\r\n\t\tclass PointerSystem final : public ChilliSource::PointerSystem\r\n\t\t{\r\n\t\tpublic:\r\n\t\t\tCS_DECLARE_NAMEDTYPE(PointerSystem);\r\n\t\t\t//----------------------------------------------------\r\n\t\t\t/// Queries whether or not this system implements the\r\n\t\t\t/// interface with the given ID.\r\n\t\t\t///\r\n\t\t\t/// @author Ian Copland\r\n\t\t\t///\r\n\t\t\t/// @param The interface Id.\r\n\t\t\t///\r\n\t\t\t/// @return Whether or not the interface is implemented.\r\n\t\t\t//----------------------------------------------------\r\n\t\t\tbool IsA(ChilliSource::InterfaceIDType in_interfaceId) const override;\r\n\t\t\t//----------------------------------------------------\r\n\t\t\t/// Hide the window cursor\r\n\t\t\t///\r\n\t\t\t/// @author S Downie\r\n\t\t\t//----------------------------------------------------\r\n\t\t\tvoid HideSystemCursor() override;\r\n\t\t\t//----------------------------------------------------\r\n\t\t\t/// Show the window cursor\r\n\t\t\t///\r\n\t\t\t/// @author S Downie\r\n\t\t\t//----------------------------------------------------\r\n\t\t\tvoid ShowSystemCursor() override;\r\n\r\n\t\tprivate:\r\n\t\t\tfriend class ChilliSource::PointerSystem;\r\n\t\t\t//----------------------------------------------\r\n\t\t\t/// Triggered by SFML when the cursor moves\r\n\t\t\t///\r\n\t\t\t/// @author S Downie\r\n\t\t\t///\r\n\t\t\t/// @param Current position X\r\n\t\t\t/// @param Current position Y\r\n\t\t\t//----------------------------------------------\r\n\t\t\tvoid OnMouseMoved(s32 in_xPos, s32 in_yPos);\r\n\t\t\t//----------------------------------------------\r\n\t\t\t/// Triggered by SFML when a mouse button is\r\n\t\t\t/// pressed\r\n\t\t\t///\r\n\t\t\t/// @author S Downie\r\n\t\t\t///\r\n\t\t\t/// @param Button ID\r\n\t\t\t/// @param Button action (Press/Release)\r\n\t\t\t/// @param Current position X\r\n\t\t\t/// @param Current position Y\r\n\t\t\t//----------------------------------------------\r\n\t\t\tvoid OnMouseButtonEvent(sf::Mouse::Button in_button, SFMLWindow::MouseButtonEvent in_event, s32 in_xPos, s32 in_yPos);\r\n\t\t\t//----------------------------------------------\r\n\t\t\t/// Triggered by SFML when the mouse wheel is scrolled\r\n\t\t\t///\r\n\t\t\t/// @author S Downie\r\n\t\t\t///\r\n\t\t\t/// @param Number of ticks scrolled in the y-axis\r\n\t\t\t//----------------------------------------------\r\n\t\t\tvoid OnMouseWheeled(s32 in_delta);\r\n\t\t\t//------------------------------------------------\r\n\t\t\t/// Default constructor. Declared private to force\r\n\t\t\t/// the use of the factory method.\r\n\t\t\t///\r\n\t\t\t/// @author Ian Copland\r\n\t\t\t//------------------------------------------------\r\n\t\t\tPointerSystem() = default;\r\n\t\t\t//------------------------------------------------\r\n\t\t\t/// Initialisation method called at a time when\r\n\t\t\t/// all App Systems have been created. System\r\n\t\t\t/// initialisation occurs in the order they were\r\n\t\t\t/// created.\r\n\t\t\t///\r\n\t\t\t/// @author Ian Copland\r\n\t\t\t//------------------------------------------------\r\n\t\t\tvoid OnInit() override;\r\n\t\t\t//------------------------------------------------\r\n\t\t\t/// Called when the application is being destroyed.\r\n\t\t\t/// This should be used to cleanup memory and\r\n\t\t\t/// references to other systems. System destruction\r\n\t\t\t/// occurs in the reverse order to which they\r\n\t\t\t/// were created\r\n\t\t\t///\r\n\t\t\t/// @author Ian Copland\r\n\t\t\t//------------------------------------------------\r\n\t\t\tvoid OnDestroy() override;\r\n\r\n\t\t\tChilliSource::Screen* m_screen;\r\n\t\t\tChilliSource::Pointer::Id m_pointerId;\r\n\t\t};\r\n\t}\r\n}\r\n\r\n#endif\r\n\r\n#endif\r\n"
  },
  {
    "path": "Source/CSBackend/Platform/Windows/Input/TextEntry/TextEntry.cpp",
    "content": "//\r\n//  TextEntry.cpp\r\n//  ChilliSource\r\n//  Created by Scott Downie on 08/07/2014\r\n//\r\n//  The MIT License (MIT)\r\n//\r\n//  Copyright (c) 2014 Tag Games Limited\r\n//\r\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\r\n//  of this software and associated documentation files (the \"Software\"), to deal\r\n//  in the Software without restriction, including without limitation the rights\r\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\n//  copies of the Software, and to permit persons to whom the Software is\r\n//  furnished to do so, subject to the following conditions:\r\n//\r\n//  The above copyright notice and this permission notice shall be included in\r\n//  all copies or substantial portions of the Software.\r\n//\r\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r\n//  THE SOFTWARE.\r\n//\r\n\r\n#ifdef CS_TARGETPLATFORM_WINDOWS\r\n\r\n#include <CSBackend/Platform/Windows/Input/TextEntry/TextEntry.h>\r\n\r\n#include <ChilliSource/Core/Base/Application.h>\r\n#include <ChilliSource/Core/Delegate/MakeDelegate.h>\r\n#include <ChilliSource/Core/Threading/TaskScheduler.h>\r\n#include <CSBackend/Platform/Windows/SFML/Base/SFMLWindow.h>\r\n\r\nnamespace CSBackend\r\n{\r\n\tnamespace Windows\r\n\t{\r\n\t\tCS_DEFINE_NAMEDTYPE(TextEntry);\r\n\r\n\t\t//-------------------------------------------------------\r\n\t\t//-------------------------------------------------------\r\n\t\tbool TextEntry::IsA(ChilliSource::InterfaceIDType in_interfaceId) const\r\n\t\t{\r\n\t\t\treturn in_interfaceId == ChilliSource::TextEntry::InterfaceID || in_interfaceId == TextEntry::InterfaceID;\r\n\t\t}\r\n\t\t//-------------------------------------------------------\r\n\t\t//-------------------------------------------------------\r\n\t\tvoid TextEntry::Activate(const std::string& in_text, ChilliSource::TextEntryType in_type, ChilliSource::TextEntryCapitalisation in_capitalisation, const TextBufferChangedDelegate& in_changeDelegate, const TextInputDeactivatedDelegate& in_deactivateDelegate)\r\n\t\t{\r\n            CS_ASSERT(ChilliSource::Application::Get()->GetTaskScheduler()->IsMainThread(), \"Cannot activate system text entry outside of main thread.\");\r\n            CS_ASSERT(!m_active, \"Cannot activate TextEntry system while already active.\");\r\n\r\n            m_active = true;\r\n\t\t\tm_text = in_text;\r\n\t\t\tm_textBufferChangedDelegate = in_changeDelegate;\r\n\t\t\tm_textInputDeactivatedDelegate = in_deactivateDelegate;\r\n\t\t\tSFMLWindow::Get()->SetTextEnteredDelegate(ChilliSource::MakeDelegate(this, &TextEntry::OnTextEntered));\r\n\t\t}\r\n\t\t//-------------------------------------------------------\r\n\t\t//-------------------------------------------------------\r\n        void TextEntry::Deactivate()\r\n        {\r\n            CS_ASSERT(ChilliSource::Application::Get()->GetTaskScheduler()->IsMainThread(), \"Cannot deactivate system text entry outside of main thread.\");\r\n            CS_ASSERT(m_active, \"Cannot deactivate TextEntry system when not active.\");\r\n\r\n            m_active = false;\r\n            SFMLWindow::Get()->RemoveTextEnteredDelegate();\r\n            if (m_textInputDeactivatedDelegate != nullptr)\r\n            {\r\n                auto delegate = m_textInputDeactivatedDelegate;\r\n                m_textInputDeactivatedDelegate = nullptr;\r\n                delegate();\r\n            }\r\n\t\t}\r\n        //-------------------------------------------------------\r\n        //-------------------------------------------------------\r\n        bool TextEntry::IsActive() const\r\n        {\r\n            return m_active;\r\n        }\r\n        //-------------------------------------------------------\r\n        //-------------------------------------------------------\r\n        const std::string& TextEntry::GetTextBuffer() const\r\n        {\r\n            CS_ASSERT(ChilliSource::Application::Get()->GetTaskScheduler()->IsMainThread(), \"Cannot get system text entry buffer outside of main thread.\");\r\n            return m_text;\r\n        }\r\n        //-------------------------------------------------------\r\n        //-------------------------------------------------------\r\n        void TextEntry::SetTextBuffer(const std::string& in_text)\r\n        {\r\n            CS_ASSERT(ChilliSource::Application::Get()->GetTaskScheduler()->IsMainThread(), \"Cannot set system text entry buffer outside of main thread.\");\r\n            m_text = in_text;\r\n        }\r\n\t\t//-------------------------------------------------------\r\n\t\t//-------------------------------------------------------\r\n        void TextEntry::OnTextEntered(ChilliSource::UTF8Char in_unicodeChar)\r\n        {\r\n            ChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_mainThread, [=](const ChilliSource::TaskContext& taskContext)\r\n            {\r\n                std::unique_lock<std::mutex> lock(m_mutex);\r\n                const ChilliSource::UTF8Char k_backspace = 8;\r\n\r\n                std::string text;\r\n\r\n                if (in_unicodeChar != k_backspace)\r\n                {\r\n                    text = ChilliSource::UTF8StringUtils::AppendCopy(in_unicodeChar, m_text);\r\n                }\r\n                else\r\n                {\r\n                    s32 length = (s32)ChilliSource::UTF8StringUtils::CalcLength(m_text.begin(), m_text.end());\r\n                    length = std::max(length - 1, 0);\r\n                    text = ChilliSource::UTF8StringUtils::SubString(m_text, 0, (u32)length);\r\n                }\r\n\r\n                bool acceptText = true;\r\n\r\n                if (m_textBufferChangedDelegate != nullptr)\r\n                {\r\n                    acceptText = m_textBufferChangedDelegate(text);\r\n                }\r\n\r\n                if (acceptText == true)\r\n                {\r\n                    m_text = std::move(text);\r\n                }\r\n            });\r\n        }\r\n\t}\r\n}\r\n\r\n#endif\r\n"
  },
  {
    "path": "Source/CSBackend/Platform/Windows/Input/TextEntry/TextEntry.h",
    "content": "//\n//  TextEntry.h\n//  ChilliSource\n//  Created by Scott Downie on 08/07/2014\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_WINDOWS\n\n#ifndef _CSBACKEND_PLATFORM_WINDOWS_INPUT_TEXTENTRY_TEXTENTRY_H_\n#define _CSBACKEND_PLATFORM_WINDOWS_INPUT_TEXTENTRY_TEXTENTRY_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Event/EventConnection.h>\n#include <ChilliSource/Core/String/UTF8StringUtils.h>\n#include <ChilliSource/Input/TextEntry/TextEntry.h>\n#include <ChilliSource/Input/TextEntry/TextEntryCapitalisation.h>\n#include <ChilliSource/Input/TextEntry/TextEntryType.h>\n#include <CSBackend/Platform/Windows/ForwardDeclarations.h>\n\n#include <mutex>\n\n\nnamespace CSBackend\n{\n\tnamespace Windows\n\t{\n        //----------------------------------------------------------------\n        /// The Windows backend to the text entry system. Using SFML\n\t\t/// text entry events this class builds a buffer of input text.\n\t\t///\n\t\t/// NOTE: This class ignores the capitalisation policies.\n        ///\n        /// The methods in this class are not thread-safe and must be called\n        /// from the main thread.\n        ///\n        /// @author S Downie\n        //----------------------------------------------------------------\n\t\tclass TextEntry final : public ChilliSource::TextEntry\n\t\t{\n\t\tpublic:\n\t\t\tCS_DECLARE_NAMEDTYPE(TextEntry);\n\t\t\t//-------------------------------------------------------\n\t\t\t/// @author S Downie\n\t\t\t///\n\t\t\t/// @param Interface ID\n\t\t\t///\n\t\t\t/// @return Whether this system implements the given inteface\n\t\t\t//-------------------------------------------------------\n\t\t\tbool IsA(ChilliSource::InterfaceIDType in_interfaceId) const override;\n\t\t\t//-------------------------------------------------------\n\t\t\t/// The system will now receive text input.\n\t\t\t///\n\t\t\t/// @author S Downie\n\t\t\t///\n\t\t\t/// @param Initial buffer contents\n\t\t\t/// @param Preferred keyboard type\n\t\t\t/// @param Preferred capitalisation method\n\t\t\t/// @param Text changed delegate\n\t\t\t/// @param Deactivate delegate\n\t\t\t//-------------------------------------------------------\n\t\t\tvoid Activate(const std::string& in_text, ChilliSource::TextEntryType in_type, ChilliSource::TextEntryCapitalisation in_capitalisation, const TextBufferChangedDelegate& in_changeDelegate, const TextInputDeactivatedDelegate& in_deactivateDelegate) override;\n\t\t\t//-------------------------------------------------------\n\t\t\t/// The system will no longer receive text input.\n\t\t\t///\n\t\t\t/// @author S Downie\n\t\t\t//-------------------------------------------------------\n\t\t\tvoid Deactivate() override;\n\t\t\t//-------------------------------------------------------\n\t\t\t/// @author S Downie\n\t\t\t///\n\t\t\t/// @return Whether or not text input is currently\n\t\t\t/// enabled.\n\t\t\t//-------------------------------------------------------\n\t\t\tbool IsActive() const override;\n            //-------------------------------------------------------\n            /// @author S Downie\n            ///\n            /// @return The current text input buffer (UTF-8).\n            //-------------------------------------------------------\n\t\t\tconst std::string& GetTextBuffer() const override;\n            //-------------------------------------------------------\n            /// @author S Downie\n            ///\n            /// @param The new text input buffer (UTF-8).\n            //-------------------------------------------------------\n            void SetTextBuffer(const std::string& in_text) override;\n\n\t\tprivate:\n            friend ChilliSource::TextEntryUPtr ChilliSource::TextEntry::Create();\n\n            //-------------------------------------------------------\n            /// Constructor. Declared private to force the use of the\n            /// factory method.\n            ///\n            /// @author S Downie\n            //-------------------------------------------------------\n\t\t\tTextEntry() = default;\n\t\t\t//-------------------------------------------------------\n\t\t\t/// Called when a text character is entered\n\t\t\t///\n\t\t\t/// @author S Downie\n\t\t\t///\n\t\t\t/// @param UTF-8 character\n\t\t\t//-------------------------------------------------------\n\t\t\tvoid OnTextEntered(ChilliSource::UTF8Char in_unicodeChar);\n\n\t\tprivate:\n\n            TextBufferChangedDelegate m_textBufferChangedDelegate;\n            TextInputDeactivatedDelegate m_textInputDeactivatedDelegate;\n\n            std::mutex m_mutex;\n\n            bool m_active = false;\n\t\t\tstd::string m_text;\n\t\t};\n\t}\n}\n\n#endif\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Windows/Main.cpp",
    "content": "//\n//  Main.cpp\n//  ChilliSource\n//  Created by Ian Copland on 06/07/2011.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2010 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_WINDOWS\n\n#include <CSBackend/Platform/Windows/SFML/Base/SFMLWindow.h>\n\n#include <Windows.h>\n\n//----------------------------------------------------------------------------------\n/// Includes the \"main\" function as required by Windows and will create\n/// the inherited CS application using the exposed CreateApplication method that\n/// the application code base must implement.\n///\n/// @author S Downie\n///\n/// @param Handle to current application instance\n/// @param Handle to previous application instance\n/// @param Command line\n/// @param Controls how the window is to be shown (i.e hide, maximize, etc)\n///\n/// @return Exit status\n//----------------------------------------------------------------------------------\nint CALLBACK WinMain(_In_ HINSTANCE in_instance, _In_ HINSTANCE in_prevInstance, _In_ LPSTR in_cmdLine, _In_ int in_cmdShow)\n{\n\tCSBackend::Windows::SFMLWindow::Create();\n\tCSBackend::Windows::SFMLWindow::Get()->Run();\n\tCSBackend::Windows::SFMLWindow::Destroy();\n    return 0;\n}\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/Windows/Networking/Http/HttpRequest.cpp",
    "content": "//\r\n//  HttpRequestSystem.cpp\r\n//  ChilliSource\r\n//  Created by Scott Downie on 23/05/2011.\r\n//\r\n//  The MIT License (MIT)\r\n//\r\n//  Copyright (c) 2011 Tag Games Limited\r\n//\r\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\r\n//  of this software and associated documentation files (the \"Software\"), to deal\r\n//  in the Software without restriction, including without limitation the rights\r\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\n//  copies of the Software, and to permit persons to whom the Software is\r\n//  furnished to do so, subject to the following conditions:\r\n//\r\n//  The above copyright notice and this permission notice shall be included in\r\n//  all copies or substantial portions of the Software.\r\n//\r\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r\n//  THE SOFTWARE.\r\n//\r\n\r\n#ifdef CS_TARGETPLATFORM_WINDOWS\r\n\r\n#include <CSBackend/Platform/Windows/Networking/Http/HttpRequest.h>\r\n\r\n#include <CSBackend/Platform/Windows/Core/String/WindowsStringUtils.h>\r\n#include <ChilliSource/Core/Base/Application.h>\r\n#include <ChilliSource/Core/Delegate/MakeDelegate.h>\r\n#include <ChilliSource/Core/Math/MathUtils.h>\r\n#include <ChilliSource/Core/String/StringUtils.h>\r\n#include <ChilliSource/Core/String/StringParser.h>\r\n#include <ChilliSource/Core/Threading/TaskScheduler.h>\r\n\r\n#include <Windows.h>\r\n#include <winhttp.h>\r\n#include <sstream>\r\n\r\n#pragma comment(lib, \"winhttp\")\r\n\r\nnamespace CSBackend\r\n{\r\n\tnamespace Windows\r\n\t{\r\n\t\tstd::list<std::shared_ptr<std::mutex>> HttpRequest::s_destroyingMutexes;\r\n\t\tstd::mutex HttpRequest::s_addingMutexesMutex;\r\n\t\tbool HttpRequest::s_isDestroying = false;\r\n\r\n\t\tnamespace\r\n\t\t{\r\n\t\t\tconst u32 k_readBufferSize = 1024 * 50;\r\n\r\n\t\t\t//-------------------------------------------------------------------\r\n\t\t\t/// Split the WinHTTP blob header into key values\r\n\t\t\t///\r\n\t\t\t/// @author S Downie\r\n\t\t\t///\r\n\t\t\t/// @param Blob header\r\n\t\t\t/// @param Blob size\r\n\t\t\t///\r\n\t\t\t/// @return Key value dictionary\r\n\t\t\t//-------------------------------------------------------------------\r\n\t\t\tChilliSource::ParamDictionary ParseHeaders(const WCHAR* in_headerBlob, DWORD in_headerSize)\r\n\t\t\t{\r\n\t\t\t\t//---SAMPLE\r\n\r\n\t\t\t\t//\"HTTP/1.1 200 OK\\r\\n\r\n\t\t\t\t//Connection: keep - alive\\r\\n\r\n\t\t\t\t//Date : Thu, 03 Apr 2014 08 : 18 : 57 GMT\\r\\n\r\n\t\t\t\t//Content - Length: 24\\r\\n\r\n\t\t\t\t//Content - Type: application / json\\r\\n\r\n\t\t\t\t//Server : Apache\\r\\n\r\n\t\t\t\t//X - Powered - By: PHP / 5.3.10 - 1ubuntu3.9\\r\\n\\r\\n\"\r\n\r\n\t\t\t\tChilliSource::ParamDictionary headers;\r\n\r\n\t\t\t\tstd::wstring key;\r\n\t\t\t\tstd::wstring value;\r\n\r\n\t\t\t\tu32 headerIndex = 0;\r\n\r\n\t\t\t\t//Disregard the first line as it contains only the request status\r\n\t\t\t\twhile (in_headerBlob[headerIndex] != '\\r')\r\n\t\t\t\t{\r\n\t\t\t\t\theaderIndex++;\r\n\t\t\t\t}\r\n\t\t\t\t//Skip the '\\r\\n'\r\n\t\t\t\theaderIndex += 2;\r\n\r\n\t\t\t\twhile (headerIndex < in_headerSize)\r\n\t\t\t\t{\r\n\t\t\t\t\t//Read the key\r\n\t\t\t\t\twhile (in_headerBlob[headerIndex] != ':')\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tkey += in_headerBlob[headerIndex];\r\n\t\t\t\t\t\theaderIndex++;\r\n\t\t\t\t\t}\r\n\t\t\t\t\t//Skip the ': '\r\n\t\t\t\t\theaderIndex += 2;\r\n\r\n\t\t\t\t\t//Read the value\r\n\t\t\t\t\twhile (in_headerBlob[headerIndex] != '\\r')\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tvalue += in_headerBlob[headerIndex];\r\n\t\t\t\t\t\theaderIndex++;\r\n\t\t\t\t\t}\r\n\t\t\t\t\t//Skip the '\\r\\n'\r\n\t\t\t\t\theaderIndex += 2;\r\n\r\n\t\t\t\t\t//Add to param dictionary\r\n\t\t\t\t\theaders.SetValue(WindowsStringUtils::UTF16ToUTF8(key), WindowsStringUtils::UTF16ToUTF8(value));\r\n\t\t\t\t\tkey.clear();\r\n\t\t\t\t\tvalue.clear();\r\n\r\n\t\t\t\t\t//Check for the terminating '\\r\\n'\r\n\t\t\t\t\tif (in_headerBlob[headerIndex] == '\\r' && in_headerBlob[headerIndex + 1] == '\\n')\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n\t\t\t\treturn headers;\r\n\t\t\t}\r\n\t\t\t//-------------------------------------------------------------------\r\n\t\t\t/// Get the Http header from the request\r\n\t\t\t///\r\n\t\t\t/// @author S Downie\r\n\t\t\t///\r\n\t\t\t/// @param Blob header\r\n\t\t\t///\r\n\t\t\t/// @return Key value dictionary\r\n\t\t\t//-------------------------------------------------------------------\r\n\t\t\tChilliSource::ParamDictionary GetRequestHeaders(HINTERNET in_requestHandle)\r\n\t\t\t{\r\n\t\t\t\tChilliSource::ParamDictionary headers;\r\n\r\n\t\t\t\tDWORD headerSize;\r\n\t\t\t\tWinHttpQueryHeaders(in_requestHandle, WINHTTP_QUERY_RAW_HEADERS_CRLF, WINHTTP_HEADER_NAME_BY_INDEX, nullptr, &headerSize, WINHTTP_NO_HEADER_INDEX);\r\n\t\t\t\tif (GetLastError() == ERROR_INSUFFICIENT_BUFFER)\r\n\t\t\t\t{\r\n\t\t\t\t\tDWORD bufferSize = headerSize / sizeof(WCHAR);\r\n\t\t\t\t\tWCHAR* headerBuffer = new WCHAR[bufferSize];\r\n\r\n\t\t\t\t\tif (WinHttpQueryHeaders(in_requestHandle, WINHTTP_QUERY_RAW_HEADERS_CRLF, WINHTTP_HEADER_NAME_BY_INDEX, headerBuffer, &headerSize, WINHTTP_NO_HEADER_INDEX) == TRUE)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\theaders = ParseHeaders(headerBuffer, bufferSize);\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tdelete[] headerBuffer;\r\n\t\t\t\t}\r\n\r\n\t\t\t\treturn headers;\r\n\t\t\t}\r\n\t\t}\r\n\t\t//------------------------------------------------------------------\r\n\t\t//------------------------------------------------------------------\r\n\t\tHttpRequest::HttpRequest(Type in_type, const std::string& in_url, const std::string& in_body, const ChilliSource::ParamDictionary& in_headers, u32 in_timeoutSecs, \r\n\t\t\tHINTERNET in_requestHandle, HINTERNET in_connectionHandle, u32 in_bufferFlushSize, const Delegate& in_delegate)\r\n\t\t\t: m_url(in_url), m_type(in_type), m_headers(in_headers), m_body(in_body), m_bufferFlushSize(in_bufferFlushSize), m_completionDelegate(in_delegate)\r\n\t\t{\r\n\t\t\tCS_ASSERT(m_completionDelegate, \"Http request cannot have null delegate\");\r\n\r\n\t\t\t//Begin the read loop as a threaded task\r\n\t\t\tauto destroyingMutex = std::make_shared<std::mutex>();\r\n\t\t\tstd::unique_lock<std::mutex> lock(s_addingMutexesMutex);\r\n\t\t\ts_destroyingMutexes.push_back(destroyingMutex);\r\n\t\t\tlock.unlock();\r\n\r\n\t\t\tu32 connectTimeoutMilliSecs = in_timeoutSecs * 1000;\r\n\t\t\tu32 readTimeoutMilliSecs = 60000;\r\n\t\t\t::WinHttpSetTimeouts(in_requestHandle, connectTimeoutMilliSecs, connectTimeoutMilliSecs, readTimeoutMilliSecs, readTimeoutMilliSecs);\r\n\r\n\t\t\t//TODO: This should probably be handled by a HTTP system specific thread, like the other platforms.\r\n\t\t\tm_taskScheduler = ChilliSource::Application::Get()->GetTaskScheduler();\r\n\t\t\tm_taskScheduler->ScheduleTask(ChilliSource::TaskType::k_large, [=](const ChilliSource::TaskContext&)\r\n\t\t\t{\r\n\t\t\t\tPollReadStream(in_requestHandle, in_connectionHandle, destroyingMutex);\r\n\t\t\t});\r\n\t\t}\r\n\t\t//------------------------------------------------------------------\r\n\t\t//------------------------------------------------------------------\r\n\t\tvoid HttpRequest::Update(f32 infDT)\r\n\t\t{\r\n\t\t\t//Check if the data has finished streaming and invoke the completion delegate on the main thread\r\n\t\t\tif(m_isPollingComplete == true && m_flushesPending <= 0)\r\n\t\t\t{\r\n\t\t\t\tm_isRequestComplete = true;\r\n\r\n\t\t\t\tif (m_isRequestCancelled == false)\r\n\t\t\t\t{\r\n\t\t\t\t\tm_completionDelegate(this, ChilliSource::HttpResponse(m_requestResult, m_responseCode, m_responseData));\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\t//------------------------------------------------------------------\r\n\t\t//------------------------------------------------------------------\r\n\t\tvoid HttpRequest::PollReadStream(HINTERNET in_requestHandle, HINTERNET in_connectionHandle, std::shared_ptr<std::mutex> in_destroyingMutex)\r\n\t\t{\t\r\n\t\t\tstd::unique_lock<std::mutex> lock(*in_destroyingMutex);\r\n\r\n\t\t\tif (s_isDestroying == true)\r\n\t\t\t\treturn;\r\n\r\n\t\t\tu32 bufferFlushSize = m_bufferFlushSize;\r\n\t\t\tstd::string body = m_body;\r\n\r\n\t\t\tlock.unlock();\r\n\t\t\tBOOL sendRequestResult = WinHttpSendRequest(in_requestHandle, 0, WINHTTP_NO_REQUEST_DATA, (LPVOID)body.data(), DWORD(body.length()), DWORD(body.length()), NULL);\r\n\t\t\tlock.lock();\r\n\r\n\t\t\tif (s_isDestroying == true)\r\n\t\t\t\treturn;\r\n\t\t\r\n\t\t\tif (sendRequestResult == FALSE)\r\n\t\t\t{\r\n\t\t\t\tDWORD error = GetLastError();\r\n\t\t\t\tChilliSource::HttpResponse::Result result;\r\n\t\t\t\tswitch (error)\r\n\t\t\t\t{\r\n\t\t\t\tcase ERROR_WINHTTP_TIMEOUT:\r\n\t\t\t\t\tresult = ChilliSource::HttpResponse::Result::k_timeout;\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tdefault:\r\n\t\t\t\t\tresult = ChilliSource::HttpResponse::Result::k_failed;\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tWinHttpCloseHandle(in_requestHandle);\r\n\t\t\t\tWinHttpCloseHandle(in_connectionHandle);\r\n\t\t\t\tm_isPollingComplete = true;\r\n\t\t\t\tm_requestResult = result;\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\r\n\t\t\tlock.unlock();\r\n\t\t\tBOOL receiveResponseResult = WinHttpReceiveResponse(in_requestHandle, nullptr);\r\n\t\t\tlock.lock();\r\n\r\n\t\t\tif (s_isDestroying == true)\r\n\t\t\t\treturn;\r\n\r\n\t\t\tif (receiveResponseResult == FALSE)\r\n\t\t\t{\r\n\t\t\t\tDWORD error = GetLastError();\r\n\t\t\t\tChilliSource::HttpResponse::Result result;\r\n\t\t\t\tswitch (error)\r\n\t\t\t\t{\r\n\t\t\t\tcase ERROR_WINHTTP_TIMEOUT:\r\n\t\t\t\t\tresult = ChilliSource::HttpResponse::Result::k_timeout;\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tdefault:\r\n\t\t\t\t\tresult = ChilliSource::HttpResponse::Result::k_failed;\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tWinHttpCloseHandle(in_requestHandle);\r\n\t\t\t\tWinHttpCloseHandle(in_connectionHandle);\r\n\t\t\t\tm_isPollingComplete = true;\r\n\t\t\t\tm_requestResult = result;\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\r\n\t\t\t//Get the status from the server\r\n\t\t\tDWORD headerSize = sizeof(DWORD);\r\n\t\t\tu32 responseCode = 0;\r\n\t\t\tWinHttpQueryHeaders(in_requestHandle, WINHTTP_QUERY_STATUS_CODE | WINHTTP_QUERY_FLAG_NUMBER, nullptr, &responseCode, &headerSize, nullptr);\r\n\t\t\t\r\n\t\t\tChilliSource::ParamDictionary headers = GetRequestHeaders(in_requestHandle);\r\n\t\t\tstd::string expectedSize;\r\n\t\t\theaders.TryGetValue(\"Content-Length\", expectedSize);\r\n\t\t\tm_expectedSize = ChilliSource::ParseU32(expectedSize);\r\n\r\n\t\t\t// Keep reading from the remote server until there's\r\n\t\t\t// nothing left to read\r\n\t\t\tDWORD bytesToBeRead = 0;\r\n\t\t\tDWORD bytesRead = 0;\r\n\t\t\tChilliSource::HttpResponse::Result result = ChilliSource::HttpResponse::Result::k_failed;\r\n\t\t\tu32 totalBytesReadThisBlock = 0;\r\n\t\t\ts8 readBuffer[k_readBufferSize];\r\n\t\t\tstd::stringstream streamBuffer;\r\n\r\n\t\t\tdo\r\n\t\t\t{\r\n\t\t\t\tlock.unlock(); \r\n\t\t\t\tBOOL queryAvailableResult = WinHttpQueryDataAvailable(in_requestHandle, &bytesToBeRead);\r\n\t\t\t\tlock.lock();\r\n\r\n\t\t\t\tif (s_isDestroying == true)\r\n\t\t\t\t\treturn;\r\n\r\n\t\t\t\tif (queryAvailableResult == FALSE)\r\n\t\t\t\t{\r\n\t\t\t\t\tWinHttpCloseHandle(in_requestHandle);\r\n\t\t\t\t\tWinHttpCloseHandle(in_connectionHandle);\r\n\t\t\t\t\tm_requestResult = ChilliSource::HttpResponse::Result::k_failed;\r\n\t\t\t\t\tm_isPollingComplete = true;\r\n\t\t\t\t\treturn;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tlock.unlock();\r\n\t\t\t\tBOOL readDataResult = WinHttpReadData(in_requestHandle, readBuffer, k_readBufferSize, &bytesRead);\r\n\t\t\t\tlock.lock();\r\n\r\n\t\t\t\tif (s_isDestroying == true)\r\n\t\t\t\t\treturn;\r\n\r\n\t\t\t\tif (readDataResult == FALSE)\r\n\t\t\t\t{\r\n\t\t\t\t\tWinHttpCloseHandle(in_requestHandle);\r\n\t\t\t\t\tWinHttpCloseHandle(in_connectionHandle);\r\n\t\t\t\t\tm_requestResult = ChilliSource::HttpResponse::Result::k_failed;\r\n\t\t\t\t\tm_isPollingComplete = true;\r\n\t\t\t\t\treturn;\r\n\t\t\t\t}\r\n\r\n\t\t\t\t//We have read some data\r\n\t\t\t\tif (bytesRead > 0)\r\n\t\t\t\t{\r\n\t\t\t\t\tstreamBuffer.write(readBuffer, bytesRead);\r\n\t\t\t\t\tm_totalBytesRead += bytesRead;\r\n\t\t\t\t\ttotalBytesReadThisBlock += bytesRead;\r\n\r\n\t\t\t\t\tif (bufferFlushSize != 0 && totalBytesReadThisBlock >= bufferFlushSize)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tm_responseData = streamBuffer.str();\r\n\t\t\t\t\t\tm_requestResult = ChilliSource::HttpResponse::Result::k_flushed;\r\n\r\n\t\t\t\t\t\t++m_flushesPending;\r\n\t\t\t\t\t\tm_taskScheduler->ScheduleTask(ChilliSource::TaskType::k_mainThread, [=](const ChilliSource::TaskContext&)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t--m_flushesPending;\r\n\t\t\t\t\t\t\tm_completionDelegate(this, ChilliSource::HttpResponse(m_requestResult, m_responseCode, m_responseData));\r\n\t\t\t\t\t\t});\r\n\r\n\t\t\t\t\t\tstreamBuffer.clear();\r\n\t\t\t\t\t\tstreamBuffer.str(\"\");\r\n\t\t\t\t\t\ttotalBytesReadThisBlock = 0;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n\t\t\t} while (bytesRead > 0 && m_shouldKillThread == false);\r\n\r\n\t\t\tif (m_shouldKillThread == false)\r\n\t\t\t{\r\n\t\t\t\tresult = ChilliSource::HttpResponse::Result::k_completed;\r\n\t\t\t}\r\n\r\n\t\t\tWinHttpCloseHandle(in_requestHandle);\r\n\t\t\tWinHttpCloseHandle(in_connectionHandle);\r\n\t\t\tm_isPollingComplete = true;\r\n\t\t\tm_requestResult = result;\r\n\t\t\tm_responseCode = responseCode;\r\n\t\t\tm_responseData = streamBuffer.str();\r\n\t\t}\r\n\t\t//----------------------------------------------------------------------------------------\r\n\t\t//----------------------------------------------------------------------------------------\r\n\t\tvoid HttpRequest::Cancel()\r\n\t\t{\r\n\t\t\tm_shouldKillThread = true;\r\n\t\t\tm_isRequestCancelled = true;\r\n\t\t}\r\n\t\t//----------------------------------------------------------------------------------------\r\n\t\t//----------------------------------------------------------------------------------------\r\n\t\tbool HttpRequest::HasCompleted() const\r\n\t\t{\r\n\t\t\treturn m_isRequestComplete;\r\n\t\t}\r\n\t\t//----------------------------------------------------------------------------------------\r\n\t\t//----------------------------------------------------------------------------------------\r\n\t\tHttpRequest::Type HttpRequest::GetType() const\r\n\t\t{\r\n\t\t\treturn m_type;\r\n\t\t}\r\n\t\t//----------------------------------------------------------------------------------------\r\n\t\t//----------------------------------------------------------------------------------------\r\n\t\tconst std::string& HttpRequest::GetUrl() const\r\n\t\t{\r\n\t\t\treturn m_url;\r\n\t\t}\r\n\t\t//----------------------------------------------------------------------------------------\r\n\t\t//----------------------------------------------------------------------------------------\r\n\t\tconst std::string& HttpRequest::GetBody() const\r\n\t\t{\r\n\t\t\treturn m_body;\r\n\t\t}\r\n\t\t//----------------------------------------------------------------------------------------\r\n\t\t//----------------------------------------------------------------------------------------\r\n\t\tconst ChilliSource::ParamDictionary& HttpRequest::GetHeaders() const\r\n\t\t{\r\n\t\t\treturn m_headers;\r\n\t\t}\r\n\t\t//----------------------------------------------------------------------------------------\r\n\t\t//----------------------------------------------------------------------------------------\r\n\t\tvoid HttpRequest::Shutdown()\r\n\t\t{\r\n\t\t\tstd::unique_lock<std::mutex> mutexLock(s_addingMutexesMutex);\r\n\r\n\t\t\tstd::vector<std::unique_lock<std::mutex>> locks;\r\n\t\t\tlocks.reserve(s_destroyingMutexes.size());\r\n\r\n\t\t\tfor (auto& mutex : s_destroyingMutexes)\r\n\t\t\t{\r\n\t\t\t\tlocks.push_back(std::unique_lock<std::mutex>(*mutex));\r\n\t\t\t}\r\n\r\n\t\t\ts_isDestroying = true;\r\n\t\t}\r\n\t\t//----------------------------------------------------------------------------------------\r\n\t\t//----------------------------------------------------------------------------------------\r\n\t\tu64 HttpRequest::GetExpectedSize() const\r\n\t\t{\r\n\t\t\treturn m_expectedSize;\r\n\t\t}\r\n\t\t//----------------------------------------------------------------------------------------\r\n\t\t//----------------------------------------------------------------------------------------\r\n\t\tu64 HttpRequest::GetDownloadedBytes() const\r\n\t\t{\r\n\t\t\treturn m_totalBytesRead;\r\n\t\t}\r\n\t}\r\n}\r\n\r\n#endif\r\n"
  },
  {
    "path": "Source/CSBackend/Platform/Windows/Networking/Http/HttpRequest.h",
    "content": "//\r\n//  HttpRequest.h\r\n//  ChilliSource\r\n//  Created by Scott Downie on 23/05/2011.\r\n//\r\n//  The MIT License (MIT)\r\n//\r\n//  Copyright (c) 2011 Tag Games Limited\r\n//\r\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\r\n//  of this software and associated documentation files (the \"Software\"), to deal\r\n//  in the Software without restriction, including without limitation the rights\r\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\n//  copies of the Software, and to permit persons to whom the Software is\r\n//  furnished to do so, subject to the following conditions:\r\n//\r\n//  The above copyright notice and this permission notice shall be included in\r\n//  all copies or substantial portions of the Software.\r\n//\r\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r\n//  THE SOFTWARE.\r\n//\r\n\r\n#ifdef CS_TARGETPLATFORM_WINDOWS\r\n\r\n#ifndef _CSBACKEND_PLATFORM_WINDOWS_HTTP_HTTPREQUEST_H_\r\n#define _CSBACKEND_PLATFORM_WINDOWS_HTTP_HTTPREQUEST_H_\r\n\r\n#include <ChilliSource/ChilliSource.h>\r\n#include <CSBackend/Platform/Windows/ForwardDeclarations.h>\r\n#include <ChilliSource/Networking/Http/HttpRequest.h>\r\n#include <ChilliSource/Networking/Http/HttpResponse.h>\r\n\r\n#include <atomic>\r\n#include <list>\r\n#include <mutex>\r\n\r\nnamespace CSBackend\r\n{\r\n\tnamespace Windows\r\n\t{\r\n\t\t//Windows typedefs so we don't have to include windows.h in the header\r\n\t\ttypedef void* HINTERNET;\r\n\r\n\t\t//----------------------------------------------------------------------------------------\r\n\t\t/// Concrete implementation of Windows http request using the WinHTTP library. Requests\r\n\t\t/// are performed on a background thread.\r\n\t\t///\r\n\t\t/// @author S Downie\r\n\t\t//----------------------------------------------------------------------------------------\r\n\t\tclass HttpRequest final : public ChilliSource::HttpRequest\r\n\t\t{\r\n\t\tpublic:\r\n\t\t\t//----------------------------------------------------------------------------------------\r\n\t\t\t/// @author S Downie\r\n\t\t\t///\r\n\t\t\t/// @return The type of the request (POST or GET)\r\n\t\t\t//----------------------------------------------------------------------------------------\r\n\t\t\tType GetType() const override;\r\n\t\t\t//----------------------------------------------------------------------------------------\r\n\t\t\t/// @author S Downie\r\n\t\t\t///\r\n\t\t\t/// @return The original url to which the request was sent\r\n\t\t\t//----------------------------------------------------------------------------------------\r\n\t\t\tconst std::string& GetUrl() const override;\r\n\t\t\t//----------------------------------------------------------------------------------------\r\n\t\t\t/// @author S Downie\r\n\t\t\t///\r\n\t\t\t/// @return The body of the POST request (GET request will return empty)\r\n\t\t\t//----------------------------------------------------------------------------------------\r\n\t\t\tconst std::string& GetBody() const override;\r\n\t\t\t//----------------------------------------------------------------------------------------\r\n\t\t\t/// @author S Downie\r\n\t\t\t///\r\n\t\t\t/// @return The original headers of the request as keys/values\r\n\t\t\t//----------------------------------------------------------------------------------------\r\n\t\t\tconst ChilliSource::ParamDictionary& GetHeaders() const override;\r\n\t\t\t//----------------------------------------------------------------------------------------\r\n\t\t\t/// Close the request. Note: The completion delegate is not invoked\r\n\t\t\t///\r\n\t\t\t/// @author S Downie\r\n\t\t\t//----------------------------------------------------------------------------------------\r\n\t\t\tvoid Cancel() override;\r\n\t\t\t//----------------------------------------------------------------------------------------\r\n\t\t\t/// @author HMcLaughlin\r\n\t\t\t///\r\n\t\t\t/// @return The expected total size of the request\r\n\t\t\t//----------------------------------------------------------------------------------------\r\n\t\t\tu64 GetExpectedSize() const override;\r\n\t\t\t//----------------------------------------------------------------------------------------\r\n\t\t\t/// @author HMcLaughlin\r\n\t\t\t///\r\n\t\t\t/// @return The current transferred size of the request\r\n\t\t\t//----------------------------------------------------------------------------------------\r\n\t\t\tu64 GetDownloadedBytes() const override;\r\n\r\n\t\tprivate:\r\n\t\t\tfriend class HttpRequestSystem;\r\n\t\t\t//----------------------------------------------------------------------------------------\r\n\t\t\t/// Constructor\r\n\t\t\t///\r\n\t\t\t/// @author S Downie\r\n\t\t\t///\r\n\t\t\t/// @param Type (POST or GET)\r\n\t\t\t/// @param Url to send request to\r\n\t\t\t/// @param POST body\r\n\t\t\t/// @param Headers\r\n\t\t\t/// @param Timeout in seconds\r\n\t\t\t/// @param WinHTTP request handle\r\n\t\t\t/// @param WinHTTP connection handle\r\n\t\t\t/// @param Max buffer size before flush required\r\n\t\t\t/// @param Completion delegate\r\n\t\t\t//----------------------------------------------------------------------------------------\r\n\t\t\tHttpRequest(Type in_type, const std::string& in_url, const std::string& in_body, const ChilliSource::ParamDictionary& in_headers, u32 in_timeoutSecs,\r\n\t\t\t\tHINTERNET in_requestHandle, HINTERNET in_connectionHandle, u32 in_bufferFlushSize, const Delegate& in_delegate);\r\n\t\t\t//----------------------------------------------------------------------------------------\r\n\t\t\t/// Reads data from the open stream when it becomes available\r\n\t\t\t/// buffers the data flags on complete\r\n\t\t\t///\r\n\t\t\t/// @author S Downie\r\n\t\t\t///\r\n\t\t\t/// @param Request handle\r\n\t\t\t/// @param Connection handle\r\n\t\t\t/// @param Mutex that manages the critical section of the HTTP system being shutdown\r\n\t\t\t//----------------------------------------------------------------------------------------\r\n\t\t\tvoid PollReadStream(HINTERNET inRequestHandle, HINTERNET inConnectionHandle, std::shared_ptr<std::mutex> in_destroyingMutex);\r\n\t\t\t//----------------------------------------------------------------------------------------\r\n\t\t\t/// Checks the stream to see if any data is available for reading\r\n\t\t\t/// and reads this into a buffer. Once all the data is read\r\n\t\t\t/// the request will call the complete delegate\r\n\t\t\t///\r\n\t\t\t/// @author S Downie\r\n\t\t\t///\r\n\t\t\t/// @param Time in seconds since last update\r\n\t\t\t//----------------------------------------------------------------------------------------\r\n\t\t\tvoid Update(f32 in_timeSinceLastUpdate);\r\n\t\t\t//----------------------------------------------------------------------------------------\r\n\t\t\t/// @author S Downie\r\n\t\t\t///\r\n\t\t\t/// @return Whether the request has completed - regardless of success or failure\r\n\t\t\t//----------------------------------------------------------------------------------------\r\n\t\t\tbool HasCompleted() const;\r\n\t\t\t//----------------------------------------------------------------------------------------\r\n\t\t\t/// Inform the polling threads in a thread-safe manner that the system is shutting down\r\n\t\t\t///\r\n\t\t\t/// @author S Downie\r\n\t\t\t//----------------------------------------------------------------------------------------\r\n\t\t\tstatic void Shutdown();\r\n\r\n\t\tprivate:\r\n\r\n\t\t\tstatic std::mutex s_addingMutexesMutex;\r\n\t\t\tstatic std::list<std::shared_ptr<std::mutex>> s_destroyingMutexes;\r\n\t\t\tstatic bool s_isDestroying;\r\n\r\n\t\t\tconst Type m_type;\r\n\t\t\tconst std::string m_url;\r\n\t\t\tconst std::string m_body;\r\n\t\t\tconst ChilliSource::ParamDictionary m_headers;\r\n\t\t\tconst Delegate m_completionDelegate;\r\n\t\t\tconst u32 m_bufferFlushSize;\r\n\r\n\t\t\tstd::string m_responseData;\r\n\t\t\tu32 m_responseCode = 0;\r\n\t\t\tChilliSource::HttpResponse::Result m_requestResult = ChilliSource::HttpResponse::Result::k_failed;\r\n\r\n\t\t\tu64 m_totalBytesRead = 0;\r\n\t\t\tu64 m_expectedSize = 0;\r\n\t\t\t\r\n\t\t\tbool m_shouldKillThread = false;\r\n\t\t\tbool m_isPollingComplete = false;\r\n\t\t\tbool m_isRequestComplete = false;\r\n\t\t\tbool m_isRequestCancelled = false;\r\n\r\n\t\t\tstd::atomic_int m_flushesPending = 0;\r\n\r\n\t\t\tChilliSource::TaskScheduler* m_taskScheduler;\r\n\t\t};\r\n\t}\r\n}\r\n\r\n#endif\r\n\r\n#endif\r\n"
  },
  {
    "path": "Source/CSBackend/Platform/Windows/Networking/Http/HttpRequestSystem.cpp",
    "content": "//\r\n//  HttpRequestSystem.cpp\r\n//  ChilliSource\r\n//  Created by Scott Downie on 23/05/2011.\r\n//\r\n//  The MIT License (MIT)\r\n//\r\n//  Copyright (c) 2011 Tag Games Limited\r\n//\r\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\r\n//  of this software and associated documentation files (the \"Software\"), to deal\r\n//  in the Software without restriction, including without limitation the rights\r\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\n//  copies of the Software, and to permit persons to whom the Software is\r\n//  furnished to do so, subject to the following conditions:\r\n//\r\n//  The above copyright notice and this permission notice shall be included in\r\n//  all copies or substantial portions of the Software.\r\n//\r\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r\n//  THE SOFTWARE.\r\n//\r\n\r\n#ifdef CS_TARGETPLATFORM_WINDOWS\r\n\r\n#include <CSBackend/Platform/Windows/Networking/Http/HttpRequestSystem.h>\r\n\r\n#include <CSBackend/Platform/Windows/Core/String/WindowsStringUtils.h>\r\n#include <ChilliSource/Core/Base/Application.h>\r\n#include <ChilliSource/Core/Threading/TaskScheduler.h>\r\n\r\n#include <Windows.h>\r\n\r\n// Have to wrap WinInet's include in a namespace, because MS violates ODR with WinInet and WinHTTP.\r\nnamespace WinInet\r\n{\r\n#include <WinInet.h>\r\n}\r\n\r\n// A couple of undefs required too.\r\n#undef BOOLAPI\r\n#undef SECURITY_FLAG_IGNORE_CERT_DATE_INVALID\r\n#undef SECURITY_FLAG_IGNORE_CERT_CN_INVALID\r\n\r\n#include <winhttp.h>\r\n\r\n\r\n\r\n#pragma comment(lib, \"winhttp\")\r\n#pragma comment(lib, \"wininet\")\r\n\r\nnamespace CSBackend\r\n{\r\n\tnamespace Windows\r\n\t{\r\n\t\tnamespace\r\n\t\t{\r\n\t\t\t//--------------------------------------------------------------------------------------------------\r\n\t\t\t/// Setup the request to use SSL level 3\r\n\t\t\t///\r\n\t\t\t/// @author S Downie\r\n\t\t\t///\r\n\t\t\t/// @param Request handle\r\n\t\t\t///\r\n\t\t\t/// @return Success or failure\r\n\t\t\t//--------------------------------------------------------------------------------------------------\r\n\t\t\tbool ApplySSLSettings(HINTERNET in_requestHandle)\r\n\t\t\t{\r\n\t\t\t\tDWORD requestOptions = SECURITY_FLAG_IGNORE_CERT_CN_INVALID | SECURITY_FLAG_IGNORE_CERT_DATE_INVALID | SECURITY_FLAG_IGNORE_UNKNOWN_CA | SECURITY_FLAG_IGNORE_CERT_WRONG_USAGE;\r\n\t\t\t\tif (!WinHttpSetOption(in_requestHandle, WINHTTP_OPTION_SECURITY_FLAGS, &requestOptions, sizeof(DWORD)))\r\n\t\t\t\t{\r\n\t\t\t\t\tCS_LOG_ERROR(\"Failed to set HTTP SSL security flag options\");\r\n\t\t\t\t\treturn false;\r\n\t\t\t\t}\r\n\r\n\t\t\t\treturn true;\r\n\t\t\t}\r\n\t\t\t//--------------------------------------------------------------------------------------------------\r\n\t\t\t/// Convert param dictionary to header format required by WinHTTP\r\n\t\t\t///\r\n\t\t\t/// @author S Downie\r\n\t\t\t///\r\n\t\t\t/// @param Header dictionary\r\n\t\t\t///\r\n\t\t\t/// @return Header blob\r\n\t\t\t//--------------------------------------------------------------------------------------------------\r\n\t\t\tstd::wstring ConvertHeaders(const ChilliSource::ParamDictionary& in_headers)\r\n\t\t\t{\r\n\t\t\t\t//The headers must be passed as a single string with each header except the last\r\n\t\t\t\t//terminated by a carraige return/line feed\r\n\t\t\t\tstd::string headerBlob;\r\n\t\t\t\tfor (auto it = in_headers.begin(); it != in_headers.end(); ++it)\r\n\t\t\t\t{\r\n\t\t\t\t\theaderBlob += it->first;\r\n\t\t\t\t\theaderBlob += \": \";\r\n\t\t\t\t\theaderBlob += it->second;\r\n\t\t\t\t\theaderBlob += '\\r';\r\n\t\t\t\t\theaderBlob += '\\n';\r\n\t\t\t\t}\r\n\r\n\t\t\t\tCS_ASSERT(headerBlob.length() > 2, \"Http: Cannot convert empty headers\");\r\n\r\n\t\t\t\tstd::wstring headerBlobWide(headerBlob.length() - 2, L' ');\r\n\t\t\t\tstd::copy(headerBlob.begin(), headerBlob.end()-2, headerBlobWide.begin());\r\n\t\t\t\treturn headerBlobWide;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tCS_DEFINE_NAMEDTYPE(HttpRequestSystem);\r\n\r\n\t\t//--------------------------------------------------------------------------------------------------\r\n\t\t//--------------------------------------------------------------------------------------------------\r\n\t\tvoid HttpRequestSystem::OnInit()\r\n\t\t{\r\n\t\t\tm_sessionHandle = ::WinHttpOpen(L\"CSWinHttpClient\", WINHTTP_ACCESS_TYPE_NO_PROXY, WINHTTP_NO_PROXY_NAME, WINHTTP_NO_PROXY_BYPASS, 0);\r\n\t\t\tCS_ASSERT(m_sessionHandle != nullptr, \"Failed to open WinHTTP session\");\r\n\t\t}\r\n\t\t//--------------------------------------------------------------------------------------------------\r\n\t\t//--------------------------------------------------------------------------------------------------\r\n\t\tbool HttpRequestSystem::IsA(ChilliSource::InterfaceIDType in_interfaceId) const\r\n\t\t{\r\n\t\t\treturn in_interfaceId == ChilliSource::HttpRequestSystem::InterfaceID || in_interfaceId == HttpRequestSystem::InterfaceID;\r\n\t\t}\r\n\t\t//--------------------------------------------------------------------------------------------------\r\n\t\t//--------------------------------------------------------------------------------------------------\r\n\t\tHttpRequest* HttpRequestSystem::MakeGetRequest(const std::string& in_url, const HttpRequest::Delegate& in_delegate, u32 in_timeoutSecs)\r\n\t\t{\r\n\t\t\treturn MakeRequest(HttpRequest::Type::k_get, in_url, \"\", ChilliSource::ParamDictionary(), in_delegate, in_timeoutSecs);\r\n\t\t}\r\n\t\t//--------------------------------------------------------------------------------------------------\r\n\t\t//--------------------------------------------------------------------------------------------------\r\n\t\tHttpRequest* HttpRequestSystem::MakeGetRequest(const std::string& in_url, const ChilliSource::ParamDictionary& in_headers, const HttpRequest::Delegate& in_delegate, u32 in_timeoutSecs)\r\n\t\t{\r\n\t\t\treturn MakeRequest(HttpRequest::Type::k_get, in_url, \"\", in_headers, in_delegate, in_timeoutSecs);\r\n\t\t}\r\n\t\t//--------------------------------------------------------------------------------------------------\r\n\t\t//--------------------------------------------------------------------------------------------------\r\n\t\tHttpRequest* HttpRequestSystem::MakePostRequest(const std::string& in_url, const std::string& in_body, const HttpRequest::Delegate& in_delegate, u32 in_timeoutSecs)\r\n\t\t{\r\n\t\t\treturn MakeRequest(HttpRequest::Type::k_post, in_url, in_body, ChilliSource::ParamDictionary(), in_delegate, in_timeoutSecs);\r\n\t\t}\r\n\t\t//--------------------------------------------------------------------------------------------------\r\n\t\t//--------------------------------------------------------------------------------------------------\r\n\t\tHttpRequest* HttpRequestSystem::MakePostRequest(const std::string& in_url, const std::string& in_body, const ChilliSource::ParamDictionary& in_headers, const HttpRequest::Delegate& in_delegate, u32 in_timeoutSecs)\r\n\t\t{\r\n\t\t\treturn MakeRequest(HttpRequest::Type::k_post, in_url, in_body, in_headers, in_delegate, in_timeoutSecs);\r\n\t\t}\r\n\t\t//--------------------------------------------------------------------------------------------------\r\n\t\t//--------------------------------------------------------------------------------------------------\r\n\t\tHttpRequest* HttpRequestSystem::MakeRequest(HttpRequest::Type in_type, const std::string& in_url, const std::string& in_body, const ChilliSource::ParamDictionary& in_headers, const HttpRequest::Delegate& in_delegate, u32 in_timeoutSecs)\r\n\t\t{\r\n\t\t\tCS_ASSERT(ChilliSource::Application::Get()->GetTaskScheduler()->IsMainThread() == true, \"Http requests can currently only be made on the main thread\");\r\n\t\t\tCS_ASSERT(in_delegate != nullptr, \"Cannot make an http request with a null delegate\");\r\n\t\t\tCS_ASSERT(in_url.empty() == false, \"Cannot make an http request to a blank url\");\r\n\r\n\t\t\tURL_COMPONENTS urlComps;\r\n\r\n\t\t\t//Initialize the URL_COMPONENTS structure.\r\n\t\t\tZeroMemory(&urlComps, sizeof(URL_COMPONENTS));\r\n\t\t\turlComps.dwStructSize = sizeof(URL_COMPONENTS);\r\n\r\n\t\t\t//Set required component lengths to non-zero so that they are cracked.\r\n\t\t\turlComps.dwSchemeLength    = (DWORD)-1;\r\n\t\t\turlComps.dwHostNameLength  = (DWORD)-1;\r\n\t\t\turlComps.dwUrlPathLength   = (DWORD)-1;\r\n\t\t\turlComps.dwExtraInfoLength = (DWORD)-1;\r\n\r\n\t\t\t//Change the URL to wide string\r\n\t\t\tstd::wstring url(WindowsStringUtils::UTF8ToUTF16(in_url));\r\n\r\n\t\t\t//Crack the URL.\r\n\t\t\tif (!WinHttpCrackUrl(url.c_str(), (DWORD)url.length(), 0, &urlComps))\r\n\t\t\t{\r\n\t\t\t\tCS_LOG_FATAL(\"Cannot crack URL: \" + in_url);\r\n\t\t\t\treturn nullptr;\r\n\t\t\t}\r\n\r\n\t\t\t//Weirdly the cracked URL struct only gives you the ability to crack your own URL\r\n\t\t\tstd::wstring hostName = urlComps.lpszHostName;\r\n\t\t\thostName = hostName.substr(0, urlComps.dwHostNameLength);\r\n\t\t\tHINTERNET connectionHandle = ::WinHttpConnect(m_sessionHandle, hostName.c_str(), INTERNET_DEFAULT_PORT, 0);\r\n\r\n\t\t\tif (!connectionHandle)\r\n\t\t\t{\r\n\t\t\t\tCS_LOG_ERROR(\"Failed to connect to server: \" + in_url);\r\n\t\t\t\treturn nullptr;\r\n\t\t\t}\r\n\r\n\t\t\t//Set up the request based on whether it is POST or GET and whether it is SSL\r\n\t\t\tLPCWSTR type = (in_type == ChilliSource::HttpRequest::Type::k_get ? L\"GET\" : L\"POST\");\r\n\t\t\tHINTERNET requestHandle = 0;\r\n\r\n\t\t\tstd::wstring urlPath = urlComps.lpszUrlPath;\r\n\t\t\turlPath = urlPath.substr(0, urlComps.dwUrlPathLength);\r\n\r\n\t\t\tif (urlComps.nScheme == INTERNET_SCHEME_HTTPS)\r\n\t\t\t{\r\n\t\t\t\trequestHandle = ::WinHttpOpenRequest(connectionHandle, type, urlPath.c_str(), L\"HTTP/1.1\", WINHTTP_NO_REFERER, WINHTTP_DEFAULT_ACCEPT_TYPES, WINHTTP_FLAG_SECURE);\r\n\t\t\t\tif (requestHandle == nullptr || ApplySSLSettings(requestHandle) == false)\r\n\t\t\t\t{\r\n\t\t\t\t\tCS_LOG_ERROR(\"Failed to open request: \" + in_url);\r\n\t\t\t\t\tWinHttpCloseHandle(connectionHandle);\r\n\t\t\t\t\treturn nullptr;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\trequestHandle = ::WinHttpOpenRequest(connectionHandle, type, urlPath.c_str(), L\"HTTP/1.1\", WINHTTP_NO_REFERER, WINHTTP_DEFAULT_ACCEPT_TYPES, 0);\r\n\t\t\t\tif (requestHandle == nullptr)\r\n\t\t\t\t{\r\n\t\t\t\t\tCS_LOG_ERROR(\"Failed to open request: \" + in_url);\r\n\t\t\t\t\tWinHttpCloseHandle(connectionHandle);\r\n\t\t\t\t\treturn nullptr;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tif (in_headers.empty() == false)\r\n\t\t\t{\r\n\t\t\t\tstd::wstring headerBlob = ConvertHeaders(in_headers);\r\n\r\n\t\t\t\tif (WinHttpAddRequestHeaders(requestHandle, headerBlob.c_str(), DWORD(headerBlob.length()), WINHTTP_ADDREQ_FLAG_ADD) == false)\r\n\t\t\t\t{\r\n\t\t\t\t\tCS_LOG_ERROR(\"Failed to add http headers: \" + in_url);\r\n\t\t\t\t\tWinHttpCloseHandle(requestHandle);\r\n\t\t\t\t\tWinHttpCloseHandle(connectionHandle);\r\n\t\t\t\t\treturn nullptr;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tHttpRequest* httpRequest = new HttpRequest(in_type, in_url, in_body, in_headers, in_timeoutSecs, requestHandle, connectionHandle, GetMaxBufferSize(), in_delegate);\r\n\t\t\tm_requests.push_back(httpRequest);\r\n\t\t\treturn httpRequest;\r\n\t\t}\r\n\t\t//--------------------------------------------------------------------------------------------------\r\n\t\t//--------------------------------------------------------------------------------------------------\r\n\t\tvoid HttpRequestSystem::CancelAllRequests()\r\n\t\t{\r\n\t\t\tCS_ASSERT(ChilliSource::Application::Get()->GetTaskScheduler()->IsMainThread() == true, \"Http requests can currently only be made on the main thread\");\r\n\r\n\t\t\tfor(u32 nRequest=0; nRequest<m_requests.size(); ++nRequest)\r\n\t\t\t{\r\n\t\t\t\tm_requests[nRequest]->Cancel();\r\n\t\t\t}\r\n\t\t}\r\n\t\t//--------------------------------------------------------------------------------------------------\r\n\t\t//--------------------------------------------------------------------------------------------------\r\n\t\tvoid HttpRequestSystem::CheckReachability(const ReachabilityResultDelegate& in_reachabilityDelegate) const\r\n\t\t{\r\n\t\t\t// Check internet connectivity/reachability, using WinINet.\r\n\t\t\tDWORD inetState = 0;\r\n\t\t\tBOOL hasConnection = WinInet::InternetGetConnectedState(&inetState, 0);\r\n\r\n\t\t\t// True is returned when the device has an active connection to the internet, or a correctly-configured proxy connection.\r\n\t\t\t// False is returned when the device has no connection to the internet, even if successfully connected to LAN.\r\n\t\t\t// More information about the connection can be obtained from the 'inetState' flag.\r\n\t\t\t \r\n            CS_ASSERT(in_reachabilityDelegate, \"The reachability delegate should not be null.\");\r\n\t\t\tin_reachabilityDelegate(hasConnection ? true : false); //ternary operator used here because BOOL is a typedef'd int & conversion has perf issues\r\n\t\t}\r\n\t\t//--------------------------------------------------------------------------------------------------\r\n\t\t//--------------------------------------------------------------------------------------------------\r\n\t\tvoid HttpRequestSystem::OnUpdate(f32 in_timeSinceLastUpdate)\r\n\t\t{\r\n\t\t\t//We should do this in two loops incase anyone tries to insert into the requests from the completion callback\r\n\t\t\tfor (u32 i=0; i<m_requests.size(); ++i)\r\n\t\t\t{\r\n\t\t\t\tm_requests[i]->Update(in_timeSinceLastUpdate);\r\n\t\t\t}\r\n\r\n\t\t\tfor (auto it = m_requests.begin(); it != m_requests.end(); /*No increment*/)\r\n\t\t\t{\r\n\t\t\t\tif((*it)->HasCompleted())\r\n\t\t\t\t{\r\n\t\t\t\t\t//...and remove the completed request\r\n\t\t\t\t\tCS_SAFEDELETE(*it);\r\n\t\t\t\t\tit = m_requests.erase(it);\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t{\r\n\t\t\t\t\t++it;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\t//--------------------------------------------------------------------------------------------------\r\n\t\t//--------------------------------------------------------------------------------------------------\r\n\t\tvoid HttpRequestSystem::OnDestroy()\r\n\t\t{\r\n\t\t\tCancelAllRequests();\r\n\r\n\t\t\tHttpRequest::Shutdown();\r\n\r\n\t\t\tfor (auto it = m_requests.begin(); it != m_requests.end(); ++it)\r\n\t\t\t{\r\n\t\t\t\tCS_SAFEDELETE(*it);\r\n\t\t\t}\r\n\r\n\t\t\tm_requests.clear();\r\n\t\t\tm_requests.shrink_to_fit();\r\n\r\n\t\t\tWinHttpCloseHandle(m_sessionHandle);\r\n\t\t}\r\n\t}\r\n}\r\n\r\n#endif\r\n"
  },
  {
    "path": "Source/CSBackend/Platform/Windows/Networking/Http/HttpRequestSystem.h",
    "content": "//\r\n//  HttpRequestSystem.h\r\n//  ChilliSource\r\n//  Created by Scott Downie on 23/05/2011.\r\n//\r\n//  The MIT License (MIT)\r\n//\r\n//  Copyright (c) 2011 Tag Games Limited\r\n//\r\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\r\n//  of this software and associated documentation files (the \"Software\"), to deal\r\n//  in the Software without restriction, including without limitation the rights\r\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\n//  copies of the Software, and to permit persons to whom the Software is\r\n//  furnished to do so, subject to the following conditions:\r\n//\r\n//  The above copyright notice and this permission notice shall be included in\r\n//  all copies or substantial portions of the Software.\r\n//\r\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r\n//  THE SOFTWARE.\r\n//\r\n\r\n#ifdef CS_TARGETPLATFORM_WINDOWS\r\n\r\n#ifndef _CSBACKEND_PLATFORM_WINDOWS_HTTP_HTTPREQUESTSYSTEM_H_\r\n#define _CSBACKEND_PLATFORM_WINDOWS_HTTP_HTTPREQUESTSYSTEM_H_\r\n\r\n#include <CSBackend/Platform/Windows/ForwardDeclarations.h>\r\n#include <CSBackend/Platform/Windows/Networking/Http/HttpRequest.h>\r\n#include <ChilliSource/Networking/Http/HttpRequestSystem.h>\r\n\r\nnamespace CSBackend\r\n{\r\n\tnamespace Windows\r\n\t{\t\r\n\t\t//Windows typedefs so we don't have to include windows.h in the header\r\n\t\ttypedef void* HINTERNET;\r\n\r\n\t\t//--------------------------------------------------------------------------------------------------\r\n\t\t/// Windows implementation of the http connection system. Reponsible for making http requests to remote\r\n\t\t/// urls and managing the lifetime of the requests and the connections. Uses the WinHTTP library\r\n\t\t///\r\n\t\t/// @author S Downie\r\n\t\t//--------------------------------------------------------------------------------------------------\r\n\t\tclass HttpRequestSystem final : public ChilliSource::HttpRequestSystem\r\n\t\t{\r\n\t\tpublic:\r\n\r\n\t\t\tCS_DECLARE_NAMEDTYPE(HttpRequestSystem);\r\n\r\n\t\t\t//--------------------------------------------------------------------------------------------------\r\n\t\t\t/// @author S Downie\r\n\t\t\t///\r\n\t\t\t/// @param Interface ID\r\n\t\t\t///\r\n\t\t\t/// @return Whether object if of argument type\r\n\t\t\t//--------------------------------------------------------------------------------------------------\r\n\t\t\tbool IsA(ChilliSource::InterfaceIDType in_interfaceId) const override;\r\n\t\t\t//--------------------------------------------------------------------------------------------------\r\n\t\t\t/// Causes the system to issue an Http GET request.\r\n\t\t\t///\r\n\t\t\t/// @author S Downie\r\n\t\t\t///\r\n\t\t\t/// @param URL\r\n\t\t\t/// @param Delegate that is called on request completed. Completion can be failure as well as success\r\n\t\t\t/// @param Request timeout in seconds\r\n\t\t\t///\r\n\t\t\t/// @return A pointer to the request. The system owns this pointer.\r\n\t\t\t//--------------------------------------------------------------------------------------------------\r\n\t\t\tHttpRequest* MakeGetRequest(const std::string& in_url, const HttpRequest::Delegate& in_delegate, u32 in_timeoutSecs = k_defaultTimeoutSecs) override;\r\n\t\t\t//--------------------------------------------------------------------------------------------------\r\n\t\t\t/// Causes the system to issue an Http GET request.\r\n\t\t\t///\r\n\t\t\t/// @author S Downie\r\n\t\t\t///\r\n\t\t\t/// @param URL\r\n\t\t\t/// @param Key value headers to attach to the request\r\n\t\t\t/// @param Delegate that is called on request completed. Completion can be failure as well as success\r\n\t\t\t/// @param Request timeout in seconds\r\n\t\t\t///\r\n\t\t\t/// @return A pointer to the request. The system owns this pointer.\r\n\t\t\t//--------------------------------------------------------------------------------------------------\r\n\t\t\tHttpRequest* MakeGetRequest(const std::string& in_url, const ChilliSource::ParamDictionary& in_headers, const HttpRequest::Delegate& in_delegate, u32 in_timeoutSecs = k_defaultTimeoutSecs) override;\r\n\t\t\t//--------------------------------------------------------------------------------------------------\r\n\t\t\t/// Causes the system to issue an Http POST request with the given body.\r\n\t\t\t///\r\n\t\t\t/// @author S Downie\r\n\t\t\t///\r\n\t\t\t/// @param URL\r\n\t\t\t/// @param POST body\r\n\t\t\t/// @param Delegate that is called on request completed. Completion can be failure as well as success\r\n\t\t\t/// @param Request timeout in seconds\r\n\t\t\t///\r\n\t\t\t/// @return A pointer to the request. The system owns this pointer.\r\n\t\t\t//--------------------------------------------------------------------------------------------------\r\n\t\t\tHttpRequest* MakePostRequest(const std::string& in_url, const std::string& in_body, const HttpRequest::Delegate& in_delegate, u32 in_timeoutSecs = k_defaultTimeoutSecs) override;\r\n\t\t\t//--------------------------------------------------------------------------------------------------\r\n\t\t\t/// Causes the system to issue an Http POST request with the given body.\r\n\t\t\t///\r\n\t\t\t/// @author S Downie\r\n\t\t\t///\r\n\t\t\t/// @param URL\r\n\t\t\t/// @param POST body\r\n\t\t\t/// @param Key value headers to attach to the request\r\n\t\t\t/// @param Delegate that is called on request completed. Completion can be failure as well as success\r\n\t\t\t/// @param Request timeout in seconds\r\n\t\t\t///\r\n\t\t\t/// @return A pointer to the request. The system owns this pointer.\r\n\t\t\t//--------------------------------------------------------------------------------------------------\r\n\t\t\tHttpRequest* MakePostRequest(const std::string& in_url, const std::string& in_body, const ChilliSource::ParamDictionary& in_headers, const HttpRequest::Delegate& in_delegate, u32 in_timeoutSecs = k_defaultTimeoutSecs) override;\r\n\t\t\t//--------------------------------------------------------------------------------------------------\r\n\t\t\t/// Equivalent to calling cancel on every incomplete request in progress.\r\n\t\t\t///\r\n\t\t\t/// @author S Downie\r\n\t\t\t//--------------------------------------------------------------------------------------------------\r\n\t\t\tvoid CancelAllRequests() override;\r\n\t\t\t//--------------------------------------------------------------------------------------------------\r\n\t\t\t/// Checks if the device is internet ready\r\n\t\t\t///\r\n\t\t\t/// @author S Downie\r\n\t\t\t///\r\n\t\t\t/// @param Delegate to call when reachability is determined\r\n\t\t\t//--------------------------------------------------------------------------------------------------\r\n\t\t\tvoid CheckReachability(const ReachabilityResultDelegate& in_reachabilityDelegate) const override;\r\n\r\n\t\tprivate:\r\n\t\t\tfriend ChilliSource::HttpRequestSystemUPtr ChilliSource::HttpRequestSystem::Create();\r\n\t\t\t//-------------------------------------------------------\r\n\t\t\t/// Private constructor to fore use of factory method\r\n\t\t\t///\r\n\t\t\t/// @author S Downie\r\n\t\t\t//-------------------------------------------------------\r\n\t\t\tHttpRequestSystem() = default;\r\n\t\t\t//------------------------------------------------------------------\r\n\t\t\t/// Concrete method to which all MakeRequest overloads feed.\r\n\t\t\t///\r\n\t\t\t/// @author S Downie\r\n\t\t\t///\r\n\t\t\t/// @param Type (POST or GET)\r\n\t\t\t/// @param Url\r\n\t\t\t/// @param Body (POST only)\r\n\t\t\t/// @param Headers\r\n\t\t\t/// @param Completion delegate\r\n\t\t\t/// @param Request timeout in seconds\r\n\t\t\t///\r\n\t\t\t/// @return Request. Owned by the system.\r\n\t\t\t//------------------------------------------------------------------\r\n\t\t\tHttpRequest* MakeRequest(HttpRequest::Type in_type, const std::string& in_url, const std::string& in_body, const ChilliSource::ParamDictionary& in_headers, const HttpRequest::Delegate& in_delegate, u32 in_timeoutSecs);\r\n\t\t\t//--------------------------------------------------------------------------------------------------\r\n\t\t\t/// Called when the system is created. Creates the WinHTTP session\r\n\t\t\t///\r\n\t\t\t/// @author S Downie\r\n\t\t\t//--------------------------------------------------------------------------------------------------\r\n\t\t\tvoid OnInit() override;\r\n\t\t\t//--------------------------------------------------------------------------------------------------\r\n\t\t\t/// Poll the connection on active requests\r\n\t\t\t///\r\n\t\t\t/// @author S Downie\r\n\t\t\t///\r\n\t\t\t/// @param Time since last update in seconds\r\n\t\t\t//--------------------------------------------------------------------------------------------------\r\n\t\t\tvoid OnUpdate(f32 in_timeSinceLastUpdate) override;\r\n\t\t\t//--------------------------------------------------------------------------------------------------\r\n\t\t\t/// Called when the system is destroyed. Cancels all pending requests and destroys the session\r\n\t\t\t///\r\n\t\t\t/// @author S Downie\r\n\t\t\t//--------------------------------------------------------------------------------------------------\r\n\t\t\tvoid OnDestroy() override;\r\n\r\n\t\tprivate:\r\n\r\n\t\t\tstd::vector<HttpRequest*> m_requests;\r\n\r\n\t\t\tHINTERNET m_sessionHandle;\r\n\t\t};\r\n\t}\r\n}\r\n\r\n#endif\r\n\r\n#endif\r\n\r\n"
  },
  {
    "path": "Source/CSBackend/Platform/Windows/SFML/Base/SFMLWindow.cpp",
    "content": "//\r\n//  SFMLWindow.cpp\r\n//  ChilliSource\r\n//  Created by Scott Downie on 11/03/2014.\r\n//\r\n//  The MIT License (MIT)\r\n//\r\n//  Copyright (c) 2014 Tag Games Limited\r\n//\r\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\r\n//  of this software and associated documentation files (the \"Software\"), to deal\r\n//  in the Software without restriction, including without limitation the rights\r\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\n//  copies of the Software, and to permit persons to whom the Software is\r\n//  furnished to do so, subject to the following conditions:\r\n//\r\n//  The above copyright notice and this permission notice shall be included in\r\n//  all copies or substantial portions of the Software.\r\n//\r\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r\n//  THE SOFTWARE.\r\n//\r\n\r\n#ifdef CS_TARGETPLATFORM_WINDOWS\r\n\r\n#include <CSBackend/Platform/Windows/SFML/Base/SFMLWindow.h>\r\n\r\n#include <CSBackend/Platform/Windows/Core/Base/SystemInfoFactory.h>\r\n#include <CSBackend/Platform/Windows/Core/String/WindowsStringUtils.h>\r\n#include <ChilliSource/Core/Base/AppConfig.h>\r\n#include <ChilliSource/Core/Base/Application.h>\r\n#include <ChilliSource/Core/Base/LifecycleManager.h>\r\n#include <ChilliSource/Core/Base/SystemInfo.h>\r\n#include <ChilliSource/Core/Container/VectorUtils.h>\r\n#include <ChilliSource/Core/String/StringParser.h>\r\n#include <ChilliSource/Core/Threading/TaskScheduler.h>\r\n#include <ChilliSource/Rendering/Base/SurfaceFormat.h>\r\n\r\n#include <GL/glew.h>\r\n#include <json/json.h>\r\n#include <SFML/OpenGL.hpp>\r\n\r\n#include <fstream>\r\n#include <array>\r\n#include <mutex>\r\n\r\n#include <windows.h>\r\n\r\n\r\nnamespace CSBackend\r\n{\r\n\tnamespace Windows\r\n\t{\r\n\t\tnamespace\r\n\t\t{\r\n\t\t\t//-------------------------------------------------------------\r\n\t\t\t/// Reads the app.config file root into a Json object\r\n\t\t\t///\r\n\t\t\t/// @author Ian Copland\r\n\t\t\t///\r\n\t\t\t/// @return Json root\r\n\t\t\t//-------------------------------------------------------------\r\n\t\t\tJson::Value ReadAppConfig() noexcept\r\n\t\t\t{\r\n\t\t\t\t//get the path to here\r\n\t\t\t\twchar_t pathChars[MAX_PATH];\r\n\t\t\t\tGetModuleFileName(nullptr, pathChars, MAX_PATH);\r\n\t\t\t\tstd::string path = WindowsStringUtils::ConvertWindowsFilePathToStandard(std::wstring(pathChars));\r\n\t\t\t\tstd::string::size_type pos = path.find_last_of(\"/\");\r\n\t\t\t\tstd::string workingDir = ChilliSource::StringUtils::StandardiseDirectoryPath(path.substr(0, pos));\r\n\r\n\t\t\t\t//open the file\r\n\t\t\t\tstd::ifstream file(workingDir + \"assets/AppResources/App.config\");\r\n\r\n\t\t\t\tJson::Value root;\r\n\r\n\t\t\t\tif (file.good() == true)\r\n\t\t\t\t{\r\n\t\t\t\t\tstd::string contents((std::istreambuf_iterator<s8>(file)), std::istreambuf_iterator<s8>());\r\n\r\n\t\t\t\t\t//parse the json\r\n\t\t\t\t\tJson::Reader jReader;\r\n\t\t\t\t\tif (!jReader.parse(contents, root))\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tOutputDebugString(CSBackend::Windows::WindowsStringUtils::UTF8ToUTF16(\"[ChilliSource] Could not parse App.config: \" + jReader.getFormattedErrorMessages() + \"\\n\").c_str());\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n\t\t\t\treturn root;\r\n\t\t\t}\r\n\t\t\t//-------------------------------------------------------------\r\n\t\t\t/// Reads the surface format from the App.config file.\r\n\t\t\t///\r\n\t\t\t/// @author S Downie\r\n\t\t\t///\r\n\t\t\t/// @param App config Json root\r\n\t\t\t///\r\n\t\t\t/// @return The surface format.\r\n\t\t\t//-------------------------------------------------------------\r\n\t\t\tChilliSource::SurfaceFormat ReadSurfaceFormat(const Json::Value& in_root) noexcept\r\n\t\t\t{\r\n\t\t\t\tconst std::string k_defaultFormat = \"rgb565_depth24\";\r\n\t\t\t\tstd::string formatString = in_root.get(\"PreferredSurfaceFormat\", k_defaultFormat).asString();\r\n\r\n\t\t\t\tconst Json::Value& windows = in_root[\"Windows\"];\r\n\t\t\t\tif (windows.isNull() == false && windows.isMember(\"PreferredSurfaceFormat\"))\r\n\t\t\t\t{\r\n\t\t\t\t\tformatString = windows[\"PreferredSurfaceFormat\"].asString();\r\n\t\t\t\t}\r\n\r\n\t\t\t\treturn ChilliSource::ParseSurfaceFormat(formatString);\r\n\t\t\t}\r\n\t\t\t//-------------------------------------------------------------\r\n\t\t\t/// Reads the multisample format from the App.config file.\r\n\t\t\t///\r\n\t\t\t/// @author S Downie\r\n\t\t\t///\r\n\t\t\t/// @param App config Json root\r\n\t\t\t///\r\n\t\t\t/// @return Number times multisample 0x, 2x, 4x.\r\n\t\t\t//-------------------------------------------------------------\r\n\t\t\tu32 ReadMultisampleFormat(const Json::Value& in_root) noexcept\r\n\t\t\t{\r\n\t\t\t\tstd::string stringFormat = in_root.get(\"Multisample\", \"None\").asString();\r\n\r\n\t\t\t\tconst Json::Value& windows = in_root[\"Windows\"];\r\n\t\t\t\tif (windows.isNull() == false && windows.isMember(\"Multisample\"))\r\n\t\t\t\t{\r\n\t\t\t\t\tstringFormat = windows[\"Multisample\"].asString();\r\n\t\t\t\t}\r\n\r\n\t\t\t\tChilliSource::StringUtils::ToLowerCase(stringFormat);\r\n\r\n\t\t\t\tif (stringFormat == \"none\")\r\n\t\t\t\t{\r\n\t\t\t\t\treturn 0;\r\n\t\t\t\t}\r\n\t\t\t\telse if (stringFormat == \"2x\")\r\n\t\t\t\t{\r\n\t\t\t\t\treturn 2;\r\n\t\t\t\t}\r\n\t\t\t\telse if (stringFormat == \"4x\")\r\n\t\t\t\t{\r\n\t\t\t\t\treturn 4;\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t{\r\n\t\t\t\t\tOutputDebugString(CSBackend::Windows::WindowsStringUtils::UTF8ToUTF16(\"[ChilliSource] Unknown multisample format : \" + stringFormat + \".Options are None, 2x or 4x\\n\").c_str());\r\n\t\t\t\t}\r\n\r\n\t\t\t\treturn 0;\r\n\t\t\t}\r\n\t\t\t//-------------------------------------------------------------\r\n\t\t\t/// Builds an SFML context based on the surface format\r\n\t\t\t/// NOTE: SFML doesn't support setting of RGBA values\r\n\t\t\t///\r\n\t\t\t/// @author S Downie\r\n\t\t\t///\r\n\t\t\t/// @param Surface format\r\n\t\t\t/// @param Number of samples for MSAA\r\n\t\t\t///\r\n\t\t\t/// @return Context settings\r\n\t\t\t//-------------------------------------------------------------\r\n\t\t\tsf::ContextSettings CreateContextSettings(ChilliSource::SurfaceFormat in_format, u32 in_multiSampleFormat) noexcept\r\n\t\t\t{\r\n\t\t\t\tsf::ContextSettings glSettings;\r\n\t\t\t\tglSettings.majorVersion = 2;\r\n\t\t\t\tglSettings.minorVersion = 0;\r\n\t\t\t\tglSettings.antialiasingLevel = in_multiSampleFormat;\r\n\t\t\t\tglSettings.stencilBits = 0;\r\n\r\n\t\t\t\tswitch (in_format)\r\n\t\t\t\t{\r\n\t\t\t\tcase ChilliSource::SurfaceFormat::k_rgb565_depth24:\r\n\t\t\t\tcase ChilliSource::SurfaceFormat::k_rgb888_depth24:\r\n\t\t\t\tdefault:\r\n\t\t\t\t\tglSettings.depthBits = 24;\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase ChilliSource::SurfaceFormat::k_rgb565_depth32:\r\n\t\t\t\tcase ChilliSource::SurfaceFormat::k_rgb888_depth32:\r\n\t\t\t\t\tglSettings.depthBits = 32;\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\r\n\t\t\t\treturn glSettings;\r\n\t\t\t}\r\n\t\t\t//-------------------------------------------------------------\r\n\t\t\t/// Read the RGBA bit depth based on the surface format\r\n\t\t\t///\r\n\t\t\t/// @author S Downie\r\n\t\t\t///\r\n\t\t\t/// @param Surface format\r\n\t\t\t///\r\n\t\t\t/// @return Pixel bit depth\r\n\t\t\t//-------------------------------------------------------------\r\n\t\t\tu32 ReadRGBAPixelDepth(ChilliSource::SurfaceFormat in_format) noexcept\r\n\t\t\t{\r\n\t\t\t\tu32 depth = 32;\r\n\r\n\t\t\t\tswitch (in_format)\r\n\t\t\t\t{\r\n\t\t\t\tcase ChilliSource::SurfaceFormat::k_rgb565_depth24:\r\n\t\t\t\tcase ChilliSource::SurfaceFormat::k_rgb565_depth32:\r\n\t\t\t\tdefault:\r\n\t\t\t\t\tdepth = 16;\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase ChilliSource::SurfaceFormat::k_rgb888_depth24:\r\n\t\t\t\tcase ChilliSource::SurfaceFormat::k_rgb888_depth32:\r\n\t\t\t\t\tdepth = 32;\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\r\n\t\t\t\treturn depth;\r\n\t\t\t}\r\n\r\n\t\t\t/// @param appConfigRoot\r\n\t\t\t///\t\tThe app config JSON\r\n\t\t\t/// @param fallbackResolution\r\n\t\t\t///\t\tWindow res to fallback on if none are specified\r\n\t\t\t///\r\n\t\t\t/// @return Inital window resolution as read from the config\r\n\t\t\t///\r\n\t\t\tChilliSource::Integer2 ReadInitialWindowSize(const Json::Value& appConfigRoot, const ChilliSource::Integer2& fallbackResolution) noexcept\r\n\t\t\t{\r\n\t\t\t\tChilliSource::Integer2 res = fallbackResolution;\r\n\t\t\t\tconst Json::Value& resObj = appConfigRoot[\"WindowResolution\"];\r\n\t\t\t\tif(resObj.isNull() == false)\r\n\t\t\t\t{\r\n\t\t\t\t\tres = ChilliSource::ParseInteger2(resObj.asString());\r\n\t\t\t\t}\r\n\t\t\t\tconst Json::Value& platformObj = appConfigRoot[\"Windows\"];\r\n\t\t\t\tif(platformObj.isNull() == false)\r\n\t\t\t\t{\r\n\t\t\t\t\tconst Json::Value& resObjPlatform = platformObj[\"WindowResolution\"];\r\n\t\t\t\t\tif(resObjPlatform.isNull() == false)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tres = ChilliSource::ParseInteger2(resObjPlatform.asString());\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n\t\t\t\treturn res;\r\n\t\t\t}\r\n\r\n\t\t\t/// @param appConfigRoot\r\n\t\t\t///\t\tThe app config JSON\r\n\t\t\t///\r\n\t\t\t/// @return Inital window mode as read from the config\r\n\t\t\t///\r\n\t\t\tChilliSource::Screen::DisplayMode ReadInitialWindowMode(const Json::Value& appConfigRoot) noexcept\r\n\t\t\t{\r\n\t\t\t\tstd::string mode = appConfigRoot.get(\"WindowDisplayMode\", \"windowed\").asString();\r\n\t\t\t\tconst Json::Value& platformObj = appConfigRoot[\"Windows\"];\r\n\t\t\t\tif(platformObj.isNull() == false)\r\n\t\t\t\t{\r\n\t\t\t\t\tmode = platformObj.get(\"WindowDisplayMode\", mode.c_str()).asString();\r\n\t\t\t\t}\r\n\r\n\t\t\t\treturn ChilliSource::Screen::ParseDisplayMode(mode);\r\n\t\t\t}\r\n\t\t}\r\n\t\t//-------------------------------------------------\r\n\t\t//-------------------------------------------------\r\n\t\tvoid SFMLWindow::SetPreferredFPS(u32 in_fps)\r\n\t\t{\r\n\t\t\tm_preferredFPS = in_fps;\r\n\t\t\tm_window.setVerticalSyncEnabled(false);\r\n\t\t\tm_window.setFramerateLimit(in_fps);\r\n\t\t}\r\n\t\t//-------------------------------------------------\r\n\t\t//-------------------------------------------------\r\n\t\tvoid SFMLWindow::SetVSyncEnabled(bool in_enable)\r\n\t\t{\r\n\t\t\tif (in_enable == true)\r\n\t\t\t{\r\n\t\t\t\tm_window.setFramerateLimit(0);\r\n\t\t\t\tm_window.setVerticalSyncEnabled(true);\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tm_window.setVerticalSyncEnabled(false);\r\n\t\t\t\tm_window.setFramerateLimit(m_preferredFPS);\r\n\t\t\t}\r\n\t\t}\r\n\t\t//-------------------------------------------------\r\n\t\t//-------------------------------------------------\r\n\t\tvoid SFMLWindow::SetSize(const ChilliSource::Integer2& in_size)\r\n\t\t{\r\n\t\t\tif(in_size == GetWindowSize())\r\n\t\t\t\treturn;\r\n\r\n\t\t\tif (m_displayMode == ChilliSource::Screen::DisplayMode::k_fullscreen)\r\n\t\t\t{\r\n\t\t\t\tCS_ASSERT(ChilliSource::VectorUtils::Contains(GetSupportedFullscreenResolutions(), in_size) == true, \"Resolution not supported in fullscreen mode.\");\r\n\t\t\t}\r\n\r\n\t\t\t//Clamp to the actual screen size\r\n\t\t\tauto windowSize = ChilliSource::Integer2::Max(in_size, ChilliSource::Integer2::k_one);\r\n\r\n\t\t\t//This will trigger an SFML resize event\r\n\t\t\tm_window.setSize(sf::Vector2u(windowSize.x, windowSize.y));\r\n\r\n\t\t\tif (m_displayMode == ChilliSource::Screen::DisplayMode::k_fullscreen)\r\n\t\t\t{\r\n\t\t\t\tSetFullscreen(windowSize);\r\n\t\t\t}\r\n\t\t}\r\n\t\t//-------------------------------------------------\r\n\t\t//-------------------------------------------------\r\n\t\tvoid SFMLWindow::SetDisplayMode(ChilliSource::Screen::DisplayMode in_mode, const ChilliSource::Integer2& size, bool force)\r\n\t\t{\r\n\t\t\tif (in_mode == m_displayMode && force == false)\r\n\t\t\t\treturn;\r\n\r\n\t\t\tm_displayMode = in_mode;\r\n\r\n\t\t\tswitch (m_displayMode)\r\n\t\t\t{\r\n\t\t\tcase ChilliSource::Screen::DisplayMode::k_fullscreen:\r\n\t\t\t\tSetFullscreen(size);\r\n\t\t\t\tbreak;\r\n\t\t\tcase ChilliSource::Screen::DisplayMode::k_windowed:\r\n\t\t\t\tSetWindowed(ChilliSource::Integer2::Min(size, m_desktopSize));\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\t\t//-------------------------------------------------\r\n\t\t//-------------------------------------------------\r\n\t\tvoid SFMLWindow::SetFullscreen(const ChilliSource::Integer2& size)\r\n\t\t{\r\n\t\t\tCS_ASSERT(ChilliSource::VectorUtils::Contains(GetSupportedFullscreenResolutions(), size) == true, \"Resolution not supported in fullscreen mode.\");\r\n\r\n\t\t\t//Pick the best fit RGBA depth based on the supported depths\r\n\t\t\tfor (auto it = sf::VideoMode::getFullscreenModes().rbegin(); it != sf::VideoMode::getFullscreenModes().rend(); ++it)\r\n\t\t\t{\r\n\t\t\t\tu32 bpp = it->bitsPerPixel;\r\n\t\t\t\tif (bpp >= m_preferredRGBADepth)\r\n\t\t\t\t{\r\n\t\t\t\t\tm_window.create(sf::VideoMode(size.x, size.y, bpp), m_title, sf::Style::Fullscreen, m_contextSettings);\r\n\r\n                    std::unique_lock<std::mutex> lock(m_windowMutex);\r\n                    if (m_windowDisplayModeDelegate)\r\n                    {\r\n                        m_windowDisplayModeDelegate(ChilliSource::Screen::DisplayMode::k_fullscreen);\r\n                    }\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\t//-------------------------------------------------\r\n\t\t//-------------------------------------------------\r\n\t\tvoid SFMLWindow::SetWindowed(const ChilliSource::Integer2& size)\r\n\t\t{\r\n\t\t\tbool resized = m_window.isOpen() && GetWindowSize() != size;\r\n\t\t\tm_window.create(sf::VideoMode((u32)size.x, (u32)size.y, sf::VideoMode::getDesktopMode().bitsPerPixel), m_title, sf::Style::Default, m_contextSettings);\r\n\r\n            std::unique_lock<std::mutex> lock(m_windowMutex);\r\n            if (m_windowDisplayModeDelegate)\r\n            {\r\n                m_windowDisplayModeDelegate(ChilliSource::Screen::DisplayMode::k_windowed);\r\n            }\r\n\r\n\t\t\tif (resized && m_windowResizeDelegate)\r\n\t\t\t{\r\n\t\t\t\tm_windowResizeDelegate(size);\r\n\t\t\t}\r\n\t\t}\r\n\t\t//----------------------------------------------------------\r\n\t\t//----------------------------------------------------------\r\n\t\tstd::vector<ChilliSource::Integer2> SFMLWindow::GetSupportedFullscreenResolutions() const\r\n\t\t{\r\n\t\t\tstd::vector<ChilliSource::Integer2> result;\r\n\t\t\tresult.reserve(sf::VideoMode::getFullscreenModes().size());\r\n\r\n\t\t\tfor (const auto& mode : sf::VideoMode::getFullscreenModes())\r\n\t\t\t{\r\n\t\t\t\tChilliSource::Integer2 resolution((s32)mode.width, (s32)mode.height);\r\n\t\t\t\tif (ChilliSource::VectorUtils::Contains(result, resolution) == false)\r\n\t\t\t\t{\r\n\t\t\t\t\tresult.push_back(resolution);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\treturn result;\r\n\t\t}\r\n        //------------------------------------------------\r\n        //------------------------------------------------\r\n        void SFMLWindow::SetWindowDelegates(const WindowResizeDelegate& in_windowResizeDelegate, const WindowDisplayModeDelegate& in_windowDisplayModeDelegate) noexcept\r\n        {\r\n            CS_ASSERT(in_windowResizeDelegate, \"Window resize delegate invalid.\");\r\n            CS_ASSERT(in_windowDisplayModeDelegate, \"Window display mode delegate invalid.\");\r\n            CS_ASSERT(!m_windowResizeDelegate, \"Window resize delegate already set.\");\r\n            CS_ASSERT(!m_windowDisplayModeDelegate, \"Window display mode delegate already set.\");\r\n\r\n            std::unique_lock<std::mutex> lock(m_windowMutex);\r\n            m_windowResizeDelegate = in_windowResizeDelegate;\r\n            m_windowDisplayModeDelegate = in_windowDisplayModeDelegate;\r\n        }\r\n        //------------------------------------------------\r\n        //------------------------------------------------\r\n        void SFMLWindow::SetMouseDelegates(const MouseButtonDelegate& in_mouseButtonDelegate, const MouseMovedDelegate& in_mouseMovedDelegate, const MouseWheelDelegate& in_mouseWheelDelegate) noexcept\r\n        {\r\n            CS_ASSERT(in_mouseButtonDelegate, \"Mouse button event delegate invalid.\");\r\n            CS_ASSERT(in_mouseMovedDelegate, \"Mouse moved delegate invalid.\");\r\n            CS_ASSERT(in_mouseWheelDelegate, \"Mouse wheel scroll delegate invalid.\");\r\n            CS_ASSERT(!m_mouseButtonDelegate, \"Mouse button event delegate already set.\");\r\n            CS_ASSERT(!m_mouseMovedDelegate, \"Mouse moved delegate already set.\");\r\n            CS_ASSERT(!m_mouseWheelDelegate, \"Mouse wheel scroll delegate already set.\");\r\n\r\n            std::unique_lock<std::mutex> lock(m_mouseMutex);\r\n            m_mouseButtonDelegate = in_mouseButtonDelegate;\r\n            m_mouseMovedDelegate = in_mouseMovedDelegate;\r\n            m_mouseWheelDelegate = in_mouseWheelDelegate;\r\n        }\r\n        //------------------------------------------------\r\n        //------------------------------------------------\r\n        void SFMLWindow::SetTextEnteredDelegate(const TextEnteredDelegate& in_textEnteredDelegate) noexcept\r\n        {\r\n            CS_ASSERT(in_textEnteredDelegate, \"Text entered delegate invalid.\");\r\n            CS_ASSERT(!m_textEnteredDelegate, \"Text entered delegate already set.\");\r\n\r\n            std::unique_lock<std::mutex> lock(m_textEntryMutex);\r\n            m_textEnteredDelegate = in_textEnteredDelegate;\r\n        }\r\n        //------------------------------------------------\r\n        //------------------------------------------------\r\n        void SFMLWindow::SetKeyDelegates(const KeyPressedDelegate& in_keyPressedDelegate, const KeyReleasedDelegate& in_keyReleasedDelegate) noexcept\r\n        {\r\n            CS_ASSERT(in_keyPressedDelegate, \"Key pressed delegate invalid.\");\r\n            CS_ASSERT(in_keyReleasedDelegate, \"Key released delegate invalid.\");\r\n            CS_ASSERT(!m_keyPressedDelegate, \"Key pressed delegate already set.\");\r\n            CS_ASSERT(!m_keyReleasedDelegate, \"Key released delegate already set.\");\r\n\r\n            std::unique_lock<std::mutex> lock(m_keyMutex);\r\n            m_keyPressedDelegate = in_keyPressedDelegate;\r\n            m_keyReleasedDelegate = in_keyReleasedDelegate;\r\n        }\r\n\r\n\t\t//------------------------------------------------------------------------------\r\n\t\tvoid SFMLWindow::SetJoystickDelegates(JoystickConnectionChangedDelegate connectedDelegate, JoystickConnectionChangedDelegate disconnectedDelegate,\r\n\t\t\tJoystickButtonDelegate buttonPressedDelegate, JoystickButtonDelegate buttonReleasedDelegate, JoystickMovedDelegate movedDelegate) noexcept\r\n\t\t{\r\n\t\t\tCS_ASSERT(connectedDelegate, \"Joystick connected delegate invalid.\");\r\n\t\t\tCS_ASSERT(disconnectedDelegate, \"Joystick disconnected delegate invalid.\");\r\n\t\t\tCS_ASSERT(buttonPressedDelegate, \"Joystick pressed delegate invalid.\");\r\n\t\t\tCS_ASSERT(buttonReleasedDelegate, \"Joystick released delegate invalid.\");\r\n\t\t\tCS_ASSERT(movedDelegate, \"Joystick moved delegate invalid.\");\r\n\r\n\t\t\tCS_ASSERT(!m_joystickConnectedDelegate, \"Joystick connected already set.\");\r\n\t\t\tCS_ASSERT(!m_joystickDisconnectedDelegate, \"Joystick disconnected already set.\");\r\n\t\t\tCS_ASSERT(!m_joystickButtonPressedDelegate, \"Joystick pressed already set.\");\r\n\t\t\tCS_ASSERT(!m_joystickButtonReleasedDelegate, \"Joystick released already set.\");\r\n\t\t\tCS_ASSERT(!m_joystickMovedDelegate, \"Joystick moved already set.\");\r\n\r\n\t\t\tstd::unique_lock<std::mutex> lock(m_joystickMutex);\r\n\t\t\tm_joystickConnectedDelegate = std::move(connectedDelegate);\r\n\t\t\tm_joystickDisconnectedDelegate = std::move(disconnectedDelegate);\r\n\t\t\tm_joystickButtonPressedDelegate = std::move(buttonPressedDelegate);\r\n\t\t\tm_joystickButtonReleasedDelegate = std::move(buttonReleasedDelegate);\r\n\t\t\tm_joystickMovedDelegate = std::move(movedDelegate);\r\n\t\t}\r\n\r\n        //------------------------------------------------\r\n        //------------------------------------------------\r\n        void SFMLWindow::RemoveWindowDelegates() noexcept\r\n        {\r\n            std::unique_lock<std::mutex> lock(m_windowMutex);\r\n            m_windowResizeDelegate = nullptr;\r\n            m_windowDisplayModeDelegate = nullptr;\r\n        }\r\n        //------------------------------------------------\r\n        //------------------------------------------------\r\n        void SFMLWindow::RemoveMouseDelegates() noexcept\r\n        {\r\n            std::unique_lock<std::mutex> lock(m_mouseMutex);\r\n            m_mouseButtonDelegate = nullptr;\r\n            m_mouseMovedDelegate = nullptr;\r\n            m_mouseWheelDelegate = nullptr;\r\n        }\r\n        //------------------------------------------------\r\n        //------------------------------------------------\r\n        void SFMLWindow::RemoveTextEnteredDelegate() noexcept\r\n        {\r\n            std::unique_lock<std::mutex> lock(m_textEntryMutex);\r\n            m_textEnteredDelegate = nullptr;\r\n        }\r\n        //------------------------------------------------\r\n        //------------------------------------------------\r\n        void SFMLWindow::RemoveKeyDelegates() noexcept\r\n        {\r\n            std::unique_lock<std::mutex> lock(m_keyMutex);\r\n            m_keyPressedDelegate = nullptr;\r\n            m_keyReleasedDelegate = nullptr;\r\n        }\r\n\r\n\t\t//------------------------------------------------------------------------------\r\n\t\tvoid SFMLWindow::RemoveJoystickDelegates() noexcept\r\n\t\t{\r\n\t\t\tstd::unique_lock<std::mutex> lock(m_joystickMutex);\r\n\t\t\tm_joystickConnectedDelegate = nullptr;\r\n\t\t\tm_joystickDisconnectedDelegate = nullptr;\r\n\t\t\tm_joystickButtonPressedDelegate = nullptr;\r\n\t\t\tm_joystickButtonReleasedDelegate = nullptr;\r\n\t\t\tm_joystickMovedDelegate = nullptr;\r\n\t\t}\r\n\r\n\t\t//------------------------------------------------\r\n\t\t//------------------------------------------------\r\n\t\tChilliSource::Integer2 SFMLWindow::GetWindowSize() const\r\n\t\t{\r\n\t\t\tauto size = m_window.getSize();\r\n\t\t\treturn ChilliSource::Integer2((s32)size.x, (s32)size.y);\r\n\t\t}\r\n\t\t//------------------------------------------------\r\n\t\t//------------------------------------------------\r\n\t\tsf::WindowHandle SFMLWindow::GetWindowHandle() const\r\n\t\t{\r\n\t\t\treturn m_window.getSystemHandle();\r\n\t\t}\r\n\t\t//------------------------------------------------\r\n\t\t//------------------------------------------------\r\n\t\tChilliSource::Integer2 SFMLWindow::GetMousePosition() const\r\n\t\t{\r\n\t\t\tsf::Vector2i pos = sf::Mouse::getPosition(m_window);\r\n\t\t\treturn ChilliSource::Integer2((s32)pos.x, (s32)pos.y);\r\n\t\t}\r\n\t\t//----------------------------------------------------\r\n\t\t//----------------------------------------------------\r\n\t\tvoid SFMLWindow::HideSystemCursor()\r\n\t\t{\r\n\t\t\tm_window.setMouseCursorVisible(false);\r\n\t\t}\r\n\t\t//----------------------------------------------------\r\n\t\t//----------------------------------------------------\r\n\t\tvoid SFMLWindow::ShowSystemCursor()\r\n\t\t{\r\n\t\t\tm_window.setMouseCursorVisible(true);\r\n\t\t}\r\n\t\t//-------------------------------------------------\r\n\t\t//-------------------------------------------------\r\n\t\tvoid SFMLWindow::Run()\r\n\t\t{\r\n\t\t\tJson::Value appConfigRoot = ReadAppConfig();\r\n\t\t\tChilliSource::SurfaceFormat surfaceFormat = ReadSurfaceFormat(appConfigRoot);\r\n\t\t\tu32 msaaFormat = ReadMultisampleFormat(appConfigRoot);\r\n\t\t\tm_contextSettings = CreateContextSettings(surfaceFormat, msaaFormat);\r\n\t\t\tm_preferredRGBADepth = ReadRGBAPixelDepth(surfaceFormat);\r\n\r\n\t\t\tauto displayMode = ReadInitialWindowMode(appConfigRoot);\r\n\t\t\tm_desktopSize = ChilliSource::Integer2((s32)sf::VideoMode::getDesktopMode().width, (s32)sf::VideoMode::getDesktopMode().height);\r\n\t\t\tChilliSource::Integer2 windowSize = ReadInitialWindowSize(appConfigRoot, displayMode == ChilliSource::Screen::DisplayMode::k_windowed ? m_desktopSize : GetSupportedFullscreenResolutions()[0]);\r\n\t\t\tSetDisplayMode(displayMode, windowSize, true);\r\n\r\n\t\t\tglewExperimental = GL_TRUE;\r\n\t\t\tGLenum glewError = glewInit();\r\n\t\t\tif (GLEW_OK != glewError)\r\n\t\t\t{\r\n\t\t\t\tOutputDebugString(CSBackend::Windows::WindowsStringUtils::UTF8ToUTF16(\"[ChilliSource] Glew Error On Init : \" + std::string((const char*)glewGetErrorString(glewError)) + \"\\n\").c_str());\r\n\t\t\t\texit(1);\r\n\t\t\t}\r\n\r\n            // Create SystemInfo here (make into an immutable class)\r\n            // Pass to application\r\n\t\t\tChilliSource::ApplicationUPtr app = ChilliSource::ApplicationUPtr(CreateApplication(SystemInfoFactory::CreateSystemInfo()));\r\n            m_lifecycleManager = ChilliSource::LifecycleManagerUPtr(new ChilliSource::LifecycleManager(app.get()));\r\n            m_lifecycleManager->Resume();\r\n            m_lifecycleManager->Foreground();\r\n\r\n\t\t\tm_isRunning = true;\r\n\t\t\tm_isFocused = true;\r\n\r\n\t\t\tauto appConfig = ChilliSource::Application::Get()->GetAppConfig();\r\n\t\t\tm_preferredFPS = appConfig->GetPreferredFPS();\r\n\r\n\t\t\tif (appConfig->IsVSyncEnabled())\r\n\t\t\t{\r\n\t\t\t\tSetVSyncEnabled(true);\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tm_window.setFramerateLimit(m_preferredFPS);\r\n\t\t\t}\r\n\r\n\t\t\tm_title = appConfig->GetDisplayableName();\r\n\t\t\tm_window.setTitle(m_title);\r\n\r\n\t\t\twhile (m_isRunning == true)\r\n\t\t\t{\r\n\t\t\t\tsf::Event event;\r\n\t\t\t\twhile (m_window.pollEvent(event))\r\n\t\t\t\t{\r\n\t\t\t\t\tswitch (event.type)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tdefault:\r\n\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\tcase sf::Event::Closed:\r\n\t\t\t\t\t\t\tQuit();\r\n\t\t\t\t\t\t\treturn;\r\n\t\t\t\t\t\tcase sf::Event::Resized:\r\n                        {\r\n                            std::unique_lock<std::mutex> lock(m_windowMutex);\r\n                            if (m_windowResizeDelegate)\r\n                            {\r\n                                m_windowResizeDelegate(ChilliSource::Integer2(s32(event.size.width), s32(event.size.height)));\r\n                            }\r\n                            break;\r\n                        }\r\n\t\t\t\t\t\tcase sf::Event::GainedFocus:\r\n\t\t\t\t\t\t\tif (m_isFocused == false)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tm_isFocused = true;\r\n                                m_lifecycleManager->Foreground();\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\tcase sf::Event::LostFocus:\r\n\t\t\t\t\t\t\tif (m_isFocused == true)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tm_isFocused = false;\r\n                                m_lifecycleManager->Background();\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\tcase sf::Event::MouseButtonPressed:\r\n                        {\r\n                            std::unique_lock<std::mutex> lock(m_mouseMutex);\r\n                            if (m_mouseButtonDelegate)\r\n                            {\r\n                                m_mouseButtonDelegate(event.mouseButton.button, MouseButtonEvent::k_pressed, event.mouseButton.x, event.mouseButton.y);\r\n                            }\r\n                            break;\r\n                        }\r\n\t\t\t\t\t\tcase sf::Event::MouseButtonReleased:\r\n                        {\r\n                            std::unique_lock<std::mutex> lock(m_mouseMutex);\r\n                            if (m_mouseButtonDelegate)\r\n                            {\r\n                                m_mouseButtonDelegate(event.mouseButton.button, MouseButtonEvent::k_released, event.mouseButton.x, event.mouseButton.y);\r\n                            }\r\n                            break;\r\n                        }\r\n\t\t\t\t\t\tcase sf::Event::MouseMoved:\r\n                        {\r\n                            std::unique_lock<std::mutex> lock(m_mouseMutex);\r\n                            if (m_mouseMovedDelegate)\r\n                            {\r\n                                m_mouseMovedDelegate(event.mouseMove.x, event.mouseMove.y);\r\n                            }\r\n                            break;\r\n                        }\r\n\t\t\t\t\t\tcase sf::Event::MouseWheelMoved:\r\n                        {\r\n                            std::unique_lock<std::mutex> lock(m_mouseMutex);\r\n                            if (m_mouseWheelDelegate)\r\n                            {\r\n                                m_mouseWheelDelegate(event.mouseWheel.delta);\r\n                            }\r\n                            break;\r\n                        }\r\n\t\t\t\t\t\tcase sf::Event::KeyPressed:\r\n                        {\r\n                            std::unique_lock<std::mutex> lock(m_keyMutex);\r\n                            if (m_keyPressedDelegate)\r\n                            {\r\n                                m_keyPressedDelegate(event.key.code, event.key);\r\n                            }\r\n                            break;\r\n                        }\r\n\t\t\t\t\t\tcase sf::Event::KeyReleased:\r\n                        {\r\n                            std::unique_lock<std::mutex> lock(m_keyMutex);\r\n                            if (m_keyReleasedDelegate)\r\n                            {\r\n                                m_keyReleasedDelegate(event.key.code);\r\n                            }\r\n                            break;\r\n                        }\r\n\t\t\t\t\t\tcase sf::Event::TextEntered:\r\n\t\t\t\t\t\t{\r\n                            std::unique_lock<std::mutex> lock(m_textEntryMutex);\r\n                            if (m_textEnteredDelegate)\r\n                            {\r\n                                ChilliSource::UTF8Char utf8Char = event.text.unicode;\r\n                                m_textEnteredDelegate(utf8Char);\r\n                            }\r\n\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tcase sf::Event::JoystickConnected:\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tstd::unique_lock<std::mutex> lock(m_joystickMutex);\r\n\t\t\t\t\t\t\tif (m_joystickConnectedDelegate)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tm_joystickConnectedDelegate(event.joystickConnect.joystickId);\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tcase sf::Event::JoystickDisconnected:\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tstd::unique_lock<std::mutex> lock(m_joystickMutex);\r\n\t\t\t\t\t\t\tif (m_joystickDisconnectedDelegate)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tm_joystickDisconnectedDelegate(event.joystickConnect.joystickId);\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tcase sf::Event::JoystickButtonPressed:\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tstd::unique_lock<std::mutex> lock(m_joystickMutex);\r\n\t\t\t\t\t\t\tif (m_joystickButtonPressedDelegate)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tm_joystickButtonPressedDelegate(event.joystickButton.joystickId, event.joystickButton.button);\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tcase sf::Event::JoystickButtonReleased:\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tstd::unique_lock<std::mutex> lock(m_joystickMutex);\r\n\t\t\t\t\t\t\tif (m_joystickButtonReleasedDelegate)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tm_joystickButtonReleasedDelegate(event.joystickButton.joystickId, event.joystickButton.button);\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tcase sf::Event::JoystickMoved:\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tstd::unique_lock<std::mutex> lock(m_joystickMutex);\r\n\t\t\t\t\t\t\tif (m_joystickMovedDelegate)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tm_joystickMovedDelegate(event.joystickMove.joystickId, event.joystickMove.axis, event.joystickMove.position);\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif (m_isFocused == true)\r\n\t\t\t\t{\r\n                \tm_lifecycleManager->SystemUpdate();\r\n                \tm_lifecycleManager->Render();\r\n                \tm_window.display();\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif (m_quitScheduled)\r\n\t\t\t\t{\r\n\t\t\t\t\tQuit();\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\t//--------------------------------------------\r\n\t\t//--------------------------------------------\r\n\t\tvoid SFMLWindow::Quit()\r\n\t\t{\r\n\t\t\tif (m_isFocused == true)\r\n\t\t\t{\r\n                m_lifecycleManager->Background();\r\n\t\t\t\tm_isFocused = false;\r\n\t\t\t}\r\n\r\n            m_lifecycleManager->Suspend();\r\n            m_lifecycleManager.reset();\r\n\r\n\t\t\tm_isRunning = false;\r\n\t\t}\r\n        //------------------------------------------------\r\n        //------------------------------------------------\r\n        SFMLWindow::~SFMLWindow() noexcept\r\n        {\r\n            CS_ASSERT(!m_windowResizeDelegate, \"Window resize delegate not removed.\");\r\n            CS_ASSERT(!m_windowDisplayModeDelegate, \"Window display mode delegate not removed.\");\r\n            CS_ASSERT(!m_mouseButtonDelegate, \"Mouse button event delegate not removed.\");\r\n            CS_ASSERT(!m_mouseMovedDelegate, \"Mouse moved delegate not removed.\");\r\n            CS_ASSERT(!m_mouseWheelDelegate, \"Mouse wheel scroll delegate not removed.\");\r\n            CS_ASSERT(!m_textEnteredDelegate, \"Text entry delegate not removed.\");\r\n            CS_ASSERT(!m_keyPressedDelegate, \"Key press delegate not removed.\");\r\n            CS_ASSERT(!m_keyReleasedDelegate, \"Key release delegate not removed.\");\r\n\t\t\tCS_ASSERT(!m_joystickConnectedDelegate, \"Joystick connected delegate not removed.\");\r\n\t\t\tCS_ASSERT(!m_joystickDisconnectedDelegate, \"Joystick disconnected delegate not removed.\");\r\n\t\t\tCS_ASSERT(!m_joystickButtonPressedDelegate, \"Joystick pressed delegate not removed.\");\r\n\t\t\tCS_ASSERT(!m_joystickButtonReleasedDelegate, \"Joystick released delegate not removed.\");\r\n\t\t\tCS_ASSERT(!m_joystickMovedDelegate, \"Joystick connected moved not removed.\");\r\n        }\r\n\t}\r\n}\r\n\r\n#endif\r\n"
  },
  {
    "path": "Source/CSBackend/Platform/Windows/SFML/Base/SFMLWindow.h",
    "content": "//\r\n//  SFMLWindow.h\r\n//  ChilliSource\r\n//  Created by Scott Downie on 11/03/2014.\r\n//\r\n//  The MIT License (MIT)\r\n//\r\n//  Copyright (c) 2014 Tag Games Limited\r\n//\r\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\r\n//  of this software and associated documentation files (the \"Software\"), to deal\r\n//  in the Software without restriction, including without limitation the rights\r\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\n//  copies of the Software, and to permit persons to whom the Software is\r\n//  furnished to do so, subject to the following conditions:\r\n//\r\n//  The above copyright notice and this permission notice shall be included in\r\n//  all copies or substantial portions of the Software.\r\n//\r\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r\n//  THE SOFTWARE.\r\n//\r\n#ifdef CS_TARGETPLATFORM_WINDOWS\r\n\r\n#ifndef _CSBACKEND_PLATFORM_WINDOWS_SFML_BASE_SFMLWINDOW_H_\r\n#define _CSBACKEND_PLATFORM_WINDOWS_SFML_BASE_SFMLWINDOW_H_\r\n\r\n#include <CSBackend/Platform/Windows/ForwardDeclarations.h>\r\n#include <ChilliSource/ChilliSource.h>\r\n#include <ChilliSource/Core/Base/LifeCycleManager.h>\r\n#include <ChilliSource/Core/Base/Singleton.h>\r\n#include <ChilliSource/Core/Base/Screen.h>\r\n#include <ChilliSource/Core/Event/Event.h>\r\n#include <ChilliSource/Core/Math/Vector2.h>\r\n#include <ChilliSource/Core/String/UTF8StringUtils.h>\r\n\r\n#include <SFML/Window.hpp>\r\n\r\n#include <functional>\r\n#include <mutex>\r\n\r\nnamespace CSBackend\r\n{\r\n\tnamespace Windows\r\n\t{\r\n\t\t//-----------------------------------------------------------\r\n\t\t/// System that allows access to SFML and its window\r\n        ///\r\n        /// While some of the methods in this class are thread-safe,\r\n        /// most should be called on the system thread.\r\n\t\t///\r\n\t\t/// @author S Downie\r\n\t\t//-----------------------------------------------------------\r\n\t\tclass SFMLWindow final : public ChilliSource::Singleton<SFMLWindow>\r\n\t\t{\r\n\t\tpublic:\r\n\r\n\t\t\t//-----------------------------------------------------------\r\n\t\t\t/// A delegate called when the window size changes.\r\n\t\t\t///\r\n\t\t\t/// @author S Downie\r\n\t\t\t///\r\n\t\t\t/// @param The new window size.\r\n\t\t\t//-----------------------------------------------------------\r\n\t\t\tusing WindowResizeDelegate = std::function<void(const ChilliSource::Integer2&)>;\r\n\t\t\t//-----------------------------------------------------------\r\n\t\t\t/// A delegate called when the window mode changes.\r\n\t\t\t///\r\n\t\t\t/// @author S Downie\r\n\t\t\t///\r\n\t\t\t/// @param The new window mode.\r\n\t\t\t//-----------------------------------------------------------\r\n\t\t\tusing WindowDisplayModeDelegate = std::function<void(ChilliSource::Screen::DisplayMode)>;\r\n\t\t\t//-----------------------------------------------------------\r\n\t\t\t/// List of the events that can occur on a mouse button\r\n\t\t\t///\r\n\t\t\t/// @author S Downie\r\n\t\t\t//-----------------------------------------------------------\r\n\t\t\tenum class MouseButtonEvent\r\n\t\t\t{\r\n\t\t\t\tk_pressed,\r\n\t\t\t\tk_released\r\n\t\t\t};\r\n\t\t\t//-----------------------------------------------------------\r\n\t\t\t/// A delegate called when a mouse button event occurs.\r\n\t\t\t///\r\n\t\t\t/// @author S Downie\r\n\t\t\t///\r\n\t\t\t/// @param Mouse button that the action occurred on\r\n\t\t\t/// @param The event type (Pressed/Released)\r\n\t\t\t/// @param Mouse position X\r\n\t\t\t/// @param Mouse position Y\r\n\t\t\t//-----------------------------------------------------------\r\n\t\t\tusing MouseButtonDelegate = std::function<void(sf::Mouse::Button, MouseButtonEvent, s32, s32)>;\r\n\t\t\t//-----------------------------------------------------------\r\n\t\t\t/// A delegate called when a mouse move event occurs.\r\n\t\t\t///\r\n\t\t\t/// @author S Downie\r\n\t\t\t///\r\n\t\t\t/// @param Mouse position X\r\n\t\t\t/// @param Mouse position Y\r\n\t\t\t//-----------------------------------------------------------\r\n\t\t\tusing MouseMovedDelegate = std::function<void(s32, s32)>;\r\n\t\t\t//-----------------------------------------------------------\r\n\t\t\t/// A delegate called when a mouse wheel event occurs.\r\n\t\t\t///\r\n\t\t\t/// @author S Downie\r\n\t\t\t///\r\n\t\t\t/// @param The number of ticks the wheel has moved in the y-axis\r\n\t\t\t//-----------------------------------------------------------\r\n\t\t\tusing MouseWheelDelegate = std::function<void(s32)>;\r\n\t\t\t//-----------------------------------------------------------\r\n\t\t\t/// A delegate called when a text is entered via user input.\r\n\t\t\t///\r\n\t\t\t/// @author S Downie\r\n\t\t\t///\r\n\t\t\t/// @param UTF-8 character entered\r\n\t\t\t//-----------------------------------------------------------\r\n\t\t\tusing TextEnteredDelegate = std::function<void(ChilliSource::UTF8Char)>;\r\n\t\t\t//-------------------------------------------------------\r\n\t\t\t/// Delegate that receieves events on the key with the\r\n\t\t\t/// given code when key is pressed\r\n\t\t\t///\r\n\t\t\t/// @author S Downie\r\n\t\t\t///\r\n\t\t\t/// @param Key code\r\n\t\t\t/// @param Event\r\n\t\t\t//-------------------------------------------------------\r\n\t\t\tusing KeyPressedDelegate = std::function<void(sf::Keyboard::Key, const sf::Event::KeyEvent&)>;\r\n\t\t\t//-------------------------------------------------------\r\n\t\t\t/// Delegate that receieves events on the key with the\r\n\t\t\t/// given code when key is released\r\n\t\t\t///\r\n\t\t\t/// @author S Downie\r\n\t\t\t///\r\n\t\t\t/// @param Key code\r\n\t\t\t//-------------------------------------------------------\r\n\t\t\tusing KeyReleasedDelegate = std::function<void(sf::Keyboard::Key)>;\r\n\r\n\t\t\t/// Delegate that receieves events when a new joystick is attached or removed\r\n\t\t\t///\r\n\t\t\t/// @param Index of joystick\r\n\t\t\t///\r\n\t\t\tusing JoystickConnectionChangedDelegate = std::function<void(u32)>;\r\n\r\n\t\t\t/// Delegate that receieves events when a button is pressed or released\r\n\t\t\t///\r\n\t\t\t/// @param Index of joystick\r\n\t\t\t/// @param Index of button\r\n\t\t\t///\r\n\t\t\tusing JoystickButtonDelegate = std::function<void(u32, u32)>;\r\n\r\n\t\t\t/// Delegate that receieves events when a button is pressed or released\r\n\t\t\t///\r\n\t\t\t/// @param Index of joystick\r\n\t\t\t/// @param Id of axis\r\n\t\t\t/// @param Position of axis\r\n\t\t\t///\r\n\t\t\tusing JoystickMovedDelegate = std::function<void(u32, sf::Joystick::Axis, f32)>;\r\n\r\n\t\t\t//-------------------------------------------------\r\n\t\t\t/// Create and begin running the SFML window which in turn\r\n\t\t\t/// will update and render the app\r\n\t\t\t///\r\n\t\t\t/// @author S Downie\r\n\t\t\t//-------------------------------------------------\r\n\t\t\tvoid Run();\r\n\t\t\t//-------------------------------------------------\r\n\t\t\t/// Set the desired frame limit for the SFML update\r\n\t\t\t/// and refresh. This is not completely accurate\r\n\t\t\t///\r\n\t\t\t/// @author S Downie\r\n\t\t\t///\r\n\t\t\t/// @param Frame per second limit\r\n\t\t\t//-------------------------------------------------\r\n\t\t\tvoid SetPreferredFPS(u32 in_fps);\r\n\t\t\t//-------------------------------------------------\r\n\t\t\t/// Enable or disable VSync\r\n\t\t\t///\r\n\t\t\t/// @author S Downie\r\n\t\t\t///\r\n\t\t\t/// @param Whether to enable or disable\r\n\t\t\t//-------------------------------------------------\r\n\t\t\tvoid SetVSyncEnabled(bool in_enable);\r\n\t\t\t//-------------------------------------------------\r\n\t\t\t/// Set the size of the window in pixels.\r\n\t\t\t///\r\n\t\t\t/// @author S Downie\r\n\t\t\t///\r\n\t\t\t/// @param Size in pixels\r\n\t\t\t//-------------------------------------------------\r\n\t\t\tvoid SetSize(const ChilliSource::Integer2& in_size);\r\n\t\t\t//-------------------------------------------------\r\n\t\t\t/// Set the window to fullscreen mode or windowed mode\r\n\t\t\t/// which will hide or the menu bar\r\n\t\t\t///\r\n\t\t\t/// @author S Downie\r\n\t\t\t///\r\n\t\t\t/// @param Window mode\r\n\t\t\t/// @param Window size\r\n\t\t\t/// @param TRUE to force set even if the same as previous\r\n\t\t\t//-------------------------------------------------\r\n\t\t\tvoid SetDisplayMode(ChilliSource::Screen::DisplayMode in_mode, const ChilliSource::Integer2& size, bool force = false);\r\n\t\t\t//----------------------------------------------------------\r\n\t\t\t/// @author S Downie\r\n\t\t\t///\r\n\t\t\t/// @return A list of resolutions supported by the display\r\n\t\t\t//----------------------------------------------------------\r\n\t\t\tstd::vector<ChilliSource::Integer2> GetSupportedFullscreenResolutions() const;\r\n\t\t\t//----------------------------------------------------\r\n\t\t\t/// Hide the window cursor\r\n\t\t\t///\r\n\t\t\t/// @author S Downie\r\n\t\t\t//----------------------------------------------------\r\n\t\t\tvoid HideSystemCursor();\r\n\t\t\t//----------------------------------------------------\r\n\t\t\t/// Show the window cursor\r\n\t\t\t///\r\n\t\t\t/// @author S Downie\r\n\t\t\t//----------------------------------------------------\r\n\t\t\tvoid ShowSystemCursor();\r\n\t\t\t//-------------------------------------------------\r\n            /// Set the delegates that relate to window events.\r\n            /// This method will assert if a given delegate is null\r\n            /// or if the delegate has already been set.\r\n            ///\r\n            /// This method is thread-safe.\r\n            ///\r\n            /// @author Jordan Brown\r\n            ///\r\n            /// @param in_windowResizeDelegate - The delegate to be\r\n            /// called when the window is resized.\r\n            /// @param in_windowDisplayModeDelegate - The delegate to be\r\n            /// called when the window's display mode is changed.\r\n            //-------------------------------------------------------\r\n            void SetWindowDelegates(const WindowResizeDelegate& in_windowResizeDelegate, const WindowDisplayModeDelegate& in_windowDisplayModeDelegate) noexcept;\r\n            //-------------------------------------------------------\r\n            /// Set the delegates that relate to mouse events.\r\n            /// This method will assert if a given delegate is null\r\n            /// or if the delegate has already been set.\r\n            ///\r\n            /// This method is thread-safe.\r\n            ///\r\n            /// @author Jordan Brown\r\n            ///\r\n            /// @param in_mouseButtonDelegate - The delegate to be\r\n            /// called when a mouse button event occurs.\r\n            /// @param in_mouseMovedDelegate - The delegate to be\r\n            /// called when the mouse is moved.\r\n            /// @param in_mouseWheelDelegate - The delegate to be\r\n            /// called when the mouse wheel is scrolled.\r\n            //-------------------------------------------------------\r\n            void SetMouseDelegates(const MouseButtonDelegate& in_mouseButtonDelegate, const MouseMovedDelegate& in_mouseMovedDelegate, const MouseWheelDelegate& in_mouseWheelDelegate) noexcept;\r\n            //-------------------------------------------------------\r\n            /// Set the delegate that is called when text is entered.\r\n            /// This method will assert if a given delegate is null\r\n            /// or if the delegate has already been set.\r\n            ///\r\n            /// This method is thread-safe.\r\n            ///\r\n            /// @author Jordan Brown\r\n            ///\r\n            /// @param in_textEnteredDelegate - The delegate to be\r\n            /// called.\r\n            //-------------------------------------------------------\r\n            void SetTextEnteredDelegate(const TextEnteredDelegate& in_textEnteredDelegate) noexcept;\r\n            //-------------------------------------------------------\r\n            /// Set the delegates that relate to keyboard events.\r\n            /// This method will assert if a given delegate is null\r\n            /// or if the delegate has already been set.\r\n            ///\r\n            /// This method is thread-safe.\r\n            ///\r\n            /// @author Jordan Brown\r\n            ///\r\n            /// @param in_keyPressedDelegate - The delegate to be\r\n            /// called when a key is pressed.\r\n            /// @param in_keyReleasedDelegate - The delegate to be\r\n            /// called when a key is released.\r\n            //-------------------------------------------------------\r\n            void SetKeyDelegates(const KeyPressedDelegate& in_keyPressedDelegate, const KeyReleasedDelegate& in_keyReleasedDelegate) noexcept;\r\n\r\n\t\t\t/// Set the delegates that relate to joystick events.\r\n\t\t\t/// This method will assert if a given delegate is null\r\n\t\t\t/// or if the delegate has already been set.\r\n\t\t\t///\r\n\t\t\t/// This method is thread-safe.\r\n\t\t\t///\r\n\t\t\t/// @param connectedDelegate\r\n\t\t\t///\t\tCalled when a new joystick is attached\r\n\t\t\t/// @param disconnectedDelegate\r\n\t\t\t///\t\tCalled when an existing joystick is removed\r\n\t\t\t/// @param buttonPressedDelegate\r\n\t\t\t///\t\tCalled when a button is pressed on a joystick\r\n\t\t\t/// @param buttonReleasedDelegate\r\n\t\t\t///\t\tCalled when a button is released on a joystick\r\n\t\t\t/// @param movedDelegate\r\n\t\t\t///\t\tCalled when an analogue stick is moved\r\n\t\t\t///\r\n\t\t\tvoid SetJoystickDelegates(JoystickConnectionChangedDelegate connectedDelegate, JoystickConnectionChangedDelegate disconnectedDelegate,\r\n\t\t\t\tJoystickButtonDelegate buttonPressedDelegate, JoystickButtonDelegate buttonReleasedDelegate, JoystickMovedDelegate movedDelegate) noexcept;\r\n\r\n            //-------------------------------------------------------\r\n            /// Remove the delegates that relate to window events.\r\n            ///\r\n            /// This method is thread-safe.\r\n            ///\r\n            /// @author Jordan Brown\r\n            //-------------------------------------------------------\r\n            void RemoveWindowDelegates() noexcept;\r\n            //-------------------------------------------------------\r\n            /// Remove the delegates that relate to mouse events.\r\n            ///\r\n            /// This method is thread-safe.\r\n            ///\r\n            /// @author Jordan Brown\r\n            //-------------------------------------------------------\r\n            void RemoveMouseDelegates() noexcept;\r\n            //-------------------------------------------------------\r\n            /// Remove the delegate that is called when text is entered.\r\n            ///\r\n            /// This method is thread-safe.\r\n            ///\r\n            /// @author Jordan Brown\r\n            //-------------------------------------------------------\r\n            void RemoveTextEnteredDelegate() noexcept;\r\n            //-------------------------------------------------------\r\n            /// Remove the delegates that relate to keyboard events.\r\n            ///\r\n            /// This method is thread-safe.\r\n            ///\r\n            /// @author Jordan Brown\r\n            //-------------------------------------------------------\r\n            void RemoveKeyDelegates() noexcept;\r\n\r\n\t\t\t/// Removes the delegates related to joystick events\r\n\t\t\t///\r\n\t\t\t/// This method is thread-safe\r\n\t\t\t///\r\n\t\t\tvoid RemoveJoystickDelegates() noexcept;\r\n\r\n\t\t\t//------------------------------------------------\r\n\t\t\t/// @author S Downie\r\n\t\t\t///\r\n\t\t\t/// @return Current size of the SFML window\r\n\t\t\t//------------------------------------------------\r\n\t\t\tChilliSource::Integer2 GetWindowSize() const;\r\n\t\t\t//------------------------------------------------\r\n\t\t\t/// @author S Downie\r\n\t\t\t///\r\n\t\t\t/// @return Current handle of the SFML window\r\n\t\t\t//------------------------------------------------\r\n\t\t\tsf::WindowHandle GetWindowHandle() const;\r\n\t\t\t//------------------------------------------------\r\n\t\t\t/// @author S Downie\r\n\t\t\t///\r\n\t\t\t/// @return Current position of mouse relative to Window\r\n\t\t\t//------------------------------------------------\r\n\t\t\tChilliSource::Integer2 GetMousePosition() const;\r\n\t\t\t//-------------------------------------------------\r\n\t\t\t/// Schedules a quit to occur at the end of the\r\n\t\t\t/// the current update.\r\n\t\t\t///\r\n\t\t\t/// @author HMcLaughlin\r\n\t\t\t//-------------------------------------------------\r\n\t\t\tvoid ScheduleQuit() noexcept { m_quitScheduled = true; }\r\n            //-------------------------------------------------\r\n            /// Destructor; makes sure that delegates have been\r\n            /// properly un-set.\r\n            ///\r\n            /// @author Jordan Brown\r\n            //-------------------------------------------------\r\n            ~SFMLWindow() noexcept;\r\n\r\n\t\tprivate:\r\n\r\n\t\t\t//-------------------------------------------------\r\n\t\t\t/// Recreate the window in fullscreen state\r\n\t\t\t///\r\n\t\t\t/// @author S Downie\r\n\t\t\t///\r\n\t\t\t/// @param size of window\r\n\t\t\t//-------------------------------------------------\r\n\t\t\tvoid SetFullscreen(const ChilliSource::Integer2& size);\r\n\t\t\t//-------------------------------------------------\r\n\t\t\t/// Recreate the window in windowed state\r\n\t\t\t///\r\n\t\t\t/// @author S Downie\r\n\t\t\t///\r\n\t\t\t/// @param size of window\r\n\t\t\t//-------------------------------------------------\r\n\t\t\tvoid SetWindowed(const ChilliSource::Integer2& size);\r\n\t\t\t//-------------------------------------------------\r\n\t\t\t/// Stops the update loop causing the application\r\n\t\t\t/// to terminate.\r\n\t\t\t///\r\n\t\t\t/// @author S Downie\r\n\t\t\t//-------------------------------------------------\r\n\t\t\tvoid Quit();\r\n\r\n\t\tprivate:\r\n\r\n\t\t\tsf::Window m_window;\r\n\r\n            WindowResizeDelegate m_windowResizeDelegate;\r\n            WindowDisplayModeDelegate m_windowDisplayModeDelegate;\r\n            MouseButtonDelegate m_mouseButtonDelegate;\r\n            MouseMovedDelegate m_mouseMovedDelegate;\r\n            MouseWheelDelegate m_mouseWheelDelegate;\r\n            TextEnteredDelegate m_textEnteredDelegate;\r\n            KeyPressedDelegate m_keyPressedDelegate;\r\n            KeyReleasedDelegate m_keyReleasedDelegate;\r\n\t\t\tJoystickConnectionChangedDelegate m_joystickConnectedDelegate;\r\n\t\t\tJoystickConnectionChangedDelegate m_joystickDisconnectedDelegate;\r\n\t\t\tJoystickButtonDelegate m_joystickButtonPressedDelegate;\r\n\t\t\tJoystickButtonDelegate m_joystickButtonReleasedDelegate;\r\n\t\t\tJoystickMovedDelegate m_joystickMovedDelegate;\r\n\r\n            std::mutex m_windowMutex;\r\n            std::mutex m_mouseMutex;\r\n            std::mutex m_textEntryMutex;\r\n            std::mutex m_keyMutex;\r\n\t\t\tstd::mutex m_joystickMutex;\r\n\r\n\t\t\tstd::string m_title;\r\n\r\n\t\t\tsf::ContextSettings m_contextSettings;\r\n\r\n\t\t\tu32 m_preferredRGBADepth = 32;\r\n\t\t\tu32 m_preferredFPS = 0;\r\n\t\t\tChilliSource::Integer2 m_desktopSize;\r\n\r\n\t\t\tbool m_isRunning = true;\r\n\t\t\tbool m_isFocused = true;\r\n\t\t\tbool m_quitScheduled = false;\r\n\r\n\t\t\tChilliSource::Screen::DisplayMode m_displayMode = ChilliSource::Screen::DisplayMode::k_windowed;\r\n\r\n            ChilliSource::LifecycleManagerUPtr m_lifecycleManager;\r\n\t\t};\r\n\t}\r\n}\r\n\r\n#endif\r\n\r\n#endif\r\n"
  },
  {
    "path": "Source/CSBackend/Platform/iOS/Core/Base/CSAppDelegate.h",
    "content": "//\n//  CSAppDelegate.h\n//  ChilliSource\n//  Created by Scott Downie on 08/02/2011.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2011 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_IOS\n\n#import <ChilliSource/ChilliSource.h>\n#import <GLKit/GLKit.h>\n#import <UIKit/UIKit.h>\n\n//--------------------------------------------------------------------\n/// iOS application delegate. This receieves events from the OS\n/// and controls the lifecycle and view hierarchy of the application.\n///\n/// iOS libraries can register as listeners to obtain the app delegate\n/// events\n///\n/// @author S Downie\n//--------------------------------------------------------------------\n@interface CSAppDelegate : NSObject <UIApplicationDelegate, GLKViewControllerDelegate, GLKViewDelegate>\n{\n    UIWindow* m_window;\n    GLKViewController* m_viewControllerInternal;\n    ChilliSource::ApplicationUPtr m_application;\n    ChilliSource::LifecycleManagerUPtr m_lifecycleManager;\n    \n    //Used to manually invoke OnForeground to conform to\n    //ChilliSource lifecycle events\n    BOOL m_isFirstActive;\n    \n    //Used to ensure that the Update event is only called\n    //between has become active and will resign active\n    BOOL m_isActive;\n    \n    NSMutableArray* m_subDelegates;\n}\n//--------------------------------------------------------------------\n/// @author Ian Copland\n///\n/// @return The view controller instance.\n//--------------------------------------------------------------------\n@property (readonly) GLKViewController* viewController;\n//--------------------------------------------------------------------\n/// @author S Downie\n///\n/// @return Singleton instance of the application delegate\n//--------------------------------------------------------------------\n+ (CSAppDelegate*) sharedInstance;\n//--------------------------------------------------------------------\n/// Add another UIApplication as a listener of AppDelegate events.\n/// This is useful for 3rd party iOS libraries that require\n/// hooks into the app delegate.\n///\n/// @author S Downie\n///\n/// @param UIApplicationDelegate\n//--------------------------------------------------------------------\n- (void) addAppDelegateListener:(id<UIApplicationDelegate>)in_delegate;\n//--------------------------------------------------------------------\n/// Remove another UIApplication as a listener of AppDelegate events.\n///\n/// @author S Downie\n///\n/// @param UIApplicationDelegate\n//--------------------------------------------------------------------\n- (void) removeAppDelegateListener:(id<UIApplicationDelegate>)in_delegate;\n//--------------------------------------------------------------------\n/// Set the target frame rate in frames per second\n///\n/// @author S Downie\n///\n/// @param Target FPS (15, 30, 60, etc)\n//--------------------------------------------------------------------\n- (void) setPreferredFPS:(NSUInteger)in_fps;\n\n@end\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/iOS/Core/Base/CSAppDelegate.mm",
    "content": "//\n//  CSAppDelegate.mm\n//  ChilliSource\n//  Created by Scott Downie on 08/02/2011.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2011 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_IOS\n\n#import <CSBackend/Platform/iOS/Core/Base/CSAppDelegate.h>\n\n#import <CSBackend/Platform/iOS/Core/Base/CSGLViewController.h>\n#import <CSBackend/Platform/iOS/Core/Base/SystemInfoFactory.h>\n#import <CSBackend/Platform/iOS/Core/Notification/LocalNotificationSystem.h>\n#import <CSBackend/Platform/iOS/Core/Notification/RemoteNotificationSystem.h>\n#import <ChilliSource/Core/Base/Application.h>\n#import <ChilliSource/Core/Base/LifecycleManager.h>\n#import <ChilliSource/Core/Threading/TaskScheduler.h>\n\nCSAppDelegate* singletonInstance = nil;\n\n@implementation CSAppDelegate\n\n@synthesize viewController = viewControllerInternal;\n\n//--------------------------------------------------------------------\n//--------------------------------------------------------------------\n+ (CSAppDelegate*) sharedInstance\n{\n    return singletonInstance;\n}\n//--------------------------------------------------------------------\n//--------------------------------------------------------------------\n- (void) addAppDelegateListener:(id<UIApplicationDelegate>)in_delegate\n{\n    [m_subDelegates addObject:in_delegate];\n}\n//--------------------------------------------------------------------\n//--------------------------------------------------------------------\n- (void) removeAppDelegateListener:(id<UIApplicationDelegate>)in_delegate\n{\n    [m_subDelegates removeObject:in_delegate];\n}\n//--------------------------------------------------------------------\n//--------------------------------------------------------------------\n- (void) setPreferredFPS:(NSUInteger)in_fps\n{\n    viewControllerInternal.preferredFramesPerSecond = in_fps;\n}\n\n#pragma mark -\n#pragma mark Application lifecycle\n//-------------------------------------------------------------\n/// Called when the app is first launched. The application can\n/// be launched with a dictionary of options.\n///\n/// The event is passed onto the listeners.\n///\n/// @author S Downie\n///\n/// @param Application\n/// @param Launching options\n//-------------------------------------------------------------\n- (BOOL) application:(UIApplication*)in_application didFinishLaunchingWithOptions:(NSDictionary*)in_launchingOptions\n{\n    singletonInstance = self;\n    \n    m_subDelegates = [[NSMutableArray alloc] init];\n    \n    m_window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];\n\tviewControllerInternal = [[CSGLViewController alloc] initWithDelegate:self];\n    [m_window setRootViewController: viewControllerInternal];\n    [m_window makeKeyAndVisible];\n    \n    m_application = ChilliSource::ApplicationUPtr(CreateApplication(CSBackend::iOS::SystemInfoFactory::CreateSystemInfo()));\n    \n    m_lifecycleManager = ChilliSource::LifecycleManagerUPtr(new ChilliSource::LifecycleManager(m_application.get()));\n    \n    m_isFirstActive = YES;\n    \n    for(id<UIApplicationDelegate> delegate in m_subDelegates)\n    {\n        if([delegate respondsToSelector:@selector(application:didFinishLaunchingWithOptions:)])\n        {\n            [delegate application:in_application didFinishLaunchingWithOptions:in_launchingOptions];\n        }\n    }\n    \n    CSBackend::iOS::LocalNotificationSystem::ApplicationDidFinishLaunchingWithOptions(in_application, in_launchingOptions);\n    \n\treturn YES;\n}\n//-------------------------------------------------------------\n/// Called when the app is forwarded a URL.\n///\n/// @author S Downie\n///\n/// @param Application\n/// @param URL\n/// @param Application that send URL\n/// @param Annotation\n//-------------------------------------------------------------\n- (BOOL) application:(UIApplication*)in_application openURL:(NSURL*)in_url sourceApplication:(NSString*)in_sourceApplication annotation:(id)in_annotation\n{\n    for(id<UIApplicationDelegate> delegate in m_subDelegates)\n    {\n        if([delegate respondsToSelector:@selector(application:openURL:sourceApplication:annotation:)])\n        {\n            if([delegate application:in_application openURL:in_url sourceApplication:in_sourceApplication annotation:in_annotation] == YES)\n            {\n                return YES;\n            }\n        }\n    }\n    \n    return NO;\n}\n//-------------------------------------------------------------\n/// Called when the app is suspended. This can occur\n/// when the user exits the application of as a result\n/// of interruptions such as phone calls.\n///\n/// The event is passed onto the listeners.\n///\n/// @author S Downie\n///\n/// @param Application\n//-------------------------------------------------------------\n- (void)applicationWillResignActive:(UIApplication*)in_application\n{\n    for(id<UIApplicationDelegate> delegate in m_subDelegates)\n    {\n        if([delegate respondsToSelector:@selector(applicationWillResignActive:)])\n        {\n            [delegate applicationWillResignActive:in_application];\n        }\n    }\n    \n    UIBackgroundTaskIdentifier bgTask = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:nil];\n    \n    dispatch_async(dispatch_get_main_queue(), ^\n    {\n        m_lifecycleManager->Background();\n        [[UIApplication sharedApplication] endBackgroundTask:bgTask];\n    });\n}\n//-------------------------------------------------------------\n/// Called when the app is backgrounded.\n/// The event is passed onto the listeners.\n///\n/// @author S Downie\n///\n/// @param Application\n//-------------------------------------------------------------\n- (void)applicationDidEnterBackground:(UIApplication*)in_application\n{\n    for(id<UIApplicationDelegate> delegate in m_subDelegates)\n    {\n        if([delegate respondsToSelector:@selector(applicationDidEnterBackground:)])\n        {\n            [delegate applicationDidEnterBackground:in_application];\n        }\n    }\n    \n    UIBackgroundTaskIdentifier bgTask = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:nil];\n    \n    dispatch_async(dispatch_get_main_queue(), ^\n    {\n        m_isActive = NO;\n        m_lifecycleManager->Suspend();\n        [[UIApplication sharedApplication] endBackgroundTask:bgTask];\n    });\n}\n//-------------------------------------------------------------\n/// Called when the app is resumed after being in the background.\n/// The event is passed onto the listeners.\n///\n/// @author S Downie\n///\n/// @param Application\n//-------------------------------------------------------------\n- (void)applicationWillEnterForeground:(UIApplication*)in_application\n{\n    //Sometimes iOS steals the context and doesn't return it.\n    GLKView* view = (GLKView*)viewControllerInternal.view;\n    if([EAGLContext currentContext] != view.context)\n    {\n        [EAGLContext setCurrentContext:view.context];\n    }\n    \n    m_lifecycleManager->Resume();\n    m_isActive = YES;\n    \n    for(id<UIApplicationDelegate> delegate in m_subDelegates)\n    {\n        if([delegate respondsToSelector:@selector(applicationWillEnterForeground:)])\n        {\n            [delegate applicationWillEnterForeground:in_application];\n        }\n    }\n}\n//-------------------------------------------------------------\n/// Called when the app is resumed after being started or\n/// re-activated. The event is passed onto the listeners.\n///\n/// @author S Downie\n///\n/// @param Application\n//-------------------------------------------------------------\n- (void)applicationDidBecomeActive:(UIApplication*)in_application\n{\n    if(m_isFirstActive == YES)\n    {\n        m_isFirstActive = NO;\n        \n        //Sometimes iOS steals the context and doesn't return it.\n        GLKView* view = (GLKView*)viewControllerInternal.view;\n        if([EAGLContext currentContext] != view.context)\n        {\n            [EAGLContext setCurrentContext:view.context];\n        }\n        \n        m_lifecycleManager->Resume();\n        m_isActive = YES;\n    }\n    \n    m_lifecycleManager->Foreground();\n    \n    for(id<UIApplicationDelegate> delegate in m_subDelegates)\n    {\n        if([delegate respondsToSelector:@selector(applicationDidBecomeActive:)])\n        {\n            [delegate applicationDidBecomeActive:in_application];\n        }\n    }\n    \n    CSBackend::iOS::LocalNotificationSystem::ApplicationDidBecomeActive(in_application);\n}\n//-------------------------------------------------------------\n/// Called when the app is about to terminate. Allowing CS\n/// to suspend safely. The event is passed onto the listeners.\n///\n/// @author S Downie\n///\n/// @param Application\n//-------------------------------------------------------------\n- (void)applicationWillTerminate:(UIApplication*)in_application\n{\n    for(id<UIApplicationDelegate> delegate in m_subDelegates)\n    {\n        if([delegate respondsToSelector:@selector(applicationWillTerminate:)])\n        {\n            [delegate applicationWillTerminate:in_application];\n        }\n    }\n    \n    UIBackgroundTaskIdentifier bgTask = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:nil];\n        \n    dispatch_async(dispatch_get_main_queue(), ^\n    {\n        m_isActive = NO;\n        m_lifecycleManager->Suspend();\n        [[UIApplication sharedApplication] endBackgroundTask:bgTask];\n    });\n}\n\n#pragma mark -\n#pragma mark GL Lifecycle\n\n/// Update the main game lopp\n///\n- (void)glkViewControllerUpdate:(GLKViewController*)controller\n{\n    if (m_isActive == YES)\n    {\n        m_lifecycleManager->SystemUpdate();\n    }\n}\n\n\n//-------------------------------------------------------------\n/// The main render loop for the application\n///\n/// @author S Downie\n///\n/// @param GL view\n/// @param Canvas size\n//-------------------------------------------------------------\n- (void)glkView:(GLKView*)view drawInRect:(CGRect)rect\n{\n    if (m_isActive == YES)\n    {\n        m_lifecycleManager->Render();\n    }\n}\n\n#pragma mark -\n#pragma mark Memory management\n//-------------------------------------------------------------\n/// Called when the device is low on memory and tells the\n/// application to purge its resource caches. Passes\n/// the event onto the listeners\n///\n/// @author S Downie\n///\n/// @param Application\n//-------------------------------------------------------------\n- (void)applicationDidReceiveMemoryWarning:(UIApplication*)in_application\n{\n    for(id<UIApplicationDelegate> delegate in m_subDelegates)\n    {\n        if([delegate respondsToSelector:@selector(applicationDidReceiveMemoryWarning:)])\n        {\n            [delegate applicationDidReceiveMemoryWarning:in_application];\n        }\n    }\n\n    m_lifecycleManager->MemoryWarning();\n}\n\n#pragma mark -\n#pragma mark Local notifications\n//-------------------------------------------------------------\n/// Called when the app receives a local notification from\n/// the OS. This notification is passed into the LocalNotificationSystem\n/// and the listeners\n///\n/// @author S Downie\n///\n/// @param Application\n/// @param Notification\n//-------------------------------------------------------------\n- (void)application:(UIApplication*)in_application didReceiveLocalNotification:(UILocalNotification*)in_notification\n{\n    for(id<UIApplicationDelegate> delegate in m_subDelegates)\n    {\n        if([delegate respondsToSelector:@selector(application:didReceiveLocalNotification:)])\n        {\n            [delegate application:in_application didReceiveLocalNotification:in_notification];\n        }\n    }\n    \n    CSBackend::iOS::LocalNotificationSystem::ApplicationDidReceiveLocalNotification(in_application, in_notification);\n}\n\n#pragma mark -\n#pragma mark Remote notifications\n//-------------------------------------------------------------\n/// Called when a request for a remote notification token\n/// is successful. The token is passed to the RemoteNotificationSystem\n/// and the listeners\n///\n/// @author S Downie\n///\n/// @param Application\n/// @param Token\n//-------------------------------------------------------------\n- (void)application:(UIApplication*)in_application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)in_deviceToken\n{\n    for(id<UIApplicationDelegate> delegate in m_subDelegates)\n    {\n        if([delegate respondsToSelector:@selector(application:didRegisterForRemoteNotificationsWithDeviceToken:)])\n        {\n            [delegate application:in_application didRegisterForRemoteNotificationsWithDeviceToken:in_deviceToken];\n        }\n    }\n    \n\tCSBackend::iOS::RemoteNotificationSystem* remoteNotificationSystem = ChilliSource::Application::Get()->GetSystem<CSBackend::iOS::RemoteNotificationSystem>();\n    if(nullptr != remoteNotificationSystem)\n    {\n        CS_LOG_WARNING(\"Received new remote notification token\");\n        remoteNotificationSystem->OnRemoteTokenReceived(in_deviceToken);\n    }\n    else\n    {\n        CS_LOG_ERROR(\"Error: Unable to get remote notification system. Has the system been created?\");\n    }\n}\n//-------------------------------------------------------------\n/// Called when the request for a remote notification token\n/// fails\n///\n/// @author S Downie\n///\n/// @param Application\n/// @param Error\n//-------------------------------------------------------------\n- (void)application:(UIApplication*)in_application didFailToRegisterForRemoteNotificationsWithError:(NSError*)in_error\n{\n\tNSLog(@\"Failed to receive remote notification token %@\", [in_error localizedDescription]);\n    \n    for(id<UIApplicationDelegate> delegate in m_subDelegates)\n    {\n        if([delegate respondsToSelector:@selector(application:didFailToRegisterForRemoteNotificationsWithError:)])\n        {\n            [delegate application:in_application didFailToRegisterForRemoteNotificationsWithError:in_error];\n        }\n    }\n}\n//-------------------------------------------------------------\n/// Called when the app receives a remote/push notification\n/// from an external sender. This funnels the notification into\n/// the RemoteNotification system and invokes the delegate listeners\n///\n/// @author S Downie\n///\n/// @param Application\n/// @param Dictionary containing the notification data\n//-------------------------------------------------------------\n- (void)application:(UIApplication*)in_application didReceiveRemoteNotification:(NSDictionary*)in_userInfo\n{\n\tCSBackend::iOS::RemoteNotificationSystem* remoteNotificationSystem = ChilliSource::Application::Get()->GetSystem<CSBackend::iOS::RemoteNotificationSystem>();\n    if(nullptr != remoteNotificationSystem)\n    {\n        CS_LOG_VERBOSE(\"Received remote notification\");\n        remoteNotificationSystem->OnRemoteNotificationReceived(in_application, in_userInfo);\n    }\n    else\n    {\n        CS_LOG_ERROR(\"Error: Unable to get remote notification system. Has the system been created?\");\n    }\n    \n    for(id<UIApplicationDelegate> delegate in m_subDelegates)\n    {\n        if([delegate respondsToSelector:@selector(application:didReceiveRemoteNotification:)])\n        {\n            [delegate application:in_application didReceiveRemoteNotification:in_userInfo];\n        }\n    }\n}\n//-------------------------------------------------------------\n/// Dealloc cleans up the application and UIViews\n///\n/// @author S Downie\n//-------------------------------------------------------------\n- (void)dealloc\n{\n    m_lifecycleManager.reset();\n    m_application.reset();\n    \n\t[m_viewControllerInternal release];\n    [m_window release];\n    [m_subDelegates release];\n    \n    singletonInstance = nil;\n    \n    [super dealloc];\n}\n\n@end\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/iOS/Core/Base/CSGLViewController.h",
    "content": "//\n//  CSGLViewController.h\n//  ChilliSource\n//  Created by Scott Downie on 09/05/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_IOS\n\n#import <GLKit/GLKit.h>\n\n//-------------------------------------------------------------\n/// GL view controller that is manages the GL view that iOS\n/// will render. The controller is responsible for\n/// view orientation, input, updating and rendering\n///\n/// @author S Downie\n//-------------------------------------------------------------\n@interface CSGLViewController : GLKViewController\n{\n    NSSet* supportedOrientations;\n}\n\n//-------------------------------------------------------------\n/// Create the view and the GL context.\n///\n/// @author S Downie\n///\n/// @param Delegate that implements the draw and update methods\n///        (GLKViewControllerDelegate, GLKViewDelegate)\n//-------------------------------------------------------------\n- (id)initWithDelegate:(id)in_delegate;\n\n@end\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/iOS/Core/Base/CSGLViewController.mm",
    "content": "//\n//  CSGLViewController.mm\n//  ChilliSource\n//  Created by Scott Downie on 09/05/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_IOS\n\n#import <CSBackend/Platform/iOS/Core/Base/CSGLViewController.h>\n\n#import <CSBackend/Platform/iOS/Core/Base/Screen.h>\n#import <CSBackend/Platform/iOS/Core/String/NSStringUtils.h>\n#import <CSBackend/Platform/iOS/Input/Pointer/PointerSystem.h>\n#import <ChilliSource/Core/Base/AppConfig.h>\n#import <ChilliSource/Core/Base/Application.h>\n#import <ChilliSource/Core/Base/Utils.h>\n#import <ChilliSource/Core/String/StringParser.h>\n#import <ChilliSource/Rendering/Base/SurfaceFormat.h>\n\n#import <json/json.h>\n\n@implementation CSGLViewController\n\n//-------------------------------------------------------------\n//-------------------------------------------------------------\n- (id)initWithDelegate:(id)in_delegate\n{\n    if((self = [super init]))\n\t{\n        EAGLContext* context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];\n        BOOL isContextSet = [EAGLContext setCurrentContext:context];\n        \n        if(context == nil || isContextSet == NO)\n        {\n            NSLog(@\"Could Create OpenGL ES 2.0 Context\");\n        }\n        \n        //load the JSON app.config string from file.\n        NSString* relativePath = [NSStringUtils newNSStringWithUTF8String:\"AppResources/App\"];\n        NSString* fullPath = [[NSBundle mainBundle] pathForResource:relativePath ofType:@\"config\"];\n        [relativePath release];\n        NSString* content = [NSString stringWithContentsOfFile:fullPath encoding:NSUTF8StringEncoding error:nil];\n        std::string jsonString = [NSStringUtils newUTF8StringWithNSString:content];\n        \n        //parse the json\n        Json::Reader jReader;\n        Json::Value root;\n        if(!jReader.parse(jsonString, root))\n        {\n            NSString* errors = [NSStringUtils newNSStringWithUTF8String:jReader.getFormatedErrorMessages()];\n            NSLog(@\"Could not parse App.config: %@\", errors);\n            [errors release];\n        }\n        \n        GLKView* view = [[GLKView alloc] initWithFrame:[[UIScreen mainScreen] bounds] context:context];\n        [self applySurfaceFormat:view fromConfig:root];\n        [self applyMultisampleFormat:view fromConfig:root];\n        view.userInteractionEnabled = YES;\n        view.enableSetNeedsDisplay = NO;\n        view.multipleTouchEnabled = YES;\n        view.delegate = in_delegate;\n        \n        self.view = view;\n        self.delegate = in_delegate;\n        \n        //Fetch the supported orientations from the plist\n        NSMutableSet* supportedOrientationTypes = [[NSMutableSet alloc] initWithCapacity:4];\n        supportedOrientations = supportedOrientationTypes;\n        \n        NSArray* supportedOrientationStrings = [[[NSBundle mainBundle] infoDictionary] objectForKey:@\"UISupportedInterfaceOrientations\"];\n        if(supportedOrientationStrings != nil)\n        {\n            for(NSString* string in supportedOrientationStrings)\n            {\n                if([string isEqualToString:@\"UIInterfaceOrientationLandscapeLeft\"])\n                {\n                    [supportedOrientationTypes addObject:[NSNumber numberWithInt:UIInterfaceOrientationLandscapeLeft]];\n                }\n                else if([string isEqualToString:@\"UIInterfaceOrientationLandscapeRight\"])\n                {\n                    [supportedOrientationTypes addObject:[NSNumber numberWithInt:UIInterfaceOrientationLandscapeRight]];\n                }\n                else if([string isEqualToString:@\"UIInterfaceOrientationPortrait\"])\n                {\n                    [supportedOrientationTypes addObject:[NSNumber numberWithInt:UIInterfaceOrientationPortrait]];\n                }\n                else if([string isEqualToString:@\"UIInterfaceOrientationPortraitUpsideDown\"])\n                {\n                    [supportedOrientationTypes addObject:[NSNumber numberWithInt:UIInterfaceOrientationPortraitUpsideDown]];\n                }\n            }\n        }\n        \n        return self;\n    }\n\n    return nil;\n}\n//-------------------------------------------------------------\n/// Applies the surface format described in the App.config file\n/// to the given view.\n///\n/// @author Ian Copland\n///\n/// @param The view to apply the format to.\n/// @param App config JSON\n//-------------------------------------------------------------\n- (void)applySurfaceFormat:(GLKView*)in_view fromConfig:(const Json::Value&)in_configRoot\n{\n    ChilliSource::SurfaceFormat preferredFormat = ChilliSource::ParseSurfaceFormat(in_configRoot.get(\"PreferredSurfaceFormat\", \"rgb565_depth24\").asString());\n    \n    const Json::Value& iOS = in_configRoot[\"iOS\"];\n    if(iOS.isNull() == false && iOS.isMember(\"PreferredSurfaceFormat\"))\n    {\n        preferredFormat = ChilliSource::ParseSurfaceFormat(iOS[\"PreferredSurfaceFormat\"].asString());\n    }\n    \n    //apply format\n    switch (preferredFormat)\n    {\n        case ChilliSource::SurfaceFormat::k_rgb565_depth24:\n        default:\n            in_view.drawableColorFormat = GLKViewDrawableColorFormatRGB565;\n            in_view.drawableDepthFormat = GLKViewDrawableDepthFormat24;\n            in_view.drawableStencilFormat = GLKViewDrawableStencilFormatNone;\n            break;\n        case ChilliSource::SurfaceFormat::k_rgb565_depth32:\n            in_view.drawableColorFormat = GLKViewDrawableColorFormatRGB565;\n            in_view.drawableDepthFormat = GLKViewDrawableDepthFormat24;\n            in_view.drawableStencilFormat = GLKViewDrawableStencilFormatNone;\n            break;\n        case ChilliSource::SurfaceFormat::k_rgb888_depth24:\n            in_view.drawableColorFormat = GLKViewDrawableColorFormatRGBA8888;\n            in_view.drawableDepthFormat = GLKViewDrawableDepthFormat24;\n            in_view.drawableStencilFormat = GLKViewDrawableStencilFormatNone;\n            break;\n        case ChilliSource::SurfaceFormat::k_rgb888_depth32:\n            in_view.drawableColorFormat = GLKViewDrawableColorFormatRGBA8888;\n            in_view.drawableDepthFormat = GLKViewDrawableDepthFormat24;\n            in_view.drawableStencilFormat = GLKViewDrawableStencilFormatNone;\n            break;\n        case ChilliSource::SurfaceFormat::k_rgb565_depth24_stencil8:\n            in_view.drawableColorFormat = GLKViewDrawableColorFormatRGB565;\n            in_view.drawableDepthFormat = GLKViewDrawableDepthFormat24;\n            in_view.drawableStencilFormat = GLKViewDrawableStencilFormat8;\n            break;\n        case ChilliSource::SurfaceFormat::k_rgb565_depth32_stencil8:\n            in_view.drawableColorFormat = GLKViewDrawableColorFormatRGB565;\n            in_view.drawableDepthFormat = GLKViewDrawableDepthFormat24;\n            in_view.drawableStencilFormat = GLKViewDrawableStencilFormat8;\n            break;\n        case ChilliSource::SurfaceFormat::k_rgb888_depth24_stencil8:\n            in_view.drawableColorFormat = GLKViewDrawableColorFormatRGBA8888;\n            in_view.drawableDepthFormat = GLKViewDrawableDepthFormat24;\n            in_view.drawableStencilFormat = GLKViewDrawableStencilFormat8;\n            break;\n        case ChilliSource::SurfaceFormat::k_rgb888_depth32_stencil8:\n            in_view.drawableColorFormat = GLKViewDrawableColorFormatRGBA8888;\n            in_view.drawableDepthFormat = GLKViewDrawableDepthFormat24;\n            in_view.drawableStencilFormat = GLKViewDrawableStencilFormat8;\n            break;\n    }\n}\n//-------------------------------------------------------------\n/// Applies the MSAA format described in the App.config file\n/// to the given view.\n///\n/// @author S Downie\n///\n/// @param The view to apply the format to.\n/// @param App config JSON\n//-------------------------------------------------------------\n- (void)applyMultisampleFormat:(GLKView*)in_view fromConfig:(const Json::Value&)in_configRoot\n{\n    GLKViewDrawableMultisample format = GLKViewDrawableMultisampleNone;\n    \n    std::string stringFormat = in_configRoot.get(\"Multisample\", \"None\").asString();\n    \n    const Json::Value& iOS = in_configRoot[\"iOS\"];\n    if(iOS.isNull() == false && iOS.isMember(\"Multisample\"))\n    {\n        stringFormat = iOS[\"Multisample\"].asString();\n    }\n    \n    ChilliSource::StringUtils::ToLowerCase(stringFormat);\n    if(stringFormat == \"none\")\n    {\n        format = GLKViewDrawableMultisampleNone;\n    }\n    else if(stringFormat == \"4x\")\n    {\n        format = GLKViewDrawableMultisample4X;\n    }\n    else\n    {\n        CS_LOG_FATAL(\"Unknown multisample format: \" + stringFormat + \". Options are None or 4x\");\n    }\n    \n    in_view.drawableMultisample = format;\n}\n//-------------------------------------------------------------\n/// Called by the OS to query whether the view should be\n/// allowed to rotate to the given orientation. The return\n/// is based on the values in the plist.\n///\n/// @author S Downie\n///\n/// @param Interface orientation to rotate to\n///\n/// @return Whether we support the given orientation\n//-------------------------------------------------------------\n- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)in_interfaceOrientation\n{\n\treturn [supportedOrientations containsObject:[NSNumber numberWithInt:in_interfaceOrientation]];\n}\n//-------------------------------------------------------------\n/// Called by the OS immediately before a view rotation\n/// occurs. This allows use to notify the engine of the orientation\n/// change. This will only get called in iOS versions prior to\n/// 8.0\n///\n/// @author S Downie\n///\n/// @param New orientation\n/// @param Time in seconds of orientation animation\n//-------------------------------------------------------------\n- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)in_toInterfaceOrientation duration:(NSTimeInterval)in_duration\n{\n    if(ChilliSource::Application::Get() != nullptr)\n    {\n        CSBackend::iOS::Screen* screen = ChilliSource::Application::Get()->GetSystem<CSBackend::iOS::Screen>();\n        screen->OnOrientationChanged(in_toInterfaceOrientation);\n    }\n}\n//-------------------------------------------------------------\n/// Called when the view is about to change size. This typically\n/// occurs on orientation change. This is only available in\n/// iOS 8 and above. Prior to iOS 8 the method\n/// willRotateToInterfaceOrientation is used instead.\n///\n/// @author Ian Copland\n///\n/// @param The new size.\n/// @param The coordinator.\n//-------------------------------------------------------------\n- (void)viewWillTransitionToSize:(CGSize)in_size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)in_coordinator\n{\n    if(ChilliSource::Application::Get() != nullptr)\n    {\n        CSBackend::iOS::Screen* screen = ChilliSource::Application::Get()->GetSystem<CSBackend::iOS::Screen>();\n        screen->OnResolutionChanged(in_size);\n    }\n}\n//-------------------------------------------------------------\n/// Ensures that the status bar is hidden while the GL View is\n/// active.\n///\n/// @author Ian Copland\n///\n/// @param Whether or not the status bar should be hidden.\n//-------------------------------------------------------------\n- (BOOL)prefersStatusBarHidden\n{\n    return YES;\n}\n//-------------------------------------------------------------\n/// Called by the OS when one or more touches start on the view\n///\n/// @author S Downie\n///\n/// @param Set of touches\n/// @param Event\n//-------------------------------------------------------------\n- (void)touchesBegan:(NSSet*)in_touches withEvent:(UIEvent*)in_event\n{\n    CSBackend::iOS::PointerSystem* pointerSystem = ChilliSource::Application::Get()->GetSystem<CSBackend::iOS::PointerSystem>();\n    CS_ASSERT(pointerSystem, \"touchesBegan callback requires the pointer system.\");\n    \n    for (UITouch* touch in in_touches)\n    {\n        pointerSystem->OnTouchBegan(touch);\n    }\n}\n\n//-------------------------------------------------------------\n/// Called by the OS when one or more touches are cancelled\n///\n/// @author S Downie\n///\n/// @param Set of touches\n/// @param Event\n//-------------------------------------------------------------\n- (void)touchesCancelled:(NSSet*)in_touches withEvent:(UIEvent*)in_event\n{\n    CSBackend::iOS::PointerSystem* pointerSystem = ChilliSource::Application::Get()->GetSystem<CSBackend::iOS::PointerSystem>();\n    CS_ASSERT(pointerSystem, \"touchesCancelled callback requires the pointer system.\");\n    \n    for (UITouch* touch in in_touches)\n    {\n        pointerSystem->OnTouchEnded(touch);\n    }\n}\n//-------------------------------------------------------------\n/// Called by the OS when one or more touches end on the view\n///\n/// @author S Downie\n///\n/// @param Set of touches\n/// @param Event\n//-------------------------------------------------------------\n- (void)touchesEnded:(NSSet*)in_touches withEvent:(UIEvent*)in_event\n{\n    CSBackend::iOS::PointerSystem* pointerSystem = ChilliSource::Application::Get()->GetSystem<CSBackend::iOS::PointerSystem>();\n    CS_ASSERT(pointerSystem, \"touchesEnded callback requires the pointer system.\");\n    \n\tfor (UITouch* touch in in_touches)\n    {\n        pointerSystem->OnTouchEnded(touch);\n    }\n}\n//-------------------------------------------------------------\n/// Called by the OS when one or more touches that have been\n/// started are then moved\n///\n/// @author S Downie\n///\n/// @param Set of touches\n/// @param Event\n//-------------------------------------------------------------\n- (void)touchesMoved:(NSSet*)in_touches withEvent:(UIEvent*)in_event\n{\n    CSBackend::iOS::PointerSystem* pointerSystem = ChilliSource::Application::Get()->GetSystem<CSBackend::iOS::PointerSystem>();\n    CS_ASSERT(pointerSystem, \"touchesEnded callback requires the pointer system.\");\n    \n    for (UITouch* touch in in_touches)\n    {\n        pointerSystem->OnTouchMoved(touch);\n    }\n}\n//-------------------------------------------------------------\n/// Dealloc\n///\n/// @author S Downie\n//-------------------------------------------------------------\n- (void) dealloc\n{\n    GLKView* view = (GLKView*)self.view;\n    [view.context release];\n    [EAGLContext setCurrentContext:nil];\n    [view release];\n    \n    [supportedOrientations release];\n    \n    [super dealloc];\n}\n\n@end\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/iOS/Core/Base/PlatformSystem.h",
    "content": "//\n//  PlatformSystem.h\n//  ChilliSource\n//  Created by Scott Downie on 24/11/2010.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2010 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_IOS\n\n#import <ChilliSource/ChilliSource.h>\n#import <CSBackend/Platform/iOS/ForwardDeclarations.h>\n#import <ChilliSource/Core/Base/PlatformSystem.h>\n\nnamespace CSBackend\n{\n\tnamespace iOS\n\t{\n\t\t//-------------------------------------------------------------\n\t\t/// The iOS backend for the platform system. This creates the\n        /// iOS specfic default systems and sets up the updater.\n        ///\n        /// @author S Downie\n\t\t//-------------------------------------------------------------\n\t\tclass PlatformSystem final : public ChilliSource::PlatformSystem\n\t\t{\n\t\tpublic:\n            CS_DECLARE_NAMEDTYPE(PlatformSystem);\n            //-------------------------------------------------------\n\t\t\t/// Queries whether or not this system implements the\n            /// interface with the given Id.\n\t\t\t///\n            /// @author Ian Copland\n            ///\n\t\t\t/// @param The interface Id.\n\t\t\t/// @param Whether system is of given type.\n\t\t\t//-------------------------------------------------------\n\t\t\tbool IsA(ChilliSource::InterfaceIDType in_interfaceId) const override;\n\t\t\t//------------------------------------------------------\n\t\t\t/// Adds default systems to the applications system\n\t\t\t/// list.\n            ///\n            /// @author S Downie\n\t\t\t///\n\t\t\t/// @param Application instance to add the default\n            /// platform systems to.\n\t\t\t//------------------------------------------------------\n\t\t\tvoid CreateDefaultSystems(ChilliSource::Application* in_application) override;\n            //------------------------------------------------------\n            /// @author S Downie\n            ///\n            /// @param The maximum frames per second to clamp to.\n            /// This should be in multiples of 15 (15, 30, 60)\n            //------------------------------------------------------\n            void SetPreferredFPS(u32 in_fps) override;\n            //---------------------------------------------------\n            /// NOTE: Not supported on iOS\n            ///\n            /// @author S Downie\n            ///\n            /// @param Enable/Disable\n            //---------------------------------------------------\n            void SetVSyncEnabled(bool in_enabled) override {};\n            //------------------------------------------------------\n            /// iOS cannot be manually quit\n            ///\n            /// @author S Downie\n            //------------------------------------------------------\n            void Quit() override {}\n\t\tprivate:\n            \n            friend ChilliSource::PlatformSystemUPtr ChilliSource::PlatformSystem::Create();\n            //------------------------------------------------------\n            /// Private constructor to force use of\n            /// factory method\n            ///\n            /// @author S Downie\n            //------------------------------------------------------\n            PlatformSystem() = default;\n\t\t};\n\t}\n}\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/iOS/Core/Base/PlatformSystem.mm",
    "content": "//\n//  PlatformSystem.mm\n//  ChilliSource\n//  Created by Scott Downie on 24/11/2010.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2010 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_IOS\n\n#import <CSBackend/Platform/iOS/Core/Base/PlatformSystem.h>\n\n#import <CSBackend/Platform/iOS/Core/Base/CSAppDelegate.h>\n#import <CSBackend/Platform/iOS/Core/String/NSStringUtils.h>\n#import <ChilliSource/Core/Base/Application.h>\n#import <ChilliSource/Core/Image/PVRImageProvider.h>\n#import <ChilliSource/Core/Threading/TaskScheduler.h>\n\nnamespace CSBackend \n{\n\tnamespace iOS\n\t{\n        CS_DEFINE_NAMEDTYPE(PlatformSystem);\n        //-------------------------------------------------------\n        //-------------------------------------------------------\n        bool PlatformSystem::IsA(ChilliSource::InterfaceIDType in_interfaceId) const\n        {\n            return (ChilliSource::PlatformSystem::InterfaceID == in_interfaceId || PlatformSystem::InterfaceID == in_interfaceId);\n        }\n        //-------------------------------------------------------\n        //-------------------------------------------------------\n\t\tvoid PlatformSystem::CreateDefaultSystems(ChilliSource::Application* in_application)\n\t\t{\n            in_application->CreateSystem<ChilliSource::PVRImageProvider>();\n\t\t}\n        //-------------------------------------------------------\n        //-------------------------------------------------------\n        void PlatformSystem::SetPreferredFPS(u32 in_fps)\n        {\n            ChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_system, [=](const ChilliSource::TaskContext& in_taskContext)\n            {\n                [[CSAppDelegate sharedInstance] setPreferredFPS:in_fps];\n            });\n        }\n\t}\n}\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/iOS/Core/Base/Screen.h",
    "content": "//\n//  Screen.h\n//  ChilliSource\n//  Created by Ian Copland on 25/04/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_IOS\n\n#import <ChilliSource/ChilliSource.h>\n#import <CSBackend/Platform/iOS/ForwardDeclarations.h>\n#import <ChilliSource/Core/Base/Screen.h>\n#import <ChilliSource/Core/Event/Event.h>\n\n#import <UIKit/UIKit.h>\n\nnamespace CSBackend\n{\n    namespace iOS\n    {\n        //----------------------------------------------------------------\n        /// The iOS backend for the screen. This provides information on\n        /// the iOS device's screen such as resolution and density scale.\n        ///\n        /// @author Ian Copland\n        //----------------------------------------------------------------\n\t\tclass Screen final : public ChilliSource::Screen\n\t\t{\n\t\tpublic:\n            CS_DECLARE_NAMEDTYPE(Screen);\n            //-------------------------------------------------------\n\t\t\t/// Queries whether or not this system implements the\n            /// interface with the given Id.\n\t\t\t///\n            /// @author Ian Copland\n            ///\n\t\t\t/// @param The interface Id.\n\t\t\t/// @param Whether system is of given type.\n\t\t\t//-------------------------------------------------------\n\t\t\tbool IsA(ChilliSource::InterfaceIDType in_interfaceId) const override;\n\t\t\t//-----------------------------------------------------------\n\t\t\t/// @author Ian Copland\n\t\t\t///\n\t\t\t/// @return Vector containing the width and height of screen\n            /// space available to the application. For a desktop app\n            /// this will be the current size of the window. For a mobile\n            /// application this will be full size of the screen.\n\t\t\t//-----------------------------------------------------------\n\t\t\tconst ChilliSource::Vector2& GetResolution() const override;\n            //-----------------------------------------------------------\n            /// The density scale factor as reported by the device. What\n            /// this factor relates to is platform dependant. On iOS it\n            /// is relative to a non-retina screen resolution. On Android\n            /// it is a factor that changes depending on whether the\n            /// screen is considered, low, medium, high or extra high\n            /// density.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @return The density scale factor of the screen\n            //-----------------------------------------------------------\n            f32 GetDensityScale() const override;\n            //-----------------------------------------------------------\n            /// @author Ian Copland\n            ///\n            /// @return The inverse of density scale factor of the screen\n            //-----------------------------------------------------------\n            f32 GetInverseDensityScale() const override;\n            //-----------------------------------------------------------\n            /// @author Ian Copland\n\t\t\t///\n\t\t\t/// @return An event that is called when the screen resolution\n            /// changes.\n\t\t\t//-----------------------------------------------------------\n            ChilliSource::IConnectableEvent<ResolutionChangedDelegate>& GetResolutionChangedEvent() override;\n            //-----------------------------------------------------------\n            /// @author S Downie\n\t\t\t///\n\t\t\t/// @return An event that is called when the screen display\n            /// mode changes.\n\t\t\t//-----------------------------------------------------------\n            ChilliSource::IConnectableEvent<DisplayModeChangedDelegate>& GetDisplayModeChangedEvent() override;\n            //----------------------------------------------------------\n            /// Does nothing on iOS due to fixed screen size\n            ///\n            /// @author S Downie\n            //\n\t\t\t/// @param Screen size in pixels\n\t\t\t//----------------------------------------------------------\n\t\t\tvoid SetResolution(const ChilliSource::Integer2& in_size) override;\n            //----------------------------------------------------------\n            /// Does nothing on iOS due to fixed screen state\n            ///\n            /// @author S Downie\n            //----------------------------------------------------------\n            void SetDisplayMode(DisplayMode in_mode) override;;\n            //----------------------------------------------------------\n            /// @author S Downie\n            ///\n            /// @return A list of resolutions supported by the display\n            //----------------------------------------------------------\n            std::vector<ChilliSource::Integer2> GetSupportedFullscreenResolutions() const override;\n            //-----------------------------------------------------------\n            /// Called when the screen orientation changes. This will update\n            /// the screen resolution and notify listeners that the resolution\n            /// has changed. This is for internal use and should not be\n            /// called manually. Note: As of iOS 8 this is now deprecated.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param The new orientation.\n            //------------------------------------------------------------\n            void OnOrientationChanged(UIInterfaceOrientation in_orientation);\n            //-----------------------------------------------------------\n            /// Called when the screen resolution changes. This will update\n            /// the screen resolution and notify listeners that the resolution\n            /// has changed. This is for internal use and should not be\n            /// called manually. This will only be called from iOS 8 onwards.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param The screen size in DIPS.\n            //------------------------------------------------------------\n            void OnResolutionChanged(CGSize in_dipsSize);\n        private:\n            friend ChilliSource::ScreenUPtr ChilliSource::Screen::Create(const ChilliSource::ScreenInfo& screenInfo);\n            //-------------------------------------------------------\n\t\t\t/// Private constructor to force the use of the Create()\n            /// factory method.\n\t\t\t///\n            /// @author Ian Copland\n\t\t\t//-------------------------------------------------------\n\t\t\tScreen(const ChilliSource::ScreenInfo& screenInfo);\n    \n            ChilliSource::ScreenInfo m_screenInfo;\n            ChilliSource::Vector2 m_resolution;\n\n            ChilliSource::Event<ResolutionChangedDelegate> m_resolutionChangedEvent;\n            ChilliSource::Event<DisplayModeChangedDelegate> m_displayModeChangedEvent;\n        };\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/iOS/Core/Base/Screen.mm",
    "content": "//\n//  Screen.mm\n//  ChilliSource\n//  Created by Ian Copland on 25/04/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_IOS\n\n#import <ChilliSource/Core/Base/Application.h>\n#import <ChilliSource/Core/Threading/TaskScheduler.h>\n\n#import <CSBackend/Platform/iOS/Core/Base/CSAppDelegate.h>\n#import <CSBackend/Platform/iOS/Core/Base/Screen.h>\n\n#import <Foundation/Foundation.h>\n#import <UIKit/UIKit.h>\n\nnamespace CSBackend\n{\n    namespace iOS\n    {\n        namespace\n        {\n            //----------------------------------------------------\n            /// Calculate the resolution of the screen, pre-iOS 8.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param The orientation of the application.\n            /// @param The size of the screen in portrait DIPS.\n            /// @param The device pixel scale factor.\n            ///\n            /// @return The iOS device resolution.\n            //----------------------------------------------------\n            ChilliSource::Vector2 CalculateResolution(UIInterfaceOrientation in_orientation, CGSize in_dipsSize, f32 in_pixelScaleFactor)\n            {\n                ChilliSource::Vector2 resolution(in_dipsSize.width * in_pixelScaleFactor, in_dipsSize.height * in_pixelScaleFactor);\n                \n                if (in_orientation == UIInterfaceOrientationLandscapeLeft || in_orientation == UIInterfaceOrientationLandscapeRight)\n                {\n                    resolution = ChilliSource::Vector2(resolution.y, resolution.x);\n                }\n                \n                return resolution;\n            }\n            //----------------------------------------------------\n            /// Calculate the resolution of the screen in iOS 8\n            /// and above.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param The size of the screen in DIPS.\n            /// @param The device pixel scale factor.\n            ///\n            /// @return The iOS device resolution.\n            //----------------------------------------------------\n            ChilliSource::Vector2 CalculateResolution(CGSize in_dipsSize, f32 in_pixelScaleFactor)\n            {\n                ChilliSource::Vector2 resolution(std::round(in_dipsSize.width * in_pixelScaleFactor), std::round(in_dipsSize.height * in_pixelScaleFactor));\n                return resolution;\n            }\n            //----------------------------------------------------\n            /// @author Ian Copland\n            ///\n            /// @return Whether or not the resolution should be\n            /// calculated based on the screen orientation. This\n            /// is only the case below iOS 8, and this is\n            /// effectively a check for pre-iOS 8.\n            //----------------------------------------------------\n#if CS_ENABLE_DEBUG\n            bool ShouldCalculateBasedOnOrientation()\n            {\n#ifdef NSFoundationVersionNumber_iOS_7_1\n                return (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_7_1);\n#else\n                return true;\n#endif\n            }\n#endif\n        }\n        \n        CS_DEFINE_NAMEDTYPE(Screen);\n        //-------------------------------------------------------\n        //-------------------------------------------------------\n        Screen::Screen(const ChilliSource::ScreenInfo& screenInfo)\n            : m_screenInfo(screenInfo)\n        {\n            m_resolution = m_screenInfo.GetInitialResolution();\n        }\n        //-------------------------------------------------------\n        //-------------------------------------------------------\n        bool Screen::IsA(ChilliSource::InterfaceIDType in_interfaceId) const\n        {\n            return (ChilliSource::Screen::InterfaceID == in_interfaceId || Screen::InterfaceID == in_interfaceId);\n        }\n        //-----------------------------------------------------------\n        //-----------------------------------------------------------\n        const ChilliSource::Vector2& Screen::GetResolution() const\n        {\n            return m_resolution;\n        }\n        //-----------------------------------------------------------\n        //-----------------------------------------------------------\n        f32 Screen::GetDensityScale() const\n        {\n            return m_screenInfo.GetDensityScale();\n        }\n        //----------------------------------------------------------\n        //-----------------------------------------------------------\n        f32 Screen::GetInverseDensityScale() const\n        {\n            return m_screenInfo.GetInverseDensityScale();\n        }\n        //-----------------------------------------------------------\n        //-----------------------------------------------------------\n        ChilliSource::IConnectableEvent<Screen::ResolutionChangedDelegate>& Screen::GetResolutionChangedEvent()\n        {\n            return m_resolutionChangedEvent;\n        }\n        //-----------------------------------------------------------\n        //-----------------------------------------------------------\n        ChilliSource::IConnectableEvent<Screen::DisplayModeChangedDelegate>& Screen::GetDisplayModeChangedEvent()\n        {\n            return m_displayModeChangedEvent;\n        }\n        //----------------------------------------------------------\n        //----------------------------------------------------------\n        std::vector<ChilliSource::Integer2> Screen::GetSupportedFullscreenResolutions() const\n        {\n            return m_screenInfo.GetSupportedFullscreenResolutions();\n        }\n        //----------------------------------------------------------\n\t\t//----------------------------------------------------------\n\t\tvoid Screen::SetResolution(const ChilliSource::Integer2& in_size)\n\t\t{\n\t\t\tCS_LOG_WARNING(\"Screen::SetResolution has no effect on iOS\");\n\t\t}\n        //----------------------------------------------------------\n        //----------------------------------------------------------\n        void Screen::SetDisplayMode(DisplayMode in_mode)\n        {\n        \tCS_LOG_WARNING(\"Screen::SetDisplayMode has no effect on iOS\");\n        }\n        //-----------------------------------------------------------\n        //------------------------------------------------------------\n        void Screen::OnOrientationChanged(UIInterfaceOrientation in_orientation)\n        {\n            CS_ASSERT(ShouldCalculateBasedOnOrientation() == true, \"OnOrientationChanged() should not get called on devices that do not require orientation based calculations.\");\n            \n            ChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_mainThread, [=](const ChilliSource::TaskContext& taskContext)\n            {\n                m_resolution = CalculateResolution(in_orientation, [[UIScreen mainScreen] bounds].size, [UIScreen mainScreen].scale);\n                m_resolutionChangedEvent.NotifyConnections(m_resolution);\n            });\n        }\n        //-----------------------------------------------------------\n        //-----------------------------------------------------------\n        void Screen::OnResolutionChanged(CGSize in_dipsSize)\n        {\n            CS_ASSERT(ShouldCalculateBasedOnOrientation() == false, \"OnResolutionChanged() should not get called on devices that require orientation based calculations.\");\n            \n            ChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_mainThread, [=](const ChilliSource::TaskContext& taskContext)\n            {\n                m_resolution = CalculateResolution(in_dipsSize, m_screenInfo.GetDensityScale());\n                m_resolutionChangedEvent.NotifyConnections(m_resolution);\n            });\n        }\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/iOS/Core/Base/SystemInfoFactory.h",
    "content": "//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_IOS\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Base/SystemInfo.h>\n#include <CSBackend/Platform/iOS/ForwardDeclarations.h>\n\nnamespace CSBackend\n{\n    namespace iOS\n    {\n        /// A factory for creating new instances of SystemInfo. This will query the iOS\n        /// API to gather information about the device.\n        ///\n        namespace SystemInfoFactory\n        {\n            /// This function creates the new SystemInfo instance.\n            /// @return The new instance.\n            ///\n            ChilliSource::SystemInfoCUPtr CreateSystemInfo() noexcept;\n        }\n    }\n}\n\n#endif"
  },
  {
    "path": "Source/CSBackend/Platform/iOS/Core/Base/SystemInfoFactory.mm",
    "content": "//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_IOS\n\n#import <ChilliSource/Core/Base/DeviceInfo.h>\n#import <ChilliSource/Core/Base/ScreenInfo.h>\n#import <ChilliSource/Core/Base/SystemInfo.h>\n#import <ChilliSource/Core/String/StringUtils.h>\n\n#import <CSBackend/Platform/iOS/Core/Base/CSAppDelegate.h>\n#import <CSBackend/Platform/iOS/Core/Base/Screen.h>\n#import <CSBackend/Platform/iOS/Core/Base/SystemInfoFactory.h>\n\n#import <CSBackend/Platform/iOS/Core/String/NSStringUtils.h>\n#import <CSBackend/Rendering/OpenGL/Base/RenderInfoFactory.h>\n\n#import <Foundation/Foundation.h>\n#import <UIKit/UIKit.h>\n#import <sys/types.h>\n#import <sys/sysctl.h>\n\nnamespace CSBackend\n{\n    namespace iOS\n    {\n        namespace\n        {\n            const std::string k_deviceManufacturer = \"Apple\";\n            \n            /// @return The current device model.\n            ///\n            std::string GetDeviceModel() noexcept\n            {\n                @autoreleasepool\n                {\n                    NSString * type = [[UIDevice currentDevice] model];\n                    return [NSStringUtils newUTF8StringWithNSString:type];\n                }\n            }\n            \n            /// @return The current device model type.\n            ///\n            std::string GetDeviceModelType() noexcept\n            {\n                size_t size = 0;\n                sysctlbyname(\"hw.machine\", nullptr, &size, nullptr, 0);\n                s8* machine = new s8[size];\n                sysctlbyname(\"hw.machine\", machine, &size, nullptr, 0);\n                std::string modelType(machine);\n                CS_SAFEDELETE_ARRAY(machine);\n                \n                std::string output;\n                bool record = false;\n                for(std::string::const_iterator it = modelType.begin(); it != modelType.end(); ++it)\n                {\n                    if(isdigit(*it))\n                    {\n                        record = true;\n                    }\n                    \n                    if(record)\n                    {\n                        output += (*it);\n                    }\n                }\n                return output;\n            }\n            \n            /// @return The current OS version.\n            ///\n            std::string GetOSVersion() noexcept\n            {\n                @autoreleasepool\n                {\n                    NSString* version = [[UIDevice currentDevice] systemVersion];\n                    return [NSStringUtils newUTF8StringWithNSString:version];\n                }\n            }\n            \n            /// @return The current locale.\n            ///\n            std::string GetLocale() noexcept\n            {\n                @autoreleasepool\n                {\n                    NSLocale* locale = [NSLocale currentLocale];\n                    NSString* languageCode = [locale objectForKey:NSLocaleLanguageCode];\n                    NSString* countryCode = [locale objectForKey:NSLocaleCountryCode];\n                    if (countryCode != nil && [countryCode length] > 0)\n                    {\n                        return [NSStringUtils newUTF8StringWithNSString:languageCode] + \"_\" + [NSStringUtils newUTF8StringWithNSString:countryCode];\n                    }\n                    else\n                    {\n                        return [NSStringUtils newUTF8StringWithNSString:languageCode];\n                    }\n                }\n            }\n            \n            /// @return The current language.\n            ///\n            std::string GetLanguage() noexcept\n            {\n                @autoreleasepool\n                {\n                    NSUserDefaults* userDefaults = [NSUserDefaults standardUserDefaults];\n                    NSArray* supportedLanguages = [userDefaults objectForKey:@\"AppleLanguages\"];\n                    NSString* userLocale = [supportedLanguages objectAtIndex:0];\n                    std::string localeCode = [userLocale UTF8String];\n                    \n                    std::vector<std::string> localeBrokenUp = ChilliSource::StringUtils::Split(localeCode, \"-\", 0);\n                    if (localeBrokenUp.size() > 0)\n                    {\n                        return localeBrokenUp[0];\n                    }\n                    else\n                    {\n                        return \"en\";\n                    }\n                }\n            }\n            \n            /// @return The unique device identifier.\n            ///\n            std::string GetUDID() noexcept\n            {\n                @autoreleasepool\n                {\n                    if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 6.0f)\n                    {\n                        NSUUID* uid = [UIDevice currentDevice].identifierForVendor;\n                        return [NSStringUtils newUTF8StringWithNSString:[uid UUIDString]];\n                    }\n                    \n                    return \"\";\n                }\n            }\n            \n            /// @return The number of cores.\n            ///\n            u32 GetNumberOfCPUCores() noexcept\n            {\n                u32 numCores = 1;\n                size_t size = sizeof(numCores);\n                \n                if(sysctlbyname(\"hw.ncpu\", &numCores, &size, nullptr, 0))\n                {\n                    return 1;\n                }\n                else\n                {\n                    return numCores;\n                }\n            }\n    \n            /// Calculate the resolution of the screen, pre-iOS 8.\n            ///\n            /// @param The orientation of the application.\n            /// @param The size of the screen in portrait DIPS.\n            /// @param The device pixel scale factor.\n            ///\n            /// @return The iOS device resolution.\n            ChilliSource::Vector2 CalculateResolution(UIInterfaceOrientation in_orientation, CGSize in_dipsSize, f32 in_pixelScaleFactor)\n            {\n                ChilliSource::Vector2 resolution(in_dipsSize.width * in_pixelScaleFactor, in_dipsSize.height * in_pixelScaleFactor);\n                \n                if (in_orientation == UIInterfaceOrientationLandscapeLeft || in_orientation == UIInterfaceOrientationLandscapeRight)\n                {\n                    resolution = ChilliSource::Vector2(resolution.y, resolution.x);\n                }\n                \n                return resolution;\n            }\n            \n            /// Calculate the resolution of the screen in iOS 8\n            /// and above.\n            ///\n            /// @param The size of the screen in DIPS.\n            /// @param The device pixel scale factor.\n            ///\n            /// @return The iOS device resolution.\n            ///\n            ChilliSource::Vector2 CalculateResolution(CGSize in_dipsSize, f32 in_pixelScaleFactor)\n            {\n                ChilliSource::Vector2 resolution(std::round(in_dipsSize.width * in_pixelScaleFactor), std::round(in_dipsSize.height * in_pixelScaleFactor));\n                return resolution;\n            }\n\n            /// @return Whether or not the resolution should be\n            /// calculated based on the screen orientation. This\n            /// is only the case below iOS 8, and this is\n            /// effectively a check for pre-iOS 8.\n            ///\n            bool ShouldCalculateBasedOnOrientation()\n            {\n#ifdef NSFoundationVersionNumber_iOS_7_1\n                return (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_7_1);\n#else\n                return true;\n#endif\n            }\n\n        }\n        \n        //-------------------------------------------------------\n        ChilliSource::SystemInfoCUPtr SystemInfoFactory::CreateSystemInfo() noexcept\n        {\n\t\t\t// Create DeviceInfo.\n\t\t\tChilliSource::DeviceInfo deviceInfo(GetDeviceModel(), GetDeviceModelType(), k_deviceManufacturer, GetUDID(), GetLocale(), GetLanguage(), GetOSVersion(), GetNumberOfCPUCores());\n\n            // Create ScreenInfo\n            f32 densityScale;\n            ChilliSource::Vector2 currentResolution;\n            std::vector<ChilliSource::Integer2> supportedResolutions;\n            std::string appVersion;\n            \n            @autoreleasepool\n            {\n                if (ShouldCalculateBasedOnOrientation() == false)\n                {\n                    //get resolution for iOS 8 and higher.\n                    densityScale = [UIScreen mainScreen].nativeScale;\n                    currentResolution = CalculateResolution([[UIScreen mainScreen] bounds].size, densityScale);\n                }\n                else\n                {\n                    //get resolution for pre-iOS 8 devices.\n                    densityScale = [UIScreen mainScreen].scale;\n                    currentResolution = CalculateResolution([[CSAppDelegate sharedInstance] viewController].interfaceOrientation, [[UIScreen mainScreen] bounds].size, densityScale);\n                }\n                \n                NSString* version = [[NSBundle mainBundle] objectForInfoDictionaryKey:(NSString *)kCFBundleVersionKey];\n                appVersion = [NSStringUtils newUTF8StringWithNSString:version];\n            }\n\n            supportedResolutions.push_back(ChilliSource::Integer2((s32)currentResolution.x, (s32)currentResolution.y));\n            supportedResolutions.push_back(ChilliSource::Integer2((s32)currentResolution.y, (s32)currentResolution.x));\n            \n            ChilliSource::RenderInfo renderInfo = OpenGL::RenderInfoFactory::CreateRenderInfo();\n            ChilliSource::ScreenInfo screenInfo(currentResolution, densityScale, 1.0f / densityScale, supportedResolutions);\n            \n            // Create SystemInfo.\n            ChilliSource::SystemInfoUPtr systemInfo(new ChilliSource::SystemInfo(deviceInfo, screenInfo, renderInfo, appVersion));\n            \n            return std::move(systemInfo);\n        }\n        \n    }\n}\n\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/iOS/Core/DialogueBox/DialogueBoxListener.h",
    "content": "//\n//  DialogueBoxListener.h\n//  ChilliSource\n//  Created by Ian Copland on 05/03/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_IOS\n\n#include <ChilliSource/ChilliSource.h>\n#include <CSBackend/Platform/iOS/ForwardDeclarations.h>\n\n#import <Foundation/Foundation.h>\n#import <UIKit/UIKit.h>\n\n//------------------------------------------------------------\n/// Listener for callbacks from system message boxes.\n//------------------------------------------------------------\n@interface DialogueBoxListener : NSObject\n{\n    CSBackend::iOS::DialogueBoxSystem* dialogueBoxSystem;\n}\n//------------------------------------------------------------\n/// Constructor\n///\n/// @author Ian Copland\n///\n/// @param The dialogue box system.\n//------------------------------------------------------------\n-(id) initWithDialogueBoxSystem:(CSBackend::iOS::DialogueBoxSystem*)system;\n//------------------------------------------------------------\n/// Listens for callbacks from alert views.\n///\n/// @author Ian Copland\n///\n/// @param The alert view.\n/// @param The button index.\n//------------------------------------------------------------\n-(void) alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex;\n//------------------------------------------------------------\n/// Destructor\n///\n/// @author Ian Copland\n//------------------------------------------------------------\n-(void) dealloc;\n\n@end\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/iOS/Core/DialogueBox/DialogueBoxListener.mm",
    "content": "//\n//  DialogueBoxListener.mm\n//  ChilliSource\n//  Created by Ian Copland on 05/03/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_IOS\n\n#import <CSBackend/Platform/iOS/Core/DialogueBox/DialogueBoxListener.h>\n\n#import <CSBackend/Platform/iOS/Core/DialogueBox/DialogueBoxSystem.h>\n\n@implementation DialogueBoxListener\n//------------------------------------------------------------\n//------------------------------------------------------------\n-(id) initWithDialogueBoxSystem:(CSBackend::iOS::DialogueBoxSystem*)system\n{\n    if (self = [super init])\n    {\n        dialogueBoxSystem = system;\n        return self;\n    }\n    return nil;\n}\n//------------------------------------------------------------\n//------------------------------------------------------------\n-(void) alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex\n{\n    if (dialogueBoxSystem != nullptr)\n    {\n        //we know the Id is in the range of a u32 as we set it when the confirm dialogue was created meaning we can cast to that.\n        u32 tag = static_cast<u32>(alertView.tag);\n        \n        // NO = 0, YES = 1\n        if(buttonIndex == 0)\n        {\n            dialogueBoxSystem->OnSystemConfirmDialogResult(tag, ChilliSource::DialogueBoxSystem::DialogueResult::k_cancel);\n        }\n        else\n        {\n            dialogueBoxSystem->OnSystemConfirmDialogResult(tag, ChilliSource::DialogueBoxSystem::DialogueResult::k_confirm);\n        }\n    }\n}\n//------------------------------------------------------------\n//------------------------------------------------------------\n-(void) dealloc\n{\n    dialogueBoxSystem = nullptr;\n    [super dealloc];\n}\n\n@end\n\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/iOS/Core/DialogueBox/DialogueBoxSystem.h",
    "content": "//\n//  DialogueBoxSystem.h\n//  ChilliSource\n//  Created by Ian Copland on 04/03/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_IOS\n\n#ifndef _CSBACKEND_PLATFORM_CORE_DIALOGUE_DIALOGUESYSTEM_H_\n#define _CSBACKEND_PLATFORM_CORE_DIALOGUE_DIALOGUESYSTEM_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <CSBackend/Platform/iOS/ForwardDeclarations.h>\n#include <ChilliSource/Core/DialogueBox/DialogueBoxSystem.h>\n\n@class DialogueBoxListener;\n\nnamespace CSBackend\n{\n\tnamespace iOS\n\t{\n\t\t//-----------------------------------------------------------\n\t\t/// A system used to display platform specific system\n        /// dialogue boxes.\n\t\t//-----------------------------------------------------------\n\t\tclass DialogueBoxSystem final : public ChilliSource::DialogueBoxSystem\n\t\t{\n\t\tpublic:\n            CS_DECLARE_NAMEDTYPE(DialogueBoxSystem);\n            //----------------------------------------------------\n            /// Is A\n            ///\n            /// @return Whether this implements the passed in\n            /// interface id.\n            //-----------------------------------------------------\n            bool IsA(ChilliSource::InterfaceIDType in_interfaceId) const override;\n            //-----------------------------------------------------\n            /// Display a system dialog with the given ID and delegate\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param ID\n            /// @param SystemConfirmDialogDelegate\n            /// @param Title text (UTF-8)\n            /// @param Message text (UTF-8)\n            /// @param Confirm text (UTF-8)\n            //------------------------------------------------------\n            void ShowSystemDialogue(u32 in_id, const ChilliSource::DialogueBoxSystem::DialogueDelegate& in_delegate, const std::string& in_title, const std::string& in_message, const std::string& in_confirm) override;\n            //-----------------------------------------------------\n            /// Display a system confirmation dialog with the given\n            /// ID and delegate.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param ID\n            /// @param SystemConfirmDialogDelegate\n            /// @param Title text (UTF-8)\n            /// @param Message text (UTF-8)\n            /// @param Confirm text (UTF-8)\n            /// @param Cancel text (UTF-8)\n            //-----------------------------------------------------\n            void ShowSystemConfirmDialogue(u32 in_id, const ChilliSource::DialogueBoxSystem::DialogueDelegate& in_delegate, const std::string& in_title, const std::string& in_message, const std::string& in_confirm, const std::string& in_cancel) override;\n            //-----------------------------------------------------\n            /// Display a toast notification with the given text\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param The text to display (UTF-8).\n            //-----------------------------------------------------\n            void MakeToast(const std::string& in_text) override;\n            //------------------------------------------------------\n            /// Triggered from a system dialog confirmation event\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param ID\n            /// @param Result\n            //------------------------------------------------------\n            void OnSystemConfirmDialogResult(u32 in_id, ChilliSource::DialogueBoxSystem::DialogueResult in_result);\n            //----------------------------------------------------\n\t\t\t/// Destructor.\n            ///\n            /// @author Ian Copland\n\t\t\t//----------------------------------------------------\n            ~DialogueBoxSystem();\n            \n        private:\n            \n            friend ChilliSource::DialogueBoxSystemUPtr ChilliSource::DialogueBoxSystem::Create();\n            //-------------------------------------------------------\n            /// Private constructor to force use of factory method\n            ///\n            /// @author Ian Copland\n            //-------------------------------------------------------\n            DialogueBoxSystem();\n        private:\n            \n\t\t\tChilliSource::DialogueBoxSystem::DialogueDelegate m_activeSysConfirmDelegate;\n            DialogueBoxListener* m_listener;\n\t\t};\n\t}\n}\n\n#endif\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/iOS/Core/DialogueBox/DialogueBoxSystem.mm",
    "content": "//\n//  DialogueBoxSystem.mm\n//  ChilliSource\n//  Created by Ian Copland on 04/03/2014\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_IOS\n\n#import <CSBackend/Platform/iOS/Core/DialogueBox/DialogueBoxSystem.h>\n\n#import <CSBackend/Platform/iOS/Core/DialogueBox/DialogueBoxListener.h>\n#import <CSBackend/Platform/iOS/Core/String/NSStringUtils.h>\n\n#import <ChilliSource/Core/Base/Application.h>\n#import <ChilliSource/Core/Base/PlatformSystem.h>\n#import <ChilliSource/Core/Threading/TaskScheduler.h>\n\n#import <UIKit/UIKit.h>\n\nnamespace CSBackend\n{\n\tnamespace iOS\n\t{\n        //TODO: Remove UIAlertView once we reach iOS 11 or 12\n        \n        CS_DEFINE_NAMEDTYPE(DialogueBoxSystem);\n        //----------------------------------------------------\n        //----------------------------------------------------\n        DialogueBoxSystem::DialogueBoxSystem()\n        {\n            if ([UIAlertController class] == nil)\n            {\n                m_listener = [[DialogueBoxListener alloc] initWithDialogueBoxSystem:this];\n            }\n            else\n            {\n                m_listener = nil;\n            }\n        }\n        //----------------------------------------------------\n        //----------------------------------------------------\n        bool DialogueBoxSystem::IsA(ChilliSource::InterfaceIDType in_interfaceID) const\n        {\n            return (DialogueBoxSystem::InterfaceID == in_interfaceID || ChilliSource::DialogueBoxSystem::InterfaceID == in_interfaceID);\n        }\n        //-----------------------------------------------------\n        //-----------------------------------------------------\n        void DialogueBoxSystem::ShowSystemDialogue(u32 in_id, const ChilliSource::DialogueBoxSystem::DialogueDelegate& in_delegate, const std::string& in_title, const std::string& in_message, const std::string& in_confirm)\n        {\n            CS_RELEASE_ASSERT(ChilliSource::Application::Get()->GetTaskScheduler()->IsMainThread(), \"System Dialogue requested outside of main thread.\");\n            \n            m_activeSysConfirmDelegate = in_delegate;\n            \n            ChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_system, [=](const ChilliSource::TaskContext& taskContext)\n            {\n                NSString* title = [NSStringUtils newNSStringWithUTF8String:in_title];\n                NSString* message = [NSStringUtils newNSStringWithUTF8String:in_message];\n                NSString* confirm = [NSStringUtils newNSStringWithUTF8String:in_confirm];\n                \n                //UIAlertController was only introduced in iOS 8\n                if ([UIAlertController class])\n                {\n                    //Create a new alert with a confirm action\n                    UIAlertController* alertController = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAlert];\n                    UIAlertAction* confirmAction = [UIAlertAction actionWithTitle:confirm style:UIAlertActionStyleDefault handler:^(UIAlertAction* action)\n                    {\n                        OnSystemConfirmDialogResult(in_id, ChilliSource::DialogueBoxSystem::DialogueResult::k_confirm);\n                    }];\n                    [alertController addAction:confirmAction];\n                    \n                    [[UIApplication sharedApplication].keyWindow.rootViewController presentViewController:alertController animated:YES completion:nil];\n                }\n                else\n                {\n                    UIAlertView* pConfirm = [[UIAlertView alloc] initWithTitle:title message:message delegate:m_listener cancelButtonTitle:confirm otherButtonTitles:nil];\n                    pConfirm.tag = in_id;\n                    [pConfirm show];\n                    [pConfirm release];\n                }\n                \n                [title release];\n                [message release];\n                [confirm release];\n            });\n        }\n        //-----------------------------------------------------\n        //-----------------------------------------------------\n        void DialogueBoxSystem::ShowSystemConfirmDialogue(u32 in_id, const ChilliSource::DialogueBoxSystem::DialogueDelegate& in_delegate, const std::string& in_title, const std::string& in_message, const std::string& in_confirm, const std::string& in_cancel)\n        {\n            CS_RELEASE_ASSERT(ChilliSource::Application::Get()->GetTaskScheduler()->IsMainThread(), \"System Confirm Dialogue requested outside of main thread.\");\n            \n            m_activeSysConfirmDelegate = in_delegate;\n            \n            ChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_system, [=](const ChilliSource::TaskContext& taskContext)\n            {\n                NSString* title = [NSStringUtils newNSStringWithUTF8String:in_title];\n                NSString* message = [NSStringUtils newNSStringWithUTF8String:in_message];\n                NSString* confirm = [NSStringUtils newNSStringWithUTF8String:in_confirm];\n                NSString* cancel = [NSStringUtils newNSStringWithUTF8String:in_cancel];\n                \n                //UIAlertController was only introduced in iOS 8\n                if ([UIAlertController class])\n                {\n                    //Create a new alert with a confirm and cancel actions\n                    UIAlertController* alertController = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAlert];\n                    \n                    UIAlertAction* confirmAction = [UIAlertAction actionWithTitle:confirm style:UIAlertActionStyleDefault handler:^(UIAlertAction* action)\n                    {\n                        OnSystemConfirmDialogResult(in_id, ChilliSource::DialogueBoxSystem::DialogueResult::k_confirm);\n                    }];\n                    \n                    UIAlertAction* cancelAction = [UIAlertAction actionWithTitle:cancel style:UIAlertActionStyleDefault handler:^(UIAlertAction* action)\n                    {\n                        OnSystemConfirmDialogResult(in_id, ChilliSource::DialogueBoxSystem::DialogueResult::k_cancel);\n                    }];\n                    \n                    //The order they are added is the order they appear\n                    [alertController addAction:cancelAction];\n                    [alertController addAction:confirmAction];\n                    \n                    [[UIApplication sharedApplication].keyWindow.rootViewController presentViewController:alertController animated:YES completion:nil];\n                }\n                else\n                {\n                    UIAlertView* pConfirm = [[UIAlertView alloc] initWithTitle:title message:message delegate:m_listener cancelButtonTitle:cancel otherButtonTitles:confirm, nil];\n                    pConfirm.tag = in_id;\n                    [pConfirm show];\n                    [pConfirm release];\n                }\n        \n                [title release];\n                [message release];\n                [confirm release];\n                [cancel release];\n            });\n        }\n        //-----------------------------------------------------\n        //-----------------------------------------------------\n        void DialogueBoxSystem::MakeToast(const std::string& in_text)\n        {\n            CS_LOG_WARNING(\"Dialogue Box System: Toast's are not supported on iOS.\");\n        }\n        //------------------------------------------------------\n        //------------------------------------------------------\n        void DialogueBoxSystem::OnSystemConfirmDialogResult(u32 in_id, ChilliSource::DialogueBoxSystem::DialogueResult in_result)\n        {\n            ChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_mainThread, [=](const ChilliSource::TaskContext& taskContext)\n            {\n                if(m_activeSysConfirmDelegate)\n                {\n                    u32 dialogueId = in_id;\n                    \n                    m_activeSysConfirmDelegate(dialogueId, in_result);\n                    m_activeSysConfirmDelegate = nullptr;\n                }\n            });\n        }\n        //-----------------------------------------------------\n        //-----------------------------------------------------\n        DialogueBoxSystem::~DialogueBoxSystem()\n        {\n            if(m_listener)\n            {\n                [m_listener release];\n            }\n        }\n\t}\n}\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/iOS/Core/File/FileSystem.h",
    "content": "//\n//  FileSystem.h\n//  ChilliSource\n//  Created by Ian Copland on 25/03/2011.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2011 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_IOS\n\n#ifndef _CSBACKEND_PLATFORM_IOS_CORE_FILE_FILESYSTEM_H_\n#define _CSBACKEND_PLATFORM_IOS_CORE_FILE_FILESYSTEM_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <CSBackend/Platform/iOS/ForwardDeclarations.h>\n#include <ChilliSource/Core/File/FileStream/BinaryInputStream.h>\n#include <ChilliSource/Core/File/FileStream/BinaryOutputStream.h>\n#include <ChilliSource/Core/File/FileStream/TextInputStream.h>\n#include <ChilliSource/Core/File/FileStream/TextOutputStream.h>\n#include <ChilliSource/Core/File/FileSystem.h>\n\n#include <string>\n\nnamespace CSBackend\n{\n\tnamespace iOS \n\t{\n\t\t//-------------------------------------------------------------------\n\t\t/// The iOS specific implementation for the File System.\n        ///\n        /// @author Ian Copland\n\t\t//-------------------------------------------------------------------\n\t\tclass FileSystem final : public ChilliSource::FileSystem\n\t\t{\n\t\tpublic:\n            CS_DECLARE_NAMEDTYPE(FileSystem);\n            //----------------------------------------------------------\n\t\t\t/// Queries whether or not this system implements the\n            /// interface with the given Id.\n            ///\n            /// @author Ian Copland\n\t\t\t///\n\t\t\t/// @param The interface Id.\n            ///\n\t\t\t/// @return Whether or not the interface is implemented.\n\t\t\t//----------------------------------------------------------\n\t\t\tbool IsA(ChilliSource::InterfaceIDType in_interfaceId) const override;\n            //------------------------------------------------------------------------------\n            /// Creates a new input text stream to the given file in the given storage location.\n            ///\n            /// @author HMcLaughlin\n            ///\n            /// @param in_storageLocation - The storage location.\n            /// @param in_filePath - The file path.\n            ///\n            /// @return The new file stream. If the stream cannot be created or is invalid,\n            /// null be returned.\n            //------------------------------------------------------------------------------\n            ChilliSource::ITextInputStreamUPtr CreateTextInputStream(ChilliSource::StorageLocation in_storageLocation, const std::string& in_filePath) const override;\n            //------------------------------------------------------------------------------\n            /// Creates a new input binary stream to the given file in the given storage location.\n            ///\n            /// @author HMcLaughlin\n            ///\n            /// @param in_storageLocation - The storage location.\n            /// @param in_filePath - The file path.\n            ///\n            /// @return The new file stream. If the stream cannot be created or is invalid,\n            /// null be returned.\n            //------------------------------------------------------------------------------\n            ChilliSource::IBinaryInputStreamUPtr CreateBinaryInputStream(ChilliSource::StorageLocation in_storageLocation, const std::string& in_filePath) const override;\n            //------------------------------------------------------------------------------\n            /// Creates a new output text stream to the given file in the given storage location.\n            ///\n            /// @author HMcLaughlin\n            ///\n            /// @param in_storageLocation - The storage location.\n            /// @param in_filePath - The file path.\n            ///\n            /// @return The new file stream. If the stream cannot be created or is invalid,\n            /// null be returned.\n            //------------------------------------------------------------------------------\n            ChilliSource::TextOutputStreamUPtr CreateTextOutputStream(ChilliSource::StorageLocation in_storageLocation, const std::string& in_filePath, ChilliSource::FileWriteMode in_fileMode) const override;\n            //------------------------------------------------------------------------------\n            /// Creates a new output binary stream to the given file in the given storage location.\n            ///\n            /// @author HMcLaughlin\n            ///\n            /// @param in_storageLocation - The storage location.\n            /// @param in_filePath - The file path.\n            ///\n            /// @return The new file stream. If the stream cannot be created or is invalid,\n            /// null be returned.\n            //------------------------------------------------------------------------------\n            ChilliSource::BinaryOutputStreamUPtr CreateBinaryOutputStream(ChilliSource::StorageLocation in_storageLocation, const std::string& in_filePath, ChilliSource::FileWriteMode in_fileMode) const override;\n            //--------------------------------------------------------------\n            /// Creates the given directory. The full directory hierarchy\n            /// will be created.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param The Storage Location\n            /// @param The directory path.\n            ///\n            /// @return Whether or not this was successful. Failure to\n            /// create the directory because it already exists is considered\n            /// a success.\n            //--------------------------------------------------------------\n            bool CreateDirectoryPath(ChilliSource::StorageLocation in_storageLocation, const std::string& in_directoryPath) const override;\n            //--------------------------------------------------------------\n            /// Copies a file from one location to another.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param The source storage location.\n            /// @param The source directory.\n            /// @param The destination storage location.\n            /// @param The destination directory.\n            ///\n            /// @return Whether or not the file was successfully copied.\n            //--------------------------------------------------------------\n            bool CopyFile(ChilliSource::StorageLocation in_sourceStorageLocation, const std::string& in_sourceFilePath,\n                          ChilliSource::StorageLocation in_destinationStorageLocation, const std::string& in_destinationFilePath) const override;\n            //--------------------------------------------------------------\n            /// Copies a directory from one location to another. If the\n            /// destination directory does not exist, it will be created.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param The source storage location.\n            /// @param The source directory.\n            /// @param The destination storage location.\n            /// @param The destination directory.\n            ///\n            /// @return Whether or not the files were successfully copied.\n            //--------------------------------------------------------------\n            bool CopyDirectory(ChilliSource::StorageLocation in_sourceStorageLocation, const std::string& in_sourceDirectoryPath,\n                               ChilliSource::StorageLocation in_destinationStorageLocation, const std::string& in_destinationDirectoryPath) const override;\n            //--------------------------------------------------------------\n            /// Deletes the specified file.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param The storage location.\n            /// @param The filepath.\n            ///\n            /// @return Whether or not the file was successfully deleted.\n            //--------------------------------------------------------------\n            bool DeleteFile(ChilliSource::StorageLocation in_storageLocation, const std::string& in_filepath) const override;\n            //--------------------------------------------------------------\n            /// Deletes a directory and all its contents.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param The storage location.\n            /// @param The directory.\n            ///\n            /// @return Whether or not the directory was successfully deleted.\n            //--------------------------------------------------------------\n            bool DeleteDirectory(ChilliSource::StorageLocation in_storageLocation, const std::string& in_directoryPath) const override;\n            //--------------------------------------------------------------\n            /// Creates a dynamic array containing the filenames of each file\n            /// in the given directory. File paths will be relative to the\n            /// input directory.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param The Storage Location\n            /// @param The directory\n            /// @param Flag to determine whether or not to recurse into sub\n            /// directories\n            ///\n            /// @return dynamic array containing the filenames.\n            //--------------------------------------------------------------\n            std::vector<std::string> GetFilePaths(ChilliSource::StorageLocation in_storageLocation, const std::string& in_directoryPath,  bool in_recursive) const override;\n            //--------------------------------------------------------------\n            /// Creates a dynamic array containing the names of each directory\n            /// in the given directory. Directory paths will be relative to\n            /// the input directory.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param The Storage Location\n            /// @param The directory\n            /// @param Flag to determine whether or not to recurse into sub\n            /// directories\n            ///\n            /// @return Output dynamic array containing the dir names.\n            //--------------------------------------------------------------\n            std::vector<std::string> GetDirectoryPaths(ChilliSource::StorageLocation in_storageLocation, const std::string& in_directoryPath,  bool in_recursive) const override;\n            //--------------------------------------------------------------\n            /// returns whether or not the given file exists.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param The Storage Location\n            /// @param The file path\n            ///\n            /// @return Whether or not it exists.\n            //--------------------------------------------------------------\n            bool DoesFileExist(ChilliSource::StorageLocation in_storageLocation, const std::string& in_filePath) const override;\n\t\t\t//--------------------------------------------------------------\n\t\t\t/// Returns whether or not the file exists in the Cached DLC\n            /// directory.\n            ///\n            /// @author Ian Copland\n\t\t\t///\n\t\t\t/// @param The file path.\n            ///\n\t\t\t/// @return Whether or not it is in the cached DLC.\n\t\t\t//--------------------------------------------------------------\n\t\t\tbool DoesFileExistInCachedDLC(const std::string& in_filePath) const override;\n\t\t\t//--------------------------------------------------------------\n\t\t\t/// Returns whether or not the file exists in the package DLC\n            /// directory.\n            ///\n            /// @author Ian Copland\n\t\t\t///\n\t\t\t/// @param The file path.\n            ///\n\t\t\t/// @return Whether or not it is in the package DLC.\n\t\t\t//--------------------------------------------------------------\n\t\t\tbool DoesFileExistInPackageDLC(const std::string& in_filePath) const override;\n            //--------------------------------------------------------------\n            /// Returns whether or not the given directory exists.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param The Storage Location\n            /// @param The directory path\n            ///\n            /// @return Whether or not it exists.\n            //--------------------------------------------------------------\n            bool DoesDirectoryExist(ChilliSource::StorageLocation in_storageLocation, const std::string& in_directoryPath) const override;\n            //--------------------------------------------------------------\n            /// Returns whether or not the directory exists in the Cached\n            /// DLC directory.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param in_directoryPath - The directory path.\n            ///\n            /// @return Whether or not it is in the cached DLC.\n            //--------------------------------------------------------------\n            bool DoesDirectoryExistInCachedDLC(const std::string& in_directoryPath) const override;\n            //--------------------------------------------------------------\n            /// Returns whether or not the directory exists in the package\n            /// DLC directory.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param in_directoryPath - The directory path.\n            ///\n            /// @return Whether or not it is in the package DLC.\n            //--------------------------------------------------------------\n            bool DoesDirectoryExistInPackageDLC(const std::string& in_directoryPath) const override;\n\t\t\t//--------------------------------------------------------------\n\t\t\t/// Returns the absolute path to the given storage location. The\n            /// value this returns is platform specific and use of this\n            /// should be kept to a minimum in cross platform projects.\n            ///\n            /// @author S Downie\n            ///\n\t\t\t/// @param The source storage location.\n            ///\n\t\t\t/// @return The directory. returns an empty string if the location\n\t\t\t/// is not available.\n\t\t\t//--------------------------------------------------------------\n\t\t\tstd::string GetAbsolutePathToStorageLocation(ChilliSource::StorageLocation in_storageLocation) const override;\n\n\t\tprivate:\n            friend ChilliSource::FileSystemUPtr ChilliSource::FileSystem::Create();\n            //--------------------------------------------------------------\n            /// A container for information on a single item in the package\n            /// manifest.\n            ///\n            /// @author Ian Copland\n            //--------------------------------------------------------------\n            struct PackageManifestItem\n            {\n                u32 m_pathHash;\n                bool m_isFile;\n            };\n            //--------------------------------------------------------------\n            /// Private constructor to force use of factory method\n            ///\n            /// @author S Downie\n            //--------------------------------------------------------------\n            FileSystem();\n            //--------------------------------------------------------------\n            /// Creates the manifest of all files and directories in the\n            /// package.\n            ///\n            /// @author S Downie\n            //--------------------------------------------------------------\n            void CreatePackageManifest();\n            //--------------------------------------------------------------\n\t        /// Tries to get an item from the package manifest for the given\n            /// path.\n\t        ///\n            /// @author Ian Copland\n            ///\n            /// @param The path to look up.\n\t        /// @param [Out] The manifest item if successful.\n\t        ///\n            /// @return Whether or not the look up was successful.\n            //--------------------------------------------------------------\n            bool TryGetPackageManifestItem(const std::string& in_path, PackageManifestItem& out_manifestItem) const;\n            //--------------------------------------------------------------\n\t\t\t/// Returns whether or not this given file path exist in the\n            /// package. This looks up the package manifest rather than\n            /// reading from disk.\n            ///\n            /// @author S Downie\n            ///\n            /// @param the filepath.\n            ///\n            /// @return whether or not it exists.\n\t\t\t//--------------------------------------------------------------\n            bool DoesFileExistInPackage(const std::string& in_filePath) const;\n            //--------------------------------------------------------------\n\t\t\t/// Returns whether or not this given directory path exist in the\n            /// package. This looks up the package manifest rather than\n            /// reading from disk.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param the directory path.\n            ///\n            /// @return whether or not it exists.\n\t\t\t//--------------------------------------------------------------\n            bool DoesDirectoryExistInPackage(const std::string& in_directoryPath) const;\n            //--------------------------------------------------------------\n\t\t\t/// Returns whether or not a file or directory exists specifically\n            /// in the DLC cache.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param The filepath.\n            ///\n            /// @return whether or not it exists.\n\t\t\t//--------------------------------------------------------------\n            bool DoesItemExistInDLCCache(const std::string& in_path, bool in_isDirectory) const;\n            //------------------------------------------------------------\n            /// Builds a list of the paths that the given path might refer\n\t\t\t/// to in the given storage location. For example, a path in\n\t\t\t/// DLC might refer to the DLC cache or the Package DLC.\n            ///\n            /// @author S Downie\n            ///\n            /// @param Storage location\n            /// @param File name to append\n            ///\n            /// @return All the paths for the given location\n            //------------------------------------------------------------\n            std::vector<std::string> GetPossibleAbsoluteDirectoryPaths(ChilliSource::StorageLocation in_storageLocation, const std::string& in_directoryPath) const;\n            \n            \n\t\t\tstd::string m_bundlePath;\n\t\t\tstd::string m_documentsPath;\n            std::string m_libraryPath;\n            \n            std::vector<PackageManifestItem> m_packageManifestItems;\n\t\t};\n\t}\n}\n\n#endif\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/iOS/Core/File/FileSystem.mm",
    "content": "//\n//  FileSystem.cpp\n//  ChilliSource\n//  Created by Ian Copland on 25/03/2011.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2011 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_IOS\n\n#import <CSBackend/Platform/iOS/Core/File/FileSystem.h>\n\n#import <CSBackend/Platform/iOS/Core/String/NSStringUtils.h>\n\n#import <ChilliSource/Core/String/StringUtils.h>\n\n#import <iostream>\n#import <UIKit/UIKit.h>\n#import <sys/types.h>\n#import <sys/sysctl.h>\n\nnamespace CSBackend\n{\n\tnamespace iOS \n\t{\n        namespace\n        {\n            const std::string k_saveDataPath  = \"SaveData/\";\n            const std::string k_cachePath  = \"Caches/Cache/\";\n            const std::string k_dlcPath  = \"Caches/DLC/\";\n            \n            //--------------------------------------------------------------\n            /// Returns a string containing the error in the given NSError.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @return The error string.\n            //--------------------------------------------------------------\n            std::string GetErrorString(NSError* in_error)\n            {\n                if (in_error != nil)\n                {\n                    return [NSStringUtils newUTF8StringWithNSString:[in_error localizedDescription]];\n                }\n                \n                return nil;\n            }\n            //--------------------------------------------------------------\n            /// @author S Downie\n            ///\n            /// @return The device bundle path as returned by iOS\n            //--------------------------------------------------------------\n            std::string RetrieveBundlePath()\n            {\n                CFBundleRef mainBundle = CFBundleGetMainBundle();\n                CFURLRef resourcesURL = CFBundleCopyResourcesDirectoryURL(mainBundle);\n                char path[PATH_MAX];\n                if (!CFURLGetFileSystemRepresentation(resourcesURL, TRUE, (UInt8 *)path, PATH_MAX))\n                {\n                    CS_LOG_ERROR(\"Changing working directory to resource folder\");\n                }\n                CFRelease(resourcesURL);\n                return std::string(path)  + \"/\";\n            }\n            //--------------------------------------------------------------\n            /// @author S Downie\n            ///\n            /// @return The device documents path as returned by iOS\n            //--------------------------------------------------------------\n            std::string RetrieveDocumentsPath()\n            {\n                NSArray* documentDir = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);\n                if (documentDir)\n                {\n                    NSString*\tnsDocumentPath = nil;\n                    nsDocumentPath = [documentDir objectAtIndex:0];\n                    if (nsDocumentPath != nil)\n                    {\n                        const char* pPath = [nsDocumentPath fileSystemRepresentation];\n                        return std::string(pPath) + \"/\";\n                    }\n                }\n                \n                return \"\";\n            }\n            //--------------------------------------------------------------\n            /// @author S Downie\n            ///\n            /// @return The device library path as returned by iOS\n            //--------------------------------------------------------------\n            std::string RetrieveLibraryPath()\n            {\n                NSArray* libraryDir = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES);\n                if (libraryDir)\n                {\n                    NSString*\tnsLibraryPath = nil;\n                    nsLibraryPath = [libraryDir objectAtIndex:0];\n                    if (nsLibraryPath != nil)\n                    {\n                        const char* pPath = [nsLibraryPath fileSystemRepresentation];\n                        return std::string(pPath) + \"/\";\n                    }\n                }\n                \n                return \"\";\n            }\n            //--------------------------------------------------------------\n            /// @author S Downie\n            ///\n            /// @param Unfiltered names\n            /// @return Filtered names\n            //--------------------------------------------------------------\n            NSArray* FilterPathsByFile(NSArray* in_fileNames)\n            {\n                //Filter out the files we don't want\n                NSString* Predicate = [NSString stringWithFormat:@\"self contains '.'\"];\n                NSArray* Filtered = [in_fileNames filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:Predicate]];\n                return Filtered;\n            }\n            //--------------------------------------------------------------\n            /// @author Ian Copland\n            ///\n            /// @param Unfiltered names\n            /// @return Filtered names\n            //--------------------------------------------------------------\n            NSArray* FilterPathsByDirectory(NSArray* in_fileNames)\n            {\n                //Filter out the files we don't want\n                NSString* Predicate = [NSString stringWithFormat:@\"not (self contains '.')\"];\n                NSArray* Filtered = [in_fileNames filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:Predicate]];\n                return Filtered;\n            }\n            //--------------------------------------------------------------\n            /// @author S Downie\n            ///\n            /// @param Filenames ObjC\n            ///\n            /// @return vector of file paths.\n            //--------------------------------------------------------------\n            std::vector<std::string> ConvertObjCToPath(NSArray* in_objFilePaths)\n            {\n                std::vector<std::string> output;\n                for(NSString* filePath in in_objFilePaths)\n                {\n                    output.push_back([NSStringUtils newUTF8StringWithNSString:filePath]);\n                }\n                return output;\n            }\n            //--------------------------------------------------------------\n\t\t\t/// returns whether the path exists on the filesystem\n            ///\n            /// @author S Downie\n            ///\n            /// @param the filepath.\n            ///\n            /// @return whether or not it exists.\n\t\t\t//--------------------------------------------------------------\n            bool DoesFileExist(const std::string& in_filePath)\n            {\n                bool fileExists = false;\n                \n                @autoreleasepool\n                {\n                    BOOL bDirectory = NO;\n                    bool bExists = false;\n                    \n                    NSFileManager *fileManager = [NSFileManager defaultManager];\n                    if ([fileManager fileExistsAtPath:[NSString stringWithUTF8String:in_filePath.c_str()] isDirectory:&bDirectory])\n                    {\n                        bExists = true;\n                    }\n                    \n                    fileExists = (bExists && !bDirectory);\n                }\n                \n                return fileExists;\n            }\n            //--------------------------------------------------------------\n\t\t\t/// returns whether the path exists on the filesystem\n            ///\n            /// @author S Downie\n            ///\n            /// @param the filepath.\n            ///\n            /// @return whether or not it exists.\n\t\t\t//--------------------------------------------------------------\n            bool DoesDirectoryExist(const std::string& in_directoryPath)\n            {\n                bool directoryExists = false;\n                \n                @autoreleasepool\n                {\n                    BOOL bDirectory = NO;\n                    bool bExists = false;\n                    \n                    NSFileManager *fileManager= [NSFileManager defaultManager];\n                    if ([fileManager fileExistsAtPath:[NSString stringWithUTF8String:in_directoryPath.c_str()] isDirectory:&bDirectory])\n                    {\n                        bExists = true;\n                    }\n                    \n                    directoryExists = (bExists && bDirectory);\n                }\n                \n                return directoryExists;\n            }\n            //------------------------------------------------------------\n            /// @author S Downie\n            ///\n            /// @param Directories\n            /// @param Recurse into sub directories\n            /// @param Out: Content file names\n            //------------------------------------------------------------\n            void GetDirectoryContents(const std::vector<std::string>& in_directoryPaths, bool in_recursive, NSMutableArray* out_contents)\n            {\n                @autoreleasepool\n                {\n                    for(std::vector<std::string>::const_iterator it = in_directoryPaths.begin(); it != in_directoryPaths.end(); ++it)\n                    {\n                        if (DoesDirectoryExist(*it) == true)\n                        {\n                            std::string path = ChilliSource::StringUtils::StandardiseDirectoryPath(*it);\n                            NSString* Dir = [NSString stringWithCString:path.c_str() encoding:NSASCIIStringEncoding];\n                            NSError* error = nil;\n                            \n                            if (in_recursive == true)\n                            {\n                                [out_contents addObjectsFromArray:[[NSFileManager defaultManager] subpathsOfDirectoryAtPath:Dir error:&error]];\n                            }\n                            else\n                            {\n                                [out_contents addObjectsFromArray:[[NSFileManager defaultManager] contentsOfDirectoryAtPath:Dir error:&error]];\n                            }\n                            \n                            if (error != nil)\n                            {\n                                CS_LOG_ERROR(\"File System: Failed to get contents of directory '\" + *it + \"' - \" + GetErrorString(error));\n                                return;\n                            }\n                        }\n                    }\n                }\n            }\n        }\n        \n        CS_DEFINE_NAMEDTYPE(FileSystem);\n        //--------------------------------------------------------------\n        //--------------------------------------------------------------\n\t\tFileSystem::FileSystem()\n\t\t{\n            m_bundlePath = RetrieveBundlePath();\n            m_documentsPath = RetrieveDocumentsPath();\n            m_libraryPath = RetrieveLibraryPath();\n            \n            CreateDirectoryPath(ChilliSource::StorageLocation::k_saveData, \"\");\n            CreateDirectoryPath(ChilliSource::StorageLocation::k_cache, \"\");\n            CreateDirectoryPath(ChilliSource::StorageLocation::k_DLC, \"\");\n            \n            CreatePackageManifest();\n\t\t}\n        //----------------------------------------------------------\n        //----------------------------------------------------------\n        bool FileSystem::IsA(ChilliSource::InterfaceIDType in_interfaceId) const\n        {\n            return (ChilliSource::FileSystem::InterfaceID == in_interfaceId || FileSystem::InterfaceID == in_interfaceId);\n        }\n        //--------------------------------------------------------------\n        //--------------------------------------------------------------\n        ChilliSource::ITextInputStreamUPtr FileSystem::CreateTextInputStream(ChilliSource::StorageLocation in_storageLocation, const std::string& in_filePath) const\n        {\n            std::string absFilePath = \"\";\n            if (in_storageLocation == ChilliSource::StorageLocation::k_DLC && DoesFileExistInCachedDLC(in_filePath) == false)\n            {\n                absFilePath = GetAbsolutePathToStorageLocation(ChilliSource::StorageLocation::k_package) + GetPackageDLCPath() + in_filePath;\n            }\n            else\n            {\n                absFilePath = GetAbsolutePathToStorageLocation(in_storageLocation) + in_filePath;\n            }\n            \n            ChilliSource::ITextInputStreamUPtr output(new ChilliSource::TextInputStream(absFilePath));\n            if (output->IsValid() == true)\n            {\n                return output;\n            }\n            else\n            {\n                return nullptr;\n            }\n        }\n        //--------------------------------------------------------------\n        //--------------------------------------------------------------\n        ChilliSource::IBinaryInputStreamUPtr FileSystem::CreateBinaryInputStream(ChilliSource::StorageLocation in_storageLocation, const std::string& in_filePath) const\n        {\n            std::string absFilePath = \"\";\n            if (in_storageLocation == ChilliSource::StorageLocation::k_DLC && DoesFileExistInCachedDLC(in_filePath) == false)\n            {\n                absFilePath = GetAbsolutePathToStorageLocation(ChilliSource::StorageLocation::k_package) + GetPackageDLCPath() + in_filePath;\n            }\n            else\n            {\n                absFilePath = GetAbsolutePathToStorageLocation(in_storageLocation) + in_filePath;\n            }\n            \n            ChilliSource::IBinaryInputStreamUPtr output(new ChilliSource::BinaryInputStream(absFilePath));\n            if (output->IsValid() == true)\n            {\n                return output;\n            }\n            else\n            {\n                return nullptr;\n            }\n        }\n        //--------------------------------------------------------------\n        //--------------------------------------------------------------\n        ChilliSource::TextOutputStreamUPtr FileSystem::CreateTextOutputStream(ChilliSource::StorageLocation in_storageLocation, const std::string& in_filePath, ChilliSource::FileWriteMode in_fileMode) const\n        {\n            CS_ASSERT(IsStorageLocationWritable(in_storageLocation), \"File System: Trying to write to read only storage location.\");\n            \n            if(IsStorageLocationWritable(in_storageLocation))\n            {\n                std::string absFilePath = GetAbsolutePathToStorageLocation(in_storageLocation) + in_filePath;\n                \n                ChilliSource::TextOutputStreamUPtr output(new ChilliSource::TextOutputStream(absFilePath, in_fileMode));\n                if (output->IsValid() == true)\n                {\n                    return output;\n                }\n            }\n            \n            return nullptr;\n        }\n        //--------------------------------------------------------------\n        //--------------------------------------------------------------\n        ChilliSource::BinaryOutputStreamUPtr FileSystem::CreateBinaryOutputStream(ChilliSource::StorageLocation in_storageLocation, const std::string& in_filePath, ChilliSource::FileWriteMode in_fileMode) const\n        {\n            CS_ASSERT(IsStorageLocationWritable(in_storageLocation), \"File System: Trying to write to read only storage location.\");\n            \n            if(IsStorageLocationWritable(in_storageLocation))\n            {\n                std::string absFilePath = GetAbsolutePathToStorageLocation(in_storageLocation) + in_filePath;\n                \n                ChilliSource::BinaryOutputStreamUPtr output(new ChilliSource::BinaryOutputStream(absFilePath, in_fileMode));\n                if (output->IsValid() == true)\n                {\n                    return output;\n                }\n            }\n            \n            return nullptr;\n        }\n        //--------------------------------------------------------------\n        //--------------------------------------------------------------\n        bool FileSystem::CreateDirectoryPath(ChilliSource::StorageLocation in_storageLocation, const std::string& in_directoryPath) const\n        {\n            CS_ASSERT(IsStorageLocationWritable(in_storageLocation), \"File System: Trying to write to read only storage location.\");\n            \n            @autoreleasepool\n            {\n                //create the directory\n                std::string path = GetAbsolutePathToStorageLocation(in_storageLocation) + in_directoryPath;\n                NSFileManager* fileManager = [NSFileManager defaultManager];\n                NSError* error = nil;\n                if (![fileManager fileExistsAtPath:[NSString stringWithUTF8String:path.c_str()]])\n                {\n                    if (![fileManager createDirectoryAtPath:[NSString stringWithUTF8String:path.c_str()] withIntermediateDirectories:YES attributes:nil error:&error])\n                    {\n                        CS_LOG_ERROR(\"File System: Error creating directory '\" + in_directoryPath + \"' - \" + GetErrorString(error));\n                        return false;\n                    }\n                }\n            }\n            \n\t\t\treturn true;\n        }\n        //--------------------------------------------------------------\n        //--------------------------------------------------------------\n        bool FileSystem::CopyFile(ChilliSource::StorageLocation in_sourceStorageLocation, const std::string& in_sourceFilePath,\n                                   ChilliSource::StorageLocation in_destinationStorageLocation, const std::string& in_destinationFilePath) const\n        {\n            CS_ASSERT(IsStorageLocationWritable(in_destinationStorageLocation), \"File System: Trying to write to read only storage location.\");\n            \n            @autoreleasepool\n            {\n                std::string sourcePath;\n                if (in_sourceStorageLocation == ChilliSource::StorageLocation::k_DLC && DoesFileExistInCachedDLC(in_sourceFilePath) == false)\n                {\n                    sourcePath = GetAbsolutePathToStorageLocation(ChilliSource::StorageLocation::k_package) + GetPackageDLCPath() + ChilliSource::StringUtils::StandardiseFilePath(in_sourceFilePath);\n                }\n                else\n                {\n                    sourcePath = GetAbsolutePathToStorageLocation(in_sourceStorageLocation) + ChilliSource::StringUtils::StandardiseFilePath(in_sourceFilePath);\n                }\n                \n                if(CSBackend::iOS::DoesFileExist(sourcePath) == false)\n                {\n                    CS_LOG_ERROR(\"File System: Trying to copy file '\" + in_sourceFilePath + \"' but it does not exist.\");\n                    return false;\n                }\n                \n                //get the path to the file\n                std::string destinationFileName, destinationDirectoryPath;\n                ChilliSource::StringUtils::SplitFilename(in_destinationFilePath, destinationFileName, destinationDirectoryPath);\n                \n                //create the output directory\n                CreateDirectoryPath(in_destinationStorageLocation, destinationDirectoryPath);\n                \n                std::string destinationPath = GetAbsolutePathToStorageLocation(in_destinationStorageLocation) + in_destinationFilePath;\n                std::string atomicDestinationPath = destinationPath + \".tmp\";\n                \n                NSString* nsSourcePath = [NSString stringWithUTF8String:sourcePath.c_str()];\n                NSString* nsAtomicDestinationPath = [NSString stringWithUTF8String:atomicDestinationPath.c_str()];\n                \n                NSError* pCopyError = nil;\n                [[NSFileManager defaultManager] copyItemAtPath:nsSourcePath toPath:nsAtomicDestinationPath error:&pCopyError];\n                if (pCopyError != nil)\n                {\n                    CS_LOG_ERROR(\"File System: Failed to copy file '\" + in_sourceFilePath + \"' - \" + GetErrorString(pCopyError));\n                    return false;\n                }\n\n                NSString* nsDestinationURLPath = [NSString stringWithUTF8String:(\"file://\" + destinationPath).c_str()];\n                NSString* nsAtomicDestinationURLPath = [NSString stringWithUTF8String:(\"file://\" + atomicDestinationPath).c_str()];\n                NSURL* destinationURL = [NSURL URLWithString:[nsDestinationURLPath stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];\n                NSURL* atomicDestinationURL = [NSURL URLWithString:[nsAtomicDestinationURLPath stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];\n                \n                NSError* pReplaceError = nil;\n                [[NSFileManager defaultManager] replaceItemAtURL:destinationURL withItemAtURL:atomicDestinationURL backupItemName:nil options:NSFileManagerItemReplacementUsingNewMetadataOnly resultingItemURL:nil error:&pReplaceError];\n                if (pReplaceError != nil)\n                {\n                    CS_LOG_ERROR(\"File System: Failed to copy file '\" + in_sourceFilePath + \"' - \" + GetErrorString(pReplaceError));\n                    return false;\n                }\n            }\n            \n            return true;\n        }\n        //--------------------------------------------------------------\n        //--------------------------------------------------------------\n        bool FileSystem::CopyDirectory(ChilliSource::StorageLocation in_sourceStorageLocation, const std::string& in_sourceDirectoryPath,\n                                        ChilliSource::StorageLocation in_destinationStorageLocation, const std::string& in_destinationDirectoryPath) const\n        {\n            CS_ASSERT(IsStorageLocationWritable(in_destinationStorageLocation), \"File System: Trying to write to read only storage location.\");\n            \n            if (DoesDirectoryExist(in_sourceStorageLocation, in_sourceDirectoryPath) == false)\n\t\t\t{\n\t\t\t\tCS_LOG_ERROR(\"File System: Trying to copy directory '\" + in_sourceDirectoryPath + \"' but it doesn't exist.\");\n\t\t\t\treturn false;\n\t\t\t}\n\n            //get all the files in the directory\n            std::vector<std::string> astrFilenames = GetFilePaths(in_sourceStorageLocation, in_sourceDirectoryPath, true);\n            \n            //error if there are no files\n            if (astrFilenames.size() == 0)\n            {\n                CreateDirectoryPath(in_destinationStorageLocation, in_destinationDirectoryPath);\n            }\n            else\n            {\n                //copy each of these files individually\n                std::string sourcePath = ChilliSource::StringUtils::StandardiseDirectoryPath(in_sourceDirectoryPath);\n                std::string destPath = ChilliSource::StringUtils::StandardiseDirectoryPath(in_destinationDirectoryPath);\n                for (std::vector<std::string>::iterator it = astrFilenames.begin(); it != astrFilenames.end(); ++it)\n                {\n                    if (CopyFile(in_sourceStorageLocation, sourcePath + *it, in_destinationStorageLocation, destPath + *it) == false)\n                    {\n                        return false;\n                    }\n                }\n            }\n            \n            return true;\n        }\n        //--------------------------------------------------------------\n        //--------------------------------------------------------------\n        bool FileSystem::DeleteFile(ChilliSource::StorageLocation in_storageLocation, const std::string& in_filePath) const\n        {\n            CS_ASSERT(IsStorageLocationWritable(in_storageLocation), \"File System: Trying to delete from a read only storage location.\");\n            \n            @autoreleasepool\n            {\n                //get the filepath\n                std::string path = GetAbsolutePathToStorageLocation(in_storageLocation) + in_filePath;\n                \n                NSError* error = nil;\n                \n                NSString* nsPath = [NSStringUtils newNSStringWithUTF8String:path];\n                [[NSFileManager defaultManager] removeItemAtPath:nsPath error:&error];\n                [nsPath release];\n                \n                if (error != nil)\n                {\n                    return false;\n                }\n            }\n            \n            //return successful\n            return true;\n        }\n        //--------------------------------------------------------------\n        //--------------------------------------------------------------\n        bool FileSystem::DeleteDirectory(ChilliSource::StorageLocation in_storageLocation, const std::string& in_directoryPath) const\n        {\n            CS_ASSERT(IsStorageLocationWritable(in_storageLocation), \"File System: Trying to delete from a read only storage location.\");\n            \n            @autoreleasepool\n            {\n                std::string directoryPath = GetAbsolutePathToStorageLocation(in_storageLocation) + in_directoryPath;\n                \n                NSError* error = nil;\n                \n                NSString* nsPath = [NSStringUtils newNSStringWithUTF8String:directoryPath];\n                [[NSFileManager defaultManager] removeItemAtPath:nsPath error:&error];\n                [nsPath release];\n                \n                if (error != nil)\n                {\n                    return false;\n                }\n            }\n            \n            return true;\n        }\n        //--------------------------------------------------------------\n        //--------------------------------------------------------------\n        std::vector<std::string> FileSystem::GetFilePaths(ChilliSource::StorageLocation in_storageLocation, const std::string& in_directoryPath, bool in_recursive) const\n        {\n            std::vector<std::string> output;\n            \n            @autoreleasepool\n            {\n                std::vector<std::string> astrDirectoriesToCheck = GetPossibleAbsoluteDirectoryPaths(in_storageLocation, in_directoryPath);\n                \n                NSMutableArray* Contents = [NSMutableArray array];\n                \n                GetDirectoryContents(astrDirectoriesToCheck, in_recursive, Contents);\n                \n                if([Contents count] > 0)\n                {\n                    NSArray* Filtered = FilterPathsByFile(Contents);\n                    output = ConvertObjCToPath(Filtered);\n                }\n                \n                std::sort(output.begin(), output.end());\n                std::vector<std::string>::iterator it = std::unique(output.begin(), output.end());\n                output.resize(it - output.begin());\n                \n                for (auto& filePath : output)\n                {\n                    filePath = ChilliSource::StringUtils::StandardiseFilePath(filePath);\n                }\n            }\n            \n            return output;\n        }\n        //--------------------------------------------------------------\n        //--------------------------------------------------------------\n        std::vector<std::string> FileSystem::GetDirectoryPaths(ChilliSource::StorageLocation in_storageLocation, const std::string& in_directoryPath, bool in_recursive) const\n        {\n            std::vector<std::string> output;\n            \n            @autoreleasepool\n            {\n                std::vector<std::string> astrDirectoriesToCheck = GetPossibleAbsoluteDirectoryPaths(in_storageLocation, in_directoryPath);\n                \n                NSMutableArray* Contents = [NSMutableArray array];\n                \n                GetDirectoryContents(astrDirectoriesToCheck, in_recursive, Contents);\n                \n                if([Contents count] > 0)\n                {\n                    NSArray* Filtered = FilterPathsByDirectory(Contents);\n                    output = ConvertObjCToPath(Filtered);\n                }\n                \n                std::sort(output.begin(), output.end());\n                std::vector<std::string>::iterator it = std::unique(output.begin(), output.end());\n                output.resize(it - output.begin());\n                \n                for (auto& directoryPath : output)\n                {\n                    directoryPath = ChilliSource::StringUtils::StandardiseDirectoryPath(directoryPath);\n                }\n            }\n            \n            return output;\n        }\n        //--------------------------------------------------------------\n        //--------------------------------------------------------------\n        bool FileSystem::DoesFileExist(ChilliSource::StorageLocation in_storageLocation, const std::string& in_filePath) const\n        {\n            if(in_storageLocation == ChilliSource::StorageLocation::k_package)\n            {\n                if(DoesFileExistInPackage(in_filePath))\n                {\n                    return true;\n                }\n                \n                return false;\n            }\n            \n            //get the filepath\n            std::string path = GetAbsolutePathToStorageLocation(in_storageLocation) + in_filePath;\n            \n            //if its a DLC stream, make sure that it exists in the DLC cache, if not fall back on the package\n            if (in_storageLocation == ChilliSource::StorageLocation::k_DLC)\n            {\n                if (DoesItemExistInDLCCache(in_filePath, false) == true)\n                {\n                    return true;\n                }\n                \n                return DoesFileExist(ChilliSource::StorageLocation::k_package, GetPackageDLCPath() + in_filePath);\n            }\n            \n            //return whether or not the file exists\n\t\t\treturn CSBackend::iOS::DoesFileExist(ChilliSource::StringUtils::StandardiseFilePath(path));\n        }\n        //--------------------------------------------------------------\n        //--------------------------------------------------------------\n        bool FileSystem::DoesFileExistInCachedDLC(const std::string& in_filePath) const\n        {\n            return DoesItemExistInDLCCache(in_filePath, false);\n        }\n        //--------------------------------------------------------------\n        //--------------------------------------------------------------\n        bool FileSystem::DoesFileExistInPackageDLC(const std::string& in_filePath) const\n        {\n            return DoesFileExist(ChilliSource::StorageLocation::k_package, GetPackageDLCPath() + in_filePath);\n        }\n        //--------------------------------------------------------------\n        //--------------------------------------------------------------\n        bool FileSystem::DoesDirectoryExist(ChilliSource::StorageLocation in_storageLocation, const std::string& in_directoryPath) const\n        {\n            if(in_storageLocation == ChilliSource::StorageLocation::k_package)\n            {\n                if(DoesDirectoryExistInPackage(in_directoryPath))\n                {\n                    return true;\n                }\n                \n                return false;\n            }\n            \n            //get the filepath\n            std::string path = GetAbsolutePathToStorageLocation(in_storageLocation) + in_directoryPath;\n            \n            //if its a DLC stream, make sure that it exists in the DLC cache, if not fall back on the package\n            if (in_storageLocation == ChilliSource::StorageLocation::k_DLC)\n            {\n                if (DoesItemExistInDLCCache(in_directoryPath, true) == true)\n                {\n                    return true;\n                }\n                \n                return DoesDirectoryExist(ChilliSource::StorageLocation::k_package, GetPackageDLCPath() + in_directoryPath);\n            }\n            \n            //return whether or not the dir exists\n\t\t\treturn CSBackend::iOS::DoesDirectoryExist(ChilliSource::StringUtils::StandardiseDirectoryPath(path));\n        }\n        //--------------------------------------------------------------\n        //--------------------------------------------------------------\n        bool FileSystem::DoesDirectoryExistInCachedDLC(const std::string& in_directoryPath) const\n        {\n            return DoesItemExistInDLCCache(in_directoryPath, true);\n        }\n        //--------------------------------------------------------------\n        //--------------------------------------------------------------\n        bool FileSystem::DoesDirectoryExistInPackageDLC(const std::string& in_directoryPath) const\n        {\n            return DoesDirectoryExist(ChilliSource::StorageLocation::k_package, GetPackageDLCPath() + in_directoryPath);\n        }\n        //--------------------------------------------------------------\n        //--------------------------------------------------------------\n        std::string FileSystem::GetAbsolutePathToStorageLocation(ChilliSource::StorageLocation in_storageLocation) const\n        {\n            //get the storage location path\n            std::string strStorageLocationPath;\n            switch (in_storageLocation)\n            {\n                case ChilliSource::StorageLocation::k_package:\n                    strStorageLocationPath = m_bundlePath + \"AppResources/\";\n                    break;\n                case ChilliSource::StorageLocation::k_chilliSource:\n                    strStorageLocationPath = m_bundlePath + \"CSResources/\";\n                    break;\n                case ChilliSource::StorageLocation::k_saveData:\n                    strStorageLocationPath = m_documentsPath + k_saveDataPath;\n                    break;\n                case ChilliSource::StorageLocation::k_cache:\n                    strStorageLocationPath = m_libraryPath + k_cachePath;\n                    break;\n                case ChilliSource::StorageLocation::k_DLC:\n                    strStorageLocationPath = m_libraryPath + k_dlcPath;\n                    break;\n                default:\n                    CS_LOG_ERROR(\"Storage Location not available on this platform!\");\n                    break;\n            }\n            \n            return strStorageLocationPath;\n        }\n        //--------------------------------------------------------------\n        //--------------------------------------------------------------\n        void FileSystem::CreatePackageManifest()\n        {\n            @autoreleasepool\n            {\n                NSMutableArray* contents = [NSMutableArray array];\n                NSString* directory = [NSStringUtils newNSStringWithUTF8String:m_bundlePath + \"AppResources/\"];\n                \n                NSError* error = nil;\n                [contents addObjectsFromArray:[[NSFileManager defaultManager] subpathsOfDirectoryAtPath:directory error:&error]];\n                if (error != nil)\n                {\n                    CS_LOG_FATAL(\"File System: Failed to create package manfest - \" + GetErrorString(error));\n                }\n                \n                for(NSString* nsPath in contents)\n                {\n                    BOOL isDirectory = NO;\n                    NSFileManager* fileManager = [NSFileManager defaultManager];\n                    NSString* nsFullPath = [NSString stringWithFormat:@\"%@%@\", directory, nsPath];\n                    \n                    if ([fileManager fileExistsAtPath:nsFullPath isDirectory:&isDirectory] == true)\n                    {\n                        std::string path([nsPath UTF8String]);\n                        PackageManifestItem item;\n                        if(isDirectory == NO)\n                        {\n                            item.m_pathHash = ChilliSource::HashCRC32::GenerateHashCode(ChilliSource::StringUtils::StandardiseFilePath(path));\n                        }\n                        else\n                        {\n                            item.m_pathHash = ChilliSource::HashCRC32::GenerateHashCode(ChilliSource::StringUtils::StandardiseDirectoryPath(path));\n                        }\n                        item.m_isFile = (isDirectory == NO);\n                        m_packageManifestItems.push_back(item);\n                    }\n                }\n                \n                std::sort(m_packageManifestItems.begin(), m_packageManifestItems.end(), [](const FileSystem::PackageManifestItem& in_lhs, const FileSystem::PackageManifestItem& in_rhs)\n                {\n                    return in_lhs.m_pathHash < in_rhs.m_pathHash;\n                });\n                \n                [directory release];\n            }\n        }\n        //--------------------------------------------------------------\n        //--------------------------------------------------------------\n        bool FileSystem::TryGetPackageManifestItem(const std::string& in_path, PackageManifestItem& out_manifestItem) const\n        {\n            PackageManifestItem searchItem;\n\t\t\tsearchItem.m_pathHash = ChilliSource::HashCRC32::GenerateHashCode(in_path);\n            \n\t\t\tauto it = std::lower_bound(m_packageManifestItems.begin(), m_packageManifestItems.end(), searchItem, [](const FileSystem::PackageManifestItem& in_lhs, const FileSystem::PackageManifestItem& in_rhs)\n            {\n                return in_lhs.m_pathHash < in_rhs.m_pathHash;\n            });\n            \n\t\t\tif(it !=  m_packageManifestItems.end() && it->m_pathHash == searchItem.m_pathHash)\n\t\t\t{\n\t\t\t\tout_manifestItem = *it;\n\t\t\t\treturn true;\n\t\t\t}\n            \n\t\t\treturn false;\n        }\n        //--------------------------------------------------------------\n        //--------------------------------------------------------------\n        bool FileSystem::DoesFileExistInPackage(const std::string& in_filePath) const\n        {\n            PackageManifestItem item;\n            if (TryGetPackageManifestItem(ChilliSource::StringUtils::StandardiseFilePath(in_filePath), item) == true)\n            {\n                if (item.m_isFile == true)\n                {\n                    return true;\n                }\n            }\n            \n            return false;\n        }\n        //--------------------------------------------------------------\n        //--------------------------------------------------------------\n        bool FileSystem::DoesDirectoryExistInPackage(const std::string& in_directoryPath) const\n        {\n            PackageManifestItem item;\n            if (TryGetPackageManifestItem(ChilliSource::StringUtils::StandardiseDirectoryPath(in_directoryPath), item) == true)\n            {\n                if (item.m_isFile == false)\n                {\n                    return true;\n                }\n            }\n            \n            return false;\n        }\n        //--------------------------------------------------------------\n        //--------------------------------------------------------------\n        bool FileSystem::DoesItemExistInDLCCache(const std::string& in_path, bool in_isDirectory) const\n        {\n            if(in_isDirectory == true)\n            {\n                return CSBackend::iOS::DoesDirectoryExist(ChilliSource::StringUtils::StandardiseFilePath(GetAbsolutePathToStorageLocation(ChilliSource::StorageLocation::k_DLC) + in_path));\n            }\n            else\n            {\n                return CSBackend::iOS::DoesFileExist(ChilliSource::StringUtils::StandardiseFilePath(GetAbsolutePathToStorageLocation(ChilliSource::StorageLocation::k_DLC) + in_path));\n            }\n        }\n        //--------------------------------------------------------------\n        //--------------------------------------------------------------\n        std::vector<std::string> FileSystem::GetPossibleAbsoluteDirectoryPaths(ChilliSource::StorageLocation in_storageLocation, const std::string& in_directoryPath) const\n        {\n            std::vector<std::string> output;\n            switch(in_storageLocation)\n            {\n                case ChilliSource::StorageLocation::k_package:\n                {\n                    output.push_back(GetAbsolutePathToStorageLocation(in_storageLocation) + in_directoryPath);\n                    break;\n                }\n                case ChilliSource::StorageLocation::k_DLC:\n                {\n                    output.push_back(GetAbsolutePathToStorageLocation(ChilliSource::StorageLocation::k_package) + GetPackageDLCPath() + in_directoryPath);\n                    output.push_back(GetAbsolutePathToStorageLocation(ChilliSource::StorageLocation::k_DLC) + in_directoryPath);\n                    break;\n                }\n                default:\n                {\n                    output.push_back(GetAbsolutePathToStorageLocation(in_storageLocation) + in_directoryPath);\n                    break;\n                }\n            }\n            return output;\n        }\n\t}\n}\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/iOS/Core/Image/PNGImageProvider.cpp",
    "content": "//\n//  PNGImageProvider.cpp\n//  ChilliSource\n//  Created by S McGaw on 01/10/2010.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2010 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_IOS\n\n#include <CSBackend/Platform/iOS/Core/Image/PNGImageProvider.h>\n\n#include <CSBackend/Platform/iOS/Core/File/FileSystem.h>\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/Image/Image.h>\n#include <ChilliSource/Core/Image/ImageCompression.h>\n#include <ChilliSource/Core/Image/ImageFormat.h>\n#include <ChilliSource/Core/Threading/TaskScheduler.h>\n\n#import <UIKit/UIKit.h>\n\nnamespace CSBackend\n{\n\tnamespace iOS\n\t{\n        namespace\n        {\n            const std::string k_pngExtension(\"png\");\n            \n            //-----------------------------------------------------------\n            /// Create a PNG image using the Apple API\n            ///\n            /// @author S McGaw\n            ///\n            /// @param Image data in bytes\n\t\t\t/// @param Size of data in bytes\n\t\t\t/// @param Whether the asset is high res\n\t\t\t/// @param Image format\n\t\t\t/// @param [Out] Image resource\n            //-----------------------------------------------------------\n            void CreatePNGImageFromFile(const s8* in_data, u32 in_dataSize, ChilliSource::Image* out_image)\n            {\n                CFDataRef pData = CFDataCreateWithBytesNoCopy(nullptr, (u8*)in_data, in_dataSize, kCFAllocatorNull);\n                CGDataProviderRef imgDataProvider = CGDataProviderCreateWithCFData(pData);\n                CGImageRef cgImage = CGImageCreateWithPNGDataProvider(imgDataProvider, nullptr, true, kCGRenderingIntentDefault);\n                \n                // Get the width and height of the image.\n                u32 udwWidth = static_cast<u32>(CGImageGetWidth(cgImage));\n                u32 udwHeight = static_cast<u32>(CGImageGetHeight(cgImage));\n                u32 udwBitsPerComponent = static_cast<u32>(CGImageGetBitsPerComponent(cgImage));\n                u32 udwBytesPerPixel = (udwBitsPerComponent * 4)/8;\n                u32 udwArea = udwWidth * udwHeight;\n                \n                //Check if the image has alpha\n                CGImageAlphaInfo AlphaInfo = CGImageGetAlphaInfo(cgImage);\n                \n                bool bHasAlpha = ((AlphaInfo == kCGImageAlphaPremultipliedLast) || (AlphaInfo == kCGImageAlphaPremultipliedFirst) || (AlphaInfo == kCGImageAlphaLast) || (AlphaInfo == kCGImageAlphaFirst));\n                \n                AlphaInfo = (bHasAlpha ? kCGImageAlphaPremultipliedLast : kCGImageAlphaNoneSkipLast);\n                \n                // Grab image's color format\n                CGColorSpaceRef ColorSpaceInfo = CGImageGetColorSpace(cgImage);\n                \n                // Retain here as we may need to create one and release later\n                CGColorSpaceRetain(ColorSpaceInfo);\n                \n                // Special case for GreyScale images\n                ChilliSource::ImageFormat format = ChilliSource::ImageFormat::k_RGBA8888;\n                if(CGColorSpaceGetModel(ColorSpaceInfo) == kCGColorSpaceModelMonochrome)\n                {\n                    if(bHasAlpha)\n                    {\n                        format = ChilliSource::ImageFormat::k_LumA88;\n                        ColorSpaceInfo = CGColorSpaceCreateDeviceRGB();\n                    }\n                    else\n                    {\n                        format = ChilliSource::ImageFormat::k_Lum8;\n                        ColorSpaceInfo = CGColorSpaceCreateDeviceRGB();\n                    }\n                }\n                \n                // Allocated memory needed for the bitmap context\n                u32 dataSize = udwArea * udwBytesPerPixel;\n                u8* pubyBitmapData8888 = new u8[dataSize];\n                memset(pubyBitmapData8888, 0, dataSize);\n\n                // Uses the bitmatp creation function provided by the Core Graphics framework.\n                CGContextRef bitmapContext = CGBitmapContextCreate(pubyBitmapData8888, udwWidth, udwHeight, udwBitsPerComponent, udwWidth * udwBytesPerPixel, ColorSpaceInfo, AlphaInfo);\n                \n                // After you create the context, you can draw the sprite image to the context.\n                CGContextDrawImage(bitmapContext, CGRectMake(0.0f, 0.0f, (CGFloat)udwWidth, (CGFloat)udwHeight), cgImage);\n                CGImageRelease(cgImage);\n                \n                // You don't need the context at this point, so you need to release it to avoid memory leaks.\n                CGContextRelease(bitmapContext);\n                \n                CGColorSpaceRelease(ColorSpaceInfo);\n                CGDataProviderRelease(imgDataProvider);\n                CFRelease(pData);\n\n                ChilliSource::Image::Descriptor desc;\n                desc.m_compression = ChilliSource::ImageCompression::k_none;\n                desc.m_format = format;\n                desc.m_width = udwWidth;\n                desc.m_height = udwHeight;\n                desc.m_dataSize = dataSize;\n                out_image->Build(desc, ChilliSource::Image::ImageDataUPtr(pubyBitmapData8888));\n            }\n            //-----------------------------------------------------------\n            /// Performs the heavy lifting for the 2 create methods\n            ///\n            /// @author S Downie\n            ///\n            /// @param The storage location.\n            /// @param The filepath.\n            /// @param Completion delegate\n            /// @param [Out] The output resource\n            //-----------------------------------------------------------\n            void LoadImage(ChilliSource::StorageLocation in_storageLocation, const std::string& in_filePath, const ChilliSource::ResourceProvider::AsyncLoadDelegate& in_delegate, const ChilliSource::ResourceSPtr& out_resource)\n            {\n                auto pImageFile = ChilliSource::Application::Get()->GetFileSystem()->CreateBinaryInputStream(in_storageLocation, in_filePath);\n                \n                if(pImageFile == nullptr)\n                {\n                    out_resource->SetLoadState(ChilliSource::Resource::LoadState::k_failed);\n                    if(in_delegate != nullptr)\n                    {\n                        ChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_mainThread, [=](const ChilliSource::TaskContext&) noexcept\n                        {\n                            in_delegate(out_resource);\n                        });\n                    }\n                    return;\n                }\n                \n                auto data = pImageFile->ReadAll();\n                \n                CS_ASSERT(data->GetLength() < static_cast<std::string::size_type>(std::numeric_limits<u32>::max()), \"Image is too large. It cannot exceed \" + ChilliSource::ToString(std::numeric_limits<u32>::max()) + \" bytes.\");\n                CreatePNGImageFromFile(reinterpret_cast<const s8*>(data->GetData()), data->GetLength(), (ChilliSource::Image*)out_resource.get());\n                \n                out_resource->SetLoadState(ChilliSource::Resource::LoadState::k_loaded);\n                if(in_delegate != nullptr)\n                {\n                    ChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_mainThread, [=](const ChilliSource::TaskContext&) noexcept\n                    {\n                        in_delegate(out_resource);\n                    });\n                }\n            }\n        }\n        CS_DEFINE_NAMEDTYPE(PNGImageProvider);\n\t\t//----------------------------------------------------------------\n\t\t//----------------------------------------------------------------\n\t\tbool PNGImageProvider::IsA(ChilliSource::InterfaceIDType in_interaceId) const\n\t\t{\n\t\t\treturn (in_interaceId == ChilliSource::ResourceProvider::InterfaceID || in_interaceId == ChilliSource::PNGImageProvider::InterfaceID || in_interaceId == PNGImageProvider::InterfaceID);\n\t\t}\n        //-------------------------------------------------------\n        //-------------------------------------------------------\n        ChilliSource::InterfaceIDType PNGImageProvider::GetResourceType() const\n        {\n            return ChilliSource::Image::InterfaceID;\n        }\n\t\t//----------------------------------------------------------------\n\t\t//----------------------------------------------------------------\n\t\tbool PNGImageProvider::CanCreateResourceWithFileExtension(const std::string& in_extension) const\n\t\t{\n\t\t\treturn in_extension == k_pngExtension;\n\t\t}\n\t\t//----------------------------------------------------------------\n\t\t//----------------------------------------------------------------\n\t\tvoid PNGImageProvider::CreateResourceFromFile(ChilliSource::StorageLocation in_storageLocation, const std::string& in_filePath, const ChilliSource::IResourceOptionsBaseCSPtr& in_options, const ChilliSource::ResourceSPtr& out_resource)\n\t\t{\n            LoadImage(in_storageLocation, in_filePath, nullptr, out_resource);\n\t\t}\n        //----------------------------------------------------\n        //----------------------------------------------------\n        void PNGImageProvider::CreateResourceFromFileAsync(ChilliSource::StorageLocation in_storageLocation, const std::string& in_filePath, const ChilliSource::IResourceOptionsBaseCSPtr& in_options, const ChilliSource::ResourceProvider::AsyncLoadDelegate& in_delegate, const ChilliSource::ResourceSPtr& out_resource)\n        {\n            ChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_file, [=](const ChilliSource::TaskContext&) noexcept\n            {\n                LoadImage(in_storageLocation, in_filePath, in_delegate, out_resource);\n            });\n        }\n\t}\n}\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/iOS/Core/Image/PNGImageProvider.h",
    "content": "//\n//  PNGImageProvider.h\n//  ChilliSource\n//  Created by S McGaw on 01/10/2010.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2010 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_IOS\n\n#ifndef _CSBACKEND_PLATFORM_IOS_IMAGE_PNGIMAGEPROVIDER_H_\n#define _CSBACKEND_PLATFORM_IOS_IMAGE_PNGIMAGEPROVIDER_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <CSBackend/Platform/iOS/ForwardDeclarations.h>\n#include <ChilliSource/Core/Image/PNGImageProvider.h>\n\nnamespace CSBackend\n{\n\tnamespace iOS\n\t{\n        //----------------------------------------------------------------\n        /// The iOS backend for the PNG resource provider.\n        ///\n        /// @author S McGaw\n        //----------------------------------------------------------------\n\t\tclass PNGImageProvider final : public ChilliSource::PNGImageProvider\n\t\t{\n\t\tpublic:\n            CS_DECLARE_NAMEDTYPE(PNGImageProvider);\n\t\t\t//----------------------------------------------------------\n\t\t\t/// Is the object of the given interface type\n            ///\n            /// @author S McGaw\n            ///\n\t\t\t/// @param Interface type to query\n            ///\n\t\t\t/// @return Whether the object is of given type\n\t\t\t//----------------------------------------------------------\n\t\t\tbool IsA(ChilliSource::InterfaceIDType in_interfaceId) const override;\n            //-------------------------------------------------------\n            /// @author S Downie\n            ///\n            /// @return The resource type this provider can load\n            //-------------------------------------------------------\n            ChilliSource::InterfaceIDType GetResourceType() const override;\n\t\t\t//----------------------------------------------------------\n\t\t\t/// Whether or not the provider can create resources from\n            /// files with the given extension.\n            ///\n\t\t\t/// @author S McGaw\n            ///\n\t\t\t/// @param Extension to compare against\n            ///\n\t\t\t/// @return Whether the object can load a resource with that\n            /// extension\n\t\t\t//----------------------------------------------------------\n\t\t\tbool CanCreateResourceWithFileExtension(const std::string& in_extension) const override;\n\t\t\t//----------------------------------------------------------\n\t\t\t/// Creates a new image resource from file. Check the\n            /// resource load state for success or failure\n\t\t\t///\n            /// @author S McGaw\n            ///\n            /// @param The storage location to load from\n\t\t\t/// @param File path to resource\n            /// @param Options to customise the creation\n\t\t\t/// @param [Out] Resource\n\t\t\t//-----------------------------------------------------------\n\t\t\tvoid CreateResourceFromFile(ChilliSource::StorageLocation in_storageLocation, const std::string& in_filePath, const ChilliSource::IResourceOptionsBaseCSPtr& in_options, const ChilliSource::ResourceSPtr& out_resource) override;\n            //----------------------------------------------------\n            /// Creates a new resource from file asynchronously.\n            /// Completion delegate is called when load is finished.\n            /// Check the resource load state for success or failure\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param The storage location.\n            /// @param The filepath.\n            /// @param Options to customise the creation\n            /// @param Completion delegate\n            /// @param [Out] The output resource.\n            //----------------------------------------------------\n\t\t\tvoid CreateResourceFromFileAsync(ChilliSource::StorageLocation in_storageLocation, const std::string& in_filePath, const ChilliSource::IResourceOptionsBaseCSPtr& in_options, const ChilliSource::ResourceProvider::AsyncLoadDelegate& in_delegate, const ChilliSource::ResourceSPtr& out_resource) override;\n        private:\n            \n            friend ChilliSource::PNGImageProviderUPtr ChilliSource::PNGImageProvider::Create();\n            //-----------------------------------------------------------\n            /// Private constructor to force use of factory method\n            ///\n            /// @author S Downie\n            //-----------------------------------------------------------\n            PNGImageProvider() = default;\n\t\t};\n\t}\n}\n\n#endif\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/iOS/Core/Math/RNGContainer.h",
    "content": "//\n//  RNGContainer.h\n//  ChilliSource\n//  Created by Ian Copland on 23/12/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_IOS\n\n#import <ChilliSource/ChilliSource.h>\n\n#import <Foundation/Foundation.h>\n\n#include <random>\n\n//------------------------------------------------------------------------------\n/// An objective C container for a C++ random number generator. This is required\n/// to store the RNG in a NSDictionary without potential memory leaks.\n///\n/// @author Ian Copland.\n//------------------------------------------------------------------------------\n@interface RNGContainer : NSObject\n{\n    std::mt19937 m_rng;\n}\n//------------------------------------------------------------------------------\n/// Initialises the container with the given random number generator.\n///\n/// @author Ian Copland\n///\n/// @param The RNG.\n//------------------------------------------------------------------------------\n-(id) initWithRNG: (const std::mt19937&)in_rng;\n//------------------------------------------------------------------------------\n/// @author Ian Copland\n///\n/// @return The RNG.\n//------------------------------------------------------------------------------\n-(std::mt19937&) rng;\n//------------------------------------------------------------------------------\n/// Destroys the container and the RNG.\n///\n/// @author Ian Copland.\n//------------------------------------------------------------------------------\n-(void) dealloc;\n\n@end\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/iOS/Core/Math/RNGContainer.mm",
    "content": "//\n//  RNGContainer.cpp\n//  ChilliSource\n//  Created by Ian Copland on 23/12/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2012 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_IOS\n\n#import <CSBackend/Platform/iOS/Core/Math/RNGContainer.h>\n\n@implementation RNGContainer\n\n//------------------------------------------------------------------------------\n//------------------------------------------------------------------------------\n-(id) initWithRNG: (const std::mt19937&)in_rng\n{\n    if(self = [super init])\n\t{\n        m_rng = in_rng;\n\t\treturn self;\n\t}\n    \n    return nil;\n}\n//------------------------------------------------------------------------------\n//------------------------------------------------------------------------------\n-(std::mt19937&) rng\n{\n    return m_rng;\n}\n//------------------------------------------------------------------------------\n//------------------------------------------------------------------------------\n-(void) dealloc\n{\n    [super dealloc];\n}\n@end\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/iOS/Core/Notification/LocalNotificationSystem.cpp",
    "content": "//\n//  LocalNotificationSystem.cpp\n//  ChilliSource\n//  Created by Scott Downie on 01/07/2011.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2011 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_IOS\n\n#include <CSBackend/Platform/iOS/Core/Notification/LocalNotificationSystem.h>\n#include <CSBackend/Platform/iOS/Core/String/NSStringUtils.h>\n\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/Threading/TaskScheduler.h>\n\n#import <UIKit/UIKit.h>\n\nnamespace CSBackend\n{\n    namespace iOS\n    {\n        namespace\n        {\n            LocalNotificationSystem* g_localNotificationSystem;\n            std::vector<ChilliSource::NotificationSPtr> g_queuedNotifications;\n            \n            //---------------------------------------------------------------\n            /// Convert UILocalNotification to Notification\n            ///\n            /// @author Scott Downie\n            ///\n            /// @param Apple UILocalNotification\n            /// @param [Out] ChilliSource notification\n            //---------------------------------------------------------------\n            ChilliSource::NotificationUPtr ConvertUILocalNotificationToNotification(UILocalNotification* in_uiLocal)\n            {\n                ChilliSource::NotificationUPtr notification = ChilliSource::NotificationUPtr(new ChilliSource::Notification());\n                notification->m_id = (ChilliSource::Notification::ID)[[in_uiLocal.userInfo objectForKey:@\"ID\"] unsignedIntValue];\n                notification->m_priority = (ChilliSource::Notification::Priority)[[in_uiLocal.userInfo objectForKey:@\"Priority\"] unsignedIntValue];\n                \n                NSDictionary* nsParams = (NSDictionary*)[in_uiLocal.userInfo objectForKey:@\"Params\"];\n                for(id key in nsParams)\n                {\n                    notification->m_params.SetValue([NSStringUtils newUTF8StringWithNSString:[nsParams objectForKey:key]], [NSStringUtils newUTF8StringWithNSString:key]);\n                }\n                \n                return notification;\n            }\n        }\n        CS_DEFINE_NAMEDTYPE(LocalNotificationSystem);\n        //----------------------------------------------------------\n        //----------------------------------------------------------\n        LocalNotificationSystem::LocalNotificationSystem()\n        : m_enabled(true)\n        {\n            m_recentlyAddedNotifications = [[NSMutableArray alloc] init];\n        }\n        //--------------------------------------------------------\n        //-------------------------------------------------------\n        bool LocalNotificationSystem::IsA(ChilliSource::InterfaceIDType in_interfaceId) const\n        {\n            return (ChilliSource::LocalNotificationSystem::InterfaceID == in_interfaceId || LocalNotificationSystem::InterfaceID == in_interfaceId);\n        }\n        //--------------------------------------------------\n        //---------------------------------------------------\n        void LocalNotificationSystem::SetEnabled(bool in_enabled)\n        {\n            CS_RELEASE_ASSERT(ChilliSource::Application::Get()->GetTaskScheduler()->IsMainThread(), \"Attempted to enable/disable notifications outside of main thread.\");\n            \n            ChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_system, [=](const ChilliSource::TaskContext& taskContext)\n            {\n                m_enabled = in_enabled;\n                \n                if (m_enabled == false)\n                {\n                    CancelAll();\n                }\n            });\n        }\n        //---------------------------------------------------\n        //---------------------------------------------------\n        void LocalNotificationSystem::ScheduleNotificationForTime(ChilliSource::Notification::ID in_id, const ChilliSource::ParamDictionary& in_params, TimeIntervalSecs in_time, ChilliSource::Notification::Priority in_priority)\n        {\n            @autoreleasepool\n            {\n                CS_RELEASE_ASSERT(ChilliSource::Application::Get()->GetTaskScheduler()->IsMainThread(), \"Attempted to schedule notification outside of main thread.\");\n                \n                \n                ChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_system, [=](const ChilliSource::TaskContext& taskContext)\n                {\n                    //Clean-up any duplicates from recently added\n                    for(UILocalNotification* nsNotification in [[UIApplication sharedApplication] scheduledLocalNotifications])\n                    {\n                        if([m_recentlyAddedNotifications containsObject:nsNotification] == YES)\n                        {\n                            [m_recentlyAddedNotifications removeObject:nsNotification];\n                        }\n                    }\n                    \n                    if (m_enabled == true)\n                    {\n                        //Create the notifications\n                        UILocalNotification* nsNotification = [[[UILocalNotification alloc] init] autorelease];\n                        nsNotification.fireDate = [NSDate dateWithTimeIntervalSince1970:(NSTimeInterval)in_time];\n                        nsNotification.timeZone = [NSTimeZone defaultTimeZone];\n                        nsNotification.alertAction = @\"View\";\n                        \n                        NSString* body = [NSStringUtils newNSStringWithUTF8String:in_params.GetValue(\"Body\")];\n                        nsNotification.alertBody = body;\n                        [body release];\n                        \n                        if(in_params.HasKey(\"Sound\") == true)\n                        {\n                            NSString* sound = [NSStringUtils newNSStringWithUTF8String:in_params.GetValue(\"Sound\")];\n                            nsNotification.soundName = sound;\n                            [sound release];\n                        }\n                        else\n                        {\n                            nsNotification.soundName = UILocalNotificationDefaultSoundName;\n                        }\n                        \n                        nsNotification.applicationIconBadgeNumber = 1;\n                        \n                        NSMutableDictionary* nsParams = [[NSMutableDictionary alloc] init];\n                        for(ChilliSource::ParamDictionary::const_iterator it = in_params.begin(); it != in_params.end(); ++it)\n                        {\n                            NSString* key = [NSStringUtils newNSStringWithUTF8String:it->first];\n                            NSString* value = [NSStringUtils newNSStringWithUTF8String:it->second];\n                            [nsParams setObject:key forKey:value];\n                            [key release];\n                            [value release];\n                        }\n                        \n                        //Encode the type ID into the notification so we can retrieve it at the other end\n                        NSDictionary* pInfo = [NSDictionary dictionaryWithObjectsAndKeys:\n                                               [NSNumber numberWithUnsignedInt:(u32)in_id], @\"ID\",\n                                               [NSNumber numberWithUnsignedInt:(u32)in_priority], @\"Priority\",\n                                               nsParams, @\"Params\",\n                                               nil];\n                        \n                        nsNotification.userInfo = pInfo;\n                        \n                        // pInfo dictionary retains the pParams dictionary on insertion so we need to release\n                        [nsParams release];\n                        \n                        //Schedule this baby\n                        [[UIApplication sharedApplication] scheduleLocalNotification:nsNotification];\n                        \n                        //Unfortunately it seems that scheduling a notification doesn't immediately add it to the notifications list\n                        //and subsequent attempts to cancel or retrieve it may fail. In order to workaround this we need to maintain our\n                        //own list of recently added notifications.\n                        [m_recentlyAddedNotifications addObject:nsNotification];\n                    }\n                });\n            }\n        }\n        //--------------------------------------------------------\n        //--------------------------------------------------------\n        void LocalNotificationSystem::GetScheduledNotifications(const GetScheduledNotificationsDelegate& in_delegate, TimeIntervalSecs in_time, TimeIntervalSecs in_period) const\n        {\n            CS_RELEASE_ASSERT(ChilliSource::Application::Get()->GetTaskScheduler()->IsMainThread(), \"Attempted to retrieve scheduled notifications outside of main thread.\");\n            \n            ChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_system, [=](const ChilliSource::TaskContext& taskContext)\n            {\n                std::vector<ChilliSource::NotificationCSPtr> notificationList;\n                \n                for(UILocalNotification* nsNotification in [[UIApplication sharedApplication] scheduledLocalNotifications])\n                {\n                    TimeIntervalSecs triggerTime = (TimeIntervalSecs)[nsNotification.fireDate timeIntervalSince1970];\n                    s32 dwDeltaSecs = (s32)(in_time - triggerTime);\n                    \n                    if(std::abs(dwDeltaSecs) <= in_period)\n                    {\n                        ChilliSource::NotificationSPtr notification = ConvertUILocalNotificationToNotification(nsNotification);\n                        notificationList.push_back(notification);\n                    }\n                    \n                    if([m_recentlyAddedNotifications containsObject:nsNotification] == YES)\n                    {\n                        [m_recentlyAddedNotifications removeObject:nsNotification];\n                    }\n                }\n                \n                for(UILocalNotification* nsNotification in m_recentlyAddedNotifications)\n                {\n                    TimeIntervalSecs triggerTime = (TimeIntervalSecs)[nsNotification.fireDate timeIntervalSince1970];\n                    s32 dwDeltaSecs = (s32)(in_time - triggerTime);\n                    \n                    if(std::abs(dwDeltaSecs) <= in_period)\n                    {\n                        ChilliSource::NotificationSPtr notification = ConvertUILocalNotificationToNotification(nsNotification);\n                        notificationList.push_back(notification);\n                    }\n                }\n                \n                ChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_mainThread, [=](const ChilliSource::TaskContext& taskContext)\n                {\n                    if(in_delegate)\n                    {\n                        in_delegate(notificationList);\n                    }\n                });\n            });\n        }\n        //------------------------------------------------\n        //------------------------------------------------\n        void LocalNotificationSystem::CancelByID(ChilliSource::Notification::ID in_id)\n        {\n            CS_RELEASE_ASSERT(ChilliSource::Application::Get()->GetTaskScheduler()->IsMainThread(), \"Attempted to cancel notification outside of main thread.\");\n            \n            ChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_system, [=](const ChilliSource::TaskContext& taskContext)\n            {\n                for(UILocalNotification* nsNotification in [[UIApplication sharedApplication] scheduledLocalNotifications])\n                {\n                    ChilliSource::Notification::ID notificationId = [[nsNotification.userInfo objectForKey:@\"ID\"] unsignedIntValue];\n                    \n                    if(notificationId == in_id)\n                    {\n                        [[UIApplication sharedApplication] cancelLocalNotification:nsNotification];\n                    }\n                    \n                    if([m_recentlyAddedNotifications containsObject:nsNotification] == YES)\n                    {\n                        [m_recentlyAddedNotifications removeObject:nsNotification];\n                    }\n                }\n                \n                for(UILocalNotification* nsNotification in m_recentlyAddedNotifications)\n                {\n                    ChilliSource::Notification::ID notificationId = [[nsNotification.userInfo objectForKey:@\"ID\"] unsignedIntValue];\n                    \n                    if(notificationId == in_id)\n                    {\n                        [[UIApplication sharedApplication] cancelLocalNotification:nsNotification];\n                    }\n                }\n            });\n        }\n        //------------------------------------------------\n        //------------------------------------------------\n        void LocalNotificationSystem::CancelAll()\n        {\n            CS_RELEASE_ASSERT(ChilliSource::Application::Get()->GetTaskScheduler()->IsMainThread(), \"Attempted to cancel all notifications outside of main thread.\");\n            \n            ChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_system, [=](const ChilliSource::TaskContext& taskContext)\n            {\n                [m_recentlyAddedNotifications removeAllObjects];\n                [[UIApplication sharedApplication] cancelAllLocalNotifications];\n            });\n        }\n        //--------------------------------------------------\n        //---------------------------------------------------\n        ChilliSource::IConnectableEvent<ChilliSource::LocalNotificationSystem::ReceivedDelegate>& LocalNotificationSystem::GetReceivedEvent()\n        {\n            return m_receivedEvent;\n        }\n        //------------------------------------------------\n        //------------------------------------------------\n        bool LocalNotificationSystem::ApplicationDidFinishLaunchingWithOptions(UIApplication* inpApplication, NSDictionary* inpOptions)\n        {\n            //Reset the badge number\n            inpApplication.applicationIconBadgeNumber = 0;\n            \n            UILocalNotification* pLocalNotification = [inpOptions objectForKey:UIApplicationLaunchOptionsLocalNotificationKey];\n            if(pLocalNotification) \n            {\n                ChilliSource::NotificationSPtr notification = ConvertUILocalNotificationToNotification(pLocalNotification);\n                if (g_localNotificationSystem != nullptr)\n                {\n                    g_localNotificationSystem->OnNotificationReceived(notification);\n                }\n                else\n                {\n                    g_queuedNotifications.push_back(notification);\n                }\n                return true;\n            }\n            \n            return false;\n        }\n        //------------------------------------------------\n        //------------------------------------------------\n\t\tvoid LocalNotificationSystem::ApplicationDidBecomeActive(UIApplication* inpApplication)\n\t\t{\n\t\t\t//Reset the badge number\n            inpApplication.applicationIconBadgeNumber = 0;\n\t\t}\n        //------------------------------------------------\n        //------------------------------------------------\n        void LocalNotificationSystem::ApplicationDidReceiveLocalNotification(UIApplication* inpApplication, UILocalNotification* inpNotification)\n        {\n            //Reset the badge number\n            inpApplication.applicationIconBadgeNumber = (inpApplication.applicationIconBadgeNumber - 1);\n            \n            ChilliSource::NotificationSPtr notification = ConvertUILocalNotificationToNotification(inpNotification);\n            if (g_localNotificationSystem != nullptr)\n            {\n                g_localNotificationSystem->OnNotificationReceived(notification);\n            }\n            else\n            {\n                g_queuedNotifications.push_back(notification);\n            }\n        }\n        //--------------------------------------------------------\n        //--------------------------------------------------------\n        void LocalNotificationSystem::OnInit()\n        {\n#ifdef __IPHONE_8_0\n            if ([[UIApplication sharedApplication] respondsToSelector:@selector(registerUserNotificationSettings:)])\n            {\n                //From iOS 8 we need to request permissions to display notifications, to badge the app icon and to play a sound\n                UIUserNotificationSettings* notificationSettings = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert | UIUserNotificationTypeBadge | UIUserNotificationTypeSound categories:nil];\n                [[UIApplication sharedApplication] registerUserNotificationSettings:notificationSettings];\n            }\n#endif\n            \n            ChilliSource::LocalNotificationSystem::OnInit();\n            \n            CS_ASSERT(g_localNotificationSystem == nullptr, \"Cannot create more than 1 Local Notification System!\");\n            g_localNotificationSystem = this;\n            \n            for (const ChilliSource::NotificationSPtr& notification : g_queuedNotifications)\n            {\n                OnNotificationReceived(notification);\n            }\n            \n            g_queuedNotifications.clear();\n            g_queuedNotifications.shrink_to_fit();\n        }\n        //--------------------------------------------------------\n        //--------------------------------------------------------\n        void LocalNotificationSystem::OnNotificationReceived(const ChilliSource::NotificationSPtr& in_notification)\n        {\n            m_receivedEvent.NotifyConnections(in_notification);\n        }\n        //--------------------------------------------------------\n        //--------------------------------------------------------\n        void LocalNotificationSystem::OnDestroy()\n        {\n            g_localNotificationSystem = nullptr;\n            ChilliSource::LocalNotificationSystem::OnDestroy();\n        }\n        //----------------------------------------------------------\n        //----------------------------------------------------------\n        LocalNotificationSystem::~LocalNotificationSystem()\n        {\n            [m_recentlyAddedNotifications release];\n            g_localNotificationSystem = nullptr;\n        }\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/iOS/Core/Notification/LocalNotificationSystem.h",
    "content": "//\n//  LocalNotifcationSystem.h\n//  ChilliSource\n//  Created by Scott Downie on 01/07/2011.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2011 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_IOS\n\n#ifndef _CSBACKEND_PLATFORM_IOS_CORE_NOTIFICATION_LOCALNOTIFICATIONSYSTEM_H_\n#define _CSBACKEND_PLATFORM_IOS_CORE_NOTIFICATION_LOCALNOTIFICATIONSYSTEM_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <CSBackend/Platform/iOS/ForwardDeclarations.h>\n#include <ChilliSource/Core/Notification/LocalNotificationSystem.h>\n\n@class UIApplication;\n@class UILocalNotification;\n@class NSDictionary;\n@class NSMutableArray;\n\nnamespace CSBackend\n{\n    namespace iOS\n    {\n        class LocalNotificationSystem final : public ChilliSource::LocalNotificationSystem\n        {\n        public:\n            CS_DECLARE_NAMEDTYPE(LocalNotificationSystem);\n            //--------------------------------------------------------\n            /// @author Ian Copland\n            ///\n            /// @param The interface ID to check against.\n            /// @return Whether this implements the passed in interface\n            /// id.\n            //-------------------------------------------------------\n            bool IsA(ChilliSource::InterfaceIDType in_interfaceId) const override;\n            //--------------------------------------------------\n            /// Enables and disables addition of local notifications.\n            /// All existing notifications will be cancelled\n            /// when this is disabled. This is enabled by default.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param Whether or not to enable the scheduling\n            /// of app notifications.\n            //---------------------------------------------------\n            void SetEnabled(bool in_enabled) override;\n            //---------------------------------------------------\n            /// Schedules a Local Notifcation which should fire\n            /// at the given time. A Local Notification uses\n            /// the system specfic notification alarms and can\n            /// be received even if it was scheduled during a\n            /// previous instance of the application.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param The notification id\n            /// @param The notification params.\n            /// @param Time in seconds at which it should trigger.\n            /// @param [Optional] The notification priority. Defaults\n            /// to standard priority.\n            //---------------------------------------------------\n            void ScheduleNotificationForTime(ChilliSource::Notification::ID in_id, const ChilliSource::ParamDictionary& in_params, TimeIntervalSecs in_time, ChilliSource::Notification::Priority in_priority = ChilliSource::Notification::Priority::k_standard) override;\n            //--------------------------------------------------------\n            /// Generates a list of all notifications that are currently\n            /// scheduled. Because the list cannot be immediately\n            /// calculated, the result is returned through the provided\n            /// delegate when ready.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param The delegate function to execute.\n            /// @param [Optional] The start time.\n            /// @param [Optional] The end time.\n            //--------------------------------------------------------\n            void GetScheduledNotifications(const GetScheduledNotificationsDelegate& in_delegate, TimeIntervalSecs in_time = 0, TimeIntervalSecs in_period = std::numeric_limits<TimeIntervalSecs>::max()) const override;\n            //--------------------------------------------------------\n            /// Prevent any notifications with given ID type from firing\n            ///\n            /// @author Scott Downie\n            ///\n            /// @param ID type\n            //--------------------------------------------------------\n            void CancelByID(ChilliSource::Notification::ID in_id) override;\n            //--------------------------------------------------------\n            /// Terminate all currently scheduled notifications\n            ///\n            /// @author Scott Downie\n            //--------------------------------------------------------\n            void CancelAll() override;\n            //--------------------------------------------------\n            /// @author Ian Copland\n            ///\n            /// @return An event that can be used to listen for\n            /// new notifications being received.\n            //---------------------------------------------------\n            ChilliSource::IConnectableEvent<ChilliSource::LocalNotificationSystem::ReceivedDelegate>& GetReceivedEvent() override;\n            //--------------------------------------------------------\n            /// Called by the app delegate when the app launches. Used\n            /// to pull local notification data from the options\n            ///\n            /// @author Scott Downie\n            ///\n            /// @param UIApplication\n            /// @param Launching options dictionary\n            /// @return Whether the app was launched with local\n            /// notifications\n            //---------------------------------------------------------\n            static bool ApplicationDidFinishLaunchingWithOptions(UIApplication* in_application, NSDictionary* in_options);\n\t\t\t//---------------------------------------------------------\n            /// Called by the app delegate when the app becomes active.\n            /// Used to clear the icon badge number\n            ///\n            /// @author Scott Downie\n            ///\n            /// @param UIApplication\n            //----------------------------------------------------------\n            static void ApplicationDidBecomeActive(UIApplication* in_application);\n            //----------------------------------------------------------\n            /// Called by the app delegate when it receives a local\n            /// notification.\n            ///\n            /// @author Scott Downie\n            ///\n            /// @param UILocalNotification\n            //----------------------------------------------------------\n            static void ApplicationDidReceiveLocalNotification(UIApplication* in_application, UILocalNotification* in_notification);\n            //----------------------------------------------------------\n            /// Destructor.\n            ///\n            /// @author Scott Downie\n            //----------------------------------------------------------\n            ~LocalNotificationSystem();\n        private:\n            friend ChilliSource::LocalNotificationSystemUPtr ChilliSource::LocalNotificationSystem::Create();\n            //----------------------------------------------------------\n            /// Private constructor to force use of factory method.\n            ///\n            /// @author S Downie\n            //----------------------------------------------------------\n            LocalNotificationSystem();\n            //--------------------------------------------------------\n            /// Initalises the local notification system.\n            ///\n            /// @author Ian Copland\n            //--------------------------------------------------------\n            void OnInit() override;\n            //--------------------------------------------------------\n            /// Called when a notification is received.\n            ///\n            /// @author Ian Copland\n            //--------------------------------------------------------\n            void OnNotificationReceived(const ChilliSource::NotificationSPtr& in_notification);\n            //--------------------------------------------------------\n            /// destroys the local notification system.\n            ///\n            /// @author Ian Copland\n            //--------------------------------------------------------\n            void OnDestroy() override;\n            \n            bool m_enabled;\n            ChilliSource::Event<ChilliSource::LocalNotificationSystem::ReceivedDelegate> m_receivedEvent;\n            \n            NSMutableArray* m_recentlyAddedNotifications;\n        };\n    }\n}\n\n#endif\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/iOS/Core/Notification/NSNotificationAdapter.h",
    "content": "//\n//  NSNotificationAdapter.h\n//  ChilliSource\n//  Created by Scott Downie on 01/02/2011.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2011 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_IOS\n\n#ifndef _NS_NOTIFICATION_ADAPTER_H_\n#define _NS_NOTIFICATION_ADAPTER_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Event/Event.h>\n\n#import <Foundation/Foundation.h>\n\n#include <functional>\n\ntypedef std::function<void()> NotificationEventDelegate;\n\n@interface NSNotificationAdapter : NSObject \n{    \n    //---Media Player\n    ChilliSource::Event<NotificationEventDelegate> mMPLoadStateChangeEvent;\n    ChilliSource::Event<NotificationEventDelegate> mMPPlaybackDidFinishEvent;\n}\n\n//-----------------------------------------------\n/// Shared Instance\n///\n/// @return Singleton instance \n//-----------------------------------------------\n+(NSNotificationAdapter*) sharedInstance;\n\n//-----------------------------------------------\n/// Begin Listening For MP Load State Changed\n//-----------------------------------------------\n-(void) BeginListeningForMPLoadStateChanged;\n//-----------------------------------------------\n/// Stop Listening For MP Load State Changed\n//-----------------------------------------------\n-(void) StopListeningForMPLoadStateChanged;\n\n//-----------------------------------------------\n/// Begin Listening For MP Playback Did Finish\n//-----------------------------------------------\n-(void) BeginListeningForMPPlaybackDidFinish;\n//-----------------------------------------------\n/// Stop Listening For MP Playback Did Finish\n//-----------------------------------------------\n-(void) StopListeningForMPPlaybackDidFinish;\n\n//-----------------------------------------------\n/// Get Movie Player Load State Change Event\n///\n/// @return Event Object\n//-----------------------------------------------\n-(ChilliSource::IConnectableEvent<NotificationEventDelegate>&) GetMPLoadStateChangeEvent;\n//-----------------------------------------------\n/// Get Movie Player Playback Did Finish Event\n///\n/// @return Event Object\n//-----------------------------------------------\n-(ChilliSource::IConnectableEvent<NotificationEventDelegate>&) GetMPPlaybackDidFinishEvent;\n\n//---Notification callbacks\n//-----------------------------------------------\n/// On Movie Player Load State Changed\n//-----------------------------------------------\n-(void) OnMoviePlayerLoadStateChanged;\n//-----------------------------------------------\n/// On Movie Player Playback Did Finish\n//-----------------------------------------------\n-(void) OnMoviePlayerPlaybackDidFinish;\n\n@end\n\n#endif\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/iOS/Core/Notification/NSNotificationAdapter.mm",
    "content": "//\n//  NSNotificationAdapter.mm\n//  ChilliSource\n//  Created by Scott Downie on 01/02/2011.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2011 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_IOS\n\n#import <CSBackend/Platform/iOS/Core/Notification/NSNotificationAdapter.h>\n\n#import <GameKit/GameKit.h>\n#import <MediaPlayer/MediaPlayer.h>\n\nNSNotificationAdapter* gpSharedInstance = nil;\n\n@implementation NSNotificationAdapter\n\n//-----------------------------------------------\n/// Shared Instance\n///\n/// @return Singleton instance \n//-----------------------------------------------\n+(NSNotificationAdapter*) sharedInstance\n{\n\tif(!gpSharedInstance)\n\t{\n\t\tgpSharedInstance = [[NSNotificationAdapter alloc] init];\n\t}\n\t\n\treturn gpSharedInstance;\n}\n\n//-----------------------------------------------\n/// Begin Listening For MP Load State Changed\n//-----------------------------------------------\n-(void) BeginListeningForMPLoadStateChanged\n{\n    //Register that the load state changed (movie is ready)\n    [[NSNotificationCenter defaultCenter] addObserver:gpSharedInstance \n                                             selector:@selector(OnMoviePlayerLoadStateChanged) \n                                                 name:MPMoviePlayerLoadStateDidChangeNotification \n                                               object:nil];\n}\n//-----------------------------------------------\n/// Stop Listening For MP Load State Changed\n//-----------------------------------------------\n-(void) StopListeningForMPLoadStateChanged\n{\n    [[NSNotificationCenter defaultCenter] removeObserver:gpSharedInstance \n                                                    name:MPMoviePlayerLoadStateDidChangeNotification \n                                                  object:nil];\n}\n\n//-----------------------------------------------\n/// Begin Listening For MP Playback Did Finish\n//-----------------------------------------------\n-(void) BeginListeningForMPPlaybackDidFinish\n{\n    //Register to receive a notification when the movie has finished playing. \n    [[NSNotificationCenter defaultCenter] addObserver:gpSharedInstance \n                                             selector:@selector(OnMoviePlayerPlaybackDidFinish) \n                                                 name:MPMoviePlayerPlaybackDidFinishNotification \n                                               object:nil];\n}\n//-----------------------------------------------\n/// Stop Listening For MP Playback Did Finish\n//-----------------------------------------------\n-(void) StopListeningForMPPlaybackDidFinish\n{\n    [[NSNotificationCenter defaultCenter] removeObserver:gpSharedInstance \n                                                    name:MPMoviePlayerPlaybackDidFinishNotification \n                                                  object:nil];\n}\n\n//-----------------------------------------------\n/// Get Movie Player Load State Change Event\n///\n/// @return Event Object\n//-----------------------------------------------\n-(ChilliSource::IConnectableEvent<NotificationEventDelegate>&) GetMPLoadStateChangeEvent\n{\n    return mMPLoadStateChangeEvent;\n}\n//-----------------------------------------------\n/// Get Movie Player Playback Did Finish Event\n///\n/// @return Event Object\n//-----------------------------------------------\n-(ChilliSource::IConnectableEvent<NotificationEventDelegate>&) GetMPPlaybackDidFinishEvent\n{\n    return mMPPlaybackDidFinishEvent;\n}\n//-----------------------------------------------\n/// On Movie Player Load State Changed\n//-----------------------------------------------\n-(void) OnMoviePlayerLoadStateChanged\n{\n    mMPLoadStateChangeEvent.NotifyConnections();\n}\n//-----------------------------------------------\n/// On Movie Player Playback Did Finish\n//-----------------------------------------------\n-(void) OnMoviePlayerPlaybackDidFinish\n{\n    mMPPlaybackDidFinishEvent.NotifyConnections();\n}\n\n@end\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/iOS/Core/Notification/RemoteNotificationSystem.cpp",
    "content": "//\n//  RemoteNotificationSystem.cpp\n//  ChilliSource\n//  Created by Robert Henning on 22/01/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_IOS\n\n#include <CSBackend/Platform/iOS/Core/Notification/RemoteNotificationSystem.h>\n\n#include <CSBackend/Platform/iOS/Core/String/NSStringUtils.h>\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/Cryptographic/BaseEncoding.h>\n#include <ChilliSource/Core/Notification/Notification.h>\n#include <ChilliSource/Core/Threading/TaskScheduler.h>\n\n#include <UIKit/UIKit.h>\n\nnamespace CSBackend\n{\n    namespace iOS\n    {\n        namespace\n        {\n            const std::string k_providerID = \"Apple\";\n        }\n        \n        CS_DEFINE_NAMEDTYPE(RemoteNotificationSystem);\n        //--------------------------------------------------\n        //--------------------------------------------------\n        RemoteNotificationSystem::RemoteNotificationSystem()\n            : m_enabled(true)\n        {\n        }\n        //--------------------------------------------------\n        //--------------------------------------------------\n        bool RemoteNotificationSystem::IsA(ChilliSource::InterfaceIDType in_interfaceId) const\n        {\n            return (RemoteNotificationSystem::InterfaceID == in_interfaceId || ChilliSource::RemoteNotificationSystem::InterfaceID == in_interfaceId);\n        }\n        //--------------------------------------------------\n        //--------------------------------------------------\n        void RemoteNotificationSystem::OnInit()\n        {\n#ifdef __IPHONE_8_0\n            ChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_system, [=](const ChilliSource::TaskContext& taskContext)\n            {\n                if ([[UIApplication sharedApplication] respondsToSelector:@selector(registerUserNotificationSettings:)])\n                {\n                    //From iOS 8 we need to request permissions to display notifications, to badge the app icon and to play a sound\n                    UIUserNotificationSettings* notificationSettings = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert | UIUserNotificationTypeBadge | UIUserNotificationTypeSound categories:nil];\n                    [[UIApplication sharedApplication] registerUserNotificationSettings:notificationSettings];\n                }\n            });\n#endif\n        }\n        //--------------------------------------------------\n        //--------------------------------------------------\n        void RemoteNotificationSystem::SetEnabled(bool in_enabled)\n        {\n            m_enabled = in_enabled;\n        }\n        //--------------------------------------------------\n        //--------------------------------------------------\n        void RemoteNotificationSystem::RequestRemoteToken(const TokenReceivedDelegate& in_delegate)\n        {\n            m_delegate = in_delegate;\n\n            ChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_system, [=](const ChilliSource::TaskContext& taskContext)\n            {\n#ifdef __IPHONE_8_0\n                if ([[UIApplication sharedApplication] respondsToSelector:@selector(registerForRemoteNotifications)])\n                {\n                    [[UIApplication sharedApplication] registerForRemoteNotifications];\n                }\n                else\n#endif\n                {\n                    UIRemoteNotificationType Types = UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert;\n                    [[UIApplication sharedApplication] registerForRemoteNotificationTypes:Types];\n                }\n            });\n        }\n        //--------------------------------------------------\n        //--------------------------------------------------\n        const std::string& RemoteNotificationSystem::GetRemoteToken() const\n        {\n            return m_token;\n        }\n        //--------------------------------------------------\n        //--------------------------------------------------\n        const std::string& RemoteNotificationSystem::GetProviderID() const\n        {\n            return k_providerID;\n        }\n        //--------------------------------------------------\n        //--------------------------------------------------\n        void RemoteNotificationSystem::OnRemoteTokenReceived(NSData* in_token)\n        {\n            m_token = ChilliSource::BaseEncoding::Base64Encode((const s8*)[in_token bytes], static_cast<u32>(in_token.length));\n            \n            ChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_mainThread, [=](const ChilliSource::TaskContext& taskContext)\n            {\n                if(m_delegate != nullptr)\n                {\n                    m_delegate(m_token);\n                    m_delegate = nullptr;\n                }\n            });\n        }\n        //--------------------------------------------------\n        //--------------------------------------------------\n        void RemoteNotificationSystem::OnRemoteNotificationReceived(UIApplication* in_application, NSDictionary* in_payload)\n        {\n            @autoreleasepool\n            {\n                if (m_enabled == true)\n                {\n                    in_application.applicationIconBadgeNumber = 0;\n                    \n                    ChilliSource::NotificationSPtr notification = std::make_shared<ChilliSource::Notification>();\n                    notification->m_id = 0;\n                    notification->m_priority = ChilliSource::Notification::Priority::k_standard;\n                    \n                    // Add the message\n                    NSObject* apsObject = [in_payload objectForKey:@\"aps\"];\n                    if(apsObject != nil && [apsObject isKindOfClass:[NSDictionary class]])\n                    {\n                        NSDictionary* apsDictionary = (NSDictionary*)apsObject;\n                        NSObject* alertObject = [apsDictionary objectForKey:@\"alert\"];\n                        if(alertObject != nil && [alertObject isKindOfClass:[NSDictionary class]])\n                        {\n                            NSDictionary* alertDictionary = (NSDictionary*)alertObject;\n                            NSObject* bodyObject = [alertDictionary objectForKey:@\"body\"];\n                            if(bodyObject != nil && [bodyObject isKindOfClass:[NSString class]])\n                            {\n                                NSString* body = (NSString*) bodyObject;\n                                notification->m_params.SetValue(\"message\", [NSStringUtils newUTF8StringWithNSString:body]);\n                            }\n                        }\n                    }\n                    \n                    // Get the extra data\n                    for(NSString* key in in_payload)\n                    {\n                        if([key isKindOfClass:[NSString class]])\n                        {\n                            NSObject* payloadObject = [in_payload objectForKey:key];\n                            if([payloadObject isKindOfClass:[NSString class]])\n                            {\n                                NSString* payloadString = (NSString*)payloadObject;\n                                notification->m_params.SetValue([NSStringUtils newUTF8StringWithNSString:key], [NSStringUtils newUTF8StringWithNSString:payloadString]);\n                            }\n                        }\n                    }\n                    \n                    ChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_mainThread, [=](const ChilliSource::TaskContext& taskContext)\n                    {\n                        m_receivedEvent.NotifyConnections(notification);\n                    });\n                }\n            }\n        }\n        //--------------------------------------------------\n        //---------------------------------------------------\n        ChilliSource::IConnectableEvent<ChilliSource::RemoteNotificationSystem::NotificationReceivedDelegate>& RemoteNotificationSystem::GetReceivedEvent()\n        {\n            return m_receivedEvent;\n        }\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/iOS/Core/Notification/RemoteNotificationSystem.h",
    "content": "//\n//  RemoteNotificationSystem.h\n//  ChilliSource\n//  Created by Robert Henning on 22/01/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_IOS\n\n#ifndef _CSBACKEND_PLATFORM_IOS_CORE_NOTIFICATION_REMOTENOTIFICATIONSYSTEM_H_\n#define _CSBACKEND_PLATFORM_IOS_CORE_NOTIFICATION_REMOTENOTIFICATIONSYSTEM_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <CSBackend/Platform/iOS/ForwardDeclarations.h>\n#include <ChilliSource/Core/Event/Event.h>\n#include <ChilliSource/Core/Notification/RemoteNotificationSystem.h>\n\n#include <UIKit/UIKit.h>\n\nnamespace CSBackend\n{\n    namespace iOS\n    {\n        //---------------------------------------------------------\n        /// The iOS backend for the remote notification system.\n        ///\n        /// @author Robert Henning\n        //---------------------------------------------------------\n        class RemoteNotificationSystem : public ChilliSource::RemoteNotificationSystem\n        {\n        public:\n            CS_DECLARE_NAMEDTYPE(RemoteNotificationSystem);\n            //--------------------------------------------------\n            /// @author Ian Copland\n            ///\n            /// @param The interface ID to check against.\n            ///\n            /// @return Whether this implements the passed in\n            /// interface id.\n            //--------------------------------------------------\n            bool IsA(ChilliSource::InterfaceIDType in_interfaceId) const override;\n            //--------------------------------------------------\n            /// Request the remote token for this device for use\n            /// with Push Notifications.\n            ///\n            /// @author Robert Henning\n            ///\n            /// @param The return delegate.\n            //--------------------------------------------------\n            void RequestRemoteToken(const TokenReceivedDelegate& in_delegate) override;\n            //--------------------------------------------------\n            /// Enables and disables addition of remote notifications.\n            /// All existing notifications will be cancelled\n            /// when this is disabled. This is enabled by default.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param Whether or not to enable the scheduling\n            /// of app notifications.\n            //---------------------------------------------------\n            void SetEnabled(bool in_enabled) override;\n            //---------------------------------------------------\n            /// @author Robert Henning\n            ///\n            /// @return The unique token that the push notification\n            /// provider uses to identify the device\n            //---------------------------------------------------\n            const std::string& GetRemoteToken() const override;\n            //---------------------------------------------------\n            /// @author Robert Henning\n            ///\n            /// @return The ID for the Apple remote notification\n            /// service\n            //---------------------------------------------------\n            const std::string& GetProviderID() const override;\n            //--------------------------------------------------\n            /// @author Ian Copland\n            ///\n            /// @return An event that can be used to listen for\n            /// new notifications being received.\n            //---------------------------------------------------\n            ChilliSource::IConnectableEvent<NotificationReceivedDelegate>& GetReceivedEvent() override;\n            //---------------------------------------------------\n            /// @author Robert Henning\n            ///\n            /// @param The unique token that the push notification\n            /// provider uses to identify the device\n            //---------------------------------------------------\n            void OnRemoteTokenReceived(NSData* in_token);\n            //---------------------------------------------------\n            /// Called when the app delegate receives a push\n            /// notification\n            ///\n            /// @author Robert Henning\n            ///\n            /// @param UIApplication\n            /// @param Dictionary payload of remote notification\n            //---------------------------------------------------\n            void OnRemoteNotificationReceived(UIApplication* in_application, NSDictionary* in_payload);\n            \n        private:\n            friend ChilliSource::RemoteNotificationSystemUPtr ChilliSource::RemoteNotificationSystem::Create();\n            //----------------------------------------------------------\n            /// Private constructor to force use of factory method.\n            ///\n            /// @author S Downie\n            //----------------------------------------------------------\n            RemoteNotificationSystem();\n            //--------------------------------------------------\n            /// Called when the system is initialised to request\n            /// the permissions\n            ///\n            /// @author S Downie\n            //--------------------------------------------------\n            void OnInit() override;\n            \n            bool m_enabled;\n            std::string m_token;\n            TokenReceivedDelegate m_delegate;\n            ChilliSource::Event<NotificationReceivedDelegate> m_receivedEvent;\n        };\n    }\n}\n\n#endif\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/iOS/Core/String/NSStringUtils.h",
    "content": "//\n//  NSStringUtils.h\n//  ChilliSource\n//  Created by Ian Copland on 04/04/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_IOS\n\n#ifndef _CSBACKEND_PLATFORM_IOS_CORE_STRING_NSSTRINGUTILS_H_\n#define _CSBACKEND_PLATFORM_IOS_CORE_STRING_NSSTRINGUTILS_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <CSBackend/Platform/iOS/ForwardDeclarations.h>\n\n#include <Foundation/Foundation.h>\n\n//------------------------------------------------------------------\n/// A collection of functions for working with NSStrings on iOS,\n/// for example functions for converting to and from std::string.\n///\n/// @author Ian Copland\n//------------------------------------------------------------------\n@interface NSStringUtils : NSObject \n{\n}\n//----------------------------------------------------------\n/// Converts from a NSString to a std::string\n///\n/// @author S Downie\n///\n/// @param The NSString\n///\n/// @return The std::string containing UTF-8 codepoints\n//----------------------------------------------------------\n+ (std::string) newUTF8StringWithNSString:(NSString*)string;\n//----------------------------------------------------------\n/// Converts from an std::string to a NSString.\n///\n/// @author S Downie\n///\n/// @param The std::string of UTF-8 codepoints.\n///\n/// @return The NSString.\n//----------------------------------------------------------\n+ (NSString*) newNSStringWithUTF8String:(const std::string&)string;\n\n@end\n\n#endif\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/iOS/Core/String/NSStringUtils.mm",
    "content": "//\n//  NSStringUtils.cpp\n//  ChilliSource\n//  Created by Ian Copland on 04/04/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_IOS\n\n#import <CSBackend/Platform/iOS/Core/String/NSStringUtils.h>\n\n@implementation NSStringUtils\n\n//----------------------------------------------------------\n//----------------------------------------------------------\n+ (std::string) newUTF8StringWithNSString:(NSString*)string\n{\n    if(string == nil)\n    {\n        return \"\";\n    }\n    \n    return [string cStringUsingEncoding:NSUTF8StringEncoding];\n}\n//----------------------------------------------------------\n//----------------------------------------------------------\n+ (NSString*) newNSStringWithUTF8String:(const std::string&)string\n{\n    if(string.length() == 0)\n    {\n        return [[NSString alloc] init];\n    }\n    \n    NSStringEncoding encode = CFStringConvertEncodingToNSStringEncoding (kCFStringEncodingUTF8);\n    return [[NSString alloc] initWithBytes:string.data() length:string.size() encoding:encode];\n}\n\n@end\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/iOS/ForwardDeclarations.h",
    "content": "//\n//  ForwardDeclarations.h\n//  ChilliSource\n//  Created by Ian Copland on 04/03/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_IOS\n\n#ifndef _CSBACKEND_PLATFORM_IOS_FORWARDDECLARATIONS_H_\n#define _CSBACKEND_PLATFORM_IOS_FORWARDDECLARATIONS_H_\n\n#include <ChilliSource/Core/Base/StandardMacros.h>\n\n#include <memory>\n\nnamespace CSBackend\n{\n    namespace iOS\n    {\n        //------------------------------------------------------\n\t\t/// Core\n\t\t//------------------------------------------------------\n\t\tCS_FORWARDDECLARE_CLASS(PlatformSystem);\n        CS_FORWARDDECLARE_CLASS(DialogueBoxSystem);\n        CS_FORWARDDECLARE_CLASS(FileSystem);\n        CS_FORWARDDECLARE_CLASS(PNGImageProvider);\n        CS_FORWARDDECLARE_CLASS(LocalNotificationSystem);\n        CS_FORWARDDECLARE_CLASS(RemoteNotificationSystem);\n        CS_FORWARDDECLARE_CLASS(Screen);\n        //------------------------------------------------------\n\t\t/// Input\n\t\t//------------------------------------------------------\n        CS_FORWARDDECLARE_CLASS(Accelerometer);\n        CS_FORWARDDECLARE_CLASS(DeviceButtonSystem);\n        CS_FORWARDDECLARE_CLASS(Gyroscope);\n        CS_FORWARDDECLARE_CLASS(PointerSystem);\n        CS_FORWARDDECLARE_CLASS(TextEntry);\n        //------------------------------------------------------\n\t\t/// Networking\n\t\t//------------------------------------------------------\n        CS_FORWARDDECLARE_CLASS(TouchScreen);\n        CS_FORWARDDECLARE_CLASS(HttpRequestSystem);\n        CS_FORWARDDECLARE_CLASS(HttpRequest);\n        CS_FORWARDDECLARE_CLASS(IAPSystem);\n        //------------------------------------------------------\n\t\t/// Social\n\t\t//------------------------------------------------------\n        CS_FORWARDDECLARE_CLASS(EmailComposer);\n        //------------------------------------------------------\n\t\t/// Video\n\t\t//------------------------------------------------------\n        CS_FORWARDDECLARE_CLASS(VideoPlayer);\n        //------------------------------------------------------\n\t\t/// Web\n\t\t//------------------------------------------------------\n        CS_FORWARDDECLARE_CLASS(WebView);\n    }\n}\n\n#endif\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/iOS/Input/Accelerometer/Accelerometer.h",
    "content": "//\n//  Accelerometer.h\n//  ChilliSource\n//  Created by Scott Downie on 15/11/2010\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2010 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_IOS\n\n#ifndef _CSBACKEND_IOS_INPUT_ACCELEROMETER_ACCELEROMETER_H_\n#define _CSBACKEND_IOS_INPUT_ACCELEROMETER_ACCELEROMETER_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <CSBackend/Platform/iOS/ForwardDeclarations.h>\n#include <ChilliSource/Input/Accelerometer/Accelerometer.h>\n\n@class CMAccelerometerData;\n@class CMMotionManager;\n@class NSError;\n\nnamespace CSBackend\n{\n\tnamespace iOS\n\t{\n        //------------------------------------------------------------\n        /// The iOS backend implementation of the Accelerometer.\n        ///\n        /// @author S Downie\n        //------------------------------------------------------------\n\t\tclass Accelerometer final : public ChilliSource::Accelerometer\n\t\t{\n\t\tpublic:\n            CS_DECLARE_NAMEDTYPE(Accelerometer);\n            //----------------------------------------------------\n            /// Returns whether or not this is supported on this\n            /// device. This should be called prior to allocating\n            /// the system.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @return Whether or not the accelerometer is supported\n            /// on this device.\n            //----------------------------------------------------\n            static bool IsSupportedByDevice();\n            //----------------------------------------------------\n\t\t\t/// Queries whether or not this system implements the\n            /// interface with the given ID.\n            ///\n            /// @author S McGaw\n            ///\n            /// @param The interface Id.\n            ///\n\t\t\t/// @return Whether or not the interface is implemented.\n\t\t\t//----------------------------------------------------\n            bool IsA(ChilliSource::InterfaceIDType in_interfaceId) const override;\n            //----------------------------------------------------\n            /// @author Ian Copland\n\t\t\t///\n\t\t\t/// @return whether or not the accelerometer is\n            /// currently updating.\n\t\t\t//----------------------------------------------------\n\t\t\tbool IsUpdating() const override;\n\t\t\t//----------------------------------------------------\n\t\t\t/// Start listening for accelerometer changes.\n            ///\n            /// @author Ian Copland\n\t\t\t//----------------------------------------------------\n\t\t\tvoid StartUpdating() override;\n            \n\t\t\t//----------------------------------------------------\n\t\t\t/// @author Ian Copland\n            ///\n\t\t\t/// @return The acceleration in Gs.\n\t\t\t//----------------------------------------------------\n            ChilliSource::Vector3 GetAcceleration() const override;\n            //----------------------------------------------------\n\t\t\t/// @author Ian Copland\n\t\t\t///\n\t\t\t/// @return An event that is invoked every time the\n\t\t\t/// acceleration is updated. The acceleration will not\n\t\t\t/// necessarily have changed between updates.\n\t\t\t//----------------------------------------------------\n\t\t\tChilliSource::IConnectableEvent<AccelerationUpdatedDelegate>& GetAccelerationUpdatedEvent() override;\n\t\t\t//----------------------------------------------------\n\t\t\t/// Stop listening for accelerometer changes.\n            ///\n            /// @author Ian Copland\n\t\t\t//----------------------------------------------------\n\t\t\tvoid StopUpdating() override;\n\t\tprivate:\n            friend ChilliSource::AccelerometerUPtr ChilliSource::Accelerometer::Create();\n            \n            //----------------------------------------------------\n\t\t\t/// Constructor. Declared private to force the use of\n            /// the factory method.\n            ///\n            /// @author S Downie\n\t\t\t//----------------------------------------------------\n\t\t\tAccelerometer();\n            //----------------------------------------------------\n\t\t\t/// Initialises the system. This is called at a time\n            /// when all systems have already been added.\n            ///\n            /// @author Ian Copland\n\t\t\t//----------------------------------------------------\n            void OnInit() override;\n            \n            ///\n            /// Grabs the data from the motion device and calls\n            /// the event. Also updates the data used for polling\n            ///\n            /// @param deltaSecs\n            ///     Time since last frame in seconds\n            ///\n            void OnUpdate(f32 deltaSecs) override;\n            \n            //----------------------------------------------------\n            /// This is called whenever the acceleration is\n            /// updated through iOS CMMotionManager events\n            ///\n            /// @author Jordan Brown\n            ///\n            /// @param accelerometerData - New accelerometer data\n            /// generated by event.\n            //----------------------------------------------------\n            void OnAccelerationUpdated(CMAccelerometerData* accelerometerData) noexcept;\n            //----------------------------------------------------\n\t\t\t/// Destroys the system immediately before systems\n            /// are removed from the application.\n            ///\n            /// @author Ian Copland\n\t\t\t//----------------------------------------------------\n            void OnDestroy() override;\n            \n            bool m_isUpdating;\n            CMMotionManager* m_motionManager;\n            ChilliSource::Event<AccelerationUpdatedDelegate> m_accelerationUpdatedEvent;\n            ChilliSource::Vector3 m_acceleration;\n\t\t};\n\t}\n}\n\n#endif\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/iOS/Input/Accelerometer/Accelerometer.mm",
    "content": "//\n//  Accelerometer.mm\n//  ChilliSource\n//  Created by Scott Downie on 15/11/2010\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2010 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_IOS\n\n#import <CSBackend/Platform/iOS/Input/Accelerometer/Accelerometer.h>\n\n#import <ChilliSource/Core/Base/Application.h>\n#import <ChilliSource/Core/Base/AppConfig.h>\n#import <ChilliSource/Core/Math/MathUtils.h>\n#import <ChilliSource/Core/Threading/TaskScheduler.h>\n\n#import <CoreMotion/CoreMotion.h>\n#import <Foundation/Foundation.h>\n#import <UIKit/UIKit.h>\n\nnamespace CSBackend\n{\n\tnamespace iOS\n\t{\n        CS_DEFINE_NAMEDTYPE(Accelerometer);\n        //----------------------------------------------------\n        //----------------------------------------------------\n        bool Accelerometer::IsSupportedByDevice()\n        {\n            if(NSClassFromString(@\"CMMotionManager\") == nil)\n                return false;\n            \n            CMMotionManager* manager = [[CMMotionManager alloc] init];\n            bool supported = manager.accelerometerAvailable;\n            [manager release];\n            \n            return supported;\n        }\n        //----------------------------------------------------\n        //----------------------------------------------------\n        Accelerometer::Accelerometer()\n            : m_isUpdating(false), m_motionManager(nil)\n        {\n            CS_ASSERT(IsSupportedByDevice(), \"Cannot create accelerometer on device that does not support it!\");\n        }\n        //----------------------------------------------------\n        //----------------------------------------------------\n        bool Accelerometer::IsA(ChilliSource::InterfaceIDType in_interfaceID) const\n        {\n            return (in_interfaceID == ChilliSource::Accelerometer::InterfaceID || in_interfaceID == Accelerometer::InterfaceID);\n        }\n        //----------------------------------------------------\n        //----------------------------------------------------\n        bool Accelerometer::IsUpdating() const\n        {\n            return m_isUpdating;\n        }\n        //----------------------------------------------------\n        //----------------------------------------------------\n        void Accelerometer::StartUpdating()\n        {\n            CS_RELEASE_ASSERT(ChilliSource::Application::Get()->GetTaskScheduler()->IsMainThread(), \"Tried to start accelerometer updating from background thread.\");\n            if (m_isUpdating == false)\n            {\n                m_isUpdating = true;\n                [m_motionManager startAccelerometerUpdates];\n            }\n        }\n        \n        //----------------------------------------------------\n        void Accelerometer::OnUpdate(f32 deltaSecs)\n        {\n            if(m_isUpdating == true)\n            {\n                OnAccelerationUpdated(m_motionManager.accelerometerData);\n            }\n        }\n        \n        //----------------------------------------------------\n        //----------------------------------------------------\n        ChilliSource::Vector3 Accelerometer::GetAcceleration() const\n        {\n            CS_RELEASE_ASSERT(ChilliSource::Application::Get()->GetTaskScheduler()->IsMainThread(), \"Tried to get current acceleration from background thread.\");\n            return m_acceleration;\n        }\n        //----------------------------------------------------\n        //----------------------------------------------------\n        ChilliSource::IConnectableEvent<Accelerometer::AccelerationUpdatedDelegate>& Accelerometer::GetAccelerationUpdatedEvent()\n        {\n            return m_accelerationUpdatedEvent;\n        }\n        //----------------------------------------------------\n        //----------------------------------------------------\n        void Accelerometer::StopUpdating()\n        {\n            CS_RELEASE_ASSERT(ChilliSource::Application::Get()->GetTaskScheduler()->IsMainThread(), \"Tried to stop accelerometer updating from background thread.\");\n            if (m_isUpdating == true)\n            {\n                m_isUpdating = false;\n                ChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_system, [=](const ChilliSource::TaskContext& taskContext)\n                {\n                    [m_motionManager stopAccelerometerUpdates];\n                });\n            }\n        }\n        //----------------------------------------------------\n        //----------------------------------------------------\n        void Accelerometer::OnInit()\n        {\n            m_motionManager = [[CMMotionManager alloc] init];\n            m_motionManager.accelerometerUpdateInterval = 1.0f / ChilliSource::Application::Get()->GetAppConfig()->GetPreferredFPS();\n        }\n        //----------------------------------------------------\n        //----------------------------------------------------\n        void Accelerometer::OnAccelerationUpdated(CMAccelerometerData* accelerometerData) noexcept\n        {\n            ChilliSource::Matrix4 orientationTransform;\n            switch ([UIApplication sharedApplication].keyWindow.rootViewController.interfaceOrientation)\n            {\n                case UIInterfaceOrientationPortrait:\n                    orientationTransform = ChilliSource::Matrix4::k_identity;\n                    break;\n                case UIInterfaceOrientationLandscapeLeft:\n                    orientationTransform = ChilliSource::Matrix4::CreateRotationZ(ChilliSource::MathUtils::k_pi * 1.5f);\n                    break;\n                case UIInterfaceOrientationLandscapeRight:\n                    orientationTransform = ChilliSource::Matrix4::CreateRotationZ(ChilliSource::MathUtils::k_pi * 0.5f);\n                    break;\n                case UIInterfaceOrientationPortraitUpsideDown:\n                    orientationTransform = ChilliSource::Matrix4::CreateRotationZ(ChilliSource::MathUtils::k_pi);\n                    break;\n                default:\n                    CS_LOG_ERROR(\"Unknown orientation!\");\n                    orientationTransform = ChilliSource::Matrix4::k_identity;\n                    break;\n            }\n            \n            ChilliSource::Vector3 newAcceleration(accelerometerData.acceleration.x, accelerometerData.acceleration.y, accelerometerData.acceleration.z);\n            newAcceleration.Transform3x4(orientationTransform);\n            \n            ChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_mainThread, [=](const ChilliSource::TaskContext& taskContext)\n            {\n                m_acceleration = newAcceleration;\n                m_accelerationUpdatedEvent.NotifyConnections(m_acceleration);\n            });\n        }\n        //----------------------------------------------------\n        //----------------------------------------------------\n        void Accelerometer::OnDestroy()\n        {\n            [m_motionManager release];\n            m_motionManager = nil;\n        }\n\t}\n}\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/iOS/Input/DeviceButtons/DeviceButtonSystem.h",
    "content": "//\n//  DeviceButtonSystem.h\n//  ChilliSource\n//  Created by Ian Copland on 16/05/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_IOS\n\n#import <ChilliSource/ChilliSource.h>\n#import <CSBackend/Platform/iOS/ForwardDeclarations.h>\n#import <ChilliSource/Input/DeviceButtons/DeviceButtonSystem.h>\n\nnamespace CSBackend\n{\n\tnamespace iOS\n\t{\n        //------------------------------------------------------------\n        /// The iOS backend implementation of the Device Button System.\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------------------\n\t\tclass DeviceButtonSystem final : public ChilliSource::DeviceButtonSystem\n\t\t{\n\t\tpublic:\n            CS_DECLARE_NAMEDTYPE(DeviceButtonSystem);\n            //----------------------------------------------------\n\t\t\t/// Queries whether or not this system implements the\n            /// interface with the given ID.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param The interface Id.\n            ///\n\t\t\t/// @return Whether or not the interface is implemented.\n\t\t\t//----------------------------------------------------\n            bool IsA(ChilliSource::InterfaceIDType in_interfaceId) const override;\n            //----------------------------------------------------\n\t\t\t/// @author Ian Copland\n            ///\n            /// @return An event that will be called whenever a\n            /// device button is triggered.\n\t\t\t//----------------------------------------------------\n            ChilliSource::IConnectableEvent<TriggeredDelegate>& GetTriggeredEvent() override;\n\t\tprivate:\n            friend ChilliSource::DeviceButtonSystemUPtr ChilliSource::DeviceButtonSystem::Create();\n            \n            //----------------------------------------------------\n\t\t\t/// Constructor. Declared private to force the use of\n            /// the factory method.\n            ///\n            /// @author Ian Copland\n\t\t\t//----------------------------------------------------\n\t\t\tDeviceButtonSystem() = default;\n\n            ChilliSource::Event<TriggeredDelegate> m_triggeredEvent;\n\t\t};\n\t}\n}\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/iOS/Input/DeviceButtons/DeviceButtonSystem.mm",
    "content": "//\n//  DeviceButtonSystem.mm\n//  ChilliSource\n//  Created by Ian Copland on 16/05/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_IOS\n\n#import <CSBackend/Platform/iOS/Input/DeviceButtons/DeviceButtonSystem.h>\n\nnamespace CSBackend\n{\n\tnamespace iOS\n\t{\n        CS_DEFINE_NAMEDTYPE(DeviceButtonSystem);\n        //----------------------------------------------------\n        //----------------------------------------------------\n        bool DeviceButtonSystem::IsA(ChilliSource::InterfaceIDType in_interfaceID) const\n        {\n            return (in_interfaceID == ChilliSource::DeviceButtonSystem::InterfaceID || in_interfaceID == DeviceButtonSystem::InterfaceID);\n        }\n        //----------------------------------------------------\n        //----------------------------------------------------\n        ChilliSource::IConnectableEvent<DeviceButtonSystem::TriggeredDelegate>& DeviceButtonSystem::GetTriggeredEvent()\n        {\n            return m_triggeredEvent;\n        }\n\t}\n}\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/iOS/Input/Gyroscope/Gyroscope.h",
    "content": "//\n//  Gyroscope.h\n//  ChilliSource\n//  Created by Jordan Brown on 19/01/2017\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2017 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_IOS\n\n#ifndef _CSBACKEND_IOS_INPUT_GYROSCOPE_GYROSCOPE_H_\n#define _CSBACKEND_IOS_INPUT_GYROSCOPE_GYROSCOPE_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <CSBackend/Platform/iOS/ForwardDeclarations.h>\n#include <ChilliSource/Input/Gyroscope/Gyroscope.h>\n\n@class CMDeviceMotion;\n@class CMMotionManager;\n@class NSError;\n\nnamespace CSBackend\n{\n    namespace iOS\n    {\n        //------------------------------------------------------------\n        /// The iOS backend implementation of the Gyroscope.\n        ///\n        /// @author J Brown\n        //------------------------------------------------------------\n        class Gyroscope final : public ChilliSource::Gyroscope\n        {\n        public:\n            CS_DECLARE_NAMEDTYPE(Gyroscope);\n            //----------------------------------------------------\n            /// Returns whether or not this is supported on this\n            /// device. This should be called prior to allocating\n            /// the system.\n            ///\n            /// @author J Brown\n            ///\n            /// @return Whether or not the Gyroscope is supported\n            /// on this device.\n            //----------------------------------------------------\n            static bool IsSupportedByDevice();\n            //----------------------------------------------------\n            /// Queries whether or not this system implements the\n            /// interface with the given ID.\n            ///\n            /// @author J Brown\n            ///\n            /// @param The interface Id.\n            ///\n            /// @return Whether or not the interface is implemented.\n            //----------------------------------------------------\n            bool IsA(ChilliSource::InterfaceIDType in_interfaceId) const override;\n            //----------------------------------------------------\n            /// @author J Brown\n            ///\n            /// @return whether or not the gyroscope is\n            /// currently updating.\n            //----------------------------------------------------\n            bool IsUpdating() const override;\n            //----------------------------------------------------\n            /// Start listening for gyroscope changes.\n            ///\n            /// @author J Brown\n            //----------------------------------------------------\n            void StartUpdating() override;\n            \n            //----------------------------------------------------\n            /// @author J Brown\n            ///\n            /// @return The physical orientation of the device.\n            //----------------------------------------------------\n            ChilliSource::Quaternion GetOrientation() const override;\n            //----------------------------------------------------\n            /// @author J Brown\n            ///\n            /// @return An event that is invoked every time the\n            /// orientation is updated. The orientation will not\n            /// necessarily have changed between updates.\n            //----------------------------------------------------\n            ChilliSource::IConnectableEvent<OrientationUpdatedDelegate>& GetOrientationUpdatedEvent() override;\n            //----------------------------------------------------\n            /// Stop listening for orientation changes.\n            ///\n            /// @author J Brown\n            //----------------------------------------------------\n            void StopUpdating() override;\n        private:\n            friend ChilliSource::GyroscopeUPtr ChilliSource::Gyroscope::Create();\n            \n            //----------------------------------------------------\n            /// Constructor. Declared private to force the use of\n            /// the factory method.\n            ///\n            /// @author J Brown\n            //----------------------------------------------------\n            Gyroscope();\n            //----------------------------------------------------\n            /// Initialises the system. This is called at a time\n            /// when all systems have already been added.\n            ///\n            /// @author J Brown\n            //----------------------------------------------------\n            void OnInit() override;\n            \n            ///\n            /// Grabs the data from the motion device and calls\n            /// the event. Also updates the data used for polling\n            ///\n            /// @param deltaSecs\n            ///     Time since last frame in seconds\n            ///\n            void OnUpdate(f32 deltaSecs) override;\n            \n            //----------------------------------------------------\n            /// This is called whenever the devicemotion is\n            /// updated through iOS CMMotionManager events\n            ///\n            /// @author Jordan Brown\n            ///\n            /// @param deviceMotionData\n            ///     New orientation data generated by event.\n            //----------------------------------------------------\n            void OnDeviceMotionUpdated(CMDeviceMotion* deviceMotionData) noexcept;\n            //----------------------------------------------------\n            /// Destroys the system immediately before systems\n            /// are removed from the application.\n            ///\n            /// @author J Brown\n            //----------------------------------------------------\n            void OnDestroy() override;\n            \n            bool m_isUpdating;\n            CMMotionManager* m_motionManager;\n            ChilliSource::Event<OrientationUpdatedDelegate> m_orientationUpdatedEvent;\n            ChilliSource::Quaternion m_orientation;\n        };\n    }\n}\n\n#endif\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/iOS/Input/Gyroscope/Gyroscope.mm",
    "content": "//\n//  Gyroscope.mm\n//  ChilliSource\n//  Created by Jordan Brown on 19/01/2017\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2017 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_IOS\n\n#import <CSBackend/Platform/iOS/Input/Gyroscope/Gyroscope.h>\n\n#import <ChilliSource/Core/Base/Application.h>\n#import <ChilliSource/Core/Base/AppConfig.h>\n#import <ChilliSource/Core/Math/MathUtils.h>\n#import <ChilliSource/Core/Threading/TaskScheduler.h>\n\n#import <CoreMotion/CoreMotion.h>\n#import <Foundation/Foundation.h>\n#import <UIKit/UIKit.h>\n\nnamespace CSBackend\n{\n    namespace iOS\n    {\n        CS_DEFINE_NAMEDTYPE(Gyroscope);\n        //----------------------------------------------------\n        //----------------------------------------------------\n        bool Gyroscope::IsSupportedByDevice()\n        {\n            if(NSClassFromString(@\"CMMotionManager\") == nil)\n                return false;\n            \n            CMMotionManager* manager = [[CMMotionManager alloc] init];\n            bool supported = manager.deviceMotionAvailable;\n            [manager release];\n            \n            return supported;\n        }\n        //----------------------------------------------------\n        //----------------------------------------------------\n        Gyroscope::Gyroscope()\n        : m_isUpdating(false), m_motionManager(nil)\n        {\n            CS_ASSERT(IsSupportedByDevice(), \"Cannot create gyroscope on device that does not support it!\");\n        }\n        //----------------------------------------------------\n        //----------------------------------------------------\n        bool Gyroscope::IsA(ChilliSource::InterfaceIDType in_interfaceID) const\n        {\n            return (in_interfaceID == ChilliSource::Gyroscope::InterfaceID || in_interfaceID == Gyroscope::InterfaceID);\n        }\n        //----------------------------------------------------\n        //----------------------------------------------------\n        bool Gyroscope::IsUpdating() const\n        {\n            return m_isUpdating;\n        }\n        //----------------------------------------------------\n        //----------------------------------------------------\n        void Gyroscope::StartUpdating()\n        {\n            CS_RELEASE_ASSERT(ChilliSource::Application::Get()->GetTaskScheduler()->IsMainThread(), \"Tried to start gyroscope updating from background thread.\");\n            if (m_isUpdating == false)\n            {\n                m_isUpdating = true;\n                [m_motionManager startDeviceMotionUpdatesUsingReferenceFrame:CMAttitudeReferenceFrameXArbitraryZVertical];\n            }\n        }\n        \n        //----------------------------------------------------\n        void Gyroscope::OnUpdate(f32 deltaSecs)\n        {\n            if(m_isUpdating == true)\n            {\n                OnDeviceMotionUpdated(m_motionManager.deviceMotion);\n            }\n        }\n        \n        //----------------------------------------------------\n        //----------------------------------------------------\n        ChilliSource::Quaternion Gyroscope::GetOrientation() const\n        {\n            CS_RELEASE_ASSERT(ChilliSource::Application::Get()->GetTaskScheduler()->IsMainThread(), \"Tried to get current gyro orientation from background thread.\");\n            return m_orientation;\n        }\n        //----------------------------------------------------\n        //----------------------------------------------------\n        ChilliSource::IConnectableEvent<Gyroscope::OrientationUpdatedDelegate>& Gyroscope::GetOrientationUpdatedEvent()\n        {\n            return m_orientationUpdatedEvent;\n        }\n        //----------------------------------------------------\n        //----------------------------------------------------\n        void Gyroscope::StopUpdating()\n        {\n            CS_RELEASE_ASSERT(ChilliSource::Application::Get()->GetTaskScheduler()->IsMainThread(), \"Tried to stop gyroscope updating from background thread.\");\n            if (m_isUpdating == true)\n            {\n                m_isUpdating = false;\n                ChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_system, [=](const ChilliSource::TaskContext& taskContext)\n                {\n                    [m_motionManager stopDeviceMotionUpdates];\n                });\n            }\n        }\n        //----------------------------------------------------\n        //----------------------------------------------------\n        void Gyroscope::OnInit()\n        {\n            m_motionManager = [[CMMotionManager alloc] init];\n            m_motionManager.gyroUpdateInterval = 1.0f / ChilliSource::Application::Get()->GetAppConfig()->GetPreferredFPS();\n        }\n        //----------------------------------------------------\n        //----------------------------------------------------\n        void Gyroscope::OnDeviceMotionUpdated(CMDeviceMotion* deviceMotionData) noexcept\n        {\n            ChilliSource::Quaternion newOrientation;\n            newOrientation.x = deviceMotionData.attitude.quaternion.x;\n            newOrientation.y = deviceMotionData.attitude.quaternion.y;\n            newOrientation.z = deviceMotionData.attitude.quaternion.z;\n            newOrientation.w = deviceMotionData.attitude.quaternion.w;\n            \n            ChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_mainThread, [=](const ChilliSource::TaskContext& taskContext)\n            {\n                m_orientation = newOrientation;\n                m_orientationUpdatedEvent.NotifyConnections(m_orientation);\n            });\n        }\n        //----------------------------------------------------\n        //----------------------------------------------------\n        void Gyroscope::OnDestroy()\n        {\n            [m_motionManager release];\n            m_motionManager = nil;\n        }\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/iOS/Input/Pointer/PointerSystem.h",
    "content": "//\n//  PointerSystem.h\n//  ChilliSource\n//  Created by Ian Copland on 26/03/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_IOS\n\n#ifndef _CSBACKEND_PLATFORM_IOS_INPUT_POINTER_POINTERSYSTEM_H_\n#define _CSBACKEND_PLATFORM_IOS_INPUT_POINTER_POINTERSYSTEM_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <CSBackend/Platform/iOS/ForwardDeclarations.h>\n#include <ChilliSource/Input/Pointer/PointerSystem.h>\n\n#include <unordered_map>\n\n@class UITouch;\n\nnamespace CSBackend\n{\n    namespace iOS\n    {\n        //------------------------------------------------------------\n        /// The iOS backend for the pointer system. This provides\n        /// access to touch events.\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------------------\n        class PointerSystem final : public ChilliSource::PointerSystem\n        {\n        public:\n            CS_DECLARE_NAMEDTYPE(PointerSystem);\n            //----------------------------------------------------\n\t\t\t/// Queries whether or not this system implements the\n            /// interface with the given ID.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param The interface Id.\n            ///\n\t\t\t/// @return Whether or not the interface is implemented.\n\t\t\t//----------------------------------------------------\n            bool IsA(ChilliSource::InterfaceIDType in_interfaceId) const override;\n            //----------------------------------------------------\n\t\t\t/// Called when a touch begin event is received.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param The touch.\n\t\t\t//----------------------------------------------------\n            void OnTouchBegan(UITouch* in_touch);\n            //----------------------------------------------------\n\t\t\t/// Called when a touch moved event is received.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param The touch.\n\t\t\t//----------------------------------------------------\n\t\t\tvoid OnTouchMoved(UITouch* in_touch);\n            //----------------------------------------------------\n\t\t\t/// Called when a touch ended event is received.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param The touch.\n\t\t\t//----------------------------------------------------\n\t\t\tvoid OnTouchEnded(UITouch* in_touch);\n            //----------------------------------------------------\n            /// iOS has no cursor so this does nothing\n            ///\n            /// @author S Downie\n            //----------------------------------------------------\n            void HideSystemCursor() override {};\n            //----------------------------------------------------\n            /// iOS has no cursor so this does nothing\n            ///\n            /// @author S Downie\n            //----------------------------------------------------\n            void ShowSystemCursor() override {};\n        private:\n            friend class ChilliSource::PointerSystem;\n            \n            //------------------------------------------------\n            /// Default constructor. Declared private to force\n            /// the use of the factory method.\n            ///\n            /// @author Ian Copland\n            //------------------------------------------------\n            PointerSystem() = default;\n            //------------------------------------------------\n            /// Initialisation method called at a time when\n            /// all App Systems have been created. System\n            /// initialisation occurs in the order they were\n            /// created.\n            ///\n            /// @author Ian Copland\n            //------------------------------------------------\n            void OnInit() override;\n            //------------------------------------------------\n            /// Called when the application is being destroyed.\n            /// This should be used to cleanup memory and\n            /// references to other systems. System destruction\n            /// occurs in the reverse order to which they\n            /// were created\n            ///\n            /// @author Ian Copland\n            //------------------------------------------------\n            void OnDestroy() override;\n            \n            std::unordered_map<UITouch*, ChilliSource::Pointer::Id> m_touchToIdMap;\n            ChilliSource::Screen* m_screen;\n        };\n    }\n}\n\n#endif\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/iOS/Input/Pointer/PointerSystem.mm",
    "content": "//\n//  PointerSystem.mm\n//  ChilliSource\n//  Created by Ian Copland on 26/03/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_IOS\n\n#import <CSBackend/Platform/iOS/Input/Pointer/PointerSystem.h>\n\n#import <ChilliSource/Core/Base/Application.h>\n#import <ChilliSource/Core/Base/Screen.h>\n\n#import <UIKit/UIKit.h>\n\nnamespace CSBackend\n{\n    namespace iOS\n    {\n        CS_DEFINE_NAMEDTYPE(PointerSystem);\n        //----------------------------------------------------\n        //----------------------------------------------------\n        bool PointerSystem::IsA(ChilliSource::InterfaceIDType in_interfaceId) const\n        {\n            return (ChilliSource::PointerSystem::InterfaceID == in_interfaceId || PointerSystem::InterfaceID == in_interfaceId);\n        }\n        //----------------------------------------------------\n        //----------------------------------------------------\n        void PointerSystem::OnTouchBegan(UITouch* in_touch)\n        {\n            //Grab the touch location from the OS\n\t\t\tCGPoint uitouchLocation = [in_touch locationInView:in_touch.view];\n            ChilliSource::Vector2 touchLocation(uitouchLocation.x * m_screen->GetDensityScale(), m_screen->GetResolution().y - uitouchLocation.y * m_screen->GetDensityScale());\n\t\t\tu64 pointerId = AddPointerCreateEvent(touchLocation);\n            AddPointerDownEvent(pointerId, ChilliSource::Pointer::InputType::k_touch);\n\t\t\tm_touchToIdMap.emplace(in_touch, pointerId);\n        }\n        //----------------------------------------------------\n        //----------------------------------------------------\n        void PointerSystem::OnTouchMoved(UITouch* in_touch)\n        {\n            auto it = m_touchToIdMap.find(in_touch);\n\t\t\tif (it != m_touchToIdMap.end())\n\t\t\t{\n                CGPoint uitouchLocation = [in_touch locationInView:in_touch.view];\n                ChilliSource::Vector2 touchLocation(uitouchLocation.x * m_screen->GetDensityScale(), m_screen->GetResolution().y - uitouchLocation.y * m_screen->GetDensityScale());\n\t\t\t\tAddPointerMovedEvent(it->second, touchLocation);\n\t\t\t}\n        }\n        //----------------------------------------------------\n        //----------------------------------------------------\n        void PointerSystem::OnTouchEnded(UITouch* in_touch)\n        {\n            auto it = m_touchToIdMap.find(in_touch);\n\t\t\tif (it != m_touchToIdMap.end())\n\t\t\t{\n\t\t\t\tAddPointerUpEvent(it->second, ChilliSource::Pointer::InputType::k_touch);\n                AddPointerRemoveEvent(it->second);\n                m_touchToIdMap.erase(it);\n\t\t\t}\n        }\n        //------------------------------------------------\n        //------------------------------------------------\n        void PointerSystem::OnInit()\n        {\n            m_screen = ChilliSource::Application::Get()->GetSystem<ChilliSource::Screen>();\n        }\n        //------------------------------------------------\n        //------------------------------------------------\n        void PointerSystem::OnDestroy()\n        {\n            RemoveAllPointers();\n            m_screen = nullptr;\n        }\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/iOS/Input/TextEntry/TextEntry.h",
    "content": "//\n//  TextEntry.h\n//  ChilliSource\n//  Created by Scott Downie on 08/07/2014\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_IOS\n\n#ifndef _CSBACKEND_PLATFORM_IOS_INPUT_TEXTENTRY_TEXTENTRY_H_\n#define _CSBACKEND_PLATFORM_IOS_INPUT_TEXTENTRY_TEXTENTRY_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <CSBackend/Platform/iOS/ForwardDeclarations.h>\n#include <ChilliSource/Input/TextEntry/TextEntry.h>\n#include <ChilliSource/Input/TextEntry/TextEntryCapitalisation.h>\n#include <ChilliSource/Input/TextEntry/TextEntryType.h>\n\n#include <mutex>\n\n@class TextEntryDelegate;\n@class UITextField;\n@class NSString;\n\nnamespace CSBackend\n{\n\tnamespace iOS\n\t{\n        //----------------------------------------------------------------\n        /// The iOS backend to the text entry system. This provides access\n        /// to the iOS virtual keyboard functionality via a text buffer\n        ///\n        /// @author S Downie\n        //----------------------------------------------------------------\n\t\tclass TextEntry final : public ChilliSource::TextEntry\n\t\t{\n\t\tpublic:\n            \n            CS_DECLARE_NAMEDTYPE(TextEntry);\n            //-------------------------------------------------------\n            /// @author S Downie\n            ///\n            /// @param Interface ID\n            ///\n            /// @return Whether this system implements the given inteface\n            //-------------------------------------------------------\n            bool IsA(ChilliSource::InterfaceIDType in_interfaceId) const override;\n            //-------------------------------------------------------\n            /// The system will now receive text input. This will also\n            /// show the virtual keyboard\n            ///\n            /// @author S Downie\n            ///\n            /// @param Initial buffer contents\n            /// @param Preferred keyboard type\n            /// @param Preferred capitalisation method\n            /// @param Text changed delegate\n            /// @param Deactivate delegate\n            //-------------------------------------------------------\n            void Activate(const std::string& in_text, ChilliSource::TextEntryType in_type, ChilliSource::TextEntryCapitalisation in_capitalisation, const TextBufferChangedDelegate& in_changeDelegate, const TextInputDeactivatedDelegate& in_deactivateDelegate) override;\n            //-------------------------------------------------------\n            /// The system will no longer receive text input. This\n            /// will also hide the virtual keyboard\n            ///\n            /// @author S Downie\n            //-------------------------------------------------------\n            void Deactivate() override;\n            //-------------------------------------------------------\n            /// @author S Downie\n            ///\n            /// This should only be called from the main thread.\n            ///\n            /// @return Whether or not text input is currently\n            /// enabled.\n            //-------------------------------------------------------\n\t\t\tbool IsActive() const override;\n            //-------------------------------------------------------\n            /// @author S Downie\n            ///\n            /// @return The current text input buffer (UTF-8).\n            //-------------------------------------------------------\n\t\t\tconst std::string& GetTextBuffer() const override;\n            //-------------------------------------------------------\n            /// @author S Downie\n            ///\n            /// @param The new text input buffer (UTF-8).\n            //-------------------------------------------------------\n            void SetTextBuffer(const std::string& in_text) override;\n            //-------------------------------------------------------\n            /// Called when the keyboard text is updated.\n            ///\n            /// @author S Downie\n            ///\n            //-------------------------------------------------------\n\t\t\tvoid OnTextUpdated(NSString* in_text);\n            //-------------------------------------------------------\n            /// Destructor.\n            ///\n            /// @author S Downie\n            //-------------------------------------------------------\n\t\t\t~TextEntry();\n\t\tprivate:\n            friend ChilliSource::TextEntryUPtr ChilliSource::TextEntry::Create();\n        \n            //-------------------------------------------------------\n            /// Constructor. Declared private to force the use of the\n            /// factory method.\n            ///\n            /// @author S Downie\n            //-------------------------------------------------------\n\t\t\tTextEntry();\n            //-------------------------------------------------------\n            /// Sets the type of keyboard to display if using a\n            /// virtual keyboard. This must be set prior to the keyboard\n            /// being displayed. Note that this is only a suggestion\n            /// and the virtual keyboard implementation may choose to\n            /// ignore it.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param The keyboard type\n            //-------------------------------------------------------\n            void SetType(ChilliSource::TextEntryType in_type);\n            //-------------------------------------------------------\n            /// Sets capitalisation method to be used for text input.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param The capitalisation method.\n            //-------------------------------------------------------\n            void SetCapitalisation(ChilliSource::TextEntryCapitalisation in_capitalisation);\n            \n            bool m_isActive = false;\n            bool m_isViewSetup = false;\n            \n            UITextField* m_textView;\n            TextEntryDelegate* m_delegate;\n            TextBufferChangedDelegate m_textBufferChangedDelegate;\n            TextInputDeactivatedDelegate m_textInputDeactivatedDelegate;\n            std::string m_text;\n            mutable std::mutex m_mutex;\n        };\n    }\n}\n\n#endif\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/iOS/Input/TextEntry/TextEntry.mm",
    "content": "//\n//  TextEntry.mm\n//  ChilliSource\n//  Created by Scott Downie on 08/07/2014\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_IOS\n\n#import <CSBackend/Platform/iOS/Input/TextEntry/TextEntry.h>\n\n#import <CSBackend/Platform/iOS/Core/String/NSStringUtils.h>\n#import <CSBackend/Platform/iOS/Input/TextEntry/TextEntryDelegate.h>\n#import <ChilliSource/Core/Base/Application.h>\n#import <ChilliSource/Core/Threading/TaskScheduler.h>\n#import <ChilliSource/Core/String/StringUtils.h>\n\n#import <UIKit/UIKit.h>\n\nnamespace CSBackend\n{\n\tnamespace iOS\n\t{\n        CS_DEFINE_NAMEDTYPE(TextEntry);\n        \n        //-------------------------------------------------------\n        //-------------------------------------------------------\n        TextEntry::TextEntry()\n        {\n            m_delegate = [[TextEntryDelegate alloc] initWithTextEntry:this];\n            \n            //Just create it with garbage size as we will never see it\n            m_textView = [[UITextField alloc] initWithFrame:CGRectMake(200, 10, 100, 200)];\n            [m_textView setReturnKeyType:UIReturnKeyDone];\n            m_textView.autocorrectionType = UITextAutocorrectionTypeNo;\n            m_textView.autocapitalizationType = UITextAutocapitalizationTypeNone;\n            m_textView.keyboardType = UIKeyboardTypeASCIICapable;\n            m_textView.delegate = m_delegate;\n            m_textView.hidden = YES;\n        }\n        //-------------------------------------------------------\n        //-------------------------------------------------------\n        bool TextEntry::IsA(ChilliSource::InterfaceIDType in_interfaceId) const\n        {\n            return in_interfaceId == ChilliSource::TextEntry::InterfaceID || in_interfaceId == TextEntry::InterfaceID;\n        }\n        //-------------------------------------------------------\n        //-------------------------------------------------------\n        void TextEntry::Activate(const std::string& in_text, ChilliSource::TextEntryType in_type, ChilliSource::TextEntryCapitalisation in_capitalisation, const TextBufferChangedDelegate& in_changeDelegate, const TextInputDeactivatedDelegate& in_deactivateDelegate)\n        {\n            m_isActive = true;\n            \n            ChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_system, [=](const ChilliSource::TaskContext& taskContext)\n            {\n                if (m_isViewSetup == false && [m_textView canBecomeFirstResponder])\n                {\n                    m_isViewSetup = true;\n                    \n                    SetType(in_type);\n                    SetCapitalisation(in_capitalisation);\n                    SetTextBuffer(in_text);\n                    m_textBufferChangedDelegate = in_changeDelegate;\n                    m_textInputDeactivatedDelegate = in_deactivateDelegate;\n                    \n                    [[UIApplication sharedApplication].keyWindow.rootViewController.view addSubview:m_textView];\n                    [m_textView becomeFirstResponder];\n                }\n            });\n        }\n        //-------------------------------------------------------\n        //-------------------------------------------------------\n        void TextEntry::Deactivate()\n        {\n            m_isActive = false;\n            \n            ChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_system, [=](const ChilliSource::TaskContext& taskContext)\n            {\n                if (m_isViewSetup == true)\n                {\n                    m_isViewSetup = false;\n                    \n                    [m_textView resignFirstResponder];\n                    [m_textView removeFromSuperview];\n                    \n                    ChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_mainThread, [=](const ChilliSource::TaskContext& taskContext)\n                    {\n                        if(m_textInputDeactivatedDelegate != nullptr)\n                        {\n                            auto delegate = m_textInputDeactivatedDelegate;\n                            m_textInputDeactivatedDelegate = nullptr;\n                            delegate();\n                        }\n                    });\n                }\n            });\n        }\n        //-------------------------------------------------------\n        //-------------------------------------------------------\n        bool TextEntry::IsActive() const\n        {\n            return m_isActive;\n        }\n        //-------------------------------------------------------\n        //-------------------------------------------------------\n        const std::string& TextEntry::GetTextBuffer() const\n        {\n            std::unique_lock<std::mutex> lock(m_mutex);\n            return m_text;\n        }\n        //-------------------------------------------------------\n        //-------------------------------------------------------\n        void TextEntry::SetTextBuffer(const std::string& in_text)\n        {\n            ChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_system, [=](const ChilliSource::TaskContext& taskContext)\n            {\n                m_text = in_text;\n                NSString* text = [NSStringUtils newNSStringWithUTF8String:m_text];\n                m_textView.text = text;\n                [text release];\n            });\n        }\n        //-------------------------------------------------------\n        //-------------------------------------------------------\n        void TextEntry::SetType(ChilliSource::TextEntryType in_type)\n        {\n            ChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_system, [=](const ChilliSource::TaskContext& taskContext)\n            {\n                if(m_textView != nullptr)\n                {\n                    switch (in_type)\n                    {\n                        case ChilliSource::TextEntryType::k_text:\n                            m_textView.keyboardType = UIKeyboardTypeASCIICapable;\n                            break;\n                        case ChilliSource::TextEntryType::k_numeric:\n                            m_textView.keyboardType = UIKeyboardTypeNumberPad;\n                            break;\n                        default:\n                            CS_LOG_ERROR(\"Invalid keyboard type passed to keyboard!\");\n                            m_textView.keyboardType = UIKeyboardTypeASCIICapable;\n                            break;\n                    }\n                }\n            });\n        }\n        //-------------------------------------------------------\n        //-------------------------------------------------------\n        void TextEntry::SetCapitalisation(ChilliSource::TextEntryCapitalisation in_capitalisation)\n        {\n            ChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_system, [=](const ChilliSource::TaskContext& taskContext)\n            {\n                if(m_textView != nullptr)\n                {\n                    switch (in_capitalisation)\n                    {\n                        case ChilliSource::TextEntryCapitalisation::k_none:\n                            m_textView.autocapitalizationType = UITextAutocapitalizationTypeNone;\n                            break;\n                        case ChilliSource::TextEntryCapitalisation::k_words:\n                            m_textView.autocapitalizationType = UITextAutocapitalizationTypeWords;\n                            break;\n                        case ChilliSource::TextEntryCapitalisation::k_sentences:\n                            m_textView.autocapitalizationType = UITextAutocapitalizationTypeSentences;\n                            break;\n                        case ChilliSource::TextEntryCapitalisation::k_all:\n                            m_textView.autocapitalizationType = UITextAutocapitalizationTypeAllCharacters;\n                            break;\n                        default:\n                            CS_LOG_WARNING(\"Unknown Capitalisation Method\");\n                            m_textView.autocapitalizationType = UITextAutocapitalizationTypeNone;\n                            break;\n                    }\n                }\n            });\n        }\n        //-------------------------------------------------------\n        //-------------------------------------------------------\n        void TextEntry::OnTextUpdated(NSString* in_text)\n        {\n            auto text = [NSStringUtils newUTF8StringWithNSString:in_text];\n            \n            ChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_mainThread, [=](const ChilliSource::TaskContext& taskContext)\n            {\n                bool acceptText = true;\n                    \n                if(m_textBufferChangedDelegate != nullptr)\n                {\n                    acceptText = m_textBufferChangedDelegate(text);\n                }\n                \n                if(acceptText == true)\n                {\n                    SetTextBuffer(text);\n                }\n            });\n        }\n        //-------------------------------------------------------\n        //-------------------------------------------------------\n        TextEntry::~TextEntry()\n        {\n            if(m_textView != nullptr)\n\t\t\t{\n\t\t\t\t[m_textView release];\n\t\t\t\tm_textView = nil;\n\t\t\t}\n            \n            if(m_delegate != nullptr)\n            {\n                [m_delegate release];\n                m_delegate = nil;\n            }\n        }\n\t}\n}\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/iOS/Input/TextEntry/TextEntryDelegate.h",
    "content": "//\n//  TextEntryDelegate.h\n//  ChilliSource\n//  Created by Scott Downie on 18/07/2011.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2011 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_IOS\n\n#ifndef _CSBACKEND_PLATFORM_IOS_INPUT_TEXTENTRY_TEXTENTRYDELEGATE_H_\n#define _CSBACKEND_PLATFORM_IOS_INPUT_TEXTENTRY_TEXTENTRYDELEGATE_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <CSBackend/Platform/iOS/ForwardDeclarations.h>\n\n#include <UIKit/UIKit.h>\n\n//---------------------------------------------------------\n/// A delegate class for listening for changes from a UI text\n/// field\n///\n/// @author S Downie\n//---------------------------------------------------------\n@interface TextEntryDelegate : NSObject<UITextFieldDelegate>\n{\n    CSBackend::iOS::TextEntry* textEntry;\n}\n//---------------------------------------------------------\n/// Constructor.\n///\n/// @author S Downie\n///\n/// @param The text entry system to notify.\n///\n/// @return The new instance of the delegate.\n//---------------------------------------------------------\n-(TextEntryDelegate*) initWithTextEntry:(CSBackend::iOS::TextEntry*) in_textEntry;\n\n@end\n\n#endif\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/iOS/Input/TextEntry/TextEntryDelegate.mm",
    "content": "//\n//  VirtualTextEntryDelegate.mm\n//  ChilliSource\n//  Created by Scott Downie on 18/07/2011.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2011 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_IOS\n\n#import <CSBackend/Platform/iOS/Input/TextEntry/TextEntryDelegate.h>\n\n#import <CSBackend/Platform/iOS/Input/TextEntry/TextEntry.h>\n\n#import <ChilliSource/Core/Base/Application.h>\n#import <ChilliSource/Core/Threading/TaskScheduler.h>\n\n@implementation TextEntryDelegate\n\n//---------------------------------------------------------\n//---------------------------------------------------------\n-(TextEntryDelegate*) initWithTextEntry:(CSBackend::iOS::TextEntry*) in_textEntry\n{\n    if(self = [super init])\n    {\n        textEntry = in_textEntry;\n        return self;\n    }\n    return nil;\n}\n//---------------------------------------------------------\n/// Called when the text buffer changes.\n///\n/// @author S Downie\n///\n/// @param The text field in which the text has changed.\n/// @param The range of characters that have changed.\n/// @param The replacement string.\n///\n/// @return Whether or not this change has been accepted.\n//---------------------------------------------------------\n-(BOOL) textField:(UITextField*)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString*)string\n{\n    NSString* updateText = [textField.text stringByReplacingCharactersInRange:range withString:string];\n    textEntry->OnTextUpdated(updateText);\n    \n    return false;\n}\n//---------------------------------------------------------\n/// @author S Downie\n///\n/// @param The text field.\n///\n/// @return Whether or not text editing should end.\n//---------------------------------------------------------\n-(BOOL) textFieldShouldReturn:(UITextField*)textField\n{\n    textEntry->Deactivate();\n    return NO;\n}\n\n@end\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/iOS/Main.cpp",
    "content": "//\n//  Main.cpp\n//  ChilliSource\n//  Created by Ian Copland on 06/07/2011.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2010 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_IOS\n\n#include <ChilliSource/Core/Base/Application.h>\n\n#import <UIKit/UIKit.h>\n\n//----------------------------------------------------------------------------------\n/// Includes the \"main\" function as required by iOS and will create\n/// the inherited CS application using the exposed CreateApplication method that\n/// the application code base must implement.\n///\n/// @author S Downie\n///\n/// @param Num arguments from command line\n/// @param Arguments array from command line\n///\n/// @return Exit status\n//----------------------------------------------------------------------------------\nint main(int in_argc, char* in_argv[])\n{\n    @autoreleasepool\n    {\n        s32 retVal = UIApplicationMain(in_argc, in_argv, nil, @\"CSAppDelegate\");\n        return retVal;\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/iOS/Networking/Http/HttpDelegate.h",
    "content": "//\n//  HttpDelegate.h\n//  ChilliSource\n//  Created by Ian Copland on 11/12/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_IOS\n\n#include <ChilliSource/ChilliSource.h>\n#include <CSBackend/Platform/iOS/Networking/Http/HttpRequestSystem.h>\n\n#import <Foundation/Foundation.h>\n\n#include <functional>\n\n//--------------------------------------------------------------------------------------------------\n/// Called when the connection is established.\n///\n/// @author HMcLaughlin\n///\n/// @param Expected size of the request\n//--------------------------------------------------------------------------------------------------\ntypedef std::function<void(u64 in_expectedSize)> ConnectionEstablishedDelegate;\n//--------------------------------------------------------------------------------------------------\n/// Called when the max buffer size is exceeded\n///\n/// @author HMcLaughlin\n///\n/// @param in_result - The result.\n/// @param in_responseCode - The response code.\n/// @param in_data - The data in string form.\n//--------------------------------------------------------------------------------------------------\ntypedef std::function<void(ChilliSource::HttpResponse::Result in_result, u32 in_responseCode, const std::string& in_data)> FlushedDelegate;\n//--------------------------------------------------------------------------------------------------\n/// Called once the request has complete\n///\n/// @author HMcLaughlin\n///\n/// @param in_result - The result.\n/// @param in_responseCode - The response code.\n/// @param in_data - The data in string form.\n//--------------------------------------------------------------------------------------------------\ntypedef std::function<void(ChilliSource::HttpResponse::Result in_result, u32 in_responseCode, const std::string& in_data)> CompleteDelegate;\n\n\n//--------------------------------------------------------------------------------------------------\n/// A delegate for callbacks from a NSURLConnection. This passes any events on to\n/// the Http Request System.\n///\n/// @author Ian Copland\n//--------------------------------------------------------------------------------------------------\n@interface HttpDelegate : NSObject <NSURLConnectionDataDelegate>\n{\n    u32 m_responseCode;\n    u32 m_maxBufferSize;\n    \n    ConnectionEstablishedDelegate m_connectionEstablishedDelegate;\n    FlushedDelegate m_flushedDelegate;\n    CompleteDelegate m_completeDelegate;\n    \n    NSMutableData* m_data;\n}\n\n//--------------------------------------------------------------------------------------------------\n/// Constructor.\n///\n/// @author HMcLaughlin\n///\n/// @param in_connectionEstablishedDelegate - Delegate to call when connection is established.\n/// @param in_flushedDelegate - Delegate to call when connection is flushed.\n/// @param in_completeDelegate - Delegate to call when connection is completed.\n/// @param in_bufferSize - The buffer size of the request in bytes after which we flush\n//--------------------------------------------------------------------------------------------------\n- (id) initWithConnectionDelegate:(const ConnectionEstablishedDelegate&)in_connectionEstablishedDelegate andFlushedDelegate:(const FlushedDelegate&)in_flushedDelegate andCompleteDelegate:(const FlushedDelegate&)in_completeDelegate andMaxBufferSize:(u32) in_bufferSize;\n//--------------------------------------------------------------------------------------------------\n/// Cleans up the delegate.\n///\n/// @author Ian Copland\n//--------------------------------------------------------------------------------------------------\n-(void) dealloc;\n\n@end\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/iOS/Networking/Http/HttpDelegate.mm",
    "content": "//\n//  HttpDelegate.mm\n//  ChilliSource\n//  Created by Ian Copland on 11/12/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_IOS\n\n#import <CSBackend/Platform/iOS/Networking/Http/HttpDelegate.h>\n\n#import <CSBackend/Platform/iOS/Core/String/NSStringUtils.h>\n#import <CSBackend/Platform/iOS/Networking/Http/HttpRequest.h>\n\n@implementation HttpDelegate\n\n//-----------------------------------------------------------------------------\n//-----------------------------------------------------------------------------\n- (id) initWithConnectionDelegate:(const ConnectionEstablishedDelegate&)in_connectionEstablishedDelegate andFlushedDelegate:(const FlushedDelegate&)in_flushedDelegate andCompleteDelegate:(const FlushedDelegate&)in_completeDelegate andMaxBufferSize:(u32) in_bufferSize\n{\n    if (self = [super init])\n    {\n        m_data = nil;\n        m_responseCode = 0;\n        m_maxBufferSize = in_bufferSize;\n        \n        m_connectionEstablishedDelegate = in_connectionEstablishedDelegate;\n        m_flushedDelegate = in_flushedDelegate;\n        m_completeDelegate = in_completeDelegate;\n        \n        CS_ASSERT(m_flushedDelegate && m_completeDelegate, \"HttpDelegate needs to have the flushed and complete delegates set!\");\n        \n        return self;\n    }\n    \n    return nil;\n}\n//-----------------------------------------------------------------------------\n/// Called when a connection is established.\n///\n/// @author Ian Copland\n///\n/// @param The connection.\n/// @param The response.\n//-----------------------------------------------------------------------------\n- (void) connection:(NSURLConnection*)in_connection didReceiveResponse:(NSURLResponse *)in_response\n{\n    //if we get a redirect we may want to clear the data.\n    if (m_data != nil)\n    {\n        [m_data release];\n        m_data = nil;\n    }\n    \n    m_data = [[NSMutableData alloc] init];\n    \n    m_responseCode = static_cast<u32>(((NSHTTPURLResponse*)in_response).statusCode);\n    \n    if(m_connectionEstablishedDelegate)\n    {\n        m_connectionEstablishedDelegate(in_response.expectedContentLength);\n    }\n}\n//-----------------------------------------------------------------------------\n/// Called when the next block of data is received. This should be appended to\n/// the retained data.\n///\n/// @author Ian Copland\n///\n/// @param The connection.\n/// @param The data.\n//-----------------------------------------------------------------------------\n- (void) connection:(NSURLConnection*)in_connection didReceiveData:(NSData *)in_data\n{\n    CS_ASSERT(m_data != nil, \"Cannot receive data before connection is established!\");\n    \n    if(m_maxBufferSize > 0)\n    {\n        NSUInteger currentSize = [m_data length];\n        NSUInteger appendSize = [in_data length];\n        if(currentSize + appendSize >= m_maxBufferSize)\n        {\n            std::string data(reinterpret_cast<const s8*>([m_data bytes]), (s32)[m_data length]);\n            m_flushedDelegate(ChilliSource::HttpResponse::Result::k_flushed, m_responseCode, data);\n            \n            [m_data setLength:0];\n        }\n    }\n    \n    [m_data appendData:in_data];\n}\n//-----------------------------------------------------------------------------\n/// Called when the connection has finished sending data.\n///\n/// @author Ian Copland\n///\n/// @param The connection.\n//-----------------------------------------------------------------------------\n- (void) connectionDidFinishLoading:(NSURLConnection*)in_connection\n{\n    CS_ASSERT(m_data != nil, \"Cannot finish before connection is established!\");\n    \n    std::string data(reinterpret_cast<const s8*>([m_data bytes]), (s32)[m_data length]);\n    [m_data release];\n    m_data = nil;\n    \n    m_completeDelegate(ChilliSource::HttpResponse::Result::k_completed, m_responseCode, data);\n}\n//-----------------------------------------------------------------------------\n/// Called if a connection fails.\n///\n/// @author Ian Copland\n///\n/// @param The connection.\n/// @param The error.\n//-----------------------------------------------------------------------------\n- (void) connection:(NSURLConnection*)in_connection didFailWithError:(NSError*)in_error\n{\n    std::string errorMessage = [NSStringUtils newUTF8StringWithNSString:[in_error localizedDescription]];\n    CS_LOG_VERBOSE(\"HTTP Request error: \" + errorMessage);\n\n    m_completeDelegate(ChilliSource::HttpResponse::Result::k_failed, m_responseCode, \"\");\n}\n//-----------------------------------------------------------------------------\n/// Called to check how a response should be cached. We don't want to cache\n/// so we return nil.\n///\n/// @author Ian Copland\n///\n/// @param The connection.\n/// @param The cached response.\n//-----------------------------------------------------------------------------\n- (NSCachedURLResponse*) connection:(NSURLConnection*)in_connection willCacheResponse:(NSCachedURLResponse*)in_cachedResponse\n{\n    return nil;\n}\n//-----------------------------------------------------------------------------\n/// Called when authenticating a HTTPS connection. This will always allow even\n/// untrusted connection, so be wary. This will need to be improved in the\n/// future.\n///\n/// @author Ian Copland\n///\n/// @param The connection.\n/// @param The challenge.\n//-----------------------------------------------------------------------------\n-(void)connection:(NSURLConnection *)in_connection willSendRequestForAuthenticationChallenge:(NSURLAuthenticationChallenge *)in_challenge\n{\n    //TODO: Make this safe!\n    [in_challenge.sender useCredential:[NSURLCredential credentialForTrust:in_challenge.protectionSpace.serverTrust] forAuthenticationChallenge:in_challenge];\n}\n//---------------------------------------------------------------------------\n//---------------------------------------------------------------------------\n-(void) dealloc\n{\n    if (m_data != nil)\n    {\n        [m_data release];\n    }\n    \n    [super dealloc];\n}\n\n@end\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/iOS/Networking/Http/HttpRequest.h",
    "content": "//\n//  HttpRequest.h\n//  ChilliSource\n//  Created by Scott Downie on 23/05/2011.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2011 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_IOS\n\n#include <ChilliSource/ChilliSource.h>\n#include <CSBackend/Platform/iOS/ForwardDeclarations.h>\n#include <ChilliSource/Networking/Http/HttpRequest.h>\n#include <ChilliSource/Networking/Http/HttpResponse.h>\n\n#import <Foundation/Foundation.h>\n\n@class HttpDelegate;\n\nnamespace CSBackend\n{\n\tnamespace iOS\n\t{\n        //-------------------------------------------------------------------------\n        /// Concrete implementation of an Http request using iOS NSURLConnection\n        ///\n        /// @author S Downie\n        //-------------------------------------------------------------------------\n        class HttpRequest final : public ChilliSource::HttpRequest\n        {\n        public:\n            //----------------------------------------------------------------------------------------\n            /// @author S Downie\n            ///\n            /// @return The type of the request (POST or GET)\n            //----------------------------------------------------------------------------------------\n            Type GetType() const override;\n            //----------------------------------------------------------------------------------------\n            /// @author S Downie\n            ///\n            /// @return The original url to which the request was sent\n            //----------------------------------------------------------------------------------------\n            const std::string& GetUrl() const override;\n            //----------------------------------------------------------------------------------------\n            /// @author S Downie\n            ///\n            /// @return The body of the POST request (GET request will return empty)\n            //----------------------------------------------------------------------------------------\n            const std::string& GetBody() const override;\n            //----------------------------------------------------------------------------------------\n            /// @author S Downie\n            ///\n            /// @return The original headers of the request as keys/values\n            //----------------------------------------------------------------------------------------\n            const ChilliSource::ParamDictionary& GetHeaders() const override;\n            //----------------------------------------------------------------------------------------\n            /// @author N Tanda\n            ///\n            /// @return The expected total size of the request\n            //----------------------------------------------------------------------------------------\n            u64 GetExpectedSize() const override;\n            //----------------------------------------------------------------------------------------\n            /// @author N Tanda\n            ///\n            /// @return The current transferred size of the request\n            //----------------------------------------------------------------------------------------\n            u64 GetDownloadedBytes() const override;\n            //------------------------------------------------------------------\n            /// Close the request. Note: The completion delegate is not invoked\n            ///\n            /// @author S Downie\n            //------------------------------------------------------------------\n            void Cancel() override;\n            //------------------------------------------------------------------\n            /// Destructor.\n            ///\n            /// @author Ian Copland\n            //------------------------------------------------------------------\n            ~HttpRequest();\n            \n        private:\n            \n            friend class HttpRequestSystem;\n            //------------------------------------------------------------------\n            /// Constructor. Can only be created via HttpRequestSystem\n            ///\n            /// @author S Downie\n            ///\n            /// @param Type (POST or GET)\n            /// @param Url to send request to\n            /// @param POST body\n            /// @param Headers\n            /// @param Timeout in seconds\n            /// @param Max buffer size in bytes\n            /// @param Completion delegate\n            //------------------------------------------------------------------\n            HttpRequest(Type in_type, const std::string& in_url, const std::string& in_body, const ChilliSource::ParamDictionary& in_headers, u32 in_timeoutSecs, u32 in_maxBufferSize, const Delegate& in_delegate);\n            \n        private:\n            \n            const Type m_type;\n            const std::string m_url;\n            const std::string m_body;\n            const ChilliSource::ParamDictionary m_headers;\n            const Delegate m_completionDelegate;\n            \n            //These need to be shared_ptr so we can access them in result lambdas if\n            //(*this) is destroyed, which may occur if a callback occurs while waiting to cancel a request\n            //on the system thread.\n            std::shared_ptr<bool> m_complete;\n            std::shared_ptr<bool> m_isCancelled;\n            \n            NSURLConnection* m_connection = nil;\n            HttpDelegate* m_httpDelegate = nil;\n            \n            u64 m_downloadedBytes = 0;\n            u64 m_expectedSize = 0;\n        };\n\t}\n}\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/iOS/Networking/Http/HttpRequest.mm",
    "content": "//\n//  HttpRequest.cpp\n//  ChilliSource\n//  Created by Scott Downie on 23/05/2011.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2011 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_IOS\n\n#import <CSBackend/Platform/iOS/Networking/Http/HttpRequest.h>\n\n#import <CSBackend/Platform/iOS/Networking/Http/HttpDelegate.h>\n#include <CSBackend/Platform/iOS/Core/String/NSStringUtils.h>\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/String/StringUtils.h>\n#include <ChilliSource/Core/Threading/TaskScheduler.h>\n#include <ChilliSource/Networking/Http/HttpRequestSystem.h>\n\n#import <Foundation/Foundation.h>\n\nnamespace CSBackend\n{\n\tnamespace iOS\n\t{\n        //------------------------------------------------------------------\n        //------------------------------------------------------------------\n\t\tHttpRequest::HttpRequest(Type in_type, const std::string& in_url, const std::string& in_body, const ChilliSource::ParamDictionary& in_headers, u32 in_timeoutSecs, u32 in_maxBufferSize, const Delegate& in_delegate)\n        : m_type(in_type), m_url(in_url), m_body(in_body), m_headers(in_headers), m_completionDelegate(in_delegate)\n\t\t{\n            CS_ASSERT(m_completionDelegate, \"Http request cannot have null delegate\");\n            \n            m_complete = std::shared_ptr<bool>(new bool(false));\n            m_isCancelled = std::shared_ptr<bool>(new bool(false));\n            \n            ChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_system, [=](const ChilliSource::TaskContext& taskContext)\n            {\n                @autoreleasepool\n                {\n                    NSString* urlString = [NSStringUtils newNSStringWithUTF8String:m_url];\n                    NSURL* url = [NSURL URLWithString:urlString];\n                    [urlString release];\n                    \n                    NSMutableURLRequest* request = [NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:in_timeoutSecs];\n                    \n                    //apply header\n                    NSMutableDictionary* header = [NSMutableDictionary dictionaryWithCapacity:m_headers.size()];\n                    for (const auto& fieldPair : m_headers)\n                    {\n                        NSString* key = [NSStringUtils newNSStringWithUTF8String:fieldPair.first];\n                        NSString* value = [NSStringUtils newNSStringWithUTF8String:fieldPair.second];\n                        [header setObject:value forKey:key];\n                        [value release];\n                        [key release];\n                    }\n                    [request setAllHTTPHeaderFields:header];\n                    \n                    //apply body if a post request.\n                    if (m_type == Type::k_post)\n                    {\n                        request.HTTPMethod = @\"POST\";\n                        request.HTTPBody = [NSData dataWithBytes:m_body.c_str() length:m_body.length()];\n                    }\n                    \n                    auto connectionEstablishedDelegate = [this](u64 in_expectedSize)\n                    {\n                        m_expectedSize = in_expectedSize;\n                    };\n                    \n                    auto complete = m_complete;\n                    auto cancelled = m_isCancelled;\n                    \n                    auto connectionFlushedDelegate = [=](ChilliSource::HttpResponse::Result in_result, u32 in_responseCode, const std::string& in_data)\n                    {\n                        ChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_mainThread, [=](const ChilliSource::TaskContext& taskContext)\n                        {\n                            //Ensure that we only call the delegate when cancelled is false as (*this) may not be around\n                            if(!*complete && !*cancelled)\n                            {\n                                m_downloadedBytes += in_data.length();\n                                m_completionDelegate(this, ChilliSource::HttpResponse(in_result, in_responseCode, in_data));\n                            }\n                        });\n                    };\n                    \n                    auto connectionCompleteDelegate = [=](ChilliSource::HttpResponse::Result in_result, u32 in_responseCode, const std::string& in_data)\n                    {\n                        ChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_mainThread, [=](const ChilliSource::TaskContext& taskContext)\n                        {\n                            //Ensure that we only call the delegate when cancelled is false as (*this) may not be around\n                            if(!*complete && !*cancelled)\n                            {\n                                *complete = true;\n                                m_downloadedBytes += in_data.length();\n                                \n                                m_completionDelegate(this, ChilliSource::HttpResponse(in_result, in_responseCode, in_data));\n                            }\n                        });\n                    };\n                    \n                    m_httpDelegate = [[HttpDelegate alloc] initWithConnectionDelegate:connectionEstablishedDelegate andFlushedDelegate:connectionFlushedDelegate andCompleteDelegate:connectionCompleteDelegate andMaxBufferSize:in_maxBufferSize];\n                    m_connection = [[NSURLConnection connectionWithRequest:[request copy] delegate: m_httpDelegate] retain];\n                }\n            });\n        }\n        //----------------------------------------------------------------------------------------\n        //----------------------------------------------------------------------------------------\n        HttpRequest::Type HttpRequest::GetType() const\n        {\n            return m_type;\n        }\n        //----------------------------------------------------------------------------------------\n        //----------------------------------------------------------------------------------------\n        const std::string& HttpRequest::GetUrl() const\n        {\n            return m_url;\n        }\n        //----------------------------------------------------------------------------------------\n        //----------------------------------------------------------------------------------------\n        const std::string& HttpRequest::GetBody() const\n        {\n            return m_body;\n        }\n        //----------------------------------------------------------------------------------------\n        //----------------------------------------------------------------------------------------\n        const ChilliSource::ParamDictionary& HttpRequest::GetHeaders() const\n        {\n            return m_headers;\n        }\n        //----------------------------------------------------------------------------------------\n        //----------------------------------------------------------------------------------------\n        u64 HttpRequest::GetExpectedSize() const\n        {\n            return m_expectedSize;\n        }\n        //----------------------------------------------------------------------------------------\n        //----------------------------------------------------------------------------------------\n        u64 HttpRequest::GetDownloadedBytes() const\n        {\n            return m_downloadedBytes;\n        }\n        //------------------------------------------------------------------\n        //------------------------------------------------------------------\n\t\tvoid HttpRequest::Cancel()\n\t\t{\n            CS_ASSERT(*m_complete == false, \"Cannot cancel an already complete request.\");\n            \n            *m_isCancelled = true;\n            \n            ChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_system, [=](const ChilliSource::TaskContext& taskContext)\n            {\n                [m_connection cancel];\n            });\n\t\t}\n        //------------------------------------------------------------------\n        //------------------------------------------------------------------\n        HttpRequest::~HttpRequest()\n        {\n            NSURLConnection* connection = m_connection;\n            HttpDelegate* delegate = m_httpDelegate;\n            m_connection = nil;\n            m_httpDelegate = nil;\n            \n            ChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_system, [=](const ChilliSource::TaskContext& taskContext)\n            {\n                [connection release];\n                [delegate release];\n            });\n        }\n\t}\n}\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/iOS/Networking/Http/HttpRequestSystem.h",
    "content": "//\n//  HttpRequestSystem.h\n//  ChilliSource\n//  Created by Scott Downie on 23/05/2011.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2011 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_IOS\n\n#include <ChilliSource/ChilliSource.h>\n#include <CSBackend/Platform/iOS/ForwardDeclarations.h>\n#import <CSBackend/Platform/iOS/Networking/Http/HttpRequest.h>\n#include <ChilliSource/Networking/Http/HttpRequestSystem.h>\n\n#import <CoreFoundation/CoreFoundation.h>\n\n#include <vector>\n\nnamespace CSBackend\n{\n\tnamespace iOS\n\t{\n        //-------------------------------------------------------------------------\n        /// iOS implementation of the http connection system. Reponsible for making\n        /// http requests to remote urls and managing the lifetime of the requests\n        /// and the connections. Uses the CFNetworking library.\n        ///\n        /// @author S Downie\n        //-------------------------------------------------------------------------\n\t\tclass HttpRequestSystem final : public ChilliSource::HttpRequestSystem\n\t\t{\n\t\tpublic:\n            CS_DECLARE_NAMEDTYPE(HttpRequestSystem);\n            \n\t\t\t//------------------------------------------------------------------\n\t\t\t/// @author S Downie\n\t\t\t///\n\t\t\t/// @param Interface ID\n            ///\n\t\t\t/// @return Whether object if of argument type\n\t\t\t//------------------------------------------------------------------\n            bool IsA(ChilliSource::InterfaceIDType in_interfaceId) const override;\n            //--------------------------------------------------------------------------------------------------\n            /// Causes the system to issue an Http GET request.\n            ///\n            /// @author S Downie\n            ///\n            /// @param URL\n            /// @param Delegate that is called on request completed. Completion can be failure as well as success\n            /// @param Request timeout in seconds\n            ///\n            /// @return A pointer to the request. The system owns this pointer.\n            //--------------------------------------------------------------------------------------------------\n            HttpRequest* MakeGetRequest(const std::string& in_url, const HttpRequest::Delegate& in_delegate, u32 in_timeoutSecs = k_defaultTimeoutSecs) override;\n            //--------------------------------------------------------------------------------------------------\n            /// Causes the system to issue an Http GET request.\n            ///\n            /// @author S Downie\n            ///\n            /// @param URL\n            /// @param Key value headers to attach to the request\n            /// @param Delegate that is called on request completed. Completion can be failure as well as success\n            /// @param Request timeout in seconds\n            ///\n            /// @return A pointer to the request. The system owns this pointer.\n            //--------------------------------------------------------------------------------------------------\n            HttpRequest* MakeGetRequest(const std::string& in_url, const ChilliSource::ParamDictionary& in_headers, const HttpRequest::Delegate& in_delegate, u32 in_timeoutSecs = k_defaultTimeoutSecs) override;\n            //--------------------------------------------------------------------------------------------------\n            /// Causes the system to issue an Http POST request with the given body.\n            ///\n            /// @author S Downie\n            ///\n            /// @param URL\n            /// @param POST body\n            /// @param Delegate that is called on request completed. Completion can be failure as well as success\n            /// @param Request timeout in seconds\n            ///\n            /// @return A pointer to the request. The system owns this pointer.\n            //--------------------------------------------------------------------------------------------------\n            HttpRequest* MakePostRequest(const std::string& in_url, const std::string& in_body, const HttpRequest::Delegate& in_delegate, u32 in_timeoutSecs = k_defaultTimeoutSecs) override;\n            //--------------------------------------------------------------------------------------------------\n            /// Causes the system to issue an Http POST request with the given body.\n            ///\n            /// @author S Downie\n            ///\n            /// @param URL\n            /// @param POST body\n            /// @param Key value headers to attach to the request\n            /// @param Delegate that is called on request completed. Completion can be failure as well as success\n            /// @param Request timeout in seconds\n            ///\n            /// @return A pointer to the request. The system owns this pointer.\n            //--------------------------------------------------------------------------------------------------\n            HttpRequest* MakePostRequest(const std::string& in_url, const std::string& in_body, const ChilliSource::ParamDictionary& in_headers, const HttpRequest::Delegate& in_delegate, u32 in_timeoutSecs = k_defaultTimeoutSecs) override;\n\t\t\t//------------------------------------------------------------------\n            /// Equivalent to calling cancel on every incomplete request in\n            /// progress.\n            ///\n            /// @author S Downie\n            //------------------------------------------------------------------\n            void CancelAllRequests() override;\n            //------------------------------------------------------------------\n            /// Checks if the device is internet ready\n            ///\n            /// @author S Downie\n            ///\n            /// @param Delegate to call when reachability is determined\n            //------------------------------------------------------------------\n            void CheckReachability(const ReachabilityResultDelegate& in_reachabilityDelegate) const override;\n            \n        private:\n            friend ChilliSource::HttpRequestSystemUPtr ChilliSource::HttpRequestSystem::Create();\n            //------------------------------------------------------------------\n            /// Private constructor to fore use of factory method\n            ///\n            /// @author S Downie\n            //------------------------------------------------------------------\n            HttpRequestSystem() = default;\n            //------------------------------------------------------------------\n            /// Concrete method to which all MakeRequest overloads feed.\n            ///\n            /// @author S Downie\n            ///\n            /// @param Type (POST or GET)\n            /// @param Url\n            /// @param Body (POST only)\n            /// @param Headers\n            /// @param Completion delegate\n            /// @param Request timeout in seconds\n            ///\n            /// @return Request. Owned by the system.\n            //------------------------------------------------------------------\n            HttpRequest* MakeRequest(HttpRequest::Type in_type, const std::string& in_url, const std::string& in_body, const ChilliSource::ParamDictionary& in_headers, const HttpRequest::Delegate& in_delegate, u32 in_timeoutSecs);\n            //------------------------------------------------------------------\n            /// Poll the connection on active requests\n            ///\n            /// @author S Downie\n            ///\n            /// @param Time since last update in seconds\n            //------------------------------------------------------------------\n            void OnUpdate(f32 in_timeSinceLastUpdate) override;\n            //------------------------------------------------------------------\n            /// Called when the system is destroyed. Cancels all pending requests\n            ///\n            /// @author S Downie\n            //------------------------------------------------------------------\n            void OnDestroy() override;\n        \n        private:\n\t\t\tstd::vector<HttpRequestUPtr> m_requests;\n            std::vector<const ChilliSource::HttpRequest*> m_finishedRequests;\n\t\t};\n\t}\n}\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/iOS/Networking/Http/HttpRequestSystem.mm",
    "content": "//\n//  HttpRequestSystem.cpp\n//  ChilliSource\n//  Created by Scott Downie on 23/05/2011.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2011 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_IOS\n\n#import <CSBackend/Platform/iOS/Networking/Http/HttpRequestSystem.h>\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/Threading/TaskScheduler.h>\n\n#import <Reachability/CSReachability.h>\n#import <CFNetwork/CFNetwork.h>\n\nnamespace CSBackend\n{\n\tnamespace iOS\n\t{\n        CS_DEFINE_NAMEDTYPE(HttpRequestSystem);\n        \n        //------------------------------------------------------------------\n        //------------------------------------------------------------------\n\t\tbool HttpRequestSystem::IsA(ChilliSource::InterfaceIDType in_interfaceId) const\n\t\t{\n\t\t\treturn in_interfaceId == ChilliSource::HttpRequestSystem::InterfaceID || in_interfaceId == HttpRequestSystem::InterfaceID;\n\t\t}\n        //--------------------------------------------------------------------------------------------------\n        //--------------------------------------------------------------------------------------------------\n        HttpRequest* HttpRequestSystem::MakeGetRequest(const std::string& in_url, const HttpRequest::Delegate& in_delegate, u32 in_timeoutSecs)\n        {\n            return MakeRequest(HttpRequest::Type::k_get, in_url, \"\", ChilliSource::ParamDictionary(), in_delegate, in_timeoutSecs);\n        }\n        //--------------------------------------------------------------------------------------------------\n        //--------------------------------------------------------------------------------------------------\n        HttpRequest* HttpRequestSystem::MakeGetRequest(const std::string& in_url, const ChilliSource::ParamDictionary& in_headers, const HttpRequest::Delegate& in_delegate, u32 in_timeoutSecs)\n        {\n            return MakeRequest(HttpRequest::Type::k_get, in_url, \"\", in_headers, in_delegate, in_timeoutSecs);\n        }\n        //--------------------------------------------------------------------------------------------------\n        //--------------------------------------------------------------------------------------------------\n        HttpRequest* HttpRequestSystem::MakePostRequest(const std::string& in_url, const std::string& in_body, const HttpRequest::Delegate& in_delegate, u32 in_timeoutSecs)\n        {\n            return MakeRequest(HttpRequest::Type::k_post, in_url, in_body, ChilliSource::ParamDictionary(), in_delegate, in_timeoutSecs);\n        }\n        //--------------------------------------------------------------------------------------------------\n        //--------------------------------------------------------------------------------------------------\n        HttpRequest* HttpRequestSystem::MakePostRequest(const std::string& in_url, const std::string& in_body, const ChilliSource::ParamDictionary& in_headers, const HttpRequest::Delegate& in_delegate, u32 in_timeoutSecs)\n        {\n            return MakeRequest(HttpRequest::Type::k_post, in_url, in_body, in_headers, in_delegate, in_timeoutSecs);\n        }\n        //------------------------------------------------------------------\n        //------------------------------------------------------------------\n        HttpRequest* HttpRequestSystem::MakeRequest(HttpRequest::Type in_type, const std::string& in_url, const std::string& in_body, const ChilliSource::ParamDictionary& in_headers, const HttpRequest::Delegate& in_delegate, u32 in_timeoutSecs)\n        {\n            CS_RELEASE_ASSERT(ChilliSource::Application::Get()->GetTaskScheduler()->IsMainThread() == true, \"Http requests can currently only be made on the main thread\");\n            CS_ASSERT(in_delegate != nullptr, \"Cannot make an http request with a null delegate\");\n            CS_ASSERT(in_url.empty() == false, \"Cannot make an http request to a blank url\");\n            \n            HttpRequestUPtr request(new HttpRequest(in_type, in_url, in_body, in_headers, in_timeoutSecs, GetMaxBufferSize(), [=](const ChilliSource::HttpRequest* in_request, const ChilliSource::HttpResponse& in_response)\n            {\n                //If flushed, we are not finished with the request yet\n                if(in_response.GetResult() != ChilliSource::HttpResponse::Result::k_flushed)\n                {\n                    m_finishedRequests.push_back(in_request);\n                }\n                \n                in_delegate(in_request, in_response);\n            }));\n            \n            auto requestRaw = request.get();\n            m_requests.push_back(std::move(request));\n            \n            return requestRaw;\n\t\t}\n        //------------------------------------------------------------------\n        //------------------------------------------------------------------\n\t\tvoid HttpRequestSystem::CancelAllRequests()\n        {\n            CS_RELEASE_ASSERT(ChilliSource::Application::Get()->GetTaskScheduler()->IsMainThread() == true, \"Http requests can currently only be made on the main thread\");\n            \n            for(auto& request : m_requests)\n            {\n\t\t\t\trequest->Cancel();\n\t\t\t}\n\t\t}\n        //------------------------------------------------------------------\n        //------------------------------------------------------------------\n        void HttpRequestSystem::CheckReachability(const ReachabilityResultDelegate& in_reachabilityDelegate) const\n        {\n            CS_ASSERT(in_reachabilityDelegate, \"The reachability delegate should not be null.\");\n            \n            ChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_system, [=](const ChilliSource::TaskContext& taskContext)\n            {\n                CSReachability* reachability = [CSReachability reachabilityForInternetConnection];\n                NetworkStatus status = [reachability currentReachabilityStatus];\n                \n                ChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_mainThread, [=](const ChilliSource::TaskContext& taskContext)\n                {\n                    in_reachabilityDelegate(status != NotReachable);\n                });\n            });\n        }\n        //------------------------------------------------------------------\n        //------------------------------------------------------------------\n\t\tvoid HttpRequestSystem::OnUpdate(f32 in_timeSinceLastUpdate)\n\t\t{\n            //remove any finished requests.\n            for (auto& finishedRequest : m_finishedRequests)\n            {\n                for (auto requestIt = m_requests.begin(); requestIt != m_requests.end();)\n                {\n                    if (requestIt->get() == finishedRequest)\n                    {\n                        requestIt = m_requests.erase(requestIt);\n                        break;\n                    }\n                    else\n                    {\n                        ++requestIt;\n                    }\n                }\n            }\n            \n            m_finishedRequests.clear();\n\t\t}\n        //------------------------------------------------------------------\n        //------------------------------------------------------------------\n        void HttpRequestSystem::OnDestroy()\n        {\n            CancelAllRequests();\n\n            m_requests.clear();\n            m_requests.shrink_to_fit();\n        }\n\t}\n}\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/iOS/Networking/IAP/IAPSystem.h",
    "content": "//\n//  IAPSystem.h\n//  ChilliSource\n//  Created by Scott Downie on 12/06/2013.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2013 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_IOS\n\n#ifndef _CSBACKEND_PLATFORM_IOS_NETWORKING_IAP_IAPSYSTEM_H_\n#define _CSBACKEND_PLATFORM_IOS_NETWORKING_IAP_IAPSYSTEM_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <CSBackend/Platform/iOS/ForwardDeclarations.h>\n#include <CSBackend/Platform/iOS/Networking/IAP/StoreKitIAPSystem.h>\n#include <ChilliSource/Networking/IAP/IAPSystem.h>\n\nnamespace CSBackend\n{\n    namespace iOS\n    {\n        //----------------------------------------------------------------------------------\n        /// System that allows purchasing of IAPs from\n        /// the iOS App Store. System allows product info\n        /// to be requested in ordrer to build displays and then\n        /// for products to be purchased. NOTE: Must StartListeningForTransactionUpdates()\n        /// before any purchases are made as this can be called with previously incomplete\n        /// transactions.\n        ///\n        /// @author S Downie\n        //----------------------------------------------------------------------------------\n        class IAPSystem final : public ChilliSource::IAPSystem\n        {\n        public:\n\n            CS_DECLARE_NAMEDTYPE(IAPSystem);\n            \n            //---------------------------------------------------------------\n            /// This defines platform-specific extra product information.\n            ///\n            /// @author T Kane\n            //---------------------------------------------------------------\n            struct ExtraProductInfo final\n            {\n                std::string m_productId;            // Platform-specific product ID\n                std::string m_unformattedPrice;     // Unformatted price e.g. 1.00\n                std::string m_currencyCode;         // ISO 4217 currency code, e.g. GBP, USD\n            };\n            \n            //---------------------------------------------------------------\n            /// @author S Downie\n            ///\n            /// @param Interface ID to compare\n            ///\n            /// @return Whether the class is of the given type\n            //---------------------------------------------------------------\n            bool IsA(ChilliSource::InterfaceIDType in_interfaceId) const override;\n            //---------------------------------------------------------------\n            /// Inform the system of which products are available for\n            /// purchase and whether they are managed or unmanaged\n            ///\n            /// @author S Downie\n            ///\n            /// @param List of products\n            //---------------------------------------------------------------\n            void RegisterProducts(const std::vector<ProductRegInfo>& in_productInfos) override;\n            //---------------------------------------------------------------\n\t\t\t/// @author S Downie\n\t\t\t///\n\t\t\t/// @return The ID off the IAP provider as a string.\n            //---------------------------------------------------------------\n\t\t\tstd::string GetProviderID() const override;\n            //---------------------------------------------------------------\n\t\t\t/// @author S Downie\n            ///\n            /// @param Purchasing enabled delegate\n            //---------------------------------------------------------------\n            void IsPurchasingEnabled(const PurchasingEnabledDelegate& in_delegate) override;\n            //---------------------------------------------------------------\n\t\t\t/// Calling this function will set the listener to which any\n            /// transaction events are directed. This is not necessarily\n            /// in response to a user action it may be previously outstanding\n            /// transactions.\n            ///\n            /// @author S Downie\n            ///\n            /// @param Delegate\n            //---------------------------------------------------------------\n            void StartListeningForTransactionUpdates(const TransactionStatusDelegate& in_delegate) override;\n            //---------------------------------------------------------------\n            /// Prevent any more transaction uppdates from being triggered.\n            ///\n            /// @author S Downie\n            //---------------------------------------------------------------\n            void StopListeningForTransactionUpdates() override;\n            //---------------------------------------------------------------\n            /// Starts a request to the store for details of the products.\n            /// These details are name, description and price\n            ///\n            /// @author S Downie\n            ///\n\t\t\t/// @param List of product IDs to request descriptions for\n            /// @param Delegate to invoke when the request completes\n            //---------------------------------------------------------------\n            void RequestProductDescriptions(const std::vector<std::string>& in_productIds, const ProductDescDelegate& in_delegate) override;\n            //---------------------------------------------------------------\n            /// Starts a request to the store for details of all registered\n            /// products. These details are name, description and price\n            ///\n            /// @author S Downie\n            ///\n            /// @param Delegate to invoke when the request completes\n            //---------------------------------------------------------------\n            void RequestAllProductDescriptions(const ProductDescDelegate& in_delegate) override;\n            //---------------------------------------------------------------\n\t\t\t/// Prevent the completion delegate being called for\n            /// any pending product description requests and attempt to\n            /// cancel the request to the store.\n            ///\n            /// @author S Downie\n            //---------------------------------------------------------------\n            void CancelProductDescriptionsRequest() override;\n            //---------------------------------------------------------------\n\t\t\t/// Make a request to the store to purchase the item.\n            /// This will trigger a call to the transaction listener delegate\n            ///\n            /// @author S Downie\n            ///\n            /// @param Product ID\n            //---------------------------------------------------------------\n            void RequestProductPurchase(const std::string& in_productId) override;\n            //---------------------------------------------------------------\n            /// Tell the store to close the transaction as complete.\n            /// NOTE: This should only be called after the goods have been\n            /// awarded.\n            ///\n            /// @author S Downie\n            ///\n            /// @param Transaction to close\n            /// @param Delegate to call when closed (either with success or failure)\n            //---------------------------------------------------------------\n            void CloseTransaction(const TransactionSPtr& inpTransaction, const TransactionCloseDelegate& in_delegate) override;\n            //---------------------------------------------------------------\n            /// Request that the store trigger new purchase requests for\n            /// owned non-consumable items\n            ///\n            /// @author S Downie\n            //---------------------------------------------------------------\n            void RestoreManagedPurchases() override;\n            //---------------------------------------------------------------\n            /// @author T Kane\n            ///\n            /// @return A vector of extra product information, particular to\n            /// this platform. Note that products must be requested from the\n            /// store via RequestProductDescriptions or\n            /// RequestProductDescriptions before being available so there is\n            /// no guarantee that a particular product will be available. It is\n            /// the application's responsibility to ensure the correct data\n            /// has been requested up-front.\n            //---------------------------------------------------------------\n            std::vector<ExtraProductInfo> GetExtraProductInfo() const;\n            \n        private:\n            \n            friend ChilliSource::IAPSystemUPtr ChilliSource::IAPSystem::Create(const ChilliSource::ParamDictionary&);\n            //-------------------------------------------------------\n            /// Private constructor to force use of factory method\n            ///\n            /// @author S Downie\n            //-------------------------------------------------------\n            IAPSystem() = default;\n            //-------------------------------------------------------\n            /// Called when the system is created. Initialises\n            /// the StoreKit backend\n            ///\n            /// @author S Downie\n            //-------------------------------------------------------\n            void OnInit() override;\n            //-------------------------------------------------------\n            /// Called when the system is shutdown.\n            ///\n            /// @author S Downie\n            //-------------------------------------------------------\n            void OnDestroy() override;\n            //---------------------------------------------------------------\n            /// @author S Downie\n            ///\n            /// @param List of StoreKit product informtation\n            //---------------------------------------------------------------\n            void OnProductDescriptionRequestComplete(NSArray* in_products);\n            //---------------------------------------------------------------\n            /// Triggered by StoreKit with transactions update\n            ///\n            /// @author S Downie\n            ///\n            /// @param Product ID\n            /// @param Result\n            /// @param Transaction\n            //---------------------------------------------------------------\n            void OnTransactionUpdate(NSString* in_productId, StoreKitIAP::TransactionResult in_result, SKPaymentTransaction* in_transaction);\n            \n        private:\n            \n            std::vector<ProductRegInfo> m_productRegInfos;\n            \n            StoreKitIAPSystem* m_storeKitSystem;\n            \n            ProductDescDelegate m_productDescDelegate;\n            TransactionStatusDelegate m_transactionStatusDelegate;\n            TransactionCloseDelegate m_transactionCloseDelegate;\n        };\n    }\n}\n\n#endif \n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/iOS/Networking/IAP/IAPSystem.mm",
    "content": "//\n//  IAPSystem.mm\n//  ChilliSource\n//  Created by Scott Downie on 12/06/2013.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2013 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_IOS\n\n#import <CSBackend/Platform/iOS/Networking/IAP/IAPSystem.h>\n\n#import <CSBackend/Platform/iOS/Core/String/NSStringUtils.h>\n\n#import <ChilliSource/Core/Base/Application.h>\n#import <ChilliSource/Core/Cryptographic/BaseEncoding.h>\n#import <ChilliSource/Core/Delegate/MakeDelegate.h>\n#import <ChilliSource/Core/String/StringUtils.h>\n#import <ChilliSource/Core/Threading/TaskScheduler.h>\n\nnamespace CSBackend\n{\n    namespace iOS\n    {\n        namespace\n        {\n            //---------------------------------------------------------------\n            /// @author S Downie\n            ///\n            /// @param List of product registrations\n            /// @param Product Id to find\n            ///\n            /// @return Whether a product reg info exists in the list\n            /// with the given Id.\n            //---------------------------------------------------------------\n            bool ContainsProductId(const std::vector<ChilliSource::IAPSystem::ProductRegInfo>& in_productInfos, const std::string& in_productId)\n            {\n                for(u32 i=0; i<in_productInfos.size(); ++i)\n                {\n                    if(in_productInfos[i].m_id == in_productId)\n                    {\n                        return true;\n                    }\n                }\n                \n                return false;\n            }\n        }\n        \n        CS_DEFINE_NAMEDTYPE(IAPSystem);\n        \n        //---------------------------------------------------------------\n        //---------------------------------------------------------------\n        bool IAPSystem::IsA(ChilliSource::InterfaceIDType in_interfaceId) const\n        {\n            return in_interfaceId == ChilliSource::IAPSystem::InterfaceID || in_interfaceId == IAPSystem::InterfaceID;\n        }\n        //---------------------------------------------------------------\n        //---------------------------------------------------------------\n        void IAPSystem::OnInit()\n        {\n            ChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_system, [=](const ChilliSource::TaskContext& in_taskContext)\n            {\n                m_storeKitSystem = [[StoreKitIAPSystem alloc] init];\n            });\n        }\n        //---------------------------------------------------------------\n        //---------------------------------------------------------------\n        void IAPSystem::RegisterProducts(const std::vector<ProductRegInfo>& in_productInfos)\n        {\n            CS_ASSERT(in_productInfos.empty() == false, \"Must register at least one product\");\n            m_productRegInfos = in_productInfos;\n        }\n        //---------------------------------------------------------------\n        //---------------------------------------------------------------\n        std::string IAPSystem::GetProviderID() const\n        {\n            return \"AppleAppStore\";\n        }\n        //---------------------------------------------------------------\n        //---------------------------------------------------------------\n        void IAPSystem::IsPurchasingEnabled(const PurchasingEnabledDelegate& in_delegate)\n        {\n            CS_ASSERT(in_delegate, \"Cannot have empty delegate\");\n            ChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_system, [=](const ChilliSource::TaskContext& in_taskContext)\n            {\n                in_delegate([m_storeKitSystem isPurchasingEnabled]);\n            });\n        }\n        //---------------------------------------------------------------\n        //---------------------------------------------------------------\n        void IAPSystem::StartListeningForTransactionUpdates(const TransactionStatusDelegate& in_delegate)\n        {\n            CS_ASSERT(in_delegate != nullptr, \"Cannot have null transaction delegate\");\n            m_transactionStatusDelegate = in_delegate;\n            \n            ChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_system, [=](const ChilliSource::TaskContext& in_taskContext)\n            {\n                [m_storeKitSystem startListeningForTransactions:ChilliSource::MakeDelegate(this, &IAPSystem::OnTransactionUpdate)];\n            });\n        }\n        //---------------------------------------------------------------\n        //---------------------------------------------------------------\n        void IAPSystem::OnTransactionUpdate(NSString* in_productID, StoreKitIAP::TransactionResult in_result, SKPaymentTransaction* in_skTransaction)\n        {\n            ChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_mainThread, [=](const ChilliSource::TaskContext& in_taskContext)\n            {\n                if(m_transactionStatusDelegate == nullptr)\n                    return;\n                \n                bool hasReceipt = false;\n                Transaction::Status result = Transaction::Status::k_failed;\n                switch(in_result)\n                {\n                    case StoreKitIAP::TransactionResult::k_succeeded:\n                        hasReceipt = true;\n                        result = Transaction::Status::k_succeeded;\n                        break;\n                    case StoreKitIAP::TransactionResult::k_failed:\n                        result = Transaction::Status::k_failed;\n                        break;\n                    case StoreKitIAP::TransactionResult::k_cancelled:\n                        result = Transaction::Status::k_cancelled;\n                        break;\n                    case StoreKitIAP::TransactionResult::k_restored:\n                        hasReceipt = true;\n                        result = Transaction::Status::k_restored;\n                        break;\n                    case StoreKitIAP::TransactionResult::k_resumed:\n                        hasReceipt = true;\n                        result = Transaction::Status::k_resumed;\n                        break;\n                }\n                \n                TransactionSPtr transaction(new Transaction());\n                transaction->m_productId = [NSStringUtils newUTF8StringWithNSString:in_productID];\n                transaction->m_transactionId = [NSStringUtils newUTF8StringWithNSString:in_skTransaction.transactionIdentifier];\n                if(hasReceipt)\n                {\n                    NSData* receiptData = [NSData dataWithContentsOfURL:[[NSBundle mainBundle] appStoreReceiptURL]];\n                    CS_ASSERT([receiptData length] < static_cast<NSUInteger>(std::numeric_limits<u32>::max()), \"Transaction receipt is too large, cannot exceed \" + ChilliSource::ToString(std::numeric_limits<u32>::max()) + \" bytes.\");\n                    u32 length = static_cast<u32>([receiptData length]);\n                    \n                    transaction->m_receipt = ChilliSource::BaseEncoding::Base64Encode((s8*)[receiptData bytes], length);\n                }\n                \n                m_transactionStatusDelegate(result, transaction);\n            });\n        }\n        //---------------------------------------------------------------\n        //---------------------------------------------------------------\n        void IAPSystem::StopListeningForTransactionUpdates()\n        {\n            m_transactionStatusDelegate = nullptr;\n            \n            ChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_system, [=](const ChilliSource::TaskContext& in_taskContext)\n            {\n                [m_storeKitSystem stopListeningForTransactions];\n            });\n        }\n        //---------------------------------------------------------------\n        //---------------------------------------------------------------\n        void IAPSystem::RequestProductDescriptions(const std::vector<std::string>& in_productIds, const ProductDescDelegate& in_delegate)\n        {\n            CS_ASSERT(in_productIds.empty() == false, \"Cannot request no product descriptions\");\n            CS_ASSERT(in_delegate != nullptr, \"Cannot have null product description delegate\");\n            CS_ASSERT(m_productDescDelegate == nullptr, \"Only 1 product description request can be active at a time\");\n            \n            m_productDescDelegate = in_delegate;\n            \n            ChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_system, [=](const ChilliSource::TaskContext& in_taskContext)\n            {\n                NSMutableSet* idSet = [[NSMutableSet alloc] initWithCapacity:in_productIds.size()];\n                \n                for (u32 i=0; i<in_productIds.size(); ++i)\n                {\n                    NSString* projectId = [NSStringUtils newNSStringWithUTF8String:in_productIds[i]];\n                    [idSet addObject:projectId];\n                    [projectId release];\n                }\n                \n                [m_storeKitSystem requestProducts:idSet forDelegate:ChilliSource::MakeDelegate(this, &IAPSystem::OnProductDescriptionRequestComplete)];\n                \n                [idSet release];\n            });\n        }\n        //---------------------------------------------------------------\n        //---------------------------------------------------------------\n        void IAPSystem::RequestAllProductDescriptions(const ProductDescDelegate& in_delegate)\n        {\n            std::vector<std::string> productIds;\n            productIds.reserve(m_productRegInfos.size());\n            \n            for(u32 i=0; i<m_productRegInfos.size(); ++i)\n            {\n                productIds.push_back(m_productRegInfos[i].m_id);\n            }\n            \n            RequestProductDescriptions(productIds, in_delegate);\n        }\n        //---------------------------------------------------------------\n        //---------------------------------------------------------------\n        void IAPSystem::OnProductDescriptionRequestComplete(NSArray* in_products)\n        {\n            std::vector<ProductDesc> descriptions;\n            \n            if(in_products != nil)\n            {\n                NSNumberFormatter* formatter = [[NSNumberFormatter alloc] init];\n                [formatter setFormatterBehavior:NSNumberFormatterBehavior10_4];\n                [formatter setNumberStyle:NSNumberFormatterCurrencyStyle];\n                \n                for(SKProduct* product in in_products)\n                {\n                    ProductDesc description;\n                    description.m_id = [NSStringUtils newUTF8StringWithNSString:product.productIdentifier];\n                    description.m_name = [NSStringUtils newUTF8StringWithNSString:product.localizedTitle];\n                    description.m_description = [NSStringUtils newUTF8StringWithNSString:product.localizedDescription];\n                    \n                    [formatter setLocale:product.priceLocale];\n                    description.m_formattedPrice = [NSStringUtils newUTF8StringWithNSString:[formatter stringFromNumber:product.price]];\n                    \n                    NSLocale* storeLocale = product.priceLocale;\n                    description.m_countryCode = [NSStringUtils newUTF8StringWithNSString:(NSString*)CFLocaleGetValue((CFLocaleRef)storeLocale, kCFLocaleCountryCode)];\n                    \n                    descriptions.push_back(description);\n                }\n                \n                [formatter release];\n            }\n            \n            ChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_mainThread, [=](const ChilliSource::TaskContext& in_taskContext)\n            {\n                if(m_productDescDelegate == nullptr)\n                    return;\n\n                m_productDescDelegate(descriptions);\n                m_productDescDelegate = nullptr;\n            });\n        }\n        //---------------------------------------------------------------\n        //---------------------------------------------------------------\n        void IAPSystem::CancelProductDescriptionsRequest()\n        {\n            m_productDescDelegate = nullptr;\n            \n            ChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_system, [=](const ChilliSource::TaskContext& in_taskContext)\n            {\n                [m_storeKitSystem cancelProductsRequest];\n            });\n        }\n        //---------------------------------------------------------------\n        //---------------------------------------------------------------\n        void IAPSystem::RequestProductPurchase(const std::string& in_productId)\n        {\n            ChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_system, [=](const ChilliSource::TaskContext& in_taskContext)\n            {\n                CS_RELEASE_ASSERT(ContainsProductId(m_productRegInfos, in_productId), \"Products must be registered with the IAP system before purchasing\");\n                NSString* productID = [NSStringUtils newNSStringWithUTF8String:in_productId];\n                [m_storeKitSystem requestPurchaseWithProductID:productID andQuantity:1];\n                [productID release];\n            });\n        }\n        //---------------------------------------------------------------\n        //---------------------------------------------------------------\n        void IAPSystem::CloseTransaction(const TransactionSPtr& in_transaction, const TransactionCloseDelegate& in_delegate)\n        {\n            CS_ASSERT(in_delegate != nullptr, \"Cannot have null transaction close delegate\");\n            CS_ASSERT(m_transactionCloseDelegate == nullptr, \"Only 1 transaction can be closed at a time\");\n            \n            m_transactionCloseDelegate = in_delegate;\n            \n            ChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_system, [=](const ChilliSource::TaskContext& in_taskContext)\n            {\n                NSString* transactionId = [NSStringUtils newNSStringWithUTF8String:in_transaction->m_transactionId];\n                [m_storeKitSystem closeTransactionWithID:transactionId];\n                [transactionId release];\n                \n                ChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_mainThread, [=](const ChilliSource::TaskContext& in_taskContext)\n                {\n                    m_transactionCloseDelegate(in_transaction->m_productId, in_transaction->m_transactionId, true);\n                    m_transactionCloseDelegate = nullptr;\n                });\n            });\n        }\n        //---------------------------------------------------------------\n        //---------------------------------------------------------------\n        void IAPSystem::RestoreManagedPurchases()\n        {\n            ChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_system, [=](const ChilliSource::TaskContext& in_taskContext)\n            {\n                [m_storeKitSystem restoreNonConsumablePurchases];\n            });\n        }\n        //---------------------------------------------------------------\n        //---------------------------------------------------------------\n        std::vector<IAPSystem::ExtraProductInfo> IAPSystem::GetExtraProductInfo() const\n        {\n            CS_RELEASE_ASSERT(ChilliSource::Application::Get()->GetTaskScheduler()->IsMainThread() == true, \"This can only be called on the main thread.\");\n            \n            ExtraProductInfo extraProductInfo;\n            std::vector<ExtraProductInfo> extraProductsInfo;\n\n            NSArray* products = [m_storeKitSystem getNativeStoreData];\n            if (products != nil)\n            {\n                for (SKProduct* product in products)\n                {\n                    extraProductInfo.m_productId = [NSStringUtils newUTF8StringWithNSString:product.productIdentifier];\n                    extraProductInfo.m_unformattedPrice = [NSStringUtils newUTF8StringWithNSString:[product.price stringValue]];\n\n                    NSNumberFormatter* Formatter = [[[NSNumberFormatter alloc] init] autorelease];\n                    [Formatter setNumberStyle:NSNumberFormatterCurrencyStyle];\n                    [Formatter setLocale:product.priceLocale];\n                    extraProductInfo.m_currencyCode = [NSStringUtils newUTF8StringWithNSString:[Formatter currencyCode]];\n                    \n                    extraProductsInfo.push_back(extraProductInfo);\n                }\n            }\n            \n            return extraProductsInfo;\n        }\n        //---------------------------------------------------------------\n        //---------------------------------------------------------------\n        void IAPSystem::OnDestroy()\n        {\n            auto storeKitSystem = m_storeKitSystem;\n            m_storeKitSystem = nil;\n            \n            ChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_system, [storeKitSystem](const ChilliSource::TaskContext& in_taskContext)\n            {\n                [storeKitSystem release];\n            });\n            \n            m_productDescDelegate = nullptr;\n            m_transactionStatusDelegate = nullptr;\n            m_transactionCloseDelegate = nullptr;\n            m_productRegInfos.clear();\n            m_productRegInfos.shrink_to_fit();\n        }\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/iOS/Networking/IAP/StoreKitIAPSystem.h",
    "content": "//\n//  StoreKitIAPSystem.h\n//  ChilliSource\n//  Created by Scott Downie on 12/06/2013.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2013 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_IOS\n\n#include <ChilliSource/ChilliSource.h>\n\n#import <StoreKit/StoreKit.h>\n\n#include <functional>\n\nnamespace StoreKitIAP\n{\n    enum class TransactionResult\n    {\n        k_succeeded,\n        k_failed,\n        k_cancelled,\n        k_restored,\n        k_resumed\n    };\n    \n    typedef std::function<void(NSArray*)> ProductsDelegate;\n    typedef std::function<void(NSString*, TransactionResult, SKPaymentTransaction*)> TransactionUpdateDelegate;\n}\n\n@interface StoreKitIAPSystem : NSObject<SKProductsRequestDelegate, SKPaymentTransactionObserver>\n{\n    StoreKitIAP::ProductsDelegate mProductsDelegate;\n    NSArray* mProducts;\n    NSMutableArray* mOpenTransactions;\n    NSMutableArray* mUserPurchasedProductIDs;\n    SKProductsRequest* mProductsRequest;\n    StoreKitIAP::TransactionUpdateDelegate mTransactionUpdateDelegate;\n}\n//---------------------------------------------------------------\n/// Init\n//---------------------------------------------------------------\n-(StoreKitIAPSystem*) init;\n\n//---------------------------------------------------------------\n/// Is Purchasing Enabled\n///\n/// @return Whether purchasing is enabled or not\n//---------------------------------------------------------------\n-(BOOL) isPurchasingEnabled;\n\n//---------------------------------------------------------------\n/// Request Products Fore Delegate\n///\n/// Starts requesting the SKProducts from the store\n/// based on the given product IDs and return the\n/// results to the given delegate\n///\n/// @param Set of product IDs\n/// @param Delegate to pass results to\n//---------------------------------------------------------------\n-(void) requestProducts:(NSSet*)inProductIDs forDelegate:(const StoreKitIAP::ProductsDelegate&) inDelegate;\n//---------------------------------------------------------------\n/// Cancel Products Request\n///\n/// Cancels the request.\n//---------------------------------------------------------------\n-(void) cancelProductsRequest;\n\n//---------------------------------------------------------------\n/// Start Listening For Transactions\n///\n/// Add the delegate as a listener to the payment\n/// queue\n///\n/// @param Delegate to pass updates to\n//---------------------------------------------------------------\n-(void) startListeningForTransactions:(const StoreKitIAP::TransactionUpdateDelegate&) inDelegate;\n//---------------------------------------------------------------\n/// Stop Listening For Transactions\n///\n/// Remove the delegate as a listener to the payment\n/// queue\n//---------------------------------------------------------------\n-(void) stopListeningForTransactions;\n\n//---------------------------------------------------------------\n/// Request Purchase With Product ID and Quantity\n///\n/// @param Product ID\n/// @param Quantity\n//---------------------------------------------------------------\n-(void) requestPurchaseWithProductID:(NSString*)inProductID andQuantity:(u32)inQuantity;\n\n//---------------------------------------------------------------\n/// Close Transaction With ID\n///\n/// Close the transaction with the given transaction ID\n///\n/// @param Transaction ID\n//---------------------------------------------------------------\n-(void) closeTransactionWithID:(NSString*)inTransactionID;\n\n//---------------------------------------------------------------\n/// Restore Non Consumable Purchases\n///\n/// Request that the store trigger new purchase requests for\n/// owned non-consumable items\n//---------------------------------------------------------------\n-(void) restoreNonConsumablePurchases;\n\n//---------------------------------------------------------------\n/// Returns native store data as return from Apple\n///\n/// @author N Tanda\n///\n/// @return Array of native store product obejcts\n//---------------------------------------------------------------\n-(NSArray*) getNativeStoreData;\n\n@end\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/iOS/Networking/IAP/StoreKitIAPSystem.mm",
    "content": "//\n//  StoreKitIAPSystem.mm\n//  ChilliSource\n//  Created by Scott Downie on 12/06/2013.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2013 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_IOS\n\n#import <CSBackend/Platform/iOS/Networking/IAP/StoreKitIAPSystem.h>\n\n@implementation StoreKitIAPSystem\n\n//---------------------------------------------------------------\n//---------------------------------------------------------------\n-(StoreKitIAPSystem*) init\n{\n    if ((self = [super init]))\n    {\n        mProductsDelegate = nullptr;\n        mTransactionUpdateDelegate = nullptr;\n        mProducts = nil;\n        \n        mOpenTransactions = [[NSMutableArray alloc] init];\n        mUserPurchasedProductIDs = [[NSMutableArray alloc] init];\n\t}\n    \n\treturn self;\n}\n//---------------------------------------------------------------\n//---------------------------------------------------------------\n-(BOOL) isPurchasingEnabled\n{\n    return [SKPaymentQueue canMakePayments];\n}\n//---------------------------------------------------------------\n//---------------------------------------------------------------\n-(void) requestProducts:(NSSet*)inProductIDs forDelegate:(const StoreKitIAP::ProductsDelegate&) inDelegate\n{\n    //If we are already requesting the products then cancel and request the new product IDs instead\n    if(mProductsDelegate)\n    {\n        [self cancelProductsRequest];\n    }\n    \n    mProductsDelegate = inDelegate;\n    \n    if(mProducts != nil)\n    {\n        //Check if all the products already exist and if so then\n        //we can return the cached version\n        NSMutableArray* cachedProducts = [[NSMutableArray alloc] initWithCapacity:inProductIDs.count];\n        for(NSString* productID in inProductIDs)\n        {\n            for(SKProduct* product in mProducts)\n            {\n                if([productID compare:product.productIdentifier] == NSOrderedSame)\n                {\n                    [cachedProducts addObject:product];\n                    break;\n                }\n            }\n        }\n        \n        if(cachedProducts.count == inProductIDs.count)\n        {\n            mProductsDelegate(cachedProducts);\n            mProductsDelegate = nullptr;\n            return;\n        }\n    }\n    \n    mProductsRequest = [[SKProductsRequest alloc] initWithProductIdentifiers:inProductIDs];\n    mProductsRequest.delegate = self;\n    [mProductsRequest start];\n}\n//---------------------------------------------------------------\n//---------------------------------------------------------------\n-(void) cancelProductsRequest \n{\n    if(mProductsRequest != nil)\n    {\n        [mProductsRequest cancel];\n        [mProductsRequest release];\n    }\n    mProductsRequest = nil;\n\tmProductsDelegate = nullptr;\n}\n//---------------------------------------------------------------\n//---------------------------------------------------------------\n- (void)productsRequest:(SKProductsRequest*) inRequest didReceiveResponse:(SKProductsResponse *) inResponse\n{\n    //Clean up the product request as we allocated it on starting the request\n    [mProductsRequest release];\n    mProductsRequest = nil;\n    \n    if(inResponse.invalidProductIdentifiers.count > 0)\n    {\n        NSLog(@\"Invalid Product IDs: %@\", inResponse.invalidProductIdentifiers);\n    }\n    \n    if(mProductsDelegate == nullptr)\n        return;\n    \n    //Store the products as we will need the objects to perform the purchases\n    mProducts = [inResponse.products retain];\n\t\n    mProductsDelegate(mProducts);\n    mProductsDelegate = nullptr;\n}\n//---------------------------------------------------------------\n//---------------------------------------------------------------\n-(void) startListeningForTransactions:(const StoreKitIAP::TransactionUpdateDelegate&) inDelegate\n{\n    [self stopListeningForTransactions];\n    \n    mTransactionUpdateDelegate = inDelegate;\n    [[SKPaymentQueue defaultQueue] addTransactionObserver:self];\n}\n//---------------------------------------------------------------\n//---------------------------------------------------------------\n-(void) stopListeningForTransactions\n{\n    mTransactionUpdateDelegate = nullptr;\n    [[SKPaymentQueue defaultQueue] removeTransactionObserver:self];\n}\n//---------------------------------------------------------------\n//---------------------------------------------------------------\n-(void) requestPurchaseWithProductID:(NSString*)inProductID andQuantity:(u32)inQuantity\n{\n    CS_ASSERT([mOpenTransactions count] == 0 && [mUserPurchasedProductIDs count] == 0, \"IAPSystem: Cannot make multiple purchases at same time\");\n    \n    for(SKProduct* pProduct in mProducts)\n    {\n        if([inProductID compare:pProduct.productIdentifier] == NSOrderedSame)\n        {\n            [mUserPurchasedProductIDs addObject:inProductID];\n            \n            SKMutablePayment * pPayment = [SKMutablePayment paymentWithProduct:pProduct];\n            pPayment.quantity = inQuantity;\n            [[SKPaymentQueue defaultQueue] addPayment:pPayment];\n            return;\n        }\n    }\n    \n    //Invoke failure as we cannot find a product with that ID\n    NSLog(@\"ERROR: IAP: Purchase - Cannot find product with ID: %@\", inProductID);\n    \n    if(mTransactionUpdateDelegate)\n    {\n        mTransactionUpdateDelegate(inProductID, StoreKitIAP::TransactionResult::k_failed, nil);\n    }\n}\n//---------------------------------------------------------------\n//---------------------------------------------------------------\n- (void)paymentQueue:(SKPaymentQueue *)inQueue updatedTransactions:(NSArray*)inTransactions\n{\n    if(mTransactionUpdateDelegate == nullptr)\n        return;\n    \n\tfor(SKPaymentTransaction * pTransaction in inTransactions)\n    {\n        if(SKPaymentTransactionStatePurchasing != pTransaction.transactionState)\n        {\n            [mOpenTransactions addObject:pTransaction];\n        }\n        \n        StoreKitIAP::TransactionResult eResult = StoreKitIAP::TransactionResult::k_failed;\n        \n\t\tswitch (pTransaction.transactionState)\n        {\n\t\t\tcase SKPaymentTransactionStatePurchased:\n                //If this was not started by the user it is a past transaction resuming\n                //otherwise it is a vanilla transaction\n                eResult = StoreKitIAP::TransactionResult::k_resumed;\n                for(NSString* productID in mUserPurchasedProductIDs)\n                {\n                    if([productID compare:pTransaction.payment.productIdentifier] == NSOrderedSame)\n                    {\n                        eResult = StoreKitIAP::TransactionResult::k_succeeded;\n                        break;\n                    }\n                }\n                break;\n\t\t\tcase SKPaymentTransactionStateFailed:\n\t\t\t\tNSLog(@\"%@\", [pTransaction.error localizedDescription]);\n                eResult = (pTransaction.error.code == SKErrorPaymentCancelled) ? StoreKitIAP::TransactionResult::k_cancelled : StoreKitIAP::TransactionResult::k_failed;\n\t\t\t\tbreak;\n            case SKPaymentTransactionStateRestored:\n                eResult = StoreKitIAP::TransactionResult::k_restored;\n                break;\n\t\t\tdefault:\n\t\t\t\tcontinue;\n\t\t\t\tbreak;\n\t\t}\n\t\t\n        mTransactionUpdateDelegate(pTransaction.payment.productIdentifier, eResult, pTransaction);\n\t}\n}\n//---------------------------------------------------------------\n//---------------------------------------------------------------\n-(void) restoreNonConsumablePurchases\n{\n    [[SKPaymentQueue defaultQueue] restoreCompletedTransactions];\n}\n//---------------------------------------------------------------\n//---------------------------------------------------------------\n- (void)paymentQueue:(SKPaymentQueue *)queue restoreCompletedTransactionsFailedWithError:(NSError *)error\n{\n    NSLog(@\"restoreCompletedTransactionsFailedWithError:\");\n    NSLog(@\"%@\", [error localizedDescription]);\n}\n//---------------------------------------------------------------\n//---------------------------------------------------------------\n- (void)paymentQueueRestoreCompletedTransactionsFinished:(SKPaymentQueue *)queue\n{\n    NSLog(@\"paymentQueueRestoreCompletedTransactionsFinished:\");\n}\n//---------------------------------------------------------------\n//---------------------------------------------------------------\n-(void) closeTransactionWithID:(NSString*)inTransactionID\n{\n    for(SKPaymentTransaction* pTransaction in mOpenTransactions)\n    {\n        if([pTransaction.transactionIdentifier compare:inTransactionID] == NSOrderedSame)\n        {\n            u32 udwIndex = 0;\n            for(NSString* productID in mUserPurchasedProductIDs)\n            {\n                if([productID compare:pTransaction.payment.productIdentifier] == NSOrderedSame)\n                {\n                    [mUserPurchasedProductIDs removeObjectAtIndex:udwIndex];\n                    break;\n                }\n                ++udwIndex;\n            }\n           \n            [[SKPaymentQueue defaultQueue] finishTransaction:pTransaction];\n            [mOpenTransactions removeObject:pTransaction];\n            return;\n        }\n    }\n    \n    NSLog(@\"ERROR: IAP: Close Transaction - Cannot find transaction with ID: %@\", inTransactionID);\n}\n//---------------------------------------------------------------\n//---------------------------------------------------------------\n-(NSArray*) getNativeStoreData\n{\n    return [[mProducts retain] autorelease];\n}\n//---------------------------------------------------------------\n//---------------------------------------------------------------\n-(void) dealloc\n{\n    if(mProducts != nil)\n        [mProducts release];\n    \n    if(mOpenTransactions != nil)\n       [mOpenTransactions release];\n    \n    if(mUserPurchasedProductIDs != nil)\n        [mUserPurchasedProductIDs release];\n    \n    [super dealloc];\n}\n\n@end\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/iOS/Social/Communications/EmailComposer.h",
    "content": "//\n//  EmailComposer.h\n//  ChilliSource\n//  Created by Stuart McGaw on 09/06/2011.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2011 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_IOS\n\n#import <ChilliSource/ChilliSource.h>\n#import <CSBackend/Platform/iOS/ForwardDeclarations.h>\n#import <ChilliSource/Social/Communications/EmailComposer.h>\n\n#import <MessageUI/MessageUI.h>\n\n#import <mutex>\n\n@class EmailComposerDelegate;\n\nnamespace CSBackend\n{\n\tnamespace iOS\n    {\n        //-------------------------------------------------------------\n        /// The iOS backend for the email composition state system.\n        ///\n        /// @author S McGaw\n        //-------------------------------------------------------------\n        class EmailComposer final : public ChilliSource::EmailComposer\n\t\t{\n\t\tpublic:\n            CS_DECLARE_NAMEDTYPE(EmailComposer);\n            //-------------------------------------------------------\n\t\t\t/// Queries whether or not this system implements the\n            /// interface with the given Id.\n\t\t\t///\n            /// @author S McGaw\n            ///\n\t\t\t/// @param The interface Id.\n\t\t\t/// @return Whether system is of given type.\n\t\t\t//-------------------------------------------------------\n\t\t\tbool IsA(ChilliSource::InterfaceIDType in_interfaceId) const override;\n            //-------------------------------------------------------\n            /// Displays the email activity with the given recipients,\n            /// subject and contents.\n            ///\n            /// @author S Downie\n            ///\n            /// @param A list of recipients (UTF-8).\n            /// @param The subject (UTF-8).\n            /// @param The body of the email (UTF-8).\n            /// @param The format of the body of the email.\n            /// @param The callback describing the result of the email.\n            //-------------------------------------------------------\n\t\t\tvoid Present(const std::vector<std::string>& in_recipientAddresses, const std::string& in_subject, const std::string& in_contents, ContentFormat in_contentFormat,\n                         const SendResultDelegate& in_callback) override;\n            //-------------------------------------------------------\n            /// Displays the email activity with the given recipients,\n            /// subject and contents, and adds a list of attachments\n            /// to the email.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param A list of recipients (UTF-8).\n            /// @param The subject (UTF-8).\n            /// @param The body of the email (UTF-8).\n            /// @param The format of the body of the email.\n            /// @param The attachment.\n            /// @param The callback describing the result of the email.\n            //-------------------------------------------------------\n            void PresentWithAttachment(const std::vector<std::string>& in_recipientAddresses, const std::string& in_subject, const std::string& in_contents, ContentFormat in_contentFormat,\n                                       const Attachment& in_attachment, const SendResultDelegate & in_callback) override;\n            //-------------------------------------------------------\n            /// Determines whether or not the composer is presented.\n            /// @author Jordan Brown\n            //-------------------------------------------------------\n            bool IsPresented() override;\n            //-------------------------------------------------------\n            /// Called when the result is received from the email\n            /// composition view controller. This is for internal\n            /// use and should not be called manually by the user.\n            ///\n            /// @author Ian Copland\n            //-------------------------------------------------------\n\t\t\tvoid OnResult(MFMailComposeViewController* in_viewController, MFMailComposeResult in_result);\n\t\tprivate:\n            friend ChilliSource::EmailComposerUPtr ChilliSource::EmailComposer::Create();\n            \n            //-------------------------------------------------------\n            /// This checks whether or not the current iOS device\n            /// supports email. This should always be checked before\n            /// creating an instance of the class.\n            ///\n            /// @author S McGaw\n            //-------------------------------------------------------\n            static bool IsSupportedByDevice();\n            //----------------------------------------------------\n            /// Private constructor to force the use of the\n            /// factory method.\n            ///\n            /// @author Ian Copland\n            //----------------------------------------------------\n            EmailComposer();\n            //------------------------------------------------------\n            /// Called when the owning state is initialised.\n            ///\n            /// @author Ian Copland\n            //------------------------------------------------------\n            void OnInit() override;\n            //----------------------------------------------------\n            /// Cleans up the email composer and sets it back to\n            /// a state where it is ready to be presented again.\n            ///\n            /// @author Ian Copland\n            //----------------------------------------------------\n            void Cleanup();\n            //------------------------------------------------------\n            /// Called when the owning state is destroyed.\n            ///\n            /// @author Ian Copland\n            //------------------------------------------------------\n            void OnDestroy() override;\n            \n            SendResultDelegate m_resultDelegate;\n\t\t\tEmailComposerDelegate* m_emailComposerDelegate;\n\t\t\tMFMailComposeViewController* m_viewController;\n            UIViewController* m_rootViewController;\n            bool m_isPresented = false;\n\t\t};\n\t\t \n\t}\n}\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/iOS/Social/Communications/EmailComposer.mm",
    "content": "//\n//  EmailComposer.mm\n//  ChilliSource\n//  Created by Stuart McGaw on 09/06/2011.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2011 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_IOS\n\n#import <CSBackend/Platform/iOS/Social/Communications/EmailComposer.h>\n\n#import <CSBackend/Platform/iOS/Core/String/NSStringUtils.h>\n#import <CSBackend/Platform/iOS/Social/Communications/EmailComposerDelegate.h>\n#import <ChilliSource/Core/Base/Application.h>\n#import <ChilliSource/Core/File/FileSystem.h>\n#import <ChilliSource/Core/String/StringUtils.h>\n#import <ChilliSource/Core/Threading/TaskScheduler.h>\n\nnamespace CSBackend\n{\n\tnamespace iOS\n    {\n        CS_DEFINE_NAMEDTYPE(EmailComposer);\n        //-------------------------------------------------------\n        //-------------------------------------------------------\n        EmailComposer::EmailComposer()\n            : m_isPresented(false), m_emailComposerDelegate(nil), m_viewController(nil), m_rootViewController(nil)\n\t\t{\n\t\t}\n        //------------------------------------------------------\n        //------------------------------------------------------\n\t\tbool EmailComposer::IsA(ChilliSource::InterfaceIDType in_interfaceId) const\n        {\n\t\t\treturn (in_interfaceId == ChilliSource::EmailComposer::InterfaceID || in_interfaceId == EmailComposer::InterfaceID);\n\t\t}\n        //-------------------------------------------------------\n        //-------------------------------------------------------\n\t\tvoid EmailComposer::Present(const std::vector<std::string>& in_recipientAddresses, const std::string& in_subject, const std::string& in_contents, ContentFormat in_contentFormat,\n                                    const SendResultDelegate& in_callback)\n        {\n            Attachment emptyAttachment;\n            emptyAttachment.m_storageLocation = ChilliSource::StorageLocation::k_none;\n\t\t\tPresentWithAttachment(in_recipientAddresses, in_subject, in_contents, in_contentFormat, emptyAttachment, in_callback);\n\t\t}\n        //-------------------------------------------------------\n        //-------------------------------------------------------\n\t\tvoid EmailComposer::PresentWithAttachment(const std::vector<std::string>& in_recipientAddresses, const std::string& in_subject, const std::string& in_contents, ContentFormat in_contentFormat,\n                                                  const Attachment& in_attachment, const SendResultDelegate& in_callback)\n        {\n            @autoreleasepool\n            {\n                CS_ASSERT(!IsPresented(), \"Cannot present the email composer when it is already presented.\");\n                CS_RELEASE_ASSERT(ChilliSource::Application::Get()->GetTaskScheduler()->IsMainThread(), \"Tried to present Email Composer outside of main thread.\");\n                \n                m_isPresented = true;\n                \n                ChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_system, [=](const ChilliSource::TaskContext& taskContext)\n                {\n                    m_resultDelegate = in_callback;\n                \n                    m_viewController = [[MFMailComposeViewController alloc] init];\n                    if ([MFMailComposeViewController canSendMail] == false)\n                    {\n                        [m_viewController release];\n                        in_callback(SendResult::k_failed);\n                        return;\n                    }\n                \n                    m_viewController.mailComposeDelegate = m_emailComposerDelegate;\n                \n                    NSMutableArray * pNamesArray = [[NSMutableArray alloc] initWithCapacity:in_recipientAddresses.size()];\n                \n                    for (u32 nRecipient = 0; nRecipient < in_recipientAddresses.size(); nRecipient++)\n                    {\n                        NSString* address = [NSStringUtils newNSStringWithUTF8String:in_recipientAddresses[nRecipient]];\n                        [pNamesArray addObject:address];\n                        [address release];\n                    }\n                    [m_viewController setToRecipients:pNamesArray];\n                \n                    NSString* body = [NSStringUtils newNSStringWithUTF8String:in_contents];\n                    NSString* subject = [NSStringUtils newNSStringWithUTF8String:in_subject];\n                \n                    [m_viewController setMessageBody:body isHTML:(in_contentFormat == ContentFormat::k_html)];\n                    [m_viewController setSubject:subject];\n                \n                    [body release];\n                    [subject release];\n                \n                    //add the attachment if one is available.\n                    if (in_attachment.m_filename.size() > 0)\n                    {\n                        auto fileSystem = ChilliSource::Application::Get()->GetFileSystem();\n\n                        std::string strFilename;\n                        if (in_attachment.m_storageLocation == ChilliSource::StorageLocation::k_DLC && fileSystem->DoesFileExistInCachedDLC(in_attachment.m_filename) == false)\n                        {\n                            strFilename = fileSystem->GetAbsolutePathToStorageLocation(ChilliSource::StorageLocation::k_package) + fileSystem->GetPackageDLCPath() + in_attachment.m_filename;\n                        }\n                        else\n                        {\n                            strFilename = fileSystem->GetAbsolutePathToStorageLocation(in_attachment.m_storageLocation) + in_attachment.m_filename;\n                        }\n                    \n                        std::string strPath, strBasename;\n                        ChilliSource::StringUtils::SplitFilename(in_attachment.m_filename, strBasename, strPath);\n                        NSData* pData = [NSData dataWithContentsOfFile: [NSString stringWithUTF8String:strFilename.c_str()]];\n                        [m_viewController addAttachmentData:pData mimeType:[NSString stringWithUTF8String:in_attachment.m_mimeType.c_str()] fileName:[NSString stringWithUTF8String:strBasename.c_str()]];\n                    }\n                    \n                    m_rootViewController = [UIApplication sharedApplication].keyWindow.rootViewController;\n                    [m_rootViewController presentViewController:m_viewController animated:YES completion:nil];\n                \n                    [pNamesArray release];\n                });\n            }\n        }\n        //----------------------------------------------------\n        //----------------------------------------------------\n        void EmailComposer::Cleanup()\n        {\n            m_viewController.mailComposeDelegate = nil;\n            \n            [m_rootViewController dismissViewControllerAnimated:YES completion:nil];\n            m_rootViewController = nil;\n            \n            [m_viewController release];\n            m_viewController = nil;\n            \n        }\n        //-------------------------------------------------------\n        //-------------------------------------------------------\n        bool EmailComposer::IsPresented()\n        {\n            return m_isPresented;\n        }\n        //-------------------------------------------------------\n        //-------------------------------------------------------\n        void EmailComposer::OnResult(MFMailComposeViewController* in_viewController, MFMailComposeResult in_result)\n        {\n            Cleanup();\n            \n            ChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_mainThread, [=](const ChilliSource::TaskContext& taskContext)\n            {\n                CS_ASSERT(IsPresented(), \"Received result while email composer is not presented.\");\n            \n                SendResult sendResult = SendResult::k_failed;\n                switch (in_result)\n                {\n                    case MFMailComposeResultSaved:\n                    case MFMailComposeResultSent:\n                        sendResult = SendResult::k_succeed;\n                        break;\n                    case MFMailComposeResultCancelled:\n                        sendResult = SendResult::k_cancelled;\n                        break;\n                    default:\n                        sendResult = SendResult::k_failed;\n                        break;\n                }\n            \n                if (m_resultDelegate != nullptr)\n                {\n                    SendResultDelegate delegate = m_resultDelegate;\n                    m_resultDelegate = nullptr;\n                    delegate(SendResult::k_cancelled);\n                }\n                \n                m_isPresented = false;\n            });\n        }\n        //------------------------------------------------------\n        //------------------------------------------------------\n        void EmailComposer::OnInit()\n        {\n            m_emailComposerDelegate = [[EmailComposerDelegate alloc] initWithSystem:this];\n        }\n        //------------------------------------------------------\n        //------------------------------------------------------\n        void EmailComposer::OnDestroy()\n        {\n            CS_ASSERT(!m_isPresented, \"Cannot destroy Email Composer while presented.\");\n            [m_emailComposerDelegate release];\n            m_emailComposerDelegate = nil;\n        }\n        //-------------------------------------------------------\n        //-------------------------------------------------------\n\t\tbool EmailComposer::IsSupportedByDevice()\n        {\n            @autoreleasepool\n            {\n                NSString *reqSysVer = @\"3.0\";\n                NSString *currSysVer = [[UIDevice currentDevice] systemVersion];\n                bool osVersionSupported = ([currSysVer compare:reqSysVer options:NSNumericSearch] != NSOrderedAscending);\n                if (osVersionSupported)\n                {\n                    return [MFMailComposeViewController canSendMail];\n                }\n                \n                return false;\n            }\n\t\t}\n\t}\n}\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/iOS/Social/Communications/EmailComposerDelegate.h",
    "content": "//\n//  EmailComposerDelegate.h\n//  ChilliSource\n//  Created by Ian Copland on 15/04/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_IOS\n\n#import <ChilliSource/ChilliSource.h>\n#import <CSBackend/Platform/iOS/ForwardDeclarations.h>\n#import <CSBackend/Platform/iOS/Social/Communications/EmailComposer.h>\n\n#import <Foundation/Foundation.h>\n#import <MessageUI/MessageUI.h>\n\n//---------------------------------------------------------\n/// A delegate for recieving events for the email composer.\n///\n/// @author S McGaw\n//---------------------------------------------------------\n@interface EmailComposerDelegate : NSObject<MFMailComposeViewControllerDelegate>\n{\n\tCSBackend::iOS::EmailComposer* emailComposer;\n}\n//-------------------------------------------------------\n/// Constructor\n///\n/// @author Ian Copland\n///\n/// @param The email composition system.\n///\n/// @return The constructed object.\n//-------------------------------------------------------\n-(id) initWithSystem:(CSBackend::iOS::EmailComposer*)system;\n\n@end\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/iOS/Social/Communications/EmailComposerDelegate.mm",
    "content": "//\n//  EmailComposerDelegate.mm\n//  ChilliSource\n//  Created by Ian Copland on 15/04/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_IOS\n\n#import <CSBackend/Platform/iOS/Social/Communications/EmailComposerDelegate.h>\n\n#import <CSBackend/Platform/iOS/Core/String/NSStringUtils.h>\n\n@implementation EmailComposerDelegate\n//-------------------------------------------------------\n//-------------------------------------------------------\n-(id) initWithSystem:(CSBackend::iOS::EmailComposer*)system\n{\n\tif (self = [super init])\n    {\n        emailComposer = system;\n        CS_ASSERT(emailComposer, \"Cannot create email composer delegate without system.\");\n        return self;\n\t}\n    \n\treturn nil;\n}\n//-------------------------------------------------------\n//-------------------------------------------------------\n- (void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result  error:(NSError*)error\n{\n    if (error == nil)\n    {\n        emailComposer->OnResult(controller, result);\n    }\n    else\n    {\n        CS_LOG_ERROR([NSStringUtils newUTF8StringWithNSString:[error localizedDescription]]);\n        emailComposer->OnResult(controller, MFMailComposeResultFailed);\n    }\n}\n\n@end\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/iOS/Video/Base/SubtitlesRenderer.h",
    "content": "//\n//  SubtitlesRenderer.h\n//  ChilliSource\n//  Created by Ian Copland on 22/02/2013.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2013 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_IOS\n\n#ifndef _CHILLISOURCE_PLATFORM_IOS_VIDEO_SUBTITLESRENDERER_H_\n#define _CHILLISOURCE_PLATFORM_IOS_VIDEO_SUBTITLESRENDERER_H_\n\n#import <ChilliSource/ChilliSource.h>\n#import <ChilliSource/Video/Base/Subtitles.h>\n#import <CSBackend/Platform/iOS/Video/Base/VideoPlayer.h>\n\n#import <Foundation/Foundation.h>\n#import <UIKit/UIKit.h>\n\n//========================================================\n/// Subtitles Renderer\n///\n/// Renders subtitles on top of the video player.\n//========================================================\n@interface CSubtitlesRenderer : NSObject\n{\n    UIView* mpBaseView;\n    CADisplayLink* mpDisplayLink;\n    ChilliSource::Screen* m_screen;\n    ChilliSource::SubtitlesCSPtr mpSubtitles;\n    CSBackend::iOS::VideoPlayer* m_videoPlayer;\n    std::unordered_map<const ChilliSource::Subtitles::Subtitle*, UITextView*> maTextViewMap;\n    std::vector<const ChilliSource::Subtitles::Subtitle*> maSubtitlesToRemove;\n    TimeIntervalMs mCurrentTimeMS;\n}\n//--------------------------------------------------------\n/// init With Video Player\n///\n/// Initialises the subtitles renderer.\n///\n/// @param Video player\n/// @param The view.\n/// @param The subtitles.\n//--------------------------------------------------------\n-(id) initWithVideoPlayer:(CSBackend::iOS::VideoPlayer*)in_videoPlayer view:(UIView*)inpView andSubtitles:(const ChilliSource::SubtitlesCSPtr&)in_subtitles;\n//--------------------------------------------------------\n/// On Update\n///\n/// Called each frame.\n//--------------------------------------------------------\n-(void) OnUpdate;\n//--------------------------------------------------------\n/// Add Text View\n///\n/// Adds a new text view for the given subtitle.\n///\n/// @param the subtitle.\n/// @param Localised text resource\n//--------------------------------------------------------\n-(void) AddTextViewWithSubtitle:(const ChilliSource::Subtitles::Subtitle*)inpSubtitle andLocalisedText:(const ChilliSource::LocalisedText*) in_localisedText;\n//--------------------------------------------------------\n/// Update Text View\n///\n/// Updates the given text view.\n///\n/// @param The text view.\n/// @param the subtitle.\n//--------------------------------------------------------\n-(void) UpdateTextView:(UITextView*)inpTextView Subtitle:(const ChilliSource::Subtitles::Subtitle*)inpSubtitle Time:(TimeIntervalMs)inTimeMS;\n//--------------------------------------------------------\n/// Remove Text View\n///\n/// Queues the text view paired with the given subtitle\n/// for removal.\n///\n/// @param The subtitle.\n//--------------------------------------------------------\n-(void) RemoveTextView:(const ChilliSource::Subtitles::Subtitle*)inpSubtitle;\n//--------------------------------------------------------\n/// Set Alignment\n///\n/// Sets the alignment of the text in the given text view.\n///\n/// @param the UITextView.\n/// @param The alignment achor.\n//--------------------------------------------------------\n-(void) SetAlignment:(UITextView*)inpView WithAnchor:(ChilliSource::AlignmentAnchor)ineAnchor;\n//--------------------------------------------------------\n/// Text Alignment From Anchor\n///\n/// Converts from a ChilliSource alignment anchor to NSText\n/// alignment.\n///\n/// @param The alignment achor.\n/// @return the NSTextAlignment.\n//--------------------------------------------------------\n-(NSTextAlignment) TextAlignmentFromAnchor:(ChilliSource::AlignmentAnchor)ineAnchor;\n//--------------------------------------------------------\n/// Calculate Text Box Rect\n///\n/// @return the rectangle in which the text box should\n/// appear on screen.\n//--------------------------------------------------------\n-(CGRect) CalculateTextBoxRect:(const ChilliSource::Rectangle&)inRelativeBounds;\n//--------------------------------------------------------\n/// CleanUp\n///\n/// Cleans up any possible retainers, should be called before releasing\n//--------------------------------------------------------\n-(void) CleanUp;\n//--------------------------------------------------------\n/// Dealloc\n///\n/// destroys the listener\n//--------------------------------------------------------\n-(void) dealloc;\n@end\n\n#endif\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/iOS/Video/Base/SubtitlesRenderer.mm",
    "content": "//\n//  SubtitlesRenderer.mm\n//  ChilliSource\n//  Created by Ian Copland on 22/02/2013.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2013 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_IOS\n\n#import <CSBackend/Platform/iOS/Video/Base/SubtitlesRenderer.h>\n\n#import <CSBackend/Platform/iOS/Core/String/NSStringUtils.h>\n#import <ChilliSource/Core/Base/Application.h>\n#import <ChilliSource/Core/Base/Screen.h>\n#import <ChilliSource/Core/String/StringUtils.h>\n#import <ChilliSource/Core/Localisation/LocalisedText.h>\n#import <ChilliSource/Video/Base/Subtitles.h>\n\n#import <QuartzCore/QuartzCore.h>\n\n@implementation CSubtitlesRenderer\n//--------------------------------------------------------\n//--------------------------------------------------------\n-(id) initWithVideoPlayer:(CSBackend::iOS::VideoPlayer*)in_videoPlayer view:(UIView*)inpView andSubtitles:(const ChilliSource::SubtitlesCSPtr&)in_subtitles\n{\n    if(!(self = [super init]))\n\t{\n\t\treturn nil;\n\t}\n    \n    m_videoPlayer = in_videoPlayer;\n    mpBaseView = inpView;\n    m_screen = ChilliSource::Application::Get()->GetSystem<ChilliSource::Screen>();\n    \n    //create the display link\n    mpDisplayLink = [CADisplayLink displayLinkWithTarget: self selector: @selector(OnUpdate)];\n    [mpDisplayLink addToRunLoop: [NSRunLoop mainRunLoop] forMode:NSDefaultRunLoopMode];\n    \n    //load the subtitles\n    CS_ASSERT(in_subtitles != nullptr, \"Cannot render null subtitles\");\n    mpSubtitles = in_subtitles;\n    \n    return self;\n}\n//--------------------------------------------------------\n/// On Update\n//--------------------------------------------------------\n-(void) OnUpdate\n{\n    //get the current subtitles\n    f32 fPosition = m_videoPlayer->GetCurrentTime();\n    TimeIntervalMs currentTimeMS = (TimeIntervalMs)(fPosition * 1000.0f);\n    \n    if (mCurrentTimeMS != currentTimeMS)\n    {\n        mCurrentTimeMS = currentTimeMS;\n        auto pSubtitleArray = mpSubtitles->GetSubtitlesAtTime(mCurrentTimeMS);\n        auto localisedText = mpSubtitles->GetLocalisedText().get();\n\n        //add any new subtitles\n        for (auto it = pSubtitleArray.begin(); it != pSubtitleArray.end(); ++it)\n        {\n            \n            auto mapEntry = maTextViewMap.find(*it);\n            if (mapEntry == maTextViewMap.end())\n            {\n                [self AddTextViewWithSubtitle:*it andLocalisedText:localisedText];\n            }\n        }\n\n        //update the current text views\n        for (auto it = maTextViewMap.begin(); it != maTextViewMap.end(); ++it)\n        {\n            [self UpdateTextView:it->second Subtitle:it->first Time:mCurrentTimeMS];\n        }\n\n        //removes any text views that are no longer needed.\n        for (auto it = maSubtitlesToRemove.begin(); it != maSubtitlesToRemove.end(); ++it)\n        {\n            auto mapEntry = maTextViewMap.find(*it);\n            if (mapEntry != maTextViewMap.end())\n            {\n                [mapEntry->second removeFromSuperview];\n                [mapEntry->second release];\n                maTextViewMap.erase(mapEntry);\n            }\n        }\n        maSubtitlesToRemove.clear();\n    }\n}\n//--------------------------------------------------------\n/// Add Text View\n//--------------------------------------------------------\n-(void) AddTextViewWithSubtitle:(const ChilliSource::Subtitles::Subtitle*)inpSubtitle andLocalisedText:(const ChilliSource::LocalisedText*) in_localisedText\n{\n    //get the style\n    const ChilliSource::Subtitles::Style* pStyle = mpSubtitles->GetStyleWithName(inpSubtitle->m_styleName);\n    if (pStyle == nullptr)\n    {\n        CS_LOG_ERROR(\"Cannot find style '\" + inpSubtitle->m_styleName + \"' in subtitles.\");\n        return;\n    }\n    \n    //create the new text view\n    UITextView* pNewTextView = [[UITextView alloc] initWithFrame: [self CalculateTextBoxRect:pStyle->m_bounds]];\n    [mpBaseView addSubview:pNewTextView];\n    [mpBaseView bringSubviewToFront:pNewTextView];\n    pNewTextView.backgroundColor = [UIColor clearColor];\n    \n    //setup the text.\n    NSString* text = [NSStringUtils newNSStringWithUTF8String:in_localisedText->GetText(inpSubtitle->m_localisedTextId)];\n    NSString* fontName = [NSStringUtils newNSStringWithUTF8String:pStyle->m_fontName];\n    [pNewTextView setText:text];\n    [pNewTextView setFont:[UIFont fontWithName:fontName size: pStyle->m_fontSize]];\n    [pNewTextView setTextColor:[UIColor colorWithRed:pStyle->m_colour.r green:pStyle->m_colour.g blue:pStyle->m_colour.b alpha:0.0f]];\n    [pNewTextView setUserInteractionEnabled:NO];\n    [text release];\n    [fontName release];\n    \n    [self SetAlignment: pNewTextView WithAnchor: pStyle->m_alignment];\n    maTextViewMap.insert(std::make_pair(inpSubtitle, pNewTextView));\n}\n//--------------------------------------------------------\n/// Update Text View\n//--------------------------------------------------------\n-(void) UpdateTextView:(UITextView*)inpTextView Subtitle:(const ChilliSource::Subtitles::Subtitle*)inpSubtitle Time:(TimeIntervalMs)inTimeMS\n{\n    const ChilliSource::Subtitles::Style* pStyle = mpSubtitles->GetStyleWithName(inpSubtitle->m_styleName);\n    \n    f32 fFade = 0.0f;\n    s64 lwRelativeTime = ((s64)inTimeMS) - ((s64)inpSubtitle->m_startTimeMS);\n    s64 lwDisplayTime = ((s64)inpSubtitle->m_endTimeMS) - ((s64)inpSubtitle->m_startTimeMS);\n    \n    //subtitle should not be displayed yet so remove\n    if (lwRelativeTime < 0)\n    {\n        [self RemoveTextView:inpSubtitle];\n    }\n    \n    //fading in\n    else if (lwRelativeTime < pStyle->m_fadeTimeMS)\n    {\n        fFade = ((f32)lwRelativeTime) / ((f32)pStyle->m_fadeTimeMS);\n    }\n    \n    //active\n    else if (lwRelativeTime < lwDisplayTime - pStyle->m_fadeTimeMS)\n    {\n        fFade = 1.0f;\n    }\n    \n    //fading out\n    else if (lwRelativeTime < lwDisplayTime)\n    {\n        fFade = 1.0f - (((f32)lwRelativeTime - (lwDisplayTime - pStyle->m_fadeTimeMS)) / ((f32)pStyle->m_fadeTimeMS));\n    }\n    \n    //should no longer be displayed so remove\n    else if (lwRelativeTime >= lwDisplayTime)\n    {\n        [self RemoveTextView:inpSubtitle];\n    }\n    \n    [inpTextView setTextColor:[UIColor colorWithRed:pStyle->m_colour.r green:pStyle->m_colour.g blue:pStyle->m_colour.b alpha:(fFade * pStyle->m_colour.a)]];\n    [self SetAlignment: inpTextView WithAnchor: pStyle->m_alignment];\n}\n//--------------------------------------------------------\n/// Remove Text View\n//--------------------------------------------------------\n-(void) RemoveTextView:(const ChilliSource::Subtitles::Subtitle*)inpSubtitle\n{\n    maSubtitlesToRemove.push_back(inpSubtitle);\n}\n//--------------------------------------------------------\n/// Set Alignment\n//--------------------------------------------------------\n-(void) SetAlignment:(UITextView*)inpView WithAnchor:(ChilliSource::AlignmentAnchor)ineAnchor\n{\n    inpView.textAlignment = [self TextAlignmentFromAnchor: ineAnchor];\n    \n    switch (ineAnchor)\n    {\n        case ChilliSource::AlignmentAnchor::k_topLeft:\n        case ChilliSource::AlignmentAnchor::k_topCentre:\n        case ChilliSource::AlignmentAnchor::k_topRight:\n        {\n            inpView.contentOffset = (CGPoint){.x = 0.0f, .y = 0.0f};\n            break;\n        }\n        case ChilliSource::AlignmentAnchor::k_middleLeft:\n        case ChilliSource::AlignmentAnchor::k_middleCentre:\n        case ChilliSource::AlignmentAnchor::k_middleRight:\n        {\n            f32 fBoxSize = [inpView bounds].size.height;\n            CGSize textViewSize = [inpView sizeThatFits:CGSizeMake(inpView.frame.size.width, FLT_MAX)];\n            f32 fContentSize = textViewSize.height;\n            f32 fOffset = (fBoxSize - fContentSize);\n            if (fOffset < 0.0f)\n            {\n                fOffset = 0.0f;\n            }\n            inpView.contentOffset = (CGPoint){.x = 0.0f, .y = -fOffset / 2.0f};\n            break;\n            break;\n        }\n        case ChilliSource::AlignmentAnchor::k_bottomLeft:\n        case ChilliSource::AlignmentAnchor::k_bottomCentre:\n        case ChilliSource::AlignmentAnchor::k_bottomRight:\n        {\n            f32 fBoxSize = [inpView bounds].size.height;\n            CGSize textViewSize = [inpView sizeThatFits:CGSizeMake(inpView.frame.size.width, FLT_MAX)];\n            f32 fContentSize = textViewSize.height;\n            f32 fOffset = (fBoxSize - fContentSize);\n            if (fOffset < 0.0f)\n            {\n                fOffset = 0.0f;\n            }\n            inpView.contentOffset = (CGPoint){.x = 0.0f, .y = -fOffset};\n            break;\n        }\n        default:\n             CS_LOG_WARNING(\"Could not set vertical alignment.\");\n            break;\n    }\n}\n//--------------------------------------------------------\n/// Text Alignment From Anchor\n//--------------------------------------------------------\n-(NSTextAlignment) TextAlignmentFromAnchor:(ChilliSource::AlignmentAnchor)ineAnchor\n{\n    switch (ineAnchor)\n    {\n        case ChilliSource::AlignmentAnchor::k_topLeft:\n        case ChilliSource::AlignmentAnchor::k_middleLeft:\n        case ChilliSource::AlignmentAnchor::k_bottomLeft:\n            return NSTextAlignmentLeft;\n        case ChilliSource::AlignmentAnchor::k_topCentre:\n        case ChilliSource::AlignmentAnchor::k_middleCentre:\n        case ChilliSource::AlignmentAnchor::k_bottomCentre:\n            return NSTextAlignmentCenter;\n        case ChilliSource::AlignmentAnchor::k_topRight:\n        case ChilliSource::AlignmentAnchor::k_middleRight:\n        case ChilliSource::AlignmentAnchor::k_bottomRight:\n            return NSTextAlignmentRight;\n        default:\n            CS_LOG_WARNING(\"Could not convert alignment anchor to NSTextAlignment.\");\n            return NSTextAlignmentLeft;\n    }\n}\n//--------------------------------------------------------\n/// Calculate Text Box Rect\n///\n/// @return the rectangle in which the text box should\n/// appear on screen.\n//--------------------------------------------------------\n-(CGRect) CalculateTextBoxRect:(const ChilliSource::Rectangle&)inRelativeBounds\n{\n    ChilliSource::Vector2 vScreenDimensions(m_screen->GetResolution().x * m_screen->GetInverseDensityScale(), m_screen->GetResolution().y * m_screen->GetInverseDensityScale());\n    ChilliSource::Vector2 vVideoDimensions = m_videoPlayer->GetVideoDimensions();\n    float fScreenAspectRatio = vScreenDimensions.x / vScreenDimensions.y;\n    float fVideoAspectRatio = vVideoDimensions.x / vVideoDimensions.y;\n    \n    ChilliSource::Vector2 vVideoViewDimensions;\n    if (fScreenAspectRatio < fVideoAspectRatio)\n    {\n        vVideoViewDimensions.x = vScreenDimensions.x;\n        vVideoViewDimensions.y = vScreenDimensions.x * (vVideoDimensions.y / vVideoDimensions.x);\n    }\n    else\n    {\n        vVideoViewDimensions.x = vScreenDimensions.y * (vVideoDimensions.x / vVideoDimensions.y);\n        vVideoViewDimensions.y = vScreenDimensions.y;\n    }\n    \n    ChilliSource::Vector2 vVideoViewBottomLeft = (vScreenDimensions - vVideoViewDimensions) * 0.5f;\n    \n    return CGRectMake(vVideoViewBottomLeft.x + inRelativeBounds.Left() * vVideoViewDimensions.x, vVideoViewBottomLeft.y + inRelativeBounds.Bottom() * vVideoViewDimensions.y, inRelativeBounds.vSize.x * vVideoViewDimensions.x, inRelativeBounds.vSize.y * vVideoViewDimensions.y);\n}\n\n//--------------------------------------------------------\n/// CleanUp\n///\n/// Cleans up any possible retainers, should be called before releasing\n//--------------------------------------------------------\n-(void) CleanUp\n{\n    [mpDisplayLink invalidate];\n}\n\n//--------------------------------------------------------\n/// Dealloc\n//--------------------------------------------------------\n-(void) dealloc\n{\n    [super dealloc];\n}\n@end\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/iOS/Video/Base/VideoOverlayView.h",
    "content": "//\n//  VideoOverlayView.h\n//  ChilliSource\n//  Created by Ian Copland on 11/04/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_IOS\n\n#import <ChilliSource/ChilliSource.h>\n#import <Foundation/Foundation.h>\n#import <UIKit/UIKit.h>\n\n//---------------------------------------------------\n/// A view that overlays the video view. This consumes\n/// touches so the EAGLView doesn't receive them during\n/// video playback.\n///\n/// @author Ian Copland\n//---------------------------------------------------\n@interface VideoOverlayView : UIView\n{\n}\n\n//---------------------------------------------------\n/// Constructor\n///\n/// @author Ian Copland\n///\n/// @param The frame.\n//---------------------------------------------------\n- (id) initWithFrame:(CGRect)in_frame;\n//---------------------------------------------------\n/// Called when a touch begins over this view.\n///\n/// @author Ian Copland\n///\n/// @param The touches.\n/// @param The event.\n//---------------------------------------------------\n- (void) touchesBegan:(NSSet *)in_touches withEvent:(UIEvent*)in_event;\n//---------------------------------------------------\n/// Called when a touch moves over this view.\n///\n/// @author Ian Copland\n///\n/// @param The touches.\n/// @param The event.\n//---------------------------------------------------\n- (void) touchesMoved:(NSSet *)in_touches withEvent:(UIEvent*)in_event;\n//---------------------------------------------------\n/// Called when a touch ends over this view.\n///\n/// @author Ian Copland\n///\n/// @param The touches.\n/// @param The event.\n//---------------------------------------------------\n- (void) touchesEnded:(NSSet *)in_touches withEvent:(UIEvent*)in_event;\n//---------------------------------------------------\n/// Called when a touch is cancelled over this view.\n///\n/// @author Ian Copland\n///\n/// @param The touches.\n/// @param The event.\n//---------------------------------------------------\n- (void) touchesCancelled:(NSSet *)in_touches withEvent:(UIEvent*)in_event;\n\n@end\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/iOS/Video/Base/VideoOverlayView.mm",
    "content": "//\n//  VideoOverlayView.mm\n//  ChilliSource\n//  Created by Ian Copland on 11/04/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_IOS\n\n#import <CSBackend/Platform/iOS/Video/Base/VideoOverlayView.h>\n\n@implementation VideoOverlayView\n\n//---------------------------------------------------\n//---------------------------------------------------\n- (id) initWithFrame:(CGRect)in_frame\n{\n    if (self = [super initWithFrame: in_frame])\n    {\n        return self;\n    }\n    return nil;\n}\n//---------------------------------------------------\n//---------------------------------------------------\n- (void) touchesBegan:(NSSet*)in_touches withEvent:(UIEvent*)in_event\n{\n}\n//---------------------------------------------------\n//---------------------------------------------------\n- (void) touchesMoved:(NSSet*)in_touches withEvent:(UIEvent*)in_event\n{\n}\n//---------------------------------------------------\n//---------------------------------------------------\n- (void) touchesEnded:(NSSet*)in_touches withEvent:(UIEvent*)in_event\n{\n}\n//---------------------------------------------------\n//---------------------------------------------------\n- (void) touchesCancelled:(NSSet*)in_touches withEvent:(UIEvent*)in_event\n{\n}\n\n@end\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/iOS/Video/Base/VideoPlayer.h",
    "content": "//\n//  VideoPlayer.h\n//  ChilliSource\n//  Created by S Downie on 12/05/2011.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2011 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_IOS\n\n#import <ChilliSource/ChilliSource.h>\n#import <CSBackend/Platform/iOS/ForwardDeclarations.h>\n#import <ChilliSource/Video/Base/VideoPlayer.h>\n\n#import <atomic>\n#import <mutex>\n\n@class MPMoviePlayerController;\n@class CVideoPlayerTapListener;\n@class CSubtitlesRenderer;\n@class UIView;\n\nnamespace CSBackend\n{\n    namespace iOS\n    {\n        //--------------------------------------------------------------\n        /// The iOS backend for the video player.\n        ///\n        /// @author S Downie\n        //--------------------------------------------------------------\n        class VideoPlayer final : public ChilliSource::VideoPlayer\n        {\n        public:\n            CS_DECLARE_NAMEDTYPE(VideoPlayer);\n\t\t\t//-------------------------------------------------------\n\t\t\t/// Queries whether or not this system implements the\n            /// interface with the given Id.\n\t\t\t///\n            /// @author S Downie\n            ///\n\t\t\t/// @param The interface Id.\n\t\t\t/// @param Whether system is of given type.\n\t\t\t//-------------------------------------------------------\n\t\t\tbool IsA(ChilliSource::InterfaceIDType in_interfaceId) const override;\n            //-------------------------------------------------------\n            /// Begin streaming the video from file\n            ///\n            /// @author S Downie\n            ///\n            /// @param The storage location of the video.\n            /// @param The video file name.\n            /// @param Connection to the completion delegate.\n            /// @param [Optional] Whether or not the video can be\n            /// dismissed by tapping. Defaults to true.\n            /// @param [Optional] The video background colour. Defaults\n            /// to black.\n            //--------------------------------------------------------\n            void Present(ChilliSource::StorageLocation in_storageLocation, const std::string& in_fileName, VideoCompleteDelegate::Connection&& in_delegateConnection, bool in_dismissWithTap = true,\n                         const ChilliSource::Colour& in_backgroundColour = ChilliSource::Colour::k_black) override;\n            //--------------------------------------------------------\n            /// Begin streaming the video from file with subtitles.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param The storage location of the video.\n            /// @param The video file name.\n            /// @param The subtitles resource.\n            /// @param Connection to the completion delegate.\n            /// @param [Optional] Whether or not the video can be\n            /// dismissed by tapping. Defaults to true.\n            /// @param [Optional] The video background colour. Defaults\n            /// to black.\n            //--------------------------------------------------------\n            void PresentWithSubtitles(ChilliSource::StorageLocation in_storageLocation, const std::string& in_fileName, const ChilliSource::SubtitlesCSPtr& in_subtitles, VideoCompleteDelegate::Connection&& in_delegateConnection,\n                                      bool in_dismissWithTap, const ChilliSource::Colour& in_backgroundColour = ChilliSource::Colour::k_black) override;\n            //-------------------------------------------------------\n            /// @author S Downie\n            ///\n            /// This isn't thread-safe, and should only be called\n            /// on the system thread. Used by SubtitlesRenderer.\n            ///\n            /// @return The current time though the video.\n\t\t\t//-------------------------------------------------------\n\t\t\tf32 GetCurrentTime() const;\n            //-------------------------------------------------------\n            /// @author Ian Copland\n            ///\n            /// This isn't thread-safe, and should only be called\n            /// on the system thread. Used by SubtitlesRenderer.\n            ///\n            /// @return the actual dimensions of the playing video.\n            //-------------------------------------------------------\n            ChilliSource::Vector2 GetVideoDimensions() const;\n            //-------------------------------------------------------\n            /// Returns whether or not the player is currently\n            /// presented.\n            ///\n            /// @author Jordan Brown\n            //-------------------------------------------------------\n            bool IsPresented() const noexcept override;\n        private:\n            friend ChilliSource::VideoPlayerUPtr ChilliSource::VideoPlayer::Create();\n            //-------------------------------------------------------\n            /// Represents the current state of the video player.\n            ///\n            /// @author Jordan Brown\n            //-------------------------------------------------------\n            enum class State\n            {\n                k_inactive,\n                k_loading,\n                k_ready,\n                k_playing\n            };\n            //--------------------------------------------------------\n            /// Private constructor to force use of factory method\n            ///\n            /// @author S Downie\n            //--------------------------------------------------------\n            VideoPlayer();\n            //--------------------------------------------------------\n            /// Called when the owning state is initialised.\n            ///\n            /// @author Ian Copland\n            //--------------------------------------------------------\n            void OnInit() override;\n            //--------------------------------------------------------\n            /// Called when the application is resumed. if a video was\n            /// playing when suspend was called, it will be resumed.\n            ///\n            /// @author Ian Copland\n            //--------------------------------------------------------\n            void OnResume() override;\n            //--------------------------------------------------------\n            /// Called when the video is tapped.\n            ///\n            /// @author Ian Copland\n            //--------------------------------------------------------\n            void OnTapped();\n            //--------------------------------------------------------\n            /// Triggered when the preloading of the video has completed\n            /// This will start the playback of the movie.\n            ///\n            /// @author S Downie\n            //--------------------------------------------------------\n            void OnLoadStateChanged();\n            //--------------------------------------------------------\n            /// Triggered when the movie playback ends or is stopped.\n            ///\n            /// @author S Downie\n            //--------------------------------------------------------\n            void OnPlaybackFinished();\n            //--------------------------------------------------------\n            /// Prepares the video for being played.\n            ///\n            ///  @author S Downie.\n            //--------------------------------------------------------\n            void Prepare();\n            //--------------------------------------------------------\n            /// Plays the movie.\n            ///\n            /// @author S Downie.\n            //--------------------------------------------------------\n            void Play();\n            //--------------------------------------------------------\n            /// Create the movie view frame, size and position.\n            ///\n            /// @author S Downie\n            //--------------------------------------------------------\n            void SetupMovieView();\n            //--------------------------------------------------------\n            /// Attach the movie players UIView to the key window.\n            ///\n            /// @author S Downie\n            //--------------------------------------------------------\n            void AttachMovieViewToWindow();\n            //--------------------------------------------------------\n            /// Register with the notification centre for the relevant\n            /// MPMoviePlayer notifications for starting and stopping.\n            ///\n            /// @author S Downie\n            //--------------------------------------------------------\n            void ListenForMoviePlayerNotifications();\n            //--------------------------------------------------------\n            /// Deregister with the notification centre for the relevant\n            /// MPMoviePlayer notifications for starting and stopping\n            ///\n            /// @author Ian Copland\n            //--------------------------------------------------------\n            void StopListeningForMoviePlayerNotifications();\n            //--------------------------------------------------------\n            /// Creates the video overlay view and sets up any active\n            /// overlay views.\n            ///\n            /// @author S Downie\n            //--------------------------------------------------------\n            void CreateVideoOverlay();\n            //--------------------------------------------------------\n            /// Deletes the video overlay view and cleans up any active\n            /// overlay views.\n            ///\n            /// @author S Downie\n            //--------------------------------------------------------\n            void DeleteVideoOverlay();\n            //--------------------------------------------------------\n            /// Called when the owning state is destroyed.\n            ///\n            /// @author Ian Copland\n            //--------------------------------------------------------\n            void OnDestroy() override;\n            \n        private:\n            ChilliSource::Screen* m_screen;\n            \n            std::atomic<State> m_currentState;\n            MPMoviePlayerController* m_moviePlayerController;\n            \n            bool m_dismissWithTap;\n            ChilliSource::SubtitlesCSPtr m_subtitles;\n            UIView* m_videoOverlayView;\n            CVideoPlayerTapListener* m_tapListener;\n            CSubtitlesRenderer* m_subtitlesRenderer;\n            \n            ChilliSource::Colour m_backgroundColour;\n            \n            ChilliSource::EventConnectionUPtr m_moviePlayerLoadStateChangedConnection;\n            ChilliSource::EventConnectionUPtr m_moviePlayerPlaybackFinishedConnection;\n            \n            VideoCompleteDelegate::Connection m_completionDelegateConnection;\n        };\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/iOS/Video/Base/VideoPlayer.mm",
    "content": "//\n//  VideoPlayer.cpp\n//  ChilliSource\n//  Created by S Downie on 12/05/2011.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2011 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_IOS\n\n#import <CSBackend/Platform/iOS/Video/Base/VideoPlayer.h>\n\n#import <CSBackend/Platform/iOS/Core/File/FileSystem.h>\n#import <CSBackend/Platform/iOS/Core/Notification/NSNotificationAdapter.h>\n#import <CSBackend/Platform/iOS/Core/String/NSStringUtils.h>\n#import <CSBackend/Platform/iOS/Video/Base/SubtitlesRenderer.h>\n#import <CSBackend/Platform/iOS/Video/Base/VideoOverlayView.h>\n#import <CSBackend/Platform/iOS/Video/Base/VideoPlayerTapListener.h>\n#import <ChilliSource/Core/Base/Application.h>\n#import <ChilliSource/Core/Base/Screen.h>\n#import <ChilliSource/Core/Delegate/MakeDelegate.h>\n#import <ChilliSource/Core/Math/MathUtils.h>\n#import <ChilliSource/Core/String/StringUtils.h>\n#import <ChilliSource/Core/Threading/TaskScheduler.h>\n\n#import <AudioToolbox/AudioSession.h>\n#import <MediaPlayer/MediaPlayer.h>\n\nnamespace CSBackend\n{\n    namespace iOS\n    {\n        namespace\n        {\n            //--------------------------------------------------------------\n            //--------------------------------------------------------------\n            void AudioRouteCallback(void *in_userData, AudioSessionPropertyID in_propertyID, UInt32 in_propertyValueSize, const void *in_propertyValue)\n            {\n                // Only interested in audio route changes.\n                if(in_propertyID != kAudioSessionProperty_AudioRouteChange)\n                {\n                    return;\n                }\n                \n                const CFDictionaryRef kRouteChangeDictionary = (CFDictionaryRef)in_propertyValue;\n                const CFNumberRef     kRouteChangeReasonRef  = (CFNumberRef)CFDictionaryGetValue(kRouteChangeDictionary, CFSTR (kAudioSession_AudioRouteChangeKey_Reason));\n                \n                SInt32 dwRouteChangeReason(0);\n                CFNumberGetValue (kRouteChangeReasonRef, kCFNumberSInt32Type, &dwRouteChangeReason);\n                \n                // If headphones pulled out or connection to speakers lost.\n                if(dwRouteChangeReason == kAudioSessionRouteChangeReason_OldDeviceUnavailable)\n                {\n                    // Get the movie controller.\n                    MPMoviePlayerController *pMovieController = static_cast<MPMoviePlayerController*>(in_userData);\n                    \n                    // Restart the movie.\n                    if(pMovieController)\n                    {\n                        // The sleep is required, as sometimes it seems the callback is applied before the video has been paused.\n                        usleep(3000);\n                        [pMovieController play];\n                    }\n                }\n            }\n        }\n        \n        CS_DEFINE_NAMEDTYPE(VideoPlayer);\n        //--------------------------------------------------------------\n        //--------------------------------------------------------------\n        VideoPlayer::VideoPlayer()\n            : m_moviePlayerController(nil), m_tapListener(nil), m_currentState(State::k_inactive), m_dismissWithTap(false), m_videoOverlayView(nil), m_subtitlesRenderer(nil)\n        {\n        }\n\t\t//--------------------------------------------------------------\n\t\t//--------------------------------------------------------------\n\t\tbool VideoPlayer::IsA(ChilliSource::InterfaceIDType in_interfaceId) const\n\t\t{\n\t\t\treturn (in_interfaceId == ChilliSource::VideoPlayer::InterfaceID || in_interfaceId == VideoPlayer::InterfaceID);\n\t\t}\n        //--------------------------------------------------------------\n        //--------------------------------------------------------------\n        void VideoPlayer::Present(ChilliSource::StorageLocation in_storageLocation, const std::string& in_fileName, VideoCompleteDelegate::Connection&& in_delegateConnection, bool in_dismissWithTap, const ChilliSource::Colour& in_backgroundColour)\n        {\n            CS_RELEASE_ASSERT(ChilliSource::Application::Get()->GetTaskScheduler()->IsMainThread(), \"Cannot present video on background thread.\");\n            \n            auto previousState = m_currentState.exchange(State::k_loading);\n            CS_RELEASE_ASSERT(previousState == State::k_inactive, \"Cannot present video while a video is already playing.\");\n            \n            m_completionDelegateConnection = std::move(in_delegateConnection);\n            \n            ChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_system, [=](const ChilliSource::TaskContext& taskContext)\n            {\n                m_backgroundColour = in_backgroundColour;\n                m_dismissWithTap = in_dismissWithTap;\n\n                auto fileSystem = ChilliSource::Application::Get()->GetFileSystem();\n                std::string filePath;\n                if (in_storageLocation == ChilliSource::StorageLocation::k_DLC && fileSystem->DoesFileExistInCachedDLC(in_fileName) == false)\n                {\n                    filePath = fileSystem->GetAbsolutePathToStorageLocation(ChilliSource::StorageLocation::k_package) + fileSystem->GetPackageDLCPath() + in_fileName;\n                }\n                else\n                {\n                    filePath = fileSystem->GetAbsolutePathToStorageLocation(in_storageLocation) + in_fileName;\n                }\n\n                NSString* urlString = [NSStringUtils newNSStringWithUTF8String:filePath];\n                NSURL* pMovieURL = [NSURL fileURLWithPath:urlString];\n                [urlString release];\n                \n                m_moviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:pMovieURL];\n                \n                AudioSessionAddPropertyListener(kAudioSessionProperty_AudioRouteChange, AudioRouteCallback, m_moviePlayerController);\n                \n                ListenForMoviePlayerNotifications();\n                \n                Prepare();\n            });\n        }\n        //--------------------------------------------------------------\n        //--------------------------------------------------------------\n        void VideoPlayer::PresentWithSubtitles(ChilliSource::StorageLocation in_storageLocation, const std::string& in_fileName, const ChilliSource::SubtitlesCSPtr& in_subtitles, VideoCompleteDelegate::Connection&& in_delegateConnection,\n                                                     bool in_dismissWithTap, const ChilliSource::Colour& in_backgroundColour)\n        {\n            CS_RELEASE_ASSERT(ChilliSource::Application::Get()->GetTaskScheduler()->IsMainThread(), \"Cannot present video on background thread.\");\n            m_subtitles = in_subtitles;\n            Present(in_storageLocation, in_fileName, std::move(in_delegateConnection), in_dismissWithTap);\n        }\n        //-------------------------------------------------------------\n        //-------------------------------------------------------------\n        f32 VideoPlayer::GetCurrentTime() const\n        {\n            f32 time = 0.0f;\n            \n            if (m_moviePlayerController != nil)\n            {\n                time = (f32)[m_moviePlayerController currentPlaybackTime];\n            }\n            \n            return time;\n        }\n        //--------------------------------------------------------------\n        //--------------------------------------------------------------\n        ChilliSource::Vector2 VideoPlayer::GetVideoDimensions() const\n        {\n            return ChilliSource::Vector2(m_moviePlayerController.naturalSize.width, m_moviePlayerController.naturalSize.height);\n        }\n        //--------------------------------------------------------\n        //--------------------------------------------------------\n        bool VideoPlayer::IsPresented() const noexcept\n        {\n            return (m_currentState != State::k_inactive);\n        }\n        //--------------------------------------------------------\n        //--------------------------------------------------------\n        void VideoPlayer::OnInit()\n        {\n            m_screen = ChilliSource::Application::Get()->GetSystem<ChilliSource::Screen>();\n            m_tapListener = [[CVideoPlayerTapListener alloc] init];\n        }\n        //---------------------------------------------------------------\n        //---------------------------------------------------------------\n        void VideoPlayer::Prepare()\n        {\n            auto previousState = m_currentState.exchange(State::k_ready);\n            CS_RELEASE_ASSERT(previousState == State::k_loading, \"Video player not presented, cannot prepare to play video.\");\n            \n            [m_moviePlayerController setControlStyle:MPMovieControlStyleNone];\n            [m_moviePlayerController setFullscreen:YES];\n            [m_moviePlayerController setRepeatMode:MPMovieRepeatModeNone];\n            [m_moviePlayerController prepareToPlay];\n        }\n        //---------------------------------------------------------------\n        //---------------------------------------------------------------\n        void VideoPlayer::Play()\n        {\n            auto previousState = m_currentState.exchange(State::k_playing);\n            CS_RELEASE_ASSERT(previousState == State::k_ready, \"Video player not prepared to play video yet, cannot play.\");\n            \n            CreateVideoOverlay();\n            [m_moviePlayerController play];\n        }\n        //---------------------------------------------------------------\n        //---------------------------------------------------------------\n        void VideoPlayer::ListenForMoviePlayerNotifications()\n        {\n            [[NSNotificationAdapter sharedInstance] BeginListeningForMPLoadStateChanged];\n            m_moviePlayerLoadStateChangedConnection = [[NSNotificationAdapter sharedInstance] GetMPLoadStateChangeEvent].OpenConnection(ChilliSource::MakeDelegate(this, &VideoPlayer::OnLoadStateChanged));\n            [[NSNotificationAdapter sharedInstance] BeginListeningForMPPlaybackDidFinish];\n            m_moviePlayerPlaybackFinishedConnection = [[NSNotificationAdapter sharedInstance] GetMPPlaybackDidFinishEvent].OpenConnection(ChilliSource::MakeDelegate(this, &VideoPlayer::OnPlaybackFinished));\n        }\n        //---------------------------------------------------------------\n        //---------------------------------------------------------------\n        void VideoPlayer::StopListeningForMoviePlayerNotifications()\n        {\n            m_moviePlayerLoadStateChangedConnection = nullptr;\n            m_moviePlayerPlaybackFinishedConnection = nullptr;\n            \n            [[NSNotificationAdapter sharedInstance] StopListeningForMPLoadStateChanged];\n            [[NSNotificationAdapter sharedInstance] StopListeningForMPPlaybackDidFinish];\n        }\n        //---------------------------------------------------------------\n        //---------------------------------------------------------------\n        void VideoPlayer::OnTapped()\n        {\n            if(m_moviePlayerController)\n            {\n                [m_moviePlayerController stop];\n            }\n        }\n        //---------------------------------------------------------------\n        //---------------------------------------------------------------\n        void VideoPlayer::OnLoadStateChanged()\n        {\n            //Unless state is unknown, start playback\n            if([m_moviePlayerController loadState] != MPMovieLoadStateUnknown)\n            {\n                [[NSNotificationAdapter sharedInstance] StopListeningForMPLoadStateChanged];\n                m_moviePlayerLoadStateChangedConnection = nullptr;\n                \n                SetupMovieView();\n                AttachMovieViewToWindow();\n                Play();\n            }\n        }\n        //---------------------------------------------------------------\n        //---------------------------------------------------------------\n        void VideoPlayer::SetupMovieView()\n        {\n            @autoreleasepool\n            {\n                f32 orientedWidthDensityCorrected = m_screen->GetResolution().x * m_screen->GetInverseDensityScale();\n                f32 orientedHeightDensityCorrected = m_screen->GetResolution().y * m_screen->GetInverseDensityScale();\n            \n                m_moviePlayerController.backgroundView.backgroundColor = [UIColor colorWithRed:m_backgroundColour.r green:m_backgroundColour.g blue:m_backgroundColour.b alpha:m_backgroundColour.a];\n                [[m_moviePlayerController view] setFrame:CGRectMake(0, 0, orientedWidthDensityCorrected, orientedHeightDensityCorrected)];\n            }\n        }\n        //---------------------------------------------------------------\n        //---------------------------------------------------------------\n        void VideoPlayer::AttachMovieViewToWindow()\n        {\n            [[[[[UIApplication sharedApplication] keyWindow] rootViewController] view] addSubview:m_moviePlayerController.view];\n        }\n        //---------------------------------------------------------------\n        //---------------------------------------------------------------\n        void VideoPlayer::OnPlaybackFinished()\n        {\n            auto previousState = m_currentState.exchange(State::k_inactive);\n            CS_RELEASE_ASSERT(previousState == State::k_playing, \"Playback finished should only happen once per playing video.\");\n            \n            DeleteVideoOverlay();\n            \n            if([m_moviePlayerController respondsToSelector:@selector(setFullscreen:animated:)])\n            {\n                [m_moviePlayerController.view removeFromSuperview];\n            }\n            \n            AudioSessionRemovePropertyListenerWithUserData(kAudioSessionProperty_AudioRouteChange, AudioRouteCallback, m_moviePlayerController);\n            \n            StopListeningForMoviePlayerNotifications();\n            \n            [m_moviePlayerController release];\n            m_moviePlayerController = nil;\n            \n            [[NSNotificationAdapter sharedInstance] StopListeningForMPPlaybackDidFinish];\n            m_moviePlayerPlaybackFinishedConnection = nullptr;\n            \n            ChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_mainThread, [=](const ChilliSource::TaskContext& taskContext)\n            {\n                if (m_completionDelegateConnection != nullptr)\n                {\n                    auto delegateConnection = std::move(m_completionDelegateConnection);\n                    m_completionDelegateConnection = nullptr;\n                    delegateConnection->Call();\n                }\n            });\n        }\n        //---------------------------------------------------------------\n        //---------------------------------------------------------------\n        void VideoPlayer::OnResume()\n        {\n            ChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_system, [=](const ChilliSource::TaskContext& taskContext)\n            {\n                if (m_moviePlayerController != nil)\n                {\n                    if (m_currentState == State::k_playing || m_currentState == State::k_ready)\n                    {\n                        [m_moviePlayerController play];\n                    }\n                }\n            });\n        }\n        //---------------------------------------------------------------\n        //---------------------------------------------------------------\n        void VideoPlayer::CreateVideoOverlay()\n        {\n            if (m_videoOverlayView == nil)\n            {\n                //create the overlay\n                CGRect rect = CGRectMake(0, 0, m_screen->GetResolution().x * m_screen->GetInverseDensityScale(), m_screen->GetResolution().y * m_screen->GetInverseDensityScale());\n                m_videoOverlayView = [[VideoOverlayView alloc] initWithFrame: rect];\n                UIView* rootView = [[[[UIApplication sharedApplication] keyWindow] rootViewController] view];\n                [rootView addSubview:m_videoOverlayView];\n                [rootView bringSubviewToFront:m_videoOverlayView];\n                \n                //setup the tap gesture if we can dismiss with tap\n                if (m_dismissWithTap && m_tapListener != nil)\n                {\n                    [m_tapListener SetupWithView: m_videoOverlayView AndDelegate:ChilliSource::MakeDelegate(this, &VideoPlayer::OnTapped)];\n                }\n                \n                //create the subtitles renderer\n                if (m_subtitles != nullptr && m_subtitlesRenderer == nil)\n                {\n                    m_subtitlesRenderer = [[CSubtitlesRenderer alloc] initWithVideoPlayer:this view:m_videoOverlayView andSubtitles:m_subtitles];\n                }\n            }\n        }\n        //---------------------------------------------------------------\n        //---------------------------------------------------------------\n        void VideoPlayer::DeleteVideoOverlay()\n        {\n            if (m_videoOverlayView != nil)\n            {\n                //cleanup the subtitles renderer\n                if (m_subtitlesRenderer != nil)\n                {\n                    [m_subtitlesRenderer CleanUp];\n                    [m_subtitlesRenderer release];\n                    m_subtitlesRenderer = nil;\n                }\n                \n                //cleanup the tap listener\n                if (m_tapListener != nil)\n                {\n                    [m_tapListener Reset];\n                }\n                \n                //delete the overlay\n                [m_videoOverlayView removeFromSuperview];\n                [m_videoOverlayView release];\n                m_videoOverlayView = nil;\n                \n                //reset the overlay options\n                m_dismissWithTap = false;\n            }\n        }\n        //--------------------------------------------------------\n        //--------------------------------------------------------\n        void VideoPlayer::OnDestroy()\n        {\n            [m_tapListener release];\n        }\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/iOS/Video/Base/VideoPlayerTapListener.h",
    "content": "//\n//  VideoPlayerTapListener.h\n//  ChilliSource\n//  Created by Ian Copland on 16/08/2012.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2012 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_IOS\n\n#import <ChilliSource/ChilliSource.h>\n\n#import <Foundation/Foundation.h>\n#import <MediaPlayer/MediaPlayer.h>\n\n#import <functional>\n\n@class UIView;\n@class UITapGestureRecognizer;\n@class CADisplayLink;\n\nnamespace CSBackend\n{\n    namespace iOS\n    {\n        //========================================================\n        /// Delegates\n        //========================================================\n        typedef std::function<void()> VideoPlayerTappedDelegate;\n    }\n}\n//========================================================\n/// Video Player Tap Listener\n///\n/// This is used to get tap events back from the\n/// movie player controller.\n//========================================================\n@interface CVideoPlayerTapListener : NSObject\n{\n    UITapGestureRecognizer* mpRecogniser;\n    CADisplayLink* mpDisplayLink;\n    bool mbReceivedTap;\n    CSBackend::iOS::VideoPlayerTappedDelegate mTappedDelegate;\n    UIView* mpView;\n}\n//--------------------------------------------------------\n/// init\n///\n/// Initialises the listener.\n//--------------------------------------------------------\n-(id) init;\n//--------------------------------------------------------\n/// Setup View\n///\n/// sets up the listener with the view and the delegate\n///\n/// @param the view.\n/// @param the tapped delegate.\n//--------------------------------------------------------\n-(void) SetupWithView:(UIView*)inpView AndDelegate:(CSBackend::iOS::VideoPlayerTappedDelegate)inTappedDelegate;\n//--------------------------------------------------------\n/// On Tap\n///\n/// Method called when the view is tapped.\n///\n/// @param The gesture sending the message.\n//--------------------------------------------------------\n-(void) OnTap:(UIGestureRecognizer*)gestureRecogniser;\n//--------------------------------------------------------\n/// On Update\n///\n/// Called each frame.\n//--------------------------------------------------------\n-(void) OnUpdate;\n//--------------------------------------------------------\n/// Reset\n///\n/// Cleans up the view and delegate, restoring\n/// the listener back to its orginal state ready to be\n/// used again.\n//--------------------------------------------------------\n-(void) Reset;\n//--------------------------------------------------------\n/// Dealloc\n///\n/// destroys the listener\n//--------------------------------------------------------\n-(void) dealloc;\n\n@end\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/iOS/Video/Base/VideoPlayerTapListener.mm",
    "content": "//\n//  VideoPlayerTapListener.mm\n//  ChilliSource\n//  Created by Ian Copland on 16/08/2012.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2012 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_IOS\n\n#import <CSBackend/Platform/iOS/Video/Base/VideoPlayerTapListener.h>\n#import <QuartzCore/QuartzCore.h>\n#import <ChilliSource/Core/Base/Screen.h>\n\nusing namespace CSBackend;\nusing namespace CSBackend::iOS;\n\n@implementation CVideoPlayerTapListener\n//--------------------------------------------------------\n/// Init\n//--------------------------------------------------------\n-(id) init\n{\n    //Do that daft ObjC thing of setting self to super init.\n    if(!(self = [super init]))\n\t{\n\t\treturn nil;\n\t}\n    \n    mpRecogniser = nil;\n    mpView = nil;\n    mbReceivedTap = false;\n    mpDisplayLink = [CADisplayLink displayLinkWithTarget: self selector: @selector(OnUpdate)];\n    [mpDisplayLink addToRunLoop: [NSRunLoop mainRunLoop] forMode:NSDefaultRunLoopMode];\n    mpDisplayLink.paused = YES;\n    \n    return self;\n}\n//--------------------------------------------------------\n/// Setup With View\n//--------------------------------------------------------\n-(void) SetupWithView:(UIView*)inpView AndDelegate:(VideoPlayerTappedDelegate)inTappedDelegate\n{\n    mTappedDelegate = inTappedDelegate;\n    \n    //try and create a gesture recogniser and add it to the video player.\n    if (inpView != nil && [inpView respondsToSelector:@selector(addGestureRecognizer:)])\n    {\n        //add the gesture recogniser to the tappable view.\n        mpView = inpView;\n        mpRecogniser = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(OnTap:)];\n        mpRecogniser.numberOfTapsRequired = 1;\n        [mpView addGestureRecognizer:mpRecogniser];\n        [mpRecogniser setEnabled:YES];\n    }\n    else\n    {\n        mpView = nil;\n        mpRecogniser = nil;\n    }\n    \n    //start the updater\n    if (mpDisplayLink != nil)\n    {\n        mpDisplayLink.paused = NO;\n    }\n}\n//--------------------------------------------------------\n/// OnTap\n//--------------------------------------------------------\n-(void)OnTap:(UIGestureRecognizer*)gestureRecogniser\n{\n    if (gestureRecogniser.state == UIGestureRecognizerStateEnded)\n    {\n        mbReceivedTap = true;\n    }\n}\n//--------------------------------------------------------\n/// On Update\n//--------------------------------------------------------\n-(void)OnUpdate\n{\n    if (mbReceivedTap == true)\n    {\n        if (mTappedDelegate != nullptr)\n        {\n            mTappedDelegate();\n        }\n        \n        mbReceivedTap = false;\n    }\n}\n//--------------------------------------------------------\n/// Reset\n//--------------------------------------------------------\n-(void) Reset\n{\n    if (mpView != nil)\n    {\n        if ([mpView respondsToSelector:@selector(removeGestureRecognizer:)] && mpRecogniser != nil)\n        {\n            //remove the gesture from the view\n            [mpView removeGestureRecognizer:mpRecogniser];\n            [mpRecogniser release];\n            mpRecogniser = nil;\n        }\n        \n        //cleanup the view\n        mpView = nil;\n    }\n    \n    if (mpDisplayLink != nil)\n    {\n        mpDisplayLink.paused = YES;\n    }\n    \n    mbReceivedTap = false;\n}\n//--------------------------------------------------------\n/// dealloc\n//--------------------------------------------------------\n-(void) dealloc\n{\n    [mpDisplayLink invalidate];\n    [super dealloc];\n}\n@end\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/iOS/Web/Base/WebView.h",
    "content": "//\n//  WebView.h\n//  ChilliSource\n//  Created by Scott Downie on 25/07/2011.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2011 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_IOS\n\n#import <ChilliSource/ChilliSource.h>\n#import <CSBackend/Platform/iOS/ForwardDeclarations.h>\n#import <ChilliSource/Core/File/FileSystem.h>\n#import <ChilliSource/Core/Math/UnifiedCoordinates.h>\n#import <ChilliSource/Web/Base/WebView.h>\n\n@class WebViewDelegate;\n@class UIWebView;\n@class UIActivityIndicatorView;\n@class UIButton;\n\nnamespace CSBackend\n{\n\tnamespace iOS\n\t{\n        //-------------------------------------------------------\n        /// The iOS backend for the web view.\n        ///\n        /// @author S Downie\n        //-------------------------------------------------------\n\t\tclass WebView final : public ChilliSource::WebView\n\t\t{\n\t\tpublic:\n            CS_DECLARE_NAMEDTYPE(WebView);\n            \n            //-------------------------------------------------------\n\t\t\t/// Queries whether or not this system implements the\n            /// interface with the given Id.\n\t\t\t///\n            /// @author S Downie\n            ///\n\t\t\t/// @param The interface Id.\n\t\t\t/// @param Whether system is of given type.\n\t\t\t//-------------------------------------------------------\n\t\t\tbool IsA(ChilliSource::InterfaceIDType in_interfaceId) const override;\n            //---------------------------------------------------------\n            /// Displays the website at the given URL in an in-app\n            /// web view.\n            ///\n            /// @author S Downie\n            ///\n            /// @param The Url.\n            /// @param The size of the webview in GUI coordinates.\n            /// @param The relative size of the dismiss button.\n            /// @param The dismissed delegate.\n            /// @param in_customURLClickHandler - The delegate to call when a link is\n            /// clicked on the displayed page\n            //---------------------------------------------------------\n            void Present(const std::string& in_url, const ChilliSource::UnifiedVector2& in_size, f32 in_dismissButtonRelativeSize, const DismissedDelegate& in_delegate, const CustomLinkHandlerDelegate& in_customLinkHandler = nullptr) override;\n            //---------------------------------------------------------\n            /// Displays the website at the given location on disk in\n            /// an in-app web view.\n            ///\n            /// @author S Downie\n            ///\n            /// @param The storage location.\n            /// @param The file path.\n            /// @param The size of the webview in GUI coordinates.\n            /// @param The relative size of the dismiss button.\n            /// @param The dismissed delegate.\n            /// @param in_customURLClickHandler - The delegate to call when a link is\n            /// clicked on the displayed page\n            //---------------------------------------------------------\n            void PresentFromFile(ChilliSource::StorageLocation in_storageLocation, const std::string& in_filePath, const ChilliSource::UnifiedVector2& in_size, f32 in_dismissButtonRelativeSize, const DismissedDelegate& in_delegate, const CustomLinkHandlerDelegate& in_customLinkHandler = nullptr) override;\n            //---------------------------------------------------------\n            /// Displays the website at the given Url in an external\n            /// browser.\n            ///\n            /// @author S Downie\n            ///\n            /// @param The Url.\n            //---------------------------------------------------------\n            void PresentInExternalBrowser(const std::string& in_url) override;\n            //---------------------------------------------------------\n            /// Dismiss the web view if it is currently presented.\n            ///\n            /// @author S Downie\n            //---------------------------------------------------------\n            void Dismiss() override;\n            //---------------------------------------------------------\n            /// @author Ian Copland\n            ///\n            /// @return Whether or not the web view is currently\n            /// presented.\n            //---------------------------------------------------------\n            bool IsPresented() const override;\n            //---------------------------------------------------------\n            /// Called from the webview delegate to inform the system\n            /// that the webview has finished loading. This should not\n            /// be called manually by the user.\n            ///\n            /// @author Ian Copland\n            //---------------------------------------------------------\n            void OnViewDidFinishLoad();\n            //---------------------------------------------------------\n            /// Called from the webview delegate to inform the system\n            /// that a link on the webview has been clicked. This will\n            /// pass the link to any external handlers (if any) and\n            /// return based on whether it will be handled elsewhere\n            ///\n            /// This should not be called manually by the user.\n            ///\n            /// @author HMcLaughlin\n            ///\n            /// @param in_url - URL Clicked\n            ///\n            /// @return If this link will be handled elsewhere\n            //---------------------------------------------------------\n            bool OnLinkClicked(const std::string& in_url);\n            \n        private:\n            friend ChilliSource::WebViewUPtr ChilliSource::WebView::Create();\n            //------------------------------------------------------------------------------\n            /// Describes the current state of the webview.\n            ///\n            /// @author Jordan Brown\n            //------------------------------------------------------------------------------\n            enum class State\n            {\n                k_inactive,\n                k_presented,\n                k_dismissing\n            };\n            //---------------------------------------------------------\n            /// Private constructor to force use of factory method\n            ///\n            /// @author S Downie\n            //---------------------------------------------------------\n            WebView();\n            //---------------------------------------------------------\n            /// Called when the owning state is initialised.\n            ///\n            /// @author Ian Copland\n            //---------------------------------------------------------\n            void OnInit() override;\n            //---------------------------------------------------------\n            /// Create a webview instance from the size member and\n            /// centre it on-screen.\n            ///\n            /// @author S Downie\n            ///\n            /// @param The size.\n            //---------------------------------------------------------\n            void CreateWebview(const ChilliSource::UnifiedVector2& in_size);\n            //---------------------------------------------------------\n            /// Adds the webview to the main view.\n            ///\n            /// @author S Downie\n            //---------------------------------------------------------\n            void Display();\n\t\t\t//---------------------------------------------------------\n\t\t\t/// Create a button that can dismiss the web view.\n            ///\n            /// @author S Downie\n\t\t\t//---------------------------------------------------------\n\t\t\tvoid AddDismissButton();\n            //---------------------------------------------------------\n\t\t\t/// Adds the activity indicatator while loading the web\n            /// view.\n            ///\n\t\t\t/// @author S Downie\n\t\t\t//---------------------------------------------------------\n\t\t\tvoid AddActivityIndicator();\n            //---------------------------------------------------------\n\t\t\t/// Removes the acitivity indicator once web view loading\n            /// has completed.\n\t\t\t///\n            /// @author S Downie\n\t\t\t//---------------------------------------------------------\n\t\t\tvoid RemoveActivityIndicator();\n            //---------------------------------------------------------\n            /// Called when the owning state is destroyed.\n            ///\n            /// @author Ian Copland\n            //---------------------------------------------------------\n            void OnDestroy() override;\n\t\tprivate:\n\t\t\t\n            DismissedDelegate m_dismissedDelegate;\n            CustomLinkHandlerDelegate m_linkHandlerDelegate;\n            \n            ChilliSource::Screen* m_screen;\n\t\t\tUIWebView* m_webView;\n\t\t\tUIButton * m_dismissButton;\n            UIActivityIndicatorView* m_activityIndicator;\n\t\t\tWebViewDelegate* m_webViewDelegate;\n            \n            std::string m_anchor;\n            \n\t\t\tChilliSource::Vector2 m_absoluteSize;\n\t\t\tChilliSource::Vector2 m_absolutePosition;\n            \n            f32 m_dismissButtonRelativeSize;\n\t\t\t\n            State m_currentState = State::k_inactive;\n\t\t};\n\t}\n}\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/iOS/Web/Base/WebView.mm",
    "content": "//\n//  WebView.cpp\n//  ChilliSource\n//  Created by Scott Downie on 25/07/2011.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2011 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_IOS\n\n#import <CSBackend/Platform/iOS/Web/Base/WebView.h>\n\n#import <CSBackend/Platform/iOS/Core/File/FileSystem.h>\n#import <CSBackend/Platform/iOS/Core/String/NSStringUtils.h>\n#import <CSBackend/Platform/iOS/Web/Base/WebViewDelegate.h>\n#import <ChilliSource/Core/Base/Application.h>\n#import <ChilliSource/Core/Base/Screen.h>\n#import <ChilliSource/Core/File/FileSystem.h>\n#import <ChilliSource/Core/String/StringUtils.h>\n#import <ChilliSource/Core/Threading/TaskScheduler.h>\n\n#import <UIKit/UIKit.h>\n#import <QuartzCore/CALayer.h>\n\nnamespace CSBackend\n{\n\tnamespace iOS\n\t{\n        namespace\n        {\n            //---------------------------------------------------------\n\t\t\t/// Breaks the given url path into the file path and anchor.\n\t\t\t///\n\t\t\t/// @author Ian Copland\n\t\t\t///\n\t\t\t/// @param The URL.\n\t\t\t/// @param [Out] The file path.\n\t\t\t/// @param [Out] The anchor.\n\t\t\t//---------------------------------------------------------\n\t\t\tvoid GetFilePathAndAnchor(const std::string& in_combined, std::string& out_filePath, std::string& out_anchor)\n            {\n                size_t anchorStart = in_combined.find_last_of('#');\n                \n\t\t\t\tif(anchorStart != std::string::npos)\n\t\t\t\t{\n\t\t\t\t\tout_anchor = in_combined.substr(anchorStart, in_combined.size() - anchorStart);\n\t\t\t\t\tout_filePath = in_combined.substr(0, anchorStart);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tout_anchor = \"\";\n\t\t\t\t\tout_filePath = in_combined;\n\t\t\t\t}\n            }\n        }\n        CS_DEFINE_NAMEDTYPE(WebView);\n\t\t//-----------------------------------------------\n\t\t//-----------------------------------------------\n\t\tWebView::WebView()\n            : m_webView(nil), m_dismissButton(nil), m_currentState(State::k_inactive), m_activityIndicator(nil), m_webViewDelegate(nil), m_dismissButtonRelativeSize(0.0f)\n\t\t{\n\t\t}\n        //-------------------------------------------------------\n        //-------------------------------------------------------\n        bool WebView::IsA(ChilliSource::InterfaceIDType in_interfaceId) const\n        {\n            return (ChilliSource::WebView::InterfaceID == in_interfaceId || WebView::InterfaceID == in_interfaceId);\n        }\n\t\t//-----------------------------------------------\n\t\t//-----------------------------------------------\n\t\tvoid WebView::Present(const std::string& in_url, const ChilliSource::UnifiedVector2& in_size, f32 in_dismissButtonRelativeSize, const DismissedDelegate& in_delegate, const CustomLinkHandlerDelegate& in_customLinkHandler)\n\t\t{\n            CS_ASSERT(m_currentState == State::k_inactive, \"Cannot present a web view while one is already displayed.\");\n            \n            m_currentState = State::k_presented;\n            m_dismissedDelegate = in_delegate;\n            m_linkHandlerDelegate = in_customLinkHandler;\n            m_dismissButtonRelativeSize = in_dismissButtonRelativeSize;\n            \n            ChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_system, [=](const ChilliSource::TaskContext& taskContext)\n            {\n                if(!m_webView)\n                {\n                    CreateWebview(in_size);\n                    \n                    m_anchor = \"\";\n                    \n                    NSString* urlString = [NSStringUtils newNSStringWithUTF8String:in_url];\n                    NSURL* url = [NSURL URLWithString:urlString];\n                    [urlString release];\n                    \n                    [m_webView loadRequest:[NSURLRequest requestWithURL:url]];\n                    \n                    m_webView.backgroundColor = [UIColor clearColor];\n                    m_webView.opaque = NO;\n                    \n                    AddActivityIndicator();\n                }\n                \n                Display();\n            });\n\t\t}\n\t\t//-----------------------------------------------\n\t\t//-----------------------------------------------\n\t\tvoid WebView::PresentFromFile(ChilliSource::StorageLocation in_storageLocation, const std::string& in_filePath, const ChilliSource::UnifiedVector2& in_size, f32 in_dismissButtonRelativeSize, const DismissedDelegate& in_delegate, const CustomLinkHandlerDelegate& in_customLinkHandler)\n\t\t{\n            CS_ASSERT(m_currentState == State::k_inactive, \"Cannot present a web view while one is already displayed.\");\n            \n            m_currentState = State::k_presented;\n            m_dismissedDelegate = in_delegate;\n            m_dismissButtonRelativeSize = in_dismissButtonRelativeSize;\n            m_linkHandlerDelegate = in_customLinkHandler;\n            \n            ChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_system, [=](const ChilliSource::TaskContext& taskContext)\n            {\n                CreateWebview(in_size);\n                \n                std::string filePath;\n                GetFilePathAndAnchor(in_filePath, filePath, m_anchor);\n                \n                ChilliSource::FileSystem* fileSystem = ChilliSource::Application::Get()->GetFileSystem();\n\n                std::string fullFilePath;\n                if (in_storageLocation == ChilliSource::StorageLocation::k_DLC && fileSystem->DoesFileExistInCachedDLC(filePath) == false)\n                {\n                    fullFilePath = fileSystem->GetAbsolutePathToStorageLocation(ChilliSource::StorageLocation::k_package) + fileSystem->GetPackageDLCPath() + filePath;\n                }\n                else\n                {\n                    fullFilePath = fileSystem->GetAbsolutePathToStorageLocation(in_storageLocation) + filePath;\n                }\n\n                \n                auto HTMLFileStream = fileSystem->CreateTextInputStream(in_storageLocation, in_filePath);\n                CS_ASSERT(HTMLFileStream, \"Could not open file: \" + filePath);\n                std::string HTMLFileContents = HTMLFileStream->ReadAll();\n                HTMLFileStream.reset();\n                \n                NSString* pstrHTML = [NSStringUtils newNSStringWithUTF8String:HTMLFileContents];\n                NSString* urlString = [NSStringUtils newNSStringWithUTF8String:fullFilePath];\n                [m_webView loadHTMLString:pstrHTML baseURL:[NSURL fileURLWithPath:urlString]];\n                [urlString release];\n                [pstrHTML release];\n                \n                m_webView.backgroundColor = [UIColor clearColor];\n                m_webView.opaque = NO;\n                \n                AddActivityIndicator();\n                \n                Display();\n            });\n\t\t}\n        //-----------------------------------------------\n\t\t//-----------------------------------------------\n\t\tvoid WebView::PresentInExternalBrowser(const std::string& in_url)\n\t\t{\n            ChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_system, [=](const ChilliSource::TaskContext& taskContext)\n            {\n                NSString* urlString = [NSStringUtils newNSStringWithUTF8String:in_url];\n                NSURL* url = [NSURL URLWithString:urlString];\n                [urlString release];\n                \n                [[UIApplication sharedApplication] openURL:url];\n            });\n\t\t}\n        //-----------------------------------------------\n\t\t//-----------------------------------------------\n\t\tvoid WebView::Dismiss()\n\t\t{\n            CS_ASSERT(m_currentState == State::k_presented, \"Cannot dismiss a view which is not presented\");\n           \n            m_currentState = State::k_dismissing;\n            \n            ChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_system, [=](const ChilliSource::TaskContext& taskContext)\n            {\n                if (m_activityIndicator != nil)\n                {\n                    RemoveActivityIndicator();\n                }\n                \n                if (m_dismissButton != nil)\n                {\n                    [m_dismissButton removeFromSuperview];\n                    [m_dismissButton release];\n                    m_dismissButton = nil;\n                }\n                \n                [m_webViewDelegate release];\n                m_webViewDelegate = nil;\n                \n                [m_webView stopLoading];\n                [m_webView removeFromSuperview];\n                [m_webView release];\n                m_webView = nil;\n                \n                ChilliSource::Application::Get()->GetTaskScheduler()->ScheduleTask(ChilliSource::TaskType::k_mainThread, [=](const ChilliSource::TaskContext& taskContext)\n                {\n                    if (m_dismissedDelegate)\n                    {\n                        DismissedDelegate delegate = m_dismissedDelegate;\n                        m_dismissedDelegate = nullptr;\n                        delegate();\n                    }\n                    m_currentState = State::k_inactive;\n                });\n            });\n\t\t}\n        //---------------------------------------------------------\n        //---------------------------------------------------------\n        bool WebView::IsPresented() const\n        {\n            return (m_currentState != State::k_inactive);\n        }\n        //---------------------------------------------------------\n        //---------------------------------------------------------\n        void WebView::OnViewDidFinishLoad()\n        {\n            if(m_anchor.length() > 0)\n            {\n                std::string strJavaScript = \"window.location.href = '\" + m_anchor + \"';\";\n                NSString* nsJavaString = [NSStringUtils newNSStringWithUTF8String:strJavaScript];\n                [m_webView stringByEvaluatingJavaScriptFromString:nsJavaString];\n                [nsJavaString release];\n            }\n            \n            if(m_dismissButton == nullptr)\n            {\n                AddDismissButton();\n            }\n            \n            RemoveActivityIndicator();\n        }\n        //---------------------------------------------------------\n        //---------------------------------------------------------\n        bool WebView::OnLinkClicked(const std::string& in_url)\n        {\n            if(m_linkHandlerDelegate)\n            {\n                return m_linkHandlerDelegate(in_url);\n            }\n            \n            return false;\n        }\n        //---------------------------------------------------------\n        //---------------------------------------------------------\n        void WebView::OnInit()\n        {\n            m_screen = ChilliSource::Application::Get()->GetSystem<ChilliSource::Screen>();\n        }\n        //-----------------------------------------------\n        //-----------------------------------------------\n        void WebView::CreateWebview(const ChilliSource::UnifiedVector2& in_size)\n        {\n            CS_ASSERT(m_webView == nil, \"Cannot create webview because one already exists!\");\n            \n            ChilliSource::Vector2 dipsResolution = m_screen->GetResolution() * m_screen->GetInverseDensityScale();\n            \n            //Create the  view and present it, centered on screen\n            m_absoluteSize = (dipsResolution * in_size.GetRelative()) + in_size.GetAbsolute();\n            m_absolutePosition = (dipsResolution - m_absoluteSize) / 2.0f;\n            m_webView = [[UIWebView alloc] initWithFrame:CGRectMake(m_absolutePosition.x, m_absolutePosition.y, m_absoluteSize.x, m_absoluteSize.y)];\n        }\n        //-----------------------------------------------\n        //-----------------------------------------------\n        void WebView::Display()\n        {\n            UIView* view = [[[[UIApplication sharedApplication] keyWindow] rootViewController] view];\n            [view addSubview:m_webView];\n            m_webViewDelegate = [[WebViewDelegate alloc] initWithSystem:this];\n            m_webView.delegate = m_webViewDelegate;\n        }\n\t\t//-----------------------------------------------\n\t\t//-----------------------------------------------\n\t\tvoid WebView::AddDismissButton()\n\t\t{\n            CS_ASSERT(m_dismissButton == nil, \"Cannot add dismiss button as one already exists.\");\n            \n            UIImage* btnImage = [UIImage imageNamed:@\"WebViewCloseButton.png\"];\n            if(btnImage)\n            {\n                m_dismissButton = [[UIButton buttonWithType:UIButtonTypeCustom] retain];\n                [m_dismissButton addTarget:m_webViewDelegate action:@selector(onDismissButtonPressed:) forControlEvents:UIControlEventTouchUpInside];\n                \n                f32 size = m_absoluteSize.x * m_dismissButtonRelativeSize;\n                [m_dismissButton setFrame:CGRectMake(m_absoluteSize.x - size - 10, 10, size, size)];\n                [m_dismissButton setBackgroundImage:btnImage forState:UIControlStateNormal];\n                [m_webView addSubview:m_dismissButton];\n            }\n            else\n            {\n                m_dismissButton = [[UIButton buttonWithType:UIButtonTypeRoundedRect] retain];\n                [m_dismissButton addTarget:m_webViewDelegate action:@selector(onDismissButtonPressed:) forControlEvents:UIControlEventTouchUpInside];\n                 \n                f32 size = m_absoluteSize.x * m_dismissButtonRelativeSize;\n                [m_dismissButton setFrame:CGRectMake(m_absoluteSize.x - size - 10, 10, size, size)];\n                [m_dismissButton setTitle:@\"X\" forState:UIControlStateNormal];\n                [m_dismissButton setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];\n                [m_webView addSubview:m_dismissButton];\n            }\n\t\t}\n        //-----------------------------------------------\n        //-----------------------------------------------\n        void WebView::AddActivityIndicator()\n        {\n            CS_ASSERT(m_activityIndicator == nil, \"Cannot add activity indicator as one already exists.\");\n            \n            m_activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];\n            m_activityIndicator.center = m_webView.center;\n            [m_activityIndicator setBackgroundColor:[UIColor grayColor]];\n            m_activityIndicator.layer.cornerRadius = 5;\n            [m_activityIndicator startAnimating];\n            [m_webView addSubview:m_activityIndicator];\n            \n        }\n        //-----------------------------------------------\n        //-----------------------------------------------\n        void WebView::RemoveActivityIndicator()\n        {\n            if (m_activityIndicator != nil)\n            {\n                [m_activityIndicator removeFromSuperview];\n                [m_activityIndicator release];\n                m_activityIndicator = nil;\n            }\n        }\n        //------------------------------------------------\n        //------------------------------------------------\n        void WebView::OnDestroy()\n        {\n            if (IsPresented() == true)\n            {\n                Dismiss();\n            }\n        }\n\t}\n}\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/iOS/Web/Base/WebViewDelegate.h",
    "content": "//\n//  WebViewDelegate.h\n//  ChilliSource\n//  Created by Ian Copland on 14/04/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_IOS\n\n#import <ChilliSource/ChilliSource.h>\n#import <CSBackend/Platform/iOS/Web/Base/WebView.h>\n\n#import <Foundation/Foundation.h>\n#import <UIKit/UIKit.h>\n\n//---------------------------------------------------------\n/// A delegate for receiving callbacks from the web view.\n///\n/// @author S Downie\n//---------------------------------------------------------\n@interface WebViewDelegate : NSObject<UIWebViewDelegate>\n{\n\tCSBackend::iOS::WebView* webViewSystem;\n}\n//----------------------------------------------------\n/// Constructor for creating the delegate with the\n/// webview system to relay on events to.\n///\n/// @author S Downie\n///\n/// @param The web view system.\n//----------------------------------------------------\n-(id) initWithSystem:(CSBackend::iOS::WebView*)system;\n//----------------------------------------------------\n/// Called when the dismiss button is pressed. This\n/// is for internal use and should not be called\n/// manually by the user.\n///\n/// @author S Downie\n///\n/// @param The object.\n//----------------------------------------------------\n-(void) onDismissButtonPressed:(id)object;\n\n@end\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Platform/iOS/Web/Base/WebViewDelegate.mm",
    "content": "//\n//  WebViewDelegate.mm\n//  ChilliSource\n//  Created by Ian Copland on 14/04/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifdef CS_TARGETPLATFORM_IOS\n\n#import <CSBackend/Platform/iOS/Web/Base/WebViewDelegate.h>\n\n#import <ChilliSource/Core/Base.h>\n#import <ChilliSource/Core/DialogueBox/DialogueBoxSystem.h>\n\n#import <CSBackend/Platform/iOS/Core/String/NSStringUtils.h>\n\n@implementation WebViewDelegate\n//----------------------------------------------------\n//----------------------------------------------------\n-(id) initWithSystem:(CSBackend::iOS::WebView*)system\n{\n    if (self = [super init])\n    {\n        webViewSystem = system;\n        return self;\n    }\n    return nil;\n}\n//----------------------------------------------------\n//----------------------------------------------------\n-(void) onDismissButtonPressed:(id)object\n{\n    webViewSystem->Dismiss();\n}\n//----------------------------------------------------\n//----------------------------------------------------\n-(BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)in_request navigationType:(UIWebViewNavigationType)in_navigationType\n{\n    if(in_navigationType == UIWebViewNavigationTypeLinkClicked)\n    {\n        if(webViewSystem)\n        {\n            std::string url = [NSStringUtils newUTF8StringWithNSString:[in_request.URL absoluteString]];\n            bool linkHandledExternally = webViewSystem->OnLinkClicked(url);\n            \n            if(linkHandledExternally)\n            {\n                return NO;\n            }\n        }\n        \n        if([[[in_request URL] scheme] isEqualToString:@\"file\"] == TRUE)\n        {\n            //Load all other links externally\n            [[UIApplication sharedApplication] openURL:in_request.URL];\n            return NO;\n        }\n    }\n    \n    return YES;\n}\n//----------------------------------------------------\n//----------------------------------------------------\n-(void) webViewDidFinishLoad:(UIWebView*)in_webView\n{\n    webViewSystem->OnViewDidFinishLoad();\n}\n//----------------------------------------------------\n//----------------------------------------------------\n-(void)webView:(UIWebView*)webView didFailLoadWithError:(NSError*)in_error\n{\n    CS_LOG_ERROR([NSStringUtils newUTF8StringWithNSString:[in_error localizedDescription]]);\n    \n    if (in_error.code == NSURLErrorNotConnectedToInternet)\n    {\n        auto dialogResultLambda = [=](u32 in_id, ChilliSource::DialogueBoxSystem::DialogueResult in_result)\n        {\n            if(webViewSystem)\n            {\n                webViewSystem->Dismiss();\n            }\n        };\n        \n        auto dialogSystem = ChilliSource::Application::Get()->GetSystem<ChilliSource::DialogueBoxSystem>();\n        dialogSystem->ShowSystemDialogue(0, dialogResultLambda, \"Error\", [NSStringUtils newUTF8StringWithNSString:[in_error localizedDescription]], \"OK\");\n    }\n    else if(webViewSystem)\n    {\n        webViewSystem->Dismiss();\n    }\n}\n//----------------------------------------------------\n//----------------------------------------------------\n- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)in_buttonIndex\n{\n    if (in_buttonIndex == 0)\n    {\n        if(webViewSystem)\n        {\n            webViewSystem->Dismiss();\n        }\n    }\n}\n@end\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Rendering/OpenGL/Base/GLContextRestorer.cpp",
    "content": "//\n//  ContextRestorer.cpp\n//  ChilliSource\n//  Created by Scott Downie on 14/04/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <CSBackend/Rendering/OpenGL/Base/GLContextRestorer.h>\n\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/Resource/ResourcePool.h>\n#include <ChilliSource/Rendering/Base/RenderSnapshot.h>\n#include <ChilliSource/Rendering/Base/TargetType.h>\n#include <ChilliSource/Rendering/Material/Material.h>\n#include <ChilliSource/Rendering/Model/Model.h>\n#include <ChilliSource/Rendering/Model/RenderMesh.h>\n#include <ChilliSource/Rendering/Shader/RenderShader.h>\n#include <ChilliSource/Rendering/Shader/Shader.h>\n#include <ChilliSource/Rendering/Target/RenderTargetGroupManager.h>\n#include <ChilliSource/Rendering/Texture/RenderTexture.h>\n#include <ChilliSource/Rendering/Texture/Cubemap.h>\n#include <ChilliSource/Rendering/Texture/Texture.h>\n\n#include <CSBackend/Rendering/OpenGL/Model/GLMesh.h>\n#include <CSBackend/Rendering/OpenGL/Shader/GLShader.h>\n#include <CSBackend/Rendering/OpenGL/Target/GLTargetGroup.h>\n#include <CSBackend/Rendering/OpenGL/Texture/GLCubemap.h>\n#include <CSBackend/Rendering/OpenGL/Texture/GLTexture.h>\n\nnamespace CSBackend\n{\n    namespace OpenGL\n    {\n        CS_DEFINE_NAMEDTYPE(GLContextRestorer);\n        \n        //------------------------------------------------------------------------------\n        GLContextRestorerUPtr GLContextRestorer::Create() noexcept\n        {\n            return GLContextRestorerUPtr(new GLContextRestorer());\n        }\n        //------------------------------------------------------------------------------\n        bool GLContextRestorer::IsA(ChilliSource::InterfaceIDType interfaceId) const noexcept\n        {\n            return (GLContextRestorer::InterfaceID == interfaceId);\n        }\n        //------------------------------------------------------------------------------\n        void GLContextRestorer::InvalidateResources() noexcept\n        {\n            if(m_hasContextBeenBackedUp == false)\n            {\n                m_hasContextBeenBackedUp = true;\n                \n                ChilliSource::ResourcePool* resourcePool = ChilliSource::Application::Get()->GetResourcePool();\n                \n                auto allShaders = resourcePool->GetAllResources<ChilliSource::Shader>();\n                for (const auto& shader : allShaders)\n                {\n                    GLShader* glShader = static_cast<GLShader*>(shader->GetRenderShader()->GetExtraData());\n                    if(glShader)\n                    {\n                        glShader->Invalidate();\n                    }\n                }\n                \n                auto allTextures = resourcePool->GetAllResources<ChilliSource::Texture>();\n                for (const auto& texture : allTextures)\n                {\n                    GLTexture* glTexture = static_cast<GLTexture*>(texture->GetRenderTexture()->GetExtraData());\n                    if(glTexture)\n                    {\n                        glTexture->Invalidate();\n                    }\n                }\n                \n                auto allCubemaps = resourcePool->GetAllResources<ChilliSource::Cubemap>();\n                for (const auto& cubemap : allCubemaps)\n                {\n                    GLCubemap* glCubemap = static_cast<GLCubemap*>(cubemap->GetRenderTexture()->GetExtraData());\n                    if(glCubemap)\n                    {\n                        glCubemap->Invalidate();\n                    }\n                }\n                \n                auto allModels = resourcePool->GetAllResources<ChilliSource::Model>();\n                for (const auto& model : allModels)\n                {\n                    for(u32 i = 0; i < model->GetNumMeshes(); ++i)\n                    {\n                        GLMesh* glMesh = static_cast<GLMesh*>(model->GetRenderMesh(i)->GetExtraData());\n                        \n                        if(glMesh)\n                        {\n                            glMesh->Invalidate();\n                        }\n                    }\n                }\n                \n                auto renderTargetGroupManager = ChilliSource::Application::Get()->GetSystem<ChilliSource::RenderTargetGroupManager>();\n                for(const auto renderTargetGroup : renderTargetGroupManager->GetRenderTargetGroups())\n                {\n                    GLTargetGroup* targetGroup = static_cast<GLTargetGroup*>(renderTargetGroup->GetExtraData());\n                    targetGroup->Invalidate();\n                }\n            }\n        }\n        //------------------------------------------------------------------------------\n        void GLContextRestorer::RestoreResources() noexcept\n        {\n            if(m_hasContextBeenBackedUp == true)\n            {\n                ChilliSource::ResourcePool* resourcePool = ChilliSource::Application::Get()->GetResourcePool();\n                \n#if CS_ENABLE_DEBUG\n                auto allShaders = resourcePool->GetAllResources<ChilliSource::Shader>();\n                for (const auto& shader : allShaders)\n                {\n                \tCS_ASSERT(shader->GetStorageLocation() != ChilliSource::StorageLocation::k_none, \"Cannot restore Shader because restoration of OpenGL resources that were not loaded from file is not supported. To resolve this, manually release the resource on suspend and re-create it on resume.\");\n                }\n#endif\n                resourcePool->RefreshResources<ChilliSource::Shader>();\n                \n                auto allTextures = resourcePool->GetAllResources<ChilliSource::Texture>();\n                for (const auto& texture : allTextures)\n\t\t\t\t{\n                    if (texture->GetStorageLocation() == ChilliSource::StorageLocation::k_none)\n                    {\n                        ChilliSource::RestoreTextureRenderCommand command(texture->GetRenderTexture());\n                        m_pendingRestoreTextureCommands.push_back(std::move(command));\n                    }\n                }\n                resourcePool->RefreshResources<ChilliSource::Texture>();\n                \n                auto allCubemaps = resourcePool->GetAllResources<ChilliSource::Cubemap>();\n                for (const auto& cubemap : allCubemaps)\n                {\n                    if (cubemap->GetStorageLocation() == ChilliSource::StorageLocation::k_none)\n                    {\n                        ChilliSource::RestoreCubemapRenderCommand command(cubemap->GetRenderTexture());\n                        m_pendingRestoreCubemapCommands.push_back(std::move(command));\n                    }\n                }\n                resourcePool->RefreshResources<ChilliSource::Cubemap>();\n                \n                auto allModels = resourcePool->GetAllResources<ChilliSource::Model>();\n                for (const auto& model : allModels)\n                {\n                    if (model->GetStorageLocation() == ChilliSource::StorageLocation::k_none)\n                    {\n                        for(u32 i = 0; i < model->GetNumMeshes(); ++i)\n                        {\n                            ChilliSource::RestoreMeshRenderCommand command(model->GetRenderMesh(i));\n                            m_pendingRestoreMeshCommands.push_back(std::move(command));\n                        }\n                    }\n                }\n                resourcePool->RefreshResources<ChilliSource::Model>();\n                \n                auto renderTargetGroupManager = ChilliSource::Application::Get()->GetSystem<ChilliSource::RenderTargetGroupManager>();\n                for(const auto renderTargetGroup : renderTargetGroupManager->GetRenderTargetGroups())\n                {\n                    ChilliSource::RestoreRenderTargetGroupCommand command(renderTargetGroup);\n                    m_pendingRestoreRenderTargetGroupCommands.push_back(std::move(command));\n                }\n                \n                m_hasContextBeenBackedUp = false;\n            }\n        }\n        //------------------------------------------------------------------------------\n        void GLContextRestorer::OnResume() noexcept\n        {\n            if(m_initialised)\n            {\n#ifdef CS_TARGETPLATFORM_ANDROID\n                RestoreResources();\n#endif\n            }\n            \n            m_initialised = true;\n        }\n        \n        //------------------------------------------------------------------------------\n        void GLContextRestorer::OnRenderSnapshot(ChilliSource::TargetType targetType, ChilliSource::RenderSnapshot& renderSnapshot, ChilliSource::IAllocator* frameAllocator) noexcept\n        {\n#ifdef CS_TARGETPLATFORM_ANDROID\n            if(targetType == ChilliSource::TargetType::k_main)\n            {\n                auto preRenderCommandList = renderSnapshot.GetPreRenderCommandList();\n                \n                for(auto& restoreMeshCommand : m_pendingRestoreMeshCommands)\n                {\n                    preRenderCommandList->AddRestoreMeshCommand(restoreMeshCommand.GetRenderMesh());\n                }\n                \n                for(auto& restoreTextureCommand : m_pendingRestoreTextureCommands)\n                {\n                    preRenderCommandList->AddRestoreTextureCommand(restoreTextureCommand.GetRenderTexture());\n                }\n                \n                for(auto& restoreCubemapCommand : m_pendingRestoreCubemapCommands)\n                {\n                    preRenderCommandList->AddRestoreCubemapCommand(restoreCubemapCommand.GetRenderTexture());\n                }\n                \n                for(auto& restoreRenderTargetGroupCommand : m_pendingRestoreRenderTargetGroupCommands)\n                {\n                    preRenderCommandList->AddRestoreRenderTargetGroupCommand(restoreRenderTargetGroupCommand.GetTargetRenderGroup());\n                }\n                \n                m_pendingRestoreMeshCommands.clear();\n                m_pendingRestoreTextureCommands.clear();\n                m_pendingRestoreCubemapCommands.clear();\n                m_pendingRestoreRenderTargetGroupCommands.clear();\n            }\n#endif\n        }\n        \n        //------------------------------------------------------------------------------\n        void GLContextRestorer::OnSystemSuspend() noexcept\n        {\n#ifdef CS_TARGETPLATFORM_ANDROID\n            InvalidateResources();\n#endif\n        }\n    }\n}\n"
  },
  {
    "path": "Source/CSBackend/Rendering/OpenGL/Base/GLContextRestorer.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CSBACKEND_RENDERING_OPENGL_BASE_GLCONTEXTRESTORER_H_\n#define _CSBACKEND_RENDERING_OPENGL_BASE_GLCONTEXTRESTORER_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/System/AppSystem.h>\n#include <ChilliSource/Rendering/RenderCommand/Commands/RestoreMeshRenderCommand.h>\n#include <ChilliSource/Rendering/RenderCommand/Commands/RestoreRenderTargetGroupCommand.h>\n#include <ChilliSource/Rendering/RenderCommand/Commands/RestoreCubemapRenderCommand.h>\n#include <ChilliSource/Rendering/RenderCommand/Commands/RestoreTextureRenderCommand.h>\n\n#include <CSBackend/Rendering/OpenGL/ForwardDeclarations.h>\n\n#include <vector>\n\nnamespace CSBackend\n{\n    namespace OpenGL\n    {\n        /// OpenGL on Android has its context killed whenever the app is suspended.\n        /// This system has 2 main functions, handling glResources when the context is\n        /// lost and restoring these resources when the context is restored.\n        ///\n        /// During a context loss, all GPU memory will be destroyed leaving existing resources\n        /// with invalid memory handles. We iterate through each of these and set an invalid flag,\n        /// which stops the resource from attempting to delete that memory on destruction.\n        ///\n        /// During the restore, we have 4 different ways to restore a resource:\n        /// - If the resource was originally loaded from file we can reload the resource, essentially\n        ///   creating a new one.\n        /// - If not from file, we can restore from a backup of any data on a resource.\n        /// - If there is no backup and where allowed, we can restore back to a basic state with loss\n        ///   of data.\n        /// - Else we cannot restore and assert is called.\n        ///\n        class GLContextRestorer final : public ChilliSource::AppSystem\n        {\n        public:\n            \n            CS_DECLARE_NAMEDTYPE(GLContextRestorer);\n           \n            /// Allows querying of whether or not this system implements the interface described by the\n            /// given interface Id. Typically this is not called directly as the templated equivalent\n            /// IsA<Interface>() is preferred.\n            ///\n            /// @param interfaceId\n            ///     The Id of the interface.\n            ///\n            /// @return Whether or not the interface is implemented.\n            ///\n            bool IsA(ChilliSource::InterfaceIDType interfaceId) const noexcept override;\n            \n        private:\n            friend class ChilliSource::Application;\n            friend class ChilliSource::LifecycleManager;\n            \n            /// A factory method for creating new instances of the system. This must be called by\n            /// Application.\n            ///\n            /// @return The new instance of the system.\n            ///\n            static GLContextRestorerUPtr Create() noexcept;\n            \n            /// Constructor\n            ///\n            GLContextRestorer() = default;\n            \n            /// Iterate any GL resources and place them in an invalid state\n            ///\n            void InvalidateResources() noexcept;\n            \n            /// Iterate all resources and either re-load them from file or\n            /// restore them from cached memory\n            ///\n            void RestoreResources() noexcept;\n            \n            /// Called when the app system is resumed\n            ///\n            void OnResume() noexcept override;\n            \n            /// The render snapshot event can be implemented by a system to\n            /// allow it to snapshot any data which pertains to the renderer.\n            ///\n            /// @param targetType\n            ///     Whether the snapshot is for the main screen or an offscreen render target\n            /// @param renderSnapshot\n            ///     The render snapshot object which contains all snapshotted data.\n            /// @param frameAllocator\n            ///     Allocate memory for this render frame from here\n            ///\n            void OnRenderSnapshot(ChilliSource::TargetType targetType, ChilliSource::RenderSnapshot& renderSnapshot, ChilliSource::IAllocator* frameAllocator) noexcept override;\n            \n            /// Called when the application delegate is suspended. This is called directly\n            /// from lifecycle manager and will be called before the OnSuspend.\n            ///\n            void OnSystemSuspend() noexcept;\n            \n        private:\n            \n            bool m_initialised = false;\n            bool m_hasContextBeenBackedUp = false;\n            \n            std::vector<ChilliSource::RestoreMeshRenderCommand> m_pendingRestoreMeshCommands;\n            std::vector<ChilliSource::RestoreTextureRenderCommand> m_pendingRestoreTextureCommands;\n            std::vector<ChilliSource::RestoreCubemapRenderCommand> m_pendingRestoreCubemapCommands;\n            std::vector<ChilliSource::RestoreRenderTargetGroupCommand> m_pendingRestoreRenderTargetGroupCommands;\n        };\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Rendering/OpenGL/Base/GLError.cpp",
    "content": "//\n//  GLError.cpp\n//  ChilliSource\n//  Created by Ian Copland on 21/05/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <CSBackend/Rendering/OpenGL/Base/GLError.h>\n\n#include <CSBackend/Rendering/OpenGL/Base/GLIncludes.h>\n\n#include <vector>\n\nnamespace CSBackend\n{\n    namespace OpenGL\n    {\n        namespace GLError\n        {\n            //---------------------------------------------------\n            //---------------------------------------------------\n            void Print()\n            {\n#ifdef CS_ENABLE_DEBUG\n                //get an array of all the errors that have occurred\n                std::vector<GLenum> errors;\n                GLenum currentError = glGetError();\n                while (currentError != GL_NO_ERROR)\n                {\n                    errors.push_back(currentError);\n                    currentError = glGetError();\n                }\n                \n                //print out the meaning of each error found\n                for (const GLenum& error : errors)\n                {\n                    switch (error)\n                    {\n                        case GL_INVALID_ENUM:\n                            CS_LOG_ERROR(\"GL_INVALID_ENUM: An unacceptable value is specified for an enumerated argument. The offending command is ignored and has no other side effect than to set the error flag.\");\n                            break;\n                        case GL_INVALID_VALUE:\n                            CS_LOG_ERROR(\"GL_INVALID_VALUE: A numeric argument is out of range. The offending command is ignored and has no other side effect than to set the error flag.\");\n                            break;\n                        case GL_INVALID_OPERATION:\n                            CS_LOG_ERROR(\"GL_INVALID_OPERATION: The specified operation is not allowed in the current state. The offending command is ignored and has no other side effect than to set the error flag.\");\n                            break;\n                        case GL_INVALID_FRAMEBUFFER_OPERATION:\n                            CS_LOG_ERROR(\"GL_INVALID_FRAMEBUFFER_OPERATION: The command is trying to render to or read from the framebuffer while the currently bound framebuffer is not framebuffer complete (i.e. the return value from glCheckFramebufferStatus is not GL_FRAMEBUFFER_COMPLETE). The offending command is ignored and has no other side effect than to set the error flag.\");\n                            break;\n                        case GL_OUT_OF_MEMORY:\n                            CS_LOG_ERROR(\"GL_OUT_OF_MEMORY: There is not enough memory left to execute the command. The state of the GL is undefined, except for the state of the error flags, after this error is recorded.\");\n                            break;\n                        case GL_NO_ERROR:\n                        default:\n                            CS_LOG_ERROR(\"An unknown OpenGL error has occurred!\");\n                            break;\n                    }\n                }\n#endif\n            }\n            //---------------------------------------------------\n            //---------------------------------------------------\n            void AssertNoGLError(const std::string in_message)\n            {\n#ifdef CS_ENABLE_DEBUG\n                std::vector<GLenum> errors;\n                GLenum currentError = glGetError();\n                while (currentError != GL_NO_ERROR)\n                {\n                    errors.push_back(currentError);\n                    currentError = glGetError();\n                }\n                \n                if (errors.size() > 0)\n                {\n                    std::string errorText = in_message + \" (\";\n                    bool first = true;\n                    for (const GLenum& error : errors)\n                    {\n                        if (first == false)\n                        {\n                            errorText += \", \";\n                        }\n                        first = false;\n                        \n                        switch (error)\n                        {\n                            case GL_INVALID_ENUM:\n                                errorText += \"GL_INVALID_ENUM\";\n                                break;\n                            case GL_INVALID_VALUE:\n                                errorText += \"GL_INVALID_VALUE\";\n                                break;\n                            case GL_INVALID_OPERATION:\n                                errorText += \"GL_INVALID_OPERATION\";\n                                break;\n                            case GL_INVALID_FRAMEBUFFER_OPERATION:\n                                errorText += \"GL_INVALID_FRAMEBUFFER_OPERATION\";\n                                break;\n                            case GL_OUT_OF_MEMORY:\n                                errorText += \"GL_OUT_OF_MEMORY\";\n                                break;\n                            case GL_NO_ERROR:\n                            default:\n                                errorText += \"?\";\n                                break;\n                        }\n                    }\n                    errorText += \")\";\n                    CS_LOG_FATAL(errorText);\n                }\n#endif\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "Source/CSBackend/Rendering/OpenGL/Base/GLError.h",
    "content": "//\n//  GLError.h\n//  ChilliSource\n//  Created by Ian Copland on 21/05/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CSBACKEND_RENDERING_OPENGL_BASE_GLERROR_H_\n#define _CSBACKEND_RENDERING_OPENGL_BASE_GLERROR_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <CSBackend/Rendering/OpenGL/ForwardDeclarations.h>\n\n#ifdef CS_ENABLE_DEBUG\n#define CS_ASSERT_NOGLERROR(in_message) {CSBackend::OpenGL::GLError::AssertNoGLError(in_message);}\n#else\n#define CS_ASSERT_NOGLERROR(in_message) {}\n#endif\n\nnamespace CSBackend\n{\n    namespace OpenGL\n    {\n        //---------------------------------------------------------\n        /// A small collection of utility functions for error\n        /// checking in OpenGl.\n        ///\n        /// @author Ian Copland\n        //---------------------------------------------------------\n        namespace GLError\n        {\n            //---------------------------------------------------\n            /// When debug mode is enabled (CS_ENABLE_DEBUG) this\n            /// prints any Open GL errors that have occurred.\n            ///\n            /// @author Ian Copland\n            //---------------------------------------------------\n            void Print();\n            //---------------------------------------------------\n            /// When debug mode is enabled (CS_ENABLE_DEBUG) this\n            /// will assert if a GL error has occurred, printing\n            /// the given message.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param The message to print if an error has\n            /// occurred.\n            //---------------------------------------------------\n            void AssertNoGLError(const std::string in_message);\n        }\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Rendering/OpenGL/Base/GLExtensions.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2017 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <CSBackend/Rendering/OpenGL/Base/GLExtensions.h>\n\n#if defined CS_TARGETPLATFORM_ANDROID || defined CS_TARGETPLATFORM_RPI\n#   include <EGL/egl.h>\n\nPFNGLGENVERTEXARRAYSOESPROC glGenVertexArraysOESEXT = 0;\nPFNGLBINDVERTEXARRAYOESPROC glBindVertexArrayOESEXT = 0;\nPFNGLDELETEVERTEXARRAYSOESPROC glDeleteVertexArraysOESEXT = 0;\n#endif\n\nnamespace CSBackend\n{\n    namespace OpenGL\n    {\n        namespace GLExtensions\n        {\n            //-------------------------------------------------------\n            void InitExtensions()\n            {\n#if defined CS_TARGETPLATFORM_ANDROID || defined CS_TARGETPLATFORM_RPI\n                glGenVertexArraysOESEXT = (PFNGLGENVERTEXARRAYSOESPROC)eglGetProcAddress(\"glGenVertexArraysOES\");\n                glBindVertexArrayOESEXT = (PFNGLBINDVERTEXARRAYOESPROC)eglGetProcAddress(\"glBindVertexArrayOES\");\n                glDeleteVertexArraysOESEXT = (PFNGLDELETEVERTEXARRAYSOESPROC)eglGetProcAddress(\"glDeleteVertexArraysOES\");\n#endif\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "Source/CSBackend/Rendering/OpenGL/Base/GLExtensions.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2017 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERINGPLATFORM_OPENGL_GLEXTENSIONS_H_\n#define _CHILLISOURCE_RENDERINGPLATFORM_OPENGL_GLEXTENSIONS_H_\n\n#include <CSBackend/Rendering/OpenGL/Base/GLIncludes.h>\n\n#if defined CS_TARGETPLATFORM_ANDROID || defined CS_TARGETPLATFORM_RPI\n\nextern PFNGLGENVERTEXARRAYSOESPROC glGenVertexArraysOESEXT;\nextern PFNGLBINDVERTEXARRAYOESPROC glBindVertexArrayOESEXT;\nextern PFNGLDELETEVERTEXARRAYSOESPROC glDeleteVertexArraysOESEXT;\n\n#   define glGenVertexArraysOES glGenVertexArraysOESEXT\n#   define glBindVertexArrayOES glBindVertexArrayOESEXT\n#   define glDeleteVertexArraysOES glDeleteVertexArraysOESEXT\n#endif\n\n#ifdef CS_OPENGLVERSION_ES\n#   define glDeleteVertexArrays glDeleteVertexArraysOES\n#   define glBindVertexArray glBindVertexArrayOES\n#   define glGenVertexArrays glGenVertexArraysOES\n\n#   define GL_WRITE_ONLY GL_WRITE_ONLY_OES\n#   define glMapBuffer glMapBufferOES\n#   define glUnmapBuffer glUnmapBufferOES\n#endif\n\nnamespace CSBackend\n{\n    namespace OpenGL\n    {\n        namespace GLExtensions\n        {\n            /// Grab the functions pointers for any GL extensions required by the current platform\n            ///\n            void InitExtensions();\n        }\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Rendering/OpenGL/Base/GLIncludes.h",
    "content": "//\n//  GLIncludes.h\n//  ChilliSource\n//  Created by Ian Copland on 14/01/2011.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2011 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERINGPLATFORM_OPENGL_GLINCLUDES_H_\n#define _CHILLISOURCE_RENDERINGPLATFORM_OPENGL_GLINCLUDES_H_\n\n//---Missing OpenGL definitions\n#define GL_GLEXT_PROTOTYPES\n#ifdef CS_TARGETPLATFORM_ANDROID\ntypedef char GLchar;\n#endif\n\n#ifdef CS_TARGETPLATFORM_IOS\n#   include <OpenGLES/ES2/gl.h>\n#   include <OpenGLES/ES2/glext.h>\n#   include <OpenGLES/EAGL.h>\n#   include <OpenGLES/EAGLDrawable.h>\n#elif defined CS_TARGETPLATFORM_WINDOWS\n#   include <GL/glew.h>\n#   include <SFML/OpenGL.hpp>\n#   include <CSBackend/Platform/Windows/SFML/Base/SFMLWindow.h>\n#else\n#   include <GLES2/gl2.h>\n#   include <GLES2/gl2ext.h>\n#endif\n\n#if defined CS_TARGETPLATFORM_IOS || defined CS_TARGETPLATFORM_ANDROID || defined CS_TARGETPLATFORM_RPI\n#   define CS_OPENGLVERSION_ES\n#elif defined CS_TARGETPLATFORM_WINDOWS\n#   define CS_OPENGLVERSION_STANDARD\n#endif\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Rendering/OpenGL/Base/RenderCommandProcessor.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <CSBackend/Rendering/OpenGL/Base/RenderCommandProcessor.h>\n\n#include <CSBackend/Rendering/OpenGL/Base/GLError.h>\n#include <CSBackend/Rendering/OpenGL/Base/GLExtensions.h>\n#include <CSBackend/Rendering/OpenGL/Lighting/GLAmbientLight.h>\n#include <CSBackend/Rendering/OpenGL/Lighting/GLDirectionalLight.h>\n#include <CSBackend/Rendering/OpenGL/Lighting/GLPointLight.h>\n#include <CSBackend/Rendering/OpenGL/Material/GLMaterial.h>\n#include <CSBackend/Rendering/OpenGL/Model/GLMesh.h>\n#include <CSBackend/Rendering/OpenGL/Model/GLSkinnedAnimation.h>\n#include <CSBackend/Rendering/OpenGL/Shader/GLShader.h>\n#include <CSBackend/Rendering/OpenGL/Target/GLTargetGroup.h>\n#include <CSBackend/Rendering/OpenGL/Texture/GLCubemap.h>\n#include <CSBackend/Rendering/OpenGL/Texture/GLTexture.h>\n\n#include <ChilliSource/Rendering/Model/IndexFormat.h>\n#include <ChilliSource/Rendering/Model/PolygonType.h>\n#include <ChilliSource/Rendering/Model/RenderDynamicMesh.h>\n#include <ChilliSource/Rendering/RenderCommand/RenderCommandList.h>\n#include <ChilliSource/Rendering/RenderCommand/RenderCommandBuffer.h>\n#include <ChilliSource/Rendering/RenderCommand/Commands/ApplyAmbientLightRenderCommand.h>\n#include <ChilliSource/Rendering/RenderCommand/Commands/ApplyDirectionalLightRenderCommand.h>\n#include <ChilliSource/Rendering/RenderCommand/Commands/ApplyCameraRenderCommand.h>\n#include <ChilliSource/Rendering/RenderCommand/Commands/ApplyDynamicMeshRenderCommand.h>\n#include <ChilliSource/Rendering/RenderCommand/Commands/ApplyMaterialRenderCommand.h>\n#include <ChilliSource/Rendering/RenderCommand/Commands/ApplyMeshRenderCommand.h>\n#include <ChilliSource/Rendering/RenderCommand/Commands/ApplyMeshBatchRenderCommand.h>\n#include <ChilliSource/Rendering/RenderCommand/Commands/ApplyPointLightRenderCommand.h>\n#include <ChilliSource/Rendering/RenderCommand/Commands/ApplySkinnedAnimationRenderCommand.h>\n#include <ChilliSource/Rendering/RenderCommand/Commands/BeginRenderCommand.h>\n#include <ChilliSource/Rendering/RenderCommand/Commands/BeginWithTargetGroupRenderCommand.h>\n#include <ChilliSource/Rendering/RenderCommand/Commands/EndRenderCommand.h>\n#include <ChilliSource/Rendering/RenderCommand/Commands/LoadMaterialGroupRenderCommand.h>\n#include <ChilliSource/Rendering/RenderCommand/Commands/LoadMeshRenderCommand.h>\n#include <ChilliSource/Rendering/RenderCommand/Commands/LoadShaderRenderCommand.h>\n#include <ChilliSource/Rendering/RenderCommand/Commands/LoadTargetGroupRenderCommand.h>\n#include <ChilliSource/Rendering/RenderCommand/Commands/LoadCubemapRenderCommand.h>\n#include <ChilliSource/Rendering/RenderCommand/Commands/LoadTextureRenderCommand.h>\n#include <ChilliSource/Rendering/RenderCommand/Commands/RenderInstanceRenderCommand.h>\n#include <ChilliSource/Rendering/RenderCommand/Commands/RestoreMeshRenderCommand.h>\n#include <ChilliSource/Rendering/RenderCommand/Commands/RestoreRenderTargetGroupCommand.h>\n#include <ChilliSource/Rendering/RenderCommand/Commands/RestoreCubemapRenderCommand.h>\n#include <ChilliSource/Rendering/RenderCommand/Commands/RestoreTextureRenderCommand.h>\n#include <ChilliSource/Rendering/RenderCommand/Commands/UnloadMaterialGroupRenderCommand.h>\n#include <ChilliSource/Rendering/RenderCommand/Commands/UnloadMeshRenderCommand.h>\n#include <ChilliSource/Rendering/RenderCommand/Commands/UnloadShaderRenderCommand.h>\n#include <ChilliSource/Rendering/RenderCommand/Commands/UnloadTargetGroupRenderCommand.h>\n#include <ChilliSource/Rendering/RenderCommand/Commands/UnloadCubemapRenderCommand.h>\n#include <ChilliSource/Rendering/RenderCommand/Commands/UnloadTextureRenderCommand.h>\n\n#ifdef CS_TARGETPLATFORM_IOS\n#   import <CSBackend/Platform/iOS/Core/Base/CSAppDelegate.h>\n#   import <CSBackend/Platform/iOS/Core/Base/CSGLViewController.h>\n#endif\n\nnamespace CSBackend\n{\n    namespace OpenGL\n    {\n        namespace\n        {\n            const std::string k_uniformWVPMat = \"u_wvpMat\";\n            const std::string k_uniformWorldMat = \"u_worldMat\";\n            const std::string k_uniformViewMat = \"u_viewMat\";\n            const std::string k_uniformNormalMat = \"u_normalMat\";\n            \n            /// Converts from a ChilliSource polygon type to a OpenGL polygon type.\n            ///\n            /// @param blendMode\n            ///     The ChilliSource polygon type.\n            ///\n            /// @return The OpenGL polygon type.\n            ///\n            GLenum ToGLPolygonType(ChilliSource::PolygonType polygonType) noexcept\n            {\n                switch(polygonType)\n                {\n                    case ChilliSource::PolygonType::k_triangle:\n                        return GL_TRIANGLES;\n                    case ChilliSource::PolygonType::k_triangleStrip:\n                        return GL_TRIANGLE_STRIP;\n                    case ChilliSource::PolygonType::k_line:\n                        return GL_LINES;\n                    default:\n                        CS_LOG_FATAL(\"Invalid polygon type.\");\n                        return GL_TRIANGLES;\n                };\n            }\n            \n            /// Converts from a ChilliSource IndexFormat to an OpenGL type.\n            ///\n            /// @param indexFormat\n            ///     The index format to convert.\n            ///\n            /// @return The OpenGL type.\n            ///\n            GLenum ToGLIndexType(ChilliSource::IndexFormat indexFormat) noexcept\n            {\n                switch (indexFormat)\n                {\n                    case ChilliSource::IndexFormat::k_short:\n                        return GL_UNSIGNED_SHORT;\n                    default:\n                        CS_LOG_FATAL(\"Invalid index format.\");\n                        return GL_UNSIGNED_SHORT;\n                }\n            }\n        }\n        \n        //------------------------------------------------------------------------------\n        void RenderCommandProcessor::Process(const ChilliSource::RenderCommandBuffer* renderCommandBuffer) noexcept\n        {\n            if (m_initRequired)\n            {\n                m_initRequired = false;\n                Init();\n            }\n            \n            for(const auto& renderCommandList : renderCommandBuffer->GetQueue())\n            {\n                for (const auto& renderCommand : renderCommandList->GetOrderedList())\n                {\n                    switch (renderCommand->GetType())\n                    {\n                        case ChilliSource::RenderCommand::Type::k_loadShader:\n                            LoadShader(static_cast<const ChilliSource::LoadShaderRenderCommand*>(renderCommand));\n                            break;\n                        case ChilliSource::RenderCommand::Type::k_loadTexture:\n                            LoadTexture(static_cast<const ChilliSource::LoadTextureRenderCommand*>(renderCommand));\n                            break;\n                        case ChilliSource::RenderCommand::Type::k_loadCubemap:\n                            LoadCubemap(static_cast<const ChilliSource::LoadCubemapRenderCommand*>(renderCommand));\n                            break;\n                        case ChilliSource::RenderCommand::Type::k_loadMaterialGroup:\n                            // Do nothing in OpenGL 2.0 / ES 2.0\n                            break;\n                        case ChilliSource::RenderCommand::Type::k_loadMesh:\n                            LoadMesh(static_cast<const ChilliSource::LoadMeshRenderCommand*>(renderCommand));\n                            break;\n                        case ChilliSource::RenderCommand::Type::k_restoreMesh:\n                            RestoreMesh(static_cast<const ChilliSource::RestoreMeshRenderCommand*>(renderCommand));\n                            break;\n                        case ChilliSource::RenderCommand::Type::k_restoreTexture:\n                            RestoreTexture(static_cast<const ChilliSource::RestoreTextureRenderCommand*>(renderCommand));\n                            break;\n                        case ChilliSource::RenderCommand::Type::k_restoreCubemap:\n                            RestoreCubemap(static_cast<const ChilliSource::RestoreCubemapRenderCommand*>(renderCommand));\n                            break;\n                        case ChilliSource::RenderCommand::Type::k_restoreRenderTargetGroup:\n                            RestoreRenderTargetGroup(static_cast<const ChilliSource::RestoreRenderTargetGroupCommand*>(renderCommand));\n                            break;\n                        case ChilliSource::RenderCommand::Type::k_loadTargetGroup:\n                            LoadTargetGroup(static_cast<const ChilliSource::LoadTargetGroupRenderCommand*>(renderCommand));\n                            break;\n                        case ChilliSource::RenderCommand::Type::k_begin:\n                            Begin(static_cast<const ChilliSource::BeginRenderCommand*>(renderCommand));\n                            break;\n                        case ChilliSource::RenderCommand::Type::k_beginWithTargetGroup:\n                            BeginWithTargetGroup(static_cast<const ChilliSource::BeginWithTargetGroupRenderCommand*>(renderCommand));\n                            break;\n                        case ChilliSource::RenderCommand::Type::k_applyCamera:\n                            ApplyCamera(static_cast<const ChilliSource::ApplyCameraRenderCommand*>(renderCommand));\n                            break;\n                        case ChilliSource::RenderCommand::Type::k_applyAmbientLight:\n                            ApplyAmbientLight(static_cast<const ChilliSource::ApplyAmbientLightRenderCommand*>(renderCommand));\n                            break;\n                        case ChilliSource::RenderCommand::Type::k_applyDirectionalLight:\n                            ApplyDirectionalLight(static_cast<const ChilliSource::ApplyDirectionalLightRenderCommand*>(renderCommand));\n                            break;\n                        case ChilliSource::RenderCommand::Type::k_applyPointLight:\n                            ApplyPointLight(static_cast<const ChilliSource::ApplyPointLightRenderCommand*>(renderCommand));\n                            break;\n                        case ChilliSource::RenderCommand::Type::k_applyMaterial:\n                            ApplyMaterial(static_cast<const ChilliSource::ApplyMaterialRenderCommand*>(renderCommand));\n                            break;\n                        case ChilliSource::RenderCommand::Type::k_applyMesh:\n                            ApplyMesh(static_cast<const ChilliSource::ApplyMeshRenderCommand*>(renderCommand));\n                            break;\n                        case ChilliSource::RenderCommand::Type::k_applyDynamicMesh:\n                            ApplyDynamicMesh(static_cast<const ChilliSource::ApplyDynamicMeshRenderCommand*>(renderCommand));\n                            break;\n                        case ChilliSource::RenderCommand::Type::k_applyMeshBatch:\n                            ApplyMeshBatch(static_cast<const ChilliSource::ApplyMeshBatchRenderCommand*>(renderCommand));\n                            break;\n                        case ChilliSource::RenderCommand::Type::k_applySkinnedAnimation:\n                            ApplySkinnedAnimation(static_cast<const ChilliSource::ApplySkinnedAnimationRenderCommand*>(renderCommand));\n                            break;\n                        case ChilliSource::RenderCommand::Type::k_renderInstance:\n                            RenderInstance(static_cast<const ChilliSource::RenderInstanceRenderCommand*>(renderCommand));\n                            break;\n                        case ChilliSource::RenderCommand::Type::k_end:\n                            End();\n                            break;\n                        case ChilliSource::RenderCommand::Type::k_unloadShader:\n                            UnloadShader(static_cast<const ChilliSource::UnloadShaderRenderCommand*>(renderCommand));\n                            break;\n                        case ChilliSource::RenderCommand::Type::k_unloadTexture:\n                            UnloadTexture(static_cast<const ChilliSource::UnloadTextureRenderCommand*>(renderCommand));\n                            break;\n                        case ChilliSource::RenderCommand::Type::k_unloadCubemap:\n                            UnloadCubemap(static_cast<const ChilliSource::UnloadCubemapRenderCommand*>(renderCommand));\n                            break;\n                        case ChilliSource::RenderCommand::Type::k_unloadMaterialGroup:\n                            // Do nothing in OpenGL 2.0 / ES 2.0\n                            break;\n                        case ChilliSource::RenderCommand::Type::k_unloadMesh:\n                            UnloadMesh(static_cast<const ChilliSource::UnloadMeshRenderCommand*>(renderCommand));\n                            break;\n                        case ChilliSource::RenderCommand::Type::k_unloadTargetGroup:\n                            UnloadTargetGroup(static_cast<const ChilliSource::UnloadTargetGroupRenderCommand*>(renderCommand));\n                            break;\n                        default:\n                            CS_LOG_FATAL(\"Unknown render command.\");\n                            break;\n                    }\n                }\n            }\n        }\n        \n        //------------------------------------------------------------------------------\n        void RenderCommandProcessor::Invalidate() noexcept\n        {\n            if(m_glDynamicMesh)\n            {\n                m_glDynamicMesh->Invalidate();\n            }\n        }\n        \n        //------------------------------------------------------------------------------\n        void RenderCommandProcessor::Restore() noexcept\n        {\n            ResetCache();\n            \n            m_glDynamicMesh.reset();\n            m_glDynamicMesh = GLDynamicMeshUPtr(new GLDynamicMesh(ChilliSource::RenderDynamicMesh::k_maxVertexDataSize, ChilliSource::RenderDynamicMesh::k_maxIndexDataSize));\n        }\n        \n        //------------------------------------------------------------------------------\n        void RenderCommandProcessor::Init() noexcept\n        {\n            GLExtensions::InitExtensions();\n            m_textureUnitManager = GLTextureUnitManagerUPtr(new GLTextureUnitManager());\n            m_glDynamicMesh = GLDynamicMeshUPtr(new GLDynamicMesh(ChilliSource::RenderDynamicMesh::k_maxVertexDataSize, ChilliSource::RenderDynamicMesh::k_maxIndexDataSize));\n            \n            ResetCache();\n        }\n        \n        //------------------------------------------------------------------------------\n        void RenderCommandProcessor::LoadShader(const ChilliSource::LoadShaderRenderCommand* renderCommand) noexcept\n        {\n            ResetCache();\n            \n            auto renderShader = renderCommand->GetRenderShader();\n            \n            //TODO: Should be pooled.\n            auto glShader = new GLShader(renderCommand->GetVertexShader(), renderCommand->GetFragmentShader());\n            \n            renderShader->SetExtraData(glShader);\n        }\n        \n        //------------------------------------------------------------------------------\n        void RenderCommandProcessor::LoadTexture(const ChilliSource::LoadTextureRenderCommand* renderCommand) noexcept\n        {\n            ResetCache();\n            \n            auto renderTexture = renderCommand->GetRenderTexture();\n            \n            //TODO: Should be pooled.\n            auto glTexture = new GLTexture(renderCommand->GetTextureData(), renderCommand->GetTextureDataSize(), renderTexture);\n            \n            renderTexture->SetExtraData(glTexture);\n        }\n        \n        //------------------------------------------------------------------------------\n        void RenderCommandProcessor::LoadCubemap(const ChilliSource::LoadCubemapRenderCommand* renderCommand) noexcept\n        {\n            ResetCache();\n            \n            auto renderTexture = renderCommand->GetRenderTexture();\n            \n            //TODO: Should be pooled.\n            auto glCubemap = new GLCubemap(renderCommand->GetTextureData(), renderCommand->GetTextureDataSize(), renderTexture);\n            \n            renderTexture->SetExtraData(glCubemap);\n        }\n        \n        //------------------------------------------------------------------------------\n        void RenderCommandProcessor::LoadMesh(const ChilliSource::LoadMeshRenderCommand* renderCommand) noexcept\n        {\n            ResetCache();\n            \n            auto renderMesh = renderCommand->GetRenderMesh();\n            \n            //TODO: Should be pooled.\n            auto glMesh = new GLMesh(renderCommand->GetVertexData(), renderCommand->GetVertexDataSize(), renderCommand->GetIndexData(), renderCommand->GetIndexDataSize(), renderMesh);\n            \n            renderMesh->SetExtraData(glMesh);\n        }\n        \n        //------------------------------------------------------------------------------\n        void RenderCommandProcessor::RestoreTexture(const ChilliSource::RestoreTextureRenderCommand* renderCommand) noexcept\n        {\n            GLTexture* glTexture = static_cast<GLTexture*>(renderCommand->GetRenderTexture()->GetExtraData());\n            glTexture->Restore();\n        }\n        \n        //------------------------------------------------------------------------------\n        void RenderCommandProcessor::RestoreCubemap(const ChilliSource::RestoreCubemapRenderCommand* renderCommand) noexcept\n        {\n            GLCubemap* glCubemap = static_cast<GLCubemap*>(renderCommand->GetRenderTexture()->GetExtraData());\n            glCubemap->Restore();\n        }\n        \n        //------------------------------------------------------------------------------\n        void RenderCommandProcessor::RestoreMesh(const ChilliSource::RestoreMeshRenderCommand* renderCommand) noexcept\n        {\n            GLMesh* glMesh = static_cast<GLMesh*>(renderCommand->GetRenderMesh()->GetExtraData());\n            glMesh->Restore();\n        }\n        \n        //------------------------------------------------------------------------------\n        void RenderCommandProcessor::RestoreRenderTargetGroup(const ChilliSource::RestoreRenderTargetGroupCommand* renderCommand) noexcept\n        {\n            //Check if any of the textures are invalid before restoring, if a texture is still invalid at this stage\n            //it was loaded from disk and the RenderTargetGroup will be recreated when TargetGroup is accessed again.\n            bool texturesInvalid = false;\n            const auto targetRenderGroup = renderCommand->GetTargetRenderGroup();\n            if(targetRenderGroup->GetDepthTarget())\n            {\n                GLTexture* glDepthTexture = static_cast<GLTexture*>(targetRenderGroup->GetDepthTarget()->GetExtraData());\n                texturesInvalid = glDepthTexture->IsDataInvalid();\n            }\n            \n            if(!texturesInvalid && targetRenderGroup->GetColourTarget())\n            {\n                GLTexture* glColourTexture = static_cast<GLTexture*>(targetRenderGroup->GetColourTarget()->GetExtraData());\n                texturesInvalid = glColourTexture->IsDataInvalid();\n            }\n            \n            if(!texturesInvalid)\n            {\n                GLTargetGroup* glTarget = static_cast<GLTargetGroup*>(targetRenderGroup->GetExtraData());\n                glTarget->Restore();\n            }\n        }\n        \n        //------------------------------------------------------------------------------\n        void RenderCommandProcessor::LoadTargetGroup(const ChilliSource::LoadTargetGroupRenderCommand* renderCommand) noexcept\n        {\n            ResetCache();\n            \n            auto renderTargetGroup = renderCommand->GetRenderTargetGroup();\n            \n            //TODO: Should be pooled.\n            auto glTargetGroup = new GLTargetGroup(renderTargetGroup);\n            \n            renderTargetGroup->SetExtraData(glTargetGroup);\n        }\n        \n        //------------------------------------------------------------------------------\n        void RenderCommandProcessor::Begin(const ChilliSource::BeginRenderCommand* renderCommand) noexcept\n        {\n            ResetCache();\n     \n            // iOS doesn't have a default frame buffer bound to 0, instead the view controllers frame buffer must\n            // be bound manually. Other platforms can just bind 0.\n#ifdef CS_TARGETPLATFORM_IOS\n            GLKView* glView = (GLKView*)[CSAppDelegate sharedInstance].viewController.view;\n            [glView bindDrawable];\n#else\n            glBindFramebuffer(GL_FRAMEBUFFER, 0);\n            glViewport(0, 0, renderCommand->GetResolution().x, renderCommand->GetResolution().y);\n#endif\n            \n            glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);\n            glDepthMask(GL_TRUE);\n            \n            glClearColor(renderCommand->GetClearColour().r, renderCommand->GetClearColour().g, renderCommand->GetClearColour().b, renderCommand->GetClearColour().a);\n            glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);\n            \n            glBlendEquation(GL_FUNC_ADD);\n            \n            CS_ASSERT_NOGLERROR(\"An OpenGL error occurred while beginning rendering.\");\n        }\n        \n        //------------------------------------------------------------------------------\n        void RenderCommandProcessor::BeginWithTargetGroup(const ChilliSource::BeginWithTargetGroupRenderCommand* renderCommand) noexcept\n        {\n            ResetCache();\n            \n            m_currentRenderTargetGroup = renderCommand->GetRenderTargetGroup();\n            CS_ASSERT(m_currentRenderTargetGroup, \"Cannot render with a null render target group.\");\n            \n            auto glTargetGroup = static_cast<GLTargetGroup*>(m_currentRenderTargetGroup->GetExtraData());\n            CS_ASSERT(glTargetGroup, \"Cannot render with a render target group which hasn't been loaded.\");\n            \n            glTargetGroup->Bind();\n            \n            glViewport(0, 0, m_currentRenderTargetGroup->GetResolution().x, m_currentRenderTargetGroup->GetResolution().y);\n            \n            glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);\n            glDepthMask(GL_TRUE);\n            \n            glClearColor(renderCommand->GetClearColour().r, renderCommand->GetClearColour().g, renderCommand->GetClearColour().b, renderCommand->GetClearColour().a);\n            glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);\n            \n            CS_ASSERT_NOGLERROR(\"An OpenGL error occurred while beginning rendering with a target group.\");\n        }\n        \n        //------------------------------------------------------------------------------\n        void RenderCommandProcessor::ApplyCamera(const ChilliSource::ApplyCameraRenderCommand* renderCommand) noexcept\n        {\n            m_currentMaterial = nullptr;\n            \n            m_currentCamera = GLCamera(renderCommand->GetPosition(), renderCommand->GetViewMatrix(), renderCommand->GetViewProjectionMatrix());\n        }\n        \n        //------------------------------------------------------------------------------\n        void RenderCommandProcessor::ApplyAmbientLight(const ChilliSource::ApplyAmbientLightRenderCommand* renderCommand) noexcept\n        {\n            m_currentMaterial = nullptr;\n            \n            m_currentLight = GLLightUPtr(new GLAmbientLight(renderCommand->GetColour()));\n        }\n        \n        //------------------------------------------------------------------------------\n        void RenderCommandProcessor::ApplyDirectionalLight(const ChilliSource::ApplyDirectionalLightRenderCommand* renderCommand) noexcept\n        {\n            m_currentMaterial = nullptr;\n            \n            m_currentLight = GLLightUPtr(new GLDirectionalLight(renderCommand->GetColour(), renderCommand->GetDirection(), renderCommand->GetLightViewProjection(),\n                                                                renderCommand->GetShadowTolerance(), renderCommand->GetShadowMapRenderTexture()));\n        }\n\n        //------------------------------------------------------------------------------\n        void RenderCommandProcessor::ApplyPointLight(const ChilliSource::ApplyPointLightRenderCommand* renderCommand) noexcept\n        {\n            m_currentMaterial = nullptr;\n            \n            m_currentLight = GLLightUPtr(new GLPointLight(renderCommand->GetColour(), renderCommand->GetPosition(), renderCommand->GetAttenuation()));\n        }\n        \n        //------------------------------------------------------------------------------\n        void RenderCommandProcessor::ApplyMaterial(const ChilliSource::ApplyMaterialRenderCommand* renderCommand) noexcept\n        {\n            auto renderMaterial = renderCommand->GetRenderMaterial();\n            if (m_currentMaterial != renderMaterial)\n            {\n                m_currentMaterial = renderMaterial;\n                \n                auto renderShader = m_currentMaterial->GetRenderShader();\n                GLShader* glShader = static_cast<GLShader*>(renderShader->GetExtraData());\n                if (m_currentShader != renderShader)\n                {\n                    m_currentMesh = nullptr;\n                    m_currentDynamicMesh = nullptr;\n                    m_currentSkinnedAnimation = nullptr;\n                    \n                    m_currentShader = renderShader;\n                    \n                    glShader->Bind();\n                }\n                \n                m_textureUnitManager->Bind(GL_TEXTURE_2D, m_currentMaterial->GetRenderTextures2D(), 0u);\n                m_textureUnitManager->Bind(GL_TEXTURE_CUBE_MAP, m_currentMaterial->GetRenderTexturesCubemap(), u32(m_currentMaterial->GetRenderTextures2D().size()));\n                \n                m_currentCamera.Apply(glShader);\n                \n                GLMaterial::Apply(renderMaterial, glShader);\n                \n                if (m_currentLight)\n                {\n                    // The light may bind additional textures, meaning it must be applied after the material is applied.\n                    m_currentLight->Apply(glShader, m_textureUnitManager.get());\n                }\n            }\n        }\n        \n        //------------------------------------------------------------------------------\n        void RenderCommandProcessor::ApplyMesh(const ChilliSource::ApplyMeshRenderCommand* renderCommand) noexcept\n        {\n            CS_ASSERT(m_currentMaterial, \"A material must be applied before applying mesh.\");\n            CS_ASSERT(m_currentShader, \"A shader must be applied before applying mesh.\");\n            \n            auto renderMesh = renderCommand->GetRenderMesh();\n            if (m_currentMesh != renderMesh)\n            {\n                m_currentMesh = renderMesh;\n                m_currentDynamicMesh = nullptr;\n                m_currentSkinnedAnimation = nullptr;\n                \n                auto glMesh = static_cast<GLMesh*>(m_currentMesh->GetExtraData());\n                auto glShader = static_cast<GLShader*>(m_currentShader->GetExtraData());\n                glMesh->Bind(glShader);\n            }\n        }\n        \n        //------------------------------------------------------------------------------\n        void RenderCommandProcessor::ApplyDynamicMesh(const ChilliSource::ApplyDynamicMeshRenderCommand* renderCommand) noexcept\n        {\n            CS_ASSERT(m_currentMaterial, \"A material must be applied before applying mesh.\");\n            CS_ASSERT(m_currentShader, \"A shader must be applied before applying mesh.\");\n            \n            auto renderDynamicMesh = renderCommand->GetRenderDynamicMesh();\n            if (m_currentDynamicMesh != renderDynamicMesh)\n            {\n                m_currentMesh = nullptr;\n                m_currentDynamicMesh = renderDynamicMesh;\n                m_currentSkinnedAnimation = nullptr;\n                \n                auto glShader = static_cast<GLShader*>(m_currentShader->GetExtraData());\n                \n                auto polygonType = m_currentDynamicMesh->GetPolygonType();\n                const auto& vertexFormat = m_currentDynamicMesh->GetVertexFormat();\n                auto indexFormat = m_currentDynamicMesh->GetIndexFormat();\n                auto numVertices = m_currentDynamicMesh->GetNumVertices();\n                auto numIndices = m_currentDynamicMesh->GetNumIndices();\n                auto vertexData = m_currentDynamicMesh->GetVertexData();\n                auto vertexDataSize = m_currentDynamicMesh->GetVertexDataSize();\n                auto indexData = m_currentDynamicMesh->GetIndexData();\n                auto indexDataSize = m_currentDynamicMesh->GetIndexDataSize();\n                \n                m_glDynamicMesh->Bind(glShader, polygonType, vertexFormat, indexFormat, numVertices, numIndices, vertexData, vertexDataSize, indexData, indexDataSize);\n            }\n        }\n        \n        //------------------------------------------------------------------------------\n        void RenderCommandProcessor::ApplyMeshBatch(const ChilliSource::ApplyMeshBatchRenderCommand* renderCommand) noexcept\n        {\n            CS_ASSERT(m_currentMaterial, \"A material must be applied before applying mesh batch.\");\n            CS_ASSERT(m_currentShader, \"A shader must be applied before applying mesh batch.\");\n            \n            m_currentMesh = nullptr;\n            m_currentDynamicMesh = nullptr;\n            m_currentSkinnedAnimation = nullptr;\n            auto renderMeshBatch = renderCommand->GetRenderMeshBatch();\n            \n            auto glShader = static_cast<GLShader*>(m_currentShader->GetExtraData());\n            \n            auto polygonType = renderMeshBatch->GetPolygonType();\n            const auto& vertexFormat = renderMeshBatch->GetVertexFormat();\n            auto indexFormat = renderMeshBatch->GetIndexFormat();\n            auto numVertices = renderMeshBatch->GetNumVertices();\n            auto numIndices = renderMeshBatch->GetNumIndices();\n            auto vertexDataSize = renderMeshBatch->GetVertexDataSize();\n            auto indexDataSize = renderMeshBatch->GetIndexDataSize();\n            const auto& meshes = renderMeshBatch->GetMeshes();\n            \n            m_glDynamicMesh->Bind(glShader, polygonType, vertexFormat, indexFormat, numVertices, numIndices, vertexDataSize, indexDataSize, meshes);\n        }\n        \n        //------------------------------------------------------------------------------\n        void RenderCommandProcessor::ApplySkinnedAnimation(const ChilliSource::ApplySkinnedAnimationRenderCommand* renderCommand) noexcept\n        {\n            CS_ASSERT(m_currentMaterial, \"A material must be applied before applying skinned animation.\");\n            CS_ASSERT(m_currentShader, \"A shader must be applied before applying skinned animation.\");\n            CS_ASSERT(m_currentMesh || m_currentDynamicMesh, \"A mesh must be applied before applying skinned animation.\");\n            \n            if (m_currentSkinnedAnimation != renderCommand->GetRenderSkinnedAnimation())\n            {\n                m_currentSkinnedAnimation = renderCommand->GetRenderSkinnedAnimation();\n                \n                auto glShader = static_cast<GLShader*>(m_currentShader->GetExtraData());\n                \n                GLSkinnedAnimation::Apply(m_currentSkinnedAnimation, glShader);\n            }\n        }\n        \n        //------------------------------------------------------------------------------\n        void RenderCommandProcessor::RenderInstance(const ChilliSource::RenderInstanceRenderCommand* renderCommand) noexcept\n        {\n            CS_ASSERT(m_currentMaterial, \"A material must be applied before rendering a mesh.\");\n            CS_ASSERT(m_currentShader, \"A shader must be applied before rendering a mesh.\");\n            \n            auto glShader = static_cast<GLShader*>(m_currentShader->GetExtraData());\n            glShader->SetUniform(k_uniformWorldMat, renderCommand->GetWorldMatrix(), GLShader::FailurePolicy::k_silent);\n            glShader->SetUniform(k_uniformViewMat, m_currentCamera.GetViewMatrix(), GLShader::FailurePolicy::k_silent);\n            glShader->SetUniform(k_uniformWVPMat, renderCommand->GetWorldMatrix() * m_currentCamera.GetViewProjectionMatrix(), GLShader::FailurePolicy::k_silent);\n            glShader->SetUniform(k_uniformNormalMat, ChilliSource::Matrix4::Transpose(ChilliSource::Matrix4::Inverse(renderCommand->GetWorldMatrix())), GLShader::FailurePolicy::k_silent);\n            \n            if (m_currentMesh)\n            {\n                if (m_currentMesh->GetNumIndices() > 0)\n                {\n                    glDrawElements(ToGLPolygonType(m_currentMesh->GetPolygonType()), m_currentMesh->GetNumIndices(), ToGLIndexType(m_currentMesh->GetIndexFormat()), 0);\n                }\n                else\n                {\n                    glDrawArrays(ToGLPolygonType(m_currentMesh->GetPolygonType()), 0, m_currentMesh->GetNumVertices());\n                }\n            }\n            else\n            {\n                if (m_glDynamicMesh->GetNumIndices() > 0)\n                {\n                    glDrawElements(ToGLPolygonType(m_glDynamicMesh->GetPolygonType()), m_glDynamicMesh->GetNumIndices(), ToGLIndexType(m_glDynamicMesh->GetIndexFormat()), 0);\n                }\n                else\n                {\n                    glDrawArrays(ToGLPolygonType(m_glDynamicMesh->GetPolygonType()), 0, m_glDynamicMesh->GetNumVertices());\n                }\n                \n                m_glDynamicMesh->SwitchBuffer();\n            }\n            \n            CS_ASSERT_NOGLERROR(\"An OpenGL error occurred while rendering an instance.\");\n        }\n        \n        //------------------------------------------------------------------------------\n        void RenderCommandProcessor::End() noexcept\n        {\n            if (m_currentRenderTargetGroup)\n            {\n                // For some platforms we need to store a shadow copy of textures in memory\n                // so we can restore if the context is lost. This updates that shadow copy\n                if(m_currentRenderTargetGroup->GetColourTarget())\n                {\n                    auto glColourTexture = static_cast<GLTexture*>(m_currentRenderTargetGroup->GetColourTarget()->GetExtraData());\n                    glColourTexture->UpdateRestorableBackup();\n                }\n                \n                if(m_currentRenderTargetGroup->GetDepthTarget())\n                {\n                    auto glDepthTexture = static_cast<GLTexture*>(m_currentRenderTargetGroup->GetDepthTarget()->GetExtraData());\n                    glDepthTexture->UpdateRestorableBackup();\n                }\n            }\n            \n            ResetCache();\n        }\n        \n        //------------------------------------------------------------------------------\n        void RenderCommandProcessor::UnloadShader(const ChilliSource::UnloadShaderRenderCommand* renderCommand) noexcept\n        {\n            ResetCache();\n            \n            auto renderShader = renderCommand->GetRenderShader();\n            auto glShader = static_cast<GLShader*>(renderShader->GetExtraData());\n            \n            CS_SAFEDELETE(glShader);\n        }\n        \n        //------------------------------------------------------------------------------\n        void RenderCommandProcessor::UnloadTexture(const ChilliSource::UnloadTextureRenderCommand* renderCommand) noexcept\n        {\n            ResetCache();\n            \n            auto renderTexture = renderCommand->GetRenderTexture();\n            auto glTexture = static_cast<GLTexture*>(renderTexture->GetExtraData());\n            \n            CS_SAFEDELETE(glTexture);\n        }\n        \n        //------------------------------------------------------------------------------\n        void RenderCommandProcessor::UnloadCubemap(const ChilliSource::UnloadCubemapRenderCommand* renderCommand) noexcept\n        {\n            ResetCache();\n            \n            auto renderTexture = renderCommand->GetRenderTexture();\n            auto glCubemap = static_cast<GLCubemap*>(renderTexture->GetExtraData());\n            \n            CS_SAFEDELETE(glCubemap);\n        }\n        \n        //------------------------------------------------------------------------------\n        void RenderCommandProcessor::UnloadMesh(const ChilliSource::UnloadMeshRenderCommand* renderCommand) noexcept\n        {\n            ResetCache();\n            \n            auto renderMesh = renderCommand->GetRenderMesh();\n            auto glMesh = static_cast<GLMesh*>(renderMesh->GetExtraData());\n            \n            CS_SAFEDELETE(glMesh);\n        }\n        \n        //------------------------------------------------------------------------------\n        void RenderCommandProcessor::UnloadTargetGroup(const ChilliSource::UnloadTargetGroupRenderCommand* renderCommand) noexcept\n        {\n            ResetCache();\n            \n            auto renderTargetGroup = renderCommand->GetRenderTargetGroup();\n            auto glTargetGroup = static_cast<GLTargetGroup*>(renderTargetGroup->GetExtraData());\n            \n            CS_SAFEDELETE(glTargetGroup);\n        }\n        \n        //------------------------------------------------------------------------------\n        void RenderCommandProcessor::ResetCache() noexcept\n        {\n            m_textureUnitManager->Reset();\n            m_currentCamera = GLCamera();\n            m_currentLight.reset();\n            m_currentRenderTargetGroup = nullptr;\n            m_currentMesh = nullptr;\n            m_currentDynamicMesh = nullptr;\n            m_currentShader = nullptr;\n            m_currentMaterial = nullptr;\n            m_currentSkinnedAnimation = nullptr;\n        }\n\n        //------------------------------------------------------------------------------\n        RenderCommandProcessor::~RenderCommandProcessor() noexcept\n        {\n            // This is destroyed from the main thread so the GLDynamicMesh cannot be cleaned up gracefully.\n            // However, if this is called the context is about to be lost anyway so it doesn't need to be\n            // cleaned up, so we can just invalidate it.\n            m_glDynamicMesh->Invalidate();\n        }\n    }\n}\n"
  },
  {
    "path": "Source/CSBackend/Rendering/OpenGL/Base/RenderCommandProcessor.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CSBACKEND_RENDERING_OPENGL_BASE_RENDERCOMMANDPROCESSOR_H_\n#define _CSBACKEND_RENDERING_OPENGL_BASE_RENDERCOMMANDPROCESSOR_H_\n\n#include <CSBackend/Rendering/OpenGL/ForwardDeclarations.h>\n\n#include <CSBackend/Rendering/OpenGL/Camera/GLCamera.h>\n#include <CSBackend/Rendering/OpenGL/Lighting/GLLight.h>\n#include <CSBackend/Rendering/OpenGL/Model/GLDynamicMesh.h>\n#include <CSBackend/Rendering/OpenGL/Texture/GLTextureUnitManager.h>\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Base/Colour.h>\n#include <ChilliSource/Core/Memory/UniquePtr.h>\n#include <ChilliSource/Rendering/Base/IRenderCommandProcessor.h>\n\nnamespace CSBackend\n{\n    namespace OpenGL\n    {\n        /// An OpenGL implementation of the IRenderCommandProcessor interface. This processes\n        /// buffers of render commands using the OpenGL render API.\n        ///\n        /// This is not thread-safe and must be called on the render thread.\n        ///\n        class RenderCommandProcessor final : public ChilliSource::IRenderCommandProcessor\n        {\n        public:\n            /// Processes the given render command buffer, performing the required actions for\n            /// the command using OpenGL.\n            ///\n            /// @param renderCommandBuffer\n            ///     The buffer of render commands that should be processed.\n            ///\n            void Process(const ChilliSource::RenderCommandBuffer* renderCommandBuffer) noexcept override;\n            \n            /// Called when the GL context is lost, iterate any GL resources and place\n            /// them in an invalid state\n            ///\n            void Invalidate() noexcept override;\n            \n            /// Called when the GL context is restored, need to rebuild any GL resources\n            ///\n            void Restore() noexcept override;\n\n            ~RenderCommandProcessor() noexcept;\n            \n        private:\n            /// Initialises the render command processor. This is deferred until Process is first called\n            /// to ensure it is run on the render thread.\n            ///\n            void Init() noexcept;\n            \n            /// Loads the shader described by the given load command\n            ///\n            /// @param renderCommand\n            ///     The render command\n            ///\n            void LoadShader(const ChilliSource::LoadShaderRenderCommand* renderCommand) noexcept;\n            \n            /// Loads the texture described by the given load command\n            ///\n            /// @param renderCommand\n            ///     The render command\n            ///\n            void LoadTexture(const ChilliSource::LoadTextureRenderCommand* renderCommand) noexcept;\n            \n            /// Loads the cubemap described by the given load command\n            ///\n            /// @param renderCommand\n            ///     The render command\n            ///\n            void LoadCubemap(const ChilliSource::LoadCubemapRenderCommand* renderCommand) noexcept;\n            \n            /// Loads the mesh described by the given load command\n            ///\n            /// @param renderCommand\n            ///     The render command\n            ///\n            void LoadMesh(const ChilliSource::LoadMeshRenderCommand* renderCommand) noexcept;\n            \n            /// Restores the texture given by the command\n            ///\n            /// @param renderCommand\n            ///     The render command\n            ///\n            void RestoreTexture(const ChilliSource::RestoreTextureRenderCommand* renderCommand) noexcept;\n            \n            /// Restores the cubemap given by the command\n            ///\n            /// @param renderCommand\n            ///     The render command\n            ///\n            void RestoreCubemap(const ChilliSource::RestoreCubemapRenderCommand* renderCommand) noexcept;\n            \n            /// Restores the mesh given by the command\n            ///\n            /// @param renderCommand\n            ///     The render command\n            ///\n            void RestoreMesh(const ChilliSource::RestoreMeshRenderCommand* renderCommand) noexcept;\n\n            /// Restores the render target group given by the command\n            ///\n            /// @param renderCommand\n            ///     The render command\n            ///\n            void RestoreRenderTargetGroup(const ChilliSource::RestoreRenderTargetGroupCommand* renderCommand) noexcept;\n            \n            /// Loads the target group described by the given load command\n            ///\n            /// @param renderCommand\n            ///     The render command\n            ///\n            void LoadTargetGroup(const ChilliSource::LoadTargetGroupRenderCommand* renderCommand) noexcept;\n\n            /// Begins rendering to the default render target.\n            ///\n            /// @param renderCommand\n            ///     The render command\n            ///\n            void Begin(const ChilliSource::BeginRenderCommand* renderCommand) noexcept;\n            \n            /// Begins rendering to the the described render target group.\n            ///\n            /// @param renderCommand\n            ///     The render command\n            ///\n            void BeginWithTargetGroup(const ChilliSource::BeginWithTargetGroupRenderCommand* renderCommand) noexcept;\n            \n            /// Caches the given camera data. All applied materials after this will use this camera data.\n            /// The currently applied material will be invalidated and needs to be re-applied.\n            ///\n            /// @param renderCommand\n            ///     The render command\n            ///\n            void ApplyCamera(const ChilliSource::ApplyCameraRenderCommand* renderCommand) noexcept;\n            \n            /// Caches the given ambient light data and invalidates all other light data. All applied materials\n            /// after this will use this data.\n            ///\n            /// The currently applied material will be invalidated and needs to be re-applied.\n            ///\n            /// @param renderCommand\n            ///     The render command\n            ///\n            void ApplyAmbientLight(const ChilliSource::ApplyAmbientLightRenderCommand* renderCommand) noexcept;\n            \n            /// Caches the given directional light data and invalidates all other light data. All applied materials\n            /// after this will use this data.\n            ///\n            /// The currently applied material will be invalidated and needs to be re-applied.\n            ///\n            /// @param renderCommand\n            ///     The render command\n            ///\n            void ApplyDirectionalLight(const ChilliSource::ApplyDirectionalLightRenderCommand* renderCommand) noexcept;\n            \n            /// Caches the given point light data and invalidates all other light data. All applied materials\n            /// after this will use this data.\n            ///\n            /// The currently applied material will be invalidated and needs to be re-applied.\n            ///\n            /// @param renderCommand\n            ///     The render command\n            ///\n            void ApplyPointLight(const ChilliSource::ApplyPointLightRenderCommand* renderCommand) noexcept;\n            \n            /// Applies the given material to the OpenGL Context. The cached camera data will be used.\n            ///\n            /// @param renderCommand\n            ///     The render command\n            ///\n            void ApplyMaterial(const ChilliSource::ApplyMaterialRenderCommand* renderCommand) noexcept;\n            \n            /// Applies the given mesh to the OpenGL Context.\n            ///\n            /// @param renderCommand\n            ///     The render command\n            ///\n            void ApplyMesh(const ChilliSource::ApplyMeshRenderCommand* renderCommand) noexcept;\n            \n            /// Applies the given dynamic mesh to the OpenGL Context.\n            ///\n            /// @param renderCommand\n            ///     The render command\n            ///\n            void ApplyDynamicMesh(const ChilliSource::ApplyDynamicMeshRenderCommand* renderCommand) noexcept;\n            \n            /// Applies the given mesh batch to the OpenGL Context.\n            ///\n            /// @param renderCommand\n            ///     The render command\n            ///\n            void ApplyMeshBatch(const ChilliSource::ApplyMeshBatchRenderCommand* renderCommand) noexcept;\n            \n            /// Applies the given skinned animation to the OpenGL Context. If the skinned animation is null\n            /// then skinned animation will be disabled.\n            ///\n            /// @param renderCommand\n            ///     The render command\n            ///\n            void ApplySkinnedAnimation(const ChilliSource::ApplySkinnedAnimationRenderCommand* renderCommand) noexcept;\n            \n            /// Renders an instance of the mesh described by the current OpenGL context state. A camera,\n            /// material and mesh must all currently be appled to the context.\n            ///\n            /// @param renderCommand\n            ///     The render command\n            ///\n            void RenderInstance(const ChilliSource::RenderInstanceRenderCommand* renderCommand) noexcept;\n            \n            /// Ends rendering to the current render target.\n            ///\n            void End() noexcept;\n            \n            /// Unloads the shader described by the given unload command\n            ///\n            /// @param renderCommand\n            ///     The render command\n            ///\n            void UnloadShader(const ChilliSource::UnloadShaderRenderCommand* renderCommand) noexcept;\n            \n            /// Unloads the texture described by the given unload command\n            ///\n            /// @param renderCommand\n            ///     The render command\n            ///\n            void UnloadTexture(const ChilliSource::UnloadTextureRenderCommand* renderCommand) noexcept;\n            \n            /// Unloads the cubemap described by the given unload command\n            ///\n            /// @param renderCommand\n            ///     The render command\n            ///\n            void UnloadCubemap(const ChilliSource::UnloadCubemapRenderCommand* renderCommand) noexcept;\n            \n            /// Unloads the mesh described by the given unload command\n            ///\n            /// @param renderCommand\n            ///     The render command\n            ///\n            void UnloadMesh(const ChilliSource::UnloadMeshRenderCommand* renderCommand) noexcept;\n            \n            /// Unloads the target group described by the given unload command\n            ///\n            /// @param renderCommand\n            ///     The render command\n            ///\n            void UnloadTargetGroup(const ChilliSource::UnloadTargetGroupRenderCommand* renderCommand) noexcept;\n            \n            /// Resets the cached values back to thier original state.\n            ///\n            void ResetCache() noexcept;\n            \n            bool m_initRequired = true;\n            \n            GLTextureUnitManagerUPtr m_textureUnitManager;\n            GLDynamicMeshUPtr m_glDynamicMesh;\n            \n            GLCamera m_currentCamera;\n            GLLightUPtr m_currentLight;\n            const ChilliSource::RenderTargetGroup* m_currentRenderTargetGroup = nullptr;\n            const ChilliSource::RenderShader* m_currentShader = nullptr;\n            const ChilliSource::RenderMaterial* m_currentMaterial = nullptr;\n            const ChilliSource::RenderMesh* m_currentMesh = nullptr;\n            const ChilliSource::RenderDynamicMesh* m_currentDynamicMesh = nullptr;\n            const ChilliSource::RenderSkinnedAnimation* m_currentSkinnedAnimation = nullptr;\n        };\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Rendering/OpenGL/Base/RenderInfoFactory.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <CSBackend/Rendering/OpenGL/Base/RenderInfoFactory.h>\n\n#include <CSBackend/Rendering/OpenGL/Base/GLError.h>\n#include <CSBackend/Rendering/OpenGL/Base/GLIncludes.h>\n\nnamespace CSBackend\n{\n    namespace OpenGL\n    {\n        namespace\n        {\n            /// Check for OpenGL Extension support\n            ///\n            /// @param extension\n            ///     The extension to check\n            ///\n            /// @return Whether it is supported\n            ///\n            bool CheckForOpenGLExtension(const std::string& extension)\n            {\n                std::string extensions = (const char*)glGetString(GL_EXTENSIONS);\n                return extensions.find(extension) != extensions.npos;\n            }\n        }\n        \n        //-------------------------------------------------------\n        ChilliSource::RenderInfo RenderInfoFactory::CreateRenderInfo() noexcept\n        {\n            bool areHighPrecFragmentsSupported = true;\n            bool areMapBuffersSupported = true;\n            bool areVAOsSupported = true;\n            bool areDepthTexturesSupported = false;\n            bool areShadowMapsSupported = false;\n            \n            u32 maxTextureSize = 0;\n            u32 maxTextureUnits = 0;\n            u32 maxVertexAttribs = 0;\n            \n#ifdef CS_OPENGLVERSION_ES\n            s32 fragmentHighRanges[2];\n            s32 fragmentHighPrecision;\n            \n            glGetShaderPrecisionFormat(GL_FRAGMENT_SHADER, GL_HIGH_FLOAT, fragmentHighRanges, &fragmentHighPrecision);\n            areHighPrecFragmentsSupported = fragmentHighPrecision != 0 && fragmentHighRanges[0] != 0 && fragmentHighRanges[1] != 0;\n            \n#ifdef CS_TARGETPLATFORM_ANDROID\n            //Check for map buffer support\n            areMapBuffersSupported = CheckForOpenGLExtension(\"GL_OES_mapbuffer\");\n            areVAOsSupported = CheckForOpenGLExtension(\"GL_OES_vertex_array_object\");\n#endif\n            \n#ifdef CS_TARGETPLATFORM_RPI\n            areVAOsSupported = false;\n#endif\n            \n#endif\n            \n#ifdef CS_OPENGLVERSION_STANDARD\n            areDepthTexturesSupported = CheckForOpenGLExtension(\"GL_ARB_depth_texture\");\n#elif defined(CS_OPENGLVERSION_ES)\n            areDepthTexturesSupported = CheckForOpenGLExtension(\"GL_OES_depth_texture\");\n#endif\n            areShadowMapsSupported = (areDepthTexturesSupported && areHighPrecFragmentsSupported);\n            glGetIntegerv(GL_MAX_TEXTURE_SIZE, (GLint*)&maxTextureSize);\n            glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, (GLint*)&maxTextureUnits);\n            glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, (GLint*)&maxVertexAttribs);\n            \n            CS_ASSERT_NOGLERROR(\"An OpenGL error occurred while getting render capabilities.\");\n            \n            ChilliSource::RenderInfo renderInfo(areShadowMapsSupported, areDepthTexturesSupported, areMapBuffersSupported, areVAOsSupported, areHighPrecFragmentsSupported, maxTextureSize, maxTextureUnits, maxVertexAttribs);\n            \n            return renderInfo;\n        }\n    }\n} \n"
  },
  {
    "path": "Source/CSBackend/Rendering/OpenGL/Base/RenderInfoFactory.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CSBACKEND_RENDERING_OPENGL_BASE_RENDERINFOFACTORY_H_\n#define _CSBACKEND_RENDERING_OPENGL_BASE_RENDERINFOFACTORY_H_\n\n#include <ChilliSource/ChilliSource.h>\n\n#include <ChilliSource/Core/Base/RenderInfo.h>\n\nnamespace CSBackend\n{\n    namespace OpenGL\n    {\n        /// A factory for creating new instances of RenderInfo. This will query openGL\n        /// to gather information about the rendering capabilities of the current device.\n        ///\n        namespace RenderInfoFactory\n        {\n            /// @return The RenderInfo for this device.\n            ///\n            ChilliSource::RenderInfo CreateRenderInfo() noexcept;\n        }\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Rendering/OpenGL/Camera/GLCamera.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <CSBackend/Rendering/OpenGL/Camera/GLCamera.h>\n\n#include <CSBackend/Rendering/OpenGL/Shader/GLShader.h>\n\nnamespace CSBackend\n{\n    namespace OpenGL\n    {\n        namespace\n        {\n            const std::string k_uniformCameraPos = \"u_cameraPos\";\n        }\n        \n        //------------------------------------------------------------------------------\n        GLCamera::GLCamera(const ChilliSource::Vector3& position, const ChilliSource::Matrix4& viewMatrix, const ChilliSource::Matrix4& viewProjectionMatrix) noexcept\n            : m_position(position), m_viewMatrix(viewMatrix), m_viewProjectionMatrix(viewProjectionMatrix)\n        {\n        }\n        \n        //------------------------------------------------------------------------------\n        void GLCamera::Apply(GLShader* glShader) const noexcept\n        {\n            glShader->SetUniform(k_uniformCameraPos, m_position, GLShader::FailurePolicy::k_silent);\n        }\n    }\n}\n"
  },
  {
    "path": "Source/CSBackend/Rendering/OpenGL/Camera/GLCamera.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CSBACKEND_RENDERING_OPENGL_CAMERA_GLCAMERA_H_\n#define _CSBACKEND_RENDERING_OPENGL_CAMERA_GLCAMERA_H_\n\n#include <CSBackend/Rendering/OpenGL/ForwardDeclarations.h>\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Math/Matrix4.h>\n#include <ChilliSource/Core/Math/Vector3.h>\n\nnamespace CSBackend\n{\n    namespace OpenGL\n    {\n        /// Describes the state of the camera, including it's view projection matrix and the\n        /// current camera position.\n        ///\n        /// This is immutable and therefore thread-safe.\n        ///\n        class GLCamera final\n        {\n        public:\n            GLCamera() = default;\n            \n            /// Constructs the camera with the given view projection matrix and position data.\n            ///\n            /// @param position\n            ///     The world space position of the camera.\n            /// @param viewMatrix\n            ///     The view matrix (inverse transform) of the camera\n            /// @param viewProjectionMatrix\n            ///     The view projection matrix of the camera.\n            ///\n            GLCamera(const ChilliSource::Vector3& position, const ChilliSource::Matrix4& viewMatrix, const ChilliSource::Matrix4& viewProjectionMatrix) noexcept;\n            \n            /// @return The world space position of the camera.\n            ///\n            const ChilliSource::Vector3& GetPosition() const noexcept { return m_position; }\n            \n            /// @return The view matrix of the camera.\n            ///\n            const ChilliSource::Matrix4& GetViewMatrix() const noexcept { return m_viewMatrix; }\n            \n            /// @return The view projection matrix of the camera.\n            ///\n            const ChilliSource::Matrix4& GetViewProjectionMatrix() const noexcept { return m_viewProjectionMatrix; }\n            \n            /// Applies the camera to the given shader.\n            ///\n            /// This must be called on the render thread.\n            ///\n            /// @param glShader\n            ///     The shader the camera data should be applied to.\n            ///\n            void Apply(GLShader* glShader) const noexcept;\n            \n        private:\n            ChilliSource::Vector3 m_position;\n            ChilliSource::Matrix4 m_viewMatrix;\n            ChilliSource::Matrix4 m_viewProjectionMatrix;\n        };\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Rendering/OpenGL/ForwardDeclarations.h",
    "content": "//\n//  ForwardDeclarations.h\n//  ChilliSource\n//  Created by Scott Downie on 25/01/2012.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2012 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CSBACKEND_RENDERING_OPENGL_FORWARDDECLARATIONS_H_\n#define _CSBACKEND_RENDERING_OPENGL_FORWARDDECLARATIONS_H_\n\n#include <ChilliSource/Core/Base/StandardMacros.h>\n\n#include <memory>\n\nnamespace CSBackend\n{\n    namespace OpenGL\n    {\n        //----------------------------------------------------\n        /// Base\n        //----------------------------------------------------\n        CS_FORWARDDECLARE_CLASS(ContextState);\n        CS_FORWARDDECLARE_CLASS(GLContextRestorer);\n\n        CS_FORWARDDECLARE_CLASS(RenderCapabilities);\n        CS_FORWARDDECLARE_CLASS(RenderCommandProcessor);\n        //----------------------------------------------------\n        /// Camera\n        //----------------------------------------------------\n        CS_FORWARDDECLARE_CLASS(GLCamera);\n        //----------------------------------------------------\n        /// Lighting\n        //----------------------------------------------------\n        CS_FORWARDDECLARE_CLASS(GLAmbientLight);\n        CS_FORWARDDECLARE_CLASS(GLDirectionalLight);\n        CS_FORWARDDECLARE_CLASS(GLLight);\n        CS_FORWARDDECLARE_CLASS(GLPointLight);\n        //----------------------------------------------------\n        /// Model\n        //----------------------------------------------------\n        CS_FORWARDDECLARE_CLASS(GLMesh);\n        CS_FORWARDDECLARE_CLASS(GLDynamicMesh);\n        //----------------------------------------------------\n        /// Shader\n        //----------------------------------------------------\n        CS_FORWARDDECLARE_CLASS(GLShader);\n        //----------------------------------------------------\n        /// Target\n        //----------------------------------------------------\n        CS_FORWARDDECLARE_CLASS(GLTargetGroup);\n        //----------------------------------------------------\n        /// Texture\n        //----------------------------------------------------\n        CS_FORWARDDECLARE_CLASS(GLCubemap);\n        CS_FORWARDDECLARE_CLASS(GLTexture);\n        CS_FORWARDDECLARE_CLASS(GLTextureUnitManager);\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Rendering/OpenGL/Lighting/GLAmbientLight.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <CSBackend/Rendering/OpenGL/Lighting/GLAmbientLight.h>\n\n#include <CSBackend/Rendering/OpenGL/Shader/GLShader.h>\n\nnamespace CSBackend\n{\n    namespace OpenGL\n    {\n        namespace\n        {\n            const std::string k_uniformLightCol = \"u_lightCol\";\n        }\n        \n        //------------------------------------------------------------------------------\n        GLAmbientLight::GLAmbientLight(const ChilliSource::Colour& colour) noexcept\n            : m_colour(colour)\n        {\n        }\n            \n        //------------------------------------------------------------------------------\n        void GLAmbientLight::Apply(GLShader* glShader, GLTextureUnitManager* glTextureUnitManager) const noexcept\n        {\n            glShader->SetUniform(k_uniformLightCol, m_colour, GLShader::FailurePolicy::k_silent);\n        }\n    }\n}\n"
  },
  {
    "path": "Source/CSBackend/Rendering/OpenGL/Lighting/GLAmbientLight.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CSBACKEND_RENDERING_OPENGL_LIGHTING_GLAMBIENTLIGHT_H_\n#define _CSBACKEND_RENDERING_OPENGL_LIGHTING_GLAMBIENTLIGHT_H_\n\n#include <CSBackend/Rendering/OpenGL/ForwardDeclarations.h>\n#include <CSBackend/Rendering/OpenGL/Lighting/GLLight.h>\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Base/Colour.h>\n\nnamespace CSBackend\n{\n    namespace OpenGL\n    {\n        /// The ambient OpenGL light object, which stores the ambient light colour and provides\n        /// the means to apply this colour to a shader.\n        ///\n        /// This is immutable and therefore thread-safe, but apply must be called on the render\n        /// thread.\n        ///\n        class GLAmbientLight final : public GLLight\n        {\n        public:\n            /// Creates a new instance with the given colour.\n            ///\n            /// @param colour\n            ///     The ambient light colour.\n            ///\n            GLAmbientLight(const ChilliSource::Colour& colour) noexcept;\n            \n            /// Applies the light to the given shader.\n            ///\n            /// This must be called on the render thread.\n            ///\n            /// @param glShader\n            ///     The shader the light data should be applied to.\n            /// @param glTextureUnitManager\n            ///     The texture unit manager which can be used to bind additional textures required by a light\n            ///     such as a shadow map.\n            ///\n            void Apply(GLShader* glShader, GLTextureUnitManager* glTextureUnitManager) const noexcept override;\n            \n        private:\n            ChilliSource::Colour m_colour;\n        };\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Rendering/OpenGL/Lighting/GLDirectionalLight.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <CSBackend/Rendering/OpenGL/Lighting/GLDirectionalLight.h>\n\n#include <CSBackend/Rendering/OpenGL/Shader/GLShader.h>\n#include <CSBackend/Rendering/OpenGL/Texture/GLTextureUnitManager.h>\n\nnamespace CSBackend\n{\n    namespace OpenGL\n    {\n        namespace\n        {\n            const std::string k_uniformLightCol = \"u_lightCol\";\n            const std::string k_uniformLightDir = \"u_lightDir\";\n            const std::string k_uniformShadowMap = \"u_shadowMap\";\n            const std::string k_uniformShadowTolerance = \"u_shadowTolerance\";\n            const std::string k_uniformLightMat = \"u_lightMat\";\n        }\n        \n        //------------------------------------------------------------------------------\n        GLDirectionalLight::GLDirectionalLight(const ChilliSource::Colour& colour, const ChilliSource::Vector3& direction, const ChilliSource::Matrix4& lightViewProjection, f32 shadowTolerance,\n                                               const ChilliSource::RenderTexture* shadowMapRenderTexture) noexcept\n            : m_colour(colour), m_direction(direction), m_lightViewProjection(lightViewProjection), m_shadowTolerance(shadowTolerance), m_shadowMapRenderTexture(shadowMapRenderTexture)\n        {\n        }\n            \n        //------------------------------------------------------------------------------\n        void GLDirectionalLight::Apply(GLShader* glShader, GLTextureUnitManager* glTextureUnitManager) const noexcept\n        {\n            glShader->SetUniform(k_uniformLightCol, m_colour, GLShader::FailurePolicy::k_silent);\n            glShader->SetUniform(k_uniformLightDir, m_direction, GLShader::FailurePolicy::k_silent);\n            \n            if (m_shadowMapRenderTexture)\n            {\n                auto texUnit = glTextureUnitManager->BindAdditional(GL_TEXTURE_2D, m_shadowMapRenderTexture);\n                \n                glShader->SetUniform(k_uniformShadowMap, s32(texUnit), GLShader::FailurePolicy::k_silent);\n                glShader->SetUniform(k_uniformShadowTolerance, m_shadowTolerance, GLShader::FailurePolicy::k_silent);\n                glShader->SetUniform(k_uniformLightMat, m_lightViewProjection, GLShader::FailurePolicy::k_silent);\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "Source/CSBackend/Rendering/OpenGL/Lighting/GLDirectionalLight.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CSBACKEND_RENDERING_OPENGL_LIGHTING_GLDIRECTIONALLIGHT_H_\n#define _CSBACKEND_RENDERING_OPENGL_LIGHTING_GLDIRECTIONALLIGHT_H_\n\n#include <CSBackend/Rendering/OpenGL/ForwardDeclarations.h>\n#include <CSBackend/Rendering/OpenGL/Lighting/GLLight.h>\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Base/Colour.h>\n#include <ChilliSource/Core/Math/Matrix4.h>\n#include <ChilliSource/Core/Math/Vector3.h>\n\nnamespace CSBackend\n{\n    namespace OpenGL\n    {\n        /// The directional OpenGL light object, which stores the direction light data and provides\n        /// the means to apply the data to a shader.\n        ///\n        /// This is immutable and therefore thread-safe, but apply must be called on the render\n        /// thread.\n        ///\n        class GLDirectionalLight final : public GLLight\n        {\n        public:\n            /// Creates a new instance with the given directional light information. \n            ///\n            /// @param colour\n            ///     The colour of the light.\n            /// @param direction\n            ///     The direction of the light.\n            /// @param lightViewProjection\n            ///     The view projection matrix of the light which is used as the camera when rendering\n            ///     the shadow map.\n            /// @param shadowTolerance\n            ///     The tolerence used to judge if an object is in shadow.\n            /// @param shadowMapRenderTexture\n            ///     The render texture which should be used for the shadow map. Can be null if there is no\n            ///     shadow map.\n            ///\n            GLDirectionalLight(const ChilliSource::Colour& colour, const ChilliSource::Vector3& direction, const ChilliSource::Matrix4& lightViewProjection, f32 shadowTolerance,\n                               const ChilliSource::RenderTexture* shadowMapRenderTexture) noexcept;\n            \n            /// Applies the light to the given shader.\n            ///\n            /// This must be called on the render thread.\n            ///\n            /// @param glShader\n            ///     The shader the light data should be applied to.\n            /// @param glTextureUnitManager\n            ///     The texture unit manager which can be used to bind additional textures required by a light\n            ///     such as a shadow map.\n            ///\n            void Apply(GLShader* glShader, GLTextureUnitManager* glTextureUnitManager) const noexcept override;\n            \n        private:\n            ChilliSource::Colour m_colour;\n            ChilliSource::Vector3 m_direction;\n            ChilliSource::Matrix4 m_lightViewProjection;\n            f32 m_shadowTolerance;\n            const ChilliSource::RenderTexture* m_shadowMapRenderTexture;\n        };\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Rendering/OpenGL/Lighting/GLLight.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CSBACKEND_RENDERING_OPENGL_LIGHTING_GLLIGHT_H_\n#define _CSBACKEND_RENDERING_OPENGL_LIGHTING_GLLIGHT_H_\n\n#include <CSBackend/Rendering/OpenGL/ForwardDeclarations.h>\n\n#include <ChilliSource/ChilliSource.h>\n\nnamespace CSBackend\n{\n    namespace OpenGL\n    {\n        /// The base class for all OpenGL light objects. This is used to apply the appropriate\n        /// lighting data to the active shader.\n        ///\n        /// The underlying light object should be immutable and therefore thread-safe, but apply\n        /// must be called on the render thread.\n        ///\n        class GLLight\n        {\n        public:\n            /// Applies the light to the given shader.\n            ///\n            /// This must be called on the render thread.\n            ///\n            /// @param glShader\n            ///     The shader the light data should be applied to.\n            /// @param glTextureUnitManager\n            ///     The texture unit manager which can be used to bind additional textures required by a light\n            ///     such as a shadow map.\n            ///\n            virtual void Apply(GLShader* glShader, GLTextureUnitManager* glTextureUnitManager) const noexcept = 0;\n            \n            virtual ~GLLight() {}\n        };\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Rendering/OpenGL/Lighting/GLPointLight.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <CSBackend/Rendering/OpenGL/Lighting/GLPointLight.h>\n\n#include <CSBackend/Rendering/OpenGL/Shader/GLShader.h>\n\nnamespace CSBackend\n{\n    namespace OpenGL\n    {\n        namespace\n        {\n            const std::string k_uniformLightCol = \"u_lightCol\";\n            const std::string k_uniformLightPos = \"u_lightPos\";\n            const std::string k_uniformAttenuationConstant = \"u_attenuationConstant\";\n            const std::string k_uniformAttenuationLinear = \"u_attenuationLinear\";\n            const std::string k_uniformAttenuationQuadratic = \"u_attenuationQuadratic\";\n        }\n        \n        //------------------------------------------------------------------------------\n        GLPointLight::GLPointLight(const ChilliSource::Colour& colour, const ChilliSource::Vector3& position, const ChilliSource::Vector3& attenuation) noexcept\n            : m_colour(colour), m_position(position), m_attenuation(attenuation)\n        {\n        }\n        \n        //------------------------------------------------------------------------------\n        void GLPointLight::Apply(GLShader* glShader, GLTextureUnitManager* glTextureUnitManager) const noexcept\n        {\n            glShader->SetUniform(k_uniformLightCol, m_colour, GLShader::FailurePolicy::k_silent);\n            glShader->SetUniform(k_uniformLightPos, m_position, GLShader::FailurePolicy::k_silent);\n            glShader->SetUniform(k_uniformAttenuationConstant, m_attenuation.x, GLShader::FailurePolicy::k_silent);\n            glShader->SetUniform(k_uniformAttenuationLinear, m_attenuation.y, GLShader::FailurePolicy::k_silent);\n            glShader->SetUniform(k_uniformAttenuationQuadratic, m_attenuation.z, GLShader::FailurePolicy::k_silent);\n        }\n    }\n}\n"
  },
  {
    "path": "Source/CSBackend/Rendering/OpenGL/Lighting/GLPointLight.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CSBACKEND_RENDERING_OPENGL_LIGHTING_GLPOINTLIGHT_H_\n#define _CSBACKEND_RENDERING_OPENGL_LIGHTING_GLPOINTLIGHT_H_\n\n#include <CSBackend/Rendering/OpenGL/ForwardDeclarations.h>\n#include <CSBackend/Rendering/OpenGL/Lighting/GLLight.h>\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Base/Colour.h>\n#include <ChilliSource/Core/Math/Vector3.h>\n\nnamespace CSBackend\n{\n    namespace OpenGL\n    {\n        /// The point OpenGL light object, which stores the point light data and provides the means\n        /// to apply the data to a shader.\n        ///\n        /// This is immutable and therefore thread-safe, but apply must be called on the render\n        /// thread.\n        ///\n        class GLPointLight final : public GLLight\n        {\n        public:\n            /// Creates a new instance with the given directional light information.\n            ///\n            /// @param colour\n            ///     The colour of the light.\n            /// @param position\n            ///     The position of the light.\n            /// @param attenuation\n            ///     The vector containing the constant, linear and quadratic attenuation values of the\n            ///     light.\n            ///\n            GLPointLight(const ChilliSource::Colour& colour, const ChilliSource::Vector3& position, const ChilliSource::Vector3& attenuation) noexcept;\n            \n            /// Applies the light to the given shader.\n            ///\n            /// This must be called on the render thread.\n            ///\n            /// @param glShader\n            ///     The shader the light data should be applied to.\n            /// @param glTextureUnitManager\n            ///     The texture unit manager which can be used to bind additional textures required by a light\n            ///     such as a shadow map.\n            ///\n            void Apply(GLShader* glShader, GLTextureUnitManager* glTextureUnitManager) const noexcept override;\n            \n        private:\n            ChilliSource::Colour m_colour;\n            ChilliSource::Vector3 m_position;\n            ChilliSource::Vector3 m_attenuation;\n        };\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Rendering/OpenGL/Material/GLMaterial.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <CSBackend/Rendering/OpenGL/Material/GLMaterial.h>\n\n#include <CSBackend/Rendering/OpenGL/Camera/GLCamera.h>\n#include <CSBackend/Rendering/OpenGL/Shader/GLShader.h>\n\n#include <ChilliSource/Core/Base/Colour.h>\n#include <ChilliSource/Rendering/Base/BlendMode.h>\n#include <ChilliSource/Rendering/Base/CullFace.h>\n#include <ChilliSource/Rendering/Base/StencilOp.h>\n#include <ChilliSource/Rendering/Base/TestFunc.h>\n#include <ChilliSource/Rendering/Material/RenderMaterial.h>\n\nnamespace CSBackend\n{\n    namespace OpenGL\n    {\n        namespace\n        {\n            const std::string k_uniformEmissive = \"u_emissive\";\n            const std::string k_uniformAmbient = \"u_ambient\";\n            const std::string k_uniformDiffuse = \"u_diffuse\";\n            const std::string k_uniformSpecular = \"u_specular\";\n            const std::string k_uniformTexturePrefix = \"u_texture\";\n            const std::string k_uniformCubemapPrefix = \"u_cubemap\";\n            \n            /// Converts from a ChilliSource blend mode to an OpenGL blend mode.\n            ///\n            /// @param blendMode\n            ///     The ChilliSource blend mode.\n            ///\n            /// @return The OpenGL blend mode.\n            ///\n            GLenum ToGLBlendMode(ChilliSource::BlendMode blendMode)\n            {\n                switch(blendMode)\n                {\n                    case ChilliSource::BlendMode::k_zero:\n                        return GL_ZERO;\n                    case ChilliSource::BlendMode::k_one:\n                        return GL_ONE;\n                    case ChilliSource::BlendMode::k_sourceCol:\n                        return GL_SRC_COLOR;\n                    case ChilliSource::BlendMode::k_oneMinusSourceCol:\n                        return GL_ONE_MINUS_SRC_COLOR;\n                    case ChilliSource::BlendMode::k_sourceAlpha:\n                        return GL_SRC_ALPHA;\n                    case ChilliSource::BlendMode::k_oneMinusSourceAlpha:\n                        return GL_ONE_MINUS_SRC_ALPHA;\n                    case ChilliSource::BlendMode::k_destCol:\n                        return GL_DST_COLOR;\n                    case ChilliSource::BlendMode::k_oneMinusDestCol:\n                        return GL_ONE_MINUS_DST_COLOR;\n                    case ChilliSource::BlendMode::k_destAlpha:\n                        return GL_DST_ALPHA;\n                    case ChilliSource::BlendMode::k_oneMinusDestAlpha:\n                        return GL_ONE_MINUS_DST_ALPHA;\n                    default:\n                        CS_LOG_FATAL(\"Invalid blend mode.\");\n                        return GL_ZERO;\n                };\n            }\n            \n            /// Converts from a ChilliSource stencil op to an OpenGL one\n            ///\n            /// @param stencilOp\n            ///     The ChilliSource stencil op\n            ///\n            /// @return The OpenGL stencil op.\n            ///\n            GLenum ToGLStencilOp(ChilliSource::StencilOp stencilOp)\n            {\n                switch(stencilOp)\n                {\n                    case ChilliSource::StencilOp::k_keep:\n                        return GL_KEEP;\n                    case ChilliSource::StencilOp::k_zero:\n                        return GL_ZERO;\n                    case ChilliSource::StencilOp::k_replace:\n                        return GL_REPLACE;\n                    case ChilliSource::StencilOp::k_increment:\n                        return GL_INCR;\n                    case ChilliSource::StencilOp::k_incrementWrap:\n                        return GL_INCR_WRAP;\n                    case ChilliSource::StencilOp::k_decrement:\n                        return GL_DECR;\n                    case ChilliSource::StencilOp::k_decrementWrap:\n                        return GL_DECR_WRAP;\n                    case ChilliSource::StencilOp::k_invert:\n                        return GL_INVERT;\n                    default:\n                        CS_LOG_FATAL(\"Invalid stencil op.\");\n                        return GL_KEEP;\n                };\n            }\n            \n            /// Converts from a ChilliSource test func to an OpenGL one\n            ///\n            /// @param testFunc\n            ///     The ChilliSource test func\n            ///\n            /// @return The OpenGL test func.\n            ///\n            GLenum ToGLTestFunc(ChilliSource::TestFunc testFunc)\n            {\n                switch(testFunc)\n                {\n                    case ChilliSource::TestFunc::k_never:\n                        return GL_NEVER;\n                    case ChilliSource::TestFunc::k_less:\n                        return GL_LESS;\n                    case ChilliSource::TestFunc::k_lessEqual:\n                        return GL_LEQUAL;\n                    case ChilliSource::TestFunc::k_greater:\n                        return GL_GREATER;\n                    case ChilliSource::TestFunc::k_greaterEqual:\n                        return GL_GEQUAL;\n                    case ChilliSource::TestFunc::k_equal:\n                        return GL_EQUAL;\n                    case ChilliSource::TestFunc::k_notEqual:\n                        return GL_NOTEQUAL;\n                    case ChilliSource::TestFunc::k_always:\n                        return GL_ALWAYS;\n                    default:\n                        CS_LOG_FATAL(\"Invalid test func.\");\n                        return GL_ALWAYS;\n                };\n            }\n            \n            /// Converts from a ChilliSource cull face to an OpenGL one\n            ///\n            /// @param cullFace\n            ///     The ChilliSource cull face\n            ///\n            /// @return The OpenGL cull face.\n            ///\n            GLenum ToGLCullFace(ChilliSource::CullFace cullFace)\n            {\n                switch(cullFace)\n                {\n                    case ChilliSource::CullFace::k_front:\n                        return GL_FRONT;\n                    case ChilliSource::CullFace::k_back:\n                        return GL_BACK;\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tCS_LOG_FATAL(\"Invalid cull face.\");\n\t\t\t\t\t\treturn GL_BACK;\n                }\n            }\n            \n            /// Applies the given batch of custom shader variables to the given shader. If\n            /// any of the variables do not exist in the shader, this will assert.\n            ///\n            /// @param renderShaderVariables\n            ///     The shader variables to apply.\n            /// @param glShader\n            ///     The shader to apply the variables to.\n            ///\n            void ApplyCustomShaderVariables(const ChilliSource::RenderShaderVariables* renderShaderVariables, GLShader* glShader) noexcept\n            {\n                CS_ASSERT(renderShaderVariables, \"Cannot apply null shader variables.\");\n                CS_ASSERT(glShader, \"Cannot apply shader variables to null shader.\");\n                \n                for (const auto& pair : renderShaderVariables->GetFloatVariables())\n                {\n                    glShader->SetUniform(pair.first, pair.second);\n                }\n                \n                for (const auto& pair : renderShaderVariables->GetVector2Variables())\n                {\n                    glShader->SetUniform(pair.first, pair.second);\n                }\n                \n                for (const auto& pair : renderShaderVariables->GetVector3Variables())\n                {\n                    glShader->SetUniform(pair.first, pair.second);\n                }\n                \n                for (const auto& pair : renderShaderVariables->GetVector4Variables())\n                {\n                    glShader->SetUniform(pair.first, pair.second);\n                }\n                \n                for (const auto& pair : renderShaderVariables->GetMatrix4Variables())\n                {\n                    glShader->SetUniform(pair.first, pair.second);\n                }\n                \n                for (const auto& pair : renderShaderVariables->GetColourVariables())\n                {\n                    glShader->SetUniform(pair.first, pair.second);\n                }\n            }\n        }\n        \n        //------------------------------------------------------------------------------\n        void GLMaterial::Apply(const ChilliSource::RenderMaterial* renderMaterial, GLShader* glShader) noexcept\n        {\n            renderMaterial->IsDepthWriteEnabled() ? glDepthMask(GL_TRUE) : glDepthMask(GL_FALSE);\n            renderMaterial->IsColourWriteEnabled() ? glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE) : glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);\n\n            if(renderMaterial->IsDepthTestEnabled())\n            {\n                glEnable(GL_DEPTH_TEST);\n                glDepthFunc(ToGLTestFunc(renderMaterial->GetDepthTestFunc()));\n            }\n            else\n            {\n                glDisable(GL_DEPTH_TEST);\n            }\n            \n            if (renderMaterial->IsFaceCullingEnabled())\n            {\n                glEnable(GL_CULL_FACE);\n                glCullFace(ToGLCullFace(renderMaterial->GetCullFace()));\n            }\n            else\n            {\n                glDisable(GL_CULL_FACE);\n            }\n            \n            if (renderMaterial->IsTransparencyEnabled())\n            {\n                glEnable(GL_BLEND);\n                glBlendFunc(ToGLBlendMode(renderMaterial->GetSourceBlendMode()), ToGLBlendMode(renderMaterial->GetDestinationBlendMode()));\n            }\n            else\n            {\n                glDisable(GL_BLEND);\n            }\n            \n            if(renderMaterial->IsStencilTestEnabled())\n            {\n                glEnable(GL_STENCIL_TEST);\n                glStencilOp(ToGLStencilOp(renderMaterial->GetStencilFailOp()), ToGLStencilOp(renderMaterial->GetStencilDepthFailOp()), ToGLStencilOp(renderMaterial->GetStencilPassOp()));\n                glStencilFunc(ToGLTestFunc(renderMaterial->GetStencilTestFunc()), (GLint)renderMaterial->GetStencilTestFuncRef(), (GLuint)renderMaterial->GetStencilTestFuncMask());\n            }\n            else\n            {\n                glDisable(GL_STENCIL_TEST);\n            }\n            \n            s32 samplerNumber = 0;\n            \n            for (std::size_t i = 0; i < renderMaterial->GetRenderTextures2D().size(); ++i, ++samplerNumber)\n            {\n                glShader->SetUniform(k_uniformTexturePrefix + ChilliSource::ToString(i), samplerNumber);\n            }\n            \n            for (std::size_t i = 0; i < renderMaterial->GetRenderTexturesCubemap().size(); ++i, ++samplerNumber)\n            {\n                glShader->SetUniform(k_uniformCubemapPrefix + ChilliSource::ToString(i), samplerNumber);\n            }\n            \n            glShader->SetUniform(k_uniformEmissive, renderMaterial->GetEmissiveColour(), GLShader::FailurePolicy::k_silent);\n            glShader->SetUniform(k_uniformAmbient, renderMaterial->GetAmbientColour(), GLShader::FailurePolicy::k_silent);\n            glShader->SetUniform(k_uniformDiffuse, renderMaterial->GetDiffuseColour(), GLShader::FailurePolicy::k_silent);\n            glShader->SetUniform(k_uniformSpecular, renderMaterial->GetSpecularColour(), GLShader::FailurePolicy::k_silent);\n            \n            if (renderMaterial->GetRenderShaderVariables())\n            {\n                ApplyCustomShaderVariables(renderMaterial->GetRenderShaderVariables(), glShader);\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "Source/CSBackend/Rendering/OpenGL/Material/GLMaterial.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CSBACKEND_RENDERING_OPENGL_MATERIAL_GLMATERIAL_H_\n#define _CSBACKEND_RENDERING_OPENGL_MATERIAL_GLMATERIAL_H_\n\n#include <CSBackend/Rendering/OpenGL/ForwardDeclarations.h>\n#include <CSBackend/Rendering/OpenGL/Base/GLIncludes.h>\n\n#include <ChilliSource/ChilliSource.h>\n\nnamespace CSBackend\n{\n    namespace OpenGL\n    {\n        /// A container for all functionality pertaining to materials in OpenGL.\n        ///\n        namespace GLMaterial\n        {\n            /// Applys the state described by the given RenderMaterial to the OpenGL context.\n            ///\n            /// @param renderMaterial\n            ///     The render material to apply.\n            /// @param glShader\n            ///     The currently active shader to apply uniforms to.\n            ///\n            void Apply(const ChilliSource::RenderMaterial* renderMaterial, GLShader* glShader) noexcept;\n        };\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Rendering/OpenGL/Model/GLDynamicMesh.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <CSBackend/Rendering/OpenGL/Model/GLDynamicMesh.h>\n\n#include <CSBackend/Rendering/OpenGL/Base/GLExtensions.h>\n#include <CSBackend/Rendering/OpenGL/Base/GLError.h>\n#include <CSBackend/Rendering/OpenGL/Model/GLMeshUtils.h>\n#include <CSBackend/Rendering/OpenGL/Shader/GLShader.h>\n\n#include <ChilliSource/Core/Base/ByteColour.h>\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/Memory/UniquePtr.h>\n#include <ChilliSource/Rendering/Model/RenderDynamicMesh.h>\n#include <ChilliSource/Rendering/Model/VertexFormat.h>\n#include <ChilliSource/Rendering/Base/RenderCapabilities.h>\n\nnamespace CSBackend\n{\n    namespace OpenGL\n    {\n        namespace\n        {\n            constexpr u32 k_allocatorSize = ChilliSource::RenderDynamicMesh::k_maxVertexDataSize;\n            \n            /// Applies each of the sprite meshes' vertices to the combined mesh batch vertex buffer. The vertices\n            /// are converted into world space before being added to the new buffer. The vertex data is applied to\n            /// the currently bound vertex buffer.\n            ///\n            /// This version makes use of the map buffer extension which means the data can be copied straight to GL without an additional copy being made\n            ///\n            /// @param numVertices\n            ///     The total number of vertices in the batch.\n            /// @param vertexDataSize\n            ///     The total vertex data size of the batch.\n            /// @param meshes\n            ///     The meshes which should be added to the batch.\n            ///\n            void ApplySpriteBatchVerticesMapBuffer(u32 numVertices, u32 vertexDataSize, const std::vector<ChilliSource::RenderMeshBatch::Mesh>& meshes) noexcept\n            {\n                CS_ASSERT(numVertices * ChilliSource::VertexFormat::k_sprite.GetSize() == vertexDataSize, \"Vertex data size and number of vertices is out of sync.\");\n                CS_ASSERT(!meshes.empty(), \"Batch must contain at least one mesh.\");\n                \n                glBufferData(GL_ARRAY_BUFFER, vertexDataSize, nullptr, GL_DYNAMIC_DRAW);\n                auto combinedVertices = static_cast<ChilliSource::SpriteVertex*>(glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY));\n\n                u32 vertexOffset = 0;\n                for (const auto& mesh : meshes)\n                {\n                    auto meshVertices = reinterpret_cast<const ChilliSource::SpriteVertex*>(mesh.GetVertexData());\n                    \n                    for (u32 i = 0; i < mesh.GetNumVertices(); ++i)\n                    {\n                        combinedVertices[vertexOffset + i] = meshVertices[i];\n                        combinedVertices[vertexOffset + i].m_position *= mesh.GetWorldMatrix();\n                    }\n                    \n                    vertexOffset += mesh.GetNumVertices();\n                }\n                \n                glUnmapBuffer(GL_ARRAY_BUFFER);\n            }\n            \n            /// Applies each of the sprite meshes' vertices to the combined mesh batch vertex buffer. The vertices\n            /// are converted into world space before being added to the new buffer. The vertex data is applied to\n            /// the currently bound vertex buffer.\n            ///\n            /// This version is used when map buffer is unavailable and will copy the data to a temp buffer that is then\n            /// uploaded to GL\n            ///\n            /// @param allocator\n            ///     The allocator which should be used to generate the temporary buffer. Note that the allocator\n            ///     will be reset, meaning it should have no other active allocations.\n            /// @param numVertices\n            ///     The total number of vertices in the batch.\n            /// @param vertexDataSize\n            ///     The total vertex data size of the batch.\n            /// @param meshes\n            ///     The meshes which should be added to the batch.\n            ///\n            void ApplySpriteBatchVertices(ChilliSource::LinearAllocator& allocator, u32 numVertices, u32 vertexDataSize, const std::vector<ChilliSource::RenderMeshBatch::Mesh>& meshes) noexcept\n            {\n                CS_ASSERT(numVertices * ChilliSource::VertexFormat::k_sprite.GetSize() == vertexDataSize, \"Vertex data size and number of vertices is out of sync.\");\n                CS_ASSERT(!meshes.empty(), \"Batch must contain at least one mesh.\");\n                \n                auto combinedVertices = ChilliSource::MakeUniqueArray<ChilliSource::SpriteVertex>(allocator, numVertices);\n                \n                u32 vertexOffset = 0;\n                for (const auto& mesh : meshes)\n                {\n                    auto meshVertices = reinterpret_cast<const ChilliSource::SpriteVertex*>(mesh.GetVertexData());\n                    \n                    for (u32 i = 0; i < mesh.GetNumVertices(); ++i)\n                    {\n                        combinedVertices[vertexOffset + i] = meshVertices[i];\n                        combinedVertices[vertexOffset + i].m_position *= mesh.GetWorldMatrix();\n                    }\n                    \n                    vertexOffset += mesh.GetNumVertices();\n                }\n\n                glBufferData(GL_ARRAY_BUFFER, vertexDataSize, reinterpret_cast<const u8*>(combinedVertices.get()), GL_DYNAMIC_DRAW);\n\n                combinedVertices.reset();\n                allocator.Reset();\n            }\n            \n            /// Applies each of the meshes' vertices to the combined mesh batch vertex buffer. The vertices are\n            /// converted into world space before being added to the new buffer. The vertex data is applied to\n            /// the currently bound vertex buffer.\n            ///\n            /// @param allocator\n            ///     The allocator which should be used to generate the temporary buffer. Note that the allocator\n            ///     will be reset, meaning it should have no other active allocations.\n            /// @param vertexFormat\n            ///     The vertex format of the batch.\n            /// @param numVertices\n            ///     The total number of vertices in the batch.\n            /// @param vertexDataSize\n            ///     The total vertex data size of the batch.\n            /// @param meshes\n            ///     The meshes which should be added to the batch.\n            /// @param useMapBuffer\n            ///     If the hardware supports it we can use map buffer to eliminate a copy\n            ///\n            void ApplyBatchVertices(ChilliSource::LinearAllocator& allocator, const ChilliSource::VertexFormat& vertexFormat, u32 numVertices, u32 vertexDataSize,\n                               const std::vector<ChilliSource::RenderMeshBatch::Mesh>& meshes, bool useMapBuffer) noexcept\n            {\n                //TODO: Add support for static mesh vertex formats\n                if (vertexFormat == ChilliSource::VertexFormat::k_sprite)\n                {\n                    useMapBuffer ? ApplySpriteBatchVerticesMapBuffer(numVertices, vertexDataSize, meshes) : ApplySpriteBatchVertices(allocator, numVertices, vertexDataSize, meshes);\n                }\n                else\n                {\n                    CS_LOG_FATAL(\"Unsupported vertex format.\");\n                }\n            }\n            \n            /// Applies each of the meshes' indices to the combined mesh batch index buffer. The indices are\n            /// updated to reflect the new position of the vertices in the combined vertex buffer. The index\n            /// data is applied to the currently bound index buffer.\n            ///\n            /// This version makes use of the map buffer extension which means the data can be copied straight to GL without an additional copy being made\n            ///\n            /// @param indexFormat\n            ///     The format of the indices. Currently only short indices are supported.\n            /// @param numIndices\n            ///     The total number of indices in the batch.\n            /// @param indexDataSize\n            ///     The total index data size of the batch.\n            /// @param meshes\n            ///     The list of meshes which should be batched.\n            ///\n            void ApplyBatchIndicesMapBuffer(ChilliSource::IndexFormat indexFormat, u32 numIndices, u32 indexDataSize,\n                              const std::vector<ChilliSource::RenderMeshBatch::Mesh>& meshes) noexcept\n            {\n                CS_ASSERT(indexFormat == ChilliSource::IndexFormat::k_short, \"Only short indices are supported at the moment.\");\n                CS_ASSERT(numIndices * ChilliSource::GetIndexSize(indexFormat) == indexDataSize, \"Index data size and number of indices is out of sync.\");\n                CS_ASSERT(!meshes.empty(), \"Batch must contain at least one mesh.\");\n                \n                glBufferData(GL_ELEMENT_ARRAY_BUFFER, indexDataSize, nullptr, GL_DYNAMIC_DRAW);\n                auto combinedIndices = static_cast<u16*>(glMapBuffer(GL_ELEMENT_ARRAY_BUFFER, GL_WRITE_ONLY));\n                \n                u32 vertexOffset = 0;\n                u32 indexOffset = 0;\n                for (const auto& mesh : meshes)\n                {\n                    auto meshIndices = reinterpret_cast<const u16*>(mesh.GetIndexData());\n                    \n                    for (u32 i = 0; i < mesh.GetNumIndices(); ++i)\n                    {\n                        combinedIndices[indexOffset + i] = vertexOffset + meshIndices[i];\n                    }\n                    \n                    vertexOffset += mesh.GetNumVertices();\n                    indexOffset += mesh.GetNumIndices();\n                }\n                \n                glUnmapBuffer(GL_ELEMENT_ARRAY_BUFFER);\n            }\n            \n            /// Applies each of the meshes' indices to the combined mesh batch index buffer. The indices are\n            /// updated to reflect the new position of the vertices in the combined vertex buffer. The index\n            /// data is applied to the currently bound index buffer.\n            ///\n            /// Used when map buffer is unavailable. The temporary buffer is allocated from the given linear allocator.\n            ///\n            /// @param allocator\n            ///     The allocator which should be used to generate the temporary buffer. Note that the allocator\n            ///     will be reset, meaning it should have no other active allocations.\n            /// @param indexFormat\n            ///     The format of the indices. Currently only short indices are supported.\n            /// @param numIndices\n            ///     The total number of indices in the batch.\n            /// @param indexDataSize\n            ///     The total index data size of the batch.\n            /// @param meshes\n            ///     The list of meshes which should be batched.\n            ///\n            void ApplyBatchIndices(ChilliSource::LinearAllocator& allocator, ChilliSource::IndexFormat indexFormat, u32 numIndices, u32 indexDataSize,\n                                   const std::vector<ChilliSource::RenderMeshBatch::Mesh>& meshes) noexcept\n            {\n                CS_ASSERT(indexFormat == ChilliSource::IndexFormat::k_short, \"Only short indices are supported at the moment.\");\n                CS_ASSERT(numIndices * ChilliSource::GetIndexSize(indexFormat) == indexDataSize, \"Index data size and number of indices is out of sync.\");\n                CS_ASSERT(!meshes.empty(), \"Batch must contain at least one mesh.\");\n                \n                auto combinedIndices = ChilliSource::MakeUniqueArray<u16>(allocator, numIndices);\n                \n                u32 vertexOffset = 0;\n                u32 indexOffset = 0;\n                for (const auto& mesh : meshes)\n                {\n                    auto meshIndices = reinterpret_cast<const u16*>(mesh.GetIndexData());\n                    \n                    for (u32 i = 0; i < mesh.GetNumIndices(); ++i)\n                    {\n                        combinedIndices[indexOffset + i] = vertexOffset + meshIndices[i];\n                    }\n                    \n                    vertexOffset += mesh.GetNumVertices();\n                    indexOffset += mesh.GetNumIndices();\n                }\n                \n                glBufferData(GL_ELEMENT_ARRAY_BUFFER, indexDataSize, reinterpret_cast<const u8*>(combinedIndices.get()), GL_DYNAMIC_DRAW);\n\n                combinedIndices.reset();\n                allocator.Reset();\n            }\n        }\n        \n        //------------------------------------------------------------------------------\n        GLDynamicMesh::GLDynamicMesh(u32 vertexDataSize, u32 indexDataSize) noexcept\n           : m_allocator(k_allocatorSize), m_maxVertexDataSize(vertexDataSize), m_maxIndexDataSize(indexDataSize)\n        {\n            for(u32 i=0; i<k_numBuffers; ++i)\n            {\n                glGenBuffers(1, &m_vertexBufferHandles[i]);\n                CS_ASSERT(m_vertexBufferHandles[i] != 0, \"Invalid vertex buffer.\");\n                \n                if(indexDataSize > 0)\n                {\n                    glGenBuffers(1, &m_indexBufferHandles[i]);\n                    CS_ASSERT(m_indexBufferHandles[i] != 0, \"Invalid index buffer.\");\n                }\n                \n                glBindBuffer(GL_ARRAY_BUFFER, m_vertexBufferHandles[i]);\n                glBufferData(GL_ARRAY_BUFFER, m_maxVertexDataSize, nullptr, GL_DYNAMIC_DRAW);\n                \n                if(indexDataSize > 0)\n                {\n                    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_indexBufferHandles[i]);\n                    glBufferData(GL_ELEMENT_ARRAY_BUFFER, m_maxIndexDataSize, nullptr, GL_DYNAMIC_DRAW);\n                }\n            }\n            \n            CS_ASSERT_NOGLERROR(\"An OpenGL error occurred while creating GLDynamicMesh.\");\n            \n            auto renderCapabilities = ChilliSource::Application::Get()->GetSystem<ChilliSource::RenderCapabilities>();\n            m_maxVertexAttributes = renderCapabilities->GetNumVertexAttributes();\n            m_useMapBuffer = renderCapabilities->IsMapBufferSupported();\n            m_areVAOsSupported = renderCapabilities->IsVAOSupported();\n        }\n        \n        //------------------------------------------------------------------------------\n        void GLDynamicMesh::Bind(GLShader* glShader, ChilliSource::PolygonType polygonType, const ChilliSource::VertexFormat& vertexFormat, ChilliSource::IndexFormat indexFormat, u32 numVertices, u32 numIndices,\n                                 const u8* vertexData, u32 vertexDataSize, const u8* indexData, u32 indexDataSize) noexcept\n        {\n            m_polygonType = polygonType;\n            m_vertexFormat = vertexFormat;\n            m_indexFormat = indexFormat;\n            m_numVertices = numVertices;\n            m_numIndices = numIndices;\n        \n            if(m_areVAOsSupported == true)\n            {\n                glBindVertexArray(0);\n            }\n            glBindBuffer(GL_ARRAY_BUFFER, m_vertexBufferHandles[m_currentBufferIndex]);\n            glBufferData(GL_ARRAY_BUFFER, vertexDataSize, vertexData, GL_DYNAMIC_DRAW);\n            \n            glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_indexBufferHandles[m_currentBufferIndex]);\n            if (m_indexBufferHandles[m_currentBufferIndex] != 0)\n            {\n                glBufferData(GL_ELEMENT_ARRAY_BUFFER, indexDataSize, indexData, GL_DYNAMIC_DRAW);\n            }\n            \n            CS_ASSERT_NOGLERROR(\"An OpenGL error occurred while binding GLDynamicMesh.\");\n            \n            ApplyVertexAttributes(glShader);\n        }\n        \n        //------------------------------------------------------------------------------\n        void GLDynamicMesh::Bind(GLShader* glShader, ChilliSource::PolygonType polygonType, const ChilliSource::VertexFormat& vertexFormat, ChilliSource::IndexFormat indexFormat,\n                                 u32 numVertices, u32 numIndices, u32 vertexDataSize, u32 indexDataSize, const std::vector<ChilliSource::RenderMeshBatch::Mesh>& meshes) noexcept\n        {\n            m_polygonType = polygonType;\n            m_vertexFormat = vertexFormat;\n            m_indexFormat = indexFormat;\n            m_numVertices = numVertices;\n            m_numIndices = numIndices;\n            \n            if(m_areVAOsSupported == true)\n            {\n                glBindVertexArray(0);\n            }\n            glBindBuffer(GL_ARRAY_BUFFER, m_vertexBufferHandles[m_currentBufferIndex]);\n            ApplyBatchVertices(m_allocator, m_vertexFormat, numVertices, vertexDataSize, meshes, m_useMapBuffer);\n\n            glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_indexBufferHandles[m_currentBufferIndex]);\n            if (m_indexBufferHandles[m_currentBufferIndex] != 0)\n            {\n                m_useMapBuffer ? ApplyBatchIndicesMapBuffer(indexFormat, numIndices, indexDataSize, meshes) : ApplyBatchIndices(m_allocator, indexFormat, numIndices, indexDataSize, meshes);\n            }\n            \n            ApplyVertexAttributes(glShader);\n        }\n        \n        //------------------------------------------------------------------------------\n        void GLDynamicMesh::ApplyVertexAttributes(GLShader* glShader) const noexcept\n        {\n            CS_ASSERT(m_maxVertexAttributes >= m_vertexFormat.GetNumElements(), \"Too many vertex elements.\");\n            \n            for (u32 i = 0; i < ChilliSource::VertexFormat::k_maxElements; ++i)\n            {\n                glDisableVertexAttribArray(i);\n            }\n            \n            for (u32 i = 0; i < m_vertexFormat.GetNumElements(); ++i)\n            {\n                auto elementType = m_vertexFormat.GetElement(i);\n                \n                GLint attribHandle = glShader->GetAttributeHandle((u32)elementType);\n                if(attribHandle < 0)\n                    continue;\n                \n                glEnableVertexAttribArray(i);\n                \n                auto numComponents = ChilliSource::VertexFormat::GetNumComponents(elementType);\n                auto type = GLMeshUtils::GetGLType(ChilliSource::VertexFormat::GetDataType(elementType));\n                auto normalised = GLMeshUtils::IsNormalised(elementType);\n                auto offset = reinterpret_cast<const GLvoid*>(u64(m_vertexFormat.GetElementOffset(i)));\n                \n                glShader->SetAttribute((u32)elementType, numComponents, type, normalised, m_vertexFormat.GetSize(), offset);\n            }\n        }\n        \n        //------------------------------------------------------------------------------\n        GLDynamicMesh::~GLDynamicMesh() noexcept\n        {\n            if(!m_invalidData)\n            {\n                for(u32 i=0; i<k_numBuffers; ++i)\n                {\n                    glDeleteBuffers(1, &m_vertexBufferHandles[i]);\n                    if(m_indexBufferHandles[i] != 0)\n                    {\n                        glDeleteBuffers(1, &m_indexBufferHandles[i]);\n                    }\n                }\n                \n                CS_ASSERT_NOGLERROR(\"An OpenGL error occurred while deleting GLDynamicMesh.\");\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "Source/CSBackend/Rendering/OpenGL/Model/GLDynamicMesh.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CSBACKEND_RENDERING_OPENGL_MODEL_GLDYNAMICMESH_H_\n#define _CSBACKEND_RENDERING_OPENGL_MODEL_GLDYNAMICMESH_H_\n\n#include <CSBackend/Rendering/OpenGL/ForwardDeclarations.h>\n#include <CSBackend/Rendering/OpenGL/Base/GLIncludes.h>\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Memory/LinearAllocator.h>\n#include <ChilliSource/Rendering/Model/IndexFormat.h>\n#include <ChilliSource/Rendering/Model/PolygonType.h>\n#include <ChilliSource/Rendering/Model/RenderMeshBatch.h>\n\nnamespace CSBackend\n{\n    namespace OpenGL\n    {\n        /// A container for all functionality pertaining to a single dynamic OpenGL mesh, including\n        /// buffer creation, and updating and binding the mesh. Binding includes setting up the\n        /// relevant shader attributes. A dynamic mesh does not have a fixed vertex or index format,\n        /// instead this is set when the data is bound.\n        ///\n        /// This also support batching of meshes.\n        ///\n        /// This is not thread-safe and should only be accessed from the render thread.\n        ///\n        class GLDynamicMesh final\n        {\n        public:\n            CS_DECLARE_NOCOPY(GLDynamicMesh);\n            \n            /// Creates a new OpenGL dynamic mesh of the given size.\n            ///\n            /// @param vertexDataSize\n            ///     The size of the vertex data.\n            /// @param indexDataSize\n            ///     The size of the index data.\n            ///\n            GLDynamicMesh(u32 vertexDataSize, u32 indexDataSize) noexcept;\n            \n            /// @return The current polygon type.\n            ///\n            ChilliSource::PolygonType GetPolygonType() const noexcept { return m_polygonType; }\n            \n            /// @return The current vertex format.\n            ///\n            const ChilliSource::VertexFormat& GetVertexFormat() const noexcept { return m_vertexFormat; }\n            \n            /// @return The current index format.\n            ///\n            ChilliSource::IndexFormat GetIndexFormat() const noexcept { return m_indexFormat; }\n            \n            /// @return The current number of vertices.\n            ///\n            u32 GetNumVertices() const noexcept { return m_numVertices; }\n            \n            /// @return The current number of indices.\n            ///\n            u32 GetNumIndices() const noexcept { return m_numIndices; }\n            \n            /// Updates the vertex and index data stored in the dynamic mesh, binds the mesh for use\n            /// and applies attibutes to the given shader.\n            ///\n            /// @param glShader\n            ///     The shader to apply attributes to.\n            /// @param polygonType\n            ///     The polygon type of the mesh.\n            /// @param vertexFormat\n            ///     The vertex format.\n            /// @param indexFormat\n            ///     The index format of the mesh.\n            /// @param numVertices\n            ///     The number of vertices in the mesh.\n            /// @param numIndices\n            ///     The number of indices in the mesh.\n            /// @param vertexData\n            ///     The vertex data.\n            /// @param vertexDataSize\n            ///     The size of the vertex data.\n            /// @param indexData\n            ///     The size of the index data.\n            /// @param indexDataSize\n            ///     The size of the index data.\n            ///\n            void Bind(GLShader* glShader, ChilliSource::PolygonType polygonType, const ChilliSource::VertexFormat& vertexFormat, ChilliSource::IndexFormat indexFormat, u32 numVertices, u32 numIndices,\n                      const u8* vertexData, u32 vertexDataSize, const u8* indexData, u32 indexDataSize) noexcept;\n            \n            /// Updates the vertex and index data stored in the dynamic mesh, binds the mesh batch for use\n            /// and applies attibutes to the given shader.\n            ///\n            /// @param glShader\n            ///     The shader to apply attributes to.\n            /// @param polygonType\n            ///     The polygon type of the batch.\n            /// @param vertexFormat\n            ///     The vertex format of the batch.\n            /// @param indexFormat\n            ///     The index format of the batch.\n            /// @param numVertices\n            ///     The number of vertices in the batch.\n            /// @param numIndices\n            ///     The number of indices in the batch.\n            /// @param vertexDataSize\n            ///     The total size of the vertex data in the batch.\n            /// @param indexDataSize\n            ///     The total size of the index data in the batch.\n            /// @param batchMeshDescs\n            ///     The list of meshes that should be batched.\n            ///\n            void Bind(GLShader* glShader, ChilliSource::PolygonType polygonType, const ChilliSource::VertexFormat& vertexFormat, ChilliSource::IndexFormat indexFormat, u32 numVertices, u32 numIndices,\n                      u32 vertexDataSize, u32 indexDataSize, const std::vector<ChilliSource::RenderMeshBatch::Mesh>& meshes) noexcept;\n            \n            /// Called when graphics memory is lost, usually through the GLContext being destroyed\n            /// on Android. Function will set a flag to handle safe destructing of this object, preventing\n            /// us from trying to delete invalid memory.\n            ///\n            void Invalidate() noexcept { m_invalidData = true; }\n            \n            ///\n            /// Dynamic buffers are multi buffered. This is called after submitting to the GPu\n            /// to allow the CPU to upload to the next buffer\n            ///\n            void SwitchBuffer() noexcept { m_currentBufferIndex = (m_currentBufferIndex + 1) % k_numBuffers; }\n            \n            /// Destroys the OpenGL dynamic mesh that this represents.\n            ///\n            ~GLDynamicMesh() noexcept;\n            \n        private:\n            /// Applies the vertex attributes to the given shader.\n            ///\n            /// @param glShader\n            ///     The shader to apply the attributes to.\n            ///\n            void ApplyVertexAttributes(GLShader* glShader) const noexcept;\n            \n            ChilliSource::LinearAllocator m_allocator;\n            \n            u32 m_maxVertexDataSize;\n            u32 m_maxIndexDataSize;\n            u32 m_maxVertexAttributes;\n            \n            bool m_areVAOsSupported = false;\n            bool m_useMapBuffer = false;\n            \n            static const u32 k_numBuffers = 3;\n            std::array<GLuint, k_numBuffers> m_vertexBufferHandles;\n            std::array<GLuint, k_numBuffers> m_indexBufferHandles;\n            u32 m_currentBufferIndex = 0;\n\n            ChilliSource::PolygonType m_polygonType = ChilliSource::PolygonType::k_triangle;\n            ChilliSource::VertexFormat m_vertexFormat = ChilliSource::VertexFormat::k_staticMesh;\n            ChilliSource::IndexFormat m_indexFormat = ChilliSource::IndexFormat::k_short;\n            u32 m_numVertices = 0;\n            u32 m_numIndices = 0;\n            \n            bool m_invalidData = false;\n        };\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Rendering/OpenGL/Model/GLMesh.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <CSBackend/Rendering/OpenGL/Model/GLMesh.h>\n\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Rendering/Base/RenderCapabilities.h>\n#include <ChilliSource/Rendering/Model/RenderMesh.h>\n\n#include <CSBackend/Rendering/OpenGL/Base/GLExtensions.h>\n#include <CSBackend/Rendering/OpenGL/Base/GLError.h>\n#include <CSBackend/Rendering/OpenGL/Model/GLMeshUtils.h>\n#include <CSBackend/Rendering/OpenGL/Shader/GLShader.h>\n\n\nnamespace CSBackend\n{\n    namespace OpenGL\n    {\n        namespace\n        {\n#ifdef CS_TARGETPLATFORM_ANDROID\n            //Should maintain memory backups on android to restore data when the context\n            //is lost when dealing with meshes that are not loaded from file.\n            const bool k_shouldBackupMeshDataFromMemory = true;\n#else\n            const bool k_shouldBackupMeshDataFromMemory = false;\n#endif\n        }\n        \n        //------------------------------------------------------------------------------\n        GLMesh::GLMesh(const u8* vertexData, u32 vertexDataSize, const u8* indexData, u32 indexDataSize, ChilliSource::RenderMesh* renderMesh) noexcept\n            : m_vertexDataSize(vertexDataSize), m_indexDataSize(indexDataSize), m_renderMesh(renderMesh)\n        {\n            BuildMesh(vertexData, vertexDataSize, indexData, indexDataSize);\n            \n            if(k_shouldBackupMeshDataFromMemory && renderMesh->ShouldBackupData())\n            {\n                u8* vertextDataCopy = new u8[vertexDataSize];\n                memcpy(vertextDataCopy, vertexData, vertexDataSize);\n                m_vertexDataBackup = std::unique_ptr<const u8[]>(vertextDataCopy);\n                \n                u8* indexDataCopy = new u8[indexDataSize];\n                memcpy(indexDataCopy, indexData, indexDataSize);\n                m_indexDataBackup = std::unique_ptr<const u8[]>(indexDataCopy);\n            }\n            \n            auto renderCapabilities = ChilliSource::Application::Get()->GetSystem<ChilliSource::RenderCapabilities>();\n            m_maxVertexAttributes = renderCapabilities->GetNumVertexAttributes();\n            CS_ASSERT(m_maxVertexAttributes >= m_renderMesh->GetVertexFormat().GetNumElements(), \"Too many vertex elements.\");\n            \n            m_areVAOsSupported = renderCapabilities->IsVAOSupported();\n        }\n        \n        //------------------------------------------------------------------------------\n        void GLMesh::Bind(GLShader* glShader) noexcept\n        {\n            if(m_areVAOsSupported == true)\n            {\n                //Check if we have been rendererd using this shader before and\n                //if so we have a VAO setup for this shader\n                GLuint vao = 0;\n                for(const auto& pair : m_vaoCache)\n                {\n                    if(pair.first == glShader)\n                    {\n                        vao = pair.second;\n                        break;\n                    }\n                }\n                \n                if(vao > 0)\n                {\n                    glBindVertexArray(vao);\n                    CS_ASSERT_NOGLERROR(\"An OpenGL error occurred while binding GLMesh.\");\n                    return;\n                }\n            \n                //Otherwise we need to create a VAO\n                GLuint vaoHandle = 0;\n                glGenVertexArrays(1, &vaoHandle);\n                glBindVertexArray(vaoHandle);\n                m_vaoCache.push_back(std::make_pair(glShader, vaoHandle));\n            }\n            \n            glBindBuffer(GL_ARRAY_BUFFER, m_vertexBufferHandle);\n            glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_indexBufferHandle);\n            \n            CS_ASSERT_NOGLERROR(\"An OpenGL error occurred while creating VAO for GLMesh.\");\n            \n            for (u32 i = 0; i < ChilliSource::VertexFormat::k_maxElements; ++i)\n            {\n                glDisableVertexAttribArray(i);\n            }\n            \n            auto vertexFormat = m_renderMesh->GetVertexFormat();\n            for (u32 i = 0; i < vertexFormat.GetNumElements(); ++i)\n            {\n                auto elementType = vertexFormat.GetElement(i);\n                \n                GLint attribHandle = glShader->GetAttributeHandle((u32)elementType);\n                if(attribHandle < 0)\n                    continue;\n                \n                glEnableVertexAttribArray(attribHandle);\n                \n                auto numComponents = ChilliSource::VertexFormat::GetNumComponents(elementType);\n                auto type = GLMeshUtils::GetGLType(ChilliSource::VertexFormat::GetDataType(elementType));\n                auto normalised = GLMeshUtils::IsNormalised(elementType);\n                auto offset = reinterpret_cast<const GLvoid*>(u64(vertexFormat.GetElementOffset(i)));\n                \n                glShader->SetAttribute((u32)elementType, numComponents, type, normalised, vertexFormat.GetSize(), offset);\n            }\n        }\n        \n        //------------------------------------------------------------------------------\n        void GLMesh::Restore() noexcept\n        {\n            if(m_invalidData == true)\n            {\n                m_vaoCache.clear();\n                \n                if(m_vertexDataBackup)\n                {\n                    BuildMesh(m_vertexDataBackup.get(), m_vertexDataSize, m_indexDataBackup.get(), m_indexDataSize);\n                }\n                \n                m_invalidData = false;\n            }\n        }\n        \n        //------------------------------------------------------------------------------\n        void GLMesh::BuildMesh(const u8* vertexData, u32 vertexDataSize, const u8* indexData, u32 indexDataSize) noexcept\n        {\n            CS_ASSERT(vertexDataSize > 0 && vertexData, \"Cannot build mesh with empty data\");\n            \n            glGenBuffers(1, &m_vertexBufferHandle);\n            CS_ASSERT(m_vertexBufferHandle != 0, \"Invalid vertex buffer.\");\n            \n            if(indexData)\n            {\n                glGenBuffers(1, &m_indexBufferHandle);\n                CS_ASSERT(m_indexBufferHandle != 0, \"Invalid index buffer.\");\n            }\n            \n            glBindBuffer(GL_ARRAY_BUFFER, m_vertexBufferHandle);\n            glBufferData(GL_ARRAY_BUFFER, vertexDataSize, vertexData, GL_STATIC_DRAW);\n            \n            if(indexData)\n            {\n                glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_indexBufferHandle);\n                glBufferData(GL_ELEMENT_ARRAY_BUFFER, indexDataSize, indexData, GL_STATIC_DRAW);\n            }\n            \n            CS_ASSERT_NOGLERROR(\"An OpenGL error occurred while creating GLMesh.\");\n        }\n        \n        //------------------------------------------------------------------------------\n        GLMesh::~GLMesh() noexcept\n        {\n            if(!m_invalidData)\n            {\n                for(auto& vao : m_vaoCache)\n                {\n                    glDeleteVertexArrays(1, &vao.second);\n                }\n                glDeleteBuffers(1, &m_vertexBufferHandle);\n                if(m_indexBufferHandle != 0)\n                {\n                    glDeleteBuffers(1, &m_indexBufferHandle);\n                }\n                \n                CS_ASSERT_NOGLERROR(\"An OpenGL error occurred while deleting GLMesh.\");\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "Source/CSBackend/Rendering/OpenGL/Model/GLMesh.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CSBACKEND_RENDERING_OPENGL_MODEL_GLMESH_H_\n#define _CSBACKEND_RENDERING_OPENGL_MODEL_GLMESH_H_\n\n#include <CSBackend/Rendering/OpenGL/ForwardDeclarations.h>\n#include <CSBackend/Rendering/OpenGL/Base/GLIncludes.h>\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Rendering/Model/VertexFormat.h>\n\n#include <vector>\n\nnamespace CSBackend\n{\n    namespace OpenGL\n    {\n        /// A container for all functionality pertaining to a single OpenGL mesh, including\n        /// loading, unloading and binding the mesh. Binding includes setting up the relevant\n        /// shader attributes.\n        ///\n        /// This is not thread-safe and should only be accessed from the render thread.\n        ///\n        class GLMesh final\n        {\n        public:\n            CS_DECLARE_NOCOPY(GLMesh);\n            \n            /// Creates a new OpenGL mesh with the given mesh data and description.\n            ///\n            /// @param vertexData\n            ///     The vertex data.\n            /// @param vertexDataSize\n            ///     The size of the vertex data.\n            /// @param indexData\n            ///     The size of the index data.\n            /// @param indexDataSize\n            ///     The size of the index data.\n            /// @param render\n            ///     The size of the index data.\n            ///\n            GLMesh(const u8* vertexData, u32 vertexDataSize, const u8* indexData, u32 indexDataSize, ChilliSource::RenderMesh* renderMesh) noexcept;\n            \n            /// Binds the mesh for use and applies attibutes to the given shader.\n            ///\n            /// @param glShader\n            ///     The shader to apply attributes to.\n            ///\n            void Bind(GLShader* glShader) noexcept;\n            \n            /// Called when we should restore any cached mesh data.\n            ///\n            /// This will assert if called without having data backed up.\n            ///\n            void Restore() noexcept;\n            \n            /// Called when graphics memory is lost, usually through the GLContext being destroyed\n            /// on Android. Function will set a flag to handle safe destructing of this object, preventing\n            /// us from trying to delete invalid memory.\n            ///\n            void Invalidate() noexcept { m_invalidData = true; }\n            \n            /// Destroys the OpenGL mesh that this represents.\n            ///\n            ~GLMesh() noexcept;\n            \n        private:\n            \n            /// Creates a new OpenGL mesh with the given mesh data.\n            ///\n            /// @param vertexData\n            ///     The vertex data.\n            /// @param vertexDataSize\n            ///     The size of the vertex data.\n            /// @param indexData\n            ///     The size of the index data.\n            /// @param indexDataSize\n            ///     The size of the index data.\n            ///\n            void BuildMesh(const u8* vertexData, u32 vertexDataSize, const u8* indexData, u32 indexDataSize) noexcept;\n            \n            GLuint m_vertexBufferHandle = 0;\n            GLuint m_indexBufferHandle = 0;\n            std::vector<std::pair<const GLShader*, GLuint>> m_vaoCache;\n            \n            std::unique_ptr<const u8[]> m_vertexDataBackup = nullptr;\n            std::unique_ptr<const u8[]> m_indexDataBackup = nullptr;\n            \n            u32 m_indexDataSize = 0;\n            u32 m_vertexDataSize = 0;\n            u32 m_maxVertexAttributes = 0;\n            bool m_areVAOsSupported;\n            \n            ChilliSource::RenderMesh* m_renderMesh = nullptr;\n            \n            bool m_invalidData = false;\n        };\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Rendering/OpenGL/Model/GLMeshUtils.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <CSBackend/Rendering/OpenGL/Model/GLMeshUtils.h>\n\nnamespace CSBackend\n{\n    namespace OpenGL\n    {\n        /// @param dataType\n        ///     The vertex element data type.\n        ///\n        /// @return the OpenGL type for the requested data type.\n        ///\n        GLenum GLMeshUtils::GetGLType(ChilliSource::VertexFormat::DataType dataType) noexcept\n        {\n            switch (dataType)\n            {\n                case ChilliSource::VertexFormat::DataType::k_byte:\n                    return GL_UNSIGNED_BYTE;\n                case ChilliSource::VertexFormat::DataType::k_float:\n                    return GL_FLOAT;\n                default:\n                    CS_LOG_FATAL(\"Invalid data type.\");\n                    return GL_UNSIGNED_BYTE;\n            }\n        }\n        \n        /// @param elementType\n        ///     The vertex element type.\n        ///\n        /// @return Whether or not the value is normalised for the given element type.\n        ///\n        GLboolean GLMeshUtils::IsNormalised(ChilliSource::VertexFormat::ElementType elementType) noexcept\n        {\n            switch (elementType)\n            {\n                case ChilliSource::VertexFormat::ElementType::k_position4:\n                    return GL_FALSE;\n                case ChilliSource::VertexFormat::ElementType::k_normal3:\n                    return GL_FALSE;\n                case ChilliSource::VertexFormat::ElementType::k_tangent3:\n                    return GL_FALSE;\n                case ChilliSource::VertexFormat::ElementType::k_bitangent3:\n                    return GL_FALSE;\n                case ChilliSource::VertexFormat::ElementType::k_uv2:\n                    return GL_FALSE;\n                case ChilliSource::VertexFormat::ElementType::k_colour4:\n                    return GL_TRUE;\n                case ChilliSource::VertexFormat::ElementType::k_weight4:\n                    return GL_FALSE;\n                case ChilliSource::VertexFormat::ElementType::k_jointIndex4:\n                    return GL_FALSE;\n                default:\n                    CS_LOG_FATAL(\"Invalid element type.\");\n                    return GL_FALSE;\n            }\n        }\n        \n        /// @param elementType\n        ///     The vertex element type.\n        ///\n        /// @return The attribute name for the given element type.\n        ///\n        const char* GLMeshUtils::GetAttributeName(ChilliSource::VertexFormat::ElementType elementType) noexcept\n        {\n            switch (elementType)\n            {\n                case ChilliSource::VertexFormat::ElementType::k_position4:\n                    return \"a_position\";\n                case ChilliSource::VertexFormat::ElementType::k_normal3:\n                    return \"a_normal\";\n                case ChilliSource::VertexFormat::ElementType::k_tangent3:\n                    return \"a_tangent\";\n                case ChilliSource::VertexFormat::ElementType::k_bitangent3:\n                    return \"a_bitangent\";\n                case ChilliSource::VertexFormat::ElementType::k_uv2:\n                    return \"a_texCoord\";\n                case ChilliSource::VertexFormat::ElementType::k_colour4:\n                    return \"a_colour\";\n                case ChilliSource::VertexFormat::ElementType::k_weight4:\n                    return \"a_weights\";\n                case ChilliSource::VertexFormat::ElementType::k_jointIndex4:\n                    return \"a_jointIndices\";\n                default:\n                    CS_LOG_FATAL(\"Invalid element type.\");\n                    return \"\";\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "Source/CSBackend/Rendering/OpenGL/Model/GLMeshUtils.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CSBACKEND_RENDERING_OPENGL_MODEL_GLMESHUTILS_H_\n#define _CSBACKEND_RENDERING_OPENGL_MODEL_GLMESHUTILS_H_\n\n#include <CSBackend/Rendering/OpenGL/ForwardDeclarations.h>\n#include <CSBackend/Rendering/OpenGL/Base/GLIncludes.h>\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Rendering/Model/VertexFormat.h>\n\nnamespace CSBackend\n{\n    namespace OpenGL\n    {\n        /// A series of utility methods pertaining to OpenGL meshes, such as conversions\n        /// from ChilliSource formats to OpenGL formats.\n        ///\n        /// This is not thread-safe and should only be accessed from the render thread.\n        ///\n        namespace GLMeshUtils\n        {\n            /// @param dataType\n            ///     The vertex element data type.\n            ///\n            /// @return the OpenGL type for the requested data type.\n            ///\n            GLenum GetGLType(ChilliSource::VertexFormat::DataType dataType) noexcept;\n            \n            /// @param elementType\n            ///     The vertex element type.\n            ///\n            /// @return Whether or not the value is normalised for the given element type.\n            ///\n            GLboolean IsNormalised(ChilliSource::VertexFormat::ElementType elementType) noexcept;\n            \n            /// @param elementType\n            ///     The vertex element type.\n            ///\n            /// @return The attribute name for the given element type.\n            ///\n            const char* GetAttributeName(ChilliSource::VertexFormat::ElementType elementType) noexcept;\n        }\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Rendering/OpenGL/Model/GLSkinnedAnimation.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <CSBackend/Rendering/OpenGL/Model/GLSkinnedAnimation.h>\n\n#include <CSBackend/Rendering/OpenGL/Shader/GLShader.h>\n\n#include <ChilliSource/Rendering/Model/RenderSkinnedAnimation.h>\n\nnamespace CSBackend\n{\n    namespace OpenGL\n    {\n        namespace\n        {\n            const std::string k_uniformJoints = \"u_joints\";\n        }\n        \n        //------------------------------------------------------------------------------\n        void GLSkinnedAnimation::Apply(const ChilliSource::RenderSkinnedAnimation* renderSkinnedAnimation, GLShader* glShader) noexcept\n        {\n            glShader->SetUniform(k_uniformJoints, renderSkinnedAnimation->GetJointData(), renderSkinnedAnimation->GetJointDataSize());\n        }\n    }\n}\n"
  },
  {
    "path": "Source/CSBackend/Rendering/OpenGL/Model/GLSkinnedAnimation.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CSBACKEND_RENDERING_OPENGL_MODEL_GLSKINNEDANIMATION_H_\n#define _CSBACKEND_RENDERING_OPENGL_MODEL_GLSKINNEDANIMATION_H_\n\n#include <CSBackend/Rendering/OpenGL/ForwardDeclarations.h>\n#include <CSBackend/Rendering/OpenGL/Base/GLIncludes.h>\n\n#include <ChilliSource/ChilliSource.h>\n\nnamespace CSBackend\n{\n    namespace OpenGL\n    {\n        /// A container for all functionality pertaining to skinned animation in OpenGL.\n        ///\n        namespace GLSkinnedAnimation\n        {\n            /// Applys the animation data described by the given RenderSkinnedAnimation to the OpenGL context.\n            ///\n            /// @param renderSkinnedAnimation\n            ///     The render skinned animation to apply.\n            /// @param glShader\n            ///     The currently active shader to apply uniforms to.\n            ///\n            void Apply(const ChilliSource::RenderSkinnedAnimation* renderSkinnedAnimation, GLShader* glShader) noexcept;\n        };\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Rendering/OpenGL/Shader/GLShader.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <CSBackend/Rendering/OpenGL/Shader/GLShader.h>\n\n#include <CSBackend/Rendering/OpenGL/Base/GLError.h>\n\n#include <array>\n\nnamespace CSBackend\n{\n    namespace OpenGL\n    {\n        namespace\n        {\n            /// Compiles the given GLSL shader source.\n            ///\n            /// @param source\n            ///     The shader source string.\n            /// @param type\n            ///     The shader type.\n            ///\n            /// @return The shader handle.\n            ///\n            GLuint CompileShader(const std::string& source, GLenum type)\n            {\n                auto shaderId = glCreateShader(type);\n                CS_ASSERT(shaderId > 0, \"OpenGL ES 2.0 does not support this shader type\");\n                \n                const GLchar* glSource = source.c_str();\n                glShaderSource(shaderId, 1, &glSource, nullptr);\n                glCompileShader(shaderId);\n                \n                GLint compilationStatus;\n                glGetShaderiv(shaderId, GL_COMPILE_STATUS, &compilationStatus);\n                \n                if(compilationStatus == 0)\n                {\n                    GLint errorLength = 0;\n                    glGetShaderiv(shaderId, GL_INFO_LOG_LENGTH, &errorLength);\n                    \n                    if(errorLength > 1)\n                    {\n                        char* errorLog = (char*)malloc(sizeof(char) * errorLength);\n                        glGetShaderInfoLog(shaderId, errorLength, nullptr, errorLog);\n                        \n                        CS_LOG_ERROR(\"GLSL compilation error: \" + std::string(errorLog));\n                        free(errorLog);\n                    }\n                    \n                    CS_LOG_FATAL(\"Failed to compile GLSL shader\");\n                }\n                \n                CS_ASSERT_NOGLERROR(\"An OpenGL error occurred while compiling shader.\");\n                \n                return shaderId;\n            }\n            \n            /// Combines the given vertex and fragment shader to create a shader program.\n            ///\n            /// @param vsHandle\n            ///     The vertex shader handle\n            /// @param fsHandle\n            ///     The fragment shader handle.\n            ///\n            GLuint CreateProgram(GLuint vsHandle, GLuint fsHandle)\n            {\n                auto programId = glCreateProgram();\n                CS_ASSERT(programId > 0, \"Failed to create GLSL program\");\n                \n                glAttachShader(programId, vsHandle);\n                glAttachShader(programId, fsHandle);\n                glLinkProgram(programId);\n                \n                //Check for success\n                GLint linkStatus;\n                glGetProgramiv(programId, GL_LINK_STATUS, &linkStatus);\n                \n                if(linkStatus == 0)\n                {\n                    GLint errorLength = 0;\n                    glGetProgramiv(programId, GL_INFO_LOG_LENGTH, &errorLength);\n                    \n                    if(errorLength > 1)\n                    {\n                        char* errorLog = (char*)malloc(sizeof(char) * errorLength);\n                        glGetProgramInfoLog(programId, errorLength, nullptr, errorLog);\n                        CS_LOG_ERROR(\"GLSL link error: \" + std::string(errorLog));\n                        free(errorLog);\n                    }\n                    \n                    CS_LOG_FATAL(\"Failed to link GLSL shader\");\n                }\n                \n                CS_ASSERT_NOGLERROR(\"An OpenGL error occurred while creating shader program.\");\n                \n                return programId;\n            }\n        }\n        \n        const std::string GLShader::k_attributePosition = \"a_position\";\n        const std::string GLShader::k_attributeNormal = \"a_normal\";\n        const std::string GLShader::k_attributeTangent = \"a_tangent\";\n        const std::string GLShader::k_attributeBitangent = \"a_bitangent\";\n        const std::string GLShader::k_attributeTexCoord = \"a_texCoord\";\n        const std::string GLShader::k_attributeColour = \"a_colour\";\n        const std::string GLShader::k_attributeWeights = \"a_weights\";\n        const std::string GLShader::k_attributeJointIndices = \"a_jointIndices\";\n    \n        //------------------------------------------------------------------------------\n        GLShader::GLShader(const std::string& vertexShader, const std::string& fragmentShader) noexcept\n        {\n            m_vertexShaderId = CompileShader(vertexShader, GL_VERTEX_SHADER);\n            m_fragmentShaderId = CompileShader(fragmentShader, GL_FRAGMENT_SHADER);\n            m_programId = CreateProgram(m_vertexShaderId, m_fragmentShaderId);\n            \n            BuildAttributeHandleMap();\n        }\n    \n        //------------------------------------------------------------------------------\n        void GLShader::Bind() noexcept\n        {\n            glUseProgram(m_programId);\n            CS_ASSERT_NOGLERROR(\"An OpenGL error occurred while binding shader.\");\n        }\n        \n        //------------------------------------------------------------------------------\n        void GLShader::SetUniform(const std::string& name, s32 value, FailurePolicy failurePolicy) noexcept\n        {\n            GLint uniformHandle = GetUniformHandle(name, failurePolicy);\n            \n            if(uniformHandle >= 0)\n            {\n                glUniform1i(uniformHandle, value);\n                CS_ASSERT_NOGLERROR(\"An OpenGL error occurred while setting uniform.\");\n            }\n        }\n        \n        //------------------------------------------------------------------------------\n        void GLShader::SetUniform(const std::string& name, f32 value, FailurePolicy failurePolicy) noexcept\n        {\n            GLint uniformHandle = GetUniformHandle(name, failurePolicy);\n            \n            if(uniformHandle >= 0)\n            {\n                glUniform1f(uniformHandle, value);\n                CS_ASSERT_NOGLERROR(\"An OpenGL error occurred while setting uniform.\");\n            }\n        }\n        \n        //------------------------------------------------------------------------------\n        void GLShader::SetUniform(const std::string& name, const ChilliSource::Vector2& value, FailurePolicy failurePolicy) noexcept\n        {\n            GLint uniformHandle = GetUniformHandle(name, failurePolicy);\n            \n            if(uniformHandle >= 0)\n            {\n                glUniform2fv(uniformHandle, 1, reinterpret_cast<const GLfloat*>(&value));\n                CS_ASSERT_NOGLERROR(\"An OpenGL error occurred while setting uniform.\");\n            }\n        }\n        \n        //------------------------------------------------------------------------------\n        void GLShader::SetUniform(const std::string& name, const ChilliSource::Vector3& value, FailurePolicy failurePolicy) noexcept\n        {\n            GLint uniformHandle = GetUniformHandle(name, failurePolicy);\n            \n            if(uniformHandle >= 0)\n            {\n                glUniform3fv(uniformHandle, 1, reinterpret_cast<const GLfloat*>(&value));\n                CS_ASSERT_NOGLERROR(\"An OpenGL error occurred while setting uniform.\");\n            }\n        }\n        \n        //------------------------------------------------------------------------------\n        void GLShader::SetUniform(const std::string& name, const ChilliSource::Vector4& value, FailurePolicy failurePolicy) noexcept\n        {\n            GLint uniformHandle = GetUniformHandle(name, failurePolicy);\n            \n            if(uniformHandle >= 0)\n            {\n                glUniform4fv(uniformHandle, 1, reinterpret_cast<const GLfloat*>(&value));\n                CS_ASSERT_NOGLERROR(\"An OpenGL error occurred while setting uniform.\");\n            }\n        }\n        \n        //------------------------------------------------------------------------------\n        void GLShader::SetUniform(const std::string& name, const ChilliSource::Matrix4& value, FailurePolicy failurePolicy) noexcept\n        {\n            GLint uniformHandle = GetUniformHandle(name, failurePolicy);\n            \n            if(uniformHandle >= 0)\n            {\n                glUniformMatrix4fv(uniformHandle, 1, GL_FALSE, reinterpret_cast<const GLfloat*>(&value.m));\n                CS_ASSERT_NOGLERROR(\"An OpenGL error occurred while setting uniform.\");\n            }\n        }\n        \n        //------------------------------------------------------------------------------\n        void GLShader::SetUniform(const std::string& name, const ChilliSource::Colour& value, FailurePolicy failurePolicy) noexcept\n        {\n            GLint uniformHandle = GetUniformHandle(name, failurePolicy);\n            \n            if(uniformHandle >= 0)\n            {\n                glUniform4fv(uniformHandle, 1, reinterpret_cast<const GLfloat*>(&value));\n                CS_ASSERT_NOGLERROR(\"An OpenGL error occurred while setting uniform.\");\n            }\n        }\n        \n        //------------------------------------------------------------------------------\n        void GLShader::SetUniform(const std::string& name, const ChilliSource::Vector4* values, u32 numValues, FailurePolicy failurePolicy) noexcept\n        {\n            GLint uniformHandle = GetUniformHandle(name, failurePolicy);\n            \n            if(uniformHandle >= 0)\n            {\n                glUniform4fv(uniformHandle, numValues, reinterpret_cast<const GLfloat*>(values));\n                CS_ASSERT_NOGLERROR(\"An OpenGL error occurred while setting uniform.\");\n            }\n        }\n        \n        //------------------------------------------------------------------------------\n        void GLShader::SetAttribute(u32 index, GLint size, GLenum type, GLboolean isNormalised, GLsizei stride, const GLvoid* offset) noexcept\n        {\n\t\t\tGLint handle = m_attributeHandles[index]; \n            if(handle < 0)\n            {\n                return;\n            }\n\n            glVertexAttribPointer(handle, size, type, isNormalised, stride, offset);\n\n            CS_ASSERT_NOGLERROR(\"An OpenGL error occurred while setting attribute.\");\n        }\n\n        \n        //------------------------------------------------------------------------------\n        void GLShader::BuildAttributeHandleMap() noexcept\n        {\n\t\t\t// This list must be kept in the same order as the ElementType enum in VertexFormat.h\n            static const std::array<std::string, 8> attribNames =\n            {{\n                k_attributePosition, \n                k_attributeNormal,\n                k_attributeTangent,\n                k_attributeBitangent,\n                k_attributeTexCoord,\n                k_attributeColour,\n                k_attributeWeights,\n                k_attributeJointIndices\n            }};\n            \n            for(std::size_t i = 0; i < attribNames.size(); ++i)\n            {\n                GLint handle = glGetAttribLocation(m_programId, attribNames[i].c_str());\n                \n                if(handle >= 0)\n                {\n\t\t\t\t\tm_attributeHandles[i] = handle;\n                }\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tm_attributeHandles[i] = -1;\n\t\t\t\t}\n            }\n            \n            CS_ASSERT_NOGLERROR(\"An OpenGL error occurred while populating attribute handles.\");\n        }\n        \n        //------------------------------------------------------------------------------\n        GLint GLShader::GetUniformHandle(const std::string& name, FailurePolicy failurePolicy) noexcept\n        {\n            GLint uniformHandle = -1;\n            \n            auto it = m_uniformHandles.find(name);\n            if(it != m_uniformHandles.end())\n            {\n                uniformHandle = it->second;\n            }\n            else\n            {\n                uniformHandle = glGetUniformLocation(m_programId, name.c_str());\n                CS_ASSERT_NOGLERROR(\"An OpenGL error occurred while getting uniform handle.\");\n                \n                m_uniformHandles.insert(std::make_pair(name, uniformHandle));\n            }\n\n            if (uniformHandle < 0 && failurePolicy == FailurePolicy::k_hard)\n            {\n                CS_LOG_FATAL(\"Cannot find shader uniform: \" + name);\n            }\n            \n            return uniformHandle;\n        }\n        \n        //------------------------------------------------------------------------------\n        GLShader::~GLShader() noexcept\n        {\n            if(!m_invalidData)\n            {\n                if(m_vertexShaderId > 0)\n                {\n                    glDetachShader(m_programId, m_vertexShaderId);\n                    glDeleteShader(m_vertexShaderId);\n                }\n                if(m_fragmentShaderId > 0)\n                {\n                    glDetachShader(m_programId, m_fragmentShaderId);\n                    glDeleteShader(m_fragmentShaderId);\n                }\n                if(m_programId > 0)\n                {\n                    glDeleteProgram(m_programId);\n                }\n                \n                CS_ASSERT_NOGLERROR(\"An OpenGL error occurred while destroying shader.\");\n            }\n        }\n\n    }\n}\n"
  },
  {
    "path": "Source/CSBackend/Rendering/OpenGL/Shader/GLShader.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CSBACKEND_RENDERING_OPENGL_SHADER_GLSHADER_H_\n#define _CSBACKEND_RENDERING_OPENGL_SHADER_GLSHADER_H_\n\n#include <CSBackend/Rendering/OpenGL/ForwardDeclarations.h>\n#include <CSBackend/Rendering/OpenGL/Base/GLIncludes.h>\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Base/Colour.h>\n#include <ChilliSource/Core/Math/Matrix4.h>\n#include <ChilliSource/Core/Math/Vector2.h>\n#include <ChilliSource/Core/Math/Vector3.h>\n#include <ChilliSource/Core/Math/Vector4.h>\n\n#include <unordered_map>\n#include <array>\n\nnamespace CSBackend\n{\n    namespace OpenGL\n    {\n        /// A container for all OpenGL functionality relating to a single shader, including loading,\n        /// binding and applying attributes and uniforms.\n        ///\n        /// This is not thread-safe and should only be accessed from the render thread.\n        ///\n        class GLShader final\n        {\n        public:\n            CS_DECLARE_NOCOPY(GLShader);\n            \n\t\t\tstatic const u8 k_numAttributes = 8;\n            static const std::string k_attributePosition;\n            static const std::string k_attributeNormal;\n            static const std::string k_attributeTangent;\n            static const std::string k_attributeBitangent;\n            static const std::string k_attributeTexCoord;\n            static const std::string k_attributeColour;\n            static const std::string k_attributeWeights;\n            static const std::string k_attributeJointIndices;\n            \n            /// An enum describing the different types of failure policy. This is used when setting\n            /// uniforms to judge if an assertion should occur when the uniform doesn't exist.\n            ///\n            enum class FailurePolicy\n            {\n                k_hard,\n                k_silent\n            };\n            \n            /// Creates and loads a new shader with the given vertex and fragment shader strings.\n            ///\n            /// @param vertexShader\n            ///     The vertex shader string.\n            /// @param fragmentShader\n            ///     The fragment shader string.\n            ///\n            GLShader(const std::string& vertexShader, const std::string& fragmentShader) noexcept;\n            \n            /// Binds the shader such that it is ready for use in rendering.\n            ///\n            void Bind() noexcept;\n            \n            /// Sets the uniform with the given name to the given value. If if the hard failure policy\n            /// is specified and there is no uniform with the requested name, then this will assert.\n            ///\n            /// @param name\n            ///     The name of the uniform.\n            /// @param value\n            ///     The value to set the uniform to.\n            /// @param failurePolicy\n            ///     The failure policy for if the uniform doesn't exist. Defaults to hard.\n            ///\n            void SetUniform(const std::string& name, s32 value, FailurePolicy failurePolicy = FailurePolicy::k_hard) noexcept;\n            \n            /// Sets the uniform with the given name to the given value. If if the hard failure policy\n            /// is specified and there is no uniform with the requested name, then this will assert.\n            ///\n            /// @param name\n            ///     The name of the uniform.\n            /// @param value\n            ///     The value to set the uniform to.\n            /// @param failurePolicy\n            ///     The failure policy for if the uniform doesn't exist. Defaults to hard.\n            ///\n            void SetUniform(const std::string& name, f32 value, FailurePolicy failurePolicy = FailurePolicy::k_hard) noexcept;\n            \n            /// Sets the uniform with the given name to the given value. If if the hard failure policy\n            /// is specified and there is no uniform with the requested name, then this will assert.\n            ///\n            /// @param name\n            ///     The name of the uniform.\n            /// @param value\n            ///     The value to set the uniform to.\n            /// @param failurePolicy\n            ///     The failure policy for if the uniform doesn't exist. Defaults to hard.\n            ///\n            void SetUniform(const std::string& name, const ChilliSource::Vector2& value, FailurePolicy failurePolicy = FailurePolicy::k_hard) noexcept;\n            \n            /// Sets the uniform with the given name to the given value. If if the hard failure policy\n            /// is specified and there is no uniform with the requested name, then this will assert.\n            ///\n            /// @param name\n            ///     The name of the uniform.\n            /// @param value\n            ///     The value to set the uniform to.\n            /// @param failurePolicy\n            ///     The failure policy for if the uniform doesn't exist. Defaults to hard.\n            ///\n            void SetUniform(const std::string& name, const ChilliSource::Vector3& value, FailurePolicy failurePolicy = FailurePolicy::k_hard) noexcept;\n            \n            /// Sets the uniform with the given name to the given value. If if the hard failure policy\n            /// is specified and there is no uniform with the requested name, then this will assert.\n            ///\n            /// @param name\n            ///     The name of the uniform.\n            /// @param value\n            ///     The value to set the uniform to.\n            /// @param failurePolicy\n            ///     The failure policy for if the uniform doesn't exist. Defaults to hard.\n            ///\n            void SetUniform(const std::string& name, const ChilliSource::Vector4& value, FailurePolicy failurePolicy = FailurePolicy::k_hard) noexcept;\n            \n            /// Sets the uniform with the given name to the given value. If if the hard failure policy\n            /// is specified and there is no uniform with the requested name, then this will assert.\n            ///\n            /// @param name\n            ///     The name of the uniform.\n            /// @param value\n            ///     The value to set the uniform to.\n            /// @param failurePolicy\n            ///     The failure policy for if the uniform doesn't exist. Defaults to hard.\n            ///\n            void SetUniform(const std::string& name, const ChilliSource::Matrix4& value, FailurePolicy failurePolicy = FailurePolicy::k_hard) noexcept;\n            \n            /// Sets the uniform with the given name to the given value. If if the hard failure policy\n            /// is specified and there is no uniform with the requested name, then this will assert.\n            ///\n            /// @param name\n            ///     The name of the uniform.\n            /// @param value\n            ///     The value to set the uniform to.\n            /// @param failurePolicy\n            ///     The failure policy for if the uniform doesn't exist. Defaults to hard.\n            ///\n            void SetUniform(const std::string& name, const ChilliSource::Colour& value, FailurePolicy failurePolicy = FailurePolicy::k_hard) noexcept;\n            \n            /// Sets the uniform with the given name to the given array of values. If if the hard failure\n            /// policy is specified and there is no uniform with the requested name, then this will assert.\n            ///\n            /// @param name\n            ///     The name of the uniform.\n            /// @param values\n            ///     The values to set the uniform to.\n            /// @param numValues\n            ///     The number of values to set.\n            /// @param failurePolicy\n            ///     The failure policy for if the uniform doesn't exist. Defaults to hard.\n            ///\n            void SetUniform(const std::string& name, const ChilliSource::Vector4* values, u32 numValues, FailurePolicy failurePolicy = FailurePolicy::k_hard) noexcept;\n            \n            /// @param index\n            ///     Index of the attribute as defined in vertex format\n            ///\n            /// @return Handle of attribute in shader. -1 if doesn't exist\n            ///\n            GLint GetAttributeHandle(u32 index) const noexcept { return m_attributeHandles[index]; }\n            \n            /// Sets the attribute with the given name and data information. If the attribute doesn't\n            /// exist then it will be ignored.\n            ///\n            /// @param index\n            ///     The index of the attribute.\n            /// @param size\n            ///     The size of the data.\n            /// @param type\n            ///     The data type.\n            /// @param isNormalised\n            ///     Whether or not the data is normalised.\n            /// @param stride\n            ///     The stride of the data\n            /// @param offset\n            ///     The data offset\n            ///\n\t\t\tvoid SetAttribute(u32 index, GLint size, GLenum type, GLboolean isNormalised, GLsizei stride, const GLvoid* offset) noexcept;\n            \n            /// Called when graphics memory is lost, usually through the GLContext being destroyed\n            /// on Android. Function will set a flag to handle safe destructing of this object, preventing\n            /// us from trying to delete invalid memory.\n            ///\n            void Invalidate() noexcept { m_invalidData = true; }\n            \n            /// Unloads the opengl shader.\n            ///\n            ~GLShader() noexcept;\n            \n        private:\n            /// Evaulates which attributes exist in the shader and builds a map to their handles.\n            ///\n            void BuildAttributeHandleMap() noexcept;\n            \n            /// Finds the handle of the shader with the given name. Uniform handles are cached. This\n            /// will assert if the uniform doesn't exist and the hard failure policy is specified.\n            ///\n            /// @param name\n            ///     The name of the uniform.\n            /// @param failurePolicy\n            ///     The failure policy.\n            ///\n            /// @return The uniform handle, or -1 if it doesn't exist in the shader and a silent failure\n            ///     policy was requested.\n            ///\n            GLint GetUniformHandle(const std::string& name, FailurePolicy failurePolicy) noexcept;\n            \n            GLuint m_vertexShaderId = 0;\n            GLuint m_fragmentShaderId = 0;\n            GLuint m_programId = 0;\n            std::unordered_map<std::string, GLint> m_uniformHandles;\n            std::array<GLint, k_numAttributes> m_attributeHandles;\n            \n            bool m_invalidData = false;\n        };\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Rendering/OpenGL/Target/GLTargetGroup.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <CSBackend/Rendering/OpenGL/Target/GLTargetGroup.h>\n\n#include <CSBackend/Rendering/OpenGL/Base/GLError.h>\n#include <CSBackend/Rendering/OpenGL/Texture/GLTexture.h>\n\n#include <ChilliSource/Rendering/Target/RenderTargetGroup.h>\n#include <ChilliSource/Rendering/Texture/RenderTexture.h>\n\n#ifdef CS_OPENGLVERSION_ES\n\t#define GL_DEPTH24_STENCIL8 GL_DEPTH24_STENCIL8_OES\n#endif\n\nnamespace CSBackend\n{\n    namespace OpenGL\n    {\n        namespace\n        {\n#ifdef CS_TARGETPLATFORM_WINDOWS\n            /// Creates a new colour render buffer with the requested size.\n            ///\n            /// @param dimensions\n            ///     The dimensions of the colour buffer.\n            ///\n            /// @return The handle of the buffer.\n            ///\n            GLuint CreateColourRenderBuffer(const ChilliSource::Integer2& dimensions) noexcept\n            {\n                GLuint handle = 0;\n                glGenRenderbuffers(1, &handle);\n                glBindRenderbuffer(GL_RENDERBUFFER, handle);\n                glRenderbufferStorage(GL_RENDERBUFFER, GL_RGB, dimensions.x, dimensions.y);\n                \n                CS_ASSERT_NOGLERROR(\"An OpenGL error occurred while creating a colour render buffer.\");\n                \n                return handle;\n            }\n#endif\n            \n            /// Creates a new depth render buffer with the requested size.\n            ///\n            /// @param dimensions\n            ///     The dimensions of the colour buffer.\n            /// @param format\n            ///     Format of the depth buffer\n            ///\n            /// @return The handle of the buffer.\n            ///\n            GLuint CreateDepthRenderBuffer(const ChilliSource::Integer2& dimensions, GLenum format) noexcept\n            {\n                GLuint handle = 0;\n                glGenRenderbuffers(1, &handle);\n                glBindRenderbuffer(GL_RENDERBUFFER, handle);\n                glRenderbufferStorage(GL_RENDERBUFFER, format, dimensions.x, dimensions.y);\n                \n                CS_ASSERT_NOGLERROR(\"An OpenGL error occurred while creating a depth render buffer.\");\n                \n                return handle;\n            }\n            \n            /// Validates that the current frame buffer is complete. If it isn't, a fatal error\n            /// will occur.\n            ///\n#if CS_ENABLE_DEBUG\n            void ValidateFramebuffer() noexcept\n            {\n                GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);\n                \n                switch(status)\n                {\n                    case GL_FRAMEBUFFER_COMPLETE:\n                        break;\n                    case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT:\n                        CS_LOG_FATAL(\"Framebuffer has incomplete attachment!\");\n                        break;\n#ifdef CS_OPENGLVERSION_ES\n                    case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS:\n                        CS_LOG_FATAL(\"Framebuffer has incomplete dimensions!\");\n                        break;\n#endif\n                    case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:\n                        CS_LOG_FATAL(\"Framebuffer has missing attachment!\");\n                        break;\n                    case GL_FRAMEBUFFER_UNSUPPORTED:\n                        CS_LOG_FATAL(\"Framebuffer is unsupported!\");\n                        break;\n                }\n            }\n#endif\n        }\n        \n        //------------------------------------------------------------------------------\n        GLTargetGroup::GLTargetGroup(const ChilliSource::RenderTargetGroup* renderTargetGroup) noexcept\n            : m_renderTargetGroup(renderTargetGroup)\n        {\n            BuildTargetGroup();\n        }\n        \n        //------------------------------------------------------------------------------\n        void GLTargetGroup::Bind() noexcept\n        {\n            glBindFramebuffer(GL_FRAMEBUFFER, m_frameBufferHandle);\n            \n             CS_ASSERT_NOGLERROR(\"An OpenGL error occurred while binding target group.\");\n        }\n        \n        //------------------------------------------------------------------------------\n        void GLTargetGroup::Restore() noexcept\n        {\n            if(m_invalidData)\n            {\n                BuildTargetGroup();\n                m_invalidData = false;\n            }\n        }\n        \n        //------------------------------------------------------------------------------\n        void GLTargetGroup::BuildTargetGroup() noexcept\n        {\n            glGenFramebuffers(1, &m_frameBufferHandle);\n            glBindFramebuffer(GL_FRAMEBUFFER, m_frameBufferHandle);\n            \n            if (m_renderTargetGroup->GetColourTarget())\n            {\n                auto glTexture = static_cast<GLTexture*>(m_renderTargetGroup->GetColourTarget()->GetExtraData());\n                CS_ASSERT(!glTexture->IsDataInvalid(), \"GLTexture data is invalid! Ensure targets are restored after textures.\");\n                glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, glTexture->GetHandle(), 0);\n            }\n            else\n            {\n                // OpenGL 2.0 on windows requires a colour buffer, else the frame buffer cannot be used.\n#ifdef CS_TARGETPLATFORM_WINDOWS\n                m_colourRenderBufferHandle = CreateColourRenderBuffer(m_renderTargetGroup->GetResolution());\n                glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, m_colourRenderBufferHandle);\n#endif\n            }\n            \n            if (m_renderTargetGroup->GetDepthTarget())\n            {\n                auto glTexture = static_cast<GLTexture*>(m_renderTargetGroup->GetDepthTarget()->GetExtraData());\n                CS_ASSERT(!glTexture->IsDataInvalid(), \"GLTexture data is invalid! Ensure targets are restored after textures.\");\n                glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, glTexture->GetHandle(), 0);\n            }\n            else if (m_renderTargetGroup->ShouldUseDepthBuffer())\n            {\n                m_depthRenderBufferHandle = CreateDepthRenderBuffer(m_renderTargetGroup->GetResolution(), m_renderTargetGroup->ShouldUseStencilBuffer() ? GL_DEPTH24_STENCIL8 : GL_DEPTH_COMPONENT16);\n                glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, m_depthRenderBufferHandle);\n            }\n            \n#ifdef CS_ENABLE_DEBUG\n            ValidateFramebuffer();\n#endif\n            \n            CS_ASSERT_NOGLERROR(\"An OpenGL error occurred while creating target group.\");\n        }\n        \n        //------------------------------------------------------------------------------\n        GLTargetGroup::~GLTargetGroup() noexcept\n        {\n            if(!m_invalidData)\n            {\n                if (m_colourRenderBufferHandle > 0)\n                {\n                    glDeleteRenderbuffers(1, &m_colourRenderBufferHandle);\n                }\n\n                if (m_depthRenderBufferHandle > 0)\n                {\n                    glDeleteRenderbuffers(1, &m_depthRenderBufferHandle);\n                }\n                \n                glDeleteFramebuffers(1, &m_frameBufferHandle);\n\n                CS_ASSERT_NOGLERROR(\"An OpenGL error occurred while destroying target group.\");\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "Source/CSBackend/Rendering/OpenGL/Target/GLTargetGroup.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CSBACKEND_RENDERING_OPENGL_TARGET_GLTARGETGROUP_H_\n#define _CSBACKEND_RENDERING_OPENGL_TARGET_GLTARGETGROUP_H_\n\n#include <CSBackend/Rendering/OpenGL/ForwardDeclarations.h>\n#include <CSBackend/Rendering/OpenGL/Base/GLIncludes.h>\n\n#include <ChilliSource/ChilliSource.h>\n\n#include <unordered_map>\n#include <vector>\n\nnamespace CSBackend\n{\n    namespace OpenGL\n    {\n        /// A container for all functionality pertaining to a single OpenGL target group, including\n        /// creation, deletion and binding of frame buffers.\n        ///\n        /// This is not thread-safe and should only be accessed from the render thread.\n        ///\n        class GLTargetGroup final\n        {\n        public:\n            CS_DECLARE_NOCOPY(GLTargetGroup);\n            \n            /// Creates a new OpenGL texture with the given texture data and description.\n            ///\n            /// @param renderTargetGroup\n            ///     The render target\n            ///\n            GLTargetGroup(const ChilliSource::RenderTargetGroup* renderTargetGroup) noexcept;\n            \n            /// Binds the frame buffer that this target group represents for rendering.\n            ///\n            void Bind() noexcept;\n            \n            /// Called when we should restore the target group.\n            ///\n            void Restore() noexcept;\n            \n            /// Called when graphics memory is lost, usually through the GLContext being destroyed\n            /// on Android. Function will set a flag to handle safe destructing of this object, preventing\n            /// us from trying to delete invalid memory.\n            ///\n            void Invalidate() noexcept { m_invalidData = true; }\n            \n            /// Destroys the OpenGL texture that this represents.\n            ///\n            ~GLTargetGroup() noexcept;\n            \n        private:\n            \n            /// Creates glTextures for the depth|colour buffers of the stored RenderTargetGroup\n            ///\n            void BuildTargetGroup() noexcept;\n            \n            const ChilliSource::RenderTargetGroup* m_renderTargetGroup;\n            \n            GLuint m_frameBufferHandle;\n            GLuint m_colourRenderBufferHandle = 0;\n            GLuint m_depthRenderBufferHandle = 0;\n            \n            bool m_invalidData = false;\n        };\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Rendering/OpenGL/Texture/GLCubemap.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n#include <CSBackend/Rendering/OpenGL/Texture/GLCubemap.h>\n\n#include <CSBackend/Rendering/OpenGL/Base/GLError.h>\n#include <CSBackend/Rendering/OpenGL/Texture/GLTextureUtils.h>\n\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/Image/ImageFormatConverter.h>\n#include <ChilliSource/Core/Math/MathUtils.h>\n#include <ChilliSource/Rendering/Base/RenderCapabilities.h>\n#include <ChilliSource/Rendering/Texture/RenderTexture.h>\n#include <ChilliSource/Rendering/Texture/TextureFilterMode.h>\n#include <ChilliSource/Rendering/Texture/TextureWrapMode.h>\n\nnamespace CSBackend\n{\n    namespace OpenGL\n    {\n        namespace\n        {\n#ifdef CS_TARGETPLATFORM_ANDROID\n            //Should maintain memory backups on android to restore data when the context\n            //is lost when dealing with meshes that are not loaded from file.\n            const bool k_shouldBackupMeshDataFromMemory = true;\n#else\n            const bool k_shouldBackupMeshDataFromMemory = false;\n#endif\n    \n            /// Creates a new OpenGL texture with the given texture data.\n            ///\n            /// @param textureData\n            ///     Texture data for each cubemap face\n            /// @param dataSize\n            ///     Size of the data for any face (as face textures are all the same dimensions and format)\n            /// @param renderTexture\n            ///     Settings for all cubemap textures\n            ///\n            /// @return Handle to the cubemap\n            ///\n            GLuint BuildCubemap(const std::array<std::unique_ptr<const u8[]>, 6>& textureData, u32 dataSize, const ChilliSource::RenderTexture* renderTexture) noexcept\n            {\n                GLuint handle;\n                glGenTextures(1, &handle);\n                \n                glActiveTexture(GL_TEXTURE0);\n                glBindTexture(GL_TEXTURE_CUBE_MAP, handle);\n                \n                const auto& dimensions = renderTexture->GetDimensions();\n                \n                u32 faceIndex = 0;\n                for(const auto& data : textureData)\n                {\n                    GLenum faceTarget = GL_TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex;\n                    \n                    switch(renderTexture->GetImageCompression())\n                    {\n                        case ChilliSource::ImageCompression::k_none:\n                            GLTextureUtils::UploadImageDataNoCompression(faceTarget, renderTexture->GetImageFormat(), dimensions, data.get());\n                            break;\n                        case ChilliSource::ImageCompression::k_ETC1:\n                            GLTextureUtils::UploadImageDataETC1(faceTarget, renderTexture->GetImageFormat(), dimensions, data.get(), dataSize);\n                            break;\n                        case ChilliSource::ImageCompression::k_PVR2Bpp:\n                            GLTextureUtils::UploadImageDataPVR2(faceTarget, renderTexture->GetImageFormat(), dimensions, data.get(), dataSize);\n                            break;\n                        case ChilliSource::ImageCompression::k_PVR4Bpp:\n                            GLTextureUtils::UploadImageDataPVR4(faceTarget, renderTexture->GetImageFormat(), dimensions, data.get(), dataSize);\n                            break;\n                    };\n                    \n                    ++faceIndex;\n                }\n                \n                if(renderTexture->IsMipmapped())\n                {\n                    CS_ASSERT(ChilliSource::MathUtils::IsPowerOfTwo(dimensions.x) && ChilliSource::MathUtils::IsPowerOfTwo(dimensions.y), \"Mipmapped images must be a power of two.\");\n                    \n                    glGenerateMipmap(GL_TEXTURE_CUBE_MAP);\n                }\n                \n                GLTextureUtils::ApplyFilterMode(GL_TEXTURE_CUBE_MAP, renderTexture->GetFilterMode(), renderTexture->IsMipmapped());\n                GLTextureUtils::ApplyWrapMode(GL_TEXTURE_CUBE_MAP, renderTexture->GetWrapModeS(), renderTexture->GetWrapModeT());\n                \n                CS_ASSERT_NOGLERROR(\"An OpenGL error occurred while building cubemap.\");\n                \n                return handle;\n            }\n        }\n        \n        //------------------------------------------------------------------------------\n        GLCubemap::GLCubemap(const std::array<std::unique_ptr<const u8[]>, 6>& textureData, u32 dataSize, const ChilliSource::RenderTexture* renderTexture) noexcept\n        : m_imageDataSize(dataSize), m_renderTexture(renderTexture)\n        {\n#ifdef CS_ENABLE_DEBUG\n            auto renderCapabilities = ChilliSource::Application::Get()->GetSystem<ChilliSource::RenderCapabilities>();\n            auto dimensions = m_renderTexture->GetDimensions();\n            CS_ASSERT(u32(dimensions.x) <= renderCapabilities->GetMaxTextureSize() && u32(dimensions.y) <= renderCapabilities->GetMaxTextureSize(), \"OpenGL does not support textures of this size on this device (\" + ChilliSource::ToString(dimensions.x) + \", \" + ChilliSource::ToString(dimensions.y) + \")\");\n#endif\n            m_handle = BuildCubemap(textureData, dataSize, m_renderTexture);\n            \n            if(k_shouldBackupMeshDataFromMemory && renderTexture->ShouldBackupData())\n            {\n                for(std::size_t i=0; i<textureData.size(); ++i)\n                {\n                    u8* imageDataCopy = new u8[dataSize];\n                    memcpy(imageDataCopy, textureData[i].get(), dataSize);\n                    m_imageDataBackup[i] = std::unique_ptr<const u8[]>(imageDataCopy);\n                }\n            }\n        }\n        \n        //------------------------------------------------------------------------------\n        void GLCubemap::Restore() noexcept\n        {\n            if(m_invalidData)\n            {\n                m_handle = BuildCubemap(m_imageDataBackup, m_imageDataSize, m_renderTexture);\n\n                m_invalidData = false;\n            }\n        }\n        \n        //------------------------------------------------------------------------------\n        GLCubemap::~GLCubemap() noexcept\n        {\n            if(!m_invalidData)\n            {\n                glDeleteTextures(1, &m_handle);\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "Source/CSBackend/Rendering/OpenGL/Texture/GLCubemap.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CSBACKEND_RENDERING_OPENGL_TEXTURE_GLCUBEMAP_H_\n#define _CSBACKEND_RENDERING_OPENGL_TEXTURE_GLCUBEMAP_H_\n\n#include <CSBackend/Rendering/OpenGL/ForwardDeclarations.h>\n#include <CSBackend/Rendering/OpenGL/Base/GLIncludes.h>\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Image/ImageFormat.h>\n#include <ChilliSource/Core/Image/ImageCompression.h>\n#include <ChilliSource/Core/Math/Vector2.h>\n\n#include <array>\n\nnamespace CSBackend\n{\n    namespace OpenGL\n    {\n        /// A container for all functionality pertaining to a single OpenGL cubemaps consisting of 6 textures, including\n        /// loading, unloading and binding of textures.\n        ///\n        /// This is not thread-safe and should only be accessed from the render thread.\n        ///\n        class GLCubemap final\n        {\n        public:\n            CS_DECLARE_NOCOPY(GLCubemap);\n            \n            /// Creates a new OpenGL cubemap with the given texture data and description.\n            /// NOTE: Only one description is given as all face textures must have the same settings\n            ///\n            /// @param textureData\n            ///     Texture data for each face\n            /// @param dataSize\n            ///     Size of the data for any face (as face textures are all the same dimensions and format)\n            /// @param renderTexture\n            ///     Description of the settings for all cubemap faces\n            ///\n            GLCubemap(const std::array<std::unique_ptr<const u8[]>, 6>& textureData, u32 dataSize, const ChilliSource::RenderTexture* renderTexture) noexcept;\n            \n            /// @return The OpenGL texture handle.\n            ///\n            GLuint GetHandle() noexcept { return m_handle; }\n            \n            /// @return The OpenGL texture handle.\n            ///\n            bool IsDataInvalid() const noexcept { return m_invalidData; }\n            \n            /// Called when we should restore any cached texture data.\n            ///\n            /// This will assert if called without having data backed up.\n            ///\n            void Restore() noexcept;\n            \n            /// Called when graphics memory is lost, usually through the GLContext being destroyed\n            /// on Android. Function will set a flag to handle safe destructing of this object, preventing\n            /// us from trying to delete invalid memory.\n            ///\n            void Invalidate() noexcept { m_invalidData = true; }\n            \n            /// Destroys the OpenGL cubemap that this represents.\n            ///\n            ~GLCubemap() noexcept;\n            \n        private:\n            \n            GLuint m_handle = 0;\n            \n            const ChilliSource::RenderTexture* m_renderTexture;\n            u32 m_imageDataSize = 0;\n            \n            std::array<std::unique_ptr<const u8[]>, 6> m_imageDataBackup;\n            \n            bool m_invalidData = false;\n        };\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Rendering/OpenGL/Texture/GLTexture.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n#include <CSBackend/Rendering/OpenGL/Texture/GLTexture.h>\n\n#include <CSBackend/Rendering/OpenGL/Base/GLError.h>\n#include <CSBackend/Rendering/OpenGL/Texture/GLTextureUtils.h>\n\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/Image/ImageFormatConverter.h>\n#include <ChilliSource/Core/Math/MathUtils.h>\n#include <ChilliSource/Rendering/Base/RenderCapabilities.h>\n#include <ChilliSource/Rendering/Texture/RenderTexture.h>\n#include <ChilliSource/Rendering/Texture/TextureFilterMode.h>\n#include <ChilliSource/Rendering/Texture/TextureWrapMode.h>\n\nnamespace CSBackend\n{\n    namespace OpenGL\n    {\n        namespace\n        {\n#ifdef CS_TARGETPLATFORM_ANDROID\n            //Should maintain memory backups on android to restore data when the context\n            //is lost when dealing with meshes that are not loaded from file.\n            const bool k_shouldBackupMeshDataFromMemory = true;\n#else\n            const bool k_shouldBackupMeshDataFromMemory = false;\n#endif\n    \n            /// Creates a new OpenGL texture with the given texture data.\n            ///\n            /// @param data\n            ///     The texture data.\n            /// @param dataSize\n            ///     The size of the texture data.\n            /// @param renderTexture\n            ///     The RenderTexture containing image format data.\n            ///\n            /// @return Handle to the texture\n            ///\n            GLuint BuildTexture(const u8* data, u32 dataSize, const ChilliSource::RenderTexture* renderTexture) noexcept\n            {\n                GLuint handle;\n                glGenTextures(1, &handle);\n                \n                glActiveTexture(GL_TEXTURE0);\n                glBindTexture(GL_TEXTURE_2D, handle);\n                \n                const auto& dimensions = renderTexture->GetDimensions();\n                \n                switch(renderTexture->GetImageCompression())\n                {\n                    case ChilliSource::ImageCompression::k_none:\n                        GLTextureUtils::UploadImageDataNoCompression(GL_TEXTURE_2D, renderTexture->GetImageFormat(), dimensions, data);\n                        break;\n                    case ChilliSource::ImageCompression::k_ETC1:\n                        GLTextureUtils::UploadImageDataETC1(GL_TEXTURE_2D, renderTexture->GetImageFormat(), dimensions, data, dataSize);\n                        break;\n                    case ChilliSource::ImageCompression::k_PVR2Bpp:\n                        GLTextureUtils::UploadImageDataPVR2(GL_TEXTURE_2D, renderTexture->GetImageFormat(), dimensions, data, dataSize);\n                        break;\n                    case ChilliSource::ImageCompression::k_PVR4Bpp:\n                        GLTextureUtils::UploadImageDataPVR4(GL_TEXTURE_2D, renderTexture->GetImageFormat(), dimensions, data, dataSize);\n                        break;\n                };\n                \n                if(renderTexture->IsMipmapped())\n                {\n                    CS_ASSERT(ChilliSource::MathUtils::IsPowerOfTwo(dimensions.x) && ChilliSource::MathUtils::IsPowerOfTwo(dimensions.y), \"Mipmapped images must be a power of two.\");\n                    \n                    glGenerateMipmap(GL_TEXTURE_2D);\n                }\n                \n                GLTextureUtils::ApplyFilterMode(GL_TEXTURE_2D, renderTexture->GetFilterMode(), renderTexture->IsMipmapped());\n                GLTextureUtils::ApplyWrapMode(GL_TEXTURE_2D, renderTexture->GetWrapModeS(), renderTexture->GetWrapModeT());\n                \n                CS_ASSERT_NOGLERROR(\"An OpenGL error occurred while building texture.\");\n                \n                return handle;\n            }\n        }\n        \n        //------------------------------------------------------------------------------\n        GLTexture::GLTexture(const u8* data, u32 dataSize, const ChilliSource::RenderTexture* renderTexture) noexcept\n            :m_imageDataSize(dataSize), m_renderTexture(renderTexture)\n        {\n#ifdef CS_ENABLE_DEBUG\n            auto renderCapabilities = ChilliSource::Application::Get()->GetSystem<ChilliSource::RenderCapabilities>();\n            auto dimensions = renderTexture->GetDimensions();\n            CS_ASSERT(u32(dimensions.x) <= renderCapabilities->GetMaxTextureSize() && u32(dimensions.y) <= renderCapabilities->GetMaxTextureSize(),\n                      \"OpenGL does not support textures of this size on this device (\" + ChilliSource::ToString(dimensions.x) + \", \" + ChilliSource::ToString(dimensions.y) + \")\");\n#endif\n            m_handle = BuildTexture(data, dataSize, m_renderTexture);\n            \n            if(k_shouldBackupMeshDataFromMemory && renderTexture->ShouldBackupData() && data)\n            {\n                u8* imageDataCopy = new u8[dataSize];\n                memcpy(imageDataCopy, data, dataSize);\n                m_imageDataBackup = std::unique_ptr<const u8[]>(imageDataCopy);\n            }\n        }\n        \n        //------------------------------------------------------------------------------\n        void GLTexture::Restore() noexcept\n        {\n            if(m_invalidData)\n            {\n                if(m_imageDataBackup)\n                {\n                    m_handle = BuildTexture(m_imageDataBackup.get(), m_imageDataSize, m_renderTexture);\n                }\n                else\n                {\n                    m_handle = BuildTexture(nullptr, 0, m_renderTexture);\n                }\n                m_invalidData = false;\n            }\n        }\n        \n        //------------------------------------------------------------------------------\n        void GLTexture::UpdateRestorableBackup() noexcept\n        {\n            if(k_shouldBackupMeshDataFromMemory && m_renderTexture->ShouldBackupData())\n            {\n                //create an bind a new frame buffer.\n                GLuint frameBufferHandle = 0;\n                glGenFramebuffers(1, &frameBufferHandle);\n                glBindFramebuffer(GL_FRAMEBUFFER, frameBufferHandle);\n                \n                //attach the texture\n                glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_handle, 0);\n                GLuint glCheck = glCheckFramebufferStatus(GL_FRAMEBUFFER);\n                if(glCheck != GL_FRAMEBUFFER_COMPLETE)\n                {\n                    CS_LOG_FATAL(\"Framebuffer incomplete while updating texture restoration data.\");\n                }\n                \n                //read the data from the texture. This can only be read back in RGBA8888 format so it will need\n                //to be converted back to the format of the texture.\n                u32 unconvertedDataSize = m_renderTexture->GetDimensions().x * m_renderTexture->GetDimensions().y * 4;\n                std::unique_ptr<u8[]> unconvertedData(new u8[unconvertedDataSize]);\n                glReadPixels(0, 0, m_renderTexture->GetDimensions().x, m_renderTexture->GetDimensions().y, GL_RGBA, GL_UNSIGNED_BYTE, unconvertedData.get());\n                \n                //Convert to the format of this texture\n                ChilliSource::ImageFormatConverter::ImageBuffer convertedData;\n                switch (m_renderTexture->GetImageFormat())\n                {\n                    case ChilliSource::ImageFormat::k_RGBA8888:\n                        convertedData.m_size = unconvertedDataSize;\n                        convertedData.m_data = std::move(unconvertedData);\n                        break;\n                    case ChilliSource::ImageFormat::k_RGB888:\n                        convertedData = CS::ImageFormatConverter::RGBA8888ToRGB888(unconvertedData.get(), unconvertedDataSize);\n                        unconvertedData.reset();\n                        break;\n                    case ChilliSource::ImageFormat::k_RGBA4444:\n                        convertedData = CS::ImageFormatConverter::RGBA8888ToRGBA4444(unconvertedData.get(), unconvertedDataSize);\n                        unconvertedData.reset();\n                        break;\n                    case ChilliSource::ImageFormat::k_RGB565:\n                        convertedData = CS::ImageFormatConverter::RGBA8888ToRGB565(unconvertedData.get(), unconvertedDataSize);\n                        unconvertedData.reset();\n                        break;\n                    default:\n                        CS_LOG_FATAL(\"Texture is not in a restorable format. The restorable texture data option must be disabled for this texture.\");\n                        break;\n                }\n                \n                m_imageDataSize = convertedData.m_size;\n                m_imageDataBackup = std::move(convertedData.m_data);\n                \n                //clean up the frame buffer.\n                glBindFramebuffer(GL_FRAMEBUFFER, 0);\n                glDeleteFramebuffers(1, &frameBufferHandle);\n                \n                CS_ASSERT_NOGLERROR(\"An OpenGL error occurred while updating texture restoration data.\");\n            }\n        }\n        \n        //------------------------------------------------------------------------------\n        GLTexture::~GLTexture() noexcept\n        {\n            if(!m_invalidData)\n            {\n                glDeleteTextures(1, &m_handle);\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "Source/CSBackend/Rendering/OpenGL/Texture/GLTexture.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CSBACKEND_RENDERING_OPENGL_TEXTURE_GLTEXTURE_H_\n#define _CSBACKEND_RENDERING_OPENGL_TEXTURE_GLTEXTURE_H_\n\n#include <CSBackend/Rendering/OpenGL/ForwardDeclarations.h>\n#include <CSBackend/Rendering/OpenGL/Base/GLIncludes.h>\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Image/ImageFormat.h>\n#include <ChilliSource/Core/Image/ImageCompression.h>\n#include <ChilliSource/Core/Math/Vector2.h>\n\nnamespace CSBackend\n{\n    namespace OpenGL\n    {\n        /// A container for all functionality pertaining to a single OpenGL texture, including\n        /// loading, unloading and binding of textures.\n        ///\n        /// This is not thread-safe and should only be accessed from the render thread.\n        ///\n        class GLTexture final\n        {\n        public:\n            CS_DECLARE_NOCOPY(GLTexture);\n            \n            /// Creates a new OpenGL texture with the given texture data and description.\n            ///\n            /// @param data\n            ///     The texture data.\n            /// @param dataSize\n            ///     The size of the texture data.\n            ///\n            GLTexture(const u8* data, u32 dataSize, const ChilliSource::RenderTexture* renderTexture) noexcept;\n            \n            /// @return The OpenGL texture handle.\n            ///\n            GLuint GetHandle() noexcept { return m_handle; }\n            \n            /// @return The OpenGL texture handle.\n            ///\n            bool IsDataInvalid() const noexcept { return m_invalidData; }\n            \n            /// Called prior to the app suspending and losing context to update\n            /// the restorable copy of the image data. This is used primarily\n            /// or render textures which are changed after creation\n            ///\n            void UpdateRestorableBackup() noexcept;\n            \n            /// Called when we should restore any cached texture data.\n            ///\n            /// This will assert if called without having data backed up.\n            ///\n            void Restore() noexcept;\n            \n            /// Called when graphics memory is lost, usually through the GLContext being destroyed\n            /// on Android. Function will set a flag to handle safe destructing of this object, preventing\n            /// us from trying to delete invalid memory.\n            ///\n            void Invalidate() noexcept { m_invalidData = true; }\n            \n            /// Destroys the OpenGL texture that this represents.\n            ///\n            ~GLTexture() noexcept;\n            \n        private:\n            \n            GLuint m_handle = 0;\n            \n            const ChilliSource::RenderTexture* m_renderTexture;\n            \n            std::unique_ptr<const u8[]> m_imageDataBackup = nullptr;\n            \n            u32 m_imageDataSize = 0;\n            \n            bool m_invalidData = false;\n        };\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Rendering/OpenGL/Texture/GLTextureUnitManager.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <CSBackend/Rendering/OpenGL/Texture/GLTextureUnitManager.h>\n\n#include <CSBackend/Rendering/OpenGL/Base/GLError.h>\n#include <CSBackend/Rendering/OpenGL/Texture/GLCubemap.h>\n#include <CSBackend/Rendering/OpenGL/Texture/GLTexture.h>\n\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Rendering/Base/RenderCapabilities.h>\n#include <ChilliSource/Rendering/Texture/RenderTexture.h>\n\nnamespace CSBackend\n{\n    namespace OpenGL\n    {\n        //------------------------------------------------------------------------------\n        GLTextureUnitManager::GLTextureUnitManager() noexcept\n        {\n            u32 numTextureUnits = CS::Application::Get()->GetSystem<CS::RenderCapabilities>()->GetNumTextureUnits();\n \n            m_boundTextures.reserve(numTextureUnits);\n            for (u32 i = 0; i < numTextureUnits; ++i)\n            {\n                m_boundTextures.push_back(nullptr);\n            }\n            \n            CS_ASSERT_NOGLERROR(\"An OpenGL error occurred while setting up the texture unit manager.\");\n        }\n        \n        //------------------------------------------------------------------------------\n        void GLTextureUnitManager::Bind(GLenum target, const std::vector<const ChilliSource::RenderTexture*>& textures, u32 startingBindIdx) noexcept\n        {\n            for(std::size_t i=0; i<textures.size(); ++i)\n            {\n                auto textureUnitIndex = startingBindIdx + i;\n                \n                if (m_boundTextures[textureUnitIndex] != textures[i])\n                {\n                    m_boundTextures[textureUnitIndex] = textures[i];\n                    \n                    glActiveTexture((GLenum)(GL_TEXTURE0 + textureUnitIndex));\n                    \n                    switch(target)\n                    {\n                        case GL_TEXTURE_2D:\n                        {\n                            auto glTexture = static_cast<GLTexture*>(m_boundTextures[textureUnitIndex]->GetExtraData());\n                            \n                            CS_ASSERT(glTexture, \"Cannot bind a texture which hasn't been loaded.\");\n                            CS_ASSERT(!glTexture->IsDataInvalid(), \"GLTextureUnitManager::Bind(): Failed to bind texture, its context is invalid!\");\n                            glBindTexture(target, glTexture->GetHandle());\n                            break;\n                        }\n                        case GL_TEXTURE_CUBE_MAP:\n                        {\n                            auto glCubemap = static_cast<GLCubemap*>(m_boundTextures[textureUnitIndex]->GetExtraData());\n                            \n                            CS_ASSERT(glCubemap, \"Cannot bind a cubemap which hasn't been loaded.\");\n                            CS_ASSERT(!glCubemap->IsDataInvalid(), \"GLTextureUnitManager::Bind(): Failed to bind cubemap, its context is invalid!\");\n                            glBindTexture(target, glCubemap->GetHandle());\n                            break;\n                        }\n                    }\n                }\n            }\n            \n            glActiveTexture(GL_TEXTURE0);\n            \n            CS_ASSERT_NOGLERROR(\"An OpenGL error occurred while binding textures.\");\n        }\n        \n        //------------------------------------------------------------------------------\n        GLuint GLTextureUnitManager::BindAdditional(GLenum target, const ChilliSource::RenderTexture* texture) noexcept\n        {\n            GLuint textureIndex = GetBoundOrAvailableUnit(texture);\n            \n            if (m_boundTextures[textureIndex] != texture)\n            {\n                m_boundTextures[textureIndex] = texture;\n                \n                glActiveTexture((GLenum)GL_TEXTURE0 + textureIndex);\n                \n                switch(target)\n                {\n                    case GL_TEXTURE_2D:\n                    {\n                        auto glTexture = static_cast<GLTexture*>(texture->GetExtraData());\n                        CS_ASSERT(glTexture, \"Cannot bind a texture which hasn't been loaded.\");\n                        glBindTexture(target, glTexture->GetHandle());\n                        break;\n                    }\n                    case GL_TEXTURE_CUBE_MAP:\n                    {\n                        auto glCubemap = static_cast<GLCubemap*>(texture->GetExtraData());\n                        CS_ASSERT(glCubemap, \"Cannot bind a cubemap which hasn't been loaded.\");\n                        glBindTexture(target, glCubemap->GetHandle());\n                        break;\n                    }\n                }\n            }\n        \n            glActiveTexture(GL_TEXTURE0);\n            \n            CS_ASSERT_NOGLERROR(\"An OpenGL error occurred while binding an additional texture.\");\n            \n            return textureIndex;\n        }\n        \n        //------------------------------------------------------------------------------\n        void GLTextureUnitManager::Reset() noexcept\n        {\n            for (auto& texture : m_boundTextures)\n            {\n                texture = nullptr;\n            }\n        }\n        \n        //------------------------------------------------------------------------------\n        GLint GLTextureUnitManager::GetBoundOrAvailableUnit(const ChilliSource::RenderTexture* texture) const noexcept\n        {\n            GLint freeIndex = -1;\n            \n            for(u32 i=0; i<m_boundTextures.size(); ++i)\n            {\n                if(m_boundTextures[i] == texture)\n                {\n                    return (GLint)i;\n                }\n                \n                if(m_boundTextures[i] == nullptr && freeIndex == -1)\n                {\n                    freeIndex = (GLint)i;\n                }\n            }\n            \n            CS_ASSERT(freeIndex >= 0, \"No free GL texture units\");\n            return freeIndex;\n        }\n    }\n}\n"
  },
  {
    "path": "Source/CSBackend/Rendering/OpenGL/Texture/GLTextureUnitManager.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CSBACKEND_RENDERING_OPENGL_TEXTURE_TEXTUREUNITMANAGER_H_\n#define _CSBACKEND_RENDERING_OPENGL_TEXTURE_TEXTUREUNITMANAGER_H_\n\n#include <CSBackend/Rendering/OpenGL/ForwardDeclarations.h>\n#include <CSBackend/Rendering/OpenGL/Base/GLIncludes.h>\n\n#include <ChilliSource/ChilliSource.h>\n\n#include <vector>\n\nnamespace CSBackend\n{\n    namespace OpenGL\n    {\n        /// Provides the ability to bind a number of textures to different opengl texture\n        /// units.\n        ///\n        /// This is not thread-safe and should only be accessed from the render thread.\n        ///\n        class GLTextureUnitManager final\n        {\n        public:\n            CS_DECLARE_NOCOPY(GLTextureUnitManager);\n            \n            GLTextureUnitManager() noexcept;\n            \n            /// @return The number of available texture slots.\n            ///\n            u32 GetNumTextureSlots() noexcept { return u32(m_boundTextures.size()); }\n            \n            /// Binds the given list of textures to texture units, in order. If the list is\n            /// greater in size than the number of available texture units this will assert.\n            ///\n            /// @param target\n            ///     Texture2D or Cubemap\n            /// @param textures\n            ///     The list of textures which should be bound.\n            /// @param startingBindIdx\n            ///     The index to start binding from\n            ///\n            void Bind(GLenum target, const std::vector<const ChilliSource::RenderTexture*>& textures, u32 startingBindIdx) noexcept;\n            \n            /// Binds an additional texture to the first free slot, returning the slot index.\n            ///\n            /// @param target\n            ///     Texture2D or Cubemap\n            /// @param texture\n            ///     The additional texture which should be bound.\n            ///\n            /// @return The slot index of the additional texture.\n            ///\n            GLuint BindAdditional(GLenum target, const ChilliSource::RenderTexture* texture) noexcept;\n            \n            /// Clears all texture slots. This doesn't unbind them from the OpenGL context, it\n            /// simply clears the cache to force them to be re-bound the next time Bind() is called\n            ///\n            void Reset() noexcept;\n            \n        private:\n            /// Finds a free texture unit or if the texture is already bound then the unit it is bound to, asserting if they are all currently full.\n            ///\n            /// @return A free texture unit (or the unit of the given texture if already bound).\n            ///\n            GLint GetBoundOrAvailableUnit(const ChilliSource::RenderTexture* texture) const noexcept;\n            \n            std::vector<const ChilliSource::RenderTexture*> m_boundTextures;\n        };\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/CSBackend/Rendering/OpenGL/Texture/GLTextureUtils.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n#include <CSBackend/Rendering/OpenGL/Texture/GLTextureUtils.h>\n\n#include <CSBackend/Rendering/OpenGL/Base/GLError.h>\n\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/Image/ImageFormatConverter.h>\n#include <ChilliSource/Core/Math/MathUtils.h>\n#include <ChilliSource/Rendering/Base/RenderCapabilities.h>\n#include <ChilliSource/Rendering/Texture/RenderTexture.h>\n#include <ChilliSource/Rendering/Texture/TextureFilterMode.h>\n#include <ChilliSource/Rendering/Texture/TextureWrapMode.h>\n\nnamespace CSBackend\n{\n    namespace OpenGL\n    {\n        namespace GLTextureUtils\n        {\n            //------------------------------------------------------------------------------\n            void UploadImageDataNoCompression(GLenum target, ChilliSource::ImageFormat format, const ChilliSource::Integer2& dimensions, const u8* imageData)\n            {\n                switch(format)\n                {\n                    default:\n                    case ChilliSource::ImageFormat::k_RGBA8888:\n                        glTexImage2D(target, 0, GL_RGBA, dimensions.x, dimensions.y, 0, GL_RGBA, GL_UNSIGNED_BYTE, imageData);\n                        break;\n                    case ChilliSource::ImageFormat::k_RGB888:\n                        glTexImage2D(target, 0, GL_RGB, dimensions.x, dimensions.y, 0, GL_RGB, GL_UNSIGNED_BYTE, imageData);\n                        break;\n                    case ChilliSource::ImageFormat::k_RGBA4444:\n                        glTexImage2D(target, 0, GL_RGBA, dimensions.x, dimensions.y, 0, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, imageData);\n                        break;\n                    case ChilliSource::ImageFormat::k_RGB565:\n                        glTexImage2D(target, 0, GL_RGB, dimensions.x, dimensions.y, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, imageData);\n                        break;\n                    case ChilliSource::ImageFormat::k_LumA88:\n                        glTexImage2D(target, 0, GL_LUMINANCE_ALPHA, dimensions.x, dimensions.y, 0, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, imageData);\n                        break;\n                    case ChilliSource::ImageFormat::k_Lum8:\n                        glTexImage2D(target, 0, GL_LUMINANCE, dimensions.x, dimensions.y, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, imageData);\n                        break;\n                    case ChilliSource::ImageFormat::k_Depth16:\n                        glTexImage2D(target, 0, GL_DEPTH_COMPONENT, dimensions.x, dimensions.y, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, imageData);\n                        break;\n                    case ChilliSource::ImageFormat::k_Depth32:\n                        glTexImage2D(target, 0, GL_DEPTH_COMPONENT, dimensions.x, dimensions.y, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, imageData);\n                        break;\n                };\n                \n                CS_ASSERT_NOGLERROR(\"An OpenGL error occurred while uploading uncompressed texture data.\");\n            }\n            \n            //------------------------------------------------------------------------------\n            void UploadImageDataETC1(GLenum target, ChilliSource::ImageFormat format, const ChilliSource::Integer2& dimensions, const u8* imageData, u32 imageDataSize)\n            {\n#ifndef CS_TARGETPLATFORM_ANDROID\n                CS_LOG_FATAL(\"ETC1 compression is only supported on Android\");\n#endif\n                CS_ASSERT(format == ChilliSource::ImageFormat::k_RGB888, \"ETC1 only supports RGB image format\");\n                \n#ifdef CS_TARGETPLATFORM_ANDROID\n                glCompressedTexImage2D(target, 0, GL_ETC1_RGB8_OES, dimensions.x, dimensions.y, 0, imageDataSize, imageData);\n#endif\n                CS_ASSERT_NOGLERROR(\"An OpenGL error occurred while uploading ETC1 texture data.\");\n            }\n            \n            //------------------------------------------------------------------------------\n            void UploadImageDataPVR2(GLenum target, ChilliSource::ImageFormat format, const ChilliSource::Integer2& dimensions, const u8* imageData, u32 imageDataSize)\n            {\n#ifndef CS_TARGETPLATFORM_IOS\n                CS_LOG_FATAL(\"PVR compression is only supported on iOS\");\n#endif\n                \n#ifdef CS_TARGETPLATFORM_IOS\n                switch(format)\n                {\n                    default:\n                        CS_LOG_FATAL(\"PVR compression only supports RGB and RGBA image formats\");\n                        break;\n                    case ChilliSource::ImageFormat::k_RGBA8888:\n                        glCompressedTexImage2D(target, 0, GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG, dimensions.x, dimensions.y, 0, imageDataSize, imageData);\n                        break;\n                    case ChilliSource::ImageFormat::k_RGB888:\n                        glCompressedTexImage2D(target, 0, GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG, dimensions.x, dimensions.y, 0, imageDataSize, imageData);\n                        break;\n                };\n#endif\n                CS_ASSERT_NOGLERROR(\"An OpenGL error occurred while uploading PVR2 texture data.\");\n            }\n            \n            //------------------------------------------------------------------------------\n            void UploadImageDataPVR4(GLenum target, ChilliSource::ImageFormat format, const ChilliSource::Integer2& dimensions, const u8* imageData, u32 imageDataSize)\n            {\n#ifndef CS_TARGETPLATFORM_IOS\n                CS_LOG_FATAL(\"PVR compression is only supported on iOS\");\n#endif\n                \n#ifdef CS_TARGETPLATFORM_IOS\n                switch(format)\n                {\n                    default:\n                        CS_LOG_FATAL(\"PVR compression only supports RGB and RGBA image formats\");\n                        break;\n                    case ChilliSource::ImageFormat::k_RGBA8888:\n                        glCompressedTexImage2D(target, 0, GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG, dimensions.x, dimensions.y, 0, imageDataSize, imageData);\n                        break;\n                    case ChilliSource::ImageFormat::k_RGB888:\n                        glCompressedTexImage2D(target, 0, GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG, dimensions.x, dimensions.y, 0, imageDataSize, imageData);\n                        break;\n                };\n#endif\n                CS_ASSERT_NOGLERROR(\"An OpenGL error occurred while uploading PVR4 texture data.\");\n            }\n            \n            //------------------------------------------------------------------------------\n            void ApplyWrapMode(GLenum target, ChilliSource::TextureWrapMode wrapModeS, ChilliSource::TextureWrapMode wrapModeT)\n            {\n                switch(wrapModeS)\n                {\n                    case ChilliSource::TextureWrapMode::k_clamp:\n                        glTexParameteri(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);\n                        break;\n                    case ChilliSource::TextureWrapMode::k_repeat:\n                        glTexParameteri(target, GL_TEXTURE_WRAP_S, GL_REPEAT);\n                        break;\n                };\n                \n                switch(wrapModeT)\n                {\n                    case ChilliSource::TextureWrapMode::k_clamp:\n                        glTexParameteri(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);\n                        break;\n                    case ChilliSource::TextureWrapMode::k_repeat:\n                        glTexParameteri(target, GL_TEXTURE_WRAP_T, GL_REPEAT);\n                        break;\n                };\n                \n                CS_ASSERT_NOGLERROR(\"An OpenGL error occurred while applying texture wrap mode.\");\n            }\n            \n            //------------------------------------------------------------------------------\n            void ApplyFilterMode(GLenum target, ChilliSource::TextureFilterMode filterMode, bool mipmappingEnabled)\n            {\n                if(mipmappingEnabled == false)\n                {\n                    switch(filterMode)\n                    {\n                        case ChilliSource::TextureFilterMode::k_nearest:\n                            glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);\n                            glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);\n                            break;\n                        case ChilliSource::TextureFilterMode::k_bilinear:\n                            glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_LINEAR);\n                            glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_LINEAR);\n                            break;\n                    }\n                }\n                else\n                {\n                    switch(filterMode)\n                    {\n                        case ChilliSource::TextureFilterMode::k_nearest:\n                            glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST);\n                            glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);\n                            break;\n                        case ChilliSource::TextureFilterMode::k_bilinear:\n                            glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);\n                            glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_LINEAR);\n                            break;\n                    }\n                }\n                \n                CS_ASSERT_NOGLERROR(\"An OpenGL error occurred while applying texture filter mode.\");\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "Source/CSBackend/Rendering/OpenGL/Texture/GLTextureUtils.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CSBACKEND_RENDERING_OPENGL_TEXTURE_GLTEXTUREUTILS_H_\n#define _CSBACKEND_RENDERING_OPENGL_TEXTURE_GLTEXTUREUTILS_H_\n\n#include <CSBackend/Rendering/OpenGL/ForwardDeclarations.h>\n#include <CSBackend/Rendering/OpenGL/Base/GLIncludes.h>\n\n#include <ChilliSource/ChilliSource.h>\n\nnamespace CSBackend\n{\n    namespace OpenGL\n    {\n        namespace GLTextureUtils\n        {\n            /// Uploads the given uncompressed image data to texture memory.\n            ///\n            /// @param target\n            ///     Texture target - 2D or specific cubemap face, etc\n            /// @param format\n            ///     The format of the image data.\n            /// @param dimensions\n            ///     The image dimensions.\n            /// @param imageData\n            ///     The image data.\n            ///\n            void UploadImageDataNoCompression(GLenum target, ChilliSource::ImageFormat format, const ChilliSource::Integer2& dimensions, const u8* imageData);\n            \n            /// Uploads the given ETC1 image data to texture memory.\n            ///\n            /// @param target\n            ///     Texture target - 2D or specific cubemap face, etc\n            /// @param format\n            ///     The format of the image data.\n            /// @param dimensions\n            ///     The image dimensions.\n            /// @param imageData\n            ///     The image data.\n            /// @param imageDataSize\n            ///     The size, in bytes, of the image data.\n            ///\n            void UploadImageDataETC1(GLenum target, ChilliSource::ImageFormat format, const ChilliSource::Integer2& dimensions, const u8* imageData, u32 imageDataSize);\n            \n            /// Uploads the given PVR2 image data to texture memory.\n            ///\n            /// @param target\n            ///     Texture target - 2D or specific cubemap face, etc\n            /// @param format\n            ///     The format of the image data.\n            /// @param dimensions\n            ///     The image dimensions.\n            /// @param imageData\n            ///     The image data.\n            /// @param imageDataSize\n            ///     The size, in bytes, of the image data.\n            ///\n            void UploadImageDataPVR2(GLenum target, ChilliSource::ImageFormat format, const ChilliSource::Integer2& dimensions, const u8* imageData, u32 imageDataSize);\n            \n            /// Uploads the given PVR4 image data to texture memory.\n            ///\n            /// @param target\n            ///     Texture target - 2D or specific cubemap face, etc\n            /// @param format\n            ///     The format of the image data.\n            /// @param dimensions\n            ///     The image dimensions.\n            /// @param imageData\n            ///     The image data.\n            /// @param imageDataSize\n            ///     The size, in bytes, of the image data.\n            ///\n            void UploadImageDataPVR4(GLenum target, ChilliSource::ImageFormat format, const ChilliSource::Integer2& dimensions, const u8* imageData, u32 imageDataSize);\n            \n            /// Applies the given wrap mode to the currently bound texture.\n            ///\n            /// @param target\n            ///     Texture target - 2D or specific cubemap face, etc\n            /// @param wrapModeS\n            ///     The s-coordinate wrap mode of the texture.\n            /// @param wrapModeT\n            ///     The t-coordinate wrap mode of the texture.\n            ///\n            void ApplyWrapMode(GLenum target, ChilliSource::TextureWrapMode wrapModeS, ChilliSource::TextureWrapMode wrapModeT);\n            \n            /// Applies the given texture filter mode to the currently bound texture.\n            ///\n            /// @param target\n            ///     Texture target - 2D or specific cubemap face, etc\n            /// @param filterMode\n            ///     The filter mode of the texutre\n            /// @param mipmappingEnabled\n            ///     Whether or not mipmapping is enabled for the texture.\n            ///\n            void ApplyFilterMode(GLenum target, ChilliSource::TextureFilterMode filterMode, bool mipmappingEnabled);\n        }\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Audio/CricketAudio/CkAudioPlayer.cpp",
    "content": "//\n//  CkAudioPlayer.cpp\n//  ChilliSource\n//  Created by Ian Copland on 30/12/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n//NOTE: Cricket does not have RPi support\n#ifndef CS_TARGETPLATFORM_RPI\n\n#include <ChilliSource/Audio/CricketAudio/CkAudioPlayer.h>\n\n#include <ChilliSource/Audio/CricketAudio/CkSound.h>\n#include <ChilliSource/Audio/CricketAudio/CricketAudioSystem.h>\n#include <ChilliSource/Core/Base/Application.h>\n\nnamespace ChilliSource\n{\n    CS_DEFINE_NAMEDTYPE(CkAudioPlayer);\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    CkAudioPlayerUPtr CkAudioPlayer::Create()\n    {\n        return CkAudioPlayerUPtr(new CkAudioPlayer());\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    bool CkAudioPlayer::IsA(InterfaceIDType in_interfaceId) const\n    {\n        return (CkAudioPlayer::InterfaceID == in_interfaceId);\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    f32 CkAudioPlayer::GetEffectVolume() const\n    {\n        return m_effectVolume;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void CkAudioPlayer::SetEffectVolume(f32 in_volume)\n    {\n        m_effectVolume = in_volume;\n        \n        for (auto& effectInfo : m_effects)\n        {\n            if (effectInfo.m_effect->GetPlaybackState() == CkSound::PlaybackState::k_playing)\n            {\n                effectInfo.m_effect->SetVolume(m_effectVolume * effectInfo.m_volume);\n            }\n        }\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    f32 CkAudioPlayer::GetMusicVolume() const\n    {\n        return m_musicVolume;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void CkAudioPlayer::SetMusicVolume(f32 in_volume)\n    {\n        m_musicVolume = in_volume;\n        \n        if (m_music != nullptr && m_music->GetPlaybackState() == CkSound::PlaybackState::k_playing)\n        {\n            m_music->SetVolume(m_musicVolume);\n        }\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void CkAudioPlayer::PlayEffect(const CkBankCSPtr& in_bank, const std::string& in_effectName, f32 in_volume)\n    {\n        EffectInfo effectInfo;\n        effectInfo.m_volume = in_volume;\n        effectInfo.m_effect = CkSound::CreateFromBank(in_bank, in_effectName);\n        \n        effectInfo.m_effect->SetVolume(m_effectVolume * effectInfo.m_volume);\n        effectInfo.m_effect->Play(CkSound::PlaybackMode::k_once, [=](const CkSound* in_audio)\n        {\n            m_effectsToRemove.push_back(in_audio);\n        });\n        \n        m_effects.push_back(std::move(effectInfo));\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void CkAudioPlayer::PlayMusic(StorageLocation in_storageLocation, const std::string& in_filePath)\n    {\n        m_music = CkSound::CreateFromStream(in_storageLocation, in_filePath);\n        m_music->SetVolume(m_musicVolume);\n        m_music->Play(CkSound::PlaybackMode::k_loop);\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void CkAudioPlayer::StopMusic()\n    {\n        if (m_music != nullptr)\n        {\n            m_music.reset();\n        }\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void CkAudioPlayer::OnInit()\n    {\n        CS_ASSERT(Application::Get()->GetSystem<CricketAudioSystem>() != nullptr, \"CkAudioPlayer missing required system: CricketAudioSystem.\");\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void CkAudioPlayer::OnResume()\n    {\n        for (auto& effectInfo : m_effects)\n        {\n            if (effectInfo.m_effect->GetPlaybackState() == CkSound::PlaybackState::k_paused)\n            {\n                effectInfo.m_effect->Resume();\n            }\n        }\n        \n        if (m_music != nullptr && m_music->GetPlaybackState() == CkSound::PlaybackState::k_paused)\n        {\n            m_music->Resume();\n        }\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void CkAudioPlayer::OnUpdate(f32 in_deltaTime)\n    {\n        for (auto& removable : m_effectsToRemove)\n        {\n            for (auto it = m_effects.begin(); it != m_effects.end();)\n            {\n                if (it->m_effect.get() == removable)\n                {\n                    it = m_effects.erase(it);\n                    break;\n                }\n                else\n                {\n                    ++it;\n                }\n            }\n        }\n        m_effectsToRemove.clear();\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void CkAudioPlayer::OnSuspend()\n    {\n        if (m_music != nullptr && m_music->GetPlaybackState() == CkSound::PlaybackState::k_playing)\n        {\n            m_music->Pause();\n        }\n        \n        for (auto& effectInfo : m_effects)\n        {\n            if (effectInfo.m_effect->GetPlaybackState() == CkSound::PlaybackState::k_playing)\n            {\n                effectInfo.m_effect->Pause();\n            }\n        }\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void CkAudioPlayer::OnDestroy()\n    {\n        m_effects.clear();\n        m_effectsToRemove.clear();\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    CkAudioPlayer::EffectInfo::EffectInfo(EffectInfo&& in_moveable)\n    {\n        m_volume = in_moveable.m_volume;\n        m_effect = std::move(in_moveable.m_effect);\n\n        in_moveable.m_volume = 0.0f;\n        in_moveable.m_effect = nullptr;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    CkAudioPlayer::EffectInfo& CkAudioPlayer::EffectInfo::operator=(CkAudioPlayer::EffectInfo&& in_moveable)\n    {\n        m_volume = in_moveable.m_volume;\n        m_effect = std::move(in_moveable.m_effect);\n\n        in_moveable.m_volume = 0.0f;\n        in_moveable.m_effect = nullptr;\n\n        return *this;\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Audio/CricketAudio/CkAudioPlayer.h",
    "content": "//\n//  CkAudioPlayer.h\n//  ChilliSource\n//  Created by Ian Copland on 30/12/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n//NOTE: Cricket does not have RPi support\n#ifndef CS_TARGETPLATFORM_RPI\n\n#ifndef _CHILLISOURCE_AUDIO_CRICKETAUDIO_CKAUDIOPLAYER_H_\n#define _CHILLISOURCE_AUDIO_CRICKETAUDIO_CKAUDIOPLAYER_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/System/StateSystem.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    /// A state system which simplies playback of basic audio using the Cricket\n    /// audio system. This allows playback of throw-away sound effects and a single\n    /// music track. Effects can be played and forgotten about since the system\n    /// will deal with cleaning them up when finished. Music will continue to loop\n    /// until the track is replaced or StopMusic() is called.\n    ///\n    /// Effects and music played through this system adhere to the State life cycle\n    /// and will be paused while the owning state is inactive and cleaned up when\n    /// the state is destroyed.\n    ///\n    /// Cricket Technology has kindly allows us to include the Cricket Audio SDK\n    /// in the engine under the free license. For more information see the\n    /// documentation for CricketAudioSystem.\n    ///\n    /// @author Ian Copland\n    //------------------------------------------------------------------------------\n    class CkAudioPlayer final : public StateSystem\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(CkAudioPlayer);\n        //------------------------------------------------------------------------------\n        /// Allows querying of whether or not this system implements the interface\n        /// described by the given interface Id. Typically this is not called directly\n        /// as the templated equivalent IsA<Interface>() is preferred.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The interface Id.\n        ///\n        /// @return Whether or not the interface is implemented.\n        //------------------------------------------------------------------------------\n        bool IsA(InterfaceIDType in_interfaceId) const override;\n        //------------------------------------------------------------------------------\n        /// @author Nicolas Tanda\n        ///\n        /// @return The current global volume of effects.\n        //------------------------------------------------------------------------------\n        f32 GetEffectVolume() const;\n        //------------------------------------------------------------------------------\n        /// Sets the global volume of effects, affecting currently playing effects.\n        /// This takes into account the volume that effects were initially\n        /// played with, i.e, if the passed volume is 0.5 and the effect is played\n        /// with a volume of 0.5 the actual volume the effect is played at will be 0.25.\n        ///\n        /// @author Nicolas Tanda\n        ///\n        /// @param The volume of the effects, between 0.0 and 1.0\n        //------------------------------------------------------------------------------\n        void SetEffectVolume(f32 in_volume);\n        //------------------------------------------------------------------------------\n        /// @author Nicolas Tanda\n        ///\n        /// @return The current volume of the music.\n        //------------------------------------------------------------------------------\n        f32 GetMusicVolume() const;\n        //------------------------------------------------------------------------------\n        /// Sets the global volume of music, also affecting currently playing music.\n        ///\n        /// @author Nicolas Tanda\n        ///\n        /// @param The volume of the music, between 0.0 and 1.0\n        //------------------------------------------------------------------------------\n        void SetMusicVolume(f32 in_volume);\n        //------------------------------------------------------------------------------\n        /// Plays the requested sound effect from the given bank once, with the given\n        /// volume. The effect will be automatically cleaned up once finished. If the\n        /// requested effect doesn't exist the app is considered to be in an\n        /// irrecoverable state and will terminate.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The bank the sound effect is in. Cannot be null.\n        /// @param The name of the sound effect.\n        /// @param [Optional] The volume of the sound effect. Defaults to 1.0.\n        //------------------------------------------------------------------------------\n        void PlayEffect(const CkBankCSPtr& in_bank, const std::string& in_effectName, f32 in_volume = 1.0f);\n        //------------------------------------------------------------------------------\n        /// Plays the requested music stream. This will loop until a new music track\n        /// is played or StopMusic() is called. If the requested stream doesn't exist\n        /// the app is considered to be in an irrecoverable state and will terminate.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The storage location of the music stream.\n        /// @param The file path of the music stream.\n        //------------------------------------------------------------------------------\n        void PlayMusic(StorageLocation in_storageLocation, const std::string& in_filePath);\n        //------------------------------------------------------------------------------\n        /// Stops the currently playing music track. Does nothing if there is no track\n        /// playing.\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------------------------------------\n        void StopMusic();\n        \n    private:\n        friend class State;\n        //------------------------------------------------------------------------------\n        /// A container for information on a playing effect.\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------------------------------------\n        struct EffectInfo\n        {\n            CkSoundUPtr m_effect;\n            f32 m_volume = 0.0f;\n\n            //------------------------------------------------------------------------------\n            /// Default constructor\n            ///\n            /// @author Ian Copland\n            //------------------------------------------------------------------------------\n            EffectInfo() = default;\n            //------------------------------------------------------------------------------\n            /// Move Constructor. This is required because it is not automatically generated \n            /// in Visual C++ 12.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param The value to move.\n            //------------------------------------------------------------------------------\n            EffectInfo(EffectInfo&& in_moveable);\n            //------------------------------------------------------------------------------\n            /// Move operator. This is required because it is not automatically generated \n            /// in Visual C++ 12.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param The value to move.\n            ///\n            /// @param A reference to this.\n            //------------------------------------------------------------------------------\n            EffectInfo& operator=(EffectInfo&& in_moveable);\n        };\n        //------------------------------------------------------------------------------\n        /// A factory method for creating new instances of the system.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @return The new instance.\n        //------------------------------------------------------------------------------\n        static CkAudioPlayerUPtr Create();\n        //------------------------------------------------------------------------------\n        /// Default constructor. Declared private to ensure the system is created\n        /// through State::CreateSystem<CkAudioPlayer>().\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------------------------------------\n        CkAudioPlayer() = default;\n        //------------------------------------------------------------------------------\n        /// Initialises the audio player.\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------------------------------------\n        void OnInit() override;\n        //------------------------------------------------------------------------------\n        /// Resumes any previously playing effects or music.\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------------------------------------\n        void OnResume() override;\n        //------------------------------------------------------------------------------\n        /// Cleans up any finished sound effects.\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------------------------------------\n        void OnUpdate(f32 in_deltaTime) override;\n        //------------------------------------------------------------------------------\n        /// Pauses any currently playing music and effects.\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------------------------------------\n        void OnSuspend() override;\n        //------------------------------------------------------------------------------\n        /// Cleans up any music and effects.\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------------------------------------\n        void OnDestroy() override;\n        \n        std::vector<EffectInfo> m_effects;\n        std::vector<const CkSound*> m_effectsToRemove;\n        CkSoundUPtr m_music;\n        f32 m_musicVolume = 1.0f;\n        f32 m_effectVolume = 1.0f;\n    };\n}\n\n#endif\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Audio/CricketAudio/CkBank.cpp",
    "content": "//\n//  CkBank.cpp\n//  ChilliSource\n//  Created by Ian Copland on 30/12/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n//NOTE: Cricket does not have RPi support\n#ifndef CS_TARGETPLATFORM_RPI\n\n#include <ChilliSource/Audio/CricketAudio/CkBank.h>\n\n#include <ck/ck.h>\n#include <ck/bank.h>\n\nnamespace ChilliSource\n{\n    CS_DEFINE_NAMEDTYPE(CkBank);\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    CkBankUPtr CkBank::Create()\n    {\n        return CkBankUPtr(new CkBank());\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    bool CkBank::IsA(InterfaceIDType in_interfaceId) const\n    {\n        return (CkBank::InterfaceID == in_interfaceId);\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void CkBank::Build(::CkBank* in_CkAudioBank, std::unique_ptr<u8[]> in_bankBuffer)\n    {\n        CS_ASSERT(m_bank == nullptr, \"Cannot call Build() on a CkBank more than once.\");\n        CS_ASSERT(in_CkAudioBank != nullptr, \"Cannot Build() a CkBank with a null bank pointer.\");\n\n        m_bank = in_CkAudioBank;\n        m_bankBuffer = std::move(in_bankBuffer);\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    ::CkBank* CkBank::GetBank() const\n    {\n        CS_ASSERT(m_bank != nullptr, \"Bank has not yet been built!\");\n\n        return m_bank;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    CkBank::~CkBank()\n    {\n        if (m_bank != nullptr)\n        {\n            m_bank->destroy();\n            m_bank = nullptr;\n\n            m_bankBuffer.reset();\n        }\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Audio/CricketAudio/CkBank.h",
    "content": "//\n//  CkBank.h\n//  ChilliSource\n//  Created by Ian Copland on 30/12/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n//NOTE: Cricket does not have RPi support\n#ifndef CS_TARGETPLATFORM_RPI\n\n#ifndef _CHILLISOURCE_AUDIO_CRICKETAUDIO_CKAUDIOBANK_H_\n#define _CHILLISOURCE_AUDIO_CRICKETAUDIO_CKAUDIOBANK_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Resource/Resource.h>\n#include <ChilliSource/Audio/CricketAudio/CkForwardDeclarations.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    /// A Cricket Audio bank resource. This contains a group of sounds which are\n    /// loaded as a batch. Individual sounds can be played by creating a CkSound\n    /// with a bank or through the CkAudioPlayer.\n    ///\n    /// Cricket Technology has kindly allows us to include the Cricket Audio SDK\n    /// in the engine under the free license. For more information see the\n    /// documentation for CricketAudioSystem.\n    ///\n    /// @author Ian Copland\n    //------------------------------------------------------------------------------\n    class CkBank final : public Resource\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(CkBank);\n        //------------------------------------------------------------------------------\n        /// Allows querying of whether or not this system implements the interface\n        /// described by the given interface Id. Typically this is not called directly\n        /// as the templated equivalent IsA<Interface>() is preferred.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The interface Id.\n        ///\n        /// @return Whether or not the interface is implemented.\n        //------------------------------------------------------------------------------\n        bool IsA(InterfaceIDType in_interfaceId) const override;\n        //------------------------------------------------------------------------------\n        /// Populates the resource with the Cricket Audio bank that it represents. This\n        /// can only be called once, if a call to this is repeated the app is considered\n        /// to be in an irrecoverable state and will terminate.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param in_ckBank - The cricket audio sound bank that this resource\n        /// represents. Cannot be null. This will take ownership of the bank and release\n        /// it when it has finished with it.\n        /// @param in_bankBuffer - [Optional] The memory buffer associated with the bank.\n        /// This is only relevant if the bank is loaded from memory and should be null\n        /// otherwise. The buffer will be de-allocated along with the bank. Defaults to\n        /// null.\n        //------------------------------------------------------------------------------\n        void Build(::CkBank* in_ckBank, std::unique_ptr<u8[]> in_bankBuffer = nullptr);\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return A pointer to the underlying sound bank. This retains ownership of the\n        /// bank so it must not be destroyed.\n        //------------------------------------------------------------------------------\n        ::CkBank* GetBank() const;\n        //------------------------------------------------------------------------------\n        /// Destructor.\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------------------------------------\n        ~CkBank();\n    private:\n        friend class ResourcePool;\n        //------------------------------------------------------------------------------\n        /// Factory method for creating a new instance of the resource. \n        ///\n        /// @author Ian Copland\n        ///\n        /// @return The new resource instance.\n        //------------------------------------------------------------------------------\n        static CkBankUPtr Create();\n        //------------------------------------------------------------------------------\n        /// Default constructor. This is declared private to ensure this is only ever\n        /// created via the Resource Pool.\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------------------------------------\n        CkBank() = default;\n\n        ::CkBank* m_bank = nullptr;\n        std::unique_ptr<u8[]> m_bankBuffer;\n    };\n}\n\n#endif\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Audio/CricketAudio/CkBankProvider.cpp",
    "content": "//\n//  CkBankProvider.cpp\n//  ChilliSource\n//  Created by Ian Copland on 30/12/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n//NOTE: Cricket does not have RPi support\n#ifndef CS_TARGETPLATFORM_RPI\n\n#include <ChilliSource/Audio/CricketAudio/CkBankProvider.h>\n\n#include <ChilliSource/Audio/CricketAudio/CkBank.h>\n#include <ChilliSource/Audio/CricketAudio/CricketAudioSystem.h>\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/Threading/TaskScheduler.h>\n\n#include <ck/ck.h>\n#include <ck/bank.h>\n\nnamespace ChilliSource\n{\n    namespace\n    {\n        const char k_bankExtension[] = \"ckb\";\n    }\n\n    CS_DEFINE_NAMEDTYPE(CkBankProvider);\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    CkBankProviderUPtr CkBankProvider::Create()\n    {\n        return CkBankProviderUPtr(new CkBankProvider());\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    bool CkBankProvider::IsA(InterfaceIDType in_interfaceId) const\n    {\n        return (ResourceProvider::InterfaceID == in_interfaceId || CkBankProvider::InterfaceID == in_interfaceId);\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    InterfaceIDType CkBankProvider::GetResourceType() const\n    {\n        return CkBank::InterfaceID;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    bool CkBankProvider::CanCreateResourceWithFileExtension(const std::string& in_extension) const\n    {\n        std::string lowerExtension = in_extension;\n        StringUtils::ToLowerCase(lowerExtension);\n\n        return (lowerExtension == k_bankExtension);\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void CkBankProvider::CreateResourceFromFile(StorageLocation in_storageLocation, const std::string& in_filePath, const IResourceOptionsBaseCSPtr& in_options, const ResourceSPtr& out_resource)\n    {\n        auto fileSystem = Application::Get()->GetFileSystem();\n\n        ::CkBank* bank = nullptr;\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n        if (in_storageLocation == StorageLocation::k_package || in_storageLocation == StorageLocation::k_chilliSource ||\n            (in_storageLocation == StorageLocation::k_DLC && fileSystem->DoesFileExistInCachedDLC(in_filePath) == false))\n        {\n            m_zippedCkBankLoader.Load(in_storageLocation, in_filePath, out_resource);\n            return;\n        }\n        else\n        {\n            auto absFilePath = fileSystem->GetAbsolutePathToStorageLocation(in_storageLocation) + in_filePath;\n            bank = ::CkBank::newBank(absFilePath.c_str(), kCkPathType_FileSystem);\n        }\n#else\n        if (in_storageLocation == StorageLocation::k_DLC && fileSystem->DoesFileExistInCachedDLC(in_filePath) == false)\n        {\n            auto absFilePath = fileSystem->GetAbsolutePathToStorageLocation(StorageLocation::k_package) + fileSystem->GetPackageDLCPath() + in_filePath;\n            bank = ::CkBank::newBank(absFilePath.c_str(), kCkPathType_FileSystem);\n        }\n        else\n        {\n            auto absFilePath = fileSystem->GetAbsolutePathToStorageLocation(in_storageLocation) + in_filePath;\n            bank = ::CkBank::newBank(absFilePath.c_str(), kCkPathType_FileSystem);\n        }\n#endif\n\n        if (bank == nullptr)\n        {\n            out_resource->SetLoadState(Resource::LoadState::k_failed);\n            return;\n        }\n        \n        static_cast<CkBank*>(out_resource.get())->Build(bank);\n        out_resource->SetLoadState(Resource::LoadState::k_loaded);\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void CkBankProvider::CreateResourceFromFileAsync(StorageLocation in_storageLocation, const std::string& in_filePath, const IResourceOptionsBaseCSPtr& in_options, const AsyncLoadDelegate& in_delegate, const ResourceSPtr& out_resource)\n    {\n        auto fileSystem = Application::Get()->GetFileSystem();\n\n        ::CkBank* bank = nullptr;\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n        if (in_storageLocation == StorageLocation::k_package || in_storageLocation == StorageLocation::k_chilliSource ||\n            (in_storageLocation == StorageLocation::k_DLC && fileSystem->DoesFileExistInCachedDLC(in_filePath) == false))\n        {\n            m_zippedCkBankLoader.LoadAsync(in_storageLocation, in_filePath, in_delegate, out_resource);\n            return;\n        }\n        else\n        {\n            auto absFilePath = fileSystem->GetAbsolutePathToStorageLocation(in_storageLocation) + in_filePath;\n            bank = ::CkBank::newBankAsync(absFilePath.c_str(), kCkPathType_FileSystem);\n        }\n#else\n        if (in_storageLocation == StorageLocation::k_DLC && fileSystem->DoesFileExistInCachedDLC(in_filePath) == false)\n        {\n            auto absFilePath = fileSystem->GetAbsolutePathToStorageLocation(StorageLocation::k_package) + fileSystem->GetPackageDLCPath() + in_filePath;\n            bank = ::CkBank::newBankAsync(absFilePath.c_str(), kCkPathType_FileSystem);\n        }\n        else\n        {\n            auto absFilePath = fileSystem->GetAbsolutePathToStorageLocation(in_storageLocation) + in_filePath;\n            bank = ::CkBank::newBankAsync(absFilePath.c_str(), kCkPathType_FileSystem);\n        }\n#endif\n\n        if (bank != nullptr)\n        {\n            AsyncRequest request;\n            request.m_bankResource = std::static_pointer_cast<CkBank>(out_resource);\n            request.m_bank = bank;\n            request.m_delegate = in_delegate;\n            m_asyncRequests.push_back(request);\n        }\n        else\n        {\n            out_resource->SetLoadState(Resource::LoadState::k_failed);\n            in_delegate(out_resource);\n        }\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void CkBankProvider::OnInit()\n    {\n        CS_ASSERT(Application::Get()->GetSystem<CricketAudioSystem>() != nullptr, \"'CricketAudioSystem' is missing and is required by 'CkBankProvider'!\");\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void CkBankProvider::OnUpdate(f32 in_deltaTime)\n    {\n        if(m_asyncRequests.empty() == false)\n        {\n            m_asyncRequests.lock();\n            for (auto it = m_asyncRequests.begin(); it != m_asyncRequests.end();)\n            {\n                if (it->m_bank->isLoaded() == true)\n                {\n                    CS_ASSERT(it->m_bank != nullptr, \"Bank cannot be null!\");\n                    \n                    AsyncRequest request = *it;\n                    it = m_asyncRequests.erase(it);\n                    \n                    if (request.m_bank->isFailed() == false)\n                    {\n                        request.m_bankResource->Build(request.m_bank);\n                        request.m_bankResource->SetLoadState(Resource::LoadState::k_loaded);\n                        request.m_delegate(request.m_bankResource);\n                    }\n                    else\n                    {\n                        request.m_bank->destroy();\n                        request.m_bankResource->SetLoadState(Resource::LoadState::k_failed);\n                        request.m_delegate(request.m_bankResource);\n                    }\n                }\n                else\n                {\n                    ++it;\n                }\n            }\n            m_asyncRequests.unlock();\n        }\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Audio/CricketAudio/CkBankProvider.h",
    "content": "//\n//  CkBankProvider.h\n//  ChilliSource\n//  Created by Ian Copland on 30/12/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n//NOTE: Cricket does not have RPi support\n#ifndef CS_TARGETPLATFORM_RPI\n\n#ifndef _CHILLISOURCE_AUDIO_CRICKETAUDIO_CKAUDIOBANKPROVIDER_H_\n#define _CHILLISOURCE_AUDIO_CRICKETAUDIO_CKAUDIOBANKPROVIDER_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Audio/CricketAudio/CkForwardDeclarations.h>\n#include <ChilliSource/Core/Container/concurrent_vector.h>\n#include <ChilliSource/Core/Resource/ResourceProvider.h>\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n#include <CSBackend/Platform/Android/Main/JNI/Audio/CricketAudio/ZippedCkBankLoader.h>\n#endif\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    /// The resource provider for Cricket Audio sound banks. An audio bank contains\n    /// a number of audio effects that are loaded into memory as a batch. Specific \n    /// sounds within a bank can be played by creating a CkSound with the bank, or \n    /// through the CKAudioPlayer.\n    ///\n    /// This is not added to Application by default. If you need to load bank\n    /// resources you will have to add this during the Application::AddSystems()\n    /// life cycle event.\n    ///\n    /// Cricket Technology has kindly allows us to include the Cricket Audio SDK\n    /// in the engine under the free license. For more information see the\n    /// documentation for CricketAudioSystem.\n    ///\n    /// @author Ian Copland\n    //------------------------------------------------------------------------------\n    class CkBankProvider final : public ResourceProvider\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(CkBankProvider);\n        //------------------------------------------------------------------------------\n        /// Allows querying of whether or not this system implements the interface\n        /// described by the given interface Id. Typically this is not called directly\n        /// as the templated equivalent IsA<Interface>() is preferred.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The interface Id.\n        ///\n        /// @return Whether or not the interface is implemented.\n        //------------------------------------------------------------------------------\n        bool IsA(InterfaceIDType in_interfaceId) const override;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The interface Id for the resource type that this provider can \n        /// create.\n        //------------------------------------------------------------------------------\n        InterfaceIDType GetResourceType() const override;\n        //------------------------------------------------------------------------------\n        /// Allows querying of whether or not this system create resources from files \n        /// with the given extension. \n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The extension of the resource file. This is case insensitive.\n        ///\n        /// @return Whether or not the resource can be created.\n        //------------------------------------------------------------------------------\n        bool CanCreateResourceWithFileExtension(const std::string& in_extension) const override;\n        //------------------------------------------------------------------------------\n        /// Creates a new Cricket Audio bank from the described file. The load state of \n        /// the resource should be checked for success or failure.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The storage location.\n        /// @param The filepath.\n        /// @param The options to customise the creation. This should always be null for\n        /// an audio bank.\n        /// @param [Out] The output audio bank resource.\n        //------------------------------------------------------------------------------\n        void CreateResourceFromFile(StorageLocation in_storageLocation, const std::string& in_filePath, const IResourceOptionsBaseCSPtr& in_options, const ResourceSPtr& out_resource) override;\n        //------------------------------------------------------------------------------\n        /// Creates a new Cricket Audio bank from the described file asynchronously. The \n        /// load state of the resource should be checked for success or failure.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The storage location.\n        /// @param The filepath.\n        /// @param The options to customise the creation. This should always be null for\n        /// an audio bank.\n        /// @param The completion delegate.\n        /// @param [Out] The output audio bank resource.\n        //------------------------------------------------------------------------------\n        void CreateResourceFromFileAsync(StorageLocation in_storageLocation, const std::string& in_filePath, const IResourceOptionsBaseCSPtr& in_options, const AsyncLoadDelegate& in_delegate, const ResourceSPtr& out_resource) override;\n\n    private:\n        friend class Application;\n        //------------------------------------------------------------------------------\n        /// A container for information needed for asynchonous load requests.\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------------------------------------\n        struct AsyncRequest\n        {\n            ::CkBank* m_bank = nullptr;\n            CkBankSPtr m_bankResource;\n            AsyncLoadDelegate m_delegate;\n        };\n        //------------------------------------------------------------------------------\n        /// A factory method for creating a new instance of the system.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @return The new instance.\n        //------------------------------------------------------------------------------\n        static CkBankProviderUPtr Create();\n        //------------------------------------------------------------------------------\n        /// Default Constructor. This is private to ensure this can only be created\n        /// through Application::CreateSystem().\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------------------------------------\n        CkBankProvider() = default;\n        //------------------------------------------------------------------------------\n        /// Called when app systems are initialised. This simply confirms that the\n        /// CricketAudioSystem exists.\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------------------------------------\n        void OnInit() override;\n        //------------------------------------------------------------------------------\n        /// Polls to check if background loaded banks are finished loading.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The delta time.\n        //------------------------------------------------------------------------------\n        void OnUpdate(f32 in_deltaTime) override;\n        \n        concurrent_vector<AsyncRequest> m_asyncRequests;\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n        CSBackend::Android::ZippedCkBankLoader m_zippedCkBankLoader;\n#endif\n    };\n}\n\n#endif\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Audio/CricketAudio/CkForwardDeclarations.h",
    "content": "//\n//  CkForwardDeclarations.h\n//  ChilliSource\n//  Created by Ian Copland on 31/12/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_AUDIO_CRICKETAUDIO_CKFORWARDDECLARATIONS_H_\n#define _CHILLISOURCE_AUDIO_CRICKETAUDIO_CKFORWARDDECLARATIONS_H_\n\n#include <ChilliSource/Core/Base/StandardMacros.h>\n\nclass CkBank;\nclass CkSound;\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Audio/CricketAudio/CkSound.cpp",
    "content": "//\n//  CkSound.cpp\n//  ChilliSource\n//  Created by Ian Copland on 30/12/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n//NOTE: Cricket does not have RPi support\n#ifndef CS_TARGETPLATFORM_RPI\n\n#include <ChilliSource/Audio/CricketAudio/CkSound.h>\n\n#include <ChilliSource/Audio/CricketAudio/CkBank.h>\n#include <ChilliSource/Audio/CricketAudio/CricketAudioSystem.h>\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/File/TaggedFilePathResolver.h>\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n#include <CSBackend/Platform/Android/Main/JNI/Core/File/FileSystem.h>\n#endif\n\n#include <ck/ck.h>\n#include <ck/sound.h>\n\nnamespace ChilliSource\n{\n    namespace\n    {\n        const f32 k_secondsPerMillisecond = 1.0f / 1000.0f;\n    }\n    \n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    CkSoundUPtr CkSound::CreateFromBank(const CkBankCSPtr& in_audioBank, const std::string& in_audioName)\n    {\n        return CkSoundUPtr(new CkSound(in_audioBank, in_audioName));\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    CkSoundUPtr CkSound::CreateFromStream(StorageLocation in_streamStorageLocation, const std::string& in_streamFilePath)\n    {\n        return CkSoundUPtr(new CkSound(in_streamStorageLocation, in_streamFilePath));\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    CkSound::CkSound(const CkBankCSPtr& in_audioBank, const std::string& in_audioName)\n    : m_audioBank(in_audioBank)\n    {\n        CS_ASSERT(m_audioBank != nullptr, \"Cannot create CkSound with null audio bank.\");\n        CS_ASSERT(m_audioBank->GetLoadState() == Resource::LoadState::k_loaded, \"Cannot create CkSound with an audio bank that hasn't been loaded: \" + m_audioBank->GetName());\n        \n        m_sound = ::CkSound::newBankSound(m_audioBank->GetBank(), in_audioName.c_str());\n        CS_ASSERT(m_sound != nullptr, \"Could not create CkSound because sound '\" + in_audioName + \"' doesn't exist in the bank '\" + m_audioBank->GetName() + \"'.\");\n        \n        m_ckSystem = Application::Get()->GetSystem<CricketAudioSystem>();\n        CS_ASSERT(m_ckSystem != nullptr, \"CkSound requires missing system: \" + CricketAudioSystem::TypeName);\n        \n        m_ckSystem->Register(this);\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    CkSound::CkSound(StorageLocation in_streamStorageLocation, const std::string& in_streamFilePath)\n    {\n        auto fileSystem = Application::Get()->GetFileSystem();\n        auto taggedFilePath = Application::Get()->GetTaggedFilePathResolver()->ResolveFilePath(in_streamStorageLocation, in_streamFilePath);\n\n#if CS_TARGETPLATFORM_ANDROID\n        if (in_streamStorageLocation == StorageLocation::k_package || in_streamStorageLocation == StorageLocation::k_chilliSource ||\n        (in_streamStorageLocation == StorageLocation::k_DLC && fileSystem->DoesFileExistInCachedDLC(taggedFilePath) == false))\n        {\n            auto androidFS = fileSystem->Cast<CSBackend::Android::FileSystem>();\n            CS_ASSERT(androidFS != nullptr, \"Could not cast to Android file system.\");\n\n            CSBackend::Android::FileSystem::ZippedFileInfo fileInfo;\n            if (androidFS->TryGetZippedFileInfo(in_streamStorageLocation, in_streamFilePath, fileInfo) == true)\n            {\n                CS_ASSERT(fileInfo.m_isCompressed == false && fileInfo.m_size == fileInfo.m_uncompressedSize, \"Cannot stream audio file '\" + in_streamFilePath + \"' becuase it is compressed inside Apk or Apk expansion file.\");\n                CS_ASSERT(fileInfo.m_size > 0, \"Cannot stream zero size audio file: \" + in_streamFilePath);\n\n                m_sound = ::CkSound::newStreamSound(androidFS->GetZipFilePath().c_str(), kCkPathType_FileSystem, fileInfo.m_offset, fileInfo.m_size, in_streamFilePath.c_str());\n            }\n        }\n        else\n        {\n            auto absFilePath = fileSystem->GetAbsolutePathToStorageLocation(in_streamStorageLocation) + taggedFilePath;\n            m_sound = ::CkSound::newStreamSound(absFilePath.c_str(), kCkPathType_FileSystem);\n        }\n#else\n        if (in_streamStorageLocation == StorageLocation::k_DLC && fileSystem->DoesFileExistInCachedDLC(taggedFilePath) == false)\n        {\n            auto absFilePath = fileSystem->GetAbsolutePathToStorageLocation(StorageLocation::k_package) + fileSystem->GetPackageDLCPath() + taggedFilePath;\n            m_sound = ::CkSound::newStreamSound(absFilePath.c_str(), kCkPathType_FileSystem);\n        }\n        else\n        {\n            auto absFilePath = fileSystem->GetAbsolutePathToStorageLocation(in_streamStorageLocation) + taggedFilePath;\n            m_sound = ::CkSound::newStreamSound(absFilePath.c_str(), kCkPathType_FileSystem);\n        }\n#endif\n\n        CS_ASSERT(m_sound != nullptr, \"Could not create CkSound because audio stream '\" + in_streamFilePath + \"' doesn't exist.\");\n        \n        m_ckSystem = Application::Get()->GetSystem<CricketAudioSystem>();\n        CS_ASSERT(m_ckSystem != nullptr, \"CkSound requires missing system: \" + CricketAudioSystem::TypeName);\n        \n        m_ckSystem->Register(this);\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    f32 CkSound::GetVolume() const\n    {\n        return m_sound->getVolume();\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    f32 CkSound::GetPitchShift() const\n    {\n        return m_sound->getPitchShift();\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    CkSound::PlaybackState CkSound::GetPlaybackState() const\n    {\n        return m_playbackState;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    f32 CkSound::GetLength() const\n    {\n        return m_sound->getLengthMs() * k_secondsPerMillisecond;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    f32 CkSound::GetPlaybackPosition() const\n    {\n        return m_sound->getPlayPositionMs() * k_secondsPerMillisecond;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void CkSound::SetVolume(f32 in_volume)\n    {\n        m_sound->setVolume(in_volume);\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void CkSound::SetPitchShift(f32 in_pitchHalfSteps)\n    {\n        m_sound->setPitchShift(in_pitchHalfSteps);\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void CkSound::SetPlaybackPosition(f32 in_playbackPosition)\n    {\n        m_sound->setPlayPositionMs(in_playbackPosition * 1000.0f);\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void CkSound::Play(PlaybackMode in_playbackMode, const FinishedDelegate& in_finishedDelegate)\n    {\n        CS_ASSERT(m_playbackState == PlaybackState::k_stopped, \"CkSound is already playing.\");\n\n        m_playbackState = PlaybackState::k_playing;\n        m_finishedDelegate = in_finishedDelegate;\n\n        switch (in_playbackMode)\n        {\n        case PlaybackMode::k_once:\n            m_sound->setLoopCount(0);\n            break;\n        case PlaybackMode::k_loop:\n            m_sound->setLoopCount(-1);\n            break;\n        default:\n            CS_LOG_FATAL(\"Invalid playback mode.\");\n            break;\n        }\n\n        m_sound->play();\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void CkSound::Resume()\n    {\n        CS_ASSERT(m_playbackState == PlaybackState::k_paused, \"CkSound cannot be resumed when it is not paused.\");\n\n        m_playbackState = PlaybackState::k_playing;\n        m_sound->setPaused(false);\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void CkSound::Pause()\n    {\n        CS_ASSERT(m_playbackState == PlaybackState::k_playing, \"CkSound can only be paused while playing.\");\n\n        m_playbackState = PlaybackState::k_paused;\n        m_sound->setPaused(true);\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void CkSound::Stop()\n    {\n        CS_ASSERT(m_playbackState != PlaybackState::k_stopped, \"CkSound is already stopped.\");\n\n        if (m_sound->isPlaying() == true)\n        {\n            m_sound->stop();\n        }\n\n        m_playbackState = PlaybackState::k_stopped;\n\n        if (m_finishedDelegate != nullptr)\n        {\n            auto finishedDelegate = m_finishedDelegate;\n            m_finishedDelegate = nullptr;\n            finishedDelegate(this);\n        }\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void CkSound::OnUpdate()\n    {\n        if (m_playbackState == PlaybackState::k_playing)\n        {\n            if (m_sound->isReady() == true && m_sound->isPlaying() == false)\n            {\n                Stop();\n            }\n        }\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    CkSound::~CkSound()\n    {\n        m_ckSystem->Deregister(this);\n\n        if (m_playbackState != PlaybackState::k_stopped)\n        {\n            Stop();\n        }\n\n        m_sound->destroy();\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Audio/CricketAudio/CkSound.h",
    "content": "//\n//  CkSound.h\n//  ChilliSource\n//  Created by Ian Copland on 30/12/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n//NOTE: Cricket does not have RPi support\n#ifndef CS_TARGETPLATFORM_RPI\n\n#ifndef _CHILLISOURCE_AUDIO_CRICKETAUDIO_CKAUDIO_H_\n#define _CHILLISOURCE_AUDIO_CRICKETAUDIO_CKAUDIO_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Audio/CricketAudio/CkForwardDeclarations.h>\n\n#include <functional>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    /// Allows playback of a single peice of audio. This can play both audio streams\n    /// and individual peices of audio in an audio bank. Audio played though this\n    /// can be paused, stopped, looped and have different effects applied to it. If \n    /// this isn't needed the simpler CkAudioPlayer can be used instead.\n    ///\n    /// Cricket Technology has kindly allows us to include the Cricket Audio SDK\n    /// in the engine under the free license. For more information see the\n    /// documentation for CricketAudioSystem.\n    ///\n    /// @author Ian Copland\n    //------------------------------------------------------------------------------\n    class CkSound final\n    {\n    public:\n        CS_DECLARE_NOCOPY(CkSound);\n        //------------------------------------------------------------------------------\n        /// An enum that describes the current playback state of the audio.\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------------------------------------\n        enum class PlaybackState\n        {\n            k_playing,\n            k_paused,\n            k_stopped\n        };\n        //------------------------------------------------------------------------------\n        /// The playback mode for the audio.\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------------------------------------\n        enum class PlaybackMode\n        {\n            k_once,\n            k_loop\n        };\n        //------------------------------------------------------------------------------\n        /// The delegate that will be called when audio has finished playing. This\n        /// is called when audio finished naturally and when manually ended by the user\n        /// calling stop.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param A pointer to the finished audio.\n        //------------------------------------------------------------------------------\n        using FinishedDelegate = std::function<void(const CkSound* in_ckAudio)>;\n        //------------------------------------------------------------------------------\n        /// Creates a new CkSound with audio from a bank. CkSound is created in the\n        /// stopped state, call Play() to begin playback.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The audio bank. Cannot be null.\n        /// @param The name of the audio within the bank. If this not in the bank the\n        /// app is considered to be in an irrecoverable state and will terminate.\n        ///\n        /// @return The new CkSound instance.\n        //------------------------------------------------------------------------------\n        static CkSoundUPtr CreateFromBank(const CkBankCSPtr& in_audioBank, const std::string& in_audioName);\n        //------------------------------------------------------------------------------\n        /// Creates a new CkSound from an audio stream. CkSound is created in the\n        /// stopped state, call Play() to begin playback. Declared private to force the\n        /// use of the factory methods.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The storage location of the stream.\n        /// @param The file path of the stream. If the stream doesn't exist the app is\n        /// considered to be in an irrecoverable state and will terminate.\n        //------------------------------------------------------------------------------\n        static CkSoundUPtr CreateFromStream(StorageLocation in_streamStorageLocation, const std::string& in_streamFilePath);\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The current volume of the audio.\n        //------------------------------------------------------------------------------\n        f32 GetVolume() const;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The current pitch shift of the audio in half-steps.\n        //------------------------------------------------------------------------------\n        f32 GetPitchShift() const;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The current playback position of the audio in seconds.\n        //------------------------------------------------------------------------------\n        f32 GetPlaybackPosition() const;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The playback length of the audio in seconds. Note that this may\n        /// return -1 for streams if the length is unknown or the length has not yet\n        /// been calculated.\n        //------------------------------------------------------------------------------\n        f32 GetLength() const;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The current playback state of the audio.\n        //------------------------------------------------------------------------------\n        PlaybackState GetPlaybackState() const;\n        //------------------------------------------------------------------------------\n        /// Sets the current volume of the audio. This can be called both before the\n        /// audio is playing and during.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The volume.\n        //------------------------------------------------------------------------------\n        void SetVolume(f32 in_volume);\n        //------------------------------------------------------------------------------\n        /// Sets the pitch shift of the effect in half-steps. This also changes playback\n        /// speed. This can be called both before the audio is playing and during. Note\n        /// that this doesn't work for streams that are not in cks or ogg format.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The pitch shift in half-steps.\n        //------------------------------------------------------------------------------\n        void SetPitchShift(f32 in_pitchHalfSteps);\n        //------------------------------------------------------------------------------\n        /// Sets the playback position of the audio in seconds. This can be called\n        /// before the effect is playing to start at an offset, or during to skip.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The position through the audio in seconds.\n        //------------------------------------------------------------------------------\n        void SetPlaybackPosition(f32 in_playbackPosition);\n        //------------------------------------------------------------------------------\n        /// Plays the audio from the beginning, or from the playback position if one\n        /// was set. If this is called when the audio is paused or already playing the\n        /// app is considered to be in an irrecoverable state and will terminate.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param [Optional] The playback mode. Defaults to Once.\n        /// @param [Optional] The delegate that will be called when the audio finishes \n        /// playing. This is called even if the audio is manually ended by calling \n        /// Stop(). Can be, and defaults to null.\n        //------------------------------------------------------------------------------\n        void Play(PlaybackMode in_playbackMode = PlaybackMode::k_once, const FinishedDelegate& in_finishedDelegate = nullptr);\n        //------------------------------------------------------------------------------\n        /// Resumes the audio if it was paused, otherwise the app is considered to be\n        /// in an irrecoverable state and will terminate.\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------------------------------------\n        void Resume();\n        //------------------------------------------------------------------------------\n        /// Pauses the audio if it is currently playing, otherwise the app is considered \n        /// to be in an irrecoverable state and will terminate.\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------------------------------------\n        void Pause();\n        //------------------------------------------------------------------------------\n        /// Stops the audio if it is currently playing or paused, otherwise the app is\n        /// considered to be in an irrecoverable state and will terminate.\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------------------------------------\n        void Stop();\n        //------------------------------------------------------------------------------\n        /// Destructor. Cleans up the underlying CkSound. All CkSound instances must\n        /// be destroyed before the end of the application OnDestroy() event, otherwise\n        /// Bank and Stream resource references will still be held when destroying \n        /// the resource pool.\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------------------------------------\n        ~CkSound();\n    private:\n        friend class CricketAudioSystem;\n        //------------------------------------------------------------------------------\n        /// Constructor. Creates this with a peice of audio from an audio bank. Audio\n        /// is created in the stopped state, call Play() to begin playback. Declared\n        /// private to force the use of the factory methods.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The audio bank. Cannot be null.\n        /// @param The name of the audio within the bank. If this not in the bank the\n        /// app is considered to be in an irrecoverable state and will terminate.\n        //------------------------------------------------------------------------------\n        CkSound(const CkBankCSPtr& in_audioBank, const std::string& in_audioName);\n        //------------------------------------------------------------------------------\n        /// Constructor. Creates this with a peice of audio from a stream. Audio\n        /// is created in the stopped state, call Play() to begin playback. Declared\n        /// private to force the use of the factory methods.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The storage location of the stream.\n        /// @param The file path of the stream. If the stream doesn't exist the app is\n        /// considered to be in an irrecoverable state and will terminate.\n        //------------------------------------------------------------------------------\n        CkSound(StorageLocation in_streamStorageLocation, const std::string& in_streamFilePath);\n        //------------------------------------------------------------------------------\n        /// Updates the playback state of the CkSound based on the current state of the\n        /// underlying CkSound. This should only be called by CricketAudioSystem.\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------------------------------------\n        void OnUpdate();\n\n        CricketAudioSystem* m_ckSystem = nullptr;\n        CkBankCSPtr m_audioBank;\n        ::CkSound* m_sound = nullptr;\n\n        PlaybackState m_playbackState = PlaybackState::k_stopped;\n        FinishedDelegate m_finishedDelegate = nullptr;\n    };\n}\n\n#endif\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Audio/CricketAudio/CricketAudioSystem.cpp",
    "content": "//\n//  CricketAudioSystem.cpp\n//  ChilliSource\n//  Created by Ian Copland on 30/12/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n//NOTE: Cricket does not have RPi support\n#ifndef CS_TARGETPLATFORM_RPI\n\n#include <ChilliSource/Audio/CricketAudio/CricketAudioSystem.h>\n\n#include <ChilliSource/Audio/CricketAudio/CkSound.h>\n#include <ChilliSource/Core/Container/VectorUtils.h>\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n#include <CSBackend/Platform/Android/Main/JNI/Core/Base/CoreJavaInterface.h>\n#include <CSBackend/Platform/Android/Main/JNI/Core/Java/JavaInterfaceManager.h>\n#endif\n\n#include <ck/ck.h>\n#include <ck/config.h>\n\nnamespace ChilliSource\n{\n    CS_DEFINE_NAMEDTYPE(CricketAudioSystem);\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    CricketAudioSystemUPtr CricketAudioSystem::Create()\n    {\n        return CricketAudioSystemUPtr(new CricketAudioSystem());\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    bool CricketAudioSystem::IsA(InterfaceIDType in_interfaceId) const\n    {\n        return (CricketAudioSystem::InterfaceID == in_interfaceId);\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void CricketAudioSystem::Register(CkSound* in_ckAudio)\n    {\n        CS_ASSERT(VectorUtils::Contains(m_ckAudioList, in_ckAudio) == false, \"The given CkSound is already registered with the CricketAudioSystem!\");\n\n        m_ckAudioList.push_back(in_ckAudio);\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void CricketAudioSystem::Deregister(CkSound* in_ckAudio)\n    {\n        VectorUtils::Remove(m_ckAudioList, in_ckAudio);\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void CricketAudioSystem::OnInit()\n    {\n#if CS_TARGETPLATFORM_ANDROID\n        auto coreJI = CSBackend::Android::JavaInterfaceManager::GetSingletonPtr()->GetJavaInterface<CSBackend::Android::CoreJavaInterface>();\n        CS_ASSERT(coreJI != nullptr, \"Must have access to the core native interface to setup Cricket Audio.\");\n\n        CkConfig config(CSBackend::Android::JavaInterfaceManager::GetSingletonPtr()->GetJNIEnvironmentPtr(), coreJI->GetActivity());\n        CkInit(&config);\n#else \n        CkConfig config;\n        CkInit(&config);\n#endif\n        //Print the license info.\n        CS_LOG_VERBOSE(\"=================\");\n        CS_LOG_VERBOSE(\"= Cricket Audio =\");\n        CS_LOG_VERBOSE(\"=================\");\n        CS_LOG_VERBOSE(\" \");\n        CS_LOG_VERBOSE(\"ChilliSource has obtained special permission to include Cricket Audio as\");\n        CS_LOG_VERBOSE(\"part of the engine. See the documentation on CricketAudioSystem for details \");\n        CS_LOG_VERBOSE(\"on how to use Cricket Audio. You are free to use Cricket Audio as part of \");\n        CS_LOG_VERBOSE(\"ChilliSource within your app subject to the Cricket Audio free license\");\n        CS_LOG_VERBOSE(\"(http://www.crickettechnology.com/free_license) as outline below:\");\n        CS_LOG_VERBOSE(\" \");\n        CS_LOG_VERBOSE(\"Cricket Audio free license\");\n        CS_LOG_VERBOSE(\" \");\n        CS_LOG_VERBOSE(\"Cricket Audio is available FREE in binary form for iOS, Android, Windows\");\n        CS_LOG_VERBOSE(\"Phone 8, OS X, Windows, and Linux.\");\n        CS_LOG_VERBOSE(\" \");\n        CS_LOG_VERBOSE(\"This free license has a few requirements:\");\n        CS_LOG_VERBOSE(\" \");\n        CS_LOG_VERBOSE(\" * Include the following message somewhere in your app, visible to users\");\n        CS_LOG_VERBOSE(\"   (for example, on a credits screen):\");\n        CS_LOG_VERBOSE(\"                     Built with Cricket Audio\");\n        CS_LOG_VERBOSE(\"                     www.crickettechnology.com\");\n        CS_LOG_VERBOSE(\" \");\n        CS_LOG_VERBOSE(\" * You may optionally include our logo (available in .svg or .png format).\");\n        CS_LOG_VERBOSE(\" \");\n        CS_LOG_VERBOSE(\" * Do not distribute our software to anyone, or post it for download on any\");\n        CS_LOG_VERBOSE(\"   site; refer them to our website instead. This license does not permit\");\n        CS_LOG_VERBOSE(\"   you to distribute Cricket Audio in an SDK, library, or other software\");\n        CS_LOG_VERBOSE(\"   development product. Contact us at info@crickettechnology.com for\");\n        CS_LOG_VERBOSE(\"   additional licensing options.\");\n        CS_LOG_VERBOSE(\" \");\n        CS_LOG_VERBOSE(\" * If you release an app that uses Cricket Audio, you must let Cricket\");\n        CS_LOG_VERBOSE(\"   Technology know. Cricket Technology will include a link to it on our\");\n        CS_LOG_VERBOSE(\"   customers page.\");\n        CS_LOG_VERBOSE(\" \");\n        CS_LOG_VERBOSE(\"If you do not want to include the credit in your app, or if you do not want\");\n        CS_LOG_VERBOSE(\"to notify us of your app's release, or if you want the source code, you can\");\n        CS_LOG_VERBOSE(\"purchase a source code license (http://www.crickettechnology.com/source_license).\");\n        CS_LOG_VERBOSE(\" \");\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void CricketAudioSystem::OnResume()\n    {\n        CkResume();\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void CricketAudioSystem::OnUpdate(f32 in_deltaTime)\n    {\n        CkUpdate();\n\n        for (auto& ckAudio : m_ckAudioList)\n        {\n            ckAudio->OnUpdate();\n        }\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void CricketAudioSystem::OnSuspend()\n    {\n        CkSuspend();\n    }\t\t\t\n    //------------------------------------------------------------------------------\n    // The Cricket Audio system is shutdown in the destructor rather then OnDestroy\n    // becuase the resource cleanup phase is immediately after OnDestroy. If\n    // showdown occurs before this, any remaining CkBank resources will not be\n    // destroyed correctly.\n    //------------------------------------------------------------------------------\n    CricketAudioSystem::~CricketAudioSystem()\n    {\n        CkShutdown();\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Audio/CricketAudio/CricketAudioSystem.h",
    "content": "//\n//  CricketAudioSystem.h\n//  ChilliSource\n//  Created by Ian Copland on 30/12/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n//NOTE: Cricket does not have RPi support\n#ifndef CS_TARGETPLATFORM_RPI\n\n#ifndef _CHILLISOURCE_AUDIO_CRICKETAUDIO_CKSYSTEM_H_\n#define _CHILLISOURCE_AUDIO_CRICKETAUDIO_CKSYSTEM_H_\n\n#include <ChilliSource/ChilliSource.h>\n\n#include <ChilliSource/Core/System/AppSystem.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    /// The Cricket Audio system. This manages the underlying cricket audio system,\n    /// initialising it and destroying when needed. \n    ///\n    /// The Cricket Audio systems, including this, are not added to Application by\n    /// default. If you intend to use Cricket Audio you will need to add CricketAudioSystem,\n    /// and CkBankProvider during the Application::AddSystems() life cycle event.\n    /// You will also need to add CkAudioPlayer during the State::AddSystems() life\n    /// cycle event for any states in which you wish to use it.\n    ///\n    /// ChilliSource has obtained special permission to include Cricket Audio as\n    /// part of the engine. You are free to use Cricket Audio as part of Chilli\n    /// Source within your app subject to the Cricket Audio free license\n    /// (http://www.crickettechnology.com/free_license) as outline below:\n    ///\n    /// Cricket Audio free license\n    ///\n    /// Cricket Audio is available FREE in binary form for iOS, Android, Windows\n    /// Phone 8, OS X, Windows, and Linux.\n    ///\n    /// This free license has a few requirements:\n    ///\n    /// * Include the following message somewhere in your app, visible to users\n    ///   (for example, on a credits screen):\n    ///                     Built with Cricket Audio\n    ///                     www.crickettechnology.com\n    ///\n    /// * You may optionally include our logo (available in .svg or .png format).\n    ///\n    /// * Do not distribute our software to anyone, or post it for download on any\n    ///   site; refer them to our website instead. This license does not permit\n    ///   you to distribute Cricket Audio in an SDK, library, or other software\n    ///   development product. Contact us at info@crickettechnology.com for\n    ///   additional licensing options.\n    ///\n    /// * If you release an app that uses Cricket Audio, you must let Cricket\n    ///   Technology know. Cricket Technology will include a link to it on our\n    ///   customers page.\n    ///\n    /// If you do not want to include the credit in your app, or if you do not want\n    /// to notify us of your app's release, or if you want the source code, you can\n    /// purchase a source code license (http://www.crickettechnology.com/source_license).\n    ///\n    /// @author Ian Copland\n    //------------------------------------------------------------------------------\n    class CricketAudioSystem final : public AppSystem\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(CricketAudioSystem);\n        //------------------------------------------------------------------------------\n        /// Allows querying of whether or not this system implements the interface\n        /// described by the given interface Id. Typically this is not called directly\n        /// as the templated equivalent IsA<Interface>() is preferred.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The interface Id.\n        ///\n        /// @return Whether or not the interface is implemented.\n        //------------------------------------------------------------------------------\n        bool IsA(InterfaceIDType in_interfaceId) const override;\n        //------------------------------------------------------------------------------\n        /// Destructor.\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------------------------------------\n        ~CricketAudioSystem();\n    private:\n        friend class Application;\n        friend class CkSound;\n        //------------------------------------------------------------------------------\n        /// A factory method for creating new instances of the Cricket Audio System.\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------------------------------------\n        static CricketAudioSystemUPtr Create();\n        //------------------------------------------------------------------------------\n        /// Default constructor. Declared private to ensure this can only be created\n        /// through Application::CreateSystem<CricketAudioSystem>().\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------------------------------------\n        CricketAudioSystem() = default;\n        //------------------------------------------------------------------------------\n        /// Registers a CkSound with the system so that it receives update events.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The pointer to the CkSound.\n        //------------------------------------------------------------------------------\n        void Register(CkSound* in_ckAudio);\n        //------------------------------------------------------------------------------\n        /// De-registers a CkSound from the system so that it no longer receives update\n        /// events.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The pointer to the CkSound.\n        //------------------------------------------------------------------------------\n        void Deregister(CkSound* in_ckAudio);\n        //------------------------------------------------------------------------------\n        /// Initialises the Cricket Audio system.\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------------------------------------\n        void OnInit() override;\n        //------------------------------------------------------------------------------\n        /// Resumes the Cricket Audio system, resuming any audio that was paused during\n        /// a suspend.\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------------------------------------\n        void OnResume() override;\n        //------------------------------------------------------------------------------\n        /// Updates the Cricket Audio system.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The delta time.\n        //------------------------------------------------------------------------------\n        void OnUpdate(f32 in_deltaTime) override;\n        //------------------------------------------------------------------------------\n        /// Suspends the cricket audio system. This ensures that all audio is currectly\n        /// paused while the app is not active.\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------------------------------------\n        void OnSuspend() override;\n\n        std::vector<CkSound*> m_ckAudioList;\n    };\n}\n\n#endif\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Audio/CricketAudio.h",
    "content": "//\n//  CricketAudio.h\n//  ChilliSource\n//  Created by Ian Copland on 30/12/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n\n#ifndef _CHILLISOURCE_AUDIO_CRICKETAUDIO_H_\n#define _CHILLISOURCE_AUDIO_CRICKETAUDIO_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Audio/CricketAudio/CkSound.h>\n#include <ChilliSource/Audio/CricketAudio/CkAudioPlayer.h>\n#include <ChilliSource/Audio/CricketAudio/CkBank.h>\n#include <ChilliSource/Audio/CricketAudio/CkBankProvider.h>\n#include <ChilliSource/Audio/CricketAudio/CricketAudioSystem.h>\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Audio/ForwardDeclarations.h",
    "content": "//\n//  ForwardDeclarations.h\n//  ChilliSource\n//  Created by Ian Copland on 27/02/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2011 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_AUDIO_FORWARDDECLARATIONS_H_\n#define _CHILLISOURCE_AUDIO_FORWARDDECLARATIONS_H_\n\n#include <ChilliSource/Core/Base/StandardMacros.h>\n\n#include <memory>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    /// Cricket Audio\n    //------------------------------------------------------------------------------\n    CS_FORWARDDECLARE_CLASS(CkSound);\n    CS_FORWARDDECLARE_CLASS(CkBank);\n    CS_FORWARDDECLARE_CLASS(CkBankProvider);\n    CS_FORWARDDECLARE_CLASS(CkAudioPlayer);\n    CS_FORWARDDECLARE_CLASS(CricketAudioSystem);\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/ChilliSource.h",
    "content": "//\n//  ChilliSource.h\n//  ChilliSource\n//  Created by Ian Copland on 25/02/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CHILLISOURCE_H_\n#define _CHILLISOURCE_CHILLISOURCE_H_\n\n#include <memory>\n#include <cstdint>\n\n//------------------------------------------------------------\n// Primitive types. These should be prefered over the standard\n// primitive types as they guarantee their size.\n//------------------------------------------------------------\ntypedef char         \t\ts8;\ntypedef int_least16_t\t\ts16;\ntypedef int_least32_t\t\ts32;\ntypedef int_least64_t\t\ts64;\n\ntypedef uint_least8_t\t\tu8;\ntypedef uint_least16_t\t\tu16;\ntypedef uint_least32_t\t\tu32;\ntypedef uint_least64_t\t\tu64;\n\ntypedef float\t\t\t\tf32;\ntypedef double\t\t\t\tf64;\n\ntypedef u64                 TimeIntervalSecs;\ntypedef u64                 TimeIntervalMs;\n\n#include <ChilliSource/Core/Base/StandardMacros.h>\n\n//------------------------------------------------------------\n// The forward declarations for each section of the Chilli\n// Source libraries.\n//------------------------------------------------------------\n#include <ChilliSource/Audio/ForwardDeclarations.h>\n#include <ChilliSource/Core/ForwardDeclarations.h>\n#include <ChilliSource/Input/ForwardDeclarations.h>\n#include <ChilliSource/Networking/ForwardDeclarations.h>\n#include <ChilliSource/Rendering/ForwardDeclarations.h>\n#include <ChilliSource/Social/ForwardDeclarations.h>\n#include <ChilliSource/UI/ForwardDeclarations.h>\n#include <ChilliSource/Video/ForwardDeclarations.h>\n#include <ChilliSource/Web/ForwardDeclarations.h>\n\n//------------------------------------------------------------\n// The base include files.\n//------------------------------------------------------------\n#include <ChilliSource/Core/String/ToString.h>\n#include <ChilliSource/Core/Base/Logging.h>\n\n//------------------------------------------------------------\n// A shorter version of the namespace. This should be\n// preferred over the full version unless it would cause\n// a collision with another name in the global namespace. If\n// this is the case, the preprocessor macro\n// CS_DISABLE_SHORTNAMESPACE should be declared.\n//------------------------------------------------------------\n#ifndef CS_DISABLE_SHORTNAMESPACE\nnamespace CS = ChilliSource;\n#endif\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Base/AppConfig.cpp",
    "content": "//\n//  AppConfig.cpp\n//  ChilliSource\n//  Created by Ian Copland on 02/06/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Core/Base/AppConfig.h>\n\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/File/StorageLocation.h>\n#include <ChilliSource/Core/File/TaggedFilePathResolver.h>\n#include <ChilliSource/Core/Json/JsonUtils.h>\n#include <ChilliSource/Core/String/StringParser.h>\n#include <ChilliSource/Core/String/StringUtils.h>\n#include <ChilliSource/Rendering/Base/SurfaceFormat.h>\n\n#include <json/json.h>\n\nnamespace ChilliSource\n{\n    namespace\n    {\n        const std::string k_configFilePath = \"App.config\";\n        const std::string k_defaultDisplayableName = \"ChilliSource App\";\n        const u32 k_defaultPreferredFPS = 30;\n    }\n    \n    CS_DEFINE_NAMEDTYPE(AppConfig);\n\n    //---------------------------------------------------------\n    //---------------------------------------------------------\n    AppConfigUPtr AppConfig::Create()\n    {\n        return AppConfigUPtr(new AppConfig());\n    }\n    //---------------------------------------------------------\n    //---------------------------------------------------------\n    AppConfig::AppConfig()\n    : m_preferredFPS(k_defaultPreferredFPS), m_displayableName(k_defaultDisplayableName)\n    {\n    }\n    //---------------------------------------------------------\n    //---------------------------------------------------------\n    bool AppConfig::IsA(InterfaceIDType in_interfaceId) const\n    {\n        return (AppConfig::InterfaceID == in_interfaceId);\n    }\n    //---------------------------------------------------------\n    //---------------------------------------------------------\n    const std::string& AppConfig::GetDisplayableName() const\n    {\n        return m_displayableName;\n    }\n    //---------------------------------------------------------\n    //---------------------------------------------------------\n    u32 AppConfig::GetPreferredFPS() const\n    {\n        return m_preferredFPS;\n    }\n    //---------------------------------------------------------\n    //---------------------------------------------------------\n    bool AppConfig::IsVSyncEnabled() const\n    {\n        return m_isVSyncEnabled;\n    }\n    //---------------------------------------------------------\n    //---------------------------------------------------------\n    void AppConfig::Load()\n    {\n        Json::Value root;\n        if(JsonUtils::ReadJson(StorageLocation::k_package, k_configFilePath, root) == true)\n        {\n            m_displayableName = root.get(\"DisplayableName\", k_defaultDisplayableName).asString();\n            m_preferredFPS = root.get(\"PreferredFPS\", k_defaultPreferredFPS).asUInt();\n            m_isVSyncEnabled = root.get(\"VSync\", false).asBool();\n            std::string cursorType = root.get(\"CursorType\", \"System\").asString();\n            m_cursorType = ParseCursorType(cursorType);\n            m_defaultCursorUIPath = root.get(\"DefaultCursorPath\", \"Widgets/DefaultCursor.csui\").asString();\n            std::string cursorLocation = root.get(\"DefaultCursorLocation\", \"ChilliSource\").asString();\n            m_defaultCursorUILocation = ParseStorageLocation(cursorLocation);\n            \n#if defined CS_TARGETPLATFORM_IOS\n            std::string platform = \"iOS\";\n#elif defined CS_TARGETPLATFORM_ANDROID\n            std::string platform = \"Android\";\n#elif defined CS_TARGETPLATFORM_WINDOWS\n            std::string platform = \"Windows\";\n#elif defined CS_TARGETPLATFORM_RPI\n            std::string platform = \"RPi\";\n#endif\n            \n            //Configurations can be overloaded per platform\n            const Json::Value& platformRoot = root[platform];\n            if(platformRoot.isNull() == false)\n            {\n                m_cursorType = ParseCursorType(platformRoot.get(\"CursorType\", cursorType).asString());\n                m_isVSyncEnabled = platformRoot.get(\"VSync\", m_isVSyncEnabled).asBool();\n                m_preferredFPS = platformRoot.get(\"PreferredFPS\", m_preferredFPS).asUInt();\n                m_defaultCursorUIPath = platformRoot.get(\"DefaultCursorPath\", m_defaultCursorUIPath).asString();\n                m_defaultCursorUILocation = ParseStorageLocation(platformRoot.get(\"DefaultCursorLocation\", cursorLocation.c_str()).asString());\n            }\n            \n            const Json::Value& fileTags = root[\"FileTags\"];\n            if(fileTags.isNull() == false)\n            {\n                Application::Get()->GetTaggedFilePathResolver()->SetFromJson(fileTags);\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Core/Base/AppConfig.h",
    "content": "//\n//  AppConfig.h\n//  ChilliSource\n//  Created by Ian Copland on 02/06/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_BASE_APPCONFIG_H_\n#define _CHILLISOURCE_CORE_BASE_APPCONFIG_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Base/CursorType.h>\n#include <ChilliSource/Core/System/AppSystem.h>\n\nnamespace ChilliSource\n{\n    //---------------------------------------------------------------\n    /// A system for managing application configuration settings. The\n    /// settings are read from an App.config file in the assets\n    /// directory. Settings include things like the displayable name\n    /// of the project and the preferred FPS.\n    ///\n    /// @author Ian Copland\n    //---------------------------------------------------------------\n    class AppConfig final : public AppSystem\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(AppConfig);\n        //---------------------------------------------------------\n        /// Allows querying of whether or not the system implements\n        /// the interface with the associated interface Id.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The interface Id.\n        ///\n        /// @return Whether or not the interface is implemented.\n        //--------------------------------------------------------\n        bool IsA(InterfaceIDType in_interfaceId) const override;\n        //---------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The displayable name of the application. This\n        /// is not necessarily the name of the app displayed when\n        /// launching the App.\n        //--------------------------------------------------------\n        const std::string& GetDisplayableName() const;\n        //---------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param The preferred FPS.\n        //--------------------------------------------------------\n        u32 GetPreferredFPS() const;\n        //---------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Whether VSync is enabled or not\n        //---------------------------------------------------------\n        bool IsVSyncEnabled() const;\n        \n        /// @return The cursor type that should be used by the application\n        ///\n        /// NOTE: This is only applicable for RPi or Windows backend\n        ///\n        CursorType GetCursorType() const noexcept { return m_cursorType; }\n        \n        /// @return The location of the UI file that describes the default cursor\n        ///\n        StorageLocation GetDefaultCursorUILocation() const noexcept { return m_defaultCursorUILocation; }\n        \n        /// @return The path to the UI file that describes the default cursor\n        ///\n        const std::string& GetDefaultCursorUIPath() const noexcept { return m_defaultCursorUIPath; }\n        \n    private:\n        friend class Application;\n        //---------------------------------------------------------\n        /// Factory method for creating a new instance of the class.\n        /// This will be called by CreateSystem() in Application.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @return New instance of the system.\n        //---------------------------------------------------------\n        static AppConfigUPtr Create();\n        //---------------------------------------------------------\n        /// Constructor. Declared private to force the use of the\n        /// factory method.\n        ///\n        /// @author Ian Copland\n        //---------------------------------------------------------\n        AppConfig();\n        //---------------------------------------------------------\n        /// Reads the contents of the app config from file.\n        ///\n        /// @author Ian Copland\n        //---------------------------------------------------------\n        void Load();\n        \n        std::string m_displayableName;\n        \n        std::string m_defaultCursorUIPath;\n        StorageLocation m_defaultCursorUILocation;\n        \n        u32 m_preferredFPS;\n\n        bool m_isVSyncEnabled = false;\n        \n        CursorType m_cursorType = CursorType::k_system;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Base/Application.cpp",
    "content": "//\n//  Application.cpp\n//  ChilliSource\n//  Created by Scott Downie on 23/09/2010.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2010 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Core/Base/Application.h>\n\n#include <ChilliSource/Core/Base/AppConfig.h>\n#include <ChilliSource/Core/Base/Device.h>\n#include <ChilliSource/Core/Base/Logging.h>\n#include <ChilliSource/Core/Base/PlatformSystem.h>\n#include <ChilliSource/Core/Base/Screen.h>\n#include <ChilliSource/Core/DialogueBox/DialogueBoxSystem.h>\n#include <ChilliSource/Core/File/AppDataStore.h>\n#include <ChilliSource/Core/File/TaggedFilePathResolver.h>\n#include <ChilliSource/Core/Image/CSImageProvider.h>\n#include <ChilliSource/Core/Image/PNGImageProvider.h>\n#include <ChilliSource/Core/Localisation/LocalisedText.h>\n#include <ChilliSource/Core/Localisation/LocalisedTextProvider.h>\n#include <ChilliSource/Core/Resource/ResourcePool.h>\n#include <ChilliSource/Core/Scene/Scene.h>\n#include <ChilliSource/Core/State/State.h>\n#include <ChilliSource/Core/State/StateManager.h>\n#include <ChilliSource/Core/String/StringParser.h>\n#include <ChilliSource/Core/Time/CoreTimer.h>\n#include <ChilliSource/Core/Threading/TaskScheduler.h>\n\n#include <ChilliSource/Input/DeviceButtons/DeviceButtonSystem.h>\n#include <ChilliSource/Input/Gamepad/GamepadSystem.h>\n#include <ChilliSource/Input/Keyboard/Keyboard.h>\n#include <ChilliSource/Input/Pointer/PointerSystem.h>\n#include <ChilliSource/Input/TextEntry/TextEntry.h>\n\n#include <ChilliSource/Rendering/Base/CanvasRenderer.h>\n#include <ChilliSource/Rendering/Base/RenderCapabilities.h>\n#include <ChilliSource/Rendering/Base/RenderCommandBufferManager.h>\n#include <ChilliSource/Rendering/Base/Renderer.h>\n#include <ChilliSource/Rendering/Base/RenderSnapshot.h>\n#include <ChilliSource/Rendering/Base/TargetType.h>\n#include <ChilliSource/Rendering/Camera/CameraComponent.h>\n#include <ChilliSource/Rendering/Font/Font.h>\n#include <ChilliSource/Rendering/Font/FontProvider.h>\n#include <ChilliSource/Rendering/Material/Material.h>\n#include <ChilliSource/Rendering/Material/MaterialProvider.h>\n#include <ChilliSource/Rendering/Material/MaterialFactory.h>\n#include <ChilliSource/Rendering/Material/RenderMaterialGroupManager.h>\n#include <ChilliSource/Rendering/Model/RenderMeshManager.h>\n#include <ChilliSource/Rendering/Particle/CSParticleProvider.h>\n#include <ChilliSource/Rendering/Particle/Affector/ParticleAffectorDefFactory.h>\n#include <ChilliSource/Rendering/Particle/Drawable/ParticleDrawableDefFactory.h>\n#include <ChilliSource/Rendering/Particle/Emitter/ParticleEmitterDefFactory.h>\n#include <ChilliSource/Rendering/Shader/CSShaderProvider.h>\n#include <ChilliSource/Rendering/Shader/RenderShaderManager.h>\n#include <ChilliSource/Rendering/Target/RenderTargetGroupManager.h>\n#include <ChilliSource/Rendering/Texture/RenderTextureManager.h>\n#include <ChilliSource/Rendering/Texture/TextureAtlasProvider.h>\n#include <ChilliSource/Rendering/Texture/TextureProvider.h>\n#include <ChilliSource/Rendering/Texture/CubemapProvider.h>\n\n#include <ChilliSource/UI/Base/UIComponentFactory.h>\n#include <ChilliSource/UI/Base/WidgetDefProvider.h>\n#include <ChilliSource/UI/Base/WidgetFactory.h>\n#include <ChilliSource/UI/Base/WidgetTemplateProvider.h>\n\n#include <algorithm>\n#include <chrono>\n#include <ctime>\n\n#if defined(CS_TARGETPLATFORM_IOS) || defined(CS_TARGETPLATFORM_ANDROID) || defined(CS_TARGETPLATFORM_WINDOWS) || defined(CS_TARGETPLATFORM_RPI)\n#   include <CSBackend/Rendering/OpenGL/Base/GLContextRestorer.h>\n#endif\n\nnamespace ChilliSource\n{\n    namespace\n    {\n        constexpr f32 k_defaultUpdateInterval = 1.0f / 60.0f;\n        constexpr f32 k_updateClampThreshold = 0.33f;\n        constexpr f32 k_updateIntervalMax = k_updateClampThreshold;\n        \n        /// Snapshot the view/camera data from the given scene into a render camera\n        ///\n        /// @return Render camera\n        ///\n        RenderCamera GenerateRenderCamera(Scene* scene) noexcept\n        {\n            auto camera = scene->GetActiveCamera();\n            \n            RenderCamera renderCamera;\n            if (camera)\n            {\n                Entity* cameraEntity = camera->GetEntity();\n                CS_ASSERT(cameraEntity, \"Active CameraComponent must be attached to an entity.\");\n                \n                const auto& transform = cameraEntity->GetTransform();\n                renderCamera = RenderCamera(transform.GetWorldTransform(), camera->GetProjection(), transform.GetWorldOrientation());\n            }\n            \n            return renderCamera;\n        }\n    }\n    \n    Application* Application::s_application = nullptr;\n    \n    //------------------------------------------------------------------------------\n    Application* Application::Get() noexcept\n    {\n        return s_application;\n    }\n\n    //------------------------------------------------------------------------------\n    Application::Application(ChilliSource::SystemInfoCUPtr systemInfo) noexcept\n        : m_updateInterval(k_defaultUpdateInterval), m_frameIndex(0), m_systemInfo(std::move(systemInfo))\n    {\n        m_appVersion = m_systemInfo->GetAppVersion();\n    }\n\n    //------------------------------------------------------------------------------\n    const std::string& Application::GetAppVersion() const noexcept\n    {\n        return m_appVersion;\n    }\n\n    //------------------------------------------------------------------------------\n    u32 Application::GetFrameIndex() const noexcept\n    {\n        return m_frameIndex;\n    }\n\n    //------------------------------------------------------------------------------\n    TimeIntervalSecs Application::GetAppElapsedTime() const noexcept\n    {\n        CS_RELEASE_ASSERT(m_taskScheduler->IsMainThread(), \"Can only be called from the main thread.\");\n        \n        return m_currentAppTime;\n    }\n\n    //------------------------------------------------------------------------------\n    TimeIntervalSecs Application::GetSystemTime() const noexcept\n    {\n        return std::chrono::duration_cast<std::chrono::seconds>((std::chrono::system_clock::now().time_since_epoch())).count();\n    }\n\n    //------------------------------------------------------------------------------\n    TimeIntervalMs Application::GetSystemTimeInMilliseconds() const noexcept\n    {\n        return std::chrono::duration_cast<std::chrono::milliseconds>((std::chrono::system_clock::now().time_since_epoch())).count();\n    }\n\n    //------------------------------------------------------------------------------\n    void Application::SetUpdateInterval(f32 updateInterval) noexcept\n    {\n        m_updateInterval = updateInterval;\n    }\n\n    //------------------------------------------------------------------------------\n    f32 Application::GetUpdateInterval() const noexcept\n    {\n        return m_updateInterval;\n    }\n\n    //------------------------------------------------------------------------------\n    f32 Application::GetUpdateIntervalMax() const noexcept\n    {\n        return k_updateIntervalMax;\n    }\n\n    //------------------------------------------------------------------------------\n    void Application::SetUpdateSpeed(f32 speed) noexcept\n    {\n        m_updateSpeed = speed;\n    }\n\n    //------------------------------------------------------------------------------\n    void Application::Quit() noexcept\n    {\n        m_platformSystem->Quit();\n    }\n    \n    //------------------------------------------------------------------------------\n    StateManager* Application::GetStateManager() noexcept\n    {\n        return m_stateManager;\n    }\n    \n    //------------------------------------------------------------------------------\n    const StateManager* Application::GetStateManager() const noexcept\n    {\n        return m_stateManager;\n    }\n    \n    //------------------------------------------------------------------------------\n    FileSystem* Application::GetFileSystem() noexcept\n    {\n        return m_fileSystem;\n    }\n    \n    //------------------------------------------------------------------------------\n    const FileSystem* Application::GetFileSystem() const noexcept\n    {\n        return m_fileSystem;\n    }\n    \n    //------------------------------------------------------------------------------\n    TaggedFilePathResolver* Application::GetTaggedFilePathResolver() noexcept\n    {\n        return m_taggedPathResolver;\n    }\n    \n    //------------------------------------------------------------------------------\n    const TaggedFilePathResolver* Application::GetTaggedFilePathResolver() const noexcept\n    {\n        return m_taggedPathResolver;\n    }\n    \n    //------------------------------------------------------------------------------\n    TaskScheduler* Application::GetTaskScheduler() noexcept\n    {\n        return m_taskScheduler;\n    }\n    \n    //------------------------------------------------------------------------------\n    const TaskScheduler* Application::GetTaskScheduler() const noexcept\n    {\n        return m_taskScheduler;\n    }\n    \n    //------------------------------------------------------------------------------\n    ResourcePool* Application::GetResourcePool() noexcept\n    {\n        return m_resourcePool;\n    }\n    \n    //------------------------------------------------------------------------------\n    const ResourcePool* Application::GetResourcePool() const noexcept\n    {\n        return m_resourcePool;\n    }\n    \n    //------------------------------------------------------------------------------\n    AppConfig* Application::GetAppConfig() noexcept\n    {\n        return m_appConfig;\n    }\n    \n    //------------------------------------------------------------------------------\n    const AppConfig* Application::GetAppConfig() const noexcept\n    {\n        return m_appConfig;\n    }\n    \n    //------------------------------------------------------------------------------\n    Screen* Application::GetScreen() noexcept\n    {\n        return m_screen;\n    }\n    \n    //------------------------------------------------------------------------------\n    const Screen* Application::GetScreen() const noexcept\n    {\n        return m_screen;\n    }\n    \n    //------------------------------------------------------------------------------\n    WidgetFactory* Application::GetWidgetFactory() noexcept\n    {\n        return m_widgetFactory;\n    }\n    \n    //------------------------------------------------------------------------------\n    const WidgetFactory* Application::GetWidgetFactory() const noexcept\n    {\n        return m_widgetFactory;\n    }\n\n    //------------------------------------------------------------------------------\n    void Application::CreateDefaultSystems() noexcept\n    {\n        //Core\n        m_platformSystem = CreateSystem<PlatformSystem>();\n        m_appConfig = CreateSystem<AppConfig>();\n        CreateSystem<Device>(m_systemInfo->GetDeviceInfo());\n        m_screen = CreateSystem<Screen>(m_systemInfo->GetScreenInfo());\n        \n        m_taskScheduler = CreateSystem<TaskScheduler>();\n        m_fileSystem = CreateSystem<FileSystem>();\n        m_stateManager = CreateSystem<StateManager>();\n        m_resourcePool = CreateSystem<ResourcePool>();\n        m_taggedPathResolver = CreateSystem<TaggedFilePathResolver>();\n        CreateSystem<AppDataStore>();\n        CreateSystem<CSImageProvider>();\n        CreateSystem<PNGImageProvider>();\n        CreateSystem<DialogueBoxSystem>();\n        CreateSystem<LocalisedTextProvider>();\n\n        //Input\n        CreateSystem<Keyboard>();\n        m_pointerSystem = CreateSystem<PointerSystem>();\n        m_gamepadSystem = CreateSystem<GamepadSystem>();\n        CreateSystem<DeviceButtonSystem>();\n        CreateSystem<TextEntry>();\n        \n        //Rendering\n#if defined(CS_TARGETPLATFORM_IOS) || defined(CS_TARGETPLATFORM_ANDROID) || defined(CS_TARGETPLATFORM_WINDOWS) || defined(CS_TARGETPLATFORM_RPI)\n        CreateSystem<CSBackend::OpenGL::GLContextRestorer>();\n#endif\n        \n        CreateSystem<RenderCommandBufferManager>();\n        m_renderer = CreateSystem<Renderer>();\n        m_renderMaterialGroupManager = CreateSystem<RenderMaterialGroupManager>();\n        CreateSystem<RenderMeshManager>();\n        CreateSystem<RenderShaderManager>();\n        CreateSystem<RenderTextureManager>();\n        CreateSystem<RenderTargetGroupManager>();\n        CreateSystem<RenderCapabilities>(m_systemInfo->GetRenderInfo());\n        CreateSystem<CanvasRenderer>();\n        CreateSystem<MaterialFactory>();\n        CreateSystem<MaterialProvider>();\n        CreateSystem<CSShaderProvider>();\n        CreateSystem<CubemapProvider>();\n        CreateSystem<TextureAtlasProvider>();\n        CreateSystem<TextureProvider>();\n        CreateSystem<FontProvider>();\n        \n        //Particles\n        CreateSystem<CSParticleProvider>();\n        CreateSystem<ParticleAffectorDefFactory>();\n        CreateSystem<ParticleDrawableDefFactory>();\n        CreateSystem<ParticleEmitterDefFactory>();\n        \n        //UI\n        CreateSystem<UIComponentFactory>();\n        m_widgetFactory = CreateSystem<WidgetFactory>();\n        CreateSystem<WidgetDefProvider>();\n        CreateSystem<WidgetTemplateProvider>();\n\n        //Create any platform specific default systems\n        m_platformSystem->CreateDefaultSystems(this);\n\n        //Clean up SystemInfo to prevent unintended uses\n        m_systemInfo.reset();\n    }\n\n    //------------------------------------------------------------------------------\n    void Application::PostCreateSystems() noexcept\n    {\n        //Loop round all the created app systems and categorise them\n        for(const AppSystemUPtr& system : m_systems)\n        {\n            //Resource providers\n            if(system->IsA(ResourceProvider::InterfaceID))\n            {\n                m_resourcePool->AddProvider(dynamic_cast<ResourceProvider*>(system.get()));\n            }\n        }\n        \n        //Texture provider is a compound provider and needs to be informed when the other providers are created.\n        GetSystem<TextureProvider>()->PostCreate();\n        GetSystem<CubemapProvider>()->PostCreate();\n        \n        //Load the app config set preferred FPS.\n        m_appConfig->Load();\n    }\n\n    //------------------------------------------------------------------------------\n    void Application::ProcessRenderSnapshotEvent() noexcept\n    {\n        CS_RELEASE_ASSERT(ChilliSource::Application::Get()->GetTaskScheduler()->IsMainThread(), \"Tried to render to target from background thread.\");\n        \n        auto activeState = m_stateManager->GetActiveState();\n        CS_ASSERT(activeState, \"Must have active state.\");\n \n        auto scenes = activeState->GetScenes();\n        CS_ASSERT(scenes.size() > 0, \"No scenes on active state\");\n        \n        m_pendingRenderSnapshots.reserve(scenes.size());\n\n        // We handle scenes backwards as the main one is always first in the list and\n        // we need to process that one last\n        for(auto it = scenes.rbegin(); it != scenes.rend(); ++it)\n        {\n            auto scene = (*it);\n            \n            if(scene->IsEnabled())\n            {\n                RenderScene(scene);\n            }\n        }\n    }\n    \n    //------------------------------------------------------------------------------\n    void Application::RenderScene(Scene* scene, TargetGroup* target) noexcept\n    {\n        CS_RELEASE_ASSERT(GetTaskScheduler()->IsMainThread(), \"Tried to render scene from background thread.\");\n        \n        auto targetToUse = target == nullptr ? scene->GetRenderTarget() : target;\n        auto clearColour = scene->GetClearColour();\n        IAllocator* frameAllocator;\n        Integer2 resolution;\n        TargetType targetType;\n        const RenderTargetGroup* targetGroup;\n        \n        if(targetToUse == nullptr)\n        {\n            // Main (screen) render target\n            \n            // Main render target claims the allocator\n            frameAllocator = m_renderer->GetFrameAllocatorQueue().Pop();\n            resolution = Integer2(s32(m_screen->GetResolution().x), s32(m_screen->GetResolution().y));\n            targetType = TargetType::k_main;\n            targetGroup = nullptr;\n        }\n        else\n        {\n            // Offscreen render target\n            \n            // Just borrows the allocator of the main target\n            frameAllocator = m_renderer->GetFrameAllocatorQueue().Front();\n            resolution = targetToUse->GetRenderTargetGroup()->GetResolution();\n            targetType = TargetType::k_offscreen;\n            targetGroup = targetToUse->GetRenderTargetGroup();\n        }\n\n        \n        RenderSnapshot renderSnapshot = m_renderer->CreateRenderSnapshot(targetGroup, resolution, clearColour, GenerateRenderCamera(scene));\n        \n        for (const AppSystemUPtr& system : m_systems)\n        {\n            system->OnRenderSnapshot(targetType, renderSnapshot, frameAllocator);\n        }\n        \n        m_stateManager->RenderSnapshotStates(targetType, renderSnapshot, frameAllocator);\n        scene->RenderSnapshotEntities(renderSnapshot, frameAllocator);\n        \n        if(targetToUse == nullptr)\n        {\n            // The renderer takes ownership of the frame allocator and will return it to the allocator queue\n            m_renderer->ProcessRenderSnapshots(frameAllocator, std::move(renderSnapshot), std::move(m_pendingRenderSnapshots));\n        }\n        else\n        {\n            m_pendingRenderSnapshots.push_back(std::move(renderSnapshot));\n        }\n    }\n    \n    //------------------------------------------------------------------------------\n    void Application::Init() noexcept\n    {\n        CS_ASSERT(s_application == nullptr, \"Application already initialised!\");\n        s_application = this;\n        \n        Logging::Create();\n        \n        //Create all application systems.\n        m_isSystemCreationAllowed = true;\n        CreateDefaultSystems();\n        CreateSystems();\n        m_isSystemCreationAllowed = false;\n        \n        PostCreateSystems();\n        \n        //initialise all of the application systems.\n        for (const AppSystemUPtr& system : m_systems)\n        {\n            system->OnInit();\n        }\n        \n        OnInit();\n        PushInitialState();\n        \n        m_platformSystem->SetPreferredFPS(m_appConfig->GetPreferredFPS());\n    }\n    \n    //------------------------------------------------------------------------------\n    void Application::Resume() noexcept\n    {\n        CS_LOG_VERBOSE(\"App Resuming...\");\n        \n        //resume all of the application systems\n        for (const AppSystemUPtr& system : m_systems)\n        {\n            system->OnResume();\n        }\n        \n        m_stateManager->ResumeStates();\n        \n        CS_LOG_VERBOSE(\"App Finished Resuming...\");\n    }\n    \n    //------------------------------------------------------------------------------\n    void Application::Foreground() noexcept\n    {\n        for (const AppSystemUPtr& system : m_systems)\n        {\n            system->OnForeground();\n        }\n        \n        m_stateManager->ForegroundStates();\n    }\n    \n    //------------------------------------------------------------------------------\n    void Application::Update(f32 deltaTime, TimeIntervalSecs timestamp) noexcept\n    {\n\n#if CS_ENABLE_DEBUG\n        //When debugging we may have breakpoints so restrict the time between\n        //updates to something feasible.\n        deltaTime = std::min(deltaTime, 0.5f);\n#endif\n        \n        deltaTime *= m_updateSpeed;\n        m_currentAppTime = timestamp;\n        \n        //We do not need to render as often as we update so this callback will be triggered\n        //less freqenctly than the update frequency suggests. We must work out how many times to update based on the time since last frame\n        //and our actual update frequency. We carry the remainder to the next frame until we have a full update cycle\n        m_updateIntervalRemainder = std::min(m_updateIntervalRemainder + deltaTime, GetUpdateIntervalMax());\n        \n        //process any queued input received by the pointer system and gamepad system.\n        if(m_pointerSystem != nullptr)\n        {\n            m_pointerSystem->ProcessQueuedInput();\n        }\n        \n        if(m_gamepadSystem != nullptr)\n        {\n            m_gamepadSystem->ProcessQueuedInput();\n        }\n        \n        bool isFirstFrame = (m_frameIndex == 0);\n        while((m_updateIntervalRemainder >= GetUpdateInterval()) || isFirstFrame)\n        {\n            m_updateIntervalRemainder -= GetUpdateInterval();\n            \n            //update all of the application systems\n            for (const AppSystemUPtr& system : m_systems)\n            {\n                system->OnFixedUpdate(GetUpdateInterval());\n            }\n            \n            m_stateManager->FixedUpdateStates(GetUpdateInterval());\n            \n            isFirstFrame = false;\n        }\n        \n        CoreTimer::Update(deltaTime);\n        \n        //update all of the application systems\n        for (const AppSystemUPtr& system : m_systems)\n        {\n            system->OnUpdate(deltaTime);\n        }\n        \n        m_stateManager->UpdateStates(deltaTime);\n        \n        m_taskScheduler->ExecuteMainThreadTasks();\n        \n        ProcessRenderSnapshotEvent();\n        \n        ++m_frameIndex;\n    }\n    \n    //------------------------------------------------------------------------------\n    void Application::Render() noexcept\n    {\n        m_renderer->ProcessRenderCommandBuffer();\n    }\n    \n    //------------------------------------------------------------------------------\n    void Application::MemoryWarning() noexcept\n    {\n        CS_LOG_VERBOSE(\"Memory Warning. Clearing resource cache...\");\n        \n        //update all of the application systems\n        for (const AppSystemUPtr& system : m_systems)\n        {\n            system->OnMemoryWarning();\n        }\n        \n        m_stateManager->MemoryWarningStates();\n    }\n    \n    //------------------------------------------------------------------------------\n    void Application::Background() noexcept\n    {\n        m_stateManager->BackgroundStates();\n        \n        for (const AppSystemUPtr& system : m_systems)\n        {\n            system->OnBackground();\n        }\n    }\n    \n    //------------------------------------------------------------------------------\n    void Application::Suspend() noexcept\n    {\n        CS_LOG_VERBOSE(\"App Suspending...\");\n\n        m_stateManager->SuspendStates();\n        \n        //suspend all application systems in reverse order.\n        for (std::vector<AppSystemUPtr>::const_reverse_iterator it = m_systems.rbegin(); it != m_systems.rend(); ++it)\n        {\n            (*it)->OnSuspend();\n        }\n        \n        CS_LOG_VERBOSE(\"App Finished Suspending...\");\n    }\n    \n    //------------------------------------------------------------------------------\n    void Application::Destroy() noexcept\n    {\n        m_taskScheduler->Destroy();\n        \n        OnDestroy();\n        \n        m_stateManager->DestroyStates();\n        \n        //suspend all application systems in reverse order.\n        for (std::vector<AppSystemUPtr>::const_reverse_iterator it = m_systems.rbegin(); it != m_systems.rend(); ++it)\n        {\n            (*it)->OnDestroy();\n        }\n\n        m_resourcePool->Destroy();\n        \n        //Needs to be destroyed after the resource pool as materials rely on this system\n        m_renderMaterialGroupManager->Destroy();\n        \n        m_systems.clear();\n        \n        Logging::Destroy();\n        \n        s_application = nullptr;\n    }\n\n    //------------------------------------------------------------------------------\n    Application::~Application() noexcept\n    {\n        CS_ASSERT(s_application == nullptr, \"Application destructed without calling OnDestroy!\");\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Core/Base/Application.h",
    "content": "//\n//  Application.h\n//  ChilliSource\n//  Created by Scott Downie on 23/09/2010.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2010 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_BASE_APPLICATION_H_\n#define _CHILLISOURCE_CORE_BASE_APPLICATION_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Base/Screen.h>\n#include <ChilliSource/Core/Base/SystemInfo.h>\n#include <ChilliSource/Core/File/FileSystem.h>\n#include <ChilliSource/Core/State/StateManager.h>\n#include <ChilliSource/Core/System/AppSystem.h>\n\n#include <limits>\n#include <atomic>\n\nnamespace ChilliSource\n{\n    const u32 k_undefinedMaxResolution = std::numeric_limits<u32>::max();\n    const f32 k_undefinedMaxDensity = std::numeric_limits<f32>::max();\n    struct ResourceDirectoryInfo\n    {\n        std::string m_directory;\n        u32 m_maxRes;\n        f32 m_maxDensity;\n        f32 m_resourcesDensity;\n    };\n    \n    \n    /// The main hub of the engine. The Application controls the overall application flow\n    /// and contains all engine systems. This also acts as the entry point into a\n    /// ChilliSource application. The user should override this class to include desired\n    /// systems and add the initial State.\n    ///\n    /// Some methods in Application are thread-safe, but others are not.\n    ///\n    class Application\n    {\n    public:\n        CS_DECLARE_NOCOPY(Application);\n        \n        /// This is thread safe.\n        ///\n        /// @return The application singleton instance pointer.\n        ///\n        static Application* Get() noexcept;\n        \n        /// Constructor\n        ///\n        Application(ChilliSource::SystemInfoCUPtr systemInfo) noexcept;\n        \n        /// Creates a new instance of the given system and adds it to the application.\n        ///\n        /// @param args\n        ///     The arguments to the system constructor.\n        ///\n        /// @return A raw pointer to the new system.\n        ///\n        template <typename TSystem, typename... TArgs> TSystem* CreateSystem(TArgs&&... args) noexcept;\n        \n        /// Looks for a system that implements the queryable interface provided as a\n        /// template parameter.\n        ///\n        /// This is thread-safe as long as it is called between the OnInit() and OnDestroy()\n        /// application lifecycle events, inclusive.\n        ///\n        /// @return A pointer to the first system found that implements the named interface.\n        ///\n        template <typename TNamedType> TNamedType* GetSystem() noexcept;\n\n        /// Looks for a system that implements the queryable interface provided as a\n        /// template parameter.\n        ///\n        /// This is thread-safe as long as it is called between the OnInit() and OnDestroy()\n        /// application lifecycle events, inclusive.\n        ///\n        /// @return A const pointer to the first system found that implements the named\n        /// interface.\n        ///\n        template <typename TNamedType> const TNamedType* GetSystem() const noexcept;\n        \n        /// Looks for all systems that implement the given queryable interface provided\n        /// as a template parameter.\n        ///\n        /// This is thread-safe as long as it is called between the OnInit() and\n        /// OnDestroy() application lifecycle events, inclusive.\n        ///\n        /// @return A list of pointers to the systems that implement the given interface.\n        ///\n        template <typename TNamedType> std::vector<TNamedType*> GetSystems() noexcept;\n\n        /// Looks for all systems that implement the given queryable interface provided\n        /// as a template parameter.\n        ///\n        /// This is thread-safe as long as it is called between the OnInit() and\n        /// OnDestroy() application lifecycle events, inclusive.\n        ///\n        /// @return A list of const pointers to the systems that implement the given\n        /// interface.\n        ///\n        template <typename TNamedType> std::vector<const TNamedType*> GetSystems() const noexcept;\n\n        /// Returns the version number of the application on the current platform\n        /// as a string.\n        ///\n        /// @return The version string.\n        ///\n        const std::string& GetAppVersion() const noexcept;\n\n        /// This is thread-safe.\n        ///\n        /// @return The unique index of the current frame.\n        ///\n        u32 GetFrameIndex() const noexcept;\n        \n        /// Returns the elapsed time since the application started running in\n        /// seconds.\n        ///\n        /// This is not thread-safe and should only be called from the main thread.\n        ///\n        /// @return The time in seconds.\n        ///\n        TimeIntervalSecs GetAppElapsedTime() const noexcept;\n\n        /// Returns the system clock time in seconds since epoch.\n        ///\n        /// @return The time in seconds.\n        ///\n        TimeIntervalSecs GetSystemTime() const noexcept;\n\n        /// Return the system clock time in milliseconds since epoch.\n        ///\n        /// @return The time in milliseconds.\n        ///\n        TimeIntervalSecs GetSystemTimeInMilliseconds() const noexcept;\n\n        /// Set the time between update calls to adjust the frame rate.\n        ///\n        /// @param updateInterval\n        ///     Time between update calls\n        ///\n        void SetUpdateInterval(f32 updateInterval) noexcept;\n        \n        /// This is not thread-safe and should only be called on the main thread.\n        ///\n        /// @return The time between update calls.\n        ///\n        f32 GetUpdateInterval() const noexcept;\n\n        /// Returns the maximum amount of time to be processed a single update frame.\n        ///\n        /// This is not thread-safe and should only be called on the main thread.\n        ///\n        /// @return Max time to be processed in a single frame.\n        ///\n        f32 GetUpdateIntervalMax() const noexcept;\n\n        /// Sets a multiplier for slowing or speeding up the delta time passed to\n        /// each system and state.\n        ///\n        /// This is not thread-safe and should only be called on the main thread.\n        ///\n        /// @param speed\n        ///     Scaler to speed up or slow down update time.\n        ///\n        void SetUpdateSpeed(f32 speed) noexcept;\n\n        /// Stop the application and exit gracefully\n        ///\n        /// This is not thread-safe and should only be called on the main thread.\n        ///\n        void Quit() noexcept;\n        \n        /// This is thread-safe as long as it is called between the init and\n        /// destroy application lifecycle events, inclusive.\n        ///\n        /// @return A pointer to the state manager.\n        ///\n        StateManager* GetStateManager() noexcept;\n\n        /// This is thread-safe as long as it is called between the init and\n        /// destroy application lifecycle events, inclusive.\n        ///\n        /// @return A const pointer to the state manager.\n        ///\n        const StateManager* GetStateManager() const noexcept;\n\n        /// This is thread-safe as long as it is called between the init and\n        /// destroy application lifecycle events, inclusive.\n        ///\n        /// @return A pointer to the file system.\n        ///\n        FileSystem* GetFileSystem() noexcept;\n\n        /// This is thread-safe as long as it is called between the init and\n        /// destroy application lifecycle events, inclusive.\n        ///\n        /// @return A const pointer to the file system.\n        ///\n        const FileSystem* GetFileSystem() const noexcept;\n\n        /// This is thread-safe as long as it is called between the init and\n        /// destroy application lifecycle events, inclusive.\n        ///\n        /// @return A pointer to the system that resolves path based on the device\n        /// config\n        ///\n        TaggedFilePathResolver* GetTaggedFilePathResolver() noexcept;\n\n        /// This is thread-safe as long as it is called between the init and\n        /// destroy application lifecycle events, inclusive.\n        ///\n        /// @return A const pointer to the system that resolves path based on the\n        /// device config\n        ///\n        const TaggedFilePathResolver* GetTaggedFilePathResolver() const noexcept;\n\n        /// This is thread-safe as long as it is called between the init and\n        /// destroy application lifecycle events, inclusive.\n        ///\n        /// @return A pointer to the task scheduler.\n        ///\n        TaskScheduler* GetTaskScheduler() noexcept;\n\n        /// This is thread-safe as long as it is called between the init and\n        /// destroy application lifecycle events, inclusive.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @return A const pointer to the task scheduler.\n        ///\n        const TaskScheduler* GetTaskScheduler() const noexcept;\n\n        /// This is thread-safe as long as it is called between the init and\n        /// destroy application lifecycle events, inclusive.\n        ///\n        /// @return A pointer to the resource pool system.\n        ///\n        ResourcePool* GetResourcePool() noexcept;\n        \n        /// This is thread-safe as long as it is called between the init and\n        /// destroy application lifecycle events, inclusive.\n        ///\n        /// @return A const pointer to the resource pool system.\n        ///\n        const ResourcePool* GetResourcePool() const noexcept;\n        \n        /// This is thread-safe as long as it is called between the init and\n        /// destroy application lifecycle events, inclusive.\n        ///\n        /// @return A pointer to the App Config.\n        ///\n        AppConfig* GetAppConfig() noexcept;\n        \n        /// This is thread-safe as long as it is called between the init and\n        /// destroy application lifecycle events, inclusive.\n        ///\n        /// @return A const pointer to the App Config.\n        ///\n        const AppConfig* GetAppConfig() const noexcept;\n        \n        /// This is thread-safe as long as it is called between the init and\n        /// destroy application lifecycle events, inclusive.\n        ///\n        /// @return A pointer to the screen system.\n        ///\n        Screen* GetScreen() noexcept;\n        \n        /// This is thread-safe as long as it is called between the init and\n        /// destroy application lifecycle events, inclusive.\n        ///\n        /// @return A const pointer to the screen system.\n        ///\n        const Screen* GetScreen() const noexcept;\n        \n        /// This is thread-safe as long as it is called between the init and\n        /// destroy application lifecycle events, inclusive.\n        ///\n        /// @return A pointer to the widget factory system.\n        ///\n        WidgetFactory* GetWidgetFactory() noexcept;\n        \n        /// This is thread-safe as long as it is called between the init and\n        /// destroy application lifecycle events, inclusive.\n        ///\n        /// @return A const pointer to the widget factory system.\n        ///\n        const WidgetFactory* GetWidgetFactory() const noexcept;\n\n        virtual ~Application() noexcept;\n        \n    protected:\n        /// The users application should override this to add desired systems.\n        /// Systems can only be added in this method.\n        ///\n        /// This will always be called on the main thread.\n        ///\n        virtual void CreateSystems() noexcept = 0;\n        \n        /// Initialisation method called after all systems have been set up and\n        /// before the first state is pushed. Application initialisation code\n        /// should be in here.\n        ///\n        /// This will always be called on the main thread.\n        ///\n        virtual void OnInit() noexcept = 0;\n        \n        /// Give the state manager the initial state. This should be overriden by\n        /// the users application to add initial state.\n        ///\n        /// This will always be called on the main thread.\n        ///\n        virtual void PushInitialState() noexcept = 0;\n        \n        /// Destuction method called just before all systems and states are released.\n        /// Application destruction code should be in here.\n        ///\n        /// This will always be called on the main thread.\n        ///\n        virtual void OnDestroy() noexcept = 0;\n        \n    private:\n        friend class LifecycleManager;\n        \n        /// Systems that are required by CS are added in this method\n        ///\n        void CreateDefaultSystems() noexcept;\n        \n        /// Once the systems have been created they are then added to the pool and\n        /// initialised.\n        ///\n        void PostCreateSystems() noexcept;\n        \n        /// Sends the render snapshot event to all active systems and components\n        /// that are current in the scene to generate the render snapshot. This\n        /// snapshot is then passed to the render pipeline for processing. This is done\n        /// for all enabled scenes\n        ///\n        void ProcessRenderSnapshotEvent() noexcept;\n        \n        /// Initialises the application, creating all systems and sending the init\n        /// lifecycle event to all systems.\n        ///\n        /// This is called by the LifecycleManager.\n        ///\n        void Init() noexcept;\n        \n        /// Resumes the application from the suspended state, and sends the resume\n        /// lifecycle event to all systems.\n        ///\n        /// This is called by the LifecycleManager.\n        ///\n        void Resume() noexcept;\n        \n        /// Foregrounds the application and sends the foreground lifecycle event to\n        /// all systems.\n        ///\n        /// This is called by the LifecycleManager.\n        ///\n        void Foreground() noexcept;\n        \n        /// Updates the application and sends the update lifecycle event and fixed\n        /// update lifecycle event to all systems.\n        ///\n        /// This is called by the LifecycleManager.\n        ///\n        /// @param deltaTime\n        ///     The time that has passed since the last update.\n        /// @param timestamp\n        ///     The frame timestamp.\n        ///\n        void Update(f32 deltaTime, TimeIntervalSecs timestamp) noexcept;\n        \n        /// Sends the render snapshot event to all systems and then initiates the\n        /// render pipeline.\n        ///\n        /// This is called on the render thread.\n        ///\n        void Render() noexcept;\n        \n        /// Triggered on receiving a \"application memory warning\" event. This will\n        /// notify active resource managers to purge their caches.\n        ///\n        /// This is called by the LifecycleManager.\n        ///\n        void MemoryWarning() noexcept;\n        \n        /// Backgrounds the application and sends the background lifecycle event to\n        /// all systems.\n        ///\n        /// This is called by the LifecycleManager.\n        ///\n        void Background() noexcept;\n        \n        /// Suspends the application and sends the suspend lifecycle event to all\n        /// systems.\n        ///\n        /// This is called by the LifecycleManager.\n        ///\n        void Suspend() noexcept;\n        \n        /// Sends the destroy lifecycle event to all systems and then deallocates\n        /// them. All background tasks will be processed before the destroy event.\n        ///\n        /// This is called by the LifecycleManager.\n        ///\n        void Destroy() noexcept;\n        \n        friend class Scene;\n        \n        /// Takes a snapshot of the given scene and renders it to its\n        /// render target during the render stage of the application.\n        /// This is used mostly for single shot render to texture\n        /// NOTE: This means the texture of the target will not be populated til next frame.\n        ///\n        /// @param scene\n        ///     Scene that should be rendered\n        /// @param target\n        ///     Optional, if wanting to render the scene to a target other than its own\n        ///\n        void RenderScene(Scene* scene, TargetGroup* target = nullptr) noexcept;\n        \n        std::vector<RenderSnapshot> m_pendingRenderSnapshots;\n        std::vector<AppSystemUPtr> m_systems;\n        \n        ResourcePool* m_resourcePool = nullptr;\n        StateManager* m_stateManager = nullptr;\n        TaskScheduler* m_taskScheduler = nullptr;\n        Renderer* m_renderer = nullptr;\n        RenderMaterialGroupManager* m_renderMaterialGroupManager = nullptr;\n        Screen* m_screen = nullptr;\n        PlatformSystem* m_platformSystem = nullptr;\n        FileSystem* m_fileSystem = nullptr;\n        TaggedFilePathResolver* m_taggedPathResolver = nullptr;\n        PointerSystem* m_pointerSystem = nullptr;\n        GamepadSystem* m_gamepadSystem = nullptr;\n        AppConfig* m_appConfig = nullptr;\n        WidgetFactory* m_widgetFactory = nullptr;\n\n        SystemInfoCUPtr m_systemInfo;\n        \n        std::atomic<u32> m_frameIndex;\n        TimeIntervalSecs m_currentAppTime = 0;\n        f32 m_updateInterval;\n        f32 m_updateSpeed = 1.0f;\n        f32 m_updateIntervalRemainder = 0.0f;\n        bool m_isSystemCreationAllowed = false;\n        std::string m_appVersion;\n        \n        static Application* s_application;\n    };\n    \n    //------------------------------------------------------------------------------\n    template <typename TSystem, typename... TArgs> TSystem* Application::CreateSystem(TArgs&&... args) noexcept\n    {\n        CS_ASSERT(m_isSystemCreationAllowed == true, \"Cannot add systems outwith the creation phase\");\n        \n        std::unique_ptr<TSystem> newSystem = TSystem::Create(std::forward<TArgs>(args)...);\n        TSystem* output = newSystem.get();\n        if (newSystem != nullptr)\n        {\n            m_systems.push_back(std::move(newSystem));\n        }\n        \n        return output;\n    }\n    \n    //------------------------------------------------------------------------------\n    template <typename TNamedType> TNamedType* Application::GetSystem() noexcept\n    {\n        for (const auto& system : m_systems)\n        {\n            if (system->IsA<TNamedType>() == true)\n            {\n                return static_cast<TNamedType*>(system.get());\n            }\n        }\n        \n        return nullptr;\n    }\n    \n    //------------------------------------------------------------------------------\n    template <typename TNamedType> const TNamedType* Application::GetSystem() const noexcept\n    {\n        for (const auto& system : m_systems)\n        {\n            if (system->IsA<TNamedType>() == true)\n            {\n                return static_cast<TNamedType*>(system.get());\n            }\n        }\n        \n        return nullptr;\n    }\n    \n    //------------------------------------------------------------------------------\n    template <typename TNamedType> std::vector<TNamedType*> Application::GetSystems() noexcept\n    {\n        std::vector<TNamedType*> output;\n        \n        for (const auto& system : m_systems)\n        {\n            if (system->IsA<TNamedType>() == true)\n            {\n                output.push_back(static_cast<TNamedType*>(system.get()));\n            }\n        }\n        \n        return output;\n    }\n    \n    //------------------------------------------------------------------------------\n    template <typename TNamedType> std::vector<const TNamedType*> Application::GetSystems() const noexcept\n    {\n        std::vector<const TNamedType*> output;\n        \n        for (const auto& system : m_systems)\n        {\n            if (system->IsA<TNamedType>() == true)\n            {\n                output.push_back(static_cast<TNamedType*>(system.get()));\n            }\n        }\n        \n        return output;\n    }\n}\n\n/// Factory method that must be implemented by the the derived application.\n///\n/// This is not thread safe and must always be called on the system thread.\n///\n/// @return Instance of concrete CS application\n///\nChilliSource::Application* CreateApplication(ChilliSource::SystemInfoCUPtr systemInfo) noexcept;\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Base/ByteBuffer.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright © 2016 Tag Games. All rights reserved.\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Core/Base/ByteBuffer.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    ByteBuffer::ByteBuffer(std::unique_ptr<const u8[]> data, u32 length) noexcept\n        : m_data(std::move(data)), m_length(length)\n    {\n    }\n    //------------------------------------------------------------------------------\n    const u8* ByteBuffer::GetData() const noexcept\n    {\n        return m_data.get();\n    }\n    //------------------------------------------------------------------------------\n    u32 ByteBuffer::GetLength() const noexcept\n    {\n        return m_length;\n    }\n}"
  },
  {
    "path": "Source/ChilliSource/Core/Base/ByteBuffer.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright © 2016 Tag Games. All rights reserved.\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_FILE_FILESTREAM_BYTEBUFFER_H_\n#define _CHILLISOURCE_CORE_FILE_FILESTREAM_BYTEBUFFER_H_\n\n#include <ChilliSource/ChilliSource.h>\n\nnamespace ChilliSource\n{\n    /// Class to store a data pointer and size\n    ///\n    /// Class will take ownership of any data passed and data will\n    /// be destroyed with this instance\n    ///\n    class ByteBuffer final\n    {\n    public:\n\t\tCS_DECLARE_NOCOPY(ByteBuffer);\n        \n        ByteBuffer(ByteBuffer&&) = default;\n        ByteBuffer& operator=(ByteBuffer&&) = default;\n        \n        /// Constructor\n        ///\n        /// @param data\n        ///     The unique pointer to the start of the data\n        /// @param length\n        ///     The length of the data\n        ///\n        ByteBuffer(std::unique_ptr<const u8[]> data, u32 length) noexcept;\n        \n        /// Gets the pointer to the start of the data.\n        /// This should never be modified directly.\n        ///\n        /// @return The pointer to the start of the data\n        ///\n        const u8* GetData() const noexcept;\n        \n        /// @return The length of the data stored\n        ///\n        u32 GetLength() const noexcept;\n        \n    private:\n        std::unique_ptr<const u8[]> m_data;\n        u32 m_length;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Base/ByteColour.cpp",
    "content": "//\n//  ByteColour.cpp\n//  ChilliSource\n//  Created by Scott Downie on 03/04/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Core/Base/ByteColour.h>\n\nnamespace ChilliSource\n{\n    //-----------------------------------------------------------\n    //-----------------------------------------------------------\n    ByteColour::ByteColour(u8 in_red, u8 in_green, u8 in_blue, u8 in_alpha)\n    : r(in_red), g(in_green), b(in_blue), a(in_alpha)\n    {\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Core/Base/ByteColour.h",
    "content": "//\n//  ByteColour.h\n//  ChilliSource\n//  Created by Scott Downie on 03/04/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_BASE_BYTECOLOUR_H_\n#define _CHILLISOURCE_CORE_BASE_BYTECOLOUR_H_\n\n#include <ChilliSource/ChilliSource.h>\n\nnamespace ChilliSource\n{\n    //-----------------------------------------------------------\n    /// Container for RGBA colour as 0 - 255 values\n    ///\n    /// @author S Downie\n    //-----------------------------------------------------------\n    class ByteColour\n    {\n    public:\n\n        //-----------------------------------------------------------\n        /// Constructor\n        ///\n        /// @author S Downie\n        ///\n        /// @param Red 0 - 255\n        /// @param Green 0 - 255\n        /// @param Blue 0 - 255\n        /// @param Alpha 0 - 255\n        //-----------------------------------------------------------\n        ByteColour(u8 in_red = 255, u8 in_green = 255, u8 in_blue = 255, u8 in_alpha = 255);\n\n\n    public:\n        \n        u8 r, g, b, a;\n    };\n    \n    //-----------------------------------------------------------\n    /// @author S Downie\n    ///\n    /// @param LHS of comparison\n    /// @param RHS of comparison\n    ///\n    /// @return Whether the two colours have equal RGBA components\n    //-----------------------------------------------------------\n    inline bool operator==(const ByteColour& in_lhs, const ByteColour& in_rhs)\n    {\n        return in_lhs.r == in_rhs.r && in_lhs.g == in_rhs.g && in_lhs.b == in_rhs.b && in_lhs.a == in_rhs.a;\n    }\n    //-----------------------------------------------------------\n    /// @author S Downie\n    ///\n    /// @param LHS of comparison\n    /// @param RHS of comparison\n    ///\n    /// @return Whether the two colours have unequal RGBA components\n    //-----------------------------------------------------------\n    inline bool operator!=(const ByteColour& in_lhs, const ByteColour& in_rhs)\n    {\n        return in_lhs.r != in_rhs.r || in_lhs.g != in_rhs.g || in_lhs.b != in_rhs.b || in_lhs.a != in_rhs.a;\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Base/Colour.cpp",
    "content": "//\n//  Colour.cpp\n//  ChilliSource\n//  Created by Scott Downie on 27/09/2010.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2010 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Core/Base/Colour.h>\n\n#include <ChilliSource/Core/Math/MathUtils.h>\n\nnamespace ChilliSource\n{\n    const Colour Colour::k_white(1.0f,1.0f,1.0f,1.0f);\n    const Colour Colour::k_transparent(0.0f,0.0f,0.0f,0.0f);\n    const Colour Colour::k_black(0.0f,0.0f,0.0f,1.0f);\n    const Colour Colour::k_grey(0.5f,0.5f,0.5f,1.0f);\n    const Colour Colour::k_red(1.0f,0.0f,0.0f,1.0f);\n    const Colour Colour::k_green(0.0f,1.0f,0.0f,1.0f);\n    const Colour Colour::k_blue(0.0f,0.0f,1.0f,1.0f);\n    const Colour Colour::k_magenta(1.0f,0.0f,1.0f,1.0f);\n    const Colour Colour::k_yellow(1.0f,1.0f,0.0f,1.0f);\n    const Colour Colour::k_cyan(0.0f,1.0f,1.0f,1.0f);\n    const Colour Colour::k_cornflowerBlue(0.4f,0.5f,0.8f,1.0f);\n    const Colour Colour::k_lightGrey(0.8f,0.8f,0.8f,1.0f);\n    const Colour Colour::k_turquoise(0.25f,0.88f,0.82f,1.0f);\n    const Colour Colour::k_orange(0.9f,0.4f,0.12f,1.0f);\n    const Colour Colour::k_purple(0.5f,0.0f,0.5f,1.0f);\n    const Colour Colour::k_pink(0.94f,0.36f,0.47f,1.0f);\n    \n    //-----------------------------------------------------------\n    //-----------------------------------------------------------\n    Colour Colour::Clamp(const Colour& in_value, const Colour& in_min, const Colour& in_max)\n    {\n        Colour result;\n        result.r = MathUtils::Clamp(in_value.r, in_min.r, in_max.r);\n        result.g = MathUtils::Clamp(in_value.g, in_min.g, in_max.g);\n        result.b = MathUtils::Clamp(in_value.b, in_min.b, in_max.b);\n        result.a = MathUtils::Clamp(in_value.a, in_min.a, in_max.a);\n        return result;\n    }\n    //-----------------------------------------------------------\n    //-----------------------------------------------------------\n    Colour Colour::Lerp(f32 t, const Colour& a, const Colour& b)\n    {\n        Colour result;\n        result.r = MathUtils::Lerp(t, a.r, b.r);\n        result.g = MathUtils::Lerp(t, a.g, b.g);\n        result.b = MathUtils::Lerp(t, a.b, b.b);\n        result.a = MathUtils::Lerp(t, a.a, b.a);\n        return result;\n    }\n    //-----------------------------------------------------------\n    //-----------------------------------------------------------\n    Colour::Colour(f32 in_red, f32 in_green, f32 in_blue, f32 in_alpha)\n    : r(in_red), g(in_green), b(in_blue), a(in_alpha)\n    {\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Core/Base/Colour.h",
    "content": "//\n//  Colour.h\n//  ChilliSource\n//  Created by Scott Downie on 27/09/2010.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2010 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_BASE_COLOUR_H_\n#define _CHILLISOURCE_CORE_BASE_COLOUR_H_\n\n#include <ChilliSource/ChilliSource.h>\n\nnamespace ChilliSource\n{\n    //-----------------------------------------------------------\n    /// Container for RGBA colour as normalised 0.0 - 1.0 values\n    ///\n    /// @author S Downie\n    //-----------------------------------------------------------\n    class Colour\n    {\n    public:\n\n        //Commonly used colours\n        static const Colour k_white;\n        static const Colour k_transparent;\n        static const Colour k_black;\n        static const Colour k_grey;\n        static const Colour k_red;\n        static const Colour k_green;\n        static const Colour k_blue;\n        static const Colour k_magenta;\n        static const Colour k_yellow;\n        static const Colour k_cyan;\n        static const Colour k_cornflowerBlue;\n        static const Colour k_lightGrey;\n        static const Colour k_turquoise;\n        static const Colour k_orange;\n        static const Colour k_purple;\n        static const Colour k_pink;\n        \n        //-----------------------------------------------------------\n        /// Clamp the given colour between the min and max values\n        ///\n        /// @author S Downie\n        ///\n        /// @param Value to clamp\n        /// @param Min\n        /// @param Max\n        ///\n        /// @return Clamped colour\n        //-----------------------------------------------------------\n        static Colour Clamp(const Colour& in_value, const Colour& in_min = k_transparent, const Colour& in_max = k_white);\n        \n        ///\n        /// Linearly interpolates between the colours a and b based on t (0-1)\n        ///\n        /// @param t\n        ///     Paramteric t value between 0 and 1. 0 = a, 1 = b\n        /// @param a\n        ///     Left hand value on the lerp\n        /// @param b\n        ///     Right hand value on the lerp\n        ///\n        /// @return Lerped colour\n        ///\n        static Colour Lerp(f32 t, const Colour& a, const Colour& b);\n        \n        //-----------------------------------------------------------\n        /// Constructor\n        ///\n        /// @author S Downie\n        ///\n        /// @param Normalised red 0.0 - 1.0\n        /// @param Normalised green 0.0 - 1.0\n        /// @param Normalised blue 0.0 - 1.0\n        /// @param Normalised alpha 0.0 - 1.0\n        //-----------------------------------------------------------\n        Colour(f32 in_red = 1.0f, f32 in_green = 1.0f, f32 in_blue = 1.0f, f32 in_alpha = 1.0f);\n        //-----------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param RHS of addition\n        ///\n        /// @return Component wise addition of colour to this\n        //-----------------------------------------------------------\n        inline const Colour& operator+=(const Colour& in_rhs)\n        {\n            r += in_rhs.r;\n            g += in_rhs.g;\n            b += in_rhs.b;\n            a += in_rhs.a;\n            \n            return *this;\n        }\n        //-----------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param RHS of addition (scalar)\n        ///\n        /// @return scalar addition to this\n        //-----------------------------------------------------------\n        inline const Colour& operator+=(f32 in_scalar)\n        {\n            r += in_scalar;\n            g += in_scalar;\n            b += in_scalar;\n            a += in_scalar;\n            \n            return *this;\n        }\n        //-----------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param RHS of subtraction\n        ///\n        /// @return Component wise subtraction of colour to this\n        //-----------------------------------------------------------\n        inline const Colour& operator-=(const Colour& in_rhs)\n        {\n            r -= in_rhs.r;\n            g -= in_rhs.g;\n            b -= in_rhs.b;\n            a -= in_rhs.a;\n            \n            return *this;\n        }\n        //-----------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param RHS of subtraction (scalar)\n        ///\n        /// @return scalar subtraction to this\n        //-----------------------------------------------------------\n        inline const Colour& operator-=(f32 in_scalar)\n        {\n            r -= in_scalar;\n            g -= in_scalar;\n            b -= in_scalar;\n            a -= in_scalar;\n            \n            return *this;\n        }\n        //-----------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param RHS of multiplication\n        ///\n        /// @return Component wise multiplication of colour to this\n        //-----------------------------------------------------------\n        inline const Colour& operator*=(const Colour& in_rhs)\n        {\n            r *= in_rhs.r;\n            g *= in_rhs.g;\n            b *= in_rhs.b;\n            a *= in_rhs.a;\n            \n            return *this;\n        }\n        //-----------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param RHS of multiplication (scalar)\n        ///\n        /// @return scalar multiplication to this\n        //-----------------------------------------------------------\n        inline const Colour& operator*=(f32 in_scalar)\n        {\n            r *= in_scalar;\n            g *= in_scalar;\n            b *= in_scalar;\n            a *= in_scalar;\n            \n            return *this;\n        }\n        //-----------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param RHS of division\n        ///\n        /// @return Component wise division of colour to this\n        //-----------------------------------------------------------\n        inline const Colour& operator/=(const Colour& in_rhs)\n        {\n            r /= in_rhs.r;\n            g /= in_rhs.g;\n            b /= in_rhs.b;\n            a /= in_rhs.a;\n            \n            return *this;\n        }\n        //-----------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param RHS of division (scalar)\n        ///\n        /// @return scalar division to this\n        //-----------------------------------------------------------\n        inline const Colour& operator/=(f32 in_scalar)\n        {\n            r /= in_scalar;\n            g /= in_scalar;\n            b /= in_scalar;\n            a /= in_scalar;\n            \n            return *this;\n        }\n\n    public:\n        \n        f32 r, g, b, a;\n    };\n    \n    //-----------------------------------------------------------\n    /// @author S Downie\n    ///\n    /// @param LHS of addition\n    /// @param RHS of addition\n    ///\n    /// @return Component wise addition of colours\n    //-----------------------------------------------------------\n    inline Colour operator+(const Colour& in_lhs, const Colour& in_rhs)\n    {\n        return Colour(in_lhs.r + in_rhs.r, in_lhs.g + in_rhs.g, in_lhs.b + in_rhs.b, in_lhs.a + in_rhs.a);\n    }\n    //-----------------------------------------------------------\n    /// @author S Downie\n    ///\n    /// @param LHS of addition (colour)\n    /// @param RHS of addition (scalar)\n    ///\n    /// @return scalar addition of colours\n    //-----------------------------------------------------------\n    inline Colour operator+(const Colour& in_colour, f32 in_scalar)\n    {\n        return Colour(in_colour.r + in_scalar, in_colour.g + in_scalar, in_colour.b + in_scalar, in_colour.a + in_scalar);\n    }\n    //-----------------------------------------------------------\n    /// @author Ian Copland\n    ///\n    /// @param LHS of addition (scalar)\n    /// @param RHS of addition (colour)\n    ///\n    /// @return The colour added to the scalar.\n    //-----------------------------------------------------------\n    inline Colour operator+(f32 in_scalar, const Colour& in_colour)\n    {\n        return in_colour + in_scalar;\n    }\n    //-----------------------------------------------------------\n    /// @author S Downie\n    ///\n    /// @param LHS of subtraction\n    /// @param RHS of subtraction\n    ///\n    /// @return Component wise subtraction of colours\n    //-----------------------------------------------------------\n    inline Colour operator-(const Colour& in_lhs, const Colour& in_rhs)\n    {\n        return Colour(in_lhs.r - in_rhs.r, in_lhs.g - in_rhs.g, in_lhs.b - in_rhs.b, in_lhs.a - in_rhs.a);\n    }\n    //-----------------------------------------------------------\n    /// @author S Downie\n    ///\n    /// @param LHS of subtraction (colour)\n    /// @param RHS of subtraction (scalar)\n    ///\n    /// @return scalar subtraction of colours\n    //-----------------------------------------------------------\n    inline Colour operator-(const Colour& in_colour, f32 in_scalar)\n    {\n        return Colour(in_colour.r - in_scalar, in_colour.g - in_scalar, in_colour.b - in_scalar, in_colour.a - in_scalar);\n    }\n    //-----------------------------------------------------------\n    /// @author Ian Copland\n    ///\n    /// @param LHS of subtraction (colour)\n    /// @param RHS of subtraction (scalar)\n    ///\n    /// @return The colour subtracted from the scalar.\n    //-----------------------------------------------------------\n    inline Colour operator-(f32 in_scalar, const Colour& in_colour)\n    {\n        return Colour(in_scalar - in_colour.r, in_scalar - in_colour.g, in_scalar - in_colour.b, in_scalar - in_colour.a);\n    }\n    //-----------------------------------------------------------\n    /// @author S Downie\n    ///\n    /// @param LHS of multiplication\n    /// @param RHS of multiplication\n    ///\n    /// @return Component wise multiplication of colours\n    //-----------------------------------------------------------\n    inline Colour operator*(const Colour& in_lhs, const Colour& in_rhs)\n    {\n        return Colour(in_lhs.r * in_rhs.r, in_lhs.g * in_rhs.g, in_lhs.b * in_rhs.b, in_lhs.a * in_rhs.a);\n    }\n    //-----------------------------------------------------------\n    /// @author S Downie\n    ///\n    /// @param LHS of multiplication (colour)\n    /// @param RHS of multiplication (scalar)\n    ///\n    /// @return scalar multiplication of colours\n    //-----------------------------------------------------------\n    inline Colour operator*(const Colour& in_colour, f32 in_scalar)\n    {\n        return Colour(in_colour.r * in_scalar, in_colour.g * in_scalar, in_colour.b * in_scalar, in_colour.a * in_scalar);\n    }\n    //-----------------------------------------------------------\n    /// @author Ian Copland\n    ///\n    /// @param LHS of multiplication (colour)\n    /// @param RHS of multiplication (scalar)\n    ///\n    /// @return The scalar multiplied by the colour.\n    //-----------------------------------------------------------\n    inline Colour operator*(f32 in_scalar, const Colour& in_colour)\n    {\n        return in_colour * in_scalar;\n    }\n    //-----------------------------------------------------------\n    /// @author S Downie\n    ///\n    /// @param LHS of division\n    /// @param RHS of division\n    ///\n    /// @return Component wise division of colours\n    //-----------------------------------------------------------\n    inline Colour operator/(const Colour& in_lhs, const Colour& in_rhs)\n    {\n        return Colour(in_lhs.r / in_rhs.r, in_lhs.g / in_rhs.g, in_lhs.b / in_rhs.b, in_lhs.a / in_rhs.a);\n    }\n    //-----------------------------------------------------------\n    /// @author S Downie\n    ///\n    /// @param LHS of division (colour)\n    /// @param RHS of division (scalar)\n    ///\n    /// @return scalar division of colours\n    //-----------------------------------------------------------\n    inline Colour operator/(const Colour& in_colour, f32 in_scalar)\n    {\n        return Colour(in_colour.r / in_scalar, in_colour.g / in_scalar, in_colour.b / in_scalar, in_colour.a / in_scalar);\n    }\n    //-----------------------------------------------------------\n    /// @author Ian Copland\n    ///\n    /// @param LHS of division (colour)\n    /// @param RHS of division (scalar)\n    ///\n    /// @return The scalar divided by the colour.\n    //-----------------------------------------------------------\n    inline Colour operator/(f32 in_scalar, const Colour& in_colour)\n    {\n        return Colour(in_scalar / in_colour.r, in_scalar / in_colour.g, in_scalar / in_colour.b, in_scalar / in_colour.a);\n    }\n    //-----------------------------------------------------------\n    /// @author S Downie\n    ///\n    /// @param LHS of comparison\n    /// @param RHS of comparison\n    ///\n    /// @return Whether the two colours have equal RGBA components\n    //-----------------------------------------------------------\n    inline bool operator==(const Colour& in_lhs, const Colour& in_rhs)\n    {\n        return in_lhs.r == in_rhs.r && in_lhs.g == in_rhs.g && in_lhs.b == in_rhs.b && in_lhs.a == in_rhs.a;\n    }\n    //-----------------------------------------------------------\n    /// @author S Downie\n    ///\n    /// @param LHS of comparison\n    /// @param RHS of comparison\n    ///\n    /// @return Whether the two colours have unequal RGBA components\n    //-----------------------------------------------------------\n    inline bool operator!=(const Colour& in_lhs, const Colour& in_rhs)\n    {\n        return in_lhs.r != in_rhs.r || in_lhs.g != in_rhs.g || in_lhs.b != in_rhs.b || in_lhs.a != in_rhs.a;\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Base/ColourUtils.cpp",
    "content": "//\n//  ColourUtils.cpp\n//  ChilliSource\n//  Created by Scott Downie on 03/04/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Core/Base/ColourUtils.h>\n\n#include <ChilliSource/Core/Math/MathUtils.h>\n\nnamespace ChilliSource\n{\n    namespace ColourUtils\n    {\n        //-----------------------------------------------------------\n        //-----------------------------------------------------------\n        ByteColour ColourToByteColour(const Colour& in_colour)\n        {\n            return ColourToByteColour(in_colour.r, in_colour.g, in_colour.b, in_colour.a);\n        }\n        //-----------------------------------------------------------\n        //-----------------------------------------------------------\n        ByteColour ColourToByteColour(f32 in_red, f32 in_green, f32 in_blue, f32 in_alpha)\n        {\n            CS_ASSERT(in_red >= -std::numeric_limits<f32>::epsilon() && in_red <= 1.0f + std::numeric_limits<f32>::epsilon(), \"Colour must be in range 0.0 - 1.0\");\n            CS_ASSERT(in_green >= -std::numeric_limits<f32>::epsilon() && in_green <= 1.0f + std::numeric_limits<f32>::epsilon(), \"Colour must be in range 0.0 - 1.0\");\n            CS_ASSERT(in_blue >= -std::numeric_limits<f32>::epsilon() && in_blue <= 1.0f + std::numeric_limits<f32>::epsilon(), \"Colour must be in range 0.0 - 1.0\");\n            CS_ASSERT(in_alpha >= -std::numeric_limits<f32>::epsilon() && in_alpha <= 1.0f + std::numeric_limits<f32>::epsilon(), \"Colour must be in range 0.0 - 1.0\");\n            \n            ByteColour result;\n            \n            result.r = (u8)MathUtils::Round(in_red * 255.0f);\n            result.g = (u8)MathUtils::Round(in_green * 255.0f);\n            result.b = (u8)MathUtils::Round(in_blue * 255.0f);\n            result.a = (u8)MathUtils::Round(in_alpha * 255.0f);\n            \n            return result;\n        }\n        //-----------------------------------------------------------\n        //-----------------------------------------------------------\n        Colour PackedRGBAToColour(u32 in_rgba)\n        {\n            u8 byteR = (in_rgba >> 24) & 255;\n            u8 byteG = (in_rgba >> 16) & 255;\n            u8 byteB = (in_rgba >> 8) & 255;\n            u8 byteA = (in_rgba) & 255;\n            \n            return Colour((f32)byteR/255.0f, (f32)byteG/255.0f, (f32)byteB/255.0f, (f32)byteA/255.0f);\n        }\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Core/Base/ColourUtils.h",
    "content": "//\n//  ColourUtils.h\n//  ChilliSource\n//  Created by Scott Downie on 03/04/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_BASE_COLOURUTILS_H_\n#define _CHILLISOURCE_CORE_BASE_COLOURUTILS_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Base/ByteColour.h>\n#include <ChilliSource/Core/Base/Colour.h>\n\nnamespace ChilliSource\n{\n    namespace ColourUtils\n    {\n        //-----------------------------------------------------------\n        /// Convert a colour with components in the range 0 - 255\n        /// into a normalised colour container in the range 0.0 - 1.0\n        ///\n        /// @author S Downie\n        ///\n        /// @param Red 0 - 255\n        /// @param Green 0 - 255\n        /// @param Blue 0 - 255\n        /// @param Alpha 0 - 255\n        ///\n        /// @return Normalised colour 0.0 - 1.0\n        //-----------------------------------------------------------\n        inline Colour ByteColourToColour(u8 in_byteR, u8 in_byteG, u8 in_byteB, u8 in_byteA)\n        {\n            return Colour((f32)in_byteR/255.0f, (f32)in_byteG/255.0f, (f32)in_byteB/255.0f, (f32)in_byteA/255.0f);\n        }\n        //-----------------------------------------------------------\n        /// Convert a colour with components in the range 0 - 255\n        /// into a normalised colour container in the range 0.0 - 1.0\n        ///\n        /// @author S Downie\n        ///\n        /// @param Byte colour 0 - 255\n        ///\n        /// @return Normalised colour 0.0 - 1.0\n        //-----------------------------------------------------------\n        inline Colour ByteColourToColour(ByteColour in_colour)\n        {\n            return Colour((f32)in_colour.r/255.0f, (f32)in_colour.g/255.0f, (f32)in_colour.b/255.0f, (f32)in_colour.a/255.0f);\n        }\n        //-----------------------------------------------------------\n        /// Convert a colour with components in the range 0 - 255\n        /// that are packed into a single u32 into a normalised colour\n        /// container in the range 0.0 - 1.0\n        ///\n        /// @author S Downie\n        ///\n        /// @param RGBA\n        ///\n        /// @return Normalised colour 0.0 - 1.0\n        //-----------------------------------------------------------\n        Colour PackedRGBAToColour(u32 in_rgba);\n        //-----------------------------------------------------------\n        /// Convert a colour container with normalised range\n        /// into a byte colour with range 0 - 255\n        ///\n        /// @author S Downie\n        ///\n        /// @param Normalised colour 0.0 - 1.0\n        ///\n        /// @return Byte colour 0 - 255\n        //-----------------------------------------------------------\n        ByteColour ColourToByteColour(const Colour& in_colour);\n        //-----------------------------------------------------------\n        /// Convert a colour container with normalised range\n        /// into a byte colour with range 0 - 255\n        ///\n        /// @author S Downie\n        ///\n        /// @param Normalised red 0.0 - 1.0\n        /// @param Normalised green 0.0 - 1.0\n        /// @param Normalised blue 0.0 - 1.0\n        /// @param Normalised alpha 0.0 - 1.0\n        ///\n        /// @return Byte colour 0 - 255\n        //-----------------------------------------------------------\n        ByteColour ColourToByteColour(f32 in_red, f32 in_green, f32 in_blue, f32 in_alpha);\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Base/ConstMethodCast.h",
    "content": "//\n//  ConstMethodCast.h\n//  ChilliSource\n//  Created by Ian Copland on 13/11/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2010 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_BASE_CONSTMETHODCAST_H_\n#define _CHILLISOURCE_CORE_BASE_CONSTMETHODCAST_H_\n\n#include <ChilliSource/ChilliSource.h>\n\n#include <type_traits>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------\n    /// Casts the const away from a pointer return value of a const method.\n    /// This is used to avoid duplicate code when defining both a non-const and\n    /// const version of a method. This should only be used in non-const\n    /// methods of the class that contains the const member, its use elsewhere\n    /// should be considered just as evil as a standard const_cast!\n    ///\n    /// @author Ian Copland\n    ///\n    /// @param The object that contains the const method. This should always\n    /// be \"this\" when called, and cannot be a const instance.\n    /// @param The method that should be called.\n    /// @param The arguments to the method.\n    ///\n    /// @return The return value from the method with const removed.\n    //------------------------------------------------------------------------\n    template <typename TClassType, typename TReturnType, typename... TArgs> TReturnType* ConstMethodCast(TClassType* in_object, const TReturnType*(TClassType::*in_method)(TArgs...) const, TArgs&& ...in_args)\n    {\n        const TReturnType* constReturn = (static_cast<const TClassType*>(in_object)->*in_method)(std::forward<TArgs>(in_args)...);\n        return const_cast<TReturnType*>(constReturn);\n    }\n    //------------------------------------------------------------------------\n    /// Casts the const away from a reference return value of a const method.\n    /// This is used to avoid duplicate code when defining both a non-const and\n    /// const version of a method. This should only be used in non-const\n    /// methods of the class that contains the const member, its use elsewhere\n    /// should be considered just as evil as a standard const_cast!\n    ///\n    /// @author Ian Copland\n    ///\n    /// @param The object that contains the const method. This should always\n    /// be \"this\" when called, and cannot be a const instance.\n    /// @param The method that should be called.\n    /// @param The arguments to the method.\n    ///\n    /// @return The return value from the method with const removed.\n    //------------------------------------------------------------------------\n    template <typename TClassType, typename TReturnType, typename... TArgs> TReturnType& ConstMethodCast(TClassType* in_object, const TReturnType&(TClassType::*in_method)(TArgs...) const, TArgs&& ...in_args)\n    {\n        const TReturnType& constReturn = (static_cast<const TClassType*>(in_object)->*in_method)(std::forward<TArgs>(in_args)...);\n        return const_cast<TReturnType&>(constReturn);\n    }\n    //------------------------------------------------------------------------\n    /// Casts the const away from a shared pointer return value of a const method.\n    /// This is used to avoid duplicate code when defining both a non-const and\n    /// const version of a method. This should only be used in non-const\n    /// methods of the class that contains the const member, its use elsewhere\n    /// should be considered just as evil as a standard const_cast!\n    ///\n    /// @author Ian Copland\n    ///\n    /// @param The object that contains the const method. This should always\n    /// be \"this\" when called, and cannot be a const instance.\n    /// @param The method that should be called.\n    /// @param The arguments to the method.\n    ///\n    /// @return The return value from the method with const removed.\n    //------------------------------------------------------------------------\n    template <typename TClassType, typename TReturnType, typename... TArgs> std::shared_ptr<TReturnType> ConstMethodCast(TClassType* in_object, std::shared_ptr<const TReturnType>(TClassType::*in_method)(TArgs...) const, TArgs&& ...in_args)\n    {\n        std::shared_ptr<const TReturnType> constReturn = (static_cast<const TClassType*>(in_object)->*in_method)(std::forward<TArgs>(in_args)...);\n        return std::const_pointer_cast<TReturnType>(constReturn);\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Base/CursorType.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2017 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_BASE_CURSORTYPE_H_\n#define _CHILLISOURCE_CORE_BASE_CURSORTYPE_H_\n\n#include <ChilliSource/ChilliSource.h>\n\nnamespace ChilliSource\n{\n    enum class CursorType\n    {\n        k_none,         //No cursor\n        k_system,       //System hardware cursor if available\n        k_nonSystem     //Software cursor if available\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Base/Device.cpp",
    "content": "//\n//  Device.cpp\n//  ChilliSource\n//  Created by Scott Downie on 03/05/2011.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2011 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Core/Base/Device.h>\n#include <ChilliSource/Core/Base/DeviceInfo.h>\n\nnamespace ChilliSource\n{\n    CS_DEFINE_NAMEDTYPE(Device);\n    //--------------------------------------------------\n    DeviceUPtr Device::Create(const ChilliSource::DeviceInfo& deviceInfo)\n    {\n        return DeviceUPtr(new Device(deviceInfo));\n    }\n    //----------------------------------------------------\n    //----------------------------------------------------\n    Device::Device(const ChilliSource::DeviceInfo& deviceInfo) noexcept\n        : m_deviceInfo(deviceInfo)\n    {\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    bool Device::IsA(ChilliSource::InterfaceIDType in_interfaceId) const noexcept\n    {\n        return (Device::InterfaceID == in_interfaceId);\n    }\n    //---------------------------------------------------\n    //---------------------------------------------------\n    const std::string& Device::GetModel() const noexcept\n    {\n        return m_deviceInfo.GetModel();\n    }\n    //---------------------------------------------------\n    //---------------------------------------------------\n    const std::string& Device::GetModelType() const noexcept\n    {\n        return m_deviceInfo.GetModelType();\n    }\n    //---------------------------------------------------\n    //---------------------------------------------------\n    const std::string& Device::GetManufacturer() const noexcept\n    {\n        return m_deviceInfo.GetManufacturer();\n    }\n    //---------------------------------------------------\n    //---------------------------------------------------\n    const std::string& Device::GetLocale() const noexcept\n    {\n        return m_deviceInfo.GetLocale();\n    }\n    //---------------------------------------------------\n    //---------------------------------------------------\n    const std::string& Device::GetLanguage() const noexcept\n    {\n        return m_deviceInfo.GetLanguage();\n    }\n    //---------------------------------------------------\n    //---------------------------------------------------\n    const std::string& Device::GetOSVersion() const noexcept\n    {\n        return m_deviceInfo.GetOSVersion();\n    }\n    //---------------------------------------------------\n    //---------------------------------------------------\n    const std::string& Device::GetUDID() const noexcept\n    {\n        return m_deviceInfo.GetUDID();\n    }\n    //---------------------------------------------------\n    //---------------------------------------------------\n    u32 Device::GetNumberOfCPUCores() const noexcept\n    {\n        return m_deviceInfo.GetNumCPUCores();\n    }\n\n}\n"
  },
  {
    "path": "Source/ChilliSource/Core/Base/Device.h",
    "content": "//\n//  Device.h\n//  ChilliSource\n//  Created by Scott Downie on 03/05/2011.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2011 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_BASE_DEVICE_H_\n#define _CHILLISOURCE_CORE_BASE_DEVICE_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Base/DeviceInfo.h>\n#include <ChilliSource/Core/System/AppSystem.h>\n\n\nnamespace ChilliSource\n{\n    //---------------------------------------------------------\n    /// An application system for providing cross platform\n    /// access to information about the current device. This\n    /// includes information like the current model name and\n    /// the number of CPU cores. It is safe to use this during\n    /// the OnInit() and OnDestroy() lifecycle events.\n    ///\n    /// @author S Downie\n    //---------------------------------------------------------\n    class Device final : public AppSystem\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(Device);\n        //-------------------------------------------------------\n        /// Queries whether or not this system implements the\n        /// interface with the given Id.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The interface Id.\n        /// @param Whether system is of given type.\n        //-------------------------------------------------------\n        bool IsA(ChilliSource::InterfaceIDType in_interfaceId) const noexcept override;\n        //---------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The device model name.\n        //---------------------------------------------------\n        const std::string& GetModel() const noexcept;\n        //---------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The name of the device model type.\n        //---------------------------------------------------\n        const std::string& GetModelType() const noexcept;\n        //---------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The name of the device manufacturer.\n        //---------------------------------------------------\n        const std::string& GetManufacturer() const noexcept;\n        //---------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return The locale code registered with the\n        /// device.\n        //---------------------------------------------------\n        const std::string& GetLocale() const noexcept;\n        //---------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return The language the device is set to.\n        //---------------------------------------------------\n        const std::string& GetLanguage() const noexcept;\n        //---------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return The version of the operating system.\n        //---------------------------------------------------\n        const std::string& GetOSVersion() const noexcept;\n        //---------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return An identifier that can be used to uniquely\n        /// identify the device.\n        //---------------------------------------------------\n        const std::string& GetUDID() const noexcept;\n        //---------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return The number of CPU cores available on the\n        /// device.\n        //---------------------------------------------------\n        u32 GetNumberOfCPUCores() const noexcept;\n\n    protected:\n        friend class Application;\n        //---------------------------------------------------\n        /// Creates the system.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @return The new instance.\n        //---------------------------------------------------\n        static DeviceUPtr Create(const ChilliSource::DeviceInfo& deviceInfo);\n        //----------------------------------------------------\n        /// Constructor. Declared private to force the use of\n        /// the factory method.\n        ///\n        /// @author Ian Copland\n        //----------------------------------------------------\n        Device(const ChilliSource::DeviceInfo& deviceInfo) noexcept;\n\n        DeviceInfo m_deviceInfo;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Base/DeviceInfo.cpp",
    "content": "//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Core/Base/DeviceInfo.h>\n\nnamespace ChilliSource\n{\n    //----------------------------------------------------------------\n    DeviceInfo::DeviceInfo(const std::string& model, const std::string& modelType, const std::string& manufacturer, const std::string& udid, const std::string& locale, const std::string& language, const std::string& osVersion, u32 numCPUCores) noexcept\n        : m_model(model), m_modelType(modelType), m_manufacturer(manufacturer), m_udid(udid), m_locale(locale), m_language(language), m_osVersion(osVersion), m_numCPUCores(numCPUCores) \n    {\n    }\n\n    //----------------------------------------------------------------\n    const std::string& DeviceInfo::GetModel() const noexcept\n    {\n        return m_model;\n    }\n    \n    //----------------------------------------------------------------\n    const std::string& DeviceInfo::GetModelType() const noexcept\n    {\n        return m_modelType;\n    }\n\n    //----------------------------------------------------------------\n    const std::string& DeviceInfo::GetManufacturer() const noexcept\n    {\n        return m_manufacturer;\n    }\n\n    //----------------------------------------------------------------\n    const std::string& DeviceInfo::GetUDID() const noexcept\n    {\n        return m_udid;\n    }\n\n    //----------------------------------------------------------------\n    const std::string& DeviceInfo::GetLocale() const noexcept\n    {\n        return m_locale;\n    }\n\n    //----------------------------------------------------------------\n    const std::string& DeviceInfo::GetLanguage() const noexcept\n    {\n        return m_language;\n    }\n\n    //----------------------------------------------------------------\n    const std::string& DeviceInfo::GetOSVersion() const noexcept\n    {\n        return m_osVersion;\n    }\n\n    //----------------------------------------------------------------\n    u32 DeviceInfo::GetNumCPUCores() const noexcept\n    {\n        return m_numCPUCores;\n    }\n}"
  },
  {
    "path": "Source/ChilliSource/Core/Base/DeviceInfo.h",
    "content": "//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_BASE_DEVICEINFO_H_\n#define _CHILLISOURCE_CORE_BASE_DEVICEINFO_H_\n\n#include <ChilliSource/ChilliSource.h>\n\nnamespace ChilliSource\n{\n    /// This class contains information necessary for building\n    /// the Device class.\n    ///\n    /// This class is immutable, and therefore thread-safe.\n    ///\n    class DeviceInfo final\n    {\n        public:\n            /// Constructs the DeviceInfo class.\n            ///\n            /// @param model\n            ///         The device model name.\n            /// @param modelType\n            ///         The device model type.\n            /// @param manufacturer\n            ///         The name of the device manufacturer.\n            /// @param udid\n            ///         An identifier that can be used to uniquely\n            ///         identify the device.\n            /// @param locale\n            ///         The locale code registered with the device.\n            /// @param language\n            ///         The language the device is set to.\n            /// @param osVersion\n            ///         The version of the operating system.\n            /// @param numCPUCores\n            ///         The number of CPU cores available on the device.\n            ///\n            DeviceInfo(const std::string& model, const std::string& modelType, const std::string& manufacturer, const std::string& udid, const std::string& locale, const std::string& language, const std::string& osVersion, u32 numCPUCores) noexcept;\n\n            /// @return The device model name.\n            ///\n            const std::string& GetModel() const noexcept;\n\n            /// @return The name of the device model type.\n            ///\n            const std::string& GetModelType() const noexcept;\n\n            /// @return The name of the device manufacturer.\n            ///\n            const std::string& GetManufacturer() const noexcept;\n\n            /// @return An identifier that can be used to uniquely\n            /// identify the device.\n            ///\n            const std::string& GetUDID() const noexcept;\n\n            /// @return The locale code registered with the\n            /// device.\n            ///\n            const std::string& GetLocale() const noexcept;\n\n            /// @return The language the device is set to.\n            ///\n            const std::string& GetLanguage() const noexcept;\n\n            /// @return The version of the operating system.\n            ///\n            const std::string& GetOSVersion() const noexcept;\n\n            /// @return The number of CPU cores available on the\n            /// device.\n            ///\n            u32 GetNumCPUCores() const noexcept;\n\n        private:\n            std::string m_model;\n            std::string m_modelType;\n            std::string m_manufacturer;\n            std::string m_udid;\n            std::string m_locale;\n            std::string m_language;\n            std::string m_osVersion;\n            u32 m_numCPUCores;\n    };\n}\n\n#endif"
  },
  {
    "path": "Source/ChilliSource/Core/Base/GenericFactory.h",
    "content": "//\n//  GenericFactory.h\n//  ChilliSource\n//  Created by Ian Copland on 08/11/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _ICENGINE_RENDERING_PARTICLES_GENERICFACTORY_H_\n#define _ICENGINE_RENDERING_PARTICLES_GENERICFACTORY_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Delegate/MakeDelegate.h>\n#include <ChilliSource/Core/System/AppSystem.h>\n\n#include <json/json.h>\n\n#include <functional>\n#include <unordered_map>\n\nnamespace ChilliSource\n{\n    //--------------------------------------------------------------------------\n    /// A generic factory for creating concrete instances of an abstract class\n    /// using only a string name and json parameters. Instances can be created\n    /// either on the main thread or asynchronously.\n    ///\n    /// The object being constructed must provide two constructors: \n    /// \n    /// TConcreteType(const Json::Value&);\n    /// TConcreteType(const Json::Value&, const std::function<void(TAbstractType*)>);\n    ///\n    /// @author Ian Copland\n    //--------------------------------------------------------------------------\n    template <typename TAbstractType> class GenericFactory : public AppSystem\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(GenericFactory);\n        //-----------------------------------------------------------------\n        /// Asynchronous load completion delegate. This will be called once\n        /// the object has been fully loaded.\n        /// \n        /// @author Ian Copland\n        ///\n        /// @param The loaded affector def\n        //-----------------------------------------------------------------\n        using AsyncLoadDelegate = std::function<void(std::unique_ptr<TAbstractType> in_abstract)>;\n        //-----------------------------------------------------------------\n        /// Registers a new particle affector definition type with the \n        /// factory. Future calls to CreateAffectorDef() with the given name \n        /// will instantiate a particle affector definition of this type. \n        /// The given name must be unique, this will try to assert if it is\n        /// not.\n        ///\n        /// This is not thread-safe and should only be called on the main\n        /// thread.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The name of the affector def.\n        //-----------------------------------------------------------------\n        template <typename TConcreteType> void Register(const std::string& in_concreteTypeName);\n        //-----------------------------------------------------------------\n        /// Creates an instance of the concrete type registered under the \n        /// given name with the given json description. \n        ///\n        /// This is in not thread-safe and should only be called on the\n        /// main thread. CreateAsync() should be used for background loading.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The name of the concrete type previously registered with\n        /// the factory.\n        /// @param A json object describing the parameters of the concrete\n        /// type.\n        ///\n        /// @return The new instance.\n        //-----------------------------------------------------------------\n        std::unique_ptr<TAbstractType> CreateInstance(const std::string& in_name, const Json::Value& in_jsonParams) const;\n        //-----------------------------------------------------------------\n        /// Creates an instance of the concrete type registered under the \n        /// given name with the given json description. The object will\n        /// be asynchronously created and returned via the async load \n        /// delegate.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The name of the concrete type previously registered with\n        /// the factory.\n        /// @param A json object describing the parameters of the concrete\n        /// type.\n        /// @param The async load delegate.\n        //-----------------------------------------------------------------\n        void CreateInstanceAsync(const std::string& in_name, const Json::Value& in_jsonParams, const AsyncLoadDelegate& in_asyncLoadDelegate) const;\n    private:\n        //-----------------------------------------------------------------\n        /// A method for sub-classes to register their default concrete\n        /// classes. This is called during OnInit().\n        ///\n        /// @author Ian Copland\n        //-----------------------------------------------------------------\n        virtual void RegisterDefaults() = 0;\n    protected:\n        //-----------------------------------------------------------------\n        /// A delegate which is used to instantiate the registered concrete\n        /// class.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param A json object describing the parameters to create the\n        /// concrete class with.\n        //-----------------------------------------------------------------\n        using CreatorDelegate = std::function<std::unique_ptr<TAbstractType>(const Json::Value& in_jsonParams)>;\n        //-----------------------------------------------------------------\n        /// A delegate which is used to instantiate the registered concrete\n        /// class asynchronously.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param A json object describing the parameters to create the\n        /// concrete class with.\n        /// @param The async load delegate.\n        //-----------------------------------------------------------------\n        using CreatorAsyncDelegate = std::function<void(const Json::Value& in_jsonParams, const AsyncLoadDelegate& in_asyncLoadDelegate)>;\n        //-----------------------------------------------------------------\n        /// Creates a new instance of the concrete class. This is the method\n        /// refered to by the creator delegates.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param A json object describing the parameters for the concrete\n        /// class.\n        //-----------------------------------------------------------------\n        template <typename TConcreteType> std::unique_ptr<TAbstractType> CreateInstance(const Json::Value& in_jsonParams) const;\n        //-----------------------------------------------------------------\n        /// Creates a new instance of the concrete class asynchronously.\n        /// The async load delegate will be called once created.  This is \n        /// the method refered to by the async creator delegates.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param A json object describing the parameters for the concrete\n        /// class.\n        /// @param The async load delegate.\n        //-----------------------------------------------------------------\n        template <typename TConcreteType> void CreateInstanceAsync(const Json::Value& in_jsonParams, const AsyncLoadDelegate& in_asyncLoadDelegate) const;\n        //-----------------------------------------------------------------\n        /// Initialised the factory calling the RegisterDefaults() method\n        /// for subclasses to register their default concrete classes.\n        ///\n        /// @author Ian Copland\n        //-----------------------------------------------------------------\n        void OnInit() override;\n        //-----------------------------------------------------------------\n        /// Deregisters all concrete classes.\n        ///\n        /// @author Ian Copland\n        //-----------------------------------------------------------------\n        void OnDestroy() override;\n\n        std::unordered_map<std::string, CreatorDelegate> m_creatorDelegateMap;\n        std::unordered_map<std::string, CreatorAsyncDelegate> m_creatorAsyncDelegateMap;\n    };\n    CS_DEFINE_NAMEDTYPETEMPLATED(GenericFactory, TAbstractType);\n    //-----------------------------------------------------------------\n    //-----------------------------------------------------------------\n    template <typename TAbstractType> template <typename TConcreteType> void GenericFactory<TAbstractType>::Register(const std::string& in_typeName)\n    {\n        m_creatorDelegateMap.insert(std::make_pair(in_typeName, MakeDelegate(this, &GenericFactory<TAbstractType>::CreateInstance<TConcreteType>)));\n        m_creatorAsyncDelegateMap.insert(std::make_pair(in_typeName, MakeDelegate(this, &GenericFactory<TAbstractType>::CreateInstanceAsync<TConcreteType>)));\n    }\n    //-----------------------------------------------------------------\n    //-----------------------------------------------------------------\n    template <typename TAbstractType> std::unique_ptr<TAbstractType> GenericFactory<TAbstractType>::CreateInstance(const std::string& in_name, const Json::Value& in_jsonParams) const\n    {\n        auto delegateIt = m_creatorDelegateMap.find(in_name);\n        CS_ASSERT(delegateIt != m_creatorDelegateMap.end(), \"Could not create object with name: \" + in_name);\n\n        return delegateIt->second(in_jsonParams);\n    }\n    //-----------------------------------------------------------------\n    //-----------------------------------------------------------------\n    template <typename TAbstractType> void GenericFactory<TAbstractType>::CreateInstanceAsync(const std::string& in_name, const Json::Value& in_jsonParams, const AsyncLoadDelegate& in_asyncLoadDelegate) const\n    {\n        auto delegateIt = m_creatorAsyncDelegateMap.find(in_name);\n        CS_ASSERT(delegateIt != m_creatorAsyncDelegateMap.end(), \"Could not create particle affector def with name: \" + in_name);\n\n        delegateIt->second(in_jsonParams, in_asyncLoadDelegate);\n    }\n    //-----------------------------------------------------------------\n    //-----------------------------------------------------------------\n    template <typename TAbstractType> template <typename TConcreteType> std::unique_ptr<TAbstractType> GenericFactory<TAbstractType>::CreateInstance(const Json::Value& in_jsonParams) const\n    {\n        return std::unique_ptr<TAbstractType>(new TConcreteType(in_jsonParams));\n    }\n    //-----------------------------------------------------------------\n    //-----------------------------------------------------------------\n    template <typename TAbstractType> template <typename TConcreteType> void GenericFactory<TAbstractType>::CreateInstanceAsync(const Json::Value& in_jsonParams, const AsyncLoadDelegate& in_asyncLoadDelegate) const\n    {\n        new TConcreteType(in_jsonParams, [=](TAbstractType* in_loaded)\n        {\n            in_asyncLoadDelegate(std::unique_ptr<TAbstractType>(in_loaded));\n        });\n    }\n    //-----------------------------------------------------------------\n    //-----------------------------------------------------------------\n    template <typename TAbstractType> void GenericFactory<TAbstractType>::OnInit()\n    {\n        RegisterDefaults();\n    }\n    //-----------------------------------------------------------------\n    //-----------------------------------------------------------------\n    template <typename TAbstractType> void GenericFactory<TAbstractType>::OnDestroy()\n    {\n        m_creatorDelegateMap.clear();\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Base/LifecycleManager.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Core/Base/LifecycleManager.h>\n\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/Resource/ResourcePool.h>\n#include <ChilliSource/Core/Threading/TaskScheduler.h>\n#include <ChilliSource/Rendering/Base/RenderCommandBufferManager.h>\n#include <ChilliSource/Rendering/Base/Renderer.h>\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n#   include <CSBackend/Platform/Android/Main/JNI/Core/Java/JavaVirtualMachine.h>\n#endif\n\n#if defined(CS_TARGETPLATFORM_IOS) || defined(CS_TARGETPLATFORM_ANDROID) || defined(CS_TARGETPLATFORM_WINDOWS) || defined(CS_TARGETPLATFORM_RPI)\n    #include <CSBackend/Rendering/OpenGL/Base/GLContextRestorer.h>\n#endif\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    LifecycleManager::LifecycleManager(Application* application) noexcept\n        : m_application(application), m_targetLifecycleState(LifecycleState::k_initialised)\n    {\n        m_mainThread = std::thread(std::bind(&LifecycleManager::ProcessMainThread, this));\n        \n        std::unique_lock<std::mutex> lock(m_initialisedMutex);\n        while (!m_initialised)\n        {\n            m_initialisedCondition.wait(lock);\n        }\n    }\n    \n    //------------------------------------------------------------------------------\n    void LifecycleManager::Resume() noexcept\n    {\n        CS_ASSERT(m_targetLifecycleState == LifecycleState::k_initialised, \"Cannot resume as target lifecycle state is invalid.\");\n        m_targetLifecycleState = LifecycleState::k_resumed;\n        \n        SystemResume();\n        \n        m_activeCondition.notify_one();\n    }\n    \n    //------------------------------------------------------------------------------\n    void LifecycleManager::SystemResume() noexcept\n    {\n        m_application->GetSystem<Renderer>()->OnSystemResume();\n    }\n    \n    //------------------------------------------------------------------------------\n    void LifecycleManager::Foreground() noexcept\n    {\n        CS_ASSERT(m_targetLifecycleState == LifecycleState::k_resumed, \"Cannot foreground as target lifecycle state is invalid.\");\n        m_targetLifecycleState = LifecycleState::k_foregrounded;\n        \n        m_activeCondition.notify_one();\n    }\n    \n    //------------------------------------------------------------------------------\n    void LifecycleManager::Background() noexcept\n    {\n        CS_ASSERT(m_targetLifecycleState == LifecycleState::k_foregrounded, \"Cannot background as target lifecycle state is invalid.\");\n        m_targetLifecycleState = LifecycleState::k_resumed;\n        \n        m_activeCondition.notify_one();\n    }\n    \n    //------------------------------------------------------------------------------\n    void LifecycleManager::Suspend() noexcept\n    {\n        CS_ASSERT(m_targetLifecycleState == LifecycleState::k_resumed, \"Cannot suspend as target lifecycle state is invalid.\");\n        m_targetLifecycleState = LifecycleState::k_initialised;\n        \n        SystemSuspend();\n        \n        m_activeCondition.notify_one();\n    }\n    \n    //------------------------------------------------------------------------------\n    void LifecycleManager::SystemSuspend() noexcept\n    {\n        m_application->GetSystem<RenderCommandBufferManager>()->OnSystemSuspend();\n        m_application->GetSystem<Renderer>()->OnSystemSuspend();\n        \n#if defined(CS_TARGETPLATFORM_IOS) || defined(CS_TARGETPLATFORM_ANDROID) || defined(CS_TARGETPLATFORM_WINDOWS) || defined(CS_TARGETPLATFORM_RPI)\n        m_application->GetSystem<CSBackend::OpenGL::GLContextRestorer>()->OnSystemSuspend();\n#endif\n    }\n    \n    //------------------------------------------------------------------------------\n    void LifecycleManager::Render() noexcept\n    {\n        CS_ASSERT(m_targetLifecycleState == LifecycleState::k_resumed || m_targetLifecycleState == LifecycleState::k_foregrounded, \"Cannot render as target lifecycle state is invalid.\");\n        \n        m_application->Render();\n    }\n    \n    //------------------------------------------------------------------------------\n    void LifecycleManager::SystemUpdate() noexcept\n    {\n        m_application->GetTaskScheduler()->ExecuteSystemThreadTasks();\n    }\n    \n    //------------------------------------------------------------------------------\n    void LifecycleManager::MemoryWarning() noexcept\n    {\n        m_application->GetResourcePool()->ReleaseAllUnused();\n        \n        m_application->GetTaskScheduler()->ScheduleTask(TaskType::k_mainThread, [=](const TaskContext&)\n        {\n            m_application->MemoryWarning();\n        });\n    }\n    \n    //------------------------------------------------------------------------------\n    constexpr bool LifecycleManager::ShouldInit(LifecycleState currentLifecycleState, LifecycleState targetLifecycleState) noexcept\n    {\n        return (currentLifecycleState == LifecycleState::k_uninitialised && targetLifecycleState != LifecycleState::k_uninitialised);\n    }\n    \n    //------------------------------------------------------------------------------\n    constexpr bool LifecycleManager::ShouldResume(LifecycleState currentLifecycleState, LifecycleState targetLifecycleState) noexcept\n    {\n        return ((currentLifecycleState == LifecycleState::k_uninitialised || currentLifecycleState == LifecycleState::k_initialised) &&\n                (targetLifecycleState == LifecycleState::k_resumed || targetLifecycleState == LifecycleState::k_foregrounded));\n    }\n    \n    //------------------------------------------------------------------------------\n    constexpr bool LifecycleManager::ShouldForeground(LifecycleState currentLifecycleState, LifecycleState targetLifecycleState) noexcept\n    {\n        return (currentLifecycleState != LifecycleState::k_foregrounded && targetLifecycleState == LifecycleState::k_foregrounded);\n    }\n    \n    //------------------------------------------------------------------------------\n    constexpr bool LifecycleManager::ShouldUpdate(LifecycleState targetLifecycleState) noexcept\n    {\n        return (targetLifecycleState == LifecycleState::k_resumed || targetLifecycleState == LifecycleState::k_foregrounded);\n    }\n    \n    //------------------------------------------------------------------------------\n    constexpr bool LifecycleManager::ShouldBackground(LifecycleState currentLifecycleState, LifecycleState targetLifecycleState) noexcept\n    {\n        return (currentLifecycleState == LifecycleState::k_foregrounded && targetLifecycleState != LifecycleState::k_foregrounded);\n    }\n    \n    //------------------------------------------------------------------------------\n    constexpr bool LifecycleManager::ShouldSuspend(LifecycleState currentLifecycleState, LifecycleState targetLifecycleState) noexcept\n    {\n        return ((currentLifecycleState == LifecycleState::k_foregrounded || currentLifecycleState == LifecycleState::k_resumed) &&\n                (targetLifecycleState == LifecycleState::k_initialised || targetLifecycleState == LifecycleState::k_uninitialised));\n    }\n    \n    //------------------------------------------------------------------------------\n    constexpr bool LifecycleManager::ShouldDestroy(LifecycleState currentLifecycleState, LifecycleState targetLifecycleState) noexcept\n    {\n        return (currentLifecycleState != LifecycleState::k_uninitialised && targetLifecycleState == LifecycleState::k_uninitialised);\n    }\n\n    //------------------------------------------------------------------------------\n    void LifecycleManager::ProcessMainThread() noexcept\n    {\n#ifdef CS_TARGETPLATFORM_ANDROID\n        CSBackend::Android::JavaVirtualMachine::Get()->AttachCurrentThread();\n#endif\n\n        while (true)\n        {\n            BlockIfInactive();\n            \n            auto currentLifecycleState = m_currentLifecycleState;\n            LifecycleState targetLifecycleState = m_targetLifecycleState;\n            m_currentLifecycleState = targetLifecycleState;\n            \n            auto shouldInit = ShouldInit(currentLifecycleState, targetLifecycleState);\n            auto shouldResume = ShouldResume(currentLifecycleState, targetLifecycleState);\n            auto shouldForeground = ShouldForeground(currentLifecycleState, targetLifecycleState);\n            auto shouldUpdate = ShouldUpdate(targetLifecycleState);\n            auto shouldBackground = ShouldBackground(currentLifecycleState, targetLifecycleState);\n            auto shouldSuspend = ShouldSuspend(currentLifecycleState, targetLifecycleState);\n            auto shouldDestroy = ShouldDestroy(currentLifecycleState, targetLifecycleState);\n            \n            if (shouldInit)\n            {\n                m_initTime = std::chrono::system_clock::now();\n                \n                m_application->Init();\n                \n                std::unique_lock<std::mutex> lock(m_initialisedMutex);\n                m_initialised = true;\n                lock.unlock();\n                \n                m_initialisedCondition.notify_all();\n            }\n            \n            if (shouldResume)\n            {\n                m_lastUpdateTime = std::chrono::system_clock::now();\n                \n                m_application->Resume();\n            }\n            \n            if (shouldForeground)\n            {\n                m_application->Foreground();\n            }\n            \n            if (shouldUpdate)\n            {\n                auto timeNow = std::chrono::system_clock::now();\n                std::chrono::duration<float> deltaTime = timeNow - m_lastUpdateTime;\n                std::chrono::duration<double> runningTime = timeNow - m_initTime;\n                \n                m_lastUpdateTime = timeNow;\n                \n                m_application->Update(deltaTime.count(), TimeIntervalSecs(runningTime.count()));\n            }\n            \n            if (shouldBackground)\n            {\n                m_application->Background();\n            }\n            \n            if (shouldSuspend)\n            {\n                m_application->Suspend();\n            }\n            \n            if (shouldDestroy)\n            {\n                m_application->Destroy();\n                break;\n            }\n        }\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n        CSBackend::Android::JavaVirtualMachine::Get()->DetachCurrentThread();\n#endif\n    }\n    \n    //------------------------------------------------------------------------------\n    void LifecycleManager::BlockIfInactive() noexcept\n    {\n        std::unique_lock<std::mutex> lock(m_mainThreadMutex);\n        while (m_targetLifecycleState == m_currentLifecycleState && (m_currentLifecycleState == LifecycleState::k_uninitialised || m_currentLifecycleState == LifecycleState::k_initialised))\n        {\n            m_activeCondition.wait(lock);\n        }\n    }\n    \n    //------------------------------------------------------------------------------\n    LifecycleManager::~LifecycleManager() noexcept\n    {\n        CS_ASSERT(m_targetLifecycleState == LifecycleState::k_initialised, \"Cannot destroy as target lifecycle state is invalid.\");\n        m_targetLifecycleState = LifecycleState::k_uninitialised;\n        \n        m_activeCondition.notify_one();\n        \n        m_mainThread.join();\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Core/Base/LifecycleManager.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_BASE_LIFECYCLEMANAGER_H_\n#define _CHILLISOURCE_CORE_BASE_LIFECYCLEMANAGER_H_\n\n#include <ChilliSource/ChilliSource.h>\n\n#include <atomic>\n#include <condition_variable>\n#include <thread>\n\nnamespace ChilliSource\n{\n    /// Manages the main thread lifecycle events. The events are retreived from\n    /// the system thread and then queued for processing on the main thread.\n    ///\n    /// This is thread-safe.\n    ///\n    class LifecycleManager final\n    {\n    public:\n        CS_DECLARE_NOCOPY(LifecycleManager);\n        \n        /// Creates a new lifecycle manager instance with the given Application.\n        /// The initialise event will be sent to the main thread.\n        ///\n        /// @param application\n        ///     The application instance which will receive lifecycle events.\n        ///\n        LifecycleManager(Application* application) noexcept;\n        \n        /// Sends the resume event to the main thread. The app must currently be\n        /// suspended or this will assert.\n        ///\n        /// This is thread safe.\n        ///\n        void Resume() noexcept;\n        \n        /// Sends the foreground event to the main thread. The app must currently\n        /// be backgrounded or this will assert.\n        ///\n        /// This is thread safe.\n        ///\n        void Foreground() noexcept;\n        \n        /// Sends the background event to the main thread. The app must currently\n        /// be foregrounded or this will assert.\n        ///\n        /// This is thread safe.\n        ///\n        void Background() noexcept;\n        \n        /// Sends the background event to the main thread. The app must currently\n        /// be foregrounded or this will assert.\n        ///\n        /// This is thread safe.\n        ///\n        void Suspend() noexcept;\n        \n        /// Sends the render event to the application, rendering to the screen.\n        ///\n        /// This is not thread safe, and must be called from the render thread.\n        ///\n        void Render() noexcept;\n        \n        /// Executes scheduled system thread tasks.\n        ///\n        /// This is not thread safe, and must be called from the system thread.\n        ///\n        void SystemUpdate() noexcept;\n        \n        /// Tells the resource manager to release all and then sends the memory warning\n        /// event to the application.\n        ///\n        void MemoryWarning() noexcept;\n        \n        ~LifecycleManager() noexcept;\n        \n    private:\n        /// Describes the lifecycle states of the application.\n        ///\n        enum class LifecycleState\n        {\n            k_uninitialised,\n            k_initialised,\n            k_resumed,\n            k_foregrounded\n        };\n        \n        /// Evaluates whether or not an init event should occur by comparing the\n        /// current and target lifecycle states.\n        ///\n        /// @param currentLifecycleState\n        ///     The current lifecycle state.\n        /// @param targetLifecycleState\n        ///     The target lifecycle state.\n        ///\n        /// @return Whether or not an init event should occur.\n        ///\n        static constexpr bool ShouldInit(LifecycleState currentLifecycleState, LifecycleState targetLifecycleState) noexcept;\n        \n        /// Evaluates whether or not a resume event should occur by comparing the\n        /// current and target lifecycle states.\n        ///\n        /// @param currentLifecycleState\n        ///     The current lifecycle state.\n        /// @param targetLifecycleState\n        ///     The target lifecycle state.\n        ///\n        /// @return Whether or not a resume event should occur.\n        ///\n        static constexpr bool ShouldResume(LifecycleState currentLifecycleState, LifecycleState targetLifecycleState) noexcept;\n        \n        /// Evaluates whether or not a foreground event should occur by comparing the\n        /// current and target lifecycle states.\n        ///\n        /// @param currentLifecycleState\n        ///     The current lifecycle state.\n        /// @param targetLifecycleState\n        ///     The target lifecycle state.\n        ///\n        /// @return Whether or not a foreground event should occur.\n        ///\n        static constexpr bool ShouldForeground(LifecycleState currentLifecycleState, LifecycleState targetLifecycleState) noexcept;\n        \n        /// Evaluates whether or not an update event should occur by checking the\n        /// target lifecycle is either active or foregrounded.\n        ///\n        /// @param currentLifecycleState\n        ///     The current lifecycle state.\n        /// @param targetLifecycleState\n        ///     The target lifecycle state.\n        ///\n        /// @return Whether or not an update event should occur.\n        ///\n        static constexpr bool ShouldUpdate(LifecycleState targetLifecycleState) noexcept;\n        \n        /// Evaluates whether or not a background event should occur by comparing the\n        /// current and target lifecycle states.\n        ///\n        /// @param currentLifecycleState\n        ///     The current lifecycle state.\n        /// @param targetLifecycleState\n        ///     The target lifecycle state.\n        ///\n        /// @return Whether or not a background event should occur.\n        ///\n        static constexpr bool ShouldBackground(LifecycleState currentLifecycleState, LifecycleState targetLifecycleState) noexcept;\n        \n        /// Evaluates whether or not a suspend event should occur by comparing the\n        /// current and target lifecycle states.\n        ///\n        /// @param currentLifecycleState\n        ///     The current lifecycle state.\n        /// @param targetLifecycleState\n        ///     The target lifecycle state.\n        ///\n        /// @return Whether or not a suspend event should occur.\n        ///\n        static constexpr bool ShouldSuspend(LifecycleState currentLifecycleState, LifecycleState targetLifecycleState) noexcept;\n        \n        /// Evaluates whether or not a destroy event should occur by comparing the\n        /// current and target lifecycle states.\n        ///\n        /// @param currentLifecycleState\n        ///     The current lifecycle state.\n        /// @param targetLifecycleState\n        ///     The target lifecycle state.\n        ///\n        /// @return Whether or not a destroy event should occur.\n        ///\n        static constexpr bool ShouldDestroy(LifecycleState currentLifecycleState, LifecycleState targetLifecycleState) noexcept;\n        \n        /// Processes the main thread lifecycle events which have been received. If\n        /// the app is currently resumed or foregrounded, then update will be called,\n        /// otherwise this will block until a new event occurs.\n        ///\n        void ProcessMainThread() noexcept;\n        \n        /// Blocks the application until a new lifecycle event occurs if the application\n        /// is not currently resumed or foregrounded.\n        ///\n        void BlockIfInactive() noexcept;\n        \n        /// Called when the raw platform resume event is triggered. This is guaranteed\n        /// to happen before the regular OnResume event.\n        ///\n        void SystemResume() noexcept;\n        \n        /// Called when the raw platform suspend event is triggered. This is guaranteed\n        /// to happen before the regular OnSuspend event.\n        ///\n        void SystemSuspend() noexcept;\n        \n        Application* m_application;\n        \n        LifecycleState m_currentLifecycleState = LifecycleState::k_uninitialised;\n        std::atomic<LifecycleState> m_targetLifecycleState;\n        \n        std::chrono::time_point<std::chrono::system_clock> m_initTime;\n        std::chrono::time_point<std::chrono::system_clock> m_lastUpdateTime;\n        \n        std::thread m_mainThread;\n        std::mutex m_mainThreadMutex;\n        std::condition_variable m_activeCondition;\n        \n        std::mutex m_initialisedMutex;\n        bool m_initialised = false;\n        std::condition_variable m_initialisedCondition;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Base/Logging.cpp",
    "content": "//\n//  Logging.cpp\n//  ChilliSource\n//  Created by Scott Downie on 18/10/2010.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2010 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Core/Base/Logging.h>\n\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/File/FileSystem.h>\n\n#include <iostream>\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n#include <android/log.h>\n#include <cstdlib>\nextern \"C\"\n{\n#define CS_ANDROID_LOG_VERBOSE(...) __android_log_print(ANDROID_LOG_DEBUG, \"ChilliSource\", \"%s\", __VA_ARGS__)\n#define CS_ANDROID_LOG_WARNING(...) __android_log_print(ANDROID_LOG_WARN, \"ChilliSource\", \"%s\", __VA_ARGS__)\n#define CS_ANDROID_LOG_ERROR(...) __android_log_print(ANDROID_LOG_ERROR, \"ChilliSource\", \"%s\", __VA_ARGS__)\n}\n#endif\n\n#ifdef CS_TARGETPLATFORM_WINDOWS\n#include <CSBackend/Platform/Windows/Core/String/WindowsStringUtils.h>\n#include <Windows.h>\n#endif\n\n#ifdef CS_TARGETPLATFORM_IOS\n#include <Foundation/NSThread.h>\n#endif\n\n#ifdef CS_ENABLE_DEBUG\n#include <cassert>\n#endif\n\n#if CS_TARGETPLATFORM_IOS\n#import <Foundation/Foundation.h>\n#include <CSBackend/Platform/iOS/Core/String/NSStringUtils.h>\n#endif\n\nnamespace ChilliSource\n{\n    namespace\n    {\n#ifdef CS_ENABLE_LOGTOFILE\n        const u32 k_maxLogBufferSize = 2048;\n        const std::string k_logFileName = \"ChilliSourceLog.txt\";\n#endif\n    }\n    \n    Logging* Logging::s_logging = nullptr;\n    //-----------------------------------------------\n    //-----------------------------------------------\n    void Logging::Create()\n    {\n#ifdef CS_ENABLE_DEBUG\n        assert(s_logging == nullptr);\n#endif\n        s_logging = new Logging();\n    }\n    //-----------------------------------------------\n    //-----------------------------------------------\n    Logging* Logging::Get()\n    {\n#ifdef CS_ENABLE_DEBUG\n        assert(s_logging != nullptr);\n#endif\n        return s_logging;\n    }\n    //----------------------------------------------\n    //----------------------------------------------\n    Logging::Logging()\n#ifdef CS_ENABLE_LOGTOFILE\n        : m_isFirstLog(true)\n#endif\n    {\n    }\n    //----------------------------------------------\n    //----------------------------------------------\n    void Logging::LogVerbose(const std::string &in_message)\n    {\n#if defined CS_LOGLEVEL_VERBOSE\n        LogMessage(LogLevel::k_verbose, in_message);\n#endif\n    }\n    //----------------------------------------------\n    //----------------------------------------------\n    void Logging::LogWarning(const std::string &in_message)\n    {\n#if defined CS_LOGLEVEL_VERBOSE || defined CS_LOGLEVEL_WARNING\n        LogMessage(LogLevel::k_warning, \"WARNING: \" + in_message);\n#endif\n    }\n    //----------------------------------------------\n    //----------------------------------------------\n    void Logging::LogError(const std::string &in_message)\n    {\n#if defined CS_LOGLEVEL_VERBOSE || defined CS_LOGLEVEL_WARNING || defined CS_LOGLEVEL_ERROR\n        LogMessage(LogLevel::k_error, \"ERROR: \" + in_message);\n#endif\n    }\n    //----------------------------------------------\n    //----------------------------------------------\n    void Logging::LogFatal(const std::string &in_message)\n    {\n#if defined CS_LOGLEVEL_VERBOSE || defined CS_LOGLEVEL_WARNING || defined CS_LOGLEVEL_ERROR || defined CS_LOGLEVEL_FATAL\n        LogMessage(LogLevel::k_error, \"FATAL: \" + in_message);\n        LogMessage(LogLevel::k_error, \"ChilliSource is exiting...\");\n#endif\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n        exit(1);\n#else\n#ifdef CS_ENABLE_DEBUG\n        assert(false);\n#else\n        abort();\n#endif\n#endif\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    void Logging::Destroy()\n    {\n        CS_SAFEDELETE(s_logging);\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    void Logging::LogMessage(LogLevel in_logLevel, const std::string& in_message)\n    {\n#ifdef CS_TARGETPLATFORM_ANDROID\n        switch (in_logLevel)\n        {\n            case LogLevel::k_verbose:\n                CS_ANDROID_LOG_VERBOSE(in_message.c_str());\n                break;\n            case LogLevel::k_warning:\n                CS_ANDROID_LOG_WARNING(in_message.c_str());\n                break;\n            case LogLevel::k_error:\n                CS_ANDROID_LOG_ERROR(in_message.c_str());\n                break;\n            \n        }\n#elif defined (CS_TARGETPLATFORM_IOS)\n        NSString* message = [NSStringUtils newNSStringWithUTF8String:in_message];\n        NSLog(@\"[ChilliSource] %@\", message);\n        [message release];\n#elif defined (CS_TARGETPLATFORM_WINDOWS)\n        OutputDebugString(CSBackend::Windows::WindowsStringUtils::UTF8ToUTF16(\"[ChilliSource] \" + in_message + \"\\n\").c_str());\n#elif defined (CS_TARGETPLATFORM_RPI)\n        std::cout << \"[ChilliSource] \" << in_message << std::endl;\n#endif\n        \n#ifdef CS_ENABLE_LOGTOFILE\n        LogToFile(in_message);\n#endif\n    }\n    \n#ifdef CS_ENABLE_LOGTOFILE\n    //-----------------------------------------------\n    //-----------------------------------------------\n    void Logging::CreateLogFile()\n    {\n        FileStreamUPtr stream = Application::Get()->GetFileSystem()->CreateFileStream(StorageLocation::k_cache, k_logFileName, FileMode::k_write);\n        stream->Write(\"ChilliSource Log\");\n    }\n    //-----------------------------------------------\n    //-----------------------------------------------\n    void Logging::LogToFile(const std::string& in_message)\n    {\n        std::unique_lock<std::mutex> lock(m_mutex);\n        m_logBuffer += \"\\n\" + in_message;\n        \n        FileSystem* fileSystem = Application::Get()->GetFileSystem();\n        if(fileSystem != nullptr && m_logBuffer.length() > k_maxLogBufferSize)\n        {\n            if (m_isFirstLog == true)\n            {\n                FileStreamUPtr stream = Application::Get()->GetFileSystem()->CreateFileStream(StorageLocation::k_cache, k_logFileName, FileMode::k_write);\n                stream->Write(\"ChilliSource Log\");\n                stream->Write(m_logBuffer);\n                m_logBuffer.clear();\n                m_isFirstLog = false;\n            }\n            else\n            {\n                FileStreamUPtr stream = Application::Get()->GetFileSystem()->CreateFileStream(StorageLocation::k_cache, k_logFileName, FileMode::k_writeAppend);\n                stream->Write(m_logBuffer);\n                m_logBuffer.clear();\n            }\n        }\n    }\n#endif\n}\n"
  },
  {
    "path": "Source/ChilliSource/Core/Base/Logging.h",
    "content": "//\n//  Logging.h\n//  ChilliSource\n//  Created by Scott Downie on 18/10/2010.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2010 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_BASE_LOGGING_H_\n#define _CHILLISOURCE_CORE_BASE_LOGGING_H_\n\n#include <ChilliSource/ChilliSource.h>\n\n#include <string>\n#include <utility>\n\n#ifdef CS_ENABLE_LOGTOFILE\n#include <mutex>\n#endif\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------\n    /// A cross platform logging system. This provides logging\n    /// of debug, warning, error and fatal error messages. This\n    /// implements the singleton pattern but does not inherit\n    /// from singleton. This is because singleton uses Logging.\n    ///\n    /// @author S Downie\n    //------------------------------------------------------------\n    class Logging final\n    {\n    public:\n        CS_DECLARE_NOCOPY(Logging);\n        //-----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The singleton instance of the Logger.\n        //-----------------------------------------------------\n        static Logging* Get();\n        //-----------------------------------------------------\n        /// Used to output messages while the logging\n        /// level is set to verbose. Declare the preprocessor\n        /// macro CS_LOGLEVEL_VERBOSE to set the logging\n        /// level to verbose. This is typically used for\n        /// outputting messages while debugging.\n        ///\n        /// @author S Downie\n        ///\n        /// @param The message to log.\n        //-----------------------------------------------------\n        void LogVerbose(const std::string& in_message);\n        //-----------------------------------------------------\n        /// Used to output messages while the logging level is set\n        /// to warning or higher. Declare the preprocessor\n        /// macro CS_LOGLEVEL_WARNING to set the logging\n        /// level to warning. This is typically used to warn of\n        /// potential error states that the user can handle.\n        ///\n        /// @author S Downie\n        ///\n        /// @param The message to log.\n        //-----------------------------------------------------\n        void LogWarning(const std::string& in_message);\n        //-----------------------------------------------------\n        /// Used to output messages while the logging level is set to\n        /// error or higher. Declare the preprocessor macro\n        /// CS_LOGLEVEL_ERROR to set the logging level to\n        /// error. This is typically used to indicate that\n        /// the system has not been able to complete a process\n        /// due to entering an error state, but that the\n        /// application can recover from.\n        ///\n        /// @author S Downie\n        ///\n        /// @param The message to log.\n        //-----------------------------------------------------\n        void LogError(const std::string& in_message);\n        //-----------------------------------------------------\n        /// Used to output messages whle the logging level is set to\n        /// fatal or higher and ends the application. Declare the\n        /// preprocessor macro CS_LOGLEVEL_FATAL to set the\n        /// logging level to fatal. This is typically used to\n        /// inform the user that the application has entered into\n        /// an irrecoverable error state.\n        ///\n        /// @author S Downie\n        ///\n        /// @param The message to log.\n        //-----------------------------------------------------\n        void LogFatal(const std::string& in_message);\n        \n        ///\n        /// Used to output messages while the logging level is set to verbose. Declare the preprocessor\n        /// macro CS_LOGLEVEL_VERBOSE to set the logging level to verbose. This is typically used for\n        /// outputting messages while debugging.\n        ///\n        /// This particular method allows for printf style formatted output\n        ///\n        /// @param format\n        ///     The format of the string to print e.g. \"My name is %s\"\n        /// @param args\n        ///     Variadic list of arguments to inject into the format in order\n        ///\n        template <typename... TArgs> void LogVerboseFormatted(char const * const format, TArgs&&... args) noexcept;\n        \n        ///\n        /// Used to output messages while the logging level is set to verbose. Declare the preprocessor\n        /// macro CS_LOGLEVEL_WARNING  or lower to set the logging level to warning. This is typically used for\n        /// outputting messages while debugging.\n        ///\n        /// This particular method allows for printf style formatted output\n        ///\n        /// @param format\n        ///     The format of the string to print e.g. \"My name is %s\"\n        /// @param args\n        ///     Variadic list of arguments to inject into the format in order\n        ///\n        template <typename... TArgs> void LogWarningFormatted(char const * const format, TArgs&&... args) noexcept;\n        \n        ///\n        /// Used to output messages while the logging level is set to verbose. Declare the preprocessor\n        /// macro CS_LOGLEVEL_ERROR or lower to set the logging level to error. This is typically used for\n        /// outputting error messages.\n        ///\n        /// This particular method allows for printf style formatted output\n        ///\n        /// @param format\n        ///     The format of the string to print e.g. \"My name is %s\"\n        /// @param args\n        ///     Variadic list of arguments to inject into the format in order\n        ///\n        template <typename... TArgs> void LogErrorFormatted(char const * const format, TArgs&&... args) noexcept;\n        \n        ///\n        /// Used to output messages while the logging level is set to verbose. This is used for unrecoverable errors and\n        /// will terminate the app.\n        ///\n        /// This particular method allows for printf style formatted output\n        ///\n        /// @param format\n        ///     The format of the string to print e.g. \"My name is %s\"\n        /// @param args\n        ///     Variadic list of arguments to inject into the format in order\n        ///\n        template <typename... TArgs> void LogFatalFormatted(char const * const format, TArgs&&... args) noexcept;\n        \n    private:\n        friend class Application;\n        \n        //-----------------------------------------------------\n        /// An enum describing the various logging levels.\n        ///\n        /// @author Ian Copland\n        //-----------------------------------------------------\n        enum class LogLevel\n        {\n            k_verbose,\n            k_warning,\n            k_error\n        };\n        //-----------------------------------------------------\n        /// Creates the singleton instance of the Logger.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @return The message to log.\n        //-----------------------------------------------------\n        static void Create();\n        //-----------------------------------------------------\n        /// Destroys the Logger.\n        ///\n        /// @author Ian Copland\n        //-----------------------------------------------------\n        static void Destroy();\n        //-----------------------------------------------------\n        /// Constructor.\n        ///\n        /// @author Ian Copland\n        //-----------------------------------------------------\n        Logging();\n        //-----------------------------------------------------\n        /// Logs the given message to file. How this is logged\n        /// is dependant on platform.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The logging level.\n        /// @param The message to log.\n        //-----------------------------------------------------\n        void LogMessage(LogLevel in_logLevel, const std::string& in_message);\n        \n        ///\n        /// Method that can be overloaded to printf complex objects.\n        /// The base wrapper just returns the value and works for the\n        /// already supported printf values like ints and floats\n        ///\n        /// @param value\n        ///     Already supported printf value\n        ///\n        /// @return Given value\n        ///\n        template <typename T> T ToPrintfFormat(T value) noexcept\n        {\n            return value;\n        }\n        \n        ///\n        /// Converts a std::string to a printf string\n        ///\n        /// @param value\n        ///     String\n        ///\n        /// @return String as c-string\n        ///\n        template <typename T> T const* ToPrintfFormat(const std::basic_string<T>& value) noexcept\n        {\n            return value.c_str();\n        }\n        \n        ///\n        /// Converts printf style string to a std string ready for logging\n        ///\n        /// @param format\n        ///     The format of the string to print e.g. \"My name is %s\"\n        /// @param args\n        ///     Variadic list of arguments to inject into the format in order\n        ///\n        template <typename... TArgs> std::string CreateFormattedMessage(char const * const format, TArgs&&... args) noexcept;\n        \n#ifdef CS_ENABLE_LOGTOFILE\n        //-----------------------------------------------------\n        /// Creates a new Log file.\n        ///\n        /// @author Ian Copland\n        //-----------------------------------------------------\n        void CreateLogFile();\n        //-----------------------------------------------------\n        /// Adds the message to to the log file.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The message to log.\n        //-----------------------------------------------------\n        void LogToFile(const std::string& in_message);\n        \n        bool m_isFirstLog;\n        std::string m_logBuffer;\n        std::mutex m_mutex;\n#endif\n        static Logging* s_logging;\n    };\n    \n    //------------------------------------------------------------------------------\n    template <typename... TArgs> std::string Logging::CreateFormattedMessage(char const * const format, TArgs&&... args) noexcept\n    {\n        auto bufferSize = snprintf(NULL, 0, format, ToPrintfFormat(args)...) + 1;\n        char* buffer = new char[bufferSize];\n#ifdef CS_TARGETPLATFORM_WINDOWS\n        sprintf_s(buffer, bufferSize, format, ToPrintfFormat(args)...);\n#else\n        sprintf(buffer, format, ToPrintfFormat(args)...);\n#endif\n        \n        std::string result(buffer);\n        delete [] buffer;\n        return result;\n    }\n    \n    //------------------------------------------------------------------------------\n    template <typename... TArgs> void Logging::LogVerboseFormatted(char const * const format, TArgs&&... args) noexcept\n    {\n#if defined CS_LOGLEVEL_VERBOSE\n        LogVerbose(CreateFormattedMessage(format, std::forward<TArgs>(args)...));\n#endif\n    }\n    \n    //------------------------------------------------------------------------------\n    template <typename... TArgs> void Logging::LogWarningFormatted(char const * const format, TArgs&&... args) noexcept\n    {\n#if defined CS_LOGLEVEL_VERBOSE || defined CS_LOGLEVEL_WARNING\n        LogWarning(CreateFormattedMessage(format, std::forward<TArgs>(args)...));\n#endif\n    }\n    \n    //------------------------------------------------------------------------------\n    template <typename... TArgs> void Logging::LogErrorFormatted(char const * const format, TArgs&&... args) noexcept\n    {\n#if defined CS_LOGLEVEL_VERBOSE || defined CS_LOGLEVEL_WARNING || defined CS_LOGLEVEL_ERROR\n        LogError(CreateFormattedMessage(format, std::forward<TArgs>(args)...));\n#endif\n    }\n    \n    //------------------------------------------------------------------------------\n    template <typename... TArgs> void Logging::LogFatalFormatted(char const * const format, TArgs&&... args) noexcept\n    {\n#if defined CS_LOGLEVEL_VERBOSE || defined CS_LOGLEVEL_WARNING || defined CS_LOGLEVEL_ERROR || defined CS_LOGLEVEL_FATAL\n        LogFatal(CreateFormattedMessage(format, std::forward<TArgs>(args)...));\n#endif\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Base/MakeSharedArray.h",
    "content": "//\n//  MakeSharedArray.h\n//  ChilliSource\n//  Created by Ian Copland on 26/02/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_BASE_MAKESHAREDARRAY_H_\n#define _CHILLISOURCE_CORE_BASE_MAKESHAREDARRAY_H_\n\n#include <ChilliSource/ChilliSource.h>\n\nnamespace ChilliSource\n{\n    //-----------------------------------------------------\n    /// A function object for deleting an array. This is\n    /// used to safely delete shared pointers to arrays.\n    //-----------------------------------------------------\n    template <typename T> class ArrayDeleter\n    {\n    public:\n        //----------------------------------------------\n        /// Deletes the given array.\n        //----------------------------------------------\n        void operator () (T* in_arrayObject) const\n        {\n            delete[] in_arrayObject;\n        }\n    };\n    //-----------------------------------------------------\n    /// Creates a new shared pointer to an array of the\n    /// given object. Uses a custom deleter to ensure the\n    /// array is correctly deleted.\n    ///\n    /// @author Ian Copland\n    ///\n    /// @param The size of the array.\n    /// @return The new shared pointer.\n    //-----------------------------------------------------\n    template <typename TType> std::shared_ptr<TType> MakeSharedArray(s32 in_size)\n    {\n        return std::shared_ptr<TType>(new TType[in_size], ArrayDeleter<TType>());\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Base/PlatformSystem.cpp",
    "content": "//\n//  PlatformSystem.cpp\n//  ChilliSource\n//  Created by Ian Copland on 24/02/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Core/Base/PlatformSystem.h>\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n#include <CSBackend/Platform/Android/Main/JNI/Core/Base/PlatformSystem.h>\n#endif\n\n#ifdef CS_TARGETPLATFORM_IOS\n#import <CSBackend/Platform/iOS/Core/Base/PlatformSystem.h>\n#endif\n\n#ifdef CS_TARGETPLATFORM_WINDOWS\n#include <CSBackend/Platform/Windows/Core/Base/PlatformSystem.h>\n#endif\n\n#ifdef CS_TARGETPLATFORM_RPI\n#include <CSBackend/Platform/RPi/Core/Base/PlatformSystem.h>\n#endif\n\nnamespace ChilliSource\n{\n    CS_DEFINE_NAMEDTYPE(PlatformSystem);\n    //-----------------------------------------\n    //-----------------------------------------\n    PlatformSystemUPtr PlatformSystem::Create()\n    {\n#ifdef CS_TARGETPLATFORM_IOS\n        return PlatformSystemUPtr(new CSBackend::iOS::PlatformSystem());\n#elif defined CS_TARGETPLATFORM_ANDROID\n        return PlatformSystemUPtr(new CSBackend::Android::PlatformSystem());\n#elif defined CS_TARGETPLATFORM_WINDOWS\n        return PlatformSystemUPtr(new CSBackend::Windows::PlatformSystem());\n#elif defined CS_TARGETPLATFORM_RPI\n        return PlatformSystemUPtr(new CSBackend::RPi::PlatformSystem());\n#else\n        return nullptr;\n#endif\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Core/Base/PlatformSystem.h",
    "content": "//\n//  PlatformSystem.h\n//  ChilliSource\n//  Created by Scott Downie on 24/09/2010.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2010 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_BASE_PLATFORMSYSTEM_H_\n#define _CHILLISOURCE_CORE_BASE_PLATFORMSYSTEM_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/System/AppSystem.h>\n\nnamespace ChilliSource\n{\n    //-----------------------------------------------------------\n    /// Provides an interface for initialising the platform\n    /// specific application backend, creating platform specific\n    /// default systems and managing the platform specific\n    /// updater.\n    ///\n    /// @author S Downie\n    //-----------------------------------------------------------\n    class PlatformSystem : public AppSystem\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(PlatformSystem);\n        //---------------------------------------------------\n        /// NOTE: Setting this will disable VSync\n        ///\n        /// @author S Downie\n        ///\n        /// @param The maximum frames per second\n        /// to clamp to. This should be in multiples\n        /// of 15 (15, 30, 60)\n        //---------------------------------------------------\n        virtual void SetPreferredFPS(u32 in_fps) = 0;\n        //---------------------------------------------------\n        /// This will turn VSync on or off on platforms that\n        /// support it. NOTE: This will override the preferred FPS\n        ///\n        /// @author S Downie\n        ///\n        /// @param Enable/Disable\n        //---------------------------------------------------\n        virtual void SetVSyncEnabled(bool in_enabled) = 0;\n        //---------------------------------------------------\n        /// Terminate the app\n        ///\n        /// @author S Downie\n        //---------------------------------------------------\n        virtual void Quit() = 0;\n        //---------------------------------------------------\n        /// Adds default systems to the applications system\n        /// list.\n        ///\n        /// @author S Downie\n        ///\n        /// @param Application instance to add the default\n        /// platform systems to.\n        //---------------------------------------------------\n        virtual void CreateDefaultSystems(Application* in_application) = 0;\n        //---------------------------------------------------\n        /// Destructor\n        ///\n        /// @author S Downie\n        //---------------------------------------------------\n        virtual ~PlatformSystem(){}\n    protected:\n        friend class Application;\n        //---------------------------------------------------\n        /// Creates a new platform specfic instance of the\n        /// platform system.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @return The new instance.\n        //---------------------------------------------------\n        static PlatformSystemUPtr Create();\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Base/QueryableInterface.h",
    "content": "//\n//  QueryableInterface.h\n//  ChilliSource\n//  Created by Stuart McGaw on 27/09/2010.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2010 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_QUERYABLEINTERFACE_H_\n#define _CHILLISOURCE_CORE_QUERYABLEINTERFACE_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Base/ConstMethodCast.h>\n#include <ChilliSource/Core/Cryptographic/HashCRC32.h>\n#include <ChilliSource/Core/String/StringUtils.h>\n\n#define CS_DECLARE_NAMEDTYPE(x) \\\n    static const ChilliSource::InterfaceIDType InterfaceID; \\\n    static const ::std::string TypeName; \\\n    virtual ChilliSource::InterfaceIDType GetInterfaceID() const override; \\\n    virtual const ::std::string& GetInterfaceTypeName() const override;\n\n#define CS_DEFINE_NAMEDTYPE(x) \\\n    const ChilliSource::InterfaceIDType x::InterfaceID = ChilliSource::QueryableInterface::InterfaceIDHash(#x); \\\n    const ::std::string x::TypeName = #x; \\\n    ChilliSource::InterfaceIDType x::GetInterfaceID() const \\\n    { \\\n        return InterfaceID; \\\n    } \\\n    const ::std::string& x::GetInterfaceTypeName() const \\\n    { \\\n        return TypeName; \\\n    }\n\n#define CS_DEFINE_NAMEDTYPETEMPLATED(in_templatedClass, in_templateParams) \\\n\ttemplate <typename in_templateParams> const ChilliSource::InterfaceIDType in_templatedClass<in_templateParams>::InterfaceID = ChilliSource::QueryableInterface::InterfaceIDHash(#in_templatedClass#in_templateParams); \\\n\ttemplate <typename in_templateParams> const ::std::string in_templatedClass<in_templateParams>::TypeName = #in_templatedClass#in_templateParams; \\\n\ttemplate <typename in_templateParams> ChilliSource::InterfaceIDType in_templatedClass<in_templateParams>::GetInterfaceID() const \\\n    { \\\n    return InterfaceID; \\\n    } \\\n\ttemplate <typename in_templateParams> const ::std::string& in_templatedClass<in_templateParams>::GetInterfaceTypeName() const \\\n    { \\\n    return TypeName; \\\n    }\n\nnamespace ChilliSource\n{\n    typedef u32 InterfaceIDType;\n\n    //------------------------------------------------------------------------------\n    /// Classes that inherit from queryable interface can have their type obtained\n    /// at runtime.\n    ///\n    /// @author S McGaw\n    //------------------------------------------------------------------------------\n    class QueryableInterface\n    {\n    public:\n        //------------------------------------------------------------------------------\n        /// Allow hashing of TypeName strings at runtime without direct reference to\n        /// specific hashing function.\n        ///\n        /// @author S McGaw\n        ///\n        /// @param in_name - The interface name.\n        ///\n        /// @param The interface Id.\n        //------------------------------------------------------------------------------\n        static InterfaceIDType InterfaceIDHash(const std::string& in_name)\n        {\n            return HashCRC32::GenerateHashCode(in_name);\n        }\n        //------------------------------------------------------------------------------\n        /// Queries whether or not this object implements the interface given as a\n        /// template parameter. The interface must be a named type, in other words, it\n        /// must make use of the CS_DECLARE_NAMEDTYPE() and CS_DEFINE_NAMEDTYPE() macros.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @return Whether the object implements the given interface.\n        //------------------------------------------------------------------------------\n        template <typename TNamedType> bool IsA() const;\n        //------------------------------------------------------------------------------\n        /// Casts the object if it is declared to be a child of the type described by\n        /// the template parameter, otherwise returns null. This does not involve any\n        /// RTTI and is therefore much more efficient than a dynamic_cast.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @return This object cast to the type\n        //------------------------------------------------------------------------------\n        template <typename TNamedType> const TNamedType* Cast() const;\n        //------------------------------------------------------------------------------\n        /// Casts the object if it is declared to be a child of the type described by\n        /// the template parameter, otherwise returns null. This does not involve any\n        /// RTTI and is therefore much more efficient than a dynamic_cast.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @return This object cast to the type\n        //------------------------------------------------------------------------------\n        template <typename TNamedType> TNamedType* Cast();\n        //------------------------------------------------------------------------------\n        /// Query whether the object implements an interface that has the given Id.\n        ///\n        /// @author S McGaw\n        ///\n        /// @param in_interfaceId - The id of the interface.\n        ///\n        /// @return Whether or not the object implements the interface with the given Id.\n        //------------------------------------------------------------------------------\n        virtual bool IsA(InterfaceIDType in_interfaceId) const = 0;\n        //------------------------------------------------------------------------------\n        /// @author A Glass\n        ///\n        /// @return Interface ID of the class\n        //------------------------------------------------------------------------------\n        virtual InterfaceIDType GetInterfaceID() const = 0;\n        //------------------------------------------------------------------------------\n        /// @author A Glass\n        ///\n        /// @return String representation of interface ID of the class\n        //------------------------------------------------------------------------------\n        virtual const std::string& GetInterfaceTypeName() const = 0;\n        //------------------------------------------------------------------------------\n        /// Destructor\n        ///\n        /// @author S McGaw\n        //------------------------------------------------------------------------------\n        virtual ~QueryableInterface() {}\n    };\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    template <typename TNamedType> bool QueryableInterface::IsA() const\n    {\n        return IsA(TNamedType::InterfaceID);\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    template <typename TNamedType> const TNamedType* QueryableInterface::Cast() const\n    {\n        if (IsA<TNamedType>() == true)\n        {\n            return static_cast<const TNamedType*>(this);\n        }\n\n        return nullptr;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    template <typename TNamedType> TNamedType* QueryableInterface::Cast()\n    {\n        return ConstMethodCast(this, &QueryableInterface::Cast<TNamedType>);\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Base/RenderInfo.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Core/Base/RenderInfo.h>\n\nnamespace ChilliSource\n{\n    RenderInfo::RenderInfo(bool isShadowMapsSupported, bool isDepthTexturesSupported, bool isMapBuffersSupported, bool isVAOSupported, bool isHighPrecisionFloatsSupported, u32 maxTextureSize, u32 numTextureUnits, u32 maxVertexAttribs) noexcept\n        :\n    m_isShadowMapsSupported(isShadowMapsSupported),\n    m_isDepthTexturesSupported(isDepthTexturesSupported),\n    m_isMapBuffersSupported(isMapBuffersSupported),\n    m_isVAOSupported(isVAOSupported),\n    m_isHighPrecisionFloatsSupported(isHighPrecisionFloatsSupported),\n    m_maxTextureSize(maxTextureSize),\n    m_maxTextureUnits(numTextureUnits),\n    m_maxVertexAttributes(maxVertexAttribs)\n    {\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Core/Base/RenderInfo.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_BASE_RENDERINFO_H_\n#define _CHILLISOURCE_CORE_BASE_RENDERINFO_H_\n\n#include <ChilliSource/ChilliSource.h>\n\nnamespace ChilliSource\n{\n    /// This class contains information related to render\n    /// capabilities for the current device.\n    ///\n    /// This class is immutable, and therefore thread-safe.\n    ///\n    class RenderInfo final\n    {\n    public:\n        /// @param isShadowMapsSupported\n        ///         Whether or not shadow mapping is supported.\n        /// @param isDepthTexturesSupported\n        ///         Whether or not depth textures is supported.\n        /// @param isMapBuffersSupported\n        ///         Whether or not map buffer is supported.\n        /// @param isVAOSupported\n        ///     Whether vertex array objects are supported\n        /// @param isHighPrecisionFloatsSupported\n        ///         Whether or not the fragment shader supports highp floats.\n        /// @param maxTextureSize\n        ///         The maximum texture size available on this device.\n        /// @param numTextureUnits\n        ///         The number of texture units supported by this device.\n        /// @param maxVertexAttribs\n        ///         The max. number of vertex attributes supported by this device.\n        ///\n        RenderInfo(bool isShadowMapsSupported, bool isDepthTexturesSupported, bool isMapBuffersSupported, bool isVAOSupported, bool isHighPrecisionFloatsSupported, u32 maxTextureSize, u32 numTextureUnits, u32 maxVertexAttribs) noexcept;\n       \n        /// @return Whether or not shadow mapping is supported.\n        ///\n        bool IsShadowMappingSupported() const noexcept { return m_isShadowMapsSupported; }\n        \n        /// @return Whether or not depth textures is supported.\n        ///\n        bool IsDepthTextureSupported() const noexcept { return m_isDepthTexturesSupported; }\n        \n        /// @return Whether or not map buffer is supported.\n        ///\n        bool IsMapBufferSupported() const noexcept { return m_isMapBuffersSupported; }\n        \n        /// @return Whether or not vertex array objects are supported.\n        ///\n        bool IsVAOSupported() const noexcept { return m_isVAOSupported; }\n        \n        /// @return Whether or not the fragment shader supports highp floats.\n        ///\n        bool IsHighPrecisionFloatsSupported() const noexcept { return m_isHighPrecisionFloatsSupported; }\n        \n        /// @return The maximum texture size available on this device.\n        ///\n        u32 GetMaxTextureSize() const noexcept { return m_maxTextureSize; }\n        \n        /// @return The number of texture units supported by this device.\n        ///\n        u32 GetNumTextureUnits() const noexcept { return m_maxTextureUnits; }\n        \n        /// @return The max. number of vertex attributes supported by this device.\n        ///\n        u32 GetNumVertexAttributes() const noexcept { return m_maxVertexAttributes; }\n\n    private:\n        \n        bool m_isShadowMapsSupported;\n        bool m_isDepthTexturesSupported;\n        bool m_isMapBuffersSupported;\n        bool m_isVAOSupported;\n        bool m_isHighPrecisionFloatsSupported;\n        \n        u32 m_maxTextureSize;\n        u32 m_maxTextureUnits;\n        u32 m_maxVertexAttributes;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Base/Screen.cpp",
    "content": "//\n//  Screen.cpp\n//  ChilliSource\n//  Created by Scott Downie on 12/10/2010.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2010 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Core/Base/Screen.h>\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n#include <CSBackend/Platform/Android/Main/JNI/Core/Base/Screen.h>\n#endif\n\n#ifdef CS_TARGETPLATFORM_IOS\n#include <CSBackend/Platform/iOS/Core/Base/Screen.h>\n#endif\n\n#ifdef CS_TARGETPLATFORM_WINDOWS\n#include <CSBackend/Platform/Windows/Core/Base/Screen.h>\n#endif\n\n#ifdef CS_TARGETPLATFORM_RPI\n#include <CSBackend/Platform/RPi/Core/Base/Screen.h>\n#endif\n\nnamespace ChilliSource\n{\n    CS_DEFINE_NAMEDTYPE(Screen);\n    //-----------------------------------------------------------\n    //-----------------------------------------------------------\n    ScreenUPtr Screen::Create(const ScreenInfo& screenInfo)\n    {\n#if defined CS_TARGETPLATFORM_ANDROID\n        return ScreenUPtr(new CSBackend::Android::Screen(screenInfo));\n#elif defined CS_TARGETPLATFORM_IOS\n        return ScreenUPtr(new CSBackend::iOS::Screen(screenInfo));\n#elif defined CS_TARGETPLATFORM_WINDOWS\n        return ScreenUPtr(new CSBackend::Windows::Screen(screenInfo));\n#elif defined CS_TARGETPLATFORM_RPI\n        return ScreenUPtr(new CSBackend::RPi::Screen(screenInfo));\n#else\n        return nullptr;\n#endif\n    }\n    \n    /// Case insensitive. Will assert if no valid conversion\n    ///\n    /// @param displayMode\n    ///     Display mode as a string\n    ///\n    /// @return Display mode as a hard type\n    ///\n    Screen::DisplayMode Screen::ParseDisplayMode(const std::string& displayMode) noexcept\n    {\n        std::string lowerCase = displayMode;\n        StringUtils::ToLowerCase(lowerCase);\n        \n        if(lowerCase == \"windowed\")\n        {\n            return DisplayMode::k_windowed;\n        }\n        if(lowerCase == \"fullscreen\")\n        {\n            return DisplayMode::k_fullscreen;\n        }\n        \n        CS_LOG_FATAL(\"Cannot parse display mode: \" + displayMode);\n        return DisplayMode::k_windowed;\n    }\n}\n\n"
  },
  {
    "path": "Source/ChilliSource/Core/Base/Screen.h",
    "content": "//\n//  Screen.h\n//  ChilliSource\n//  Created by Scott Downie on 12/10/2010.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2010 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_BASE_SCREEN_H_\n#define _CHILLISOURCE_CORE_BASE_SCREEN_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Base/ScreenInfo.h>\n#include <ChilliSource/Core/Math/Vector2.h>\n#include <ChilliSource/Core/System/AppSystem.h>\n\n#include <functional>\n\nnamespace ChilliSource\n{\n    //----------------------------------------------------------------\n    /// An application system for retreiving information on the\n    /// screen such as the screen dimensions or the pixel density.\n    /// Screen is really just an alias for Window and refers to the\n    /// renderable area of the screen and not the actual monitor\n    ///\n    /// @author S Downie\n    //----------------------------------------------------------------\n    class Screen : public AppSystem\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(Screen);\n        \n        //-----------------------------------------------------------\n        /// The display modes of the screen\n        ///\n        /// @author S Downie\n        //-----------------------------------------------------------\n        enum class DisplayMode\n        {\n            k_windowed,\n            k_fullscreen\n        };\n        \n        /// Case insensitive. Will assert if no valid conversion\n        ///\n        /// @param displayMode\n        ///     Display mode as a string\n        ///\n        /// @return Display mode as a hard type\n        ///\n        static DisplayMode ParseDisplayMode(const std::string& displayMode) noexcept;\n        \n        //-----------------------------------------------------------\n        /// A delegate called when the application screen resolution\n        /// changes. This can happen when the window is resized in\n        /// a desktop app or when the orientation changes in a mobile\n        /// app.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The new screen resolution.\n        //-----------------------------------------------------------\n        using ResolutionChangedDelegate = std::function<void(const Vector2&)>;\n        //-----------------------------------------------------------\n        /// A delegate called when the application screen display mode\n        /// changes.\n        ///\n        /// @author S Downie\n        ///\n        /// @param The new screen display mode.\n        //-----------------------------------------------------------\n        using DisplayModeChangedDelegate = std::function<void(DisplayMode)>;\n        //-----------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Vector containing the width and height of screen\n        /// space available to the application. For a desktop app\n        /// this will be the current size of the window. For a mobile\n        /// application this will be full size of the screen.\n        //-----------------------------------------------------------\n        virtual const Vector2& GetResolution() const = 0;\n        //-----------------------------------------------------------\n        /// The density scale factor as reported by the device. What\n        /// this factor relates to is platform dependant. On iOS it\n        /// is relative to a non-retina screen resolution. On Android\n        /// it is a factor that changes depending on whether the\n        /// screen is considered, low, medium, high or extra high\n        /// density.\n        ///\n        /// @author S Downie\n        ///\n        /// @return The density scale factor of the screen\n        //-----------------------------------------------------------\n        virtual f32 GetDensityScale() const = 0;\n        //-----------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return The inverse of density scale factor of the screen\n        //-----------------------------------------------------------\n        virtual f32 GetInverseDensityScale() const = 0;\n        //-----------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return An event that is called when the screen resolution\n        /// changes.\n        //-----------------------------------------------------------\n        virtual IConnectableEvent<ResolutionChangedDelegate>& GetResolutionChangedEvent() = 0;\n        //-----------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return An event that is called when the screen display\n        /// mode changes.\n        //-----------------------------------------------------------\n        virtual IConnectableEvent<DisplayModeChangedDelegate>& GetDisplayModeChangedEvent() = 0;\n        //----------------------------------------------------------\n        /// Set the screen size on platforms where that is allowed\n        ///\n        /// NOTE: This can not exceed the monitor resolution and\n        /// will be clamped\n        ///\n        /// @author S Downie\n        ///\n        /// @param Screen size in pixels\n        //----------------------------------------------------------\n        virtual void SetResolution(const Integer2& in_size) = 0;\n        //----------------------------------------------------------\n        /// Set the screen to fullscreen more or windowed mode\n        /// on platforms where that is allowed. This will include the\n        /// removal or addition of any status or menu bars\n        ///\n        /// @author S Downie\n        //----------------------------------------------------------\n        virtual void SetDisplayMode(DisplayMode in_mode) = 0;\n        //----------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return A list of resolutions supported by the display\n        //----------------------------------------------------------\n        virtual std::vector<Integer2> GetSupportedFullscreenResolutions() const = 0;\n        //-----------------------------------------------------------\n        /// Destructor\n        ///\n        /// @author Ian Copland\n        //-----------------------------------------------------------\n        virtual ~Screen() {};\n    protected:\n        friend class Application;\n        //-----------------------------------------------------------\n        /// Factory creation method called by Application's Create\n        /// System method.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The new instance of the system.\n        //-----------------------------------------------------------\n        static ScreenUPtr Create(const ScreenInfo& screenInfo);\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Base/ScreenInfo.cpp",
    "content": "//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Core/Base/ScreenInfo.h>\n\nnamespace ChilliSource\n{\n    //----------------------------------------------------------------\n    ScreenInfo::ScreenInfo(const Vector2& initialResolution, f32 densityScale, f32 inverseDensityScale, const std::vector<Integer2>& supportedResolutions) noexcept\n        : m_initialResolution(initialResolution), m_densityScale(densityScale), m_inverseDensityScale(inverseDensityScale), m_supportedResolutions(supportedResolutions)\n    {\n    }\n\n    //----------------------------------------------------------------\n    const Vector2& ScreenInfo::GetInitialResolution() const noexcept\n    {\n        return m_initialResolution;\n    }\n\n    //----------------------------------------------------------------\n    f32 ScreenInfo::GetDensityScale() const noexcept\n    {\n        return m_densityScale;\n    }\n\n    //----------------------------------------------------------------\n    f32 ScreenInfo::GetInverseDensityScale() const noexcept\n    {\n        return m_inverseDensityScale;\n    }\n\n    //----------------------------------------------------------------\n    const std::vector<Integer2>& ScreenInfo::GetSupportedFullscreenResolutions() const noexcept\n    {\n        return m_supportedResolutions;\n    }\n\n\n}"
  },
  {
    "path": "Source/ChilliSource/Core/Base/ScreenInfo.h",
    "content": "//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_BASE_SCREENINFO_H_\n#define _CHILLISOURCE_CORE_BASE_SCREENINFO_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Math/Vector2.h>\n#include <vector>\n\nnamespace ChilliSource\n{\n    /// This class contains all information necessary for building\n    /// the Screen class.\n    ///\n    /// This class is immutable, and therefore thread-safe.\n    ///\n    class ScreenInfo final\n    {\n    public:\n        /// Constructs the ScreenInfo class.\n        ///\n        /// @param initialResolution\n        ///         The initial resolution for the application.\n        /// @param densityScale\n        ///         The density scale.\n        /// @param inverseDensityScale\n        ///         The inverse density scale.\n        /// @param supportedResolutions\n        ///         A list of resolutions supported by the display.\n        ///\n        ScreenInfo(const Vector2& initialResolution, f32 densityScale, f32 inverseDensityScale, const std::vector<Integer2>& supportedResolutions) noexcept;\n\n        /// @return The initial resolution for the application.\n        ///\n        const Vector2& GetInitialResolution() const noexcept;\n\n        /// @return The density scale.\n        ///\n        f32 GetDensityScale() const noexcept;\n\n        /// @return The inverse density scale.\n        ///\n        f32 GetInverseDensityScale() const noexcept;\n\n        /// @return A list of resolutions supported by the display.\n        ///\n        const std::vector<Integer2>& GetSupportedFullscreenResolutions() const noexcept;\n\n    private:\n        Vector2 m_initialResolution;\n        f32 m_densityScale;\n        f32 m_inverseDensityScale;\n        std::vector<Integer2> m_supportedResolutions;\n\n    };\n}\n\n#endif"
  },
  {
    "path": "Source/ChilliSource/Core/Base/Singleton.h",
    "content": "//\n//  Singleton.h\n//  ChilliSource\n//  Created by Scott Downie on 11/03/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_BASE_SINGLETON_H_\n#define _CHILLISOURCE_CORE_BASE_SINGLETON_H_\n\n#include <ChilliSource/ChilliSource.h>\n\nnamespace ChilliSource\n{\n    //---------------------------------------------------------------\n    /// Inherit from this class when you wish to implement\n    /// a singleton interface. The singleton is not lazily created\n    /// but instead must be explicitly created (and destroyed)\n    ///\n    /// @author S Downie\n    //---------------------------------------------------------------\n    template <typename TType> class Singleton\n    {\n    public:\n        //---------------------------------------------------------------\n        /// Destructor\n        ///\n        /// @author S Downie\n        //---------------------------------------------------------------\n        virtual ~Singleton(){}\n        //---------------------------------------------------------------\n        /// Create the singleton instance. Once this has been created\n        /// it is accessible through Get() and creating again (w/o destroying)\n        /// will cause an assertion.\n        ///\n        /// @author S Downie\n        ///\n        /// @param Variable number of argument types required to construct\n        /// the singleton instance\n        //---------------------------------------------------------------\n        template <typename... TArgTypes> static void Create(TArgTypes... in_args)\n        {\n            CS_ASSERT(m_singleton == nullptr, \"Singleton can only be created once\");\n            m_singleton = new TType(in_args...);\n        }\n        //---------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Pre-created singleton instance or null if not yet\n        /// created\n        //---------------------------------------------------------------\n        inline static TType* Get()\n        {\n            return m_singleton;\n        }\n        //---------------------------------------------------------------\n        /// Destruct the singleton instance. It can then be created again\n        ///\n        /// @author S Downie\n        //---------------------------------------------------------------\n        inline static void Destroy()\n        {\n            CS_SAFEDELETE(m_singleton);\n        }\n        \n    protected:\n        \n        //---------------------------------------------------------------\n        /// Private constructor to enforce use of creation method\n        ///\n        /// @author S Downie\n        //---------------------------------------------------------------\n        Singleton(){}\n        \n    private:\n        \n        static TType* m_singleton;\n    };\n\n    template <typename TType> TType* Singleton<TType>::m_singleton = nullptr;\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Base/StandardMacros.h",
    "content": "//\n//  StandardMacros.h\n//  ChilliSource\n//  Created by Ian Copland on 25/02/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_BASE_STANDARDMACROS_H_\n#define _CHILLISOURCE_CORE_BASE_STANDARDMACROS_H_\n\n//------------------------------------------------------------\n/// Memory macros\n//------------------------------------------------------------\n#define CS_SAFEDELETE(in_object)        {if(in_object) delete(in_object); in_object = nullptr;}\n#define CS_SAFEDELETE_ARRAY(in_object)  {if(in_object) delete[] (in_object); in_object = nullptr;}\n//------------------------------------------------------------\n/// Logging macros\n//------------------------------------------------------------\n#define CS_LOG_VERBOSE(message)      (ChilliSource::Logging::Get()->LogVerbose(message))\n#define CS_LOG_WARNING(message)      (ChilliSource::Logging::Get()->LogWarning(message))\n#define CS_LOG_ERROR(message)        (ChilliSource::Logging::Get()->LogError(message))\n#define CS_LOG_FATAL(message)        (ChilliSource::Logging::Get()->LogFatal(message))\n\n#define CS_LOG_VERBOSE_FMT(message, ...)  (ChilliSource::Logging::Get()->LogVerboseFormatted(message, __VA_ARGS__))\n#define CS_LOG_WARNING_FMT(message, ...)  (ChilliSource::Logging::Get()->LogWarningFormatted(message, __VA_ARGS__))\n#define CS_LOG_ERROR_FMT(message, ...)  (ChilliSource::Logging::Get()->LogErrorFormatted(message, __VA_ARGS__))\n#define CS_LOG_FATAL_FMT(message, ...)  (ChilliSource::Logging::Get()->LogFatalFormatted(message, __VA_ARGS__))\n//------------------------------------------------------------\n/// Assertion macros\n//------------------------------------------------------------\n#ifdef CS_ENABLE_DEBUG\n#define CS_ASSERT(in_query, in_message) if((in_query) == 0){ChilliSource::Logging::Get()->LogFatal(in_message);}\n#else\n#define CS_ASSERT(in_query, in_message)\n#endif\n#define CS_RELEASE_ASSERT(in_query, in_message) if((in_query) == 0){ChilliSource::Logging::Get()->LogFatal(in_message);}\n//------------------------------------------------------------\n/// Casting macros\n//------------------------------------------------------------\n#ifdef CS_ENABLE_DEBUG\n#define CS_SMARTCAST(in_to, in_from, in_failureMessage) dynamic_cast<in_to>(in_from); CS_ASSERT(dynamic_cast<in_to>(in_from) != nullptr, in_failureMessage);\n#else\n#define CS_SMARTCAST(in_to, in_from, in_failureMessage) static_cast<in_to>(in_from);\n#endif\n//------------------------------------------------------------\n/// Forward declaration macros.\n//------------------------------------------------------------\n#define CS_FORWARDDECLARE_CLASS(in_className)\t\t\t\t\t\t\t\\\n\tclass in_className;\t\t\t\t\t\t\t\t\t\t\t\t\t\\\n    using in_className##UPtr = std::unique_ptr<in_className>;           \\\n    using in_className##SPtr = std::shared_ptr<in_className>;           \\\n    using in_className##WPtr = std::weak_ptr<in_className>;             \\\n    using in_className##CUPtr = std::unique_ptr<const in_className>;    \\\n    using in_className##CSPtr = std::shared_ptr<const in_className>;    \\\n    using in_className##CWPtr = std::weak_ptr<const in_className>;\n\n#define CS_FORWARDDECLARE_STRUCT(in_structName)\t\t\t\t\t\t\t\\\n    struct in_structName;                                               \\\n    using in_structName##UPtr = std::unique_ptr<in_structName>;         \\\n    using in_structName##SPtr = std::shared_ptr<in_structName>;         \\\n    using in_structName##WPtr = std::weak_ptr<in_structName>;           \\\n    using in_structName##CUPtr = std::unique_ptr<const in_structName>;  \\\n    using in_structName##CSPtr = std::shared_ptr<const in_structName>;  \\\n    using in_structName##CWPtr = std::weak_ptr<const in_structName>;\n\n#define CS_FORWARDDECLARE_TEMPLATECLASS(className, T)                                   \\\n    template <typename T> class className;\t\t\t\t\t\t\t\t\t\t\t\t\\\n    template <typename T> using className##UPtr = std::unique_ptr<className<T>>;        \\\n    template <typename T> using className##SPtr = std::shared_ptr<className<T>>;        \\\n    template <typename T> using className##WPtr = std::weak_ptr<className<T>>;          \\\n    template <typename T> using className##CUPtr = std::unique_ptr<const className<T>>; \\\n    template <typename T> using className##CSPtr = std::shared_ptr<const className<T>>; \\\n    template <typename T> using className##CWPtr = std::weak_ptr<const className<T>>;\n\n//------------------------------------------------------------\n/// A macro for declaring a class non copyable. This is acheived\n/// by deleting the default copy and assignment constructor.\n/// If this is used the default constructor must manually be\n/// specified.\n//------------------------------------------------------------\n#define CS_DECLARE_NOCOPY(in_className)                            \\\n    in_className(const in_className& in_toCopy) = delete;               \\\n    in_className& operator=(const in_className& in_toCopy) = delete;\n//------------------------------------------------------------\n/// Standard input and output macros. As windows has its own\n/// \"safe\" versions of some standard io functions, these macros \n/// should be used to ensure the correct version is used for the \n/// current platform.\n//------------------------------------------------------------\n#ifdef CS_TARGETPLATFORM_WINDOWS\n#\tdefine CS_SSCANF sscanf_s\n#\tdefine CS_SPRINTF sprintf_s\n#else\n#\tdefine CS_SSCANF sscanf\n#\tdefine CS_SPRINTF sprintf\n#endif\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Base/SystemInfo.cpp",
    "content": "//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Core/Base/SystemInfo.h>\n\nnamespace ChilliSource\n{\n    //----------------------------------------------------------------\n    SystemInfo::SystemInfo(const DeviceInfo& deviceInfo, const ScreenInfo& screenInfo, const RenderInfo& renderInfo, const std::string& appVersion) noexcept\n        : m_deviceInfo(deviceInfo), m_screenInfo(screenInfo), m_renderInfo(renderInfo), m_appVersion(appVersion)\n    {   \n    }\n\n    //----------------------------------------------------------------\n    const DeviceInfo& SystemInfo::GetDeviceInfo() const noexcept\n    {\n        return m_deviceInfo;\n    }\n    \n    //----------------------------------------------------------------\n    const RenderInfo& SystemInfo::GetRenderInfo() const noexcept\n    {\n        return m_renderInfo;\n    }\n    \n    //----------------------------------------------------------------\n    const ScreenInfo& SystemInfo::GetScreenInfo() const noexcept\n    {\n        return m_screenInfo;\n    }\n    \n    //----------------------------------------------------------------\n    const std::string& SystemInfo::GetAppVersion() const noexcept\n    {\n        return m_appVersion;\n    }\n}"
  },
  {
    "path": "Source/ChilliSource/Core/Base/SystemInfo.h",
    "content": "//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_BASE_SYSTEMINFO_H_\n#define _CHILLISOURCE_CORE_BASE_SYSTEMINFO_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Base/DeviceInfo.h>\n#include <ChilliSource/Core/Base/ScreenInfo.h>\n#include <ChilliSource/Core/Base/RenderInfo.h>\n\nnamespace ChilliSource\n{\n    /// This class contains all information necessary for building\n    /// the Device, PlatformSystem, and Screen classes.\n    ///\n    class SystemInfo final\n    {\n    public:\n        /// Constructs the SystemInfo class.\n        ///\n        /// @param deviceInfo\n        ///     The device info to populate device with.\n        /// @param screenInfo\n        ///     The screen info to populate screen with.\n        /// @param renderInfo\n        ///     The render info to populate render capabilities with.\n        /// @param appVersion\n        ///     The application version.\n        ///\n        SystemInfo(const DeviceInfo& deviceInfo, const ScreenInfo& screenInfo, const RenderInfo& renderInfo, const std::string& appVersion) noexcept;\n\n        /// @return The device info for building the Device class.\n        ///\n        const DeviceInfo& GetDeviceInfo() const noexcept;\n\n        /// @return The render info for building the render capabilities class.\n        ///\n        const RenderInfo& GetRenderInfo() const noexcept;\n        \n        /// @return The screen info for building the Screen class.\n        ///\n        const ScreenInfo& GetScreenInfo() const noexcept;\n        \n        /// @return The app version.\n        ///\n        const std::string& GetAppVersion() const noexcept;\n\n    private:\n        DeviceInfo m_deviceInfo;\n        RenderInfo m_renderInfo;\n        ScreenInfo m_screenInfo;\n        \n        std::string m_appVersion;\n    };\n}\n\n#endif"
  },
  {
    "path": "Source/ChilliSource/Core/Base/Utils.cpp",
    "content": "//\n//  Utils.cpp\n//  ChilliSource\n//  Created by Andrew Glass on 09/08/2012.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2012 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Core/Base/Utils.h>\n#include <ChilliSource/Core/Base/Application.h>\n\n#include <json/json.h>\n#include <zlib.h>\n\nnamespace ChilliSource\n{\n    namespace Utils\n    {\n        bool FileToString(StorageLocation ineStorageLocation, const std::string& instrPath, std::string& outstrFileContent)\n        {\n            auto pFile = Application::Get()->GetFileSystem()->CreateTextInputStream(ineStorageLocation, instrPath);\n            \n            if(pFile == nullptr)\n            {\n                CS_LOG_WARNING(\"Utils::FileToString: Could not open file: \" + instrPath);\n                return false;\n            }\n            \n            outstrFileContent = pFile->ReadAll();\n            \n            return true;\n        }\n        \n        TextOutputStreamUPtr StringToFile(StorageLocation ineStorageLocation, const std::string& instrPath, const std::string& instrFileOut)\n        {\n            auto pFile = Application::Get()->GetFileSystem()->CreateTextOutputStream(ineStorageLocation, instrPath, FileWriteMode::k_overwrite);\n            \n            if(pFile == nullptr)\n            {\n                CS_LOG_WARNING(\"Utils::StringToFile: Could not open file: \" + instrPath);\n                return nullptr;\n            }\n            \n            pFile->Write(instrFileOut);\n            \n            return pFile;\n        }\n        \n        bool ZlibCompressString(const std::string &instrUncompressed, std::string &outstrCompressed)\n        {\n            uLongf maxCompSize = (uLongf)(instrUncompressed.size() * 1.1f + 12);\n            \n            outstrCompressed.clear();\n            outstrCompressed.resize(maxCompSize);\n            \n            s32 zlibResult = compress2(\n                                      (Bytef*)(outstrCompressed.data()),\n                                      &maxCompSize,\n                                      (Bytef*)instrUncompressed.data(),\n                                      uLong(instrUncompressed.size()),\n                                       Z_BEST_COMPRESSION);\n            \n            \n            if(zlibResult == Z_OK)\n            {\n                outstrCompressed.resize(maxCompSize);\n                return true;\n            }\n            \n            outstrCompressed.clear();\n            return false;\n        }\n\n        bool ZlibDecompressString(const std::string &instrCompressed, std::string& outstrUncompress,  u32 inOutputSizeGuess)\n        {\n            outstrUncompress.clear();\n            outstrUncompress.resize(inOutputSizeGuess);\n            \n            uLongf outBufferSize = inOutputSizeGuess;\n            s32 zlibResult = uncompress(\n                                        (Bytef*)(outstrUncompress.data()) ,\n                                        &outBufferSize,\n                                        (const Bytef*)instrCompressed.data(),\n                                        uLong(instrCompressed.size()));\n            \n            if(zlibResult == Z_OK)\n            {\n                outstrUncompress.resize(outBufferSize);\n                return true;\n            }\n            \n            outstrUncompress.clear();\n            return false;\n        }\n        //---------------------------------------------------------\n        //---------------------------------------------------------\n        u8 HexToDec(const u8* inpHex)\n        {\n            if(*inpHex >= '0' && *inpHex <= '9')\n            {\n                return *inpHex - '0';\n            }\n            else\n                if(*inpHex >= 'A' && *inpHex <= 'F')\n                {\n                    return 10 + (*inpHex - 'A');\n                }\n                else\n                {\n                    CS_LOG_ERROR(\"Invalid hex value of \\\"\"+ToString(*inpHex)+\"\\\"\");\n                }\n            \n            return -1;\n        }\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Core/Base/Utils.h",
    "content": "//\n//  Utils.h\n//  ChilliSource\n//  Created by Scott Downie on 25/10/2010.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2010 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_BASE_UTILS_H_\n#define _CHILLISOURCE_CORE_BASE_UTILS_H_\n\n#include <ChilliSource/ChilliSource.h>\n\n#include <json/forwards.h>\n\n#include <algorithm>\n#include <vector>\n\nnamespace ChilliSource\n{\n    namespace Utils\n    {\n        //------------------------------------------------------\n        /// performs a bitmask set on a with b.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The bitmask to set.\n        /// @param The bitmask to apply.\n        //------------------------------------------------------\n        template <typename TType> inline void BitmapSet(TType& in_a, TType in_b)\n        {\n            in_a |= in_b;\n        }\n        //------------------------------------------------------\n        /// performs a bitmask clear on a with b.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The bitmask to set.\n        /// @param The bitmask to apply.\n        //------------------------------------------------------\n        template <typename TType> inline void BitmapClear(TType& in_a, TType in_b)\n        {\n            in_a &= (~in_b);\n        }\n        //------------------------------------------------------\n        /// performs a bitmask flip on a with b.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The bitmask to set.\n        /// @param The bitmask to apply.\n        //------------------------------------------------------\n        template <typename TType> inline void BitmapFlip(TType& in_a, TType in_b)\n        {\n            in_a ^= in_b;\n        }\n        //------------------------------------------------------\n        /// performs a bitmask check on a with b.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The bitmask to set.\n        /// @param The bitmask to apply.\n        //------------------------------------------------------\n        template <typename TType> inline bool BitmapCheck(TType in_a, TType in_b)\n        {\n            return (in_a & in_b) != 0;\n        }\n        //------------------------------------------------------\n        /// Endian Byte Swap\n        ///\n        /// Converts the endianness of the given bytes\n        //------------------------------------------------------\n        inline s16 Endian2ByteSwap(const u16* pSrc)\n        {\n            u16 Result = *pSrc;\n            // Use bit manipulations instead of accessing individual bytes from memory, much faster.\n            return (Result >> 8) | (Result << 8);\n        }\n        \n        inline s16 Endian2ByteSwap(const s16* pSrc)\n        {\n            u16 Result = *pSrc;\n            // Use bit manipulations instead of accessing individual bytes from memory, much faster.\n            return (Result >> 8) | (Result << 8);\n        }\n        \n        // Specialization for 4-byte types.\n        inline s32 Endian4ByteSwap(const u32* pSrc)\n        {\n            u32 Result = *pSrc;\n            // Use bit manipulations instead of accessing individual bytes from memory, much faster.\n            return (Result >> 24) | ((Result & 0x00ff0000) >> 8) | ((Result & 0x0000ff00) << 8) | (Result << 24);\n        }\n        \n        inline s32 Endian4ByteSwap(const s32* pSrc)\n        {\n            u32 Result = *pSrc;\n            // Use bit manipulations instead of accessing individual bytes from memory, much faster.\n            return (Result >> 24) | ((Result & 0x00ff0000) >> 8) | ((Result & 0x0000ff00) << 8) | (Result << 24);\n        }\n        \n        template<typename T>\n        inline T BitwiseRotateRight(T inValue)\n        {\n            return (inValue >> 1) | (inValue << (sizeof(T)*8 -1));\n        }\n        \n        template<typename T>\n        inline T BitwiseRotateLeft(T inValue)\n        {\n            return (inValue << 1) | (inValue >> (sizeof(T)*8 -1));\n        }\n        \n        bool          FileToString(StorageLocation ineStorageLocation, const std::string & instrPath, std::string & outstrFileContent);\n        TextOutputStreamUPtr StringToFile(StorageLocation ineStorageLocation, const std::string & instrPath, const std::string& instrFileOut);\n        \n        bool ZlibCompressString(const std::string &instrUncompressed, std::string& outstrCompressed);\n\n        bool ZlibDecompressString(const std::string &instrCompressed, std::string& outstrUncompress, u32 inOutputSizeGuess);\n        \n        // Optimised removal of many elements from a vector while preserving the order of the vector\n        template<typename ELEMENT>\n        u32 VectorRemoveMany(std::vector<ELEMENT> & inaElements, std::vector<ELEMENT>& inaRemovables)\n        {\n            if(inaRemovables.empty())\n                return 0;\n            \n            std::sort(inaRemovables.begin(), inaRemovables.end());\n                \n            u32 uCurrent = 0;\n            u32 uRemoved = 0;\n            const u32 uSize = inaElements.size();\n            \n            // First run through array till we reach first item to remove\n            while(uCurrent + uRemoved < uSize && uRemoved == 0)\n            {\n                if(std::binary_search(inaRemovables.begin(), inaRemovables.end(), inaElements[uCurrent+uRemoved]))\n                    uRemoved++;\n                \n                if(uRemoved == 0)\n                    uCurrent += 1;\n            }\n            \n            // Next copy ahead of current position in array by amount of items removed\n            // skipping the items to be removed\n            while(uCurrent + uRemoved < uSize)\n            {\n                if(std::binary_search(inaRemovables.begin(), inaRemovables.end(), inaElements[uCurrent+uRemoved]))\n                {\n                    uRemoved++;\n                    continue;\n                }\n                \n                if(uRemoved != 0)\n                    inaElements[uCurrent] = inaElements[uCurrent + uRemoved];\n                \n                uCurrent++;\n            }\n            inaElements.resize(uCurrent);\n            return uRemoved;\n        }\n        //------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param A single hexidecimal value to convert\n        ///\n        /// @return Base ten representation of hex value or -1\n        //------------------------------------------------------\n        u8 HexToDec(const u8* in_hex);\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Base.h",
    "content": "//\n//  Base.h\n//  ChilliSource\n//  Created by Ian Copland on 07/07/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n\n#ifndef _CHILLISOURCE_CORE_BASE_H_\n#define _CHILLISOURCE_CORE_BASE_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Base/AppConfig.h>\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/Base/ByteBuffer.h>\n#include <ChilliSource/Core/Base/ByteColour.h>\n#include <ChilliSource/Core/Base/Colour.h>\n#include <ChilliSource/Core/Base/ColourUtils.h>\n#include <ChilliSource/Core/Base/CursorType.h>\n#include <ChilliSource/Core/Base/Device.h>\n#include <ChilliSource/Core/Base/LifecycleManager.h>\n#include <ChilliSource/Core/Base/Logging.h>\n#include <ChilliSource/Core/Base/MakeSharedArray.h>\n#include <ChilliSource/Core/Base/PlatformSystem.h>\n#include <ChilliSource/Core/Base/QueryableInterface.h>\n#include <ChilliSource/Core/Base/Screen.h>\n#include <ChilliSource/Core/Base/Singleton.h>\n#include <ChilliSource/Core/Base/StandardMacros.h>\n#include <ChilliSource/Core/Base/Utils.h>\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Container/HashedArray.h",
    "content": "//\n//  HashedArray.h\n//  ChilliSource\n//  Created by Scott Downie on 16/02/2012.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2012 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_CONTAINER_HASHEDARRAY_H_\n#define _CHILLISOURCE_CORE_CONTAINER_HASHEDARRAY_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Cryptographic/HashCRC32.h>\n\n#include <algorithm>\n#include <functional>\n\nnamespace ChilliSource\n{\n    //-------------------------------------------------\n    /// Key value array that uses a binary search to\n    /// perform lookups on the key. The key is\n    /// hashed. Array is statically\n    /// sized. Order is not guaranteed. The syntax\n    /// mimics std syntax\n    ///\n    /// @author S Downie\n    //-------------------------------------------------\n    template <typename TKey, typename TValue> class HashedArray\n    {\n    public:\n\n        typedef std::function<u32(TKey)> HashDelegate;\n        typedef std::pair<u32, TValue> KeyValue;\n        typedef KeyValue* iterator;\n        typedef const KeyValue* const_iterator;\n        \n        //-------------------------------------------\n        /// Constructor\n        ///\n        /// @author S Downie\n        ///\n        /// @param Capacity of the array. If this\n        /// is zero then the array cannot be added\n        /// to until set capacity is called\n        /// @param Hash function\n        //-------------------------------------------\n        HashedArray(u32 in_capacity, const HashDelegate& in_hashFunction)\n        : m_capacity(0), m_size(0), m_hashFunction(in_hashFunction), m_isSortCacheValid(true), m_storage(nullptr)\n        {\n            CS_ASSERT(m_hashFunction, \"HashedArray: Key type cannot be hashed without providing a custom hash method\");\n            \n            if(in_capacity > 0)\n            {\n                set_capacity(in_capacity);\n            }\n        }\n        //-------------------------------------------\n        /// Copy constructor\n        ///\n        /// @author S Downie\n        ///\n        /// @param Object to copy\n        //-------------------------------------------\n        HashedArray(const HashedArray& in_toCopy)\n        {\n            Clone();\n        }\n        //-------------------------------------------\n        /// Copy assignment\n        ///\n        /// @author S Downie\n        ///\n        /// @param Object to copy\n        //-------------------------------------------\n        HashedArray& operator=(const HashedArray& in_toCopy)\n        {\n            Clone();\n        }\n        //-------------------------------------------\n        /// @author S Downie\n        ///\n        /// Set the initial capacity of the array\n        /// if it has already been set then this\n        /// will assert\n        ///\n        /// @param Capacity\n        //-------------------------------------------\n        void set_capacity(u32 in_capacity)\n        {\n            CS_ASSERT(in_capacity > 0, \"HashedArray: Cannot create an array with capacity zero\");\n            CS_ASSERT(m_capacity == 0, \"HashedArray: Cannot allocate array twice\");\n            m_storage = new KeyValue[in_capacity];\n            m_capacity = in_capacity;\n        }\n        //-------------------------------------------\n        /// Insert the object into the array. Order\n        /// is not guaranteed\n        ///\n        /// @author S Downie\n        ///\n        /// @param Key\n        /// @param Value\n        //-------------------------------------------\n        void insert(const TKey& in_key, const TValue& in_value)\n        {\n            CS_ASSERT(m_capacity > 0, \"HashedArray: Must allocate capacity\");\n            CS_ASSERT(m_size < m_capacity, \"HashedArray: Exceeds capacity\");\n            \n            u32 hash = m_hashFunction(in_key);\n            m_storage[m_size].first = hash;\n            m_storage[m_size].second = in_value;\n            m_isSortCacheValid = false;\n            m_size++;\n        }\n        //-------------------------------------------\n        /// Remove the object identified by the\n        /// given key. This doesn't free any memory\n        ///\n        /// @author S Downie\n        ///\n        /// @param Key of key and value to remove\n        //-------------------------------------------\n        void remove(const TKey& in_key)\n        {\n            u32 hash = m_hashFunction(in_key);\n            s32 index = FindIndex(hash);\n            \n            CS_ASSERT(index >= 0, \"HashedArray: Cannot find key to remove\");\n            \n            std::swap(m_storage[index], m_storage[m_size-1]);\n            m_storage[m_size-1].~KeyValue();\n            \n            m_size--;\n            m_isSortCacheValid = false;\n        }\n        //-------------------------------------------\n        /// Clear all objects but hold onto the memory\n        ///\n        /// @author S Downie\n        //-------------------------------------------\n        void clear()\n        {\n            for(u32 i=0; i<m_size; ++i)\n            {\t\n                m_storage[i].~KeyValue();\n            }\n            \n            m_size = 0;\n            m_isSortCacheValid = false;\n        }\n        //-------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Key\n        ///\n        /// @return Value at key or end if not found\n        //-------------------------------------------\n        iterator find(const TKey& in_key)\n        {\n            u32 hash = m_hashFunction(in_key);\n            s32 index = FindIndex(hash);\n            \n            if(index >= 0)\n            {\n                return &m_storage[index];\n            }\n         \n            return end();\n        }\n        //-------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Key\n        ///\n        /// @return Value at key or end if not found\n        //-------------------------------------------\n        const_iterator find(const TKey& in_key) const\n        {\n            u32 hash = m_hashFunction(in_key);\n            s32 index = FindIndex(hash);\n            \n            if(index >= 0)\n            {\n                return &m_storage[index];\n            }\n            \n            return end();\n        }\n        //-------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Number of elements that have been\n        /// added\n        //-------------------------------------------\n        inline u32 length() const\n        {\n            return m_size;\n        }\n        //-------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Whether the array is empty\n        //-------------------------------------------\n        inline bool empty() const\n        {\n            return length() == 0;\n        }\n        //-------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Capcaity of the array\n        //-------------------------------------------\n        inline u32 capacity() const\n        {\n            return m_capacity;\n        }\n        //-------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Iterator pointing to the first\n        /// object in the structure\n        //-------------------------------------------\n        inline iterator begin() \n        {\n            return m_storage;\n        }\n        //-------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Iterator pointing beyond the last\n        /// object in the structure\n        //-------------------------------------------\n        inline iterator end() \n        {\n            return (m_storage + m_size);\n        }\n        //-------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Iterator pointing to the first\n        /// object in the structure\n        //-------------------------------------------\n        inline const_iterator begin() const\n        {\n            return m_storage;\n        }\n        //-------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Iterator pointing beyond the last\n        /// object in the structure\n        //-------------------------------------------\n        inline const_iterator end() const\n        {\n            return (m_storage + m_size);\n        }\n        //-------------------------------------------\n        /// Destructor\n        ///\n        /// @author S Downie\n        //-------------------------------------------\n        ~HashedArray()\n        {\n            clear();\n            CS_SAFEDELETE_ARRAY(m_storage);\n        }\n        \n    private:\n        \n        //-------------------------------------------\n        /// Sort predicate\n        ///\n        /// @author S Downie\n        ///\n        /// @param LHS\n        /// @param RHS\n        ///\n        /// @return Whether LHS is less than RHS\n        //-------------------------------------------\n        static bool LessThanSortPredicate(const KeyValue& in_lhs, const KeyValue& in_rhs)\n        {\n            return in_lhs.first < in_rhs.first;\n        }\n        //-------------------------------------------\n        /// Makes a deep copy of the array\n        ///\n        /// @author S Downie\n        ///\n        /// @param Array to copy\n        //-------------------------------------------\n        void Clone(const HashedArray& inRHS)\n        {\n            m_capacity = inRHS.m_capacity;\n            m_size = inRHS.m_size;\n            m_hashFunction = inRHS.m_hashFunction;\n            m_isSortCacheValid = inRHS.m_isSortCacheValid;\n            std::copy(inRHS.begin(), inRHS.end(), this->begin());\n        }\n        //--------------------------------------------\n        /// Performs a binary search looking for the\n        /// index of the object with the given key\n        ///\n        /// @author S Downie\n        ///\n        /// @param Key\n        ///\n        /// @return Index of object identified by key\n        /// or -1 if not found\n        //--------------------------------------------\n        s32 FindIndex(u32 in_keyHash) const\n        {\n            if(m_size == 0)\n            {\n                return -1;\n            }\n            \n            if(!m_isSortCacheValid)\n            {\n                std::sort(m_storage, m_storage + m_size, HashedArray::LessThanSortPredicate);\n                m_isSortCacheValid = true;\n            }\n            \n            u32 low = 0;\n            s32 high = m_size-1;\n            u32 mid = 0;\n            \n            while((s32)low <= high)\n            {\n                mid = (high + low)/ 2;\n                if(in_keyHash == m_storage[mid].first)\n                {\n                    return mid;\n                }\n                else if(in_keyHash < m_storage[mid].first)\n                {\n                    high = mid - 1;\n                }\n                else\n                {\n                    low = mid + 1;\n                }\n            }\n            \n            return -1;\n        }\n        \n    private:\n        \n        HashDelegate m_hashFunction;\n        \n        u32 m_size;\n        u32 m_capacity;\n        \n        mutable bool m_isSortCacheValid;\n        \n        KeyValue* m_storage;\n    };\n}\n\n#endif\n\n"
  },
  {
    "path": "Source/ChilliSource/Core/Container/ParamDictionary.cpp",
    "content": "//\n//  ParamDictionary.cpp\n//  ChilliSource\n//  Created by Stuart McGaw on 15/02/2011.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2011 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Core/Container/ParamDictionary.h>\n\nnamespace ChilliSource\n{\n    //-----------------------------------------------------------------\n    //-----------------------------------------------------------------\n    ParamDictionary::ParamDictionary(const std::initializer_list<std::pair<std::string, std::string>>& in_initList)\n    {\n        for(const auto& pair : in_initList)\n        {\n            insert(pair);\n        }\n    }\n    //-----------------------------------------------------------------\n    //-----------------------------------------------------------------\n    void ParamDictionary::SetValue(const std::string& in_key, const std::string& in_value)\n    {\n        insert(std::make_pair(in_key, in_value));\n    }\n    //-----------------------------------------------------------------\n    //-----------------------------------------------------------------\n    bool ParamDictionary::HasKey(const std::string& in_key) const\n    {\n        return find(in_key) != end();\n    }\n    //-----------------------------------------------------------------\n    //-----------------------------------------------------------------\n    bool ParamDictionary::TryGetValue(const std::string& in_key, std::string& out_value) const\n    {\n        auto it = find(in_key);\n        \n        if(it != end())\n        {\n            out_value = it->second;\n            return true;\n        }\n        \n        return false;\n    }\n    //-----------------------------------------------------------------\n    //-----------------------------------------------------------------\n    const std::string& ParamDictionary::GetValue(const std::string& in_key) const\n    {\n        return GetValueOrDefault(in_key, \"\");\n    }\n    //-----------------------------------------------------------------\n    //-----------------------------------------------------------------\n    const std::string& ParamDictionary::GetValueOrDefault(const std::string& in_key, const std::string& in_default) const\n    {\n        auto it = find(in_key);\n        \n        if(it != end())\n        {\n            return it->second;\n        }\n        \n        return in_default;\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Core/Container/ParamDictionary.h",
    "content": "//\n//  ParamDictionary.h\n//  ChilliSource\n//  Created by Stuart McGaw on 15/02/2011.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2011 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_CONTAINER_PARAMDICTIONARY_H_\n#define _CHILLISOURCE_CORE_CONTAINER_PARAMDICTIONARY_H_\n\n#include <ChilliSource/ChilliSource.h>\n\n#include <unordered_map>\n\nnamespace ChilliSource\n{\n    //-----------------------------------------------------------------\n    /// Dictionary wrapper that maps string keys to string values\n    /// and provides convenience setters and accessors\n    ///\n    /// @author S McGaw\n    //-----------------------------------------------------------------\n    class ParamDictionary final : public std::unordered_map<std::string, std::string>\n    {\n    public:\n        \n        //-----------------------------------------------------------------\n        /// Constructor default\n        ///\n        /// @author S Downie\n        //-----------------------------------------------------------------\n        ParamDictionary() = default;\n        //-----------------------------------------------------------------\n        /// Constructor from initialiser list of key/value pairs\n        ///\n        /// @author S Downie\n        ///\n        /// @param Initialiser list of key/value pairs\n        //-----------------------------------------------------------------\n        ParamDictionary(const std::initializer_list<std::pair<std::string, std::string>>& in_initList);\n        //-----------------------------------------------------------------\n        /// @author S McGaw\n        ///\n        /// @param Key\n        /// @param Value\n        //-----------------------------------------------------------------\n        void SetValue(const std::string& in_key, const std::string& in_value);\n        //-----------------------------------------------------------------\n        /// @author S McGaw\n        ///\n        /// @param Key\n        ///\n        /// @return Whether key exists in dictionary\n        //-----------------------------------------------------------------\n        bool HasKey(const std::string& in_key) const;\n        //-----------------------------------------------------------------\n        /// @author S McGaw\n        ///\n        /// @param Key\n        /// @param [Out] Storage for value if the key exists\n        ///\n        /// @return Whether key exists and value has been set\n        //-----------------------------------------------------------------\n        bool TryGetValue(const std::string& in_key, std::string& out_value) const;\n        //-----------------------------------------------------------------\n        /// @author S McGaw\n        ///\n        /// @param Key\n        ///\n        /// @return Value at key or empty\n        //-----------------------------------------------------------------\n        const std::string& GetValue(const std::string& in_key) const;\n        //-----------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Key\n        /// @param Default value to return if key does not exist\n        ///\n        /// @return Value at key or default\n        //-----------------------------------------------------------------\n        const std::string& GetValueOrDefault(const std::string& in_key, const std::string& in_default) const;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Container/ParamDictionarySerialiser.cpp",
    "content": "//\n//  ParamDictionarySerialiser.cpp\n//  ChilliSource\n//  Created by Scott Downie on 15/05/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Core/Container/ParamDictionarySerialiser.h>\n\n#include <ChilliSource/Core/Container/ParamDictionary.h>\n\nnamespace ChilliSource\n{\n    namespace ParamDictionarySerialiser\n    {\n        //-----------------------------------------------------------------\n        //-----------------------------------------------------------------\n        void ToXml(const ParamDictionary& in_dict, XML::Node* out_element)\n        {\n            XML::Document* doc = out_element->document();\n            \n            out_element->name(doc->allocate_string(\"Params\"));\n            \n            for(auto it = in_dict.begin(); it != in_dict.end(); ++it)\n            {\n                XML::Attribute* keyAttribute = out_element->document()->allocate_attribute();\n                keyAttribute->name(out_element->document()->allocate_string(\"key\"));\n                keyAttribute->value(out_element->document()->allocate_string(it->first.c_str()));\n                \n                XML::Attribute* valueAttribute = out_element->document()->allocate_attribute();\n                valueAttribute->name(out_element->document()->allocate_string(\"value\"));\n                valueAttribute->value(out_element->document()->allocate_string(it->second.c_str()));\n\n                XML::Node* node = out_element->document()->allocate_node(rapidxml::node_type::node_element);\n                node->name(doc->allocate_string(\"Param\"));\n                node->append_attribute(keyAttribute);\n                node->append_attribute(valueAttribute);\n                out_element->append_node(node);\n            }\n        }\n        //-----------------------------------------------------------------\n        //-----------------------------------------------------------------\n        ParamDictionary FromXml(const XML::Node* in_element)\n        {\n            ParamDictionary result;\n            \n            for(auto param = XMLUtils::GetFirstChildElement(in_element); param != nullptr; param = XMLUtils::GetNextSiblingElement(param))\n            {\n                std::string key;\n                std::string value;\n                for(auto attrib = XMLUtils::GetFirstAttribute(param); attrib != nullptr; attrib = XMLUtils::GetNextAttribute(attrib))\n                {\n                    if (XMLUtils::GetName(attrib) == \"key\")\n                    {\n                        key = XMLUtils::GetValue(attrib);\n                    }\n                    else if (XMLUtils::GetName(attrib) == \"value\")\n                    {\n                        value = attrib->value();\n                    }\n                }\n                \n                if(key.length() > 0 && value.length() > 0)\n                {\n                    result.SetValue(key, value);\n                }\n            }\n            \n            return result;\n        }\n        //-----------------------------------------------------------------\n        //-----------------------------------------------------------------\n        std::string ToString(const ParamDictionary& in_dict)\n        {\n            std::string result;\n            \n            for(auto it = in_dict.begin(); it != in_dict.end(); ++it)\n            {\n                result.append(it->first+\"=\"+it->second+\";\");\n            }\n            \n            return result;\n        }\n        //-----------------------------------------------------------------\n        //-----------------------------------------------------------------\n        ParamDictionary FromString(const std::string& in_string)\n        {\n            ParamDictionary result;\n            \n            u32 start = 0;\n            std::string key;\n            std::string value;\n            for(u32 i=0; i<in_string.size(); ++i)\n            {\n                const char c = in_string[i];\n                \n                // Any of these characters\n                if(c == '\\t' || c == '\\n' || c == '\\r' || c == '=' || c == ';'|| (c == ' ' && key.empty()))\n                {\n                    if(start == i)\n                    {\n                        start = i + 1;\n                        continue;\n                    }\n                    \n                    if(key.empty())\n                    {\n                        key.assign(in_string.begin() + start, in_string.begin()+i);\n                        \n                        while(in_string[start] != '=' && start < in_string.size())\n                            start++;\n                        \n                        i = start - 1;\n                    }\n                    else if(value.empty())\n                    {\n                        while(in_string[start] == ' ' && start < in_string.size())\n                            start++;\n                        \n                        value.assign(in_string.begin() + start, in_string.begin()+i);\n                        result.SetValue(key, value);\n                        \n                        key.clear();\n                        value.clear();\n                    }\n                    start = i + 1;\n                    continue;\n                }\n            }\n\n            return result;\n        }\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Core/Container/ParamDictionarySerialiser.h",
    "content": "//\n//  ParamDictionarySerialiser.h\n//  ChilliSource\n//  Created by Scott Downie on 15/05/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_CONTAINER_PARAMDICTIONARYSERIALISER_H_\n#define _CHILLISOURCE_CORE_CONTAINER_PARAMDICTIONARYSERIALISER_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/XML/XMLUtils.h>\n\nnamespace ChilliSource\n{\n    //-----------------------------------------------------------------\n    /// Methods for serialising param dictionaries to and from a\n    /// variety of formats\n    ///\n    /// @author S Downie\n    //-----------------------------------------------------------------\n    namespace ParamDictionarySerialiser\n    {\n        //-----------------------------------------------------------------\n        /// Convert the param dictionary to XML and store it in the given\n        /// XML element.\n        ///\n        /// Format: <Params><String key = \"key\" value = \"value\"/></Params>\n        ///\n        /// @author A Glass\n        ///\n        /// @param Param dictionary to serialise\n        /// @param [Out] XML element\n        //-----------------------------------------------------------------\n        void ToXml(const ParamDictionary& in_dict, XML::Node* out_element);\n        //-----------------------------------------------------------------\n        /// Convert the XML to a param dictionary of key/values\n        ///\n        /// Format: <Params><String key = \"key\" value = \"value\"/></Params>\n        ///\n        /// @author A Glass\n        ///\n        /// @param XML element\n        ///\n        /// @return Param dictionary\n        //-----------------------------------------------------------------\n        ParamDictionary FromXml(const XML::Node* in_element);\n        //-----------------------------------------------------------------\n        /// Convert the param dictionary to a string config representation\n        ///\n        /// Format: \"key1 = value1; key2 = value2;\"\n        ///\n        /// @author S McGaw\n        ///\n        /// @param Param dictionary\n        ///\n        /// @return String\n        //-----------------------------------------------------------------\n        std::string ToString(const ParamDictionary& in_dict);\n        //-----------------------------------------------------------------\n        /// Convert the given string to a param dictionary of key/values\n        ///\n        /// Format: \"key1 = value1; key2 = value2;\"\n        ///\n        /// @author S McGaw\n        ///\n        /// @param String\n        ///\n        /// @return Param dictionary\n        //-----------------------------------------------------------------\n        ParamDictionary FromString(const std::string& in_string);\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Container/Property/IProperty.h",
    "content": "//\n//  IProperty.h\n//  ChilliSource\n//  Created by Ian Copland on 03/12/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_CONTAINER_PROPERTY_IPROPERTY_H_\n#define _CHILLISOURCE_CORE_CONTAINER_PROPERTY_IPROPERTY_H_\n\n#include <ChilliSource/ChilliSource.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------\n    /// A container for a value of a type determined by the implementing class.\n    /// This is mostly used for type erasuring to store heterogeneous types in\n    /// the same container. It also provides indirect method of setting the\n    /// value without knowing the erased type, both through string parsing and\n    /// using another type erased property.\n    ///\n    /// @author Ian Copland\n    //------------------------------------------------------------------------\n    class IProperty\n    {\n    public:\n        //-----------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The underlying property type description. This can be\n        /// used to re-establish the underlying type.\n        //-----------------------------------------------------------------\n        virtual const IPropertyType* GetType() const = 0;\n        //-----------------------------------------------------------------\n        /// Parses the given string and sets the property to the parsed\n        /// value.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The string to parse.\n        //-----------------------------------------------------------------\n        virtual void Parse(const std::string& in_stringValue) = 0;\n        //-----------------------------------------------------------------\n        /// Sets the value of the property to that of the given property.\n        /// The two properties must be of the same type, otherwise the app\n        /// is considered to be in an irrecoverable state and will terminate.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The property whose value this will be set to.\n        //-----------------------------------------------------------------\n        virtual void Set(const IProperty* in_property) = 0;\n        //-----------------------------------------------------------------\n        /// Virtual destructor.\n        ///\n        /// @author Ian Copland\n        //-----------------------------------------------------------------\n        virtual ~IProperty() {}\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Container/Property/IPropertyType.h",
    "content": "//\n//  IPropertyType.h\n//  ChilliSource\n//  Created by Ian Copland on 03/12/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n#ifndef _CHILLISOURCE_CORE_CONTAINER_PROPERTY_IPROPERTYTYPE_H_\n#define _CHILLISOURCE_CORE_CONTAINER_PROPERTY_IPROPERTYTYPE_H_\n\n#include <ChilliSource/ChilliSource.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------\n    /// A container for information on a specific type of property. The\n    /// specific property type is described by the implementing class. This\n    /// is typically used for type erasure so that a series of heterogeneous\n    /// property types can be stored in the same container. This allows\n    /// creation of instances of the property described without knowing the\n    /// specific type.\n    ///\n    /// Properties retain a pointer to the Property Type that created them\n    /// which means the property type must outlive any properties created\n    /// through it. Typically Property Types are allocated statically to\n    /// guarantee this.\n    ///\n    /// @author Ian Copland\n    //------------------------------------------------------------------------\n    class IPropertyType\n    {\n    public:\n        //-----------------------------------------------------------------\n        /// Creates a new instance of the described property type. This\n        /// does not require knowledge of the specific property type.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @return The string name of the underlying type.\n        //-----------------------------------------------------------------\n        virtual IPropertyUPtr CreateProperty() const = 0;\n        //-----------------------------------------------------------------\n        /// Virtual destructor.\n        ///\n        /// @author Ian Copland\n        //-----------------------------------------------------------------\n        virtual ~IPropertyType() {};\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Container/Property/Property.h",
    "content": "//\n//  Property.h\n//  ChilliSource\n//  Created by Ian Copland on 03/12/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n#ifndef _CHILLISOURCE_CORE_CONTAINER_PROPERTY_PROPERTY_H_\n#define _CHILLISOURCE_CORE_CONTAINER_PROPERTY_PROPERTY_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Container/Property/IProperty.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------\n    /// A specific type of property. This implements the IProperty interface\n    /// and exposes the specific type of the underlying value. Methods for\n    /// setting and getting the value are provided while abtracting the\n    /// literal storage of the value.\n    ///\n    /// @author Ian Copland\n    //------------------------------------------------------------------------\n    template <typename TType> class Property : public IProperty\n    {\n    public:\n        //-----------------------------------------------------------------\n        /// Constructor. Constructs the property with the given type\n        /// description.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The type description.\n        //-----------------------------------------------------------------\n        Property(const PropertyType<TType>* in_type);\n        //-----------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The property type description.\n        //-----------------------------------------------------------------\n        const IPropertyType* GetType() const override;\n        //-----------------------------------------------------------------\n        /// A basic getter for the value of the property. The literal storage\n        /// of the value is determined by the implementing type.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The value to set the property to.\n        //-----------------------------------------------------------------\n        virtual TType Get() const = 0;\n        //-----------------------------------------------------------------\n        /// Parses the given string and sets the property to the parsed\n        /// value.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The string to parse.\n        //-----------------------------------------------------------------\n        void Parse(const std::string& in_stringValue) override;\n        //-----------------------------------------------------------------\n        /// Sets the value of the property to that of the given property.\n        /// The given property must be of the same type, otherwise the app\n        /// is considered to be in an irrecoverable state and will terminate.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The property whose value this will be set to.\n        //-----------------------------------------------------------------\n        void Set(const IProperty* in_property) override;\n        //-----------------------------------------------------------------\n        /// A basic setter for the value of the property. The literal storage\n        /// of the value is determined by the implementing type.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The value to set the property to.\n        //-----------------------------------------------------------------\n        virtual void Set(const TType& in_value) = 0;\n        \n    private:\n        const PropertyType<TType>* m_type;\n    };\n}\n\n//------------------------------------------------------------------------\n// These are included here to avoid circular inclusion issues. At this\n// stage the class has been defined which is enough for the classes\n// included to use it.\n//------------------------------------------------------------------------\n#include <ChilliSource/Core/Container/Property/PropertyType.h>\n\nnamespace ChilliSource\n{\n    //-----------------------------------------------------------------\n    //-----------------------------------------------------------------\n    template <typename TType> Property<TType>::Property(const PropertyType<TType>* in_type)\n        : m_type(in_type)\n    {\n    }\n    //-----------------------------------------------------------------\n    //-----------------------------------------------------------------\n    template <typename TType> const IPropertyType* Property<TType>::GetType() const\n    {\n        return m_type;\n    }\n    //-----------------------------------------------------------------\n    //-----------------------------------------------------------------\n    template <typename TType> void Property<TType>::Parse(const std::string& in_string)\n    {\n        auto parser = m_type->GetParseDelegate();\n        CS_ASSERT(parser != nullptr, \"Cannot parse this property type from string.\");\n        \n        TType value = parser(in_string);\n        Set(value);\n    }\n    //-----------------------------------------------------------------\n    //-----------------------------------------------------------------\n    template <typename TType> void Property<TType>::Set(const IProperty* in_property)\n    {\n        CS_ASSERT(in_property->GetType() == GetType(), \"Cannot set using the contents of another property created from a different Property Type.\");\n        \n        const Property<TType>* castProperty = CS_SMARTCAST(const Property<TType>*, in_property, \"Cannot set a property of a different property type.\");\n        Set(castProperty->Get());\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Container/Property/PropertyMap.cpp",
    "content": "//\n//  PropertyMap.cpp\n//  ChilliSource\n//  Created by Scott Downie on 29/07/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Core/Container/Property/PropertyMap.h>\n\n#include <ChilliSource/Core/Container/Property/PropertyType.h>\n#include <ChilliSource/Core/Json/JsonUtils.h>\n#include <ChilliSource/Core/Math/Vector2.h>\n#include <ChilliSource/Core/Math/Vector3.h>\n#include <ChilliSource/Core/String/StringParser.h>\n#include <ChilliSource/Rendering/Base/AlignmentAnchors.h>\n\n#include <json/json.h>\n\nnamespace ChilliSource\n{\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    PropertyMap::PropertyMap(const std::vector<PropertyDesc>& in_propertyDefs)\n    {\n        for(const auto& propertyDef : in_propertyDefs)\n        {\n            CS_ASSERT(m_properties.find(propertyDef.m_name) == m_properties.end(), \"Duplicate property name in property map descs: \" + propertyDef.m_name);\n            \n            std::string lowerName = propertyDef.m_name;\n            StringUtils::ToLowerCase(lowerName);\n            \n            PropertyContainer container;\n            container.m_initialised = false;\n            container.m_property = propertyDef.m_type->CreateProperty();\n            m_properties.insert(std::make_pair(lowerName, std::move(container)));\n            \n            m_propertyKeys.push_back(propertyDef.m_name);\n        }\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    PropertyMap::PropertyMap(PropertyMap&& in_move)\n    : m_properties(std::move(in_move.m_properties)), m_propertyKeys(std::move(in_move.m_propertyKeys))\n    {\n        in_move.m_propertyKeys.clear();\n        in_move.m_properties.clear();\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    PropertyMap::PropertyMap(const PropertyMap& in_copy)\n    {\n        for(const auto& pair : in_copy.m_properties)\n        {\n            PropertyContainer container;\n            container.m_initialised = pair.second.m_initialised;\n            container.m_property = pair.second.m_property->GetType()->CreateProperty();\n            container.m_property->Set(pair.second.m_property.get());\n            m_properties.insert(std::make_pair(pair.first, std::move(container)));\n        }\n        \n        m_propertyKeys = in_copy.m_propertyKeys;\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    PropertyMap& PropertyMap::operator=(PropertyMap&& in_move)\n    {\n        m_properties = std::move(in_move.m_properties);\n        m_propertyKeys = std::move(in_move.m_propertyKeys);\n        \n        in_move.m_properties.clear();\n        in_move.m_propertyKeys.clear();\n        \n        return *this;\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    PropertyMap& PropertyMap::operator=(const PropertyMap& in_copy)\n    {\n        m_properties.clear();\n        \n        for(auto& pair : in_copy.m_properties)\n        {\n            PropertyContainer container;\n            container.m_initialised = pair.second.m_initialised;\n            container.m_property = pair.second.m_property->GetType()->CreateProperty();\n            container.m_property->Set(pair.second.m_property.get());\n            m_properties.insert(std::make_pair(pair.first, std::move(container)));\n        }\n        \n        m_propertyKeys = in_copy.m_propertyKeys;\n        \n        return *this;\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    const std::vector<std::string>& PropertyMap::GetKeys() const\n    {\n        return m_propertyKeys;\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    bool PropertyMap::HasKey(const std::string& in_name) const\n    {\n        std::string lowerCaseName = in_name;\n        StringUtils::ToLowerCase(lowerCaseName);\n        \n        return m_properties.find(lowerCaseName) != m_properties.end();\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    bool PropertyMap::HasValue(const std::string& in_name) const\n    {\n        std::string lowerCaseName = in_name;\n        StringUtils::ToLowerCase(lowerCaseName);\n        \n        auto it = m_properties.find(lowerCaseName);\n        if (it == m_properties.end())\n        {\n            CS_LOG_FATAL(\"Querying whether a non-existant property has a value.\");\n            return false;\n        }\n        \n        return it->second.m_initialised;\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    void PropertyMap::SetProperty(const std::string& in_name, const char* in_value)\n    {\n        SetProperty<std::string>(in_name, in_value);\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    void PropertyMap::ParseProperty(const std::string& in_name, const std::string& in_value)\n    {\n        std::string lowerCaseName = in_name;\n        StringUtils::ToLowerCase(lowerCaseName);\n        \n        auto entry = m_properties.find(lowerCaseName);\n        CS_ASSERT(entry != m_properties.end(), \"No property in property map with name: \" + in_name);\n        \n        IProperty* property = entry->second.m_property.get();\n        property->Parse(in_value);\n        entry->second.m_initialised = true;\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    std::string PropertyMap::GetPropertyOrDefault(const std::string& in_name, const char* in_default) const\n    {\n        return GetPropertyOrDefault<std::string>(in_name, in_default);\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    const IPropertyType* PropertyMap::GetType(const std::string& in_name) const\n    {\n        std::string lowerCaseName = in_name;\n        StringUtils::ToLowerCase(lowerCaseName);\n        \n        auto entry = m_properties.find(lowerCaseName);\n        CS_ASSERT(entry != m_properties.end(), \"No property with name: \" + in_name);\n        return entry->second.m_property->GetType();\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    IProperty* PropertyMap::GetPropertyObject(const std::string& in_name)\n    {\n        std::string lowerCaseName = in_name;\n        StringUtils::ToLowerCase(lowerCaseName);\n        \n        auto entry = m_properties.find(lowerCaseName);\n        CS_ASSERT(entry != m_properties.end(), \"No property with name: \" + in_name);\n        return entry->second.m_property.get();\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    const IProperty* PropertyMap::GetPropertyObject(const std::string& in_name) const\n    {\n        std::string lowerCaseName = in_name;\n        StringUtils::ToLowerCase(lowerCaseName);\n        \n        auto entry = m_properties.find(lowerCaseName);\n        CS_ASSERT(entry != m_properties.end(), \"No property with name: \" + in_name);\n        return entry->second.m_property.get();\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    PropertyMap::PropertyContainer::PropertyContainer(PropertyContainer&& in_move)\n    {\n        m_initialised = in_move.m_initialised;\n        m_property = std::move(in_move.m_property);\n\n        in_move.m_initialised = false;\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    PropertyMap::PropertyContainer& PropertyMap::PropertyContainer::operator=(PropertyContainer&& in_move)\n    {\n        m_initialised = in_move.m_initialised;\n        m_property = std::move(in_move.m_property);\n\n        in_move.m_initialised = false;\n\n        return *this;\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Core/Container/Property/PropertyMap.h",
    "content": "//\n//  PropertyMap.h\n//  ChilliSource\n//  Created by Scott Downie on 29/07/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_CONTAINER_PROPERTY_PROPERTYMAP_H_\n#define _CHILLISOURCE_CORE_CONTAINER_PROPERTY_PROPERTYMAP_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Cryptographic/HashCRC32.h>\n#include <ChilliSource/Core/Cryptographic/HashCRC32.h>\n#include <ChilliSource/Core/String/StringUtils.h>\n#include <ChilliSource/Core/Container/Property/Property.h>\n\n#include <cassert>\n#include <unordered_map>\n#include <vector>\n\nnamespace ChilliSource\n{\n    //---------------------------------------------------------------------------------\n    /// Simplified version of a map data-structure. The keys can only be set at\n    /// construction time as the map has a fixed size and is contiguous. Unlike STL\n    /// maps, the property map can handle heterogenous types.\n    ///\n    /// Properties are created without a value. GetProperty() should only be used on\n    /// a property after SetProperty() has been called for it. HasValue() can be used\n    /// to check if a value has been set.\n    ///\n    /// @author S Downie\n    //---------------------------------------------------------------------------------\n    class PropertyMap final\n    {\n    public:\n        //----------------------------------------------------------------------------------------\n        /// Holds the definition of a custom property.\n        ///\n        /// @author S Downie\n        //----------------------------------------------------------------------------------------\n        struct PropertyDesc\n        {\n            const IPropertyType* m_type;\n            std::string m_name;\n        };\n        //----------------------------------------------------------------------------------------\n        /// Constructor. Creates a property map with no keys.\n        ///\n        /// @author S Downie\n        //----------------------------------------------------------------------------------------\n        PropertyMap() = default;\n        //----------------------------------------------------------------------------------------\n        /// Constructor\n        ///\n        /// @author S Downie\n        ///\n        /// @param List of the key names and types\n        //----------------------------------------------------------------------------------------\n        PropertyMap(const std::vector<PropertyDesc>& in_propertyDefs);\n        //----------------------------------------------------------------------------------------\n        /// Move constructor\n        ///\n        /// @author S Downie\n        ///\n        /// @param Object to move to this\n        //----------------------------------------------------------------------------------------\n        PropertyMap(PropertyMap&& in_move);\n        //----------------------------------------------------------------------------------------\n        /// Copy constructor\n        ///\n        /// @author S Downie\n        ///\n        /// @param Object to copy to this\n        //----------------------------------------------------------------------------------------\n        PropertyMap(const PropertyMap& in_copy);\n        //----------------------------------------------------------------------------------------\n        /// Move assignment\n        ///\n        /// @author S Downie\n        ///\n        /// @param Object to move to this\n        ///\n        /// @return this\n        //----------------------------------------------------------------------------------------\n        PropertyMap& operator=(PropertyMap&& in_move);\n        //----------------------------------------------------------------------------------------\n        /// Copy assignment\n        ///\n        /// @author S Downie\n        ///\n        /// @param Object to copy to this\n        ///\n        /// @return this\n        //----------------------------------------------------------------------------------------\n        PropertyMap& operator=(const PropertyMap& in_copy);\n        //----------------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The list of keys in the property map.\n        //----------------------------------------------------------------------------------------\n        const std::vector<std::string>& GetKeys() const;\n        //----------------------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Property name\n        ///\n        /// @return Whether the property key exists\n        //----------------------------------------------------------------------------------------\n        bool HasKey(const std::string& in_name) const;\n        //----------------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param The property name\n        ///\n        /// @return Whether or not property with the given key has a value. This will error if the\n        /// property doesn't exist.\n        //----------------------------------------------------------------------------------------\n        bool HasValue(const std::string& in_name) const;\n        //----------------------------------------------------------------------------------------\n        /// Set the value of the property with the given name. If no property exists with the\n        /// name then it will assert.\n        ///\n        /// @author S Downie\n        ///\n        /// @param Name\n        /// @param Value\n        //----------------------------------------------------------------------------------------\n        template<typename TType> void SetProperty(const std::string& in_name, TType&& in_value);\n        //----------------------------------------------------------------------------------------\n        /// Specialisation to store property value for const char* as a std::string\n        ///\n        /// @author S Downie\n        ///\n        /// @param Property name\n        /// @param Property value\n        //----------------------------------------------------------------------------------------\n        void SetProperty(const std::string& in_name, const char* in_value);\n        //----------------------------------------------------------------------------------------\n        /// Sets the property with the given name to the result of parsing the given string.\n        /// Not all property types can be parsed depending on whether or not the type specifies\n        /// a parse delegate. If not or a property with the given name doesn't exist the app is\n        /// considered to be in an irrecoverable state and will terminate.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The name of the property.\n        /// @param The value to set in string form.\n        //----------------------------------------------------------------------------------------\n        void ParseProperty(const std::string& in_name, const std::string& in_value);\n        //----------------------------------------------------------------------------------------\n        /// Get the value of the property with the given name. If no property exists with the name\n        /// or the property doesn't yet have a value, with the name then it will assert.\n        ///\n        /// @author S Downie\n        ///\n        /// @param Name\n        ///\n        /// @return Value\n        //----------------------------------------------------------------------------------------\n        template<typename TType> TType GetProperty(const std::string& in_name) const;\n        //----------------------------------------------------------------------------------------\n        /// Get the value of the property with the given name. If the property has not been set\n        /// the default will be returned instead. If the property doesn't exist it will assert.\n        ///\n        /// @author S Downie\n        ///\n        /// @param Name\n        ///\n        /// @return Value (or default)\n        //----------------------------------------------------------------------------------------\n        template<typename TType> TType GetPropertyOrDefault(const std::string& in_name, TType&& in_default) const;\n        //----------------------------------------------------------------------------------------\n        /// Specialisation to return property value for const char* which is stored as a std::string\n        ///\n        /// @author S Downie\n        ///\n        /// @param Property name\n        /// @param Default value\n        ///\n        /// @return Property value or default if name not found\n        //----------------------------------------------------------------------------------------\n        std::string GetPropertyOrDefault(const std::string& in_name, const char* in_default) const;\n        //----------------------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Property name\n        ///\n        /// @return The type of the property with the given name\n        //----------------------------------------------------------------------------------------\n        const IPropertyType* GetType(const std::string& in_name) const;\n        //----------------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param The property name.\n        ///\n        /// @return The underlying property object for the given key. If there is no property\n        /// with the given name, or the property has no value this will assert.\n        //----------------------------------------------------------------------------------------\n        IProperty* GetPropertyObject(const std::string& in_name);\n        //----------------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param The property name.\n        ///\n        /// @return A constant version of the underlying property object for the given key. If\n        /// there is no property with the given name, or the property has no value this will assert.\n        //----------------------------------------------------------------------------------------\n        const IProperty* GetPropertyObject(const std::string& in_name) const;\n        \n    private:\n        //----------------------------------------------------------------------------------------\n        /// A container for the property and a boolean to state whether or not the property has\n        /// been given a value.\n        ///\n        /// @author Ian Copland\n        //----------------------------------------------------------------------------------------\n        struct PropertyContainer\n        {\n            CS_DECLARE_NOCOPY(PropertyContainer);\n            //----------------------------------------------------------------------------------------\n            /// Default constructor.\n            ///\n            /// @author Ian Copland\n            //----------------------------------------------------------------------------------------\n            PropertyContainer() = default;\n            //----------------------------------------------------------------------------------------\n            /// Move constructor. The implicit move constructor isn't enough on windows so it needs to\n            /// be manually specified.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param The container to move.\n            //----------------------------------------------------------------------------------------\n            PropertyContainer(PropertyContainer&& in_move);\n            //----------------------------------------------------------------------------------------\n            /// Move asignment operator. The implicit move assignment isn't enough on windows so it \n            /// needs to be manually specified.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param The container to move.\n            ///\n            /// @return A reference to this.\n            //----------------------------------------------------------------------------------------\n            PropertyContainer& operator=(PropertyContainer&& in_move);\n\n            bool m_initialised = false;\n            IPropertyUPtr m_property;\n        };\n\n        std::vector<std::string> m_propertyKeys;\n        std::unordered_map<std::string, PropertyContainer> m_properties;\n    };\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    template<typename TType> void PropertyMap::SetProperty(const std::string& in_name, TType&& in_value)\n    {\n        typedef typename std::decay<TType>::type TValueType;\n        \n        std::string lowerCaseName = in_name;\n        StringUtils::ToLowerCase(lowerCaseName);\n        \n        auto entry = m_properties.find(lowerCaseName);\n        CS_ASSERT(entry != m_properties.end(), \"No property in property map with name: \" + in_name);\n\n        Property<TValueType>* property = CS_SMARTCAST(Property<TValueType>*, entry->second.m_property.get(), \"Wrong type for property with name: \" + in_name);\n        property->Set(std::forward<TType>(in_value));\n        entry->second.m_initialised = true;\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    template<typename TType> TType PropertyMap::GetProperty(const std::string& in_name) const\n    {\n        typedef typename std::decay<TType>::type TValueType;\n        \n        std::string lowerCaseName = in_name;\n        StringUtils::ToLowerCase(lowerCaseName);\n        \n        auto entry = m_properties.find(lowerCaseName);\n        CS_ASSERT(entry != m_properties.end(), \"No property in property map with name: \" + in_name);\n        CS_ASSERT(entry->second.m_initialised == true, \"Cannot get the value for an uninitialised property.\");\n        \n        Property<TValueType>* property = CS_SMARTCAST(Property<TValueType>*, entry->second.m_property.get(), \"Wrong type for property with name: \" + in_name);\n        return property->Get();\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    template<typename TType> TType PropertyMap::GetPropertyOrDefault(const std::string& in_name, TType&& in_default) const\n    {\n        typedef typename std::decay<TType>::type TValueType;\n        \n        std::string lowerCaseName = in_name;\n        StringUtils::ToLowerCase(lowerCaseName);\n        \n        auto entry = m_properties.find(lowerCaseName);\n        CS_ASSERT(entry != m_properties.end(), \"No property in property map with name: \" + in_name);\n        \n        Property<TValueType>* property = CS_SMARTCAST(Property<TValueType>*, entry->second.m_property.get(), \"Wrong type for property with name: \" + in_name);\n        if (entry->second.m_initialised == true)\n        {\n            return property->Get();\n        }\n        \n        return in_default;\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Container/Property/PropertyType.h",
    "content": "//\n//  PropertyType.h\n//  ChilliSource\n//  Created by Ian Copland on 03/12/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n#ifndef _CHILLISOURCE_CORE_CONTAINER_PROPERTY_PROPERTYTYPE_H_\n#define _CHILLISOURCE_CORE_CONTAINER_PROPERTY_PROPERTYTYPE_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Container/Property/IPropertyType.h>\n\n#include <functional>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------\n    /// A container for a specific type of property. This exposes a method\n    /// for parsing instances of the type, the default value for the type and\n    /// methods for creating properties of this type. A property type is\n    /// immutable after construction.\n    ///\n    /// Properties retain a pointer to the Property Type that created them\n    /// which means the property type must outlive any properties created\n    /// through it. Typically Property Types are allocated statically to\n    /// guarantee this.\n    ///\n    /// @author Ian Copland\n    //------------------------------------------------------------------------\n    template <typename TType> class PropertyType : public IPropertyType\n    {\n    public:\n        //-----------------------------------------------------------------\n        /// A delegate used to parse objects of the given type from a\n        /// string.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The string to parse.\n        ///\n        /// @return The parsed value.\n        //-----------------------------------------------------------------\n        using ParseDelegate = std::function<TType(const std::string& in_stringToParse)>;\n        //-----------------------------------------------------------------\n        /// The value accessor delegate that will be used to get the value\n        /// of a reference property.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @return The value of the property.\n        //-----------------------------------------------------------------\n        using GetterDelegate = std::function<TType()>;\n        //-----------------------------------------------------------------\n        /// The value accessor delegate that will be used to set the value\n        /// of a reference property.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The value of the property.\n        //-----------------------------------------------------------------\n        using SetterDelegate = std::function<void(TType)>;\n        //-----------------------------------------------------------------\n        /// Constructor. Creates a new property type with the given setting.\n        /// After construction it is immutable.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The default value for the property type.\n        /// @param The string parsing method for the type. This can be null\n        /// if the type cannot be parsed from string.\n        //-----------------------------------------------------------------\n        PropertyType(TType&& in_defaultValue, const ParseDelegate& in_parseDelegate);\n        //-----------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The default value for an instance of the property.\n        //-----------------------------------------------------------------\n        TType GetDefaultValue() const;\n        //-----------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The delegate which will be used to parse the value of\n        /// a property of this type from a string.\n        //-----------------------------------------------------------------\n        const ParseDelegate& GetParseDelegate() const;\n        //-----------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return A new instance of a property of the type described by\n        /// this, set to the default value.\n        //-----------------------------------------------------------------\n        std::unique_ptr<IProperty> CreateProperty() const override;\n        //-----------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param The getter delegate.\n        /// @param The setter delegate.\n        ///\n        /// @return A new instance of a property of the type described by\n        /// this with the given accessor delegates. The default value will\n        /// not be used, instead leaving the referenced value as it current\n        /// is.\n        //-----------------------------------------------------------------\n        std::unique_ptr<IProperty> CreateProperty(GetterDelegate&& in_getter, SetterDelegate&& in_setter) const;\n        \n    private:\n        TType m_defaultValue;\n        ParseDelegate m_parseDelegate;\n    };\n}\n\n//------------------------------------------------------------------------\n// These are included here to avoid circular inclusion issues. At this\n// stage the class has been defined which is enough for the classes\n// included to use it.\n//------------------------------------------------------------------------\n#include <ChilliSource/Core/Container/Property/ReferenceProperty.h>\n#include <ChilliSource/Core/Container/Property/ValueProperty.h>\n\nnamespace ChilliSource\n{\n    //-----------------------------------------------------------------\n    //-----------------------------------------------------------------\n    template <typename TType> PropertyType<TType>::PropertyType(TType&& in_defaultValue, const ParseDelegate& in_parseDelegate)\n        : m_defaultValue(std::forward<TType>(in_defaultValue)), m_parseDelegate(in_parseDelegate)\n    {\n    }\n    //-----------------------------------------------------------------\n    //-----------------------------------------------------------------\n    template <typename TType> TType PropertyType<TType>::GetDefaultValue() const\n    {\n        return m_defaultValue;\n    }\n    //-----------------------------------------------------------------\n    //-----------------------------------------------------------------\n    template <typename TType> const typename PropertyType<TType>::ParseDelegate& PropertyType<TType>::GetParseDelegate() const\n    {\n        return m_parseDelegate;\n    }\n    //-----------------------------------------------------------------\n    //-----------------------------------------------------------------\n    template <typename TType> IPropertyUPtr PropertyType<TType>::CreateProperty() const\n    {\n        return IPropertyUPtr(new ValueProperty<TType>(this));\n    }\n    //-----------------------------------------------------------------\n    //-----------------------------------------------------------------\n    template <typename TType> IPropertyUPtr PropertyType<TType>::CreateProperty(GetterDelegate&& in_getter, SetterDelegate&& in_setter) const\n    {\n        return IPropertyUPtr(new ReferenceProperty<TType>(this, std::forward<GetterDelegate>(in_getter), std::forward<SetterDelegate>(in_setter)));\n    }\n}\n\n#define CS_DECLARE_PROPERTYTYPE(in_type, in_name) \\\n    const ChilliSource::PropertyType<in_type>* in_name();\n\n#define CS_DEFINE_PROPERTYTYPE(in_type, in_name, in_defaultValue, in_parseMethod) \\\n    const ChilliSource::PropertyType<in_type>* in_name() \\\n    { \\\n        static const ChilliSource::PropertyType<in_type> k_property(in_defaultValue, in_parseMethod); \\\n        return &k_property; \\\n    }\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Container/Property/PropertyTypes.cpp",
    "content": "//\n//  PropertyTypes.cpp\n//  ChilliSource\n//  Created by Ian Copland on 04/12/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Core/Container/Property/PropertyTypes.h>\n\n#include <ChilliSource/Core/Base/Colour.h>\n#include <ChilliSource/Core/File/StorageLocation.h>\n#include <ChilliSource/Core/Math/Matrix3.h>\n#include <ChilliSource/Core/Math/Matrix4.h>\n#include <ChilliSource/Core/Math/Quaternion.h>\n#include <ChilliSource/Core/Math/Vector2.h>\n#include <ChilliSource/Core/Math/Vector3.h>\n#include <ChilliSource/Core/Math/Vector4.h>\n#include <ChilliSource/Core/String/StringParser.h>\n\nnamespace ChilliSource\n{\n    namespace PropertyTypes\n    {\n        CS_DEFINE_PROPERTYTYPE(bool, Bool, false, &ParseBool);\n        CS_DEFINE_PROPERTYTYPE(s32, Int, 0, &ParseS32);\n        CS_DEFINE_PROPERTYTYPE(u32, UInt, 0, &ParseU32);\n        CS_DEFINE_PROPERTYTYPE(f32, Float, 0.0f, &ParseF32);\n        CS_DEFINE_PROPERTYTYPE(ChilliSource::Vector2, Vector2, ChilliSource::Vector2(), &ParseVector2);\n        CS_DEFINE_PROPERTYTYPE(ChilliSource::Vector3, Vector3, ChilliSource::Vector3(), &ParseVector3);\n        CS_DEFINE_PROPERTYTYPE(ChilliSource::Vector4, Vector4, ChilliSource::Vector4(), &ParseVector4);\n        CS_DEFINE_PROPERTYTYPE(ChilliSource::Matrix3, Matrix3, ChilliSource::Matrix3(), &ParseMatrix3);\n        CS_DEFINE_PROPERTYTYPE(ChilliSource::Matrix4, Matrix4, ChilliSource::Matrix4(), &ParseMatrix4);\n        CS_DEFINE_PROPERTYTYPE(ChilliSource::Quaternion, Quaternion, ChilliSource::Quaternion(), &ParseQuaternion);\n        CS_DEFINE_PROPERTYTYPE(ChilliSource::Colour, Colour, ChilliSource::Colour(), &ParseColour);\n        CS_DEFINE_PROPERTYTYPE(ChilliSource::StorageLocation, StorageLocation, ChilliSource::StorageLocation::k_package, &ParseStorageLocation);\n        CS_DEFINE_PROPERTYTYPE(std::string, String, \"\", [](const std::string& in_string){return in_string;});\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Core/Container/Property/PropertyTypes.h",
    "content": "//\n//  PropertyTypes.h\n//  ChilliSource\n//  Created by Ian Copland on 04/12/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_CONTAINER_PROPERTY_DEFAULTPROPERTYTYPES_H_\n#define _CHILLISOURCE_CORE_CONTAINER_PROPERTY_DEFAULTPROPERTYTYPES_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Container/Property/PropertyType.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------\n    /// The list of default property types. Other property types can be added\n    /// in addition to these.\n    ///\n    /// @author Ian Copland\n    //------------------------------------------------------------------------\n    namespace PropertyTypes\n    {\n        CS_DECLARE_PROPERTYTYPE(bool, Bool);\n        CS_DECLARE_PROPERTYTYPE(s32, Int);\n        CS_DECLARE_PROPERTYTYPE(u32, UInt);\n        CS_DECLARE_PROPERTYTYPE(f32, Float);\n        CS_DECLARE_PROPERTYTYPE(Vector2, Vector2);\n        CS_DECLARE_PROPERTYTYPE(Vector3, Vector3);\n        CS_DECLARE_PROPERTYTYPE(Vector4, Vector4);\n        CS_DECLARE_PROPERTYTYPE(Matrix3, Matrix3);\n        CS_DECLARE_PROPERTYTYPE(Matrix4, Matrix4);\n        CS_DECLARE_PROPERTYTYPE(Quaternion, Quaternion);\n        CS_DECLARE_PROPERTYTYPE(Colour, Colour);\n        CS_DECLARE_PROPERTYTYPE(StorageLocation, StorageLocation);\n        CS_DECLARE_PROPERTYTYPE(std::string, String);\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Container/Property/ReferenceProperty.h",
    "content": "//\n//  ReferenceProperty.h\n//  ChilliSource\n//  Created by Ian Copland on 03/12/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n#ifndef _CHILLISOURCE_CORE_CONTAINER_PROPERTY_REFERENCEPROPERTY_H_\n#define _CHILLISOURCE_CORE_CONTAINER_PROPERTY_REFERENCEPROPERTY_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Container/Property/Property.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------\n    /// A reference property. This does not contain a specific value for the\n    /// instead referencing another value accessible though the provided\n    /// getter and setter delegates.\n    ///\n    /// @author Ian Copland\n    //------------------------------------------------------------------------\n    template <typename TType> class ReferenceProperty final : public Property<TType>\n    {\n    public:\n        //-----------------------------------------------------------------\n        /// The getter delegate used when calling Get() on the property.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @return The current value of the property.\n        //-----------------------------------------------------------------\n        using GetterDelegate = std::function<TType()>;\n        //-----------------------------------------------------------------\n        /// The setter delegate used when calling Set() on the property.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The new value for the property.\n        //-----------------------------------------------------------------\n        using SetterDelegate = std::function<void(TType)>;\n        //-----------------------------------------------------------------\n        /// Constructor.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The type of property.\n        /// @param The getter delegate.\n        /// @param The setter delegate.\n        //-----------------------------------------------------------------\n        ReferenceProperty(const PropertyType<TType>* in_type, const GetterDelegate& in_getter, const SetterDelegate& in_setter);\n        //-----------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The value provided by calling the getter delegate.\n        //-----------------------------------------------------------------\n        TType Get() const override;\n        //-----------------------------------------------------------------\n        /// Sets the property value of the property by calling the setter\n        /// delegate.\n        ///\n        /// @author Ian Copland\n        //-----------------------------------------------------------------\n        void Set(const TType& in_value) override;\n        \n    private:\n        GetterDelegate m_getter;\n        SetterDelegate m_setter;\n    };\n}\n\n//------------------------------------------------------------------------\n// These are included here to avoid circular inclusion issues. At this\n// stage the class has been defined which is enough for the classes\n// included to use it.\n//------------------------------------------------------------------------\n#include <ChilliSource/Core/Container/Property/PropertyType.h>\n\nnamespace ChilliSource\n{\n    //-----------------------------------------------------------------\n    //-----------------------------------------------------------------\n    template <typename TType> ReferenceProperty<TType>::ReferenceProperty(const PropertyType<TType>* in_type, const GetterDelegate& in_getter, const SetterDelegate& in_setter)\n    : Property<TType>(in_type), m_getter(in_getter), m_setter(in_setter)\n    {\n        CS_ASSERT(m_getter != nullptr, \"Property getter delegate cannot be null.\");\n        CS_ASSERT(m_setter != nullptr, \"Property setter delegate cannot be null.\");\n    }\n    //-----------------------------------------------------------------\n    //-----------------------------------------------------------------\n    template <typename TType> void ReferenceProperty<TType>::Set(const TType& in_value)\n    {\n        m_setter(in_value);\n    }\n    //-----------------------------------------------------------------\n    //-----------------------------------------------------------------\n    template <typename TType> TType ReferenceProperty<TType>::Get() const\n    {\n        return m_getter();\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Container/Property/ValueProperty.h",
    "content": "//\n//  ValueProperty.h\n//  ChilliSource\n//  Created by Ian Copland on 03/12/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_CONTAINER_PROPERTY_VALUEPROPERTY_H_\n#define _CHILLISOURCE_CORE_CONTAINER_PROPERTY_VALUEPROPERTY_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Container/Property/Property.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------\n    /// A property that contains an instance of the given type. This is exposed\n    /// via the Get() and Set() methods.\n    ///\n    /// @author Ian Copland\n    //------------------------------------------------------------------------\n    template <typename TType> class ValueProperty final : public Property<TType>\n    {\n    public:\n        //-----------------------------------------------------------------\n        /// Constructor.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The type of the property.\n        //-----------------------------------------------------------------\n        ValueProperty(const PropertyType<TType>* in_type);\n        //-----------------------------------------------------------------\n        /// Directly sets the underlying property value.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The new value for the property.\n        //-----------------------------------------------------------------\n        void Set(const TType& in_value) override;\n        //-----------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param The value of the underlying property.\n        //-----------------------------------------------------------------\n        TType Get() const override;\n        \n    private:\n        TType m_value;\n    };\n}\n\n//------------------------------------------------------------------------\n// These are included here to avoid circular inclusion issues. At this\n// stage the class has been defined which is enough for the classes\n// included to use it.\n//------------------------------------------------------------------------\n#include <ChilliSource/Core/Container/Property/PropertyType.h>\n\nnamespace ChilliSource\n{\n    //-----------------------------------------------------------------\n    //-----------------------------------------------------------------\n    template <typename TType> ValueProperty<TType>::ValueProperty(const PropertyType<TType>* in_type)\n        : Property<TType>(in_type), m_value(in_type->GetDefaultValue())\n    {\n    }\n    //-----------------------------------------------------------------\n    //-----------------------------------------------------------------\n    template <typename TType> void ValueProperty<TType>::Set(const TType& in_value)\n    {\n        m_value = in_value;\n    }\n    //-----------------------------------------------------------------\n    //-----------------------------------------------------------------\n    template <typename TType> TType ValueProperty<TType>::Get() const\n    {\n        return m_value;\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Container/VectorUtils.h",
    "content": "//\n//  VectorUtils.h\n//  ChilliSource\n//  Created by Scott Downie on 01/12/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_CONTAINER_VECTORUTILS_H_\n#define _CHILLISOURCE_CORE_CONTAINER_VECTORUTILS_H_\n\n#include <ChilliSource/ChilliSource.h>\n\n#include <algorithm>\n#include <vector>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    /// A collection of convenience methods for working with vector from the\n    /// standard library.\n    ///\n    /// @author Ian Copland\n    //------------------------------------------------------------------------------\n    namespace VectorUtils\n    {\n        //------------------------------------------------------------------------------\n        /// Returns whether or not the given vector contains the given value.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The vector.\n        /// @param The value to check.\n        ///\n        /// @return Whether or not the given value is contained in the given vector.\n        //------------------------------------------------------------------------------\n        template <typename TValueType> bool Contains(const std::vector<TValueType>& in_vector, TValueType in_value);\n        //------------------------------------------------------------------------------\n        /// Removes the first instance of the given value from the vector. If the value \n        /// doesn't exist in the vector the app is considered to be in an irrecovereable \n        /// state and will terminate. This should not be called while iterating over a \n        /// vector as it will invalidate any iterators.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The vector.\n        /// @param The value to check.\n        //------------------------------------------------------------------------------\n        template <typename TValueType> void Remove(std::vector<TValueType>& in_vector, TValueType in_value);\n        //------------------------------------------------------------------------------\n        /// Tests that two vectors have the same contents. Both must have identical\n        /// contents and be the same size, but the elements do not need to be in the\n        /// same order.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param in_a - The first vector\n        /// @param in_b - The second vector\n        ///\n        /// @return Whether or not they have the same contents.\n        //------------------------------------------------------------------------------\n        template <typename TValueType> bool EqualContents(const std::vector<TValueType>& in_a, const std::vector<TValueType>& in_b);\n\n        //------------------------------------------------------------------------------\n        //------------------------------------------------------------------------------\n        template <typename TValueType> bool Contains(const std::vector<TValueType>& in_vector, TValueType in_value)\n        {\n            return (std::find(in_vector.begin(), in_vector.end(), in_value) != in_vector.end());\n        }\n        //------------------------------------------------------------------------------\n        //------------------------------------------------------------------------------\n        template <typename TValueType> void Remove(std::vector<TValueType>& in_vector, TValueType in_value)\n        {\n            auto it = std::find(in_vector.begin(), in_vector.end(), in_value);\n            CS_ASSERT(it != in_vector.end(), \"Cannot remove the given value from the vector becuase it doesn't exist.\");\n\n            in_vector.erase(it);\n        }\n        //------------------------------------------------------------------------------\n        //------------------------------------------------------------------------------\n        template <typename TValueType> bool EqualContents(const std::vector<TValueType>& in_a, const std::vector<TValueType>& in_b)\n        {\n            if (in_a.size() != in_b.size())\n            {\n                return false;\n            }\n            \n            for (const auto& itemA : in_a)\n            {\n                if (VectorUtils::Contains(in_b, itemA) == false)\n                {\n                    return false;\n                }\n            }\n            \n            return true;\n        }\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Container/concurrent_blocking_queue.h",
    "content": "//\n//  concurrent_blocking_queue.h\n//  ChilliSource\n//  Created by Scott Downie on 29/03/2011.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2011 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_CONTAINER_CONCURRENTBLOCKINGQUEUE_H_\n#define _CHILLISOURCE_CORE_CONTAINER_CONCURRENTBLOCKINGQUEUE_H_\n\n#include <ChilliSource/ChilliSource.h>\n\n#include <condition_variable>\n#include <mutex>\n#include <queue>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------\n    /// A queue which can safely be accessed from multiple threads. If\n    /// pop is called when there is nothing in the queue it will block\n    /// until something is available.\n    /// \n    /// @author Scott Downie\n    //------------------------------------------------------------------\n    template <typename TType> class concurrent_blocking_queue final\n    {\n    public:\n        \n        using size_type = std::size_t;\n        \n        //---------------------------------------------------------\n        /// Default constructor.\n        ///\n        /// @author Ian Copland\n        //---------------------------------------------------------\n        concurrent_blocking_queue() = default;\n        //---------------------------------------------------------\n        /// Copy constructor. Copies the queue without copying the\n        /// underlying mutex.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The queue to copy.\n        //---------------------------------------------------------\n        concurrent_blocking_queue(const concurrent_blocking_queue<TType>& in_toCopy);\n        //---------------------------------------------------------\n        /// Deleted move constructor.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The queue to move.\n        //---------------------------------------------------------\n        concurrent_blocking_queue(concurrent_blocking_queue<TType>&& in_toMove) = delete;\n        //---------------------------------------------------------\n        /// Copy assignment.Copies the queue without copying the\n        /// underlying mutex.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The queue to copy.\n        ///\n        /// @return a reference to this.\n        //---------------------------------------------------------\n        concurrent_blocking_queue<TType>& operator=(const concurrent_blocking_queue<TType>& in_toCopy);\n        //---------------------------------------------------------\n        /// Deleted Copy assignment.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The queue to move.\n        ///\n        /// @return a reference to this.\n        //---------------------------------------------------------\n        concurrent_blocking_queue<TType>& operator=(concurrent_blocking_queue<TType>&& in_toMove) = delete;\n        //---------------------------------------------------------\n        /// @author Scott Downie\n        ///\n        /// @return Whether the queue has no objects in it\n        //---------------------------------------------------------\n        bool empty() const;\n        //---------------------------------------------------------\n        /// @author Scott Downie\n        ///\n        /// @return Size of queue\n        //---------------------------------------------------------\n        size_type size() const;\n        //---------------------------------------------------------\n        /// Thread safe method that will push an object onto the\n        /// back of the queue\n        ///\n        /// @author Scott Downie\n        ///\n        /// @param Object of type TType\n        //---------------------------------------------------------\n        void push(TType in_object);\n        //---------------------------------------------------------\n        /// Pops and returns the front of the queue. If the queue\n        /// is empty the current thread will block until something \n        /// is added. If the queue is deleted while a thread is \n        /// still waiting it will return unsuccessfully.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param [Out] The popped object. This will only be set\n        /// if an object was successfully retreived from the queue.\n        ///\n        /// @return Whether or not a value was successfully \n        /// retreived.\n        //---------------------------------------------------------\n        bool pop_or_wait(TType& out_poppedObject);\n        //---------------------------------------------------------\n        /// Clears the queue of all objects.\n        ///\n        /// @author Ian Copland\n        //---------------------------------------------------------\n        void clear();\n        //---------------------------------------------------------\n        /// Aborts the queue, awakening any threads that are\n        /// currently waiting for a push. These threads should be\n        /// joined (or at least confirmed to no longer be executing\n        /// inside the queue) before the queue is deleted. This\n        /// must be called before the queue is deleted. After\n        /// this is called the queue is in a \"Finished\" state and\n        /// can no longer be used.\n        ///\n        /// @author Ian Copland\n        //---------------------------------------------------------\n        void abort();\n        //---------------------------------------------------------\n        /// Destructor awakes all waiting threads\n        ///\n        /// @author S Downie\n        //---------------------------------------------------------\n        ~concurrent_blocking_queue();\n    private:\n\n        std::queue<TType> m_queue;\n        bool m_finished = false;\n        mutable std::mutex m_queueMutex;\n        std::condition_variable m_emptyWaitCondition;\n    };\n    //---------------------------------------------------------\n    //---------------------------------------------------------\n    template <typename TType> concurrent_blocking_queue<TType>::concurrent_blocking_queue(const concurrent_blocking_queue<TType>& in_toCopy)\n    {\n        std::unique_lock<std::mutex> copyQueueLock(in_toCopy.m_queueMutex);\n        m_queue = in_toCopy.m_queue;\n        m_finished = in_toCopy.m_finished;\n    }\n    //---------------------------------------------------------\n    //---------------------------------------------------------\n    template <typename TType> concurrent_blocking_queue<TType>& concurrent_blocking_queue<TType>::operator=(const concurrent_blocking_queue<TType>& in_toCopy)\n    {\n        std::unique_lock<std::mutex> copyQueueLock(in_toCopy.m_queueMutex);\n        std::queue<TType> queue = in_toCopy.m_queue;\n        bool finished = in_toCopy.m_finished;\n        copyQueueLock.unlock();\n        \n        std::unique_lock<std::mutex> thisQueueLock(m_queueMutex);\n        m_queue = queue;\n        m_finished = finished;\n        return *this;\n    }\n    //-----------------------------------------------------------\n    //-----------------------------------------------------------\n    template <typename TType> bool concurrent_blocking_queue<TType>::empty() const\n    {\n        std::unique_lock<std::mutex> queueLock(m_queueMutex);\n        CS_ASSERT(m_finished == false, \"Concurrent blocking queue is being queried after calling abort().\");\n        \n        return m_queue.empty();\n    }\n    //-----------------------------------------------------------\n    //-----------------------------------------------------------\n    template <typename TType> typename concurrent_blocking_queue<TType>::size_type concurrent_blocking_queue<TType>::size() const\n    {\n        std::unique_lock<std::mutex> queueLock(m_queueMutex);\n        CS_ASSERT(m_finished == false, \"Concurrent blocking queue is being queried after calling abort().\");\n        \n        return m_queue.size();\n    }\n    //---------------------------------------------------------\n    //---------------------------------------------------------\n    template <typename TType> void concurrent_blocking_queue<TType>::push(TType in_object)\n    {\n        //Lock the queue for writing\n        std::unique_lock<std::mutex> queueLock(m_queueMutex);\n        CS_ASSERT(m_finished == false, \"Concurrent blocking queue is being pushed after calling abort().\");\n\n        //Push the object onto the queue\n        m_queue.push(in_object);\n\n        //Wakey wakey!!!!\n        m_emptyWaitCondition.notify_one();\n    }\n    //---------------------------------------------------------\n    //---------------------------------------------------------\n    template <typename TType> bool concurrent_blocking_queue<TType>::pop_or_wait(TType& out_poppedObject)\n    {\n        std::unique_lock<std::mutex> queueLock(m_queueMutex);\n        CS_ASSERT(m_finished == false, \"Concurrent blocking queue is being popped after calling abort().\");\n        \n        while (m_queue.empty() == true && m_finished == false)\n        {\n            m_emptyWaitCondition.wait(queueLock);\n        }\n        \n        if (m_finished == false)\n        {\n            out_poppedObject = std::move(m_queue.front());\n            m_queue.pop();\n            return true;\n        }\n\n        return false;\n    }\n    //---------------------------------------------------------\n    //---------------------------------------------------------\n    template <typename TType> void concurrent_blocking_queue<TType>::clear()\n    {\n        std::unique_lock<std::mutex> queueLock(m_queueMutex);\n        CS_ASSERT(m_finished == false, \"Concurrent blocking queue is being cleared after calling abort().\");\n        \n        while (m_queue.empty() == false)\n        {\n            m_queue.pop();\n        }\n    }\n    //-----------------------------------------------------------\n    //-----------------------------------------------------------\n    template <typename TType> void concurrent_blocking_queue<TType>::abort()\n    {\n        std::unique_lock<std::mutex> queueLock(m_queueMutex);\n        CS_ASSERT(m_finished == false, \"Cannot abort() a concurrent blocking queue twice.\");\n        \n        while (m_queue.empty() == false)\n        {\n            m_queue.pop();\n        }\n        \n        m_finished = true;\n        m_emptyWaitCondition.notify_all();\n    }\n    //-----------------------------------------------------------\n    //-----------------------------------------------------------\n    template <typename TType> concurrent_blocking_queue<TType>::~concurrent_blocking_queue()\n    {\n#ifdef CS_ENABLE_DEBUG\n        std::unique_lock<std::mutex> queueLock(m_queueMutex);\n        CS_ASSERT(m_finished == true, \"Concurrent blocking queue is being deleted without first calling abort().\");\n#endif\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Container/concurrent_vector.h",
    "content": "//\n//  concurrent_vector.h\n//  ChilliSource\n//  Created by Scott Downie on 19/09/2015.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2012 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_CONTAINER_CONCURRENTVECTOR_H_\n#define _CHILLISOURCE_CORE_CONTAINER_CONCURRENTVECTOR_H_\n\n#include <ChilliSource/Core/Container/concurrent_vector_const_forward_iterator.h>\n#include <ChilliSource/Core/Container/concurrent_vector_const_reverse_iterator.h>\n#include <ChilliSource/Core/Container/concurrent_vector_forward_iterator.h>\n#include <ChilliSource/Core/Container/concurrent_vector_reverse_iterator.h>\n\n#include <atomic>\n#include <vector>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------\n    /// Concurrent vector is a thread safe dynamic array implementation.\n    /// It presevers the integrity of the array when accessing from different\n    /// threads and also from changes to the array while iterating\n    ///\n    /// NOTE: This class syntax mimics STL and therefore doe not use the CS coding\n    /// standards.\n    ///\n    /// @author S Downie\n    //------------------------------------------------------------------------\n    template <typename TType> class concurrent_vector\n    {\n    public:\n        \n        using size_type = std::size_t;\n        using difference_type = std::ptrdiff_t;\n        using iterator = concurrent_vector_forward_iterator<TType>;\n        using const_iterator = concurrent_vector_const_forward_iterator<TType>;\n        using reverse_iterator = concurrent_vector_reverse_iterator<TType>;\n        using const_reverse_iterator = concurrent_vector_const_reverse_iterator<TType>;\n        \n        //--------------------------------------------------------------------\n        /// Constructor default\n        ///\n        /// @author S Downie\n        //--------------------------------------------------------------------\n        concurrent_vector();\n        //--------------------------------------------------------------------\n        /// Construct from initialiser list\n        ///\n        /// @author S Downie\n        ///\n        /// @param Initialiser list\n        //--------------------------------------------------------------------\n        concurrent_vector(std::initializer_list<TType>&& in_initialObjects);\n        //--------------------------------------------------------------------\n        /// Copy constructor that creates this as a copy of the given vector\n        ///\n        /// @author S Downie\n        ///\n        /// @param Vector to copy\n        //--------------------------------------------------------------------\n        concurrent_vector(const concurrent_vector& in_toCopy);\n        //--------------------------------------------------------------------\n        /// Copy assignment that creates this as a copy of the given vector\n        ///\n        /// @author S Downie\n        ///\n        /// @param Vector to copy\n        ///\n        /// @return This as a copy\n        //--------------------------------------------------------------------\n        concurrent_vector& operator=(const concurrent_vector& in_toCopy);\n        //--------------------------------------------------------------------\n        /// Move constructor that transfers ownership from the given vector\n        ///\n        /// @author S Downie\n        ///\n        /// @param Vector to move\n        //--------------------------------------------------------------------\n        concurrent_vector(concurrent_vector&& in_toMove);\n        //--------------------------------------------------------------------\n        /// Move assignment that transfers ownership from the given vector\n        ///\n        /// @author S Downie\n        ///\n        /// @param Vector to move\n        ///\n        /// @return This having taken ownership of the given vector\n        //--------------------------------------------------------------------\n        concurrent_vector& operator=(concurrent_vector&& in_toMove);\n        //--------------------------------------------------------------------\n        /// Push the object onto the back of the array. Unlike STL this does\n        /// not invalidate any iterators\n        ///\n        /// @author S Downie\n        ///\n        /// @param Object to add\n        //--------------------------------------------------------------------\n        void push_back(TType&& in_object);\n        //--------------------------------------------------------------------\n        /// Push the object onto the back of the array. Unlike STL this does\n        /// not invalidate any iterators\n        ///\n        /// @author S Downie\n        ///\n        /// @param Object to add\n        //--------------------------------------------------------------------\n        void push_back(const TType& in_object);\n        //--------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return The object in the first element of the array (undefined if empty)\n        //--------------------------------------------------------------------\n        TType& front();\n        //--------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return The object in the first element of the array (undefined if empty)\n        //--------------------------------------------------------------------\n        const TType& front() const;\n        //--------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return The object in the last element of the array (undefined if empty)\n        //--------------------------------------------------------------------\n        TType& back();\n        //--------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return The object in the last element of the array (undefined if empty)\n        //--------------------------------------------------------------------\n        const TType& back() const;\n        //--------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Index\n        ///\n        /// @return The object at the given index of the array (undefined if out of bounds)\n        //--------------------------------------------------------------------\n        TType& at(size_type in_index);\n        //--------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Index\n        ///\n        /// @return The object at the given index of the array (undefined if out of bounds)\n        //--------------------------------------------------------------------\n        const TType& at(size_type in_index) const;\n        //--------------------------------------------------------------------\n        /// Lock the array which prevents its contents being modified unsafely.\n        ///\n        /// @author S Downie\n        //--------------------------------------------------------------------\n        void lock();\n        //--------------------------------------------------------------------\n        /// Unlock the array.\n        ///\n        /// @author S Downie\n        //--------------------------------------------------------------------\n        void unlock();\n        //--------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return The number of items currently in the vector\n        //--------------------------------------------------------------------\n        size_type size() const;\n        //--------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Whether the vector is empty or not\n        //--------------------------------------------------------------------\n        bool empty() const;\n        //--------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Iterator pointing to the beginning of the vector\n        //--------------------------------------------------------------------\n        iterator begin();\n        //--------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Iterator pointing to the end of the vector (the end being)\n        /// after the last element\n        //--------------------------------------------------------------------\n        iterator end();\n        //--------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Iterator pointing to the beginning of the vector\n        //--------------------------------------------------------------------\n        const_iterator begin() const;\n        //--------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Iterator pointing to the end of the vector (the end being)\n        /// after the last element\n        //--------------------------------------------------------------------\n        const_iterator end() const;\n        //--------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Iterator pointing to the beginning of the vector\n        //--------------------------------------------------------------------\n        const_iterator cbegin() const;\n        //--------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Iterator pointing to the end of the vector (the end being)\n        /// after the last element\n        //--------------------------------------------------------------------\n        const_iterator cend() const;\n        //--------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Iterator pointing to the last element of the vector\n        //--------------------------------------------------------------------\n        reverse_iterator rbegin();\n        //--------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Iterator pointing to the beginning of the vector (the beginning\n        /// in this case being before the first element)\n        //--------------------------------------------------------------------\n        reverse_iterator rend();\n        //--------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Iterator pointing to the last element of the vector\n        //--------------------------------------------------------------------\n        const_reverse_iterator rbegin() const;\n        //--------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Iterator pointing to the beginning of the vector (the beginning\n        /// in this case being before the first element)\n        //--------------------------------------------------------------------\n        const_reverse_iterator rend() const;\n        //--------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Iterator pointing to the last element of the vector\n        //--------------------------------------------------------------------\n        const_reverse_iterator crbegin() const;\n        //--------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Iterator pointing to the beginning of the vector (the beginning\n        /// in this case being before the first element)\n        //--------------------------------------------------------------------\n        const_reverse_iterator crend() const;\n        //--------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Index\n        ///\n        /// @return The object at the given index of the array (undefined if out of bounds)\n        //--------------------------------------------------------------------\n        TType& operator[](size_type in_index);\n        //--------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Index\n        ///\n        /// @return The object at the given index of the array (undefined if out of bounds)\n        //--------------------------------------------------------------------\n        const TType& operator[](size_type in_index) const;\n        //--------------------------------------------------------------------\n        /// Remove the object from the vector that is pointed to by the given\n        /// iterator. Unlike STL this does not invalidate any iterators\n        ///\n        /// @author S Downie\n        ///\n        /// @param Iterator\n        ///\n        /// @return The next iterator.\n        //--------------------------------------------------------------------\n        iterator erase(const iterator& in_itErase);\n        //--------------------------------------------------------------------\n        /// Remove the object from the vector that is pointed to by the given\n        /// iterator. Unlike STL this does not invalidate any iterators\n        ///\n        /// @author S Downie\n        ///\n        /// @param Iterator\n        ///\n        /// @return The next iterator.\n        //--------------------------------------------------------------------\n        reverse_iterator erase(const reverse_iterator& in_itErase);\n        //--------------------------------------------------------------------\n        /// Clears the vector. Unlike STL this does not invalidate any iterators\n        ///\n        /// @author S Downie\n        //--------------------------------------------------------------------\n        void clear();\n        \n    private:\n        \n        //--------------------------------------------------------------------\n        /// Cleanup any elements that are marked for removal\n        ///\n        /// @author S Downie\n        //--------------------------------------------------------------------\n        void garbage_collect();\n        \n    private:\n        \n        std::vector<std::pair<TType, bool>> m_container;\n        \n        std::atomic<size_type> m_size;\n        bool m_isLocked = false;\n        bool m_requiresGC = false;\n        \n        std::recursive_mutex m_mutex;\n        std::unique_lock<std::recursive_mutex> m_lock;\n        s32 m_lockCount = 0;\n    };\n    \n    //--------------------------------------------------------------------\n    //--------------------------------------------------------------------\n    template <typename TType> concurrent_vector<TType>::concurrent_vector()\n    : m_lock(m_mutex, std::defer_lock), m_size(0)\n    {\n    }\n    //--------------------------------------------------------------------\n    //--------------------------------------------------------------------\n    template <typename TType> concurrent_vector<TType>::concurrent_vector(std::initializer_list<TType>&& in_initialObjects)\n    : m_lock(m_mutex, std::defer_lock), m_size(0)\n    {\n        m_size = in_initialObjects.size();\n        m_container.reserve(m_size);\n        \n        for(const auto& object : in_initialObjects)\n        {\n            m_container.push_back(std::make_pair(object, false));\n        }\n    }\n    //--------------------------------------------------------------------\n    //--------------------------------------------------------------------\n    template <typename TType> concurrent_vector<TType>::concurrent_vector(const concurrent_vector& in_toCopy)\n    {\n        m_size = in_toCopy.m_size.load();\n        m_container = in_toCopy.m_container;\n    }\n    //--------------------------------------------------------------------\n    //--------------------------------------------------------------------\n    template <typename TType> concurrent_vector<TType>& concurrent_vector<TType>::operator=(const concurrent_vector<TType>& in_toCopy)\n    {\n        m_size = in_toCopy.m_size.load();\n        m_container = in_toCopy.m_container;\n    }\n    //--------------------------------------------------------------------\n    //--------------------------------------------------------------------\n    template <typename TType> concurrent_vector<TType>::concurrent_vector(concurrent_vector&& in_toMove)\n    {\n        m_size = in_toMove.m_size.load();\n        in_toMove.m_size = 0;\n        m_container = std::move(in_toMove.m_container);\n    }\n    //--------------------------------------------------------------------\n    //--------------------------------------------------------------------\n    template <typename TType> concurrent_vector<TType>& concurrent_vector<TType>::operator=(concurrent_vector<TType>&& in_toMove)\n    {\n        m_size = in_toMove.m_size.load();\n        in_toMove.m_size = 0;\n        m_container = std::move(in_toMove.m_container);\n    }\n    //--------------------------------------------------------------------\n    //--------------------------------------------------------------------\n    template <typename TType> void concurrent_vector<TType>::push_back(TType&& in_object)\n    {\n        std::unique_lock<std::recursive_mutex> scopedLock(m_mutex);\n        m_container.push_back(std::make_pair(std::forward<TType>(in_object), false));\n        m_size++;\n    }\n    //--------------------------------------------------------------------\n    //--------------------------------------------------------------------\n    template <typename TType> void concurrent_vector<TType>::push_back(const TType& in_object)\n    {\n        std::unique_lock<std::recursive_mutex> scopedLock(m_mutex);\n        m_container.push_back(std::make_pair(in_object, false));\n        m_size++;\n    }\n    //--------------------------------------------------------------------\n    //--------------------------------------------------------------------\n    template <typename TType> TType& concurrent_vector<TType>::front()\n    {\n        return at(0);\n    }\n    //--------------------------------------------------------------------\n    //--------------------------------------------------------------------\n    template <typename TType> const TType& concurrent_vector<TType>::front() const\n    {\n        return at(0);\n    }\n    //--------------------------------------------------------------------\n    //--------------------------------------------------------------------\n    template <typename TType> TType& concurrent_vector<TType>::back()\n    {\n        return at(size()-1);\n    }\n    //--------------------------------------------------------------------\n    //--------------------------------------------------------------------\n    template <typename TType> const TType& concurrent_vector<TType>::back() const\n    {\n        return at(size()-1);\n    }\n    //--------------------------------------------------------------------\n    //--------------------------------------------------------------------\n    template <typename TType> TType& concurrent_vector<TType>::at(size_type in_index)\n    {\n        std::unique_lock<std::recursive_mutex> scopedLock(m_mutex);\n        if(m_requiresGC == false)\n        {\n            return m_container.at(in_index).first;\n        }\n        else\n        {\n            size_type size = m_container.size();\n            difference_type count = -1;\n            size_type index = 0;\n            for(size_type i=0; i<size; ++i)\n            {\n                if(m_container[i].second == false)\n                {\n                    if(++count == in_index)\n                    {\n                        index = i;\n                        break;\n                    }\n                }\n            }\n            \n            return m_container[index].first;\n        }\n    }\n    //--------------------------------------------------------------------\n    //--------------------------------------------------------------------\n    template <typename TType> const TType& concurrent_vector<TType>::at(size_type in_index) const\n    {\n        std::unique_lock<std::recursive_mutex> scopedLock(m_mutex);\n        if(m_requiresGC == false)\n        {\n            return m_container.at(in_index).first;\n        }\n        else\n        {\n            size_type size = m_container.size();\n            difference_type count = -1;\n            size_type index = 0;\n            for(size_type i=0; i<size; ++i)\n            {\n                if(m_container[i].second == false)\n                {\n                    if(++count == in_index)\n                    {\n                        index = i;\n                        break;\n                    }\n                }\n            }\n            \n            return m_container[index].first;\n        }\n    }\n    //--------------------------------------------------------------------\n    //--------------------------------------------------------------------\n    template <typename TType> void concurrent_vector<TType>::lock()\n    {\n        std::unique_lock<std::recursive_mutex> scopedLock(m_mutex);\n        \n        if (m_lockCount == 0)\n        {\n            m_lock.lock();\n        }\n        \n        m_lockCount++;\n        m_isLocked = true;\n    }\n    //--------------------------------------------------------------------\n    //--------------------------------------------------------------------\n    template <typename TType> void concurrent_vector<TType>::unlock()\n    {\n        std::unique_lock<std::recursive_mutex> scopedLock(m_mutex);\n        \n        m_isLocked = false;\n        m_lockCount--;\n        \n        if (m_lockCount == 0)\n        {\n            garbage_collect();\n            m_lock.unlock();\n        }\n    }\n    //--------------------------------------------------------------------\n    //--------------------------------------------------------------------\n    template <typename TType> typename concurrent_vector<TType>::size_type concurrent_vector<TType>::size() const\n    {\n        return m_size;\n    }\n    //--------------------------------------------------------------------\n    //--------------------------------------------------------------------\n    template <typename TType> bool concurrent_vector<TType>::empty() const\n    {\n        return m_size == 0;\n    }\n    //--------------------------------------------------------------------\n    //--------------------------------------------------------------------\n    template <typename TType> typename concurrent_vector<TType>::iterator concurrent_vector<TType>::begin()\n    {\n        return iterator(&m_container, &m_mutex);\n    }\n    //--------------------------------------------------------------------\n    //--------------------------------------------------------------------\n    template <typename TType> typename concurrent_vector<TType>::iterator concurrent_vector<TType>::end()\n    {\n        return iterator(&m_container, &m_mutex) + size();\n    }\n    //--------------------------------------------------------------------\n    //--------------------------------------------------------------------\n    template <typename TType> typename concurrent_vector<TType>::const_iterator concurrent_vector<TType>::begin() const\n    {\n        return const_iterator(&m_container, const_cast<std::recursive_mutex*>(&m_mutex));\n    }\n    //--------------------------------------------------------------------\n    //--------------------------------------------------------------------\n    template <typename TType> typename concurrent_vector<TType>::const_iterator concurrent_vector<TType>::end() const\n    {\n        return const_iterator(&m_container, const_cast<std::recursive_mutex*>(&m_mutex)) + size();\n    }\n    //--------------------------------------------------------------------\n    //--------------------------------------------------------------------\n    template <typename TType> typename concurrent_vector<TType>::const_iterator concurrent_vector<TType>::cbegin() const\n    {\n        return const_iterator(&m_container, const_cast<std::recursive_mutex*>(&m_mutex));\n    }\n    //--------------------------------------------------------------------\n    //--------------------------------------------------------------------\n    template <typename TType> typename concurrent_vector<TType>::const_iterator concurrent_vector<TType>::cend() const\n    {\n        return const_iterator(&m_container, const_cast<std::recursive_mutex*>(&m_mutex)) + size();\n    }\n    //--------------------------------------------------------------------\n    //--------------------------------------------------------------------\n    template <typename TType> typename concurrent_vector<TType>::reverse_iterator concurrent_vector<TType>::rbegin()\n    {\n        return reverse_iterator(&m_container, &m_mutex);\n    }\n    //--------------------------------------------------------------------\n    //--------------------------------------------------------------------\n    template <typename TType> typename concurrent_vector<TType>::reverse_iterator concurrent_vector<TType>::rend()\n    {\n        return reverse_iterator(&m_container, &m_mutex) + size();\n    }\n    //--------------------------------------------------------------------\n    //--------------------------------------------------------------------\n    template <typename TType> typename concurrent_vector<TType>::const_reverse_iterator concurrent_vector<TType>::rbegin() const\n    {\n        return const_reverse_iterator(&m_container, const_cast<std::recursive_mutex*>(&m_mutex));\n    }\n    //--------------------------------------------------------------------\n    //--------------------------------------------------------------------\n    template <typename TType> typename concurrent_vector<TType>::const_reverse_iterator concurrent_vector<TType>::rend() const\n    {\n        return const_reverse_iterator(&m_container, const_cast<std::recursive_mutex*>(&m_mutex)) + size();\n    }\n    //--------------------------------------------------------------------\n    //--------------------------------------------------------------------\n    template <typename TType> typename concurrent_vector<TType>::const_reverse_iterator concurrent_vector<TType>::crbegin() const\n    {\n        return const_reverse_iterator(&m_container, const_cast<std::recursive_mutex*>(&m_mutex));\n    }\n    //--------------------------------------------------------------------\n    //--------------------------------------------------------------------\n    template <typename TType> typename concurrent_vector<TType>::const_reverse_iterator concurrent_vector<TType>::crend() const\n    {\n        return const_reverse_iterator(&m_container, const_cast<std::recursive_mutex*>(&m_mutex)) + size();\n    }\n    //--------------------------------------------------------------------\n    //--------------------------------------------------------------------\n    template <typename TType> TType& concurrent_vector<TType>::operator[](size_type in_index)\n    {\n        return at(in_index);\n    }\n    //--------------------------------------------------------------------\n    //--------------------------------------------------------------------\n    template <typename TType> const TType& concurrent_vector<TType>::operator[](size_type in_index) const\n    {\n        return at(in_index);\n    }\n    //--------------------------------------------------------------------\n    //--------------------------------------------------------------------\n    template <typename TType> concurrent_vector_forward_iterator<TType>  concurrent_vector<TType>::erase(const concurrent_vector_forward_iterator<TType>& in_itErase)\n    {\n        std::unique_lock<std::recursive_mutex> scopedLock(m_mutex);\n        if(m_isLocked == false)\n        {\n            m_container.erase(m_container.begin() + in_itErase.get_index());\n        }\n        else\n        {\n            m_container[in_itErase.get_index()].second = true;\n            m_requiresGC = true;\n        }\n        \n        m_size--;\n        \n        auto itCopy = in_itErase;\n        ++itCopy;\n        return itCopy;\n    }\n    //--------------------------------------------------------------------\n    /// This uses the \n    //--------------------------------------------------------------------\n    template <typename TType> concurrent_vector_reverse_iterator<TType> concurrent_vector<TType>::erase(const concurrent_vector_reverse_iterator<TType>& in_itErase)\n    {\n        std::unique_lock<std::recursive_mutex> scopedLock(m_mutex);\n        if(m_isLocked == false)\n        {\n            m_container.erase(m_container.begin() + in_itErase.get_index());\n        }\n        else\n        {\n            m_container[in_itErase.get_index()].second = true;\n            m_requiresGC = true;\n        }\n        \n        m_size--;\n        \n        auto itCopy = in_itErase;\n        ++itCopy;\n        return itCopy;\n    }\n    //--------------------------------------------------------------------\n    //--------------------------------------------------------------------\n    template <typename TType> void concurrent_vector<TType>::clear()\n    {\n        std::unique_lock<std::recursive_mutex> scopedLock(m_mutex);\n        if(m_isLocked == false)\n        {\n            m_container.clear();\n            \n        }\n        else\n        {\n            for(auto& object : m_container)\n            {\n                object.second = true;\n            }\n            \n            m_requiresGC = true;\n        }\n        \n        m_size = 0;\n    }\n    //--------------------------------------------------------------------\n    //--------------------------------------------------------------------\n    template <typename TType> void concurrent_vector<TType>::garbage_collect()\n    {\n        for(auto it = m_container.begin(); it != m_container.end(); )\n        {\n            if(it->second == true)\n            {\n                it = m_container.erase(it);\n            }\n            else\n            {\n                ++it;\n            }\n        }\n        \n        m_requiresGC = false;\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Container/concurrent_vector_const_forward_iterator.h",
    "content": "//\n//  concurrent_vector_const_forward_iterator.h\n//  ChilliSource\n//  Created by Scott Downie on 19/09/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_CONTAINER_CONCURRENTVECTORCONSTFORWARDITERATOR_H_\n#define _CHILLISOURCE_CORE_CONTAINER_CONCURRENTVECTORCONSTFORWARDITERATOR_H_\n\n#include <mutex>\n#include <vector>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------\n    /// Forward iterator for the concurrent vector class that is read only\n    ///\n    /// @author S Downie\n    //------------------------------------------------------------------------\n    template <typename TType> class concurrent_vector_const_forward_iterator\n    {\n    public:\n        \n        using difference_type = typename std::iterator<std::forward_iterator_tag, TType>::difference_type;\n        \n        //------------------------------------------------------------------------\n        /// Constructor\n        ///\n        /// @author S Downie\n        ///\n        /// @param Data structure to iterate over\n        /// @param Mutex used to protect the underlying iterable\n        //------------------------------------------------------------------------\n        concurrent_vector_const_forward_iterator(const std::vector<std::pair<TType, bool>>* in_iterable, std::recursive_mutex* in_iterableMutex)\n        : m_iterable(in_iterable), m_iterableMutex(in_iterableMutex)\n        {\n            m_iterableIndex = find_next_occupied_index(0);\n        }\n        //--------------------------------------------------------------------\n        /// Copy constructor that creates this as a copy of the given iterator\n        ///\n        /// @author S Downie\n        ///\n        /// @param iterator to copy\n        //--------------------------------------------------------------------\n        concurrent_vector_const_forward_iterator(const concurrent_vector_const_forward_iterator& in_toCopy)\n        : m_iterableIndex(in_toCopy.m_iterableIndex), m_iterable(in_toCopy.m_iterable), m_iterableMutex(in_toCopy.m_iterableMutex)\n        {\n        }\n        //--------------------------------------------------------------------\n        /// Copy assignment that creates this as a copy of the given iterator\n        ///\n        /// @author S Downie\n        ///\n        /// @param iterator to copy\n        ///\n        /// @return This as a copy\n        //--------------------------------------------------------------------\n        concurrent_vector_const_forward_iterator& operator=(const concurrent_vector_const_forward_iterator& in_toCopy)\n        {\n            m_iterableIndex = in_toCopy.m_iterableIndex;\n            m_iterable = in_toCopy.m_iterable;\n            m_iterableMutex = in_toCopy.m_iterableMutex;\n            \n            return *this;\n        }\n        //--------------------------------------------------------------------\n        /// Move constructor that transfers ownership from the given iterator\n        ///\n        /// @author S Downie\n        ///\n        /// @param iterator to move\n        //--------------------------------------------------------------------\n        concurrent_vector_const_forward_iterator(concurrent_vector_const_forward_iterator&& in_toMove)\n        : m_iterableIndex(in_toMove.m_iterableIndex), m_iterable(in_toMove.m_iterable), m_iterableMutex(in_toMove.m_iterableMutex)\n        {\n            in_toMove.m_iterableIndex = 0;\n            in_toMove.m_iterable = nullptr;\n            in_toMove.m_iterableMutex = nullptr;\n        }\n        //--------------------------------------------------------------------\n        /// Move assignment that transfers ownership from the given iterator\n        ///\n        /// @author S Downie\n        ///\n        /// @param iterator to move\n        ///\n        /// @return This having taken ownership of the given iterator\n        //--------------------------------------------------------------------\n        concurrent_vector_const_forward_iterator& operator=(concurrent_vector_const_forward_iterator&& in_toMove)\n        {\n            m_iterableIndex = in_toMove.m_iterableIndex;\n            in_toMove.m_iterableIndex = 0;\n            m_iterable = in_toMove.m_iterable;\n            in_toMove.m_iterable = nullptr;\n            m_iterableMutex = in_toMove.m_iterableMutex;\n            in_toMove.m_iterableMutex = nullptr;\n            \n            return *this;\n        }\n        //------------------------------------------------------------------------\n        /// Moves the iterator to point to the next element in the vector\n        ///\n        /// @author S Downie\n        ///\n        /// @return Updated iterator\n        //------------------------------------------------------------------------\n        concurrent_vector_const_forward_iterator& operator++()\n        {\n            m_iterableIndex = find_next_occupied_index(m_iterableIndex + 1);\n            return *this;\n        }\n        //------------------------------------------------------------------------\n        /// Moves the iterator to point to the element in the vector at the given\n        /// offset from the current iterator\n        ///\n        /// @author S Downie\n        ///\n        /// @param Offset\n        ///\n        /// @return Updated iterator\n        //------------------------------------------------------------------------\n        concurrent_vector_const_forward_iterator& operator+=(difference_type in_stride)\n        {\n            m_iterableIndex = find_next_occupied_index(m_iterableIndex + in_stride);\n            return *this;\n        }\n        //------------------------------------------------------------------------\n        /// Create an iterator that points to the element at the given offset from\n        /// this iterator\n        ///\n        /// @author S Downie\n        ///\n        /// @param Offset\n        ///\n        /// @return New iterator\n        //------------------------------------------------------------------------\n        concurrent_vector_const_forward_iterator operator+(difference_type in_stride)\n        {\n            auto iterableIndex = find_next_occupied_index(m_iterableIndex + in_stride);\n            return concurrent_vector_const_forward_iterator(m_iterable, m_iterableMutex, iterableIndex);\n        }\n        //------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Pointer to the object pointed to by the iterator\n        //------------------------------------------------------------------------\n        const TType* operator->() const\n        {\n            std::unique_lock<std::recursive_mutex> scopedLock(*m_iterableMutex);\n            return &((*m_iterable)[m_iterableIndex].first);\n        }\n        //------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return The object pointed to by the iterator\n        //------------------------------------------------------------------------\n        const TType& operator*() const\n        {\n            std::unique_lock<std::recursive_mutex> scopedLock(*m_iterableMutex);\n            return (*m_iterable)[m_iterableIndex].first;\n        }\n        //------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Iterator to compare with\n        ///\n        /// @return Whether the iterators are considered equal\n        //------------------------------------------------------------------------\n        bool operator==(const concurrent_vector_const_forward_iterator& in_toCompare) const\n        {\n            return m_iterableIndex == in_toCompare.m_iterableIndex;\n        }\n        //------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Iterator to compare with\n        ///\n        /// @return Whether the iterators are considered unequal\n        //------------------------------------------------------------------------\n        bool operator!=(const concurrent_vector_const_forward_iterator& in_toCompare) const\n        {\n            return m_iterableIndex != in_toCompare.m_iterableIndex;\n        }\n        //------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Iterator to compare with\n        ///\n        /// @return Whether this iterator points to an element after the given iterator\n        //------------------------------------------------------------------------\n        bool operator>(const concurrent_vector_const_forward_iterator& in_toCompare) const\n        {\n            return m_iterableIndex > in_toCompare.m_iterableIndex;\n        }\n        //------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Iterator to compare with\n        ///\n        /// @return Whether this iterator points to an element after or the same as the given iterator\n        //------------------------------------------------------------------------\n        bool operator>=(const concurrent_vector_const_forward_iterator& in_toCompare) const\n        {\n            return m_iterableIndex >= in_toCompare.m_iterableIndex;\n        }\n        //------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Iterator to compare with\n        ///\n        /// @return Whether this iterator points to an element before the given iterator\n        //------------------------------------------------------------------------\n        bool operator<(const concurrent_vector_const_forward_iterator& in_toCompare) const\n        {\n            return m_iterableIndex < in_toCompare.m_iterableIndex;\n        }\n        //------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Iterator to compare with\n        ///\n        /// @return Whether this iterator points to an element before or the same as the given iterator\n        //------------------------------------------------------------------------\n        bool operator<=(const concurrent_vector_const_forward_iterator& in_toCompare) const\n        {\n            return m_iterableIndex <= in_toCompare.m_iterableIndex;\n        }\n        //------------------------------------------------------------------------\n        /// NOTE: This is an internal method used to query the element index\n        /// pointed to by the iterator\n        ///\n        /// @author S Downie\n        ///\n        /// @param Element index that the iterate currently points to\n        //------------------------------------------------------------------------\n        difference_type get_index() const\n        {\n            return m_iterableIndex;\n        }\n        \n    private:\n        //------------------------------------------------------------------------\n        /// Constructor\n        ///\n        /// @author S Downie\n        ///\n        /// @param Data structure to iterate over\n        /// @param Mutex used to protect the underlying iterable\n        /// @param Initial index\n        //------------------------------------------------------------------------\n        concurrent_vector_const_forward_iterator(const std::vector<std::pair<TType, bool>>* in_iterable, std::recursive_mutex* in_iterableMutex, difference_type in_initialIndex)\n        : m_iterable(in_iterable), m_iterableMutex(in_iterableMutex), m_iterableIndex(in_initialIndex)\n        {\n            \n        }\n        //------------------------------------------------------------------------\n        /// Find the next element index (inclusive of given index) that is not\n        /// flagged for removal\n        ///\n        /// @author S Downie\n        ///\n        /// @param Index to begin at (inclusive)\n        ///\n        /// @return Index of next element (or end if none)\n        //------------------------------------------------------------------------\n        difference_type find_next_occupied_index(difference_type in_beginIndex) const\n        {\n            std::unique_lock<std::recursive_mutex> scopedLock(*m_iterableMutex);\n            auto size = m_iterable->size();\n            \n            for(std::size_t i = in_beginIndex; i < size; ++i)\n            {\n                if((*m_iterable)[i].second == false)\n                {\n                    return i;\n                }\n            }\n            \n            return size;\n        }\n        \n    private:\n        \n        difference_type m_iterableIndex = 0;\n        const std::vector<std::pair<TType, bool>>* m_iterable;\n        std::recursive_mutex* m_iterableMutex;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Container/concurrent_vector_const_reverse_iterator.h",
    "content": "//\n//  concurrent_vector_const_reverse_iterator.h\n//  ChilliSource\n//  Created by Scott Downie on 19/09/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_CONTAINER_CONCURRENTVECTORCONSTREVERSEITERATOR_H_\n#define _CHILLISOURCE_CORE_CONTAINER_CONCURRENTVECTORCONSTREVERSEITERATOR_H_\n\n#include <vector>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------\n    /// Reverse iterator for the concurrent vector class.\n    ///\n    /// @author S Downie\n    //------------------------------------------------------------------------\n    template <typename TType> class concurrent_vector_const_reverse_iterator\n    {\n    public:\n        \n        using difference_type = typename std::iterator<std::forward_iterator_tag, TType>::difference_type;\n        \n        //------------------------------------------------------------------------\n        /// Constructor\n        ///\n        /// @author S Downie\n        ///\n        /// @param Data structure to iterate over\n        /// @param Mutex used to protect the underlying iterable\n        //------------------------------------------------------------------------\n        concurrent_vector_const_reverse_iterator(const std::vector<std::pair<TType, bool>>* in_iterable, std::recursive_mutex* in_iterableMutex)\n        : m_iterable(in_iterable), m_iterableMutex(in_iterableMutex)\n        {\n            m_iterableIndex = find_previous_occupied_index(m_iterable->size());\n        }\n        //--------------------------------------------------------------------\n        /// Copy constructor that creates this as a copy of the given iterator\n        ///\n        /// @author S Downie\n        ///\n        /// @param iterator to copy\n        //--------------------------------------------------------------------\n        concurrent_vector_const_reverse_iterator(const concurrent_vector_const_reverse_iterator& in_toCopy)\n        : m_iterableIndex(in_toCopy.m_iterableIndex), m_iterable(in_toCopy.m_iterable), m_iterableMutex(in_toCopy.m_iterableMutex)\n        {\n        }\n        //--------------------------------------------------------------------\n        /// Copy assignment that creates this as a copy of the given iterator\n        ///\n        /// @author S Downie\n        ///\n        /// @param iterator to copy\n        ///\n        /// @return This as a copy\n        //--------------------------------------------------------------------\n        concurrent_vector_const_reverse_iterator& operator=(const concurrent_vector_const_reverse_iterator& in_toCopy)\n        {\n            m_iterableIndex = in_toCopy.m_iterableIndex;\n            m_iterable = in_toCopy.m_iterable;\n            m_iterableMutex = in_toCopy.m_iterableMutex;\n            \n            return *this;\n        }\n        //--------------------------------------------------------------------\n        /// Move constructor that transfers ownership from the given iterator\n        ///\n        /// @author S Downie\n        ///\n        /// @param iterator to move\n        //--------------------------------------------------------------------\n        concurrent_vector_const_reverse_iterator(concurrent_vector_const_reverse_iterator&& in_toMove)\n        : m_iterableIndex(in_toMove.m_iterableIndex), m_iterable(in_toMove.m_iterable), m_iterableMutex(in_toMove.m_iterableMutex)\n        {\n            in_toMove.m_iterableIndex = 0;\n            in_toMove.m_iterable = nullptr;\n            in_toMove.m_iterableMutex = nullptr;\n        }\n        //--------------------------------------------------------------------\n        /// Move assignment that transfers ownership from the given iterator\n        ///\n        /// @author S Downie\n        ///\n        /// @param iterator to move\n        ///\n        /// @return This having taken ownership of the given iterator\n        //--------------------------------------------------------------------\n        concurrent_vector_const_reverse_iterator& operator=(concurrent_vector_const_reverse_iterator&& in_toMove)\n        {\n            m_iterableIndex = in_toMove.m_iterableIndex;\n            in_toMove.m_iterableIndex = 0;\n            m_iterable = in_toMove.m_iterable;\n            in_toMove.m_iterable = nullptr;\n            m_iterableMutex = in_toMove.m_iterableMutex;\n            in_toMove.m_iterableMutex = nullptr;\n            \n            return *this;\n        }\n        //------------------------------------------------------------------------\n        /// Moves the iterator to point to the previous element in the vector\n        ///\n        /// @author S Downie\n        ///\n        /// @return Updated iterator\n        //------------------------------------------------------------------------\n        concurrent_vector_const_reverse_iterator& operator++()\n        {\n            m_iterableIndex = find_previous_occupied_index(m_iterableIndex);\n            return *this;\n        }\n        //------------------------------------------------------------------------\n        /// Moves the iterator to point to the element in the vector at the given\n        /// negative offset from the current iterator\n        ///\n        /// @author S Downie\n        ///\n        /// @param Offset\n        ///\n        /// @return Updated iterator\n        //------------------------------------------------------------------------\n        concurrent_vector_const_reverse_iterator& operator+=(difference_type in_stride)\n        {\n            m_iterableIndex = find_previous_occupied_index(m_iterableIndex - (in_stride - 1));\n            return *this;\n        }\n        //------------------------------------------------------------------------\n        /// Create an iterator that points to the element at the given offset from\n        /// this iterator\n        ///\n        /// @author S Downie\n        ///\n        /// @param Offset\n        ///\n        /// @return New iterator\n        //------------------------------------------------------------------------\n        concurrent_vector_const_reverse_iterator operator+(difference_type in_stride)\n        {\n            auto iterableIndex = find_previous_occupied_index(m_iterableIndex - (in_stride - 1));\n            return concurrent_vector_const_reverse_iterator(m_iterable, m_iterableMutex, iterableIndex);\n        }\n        //------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Pointer to the object pointed to by the iterator\n        //------------------------------------------------------------------------\n        const TType* operator->() const\n        {\n            std::unique_lock<std::recursive_mutex> scopedLock(*m_iterableMutex);\n            return &((*m_iterable)[m_iterableIndex].first);\n        }\n        //------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return The object pointed to by the iterator\n        //------------------------------------------------------------------------\n        const TType& operator*() const\n        {\n            std::unique_lock<std::recursive_mutex> scopedLock(*m_iterableMutex);\n            return (*m_iterable)[m_iterableIndex].first;\n        }\n        //------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Iterator to compare with\n        ///\n        /// @return Whether the iterators are considered equal\n        //------------------------------------------------------------------------\n        bool operator==(const concurrent_vector_const_reverse_iterator& in_toCompare) const\n        {\n            return m_iterableIndex == in_toCompare.m_iterableIndex;\n        }\n        //------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Iterator to compare with\n        ///\n        /// @return Whether the iterators are considered unequal\n        //------------------------------------------------------------------------\n        bool operator!=(const concurrent_vector_const_reverse_iterator& in_toCompare) const\n        {\n            return m_iterableIndex != in_toCompare.m_iterableIndex;\n        }\n        //------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Iterator to compare with\n        ///\n        /// @return Whether this iterator points to an element after the given iterator\n        //------------------------------------------------------------------------\n        bool operator>(const concurrent_vector_const_reverse_iterator& in_toCompare) const\n        {\n            return m_iterableIndex > in_toCompare.m_iterableIndex;\n        }\n        //------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Iterator to compare with\n        ///\n        /// @return Whether this iterator points to an element after or the same as the given iterator\n        //------------------------------------------------------------------------\n        bool operator>=(const concurrent_vector_const_reverse_iterator& in_toCompare) const\n        {\n            return m_iterableIndex >= in_toCompare.m_iterableIndex;\n        }\n        //------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Iterator to compare with\n        ///\n        /// @return Whether this iterator points to an element before the given iterator\n        //------------------------------------------------------------------------\n        bool operator<(const concurrent_vector_const_reverse_iterator& in_toCompare) const\n        {\n            return m_iterableIndex < in_toCompare.m_iterableIndex;\n        }\n        //------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Iterator to compare with\n        ///\n        /// @return Whether this iterator points to an element before or the same as the given iterator\n        //------------------------------------------------------------------------\n        bool operator<=(const concurrent_vector_const_reverse_iterator& in_toCompare) const\n        {\n            return m_iterableIndex <= in_toCompare.m_iterableIndex;\n        }\n        //------------------------------------------------------------------------\n        /// NOTE: This is an internal method used to query the element index\n        /// pointed to by the iterator\n        ///\n        /// @author S Downie\n        ///\n        /// @param Element index that the iterate currently points to\n        //------------------------------------------------------------------------\n        difference_type get_index() const\n        {\n            return m_iterableIndex;\n        }\n        \n    private:\n        //------------------------------------------------------------------------\n        /// Constructor\n        ///\n        /// @author S Downie\n        ///\n        /// @param Data structure to iterate over\n        /// @param Mutex used to protect the underlying iterable\n        /// @param Initial index\n        //------------------------------------------------------------------------\n        concurrent_vector_const_reverse_iterator(const std::vector<std::pair<TType, bool>>* in_iterable, std::recursive_mutex* in_iterableMutex, difference_type in_initialIndex)\n        : m_iterable(in_iterable), m_iterableMutex(in_iterableMutex), m_iterableIndex(in_initialIndex)\n        {\n\n        }\n        //------------------------------------------------------------------------\n        /// Find the previous element index (exclusive of given index) that is not\n        /// flagged for removal\n        ///\n        /// @author S Downie\n        ///\n        /// @param Index to begin at (exclusive)\n        ///\n        /// @return Index of previous element (or start if none)\n        //-----------------------------------------------------------------------\n        difference_type find_previous_occupied_index(difference_type in_beginIndex) const\n        {\n            if(in_beginIndex == 0)\n            {\n                return -1;\n            }\n            \n            in_beginIndex--;\n            \n            std::unique_lock<std::recursive_mutex> scopedLock(*m_iterableMutex);\n            for(auto i=in_beginIndex; i>=0; --i)\n            {\n                if((*m_iterable)[i].second == false)\n                {\n                    return i;\n                }\n            }\n            \n            return -1;\n        }\n        \n    private:\n        \n        difference_type m_iterableIndex = 0;\n        const std::vector<std::pair<TType, bool>>* m_iterable;\n        std::recursive_mutex* m_iterableMutex;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Container/concurrent_vector_forward_iterator.h",
    "content": "//\n//  concurrent_vector_forward_iterator.h\n//  ChilliSource\n//  Created by Scott Downie on 19/09/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_CONTAINER_CONCURRENTVECTORFORWARDITERATOR_H_\n#define _CHILLISOURCE_CORE_CONTAINER_CONCURRENTVECTORFORWARDITERATOR_H_\n\n#include <vector>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------\n    /// Forward iterator for the concurrent vector class.\n    ///\n    /// @author S Downie\n    //------------------------------------------------------------------------\n    template <typename TType> class concurrent_vector_forward_iterator\n    {\n    public:\n        \n        using difference_type = typename std::iterator<std::forward_iterator_tag, TType>::difference_type;\n        \n        //------------------------------------------------------------------------\n        /// Constructor\n        ///\n        /// @author S Downie\n        ///\n        /// @param Data structure to iterate over\n        /// @param Mutex used to protect the underlying iterable\n        //------------------------------------------------------------------------\n        concurrent_vector_forward_iterator(std::vector<std::pair<TType, bool>>* in_iterable, std::recursive_mutex* in_iterableMutex)\n        : m_iterable(in_iterable), m_iterableMutex(in_iterableMutex)\n        {\n            m_iterableIndex = find_next_occupied_index(0);\n        }\n        //--------------------------------------------------------------------\n        /// Copy constructor that creates this as a copy of the given iterator\n        ///\n        /// @author S Downie\n        ///\n        /// @param iterator to copy\n        //--------------------------------------------------------------------\n        concurrent_vector_forward_iterator(const concurrent_vector_forward_iterator& in_toCopy)\n        : m_iterableIndex(in_toCopy.m_iterableIndex), m_iterable(in_toCopy.m_iterable), m_iterableMutex(in_toCopy.m_iterableMutex)\n        {\n        }\n        //--------------------------------------------------------------------\n        /// Copy assignment that creates this as a copy of the given iterator\n        ///\n        /// @author S Downie\n        ///\n        /// @param iterator to copy\n        ///\n        /// @return This as a copy\n        //--------------------------------------------------------------------\n        concurrent_vector_forward_iterator& operator=(const concurrent_vector_forward_iterator& in_toCopy)\n        {\n            m_iterableIndex = in_toCopy.m_iterableIndex;\n            m_iterable = in_toCopy.m_iterable;\n            m_iterableMutex = in_toCopy.m_iterableMutex;\n            \n            return *this;\n        }\n        //--------------------------------------------------------------------\n        /// Move constructor that transfers ownership from the given iterator\n        ///\n        /// @author S Downie\n        ///\n        /// @param iterator to move\n        //--------------------------------------------------------------------\n        concurrent_vector_forward_iterator(concurrent_vector_forward_iterator&& in_toMove)\n        : m_iterableIndex(in_toMove.m_iterableIndex), m_iterable(in_toMove.m_iterable), m_iterableMutex(in_toMove.m_iterableMutex)\n        {\n            in_toMove.m_iterableIndex = 0;\n            in_toMove.m_iterable = nullptr;\n            in_toMove.m_iterableMutex = nullptr;\n        }\n        //--------------------------------------------------------------------\n        /// Move assignment that transfers ownership from the given iterator\n        ///\n        /// @author S Downie\n        ///\n        /// @param iterator to move\n        ///\n        /// @return This having taken ownership of the given iterator\n        //--------------------------------------------------------------------\n        concurrent_vector_forward_iterator& operator=(concurrent_vector_forward_iterator&& in_toMove)\n        {\n            m_iterableIndex = in_toMove.m_iterableIndex;\n            in_toMove.m_iterableIndex = 0;\n            m_iterable = in_toMove.m_iterable;\n            in_toMove.m_iterable = nullptr;\n            m_iterableMutex = in_toMove.m_iterableMutex;\n            in_toMove.m_iterableMutex = nullptr;\n            \n            return *this;\n        }\n        //------------------------------------------------------------------------\n        /// Moves the iterator to point to the next element in the vector\n        ///\n        /// @author S Downie\n        ///\n        /// @return Updated iterator\n        //------------------------------------------------------------------------\n        concurrent_vector_forward_iterator& operator++()\n        {\n            m_iterableIndex = find_next_occupied_index(m_iterableIndex + 1);\n            return *this;\n        }\n        //------------------------------------------------------------------------\n        /// Moves the iterator to point to the element in the vector at the given\n        /// offset from the current iterator\n        ///\n        /// @author S Downie\n        ///\n        /// @param Offset\n        ///\n        /// @return Updated iterator\n        //------------------------------------------------------------------------\n        concurrent_vector_forward_iterator& operator+=(difference_type in_stride)\n        {\n            m_iterableIndex = find_next_occupied_index(m_iterableIndex + in_stride);\n            return *this;\n        }\n        //------------------------------------------------------------------------\n        /// Create an iterator that points to the element at the given offset from\n        /// this iterator\n        ///\n        /// @author S Downie\n        ///\n        /// @param Offset\n        ///\n        /// @return New iterator\n        //------------------------------------------------------------------------\n        concurrent_vector_forward_iterator operator+(difference_type in_stride)\n        {\n            auto iterableIndex = find_next_occupied_index(m_iterableIndex + in_stride);\n            return concurrent_vector_forward_iterator(m_iterable, m_iterableMutex, iterableIndex);\n        }\n        //------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Pointer to the object pointed to by the iterator\n        //------------------------------------------------------------------------\n        TType* operator->()\n        {\n            std::unique_lock<std::recursive_mutex> scopedLock(*m_iterableMutex);\n            return &((*m_iterable)[m_iterableIndex].first);\n        }\n        //------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Pointer to the object pointed to by the iterator\n        //------------------------------------------------------------------------\n        const TType* operator->() const\n        {\n            std::unique_lock<std::recursive_mutex> scopedLock(*m_iterableMutex);\n            return &((*m_iterable)[m_iterableIndex].first);\n        }\n        //------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return The object pointed to by the iterator\n        //------------------------------------------------------------------------\n        TType& operator*()\n        {\n            std::unique_lock<std::recursive_mutex> scopedLock(*m_iterableMutex);\n            return (*m_iterable)[m_iterableIndex].first;\n        }\n        //------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return The object pointed to by the iterator\n        //------------------------------------------------------------------------\n        const TType& operator*() const\n        {\n            std::unique_lock<std::recursive_mutex> scopedLock(*m_iterableMutex);\n            return (*m_iterable)[m_iterableIndex].first;\n        }\n        //------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Iterator to compare with\n        ///\n        /// @return Whether the iterators are considered equal\n        //------------------------------------------------------------------------\n        bool operator==(const concurrent_vector_forward_iterator& in_toCompare) const\n        {\n            return m_iterableIndex == in_toCompare.m_iterableIndex;\n        }\n        //------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Iterator to compare with\n        ///\n        /// @return Whether the iterators are considered unequal\n        //------------------------------------------------------------------------\n        bool operator!=(const concurrent_vector_forward_iterator& in_toCompare) const\n        {\n            return m_iterableIndex != in_toCompare.m_iterableIndex;\n        }\n        //------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Iterator to compare with\n        ///\n        /// @return Whether this iterator points to an element after the given iterator\n        //------------------------------------------------------------------------\n        bool operator>(const concurrent_vector_forward_iterator& in_toCompare) const\n        {\n            return m_iterableIndex > in_toCompare.m_iterableIndex;\n        }\n        //------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Iterator to compare with\n        ///\n        /// @return Whether this iterator points to an element after or the same as the given iterator\n        //------------------------------------------------------------------------\n        bool operator>=(const concurrent_vector_forward_iterator& in_toCompare) const\n        {\n            return m_iterableIndex >= in_toCompare.m_iterableIndex;\n        }\n        //------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Iterator to compare with\n        ///\n        /// @return Whether this iterator points to an element before the given iterator\n        //------------------------------------------------------------------------\n        bool operator<(const concurrent_vector_forward_iterator& in_toCompare) const\n        {\n            return m_iterableIndex < in_toCompare.m_iterableIndex;\n        }\n        //------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Iterator to compare with\n        ///\n        /// @return Whether this iterator points to an element before or the same as the given iterator\n        //------------------------------------------------------------------------\n        bool operator<=(const concurrent_vector_forward_iterator& in_toCompare) const\n        {\n            return m_iterableIndex <= in_toCompare.m_iterableIndex;\n        }\n        //------------------------------------------------------------------------\n        /// NOTE: This is an internal method used to query the element index\n        /// pointed to by the iterator\n        ///\n        /// @author S Downie\n        ///\n        /// @param Element index that the iterate currently points to\n        //------------------------------------------------------------------------\n        difference_type get_index() const\n        {\n            return m_iterableIndex;\n        }\n        \n    private:\n        //------------------------------------------------------------------------\n        /// Constructor\n        ///\n        /// @author S Downie\n        ///\n        /// @param Data structure to iterate over\n        /// @param Mutex used to protect the underlying iterable\n        /// @param Initial index\n        //------------------------------------------------------------------------\n        concurrent_vector_forward_iterator(std::vector<std::pair<TType, bool>>* in_iterable, std::recursive_mutex* in_iterableMutex, difference_type in_initialIndex)\n        : m_iterable(in_iterable), m_iterableMutex(in_iterableMutex), m_iterableIndex(in_initialIndex)\n        {\n            \n        }\n        //------------------------------------------------------------------------\n        /// Find the next element index (inclusive of given index) that is not\n        /// flagged for removal\n        ///\n        /// @author S Downie\n        ///\n        /// @param Index to begin at (inclusive)\n        ///\n        /// @return Index of next element (or end if none)\n        //------------------------------------------------------------------------\n        difference_type find_next_occupied_index(difference_type in_beginIndex) const\n        {\n            std::unique_lock<std::recursive_mutex> scopedLock(*m_iterableMutex);\n            auto size = m_iterable->size();\n            \n            for(std::size_t i = in_beginIndex; i < size; ++i)\n            {\n                if((*m_iterable)[i].second == false)\n                {\n                    return i;\n                }\n            }\n            \n            return size;\n        }\n        \n    private:\n        \n        difference_type m_iterableIndex = 0;\n        std::vector<std::pair<TType, bool>>* m_iterable;\n        std::recursive_mutex* m_iterableMutex;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Container/concurrent_vector_reverse_iterator.h",
    "content": "//\n//  concurrent_vector_reverse_iterator.h\n//  ChilliSource\n//  Created by Scott Downie on 19/09/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_CONTAINER_CONCURRENTVECTORREVERSEITERATOR_H_\n#define _CHILLISOURCE_CORE_CONTAINER_CONCURRENTVECTORREVERSEITERATOR_H_\n\n#include <vector>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------\n    /// Reverse iterator for the concurrent vector class that is read only\n    ///\n    /// @author S Downie\n    //------------------------------------------------------------------------\n    template <typename TType> class concurrent_vector_reverse_iterator\n    {\n    public:\n        \n        using difference_type = typename std::iterator<std::forward_iterator_tag, TType>::difference_type;\n        \n        //------------------------------------------------------------------------\n        /// Constructor\n        ///\n        /// @author S Downie\n        ///\n        /// @param Data structure to iterate over\n        /// @param Mutex used to protect the underlying iterable\n        //------------------------------------------------------------------------\n        concurrent_vector_reverse_iterator(std::vector<std::pair<TType, bool>>* in_iterable, std::recursive_mutex* in_iterableMutex)\n        : m_iterable(in_iterable), m_iterableMutex(in_iterableMutex)\n        {\n            m_iterableIndex = find_previous_occupied_index(m_iterable->size());\n        }\n        //--------------------------------------------------------------------\n        /// Copy constructor that creates this as a copy of the given iterator\n        ///\n        /// @author S Downie\n        ///\n        /// @param iterator to copy\n        //--------------------------------------------------------------------\n        concurrent_vector_reverse_iterator(const concurrent_vector_reverse_iterator& in_toCopy)\n        : m_iterableIndex(in_toCopy.m_iterableIndex), m_iterable(in_toCopy.m_iterable), m_iterableMutex(in_toCopy.m_iterableMutex)\n        {\n        }\n        //--------------------------------------------------------------------\n        /// Copy assignment that creates this as a copy of the given iterator\n        ///\n        /// @author S Downie\n        ///\n        /// @param iterator to copy\n        ///\n        /// @return This as a copy\n        //--------------------------------------------------------------------\n        concurrent_vector_reverse_iterator& operator=(const concurrent_vector_reverse_iterator& in_toCopy)\n        {\n            m_iterableIndex = in_toCopy.m_iterableIndex;\n            m_iterable = in_toCopy.m_iterable;\n            m_iterableMutex = in_toCopy.m_iterableMutex;\n            \n            return *this;\n        }\n        //--------------------------------------------------------------------\n        /// Move constructor that transfers ownership from the given iterator\n        ///\n        /// @author S Downie\n        ///\n        /// @param iterator to move\n        //--------------------------------------------------------------------\n        concurrent_vector_reverse_iterator(concurrent_vector_reverse_iterator&& in_toMove)\n        : m_iterableIndex(in_toMove.m_iterableIndex), m_iterable(in_toMove.m_iterable), m_iterableMutex(in_toMove.m_iterableMutex)\n        {\n            in_toMove.m_iterableIndex = 0;\n            in_toMove.m_iterable = nullptr;\n            in_toMove.m_iterableMutex = nullptr;\n        }\n        //--------------------------------------------------------------------\n        /// Move assignment that transfers ownership from the given iterator\n        ///\n        /// @author S Downie\n        ///\n        /// @param iterator to move\n        ///\n        /// @return This having taken ownership of the given iterator\n        //--------------------------------------------------------------------\n        concurrent_vector_reverse_iterator& operator=(concurrent_vector_reverse_iterator&& in_toMove)\n        {\n            m_iterableIndex = in_toMove.m_iterableIndex;\n            in_toMove.m_iterableIndex = 0;\n            m_iterable = in_toMove.m_iterable;\n            in_toMove.m_iterable = nullptr;\n            m_iterableMutex = in_toMove.m_iterableMutex;\n            in_toMove.m_iterableMutex = nullptr;\n            \n            return *this;\n        }\n        //------------------------------------------------------------------------\n        /// Moves the iterator to point to the previous element in the vector\n        ///\n        /// @author S Downie\n        ///\n        /// @return Updated iterator\n        //------------------------------------------------------------------------\n        concurrent_vector_reverse_iterator& operator++()\n        {\n            m_iterableIndex = find_previous_occupied_index(m_iterableIndex);\n            return *this;\n        }\n        //------------------------------------------------------------------------\n        /// Moves the iterator to point to the element in the vector at the given\n        /// negative offset from the current iterator\n        ///\n        /// @author S Downie\n        ///\n        /// @param Offset\n        ///\n        /// @return Updated iterator\n        //------------------------------------------------------------------------\n        concurrent_vector_reverse_iterator& operator+=(difference_type in_stride)\n        {\n            m_iterableIndex = find_previous_occupied_index(m_iterableIndex - (in_stride - 1));\n            return *this;\n        }\n        //------------------------------------------------------------------------\n        /// Create an iterator that points to the element at the given offset from\n        /// this iterator\n        ///\n        /// @author S Downie\n        ///\n        /// @param Offset\n        ///\n        /// @return New iterator\n        //------------------------------------------------------------------------\n        concurrent_vector_reverse_iterator operator+(difference_type in_stride)\n        {\n            auto iterableIndex = find_previous_occupied_index(m_iterableIndex - (in_stride - 1));\n            return concurrent_vector_reverse_iterator(m_iterable, m_iterableMutex, iterableIndex);\n        }\n        //------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Pointer to the object pointed to by the iterator\n        //------------------------------------------------------------------------\n        const TType* operator->() const\n        {\n            std::unique_lock<std::recursive_mutex> scopedLock(*m_iterableMutex);\n            return &((*m_iterable)[m_iterableIndex].first);\n        }\n        //------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Pointer to the object pointed to by the iterator\n        //------------------------------------------------------------------------\n        TType* operator->()\n        {\n            std::unique_lock<std::recursive_mutex> scopedLock(*m_iterableMutex);\n            return &((*m_iterable)[m_iterableIndex].first);\n        }\n        //------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return The object pointed to by the iterator\n        //------------------------------------------------------------------------\n        const TType& operator*() const\n        {\n            std::unique_lock<std::recursive_mutex> scopedLock(*m_iterableMutex);\n            return (*m_iterable)[m_iterableIndex].first;\n        }\n        //------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return The object pointed to by the iterator\n        //------------------------------------------------------------------------\n        TType& operator*()\n        {\n            std::unique_lock<std::recursive_mutex> scopedLock(*m_iterableMutex);\n            return (*m_iterable)[m_iterableIndex].first;\n        }\n        //------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Iterator to compare with\n        ///\n        /// @return Whether the iterators are considered equal\n        //------------------------------------------------------------------------\n        bool operator==(const concurrent_vector_reverse_iterator& in_toCompare) const\n        {\n            return m_iterableIndex == in_toCompare.m_iterableIndex;\n        }\n        //------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Iterator to compare with\n        ///\n        /// @return Whether the iterators are considered unequal\n        //------------------------------------------------------------------------\n        bool operator!=(const concurrent_vector_reverse_iterator& in_toCompare) const\n        {\n            return m_iterableIndex != in_toCompare.m_iterableIndex;\n        }\n        //------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Iterator to compare with\n        ///\n        /// @return Whether this iterator points to an element after the given iterator\n        //------------------------------------------------------------------------\n        bool operator>(const concurrent_vector_reverse_iterator& in_toCompare) const\n        {\n            return m_iterableIndex > in_toCompare.m_iterableIndex;\n        }\n        //------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Iterator to compare with\n        ///\n        /// @return Whether this iterator points to an element after or the same as the given iterator\n        //------------------------------------------------------------------------\n        bool operator>=(const concurrent_vector_reverse_iterator& in_toCompare) const\n        {\n            return m_iterableIndex >= in_toCompare.m_iterableIndex;\n        }\n        //------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Iterator to compare with\n        ///\n        /// @return Whether this iterator points to an element before the given iterator\n        //------------------------------------------------------------------------\n        bool operator<(const concurrent_vector_reverse_iterator& in_toCompare) const\n        {\n            return m_iterableIndex < in_toCompare.m_iterableIndex;\n        }\n        //------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Iterator to compare with\n        ///\n        /// @return Whether this iterator points to an element before or the same as the given iterator\n        //------------------------------------------------------------------------\n        bool operator<=(const concurrent_vector_reverse_iterator& in_toCompare) const\n        {\n            return m_iterableIndex <= in_toCompare.m_iterableIndex;\n        }\n        //------------------------------------------------------------------------\n        /// NOTE: This is an internal method used to query the element index\n        /// pointed to by the iterator\n        ///\n        /// @author S Downie\n        ///\n        /// @param Element index that the iterate currently points to\n        //------------------------------------------------------------------------\n        difference_type get_index() const\n        {\n            return m_iterableIndex;\n        }\n        \n    private:\n        //------------------------------------------------------------------------\n        /// Constructor\n        ///\n        /// @author S Downie\n        ///\n        /// @param Data structure to iterate over\n        /// @param Mutex used to protect the underlying iterable\n        /// @param Initial index\n        //------------------------------------------------------------------------\n        concurrent_vector_reverse_iterator(std::vector<std::pair<TType, bool>>* in_iterable, std::recursive_mutex* in_iterableMutex, difference_type in_initialIndex)\n        : m_iterable(in_iterable), m_iterableMutex(in_iterableMutex), m_iterableIndex(in_initialIndex)\n        {\n\n        }\n        //------------------------------------------------------------------------\n        /// Find the previous element index (exclusive of given index) that is not\n        /// flagged for removal\n        ///\n        /// @author S Downie\n        ///\n        /// @param Index to begin at (exclusive)\n        ///\n        /// @return Index of previous element (or start if none)\n        //-----------------------------------------------------------------------\n        difference_type find_previous_occupied_index(difference_type in_beginIndex) const\n        {\n            if(in_beginIndex == 0)\n            {\n                return -1;\n            }\n            \n            in_beginIndex--;\n            \n            std::unique_lock<std::recursive_mutex> scopedLock(*m_iterableMutex);\n            for(auto i=in_beginIndex; i>=0; --i)\n            {\n                if((*m_iterable)[i].second == false)\n                {\n                    return i;\n                }\n            }\n            \n            return -1;\n        }\n        \n    private:\n        \n        difference_type m_iterableIndex = 0;\n        std::vector<std::pair<TType, bool>>* m_iterable;\n        std::recursive_mutex* m_iterableMutex;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Container/dynamic_array.h",
    "content": "//\n//  dynamic_array.h\n//  ChilliSource\n//  Created by Ian Copland on 20/10/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_CONTAINERS_DYNAMICARRAY_H_\n#define _CHILLISOURCE_CORE_CONTAINERS_DYNAMICARRAY_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Container/random_access_iterator.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    /// A fixed size array with a size that is decided at runtime. This is heavily\n    /// based on std::dynarray that was initially intended to be included in the \n    /// C++14 standard library. This will likely be removed if std::dynarray is \n    /// ever introduced as a standard part of the language.\n    /// \n    /// @author Ian Copland\n    //------------------------------------------------------------------------------\n    template <typename TType> class dynamic_array final\n    {\n    public:\n        \n        using value_type = TType;\n        using size_type = std::size_t;\n        using difference_type = std::ptrdiff_t;\n        using reference = value_type&;\n        using const_reference = const value_type&;\n        using pointer = value_type*;\n        using const_pointer = const value_type*;\n        using iterator = random_access_iterator<value_type>;\n        using const_iterator = random_access_iterator<const value_type>;\n        using reverse_iterator = std::reverse_iterator<iterator>;\n        using const_reverse_iterator = std::reverse_iterator<const_iterator>;\n        \n        //------------------------------------------------------------------------------\n        /// Constructor. Initialises the array with the given number of elements.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The size of the array.\n        //------------------------------------------------------------------------------\n        dynamic_array(size_type in_size);\n        //------------------------------------------------------------------------------\n        /// Move constructor.\n        ///\n        /// @author Nicolas Tanda\n        ///\n        /// @param in_dynamicArray - The dynamic array to move\n        //------------------------------------------------------------------------------\n        dynamic_array(dynamic_array<TType>&& in_dynamicArray);\n        //------------------------------------------------------------------------------\n        /// Move assignment.\n        ///\n        /// @author Nicolas Tanda\n        ///\n        /// @param in_dynamicArray - The dynamic array to move\n        //------------------------------------------------------------------------------\n        dynamic_array<TType>& operator=(dynamic_array<TType>&& in_dynamicArray);\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param The size of the array.\n        //------------------------------------------------------------------------------\n        size_type size() const;\n        //------------------------------------------------------------------------------\n        /// Sets all elements in the array to the given value.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The value to set.\n        //------------------------------------------------------------------------------\n        void fill(const_reference in_value);\n        //------------------------------------------------------------------------------\n        /// Returns a reference to the object at the given index in the array.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The index.\n        ///\n        /// @param The reference.\n        //------------------------------------------------------------------------------\n        reference at(size_type in_index);\n        //------------------------------------------------------------------------------\n        /// Returns a const reference to the object at the given index in the array.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The index.\n        ///\n        /// @param The const reference.\n        //------------------------------------------------------------------------------\n        const_reference at(size_type in_index) const;\n        //------------------------------------------------------------------------------\n        /// Returns a reference to the object at the given index in the array.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The index.\n        ///\n        /// @param The reference.\n        //------------------------------------------------------------------------------\n        reference operator[](size_type in_index);\n        //------------------------------------------------------------------------------\n        /// Returns a const reference to the object at the given index in the array.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The const reference.\n        //------------------------------------------------------------------------------\n        const_reference operator[](size_type in_index) const;\n        //------------------------------------------------------------------------------\n        /// Returns a pointer to the start of the array.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The pointer to the start of the array.\n        //------------------------------------------------------------------------------\n        pointer data();\n        //------------------------------------------------------------------------------\n        /// Returns a const pointer to the start of the array.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The const pointer to the start of the array.\n        //------------------------------------------------------------------------------\n        const_pointer data() const;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The element at the front of the array.\n        //------------------------------------------------------------------------------\n        reference front();\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return A const version of the element at the front of the array.\n        //------------------------------------------------------------------------------\n        const_reference front() const;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The element at the back of the array.\n        //------------------------------------------------------------------------------\n        reference back();\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return A const version of the element at the back of the array.\n        //------------------------------------------------------------------------------\n        const_reference back() const;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return An iterator at the beginning of the array.\n        //------------------------------------------------------------------------------\n        iterator begin();\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return A const iterator at the beginning of the array.\n        //------------------------------------------------------------------------------\n        const_iterator begin() const;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return A const iterator at the beginning of the array.\n        //------------------------------------------------------------------------------\n        const_iterator cbegin() const;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return An iterator at the end of the array.\n        //------------------------------------------------------------------------------\n        iterator end();\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return A const iterator at the end of the array.\n        //------------------------------------------------------------------------------\n        const_iterator end() const;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return A const iterator at the end of the array.\n        //------------------------------------------------------------------------------\n        const_iterator cend() const;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return A reverse iterator at the beginning of the array.\n        //------------------------------------------------------------------------------\n        reverse_iterator rbegin();\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return A const reverse iterator at the beginning of the array.\n        //------------------------------------------------------------------------------\n        const_reverse_iterator rbegin() const;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return A const reverse iterator at the beginning of the array.\n        //------------------------------------------------------------------------------\n        const_reverse_iterator crbegin() const;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return A reverse iterator at the end of the array.\n        //------------------------------------------------------------------------------\n        reverse_iterator rend();\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return A const reverse iterator at the end of the array.\n        //------------------------------------------------------------------------------\n        const_reverse_iterator rend() const;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return A const reverse iterator at the end of the array.\n        //------------------------------------------------------------------------------\n        const_reverse_iterator crend() const;\n    private:\n        size_type m_size;\n        std::unique_ptr<value_type[]> m_array;\n    };\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    template <typename TType> dynamic_array<TType>::dynamic_array(size_type in_size)\n        : m_size(in_size)\n    {\n        if(in_size > 0)\n        {\n            m_array = std::unique_ptr<TType[]>(new TType[in_size]);\n        }\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    template <typename TType> dynamic_array<TType>::dynamic_array(dynamic_array<TType>&& in_dynamicArray)\n    {\n        m_array = std::move(in_dynamicArray.m_array);\n        \n        m_size = in_dynamicArray.m_size;\n        in_dynamicArray.m_size = 0;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    template <typename TType> dynamic_array<TType>& dynamic_array<TType>::operator=(dynamic_array<TType>&& in_dynamicArray)\n    {\n        m_array = std::move(in_dynamicArray.m_array);\n        \n        m_size = in_dynamicArray.m_size;\n        in_dynamicArray.m_size = 0;\n        \n        return *this;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    template <typename TType> typename dynamic_array<TType>::size_type dynamic_array<TType>::size() const\n    {\n        return m_size;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    template <typename TType> void dynamic_array<TType>::fill(const_reference in_value)\n    {\n        for (auto& val : *this)\n        {\n            val = in_value;\n        }\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    template <typename TType> typename dynamic_array<TType>::reference dynamic_array<TType>::at(size_type in_index)\n    {\n        CS_ASSERT(in_index >= 0, \"Index into a dynamic_array cannot be below zero.\");\n        CS_ASSERT(in_index < m_size, \"Index into a dynamic_array cannot be beyond the length of the array.\");\n\n        return m_array[in_index];\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    template <typename TType> typename dynamic_array<TType>::const_reference dynamic_array<TType>::at(size_type in_index) const\n    {\n        CS_ASSERT(in_index >= 0, \"Index into a dynamic_array cannot be below zero.\");\n        CS_ASSERT(in_index < m_size, \"Index into a dynamic_array cannot be beyond the length of the array.\");\n\n        return m_array[in_index];\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    template <typename TType> typename dynamic_array<TType>::reference dynamic_array<TType>::operator[](size_type in_index)\n    {\n        return at(in_index);\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    template <typename TType> typename dynamic_array<TType>::const_reference dynamic_array<TType>::operator[](size_type in_index) const\n    {\n        return at(in_index);\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    template <typename TType> typename dynamic_array<TType>::pointer dynamic_array<TType>::data()\n    {\n        return m_array.get();\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    template <typename TType> typename dynamic_array<TType>::const_pointer dynamic_array<TType>::data() const\n    {\n        return m_array.get();\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    template <typename TType> typename dynamic_array<TType>::reference dynamic_array<TType>::front()\n    {\n        return at(0);\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    template <typename TType> typename dynamic_array<TType>::const_reference dynamic_array<TType>::front() const\n    {\n        return at(0);\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    template <typename TType> typename dynamic_array<TType>::reference dynamic_array<TType>::back()\n    {\n        return at(size() - 1);\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    template <typename TType> typename dynamic_array<TType>::const_reference dynamic_array<TType>::back() const\n    {\n        return at(size() - 1);\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    template <typename TType> typename dynamic_array<TType>::iterator dynamic_array<TType>::begin()\n    {\n        return iterator(&front());\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    template <typename TType> typename dynamic_array<TType>::const_iterator dynamic_array<TType>::begin() const\n    {\n        return const_iterator(&front());\n    }\n    //---------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    template <typename TType> typename dynamic_array<TType>::const_iterator dynamic_array<TType>::cbegin() const\n    {\n        return const_iterator(&front());\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    template <typename TType> typename dynamic_array<TType>::iterator dynamic_array<TType>::end()\n    {\n        return iterator((&back()) + 1);\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    template <typename TType> typename dynamic_array<TType>::const_iterator dynamic_array<TType>::end() const\n    {\n        return const_iterator((&back()) + 1);\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    template <typename TType> typename dynamic_array<TType>::const_iterator dynamic_array<TType>::cend() const\n    {\n        return const_iterator((&back()) + 1);\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    template <typename TType> typename dynamic_array<TType>::reverse_iterator dynamic_array<TType>::rbegin()\n    {\n        return reverse_iterator(&back());\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    template <typename TType> typename dynamic_array<TType>::const_reverse_iterator dynamic_array<TType>::rbegin() const\n    {\n        return const_reverse_iterator(&back());\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    template <typename TType> typename dynamic_array<TType>::const_reverse_iterator dynamic_array<TType>::crbegin() const\n    {\n        return const_reverse_iterator(&back());\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    template <typename TType> typename dynamic_array<TType>::reverse_iterator dynamic_array<TType>::rend()\n    {\n        return reverse_iterator((&front() - 1));\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    template <typename TType> typename dynamic_array<TType>::const_reverse_iterator dynamic_array<TType>::rend() const\n    {\n        return const_reverse_iterator((&front() - 1));\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    template <typename TType> typename dynamic_array<TType>::const_reverse_iterator dynamic_array<TType>::crend() const\n    {\n        return const_reverse_iterator((&front() - 1));\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Container/random_access_iterator.h",
    "content": "//\n//  random_access_iterator.h\n//  ChilliSource\n//  Created by Ian Copland on 27/12/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_CONTAINERS_RANDOMACCESSITERATOR_H_\n#define _CHILLISOURCE_CORE_CONTAINERS_RANDOMACCESSITERATOR_H_\n\n#include <ChilliSource/ChilliSource.h>\n\n#include <iterator>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    /// A basic random access iterator. This can be used by any container that is\n    /// backed by elements stored contiguously in memory.\n    /// \n    /// @author Ian Copland\n    //------------------------------------------------------------------------------\n    template <typename TType> class random_access_iterator final : public std::iterator<std::random_access_iterator_tag, TType>\n    {\n    public:\n\n        using value_type = typename std::iterator<std::random_access_iterator_tag, TType>::value_type;\n        using difference_type = typename std::iterator<std::random_access_iterator_tag, TType>::difference_type;\n        using pointer = typename std::iterator<std::random_access_iterator_tag, TType>::pointer;\n        using reference = typename std::iterator<std::random_access_iterator_tag, TType>::reference;\n        using iterator_category = typename std::iterator<std::random_access_iterator_tag, TType>::iterator_category;\n        \n        //------------------------------------------------------------------------------\n        /// Default constuctor.\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------------------------------------\n        random_access_iterator() = default;\n        //------------------------------------------------------------------------------\n        /// Constructor. Creates the iterator from a pointer.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The pointer.\n        //------------------------------------------------------------------------------\n        random_access_iterator(pointer in_pointer);\n        //------------------------------------------------------------------------------\n        /// Copy Constructor.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param Another random access iterator.\n        //------------------------------------------------------------------------------\n        random_access_iterator(const random_access_iterator& in_toCopy);\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param Another random access iterator.\n        ///\n        /// @return A reference to this.\n        //------------------------------------------------------------------------------\n        random_access_iterator& operator=(const random_access_iterator& in_toCopy);\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The dereferenced value.\n        //------------------------------------------------------------------------------\n        reference operator*();\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The pointer.\n        //------------------------------------------------------------------------------\n        pointer operator->();\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param Another random access iterator.\n        ///\n        /// @return Whether or not this and the given iterator have the same value.\n        //------------------------------------------------------------------------------\n        bool operator==(const random_access_iterator& in_toTest) const;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param Another random access iterator.\n        ///\n        /// @return Whether or not this and the given iterator have different values.\n        //------------------------------------------------------------------------------\n        bool operator!=(const random_access_iterator& in_toTest) const;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param Another random access iterator.\n        ///\n        /// @return Whether or not this is more than the given iterator.\n        //------------------------------------------------------------------------------\n        bool operator>(const random_access_iterator& in_toTest) const;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param Another random access iterator.\n        ///\n        /// @return Whether or not this is more than the given iterator.\n        //------------------------------------------------------------------------------\n        bool operator<(const random_access_iterator& in_toTest) const;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param Another random access iterator.\n        ///\n        /// @return Whether or not this is more than the given iterator.\n        //------------------------------------------------------------------------------\n        bool operator>=(const random_access_iterator& in_toTest) const;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param Another random access iterator.\n        ///\n        /// @return Whether or not this is more than the given iterator.\n        //------------------------------------------------------------------------------\n        bool operator<=(const random_access_iterator& in_toTest) const;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return A reference to this after the increment has been performed.\n        //------------------------------------------------------------------------------\n        random_access_iterator& operator++();\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return A copy of this before the increment is performed.\n        //------------------------------------------------------------------------------\n        random_access_iterator operator++(int);\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param The difference.\n        ///\n        /// @return A copy of this incremented by the given difference.\n        //------------------------------------------------------------------------------\n        random_access_iterator operator+(difference_type in_difference);\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param The difference.\n        ///\n        /// @return A reference to this incremented by the given difference.\n        //------------------------------------------------------------------------------\n        random_access_iterator& operator+=(difference_type in_difference);\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return A reference to this after the decrement has been performed.\n        //------------------------------------------------------------------------------\n        random_access_iterator& operator--();\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return A copy of this before the decrement is performed.\n        //------------------------------------------------------------------------------\n        random_access_iterator operator--(int);\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param The difference.\n        ///\n        /// @return A copy of this decremented by the given difference.\n        //------------------------------------------------------------------------------\n        random_access_iterator operator-(difference_type in_difference);\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param The difference.\n        ///\n        /// @return A reference to this decremented by the given difference.\n        //------------------------------------------------------------------------------\n        random_access_iterator& operator-=(difference_type in_difference);\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param Another iterator.\n        ///\n        /// @return The difference.\n        //------------------------------------------------------------------------------\n        difference_type operator-(const random_access_iterator& in_otherIt) const;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param The difference.\n        ///\n        /// @return A reference to the element at the given difference.\n        //------------------------------------------------------------------------------\n        reference operator[](difference_type in_difference);\n    private:\n        pointer m_pointer;\n    };\n    \n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    template <typename TType> random_access_iterator<TType>::random_access_iterator(pointer in_pointer)\n        : m_pointer(in_pointer)\n    {\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    template <typename TType> random_access_iterator<TType>::random_access_iterator(const random_access_iterator& in_toCopy)\n        : m_pointer(in_toCopy.m_pointer)\n    {\n        \n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    template <typename TType> random_access_iterator<TType>& random_access_iterator<TType>::operator=(const random_access_iterator& in_toCopy)\n    {\n        m_pointer = in_toCopy.m_pointer;\n        return *this;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    template <typename TType> typename random_access_iterator<TType>::reference random_access_iterator<TType>::operator*()\n    {\n        return *m_pointer;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    template <typename TType> typename random_access_iterator<TType>::pointer random_access_iterator<TType>::operator->()\n    {\n        return m_pointer;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    template <typename TType> bool random_access_iterator<TType>::operator==(const random_access_iterator& in_toTest) const\n    {\n        return m_pointer == in_toTest.m_pointer;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    template <typename TType> bool random_access_iterator<TType>::operator!=(const random_access_iterator& in_toTest) const\n    {\n        return !(*this == in_toTest);\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    template <typename TType> bool random_access_iterator<TType>::operator>(const random_access_iterator& in_toTest) const\n    {\n        return (m_pointer - in_toTest.m_pointer) > 0;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    template <typename TType> bool random_access_iterator<TType>::operator<(const random_access_iterator& in_toTest) const\n    {\n        return (in_toTest.m_pointer - m_pointer) > 0;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    template <typename TType> bool random_access_iterator<TType>::operator>=(const random_access_iterator& in_toTest) const\n    {\n        return !(*this < in_toTest);\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    template <typename TType> bool random_access_iterator<TType>::operator<=(const random_access_iterator& in_toTest) const\n    {\n        return !(*this > in_toTest);\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    template <typename TType> random_access_iterator<TType>& random_access_iterator<TType>::operator++()\n    {\n        m_pointer++;\n        return *this;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    template <typename TType> random_access_iterator<TType> random_access_iterator<TType>::operator++(int)\n    {\n        auto copy = *this;\n        (*this)++;\n        return copy;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    template <typename TType> random_access_iterator<TType> random_access_iterator<TType>::operator+(difference_type in_difference)\n    {\n        return m_pointer + in_difference;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    template <typename TType> random_access_iterator<TType>& random_access_iterator<TType>::operator+=(difference_type in_difference)\n    {\n        m_pointer += in_difference;\n        return *this;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    template <typename TType> random_access_iterator<TType>& random_access_iterator<TType>::operator--()\n    {\n        m_pointer--;\n        return *this;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    template <typename TType> random_access_iterator<TType> random_access_iterator<TType>::operator--(int)\n    {\n        auto copy = *this;\n        (*this)--;\n        return copy;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    template <typename TType> random_access_iterator<TType> random_access_iterator<TType>::operator-(difference_type in_difference)\n    {\n        return m_pointer - in_difference;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    template <typename TType> random_access_iterator<TType>& random_access_iterator<TType>::operator-=(difference_type in_difference)\n    {\n        m_pointer -= in_difference;\n        return *this;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    template <typename TType> typename random_access_iterator<TType>::difference_type random_access_iterator<TType>::operator-(const random_access_iterator& in_otherIt) const\n    {\n        return m_pointer - in_otherIt.m_pointer;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    template <typename TType> typename random_access_iterator<TType>::reference random_access_iterator<TType>::operator[](difference_type in_difference)\n    {\n        return m_pointer[in_difference];\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Container.h",
    "content": "//\n//  Container.h\n//  ChilliSource\n//  Created by Ian Copland on 07/07/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_CONTAINER_H_\n#define _CHILLISOURCE_CORE_CONTAINER_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Container/HashedArray.h>\n#include <ChilliSource/Core/Container/concurrent_vector.h>\n#include <ChilliSource/Core/Container/concurrent_blocking_queue.h>\n#include <ChilliSource/Core/Container/dynamic_array.h>\n#include <ChilliSource/Core/Container/ParamDictionary.h>\n#include <ChilliSource/Core/Container/ParamDictionarySerialiser.h>\n#include <ChilliSource/Core/Container/random_access_iterator.h>\n#include <ChilliSource/Core/Container/VectorUtils.h>\n#include <ChilliSource/Core/Container/Property/IProperty.h>\n#include <ChilliSource/Core/Container/Property/IPropertyType.h>\n#include <ChilliSource/Core/Container/Property/Property.h>\n#include <ChilliSource/Core/Container/Property/PropertyMap.h>\n#include <ChilliSource/Core/Container/Property/PropertyType.h>\n#include <ChilliSource/Core/Container/Property/ReferenceProperty.h>\n#include <ChilliSource/Core/Container/Property/ValueProperty.h>\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Cryptographic/AESEncrypt.cpp",
    "content": "//\n//  AESEncrypt.cpp\n//  ChilliSource\n//  Created by Scott Downie on 25/09/2012.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2012 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Core/Cryptographic/AESEncrypt.h>\n\n#include <aes/aes.h>\n\n#include <cstring>\n#include <limits>\n\nnamespace ChilliSource\n{\n    namespace AESEncrypt\n    {\n        namespace\n        {\n            const u32 k_aesBlockSize = 16;\n        }\n        \n        //---------------------------------------------------------\n        //---------------------------------------------------------\n        Data::Data(Data&& in_moveable)\n            : m_data(std::move(in_moveable.m_data)), m_size(in_moveable.m_size)\n        {\n        }\n        //---------------------------------------------------------\n        //---------------------------------------------------------\n        Data& Data::operator=(Data&& in_moveable)\n        {\n            m_data = std::move(in_moveable.m_data);\n            m_size = in_moveable.m_size;\n            return *this;\n        }\n        //---------------------------------------------------\n        //---------------------------------------------------\n        u32 CalculateAlignedSize(u32 in_dataSize)\n        {\n            u32 udwMod (in_dataSize % k_aesBlockSize);\n            \n            if(udwMod == 0)\n            {\n                //already aligned, no need to add\n                return in_dataSize;\n            }\n            \n            u32 udwEncryptedSize = in_dataSize + (k_aesBlockSize - udwMod); // otherwise add the difference to the next boundary\n            return udwEncryptedSize;\n        }\n        //---------------------------------------------------\n        //---------------------------------------------------\n        Data EncryptBinary(const u8* in_data, u32 in_dataLength, const std::string& in_privateKey)\n        {\n            CS_ASSERT(in_privateKey.size() == 16, \"AES Encryption keys must be 16 bytes\");\n            \n            AES_KEY sKey;\n            if(AES_set_encrypt_key((const u8*)in_privateKey.data(), 128, &sKey) != 0)\n            {\n                CS_LOG_FATAL(\"AES: Cannot set decryption key\");\n            }\n            \n            Data output;\n            output.m_size = in_dataLength;\n            output.m_data = std::unique_ptr<u8[]>(new u8[output.m_size]);\n            \n            s32 dwBytesRemaining = (s32)in_dataLength;\n            const u8* pReadData = in_data;\n            u8* pWriteData = output.m_data.get();\n            \n            while(dwBytesRemaining > 0)\n            {\n                AES_encrypt(pReadData, pWriteData, &sKey);\n                \n                pReadData += k_aesBlockSize;\n                pWriteData += k_aesBlockSize;\n                dwBytesRemaining -= k_aesBlockSize;\n            }\n            \n            return output;\n        }\n        //---------------------------------------------------\n        //---------------------------------------------------\n        Data DecryptBinary(const u8* in_data, u32 in_dataLength, const std::string& in_privateKey)\n        {\n            CS_ASSERT(in_privateKey.size() == 16, \"AES Encryption keys must be 16 bytes\");\n            \n            AES_KEY sKey;\n            if(AES_set_decrypt_key((const u8*)in_privateKey.data(), 128, &sKey) != 0)\n            {\n                CS_LOG_FATAL(\"AES: Cannot set decryption key\");\n            }\n            \n            Data output;\n            output.m_size = in_dataLength;\n            output.m_data = std::unique_ptr<u8[]>(new u8[output.m_size]);\n            \n            s32 dwBytesRemaining = (s32)in_dataLength;\n            const u8* pReadData = in_data;\n            u8* pWriteData = output.m_data.get();\n            \n            while(dwBytesRemaining > 0)\n            {\n                AES_decrypt(pReadData, pWriteData, &sKey);\n                pReadData += k_aesBlockSize;\n                pWriteData += k_aesBlockSize;\n                dwBytesRemaining -= k_aesBlockSize;\n            }\n            \n            return output;\n        }\n        //---------------------------------------------------\n        //---------------------------------------------------\n        Data EncryptString(const std::string& in_string, const std::string& in_privateKey)\n        {\n            CS_ASSERT(in_privateKey.size() == 16, \"AES Encryption keys must be 16 bytes\");\n            \n            AES_KEY privateKey;\n            if(AES_set_encrypt_key((const u8*)in_privateKey.data(), 128, &privateKey) != 0)\n            {\n                CS_LOG_FATAL(\"AES: Cannot set decryption key\");\n            }\n            \n            CS_ASSERT(in_string.length() < static_cast<std::size_t>(std::numeric_limits<u32>::max()), \"String is too long. It cannot exceed \" + ToString(std::numeric_limits<u32>::max()) + \" characters.\");\n            \n            const u32 terminatedStringSize = static_cast<u32>(in_string.length()) + 1;\n            const u32 encryptedDataSize = CalculateAlignedSize(terminatedStringSize);\n            const u32 numBlocks = encryptedDataSize / k_aesBlockSize;\n            \n            Data output;\n            output.m_size = encryptedDataSize;\n            output.m_data = std::unique_ptr<u8[]>(new u8[output.m_size]);\n            \n            const u8* readData = reinterpret_cast<const u8*>(in_string.c_str());\n            u8* writeData = output.m_data.get();\n            \n            for (u32 blockIndex = 0; blockIndex < numBlocks - 1; ++blockIndex)\n            {\n                AES_encrypt(readData, writeData, &privateKey);\n                readData += k_aesBlockSize;\n                writeData += k_aesBlockSize;\n            }\n            \n            //encrypt the final block.\n            std::unique_ptr<u8[]> finalBlock(new u8[k_aesBlockSize]);\n            memset(finalBlock.get(), '\\0', k_aesBlockSize);\n            u32 remainingStringSize = in_string.length() % k_aesBlockSize;\n            if (remainingStringSize > 0)\n            {\n                memcpy(finalBlock.get(), readData, remainingStringSize);\n            }\n            AES_encrypt(finalBlock.get(), writeData, &privateKey);\n            \n            return output;\n        }\n        //---------------------------------------------------\n        //---------------------------------------------------\n        std::string DecryptString(const u8* in_data, u32 in_dataLength, const std::string& in_privateKey)\n        {\n            CS_ASSERT(in_privateKey.size() == 16, \"AES Encryption keys must be 16 bytes\");\n            \n            AES_KEY sKey;\n            if(AES_set_decrypt_key((const u8*)in_privateKey.data(), 128, &sKey) != 0)\n            {\n                CS_LOG_FATAL(\"AES: Cannot set decryption key\");\n            }\n            \n            Data decryptedData;\n            decryptedData.m_size = in_dataLength;\n            decryptedData.m_data = std::unique_ptr<u8[]>(new u8[decryptedData.m_size]);\n            \n            s32 dwBytesRemaining = (s32)in_dataLength;\n            const u8* pReadData = in_data;\n            u8* pWriteData = decryptedData.m_data.get();\n            \n            while(dwBytesRemaining > 0)\n            {\n                AES_decrypt(pReadData, pWriteData, &sKey);\n                pReadData += k_aesBlockSize;\n                pWriteData += k_aesBlockSize;\n                dwBytesRemaining -= k_aesBlockSize;\n            }\n            \n            const s8* data = reinterpret_cast<const s8*>(decryptedData.m_data.get());\n            std::string output(data);\n            \n            return output;\n        }\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Core/Cryptographic/AESEncrypt.h",
    "content": "//\n//  AESEncrypt.h\n//  ChilliSource\n//  Created by Scott Downie on 25/09/2012.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2012 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_CRYPTOGRAPHIC_AESENCRYPT_H_\n#define _CHILLISOURCE_CORE_CRYPTOGRAPHIC_AESENCRYPT_H_\n\n#include <ChilliSource/ChilliSource.h>\n\nnamespace ChilliSource\n{\n    //--------------------------------------------------------\n    /// A collection of methods for working with AES encrpytion.\n    /// These are not threadsafe and should not be called from\n    /// multiple threads at the same time.\n    ///\n    /// @author S Downie\n    //--------------------------------------------------------\n    namespace AESEncrypt\n    {\n        //---------------------------------------------------\n        /// A container for output data, providing the data\n        /// size.\n        ///\n        /// @author S Downie\n        //---------------------------------------------------\n        struct Data\n        {\n            //---------------------------------------------------------\n            /// Default constructor. This needs to explicitly declared on\n            /// windows.\n            ///\n            /// @author Ian Copland\n            //---------------------------------------------------------\n            Data() = default;\n            //---------------------------------------------------------\n            /// Move constructor. This needs to explicitly declared on\n            /// windows.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param The object to move.\n            //---------------------------------------------------------\n            Data(Data&& in_moveable);\n            //---------------------------------------------------------\n            /// Move assignment operator. This needs to explicitly \n            /// declared on  windows.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param The object to move.\n            ///\n            /// @return a reference to this.\n            //---------------------------------------------------------\n            Data& operator=(Data&& in_moveable);\n\n            std::unique_ptr<u8[]> m_data;\n            u32 m_size;\n        };\n        //---------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param The data size.\n        ///\n        /// @return The smallest encryptable size for the given\n        /// data size. Data size must by 16 byte aligned to be\n        /// encrypted.\n        //---------------------------------------------------\n        u32 CalculateAlignedSize(u32 in_dataSize);\n        //---------------------------------------------------\n        /// Encrypts binary data with the given private key.\n        ///\n        /// @author S Downie\n        ///\n        /// @param The data.\n        /// @param The data size. Data size must be 16 byte\n        /// aligned to be encrypted.\n        /// @param The private key.\n        ///\n        /// @return The output encrypted data. This will be\n        /// 16-byte aligned.\n        //---------------------------------------------------\n        Data EncryptBinary(const u8* in_data, u32 in_dataLength, const std::string& in_privateKey);\n        //---------------------------------------------------\n        /// Decrypts binary data with the given private key.\n        ///\n        /// @author S Downie\n        ///\n        /// @param The encrypted data.\n        /// @param The data size. Data size must be 16 byte\n        /// aligned to be decrypted.\n        /// @param The private key.\n        ///\n        /// @return The output decrypted data.\n        //---------------------------------------------------\n        Data DecryptBinary(const u8* in_data, u32 in_dataLength, const std::string& in_privateKey);\n        //---------------------------------------------------\n        /// Encrypts the string with the given private key.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The string to encrypt.\n        /// @param The private key.\n        ///\n        /// @return The output encrypted data. This will be\n        /// 16-byte aligned.\n        //---------------------------------------------------\n        Data EncryptString(const std::string& in_string, const std::string& in_privateKey);\n        //---------------------------------------------------\n        /// Decrypts the string with the given private key.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The encrypted data.\n        /// @param The encrpyted data size. Data size must be\n        /// 16 byte aligned to be decrypted.\n        /// @param The private key.\n        ///\n        /// @return The output decrypted string.\n        //---------------------------------------------------\n        std::string DecryptString(const u8* in_data, u32 in_dataLength, const std::string& in_privateKey);\n    };\n}\n\n#endif\n\n"
  },
  {
    "path": "Source/ChilliSource/Core/Cryptographic/BaseEncoding.cpp",
    "content": "//\n//  BaseEncoding.cpp\n//  ChilliSource\n//  Created by Scott Downie on 06/07/2011.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2011 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Core/Cryptographic/BaseEncoding.h>\n\n#include <base64/base64.h>\n\n#include <algorithm>\n\nnamespace ChilliSource\n{\n    namespace BaseEncoding\n    {\n        //---------------------------------------------------------\n        //---------------------------------------------------------\n        std::string Base64Encode(const std::string& in_value)\n        {\n            CS_ASSERT(in_value.length() < static_cast<std::string::size_type>(std::numeric_limits<u32>::max()), \"String is too long. It cannot exceed \"\n                      + ToString(std::numeric_limits<u32>::max()) + \" characters.\");\n            \n            return Base64Encode(in_value.c_str(), static_cast<u32>(in_value.length()));\n        }\n        //---------------------------------------------------------\n        //---------------------------------------------------------\n        std::string Base64Encode(const s8* in_data, u32 in_size)\n        {\n            return base64_encode(reinterpret_cast<const u8*>(in_data), in_size);\n        }\n        //---------------------------------------------------------\n        //---------------------------------------------------------\n        std::string Base64Decode(const std::string& in_value)\n        {\n            return base64_decode(in_value);\n        }\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Core/Cryptographic/BaseEncoding.h",
    "content": "//\n//  BaseEncoding.h\n//  ChilliSource\n//  Created by Scott Downie on 06/07/2011.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2011 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_CRYPTOGRAPHIC_BASEENCODING_H_\n#define _CHILLISOURCE_CORE_CRYPTOGRAPHIC_BASEENCODING_H_\n\n#include <ChilliSource/ChilliSource.h>\n\nnamespace ChilliSource\n{\n    //-------------------------------------------------------------\n    /// A collection of methods for working with Base 64 encoding.\n    ///\n    /// @author S Downie\n    //-------------------------------------------------------------\n    namespace BaseEncoding\n    {\n        //-------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param String to encode\n        ///\n        /// @return Base 64 encoded string\n        //-------------------------------------------------------\n        std::string Base64Encode(const std::string& in_value);\n        //-------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Data to encode\n        /// @param Size of data in bytes\n        ///\n        /// @return Base 64 encoded string\n        //-------------------------------------------------------\n        std::string Base64Encode(const s8* in_data, u32 in_size);\n        //-------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Base 64 encoded string\n        ///\n        /// @return Decoded string\n        //-------------------------------------------------------\n        std::string Base64Decode(const std::string& in_value);\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Cryptographic/HashCRC32.cpp",
    "content": "//\n//  HashCRC32.cpp\n//  ChilliSource\n//  Created by Scott Downie on 06/07/2011.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2011 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Core/Cryptographic/HashCRC32.h>\n\nnamespace ChilliSource\n{\n    namespace HashCRC32\n    {\n        namespace\n        {\n            const u32 kaudwCRC32Lookup[256] =\n            {\n                0u, 1996959894u, 3993919788u, 2567524794u, 124634137u, 1886057615u,\n                3915621685u, 2657392035u, 249268274u, 2044508324u, 3772115230u, 2547177864u, 162941995u, 2125561021u, 3887607047u, 2428444049u,\n                498536548u, 1789927666u, 4089016648u, 2227061214u, 450548861u, 1843258603u, 4107580753u, 2211677639u, 325883990u, 1684777152u,\n                4251122042u, 2321926636u, 335633487u, 1661365465u, 4195302755u, 2366115317u, 997073096u, 1281953886u, 3579855332u, 2724688242u,\n                1006888145u, 1258607687u, 3524101629u, 2768942443u, 901097722u, 1119000684u, 3686517206u, 2898065728u, 853044451u, 1172266101u,\n                3705015759u, 2882616665u, 651767980u, 1373503546u, 3369554304u, 3218104598u, 565507253u, 1454621731u, 3485111705u, 3099436303u,\n                671266974u, 1594198024u, 3322730930u, 2970347812u, 795835527u, 1483230225u, 3244367275u, 3060149565u, 1994146192u, 31158534u,\n                2563907772u, 4023717930u, 1907459465u, 112637215u, 2680153253u, 3904427059u, 2013776290u, 251722036u, 2517215374u, 3775830040u,\n                2137656763u, 141376813u, 2439277719u, 3865271297u, 1802195444u, 476864866u, 2238001368u, 4066508878u, 1812370925u, 453092731u,\n                2181625025u, 4111451223u, 1706088902u, 314042704u, 2344532202u, 4240017532u, 1658658271u, 366619977u, 2362670323u, 4224994405u,\n                1303535960u, 984961486u, 2747007092u, 3569037538u, 1256170817u, 1037604311u, 2765210733u, 3554079995u, 1131014506u, 879679996u,\n                2909243462u, 3663771856u, 1141124467u, 855842277u, 2852801631u, 3708648649u, 1342533948u, 654459306u, 3188396048u, 3373015174u,\n                1466479909u, 544179635u, 3110523913u, 3462522015u, 1591671054u, 702138776u, 2966460450u, 3352799412u, 1504918807u, 783551873u,\n                3082640443u, 3233442989u, 3988292384u, 2596254646u, 62317068u, 1957810842u, 3939845945u, 2647816111u, 81470997u, 1943803523u,\n                3814918930u, 2489596804u, 225274430u, 2053790376u, 3826175755u, 2466906013u, 167816743u, 2097651377u, 4027552580u, 2265490386u,\n                503444072u, 1762050814u, 4150417245u, 2154129355u, 426522225u, 1852507879u, 4275313526u, 2312317920u, 282753626u, 1742555852u,\n                4189708143u, 2394877945u, 397917763u, 1622183637u, 3604390888u, 2714866558u, 953729732u, 1340076626u, 3518719985u, 2797360999u,\n                1068828381u, 1219638859u, 3624741850u, 2936675148u, 906185462u, 1090812512u, 3747672003u, 2825379669u, 829329135u, 1181335161u,\n                3412177804u, 3160834842u, 628085408u, 1382605366u, 3423369109u, 3138078467u, 570562233u, 1426400815u, 3317316542u, 2998733608u,\n                733239954u, 1555261956u, 3268935591u, 3050360625u, 752459403u, 1541320221u, 2607071920u, 3965973030u, 1969922972u, 40735498u,\n                2617837225u, 3943577151u, 1913087877u, 83908371u, 2512341634u, 3803740692u, 2075208622u, 213261112u, 2463272603u, 3855990285u,\n                2094854071u, 198958881u, 2262029012u, 4057260610u, 1759359992u, 534414190u, 2176718541u, 4139329115u, 1873836001u, 414664567u,\n                2282248934u, 4279200368u, 1711684554u, 285281116u, 2405801727u, 4167216745u, 1634467795u, 376229701u, 2685067896u, 3608007406u,\n                1308918612u, 956543938u, 2808555105u, 3495958263u, 1231636301u, 1047427035u, 2932959818u, 3654703836u, 1088359270u, 936918000u,\n                2847714899u, 3736837829u, 1202900863u, 817233897u, 3183342108u, 3401237130u, 1404277552u, 615818150u, 3134207493u,3453421203u,\n                1423857449u, 601450431u, 3009837614u, 3294710456u, 1567103746u, 711928724u, 3020668471u, 3272380065u, 1510334235u, 755167117u\n            };\n        }\n        //-------------------------------------------------------------\n        /// Generate Hash Code\n        ///\n        /// @param String to hash\n        /// @return CRC 32 hash code\n        //-------------------------------------------------------------\n        u32 GenerateHashCode(const std::string &instrVal)\n        {\n            return GenerateHashCode(instrVal.c_str());\n        }\n        //-------------------------------------------------------------\n        /// Generate Hash Code\n        ///\n        /// @param Null terminated string to hash\n        /// @return CRC 32 hash code\n        //-------------------------------------------------------------\n        u32 GenerateHashCode(const s8* instrVal)\n        {\n            u32 Result\t\t= 0xffffffff;\n            u16 Index\t\t= 0;\n            u8\tNextChar\t= 0;\n            \n            while(instrVal[Index] != '\\0')\n            {\n                NextChar = instrVal[Index++];\n                Result = (Result >> 8) ^ kaudwCRC32Lookup[(Result & 0xFF) ^ NextChar];\n            }\n            \n            return ~Result;\n        }\n        //-------------------------------------------------------------\n        /// Generate Hash Code\n        ///\n        /// @param Data to hash\n        /// @param Size of data in bytes\n        /// @return CRC 32 hash code\n        //-------------------------------------------------------------\n        u32 GenerateHashCode(const s8* inbyVal, u32 inudwSizeInBytes)\n        {\n            u32 Result = 0xffffffff;\n            \n            for(u32 i=0; i<inudwSizeInBytes; ++i)\n            {\n                u8 byNextByte = inbyVal[i];\n                Result = (Result >> 8) ^ kaudwCRC32Lookup[(Result & 0xFF) ^ byNextByte];\n            }\n            \n            return ~Result;\n        }\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Core/Cryptographic/HashCRC32.h",
    "content": "//\n//  HashCRC32.h\n//  ChilliSource\n//  Created by Scott Downie on 06/07/2011.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2011 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_HASH_CRC_32_H_\n#define _CHILLISOURCE_HASH_CRC_32_H_\n\n#include <ChilliSource/ChilliSource.h>\n\nnamespace ChilliSource\n{\n    namespace HashCRC32\n    {\n        //-------------------------------------------------------------\n        /// Generate Hash Code\n        ///\n        /// @param String to hash\n        /// @return CRC 32 hash code\n        //-------------------------------------------------------------\n        u32 GenerateHashCode(const std::string &instrVal);\n        //-------------------------------------------------------------\n        /// Generate Hash Code\n        ///\n        /// @param Null terminated string to hash\n        /// @return CRC 32 hash code\n        //-------------------------------------------------------------\n        u32 GenerateHashCode(const s8* instrVal);\n        //-------------------------------------------------------------\n        /// Generate Hash Code\n        ///\n        /// @param Data to hash\n        /// @param Size of data in bytes\n        /// @return CRC 32 hash code\n        //-------------------------------------------------------------\n        u32 GenerateHashCode(const s8* inbyVal, u32 inudwSizeInBytes);\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Cryptographic/HashMD5.cpp",
    "content": "//\n//  HashMD5.cpp\n//  ChilliSource\n//  Created by Scott Downie on 06/07/2011.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2011 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Core/Cryptographic/HashMD5.h>\n\n#include <md5/md5.h>\n\nnamespace ChilliSource\n{\n    namespace HashMD5\n    {\n        //-------------------------------------------------------------\n        //-------------------------------------------------------------\n        std::string GenerateHexHashCode(const std::string &in_value)\n        {\n            MD5 Hash(in_value);\n            return Hash.hexdigest();\n        }\n        //-------------------------------------------------------------\n        //-------------------------------------------------------------\n        std::string GenerateHexHashCode(const s8* in_value)\n        {\n            return GenerateHexHashCode(std::string(in_value));\n        }\n        //-------------------------------------------------------------\n        //-------------------------------------------------------------\n        std::string GenerateHexHashCode(const s8* in_value, u32 in_size)\n        {\n            MD5 Hash;\n            Hash.update(in_value, in_size);\n            Hash.finalize();\n            return Hash.hexdigest();\n        }\n        //-------------------------------------------------------------\n        //-------------------------------------------------------------\n        std::string GenerateBinaryHashCode(const std::string &in_value)\n        {\n            MD5 Hash(in_value);\n            return Hash.binarydigest();\n        }\n        //-------------------------------------------------------------\n        //-------------------------------------------------------------\n        std::string GenerateBinaryHashCode(const s8* in_value)\n        {\n            return GenerateBinaryHashCode(std::string(in_value));\n        }\n        //-------------------------------------------------------------\n        //-------------------------------------------------------------\n        std::string GenerateBinaryHashCode(const s8* in_value, u32 in_size)\n        {\n            MD5 Hash;\n            Hash.update(in_value, in_size);\n            Hash.finalize();\n            return Hash.binarydigest();\n        }\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Core/Cryptographic/HashMD5.h",
    "content": "//\n//  HashMD5.h\n//  ChilliSource\n//  Created by Scott Downie on 06/07/2011.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2011 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_CRYPTOGRAPHIC_HASHMD5_H_\n#define _CHILLISOURCE_CORE_CRYPTOGRAPHIC_HASHMD5_H_\n\n#include <ChilliSource/ChilliSource.h>\n\nnamespace ChilliSource\n{\n    namespace HashMD5\n    {\n        //-------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param String to hash\n        ///\n        /// @return MD5 hex hash code\n        //-------------------------------------------------------------\n        std::string GenerateHexHashCode(const std::string &in_value);\n        //-------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Null terminated string to hash\n        ///\n        /// @return MD5 hex hash code\n        //-------------------------------------------------------------\n        std::string GenerateHexHashCode(const s8* in_value);\n        //-------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Block of binary data\n        /// @param Size of data\n        ///\n        /// @return MD5 hex hash code\n        //-------------------------------------------------------------\n        std::string GenerateHexHashCode(const s8* in_value, u32 in_size);\n        //-------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param String to hash\n        ///\n        /// @return MD5 binary hash code\n        //-------------------------------------------------------------\n        std::string GenerateBinaryHashCode(const std::string &in_value);\n        //-------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Null terminated string to hash\n        ///\n        /// @return MD5 binary hash code\n        //-------------------------------------------------------------\n        std::string GenerateBinaryHashCode(const s8* in_value);\n        //-------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Block of binary data\n        /// @param Size of data\n        ///\n        /// @return MD5 binary hash code\n        //-------------------------------------------------------------\n        std::string GenerateBinaryHashCode(const s8* in_value, u32 in_size);\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Cryptographic/HashSHA1.cpp",
    "content": "//\n//  HashSHA1.cpp\n//  ChilliSource\n//  Created by Ian Copland on 09/06/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n\n#include <ChilliSource/Core/Cryptographic/HashSHA1.h>\n\n#include <SHA1/SHA1.h>\n\n#ifdef CS_TARGETPLATFORM_WINDOWS\n#include <CSBackend/Platform/Windows/Core/String/WindowsStringUtils.h>\n#endif\n\nnamespace ChilliSource\n{\n    namespace HashSHA1\n    {\n        //------------------------------------------------\n        //------------------------------------------------\n        std::string GenerateHexHashCode(const s8* in_data, u32 in_size)\n        {\n            const u32 k_sha1Length = 80;\n            \n            CS_LOG_WARNING(\"SHA-1 is deprecated, and no longer secure. Please use SHA-2 (SHA-256) or better.\");\n            \n            CSHA1 hash;\n            hash.Reset();\n            hash.Update(reinterpret_cast<const u8*>(in_data), in_size);\n            hash.Final();\n            \n#ifdef CS_TARGETPLATFORM_WINDOWS\n            TCHAR cHash[k_sha1Length];\n            memset(cHash, 0, k_sha1Length);\n            hash.ReportHash(cHash, CSHA1::REPORT_HEX_SHORT);\n            return CSBackend::Windows::WindowsStringUtils::UTF16ToUTF8(std::wstring(cHash));\n#else\n            s8 cHash[k_sha1Length];\n            memset(cHash, 0, k_sha1Length);\n            hash.ReportHash(cHash, CSHA1::REPORT_HEX_SHORT);\n            return std::string(cHash);\n#endif\n        }\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Core/Cryptographic/HashSHA1.h",
    "content": "//\n//  HashSHA1.h\n//  ChilliSource\n//  Created by Ian Copland on 09/06/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_CRYTOGRAPHIC_HASHSHA1_H_\n#define _CHILLISOURCE_CORE_CRYTOGRAPHIC_HASHSHA1_H_\n\n#include <ChilliSource/ChilliSource.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------\n    /// A collection of methods for working with the SHA1\n    /// hashing algorithm.\n    ///\n    /// @author Ian Copland\n    //------------------------------------------------------\n    namespace HashSHA1\n    {\n        //------------------------------------------------\n        /// Hashes the given data using SHA1. The output is\n        /// returned as a hex string.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The input data.\n        /// @param The input data size.\n        ///\n        /// @return The output hex string.\n        //------------------------------------------------\n        std::string GenerateHexHashCode(const s8* in_data, u32 in_size);\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Cryptographic/HashSHA256.cpp",
    "content": "//\n//  HashSHA256.cpp\n//  ChilliSource\n//  Created by Jordan Brown on 24/02/2017.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2017 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n\n#include <ChilliSource/Core/Cryptographic/HashSHA256.h>\n\n#include <SHA256/sha256.h>\n\nnamespace ChilliSource\n{\n    namespace HashSHA256\n    {\n        //------------------------------------------------\n        //------------------------------------------------\n        std::string GenerateHexHashCode(const s8* in_data, u32 in_size)\n        {\n            SHA256 hash;\n            hash.reset();\n            hash.add(reinterpret_cast<const u8*>(in_data), in_size);\n\n            return hash.getHash();\n        }\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Core/Cryptographic/HashSHA256.h",
    "content": "//\n//  HashSHA256.h\n//  ChilliSource\n//  Created by Jordan Brown on 24/02/2017.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2017 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_CRYTOGRAPHIC_HASHSHA256_H_\n#define _CHILLISOURCE_CORE_CRYTOGRAPHIC_HASHSHA256_H_\n\n#include <ChilliSource/ChilliSource.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------\n    /// A collection of methods for working with the SHA256\n    /// hashing algorithm.\n    ///\n    /// @author Jordan Brown\n    //------------------------------------------------------\n    namespace HashSHA256\n    {\n        //------------------------------------------------\n        /// Hashes the given data using SHA256. The output is\n        /// returned as a hex string.\n        ///\n        /// @author Jordan Brown\n        ///\n        /// @param The input data.\n        /// @param The input data size.\n        ///\n        /// @return The output hex string.\n        //------------------------------------------------\n        std::string GenerateHexHashCode(const s8* in_data, u32 in_size);\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Cryptographic/OAuth.cpp",
    "content": "//\n//  OAuth.cpp\n//  ChilliSource\n//  Created by Ian Copland on 08/04/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Core/Cryptographic/OAuth.h>\n\n#include <ChilliSource/Core/Cryptographic/BaseEncoding.h>\n#include <ChilliSource/Core/String/StringUtils.h>\n\n#include <SHA1/HMAC_SHA1.h>\n\n#include <algorithm>\n#include <ctime>\n#include <unordered_map>\n#include <vector>\n\nnamespace ChilliSource\n{\n    namespace OAuth\n    {\n        namespace\n        {\n            const std::string k_consumerKeyKey = \"oauth_consumer_key\";\n            const std::string k_nonceKey = \"oauth_nonce\";\n            const std::string k_signatureKey = \"oauth_signature\";\n            const std::string k_signatureMethodKey = \"oauth_signature_method\";\n            const std::string k_timestampKey = \"oauth_timestamp\";\n            const std::string k_versionKey = \"oauth_version\";\n            const std::string k_tokenKey = \"oauth_token\";\n            const std::string k_verifierKey = \"oauth_verifier\";\n            const std::string k_authHeader = \"OAuth \";\n            const std::string k_oauthVersion = \"1.0\";\n            \n            //-----------------------------------------------------------\n            /// A map for containing key value pair parameters.\n            ///\n            /// @author R Henning\n            //-----------------------------------------------------------\n            using ParamsMap = std::unordered_map<std::string, std::string>;\n            //-----------------------------------------------------------\n            /// Generates nonce and timestamp for OAuth header.\n            ///\n            /// @author R Henning\n            ///\n            /// @param The timestamp\n            ///\n            /// @return The nounce timestamp.\n            //-----------------------------------------------------------\n            std::string GenerateNonce(TimeIntervalSecs in_timestamp)\n            {\n                static u32 s_nounceCounter = 0;\n                \n                std::string time = ToString(in_timestamp);\n                std::string counter = ToString(s_nounceCounter);\n                \n                s_nounceCounter++;\n                return time + counter;\n            }\n            //-----------------------------------------------------------\n            /// This method prepares key-value pairs required for OAuth\n            /// header and signature generation.\n            ///\n            /// @author R Henning\n            ///\n            /// @param url encoded data. this is used during signature\n            /// generation.\n            /// @param base64 and url encoded OAuth signature.\n            /// @param The timestamp.\n            /// @param The nonce.\n            /// @param The consumer key.\n            /// @param The oauth token.\n            /// @param The OAuth verifier;\n            /// @param [Out] The params.\n            //-----------------------------------------------------------\n            void BuildOAuthTokenKeyValuePairs(const std::string& in_rawData, const std::string& in_signature, const std::string& in_timestamp, const std::string& in_nonce,\n                                              const std::string& in_consumerKey, const std::string& in_oauthToken, const std::string& in_oauthVerifier, ParamsMap& out_params)\n            {\n                out_params[k_consumerKeyKey] = in_consumerKey;\n                out_params[k_nonceKey] = in_nonce;\n                \n                if(in_signature.length() > 0)\n                {\n                    out_params[k_signatureKey] = in_signature;\n                }\n                \n                //only HMAC-SHA1 supported for now\n                out_params[k_signatureMethodKey] = \"HMAC-SHA1\";\n                out_params[k_timestampKey] = in_timestamp;\n                \n                if(in_oauthToken.length() > 0)\n                {\n                    out_params[k_tokenKey] = in_oauthToken;\n                }\n                \n                if (in_oauthVerifier.length() > 0)\n                {\n                    out_params[k_verifierKey] = in_oauthVerifier;\n                }\n                \n                out_params[k_versionKey] = k_oauthVersion;\n                \n                if(in_rawData.length())\n                {\n                    //Data should already be urlencoded once\n                    std::string dummyStrKey;\n                    std::string dummyStrValue;\n                    size_t position = in_rawData.find_first_of(\"=\");\n                    if(std::string::npos != position)\n                    {\n                        dummyStrKey = in_rawData.substr(0, position);\n                        dummyStrValue = in_rawData.substr(position + 1);\n                        out_params[dummyStrKey] = dummyStrValue;\n                    }\n                }\n            }\n            //-----------------------------------------------------------\n            /// Builds a sorted string from key-value pairs\n            ///\n            /// @author R Henning\n            ///\n            /// @param key-value pairs map\n            /// @param sepearator, either & or ,\n            ///\n            /// @return sorted string of OAuth parameters\n            //-----------------------------------------------------------\n            std::string GetStringFromOAuthKeyValuePairs(const ParamsMap& in_paramsMap, const std::string& in_paramsSeperator)\n            {\n                std::string output;\n                \n                if(in_paramsMap.size())\n                {\n                    std::vector<std::string> keyValueList;\n                    keyValueList.reserve(in_paramsMap.size());\n                    std::string dummyString;\n                    \n                    //Push key-value pairs to a list of strings\n                    for (const auto& param : in_paramsMap)\n                    {\n                        dummyString = param.first + \"=\";\n                        if(in_paramsSeperator == \",\")\n                        {\n                            dummyString += \"\\\"\";\n                        }\n                        dummyString += param.second;\n                        if(in_paramsSeperator == \",\")\n                        {\n                            dummyString += \"\\\"\";\n                        }\n                        \n                        keyValueList.push_back(dummyString);\n                    }\n                    \n                    //OAuth parameters need to be in order, so sort them\n                    std::sort(keyValueList.begin(), keyValueList.end());\n                    \n                    // Now, form a string\n                    for(const auto& param : keyValueList)\n                    {\n                        if(output.length() > 0)\n                        {\n                            output.append(in_paramsSeperator);\n                        }\n                        output.append(param.c_str());\n                    }\n                }\n                \n                return output;\n            }\n            //-----------------------------------------------------------\n            /// Calculates HMAC-SHA1 signature of OAuth header\n            ///\n            /// @author R Henning\n            ///\n            /// @param HTTP request type.\n            /// @param raw url of the HTTP request.\n            /// @param The consumer secret.\n            /// @param The oauth token secret.\n            /// @param key-value pairs containing OAuth headers and HTTP data\n            ///\n            /// @return base64 and url encoded signature.\n            //-----------------------------------------------------------\n            std::string GetSignature(RequestType in_type, const std::string& in_rawUrl, const std::string& in_consumerSecret, const std::string& in_oauthTokenSecret, const ParamsMap& in_paramsMap)\n            {\n                //Build a string using key-value pairs\n                std::string rawParams = GetStringFromOAuthKeyValuePairs(in_paramsMap, \"&\");\n                \n                //Start constructing base signature string. Refer http://dev.twitter.com/auth#intro\n                std::string sigBase;\n                switch(in_type)\n                {\n                case RequestType::k_httpGet:\n                    sigBase = \"GET&\";\n                    break;\n                case RequestType::k_httpPost:\n                    sigBase = \"POST&\";\n                    break;\n                case RequestType::k_httpDelete:\n                    sigBase = \"DELETE&\";\n                    break;\n                default:\n                    return \"\";\n                }\n                \n                sigBase += StringUtils::URLEncode(in_rawUrl) + \"&\" + StringUtils::URLEncode(rawParams);\n                \n                //Signing key is composed of consumer_secret&token_secret\n                std::string secretSigningKey = in_consumerSecret + \"&\" + in_oauthTokenSecret;\n                \n                //Now, hash the signature base string using HMAC_SHA1 class\n                const u32 k_bufferSize = 1024;\n                u8 digest[k_bufferSize];\n                memset(digest, 0, k_bufferSize);\n                \n                CHMAC_SHA1 objHMACSHA1;\n                objHMACSHA1.HMAC_SHA1((u8*)sigBase.c_str(), static_cast<int>(sigBase.length()), (u8*)secretSigningKey.c_str(), static_cast<int>(secretSigningKey.length()), (u8*)digest);\n                \n                //Do a base64 encode of signature - SHA 1 digest is 160 bits\n                std::string base64String = BaseEncoding::Base64Encode((s8*)digest, 20);\n                \n                //Do an url encode\n                return StringUtils::URLEncode(base64String);\n            }\n        }\n        //-----------------------------------------------------------\n        //-----------------------------------------------------------\n        std::string GenerateAuthorisationHeader(RequestType in_requestType, const std::string& in_url, const std::string& in_rawData, const std::string& in_consumerKey, const std::string& in_consumerSecret,\n                                                const std::string& in_oauthToken, const std::string& in_oauthTokenSecret, const std::string& in_oauthVerifier)\n        {\n            std::string pureUrl = in_url;\n\n            //If URL itself contains \"?key=value\", then extract and put them in map\n            size_t position = pureUrl.find_first_of(\"?\");\n            std::unordered_map<std::string, std::string> urlParams;\n            if(std::string::npos != position)\n            {\n                //Get only URL\n                pureUrl = in_url.substr(0, position);\n                \n                //Get only key=value data part\n                std::string dataPart = in_url.substr(position + 1);\n                \n                //This dataPart can contain many key value pairs: key1=value1&key2=value2&key3=value3\n                size_t sep = std::string::npos;\n                size_t position2 = std::string::npos;\n                std::string dataKeyVal;\n                std::string dataKey;\n                std::string dataVal;\n                while(std::string::npos != (sep = dataPart.find_first_of(\"&\")))\n                {\n                    //Extract first key=value pair\n                    dataKeyVal = dataPart.substr(0, sep);\n                    \n                    //Split them\n                    position2 = dataKeyVal.find_first_of(\"=\");\n                    if(std::string::npos != position2)\n                    {\n                        dataKey = dataKeyVal.substr(0, position2);\n                        dataVal = dataKeyVal.substr(position2 + 1);\n                        \n                        //Put this key=value pair in map\n                        urlParams[dataKey] = StringUtils::URLEncode(dataVal);\n                    }\n                    dataPart = dataPart.substr(sep + 1);\n                }\n                \n                //For the last key=value\n                dataKeyVal = dataPart.substr(0, sep);\n                \n                //Split them\n                position2 = dataKeyVal.find_first_of(\"=\");\n                if(std::string::npos != position2)\n                {\n                    dataKey = dataKeyVal.substr(0, position2);\n                    dataVal = dataKeyVal.substr(position2 + 1);\n                    \n                    //Put this key=value pair in map\n                    urlParams[dataKey] = StringUtils::URLEncode(dataVal);\n                }\n            }\n            \n            //Generate nonce and timestamp if required\n            TimeIntervalSecs timestamp = (TimeIntervalSecs)time(0);\n            std::string nonce = GenerateNonce(timestamp);\n            std::string timestampString = ToString(timestamp);\n            \n            //Build key-value pairs needed for OAuth request token, without signature\n            BuildOAuthTokenKeyValuePairs(in_rawData, \"\", timestampString, nonce, in_consumerKey, in_oauthToken, in_oauthVerifier, urlParams);\n            \n            //Get url encoded base64 signature using request type, url and parameters\n            std::string oauthSignature = GetSignature(in_requestType, pureUrl, in_consumerSecret, in_oauthTokenSecret, urlParams);\n            \n            //Now, again build key-value pairs with signature this time\n            BuildOAuthTokenKeyValuePairs(\"\", oauthSignature, timestampString, nonce, in_consumerKey, in_oauthToken, in_oauthVerifier, urlParams);\n            \n            //Get OAuth header in string format\n            std::string strRawParams = GetStringFromOAuthKeyValuePairs(urlParams, \",\");\n            \n            //Build authorization header\n            return k_authHeader + strRawParams;\n        }\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Core/Cryptographic/OAuth.h",
    "content": "//\n//  OAuth.h\n//  ChilliSource\n//  Created by Ian Copland on 08/04/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_CRYPTOGRAPHIC_OAUTH_H_\n#define _CHILLISOURCE_CORE_CRYPTOGRAPHIC_OAUTH_H_\n\n#include <ChilliSource/ChilliSource.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------\n    /// A collection of functions for working with OAuth authentication.\n    ///\n    /// @author R Henning\n    //------------------------------------------------------------------\n    namespace OAuth\n    {\n        //-----------------------------------------------------------\n        /// An enum describing the various request types.\n        ///\n        /// @author R Henning\n        //-----------------------------------------------------------\n        enum class RequestType\n        {\n            k_httpInvalid,\n            k_httpGet,\n            k_httpPost,\n            k_httpDelete\n        };\n        //-----------------------------------------------------------\n        /// Generates an OAuth authorisation header string.\n        ///\n        /// @author R Henning\n        ///\n        /// @param The http request type.\n        /// @param The URL.\n        /// @param The Http data.\n        /// @param The consumer key.\n        /// @param The consumer secret.\n        /// @param [Optional] The oauth token.\n        /// @param [Optional] The oauth token secret.\n        /// @param [Optional] The oauth verifier.\n        ///\n        /// @return The generated header string. If this failed an\n        /// empty string will be returned.\n        //-----------------------------------------------------------\n        std::string GenerateAuthorisationHeader(RequestType in_requestType, const std::string& in_url, const std::string& in_rawData, const std::string& in_consumerKey, const std::string& in_consumerSecret,\n                                                const std::string& in_oauthToken = \"\", const std::string& in_oauthTokenSecret = \"\", const std::string& in_oauthVerifier = \"\");\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Cryptographic.h",
    "content": "//\n//  Cryptographic.h\n//  ChilliSource\n//  Created by Ian Copland on 07/07/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_CRYPTOGRAPHIC_H_\n#define _CHILLISOURCE_CORE_CRYPTOGRAPHIC_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Cryptographic/AESEncrypt.h>\n#include <ChilliSource/Core/Cryptographic/BaseEncoding.h>\n#include <ChilliSource/Core/Cryptographic/HashCRC32.h>\n#include <ChilliSource/Core/Cryptographic/HashMD5.h>\n#include <ChilliSource/Core/Cryptographic/HashSHA1.h>\n#include <ChilliSource/Core/Cryptographic/OAuth.h>\n#include <ChilliSource/Core/Cryptographic/HashSHA256.h>\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Delegate/ConnectableDelegate.h",
    "content": "//\n//  ConnectableDelegate.h\n//  ChilliSource\n//  Created by S Downie on 08/05/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_DELEGATE_CONNECTABLEDELEGATE_H_\n#define _CHILLISOURCE_CORE_DELEGATE_CONNECTABLEDELEGATE_H_\n\n#include <ChilliSource/ChilliSource.h>\n\n#include <ChilliSource/Core/Delegate/DelegateConnection.h>\n\n#include <functional>\n#include <mutex>\n#include <vector>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------\n    /// Wrapper around a delegate that allows 3rd parties to establish\n    /// connections. While these connections are open the 3rd parties\n    /// can safely execute the delegate\n    ///\n    /// @author S Downie\n    //------------------------------------------------------------------\n    template <typename TReturnType, typename... TArgTypes> class ConnectableDelegate<TReturnType(TArgTypes...)> final\n    {\n    public:\n        \n        CS_DECLARE_NOCOPY(ConnectableDelegate);\n        \n        //------------------------------------------------------------------\n        /// Signature of connection which acts a convenience type for\n        /// declaring connections\n        ///\n        /// @author S Downie\n        //------------------------------------------------------------------\n        using Connection = std::unique_ptr<DelegateConnection<TReturnType(TArgTypes...)>>;\n        //------------------------------------------------------------------\n        /// Signature of the delegate function\n        ///\n        /// @author S Downie\n        ///\n        /// @params Variadic\n        ///\n        /// @return TReturnType\n        //------------------------------------------------------------------\n        using Delegate = std::function<TReturnType(TArgTypes...)>;\n        //------------------------------------------------------------------\n        /// Constructor null\n        ///\n        /// @author S Downie\n        ///\n        /// @param Null ptr\n        //------------------------------------------------------------------\n        ConnectableDelegate(std::nullptr_t in_null)\n        {\n            m_mutex = std::unique_ptr<std::mutex>(new std::mutex());\n        }\n        //------------------------------------------------------------------\n        /// Constructor\n        ///\n        /// @author S Downie\n        //------------------------------------------------------------------\n        ConnectableDelegate()\n        {\n            m_mutex = std::unique_ptr<std::mutex>(new std::mutex());\n        }\n        //------------------------------------------------------------------\n        /// Constructor\n        ///\n        /// @author S Downie\n        ///\n        /// @param Delegate to wrap\n        //------------------------------------------------------------------\n        ConnectableDelegate(const Delegate& in_delegate)\n        : m_delegate(in_delegate)\n        {\n            m_mutex = std::unique_ptr<std::mutex>(new std::mutex());\n        }\n        //------------------------------------------------------------------\n        /// Move constructor\n        ///\n        /// @author S Downie\n        ///\n        /// @param Object to move\n        //------------------------------------------------------------------\n        ConnectableDelegate(ConnectableDelegate&& in_toMove)\n        {\n            std::unique_lock<std::mutex> lock(*in_toMove.m_mutex);\n            m_mutex = std::move(in_toMove.m_mutex);\n            in_toMove.m_mutex = std::unique_ptr<std::mutex>(new std::mutex());\n            m_connections = std::move(in_toMove.m_connections);\n            m_delegate = std::move(in_toMove.m_delegate);\n        }\n        //------------------------------------------------------------------\n        /// Move assignment\n        ///\n        /// @author S Downie\n        ///\n        /// @param Object to move\n        ///\n        /// @return This\n        //------------------------------------------------------------------\n        ConnectableDelegate& operator=(ConnectableDelegate&& in_toMove)\n        {\n            std::unique_lock<std::mutex> lock(*in_toMove.m_mutex);\n            m_mutex = std::move(in_toMove.m_mutex);\n            in_toMove.m_mutex = std::unique_ptr<std::mutex>(new std::mutex());\n            m_connections = std::move(in_toMove.m_connections);\n            m_delegate = std::move(in_toMove.m_delegate);\n            \n            return *this;\n        }\n        //------------------------------------------------------------------\n        /// Open a new connection to the delegate. While the connection\n        /// remains the open the returned object can be used to invoke the\n        /// delegate\n        ///\n        /// @author S Downie\n        ///\n        /// @return New connection\n        //------------------------------------------------------------------\n        Connection OpenConnection()\n        {\n            CS_ASSERT(m_delegate != nullptr, \"Cannot open connection with null delegate\");\n            \n            Connection connection(new DelegateConnection<TReturnType(TArgTypes...)>(this));\n            \n            std::unique_lock<std::mutex> lock(*m_mutex);\n            m_connections.push_back(connection.get());\n            lock.unlock();\n            \n            return connection;\n        }\n        //------------------------------------------------------------------\n        /// Close all the open connections and prevent this delegate from\n        /// being executed in the future\n        ///\n        /// @author S Downie\n        //------------------------------------------------------------------\n        void CloseAllConnections()\n        {\n            std::unique_lock<std::mutex> lock(*m_mutex);\n            \n            for(auto connection : m_connections)\n            {\n                if(connection != nullptr)\n                {\n                    connection->CloseNoNotify();\n                }\n            }\n            \n            m_connections.clear();\n        }\n        //------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Nullptr\n        ///\n        /// @return Whether the object is considered null\n        //------------------------------------------------------------------\n        bool operator==(std::nullptr_t in_null) const\n        {\n            return m_delegate == nullptr;\n        }\n        //------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Nullptr\n        ///\n        /// @return Whether the object is NOT considered null\n        //------------------------------------------------------------------\n        bool operator!=(std::nullptr_t in_null) const\n        {\n            return m_delegate != nullptr;\n        }\n        //------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Whether the object is NOT considered null\n        //------------------------------------------------------------------\n        operator bool() const\n        {\n            return m_delegate != nullptr;\n        }\n        //------------------------------------------------------------------\n        /// Closes all open connections\n        ///\n        /// @author S Downie\n        //------------------------------------------------------------------\n        ~ConnectableDelegate()\n        {\n            //Close the connection if this is being destructed from the owner\n            CloseAllConnections();\n        }\n        \n    private:\n        \n        friend class DelegateConnection<TReturnType(TArgTypes...)>;\n        //------------------------------------------------------------------\n        /// Executes the delegate if the connection is open\n        ///\n        /// @author S Downie\n        ///\n        /// @param Variadic - matches the delegate signature\n        ///\n        /// @return TReturnType - matches the delegate signature\n        //------------------------------------------------------------------\n        TReturnType Execute(TArgTypes... in_args)\n        {\n            return m_delegate(in_args...);\n        }\n        //------------------------------------------------------------------\n        /// Flags the connection as no longer open. This is called by\n        /// the connection when it wishes to close\n        ///\n        /// @author S Downie\n        ///\n        /// @param Connection\n        //------------------------------------------------------------------\n        void Close(DelegateConnection<TReturnType(TArgTypes...)>* in_connection)\n        {\n            std::unique_lock<std::mutex> lock(*m_mutex);\n            \n            for(u32 i=0; i<m_connections.size(); ++i)\n            {\n                if(m_connections[i] == in_connection)\n                {\n                    m_connections[i] = nullptr;\n                    break;\n                }\n            }\n        }\n        \n    private:\n        \n        Delegate m_delegate;\n        \n        mutable std::unique_ptr<std::mutex> m_mutex;\n        std::vector<DelegateConnection<TReturnType(TArgTypes...)>*> m_connections;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Delegate/DelegateConnection.h",
    "content": "//\n//  DelegateConnection.h\n//  ChilliSource\n//  Created by S Downie on 08/05/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_DELEGATE_DELEGATECONNECTION_H_\n#define _CHILLISOURCE_CORE_DELEGATE_DELEGATECONNECTION_H_\n\n#include <ChilliSource/ChilliSource.h>\n\n#include <mutex>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------\n    /// Connection wrapper around a delegate to allow safe callbacks\n    /// to member functions. The connection is closed when the connection\n    /// or the delegate goes out of scope\n    ///\n    /// @author S Downie\n    //------------------------------------------------------------------\n    template <typename TReturnType, typename... TArgTypes> class DelegateConnection<TReturnType(TArgTypes...)> final\n    {\n    public:\n        \n        CS_DECLARE_NOCOPY(DelegateConnection);\n        \n        //------------------------------------------------------------------\n        /// Constructor\n        ///\n        /// @author S Downie\n        ///\n        /// @param Owning delegate\n        //------------------------------------------------------------------\n        DelegateConnection(ConnectableDelegate<TReturnType(TArgTypes...)>* in_owner)\n        : m_owningDelegate(in_owner)\n        {\n            \n        }\n        //------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Whether the connection is open and delegate can be executed\n        //------------------------------------------------------------------\n        bool IsOpen() const\n        {\n            std::unique_lock<std::mutex> lock(m_mutex);\n            return m_owningDelegate != nullptr;\n        }\n        //------------------------------------------------------------------\n        /// Close the connection and prevent the delegate from being executed\n        ///\n        /// @author S Downie\n        //------------------------------------------------------------------\n        void Close()\n        {\n            std::unique_lock<std::mutex> lock(m_mutex);\n            if(m_owningDelegate != nullptr)\n            {\n                m_owningDelegate->Close(this);\n                m_owningDelegate = nullptr;\n            }\n        }\n        //------------------------------------------------------------------\n        /// Executes the delegate if the connection is open\n        ///\n        /// @author S Downie\n        ///\n        /// @param Variadic - matches the delegate signature\n        ///\n        /// @return TReturnType - matches the delegate signature\n        //------------------------------------------------------------------\n        TReturnType Call(TArgTypes... in_args)\n        {\n            std::unique_lock<std::mutex> lock(m_mutex);\n            if(m_owningDelegate != nullptr)\n            {\n                return m_owningDelegate->Execute(in_args...);\n            }\n        }\n        //------------------------------------------------------------------\n        /// Destructor closes the connection when the owner goes out of scope\n        ///\n        /// @author S Downie\n        //------------------------------------------------------------------\n        ~DelegateConnection()\n        {\n            Close();\n        }\n        \n    private:\n        \n        friend class ConnectableDelegate<TReturnType(TArgTypes...)>;\n        //------------------------------------------------------------------\n        /// Called by the delegate when it wishes to close the connection\n        /// without being told by the connection itself\n        ///\n        /// @author S Downie\n        //------------------------------------------------------------------\n        void CloseNoNotify()\n        {\n            std::unique_lock<std::mutex> lock(m_mutex);\n            m_owningDelegate = nullptr;\n        }\n        \n    private:\n\n        mutable std::mutex m_mutex;\n        ConnectableDelegate<TReturnType(TArgTypes...)>* m_owningDelegate;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Delegate/MakeConnectableDelegate.h",
    "content": "//\n//  MakeConnectableDelegate.h\n//  ChilliSource\n//  Created by Scott Downie on 12/05/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_DELEGATE_MAKECONNECTABLEDELEGATE_H_\n#define _CHILLISOURCE_CORE_DELEGATE_MAKECONNECTABLEDELEGATE_H_\n\n#include <ChilliSource/Core/Delegate/ConnectableDelegate.h>\n\n#include <functional>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------\n    /// Constructs a connectable delegate to a free function with a signature that\n    /// matches the given return and parameter types.\n    ///\n    /// @author S Downie\n    ///\n    /// @param Function ptr\n    ///\n    /// @return Delegate\n    //------------------------------------------------------------------\n    template <typename TReturnType, typename... TArgTypes>\n    ConnectableDelegate<TReturnType(TArgTypes...)> MakeConnectableDelegate(TReturnType (*in_func)(TArgTypes...))\n    {\n        return ConnectableDelegate<TReturnType(TArgTypes...)>(std::function<TReturnType(TArgTypes...)>(in_func));\n    }\n    //------------------------------------------------------------------\n    /// Constructs a connectable delegate to a static function with a signature that\n    /// matches the given return and parameter types.\n    ///\n    /// @author S Downie\n    ///\n    /// @param Static function ptr\n    ///\n    /// @return Delegate\n    //------------------------------------------------------------------\n    template <typename TDelegate, typename TReturnType, typename... TArgTypes>\n    ConnectableDelegate<TReturnType(TArgTypes...)> MakeConnectableDelegate(TReturnType (TDelegate::*in_func)(TArgTypes...))\n    {\n        return ConnectableDelegate<TReturnType(TArgTypes...)>(std::function<TReturnType(TArgTypes...)>(in_func));\n    }\n    //------------------------------------------------------------------\n    /// Constructs a connectable delegate to a member function with a signature that\n    /// matches the given return and parameter types.\n    ///\n    /// @author S Downie\n    ///\n    /// @param Instance whose function to call\n    /// @param Member function ptr\n    ///\n    /// @return Delegate\n    //------------------------------------------------------------------\n    template <typename TDelegate, typename TSender, typename TReturnType, typename... TArgTypes>\n    ConnectableDelegate<TReturnType(TArgTypes...)> MakeConnectableDelegate(TSender* in_sender, TReturnType (TDelegate::*in_func)(TArgTypes...))\n    {\n        return ConnectableDelegate<TReturnType(TArgTypes...)>([=](TArgTypes... in_args) { return (in_sender->*in_func)(in_args...); });\n    }\n    //------------------------------------------------------------------\n    /// Constructs a connectable delegate to a const member function with a signature\n    /// that matches the given return and parameter types.\n    ///\n    /// @author S Downie\n    ///\n    /// @param Instance whose function to call\n    /// @param Const member function ptr\n    ///\n    /// @return Delegate\n    //------------------------------------------------------------------\n    template <typename TDelegate, typename TSender, typename TReturnType, typename... TArgTypes>\n    ConnectableDelegate<TReturnType(TArgTypes...)> MakeConnectableDelegate(TSender* in_sender, TReturnType (TDelegate::*in_func)(TArgTypes...) const)\n    {\n        return ConnectableDelegate<TReturnType(TArgTypes...)>([=](TArgTypes... in_args) { return (in_sender->*in_func)(in_args...); });\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Delegate/MakeDelegate.h",
    "content": "//\n//  MakeDelegate.h\n//  ChilliSource\n//  Created by Scott Downie on 25/02/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_DELEGATE_MAKEDELEGATE_H_\n#define _CHILLISOURCE_CORE_DELEGATE_MAKEDELEGATE_H_\n\n#include <functional>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------\n    /// Constructs a delegate to a free function with a signature that\n    /// matches the given return and parameter types.\n    ///\n    /// @author S Downie\n    ///\n    /// @param Function ptr\n    ///\n    /// @return Delegate\n    //------------------------------------------------------------------\n    template <typename TReturnType, typename... TArgTypes>\n    std::function<TReturnType(TArgTypes...)> MakeDelegate(TReturnType (*in_func)(TArgTypes...))\n    {\n        return std::function<TReturnType(TArgTypes...)>(in_func);\n    }\n    //------------------------------------------------------------------\n    /// Constructs a delegate to a static function with a signature that\n    /// matches the given return and parameter types.\n    ///\n    /// @author S Downie\n    ///\n    /// @param Static function ptr\n    ///\n    /// @return Delegate\n    //------------------------------------------------------------------\n    template <typename TDelegate, typename TReturnType, typename... TArgTypes>\n    std::function<TReturnType(TArgTypes...)> MakeDelegate(TReturnType (TDelegate::*in_func)(TArgTypes...))\n    {\n        return std::function<TReturnType(TArgTypes...)>(in_func);\n    }\n    //------------------------------------------------------------------\n    /// Constructs a delegate to a member function with a signature that\n    /// matches the given return and parameter types.\n    ///\n    /// @author S Downie\n    ///\n    /// @param Instance whose function to call\n    /// @param Member function ptr\n    ///\n    /// @return Delegate\n    //------------------------------------------------------------------\n    template <typename TDelegate, typename TSender, typename TReturnType, typename... TArgTypes>\n    std::function<TReturnType(TArgTypes...)> MakeDelegate(TSender* in_sender, TReturnType (TDelegate::*in_func)(TArgTypes...))\n    {\n        return [=](TArgTypes... in_args) -> TReturnType { return (in_sender->*in_func)(in_args...); };\n    }\n    //------------------------------------------------------------------\n    /// Constructs a delegate to a const member function with a signature\n    /// that matches the given return and parameter types.\n    ///\n    /// @author S Downie\n    ///\n    /// @param Instance whose function to call\n    /// @param Const member function ptr\n    ///\n    /// @return Delegate\n    //------------------------------------------------------------------\n    template <typename TDelegate, typename TSender, typename TReturnType, typename... TArgTypes>\n    std::function<TReturnType(TArgTypes...)> MakeDelegate(const TSender* in_sender, TReturnType (TDelegate::*in_func)(TArgTypes...) const)\n    {\n        return [=](TArgTypes... in_args) -> TReturnType { return (in_sender->*in_func)(in_args...); };\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Delegate.h",
    "content": "//\n//  Delegate.h\n//  ChilliSource\n//  Created by Ian Copland on 07/07/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_DELEGATE_H_\n#define _CHILLISOURCE_CORE_DELEGATE_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Delegate/ConnectableDelegate.h>\n#include <ChilliSource/Core/Delegate/DelegateConnection.h>\n#include <ChilliSource/Core/Delegate/MakeConnectableDelegate.h>\n#include <ChilliSource/Core/Delegate/MakeDelegate.h>\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/DialogueBox/DialogueBoxSystem.cpp",
    "content": "//\n//  DialogueBoxSystem.cpp\n//  ChilliSource\n//  Created by Ian Copland on 04/03/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Core/DialogueBox/DialogueBoxSystem.h>\n\n#ifdef CS_TARGETPLATFORM_IOS\n#include <CSBackend/Platform/iOS/Core/DialogueBox/DialogueBoxSystem.h>\n#endif\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n#include <CSBackend/Platform/Android/Main/JNI/Core/DialogueBox/DialogueBoxSystem.h>\n#endif\n\n#ifdef CS_TARGETPLATFORM_WINDOWS\n#include <CSBackend/Platform/Windows/Core/DialogueBox/DialogueBoxSystem.h>\n#endif\n\nnamespace ChilliSource\n{\n    CS_DEFINE_NAMEDTYPE(DialogueBoxSystem);\n    //----------------------------------------------------\n    //----------------------------------------------------\n    DialogueBoxSystemUPtr DialogueBoxSystem::Create()\n    {\n#ifdef CS_TARGETPLATFORM_IOS\n        return DialogueBoxSystemUPtr(new CSBackend::iOS::DialogueBoxSystem());\n#elif defined CS_TARGETPLATFORM_ANDROID\n        return DialogueBoxSystemUPtr(new CSBackend::Android::DialogueBoxSystem());\n#elif defined CS_TARGETPLATFORM_WINDOWS\n        return DialogueBoxSystemUPtr(new CSBackend::Windows::DialogueBoxSystem());\n#else\n        return nullptr;\n#endif\n    }\n    //----------------------------------------------------\n    //----------------------------------------------------\n    DialogueBoxSystem::~DialogueBoxSystem()\n    {\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Core/DialogueBox/DialogueBoxSystem.h",
    "content": "//\n//  DialogueBoxSystem.h\n//  ChilliSource\n//  Created by Ian Copland on 04/03/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_DIALOGUE_DIALOGUESYSTEM_H_\n#define _CHILLISOURCE_CORE_DIALOGUE_DIALOGUESYSTEM_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/System/AppSystem.h>\n\n#include <functional>\n\nnamespace ChilliSource\n{\n    //-----------------------------------------------------------\n    /// A system used to display platform specific system\n    /// dialogue boxes.\n    ///\n    /// @author Ian Copland\n    //-----------------------------------------------------------\n    class DialogueBoxSystem : public AppSystem\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(DialogueBoxSystem);\n        //----------------------------------------------------\n        /// An enum describing the possible results from a\n        /// dialogue box.\n        ///\n        /// @author Ian Copland\n        //----------------------------------------------------\n        enum class DialogueResult\n        {\n            k_confirm,\n            k_cancel\n        };\n        //----------------------------------------------------\n        /// A delegate called when a dialogue box has been\n        /// dismissed.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The Id of the dialogue box.\n        /// @param The result.\n        //----------------------------------------------------\n        typedef std::function<void(u32, DialogueResult)> DialogueDelegate;\n        //-----------------------------------------------------\n        /// Display a system dialog with the given ID and delegate\n        ///\n        /// This isn't thread-safe and must be called on the main thread.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param ID\n        /// @param SystemConfirmDialogDelegate\n        /// @param Title text (UTF-8)\n        /// @param Message text (UTF-8)\n        /// @param Confirm text (UTF-8)\n        //------------------------------------------------------\n        virtual void ShowSystemDialogue(u32 in_id, const DialogueDelegate& in_delegate, const std::string& in_title, const std::string& in_message, const std::string& in_confirm) = 0;\n        //-----------------------------------------------------\n        /// Display a system confirmation dialog with the given\n        /// ID and delegate.\n        ///\n        /// This isn't thread-safe and must be called on the main thread.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param ID\n        /// @param SystemConfirmDialogDelegate\n        /// @param Title text (UTF-8)\n        /// @param Message text (UTF-8)\n        /// @param Confirm text (UTF-8)\n        /// @param Cancel text (UTF-8)\n        //-----------------------------------------------------\n        virtual void ShowSystemConfirmDialogue(u32 in_id, const DialogueDelegate& in_delegate, const std::string& in_title, const std::string& in_message, const std::string& in_confirm, const std::string& in_cancel) = 0;\n        //-----------------------------------------------------\n        /// Display a toast notification with the given text\n        ///\n        /// This isn't thread-safe and must be called on the main thread.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The text to display (UTF-8).\n        //-----------------------------------------------------\n        virtual void MakeToast(const std::string& in_text) = 0;\n        //----------------------------------------------------\n        /// Destructor.\n        ///\n        /// @author Ian Copland\n        //----------------------------------------------------\n        virtual ~DialogueBoxSystem();\n        \n    protected:\n        friend class Application;\n        \n        //----------------------------------------------------\n        /// Creates a new instance of this system.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @return The new instance.\n        //----------------------------------------------------\n        static DialogueBoxSystemUPtr Create();\n        //-------------------------------------------------------\n        /// Private constructor to force use of factory method\n        ///\n        /// @author S Downie\n        //-------------------------------------------------------\n        DialogueBoxSystem() = default;\n    };\n}\n\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/DialogueBox.h",
    "content": "//\n//  DialogueBox.h\n//  ChilliSource\n//  Created by Ian Copland on 07/07/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_DIALOGUEBOX_H_\n#define _CHILLISOURCE_CORE_DIALOGUEBOX_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/DialogueBox/DialogueBoxSystem.h>\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Entity/Component.cpp",
    "content": "//\n//  Component.cpp\n//  ChilliSource\n//  Created by Stuart McGaw on 28/09/2010.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2010 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Core/Entity/Component.h>\n\n#include <ChilliSource/Core/Entity/Entity.h>\n\nnamespace ChilliSource\n{\n    //----------------------------------------------------\n    //----------------------------------------------------\n    Component::Component()\n    : m_entity(nullptr)\n    {\n        \n    }\n    //----------------------------------------------------\n    //----------------------------------------------------\n    Entity * Component::GetEntity()\n    {\n        return m_entity;\n    }\n    //----------------------------------------------------\n    //----------------------------------------------------\n    const Entity * Component::GetEntity() const\n    {\n        return m_entity;\n    }\n    //----------------------------------------------------\n    //----------------------------------------------------\n    void Component::SetEntity(Entity* in_newOwner)\n    {\n        m_entity = in_newOwner;\n    }\n    //----------------------------------------------------\n    //----------------------------------------------------\n    void Component::RemoveFromEntity()\n    {\n        CS_ASSERT(m_entity != nullptr, \"Must have an entity to remove from\");\n        m_entity->RemoveComponent(this);\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Core/Entity/Component.h",
    "content": "//\n//  Component.h\n//  ChilliSource\n//  Created by Stuart McGaw on 28/09/2010.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2010 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_ENTITY_COMPONENT_H_\n#define _CHILLISOURCE_CORE_ENTITY_COMPONENT_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Base/QueryableInterface.h>\n\nnamespace ChilliSource\n{\n    class Component : public QueryableInterface\n    {\n    public:\n        CS_DECLARE_NOCOPY(Component);\n        //----------------------------------------------------\n        /// Constructor\n        ///\n        /// @author S McGaw\n        //----------------------------------------------------\n        Component();\n        //----------------------------------------------------\n        /// Destructor\n        ///\n        /// @author S McGaw\n        //----------------------------------------------------\n        virtual ~Component(){}\n        //----------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Entity to which component is attached or\n        /// null.\n        //----------------------------------------------------\n        Entity * GetEntity();\n        //----------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Const entity to which component is attached\n        /// or null.\n        //----------------------------------------------------\n        const Entity * GetEntity() const;\n        //----------------------------------------------------\n        /// Remove the component from its owning entity\n        ///\n        /// @author S Downie\n        //----------------------------------------------------\n        void RemoveFromEntity();\n        \n    protected:\n    \n        //----------------------------------------------------\n        /// Triggered when the component is attached to\n        /// an entity. Custom components should override this\n        /// as they see fit\n        ///\n        /// @author S McGaw\n        //----------------------------------------------------\n        virtual void OnAddedToEntity(){}\n        //----------------------------------------------------\n        /// Triggered when the component is attached to\n        /// an entity and that entity is on a scene.\n        /// Custom components should override this as they see\n        /// fit\n        ///\n        /// @author S Downie\n        //----------------------------------------------------\n        virtual void OnAddedToScene(){}\n        //----------------------------------------------------\n        /// Called when the application is resumed while the\n        /// component's owning entity is in a scene. This will\n        /// also be called when the owning entity is added to\n        /// the scene if the application is currently active,\n        /// or when the component is added to the entity if the\n        /// entity is already in the scene.\n        ///\n        /// @author Ian Copland\n        //----------------------------------------------------\n        virtual void OnResume(){}\n        //----------------------------------------------------\n        /// Called when the application is foregrounded while\n        /// the entity is in the scene. This will also be called\n        /// when the entity is added to the scene if the application\n        /// is currently foregrounded, or when the component is\n        /// added to the entity if the entity is already in\n        /// the scene.\n        ///\n        /// @author Ian Copland\n        //----------------------------------------------------\n        virtual void OnForeground(){}\n        //----------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Time since last update in seconds\n        //----------------------------------------------------\n        virtual void OnUpdate(f32 in_timeSinceLastUpdate){}\n        //----------------------------------------------------\n        /// Fixed update is triggered at fixed time periods\n        ///\n        /// @author S Downie\n        ///\n        /// @param Time since last fixed update in seconds\n        //----------------------------------------------------\n        virtual void OnFixedUpdate(f32 in_fixedTimeSinceLastUpdate){}\n        //----------------------------------------------------\n        /// The render snapshot event can be implemented by a\n        /// component to allow it to snapshot any data  which\n        /// pertains to the renderer.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param in_renderSnapshot - The render snapshot\n        /// object which contains all snapshotted data.\n        /// @param frameAllocator - Use this to allocate any memory\n        /// for this render frame\n        //----------------------------------------------------\n        virtual void OnRenderSnapshot(RenderSnapshot& renderSnapshot, IAllocator* frameAllocator) noexcept {};\n        //----------------------------------------------------\n        /// Called when the application is backgrounded while\n        /// the owning entity is in the scene. This will also\n        /// be called when the owning entity is removed from\n        /// the scene if the application is currently\n        /// foregrounded or when the component is removed while\n        /// the entity is in the scene.\n        ///\n        /// @author Ian Copland\n        //----------------------------------------------------\n        virtual void OnBackground(){}\n        //----------------------------------------------------\n        /// Called when the application is backgrounded while\n        /// the owning entity is in the scene. This will also be\n        /// called when the owning entity is removed from the\n        /// scene if the application is currently active or\n        /// when the component is removed while the entity is\n        /// in the scene.\n        ///\n        /// @author Ian Copland\n        //----------------------------------------------------\n        virtual void OnSuspend(){}\n        //----------------------------------------------------\n        /// Triggered when the component is removed from\n        /// an entity or when the entity is removed from the\n        /// scene. Custom components should override this as\n        /// they see fit\n        ///\n        /// @author S Downie\n        //----------------------------------------------------\n        virtual void OnRemovedFromScene(){}\n        //----------------------------------------------------\n        /// Triggered when the component is removed from\n        /// an entity. Custom components should override this\n        /// as they see fit\n        ///\n        /// @author S McGaw\n        //----------------------------------------------------\n        virtual void OnRemovedFromEntity(){}\n    private:\n        \n        friend class Entity;\n        //----------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Entity to which component is attached\n        //----------------------------------------------------\n        void SetEntity(Entity* in_newOwner);\n\n    private:\n        \n        Entity * m_entity;\n    };\n}\n\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Entity/Entity.cpp",
    "content": "//\n//  Entity.cpp\n//  ChilliSource\n//  Created by Scott Downie on 21/09/2010.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2010 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Core/Entity/Entity.h>\n#include <ChilliSource/Core/Scene/Scene.h>\n#include <ChilliSource/Core/String/StringUtils.h>\n\n#include <algorithm>\n\nnamespace ChilliSource\n{\n    namespace\n    {\n        const EntitySPtr EntityNullPtr;\n        const ComponentSPtr ComponentNullPtr;\n    }\n    \n    //------------------------------------------------------------------\n    //------------------------------------------------------------------\n    EntityUPtr Entity::Create()\n    {\n        return EntityUPtr(new Entity());\n    }\n    //-------------------------------------------------------------\n    //-------------------------------------------------------------\n    void Entity::AddEntity(const EntitySPtr& in_child)\n    {\n        CS_ASSERT(in_child != nullptr, \"Cannot add null child\");\n        CS_ASSERT(in_child->GetParent() == nullptr, \"Cannot add child with existing parent\");\n        CS_ASSERT(in_child->GetScene() == nullptr, \"Cannot add child with existing scene\");\n        CS_ASSERT(m_children.size() < static_cast<std::vector<EntitySPtr>::size_type>(std::numeric_limits<u32>::max()), \"There are too many child entities. It cannot exceed \"\n                  + ToString(std::numeric_limits<u32>::max()) + \".\");\n        \n        m_children.push_back(in_child);\n        m_transform.AddChildTransform(&in_child->GetTransform());\n        in_child->m_parent = this;\n        \n        if(m_scene != nullptr)\n        {\n            //This will add the entity and any children it may have\n            m_scene->Add(in_child);\n        }\n    }\n    //-------------------------------------------------------------\n    //-------------------------------------------------------------\n    void Entity::RemoveEntity(Entity* in_child)\n    {\n        CS_ASSERT(in_child != nullptr, \"Cannot remove null child\");\n        CS_ASSERT(in_child->GetParent() == this, \"Cannot remove entity that is not a child of this\");\n        \n        SharedEntityList::iterator it = std::find_if(m_children.begin(), m_children.end(), [in_child](const EntitySPtr& in_entity)\n        {\n            return in_entity.get() == in_child;\n        });\n        \n        if(it != m_children.end())\n        {\n            m_transform.RemoveChildTransform(&in_child->GetTransform());\n            \n            if(m_scene != nullptr)\n            {\n                m_scene->Remove(in_child);\n            }\n            \n            in_child->m_parent = nullptr;\n            std::swap(m_children.back(), *it);\n            m_children.pop_back();\n        }\n    }\n    //-------------------------------------------------------------\n    //-------------------------------------------------------------\n    void Entity::RemoveAllChildren()\n    {\n        m_transform.RemoveAllChildTransforms();\n        \n        for(SharedEntityList::iterator it = m_children.begin(); it != m_children.end(); ++it)\n        {\n            if(m_scene != nullptr)\n            {\n                m_scene->Remove(it->get());\n            }\n            \n            (*it)->m_parent = nullptr;\n        }\n        \n        m_children.clear();\n    }\n    //-------------------------------------------------------------\n    //-------------------------------------------------------------\n    void Entity::RemoveFromParent()\n    {\n        CS_ASSERT(m_parent != nullptr || m_scene != nullptr, \"Must have a parent to remove from\");\n        \n        if(m_parent != nullptr)\n        {\n            m_parent->RemoveEntity(this);\n        }\n        else if(m_scene != nullptr)\n        {\n            m_scene->Remove(this);\n        }\n    }\n    //------------------------------------------------------------------\n    //------------------------------------------------------------------\n    Entity* Entity::GetParent() \n    { \n        return m_parent;\n    }\n    //------------------------------------------------------------------\n    //------------------------------------------------------------------\n    const Entity* Entity::GetParent() const\n    {\n        return m_parent;\n    }\n    //------------------------------------------------------------------\n    //------------------------------------------------------------------\n    const EntitySPtr& Entity::GetEntityWithName(const std::string& in_name) const\n    {\n        for(SharedEntityList::const_iterator it = m_children.begin(); it != m_children.end(); ++it)\n        {\n            if((*it)->GetName() == in_name)\n            {\n                return (*it);\n            }\n        }\n        \n        return EntityNullPtr;\n    }\n    //------------------------------------------------------------------\n    //------------------------------------------------------------------\n    const EntitySPtr& Entity::GetEntityWithNameRecursive(const std::string& in_name) const\n    {\n        for (SharedEntityList::const_iterator it = m_children.begin(); it != m_children.end(); ++it)\n        {\n            if((*it)->GetName() == in_name)\n            {\n                return (*it);\n            }\n            \n            const EntitySPtr& entity = (*it)->GetEntityWithNameRecursive(in_name);\n            if (entity != nullptr)\n            {\n                return entity;\n            }\n        }\n        \n        return EntityNullPtr;\n    }\n    //------------------------------------------------------------------\n    //------------------------------------------------------------------\n    u32 Entity::GetNumEntities() const\n    {\n        return static_cast<u32>(m_children.size());\n    }\n    //------------------------------------------------------------------\n    //------------------------------------------------------------------\n    u32 Entity::GetNumComponents() const\n    {\n        return static_cast<u32>(m_components.size());\n    }\n    //------------------------------------------------------------------\n    //------------------------------------------------------------------\n    const SharedEntityList& Entity::GetEntities() const\n    {\n        return m_children;\n    }\n    //-------------------------------------------------------------\n    //-------------------------------------------------------------\n    void Entity::SetScene(Scene* in_scene)\n    {\n        m_scene = in_scene;\n    }\n    //-------------------------------------------------------------\n    //-------------------------------------------------------------\n    void Entity::AddComponent(const ComponentSPtr& in_component)\n    {\n        CS_ASSERT(in_component != nullptr, \"Cannot add null component\");\n        CS_ASSERT(in_component->GetEntity() == nullptr, \"Component cannot be attached to more than 1 entity at a time.\");\n        CS_ASSERT(m_components.size() < static_cast<std::vector<ComponentSPtr>::size_type>(std::numeric_limits<u32>::max()), \"There are too many components. It cannot exceed \"\n                  + ToString(std::numeric_limits<u32>::max()) + \".\");\n        \n        m_components.push_back(in_component);\n        \n        in_component->SetEntity(this);\n        \n        in_component->OnAddedToEntity();\n        \n        if(GetScene() != nullptr)\n        {\n            in_component->OnAddedToScene();\n            if (m_appActive == true)\n            {\n                in_component->OnResume();\n                if (m_appForegrounded == true)\n                {\n                    in_component->OnForeground();\n                }\n            }\n        }\n    }\n    //-------------------------------------------------------------\n    //-------------------------------------------------------------\n    void Entity::RemoveComponent(Component* in_component)\n    {\n        CS_ASSERT(in_component != nullptr, \"Cannot remove a null component\");\n        CS_ASSERT(in_component->GetEntity() == this, \"Cannot remove component that is not attached to this.\");\n        \n        for(ComponentList::iterator it = m_components.begin(); it != m_components.end(); ++it)\n        {\n            if(in_component == it->get())\n            {\n                if(GetScene() != nullptr)\n                {\n                    if (m_appActive == true)\n                    {\n                        if (m_appForegrounded == true)\n                        {\n                            in_component->OnBackground();\n                        }\n                        in_component->OnSuspend();\n                    }\n                    in_component->OnRemovedFromScene();\n                }\n                \n                in_component->OnRemovedFromEntity();\n                in_component->SetEntity(nullptr);\n                \n                std::swap(m_components.back(), *it);\n                m_components.pop_back();\n                return;\n            }\n        }\n    }\n    //-------------------------------------------------------------\n    //-------------------------------------------------------------\n    void Entity::RemoveAllComponents()\n    {\n        for(ComponentList::iterator it = m_components.begin(); it != m_components.end(); ++it)\n        {\n            Component* component = it->get();\n            \n            if(GetScene() != nullptr)\n            {\n                if (m_appActive == true)\n                {\n                    if (m_appForegrounded == true)\n                    {\n                        component->OnBackground();\n                    }\n                    component->OnSuspend();\n                }\n                component->OnRemovedFromScene();\n            }\n            \n            component->OnRemovedFromEntity();\n            component->SetEntity(nullptr);\n        }\n        \n        m_components.clear();\n    }\n    //-------------------------------------------------------------\n    //-------------------------------------------------------------\n    const ComponentSPtr& Entity::GetComponent(InterfaceIDType in_interfaceId) const\n    {\n        for(ComponentList::const_iterator itr = m_components.begin(); itr != m_components.end(); ++itr)\n        {\n            if((*itr)->IsA(in_interfaceId))\n            {\n                return *itr;\n            }\n        }\n        \n        return ComponentNullPtr;\n    }\n    //-------------------------------------------------------------\n    //-------------------------------------------------------------\n    void Entity::GetComponents(InterfaceIDType in_interfaceId, std::vector<ComponentSPtr>& out_components) const\n    {\n        for (ComponentList::const_iterator itr = m_components.begin(); itr != m_components.end(); ++itr)\n        {\n            if ((*itr)->IsA(in_interfaceId))\n            {\n                out_components.push_back(*itr);\n            }\n        }\n    }\n    //-------------------------------------------------------------\n    //-------------------------------------------------------------\n    const ComponentSPtr& Entity::GetComponentRecursive(InterfaceIDType in_interfaceId) const\n    {\n        for(ComponentList::const_iterator itr = m_components.begin(); itr != m_components.end(); ++itr)\n        {\n            if((*itr)->IsA(in_interfaceId))\n            {\n                return *itr;\n            }\n        }\n        \n        for(SharedEntityList::const_iterator itr = m_children.begin(); itr != m_children.end(); ++itr)\n        {\n            const ComponentSPtr& component = (*itr)->GetComponentRecursive(in_interfaceId);\n            \n            if(component != nullptr)\n            {\n                return component;\n            }\n        }\n        \n        return ComponentNullPtr;\n    }\n    //------------------------------------------------------------------\n    //------------------------------------------------------------------\n    const ComponentList& Entity::GetComponents() const\n    {\n        return m_components;\n    }\n    //-------------------------------------------------------------\n    //-------------------------------------------------------------\n    void Entity::SetName(const std::string& in_name)\n    {\n        m_name = in_name;\n    }\n    //-------------------------------------------------------------\n    //-------------------------------------------------------------\n    const std::string & Entity::GetName() const\n    {\n        return m_name;\n    }\n    //-------------------------------------------------------------\n    //-------------------------------------------------------------\n    Scene* Entity::GetScene()\n    {\n        return m_scene;\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    Transform& Entity::GetTransform()\n    {\n        return m_transform;\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    const Transform& Entity::GetTransform() const\n    {\n        return m_transform;\n    }\n    //----------------------------------------------------\n    //----------------------------------------------------\n    void Entity::OnUpdate(f32 in_timeSinceLastUpdate)\n    {\n        for(u32 i=0; i<m_components.size(); ++i)\n        {\n            m_components[i]->OnUpdate(in_timeSinceLastUpdate);\n        }\n    }\n    //-------------------------------------------------------------\n    //-------------------------------------------------------------\n    void Entity::OnAddedToScene()\n    {\n        for (u32 i = 0; i < m_components.size(); ++i)\n        {\n            m_components[i]->OnAddedToScene();\n        }\n        \n        for (u32 i = 0; i < m_children.size(); ++i)\n        {\n            m_scene->Add(m_children[i]);\n        }\n    }\n    //-------------------------------------------------------------\n    //-------------------------------------------------------------\n    void Entity::OnResume()\n    {\n        CS_ASSERT(m_appActive == false, \"Entity: Received resume while already active.\");\n        \n        m_appActive = true;\n        for (u32 i = 0; i < m_components.size(); ++i)\n        {\n            m_components[i]->OnResume();\n        }\n    }\n    //-------------------------------------------------------------\n    //-------------------------------------------------------------\n    void Entity::OnForeground()\n    {\n        CS_ASSERT(m_appForegrounded == false, \"Entity: Received foreground while already foregrounded.\");\n        \n        m_appForegrounded = true;\n        for (u32 i = 0; i < m_components.size(); ++i)\n        {\n            m_components[i]->OnForeground();\n        }\n    }\n    //-------------------------------------------------------------\n    //-------------------------------------------------------------\n    void Entity::OnRemovedFromScene()\n    {\n        for (auto it = m_children.rbegin(); it != m_children.rend(); ++it)\n        {\n            m_scene->Remove((*it).get());\n        }\n        \n        for (auto it = m_components.rbegin(); it != m_components.rend(); ++it)\n        {\n            (*it)->OnRemovedFromScene();\n        }\n    }\n    //----------------------------------------------------\n    //----------------------------------------------------\n    void Entity::OnFixedUpdate(f32 in_fixedTimeSinceLastUpdate)\n    {\n        for(u32 i=0; i<m_components.size(); ++i)\n        {\n            m_components[i]->OnFixedUpdate(in_fixedTimeSinceLastUpdate);\n        }\n    }\n    //-------------------------------------------------------------\n    //-------------------------------------------------------------\n    void Entity::OnRenderSnapshot(RenderSnapshot& renderSnapshot, IAllocator* frameAllocator) noexcept\n    {\n        for(u32 i=0; i<m_components.size(); ++i)\n        {\n            m_components[i]->OnRenderSnapshot(renderSnapshot, frameAllocator);\n        }\n    }\n    //-------------------------------------------------------------\n    //-------------------------------------------------------------\n    void Entity::OnBackground()\n    {\n        CS_ASSERT(m_appForegrounded == true, \"Entity: Received background while already backgrounded.\");\n        \n        m_appForegrounded = false;\n        \n        for (auto it = m_components.rbegin(); it != m_components.rend(); ++it)\n        {\n            (*it)->OnBackground();\n        }\n    }\n    //-------------------------------------------------------------\n    //-------------------------------------------------------------\n    void Entity::OnSuspend()\n    {\n        CS_ASSERT(m_appActive == true, \"Entity: Received suspend while already suspended.\");\n        \n        m_appActive = false;\n        \n        for (auto it = m_components.rbegin(); it != m_components.rend(); ++it)\n        {\n            (*it)->OnSuspend();\n        }\n    }\n    //------------------------------------------------------------------\n    //------------------------------------------------------------------\n    void Entity::Reset()\n    {\n        RemoveAllComponents();\n        RemoveAllChildren();\n        RemoveFromParent();\n        \n        m_name = std::string();\n        m_transform.Reset();\n    }\n    //-------------------------------------------------------------\n    //-------------------------------------------------------------\n    Entity::~Entity()\n    {\n        RemoveAllComponents();\n        RemoveAllChildren();\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Core/Entity/Entity.h",
    "content": "//\n//  Entity.h\n//  ChilliSource\n//  Created by Scott Downie on 21/09/2010.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2010 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_ENTITY_ENTITY_H_\n#define _CHILLISOURCE_CORE_ENTITY_ENTITY_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Entity/Component.h>\n#include <ChilliSource/Core/Entity/Transform.h>\n\n#ifdef CS_ENABLE_ENTITYLINKEDLIST\n#include <list>\n#else\n#include <vector>\n#endif\n\nnamespace ChilliSource\n{\n    typedef std::vector<ComponentSPtr> ComponentList;\n    \n#ifdef CS_ENABLE_ENTITYLINKEDLIST\n    typedef std::list<EntitySPtr> SharedEntityList;\n    typedef std::list<Entity*> EntityList;\n#else\t\t\n    typedef std::vector<EntitySPtr> SharedEntityList;\n    typedef std::vector<Entity*> EntityList;\n#endif\n    \n    //--------------------------------------------------------------------------------------------------\n    /// A game object that's behaviour is defined by its components\n    //--------------------------------------------------------------------------------------------------\n    class Entity final : public std::enable_shared_from_this<Entity>\n    {\t\n    public:\n        CS_DECLARE_NOCOPY(Entity);\n        //------------------------------------------------------------------\n        /// Factory method to create an empty entity\n        ///\n        /// @author S Downie\n        ///\n        /// @return Entity\n        //------------------------------------------------------------------\n        static EntityUPtr Create();\n        \n        //----------------------------------------------------------------\n        /// Destructor\n        ///\n        /// @author S Downie\n        //----------------------------------------------------------------\n        ~Entity();\n        //----------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Transform object to allow for spatial manipulation\n        //----------------------------------------------------------------\n        Transform& GetTransform();\n        //----------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Transform object to allow for spatial manipulation\n        //----------------------------------------------------------------\n        const Transform& GetTransform() const;\n        //-------------------------------------------------------------\n        /// Get Scene\n        ///\n        /// @return Scene owner\n        //-------------------------------------------------------------\n        Scene* GetScene();\n        //-------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Whether the entity has component of type\n        //-------------------------------------------------------------\n        template <typename TComponentType>\n        bool HasA() const;\n        //-------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return The first component of type\n        //-------------------------------------------------------------\n        template <typename TComponentType>\n        std::shared_ptr<TComponentType> GetComponent();\n        //-------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return The first component of type\n        //-------------------------------------------------------------\n        template <typename TComponentType>\n        std::shared_ptr<const TComponentType> GetComponent() const;\n        //-------------------------------------------------------------\n        /// Search the list of components and add ones to the list\n        /// that are of given interface type\n        ///\n        /// @author S Downie\n        ///\n        /// @param [Out] Vector to populate with components\n        //-------------------------------------------------------------\n        template <typename TComponentType>\n        void GetComponents(std::vector<std::shared_ptr<TComponentType> >& out_components) const;\n        //-------------------------------------------------------------\n        /// Search the list of components and add ones to the list\n        /// that are of given interface type\n        ///\n        /// @author S Downie\n        ///\n        /// @param [Out] Vector to populate with components\n        //-------------------------------------------------------------\n        template <typename TComponentType>\n        void GetComponents(std::vector<TComponentType*>& out_components) const;\n        //-------------------------------------------------------------\n        /// Search the list of components and add ones to the lists\n        /// that are of given interface types\n        ///\n        /// @author S Downie\n        ///\n        /// @param [Out] Vector to populate with components type 1\n        /// @param [Out] Vector to populate with components type 2\n        //-------------------------------------------------------------\n        template <typename TComponentType1, typename TComponentType2>\n        void GetComponents(std::vector<std::shared_ptr<TComponentType1> >& out_components1, std::vector<std::shared_ptr<TComponentType2> >& out_components2) const;\n        //-------------------------------------------------------------\n        /// Search the list of components and add ones to the lists\n        /// that are of given interface types\n        ///\n        /// @author S Downie\n        ///\n        /// @param [Out] Vector to populate with components type 1\n        /// @param [Out] Vector to populate with components type 2\n        //-------------------------------------------------------------\n        template <typename TComponentType1, typename TComponentType2>\n        void GetComponents(std::vector<TComponentType1*>& out_components1, std::vector<TComponentType2*>& out_components2) const;\n        //-------------------------------------------------------------\n        /// Search the list of components and add ones to the lists\n        /// that are of given interface types\n        ///\n        /// @author S Downie\n        ///\n        /// @param [Out] Vector to populate with components type 1\n        /// @param [Out] Vector to populate with components type 2\n        /// @param [Out] Vector to populate with components type 3\n        //-------------------------------------------------------------\n        template <typename TComponentType1, typename TComponentType2, typename TComponentType3>\n        void GetComponents(std::vector<std::shared_ptr<TComponentType1> >& out_components1, std::vector<std::shared_ptr<TComponentType2> >& out_components2, std::vector<std::shared_ptr<TComponentType3> >& out_components3) const;\n        //-------------------------------------------------------------\n        /// Search the list of components and add ones to the lists\n        /// that are of given interface types\n        ///\n        /// @author S Downie\n        ///\n        /// @param [Out] Vector to populate with components type 1\n        /// @param [Out] Vector to populate with components type 2\n        /// @param [Out] Vector to populate with components type 3\n        //-------------------------------------------------------------\n        template <typename TComponentType1, typename TComponentType2, typename TComponentType3>\n        void GetComponents(std::vector<TComponentType1*>& out_components1, std::vector<TComponentType2*>& out_components2, std::vector<TComponentType3*>& out_components3) const;\n        //-------------------------------------------------------------\n        /// Recursively descend from the entity through its children\n        /// searching for components with given interface ID\n        ///\n        /// @author A Mackie\n        ///\n        /// @return the first component of the given type. This will recurse\n        /// into child entities\n        //-------------------------------------------------------------\n        template <typename TComponentType>\n        std::shared_ptr<TComponentType> GetComponentRecursive();\n        //-------------------------------------------------------------\n        /// Recursively descend from the entity through its children\n        /// searching for components with given interface ID\n        ///\n        /// @author A Mackie\n        ///\n        /// @return the first component of the given type. This will recurse\n        /// into child entities\n        //-------------------------------------------------------------\n        template <typename TComponentType>\n        std::shared_ptr<const TComponentType> GetComponentRecursive() const;\n        //-------------------------------------------------------------\n        /// Recursively descend from the entity through its children\n        /// searching for components with given interface ID\n        ///\n        /// @author A Mackie\n        ///\n        /// @return the first component of the given type. This will recurse\n        /// into child entities\n        //-------------------------------------------------------------\n        template <typename TComponentType>\n        void GetComponentsRecursive(std::vector<std::shared_ptr<TComponentType> >& out_components) const;\n        //-------------------------------------------------------------\n        /// Recursively descend from the entity through its children\n        /// searching for components with given interface ID\n        ///\n        /// @author A Mackie\n        ///\n        /// @return the first component of the given type. This will recurse\n        /// into child entities\n        //-------------------------------------------------------------\n        template <typename TComponentType>\n        void GetComponentsRecursive(std::vector<TComponentType*>& out_components);\n        //------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Array of components\n        //------------------------------------------------------------------\n        const ComponentList& GetComponents() const;\n        //-------------------------------------------------------------\n        /// Add a component to the entity. It will now receieve\n        /// entity lifecycle events. The entity will have shared\n        /// ownership of the component\n        ///\n        /// @author S Downie\n        ///\n        /// @param Component to attach to the entity\n        //-------------------------------------------------------------\n        void AddComponent(const ComponentSPtr& in_component);\n        //-------------------------------------------------------------\n        /// Remove a component from the entity. The component will no\n        /// longer be owned by the entity and will no longer receieve\n        /// entity lifecycle events.\n        ///\n        /// @author S Downie\n        ///\n        /// @param Component to remove from the entity\n        //-------------------------------------------------------------\n        void RemoveComponent(Component* in_component);\n        //-------------------------------------------------------------\n        /// Removes all components\n        ///\n        /// @author S Downie\n        //-------------------------------------------------------------\n        void RemoveAllComponents();\n        //-------------------------------------------------------------\n        /// Add an entity as a child. This will link the transforms\n        /// in a hierarchy and will link lifecycle and scene events\n        ///\n        /// @author S Downie\n        ///\n        /// @param Entity\n        //-------------------------------------------------------------\n        void AddEntity(const EntitySPtr& in_child);\n        //-------------------------------------------------------------\n        /// Remove an entity as a child. This will unlink the transforms\n        /// in a hierarchy and will unlink lifecycle and scene events\n        ///\n        /// @param Entity\n        //-------------------------------------------------------------\n        void RemoveEntity(Entity* in_child);\n        //-------------------------------------------------------------\n        /// Detach the entity from its parent. If it has no parent\n        /// then remove it from the scene\n        ///\n        /// @author S Downie\n        //-------------------------------------------------------------\n        void RemoveFromParent();\n        //-------------------------------------------------------------\n        /// Remove All Children\n        ///\n        /// @author S Downie\n        //-------------------------------------------------------------\n        void RemoveAllChildren();\n        //-------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Name\n        //-------------------------------------------------------------\n        void SetName(const std::string& in_name);\n        //-------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Entity name\n        //-------------------------------------------------------------\n        const std::string & GetName() const;\n        //------------------------------------------------------------------\n        /// Return the parent entity of this entity. nullptr is returned if\n        /// there is no parent.\n        ///\n        /// @author T Kane\n        ///\n        /// @return Pointer to the parent entity or null\n        //------------------------------------------------------------------\n        Entity* GetParent();\n        //------------------------------------------------------------------\n        /// Return the parent entity of this entity. nullptr is returned if\n        /// there is no parent.\n        ///\n        /// @author HMcLaughlin\n        ///\n        /// @return Const Pointer to the parent entity or null\n        //------------------------------------------------------------------\n        const Entity* GetParent() const;\n        //------------------------------------------------------------------\n        /// Search only immediate children to find an entity and return a pointer\n        /// to the first entity it finds with the name matching that given,\n        /// or nullptr if no match found.\n        ///\n        /// @return An entity with the specified name or null\n        //------------------------------------------------------------------\n        const EntitySPtr& GetEntityWithName(const std::string& in_name) const;\n        //------------------------------------------------------------------\n        /// Recursively search the entity hierarchy in a depth-first manner\n        /// and return a pointer to the first entity it finds with the name matching\n        /// given, or nullptr if no match found.\n        ///\n        /// @author A Mackie\n        ///\n        /// @return An entity with the specified name or null\n        //------------------------------------------------------------------\n        const EntitySPtr& GetEntityWithNameRecursive(const std::string& in_name) const;\n        //------------------------------------------------------------------\n        /// @author A Mackie\n        ///\n        /// @return the number of child entities\n        //------------------------------------------------------------------\n        u32 GetNumEntities() const;\n        //------------------------------------------------------------------\n        /// @author A Mackie\n        ///\n        /// @return the number of components\n        //------------------------------------------------------------------\n        u32 GetNumComponents() const;\n        //------------------------------------------------------------------\n        /// @author S Downie\n        /// \n        /// @return List of child entities\n        //------------------------------------------------------------------\n        const SharedEntityList& GetEntities() const;\n        //------------------------------------------------------------------\n        /// Utility function to reset an entity to blank slate\n        /// useful for pooling\n        ///\n        /// @author A Glass\n        //------------------------------------------------------------------\n        void Reset();\n        \n    private:\n        \n        friend class Scene;\n        //-------------------------------------------------------------\n        /// Private to enforce the use of the factory method\n        ///\n        /// @author S Downie\n        //-------------------------------------------------------------\n        Entity() = default;\n        //-------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Component type to find\n        ///\n        /// @return the first component of the given type\n        //-------------------------------------------------------------\n        const ComponentSPtr& GetComponent(InterfaceIDType in_interfaceId) const;\n        //-------------------------------------------------------------\n        /// Search the list of components and add ones to the list\n        /// that are of given interface type\n        ///\n        /// @author S Downie\n        ///\n        /// @param Component type to find\n        /// @param [Out] Vector to populate with components\n        //-------------------------------------------------------------\n        void GetComponents(InterfaceIDType in_interfaceId, std::vector<ComponentSPtr>& out_components) const;\n        //-------------------------------------------------------------\n        /// Recursively descend from the entity through its children\n        /// searching for components with given interface ID\n        ///\n        /// @author A Mackie\n        ///\n        /// @return the first component of the given type. This will recurse\n        /// into child entities\n        //-------------------------------------------------------------\n        const ComponentSPtr& GetComponentRecursive(InterfaceIDType in_interfaceId) const;\n        //-------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Scene\n        //-------------------------------------------------------------\n        void SetScene(Scene* inpScene);\n        //-------------------------------------------------------------\n        /// Called when the entity is added to the scene\n        ///\n        /// @author S Downie\n        //-------------------------------------------------------------\n        void OnAddedToScene();\n        //-------------------------------------------------------------\n        /// Called when the application is resumed while the entity is\n        /// in the scene. This will also be called when the entity is\n        /// added to the scene if the application is currently active.\n        ///\n        /// @author Ian Copland\n        //-------------------------------------------------------------\n        void OnResume();\n        //-------------------------------------------------------------\n        /// Called when the application is foregrounded while the entity\n        /// is in the scene. This will also be called when the entity\n        /// is added to the scene if the application is currently\n        /// foregrounded.\n        ///\n        /// @author Ian Copland\n        //-------------------------------------------------------------\n        void OnForeground();\n        //-------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Time since last update in seconds\n        //-------------------------------------------------------------\n        void OnUpdate(f32 in_timeSinceLastUpdate);\n        //-------------------------------------------------------------\n        /// Fixed update is triggered at fixed time periods\n        ///\n        /// @author S Downie\n        ///\n        /// @param Time since last fixed update in seconds\n        //-------------------------------------------------------------\n        void OnFixedUpdate(f32 in_fixedTimeSinceLastUpdate);\n        //-------------------------------------------------------------\n        /// Sends the render snapshot event onto all components.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param renderSnapshot - The render snapshot object which\n        /// contains all snapshotted data.\n        /// @param frameAllocator - Allocate any memory needed for rendering\n        /// a frame from here\n        //-------------------------------------------------------------\n        void OnRenderSnapshot(RenderSnapshot& renderSnapshot, IAllocator* frameAllocator) noexcept;\n        //-------------------------------------------------------------\n        /// Called when the application is backgrounded while the entity\n        /// is in the scene. This will also be called when the entity is\n        /// removed from the scene if the application is currently\n        /// foregrounded.\n        ///\n        /// @author Ian Copland\n        //-------------------------------------------------------------\n        void OnBackground();\n        //-------------------------------------------------------------\n        /// Called when the application is backgrounded while the entity\n        /// is in the scene. This will also be called when the entity is\n        /// removed from the scene if the application is currently active.\n        ///\n        /// @author Ian Copland\n        //-------------------------------------------------------------\n        void OnSuspend();\n        //-------------------------------------------------------------\n        /// Called when the entity is removed from the scene\n        ///\n        /// @author S Downie\n        //-------------------------------------------------------------\n        void OnRemovedFromScene();\n        \n    private:\n        \n        ComponentList m_components;\n        SharedEntityList m_children;\n        \n        Transform m_transform;\n        \n        std::string m_name;\n        \n        Entity* m_parent = nullptr;\n        Scene* m_scene = nullptr;\n        \n        bool m_appActive = false;\n        bool m_appForegrounded = false;\n    };\n    \n    //-------------------------------------------------------------\n    //-------------------------------------------------------------\n    template <typename TComponentType>\n    bool Entity::HasA() const\n    {\n        return GetComponent<TComponentType>() != nullptr;\n    }\n    //-------------------------------------------------------------\n    //-------------------------------------------------------------\n    template <typename TComponentType>\n    std::shared_ptr<TComponentType> Entity::GetComponent()\n    {\n        return std::static_pointer_cast<TComponentType>(GetComponent(TComponentType::InterfaceID));\n    }\n    //-------------------------------------------------------------\n    //-------------------------------------------------------------\n    template <typename TComponentType>\n    std::shared_ptr<const TComponentType> Entity::GetComponent() const\n    {\n        return std::static_pointer_cast<const TComponentType>(GetComponent(TComponentType::InterfaceID));\n    }\n    //-------------------------------------------------------------\n    //-------------------------------------------------------------\n    template <typename TComponentType>\n    void Entity::GetComponents(std::vector<std::shared_ptr<TComponentType> >& out_components) const\n    {\n        for (ComponentList::const_iterator it = m_components.begin(); it != m_components.end(); ++it)\n        {\n            if((*it)->IsA(TComponentType::InterfaceID))\n            {\n                out_components.push_back(std::static_pointer_cast<TComponentType>(*it));\n            }\n        }\n    }\n    //-------------------------------------------------------------\n    //-------------------------------------------------------------\n    template <typename TComponentType>\n    void Entity::GetComponents(std::vector<TComponentType*>& out_components) const\n    {\n        for (ComponentList::const_iterator it = m_components.begin(); it != m_components.end(); ++it)\n        {\n            if((*it)->IsA(TComponentType::InterfaceID))\n            {\n                out_components.push_back(static_cast<TComponentType*>(it->get()));\n            }\n        }\n    }\n    //-------------------------------------------------------------\n    //-------------------------------------------------------------\n    template <typename TComponentType1, typename TComponentType2>\n    void Entity::GetComponents(std::vector<std::shared_ptr<TComponentType1> >& out_components1, std::vector<std::shared_ptr<TComponentType2> >& out_components2) const\n    {\n        for (ComponentList::const_iterator it = m_components.begin(); it != m_components.end(); ++it)\n        {\n            if((*it)->IsA(TComponentType1::InterfaceID))\n            {\n                out_components1.push_back(std::static_pointer_cast<TComponentType1>(*it));\n            }\n            if((*it)->IsA(TComponentType2::InterfaceID))\n            {\n                out_components2.push_back(std::static_pointer_cast<TComponentType2>(*it));\n            }\n        }\n    }\n    //-------------------------------------------------------------\n    //-------------------------------------------------------------\n    template <typename TComponentType1, typename TComponentType2>\n    void Entity::GetComponents(std::vector<TComponentType1*>& out_components1, std::vector<TComponentType2*>& out_components2) const\n    {\n        for (ComponentList::const_iterator it = m_components.begin(); it != m_components.end(); ++it)\n        {\n            if((*it)->IsA(TComponentType1::InterfaceID))\n            {\n                out_components1.push_back(static_cast<TComponentType1*>(it->get()));\n            }\n            if((*it)->IsA(TComponentType2::InterfaceID))\n            {\n                out_components2.push_back(static_cast<TComponentType2*>(it->get()));\n            }\n        }\n    }\n    //-------------------------------------------------------------\n    //-------------------------------------------------------------\n    template <typename TComponentType1, typename TComponentType2, typename TComponentType3>\n    void Entity::GetComponents(std::vector<std::shared_ptr<TComponentType1> >& out_components1, std::vector<std::shared_ptr<TComponentType2> >& out_components2, std::vector<std::shared_ptr<TComponentType3> >& out_components3) const\n    {\n        for (ComponentList::const_iterator it = m_components.begin(); it != m_components.end(); ++it)\n        {\n            if((*it)->IsA(TComponentType1::InterfaceID))\n            {\n                out_components1.push_back(std::static_pointer_cast<TComponentType1>(*it));\n            }\n            if((*it)->IsA(TComponentType2::InterfaceID))\n            {\n                out_components2.push_back(std::static_pointer_cast<TComponentType2>(*it));\n            }\n            if((*it)->IsA(TComponentType3::InterfaceID))\n            {\n                out_components3.push_back(std::static_pointer_cast<TComponentType3>(*it));\n            }\n        }\n    }\n    //-------------------------------------------------------------\n    //-------------------------------------------------------------\n    template <typename TComponentType1, typename TComponentType2, typename TComponentType3>\n    void Entity::GetComponents(std::vector<TComponentType1*>& out_components1, std::vector<TComponentType2*>& out_components2, std::vector<TComponentType3*>& out_components3) const\n    {\n        for (ComponentList::const_iterator it = m_components.begin(); it != m_components.end(); ++it)\n        {\n            if((*it)->IsA(TComponentType1::InterfaceID))\n            {\n                out_components1.push_back(static_cast<TComponentType1*>(it->get()));\n            }\n            if((*it)->IsA(TComponentType2::InterfaceID))\n            {\n                out_components2.push_back(static_cast<TComponentType2*>(it->get()));\n            }\n            if((*it)->IsA(TComponentType3::InterfaceID))\n            {\n                out_components3.push_back(static_cast<TComponentType3*>(it->get()));\n            }\n        }\n    }\n    //-------------------------------------------------------------\n    //-------------------------------------------------------------\n    template <typename TComponentType>\n    std::shared_ptr<TComponentType> Entity::GetComponentRecursive()\n    {\n        return std::static_pointer_cast<TComponentType>(GetComponentRecursive(TComponentType::InterfaceID));\n    }\n    //-------------------------------------------------------------\n    //-------------------------------------------------------------\n    template <typename TComponentType>\n    std::shared_ptr<const TComponentType> Entity::GetComponentRecursive() const\n    {\n        return std::static_pointer_cast<const TComponentType>(GetComponentRecursive(TComponentType::InterfaceID));\n    }\n    //-------------------------------------------------------------\n    //-------------------------------------------------------------\n    template <typename TComponentType>\n    void Entity::GetComponentsRecursive(std::vector<std::shared_ptr<TComponentType> >& out_components) const\n    {\n        for (ComponentList::const_iterator itr = m_components.begin(); itr != m_components.end(); ++itr)\n        {\n            if ((*itr)->IsA(TComponentType::InterfaceID))\n            {\n                out_components.push_back(std::static_pointer_cast<TComponentType>(*itr));\n            }\n        }\n        \n        for(SharedEntityList::const_iterator it = m_children.begin(); it != m_children.end(); ++it)\n        {\n            (*it)->GetComponentsRecursive<TComponentType>(out_components);\n        }\n    }\n    //-------------------------------------------------------------\n    //-------------------------------------------------------------\n    template <typename TComponentType>\n    void Entity::GetComponentsRecursive(std::vector<TComponentType*>& out_components)\n    {\n        for (ComponentList::const_iterator itr = m_components.begin(); itr != m_components.end(); ++itr)\n        {\n            if ((*itr)->IsA(TComponentType::InterfaceID))\n            {\n                out_components.push_back(static_cast<TComponentType*>(itr->get()));\n            }\n        }\n        \n        for(SharedEntityList::const_iterator it = m_children.begin(); it != m_children.end(); ++it)\n        {\n            (*it)->GetComponentsRecursive<TComponentType>(out_components);\n        }\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Entity/PrimitiveEntityFactory.cpp",
    "content": "//\n//  PrimitiveEntityFactory.cpp\n//  ChilliSource\n//  Created by Ian Copland on 04/08/2015.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2015 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Core/Entity/PrimitiveEntityFactory.h>\n\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/Entity/Entity.h>\n#include <ChilliSource/Core/Resource/ResourcePool.h>\n#include <ChilliSource/Core/Threading/TaskScheduler.h>\n#include <ChilliSource/Rendering/Material/Material.h>\n#include <ChilliSource/Rendering/Material/MaterialFactory.h>\n#include <ChilliSource/Rendering/Model/Model.h>\n#include <ChilliSource/Rendering/Model/StaticModelComponent.h>\n#include <ChilliSource/Rendering/Model/PrimitiveModelFactory.h>\n#include <ChilliSource/Rendering/Texture/Texture.h>\n\nnamespace ChilliSource\n{\n    CS_DEFINE_NAMEDTYPE(PrimitiveEntityFactory);\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    PrimitiveEntityFactoryUPtr PrimitiveEntityFactory::Create()\n    {\n        return PrimitiveEntityFactoryUPtr(new PrimitiveEntityFactory());\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    bool PrimitiveEntityFactory::IsA(InterfaceIDType in_interfaceId) const\n    {\n        return (PrimitiveEntityFactory::InterfaceID == in_interfaceId);\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    EntityUPtr PrimitiveEntityFactory::CreatePlane(const Colour& colour, const Vector2& size)\n    {\n        CS_RELEASE_ASSERT(Application::Get()->GetTaskScheduler()->IsMainThread(), \"Entities must be created on the main thread.\");\n        \n        MaterialCSPtr material = CreateStaticBlinnColourMaterial(colour);\n        return CreatePlane(CreateStaticBlinnColourMaterial(colour), size);\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    EntityUPtr PrimitiveEntityFactory::CreatePlane(const MaterialCSPtr& material, const Vector2& size)\n    {\n        CS_RELEASE_ASSERT(Application::Get()->GetTaskScheduler()->IsMainThread(), \"Entities must be created on the main thread.\");\n        \n        ModelCSPtr mesh = m_primitiveModelFactory->CreatePlane(size);\n        \n        StaticModelComponentSPtr meshComponent = std::make_shared<StaticModelComponent>(mesh, material);\n        meshComponent->SetShadowCastingEnabled(true);\n        \n        auto entity = Entity::Create();\n        entity->SetName(ToString(m_entityCount++) + \"-Plane\");\n        entity->AddComponent(meshComponent);\n        return entity;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    EntityUPtr PrimitiveEntityFactory::CreateBox(const Colour& colour, const Vector3& size)\n    {\n        CS_RELEASE_ASSERT(Application::Get()->GetTaskScheduler()->IsMainThread(), \"Entities must be created on the main thread.\");\n        \n        MaterialCSPtr material = CreateStaticBlinnColourMaterial(colour);\n        return CreateBox(CreateStaticBlinnColourMaterial(colour), size);\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    EntityUPtr PrimitiveEntityFactory::CreateBox(const MaterialCSPtr& material, const Vector3& size)\n    {\n        CS_RELEASE_ASSERT(Application::Get()->GetTaskScheduler()->IsMainThread(), \"Entities must be created on the main thread.\");\n        \n        ModelCSPtr mesh = m_primitiveModelFactory->CreateBox(size);\n        \n        StaticModelComponentSPtr meshComponent = std::make_shared<StaticModelComponent>(mesh, material);\n        meshComponent->SetShadowCastingEnabled(true);\n        \n        auto entity = Entity::Create();\n        entity->SetName(ToString(m_entityCount++) + \"-Box\");\n        entity->AddComponent(meshComponent);\n        return entity;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    MaterialCSPtr PrimitiveEntityFactory::CreateStaticBlinnColourMaterial(const Colour& in_colour) const\n    {\n        auto materialName = \"_PrimitiveStaticBlinnColour(\" + ToString(in_colour) + \")\";\n        auto material = m_resourcePool->GetResource<Material>(materialName);\n        \n        if (material == nullptr)\n        {\n            const Colour specularColour(0.5f, 0.5f, 0.5f, 1.0f);\n            const f32 shininess = 10.0f;\n            \n            auto texture = m_resourcePool->LoadResource<Texture>(StorageLocation::k_chilliSource, \"Textures/Blank.csimage\");\n            material = m_materialFactory->CreateBlinn(materialName, texture, Colour::k_black, in_colour, in_colour, specularColour, shininess);\n        }\n        \n        return material;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void PrimitiveEntityFactory::OnInit()\n    {\n        m_resourcePool = Application::Get()->GetResourcePool();\n        \n        m_primitiveModelFactory = Application::Get()->GetSystem<PrimitiveModelFactory>();\n        CS_ASSERT(m_primitiveModelFactory, \"PrimitiveEntityFactory could not find required app system: PrimitiveModelFactory\");\n        \n        m_materialFactory = Application::Get()->GetSystem<MaterialFactory>();\n        CS_ASSERT(m_materialFactory, \"PrimitiveEntityFactory could not find required app system: MaterialFactory\");\n        \n        m_entityCount = 0;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void PrimitiveEntityFactory::OnDestroy()\n    {\n        m_resourcePool = nullptr;\n        m_primitiveModelFactory = nullptr;\n        m_entityCount = 0;\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Core/Entity/PrimitiveEntityFactory.h",
    "content": "//\n//  PrimitiveEntityFactory.h\n//  ChilliSource\n//  Created by Ian Copland on 04/08/2015.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2015 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_ENTITY_PRIMITIVEENTITYFACTORY_H_\n#define _CHILLISOURCE_CORE_ENTITY_PRIMITIVEENTITYFACTORY_H_\n\n#include <ChilliSource/ChilliSource.h>\n\n#include <ChilliSource/Core/Math/Vector3.h>\n#include <ChilliSource/Core/System/AppSystem.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    /// A PrimitiveEntityFactory is a factory for creating primitive shape entities\n    /// such as planes and boxes. Entities will not be added to the Scene on\n    /// creation so this will have to be handled manually.\n    //\n    ///\n    /// PrimitiveEntityFactory is not a default system so it will need to be added\n    /// using Application::CreateSystem() prior to use.\n    ///\n    /// An entity can only be created on the main thread as PrimitiveEntityFactory\n    /// is not thread-safe.\n    ///\n    /// @author Ian Copland\n    //------------------------------------------------------------------------------\n    class PrimitiveEntityFactory final : public AppSystem\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(PrimitiveEntityFactory);\n        \n        ///\n        /// Allows querying of whether or not this system implements the interface\n        /// described by the given interface Id. Typically this is not called directly\n        /// as the templated equivalent IsA<Interface>() is preferred.\n        ///\n        /// @param interfaceId\n        ///     The interface Id.\n        ///\n        /// @return Whether or not the interface is implemented.\n        ///\n        bool IsA(InterfaceIDType interfaceId) const override;\n        \n        ///\n        /// Creates a coloured plane of the given size. The plane will use a blinn\n        /// shading material so there must be lights in the scene to see it.\n        ///\n        /// @param colour\n        ///     The colour of the plane.\n        /// @param size\n        ///     [Optional] The size of the plane. Defaults to [10, 10].\n        ///\n        /// @return The new entity.\n        ///\n        EntityUPtr CreatePlane(const Colour& colour, const Vector2& size = Vector2(10.0f, 10.0f));\n        \n        ///\n        /// Creates a plane of the given size with the given material\n        ///\n        /// @param material\n        ///     The material to apply.\n        /// @param size\n        ///     [Optional] The size of the plane. Defaults to [10, 10].\n        ///\n        /// @return The new entity.\n        ///\n        EntityUPtr CreatePlane(const MaterialCSPtr& material, const Vector2& size = Vector2(10.0f, 10.0f));\n        \n        ///\n        /// Creates a coloured box of the given size. The box will use a blinn shading\n        /// material so there must be lights in the scene to see it.\n        ///\n        /// @param colour\n        ///     The colour of the box.\n        /// @param size\n        ///     [Optional] The size of the box. Defaults to [1, 1, 1].\n        ///\n        /// @return The new entity.\n        ///\n        EntityUPtr CreateBox(const Colour& colour, const Vector3& size = Vector3(1.0f, 1.0f, 1.0f));\n        \n        ///\n        /// Creates a box of the given size with the given material\n        ///\n        /// @param material\n        ///     The material to apply\n        /// @param size\n        ///     [Optional] The size of the box. Defaults to [1, 1, 1].\n        ///\n        /// @return The new entity.\n        ///\n        EntityUPtr CreateBox(const MaterialCSPtr& material, const Vector3& size = Vector3(1.0f, 1.0f, 1.0f));\n        \n    private:\n        friend class Application;\n        //------------------------------------------------------------------------------\n        /// A factory method for creating new instances of the system.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @return The new instance.\n        //------------------------------------------------------------------------------\n        static PrimitiveEntityFactoryUPtr Create();\n        //------------------------------------------------------------------------------\n        /// Default constructor. Declared private to ensure the system is created\n        /// through State::CreateSystem<>().\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------------------------------------\n        PrimitiveEntityFactory() = default;\n        //------------------------------------------------------------------------------\n        /// Creates a new material with the given colour. The material is for static\n        /// models and will apply blinn lighting. If a material of the same colour\n        /// already exists it will be used rather than creating a new instance.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param in_colour - The colour of the material.\n        ///\n        /// @return The material.\n        //------------------------------------------------------------------------------\n        MaterialCSPtr CreateStaticBlinnColourMaterial(const Colour& in_colour) const;\n        //------------------------------------------------------------------------------\n        /// Initialises the system.\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------------------------------------\n        void OnInit() override;\n        //------------------------------------------------------------------------------\n        /// Cleans up the system.\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------------------------------------\n        void OnDestroy() override;\n        \n        ResourcePool* m_resourcePool = nullptr;\n        PrimitiveModelFactory* m_primitiveModelFactory = nullptr;\n        MaterialFactory* m_materialFactory = nullptr;\n        u64 m_entityCount = 0;\n    };\n}\n\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Entity/Transform.cpp",
    "content": "//\n//  Transform.cpp\n//  ChilliSource\n//  Created by Scott Downie on 24/03/2011.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2011 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Core/Entity/Transform.h>\n\n#include <algorithm>\n\nnamespace ChilliSource\n{\n    //----------------------------------------------------------------\n    /// Constructor\n    ///\n    /// Default\n    //----------------------------------------------------------------\n    Transform::Transform() : mbIsTransformCacheValid(false), mbIsParentTransformCacheValid(false), mvScale(1,1,1), mpParentTransform(nullptr)\n    {\n    \n    }\n    //----------------------------------------------------------\n    /// Set Look At\n    ///\n    /// Set the camera orientation, target and position\n    /// @param Position\n    /// @param Look target\n    /// @param Up direction\n    //----------------------------------------------------------\n    void Transform::SetLookAt(const Vector3& invPos, const Vector3& invTarget, const Vector3& invUp)\n    {\n        Vector3 vUp(invUp);\n        \n        Vector3 vForward(invTarget - invPos);\n        vForward.Normalise();\n        \n        Vector3 vRight(Vector3::CrossProduct(vUp, vForward));\n        vUp = Vector3::CrossProduct(vForward, vRight);\n        \n        vUp.Normalise();\n        vRight.Normalise();\n        \n        Quaternion cRot(vRight, vUp, vForward);\n        cRot.Normalise();\n        \n        SetPositionScaleOrientation(invPos, mvScale, cRot);\n    }\n    //----------------------------------------------------------------\n    /// Set Position Scale Orientation\n    ///\n    /// @param Position vector\n    /// @param Scale vector\n    /// @param Orientation quaternion\n    //----------------------------------------------------------------\n    void Transform::SetPositionScaleOrientation(const Vector3& invPos, const Vector3& invScale, const Quaternion& invOrientation)\n    {\n        mvPosition = invPos;\n        mvScale = invScale;\n        mqOrientation = invOrientation;\n        \n        OnTransformChanged();\n    }\n    //----------------------------------------------------------------\n    /// Set Position\n    ///\n    /// @param X Component\n    /// @param Y Component\n    /// @param Z Component\n    //----------------------------------------------------------------\n    void Transform::SetPosition(f32 infX, f32 infY, f32 infZ)\n    {\n        if(mvPosition.x == infX && mvPosition.y == infY && mvPosition.z == infZ)\n            return;\n        \n        mvPosition.x = infX;\n        mvPosition.y = infY;\n        mvPosition.z = infZ;\n        \n        OnTransformChanged();\n    }\n    //----------------------------------------------------------------\n    /// Set Position\n    ///\n    /// @param Position vector\n    //----------------------------------------------------------------\n    void Transform::SetPosition(const Vector3 &invPos)\n    {\n        if(mvPosition == invPos)\n            return;\n        \n        mvPosition = invPos;\n        \n        OnTransformChanged();\n    }\n    //----------------------------------------------------------------\n    /// Get Local Position\n    ///\n    /// @return The position of the object \n    //----------------------------------------------------------------\n    const Vector3& Transform::GetLocalPosition() const\n    {\n        return mvPosition;\n    }\n    //----------------------------------------------------------------\n    /// Get Local Scale\n    ///\n    /// @return The scale of object\n    //----------------------------------------------------------------\n    const Vector3& Transform::GetLocalScale() const\n    {\n        return mvScale;\n    }\n    //----------------------------------------------------------------\n    /// Get World Position\n    ///\n    /// @return The relative position of the object \n    //----------------------------------------------------------------\n    const Vector3& Transform::GetWorldPosition() const\n    {\n        if(mpParentTransform)\n        {\n            mvWorldPosition = GetWorldTransform().GetTranslation();\n            return mvWorldPosition;\n        }\n        \n        return mvPosition;\n    }\n    //----------------------------------------------------------------\n    /// Get World Scale\n    ///\n    /// @return The relative scale of object\n    //----------------------------------------------------------------\n    const Vector3& Transform::GetWorldScale() const\n    {\n        if(mpParentTransform)\n        {\n            mvWorldScale = mpParentTransform->GetWorldScale() * mvScale;\n            return mvWorldScale;\n        }\n        \n        return mvScale;\n    }\n    //----------------------------------------------------------------\n    /// Get Local Orientation\n    ///\n    /// @return Orientation quaternion\n    //----------------------------------------------------------------\n    const Quaternion& Transform::GetLocalOrientation() const\n    {\n        return mqOrientation;\n    }\n    //----------------------------------------------------------------\n    /// Get World Orientation\n    ///\n    /// @return Orientation quaternion relative to parent\n    //----------------------------------------------------------------\n    const Quaternion& Transform::GetWorldOrientation() const\n    {\n        if(mpParentTransform)\n        {\n            mqWorldOrientation = Quaternion(GetWorldTransform());\n            return mqWorldOrientation;\n        }\n        \n        return mqOrientation;\n    }\n    //----------------------------------------------------------------\n    /// Move By\n    ///\n    /// @param X Component\n    /// @param Y Component\n    /// @param Z Component\n    //----------------------------------------------------------------\n    void Transform::MoveBy(f32 infX, f32 infY, f32 infZ)\n    {\n        mvPosition.x += infX;\n        mvPosition.y += infY;\n        mvPosition.z += infZ;\n        \n        OnTransformChanged();\n    }\n    //----------------------------------------------------------------\n    /// Move By\n    ///\n    /// Movement direction vector\n    //----------------------------------------------------------------\n    void Transform::MoveBy(const Vector3 &invPos)\n    {\n        mvPosition += invPos;\n        \n        OnTransformChanged();\n    }\n    //----------------------------------------------------------------\n    /// Set Orientation\n    ///\n    /// @param Orientation quaternion\n    //----------------------------------------------------------------\n    void Transform::SetOrientation(const Quaternion & inqOrientation)\n    {\n        if(mqOrientation == inqOrientation)\n            return;\n        \n        mqOrientation = inqOrientation;\n        \n        OnTransformChanged();\n    }\n    //----------------------------------------------------------------\n    /// Rotate X By\n    ///\n    /// Rotate around the x-axis\n    ///\n    /// @param Angle to rotate in radians\n    //----------------------------------------------------------------\n    void Transform::RotateXBy(f32 infAngleRads)\n    {\t\t\t\n        RotateBy(Vector3::k_unitPositiveX, infAngleRads);\n    }\n    //----------------------------------------------------------------\n    /// Rotate Y By\n    ///\n    /// Rotate around the y-axis\n    ///\n    /// @param Angle to rotate in radians\n    //----------------------------------------------------------------\n    void Transform::RotateYBy(f32 infAngleRads)\n    {\n        RotateBy(Vector3::k_unitPositiveY, infAngleRads);\n    }\n    //----------------------------------------------------------------\n    /// Rotate Z By\n    ///\n    /// Rotate around the z-axis\n    ///\n    /// @param Angle to rotate in radians\n    //----------------------------------------------------------------\n    void Transform::RotateZBy(f32 infAngleRads)\n    {\n        RotateBy(Vector3::k_unitPositiveZ, infAngleRads);\n    }\n    //----------------------------------------------------------------\n    /// Rotate By\n    ///\n    /// Rotate around the arbitary axis\n    ///\n    /// @param X-axis Component\n    /// @param Y-axis Component\n    /// @param Z-axis Component\n    /// @param Angle in radians\n    //----------------------------------------------------------------\n    void Transform::RotateBy(f32 inXAxis, f32 inYAxis, f32 inZAxis, f32 infAngleRads)\n    {\t\t\t\n        RotateBy(Vector3(inXAxis,inYAxis,inZAxis), infAngleRads);\n    }\n    //----------------------------------------------------------------\n    /// Rotate By\n    ///\n    /// Rotate around the arbitary axis\n    ///\n    /// @param Axis vector\n    /// @param Angle in radians\n    //----------------------------------------------------------------\n    void Transform::RotateBy(const Vector3 &vAxis, f32 infAngleRads)\n    {\n        mqOrientation = mqOrientation * Quaternion(vAxis,infAngleRads);\n        \n        OnTransformChanged();\n    }\n    //----------------------------------------------------------------\n    /// Rotate To\n    ///\n    /// Rotate about the given axis to the given angle \n    ///\n    /// @param X-axis Component\n    /// @param Y-axis Component\n    /// @param Z-axis Component\n    /// @param Angle in radians\n    //----------------------------------------------------------------\n    void Transform::RotateTo(f32 inXAxis, f32 inYAxis, f32 inZAxis, f32 infAngleRads)\n    {\n        RotateTo(Vector3(inXAxis,inYAxis,inZAxis),infAngleRads);\n    }\n    //----------------------------------------------------------------\n    /// Rotate To\n    ///\n    /// Rotate about the given axis to the given angle \n    ///\n    /// @param Axis vector\n    /// @param Angle in radians\n    //----------------------------------------------------------------\n    void Transform::RotateTo(const Vector3 &vAxis, f32 infAngleRads)\n    {\n        mqOrientation = Quaternion(vAxis,infAngleRads);\n        \n        OnTransformChanged();\n    }\n    //----------------------------------------------------------------\n    /// Scale By\n    ///\n    /// Scale uniformly by the given amount\n    ///\n    /// @param Scale factor\n    //----------------------------------------------------------------\n    void Transform::ScaleBy(f32 inScale)\n    {\n        mvScale.x *= inScale;\n        mvScale.y *= inScale;\n        mvScale.z *= inScale;\n                      \n        OnTransformChanged();\n    }\n    //----------------------------------------------------------------\n    /// Scale By\n    ///\n    /// Scale along each axis by the given amount\n    ///\n    /// @param X Component\n    /// @param Y Component\n    /// @param Z Component\n    //----------------------------------------------------------------\n    void Transform::ScaleBy(f32 inX, f32 inY, f32 inZ)\n    {\n        mvScale.x *= inX;\n        mvScale.y *= inY;\n        mvScale.z *= inZ;\n        \n        OnTransformChanged();\n    }\n    //----------------------------------------------------------------\n    /// Scale By\n    ///\n    /// Scale along each axis by the given amount\n    ///\n    /// @param Axis vector\n    //----------------------------------------------------------------\n    void Transform::ScaleBy(const Vector3 &Vec)\n    {\n        mvScale.x *= Vec.x;\n        mvScale.y *= Vec.y;\n        mvScale.z *= Vec.z;\n        \n        OnTransformChanged();\n    }\n    //----------------------------------------------------------------\n    /// Scale To\n    ///\n    /// Scale uniformly to the given amount\n    ///\n    /// @param Scale factor\n    //----------------------------------------------------------------\n    void Transform::ScaleTo(f32 inScale)\n    {\n        if(mvScale.x == inScale && mvScale.y == inScale && mvScale.z == inScale)\n            return;\n        \n        mvScale.x = inScale;\n        mvScale.y = inScale;\n        mvScale.z = inScale;\n        \n        OnTransformChanged();\n    }\n    //----------------------------------------------------------------\n    /// Scale To\n    ///\n    /// Scale each axis to the given amount\n    ///\n    /// @param X Component\n    /// @param Y Component\n    /// @param Z Component\n    //----------------------------------------------------------------\n    void Transform::ScaleTo(f32 inX, f32 inY, f32 inZ)\n    {\n        if(mvScale.x == inX && mvScale.y == inY && mvScale.z == inZ)\n            return;\n        \n        mvScale.x = inX;\n        mvScale.y = inY;\n        mvScale.z = inZ;\n        \n        OnTransformChanged();\n    }\n    //----------------------------------------------------------------\n    /// Scale To\n    ///\n    /// Scale each axis to the given amount\n    ///\n    /// @param Axis vector\n    //----------------------------------------------------------------\n    void Transform::ScaleTo(const Vector3 &Vec)\n    {\n        if(mvScale == Vec)\n            return;\n        \n        mvScale = Vec;\n        \n        OnTransformChanged();\n    }\n    //----------------------------------------------------------------\n    /// Get Local Transform\n    ///\n    /// @return The currently cached transform (rebuilds if invalid)\n    //----------------------------------------------------------------\n    const Matrix4& Transform::GetLocalTransform() const\n    {\n        //Check if the transform needs to be re-calculated\n        if(!mbIsTransformCacheValid)\n        {\n            mbIsTransformCacheValid = true;\n            mmatTransform = Matrix4::CreateTransform(mvPosition, mvScale, mqOrientation);\n        }\n        \n        return mmatTransform;\n    }\n    //----------------------------------------------------------------\n    /// Get World Transform\n    ///\n    /// @return The tranform in relation to its parent transform\n    //----------------------------------------------------------------\n    const Matrix4& Transform::GetWorldTransform() const\n    {\n        //If we have a parent transform we must apply it to\n        //our local transform to get the relative transformation\n        if(mpParentTransform)\n        {\n            //Our parent has changed so we must re-calculate our transform\n            if(!mbIsParentTransformCacheValid)\n            {\n                mbIsParentTransformCacheValid = true;\n                \n                //Calculate the relative transform with our new parent transform\n                mmatWorldTransform = GetLocalTransform() * mpParentTransform->GetWorldTransform();\n            }\n            //Our local transform has changed therefore we must update\n            else if(!mbIsTransformCacheValid)\n            {\n                //Calculate the relative transformation from our cached parent\n                mmatWorldTransform = GetLocalTransform() * mpParentTransform->GetWorldTransform();\n            }\n        }\n        //We do not have a parent so our relative transform is actually just our local one\n        else if(!mbIsTransformCacheValid)\n        {\n            mmatWorldTransform = GetLocalTransform();\n        }\n        \n        return mmatWorldTransform;\n    }\n    //----------------------------------------------------------------\n    /// Set World Transform\n    ///\n    /// This will overwrite any parent or previous transformations\n    ///\n    /// @param Objects transformation matrix\n    //----------------------------------------------------------------\n    void Transform::SetWorldTransform(const Matrix4& inmatTransform)\n    {\n        //Change the local transform to match the given world matrix\n        if (mpParentTransform)\n        {\n            mmatTransform = inmatTransform * Matrix4::Inverse(mpParentTransform->GetWorldTransform());\n        }\n        else\n        {\n            mmatTransform = inmatTransform;\n        }\n\n        mmatTransform.Decompose(mvPosition, mvScale, mqOrientation);\n\n        OnTransformChanged();\n\n        mbIsTransformCacheValid = true;\n        mbIsParentTransformCacheValid = false;\n    }\n    //----------------------------------------------------------------\n    /// Set Local Transform\n    ///\n    /// This will overwrite any local previous transformations\n    ///\n    /// @param Objects transformation matrix\n    //----------------------------------------------------------------\n    void Transform::SetLocalTransform(const Matrix4& inmatTransform)\n    {\n        inmatTransform.Decompose(mvPosition, mvScale, mqOrientation);\n        \n        mmatTransform = inmatTransform;\n        \n        OnTransformChanged();\n        \n        mbIsTransformCacheValid = false;\n    }\n    //----------------------------------------------------------------\n    /// Is Transform Valid\n    ///\n    /// @return Whether the transform cache has been invalidated \n    //----------------------------------------------------------------\n    bool Transform::IsTransformValid() const\n    {\n        return mbIsTransformCacheValid && mbIsParentTransformCacheValid;\n    }\n    //----------------------------------------------------------------\n    /// Set Parent Transform\n    ///\n    /// Link this transform to another so that our transformations\n    /// become relative to the parent transform\n    ///\n    /// @param Transform object\n    //----------------------------------------------------------------\n    void Transform::SetParentTransform(Transform* inpTransform)\n    {\n        mpParentTransform = inpTransform;\n        \n        OnParentTransformChanged();\n    }\n    //----------------------------------------------------------------\n    /// Get Parent Transform\n    /// @return what it says on tin\n    //----------------------------------------------------------------\n    Transform* Transform::GetParentTransform() const\n    {\n        return mpParentTransform;\n    }\n    //----------------------------------------------------------------\n    /// Add Child Transform\n    ///\n    /// Link this transform to another so that our transformations\n    /// influence the childs transform\n    ///\n    /// @param Transform object\n    //----------------------------------------------------------------\n    void Transform::AddChildTransform(Transform* inpTransform)\n    {\n        inpTransform->SetParentTransform(this);\n        mChildTransforms.push_back(inpTransform);\n    }\n    //----------------------------------------------------------------\n    /// Remove Child Transform\n    ///\n    /// Unlink this transform to another so that our transformations\n    /// no longer influence the childs transform\n    ///\n    /// @param Transform object\n    /// @return Whether the child was removed successfully\n    //----------------------------------------------------------------\n    bool Transform::RemoveChildTransform(Transform* inpTransform)\n    {\n        std::vector<Transform*>::iterator it = std::find(mChildTransforms.begin(), mChildTransforms.end(), inpTransform);\n        \n        if(it != mChildTransforms.end())\n        {\n            inpTransform->SetParentTransform(nullptr);\n            mChildTransforms.erase(it);\n            return true;\n        }\n        \n        return false;\n    }\n    //----------------------------------------------------------------\n    /// Remove All Child Transforms\n    ///\n    /// Unlink this transform from all children so that our transformations\n    /// no longer influence the childs transform\n    //----------------------------------------------------------------\n    void Transform::RemoveAllChildTransforms()\n    {\n        for(std::vector<Transform*>::iterator it = mChildTransforms.begin(); it != mChildTransforms.end(); ++it)\n        {\n            (*it)->SetParentTransform(nullptr);\n        }\n        \n        mChildTransforms.clear();\n    }\n    //----------------------------------------------------------------\n    /// Get Tranform Changed Event\n    ///\n    /// Subscribe to this event for notifications of when this\n    /// transform is invalidated\n    ///\n    /// @return TransformChangedDelegate event\n    //----------------------------------------------------------------\n    IConnectableEvent<Transform::TransformChangedDelegate>& Transform::GetTransformChangedEvent()\n    {\n        return mTransformChangedEvent;\n    }\n    //----------------------------------------------------------------\n    /// On Transform Changed \n    ///\n    /// Triggered when our transform changes so we can \n    /// notify any dependant transforms\n    //----------------------------------------------------------------\n    void Transform::OnTransformChanged()\n    {\n        mbIsTransformCacheValid = false;\n        \n        for(std::vector<Transform*>::iterator it = mChildTransforms.begin(); it != mChildTransforms.end(); ++it)\n        {\n            (*it)->OnParentTransformChanged();\n        }\n        \n        mTransformChangedEvent.NotifyConnections();\n    }\n    //----------------------------------------------------------------\n    /// On Parent Transform Changed \n    ///\n    /// Triggered when our parent transform changes so we can \n    /// recalculate our transform\n    //----------------------------------------------------------------\n    void Transform::OnParentTransformChanged()\n    {\n        mbIsParentTransformCacheValid = false;\n        \n        OnTransformChanged();\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    void Transform::Reset()\n    {\n        mbIsTransformCacheValid = false;\n        mbIsParentTransformCacheValid = false;\n        mvPosition = Vector3::k_zero;\n        mvScale = Vector3::k_one;\n        mqWorldOrientation = Quaternion::k_identity;\n        mpParentTransform = nullptr;\n        mChildTransforms.clear();\n        mTransformChangedEvent.CloseAllConnections();\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Core/Entity/Transform.h",
    "content": "//\n//  Transform.h\n//  ChilliSource\n//  Created by Scott Downie on 24/03/2011.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2011 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_TRANSFORM_H_\n#define _CHILLISOURCE_CORE_TRANSFORM_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Event/Event.h>\n#include <ChilliSource/Core/Math/Matrix4.h>\n#include <ChilliSource/Core/Math/Vector3.h>\n#include <ChilliSource/Core/Math/Quaternion.h>\n\n#include <functional>\n\nnamespace ChilliSource\n{\n    class Transform\n    {\n    public:\n        typedef std::function<void()> TransformChangedDelegate;\n        \n        Transform();\n        //----------------------------------------------------------\n        /// Set Look At\n        ///\n        /// Set the camera orientation, target and position\n        /// @param Position\n        /// @param Look target\n        /// @param Up direction\n        //----------------------------------------------------------\n        void SetLookAt(const Vector3& invPos, const Vector3& invTarget, const Vector3& invUp);\n        //----------------------------------------------------------------\n        /// Set Position Scale Orientation\n        ///\n        /// @param Position vector\n        /// @param Scale vector\n        /// @param Orientation quaternion\n        //----------------------------------------------------------------\n        void SetPositionScaleOrientation(const Vector3& invPos, const Vector3& invScale, const Quaternion& invOrientation);\n        //----------------------------------------------------------------\n        /// Set Position\n        ///\n        /// @param X Component\n        /// @param Y Component\n        /// @param Z Component\n        //----------------------------------------------------------------\n        void SetPosition(f32 infX, f32 infY, f32 infZ);\n        //----------------------------------------------------------------\n        /// Set Position\n        ///\n        /// @param Position vector\n        //----------------------------------------------------------------\n        void SetPosition(const Vector3 &invPos);\n        //----------------------------------------------------------------\n        /// Get Local Position\n        ///\n        /// @return The position of the object \n        //----------------------------------------------------------------\n        const Vector3& GetLocalPosition() const;\n        //----------------------------------------------------------------\n        /// Get World Position\n        ///\n        /// @return The relative position of the object \n        //----------------------------------------------------------------\n        const Vector3& GetWorldPosition() const;\n        //----------------------------------------------------------------\n        /// Move By\n        ///\n        /// @param X Component\n        /// @param Y Component\n        /// @param Z Component\n        //----------------------------------------------------------------\n        void MoveBy(f32 infX, f32 infY, f32 infZ);\n        //----------------------------------------------------------------\n        /// Move By\n        ///\n        /// Movement direction vector\n        //----------------------------------------------------------------\n        void MoveBy(const Vector3 &invPos);\n        //----------------------------------------------------------------\n        /// Set Orientation\n        ///\n        /// @param Orientation quaternion\n        //----------------------------------------------------------------\n        void SetOrientation(const Quaternion & inqOrientation);\n        //----------------------------------------------------------------\n        /// Get Local Orientation\n        ///\n        /// @return Orientation quaternion\n        //----------------------------------------------------------------\n        const Quaternion& GetLocalOrientation() const;\n        //----------------------------------------------------------------\n        /// Get World Orientation\n        ///\n        /// @return Orientation quaternion relative to parent tranform\n        //----------------------------------------------------------------\n        const Quaternion& GetWorldOrientation() const;\n        //----------------------------------------------------------------\n        /// Rotate X By\n        ///\n        /// Rotate around the x-axis\n        ///\n        /// @param Angle to rotate in radians\n        //----------------------------------------------------------------\n        void RotateXBy(f32 infAngleRads);\n        //----------------------------------------------------------------\n        /// Rotate Y By\n        ///\n        /// Rotate around the y-axis\n        ///\n        /// @param Angle to rotate in radians\n        //----------------------------------------------------------------\n        void RotateYBy(f32 infAngleRads);\n        //----------------------------------------------------------------\n        /// Rotate Z By\n        ///\n        /// Rotate around the z-axis\n        ///\n        /// @param Angle to rotate in radians\n        //----------------------------------------------------------------\n        void RotateZBy(f32 infAngleRads);\n        //----------------------------------------------------------------\n        /// Rotate By\n        ///\n        /// Rotate around the arbitary axis\n        ///\n        /// @param X-axis Component\n        /// @param Y-axis Component\n        /// @param Z-axis Component\n        /// @param Angle in radians\n        //----------------------------------------------------------------\n        void RotateBy(f32 inXAxis, f32 inYAxis, f32 inZAxis, f32 infAngleRads);\n        //----------------------------------------------------------------\n        /// Rotate By\n        ///\n        /// Rotate around the arbitary axis\n        ///\n        /// @param Axis vector\n        /// @param Angle in radians\n        //----------------------------------------------------------------\n        void RotateBy(const Vector3 &vAxis, f32 infAngleRads);\n        //----------------------------------------------------------------\n        /// Rotate To\n        ///\n        /// Rotate about the given axis to the given angle \n        ///\n        /// @param X-axis Component\n        /// @param Y-axis Component\n        /// @param Z-axis Component\n        /// @param Angle in radians\n        //----------------------------------------------------------------\n        void RotateTo(f32 inXAxis, f32 inYAxis, f32 inZAxis, f32 infAngleRads);\n        //----------------------------------------------------------------\n        /// Rotate To\n        ///\n        /// Rotate about the given axis to the given angle \n        ///\n        /// @param Axis vector\n        /// @param Angle in radians\n        //----------------------------------------------------------------\n        void RotateTo(const Vector3 &vAxis, f32 infAngleRads);\n        //----------------------------------------------------------------\n        /// Scale By\n        ///\n        /// Scale uniformly by the given amount\n        ///\n        /// @param Scale factor\n        //----------------------------------------------------------------\n        void ScaleBy(f32 inScale);\n        //----------------------------------------------------------------\n        /// Scale By\n        ///\n        /// Scale along each axis by the given amount\n        ///\n        /// @param X Component\n        /// @param Y Component\n        /// @param Z Component\n        //----------------------------------------------------------------\n        void ScaleBy(f32 inX, f32 inY, f32 inZ);\n        //----------------------------------------------------------------\n        /// Scale By\n        ///\n        /// Scale along each axis by the given amount\n        ///\n        /// @param Axis vector\n        //----------------------------------------------------------------\n        void ScaleBy(const Vector3 &Vec);\n        //----------------------------------------------------------------\n        /// Scale To\n        ///\n        /// Scale uniformly to the given amount\n        ///\n        /// @param Scale factor\n        //----------------------------------------------------------------\n        void ScaleTo(f32 inScale);\n        //----------------------------------------------------------------\n        /// Scale To\n        ///\n        /// Scale each axis to the given amount\n        ///\n        /// @param X Component\n        /// @param Y Component\n        /// @param Z Component\n        //----------------------------------------------------------------\n        void ScaleTo(f32 inX, f32 inY, f32 inZ);\n        //----------------------------------------------------------------\n        /// Scale To\n        ///\n        /// Scale each axis to the given amount\n        ///\n        /// @param Axis vector\n        //----------------------------------------------------------------\n        void ScaleTo(const Vector3 &Vec);\n        //----------------------------------------------------------------\n        /// Get Scale\n        ///\n        /// @return The scale of object\n        //----------------------------------------------------------------\n        const Vector3& GetLocalScale() const;\n        //----------------------------------------------------------------\n        /// Get World Scale\n        ///\n        /// @return The relative scale of object\n        //----------------------------------------------------------------\n        const Vector3& GetWorldScale() const;\n        //----------------------------------------------------------------\n        /// Get Local Transform\n        ///\n        /// @return The currently cached transform (rebuilds if invalid)\n        //----------------------------------------------------------------\n        const Matrix4& GetLocalTransform() const;\n        //----------------------------------------------------------------\n        /// Get World Transform\n        ///\n        /// @return The tranform in relation to its parent transform\n        //----------------------------------------------------------------\n        const Matrix4& GetWorldTransform() const;\n        //----------------------------------------------------------------\n        /// Set World Transform\n        ///\n        /// This will overwrite any parent or previous transformations\n        ///\n        /// @param Objects transformation matrix\n        //----------------------------------------------------------------\n        void SetWorldTransform(const Matrix4& inmatTransform);\n        //----------------------------------------------------------------\n        /// Set Local Transform\n        ///\n        /// This will overwrite any local previous transformations\n        ///\n        /// @param Objects transformation matrix\n        //----------------------------------------------------------------\n        void SetLocalTransform(const Matrix4& inmatTransform);\n        //----------------------------------------------------------------\n        /// Is Transform Valid\n        ///\n        /// @return Whether the transform cache has been invalidated \n        //----------------------------------------------------------------\n        bool IsTransformValid() const;\n        \n        //----------------------------------------------------------------\n        /// Get Parent Transform\n        /// @return what it says on tin\n        //----------------------------------------------------------------\n        Transform* GetParentTransform() const;\n\n        //----------------------------------------------------------------\n        /// Get Tranform Changed Event\n        ///\n        /// Subscribe to this event for notifications of when this\n        /// transform is invalidated\n        ///\n        /// @return TransformChangedDelegate event\n        //----------------------------------------------------------------\n        IConnectableEvent<TransformChangedDelegate>& GetTransformChangedEvent();\n        \n        //----------------------------------------------------------------\n        /// Resets the transform back to identity and removes any\n        /// connections\n        ///\n        /// @author S Downie\n        //----------------------------------------------------------------\n        void Reset();\n        \n    private:\n        \n        friend class Entity;\n        \n        //----------------------------------------------------------------\n        /// Set Parent Transform\n        ///\n        /// Link this transform to another so that our transformations\n        /// become World to the parent transform\n        ///\n        /// @param Transform object\n        //----------------------------------------------------------------\n        void SetParentTransform(Transform* inpTransform);\n        \n        //----------------------------------------------------------------\n        /// Add Child Transform\n        ///\n        /// Link this transform to another so that our transformations\n        /// influence the childs transform\n        ///\n        /// @param Transform object\n        //----------------------------------------------------------------\n        void AddChildTransform(Transform* inpTransform);\n        //----------------------------------------------------------------\n        /// Remove Child Transform\n        ///\n        /// Unlink this transform from another so that our transformations\n        /// no longer influence the childs transform\n        ///\n        /// @param Transform object\n        /// @return Whether the child was removed successfully\n        //----------------------------------------------------------------\n        bool RemoveChildTransform(Transform* inpTransform);\n        //----------------------------------------------------------------\n        /// Remove All Child Transforms\n        ///\n        /// Unlink this transform from all children so that our transformations\n        /// no longer influence the childs transform\n        //----------------------------------------------------------------\n        void RemoveAllChildTransforms();\n        \n        //----------------------------------------------------------------\n        /// On Transform Changed \n        ///\n        /// Triggered when our transform changes so we can \n        /// notify any dependant transforms\n        //----------------------------------------------------------------\n        void OnTransformChanged();\n        //----------------------------------------------------------------\n        /// On Parent Transform Changed \n        ///\n        /// Triggered when our parent transform changes so we can \n        /// recalculate our transform\n        //----------------------------------------------------------------\n        void OnParentTransformChanged();\n        \n    private:\n        \n        mutable Matrix4 mmatTransform;\n        mutable Matrix4 mmatWorldTransform;\n        \n        Vector3 mvPosition;\n        Vector3 mvScale;\n        Quaternion mqOrientation;\n        \n        mutable Vector3 mvWorldPosition;\n        mutable Vector3 mvWorldScale;\n        mutable Quaternion mqWorldOrientation;\n        \n        Event<TransformChangedDelegate> mTransformChangedEvent;\n        \n        Transform* mpParentTransform;\n        \n        std::vector<Transform*> mChildTransforms;\n        \n        mutable bool mbIsTransformCacheValid;\n        mutable bool mbIsParentTransformCacheValid;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Entity.h",
    "content": "//\n//  Entity.h\n//  ChilliSource\n//  Created by Ian Copland on 07/07/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_ENTITY_H_\n#define _CHILLISOURCE_CORE_ENTITY_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Entity/Component.h>\n#include <ChilliSource/Core/Entity/Entity.h>\n#include <ChilliSource/Core/Entity/PrimitiveEntityFactory.h>\n#include <ChilliSource/Core/Entity/Transform.h>\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Event/Event.h",
    "content": "//\n//  Event.h\n//  ChilliSource\n//  Created by Scott Downie on 27/02/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_EVENT_EVENT_H_\n#define _CHILLISOURCE_CORE_EVENT_EVENT_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/ForwardDeclarations.h>\n#include <ChilliSource/Core/Event/EventConnection.h>\n#include <ChilliSource/Core/Event/IConnectableEvent.h>\n#include <ChilliSource/Core/Event/IDisconnectableEvent.h>\n\n#include <vector>\n\nnamespace ChilliSource\n{\n    //-----------------------------------------------------------------\n    /// An Event represents an object which can have multiple listeners\n    /// (connections) with the given DelegateType.\n    /// Objects should though expose the IConnectableEvent interface\n    /// to prevent other objects invoking the event.\n    ///\n    /// @author S Downie\n    //-----------------------------------------------------------------\n    template <typename TDelegateType> class Event final : public IConnectableEvent<TDelegateType>, public IDisconnectableEvent\n    {\n    public:\n        //-------------------------------------------------------------\n        /// Constructor\n        ///\n        /// @author S Downie\n        //-------------------------------------------------------------\n        Event(){}\n        //-------------------------------------------------------------\n        /// Destructor closes all open connections\n        ///\n        /// @author S Downie\n        //-------------------------------------------------------------\n        ~Event()\n        {\n            CloseAllConnections();\n        }\n        //-------------------------------------------------------------\n        /// No copying of events is allowed. If you wish to make a\n        /// shallow copy of an event then hold a pointer to it.\n        ///\n        /// @author S Downie\n        //-------------------------------------------------------------\n        Event(const Event&) = delete;\n        Event& operator= (const Event&) = delete;\n        //-------------------------------------------------------------\n        /// Although we don't want events to be copyable, we do want\n        /// them to be moveable. Connection references are updated to\n        /// point to the new event.\n        ///\n        /// @author Ian Copland\n        /// \n        /// @param The event to move into this.\n        //-------------------------------------------------------------\n        Event(Event&& in_moveFrom)\n        {\n            CloseAllConnections();\n\n            m_isNotifying = in_moveFrom.m_isNotifying;\n            m_connections = std::move(in_moveFrom.m_connections);\n            for (auto& connectionContainer : m_connections)\n            {\n                connectionContainer.m_connection->SetOwningEvent(this);\n            }\n        }\n        //-------------------------------------------------------------\n        /// Although we don't want events to be copyable, we do want\n        /// them to be moveable. Connection references are updated to\n        /// point to the new event.\n        ///\n        /// @author Ian Copland\n        /// \n        /// @param The event to move into this.\n        ///\n        /// @param A reference to this after the move.\n        //-------------------------------------------------------------\n        Event& operator= (Event&& in_moveFrom)\n        {\n            CloseAllConnections();\n\n            m_isNotifying = in_moveFrom.m_isNotifying;\n            m_connections = std::move(in_moveFrom.m_connections);\n            for (auto& connectionContainer : m_connections)\n            {\n                connectionContainer.m_connection->SetOwningEvent(this);\n            }\n\n            return *this;\n        }\n        //-------------------------------------------------------------\n        /// Opens a new connection to the event. While this connection\n        /// remains in scope the delegate will be notified of events\n        ///\n        /// @author S Downie\n        ///\n        /// @param Delegate to notify\n        ///\n        /// @return Scoped connection\n        //-------------------------------------------------------------\n        EventConnectionUPtr OpenConnection(const TDelegateType& in_delegate) override\n        {\n            EventConnectionUPtr connection(new EventConnection());\n            connection->SetOwningEvent(this);\n        \n            ConnectionDesc desc;\n            desc.m_delegate = in_delegate;\n            desc.m_connection = connection.get();\n            m_connections.push_back(desc);\n        \n            return connection;\n        }\n        //-------------------------------------------------------------\n        /// Close connection to the event. The connection will\n        /// no longer be notified of the event\n        ///\n        /// @author S Downie\n        ///\n        /// @param Connection to close\n        //-------------------------------------------------------------\n        void CloseConnection(EventConnection* in_connection) override\n        {\n            for(u32 i=0; i<m_connections.size(); ++i)\n            {\n                ConnectionDesc& desc = m_connections[i];\n                if(desc.m_connection == in_connection)\n                {\n                    if(m_isNotifying == false)\n                    {\n                        m_connections.erase(m_connections.begin() + i);\n                    }\n                    else\n                    {\n                        desc.m_connection = nullptr;\n                    }\n                    \n                    return;\n                }\n            }\n        }\n        //-------------------------------------------------------------\n        /// Notify connections that the event has occurred\n        ///\n        /// @author S Downie\n        ///\n        /// @param Arguments to pass to the connection delegate\n        //-------------------------------------------------------------\n        template <typename... TArgTypes> void NotifyConnections(TArgTypes&&... in_args)\n        {\n            m_isNotifying = true;\n            \n            //Take a snapshot of the number of delegates so any new ones added\n            //during the notify loop aren't notified themseleves.\n            auto numConnections = m_connections.size();\n            for (typename ConnectionList::size_type i = 0; i < numConnections; ++i)\n            {\n                if(m_connections[i].m_connection != nullptr)\n                {\n                    m_connections[i].m_delegate(std::forward<TArgTypes>(in_args)...);\n                }\n            }\n            \n            m_isNotifying = false;\n            \n            RemoveClosedConnections();\n        }\n        //-------------------------------------------------------------\n        /// Closes all the currently open connections\n        ///\n        /// @author S Downie\n        //-------------------------------------------------------------\n        void CloseAllConnections()\n        {\n            for(u32 i=0; i<m_connections.size(); ++i)\n            {\n                if(m_connections[i].m_connection != nullptr)\n                {\n                    m_connections[i].m_connection->SetOwningEvent(nullptr);\n                }\n            }\n            \n            m_connections.clear();\n        }\n\n    private:\n\n        //-------------------------------------------------------------------------\n        /// Remove from the list any connections that have been flagged as closed\n        ///\n        /// @author S Downie\n        //-------------------------------------------------------------------------\n        void RemoveClosedConnections()\n        {\n            for(typename ConnectionList::iterator it = m_connections.begin(); it != m_connections.end(); )\n            {\n                if(it->m_connection == nullptr)\n                {\n                    it = m_connections.erase(it);\n                }\n                else\n                {\n                    ++it;\n                }\n            }\n        }\n\n    private:\n                                \n        struct ConnectionDesc\n        {\n            TDelegateType m_delegate;\n            EventConnection* m_connection = nullptr;\n        };\n\n        typedef std::vector<ConnectionDesc> ConnectionList;\n        ConnectionList m_connections;\n    \n        bool m_isNotifying = false;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Event/EventConnection.cpp",
    "content": "//\n//  EventConnection.cpp\n//  ChilliSource\n//  Created by Scott Downie on 27/02/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Core/Event/EventConnection.h>\n\n#include <ChilliSource/Core/Event/IDisconnectableEvent.h>\n\nnamespace ChilliSource\n{\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    void EventConnection::SetOwningEvent(IDisconnectableEvent* in_owningEvent)\n    {\n        m_owningEvent = in_owningEvent;\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    void EventConnection::Close()\n    {\n        if(m_owningEvent != nullptr)\n        {\n            m_owningEvent->CloseConnection(this);\n            m_owningEvent = nullptr;\n        }\n    }\n    //----------------------------------------------------------------\n    // Destructor closes the connection automatically when the\n    // connection object is destroyed\n    //----------------------------------------------------------------\n    EventConnection::~EventConnection()\n    {\n        Close();\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Core/Event/EventConnection.h",
    "content": "//\n//  EventConnection.h\n//  ChilliSource\n//  Created by Scott Downie on 27/02/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_EVENT_EVENTCONNECTION_H_\n#define _CHILLISOURCE_CORE_EVENT_EVENTCONNECTION_H_\n\n#include <ChilliSource/ChilliSource.h>\n\nnamespace ChilliSource\n{\n    //----------------------------------------------------------------\n    /// A connection is a channel to an event. When a listener\n    /// is registered with an event a scoped connection is created\n    /// when this connection object is destroyed then the connection\n    /// is automatically closed. (See Event.h)\n    ///\n    /// @author S Downie\n    //----------------------------------------------------------------\n    class EventConnection\n    {\n    public:\n        \n        //----------------------------------------------------------------\n        /// Destructor\n        ///\n        /// @author S Downie\n        //----------------------------------------------------------------\n        ~EventConnection();\n        //----------------------------------------------------------------\n        /// Sets the event this is connected to. This should only be called\n        /// by Event itself, don't call manually.\n        ///\n        /// @author S Downie\n        ///\n        /// @param Event that owns the connection\n        //----------------------------------------------------------------\n        void SetOwningEvent(IDisconnectableEvent* in_owningEvent);\n        //----------------------------------------------------------------\n        /// Manually close the connection so that it no longer receieves\n        /// any events\n        ///\n        /// @author S Downie\n        //----------------------------------------------------------------\n        void Close();\n\n    private:\n        \n        IDisconnectableEvent* m_owningEvent = nullptr;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Event/IConnectableEvent.h",
    "content": "//\n//  IConnectableEvent.h\n//  ChilliSource\n//  Created by Scott Downie on 27/02/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_EVENT_ICONNECTABLEEVENT_H_\n#define _CHILLISOURCE_CORE_EVENT_ICONNECTABLEEVENT_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/ForwardDeclarations.h>\n\nnamespace ChilliSource\n{\n    //-----------------------------------------------------------------\n    /// An IConnectableEvent represents an object which can have multiple listeners\n    /// (connections) with the given DelegateType. The subclass Event is what\n    /// should be instanced by objects as they have an NotifyConnections method.\n    /// Objects should though expose the IConnectableEvent interface to prevent\n    /// other objects invoking the event.\n    ///\n    /// @author S Downie\n    //-----------------------------------------------------------------\n    template <typename TDelegateType> class IConnectableEvent\n    {\n    public:\n        \n        //-------------------------------------------------------------\n        /// Constructor\n        ///\n        /// @author S Downie\n        //-------------------------------------------------------------\n        IConnectableEvent(){}\n        //-------------------------------------------------------------\n        /// No copying of events is allowed. If you wish to make a\n        /// shallow copy of an event then hold a pointer to it.\n        ///\n        /// @author S Downie\n        //-------------------------------------------------------------\n        IConnectableEvent(const IConnectableEvent&) = delete;\n        IConnectableEvent& operator= (const IConnectableEvent&) = delete;\n        \n        //-------------------------------------------------------------\n        /// Opens a new connection to the event. While this connection\n        /// remains in scope the delegate will be notified of events\n        ///\n        /// @author S Downie\n        ///\n        /// @param Delegate to notify\n        ///\n        /// @return Scoped connection\n        //-------------------------------------------------------------\n        virtual EventConnectionUPtr OpenConnection(const TDelegateType& in_delegate) = 0;\n        //-------------------------------------------------------------\n        /// Virtual destructor\n        ///\n        /// @author Ian Copland\n        //-------------------------------------------------------------\n        virtual ~IConnectableEvent() {};\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Event/IDisconnectableEvent.h",
    "content": "//\n//  IDisconnectableEvent.h\n//  ChilliSource\n//  Created by Scott Downie on 27/02/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_EVENT_IDISCONNECTABLEEVENT_H_\n#define _CHILLISOURCE_CORE_EVENT_IDISCONNECTABLEEVENT_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/ForwardDeclarations.h>\n\nnamespace ChilliSource\n{\n    //-----------------------------------------------------------------\n    /// An interface that allows connections to be closed on an event\n    ///\n    /// @author S Downie\n    //-----------------------------------------------------------------\n    class IDisconnectableEvent\n    {\n    public:\n        //-------------------------------------------------------------\n        /// Constructor\n        ///\n        /// @author S Downie\n        //-------------------------------------------------------------\n        IDisconnectableEvent(){}\n        //-------------------------------------------------------------\n        /// No copying of events is allowed. If you wish to make a\n        /// shallow copy of an event then hold a pointer to it.\n        ///\n        /// @author S Downie\n        //-------------------------------------------------------------\n        IDisconnectableEvent(const IDisconnectableEvent&) = delete;\n        IDisconnectableEvent& operator= (const IDisconnectableEvent&) = delete;\n        \n        //-------------------------------------------------------------\n        /// Close connection to the event. The connection will\n        /// no longer be notified of the event\n        ///\n        /// @author S Downie\n        ///\n        /// @param Connection to close\n        //-------------------------------------------------------------\n        virtual void CloseConnection(EventConnection* in_connection) = 0;\n        //-------------------------------------------------------------\n        /// Virtual destructor\n        ///\n        /// @author Ian Copland\n        //-------------------------------------------------------------\n        virtual ~IDisconnectableEvent() {};\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Event.h",
    "content": "//\n//  Event.h\n//  ChilliSource\n//  Created by Ian Copland on 07/07/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_EVENT_H_\n#define _CHILLISOURCE_CORE_EVENT_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Event/Event.h>\n#include <ChilliSource/Core/Event/EventConnection.h>\n#include <ChilliSource/Core/Event/IConnectableEvent.h>\n#include <ChilliSource/Core/Event/IDisconnectableEvent.h>\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/File/AppDataStore.cpp",
    "content": "//\n//  AppDataStore.cpp\n//  ChilliSource\n//  Created by Stuart McGaw on 24/05/2011.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2011 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Core/File/AppDataStore.h>\n\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/Container/ParamDictionarySerialiser.h>\n#include <ChilliSource/Core/Cryptographic/AESEncrypt.h>\n#include <ChilliSource/Core/Delegate/MakeDelegate.h>\n#include <ChilliSource/Core/String/StringParser.h>\n#include <ChilliSource/Core/XML/XMLUtils.h>\n\nnamespace ChilliSource\n{\n    namespace\n    {\n        const std::string k_filename = \"App.ads\";\n        const std::string k_privateKey = \"aV0r71^jX01}pXMk\";\n    }\n    \n    CS_DEFINE_NAMEDTYPE(AppDataStore);\n    //--------------------------------------------------------------\n    //--------------------------------------------------------------\n    AppDataStoreUPtr AppDataStore::Create()\n    {\n        return AppDataStoreUPtr(new AppDataStore());\n    }\n    //--------------------------------------------------------------\n    //--------------------------------------------------------------\n    AppDataStore::AppDataStore()\n    : m_needsSynchonised(false)\n    {\n        RefreshFromFile();\n    }\n    //--------------------------------------------------------------\n    //--------------------------------------------------------------\n    bool AppDataStore::IsA(InterfaceIDType in_interfaceId) const\n    {\n        return (AppDataStore::InterfaceID == in_interfaceId);\n    }\n    //--------------------------------------------------------------\n    //--------------------------------------------------------------\n    bool AppDataStore::Contains(const std::string& in_key)\n    {\n        std::unique_lock<std::mutex> lock(m_mutex);\n        return m_dictionary.HasKey(in_key);\n    }\n    //--------------------------------------------------------------\n    //--------------------------------------------------------------\n    bool AppDataStore::TryGetValue(const std::string& in_key, std::string& out_value) const\n    {\n        std::unique_lock<std::mutex> lock(m_mutex);\n        return m_dictionary.TryGetValue(in_key, out_value);\n    }\n    //--------------------------------------------------------------\n    //--------------------------------------------------------------\n    bool AppDataStore::TryGetValue(const std::string& in_key, bool& out_value) const\n    {\n        std::unique_lock<std::mutex> lock(m_mutex);\n        \n        std::string strTempValue;\n        bool bSuccess = m_dictionary.TryGetValue(in_key, strTempValue);\n        if(bSuccess)\n        {\n            out_value = ParseBool(strTempValue);\n        }\n        return bSuccess;\n    }\n    //--------------------------------------------------------------\n    //--------------------------------------------------------------\n    bool AppDataStore::TryGetValue(const std::string& in_key, u16& out_value) const\n    {\n        std::unique_lock<std::mutex> lock(m_mutex);\n        \n        std::string strTempValue;\n        bool bSuccess = m_dictionary.TryGetValue(in_key, strTempValue);\n        if(bSuccess)\n        {\n            out_value = static_cast<u16>(ParseU32(strTempValue));\n        }\n        return bSuccess;\t\t\t\n    }\n    //--------------------------------------------------------------\n    //--------------------------------------------------------------\n    bool AppDataStore::TryGetValue(const std::string& in_key, s16& out_value) const\n    {\n        std::unique_lock<std::mutex> lock(m_mutex);\n        \n        std::string strTempValue;\n        bool bSuccess = m_dictionary.TryGetValue(in_key, strTempValue);\n        if(bSuccess)\n        {\n            out_value = static_cast<s16>(ParseS32(strTempValue));\n        }\n        return bSuccess;\n    }\n    //--------------------------------------------------------------\n    //--------------------------------------------------------------\n    bool AppDataStore::TryGetValue(const std::string& in_key, u32& out_value) const\n    {\n        std::unique_lock<std::mutex> lock(m_mutex);\n        \n        std::string strTempValue;\n        bool bSuccess = m_dictionary.TryGetValue(in_key, strTempValue);\n        if(bSuccess)\n        {\n            out_value = static_cast<u32>(ParseU32(strTempValue));\n        }\n        return bSuccess;\t\t\t\n    }\n    //--------------------------------------------------------------\n    //--------------------------------------------------------------\n    bool AppDataStore::TryGetValue(const std::string& in_key, s32& out_value) const\n    {\n        std::unique_lock<std::mutex> lock(m_mutex);\n        \n        std::string strTempValue;\n        bool bSuccess = m_dictionary.TryGetValue(in_key, strTempValue);\n        if(bSuccess)\n        {\n            out_value = static_cast<s32>(ParseS32(strTempValue));\n        }\n        return bSuccess;\t\t\t\n    }\n    //--------------------------------------------------------------\n    //--------------------------------------------------------------\n    bool AppDataStore::TryGetValue(const std::string& in_key, u64& out_value) const\n    {\n        std::unique_lock<std::mutex> lock(m_mutex);\n        \n        std::string strTempValue;\n        bool bSuccess = m_dictionary.TryGetValue(in_key, strTempValue);\n        if(bSuccess)\n        {\n            out_value = static_cast<u64>(ParseU64(strTempValue));\n        }\n        return bSuccess;\t\t\t\n    }\n    //--------------------------------------------------------------\n    //--------------------------------------------------------------\n    bool AppDataStore::TryGetValue(const std::string& in_key, s64& out_value) const\n    {\n        std::unique_lock<std::mutex> lock(m_mutex);\n        \n        std::string strTempValue;\n        bool bSuccess = m_dictionary.TryGetValue(in_key, strTempValue);\n        if(bSuccess)\n        {\n            out_value = static_cast<s64>(ParseS64(strTempValue));\n        }\n        return bSuccess;\t\t\t\n    }\n    //--------------------------------------------------------------\n    //--------------------------------------------------------------\n    bool AppDataStore::TryGetValue(const std::string& in_key, f32& out_value) const\n    {\n        std::unique_lock<std::mutex> lock(m_mutex);\n        \n        std::string strTempValue;\n        bool bSuccess = m_dictionary.TryGetValue(in_key, strTempValue);\n        if(bSuccess)\n        {\n            out_value = ParseF32(strTempValue);\n        }\n        return bSuccess;\t\t\n    }\t\t\n    //--------------------------------------------------------------\n    //--------------------------------------------------------------\n    void AppDataStore::SetValue(const std::string& in_key, const std::string& in_value)\n    {\n        std::unique_lock<std::mutex> lock(m_mutex);\n        \n        m_dictionary[in_key] = in_value;\n        m_needsSynchonised = true;\n    }\n    //--------------------------------------------------------------\n    //--------------------------------------------------------------\n    void AppDataStore::SetValue(const std::string& in_key, const s8* in_value)\n    {\n        SetValue(in_key, std::string(in_value));\n    }\n    //--------------------------------------------------------------\n    //--------------------------------------------------------------\n    void AppDataStore::SetValue(const std::string& in_key, bool in_value)\n    {\n        SetValue(in_key, ToString(in_value));\n    }\n    //--------------------------------------------------------------\n    //--------------------------------------------------------------\n    void AppDataStore::SetValue(const std::string& in_key, u16 in_value)\n    {\n        SetValue(in_key, ToString(in_value));\n    }\n    //--------------------------------------------------------------\n    //--------------------------------------------------------------\n    void AppDataStore::SetValue(const std::string& in_key, s16 in_value)\n    {\n        SetValue(in_key, ToString(in_value));\n    }\n    //--------------------------------------------------------------\n    //--------------------------------------------------------------\n    void AppDataStore::SetValue(const std::string& in_key, u32 in_value)\n    {\n        SetValue(in_key, ToString(in_value));\n    }\n    //--------------------------------------------------------------\n    //--------------------------------------------------------------\n    void AppDataStore::SetValue(const std::string& in_key, s32 in_value)\n    {\n        SetValue(in_key, ToString(in_value));\n    }\n    //--------------------------------------------------------------\n    //--------------------------------------------------------------\n    void AppDataStore::SetValue(const std::string& in_key, u64 in_value)\n    {\n        SetValue(in_key, ToString(in_value));\n    }\n    //--------------------------------------------------------------\n    //--------------------------------------------------------------\n    void AppDataStore::SetValue(const std::string& in_key, s64 in_value)\n    {\n        SetValue(in_key, ToString(in_value));\n    }\n    //--------------------------------------------------------------\n    //--------------------------------------------------------------\n    void AppDataStore::SetValue(const std::string& in_key, f32 infValue)\n    {\n        SetValue(in_key, ToString(infValue));\n    }\n    //--------------------------------------------------------------\n    //--------------------------------------------------------------\n    bool AppDataStore::Erase(const std::string& in_key)\n    {\n        std::unique_lock<std::mutex> lock(m_mutex);\n        \n        ParamDictionary::iterator pEntry = m_dictionary.find(in_key);\n        if(m_dictionary.end() != pEntry)\n        {\n            m_dictionary.erase(pEntry);\n            return true;\n        }\n        \n        return false;\n    }\n    //--------------------------------------------------------------\n    //--------------------------------------------------------------\n    void AppDataStore::Clear()\n    {\n        std::unique_lock<std::mutex> lock(m_mutex);\n        \n        m_dictionary.clear();\n        m_needsSynchonised = true;\n    }\n    //--------------------------------------------------------------\n    //--------------------------------------------------------------\n    void AppDataStore::Save()\n    {\n        std::unique_lock<std::mutex> lock(m_mutex);\n        \n        if(m_needsSynchonised == true)\n        {\n            // Convert to XML\n            XML::Document doc;\n            XML::Node* rootNode = doc.allocate_node(rapidxml::node_type::node_element);\n            doc.append_node(rootNode);\n            ParamDictionarySerialiser::ToXml(m_dictionary, rootNode);\n            \n            // Encrypt\n            std::string strDocToBeEncrypted = XMLUtils::ToString(&doc);\n            AESEncrypt::Data encryptedData = AESEncrypt::EncryptString(strDocToBeEncrypted, k_privateKey);\n\n            // Write to disk\n            FileSystem* pFileSystem = Application::Get()->GetFileSystem();\n            auto fileStream = pFileSystem->CreateBinaryOutputStream(StorageLocation::k_saveData, k_filename);\n            if(fileStream != nullptr)\n            {\n                fileStream->Write(reinterpret_cast<const u8*>(encryptedData.m_data.get()), encryptedData.m_size);\n                fileStream.reset();\n            }\n            \n            m_needsSynchonised = false;\n        }\n    }\n    //--------------------------------------------------------------\n    //--------------------------------------------------------------\n    void AppDataStore::RefreshFromFile()\n    {\n        FileSystem* pFileSystem = Application::Get()->GetFileSystem();\n        if(pFileSystem->DoesFileExist(StorageLocation::k_saveData, k_filename) == true)\n        {\n            auto fileStream = pFileSystem->CreateBinaryInputStream(StorageLocation::k_saveData, k_filename);\n            if (fileStream != nullptr)\n            {\n                u32 encryptedDataSize = u32(fileStream->GetLength());\n                \n                std::unique_ptr<u8[]> encryptedData(new u8[encryptedDataSize]);\n                fileStream->Read(encryptedData.get(), encryptedDataSize);\n                fileStream.reset();\n                \n                std::string decrypted = AESEncrypt::DecryptString(reinterpret_cast<const u8*>(encryptedData.get()), encryptedDataSize, k_privateKey);\n\n                XMLUPtr xml = XMLUtils::ParseDocument(decrypted);\n                XML::Node* root = XMLUtils::GetFirstChildElement(xml->GetDocument());\n                if(nullptr != root)\n                {\n                    m_dictionary = ParamDictionarySerialiser::FromXml(root);\n                }\n            }\n        }\n        \n        m_needsSynchonised = false;\n    }\n    //--------------------------------------------------------------\n    //--------------------------------------------------------------\n    void AppDataStore::OnSuspend()\n    {\n        Save();\n    }\n}\n\n"
  },
  {
    "path": "Source/ChilliSource/Core/File/AppDataStore.h",
    "content": "//\n//  AppDataStore.h\n//  ChilliSource\n//  Created by Stuart McGaw on 24/05/2011.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2011 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_FILE_LOCALDATASTORE_H_\n#define _CHILLISOURCE_CORE_FILE_LOCALDATASTORE_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Container/ParamDictionary.h>\n#include <ChilliSource/Core/System/AppSystem.h>\n\n#include <mutex>\n\nnamespace ChilliSource\n{\n    //--------------------------------------------------------------------\n    /// Local data store provides a simple key-value data store useful for\n    /// storing persistent data such as options and player preferences.\n    ///\n    /// The local data store is encrypted on disk however the private key\n    /// used is generated from known information. This means the local\n    /// data store should not be used to store sensitive information such\n    /// as passwords.\n    ///\n    /// Note that keys beginning with an underscore '_' are reserved for\n    /// internal engine use.\n    ///\n    /// The ADS is thread-safe and is initialised prior to the OnInit()\n    /// lifecycle event.\n    ///\n    /// @author S McGaw\n    //--------------------------------------------------------------------\n    class AppDataStore final : public AppSystem\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(AppDataStore);\n        //------------------------------------------------------------\n        /// Allows querying of whether or not this system implements\n        /// a given interface.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param Interface Id\n        ///\n        /// @return Whether this object is of the given type.\n        //------------------------------------------------------------\n        bool IsA(InterfaceIDType in_interfaceId) const override;\n        //------------------------------------------------------------\n        /// Returns if the given key exists in the data store.\n        ///\n        /// @author R Henning\n        ///\n        /// @param The name of the key.\n        ///\n        /// @return Whether or not the key exists.\n        //------------------------------------------------------------\n        bool Contains(const std::string& in_key);\n        //------------------------------------------------------------\n        /// Attempts to get the value for the given key from the data\n        /// store as a string.\n        ///\n        /// @author R Henning\n        ///\n        /// @param Key to attempt to retrieve the value for.\n        /// @param [Out] The output value.\n        ///\n        /// @return Whether or not the value was successfully retreived.\n        //------------------------------------------------------------\n        bool TryGetValue(const std::string& in_key, std::string& out_value) const;\n        //------------------------------------------------------------\n        /// Attempts to get the value for the given key from the data\n        /// store as a bool.\n        ///\n        /// @author R Henning\n        ///\n        /// @param Key to attempt to retrieve the value for.\n        /// @param [Out] The output value.\n        ///\n        /// @return Whether or not the value was successfully retreived.\n        //------------------------------------------------------------\n        bool TryGetValue(const std::string& in_key, bool& out_value) const;\n        //------------------------------------------------------------\n        /// Attempts to get the value for the given key from the data\n        /// store as a u16.\n        ///\n        /// @author R Henning\n        ///\n        /// @param Key to attempt to retrieve the value for.\n        /// @param [Out] The output value.\n        ///\n        /// @return Whether or not the value was successfully retreived.\n        //------------------------------------------------------------\n        bool TryGetValue(const std::string& in_key, u16& out_value) const;\n        //------------------------------------------------------------\n        /// Attempts to get the value for the given key from the data\n        /// store as a s16.\n        ///\n        /// @author R Henning\n        ///\n        /// @param Key to attempt to retrieve the value for.\n        /// @param [Out] The output value.\n        ///\n        /// @return Whether or not the value was successfully retreived.\n        //------------------------------------------------------------\n        bool TryGetValue(const std::string& in_key, s16& out_value) const;\n        //------------------------------------------------------------\n        /// Attempts to get the value for the given key from the data\n        /// store as a u32.\n        ///\n        /// @author R Henning\n        ///\n        /// @param Key to attempt to retrieve the value for.\n        /// @param [Out] The output value.\n        ///\n        /// @return Whether or not the value was successfully retreived.\n        //------------------------------------------------------------\n        bool TryGetValue(const std::string& in_key, u32& out_value) const;\n        //------------------------------------------------------------\n        /// Attempts to get the value for the given key from the data\n        /// store as a s32.\n        ///\n        /// @author R Henning\n        ///\n        /// @param Key to attempt to retrieve the value for.\n        /// @param [Out] The output value.\n        ///\n        /// @return Whether or not the value was successfully retreived.\n        //------------------------------------------------------------\n        bool TryGetValue(const std::string& in_key, s32& out_value) const;\n        //------------------------------------------------------------\n        /// Attempts to get the value for the given key from the data\n        /// store as a u64.\n        ///\n        /// @author R Henning\n        ///\n        /// @param Key to attempt to retrieve the value for.\n        /// @param [Out] The output value.\n        ///\n        /// @return Whether or not the value was successfully retreived.\n        //------------------------------------------------------------\n        bool TryGetValue(const std::string& in_key, u64& out_value) const;\n        //------------------------------------------------------------\n        /// Attempts to get the value for the given key from the data\n        /// store as a s64.\n        ///\n        /// @author R Henning\n        ///\n        /// @param Key to attempt to retrieve the value for.\n        /// @param [Out] The output value.\n        /// @return Whether or not the value was successfully retreived.\n        //------------------------------------------------------------\n        bool TryGetValue(const std::string& in_key, s64& out_value) const;\n        //------------------------------------------------------------\n        /// Attempts to get the value for the given key from the data\n        /// store as a f32.\n        ///\n        /// @author R Henning\n        ///\n        /// @param Key to attempt to retrieve the value for.\n        /// @param [Out] The output value.\n        ///\n        /// @return Whether or not the value was successfully retreived.\n        //------------------------------------------------------------\n        bool TryGetValue(const std::string& in_key, f32& out_value) const;\n        //--------------------------------------------------------------\n        /// Sets the value for the given key. If the key already existed\n        /// its previous value will be overwritten. Note that keys\n        /// beginning with an underscore '_' are reserved for internal\n        /// engine use.\n        ///\n        /// @author R Henning\n        ///\n        /// @param The key.\n        /// @param The value.\n        //--------------------------------------------------------------\n        void SetValue(const std::string& in_key, const std::string& in_value);\n        //--------------------------------------------------------------\n        /// Sets the value for the given key. If the key already existed\n        /// its previous value will be overwritten. Note that keys\n        /// beginning with an underscore '_' are reserved for internal\n        /// engine use.\n        ///\n        /// @author R Henning\n        ///\n        /// @param The key.\n        /// @param The value.\n        //--------------------------------------------------------------\n        void SetValue(const std::string& in_key, const s8* in_value);\n        //--------------------------------------------------------------\n        /// Sets the value for the given key. If the key already existed\n        /// its previous value will be overwritten. Note that keys\n        /// beginning with an underscore '_' are reserved for internal\n        /// engine use.\n        ///\n        /// @author R Henning\n        ///\n        /// @param The key.\n        /// @param The value.\n        //--------------------------------------------------------------\n        void SetValue(const std::string& in_key, bool in_value);\n        //--------------------------------------------------------------\n        /// Sets the value for the given key. If the key already existed\n        /// its previous value will be overwritten. Note that keys\n        /// beginning with an underscore '_' are reserved for internal\n        /// engine use.\n        ///\n        /// @author R Henning\n        ///\n        /// @param The key.\n        /// @param The value.\n        //--------------------------------------------------------------\n        void SetValue(const std::string& in_key, u16 in_value);\n        //--------------------------------------------------------------\n        /// Sets the value for the given key. If the key already existed\n        /// its previous value will be overwritten. Note that keys\n        /// beginning with an underscore '_' are reserved for internal\n        /// engine use.\n        ///\n        /// @author R Henning\n        ///\n        /// @param The key.\n        /// @param The value.\n        //--------------------------------------------------------------\n        void SetValue(const std::string& in_key, s16 in_value);\n        //--------------------------------------------------------------\n        /// Sets the value for the given key. If the key already existed\n        /// its previous value will be overwritten. Note that keys\n        /// beginning with an underscore '_' are reserved for internal\n        /// engine use.\n        ///\n        /// @author R Henning\n        ///\n        /// @param The key.\n        /// @param The value.\n        //--------------------------------------------------------------\n        void SetValue(const std::string& in_key, u32 in_value);\n        //--------------------------------------------------------------\n        /// Sets the value for the given key. If the key already existed\n        /// its previous value will be overwritten. Note that keys\n        /// beginning with an underscore '_' are reserved for internal\n        /// engine use.\n        ///\n        /// @author R Henning\n        ///\n        /// @param The key.\n        /// @param The value.\n        //--------------------------------------------------------------\n        void SetValue(const std::string& in_key, s32 in_value);\n        //--------------------------------------------------------------\n        /// Sets the value for the given key. If the key already existed\n        /// its previous value will be overwritten. Note that keys\n        /// beginning with an underscore '_' are reserved for internal\n        /// engine use.\n        ///\n        /// @author R Henning\n        ///\n        /// @param The key.\n        /// @param The value.\n        //--------------------------------------------------------------\n        void SetValue(const std::string& in_key, u64 in_value);\n        //--------------------------------------------------------------\n        /// Sets the value for the given key. If the key already existed\n        /// its previous value will be overwritten. Note that keys\n        /// beginning with an underscore '_' are reserved for internal\n        /// engine use.\n        ///\n        /// @author R Henning\n        ///\n        /// @param The key.\n        /// @param The value.\n        //--------------------------------------------------------------\n        void SetValue(const std::string& in_key, s64 in_value);\n        //--------------------------------------------------------------\n        /// Sets the value for the given key. If the key already existed\n        /// its previous value will be overwritten. Note that keys\n        /// beginning with an underscore '_' are reserved for internal\n        /// engine use.\n        ///\n        /// @author R Henning\n        ///\n        /// @param The key.\n        /// @param The value.\n        //--------------------------------------------------------------\n        void SetValue(const std::string& in_key, f32 in_value);\n        //--------------------------------------------------------------\n        /// Attempts to erase the entry for the given key from the data\n        /// store.\n        ///\n        /// @author R Henning\n        ///\n        /// @param The key of the entry to remove.\n        ///\n        /// @return Whether or not the key was successfully removed.\n        //--------------------------------------------------------------\n        bool Erase(const std::string& in_key);\n        //--------------------------------------------------------------\n        /// Clears the Local Data Store, removing all contents.\n        ///\n        /// @author Ian Copland\n        //--------------------------------------------------------------\n        void Clear();\n        //--------------------------------------------------------------\n        /// Writes the current state of the data store to disk.\n        ///\n        /// @author R Henning\n        //--------------------------------------------------------------\n        void Save();\n    \n    private:\n        friend class Application;\n        //--------------------------------------------------------------\n        /// Factory create method called by application to create a new\n        /// instance of the system.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @return Creates a new instance of the system.\n        //--------------------------------------------------------------\n        static AppDataStoreUPtr Create();\n        //--------------------------------------------------------------\n        /// Private constructor to enforce use of the factory method.\n        ///\n        /// @author S McGaw\n        //--------------------------------------------------------------\n        AppDataStore();\n        //--------------------------------------------------------------\n        /// Loads the saved data from disk into the current data store.\n        ///\n        /// @author R Henning\n        //--------------------------------------------------------------\n        void RefreshFromFile();\n        //--------------------------------------------------------------\n        /// Called when the application is suspended. This is also called\n        /// when the application is exiting just prior to calling On\n        /// Destroy. System suspend is called in the reverse order to\n        /// which they were created.\n        ///\n        /// @author Ian Copland\n        //--------------------------------------------------------------\n        void OnSuspend() override;\n        \n        mutable std::mutex m_mutex;\n        bool m_needsSynchonised;\n        ParamDictionary m_dictionary;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/File/CSBinaryChunk.cpp",
    "content": "//\n//  CSBinaryChunk.cpp\n//  ChilliSource\n//  Created by Ian Copland on 28/10/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Core/File/CSBinaryChunk.h>\n\nnamespace ChilliSource\n{\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    CSBinaryChunk::CSBinaryChunk(std::unique_ptr<u8[]> in_dataBlob, u32 in_dataSize)\n    : m_dataBlob(std::move(in_dataBlob)), m_dataSize(in_dataSize)\n    {\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    u32 CSBinaryChunk::GetSize() const\n    {\n        return m_dataSize;\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    const u8* CSBinaryChunk::GetData() const\n    {\n        return m_dataBlob.get();\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    u32 CSBinaryChunk::GetReadPosition() const\n    {\n        return m_readPosition;\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    const u8* CSBinaryChunk::Read(u32 in_dataSize)\n    {\n        if (m_readPosition + in_dataSize > m_dataSize)\n        {\n            CS_LOG_FATAL(\"Trying to read beyond the end of a Binary Chunk.\");\n        }\n        \n        u8* output = m_dataBlob.get() + m_readPosition;\n        m_readPosition += in_dataSize;\n        return output;\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    std::unique_ptr<u8[]> CSBinaryChunk::ClaimData()\n    {\n        m_dataSize = 0;\n        m_readPosition = 0;\n        return std::move(m_dataBlob);\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Core/File/CSBinaryChunk.h",
    "content": "//\n//  CSBinaryChunk.h\n//  ChilliSource\n//  Created by Ian Copland on 28/10/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_FILE_CSBINARYCHUNK_H_\n#define _CHILLISOURCE_CORE_FILE_CSBINARYCHUNK_H_\n\n#include <ChilliSource/ChilliSource.h>\n\nnamespace ChilliSource\n{\n    //----------------------------------------------------------------------\n    /// A single chunk within a ChilliSource binary \"Chunked\" file. The\n    /// contents of the chunk are loaded directly into memory on creation\n    /// meaning each call to Read() avoids further disc reads.\n    ///\n    /// CSBinaryChunk is thread agnostic and can be used and accessed on any\n    /// thread but it is not thread-safe, so a single instance should not\n    /// be shared across different threads at the same time.\n    ///\n    /// @author Ian Copland\n    //----------------------------------------------------------------------\n    class CSBinaryChunk final\n    {\n    public:\n        CS_DECLARE_NOCOPY(CSBinaryChunk);\n        //----------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The size of the chunk in bytes.\n        //----------------------------------------------------------------\n        u32 GetSize() const;\n        //----------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The raw underlying chunk data. This returns the entire\n        /// chunk, disregarding the read position.\n        //----------------------------------------------------------------\n        const u8* GetData() const;\n        //----------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The current read position.\n        //----------------------------------------------------------------\n        u32 GetReadPosition() const;\n        //----------------------------------------------------------------\n        /// Reads a value from the given chunk at the read position. After\n        /// the read, the read position is incremented by the size of the\n        /// requested type.\n        ///\n        /// If this attempts to read beyond the end of the chunk a fatal\n        /// error will be logged.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @return The value.\n        //----------------------------------------------------------------\n        template <typename TType> TType Read();\n        //----------------------------------------------------------------\n        /// Reads the requested size of data from the chunk at the current\n        /// read position. After the read, the read position is incremented\n        /// by the given data size. The returned data is not a copy and\n        /// should not be altered.\n        ///\n        /// If this attempts to read beyond the end of the chunk a fatal\n        /// error will be logged.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @return The value.\n        //----------------------------------------------------------------\n        const u8* Read(u32 in_dataSize);\n        //----------------------------------------------------------------\n        /// Claims the chunks memory. This is used in cases where the\n        /// entire contents of the chunk is desired without having to\n        /// copy the data, for example image data. After this has been\n        /// called the chunk can no longer be used.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @return The size of the chunk in bytes.\n        //----------------------------------------------------------------\n        std::unique_ptr<u8[]> ClaimData();\n    private:\n        friend class CSBinaryInputStream;\n        //----------------------------------------------------------------\n        /// Constructor. Creates the chunk with a pointer to the chunk\n        /// data blob. This is private to ensure only the CS Binary Input\n        /// Stream can instantiate it.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The chunk data blob.\n        /// @param The chunk data size.\n        //----------------------------------------------------------------\n        CSBinaryChunk(std::unique_ptr<u8[]> in_dataBlob, u32 in_dataSize);\n        \n        std::unique_ptr<u8[]> m_dataBlob;\n        u32 m_dataSize = 0;\n        u32 m_readPosition = 0;\n    };\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    template <typename TType> TType CSBinaryChunk::Read()\n    {\n        const u8* data = Read(sizeof(TType));\n        const TType output = *reinterpret_cast<const TType*>(data);\n        return output;\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/File/CSBinaryInputStream.cpp",
    "content": "//\n//  CSBinaryInputStream.cpp\n//  ChilliSource\n//  Created by Ian Copland on 28/10/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Core/File/CSBinaryInputStream.h>\n\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/File/CSBinaryChunk.h>\n#include <ChilliSource/Core/File/FileSystem.h>\n\nnamespace ChilliSource\n{\n    namespace\n    {\n        //--------------------------------------------------------------\n        /// Reads the ChilliSource \"Chunked\" binary file header.\n        ///\n        /// @param Ian Copland\n        ///\n        /// @param The file stream.\n        /// @param [Out] The file format Id.\n        /// @param [Out] The file format version.\n        /// @param [Out] The number of entries in the chunk table.\n        ///\n        /// @return Whether reading the header was successful or not.\n        //--------------------------------------------------------------\n        bool ReadHeader(IBinaryInputStream* in_fileStream, const std::string& in_filePath, u32& out_fileFormatId, u32& out_fileFormatVersion, u32& out_numChunkTableEntries)\n        {\n            CS_ASSERT(in_fileStream != nullptr, \"File stream cannot be null.\");\n            \n            //read the header data\n            const u32 k_headerSize = 20;\n            std::unique_ptr<u8[]> headerData(new u8[k_headerSize]);\n            in_fileStream->Read(headerData.get(), k_headerSize);\n            \n            //test file id.\n            if (headerData[0] != 'C' || headerData[1] != 'S' || headerData[2] != 'C' || headerData[3] != 'S')\n            {\n                CS_LOG_ERROR(\"Invalid ChilliSource file identifier in file: \" + in_filePath);\n                return false;\n            }\n            \n            //test file endianness.\n            const u32 k_endiannessCheckFlagOffset = 4;\n            u32 endiannessCheckFlag = *reinterpret_cast<const u32*>(headerData.get() + k_endiannessCheckFlagOffset);\n            if (endiannessCheckFlag != 9999)\n            {\n                CS_LOG_ERROR(\"File is big endian, only little endian is currently supported: \" + in_filePath);\n                return false;\n            }\n            \n            //read the file type\n            const u32 k_fileFormatIdOffset = 8;\n            out_fileFormatId = *reinterpret_cast<const u32*>(headerData.get() + k_fileFormatIdOffset);\n            \n            //read the file version\n            const u32 k_fileFormatVersionOffset = 12;\n            out_fileFormatVersion = *reinterpret_cast<const u32*>(headerData.get() + k_fileFormatVersionOffset);\n            \n            //read the number of chunk table entries\n            const u32 k_numChunkTableEntriesOffset = 16;\n            out_numChunkTableEntries = *reinterpret_cast<const u32*>(headerData.get() + k_numChunkTableEntriesOffset);\n            \n            return true;\n        }\n    }\n    \n    //--------------------------------------------------------------\n    //--------------------------------------------------------------\n    CSBinaryInputStream::CSBinaryInputStream(StorageLocation in_storageLocation, const std::string& in_filePath)\n    {\n        FileSystem* fileSystem = Application::Get()->GetFileSystem();\n        CS_ASSERT(fileSystem != nullptr, \"CSBinaryInputStream missing required system: FileSystem.\");\n        \n        m_fileStream = fileSystem->CreateBinaryInputStream(in_storageLocation, in_filePath);\n        if (m_fileStream != nullptr)\n        {\n            u32 numChunkTableEntries;\n            if (ReadHeader(m_fileStream.get(), in_filePath, m_fileFormatId, m_fileFormatVersion, numChunkTableEntries) == false)\n            {\n                m_fileStream.reset();\n                return;\n            }\n            \n            ReadChunkTable(numChunkTableEntries);\n            \n            m_isValid = true;\n        }\n    }\n    //--------------------------------------------------------------\n    //--------------------------------------------------------------\n    bool CSBinaryInputStream::IsValid() const\n    {\n        return m_isValid;\n    }\n    //--------------------------------------------------------------\n    //--------------------------------------------------------------\n    u32 CSBinaryInputStream::GetFileFormatId() const\n    {\n        return m_fileFormatId;\n    }\n    //--------------------------------------------------------------\n    //--------------------------------------------------------------\n    u32 CSBinaryInputStream::GetFileFormatVersion() const\n    {\n        return m_fileFormatVersion;\n    }\n    //--------------------------------------------------------------\n    //--------------------------------------------------------------\n    CSBinaryChunkUPtr CSBinaryInputStream::ReadChunk(const std::string& in_chunkId)\n    {\n        CS_ASSERT(m_isValid == true, \"Cannot read chunk from invalid Input stream.\");\n        \n        auto chunkInfoIt = m_chunkInfoMap.find(in_chunkId);\n        if (chunkInfoIt != m_chunkInfoMap.end())\n        {\n            m_fileStream->SetReadPosition(chunkInfoIt->second.m_offset);\n            CS_ASSERT(m_fileStream->GetReadPosition() == chunkInfoIt->second.m_offset, \"Seek failed.\");\n            \n            std::unique_ptr<u8[]> chunkData(new u8[chunkInfoIt->second.m_size]);\n            m_fileStream->Read(chunkData.get(), chunkInfoIt->second.m_size);\n            \n            return CSBinaryChunkUPtr(new CSBinaryChunk(std::move(chunkData), chunkInfoIt->second.m_size));\n        }\n        \n        return nullptr;\n    }\n    //--------------------------------------------------------------\n    //--------------------------------------------------------------\n    void CSBinaryInputStream::ReadChunkTable(u32 in_numEntries)\n    {\n        const u32 k_chunkEntrySize = 12;\n        \n        //read the chunk table\n        const u32 chunkTableDataSize = k_chunkEntrySize * in_numEntries;\n        std::unique_ptr<u8[]> chunkTableData(new u8[chunkTableDataSize]);\n        m_fileStream->Read(chunkTableData.get(), chunkTableDataSize);\n        \n        //iterate over the chunks\n        for (u32 i = 0; i < in_numEntries; ++i)\n        {\n            const u32 chunkOffset = i * k_chunkEntrySize;\n            \n            //get the chunk identifier\n            const u32 k_chunkIdSize = 4;\n            std::string chunkId(reinterpret_cast<const s8*>(chunkTableData.get() + chunkOffset), k_chunkIdSize);\n            \n            ChunkInfo info;\n            \n            //get the chunk offset.\n            const u32 k_offsetOffset = 4;\n            info.m_offset = *reinterpret_cast<const u32*>(chunkTableData.get() + chunkOffset + k_offsetOffset);\n            \n            //get the chunk size.\n            const u32 k_sizeOffset = 8;\n            info.m_size = *reinterpret_cast<const u32*>(chunkTableData.get() + chunkOffset + k_sizeOffset);\n            \n            m_chunkInfoMap.emplace(chunkId, info);\n        }\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Core/File/CSBinaryInputStream.h",
    "content": "//\n//  CSBinaryInputStream.h\n//  ChilliSource\n//  Created by Ian Copland on 28/10/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_FILE_CSBINARYINPUTSTREAM_H_\n#define _CHILLISOURCE_CORE_FILE_CSBINARYINPUTSTREAM_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/File/FileStream/IBinaryInputStream.h>\n\n#include <unordered_map>\n\nnamespace ChilliSource\n{\n    //----------------------------------------------------------------------\n    /// A file input stream for reading files that use ChilliSource's\n    /// \"Chunked\" binary file format. The input stream wraps around a\n    /// standard file stream and provides an easy and efficient API for\n    /// loading files.\n    ///\n    /// The ChilliSource \"Chunked\" file format has 3 sections. The header,\n    /// the chunk table and the chunk data. The header contains basic file\n    /// information such as version numbers and the chunk table size. The\n    /// chunk table describes the location and size of all file chunks. The\n    /// Chunk data section contains each of the chunks described by the\n    /// chunk tank. The quantity of chunks and format and contents of a chunk\n    /// is determined by the specific file format.\n    ///\n    /// The file header is a fixed size and contains the following:\n    ///\n    ///   [4 bytes] The 4 ASCII character ChilliSource file id: \"CSCS\".\n    ///\n    ///   [4 bytes] Endianness check flag. This is an unsigned integer that\n    ///   should always read 9999. It can be used to determine whether the\n    ///   file is big or little endian.\n    ///\n    ///   [4 bytes] The CS file format Id. An unsigned integer describing which\n    ///   of the ChilliSource file format the file is. For example a CSFont\n    ///   file has an Id of 1.\n    ///\n    ///   [4 bytes] An unsigned integer describing the file format version\n    ///   number.\n    ///\n    ///   [4 bytes] An unsigned integer describing the number of entries in\n    ///   chunk table.\n    ///\n    /// The chunk table simply contains a series of entries, each describing\n    /// a chunk. The format of a chunk table entry is as follows:\n    ///\n    ///   [4 bytes] A 4 ASCII character unique identifier for the chunk.\n    ///\n    ///   [4 bytes] An unsigned integer describing the offset of the chunk\n    ///   from the start of the file in bytes.\n    ///\n    ///   [4 bytes] An unsigned integer describing the size of the chunk in\n    ///   bytes.\n    ///\n    /// @author Ian Copland\n    //----------------------------------------------------------------------\n    class CSBinaryInputStream final\n    {\n    public:\n        CS_DECLARE_NOCOPY(CSBinaryInputStream);\n        //--------------------------------------------------------------\n        /// Constructor. Creates a new binary stream to the given file\n        /// path. Before use the IsValid() flag should be checked to\n        /// ensure that the stream has successfully be opened.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The storage location of the file.\n        /// @param The file path.\n        //--------------------------------------------------------------\n        CSBinaryInputStream(StorageLocation in_storageLocation, const std::string& in_filePath);\n        //--------------------------------------------------------------\n        /// Returns whether or not the stream has successfully been\n        /// created and is ready for use. This should be checked prior\n        /// to any other action on the stream. If it returns false, the\n        /// stream should be discarded and no further action performed on\n        /// it.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @return Whether or not the stream was successfully created.\n        //--------------------------------------------------------------\n        bool IsValid() const;\n        //--------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The CS file format Id.\n        //--------------------------------------------------------------\n        u32 GetFileFormatId() const;\n        //--------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The file format version number.\n        //--------------------------------------------------------------\n        u32 GetFileFormatVersion() const;\n        //--------------------------------------------------------------\n        /// Reads the contents of the requested chunk into memory and\n        /// returns it as a Binary Chunk to allow efficient and easy access\n        /// to the chunks contents. If the file doesn't contain the\n        /// requested chunk null will be returned.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The 4 character unique identifier for the chunk.\n        ///\n        /// @return The chunk or null if it doesn't exist.\n        //--------------------------------------------------------------\n        CSBinaryChunkUPtr ReadChunk(const std::string& in_chunkId);\n    private:\n        //--------------------------------------------------------------\n        /// A container for information on a single chunk in the chunk\n        /// table.\n        ///\n        /// @author Ian Copland\n        //--------------------------------------------------------------\n        struct ChunkInfo\n        {\n            u32 m_offset = 0;\n            u32 m_size = 0;\n        };\n        //--------------------------------------------------------------\n        /// Reads the chunk table. This should only be called immediately\n        /// after reading the file header.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The number of entries in the chunk table.\n        //--------------------------------------------------------------\n        void ReadChunkTable(u32 in_numEntries);\n        \n        IBinaryInputStreamUPtr m_fileStream;\n        bool m_isValid = false;\n        u32 m_fileFormatId = 0;\n        u32 m_fileFormatVersion = 0;\n        std::unordered_map<std::string, ChunkInfo> m_chunkInfoMap;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/File/FileStream/BinaryInputStream.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright © 2016 Tag Games. All rights reserved.\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Core/File/FileStream/BinaryInputStream.h>\n\n#include <ChilliSource/Core/Base/ByteBuffer.h>\n\n#include <algorithm>\n#include <memory>\n#include <sstream>\n#include <iostream>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    BinaryInputStream::BinaryInputStream(const std::string& filePath) noexcept\n    {\n        m_fileStream.open(filePath.c_str(), std::ios_base::in | std::ios_base::binary);\n        \n        m_isValid = m_fileStream.is_open() && !m_fileStream.bad() && !m_fileStream.fail();\n        \n        if(m_isValid)\n        {\n            m_fileStream.seekg(0, m_fileStream.end);\n            m_length = m_fileStream.tellg();\n            m_fileStream.seekg(0, m_fileStream.beg);\n        }\n    }\n    //------------------------------------------------------------------------------\n    bool BinaryInputStream::IsValid() const noexcept\n    {\n        return m_isValid;\n    }\n    //------------------------------------------------------------------------------\n    u64 BinaryInputStream::GetLength() const noexcept\n    {\n        CS_ASSERT(IsValid(), \"Trying to use an invalid FileStream.\");\n        \n        return m_length;\n    }\n    //------------------------------------------------------------------------------\n    u64 BinaryInputStream::GetReadPosition() noexcept\n    {\n        CS_ASSERT(IsValid(), \"Trying to use an invalid FileStream.\");\n        return m_fileStream.tellg();\n    }\n    //------------------------------------------------------------------------------\n    void BinaryInputStream::SetReadPosition(u64 readPosition) noexcept\n    {\n        CS_ASSERT(IsValid(), \"Trying to use an invalid FileStream.\");\n        CS_ASSERT(readPosition <= GetLength(), \"Position out of bounds!\");\n        \n        m_fileStream.seekg(readPosition);\n    }\n    //------------------------------------------------------------------------------\n    ByteBufferUPtr BinaryInputStream::ReadAll() noexcept\n    {\n        CS_ASSERT(IsValid(), \"Trying to use an invalid FileStream.\");\n        \n        //Reset the read position to the beginning\n        SetReadPosition(0);\n        \n        return Read(m_length);\n    }\n    //------------------------------------------------------------------------------\n    bool BinaryInputStream::Read(u8* buffer, u64 length) noexcept\n    {\n        CS_ASSERT(IsValid(), \"Trying to use an invalid FileStream.\");\n        \n        if(m_fileStream.eof())\n        {\n            return false;\n        }\n        \n        //Ensure that we never overrun the file stream\n        const auto currentPosition = GetReadPosition();\n        const auto maxValidLength = std::min(m_length - currentPosition, length);\n        \n        if(maxValidLength == 0)\n        {\n            return true;\n        }\n        \n        m_fileStream.read(reinterpret_cast<s8*>(buffer), (std::streamsize)maxValidLength);\n        \n        CS_ASSERT(!m_fileStream.fail(), \"Unexpected error occured in filestream\");\n        \n        return true;\n    }\n    //------------------------------------------------------------------------------\n    ByteBufferUPtr BinaryInputStream::Read(u64 length) noexcept\n    {\n        CS_ASSERT(IsValid(), \"Trying to use an invalid FileStream.\");\n        \n        if(m_fileStream.eof())\n        {\n            return nullptr;\n        }\n        \n        //Ensure that we never overrun the file stream\n        const auto currentPosition = GetReadPosition();\n        const auto maxValidLength = std::min(m_length - currentPosition, length);\n        \n        if(maxValidLength == 0)\n        {\n            return nullptr;\n        }\n        \n        s8* data = new s8[maxValidLength];\n        m_fileStream.read(data, (std::streamsize)maxValidLength);\n        \n        CS_ASSERT(!m_fileStream.fail(), \"Unexpected error occured in filestream\");\n\n        std::unique_ptr<const u8[]> uniqueData(reinterpret_cast<const u8*>(data));\n        return ByteBufferUPtr(new ByteBuffer(std::move(uniqueData), u32(maxValidLength)));\n    }\n    //------------------------------------------------------------------------------\n    BinaryInputStream::~BinaryInputStream() noexcept\n    {\n        if(m_fileStream.is_open())\n        {\n            m_fileStream.close();\n        }\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Core/File/FileStream/BinaryInputStream.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright © 2016 Tag Games. All rights reserved.\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_FILE_FILESTREAM_BINARYINPUTSTREAM_H_\n#define _CHILLISOURCE_CORE_FILE_FILESTREAM_BINARYINPUTSTREAM_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/File/FileStream/IBinaryInputStream.h>\n\n#include <fstream>\n\nnamespace ChilliSource\n{\n    /// Class to provide binary read functionality for a file\n    ///\n    /// TextInputStream is thread agnostic, but not thread-safe.\n    /// i.e. Instances can be used by one thread at a time. It doesn't matter\n    /// which thread as long as any previous threads are no longer accessing it\n    ///\n    class BinaryInputStream final : public IBinaryInputStream\n    {\n    public:\n        \n        CS_DECLARE_NOCOPY(BinaryInputStream);\n        \n        /// This will create the filestream from the path passed in and evaluate if\n        /// the stream is valid. After construction, IsValid() should be called to\n        /// ensure the stream was created without errors before proceeding to call\n        /// further functionality.\n        ///\n        /// @param filepath\n        ///     The absolute path to a file\n        ///\n        BinaryInputStream(const std::string& filePath) noexcept;\n        \n        /// Checks the status of the stream, if this returns false then the stream\n        /// can no longer be accessed.\n        ///\n        /// @return If the stream is valid and available for use.\n        ///\n        bool IsValid() const noexcept override;\n        \n        /// @return Length of stream in bytes.\n        ///\n        u64 GetLength() const noexcept override;\n        \n        /// Gets the position from which the next read operation will begin. The position\n        /// is always specified relative to the start of the file\n        ///\n        /// @return The position from the start of the stream.\n        ///\n        u64 GetReadPosition() noexcept override;\n        \n        /// Sets the position through the stream from which the next read operation will\n        /// begin. The position is always specified relative to the start of the file. This does\n        /// not affect the output of ReadAll().\n        ///\n        /// @param readPosition\n        ///     The position from the start of the stream.\n        ///\n        void SetReadPosition(u64 readPosition) noexcept override;\n        \n        /// Reads in a number of characters from the current read position and puts them\n        /// into the passed buffer. If the length of the stream is overrun, the buffer\n        /// will contain everything up to that point.\n        ///\n        /// If the current read position is at the end of the file, this function will return\n        /// false.\n        ///\n        /// @param buffer\n        ///     The buffer to read into.\n        /// @param length\n        ///     The number of characters to read.\n        ///\n        /// @return If the read was successful\n        ///\n        bool Read(u8* buffer, u64 length) noexcept override;\n        \n        /// @return The resulting read bytes wrapped in a BinaryStreamBuffer object. This\n        ///     will be nullptr for empty files\n        ///\n        ByteBufferUPtr ReadAll() noexcept override;\n\n        /// Reads in a number of characters from the current read position and puts them\n        /// into a BinaryStreamBuffer. If the length of the stream is overrun, the buffer\n        /// will contain everything up to that point.\n        ///\n        /// If the current read position is at the end of the file, this function will return\n        /// nullptr.\n        ///\n        /// @param length\n        ///     The number of characters to read\n        ///\n        /// @return The resulting read bytes wrapped in a BinaryStreamBuffer object\n        ///\n        ByteBufferUPtr Read(u64 length) noexcept override;\n        \n        /// Destructor\n        ///\n        ~BinaryInputStream() noexcept;\n        \n    private:\n        \n        bool m_isValid = false;\n        std::ifstream m_fileStream;\n        u64 m_length = 0;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/File/FileStream/BinaryOutputStream.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright © 2016 Tag Games. All rights reserved.\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Core/File/FileStream/BinaryOutputStream.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    BinaryOutputStream::BinaryOutputStream(const std::string& filePath, FileWriteMode fileMode) noexcept\n    {\n        m_fileStream.open(filePath.c_str(), ToOpenMode(fileMode));\n        m_isValid = m_fileStream.is_open() && !m_fileStream.bad() && !m_fileStream.fail();\n    }\n    //------------------------------------------------------------------------------\n    bool BinaryOutputStream::IsValid() const noexcept\n    {\n        return m_isValid;\n    }\n    //------------------------------------------------------------------------------\n    void BinaryOutputStream::Write(const u8* data, u64 length) noexcept\n    {\n        CS_ASSERT(IsValid(), \"Trying to use an invalid FileStream.\");\n        m_fileStream.write(reinterpret_cast<const s8*>(data), (std::streamsize)length);\n        CS_ASSERT(!m_fileStream.fail(), \"Unexpected error occured writing to the stream.\");\n    }\n    //------------------------------------------------------------------------------\n    void BinaryOutputStream::Write(const ByteBufferUPtr& byteBuffer) noexcept\n    {\n        CS_ASSERT(IsValid(), \"Trying to use an invalid FileStream.\");\n        m_fileStream.write(reinterpret_cast<const s8*>(byteBuffer->GetData()), byteBuffer->GetLength());\n        CS_ASSERT(!m_fileStream.fail(), \"Unexpected error occured writing to the stream.\");\n    }\n    //------------------------------------------------------------------------------\n    BinaryOutputStream::~BinaryOutputStream() noexcept\n    {\n        if(m_fileStream.is_open())\n        {\n            //Close also flushes the changes to disk\n            m_fileStream.close();\n        }\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Core/File/FileStream/BinaryOutputStream.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright © 2016 Tag Games. All rights reserved.\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_FILE_FILESTREAM_BINARYOUTPUTSTREAM_H_\n#define _CHILLISOURCE_CORE_FILE_FILESTREAM_BINARYOUTPUTSTREAM_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Base/ByteBuffer.h>\n#include <ChilliSource/Core/File/FileStream/FileWriteMode.h>\n\n#include <fstream>\n\nnamespace ChilliSource\n{\n    /// Class to provide binary write functionality for a file.\n    ///\n    /// Calling Write() on this stream will not cause a flush to disk, this will\n    /// only occur when the destructer is called.\n    ///\n    /// If a BinaryOutputStream is created with an existing file, that file will\n    /// be overwritten, regardless of whether or not a Write() was carried out, unless\n    /// the append file mode is used.\n    ///\n    /// BinaryOutputStream is thread agnostic, but not thread-safe.\n    /// i.e. Instances can used by one thread at a time. It\n    /// doesn't matter which thread as long as any previous threads\n    /// are no longer accessing it.\n    ///\n    class BinaryOutputStream final\n    {\n    public:\n        \n        CS_DECLARE_NOCOPY(BinaryOutputStream);\n        \n        /// This will create the filestream from the path passed in and evaluate if\n        /// the stream is valid. After construction, IsValid() should be called to\n        /// ensure the stream was created without errors before proceeding to call\n        /// further functionality.\n        ///\n        /// @param filepath\n        ///     The absolute path to a file\n        /// @param fileMode\n        ///     The mode to open the file with.\n        ///\n        BinaryOutputStream(const std::string& filePath, FileWriteMode fileMode) noexcept;\n        \n        /// Checks the status of the stream, if this returns false then the stream\n        /// can no longer be accessed.\n        ///\n        /// @return If the stream is valid and available for use\n        ///\n        bool IsValid() const noexcept;\n        \n        /// Writes byte data to the stream. It may not write out to file yet, but\n        /// if the buffer is full it'll flush.\n        ///\n        /// Multiple calls to this function will append to any contents already\n        /// written to the buffer.\n        ///\n        /// @param data\n        ///\t\tThe string data to write to the stream\n        /// @param length\n        ///     The length of the data to write\n        ///\n        void Write(const u8* data, u64 length) noexcept;\n        \n        /// Writes ByteBuffer data to the stream. It may not write out to file yet,\n        /// but if the buffer is full it'll flush.\n        ///\n        /// Multiple calls to this function will append to any contents already\n        /// written to the buffer.\n        ///\n        /// @param byteBuffer\n        ///\t\tThe ByteBuffer object to write to the stream\n        ///\n        void Write(const ByteBufferUPtr& byteBuffer) noexcept;\n        \n        /// Writes a standard layout data type to the stream. It may not write out\n        /// to file yet, but if the buffer is full it'll flush.\n        ///\n        /// This will static_assert if TType is not a standard layout type\n        ///\n        /// Multiple calls to this function will append to any contents already\n        /// written to the buffer.\n        ///\n        /// @param data\n        ///\t\tThe data to write to the stream\n        ///\n        template<typename TType> void Write(TType data) noexcept;\n\n        /// This will write any pending data written to this stream to disk\n        /// and close the stream\n        ///\n        ~BinaryOutputStream() noexcept;\n        \n    private:\n        \n        bool m_isValid = false;\n        std::ofstream m_fileStream;\n    };\n    //------------------------------------------------------------------------------\n    template<typename TType> void BinaryOutputStream::Write(TType data) noexcept\n    {\n        static_assert(std::is_standard_layout<TType>::value, \"TType must be standard layout type\");\n        static_assert(!std::is_pointer<TType>::value, \"TType cannot be a pointer\");\n        \n        CS_ASSERT(IsValid(), \"Trying to use an invalid FileStream.\");\n        Write(reinterpret_cast<const u8*>(&data), sizeof(TType));\n        CS_ASSERT(!m_fileStream.fail(), \"Unexpected error occured writing to the stream.\");\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/File/FileStream/FileWriteMode.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright © 2016 Tag Games. All rights reserved.\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Core/File/FileStream/FileWriteMode.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    std::ios_base::openmode ToOpenMode(FileWriteMode outputFileMode) noexcept\n    {\n        //We use the binary mode for text to ensure no platform specific formatting is appended\n        switch (outputFileMode)\n        {\n            case FileWriteMode::k_overwrite:\n                return std::ios_base::out | std::ios_base::binary;\n            case FileWriteMode::k_append:\n                return std::ios_base::out | std::ios_base::binary | std::ios_base::app;\n            default:\n                CS_LOG_FATAL(\"Unhandled FileWriteMode case.\");\n                break;\n        }\n        \n        return std::ios_base::out | std::ios_base::binary;\n    }\n}"
  },
  {
    "path": "Source/ChilliSource/Core/File/FileStream/FileWriteMode.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright © 2016 Tag Games. All rights reserved.\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_FILE_FILESTREAM_FILEWRITEMODE_H_\n#define _CHILLISOURCE_CORE_FILE_FILESTREAM_FILEWRITEMODE_H_\n\n#include <ChilliSource/ChilliSource.h>\n\nnamespace ChilliSource\n{\n    /// Specifies the modes an Text/BinaryOutputStream file can be opened with.\n    ///\n    enum class FileWriteMode\n    {\n        k_overwrite,\n        k_append\n    };\n    \n    /// Converts an FileWriteMode to a std openmode for use in\n    /// file opening.\n    ///\n    /// @param outputFileMode\n    ///     The FileWriteMode to convert.\n    ///\n    /// @return The std open mode.\n    ///\n    std::ios_base::openmode ToOpenMode(FileWriteMode outputFileMode) noexcept;\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/File/FileStream/IBinaryInputStream.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright © 2016 Tag Games. All rights reserved.\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n\n#ifndef _CHILLISOURCE_CORE_FILE_FILESTREAM_IBINARYINPUTSTREAM_H_\n#define _CHILLISOURCE_CORE_FILE_FILESTREAM_IBINARYINPUTSTREAM_H_\n\n#include <ChilliSource/ChilliSource.h>\n\n#include <ChilliSource/Core/Base/ByteBuffer.h>\n#include <ChilliSource/Core/ForwardDeclarations.h>\n\nnamespace ChilliSource\n{\n    /// Interface for classes to provide binary read functionality for a file\n    ///\n    /// Implementations shoud be considered thread agnostic, but not thread-safe.\n    /// i.e. Instances can be used by one thread at a time. It doesn't matter\n    /// which thread as long as any previous threads are no longer accessing it\n    ///\n    class IBinaryInputStream\n    {\n    public:\n        \n        /// Checks the status of the stream, if this returns false then the stream\n        /// can no longer be accessed.\n        ///\n        /// @return If the stream is valid and available for use.\n        ///\n        virtual bool IsValid() const noexcept = 0;\n        \n        /// @return Length of stream in bytes.\n        ///\n        virtual u64 GetLength() const noexcept = 0;\n        \n        /// Gets the position from which the next read operation will begin. The position\n        /// is always specified relative to the start of the file\n        ///\n        /// @return The position from the start of the stream.\n        ///\n        virtual u64 GetReadPosition() noexcept = 0;\n        \n        /// Sets the position through the stream from which the next read operation will\n        /// begin. The position is always specified relative to the start of the file. This does\n        /// not affect the output of ReadAll().\n        ///\n        /// @param readPosition\n        ///     The position from the start of the stream.\n        ///\n        virtual void SetReadPosition(u64 readPosition) noexcept = 0;\n        \n        /// @return The resulting read bytes wrapped in a BinaryStreamBuffer object. This\n        ///     will be nullptr for empty files\n        ///\n        virtual ByteBufferUPtr ReadAll() noexcept = 0;\n        \n        /// Reads in a number of characters from the current read position and puts them\n        /// into the passed buffer. If the length of the stream is overrun, the buffer\n        /// will contain everything up to that point.\n        ///\n        /// If the current read position is at the end of the file, this function will return\n        /// false.\n        ///\n        /// @param buffer\n        ///     The buffer to read into.\n        /// @param length\n        ///     The number of characters to read.\n        ///\n        /// @return If the read was successful\n        ///\n        virtual bool Read(u8* buffer, u64 length) noexcept = 0;\n        \n        /// Reads in a number of characters from the current read position and puts them\n        /// into a BinaryStreamBuffer. If the length of the stream is overrun, the buffer\n        /// will contain everything up to that point.\n        ///\n        /// If the current read position is at the end of the file, this function will return\n        /// nullptr.\n        ///\n        /// @param length\n        ///     The number of characters to read\n        ///\n        /// @return The resulting read bytes wrapped in a BinaryStreamBuffer object\n        ///\n        virtual ByteBufferUPtr Read(u64 length) noexcept = 0;\n        \n        /// Reads in the next number of bytes, specified by size of TType, and returns the data\n        /// as that type.\n        ///\n        /// If the buffer overruns before the end of the POD can be reached or the current position\n        /// is already at the EOF, an assert will be triggered.\n        ///\n        /// TType must be a POD type.\n        ///\n        /// @return The resulting bytes cast as TType\n        ///\n        template<typename TType> TType Read() noexcept;\n        \n        virtual ~IBinaryInputStream() noexcept {};\n    };\n    //------------------------------------------------------------------------------\n    template<typename TType> TType IBinaryInputStream::Read() noexcept\n    {\n        static_assert(std::is_standard_layout<TType>::value, \"TType must be standard layout type\");\n        static_assert(!std::is_pointer<TType>::value, \"TType cannot be a pointer\");\n        \n        const auto readData = Read(sizeof(TType));\n        \n        CS_ASSERT(readData, \"Could not read any data from the stream.\");\n        CS_ASSERT(readData->GetLength() == sizeof(TType), \"Could not read the correct size, Type data could not be read.\");\n        \n        return *reinterpret_cast<const TType*>(readData->GetData());\n    }\n}\n\n#endif"
  },
  {
    "path": "Source/ChilliSource/Core/File/FileStream/ITextInputStream.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright © 2016 Tag Games. All rights reserved.\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n\n#ifndef _CHILLISOURCE_CORE_FILE_FILESTREAM_ITEXTINPUTSTREAM_H_\n#define _CHILLISOURCE_CORE_FILE_FILESTREAM_ITEXTINPUTSTREAM_H_\n\n#include <ChilliSource/ChilliSource.h>\n\nnamespace ChilliSource\n{\n    /// Interface for classes to provide textual read functionality for a file\n    ///\n    /// Implementations shoud be considered thread agnostic, but not thread-safe.\n    /// i.e. Instances can be used by one thread at a time. It doesn't matter\n    /// which thread as long as any previous threads are no longer accessing it\n    ///\n    class ITextInputStream\n    {\n    public:\n        \n        /// Checks the status of the stream, if this returns false then the stream\n        /// can no longer be accessed.\n        ///\n        /// @return If the stream is valid and available for use.\n        ///\n        virtual bool IsValid() const noexcept = 0;\n        \n        /// @return Length of stream in bytes.\n        ///\n        virtual u64 GetLength() const noexcept = 0;\n        \n        /// Gets the position from which the next read operation will begin. The position\n        /// is always specified relative to the start of the file\n        ///\n        /// @return The position from the start of the stream.\n        ///\n        virtual u64 GetReadPosition() noexcept = 0;\n        \n        /// Sets the position through the stream from which the next read operation will\n        /// begin. The position is always specified relative to the start of the file. This does\n        /// not affect the output of ReadAll().\n        ///\n        /// @param readPosition\n        ///     The position from the start of the stream.\n        ///\n        virtual void SetReadPosition(u64 readPosition) noexcept = 0;\n        \n        /// @return String containing the contents of the text file, including newlines\n        ///\n        virtual std::string ReadAll() noexcept = 0;\n        \n        /// Reads from the current read position until the newline character ('\\n') or EOF\n        /// is reached. If the current read position is at the end of the file on entrance\n        /// then this will return false\n        ///\n        /// @param line\n        ///     String buffer that will be populated, this will not contain newline characters\n        ///\n        /// @return If a line was read successfully\n        ///\n        virtual bool ReadLine(std::string& line) noexcept = 0;\n        \n        /// Reads in a number of characters from the current read position and puts them\n        /// into the passed in string. If the length of the stream is overrun, readChars\n        /// will contain everything up to that point.\n        ///\n        /// If the current read position is at the end of the file, this function will return\n        /// false.\n        ///\n        /// @param length\n        ///     The number of characters to read\n        ///\n        /// @param readChars\n        ///     A string to hold the read characters, including newlines\n        ///\n        /// @return If the read was successfull\n        ///\n        virtual bool Read(u64 length, std::string& readLine) noexcept = 0;\n        \n        /// Destructor\n        ///\n        virtual ~ITextInputStream() noexcept {};\n    };\n}\n\n#endif"
  },
  {
    "path": "Source/ChilliSource/Core/File/FileStream/TextInputStream.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright © 2016 Tag Games. All rights reserved.\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Core/File/FileStream/TextInputStream.h>\n\n#include <iostream>\n#include <sstream>\n#include <string>\n#include <cstdio>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    TextInputStream::TextInputStream(const std::string& filePath) noexcept\n    {\n        m_filename = filePath;\n        \n        //Opening the file in binary mode as tellg does not function correctly on all platforms in\n        //::in mode after a read is carried out on the stream\n        m_fileStream.open(m_filename.c_str(), std::ios_base::binary);\n        \n        m_isValid = m_fileStream.is_open() && !m_fileStream.bad() && !m_fileStream.fail();\n        \n        if(m_isValid)\n        {\n            m_fileStream.seekg(0, m_fileStream.end);\n            m_length = m_fileStream.tellg();\n            m_fileStream.seekg(0, m_fileStream.beg);\n        }\n    }\n    //------------------------------------------------------------------------------\n    TextInputStream::~TextInputStream() noexcept\n    {\n        if(m_fileStream.is_open())\n        {\n            m_fileStream.close();\n        }\n    }\n    //------------------------------------------------------------------------------\n    bool TextInputStream::IsValid() const noexcept\n    {\n        return m_isValid;\n    }\n    //------------------------------------------------------------------------------\n    u64 TextInputStream::GetLength() const noexcept\n    {\n        CS_ASSERT(IsValid(), \"Trying to use an invalid FileStream.\");\n\n        return m_length;\n    }\n    //------------------------------------------------------------------------------\n    u64 TextInputStream::GetReadPosition() noexcept\n    {\n        CS_ASSERT(IsValid(), \"Trying to use an invalid FileStream.\");\n        return m_fileStream.tellg();\n    }\n    //------------------------------------------------------------------------------\n    void TextInputStream::SetReadPosition(u64 readPosition) noexcept\n    {\n        CS_ASSERT(IsValid(), \"Trying to use an invalid FileStream.\");\n        CS_ASSERT(readPosition <= GetLength(), \"Position out of bounds!\");\n\n        m_fileStream.seekg(readPosition);\n    }\n    //------------------------------------------------------------------------------\n    std::string TextInputStream::ReadAll() noexcept\n    {\n        CS_ASSERT(IsValid(), \"Trying to use an invalid FileStream.\");\n        \n        //Reset the read position to the beginning\n        SetReadPosition(0);\n        \n        std::stringstream stringStream;\n        stringStream << m_fileStream.rdbuf();\n        \n        std::string fileContents = stringStream.str();\n        \n        return fileContents;\n    }\n    //------------------------------------------------------------------------------\n    bool TextInputStream::ReadLine(std::string& line) noexcept\n    {\n        CS_ASSERT(IsValid(), \"Trying to use an invalid FileStream.\");\n        \n        if(m_fileStream.eof())\n        {\n            return false;\n        }\n        \n        std::getline(m_fileStream, line);\n        \n        //Shouldn't check fail here as the fail bit will be set on a read overrun, which we handle\n        CS_ASSERT(!m_fileStream.bad(), \"Unexpected error occured in filestream\");\n        \n        //Need to carry out another eof check here, as the check at the start of the function may\n        //not catch allcases. The EOF bit is only set when a read operation is attempted, not a seekg,\n        //so it may only be set after the above getline.\n        if(m_fileStream.eof())\n        {\n            return !line.empty();\n        }\n        \n        return true;\n    }\n    //------------------------------------------------------------------------------\n    bool TextInputStream::Read(u64 length, std::string& readChars) noexcept\n    {\n        CS_ASSERT(IsValid(), \"Trying to use an invalid FileStream.\");\n        \n        if(m_fileStream.eof())\n        {\n            return false;\n        }\n        \n        readChars.resize((std::string::size_type)length);\n        \n        //A string is guaranteed to be in contiguous memory in the c++11 standard, but not in c++03.\n        //this allows the below overwrite to work\n        m_fileStream.read(&readChars[0], (std::streamsize)length);\n        \n        //Shouldn't check fail here as the fail bit will be set on a read overrun, which we handle\n        CS_ASSERT(!m_fileStream.bad(), \"Unexpected error occured in filestream\");\n        \n        readChars.resize(m_fileStream.gcount());\n        \n        //Need to carry out another eof check here, as the check at the start of the function may\n        //not catch allcases. The EOF bit is only set when a read operation is attempted, not a seekg,\n        //so it may only be set after the above read.\n        if(m_fileStream.eof())\n        {\n            return m_fileStream.gcount() != 0;\n        }\n        \n        return true;\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Core/File/FileStream/TextInputStream.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright © 2016 Tag Games. All rights reserved.\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n\n#ifndef _CHILLISOURCE_CORE_FILE_FILESTREAM_TEXTINPUTSTREAM_H_\n#define _CHILLISOURCE_CORE_FILE_FILESTREAM_TEXTINPUTSTREAM_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/File/FileStream/ITextInputStream.h>\n\n#include <fstream>\n\nnamespace ChilliSource\n{\n    /// Class to provide textual read functionality for a file\n    ///\n    /// TextInputStream is thread agnostic, but not thread-safe.\n    /// i.e. Instances can be used by one thread at a time. It doesn't matter\n    /// which thread as long as any previous threads are no longer accessing it\n    ///\n    class TextInputStream final : public ITextInputStream\n    {\n    public:\n\n\t\tCS_DECLARE_NOCOPY(TextInputStream);\n\n        /// This will create the filestream from the path passed in and evaluate if\n        /// the stream is valid. After construction, IsValid() should be called to\n        /// ensure the stream was created without errors before proceeding to call\n        /// further functionality.\n        ///\n        /// @param filepath\n        ///     The absolute path to a file\n        ///\n        TextInputStream(const std::string& filePath) noexcept;\n        \n        /// Checks the status of the stream, if this returns false then the stream\n        /// can no longer be accessed.\n        ///\n        /// @return If the stream is valid and available for use\n        ///\n        bool IsValid() const noexcept override;\n        \n        /// @return The Length of stream in bytes\n        ///\n        u64 GetLength() const noexcept override;\n        \n        /// Gets the position from which the next read operation will begin. The position\n        /// is always specified relative to the start of the file\n        ///\n        /// @return The position from the start of the stream.\n        ///\n        u64 GetReadPosition() noexcept override;\n        \n        /// Sets the position through the stream from which the next read operation will\n        /// begin. The position is always specified relative to the start of the file. This does\n        /// not affect the output of ReadAll().\n        ///\n        /// @param readPosition\n        ///     The position from the start of the stream.\n        ///\n        void SetReadPosition(u64 readPosition) noexcept override;\n        \n        /// @return String containing the contents of the text file, including newlines\n        ///\n        std::string ReadAll() noexcept override;\n        \n        /// Reads from the current read position until the newline character ('\\n') or EOF\n        /// is reached. If the current read position is at the end of the file on entrance\n        /// then this will return false\n        ///\n        /// @param line\n        ///     String buffer that will be populated, this will not contain newline characters\n        ///\n        /// @return If a line was read successfully\n        ///\n        bool ReadLine(std::string& line) noexcept override;\n        \n        /// Reads in a number of characters from the current read position and puts them\n        /// into the passed in string. If the length of the stream is overrun, readChars\n        /// will contain everything up to that point.\n        ///\n        /// If the current read position is at the end of the file, this function will return\n        /// false.\n        ///\n        /// @param length\n        ///     The number of characters to read\n        ///\n        /// @param readChars\n        ///     A string to hold the read characters, including newlines\n        ///\n        /// @return If the read was successfull\n        ///\n        bool Read(u64 length, std::string& readChars) noexcept override;\n        \n        /// Destructor\n        ///\n        ~TextInputStream() noexcept;\n        \n    private:\n        \n        u64 m_length = 0;\n        bool m_isValid = false;\n        std::string m_filename;\n        std::ifstream m_fileStream;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/File/FileStream/TextOutputStream.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright © 2016 Tag Games. All rights reserved.\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Core/File/FileStream/TextOutputStream.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    TextOutputStream::TextOutputStream(const std::string& filePath, FileWriteMode fileMode) noexcept\n    {\n        m_fileStream.open(filePath.c_str(), ToOpenMode(fileMode));\n\t\tm_isValid = m_fileStream.is_open() && !m_fileStream.bad() && !m_fileStream.fail();\n    }\n    //------------------------------------------------------------------------------\n    bool TextOutputStream::IsValid() const noexcept\n    {\n        return m_isValid;\n    }\n    //------------------------------------------------------------------------------\n    void TextOutputStream::Write(const std::string& data) noexcept\n    {\n        CS_ASSERT(IsValid(), \"Trying to use an invalid FileStream.\");\n        m_fileStream.write(data.c_str(), data.length());\n        CS_ASSERT(!m_fileStream.fail(), \"Unexpected error occured writing to the stream.\");\n    }\n    //------------------------------------------------------------------------------\n    TextOutputStream::~TextOutputStream() noexcept\n    {\n        if(m_fileStream.is_open())\n        {\n            //Close also flushes the changes to disk\n            m_fileStream.close();\n        }\n    }\n}"
  },
  {
    "path": "Source/ChilliSource/Core/File/FileStream/TextOutputStream.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright © 2016 Tag Games. All rights reserved.\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n\n#ifndef _CHILLISOURCE_CORE_FILE_FILESTREAM_TEXTOUTPUTSTREAM_H_\n#define _CHILLISOURCE_CORE_FILE_FILESTREAM_TEXTOUTPUTSTREAM_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/File/FileStream/FileWriteMode.h>\n\n#include <fstream>\n\nnamespace ChilliSource\n{\n    /// Class to provide textual write functionality for a file.\n\t///\n\t/// Calling Write() on this stream will not cause a flush to disk, this will\n\t/// only occur when the destructer is called.\n\t///\n\t/// If a TextOutputStream is created with an existing file, that file will\n    /// be overwritten, regardless of whether or not a Write() was carried out, unless\n    /// the append file mode is used.\n    ///\n    /// OutputTextStream is thread agnostic, but not thread-safe. i.e. Instances\n    /// can used by one thread at a time. It doesn't matter which thread as long\n    /// as any previous threads are no longer accessing it.\n    ///\n    class TextOutputStream final\n    {\n    public:\n\n\t\tCS_DECLARE_NOCOPY(TextOutputStream);\n\n        /// This will create the filestream from the path passed in and evaluate if\n        /// the stream is valid. After construction, IsValid() should be called to\n        /// ensure the stream was created without errors before proceeding to call\n        /// further functionality.\n        ///\n        /// @param filepath\n        ///     The absolute path to a file\n        /// @param fileMode\n        ///     The mode to open the file with.\n        ///\n        TextOutputStream(const std::string& filePath, FileWriteMode fileMode) noexcept;\n        \n        /// Checks the status of the stream, if this returns false then the stream\n        /// can no longer be accessed.\n        ///\n        /// @return If the stream is valid and available for use\n        ///\n        bool IsValid() const noexcept;\n        \n        /// Writes string data to the stream. It may not write out to file yet, but\n        /// if the buffer is full it'll flush.\n\t\t/// \n\t\t/// Multiple calls to this function will append to any contents already \n\t\t/// written.\n        ///\n        /// @param data\n\t\t///\t\tThe string data to write to the stream\n        ///\n        void Write(const std::string& data) noexcept;\n        \n        /// This will write any pending data written to this stream to disk\n        /// and close the stream\n        ///\n        ~TextOutputStream() noexcept;\n        \n    private:\n        \n        bool m_isValid = false;\n        std::ofstream m_fileStream;\n    };\n}\n\n#endif"
  },
  {
    "path": "Source/ChilliSource/Core/File/FileSystem.cpp",
    "content": "//\n//  FileSystem.cpp\n//  ChilliSource\n//  Created by Scott Downie on 07/07/2011.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2011 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Core/File/FileSystem.h>\n\n#include <ChilliSource/Core/Base/ByteBuffer.h>\n#include <ChilliSource/Core/Cryptographic/HashMD5.h>\n#include <ChilliSource/Core/Cryptographic/HashCRC32.h>\n#include <ChilliSource/Core/String/StringUtils.h>\n\n#ifdef CS_TARGETPLATFORM_IOS\n#include <CSBackend/Platform/iOS/Core/File/FileSystem.h>\n#endif\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n#include <CSBackend/Platform/Android/Main/JNI/Core/File/FileSystem.h>\n#endif\n\n#ifdef CS_TARGETPLATFORM_WINDOWS\n#include <CSBackend/Platform/Windows/Core/File/FileSystem.h>\n#include <CSBackend/Platform/Windows/Core/String/WindowsStringUtils.h>\n#endif\n\n#ifdef CS_TARGETPLATFORM_RPI\n#include <CSBackend/Platform/RPi/Core/File/FileSystem.h>\n#endif\n\n#include <md5/md5.h>\n\n#include <algorithm>\n\nnamespace ChilliSource\n{\n    namespace\n    {\n        const std::string k_defaultPackageDLCDirectory = \"DLC/\";\n        constexpr u32 k_maxSHA1Length = 80;\n        const u32 k_md5ChunkSize = 256;\n        const u32 k_sha1ChunkSize = 256;\n    }\n    CS_DEFINE_NAMEDTYPE(FileSystem);\n    \n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    FileSystemUPtr FileSystem::Create()\n    {\n#ifdef CS_TARGETPLATFORM_IOS\n        return FileSystemUPtr(new CSBackend::iOS::FileSystem());\n#endif\n#ifdef CS_TARGETPLATFORM_ANDROID\n        return FileSystemUPtr(new CSBackend::Android::FileSystem());\n#endif\n#ifdef CS_TARGETPLATFORM_WINDOWS\n        return FileSystemUPtr(new CSBackend::Windows::FileSystem());\n#endif\n#ifdef CS_TARGETPLATFORM_RPI\n        return FileSystemUPtr(new CSBackend::RPi::FileSystem());\n#endif\n        return nullptr;\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    FileSystem::FileSystem()\n        : m_packageDLCPath(k_defaultPackageDLCDirectory)\n    {\n    }\n    //--------------------------------------------------------------\n    //--------------------------------------------------------------\n    bool FileSystem::ReadFile(StorageLocation in_storageLocation, const std::string& in_directory, std::string& out_contents) const\n    {\n        ITextInputStreamUPtr fileStream = CreateTextInputStream(in_storageLocation, in_directory);\n        if (fileStream == nullptr)\n        {\n            return false;\n        }\n        \n        out_contents = fileStream->ReadAll();\n        \n        return true;\n    }\n    //--------------------------------------------------------------\n    //--------------------------------------------------------------\n    bool FileSystem::WriteFile(StorageLocation in_storageLocation, const std::string& in_directory, const std::string& in_contents) const\n    {\n        BinaryOutputStreamUPtr fileStream = CreateBinaryOutputStream(in_storageLocation, in_directory);\n        if (fileStream.get() == nullptr)\n        {\n            return false;\n        }\n        \n        fileStream->Write(reinterpret_cast<const u8*>(in_contents.c_str()), in_contents.size());\n        \n        return true;\n    }\n    //--------------------------------------------------------------\n    //--------------------------------------------------------------\n    bool FileSystem::WriteFile(StorageLocation in_storageLocation, const std::string& in_directory, const s8* in_data, u32 in_dataSize) const\n    {\n        BinaryOutputStreamUPtr fileStream = CreateBinaryOutputStream(in_storageLocation, in_directory);\n        if (fileStream.get() == nullptr)\n        {\n            return false;\n        }\n        \n        fileStream->Write(reinterpret_cast<const u8*>(in_data), (s32)in_dataSize);\n        \n        return true;\n    }\n    //--------------------------------------------------------------\n    //--------------------------------------------------------------\n    std::vector<std::string> FileSystem::GetFilePathsWithExtension(StorageLocation in_storageLocation, const std::string& in_directoryPath,  bool in_recursive, const std::string& in_extension) const\n    {\n        std::vector<std::string> filePaths = GetFilePaths(in_storageLocation, in_directoryPath, in_recursive);\n        \n        std::string extension = \".\" + in_extension;\n        auto it = std::remove_if(filePaths.begin(), filePaths.end(), [&] (const std::string& in_path)\n        {\n            return (StringUtils::EndsWith(in_path, extension, true) == false);\n        });\n        \n        filePaths.resize(it - filePaths.begin());\n        \n        return filePaths;\n    }\n    //--------------------------------------------------------------\n    //--------------------------------------------------------------\n    std::vector<std::string> FileSystem::GetFilePathsWithFileName(StorageLocation in_storageLocation, const std::string& in_directoryPath,  bool in_recursive, const std::string& in_fileName) const\n    {\n        std::vector<std::string> filePaths = GetFilePaths(in_storageLocation, in_directoryPath, in_recursive);\n        \n        auto it = std::remove_if(filePaths.begin(), filePaths.end(), [&in_fileName] (const std::string& in_path)\n        {\n            return (StringUtils::EndsWith(in_path, in_fileName, true) == false);\n        });\n        \n        filePaths.resize(it - filePaths.begin());\n        \n        return filePaths;\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    void FileSystem::SetPackageDLCPath(const std::string& in_directoryPath)\n    {\n        std::unique_lock<std::mutex> lock(m_packageDLCPathMutex);\n        m_packageDLCPath = StringUtils::StandardiseDirectoryPath(in_directoryPath);\n    }\n    //--------------------------------------------------------------\n    //--------------------------------------------------------------\n    const std::string& FileSystem::GetPackageDLCPath() const\n    {\n        std::unique_lock<std::mutex> lock(m_packageDLCPathMutex);\n        return m_packageDLCPath;\n    }\n    //--------------------------------------------------------------\n    //--------------------------------------------------------------\n    std::string FileSystem::GetFileChecksumSHA1(StorageLocation in_storageLocation, const std::string& in_filePath, const CSHA1::REPORT_TYPE in_reportType) const\n    {\n        CS_LOG_WARNING(\"SHA-1 is deprecated and insecure. Please use SHA256.\");\n        \n        auto fileStream = CreateBinaryInputStream(in_storageLocation, in_filePath);\n        CS_ASSERT(fileStream, \"Could not open file: \" + in_filePath);\n\n        u64 currentPosition = fileStream->GetReadPosition();\n        u32 length = u32(fileStream->GetLength());\n        u8 data[k_sha1ChunkSize];\n        CSHA1 Hash;\n        Hash.Reset();\n\n        while(length >= k_sha1ChunkSize)\n        {\n            fileStream->Read(data, k_sha1ChunkSize);\n            \n            Hash.Update(reinterpret_cast<u8*>(data), k_sha1ChunkSize);\n            length -= k_sha1ChunkSize;\n        }\n        \n        // Last chunk\n        if(length > 0)\n        {\n            fileStream->Read(data, length);\n            Hash.Update(reinterpret_cast<u8*>(data), length);\n        }\n        \n        fileStream->SetReadPosition(currentPosition);\n        \n        Hash.Final();\n            \n#ifdef CS_TARGETPLATFORM_WINDOWS\n        TCHAR cHash[k_maxSHA1Length];\n        memset(cHash, 0, k_maxSHA1Length);\n        Hash.ReportHash(cHash, in_reportType);\n        return CSBackend::Windows::WindowsStringUtils::UTF16ToUTF8(std::wstring(cHash));\n#else\n        char cHash[k_maxSHA1Length];\n        memset(cHash, 0, k_maxSHA1Length);\n        Hash.ReportHash(cHash, in_reportType);\n        return std::string(cHash);\n#endif\n\n    }\n    //--------------------------------------------------------------\n    //--------------------------------------------------------------\n    std::string FileSystem::GetFileChecksumSHA256(StorageLocation in_storageLocation, const std::string& in_filePath) const\n    {\n        auto fileStream = CreateBinaryInputStream(in_storageLocation, in_filePath);\n        CS_ASSERT(fileStream, \"Could not open file: \" + in_filePath);\n        \n        u32 length = u32(fileStream->GetLength());\n\n        if(length == 0)\n        {\n            return \"\";\n        }\n        \n        SHA256 hash;\n        hash.reset();\n        \n        u8 fileData[SHA256::BlockSize];\n        \n        // Read chunks\n        while(length >= SHA256::BlockSize)\n        {\n            fileStream->Read(fileData, SHA256::BlockSize);\n            \n            hash.add(reinterpret_cast<const u8*>(fileData), SHA256::BlockSize);\n            length -= SHA256::BlockSize;\n        }\n        \n        // Last Chunk\n        if(length > 0)\n        {\n            fileStream->Read(fileData, length);\n            hash.add(reinterpret_cast<const u8*>(fileData), length);\n        }\n\n        return hash.getHash();\n    }\n    //--------------------------------------------------------------\n    //--------------------------------------------------------------\n    std::string FileSystem::GetFileChecksumMD5(StorageLocation storageLocation, const std::string& filePath) const\n    {\n        auto fileStream = CreateBinaryInputStream(storageLocation, filePath);\n        CS_ASSERT(fileStream, \"Could not open file: \" + filePath);\n        \n        u64 currentPosition = fileStream->GetReadPosition();\n        u32 length = u32(fileStream->GetLength());\n        u8 data[k_md5ChunkSize];\n        MD5 Hash;\n        \n        while(length >= k_md5ChunkSize)\n        {\n            fileStream->Read(data, k_md5ChunkSize);\n            Hash.update(data, k_md5ChunkSize);\n            length -= k_md5ChunkSize;\n        }\n        \n        // Last chunk\n        if(length > 0)\n        {\n            fileStream->Read(data, length);\n            Hash.update(data, length);\n        }\n        \n        fileStream->SetReadPosition(currentPosition);\n        \n        Hash.finalize();\n        return Hash.binarydigest();\n    }\n    //--------------------------------------------------------------\n    //--------------------------------------------------------------\n    std::string FileSystem::GetDirectoryChecksumMD5(StorageLocation in_storageLocation, const std::string& in_directoryPath) const\n    {\n        std::vector<std::string> filenames = GetFilePaths(in_storageLocation, in_directoryPath, true);\n        \n        //get a hash for each of the files.\n        std::vector<std::string> hashes;\n        for (const std::string& filename : filenames)\n        {\n            std::string fileHash = GetFileChecksumMD5(in_storageLocation, in_directoryPath + filename);\n            std::string pathHash = HashMD5::GenerateBinaryHashCode(filename.c_str(), static_cast<u32>(filename.length()));\n            hashes.push_back(fileHash);\n            hashes.push_back(pathHash);\n        }\n        \n        //sort the list so that ordering of\n        std::sort(hashes.begin(), hashes.end());\n        \n        //build this into a hashable string\n        std::string hashableDirectoryContents;\n        for (const std::string& hash : hashes)\n        {\n            hashableDirectoryContents += hash;\n        }\n        \n        //return the hash of this as the output\n        std::string strOutput = 0;\n        if (hashableDirectoryContents.length() > 0)\n        {\n            CS_ASSERT(hashableDirectoryContents.length() < static_cast<std::vector<std::string>::size_type>(std::numeric_limits<u32>::max()), \"Hashable directory contents too large. It cannot exceed \"\n                      + ToString(std::numeric_limits<u32>::max()) + \" characters.\");\n            \n            strOutput = HashMD5::GenerateBinaryHashCode(hashableDirectoryContents.c_str(), static_cast<u32>(hashableDirectoryContents.length()));\n        }\n        \n        return strOutput;\n    }\n    //--------------------------------------------------------------\n    //--------------------------------------------------------------\n    u32 FileSystem::GetFileChecksumCRC32(StorageLocation storageLocation, const std::string& filePath) const\n    {\n        u32 output = 0;\n\n        auto fileStream = CreateBinaryInputStream(storageLocation, filePath);\n        CS_ASSERT(fileStream, \"Could not open file: \" + filePath);\n\n        auto contents = fileStream->ReadAll();\n\n        //get the hash\n        output = HashCRC32::GenerateHashCode(reinterpret_cast<const s8*>(contents->GetData()), u32(contents->GetLength()));\n\n        return output;\n    }\n    //--------------------------------------------------------------\n    //--------------------------------------------------------------\n    u32 FileSystem::GetDirectoryChecksumCRC32(StorageLocation in_storageLocation, const std::string& in_directoryPath) const\n    {\n        std::vector<std::string> filenames = GetFilePaths(in_storageLocation, in_directoryPath, true);\n\n        //get a hash for each of the files.\n        std::vector<u32> hashes;\n        for (const std::string& filename : filenames)\n        {\n            u32 fileHash = GetFileChecksumCRC32(in_storageLocation, in_directoryPath + filename);\n            u32 pathHash = HashCRC32::GenerateHashCode(filename.c_str(), static_cast<u32>(filename.length()));\n            hashes.push_back(fileHash);\n            hashes.push_back(pathHash);\n        }\n\n        //sort the list so that ordering of\n        std::sort(hashes.begin(), hashes.end());\n\n        //build this into a hashable string\n        std::string hashableDirectoryContents;\n        for (const u32& hash : hashes)\n        {\n            hashableDirectoryContents += ToString(hash);\n        }\n\n        //return the hash of this as the output\n        u32 output = 0;\n        if (hashableDirectoryContents.length() > 0)\n        {\n            CS_ASSERT(hashableDirectoryContents.length() < static_cast<std::vector<std::string>::size_type>(std::numeric_limits<u32>::max()), \"Hashable directory contents too large. It cannot exceed \"\n                      + ToString(std::numeric_limits<u32>::max()) + \" characters.\");\n            \n            output = HashCRC32::GenerateHashCode(hashableDirectoryContents.c_str(), static_cast<u32>(hashableDirectoryContents.length()));\n        }\n        return output;\n    }\n    //--------------------------------------------------------------\n    //--------------------------------------------------------------\n    u64 FileSystem::GetFileSize(StorageLocation storageLocation, const std::string& filePath) const\n    {\n        auto fileStream = CreateBinaryInputStream(storageLocation, filePath);\n        CS_ASSERT(fileStream, \"Could not open file: \" + filePath);\n        \n        return fileStream->GetLength();\n    }\n    //--------------------------------------------------------------\n    //--------------------------------------------------------------\n    u64 FileSystem::GetDirectorySize(StorageLocation in_storageLocation, const std::string& in_directory) const\n    {\n        std::vector<std::string> filenames = GetFilePaths(in_storageLocation, in_directory, true);\n\n        u64 totalSize = 0;\n        for (const std::string& filename : filenames)\n        {\n            totalSize += GetFileSize(in_storageLocation, in_directory + \"/\" + filename);\n        }\n\n        return totalSize;\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    bool FileSystem::IsStorageLocationWritable(StorageLocation in_storageLocation) const\n    {\n        switch (in_storageLocation)\n        {\n            case StorageLocation::k_saveData:\n            case StorageLocation::k_cache:\n            case StorageLocation::k_DLC:\n            case StorageLocation::k_root:\n                return true;\n            default:\n                return false;\n        }\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Core/File/FileSystem.h",
    "content": "//\n//  FileSystem.h\n//  ChilliSource\n//  Created by Ian Copland on 25/03/2011.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2011 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_FILE_FILESYSTEM_H_\n#define _CHILLISOURCE_CORE_FILE_FILESYSTEM_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/File/FileStream/IBinaryInputStream.h>\n#include <ChilliSource/Core/File/FileStream/ITextInputStream.h>\n#include <ChilliSource/Core/File/FileStream/BinaryOutputStream.h>\n#include <ChilliSource/Core/File/FileStream/TextOutputStream.h>\n#include <ChilliSource/Core/File/StorageLocation.h>\n#include <ChilliSource/Core/System/AppSystem.h>\n\n#include <mutex>\n#include <SHA1/SHA1.h>\n#include <SHA256/sha256.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    /// A system for handling cross platform access to the file system. This\n    /// provides sandboxed access to specific locations on disk, such as access to\n    /// application assets, or save data. It is safe to use the File System during\n    /// the OnInit and OnDestroy lifecycle events.\n    ///\n    /// This is thread-safe though care still needs to be taken when dealing with\n    /// file streams as they are not. A file stream should be read and destroyed\n    /// on the same thread it was created.\n    ///\n    /// @author Ian Copland\n    //------------------------------------------------------------------------------\n    class FileSystem : public AppSystem\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(FileSystem);\n        //------------------------------------------------------------------------------\n        /// Reads the contents of a file from disc if the file exists.\n        ///\n        /// This is thread-safe.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param in_storageLocation - The Storage Location.\n        /// @param in_filePath - The file path.\n        /// @param out_contents - [Out] The contents of the file.\n        ///\n        /// @return Whether or not the file read was successful.\n        //------------------------------------------------------------------------------\n        bool ReadFile(StorageLocation in_storageLocation, const std::string& in_filePath, std::string& out_contents) const;\n        //------------------------------------------------------------------------------\n        /// Write a file to disc with the given data.\n        ///\n        /// This is thread-safe.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param in_storageLocation - The Storage Location.\n        /// @param in_filePath - The file path.\n        /// @param in_contents - The contents of the file.\n        ///\n        /// @return Whether or not the file was successfully written.\n        //------------------------------------------------------------------------------\n        bool WriteFile(StorageLocation in_storageLocation, const std::string& in_filePath, const std::string& in_contents) const;\n        //------------------------------------------------------------------------------\n        /// Write a file to disc with the given data.\n        ///\n        /// This is thread-safe.\n        ///\n        /// @author S Downie\n        ///\n        /// @param in_storageLocation - The Storage Location.\n        /// @param in_filePath - The file path.\n        /// @param in_data - The data.\n        /// @param in_dataSize - The size of the data.\n        ///\n        /// @return Whether or not the file was successfully written.\n        //------------------------------------------------------------------------------\n        bool WriteFile(StorageLocation in_storageLocation, const std::string& in_filePath, const s8* in_data, u32 in_dataSize) const;\n        //------------------------------------------------------------------------------\n        /// Creates a new input text stream to the given file in the given storage location.\n        ///\n        /// @author HMcLaughlin\n        ///\n        /// @param in_storageLocation - The storage location.\n        /// @param in_filePath - The file path.\n        ///\n        /// @return The new file stream. If the stream cannot be created or is invalid,\n        /// null be returned.\n        //------------------------------------------------------------------------------\n        virtual ITextInputStreamUPtr CreateTextInputStream(StorageLocation in_storageLocation, const std::string& in_filePath) const = 0;\n        //------------------------------------------------------------------------------\n        /// Creates a new input binary stream to the given file in the given storage location.\n        ///\n        /// @author HMcLaughlin\n        ///\n        /// @param in_storageLocation - The storage location.\n        /// @param in_filePath - The file path.\n        ///\n        /// @return The new file stream. If the stream cannot be created or is invalid,\n        /// null be returned.\n        //------------------------------------------------------------------------------\n        virtual IBinaryInputStreamUPtr CreateBinaryInputStream(StorageLocation in_storageLocation, const std::string& in_filePath) const = 0;\n        //------------------------------------------------------------------------------\n        /// Creates a new output text stream to the given file in the given storage location.\n        ///\n        /// @author HMcLaughlin\n        ///\n        /// @param in_storageLocation - The storage location.\n        /// @param in_filePath - The file path.\n        /// @param in_fileMode - The write mode to open the file with.\n        ///\n        /// @return The new file stream. If the stream cannot be created or is invalid,\n        /// null be returned.\n        //------------------------------------------------------------------------------\n        virtual TextOutputStreamUPtr CreateTextOutputStream(StorageLocation in_storageLocation, const std::string& in_filePath, FileWriteMode in_fileMode = FileWriteMode::k_overwrite) const = 0;\n        //------------------------------------------------------------------------------\n        /// Creates a new output binary stream to the given file in the given storage location.\n        ///\n        /// @author HMcLaughlin\n        ///\n        /// @param in_storageLocation - The storage location.\n        /// @param in_filePath - The file path.\n        /// @param in_fileMode - The write mode to open the file with.\n        ///\n        /// @return The new file stream. If the stream cannot be created or is invalid,\n        /// null be returned.\n        //------------------------------------------------------------------------------\n        virtual BinaryOutputStreamUPtr CreateBinaryOutputStream(StorageLocation in_storageLocation, const std::string& in_filePath, FileWriteMode in_fileMode = FileWriteMode::k_overwrite) const = 0;\n        //------------------------------------------------------------------------------\n        /// Creates the given directory. The full directory hierarchy will be created.\n        ///\n        /// This is thread-safe.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param in_storageLocation - The Storage Location\n        /// @param in_directoryPath - The directory path.\n        ///\n        /// @return Whether or not this was successful. Failure to create the directory\n        /// because it already exists is considered a success.\n        //------------------------------------------------------------------------------\n        virtual bool CreateDirectoryPath(StorageLocation in_storageLocation, const std::string& in_directoryPath) const = 0;\n        //------------------------------------------------------------------------------\n        /// Copies a file from one location to another.\n        ///\n        /// This is thread-safe.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param in_sourceStorageLocation - The source storage location.\n        /// @param in_sourceFilePath - The source directory.\n        /// @param in_destinationStorageLocation - The destination storage location.\n        /// @param in_destinationFilePath - The destination directory.\n        ///\n        /// @return Whether or not the file was successfully copied.\n        //------------------------------------------------------------------------------\n        virtual bool CopyFile(StorageLocation in_sourceStorageLocation, const std::string& in_sourceFilePath,\n                              StorageLocation in_destinationStorageLocation, const std::string& in_destinationFilePath) const = 0;\n        //------------------------------------------------------------------------------\n        /// Copies a directory from one location to another. If the destination\n        /// directory does not exist, it will be created.\n        ///\n        /// This is thread-safe.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param in_sourceStorageLocation - The source storage location.\n        /// @param in_sourceDirectoryPath - The source directory.\n        /// @param in_destinationStorageLocation - The destination storage location.\n        /// @param in_destinationDirectoryPath - The destination directory.\n        ///\n        /// @return Whether or not the files were successfully copied.\n        //------------------------------------------------------------------------------\n        virtual bool CopyDirectory(StorageLocation in_sourceStorageLocation, const std::string& in_sourceDirectoryPath,\n                                   StorageLocation in_destinationStorageLocation, const std::string& in_destinationDirectoryPath) const = 0;\n        //------------------------------------------------------------------------------\n        /// Deletes the specified file.\n        ///\n        /// This is thread-safe.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param in_storageLocation - The storage location.\n        /// @param in_filePath - The filepath.\n        ///\n        /// @return Whether or not the file was successfully deleted.\n        //------------------------------------------------------------------------------\n        virtual bool DeleteFile(StorageLocation in_storageLocation, const std::string& in_filePath) const = 0;\n        //------------------------------------------------------------------------------\n        /// Deletes a directory and all its contents.\n        ///\n        /// This is thread-safe.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param in_storageLocation - The storage location.\n        /// @param in_directoryPath - The directory.\n        ///\n        /// @return Whether or not the directory was successfully deleted.\n        //------------------------------------------------------------------------------\n        virtual bool DeleteDirectory(StorageLocation in_storageLocation, const std::string& in_directoryPath) const = 0;\n        //------------------------------------------------------------------------------\n        /// Creates a dynamic array containing the file names of each file in the given\n        /// directory. File paths will be relative to the input directory.\n        ///\n        /// This is thread-safe.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param in_storageLocation - The Storage Location\n        /// @param in_directoryPath - The directory\n        /// @param in_recursive - Flag to determine whether or not to recurse into sub\n        /// directories\n        ///\n        /// @return dynamic array containing the file names.\n        //------------------------------------------------------------------------------\n        virtual std::vector<std::string> GetFilePaths(StorageLocation in_storageLocation, const std::string& in_directoryPath,  bool in_recursive) const = 0;\n        //------------------------------------------------------------------------------\n        /// Creates a dynamic array containing the file names of each file that has the\n        /// provided extension in the given directory. File paths will be returned\n        /// relative to the input directory.\n        ///\n        /// This is thread-safe.\n        ///\n        /// @author S Downie\n        ///\n        /// @param in_storageLocation - The Storage Location\n        /// @param in_directoryPath - The directory path.\n        /// @param in_recursive - Flag to determine whether or not to recurse into sub\n        /// directories\n        /// @param in_extension - The extension\n        ///\n        /// @return Dynamic array containing the file names.\n        //------------------------------------------------------------------------------\n        std::vector<std::string> GetFilePathsWithExtension(StorageLocation in_storageLocation, const std::string& in_directoryPath,  bool in_recursive, const std::string& in_extension) const;\n        //------------------------------------------------------------------------------\n        /// Creates a dynamic array containing the file names of each of each file with\n        /// the given name in the given directory. File paths will be relative to the\n        /// input directory.\n        ///\n        /// This is thread-safe.\n        ///\n        /// @author S Downie\n        ///\n        /// @param in_storageLocation - The Storage Location.\n        /// @param in_directoryPath - The directory.\n        /// @param in_recursive - Flag to determine whether or not to recurse into sub\n        /// directories.\n        /// @param in_fileName - The file name.\n        ///\n        /// @return Dynamic array containing the file names.\n        //------------------------------------------------------------------------------\n        std::vector<std::string> GetFilePathsWithFileName(StorageLocation in_storageLocation, const std::string& in_directoryPath,  bool in_recursive, const std::string& in_fileName) const;\n        //------------------------------------------------------------------------------\n        /// Creates a dynamic array containing the names of each directory in the given\n        /// directory. Directory paths will be relative to the input directory.\n        ///\n        /// This is thread-safe.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param in_storageLocation - The Storage Location\n        /// @param in_directoryPath - The directory\n        /// @param in_recursive - Flag to determine whether or not to recurse into sub\n        /// directories\n        ///\n        /// @return Output dynamic array containing the dir names.\n        //------------------------------------------------------------------------------\n        virtual std::vector<std::string> GetDirectoryPaths(StorageLocation in_storageLocation, const std::string& in_directoryPath,  bool in_recursive) const = 0;\n        //------------------------------------------------------------------------------\n        /// returns whether or not the given file exists.\n        ///\n        /// This is thread-safe.\n        ///\n        /// @author Ian Copland\n        /// \n        /// @param in_storageLocation - The Storage Location\n        /// @param in_filePath - The file path\n        ///\n        /// @return Whether or not it exists.\n        //------------------------------------------------------------------------------\n        virtual bool DoesFileExist(StorageLocation in_storageLocation, const std::string& in_filePath) const = 0;\n        //------------------------------------------------------------------------------\n        /// This is thread-safe.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param in_filePath - The file path.\n        ///\n        /// @return Whether or not the file exists in the Cached DLC directory.\n        //------------------------------------------------------------------------------\n        virtual bool DoesFileExistInCachedDLC(const std::string& in_filePath) const = 0;\n        //------------------------------------------------------------------------------\n        /// This is thread-safe.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param in_filePath - The file path.\n        ///\n        /// @return Whether or not the file exists in the package DLC directory.\n        //------------------------------------------------------------------------------\n        virtual bool DoesFileExistInPackageDLC(const std::string& in_filePath) const = 0;\n        //------------------------------------------------------------------------------\n        /// This is thread-safe.\n        ///\n        /// @author Ian Copland\n        /// \n        /// @param in_storageLocation - The Storage Location\n        /// @param in_directoryPath - The directory path\n        ///\n        /// @return Whether or not the given directory exists.\n        //------------------------------------------------------------------------------\n        virtual bool DoesDirectoryExist(StorageLocation in_storageLocation, const std::string& in_directoryPath) const = 0;\n        //------------------------------------------------------------------------------\n        /// This is thread-safe.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param in_directoryPath - The directory path.\n        ///\n        /// @return Whether or not the directory exists in the Cached DLC directory.\n        //------------------------------------------------------------------------------\n        virtual bool DoesDirectoryExistInCachedDLC(const std::string& in_directoryPath) const = 0;\n        //------------------------------------------------------------------------------\n        /// This is thread-safe.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param in_directoryPath - The directory path.\n        ///\n        /// @return Whether or not the directory exists in the package DLC directory.\n        //------------------------------------------------------------------------------\n        virtual bool DoesDirectoryExistInPackageDLC(const std::string& in_directoryPath) const = 0;\n        //------------------------------------------------------------------------------\n        /// Returns the absolute path to the given storage location. The value this\n        /// returns is platform specific and use of this should be kept to a minimum in\n        /// cross platform projects.\n        ///\n        /// This is thread-safe.\n        ///\n        /// @author S Downie\n        ///\n        /// @param in_storageLocation - The source storage location.\n        ///\n        /// @return The directory. returns an empty string if the location is not\n        /// available.\n        //------------------------------------------------------------------------------\n        virtual std::string GetAbsolutePathToStorageLocation(StorageLocation in_storageLocation) const = 0;\n        //------------------------------------------------------------------------------\n        /// Sets the directory used by the DLC system to fall back on if it is not in\n        /// the DLC cache directory.\n        ///\n        /// This is thread safe.\n        ///\n        /// @author S Downie\n        ///\n        /// @param in_directoryPath - The package DLC directory.\n        //------------------------------------------------------------------------------\n        void SetPackageDLCPath(const std::string& in_directoryPath);\n        //------------------------------------------------------------------------------\n        /// This is thread-safe.\n        ///\n        /// @author S Downie\n        ///\n        /// @return The package DLC directory.\n        //------------------------------------------------------------------------------\n        const std::string& GetPackageDLCPath() const;\n        //------------------------------------------------------------------------------\n        /// Calculate the SHA1 checksum of the file at the given directory\n        ///\n        /// This is thread-safe.\n        ///\n        /// @author N Tanda\n        ///\n        /// @param in_storageLocation - Storage location\n        /// @param in_filePath - File path\n        /// @param in_reportType - SHA1 type\n        ///\n        /// @return SHA1 checksum\n        //------------------------------------------------------------------------------\n        std::string GetFileChecksumSHA1(StorageLocation in_storageLocation, const std::string& in_filePath, const CSHA1::REPORT_TYPE in_reportType = CSHA1::REPORT_HEX_SHORT) const;\n        //------------------------------------------------------------------------------\n        /// Calculate the SHA256 checksum of the file at the given directory\n        ///\n        /// This is thread-safe.\n        ///\n        /// @author J Brown\n        ///\n        /// @param in_storageLocation - Storage location\n        /// @param in_filePath - File path\n        ///\n        /// @return SHA256 checksum\n        //------------------------------------------------------------------------------\n        std::string GetFileChecksumSHA256(StorageLocation in_storageLocation, const std::string& in_filePath) const;\n        //------------------------------------------------------------------------------\n        /// Calculate the MD5 checksum of the file at the given directory\n        ///\n        /// This is thread-safe.\n        ///\n        /// @author S Downie\n        ///\n        /// @param in_storageLocation - Storage location\n        /// @param in_filePath - File path\n        ///\n        /// @return MD5 checksum\n        //------------------------------------------------------------------------------\n        std::string GetFileChecksumMD5(StorageLocation in_storageLocation, const std::string& in_filePath) const;\n        //------------------------------------------------------------------------------\n        /// Calculate the MD5 checksum of the given directory\n        ///\n        /// This is thread-safe.\n        ///\n        /// @author S Downie\n        ///\n        /// @param in_storageLocation - Storage location\n        /// @param in_directoryPath - File path\n        ///\n        /// @return MD5 checksum\n        //------------------------------------------------------------------------------\n        std::string GetDirectoryChecksumMD5(StorageLocation in_storageLocation, const std::string& in_directoryPath) const;\n        //------------------------------------------------------------------------------\n        /// Gets the CRC32 Checksum for the given file.\n        ///\n        /// This is thread-safe.\n        ///\n        /// @author S Downie\n        ///\n        /// @param in_storageLocation - The storage location.\n        /// @param in_filePath - The filepath.\n        ///\n        /// @return the checksum.\n        //------------------------------------------------------------------------------\n        u32 GetFileChecksumCRC32(StorageLocation in_storageLocation, const std::string& in_filePath) const;\n        //------------------------------------------------------------------------------\n        /// Gets the CRC32 Checksum for the given directory.\n        ///\n        /// This is thread-safe.\n        ///\n        /// @param in_storageLocation - The storage location.\n        /// @param in_directoryPath - the filepath.\n        ///\n        /// @return the checksum.\n        //------------------------------------------------------------------------------\n        u32 GetDirectoryChecksumCRC32(StorageLocation in_storageLocation, const std::string& in_directoryPath) const;\n        //------------------------------------------------------------------------------\n        /// This is thread-safe.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param in_storageLocation - The storage location.\n        /// @param in_filePath - the file path.\n        ///\n        /// @return The size in bytes of the given file.\n        //------------------------------------------------------------------------------\n        u64 GetFileSize(StorageLocation in_storageLocation, const std::string& in_filePath) const;\n        //------------------------------------------------------------------------------\n        /// This is thread-safe.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param in_storageLocation - The storage location.\n        /// @param in_directoryPath - the Directory path.\n        ///\n        /// @return The size in bytes of the contents of the given directory.\n        //------------------------------------------------------------------------------\n        u64 GetDirectorySize(StorageLocation in_storageLocation, const std::string& in_directoryPath) const;\n        //------------------------------------------------------------------------------\n        /// Returns whether or not the given storage location can be written to.\n        ///\n        /// This is thread-safe.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param in_storageLocation - The storage location.\n        ///\n        /// @return Whether or not it can be written to.\n        //------------------------------------------------------------------------------\n        bool IsStorageLocationWritable(StorageLocation in_storageLocation) const;\n        //------------------------------------------------------------------------------\n        /// Destructor\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------------------------------------\n        virtual ~FileSystem() {}\n\n    protected:\n        friend class Application;\n        //------------------------------------------------------------------------------\n        /// Create the platform dependent backend\n        ///\n        /// @author S Downie\n        ///\n        /// @return New backend instance\n        //------------------------------------------------------------------------------\n        static FileSystemUPtr Create();\n        //------------------------------------------------------------------------------\n        /// Private constructor to force use of factory method\n        ///\n        /// @author S Downie\n        //------------------------------------------------------------------------------\n        FileSystem();\n\n    private:\n        std::string m_packageDLCPath;\n        mutable std::mutex m_packageDLCPathMutex;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/File/StorageLocation.h",
    "content": "//\n//  StorageLocation.h\n//  ChilliSource\n//  Created by Ian Copland on 31/03/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_FILE_STORAGELOCATION_H_\n#define _CHILLISOURCE_CORE_FILE_STORAGELOCATION_H_\n\nnamespace ChilliSource\n{\n    //-----------------------------------------------------------------\n    /// An enum describing the different possible locations for\n    /// files to be located.\n    ///\n    /// @author Ian Copland\n    //-----------------------------------------------------------------\n    enum class StorageLocation\n    {\n        k_none,\n        k_root,\n        k_package,\n        k_saveData,\n        k_cache,\n        k_DLC,\n        k_chilliSource\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/File/TaggedFilePathResolver.cpp",
    "content": "//\n//  TaggedFilePathResolver.cpp\n//  ChilliSource\n//  Created by Scott Downie on 19/06/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Core/File/TaggedFilePathResolver.h>\n\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/Base/Device.h>\n#include <ChilliSource/Core/Base/Screen.h>\n#include <ChilliSource/Core/File/FileSystem.h>\n#include <ChilliSource/Core/String/StringParser.h>\n\n#include <algorithm>\n\nnamespace ChilliSource\n{\n    namespace\n    {\n        //--------------------------------------------------------------\n        /// Filter the list of file paths based on those that contain\n        /// the names that start with the given text\n        ///\n        /// @author S Downie\n        ///\n        /// @param List to filter\n        /// @param text\n        ///\n        /// @return Filtered list\n        //--------------------------------------------------------------\n        std::vector<std::string> FilterFileNameStartsWith(const std::vector<std::string>& in_list, const std::string& in_text)\n        {\n            std::vector<std::string> result;\n            result.reserve(in_list.size());\n            \n            for(const auto& string : in_list)\n            {\n                auto findIndex = string.find(in_text);\n                if(findIndex == 0 || (findIndex != std::string::npos && string[findIndex-1] == '/'))\n                {\n                    result.push_back(string);\n                }\n            }\n            \n            return result;\n        }\n        //--------------------------------------------------------------\n        /// Filter the list of strings based on those that contain\n        /// the given tag or do not conflict with the other tags in the group\n        ///\n        /// @author S Downie\n        ///\n        /// @param List to filter\n        /// @param Tag to find\n        /// @param Other tags in the same group\n        ///\n        /// @return Filtered list\n        //--------------------------------------------------------------\n        std::vector<std::string> FilterContainsExclusive(const std::vector<std::string>& in_list, const std::string& in_tag, const std::vector<std::string>& in_groupTags)\n        {\n            std::vector<std::string> result;\n            result.reserve(in_list.size());\n            \n            for(const auto& string : in_list)\n            {\n                if(string.find(in_tag) != std::string::npos)\n                {\n                    result.push_back(string);\n                }\n                else\n                {\n                    bool ignoreString = false;\n                    \n                    for(const auto& otherTag : in_groupTags)\n                    {\n                        if(string.find(otherTag) != std::string::npos)\n                        {\n                            ignoreString = true;\n                            break;\n                        }\n                    }\n                    \n                    if(ignoreString == false)\n                    {\n                        result.push_back(string);\n                    }\n                }\n            }\n            \n            return result;\n        }\n        //--------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Case insensitive string representing tag group\n        ///\n        /// @return Tag group enum\n        //--------------------------------------------------------------\n        TaggedFilePathResolver::TagGroup ParseGroup(const std::string& in_group)\n        {\n            std::string lowercaseGroup = in_group;\n            StringUtils::ToLowerCase(lowercaseGroup);\n            \n            if(lowercaseGroup == \"language\")\n            {\n                return TaggedFilePathResolver::TagGroup::k_language;\n            }\n            \n            if(lowercaseGroup == \"platform\")\n            {\n                return TaggedFilePathResolver::TagGroup::k_platform;\n            }\n            \n            if(lowercaseGroup == \"resolution\")\n            {\n                return TaggedFilePathResolver::TagGroup::k_resolution;\n            }\n            \n            if(lowercaseGroup == \"aspectratio\")\n            {\n                return TaggedFilePathResolver::TagGroup::k_aspectRatio;\n            }\n            \n            CS_LOG_FATAL(\"TaggedFilePathResolver: No such group: \" + in_group);\n            return TaggedFilePathResolver::TagGroup::k_platform;\n        }\n    }\n    \n    CS_DEFINE_NAMEDTYPE(TaggedFilePathResolver);\n    \n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    TaggedFilePathResolverUPtr TaggedFilePathResolver::Create()\n    {\n        return TaggedFilePathResolverUPtr(new TaggedFilePathResolver());\n    }\n    //--------------------------------------------------------------\n    //--------------------------------------------------------------\n    bool TaggedFilePathResolver::IsA(InterfaceIDType in_interfaceId) const\n    {\n        return in_interfaceId == InterfaceID;\n    }\n    //--------------------------------------------------------------\n    //--------------------------------------------------------------\n    void TaggedFilePathResolver::OnInit()\n    {\n        m_fileSystem = Application::Get()->GetFileSystem();\n        CS_ASSERT(m_fileSystem != nullptr, \"TaggedFilePathResolver must have access to FileSystem\");\n        m_screen = Application::Get()->GetSystem<Screen>();\n        CS_ASSERT(m_screen != nullptr, \"TaggedFilePathResolver must have access to Screen system\");\n\n        //Initialise the priority to the default\n        for(u32 i=0; i<(u32)TagGroup::k_total; ++i)\n        {\n            m_priorityIndices[i] = i;\n        }\n        \n        DetermineScreenDependentTags(m_screen->GetResolution());\n    }\n    //--------------------------------------------------------------\n    //--------------------------------------------------------------\n    void TaggedFilePathResolver::SetFromJson(const Json::Value& in_json)\n    {\n        std::vector<std::string> supportedLanguages;\n        const Json::Value& languages = in_json[\"Languages\"];\n        if(languages.isNull() == false)\n        {\n            for(u32 i=0; i<languages.size(); ++i)\n            {\n                supportedLanguages.push_back(languages[i].asString());\n            }\n        }\n        \n        std::vector<RangeRule> supportedResolutions;\n        const Json::Value& resolutions = in_json[\"Resolutions\"];\n        if(resolutions.isNull() == false)\n        {\n            for(auto it = resolutions.begin(); it != resolutions.end(); ++it)\n            {\n                Vector2 res = ParseVector2((*it).asString());\n                RangeRule rule(it.memberName(), res.x * res.y);\n                supportedResolutions.push_back(rule);\n            }\n        }\n        \n        std::vector<RangeRule> supportedAspectRatios;\n        const Json::Value& aspects = in_json[\"AspectRatios\"];\n        if(aspects.isNull() == false)\n        {\n            for(auto it = aspects.begin(); it != aspects.end(); ++it)\n            {\n                RangeRule rule(it.memberName(), (f32)(*it).asDouble());\n                supportedAspectRatios.push_back(rule);\n            }\n        }\n        \n        SetTags(supportedLanguages, supportedResolutions, supportedAspectRatios);\n        \n        TagGroup priorityIndices[(u32)TagGroup::k_total];\n        const Json::Value& priorities = in_json[\"Priorities\"];\n        if(priorities.isNull() == false)\n        {\n            CS_ASSERT(priorities.size() == (u32)TagGroup::k_total, \"TaggedFilePathResolver: Need to specify all groups when setting priorities\");\n            for(u32 i=0; i<priorities.size(); ++i)\n            {\n                priorityIndices[i] = ParseGroup(priorities[i].asString());\n            }\n            \n            SetPriority(priorityIndices[0], priorityIndices[1], priorityIndices[2], priorityIndices[3]);\n        }\n    }\n    //--------------------------------------------------------------\n    //--------------------------------------------------------------\n    void TaggedFilePathResolver::SetTags(const std::vector<std::string>& in_supportedLanguages,\n                                     const std::vector<RangeRule>& in_supportedResolutions,\n                                     const std::vector<RangeRule>& in_supportedAspectRatios)\n    {\n        //---Languages\n        auto device = Application::Get()->GetSystem<Device>();\n        CS_ASSERT(device != nullptr, \"TaggedFilePathResolver must have access to Device system\");\n        for(const auto& language : in_supportedLanguages)\n        {\n            m_groupTags[(u32)TagGroup::k_language].push_back(\".\" + language);\n        }\n        m_activeTags[(u32)TagGroup::k_language] = \".\" + device->GetLanguage();\n        \n        //---Platforms\n        m_groupTags[(u32)TagGroup::k_platform] = {\".ios\", \".android\", \".windows\"};\n#if defined CS_TARGETPLATFORM_IOS\n        m_activeTags[(u32)TagGroup::k_platform] = \".ios\";\n#elif defined CS_TARGETPLATFORM_ANDROID\n        m_activeTags[(u32)TagGroup::k_platform] = \".android\";\n#elif defined CS_TARGETPLATFORM_WINDOWS\n        m_activeTags[(u32)TagGroup::k_platform] = \".windows\";\n#elif defined CS_TARGETPLATFORM_RPI\n        m_activeTags[(u32)TagGroup::k_platform] = \".rpi\";\n#endif\n        \n        //---Resolution\n        m_resolutionRules = in_supportedResolutions;\n        std::sort(std::begin(m_resolutionRules), std::end(m_resolutionRules), [](const RangeRule& in_a, const RangeRule& in_b)\n        {\n            return in_a.m_minExclusive > in_b.m_minExclusive;\n        });\n        \n        for(const auto& rule : in_supportedResolutions)\n        {\n            m_groupTags[(u32)TagGroup::k_resolution].push_back(\".\" + rule.m_name);\n        }\n        \n        //---Aspect Ratio\n        m_aspectRatioRules = in_supportedAspectRatios;\n        std::sort(std::begin(m_aspectRatioRules), std::end(m_aspectRatioRules), [](const RangeRule& in_a, const RangeRule& in_b)\n        {\n            return in_a.m_minExclusive > in_b.m_minExclusive;\n        });\n        \n        for(const auto& rule : in_supportedAspectRatios)\n        {\n            m_groupTags[(u32)TagGroup::k_aspectRatio].push_back(\".\" + rule.m_name);\n        }\n        \n        if(m_screen != nullptr)\n        {\n            DetermineScreenDependentTags(m_screen->GetResolution());\n        }\n    }\n    //--------------------------------------------------------------\n    //--------------------------------------------------------------\n    void TaggedFilePathResolver::SetPriority(TagGroup in_high, TagGroup in_2, TagGroup in_3, TagGroup in_low)\n    {\n        m_priorityIndices[0] = (u32)in_high;\n        m_priorityIndices[1] = (u32)in_2;\n        m_priorityIndices[2] = (u32)in_3;\n        m_priorityIndices[3] = (u32)in_low;\n        \n#ifdef DEBUG\n        u32 priorityIndicesSorted[(u32)TagGroup::k_total];\n        std::copy(m_priorityIndices, m_priorityIndices + (u32)TagGroup::k_total, priorityIndicesSorted);\n        std::sort(priorityIndicesSorted, priorityIndicesSorted + (u32)TagGroup::k_total);\n        \n        u32 limit = (u32)(TagGroup::k_total) - 1;\n        for(u32 i=0; i<limit; ++i)\n        {\n            if(priorityIndicesSorted[i] == priorityIndicesSorted[i+1])\n            {\n                CS_LOG_FATAL(\"TaggedFilePathResolver::SetPriority: Has a priority conflict. Check for duplicate priorities\");\n            }\n        }\n#endif\n    }\n    //--------------------------------------------------------------\n    //--------------------------------------------------------------\n    void TaggedFilePathResolver::DetermineScreenDependentTags(const Vector2& in_size)\n    {\n        //---Resolution\n        f32 resolution = in_size.x * in_size.y;\n        for(const auto& rule : m_resolutionRules)\n        {\n            if(resolution > rule.m_minExclusive)\n            {\n                m_activeTags[(u32)TagGroup::k_resolution] = \".\" + rule.m_name;\n                break;\n            }\n        }\n        \n        //---Aspect Ratio\n        f32 aspectRatio = in_size.x / in_size.y;\n        for(const auto& rule : m_aspectRatioRules)\n        {\n            if(aspectRatio > rule.m_minExclusive)\n            {\n                m_activeTags[(u32)TagGroup::k_aspectRatio] = \".\" + rule.m_name;\n                break;\n            }\n        }\n    }\n    //--------------------------------------------------------------\n    //--------------------------------------------------------------\n    std::string TaggedFilePathResolver::ResolveFilePath(StorageLocation in_location, const std::string& in_basePath) const\n    {\n        std::string filePath, fileName, fileExtension;\n        StringUtils::SplitFullFilename(in_basePath, fileName, fileExtension, filePath);\n        \n        //Look for all files in the given folder with the given name and extension\n        std::vector<std::string> pathsContaining = m_fileSystem->GetFilePathsWithExtension(in_location, filePath, false, fileExtension);\n        \n        //Filter on the filename\n        pathsContaining = FilterFileNameStartsWith(pathsContaining, fileName + \".\");\n        \n        if(pathsContaining.empty() == true)\n        {\n            return in_basePath;\n        }\n\n        //Filter the paths based on the priority tag - if it doesn't contain the tag check to make sure it doesn't have an excluding tag in this group\n        //Filter those filtered paths based on the next priority tag\n        //Keep going until we have a single path or we have exhausted all tags\n        for(u32 tagIndex=0; tagIndex<(u32)TagGroup::k_total; ++tagIndex)\n        {\n            pathsContaining = FilterContainsExclusive(pathsContaining, m_activeTags[m_priorityIndices[tagIndex]], m_groupTags[m_priorityIndices[tagIndex]]);\n        }\n        \n        //We have exhausted all the tags and now have a list of all the paths applicable to this\n        //device. Pick the most applicable path by finding the one that matches the highest priority tag.\n        std::vector<std::string> finalPaths = pathsContaining;\n        for(u32 tagIndex=0; tagIndex<(u32)TagGroup::k_total; ++tagIndex)\n        {\n            pathsContaining.clear();\n            for(const auto& path : finalPaths)\n            {\n                if(path.find(m_activeTags[m_priorityIndices[tagIndex]]) != std::string::npos)\n                {\n                    pathsContaining.push_back(path);\n                }\n            }\n            \n            if(pathsContaining.empty() == false)\n            {\n                finalPaths = pathsContaining;\n            }\n        }\n\n        return finalPaths.empty() == false ? filePath + finalPaths[0] : in_basePath;\n    }\n    //--------------------------------------------------------------\n    //--------------------------------------------------------------\n    std::string TaggedFilePathResolver::GetActiveTag(TagGroup in_tagGroup) const\n    {\n        std::string output = m_activeTags[static_cast<u32>(in_tagGroup)];\n        \n        if (output.empty() == false)\n        {\n            if (output[0] == '.')\n            {\n                output = output.substr(1);\n            }\n        }\n        \n        return output;\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Core/File/TaggedFilePathResolver.h",
    "content": "//\n//  TaggedFilePathResolver.h\n//  ChilliSource\n//  Created by Scott Downie on 19/06/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_FILE_TAGGEDFILEPATHRESOLVER_H_\n#define _CHILLISOURCE_CORE_FILE_TAGGEDFILEPATHRESOLVER_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/System/AppSystem.h>\n\n#include <json/json.h>\n\nnamespace ChilliSource\n{\n    //-----------------------------------------------------------------\n    /// A system that resolves file paths based on the device configuration.\n    ///\n    /// Devices have the following configs:\n    ///     * Language\n    ///     * Platform\n    ///     * Resolution\n    ///     * Aspect ratio\n    ///\n    /// Each config has associated tags and rules that can be applied\n    /// to filenames. This system will return the path that best\n    /// suits the current device based on the given base file path and\n    /// the assets that are currently on device.\n    ///\n    /// Example:\n    ///\n    /// MyImage.png\n    /// MyImage.en.png\n    /// MyImage.high.wide.en.png\n    /// MyImage.med.low.png\n    ///\n    /// NOTE: Only the rules and tags for resolution and ratio are\n    /// configurable as the platform and language are fixed.\n    ///\n    /// @author S Downie\n    //-----------------------------------------------------------------\n    class TaggedFilePathResolver : public AppSystem\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(TaggedFilePathResolver);\n        \n        //--------------------------------------------------------------\n        /// The list of supported groups by which assets can be loaded\n        ///\n        /// @author S Downie\n        //--------------------------------------------------------------\n        enum class TagGroup\n        {\n            k_platform,\n            k_resolution,\n            k_aspectRatio,\n            k_language,\n            k_total\n        };\n        //--------------------------------------------------------------\n        /// Holds the information for a range rule. A range rule\n        /// holds true for any value greater than the minimum\n        ///\n        /// @author S Downie\n        //--------------------------------------------------------------\n        struct RangeRule\n        {\n            //--------------------------------------------------------------\n            /// Constructor\n            ///\n            /// @author S Downie\n            ///\n            /// @param Tag name\n            /// @param Min exclusive\n            //--------------------------------------------------------------\n            RangeRule(const std::string& in_name, f32 in_minExclusive)\n            : m_name(in_name), m_minExclusive(in_minExclusive)\n            {\n                \n            }\n            std::string m_name;\n            f32 m_minExclusive = 0;\n        };\n        //--------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Interface Id\n        ///\n        /// @return Whether this object is of the given type\n        //--------------------------------------------------------------\n        bool IsA(InterfaceIDType in_interfaceId) const override;\n        //--------------------------------------------------------------\n        /// Add the tags and the rules for when to apply them\n        /// based on the current device resolution, platform, language\n        /// and aspect ratio. Set the priority.\n        ///\n        /// @author S Downie\n        ///\n        /// @param Json object\n        //--------------------------------------------------------------\n        void SetFromJson(const Json::Value& in_json);\n        //--------------------------------------------------------------\n        /// Add the tags and the rules for when to apply them\n        /// based on the current device resolution, platform, language\n        /// and aspect ratio.\n        ///\n        /// @author S Downie\n        ///\n        /// @param List of supported language codes i.e. {\"en\", \"fr\", \"de\"}\n        /// @param List of supported resolutions i.e. {\"low\", 0*0, 480*320}, {\"medium\", 480*320, 960*640}\n        /// @param List of supported aspect ratios i.e. {\"std\", 1/1, 3/2}, {\"wide\", 16/9, 25/9}\n        //--------------------------------------------------------------\n        void SetTags(const std::vector<std::string>& in_supportedLanguages,\n                     const std::vector<RangeRule>& in_supportedResolutions,\n                     const std::vector<RangeRule>& in_supportedAspectRatios);\n        //--------------------------------------------------------------\n        /// Set the priority in which the tag groups are applied. This\n        /// is used to manage conflicts between shared assets.\n        ///\n        /// Example:\n        ///     MyImage.wide.png\n        ///     MyImage.high.png\n        ///\n        /// The priority governs which is loaded on a wide and high device.\n        ///\n        /// Default is: Platform, Res, Ratio, Language\n        ///\n        /// @author S Downie\n        ///\n        /// @param Highest priority\n        /// @param 2nd highest\n        /// @param 3rd highest\n        /// @param Lowest\n        //--------------------------------------------------------------\n        void SetPriority(TagGroup in_high, TagGroup in_2, TagGroup in_3, TagGroup in_low);\n        //--------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Storage location\n        /// @param Base file path (i.e. Textures/MyImage.png)\n        ///\n        /// @return The best-fit filename based on the assets in the\n        /// filesystem, the tags, the device and the priority (i.e. Textures/MyImage.high.png)\n        //--------------------------------------------------------------\n        std::string ResolveFilePath(StorageLocation in_location, const std::string& in_basePath) const;\n        //--------------------------------------------------------------\n        /// Returns the active tag for the given Tag Group.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The tag group for which to get the active tag.\n        ///\n        /// @return The active tag.\n        //--------------------------------------------------------------\n        std::string GetActiveTag(TagGroup in_tagGroup) const;\n    private:\n        \n        friend class Application;\n        //--------------------------------------------------------------\n        /// Factory create method\n        ///\n        /// @author S Downie\n        ///\n        /// @return New backend instance\n        //--------------------------------------------------------------\n        static TaggedFilePathResolverUPtr Create();\n        //--------------------------------------------------------------\n        /// Private constructor to force use of factory method\n        ///\n        /// @author S Downie\n        //--------------------------------------------------------------\n        TaggedFilePathResolver() = default;\n        //--------------------------------------------------------------\n        /// Called when the system is created\n        ///\n        /// @author S Downie\n        //--------------------------------------------------------------\n        void OnInit() override;\n        //--------------------------------------------------------------\n        /// Assigns the correct tags based on the screen size\n        ///\n        /// @author S Downie\n        ///\n        /// @param Screen size\n        //--------------------------------------------------------------\n        void DetermineScreenDependentTags(const Vector2& in_size);\n        \n    private:\n        \n        FileSystem* m_fileSystem = nullptr;\n        Screen* m_screen = nullptr;\n        \n        std::vector<RangeRule> m_resolutionRules;\n        std::vector<RangeRule> m_aspectRatioRules;\n        \n        std::vector<std::string> m_groupTags[(u32)TagGroup::k_total];\n        std::string m_activeTags[(u32)TagGroup::k_total];\n        \n        u32 m_priorityIndices[(u32)TagGroup::k_total];\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/File.h",
    "content": "//\n//  File.h\n//  ChilliSource\n//  Created by Ian Copland on 07/07/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_FILE_H_\n#define _CHILLISOURCE_CORE_FILE_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/File/AppDataStore.h>\n#include <ChilliSource/Core/File/CSBinaryChunk.h>\n#include <ChilliSource/Core/File/CSBinaryInputStream.h>\n#include <ChilliSource/Core/File/FileSystem.h>\n#include <ChilliSource/Core/File/StorageLocation.h>\n#include <ChilliSource/Core/File/TaggedFilePathResolver.h>\n#include <ChilliSource/Core/File/FileStream/BinaryInputStream.h>\n#include <ChilliSource/Core/File/FileStream/BinaryOutputStream.h>\n#include <ChilliSource/Core/File/FileStream/FileWriteMode.h>\n#include <ChilliSource/Core/File/FileStream/IBinaryInputStream.h>\n#include <ChilliSource/Core/File/FileStream/ITextInputStream.h>\n#include <ChilliSource/Core/File/FileStream/TextInputStream.h>\n#include <ChilliSource/Core/File/FileStream/TextOutputStream.h>\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/ForwardDeclarations.h",
    "content": "//\n//  ForwardDeclarations.h\n//  ChilliSource\n//  Created by Ian Copland on 27/02/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_FORWARDDECLARATIONS_H_\n#define _CHILLISOURCE_CORE_FORWARDDECLARATIONS_H_\n\n#include <ChilliSource/Core/Base/StandardMacros.h>\n\n#include <memory>\n\nnamespace ChilliSource\n{\n    //---------------------------------------------------------\n    /// Base\n    //---------------------------------------------------------\n    CS_FORWARDDECLARE_CLASS(Application);\n    CS_FORWARDDECLARE_CLASS(ByteBuffer);\n    CS_FORWARDDECLARE_CLASS(Colour);\n    CS_FORWARDDECLARE_CLASS(Device);\n    CS_FORWARDDECLARE_CLASS(DeviceInfo);\n    CS_FORWARDDECLARE_CLASS(LifecycleManager);\n    CS_FORWARDDECLARE_CLASS(Logging);\n    CS_FORWARDDECLARE_CLASS(PlatformSystem);\n    CS_FORWARDDECLARE_CLASS(QueryableInterface);\n    CS_FORWARDDECLARE_CLASS(Screen);\n    CS_FORWARDDECLARE_CLASS(ScreenInfo);\n    CS_FORWARDDECLARE_CLASS(SystemInfo);\n    CS_FORWARDDECLARE_CLASS(AppConfig);\n    enum class CursorType;\n    //---------------------------------------------------------\n    /// Container\n    //---------------------------------------------------------\n    CS_FORWARDDECLARE_CLASS(ParamDictionary);\n    CS_FORWARDDECLARE_CLASS(IProperty);\n    CS_FORWARDDECLARE_CLASS(IPropertyType);\n    CS_FORWARDDECLARE_CLASS(PropertyMap);\n    template <typename TKey, typename TValue> class HashedArray;\n    template <typename TType> class concurrent_blocking_queue;\n    template <typename TType> class concurrent_vector;\n    template <typename TType> class dynamic_array;\n    template <typename TType> class Property;\n    template <typename TType> class PropertyType;\n    template <typename TType> class random_access_iterator;\n    template <typename TType> class ReferenceProperty;\n    template <typename TType> class ValueProperty;\n    //---------------------------------------------------------\n    /// Delegate\n    //---------------------------------------------------------\n    template <typename TReturnType, typename... TArgTypes> class ConnectableDelegate;\n    template <typename TReturnType, typename... TArgTypes> class DelegateConnection;\n    //---------------------------------------------------------\n    /// Dialogue\n    //---------------------------------------------------------\n    CS_FORWARDDECLARE_CLASS(DialogueBoxSystem);\n    //---------------------------------------------------------\n    /// Entity\n    //---------------------------------------------------------\n    CS_FORWARDDECLARE_CLASS(Component);\n    CS_FORWARDDECLARE_CLASS(Entity);\n    CS_FORWARDDECLARE_CLASS(PrimitiveEntityFactory);\n    CS_FORWARDDECLARE_CLASS(Transform);\n    //---------------------------------------------------------\n    /// Event\n    //---------------------------------------------------------\n    template <typename TDelegateType> class Event;\n    template <typename TDelegateType> class IConnectableEvent;\n    CS_FORWARDDECLARE_CLASS(IDisconnectableEvent);\n    CS_FORWARDDECLARE_CLASS(EventConnection);\n    //---------------------------------------------------------\n    /// File\n    //---------------------------------------------------------\n    CS_FORWARDDECLARE_CLASS(IBinaryInputStream);\n    CS_FORWARDDECLARE_CLASS(BinaryInputStream);\n    CS_FORWARDDECLARE_CLASS(BinaryOutputStream);\n    CS_FORWARDDECLARE_CLASS(ITextInputStream);\n    CS_FORWARDDECLARE_CLASS(TextInputStream);\n    CS_FORWARDDECLARE_CLASS(TextOutputStream);\n    CS_FORWARDDECLARE_CLASS(FileSystem);\n    CS_FORWARDDECLARE_CLASS(AppDataStore);\n    CS_FORWARDDECLARE_CLASS(TaggedFilePathResolver);\n    CS_FORWARDDECLARE_CLASS(CSBinaryInputStream);\n    CS_FORWARDDECLARE_CLASS(CSBinaryChunk);\n    enum class StorageLocation;\n    enum class FileWriteMode;\n    //---------------------------------------------------------\n    /// Image\n    //---------------------------------------------------------\n    CS_FORWARDDECLARE_CLASS(CSImageProvider);\n    CS_FORWARDDECLARE_CLASS(ETC1ImageProvider);\n    CS_FORWARDDECLARE_CLASS(Image);\n    CS_FORWARDDECLARE_CLASS(PNGImageProvider);\n    CS_FORWARDDECLARE_CLASS(PVRImageProvider);\n    enum class ImageFormat;\n    enum class ImageCompression;\n    //---------------------------------------------------------\n    /// Localisation\n    //---------------------------------------------------------\n    CS_FORWARDDECLARE_CLASS(LocalisedText);\n    CS_FORWARDDECLARE_CLASS(LocalisedTextProvider);\n    //---------------------------------------------------------\n    /// Math\n    //---------------------------------------------------------\n    template <typename T> class CatmullRomSpline;\n    template <typename T> class MultiLineSegment;\n    CS_FORWARDDECLARE_CLASS(Rectangle);\n    CS_FORWARDDECLARE_CLASS(Circle);\n    CS_FORWARDDECLARE_CLASS(Sphere);\n    CS_FORWARDDECLARE_CLASS(AABB);\n    CS_FORWARDDECLARE_CLASS(OOBB);\n    CS_FORWARDDECLARE_CLASS(Ray);\n    CS_FORWARDDECLARE_CLASS(Line);\n    CS_FORWARDDECLARE_CLASS(Plane);\n    CS_FORWARDDECLARE_CLASS(Frustum);\n    CS_FORWARDDECLARE_STRUCT(UnifiedScalar);\n    CS_FORWARDDECLARE_STRUCT(UnifiedVector2);\n    CS_FORWARDDECLARE_STRUCT(UnifiedRectangle);\n    template <typename TType> class GenericVector2;\n    template <typename TType> class GenericVector3;\n    template <typename TType> class GenericVector4;\n    template <typename TType> class GenericQuaternion;\n    template <typename TType> class GenericMatrix3;\n    template <typename TType> class GenericMatrix4;\n    using Vector2 = GenericVector2<f32>;\n    using Float2 = GenericVector2<f32>;\n    using Double2 = GenericVector2<f64>;\n    using Integer2 = GenericVector2<s32>;\n    using Vector3 = GenericVector3<f32>;\n    using Float3 = GenericVector3<f32>;\n    using Double3 = GenericVector3<f64>;\n    using Integer3 = GenericVector3<s32>;\n    using Vector4 = GenericVector4<f32>;\n    using Float4 = GenericVector4<f32>;\n    using Double4 = GenericVector4<f64>;\n    using Integer4 = GenericVector4<s32>;\n    using Quaternion = GenericQuaternion<f32>;\n    using Matrix3 = GenericMatrix3<f32>;\n    using Matrix4 = GenericMatrix4<f32>;\n    //---------------------------------------------------------\n    /// Memory\n    //---------------------------------------------------------\n    CS_FORWARDDECLARE_CLASS(IAllocator);\n    CS_FORWARDDECLARE_CLASS(LinearAllocator);\n    CS_FORWARDDECLARE_CLASS(PagedLinearAllocator);\n    CS_FORWARDDECLARE_TEMPLATECLASS(ObjectPoolAllocator, T);\n    //---------------------------------------------------------\n    /// Notifications\n    //---------------------------------------------------------\n    CS_FORWARDDECLARE_STRUCT(Notification);\n    CS_FORWARDDECLARE_CLASS(NotificationManager);\n    CS_FORWARDDECLARE_CLASS(AppNotificationSystem);\n    CS_FORWARDDECLARE_CLASS(LocalNotificationSystem);\n    CS_FORWARDDECLARE_CLASS(RemoteNotificationSystem);\n    //---------------------------------------------------------\n    /// Reflection\n    //---------------------------------------------------------\n    namespace Reflect\n    {\n        CS_FORWARDDECLARE_CLASS(CInstance);\n        CS_FORWARDDECLARE_CLASS(CMetaClass);\n        CS_FORWARDDECLARE_CLASS(CProperty);\n        enum class PropAccess;\n    }\n    //---------------------------------------------------------\n    /// Resource\n    //---------------------------------------------------------\n    CS_FORWARDDECLARE_CLASS(Resource);\n    CS_FORWARDDECLARE_CLASS(ResourcePool);\n    CS_FORWARDDECLARE_CLASS(ResourceProvider);\n    CS_FORWARDDECLARE_TEMPLATECLASS(IResourceOptions, TResourceType);\n    CS_FORWARDDECLARE_CLASS(IResourceOptionsBase);\n    //---------------------------------------------------------\n    /// Scene\n    //---------------------------------------------------------\n    CS_FORWARDDECLARE_CLASS(Scene);\n    //---------------------------------------------------------\n    /// State\n    //---------------------------------------------------------\n    CS_FORWARDDECLARE_CLASS(State);\n    CS_FORWARDDECLARE_CLASS(StateManager);\n    //---------------------------------------------------------\n    /// String\n    //---------------------------------------------------------\n    CS_FORWARDDECLARE_CLASS(StringMarkupParser);\n    //---------------------------------------------------------\n    /// System\n    //---------------------------------------------------------\n    CS_FORWARDDECLARE_CLASS(AppSystem);\n    CS_FORWARDDECLARE_CLASS(StateSystem);\n    CS_FORWARDDECLARE_CLASS(IComponentProducer);\n    //---------------------------------------------------------\n    /// Threading\n    //---------------------------------------------------------\n    CS_FORWARDDECLARE_CLASS(SingleThreadTaskPool);\n    CS_FORWARDDECLARE_CLASS(TaskContext);\n    CS_FORWARDDECLARE_CLASS(TaskPool);\n    CS_FORWARDDECLARE_CLASS(TaskScheduler);\n    CS_FORWARDDECLARE_CLASS(TaskScheduler);\n    CS_FORWARDDECLARE_CLASS(ThreadPool);\n    enum class TaskType;\n    //---------------------------------------------------------\n    /// Time\n    //---------------------------------------------------------\n    CS_FORWARDDECLARE_CLASS(CoreTimer);\n    CS_FORWARDDECLARE_CLASS(PerformanceTimer);\n    CS_FORWARDDECLARE_CLASS(Timer);\n    //---------------------------------------------------------\n    /// Tween\n    //---------------------------------------------------------\n    template <typename TInterpType> class Tween;\n    //---------------------------------------------------------\n    /// Volume\n    //---------------------------------------------------------\n    CS_FORWARDDECLARE_CLASS(VolumeComponent);\n    //---------------------------------------------------------\n    /// XML\n    //---------------------------------------------------------\n    CS_FORWARDDECLARE_CLASS(XML);\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Image/CSImageProvider.cpp",
    "content": "//\n//  CSImageProvider.cpp\n//  ChilliSource\n//  Created by Scott Downie on 10/08/2012.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2012 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Core/Image/CSImageProvider.h>\n\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/Cryptographic/HashCRC32.h>\n#include <ChilliSource/Core/Image/Image.h>\n#include <ChilliSource/Core/Image/ImageCompression.h>\n#include <ChilliSource/Core/Image/ImageFormat.h>\n#include <ChilliSource/Core/Threading/TaskScheduler.h>\n\n#include <minizip/unzip.h>\n\nnamespace ChilliSource\n{\n    namespace\n    {\n        const std::string k_csImageExtension(\"csimage\");\n        \n        //------------------------------------------------------\n        /// A container for the imformation provided in the\n        /// csimage header version 2.\n        ///\n        /// @author S Downie\n        //------------------------------------------------------\n        struct ImageHeaderVersion2\n        {\n            u32 m_width;\n            u32 m_height;\n            u32 m_imageFormat;\n            u32 m_compression;\n            u32 m_dataSize;\n        };\n        //------------------------------------------------------\n        /// A container for the imformation provided in the\n        /// csimage header version 3.\n        ///\n        /// @author S Downie\n        //------------------------------------------------------\n        struct ImageHeaderVersion3\n        {\n            u32 m_width;\n            u32 m_height;\n            u32 m_imageFormat;\n            u32 m_compression;\n            u64 m_checksum;\n            u32 m_originalDataSize;\n            u32 m_compressedDataSize;\n        };\n        //-------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param The integer image format\n        /// @param The image width\n        /// @param The image height\n        /// @param [Out] The image format\n        /// @param [Out] The image size\n        ///\n        /// @return Whether the format was found\n        //-------------------------------------------------------\n        bool GetFormatInfo(const u32 in_format, const u32 in_width, const u32 in_height, ImageFormat& out_format, u32& out_imageSize)\n        {\n            switch(in_format)\n            {\n                case 1:\n                    out_format = ImageFormat::k_Lum8;\n                    out_imageSize = in_width * in_height * 1;\n                    return true;\n                case 2:\n                    out_format = ImageFormat::k_LumA88;\n                    out_imageSize = in_width * in_height * 2;\n                    return true;\n                case 3:\n                    out_format = ImageFormat::k_RGB565;\n                    out_imageSize = in_width * in_height * 2;\n                    return true;\n                case 4:\n                    out_format = ImageFormat::k_RGBA4444;\n                    out_imageSize = in_width * in_height * 2;\n                    return true;\n                case 5:\n                    out_format = ImageFormat::k_RGB888;\n                    out_imageSize = in_width * in_height * 3;\n                    return true;\n                case 6:\n                    out_format = ImageFormat::k_RGBA8888;\n                    out_imageSize = in_width * in_height * 4;\n                    return true;\n                default:\n                case 0:\n                    break;\n            }\n            return false;\n        }\n        //-------------------------------------------------------\n        /// Reads a version 3 formatted .csimage file\n        ///\n        /// @author S Downie\n        ///\n        /// @param Pointer to image data file\n        /// @param Pointer to resource destination\n        //-------------------------------------------------------\n        void ReadFileVersion3(const IBinaryInputStreamUPtr& in_stream, const ResourceSPtr& out_resource)\n        {\n            //Read the header\n            ImageHeaderVersion3 sHeader;\n            in_stream->Read((u8*)&sHeader.m_width, sizeof(u32));\n            in_stream->Read((u8*)&sHeader.m_height, sizeof(u32));\n            in_stream->Read((u8*)&sHeader.m_imageFormat, sizeof(u32));\n            in_stream->Read((u8*)&sHeader.m_compression, sizeof(u32));\n            in_stream->Read((u8*)&sHeader.m_checksum, sizeof(u64));\n            in_stream->Read((u8*)&sHeader.m_originalDataSize, sizeof(u32));\n            in_stream->Read((u8*)&sHeader.m_compressedDataSize, sizeof(u32));\n            \n            u32 udwSize = 0;\n            ImageFormat eFormat = ImageFormat::k_RGBA8888;\n            bool bFoundFormat = GetFormatInfo(sHeader.m_imageFormat, sHeader.m_width, sHeader.m_height, eFormat, udwSize);\n            CS_RELEASE_ASSERT(bFoundFormat, \"Invalid CSImage Format.\");\n            \n            u8* pubyBitmapData = nullptr;\n            if(sHeader.m_compression != 0)\n            {\n                // Allocated memory needed for the compressed image data\n                u8* pubyCompressedData = (u8*)malloc(sHeader.m_compressedDataSize);\n                in_stream->Read(pubyCompressedData, sHeader.m_compressedDataSize);\n                \n                // Allocated memory need for for the bitmap context\n                pubyBitmapData = new u8[sHeader.m_originalDataSize];\n                \n                // Inflate data (I like to think this is the machine equvilent to eating lots of pizza!)\n                z_stream infstream;\n                infstream.zalloc = Z_NULL;\n                infstream.zfree = Z_NULL;\n                infstream.opaque = Z_NULL;\n                infstream.avail_in = sHeader.m_compressedDataSize;\t\t// size of input\n                infstream.next_in = (Bytef*)pubyCompressedData;\t\t\t// input data\n                infstream.avail_out = sHeader.m_originalDataSize;\t\t// size of output\n                infstream.next_out = (Bytef*)pubyBitmapData;\t\t\t// output char array\n                \n                inflateInit(&infstream);\n                inflate(&infstream, Z_FINISH);\n                inflateEnd(&infstream);\n                \n                // Checksum test\n                u32 udwInflatedChecksum = HashCRC32::GenerateHashCode((const s8*)pubyBitmapData, sHeader.m_originalDataSize);\n                if(sHeader.m_checksum != (u64)udwInflatedChecksum)\n                {\n                    CS_LOG_ERROR(\"CSImage checksum of \"+ToString(udwInflatedChecksum)+\" does not match expected checksum \"+ToString(sHeader.m_checksum));\n                }\n                \n                free(pubyCompressedData);\n            }\n            else\n            {\n                // Allocated memory needed for the bitmap context\n                pubyBitmapData = new u8[sHeader.m_originalDataSize];;\n                in_stream->Read(pubyBitmapData, udwSize);\n            }\n            \n            Image::ImageDataUPtr imageData(pubyBitmapData);\n            \n            Image::Descriptor desc;\n            desc.m_format = eFormat;\n            desc.m_compression = ImageCompression::k_none;\n            desc.m_width = sHeader.m_width;\n            desc.m_height = sHeader.m_height;\n            desc.m_dataSize = udwSize;\n            \n            Image* outpImage = (Image*)out_resource.get();\n            outpImage->Build(desc, std::move(imageData));\n        }\n        //----------------------------------------------------\n        /// Performs the heavy lifting for the 2 create methods\n        ///\n        /// @author S Downie\n        ///\n        /// @param The storage location.\n        /// @param The filepath.\n        /// @param Completion delegate\n        /// @param [Out] The output resource.\n        //----------------------------------------------------\n        void LoadImage(StorageLocation in_storageLocation, const std::string& in_filepath, const ResourceProvider::AsyncLoadDelegate& in_delegate, const ResourceSPtr& out_resource)\n        {\n            auto pImageFile = Application::Get()->GetFileSystem()->CreateBinaryInputStream(in_storageLocation, in_filepath);\n            \n            if(pImageFile == nullptr)\n            {\n                out_resource->SetLoadState(Resource::LoadState::k_failed);\n                if(in_delegate != nullptr)\n                {\n                    Application::Get()->GetTaskScheduler()->ScheduleTask(TaskType::k_mainThread, [=](const TaskContext&) noexcept\n                    {\n                        in_delegate(out_resource);\n                    });\n                }\n                return;\n            }\n            \n            //Read the byte order mark and ensure it is 123456\n            u32 udwByteOrder = 0;\n            pImageFile->Read((u8*)&udwByteOrder, sizeof(u32));\n            CS_ASSERT(udwByteOrder == 123456, \"Endianess not supported\");\n            \n            //Read the version\n            u32 udwVersion = 0;\n            pImageFile->Read((u8*)&udwVersion, sizeof(u32));\n            CS_ASSERT(udwVersion >= 3, \"Only version 3 and above supported\");\n\n            ReadFileVersion3(pImageFile, out_resource);\n\n            pImageFile.reset();\n            \n            out_resource->SetLoadState(Resource::LoadState::k_loaded);\n            if(in_delegate != nullptr)\n            {\n                Application::Get()->GetTaskScheduler()->ScheduleTask(TaskType::k_mainThread, [=](const TaskContext&) noexcept\n                {\n                    in_delegate(out_resource);\n                });\n            }\n        }\n    }\n    \n    CS_DEFINE_NAMEDTYPE(CSImageProvider);\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    CSImageProviderUPtr CSImageProvider::Create()\n    {\n        return CSImageProviderUPtr(new CSImageProvider());\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    bool CSImageProvider::IsA(InterfaceIDType in_interfaceId) const\n    {\n        return (in_interfaceId == ResourceProvider::InterfaceID || in_interfaceId == CSImageProvider::InterfaceID);\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    InterfaceIDType CSImageProvider::GetResourceType() const\n    {\n        return Image::InterfaceID;\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    bool CSImageProvider::CanCreateResourceWithFileExtension(const std::string& in_extension) const\n    {\n        return (in_extension == k_csImageExtension);\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    void CSImageProvider::CreateResourceFromFile(StorageLocation in_storageLocation, const std::string& in_filepath, const IResourceOptionsBaseCSPtr& in_options, const ResourceSPtr& out_resource)\n    {\n        LoadImage(in_storageLocation, in_filepath, nullptr, out_resource);\n    }\n    //----------------------------------------------------\n    //----------------------------------------------------\n    void CSImageProvider::CreateResourceFromFileAsync(StorageLocation in_storageLocation, const std::string& in_filepath, const IResourceOptionsBaseCSPtr& in_options, const ResourceProvider::AsyncLoadDelegate& in_delegate, const ResourceSPtr& out_resource)\n    {\n        Application::Get()->GetTaskScheduler()->ScheduleTask(TaskType::k_file, [=](const TaskContext&) noexcept\n        {\n            LoadImage(in_storageLocation, in_filepath, in_delegate, out_resource);\n        });\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Core/Image/CSImageProvider.h",
    "content": "//\n//  CSImageProvider.h\n//  ChilliSource\n//  Created by Scott Downie on 10/08/2012.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2012 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_IMAGE_CSIMAGEPROVIDER_H_\n#define _CHILLISOURCE_CORE_IMAGE_CSIMAGEPROVIDER_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Resource/ResourceProvider.h>\n\nnamespace ChilliSource\n{\n    //-------------------------------------------------------------\n    /// A resource provider that creates images from csimage files.\n    ///\n    /// @author S Downie\n    //-------------------------------------------------------------\n    class CSImageProvider final : public ResourceProvider\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(CSImageProvider);\n\n        //-------------------------------------------------------\n        /// Is the object of the given interface type.\n        ///\n        /// @author S Downie\n        ///\n        /// @param Interface type to query\n        ///\n        /// @return Whether the object is of given type\n        //-------------------------------------------------------\n        bool IsA(InterfaceIDType in_interfaceId) const override;\n        //-------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return The resource type this provider can load\n        //-------------------------------------------------------\n        InterfaceIDType GetResourceType() const override;\n        //-------------------------------------------------------\n        /// Queries whether or not this provider can create\n        /// resources from files with the given extension.\n        ///\n        /// @author S Downie\n        ///\n        /// @param Extension to compare against\n        ///\n        /// @return Whether the object can load a resource with\n        /// that extension\n        //-------------------------------------------------------\n        bool CanCreateResourceWithFileExtension(const std::string& in_extension) const override;\n        //-------------------------------------------------------\n        /// Creates a new image from file. Check the resource\n        /// load state for success or failure\n        ///\n        /// @author S Downie\n        ///\n        /// @param The storage location to load from\n        /// @param File path to resource\n        /// @param Options to customise the creation\n        /// @param [Out] Resource\n        //-------------------------------------------------------\n        void CreateResourceFromFile(StorageLocation in_storageLocation, const std::string& in_filepath, const IResourceOptionsBaseCSPtr& in_options, const ResourceSPtr& out_resource) override;\n        //----------------------------------------------------\n        /// Creates a new resource from file asynchronously.\n        /// Completion delegate is called on finish. Check\n        /// the resource load state for success or failure\n        ///\n        /// @author S Downie\n        ///\n        /// @param The storage location.\n        /// @param The filepath.\n        /// @param Options to customise the creation\n        /// @param Completion delegate\n        /// @param [Out] The output resource.\n        //----------------------------------------------------\n        void CreateResourceFromFileAsync(StorageLocation in_storageLocation, const std::string& in_filepath, const IResourceOptionsBaseCSPtr& in_options, const ResourceProvider::AsyncLoadDelegate& in_delegate, const ResourceSPtr& out_resource) override;\n    private:\n        \n        friend class Application;\n        //-------------------------------------------------------\n        /// Factory method\n        ///\n        /// @author S Downie\n        ///\n        /// @return New backend with ownership transferred\n        //-------------------------------------------------------\n        static CSImageProviderUPtr Create();\n        //-------------------------------------------------------\n        /// Private constructor to force use of factory method\n        ///\n        /// @author S Downie\n        //-------------------------------------------------------\n        CSImageProvider() = default;\n    };\n}\n\n#endif\n\n"
  },
  {
    "path": "Source/ChilliSource/Core/Image/ETC1ImageProvider.cpp",
    "content": "//\n//  ETC1ImageProvider.cpp\n//  ChilliSource\n//  Created by Ian Copland on 09/11/2012.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2012 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Core/Image/ETC1ImageProvider.h>\n\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/Base/Utils.h>\n#include <ChilliSource/Core/File/FileStream/IBinaryInputStream.h>\n#include <ChilliSource/Core/Image/Image.h>\n#include <ChilliSource/Core/Image/ImageCompression.h>\n#include <ChilliSource/Core/Image/ImageFormat.h>\n#include <ChilliSource/Core/Threading/TaskScheduler.h>\n\nnamespace ChilliSource\n{\n    namespace\n    {\n        const std::string k_etc1Extension = \"pkm\";\n        \n        //-------------------------------------------------------\n        /// A container for the ETC1 Header.\n        ///\n        /// @author Ian Copland\n        //-------------------------------------------------------\n        struct ETC1Header\n        {\n            u8 m_pkmTag[6];\n            u16 m_numberOfMipmaps;\n            u16 m_textureWidth;\n            u16 m_textureHeight;\n            u16 m_originalWidth;\n            u16 m_originalHeight;\n        };\n        //----------------------------------------------------\n        /// Actually performs the heavy lifting for the 2\n        /// create methods\n        ///\n        /// @author S Downie\n        ///\n        /// @param The storage location.\n        /// @param The filepath.\n        /// @param Completion delegate\n        /// @param [Out] The output resource.\n        //----------------------------------------------------\n        void LoadImage(StorageLocation in_storageLocation, const std::string& in_filepath, const ResourceProvider::AsyncLoadDelegate& in_delegate, const ResourceSPtr& out_resource)\n        {\n            auto pImageFile = Application::Get()->GetFileSystem()->CreateBinaryInputStream(in_storageLocation, in_filepath);\n            \n            if(pImageFile == nullptr)\n            {\n                out_resource->SetLoadState(Resource::LoadState::k_failed);\n                if(in_delegate != nullptr)\n                {\n                    Application::Get()->GetTaskScheduler()->ScheduleTask(TaskType::k_mainThread, [=](const TaskContext&) noexcept\n                    {\n                        in_delegate(out_resource);\n                    });\n                }\n                return;\n            }\n            \n            //ETC1 Format is in big endian format. As all the platforms we support are little endian we will have to convert the data to little endian.\n            //read the header.\n            ETC1Header sHeader;\n            pImageFile->Read(sHeader.m_pkmTag, sizeof(u8) * 6);\n            \n            pImageFile->Read((u8*)&sHeader.m_numberOfMipmaps, sizeof(u16));\n            sHeader.m_numberOfMipmaps = Utils::Endian2ByteSwap(reinterpret_cast<u16*>(&sHeader.m_numberOfMipmaps));\n            \n            pImageFile->Read((u8*)&sHeader.m_textureWidth, sizeof(u16));\n            sHeader.m_textureWidth = Utils::Endian2ByteSwap(reinterpret_cast<u16*>(&sHeader.m_textureWidth));\n            \n            pImageFile->Read((u8*)&sHeader.m_textureHeight, sizeof(u16));\n            sHeader.m_textureHeight = Utils::Endian2ByteSwap(reinterpret_cast<u16*>(&sHeader.m_textureHeight));\n            \n            pImageFile->Read((u8*)&sHeader.m_originalWidth, sizeof(u16));\n            sHeader.m_originalWidth = Utils::Endian2ByteSwap(reinterpret_cast<u16*>(&sHeader.m_originalWidth));\n            \n            pImageFile->Read((u8*)&sHeader.m_originalHeight, sizeof(u16));\n            sHeader.m_originalHeight = Utils::Endian2ByteSwap(reinterpret_cast<u16*>(&sHeader.m_originalHeight));\n            \n            //get the size of the rest of the data\n            const u32 kstrHeaderSize = 16;\n            u32 dwDataSize = u32(pImageFile->GetLength()) - kstrHeaderSize;\n            \n            //read the rest of the data\n            u8* pData = new u8[dwDataSize];\n            pImageFile->Read((u8*)pData, dwDataSize);\n            pImageFile.reset();\n\n            Image::ImageDataUPtr imageData(pData);\n            \n            //setup the output image\n            Image::Descriptor desc;\n            desc.m_format = ImageFormat::k_RGB888;\n            desc.m_compression = ImageCompression::k_ETC1;\n            desc.m_width = sHeader.m_textureWidth;\n            desc.m_height = sHeader.m_textureHeight;\n            desc.m_dataSize = dwDataSize;\n            \n            Image* outpImage = (Image*)out_resource.get();\n            outpImage->Build(desc, std::move(imageData));\n            outpImage->SetLoadState(Resource::LoadState::k_loaded);\n            \n            if(in_delegate != nullptr)\n            {\n                Application::Get()->GetTaskScheduler()->ScheduleTask(TaskType::k_mainThread, [=](const TaskContext&) noexcept\n                {\n                    in_delegate(out_resource);\n                });\n            }\n        }\n    }\n    \n    CS_DEFINE_NAMEDTYPE(ETC1ImageProvider);\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    ETC1ImageProviderUPtr ETC1ImageProvider::Create()\n    {\n        return ETC1ImageProviderUPtr(new ETC1ImageProvider());\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    bool ETC1ImageProvider::IsA(InterfaceIDType in_interfaceId) const\n    {\n        return (in_interfaceId == ResourceProvider::InterfaceID || in_interfaceId == ETC1ImageProvider::InterfaceID);\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    InterfaceIDType ETC1ImageProvider::GetResourceType() const\n    {\n        return Image::InterfaceID;\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    bool ETC1ImageProvider::CanCreateResourceWithFileExtension(const std::string& in_extension) const\n    {\n        return in_extension == k_etc1Extension;\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    void ETC1ImageProvider::CreateResourceFromFile(StorageLocation in_storageLocation, const std::string& in_filepath, const IResourceOptionsBaseCSPtr& in_options, const ResourceSPtr& out_resource)\n    {\n        LoadImage(in_storageLocation, in_filepath, nullptr, out_resource);\n    }\n    //----------------------------------------------------\n    //----------------------------------------------------\n    void ETC1ImageProvider::CreateResourceFromFileAsync(StorageLocation in_storageLocation, const std::string& in_filepath, const IResourceOptionsBaseCSPtr& in_options, const ResourceProvider::AsyncLoadDelegate& in_delegate, const ResourceSPtr& out_resource)\n    {\n        Application::Get()->GetTaskScheduler()->ScheduleTask(TaskType::k_file, [=](const TaskContext&) noexcept\n        {\n            LoadImage(in_storageLocation, in_filepath, in_delegate, out_resource);\n        });\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Core/Image/ETC1ImageProvider.h",
    "content": "//\n//  ETC1ImageProvider.h\n//  ChilliSource\n//  Created by Ian Copland on 09/11/2012.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2012 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_IMAGE_ETC1IMAGEPROVIDER_H_\n#define _CHILLISOURCE_CORE_IMAGE_ETC1IMAGEPROVIDER_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Resource/ResourceProvider.h>\n\nnamespace ChilliSource\n{\n    //--------------------------------------------------------------------\n    /// An image provider for the ETC1 format. The ETC1 format is not\n    /// available on all platforms and you should be sure it is supported\n    /// if using it.\n    ///\n    /// @author Ian Copland\n    //--------------------------------------------------------------------\n    class ETC1ImageProvider final : public ResourceProvider\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(ETC1ImageProvider);\n        //-------------------------------------------------------\n        /// Is the object of the given interface type.\n        ///\n        /// @author S Downie\n        ///\n        /// @param Interface type to query\n        ///\n        /// @return Whether the object is of given type\n        //-------------------------------------------------------\n        bool IsA(InterfaceIDType in_interfaceId) const override;\n        //-------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return The resource type this provider can load\n        //-------------------------------------------------------\n        InterfaceIDType GetResourceType() const override;\n        //-------------------------------------------------------\n        /// Queries whether or not this provider can create\n        /// resources from files with the given extension.\n        ///\n        /// @author S Downie\n        ///\n        /// @param Extension to compare against\n        ///\n        /// @return Whether the object can load a resource with\n        /// that extension\n        //-------------------------------------------------------\n        bool CanCreateResourceWithFileExtension(const std::string& in_extension) const override;\n        //-------------------------------------------------------\n        /// Creates a new image from file. Check the resource\n        /// load state for success or failure\n        ///\n        /// @author S Downie\n        ///\n        /// @param The storage location to load from\n        /// @param File path to resource\n        /// @param Options to customise the creation\n        /// @param [Out] Resource\n        //-------------------------------------------------------\n        void CreateResourceFromFile(StorageLocation in_storageLocation, const std::string& in_filepath, const IResourceOptionsBaseCSPtr& in_options, const ResourceSPtr& out_resource) override;\n        //----------------------------------------------------\n        /// Creates a new resource from file asynchronously.\n        /// Completion delegate is called on finish. Check\n        /// the resource load state for success or failure\n        ///\n        /// @author S Downie\n        ///\n        /// @param The storage location.\n        /// @param The filepath.\n        /// @param Options to customise the creation\n        /// @param Completion delegate\n        /// @param [Out] The output resource.\n        //----------------------------------------------------\n        void CreateResourceFromFileAsync(StorageLocation in_storageLocation, const std::string& in_filepath, const IResourceOptionsBaseCSPtr& in_options, const ResourceProvider::AsyncLoadDelegate& in_delegate, const ResourceSPtr& out_resource) override;\n        \n    private:\n        friend class Application;\n        //-------------------------------------------------------------\n        /// Factory method\n        ///\n        /// @author S Downie\n        ///\n        /// @return New backend with ownership transferred\n        //-------------------------------------------------------------\n        static ETC1ImageProviderUPtr Create();\n        //-------------------------------------------------------\n        /// Private constructor to force use of factory method\n        ///\n        /// @author S Downie\n        //-------------------------------------------------------\n        ETC1ImageProvider() = default;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Image/Image.cpp",
    "content": "//\n//  Image.cpp\n//  ChilliSource\n//  Created by Scott Downie on 01/10/2010.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2010 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Core/Image/Image.h>\n\n#include <ChilliSource/Core/Image/ImageCompression.h>\n#include <ChilliSource/Core/Image/ImageFormat.h>\n\nnamespace ChilliSource\n{\n    CS_DEFINE_NAMEDTYPE(Image);\n\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    ImageUPtr Image::Create()\n    {\n        return ImageUPtr(new Image());\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    bool Image::IsA(InterfaceIDType in_interfaceId) const\n    {\n        return in_interfaceId == Image::InterfaceID;\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    void Image::Build(const Descriptor& in_desc, ImageDataUPtr in_imageData)\n    {\n        m_dataDesc = in_desc;\n        m_imageData = std::move(in_imageData);\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    ImageFormat Image::GetFormat() const\n    {\n        return m_dataDesc.m_format;\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    u32 Image::GetWidth() const\n    {\n        return m_dataDesc.m_width;\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    u32 Image::GetHeight() const\n    {\n        return m_dataDesc.m_height;\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    const u8* Image::GetData() const\n    {\n        return m_imageData.get();\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    Image::ImageDataUPtr&& Image::MoveData()\n    {\n        return std::move(m_imageData);\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    ImageCompression Image::GetCompression() const\n    {\n        return m_dataDesc.m_compression;\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    u32 Image::GetDataSize() const\n    {\n        return m_dataDesc.m_dataSize;\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Core/Image/Image.h",
    "content": "//\n//  Image.h\n//  ChilliSource\n//  Created by Scott Downie on 01/10/2010.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2010 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_IMAGE_IMAGE_H_\n#define _CHILLISOURCE_CORE_IMAGE_IMAGE_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Resource/Resource.h>\n\nnamespace ChilliSource\n{\n    //----------------------------------------------------------------\n    /// A resource for a loaded image in one of the formats supported\n    /// in ImageFormat.h\n    ///\n    /// @author S Downie\n    //----------------------------------------------------------------\n    class Image : public Resource\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(Image);\n        \n        using ImageDataUPtr = std::unique_ptr<u8[]>;\n        \n        //----------------------------------------------------------------\n        /// Holds the information about the image data such as size,\n        /// compression, etc. Used to build the image resource\n        ///\n        /// @author S Downie\n        //----------------------------------------------------------------\n        struct Descriptor\n        {\n            ImageCompression m_compression;\n            ImageFormat m_format;\n            u32 m_width;\n            u32 m_height;\n            u32 m_dataSize;\n        };\n        //----------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Interface type to query\n        ///\n        /// @return Whether the object is of given type\n        //----------------------------------------------------------------\n        bool IsA(InterfaceIDType in_interfaceId) const override;\n        //----------------------------------------------------------------\n        /// Populate the image with the given data. The image resource\n        /// takes ownership of the raw image data\n        ///\n        /// @author S Downie\n        ///\n        /// @param Image data descriptor\n        /// @param Image data\n        //----------------------------------------------------------------\n        void Build(const Descriptor& in_desc, ImageDataUPtr in_imageData);\n        //----------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Image format (RGB, RGBA, etc)\n        //----------------------------------------------------------------\n        ImageFormat GetFormat() const;\n        //----------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return image compression type\n        //----------------------------------------------------------------\n        ImageCompression GetCompression() const;\n        //----------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Image width\n        //----------------------------------------------------------------\n        u32 GetWidth() const;\n        //----------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Image height\n        //----------------------------------------------------------------\n        u32 GetHeight() const;\n        //----------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Return size of the image in bytes\n        //----------------------------------------------------------------\n        u32 GetDataSize() const;\n        //----------------------------------------------------------------\n        /// Use datasize, width, height, format and compression\n        /// to decode\n        ///\n        /// @author S Downie\n        ///\n        /// @return Image data.\n        //----------------------------------------------------------------\n        const u8* GetData() const;\n        \n    private:\n        friend class ResourcePool;\n        friend class TextureProvider;\n        friend class CubemapProvider;\n        //----------------------------------------------------------------\n        /// Factory create method. Only called by resource pool or by\n        /// texture provider.\n        ///\n        /// @author S Downie\n        ///\n        /// @return An empty image resource\n        //----------------------------------------------------------------\n        static ImageUPtr Create();\n        //----------------------------------------------------------------\n        /// Private constructor to force the use of the factory create\n        /// method\n        ///\n        /// @author S Downie\n        //----------------------------------------------------------------\n        Image() = default;\n        //----------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Ownership of image data.\n        //----------------------------------------------------------------\n        ImageDataUPtr&& MoveData();\n        \n    private:\n        \n        Descriptor m_dataDesc;\n        \n        ImageDataUPtr m_imageData;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Image/ImageCompression.h",
    "content": "//\n//  ImageCompression.h\n//  ChilliSource\n//  Created by Scott Downie on 15/04/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_IMAGE_IMAGECOMRPESSION_H_\n#define _CHILLISOURCE_CORE_IMAGE_IMAGECOMRPESSION_H_\n\nnamespace ChilliSource\n{\n    //-----------------------------------------------------\n    /// Holds the supported image compression that can be\n    /// converted to textures.\n    ///\n    /// @author S Downie\n    //-----------------------------------------------------\n    enum class ImageCompression\n    {\n        k_none,\n        k_PVR4Bpp,\n        k_PVR2Bpp,\n        k_ETC1\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Image/ImageFormat.h",
    "content": "//\n//  ImageFormat.h\n//  ChilliSource\n//  Created by Scott Downie on 15/04/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_IMAGE_IMAGEFORMAT_H_\n#define _CHILLISOURCE_CORE_IMAGE_IMAGEFORMAT_H_\n\nnamespace ChilliSource\n{\n    //-----------------------------------------------------\n    /// Holds the supported image formats that can be\n    /// converted to texture.\n    ///\n    /// @author S Downie\n    //-----------------------------------------------------\n    enum class ImageFormat\n    {\n        k_RGBA4444,\n        k_RGBA8888,\n        k_RGB888,\n        k_RGB565,\n        k_LumA88,\n        k_Lum8,\n        k_Depth16,\n        k_Depth32\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Image/ImageFormatConverter.cpp",
    "content": "//\n//  ImageFormatConverter.cpp\n//  ChilliSource\n//  Created by Ian Copland on 10/04/2013.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2013 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Core/Image/ImageFormatConverter.h>\n\n#include <ChilliSource/Core/Base/ByteColour.h>\n#include <ChilliSource/Core/Image/ImageCompression.h>\n#include <ChilliSource/Core/Image/ImageFormat.h>\n\nnamespace ChilliSource\n{\n    namespace ImageFormatConverter\n    {\n        //---------------------------------------------------\n        //---------------------------------------------------\n        void RGBA8888ToRGB888(Image* in_image)\n        {\n            CS_ASSERT(in_image->GetFormat() == ImageFormat::k_RGBA8888 && in_image->GetCompression() == ImageCompression::k_none, \"Cannot convert an image that is not in uncompressed RGBA8888 format.\");\n            \n            ImageBuffer rawBuffer = RGBA8888ToRGB888(in_image->GetData(), in_image->GetDataSize());\n        \n            Image::Descriptor desc;\n            desc.m_width = in_image->GetWidth();\n            desc.m_height = in_image->GetHeight();\n            desc.m_dataSize = rawBuffer.m_size;\n            desc.m_compression = in_image->GetCompression();\n            desc.m_format = ImageFormat::k_RGB888;\n            in_image->Build(desc, std::move(rawBuffer.m_data));\n        }\n        //---------------------------------------------------\n        //---------------------------------------------------\n        void RGBA8888ToRGBA4444(Image* in_image)\n        {\n            CS_ASSERT(in_image->GetFormat() == ImageFormat::k_RGBA8888 && in_image->GetCompression() == ImageCompression::k_none, \"Cannot convert an image that is not in uncompressed RGBA8888 format.\");\n            \n            ImageBuffer rawBuffer = RGBA8888ToRGBA4444(in_image->GetData(), in_image->GetDataSize());\n\n            Image::Descriptor desc;\n            desc.m_width = in_image->GetWidth();\n            desc.m_height = in_image->GetHeight();\n            desc.m_dataSize = rawBuffer.m_size;\n            desc.m_compression = in_image->GetCompression();\n            desc.m_format = ImageFormat::k_RGBA4444;\n            in_image->Build(desc, std::move(rawBuffer.m_data));\n        }\n        //---------------------------------------------------\n        //---------------------------------------------------\n        void RGBA8888ToRGB565(Image* in_image)\n        {\n            CS_ASSERT(in_image->GetFormat() == ImageFormat::k_RGBA8888 && in_image->GetCompression() == ImageCompression::k_none, \"Cannot convert an image that is not in uncompressed RGBA8888 format.\");\n            \n            ImageBuffer rawBuffer = RGBA8888ToRGB565(in_image->GetData(), in_image->GetDataSize());\n\n            Image::Descriptor desc;\n            desc.m_width = in_image->GetWidth();\n            desc.m_height = in_image->GetHeight();\n            desc.m_dataSize = rawBuffer.m_size;\n            desc.m_compression = in_image->GetCompression();\n            desc.m_format = ImageFormat::k_RGB565;\n            in_image->Build(desc, std::move(rawBuffer.m_data));\n        }\n        //---------------------------------------------------\n        //---------------------------------------------------\n        void RGBA8888ToLumA88(Image* in_image)\n        {\n            CS_ASSERT(in_image->GetFormat() == ImageFormat::k_RGBA8888 && in_image->GetCompression() == ImageCompression::k_none, \"Cannot convert an image that is not in uncompressed RGBA8888 format.\");\n            \n            ImageBuffer rawBuffer = RGBA8888ToLumA88(in_image->GetData(), in_image->GetDataSize());\n\n            Image::Descriptor desc;\n            desc.m_width = in_image->GetWidth();\n            desc.m_height = in_image->GetHeight();\n            desc.m_dataSize = rawBuffer.m_size;\n            desc.m_compression = in_image->GetCompression();\n            desc.m_format = ImageFormat::k_LumA88;\n            in_image->Build(desc, std::move(rawBuffer.m_data));\n        }\n        //---------------------------------------------------\n        //---------------------------------------------------\n        void RGBA8888ToLum8(Image* in_image)\n        {\n            CS_ASSERT(in_image->GetFormat() == ImageFormat::k_RGBA8888 && in_image->GetCompression() == ImageCompression::k_none, \"Cannot convert an image that is not in uncompressed RGBA8888 format.\");\n            \n            ImageBuffer rawBuffer = RGBA8888ToLum8(in_image->GetData(), in_image->GetDataSize());\n\n            Image::Descriptor desc;\n            desc.m_width = in_image->GetWidth();\n            desc.m_height = in_image->GetHeight();\n            desc.m_dataSize = rawBuffer.m_size;\n            desc.m_compression = in_image->GetCompression();\n            desc.m_format = ImageFormat::k_Lum8;\n            in_image->Build(desc, std::move(rawBuffer.m_data));\n        }\n        //---------------------------------------------------\n        //---------------------------------------------------\n        ImageBuffer RGBA8888ToRGB888(const u8* in_imageData, u32 in_imageDataSize)\n        {\n            CS_ASSERT(in_imageDataSize > 0 && in_imageDataSize % 4 == 0, \"Invalid input image data size.\");\n\n            struct PixelRGB888\n            {\n                u8 m_r;\n                u8 m_g;\n                u8 m_b;\n            };\n\n            const u32 k_outputBytesPerPixel = 3;\n            const u32 area = in_imageDataSize / 4;\n\n            ImageBuffer outputBuffer;\n            outputBuffer.m_size = area * k_outputBytesPerPixel;\n            outputBuffer.m_data = std::unique_ptr<u8[]>(new u8[outputBuffer.m_size]);\n\n            const ByteColour* pixel32 = reinterpret_cast<const ByteColour*>(in_imageData);\n            PixelRGB888* pixel24 = reinterpret_cast<PixelRGB888*>(outputBuffer.m_data.get());\n\n            for(u32 i = 0; i < area; ++i, ++pixel32, ++pixel24)\n            {\n                pixel24->m_r = pixel32->r;\n                pixel24->m_g = pixel32->g;\n                pixel24->m_b = pixel32->b;\n            }\n\n            return outputBuffer;\n        }\n        //---------------------------------------------------\n        //---------------------------------------------------\n        ImageBuffer RGBA8888ToRGBA4444(const u8* in_imageData, u32 in_imageDataSize)\n        {\n            CS_ASSERT(in_imageDataSize > 0 && in_imageDataSize % 4 == 0, \"Invalid input image data size.\");\n\n            const u32 k_outputBytesPerPixel = 2;\n            const u32 area = in_imageDataSize / 4;\n\n            ImageBuffer outputBuffer;\n            outputBuffer.m_size = area * k_outputBytesPerPixel;\n            outputBuffer.m_data = std::unique_ptr<u8[]>(new u8[outputBuffer.m_size]);\n\n            const u32* pixel32 = reinterpret_cast<const u32*>(in_imageData);\n            u16* pixel16 = reinterpret_cast<u16*>(outputBuffer.m_data.get());\n\n            for(u32 i = 0; i < area; ++i, ++pixel32, ++pixel16)\n            {\n                *pixel16 = ((((*pixel32 >> 0) & 0xFF) >> 4) << 12) | // R\n                    ((((*pixel32 >> 8) & 0xFF) >> 4) << 8) | // G\n                    ((((*pixel32 >> 16) & 0xFF) >> 4) << 4) | // B\n                    ((((*pixel32 >> 24) & 0xFF) >> 4) << 0); // A\n            }\n\n            return outputBuffer;\n        }\n        //---------------------------------------------------\n        //---------------------------------------------------\n        ImageBuffer RGBA8888ToRGB565(const u8* in_imageData, u32 in_imageDataSize)\n        {\n            CS_ASSERT(in_imageDataSize > 0 && in_imageDataSize % 4 == 0, \"Invalid input image data size.\");\n\n            const u32 k_outputBytesPerPixel = 2;\n            const u32 area = in_imageDataSize / 4;\n\n            ImageBuffer outputBuffer;\n            outputBuffer.m_size = area * k_outputBytesPerPixel;\n            outputBuffer.m_data = std::unique_ptr<u8[]>(new u8[outputBuffer.m_size]);\n\n            const u32* pixel32 = reinterpret_cast<const u32*>(in_imageData);\n            u16* pixel16 = reinterpret_cast<u16*>(outputBuffer.m_data.get());\n\n            for(u32 i = 0; i < area; ++i, ++pixel32, ++pixel16)\n            {\n                *pixel16 = ((((*pixel32 >> 0) & 0xFF) >> 3) << 11) |\n                    ((((*pixel32 >> 8) & 0xFF) >> 2) << 5) |\n                    ((((*pixel32 >> 16) & 0xFF) >> 3) << 0);\n            }\n\n            return outputBuffer;\n        }\n        //---------------------------------------------------\n        //---------------------------------------------------\n        ImageBuffer RGBA8888ToLumA88(const u8* in_imageData, u32 in_imageDataSize)\n        {\n            CS_ASSERT(in_imageDataSize > 0 && in_imageDataSize % 4 == 0, \"Invalid input image data size.\");\n\n            const u32 k_outputBytesPerPixel = 2;\n            const u32 area = in_imageDataSize / 4;\n\n            ImageBuffer outputBuffer;\n            outputBuffer.m_size = area * k_outputBytesPerPixel;\n            outputBuffer.m_data = std::unique_ptr<u8[]>(new u8[outputBuffer.m_size]);\n\n            const u32* pixel32 = reinterpret_cast<const u32*>(in_imageData);\n            u16* pixel16 = reinterpret_cast<u16*>(outputBuffer.m_data.get());\n\n            for(u32 i = 0; i < area; ++i, ++pixel32, ++pixel16)\n            {\n                *pixel16 = ((*pixel32) & 0xFF) | // L\n                    ((*pixel32 >> 16) & 0xFF00); // A\n            }\n\n            return outputBuffer;\n        }\n        //---------------------------------------------------\n        //---------------------------------------------------\n        ImageBuffer RGBA8888ToLum8(const u8* in_imageData, u32 in_imageDataSize)\n        {\n            CS_ASSERT(in_imageDataSize > 0 && in_imageDataSize % 4 == 0, \"Invalid input image data size.\");\n\n            const u32 k_outputBytesPerPixel = 1;\n            const u32 area = in_imageDataSize / 4;\n\n            ImageBuffer outputBuffer;\n            outputBuffer.m_size = area * k_outputBytesPerPixel;\n            outputBuffer.m_data = std::unique_ptr<u8[]>(new u8[outputBuffer.m_size]);\n\n            const u32* pixel32 = reinterpret_cast<const u32*>(in_imageData);\n            u8* pixel8 = outputBuffer.m_data.get();\n\n            for(u32 i = 0; i < area; ++i, ++pixel32, ++pixel8)\n            {\n                *pixel8 = ((*pixel32)& 0xFF);\n            }\n\n            return outputBuffer;\n        }\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Core/Image/ImageFormatConverter.h",
    "content": "//\n//  ImageFormatConverter.h\n//  ChilliSource\n//  Created by Ian Copland on 10/04/2013.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2013 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_IMAGE_IMAGEFORMATCONVERTER_H\n#define _CHILLISOURCE_CORE_IMAGE_IMAGEFORMATCONVERTER_H\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Image/Image.h>\n\nnamespace ChilliSource\n{\n    //---------------------------------------------------------\n    /// The image format converter provides a number of method\n    /// for converting from one image format to another.\n    ///\n    /// @author Ian Copland\n    //---------------------------------------------------------\n    namespace ImageFormatConverter\n    {\n        //---------------------------------------------------\n        /// A struct containing the buffer and size of raw\n        /// image data.\n        ///\n        /// @author Ian Copland\n        //---------------------------------------------------\n        struct ImageBuffer final\n        {\n            Image::ImageDataUPtr m_data;\n            u32 m_size = 0;\n        };\n        //---------------------------------------------------\n        /// Converts an Image in format RGBA8888 to RGB888\n        /// format. This will allocate a new buffer for the\n        /// target format data and release the previous\n        /// buffer.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param A pointer to the image to convert.\n        //---------------------------------------------------\n        void RGBA8888ToRGB888(Image* in_image);\n        //---------------------------------------------------\n        /// Converts an Image in format RGBA8888 to RGBA4444\n        /// format. This will allocate a new buffer for the\n        /// target format data and release the previous\n        /// buffer.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param A pointer to the image to convert.\n        //---------------------------------------------------\n        void RGBA8888ToRGBA4444(Image* in_image);\n        //---------------------------------------------------\n        /// Converts an Image in format RGBA8888 to RGB565\n        /// format. This will allocate a new buffer for the\n        /// target format data and release the previous\n        /// buffer.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param A pointer to the image to convert.\n        //---------------------------------------------------\n        void RGBA8888ToRGB565(Image* in_image);\n        //---------------------------------------------------\n        /// Converts an Image in format RGBA8888 to LumA88\n        /// format. This will allocate a new buffer for the\n        /// target format data and release the previous\n        /// buffer.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param A pointer to the image to convert.\n        //---------------------------------------------------\n        void RGBA8888ToLumA88(Image* in_image);\n        //---------------------------------------------------\n        /// Converts an Image in format RGBA8888 to LumA88\n        /// format. This will allocate a new buffer for the\n        /// target format data and release the previous\n        /// buffer.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param A pointer to the image to convert.\n        //---------------------------------------------------\n        void RGBA8888ToLum8(Image* in_image);\n        //---------------------------------------------------\n        /// Creates new RGB888 image data from RGBA8888 image\n        /// data.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The input RGBA8888 image data buffer.\n        /// @param The size of the RGBA8888 image data buffer.\n        ///\n        /// @return The output RGB888 image data.\n        //---------------------------------------------------\n        ImageBuffer RGBA8888ToRGB888(const u8* in_imageData, u32 in_imageDataSize);\n        //---------------------------------------------------\n        /// Creates new RGBA4444 image data from RGBA8888 image\n        /// data.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The input RGBA8888 image data buffer.\n        /// @param The size of the RGBA8888 image data buffer.\n        ///\n        /// @return The output RGBA4444 image data.\n        //---------------------------------------------------\n        ImageBuffer RGBA8888ToRGBA4444(const u8* in_imageData, u32 in_imageDataSize);\n        //---------------------------------------------------\n        /// Creates new RGB565 image data from RGBA8888 image\n        /// data.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The input RGBA8888 image data buffer.\n        /// @param The size of the RGBA8888 image data buffer.\n        ///\n        /// @return The output RGB565 image data.\n        //---------------------------------------------------\n        ImageBuffer RGBA8888ToRGB565(const u8* in_imageData, u32 in_imageDataSize);\n        //---------------------------------------------------\n        /// Creates new LumA88 image data from RGBA8888 image\n        /// data.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The input RGBA8888 image data buffer.\n        /// @param The size of the RGBA8888 image data buffer.\n        ///\n        /// @return The output LumA88 image data.\n        //---------------------------------------------------\n        ImageBuffer RGBA8888ToLumA88(const u8* in_imageData, u32 in_imageDataSize);\n        //---------------------------------------------------\n        /// Creates new LUM8 image data from RGBA8888 image\n        /// data.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The input RGBA8888 image data buffer.\n        /// @param The size of the RGBA8888 image data buffer.\n        ///\n        /// @return The output Lum8 image data.\n        //---------------------------------------------------\n        ImageBuffer RGBA8888ToLum8(const u8* in_imageData, u32 in_imageDataSize);\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Image/PNGImageProvider.cpp",
    "content": "//\n//  PNGImageProvider.cpp\n//  ChilliSource\n//  Created by Scott Downie on 01/08/2011.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2011 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Core/Image/PNGImageProvider.h>\n\n#ifdef CS_TARGETPLATFORM_IOS\n#include <CSBackend/Platform/iOS/Core/Image/PNGImageProvider.h>\n#endif\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n#include <CSBackend/Platform/Android/Main/JNI/Core/Image/PNGImageProvider.h>\n#endif\n\n#ifdef CS_TARGETPLATFORM_WINDOWS\n#include <CSBackend/Platform/Windows/Core/Image/PNGImageProvider.h>\n#endif\n\n#ifdef CS_TARGETPLATFORM_RPI\n#include <CSBackend/Platform/RPi/Core/Image/PNGImageProvider.h>\n#endif\n\nnamespace ChilliSource\n{\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    PNGImageProviderUPtr PNGImageProvider::Create()\n    {\n#ifdef CS_TARGETPLATFORM_IOS\n        return PNGImageProviderUPtr(new CSBackend::iOS::PNGImageProvider());\n#endif\n#ifdef CS_TARGETPLATFORM_ANDROID\n        return PNGImageProviderUPtr(new CSBackend::Android::PNGImageProvider());\n#endif\n#ifdef CS_TARGETPLATFORM_WINDOWS\n        return PNGImageProviderUPtr(new CSBackend::Windows::PNGImageProvider());\n#endif\n#ifdef CS_TARGETPLATFORM_RPI\n        return PNGImageProviderUPtr(new CSBackend::RPi::PNGImageProvider());\n#endif\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Core/Image/PNGImageProvider.h",
    "content": "//\n//  PNGImageProvider.h\n//  ChilliSource\n//  Created by Scott Downie on 01/08/2011.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2011 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_IMAGE_PNGIMAGEPROVIDER_H_\n#define _CHILLISOURCE_CORE_IMAGE_PNGIMAGEPROVIDER_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Resource/ResourceProvider.h>\n\nnamespace ChilliSource\n{\n    //---------------------------------------------------------------\n    /// An image loader interface that providers PNG resources\n    ///\n    /// @author S Downie\n    //---------------------------------------------------------------\n    class PNGImageProvider : public ResourceProvider\n    {\n    protected:\n        friend class Application;\n        //-------------------------------------------------------\n        /// Create the platform dependent backend\n        ///\n        /// @author S Downie\n        ///\n        /// @return New backend instance\n        //-------------------------------------------------------\n        static PNGImageProviderUPtr Create();\n        //-------------------------------------------------------\n        /// Private constructor to force use of factory method\n        ///\n        /// @author S Downie\n        //-------------------------------------------------------\n        PNGImageProvider() = default;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Image/PVRImageProvider.cpp",
    "content": "//\n//  PVRImageProvider.cpp\n//  ChilliSource\n//  Created by Scott Downie on 08/05/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Core/Image/PVRImageProvider.h>\n\n#include <CSBackend/Platform/iOS/Core/File/FileSystem.h>\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/Image/Image.h>\n#include <ChilliSource/Core/Image/ImageCompression.h>\n#include <ChilliSource/Core/Image/ImageFormat.h>\n#include <ChilliSource/Core/Threading/TaskScheduler.h>\n\nnamespace ChilliSource\n{\n    namespace\n    {\n        const u32 k_pvrVersionMismatch = 0x50565203;\n        \n        struct PVRTCTexHeader\n        {\n            u32 udwVersion;\n            u32 udwFlags;\n            u64 udwPixelFormat;\n            u32 udwColourSpace;\n            u32 udwChannelType;\n            u32 udwHeight;\n            u32 udwWidth;\n            u32 udwDepth;\n            u32 udwNumSurfaces;\n            u32 udwNumFaces;\n            u32 udwMipMapCount;\n            u32 udwMetaDataSize;\n        };\n        \n        //Anything outside these is not supported on iDevices\n        enum class PixelFormat\n        {\n            k_2BppRGB,\n            k_2BppRGBA,\n            k_4BppRGB,\n            k_4BppRGBA\n        };\n        \n        enum class ColourSpace\n        {\n            k_linearRGB,\n            k_SRGB\n        };\n        \n        enum class ChannelType\n        {\n            k_unsignedByteNormalised,\n            k_signedByteNormalised,\n            k_unsignedByte,\n            k_signedByte,\n            k_unsignedShortNormalised,\n            k_signedShortNormalised,\n            k_unsignedShort,\n            k_signedShort,\n            k_unsignedIntNormalised,\n            k_signedIntNormalised,\n            k_unsignedInt,\n            k_signedInt,\n            k_float\n        };\n        \n        const std::string k_pvrExtension(\"pvr\");\n        \n        //-----------------------------------------------------------\n        /// Create an image in raw byte format\n        ///\n        /// @author S McGaw\n        ///\n        /// @param Image data in bytes\n        /// @param Size of data in bytes\n        /// @param [Out] Image resource\n        //------------------------------------------------------------\n        void CreatePVRImageFromFile(const s8* in_data, u32 in_dataSize, Image* out_image)\n        {\n            //Get the header data from the image file\n            const PVRTCTexHeader* header = reinterpret_cast<const PVRTCTexHeader*>(in_data);\n            \n            //Check the version so determine endianess correctness\n            if(header->udwVersion == k_pvrVersionMismatch)\n            {\n                CS_LOG_FATAL(\"Image::UnpackPVRTCData >> Endianess Check failed for creating PVR\");\n            }\n            \n            u64 udwPFormat = header->udwPixelFormat;\n            \n            u32 udwLow32Bits  = udwPFormat & 0x00000000ffffffff;\n            u32 udwHigh32Bits = udwPFormat >> 32; //Shift to right 32bits\n            ImageCompression compression = ImageCompression::k_none;\n            ImageFormat format = ImageFormat::k_RGB888;\n            \n            //Calculate the data size for each texture level and respect the minimum number of blocks\n            u32 udwBpp = 4;\n            \n            //Where the most significant 4 bytes have been set to ‘0’ the least significant 4 bytes will contain a 32bit unsigned integer value identifying the pixel format.\n            if(udwHigh32Bits == 0)\n            {\n                if(udwLow32Bits == (u32)PixelFormat::k_2BppRGB || udwLow32Bits == (u32)PixelFormat::k_2BppRGBA)\n                {\n                    compression = ImageCompression::k_PVR2Bpp;\n                    \n                    //Pixel by pixel block size for 2bpp\n                    udwBpp = 2;\n                    \n                    //Set if Alpha in image\n                    if(udwLow32Bits == (u32)PixelFormat::k_2BppRGBA)\n                    {\n                        format = ImageFormat::k_RGBA8888;\n                    }\n                }\n                else if(udwLow32Bits == (u32)PixelFormat::k_4BppRGB || udwLow32Bits == (u32)PixelFormat::k_4BppRGBA)\n                {\n                    compression = ImageCompression::k_PVR4Bpp;\n                    \n                    //Pixel by pixel block size for 4bpp\n                    udwBpp = 4;\n                    \n                    //Set if Alpha in image\n                    if(udwLow32Bits == (u32)PixelFormat::k_4BppRGBA)\n                    {\n                        format = ImageFormat::k_RGBA8888;\n                    }\n                }\n                else\n                {\n                    CS_LOG_FATAL(\"Unrecognised PixelFormat for image\");\n                }\n            }\n            else\n            {\n                //If the most significant 4 bytes contain a value, the full 8 bytes are used to determine the pixel format. The least significant 4 bytes contain the channel order,\n                //each byte containing a single character, or a null character if there are fewer than four channels; for example, {‘r’,‘g’,‘b’,‘a’} or {‘r’,‘g’,‘b’,‘\\0’}.\n                //The most significant 4 bytes state the bit rate for each channel in the same order, each byte containing a single 8bit unsigned integer value,\n                //or zero if there are fewer than four channels; for example, {8,8,8,8} or {5,6,5,0}.\n                CS_LOG_FATAL(\"Unimplemented PixelFormat for image\");\n            }\n            \n            Image::Descriptor desc;\n            desc.m_width = header->udwWidth;\n            desc.m_height = header->udwHeight;\n            desc.m_compression = compression;\n            desc.m_format = format;\n            desc.m_dataSize = (header->udwWidth * header->udwHeight * udwBpp) >> 3;\n            \n            u8* pData = new u8[desc.m_dataSize];\n            memcpy(pData, in_data + sizeof(PVRTCTexHeader), sizeof(u8) * desc.m_dataSize);\n            out_image->Build(desc, Image::ImageDataUPtr(pData));\n        }\n        //-----------------------------------------------------------\n        /// Performs the heavy lifting for the 2 create methods\n        ///\n        /// @author S Downie\n        ///\n        /// @param The storage location.\n        /// @param The filepath.\n        /// @param Completion delegate\n        /// @param [Out] The output resource\n        //-----------------------------------------------------------\n        void LoadImage(StorageLocation in_storageLocation, const std::string& in_filePath, const ResourceProvider::AsyncLoadDelegate& in_delegate, const ResourceSPtr& out_resource)\n        {\n            auto pImageFile = Application::Get()->GetFileSystem()->CreateBinaryInputStream(in_storageLocation, in_filePath);\n            \n            if(pImageFile == nullptr)\n            {\n                out_resource->SetLoadState(Resource::LoadState::k_failed);\n                if(in_delegate != nullptr)\n                {\n                    Application::Get()->GetTaskScheduler()->ScheduleTask(TaskType::k_mainThread, [=](const TaskContext&) noexcept\n                    {\n                        in_delegate(out_resource);\n                    });\n                }\n                return;\n            }\n            \n            auto data = pImageFile->ReadAll();\n            CS_ASSERT(data->GetLength() < static_cast<std::string::size_type>(std::numeric_limits<u32>::max()), \"File is too large. It cannot exceed \" + ToString(std::numeric_limits<u32>::max()) + \" bytes.\");\n            \n            CreatePVRImageFromFile(reinterpret_cast<const s8*>(data->GetData()), u32(data->GetLength()), (Image*)out_resource.get());\n            \n            out_resource->SetLoadState(Resource::LoadState::k_loaded);\n            if(in_delegate != nullptr)\n            {\n                Application::Get()->GetTaskScheduler()->ScheduleTask(TaskType::k_mainThread, [=](const TaskContext&) noexcept\n                {\n                    in_delegate(out_resource);\n                });\n            }\n        }\n    }\n    CS_DEFINE_NAMEDTYPE(PVRImageProvider);\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    PVRImageProviderUPtr PVRImageProvider::Create()\n    {\n        return PVRImageProviderUPtr(new PVRImageProvider());\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    bool PVRImageProvider::IsA(InterfaceIDType in_interaceId) const\n    {\n        return (in_interaceId == ResourceProvider::InterfaceID || in_interaceId == PVRImageProvider::InterfaceID);\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    InterfaceIDType PVRImageProvider::GetResourceType() const\n    {\n        return Image::InterfaceID;\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    bool PVRImageProvider::CanCreateResourceWithFileExtension(const std::string& in_extension) const\n    {\n        return in_extension == k_pvrExtension;\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    void PVRImageProvider::CreateResourceFromFile(StorageLocation in_storageLocation, const std::string& in_filePath, const IResourceOptionsBaseCSPtr& in_options, const ResourceSPtr& out_resource)\n    {\n        LoadImage(in_storageLocation, in_filePath, nullptr, out_resource);\n    }\n    //----------------------------------------------------\n    //----------------------------------------------------\n    void PVRImageProvider::CreateResourceFromFileAsync(StorageLocation in_storageLocation, const std::string& in_filePath, const IResourceOptionsBaseCSPtr& in_options, const ResourceProvider::AsyncLoadDelegate& in_delegate, const ResourceSPtr& out_resource)\n    {\n        Application::Get()->GetTaskScheduler()->ScheduleTask(TaskType::k_file, [=](const TaskContext&) noexcept\n        {\n            LoadImage(in_storageLocation, in_filePath, in_delegate, out_resource);\n        });\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Core/Image/PVRImageProvider.h",
    "content": "//\n//  PVRImageProvider.h\n//  ChilliSource\n//  Created by Scott Downie on 08/05/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_IMAGE_PVRIMAGEPROVIDER_H_\n#define _CHILLISOURCE_CORE_IMAGE_PVRIMAGEPROVIDER_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Resource/ResourceProvider.h>\n\nnamespace ChilliSource\n{\n    //---------------------------------------------------------------\n    /// An image loader that provides PVR images\n    ///\n    /// @author S Downie\n    //---------------------------------------------------------------\n    class PVRImageProvider final : public ResourceProvider\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(PVRImageProvider);\n        //----------------------------------------------------------\n        /// Is the object of the given interface type\n        ///\n        /// @author S Downie\n        ///\n        /// @param Interface type to query\n        ///\n        /// @return Whether the object is of given type\n        //----------------------------------------------------------\n        bool IsA(InterfaceIDType in_interfaceId) const override;\n        //-------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return The resource type this provider can load\n        //-------------------------------------------------------\n        InterfaceIDType GetResourceType() const override;\n        //----------------------------------------------------------\n        /// Whether or not the provider can create resources from\n        /// files with the given extension.\n        ///\n        /// @author S Downie\n        ///\n        /// @param Extension to compare against\n        ///\n        /// @return Whether the object can load a resource with that\n        /// extension\n        //----------------------------------------------------------\n        bool CanCreateResourceWithFileExtension(const std::string& in_extension) const override;\n        //----------------------------------------------------------\n        /// Creates a new image resource from file. Check the\n        /// resource load state for success or failure\n        ///\n        /// @author S Downie\n        ///\n        /// @param The storage location to load from\n        /// @param File path to resource\n        /// @param Options to customise the creation\n        /// @param [Out] Resource\n        //-----------------------------------------------------------\n        void CreateResourceFromFile(StorageLocation in_storageLocation, const std::string& in_filePath, const IResourceOptionsBaseCSPtr& in_options, const ResourceSPtr& out_resource) override;\n        //----------------------------------------------------\n        /// Creates a new resource from file asynchronously.\n        /// Completion delegate is called when load is finished.\n        /// Check the resource load state for success or failure\n        ///\n        /// @author S Downie\n        ///\n        /// @param The storage location.\n        /// @param The filepath.\n        /// @param Options to customise the creation\n        /// @param Completion delegate\n        /// @param [Out] The output resource.\n        //----------------------------------------------------\n        void CreateResourceFromFileAsync(StorageLocation in_storageLocation, const std::string& in_filePath, const IResourceOptionsBaseCSPtr& in_options, const ResourceProvider::AsyncLoadDelegate& in_delegate, const ResourceSPtr& out_resource) override;\n    \n    private:\n        friend class Application;\n        //-------------------------------------------------------\n        /// Create the platform dependent backend\n        ///\n        /// @author S Downie\n        ///\n        /// @return New backend instance\n        //-------------------------------------------------------\n        static PVRImageProviderUPtr Create();\n        //-------------------------------------------------------\n        /// Private constructor to force use of factory method\n        ///\n        /// @author S Downie\n        //-------------------------------------------------------\n        PVRImageProvider() = default;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Image.h",
    "content": "//\n//  Image.h\n//  ChilliSource\n//  Created by Ian Copland on 07/07/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_IMAGE_H_\n#define _CHILLISOURCE_CORE_IMAGE_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Image/CSImageProvider.h>\n#include <ChilliSource/Core/Image/ETC1ImageProvider.h>\n#include <ChilliSource/Core/Image/Image.h>\n#include <ChilliSource/Core/Image/ImageCompression.h>\n#include <ChilliSource/Core/Image/ImageFormat.h>\n#include <ChilliSource/Core/Image/ImageFormatConverter.h>\n#include <ChilliSource/Core/Image/PNGImageProvider.h>\n#include <ChilliSource/Core/Image/PVRImageProvider.h>\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Json/JsonUtils.cpp",
    "content": "//\n//  JsonUtils.cpp\n//  ChilliSource\n//  Created by Ian Copland on 24/11/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Core/Json/JsonUtils.h>\n\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/File/FileSystem.h>\n\n\n#include <json/json.h>\n\nnamespace ChilliSource\n{\n    namespace JsonUtils\n    {\n        //---------------------------------------------------------------\n        //---------------------------------------------------------------\n        Json::Value ParseJson(const std::string& in_jsonString) noexcept\n        {\n            Json::Value output;\n            \n            Json::Reader jsonReader;\n            if (jsonReader.parse(in_jsonString, output) == false)\n            {\n                CS_LOG_FATAL(\"Could not parse json from string due to errors: \\n\" + jsonReader.getFormattedErrorMessages());\n            }\n            \n            if (output.isNull())\n            {\n                CS_LOG_FATAL(\"Could not parse json from string.\");\n            }\n            \n            return output;\n        }\n        //---------------------------------------------------------------\n        //---------------------------------------------------------------\n        bool ReadJson(StorageLocation in_storageLocation, const std::string& in_filePath, Json::Value& out_jsonValue) noexcept\n        {\n            auto fileStream = Application::Get()->GetFileSystem()->CreateTextInputStream(in_storageLocation, in_filePath);\n            \n            if (fileStream == nullptr)\n            {\n                CS_LOG_ERROR(\"Could not open json file: \" + in_filePath);\n                return false;\n            }\n            \n            std::string fileContents = fileStream->ReadAll();\n            fileStream.reset();\n            \n            Json::Reader jsonReader;\n            if (jsonReader.parse(fileContents, out_jsonValue) == false)\n            {\n                CS_LOG_FATAL(\"Could not parse json file '\" + in_filePath + \"' due to errors: \\n\" + jsonReader.getFormattedErrorMessages());\n            }\n            \n            if (out_jsonValue.isNull())\n            {\n                CS_LOG_FATAL(\"Could not parse json file: \" + in_filePath);\n            }\n            \n            return true;\n        }\n        \n        //---------------------------------------------------------------\n        bool WriteJson(StorageLocation storageLocation, const std::string& filePath, const Json::Value& jsonValue) noexcept\n        {\n            auto fileStream = Application::Get()->GetFileSystem()->CreateTextOutputStream(storageLocation, filePath);\n            \n            if (fileStream == nullptr || fileStream->IsValid() == false)\n            {\n                CS_LOG_ERROR(\"Could not open/create json file: \" + filePath);\n                return false;\n            }\n            \n            fileStream->Write(jsonValue.toStyledString());\n\n            return true;\n        }\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Core/Json/JsonUtils.h",
    "content": "//\n//  JsonUtils.h\n//  ChilliSource\n//  Created by Ian Copland on 24/11/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_JSON_JSONUTILS_H_\n#define _CHILLISOURCE_CORE_JSON_JSONUTILS_H_\n\n#include <ChilliSource/ChilliSource.h>\n\n#include <json/forwards.h>\n\nnamespace ChilliSource\n{\n    //----------------------------------------------------------------------\n    /// A collection of convenience methods for working with json. This\n    /// includes a method for creating a new Json object from a string\n    /// and for creating a new Json object from a file.\n    ///\n    /// @author Ian Copland\n    //----------------------------------------------------------------------\n    namespace JsonUtils\n    {\n        //---------------------------------------------------------------\n        /// Creates a new Json object from the given string. If there\n        /// are any errors in the given Json the app is considered to be\n        /// in an irrecoverable state and will terminate.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The input json string.\n        ///\n        /// @return The new json object.\n        //---------------------------------------------------------------\n        Json::Value ParseJson(const std::string& in_jsonString) noexcept;\n        //---------------------------------------------------------------\n        /// Creates a new Json object from the contents of the file\n        /// at the given path. If the file cannot be read this will return\n        /// false, but if the file can be read but it is not valid json\n        /// the app is considered to be in an irrecoverable state and\n        /// will terminate.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The storage location of the file.\n        /// @param The file path.\n        /// @param [OUT] Json object to populate with read data\n        ///\n        /// @return TRUE if successful\n        //---------------------------------------------------------------\n        bool ReadJson(StorageLocation in_storageLocation, const std::string& in_filePath, Json::Value& out_jsonValue) noexcept;\n        \n        /// Writes the given json object to a text file at the given location and path.\n        ///\n        /// @param storageLocation\n        ///     The location to write the file\n        /// @param filePath\n        ///     Path to the file relative to the location\n        /// @param jsonValue\n        ///     Json to output\n        ///\n        /// @return TRUE if successful\n        ///\n        bool WriteJson(StorageLocation storageLocation, const std::string& filePath, const Json::Value& jsonValue) noexcept;\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Json.h",
    "content": "//\n//  Json.h\n//  ChilliSource\n//  Created by Ian Copland on 24/11/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_JSON_H_\n#define _CHILLISOURCE_CORE_JSON_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Json/JsonUtils.h>\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Localisation/LocalisedText.cpp",
    "content": "//\n//  LocalisedText.cpp\n//  ChilliSource\n//  Created by Scott Downie on 07/12/2010.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2010 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Core/Localisation/LocalisedText.h>\n\n#include <ChilliSource/Core/String/StringUtils.h>\n\nnamespace ChilliSource\n{\n    CS_DEFINE_NAMEDTYPE(LocalisedText);\n\n    //---------------------------------------------------------------------\n    //---------------------------------------------------------------------\n    LocalisedTextUPtr LocalisedText::Create()\n    {\n        return LocalisedTextUPtr(new LocalisedText());\n    }\n    //---------------------------------------------------------------------\n    //---------------------------------------------------------------------\n    bool LocalisedText::IsA(InterfaceIDType in_interfaceId) const\n    {\n        return in_interfaceId == LocalisedText::InterfaceID;\n    }\n    //---------------------------------------------------------------------\n    //---------------------------------------------------------------------\n    void LocalisedText::Build(const std::unordered_map<std::string, std::string>& in_textMap)\n    {\n        m_text = in_textMap;\n    }\n    //---------------------------------------------------------------------\n    //---------------------------------------------------------------------\n    bool LocalisedText::Contains(const std::string& in_key) const\n    {\n        return (m_text.find(in_key) != m_text.end());\n    }\n    //---------------------------------------------------------------------\n    //---------------------------------------------------------------------\n    const std::string& LocalisedText::GetText(const std::string& in_key) const\n    {\n        auto it = m_text.find(in_key);\n\n        if (it != m_text.end())\n        {\n            return it->second;\n        }\n\n        CS_LOG_ERROR(\"No localised text for key: \" + in_key);\n        return StringUtils::BLANK;\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Core/Localisation/LocalisedText.h",
    "content": "//\n//  LocalisedText.h\n//  ChilliSource\n//  Created by Scott Downie on 07/12/2010.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2010 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_LOCALISATION_LOCALISEDTEXT_H_\n#define _CHILLISOURCE_CORE_LOCALISATION_LOCALISEDTEXT_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Resource/Resource.h>\n\n#include <unordered_map>\n\nnamespace ChilliSource\n{\n    //----------------------------------------------------------------------\n    /// Holds a resource loaded from the master text for a particular language.\n    /// The text comprises of Ids which act as the key and the text value.\n    ///\n    /// All localised text is in UTF-8 encoding format\n    ///\n    /// @author S Downie\n    //----------------------------------------------------------------------\n    class LocalisedText final : public Resource\n    {\n    public:\n        \n        CS_DECLARE_NAMEDTYPE(LocalisedText);\n\n        //---------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Interface Id\n        ///\n        /// @return Whether object is of given type\n        //---------------------------------------------------------------------\n        bool IsA(InterfaceIDType in_interfaceId) const override;\n        //---------------------------------------------------------------------\n        /// Populate the resource with the given keys and values\n        ///\n        /// @author S Downie\n        ///\n        /// @param A map containing the localised text. The text is in UTF-8\n        /// format.\n        //---------------------------------------------------------------------\n        void Build(const std::unordered_map<std::string, std::string>& in_textMap);\n        //---------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param The string key.\n        ///\n        /// @return Whether or not this has the given key.\n        //---------------------------------------------------------------------\n        bool Contains(const std::string& in_key) const;\n        //---------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param String key\n        ///\n        /// @return String containing UTF8 codepoints that maps to this key\n        //---------------------------------------------------------------------\n        const std::string& GetText(const std::string& in_key) const;\n\n    private:\n\n        friend class ResourcePool;\n        //---------------------------------------------------------------------\n        /// Factory method to create empty text resource. Only called\n        /// by the resource pool\n        ///\n        /// @author S Downie\n        ///\n        /// @return Ownership of resource\n        //---------------------------------------------------------------------\n        static LocalisedTextUPtr Create();\n        //---------------------------------------------------------------------\n        /// Private constructor to enforce use of factory create method\n        ///\n        /// @author S Downie\n        //---------------------------------------------------------------------\n        LocalisedText() = default;\n        \n    private:\n        \n        std::unordered_map<std::string, std::string> m_text;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Localisation/LocalisedTextProvider.cpp",
    "content": "//\n//  LocalisedTextProvider.cpp\n//  ChilliSource\n//  Created by Scott Downie on 25/04/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Core/Localisation/LocalisedTextProvider.h>\n\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/Base/Device.h>\n#include <ChilliSource/Core/Json/JsonUtils.h>\n#include <ChilliSource/Core/Threading/TaskScheduler.h>\n#include <ChilliSource/Core/Localisation/LocalisedText.h>\n\n#include <json/json.h>\n\nnamespace ChilliSource\n{\n    namespace\n    {\n        const u32 k_version = 1;\n        const std::string k_fileExtension(\"cstext\");\n        \n        //----------------------------------------------------\n        /// Performs the heavy lifting for the 2 create methods\n        /// by loading the keys and text files into a single resource\n        ///\n        /// @author S Downie\n        ///\n        /// @param The storage location.\n        /// @param The filepath.\n        /// @param Completion delegate\n        /// @param [Out] The output resource.\n        //----------------------------------------------------\n        void LoadResource(StorageLocation in_storageLocation, const std::string& in_filePath, const ResourceProvider::AsyncLoadDelegate& in_delegate, const ResourceSPtr& out_resource)\n        {\n            LocalisedText* textResource((LocalisedText*)out_resource.get());\n            \n            Json::Value jsonRoot;\n            if (JsonUtils::ReadJson(in_storageLocation, in_filePath, jsonRoot) == false)\n            {\n                CS_LOG_ERROR(\"Cannot read cstext file: \" + in_filePath);\n                textResource->SetLoadState(Resource::LoadState::k_failed);\n                if(in_delegate != nullptr)\n                {\n                    Application::Get()->GetTaskScheduler()->ScheduleTask(TaskType::k_mainThread, [=](const TaskContext&) noexcept\n                    {\n                        in_delegate(out_resource);\n                    });\n                }\n                return;\n            }\n            \n            \n            auto jsonVersion = jsonRoot.get(\"Version\", Json::nullValue);\n            auto jsonText = jsonRoot.get(\"Text\", Json::nullValue);\n            \n            if (jsonVersion.isNull() || jsonText.isNull())\n            {\n                CS_LOG_ERROR(\"Cannot read cstext file: \" + in_filePath);\n                textResource->SetLoadState(Resource::LoadState::k_failed);\n                if(in_delegate != nullptr)\n                {\n                    Application::Get()->GetTaskScheduler()->ScheduleTask(TaskType::k_mainThread, [=](const TaskContext&) noexcept\n                    {\n                        in_delegate(out_resource);\n                    });\n                }\n                return;\n            }\n            \n            if (jsonVersion.asInt() != k_version)\n            {\n                CS_LOG_ERROR(\"Invalid cstext file version: \" + in_filePath);\n                textResource->SetLoadState(Resource::LoadState::k_failed);\n                if(in_delegate != nullptr)\n                {\n                    Application::Get()->GetTaskScheduler()->ScheduleTask(TaskType::k_mainThread, [=](const TaskContext&) noexcept\n                    {\n                        in_delegate(out_resource);\n                    });\n                }\n                return;\n            }\n            \n            std::unordered_map<std::string, std::string> map;\n            for (const auto& member : jsonText.getMemberNames())\n            {\n                map.emplace(member, jsonText[member].asString());\n            }\n            \n            textResource->Build(map);\n            textResource->SetLoadState(Resource::LoadState::k_loaded);\n            \n            if(in_delegate != nullptr)\n            {\n                Application::Get()->GetTaskScheduler()->ScheduleTask(TaskType::k_mainThread, [=](const TaskContext&) noexcept\n                {\n                    in_delegate(out_resource);\n                });\n            }\n        }\n    }\n\n    CS_DEFINE_NAMEDTYPE(LocalisedTextProvider);\n\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    LocalisedTextProviderUPtr LocalisedTextProvider::Create()\n    {\n        return LocalisedTextProviderUPtr(new LocalisedTextProvider());\n    }\n    //----------------------------------------------------\n    //----------------------------------------------------\n    bool LocalisedTextProvider::IsA(InterfaceIDType in_interfaceId) const\n    {\n        return in_interfaceId == ResourceProvider::InterfaceID || in_interfaceId == LocalisedTextProvider::InterfaceID;\n    }\n    //----------------------------------------------------\n    //----------------------------------------------------\n    InterfaceIDType LocalisedTextProvider::GetResourceType() const\n    {\n        return LocalisedText::InterfaceID;\n    }\n    //----------------------------------------------------\n    //----------------------------------------------------\n    bool LocalisedTextProvider::CanCreateResourceWithFileExtension(const std::string& in_extension) const\n    {\n        return in_extension == k_fileExtension;\n    }\n    //----------------------------------------------------\n    //----------------------------------------------------\n    void LocalisedTextProvider::CreateResourceFromFile(StorageLocation in_storageLocation, const std::string& in_filePath, const IResourceOptionsBaseCSPtr& in_options, const ResourceSPtr& out_resource)\n    {\n        LoadResource(in_storageLocation, in_filePath, nullptr, out_resource);\n    }\n    //----------------------------------------------------\n    //----------------------------------------------------\n    void LocalisedTextProvider::CreateResourceFromFileAsync(StorageLocation in_storageLocation, const std::string& in_filePath, const IResourceOptionsBaseCSPtr& in_options, const AsyncLoadDelegate& in_delegate, const ResourceSPtr& out_resource)\n    {\n        Application::Get()->GetTaskScheduler()->ScheduleTask(TaskType::k_file, [=](const TaskContext&) noexcept\n        {\n            LoadResource(in_storageLocation, in_filePath, in_delegate, out_resource);\n        });\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Core/Localisation/LocalisedTextProvider.h",
    "content": "//\n//  LocalisedTextProvider.h\n//  ChilliSource\n//  Created by Scott Downie on 25/04/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_LOCALISATION_LOCALISEDTEXTPROVIDER_H_\n#define _CHILLISOURCE_CORE_LOCALISATION_LOCALISEDTEXTPROVIDER_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Resource/ResourceProvider.h>\n\nnamespace ChilliSource\n{\n    //---------------------------------------------------------------\n    /// Provider that loads localised text files and corresponding\n    /// keys based on the current device language. All text is\n    /// UTF8 encoded\n    ///\n    /// @author S Downie\n    //---------------------------------------------------------------\n    class LocalisedTextProvider final : public ResourceProvider \n    {\n    public:\n        \n        CS_DECLARE_NAMEDTYPE(LocalisedTextProvider);\n        \n        //----------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Interface Id\n        ///\n        /// @return Whether object is of given type\n        //----------------------------------------------------\n        bool IsA(InterfaceIDType in_interfaceId) const override;\n        //----------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return The resource type this provider can create\n        //----------------------------------------------------\n        InterfaceIDType GetResourceType() const override;\n        //----------------------------------------------------\n        /// Allows querying of the resource type this provider\n        /// can create.\n        ///\n        /// @author S Downie\n        ///\n        /// @param The extension of the resource file.\n        ///\n        /// @return Whether or not the resource can be created.\n        //----------------------------------------------------\n        bool CanCreateResourceWithFileExtension(const std::string& in_extension) const override;\n        //----------------------------------------------------\n        /// Creates a localised text resource from the given file.\n        /// Check the load state of the resource for\n        /// success or failure\n        ///\n        /// @author S Downie\n        ///\n        /// @param The storage location.\n        /// @param The filepath.\n        /// @param Options to customise the creation\n        /// @param Delegate to callback on completion either success or failure\n        /// @param [Out] The output resource.\n        //----------------------------------------------------\n        void CreateResourceFromFile(StorageLocation in_storageLocation, const std::string& in_filePath, const IResourceOptionsBaseCSPtr& in_options, const ResourceSPtr& out_resource) override;\n        //----------------------------------------------------\n        /// Creates a localised text resource asynchronously.\n        /// The delegate will be called on completion. Check\n        /// the load state for success or failure.\n        ///\n        /// @author S Downie\n        ///\n        /// @param The storage location.\n        /// @param The filepath.\n        /// @param Options to customise the creation\n        /// @param Completion delegate\n        /// @param [Out] The output resource.\n        //----------------------------------------------------\n        void CreateResourceFromFileAsync(StorageLocation in_storageLocation, const std::string& in_filePath, const IResourceOptionsBaseCSPtr& in_options, const AsyncLoadDelegate& in_delegate, const ResourceSPtr& out_resource) override;\n\n    private:\n\n        friend class Application;\n        //-------------------------------------------------------\n        /// Factory method\n        ///\n        /// @author S Downie\n        ///\n        /// @return New backend with ownership transferred\n        //-------------------------------------------------------\n        static LocalisedTextProviderUPtr Create();\n        //-------------------------------------------------------\n        /// Private constructor to force use of factory method\n        ///\n        /// @author S Downie\n        //-------------------------------------------------------\n        LocalisedTextProvider() = default;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Localisation.h",
    "content": "//\n//  Localisation.h\n//  ChilliSource\n//  Created by Ian Copland on 07/07/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_LOCALISATION_H_\n#define _CHILLISOURCE_CORE_LOCALISATION_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Localisation/LocalisedText.h>\n#include <ChilliSource/Core/Localisation/LocalisedTextProvider.h>\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Math/Geometry/Curves.h",
    "content": "//\n//  Curves.h\n//  ChilliSource\n//  Created by Stuart McGaw on 17/11/2010.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2010 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_MATH_CURVES_H_\n#define _CHILLISOURCE_CORE_MATH_CURVES_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Math/MathUtils.h>\n\n#include <vector>\n\nnamespace ChilliSource\n{\n    template <typename T> class CatmullRomSpline {\n    public:\n        CatmullRomSpline()\n        {\n            mbLengthCacheValid = false;\n            mfDeltaT = 0;\n        }\n        CatmullRomSpline(const std::vector<T> & inPoints)\n        : mPoints(inPoints)\n        {\n            mbLengthCacheValid = false;\n            mfDeltaT = 1.0f/mPoints.size();\n\n        }\n        \n        void AddPoint(const T & inPoint) {\n            mbLengthCacheValid = false;\n            mPoints.push_back(inPoint);\n            mfDeltaT = 1.0f/ (mPoints.size() - 1);\n        }\n        T GetInterpolatedPointAt(f32 infValue) const{\n            // Find out in which interval we are on the spline\n            int p = (int)(infValue / mfDeltaT);\n            // Compute local control point indices\n            #define BOUNDS(pp) { if (pp < 0) pp = 0; else if (pp >= (int)mPoints.Size()) pp = mPoints.Size() - 1; }\n            int p0 = p - 1;     BOUNDS(p0);\n            int p1 = p;         BOUNDS(p1);\n            int p2 = p + 1;     BOUNDS(p2);\n            int p3 = p + 2;     BOUNDS(p3);\n            // Relative (local) time \n            float lt = (infValue - mfDeltaT*(f32)p) / mfDeltaT;\n            // Interpolate\n            return Equation(lt, mPoints[p0], mPoints[p1], mPoints[p2], mPoints[p3]);\n        }\n        T GetTangentAtPoint(f32 infValue)\n        {\n            return (GetInterpolatedPointAt(infValue + mfSmallTDelta) - GetInterpolatedPointAt(infValue - mfSmallTDelta)).NormalisedCopy();\n        }\n        \n        //Returns the parametric \t\t\t\n        f32 GetLength() const {\n            if (!mbLengthCacheValid) {\n                CalculateLength();\n            }\n            return mfCachedLength;\n        }\n        u32 GetNumPoints(){\n            return mPoints.size();\n        }\n        T & GetPointAtIndex(u32 inIndex){\n            mbLengthCacheValid = false;\n            return mPoints[inIndex];\t\t\t\t\n        }\n        const T & GetPointAtIndex(u32 inIndex) const {\n            return mPoints[inIndex];\n        }\n        static T Equation(f32 t, const T& p1, const T& p2, const T& p3, const T& p4)\n        {\n            f32 t2 = t * t;\n            f32 t3 = t2 * t;\n            \n            f32 b1 = .5f * (     -t3 + 2.0f*t2 - t   );\n            f32 b2 = .5f * ( 3.0f*t3 - 5.0f*t2 + 2.0f);\n            f32 b3 = .5f * (-3.0f*t3 + 4.0f*t2 + t   );\n            f32 b4 = .5f * (      t3 -      t2       );\n            \n            return T(p1*b1 + p2*b2 + p3*b3 + p4*b4); \n        }\n        \n        f32 GetParametricValueForDistance(f32 infS)\n        {\n            \n            GetLength();\n            \n            u32 nMaxIndex = 0;\n            u32 NumCachedValues = mfCachedDists.size();\n            \n            while (nMaxIndex < NumCachedValues  &&  mfCachedDists[nMaxIndex] < infS) {\n                nMaxIndex++;\n            }\n            \n            u32 nMinIndex = 0;\n            \n            if (nMaxIndex != 0) {\n                nMinIndex = nMaxIndex - 1;\n            }\n            \n            f32 fInterpAmount = (infS - mfCachedDists[nMinIndex])/(mfCachedDists[nMaxIndex]-mfCachedDists[nMinIndex]);\n            fInterpAmount = MathUtils::Clamp(fInterpAmount, 0.0f,1.0f);\n            \n            f32 fResult = mfCachedParamDists[nMinIndex] + fInterpAmount * (mfCachedParamDists[nMaxIndex] - mfCachedParamDists[nMinIndex]);\n                            \n            return fResult;\n        }\n        f32 GetDistanceForParametricValue(f32 infT)\n        {\n            \n            GetLength();\n            \n            u32 nMaxIndex = 0;\n            u32 NumCachedValues = mfCachedParamDists.size();\n            \n            while (nMaxIndex < NumCachedValues  &&  mfCachedParamDists[nMaxIndex] < infT) {\n                nMaxIndex++;\n            }\n            \n            u32 nMinIndex = 0;\n            \n            if (nMaxIndex != 0) {\n                nMinIndex = nMaxIndex - 1;\n            }\n            \n            f32 fInterpAmount = (infT - mfCachedParamDists[nMinIndex])/(mfCachedParamDists[nMaxIndex]-mfCachedParamDists[nMinIndex]);\n            fInterpAmount = MathUtils::Clamp(fInterpAmount, 0.0f,1.0f);\n            \n            f32 fResult = mfCachedDists[nMinIndex] + fInterpAmount * (mfCachedDists[nMaxIndex] - mfCachedDists[nMinIndex]);\n                            \n            return fResult;\n        }\n    protected:\n        void CalculateLength() const\n        {\n            mbLengthCacheValid = true;\n            mfCachedLength = 0;\n            \n            const u32 nSamples = (mPoints.size() - 1) * wLengthSamplesPerSegment;\n            const f32 fTStep = 1.0f / nSamples;\n            \n            mfCachedParamDists.reserve(nSamples + 1);\n            mfCachedDists.reserve(nSamples + 1);\n\n            mfCachedParamDists.clear();\n            mfCachedDists.clear();\n            \n            mfCachedParamDists.push_back(0);\n            mfCachedDists.push_back(0);\n            \n            T LastPoint = GetInterpolatedPointAt(0);\n            \n            for (f32 fSample = fTStep; fSample < 1.01f; fSample+=fTStep) {\t\n                T CurrentPoint = GetInterpolatedPointAt(fSample);\n                mfCachedLength+=(LastPoint-CurrentPoint).Length();\n                LastPoint = CurrentPoint;\n                \n                mfCachedParamDists.push_back(fSample);\n                mfCachedDists.push_back(mfCachedLength);\n            }\n        }\n    protected:\n        static const u16 wLengthSamplesPerSegment;\n        static const float mfSmallTDelta;\n\n        \n        mutable bool mbLengthCacheValid;\n        mutable f32 mfCachedLength;\n        mutable std::vector<f32> mfCachedParamDists; //Cached values \n        mutable std::vector<f32> mfCachedDists; //\n        \n        f32 mfDeltaT;\n        std::vector<T> mPoints;\n    };\n    template<typename T> const u16 CatmullRomSpline<T>::wLengthSamplesPerSegment = 259;\n    template<typename T> const float CatmullRomSpline<T>::mfSmallTDelta = 0.005f;\n    \n    template <typename T> class MultiLineSegment {\n    public:\n        MultiLineSegment()\n        {\n            mbLengthCacheValid = false;\n        }\n        MultiLineSegment(const std::vector<T> & inPoints)\n        : mPoints(inPoints)\n        {\n            mbLengthCacheValid = false;\n            \n        }\n        \n        void AddPoint(const T & inPoint) {\n            mbLengthCacheValid = false;\n            mPoints.push_back(inPoint);\n        }\n        T GetInterpolatedPointAt(f32 infValue) const{\n            \n        }\n        T GetTangentAtPoint(f32 infValue)\n        {\n            \n        }\n        \n        //Returns the parametric \t\t\t\n        f32 GetLength() const {\n            if (!mbLengthCacheValid) {\n                CalculateLength();\n            }\n            return mfCachedLength;\n        }\n        u32 GetNumPoints(){\n            return mPoints.size();\n        }\n        T & GetPointAtIndex(u32 inIndex){\n            mbLengthCacheValid = false;\n            return mPoints[inIndex];\t\t\t\t\n        }\n        const T & GetPointAtIndex(u32 inIndex) const {\n            return mPoints[inIndex];\n        }\n        f32 GetParametricValueForDistance(f32 infS)\n        {\n            \n            return GetLength();\n            \n        }\n        f32 GetDistanceForParametricValue(f32 infT)\n        {\n            \n            return GetLength();\n            \n        }\n    protected:\n        void CalculateLength() const\n        {\n            mbLengthCacheValid = true;\n            mfCachedLength = 0;\n            mfCachedParamDists.clear();\n            mfCachedDists.clear();\n            \n            if (mPoints.size() < 2) {\n                return;\n            }\n            \n            for (u32 nLineSegment = 0; nLineSegment < (mPoints.size() - 1); nLineSegment++) {\n                f32 fLineLength = (mPoints[nLineSegment] - mPoints[nLineSegment]).Length();\n                mfCachedLength += fLineLength;\n                mfCachedDists.push_back(fLineLength);\n            }\n            \n\n            \n        }\n    protected:\t\t\t\n        \n        mutable bool mbLengthCacheValid;\n        mutable f32 mfCachedLength;\n        mutable std::vector<f32> mfCachedParamDists; //Cached values \n        mutable std::vector<f32> mfCachedDists; //\n        \n        std::vector<T> mPoints;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Math/Geometry/ShapeIntersection.cpp",
    "content": "//\n//  ShapeIntersection.cpp\n//  ChilliSource\n//  Created by Scott Downie on 03/11/2010.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2010 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Core/Math/Geometry/ShapeIntersection.h>\n#include <ChilliSource/Core/Math/Geometry/Shapes.h>\n#include <ChilliSource/Core/Math/MathUtils.h>\n\nnamespace ChilliSource\n{\n    namespace ShapeIntersection\n    {\n        //----------------------------------------------------------------\n        /// AABB vs Ray\n        //----------------------------------------------------------------\n        bool Intersects(const AABB& inAABB, const Ray& inRay, f32 &outfT1, f32 &outfT2)\n        {\n            //Using the slab intersection method we check for intersection\n            //against the 3 planes (slabs). If the ray fails itersection with any\n            //slab then it does not intersect the box\n            f32 t2 = std::numeric_limits<f32>::infinity();\n            f32 t1 = -t2;\n            \n            Vector3 vRayOrigin = inRay.vOrigin;\n            Vector3 vRayDir = inRay.vDirection * inRay.fLength;\n            \n            Vector3 vAABBMin = inAABB.GetMin();\n            Vector3 vAABBMax = inAABB.GetMax();\n            \n            //----X Slab \n            if(!RaySlabIntersect(vRayOrigin.x, vRayDir.x, vAABBMin.x, vAABBMax.x, t1, t2)) return false;\n            \n            //----Y Slab \n            if(!RaySlabIntersect(vRayOrigin.y, vRayDir.y, vAABBMin.y, vAABBMax.y, t1, t2)) return false;\n            \n            //----Z Slab \n            if(!RaySlabIntersect(vRayOrigin.z, vRayDir.z, vAABBMin.z, vAABBMax.z, t1, t2)) return false;\n  \n            //We haven't failed intersection against any slab therefore we must have hit\n            //t1 and t2 will give us our entry and exit point on the parametric ray\n            outfT1 = t1;\n            outfT2 = t2;\n            \n            return true; \n        }\n        //----------------------------------------------------------------\n        /// AABB vs Point\n        //----------------------------------------------------------------\n        bool Intersects(const AABB& inAABB, const Vector3& invPoint)\n        {\n            Vector3 vOrigin = inAABB.GetOrigin();\n            Vector3 vHalfSize = inAABB.GetHalfSize();\n            \n            return\t(invPoint.x >= (vOrigin.x - vHalfSize.x)) && (invPoint.x <= (vOrigin.x + vHalfSize.x)) &&\n                    (invPoint.y >= (vOrigin.y - vHalfSize.y)) && (invPoint.y <= (vOrigin.y + vHalfSize.y)) &&\n                    (invPoint.z >= (vOrigin.z - vHalfSize.z)) && (invPoint.z <= (vOrigin.z + vHalfSize.z));\n        }\n        //----------------------------------------------------------------\n        /// AABB vs AABB\n        //----------------------------------------------------------------\n        bool Intersects(const AABB& inAABBLHS, const AABB& inAABBRHS)\n        {\n            return\t(inAABBLHS.GetMax().x > inAABBRHS.GetMin().x && inAABBLHS.GetMin().x < inAABBRHS.GetMax().x) &&\n                    (inAABBLHS.GetMax().y > inAABBRHS.GetMin().y && inAABBLHS.GetMin().y < inAABBRHS.GetMax().y) &&\n                    (inAABBLHS.GetMax().z > inAABBRHS.GetMin().z && inAABBLHS.GetMin().z < inAABBRHS.GetMax().z);\n        }\n        //----------------------------------------------------------------\n        /// Sphere vs Ray\n        //----------------------------------------------------------------\n        bool Intersects(const Sphere& inSphere, const Ray& inRay)\n        {\n            Vector3 vDelta = inRay.vOrigin - inSphere.vOrigin;\n            f32 A = Vector3::DotProduct(inRay.vDirection, inRay.vDirection);\n            f32 B = 2.0f * Vector3::DotProduct(vDelta, inRay.vDirection);\n            f32 C = Vector3::DotProduct(vDelta, vDelta)-inSphere.fRadius * inSphere.fRadius;\n            f32 D = B * B - 4.0f * A * C;\n            return (D >= 0.0f); //returning true if equation has real roots.\n        }\n        //----------------------------------------------------------------\n        /// Sphere vs Point\n        //----------------------------------------------------------------\n        bool Intersects(const Sphere& inSphere, const Vector3& invPoint)\n        {\n            return (inSphere.vOrigin - invPoint).LengthSquared() <= (inSphere.fRadius * inSphere.fRadius);\n        }\n        //----------------------------------------------------------------\n        /// Sphere vs Plane\n        //----------------------------------------------------------------\n        ShapeIntersection::Result Intersects(const Sphere& inSphere, const Plane& inPlane)\n        {\n            f32 fDist = Vector3::DotProduct(inSphere.vOrigin, inPlane.mvNormal) + inPlane.mfD;\n            \n            if(fDist < -inSphere.fRadius)\n                return Result::k_outside;\n            \n            if(std::fabs(fDist) < inSphere.fRadius)\n                return Result::k_intersect;\n            \n            return Result::k_inside;\n        }\n        //----------------------------------------------------------------\n        /// Sphere vs Sphere\n        //----------------------------------------------------------------\n        bool Intersects(const Sphere& inSphereLHS, const Sphere& inSphereRHS)\n        {\n            f32 fSigmaRadius = inSphereLHS.fRadius + inSphereRHS.fRadius;\n            \n            return\tfabsf(inSphereLHS.vOrigin.x - inSphereRHS.vOrigin.x) < (fSigmaRadius) &&\n                    fabsf(inSphereLHS.vOrigin.y - inSphereRHS.vOrigin.y) < (fSigmaRadius) &&\n                    fabsf(inSphereLHS.vOrigin.z - inSphereRHS.vOrigin.z) < (fSigmaRadius);\n        }\n        //----------------------------------------------------------------\n        /// Circle vs Circle\n        //----------------------------------------------------------------\n        bool Intersects(const Circle& inCircleLHS, const Circle& inCircleRHS)\n        {\n            f32 fSigmaRadius = inCircleLHS.fRadius + inCircleRHS.fRadius;\n            \n            return\tfabsf(inCircleLHS.vOrigin.x - inCircleRHS.vOrigin.x) < (fSigmaRadius) &&\n                    fabsf(inCircleLHS.vOrigin.y - inCircleRHS.vOrigin.y) < (fSigmaRadius);\n        }\n        //----------------------------------------------------------------\n        /// Circle vs Point\n        //----------------------------------------------------------------\n        bool Intersects(const Circle& inCircle, const Vector2& invPoint)\n        {\n            return (inCircle.vOrigin - invPoint).LengthSquared() <= (inCircle.fRadius * inCircle.fRadius);\n        }\n        //----------------------------------------------------------------\n        /// Rect vs Rect\n        //----------------------------------------------------------------\n        bool Intersects(const Rectangle& inRectLHS, const Rectangle& inRectRHS)\n        {\n            Vector2 vMinLS(inRectLHS.BottomLeft());\n            Vector2 vMaxLS(inRectLHS.TopRight());\n            \n            Vector2 vMinRS(inRectRHS.BottomLeft());\n            Vector2 vMaxRS(inRectRHS.TopRight());\n            \n            return\t(vMaxLS.x > vMinRS.x && vMinLS.x < vMaxRS.x) &&\n                    (vMaxLS.y > vMinRS.y && vMinLS.y < vMaxRS.y);\n        }\n        //----------------------------------------------------------------\n        /// Rect vs Point\n        //----------------------------------------------------------------\n        bool Intersects(const Rectangle& inRect, const Vector2& invPoint)\n        {\n            Vector2 bottLeft = inRect.BottomLeft();\n            Vector2 topRight = inRect.TopRight();\n            \n            return invPoint.x >= bottLeft.x && invPoint.y >= bottLeft.y && invPoint.x <= topRight.x && invPoint.y <= topRight.y;\n        }\n        //----------------------------------------------------------------\n        /// Plane vs Plane\n        //----------------------------------------------------------------\n        bool Intersects(const Plane& inPlaneLHS, const Plane& inPlaneRHS, Ray& outIntersection)\n        {\n            outIntersection.vDirection= Vector3::CrossProduct(inPlaneLHS.mvNormal, inPlaneRHS.mvNormal);\n            \n            f32 fDenom = Vector3::DotProduct(outIntersection.vDirection, outIntersection.vDirection);\n            \n            if(fDenom < std::numeric_limits<f32>::epsilon())\n            {\n                return false;\n            }\n            \n            Vector3 v1(inPlaneLHS.mfD * inPlaneRHS.mvNormal);\n            Vector3 v2(inPlaneRHS.mfD * inPlaneLHS.mvNormal);\n            Vector3 vDelta = v1 - v2;\n            outIntersection.vOrigin = Vector3::CrossProduct(vDelta, outIntersection.vDirection);\n            outIntersection.vOrigin /= fDenom;\n            outIntersection.vDirection.Normalise();\n            \n            return true;\n        }\n        //----------------------------------------------------------------\n        /// Line vs Line\n        //----------------------------------------------------------------\n        bool Intersects(const Line& inLineLHS, const Line& inLineRHS, Vector3& outvIntersection)\n        {\n            //Due to floating point errors we will compute the smallest distance between the two lines\n            //and if this is less than epsilon we will consider that an intersection. We will then pick one of the closest\n            //points to return as the intersection point.\n            \n            //The following is taken from the Orange Physics Book - \"Realtime Collision Detection\" by Christer Ericson. p. 149\n            \n            Vector3 vAB = inLineLHS.vEndPos - inLineLHS.vStartPos;\n            Vector3 vCD = inLineRHS.vEndPos - inLineRHS.vStartPos;\n            Vector3 vAC = inLineLHS.vStartPos - inLineRHS.vStartPos;\n            \n            f32 fA = Vector3::DotProduct(vAB, vAB);\n            f32 fE = Vector3::DotProduct(vCD, vCD);\n            f32 fF = Vector3::DotProduct(vCD, vAC);\n            f32 fS = 0.0f;\n            f32 fT = 0.0f;\n            \n            Vector3 vIntersection1, vIntersection2;\n            \n            if(fabsf(fA) <= std::numeric_limits<f32>::epsilon() && fabsf(fE) <= std::numeric_limits<f32>::epsilon())\n            {\n                vIntersection1 = inLineLHS.vStartPos;\n                vIntersection2 = inLineRHS.vStartPos;\n                \n                Vector3 vDir = vIntersection1 - vIntersection2;\n                return (fabsf(Vector3::DotProduct(vDir, vDir)) <= std::numeric_limits<f32>::epsilon());\n            }\n            \n            if(fA <= std::numeric_limits<f32>::epsilon())\n            {\n                fS = 0.0f;\n                fT = MathUtils::Clamp(fF/fE, 0.0f, 1.0f);\n            }\n            else\n            {\n                f32 fC = Vector3::DotProduct(vAB, vAC);\n                if(fabsf(fE) <= std::numeric_limits<f32>::epsilon())\n                {\n                    fT = 0.0f;\n                    fS = MathUtils::Clamp(-fC/fA, 0.0f, 1.0f);\n                }\n                else\n                {\n                    f32 fB = Vector3::DotProduct(vAB, vCD);\n                    f32 fDenom = fA*fE - fB*fB;\n                    if(fDenom != 0.0f)\n                    {\n                        fS = MathUtils::Clamp((fB*fF - fC*fE)/fDenom, 0.0f, 1.0f);\n                    }\n                    else\n                    {\n                        fS = 0.0f;\n                    }\n                    \n                    fT = (fB*fS + fF)/fE;\n                    \n                    if(fT < 0.0f)\n                    {\n                        fT = 0.0f;\n                        fS = MathUtils::Clamp(-fC/fA, 0.0f, 1.0f);\n                    }\n                    else if(fT > 1.0f)\n                    {\n                        fT = 1.0f;\n                        fS = MathUtils::Clamp((fB - fC)/fA, 0.0f, 1.0f);\n                    }\n                }\n            }\n            \n            vIntersection1 = inLineLHS.vStartPos + vAB * fS;\n            vIntersection2 = inLineRHS.vStartPos + vCD * fT;\n            \n            //Pick the first one as the point of intersection\n            outvIntersection = vIntersection1;\n            \n            Vector3 vDir = vIntersection1 - vIntersection2;\n            return (fabsf(Vector3::DotProduct(vDir, vDir)) <= std::numeric_limits<f32>::epsilon());\n        }\n        //----------------------------------------------------------------\n        /// Ray vs Slab\n        //----------------------------------------------------------------\n        bool RaySlabIntersect(f32 infStart, f32 infDir, f32 infMin, f32 infMax, f32& outfFirstT, f32& outfLastT)\n        {\n            if(infDir == 0.0f)\n            {\n                //The ray direction is parallel to the slab therfore will only collide if it starts within\n                //Check if the ray begins inside the slab\n                return (infStart < infMax && infStart > infMin);\n            }\n            \n            //Work out the near and far intersection planes of the slab\n            f32 fTMin = (infMin - infStart) / infDir;\n            f32 fTMax = (infMax - infStart) / infDir;\n            \n            //TMin should be intersection with the near plane\n            if(fTMin > fTMax) \n            {\n                std::swap(fTMin, fTMax);\n            }\n            \n            //Calculate the entry and exit point\n            outfFirstT = std::max(fTMin, outfFirstT);\n            outfLastT = std::min(fTMax, outfLastT);\n            \n            if(outfFirstT > outfLastT || outfLastT < 0.0f)\n            {\n                //We have missed the slab\n                return false;\n            }\n\n            return true;\n        }\n        //----------------------------------------------------------------\n        /// Ray vs Plane\n        //----------------------------------------------------------------\n        bool Intersects(const Ray& inRay, const Plane& inPlane, Vector3& outvIntersection)\n        {\n            \n            f32 denom = Vector3::DotProduct(inPlane.mvNormal, inRay.vDirection);\n            \n            \n            if (fabsf(denom) < std::numeric_limits<f32>::epsilon())\n            {\n                // Parallel\n                return false;\n            }\n            else\n            {\n                f32 nom = Vector3::DotProduct(inPlane.mvNormal, inRay.vOrigin) + inPlane.mfD;\n                f32 t = -(nom/denom);\n                \n                if (t >= 0)\n                {\n                    outvIntersection = inRay.vOrigin + inRay.vDirection * t;\n                    \n                    return true;\n                }\n                else\n                    return false;\n            }\n            \n            return false;\n        }\n    }\n}\n\n"
  },
  {
    "path": "Source/ChilliSource/Core/Math/Geometry/ShapeIntersection.h",
    "content": "//\n//  ShapeIntersection.h\n//  ChilliSource\n//  Created by Scott Downie on 03/11/2010.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2010 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_MATH_SHAPE_INTERSECTION_H_\n#define _CHILLISOURCE_CORE_MATH_SHAPE_INTERSECTION_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Math/Geometry/Shapes.h>\n\nnamespace ChilliSource\n{\n    namespace ShapeIntersection\n    {\n        enum class Result\n        {\n            k_outside,\n            k_inside,\n            k_intersect\n        };\n        \n        //----------------------------------------------------------------\n        /// AABB vs Ray\n        //----------------------------------------------------------------\n        bool Intersects(const AABB& inAABB, const Ray& inRay, f32 &outfT1, f32 &outfT2);\n        //----------------------------------------------------------------\n        /// AABB vs Point\n        //----------------------------------------------------------------\n        bool Intersects(const AABB& inAABB, const Vector3& invPoint);\n        //----------------------------------------------------------------\n        /// AABB vs AABB\n        //----------------------------------------------------------------\n        bool Intersects(const AABB& inAABBLHS, const AABB& inAABBRHS);\n        //----------------------------------------------------------------\n        /// Sphere vs Ray\n        //----------------------------------------------------------------\n        bool Intersects(const Sphere& inSphere, const Ray& inRay);\n        //----------------------------------------------------------------\n        /// Sphere vs Point\n        //----------------------------------------------------------------\n        bool Intersects(const Sphere& inSphere, const Vector3& invPoint);\n        //----------------------------------------------------------------\n        /// Sphere vs Sphere\n        //----------------------------------------------------------------\n        bool Intersects(const Sphere& inSphereLHS, const Sphere& inSphereRHS);\n        //----------------------------------------------------------------\n        /// Sphere vs Plane\n        //----------------------------------------------------------------\n        Result Intersects(const Sphere& inSphere, const Plane& inPlane);\n        //----------------------------------------------------------------\n        /// Plane vs Plane\n        //----------------------------------------------------------------\n        bool Intersects(const Plane& inPlaneLHS, const Plane& inPlaneRHS, Ray& outIntersection);\n        //----------------------------------------------------------------\n        /// Circle vs Circle\n        //----------------------------------------------------------------\n        bool Intersects(const Circle& inCircleLHS, const Circle& inCircleRHS);\n        //----------------------------------------------------------------\n        /// Circle vs Point\n        //----------------------------------------------------------------\n        bool Intersects(const Circle& inCircle, const Vector2& invPoint);\n        //----------------------------------------------------------------\n        /// Line vs Line\n        //----------------------------------------------------------------\n        bool Intersects(const Line& inLineLHS, const Line& inLineRHS, Vector3& outvIntersection);\n        //----------------------------------------------------------------\n        /// Rect vs Rect\n        //----------------------------------------------------------------\n        bool Intersects(const Rectangle& inRectLHS, const Rectangle& inRectRHS);\n        //----------------------------------------------------------------\n        /// Rect vs Point\n        //----------------------------------------------------------------\n        bool Intersects(const Rectangle& inRect, const Vector2& invPoint);\n        //----------------------------------------------------------------\n        /// Ray vs Plane\n        //----------------------------------------------------------------\n        bool Intersects(const Ray& inRay, const Plane& inPlane, Vector3& outvIntersection);\n        //----------------------------------------------------------------\n        /// Ray vs Slab\n        //----------------------------------------------------------------\n        bool RaySlabIntersect(f32 infStart, f32 infDir, f32 infMin, f32 infMax, f32& outfFirstT, f32& outfLastT);\n    };\n}\n\n#endif\n\n"
  },
  {
    "path": "Source/ChilliSource/Core/Math/Geometry/Shapes.cpp",
    "content": "//\n//  Shapes.cpp\n//  ChilliSource\n//  Created by Scott Downie on 21/10/2010.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2010 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Core/Math/Geometry/Shapes.h>\n#include <ChilliSource/Core/Math/Geometry/ShapeIntersection.h>\n\n#include <limits>\n#include <algorithm>\n\nnamespace ChilliSource\n{\n    //================================================\n    //================================================\n    Rectangle::Rectangle(const Vector2 &invOrigin, const Vector2 &invSize)\n    : vOrigin(invOrigin), vSize(invSize)\n    {\n    }\n    //-----------------------------------------------\n    //-----------------------------------------------\n    Rectangle::Rectangle(f32 in_left, f32 in_top, f32 in_right, f32 in_bottom)\n    {\n        CS_ASSERT(in_right >= in_left && in_top >= in_bottom, \"Cannot create inverted rect\");\n        \n        vSize.x = in_right - in_left;\n        vSize.y = in_top - in_bottom;\n        \n        vOrigin.x = in_left + (vSize.x * 0.5f);\n        vOrigin.y = in_bottom + (vSize.y * 0.5f);\n    }\n    //-----------------------------------------------\n    /// Left\n    ///\n    /// @return Left side of rectangle\n    //-----------------------------------------------\n    f32 Rectangle::Left() const\n    {\n        return vOrigin.x - (vSize.x * 0.5f);\n    }\n    //-----------------------------------------------\n    /// Right\n    ///\n    /// @return Right side of rectangle\n    //-----------------------------------------------\n    f32 Rectangle::Right() const\n    {\n        return vOrigin.x + (vSize.x * 0.5f);\n    }\n    //-----------------------------------------------\n    /// Top\n    ///\n    /// @return Top side of rectangle\n    //-----------------------------------------------\n    f32 Rectangle::Top() const\n    {\n        return vOrigin.y + (vSize.y * 0.5f);\n    }\n    //-----------------------------------------------\n    /// Bottom\n    ///\n    /// @return Bottom side of rectangle\n    //-----------------------------------------------\n    f32 Rectangle::Bottom() const\n    {\n        return vOrigin.y - (vSize.y * 0.5f);\n    }\n    //-----------------------------------------------\n    /// Top Left\n    ///\n    /// @return Top left co-ordinate\n    //-----------------------------------------------\n    Vector2 Rectangle::TopLeft() const\n    {\n        return Vector2(Left(), Top());\n    }\n    //-----------------------------------------------\n    /// Top Right\n    ///\n    /// @return Top right co-ordinate\n    //-----------------------------------------------\n    Vector2 Rectangle::TopRight() const\n    {\n        return Vector2(Right(), Top());\n    }\n    //-----------------------------------------------\n    /// Bottom Left\n    ///\n    /// @return Bottom left co-ordinate\n    //-----------------------------------------------\n    Vector2 Rectangle::BottomLeft() const\n    {\n        return Vector2(Left(), Bottom());\n    }\n    //-----------------------------------------------\n    /// Bottom Right\n    ///\n    /// @return Bottom right co-ordinate\n    //-----------------------------------------------\n    Vector2 Rectangle::BottomRight() const\n    {\n        return Vector2(Right(), Bottom());\n    }\n    //-----------------------------------------------\n    /// Centre\n    ///\n    /// @return Centre point\n    //-----------------------------------------------\n    Vector2 Rectangle::Centre() const\n    {\n        return vOrigin;\n    }\n    //-----------------------------------------------\n    /// Contains (Point)\n    ///\n    /// @param Point in 2D space\n    /// @return Whether point intersects the rect\n    //-----------------------------------------------\n    bool Rectangle::Contains(const Vector2& invPoint) const\n    {\n        return ShapeIntersection::Intersects(*this, invPoint);\n    }\n    //-----------------------------------------------\n    /// Contains (Rect)\n    ///\n    /// @param Rect in 2D space\n    /// @return Whether rect intersects the rect\n    //-----------------------------------------------\n    bool Rectangle::Contains(const Rectangle& inRect) const\n    {\n        return ShapeIntersection::Intersects(*this, inRect);\n    }\n    //================================================\n    /// Circle\n    ///\n    /// Container for a circle with it's origin \n    /// at centre\n    //================================================\n    Circle::Circle(const Vector2 &invOrigin, const f32 infRadius) : vOrigin(invOrigin), fRadius(infRadius)\n    {\n    }\n    //-----------------------------------------------\n    /// Contains (Point)\n    ///\n    /// @param Point in 2D space\n    /// @return Whether point intersects the circle\n    //-----------------------------------------------\n    bool Circle::Contains(const Vector2 & invPoint) const\n    {\n        return ShapeIntersection::Intersects(*this, invPoint);\n    }\n    //-----------------------------------------------\n    /// Contains (Circle)\n    ///\n    /// @param Circle in 2D space\n    /// @return Whether circle intersects the circle\n    //-----------------------------------------------\n    bool Circle::Contains(const Circle & inCircle) const\n    {\n        return ShapeIntersection::Intersects(*this, inCircle);\n    }\n    //================================================\n    /// Sphere\n    ///\n    /// Container for a sphere with it's origin \n    /// at centre\n    //================================================\n    //-----------------------------------------------\n    //-----------------------------------------------\n    Sphere Sphere::Transform(const Sphere& sphere, const Vector3& translation, const Quaternion& orientation, const Vector3& scale) noexcept\n    {\n        f32 maxScaleComponent = std::max(std::max(scale.x, scale.y), scale.z);\n        \n        auto centre = Vector3::Rotate(translation + sphere.vOrigin * maxScaleComponent, orientation);\n        auto radius = maxScaleComponent * sphere.fRadius;\n        \n        return Sphere(centre, radius);\n    }\n    //-----------------------------------------------\n    //-----------------------------------------------\n    Sphere::Sphere(const Vector3 &invOrigin, const f32 infRadius) : vOrigin(invOrigin), fRadius(infRadius)\n    {\n    }\n    //-----------------------------------------------\n    /// Contains (Point)\n    ///\n    /// @param Point in 3D space\n    /// @return Whether point intersects the sphere\n    //-----------------------------------------------\n    bool Sphere::Contains(const Vector3 & invPoint) const\n    {\n        return ShapeIntersection::Intersects(*this, invPoint);\n    }\n    //-----------------------------------------------\n    /// Contains (Sphere)\n    ///\n    /// @param Sphere in 3D space\n    /// @return Whether sphere intersects the sphere\n    //-----------------------------------------------\n    bool Sphere::Contains(const Sphere & inSphere) const\n    {\n        return ShapeIntersection::Intersects(*this, inSphere);\n    }\n    //-----------------------------------------------\n    /// Contains (Ray)\n    ///\n    /// @param Ray in 3D space\n    /// @return Whether point intersects the sphere\n    //-----------------------------------------------\n    bool Sphere::Contains(const Ray &inRay) const\n    {\n        return ShapeIntersection::Intersects(*this, inRay);\n    }\n    //================================================\n    /// AABB\n    ///\n    /// Container for a axis-aligned bounding box \n    /// with it's origin at centre\n    //================================================\n    AABB::AABB(const Vector3 &invOrigin, const Vector3 &invSize) : mvOrigin(invOrigin), mvSize(invSize), mvHalfSize(invSize*0.5f)\n    {\n        CalculateMinandMax();\n    }\n    //-----------------------------------------------\n    /// Calculate Min and Max\n    ///\n    /// Refreshes the bounds\n    //-----------------------------------------------\n    void AABB::CalculateMinandMax()\n    {\n        mvMin.x = mvOrigin.x - mvHalfSize.x;\n        mvMin.y = mvOrigin.y - mvHalfSize.y;\n        mvMin.z = mvOrigin.z - mvHalfSize.z;\n        \n        mvMax.x = mvOrigin.x + mvHalfSize.x;\n        mvMax.y = mvOrigin.y + mvHalfSize.y;\n        mvMax.z = mvOrigin.z + mvHalfSize.z;\n    }\n    //-----------------------------------------------\n    /// Set Origin\n    ///\n    /// @param Centre point of AABB\n    //-----------------------------------------------\n    void AABB::SetOrigin(const Vector3 &invOrigin)\n    {\n        mvOrigin = invOrigin;\n        \n        CalculateMinandMax();\n    }\n    //-----------------------------------------------\n    /// Set Size\n    ///\n    /// @param Dimensions of AABB\n    //-----------------------------------------------\n    void AABB::SetSize(const Vector3 &invSize)\n    {\n        mvSize = invSize;\n        mvSize.x = fabsf(mvSize.x);\n        mvSize.y = fabsf(mvSize.y);\n        mvSize.z = fabsf(mvSize.z);\n        \n        mvHalfSize = mvSize * 0.5f;\n        \n        CalculateMinandMax();\n    }\n    //-----------------------------------------------\n    /// Front Top Left\n    ///\n    /// @return Top left co-ordinate\n    //-----------------------------------------------\n    const Vector3 AABB::FrontTopLeft() const\n    {\n        return Vector3(mvMin.x, mvMax.y, mvMin.z);\n    }\n    //-----------------------------------------------\n    /// Front Top Right\n    ///\n    /// @return Top right co-ordinate\n    //-----------------------------------------------\n    const Vector3 AABB::FrontTopRight() const\n    {\n        return Vector3(mvMax.x, mvMax.y, mvMin.z);\n    }\n    //-----------------------------------------------\n    /// Front Bottom Left\n    ///\n    /// @return Lower left co-ordinate\n    //-----------------------------------------------\n    const Vector3 AABB::FrontBottomLeft() const\n    {\n        return Vector3(mvMin.x, mvMin.y, mvMin.z);\n    }\n    //-----------------------------------------------\n    /// Front Bottom Right\n    ///\n    /// @return Lower right co-ordinate\n    //-----------------------------------------------\n    const Vector3 AABB::FrontBottomRight() const\n    {\n        return Vector3(mvMax.x, mvMin.y, mvMin.z);\n    }\n    //-----------------------------------------------\n    /// Back Top Left\n    ///\n    /// @return Top left co-ordinate\n    //-----------------------------------------------\n    const Vector3 AABB::BackTopLeft() const\n    {\n        return Vector3(mvMin.x, mvMax.y, mvMax.z);\n    }\n    //-----------------------------------------------\n    /// Back Top Right\n    ///\n    /// @return Top right co-ordinate\n    //-----------------------------------------------\n    const Vector3 AABB::BackTopRight() const\n    {\n        return Vector3(mvMax.x, mvMax.y, mvMax.z);\n    }\n    //-----------------------------------------------\n    /// Back Bottom Left\n    ///\n    /// @return Lower left co-ordinate\n    //-----------------------------------------------\n    const Vector3 AABB::BackBottomLeft() const\n    {\n        return Vector3(mvMin.x, mvMin.y, mvMax.z);\n    }\n    //-----------------------------------------------\n    /// Back Bottom Right\n    ///\n    /// @return Lower right co-ordinate\n    //-----------------------------------------------\n    const Vector3 AABB::BackBottomRight() const\n    {\n        return Vector3(mvMax.x, mvMin.y, mvMax.z);\n    }\n    //-----------------------------------------------\n    /// Centre\n    ///\n    /// @return Centre point\n    //-----------------------------------------------\n    const Vector3& AABB::Centre() const\n    {\n        return mvOrigin;\n    }\n    //-----------------------------------------------\n    /// Contains (Point)\n    ///\n    /// @param Point in 3D space\n    /// @return Whether point intersects the AABB\n    //-----------------------------------------------\n    bool AABB::Contains(const Vector3 &invPoint) const\n    {\n        return\tShapeIntersection::Intersects(*this, invPoint);\n    }\n    //-----------------------------------------------\n    /// Contains (AABB)\n    ///\n    /// @param AABB in 3D space\n    /// @return Whether AABB intersects the AABB\n    //-----------------------------------------------\n    bool AABB::Contains(const AABB &inAABB) const\n    {\n        return\tShapeIntersection::Intersects(*this, inAABB);\n    }\n    //-----------------------------------------------\n    /// Contains (Ray)\n    ///\n    /// @param Ray in 3D space\n    /// @param Near point of intersection\n    /// @param Far point of intersection\n    /// @return Whether ray intersects the AABB\n    //-----------------------------------------------\n    bool AABB::Contains(const Ray &inRay, f32 &outfT1, f32 &outfT2) const\n    {\n        return ShapeIntersection::Intersects(*this, inRay, outfT1, outfT2);\n    }\n    //-----------------------------------------------\n    /// Union\n    ///\n    /// @param AABB to union with this\n    /// @return Unions two AABBs together find the composite size.\n    //-----------------------------------------------\n    AABB AABB::Union(const AABB& inAABB)\n    {\n        AABB cUnion;\n                    \n        f32 fMinX = std::min(mvMin.x, inAABB.mvMin.x);\n        f32 fMinY = std::min(mvMin.y, inAABB.mvMin.y);\n        f32 fMinZ = std::min(mvMin.z, inAABB.mvMin.z);\n        \n        f32 fMaxX = std::max(mvMax.x, inAABB.mvMax.x);\n        f32 fMaxY = std::max(mvMax.y, inAABB.mvMax.y);\n        f32 fMaxZ = std::max(mvMax.z, inAABB.mvMax.z);\n        \n        cUnion.SetOrigin(Vector3((fMinX + fMaxX) * 0.5f,(fMinY + fMaxY) * 0.5f,(fMinZ + fMaxZ) * 0.5f));\n        cUnion.SetSize(Vector3(fMaxX - fMinX,fMaxY - fMinY,fMaxZ - fMinZ));\n        \n        return cUnion;\n    }\n    //================================================\n    /// OOBB\n    ///\n    /// Container for an object oriented bounding box \n    /// with it's origin at centre\n    //================================================\n    OOBB::OOBB() :  mHitBox(Vector3(1,1,1), Vector3::k_zero), mmatLocal(Matrix4::k_identity)\n    {\n    }\n    OOBB::OOBB(const Vector3 &invOrigin, const Vector3 &invSize) : mHitBox(invOrigin, invSize), mmatLocal(Matrix4::k_identity)\n    {\n    }\n    //-----------------------------------------------\n    /// Contains (Point)\n    ///\n    /// @param Point in 3D space\n    /// @return Whether point intersects the OOBB\n    //-----------------------------------------------\n    bool OOBB::Contains(const Vector3 &invPoint) const\n    {\n        //Convert the point into our local space\n        //allowing us to do an AABB check\n        Matrix4 matToLocal = Matrix4::Inverse(GetTransform());\n        \n        Vector3 LocalPoint = invPoint * matToLocal;\n        \n        return mHitBox.Contains(LocalPoint);\n    }\n    //-----------------------------------------------\n    /// Contains (Ray)\n    ///\n    /// @param Ray in world space\n    /// @param Near point of intersection\n    /// @param Far point of intersection\n    /// @return Whether ray intersects the OOBB\n    //------------------------------------------------\n    bool OOBB::Contains(const Ray &inRay, f32 &outfT1, f32 &outfT2) const\n    {\n        //Matrix to transform from world space to this objects local space\n        //In local space the OOBB is simply an AABB\n        Matrix4 matToLocal = Matrix4::Inverse(GetTransform());\n\n        //Convert the ray into our local space\n        //allowing us to do an AABB check\n        Ray LocalRay = inRay;\n        LocalRay.vOrigin = LocalRay.vOrigin * matToLocal;\n        LocalRay.vDirection = (LocalRay.vDirection * matToLocal) - matToLocal.GetTranslation();\n        LocalRay.fLength *= LocalRay.vDirection.Length();\n        LocalRay.vDirection.Normalise();\n        \n        return mHitBox.Contains(LocalRay, outfT1, outfT2);\n    }\n    //----------------------------------------------- \n    /// Set Origin\n    ///\n    /// @param X\n    /// @param Y\n    /// @param Z\n    //-----------------------------------------------\n    void OOBB::SetOrigin(const f32 infX, const f32 infY, const f32 infZ)\n    {\n        mHitBox.SetOrigin(Vector3(infX,infY,infZ));\n    }\n    //----------------------------------------------- \n    /// Set Origin\n    ///\n    /// @param Local origin of the object\n    //-----------------------------------------------\n    void OOBB::SetOrigin(const Vector3 &invPos)\n    {\n        mHitBox.SetOrigin(invPos);\n    }\n    //----------------------------------------------- \n    /// Get Origin\n    ///\n    /// @return Local origin of the object\n    //-----------------------------------------------\n    const Vector3& OOBB::GetOrigin() const\n    {\n        return mHitBox.GetOrigin();\n    }\n    //----------------------------------------------- \n    /// Set Size\n    ///\n    /// @param Local dimensions of the object\n    //-----------------------------------------------\n    void OOBB::SetSize(const Vector3& invSize)\n    {\n        mHitBox.SetSize(invSize);\n    }\n    //----------------------------------------------- \n    /// Get Size\n    ///\n    /// @return Local dimensions of the object\n    //-----------------------------------------------\n    const Vector3& OOBB::GetSize() const\n    {\n        return mHitBox.GetSize();\n    }\n    //----------------------------------------------- \n    /// Set Transform\n    ///\n    /// Set the matrix that transforms this object\n    /// to world space\n    /// @param To world matrix\n    //-----------------------------------------------\n    void OOBB::SetTransform(const Matrix4& inmatTransform)\n    {\n        mmatLocal = inmatTransform;\n    }\n    //----------------------------------------------- \n    /// Get Transform\n    ///\n    /// Get the model matrix that transforms this\n    /// object to world space\n    /// @return To world matrix\n    //-----------------------------------------------\n    const Matrix4& OOBB::GetTransform() const\n    {\t\t\t\n        return mmatLocal;\n    }\n    //===============================================\n    /// Ray\n    ///\n    /// Container for a ray\n    //===============================================\n    Ray::Ray(const Vector3 &invOrigin, const Vector3 &invDirection, const f32 infLength) : vOrigin(invOrigin), vDirection(invDirection), fLength(infLength)\n    {\n    }\n    //----------------------------------------------- \n    /// Get Point\n    ///\n    /// Gets the position of a point t units \n    /// along the ray.\n    /// @param A value t along parametric ray\n    /// @return Point on ray\n    //-----------------------------------------------\n    Vector3 Ray::GetPoint(f32 t) const \n    { \n        return Vector3(vOrigin + (vDirection * t) * fLength);\n    }\n    f32 Ray::DistanceFromPoint(const Vector3 &invPoint) const\n    {\n        return Vector3::CrossProduct(vDirection, invPoint).Length();\n    }\n\n    //===============================================\n    /// Plane\n    ///\n    /// Container for a plane\n    //===============================================\n    Plane::Plane(const Vector3& invOrigin, const Vector3& invNormal)\n    :mvNormal(invNormal)\n    {\n        mfD = -Vector3::DotProduct(invNormal, invOrigin);\n    }\n    Plane::Plane(f32 a, f32 b, f32 c, f32 d)\n    : mvNormal(a,b,c), mfD(d)\n    {\n\n    }\n    Plane::Plane(const Vector3& incNormal, f32 d)\n    :mvNormal(incNormal), mfD(d)\n    {\n        \n    }\n    f32 Plane::DistanceFromPoint(const Vector3& invPoint) const{\t\t\t\n        return Vector3::DotProduct(mvNormal, invPoint) + mfD;\n    }\n    \n    bool Plane::Intersects(const Ray& incRay) const{\n        f32 denom = Vector3::DotProduct(mvNormal, incRay.vDirection);\n        \n        \n        if (fabsf(denom) < std::numeric_limits<f32>::epsilon())\n        {\n            // Parallel\n            return false;\n        }\n        else\n        {\n            f32 nom = Vector3::DotProduct(mvNormal, incRay.vOrigin) + mfD;\n            f32 t = -(nom/denom);\n            return t >= 0;\n        }\n    }\n    \n    //===============================================\n    /// Frustum\n    ///\n    /// Container for a frustum\n    //===============================================\n    //----------------------------------------------------------\n    /// Calculate Clipping Planes\n    ///\n    /// Build the 6 world space planes of the frustum based on the camera\n    /// view projection matrix\n    ///\n    /// @param View projection matrix\n    //----------------------------------------------------------\n    void Frustum::CalculateClippingPlanes(const Matrix4& inmatViewProj)\n    {\n        f32 t = 0.0f;\n\n        // Left clipping plane\n        mLeftClipPlane.mvNormal.x\t= inmatViewProj.m[3] + inmatViewProj.m[0];\n        mLeftClipPlane.mvNormal.y\t= inmatViewProj.m[7] + inmatViewProj.m[4];\n        mLeftClipPlane.mvNormal.z\t= inmatViewProj.m[11] + inmatViewProj.m[8];\n        mLeftClipPlane.mfD\t\t\t= inmatViewProj.m[15] + inmatViewProj.m[12];\n\n        t = 1/(sqrtf(mLeftClipPlane.mvNormal.x * mLeftClipPlane.mvNormal.x + mLeftClipPlane.mvNormal.y * mLeftClipPlane.mvNormal.y + mLeftClipPlane.mvNormal.z * mLeftClipPlane.mvNormal.z));\n        mLeftClipPlane.mvNormal.x\t*= t;\n        mLeftClipPlane.mvNormal.y\t*= t;\n        mLeftClipPlane.mvNormal.z\t*= t;\n        mLeftClipPlane.mfD\t\t\t*= t;\n\n        // Right clipping plane\n        mRightClipPlane.mvNormal.x\t= inmatViewProj.m[3] - inmatViewProj.m[0];\n        mRightClipPlane.mvNormal.y\t= inmatViewProj.m[7] - inmatViewProj.m[4];\n        mRightClipPlane.mvNormal.z\t= inmatViewProj.m[11] - inmatViewProj.m[8];\n        mRightClipPlane.mfD\t\t\t= inmatViewProj.m[15] - inmatViewProj.m[12];\n\n        t = 1/(sqrtf(mRightClipPlane.mvNormal.x * mRightClipPlane.mvNormal.x + mRightClipPlane.mvNormal.y * mRightClipPlane.mvNormal.y + mRightClipPlane.mvNormal.z * mRightClipPlane.mvNormal.z));\n        mRightClipPlane.mvNormal.x\t*= t;\n        mRightClipPlane.mvNormal.y\t*= t;\n        mRightClipPlane.mvNormal.z\t*= t;\n        mRightClipPlane.mfD\t\t\t*= t;\n\n        // Top clipping plane\n        mTopClipPlane.mvNormal.x\t= inmatViewProj.m[3] - inmatViewProj.m[1];\n        mTopClipPlane.mvNormal.y\t= inmatViewProj.m[7] - inmatViewProj.m[5];\n        mTopClipPlane.mvNormal.z\t= inmatViewProj.m[11] - inmatViewProj.m[9];\n        mTopClipPlane.mfD\t\t\t= inmatViewProj.m[15] - inmatViewProj.m[13];\n\n        t = 1/(sqrtf(mTopClipPlane.mvNormal.x * mTopClipPlane.mvNormal.x + mTopClipPlane.mvNormal.y * mTopClipPlane.mvNormal.y + mTopClipPlane.mvNormal.z * mTopClipPlane.mvNormal.z));\n        mTopClipPlane.mvNormal.x\t*= t;\n        mTopClipPlane.mvNormal.y\t*= t;\n        mTopClipPlane.mvNormal.z\t*= t;\n        mTopClipPlane.mfD\t\t\t*= t;\n\n        // Bottom clipping plane\n        mBottomClipPlane.mvNormal.x\t= inmatViewProj.m[3] + inmatViewProj.m[1];\n        mBottomClipPlane.mvNormal.y\t= inmatViewProj.m[7] + inmatViewProj.m[5];\n        mBottomClipPlane.mvNormal.z\t= inmatViewProj.m[11] + inmatViewProj.m[9];\n        mBottomClipPlane.mfD\t\t= inmatViewProj.m[15] + inmatViewProj.m[13];\n\n        t = 1/(sqrtf(mBottomClipPlane.mvNormal.x * mBottomClipPlane.mvNormal.x + mBottomClipPlane.mvNormal.y * mBottomClipPlane.mvNormal.y + mBottomClipPlane.mvNormal.z * mBottomClipPlane.mvNormal.z));\n        mBottomClipPlane.mvNormal.x\t*= t;\n        mBottomClipPlane.mvNormal.y\t*= t;\n        mBottomClipPlane.mvNormal.z\t*= t;\n        mBottomClipPlane.mfD\t\t*= t;\n\n        // Near clipping plane\n        mFarClipPlane.mvNormal.x\t= inmatViewProj.m[3] - inmatViewProj.m[2];\n        mFarClipPlane.mvNormal.y\t= inmatViewProj.m[7] - inmatViewProj.m[6];\n        mFarClipPlane.mvNormal.z\t= inmatViewProj.m[11] - inmatViewProj.m[10];\n        mFarClipPlane.mfD\t\t\t= inmatViewProj.m[15] - inmatViewProj.m[14];\n\n        t = 1/(sqrtf(mFarClipPlane.mvNormal.x * mFarClipPlane.mvNormal.x + mFarClipPlane.mvNormal.y * mFarClipPlane.mvNormal.y + mFarClipPlane.mvNormal.z * mFarClipPlane.mvNormal.z));\n        mFarClipPlane.mvNormal.x\t*= t;\n        mFarClipPlane.mvNormal.y\t*= t;\n        mFarClipPlane.mvNormal.z\t*= t;\n        mFarClipPlane.mfD\t\t\t*= t;\n\n        // Far clipping plane\n        mNearClipPlane.mvNormal.x\t= inmatViewProj.m[3] + inmatViewProj.m[2];\n        mNearClipPlane.mvNormal.y\t= inmatViewProj.m[7] + inmatViewProj.m[6];\n        mNearClipPlane.mvNormal.z\t= inmatViewProj.m[11] + inmatViewProj.m[10];\n        mNearClipPlane.mfD\t\t\t= inmatViewProj.m[15] + inmatViewProj.m[14];\n\n        t = 1/(sqrtf(mNearClipPlane.mvNormal.x * mNearClipPlane.mvNormal.x + mNearClipPlane.mvNormal.y * mNearClipPlane.mvNormal.y + mNearClipPlane.mvNormal.z * mNearClipPlane.mvNormal.z));\n        mNearClipPlane.mvNormal.x\t*= t;\n        mNearClipPlane.mvNormal.y\t*= t;\n        mNearClipPlane.mvNormal.z\t*= t;\n        mNearClipPlane.mfD\t\t\t*= t;\n    }\n    //----------------------------------------------------------\n    /// Sphere Cull Test\n    ///\n    /// Test if the bounding sphere lies within the frustum\n    /// and determine whether it should be culled\n    ///\n    /// @param Sphere\n    /// @return Whether it lies within the bounds\n    //-----------------------------------------------------------\n    bool Frustum::SphereCullTest(const Sphere& inBoundingSphere) const\n    {\n        if(ShapeIntersection::Intersects(inBoundingSphere, mLeftClipPlane) == ShapeIntersection::Result::k_outside)\n            return false;\n\n        if(ShapeIntersection::Intersects(inBoundingSphere, mRightClipPlane) == ShapeIntersection::Result::k_outside)\n            return false;\n\n        if(ShapeIntersection::Intersects(inBoundingSphere, mTopClipPlane) == ShapeIntersection::Result::k_outside)\n            return false;\n\n        if(ShapeIntersection::Intersects(inBoundingSphere, mBottomClipPlane) == ShapeIntersection::Result::k_outside)\n            return false;\n    \n        if(ShapeIntersection::Intersects(inBoundingSphere, mNearClipPlane) == ShapeIntersection::Result::k_outside)\n            return false;\n\n        if(ShapeIntersection::Intersects(inBoundingSphere, mFarClipPlane) == ShapeIntersection::Result::k_outside)\n            return false;\n\n        return true;\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Core/Math/Geometry/Shapes.h",
    "content": "//\n//  Shapes.h\n//  ChilliSource\n//  Created by Scott Downie on 04/10/2010.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2010 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_MATHS_SHAPES_H_\n#define _CHILLISOURCE_CORE_MATHS_SHAPES_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Math/Vector2.h>\n#include <ChilliSource/Core/Math/Vector3.h>\n#include <ChilliSource/Core/Math/Quaternion.h>\n\nnamespace ChilliSource\n{\n    //---Defaults\n    const f32 kDefaultRayLength = 5000.0f;\n    \n    //================================================\n    /// Rect\n    ///\n    /// Container for a rectangle with it's origin \n    /// at the centre and Y-up\n    //================================================\n    class Rectangle\n    {\n    public:\t\n        Rectangle() = default;\n        Rectangle(const Vector2 &invOrigin, const Vector2 &invSize);\n        //-----------------------------------------------\n        /// Constructor\n        ///\n        /// @author S Downie\n        ///\n        /// @param Left\n        /// @param Top\n        /// @param Right\n        /// @param Bottom\n        //-----------------------------------------------\n        Rectangle(f32 in_left, f32 in_top, f32 in_right, f32 in_bottom);\n        \n        //-----------------------------------------------\n        /// Left\n        ///\n        /// @return Left side of rectangle\n        //-----------------------------------------------\n        f32 Left() const;\n        //-----------------------------------------------\n        /// Right\n        ///\n        /// @return Right side of rectangle\n        //-----------------------------------------------\n        f32 Right() const;\n        //-----------------------------------------------\n        /// Top\n        ///\n        /// @return Top side of rectangle\n        //-----------------------------------------------\n        f32 Top() const;\n        //-----------------------------------------------\n        /// Bottom\n        ///\n        /// @return Bottom side of rectangle\n        //-----------------------------------------------\n        f32 Bottom() const;\n        //-----------------------------------------------\n        /// Top Left\n        ///\n        /// @return Top left co-ordinate\n        //-----------------------------------------------\n        Vector2 TopLeft() const;\n        //-----------------------------------------------\n        /// Top Right\n        ///\n        /// @return Top right co-ordinate\n        //-----------------------------------------------\n        Vector2 TopRight() const;\n        //-----------------------------------------------\n        /// Bottom Left\n        ///\n        /// @return Bottom left co-ordinate\n        //-----------------------------------------------\n        Vector2 BottomLeft() const;\n        //-----------------------------------------------\n        /// Bottom Right\n        ///\n        /// @return Bottom right co-ordinate\n        //-----------------------------------------------\n        Vector2 BottomRight() const;\n        //-----------------------------------------------\n        /// Centre\n        ///\n        /// @return Centre point\n        //-----------------------------------------------\n        Vector2 Centre() const;\n        //-----------------------------------------------\n        /// Contains (Point)\n        ///\n        /// @param Point in 2D space\n        /// @return Whether point intersects the rect\n        //-----------------------------------------------\n        bool Contains(const Vector2 & invPoint) const;\n        //-----------------------------------------------\n        /// Contains (Rect)\n        ///\n        /// @param Rect in 2D space\n        /// @return Whether rect intersects the rect\n        //-----------------------------------------------\n        bool Contains(const Rectangle& inRect) const;\n        \n        ///Top Left\n        Vector2 vOrigin;\n        ///Width and height\n        Vector2 vSize;\n    };\n    //================================================\n    /// Circle\n    ///\n    /// Container for a circle with it's origin \n    /// at centre\n    //================================================\n    class Circle\n    {\n    public:\n        Circle(){}\n        Circle(const Vector2 &invOrigin, const f32 infRadius);\n        //-----------------------------------------------\n        /// Contains (Point)\n        ///\n        /// @param Point in 2D space\n        /// @return Whether point intersects the circle\n        //-----------------------------------------------\n        bool Contains(const Vector2 & invPoint) const;\n        //-----------------------------------------------\n        /// Contains (Circle)\n        ///\n        /// @param Circle in 2D space\n        /// @return Whether circle intersects the circle\n        //-----------------------------------------------\n        bool Contains(const Circle & inCircle) const;\n        \n        ///Centre\t\t\t\t   \n        Vector2 vOrigin;\n        f32 fRadius;\n    };\n    //================================================\n    /// Sphere\n    ///\n    /// Container for a sphere with it's origin \n    /// at centre\n    //================================================\n    class Sphere\n    {\n    public:\n        //-----------------------------------------------\n        /// Transforms the given sphere by the given\n        /// translation, rotation and scale. This can be used to\n        /// transform the sphere from local to world.\n        ///\n        /// Note that the sphere remains spherical; the\n        /// radius is scaled by the highest of the scale\n        /// vector components.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param sphere - The sphere to transform.\n        /// @param translation - The translation to apply.\n        /// @param orientation - The rotation to apply.\n        /// @param scale - The scale to apply (made uniform by taking the largest).\n        ///\n        /// @return The transformed sphere.\n        //-----------------------------------------------\n        static Sphere Transform(const Sphere& sphere, const Vector3& translation, const Quaternion& orientation, const Vector3& scale) noexcept;\n        \n        Sphere(){}\n        Sphere(const Vector3 &invOrigin, const f32 infRadius);\n        //-----------------------------------------------\n        /// Contains (Point)\n        ///\n        /// @param Point in 2D space\n        /// @return Whether point intersects the circle\n        //-----------------------------------------------\n        bool Contains(const Vector3 & invPoint) const;\n        //-----------------------------------------------\n        /// Contains (Ray)\n        ///\n        /// @param Point in 2D space\n        /// @return Whether point intersects the sphere\n        //-----------------------------------------------\n        bool Contains(const Ray &inRay) const;\n        //-----------------------------------------------\n        /// Contains (Sphere)\n        ///\n        /// @param Sphere in 3D space\n        /// @return Whether sphere intersects the sphere\n        //-----------------------------------------------\n        bool Contains(const Sphere & inSphere) const;\n        \n        ///Centre\t\t\t\t   \n        Vector3 vOrigin;\n        f32 fRadius = 0.0f;\n    };\n    //================================================\n    /// AABB\n    ///\n    /// Container for a axis-aligned bounding box \n    /// with it's origin at centre\n    //================================================\n    class AABB\n    {\n    public:\n        AABB(){}\n        AABB(const Vector3 &invOrigin, const Vector3 &invSize);\n        //-----------------------------------------------\n        /// Front Top Left\n        ///\n        /// @return Top left co-ordinate\n        //-----------------------------------------------\n        const Vector3 FrontTopLeft() const;\n        //-----------------------------------------------\n        /// Front Top Right\n        ///\n        /// @return Top right co-ordinate\n        //-----------------------------------------------\n        const Vector3 FrontTopRight() const;\n        //-----------------------------------------------\n        /// Front Bottom Left\n        ///\n        /// @return Lower left co-ordinate\n        //-----------------------------------------------\n        const Vector3 FrontBottomLeft() const;\n        //-----------------------------------------------\n        /// Front Bottom Right\n        ///\n        /// @return Lower right co-ordinate\n        //-----------------------------------------------\n        const Vector3 FrontBottomRight() const;\n        //-----------------------------------------------\n        /// Back Top Left\n        ///\n        /// @return Top left co-ordinate\n        //-----------------------------------------------\n        const Vector3 BackTopLeft() const;\n        //-----------------------------------------------\n        /// Back Top Right\n        ///\n        /// @return Top right co-ordinate\n        //-----------------------------------------------\n        const Vector3 BackTopRight() const;\n        //-----------------------------------------------\n        /// Back Bottom Left\n        ///\n        /// @return Lower left co-ordinate\n        //-----------------------------------------------\n        const Vector3 BackBottomLeft() const;\n        //-----------------------------------------------\n        /// Back Bottom Right\n        ///\n        /// @return Lower right co-ordinate\n        //-----------------------------------------------\n        const Vector3 BackBottomRight() const;\n        //-----------------------------------------------\n        /// Centre\n        ///\n        /// @return Centre point\n        //-----------------------------------------------\n        const Vector3& Centre() const;\n        //-----------------------------------------------\n        /// Get Origin\n        ///\n        /// @return Centre point of AABB\n        //-----------------------------------------------\n        inline const Vector3& GetOrigin() const {return mvOrigin;};\n        //-----------------------------------------------\n        /// Set Origin\n        ///\n        /// @param Centre point of AABB\n        //-----------------------------------------------\n        void SetOrigin(const Vector3 &invOrigin);\n        //-----------------------------------------------\n        /// Get Size\n        ///\n        /// @return Dimensions of AABB\n        //-----------------------------------------------\n        inline const Vector3& GetSize() const {return mvSize;};\n        //-----------------------------------------------\n        /// Set Size\n        ///\n        /// @param Dimensions of AABB\n        //-----------------------------------------------\n        void SetSize(const Vector3 &invSize);\n        //-----------------------------------------------\n        /// Get Half Size\n        ///\n        /// @return Half Dimensions of AABB\n        //-----------------------------------------------\n        inline const Vector3& GetHalfSize() const {return mvHalfSize;};\n        //-----------------------------------------------\n        /// Get Min\n        ///\n        /// @return Mininmum coords of AABB\n        //-----------------------------------------------\n        inline const Vector3& GetMin() const {return mvMin;};\n        //-----------------------------------------------\n        /// Get Max\n        ///\n        /// @return Maximum coords of AABB\n        //-----------------------------------------------\n        inline const Vector3& GetMax() const {return mvMax;};\n        //-----------------------------------------------\n        /// Calculate Min and Max\n        ///\n        /// Refreshes the bounds\n        //-----------------------------------------------\n        void CalculateMinandMax();\n        //-----------------------------------------------\n        /// Contains (Point)\n        ///\n        /// @param Point in 3D space\n        /// @return Whether point intersects the AABB\n        //-----------------------------------------------\n        bool Contains(const Vector3 &invPoint) const;\n        //-----------------------------------------------\n        /// Contains (AABB)\n        ///\n        /// @param AABB in 3D space\n        /// @return Whether AABB intersects the AABB\n        //-----------------------------------------------\n        bool Contains(const AABB &inAABB) const;\n        //-----------------------------------------------\n        /// Contains (Ray)\n        ///\n        /// @param Ray in 3D space\n        /// @param Near point of intersection\n        /// @param Far point of intersection\n        /// @return Whether ray intersects the AABB\n        //-----------------------------------------------\n        bool Contains(const Ray &inRay, f32 &outfT1, f32 &outfT2) const;\n        //-----------------------------------------------\n        /// Union\n        ///\n        /// @param AABB to union with this\n        /// @return Unions two AABBs together find the composite size.\n        //-----------------------------------------------\n        AABB Union(const AABB& inAABB);\n        \n        private:\n        ///Centre\n        Vector3 mvOrigin;\n        ///Dimensions (width, height, breadth)\n        Vector3 mvSize;\n        Vector3 mvHalfSize;\n        Vector3 mvMin;\n        Vector3 mvMax;\n    };\n    //================================================\n    /// OOBB\n    ///\n    /// Container for a object oriented bounding box \n    /// with it's origin at centre\n    //================================================\n    class OOBB\n    {\n    public:\n        OOBB();\n        OOBB(const Vector3 &invOrigin, const Vector3 &invSize);\n        \n        //----------------------------------------------- \n        /// Set Origin\n        ///\n        /// @param X\n        /// @param Y\n        /// @param Z\n        //-----------------------------------------------\n        void SetOrigin(const f32 infX, const f32 infY, const f32 infZ = 0.0f);\n        //----------------------------------------------- \n        /// Set Origin\n        ///\n        /// @param Local origin of the object\n        //-----------------------------------------------\n        void SetOrigin(const Vector3 &invPos);\n        //----------------------------------------------- \n        /// Get Origin\n        ///\n        /// @return Local origin of the object\n        //-----------------------------------------------\n        const Vector3& GetOrigin() const;\n        //----------------------------------------------- \n        /// Set Size\n        ///\n        /// @param Local dimensions of the object\n        //-----------------------------------------------\n        void SetSize(const Vector3& invSize);\n        //----------------------------------------------- \n        /// Get Size\n        ///\n        /// @return Local dimensions of the object\n        //-----------------------------------------------\n        const Vector3& GetSize() const;\t\t\t\n        //----------------------------------------------- \n        /// Get Transform\n        ///\n        /// Get the model matrix that transforms this\n        /// object to world space\n        /// @return To world matrix\n        //-----------------------------------------------\n        const Matrix4 & GetTransform() const;\n        //----------------------------------------------- \n        /// Set Transform\n        ///\n        /// Set the matrix that transforms this object\n        /// to world space\n        /// @param To world matrix\n        //-----------------------------------------------\n        void SetTransform(const Matrix4& inmatTransform);\n        \n        //-----------------------------------------------\n        /// Contains (Point)\n        ///\n        /// @param Point in 3D space\n        /// @return Whether point intersects the OOBB\n        //-----------------------------------------------\n        bool Contains(const Vector3 &invPoint) const;\n        //-----------------------------------------------\n        /// Contains (Ray)\n        ///\n        /// @param Ray in 3D space\n        /// @param Near point of intersection\n        /// @param Far point of intersection\n        /// @return Whether ray intersects the OOBB\n        //-----------------------------------------------\n        bool Contains(const Ray &inRay, f32 &outfT1, f32 &outfT2) const;\n        \n    private:\n        \n        ///AABB in Local Space\n        AABB mHitBox;\n        \n        Matrix4 mmatLocal;\n    };\n    //===============================================\n    /// Ray\n    ///\n    /// Container for a ray\n    //===============================================\n    class Ray\n    {\n    public:\n        Ray(){}\n        Ray(const Vector3 &invOrigin, const Vector3 &invDirection, const f32 infLength = kDefaultRayLength);\n        \n        Vector3 vOrigin;\n        Vector3 vDirection;\n        \n        //----------------------------------------------- \n        /// Get Point\n        ///\n        /// Gets the position of a point t units \n        /// along the ray.\n        /// @param A value t along parametric ray\n        /// @return Point on ray\n        //-----------------------------------------------\n        Vector3 GetPoint(f32 t) const;\n        \n        f32 DistanceFromPoint(const Vector3 &invOrigin) const;\n        \n        f32 fLength;\n    };\n    //===============================================\n    /// Line\n    ///\n    /// Shape described by a start and end position\n    //===============================================\n    class Line\n    {\n    public:\n        Line(){}\n        Line(const Vector3 &invStartPos, const Vector3 &invEndPos)\n        : vStartPos(invStartPos), vEndPos(invEndPos)\n        {}\n        Vector3 vStartPos;\n        Vector3 vEndPos;\n    };\n    //===============================================\n    /// Plane\n    ///\n    /// Container for a plane\n    //===============================================\n    class Plane\n    {\n    public:\n        Plane(){}\n        Plane(const Vector3& incOrigin, const Vector3& incNormal);\n        Plane(f32 a, f32 b, f32 c, f32 d);\n        Plane(const Vector3& incNormal, f32 d);\n        \n        f32 DistanceFromPoint(const Vector3& invPoint) const;\n        bool Intersects(const Ray& incRay) const;\n\n        Vector3 mvNormal;\n        f32 mfD;\n    };\n\n    //===============================================\n    /// Frustum\n    ///\n    /// Container for a frustum\n    //===============================================\n    class Frustum\n    {\n    public:\n\n        //----------------------------------------------------------\n        /// Calculate Clipping Planes\n        ///\n        /// Build the 6 world space planes of the frustum based on the camera\n        /// view projection matrix\n        ///\n        /// @param View projection matrix\n        //----------------------------------------------------------\n        void CalculateClippingPlanes(const Matrix4& inmatViewProj);\n        //----------------------------------------------------------\n        /// Sphere Cull Test\n        ///\n        /// Test if the bounding sphere lies within the frustum\n        /// and determine whether it should be culled\n        ///\n        /// @param Sphere\n        /// @return Whether it lies within the bounds\n        //-----------------------------------------------------------\n        bool SphereCullTest(const Sphere& inBoundingSphere) const;\n\n    public:\n\n        Plane mLeftClipPlane;\n        Plane mRightClipPlane;\n\n        Plane mTopClipPlane;\n        Plane mBottomClipPlane;\n\n        Plane mNearClipPlane;\n        Plane mFarClipPlane;\n    };\n}\n\n#endif //_CHILLISOURCE_CORE_MATHS_SHAPES_H_\n"
  },
  {
    "path": "Source/ChilliSource/Core/Math/Interpolate.cpp",
    "content": "//\n//  Interpolate.cpp\n//  ChilliSource\n//  Created by Ian Copland on 29/12/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Core/Math/Interpolate.h>\n\n#include <ChilliSource/Core/Delegate/MakeDelegate.h>\n\n#include <json/json.h>\n\nnamespace ChilliSource\n{\n    namespace Interpolate\n    {\n        namespace\n        {\n            const char k_linearCurveName[] = \"linear\";\n            const char k_easeInQuadCurveName[] = \"easeinquad\";\n            const char k_easeOutQuadCurveName[] = \"easeoutquad\";\n            const char k_smoothStepCurveName[] = \"smoothstep\";\n            const char k_linearPingPongCurveName[] = \"linearpingpong\";\n            const char k_easeInQuadPingPongCurveName[] = \"easeinquadpingpong\";\n            const char k_easeOutQuadPingPongCurveName[] = \"easeoutquadpingpong\";\n            const char k_smoothStepPingPongCurveName[] = \"smoothsteppingpong\";\n        }\n        \n        //------------------------------------------------------------------------------\n        //------------------------------------------------------------------------------\n        std::function<f32(f32)> GetInterpolateFunction(const std::string& in_name)\n        {\n            std::string nameLower = in_name;\n            StringUtils::ToLowerCase(nameLower);\n            \n            if (nameLower == k_linearCurveName)\n            {\n                return MakeDelegate(&Interpolate::Linear);\n            }\n            else if (nameLower == k_easeInQuadCurveName)\n            {\n                return MakeDelegate(&Interpolate::EaseInQuad);\n            }\n            else if (nameLower == k_easeOutQuadCurveName)\n            {\n                return MakeDelegate(&Interpolate::EaseOutQuad);\n            }\n            else if (nameLower == k_smoothStepCurveName)\n            {\n                return MakeDelegate(&Interpolate::SmoothStep);\n            }\n            else if (nameLower == k_linearPingPongCurveName)\n            {\n                return MakeDelegate(&Interpolate::LinearPingPong);\n            }\n            else if (nameLower == k_easeInQuadPingPongCurveName)\n            {\n                return MakeDelegate(&Interpolate::EaseInQuadPingPong);\n            }\n            else if (nameLower == k_easeOutQuadPingPongCurveName)\n            {\n                return MakeDelegate(&Interpolate::EaseOutQuadPingPong);\n            }\n            else if (nameLower == k_smoothStepPingPongCurveName)\n            {\n                return MakeDelegate(&Interpolate::SmoothStepPingPong);\n            }\n            \n            CS_LOG_FATAL(\"Invalid Interpolate function name: \" + in_name);\n            return nullptr;\n        }\n        //------------------------------------------------------------------------------\n        //------------------------------------------------------------------------------\n        f32 Linear(f32 in_x)\n        {\n            CS_ASSERT(in_x >= 0.0f && in_x <= 1.0f, \"x must always be in the range 0.0 to 1.0 in Interpolate functions.\");\n            \n            return in_x;\n        }\n        //------------------------------------------------------------------------------\n        //------------------------------------------------------------------------------\n        f32 EaseInQuad(f32 in_x)\n        {\n            CS_ASSERT(in_x >= 0.0f && in_x <= 1.0f, \"x must always be in the range 0.0 to 1.0 in Interpolate functions.\");\n            \n            return in_x * in_x;\n        }\n        //------------------------------------------------------------------------------\n        //------------------------------------------------------------------------------\n        f32 EaseOutQuad(f32 in_x)\n        {\n            CS_ASSERT(in_x >= 0.0f && in_x <= 1.0f, \"x must always be in the range 0.0 to 1.0 in Interpolate functions.\");\n            \n            return -in_x * (in_x - 2.0f);\n        }\n        //------------------------------------------------------------------------------\n        //------------------------------------------------------------------------------\n        f32 SmoothStep(f32 in_x)\n        {\n            CS_ASSERT(in_x >= 0.0f && in_x <= 1.0f, \"x must always be in the range 0.0 to 1.0 in Interpolate functions.\");\n            \n            return in_x * in_x * (3.0f - 2.0f * in_x);\n        }\n        //------------------------------------------------------------------------------\n        //------------------------------------------------------------------------------\n        f32 LinearPingPong(f32 in_x)\n        {\n            CS_ASSERT(in_x >= 0.0f && in_x <= 1.0f, \"x must always be in the range 0.0 to 1.0 in Interpolate functions.\");\n            \n            if (in_x < 0.5f)\n            {\n                return Linear(in_x * 2.0f);\n            }\n            else\n            {\n                return Linear(2.0f * (1.0f - in_x));\n            }\n        }\n        //------------------------------------------------------------------------------\n        //------------------------------------------------------------------------------\n        f32 EaseInQuadPingPong(f32 in_x)\n        {\n            CS_ASSERT(in_x >= 0.0f && in_x <= 1.0f, \"x must always be in the range 0.0 to 1.0 in Interpolate functions.\");\n            \n            if (in_x < 0.5f)\n            {\n                return EaseInQuad(in_x * 2.0f);\n            }\n            else\n            {\n                return EaseInQuad(2.0f * (1.0f - in_x));\n            }\n        }\n        //------------------------------------------------------------------------------\n        //------------------------------------------------------------------------------\n        f32 EaseOutQuadPingPong(f32 in_x)\n        {\n            CS_ASSERT(in_x >= 0.0f && in_x <= 1.0f, \"x must always be in the range 0.0 to 1.0 in Interpolate functions.\");\n            \n            if (in_x < 0.5f)\n            {\n                return EaseOutQuad(in_x * 2.0f);\n            }\n            else\n            {\n                return EaseOutQuad(2.0f * (1.0f - in_x));\n            }\n        }\n        //------------------------------------------------------------------------------\n        //------------------------------------------------------------------------------\n        f32 SmoothStepPingPong(f32 in_x)\n        {\n            CS_ASSERT(in_x >= 0.0f && in_x <= 1.0f, \"x must always be in the range 0.0 to 1.0 in Interpolate functions.\");\n            \n            if (in_x < 0.5f)\n            {\n                return SmoothStep(in_x * 2.0f);\n            }\n            else\n            {\n                return SmoothStep(2.0f * (1.0f - in_x));\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Core/Math/Interpolate.h",
    "content": "//\n//  Interpolate.h\n//  ChilliSource\n//  Created by Ian Copland on 29/12/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_MATH_INTERPOLATE_H_\n#define _CHILLISOURCE_CORE_MATH_INTERPOLATE_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/String/StringUtils.h>\n\n#include <json/json.h>\n\n#include <functional>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    /// A collection of Interpolate functions.\n    ///\n    /// @author Ian Copland\n    //------------------------------------------------------------------------------\n    namespace Interpolate\n    {\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param The string name of the curve.\n        ///\n        /// @return The associated Interpolate function.\n        //------------------------------------------------------------------------------\n        std::function<f32(f32)> GetInterpolateFunction(const std::string& in_name);\n        //------------------------------------------------------------------------------\n        /// The linear Interpolate function.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The input x. This must be in the range 0.0 to 1.0.\n        ///\n        /// @return The output y. This will be in the range 0.0 to 1.0.\n        //------------------------------------------------------------------------------\n        f32 Linear(f32 in_x);\n        //------------------------------------------------------------------------------\n        /// The ease in quad Interpolate function.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The input x. This must be in the range 0.0 to 1.0.\n        ///\n        /// @return The output y. This will be in the range 0.0 to 1.0.\n        //------------------------------------------------------------------------------\n        f32 EaseInQuad(f32 in_x);\n        //------------------------------------------------------------------------------\n        /// The ease out quad Interpolate function.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The input x. This must be in the range 0.0 to 1.0.\n        ///\n        /// @return The output y. This will be in the range 0.0 to 1.0.\n        //------------------------------------------------------------------------------\n        f32 EaseOutQuad(f32 in_x);\n        //------------------------------------------------------------------------------\n        /// The smooth step Interpolate function.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The input x. This must be in the range 0.0 to 1.0.\n        ///\n        /// @return The output y. This will be in the range 0.0 to 1.0.\n        //------------------------------------------------------------------------------\n        f32 SmoothStep(f32 in_x);\n        //------------------------------------------------------------------------------\n        /// The linear ping pong Interpolate function.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The input x. This must be in the range 0.0 to 1.0.\n        ///\n        /// @return The output y. This will be in the range 0.0 to 1.0.\n        //------------------------------------------------------------------------------\n        f32 LinearPingPong(f32 in_x);\n        //------------------------------------------------------------------------------\n        /// The ease in quad ping pong Interpolate function.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The input x. This must be in the range 0.0 to 1.0.\n        ///\n        /// @return The output y. This will be in the range 0.0 to 1.0.\n        //------------------------------------------------------------------------------\n        f32 EaseInQuadPingPong(f32 in_x);\n        //------------------------------------------------------------------------------\n        /// The ease out quad ping pong Interpolate function.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The input x. This must be in the range 0.0 to 1.0.\n        ///\n        /// @return The output y. This will be in the range 0.0 to 1.0.\n        //------------------------------------------------------------------------------\n        f32 EaseOutQuadPingPong(f32 in_x);\n        //------------------------------------------------------------------------------\n        /// The smooth step ping pong Interpolate function.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The input x. This must be in the range 0.0 to 1.0.\n        ///\n        /// @return The output y. This will be in the range 0.0 to 1.0.\n        //------------------------------------------------------------------------------\n        f32 SmoothStepPingPong(f32 in_x);\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Math/MathUtils.cpp",
    "content": "//\n//  MathUtils.cpp\n//  ChilliSource\n//  Created by Stuart McGaw on 22/09/2010.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2010 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Core/Math/MathUtils.h>\n\n#include <ctime>\n#include <random>\n\nnamespace ChilliSource\n{\n    namespace MathUtils\n    {\n        namespace\n        {\n            const f32 k_degreesToRadians = 0.0174532925f;\n            const f32 k_radiansToDegrees = 57.2957795f;\n        }\n        \n        //---------------------------------------------------------\n        //---------------------------------------------------------\n        bool IsPowerOfTwo(u32 in_value) noexcept\n        {\n            return (in_value > 0) && ((in_value & (~in_value + 1)) == in_value);\n        }\n        //---------------------------------------------------------\n        //---------------------------------------------------------\n        u32 NextPowerOfTwo(u32 in_value)\n        {\n            in_value--;\n            in_value |= in_value >> 1;  // handle  2 bit numbers\n            in_value |= in_value >> 2;  // handle  4 bit numbers\n            in_value |= in_value >> 4;  // handle  8 bit numbers\n            in_value |= in_value >> 8;  // handle 16 bit numbers\n            in_value |= in_value >> 16; // handle 32 bit numbers\n            in_value++;\n            \n            return in_value;\t\n        }\n        //---------------------------------------------------------\n        //---------------------------------------------------------\n        f32 DegToRad(f32 in_angle)\n        {\n            return in_angle * k_degreesToRadians;\n        }\n        //---------------------------------------------------------\n        //---------------------------------------------------------\n        f32 RadToDeg(f32 infAngle)\n        {\n            return infAngle * k_radiansToDegrees;\n        }\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Core/Math/MathUtils.h",
    "content": "//\n//  MathUtils.h\n//  ChilliSource\n//  Created by Stuart McGaw on 22/09/2010.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2010 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_MATH_MATHUTILS_H_\n#define _CHILLISOURCE_CORE_MATH_MATHUTILS_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Math/Random.h>\n\n#include <algorithm>\n#include <cmath>\n#include <limits>\n#include <vector>\n\nnamespace ChilliSource\n{\n    //---------------------------------------------------------\n    /// A group of miscellaneous mathematical functions\n    ///\n    /// @author S McGaw\n    //---------------------------------------------------------\n    namespace MathUtils\n    {\n        const f32 k_pi = 3.1415926536f;\n        \n        //---------------------------------------------------------\n        /// Evaluates whether or not the given integer value is a\n        /// power of two.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param in_value - The value to check.\n        ///\n        /// @return Whether or not it is a power of two.\n        //---------------------------------------------------------\n        bool IsPowerOfTwo(u32 in_value) noexcept;\n        //---------------------------------------------------------\n        /// @author S McGaw\n        ///\n        /// @param Value\n        ///\n        /// @return The closest higher power of two\n        //---------------------------------------------------------\n        u32 NextPowerOfTwo(u32 in_value);\n        //---------------------------------------------------------\n        /// @author S McGaw\n        ///\n        /// @param Angle in degrees\n        ///\n        /// @return Angle in radians\n        //---------------------------------------------------------\n        f32 DegToRad(f32 in_angle);\n        //---------------------------------------------------------\n        /// @author S McGaw\n        ///\n        /// @param Angle in radians\n        ///\n        /// @return Angle in degrees\n        //---------------------------------------------------------\n        f32 RadToDeg(f32 in_angle);\n        //---------------------------------------------------------\n        /// @author A Glass\n        ///\n        /// @param Value\n        /// @param Edge\n        /// @param Min\n        /// @param Max\n        ///\n        /// @return Value >= Edge -> Max Value < Edge -> Min\n        //---------------------------------------------------------\n        template <typename TValueType> TValueType Step(TValueType in_value, TValueType in_edge, TValueType in_min, TValueType in_max)\n        {\n            return (in_value < in_edge) ? in_min : in_max;\n        }\n        //---------------------------------------------------------\n        /// @author A Glass\n        ///\n        /// @param Value to determine sign of\n        ///\n        /// @return Sign +1 if positive -1 if negative 0 if zero\n        //---------------------------------------------------------\n        template<typename TValueType> s32 Sign(TValueType in_value)\n        {\n            return (0 < in_value) - (in_value < 0);\n        }\n        //----------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Value to clamp between range\n        /// @param Lower range value\n        /// @param Higher range value\n        ///\n        /// @return Value within the given range\n        //----------------------------------------------------------\n        template<typename TValueType> TValueType Clamp(TValueType in_value, TValueType in_min, TValueType in_max)\n        {\n            return std::max(in_min, std::min(in_value, in_max));\n        }\n        //---------------------------------------------------------\n        /// Linearly interpolate between the min and max values\n        /// based on parametric t factor (0 - 1)\n        ///\n        /// @author S Downie\n        ///\n        /// @param t factor\n        /// @param Min value in range\n        /// @param Max value in range\n        ///\n        /// @return Linearly interpolated value\n        //---------------------------------------------------------\n        template <typename TValueType> TValueType Lerp(f32 in_factor, TValueType in_min, TValueType in_max)\n        {\n            return in_min * (1.0f - in_factor) + in_max * in_factor;\n        }\n        //---------------------------------------------------------\n        /// Cubicly interpolate between the min and max values\n        /// based on parametric t factor (0 - 1) and the smoothstep\n        /// curve\n        ///\n        /// @author A Glass\n        ///\n        /// @param t factor\n        /// @param Min value in range\n        /// @param Max value in range\n        ///\n        /// @return Cubicly interpolated value\n        //---------------------------------------------------------\n        template <typename TValueType> TValueType SmoothStep(f32 in_factor, TValueType in_min, TValueType in_max)\n        {\n            TValueType t = Clamp((in_min * -1.0f + in_factor)/(in_max - in_min), 0.0f, 1.0f);\n            return t * t * ( t * -2.0f  + 3.0f);\n        }\n        //---------------------------------------------------------\n        /// Interpolate between the min and max values\n        /// based on parametric t factor (0 - 1) and the smootherstep\n        /// curve (Ken Perlin)\n        ///\n        /// @author S Downie\n        ///\n        /// @param t factor\n        /// @param Min value in range\n        /// @param Max value in range\n        ///\n        /// @return Smoother step interpolated value\n        //---------------------------------------------------------\n        template <typename TValueType> TValueType SmootherStep(f32 in_factor, TValueType in_min, TValueType in_max)\n        {\n            TValueType t = Clamp((in_min * -1.0f + in_factor)/(in_max - in_min), 0.0f, 1.0f);\n            return t * t * t * (t * (t * 6.0f - 15.0f) + 10.0f);\n        }\n        //----------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Value\n        ///\n        /// @return If the value is within epsilon of zero\n        //----------------------------------------------------------\n        template <typename TRealType> bool IsApproxZero(TRealType in_value)\n        {\n            return std::abs(in_value) < std::numeric_limits<TRealType>::epsilon();\n        }\n        //----------------------------------------------------------\n        /// Rounds the floating point number to the nearest \n        /// whole number. This is a symmetrical round\n        ///\n        /// @author A Glass\n        ///\n        /// @param Floating point to round\n        ///\n        /// @return Rounded number\n        //----------------------------------------------------------\n        template <typename TRealType> TRealType Round(TRealType in_value)\n        {\n            return TRealType((in_value > 0.0) ? std::floor(in_value + 0.5) : std::ceil(in_value - 0.5));\n        }\n        //----------------------------------------------------\n        /// Calculate the most common value from the given\n        /// data set\n        ///\n        /// @author S Downie\n        ///\n        /// @param Beginning of data set\n        /// @param End of data set\n        ///\n        /// @return Value that occurs most often\n        //----------------------------------------------------\n        template <typename TIterType> typename std::iterator_traits<TIterType>::value_type Mode(TIterType in_begin, TIterType in_end)\n        {\n            typename std::iterator_traits<TIterType>::value_type result = 0;\n            size_t largestcount = 0;\n            \n            for(auto itOuter = in_begin; itOuter != in_end; ++itOuter)\n            {\n                size_t count = 0;\n                \n                for(auto itInner = itOuter; itInner != in_end; ++itInner)\n                {\n                    if(*itOuter == *itInner)\n                    {\n                        ++count;\n                    }\n                }\n                \n                if(count >= largestcount)\n                {\n                    largestcount = count;\n                    result = *itOuter;\n                }\n            }\n            \n            return result;\n        }\n        //----------------------------------------------------\n        /// Calculate the avearge value from the given\n        /// data set\n        ///\n        /// @author S Downie\n        ///\n        /// @param Beginning of data set\n        /// @param End of data set\n        ///\n        /// @return Average value\n        //----------------------------------------------------\n        template <typename TIterType> typename std::iterator_traits<TIterType>::value_type Mean(TIterType in_begin, TIterType in_end)\n        {\n            typename std::iterator_traits<TIterType>::value_type result = 0;\n            \n            size_t size = 0;\n            for(auto it = in_begin; it != in_end; ++it)\n            {\n                result += (*it);\n                ++size;\n            }\n            \n            CS_ASSERT(size > 0, \"MathUtils::Mean: Cannot pass in empty container\");\n            return result/size;\n        }\n        //----------------------------------------------------\n        /// Calculate the mid point of the data set\n        ///\n        /// NOTE: This will re-order the array\n        ///\n        /// @author S Downie\n        ///\n        /// @param Beginning of data set\n        /// @param End of data set\n        ///\n        /// @return Value at mid point\n        //----------------------------------------------------\n        template <typename TIterType> typename std::iterator_traits<TIterType>::value_type Median(TIterType in_begin, TIterType in_end)\n        {\n            std::size_t size = in_end - in_begin;\n            \n            CS_ASSERT(size > 0, \"MathUtils::Median: Cannot pass in empty container\");\n            \n            std::size_t middleIdx = size/2;\n            \n            TIterType itTarget = in_begin + middleIdx;\n            std::nth_element(in_begin, itTarget, in_end);\n            \n            if(size % 2 != 0)\n            {\n                return *itTarget;\n            }\n            else\n            {\n                //Even number of elements\n                typename std::iterator_traits<TIterType>::value_type targetValue = *itTarget;\n                TIterType itTargetNeighbor = std::max_element(in_begin, itTarget);\n                return (targetValue + *itTargetNeighbor)/2.0;\n            }\n        }\n        //---------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param The minimum number that can be returned (inclusive)\n        /// @param The maximum number that can be returned (inclusive)\n        /// @param Number of samples\n        ///\n        /// @return The average of a certain number of random values,\n        /// within the range, as defined by the Central Limit Theorem\n        //---------------------------------------------------------\n        template <typename TValueType> TValueType CentralLimit(TValueType in_min, TValueType in_max, u32 in_numSamples)\n        {\n            CS_ASSERT(in_numSamples != 0, \"Must have at least one sample\");\n            \n            TValueType result = 0;\n            \n            for(u32 i=0; i < in_numSamples; ++i)\n            {\n                result += Random::Generate(in_min, in_max);\n            }\n            \n            return result /= in_numSamples;\n        }\n        //----------------------------------------------------\n        /// Convert the value in the given range to the range\n        /// 0 - 1 using a linear conversion\n        ///\n        /// @author S McGaw\n        ///\n        /// @param Value\n        /// @param Min\n        /// @param Max\n        ///\n        /// @return Value converted to the range 0 - 1\n        //----------------------------------------------------\n        template <typename TValueType> TValueType NormalisedRange(TValueType in_value, TValueType in_originalMin, TValueType in_originalMax)\n        {\n            CS_ASSERT(in_originalMin != in_originalMax, \"Divide by ZERO error\");\n            \n            return (in_value - in_originalMin) / (in_originalMax - in_originalMin);\n        }\n        //----------------------------------------------------\n        /// Convert the value in the given range to the new range\n        /// using a linear conversion\n        ///\n        /// @author S McGaw\n        ///\n        /// @param Value\n        /// @param Min Range 1\n        /// @param Max Range 1\n        /// @param Min Range 2\n        /// @param Max Range 2\n        ///\n        /// @return Value converted to range 2\n        //----------------------------------------------------\n        template <typename TValueType> TValueType ConvertRange(TValueType in_value, TValueType in_originalMin, TValueType in_originalMax, TValueType in_newMin, TValueType in_newMax)\n        {\n            CS_ASSERT(in_originalMin != in_originalMax, \"Divide by ZERO error\");\n            \n            return (((in_value - in_originalMin) * (in_newMax - in_newMin)) / (in_originalMax - in_originalMin)) + in_newMin;\n        }\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Math/Matrix3.h",
    "content": "//\n//  Matrix3.h\n//  ChilliSource\n//  Created by Ian Copland on 26/04/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_MATH_MATRIX3_H_\n#define _CHILLISOURCE_CORE_MATH_MATRIX3_H_\n\n#include <ChilliSource/ChilliSource.h>\n\nnamespace ChilliSource\n{\n    //---------------------------------------------------------------\n    /// A generic 3x3 matrix that provides standard matrix math\n    /// functionality. The matrix is represented internally in\n    /// row major format. Vector multiplication and transformation\n    /// matrices are described using row vector format.Typically this \n    /// would not be used directly instead the f32 typedef Matrix3 \n    /// should be used.\n    ///\n    /// @author Ian Copland\n    //---------------------------------------------------------------\n    template <typename TType> class GenericMatrix3 final\n    {\n    public:\n        //-----------------------------------------------------\n        /// Constants\n        //-----------------------------------------------------\n        static const GenericMatrix3<TType> k_identity;\n        //------------------------------------------------------\n        /// Creates a translation matrix.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param the translation.\n        ///\n        /// @return The new translation matrix.\n        //------------------------------------------------------\n        static GenericMatrix3<TType> CreateTranslation(const GenericVector2<TType>& in_translation);\n        //------------------------------------------------------\n        /// Creates a translation matrix.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param the x translation.\n        /// @param the y translation.\n        ///\n        /// @return The new translation matrix.\n        //------------------------------------------------------\n        static GenericMatrix3<TType> CreateTranslation(TType in_x, TType in_y);\n        //------------------------------------------------------\n        /// Creates a scale matrix.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param the scale.\n        ///\n        /// @return The new scale matrix.\n        //------------------------------------------------------\n        static GenericMatrix3<TType> CreateScale(const GenericVector2<TType>& in_scale);\n        //------------------------------------------------------\n        /// Creates a scale matrix.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param the x scale.\n        /// @param the y scale.\n        ///\n        /// @return The new scale matrix.\n        //------------------------------------------------------\n        static GenericMatrix3<TType> CreateScale(TType in_x, TType in_y);\n        //------------------------------------------------------\n        /// Creates a rotation matrix.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param the rotation.\n        ///\n        /// @return The new rotation matrix.\n        //------------------------------------------------------\n        static GenericMatrix3<TType> CreateRotation(TType in_angle);\n        //------------------------------------------------------\n        /// Creates a transform matrix, built out of a translation\n        /// scale and rotation.\n        ///\n        /// @author S Downie\n        ///\n        /// @param The translation.\n        /// @param The scale.\n        /// @param The rotation angle.\n        ///\n        /// @return The new transform matrix.\n        //------------------------------------------------------\n        static GenericMatrix3<TType> CreateTransform(const GenericVector2<TType>& in_translation, const GenericVector2<TType>& in_scale, TType in_angle);\n        //------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param A matrix.\n        ///\n        /// @return A transposed copy of the matrix.\n        //------------------------------------------------------\n        static GenericMatrix3<TType> Transpose(const GenericMatrix3<TType>& in_matrix);\n        //------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param A matrix.\n        ///\n        /// @return An inverted copy of the matrix.\n        //------------------------------------------------------\n        static GenericMatrix3<TType> Inverse(const GenericMatrix3<TType>& in_matrix);\n        //-----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param A matrix.\n        /// @param A translation vector.\n        ///\n        /// @return A copy of the matrix with the given translation\n        /// applied to it.\n        //-----------------------------------------------------\n        static GenericMatrix3<TType> Translate(const GenericMatrix3<TType>& in_matrix, const GenericVector2<TType>& in_translation);\n        //-----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param A matrix.\n        /// @param The x translation.\n        /// @param The y translation.\n        ///\n        /// @return A copy of the matrix with the given translation\n        /// applied to it.\n        //-----------------------------------------------------\n        static GenericMatrix3<TType> Translate(const GenericMatrix3<TType>& in_matrix, TType in_x, TType in_y);\n        //-----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param A matrix.\n        /// @param A scale vector.\n        ///\n        /// @return A copy of the matrix with the given scale\n        /// applied to it.\n        //-----------------------------------------------------\n        static GenericMatrix3<TType> Scale(const GenericMatrix3<TType>& in_matrix, const GenericVector2<TType>& in_scale);\n        //-----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param A matrix.\n        /// @param The x scale.\n        /// @param The y scale.\n        ///\n        /// @return A copy of the matrix with the given scale\n        /// applied to it.\n        //-----------------------------------------------------\n        static GenericMatrix3<TType> Scale(const GenericMatrix3<TType>& in_matrix, TType in_x, TType in_y);\n        //-----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param A matrix.\n        /// @param A rotation.\n        ///\n        /// @return A copy of the matrix with the given rotation\n        /// applied to it.\n        //-----------------------------------------------------\n        static GenericMatrix3<TType> Rotate(const GenericMatrix3<TType>& in_matrix, TType in_angle);\n        //-----------------------------------------------------\n        /// Constructor. Sets the contents to the identity\n        /// matrix.\n        ///\n        /// @author Ian Copland.\n        //-----------------------------------------------------\n        GenericMatrix3();\n        //-----------------------------------------------------\n        /// Constructor\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The matrix elements in row major format.\n        //-----------------------------------------------------\n        GenericMatrix3(TType in_a0, TType in_a1, TType in_a2, TType in_b0, TType in_b1, TType in_b2, TType in_c0, TType in_c1, TType in_c2);\n        //------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The determinant of this matrix.\n        //------------------------------------------------------\n        TType Determinant() const;\n        //------------------------------------------------------\n        /// @author S Dowie\n        ///\n        /// @param The translation part of the transform.\n        //------------------------------------------------------\n        GenericVector2<TType> GetTranslation() const;\n        //-----------------------------------------------------\n        /// Sets this matrix to the identity matrix.\n        ///\n        /// @author Ian Copland\n        //-----------------------------------------------------\n        void Identity();\n        //-----------------------------------------------------\n        /// Sets this matrix to its transpose.\n        ///\n        /// @author Ian Copland\n        //-----------------------------------------------------\n        void Transpose();\n        //------------------------------------------------------\n        /// Sets this matrix to its inverse.\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------------\n        void Inverse();\n        //-----------------------------------------------------\n        /// Translates this matrix.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param the translation vector.\n        //-----------------------------------------------------\n        void Translate(const GenericVector2<TType>& in_translation);\n        //-----------------------------------------------------\n        /// Translates this matrix.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param the x translation.\n        /// @param the y translation.\n        //-----------------------------------------------------\n        void Translate(TType in_x, TType in_y);\n        //-----------------------------------------------------\n        /// Scales this matrix.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param the scale vector.\n        //-----------------------------------------------------\n        void Scale(const GenericVector2<TType>& in_scale);\n        //-----------------------------------------------------\n        /// Scales this matrix.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param the x scale.\n        /// @param the y scale.\n        //-----------------------------------------------------\n        void Scale(TType in_x, TType in_y);\n        //-----------------------------------------------------\n        /// Rotates the matrix.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param the rotation.\n        //-----------------------------------------------------\n        void Rotate(TType in_angle);\n        //-----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param The row index.\n        /// @param The column index.\n        ///\n        /// @return The value at the given position in the\n        /// matrix. Matrices are row major so this equates to\n        /// the value at position in_row * 3 + in_column.\n        //-----------------------------------------------------\n        TType& operator()(u32 in_row, u32 in_column);\n        //-----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param The row index.\n        /// @param The column index.\n        ///\n        /// @return The value at the given position in the\n        /// matrix. Matrices are row major so this equates to\n        /// the value at position in_row * 3 + in_column.\n        //-----------------------------------------------------\n        TType operator()(u32 in_row, u32 in_column) const;\n        //-----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param Another matrix.\n        ///\n        /// @return This matrix after adding the given matrix\n        /// component-wise.\n        //-----------------------------------------------------\n        GenericMatrix3<TType>& operator+=(const GenericMatrix3<TType>& in_b);\n        //-----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param Another matrix.\n        ///\n        /// @return This matrix after subtracting the given matrix\n        /// component-wise.\n        //-----------------------------------------------------\n        GenericMatrix3<TType>& operator-=(const GenericMatrix3<TType>& in_b);\n        //-----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param Another matrix.\n        ///\n        /// @return This matrix after multiplying by the given\n        /// matrix.\n        //-----------------------------------------------------\n        GenericMatrix3<TType>& operator*=(const GenericMatrix3<TType>& in_b);\n        //-----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param A scalar\n        ///\n        /// @return This matrix after multiplying by the given \n        /// scalar.\n        //-----------------------------------------------------\n        GenericMatrix3<TType>& operator*=(TType in_b);\n        //-----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param A scalar\n        ///\n        /// @return This matrix after dividing by the given \n        /// scalar.\n        //-----------------------------------------------------\n        GenericMatrix3<TType>& operator/=(TType in_b);\n\n        TType m[9];\n    };\n    //-----------------------------------------------------\n    /// @author Ian Copland\n    ///\n    /// @param Matrix A\n    /// @param Matrix B\n    ///\n    /// @return The result of the component-wise addition of\n    /// A and B.\n    //-----------------------------------------------------\n    template <typename TType> GenericMatrix3<TType> operator+(GenericMatrix3<TType> in_a, const GenericMatrix3<TType>& in_b);\n    //-----------------------------------------------------\n    /// @author Ian Copland\n    ///\n    /// @param Matrix A\n    /// @param Matrix B\n    ///\n    /// @return The result of the component-wise subtraction \n    /// of B from A.\n    //-----------------------------------------------------\n    template <typename TType> GenericMatrix3<TType> operator-(GenericMatrix3<TType> in_a, const GenericMatrix3<TType>& in_b);\n    //-----------------------------------------------------\n    /// @author Ian Copland\n    ///\n    /// @param Matrix A\n    /// @param Matrix B\n    ///\n    /// @return The result of A * B\n    //-----------------------------------------------------\n    template <typename TType> GenericMatrix3<TType> operator*(const GenericMatrix3<TType>& in_a, const GenericMatrix3<TType>& in_b);\n    //-----------------------------------------------------\n    /// @author Ian Copland\n    ///\n    /// @param Matrix A\n    /// @param Scalar B\n    ///\n    /// @return The result of A * B\n    //-----------------------------------------------------\n    template <typename TType> GenericMatrix3<TType> operator*(GenericMatrix3<TType> in_a, TType in_b);\n    //-----------------------------------------------------\n    /// @author Ian Copland\n    ///\n    /// @param Scalar A\n    /// @param Matrix B\n    ///\n    /// @return The result of A * B\n    //-----------------------------------------------------\n    template <typename TType> GenericMatrix3<TType> operator*(TType in_a, GenericMatrix3<TType> in_b);\n    //-----------------------------------------------------\n    /// @author Ian Copland\n    ///\n    /// @param Matrix A\n    /// @param Scalar B\n    ///\n    /// @return The result of A / B\n    //-----------------------------------------------------\n    template <typename TType> GenericMatrix3<TType> operator/(GenericMatrix3<TType> in_a, TType in_b);\n    //-----------------------------------------------------\n    /// @author Ian Copland\n    ///\n    /// @param Matrix A\n    /// @param Matrix B\n    ///\n    /// @return Whether or not the matrices are equal.\n    //-----------------------------------------------------\n    template <typename TType> bool operator==(const GenericMatrix3<TType>& in_a, const GenericMatrix3<TType>& in_b);\n    //-----------------------------------------------------\n    /// @author Ian Copland\n    ///\n    /// @param Matrix A\n    /// @param Matrix B\n    ///\n    /// @return Whether or not the matrices are in-equal.\n    //-----------------------------------------------------\n    template <typename TType> bool operator!=(const GenericMatrix3<TType>& in_a, const GenericMatrix3<TType>& in_b);\n}\n\n//----------------------------------------------------\n// These are included here to avoid circular inclusion\n// issues. At this stage the class has been defined\n// which is enough for the classes included to use it.\n//----------------------------------------------------\n#include <ChilliSource/Core/Math/Vector2.h>\n\n#include <cmath>\n\nnamespace ChilliSource\n{\n    template <typename TType> const GenericMatrix3<TType> GenericMatrix3<TType>::k_identity(1, 0, 0, 0, 1, 0, 0, 0, 1);\n\n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> GenericMatrix3<TType> GenericMatrix3<TType>::CreateTranslation(const GenericVector2<TType>& in_translation)\n    {\n        return GenericMatrix3<TType>(1, 0, 0, 0, 1, 0, in_translation.x, in_translation.y, 1);\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> GenericMatrix3<TType> GenericMatrix3<TType>::CreateTranslation(TType in_x, TType in_y)\n    {\n        return CreateTranslation(GenericVector2<TType>(in_x, in_y));\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> GenericMatrix3<TType> GenericMatrix3<TType>::CreateScale(const GenericVector2<TType>& in_scale)\n    {\n        return GenericMatrix3<TType>(in_scale.x, 0, 0, 0, in_scale.y, 0, 0, 0, 1);\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> GenericMatrix3<TType> GenericMatrix3<TType>::CreateScale(TType in_x, TType in_y)\n    {\n        return CreateScale(GenericVector2<TType>(in_x, in_y));\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> GenericMatrix3<TType> GenericMatrix3<TType>::CreateRotation(TType in_angle)\n    {\n        TType sinA = (TType)std::sin(in_angle);\n        TType cosA = (TType)std::cos(in_angle);\n        return GenericMatrix3<TType>(cosA, sinA, 0, -sinA, cosA, 0, 0, 0, 1);\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> GenericMatrix3<TType> GenericMatrix3<TType>::CreateTransform(const GenericVector2<TType>& in_translation, const GenericVector2<TType>& in_scale, TType in_angle)\n    {\n        TType cosA = (TType)std::cos(in_angle);\n        TType sinA = (TType)std::sin(in_angle);\n        return GenericMatrix3<TType>(cosA * in_scale.x, sinA * in_scale.x, 0, -sinA * in_scale.y, cosA * in_scale.y, 0, in_translation.x, in_translation.y, 1);\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> GenericMatrix3<TType> GenericMatrix3<TType>::Transpose(const GenericMatrix3<TType>& in_a)\n    {\n        GenericMatrix3<TType> b;\n        b.m[0] = in_a.m[0]; b.m[1] = in_a.m[3]; b.m[2] = in_a.m[6];\n        b.m[3] = in_a.m[1]; b.m[4] = in_a.m[4]; b.m[5] = in_a.m[7];\n        b.m[6] = in_a.m[2]; b.m[7] = in_a.m[5]; b.m[8] = in_a.m[8];\n        return b;\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> GenericMatrix3<TType> GenericMatrix3<TType>::Inverse(const GenericMatrix3<TType>& in_a)\n    {\n        TType det = in_a.Determinant();\n        if (det == 0)\n        {\n            return in_a;\n        }\n        TType oneOverDet = 1 / det;\n        \n        GenericMatrix3<TType> c;\n        c.m[0] = (in_a.m[4] * in_a.m[8] - in_a.m[5] * in_a.m[7]) * oneOverDet;\n        c.m[1] = (in_a.m[2] * in_a.m[7] - in_a.m[1] * in_a.m[8]) * oneOverDet;\n        c.m[2] = (in_a.m[1] * in_a.m[5] - in_a.m[2] * in_a.m[4]) * oneOverDet;\n        c.m[3] = (in_a.m[5] * in_a.m[6] - in_a.m[3] * in_a.m[8]) * oneOverDet;\n        c.m[4] = (in_a.m[0] * in_a.m[8] - in_a.m[2] * in_a.m[6]) * oneOverDet;\n        c.m[5] = (in_a.m[2] * in_a.m[3] - in_a.m[0] * in_a.m[5]) * oneOverDet;\n        c.m[6] = (in_a.m[3] * in_a.m[7] - in_a.m[4] * in_a.m[6]) * oneOverDet;\n        c.m[7] = (in_a.m[1] * in_a.m[6] - in_a.m[0] * in_a.m[7]) * oneOverDet;\n        c.m[8] = (in_a.m[0] * in_a.m[4] - in_a.m[1] * in_a.m[3]) * oneOverDet;\n        return c;\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> GenericMatrix3<TType> GenericMatrix3<TType>::Translate(const GenericMatrix3<TType>& in_matrix, const GenericVector2<TType>& in_translation)\n    {\n        return in_matrix * CreateTranslation(in_translation);\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> GenericMatrix3<TType> GenericMatrix3<TType>::Translate(const GenericMatrix3<TType>& in_matrix, TType in_x, TType in_y)\n    {\n        return Translate(in_matrix, GenericVector2<TType>(in_x, in_y));\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> GenericMatrix3<TType> GenericMatrix3<TType>::Scale(const GenericMatrix3<TType>& in_matrix, const GenericVector2<TType>& in_scale)\n    {\n        return in_matrix * CreateScale(in_scale);\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> GenericMatrix3<TType> GenericMatrix3<TType>::Scale(const GenericMatrix3<TType>& in_matrix, TType in_x, TType in_y)\n    {\n        return Scale(in_matrix, GenericVector2<TType>(in_x, in_y));\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> GenericMatrix3<TType> GenericMatrix3<TType>::Rotate(const GenericMatrix3<TType>& in_matrix, TType in_angle)\n    {\n        return in_matrix * CreateRotation(in_angle);\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> GenericMatrix3<TType>::GenericMatrix3()\n    {\n        Identity();\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> GenericMatrix3<TType>::GenericMatrix3(TType in_a0, TType in_a1, TType in_a2, TType in_b0, TType in_b1, TType in_b2, TType in_c0, TType in_c1, TType in_c2)\n    {\n        m[0] = in_a0; m[1] = in_a1; m[2] = in_a2;\n        m[3] = in_b0; m[4] = in_b1; m[5] = in_b2;\n        m[6] = in_c0; m[7] = in_c1; m[8] = in_c2;\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> TType GenericMatrix3<TType>::Determinant() const\n    {\n        return m[0] * (m[4] * m[8] - m[5] * m[7]) - m[1] * (m[3] * m[8] - m[5] * m[6]) + m[2] * (m[3] * m[7] - m[4] * m[6]);\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> void GenericMatrix3<TType>::Identity()\n    {\n        m[0] = 1; m[1] = 0; m[2] = 0;\n        m[3] = 0; m[4] = 1; m[5] = 0;\n        m[6] = 0; m[7] = 0; m[8] = 1;\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> void GenericMatrix3<TType>::Transpose()\n    {\n        GenericMatrix3<TType> a = *this;\n        m[0] = a.m[0]; m[1] = a.m[3]; m[2] = a.m[6];\n        m[3] = a.m[1]; m[4] = a.m[4]; m[5] = a.m[7];\n        m[6] = a.m[2]; m[7] = a.m[5]; m[8] = a.m[8];\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> void GenericMatrix3<TType>::Inverse()\n    {\n        *this = Inverse(*this);\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> void GenericMatrix3<TType>::Translate(const GenericVector2<TType>& in_translation)\n    {\n        *this *= CreateTranslation(in_translation);\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> void GenericMatrix3<TType>::Translate(TType in_x, TType in_y)\n    {\n        Translate(GenericVector2<TType>(in_x, in_y));\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> void GenericMatrix3<TType>::Scale(const GenericVector2<TType>& in_scale)\n    {\n        *this *= CreateScale(in_scale);\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> void GenericMatrix3<TType>::Scale(TType in_x, TType in_y)\n    {\n        Scale(GenericVector2<TType>(in_x, in_y));\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> void GenericMatrix3<TType>::Rotate(TType in_angle)\n    {\n        *this *= CreateRotation(in_angle);\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> GenericVector2<TType> GenericMatrix3<TType>::GetTranslation() const\n    {\n        return GenericVector2<TType>(m[6], m[7]);\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> TType& GenericMatrix3<TType>::operator()(u32 in_row, u32 in_column)\n    {\n        CS_ASSERT(in_row >= 0 && in_row < 3 && in_column >= 0 && in_column < 3, \"Trying to access matrix value at [\" + ToString(in_row) + \", \" + ToString(in_column) + \"]\");\n        return m[in_column + in_row * 3];\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> TType GenericMatrix3<TType>::operator()(u32 in_row, u32 in_column) const\n    {\n        CS_ASSERT(in_row >= 0 && in_row < 3 && in_column >= 0 && in_column < 3, \"Trying to access matrix value at [\" + ToString(in_row) + \", \" + ToString(in_column) + \"]\");\n        return m[in_column + in_row * 3];\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> GenericMatrix3<TType>& GenericMatrix3<TType>::operator+=(const GenericMatrix3<TType>& in_b)\n    {\n        m[0] += in_b.m[0]; m[1] += in_b.m[1]; m[2] += in_b.m[2];\n        m[3] += in_b.m[3]; m[4] += in_b.m[4]; m[5] += in_b.m[5];\n        m[6] += in_b.m[6]; m[7] += in_b.m[7]; m[8] += in_b.m[8];\n        return *this;\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> GenericMatrix3<TType>& GenericMatrix3<TType>::operator-=(const GenericMatrix3<TType>& in_b)\n    {\n        m[0] -= in_b.m[0]; m[1] -= in_b.m[1]; m[2] -= in_b.m[2];\n        m[3] -= in_b.m[3]; m[4] -= in_b.m[4]; m[5] -= in_b.m[5];\n        m[6] -= in_b.m[6]; m[7] -= in_b.m[7]; m[8] -= in_b.m[8];\n        return *this;\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> GenericMatrix3<TType>& GenericMatrix3<TType>::operator*=(const GenericMatrix3<TType>& in_b)\n    {\n        Matrix3 c = *this;\n\n        m[0] = c.m[0] * in_b.m[0] + c.m[1] * in_b.m[3] + c.m[2] * in_b.m[6];\n        m[1] = c.m[0] * in_b.m[1] + c.m[1] * in_b.m[4] + c.m[2] * in_b.m[7];\n        m[2] = c.m[0] * in_b.m[2] + c.m[1] * in_b.m[5] + c.m[2] * in_b.m[8];\n\n        m[3] = c.m[3] * in_b.m[0] + c.m[4] * in_b.m[3] + c.m[5] * in_b.m[6];\n        m[4] = c.m[3] * in_b.m[1] + c.m[4] * in_b.m[4] + c.m[5] * in_b.m[7];\n        m[5] = c.m[3] * in_b.m[2] + c.m[4] * in_b.m[5] + c.m[5] * in_b.m[8];\n\n        m[6] = c.m[6] * in_b.m[0] + c.m[7] * in_b.m[3] + c.m[8] * in_b.m[6];\n        m[7] = c.m[6] * in_b.m[1] + c.m[7] * in_b.m[4] + c.m[8] * in_b.m[7];\n        m[8] = c.m[6] * in_b.m[2] + c.m[7] * in_b.m[5] + c.m[8] * in_b.m[8];\n\n        return *this;\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> GenericMatrix3<TType>& GenericMatrix3<TType>::operator*=(TType in_b)\n    {\n        m[0] *= in_b; m[1] *= in_b; m[2] *= in_b;\n        m[3] *= in_b; m[4] *= in_b; m[5] *= in_b;\n        m[6] *= in_b; m[7] *= in_b; m[8] *= in_b;\n        return *this;\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> GenericMatrix3<TType>& GenericMatrix3<TType>::operator/=(TType in_b)\n    {\n        m[0] /= in_b; m[1] /= in_b; m[2] /= in_b;\n        m[3] /= in_b; m[4] /= in_b; m[5] /= in_b;\n        m[6] /= in_b; m[7] /= in_b; m[8] /= in_b;\n        return *this;\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> GenericMatrix3<TType> operator+(GenericMatrix3<TType> in_a, const GenericMatrix3<TType>& in_b)\n    {\n        return (in_a += in_b);\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> GenericMatrix3<TType> operator-(GenericMatrix3<TType> in_a, const GenericMatrix3<TType>& in_b)\n    {\n        return (in_a -= in_b);\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> GenericMatrix3<TType> operator*(const GenericMatrix3<TType>& in_a, const GenericMatrix3<TType>& in_b)\n    {\n        Matrix3 c;\n\n        c.m[0] = in_a.m[0] * in_b.m[0] + in_a.m[1] * in_b.m[3] + in_a.m[2] * in_b.m[6];\n        c.m[1] = in_a.m[0] * in_b.m[1] + in_a.m[1] * in_b.m[4] + in_a.m[2] * in_b.m[7];\n        c.m[2] = in_a.m[0] * in_b.m[2] + in_a.m[1] * in_b.m[5] + in_a.m[2] * in_b.m[8];\n\n        c.m[3] = in_a.m[3] * in_b.m[0] + in_a.m[4] * in_b.m[3] + in_a.m[5] * in_b.m[6];\n        c.m[4] = in_a.m[3] * in_b.m[1] + in_a.m[4] * in_b.m[4] + in_a.m[5] * in_b.m[7];\n        c.m[5] = in_a.m[3] * in_b.m[2] + in_a.m[4] * in_b.m[5] + in_a.m[5] * in_b.m[8];\n\n        c.m[6] = in_a.m[6] * in_b.m[0] + in_a.m[7] * in_b.m[3] + in_a.m[8] * in_b.m[6];\n        c.m[7] = in_a.m[6] * in_b.m[1] + in_a.m[7] * in_b.m[4] + in_a.m[8] * in_b.m[7];\n        c.m[8] = in_a.m[6] * in_b.m[2] + in_a.m[7] * in_b.m[5] + in_a.m[8] * in_b.m[8];\n\n        return c;\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> GenericMatrix3<TType> operator*(GenericMatrix3<TType> in_a, TType in_b)\n    {\n        return (in_a *= in_b);\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> GenericMatrix3<TType> operator*(TType in_a, GenericMatrix3<TType> in_b)\n    {\n        return (in_b *= in_a);\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> GenericMatrix3<TType> operator/(GenericMatrix3<TType> in_a, TType in_b)\n    {\n        return (in_a /= in_b);\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> bool operator==(const GenericMatrix3<TType>& in_a, const GenericMatrix3<TType>& in_b)\n    {\n        for (u32 i = 0; i < 9; ++i)\n        {\n            if (in_a.m[i] != in_b.m[i])\n                return false;\n        }\n        return true;\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> bool operator!=(const GenericMatrix3<TType>& in_a, const GenericMatrix3<TType>& in_b)\n    {\n        return !(in_a == in_b);\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Math/Matrix4.h",
    "content": "//\n//  Matrix4.h\n//  ChilliSource\n//  Created by Ian Copland on 27/04/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_MATH_MATRIX4_H_\n#define _CHILLISOURCE_CORE_MATH_MATRIX4_H_\n\n#include <ChilliSource/ChilliSource.h>\n\nnamespace ChilliSource\n{\n    //-------------------------------------------------------------\n    /// A generic 4x4 matrix that provides standard matrix math\n    /// functionality. The matrix is represented internally in\n    /// row major format. Vector multiplication and transformation\n    /// matrices are described using row vector format.Typically this \n    /// would not be used directly, instead the f32 typedef Matrix4\n    /// should be used.\n    ///\n    /// @author Ian Copland\n    //-------------------------------------------------------------\n    template <typename TType> class GenericMatrix4 final\n    {\n    public:\n        //------------------------------------------------------\n        /// Constants\n        //------------------------------------------------------\n        static const GenericMatrix4<TType> k_identity;\n        //------------------------------------------------------\n        /// Creates a new perspective projection matrix with the \n        /// given parameters. This projection matrix is \"Left\n        /// Handed\" meaning the positive z axis is considered\n        /// to point into the screen.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param the view angle.\n        /// @param the aspect ratio.\n        /// @param the near plane.\n        /// @param the far plane.\n        //------------------------------------------------------\n        static GenericMatrix4<TType> CreatePerspectiveProjectionLH(TType in_viewAngle, TType in_aspectRatio, TType in_near, TType in_far);\n        //------------------------------------------------------\n        /// Creates a new perspective projection matrix with the \n        /// given parameters. This projection matrix is \"Right\n        /// Handed\" meaning the positive z axis is considered\n        /// to point out of the screen.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param the view angle.\n        /// @param the aspect ratio.\n        /// @param the near plane.\n        /// @param the far plane.\n        //------------------------------------------------------\n        static GenericMatrix4<TType> CreatePerspectiveProjectionRH(TType in_viewAngle, TType in_aspectRatio, TType in_near, TType in_far);\n        //------------------------------------------------------\n        /// Creates a new orthographic projection matrix with the \n        /// given parameters.  This projection matrix is \"Left\n        /// Handed\" meaning the positive z axis is considered\n        /// to point into the screen.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param the width.\n        /// @param the height.\n        /// @param the near plane.\n        /// @param the far plane.\n        //------------------------------------------------------\n        static GenericMatrix4<TType> CreateOrthographicProjectionLH(TType in_width, TType in_height, TType in_near, TType in_far);\n        //------------------------------------------------------\n        /// Creates a new orthographic projection matrix with the \n        /// given parameters.  This projection matrix is \"Right\n        /// Handed\" meaning the positive z axis is considered\n        /// to point out of the screen.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param the width.\n        /// @param the height.\n        /// @param the near plane.\n        /// @param the far plane.\n        //------------------------------------------------------\n        static GenericMatrix4<TType> CreateOrthographicProjectionRH(TType in_width, TType in_height, TType in_near, TType in_far);\n        //------------------------------------------------------\n        /// Creates a new orthographic projection matrix with the \n        /// given parameters.  This projection matrix is \"Left\n        /// Handed\" meaning the positive z axis is considered\n        /// to point into the screen.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param the left side.\n        /// @param The right side.\n        /// @param The bottom.\n        /// @param The top.\n        /// @param the near.\n        /// @param The far.\n        //------------------------------------------------------\n        static GenericMatrix4<TType> CreateOrthographicProjectionLH(TType in_left, f32 in_right, f32 in_bottom, f32 in_top, f32 in_near, f32 in_far);\n        //------------------------------------------------------\n        /// Creates a new orthographic projection matrix with the \n        /// given parameters.  This projection matrix is \"Right\n        /// Handed\" meaning the positive z axis is considered\n        /// to point out of the screen.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param the left side.\n        /// @param The right side.\n        /// @param The bottom.\n        /// @param The top.\n        /// @param the near.\n        /// @param The far.\n        //------------------------------------------------------\n        static GenericMatrix4<TType> CreateOrthographicProjectionRH(TType in_left, f32 in_right, f32 in_bottom, f32 in_top, f32 in_near, f32 in_far);\n        //------------------------------------------------------\n        /// Creates a new \"look-at\" matrix with the given camera\n        /// position, look at and up vector.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param the position.\n        /// @param the look at.\n        /// @param the up.\n        //------------------------------------------------------\n        static GenericMatrix4<TType> CreateLookAt(const GenericVector3<TType>& in_position, const GenericVector3<TType>& in_target, const GenericVector3<TType>& in_up);\n        //------------------------------------------------------\n        /// Create a new translation matrix.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The translation.\n        //------------------------------------------------------\n        static GenericMatrix4<TType> CreateTranslation(const GenericVector3<TType>& in_translation);\n        //------------------------------------------------------\n        /// Create a new translation matrix.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The x translation.\n        /// @param The y translation.\n        /// @param The z translation.\n        //------------------------------------------------------\n        static GenericMatrix4<TType> CreateTranslation(TType in_x, TType in_y, TType in_z);\n        //------------------------------------------------------\n        /// Creates a new scale matrix.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The scale.\n        //------------------------------------------------------\n        static GenericMatrix4<TType> CreateScale(const GenericVector3<TType>& in_scale);\n        //------------------------------------------------------\n        /// Create a new scale matrix.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The x scale.\n        /// @param The y scale.\n        /// @param The z scale.\n        //------------------------------------------------------\n        static GenericMatrix4<TType> CreateScale(TType in_x, TType in_y, TType in_z);\n        //------------------------------------------------------\n        /// Create a new matrix that describes a rotation\n        /// arround the x axis.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The angle of the rotation in radians.\n        //------------------------------------------------------\n        static GenericMatrix4<TType> CreateRotationX(TType in_angle);\n        //------------------------------------------------------\n        /// Create a new matrix that describes a rotation\n        /// arround the y axis.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The angle of the rotation in radians.\n        //------------------------------------------------------\n        static GenericMatrix4<TType> CreateRotationY(TType in_angle);\n        //------------------------------------------------------\n        /// Create a new matrix that describes a rotation\n        /// arround the y axis.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The angle of the rotation in radians.\n        //------------------------------------------------------\n        static GenericMatrix4<TType> CreateRotationZ(TType in_angle);\n        //------------------------------------------------------\n        /// Creates a rotation matrix from a quaternion.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param the quaternion.\n        //------------------------------------------------------\n        static GenericMatrix4<TType> CreateRotation(const GenericQuaternion<TType>& in_rotation);\n        //------------------------------------------------------\n        /// Creates a rotation matrix arround the given axis\n        /// by the given angle.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param the axis.\n        /// @param The angle.\n        //------------------------------------------------------\n        static GenericMatrix4<TType> CreateRotation(const GenericVector3<TType>& in_axis, TType in_angle);\n        //------------------------------------------------------\n        /// Creates a transform matrix, built out of a translation\n        /// scale and rotation.\n        ///\n        /// @author S Downie\n        ///\n        /// @param The translation.\n        /// @param The scale.\n        /// @param The rotation quaternion.\n        ///\n        /// @return The new transform matrix.\n        //------------------------------------------------------\n        static GenericMatrix4<TType> CreateTransform(const GenericVector3<TType>& in_translation, const GenericVector3<TType>& in_scale, const GenericQuaternion<TType>& in_rotation);\n        //------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param A matrix.\n        ///\n        /// @return A transposed copy of the matrix.\n        //------------------------------------------------------\n        static GenericMatrix4<TType> Transpose(const GenericMatrix4<TType>& in_a);\n        //------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param A matrix.\n        ///\n        /// @return An inverted copy of the matrix.\n        //------------------------------------------------------\n        static GenericMatrix4<TType> Inverse(const GenericMatrix4<TType>& in_a);\n        //------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param A matrix.\n        /// @param A translation vector.\n        ///\n        /// @return A copy of the matrix with the given translation\n        /// applied to it.\n        //------------------------------------------------------\n        static GenericMatrix4<TType> Translate(const GenericMatrix4<TType>& in_a, const GenericVector3<TType>& in_translation);\n        //------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param A matrix.\n        /// @param The x translation.\n        /// @param The y translation.\n        /// @param The z translation.\n        ///\n        /// @return A copy of the matrix with the given translation\n        /// applied to it.\n        //------------------------------------------------------\n        static GenericMatrix4<TType> Translate(const GenericMatrix4<TType>& in_a, TType in_x, TType in_y, TType in_z);\n        //------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param A matrix.\n        /// @param A scale vector.\n        ///\n        /// @return A copy of the matrix with the given scale\n        /// applied to it.\n        //------------------------------------------------------\n        static GenericMatrix4<TType> Scale(const GenericMatrix4<TType>& in_a, const GenericVector3<TType>& in_scale);\n        //------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param A matrix.\n        /// @param The x scale.\n        /// @param The y scale.\n        /// @param The z scale.\n        ///\n        /// @return A copy of the matrix with the given scale\n        /// applied to it.\n        //------------------------------------------------------\n        static GenericMatrix4<TType> Scale(const GenericMatrix4<TType>& in_a, TType in_x, TType in_y, TType in_z);\n        //------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param A matrix.\n        /// @param A rotation angle.\n        ///\n        /// @return A copy of the matrix with the given X axis\n        /// rotation applied to it.\n        //------------------------------------------------------\n        static GenericMatrix4<TType> RotateX(const GenericMatrix4<TType>& in_a, TType in_angle);\n        //------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param A matrix.\n        /// @param A rotation angle.\n        ///\n        /// @return A copy of the matrix with the given Y axis\n        /// rotation applied to it.\n        //------------------------------------------------------\n        static GenericMatrix4<TType> RotateY(const GenericMatrix4<TType>& in_a, TType in_angle);\n        //------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param A matrix.\n        /// @param A rotation angle.\n        ///\n        /// @return A copy of the matrix with the given Z axis\n        /// rotation applied to it.\n        //------------------------------------------------------\n        static GenericMatrix4<TType> RotateZ(const GenericMatrix4<TType>& in_a, TType in_angle);\n        //------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param A matrix.\n        /// @param A orientation quaternion.\n        ///\n        /// @return A copy of the matrix with the given rotation\n        /// applied to it.\n        //------------------------------------------------------\n        static GenericMatrix4<TType> Rotate(const GenericMatrix4<TType>& in_a, const GenericQuaternion<TType>& in_orientation);\n        //------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param A matrix.\n        /// @param The axis to rotate around.\n        /// @param The angle to rotate through.\n        ///\n        /// @return A copy of the matrix with the given rotation\n        /// applied to it.\n        //------------------------------------------------------\n        static GenericMatrix4<TType> Rotate(const GenericMatrix4<TType>& in_a, const GenericVector3<TType>& in_axis, TType in_angle);\n        //------------------------------------------------------\n        /// Constructor. Sets the contents of the matrix to the\n        /// identity matrix.\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------------\n        GenericMatrix4();\n        //------------------------------------------------------\n        /// Constructor\n        ///\n        /// @author Ian Copland\n        ///\n        /// @params The 16 matrix elements in row major format.\n        //------------------------------------------------------\n        GenericMatrix4(TType in_a0, TType in_a1, TType in_a2, TType in_a3, TType in_b0, TType in_b1, TType in_b2, TType in_b3, TType in_c0, TType in_c1, TType in_c2, TType in_c3, TType in_d0, TType in_d1, TType in_d2, TType in_d3);\n        //------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The determinant of this matrix.\n        //------------------------------------------------------\n        TType Determinant() const;\n        //------------------------------------------------------\n        /// Sets this matrix to the identity matrix.\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------------\n        void Identity();\n        //------------------------------------------------------\n        /// Sets this matrix to its transpose.\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------------\n        void Transpose();\n        //------------------------------------------------------\n        /// Sets this matrix to its inverse.\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------------\n        void Inverse();\n        //------------------------------------------------------\n        /// Translate this matrix.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param the translation vector\n        //------------------------------------------------------\n        void Translate(const GenericVector3<TType>& in_translation);\n        //------------------------------------------------------\n        /// Translate this matrix.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param the x translation.\n        /// @param the y translation.\n        /// @param the z translation.\n        //------------------------------------------------------\n        void Translate(TType in_x, TType in_y, TType in_z);\n        //------------------------------------------------------\n        /// Scales this matrix\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param the scale vector\n        //------------------------------------------------------\n        void Scale(const GenericVector3<TType>& in_scale);\n        //------------------------------------------------------\n        /// Scales this matrix\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param the x scale.\n        /// @param the y scale.\n        /// @param the z scale.\n        //------------------------------------------------------\n        void Scale(TType in_x, TType in_y, TType in_z);\n        //------------------------------------------------------\n        /// Rotates arround the x axis.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The rotation angle in radians.\n        //------------------------------------------------------\n        void RotateX(TType in_angle);\n        //------------------------------------------------------\n        /// Rotates arround the y axis.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The rotation angle in radians.\n        //------------------------------------------------------\n        void RotateY(TType in_angle);\n        //------------------------------------------------------\n        /// Rotates arround the z axis.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The rotation angle in radians.\n        //------------------------------------------------------\n        void RotateZ(TType in_angle);\n        //------------------------------------------------------\n        /// Rotates the matrix by the given quaternion rotation.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param the rotation quaternion.\n        //------------------------------------------------------\n        void Rotate(const GenericQuaternion<TType>& in_orientation);\n        //------------------------------------------------------\n        /// Rotates the matrix by the given rotation.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The axis to rotate around.\n        /// @param The angle to rotate though.\n        //------------------------------------------------------\n        void Rotate(const GenericVector3<TType>& in_axis, TType in_angle);\n        //------------------------------------------------------\n        /// @author S Dowie\n        ///\n        /// @param The right vector.\n        //------------------------------------------------------\n        GenericVector3<TType> GetRight() const;\n        //------------------------------------------------------\n        /// @author S Dowie\n        ///\n        /// @param The up vector.\n        //------------------------------------------------------\n        GenericVector3<TType> GetUp() const;\n        //------------------------------------------------------\n        /// @author S Dowie\n        ///\n        /// @param The forward vector.\n        //------------------------------------------------------\n        GenericVector3<TType> GetForward() const;\n        //------------------------------------------------------\n        /// @author S Dowie\n        ///\n        /// @param The translation part of the transform. \n        //------------------------------------------------------\n        GenericVector3<TType> GetTranslation() const;\n        //------------------------------------------------------\n        /// Decompose the matrix into the transform, scale and\n        /// rotation it was created with. \n        ///\n        /// @author S Downie\n        ///\n        /// @param [Out] The translation part of the transform.\n        /// @param [Out] The scale part of the transform.\n        /// @param [Out] The rotation part of the transform.\n        //------------------------------------------------------\n        void Decompose(GenericVector3<TType>& out_translation, GenericVector3<TType> & out_scale, GenericQuaternion<TType> & out_orientation) const;\n        //-----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param The row index.\n        /// @param The column index.\n        ///\n        /// @return The value at the given position in the\n        /// matrix. Matrices are row major so this equates to\n        /// the value at position in_row * 4 + in_column.\n        //-----------------------------------------------------\n        TType& operator()(u32 in_row, u32 in_column);\n        //-----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param The row index.\n        /// @param The column index.\n        ///\n        /// @return The value at the given position in the\n        /// matrix. Matrices are row major so this equates to\n        /// the value at position in_row * 4 + in_column.\n        //-----------------------------------------------------\n        TType operator()(u32 in_row, u32 in_column) const;\n        //-----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param Another matrix.\n        ///\n        /// @return This matrix after adding the given matrix\n        /// component-wise.\n        //-----------------------------------------------------\n        GenericMatrix4<TType>& operator+=(const GenericMatrix4<TType>& in_b);\n        //-----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param Another matrix.\n        ///\n        /// @return This matrix after subtracting the given matrix\n        /// component-wise.\n        //-----------------------------------------------------\n        GenericMatrix4<TType>& operator-=(const GenericMatrix4<TType>& in_b);\n        //-----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param Another matrix.\n        ///\n        /// @return This matrix after multiplying by the given\n        /// matrix.\n        //-----------------------------------------------------\n        GenericMatrix4<TType>& operator*=(const GenericMatrix4<TType>& in_b);\n        //-----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param A scalar.\n        ///\n        /// @return This matrix after multiplying by the given\n        /// scalar.\n        //-----------------------------------------------------\n        GenericMatrix4<TType>& operator*=(TType in_b);\n        //-----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param A scalar.\n        ///\n        /// @return This matrix after dividing by the given\n        /// scalar.\n        //-----------------------------------------------------\n        GenericMatrix4<TType>& operator/=(TType in_b);\n\n        TType m[16];\n    };\n    //-----------------------------------------------------\n    /// @author Ian Copland\n    ///\n    /// @param The matrix A.\n    /// @param The matrix B.\n    ///\n    /// @return The result of A + B.\n    //-----------------------------------------------------\n    template <typename TType> GenericMatrix4<TType> operator+(GenericMatrix4<TType> in_a, const GenericMatrix4<TType>& in_b);\n    //-----------------------------------------------------\n    /// @author Ian Copland\n    ///\n    /// @param The matrix A.\n    /// @param The matrix B.\n    ///\n    /// @return The result of A - B.\n    //-----------------------------------------------------\n    template <typename TType> GenericMatrix4<TType> operator-(GenericMatrix4<TType> in_a, const GenericMatrix4<TType>& in_b);\n    //-----------------------------------------------------\n    /// @author Ian Copland\n    ///\n    /// @param The matrix A.\n    /// @param The matrix B.\n    ///\n    /// @return The result of A * B.\n    //-----------------------------------------------------\n    template <typename TType> GenericMatrix4<TType> operator*(const GenericMatrix4<TType>& in_a, const GenericMatrix4<TType>& in_b);\n    //-----------------------------------------------------\n    /// @author Ian Copland\n    ///\n    /// @param The matrix A.\n    /// @param The scalar B.\n    ///\n    /// @return The result of A * B.\n    //-----------------------------------------------------\n    template <typename TType> GenericMatrix4<TType> operator*(GenericMatrix4<TType> in_a, TType in_b);\n    //-----------------------------------------------------\n    /// @author Ian Copland\n    ///\n    /// @param The scalar A.\n    /// @param The matrix B.\n    ///\n    /// @return The result of A * B.\n    //-----------------------------------------------------\n    template <typename TType> GenericMatrix4<TType> operator*(TType in_a, GenericMatrix4<TType> in_b);\n    //-----------------------------------------------------\n    /// @author Ian Copland\n    ///\n    /// @param The matrix A.\n    /// @param The scalar B.\n    ///\n    /// @return The result of A / B.\n    //-----------------------------------------------------\n    template <typename TType> GenericMatrix4<TType> operator/(GenericMatrix4<TType> in_a, TType in_b);\n    //-----------------------------------------------------\n    /// @author Ian Copland\n    ///\n    /// @param The matrix A.\n    /// @param The matrix B.\n    ///\n    /// @return Whether or not the matrices are equal.\n    //-----------------------------------------------------\n    template <typename TType> bool operator==(const GenericMatrix4<TType>& in_a, const GenericMatrix4<TType>& in_b);\n    //-----------------------------------------------------\n    /// @author Ian Copland\n    ///\n    /// @param The matrix A.\n    /// @param The matrix B.\n    ///\n    /// @return Whether or not the matrices are in-equal.\n    //-----------------------------------------------------\n    template <typename TType> bool operator!=(const GenericMatrix4<TType>& in_a, const GenericMatrix4<TType>& in_b);\n}\n\n\n//----------------------------------------------------\n// These are included here to avoid circular inclusion\n// issues. At this stage the class has been defined\n// which is enough for the classes included to use it.\n//----------------------------------------------------\n#include <ChilliSource/Core/Math/Quaternion.h>\n#include <ChilliSource/Core/Math/Vector3.h>\n#include <ChilliSource/Core/Math/Vector4.h>\n\n#include <cmath>\n\nnamespace ChilliSource\n{\n    template <typename TType> const GenericMatrix4<TType> GenericMatrix4<TType>::k_identity(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);\n    \n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> GenericMatrix4<TType> GenericMatrix4<TType>::CreatePerspectiveProjectionLH(TType in_viewAngle, TType in_aspectRatio, TType in_near, TType in_far)\n    {\n        TType b1 = 1 / (TType)std::tan(in_viewAngle * 0.5);\n        TType a0 = b1 / in_aspectRatio;\n        TType c2 = (in_far + in_near) / (in_far - in_near);\n        TType d2 = -(2 * in_far * in_near) / (in_far - in_near);\n        return GenericMatrix4<TType>(\n            a0, 0, 0, 0, \n            0, b1, 0, 0, \n            0, 0, c2, 1, \n            0, 0, d2, 0);\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> GenericMatrix4<TType> GenericMatrix4<TType>::CreatePerspectiveProjectionRH(TType in_viewAngle, TType in_aspectRatio, TType in_near, TType in_far)\n    {\n        TType b1 = 1 / (TType)std::tan(in_viewAngle * 0.5);\n        TType a0 = b1 / in_aspectRatio;\n        TType c2 = (in_near + in_far) / (in_near - in_far);\n        TType d2 = (2 * in_near * in_far) /  (in_near - in_far);\n        return GenericMatrix4<TType>(\n            a0, 0, 0, 0, \n            0, b1, 0, 0,\n            0, 0, c2, -1,\n            0, 0, d2, 0);\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> GenericMatrix4<TType> GenericMatrix4<TType>::CreateOrthographicProjectionLH(TType in_width, TType in_height, TType in_near, TType in_far)\n    {\n        TType a0 = 2 / in_width;\n        TType b1 = 2 / in_height;\n        TType c2 = 2 / (in_far - in_near);\n        TType d2 = (in_far + in_near) / (in_near - in_far);\n        return GenericMatrix4<TType>(\n            a0, 0, 0, 0, \n            0, b1, 0, 0, \n            0, 0, c2, 0,\n            0, 0, d2, 1);\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> GenericMatrix4<TType> GenericMatrix4<TType>::CreateOrthographicProjectionRH(TType in_width, TType in_height, TType in_near, TType in_far)\n    {\n        TType a0 = 2 / in_width;\n        TType b1 = 2 / in_height;\n        TType c2 = -2 / (in_far - in_near);\n        TType d2 = -(in_near + in_far) / (in_far - in_near);\n        return GenericMatrix4<TType>(\n            a0, 0, 0, 0, \n            0, b1, 0, 0, \n            0, 0, c2, 0, \n            0, 0, d2, 1);\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> GenericMatrix4<TType> GenericMatrix4<TType>::CreateOrthographicProjectionLH(TType in_left, f32 in_right, f32 in_bottom, f32 in_top, f32 in_near, f32 in_far)\n    {\n        TType a0 = 2 / (in_right - in_left);\n        TType b1 = 2 / (in_top - in_bottom);\n        TType c2 = 2 / (in_far - in_near);\n        TType d0 = -(in_right + in_left) / (in_right - in_left);\n        TType d1 = -(in_top + in_bottom) / (in_top - in_bottom);\n        TType d2 = (in_near + in_far) / (in_far - in_near);\n        return GenericMatrix4<TType>(\n            a0, 0, 0, 0,\n            0, b1, 0, 0,\n            0, 0, c2, 0,\n            d0, d1, d2, 1);\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> GenericMatrix4<TType> GenericMatrix4<TType>::CreateOrthographicProjectionRH(TType in_left, f32 in_right, f32 in_bottom, f32 in_top, f32 in_near, f32 in_far)\n    {\n        TType a0 = 2 / (in_right - in_left);\n        TType b1 = 2 / (in_top - in_bottom);\n        TType c2 = -2 / (in_far - in_near);\n        TType d0 = -(in_right + in_left) / (in_right - in_left);\n        TType d1 = -(in_top + in_bottom) / (in_top - in_bottom);\n        TType d2 = -(in_near + in_far) / (in_far - in_near);\n        return GenericMatrix4<TType>(\n            a0, 0, 0, 0, \n            0, b1, 0, 0, \n            0, 0, c2, 0, \n            d0, d1, d2, 1);\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> GenericMatrix4<TType> GenericMatrix4<TType>::CreateLookAt(const GenericVector3<TType>& in_position, const GenericVector3<TType>& in_target, const GenericVector3<TType>& in_up)\n    {\n        GenericVector3<TType> zAxis = in_target - in_position;\n        zAxis.Normalise();\n        GenericVector3<TType> xAxis = GenericVector3<TType>::CrossProduct(in_up, zAxis);\n        xAxis.Normalise();\n        GenericVector3<TType> yAxis = GenericVector3<TType>::CrossProduct(zAxis, xAxis);\n        TType dotX = GenericVector3<TType>::DotProduct(xAxis, in_position);\n        TType dotY = GenericVector3<TType>::DotProduct(yAxis, in_position);\n        TType dotZ = GenericVector3<TType>::DotProduct(zAxis, in_position);\n\n        GenericMatrix4<TType> m;\n        m.m[0] = xAxis.x;\t\tm.m[1] = yAxis.x;\t\tm.m[2] = zAxis.x;\t\tm.m[3] = 0;\n        m.m[4] = xAxis.y;\t\tm.m[5] = yAxis.y;\t\tm.m[6] = zAxis.y;\t\tm.m[7] = 0;\n        m.m[8] = xAxis.z;\t\tm.m[9] = yAxis.z;\t\tm.m[10] = zAxis.z;\t\tm.m[11] = 0;\n        m.m[12] = -dotX;\t\tm.m[13] = -dotY;\t\tm.m[14] = -dotZ;\t\tm.m[15] = 1;\n        return m;\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> GenericMatrix4<TType> GenericMatrix4<TType>::CreateTranslation(const GenericVector3<TType>& in_translation)\n    {\n        return GenericMatrix4<TType>(\n            1, 0, 0, 0, \n            0, 1, 0, 0, \n            0, 0, 1, 0, \n            in_translation.x, in_translation.y, in_translation.z, 1);\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> GenericMatrix4<TType> GenericMatrix4<TType>::CreateTranslation(TType in_x, TType in_y, TType in_z)\n    {\n        return CreateTranslation(GenericVector3<TType>(in_x, in_y, in_z));\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> GenericMatrix4<TType> GenericMatrix4<TType>::CreateScale(const GenericVector3<TType>& in_scale)\n    {\n        return GenericMatrix4<TType>(\n            in_scale.x, 0, 0, 0,\n            0, in_scale.y, 0, 0, \n            0, 0, in_scale.z, 0, \n            0, 0, 0, 1);\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> GenericMatrix4<TType> GenericMatrix4<TType>::CreateScale(TType in_x, TType in_y, TType in_z)\n    {\n        return CreateScale(GenericVector3<TType>(in_x, in_y, in_z));\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> GenericMatrix4<TType> GenericMatrix4<TType>::CreateRotationX(TType in_angle)\n    {\n        TType sinA = (TType)std::sin(in_angle);\n        TType cosA = (TType)std::cos(in_angle);\n        return GenericMatrix4<TType>(\n            1, 0, 0, 0, \n            0, cosA, sinA, 0, \n            0, -sinA, cosA, 0, \n            0, 0, 0, 1);\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> GenericMatrix4<TType> GenericMatrix4<TType>::CreateRotationY(TType in_angle)\n    {\n        TType sinA = (TType)std::sin(in_angle);\n        TType cosA = (TType)std::cos(in_angle);\n        return GenericMatrix4<TType>(\n            cosA, 0, -sinA, 0, \n            0, 1, 0, 0, \n            sinA, 0, cosA, 0, \n            0, 0, 0, 1);\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> GenericMatrix4<TType> GenericMatrix4<TType>::CreateRotationZ(TType in_angle)\n    {\n        TType sinA = (TType)std::sin(in_angle);\n        TType cosA = (TType)std::cos(in_angle);\n        return GenericMatrix4<TType>(\n            cosA, sinA, 0, 0, \n            -sinA, cosA, 0, 0, \n            0, 0, 1, 0, \n            0, 0, 0, 1);\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> GenericMatrix4<TType> GenericMatrix4<TType>::CreateRotation(const GenericQuaternion<TType>& in_rotation)\n    {\n        GenericQuaternion<TType> q = GenericQuaternion<TType>::Normalise(in_rotation);\n\n        TType wSquared = q.w * q.w;\n        TType xSquared = q.x * q.x;\n        TType ySquared = q.y * q.y;\n        TType zSquared = q.z * q.z;\n\n        TType a = wSquared + xSquared - ySquared - zSquared;\n        TType b = 2 * q.x * q.y + 2 * q.w * q.z;\n        TType c = 2 * q.x * q.z - 2 * q.w * q.y;\n        TType d = 0;\n        TType e = 2 * q.x * q.y - 2 * q.w * q.z;\n        TType f = wSquared - xSquared + ySquared - zSquared;\n        TType g = 2 * q.y * q.z + 2 * q.w * q.x;\n        TType h = 0;\n        TType i = 2 * q.x * q.z + 2 * q.w * q.y;\n        TType j = 2 * q.y * q.z - 2 * q.w * q.x;\n        TType k = wSquared - xSquared - ySquared + zSquared;\n        TType l = 0;\n        TType m = 0;\n        TType n = 0;\n        TType o = 0;\n        TType p = 1;\n\n        return GenericMatrix4<TType>(\n            a, b, c, d,\n            e, f, g, h,\n            i, j, k, l,\n            m, n, o, p);\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> GenericMatrix4<TType> GenericMatrix4<TType>::CreateRotation(const GenericVector3<TType>& in_axis, TType in_angle)\n    {\n        return CreateRotation(GenericQuaternion<TType>(in_axis, in_angle));\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> GenericMatrix4<TType> GenericMatrix4<TType>::CreateTransform(const GenericVector3<TType>& in_translation, const GenericVector3<TType>& in_scale, const GenericQuaternion<TType>& in_rotation)\n    {\n        GenericMatrix4<TType> rotation = CreateRotation(in_rotation);\n\n        return GenericMatrix4<TType>(\n            in_scale.x * rotation.m[0], in_scale.x * rotation.m[1], in_scale.x * rotation.m[2], 0,\n            in_scale.y * rotation.m[4], in_scale.y * rotation.m[5], in_scale.y * rotation.m[6], 0,\n            in_scale.z * rotation.m[8], in_scale.z * rotation.m[9], in_scale.z * rotation.m[10], 0,\n            in_translation.x, in_translation.y, in_translation.z, 1);\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> GenericMatrix4<TType> GenericMatrix4<TType>::Transpose(const GenericMatrix4<TType>& in_a)\n    {\n        return GenericMatrix4<TType>(\n            in_a.m[0], in_a.m[4], in_a.m[8], in_a.m[12],\n            in_a.m[1], in_a.m[5], in_a.m[9], in_a.m[13],\n            in_a.m[2], in_a.m[6], in_a.m[10], in_a.m[14],\n            in_a.m[3], in_a.m[7], in_a.m[11], in_a.m[15]);\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> GenericMatrix4<TType> GenericMatrix4<TType>::Inverse(const GenericMatrix4<TType>& in_a)\n    {\n        TType det = in_a.Determinant();\n        if (det == 0)\n        {\n            return in_a;\n        }\n        \n        GenericMatrix4<TType> b;\n        b.m[0] = (in_a.m[6] * in_a.m[11] * in_a.m[13] - in_a.m[7] * in_a.m[10] * in_a.m[13] + in_a.m[7] * in_a.m[9] * in_a.m[14] - in_a.m[5] * in_a.m[11] * in_a.m[14] - in_a.m[6] * in_a.m[9] * in_a.m[15] + in_a.m[5] * in_a.m[10] * in_a.m[15]) / det;\n        b.m[1] = (in_a.m[3] * in_a.m[10] * in_a.m[13] - in_a.m[2] * in_a.m[11] * in_a.m[13] - in_a.m[3] * in_a.m[9] * in_a.m[14] + in_a.m[1] * in_a.m[11] * in_a.m[14] + in_a.m[2] * in_a.m[9] * in_a.m[15] - in_a.m[1] * in_a.m[10] * in_a.m[15]) / det;\n        b.m[2] = (in_a.m[2] * in_a.m[7] * in_a.m[13] - in_a.m[3] * in_a.m[6] * in_a.m[13] + in_a.m[3] * in_a.m[5] * in_a.m[14] - in_a.m[1] * in_a.m[7] * in_a.m[14] - in_a.m[2] * in_a.m[5] * in_a.m[15] + in_a.m[1] * in_a.m[6] * in_a.m[15]) / det;\n        b.m[3] = (in_a.m[3] * in_a.m[6] * in_a.m[9] - in_a.m[2] * in_a.m[7] * in_a.m[9] - in_a.m[3] * in_a.m[5] * in_a.m[10] + in_a.m[1] * in_a.m[7] * in_a.m[10] + in_a.m[2] * in_a.m[5] * in_a.m[11] - in_a.m[1] * in_a.m[6] * in_a.m[11]) / det;\n        b.m[4] = (in_a.m[7] * in_a.m[10] * in_a.m[12] - in_a.m[6] * in_a.m[11] * in_a.m[12] - in_a.m[7] * in_a.m[8] * in_a.m[14] + in_a.m[4] * in_a.m[11] * in_a.m[14] + in_a.m[6] * in_a.m[8] * in_a.m[15] - in_a.m[4] * in_a.m[10] * in_a.m[15]) / det;\n        b.m[5] = (in_a.m[2] * in_a.m[11] * in_a.m[12] - in_a.m[3] * in_a.m[10] * in_a.m[12] + in_a.m[3] * in_a.m[8] * in_a.m[14] - in_a.m[0] * in_a.m[11] * in_a.m[14] - in_a.m[2] * in_a.m[8] * in_a.m[15] + in_a.m[0] * in_a.m[10] * in_a.m[15]) / det;\n        b.m[6] = (in_a.m[3] * in_a.m[6] * in_a.m[12] - in_a.m[2] * in_a.m[7] * in_a.m[12] - in_a.m[3] * in_a.m[4] * in_a.m[14] + in_a.m[0] * in_a.m[7] * in_a.m[14] + in_a.m[2] * in_a.m[4] * in_a.m[15] - in_a.m[0] * in_a.m[6] * in_a.m[15]) / det;\n        b.m[7] = (in_a.m[2] * in_a.m[7] * in_a.m[8] - in_a.m[3] * in_a.m[6] * in_a.m[8] + in_a.m[3] * in_a.m[4] * in_a.m[10] - in_a.m[0] * in_a.m[7] * in_a.m[10] - in_a.m[2] * in_a.m[4] * in_a.m[11] + in_a.m[0] * in_a.m[6] * in_a.m[11]) / det;\n        b.m[8] = (in_a.m[5] * in_a.m[11] * in_a.m[12] - in_a.m[7] * in_a.m[9] * in_a.m[12] + in_a.m[7] * in_a.m[8] * in_a.m[13] - in_a.m[4] * in_a.m[11] * in_a.m[13] - in_a.m[5] * in_a.m[8] * in_a.m[15] + in_a.m[4] * in_a.m[9] * in_a.m[15]) / det;\n        b.m[9] = (in_a.m[3] * in_a.m[9] * in_a.m[12] - in_a.m[1] * in_a.m[11] * in_a.m[12] - in_a.m[3] * in_a.m[8] * in_a.m[13] + in_a.m[0] * in_a.m[11] * in_a.m[13] + in_a.m[1] * in_a.m[8] * in_a.m[15] - in_a.m[0] * in_a.m[9] * in_a.m[15]) / det;\n        b.m[10] = (in_a.m[1] * in_a.m[7] * in_a.m[12] - in_a.m[3] * in_a.m[5] * in_a.m[12] + in_a.m[3] * in_a.m[4] * in_a.m[13] - in_a.m[0] * in_a.m[7] * in_a.m[13] - in_a.m[1] * in_a.m[4] * in_a.m[15] + in_a.m[0] * in_a.m[5] * in_a.m[15]) / det;\n        b.m[11] = (in_a.m[3] * in_a.m[5] * in_a.m[8] - in_a.m[1] * in_a.m[7] * in_a.m[8] - in_a.m[3] * in_a.m[4] * in_a.m[9] + in_a.m[0] * in_a.m[7] * in_a.m[9] + in_a.m[1] * in_a.m[4] * in_a.m[11] - in_a.m[0] * in_a.m[5] * in_a.m[11]) / det;\n        b.m[12] = (in_a.m[6] * in_a.m[9] * in_a.m[12] - in_a.m[5] * in_a.m[10] * in_a.m[12] - in_a.m[6] * in_a.m[8] * in_a.m[13] + in_a.m[4] * in_a.m[10] * in_a.m[13] + in_a.m[5] * in_a.m[8] * in_a.m[14] - in_a.m[4] * in_a.m[9] * in_a.m[14]) / det;\n        b.m[13] = (in_a.m[1] * in_a.m[10] * in_a.m[12] - in_a.m[2] * in_a.m[9] * in_a.m[12] + in_a.m[2] * in_a.m[8] * in_a.m[13] - in_a.m[0] * in_a.m[10] * in_a.m[13] - in_a.m[1] * in_a.m[8] * in_a.m[14] + in_a.m[0] * in_a.m[9] * in_a.m[14]) / det;\n        b.m[14] = (in_a.m[2] * in_a.m[5] * in_a.m[12] - in_a.m[1] * in_a.m[6] * in_a.m[12] - in_a.m[2] * in_a.m[4] * in_a.m[13] + in_a.m[0] * in_a.m[6] * in_a.m[13] + in_a.m[1] * in_a.m[4] * in_a.m[14] - in_a.m[0] * in_a.m[5] * in_a.m[14]) / det;\n        b.m[15] = (in_a.m[1] * in_a.m[6] * in_a.m[8] - in_a.m[2] * in_a.m[5] * in_a.m[8] + in_a.m[2] * in_a.m[4] * in_a.m[9] - in_a.m[0] * in_a.m[6] * in_a.m[9] - in_a.m[1] * in_a.m[4] * in_a.m[10] + in_a.m[0] * in_a.m[5] * in_a.m[10]) / det;\n        return b;\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> GenericMatrix4<TType> GenericMatrix4<TType>::Translate(const GenericMatrix4<TType>& in_a, const GenericVector3<TType>& in_translation)\n    {\n        return in_a * CreateTranslation(in_translation);\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> GenericMatrix4<TType> GenericMatrix4<TType>::Translate(const GenericMatrix4<TType>& in_a, TType in_x, TType in_y, TType in_z)\n    {\n        return Translate(in_a, GenericVector3<TType>(in_x, in_y, in_z));\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> GenericMatrix4<TType> GenericMatrix4<TType>::Scale(const GenericMatrix4<TType>& in_a, const GenericVector3<TType>& in_scale)\n    {\n        return in_a * CreateScale(in_scale);\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> GenericMatrix4<TType> GenericMatrix4<TType>::Scale(const GenericMatrix4<TType>& in_a, TType in_x, TType in_y, TType in_z)\n    {\n        return Scale(in_a, GenericVector3<TType>(in_x, in_y, in_z));\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> GenericMatrix4<TType> GenericMatrix4<TType>::RotateX(const GenericMatrix4<TType>& in_a, TType in_angle)\n    {\n        return in_a * CreateRotationX(in_angle);\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> GenericMatrix4<TType> GenericMatrix4<TType>::RotateY(const GenericMatrix4<TType>& in_a, TType in_angle)\n    {\n        return in_a * CreateRotationY(in_angle);\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> GenericMatrix4<TType> GenericMatrix4<TType>::RotateZ(const GenericMatrix4<TType>& in_a, TType in_angle)\n    {\n        return in_a * CreateRotationZ(in_angle);\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> GenericMatrix4<TType> GenericMatrix4<TType>::Rotate(const GenericMatrix4<TType>& in_a, const GenericQuaternion<TType>& in_orientation)\n    {\n        return in_a * CreateRotation(in_orientation);\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> GenericMatrix4<TType> GenericMatrix4<TType>::Rotate(const GenericMatrix4<TType>& in_a, const GenericVector3<TType>& in_axis, TType in_angle)\n    {\n        return Rotate(in_a, GenericQuaternion<TType>(in_axis, in_angle));\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> GenericMatrix4<TType>::GenericMatrix4()\n    {\n        Identity();\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> GenericMatrix4<TType>::GenericMatrix4(TType in_a0, TType in_a1, TType in_a2, TType in_a3, TType in_b0, TType in_b1, TType in_b2, TType in_b3, TType in_c0, TType in_c1, TType in_c2, TType in_c3, TType in_d0, TType in_d1, TType in_d2, TType in_d3)\n    {\n        m[0] = in_a0; m[1] = in_a1; m[2] = in_a2; m[3] = in_a3;\n        m[4] = in_b0; m[5] = in_b1; m[6] = in_b2; m[7] = in_b3;\n        m[8] = in_c0; m[9] = in_c1; m[10] = in_c2; m[11] = in_c3;\n        m[12] = in_d0; m[13] = in_d1; m[14] = in_d2; m[15] = in_d3;\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> TType GenericMatrix4<TType>::Determinant() const\n    {\n        return\tm[3] * m[6] * m[9] * m[12] - m[2] * m[7] * m[9] * m[12] - m[3] * m[5] * m[10] * m[12] + m[1] * m[7] * m[10] * m[12] +\n        m[2] * m[5] * m[11] * m[12] - m[1] * m[6] * m[11] * m[12] - m[3] * m[6] * m[8] * m[13] + m[2] * m[7] * m[8] * m[13] +\n        m[3] * m[4] * m[10] * m[13] - m[0] * m[7] * m[10] * m[13] - m[2] * m[4] * m[11] * m[13] + m[0] * m[6] * m[11] * m[13] +\n        m[3] * m[5] * m[8] * m[14] - m[1] * m[7] * m[8] * m[14] - m[3] * m[4] * m[9] * m[14] + m[0] * m[7] * m[9] * m[14] +\n        m[1] * m[4] * m[11] * m[14] - m[0] * m[5] * m[11] * m[14] - m[2] * m[5] * m[8] * m[15] + m[1] * m[6] * m[8] * m[15] +\n        m[2] * m[4] * m[9] * m[15] - m[0] * m[6] * m[9] * m[15] - m[1] * m[4] * m[10] * m[15] + m[0] * m[5] * m[10] * m[15];\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> void GenericMatrix4<TType>::Identity()\n    {\n        m[0] = 1; m[1] = 0; m[2] = 0; m[3] = 0;\n        m[4] = 0; m[5] = 1; m[6] = 0; m[7] = 0;\n        m[8] = 0; m[9] = 0; m[10] = 1; m[11] = 0;\n        m[12] = 0; m[13] = 0; m[14] = 0; m[15] = 1;\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> void GenericMatrix4<TType>::Transpose()\n    {\n        GenericMatrix4<TType> a = *this;\n        \n        m[0] = a.m[0]; m[1] = a.m[4]; m[2] = a.m[8]; m[3] = a.m[12];\n        m[4] = a.m[1]; m[5] = a.m[5]; m[6] = a.m[9]; m[7] = a.m[13];\n        m[8] = a.m[2]; m[9] = a.m[6]; m[10] = a.m[10]; m[11] = a.m[14];\n        m[12] = a.m[3]; m[13] = a.m[7]; m[14] = a.m[11]; m[15] = a.m[15];\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> void GenericMatrix4<TType>::Inverse()\n    {\n        *this = Inverse(*this);\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> void GenericMatrix4<TType>::Translate(const GenericVector3<TType>& in_translation)\n    {\n        *this *= CreateTranslation(in_translation);\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> void GenericMatrix4<TType>::Translate(TType in_x, TType in_y, TType in_z)\n    {\n        Translate(GenericVector3<TType>(in_x, in_y, in_z));\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> void GenericMatrix4<TType>::Scale(const GenericVector3<TType>& in_scale)\n    {\n        *this *= CreateScale(in_scale);\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> void GenericMatrix4<TType>::Scale(TType in_x, TType in_y, TType in_z)\n    {\n        Scale(GenericVector3<TType>(in_x, in_y, in_z));\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> void GenericMatrix4<TType>::RotateX(TType in_angle)\n    {\n        *this *= CreateRotationX(in_angle);\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> void GenericMatrix4<TType>::RotateY(TType in_angle)\n    {\n        *this *= CreateRotationY(in_angle);\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> void GenericMatrix4<TType>::RotateZ(TType in_angle)\n    {\n        *this *= CreateRotationZ(in_angle);\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> void GenericMatrix4<TType>::Rotate(const GenericQuaternion<TType>& in_orientation)\n    {\n        *this *= CreateRotation(in_orientation);\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> void GenericMatrix4<TType>::Rotate(const GenericVector3<TType>& in_axis, TType in_angle)\n    {\n        Rotate(GenericQuaternion<TType>(in_axis, in_angle));\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> GenericVector3<TType> GenericMatrix4<TType>::GetRight() const\n    {\n        return GenericVector3<TType>(m[0], m[1], m[2]);\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> GenericVector3<TType> GenericMatrix4<TType>::GetUp() const\n    {\n        return GenericVector3<TType>(m[4], m[5], m[6]);\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> GenericVector3<TType> GenericMatrix4<TType>::GetForward() const\n    {\n        return GenericVector3<TType>(m[8], m[9], m[10]);\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> GenericVector3<TType> GenericMatrix4<TType>::GetTranslation() const\n    {\n        return GenericVector3<TType>(m[12], m[13], m[14]);\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> void GenericMatrix4<TType>::Decompose(GenericVector3<TType>& out_translation, GenericVector3<TType> & out_scale, GenericQuaternion<TType> & out_orientation) const\n    {\n        out_translation.x = m[12];\n        out_translation.y = m[13];\n        out_translation.z = m[14];\n\n        GenericMatrix4<TType> p;\n\n        // build orthogonal matrix p\n        TType invLength = 1 / std::sqrt(m[0] * m[0] + m[1] * m[1] + m[2] * m[2]);\n        p.m[0] = m[0] * invLength;\n        p.m[1] = m[1] * invLength;\n        p.m[2] = m[2] * invLength;\n\n        TType dot = p.m[0] * m[4] + p.m[1] * m[5] + p.m[2] * m[6];\n        p.m[4] = m[4] - dot * p.m[0];\n        p.m[5] = m[5] - dot * p.m[1];\n        p.m[6] = m[6] - dot * p.m[2];\n        invLength = 1 / std::sqrt(p.m[4] * p.m[4] + p.m[5] * p.m[5] + p.m[6] * p.m[6]);\n        p.m[4] *= invLength;\n        p.m[5] *= invLength;\n        p.m[6] *= invLength;\n\n        dot = p.m[0] * m[8] + p.m[1] * m[9] + p.m[2] * m[10];\n        p.m[8] = m[8] - dot * p.m[0];\n        p.m[9] = m[9] - dot * p.m[1];\n        p.m[10] = m[10] - dot * p.m[2];\n        dot = p.m[4] * m[8] + p.m[5] * m[9] + p.m[6] * m[10];\n        p.m[8] -= dot * p.m[4];\n        p.m[9] -= dot * p.m[5];\n        p.m[10] -= dot * p.m[6];\n        invLength = 1 / std::sqrt(p.m[8] * p.m[8] + p.m[9] * p.m[9] + p.m[10] * p.m[10]);\n        p.m[8] *= invLength;\n        p.m[9] *= invLength;\n        p.m[10] *= invLength;\n\n        // guarantee that orthogonal matrix has determinant 1 (no reflections)\n        TType det = p.m[0] * p.m[5] * p.m[10] + p.m[4] * p.m[9] * p.m[2] +\n            p.m[8] * p.m[1] * p.m[6] - p.m[8] * p.m[5] * p.m[2] -\n            p.m[4] * p.m[1] * p.m[10] - p.m[0] * p.m[9] * p.m[6];\n\n        if (det < 0)\n        {\n            for (u32 i = 0; i < 16; i++)\n            {\n                p.m[i] = -p.m[i];\n            }\n        }\n\n        // build \"right\" matrix R\n        Matrix4 r;\n        r.m[0] = p.m[0] * m[0] + p.m[1] * m[1] + p.m[2] * m[2];\n        r.m[4] = p.m[0] * m[4] + p.m[1] * m[5] + p.m[2] * m[6];\n        r.m[5] = p.m[4] * m[4] + p.m[5] * m[5] + p.m[6] * m[6];\n        r.m[8] = p.m[0] * m[8] + p.m[1] * m[9] + p.m[2] * m[10];\n        r.m[9] = p.m[4] * m[8] + p.m[5] * m[9] + p.m[6] * m[10];\n        r.m[10] = p.m[8] * m[8] + p.m[9] * m[9] + p.m[10] * m[10];\n\n        // the scaling component\n        out_scale.x = r.m[0];\n        out_scale.y = r.m[5];\n        out_scale.z = r.m[10];\n\n        out_orientation = GenericQuaternion<TType>(p);\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> TType& GenericMatrix4<TType>::operator()(u32 in_row, u32 in_column)\n    {\n        CS_ASSERT(in_row >= 0 && in_row < 4 && in_column >= 0 && in_column < 4, \"Trying to access matrix value at [\" + ToString(in_row) + \", \" + ToString(in_column) + \"]\");\n        return m[in_column + in_row * 4];\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> TType GenericMatrix4<TType>::operator()(u32 in_row, u32 in_column) const\n    {\n        CS_ASSERT(in_row >= 0 && in_row < 4 && in_column >= 0 && in_column < 4, \"Trying to access matrix value at [\" + ToString(in_row) + \", \" + ToString(in_column) + \"]\");\n        return m[in_column + in_row * 4];\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> GenericMatrix4<TType>& GenericMatrix4<TType>::operator+=(const GenericMatrix4<TType>& in_b)\n    {\n        m[0] += in_b.m[0]; m[1] += in_b.m[1]; m[2] += in_b.m[2]; m[3] += in_b.m[3];\n        m[4] += in_b.m[4]; m[5] += in_b.m[5]; m[6] += in_b.m[6]; m[7] += in_b.m[7];\n        m[8] += in_b.m[8]; m[9] += in_b.m[9]; m[10] += in_b.m[10]; m[11] += in_b.m[11];\n        m[12] += in_b.m[12]; m[13] += in_b.m[13]; m[14] += in_b.m[14]; m[15] += in_b.m[15];\n        return *this;\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> GenericMatrix4<TType>& GenericMatrix4<TType>::operator-=(const GenericMatrix4<TType>& in_b)\n    {\n        m[0] -= in_b.m[0]; m[1] -= in_b.m[1]; m[2] -= in_b.m[2]; m[3] -= in_b.m[3];\n        m[4] -= in_b.m[4]; m[5] -= in_b.m[5]; m[6] -= in_b.m[6]; m[7] -= in_b.m[7];\n        m[8] -= in_b.m[8]; m[9] -= in_b.m[9]; m[10] -= in_b.m[10]; m[11] -= in_b.m[11];\n        m[12] -= in_b.m[12]; m[13] -= in_b.m[13]; m[14] -= in_b.m[14]; m[15] -= in_b.m[15];\n        return *this;\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> GenericMatrix4<TType>& GenericMatrix4<TType>::operator*=(const GenericMatrix4<TType>& in_b)\n    {\n        GenericMatrix4<TType> c = *this;\n\n        m[0] = c.m[0] * in_b.m[0] + c.m[1] * in_b.m[4] + c.m[2] * in_b.m[8] + c.m[3] * in_b.m[12];\n        m[1] = c.m[0] * in_b.m[1] + c.m[1] * in_b.m[5] + c.m[2] * in_b.m[9] + c.m[3] * in_b.m[13];\n        m[2] = c.m[0] * in_b.m[2] + c.m[1] * in_b.m[6] + c.m[2] * in_b.m[10] + c.m[3] * in_b.m[14];\n        m[3] = c.m[0] * in_b.m[3] + c.m[1] * in_b.m[7] + c.m[2] * in_b.m[11] + c.m[3] * in_b.m[15];\n\n        m[4] = c.m[4] * in_b.m[0] + c.m[5] * in_b.m[4] + c.m[6] * in_b.m[8] + c.m[7] * in_b.m[12];\n        m[5] = c.m[4] * in_b.m[1] + c.m[5] * in_b.m[5] + c.m[6] * in_b.m[9] + c.m[7] * in_b.m[13];\n        m[6] = c.m[4] * in_b.m[2] + c.m[5] * in_b.m[6] + c.m[6] * in_b.m[10] + c.m[7] * in_b.m[14];\n        m[7] = c.m[4] * in_b.m[3] + c.m[5] * in_b.m[7] + c.m[6] * in_b.m[11] + c.m[7] * in_b.m[15];\n\n        m[8] = c.m[8] * in_b.m[0] + c.m[9] * in_b.m[4] + c.m[10] * in_b.m[8] + c.m[11] * in_b.m[12];\n        m[9] = c.m[8] * in_b.m[1] + c.m[9] * in_b.m[5] + c.m[10] * in_b.m[9] + c.m[11] * in_b.m[13];\n        m[10] = c.m[8] * in_b.m[2] + c.m[9] * in_b.m[6] + c.m[10] * in_b.m[10] + c.m[11] * in_b.m[14];\n        m[11] = c.m[8] * in_b.m[3] + c.m[9] * in_b.m[7] + c.m[10] * in_b.m[11] + c.m[11] * in_b.m[15];\n\n        m[12] = c.m[12] * in_b.m[0] + c.m[13] * in_b.m[4] + c.m[14] * in_b.m[8] + c.m[15] * in_b.m[12];\n        m[13] = c.m[12] * in_b.m[1] + c.m[13] * in_b.m[5] + c.m[14] * in_b.m[9] + c.m[15] * in_b.m[13];\n        m[14] = c.m[12] * in_b.m[2] + c.m[13] * in_b.m[6] + c.m[14] * in_b.m[10] + c.m[15] * in_b.m[14];\n        m[15] = c.m[12] * in_b.m[3] + c.m[13] * in_b.m[7] + c.m[14] * in_b.m[11] + c.m[15] * in_b.m[15];\n\n        return *this;\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> GenericMatrix4<TType>& GenericMatrix4<TType>::operator*=(TType in_b)\n    {\n        m[0] *= in_b; m[1] *= in_b; m[2] *= in_b; m[3] *= in_b;\n        m[4] *= in_b; m[5] *= in_b; m[6] *= in_b; m[7] *= in_b;\n        m[8] *= in_b; m[9] *= in_b; m[10] *= in_b; m[11] *= in_b;\n        m[12] *= in_b; m[13] *= in_b; m[14] *= in_b; m[15] *= in_b;\n        return *this;\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> GenericMatrix4<TType>& GenericMatrix4<TType>::operator/=(TType in_b)\n    {\n        m[0] /= in_b; m[1] /= in_b; m[2] /= in_b; m[3] /= in_b;\n        m[4] /= in_b; m[5] /= in_b; m[6] /= in_b; m[7] /= in_b;\n        m[8] /= in_b; m[9] /= in_b; m[10] /= in_b; m[11] /= in_b;\n        m[12] /= in_b; m[13] /= in_b; m[14] /= in_b; m[15] /= in_b;\n        return *this;\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> GenericMatrix4<TType> operator+(GenericMatrix4<TType> in_a, const GenericMatrix4<TType>& in_b)\n    {\n        return (in_a += in_b);\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> GenericMatrix4<TType> operator-(GenericMatrix4<TType> in_a, const GenericMatrix4<TType>& in_b)\n    {\n        return (in_a -= in_b);\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> GenericMatrix4<TType> operator*(const GenericMatrix4<TType>& in_a, const GenericMatrix4<TType>& in_b)\n    {\n        GenericMatrix4<TType> c;\n\n        c.m[0] = in_a.m[0] * in_b.m[0] + in_a.m[1] * in_b.m[4] + in_a.m[2] * in_b.m[8] + in_a.m[3] * in_b.m[12];\n        c.m[1] = in_a.m[0] * in_b.m[1] + in_a.m[1] * in_b.m[5] + in_a.m[2] * in_b.m[9] + in_a.m[3] * in_b.m[13];\n        c.m[2] = in_a.m[0] * in_b.m[2] + in_a.m[1] * in_b.m[6] + in_a.m[2] * in_b.m[10] + in_a.m[3] * in_b.m[14];\n        c.m[3] = in_a.m[0] * in_b.m[3] + in_a.m[1] * in_b.m[7] + in_a.m[2] * in_b.m[11] + in_a.m[3] * in_b.m[15];\n\n        c.m[4] = in_a.m[4] * in_b.m[0] + in_a.m[5] * in_b.m[4] + in_a.m[6] * in_b.m[8] + in_a.m[7] * in_b.m[12];\n        c.m[5] = in_a.m[4] * in_b.m[1] + in_a.m[5] * in_b.m[5] + in_a.m[6] * in_b.m[9] + in_a.m[7] * in_b.m[13];\n        c.m[6] = in_a.m[4] * in_b.m[2] + in_a.m[5] * in_b.m[6] + in_a.m[6] * in_b.m[10] + in_a.m[7] * in_b.m[14];\n        c.m[7] = in_a.m[4] * in_b.m[3] + in_a.m[5] * in_b.m[7] + in_a.m[6] * in_b.m[11] + in_a.m[7] * in_b.m[15];\n\n        c.m[8] = in_a.m[8] * in_b.m[0] + in_a.m[9] * in_b.m[4] + in_a.m[10] * in_b.m[8] + in_a.m[11] * in_b.m[12];\n        c.m[9] = in_a.m[8] * in_b.m[1] + in_a.m[9] * in_b.m[5] + in_a.m[10] * in_b.m[9] + in_a.m[11] * in_b.m[13];\n        c.m[10] = in_a.m[8] * in_b.m[2] + in_a.m[9] * in_b.m[6] + in_a.m[10] * in_b.m[10] + in_a.m[11] * in_b.m[14];\n        c.m[11] = in_a.m[8] * in_b.m[3] + in_a.m[9] * in_b.m[7] + in_a.m[10] * in_b.m[11] + in_a.m[11] * in_b.m[15];\n\n        c.m[12] = in_a.m[12] * in_b.m[0] + in_a.m[13] * in_b.m[4] + in_a.m[14] * in_b.m[8] + in_a.m[15] * in_b.m[12];\n        c.m[13] = in_a.m[12] * in_b.m[1] + in_a.m[13] * in_b.m[5] + in_a.m[14] * in_b.m[9] + in_a.m[15] * in_b.m[13];\n        c.m[14] = in_a.m[12] * in_b.m[2] + in_a.m[13] * in_b.m[6] + in_a.m[14] * in_b.m[10] + in_a.m[15] * in_b.m[14];\n        c.m[15] = in_a.m[12] * in_b.m[3] + in_a.m[13] * in_b.m[7] + in_a.m[14] * in_b.m[11] + in_a.m[15] * in_b.m[15];\n\n        return c;\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> GenericMatrix4<TType> operator*(GenericMatrix4<TType> in_a, TType in_b)\n    {\n        return (in_a *= in_b);\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> GenericMatrix4<TType> operator*(TType in_a, GenericMatrix4<TType> in_b)\n    {\n        return (in_b *= in_a);\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> GenericMatrix4<TType> operator/(GenericMatrix4<TType> in_a, TType in_b)\n    {\n        return (in_a /= in_b);\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> bool operator==(const GenericMatrix4<TType>& in_a, const GenericMatrix4<TType>& in_b)\n    {\n        for (u32 i = 0; i < 16; ++i)\n        {\n            if (in_a.m[i] != in_b.m[i])\n                return false;\n        }\n        return true;\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> bool operator!=(const GenericMatrix4<TType>& in_a, const GenericMatrix4<TType>& in_b)\n    {\n        return !(in_a == in_b);\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Math/NumericLimits.h",
    "content": "//\n//  NumericLimits.h\n//  ChilliSource\n//  Created by Ian Copland on 10/03/2015.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2015 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_MATH_NUMERICLIMITS_H_\n#define _CHILLISOURCE_CORE_MATH_NUMERICLIMITS_H_\n\n#include <ChilliSource/ChilliSource.h>\n\n#include <limits>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    /// A series of functions for acquiring the highest and lowest values for a\n    /// specific type. Typically std::numeric_limits should be used for this purpose.\n    /// However, the Visual C++ compiler cannot handle the use of std::numeric_limits\n    /// in default function / method parameters. This can be used instead.\n    ///\n    /// @author Ian Copland\n    //------------------------------------------------------------------------------\n    namespace NumericLimits\n    {\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param The lowest possible value for the requested type.\n        //------------------------------------------------------------------------------\n        template <typename TType> TType Lowest();\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param The highest possible value for the requested type.\n        //------------------------------------------------------------------------------\n        template <typename TType> TType Highest();\n\n        //------------------------------------------------------------------------------.\n        //------------------------------------------------------------------------------\n        template <typename TType> TType Lowest()\n        {\n            return std::numeric_limits<TType>::lowest();\n        }\n        //------------------------------------------------------------------------------\n        //------------------------------------------------------------------------------\n        template <typename TType> TType Highest()\n        {\n            return std::numeric_limits<TType>::max();\n        }\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Math/Quaternion.h",
    "content": "//\n//  Quaternion.h\n//  ChilliSource\n//  Created by Ian Copland on 27/04/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_MATH_QUATERNION_H_\n#define _CHILLISOURCE_CORE_MATH_QUATERNION_H_\n\n#include <ChilliSource/ChilliSource.h>\n\nnamespace ChilliSource\n{\n    //-------------------------------------------------------\n    /// A generic quaternion class for respresention 3D\n    /// orientations.\n    ///\n    /// @author Ian Copland\n    //-------------------------------------------------------\n    template <typename TType> class GenericQuaternion final\n    {\n    public:\n        //-----------------------------------------------\n        /// Constants\n        //-----------------------------------------------\n        static const GenericQuaternion<TType> k_identity;\n        \n        //-----------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param A quaternion\n        ///\n        /// @return a normalised version of the quaternion.\n        //-----------------------------------------------\n        static GenericQuaternion<TType> Normalise(GenericQuaternion<TType> in_a);\n        //-----------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param A quaternion\n        ///\n        /// @return the conjugate of the quaternion.\n        //-----------------------------------------------\n        static GenericQuaternion<TType> Conjugate(GenericQuaternion<TType> in_a);\n        //-----------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param A quaternion\n        ///\n        /// @return the inverse of the quaternion.\n        //-----------------------------------------------\n        static GenericQuaternion<TType> Inverse(GenericQuaternion<TType> in_a);\n        //--------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param The first quaternion.\n        /// @param The second quaternion.\n        ///\n        /// @return The dot product of two quaternions.\n        //--------------------------------------------\n        static TType Dot(const GenericQuaternion<TType>& in_a, const GenericQuaternion<TType>& in_b);\n        //--------------------------------------------\n        /// Spherical Linear Interpolation on two\n        /// quaternions.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The first quaternion.\n        /// @param The second quaternion.\n        /// @param The step between the two values. This\n        /// is in the range 0.0 - 1.0 and will be clamped\n        /// if outside of it.\n        ///\n        /// @return The interpolated quaternion.\n        //--------------------------------------------\n        static GenericQuaternion<TType> Slerp(GenericQuaternion<TType> in_a, const GenericQuaternion<TType>& in_b, f32 in_t);\n        //--------------------------------------------\n        /// Normalised Linear Interpolation on two\n        /// quaternions.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The first quaternion.\n        /// @param The second quaternion.\n        /// @param The step between the two values. This\n        /// is in the range 0.0 - 1.0 and will be clamped\n        /// if outside of it.\n        ///\n        /// @return The interpolated quaternion.\n        //--------------------------------------------\n        static GenericQuaternion<TType> Nlerp(GenericQuaternion<TType> in_a, const GenericQuaternion<TType>& in_b, f32 in_t);\n        //-----------------------------------------------\n        /// Constructor. Sets the contents to the\n        /// Identity quaternion.\n        ///\n        /// @author Ian Copland\n        //-----------------------------------------------\n        GenericQuaternion();\n        //-----------------------------------------------\n        /// Constructor.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param x\n        /// @param y\n        /// @param z\n        /// @param w\n        //-----------------------------------------------\n        explicit GenericQuaternion(TType in_x, TType in_y, TType in_z, TType in_w);\n        //-----------------------------------------------\n        /// Constructor. Initalises the quaternion to\n        /// represent the rotation described by the given\n        /// axis and angle.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param An axis.\n        /// @param An angle.\n        //-----------------------------------------------\n        explicit GenericQuaternion(const GenericVector3<TType>& in_axis, TType in_angle);\n        //-----------------------------------------------\n        /// Constructor. Initalises the quaternion to\n        /// represent the rotation described by the given\n        /// euler axes.\n        ///\n        /// @author S Downie\n        ///\n        /// @param The x axis.\n        /// @param The y axis.\n        /// @param The z axis.\n        //-----------------------------------------------\n        explicit GenericQuaternion(const GenericVector3<TType>& in_xAxis, const GenericVector3<TType>& in_yAxis, const GenericVector3<TType>& in_zAxis);\n        //-----------------------------------------------\n        /// Constructor. Initalises the quaternion to\n        /// represent the rotation described by the given\n        /// rotation matrix.\n        ///\n        /// @author S Downie\n        ///\n        /// @param The rotation matrix.\n        //-----------------------------------------------\n        explicit GenericQuaternion(const GenericMatrix4<TType>& in_rotation);\n        //-----------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return the magnitude of the quaternion.\n        //-----------------------------------------------\n        TType Magnitude() const;\n        //-----------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return the magnitude of the quaternion\n        /// squared.\n        //-----------------------------------------------\n        TType MagnitudeSquared() const;\n        //-----------------------------------------------\n        /// Normalises this quaternion.\n        ///\n        /// @author Ian Copland\n        //-----------------------------------------------\n        void Normalise();\n        //-----------------------------------------------\n        /// Sets this quaternion to its conjugate.\n        ///\n        /// @author Ian Copland\n        //-----------------------------------------------\n        void Conjugate();\n        //-----------------------------------------------\n        /// Sets this quaternion to its inverse.\n        ///\n        /// @author Ian Copland\n        //-----------------------------------------------\n        void Inverse();\n        //--------------------------------------------\n        /// Sets this to the result of spherical\n        /// linear interpolation of this and the given\n        /// quaternion with the given interpolation\n        /// factor.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The other quaternion.\n        /// @param The step between the two values. This\n        /// is in the range 0.0 - 1.0 and will be clamped\n        /// if outside of it.\n        //--------------------------------------------\n        void Slerp(const GenericQuaternion<TType>& in_b, f32 in_t);\n        //--------------------------------------------\n        /// Sets this to the result of normalised\n        /// linear interpolation of this and the given\n        /// quaternion with the given interpolation\n        /// factor.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The other quaternion.\n        /// @param The step between the two values. This\n        /// is in the range 0.0 - 1.0 and will be clamped\n        /// if outside of it.\n        //--------------------------------------------\n        void Nlerp(const GenericQuaternion<TType>& in_b, f32 in_t);\n        //-----------------------------------------------\n        /// Converts the quaternion into the axis and\n        /// angle it represents.\n        ///\n        /// @author S Downie\n        ///\n        /// @param [Out] The axis.\n        /// @param [Out] The angle.\n        //-----------------------------------------------\n        void ToAxisAngle(GenericVector3<TType>& out_axis, TType& out_angle) const;\n        //-----------------------------------------------\n        /// Converts the quaternion into the equivelant\n        /// euler axes.\n        ///\n        /// @author S Downie\n        ///\n        /// @param [Out] The x axis.\n        /// @param [Out] The y axis.\n        /// @param [Out] The z axis.\n        //-----------------------------------------------\n        void ToEulerAxes(GenericVector3<TType>& out_xAxis, GenericVector3<TType>& out_yAxis, GenericVector3<TType>& out_zAxis) const;\n        //-----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param Another quaternion.\n        ///\n        /// @return This quaternion after adding the given\n        /// quaternion.\n        //-----------------------------------------------------\n        GenericQuaternion<TType>& operator+=(const GenericQuaternion<TType>& in_b);\n        //-----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param Another quaternion.\n        ///\n        /// @return This quaternion after subtracting the given\n        /// quaternion.\n        //-----------------------------------------------------\n        GenericQuaternion<TType>& operator-=(const GenericQuaternion<TType>& in_b);\n        //-----------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return This quaternion after it has been negated\n        //-----------------------------------------------------\n        GenericQuaternion<TType>& operator-();\n        //-----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param Another quaternion.\n        ///\n        /// @return This quaternion after multiplying by the given\n        /// quaternion.\n        //-----------------------------------------------------\n        GenericQuaternion<TType>& operator*=(const GenericQuaternion<TType>& in_b);\n        //-----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param A scalar.\n        ///\n        /// @return This quaternion after multiplying by the given\n        /// scalar.\n        //-----------------------------------------------------\n        GenericQuaternion<TType>& operator*=(TType in_b);\n        //-----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param A scalar.\n        ///\n        /// @return This quaternion after dividing by the given\n        /// scalar.\n        //-----------------------------------------------------\n        GenericQuaternion<TType>& operator/=(TType in_b);\n        \n        TType x;\n        TType y;\n        TType z;\n        TType w;\n    };\n    //-----------------------------------------------------\n    /// @author Ian Copland\n    ///\n    /// @param The quaternion A.\n    /// @param The quaternion B.\n    ///\n    /// @return The result of A + B.\n    //-----------------------------------------------------\n    template <typename TType> GenericQuaternion<TType> operator+(GenericQuaternion<TType> in_a, const GenericQuaternion<TType>& in_b);\n    //-----------------------------------------------------\n    /// @author Ian Copland\n    ///\n    /// @param The quaternion A.\n    /// @param The quaternion B.\n    ///\n    /// @return The result of A - B.\n    //-----------------------------------------------------\n    template <typename TType> GenericQuaternion<TType> operator-(GenericQuaternion<TType> in_a, const GenericQuaternion<TType>& in_b);\n    //-----------------------------------------------------\n    /// @author Ian Copland\n    ///\n    /// @param The quaternion A.\n    /// @param The quaternion B.\n    ///\n    /// @return The result of A * B.\n    //-----------------------------------------------------\n    template <typename TType> GenericQuaternion<TType> operator*(GenericQuaternion<TType> in_a, const GenericQuaternion<TType>& in_b);\n    //-----------------------------------------------------\n    /// @author Ian Copland\n    ///\n    /// @param The quaternion A.\n    /// @param The scalar B.\n    ///\n    /// @return The result of A * B.\n    //-----------------------------------------------------\n    template <typename TType> GenericQuaternion<TType> operator*(GenericQuaternion<TType> in_a, TType in_b);\n    //-----------------------------------------------------\n    /// @author Ian Copland\n    ///\n    /// @param The scalar A.\n    /// @param The quaternion B.\n    ///\n    /// @return The result of A * B.\n    //-----------------------------------------------------\n    template <typename TType> GenericQuaternion<TType> operator*(TType in_a, GenericQuaternion<TType> in_b);\n    //-----------------------------------------------------\n    /// @author Ian Copland\n    ///\n    /// @param The quaternion A.\n    /// @param The scalar B.\n    ///\n    /// @return The result of A / B.\n    //-----------------------------------------------------\n    template <typename TType> GenericQuaternion<TType> operator/(GenericQuaternion<TType> in_a, TType in_b);\n    //-----------------------------------------------------\n    /// @author Ian Copland\n    ///\n    /// @param The quaternion A.\n    /// @param The quaternion B.\n    ///\n    /// @return Whether or not they are equal.\n    //-----------------------------------------------------\n    template <typename TType> bool operator==(const GenericQuaternion<TType>& in_a, const GenericQuaternion<TType>& in_b);\n    //-----------------------------------------------------\n    /// @author Ian Copland\n    ///\n    /// @param The quaternion A.\n    /// @param The quaternion B.\n    ///\n    /// @return Whether or not they are in-equal.\n    //-----------------------------------------------------\n    template <typename TType> bool operator!=(const GenericQuaternion<TType>& in_a, const GenericQuaternion<TType>& in_b);\n}\n\n//----------------------------------------------------\n// These are included here to avoid circular inclusion\n// issues. At this stage the class has been defined\n// which is enough for the classes included to use it.\n//----------------------------------------------------\n#include <ChilliSource/Core/Math/Matrix4.h>\n#include <ChilliSource/Core/Math/Vector3.h>\n\n#include <cmath>\n\nnamespace ChilliSource\n{\n    template <typename TType> const GenericQuaternion<TType> GenericQuaternion<TType>::k_identity(0, 0, 0, 1);\n    \n    //-----------------------------------------------\n    //-----------------------------------------------\n    template <typename TType> GenericQuaternion<TType> GenericQuaternion<TType>::Normalise(GenericQuaternion<TType> in_a)\n    {\n        in_a.Normalise();\n        return in_a;\n    }\n    //-----------------------------------------------\n    //-----------------------------------------------\n    template <typename TType> GenericQuaternion<TType> GenericQuaternion<TType>::Conjugate(GenericQuaternion<TType> in_a)\n    {\n        in_a.Conjugate();\n        return in_a;\n    }\n    //-----------------------------------------------\n    //-----------------------------------------------\n    template <typename TType> GenericQuaternion<TType> GenericQuaternion<TType>::Inverse(GenericQuaternion<TType> in_a)\n    {\n        in_a.Inverse();\n        return in_a;\n    }\n    //-----------------------------------------------\n    //-----------------------------------------------\n    template <typename TType> TType GenericQuaternion<TType>::Dot(const GenericQuaternion<TType>& in_a, const GenericQuaternion<TType>& in_b)\n    {\n        return (in_a.x * in_b.x + in_a.y * in_b.y + in_a.z * in_b.z + in_a.w * in_b.w);\n    }\n    //-----------------------------------------------\n    //-----------------------------------------------\n    template <typename TType> GenericQuaternion<TType> GenericQuaternion<TType>::Slerp(GenericQuaternion<TType> in_a, const GenericQuaternion<TType>& in_b, f32 in_t)\n    {\n        in_a.Slerp(in_b, in_t);\n        return in_a;\n    }\n    //--------------------------------------------\n    //--------------------------------------------\n    template <typename TType> GenericQuaternion<TType> GenericQuaternion<TType>::Nlerp(GenericQuaternion<TType> in_a, const GenericQuaternion<TType>& in_b, f32 in_t)\n    {\n        in_a.Nlerp(in_b, in_t);\n        return in_a;\n    }\n    //-----------------------------------------------\n    //-----------------------------------------------\n    template <typename TType> GenericQuaternion<TType>::GenericQuaternion()\n    : x(0), y(0), z(0), w(1)\n    {\n    }\n    //-----------------------------------------------\n    //-----------------------------------------------\n    template <typename TType> GenericQuaternion<TType>::GenericQuaternion(TType in_x, TType in_y, TType in_z, TType in_w)\n    : x(in_x), y(in_y), z(in_z), w(in_w)\n    {\n    }\n    //-----------------------------------------------\n    //-----------------------------------------------\n    template <typename TType> GenericQuaternion<TType>::GenericQuaternion(const GenericVector3<TType>& in_axis, TType in_angle)\n    {\n        GenericVector3<TType> normalised = GenericVector3<TType>::Normalise(in_axis);\n        TType halfAngle = in_angle / 2;\n        TType sinAngle = (TType)std::sin(halfAngle);\n        \n        x = normalised.x * sinAngle;\n        y = normalised.y * sinAngle;\n        z = normalised.z * sinAngle;\n        w = (TType)std::cos(halfAngle);\n    }\n    //-----------------------------------------------\n    //-----------------------------------------------\n    template <typename TType> GenericQuaternion<TType>::GenericQuaternion(const GenericVector3<TType>& in_xAxis, const GenericVector3<TType>& in_yAxis, const GenericVector3<TType>& in_zAxis)\n    {\n        GenericMatrix4<TType> rotation;\n        \n        rotation.m[0] = in_xAxis.x;\n        rotation.m[1] = in_xAxis.y;\n        rotation.m[2] = in_xAxis.z;\n        \n        rotation.m[4] = in_yAxis.x;\n        rotation.m[5] = in_yAxis.y;\n        rotation.m[6] = in_yAxis.z;\n        \n        rotation.m[8] = in_zAxis.x;\n        rotation.m[9] = in_zAxis.y;\n        rotation.m[10] = in_zAxis.z;\n        \n        (*this) = Quaternion(rotation);\n    }\n    //-----------------------------------------------\n    // Algorithm in Ken Shoemake's article in 1987\n    // SIGGRAPH course notes article \"Quaternion\n    // Calculus and Fast Animation\".\n    //-----------------------------------------------\n    template <typename TType> GenericQuaternion<TType>::GenericQuaternion(const GenericMatrix4<TType>& in_rotation)\n    {\n        TType trace = in_rotation.m[0] + in_rotation.m[5] + in_rotation.m[10];\n        TType root = 0;\n        \n        if (trace > 0)\n        {\n            root = std::sqrt(trace + 1);\n            w = (TType)0.5 * root;\n            root = (TType)0.5 / root;\n            x = (in_rotation.m[6] - in_rotation.m[9]) * root;\n            y = (in_rotation.m[8] - in_rotation.m[2]) * root;\n            z = (in_rotation.m[1] - in_rotation.m[4]) * root;\n        }\n        else\n        {\n            static u32 s_iNext[3] = { 1, 2, 0 };\n            u32 i = 0;\n            if (in_rotation.m[5] > in_rotation.m[0])\n            {\n                i = 1;\n            }\n            if (in_rotation.m[10] > in_rotation(i, i))\n            {\n                i = 2;\n            }\n            u32 j = s_iNext[i];\n            u32 k = s_iNext[j];\n            \n            root = std::sqrt(in_rotation(i, i) - in_rotation(j, j) - in_rotation(k, k) + 1);\n            \n            f32* apkQuat[3] = { &x, &y, &z };\n            *apkQuat[i] = (TType)0.5 * root;\n            root = (TType)0.5 / root;\n            w = (in_rotation(j, k) - in_rotation(k, j)) * root;\n            *apkQuat[j] = (in_rotation(j, i) + in_rotation(i, j)) * root;\n            *apkQuat[k] = (in_rotation(k, i) + in_rotation(i, k)) * root;\n        }\n    }\n    //-----------------------------------------------\n    //-----------------------------------------------\n    template <typename TType> TType GenericQuaternion<TType>::Magnitude() const\n    {\n        return (TType)std::sqrt(w*w + x*x + y*y + z*z);\n    }\n    //-----------------------------------------------\n    //-----------------------------------------------\n    template <typename TType> TType GenericQuaternion<TType>::MagnitudeSquared() const\n    {\n        return (w*w + x*x + y*y + z*z);\n    }\n    //-----------------------------------------------\n    //-----------------------------------------------\n    template <typename TType> void GenericQuaternion<TType>::Normalise()\n    {\n        TType mangitude = Magnitude();\n        if (mangitude != 0)\n        {\n            TType invMagnitude = 1 / mangitude;\n            w *= invMagnitude;\n            x *= invMagnitude;\n            y *= invMagnitude;\n            z *= invMagnitude;\n        }\n    }\n    //-----------------------------------------------\n    //-----------------------------------------------\n    template <typename TType> void GenericQuaternion<TType>::Conjugate()\n    {\n        x = -x;\n        y = -y;\n        z = -z;\n    }\n    //-----------------------------------------------\n    //-----------------------------------------------\n    template <typename TType> void GenericQuaternion<TType>::Inverse()\n    {\n        TType magnitudeSquared = MagnitudeSquared();\n        if (magnitudeSquared != 0)\n        {\n            Conjugate();\n            TType invMagnitudeSquared = 1 / magnitudeSquared;\n            w *= invMagnitudeSquared;\n            x *= invMagnitudeSquared;\n            y *= invMagnitudeSquared;\n            z *= invMagnitudeSquared;\n        }\n    }\n    //--------------------------------------------\n    //--------------------------------------------\n    template <typename TType> void GenericQuaternion<TType>::Slerp(const GenericQuaternion<TType>& in_b, f32 in_t)\n    {\n        const TType k_epsilon = (TType)0.0001;\n        \n        if (in_t <= 0)\n        {\n            return;\n        }\n        if (in_t >= 1)\n        {\n            *this = in_b;\n        }\n        \n        GenericQuaternion<TType> B = in_b;\n        TType aDotB = Dot(*this, B);\n        if (aDotB < 0)\n        {\n            B.x = -B.x;\n            B.y = -B.y;\n            B.z = -B.z;\n            B.w = -B.w;\n            aDotB = -aDotB;\n        }\n        \n        if (aDotB > 1 - k_epsilon)\n        {\n            *this = *this + in_t * (B - *this);\n            Normalise();\n        }\n        else\n        {\n            TType acosADotB = std::acos(aDotB);\n            *this = (std::sin((1 - in_t) * acosADotB) * *this + std::sin(in_t * acosADotB) * B) / std::sin(acosADotB);\n        }\n    }\n    //--------------------------------------------\n    //--------------------------------------------\n    template <typename TType> void GenericQuaternion<TType>::Nlerp(const GenericQuaternion<TType>& in_b, f32 in_t)\n    {\n        const f32 dot = Dot(*this, in_b);\n        Quaternion output;\n        \n        if (dot < 0)\n        {\n            *this = *this + (in_t * ((in_b * (TType)-1) - *this));\n        }\n        else\n        {\n            *this = *this + (in_t * (in_b - *this));\n        }\n        \n        Normalise();\n    }\n    //-----------------------------------------------\n    //-----------------------------------------------\n    template <typename TType> void GenericQuaternion<TType>::ToAxisAngle(GenericVector3<TType>& out_axis, TType& out_angle) const\n    {\n        TType sqrLength = (x * x + y * y + z * z);\n        \n        if (sqrLength > 0)\n        {\n            TType invLength = 1.0f / std::sqrt(sqrLength);\n            out_angle = 2 * std::acos(w);\n            out_axis = Vector3(x * invLength, y * invLength, z * invLength);\n        }\n        else\n        {\n            out_angle = 0;\n            out_axis = Vector3::k_unitPositiveX;\n        }\n    }\n    //-----------------------------------------------\n    //-----------------------------------------------\n    template <typename TType> void GenericQuaternion<TType>::ToEulerAxes(GenericVector3<TType>& out_xAxis, GenericVector3<TType>& out_yAxis, GenericVector3<TType>& out_zAxis) const\n    {\n        GenericMatrix4<TType> rotation = Matrix4::CreateRotation(*this);\n        \n        out_xAxis.x = rotation(0, 0);\n        out_xAxis.y = rotation(0, 1);\n        out_xAxis.z = rotation(0, 2);\n        \n        out_yAxis.x = rotation(1, 0);\n        out_yAxis.y = rotation(1, 1);\n        out_yAxis.z = rotation(1, 2);\n        \n        out_zAxis.x = rotation(2, 0);\n        out_zAxis.y = rotation(2, 1);\n        out_zAxis.z = rotation(2, 2);\n    }\n    \n    //-----------------------------------------------\n    //-----------------------------------------------\n    template <typename TType> GenericQuaternion<TType>& GenericQuaternion<TType>::operator+=(const GenericQuaternion<TType>& in_b)\n    {\n        x += in_b.x;\n        y += in_b.y;\n        z += in_b.z;\n        w += in_b.w;\n        return *this;\n    }\n    //-----------------------------------------------\n    //-----------------------------------------------\n    template <typename TType> GenericQuaternion<TType>& GenericQuaternion<TType>::operator-=(const GenericQuaternion<TType>& in_b)\n    {\n        x -= in_b.x;\n        y -= in_b.y;\n        z -= in_b.z;\n        w -= in_b.w;\n        return *this;\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> GenericQuaternion<TType>& GenericQuaternion<TType>::operator-()\n    {\n        x = -x;\n        y = -y;\n        z = -z;\n        w = -w;\n        return *this;\n    }\n    //-----------------------------------------------\n    //-----------------------------------------------\n    template <typename TType> GenericQuaternion<TType>& GenericQuaternion<TType>::operator *= (const GenericQuaternion<TType>& in_b)\n    {\n        GenericQuaternion<TType> copy = *this;\n        w = in_b.w * copy.w - in_b.x *copy.x - in_b.y * copy.y - in_b.z * copy.z;\n        x = in_b.w * copy.x + in_b.x *copy.w + in_b.y * copy.z - in_b.z * copy.y;\n        y = in_b.w * copy.y - in_b.x *copy.z + in_b.y * copy.w + in_b.z * copy.x;\n        z = in_b.w * copy.z + in_b.x *copy.y - in_b.y * copy.x + in_b.z * copy.w;\n        return *this;\n    }\n    //-----------------------------------------------\n    //-----------------------------------------------\n    template <typename TType> GenericQuaternion<TType>& GenericQuaternion<TType>::operator*=(TType in_b)\n    {\n        x *= in_b;\n        y *= in_b;\n        z *= in_b;\n        w *= in_b;\n        return *this;\n    }\n    //-----------------------------------------------\n    //-----------------------------------------------\n    template <typename TType> GenericQuaternion<TType>& GenericQuaternion<TType>::operator/=(TType in_b)\n    {\n        x /= in_b;\n        y /= in_b;\n        z /= in_b;\n        w /= in_b;\n        return *this;\n    }\n    //-----------------------------------------------\n    //-----------------------------------------------\n    template <typename TType> GenericQuaternion<TType> operator+(GenericQuaternion<TType> in_a, const GenericQuaternion<TType>& in_b)\n    {\n        return (in_a += in_b);\n    }\n    //-----------------------------------------------\n    //-----------------------------------------------\n    template <typename TType> GenericQuaternion<TType> operator-(GenericQuaternion<TType> in_a, const GenericQuaternion<TType>& in_b)\n    {\n        return (in_a -= in_b);\n    }\n    //-----------------------------------------------\n    //-----------------------------------------------\n    template <typename TType> GenericQuaternion<TType> operator*(GenericQuaternion<TType> in_a, const GenericQuaternion<TType>& in_b)\n    {\n        return (in_a *= in_b);\n    }\n    //-----------------------------------------------\n    //-----------------------------------------------\n    template <typename TType> GenericQuaternion<TType> operator*(GenericQuaternion<TType> in_a, TType in_b)\n    {\n        return (in_a *= in_b);\n    }\n    //-----------------------------------------------\n    //-----------------------------------------------\n    template <typename TType> GenericQuaternion<TType> operator*(TType in_a, GenericQuaternion<TType> in_b)\n    {\n        return (in_b *= in_a);\n    }\n    //-----------------------------------------------\n    //-----------------------------------------------\n    template <typename TType> GenericQuaternion<TType> operator/(GenericQuaternion<TType> in_a, TType in_b)\n    {\n        return (in_a /= in_b);\n    }\n    //-----------------------------------------------\n    //-----------------------------------------------\n    template <typename TType> bool operator==(const GenericQuaternion<TType>& in_a, const GenericQuaternion<TType>& in_b)\n    {\n        return (in_a.x == in_b.x && in_a.y == in_b.y && in_a.z == in_b.z && in_a.w == in_b.w);\n    }\n    //-----------------------------------------------\n    //-----------------------------------------------\n    template <typename TType> bool operator!=(const GenericQuaternion<TType>& in_a, const GenericQuaternion<TType>& in_b)\n    {\n        return !(in_a == in_b);\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Math/Random.cpp",
    "content": "//\n//  Random.cpp\n//  ChilliSource\n//  Created by Ian Copland on 24/10/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n\n#include <ChilliSource/Core/Math/Random.h>\n\n#include <ChilliSource/Core/Base/Colour.h>\n#include <ChilliSource/Core/Math/Matrix3.h>\n#include <ChilliSource/Core/Math/Matrix4.h>\n#include <ChilliSource/Core/Math/Quaternion.h>\n#include <ChilliSource/Core/Math/Vector2.h>\n#include <ChilliSource/Core/Math/Vector3.h>\n#include <ChilliSource/Core/Math/Vector4.h>\n\n#include <mutex>\n\n#ifdef CS_TARGETPLATFORM_IOS\n#import <Foundation/Foundation.h>\n#import <CSBackend/Platform/iOS/Core/Math/RNGContainer.h>\n#endif\n\nnamespace ChilliSource\n{\n    namespace\n    {\n        //----------------------------------------------------------------\n        /// This generates a random seed for the thread local random\n        /// number generators.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @return A randomly generated 32-bit integer.\n        //----------------------------------------------------------------\n        u32 GenerateSeed()\n        {\n            static std::mt19937* g_seedGenerator = nullptr;\n            static std::mutex g_seedMutex;\n            \n            std::unique_lock<std::mutex> lock(g_seedMutex);\n            \n            if (g_seedGenerator == nullptr)\n            {\n                g_seedGenerator = new std::mt19937(std::random_device()());\n            }\n            \n            std::uniform_int_distribution<u32> distribution(std::numeric_limits<u32>::min(), std::numeric_limits<u32>::max());\n            return distribution(*g_seedGenerator);\n        }\n        \n#ifdef CS_TARGETPLATFORM_IOS\n        //----------------------------------------------------------------\n        /// iOS doesn't support C++ thread_local so we have to use the\n        /// objective c version instead.\n        ///\n        /// @author Ian Copland\n        //----------------------------------------------------------------\n        const char k_rngKey[] = \"_threadLocalRNG\";\n        \n#elif defined (CS_TARGETPLATFORM_WINDOWS)\n        //----------------------------------------------------------------\n        /// Visual C++ doesn't support thread_local yet, so the compiler\n        /// specific version should be used instead. This doesn't support\n        /// storage of objects that have a contructor so we are storing \n        /// the RNG as a pointer and allocating it lazily when it's first \n        /// used. To ensure that the RNG is cleaned up when the thread is \n        /// destroyed, placement new is used to store the RNG in an array.\n        /// The RNG doesn't have a destructor, so this should be safe.\n        ///\n        /// @author Ian Copland\n        //----------------------------------------------------------------\n        __declspec(thread) u8 g_rngMemory[sizeof(std::mt19937)];\n        __declspec(thread) std::mt19937* g_randomNumberGenerator = nullptr;\n        \n#else\n        thread_local std::mt19937 g_randomNumberGenerator(GenerateSeed());\n#endif\n    }\n\n    namespace Random\n    {\n        //----------------------------------------------------------------\n        //----------------------------------------------------------------\n        template <> Vector2 GenerateComponentwise(Vector2 in_lower, Vector2 in_upper)\n        {\n            return Vector2(Generate(in_lower.x, in_upper.x), Generate(in_lower.y, in_upper.y));\n        }\n        //----------------------------------------------------------------\n        //----------------------------------------------------------------\n        template <> Vector3 GenerateComponentwise(Vector3 in_lower, Vector3 in_upper)\n        {\n            return Vector3(Generate(in_lower.x, in_upper.x), Generate(in_lower.y, in_upper.y), Generate(in_lower.z, in_upper.z));\n        }\n        //----------------------------------------------------------------\n        //----------------------------------------------------------------\n        template <> Vector4 GenerateComponentwise(Vector4 in_lower, Vector4 in_upper)\n        {\n            return Vector4(Generate(in_lower.x, in_upper.x), Generate(in_lower.y, in_upper.y), Generate(in_lower.z, in_upper.z), Generate(in_lower.w, in_upper.w));\n        }\n        //----------------------------------------------------------------\n        //----------------------------------------------------------------\n        template <> Matrix3 GenerateComponentwise(Matrix3 in_lower, Matrix3 in_upper)\n        {\n            f32 a = Generate(in_lower.m[0], in_upper.m[0]);\n            f32 b = Generate(in_lower.m[1], in_upper.m[1]);\n            f32 c = Generate(in_lower.m[2], in_upper.m[2]);\n            f32 d = Generate(in_lower.m[3], in_upper.m[3]);\n            f32 e = Generate(in_lower.m[4], in_upper.m[4]);\n            f32 f = Generate(in_lower.m[5], in_upper.m[5]);\n            f32 g = Generate(in_lower.m[6], in_upper.m[6]);\n            f32 h = Generate(in_lower.m[7], in_upper.m[7]);\n            f32 i = Generate(in_lower.m[8], in_upper.m[8]);\n            \n            return Matrix3(a, b, c, d, e, f, g, h, i);\n        }\n        //----------------------------------------------------------------\n        //----------------------------------------------------------------\n        template <> Matrix4 GenerateComponentwise(Matrix4 in_lower, Matrix4 in_upper)\n        {\n            f32 a = Generate(in_lower.m[0], in_upper.m[0]);\n            f32 b = Generate(in_lower.m[1], in_upper.m[1]);\n            f32 c = Generate(in_lower.m[2], in_upper.m[2]);\n            f32 d = Generate(in_lower.m[3], in_upper.m[3]);\n            f32 e = Generate(in_lower.m[4], in_upper.m[4]);\n            f32 f = Generate(in_lower.m[5], in_upper.m[5]);\n            f32 g = Generate(in_lower.m[6], in_upper.m[6]);\n            f32 h = Generate(in_lower.m[7], in_upper.m[7]);\n            f32 i = Generate(in_lower.m[8], in_upper.m[8]);\n            f32 j = Generate(in_lower.m[9], in_upper.m[9]);\n            f32 k = Generate(in_lower.m[10], in_upper.m[10]);\n            f32 l = Generate(in_lower.m[11], in_upper.m[11]);\n            f32 m = Generate(in_lower.m[12], in_upper.m[12]);\n            f32 n = Generate(in_lower.m[13], in_upper.m[13]);\n            f32 o = Generate(in_lower.m[14], in_upper.m[14]);\n            f32 p = Generate(in_lower.m[15], in_upper.m[15]);\n            \n            return Matrix4(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p);\n        }\n        //----------------------------------------------------------------\n        //----------------------------------------------------------------\n        template <> Quaternion GenerateComponentwise(Quaternion in_lower, Quaternion in_upper)\n        {\n            return Quaternion(Generate(in_lower.x, in_upper.x), Generate(in_lower.y, in_upper.y), Generate(in_lower.z, in_upper.z), Generate(in_lower.w, in_upper.w));\n        }\n        //----------------------------------------------------------------\n        //----------------------------------------------------------------\n        template <> Colour GenerateComponentwise(Colour in_lower, Colour in_upper)\n        {\n            return Colour(Generate(in_lower.r, in_upper.r), Generate(in_lower.g, in_upper.g), Generate(in_lower.b, in_upper.b), Generate(in_lower.a, in_upper.a));\n        }\n        //----------------------------------------------------------------\n        //----------------------------------------------------------------\n        std::mt19937& GetRandomNumberGenerator()\n        {\n#ifdef CS_TARGETPLATFORM_IOS\n            @autoreleasepool\n            {\n                NSMutableDictionary* threadLocalDict = [[NSThread currentThread] threadDictionary];\n            \n                NSString* key = [NSString stringWithCString:k_rngKey encoding:NSUTF8StringEncoding];\n                RNGContainer* rngContainer = (RNGContainer*)[threadLocalDict objectForKey:key];\n                if (rngContainer == nil)\n                {\n                    std::mt19937 newRandomNumberGenerator(GenerateSeed());\n                    rngContainer = [[RNGContainer alloc] initWithRNG:newRandomNumberGenerator];\n                    [threadLocalDict setObject:rngContainer forKey:key];\n                    [rngContainer release];\n                }\n                \n                return [rngContainer rng];\n            }\n#elif CS_TARGETPLATFORM_WINDOWS\n            if (g_randomNumberGenerator == nullptr)\n            {\n                g_randomNumberGenerator = new (g_rngMemory) std::mt19937(GenerateSeed());\n            }\n\n            return *g_randomNumberGenerator;\n#else\n            return g_randomNumberGenerator;\n#endif\n        }\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Core/Math/Random.h",
    "content": "//\n//  Random.h\n//  ChilliSource\n//  Created by Ian Copland on 24/10/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_MATH_RANDOM_H_\n#define _CHILLISOURCE_CORE_MATH_RANDOM_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Math/NumericLimits.h>\n\n#include <random>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    /// A collection of thread-safe methods which can be used to generate pseudo\n    /// random numbers.\n    ///\n    /// @author Ian Copland\n    //------------------------------------------------------------------------------\n    namespace Random\n    {\n        //------------------------------------------------------------------------------\n        /// Generates a pseudo-random value of the requested type within the given range.\n        /// Defaults to the maximum possible range for the given type.\n        ///\n        /// This is thread-safe.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param [Optional] The lower value, inclusive.\n        /// @param [Optional] The upper value, inclusive.\n        ///\n        /// @return A value within the range.\n        //------------------------------------------------------------------------------\n        template <typename TType> TType Generate(TType in_lower = NumericLimits::Lowest<TType>(), TType in_upper = NumericLimits::Highest<TType>());\n        //------------------------------------------------------------------------------\n        /// Generates a pseudo-random number in the range between 0.0 and 1.0 for the\n        /// given type.\n        ///\n        /// This is thread safe.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @return A value within the range.\n        //------------------------------------------------------------------------------\n        template <typename TType> TType GenerateNormalised();\n        //------------------------------------------------------------------------------\n        /// Generates a pseudo-random direction vector in 2 dimensions with uniform\n        /// distribution.\n        ///\n        /// This is thread-safe.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @return A direction vector.\n        //------------------------------------------------------------------------------\n        template <typename TType> GenericVector2<TType> GenerateDirection2D();\n        //------------------------------------------------------------------------------\n        /// Generates a pseudo-random direction vector in 3 dimensions with uniform\n        /// distribution.\n        ///\n        /// This is thread-safe.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @return A direction vector.\n        //------------------------------------------------------------------------------\n        template <typename TType> GenericVector3<TType> GenerateDirection3D();\n        //------------------------------------------------------------------------------\n        /// Generates a pseudo-random direction vector in 4 dimensions with uniform\n        /// distribution.\n        ///\n        /// This is thread-safe.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @return A direction vector.\n        //------------------------------------------------------------------------------\n        template <typename TType> GenericVector4<TType> GenerateDirection4D();\n        //------------------------------------------------------------------------------\n        /// Generates a pseudo-random direction vector in 4 dimensions with uniform\n        /// distribution.\n        ///\n        /// This is thread-safe.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @return A direction vector.\n        //------------------------------------------------------------------------------\n        template <typename TType> GenericVector4<TType> GenerateDirection4D();\n        //------------------------------------------------------------------------------\n        /// Generates a pseudo-random value between the two given values. If the value\n        /// has multiple components, each will be randomised individually, otherwise\n        /// this is identical to Generate().\n        ///\n        /// This is thread-safe.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The lower value, inclusive.\n        /// @param The upper value, inclusive.\n        ///\n        /// @return The value in the given range.\n        //------------------------------------------------------------------------------\n        template <typename TType> TType GenerateComponentwise(TType in_lower = NumericLimits::Lowest<TType>(), TType in_upper = NumericLimits::Highest<TType>());\n    }\n}\n\n#include <ChilliSource/Core/Math/RandomImpl.h>\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Math/RandomImpl.h",
    "content": "//\n//  RandomImpl.h\n//  ChilliSource\n//  Created by Ian Copland on 06/01/2015.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2015 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_MATH_RANDOMIMPL_H_\n#define _CHILLISOURCE_CORE_MATH_RANDOMIMPL_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Math/Random.h>\n\n#include <algorithm>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    /// A collection of thread-safe methods which can be used to generate pseudo\n    /// random numbers.\n    ///\n    /// @author Ian Copland\n    //------------------------------------------------------------------------------\n    namespace Random\n    {\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return Returns the random number generator for the current\n        /// thread.\n        //------------------------------------------------------------------------------\n        std::mt19937& GetRandomNumberGenerator();\n        //------------------------------------------------------------------------------\n        /// Specialisation of GenerateComponentwise() for values\n        /// of type Vector2.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The lower value, inclusive.\n        /// @param The upper value, inclusive.\n        ///\n        /// @return The value in the given range.\n        //------------------------------------------------------------------------------\n        template <> Vector2 GenerateComponentwise(Vector2 in_lower, Vector2 in_upper);\n        //------------------------------------------------------------------------------\n        /// Specialisation of GenerateComponentwise() for values\n        /// of type Vector3.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The lower value, inclusive.\n        /// @param The upper value, inclusive.\n        ///\n        /// @return The value in the given range.\n        //------------------------------------------------------------------------------\n        template <> Vector3 GenerateComponentwise(Vector3 in_lower, Vector3 in_upper);\n        //------------------------------------------------------------------------------\n        /// Specialisation of GenerateComponentwise() for values\n        /// of type Vector4.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The lower value, inclusive.\n        /// @param The upper value, inclusive.\n        ///\n        /// @return The value in the given range.\n        //------------------------------------------------------------------------------\n        template <> Vector4 GenerateComponentwise(Vector4 in_lower, Vector4 in_upper);\n        //------------------------------------------------------------------------------\n        /// Specialisation of GenerateComponentwise() for values\n        /// of type Matrix3.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The lower value, inclusive.\n        /// @param The upper value, inclusive.\n        ///\n        /// @return The value in the given range.\n        //------------------------------------------------------------------------------\n        template <> Matrix3 GenerateComponentwise(Matrix3 in_lower, Matrix3 in_upper);\n        //------------------------------------------------------------------------------\n        /// Specialisation of GenerateComponentwise() for values\n        /// of type Matrix4.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The lower value, inclusive.\n        /// @param The upper value, inclusive.\n        ///\n        /// @return The value in the given range.\n        //------------------------------------------------------------------------------\n        template <> Matrix4 GenerateComponentwise(Matrix4 in_lower, Matrix4 in_upper);\n        //------------------------------------------------------------------------------\n        /// Specialisation of GenerateComponentwise() for values\n        /// of type Quaternion.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The lower value, inclusive.\n        /// @param The upper value, inclusive.\n        ///\n        /// @return The value in the given range.\n        //------------------------------------------------------------------------------\n        template <> Quaternion GenerateComponentwise(Quaternion in_lower, Quaternion in_upper);\n        //------------------------------------------------------------------------------\n        /// Specialisation of GenerateComponentwise() for values\n        /// of type Colour.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The lower value, inclusive.\n        /// @param The upper value, inclusive.\n        ///\n        /// @return The value in the given range.\n        //------------------------------------------------------------------------------\n        template <> Colour GenerateComponentwise(Colour in_lower, Colour in_upper);\n        //------------------------------------------------------------------------------\n        /// A simple class which uses template specialisation to determine which of the\n        /// 3 random number generation types should be used: Integer, Float or Generic.\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------------------------------------\n        template <typename TType, bool = std::is_integral<TType>::value, bool = std::is_floating_point<TType>::value> struct RandomNumberGenerator\n        {\n            //------------------------------------------------------------------------------\n            /// Generates a value in the given range. Unspecialised, this uses a random\n            /// float between 0.0 and 1.0 to interpolate between the min and max.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param The lower value.\n            /// @param The upper value.\n            ///\n            /// @return The generated value.\n            //------------------------------------------------------------------------------\n            static TType Generate(TType in_lower, TType in_upper)\n            {\n                return in_lower + (in_upper - in_lower) * GenerateNormalised<f32>();\n            }\n        };\n        //------------------------------------------------------------------------------\n        /// A specialisation of the random number generator for integer types.\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------------------------------------\n        template <typename TType> struct RandomNumberGenerator<TType, true, false>\n        {\n            //------------------------------------------------------------------------------\n            /// Generates an integer value in the given range. Uses an integer distribution.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param The lower value.\n            /// @param The upper value.\n            ///\n            /// @return The generated value.\n            //------------------------------------------------------------------------------\n            static TType Generate(TType in_lower, TType in_upper)\n            {\n                TType lower = std::min(in_lower, in_upper);\n                TType upper = std::max(in_lower, in_upper);\n\n                std::uniform_int_distribution<TType> distribution(lower, upper);\n                return distribution(GetRandomNumberGenerator());\n            }\n        };\n        //------------------------------------------------------------------------------\n        /// A specialisation of the random number generator for floating point types.\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------------------------------------\n        template <typename TType> struct RandomNumberGenerator<TType, false, true>\n        {\n            //------------------------------------------------------------------------------\n            /// Generates an floating point value in the given range. Uses a floating point\n            //// distribution.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param The minimum value.\n            /// @param The maximum value.\n            ///\n            /// @return The generated value.\n            //------------------------------------------------------------------------------\n            static TType Generate(TType in_lower, TType in_upper)\n            {\n                TType lower = std::min(in_lower, in_upper);\n                TType upper = std::max(in_lower, in_upper);\n\n                std::uniform_real_distribution<TType> distribution(lower, upper);\n                return distribution(GetRandomNumberGenerator());\n            }\n        };\n        //------------------------------------------------------------------------------\n        //------------------------------------------------------------------------------\n        template <typename TType> TType Generate(TType in_lower, TType in_upper)\n        {\n            return RandomNumberGenerator<TType>::Generate(in_lower, in_upper);\n        }\n        //------------------------------------------------------------------------------\n        //------------------------------------------------------------------------------\n        template <typename TType> TType GenerateNormalised()\n        {\n            return Generate<TType>(TType(0), TType(1));\n        }\n        //------------------------------------------------------------------------------\n        //------------------------------------------------------------------------------\n        template <typename TType> GenericVector2<TType> GenerateDirection2D()\n        {\n            GenericVector2<TType> vector(Generate(TType(-1), TType(1)), Generate(TType(-1), TType(1)));\n            vector.Normalise();\n            return vector;\n        }\n        //------------------------------------------------------------------------------\n        //------------------------------------------------------------------------------\n        template <typename TType> GenericVector3<TType> GenerateDirection3D()\n        {\n            GenericVector3<TType> vector(Generate(TType(-1), TType(1)), Generate(TType(-1), TType(1)), Generate(TType(-1), TType(1)));\n            vector.Normalise();\n            return vector;\n        }\n        //------------------------------------------------------------------------------\n        //------------------------------------------------------------------------------\n        template <typename TType> GenericVector4<TType> GenerateDirection4D()\n        {\n            GenericVector4<TType> vector(Generate(TType(-1), TType(1)), Generate(TType(-1), TType(1)), Generate(TType(-1), TType(1)), Generate(TType(-1), TType(1)));\n            vector.Normalise();\n            return vector;\n        }\n        //------------------------------------------------------------------------------\n        //------------------------------------------------------------------------------\n        template <typename TType> TType GenerateComponentwise(TType in_lower, TType in_upper)\n        {\n            return Generate(in_lower, in_upper);\n        }\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Math/UnifiedCoordinates.cpp",
    "content": "//\n//  UnifiedCoordinates.cpp\n//  ChilliSource\n//  Created by Scott Downie on 22/04/2011.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2011 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Core/Math/UnifiedCoordinates.h>\n\nnamespace ChilliSource\n{\n    const UnifiedVector2 UnifiedVector2::ZERO(Vector2::k_zero, Vector2::k_zero);\n    \n    //------------------------------------------------------\n    /// Get Absolute\n    ///\n    /// @return Absolute vector\n    //------------------------------------------------------\n    const Vector2& UnifiedVector2::GetAbsolute() const\n    {\n        return vAbsolute;\n    }\n    //------------------------------------------------------\n    /// Get Relative\n    ///\n    /// @return Relative vector\n    //------------------------------------------------------\n    const Vector2& UnifiedVector2::GetRelative() const\n    {\n        return vRelative;\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Core/Math/UnifiedCoordinates.h",
    "content": "//\n//  UnifiedCoordinates.h\n//  ChilliSource\n//  Created by Scott Downie on 22/04/2011.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2011 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_GUI_UNIFIED_COORDINATES_H_\n#define _CHILLISOURCE_GUI_UNIFIED_COORDINATES_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Math/Vector2.h>\n\n//---------------------------------------------------------------\n/// Unified Co-ordinates\n///\n/// Specify position, scaling etc in relative and absolute terms.\n///\n/// Relative co-ordinates are described in normalized units of \n/// the parent. i.e. the parent is bound by 0.0 - 1.0. Setting\n/// a relative size of the view as (0.5f, 1.5f) would set the \n/// views dimensions to half the width of the parent and 1.5\n/// times the height of the parent.\n///\n/// Absolute co-ordinates are described in dips and are applied\n/// to the relative term. Using the above example setting the\n/// absolute term to (10.0f, 10.0f) would add 10 units to the\n/// width and height of the view once the relative term has \n/// been applied.\n//--------------------------------------------------------------\nnamespace ChilliSource\n{\n    struct UnifiedScalar\n    {\n        UnifiedScalar() : fRelative(0.0f), fAbsolute(0.0f){}\n        UnifiedScalar(f32 infRel, f32 infAbs) : fRelative(infRel), fAbsolute(infAbs){}\n\n        f32 fRelative;\n        f32 fAbsolute;\n    };\n\n    struct UnifiedVector2\n    {\n        UnifiedVector2(){}\n        UnifiedVector2(const Vector2& invRelative, const Vector2& invAbsolute) : vRelative(invRelative), vAbsolute(invAbsolute){}\n        UnifiedVector2(f32 infRelX, f32 infRelY, f32 infAbsX, f32 infAbsY) : vRelative(infRelX, infRelY), vAbsolute(infAbsX, infAbsY){}\n\n        //------------------------------------------------------\n        /// Get Absolute\n        ///\n        /// @return Absolute vector\n        //------------------------------------------------------\n        const Vector2& GetAbsolute() const;\n        //------------------------------------------------------\n        /// Get Relative\n        ///\n        /// @return Relative vector\n        //------------------------------------------------------\n        const Vector2& GetRelative() const;\n\n        Vector2 vRelative;\n        Vector2 vAbsolute;\n\n        //---------------------------------\n        // Operators\n        //---------------------------------\n        UnifiedVector2& operator=(const UnifiedVector2 &Vec)\n        {this->vRelative = Vec.vRelative; this->vAbsolute = Vec.vAbsolute; return *this;}\n\n        UnifiedVector2 operator+(const UnifiedVector2 &Vec) const\n        {UnifiedVector2 Result; Result.vRelative = this->vRelative + Vec.vRelative; Result.vAbsolute = this->vAbsolute + Vec.vAbsolute; return Result;}\n        \n        UnifiedVector2 operator-(const UnifiedVector2 &Vec) const\n        {UnifiedVector2 Result; Result.vRelative = this->vRelative - Vec.vRelative; Result.vAbsolute = this->vAbsolute - Vec.vAbsolute; return Result;}\n\n        UnifiedVector2 operator*(const UnifiedVector2 &Vec) const\n        {UnifiedVector2 Result; Result.vRelative = this->vRelative * Vec.vRelative; Result.vAbsolute = this->vAbsolute * Vec.vAbsolute; return Result;}\n        \n        UnifiedVector2 operator*(f32 infValue) const\n        {UnifiedVector2 Result; Result.vRelative = this->vRelative * infValue; Result.vAbsolute = this->vAbsolute * infValue; return Result;}\n\n        UnifiedVector2 operator/(const UnifiedVector2 &Vec) const\n        {UnifiedVector2 Result; Result.vRelative = this->vRelative / Vec.vRelative; Result.vAbsolute = this->vAbsolute / Vec.vAbsolute; return Result;}\n        \n        UnifiedVector2 operator/(f32 infValue) const\n        {UnifiedVector2 Result; Result.vRelative = this->vRelative / infValue; Result.vAbsolute = this->vAbsolute / infValue; return Result;}\n\n        const UnifiedVector2& operator+=(const UnifiedVector2 &Vec)\n        {this->vRelative += Vec.vRelative; this->vAbsolute += Vec.vAbsolute; return *this;}\n\n        const UnifiedVector2& operator-=(const UnifiedVector2 &Vec)\n        {this->vRelative -= Vec.vRelative; this->vAbsolute -= Vec.vAbsolute; return *this;}\n\n        const UnifiedVector2& operator*=(const UnifiedVector2 &Vec)\n        {this->vRelative *= Vec.vRelative; this->vAbsolute *= Vec.vAbsolute; return *this;}\n\n        const UnifiedVector2& operator/=(const UnifiedVector2 &Vec)\n        {this->vRelative /= Vec.vRelative; this->vAbsolute /= Vec.vAbsolute; return *this;}\n\n        bool operator==(const UnifiedVector2 &Vec) const\n        {return (Vec.vRelative == vRelative && Vec.vAbsolute == vAbsolute);}\n\n        bool operator!=(const UnifiedVector2 &Vec) const\n        {return (Vec.vRelative != vRelative || Vec.vAbsolute != vAbsolute);}\n        \n        static const UnifiedVector2 ZERO;\n    };\n\n    struct UnifiedRectangle\n    {\n        UnifiedRectangle(){}\n        UnifiedRectangle(const UnifiedVector2& invTL, const UnifiedVector2& invTR, const UnifiedVector2& invBL, const UnifiedVector2& invBR)\n        : vTopLeft(invTL), vTopRight(invTR), vBottomLeft(invBL), vBottomRight(invBR){}\n\n        UnifiedVector2 vTopLeft;\n        UnifiedVector2 vTopRight;\n        UnifiedVector2 vBottomLeft;\n        UnifiedVector2 vBottomRight;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Math/Vector2.h",
    "content": "//\n//  Vector2.h\n//  ChilliSource\n//  Created by Ian Copland on 20/04/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_MATH_VECTOR2_H_\n#define _CHILLISOURCE_CORE_MATH_VECTOR2_H_\n\n#include <ChilliSource/ChilliSource.h>\n\nnamespace ChilliSource\n{\n    //-----------------------------------------------------------\n    /// A generic two dimensional mathematical vector. Typically\n    /// the type specific typedefs of this class would be used\n    /// over direct use. For example:\n    ///\t\tVector2 -> GenericVector2<f32>\n    ///\t\tFloat2 -> GenericVector2<f32>\n    ///\t\tInteger2 -> GenericVector2<s32>\n    ///\n    /// @author Ian Copland\n    //-----------------------------------------------------------\n    template <typename TType> class GenericVector2 final\n    {\n    public:\n        //-----------------------------------------------------\n        /// Constants\n        //-----------------------------------------------------\n        static const GenericVector2<TType> k_zero;\n        static const GenericVector2<TType> k_one;\n        static const GenericVector2<TType> k_unitPositiveX;\n        static const GenericVector2<TType> k_unitNegativeX;\n        static const GenericVector2<TType> k_unitPositiveY;\n        static const GenericVector2<TType> k_unitNegativeY;\n        //-----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param A vector.\n        ///\n        /// @return a normalised copy of the vector.\n        //-----------------------------------------------------\n        static GenericVector2<TType> Normalise(GenericVector2<TType> in_a);\n        //-----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param A vector.\n        ///\n        /// @return An inversed copy of the vector.\n        //-----------------------------------------------------\n        static GenericVector2<TType> Inverse(GenericVector2<TType> in_a);\n        //-----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param A vector.\n        ///\n        /// @return an absolute copy of the vector.\n        //-----------------------------------------------------\n        static GenericVector2<TType> Abs(GenericVector2<TType> in_a);\n        //-----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param a vector.\n        /// @param another vector.\n        ///\n        /// @return A vector containing the minimum value for\n        /// each component in each vector.\n        //-----------------------------------------------------\n        static GenericVector2<TType> Min(GenericVector2<TType> in_a, const GenericVector2<TType>& in_b);\n        //-----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param a vector.\n        /// @param another vector.\n        ///\n        /// @return A vector containing the maximum value for\n        /// each component in each vector.\n        //-----------------------------------------------------\n        static GenericVector2<TType> Max(GenericVector2<TType> in_a, const GenericVector2<TType>& in_b);\n        //-----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param A vector.\n        /// @param The minimum vector.\n        /// @param The maximum vector.\n        ///\n        /// @return A vector in which each component is clamped\n        /// between the equivalent in the min and max vectors.\n        //-----------------------------------------------------\n        static GenericVector2<TType> Clamp(GenericVector2<TType> in_value, const GenericVector2<TType>& in_min, const GenericVector2<TType>& in_max);\n        //-----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param a vector.\n        /// @param another vector.\n        /// @param The interpolation factor.\n        ///\n        /// @return The interpolated vector.\n        //-----------------------------------------------------\n        static GenericVector2<TType> Lerp(GenericVector2<TType> in_a, const GenericVector2<TType>& in_b, f32 in_t);\n        //-----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param a vector.\n        /// @param another vector.\n        ///\n        /// @return the dot product of these two vectors.\n        //-----------------------------------------------------\n        static TType DotProduct(const GenericVector2<TType>& in_a, const GenericVector2<TType>& in_b);\n        //-----------------------------------------------------\n        /// Treats the two vectors as 3D with the z-component\n        /// set to zero to calculate the z component of the\n        /// cross product.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param  A vector.\n        /// @param  Another vector.\n        ///\n        /// @return The z component of the cross product.\n        //-----------------------------------------------------\n        static TType CrossProductZ(const GenericVector2<TType>& in_a, const GenericVector2<TType>& in_b);\n        //-----------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param  A vector.\n        /// @param  Another vector.\n        ///\n        /// @return The angle between the two vectors in\n        /// radians.\n        //-----------------------------------------------------\n        static TType Angle(const GenericVector2<TType>& in_a, const GenericVector2<TType>& in_b);\n        //-----------------------------------------------------\n        /// Returns a vector that is the result of rotating the\n        /// given vector by the given angle.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The vector.\n        /// @param The angle to rotate through in radians.\n        ///\n        /// @return The new vector after rotation.\n        //-----------------------------------------------------\n        static GenericVector2<TType> Rotate(GenericVector2<TType> in_a, TType in_angle);\n        //-----------------------------------------------------\n        /// calculates the result of transforming the vector by\n        /// the given regular transform matrix. This is more\n        /// efficient than standard matrix multiplication but\n        /// will only work for trasform matrices where the point\n        /// transformation is in the form:\n        ///\n        ///  Result = |x y 1|| a b 0 |\n        ///                  | c d 0 |\n        ///                  | g h 1 |\n        ///\n        /// This is the case for all non-projective transforms.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The vector.\n        /// @param The transform matrix.\n        //-----------------------------------------------------\n        static GenericVector2<TType> Transform2x3(const GenericVector2<TType>& in_a, const GenericMatrix3<TType>& in_transform);\n        \n        ///\n        /// @param a\n        ///     First position vector\n        /// @param b\n        ///     Second position vector\n        ///\n        /// @return Distance between the 2 given positions (magnitude of the vector between them)\n        ///\n        static TType Distance(const GenericVector2<TType>& a, const GenericVector2<TType>& b);\n        \n        //-----------------------------------------------------\n        /// Constructor\n        ///\n        /// @author Ian Copland\n        //-----------------------------------------------------\n        GenericVector2();\n        //-----------------------------------------------------\n        /// Constructor\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param the x component.\n        /// @param the y component.\n        //-----------------------------------------------------\n        explicit GenericVector2(TType in_x, TType in_y);\n        //-----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return the length of the vector.\n        //-----------------------------------------------------\n        TType Length() const;\n        //-----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return the length of the vector squared\n        //-----------------------------------------------------\n        TType LengthSquared() const;\n        //-----------------------------------------------------\n        /// Normalises the contents of this vector.\n        ///\n        /// @author Ian Copland\n        //-----------------------------------------------------\n        void Normalise();\n        //-----------------------------------------------------\n        /// Sets this contents of this vector to its inverse.\n        ///\n        /// @author Ian Copland\n        //-----------------------------------------------------\n        void Inverse();\n        //-----------------------------------------------------\n        /// Sets this vector to it's absolute value.\n        ///\n        /// @author Ian Copland\n        //-----------------------------------------------------\n        void Abs();\n        //-----------------------------------------------------\n        /// Sets each component in this vector to which ever is\n        /// smaller, itself or the equivelent in the given\n        /// vector.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The other vector.\n        //-----------------------------------------------------\n        void Min(const GenericVector2<TType>& in_b);\n        //-----------------------------------------------------\n        /// Sets each component in this vector to which ever is\n        /// greater, itself or the equivelent in the given\n        /// vector.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The other vector.\n        //-----------------------------------------------------\n        void Max(const GenericVector2<TType>& in_b);\n        //-----------------------------------------------------\n        /// Clamps each component in this vector between the\n        /// values described by the min and max vectors.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The minimum vector.\n        /// @param The maximum vector.\n        //-----------------------------------------------------\n        void Clamp(const GenericVector2<TType>& in_min, const GenericVector2<TType>& in_max);\n        //-----------------------------------------------------\n        /// Sets the contents of the vector to the result of\n        /// interpolating between this and the given vector\n        /// with the given interpolation factor.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The other vector.\n        /// @param The interpolation factor.\n        //-----------------------------------------------------\n        void Lerp(const GenericVector2<TType>& in_b, f32 in_t);\n        //-----------------------------------------------------\n        /// Rotates this vector by the given angle.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The angle to rotate though in radians.\n        //-----------------------------------------------------\n        void Rotate(TType in_angle);\n        //-----------------------------------------------------\n        /// Sets this vector to the result of transforming by\n        /// the given regular transform matrix. This is more\n        /// efficient than standard matrix multiplication but\n        /// will only work for trasform matrices where the point\n        /// transformation is in the form:\n        ///\n        ///  Result = |x y 1|| a b 0 |\n        ///                  | c d 0 |\n        ///                  | e f 0 |\n        ///\n        /// This is the case for all non-projective transforms.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The transform matrix.\n        //-----------------------------------------------------\n        void Transform2x3(const GenericMatrix3<TType>& in_transform);\n        //-----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param Another vector.\n        ///\n        /// @return This vector after having the given vector\n        /// added to it.\n        //-----------------------------------------------------\n        GenericVector2<TType>& operator+=(const GenericVector2<TType>& in_b);\n        //-----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param Another vector.\n        ///\n        /// @return This vector after having the given vector\n        /// subtracted from it.\n        //-----------------------------------------------------\n        GenericVector2<TType>& operator-=(const GenericVector2<TType>& in_b);\n        //-----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param Another vector.\n        ///\n        /// @return This vector after being multiplied by the\n        /// given vector.\n        //-----------------------------------------------------\n        GenericVector2<TType>& operator*=(const GenericVector2<TType>& in_b);\n        //-----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param Another vector.\n        ///\n        /// @return This vector after being divided by the\n        /// given vector.\n        //-----------------------------------------------------\n        GenericVector2<TType>& operator/=(const GenericVector2<TType>& in_b);\n        //-----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param A matrix.\n        ///\n        /// @return This vector after being multiplied by the\n        /// given matrix.\n        //-----------------------------------------------------\n        GenericVector2<TType>& operator*=(const GenericMatrix3<TType>& in_b);\n        //-----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param  A scalar.\n        ///\n        /// @return This vector after being multiplied by the\n        /// given scalar.\n        //-----------------------------------------------------\n        GenericVector2<TType>& operator*=(TType in_b);\n        //-----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param A scalar.\n        ///\n        /// @return This vector after being divided by the\n        /// given scalar.\n        //-----------------------------------------------------\n        GenericVector2<TType>& operator/=(TType in_b);\n        \n        TType x;\n        TType y;\n    };\n    //-----------------------------------------------------\n    /// @author Ian Copland\n    ///\n    /// @param Vector A\n    /// @param Vector B\n    ///\n    /// @return The result of A + B.\n    //-----------------------------------------------------\n    template <typename TType> GenericVector2<TType> operator+(GenericVector2<TType> in_a, const GenericVector2<TType>& in_b);\n    //-----------------------------------------------------\n    /// @author Ian Copland\n    ///\n    /// @param Vector A\n    /// @param Vector B\n    ///\n    /// @return The result of A - B.\n    //-----------------------------------------------------\n    template <typename TType> GenericVector2<TType> operator-(GenericVector2<TType> in_a, const GenericVector2<TType>& in_b);\n    //-----------------------------------------------------\n    /// @author Ian Copland\n    ///\n    /// @param Vector A\n    /// @param Vector B\n    ///\n    /// @return The result of A * B.\n    //-----------------------------------------------------\n    template <typename TType> GenericVector2<TType> operator*(GenericVector2<TType> in_a, const GenericVector2<TType>& in_b);\n    //-----------------------------------------------------\n    /// @author Ian Copland\n    ///\n    /// @param Vector A\n    /// @param Vector B\n    ///\n    /// @return The result of A / B.\n    //-----------------------------------------------------\n    template <typename TType> GenericVector2<TType> operator/(GenericVector2<TType> in_a, const GenericVector2<TType>& in_b);\n    //-----------------------------------------------------\n    /// @author Ian Copland\n    ///\n    /// @param Vector A\n    /// @param Matrix B\n    ///\n    /// @return The result of A * B\n    //-----------------------------------------------------\n    template <typename TType> GenericVector2<TType> operator*(const GenericVector2<TType>& in_a, const GenericMatrix3<TType>& in_b);\n    //-----------------------------------------------------\n    /// @author Ian Copland\n    ///\n    /// @param Vector A\n    /// @param Scalar B\n    ///\n    /// @return The result of A * B.\n    //-----------------------------------------------------\n    template <typename TType> GenericVector2<TType> operator*(GenericVector2<TType> in_a, TType in_b);\n    //-----------------------------------------------------\n    /// @author Ian Copland\n    ///\n    /// @param Scalar A\n    /// @param Vector B\n    ///\n    /// @return The result of A * B.\n    //-----------------------------------------------------\n    template <typename TType> GenericVector2<TType> operator*(TType in_a, GenericVector2<TType> in_b);\n    //-----------------------------------------------------\n    /// @author Ian Copland\n    ///\n    /// @param Vector A\n    /// @param Scalar B\n    ///\n    /// @return The result of A / B.\n    //-----------------------------------------------------\n    template <typename TType> GenericVector2<TType> operator/(GenericVector2<TType> in_a, TType in_b);\n    //-----------------------------------------------------\n    /// @author Ian Copland\n    ///\n    /// @param Vector A\n    /// @param Vector B\n    ///\n    /// @return Whether or not the two vectors are equal\n    //-----------------------------------------------------\n    template <typename TType> bool operator==(const GenericVector2<TType>& in_a, const GenericVector2<TType>& in_b);\n    //-----------------------------------------------------\n    /// @author Ian Copland\n    ///\n    /// @param Vector A\n    /// @param Vector B\n    ///\n    /// @return Whether or not the two vectors are in-equal\n    //-----------------------------------------------------\n    template <typename TType> bool operator!=(const GenericVector2<TType>& in_a, const GenericVector2<TType>& in_b);\n    //-----------------------------------------------------\n    /// @author Ian Copland\n    ///\n    /// @param in_a - A vector.\n    ///\n    /// @return A negated copy of the given vector.\n    //-----------------------------------------------------\n    template <typename TType> GenericVector2<TType> operator-(GenericVector2<TType> in_a);\n}\n\n//----------------------------------------------------\n// These are included here to avoid circular inclusion\n// issues. At this stage the class has been defined\n// which is enough for the classes included to use it.\n//----------------------------------------------------\n#include <ChilliSource/Core/Math/Matrix3.h>\n\n#include <algorithm>\n#include <assert.h>\n#include <cmath>\n\nnamespace ChilliSource\n{\n    template <typename TType> const GenericVector2<TType> GenericVector2<TType>::k_zero(0, 0);\n    template <typename TType> const GenericVector2<TType> GenericVector2<TType>::k_one(1, 1);\n    template <typename TType> const GenericVector2<TType> GenericVector2<TType>::k_unitPositiveX(1, 0);\n    template <typename TType> const GenericVector2<TType> GenericVector2<TType>::k_unitNegativeX(-1, 0);\n    template <typename TType> const GenericVector2<TType> GenericVector2<TType>::k_unitPositiveY(0, 1);\n    template <typename TType> const GenericVector2<TType> GenericVector2<TType>::k_unitNegativeY(0, -1);\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> GenericVector2<TType> GenericVector2<TType>::Normalise(GenericVector2<TType> in_a)\n    {\n        in_a.Normalise();\n        return in_a;\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> GenericVector2<TType> GenericVector2<TType>::Inverse(GenericVector2<TType> in_a)\n    {\n        in_a.Inverse();\n        return in_a;\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> GenericVector2<TType> GenericVector2<TType>::Abs(GenericVector2<TType> in_a)\n    {\n        in_a.Abs();\n        return in_a;\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> GenericVector2<TType> GenericVector2<TType>::Min(GenericVector2<TType> in_a, const GenericVector2<TType>& in_b)\n    {\n        in_a.Min(in_b);\n        return in_a;\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> GenericVector2<TType> GenericVector2<TType>::Max(GenericVector2<TType> in_a, const GenericVector2<TType>& in_b)\n    {\n        in_a.Max(in_b);\n        return in_a;\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> GenericVector2<TType> GenericVector2<TType>::Clamp(GenericVector2<TType> in_value, const GenericVector2<TType>& in_min, const GenericVector2<TType>& in_max)\n    {\n        in_value.Clamp(in_min, in_max);\n        return in_value;\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> GenericVector2<TType> GenericVector2<TType>::Lerp(GenericVector2<TType> in_a, const GenericVector2<TType>& in_b, f32 in_t)\n    {\n        in_a.Lerp(in_b, in_t);\n        return in_a;\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> TType GenericVector2<TType>::DotProduct(const GenericVector2<TType>& in_a, const GenericVector2<TType>& in_b)\n    {\n        return (in_a.x * in_b.x + in_a.y * in_b.y);\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> TType GenericVector2<TType>::CrossProductZ(const GenericVector2<TType> & in_a, const GenericVector2<TType> & in_b)\n    {\n        return (in_a.x * in_b.y - in_a.y * in_b.x);\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> TType GenericVector2<TType>::Angle(const GenericVector2<TType>& in_a, const GenericVector2<TType>& in_b)\n    {\n        return std::abs(std::atan2(in_b.y, in_b.x) - std::atan2(in_a.y, in_a.x));\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> GenericVector2<TType> GenericVector2<TType>::Rotate(GenericVector2<TType> in_a, TType in_angle)\n    {\n        in_a.Rotate(in_angle);\n        return in_a;\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> GenericVector2<TType> GenericVector2<TType>::Transform2x3(const GenericVector2<TType>& in_a, const GenericMatrix3<TType>& in_transform)\n    {\n        GenericVector2<TType> c;\n        c.x = in_a.x * in_transform.m[0] + in_a.y * in_transform.m[3] + in_transform.m[6];\n        c.y = in_a.x * in_transform.m[1] + in_a.y * in_transform.m[4] + in_transform.m[7];\n        return c;\n    }\n    //-----------------------------------------------------\n    template <typename TType> TType GenericVector2<TType>::Distance(const GenericVector2<TType>& a, const GenericVector2<TType>& b)\n    {\n        return (b - a).Length();\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> GenericVector2<TType>::GenericVector2()\n    : x(0), y(0)\n    {\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> GenericVector2<TType>::GenericVector2(TType in_x, TType in_y)\n    : x(in_x), y(in_y)\n    {\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> TType GenericVector2<TType>::LengthSquared() const\n    {\n        return (x * x + y * y);\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> TType GenericVector2<TType>::Length() const\n    {\n        return (std::sqrt(x * x + y * y));\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> void GenericVector2<TType>::Normalise()\n    {\n        TType length = Length();\n        if (length != 0)\n        {\n            TType invLength = 1 / length;\n            x *= invLength;\n            y *= invLength;\n        }\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> void GenericVector2<TType>::Inverse()\n    {\n        if (x != 0)\n        {\n            x = 1 / x;\n        }\n        \n        if (y != 0)\n        {\n            y = 1 / y;\n        }\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> void GenericVector2<TType>::Abs()\n    {\n        x = std::abs(x);\n        y = std::abs(y);\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> void GenericVector2<TType>::Min(const GenericVector2<TType>& in_b)\n    {\n        x = std::min(x, in_b.x);\n        y = std::min(y, in_b.y);\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> void GenericVector2<TType>::Max(const GenericVector2<TType>& in_b)\n    {\n        x = std::max(x, in_b.x);\n        y = std::max(y, in_b.y);\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> void GenericVector2<TType>::Clamp(const GenericVector2<TType>& in_min, const GenericVector2<TType>& in_max)\n    {\n        assert(in_min.x <= in_max.x && in_min.y <= in_max.y);\n        \n        x = std::min(std::max(x, in_min.x), in_max.x);\n        y = std::min(std::max(y, in_min.y), in_max.y);\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> void GenericVector2<TType>::Lerp(const GenericVector2<TType>& in_b, f32 in_t)\n    {\n        f32 t = std::min(std::max(in_t, 0.0f), 1.0f);\n        *this = (*this + t * (in_b - *this));\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> void GenericVector2<TType>::Rotate(TType in_angle)\n    {\n        GenericVector2<TType> b = *this;\n        TType sinA = (TType)std::sin(in_angle);\n        TType cosA = (TType)std::cos(in_angle);\n        x =  b.x * cosA + b.y * sinA;\n        y = -b.x * sinA + b.y * cosA;\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> void GenericVector2<TType>::Transform2x3(const GenericMatrix3<TType>& in_transform)\n    {\n        GenericVector2<TType> b = *this;\n        x = b.x * in_transform.m[0] + b.y * in_transform.m[3] + in_transform.m[6];\n        y = b.x * in_transform.m[1] + b.y * in_transform.m[4] + in_transform.m[7];\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> GenericVector2<TType>& GenericVector2<TType>::operator+=(const GenericVector2<TType>& in_b)\n    {\n        x += in_b.x;\n        y += in_b.y;\n        return *this;\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> GenericVector2<TType>& GenericVector2<TType>::operator-=(const GenericVector2<TType>& in_b)\n    {\n        x -= in_b.x;\n        y -= in_b.y;\n        return *this;\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> GenericVector2<TType>& GenericVector2<TType>::operator*=(const GenericVector2<TType>& in_b)\n    {\n        x *= in_b.x;\n        y *= in_b.y;\n        return *this;\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> GenericVector2<TType>& GenericVector2<TType>::operator/=(const GenericVector2<TType>& in_b)\n    {\n        x /= in_b.x;\n        y /= in_b.y;\n        return *this;\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> GenericVector2<TType>& GenericVector2<TType>::operator*=(const GenericMatrix3<TType>& in_b)\n    {\n        GenericVector2<TType> c = *this;\n        x = c.x * in_b.m[0] + c.y * in_b.m[3] + in_b.m[6];\n        y = c.x * in_b.m[1] + c.y * in_b.m[4] + in_b.m[7];\n        TType oneOverZ = 1 / (c.x * in_b.m[2] + c.y * in_b.m[5] + in_b.m[8]);\n        *this *= oneOverZ;\n        return *this;\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> GenericVector2<TType>& GenericVector2<TType>::operator*=(TType in_b)\n    {\n        x *= in_b;\n        y *= in_b;\n        return *this;\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> GenericVector2<TType>& GenericVector2<TType>::operator/=(TType in_b)\n    {\n        x /= in_b;\n        y /= in_b;\n        return *this;\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> GenericVector2<TType> operator+(GenericVector2<TType> in_a, const GenericVector2<TType>& in_b)\n    {\n        return (in_a += in_b);\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> GenericVector2<TType> operator-(GenericVector2<TType> in_a, const GenericVector2<TType>& in_b)\n    {\n        return (in_a -= in_b);\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> GenericVector2<TType> operator*(GenericVector2<TType> in_a, const GenericVector2<TType>& in_b)\n    {\n        return (in_a *= in_b);\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> GenericVector2<TType> operator/(GenericVector2<TType> in_a, const GenericVector2<TType>& in_b)\n    {\n        return (in_a /= in_b);\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> GenericVector2<TType> operator*(const GenericVector2<TType>& in_a, const GenericMatrix3<TType>& in_b)\n    {\n        GenericVector2<TType> c;\n        c.x = in_a.x * in_b.m[0] + in_a.y * in_b.m[3] + in_b.m[6];\n        c.y = in_a.x * in_b.m[1] + in_a.y * in_b.m[4] + in_b.m[7];\n        TType oneOverZ = 1 / (c.x * in_b.m[2] + c.y * in_b.m[5] + in_b.m[8]);\n        c *= oneOverZ;\n        return c;\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> GenericVector2<TType> operator*(GenericVector2<TType> in_a, TType in_b)\n    {\n        return (in_a *= in_b);\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> GenericVector2<TType> operator*(TType in_a, GenericVector2<TType> in_b)\n    {\n        return (in_b *= in_a);\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> GenericVector2<TType> operator/(GenericVector2<TType> in_a, TType in_b)\n    {\n        return (in_a /= in_b);\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> bool operator==(const GenericVector2<TType>& in_a, const GenericVector2<TType>& in_b)\n    {\n        return (in_a.x == in_b.x && in_a.y == in_b.y);\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> bool operator!=(const GenericVector2<TType>& in_a, const GenericVector2<TType>& in_b)\n    {\n        return !(in_a == in_b);\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> GenericVector2<TType> operator-(GenericVector2<TType> in_a)\n    {\n        in_a.x = -in_a.x;\n        in_a.y = -in_a.y;\n        return in_a;\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Math/Vector3.h",
    "content": "//\n//  Vector3.h\n//  ChilliSource\n//  Created by Ian Copland on 20/04/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLLISOURCE_CORE_MATH_VECTOR3_H_\n#define _CHILLLISOURCE_CORE_MATH_VECTOR3_H_\n\n#include <ChilliSource/ChilliSource.h>\n\nnamespace ChilliSource\n{\n    //-------------------------------------------------------------------\n    /// A generic three dimensional mathematical vector. Typically\n    /// the type specific typedefs of this class would be used\n    /// over direct use. For example:\n    ///\t\tVector3 -> GenericVector3<f32>\n    ///\t\tFloat3 -> GenericVector3<f32>\n    ///\t\tInteger3 -> GenericVector3<s32>\n    ///\n    /// @author Ian Copland\n    //-------------------------------------------------------------------\n    template <typename TType> class GenericVector3 final\n    {\n    public:\n        //-----------------------------------------------------\n        /// Constants\n        //-----------------------------------------------------\n        static const GenericVector3<TType> k_zero;\n        static const GenericVector3<TType> k_one;\n        static const GenericVector3<TType> k_unitPositiveX;\n        static const GenericVector3<TType> k_unitNegativeX;\n        static const GenericVector3<TType> k_unitPositiveY;\n        static const GenericVector3<TType> k_unitNegativeY;\n        static const GenericVector3<TType> k_unitPositiveZ;\n        static const GenericVector3<TType> k_unitNegativeZ;\n        //-----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param A vector.\n        ///\n        /// @return a normalised copy of the vector.\n        //-----------------------------------------------------\n        static GenericVector3<TType> Normalise(GenericVector3<TType> in_a);\n        //-----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param A vector.\n        ///\n        /// @return An inversed copy of the vector.\n        //-----------------------------------------------------\n        static GenericVector3<TType> Inverse(GenericVector3<TType> in_a);\n        //-----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param A vector.\n        ///\n        /// @return an absolute copy of the vector.\n        //-----------------------------------------------------\n        static GenericVector3<TType> Abs(GenericVector3<TType> in_a);\n        //-----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param a vector.\n        /// @param another vector.\n        ///\n        /// @return A vector containing the minimum value for\n        /// each component in the vectors.\n        //-----------------------------------------------------\n        static GenericVector3<TType> Min(GenericVector3<TType> in_a, const GenericVector3<TType>& in_b);\n        //-----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param a vector.\n        /// @param another vector.\n        ///\n        /// @return A vector containing the maximum value for\n        /// each component in the vectors.\n        //-----------------------------------------------------\n        static GenericVector3<TType> Max(GenericVector3<TType> in_a, const GenericVector3<TType>& in_b);\n        //-----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param A vector.\n        /// @param A minimum vector.\n        /// @param A maximum vector.\n        ///\n        /// @return A vector in which each component is clamped\n        /// between the equivalent in the min and max vectors.\n        //-----------------------------------------------------\n        static GenericVector3<TType> Clamp(GenericVector3<TType> in_value, const GenericVector3<TType>& in_min, const GenericVector3<TType>& in_max);\n        //-----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param a vector.\n        /// @param another vector.\n        /// @param the interpolation factor.\n        ///\n        /// @return The interpolated vector.\n        //-----------------------------------------------------\n        static GenericVector3<TType> Lerp(GenericVector3<TType> in_a, const GenericVector3<TType>& in_b, f32 in_t);\n        //-----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param a vector.\n        /// @param another vector.\n        ///\n        /// @return the dot product of these two vectors.\n        //-----------------------------------------------------\n        static TType DotProduct(const GenericVector3<TType>& in_a, const GenericVector3<TType>& in_b);\n        //-----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param a vector.\n        /// @param another vector.\n        ///\n        /// @return the cross product of these two vectors\n        //-----------------------------------------------------\n        static GenericVector3<TType> CrossProduct(const GenericVector3<TType>& in_a, const GenericVector3<TType>& in_b);\n        //-----------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param  A vector.\n        /// @param  Another vector.\n        ///\n        /// @return The angle between the two vectors in\n        /// radians.\n        //-----------------------------------------------------\n        static TType Angle(const GenericVector3<TType>& in_a, const GenericVector3<TType>& in_b);\n        //-----------------------------------------------------\n        /// Rotates the vector by the given quaternion.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The vector.\n        /// @param The quaternion.\n        ///\n        /// @return The new vector after rotation.\n        //-----------------------------------------------------\n        static GenericVector3<TType> Rotate(GenericVector3<TType> in_a, const GenericQuaternion<TType>& in_b);\n        //-----------------------------------------------------\n        /// calculates the result of transforming the vector by\n        /// the given regular transform matrix. This is more\n        /// efficient than standard matrix multiplication but\n        /// will only work for trasform matrices where the point\n        /// transformation is in the form:\n        ///\n        ///  Result = |x y z 1|| a b c 0 |\n        ///                    | d e f 0 |\n        ///                    | g h i 0 |\n        ///                    | j k l 1 |\n        ///\n        /// This is the case for all non-projective transforms.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The vector.\n        /// @param The transform matrix.\n        //-----------------------------------------------------\n        static GenericVector3<TType> Transform3x4(const GenericVector3<TType>& in_a, const GenericMatrix4<TType>& in_transform);\n        \n        ///\n        /// @param a\n        ///     First position vector\n        /// @param b\n        ///     Second position vector\n        ///\n        /// @return Distance between the 2 given positions (magnitude of the vector between them)\n        ///\n        static TType Distance(const GenericVector3<TType>& a, const GenericVector3<TType>& b);\n        \n        //-----------------------------------------------------\n        /// Constructor\n        ///\n        /// @author Ian Copland\n        //-----------------------------------------------------\n        GenericVector3();\n        //-----------------------------------------------------\n        /// Constructor\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param the x component.\n        /// @param the y component.\n        /// @param the z component.\n        //-----------------------------------------------------\n        explicit GenericVector3(TType in_x, TType in_y, TType in_z);\n        //-----------------------------------------------------\n        /// Constructor\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param A two component vector of the same type.\n        /// @param the z component.\n        //-----------------------------------------------------\n        explicit GenericVector3(const GenericVector2<TType>& in_xy, TType in_z);\n        //-----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return A copy of the XY components of this vector\n        /// as a Vector2.\n        //-----------------------------------------------------\n        GenericVector2<TType> XY() const;\n        //-----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return the length of the vector\n        //-----------------------------------------------------\n        TType Length() const;\n        //-----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return the length of the vector squared\n        //-----------------------------------------------------\n        TType LengthSquared() const;\n        //-----------------------------------------------------\n        /// Normalises the contents of this vector.\n        ///\n        /// @author Ian Copland\n        //-----------------------------------------------------\n        void Normalise();\n        //-----------------------------------------------------\n        /// Sets this contents of this vector to its inverse.\n        ///\n        /// @author Ian Copland\n        //-----------------------------------------------------\n        void Inverse();\n        //-----------------------------------------------------\n        /// Sets this vector to it's absolute value.\n        ///\n        /// @author Ian Copland\n        //-----------------------------------------------------\n        void Abs();\n        //-----------------------------------------------------\n        /// Sets each component in this vector to which ever is\n        /// smaller, itself or the equivelent in the given\n        /// vector.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The other vector.\n        //-----------------------------------------------------\n        void Min(const GenericVector3<TType>& in_b);\n        //-----------------------------------------------------\n        /// Sets each component in this vector to which ever is\n        /// greater, itself or the equivelent in the given\n        /// vector.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The other vector.\n        //-----------------------------------------------------\n        void Max(const GenericVector3<TType>& in_b);\n        //-----------------------------------------------------\n        /// Clamps each component in this vector between the\n        /// values described by the min and max vectors.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param A minimum vector.\n        /// @param A maximum vector.\n        //-----------------------------------------------------\n        void Clamp(const GenericVector3<TType>& in_min, const GenericVector3<TType>& in_max);\n        //-----------------------------------------------------\n        /// Sets the contents of the vector to the result of\n        /// interpolating between this and the given vector\n        /// with the given interpolation factor.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The other vector.\n        /// @param the interpolation factor.\n        //-----------------------------------------------------\n        void Lerp(const GenericVector3<TType>& in_b, f32 in_t);\n        //-----------------------------------------------------\n        /// Sets this vector to the result of the cross product\n        /// between itself and the given vector.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The other vector.\n        //-----------------------------------------------------\n        void CrossProduct(const GenericVector3<TType>& in_b);\n        //-----------------------------------------------------\n        /// Rotates this vector by the given quaternion.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The quaternion to rotate by.\n        //-----------------------------------------------------\n        void Rotate(const GenericQuaternion<TType>& in_b);\n        //-----------------------------------------------------\n        /// Sets this vector to the result of transforming by\n        /// the given regular transform matrix. This is more\n        /// efficient than standard matrix multiplication but\n        /// will only work for trasform matrices where the point\n        /// transformation is in the form:\n        ///\n        ///  Result = |x y z 1|| a b c 0 |\n        ///                    | d e f 0 |\n        ///                    | g h i 0 |\n        ///                    | j k l 1 |\n        ///\n        /// This is the case for all non-projective transforms.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The transform matrix.\n        //-----------------------------------------------------\n        void Transform3x4(const GenericMatrix4<TType>& in_transform);\n        //-----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param Another vector.\n        ///\n        /// @return This vector after the given vector has been\n        /// added to it.\n        //-----------------------------------------------------\n        GenericVector3<TType>& operator+=(const GenericVector3<TType>& in_b);\n        //-----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param Another vector.\n        ///\n        /// @return This vector after the given vector has been\n        /// subtracted from it.\n        //-----------------------------------------------------\n        GenericVector3<TType>& operator-=(const GenericVector3<TType>& in_b);\n        //-----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param Another vector.\n        ///\n        /// @return This vector after it has been multiplied\n        /// by the given vector.\n        //-----------------------------------------------------\n        GenericVector3<TType>& operator*=(const GenericVector3<TType>& in_b);\n        //-----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param Another vector.\n        ///\n        /// @return This vector after it has been divided\n        /// by the given vector.\n        //-----------------------------------------------------\n        GenericVector3<TType>& operator/=(const GenericVector3<TType>& in_b);\n        //-----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param A matrix.\n        ///\n        /// @return This vector after it has been multiplied\n        /// by the given matrix.\n        //-----------------------------------------------------\n        GenericVector3<TType>& operator*=(const GenericMatrix3<TType>& in_b);\n        //-----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param A matrix.\n        ///\n        /// @return This vector after it has been multiplied\n        /// by the given matrix.\n        //-----------------------------------------------------\n        GenericVector3<TType>& operator*=(const GenericMatrix4<TType>& in_b);\n        //-----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param A scalar\n        ///\n        /// @return This vector after it has been multiplied\n        /// by the given scalar.\n        //-----------------------------------------------------\n        GenericVector3<TType>& operator*=(TType in_b);\n        //-----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param A scalar.\n        ///\n        /// @return This vector after it has been divided\n        /// by the given scalar.\n        //-----------------------------------------------------\n        GenericVector3<TType>& operator/=(TType in_b);\n        \n        TType x;\n        TType y;\n        TType z;\n    };\n    \n    //-----------------------------------------------------\n    /// @author Ian Copland\n    ///\n    /// @param The vector A.\n    /// @param The vector B.\n    ///\n    /// @return The result of A + B.\n    //-----------------------------------------------------\n    template <typename TType> GenericVector3<TType> operator+(GenericVector3<TType> in_a, const GenericVector3<TType>& in_b);\n    //-----------------------------------------------------\n    /// @author Ian Copland\n    ///\n    /// @param The vector A.\n    /// @param The vector B.\n    ///\n    /// @return The result of A - B.\n    //-----------------------------------------------------\n    template <typename TType> GenericVector3<TType> operator-(GenericVector3<TType> in_a, const GenericVector3<TType>& in_b);\n    //-----------------------------------------------------\n    /// @author Ian Copland\n    ///\n    /// @param The vector A.\n    /// @param The vector B.\n    ///\n    /// @return The result of A * B.\n    //-----------------------------------------------------\n    template <typename TType> GenericVector3<TType> operator*(GenericVector3<TType> in_a, const GenericVector3<TType>& in_b);\n    //-----------------------------------------------------\n    /// @author Ian Copland\n    ///\n    /// @param The vector A.\n    /// @param The vector B.\n    ///\n    /// @return The result of A / B.\n    //-----------------------------------------------------\n    template <typename TType> GenericVector3<TType> operator/(GenericVector3<TType> in_a, const GenericVector3<TType>& in_b);\n    //-----------------------------------------------------\n    /// @author Ian Copland\n    ///\n    /// @param The vector A.\n    /// @param The matrix B.\n    ///\n    /// @return The result of A * B.\n    //-----------------------------------------------------\n    template <typename TType> GenericVector3<TType> operator*(const GenericVector3<TType>& in_a, const GenericMatrix3<TType>& in_b);\n    //-----------------------------------------------------\n    /// @author Ian Copland\n    ///\n    /// @param The vector A.\n    /// @param The matrix B.\n    ///\n    /// @return The result of A * B.\n    //-----------------------------------------------------\n    template <typename TType> GenericVector3<TType> operator*(const GenericVector3<TType>& in_a, const GenericMatrix4<TType>& in_b);\n    //-----------------------------------------------------\n    /// @author Ian Copland\n    ///\n    /// @param The vector A.\n    /// @param The scalar B.\n    ///\n    /// @return The result of A * B.\n    //-----------------------------------------------------\n    template <typename TType> GenericVector3<TType> operator*(GenericVector3<TType> in_a, TType in_b);\n    //-----------------------------------------------------\n    /// @author Ian Copland\n    ///\n    /// @param The scalar A.\n    /// @param The vector B.\n    ///\n    /// @return The result of A * B.\n    //-----------------------------------------------------\n    template <typename TType> GenericVector3<TType> operator*(TType in_a, GenericVector3<TType> in_b);\n    //-----------------------------------------------------\n    /// @author Ian Copland\n    ///\n    /// @param The vector A.\n    /// @param The scalar B.\n    ///\n    /// @return The result of A / B.\n    //-----------------------------------------------------\n    template <typename TType> GenericVector3<TType> operator/(GenericVector3<TType> in_a, TType in_b);\n    //-----------------------------------------------------\n    /// @author Ian Copland\n    ///\n    /// @param The vector A.\n    /// @param The vector B.\n    ///\n    /// @return Whether or not the two vectors are equal.\n    //-----------------------------------------------------\n    template <typename TType> bool operator==(const GenericVector3<TType>& in_a, const GenericVector3<TType>& in_b);\n    //-----------------------------------------------------\n    /// @author Ian Copland\n    ///\n    /// @param The vector A.\n    /// @param The vector B.\n    ///\n    /// @return Whether or not the two vectors are in-equal.\n    //-----------------------------------------------------\n    template <typename TType> bool operator!=(const GenericVector3<TType>& in_a, const GenericVector3<TType>& in_b);\n    //-----------------------------------------------------\n    /// @author Ian Copland\n    ///\n    /// @param in_a - A vector.\n    ///\n    /// @return A negated copy of the given vector.\n    //-----------------------------------------------------\n    template <typename TType> GenericVector3<TType> operator-(GenericVector3<TType> in_a);\n}\n\n//----------------------------------------------------\n// These are included here to avoid circular inclusion\n// issues. At this stage the class has been defined\n// which is enough for the classes included to use it.\n//----------------------------------------------------\n#include <ChilliSource/Core/Math/Matrix3.h>\n#include <ChilliSource/Core/Math/Matrix4.h>\n#include <ChilliSource/Core/Math/Quaternion.h>\n#include <ChilliSource/Core/Math/Vector2.h>\n\n#include <algorithm>\n#include <assert.h>\n#include <cmath>\n\nnamespace ChilliSource\n{\n    template <typename TType> const GenericVector3<TType> GenericVector3<TType>::k_zero(0, 0, 0);\n    template <typename TType> const GenericVector3<TType> GenericVector3<TType>::k_one(1, 1, 1);\n    template <typename TType> const GenericVector3<TType> GenericVector3<TType>::k_unitPositiveX(1, 0, 0);\n    template <typename TType> const GenericVector3<TType> GenericVector3<TType>::k_unitNegativeX(-1, 0, 0);\n    template <typename TType> const GenericVector3<TType> GenericVector3<TType>::k_unitPositiveY(0, 1, 0);\n    template <typename TType> const GenericVector3<TType> GenericVector3<TType>::k_unitNegativeY(0, -1, 0);\n    template <typename TType> const GenericVector3<TType> GenericVector3<TType>::k_unitPositiveZ(0, 0, 1);\n    template <typename TType> const GenericVector3<TType> GenericVector3<TType>::k_unitNegativeZ(0, 0, -1);\n    \n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> GenericVector3<TType> GenericVector3<TType>::Normalise(GenericVector3<TType> in_a)\n    {\n        in_a.Normalise();\n        return in_a;\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> GenericVector3<TType> GenericVector3<TType>::Inverse(GenericVector3<TType> in_a)\n    {\n        in_a.Inverse();\n        return in_a;\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> GenericVector3<TType> GenericVector3<TType>::Abs(GenericVector3<TType> in_a)\n    {\n        in_a.Abs();\n        return in_a;\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> GenericVector3<TType> GenericVector3<TType>::Min(GenericVector3<TType> in_a, const GenericVector3<TType>& in_b)\n    {\n        in_a.Min(in_b);\n        return in_a;\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> GenericVector3<TType> GenericVector3<TType>::Max(GenericVector3<TType> in_a, const GenericVector3<TType>& in_b)\n    {\n        in_a.Max(in_b);\n        return in_a;\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> GenericVector3<TType> GenericVector3<TType>::Clamp(GenericVector3<TType> in_value, const GenericVector3<TType>& in_min, const GenericVector3<TType>& in_max)\n    {\n        in_value.Clamp(in_min, in_max);\n        return in_value;\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> GenericVector3<TType> GenericVector3<TType>::Lerp(GenericVector3<TType> in_a, const GenericVector3<TType>& in_b, f32 in_t)\n    {\n        in_a.Lerp(in_b, in_t);\n        return in_a;\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> TType GenericVector3<TType>::DotProduct(const GenericVector3<TType>& in_a, const GenericVector3<TType>& in_b)\n    {\n        return (in_a.x * in_b.x + in_a.y * in_b.y + in_a.z * in_b.z);\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> GenericVector3<TType> GenericVector3<TType>::CrossProduct(const GenericVector3<TType>& in_a, const GenericVector3<TType>& in_b)\n    {\n        GenericVector3<TType> c;\n        c.x = in_a.y * in_b.z - in_a.z * in_b.y;\n        c.y = -in_a.x * in_b.z + in_a.z * in_b.x;\n        c.z = in_a.x * in_b.y - in_a.y * in_b.x;\n        return c;\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> TType GenericVector3<TType>::Angle(const GenericVector3<TType>& in_a, const GenericVector3<TType>& in_b)\n    {\n        TType dot = DotProduct(in_a, in_b);\n        TType totalMagnitude = in_a.Length() * in_b.Length();\n        \n        if (totalMagnitude == 0)\n        {\n            totalMagnitude = 1;\n        }\n        \n        //This just caps the quotient because in practical use, sometimes dot and totalMagnitude yield a very small number above 1.0,\n        //e.g. 1.00003 when angles tend towards 0 degrees\n        f32 ratio = dot / totalMagnitude;\n        if (ratio > 1)\n        {\n            ratio = 1;\n        }\n        else if (ratio < -1)\n        {\n            ratio = -1;\n        }\n        \n        return std::acos(ratio);\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> GenericVector3<TType> GenericVector3<TType>::Rotate(GenericVector3<TType> in_a, const GenericQuaternion<TType>& in_b)\n    {\n        in_a.Rotate(in_b);\n        return in_a;\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> GenericVector3<TType> GenericVector3<TType>::Transform3x4(const GenericVector3<TType>& in_a, const GenericMatrix4<TType>& in_transform)\n    {\n        GenericVector3<TType> b;\n        b.x = in_a.x * in_transform.m[0] + in_a.y * in_transform.m[4] + in_a.z * in_transform.m[8] + in_transform.m[12];\n        b.y = in_a.x * in_transform.m[1] + in_a.y * in_transform.m[5] + in_a.z * in_transform.m[9] + in_transform.m[13];\n        b.z = in_a.x * in_transform.m[2] + in_a.y * in_transform.m[6] + in_a.z * in_transform.m[10] + in_transform.m[14];\n        return b;\n    }\n    //-----------------------------------------------------\n    template <typename TType> TType GenericVector3<TType>::Distance(const GenericVector3<TType>& a, const GenericVector3<TType>& b)\n    {\n        return (b - a).Length();\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> GenericVector3<TType>::GenericVector3()\n    : x(0), y(0), z(0)\n    {\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> GenericVector3<TType>::GenericVector3(TType in_x, TType in_y, TType in_z)\n    : x(in_x), y(in_y), z(in_z)\n    {\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> GenericVector3<TType>::GenericVector3(const GenericVector2<TType>& in_xy, TType in_z)\n    : x(in_xy.x), y(in_xy.y), z(in_z)\n    {\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> GenericVector2<TType> GenericVector3<TType>::XY() const\n    {\n        return GenericVector2<TType>(x, y);\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> TType GenericVector3<TType>::LengthSquared() const\n    {\n        return (x * x + y * y + z * z);\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> TType GenericVector3<TType>::Length() const\n    {\n        return (std::sqrt(x * x + y * y + z * z));\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> void GenericVector3<TType>::Normalise()\n    {\n        TType length = Length();\n        if (length != 0)\n        {\n            TType invLength = 1 / length;\n            x *= invLength;\n            y *= invLength;\n            z *= invLength;\n        }\n    }\n    \n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> void GenericVector3<TType>::Inverse()\n    {\n        if (x != 0)\n        {\n            x = 1 / x;\n        }\n        \n        if (y != 0)\n        {\n            y = 1 / y;\n        }\n        \n        if (z != 0)\n        {\n            z = 1 / z;\n        }\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> void GenericVector3<TType>::Abs()\n    {\n        x = std::abs(x);\n        y = std::abs(y);\n        z = std::abs(z);\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> void GenericVector3<TType>::Min(const GenericVector3<TType>& in_b)\n    {\n        x = std::min(x, in_b.x);\n        y = std::min(y, in_b.y);\n        z = std::min(z, in_b.z);\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> void GenericVector3<TType>::Max(const GenericVector3<TType>& in_b)\n    {\n        x = std::max(x, in_b.x);\n        y = std::max(y, in_b.y);\n        z = std::max(z, in_b.z);\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> void GenericVector3<TType>::Clamp(const GenericVector3<TType>& in_min, const GenericVector3<TType>& in_max)\n    {\n        assert(in_min.x <= in_max.x && in_min.y <= in_max.y && in_min.z <= in_max.z);\n        \n        x = std::min(std::max(x, in_min.x), in_max.x);\n        y = std::min(std::max(y, in_min.y), in_max.y);\n        z = std::min(std::max(z, in_min.z), in_max.z);\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> void GenericVector3<TType>::Lerp(const GenericVector3<TType>& in_b, f32 in_t)\n    {\n        f32 t = std::min(std::max(in_t, 0.0f), 1.0f);\n        *this = (*this + t * (in_b - *this));\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> void GenericVector3<TType>::CrossProduct(const GenericVector3<TType>& in_b)\n    {\n        GenericVector3<TType> c = *this;\n        x = c.y * in_b.z - c.z * in_b.y;\n        y = -c.x * in_b.z + c.z * in_b.x;\n        z = c.x * in_b.y - c.y * in_b.x;\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> void GenericVector3<TType>::Rotate(const GenericQuaternion<TType>& in_b)\n    {\n        GenericVector3<TType> xyzA(in_b.x, in_b.y, in_b.z);\n        GenericVector3<TType> t = ((TType)2) * CrossProduct(xyzA, *this);\n        *this = *this + in_b.w * t + CrossProduct(xyzA, t);\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> void GenericVector3<TType>::Transform3x4(const GenericMatrix4<TType>& in_transform)\n    {\n        GenericVector3<TType> b = *this;\n        x = b.x * in_transform.m[0] + b.y * in_transform.m[4] + b.z * in_transform.m[8] + in_transform.m[12];\n        y = b.x * in_transform.m[1] + b.y * in_transform.m[5] + b.z * in_transform.m[9] + in_transform.m[13];\n        z = b.x * in_transform.m[2] + b.y * in_transform.m[6] + b.z * in_transform.m[10] + in_transform.m[14];\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> GenericVector3<TType>& GenericVector3<TType>::operator+=(const GenericVector3<TType>& in_b)\n    {\n        x += in_b.x;\n        y += in_b.y;\n        z += in_b.z;\n        return *this;\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> GenericVector3<TType>& GenericVector3<TType>::operator-=(const GenericVector3<TType>& in_b)\n    {\n        x -= in_b.x;\n        y -= in_b.y;\n        z -= in_b.z;\n        return *this;\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> GenericVector3<TType>& GenericVector3<TType>::operator*=(const GenericVector3<TType>& in_b)\n    {\n        x *= in_b.x;\n        y *= in_b.y;\n        z *= in_b.z;\n        return *this;\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> GenericVector3<TType>& GenericVector3<TType>::operator/=(const GenericVector3<TType>& in_b)\n    {\n        x /= in_b.x;\n        y /= in_b.y;\n        z /= in_b.z;\n        return *this;\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> GenericVector3<TType>& GenericVector3<TType>::operator*=(const GenericMatrix3<TType>& in_b)\n    {\n        GenericVector3<TType> c = *this;\n        x = c.x * in_b.m[0] + c.y * in_b.m[3] + c.z * in_b.m[6];\n        y = c.x * in_b.m[1] + c.y * in_b.m[4] + c.z * in_b.m[7];\n        z = c.x * in_b.m[2] + c.y * in_b.m[5] + c.z * in_b.m[8];\n        return *this;\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> GenericVector3<TType>& GenericVector3<TType>::operator*=(const GenericMatrix4<TType>& in_b)\n    {\n        GenericVector3<TType> c = *this;\n        x = c.x * in_b.m[0] + c.y * in_b.m[4] + c.z * in_b.m[8] + in_b.m[12];\n        y = c.x * in_b.m[1] + c.y * in_b.m[5] + c.z * in_b.m[9] + in_b.m[13];\n        z = c.x * in_b.m[2] + c.y * in_b.m[6] + c.z * in_b.m[10] + in_b.m[14];\n        TType oneOverW = 1 / (c.x * in_b.m[3] + c.y * in_b.m[7] + c.z * in_b.m[11] + in_b.m[15]);\n        *this *= oneOverW;\n        return *this;\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> GenericVector3<TType>& GenericVector3<TType>::operator*=(TType in_b)\n    {\n        x *= in_b;\n        y *= in_b;\n        z *= in_b;\n        return *this;\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> GenericVector3<TType>& GenericVector3<TType>::operator/=(TType in_b)\n    {\n        x /= in_b;\n        y /= in_b;\n        z /= in_b;\n        return *this;\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> GenericVector3<TType> operator+(GenericVector3<TType> in_a, const GenericVector3<TType>& in_b)\n    {\n        return (in_a += in_b);\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> GenericVector3<TType> operator-(GenericVector3<TType> in_a, const GenericVector3<TType>& in_b)\n    {\n        return (in_a -= in_b);\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> GenericVector3<TType> operator*(GenericVector3<TType> in_a, const GenericVector3<TType>& in_b)\n    {\n        return (in_a *= in_b);\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> GenericVector3<TType> operator/(GenericVector3<TType> in_a, const GenericVector3<TType>& in_b)\n    {\n        return (in_a /= in_b);\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> GenericVector3<TType> operator*(const GenericVector3<TType>& in_a, const GenericMatrix3<TType>& in_b)\n    {\n        GenericVector3<TType> c;\n        c.x = in_a.x * in_b.m[0] + in_a.y * in_b.m[3] + in_a.z * in_b.m[6];\n        c.y = in_a.x * in_b.m[1] + in_a.y * in_b.m[4] + in_a.z * in_b.m[7];\n        c.z = in_a.x * in_b.m[2] + in_a.y * in_b.m[5] + in_a.z * in_b.m[8];\n        return c;\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> GenericVector3<TType> operator*(const GenericVector3<TType>& in_a, const GenericMatrix4<TType>& in_b)\n    {\n        GenericVector3<TType> c;\n        c.x = in_a.x * in_b.m[0] + in_a.y * in_b.m[4] + in_a.z * in_b.m[8] + in_b.m[12];\n        c.y = in_a.x * in_b.m[1] + in_a.y * in_b.m[5] + in_a.z * in_b.m[9] + in_b.m[13];\n        c.z = in_a.x * in_b.m[2] + in_a.y * in_b.m[6] + in_a.z * in_b.m[10] + in_b.m[14];\n        TType oneOverW = 1 / (in_a.x * in_b.m[3] + in_a.y * in_b.m[7] + in_a.z * in_b.m[11] + in_b.m[15]);\n        c *= oneOverW;\n        return c;\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> GenericVector3<TType> operator*(GenericVector3<TType> in_a, TType in_b)\n    {\n        return (in_a *= in_b);\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> GenericVector3<TType> operator*(TType in_a, GenericVector3<TType> in_b)\n    {\n        return (in_b *= in_a);\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> GenericVector3<TType> operator/(GenericVector3<TType> in_a, TType in_b)\n    {\n        return (in_a /= in_b);\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> bool operator==(const GenericVector3<TType>& in_a, const GenericVector3<TType>& in_b)\n    {\n        return (in_a.x == in_b.x && in_a.y == in_b.y && in_a.z == in_b.z);\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> bool operator!=(const GenericVector3<TType>& in_a, const GenericVector3<TType>& in_b)\n    {\n        return !(in_a == in_b);\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> GenericVector3<TType> operator-(GenericVector3<TType> in_a)\n    {\n        in_a.x = -in_a.x;\n        in_a.y = -in_a.y;\n        in_a.z = -in_a.z;\n        return in_a;\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Math/Vector4.h",
    "content": "//\n//  Vector4.h\n//  ChilliSource\n//  Created by Ian Copland on 26/04/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_MATH_VECTOR4_H_\n#define _CHILLISOURCE_CORE_MATH_VECTOR4_H_\n\n#include <ChilliSource/ChilliSource.h>\n\nnamespace ChilliSource\n{\n    //-------------------------------------------------------------------\n    /// A generic four dimensional mathematical vector. Typically\n    /// the type specific typedefs of this class would be used\n    /// over direct use. For example:\n    ///\t\tVector4 -> GenericVector4<f32>\n    ///\t\tFloat4 -> GenericVector4<f32>\n    ///\t\tInteger4 -> GenericVector4<s32>\n    ///\n    /// @author Ian Copland\n    //-------------------------------------------------------------------\n    template <typename TType> class GenericVector4 final\n    {\n    public:\n        //-----------------------------------------------------\n        /// Constants\n        //-----------------------------------------------------\n        static const GenericVector4<TType> k_zero;\n        static const GenericVector4<TType> k_one;\n        static const GenericVector4<TType> k_unitPositiveX;\n        static const GenericVector4<TType> k_unitNegativeX;\n        static const GenericVector4<TType> k_unitPositiveY;\n        static const GenericVector4<TType> k_unitNegativeY;\n        static const GenericVector4<TType> k_unitPositiveZ;\n        static const GenericVector4<TType> k_unitNegativeZ;\n        static const GenericVector4<TType> k_unitPositiveW;\n        static const GenericVector4<TType> k_unitNegativeW;\n        //-----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param A vector.\n        ///\n        /// @return a normalised copy of the vector.\n        //-----------------------------------------------------\n        static GenericVector4<TType> Normalise(GenericVector4<TType> in_a);\n        //-----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param A vector.\n        ///\n        /// @return An inversed copy of the vector.\n        //-----------------------------------------------------\n        static GenericVector4<TType> Inverse(GenericVector4<TType> in_a);\n        //-----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param A vector.\n        ///\n        /// @return an absolute copy of the vector.\n        //-----------------------------------------------------\n        static GenericVector4<TType> Abs(GenericVector4<TType> in_a);\n        //-----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param a vector.\n        /// @param another vector.\n        ///\n        /// @return A vector containing the minimum value for\n        /// each component in each vector.\n        //-----------------------------------------------------\n        static GenericVector4<TType> Min(GenericVector4<TType> in_a, const GenericVector4<TType>& in_b);\n        //-----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param a vector.\n        /// @param another vector.\n        ///\n        /// @return A vector containing the maximum value for\n        /// each component in each vector.\n        //-----------------------------------------------------\n        static GenericVector4<TType> Max(GenericVector4<TType> in_a, const GenericVector4<TType>& in_b);\n        //-----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param A vector.\n        /// @param The minimum vector.\n        /// @param The maximum vector.\n        ///\n        /// @return A vector in which each component is clamped\n        /// between the equivalent in the min and max vectors.\n        //-----------------------------------------------------\n        static GenericVector4<TType> Clamp(GenericVector4<TType> in_value, const GenericVector4<TType>& in_min, const GenericVector4<TType>& in_max);\n        //-----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param a vector.\n        /// @param another vector.\n        ///\n        /// @return The interpolated vector.\n        //-----------------------------------------------------\n        static GenericVector4<TType> Lerp(GenericVector4<TType> in_a, const GenericVector4<TType>& in_b, f32 in_t);\n        //-----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param a vector.\n        /// @param another vector.\n        ///\n        /// @return the dot product of these two vectors.\n        //-----------------------------------------------------\n        static TType DotProduct(const GenericVector4<TType>& in_a, const GenericVector4<TType>& in_b);\n        \n        ///\n        /// @param a\n        ///     First position vector\n        /// @param b\n        ///     Second position vector\n        ///\n        /// @return Distance between the 2 given positions (magnitude of the vector between them)\n        ///\n        static TType Distance(const GenericVector4<TType>& a, const GenericVector4<TType>& b);\n        \n        //-----------------------------------------------------\n        /// Constructor\n        ///\n        /// @author Ian Copland\n        //-----------------------------------------------------\n        GenericVector4();\n        //-----------------------------------------------------\n        /// Constructor\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param the x component.\n        /// @param the y component.\n        /// @param the z component.\n        /// @param the w component.\n        //-----------------------------------------------------\n        explicit GenericVector4(TType in_x, TType in_y, TType in_z, TType in_w);\n        //-----------------------------------------------------\n        /// Constructor\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param A vector2.\n        /// @param the z component.\n        /// @param the w component.\n        //-----------------------------------------------------\n        explicit GenericVector4(const GenericVector2<TType>& in_xy, TType in_z, TType in_w);\n        //-----------------------------------------------------\n        /// Constructor\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param A vector2 representing the x and y component\n        /// @param A vector2 representing the z and w component\n        //-----------------------------------------------------\n        explicit GenericVector4(const GenericVector2<TType>& in_xy, const GenericVector2<TType>& in_zw);\n        //-----------------------------------------------------\n        /// Constructor\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param A vector3 representing the x, y and z components\n        /// @param The w component.\n        //-----------------------------------------------------\n        explicit GenericVector4(const GenericVector3<TType>& in_xyz, TType in_w);\n        //-----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return A copy of the XY components of this vector\n        /// as a Vector2.\n        //-----------------------------------------------------\n        GenericVector2<TType> XY() const;\n        //-----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return A copy of the ZW components of this vector\n        /// as a Vector2.\n        //-----------------------------------------------------\n        GenericVector2<TType> ZW() const;\n        //-----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return A copy of the XYZ components of this vector\n        /// as a Vector3.\n        //-----------------------------------------------------\n        GenericVector3<TType> XYZ() const;\n        //-----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return the length of the vector\n        //-----------------------------------------------------\n        TType Length() const;\n        //-----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return the length of the vector squared\n        //-----------------------------------------------------\n        TType LengthSquared() const;\n        //-----------------------------------------------------\n        /// Normalises the contents of this vector.\n        ///\n        /// @author Ian Copland\n        //-----------------------------------------------------\n        void Normalise();\n        //-----------------------------------------------------\n        /// Sets this contents of this vector to its inverse.\n        ///\n        /// @author Ian Copland\n        //-----------------------------------------------------\n        void Inverse();\n        //-----------------------------------------------------\n        /// Sets this vector to it's absolute value.\n        ///\n        /// @author Ian Copland\n        //-----------------------------------------------------\n        void Abs();\n        //-----------------------------------------------------\n        /// Sets each component in this vector to which ever is\n        /// smaller, itself or the equivelent in the given\n        /// vector.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The other vector.\n        //-----------------------------------------------------\n        void Min(const GenericVector4<TType>& in_b);\n        //-----------------------------------------------------\n        /// Sets each component in this vector to which ever is\n        /// greater, itself or the equivelent in the given\n        /// vector.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The other vector.\n        //-----------------------------------------------------\n        void Max(const GenericVector4<TType>& in_b);\n        //-----------------------------------------------------\n        /// Clamps each component in this vector between the\n        /// values described by the min and max vectors.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The minimum vector.\n        /// @param The maximum vector.\n        //-----------------------------------------------------\n        void Clamp(const GenericVector4<TType>& in_min, const GenericVector4<TType>& in_max);\n        //-----------------------------------------------------\n        /// Sets the contents of the vector to the result of\n        /// interpolating between this and the given vector\n        /// with the given interpolation factor.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The other vector.\n        /// @param The interpolation factor.\n        //-----------------------------------------------------\n        void Lerp(const GenericVector4<TType>& in_b, f32 in_t);\n        //-----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param Another vector.\n        ///\n        /// @return This vector after the given vector has been\n        /// added to it.\n        //-----------------------------------------------------\n        GenericVector4<TType>& operator+=(const GenericVector4<TType>& in_b);\n        //-----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param Another vector.\n        ///\n        /// @return This vector after the given vector has been\n        /// subtracted from it.\n        //-----------------------------------------------------\n        GenericVector4<TType>& operator-=(const GenericVector4<TType>& in_b);\n        //-----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param Another vector.\n        ///\n        /// @return This vector after being multiplied by the\n        /// given vector.\n        //-----------------------------------------------------\n        GenericVector4<TType>& operator*=(const GenericVector4<TType>& in_b);\n        //-----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param Another vector.\n        ///\n        /// @return This vector after being divided by the given\n        /// vector.\n        //-----------------------------------------------------\n        GenericVector4<TType>& operator/=(const GenericVector4<TType>& in_b);\n        //-----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param A matrix\n        ///\n        /// @return This vector after being multipled by the given\n        /// matrix.\n        //-----------------------------------------------------\n        GenericVector4<TType>& operator*=(const GenericMatrix4<TType>& in_b);\n        //-----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param A scalar.\n        ///\n        /// @return This vector after being multiplied by the\n        /// given scalar.\n        //-----------------------------------------------------\n        GenericVector4<TType>& operator*=(TType in_b);\n        //-----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param A scalar.\n        ///\n        /// @return This vector after being divided by the\n        /// given scalar.\n        //-----------------------------------------------------\n        GenericVector4<TType>& operator/=(TType in_b);\n        \n        TType x;\n        TType y;\n        TType z;\n        TType w;\n    };\n    //-----------------------------------------------------\n    /// @author Ian Copland\n    ///\n    /// @param The vector A.\n    /// @param The vector B.\n    ///\n    /// @return The result of A + B.\n    //-----------------------------------------------------\n    template <typename TType> GenericVector4<TType> operator+(GenericVector4<TType> in_a, const GenericVector4<TType>& in_b);\n    //-----------------------------------------------------\n    /// @author Ian Copland\n    ///\n    /// @param The vector A.\n    /// @param The vector B.\n    ///\n    /// @return The result of A - B.\n    //-----------------------------------------------------\n    template <typename TType> GenericVector4<TType> operator-(GenericVector4<TType> in_a, const GenericVector4<TType>& in_b);\n    //-----------------------------------------------------\n    /// @author Ian Copland\n    ///\n    /// @param The vector A.\n    /// @param The vector B.\n    ///\n    /// @return The result of A * B.\n    //-----------------------------------------------------\n    template <typename TType> GenericVector4<TType> operator*(GenericVector4<TType> in_a, const GenericVector4<TType>& in_b);\n    //-----------------------------------------------------\n    /// @author Ian Copland\n    ///\n    /// @param The vector A.\n    /// @param The vector B.\n    ///\n    /// @return The result of A / B.\n    //-----------------------------------------------------\n    template <typename TType> GenericVector4<TType> operator/(GenericVector4<TType> in_a, const GenericVector4<TType>& in_b);\n    //-----------------------------------------------------\n    /// @author Ian Copland\n    ///\n    /// @param The vector A.\n    /// @param The matrix B.\n    ///\n    /// @return The result of A * B.\n    //-----------------------------------------------------\n    template <typename TType> GenericVector4<TType> operator*(const GenericVector4<TType>& in_a, const GenericMatrix4<TType>& in_b);\n    //-----------------------------------------------------\n    /// @author Ian Copland\n    ///\n    /// @param The vector A.\n    /// @param The scalar B.\n    ///\n    /// @return The result of A * B.\n    //-----------------------------------------------------\n    template <typename TType> GenericVector4<TType> operator*(GenericVector4<TType> in_a, TType in_b);\n    //-----------------------------------------------------\n    /// @author Ian Copland\n    ///\n    /// @param The scalar A.\n    /// @param The vector B.\n    ///\n    /// @return The result of A * B.\n    //-----------------------------------------------------\n    template <typename TType> GenericVector4<TType> operator*(TType in_a, GenericVector4<TType> in_b);\n    //-----------------------------------------------------\n    /// @author Ian Copland\n    ///\n    /// @param The vector A.\n    /// @param The scalar B.\n    ///\n    /// @return The result of A / B.\n    //-----------------------------------------------------\n    template <typename TType> GenericVector4<TType> operator/(GenericVector4<TType> in_a, TType in_b);\n    //-----------------------------------------------------\n    /// @author Ian Copland\n    ///\n    /// @param The vector A.\n    /// @param The vector B.\n    ///\n    /// @return Whether or not they are equal.\n    //-----------------------------------------------------\n    template <typename TType> bool operator==(const GenericVector4<TType>& in_a, const GenericVector4<TType>& in_b);\n    //-----------------------------------------------------\n    /// @author Ian Copland\n    ///\n    /// @param The vector A.\n    /// @param The vector B.\n    ///\n    /// @return Whether or not they are in-equal.\n    //-----------------------------------------------------\n    template <typename TType> bool operator!=(const GenericVector4<TType>& in_a, const GenericVector4<TType>& in_b);\n    //-----------------------------------------------------\n    /// @author Ian Copland\n    ///\n    /// @param in_a - A vector.\n    ///\n    /// @return A negated copy of the given vector.\n    //-----------------------------------------------------\n    template <typename TType> GenericVector4<TType> operator-(GenericVector4<TType> in_a);\n}\n\n//----------------------------------------------------\n// These are included here to avoid circular inclusion\n// issues. At this stage the class has been defined\n// which is enough for the classes included to use it.\n//----------------------------------------------------\n#include <ChilliSource/Core/Math/Matrix4.h>\n#include <ChilliSource/Core/Math/Vector2.h>\n#include <ChilliSource/Core/Math/Vector3.h>\n\n#include <algorithm>\n#include <assert.h>\n#include <cmath>\n\nnamespace ChilliSource\n{\n    template <typename TType> const GenericVector4<TType> GenericVector4<TType>::k_zero(0, 0, 0, 0);\n    template <typename TType> const GenericVector4<TType> GenericVector4<TType>::k_one(1, 1, 1, 1);\n    template <typename TType> const GenericVector4<TType> GenericVector4<TType>::k_unitPositiveX(1, 0, 0, 0);\n    template <typename TType> const GenericVector4<TType> GenericVector4<TType>::k_unitNegativeX(-1, 0, 0, 0);\n    template <typename TType> const GenericVector4<TType> GenericVector4<TType>::k_unitPositiveY(0, 1, 0, 0);\n    template <typename TType> const GenericVector4<TType> GenericVector4<TType>::k_unitNegativeY(0, -1, 0, 0);\n    template <typename TType> const GenericVector4<TType> GenericVector4<TType>::k_unitPositiveZ(0, 0, 1, 0);\n    template <typename TType> const GenericVector4<TType> GenericVector4<TType>::k_unitNegativeZ(0, 0, -1, 0);\n    template <typename TType> const GenericVector4<TType> GenericVector4<TType>::k_unitPositiveW(0, 0, 0, 1);\n    template <typename TType> const GenericVector4<TType> GenericVector4<TType>::k_unitNegativeW(0, 0, 0, -1);\n    \n    \n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> GenericVector4<TType> GenericVector4<TType>::Normalise(GenericVector4<TType> in_a)\n    {\n        in_a.Normalise();\n        return in_a;\n    }\n    \n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> GenericVector4<TType> GenericVector4<TType>::Inverse(GenericVector4<TType> in_a)\n    {\n        in_a.Inverse();\n        return in_a;\n    }\n    \n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> GenericVector4<TType> GenericVector4<TType>::Abs(GenericVector4<TType> in_a)\n    {\n        in_a.Abs();\n        return in_a;\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> GenericVector4<TType> GenericVector4<TType>::Min(GenericVector4<TType> in_a, const GenericVector4<TType>& in_b)\n    {\n        in_a.Min(in_b);\n        return in_a;\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> GenericVector4<TType> GenericVector4<TType>::Max(GenericVector4<TType> in_a, const GenericVector4<TType>& in_b)\n    {\n        in_a.Max(in_b);\n        return in_a;\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> GenericVector4<TType> GenericVector4<TType>::Clamp(GenericVector4<TType> in_value, const GenericVector4<TType>& in_min, const GenericVector4<TType>& in_max)\n    {\n        in_value.Clamp(in_min, in_max);\n        return in_value;\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> GenericVector4<TType> GenericVector4<TType>::Lerp(GenericVector4<TType> in_a, const GenericVector4<TType>& in_b, f32 in_t)\n    {\n        in_a.Lerp(in_b, in_t);\n        return in_a;\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> TType GenericVector4<TType>::DotProduct(const GenericVector4<TType>& in_a, const GenericVector4<TType>& in_b)\n    {\n        return (in_a.x * in_b.x + in_a.y * in_b.y + in_a.z * in_b.z + in_a.w * in_b.w);\n    }\n    //-----------------------------------------------------\n    template <typename TType> TType GenericVector4<TType>::Distance(const GenericVector4<TType>& a, const GenericVector4<TType>& b)\n    {\n        return (b - a).Length();\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> GenericVector4<TType>::GenericVector4()\n    : x(0), y(0), z(0), w(0)\n    {\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> GenericVector4<TType>::GenericVector4(TType in_x, TType in_y, TType in_z, TType in_w)\n    : x(in_x), y(in_y), z(in_z), w(in_w)\n    {\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> GenericVector4<TType>::GenericVector4(const GenericVector2<TType>& in_xy, TType in_z, TType in_w)\n    : x(in_xy.x), y(in_xy.y), z(in_z), w(in_w)\n    {\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> GenericVector4<TType>::GenericVector4(const GenericVector2<TType>& in_xy, const GenericVector2<TType>& in_zw)\n    : x(in_xy.x), y(in_xy.y), z(in_zw.x), w(in_zw.y)\n    {\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> GenericVector4<TType>::GenericVector4(const GenericVector3<TType>& in_xyz, TType in_w)\n    : x(in_xyz.x), y(in_xyz.y), z(in_xyz.z), w(in_w)\n    {\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> GenericVector2<TType> GenericVector4<TType>::XY() const\n    {\n        return GenericVector2<TType>(x, y);\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> GenericVector2<TType> GenericVector4<TType>::ZW() const\n    {\n        return GenericVector2<TType>(z, w);\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> GenericVector3<TType> GenericVector4<TType>::XYZ() const\n    {\n        return GenericVector3<TType>(x, y, z);\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> TType GenericVector4<TType>::LengthSquared() const\n    {\n        return (x * x + y * y + z * z + w * w);\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> TType GenericVector4<TType>::Length() const\n    {\n        return (std::sqrt(x * x + y * y + z * z + w * w));\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> void GenericVector4<TType>::Normalise()\n    {\n        TType length = Length();\n        if (length != 0)\n        {\n            TType invLength = 1 / length;\n            x *= invLength;\n            y *= invLength;\n            z *= invLength;\n            w *= invLength;\n        }\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> void GenericVector4<TType>::Inverse()\n    {\n        if (x != 0)\n        {\n            x = 1 / x;\n        }\n        \n        if (y != 0)\n        {\n            y = 1 / y;\n        }\n        \n        if (z != 0)\n        {\n            z = 1 / z;\n        }\n        \n        if (w != 0)\n        {\n            w = 1 / w;\n        }\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> void GenericVector4<TType>::Abs()\n    {\n        x = std::abs(x);\n        y = std::abs(y);\n        z = std::abs(z);\n        w = std::abs(w);\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> void GenericVector4<TType>::Min(const GenericVector4<TType>& in_b)\n    {\n        x = std::min(x, in_b.x);\n        y = std::min(y, in_b.y);\n        z = std::min(z, in_b.z);\n        w = std::min(w, in_b.w);\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> void GenericVector4<TType>::Max(const GenericVector4<TType>& in_b)\n    {\n        x = std::max(x, in_b.x);\n        y = std::max(y, in_b.y);\n        z = std::max(z, in_b.z);\n        w = std::max(w, in_b.w);\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> void GenericVector4<TType>::Clamp(const GenericVector4<TType>& in_min, const GenericVector4<TType>& in_max)\n    {\n        assert(in_min.x <= in_max.x && in_min.y <= in_max.y && in_min.z <= in_max.z && in_min.w <= in_max.w);\n        \n        x = std::min(std::max(x, in_min.x), in_max.x);\n        y = std::min(std::max(y, in_min.y), in_max.y);\n        z = std::min(std::max(z, in_min.z), in_max.z);\n        w = std::min(std::max(w, in_min.w), in_max.w);\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> void GenericVector4<TType>::Lerp(const GenericVector4<TType>& in_b, f32 in_t)\n    {\n        f32 t = std::min(std::max(in_t, 0.0f), 1.0f);\n        *this = (*this + t * (in_b - *this));\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> GenericVector4<TType>& GenericVector4<TType>::operator+=(const GenericVector4<TType>& in_b)\n    {\n        x += in_b.x;\n        y += in_b.y;\n        z += in_b.z;\n        w += in_b.w;\n        return *this;\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> GenericVector4<TType>& GenericVector4<TType>::operator-=(const GenericVector4<TType>& in_b)\n    {\n        x -= in_b.x;\n        y -= in_b.y;\n        z -= in_b.z;\n        w -= in_b.w;\n        return *this;\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> GenericVector4<TType>& GenericVector4<TType>::operator*=(const GenericVector4<TType>& in_b)\n    {\n        x *= in_b.x;\n        y *= in_b.y;\n        z *= in_b.z;\n        w *= in_b.w;\n        return *this;\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> GenericVector4<TType>& GenericVector4<TType>::operator/=(const GenericVector4<TType>& in_b)\n    {\n        x /= in_b.x;\n        y /= in_b.y;\n        z /= in_b.z;\n        w /= in_b.w;\n        return *this;\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> GenericVector4<TType>& GenericVector4<TType>::operator*=(const GenericMatrix4<TType>& in_b)\n    {\n        GenericVector4<TType> c = *this;\n        x = c.x * in_b.m[0] + c.y * in_b.m[4] + c.z * in_b.m[8] + c.w * in_b.m[12];\n        y = c.x * in_b.m[1] + c.y * in_b.m[5] + c.z * in_b.m[9] + c.w * in_b.m[13];\n        z = c.x * in_b.m[2] + c.y * in_b.m[6] + c.z * in_b.m[10] + c.w * in_b.m[14];\n        w = c.x * in_b.m[3] + c.y * in_b.m[7] + c.z * in_b.m[11] + c.w * in_b.m[15];\n        return *this;\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> GenericVector4<TType>& GenericVector4<TType>::operator*=(TType in_b)\n    {\n        x *= in_b;\n        y *= in_b;\n        z *= in_b;\n        w *= in_b;\n        return *this;\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> GenericVector4<TType>& GenericVector4<TType>::operator/=(TType in_b)\n    {\n        x /= in_b;\n        y /= in_b;\n        z /= in_b;\n        w /= in_b;\n        return *this;\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> GenericVector4<TType> operator+(GenericVector4<TType> in_a, const GenericVector4<TType>& in_b)\n    {\n        return (in_a += in_b);\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> GenericVector4<TType> operator-(GenericVector4<TType> in_a, const GenericVector4<TType>& in_b)\n    {\n        return (in_a -= in_b);\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> GenericVector4<TType> operator*(GenericVector4<TType> in_a, const GenericVector4<TType>& in_b)\n    {\n        return (in_a *= in_b);\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> GenericVector4<TType> operator/(GenericVector4<TType> in_a, const GenericVector4<TType>& in_b)\n    {\n        return (in_a /= in_b);\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    template <typename TType> GenericVector4<TType> operator*(const GenericVector4<TType>& in_a, const GenericMatrix4<TType>& in_b)\n    {\n        GenericVector4<TType> c;\n        c.x = in_a.x * in_b.m[0] + in_a.y * in_b.m[4] + in_a.z * in_b.m[8] + in_a.w * in_b.m[12];\n        c.y = in_a.x * in_b.m[1] + in_a.y * in_b.m[5] + in_a.z * in_b.m[9] + in_a.w * in_b.m[13];\n        c.z = in_a.x * in_b.m[2] + in_a.y * in_b.m[6] + in_a.z * in_b.m[10] + in_a.w * in_b.m[14];\n        c.w = in_a.x * in_b.m[3] + in_a.y * in_b.m[7] + in_a.z * in_b.m[11] + in_a.w * in_b.m[15];\n        return c;\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> GenericVector4<TType> operator*(GenericVector4<TType> in_a, TType in_b)\n    {\n        return (in_a *= in_b);\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> GenericVector4<TType> operator*(TType in_a, GenericVector4<TType> in_b)\n    {\n        return (in_b *= in_a);\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> GenericVector4<TType> operator/(GenericVector4<TType> in_a, TType in_b)\n    {\n        return (in_a /= in_b);\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> bool operator==(const GenericVector4<TType>& in_a, const GenericVector4<TType>& in_b)\n    {\n        return (in_a.x == in_b.x && in_a.y == in_b.y && in_a.z == in_b.z && in_a.w == in_b.w);\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> bool operator!=(const GenericVector4<TType>& in_a, const GenericVector4<TType>& in_b)\n    {\n        return !(in_a == in_b);\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    template <typename TType> GenericVector4<TType> operator-(GenericVector4<TType> in_a)\n    {\n        in_a.x = -in_a.x;\n        in_a.y = -in_a.y;\n        in_a.z = -in_a.z;\n        in_a.w = -in_a.w;\n        return in_a;\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Math.h",
    "content": "//\n//  Math.h\n//  ChilliSource\n//  Created by Ian Copland on 07/07/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_MATH_H_\n#define _CHILLISOURCE_CORE_MATH_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Math/Interpolate.h>\n#include <ChilliSource/Core/Math/MathUtils.h>\n#include <ChilliSource/Core/Math/Matrix3.h>\n#include <ChilliSource/Core/Math/Matrix4.h>\n#include <ChilliSource/Core/Math/Quaternion.h>\n#include <ChilliSource/Core/Math/Random.h>\n#include <ChilliSource/Core/Math/UnifiedCoordinates.h>\n#include <ChilliSource/Core/Math/Vector2.h>\n#include <ChilliSource/Core/Math/Vector3.h>\n#include <ChilliSource/Core/Math/Vector4.h>\n#include <ChilliSource/Core/Math/Geometry/Curves.h>\n#include <ChilliSource/Core/Math/Geometry/ShapeIntersection.h>\n#include <ChilliSource/Core/Math/Geometry/Shapes.h>\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Memory/IAllocator.h",
    "content": "//\n// The MIT License(MIT)\n// \n// Copyright(c) 2016 Ian Copland\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files(the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and / or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions :\n//\n// The above copyright notice and this permission notice shall be included in all\n// copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n// SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_MEMORY_IALLOCATOR_H_\n#define _CHILLISOURCE_CORE_MEMORY_IALLOCATOR_H_\n\n#include <ChilliSource/ChilliSource.h>\n\n#include <cstddef>\n#include <cstdint>\n\nnamespace ChilliSource\n{\n    /// An interface for all allocator types. This provides the allocation and deallocation\n    /// methods which all allocators should implement.\n    ///\n    /// Implementing this interface allows the allocator to be used with the STD types like\n    /// string and vector.\n    ///\n    /// Whether or not the allocator is thread-safe is dependant on the concrete type.\n    ///\n    class IAllocator\n    {\n    public:\n        /// @return the maximum allocation size allowed by the allocator.\n        ///\n        virtual std::size_t GetMaxAllocationSize() const noexcept = 0;\n\n        /// Allocates a new block of memory of the requested size. Note that the underlying\n        /// implemention may allocate more memory than has been requested.\n        ///\n        /// @param allocationSize\n        ///     The size of the allocation.\n        ///\n        /// @return The allocated memory.\n        ///\n        virtual void* Allocate(std::size_t allocationSize) noexcept = 0;\n\n        /// Deallocates the given memory. This must have been allocated via this allocator.\n        /// Note that the underlying implementation may not actually deallocate the memory\n        /// at this point, though deallocate must still be called.\n        ///\n        /// @param pointer\n        ///     The pointer to deallocate.\n        /// @param allocationSize\n        ///     Size of the initial allocation\n        ///\n        virtual void Deallocate(void* pointer, std::size_t allocationSize) noexcept = 0;\n\n        virtual ~IAllocator() noexcept { }\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Memory/LinearAllocator.cpp",
    "content": "//\n// The MIT License(MIT)\n// \n// Copyright(c) 2015 Ian Copland\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files(the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and / or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions :\n//\n// The above copyright notice and this permission notice shall be included in all\n// copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n// SOFTWARE.\n//\n\n#include <ChilliSource/Core/Memory/LinearAllocator.h>\n\n#include <ChilliSource/Core/Memory/MemoryUtils.h>\n\n#include <cassert>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    LinearAllocator::LinearAllocator(std::size_t pageSize) noexcept\n        : m_bufferSize(pageSize), m_parentAllocator(nullptr)\n    {\n        m_buffer = new std::uint8_t[m_bufferSize];\n        m_nextPointer = MemoryUtils::Align(m_buffer, sizeof(std::intptr_t));\n    }\n\n    //------------------------------------------------------------------------------\n    LinearAllocator::LinearAllocator(IAllocator& parentAllocator, std::size_t pageSize) noexcept\n        : m_bufferSize(pageSize), m_parentAllocator(&parentAllocator)\n    {\n        m_buffer = reinterpret_cast<std::uint8_t*>(m_parentAllocator->Allocate(m_bufferSize));\n        m_nextPointer = MemoryUtils::Align(m_buffer, sizeof(std::intptr_t));\n    }\n\n    //------------------------------------------------------------------------------\n    std::size_t LinearAllocator::GetRemainingSpace() const noexcept\n    {\n        auto freeSpace = m_bufferSize - MemoryUtils::GetPointerOffset(m_nextPointer, m_buffer);\n        auto freeSpaceAligned = freeSpace & ~(sizeof(std::intptr_t) - 1);\n        return freeSpaceAligned;\n    }\n\n    //------------------------------------------------------------------------------\n    void* LinearAllocator::Allocate(std::size_t allocationSize) noexcept\n    {\n        CS_ASSERT(allocationSize <= GetRemainingSpace(), \"Allocation is too big to fit in the remaining space.\");\n\n        std::uint8_t* output = m_nextPointer;\n        m_nextPointer = MemoryUtils::Align(m_nextPointer + allocationSize, sizeof(std::intptr_t));\n\n        ++m_activeAllocationCount;\n\n        return output;\n    }\n\n    //------------------------------------------------------------------------------\n    void LinearAllocator::Deallocate(void* pointer, std::size_t allocationSize) noexcept\n    {\n        CS_ASSERT(Contains(pointer), \"Cannot deallocate a pointer that did not originate from this allocator.\");\n\n        --m_activeAllocationCount;\n    }\n\n    //------------------------------------------------------------------------------\n    bool LinearAllocator::Contains(void* pointer) noexcept\n    {\n        return (pointer >= m_buffer && pointer < reinterpret_cast<std::uint8_t*>(m_buffer) + m_bufferSize);\n    }\n\n    //------------------------------------------------------------------------------\n    void LinearAllocator::Reset() noexcept\n    {\n        CS_ASSERT(m_activeAllocationCount == 0, \"Cannot reset before all allocations have been deallocated.\");\n\n        m_nextPointer = MemoryUtils::Align(m_buffer, sizeof(std::intptr_t));\n    }\n\n    //------------------------------------------------------------------------------\n    LinearAllocator::~LinearAllocator() noexcept\n    {\n        Reset();\n\n        if (m_parentAllocator)\n        {\n            m_parentAllocator->Deallocate(m_buffer, m_bufferSize);\n        }\n        else\n        {\n            delete[] m_buffer;\n        }\n\n        m_buffer = nullptr;\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Core/Memory/LinearAllocator.h",
    "content": "//\n// The MIT License(MIT)\n// \n// Copyright(c) 2015 Ian Copland\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files(the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and / or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions :\n//\n// The above copyright notice and this permission notice shall be included in all\n// copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n// SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_MEMORY_LINEARALLOCATOR_H_\n#define _CHILLISOURCE_CORE_MEMORY_LINEARALLOCATOR_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Memory/IAllocator.h>\n\n#include <vector>\n\nnamespace ChilliSource\n{\n    /// A linear allocator which allocates from a large buffer by simply moving the\n    /// next allocation pointer through the buffer by the size of the allocation. All \n    /// allocations are 'deallocated' at the same time by resetting the allocation \n    /// pointer back to the start of the buffer.\n    ///\n    /// A LinearAllocator can be backed by other allocator types, from which the buffer\n    /// will be allocated, otherwise it's allocated from the free store.\n    ///\n    /// Note that this is not thread-safe and should not be accessed from multiple\n    /// threads at the same time.\n    ///\n    class LinearAllocator final : public IAllocator\n    {\n    public:\n        /// Initialises a new Linear Allocator with the given buffer size. The buffer will be allocated\n        /// from the free store.\n        ///\n        /// @param bufferSize\n        ///     The size of the buffer.\n        /// \n        LinearAllocator(std::size_t bufferSize) noexcept;\n\n        /// Initialises a new Linear Allocator with the given buffer size. The buffer will be allocated\n        /// from the given parent allocator.\n        ///\n        /// @param parentAllocator\n        ///     The allocator from which the buffer will be allocated.\n        /// @param bufferSize\n        ///     The size of the buffer.\n        /// \n        LinearAllocator(IAllocator& parentAllocator, std::size_t bufferSize) noexcept;\n\n        /// This thread-safe.\n        ///\n        /// @return The maximum allocation size from this allocator. This will always be \n        /// the size of the buffer.\n        ///\n        std::size_t GetMaxAllocationSize() const noexcept override { return GetBufferSize(); }\n\n        /// This thread-safe.\n        ///\n        /// @return The size of the buffer. \n        ///\n        std::size_t GetBufferSize() const noexcept { return m_bufferSize; }\n\n        /// @return The number of bytes which are free in the buffer. \n        ///\n        std::size_t GetRemainingSpace() const noexcept;\n\n        /// Allocates a new block of memory of the requested size. If there is no space left in the\n        /// buffer for the alloaction then this will assert.\n        ///\n        /// @param allocationSize\n        ///     The size of the allocation.\n        ///\n        /// @return The allocated memory.\n        ///\n        void* Allocate(std::size_t allocationSize) noexcept override;\n\n        /// Decriments the allocation count. This is checked when resetting to ensure that all previously\n        /// allocated memory has been deallocated.\n        ///\n        /// @param pointer\n        ///     The pointer to deallocate.\n        /// @param allocationSize\n        ///     Size of the initial allocation\n        ///\n        void Deallocate(void* pointer, std::size_t allocationSize) noexcept override;\n\n        /// Evaluates whether or not the given pointer was allocated from this linear\n        /// allocator.\n        ///\n        /// @param pointer\n        ///        The pointer.\n        ///\n        /// @return Whether or not the pointer was allocated from this allocator.\n        ///\n        bool Contains(void* pointer) noexcept;\n\n        /// Resets the buffer, allowing all previously allocated memory to be reused. Deallocate() must\n        /// have been called for all allocated blocks prior to reset() being called.\n        /// \n        void Reset() noexcept;\n\n        ~LinearAllocator() noexcept;\n\n    private:\n        LinearAllocator(LinearAllocator&) = delete;\n        LinearAllocator& operator=(LinearAllocator&) = delete;\n        LinearAllocator(LinearAllocator&&) = delete;\n        LinearAllocator& operator=(LinearAllocator&&) = delete;\n\n        const std::size_t m_bufferSize;\n\n        IAllocator* m_parentAllocator;\n\n        std::uint8_t* m_buffer;\n        std::uint8_t* m_nextPointer = nullptr;\n\n        std::size_t m_activeAllocationCount = 0;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Memory/MemoryUtils.h",
    "content": "//\n// The MIT License(MIT)\n// \n// Copyright(c) 2015 Ian Copland\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files(the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and / or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions :\n//\n// The above copyright notice and this permission notice shall be included in all\n// copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n// SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_MEMORY_MEMORYUTILS_H_\n#define _CHILLISOURCE_CORE_MEMORY_MEMORYUTILS_H_\n\n#include <ChilliSource/ChilliSource.h>\n\n#include <cstdint>\n#include <cassert>\n#include <type_traits>\n\nnamespace ChilliSource\n{\n    namespace MemoryUtils\n    {\n        /// Aligns the given pointer to the given alignment. The alignment should be a power\n        /// of two.\n        ///\n        /// @param value\n        ///     The value to align.\n        /// @param alignment\n        ///     The alignment.\n        ///\n        /// @return The aligned pointer.\n        ///\n        template <typename TValueType, typename TAlignmentType> TValueType* Align(TValueType* value, TAlignmentType alignment) noexcept;\n\n        /// Aligns the given integer to the given alignment. The alignment should be a power\n        /// of two.\n        ///\n        /// @param value\n        ///     The value to align.\n        /// @param alignment\n        ///     The alignment.\n        ///\n        /// @return The aligned integer.\n        ///\n        template <typename TValueType, typename TAlignmentType> TValueType Align(TValueType value, TAlignmentType alignment) noexcept;\n\n        /// @param value\n        ///     The value.\n        /// @param alignment\n        ///     The alignment.\n        ///\n        /// @return Whether or not the given integer is aligned.\n        ///\n        template <typename TValueType, typename TAlignmentType> TValueType IsAligned(TValueType value, TAlignmentType alignment) noexcept;\n\n        /// @param value\n        ///     The value to check.\n        ///\n        /// @return Whether or not the given integer is a power of two.\n        ///\n        template <typename TType> constexpr bool IsPowerOfTwo(TType value) noexcept;\n\n        /// @param value\n        ///     The value.\n        ///\n        /// @return The next power ot two on from the given value. This only supports 32-bit values.\n        ///\n        template <typename TType> TType NextPowerofTwo(TType value) noexcept;\n\n        /// @param value\n        ///     The value. Must be a power of two.\n        ///\n        /// @return The number of times 0x1 has to be shifted to get the given value. \n        ///\n        template <typename TType> std::size_t CalcShift(TType value) noexcept;\n\n        /// @param pointer\n        ///     The pointer.\n        /// @param relativeTo\n        ///     The pointer that the other is relative to. Must have a lower memory address\n        ///     than the value.\n        ///\n        /// @return The offset in bytes between the two pointers. \n        ///\n        template <typename TTypeA, typename TTypeB> std::uintptr_t GetPointerOffset(TTypeA* pointer, TTypeB* relativeTo) noexcept;\n\n        /// Calculates the size of block required for the given object type\n        ///\n        /// @return The block size.\n        ///\n        template <typename TObject> constexpr std::size_t GetBlockSize() noexcept;\n    }\n}\n\n#include \"MemoryUtilsImpl.h\"\n\n#endif"
  },
  {
    "path": "Source/ChilliSource/Core/Memory/MemoryUtilsImpl.h",
    "content": "//\n// The MIT License(MIT)\n// \n// Copyright(c) 2016 Ian Copland\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files(the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and / or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions :\n//\n// The above copyright notice and this permission notice shall be included in all\n// copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n// SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_MEMORY_MEMORYUTILSIMPL_H_\n#define _CHILLISOURCE_CORE_MEMORY_MEMORYUTILSIMPL_H_\n\n#include <algorithm>\n\nnamespace ChilliSource\n{\n    namespace MemoryUtils\n    {\n        //------------------------------------------------------------------------------\n        template <typename TValueType, typename TAlignmentType> TValueType* Align(TValueType* value, TAlignmentType alignment) noexcept\n        {\n            static_assert(std::is_integral<TAlignmentType>::value, \"Alignment must be integral type.\");\n            static_assert(std::is_unsigned<TAlignmentType>::value, \"Alignment must be unsigned.\");\n\n            CS_ASSERT(IsPowerOfTwo(alignment), \"Must be a power of two.\");\n            \n            std::uintptr_t valueIntPtr = reinterpret_cast<std::uintptr_t>(value);\n            std::uintptr_t alignmentIntPtr = static_cast<std::uintptr_t>(alignment);\n\n            return reinterpret_cast<TValueType*>((valueIntPtr + alignmentIntPtr - 1) & ~(alignmentIntPtr - 1));\n        }\n\n        //------------------------------------------------------------------------------\n        template <typename TValueType, typename TAlignmentType> TValueType Align(TValueType value, TAlignmentType alignment) noexcept\n        {\n            static_assert(std::is_integral<TValueType>::value, \"Value must be integral type.\");\n            static_assert(std::is_unsigned<TValueType>::value, \"Value must be unsigned.\");\n            static_assert(std::is_integral<TAlignmentType>::value, \"Alignment must be integral type.\");\n            static_assert(std::is_unsigned<TAlignmentType>::value, \"Alignment must be unsigned.\");\n\n            std::uintptr_t valueIntPtr = static_cast<std::uintptr_t>(value);\n            std::uintptr_t alignmentIntPtr = static_cast<std::uintptr_t>(alignment);\n\n            return static_cast<TValueType>((valueIntPtr + alignmentIntPtr - 1) & ~(alignmentIntPtr - 1));\n        }\n\n        //------------------------------------------------------------------------------\n        template <typename TValueType, typename TAlignmentType> TValueType IsAligned(TValueType value, TAlignmentType alignment) noexcept\n        {\n            static_assert(std::is_integral<TAlignmentType>::value, \"Alignment must be integral type.\");\n            static_assert(std::is_unsigned<TAlignmentType>::value, \"Alignment must be unsigned.\");\n\n            return static_cast<TValueType>((static_cast<TAlignmentType>(value) & (alignment - 1)) == 0);\n        }\n\n        //------------------------------------------------------------------------------\n        template <typename TType> constexpr bool IsPowerOfTwo(TType value) noexcept\n        {\n            static_assert(std::is_integral<TType>::value, \"Value must be integral type.\");\n            static_assert(std::is_unsigned<TType>::value, \"Value must be unsigned.\");\n\n            return (value > 0) && ((value & (~value + 1)) == value);\n        }\n\n        //------------------------------------------------------------------------------\n        template <typename TType> TType NextPowerofTwo(TType value) noexcept\n        {\n            static_assert(std::is_integral<TType>::value, \"Value must be integral type.\");\n            static_assert(std::is_unsigned<TType>::value, \"Value must be unsigned.\");\n\n            value--;\n            value |= value >> 1;\n            value |= value >> 2;\n            value |= value >> 4;\n            value |= value >> 8;\n            value |= value >> 16;\n            value++;\n\n            return value;\n        }\n\n        //------------------------------------------------------------------------------\n        template <typename TType> std::size_t CalcShift(TType value) noexcept\n        {\n            CS_ASSERT(IsPowerOfTwo(value), \"Must be a power of two.\");\n\n            TType output = 0;\n            while (value > 1)\n            {\n                output++;\n                value >>= 1;\n            }\n\n            return output;\n        }\n\n        //------------------------------------------------------------------------------\n        template <typename TTypeA, typename TTypeB> std::uintptr_t GetPointerOffset(TTypeA* pointer, TTypeB* relativeTo) noexcept\n        {\n            auto pointerInt = reinterpret_cast<std::uintptr_t>(pointer);\n            auto relativeToInt = reinterpret_cast<std::uintptr_t>(relativeTo);\n\n            CS_ASSERT(pointerInt >= relativeToInt, \"Pointer must greater than it's parent.\");\n            return (pointerInt - relativeToInt);\n        }\n\n        //------------------------------------------------------------------------------\n        template <typename TObject> constexpr std::size_t GetBlockSize() noexcept\n        {\n            return std::max(sizeof(std::intptr_t) * 2, MemoryUtils::Align(sizeof(TObject), sizeof(std::intptr_t)));\n        }\n    }\n}\n\n#endif"
  },
  {
    "path": "Source/ChilliSource/Core/Memory/ObjectPoolAllocator.h",
    "content": "//\n// The MIT License(MIT)\n// \n// Copyright(c) 2017 Tag Games Ltd\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files(the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and / or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions :\n//\n// The above copyright notice and this permission notice shall be included in all\n// copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n// SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_MEMORY_OBJECTPOOLALLOCATOR_H_\n#define _CHILLISOURCE_CORE_MEMORY_OBJECTPOOLALLOCATOR_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Memory/IAllocator.h>\n\n#include <mutex>\n#include <vector>\n\nnamespace ChilliSource\n{\n    enum class ObjectPoolAllocatorLimitPolicy\n    {\n        k_fixed,\n        k_expand\n    };\n\n    /// Allows allocation of objects of a fixed size from a pre allocated memory block.\n    /// Instead of being deleted objects are returned to the pool.\n    ///\n    /// Pool is created with one of the following policies:\n    /// * FIXED: Does not expand and will assert if out of memory (NOTE: Contiguous in memory)\n    /// * EXPAND: Once the initial limit is reached the pool will expand (NOTE: Expanding pools are not guaranteed to be contiguous in memory as the buffers are paged on the inital size).\n    ///\n    /// Note that this is thread-safe\n    ///\n    template <typename T> class ObjectPoolAllocator final : public IAllocator\n    {\n    public:\n        \n        /// Initialises the pool with the given number of objects. The buffer will be allocated\n        /// from the free store.\n        ///\n        /// @param numObjects\n        ///     The number of objects in the pool\n        /// @param limitPolicy\n        ///     How to handle the case where pool limit is reached\n        /// \n        ObjectPoolAllocator(std::size_t numObjects, ObjectPoolAllocatorLimitPolicy limitPolicy = ObjectPoolAllocatorLimitPolicy::k_fixed) noexcept;\n        \n        \n        /// @return the maximum allocation size allowed by the allocator.\n        ///\n        std::size_t GetMaxAllocationSize() const noexcept override { return m_capacityObjects * sizeof(T); };\n        \n        /// Should be used to allocate only a single object and will\n        /// assert if the given size is not aligned with sizeof(T).\n        ///\n        /// If the limit is reached will obey the limit policy\n        ///\n        /// NOTE: Used via STL container allocation interface and is NOT constructed using placement new\n        ///\n        /// @param allocationSize\n        ///     The size of the allocation must aligned with sizeof(T)\n        ///\n        /// @return The allocated memory (not yet constructed).\n        ///\n        void* Allocate(std::size_t allocationSize) noexcept override;\n\n        /// Allocates a new object from the pool (if the limit is reached will obey the limit policy)\n        ///\n        /// NOTE: Use this if you are using the pool directly and not via STL containers\n        ///\n        /// @return The allocated object (equivalent to calling new T()).\n        ///\n        T* Allocate() noexcept;\n        \n        /// Returns the memory held by the object to the pool. It must have been allocated from\n        /// this pool or will assert\n        ///\n        /// NOTE: Used via STL container allocation interface and is not destructed\n        ///\n        /// @param pointer\n        ///     The pointer to deallocate.\n        /// @param allocationSize\n        ///     Initial allocation size\n        ///\n        void Deallocate(void* pointer, std::size_t allocationSize) noexcept override;\n        \n        /// Returns the memory held by the object to the pool. It must have been allocated from\n        /// this pool or will assert.\n        ///\n        /// NOTE: Use this if you are using the pool directly and not via STL containers\n        ///\n        /// @param pointer\n        ///     The pointer to deallocate and destruct\n        ///\n        void Deallocate(T* pointer) noexcept;\n\n\n        /// Resets the buffer, allowing all previously allocated memory to be reused. Deallocate() must\n        /// have been called for all allocated blocks prior to reset() being called.\n        /// \n        void Reset() noexcept;\n\n        ~ObjectPoolAllocator() noexcept;\n\n    private:\n        ObjectPoolAllocator(ObjectPoolAllocator&) = delete;\n        ObjectPoolAllocator& operator=(ObjectPoolAllocator&) = delete;\n        ObjectPoolAllocator(ObjectPoolAllocator&&) = delete;\n        ObjectPoolAllocator& operator=(ObjectPoolAllocator&&) = delete;\n        \n        /// @return TRUE if the given memory is owned by this pool\n        ///\n        bool IsOwnedByPool(T* pointer) const noexcept;\n        \n        /// @return TRUE if the given memory is currently free to allocate\n        ///\n        bool IsOnFreeStore(T* pointer) const noexcept;\n        \n        /// Adds a new page buffer at a fraction of the size of the original\n        ///\n        /// @param minObjects\n        ///     Min number of objects in the new page\n        ///\n        void Expand(std::size_t minObjects) noexcept;\n        \n        /// Moves all objects to the free store\n        ///\n        void PopulateFreeStore() noexcept;\n        \n        ObjectPoolAllocatorLimitPolicy m_limitPolicy;\n        std::size_t m_activeAllocationCount = 0;\n\t\tstd::size_t m_capacityObjects;\n\n        std::mutex m_mutex;\n        \n        //Buffers are paged to accomodate expansion without invalidating the existing pointers\n        //Fixed size only has a single buffer\n        std::vector<T*> m_buffers;\n        std::vector<std::size_t> m_capacities;\n        T** m_freeStore;\n        T** m_freeStoreHead;\n    };\n    \n    //-----------------------------------------------------------------------------\n    template <typename T> ObjectPoolAllocator<T>::ObjectPoolAllocator(std::size_t numObjects, ObjectPoolAllocatorLimitPolicy limitPolicy) noexcept\n    : m_limitPolicy(limitPolicy), m_capacityObjects(numObjects)\n    {\n        CS_ASSERT(numObjects > 0, \"Cannot create a pool of size 0\");\n        \n        //Create the initial buffer page\n        m_buffers.push_back((T*)malloc(sizeof(T) * numObjects));\n        m_capacities.push_back(numObjects);\n        \n        m_freeStore = (T**)malloc(sizeof(T*) * numObjects);\n        \n        Reset();\n    }\n    \n    //-----------------------------------------------------------------------------\n    template <typename T> void* ObjectPoolAllocator<T>::Allocate(std::size_t allocationSize) noexcept\n    {\n        CS_ASSERT(allocationSize % sizeof(T) == 0, \"Allocations must be sizeof(T) aligned\");\n        \n        std::size_t numToAllocate = allocationSize / sizeof(T);\n        \n        std::unique_lock<std::mutex> lock(m_mutex);\n        \n\t\tstd::size_t remaining = m_capacityObjects - m_activeAllocationCount;\n        \n        if(remaining < numToAllocate)\n        {\n            switch(m_limitPolicy)\n            {\n                case ObjectPoolAllocatorLimitPolicy::k_fixed:\n                    CS_LOG_FATAL(\"ObjectPool out of memory. Allocate more upfront or change to an expansion policy\");\n                    return nullptr;\n                case ObjectPoolAllocatorLimitPolicy::k_expand:\n                    Expand(numToAllocate - remaining);\n                    break;\n            }\n        }\n        \n        T* free = *m_freeStoreHead;\n        m_freeStoreHead += numToAllocate;\n        m_activeAllocationCount += numToAllocate;\n        return free;\n    }\n    \n    //-----------------------------------------------------------------------------\n    template <typename T> T* ObjectPoolAllocator<T>::Allocate() noexcept\n    {\n        void* memory = Allocate(sizeof(T));\n        T* object = new (memory) T();\n        return object;\n    }\n    \n    //-----------------------------------------------------------------------------\n    template <typename T> void ObjectPoolAllocator<T>::Deallocate(void* pointer, std::size_t allocationSize) noexcept\n    {\n        std::unique_lock<std::mutex> lock(m_mutex);\n        \n        CS_ASSERT(allocationSize % sizeof(T) == 0, \"Allocations must be sizeof(T) aligned\");\n        CS_ASSERT(IsOwnedByPool((T*)pointer) == true, \"Pointer you are trying to deallocate from pool is not managed by this pool\");\n        CS_ASSERT(IsOnFreeStore((T*)pointer) == false, \"Pointer you are trying to deallocate from pool has not been allocated\");\n        CS_ASSERT(m_activeAllocationCount > 0, \"The pool has no active allocations.\")\n        \n        auto numObjects = allocationSize / sizeof(T);\n        \n        m_freeStoreHead -= numObjects;\n        m_activeAllocationCount -= numObjects;\n        *m_freeStoreHead = (T*)pointer;\n    }\n    \n    //-----------------------------------------------------------------------------\n    template <typename T> void ObjectPoolAllocator<T>::Deallocate(T* pointer) noexcept\n    {\n        pointer->~T();\n        Deallocate((void*)pointer, sizeof(T));\n    }\n    \n    //-----------------------------------------------------------------------------\n    template <typename T> void ObjectPoolAllocator<T>::Reset() noexcept\n    {\n        std::unique_lock<std::mutex> lock(m_mutex);\n        \n        CS_ASSERT(m_activeAllocationCount == 0, \"Cannot reset before all allocations have been deallocated.\");\n        \n        m_freeStoreHead = m_freeStore;\n        \n        PopulateFreeStore();\n    }\n    \n    //-----------------------------------------------------------------------------\n    template <typename T> bool ObjectPoolAllocator<T>::IsOwnedByPool(T* pointer) const noexcept\n    {\n        for(u32 i=0; i<m_buffers.size(); ++i)\n        {\n            if(pointer >= m_buffers[i] && pointer < m_buffers[i] + m_capacities[i])\n            {\n                return true;\n            }\n        }\n        \n        return false;\n    }\n    \n    //-----------------------------------------------------------------------------\n    template <typename T> bool ObjectPoolAllocator<T>::IsOnFreeStore(T* pointer) const noexcept\n    {\n        for(auto i=m_freeStoreHead; i<m_freeStore+m_capacityObjects; ++i)\n        {\n            if(*i == pointer)\n                return true;\n        }\n        \n        return false;\n    }\n    \n    //-----------------------------------------------------------------------------\n    template <typename T> void ObjectPoolAllocator<T>::Expand(std::size_t minObjects) noexcept\n    {\n        //We use a fraction of the total buffer size for the new buffer\n        auto numObjects = std::max(minObjects, (std::size_t)m_capacityObjects/4);\n        T* buffer = (T*)malloc(sizeof(T) * numObjects);\n        m_buffers.push_back(buffer);\n        m_capacities.push_back(numObjects);\n        m_capacityObjects += numObjects;\n        \n        //Delete the old free store and rebuild with the new buffer appended\n        auto headOffset = m_freeStoreHead - m_freeStore;\n        free(m_freeStore);\n        \n        m_freeStore = (T**)malloc(sizeof(T*) * m_capacityObjects);\n        m_freeStoreHead = m_freeStore + headOffset;\n        \n        PopulateFreeStore();\n    }\n    \n    //-----------------------------------------------------------------------------\n    template <typename T> void ObjectPoolAllocator<T>::PopulateFreeStore() noexcept\n    {\n        u32 freeStoreIndex = 0;\n        \n        for(u32 i=0; i<m_buffers.size(); ++i)\n        {\n            for(std::size_t j=0; j<m_capacities[i]; ++j, ++freeStoreIndex)\n            {\n                m_freeStore[freeStoreIndex] = m_buffers[i] + j;\n            }\n        }\n    }\n    \n    //-----------------------------------------------------------------------------\n    template <typename T> ObjectPoolAllocator<T>::~ObjectPoolAllocator() noexcept\n    {\n        Reset();\n        \n        free(m_freeStore);\n        \n        for(u32 i=0; i<m_buffers.size(); ++i)\n        {\n            free(m_buffers[i]);\n        }\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Memory/PagedLinearAllocator.cpp",
    "content": "//\n// The MIT License(MIT)\n// \n// Copyright(c) 2016 Ian Copland\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files(the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and / or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions :\n//\n// The above copyright notice and this permission notice shall be included in all\n// copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n// SOFTWARE.\n//\n\n#include <ChilliSource/Core/Memory/PagedLinearAllocator.h>\n\n#include <cassert>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    PagedLinearAllocator::PagedLinearAllocator(std::size_t pageSize) noexcept\n        : m_pageSize(pageSize), m_freeStoreLinearAllocators()\n    {\n        m_freeStoreLinearAllocators.push_back(std::unique_ptr<LinearAllocator>(new LinearAllocator(m_pageSize)));\n    }\n\n    //------------------------------------------------------------------------------\n    PagedLinearAllocator::PagedLinearAllocator(IAllocator& parentAllocator, std::size_t pageSize) noexcept\n        : m_pageSize(pageSize), m_parentAllocator(&parentAllocator), m_parentAllocatorLinearAllocators()\n    {\n        m_parentAllocatorLinearAllocators.push_back(MakeUnique<LinearAllocator>(*m_parentAllocator, *m_parentAllocator, m_pageSize));\n    }\n\n    //------------------------------------------------------------------------------\n    std::size_t PagedLinearAllocator::GetNumPages() const noexcept\n    {\n        if (m_parentAllocator)\n        {\n            return m_parentAllocatorLinearAllocators.size();\n        }\n        else\n        {\n            return m_freeStoreLinearAllocators.size();\n        }\n    }\n\n    //------------------------------------------------------------------------------\n    void* PagedLinearAllocator::Allocate(std::size_t allocationSize) noexcept\n    {\n        CS_ASSERT(allocationSize <= GetMaxAllocationSize(), \"Allocation size is too big.\");\n\n        if (m_parentAllocator)\n        {\n            for (const auto& allocator : m_parentAllocatorLinearAllocators)\n            {\n                if (allocator->GetRemainingSpace() >= allocationSize)\n                {\n                    return allocator->Allocate(allocationSize);\n                }\n            }\n\n            m_parentAllocatorLinearAllocators.push_back(MakeUnique<LinearAllocator>(*m_parentAllocator, *m_parentAllocator, m_pageSize));\n            return m_parentAllocatorLinearAllocators.back()->Allocate(allocationSize);\n        }\n        else\n        {\n            for (const auto& allocator : m_freeStoreLinearAllocators)\n            {\n                if (allocator->GetRemainingSpace() >= allocationSize)\n                {\n                    return allocator->Allocate(allocationSize);\n                }\n            }\n\n            m_freeStoreLinearAllocators.push_back(std::unique_ptr<LinearAllocator>(new LinearAllocator(m_pageSize)));\n            return m_freeStoreLinearAllocators.back()->Allocate(allocationSize);\n        }\n    }\n\n    //------------------------------------------------------------------------------\n    void PagedLinearAllocator::Deallocate(void* pointer, std::size_t allocationSize) noexcept\n    {\n        if (m_parentAllocator)\n        {\n            for (const auto& allocator : m_parentAllocatorLinearAllocators)\n            {\n                if (allocator->Contains(pointer))\n                {\n                    return allocator->Deallocate(pointer, allocationSize);\n                }\n            }\n        }\n        else\n        {\n            for (const auto& allocator : m_freeStoreLinearAllocators)\n            {\n                if (allocator->Contains(pointer))\n                {\n                    return allocator->Deallocate(pointer, allocationSize);\n                }\n            }\n        }\n\n        CS_LOG_FATAL(\"Cannot deallocate a pointer that did not originate from this allocator.\");\n    }\n\n    //------------------------------------------------------------------------------\n    void PagedLinearAllocator::Reset() noexcept\n    {\n        if (m_parentAllocator)\n        {\n            for (auto& allocator : m_parentAllocatorLinearAllocators)\n            {\n                allocator->Reset();\n            }\n        }\n        else\n        {\n            for (auto& allocator : m_freeStoreLinearAllocators)\n            {\n                allocator->Reset();\n            }\n        }\n    }\n\n    //------------------------------------------------------------------------------\n    void PagedLinearAllocator::ResetAndShrink() noexcept\n    {\n        Reset();\n\n        if (m_parentAllocator)\n        {\n            while (m_parentAllocatorLinearAllocators.size() > 1)\n            {\n                m_parentAllocatorLinearAllocators.erase(m_parentAllocatorLinearAllocators.begin() + 1);\n            }\n        }\n        else\n        {\n            while (m_freeStoreLinearAllocators.size() > 1)\n            {\n                m_freeStoreLinearAllocators.erase(m_freeStoreLinearAllocators.begin() + 1);\n            }\n        }\n    }\n\n    //------------------------------------------------------------------------------\n    PagedLinearAllocator::~PagedLinearAllocator() noexcept\n    {\n        Reset();\n\n        if (m_parentAllocator)\n        {\n            m_parentAllocatorLinearAllocators.~vector();\n        }\n        else\n        {\n            m_freeStoreLinearAllocators.~vector();\n        }\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Core/Memory/PagedLinearAllocator.h",
    "content": "//\n// The MIT License(MIT)\n// \n// Copyright(c) 2016 Ian Copland\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files(the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and / or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions :\n//\n// The above copyright notice and this permission notice shall be included in all\n// copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n// SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_MEMORY_PAGEDLINEARALLOCATOR_H_\n#define _CHILLISOURCE_CORE_MEMORY_PAGEDLINEARALLOCATOR_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Memory/LinearAllocator.h>\n#include <ChilliSource/Core/Memory/UniquePtr.h>\n\n#include <vector>\n\nnamespace ChilliSource\n{\n    /// A paged version of the linear allocator. This allocates from a large buffer by \n    /// simply moving the next allocation pointer through the buffer by the size of the\n    /// allocation. All allocations are 'deallocated' at the same time by resetting the \n    /// allocation pointer back to the start of the buffer. If an allocation will not\n    /// fit in the current buffer then a new page is allocated. Once a page has been\n    /// allocated it will not be deallocated until ResetAndShink() is called.\n    ///\n    /// A PagedLinearAllocator can be backed by other allocator types, from which pages \n    /// will be allocated, otherwise they are allocated from the free store.\n    ///\n    /// Note that this is not thread-safe and should not be accessed from multiple\n    /// threads at the same time.\n    ///\n    class PagedLinearAllocator final : public IAllocator\n    {\n    public:\n        static constexpr std::size_t k_defaultPageSize = 4 * 1024;\n\n        /// Initialises a new PagedLinearAllocator with the given page size. Pages will be allocated\n        /// from the free store.\n        ///\n        /// @param pageSize\n        ///     The size of a page.\n        /// \n        PagedLinearAllocator(std::size_t pageSize = k_defaultPageSize) noexcept;\n\n        /// Initialises a new PagedLinearAllocator with the given page size. Pages will be allocated\n        /// from the given parent allocator.\n        ///\n        /// @param parentAllocator\n        ///     The allocator from which pages will be allocated.\n        /// @param pageSize\n        ///     The size of a page.\n        /// \n        PagedLinearAllocator(IAllocator& parentAllocator, std::size_t pageSize = k_defaultPageSize) noexcept;\n\n        /// This thread-safe.\n        ///\n        /// @return The maximum allocation size from this allocator. This will always be \n        /// the size of a page.\n        ///\n        std::size_t GetMaxAllocationSize() const noexcept override { return GetPageSize(); }\n\n        /// This thread-safe.\n        ///\n        /// @return The size of a page. \n        ///\n        std::size_t GetPageSize() const noexcept { return m_pageSize; }\n\n        /// @return The number of pages in the allocator.\n        ///\n        std::size_t GetNumPages() const noexcept;\n\n        /// Allocates a new block of memory of the requested size. If there is no space left in the\n        /// buffer for the alloaction then a new page will be allocated. Allocations must be smaller\n        /// than the size of a single page.\n        ///\n        /// @param allocationSize\n        ///     The size of the allocation.\n        ///\n        /// @return The allocated memory.\n        ///\n        void* Allocate(std::size_t allocationSize) noexcept override;\n\n        /// Decriments the allocation count. This is checked when resetting to ensure that all previously\n        /// allocated memory has been deallocated.\n        ///\n        /// @param pointer\n        ///     The pointer to deallocate.\n        /// @param allocationSize\n        ///     Size of the initial allocation\n        ///\n        void Deallocate(void* pointer, std::size_t allocationSize) noexcept override;\n\n        /// Resets the buffer, allowing all previously allocated memory to be reused. Deallocate() must\n        /// have been called for all allocated blocks prior to reset() being called.\n        /// \n        void Reset() noexcept;\n\n        /// Resets the buffer and deallocates any extra pages which have been allocated.\n        /// \n        void ResetAndShrink() noexcept;\n\n        ~PagedLinearAllocator() noexcept;\n\n    private:\n        PagedLinearAllocator(PagedLinearAllocator&) = delete;\n        PagedLinearAllocator& operator=(PagedLinearAllocator&) = delete;\n        PagedLinearAllocator(PagedLinearAllocator&&) = delete;\n        PagedLinearAllocator& operator=(PagedLinearAllocator&&) = delete;\n\n        const std::size_t m_pageSize;\n\n        IAllocator* m_parentAllocator = nullptr;\n\n        union\n        {\n            std::vector<std::unique_ptr<LinearAllocator>> m_freeStoreLinearAllocators;\n            std::vector<UniquePtr<LinearAllocator>> m_parentAllocatorLinearAllocators;\n        };\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Memory/SharedPtr.h",
    "content": "//\n// The MIT License(MIT)\n// \n// Copyright(c) 2016 Ian Copland\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files(the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and / or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions :\n//\n// The above copyright notice and this permission notice shall be included in all\n// copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n// SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_MEMORY_SHAREDPTR_H_\n#define _CHILLISOURCE_CORE_MEMORY_SHAREDPTR_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Memory/IAllocator.h>\n\n#include <memory>\n\nnamespace ChilliSource\n{\n    template <typename TType> using SharedPtr = std::shared_ptr<TType>;\n\n    /// Allocates a new shared pointer from the given Allocator with the given \n    /// constructor parameters. This follows the make_* convention set in the \n    /// standard library.\n    ///\n    /// @param allocator\n    ///     The allocator from which to allocate the requested type.\n    /// @param constructorArgs\n    ///     The arguments for the constructor if appropriate.\n    ///\n    /// @return A shared pointer to the allocated instance.\n    ///\n    template <typename TType, typename... TConstructorArgs> SharedPtr<TType> MakeShared(IAllocator& allocator, TConstructorArgs&&... constructorArgs) noexcept;\n}\n\n#include \"SharedPtrImpl.h\"\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Memory/SharedPtrImpl.h",
    "content": "//\n// The MIT License(MIT)\n// \n// Copyright(c) 2016 Ian Copland\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files(the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and / or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions :\n//\n// The above copyright notice and this permission notice shall be included in all\n// copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n// SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_MEMORY_SHAREDPTRIMPL_H_\n#define _CHILLISOURCE_CORE_MEMORY_SHAREDPTRIMPL_H_\n\n#include <ChilliSource/Core/Memory/UniquePtr.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    template <typename TType, typename... TConstructorArgs> SharedPtr<TType> MakeShared(IAllocator& allocator, TConstructorArgs&&... constructorArgs) noexcept\n    {\n        return MakeUnique<TType>(allocator, std::forward<TConstructorArgs>(constructorArgs)...);\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Memory/UniquePtr.h",
    "content": "//\n// The MIT License(MIT)\n// \n// Copyright(c) 2016 Ian Copland\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files(the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and / or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions :\n//\n// The above copyright notice and this permission notice shall be included in all\n// copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n// SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_MEMORY_UNIQUEPTR_H_\n#define _CHILLISOURCE_CORE_MEMORY_UNIQUEPTR_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Memory/IAllocator.h>\n\n#include <functional>\n#include <memory>\n\nnamespace ChilliSource\n{\n    template <typename TType> using UniquePtr = std::unique_ptr<TType, std::function<void(typename std::add_const<typename std::remove_all_extents<TType>::type>::type*)>>;\n\n    /// Allocates a new unique pointer from the given Allocator with the given \n    /// constructor parameters. This follows the make_* convention set in the \n    /// standard library.\n    ///\n    /// @param allocator\n    ///     The allocator from which to allocate the requested type.\n    /// @param constructorArgs\n    ///     The arguments for the constructor if appropriate.\n    ///\n    /// @return A unique pointer to the allocated instance.\n    ///\n    template <typename TType, typename... TConstructorArgs> UniquePtr<TType> MakeUnique(IAllocator& allocator, TConstructorArgs&&... constructorArgs) noexcept;\n\n    /// Allocates a new unique pointer to an array from the given Allocator with \n    /// the given size. This follows the make_* convention  set in the standard \n    /// library. Note that, like new[], fundamental types  will not be set to a \n    /// default value. \n    ///\n    /// @param allocator\n    ///     The allocator from which to allocate the requested type.\n    /// @param size\n    ///     The size of the array.\n    ///\n    /// @return A unique pointer to the allocated array.\n    ///\n    template <typename TType> UniquePtr<TType[]> MakeUniqueArray(IAllocator& allocator, std::size_t size) noexcept;\n}\n\n#include \"UniquePtrImpl.h\"\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Memory/UniquePtrImpl.h",
    "content": "//\n// The MIT License(MIT)\n// \n// Copyright(c) 2016 Ian Copland\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files(the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and / or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions :\n//\n// The above copyright notice and this permission notice shall be included in all\n// copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n// SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_MEMORY_UNIQUEPTRIMPL_H_\n#define _CHILLISOURCE_CORE_MEMORY_UNIQUEPTRIMPL_H_\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    template <typename TType, typename... TConstructorArgs> UniquePtr<TType> MakeUnique(IAllocator& allocator, TConstructorArgs&&... constructorArgs) noexcept\n    {\n        void* memory = allocator.Allocate(sizeof(TType));\n        TType* object = new (memory) TType(std::forward<TConstructorArgs>(constructorArgs)...);\n        return UniquePtr<TType>(object, [&allocator](const TType* object) noexcept -> void\n        {\n            object->~TType();\n            allocator.Deallocate((void*)(object), sizeof(TType));\n        });\n    }\n\n    //------------------------------------------------------------------------------\n    template <typename TType> UniquePtr<TType[]> MakeUniqueArray(IAllocator& allocator, std::size_t size) noexcept\n    {\n        auto array = reinterpret_cast<TType*>(allocator.Allocate(sizeof(TType) * size));\n        if (!std::is_fundamental<TType>::value)\n        {\n            for (std::size_t i = 0; i < size; ++i)\n            {\n                new (array + i) TType();\n            }\n        }\n\n        return UniquePtr<TType[]>(array, [&allocator, size](const TType* array) noexcept -> void\n        {\n            if (!std::is_fundamental<TType>::value)\n            {\n                for (std::size_t i = 0; i < size; ++i)\n                {\n                    (array + i)->~TType();\n                }\n            }\n\n            allocator.Deallocate((void*)(array), sizeof(TType) * size);\n        });\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Memory.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_MEMORY_H_\n#define _CHILLISOURCE_CORE_MEMORY_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Memory/IAllocator.h>\n#include <ChilliSource/Core/Memory/LinearAllocator.h>\n#include <ChilliSource/Core/Memory/MemoryUtils.h>\n#include <ChilliSource/Core/Memory/ObjectPoolAllocator.h>\n#include <ChilliSource/Core/Memory/PagedLinearAllocator.h>\n#include <ChilliSource/Core/Memory/SharedPtr.h>\n#include <ChilliSource/Core/Memory/UniquePtr.h>\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Notification/AppNotificationSystem.cpp",
    "content": "//\n//  AppNotificationSystem.cpp\n//  ChilliSource\n//\n//  Created by Ian Copland on 10/03/2014.\n//  Copyright (c) 2014 Tag Games Ltd. All rights reserved.\n//\n\n#include <ChilliSource/Core/Notification/AppNotificationSystem.h>\n\n#include <ChilliSource/Core/Base/Application.h>\n\nnamespace ChilliSource\n{\n    CS_DEFINE_NAMEDTYPE(AppNotificationSystem);\n    //--------------------------------------------------\n    //--------------------------------------------------\n    AppNotificationSystemUPtr AppNotificationSystem::Create()\n    {\n        return AppNotificationSystemUPtr(new AppNotificationSystem());\n    }\n    //--------------------------------------------------\n    //--------------------------------------------------\n    AppNotificationSystem::AppNotificationSystem()\n    : m_enabled(true)\n    {\n    }\n    //--------------------------------------------------\n    //--------------------------------------------------\n    bool AppNotificationSystem::IsA(InterfaceIDType in_interfaceId) const\n    {\n        return (AppNotificationSystem::InterfaceID == in_interfaceId);\n    }\n    //--------------------------------------------------\n    //--------------------------------------------------\n    void AppNotificationSystem::SetEnabled(bool in_enabled)\n    {\n        m_enabled = in_enabled;\n        if (m_enabled == false)\n        {\n            CancelAll();\n        }\n    }\n    //---------------------------------------------------\n    //---------------------------------------------------\n    void AppNotificationSystem::ScheduleNotificationForTime(Notification::ID in_id, const ParamDictionary& in_params, TimeIntervalSecs in_time, Notification::Priority in_priority)\n    {\n        if (m_enabled == true)\n        {\n            NotificationContainer notificationContainer;\n            notificationContainer.m_notification = std::make_shared<Notification>();\n            notificationContainer.m_notification->m_id = in_id;\n            notificationContainer.m_notification->m_params = in_params;\n            notificationContainer.m_notification->m_priority = in_priority;\n            notificationContainer.m_triggerTime = in_time;\n            m_notifications.push_back(notificationContainer);\n        }\n    }\n    //--------------------------------------------------------\n    //--------------------------------------------------------\n    void AppNotificationSystem::GetScheduledNotifications(std::vector<NotificationCSPtr>& out_notifications, TimeIntervalSecs in_time, TimeIntervalSecs in_period) const\n    {\n        for (const NotificationContainer& notificationContainer : m_notifications)\n        {\n            if (notificationContainer.m_triggerTime > in_time && notificationContainer.m_triggerTime <= in_time + in_period)\n            {\n                out_notifications.push_back(notificationContainer.m_notification);\n            }\n        }\n    }\n    //--------------------------------------------------------\n    //--------------------------------------------------------\n    void AppNotificationSystem::CancelByID(Notification::ID in_id)\n    {\n        for(auto it = m_notifications.begin(); it != m_notifications.end();)\n        {\n            if(in_id == it->m_notification->m_id)\n            {\n                it = m_notifications.erase(it);\n            }\n            else\n            {\n                ++it;\n            }\n        }\n    }\n    //--------------------------------------------------------\n    //--------------------------------------------------------\n    void AppNotificationSystem::CancelAll()\n    {\n        m_notifications.clear();\n    }\n    //--------------------------------------------------\n    //---------------------------------------------------\n    IConnectableEvent<AppNotificationSystem::ReceivedDelegate>& AppNotificationSystem::GetReceivedEvent()\n    {\n        return m_receivedEvent;\n    }\n    //--------------------------------------------------\n    //--------------------------------------------------\n    void AppNotificationSystem::OnUpdate(f32 in_deltaTime)\n    {\n        TimeIntervalSecs currentTime = Application::Get()->GetSystemTime();\n        \n        for(auto it = m_notifications.begin(); it != m_notifications.end();)\n        {\n            if(currentTime >= it->m_triggerTime)\n            {\n                m_receivedEvent.NotifyConnections(it->m_notification);\n                it = m_notifications.erase(it);\n            }\n            else\n            {\n                ++it;\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Core/Notification/AppNotificationSystem.h",
    "content": "//\n//  AppNotificationSystem.h\n//  ChilliSource\n//  Created by Ian Copland on 10/03/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_NOTIFICATION_APPNOTIFICATIONSYSTEM_H_\n#define _CHILLISOURCE_CORE_NOTIFICATION_APPNOTIFICATIONSYSTEM_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/System/AppSystem.h>\n#include <ChilliSource/Core/Notification/Notification.h>\n\n#include <functional>\n#include <limits>\n#include <vector>\n\nnamespace ChilliSource\n{\n    //---------------------------------------------------------\n    /// Schedules notifications within the application. These\n    /// will be lost if the application is re-started.\n    //---------------------------------------------------------\n    class AppNotificationSystem final : public AppSystem\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(AppNotificationSystem);\n        //--------------------------------------------------\n        /// Delegates\n        //--------------------------------------------------\n        using ReceivedDelegate = std::function<void(const NotificationCSPtr&)>;\n        //--------------------------------------------------\n        /// Creates a new instance of the system.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @return The new instance.\n        //--------------------------------------------------\n        static AppNotificationSystemUPtr Create();\n        //--------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param The interface ID to check against.\n        /// @return Whether this implements the passed in\n        /// interface id.\n        //--------------------------------------------------\n        bool IsA(InterfaceIDType in_interfaceId) const override;\n        //--------------------------------------------------\n        /// Enables and disables addition of app notifications.\n        /// All existing notifications will be cancelled\n        /// when this is disabled. This is enabled by default.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param Whether or not to enable the scheduling\n        /// of app notifications.\n        //---------------------------------------------------\n        void SetEnabled(bool in_enabled);\n        //---------------------------------------------------\n        /// Once the time is reached the notification will\n        /// be inserted into the queue. Upon reaching the head\n        /// of the queue it will trigger.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The notification id\n        /// @param The notification params.\n        /// @param Time in seconds at which it should trigger.\n        /// @param [Optional] The notification priority. Defaults\n        /// to standard priority.\n        //---------------------------------------------------\n        void ScheduleNotificationForTime(Notification::ID in_id, const ParamDictionary& in_params, TimeIntervalSecs in_time, Notification::Priority in_priority = Notification::Priority::k_standard);\n        //--------------------------------------------------------\n        /// Builds a list of all notifications currently scheduled\n        /// within the given time period.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param [Out] The list of notifications.\n        /// @param [Optional] The start time.\n        /// @param [Optional] The end time.\n        //--------------------------------------------------------\n        void GetScheduledNotifications(std::vector<NotificationCSPtr>& out_notifications, TimeIntervalSecs in_time = 0, TimeIntervalSecs in_period = std::numeric_limits<TimeIntervalSecs>::max()) const;\n        //--------------------------------------------------------\n        /// Prevent any notifications with given ID type from\n        /// firing.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param ID type\n        //--------------------------------------------------------\n        void CancelByID(Notification::ID in_id);\n        //--------------------------------------------------------\n        /// Terminate all currently scheduled notifications.\n        ///\n        /// @author Ian Copland\n        //--------------------------------------------------------\n        void CancelAll();\n        //--------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return An event that can be used to listen for\n        /// new notifications being received.\n        //---------------------------------------------------\n        IConnectableEvent<ReceivedDelegate>& GetReceivedEvent();\n        \n    private:\n        //--------------------------------------------------\n        /// A container for information about a single\n        /// notification, including the time it is scheduled\n        /// for.\n        //--------------------------------------------------\n        struct NotificationContainer\n        {\n            NotificationSPtr m_notification;\n            TimeIntervalSecs m_triggerTime;\n        };\n        //--------------------------------------------------\n        /// Private constructor to force the use of the\n        /// factory method.\n        ///\n        /// @author Ian Copland\n        //--------------------------------------------------\n        AppNotificationSystem();\n        //--------------------------------------------------\n        /// Processes the notifications, triggering any that\n        /// are queued.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The delta time.\n        //--------------------------------------------------\n        void OnUpdate(f32 in_deltaTime) override;\n        \n        bool m_enabled;\n        std::vector<NotificationContainer> m_notifications;\n        Event<ReceivedDelegate> m_receivedEvent;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Notification/LocalNotificationSystem.cpp",
    "content": "//\n//  LocalNotificationSystem.h\n//  ChilliSource\n//  Created by Ian Copland on 12/01/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Core/Notification/LocalNotificationSystem.h>\n\n#include <ChilliSource/Core/Base/Application.h>\n\n#ifdef CS_TARGETPLATFORM_IOS\n#include <CSBackend/Platform/iOS/Core/Notification/LocalNotificationSystem.h>\n#endif\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n#include <CSBackend/Platform/Android/Main/JNI/Core/Notification/LocalNotificationSystem.h>\n#endif\n\nnamespace ChilliSource\n{\n    CS_DEFINE_NAMEDTYPE(LocalNotificationSystem);\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    LocalNotificationSystemUPtr LocalNotificationSystem::Create()\n    {\n#ifdef CS_TARGETPLATFORM_IOS\n        return LocalNotificationSystemUPtr(new CSBackend::iOS::LocalNotificationSystem());\n#endif\n#ifdef CS_TARGETPLATFORM_ANDROID\n        return LocalNotificationSystemUPtr(new CSBackend::Android::LocalNotificationSystem());\n#endif\n        return nullptr;\n    }\n}\n\n\n"
  },
  {
    "path": "Source/ChilliSource/Core/Notification/LocalNotificationSystem.h",
    "content": "//\n//  LocalNotificationSystem.h\n//  ChilliSource\n//  Created by Ian Copland on 12/01/2012.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2012 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_NOTIFICATION_LOCALNOTIFICATIONSYSTEM_H_\n#define _CHILLISOURCE_CORE_NOTIFICATION_LOCALNOTIFICATIONSYSTEM_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/System/AppSystem.h>\n#include <ChilliSource/Core/Notification/Notification.h>\n\n#include <functional>\n#include <limits>\n\nnamespace ChilliSource\n{\n    //-------------------------------------------------------\n    /// Schedules notifications using the platform specific\n    /// notification alarm. Notifications scheduled using\n    /// this can still be received even if the Application\n    /// is restarted.\n    ///\n    /// The methods in this class aren't thread-safe, and \n    /// must be accessed from the main thread.\n    ///\n    //-------------------------------------------------------\n    class LocalNotificationSystem : public AppSystem\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(LocalNotificationSystem);\n        //--------------------------------------------------\n        /// Delegates\n        //--------------------------------------------------\n        using ReceivedDelegate = std::function<void(const NotificationCSPtr&)>;\n        using GetScheduledNotificationsDelegate = std::function<void(const std::vector<NotificationCSPtr>& scheduledNotifications)>;\n        //-------------------------------------------------------\n        /// Create the platform dependent backend\n        ///\n        /// @author S Downie\n        ///\n        /// @return New backend instance\n        //-------------------------------------------------------\n        static LocalNotificationSystemUPtr Create();\n        //--------------------------------------------------\n        /// Enables and disables addition of local notifications.\n        /// All existing notifications will be cancelled\n        /// when this is disabled. This is enabled by default.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param Whether or not to enable the scheduling\n        /// of app notifications.\n        //---------------------------------------------------\n        virtual void SetEnabled(bool in_enabled) = 0;\n        //---------------------------------------------------\n        /// Schedules a Local Notifcation which should fire\n        /// at the given time. A Local Notification uses\n        /// the system specfic notification alarms and can\n        /// be received even if it was scheduled during a\n        /// previous instance of the application.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The notification id\n        /// @param The notification params.\n        /// @param Time in seconds at which it should trigger.\n        /// @param [Optional] The notification priority. Defaults\n        /// to standard priority.\n        //---------------------------------------------------\n        virtual void ScheduleNotificationForTime(Notification::ID in_id, const ParamDictionary& in_params, TimeIntervalSecs in_time, Notification::Priority in_priority = Notification::Priority::k_standard) = 0;\n        //----------------------------------------------------------\n        /// Generates a list of all notifications that are currently\n        /// scheduled. Because the list cannot be immediately\n        /// calculated, the result is returned through the provided\n        /// delegate when ready.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The delegate function to execute.\n        /// @param [Optional] The start time.\n        /// @param [Optional] The end time.\n        //---------------------------------------------------------\n        virtual void GetScheduledNotifications(const GetScheduledNotificationsDelegate& in_delegate, TimeIntervalSecs in_time = 0, TimeIntervalSecs in_period = std::numeric_limits<TimeIntervalSecs>::max()) const = 0;\n        //--------------------------------------------------------\n        /// Cancel By ID\n        ///\n        /// Prevent any notifications with given ID type from firing\n        ///\n        /// @param ID type\n        //--------------------------------------------------------\n        virtual void CancelByID(Notification::ID inID) = 0;\n        //--------------------------------------------------------\n        /// Cancel All\n        ///\n        /// Terminate all currently scheduled notifications\n        //--------------------------------------------------------\n        virtual void CancelAll() = 0;\n        //--------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return An event that can be used to listen for\n        /// new notifications being received.\n        //---------------------------------------------------\n        virtual IConnectableEvent<ReceivedDelegate>& GetReceivedEvent() = 0;\n        //--------------------------------------------------------\n        /// Destructor\n        //--------------------------------------------------------\n        virtual ~LocalNotificationSystem(){};\n    protected:\n        //-------------------------------------------------------\n        /// Private constructor to force use of factory method\n        ///\n        /// @author S Downie\n        //-------------------------------------------------------\n        LocalNotificationSystem(){}\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Notification/Notification.h",
    "content": "//\n//  Notification.h\n//  ChilliSource\n//  Created by Ian Copland on 10/03/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_NOTIFICATION_NOTIFICATION_H_\n#define _CHILLISOURCE_CORE_NOTIFICATION_NOTIFICATION_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Event/Event.h>\n#include <ChilliSource/Core/Container/ParamDictionary.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------\n    /// A notification that can be used by any of the notification\n    /// systems.\n    //------------------------------------------------------------\n    struct Notification\n    {\n        //----------------------------------------------------\n        /// An enum describing the priority of a notification.\n        //----------------------------------------------------\n        enum class Priority\n        {\n            k_standard,\n            k_high\n        };\n        //----------------------------------------------------\n        /// Typedefs\n        //----------------------------------------------------\n        typedef u32 ID;\n\n        ID m_id;\n        ParamDictionary m_params;\n        Priority m_priority;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Notification/NotificationManager.cpp",
    "content": "//\n//  NotificationSystem.cpp\n//  ChilliSource\n//  Created by Ian Copland on 10/03/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Core/Notification/NotificationManager.h>\n\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/Delegate/MakeDelegate.h>\n#include <ChilliSource/Core/Notification/AppNotificationSystem.h>\n#include <ChilliSource/Core/Notification/LocalNotificationSystem.h>\n#include <ChilliSource/Core/Notification/RemoteNotificationSystem.h>\n\nnamespace ChilliSource\n{\n    namespace\n    {\n        const f32 k_minTimeBetweenNotifications = 2.0f;\n    }\n    \n    CS_DEFINE_NAMEDTYPE(NotificationManager);\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    NotificationManagerUPtr NotificationManager::Create()\n    {\n        return NotificationManagerUPtr(new NotificationManager());\n    }\n    //--------------------------------------------------\n    //--------------------------------------------------\n    NotificationManager::NotificationManager()\n        : m_appNotificationSystem(nullptr), m_localNotificationSystem(nullptr), m_remoteNotificationSystem(nullptr), m_timeSinceNotification(0.0f)\n    {\n    }\n    //-----------------------------------------------------\n    //-----------------------------------------------------\n    bool NotificationManager::IsA(InterfaceIDType in_interfaceId) const\n    {\n        return (NotificationManager::InterfaceID == in_interfaceId);\n    }\n    //--------------------------------------------------\n    //---------------------------------------------------\n    void NotificationManager::ScheduleAppNotification(Notification::ID in_id, const ParamDictionary& in_params, Notification::Priority in_priority)\n    {\n        ScheduleAppNotificationForTime(in_id, in_params, 0, in_priority);\n    }\n    //---------------------------------------------------\n    //---------------------------------------------------\n    void NotificationManager::ScheduleAppNotificationForTime(Notification::ID in_id, const ParamDictionary& in_params, TimeIntervalSecs in_time, Notification::Priority in_priority)\n    {\n        if (m_appNotificationSystem != nullptr)\n        {\n            m_appNotificationSystem->ScheduleNotificationForTime(in_id, in_params, in_time, in_priority);\n        }\n    }\n    //---------------------------------------------------\n    //----------------------------------------------------\n    void NotificationManager::ScheduleAppNotificationAfterTime(Notification::ID in_id, const ParamDictionary& in_params, TimeIntervalSecs in_time, Notification::Priority in_priority)\n    {\n        ScheduleAppNotificationForTime(in_id, in_params, Application::Get()->GetSystemTime() + in_time, in_priority);\n    }\n    //---------------------------------------------------\n    //---------------------------------------------------\n    void NotificationManager::ScheduleLocalNotificationForTime(Notification::ID in_id, const ParamDictionary& in_params, TimeIntervalSecs in_time, Notification::Priority in_priority)\n    {\n        if (m_localNotificationSystem != nullptr)\n        {\n            m_localNotificationSystem->ScheduleNotificationForTime(in_id, in_params, in_time, in_priority);\n        }\n    }\n    //---------------------------------------------------\n    //----------------------------------------------------\n    void NotificationManager::ScheduleLocalNotificationAfterTime(Notification::ID in_id, const ParamDictionary& in_params, TimeIntervalSecs in_time, Notification::Priority in_priority)\n    {\n        ScheduleLocalNotificationForTime(in_id, in_params, Application::Get()->GetSystemTime() + in_time, in_priority);\n    }\n    //--------------------------------------------------------\n    //--------------------------------------------------------\n    void NotificationManager::GetScheduledNotifications(const GetScheduledNotificationsDelegate& in_delegate, TimeIntervalSecs in_time, TimeIntervalSecs in_period) const\n    {\n        std::vector<NotificationCSPtr> scheduledAppNotifications;\n        \n        if(m_appNotificationSystem != nullptr)\n        {\n            m_appNotificationSystem->GetScheduledNotifications(scheduledAppNotifications);\n        }\n        \n        if(m_localNotificationSystem != nullptr)\n        {\n            m_localNotificationSystem->GetScheduledNotifications([=](std::vector<NotificationCSPtr> notifications)\n            {\n                std::vector<NotificationCSPtr> scheduledNotifications;\n                \n                for(auto notification : scheduledAppNotifications)\n                {\n                    scheduledNotifications.push_back(notification);\n                }\n                \n                for(auto notification : notifications)\n                {\n                    scheduledNotifications.push_back(notification);\n                }\n                \n                in_delegate(scheduledNotifications);\n            });\n        }\n    }\n    //---------------------------------------------------\n    //---------------------------------------------------\n    void NotificationManager::CancelByID(Notification::ID in_id)\n    {\n        if (m_appNotificationSystem != nullptr)\n        {\n            m_appNotificationSystem->CancelByID(in_id);\n        }\n        \n        if (m_localNotificationSystem != nullptr)\n        {\n            m_localNotificationSystem->CancelByID(in_id);\n        }\n    }\n    //---------------------------------------------------\n    //---------------------------------------------------\n    void NotificationManager::CancelAll()\n    {\n        if (m_appNotificationSystem != nullptr)\n        {\n            m_appNotificationSystem->CancelAll();\n        }\n        \n        if (m_localNotificationSystem != nullptr)\n        {\n            m_localNotificationSystem->CancelAll();\n        }\n    }\n    //---------------------------------------------------\n    //----------------------------------------------------\n    void NotificationManager::Dismiss(const NotificationCSPtr& in_notification)\n    {\n        CS_ASSERT(m_notificationQueue.empty() == false, \"Cannot dismiss from an empty notification queue!\");\n        CS_ASSERT(m_notificationQueue.front().m_notification == in_notification, \"Trying to dismiss notification that is not the active notification!\");\n        \n        if (m_notificationQueue.empty() == false && m_notificationQueue.front().m_notification == in_notification)\n        {\n            m_notificationQueue.front().m_dismissed = true;\n        }\n    }\n    //---------------------------------------------------\n    //----------------------------------------------------\n    IConnectableEvent<NotificationManager::ReceivedDelegate>& NotificationManager::GetReceivedEvent()\n    {\n        return m_receivedEvent;\n    }\n    //---------------------------------------------------\n    //----------------------------------------------------\n    IConnectableEvent<NotificationManager::DismissedDelegate>& NotificationManager::GetDismissedEvent()\n    {\n        return m_dismissedEvent;\n    }\n    //------------------------------------------------\n    //------------------------------------------------\n    void NotificationManager::OnInit()\n    {\n        //setup the app notification system\n        m_appNotificationSystem = Application::Get()->GetSystem<AppNotificationSystem>();\n        if (m_appNotificationSystem != nullptr)\n        {\n            m_appReceivedConnection = m_appNotificationSystem->GetReceivedEvent().OpenConnection(MakeDelegate(this, &NotificationManager::OnNotificationReceived));\n        }\n        \n        //setup the local notification system\n        m_localNotificationSystem = Application::Get()->GetSystem<LocalNotificationSystem>();\n        if (m_localNotificationSystem != nullptr)\n        {\n            m_localReceivedConnection = m_localNotificationSystem->GetReceivedEvent().OpenConnection(MakeDelegate(this, &NotificationManager::OnNotificationReceived));\n        }\n        \n        //setup the remote notification system\n        m_remoteNotificationSystem = Application::Get()->GetSystem<RemoteNotificationSystem>();\n        if (m_remoteNotificationSystem != nullptr)\n        {\n            m_remoteReceivedConnection = m_remoteNotificationSystem->GetReceivedEvent().OpenConnection(MakeDelegate(this, &NotificationManager::OnNotificationReceived));\n        }\n    }\n    //------------------------------------------------\n    //------------------------------------------------\n    void NotificationManager::OnNotificationReceived(const NotificationCSPtr& in_notification)\n    {\n        NotificationContainer notificationContainer;\n        notificationContainer.m_notification = std::make_shared<Notification>();\n        notificationContainer.m_notification->m_id = in_notification->m_id;\n        notificationContainer.m_notification->m_params = in_notification->m_params;\n        notificationContainer.m_notification->m_priority = in_notification->m_priority;\n        notificationContainer.m_dismissed = false;\n        notificationContainer.m_triggered = false;\n        \n        switch (notificationContainer.m_notification->m_priority)\n        {\n            case Notification::Priority::k_standard:\n                m_notificationQueue.push_back(notificationContainer);\n                break;\n            case Notification::Priority::k_high:\n                m_notificationQueue.push_front(notificationContainer);\n                break;\n            default:\n                CS_LOG_ERROR(\"Invalid notification priority.\");\n        }\n    }\n    //------------------------------------------------\n    //------------------------------------------------\n    void NotificationManager::OnUpdate(f32 in_deltaTime)\n    {\n        m_timeSinceNotification += in_deltaTime;\n        \n        if(m_notificationQueue.empty() == false && m_timeSinceNotification >= k_minTimeBetweenNotifications)\n        {\n            if (m_notificationQueue.front().m_dismissed == true)\n            {\n                m_dismissedEvent.NotifyConnections(m_notificationQueue.front().m_notification);\n                m_notificationQueue.pop_front();\n            }\n            \n            if(m_notificationQueue.empty() == false && m_notificationQueue.front().m_triggered == false)\n            {\n                m_receivedEvent.NotifyConnections(this, m_notificationQueue.front().m_notification);\n                m_notificationQueue.front().m_triggered = true;\n                m_timeSinceNotification = 0.0f;\n            }\n        }\n    }\n    //------------------------------------------------\n    //------------------------------------------------\n    void NotificationManager::OnDestroy()\n    {\n        //cleanup the app notification system.\n        m_appReceivedConnection.reset();\n        m_appNotificationSystem = nullptr;\n        \n        //cleanup the local notification system\n        m_localReceivedConnection.reset();\n        m_localNotificationSystem = nullptr;\n        \n        //cleanup the remote notification system\n        m_remoteReceivedConnection.reset();\n        m_remoteNotificationSystem = nullptr;\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Core/Notification/NotificationManager.h",
    "content": "//\n//  NotificationManager.h\n//  ChilliSource\n//  Created by Ian Copland on 10/03/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_NOTIFICATION_NOTIFICATIONMANAGER_H_\n#define _CHILLISOURCE_CORE_NOTIFICATION_NOTIFICATIONMANAGER_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Notification/Notification.h>\n#include <ChilliSource/Core/Notification/LocalNotificationSystem.h>\n#include <ChilliSource/Core/System/AppSystem.h>\n\n#include <functional>\n#include <limits>\n#include <queue>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------\n    /// Manages the various different notification systems,\n    /// providing a single interface though which different\n    /// notification types can be created and received. Notifications\n    /// received though this are queued so that only one notification\n    /// can be received at a time.\n    //------------------------------------------------------------\n    class NotificationManager final : public AppSystem\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(NotificationManager);\n        //-----------------------------------------------------\n        /// Typedefs\n        //-----------------------------------------------------\n        using ReceivedDelegate = std::function<void(NotificationManager*, const NotificationCSPtr&)>;\n        using DismissedDelegate = std::function<void(const NotificationCSPtr&)>;\n        using GetScheduledNotificationsDelegate = std::function<void(const std::vector<NotificationCSPtr>& scheduledNotifications)>;\n        //-----------------------------------------------------\n        /// Creates a new instance of the system.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @return The new instance.\n        //-----------------------------------------------------\n        static NotificationManagerUPtr Create();\n        //-----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param The interface Id to check against.\n        /// @return Whether this implements the passed in\n        /// interface id.\n        //-----------------------------------------------------\n        bool IsA(InterfaceIDType in_interfaceId) const override;\n        //--------------------------------------------------\n        /// Schedules an App Notification which should fire\n        /// as soon as it can. An App Notification is\n        /// specfic to this process and will be lost if\n        /// the application is restarted.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The notification id\n        /// @param The notification params.\n        /// @param [Optional] The notification priority. Defaults\n        /// to standard priority.\n        //---------------------------------------------------\n        void ScheduleAppNotification(Notification::ID in_id, const ParamDictionary& in_params, Notification::Priority in_priority = Notification::Priority::k_standard);\n        //---------------------------------------------------\n        /// Schedules an App Notification which should fire\n        /// at the given time. An App Notification is specific\n        /// to this process and will be lost if the application\n        /// is restarted.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The notification id\n        /// @param The notification params.\n        /// @param Time in seconds at which it should trigger.\n        /// @param [Optional] The notification priority. Defaults\n        /// to standard priority.\n        //---------------------------------------------------\n        void ScheduleAppNotificationForTime(Notification::ID in_id, const ParamDictionary& in_params, TimeIntervalSecs in_time, Notification::Priority in_priority = Notification::Priority::k_standard);\n        //---------------------------------------------------\n        /// Schedules an App Notification should shoud fire\n        /// after the given time. An App Notification is\n        /// specific to this process and will be lost if\n        /// the application is restarted.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The notification id\n        /// @param The notification params.\n        /// @param Time in seconds at which it should trigger.\n        /// @param [Optional] The notification priority. Defaults\n        /// to standard priority.\n        //----------------------------------------------------\n        void ScheduleAppNotificationAfterTime(Notification::ID in_id, const ParamDictionary& in_params, TimeIntervalSecs in_time, Notification::Priority in_priority = Notification::Priority::k_standard);\n        //---------------------------------------------------\n        /// Schedules a Local Notifcation which should fire\n        /// at the given time. A Local Notification uses\n        /// the system specfic notification alarms and can\n        /// be received even if it was scheduled during a\n        /// previous instance of the application.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The notification id\n        /// @param The notification params.\n        /// @param Time in seconds at which it should trigger.\n        /// @param [Optional] The notification priority. Defaults\n        /// to standard priority.\n        //---------------------------------------------------\n        void ScheduleLocalNotificationForTime(Notification::ID in_id, const ParamDictionary& in_params, TimeIntervalSecs in_time, Notification::Priority in_priority = Notification::Priority::k_standard);\n        //---------------------------------------------------\n        /// Schedules a Local Notifcation which should fire\n        /// after the given time. A Local Notification uses\n        /// the system specfic notification alarms and can\n        /// be received even if it was scheduled during a\n        /// previous instance of the application.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The notification id\n        /// @param The notification params.\n        /// @param Time in seconds at which it should trigger.\n        /// @param [Optional] The notification priority. Defaults\n        /// to standard priority.\n        //----------------------------------------------------\n        void ScheduleLocalNotificationAfterTime(Notification::ID in_id, const ParamDictionary& in_params, TimeIntervalSecs in_time, Notification::Priority in_priority = Notification::Priority::k_standard);\n        //----------------------------------------------------------\n        /// Generates a list of all notifications that are currently\n        /// scheduled. Because the list cannot be immediately\n        /// calculated, the result is returned through the provided\n        /// delegate when ready.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The delegate function to execute.\n        /// @param [Optional] The start time.\n        /// @param [Optional] The end time.\n        //---------------------------------------------------------\n        void GetScheduledNotifications(const GetScheduledNotificationsDelegate& in_delegate, TimeIntervalSecs in_time = 0, TimeIntervalSecs in_period = std::numeric_limits<TimeIntervalSecs>::max()) const;\n        //---------------------------------------------------\n        /// Prevent any notifications with given ID type from\n        /// firing.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The ID of the notification to cancel.\n        //---------------------------------------------------\n        void CancelByID(Notification::ID in_id);\n        //---------------------------------------------------\n        /// Terminate all currently scheduled notifications.\n        ///\n        /// @author Ian Copland\n        //---------------------------------------------------\n        void CancelAll();\n        //---------------------------------------------------\n        /// Dismisses the given event. This must be called when\n        /// an even is received to allow the next event though.\n        ///\n        /// @author\n        //----------------------------------------------------\n        void Dismiss(const NotificationCSPtr& in_notification);\n        //---------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return An event which will be fired whenever a\n        /// notification is received.\n        //----------------------------------------------------\n        IConnectableEvent<ReceivedDelegate>& GetReceivedEvent();\n        //---------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return An event which will be fired whenever a\n        /// notification is dismissed.\n        //----------------------------------------------------\n        IConnectableEvent<DismissedDelegate>& GetDismissedEvent();\n    private:\n        //--------------------------------------------------\n        /// A container for information about a single\n        /// notification, including the time it is scheduled\n        /// for.\n        //--------------------------------------------------\n        struct NotificationContainer\n        {\n            NotificationSPtr m_notification;\n            bool m_dismissed;\n            bool m_triggered;\n        };\n        //--------------------------------------------------\n        /// Private constructor to force the use of the\n        /// factory method.\n        ///\n        /// @author Ian Copland\n        //--------------------------------------------------\n        NotificationManager();\n        //------------------------------------------------\n        /// Gets handles to the different notification\n        /// systems if they exist.\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------\n        void OnInit() override;\n        //------------------------------------------------\n        /// Called when a notification is received from\n        /// any of the notification systems.\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------\n        void OnNotificationReceived(const NotificationCSPtr& in_notification);\n        //------------------------------------------------\n        /// Updates the notification queue and fires any\n        /// notifications that are ready.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The delta time.\n        //------------------------------------------------\n        void OnUpdate(f32 in_deltaTime) override;\n        //------------------------------------------------\n        /// Cleans up the handles to the different\n        /// notification systems.\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------\n        void OnDestroy() override;\n        \n        AppNotificationSystem* m_appNotificationSystem;\n        LocalNotificationSystem* m_localNotificationSystem;\n        RemoteNotificationSystem* m_remoteNotificationSystem;\n        std::deque<NotificationContainer> m_notificationQueue;\n        Event<ReceivedDelegate> m_receivedEvent;\n        Event<DismissedDelegate> m_dismissedEvent;\n        EventConnectionUPtr m_appReceivedConnection;\n        EventConnectionUPtr m_localReceivedConnection;\n        EventConnectionUPtr m_remoteReceivedConnection;\n        f32 m_timeSinceNotification;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Notification/RemoteNotificationSystem.cpp",
    "content": "//\n//  RemoteNotificationSystem.cpp\n//  ChilliSource\n//  Created by Robert Henning on 22/01/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Core/Notification/RemoteNotificationSystem.h>\n\n#ifdef CS_TARGETPLATFORM_IOS\n#import <CSBackend/Platform/iOS/Core/Notification/RemoteNotificationSystem.h>\n#endif\n\nnamespace ChilliSource\n{\n    CS_DEFINE_NAMEDTYPE(RemoteNotificationSystem);\n    //----------------------------------------------------\n    //----------------------------------------------------\n    RemoteNotificationSystemUPtr RemoteNotificationSystem::Create()\n    {\n#ifdef CS_TARGETPLATFORM_IOS\n        return RemoteNotificationSystemUPtr(new CSBackend::iOS::RemoteNotificationSystem());\n#elif defined(CS_TARGETPLATFORM_ANDROID)\n#ifdef CS_ANDROIDFLAVOUR_GOOGLEPLAY\n        return nullptr;\n#endif\n#endif\n        return nullptr;\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Core/Notification/RemoteNotificationSystem.h",
    "content": "//\n//  RemoteNotificationSystem.h\n//  ChilliSource\n//  Created by Robert Henning on 22/01/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_NOTIFICATION_REMOTENOTIFICATIONSYSTEM_H_\n#define _CHILLISOURCE_CORE_NOTIFICATION_REMOTENOTIFICATIONSYSTEM_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/System/AppSystem.h>\n\n#include <functional>\n\nnamespace ChilliSource\n{\n    //---------------------------------------------------\n    /// A system for listening for remote/push notifications.\n    ///\n    /// @author Robert Henning\n    //---------------------------------------------------\n    class RemoteNotificationSystem : public AppSystem\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(RemoteNotificationSystem);\n        //---------------------------------------------------\n        /// Typedefs\n        //---------------------------------------------------\n        using TokenReceivedDelegate = std::function<void(const std::string&)>;\n        using NotificationReceivedDelegate = std::function<void(const NotificationCSPtr&)>;\n        //---------------------------------------------------\n        /// Creates a new platform specfic instance of the remote\n        /// notification system.\n        ///\n        /// @author Robert Henning\n        //---------------------------------------------------\n        static RemoteNotificationSystemUPtr Create();\n        //--------------------------------------------------\n        /// Enables and disables addition of remote notifications.\n        /// All existing notifications will be cancelled\n        /// when this is disabled. This is enabled by default.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param Whether or not to enable the scheduling\n        /// of app notifications.\n        //---------------------------------------------------\n        virtual void SetEnabled(bool in_enabled) = 0;\n        //--------------------------------------------------\n        /// Request the remote token for this device for use\n        /// with Push Notifications.\n        ///\n        /// @author Robert Henning\n        ///\n        /// @param The return delegate.\n        //--------------------------------------------------\n        virtual void RequestRemoteToken(const TokenReceivedDelegate& in_delegate) = 0;\n        //--------------------------------------------------\n        /// @author Robert Hennin\n        ///\n        /// @return The unique token that the push notification\n        /// provider uses to identify the device\n        //--------------------------------------------------\n        virtual const std::string& GetRemoteToken() const = 0;\n        //--------------------------------------------------\n        /// @author Robert Hennin\n        ///\n        /// @return The ID for the Apple remote notification\n        /// service\n        //--------------------------------------------------\n        virtual const std::string& GetProviderID() const = 0;\n        //--------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return An event that can be used to listen for\n        /// new notifications being received.\n        //---------------------------------------------------\n        virtual IConnectableEvent<NotificationReceivedDelegate>& GetReceivedEvent() = 0;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Notification.h",
    "content": "//\n//  Notification.h\n//  ChilliSource\n//  Created by Ian Copland on 07/07/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_NOTIFICATION_H_\n#define _CHILLISOURCE_CORE_NOTIFICATION_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Notification/AppNotificationSystem.h>\n#include <ChilliSource/Core/Notification/LocalNotificationSystem.h>\n#include <ChilliSource/Core/Notification/Notification.h>\n#include <ChilliSource/Core/Notification/NotificationManager.h>\n#include <ChilliSource/Core/Notification/RemoteNotificationSystem.h>\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Resource/IResourceOptions.h",
    "content": "//\n//  IResourceOptions.h\n//  ChilliSource\n//  Created by Scott Downie on 16/05/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n\n#ifndef _CHILLISOURCE_CORE_RESOURCE_IRESOURCEOPTIONS_H_\n#define _CHILLISOURCE_CORE_RESOURCE_IRESOURCEOPTIONS_H_\n\n#include <ChilliSource/ChilliSource.h>\n\nnamespace ChilliSource\n{\n    //-------------------------------------------------------\n    /// Interface class for custom loading options for\n    /// resources. This allows custom loading to take place\n    /// via the generic resource pool loaders.\n    ///\n    /// @author S Downie\n    //-------------------------------------------------------\n    class IResourceOptionsBase\n    {\n    public:\n        //-------------------------------------------------------\n        /// Overriden to generate a unique hash based on the\n        /// currently set options\n        ///\n        /// @author S Downie\n        ///\n        /// @return Hash of the options contents\n        //-------------------------------------------------------\n        virtual u32 GenerateHash() const = 0;\n        //-------------------------------------------------------\n        /// Virual destructor\n        ///\n        /// @author S Downie\n        //-------------------------------------------------------\n        virtual ~IResourceOptionsBase(){}\n    };\n    //-------------------------------------------------------\n    /// Interface class that provides type protection when\n    /// passing into resource pool.\n    ///\n    /// @author S Downie\n    //-------------------------------------------------------\n    template <typename TResourceType> class IResourceOptions : public IResourceOptionsBase\n    {\n    public:\n        \n        //-------------------------------------------------------\n        /// Virual destructor\n        ///\n        /// @author S Downie\n        //-------------------------------------------------------\n        virtual ~IResourceOptions(){}\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Resource/Resource.cpp",
    "content": "//\n//  Resource.cpp\n//  ChilliSource\n//  Created by Scott Downie on 30/09/2010.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2010 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Core/Resource/Resource.h>\n\n#include <ChilliSource/Core/File/StorageLocation.h>\n\nnamespace ChilliSource\n{\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    Resource::Resource()\n    : m_location(StorageLocation::k_none), m_loadState(LoadState::k_loading)\n    {\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    Resource::LoadState Resource::GetLoadState() const\n    {\n        return m_loadState;\n    }\n    //-------------------------------------------------------\n    /// If we set the load state to loaded or failed\n    /// we need to notify any waiting parties that the resource\n    /// is now ready\n    //-------------------------------------------------------\n    void Resource::SetLoadState(LoadState in_loadState)\n    {\n        m_loadState = in_loadState;\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    void Resource::SetFilePath(const std::string& in_filePath)\n    {\n        m_filePath = in_filePath;\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    const std::string& Resource::GetFilePath() const\n    {\n        return m_filePath;\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    void Resource::SetName(const std::string& in_name)\n    {\n        m_name = in_name;\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    const std::string& Resource::GetName() const\n    {\n        return m_name;\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    void Resource::SetId(ResourceId in_id)\n    {\n        m_id = in_id;\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    Resource::ResourceId Resource::GetId() const\n    {\n        return m_id;\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    void Resource::SetOptions(const IResourceOptionsBaseCSPtr& in_options)\n    {\n        m_options = in_options;\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    const IResourceOptionsBaseCSPtr& Resource::GetOptions() const\n    {\n        return m_options;\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    void Resource::SetStorageLocation(StorageLocation in_location)\n    {\n        m_location = in_location;\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    StorageLocation Resource::GetStorageLocation() const\n    {\n        return m_location;\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Core/Resource/Resource.h",
    "content": "//\n//  Resource.h\n//  ChilliSource\n//  Created by Scott Downie on 30/09/2010.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2010 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n\n#ifndef _CHILLISOURCE_CORE_RESOURCE_RESOURCE_H_\n#define _CHILLISOURCE_CORE_RESOURCE_RESOURCE_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Base/QueryableInterface.h>\n#include <ChilliSource/Core/Container/ParamDictionary.h>\n\n#include <atomic>\n\nnamespace ChilliSource\n{\n    //-------------------------------------------------------\n    /// Interface into a resource. A resource is typically\n    /// an asset loaded from file (i.e. an image, a shader, a\n    /// model, etc.). Resources are loaded via providers\n    /// and the resource pool API. Resources are cached\n    /// by the pool and will not be destroyed until the pool\n    /// releases them. Resources can be loaded asynchronously\n    /// and their current load state queried.\n    ///\n    /// @author S Downie\n    //-------------------------------------------------------\n    class Resource : public QueryableInterface\n    {\n    public:\n        \n        using ResourceId = u32;\n        \n        CS_DECLARE_NOCOPY(Resource);\n        \n        //-------------------------------------------------------\n        /// Describes the current load state of the resource\n        /// largely for use with async loading in order to\n        /// determine when the resource is safe to use\n        ///\n        /// @author S Downie\n        //-------------------------------------------------------\n        enum class LoadState\n        {\n            k_loading,\n            k_loaded,\n            k_failed\n        };\n        \n        //-------------------------------------------------------\n        /// Constructor\n        ///\n        /// @author S Downie\n        //-------------------------------------------------------\n        Resource();\n        //-------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return The file path of the resource. If the resource\n        /// was not loaded from file then this is empty.\n        //-------------------------------------------------------\n        const std::string& GetFilePath() const;\n        //-------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The name of the resource. If this was loaded\n        /// from file this will be the file name. Otherwise this\n        /// will be the unique string Id of the resource.\n        //-------------------------------------------------------\n        const std::string& GetName() const;\n        //-------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return The resource id as set by the resource pool\n        //-------------------------------------------------------\n        ResourceId GetId() const;\n        //-------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param The storage location of the resource.\n        //-------------------------------------------------------\n        void SetStorageLocation(StorageLocation in_location);\n        //-------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return The storage location of the resource.\n        //-------------------------------------------------------\n        StorageLocation GetStorageLocation() const;\n        //-------------------------------------------------------\n        /// NOTE: This is used by the resource providers and\n        /// should not be called by the general application unless\n        /// they are manually constructing resources. The application\n        /// can check this flag to determine if the resource was\n        /// loaded correctly\n        ///\n        /// @author S Downie\n        ///\n        /// @param Current load state\n        //-------------------------------------------------------\n        void SetLoadState(LoadState in_loadState);\n        //-------------------------------------------------------\n        /// Used to query the loading progress of a resource\n        /// to determine when it is safe to use\n        ///\n        /// @author S Downie\n        ///\n        /// @return Current load state\n        //-------------------------------------------------------\n        LoadState GetLoadState() const;\n        //-------------------------------------------------------\n        /// Virtual desctructor\n        ///\n        /// @author S Downie\n        //-------------------------------------------------------\n        virtual ~Resource(){}\n        \n    private:\n        \n        friend class ResourcePool;\n        //-------------------------------------------------------\n        /// NOTE: Not for general application used by the providers\n        /// to set the file path as the resource may need to be\n        /// reloaded on context loss\n        ///\n        /// @author S Downie\n        ///\n        /// @param The file path of the resource. Used to load\n        /// again if context is lost\n        //-------------------------------------------------------\n        void SetFilePath(const std::string& in_filePath);\n        //-------------------------------------------------------\n        /// Sets the name of the resource. This is the name\n        /// that can be used to look up the resource using\n        /// ResourcePool::GetResource(). This should only be set\n        /// by the resource pool.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The name of the resource.\n        //-------------------------------------------------------\n        void SetName(const std::string& in_name);\n        //-------------------------------------------------------\n        /// NOTE: Not for general application used by the providers\n        /// to set the id\n        ///\n        /// @author S Downie\n        ///\n        /// @param The resource id\n        //-------------------------------------------------------\n        void SetId(ResourceId in_id);\n        //-------------------------------------------------------\n        /// NOTE: Not for general application used by the providers\n        /// to set the load options as the resource may need to be\n        /// reloaded on context loss\n        ///\n        /// @author S Downie\n        ///\n        /// @param The load options of the resource. Used to load\n        /// again if context is lost\n        //-------------------------------------------------------\n        void SetOptions(const IResourceOptionsBaseCSPtr& in_options);\n        //-------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return The options that were set on the resource on\n        /// loading.\n        //-------------------------------------------------------\n        const IResourceOptionsBaseCSPtr& GetOptions() const;\n        \n    private:\n        \n        IResourceOptionsBaseCSPtr m_options;\n        \n        std::string m_filePath;\n        std::string m_name;\n        StorageLocation m_location;\n        ResourceId m_id;\n    \n        std::atomic<LoadState> m_loadState;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Resource/ResourcePool.cpp",
    "content": "//\n//  ResourcePool.cpp\n//  ChilliSource\n//  Created by Scott Downie on 03/04/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Core/Resource/ResourcePool.h>\n\n#include <ChilliSource/Core/Resource/ResourceProvider.h>\n\nnamespace ChilliSource\n{\n    CS_DEFINE_NAMEDTYPE(ResourcePool);\n    \n    //------------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------------\n    ResourcePoolUPtr ResourcePool::Create()\n    {\n        return ResourcePoolUPtr(new ResourcePool());\n    }\n    //------------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------------\n    bool ResourcePool::IsA(InterfaceIDType in_interfaceId) const\n    {\n        return in_interfaceId == ResourcePool::InterfaceID;\n    }\n    //------------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------------\n    void ResourcePool::AddProvider(ResourceProvider* in_provider)\n    {\n        CS_ASSERT(in_provider != nullptr, \"Cannot add null resource provider to pool\");\n        auto itDescriptor = m_descriptors.find(in_provider->GetResourceType());\n        \n        if(itDescriptor == m_descriptors.end())\n        {\n            PoolDesc desc;\n            desc.m_providers.push_back(in_provider);\n            m_descriptors.insert(std::make_pair(in_provider->GetResourceType(), desc));\n        }\n        else\n        {\n            itDescriptor->second.m_providers.push_back(in_provider);\n        }\n    }\n    //------------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------------\n    ResourceProvider* ResourcePool::FindProvider(const std::string& in_filePath, const PoolDesc& in_desc)\n    {\n        //Find the resource provider that can handle this extension\n        std::string fileName;\n        std::string fileExtension;\n        StringUtils::SplitBaseFilename(in_filePath, fileName, fileExtension);\n        \n        u32 numProviders = static_cast<u32>(in_desc.m_providers.size());\n        for(u32 i=0; i<numProviders; ++i)\n        {\n            if(in_desc.m_providers[i]->CanCreateResourceWithFileExtension(fileExtension))\n            {\n                return in_desc.m_providers[i];\n            }\n        }\n        \n        CS_LOG_ERROR(\"Failed to find resource provider for extension \" + fileExtension);\n        return nullptr;\n    }\n    //------------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------------\n    Resource::ResourceId ResourcePool::GenerateResourceId(const std::string& in_uniqueId) const\n    {\n        return HashCRC32::GenerateHashCode(in_uniqueId);\n    }\n    //------------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------------\n    Resource::ResourceId ResourcePool::GenerateResourceId(StorageLocation in_location, const std::string& in_filePath, const IResourceOptionsBaseCSPtr& in_options) const\n    {\n        std::string combined(ToString((u32)in_location) + in_filePath);\n        u32 fileHash = HashCRC32::GenerateHashCode(combined);\n        \n        if(in_options == nullptr)\n        {\n            return fileHash;\n        }\n        \n        u32 optionsHash = in_options->GenerateHash();\n        \n        u64 combinedHash = fileHash + ((u64)(optionsHash) << 32);\n        return HashCRC32::GenerateHashCode((const s8*)&combinedHash, sizeof(u64));\n    }\n    //-------------------------------------------------------------------------------------\n    /// Resources often have references to other resources and therefore multiple release passes\n    /// are required until no more resources are released\n    //-------------------------------------------------------------------------------------\n    void ResourcePool::ReleaseAllUnused()\n    {\n        std::unique_lock<std::mutex> lock(m_mutex);\n        u32 numReleased = 0;\n        \n        do\n        {\n            numReleased = 0;\n            \n            for(auto& descEntry : m_descriptors)\n            {\n                for(auto itResource = descEntry.second.m_cachedResources.begin(); itResource != descEntry.second.m_cachedResources.end(); /*NO INCREMENT*/)\n                {\n                    if(itResource->second.use_count() == 1)\n                    {\n                        //The pool is the sole owner so we can safely release the object\n                        CS_LOG_VERBOSE(\"Releasing resource from pool \" + itResource->second->GetName());\n                        itResource = descEntry.second.m_cachedResources.erase(itResource);\n                        numReleased++;\n                    }\n                    else\n                    {\n                        ++itResource;\n                    }\n                }\n            }\n        }\n        while(numReleased > 0);\n    }\n    //-------------------------------------------------------------------------------------\n    //-------------------------------------------------------------------------------------\n    void ResourcePool::Release(const Resource* in_resource)\n    {\n        CS_RELEASE_ASSERT(Application::Get()->GetTaskScheduler()->IsMainThread() == true, \"Resources can only be released on the main thread\");\n        CS_ASSERT(in_resource != nullptr, \"Pool cannot release null resource\");\n        //Find the descriptor that handles this type of resource\n        \n        std::unique_lock<std::mutex> lock(m_mutex);\n        auto itDescriptor = m_descriptors.find(in_resource->GetInterfaceID());\n        CS_ASSERT(itDescriptor != m_descriptors.end(), \"Failed to find resource pool for \" + in_resource->GetInterfaceTypeName());\n        \n        auto& cachedResources(itDescriptor->second.m_cachedResources);\n        \n        for(auto itResource = cachedResources.begin(); itResource != cachedResources.end(); /*NO INCREMENT*/)\n        {\n            if(itResource->second.get() == in_resource)\n            {\n                ResourceSPtr& resource = itResource->second;\n                CS_ASSERT((resource.use_count() <= 1), \"Cannot release a resource if it is owned by another object (i.e. use_count > 0) : (\" + resource->GetName() + \")\");\n                CS_LOG_VERBOSE(\"Releasing resource from pool \" + resource->GetName());\n                cachedResources.erase(itResource);\n                return;\n            }\n            else\n            {\n                ++itResource;\n            }\n        }\n    }\n    //------------------------------------------------------------------------------------\n    /// At this stage in the app lifecycle all app and system references to resource\n    /// should have been released. If the resource pool still has resources then this\n    /// indicated leaks.\n    //------------------------------------------------------------------------------------\n    void ResourcePool::Destroy()\n    {\n        ReleaseAllUnused();\n        \n        bool error = false;\n        \n        for(auto& descEntry : m_descriptors)\n        {\n            for(auto itResource = descEntry.second.m_cachedResources.begin(); itResource != descEntry.second.m_cachedResources.end(); ++itResource)\n            {\n                //The pool is the sole owner so we can safely release the object\n                CS_LOG_ERROR(\"Resource still in use: \" + itResource->second->GetName());\n                error = true;\n            }\n        }\n        \n        if(error == true)\n        {\n            CS_LOG_FATAL(\"Resources are still in use. Indicates that there is leaky references\");\n        }\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Core/Resource/ResourcePool.h",
    "content": "//\n//  ResourcePool.h\n//  ChilliSource\n//  Created by Scott Downie on 03/04/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_RESOURCE_RESOURCEPOOL_H_\n#define _CHILLISOURCE_CORE_RESOURCE_RESOURCEPOOL_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/File/TaggedFilePathResolver.h>\n#include <ChilliSource/Core/Resource/IResourceOptions.h>\n#include <ChilliSource/Core/Resource/Resource.h>\n#include <ChilliSource/Core/Resource/ResourceProvider.h>\n#include <ChilliSource/Core/System/AppSystem.h>\n#include <ChilliSource/Core/Threading/TaskScheduler.h>\n\n#include <functional>\n#include <mutex>\n#include <unordered_map>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------------\n    /// System that allows the loading and caching of resources. Resource can be loaded\n    /// from file based on the resource type and are cached. Subsequent requests for the\n    /// same resource will return the cached copy. The resource pool always holds the last\n    /// reference to any resource.\n    ///\n    /// @author S Downie\n    //------------------------------------------------------------------------------------\n    class ResourcePool final : public AppSystem\n    {\n    public:\n        \n        CS_DECLARE_NAMEDTYPE(ResourcePool);\n        \n        //------------------------------------------------------------------------------------\n        /// Factory method for creating the system\n        ///\n        /// @author S Downie\n        ///\n        /// @return Ownership of new system instance\n        //------------------------------------------------------------------------------------\n        static ResourcePoolUPtr Create();\n        //------------------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Interface ID to compare\n        ///\n        /// @return Whether the object is of the given interface type\n        //------------------------------------------------------------------------------------\n        bool IsA(InterfaceIDType in_interfaceId) const override;\n        //------------------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Resource provider that will be assigned to load a specific resource type\n        //------------------------------------------------------------------------------------\n        void AddProvider(ResourceProvider* in_provider);\n        //------------------------------------------------------------------------------------\n        /// Creates an unloaded mutable resource with the given Id. The resource will be\n        /// cached by the pool. The responsibility for loading or building the resource\n        /// lies with the app code. Attempting to create a resource with an exisiting Id will\n        /// cause an assertion.\n        ///\n        /// The resource is mutable\n        ///\n        /// NOTE: Resource should not start with '_'. This is reserved for internal engine\n        /// resources.\n        ///\n        /// @author S Downie\n        ///\n        /// @param Unique Id\n        ///\n        /// @return Resource or null\n        //-------------------------------------------------------------------------------------\n        template <typename TResourceType> std::shared_ptr<TResourceType> CreateResource(const std::string& in_uniqueId);\n        //------------------------------------------------------------------------------------\n        /// Return the cached resource with the given unique ID. If the resource\n        /// does not exist then null is returned.\n        ///\n        /// The resource is immutable\n        ///\n        /// @author S Downie\n        ///\n        /// @param Unique ID\n        ///\n        /// @return Resource or null\n        //-------------------------------------------------------------------------------------\n        template <typename TResourceType> std::shared_ptr<const TResourceType> GetResource(const std::string& in_uniqueId) const;\n        //------------------------------------------------------------------------------------\n        /// Returns all cached resources of the requested type.  The resources are immutable.\n        ///\n        /// @author I Copland\n        ///\n        /// @return A list of all resource of the requested type.\n        //-------------------------------------------------------------------------------------\n        template <typename TResourceType> std::vector<std::shared_ptr<const TResourceType>> GetAllResources() const;\n        //------------------------------------------------------------------------------------\n        /// Load the resource of given type from the file location. If the resource at this\n        /// location has previously been loaded then the cached version will be returned.\n        /// Check the load state of the resources of that type prior to use.\n        ///\n        /// The resource is immutable\n        ///\n        /// If the resource cannot be loaded or no loader exists for that type of resource\n        /// then null will be returned\n        ///\n        /// @author S Downie\n        ///\n        /// @param Storage location\n        /// @param File path\n        /// @param Load options that are used by the underlying providers to customise\n        /// initialisation\n        ///\n        /// @return Resource or null\n        //-------------------------------------------------------------------------------------\n        template <typename TResourceType> std::shared_ptr<const TResourceType> LoadResource(StorageLocation in_location, const std::string& in_filePath, const IResourceOptionsCSPtr<TResourceType>& in_options = nullptr);\n        //------------------------------------------------------------------------------------\n        /// Forec the reload of the resource of given type from the file location. This will\n        /// overwrite the currently cached version. This will fail if no cached resource\n        /// is found. Check the load state of the resources of that type prior to use\n        ///\n        /// The resource is immutable\n        ///\n        /// If the resource cannot be loaded or no loader exists for that type of resource\n        /// then null will be returned\n        ///\n        /// @author S Downie\n        ///\n        /// @param Storage location\n        /// @param File path\n        /// @param Load options that are used by the underlying providers to customise\n        /// initialisation\n        ///\n        /// @return Resource or null\n        //-------------------------------------------------------------------------------------\n        template <typename TResourceType> std::shared_ptr<const TResourceType> RefreshResource(StorageLocation in_location, const std::string& in_filePath, const IResourceOptionsCSPtr<TResourceType>& in_options = nullptr);\n        //------------------------------------------------------------------------------------\n        /// Force the reload of the resources of the given type that are currently cached.\n        /// Check the load state of the resources of that type prior to use, although if they\n        /// have loaded once then chances are they will load again.\n        ///\n        /// @author S Downie\n        //-------------------------------------------------------------------------------------\n        template <typename TResourceType> void RefreshResources();\n        //------------------------------------------------------------------------------------\n        /// Load the resource of given type from the file location. If the resource at this\n        /// location has previously been loaded then the cached version will be returned in the\n        /// delegate.\n        ///\n        /// The resource is immutable\n        ///\n        /// If the file requires loading it will be done on a background thread. The resource\n        /// will be returned in the delegate. Check the resource load state to see\n        /// if it has loaded successfully or not. NOTE: The resource may be null which also\n        /// indicates failure\n        ///\n        /// @author S Downie\n        ///\n        /// @param Storage location\n        /// @param File path\n        /// @param Load options that are used by the underlying providers to customise\n        /// initialisation\n        /// @param Delegate to trigger when the resource is loaded or failed. Note: Always\n        /// called on the main thread\n        //-------------------------------------------------------------------------------------\n        template <typename TResourceType> void LoadResourceAsync(StorageLocation in_location, const std::string& in_filePath, const IResourceOptionsCSPtr<TResourceType>& in_options, const std::function<void(const std::shared_ptr<const TResourceType>&)>& in_delegate);\n        //------------------------------------------------------------------------------------\n        /// Load the resource of given type from the file location. If the resource at this\n        /// location has previously been loaded then the cached version will be returned in the\n        /// delegate.\n        ///\n        /// The resource is immutable\n        ///\n        /// If the file requires loading it will be done on a background thread. The resource\n        /// will be returned in the delegate. Check the resource load state to see\n        /// if it has loaded successfully or not. NOTE: The resource may be null which also\n        /// indicates failure\n        ///\n        /// @author S Downie\n        ///\n        /// @param Storage location\n        /// @param File path\n        /// @param Delegate to trigger when the resource is loaded or failed. Note: Always\n        /// called on the main thread\n        //-------------------------------------------------------------------------------------\n        template <typename TResourceType> void LoadResourceAsync(StorageLocation in_location, const std::string& in_filePath, const std::function<void(const std::shared_ptr<const TResourceType>&)>& in_delegate);\n        //-------------------------------------------------------------------------------------\n        /// Forces the pool to release its handle to any unused resources of the given type.\n        /// If a resource is still in use the pool will keep it in the cache. The pool is\n        /// therefore the last reference to a resource and the resource will be destroyed once\n        /// it is removed from the pool\n        ///\n        /// @author S Downie\n        //-------------------------------------------------------------------------------------\n        template <typename TResourceType> void ReleaseUnused();\n        //-------------------------------------------------------------------------------------\n        /// Forces the pool to release its handle to any unused resources.\n        /// If a resource is still in use the pool will keep it in the cache. The pool is\n        /// therefore the last reference to a resource and the resource will be destroyed once\n        /// it is removed from the pool\n        ///\n        /// @author S Downie\n        //-------------------------------------------------------------------------------------\n        void ReleaseAllUnused();\n        //-------------------------------------------------------------------------------------\n        /// Remove the resource from the resource pool and cause it\n        /// to be destroyed. This will assert if the resource has\n        /// any references so call with a raw pointer i.e.\n        ///\n        ///\n        ///  rawCPtr = sharedPtr.get();\n        ///  sharedPtr.reset();\n        ///  pool->Release(rawCPtr);\n        ///\n        ///\n        /// @author S Downie\n        ///\n        /// @param Resource to release\n        //-------------------------------------------------------------------------------------\n        void Release(const Resource* in_resource);\n        //------------------------------------------------------------------------------------\n        /// Called when the system is destroyed after the system lifecycle destroy.\n        /// Flushes the resource caches and errors if any resources are still in use\n        ///\n        /// @author S Downie\n        //------------------------------------------------------------------------------------\n        void Destroy();\n        \n    private:\n        \n        //-------------------------------------------------------------------------------------\n        /// Descriptor that holds the providers and cached resources for a given type\n        ///\n        /// @author S Downie\n        //-------------------------------------------------------------------------------------\n        struct PoolDesc\n        {\n            std::vector<ResourceProvider*> m_providers;\n            std::unordered_map<Resource::ResourceId, ResourceSPtr> m_cachedResources;\n        };\n        //------------------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param File path\n        /// @param Descriptor\n        ///\n        /// @return Resource provider in descriptor that can load file or null\n        //------------------------------------------------------------------------------------\n        ResourceProvider* FindProvider(const std::string& in_filePath, const PoolDesc& in_desc);\n        //------------------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Location\n        /// @param File path\n        /// @param Loading options\n        ///\n        /// @return Unique ID based on the location, path and options\n        //------------------------------------------------------------------------------------\n        Resource::ResourceId GenerateResourceId(StorageLocation in_location, const std::string& in_filePath, const IResourceOptionsBaseCSPtr& in_options) const;\n        //------------------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Unique string ID\n        ///\n        /// @return Unique ID based on the location and path\n        //------------------------------------------------------------------------------------\n        Resource::ResourceId GenerateResourceId(const std::string& in_uniqueId) const;\n        \n    private:\n        \n        std::unordered_map<InterfaceIDType, PoolDesc> m_descriptors;\n        mutable std::mutex m_mutex;\n    };\n    //------------------------------------------------------------------------------------\n    //-------------------------------------------------------------------------------------\n    template <typename TResourceType> std::shared_ptr<const TResourceType> ResourcePool::GetResource(const std::string& in_uniqueId) const\n    {\n        CS_ASSERT(in_uniqueId.empty() == false, \"Cannot find resource with empty unique Id\");\n        \n        std::unique_lock<std::mutex> lock(m_mutex);\n        \n        auto itDescriptor = m_descriptors.find(TResourceType::InterfaceID);\n        \n        if(itDescriptor == m_descriptors.end())\n        {\n            CS_LOG_ERROR(\"Failed to find resource provider for \" + TResourceType::TypeName);\n            return nullptr;\n        }\n        \n        const PoolDesc& desc(itDescriptor->second);\n        \n        //Check descriptor and see if this resource already exists\n        Resource::ResourceId resourceId = GenerateResourceId(in_uniqueId);\n        auto itResource = desc.m_cachedResources.find(resourceId);\n        if(itResource != desc.m_cachedResources.end())\n        {\n            return std::static_pointer_cast<const TResourceType>(itResource->second);\n        }\n        \n        return nullptr;\n    }\n    //------------------------------------------------------------------------------------\n    //-------------------------------------------------------------------------------------\n    template <typename TResourceType> std::vector<std::shared_ptr<const TResourceType>> ResourcePool::GetAllResources() const\n    {\n        std::unique_lock<std::mutex> lock(m_mutex);\n        \n        std::vector<std::shared_ptr<const TResourceType>> output;\n        \n        auto itDescriptor = m_descriptors.find(TResourceType::InterfaceID);\n        if(itDescriptor != m_descriptors.end())\n        {\n            const PoolDesc& desc(itDescriptor->second);\n            for (const auto& resource : desc.m_cachedResources)\n            {\n                output.push_back(std::static_pointer_cast<const TResourceType>(resource.second));\n            }\n        }\n        \n        return output;\n    }\n    //------------------------------------------------------------------------------------\n    //-------------------------------------------------------------------------------------\n    template <typename TResourceType> std::shared_ptr<TResourceType> ResourcePool::CreateResource(const std::string& in_uniqueId)\n    {\n        CS_RELEASE_ASSERT(Application::Get()->GetTaskScheduler()->IsMainThread() == true, \"Resources can only be created on the main thread\");\n        \n        Resource::ResourceId resourceId = GenerateResourceId(in_uniqueId);\n        std::shared_ptr<TResourceType> resource(TResourceType::Create());\n        resource->SetId(resourceId);\n        resource->SetName(in_uniqueId);\n        \n        std::unique_lock<std::mutex> lock(m_mutex);\n        \n        auto itDescriptor = m_descriptors.find(TResourceType::InterfaceID);\n        if(itDescriptor == m_descriptors.end())\n        {\n            PoolDesc desc;\n            desc.m_cachedResources.insert(std::make_pair(resourceId, resource));\n            m_descriptors.insert(std::make_pair(TResourceType::InterfaceID, desc));\n            return resource;\n        }\n        \n        //Check to make sure this doesn't already exist\n        PoolDesc& desc(itDescriptor->second);\n        CS_ASSERT(desc.m_cachedResources.find(resourceId) == desc.m_cachedResources.end(), \"Resource with Id: \" + in_uniqueId + \" already exists\");\n        desc.m_cachedResources.insert(std::make_pair(resourceId, resource));\n        \n        return resource;\n    }\n    //-------------------------------------------------------------------------------------\n    //-------------------------------------------------------------------------------------\n    template <typename TResourceType> std::shared_ptr<const TResourceType> ResourcePool::LoadResource(StorageLocation in_location, const std::string& in_filePath, const IResourceOptionsCSPtr<TResourceType>& in_options)\n    {\n        CS_RELEASE_ASSERT(Application::Get()->GetTaskScheduler()->IsMainThread() == true, \"Resources can only be loaded on the main thread - use LoadResourceAsync\");\n        CS_ASSERT(in_filePath.empty() == false, \"Cannot load resource with no file path\");\n        \n        std::unique_lock<std::mutex> lock(m_mutex);\n        auto itDescriptor = m_descriptors.find(TResourceType::InterfaceID);\n        \n        if(itDescriptor == m_descriptors.end())\n        {\n            CS_LOG_ERROR(\"Failed to find resource provider for \" + TResourceType::TypeName);\n            return nullptr;\n        }\n        \n        PoolDesc& desc(itDescriptor->second);\n        \n        //Find a provider that can load this resource\n        ResourceProvider* provider = FindProvider(in_filePath, desc);\n        if(provider == nullptr)\n        {\n            return nullptr;\n        }\n        lock.unlock();\n        \n        IResourceOptionsBaseCSPtr options(in_options);\n        if(options == nullptr)\n        {\n            options = provider->GetDefaultOptions();\n        }\n        \n        //Check descriptor and see if this resource already exists\n        Resource::ResourceId resourceId = GenerateResourceId(in_location, in_filePath, options);\n        \n        lock.lock();\n        auto itResource = desc.m_cachedResources.find(resourceId);\n        if(itResource != desc.m_cachedResources.end())\n        {\n            return std::static_pointer_cast<TResourceType>(itResource->second);\n        }\n        lock.unlock();\n        \n        //Load the resource\n        ResourceSPtr resource(TResourceType::Create());\n        resource->SetStorageLocation(in_location);\n        resource->SetFilePath(in_filePath);\n        resource->SetName(in_filePath);\n        resource->SetOptions(options);\n        resource->SetId(resourceId);\n\n        std::string deviceFilePath = Application::Get()->GetTaggedFilePathResolver()->ResolveFilePath(in_location, in_filePath);\n        provider->CreateResourceFromFile(in_location, deviceFilePath, options, resource);\n        if(resource->GetLoadState() != Resource::LoadState::k_loaded)\n        {\n            CS_LOG_ERROR(\"Failed to create resource for \" + in_filePath);\n            return nullptr;\n        }\n        \n        lock.lock();\n        //Check the async call hasn't sneaked in here with the same resource\n        itResource = desc.m_cachedResources.find(resourceId);\n        if(itResource == desc.m_cachedResources.end())\n        {\n            desc.m_cachedResources.insert(std::make_pair(resourceId, resource));\n        }\n        else\n        {\n            resource = itResource->second;\n        }\n        lock.unlock();\n        \n        return std::static_pointer_cast<TResourceType>(resource);\n    }\n    //-------------------------------------------------------------------------------------\n    //-------------------------------------------------------------------------------------\n    template <typename TResourceType> std::shared_ptr<const TResourceType> ResourcePool::RefreshResource(StorageLocation in_location, const std::string& in_filePath, const IResourceOptionsCSPtr<TResourceType>& in_options)\n    {\n        CS_RELEASE_ASSERT(Application::Get()->GetTaskScheduler()->IsMainThread() == true, \"Resources can only be refreshed on the main thread\");\n        CS_ASSERT(in_filePath.empty() == false, \"Cannot refresh resource with no file path\");\n        \n        std::unique_lock<std::mutex> lock(m_mutex);\n        auto itDescriptor = m_descriptors.find(TResourceType::InterfaceID);\n        \n        if(itDescriptor == m_descriptors.end())\n        {\n            CS_LOG_ERROR(\"Failed to find resource provider for \" + TResourceType::TypeName);\n            return nullptr;\n        }\n        \n        PoolDesc& desc(itDescriptor->second);\n        \n        //Find a provider that can load this resource\n        ResourceProvider* provider = FindProvider(in_filePath, desc);\n        if(provider == nullptr)\n        {\n            return nullptr;\n        }\n        lock.unlock();\n        \n        IResourceOptionsBaseCSPtr options(in_options);\n        if(options == nullptr)\n        {\n            options = provider->GetDefaultOptions();\n        }\n        \n        //Check descriptor and see if this resource already exists\n        Resource::ResourceId resourceId = GenerateResourceId(in_location, in_filePath, options);\n        \n        lock.lock();\n        auto itResource = desc.m_cachedResources.find(resourceId);\n        if(itResource == desc.m_cachedResources.end())\n        {\n            CS_LOG_ERROR(\"Failed to refresh non-existing resource for \" + in_filePath);\n            return nullptr;\n        }\n        \n        //Load the resource\n        ResourceSPtr resource(itResource->second);\n        \n        lock.unlock();\n        \n        resource->SetLoadState(Resource::LoadState::k_loading);\n        std::string deviceFilePath = Application::Get()->GetTaggedFilePathResolver()->ResolveFilePath(in_location, in_filePath);\n        provider->CreateResourceFromFile(in_location, deviceFilePath, options, resource);\n        if(resource->GetLoadState() != Resource::LoadState::k_loaded)\n        {\n            CS_LOG_ERROR(\"Failed to refresh resource for \" + deviceFilePath);\n            return nullptr;\n        }\n        \n        return std::static_pointer_cast<TResourceType>(resource);\n    }\n    //------------------------------------------------------------------------------------\n    //-------------------------------------------------------------------------------------\n    template <typename TResourceType> void ResourcePool::RefreshResources()\n    {\n        CS_RELEASE_ASSERT(Application::Get()->GetTaskScheduler()->IsMainThread() == true, \"Resources can only be refreshed on the main thread\");\n        \n        std::unique_lock<std::mutex> lock(m_mutex);\n        \n        auto itDescriptor = m_descriptors.find(TResourceType::InterfaceID);\n        \n        if(itDescriptor == m_descriptors.end())\n        {\n            CS_LOG_ERROR(\"Failed to find resource provider for \" + TResourceType::TypeName);\n            return;\n        }\n        \n        PoolDesc& desc(itDescriptor->second);\n        \n        for(auto& resourceEntry : desc.m_cachedResources)\n        {\n            ResourceSPtr& resource(resourceEntry.second);\n            \n            if(resource->GetStorageLocation() != StorageLocation::k_none)\n            {\n                //Find a provider that can load this resource\n                ResourceProvider* provider = FindProvider(resource->GetFilePath(), desc);\n                if(provider == nullptr)\n                {\n                    CS_LOG_ERROR(\"Failed to find resource provider for \" + resource->GetName());\n                    continue;\n                }\n                \n                resource->SetLoadState(Resource::LoadState::k_loading);\n                std::string deviceFilePath = Application::Get()->GetTaggedFilePathResolver()->ResolveFilePath(resource->GetStorageLocation(), resource->GetFilePath());\n                provider->CreateResourceFromFile(resource->GetStorageLocation(), deviceFilePath, resource->GetOptions(), resource);\n                if(resource->GetLoadState() != Resource::LoadState::k_loaded)\n                {\n                    CS_LOG_ERROR(\"Failed to refresh resource for \" + resource->GetName());\n                    continue;\n                }\n            }\n        }\n    }\n    //-------------------------------------------------------------------------------------\n    //-------------------------------------------------------------------------------------\n    template <typename TResourceType> void ResourcePool::LoadResourceAsync(StorageLocation in_location, const std::string& in_filePath, const std::function<void(const std::shared_ptr<const TResourceType>&)>& in_delegate)\n    {\n        LoadResourceAsync(in_location, in_filePath, IResourceOptionsCSPtr<TResourceType>(), in_delegate);\n    }\n    //-------------------------------------------------------------------------------------\n    //-------------------------------------------------------------------------------------\n    template <typename TResourceType> void ResourcePool::LoadResourceAsync(StorageLocation in_location, const std::string& in_filePath, const IResourceOptionsCSPtr<TResourceType>& in_options, const std::function<void(const std::shared_ptr<const TResourceType>&)>& in_delegate)\n    {\n        CS_ASSERT(in_filePath.empty() == false, \"Cannot load resource async with no file path\");\n        CS_ASSERT(in_delegate != nullptr, \"Cannot load resource async with null delegate\");\n        \n        std::unique_lock<std::mutex> lock(m_mutex);\n        auto itDescriptor = m_descriptors.find(TResourceType::InterfaceID);\n        \n        if(itDescriptor == m_descriptors.end())\n        {\n            CS_LOG_ERROR(\"Failed to find resource provider for \" + TResourceType::TypeName);\n            in_delegate(nullptr);\n            return;\n        }\n        \n        PoolDesc& desc(itDescriptor->second);\n        \n        //Find a provider that can load this resource\n        ResourceProvider* provider = FindProvider(in_filePath, desc);\n        if(provider == nullptr)\n        {\n            in_delegate(nullptr);\n            return;\n        }\n        lock.unlock();\n        \n        IResourceOptionsBaseCSPtr options(in_options);\n        if(options == nullptr)\n        {\n            options = provider->GetDefaultOptions();\n        }\n        \n        //Check descriptor and see if this resource already exists\n        Resource::ResourceId resourceId = GenerateResourceId(in_location, in_filePath, options);\n        \n        lock.lock();\n        auto itResource = desc.m_cachedResources.find(resourceId);\n        if(itResource != desc.m_cachedResources.end())\n        {\n            in_delegate(std::static_pointer_cast<const TResourceType>(itResource->second));\n            return;\n        }\n        \n        //Load the resource\n        ResourceSPtr resource(TResourceType::Create());\n        resource->SetStorageLocation(in_location);\n        resource->SetFilePath(in_filePath);\n        resource->SetName(in_filePath);\n        resource->SetOptions(options);\n        resource->SetId(resourceId);\n\n        //Add it to the cache\n        desc.m_cachedResources.insert(std::make_pair(resourceId, resource));\n        lock.unlock();\n        \n        ResourceProvider::AsyncLoadDelegate convertDelegate([=](const ResourceSPtr& in_resource)\n        {\n            in_delegate(std::static_pointer_cast<const TResourceType>(in_resource));\n        });\n\n        std::string deviceFilePath = Application::Get()->GetTaggedFilePathResolver()->ResolveFilePath(in_location, in_filePath);\n        provider->CreateResourceFromFileAsync(in_location, deviceFilePath, options, convertDelegate, resource);\n    }\n    //-------------------------------------------------------------------------------------\n    /// Resources often have references to other resources and therefore multiple release passes\n    /// are required until no more resources are released\n    //-------------------------------------------------------------------------------------\n    template <typename TResourceType> void ResourcePool::ReleaseUnused()\n    {\n        CS_RELEASE_ASSERT(Application::Get()->GetTaskScheduler()->IsMainThread() == true, \"Resources can only be released on the main thread\");\n        \n        std::unique_lock<std::mutex> lock(m_mutex);\n        //Find the descriptor that handles this type of resource\n        auto itDescriptor = m_descriptors.find(TResourceType::InterfaceID);\n        CS_ASSERT(itDescriptor != m_descriptors.end(), \"Failed to find resource provider for \" + TResourceType::TypeName);\n\n        auto& cachedResources(itDescriptor->second.m_cachedResources);\n        \n        u32 numReleased = 0;\n        \n        do\n        {\n            numReleased = 0;\n            \n            for(auto itResource = cachedResources.begin(); itResource != cachedResources.end(); /*NO INCREMENT*/)\n            {\n                if(itResource->second.use_count() == 1)\n                {\n                    //The pool is the sole owner so we can safely release the object\n                    CS_LOG_VERBOSE(\"Releasing resource from pool \" + itResource->second->GetName());\n                    itResource = cachedResources.erase(itResource);\n                    numReleased++;\n                }\n                else\n                {\n                    ++itResource;\n                }\n            }\n        }\n        while(numReleased > 0);\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Resource/ResourceProvider.cpp",
    "content": "//\n//  ResourceProvider.cpp\n//  ChilliSource\n//  Created by Scott Downie on 30/09/2010.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2010 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Core/Resource/ResourceProvider.h>\n\nnamespace ChilliSource\n{\n    CS_DEFINE_NAMEDTYPE(ResourceProvider);\n    \n    //----------------------------------------------------\n    //----------------------------------------------------\n    IResourceOptionsBaseCSPtr ResourceProvider::GetDefaultOptions() const\n    {\n        return nullptr;\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Core/Resource/ResourceProvider.h",
    "content": "//\n//  ResourceProvider.h\n//  ChilliSource\n//  Created by Scott Downie on 30/09/2010.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2010 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_RESOURCE_RESOURCEPROVIDER_H_\n#define _CHILLISOURCE_CORE_RESOURCE_RESOURCEPROVIDER_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/File/StorageLocation.h>\n#include <ChilliSource/Core/System/AppSystem.h>\n\n#include <functional>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------\n    /// ResourceProviderOld defines an interface for systems which\n    /// produce resource objects from files.\n    ///\n    /// @author S Downie\n    //------------------------------------------------------------\n    class ResourceProvider : public AppSystem\n    {\n    public:\n        \n        //----------------------------------------------------\n        /// Delegate called from async load methods when the\n        /// load finishes. Check the load state of the resource\n        /// for success or failure\n        ///\n        /// @author S Downie\n        ///\n        /// @param Resource\n        //----------------------------------------------------\n        using AsyncLoadDelegate = std::function<void(const std::shared_ptr<Resource>&)>;\n        \n        CS_DECLARE_NAMEDTYPE(ResourceProvider);\n        //----------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return The resource type this provider can create\n        //----------------------------------------------------\n        virtual InterfaceIDType GetResourceType() const = 0;\n        //----------------------------------------------------\n        /// Allows querying of the resource type this provider\n        /// can create.\n        ///\n        /// @author S Downie\n        ///\n        /// @param The extension of the resource file.\n        ///\n        /// @return Whether or not the resource can be created.\n        //----------------------------------------------------\n        virtual bool CanCreateResourceWithFileExtension(const std::string& in_extension) const = 0;\n        //----------------------------------------------------\n        /// Creates a new resource from file.\n        ///\n        /// @author S Downie\n        ///\n        /// @param The storage location.\n        /// @param The filepath.\n        /// @param Options to customise the creation\n        /// @param Delegate to callback on completion either success or failure\n        /// @param [Out] The output resource.\n        //----------------------------------------------------\n        virtual void CreateResourceFromFile(StorageLocation in_storageLocation, const std::string& in_filePath, const IResourceOptionsBaseCSPtr& in_options, const ResourceSPtr& out_resource) = 0;\n        //----------------------------------------------------\n        /// Creates a new resource from file asynchronously.\n        /// Check the load state on the resource for success\n        /// or failure\n        ///\n        /// @author S Downie\n        ///\n        /// @param The storage location.\n        /// @param The filepath.\n        /// @param Options to customise the creation\n        /// @param Completion delegate\n        /// @param [Out] The output resource.\n        //----------------------------------------------------\n        virtual void CreateResourceFromFileAsync(StorageLocation in_storageLocation, const std::string& in_filePath, const IResourceOptionsBaseCSPtr& in_options, const AsyncLoadDelegate& in_delegate, const ResourceSPtr& out_resource) = 0;\n        //----------------------------------------------------\n        /// Options can be used to customise the loading\n        /// of resources. Not all resource will require\n        /// custom options so this function will return null.\n        ///\n        /// Default options are required for resources\n        /// that use options in order to make options optional\n        /// but ensure resource pool cache is correct\n        ///\n        /// @author S Downie\n        ///\n        /// @retrun Default options (null)\n        //----------------------------------------------------\n        virtual IResourceOptionsBaseCSPtr GetDefaultOptions() const;\n        //----------------------------------------------------\n        /// Destructor.\n        ///\n        /// @author S Downie\n        //----------------------------------------------------\n        virtual ~ResourceProvider() {}\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Resource.h",
    "content": "//\n//  Resource.h\n//  ChilliSource\n//  Created by Ian Copland on 07/07/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_RESOURCE_H_\n#define _CHILLISOURCE_CORE_RESOURCE_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Resource/IResourceOptions.h>\n#include <ChilliSource/Core/Resource/Resource.h>\n#include <ChilliSource/Core/Resource/ResourcePool.h>\n#include <ChilliSource/Core/Resource/ResourceProvider.h>\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Scene/Scene.cpp",
    "content": "//\n//  Scene.cpp\n//  Chilli Source\n//  Created by Scott Downie on 21/09/2010.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2010 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Core/Scene/Scene.h>\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Rendering/Target/TargetGroup.h>\n\n#include <algorithm>\n\nnamespace ChilliSource\n{\n    CS_DEFINE_NAMEDTYPE(Scene);\n    \n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    SceneUPtr Scene::Create(TargetGroupUPtr renderTarget) noexcept\n    {\n        return SceneUPtr(new Scene(std::move(renderTarget)));\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    Scene::Scene(TargetGroupUPtr renderTarget) noexcept\n    : m_renderTarget(std::move(renderTarget))\n    {\n        m_clearColour = ChilliSource::Colour::k_black;\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    bool Scene::IsA(InterfaceIDType in_interfaceId) const\n    {\n        return Scene::InterfaceID == in_interfaceId;\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    void Scene::ResumeEntities()\n    {\n        CS_ASSERT(m_entitiesActive == false, \"Received resume entities event while entities are already active.\")\n        m_entitiesActive = true;\n        \n        for(u32 i = 0; i < m_entities.size(); ++i)\n        {\n            m_entities[i]->OnResume();\n        }\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    void Scene::ForegroundEntities()\n    {\n        CS_ASSERT(m_entitiesForegrounded == false, \"Received foreground entities event while entities are already foregrounded.\")\n        m_entitiesForegrounded = true;\n        \n        for(u32 i = 0; i<m_entities.size(); ++i)\n        {\n            m_entities[i]->OnForeground();\n        }\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    void Scene::UpdateEntities(f32 in_timeSinceLastUpdate)\n    {\n        if(m_enabled)\n        {\n            for(u32 i = 0; i < m_entities.size(); ++i)\n            {\n                m_entities[i]->OnUpdate(in_timeSinceLastUpdate);\n            }\n        }\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    void Scene::FixedUpdateEntities(f32 in_fixedTimeSinceLastUpdate)\n    {\n        if(m_enabled)\n        {\n            for(u32 i=0; i<m_entities.size(); ++i)\n            {\n                m_entities[i]->OnFixedUpdate(in_fixedTimeSinceLastUpdate);\n            }\n        }\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    void Scene::RenderSnapshotEntities(RenderSnapshot& renderSnapshot, IAllocator* frameAllocator) noexcept\n    {\n        for(u32 i=0; i<m_entities.size(); ++i)\n        {\n            m_entities[i]->OnRenderSnapshot(renderSnapshot, frameAllocator);\n        }\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    void Scene::BackgroundEntities()\n    {\n        CS_ASSERT(m_entitiesForegrounded == true, \"Received background entities event while entities are already backgrounded.\")\n        m_entitiesForegrounded = false;\n        \n        for (auto it = m_entities.rbegin(); it != m_entities.rend(); ++it)\n        {\n            (*it)->OnBackground();\n        }\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    void Scene::SuspendEntities()\n    {\n        CS_ASSERT(m_entitiesActive == true, \"Received suspend entities event while entities are already suspended.\")\n        m_entitiesActive = false;\n        \n        for (auto it = m_entities.rbegin(); it != m_entities.rend(); ++it)\n        {\n            (*it)->OnSuspend();\n        }\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    void Scene::Add(const EntitySPtr& in_entity)\n    {\n        CS_ASSERT(in_entity != nullptr, \"Cannot add a null entity\");\n        CS_ASSERT(in_entity->GetScene() == nullptr, \"Cannot add an entity with pre-exisitng scene\");\n        CS_ASSERT((in_entity->GetParent() == nullptr || in_entity->GetParent()->GetScene() == this), \"Cannot add an entity to a different scene than its parent.\");\n        CS_ASSERT(m_entities.size() < static_cast<std::vector<EntitySPtr>::size_type>(std::numeric_limits<u32>::max()), \"There are too many entities in the scene. It cannot exceed \"\n                  + ToString(std::numeric_limits<u32>::max()) + \".\");\n        \n        m_entities.push_back(in_entity);\n\n        in_entity->SetScene(this);\n        in_entity->OnAddedToScene();\n        \n        if (m_entitiesActive == true)\n        {\n            in_entity->OnResume();\n            if (m_entitiesForegrounded == true)\n            {\n                in_entity->OnForeground();\n            }\n        }\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    void Scene::RemoveAllEntities()\n    {\n        for(u32 i=0; i<m_entities.size(); ++i)\n        {\n            Entity* ent = m_entities[i].get();\n            \n            if (ent->GetParent() == nullptr)\n            {\n                if (m_entitiesActive == true)\n                {\n                    if (m_entitiesForegrounded == true)\n                    {\n                        ent->OnBackground();\n                    }\n                    ent->OnSuspend();\n                }\n                \n                ent->OnRemovedFromScene();\n                ent->SetScene(nullptr);\n            }\n        }\n        \n        m_entities.clear();\n    }\n    \n    //------------------------------------------------------------------------------\n    void Scene::Render(TargetGroup* target) noexcept\n    {\n        CS_ASSERT(target != nullptr || m_renderTarget != nullptr, \"Cannot force render the main scene\");\n        \n        Application::Get()->RenderScene(this, target);\n    }\n    \n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    const SharedEntityList& Scene::GetEntities() const\n    {\n        return m_entities;\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    void Scene::SetClearColour(const Colour& in_colour)\n    {\n        m_clearColour = in_colour;\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    const Colour& Scene::GetClearColour() const\n    {\n        return m_clearColour;\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    void Scene::SetActiveCamera(CameraComponent* in_cameraComponent) noexcept\n    {\n        CS_ASSERT(!in_cameraComponent != !m_activeCameraComponent, \"A camera component cannot be activated while another is active, nor can it be deactived if there isn't currently one active.\");\n        \n        m_activeCameraComponent = in_cameraComponent;\n    }\n    //--------------------------------------------------------------------------------------------------\n    //--------------------------------------------------------------------------------------------------\n    void Scene::QuerySceneForIntersection(const Ray &in_ray, std::vector<VolumeComponent*>& out_volumeComponents)\n    {\n        std::vector<VolumeComponent*> intersectableComponents;\n        QuerySceneForComponents(intersectableComponents);\n        \n        //Loop through the render components and check for intersection\n        //If any intersect then add them to the intersect list\n        for(std::vector<VolumeComponent*>::iterator it = intersectableComponents.begin(); it != intersectableComponents.end(); ++it)\n        {\n            VolumeComponent* component = (*it);\n            \n            f32 nearIntersection, farIntersection = 0.0f;\n            \n            if(component->GetOOBB().Contains(in_ray, nearIntersection, farIntersection))\n            {\n                //We use this to sort by\n                component->mfQueryIntersectionValue = nearIntersection;\n                out_volumeComponents.push_back(component);\n            }\n        }\n    }\n    //--------------------------------------------------------------------------------------------------\n    //--------------------------------------------------------------------------------------------------\n    void Scene::Remove(Entity* in_entity)\n    {\n        CS_ASSERT(in_entity != nullptr, \"Cannot remove a null entity\");\n        CS_ASSERT(in_entity->GetScene() == this, \"Cannot add an entity without a pre-exisitng scene\");\n        CS_ASSERT((in_entity->GetParent() == nullptr || in_entity->GetParent()->GetScene() == this), \"Cannot remove an entity from a different scene than it's parent.\");\n        \n        auto searchPredicate = [in_entity](const EntitySPtr& in_entityInList)\n        {\n            return in_entityInList.get() == in_entity;\n        };\n        \n        auto it = std::find_if(m_entities.begin(), m_entities.end(), searchPredicate);\n        \n        if(it != m_entities.end())\n        {\n            if (m_entitiesActive == true)\n            {\n                if (m_entitiesForegrounded == true)\n                {\n                    in_entity->OnBackground();\n                }\n                in_entity->OnSuspend();\n            }\n            \n            in_entity->OnRemovedFromScene();\n            in_entity->SetScene(nullptr);\n            \n            //the iterator may have been invalidated during OnBackground, OnSuspend or OnRemovedFromScene, so re-calculate it\n            it = std::find_if(m_entities.begin(), m_entities.end(), searchPredicate);\n            \n            it->swap(m_entities.back());\n            m_entities.pop_back();\n        }\n    }\n    //--------------------------------------------------------------------------------------------------\n    //--------------------------------------------------------------------------------------------------\n    void Scene::OnDestroy() noexcept\n    {\n        m_renderTarget.reset();\n    }\n    //--------------------------------------------------------------------------------------------------\n    //--------------------------------------------------------------------------------------------------\n    Scene::~Scene()\n    {\n        RemoveAllEntities();\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Core/Scene/Scene.h",
    "content": "//\n//  Scene.h\n//  ChilliSource\n//  Created by Scott Downie on 21/09/2010.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2010 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_SCENE_SCENE_H_\n#define _CHILLISOURCE_CORE_SCENE_SCENE_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Base/Colour.h>\n#include <ChilliSource/Core/Entity/Entity.h>\n#include <ChilliSource/Core/Math/Geometry/Shapes.h>\n#include <ChilliSource/Core/System/StateSystem.h>\n#include <ChilliSource/Core/Volume/VolumeComponent.h>\n#include <ChilliSource/Rendering/Target/TargetGroup.h>\n\nnamespace ChilliSource\n{\n    //--------------------------------------------------------------------------------------------------\n    /// Holds the entities that form the scene. Entities will be updated from the scene and the\n    /// scene is queried by other systems for render components etc.\n    ///\n    /// @author S Downie\n    //--------------------------------------------------------------------------------------------------\n    class Scene final : public StateSystem\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(Scene);\n        //-------------------------------------------------------\n        /// Factory method\n        ///\n        /// @author S Downie\n        ///\n        /// @param renderTarget\n        ///     The target into which the scene renders, if null renders to screen\n        //-------------------------------------------------------\n        static SceneUPtr Create(TargetGroupUPtr renderTarget) noexcept;\n        \n        //-------------------------------------------------------\n        /// Destructor\n        ///\n        /// @author S Downie\n        //-------------------------------------------------------\n        ~Scene();\n        //-------------------------------------------------------\n        /// Query interface to determine if the object implements\n        /// the interface with the given ID\n        ///\n        /// @author S Downie\n        ///\n        /// @param Interface ID\n        ///\n        /// @return Whether the system has the given interface\n        //-------------------------------------------------------\n        bool IsA(InterfaceIDType in_interfaceId) const override;\n        \n        /// Enable/Disable updating and rendering on the scene\n        ///\n        /// @param enabled\n        ///     True if enabling, False if disabling\n        ///\n        void SetEnabled(bool enabled) noexcept { m_enabled = enabled; }\n        \n        /// @return TRUE if the scene is updating and rendering\n        ///\n        bool IsEnabled() const noexcept { return m_enabled; }\n        \n        //-------------------------------------------------------\n        /// Add an entity to the scene. This entity cannot\n        /// exist on another scene prior to adding. The entity\n        /// will now be updated from the scene\n        ///\n        /// @author S Downie\n        ///\n        /// @param Entity\n        //-------------------------------------------------------\n        void Add(const EntitySPtr& in_entity);\n        //-------------------------------------------------------\n        /// Remove all the entities from the scene\n        ///\n        /// @author S Downie\n        //-------------------------------------------------------\n        void RemoveAllEntities();\n        //-------------------------------------------------------\n        /// @author A Mackie\n        ///\n        /// @return the list of all the entities in the scene.\n        //-------------------------------------------------------\n        const SharedEntityList& GetEntities() const;\n        //------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Screen clear colour\n        //------------------------------------------------------\n        void SetClearColour(const Colour& in_colour);\n        //------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Screen clear colour\n        //------------------------------------------------------\n        const Colour& GetClearColour() const;\n        //------------------------------------------------------\n        /// Sets the active camera in the scene. This should be\n        /// set by CameraComponent during OnAddedToScene() and\n        /// OnRemovedFromScene() to ensure the scene is always\n        /// aware of the current camera.\n        ///\n        /// If a second camera is set while another is active\n        /// this will assert.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param in_cameraComponent - The camera component\n        /// that should become active. Null should be passed to\n        /// deactivate a camera.\n        //------------------------------------------------------\n        void SetActiveCamera(CameraComponent* in_cameraComponent) noexcept;\n        //------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The active camera in this scene, or null if\n        /// there isn't one.\n        //------------------------------------------------------\n        CameraComponent* GetActiveCamera() const noexcept { return m_activeCameraComponent; }\n        //------------------------------------------------------\n        /// @return The render target, if nullptr then renders to screen\n        //------------------------------------------------------\n        TargetGroup* GetRenderTarget() const noexcept { return m_renderTarget.get(); }\n        //-------------------------------------------------------\n        /// Sends the resume event on to the entities.\n        ///\n        /// @author S Downie\n        //-------------------------------------------------------\n        void ResumeEntities();\n        //-------------------------------------------------------\n        /// Sends the foreground event on to the entities.\n        ///\n        /// @author Ian Copland\n        //-------------------------------------------------------\n        void ForegroundEntities();\n        //-------------------------------------------------------\n        /// Updates all entities.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param Time since last update in seconds.\n        //-------------------------------------------------------\n        void UpdateEntities(f32 in_timeSinceLastUpdate);\n        //-------------------------------------------------------\n        /// Fixed updates all entities.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param Time since last update in seconds.\n        //-------------------------------------------------------\n        void FixedUpdateEntities(f32 in_timeSinceLastUpdate);\n        //-------------------------------------------------------\n        /// Sends the render snapshot event to all entities in\n        /// the scene.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param renderSnapshot - The render snapshot object\n        /// which contains all snapshotted data.\n        /// @param frameAllocator - Allocate any render frame data\n        /// from here\n        //-------------------------------------------------------\n        void RenderSnapshotEntities(RenderSnapshot& renderSnapshot, IAllocator* frameAllocator) noexcept;\n        //-------------------------------------------------------\n        /// Sends the background event on to the entities.\n        ///\n        /// @author Ian Copland\n        //-------------------------------------------------------\n        void BackgroundEntities();\n        //-------------------------------------------------------\n        /// Sends the suspend event on to the entities.\n        ///\n        /// @author Ian Copland\n        //-------------------------------------------------------\n        void SuspendEntities();\n        \n        /// Takes a snapshot of the scene and renders it to its\n        /// render target during the render stage of the application.\n        ///\n        /// Should only be called directly by app if performing single shot RTT on a disabled scene\n        ///\n        /// NOTE: The texture of the target will not be populated until next frame.\n        ///\n        /// @param scene\n        ///     Scene that should be rendered\n        /// @param target\n        ///     Optional, if wanting to render the scene to a target other than its own\n        ///\n        void Render(TargetGroup* target = nullptr) noexcept;\n        \n        //--------------------------------------------------------------------------------------------------\n        /// Traverses the contents of the scene and adds any objects that intersect with the ray to the\n        /// list. The list order is undefined. Use the query intersection value on the volume component\n        /// to sort by depth\n        ///\n        /// @author S Downie\n        ///\n        /// @param Ray to check intersection\n        /// @param [Out] Container to fill with intersecting components\n        //--------------------------------------------------------------------------------------------------\n        void QuerySceneForIntersection(const Ray &in_ray, std::vector<VolumeComponent*>& out_volumeComponents);\n        //--------------------------------------------------------------------------------------------------\n        /// Traverse the scene for the given component type and fill the list with those components\n        ///\n        /// @author S Downie\n        ///\n        /// @param [Out] Empty container to be filled\n        //--------------------------------------------------------------------------------------------------\n        template <typename TComponentType>\n        void QuerySceneForComponents(std::vector<TComponentType*>& out_components)\n        {\n            for(SharedEntityList::const_iterator it = m_entities.begin(); it != m_entities.end(); ++it)\n            {\n                (*it)->GetComponents<TComponentType>(out_components);\n            }\n        }\n        //--------------------------------------------------------------------------------------------------\n        /// Traverse the scene for the given component types and fill the lists with those components\n        //\n        /// @author S Downie\n        ///\n        /// @param [Out] Empty container to be filled with T1\n        /// @param [Out] Empty container to be filled with T2\n        //--------------------------------------------------------------------------------------------------\n        template <typename TComponentType1, typename TComponentType2>\n        void QuerySceneForComponents(std::vector<TComponentType1*>& out_components1, std::vector<TComponentType2*>& out_components2)\n        {\n            for(SharedEntityList::const_iterator it = m_entities.begin(); it != m_entities.end(); ++it)\n            {\n                (*it)->GetComponents<TComponentType1, TComponentType2>(out_components1, out_components2);\n            }\n        }\n        //--------------------------------------------------------------------------------------------------\n        /// Traverse the scene for the given component types and fill the lists with those components\n        ///\n        /// @author S Downie\n        ///\n        /// @param [Out] Empty container to be filled with T1\n        /// @param [Out] Empty container to be filled with T2\n        /// @param [Out] Empty container to be filled with T3\n        //--------------------------------------------------------------------------------------------------\n        template <typename TComponentType1, typename TComponentType2, typename TComponentType3>\n        void QuerySceneForComponents(std::vector<TComponentType1*>& out_components1, std::vector<TComponentType2*>& out_components2, std::vector<TComponentType3*>& out_components3)\n        {\n            for(SharedEntityList::const_iterator it = m_entities.begin(); it != m_entities.end(); ++it)\n            {\n                (*it)->GetComponents<TComponentType1, TComponentType2, TComponentType3>(out_components1, out_components2, out_components3);\n            }\n        }\n        \n    private:\n        friend class Entity;\n        \n        //-------------------------------------------------------\n        /// Private to enforce use of factory method\n        ///\n        /// @author S Downie\n        ///\n        /// @param renderTarget\n        ///     The target into which the scene renders, if null renders to screen\n        //-------------------------------------------------------\n        Scene(TargetGroupUPtr renderTarget) noexcept;\n        //-------------------------------------------------------\n        /// Remove the entity from the scene\n        ///\n        /// @author S Downie\n        ///\n        /// @param Entity\n        //-------------------------------------------------------\n        void Remove(Entity* inpEntity);\n        \n        //------------------------------------------------\n        /// Called when the owning state is being destroyed.\n        /// Used to release held objects\n        ///\n        /// @author S Downie\n        //------------------------------------------------\n        void OnDestroy() noexcept override;\n        \n    private:\n        \n        SharedEntityList m_entities;\n        Colour m_clearColour;\n        bool m_entitiesActive = false;\n        bool m_entitiesForegrounded = false;\n        bool m_enabled = true;\n        CameraComponent* m_activeCameraComponent = nullptr;\n        TargetGroupUPtr m_renderTarget;\n    };\t\t\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Scene.h",
    "content": "//\n//  Scene.h\n//  ChilliSource\n//  Created by Ian Copland on 07/07/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_SCENE_H_\n#define _CHILLISOURCE_CORE_SCENE_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Scene/Scene.h>\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/State/State.cpp",
    "content": "//\n//  State.cpp\n//  ChilliSource\n//  Created by Scott Downie on 21/09/2010.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2010 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Core/State/State.h>\n\n#include <ChilliSource/Core/Scene/Scene.h>\n#include <ChilliSource/Core/State/StateManager.h>\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Input/Gesture/GestureSystem.h>\n#include <ChilliSource/Rendering/Base/TargetType.h>\n#include <ChilliSource/Rendering/Target/TargetGroup.h>\n#include <ChilliSource/UI/Base/Canvas.h>\n\nnamespace ChilliSource\n{\n    //-----------------------------------------\n    //-----------------------------------------\n    void State::Init()\n    {\n        m_canAddSystems = true;\n        \n        //Create the default systems and main scene\n        CreateSystem<Scene>(nullptr);\n        m_canvas = CreateSystem<Canvas>();\n        CreateSystem<GestureSystem>();\n        \n        //create user systems.\n        CreateSystems();\n        \n        m_canAddSystems = false;\n        \n        for(auto& system : m_systems)\n        {\n           if(system->IsA<Scene>())\n           {\n               m_scenes.push_back(static_cast<Scene*>(system.get()));\n           }\n        }\n        \n        for(auto& system : m_systems)\n        {\n            system->OnInit();\n        }\n        \n        OnInit();\n    }\n    //-----------------------------------------\n    //-----------------------------------------\n    void State::Resume()\n    {\n        for(auto& system : m_systems)\n        {\n            system->OnResume();\n        }\n        \n        for(auto scene : m_scenes)\n        {\n            scene->ResumeEntities();\n        }\n        \n        OnResume();\n    }\n    //-----------------------------------------\n    //-----------------------------------------\n    void State::Foreground()\n    {\n        for(auto& system : m_systems)\n        {\n            system->OnForeground();\n        }\n        \n        for(auto scene : m_scenes)\n        {\n            scene->ForegroundEntities();\n        }\n        \n        OnForeground();\n    }\n    //-----------------------------------------\n    //-----------------------------------------\n    void State::Update(f32 in_timeSinceLastUpdate)\n    {\n        for(auto& system : m_systems)\n        {\n            system->OnUpdate(in_timeSinceLastUpdate);\n        }\n        \n        for(auto scene : m_scenes)\n        {\n            scene->UpdateEntities(in_timeSinceLastUpdate);\n        }\n        \n        OnUpdate(in_timeSinceLastUpdate);\n    }\n    //-----------------------------------------\n    //-----------------------------------------\n    void State::FixedUpdate(f32 in_fixedTimeSinceLastUpdate)\n    {\n        for(auto& system : m_systems)\n        {\n            system->OnFixedUpdate(in_fixedTimeSinceLastUpdate);\n        }\n        \n        for(auto scene : m_scenes)\n        {\n            scene->FixedUpdateEntities(in_fixedTimeSinceLastUpdate);\n        }\n        \n        OnFixedUpdate(in_fixedTimeSinceLastUpdate);\n    }\n    //-----------------------------------------\n    //-----------------------------------------\n    void State::RenderSnapshot(TargetType targetType, class RenderSnapshot& renderSnapshot, IAllocator* frameAllocator) noexcept\n    {\n        for(auto& system : m_systems)\n        {\n            system->OnRenderSnapshot(targetType, renderSnapshot, frameAllocator);\n        }\n        \n        OnRenderSnapshot(targetType, renderSnapshot, frameAllocator);\n    }\n    //-----------------------------------------\n    //-----------------------------------------\n    void State::Background()\n    {\n        OnBackground();\n        \n        for (auto it = m_scenes.rbegin(); it != m_scenes.rend(); ++it)\n        {\n            (*it)->BackgroundEntities();\n        }\n        \n        for (auto it = m_systems.rbegin(); it != m_systems.rend(); ++it)\n        {\n            (*it)->OnBackground();\n        }\n    }\n    //-----------------------------------------\n    //-----------------------------------------\n    void State::Suspend()\n    {\n        OnSuspend();\n        \n        for (auto it = m_scenes.rbegin(); it != m_scenes.rend(); ++it)\n        {\n            (*it)->SuspendEntities();\n        }\n        \n        for(auto it = m_systems.rbegin(); it != m_systems.rend(); ++it)\n        {\n            (*it)->OnSuspend();\n        }\n    }\n    //-----------------------------------------\n    //-----------------------------------------\n    void State::Destroy()\n    {\n        OnDestroy();\n        \n        for (auto it = m_scenes.rbegin(); it != m_scenes.rend(); ++it)\n        {\n            (*it)->RemoveAllEntities();\n        }\n        \n        for(auto it = m_systems.rbegin(); it != m_systems.rend(); ++it)\n        {\n            (*it)->OnDestroy();\n        }\n    }\n    //------------------------------------------------\n    //------------------------------------------------\n    void State::MemoryWarning()\n    {\n        for(auto& system : m_systems)\n        {\n            system->OnMemoryWarning();\n        }\n    }\n    //------------------------------------------\n    //------------------------------------------\n    Scene* State::GetMainScene() noexcept\n    {\n        return m_scenes[0];\n    }\n    //------------------------------------------\n    //------------------------------------------\n    const Scene* State::GetMainScene() const noexcept\n    {\n        return m_scenes[0];\n    }\n    //------------------------------------------\n    //------------------------------------------\n    Canvas* State::GetUICanvas()\n    {\n        return m_canvas;\n    }\n    //------------------------------------------\n    //------------------------------------------\n    const Canvas* State::GetUICanvas() const\n    {\n        return m_canvas;\n    }\n    //------------------------------------------\n    //------------------------------------------\n    bool State::IsActiveState() const \n    { \n        return Application::Get()->GetStateManager()->GetActiveState().get() == this;\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Core/State/State.h",
    "content": "//\n//  State.h\n//  ChilliSource\n//  Created by Scott Downie on 21/09/2010.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2010 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_STATE_STATE_H_\n#define _CHILLISOURCE_CORE_STATE_STATE_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/System/StateSystem.h>\n\n#include <vector>\n\nnamespace ChilliSource\n{\n    //----------------------------------------------------------------------\n    /// Manages the lifecycle of a user defined state. A state has its own\n    /// scene that is rendered while the state is at the top of the stack.\n    ///\n    /// Applications should inherit from states and override the lifecycle\n    /// delegates to load/display resources and manage game logic.\n    ///\n    /// States also have state systems thats lifecycles are governed by\n    /// the state.\n    ///\n    /// @author S Downie\n    //----------------------------------------------------------------------\n    class State\n    {\n    public:\n        CS_DECLARE_NOCOPY(State);\n        //----------------------------------------------------\n        /// Constructor\n        ///\n        /// @author S Downie\n        //----------------------------------------------------\n        State() = default;\n        //----------------------------------------------------\n        /// Destructor\n        ///\n        /// @author S Downie\n        //----------------------------------------------------\n        virtual ~State(){}\n        //----------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return A pointer to the main scene (that renders to screen).\n        //----------------------------------------------------\n        Scene* GetMainScene() noexcept;\n        //----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return A const pointer to the main scene (that renders to screen).\n        //----------------------------------------------------\n        const Scene* GetMainScene() const noexcept;\n        //----------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return List of pointers to the scenes (main and offscreen).\n        //----------------------------------------------------\n        const std::vector<Scene*>& GetScenes() const noexcept { return m_scenes; }\n        //----------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return A pointer to the UI canvas\n        //----------------------------------------------------\n        Canvas* GetUICanvas();\n        //----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return A const pointer to the UI canvas.\n        //----------------------------------------------------\n        const Canvas* GetUICanvas() const;\n        //----------------------------------------------------\n        /// Searches the state systems and returns the first\n        /// one that implements the named interface\n        ///\n        /// @author S Downie\n        ///\n        /// @return A pointer to the system of type TNamedType\n        //----------------------------------------------------\n        template <typename TNamedType> TNamedType* GetSystem();\n        //----------------------------------------------------\n        /// Searches the state systems and returns the first\n        /// one that implements the named interface\n        ///\n        /// @author Ian Copland\n        ///\n        /// @return A const pointer to the system of type\n        /// TNamedType\n        //----------------------------------------------------\n        template <typename TNamedType> const TNamedType* GetSystem() const;\n        //----------------------------------------------------\n        /// Searches the state systems and returns all systems\n        /// that implements the named interface\n        ///\n        /// @author HMcLaughlin\n        ///\n        /// @return A vector of pointers to the systems of type\n        /// TNamedType\n        //----------------------------------------------------\n        template <typename TNamedType> std::vector<TNamedType*> GetSystems();\n        //----------------------------------------------------\n        /// Searches the state systems and returns all systems\n        /// that implements the named interface\n        ///\n        /// @author Ian Copland\n        ///\n        /// @return A vector of const pointers to the systems\n        /// of type TNamedType\n        //----------------------------------------------------\n        template <typename TNamedType> std::vector<const TNamedType*> GetSystems() const;\n        //----------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Whether the state is the top of the\n        /// hierarchy\n        //----------------------------------------------------\n        bool IsActiveState() const;\n        \n    protected:\n        \n        //----------------------------------------------------\n        /// Factory method that ensures systems are created\n        /// and added at the same time to prevent ordering\n        /// issues\n        ///\n        /// @author S Downie\n        ///\n        /// @param System creation arguments\n        ///\n        /// @return New system owned by state\n        //----------------------------------------------------\n        template <typename TSystem, typename... TArgs> TSystem* CreateSystem(TArgs&&... in_args);\n        \n    private:\n\n        //-----------------------------------------\n        /// Triggered whenever a state is added\n        /// to the state manager.\n        ///\n        /// (Pairs with Destroy)\n        ///\n        /// @author S Downie\n        //-----------------------------------------\n        void Init();\n        //-----------------------------------------\n        /// Triggered when a state is the\n        /// active state in the state manager and\n        /// the application/state resumes.\n        ///\n        /// (Pairs with Suspend)\n        ///\n        /// @author S Downie\n        //-----------------------------------------\n        void Resume();\n        //-----------------------------------------\n        /// Triggered when a state is the\n        /// active state in the state manager and\n        /// the application becomes the foreground\n        /// app.\n        ///\n        /// (Pairs with Background)\n        ///\n        /// @author S Downie\n        //-----------------------------------------\n        void Foreground();\n        //-----------------------------------------\n        /// Triggered each update loop while the\n        /// state is the active state.\n        ///\n        /// @author S Downie\n        ///\n        /// @param Time since last update (Secs)\n        //-----------------------------------------\n        void Update(f32 in_timeSinceLastUpdate);\n        //-----------------------------------------\n        /// Triggered each update loop at a fixed\n        /// interval while the state is the active\n        /// state.\n        ///\n        /// @author S Downie\n        ///\n        /// @param Fixed time since last update (Secs)\n        //-----------------------------------------\n        void FixedUpdate(f32 in_fixedTimeSinceLastUpdate);\n        //-----------------------------------------\n        /// Sends the render snapshot event onto\n        /// the state, all state systems and any\n        /// entities currently in the scene.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param targetType - Whether the snapshot is\n        /// for the main screen or an offscreen target\n        /// @param renderSnapshot - The render\n        /// snapshot object which contains all\n        /// snapshotted data.\n        /// @param frameAllocator - Allocate\n        /// any data required for rendering this frame\n        /// from here\n        //-----------------------------------------\n        void RenderSnapshot(TargetType targetType, RenderSnapshot& renderSnapshot, IAllocator* frameAllocator) noexcept;\n        //-----------------------------------------\n        /// Triggered when a state is the\n        /// active state in the state manager and\n        /// the application is no longer at the\n        /// foreground.\n        ///\n        /// (Pairs with OnForeground)\n        ///\n        /// @author S Downie\n        //-----------------------------------------\n        void Background();\n        //-----------------------------------------\n        /// Triggered when a state is the\n        /// active state in the state manager and\n        /// the application/state suspends.\n        ///\n        /// (Pairs with OnResume)\n        ///\n        /// @author S Downie\n        //-----------------------------------------\n        void Suspend();\n        //-----------------------------------------\n        /// Triggered whenever a state is removed\n        /// from the state manager.\n        ///\n        /// (Pairs with Init)\n        ///\n        /// @author S Downie\n        //-----------------------------------------\n        void Destroy();\n        //------------------------------------------------\n        /// Called when the application receives a memory\n        /// warning. This is filtered to all states\n        ///\n        /// @author S Downie\n        //------------------------------------------------\n        void MemoryWarning();\n        //------------------------------------------------------\n        /// The users state should override this to add\n        /// desired systems. Systems can only be added in this\n        /// method.\n        ///\n        /// @author S Downie\n        //------------------------------------------------------\n        virtual void CreateSystems(){};\n        //-----------------------------------------\n        /// Triggered whenever a state is added\n        /// to the state manager.\n        ///\n        /// (Pairs with OnDestroy)\n        ///\n        /// @author S Downie\n        //-----------------------------------------\n        virtual void OnInit(){};\n        //-----------------------------------------\n        /// Triggered when a state is the\n        /// active state in the state manager and\n        /// the application/state resumes.\n        ///\n        /// (Pairs with OnSuspend)\n        ///\n        /// @author S Downie\n        //-----------------------------------------\n        virtual void OnResume(){};\n        //-----------------------------------------\n        /// Triggered when a state is the\n        /// active state in the state manager and\n        /// the application becomes the foreground\n        /// app.\n        ///\n        /// (Pairs with OnBackground)\n        ///\n        /// @author S Downie\n        //-----------------------------------------\n        virtual void OnForeground(){};\n        //-----------------------------------------\n        /// Triggered each update loop while the\n        /// state is the active state.\n        ///\n        /// @author S Downie\n        ///\n        /// @param Time since last update (Secs)\n        //-----------------------------------------\n        virtual void OnUpdate(f32 in_deltaTime){};\n        //-----------------------------------------\n        /// Triggered each update loop at a fixed\n        /// interval while the state is the active\n        /// state.\n        ///\n        /// @author S Downie\n        ///\n        /// @param Fixed time since last update (Secs)\n        //-----------------------------------------\n        virtual void OnFixedUpdate(f32 in_deltaTime){};\n        \n        /// The render snapshot event can be implemented by a state to allow it to\n        /// snapshot any data which pertains to the renderer.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param targetType\n        ///     Whether the snapshot is for the main screen or offscreen\n        /// @param renderSnapshot\n        ///     The render snapshot object which contains all snapshotted data.\n        /// @param frameAllocator\n        ///     Use this to allocate any memory required for this frame\n        ///\n        virtual void OnRenderSnapshot(TargetType targetType, class RenderSnapshot& renderSnapshot, IAllocator* frameAllocator) noexcept {};\n        \n        //-----------------------------------------\n        /// Triggered when a state is the\n        /// active state in the state manager and\n        /// the application is no longer at the\n        /// foreground.\n        ///\n        /// (Pairs with OnForeground)\n        ///\n        /// @author S Downie\n        //-----------------------------------------\n        virtual void OnBackground(){};\n        //-----------------------------------------\n        /// Triggered when a state is the\n        /// active state in the state manager and\n        /// the application/state suspends.\n        ///\n        /// (Pairs with OnResume)\n        ///\n        /// @author S Downie\n        //-----------------------------------------\n        virtual void OnSuspend(){};\n        //-----------------------------------------\n        /// Triggered whenever a state is removed\n        /// from the state manager.\n        ///\n        /// (Pairs with OnInit)\n        ///\n        /// @author S Downie\n        //-----------------------------------------\n        virtual void OnDestroy(){};\n        \n    private:\n        \n        std::vector<StateSystemUPtr> m_systems;\n        \n        std::vector<Scene*> m_scenes;\n        Canvas* m_canvas = nullptr;\n        bool m_canAddSystems = false;\n        \n        friend class StateManager;\n    };\n    \n    //----------------------------------------------------\n    //----------------------------------------------------\n    template <typename TSystem, typename... TArgs> TSystem* State::CreateSystem(TArgs&&... in_args)\n    {\n        CS_ASSERT(m_canAddSystems == true, \"Cannot add systems outwith the creation phase\");\n        \n        std::unique_ptr<TSystem> newSystem = TSystem::Create(std::forward<TArgs>(in_args)...);\n        TSystem* output = newSystem.get();\n        if (newSystem != nullptr)\n        {\n            newSystem->SetState(this);\n            m_systems.push_back(std::move(newSystem));\n        }\n        return output;\n    }\n    //----------------------------------------------------\n    //----------------------------------------------------\n    template <typename TNamedType> TNamedType* State::GetSystem()\n    {\n        for (const auto& system : m_systems)\n        {\n            if (system->IsA<TNamedType>() == true)\n            {\n                return static_cast<TNamedType*>(system.get());\n            }\n        }\n        \n        return nullptr;\n    }\n    //----------------------------------------------------\n    //----------------------------------------------------\n    template <typename TNamedType> const TNamedType* State::GetSystem() const\n    {\n        for (const auto& system : m_systems)\n        {\n            if (system->IsA<TNamedType>() == true)\n            {\n                return static_cast<TNamedType*>(system.get());\n            }\n        }\n        \n        return nullptr;\n    }\n    //----------------------------------------------------\n    //----------------------------------------------------\n    template <typename TNamedType> std::vector<TNamedType*> State::GetSystems()\n    {\n        std::vector<TNamedType*> systems;\n        \n        for (const auto& stateSystem : m_systems)\n        {\n            if (stateSystem->IsA(TNamedType::InterfaceID))\n            {\n                systems.push_back(static_cast<TNamedType*>(stateSystem.get()));\n            }\n        }\n        \n        return systems;\n    }\n    //----------------------------------------------------\n    //----------------------------------------------------\n    template <typename TNamedType> std::vector<const TNamedType*> State::GetSystems() const\n    {\n        std::vector<const TNamedType*> systems;\n        \n        for (const auto& stateSystem : m_systems)\n        {\n            if (stateSystem->IsA(TNamedType::InterfaceID))\n            {\n                systems.push_back(static_cast<TNamedType*>(stateSystem.get()));\n            }\n        }\n        \n        return systems;\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/State/StateManager.cpp",
    "content": "//\n//  StateManager.cpp\n//  ChilliSource\n//  Created by Scott Downie on 23/09/2010.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2010 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Core/State/StateManager.h>\n\n#include <ChilliSource/Core/State/State.h>\n\nnamespace ChilliSource\n{\n    namespace\n    {\n        const StateSPtr NullStatePtr;\n    }\n    \n    CS_DEFINE_NAMEDTYPE(StateManager);\n    \n    //---------------------------------------------------------\n    //---------------------------------------------------------\n    StateManagerUPtr StateManager::Create()\n    {\n        return StateManagerUPtr(new StateManager());\n    }\n    //---------------------------------------------------------\n    //---------------------------------------------------------\n    StateManager::StateManager()\n    : m_isStartState(false)\n    {\n    }\n    //---------------------------------------------------------\n    //---------------------------------------------------------\n    bool StateManager::IsA(InterfaceIDType in_interfaceId) const\n    {\n        return in_interfaceId == StateManager::InterfaceID;\n    }\n    //---------------------------------------------------------\n    //---------------------------------------------------------\n    void StateManager::PopHierarchy()\n    {\n        m_states.pop_back();\n    }\n    //---------------------------------------------------------\n    //---------------------------------------------------------\n    void StateManager::PushHierarchy(const StateSPtr& in_state)\n    {\n        m_states.push_back(in_state);\n    }\n    //---------------------------------------------------------\n    //---------------------------------------------------------\n    void StateManager::ResumeStates()\n    {\n        CS_ASSERT(m_statesActive == false, \"Resume states called when states are already active.\");\n\n        if(!m_states.empty())\n        {\n            m_states.back()->Resume();\n        }\n\n        m_statesActive = true;\n    }\n    //---------------------------------------------------------\n    //---------------------------------------------------------\n    void StateManager::ForegroundStates()\n    {\n        CS_ASSERT(m_statesForegrounded == false, \"Foreground states called when states are not backgrounded.\");\n\n        if(!m_states.empty())\n        {\n            m_states.back()->Foreground();\n        }\n\n        m_statesForegrounded = true;\n    }\n    //---------------------------------------------------------\n    //---------------------------------------------------------\n    void StateManager::UpdateStates(f32 in_timeSinceLastUpdate)\n    {\n        while(!m_operations.empty())\n        {\n            switch(m_operations.front().m_action)\n            {\n                case StateOperationAction::k_push:\n                {\n                    StateSPtr pushed = m_operations.front().m_state;\n                    StateSPtr top;\n                    \n                    if(!m_states.empty())\n                    {\n                        top = m_states.back();\n                        CS_ASSERT(top != pushed, \"You cannot push a copy of a state onto itself\");\n                    }\n                    \n                    //Only the top state will have been started so this\n                    //is the only one we need to stop\n                    if(!m_isStartState && !m_states.empty())\n                    {\n                        if (m_statesForegrounded == true)\n                        {\n                            top->Background();\n                        }\n\n                        if (m_statesActive == true)\n                        {\n                            top->Suspend();\n                        }\n                    }\n                    \n                    //Check that the state we have pushed is not already in the hierarchy\n                    bool bAlreadyInHierarchy = DoesStateExist(pushed.get());\n                    \n                    PushHierarchy(pushed);\n                    \n                    if(!bAlreadyInHierarchy)\n                    {\n                        pushed->Init();\n                    }\n                    \n                    m_isStartState = true;\n                    break;\n                }\n                case StateOperationAction::k_popTo:\n                {\n                    State * targetState = m_operations.front().m_rawState;\n                    bool isTopStateStopped = false;\n                    while (!m_states.empty() && (m_states.back().get() != targetState))\n                    {\n                        StateSPtr popped = m_states.back();\n                        \n                        // Stop the top state only\n                        if(!isTopStateStopped)\n                        {\n                            isTopStateStopped = true;\n\n                            if (m_statesForegrounded == true)\n                            {\n                                popped->Background();\n                            }\n\n                            if (m_statesActive == true)\n                            {\n                                popped->Suspend();\n                            }\n                        }\n                        \n                        if(GetNumInstancesOfState(popped.get()) == 1)\n                        {\n                            popped->Destroy();\n                        }\n                        \n                        PopHierarchy();\n                        \n                        // Only start the state if something has been popped\n                        m_isStartState = true;\n                    }\n                    \n                    break;\n                }\n                case StateOperationAction::k_popToUnique:\n                {\n                    State * targetState = m_operations.front().m_rawState;\n                    bool isTopStateStopped = false;\n                    while (!m_states.empty())\n                    {\n                        // If top state is the target and is unique\n                        if(m_states.back().get() == targetState && GetNumInstancesOfState(targetState) == 1)\n                            break;\n                        \n                        StateSPtr popped = m_states.back();\n                        \n                        // Stop the top state only\n                        if(!isTopStateStopped)\n                        {\n                            isTopStateStopped = true;\n                            \n                            if (m_statesForegrounded == true)\n                            {\n                                popped->Background();\n                            }\n\n                            if (m_statesActive == true)\n                            {\n                                popped->Suspend();\n                            }\n                        }\n                        \n                        if(GetNumInstancesOfState(popped.get()) == 1)\n                        {\n                            popped->Destroy();\n                        }\n                        \n                        PopHierarchy();\n                    }\n                    \n                    m_isStartState = true;\n                    \n                    break;\n                }\n                case StateOperationAction::k_clear:\n                    \n                    if(!m_states.empty())\n                    {\n                        StateSPtr top = m_states.back();\n\n                        if (m_statesForegrounded == true)\n                        {\n                            top->Background();\n                        }\n\n                        if (m_statesActive == true)\n                        {\n                            top->Suspend();\n                        }\n                    }\n                    \n                    while (!m_states.empty())\n                    {\n                        StateSPtr top = m_states.back();\n                        \n                        if(GetNumInstancesOfState(top.get()) == 1)\n                        {\n                            top->Destroy();\n                        }\n                        \n                        PopHierarchy();\n                    }\n                    break;\n                case StateOperationAction::k_pop:\n                {\n                    if(m_states.empty())\n                    {\n                        break;\n                    }\n                    \n                    //Only the top state will have been started so this\n                    //is the only one we need to stop\n                    StateSPtr popped = m_states.back();\n                    \n                    if(!m_isStartState)\n                    {\n                        if (m_statesForegrounded == true)\n                        {\n                            popped->Background();\n                        }\n\n                        if (m_statesActive == true)\n                        {\n                            popped->Suspend();\n                        }\n                    }\n                    \n                    if(GetNumInstancesOfState(popped.get()) == 1)\n                    {\n                        popped->Destroy();\n                    }\n                    \n                    PopHierarchy();\n                    \n                    m_isStartState = true;\n                    break;\n                }\n                default:\n                    break;\n            }\n            m_operations.pop_front();\n        }\n        \n        if(!m_states.empty())\n        {\n            //We only want to start the state we intend to finish on (i.e. pushing 3 states in a single frame)\n            if(m_isStartState)\n            {\n                m_isStartState = false;\n\n                if (m_statesActive == true)\n                {\n                    m_states.back()->Resume();\n                }\n\n                if (m_statesForegrounded == true)\n                {\n                    m_states.back()->Foreground();\n                }\n            }\n            \n            m_states.back()->Update(in_timeSinceLastUpdate);\n        }\n\n    }\n    //---------------------------------------------------------\n    //---------------------------------------------------------\n    void StateManager::FixedUpdateStates(f32 in_fixedTimeSinceLastUpdate)\n    {\n        if(!m_states.empty())\n        {\n            m_states.back()->FixedUpdate(in_fixedTimeSinceLastUpdate);\n        }\n    }\n    //---------------------------------------------------------\n    //---------------------------------------------------------\n    void StateManager::RenderSnapshotStates(TargetType targetType, RenderSnapshot& renderSnapshot, IAllocator* frameAllocator) noexcept\n    {\n        if(!m_states.empty())\n        {\n            m_states.back()->RenderSnapshot(targetType, renderSnapshot, frameAllocator);\n        }\n    }\n    //---------------------------------------------------------\n    //---------------------------------------------------------\n    void StateManager::BackgroundStates()\n    {\n        CS_ASSERT(m_statesForegrounded == true, \"Background states called when states are not foregrounded.\");\n\n        if(!m_states.empty())\n        {\n            m_states.back()->Background();\n        }\n\n        m_statesForegrounded = false;\n    }\n    //---------------------------------------------------------\n    //---------------------------------------------------------\n    void StateManager::SuspendStates()\n    {\n        CS_ASSERT(m_statesActive == true, \"Suspend states called when states are not active.\");\n\n        if(!m_states.empty())\n        {\n            m_states.back()->Suspend();\n        }\n\n        m_statesActive = false;\n    }\n    //---------------------------------------------------------\n    //---------------------------------------------------------\n    void StateManager::DestroyStates()\n    {\n        while(!m_states.empty())\n        {\n            StateSPtr state = m_states.back();\n            m_states.pop_back();\n            \n            if(!DoesStateExist(state.get()))\n            {\n                state->Destroy();\n            }\n        }\n    }\n    //---------------------------------------------------------\n    //---------------------------------------------------------\n    void StateManager::MemoryWarningStates()\n    {\n        for(std::vector<StateSPtr>::const_iterator it = m_states.begin(); it != m_states.end(); ++it)\n        {\n            (*it)->MemoryWarning();\n        }\n    }\n    //---------------------------------------------------------\n    //---------------------------------------------------------\n    void StateManager::Push(const StateSPtr &in_state)\n    {\n        m_operations.push_back(StateOperation(StateOperationAction::k_push, in_state));\n    }\n    //---------------------------------------------------------\n    //---------------------------------------------------------\n    void StateManager::Pop()\n    {\n        m_operations.push_back(StateOperation(StateOperationAction::k_pop));\n    }\n    //---------------------------------------------------------\n    //---------------------------------------------------------\n    void StateManager::PopToState(State* in_target)\n    {\n        m_operations.push_back(StateOperation(StateOperationAction::k_popTo, in_target));\n    }\n    //---------------------------------------------------------\n    //---------------------------------------------------------\n    void StateManager::PopToStateUnique(State * in_target)\n    {\n        m_operations.push_back(StateOperation(StateOperationAction::k_popToUnique, in_target));\n    }\n    //---------------------------------------------------------\n    //---------------------------------------------------------\n    void StateManager::Clear()\n    {\n        m_operations.push_back(StateOperation(StateOperationAction::k_clear));\n    }\n    //---------------------------------------------------------\n    //---------------------------------------------------------\n    u32 StateManager::GetNumStates() const\n    {\n        return static_cast<u32>(m_states.size());\n    }\n    //---------------------------------------------------------\n    //---------------------------------------------------------\n    void StateManager::Change(const StateSPtr& in_state)\n    {\n        m_operations.push_back(StateOperation(StateOperationAction::k_pop));\n        m_operations.push_back(StateOperation(StateOperationAction::k_push, in_state));\n    }\n    //---------------------------------------------------------\n    //---------------------------------------------------------\n    const std::vector<StateSPtr>& StateManager::GetStates() const\n    {\n        return m_states;\n    }\n    //---------------------------------------------------------\n    //---------------------------------------------------------\n    const StateSPtr& StateManager::GetActiveState() const\n    {\n        if(!m_states.empty())\n        {\n            return m_states.back();\n        }\n        else\n        {\n            return NullStatePtr;\n        }\n    }\n    //---------------------------------------------------------\n    //---------------------------------------------------------\n    u32 StateManager::GetNumInstancesOfState(State* in_state) const\n    {\n        u32 numInstances = 0;\n        \n        for (std::vector<StateSPtr>::const_iterator it = m_states.begin(); it != m_states.end(); ++it)\n        {\n            if ((*it).get() == in_state)\n            {\n                ++numInstances;\n            }\n        }\n        \n        return numInstances;\n    }\n    //---------------------------------------------------------\n    //---------------------------------------------------------\n    bool StateManager::DoesStateExist(State* in_state) const\n    {\n        for (std::vector<StateSPtr>::const_iterator it = m_states.begin(); it != m_states.end(); ++it)\n        {\n            if ((*it).get() == in_state)\n            {\n                return true;\n            }\n        }\n        \n        return false;\n    }\n    //---------------------------------------------------------\n    //---------------------------------------------------------\n    bool StateManager::IsStatePending(State* in_state) const\n    {\n        for (std::list<StateOperation>::const_iterator it = m_operations.begin(); it != m_operations.end(); ++it)\n        {\n            if (((*it).m_action == StateOperationAction::k_push || (*it).m_action == StateOperationAction::k_popTo) && (*it).m_state.get() == in_state)\n            {\n                return true;\n            }\n        }\n        \n        return false;\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Core/State/StateManager.h",
    "content": "//\n//  StateManager.h\n//  ChilliSource\n//  Created by Scott Downie on 23/09/2010.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2010 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_STATE_STATEMANAGER_H_\n#define _CHILLISOURCE_CORE_STATE_STATEMANAGER_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/System/AppSystem.h>\n\n#include <list>\n#include <vector>\n\nnamespace ChilliSource\n{\n    //---------------------------------------------------------\n    /// Manages the state stack ensuring that only one state\n    /// is active at a time. Funnels application lifecycle\n    /// events to the active state.\n    ///\n    /// @author S Downie\n    //---------------------------------------------------------\n    class StateManager : public AppSystem\n    {\n    public:\n        \n        CS_DECLARE_NAMEDTYPE(StateManager);\n        \n        //---------------------------------------------------------\n        /// Factory method\n        ///\n        /// @author S Downie\n        ///\n        /// @return New state manager instance\n        //---------------------------------------------------------\n        static StateManagerUPtr Create();\n        //---------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Interface ID\n        ///\n        /// @return Whether the system implements the given interface\n        //---------------------------------------------------------\n        bool IsA(InterfaceIDType in_interfaceId) const override;\n        //---------------------------------------------------------\n        /// @author T Kane\n        ///\n        /// @return all States\n        //---------------------------------------------------------\n        const std::vector<StateSPtr>& GetStates() const;\n        //---------------------------------------------------------\n        /// @author N Tanda\n        ///\n        /// @return State on top of the hierarchy or null\n        //---------------------------------------------------------\n        const StateSPtr& GetActiveState() const;\n        //---------------------------------------------------------\n        /// @author N Tanda\n        ///\n        /// @return returns true if state is in stack, otherwise false\n        //---------------------------------------------------------\n        bool DoesStateExist(State* in_state) const;\n        //---------------------------------------------------------\n        /// @author N Tanda\n        ///\n        /// @return The number of times the state appears in the stack\n        //---------------------------------------------------------\n        u32 GetNumInstancesOfState(State* in_state) const;\n        //---------------------------------------------------------\n        /// @author N Tanda\n        ///\n        /// @return returns true if state is pending to be pushed\n        /// in state operation stack\n        //---------------------------------------------------------\n        bool IsStatePending(State* in_state) const;\n        //---------------------------------------------------------\n        /// Add this state to the stack and make it the active\n        /// state.\n        ///\n        /// @author S Downie\n        ///\n        /// @param New active state\n        //---------------------------------------------------------\n        void Push(const StateSPtr& in_state);\n        //---------------------------------------------------------\n        /// Remove the active state from the hierarchy\n        /// and resume the state beneath it. This\n        /// state will now be the active state\n        ///\n        /// @author S Downie\n        //---------------------------------------------------------\n        void Pop();\n        //---------------------------------------------------------\n        /// Removes states from the hierarchy until the\n        /// specified state is topmost. The given state\n        /// will become active. Will pop to empty if state doesn't\n        /// exist.\n        ///\n        /// @author N Tanda\n        ///\n        /// @param Target state\n        //---------------------------------------------------------\n        void PopToState(State* in_target);\n        //---------------------------------------------------------\n        /// Removes states from the hierarchy until the\n        /// specified state is topmost and is unique in the stack.\n        /// The given state will become active. Will pop to empty\n        /// if state doesn't exist.\n        ///\n        /// @author N Tanda\n        ///\n        /// @param Target state\n        //---------------------------------------------------------\n        void PopToStateUnique(State* in_target);\n        //---------------------------------------------------------\n        /// Remove all states from the stack.\n        ///\n        /// @author S Downie\n        //---------------------------------------------------------\n        void Clear();\n        //---------------------------------------------------------\n        /// @author N Tanda\n        ///\n        /// @return the number of states on the stack.\n        //---------------------------------------------------------\n        u32 GetNumStates() const;\n        //---------------------------------------------------------\n        /// Change\n        ///\n        /// Pop the current state and push the given state\n        ///\n        /// @author S Downie\n        ///\n        /// @param State to become active\n        //---------------------------------------------------------\n        void Change(const StateSPtr& in_state);\n        \n    private:\n        friend class Application;\n        \n        //---------------------------------------------------------\n        /// Private to enforce use of factory method\n        ///\n        /// @author S Downie\n        //---------------------------------------------------------\n        StateManager();\n        //---------------------------------------------------------\n        /// Triggered by the application when the system is\n        /// resumed. Forwards to states.\n        ///\n        /// @author S Downie\n        //---------------------------------------------------------\n        void ResumeStates();\n        //---------------------------------------------------------\n        /// Triggered by the application when the system is\n        /// pushed to the foreground. Forwards to states.\n        ///\n        /// @author S Downie\n        //---------------------------------------------------------\n        void ForegroundStates();\n        //---------------------------------------------------------\n        /// Updates the current state with the time since last\n        /// update\n        ///\n        /// @author S Downie\n        ///\n        /// @param Time since last update in seconds\n        //---------------------------------------------------------\n        void UpdateStates(f32 in_timeSinceLastUpdate);\n        //---------------------------------------------------------\n        /// Updates the current state with the time since last\n        /// update. This is called at a fixed interval\n        ///\n        /// @author S Downie\n        ///\n        /// @param Fixed time since last update in seconds\n        //---------------------------------------------------------\n        void FixedUpdateStates(f32 in_fixedTimeSinceLastUpdate);\n        //---------------------------------------------------------\n        /// Sends the render snapshot event to the active state,\n        /// allowing it to snapshot data which pertains to the\n        /// renderer.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param targetType - Whether the snapshot is for the main screen\n        /// or an offscreen target\n        /// @param renderSnapshot - The render snapshot object\n        /// which contains all snapshotted data.\n        /// @param frameAllocator - Allocate memory required for\n        /// rendering this frame from here\n        //---------------------------------------------------------\n        void RenderSnapshotStates(TargetType targetType, RenderSnapshot& renderSnapshot, IAllocator* frameAllocator) noexcept;\n        //---------------------------------------------------------\n        /// Triggered by the application when the system is\n        /// pushed to the background. Forwards to states.\n        ///\n        /// @author S Downie\n        //---------------------------------------------------------\n        void BackgroundStates();\n        //---------------------------------------------------------\n        /// Triggered by the application when the app is suspended.\n        /// Forwards to states.\n        ///\n        /// @author S Downie\n        //---------------------------------------------------------\n        void SuspendStates();\n        //---------------------------------------------------------\n        /// Triggered by the application when the system is\n        /// about to be destroyed to ensure systems exist when\n        /// states are destroyed.\n        ///\n        /// @author S Downie\n        //---------------------------------------------------------\n        void DestroyStates();\n        //---------------------------------------------------------\n        /// Triggered by the application when it receives\n        /// a low memory warning. Forwards to states.\n        ///\n        /// @author S Downie\n        //---------------------------------------------------------\n        void MemoryWarningStates();\n        //---------------------------------------------------------\n        /// Pop Hierarchy\n        ///\n        /// Manages the hierarchy list and the setting of\n        /// the state as active or inactive\n        //---------------------------------------------------------\n        void PopHierarchy();\n        //---------------------------------------------------------\n        /// Push Hierarchy\n        ///\n        /// Manages the hierarchy list and the setting of\n        /// the state as active or inactive\n        ///\n        /// @param State to push\n        //---------------------------------------------------------\n        void PushHierarchy(const StateSPtr& inpState);\n        \n        enum class StateOperationAction\n        {\n            k_push,\n            k_pop,\n            k_popTo,\n            k_popToUnique,\n            k_clear\n        };\n        \n        struct StateOperation\n        {\n            StateOperation(StateOperationAction in_action) : m_action(in_action), m_rawState(nullptr){}\n            StateOperation(StateOperationAction in_action, const StateSPtr& in_state) : m_action(in_action), m_state(in_state), m_rawState(nullptr){}\n            StateOperation(StateOperationAction in_action, State* in_state) : m_action(in_action), m_rawState(in_state){}\n\n            StateOperationAction m_action;\n            StateSPtr m_state;\n            State * m_rawState;\n        };\n        \n    private:\n    \n        std::vector<StateSPtr> m_states;\n        std::list<StateOperation> m_operations;\n        \n        bool m_isStartState;\n        bool m_statesActive = false;\n        bool m_statesForegrounded = false;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/State.h",
    "content": "//\n//  State.h\n//  ChilliSource\n//  Created by Ian Copland on 07/07/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_STATE_H_\n#define _CHILLISOURCE_CORE_STATE_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/State/State.h>\n#include <ChilliSource/Core/State/StateManager.h>\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/String/MarkupDef.cpp",
    "content": "//\n//  MarkupDef.cpp\n//  ChilliSource\n//  Created by Nicolas Tanda on 08/07/2015.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2015 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Core/String/MarkupDef.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void MarkupDef::AddKeyword(const std::string& in_name, bool in_nestable)\n    {\n        CS_ASSERT(HasKeyword(in_name) == false, \"The markup definition already has \\\"\" + in_name + \"\\\" as a keyword\");\n        \n        m_keywords[in_name] = in_nestable;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    bool MarkupDef::HasKeyword(const std::string& in_name) const\n    {\n        return m_keywords.find(in_name) != m_keywords.end();\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    bool MarkupDef::IsKeywordNestable(const std::string& in_name) const\n    {\n        std::unordered_map<std::string, bool>::const_iterator itKeyword = m_keywords.find(in_name);\n        if(itKeyword != m_keywords.end())\n        {\n            return itKeyword->second;\n        }\n        return false;\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Core/String/MarkupDef.h",
    "content": "//\n//  MarkupDef.h\n//  ChilliSource\n//  Created by Nicolas Tanda on 08/07/2015.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2015 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_STRING_MARKUPDEF_H_\n#define _CHILLISOURCE_CORE_STRING_MARKUPDEF_H_\n\n#include <ChilliSource/ChilliSource.h>\n\n#include <unordered_map>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    /// Defines the markups\n    ///\n    /// @author N Tanda\n    //------------------------------------------------------------------------------\n    class MarkupDef final\n    {\n    public:\n        //------------------------------------------------------------------------------\n        /// Adds a keyword to the markup\n        ///\n        /// @author N Tanda\n        ///\n        /// @param in_name - The unique name of the keyword.\n        /// @param in_nestable - Whether the keyword can include other markups\n        //------------------------------------------------------------------------------\n        void AddKeyword(const std::string& in_name, bool in_nestable);\n        //------------------------------------------------------------------------------\n        /// @author N Tanda\n        ///\n        /// @param in_name - The unique name of the keyword.\n        ///\n        /// @return Whether the keyword is known\n        //------------------------------------------------------------------------------\n        bool HasKeyword(const std::string& in_name) const;\n        //------------------------------------------------------------------------------\n        /// @author N Tanda\n        ///\n        /// @param in_name - The unique name of the keyword.\n        ///\n        /// @return Whether the keyword can include other markups\n        //------------------------------------------------------------------------------\n        bool IsKeywordNestable(const std::string& in_name) const;\n        \n    private:\n        std::unordered_map<std::string, bool> m_keywords;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/String/StringMarkupParser.cpp",
    "content": "//\n//  StringMarkupParser.cpp\n//  ChilliSource\n//  Created by Nicolas Tanda on 08/07/2015.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2015 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Core/String/StringMarkupParser.h>\n\n#include <ChilliSource/Core/String/UTF8StringUtils.h>\n\nnamespace ChilliSource\n{\n    namespace\n    {\n        const char k_markupStart = '[';\n        const char k_markupSeparator = '=';\n        const char k_markupEnd = ']';\n    }\n    \n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    StringMarkupParser::StringMarkupParser(const MarkupDef& in_markupDef)\n    :m_markupDef(in_markupDef)\n    {\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    std::string StringMarkupParser::Parse(const std::string& in_string, const MarkupFoundDelegate& in_callback)\n    {\n        std::string out_string;\n        u32 index = 0;\n        \n        auto it = in_string.begin();\n        while(it < in_string.end())\n        {\n            auto character = UTF8StringUtils::Next(it);\n            \n            if(character != k_markupStart)\n            {\n                UTF8StringUtils::Append(character, out_string);\n                if(character != ' ' && character != '\\t' && character != '\\n')\n                {\n                    ++index;\n                }\n            }\n            else\n            {\n                // Found a mark up, check it\n                ParseRecursive(index, it, out_string, in_callback);\n            }\n        }\n        \n        return out_string;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    std::string StringMarkupParser::ParseRecursive(u32 in_indexInString, std::string::const_iterator& out_iterator, std::string& out_string, const MarkupFoundDelegate& in_callback)\n    {\n        // Found some mark-up. What type is it?\n        std::string type;\n        UTF8Char nextChar = '\\0';\n        \n        while (nextChar != k_markupSeparator)\n        {\n            nextChar = UTF8StringUtils::Next(out_iterator);\n            \n            if(nextChar != k_markupSeparator && nextChar != ' ')\n            {\n                type += nextChar;\n            }\n        }\n        \n        // Variable type has been located\n        std::string varName;\n        \n        // There may be some whitespace that we need to ignore\n        nextChar = UTF8StringUtils::Next(out_iterator);\n        if(nextChar != ' ')\n        {\n            varName += nextChar;\n        }\n        \n        // Find the closing bracket\n        while (nextChar != k_markupEnd)\n        {\n            nextChar = UTF8StringUtils::Next(out_iterator);\n            \n            if(nextChar != k_markupEnd && nextChar != k_markupStart && nextChar != ' ')\n            {\n                varName += nextChar;\n            }\n            \n            // Nested variable\n            if(nextChar == k_markupStart)\n            {\n                std::string variableName;\n                \n                const auto& subType = ParseRecursive(in_indexInString, out_iterator, variableName, in_callback);\n                \n                // Check if the keyword is nestable\n                if(m_markupDef.HasKeyword(subType))\n                {\n                    CS_ASSERT(m_markupDef.IsKeywordNestable(subType) == true, \"Keyword \\\"\" + subType + \"\\\" isn't a nestable type\");\n                }\n                \n                varName += variableName;\n            }\n        }\n        \n        if(m_markupDef.HasKeyword(type))\n        {\n            const auto& variable = in_callback(type, varName, in_indexInString);\n            out_string.append(variable);\n        }\n        else\n        {\n            out_string.append(k_markupStart + type + k_markupSeparator + varName + k_markupEnd);\n        }\n        \n        return type;\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Core/String/StringMarkupParser.h",
    "content": "//\n//  StringMarkupParser.h\n//  ChilliSource\n//  Created by Nicolas Tanda on 08/07/2015.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2015 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_STRING_STRINGMARKUPPARSER_H_\n#define _CHILLISOURCE_CORE_STRING_STRINGMARKUPPARSER_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/String/MarkupDef.h>\n\n#include <functional>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    /// Defines a markup parser\n    ///\n    /// @author N Tanda\n    //------------------------------------------------------------------------------\n    class StringMarkupParser final\n    {\n    public:\n        //------------------------------------------------------------------------------\n        /// Callback for when a markup has been found in the string.\n        /// A markup is composed by a keyword and a value in the form [keyword= value]\n        ///\n        /// @author N Tanda\n        ///\n        /// @param in_keywordName - The keyword name found in the string\n        /// @param in_keywordValue - The value of the keyword\n        /// @param in_indexInString - The index of the string within which the output will\n        ///        be placed at\n        ///\n        /// @return The value replacing the markup in the string\n        //------------------------------------------------------------------------------\n        using MarkupFoundDelegate = std::function<std::string(const std::string& in_keywordName, const std::string& in_keywordValue, u32 in_indexInString)>;\n        \n        //------------------------------------------------------------------------------\n        /// Constructor\n        ///\n        /// @author N Tanda\n        //------------------------------------------------------------------------------\n        StringMarkupParser() = default;\n        //------------------------------------------------------------------------------\n        /// Constructor\n        ///\n        /// @author N Tanda\n        ///\n        /// @param in_markupDef - The markup definition\n        //------------------------------------------------------------------------------\n        StringMarkupParser(const MarkupDef& in_markupDef);\n        //------------------------------------------------------------------------------\n        /// Parses the given string using the callback function passed to decide what to\n        /// do with the markups found.\n        ///\n        /// @author N Tanda\n        ///\n        /// @param in_string - The string to parse\n        /// @param in_callback - The delegate to callback when a markup has been found\n        ///\n        /// @return The parsed string\n        //------------------------------------------------------------------------------\n        std::string Parse(const std::string& in_string, const MarkupFoundDelegate& in_callback);\n        \n    private:\n        //------------------------------------------------------------------------------\n        /// Parses the given string using the callback function passed to decide what to\n        /// do with the markups found.\n        ///\n        /// @author N Tanda\n        ///\n        /// @param in_indexInString - The index of the string within which the output\n        ///        will be placed at\n        /// @param out_iterator - [OUT] The iterator going through the text\n        /// @param out_string - [OUT] The text output\n        /// @param in_callback - The delegate to callback when a markup has been found\n        ///\n        /// @return The keyword name found in the string\n        //------------------------------------------------------------------------------\n        std::string ParseRecursive(u32 in_indexInString, std::string::const_iterator& out_iterator, std::string& out_string, const MarkupFoundDelegate& in_callback);\n        \n    private:\n        MarkupDef m_markupDef;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/String/StringParser.cpp",
    "content": "//\n//  StringParser.cpp\n//  ChilliSource\n//  Created by Ian Copland on 25/02/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Core/String/StringParser.h>\n\n#include <ChilliSource/Core/Base/CursorType.h>\n#include <ChilliSource/Core/String/StringUtils.h>\n#include <ChilliSource/Rendering/Base/SurfaceFormat.h>\n\n#include <cstdlib>\n#include <string>\n\nnamespace ChilliSource\n{\n    namespace\n    {\n        //------------------------------------------------------------\n        /// Helper function to count items in a string seperated by a\n        /// space ' ' character.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The string list.\n        ///\n        /// @return The number of items.\n        //------------------------------------------------------------\n        static const u32 EnumerateItems(const std::string& in_stringList)\n        {\n            u32 itemCount = 0;\n            std::size_t i = 0;\n            const std::size_t size = in_stringList.size();\n            while(i < size)\n            {\n                if(in_stringList[i] != ' ')\n                {\n                    itemCount++;\n                    while(in_stringList[i] != ' ' &&  i < size)i++;\n                }\n                \n                while(in_stringList[i] == ' ' &&  i < size)i++;\n            }\n            \n            return itemCount;\n        }\n    }\n    \n    //------------------------------------------------------------\n    //------------------------------------------------------------\n    f32 ParseF32(const std::string& in_string)\n    {\n        return (f32)strtod(in_string.c_str(), nullptr);\n    }\n    //------------------------------------------------------------\n    //------------------------------------------------------------\n    s32 ParseS32(const std::string& in_string)\n    {\n        return static_cast<s32>(strtol(in_string.c_str(), nullptr, 10));\n    }\n    //------------------------------------------------------------\n    //------------------------------------------------------------\n    u32 ParseU32(const std::string& in_string)\n    {\n        return static_cast<u32>(strtoul(in_string.c_str(), nullptr, 10));\n    }\n    //------------------------------------------------------------\n    //------------------------------------------------------------\n    s64 ParseS64(const std::string& in_string)\n    {\n        std::istringstream str(in_string);\n        long ret = 0;\n        str >> ret;\n        return ret;\n    }\n    //------------------------------------------------------------\n    //------------------------------------------------------------\n    u64 ParseU64(const std::string& in_string)\n    {\n        std::istringstream str(in_string);\n        unsigned long ret = 0;\n        str >> ret;\n        return ret;\n    }\n    //------------------------------------------------------------\n    //------------------------------------------------------------\n    bool ParseBool(const std::string& in_string)\n    {\n        return (StringUtils::StartsWith(in_string, \"true\") || StringUtils::StartsWith(in_string, \"yes\") || StringUtils::StartsWith(in_string, \"1\"));\n    }\n    //------------------------------------------------------------\n    //------------------------------------------------------------\n    Vector2 ParseVector2(const std::string& in_string)\n    {\n        u32 udwSize = EnumerateItems(in_string);\n        CS_ASSERT((udwSize == 2), \"Invalid number of elements for Vector2.\");\n        \n        if (udwSize != 2)\n        {\n            return Vector2::k_zero;\n        }\n        else\n        {\n            Vector2 vRet;\n            CS_SSCANF(in_string.c_str(), \"%f %f\", &vRet.x, &vRet.y);\n            return vRet;\n        }\n    }\n    \n    //------------------------------------------------------------\n    Integer2 ParseInteger2(const std::string& string)\n    {\n        u32 size = EnumerateItems(string);\n        CS_ASSERT((size == 2), \"Invalid number of elements for Integer2.\");\n        \n        if (size != 2)\n        {\n            return Integer2::k_zero;\n        }\n        else\n        {\n            Integer2 ret;\n            CS_SSCANF(string.c_str(), \"%d %d\", &ret.x, &ret.y);\n            return ret;\n        }\n    }\n    \n    //------------------------------------------------------------\n    //------------------------------------------------------------\n    Vector3 ParseVector3(const std::string& in_string)\n    {\n        u32 udwSize = EnumerateItems(in_string);\n        CS_ASSERT((udwSize == 3), \"Invalid number of elements for Vector3.\");\n        \n        if (udwSize != 3)\n        {\n            return Vector3::k_zero;\n        }\n        else\n        {\n            Vector3 vRet;\n            CS_SSCANF(in_string.c_str(), \"%f %f %f\", &vRet.x, &vRet.y, &vRet.z);\n            return vRet;\n        }\n    }\n    \n    //------------------------------------------------------------\n    Integer3 ParseInteger3(const std::string& string)\n    {\n        u32 size = EnumerateItems(string);\n        CS_ASSERT((size == 3), \"Invalid number of elements for Integer3.\");\n        \n        if (size != 3)\n        {\n            return Integer3::k_zero;\n        }\n        else\n        {\n            Integer3 ret;\n            CS_SSCANF(string.c_str(), \"%d %d %d\", &ret.x, &ret.y, &ret.z);\n            return ret;\n        }\n    }\n    \n    //------------------------------------------------------------\n    //------------------------------------------------------------\n    Vector4 ParseVector4(const std::string& in_string)\n    {\n        u32 udwSize = EnumerateItems(in_string);\n        CS_ASSERT((udwSize == 4), \"Invalid number of elements for Vector4.\");\n        \n        if (udwSize != 4)\n        {\n            return Vector4::k_zero;\n        }\n        else\n        {\n            Vector4 vRet;\n            CS_SSCANF(in_string.c_str(), \"%f %f %f %f\", &vRet.x, &vRet.y, &vRet.z, &vRet.w);\n            return vRet;\n        }\n    }\n    \n    //------------------------------------------------------------\n    Integer4 ParseInteger4(const std::string& string)\n    {\n        u32 size = EnumerateItems(string);\n        CS_ASSERT((size == 4), \"Invalid number of elements for Integer4.\");\n        \n        if (size != 4)\n        {\n            return Integer4::k_zero;\n        }\n        else\n        {\n            Integer4 ret;\n            CS_SSCANF(string.c_str(), \"%d %d %d %d\", &ret.x, &ret.y, &ret.z, &ret.w);\n            return ret;\n        }\n    }\n    \n    //------------------------------------------------------------\n    //------------------------------------------------------------\n    Matrix3 ParseMatrix3(const std::string& in_string)\n    {\n        u32 udwSize = EnumerateItems(in_string);\n        CS_ASSERT((udwSize == 9), \"Invalid number of elements for Matrix3.\");\n        \n        if (udwSize != 9)\n        {\n            return Matrix3::k_identity;\n        }\n        else\n        {\n            Matrix3 matRet;\n            \n            CS_SSCANF(in_string.c_str(), \"%f %f %f %f %f %f %f %f %f\",\n                      &matRet.m[0], &matRet.m[1], &matRet.m[2],\n                      &matRet.m[3], &matRet.m[4], &matRet.m[5],\n                      &matRet.m[6], &matRet.m[7], &matRet.m[8]);\n            \n            return matRet;\n        }\n    }\n    //------------------------------------------------------------\n    //------------------------------------------------------------\n    Matrix4 ParseMatrix4(const std::string& in_string)\n    {\n        u32 udwSize = EnumerateItems(in_string);\n        CS_ASSERT((udwSize == 16), \"Invalid number of elements for Matrix4.\");\n        \n        if (udwSize != 16)\n        {\n            return Matrix4::k_identity;\n        }\n        else\n        {\n            Matrix4 matRet;\n            \n            CS_SSCANF(in_string.c_str(), \"%f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f \",\n                    &matRet.m[0], &matRet.m[1], &matRet.m[2], &matRet.m[3],\n                    &matRet.m[4], &matRet.m[5], &matRet.m[6], &matRet.m[7],\n                    &matRet.m[8], &matRet.m[9], &matRet.m[10], &matRet.m[11],\n                    &matRet.m[12], &matRet.m[13], &matRet.m[14], &matRet.m[15]);\n            \n            return matRet;\n            \n        }\n    }\n    //------------------------------------------------------------\n    //------------------------------------------------------------\n    Quaternion ParseQuaternion(const std::string& in_string)\n    {\n        u32 udwSize = EnumerateItems(in_string);\n        CS_ASSERT((udwSize == 4), \"Invalid number of elements for Quaternion.\");\n        \n        if (udwSize != 4)\n        {\n            return Quaternion::k_identity;\n        }\n        else\n        {\n            Quaternion qRet;\n            CS_SSCANF(in_string.c_str(), \"%f %f %f %f\", &qRet.w, &qRet.x, &qRet.y, &qRet.z);\n            return qRet;\n        }\n    }\n    //------------------------------------------------------------\n    //------------------------------------------------------------\n    Colour ParseColour(const std::string& in_string)\n    {\n        u32 udwSize = EnumerateItems(in_string);\n        CS_ASSERT((udwSize == 3 || udwSize == 4), \"Invalid number of elements for Colour.\");\n        \n        Colour cRet(Colour::k_black);\n        \n        if (udwSize == 4)\n        {\n            CS_SSCANF(in_string.c_str(), \"%f %f %f %f\", &cRet.r, &cRet.g, &cRet.b, &cRet.a);\n        }\n        else if (udwSize == 3)\n        {\n            CS_SSCANF(in_string.c_str(), \"%f %f %f\", &cRet.r, &cRet.g, &cRet.b);\n        }\n        return cRet;\n    }\n    //------------------------------------------------------------\n    //------------------------------------------------------------\n    StorageLocation ParseStorageLocation(const std::string &in_string)\n    {\n        std::string lowerCase = in_string;\n        StringUtils::ToLowerCase(lowerCase);\n        \n        if(lowerCase == \"package\")\n        {\n            return StorageLocation::k_package;\n        }\n        else if(lowerCase == \"savedata\")\n        {\n            return StorageLocation::k_saveData;\n        }\n        else if(lowerCase == \"cache\")\n        {\n            return StorageLocation::k_cache;\n        }\n        else if(lowerCase == \"dlc\")\n        {\n            return StorageLocation::k_DLC;\n        }\n        else if(lowerCase == \"root\")\n        {\n            return StorageLocation::k_root;\n        }\n        else if(lowerCase == \"chillisource\")\n        {\n            return StorageLocation::k_chilliSource;\n        }\n        else if(lowerCase == \"none\")\n        {\n            return StorageLocation::k_none;\n        }\n        \n        CS_ASSERT(false, \"Invalid storage location.\");\n        CS_LOG_ERROR(\"String Parser: Invalid storage location.\");\n        return StorageLocation::k_package;\n    }\n    //------------------------------------------------------------\n    //------------------------------------------------------------\n    SurfaceFormat ParseSurfaceFormat(const std::string& in_surfaceFormat)\n    {\n        std::string lowerCase = in_surfaceFormat;\n        StringUtils::ToLowerCase(lowerCase);\n        \n        if (lowerCase == \"rgb565_depth24\")\n        {\n            return SurfaceFormat::k_rgb565_depth24;\n        }\n        else if (lowerCase == \"rgb565_depth32\")\n        {\n            return SurfaceFormat::k_rgb565_depth32;\n        }\n        else if (lowerCase == \"rgb888_depth24\")\n        {\n            return SurfaceFormat::k_rgb888_depth24;\n        }\n        else if (lowerCase == \"rgb888_depth32\")\n        {\n            return SurfaceFormat::k_rgb888_depth32;\n        }\n        else if (lowerCase == \"rgb565_depth24_stencil8\")\n        {\n            return SurfaceFormat::k_rgb565_depth24_stencil8;\n        }\n        else if (lowerCase == \"rgb565_depth32_stencil8\")\n        {\n            return SurfaceFormat::k_rgb565_depth32_stencil8;\n        }\n        else if (lowerCase == \"rgb888_depth24_stencil8\")\n        {\n            return SurfaceFormat::k_rgb888_depth24_stencil8;\n        }\n        else if (lowerCase == \"rgb888_depth32_stencil8\")\n        {\n            return SurfaceFormat::k_rgb888_depth32_stencil8;\n        }\n        \n        CS_ASSERT(false, \"Invalid surface format.\");\n        CS_LOG_ERROR(\"String Parser: Invalid surface format.\");\n        return SurfaceFormat::k_rgb565_depth24;\n    }\n    \n    //----------------------------------------------------------------------\n    CursorType ParseCursorType(const std::string& cursorType) noexcept\n    {\n        std::string lowerCase = cursorType;\n        StringUtils::ToLowerCase(lowerCase);\n        \n        if(lowerCase == \"system\")\n            return CursorType::k_system;\n        if(lowerCase == \"nonsystem\")\n            return CursorType::k_nonSystem;\n        if(lowerCase == \"none\")\n            return CursorType::k_none;\n        \n        CS_LOG_ERROR(\"String Parser: Invalid cursor type: \" + cursorType);\n        return CursorType::k_none;\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Core/String/StringParser.h",
    "content": "//\n//  StringParser.h\n//  ChilliSource\n//  Created by Ian Copland on 25/02/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_STRING_STRINGPARSER_H_\n#define _CHILLISOURCE_CORE_STRING_STRINGPARSER_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Math/Vector2.h>\n#include <ChilliSource/Core/Math/Vector3.h>\n#include <ChilliSource/Core/Math/Vector4.h>\n#include <ChilliSource/Core/Math/Matrix4.h>\n#include <ChilliSource/Core/Math/Quaternion.h>\n#include <ChilliSource/Core/Base/Colour.h>\n#include <ChilliSource/Core/File/FileSystem.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------\n    /// Parse a string to a 32 bit float. If the string cannot be\n    /// be parsed this will return 0.\n    ///\n    /// @author Ian Copland\n    ///\n    /// @param The string.\n    ///\n    /// @return The float value.\n    //------------------------------------------------------------\n    f32 ParseF32(const std::string& in_string);\n    //------------------------------------------------------------\n    /// Parse a string to a 32 bit signed integer. If the string\n    /// cannot be parsed this will return 0.\n    ///\n    /// @author Ian Copland\n    ///\n    /// @param The string.\n    ///\n    /// @return The integer value.\n    //------------------------------------------------------------\n    s32 ParseS32(const std::string& in_string);\n    //------------------------------------------------------------\n    /// Parse a string to a 32 bit unsigned integer. If the string\n    /// cannot be parsed this will return 0.\n    ///\n    /// @author Ian Copland\n    ///\n    /// @param The string.\n    ///\n    /// @return The integer value.\n    //------------------------------------------------------------\n    u32 ParseU32(const std::string& in_string);\n    //------------------------------------------------------------\n    /// Parse a string to a 64 bit signed integer. If the string\n    /// cannot be parsed this will return 0.\n    ///\n    /// @author Ian Copland\n    ///\n    /// @param The string.\n    ///\n    /// @return The integer value.\n    //------------------------------------------------------------\n    s64 ParseS64(const std::string& in_string);\n    //------------------------------------------------------------\n    /// Parse a string to a 32 bit unsigned integer. If the string\n    /// cannot be parsed this will return 0.\n    ///\n    /// @author Ian Copland\n    ///\n    /// @param The string.\n    ///\n    /// @return The integer value.\n    //------------------------------------------------------------\n    u64 ParseU64(const std::string& in_string);\n    //------------------------------------------------------------\n    /// Parse a string to a 32 bit unsigned integer. True will be\n    /// returned if the string is \"true\", \"yes\" or \"1\" and false\n    /// will be returned in all other cases.\n    ///\n    /// @author Ian Copland\n    ///\n    /// @param The string.\n    ///\n    /// @return The boolean value.\n    //------------------------------------------------------------\n    bool ParseBool(const std::string& in_string);\n    //------------------------------------------------------------\n    /// Parse a string to a 2 component vector. The vector must be\n    /// in the format \"x y\", i.e F32 values, space delimited. Failure\n    /// to parse will result in a zero vector.\n    ///\n    /// @author Ian Copland\n    ///\n    /// @param The string.\n    ///\n    /// @return The vector value.\n    //------------------------------------------------------------\n    Vector2 ParseVector2(const std::string& in_string);\n    //------------------------------------------------------------\n    /// Parse a string to a 3 component vector. The vector must be\n    /// in the format \"x y z\", i.e F32 values, space delimited. Failure\n    /// to parse will result in a zero vector.\n    ///\n    /// @author Ian Copland\n    ///\n    /// @param The string.\n    ///\n    /// @return The vector value.\n    //------------------------------------------------------------\n    Vector3 ParseVector3(const std::string& in_string);\n    //------------------------------------------------------------\n    /// Parse a string to a 4 component vector. The vector must be\n    /// in the format \"x y z w\", i.e F32 values, space delimited.\n    /// Failure to parse will result in a zero vector.\n    ///\n    /// @author Ian Copland\n    ///\n    /// @param The string.\n    ///\n    /// @return The vector value.\n    //------------------------------------------------------------\n    Vector4 ParseVector4(const std::string& in_string);\n    \n    /// Parse a string to a 2 component integer vector. The vector must be\n    /// in the format \"x y\", i.e s32 values, space delimited. Failure\n    /// to parse will result in a zero vector.\n    ///\n    /// @param string\n    ///     The string to parse\n    ///\n    /// @return The vector value.\n    ///\n    Integer2 ParseInteger2(const std::string& string);\n    \n    /// Parse a string to a 3 component integer vector. The vector must be\n    /// in the format \"x y z\", i.e s32 values, space delimited. Failure\n    /// to parse will result in a zero vector.\n    ///\n    /// @param string\n    ///     The string to parse\n    ///\n    /// @return The vector value.\n    ///\n    Integer3 ParseInteger3(const std::string& string);\n    \n    /// Parse a string to a 4 component integer vector. The vector must be\n    /// in the format \"x y z w\", i.e s32 values, space delimited. Failure\n    /// to parse will result in a zero vector.\n    ///\n    /// @param string\n    ///     The string to parse\n    ///\n    /// @return The vector value.\n    ///\n    Integer4 ParseInteger4(const std::string& string);\n    \n    //------------------------------------------------------------\n    /// Parse a string to a matrix. The matrix should be provided\n    /// in row major format, space delimited. failure to parse will\n    /// result in an identity matrix.\n    ///\n    /// @author Ian Copland\n    ///\n    /// @param The string.\n    ///\n    /// @return The matrix value.\n    //------------------------------------------------------------\n    Matrix3 ParseMatrix3(const std::string& in_string);\n    //------------------------------------------------------------\n    /// Parse a string to a matrix. The matrix should be provided\n    /// in row major format, space delimited. failure to parse will\n    /// result in an identity matrix.\n    ///\n    /// @author Ian Copland\n    ///\n    /// @param The string.\n    ///\n    /// @return The matrix value.\n    //------------------------------------------------------------\n    Matrix4 ParseMatrix4(const std::string& in_string);\n    //------------------------------------------------------------\n    /// Parse a string to a quaternion. The quaternion must be\n    /// in the format \"w x y z\", i.e F32 values, space delimited.\n    /// Failure to parse will result in an identity quaternion.\n    ///\n    /// @author Ian Copland\n    ///\n    /// @param The string.\n    ///\n    /// @return The quaternion value.\n    //------------------------------------------------------------\n    Quaternion ParseQuaternion(const std::string& in_string);\n    //------------------------------------------------------------\n    /// Parse a string to a colour. The colour must be\n    /// in the format \"r g b a\", i.e F32 values, space delimited.\n    /// \"r g b\" will also be accepted. Failure to parse will result\n    /// in a black colour.\n    ///\n    /// @author Ian Copland\n    ///\n    /// @param The string.\n    ///\n    /// @return The colour value.\n    //------------------------------------------------------------\n    Colour ParseColour(const std::string& in_string);\n    //------------------------------------------------------------\n    /// Parse a storage location. Acceptable storage locations are:\n    ///\n    ///  - Package\n    ///  - DLC\n    ///  - SaveData\n    ///  - Cache\n    ///  - Root\n    ///\n    /// Note that the location strings are not case sensitive.\n    ///\n    /// @author Ian Copland\n    ///\n    /// @param The string.\n    ///\n    /// @return The colour value.\n    //------------------------------------------------------------\n    StorageLocation ParseStorageLocation(const std::string &in_string);\n    //------------------------------------------------------------\n    /// Converts from a string to a surface format type. Valid\n    /// formats are:\n    ///\n    ///  - RGB565_DEPTH24\n    ///  - RGB565_DEPTH32\n    ///  - RGB888_DEPTH24\n    ///  - RGB888_DEPTH32\n    ///\n    /// Note that the format strings are not case sensitive.\n    ///\n    /// @author Ian Copland\n    ///\n    /// @param The string.\n    ///\n    /// @return The surface format.\n    //------------------------------------------------------------\n    SurfaceFormat ParseSurfaceFormat(const std::string& in_surfaceFormat);\n    \n    /// Converts a cursor type string to a strong type.\n    ///\n    /// - System\n    /// - NonSystem\n    /// - None\n    ///\n    /// NOTE: Case insensitive. Will assert if no conversion possible\n    ///\n    /// @param cursorType\n    ///     Cursor type as a string.\n    ///\n    /// @return String converted to cursor type\n    ///\n    CursorType ParseCursorType(const std::string& cursorType) noexcept;\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/String/StringUtils.cpp",
    "content": "//\n//  StringUtils.cpp\n//  ChilliSource\n//  Created by Stuart McGaw on 25/10/2010.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2010 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Core/String/StringUtils.h>\n\n#include <ChilliSource/Core/Base/Utils.h>\n#include <ChilliSource/Core/Container/ParamDictionary.h>\n#include <ChilliSource/Core/String/StringParser.h>\n#include <ChilliSource/Core/String/UTF8StringUtils.h>\n\n#include <algorithm>\n#include <cctype>\n\nnamespace ChilliSource\n{\n    namespace StringUtils\n    {\n        namespace\n        {\n            const std::string kastrTimeFormat[(u32)StringTimeFormat::k_total] =\n            {\n                \"YYYY-MM-DD-HH:MM\",\n            };\n            \n            //-------------------------------------------------------\n            /// Replace Variables Recursive\n            ///\n            /// Find any variable or nested variable mark-up and insert the\n            /// value of the variables\n            ///\n            /// For instance \"My string contains [var =a] variable\n            /// and [var= b] variable called a and b\n            ///\n            /// Furthermore, [var= Var_[var= a]_b] has variables\n            /// called a, and e.g.  Var_12_b   (if a == \"12\")\n            ///\n            /// @param Params\n            /// @param Out: Text string (UTF-8)\n            /// @param Out: String iterator (UTF-8)\n            //-------------------------------------------------------\n            void ReplaceVariableRecursive(const ParamDictionary& insParams, std::string& outstrText, std::string::const_iterator& it)\n            {\n                //Found some mark-up. What type is it?\n                std::string strType;\n                UTF8Char byNextChar = '\\0';\n                \n                while(byNextChar != '=')\n                {\n                    byNextChar = UTF8StringUtils::Next(it);\n                    \n                    if(byNextChar != '=' && byNextChar != ' ')\n                    {\n                        strType += byNextChar;\n                    }\n                }\n                \n                // Variable type has been located\n                std::string strVarName;\n                std::string strVarValue;\n                \n                // There may be some whitespace that we need to ignore\n                byNextChar = UTF8StringUtils::Next(it);\n                if(byNextChar != ' ')\n                {\n                    strVarName += byNextChar;\n                }\n                \n                // Find the closing bracket\n                while(byNextChar != ']')\n                {\n                    byNextChar = UTF8StringUtils::Next(it);\n                    \n                    if(byNextChar != ']' && byNextChar != '[' && byNextChar != ' ')\n                    {\n                        strVarName += byNextChar;\n                    }\n                    \n                    // Nested variable\n                    if(byNextChar == '[')\n                    {\n                        std::string strVariableName;\n                        ReplaceVariableRecursive(insParams, strVariableName, it);\n                        strVarName += strVariableName;\n                    }\n                }\n                \n                bool bVariableReplaced = false;\n                \n                if(strType == \"var\")\n                {\n                    if(insParams.TryGetValue(strVarName, strVarValue))\n                    {\n                        //Let's replace the mark-up with the value\n                        outstrText.append(strVarValue);\n                        bVariableReplaced = true;\n                    }\n                }\n                \n                // If not, readd the [xxx= ]\n                if(!bVariableReplaced)\n                {\n                    outstrText.append(\"[\" + strType + \"= \" + strVarName + \"]\");\n                }\n            }\n            \n            /**\n             Converts the given time to a timestamp in seconds\n             */\n            TimeIntervalSecs ToTimeIntervalSecs(const std::string& instrYear,\n                                                const std::string& instrMonth,\n                                                const std::string& instrDays,\n                                                const std::string& instrHours,\n                                                const std::string& instrMins,\n                                                const std::string& instrSecs)\n            {\n                u32 udwYears = ParseS32(instrYear);\n                u32 udwMonths = ParseS32(instrMonth);\n                if(udwMonths > 0)\n                    udwMonths--;// Don't cound full month for current month\n                u32 udwDays = ParseS32(instrDays);\n                if(udwDays > 0)\n                    udwDays--;// Don't count full day as starts on 1st of month\n                u32 udwHours = ParseS32(instrHours);\n                if(udwHours > 0)\n                    udwHours--;// Don't count 1 hour of days\n                u32 udwMins = ParseS32(instrMins);\n                u32 udwSecs = ParseS32(instrSecs);\n                \n                u32 udwTotalDays = 0;\n                for(u32 i = 1970; i < udwYears; i++)\n                {\n                    if((i % 4) != 0)\n                        udwTotalDays += 365;\n                    else\n                    {\n                        udwTotalDays += 366;\n                    }\n                }\n                for(u32 i = 0; i < udwMonths; i++)\n                {\n                    if((i == 3) || (i == 5) || (i == 8) || (i == 10))\n                        udwTotalDays += 30;\n                    else\n                        if(i == 1)\n                        {\n                            if((udwYears % 4) != 0)\n                                udwTotalDays += 28;\n                            else\n                                udwTotalDays += 29;\n                        }\n                        else\n                            udwTotalDays += 31;\n                }\n                udwTotalDays += udwDays;\n                \n                u32 udwTotalHours = (udwTotalDays * 24) + udwHours;\n                u32 udwTotalMins = (udwTotalHours * 60) + udwMins;\n                u32 udwTotalSecs = (udwTotalMins * 60) + udwSecs;\n                \n                return udwTotalSecs;\n            }\n        }\n        \n\n        //-----------------------------------------------------------------------\n        void Trim(std::string& str, bool left, bool right)\n        {\n            static const std::string delims = \" \\t\\r\";\n            if(right)\n                str.erase(str.find_last_not_of(delims)+1); // trim right\n            if(left)\n                str.erase(0, str.find_first_not_of(delims)); // trim left\n        }\n\n        //-----------------------------------------------------------------------\n        void Chop( std::string& str, u32 inudwNumCharacters)\n        {\n            str.erase(str.length() - inudwNumCharacters);\n        }\n        \n        //-----------------------------------------------------------------------\n        void ChopTrailingChars( std::string& str, s8 inbyChar)\n        {\n            u32 udwNumCharsToRemove = 0;\n            for(std::string::reverse_iterator it = str.rbegin(); it != str.rend(); ++it)\n            {\n                if((*it) == inbyChar)\n                {\n                    ++udwNumCharsToRemove;\n                }\n                else\n                {\n                    break;\n                }\n            }\n            \n            if(udwNumCharsToRemove > 0)\n            {\n                Chop(str, udwNumCharsToRemove);\n            }\n        }\n\n        //-----------------------------------------------------------------------\n        void TerminateStringWith(std::string &instrMain, const std::string &instrEnding)\n        {\n            // Simplest case, already terminated\n            if( EndsWith(instrMain, instrEnding))\n                return;\n            \n            // Assume no partials if not already terminated\n            instrMain += instrEnding;\n        }\n        \n        //-----------------------------------------------------------------------\n        std::vector<std::string> Split( const std::string& str, const std::string& delims, unsigned int maxSplits)\n        {\n            std::vector<std::string> ret;\n            // Pre-allocate some space for performance\n            ret.reserve(maxSplits ? maxSplits+1 : 10);    // 10 is guessed capacity for most case\n            \n            unsigned int numSplits = 0;\n            \n            // Use STL methods \n            size_t start, pos;\n            start = 0;\n            do \n            {\n                pos = str.find_first_of(delims, start);\n                if (pos == start)\n                {\n                    // Do nothing\n                    start = pos + 1;\n                }\n                else if (pos == std::string::npos || (maxSplits && numSplits == maxSplits))\n                {\n                    // Copy the rest of the string\n                    ret.push_back( str.substr(start) );\n                    break;\n                }\n                else\n                {\n                    // Copy up to delimiter\n                    ret.push_back( str.substr(start, pos - start) );\n                    start = pos + 1;\n                }\n                // parse up to next real data\n                start = str.find_first_not_of(delims, start);\n                ++numSplits;\n                \n            } while (pos != std::string::npos);\n            \n            \n            \n            return ret;\n        }\n\n\n        //-----------------------------------------------------------------------\n        std::vector< std::string > Tokenise( const std::string& str, const std::string& singleDelims, const std::string& doubleDelims, unsigned int maxSplits)\n        {\n            std::vector<std::string> ret;\n            // Pre-allocate some space for performance\n            ret.reserve(maxSplits ? maxSplits+1 : 10);    // 10 is guessed capacity for most case\n            \n            unsigned int numSplits = 0;\n            std::string delims = singleDelims + doubleDelims;\n            \n            // Use STL methods \n            size_t start, pos;\n            char curDoubleDelim = 0;\n            start = 0;\n            do \n            {\n                if (curDoubleDelim != 0)\n                {\n                    pos = str.find(curDoubleDelim, start);\n                }\n                else\n                {\n                    pos = str.find_first_of(delims, start);\n                }\n                \n                if (pos == start)\n                {\n                    char curDelim = str.at(pos);\n                    if (doubleDelims.find_first_of(curDelim) != std::string::npos)\n                    {\n                        curDoubleDelim = curDelim;\n                    }\n                    // Do nothing\n                    start = pos + 1;\n                }\n                else if (pos == std::string::npos || (maxSplits && numSplits == maxSplits))\n                {\n                    if (curDoubleDelim != 0)\n                    {\n                        //Missing closer. Warn or throw exception?\n                    }\n                    // Copy the rest of the string\n                    ret.push_back( str.substr(start) );\n                    break;\n                }\n                else\n                {\n                    if (curDoubleDelim != 0)\n                    {\n                        curDoubleDelim = 0;\n                    }\n                    \n                    // Copy up to delimiter\n                    ret.push_back( str.substr(start, pos - start) );\n                    start = pos + 1;\n                }\n                if (curDoubleDelim == 0)\n                {\n                    // parse up to next real data\n                    start = str.find_first_not_of(singleDelims, start);\n                }\n                \n                ++numSplits;\n                \n            } while (pos != std::string::npos);\n            \n            return ret;\n        }\n\n        //-----------------------------------------------------------------------\n        void ToLowerCase(std::string& str)\n        {\n            std::transform(\n                           str.begin(),\n                           str.end(),\n                           str.begin(),\n                           tolower);\n        }\n\n\n        //-----------------------------------------------------------------------\n        void ToUpperCase(std::string& str)\n        {\n            std::transform(\n                           str.begin(),\n                           str.end(),\n                           str.begin(),\n                           toupper);\n        }\n        \n        //-----------------------------------------------------------------------\n        void ToFirstLetterCapitalised(std::string& str)\n        {\n            std::string strLower=str;\n            std::string strUpper=str;\n            ToLowerCase(strLower);\n            ToUpperCase(strUpper);\n            if(strUpper.length() > 0)\n                str=strUpper.substr(0,1);\n            if(strLower.length() > 1)\n                str=str+strLower.substr(1,strLower.length()-1);\n        }\n        \n        //-----------------------------------------------------------------------\n        void ToPascalCase(std::string& str)\n        {\n            std::string strPascal;\n            std::string strChar;\n            bool bNewWord = true;\n            for(std::string::iterator it=str.begin(); it!=str.end(); ++it)\n            {\n                strChar=(*it);\n                if(strChar==\" \" || strChar==\"_\" || strChar==\"-\")\n                {\n                    bNewWord=true;\n                }\n                else\n                {\n                    if(bNewWord)\n                    {\n                        ToUpperCase(strChar);\n                    }\n                    else\n                    {\n                        ToLowerCase(strChar);\n                    }\n                    strPascal=strPascal+strChar;\n                    \n                    bNewWord=false;\n                }\n            }\n\n            str=strPascal;\n        }\n\n        //-----------------------------------------------------------------------\n        bool StartsWith(const std::string& str, const std::string& pattern, bool lowerCase)\n        {\n            size_t thisLen = str.length();\n            size_t patternLen = pattern.length();\n            if (thisLen < patternLen || patternLen == 0)\n                return false;\n\n            if (lowerCase)\n                return std::equal(pattern.begin(), pattern.end(), str.begin(), StringUtils::CaseInsensitiveCompare);\n            \n            return std::equal(pattern.begin(), pattern.end(), str.begin());\n        }\n\n\n        //-----------------------------------------------------------------------\n        bool EndsWith(const std::string& str, const std::string& pattern, bool lowerCase)\n        {\n            size_t thisLen = str.length();\n            size_t patternLen = pattern.length();\n            if (thisLen < patternLen || patternLen == 0)\n                return false;\n\n            if (lowerCase)\n                return std::equal(pattern.begin(), pattern.end(), str.begin() + (thisLen - patternLen), StringUtils::CaseInsensitiveCompare);\n\n            return std::equal(pattern.begin(), pattern.end(), str.begin() + (thisLen - patternLen));\n        }\n\n        //-----------------------------------------------------------------------\n        std::string StandardiseFilePath(const std::string& init)\n        {\n            std::string path = init;\n            std::replace( path.begin(), path.end(), '\\\\', '/' );\n\n            bool startsWithDoubleSlash = StartsWith(path, \"//\");\n            path = ReplaceAll(path, \"//\", \"/\");\n            ChopTrailingChars(path, '/');\n            \n            if (startsWithDoubleSlash)\n            {\n                path = \"/\" + path;\n            }\n\n            return path;\n        }\n        \n        //-----------------------------------------------------------------------\n        std::string StandardiseDirectoryPath(const std::string& init)\n        {\n            std::string path = init;\n            std::replace( path.begin(), path.end(), '\\\\', '/' );\n\n            bool startsWithDoubleSlash = StartsWith(path, \"//\");\n            path = ReplaceAll(path, \"//\", \"/\");\n            \n            if(!path.empty() && path.back() != '/')\n            {\n                TerminateStringWith(path, \"/\");\n            }\n\n            if (startsWithDoubleSlash)\n            {\n                path = \"/\" + path;\n            }\n            \n            return path;\n        }\n\n        //-----------------------------------------------------------------------\n        void SplitFilename(const std::string& qualifiedName,\n                                       std::string& outBasename, std::string& outPath)\n        {\n            std::string path = qualifiedName;\n            // Replace \\ with / first\n            std::replace( path.begin(), path.end(), '\\\\', '/' );\n            // split based on final /\n            size_t i = path.find_last_of('/');\n            \n            if (i == std::string::npos)\n            {\n                outPath.clear();\n                outBasename = qualifiedName;\n            }\n            else\n            {\n                outBasename = path.substr(i+1, path.size() - i - 1);\n                outPath = path.substr(0, i+1);\n            }\n            \n        }\n\n\n        //-----------------------------------------------------------------------\n        void SplitBaseFilename(const std::string& fullName,\n                                          std::string& outBasename, std::string& outExtention)\n        {\n            size_t i = fullName.find_last_of(\".\");\n            if (i == std::string::npos)\n            {\n                outExtention.clear();\n                outBasename = fullName;\n            }\n            else\n            {\n                outExtention = fullName.substr(i+1);\n                outBasename = fullName.substr(0, i);\n            }\n        }\n\n        // ----------------------------------------------------------------------------------------------------------------------------------------------\n        void SplitFullFilename(\tconst std::string& qualifiedName,\n                                           std::string& outBasename, std::string& outExtention, std::string& outPath )\n        {\n            std::string fullName;\n            SplitFilename( qualifiedName, fullName, outPath );\n            SplitBaseFilename( fullName, outBasename, outExtention );\n        }\n\n        //-----------------------------------------------------------------------\n        bool Match(const std::string& str, const std::string& pattern, bool caseSensitive)\n        {\n            std::string tmpStr = str;\n            std::string tmpPattern = pattern;\n            if (!caseSensitive)\n            {\n                StringUtils::ToLowerCase(tmpStr);\n                StringUtils::ToLowerCase(tmpPattern);\n            }\n            \n            std::string::const_iterator strIt = tmpStr.begin();\n            std::string::const_iterator patIt = tmpPattern.begin();\n            std::string::const_iterator lastWildCardIt = tmpPattern.end();\n            while (strIt != tmpStr.end() && patIt != tmpPattern.end())\n            {\n                if (*patIt == '*')\n                {\n                    lastWildCardIt = patIt;\n                    // Skip over looking for next character\n                    ++patIt;\n                    if (patIt == tmpPattern.end())\n                    {\n                        // Skip right to the end since * matches the entire rest of the string\n                        strIt = tmpStr.end();\n                    }\n                    else\n                    {\n                        // scan until we find next pattern character\n                        while(strIt != tmpStr.end() && *strIt != *patIt)\n                            ++strIt;\n                    }\n                }\n                else\n                {\n                    if (*patIt != *strIt)\n                    {\n                        if (lastWildCardIt != tmpPattern.end())\n                        {\n                            // The last wildcard can match this incorrect sequence\n                            // rewind pattern to wildcard and keep searching\n                            patIt = lastWildCardIt;\n                            lastWildCardIt = tmpPattern.end();\n                        }\n                        else\n                        {\n                            // no wildwards left\n                            return false;\n                        }\n                    }\n                    else\n                    {\n                        ++patIt;\n                        ++strIt;\n                    }\n                }\n                \n            }\n            // If we reached the end of both the pattern and the string, we succeeded\n            if (patIt == tmpPattern.end() && strIt == tmpStr.end())\n            {\n                return true;\n            }\n            else\n            {\n                return false;\n            }\n            \n        }\n\n        //-----------------------------------------------------------------------\n        const std::string ReplaceAll(const std::string& source, const std::string& replaceWhat, const std::string& replaceWithWhat)\n        {\n            std::string result = source;\n            while(1)\n            {\n                std::string::size_type pos = result.find(replaceWhat);\n                if (pos == std::string::npos) break;\n                result.replace(pos,replaceWhat.size(),replaceWithWhat);\n            }\n            return result;\n        }\n        \n        /** converts a string to a unix timestamp\n         */\n        TimeIntervalSecs ToTimestamp(const std::string& instrSource, StringTimeFormat ineFormat)\n        {\n            std::string strTime = instrSource;\n            std::string strFormat = kastrTimeFormat[(u32)ineFormat];\n            \n            if(StringTimeFormat::k_YYYYDDMMHHMM == ineFormat)\n            {\n                std::string::size_type pos = strFormat.find('-');\n                std::string strYear = strTime.substr(0, pos);\n                \n                strFormat = strFormat.substr(pos + 1, std::string::npos);\n                strTime = strTime.substr(pos + 1, std::string::npos);\n                pos = strFormat.find('-');\n                std::string strMonth = strTime.substr(0, pos);\n                \n                strFormat = strFormat.substr(pos + 1, std::string::npos);\n                strTime = strTime.substr(pos + 1, std::string::npos);\n                pos = strFormat.find('-');\n                std::string strDay = strTime.substr(0, pos);\n                \n                strFormat = strFormat.substr(pos + 1, std::string::npos);\n                strTime = strTime.substr(pos + 1, std::string::npos);\n                pos = strFormat.find(':');\n                std::string strHour = strTime.substr(0, pos);\n                \n                std::string strMins = strTime.substr(pos + 1, std::string::npos);\n                \n                return ToTimeIntervalSecs(strYear, strMonth, strDay, strHour, strMins, \"0\");\n            }\n            \n            return 0;\n        }\n        \n        bool CaseInsensitiveCompare(const char &inA, const char &inB)\n        {\n            return tolower(inA) == tolower(inB);\n        }\n        \n\n    \n        //-------------------------------------------------------\n        //-------------------------------------------------------\n        std::string InsertVariables(const std::string& in_text, const ParamDictionary& in_params)\n        {\n            std::string output;\n            \n            auto it = in_text.begin();\n            while(it < in_text.end())\n            {\n                auto character = UTF8StringUtils::Next(it);\n\n                if(character != '[')\n                {\n                    UTF8StringUtils::Append(character, output);\n                }\n                else\n                {\n                    // Found a mark up, check it\n                    ReplaceVariableRecursive(in_params, output, it);\n                }\n            }\n            \n            return output;\n        }\n\n        //-- Private\n        \n\n        //-----------------------------------------------------------------------\n        bool isNumber(const std::string& val)\n        {\n            std::istringstream str(val);\n            float tst;\n            str >> tst;\n            return !str.fail() && str.eof();\n        }\n        //----------------------------------------------------\n        //----------------------------------------------------\n        void ToCSV(const std::vector<std::string>& in_values, std::string& out_csv)\n        {\n            if(in_values.empty())\n                return;\n            \n            CS_ASSERT(in_values.size() < static_cast<std::size_t>(std::numeric_limits<u32>::max()), \"Too many CSV items. It cannot exceed \" + ToString(std::numeric_limits<u32>::max()) + \".\");\n            \n            u32 numVals = static_cast<u32>(in_values.size()) - 1;\n            for(u32 i=0; i<numVals; ++i)\n            {\n                out_csv += in_values[i];\n                out_csv += \",\";\n            }\n            \n            //Add the last one without a following comma\n            out_csv += in_values[numVals];\n        }\n        //---------------------------------------------------------\n        //---------------------------------------------------------\n        std::string URLEncode(const std::string& instrURL)\n        {\n            std::string strEscaped;\n            \n            u32 dwMax = static_cast<s32>(instrURL.length());\n            for(u32 i = 0; i < dwMax; i++)\n            {\n                if( (48 <= instrURL[i] && instrURL[i] <= 57) ||\t\t\t// 0-9\n                   (65 <= instrURL[i] && instrURL[i] <= 90) ||\t\t\t// ABC...XYZ\n                   (97 <= instrURL[i] && instrURL[i] <= 122) || \t\t// abc...xyz\n                   (instrURL[i]=='~' || instrURL[i]=='-' || instrURL[i]=='_' || instrURL[i]=='.') )\n                {\n                    strEscaped.append(&instrURL[i], 1);\n                }\n                else\n                {\n                    strEscaped.append(\"%\");\n                    strEscaped.append(StringUtils::CharToHex((u8)instrURL[i])); // Converts char 255 to string \"FF\"\n                }\n            }\n            \n            return strEscaped;\n        }\n        //---------------------------------------------------------\n        //---------------------------------------------------------\n        std::string URLDecode(const std::string& instrSrc)\n        {\n            // Note from RFC1630: \"Sequences which start with a percent\n            // sign but are not followed by two hexadecimal characters\n            // (0-9, A-F) are reserved for future extension\"\n            \n            const unsigned char* pSrc = (const unsigned char*)instrSrc.c_str();\n            const u32 udwSourceLength = static_cast<u32>(instrSrc.length());\n            const unsigned char* const pSourceEnd = pSrc + udwSourceLength;\n            // last decodable '%'\n            const unsigned char* const pSourceLastDecode = pSourceEnd - 2;\n            \n            char* const pStart = new char[udwSourceLength];\n            char* pEnd = pStart;\n            \n            while(pSrc < pSourceLastDecode)\n            {\n                if(*pSrc == '%')\n                {\n                    char dec1 = static_cast<char>(Utils::HexToDec((pSrc + 1)));\n                    char dec2 = static_cast<char>(Utils::HexToDec((pSrc + 2)));\n                    if(-1 != dec1 && -1 != dec2)\n                    {\n                        *pEnd++ = (dec1 << 4) + dec2;\n                        pSrc += 3;\n                        continue;\n                    }\n                }\n                *pEnd++ = *pSrc++;\n            }\n            \n            // the last 2- chars\n            while(pSrc < pSourceEnd)\n            {\n                *pEnd++ = *pSrc++;\n            }\n            \n            std::string sResult(pStart, pEnd);\n            delete [] pStart;\n            return sResult;\n        }\n        //---------------------------------------------------------\n        //---------------------------------------------------------\n        std::string CharToHex(u8 inubyDec)\n        {\n            u8 ubyDig1 = (inubyDec&0xF0) >> 4;\n            u8 ubyDig2 = (inubyDec&0x0F);\n            if ( 0 <= ubyDig1 && ubyDig1 <= 9) ubyDig1 += 48;    \t\t// 0,48 in ASCII\n            if (10 <= ubyDig1 && ubyDig1 <=15) ubyDig1 += 65 - 10; \t\t// A,65 in ASCII\n            if ( 0 <= ubyDig2 && ubyDig2 <= 9) ubyDig2 += 48;\n            if (10 <= ubyDig2 && ubyDig2 <=15) ubyDig2 += 65 - 10;\n            \n            std::string strResult;\n            strResult.append((char*)&ubyDig1, 1);\n            strResult.append((char*)&ubyDig2, 1);\n            \n            return strResult;\n        }\n        //-------------------------------------------------------\n        //-------------------------------------------------------\n        std::string ResolveParentedDirectories(const std::string& in_relPath)\n        {\n            std::string standardRelPath = StandardiseFilePath(in_relPath);\n            \n            std::vector<std::string> relDirs = Split(standardRelPath, \"/\");\n            \n            for(u32 i=0; i<relDirs.size(); )\n            {\n                if(relDirs[i] == \"..\")\n                {\n                    CS_ASSERT(i > 0, \"StringUtils::ResolveParentedDirectories Cannot go up directories beyond the root\");\n                    relDirs.erase(relDirs.begin() + i);\n                    relDirs.erase(relDirs.begin() + i - 1);\n                    --i;\n                }\n                else\n                {\n                    ++i;\n                }\n            }\n\n            std::string absPath;\n            \n            if(relDirs.size() > 0)\n            {\n                for(u32 i=0; i<relDirs.size()-1; ++i)\n                {\n                    absPath += relDirs[i] + \"/\";\n                }\n            \n                absPath += relDirs.back();\n            }\n            \n            return absPath;\n        }\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Core/String/StringUtils.h",
    "content": "//\n//  StringUtils.h\n//  ChilliSource\n//  Created by Stuart McGaw on 25/10/2010.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2010 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_STRINGUTILITIES_H_\n#define _CHILLISOURCE_CORE_STRINGUTILITIES_H_\n\n#include <ChilliSource/ChilliSource.h>\n\n#include <sstream>\n#include <string>\n#include <vector>\n\nnamespace ChilliSource\n{\n    /** Utility class for manipulating Strings.  */\n    namespace StringUtils\n    {\n        typedef std::stringstream StrStreamType;\n\n        enum class StringTimeFormat\n        {\n            k_YYYYDDMMHHMM,\n            k_total\n        };\n        \n        /// Constant blank string, useful for returning by ref where local does not exist\n        const std::string BLANK;\n        \n        /** Removes any whitespace characters, be it standard space or\n         TABs and so on.\n         @remarks\n         The user may specify wether they want to trim only the\n         beginning or the end of the String ( the default action is\n         to trim both).\n         */\n        void Trim( std::string& str, bool left = true, bool right = true );\n        \n        /** Remove the number of characters from the end of the string.\n         */\n        void Chop( std::string& str, u32 inudwNumCharacters);\n        \n        /** Remove any of the given chars from the end of the string.\n         */\n        void ChopTrailingChars( std::string& str, s8 inbyChar);\n\n        /** Ensures the input string is terminated by a singular instance of\n         inputted terminator\n         @param \n         delims The string to terminate\n         @param\n         delims The string used to terminate first string\n         */\n        void TerminateStringWith(std::string& instrMain, const std::string & instrEnding);\n        \n        /** Returns a StringVector that contains all the substrings delimited\n         by the characters in the passed <code>delims</code> argument.\n         @param\n         delims A list of delimiter characters to split by\n         @param\n         maxSplits The maximum number of splits to perform (0 for unlimited splits). If this\n         parameters is > 0, the splitting process will stop after this many splits, left to right.\n         */\n        std::vector< std::string > Split( const std::string& str, const std::string& delims = \"\\t\\n \", unsigned int maxSplits = 0);\n\n        /** Returns a StringVector that contains all the substrings delimited\n         by the characters in the passed <code>delims</code> argument, \n         or in the <code>doubleDelims</code> argument, which is used to include (normal) \n         delimeters in the tokenised string. For example, \"strings like this\".\n         @param\n         delims A list of delimiter characters to split by\n         @param\n         delims A list of double delimeters characters to tokenise by\n         @param\n         maxSplits The maximum number of splits to perform (0 for unlimited splits). If this\n         parameters is > 0, the splitting process will stop after this many splits, left to right.\n         */\n        std::vector< std::string > Tokenise( const std::string& str, const std::string& delims = \"\\t\\n \", const std::string& doubleDelims = \"\\\"\", unsigned int maxSplits = 0);\n\n        /** Lower-cases all the characters in the string.\n         */\n        void ToLowerCase( std::string& str );\n\n        /** Upper-cases all the characters in the string.\n         */\n        void ToUpperCase( std::string& str );\n\n        /** Upper-cases first character, Lower-cases the rest.\n         */\n        void ToFirstLetterCapitalised( std::string& str );\n        \n        /** Performs first letter capitalisation on each word\n         ** and removes space characters.\n         */\n        void ToPascalCase( std::string& str );\n\n        /** Returns whether the string begins with the pattern passed in.\n         @param pattern The pattern to compare with.\n         @param lowerCase If true, the start of the string will be lower cased before\n         comparison, pattern should also be in lower case.\n         */\n        bool StartsWith(const std::string& str, const std::string& pattern, bool lowerCase = true);\n\n        /** Returns whether the string ends with the pattern passed in.\n         @param pattern The pattern to compare with.\n         @param lowerCase If true, the end of the string will be lower cased before\n         comparison, pattern should also be in lower case.\n         */\n        bool EndsWith(const std::string& str, const std::string& pattern, bool lowerCase = true);\n\n        /** Method for standardising file paths - use forward slashes only, removes trailing slashes\n         */\n        std::string StandardiseFilePath( const std::string &init);\n        \n        /** Method for standardising directory paths - use forward slashes only, end with slash.\n         */\n        std::string StandardiseDirectoryPath( const std::string &init);\n\n        /** Method for splitting a fully qualified filename into the base name\n         and path.\n         @remarks\n         Path is standardised as in standardisePath\n         */\n        void SplitFilename(const std::string& qualifiedName, std::string& outBasename, std::string& outPath);\n\n        /** Method for splitting a fully qualified filename into the base name,\n         extension and path.\n         @remarks\n         Path is standardised as in standardisePath\n         */\n        void SplitFullFilename(const std::string& qualifiedName, std::string& outBasename, std::string& outExtention, std::string& outPath);\n        \n        /** Method for splitting a filename into the base name\n         and extension.\n         */\n        void SplitBaseFilename(const std::string& fullName, std::string& outBasename, std::string& outExtention);\n        \n        /** Simple pattern-matching routine allowing a wildcard pattern.\n         @param str String to test\n         @param pattern Pattern to match against; can include simple '*' wildcards\n         @param caseSensitive Whether the match is case sensitive or not\n         */\n        bool Match(const std::string& str, const std::string& pattern, bool caseSensitive = true);\n\n        /** replace all instances of a sub-string with a another sub-string.\n         @param source Source string\n         @param replaceWhat Sub-string to find and replace\n         @param replaceWithWhat Sub-string to replace with (the new sub-string)\n         @returns An updated string with the sub-string replaced\n         */\n        const std::string ReplaceAll(const std::string& source, const std::string& replaceWhat, const std::string& replaceWithWhat);\n\n        /** converts a string to a unix timestamp\n         @param source String to convert to unix timestamp\n         @param format Format of source string\n         @return unix timestamp or 0\n         */\n        TimeIntervalSecs ToTimestamp(const std::string& instrSource, StringTimeFormat ineFormat);\n        \n        // Utility function for comparing two characters in a case insensitive way\n        bool CaseInsensitiveCompare(const char & inA, const char & inB);\n        \n        //-------------------------------------------------------\n        /// Inserts variables into the given string with the\n        /// values using basic markup. The markup is in the form\n        /// [var=VariablenName], and the value for the variable is\n        /// looked up in the given param dictionary.\n        ///\n        /// For example \"Time remaining: [var=TimeRemaining]\" with\n        /// a param dictionary containig \"TimeRemaining\"=\"12\" will\n        /// become \"Time Remaining: 12\".\n        ///\n        /// The markup is also recursive, meaning that the\n        /// following is valid: \"[var=TextValue[var=ValueIndex]]\".\n        ///\n        /// @param N Tanda\n        ///\n        /// @param The UTF-8 string which contains the markup.\n        /// @param The param dictionary containing the variables.\n        ///\n        /// @return The output formatted UTF-8 string.\n        //-------------------------------------------------------\n        std::string InsertVariables(const std::string& in_text, const ParamDictionary& in_params);\n        \n        /** Checks the std::string is a inValid number inValue. */\n        bool isNumber(const std::string& inVal);\n        \n        //----------------------------------------------------\n        /// Convert a list of string values to a CSV string\n        ///\n        /// @author S Downie\n        ///\n        /// @param List of values\n        /// @param [Out] CSV string\n        //----------------------------------------------------\n        void ToCSV(const std::vector<std::string>& in_values, std::string& out_csv);\n        //-------------------------------------------------------\n        /// Encodes a URL to use correct escape values\n        ///\n        /// @param String to URL encode\n        ///\n        /// @return URL encoded string\n        //------------------------------------------------------\n        std::string URLEncode(const std::string& in_url);\n        //------------------------------------------------------\n        /// @param String to URL decode\n        ///\n        /// @return decoded string\n        //------------------------------------------------------\n        std::string URLDecode(const std::string& in_src);\n        //-------------------------------------------------------\n        /// Converts a value in the range [0,255] to hex value\n        ///\n        /// @author S Downie\n        ///\n        /// @param Integer value in range [0,255]\n        ///\n        /// @return String hex representation of integer\n        //-------------------------------------------------------\n        std::string CharToHex(u8 in_dec);\n        //-------------------------------------------------------\n        /// Resolves \"..\" parented directories in paths relative\n        /// to the root.\n        ///\n        /// NOTE: In CS even absolute paths are relative to the sandboxed\n        /// storage locations and it is forbidden to go \"up\" beyond the root\n        /// of each storage location.\n        ///\n        /// Examples:\n        ///     \"A/B.ext\" -> \"A/B.ext\"\n        ///     \"A/../B.ext\" -> \"B.ext\"\n        ///     \"A/../../B.ext\" -> Assert\n        ///\n        /// @author S Downie\n        ///\n        /// @param File path containing parented links (\"..\")\n        ///\n        /// @return File path with \"..\" resolved\n        //-------------------------------------------------------\n        std::string ResolveParentedDirectories(const std::string& in_relPath);\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/String/ToString.cpp",
    "content": "//\n//  ToString.cpp\n//  ChilliSource\n//  Created by Ian Copland on 25/02/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Core/String/ToString.h>\n\n#include <ChilliSource/Core/Base/Colour.h>\n#include <ChilliSource/Core/File/FileSystem.h>\n#include <ChilliSource/Core/Math/Matrix4.h>\n#include <ChilliSource/Core/Math/Quaternion.h>\n#include <ChilliSource/Core/Math/Vector2.h>\n#include <ChilliSource/Core/Math/Vector3.h>\n#include <ChilliSource/Core/Math/Vector4.h>\n\n#include <sstream>\n\nnamespace ChilliSource\n{\n    //---------------------------------------------------------\n    //---------------------------------------------------------\n    std::string ToString(f32 in_value, u16 in_precision, u16 in_width, s8 in_fill, std::ios::fmtflags in_flags)\n    {\n        std::stringstream stream;\n        stream.precision(in_precision);\n        stream.width(in_width);\n        stream.fill(in_fill);\n        if (in_flags)\n            stream.setf(in_flags);\n        stream << in_value;\n        return stream.str();\n    }\n    //---------------------------------------------------------\n    //---------------------------------------------------------\n    std::string ToString(f64 in_value, u16 in_precision, u16 in_width, s8 in_fill, std::ios::fmtflags in_flags)\n    {\n        std::stringstream stream;\n        stream.precision(in_precision);\n        stream.width(in_width);\n        stream.fill(in_fill);\n        if (in_flags)\n            stream.setf(in_flags);\n        stream << in_value;\n        return stream.str();\n    }\n    //---------------------------------------------------------\n    //---------------------------------------------------------\n    std::string ToString(s32 in_value, u16 in_width, s8 in_fill, std::ios::fmtflags in_flags)\n    {\n        std::stringstream stream;\n        stream.width(in_width);\n        stream.fill(in_fill);\n        if (in_flags)\n            stream.setf(in_flags);\n        stream << in_value;\n        return stream.str();\n    }\n    //---------------------------------------------------------\n    //---------------------------------------------------------\n    std::string ToString(s32 in_value)\n    {\n        s8 buffer[16];\n        u32 size = CS_SPRINTF(buffer, \"%d\", in_value);\n        return std::string(buffer, buffer + size);\n    }\n    //---------------------------------------------------------\n    //---------------------------------------------------------\n    std::string ToString(u32 in_value, u16 in_width, s8 in_fill, std::ios::fmtflags in_flags)\n    {\n        std::stringstream stream;\n        stream.width(in_width);\n        stream.fill(in_fill);\n        if (in_flags)\n            stream.setf(in_flags);\n        stream << in_value;\n        return stream.str();\n    }\n    //---------------------------------------------------------\n    //---------------------------------------------------------\n    std::string ToString(u32 in_value)\n    {\n        s8 buffer[16];\n        u32 size = CS_SPRINTF(buffer, \"%d\", in_value);\n        return std::string(buffer, buffer + size);\n    }\n    //---------------------------------------------------------\n    //---------------------------------------------------------\n    std::string ToString(s64 in_value, u16 in_width, s8 in_fill, std::ios::fmtflags in_flags)\n    {\n        std::stringstream stream;\n        stream.width(in_width);\n        stream.fill(in_fill);\n        if (in_flags)\n            stream.setf(in_flags);\n        stream << in_value;\n        return stream.str();\n    }\n    //---------------------------------------------------------\n    //---------------------------------------------------------\n    std::string ToString(u64 in_value, u16 in_width, s8 in_fill, std::ios::fmtflags in_flags)\n    {\n        std::stringstream stream;\n        stream.width(in_width);\n        stream.fill(in_fill);\n        if (in_flags)\n            stream.setf(in_flags);\n        stream << in_value;\n        return stream.str();\n    }\n    //---------------------------------------------------------\n    //---------------------------------------------------------\n    std::string ToString(bool in_value, bool in_yesNo)\n    {\n        if (in_value)\n        {\n            if (in_yesNo)\n            {\n                return \"yes\";\n            }\n            else\n            {\n                return \"true\";\n            }\n        }\n        else\n        {\n            if (in_yesNo)\n            {\n                return \"no\";\n            }\n            else\n            {\n                return \"false\";\n            }\n        }\n    }\n    //---------------------------------------------------------\n    //---------------------------------------------------------\n    std::string ToString(const Vector2& in_value)\n    {\n        std::stringstream stream;\n        stream << in_value.x << \" \" << in_value.y;\n        return stream.str();\n    }\n    //---------------------------------------------------------\n    //---------------------------------------------------------\n    std::string ToString(const Vector3& in_value)\n    {\n        std::stringstream stream;\n        stream << in_value.x << \" \" << in_value.y << \" \" << in_value.z;\n        return stream.str();\n    }\n    //---------------------------------------------------------\n    //---------------------------------------------------------\n    std::string ToString(const Vector4& in_value)\n    {\n        std::stringstream stream;\n        stream << in_value.x << \" \" << in_value.y << \" \" << in_value.z << \" \" << in_value.w;\n        return stream.str();\n    }\n    \n    //---------------------------------------------------------\n    std::string ToString(const Integer2& value)\n    {\n        std::stringstream stream;\n        stream << value.x << \" \" << value.y;\n        return stream.str();\n    }\n    \n    //---------------------------------------------------------\n    std::string ToString(const Integer3& value)\n    {\n        std::stringstream stream;\n        stream << value.x << \" \" << value.y << \" \" << value.z;\n        return stream.str();\n    }\n    \n    //---------------------------------------------------------\n    std::string ToString(const Integer4& value)\n    {\n        std::stringstream stream;\n        stream << value.x << \" \" << value.y << \" \" << value.z << \" \" << value.w;\n        return stream.str();\n    }\n    \n    //---------------------------------------------------------\n    //---------------------------------------------------------\n    std::string ToString(const Matrix4& in_value)\n    {\n        std::stringstream stream;\n        stream << in_value.m[0] << \" \"\n        << in_value.m[1] << \" \"\n        << in_value.m[2] << \" \"\n        << in_value.m[3] << \" \"\n        << in_value.m[4] << \" \"\n        << in_value.m[5] << \" \"\n        << in_value.m[6] << \" \"\n        << in_value.m[7] << \" \"\n        << in_value.m[8] << \" \"\n        << in_value.m[9] << \" \"\n        << in_value.m[10] << \" \"\n        << in_value.m[11] << \" \"\n        << in_value.m[12] << \" \"\n        << in_value.m[13] << \" \"\n        << in_value.m[14] << \" \"\n        << in_value.m[15];\n        return stream.str();\n    }\n    //---------------------------------------------------------\n    //---------------------------------------------------------\n    std::string ToString(const Quaternion& in_value)\n    {\n        std::stringstream stream;\n        stream  << in_value.w << \" \" << in_value.x << \" \" << in_value.y << \" \" << in_value.z;\n        return stream.str();\n    }\n    //---------------------------------------------------------\n    //---------------------------------------------------------\n    std::string ToString(const Colour& in_value)\n    {\n        std::stringstream stream;\n        stream << in_value.r << \" \" << in_value.g << \" \" << in_value.b << \" \" << in_value.a;\n        return stream.str();\n    }\n    //---------------------------------------------------------\n    //---------------------------------------------------------\n    std::string ToString(const StorageLocation& in_storageLocation)\n    {\n        switch (in_storageLocation)\n        {\n            case StorageLocation::k_package:\n                return \"Package\";\n            case StorageLocation::k_saveData:\n                return \"SaveData\";\n            case StorageLocation::k_cache:\n                return \"Cache\";\n            case StorageLocation::k_DLC:\n                return \"DLC\";\n            case StorageLocation::k_chilliSource:\n                return \"ChilliSource\";\n            default:\n                return \"\";\n        }\n    }\n    \n#ifdef CS_TARGETPLATFORM_IOS\n    //---------------------------------------------------------\n    //---------------------------------------------------------\n    std::string ToString(size_t in_value)\n    {\n        return ToString(static_cast<u32>(in_value));\n    }\n#endif\n}\n"
  },
  {
    "path": "Source/ChilliSource/Core/String/ToString.h",
    "content": "//\n//  ToString.h\n//  ChilliSource\n//  Created by Ian Copland on 25/02/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_STRING_TOSTRING_H_\n#define _CHILLISOURCE_CORE_STRING_TOSTRING_H_\n\n#include <ChilliSource/ChilliSource.h>\n\n#include <string>\n#include <iostream>\n\nnamespace ChilliSource\n{\n    //---------------------------------------------------------\n    /// Converts a 32 bit float to a string.\n    ///\n    /// @author Ian Copland\n    ///\n    /// @param The float value.\n    /// @param The precision to use.\n    /// @param The minimum width of the string.\n    /// @param The char used to pad strings smaller than the\n    /// width.\n    /// @param The format flags.\n    ///\n    /// @return The value as a string.\n    //---------------------------------------------------------\n    std::string ToString(f32 in_value, u16 in_precision = 6, u16 in_width = 0, s8 in_fill = ' ', std::ios::fmtflags in_flags = std::ios::fmtflags(0));\n    //---------------------------------------------------------\n    /// Converts a 64 bit float to a string.\n    ///\n    /// @author Ian Copland\n    ///\n    /// @param The float value.\n    /// @param The precision to use.\n    /// @param The minimum width of the string.\n    /// @param The char used to pad strings smaller than the\n    /// width.\n    /// @param The format flags.\n    ///\n    /// @return The value as a string.\n    //---------------------------------------------------------\n    std::string ToString(f64 in_value, u16 in_precision = 6, u16 in_width = 0, s8 in_fill = ' ', std::ios::fmtflags in_flags = std::ios::fmtflags(0));\n    //---------------------------------------------------------\n    /// Converts a 32 bit signed integer to a string.\n    ///\n    /// @author Ian Copland\n    ///\n    /// @param The integer value.\n    /// @param The minimum width of the string.\n    /// @param The char used to pad strings smaller than the\n    /// width.\n    /// @param The format flags.\n    \n    /// @return The value as a string.\n    //---------------------------------------------------------\n    std::string ToString(s32 in_value, u16 in_width, s8 in_fill = ' ', std::ios::fmtflags in_flags = std::ios::fmtflags(0));\n    //---------------------------------------------------------\n    /// Converts a 32 bit signed integer to a string.\n    ///\n    /// @author Ian Copland\n    ///\n    /// @param The integer value.\n    ///\n    /// @return The value as a string.\n    //---------------------------------------------------------\n    std::string ToString(s32 in_val);\n    //---------------------------------------------------------\n    /// Converts a 32 bit unsigned integer to a string.\n    ///\n    /// @author Ian Copland\n    ///\n    /// @param The integer value.\n    /// @param The minimum width of the string.\n    /// @param The char used to pad strings smaller than the\n    /// width.\n    /// @param The format flags.\n    ///\n    /// @return The value as a string.\n    //---------------------------------------------------------\n    std::string ToString(u32 in_value, u16 in_width, s8 in_fill = ' ', std::ios::fmtflags in_flags = std::ios::fmtflags(0));\n    //---------------------------------------------------------\n    /// Converts a 32 bit unsigned integer to a string.\n    ///\n    /// @author Ian Copland\n    ///\n    /// @param The integer value.\n    ///\n    /// @return The value as a string.\n    //---------------------------------------------------------\n    std::string ToString(u32 in_value);\n    //---------------------------------------------------------\n    /// Converts a 64 bit signed integer to a string.\n    ///\n    /// @author Ian Copland\n    ///\n    /// @param The integer value.\n    /// @param The minimum width of the string.\n    /// @param The char used to pad strings smaller than the\n    /// width.\n    /// @param The format flags.\n    ///\n    /// @return The value as a string.\n    //---------------------------------------------------------\n    std::string ToString(s64 in_value, u16 in_width = 0, s8 in_fill = ' ', std::ios::fmtflags in_flags = std::ios::fmtflags(0));\n    //---------------------------------------------------------\n    /// Converts a 64 bit signed integer to a string.\n    ///\n    /// @author Ian Copland\n    ///\n    /// @param The integer value.\n    /// @param The minimum width of the string.\n    /// @param The char used to pad strings smaller than the\n    /// width.\n    /// @param The format flags.\n    ///\n    /// @return The value as a string.\n    //---------------------------------------------------------\n    std::string ToString(u64 in_value, u16 in_width = 0, s8 in_fill = ' ', std::ios::fmtflags in_flags = std::ios::fmtflags(0));\n    //---------------------------------------------------------\n    /// Converts a boolean to a string.\n    ///\n    /// @author Ian Copland\n    ///\n    /// @param The boolean value.\n    /// @param If this is true the result given will be \"yes\"\n    /// and \"no\" instead of \"true\" and \"false\".\n    ///\n    /// @return The value as a string.\n    //---------------------------------------------------------\n    std::string ToString(bool in_value, bool in_yesNo = false);\n    //---------------------------------------------------------\n    /// Converts a 2 component vector to a string.\n    ///\n    /// @author Ian Copland\n    ///\n    /// @param The vector value.\n    ///\n    /// @return The value as a string.\n    //---------------------------------------------------------\n    std::string ToString(const Vector2& in_value);\n    //---------------------------------------------------------\n    /// Converts a 3 component vector to a string.\n    ///\n    /// @author Ian Copland\n    ///\n    /// @param The vector value.\n    ///\n    /// @return The value as a string.\n    //---------------------------------------------------------\n    std::string ToString(const Vector3& in_value);\n    //---------------------------------------------------------\n    /// Converts a 4 component vector to a string.\n    ///\n    /// @author Ian Copland\n    ///\n    /// @param The vector value.\n    ///\n    /// @return The value as a string.\n    //---------------------------------------------------------\n    std::string ToString(const Vector4& in_value);\n    \n    /// Converts a 2 component integer vector to a string.\n    ///\n    /// @param value\n    ///     The vector value.\n    ///\n    /// @return The value as a string.\n    ///\n    std::string ToString(const Integer2& value);\n    \n    /// Converts a 3 component integer vector to a string.\n    ///\n    /// @param value\n    ///     The vector value.\n    ///\n    /// @return The value as a string.\n    ///\n    std::string ToString(const Integer3& value);\n\n    /// Converts a 4 component integer vector to a string.\n    ///\n    /// @param value\n    ///     The vector value.\n    ///\n    /// @return The value as a string.\n    ///\n    std::string ToString(const Integer4& value);\n    \n    //---------------------------------------------------------\n    /// Converts a 4x4 matrix to a string.\n    ///\n    /// @author Ian Copland\n    ///\n    /// @param The matrix value.\n    ///\n    /// @return The value as a string.\n    //---------------------------------------------------------\n    std::string ToString(const Matrix4& in_value);\n    //---------------------------------------------------------\n    /// Converts a quaternion to a string.\n    ///\n    /// @author Ian Copland\n    ///\n    /// @param The quaternion value.\n    ///\n    /// @return The value as a string.\n    //---------------------------------------------------------\n    std::string ToString(const Quaternion& in_value);\n    //---------------------------------------------------------\n    /// Converts a colour to a string.\n    ///\n    /// @author Ian Copland\n    ///\n    /// @param The colour value.\n    ///\n    /// @return The value as a string.\n    //---------------------------------------------------------\n    std::string ToString(const Colour& in_value);\n    //---------------------------------------------------------\n    /// Converts a storage location value to a string.\n    ///\n    /// @author Ian Copland\n    ///\n    /// @param The storage location value.\n    ///\n    /// @return The value as a string.\n    //---------------------------------------------------------\n    std::string ToString(const StorageLocation& in_storageLocation);\n    \n#ifdef CS_TARGETPLATFORM_IOS\n    //---------------------------------------------------------\n    /// Converts a size_t to a string.\n    ///\n    /// @author Ian Copland\n    ///\n    /// @param The size_t value.\n    ///\n    /// @return The value as a string.\n    //---------------------------------------------------------\n    std::string ToString(size_t in_value);\n#endif\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/String/UTF8StringUtils.cpp",
    "content": "//\n//  UTF8StringUtils.cpp\n//  ChilliSource\n//  Created by Scott Downie on 26/05/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Core/String/UTF8StringUtils.h>\n\nnamespace ChilliSource\n{\n    namespace UTF8StringUtils\n    {\n        //-----------------------------------------------------\n        //-----------------------------------------------------\n        std::string AppendCopy(UTF8Char in_char, const std::string& in_string)\n        {\n            std::string result(in_string);\n            Append(in_char, result);\n            return result;\n        }\n        //-----------------------------------------------------\n        //-----------------------------------------------------\n        void Append(UTF8Char in_char, std::string& out_appendedResult)\n        {\n            //Single byte code (ASCII)\n            if(in_char <= 0x7F)\n            {\n                out_appendedResult.reserve(1);\n                out_appendedResult +=((in_char>>0) & 0x7F);\n            }\n            //Two byte code\n            else if(in_char <= 0x7FF)\n            {\n                out_appendedResult.reserve(2);\n                out_appendedResult += 0xC0 | ((in_char>>6) & 0x1F);\n                out_appendedResult += 0x80 | ((in_char) & 0x3F);\n\n            }\n            //Three byte code\n            else if(in_char <= 0xFFFF)\n            {\n                out_appendedResult.reserve(3);\n                out_appendedResult += 0xE0 | ((in_char>>12) & 0x0F);\n                out_appendedResult += 0x80 | ((in_char>>6) & 0x3F);\n                out_appendedResult += 0x80 | ((in_char) & 0x3F);\n\n            }\n            //Four byte code\n            else if(in_char <= 0x1FFFFF)\n            {\n                out_appendedResult.reserve(4);\n                out_appendedResult += 0xF0 | ((in_char>>18) & 0x07);\n                out_appendedResult += 0x80 | ((in_char>>12) & 0x3F);\n                out_appendedResult += 0x80 | ((in_char>>6) & 0x3F);\n                out_appendedResult += 0x80 | ((in_char) & 0x3F);\n            }\n            //Invalid format\n            else\n            {\n                CS_LOG_FATAL(\"Invalid UTF8 format\");\n            }\n        }\n        //-----------------------------------------------------\n        //-----------------------------------------------------\n        std::string SubString(const std::string& in_string, u32 in_start, u32 in_length)\n        {\n            if (in_length == 0)\n            {\n                return \"\";\n            }\n            \n            std::size_t start = in_start;\n            std::size_t length = in_length;\n            std::size_t codePointStart = std::string::npos;\n            std::size_t codePointLength = std::string::npos;\n            std::size_t numCodePoints = in_string.length();\n            \n            u32 codePointIdx = 0;\n            for (u32 charIdx=0; charIdx<numCodePoints; ++charIdx, ++codePointIdx)\n            {\n                if (codePointIdx == in_start)\n                {\n                    codePointStart = charIdx;\n                }\n                \n                if (codePointIdx <= start + length || length == std::string::npos)\n                {\n                    codePointLength = charIdx;\n                }\n                \n                UTF8Char character = (UTF8Char)in_string[charIdx];\n                if (character <= 127)\n                {\n                    charIdx += 0;\n                }\n                else if ((character & 0xE0) == 0xC0)\n                {\n                    charIdx += 1;\n                }\n                else if ((character & 0xF0) == 0xE0)\n                {\n                    charIdx += 2;\n                }\n                else if ((character & 0xF8) == 0xF0)\n                {\n                    charIdx += 3;\n                }\n                else\n                {\n                    CS_LOG_FATAL(\"Invalid UTF8 format\");\n                }\n            }\n            \n            if (codePointIdx <= start + length || length == std::string::npos)\n            {\n                codePointLength = numCodePoints;\n            }\n            if (codePointStart == std::string::npos || codePointLength == std::string::npos)\n            {\n                return \"\";\n            }\n        \n            return in_string.substr(codePointStart, codePointLength);\n        }\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Core/String/UTF8StringUtils.h",
    "content": "//\n//  UTF8StringUtils.h\n//  ChilliSource\n//  Created by Scott Downie on 26/05/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_STRING_UTF8STRINGUTILS_H_\n#define _CHILLISOURCE_CORE_STRING_UTF8STRINGUTILS_H_\n\n#include <ChilliSource/ChilliSource.h>\n\nnamespace ChilliSource\n{\n    using UTF8Char = u32;\n    \n    //---------------------------------------------------------\n    /// Utility methods for accessing a list of code points as\n    /// a UTF8 encoded string (often a std::string).\n    /// UTF8 characters range in size from 1 byte to 4 bytes\n    /// depending on the number of code points.\n    /// ASCII and UTF8 have a direct mapping.\n    ///\n    /// @author S Downie\n    //---------------------------------------------------------\n    namespace UTF8StringUtils\n    {\n        //-----------------------------------------------------\n        /// Return the next UTF-8 character in the sequence\n        /// from the current iterator and advance the iterator\n        /// by a character.\n        ///\n        /// NOTE: This will not perform any bounds checking on\n        /// the container.\n        ///\n        /// @author S Downie\n        ///\n        /// @param Current iterator which is advanced\n        ///\n        /// @return UTF8 character pointed to by iterator prior\n        /// to advancing\n        //-----------------------------------------------------\n        template<typename TCodePointIter> UTF8Char Next(TCodePointIter& inout_currentIt)\n        {\n            UTF8Char result = 0;\n            \n            s8 firstCodePoint = (*inout_currentIt);\n            \n            //Single byte code (ASCII)\n            if(firstCodePoint > 0)\n            {\n                //Just return the code point\n                result = (UTF8Char)firstCodePoint;\n                ++inout_currentIt;\n                return result;\n            }\n            \n            switch(0xF0 & firstCodePoint)\n            {\n                case 0xE0:\n                    result =  (*inout_currentIt & 0x0F) << 12;\n                    ++inout_currentIt;\n                    result |= (*inout_currentIt & 0x3F) << 6;\n                    ++inout_currentIt;\n                    result |= (*inout_currentIt & 0x3F);\n                    ++inout_currentIt;\n                    break;\n                case 0xF0:\n                    result =  (*inout_currentIt & 0x07) << 18;\n                    ++inout_currentIt;\n                    result |= (*inout_currentIt & 0x3F) << 12;\n                    ++inout_currentIt;\n                    result |= (*inout_currentIt & 0x3F) << 6;\n                    ++inout_currentIt;\n                    result |= (*inout_currentIt & 0x3F);\n                    ++inout_currentIt;\n                    break;\n                default:\n                    result =  (*inout_currentIt & 0x1F) << 6;\n                    ++inout_currentIt;\n                    result |= (*inout_currentIt & 0x3F);\n                    ++inout_currentIt;\n                    break;\n            }\n            \n            return result;\n        }\n        //-----------------------------------------------------\n        /// Calculate the number of UTF-8 characters based on\n        /// list of codepoints between the start and end\n        /// iteration points\n        ///\n        /// @author S Downie\n        ///\n        /// @param Begin iterator\n        /// @param End iterator\n        ///\n        /// @return Number of characters between begin and end\n        //-----------------------------------------------------\n        template<typename TCodePointIter> u32 CalcLength(TCodePointIter in_begin, TCodePointIter in_end)\n        {\n            //UTF-8 is a multi-byte standard which means the characters\n            //are not fixed length but each character contains the 'trail' bytes bit pattern of 10xxxxxx.\n            //We can calculate the length by counting the number of 'trail' bytes\n            u32 length = 0;\n            for (auto it = in_begin; it != in_end; ++it)\n            {\n                length += ((*it) & 0xc0) != 0x80;\n            }\n            \n            return length;\n        }\n        //-----------------------------------------------------\n        /// Copy and append the given UTF8 character to the list of code\n        /// points held in the std::string and return the result\n        ///\n        /// @author S Downie\n        ///\n        /// @param UTF-8 character\n        /// @param String of code points\n        ///\n        /// @return String of code points with character appended\n        //-----------------------------------------------------\n        std::string AppendCopy(UTF8Char in_char, const std::string& in_string);\n        //-----------------------------------------------------\n        /// Append the given UTF8 character to the list of code\n        /// points held in the std::string\n        ///\n        /// @author S Downie\n        ///\n        /// @param UTF-8 character\n        /// @param [Out] String of code points\n        //-----------------------------------------------------\n        void Append(UTF8Char in_char, std::string& out_appendedResult);\n        //-----------------------------------------------------\n        /// Return a sub-string copy going from begin for\n        /// the given number of characters\n        ///\n        /// Note: Length should not exceed end of string\n        ///\n        /// @author S Downie\n        ///\n        /// @param UTF8 String\n        /// @param Start character index (UTF-8)\n        /// @param Num UTF-8 characters from start to copy\n        ///\n        /// @return Sub-string of code points\n        //-----------------------------------------------------\n        std::string SubString(const std::string& in_string, u32 in_start, u32 in_length);\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/String.h",
    "content": "//\n//  String.h\n//  ChilliSource\n//  Created by Ian Copland on 07/07/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_STRING_H_\n#define _CHILLISOURCE_CORE_STRING_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/String/MarkupDef.h>\n#include <ChilliSource/Core/String/StringMarkupParser.h>\n#include <ChilliSource/Core/String/StringParser.h>\n#include <ChilliSource/Core/String/StringUtils.h>\n#include <ChilliSource/Core/String/ToString.h>\n#include <ChilliSource/Core/String/UTF8StringUtils.h>\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/System/AppSystem.h",
    "content": "//\n//  AppSystem.h\n//  ChilliSource\n//  Created by Ian Copland on 07/03/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_SYSTEM_APPSYSTEM_H_\n#define _CHILLISOURCE_CORE_SYSTEM_APPSYSTEM_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Base/QueryableInterface.h>\n\nnamespace ChilliSource\n{\n    //-------------------------------------------------------\n    /// An application level system. An app system is created\n    /// when an application begins and exists through the\n    /// entire life of the app.\n    //-------------------------------------------------------\n    class AppSystem : public QueryableInterface\n    {\n    public:\n        CS_DECLARE_NOCOPY(AppSystem);\n        //------------------------------------------------\n        /// Destructor\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------\n        virtual ~AppSystem() {};\n    protected:\n        friend class Application;\n        \n        //------------------------------------------------\n        /// Default constructor.\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------\n        AppSystem() = default;\n        //------------------------------------------------\n        /// Initialisation method called at a time when\n        /// all App Systems have been created. System\n        /// initialisation occurs in the order they were\n        /// created.\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------\n        virtual void OnInit() {};\n        //------------------------------------------------\n        /// Called when the application is resumed after\n        /// having been suspended. This is also called\n        /// on first run immediately after On Initialise()\n        /// System resume is called in the order that\n        /// the systems were created.\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------\n        virtual void OnResume() {};\n        //------------------------------------------------\n        /// Called when the application becomes the active\n        /// application. This is also called on first run\n        /// immediately following On Resume. System\n        /// foregrounded is called in the order the systems\n        /// were created.\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------\n        virtual void OnForeground() {};\n        //------------------------------------------------\n        /// Update method. This is called once for every\n        /// update frame. Systems update is called in the\n        /// order the systems were created.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The delta time.\n        //------------------------------------------------\n        virtual void OnUpdate(f32 in_deltaTime) {};\n        //------------------------------------------------\n        /// An update method called at a fixed interval.\n        /// The time between fixed updates is defined in\n        /// Application. System update is called in the\n        /// order the systems were created.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The delta time.\n        //------------------------------------------------\n        virtual void OnFixedUpdate(f32 in_deltaTime) {};\n        //------------------------------------------------\n        /// The render snapshot event can be implemented\n        /// by a system to allow it to snapshot any data\n        /// which pertains to the renderer.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param targetType - Whether the snapshot is for the main\n        /// screen or an offscreen target\n        /// @param renderSnapshot - The render snapshot\n        /// object which contains all snapshotted data.\n        /// @param frameAllocator - Allocate memory for\n        /// this render frame from here\n        //------------------------------------------------\n        virtual void OnRenderSnapshot(TargetType targetType, RenderSnapshot& renderSnapshot, IAllocator* frameAllocator) noexcept {};\n        //------------------------------------------------\n        /// Called when the application transitions from\n        /// being active app into the background. This\n        /// is also called when the application is\n        /// exiting just prior to calling On Suspend.\n        /// System backgrounded is called in the reverse\n        /// order to which they were created.\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------\n        virtual void OnBackground() {};\n        //------------------------------------------------\n        /// Called when the application is suspended. This\n        /// is also called when the application is exiting\n        /// just prior to calling On Destroy. System\n        /// suspend is called in the reverse order to\n        /// which they were created.\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------\n        virtual void OnSuspend() {};\n        //------------------------------------------------\n        /// Called when the application is being destroyed.\n        /// This should be used to cleanup memory and\n        /// references to other systems. System destruction\n        /// occurs in the reverse order to which they\n        /// were created\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------\n        virtual void OnDestroy() {};\n        //------------------------------------------------\n        /// Called when the application receives a memory\n        /// warning. This should be used to clean up any\n        /// non-essensial memory.\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------\n        virtual void OnMemoryWarning() {};\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/System/StateSystem.cpp",
    "content": "//\n//  StateSystem.cpp\n//  ChilliSource\n//  Created by Ian Copland on 11/06/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Core/System/StateSystem.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------\n    //------------------------------------------------\n    State* StateSystem::GetState() const\n    {\n        return m_state;\n    }\n    //------------------------------------------------\n    //------------------------------------------------\n    void StateSystem::SetState(State* in_state)\n    {\n        m_state = in_state;\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Core/System/StateSystem.h",
    "content": "//\n//  StateSystem.h\n//  ChilliSource\n//  Created by Ian Copland on 07/03/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_SYSTEM_STATESYSTEM_H_\n#define _CHILLISOURCE_CORE_SYSTEM_STATESYSTEM_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Base/QueryableInterface.h>\n\nnamespace ChilliSource\n{\n    //-------------------------------------------------------\n    /// A state level system. A state system is created\n    /// at the same time as the state that owns it and lives\n    /// for the same length of time.\n    ///\n    /// @author Ian Copland\n    //-------------------------------------------------------\n    class StateSystem : public QueryableInterface\n    {\n    public:\n        CS_DECLARE_NOCOPY(StateSystem);\n        //------------------------------------------------\n        /// Destructor\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------\n        virtual ~StateSystem() {};\n    protected:\n        friend class State;\n        \n        //------------------------------------------------\n        /// Default constructor.\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------\n        StateSystem() = default;\n        //------------------------------------------------\n        /// Initialisation method called at a time when\n        /// all State Systems have been created. System\n        /// initialisation occurs in the order they were\n        /// created.\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------\n        virtual void OnInit() {};\n        //------------------------------------------------\n        /// Called when the state is resumed after\n        /// having been suspended. This is also called when\n        /// the owning state is initialised immediately after\n        /// On Start(). System resume is called in the\n        /// order that the systems were created.\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------\n        virtual void OnResume() {};\n        //------------------------------------------------\n        /// Called when the state becomes the active\n        /// application. This is also called on when the\n        /// owning state is initialised, immediately following\n        /// On Resume. System foregrounded is called in the\n        /// order the systems were created.\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------\n        virtual void OnForeground() {};\n        //------------------------------------------------\n        /// Update method. This is called once for every\n        /// update frame that the owning state is active.\n        /// Systems update is called in the order the\n        /// systems were created.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The delta time.\n        //------------------------------------------------\n        virtual void OnUpdate(f32 in_deltaTime) {};\n        //------------------------------------------------\n        /// An update method called at a fixed interval\n        /// while the owning state is active. The time between\n        /// fixed updates is defined in Application. System\n        /// update is called in the order the systems were\n        /// created.\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------\n        virtual void OnFixedUpdate(f32 in_deltaTime) {};\n        //------------------------------------------------\n        /// The render snapshot event can be implemented\n        /// by a system to allow it to snapshot any data\n        /// which pertains to the renderer.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param targetType - Whether the snapshot is for the\n        /// main screen or an offscreen render target\n        /// @param renderSnapshot - The render snapshot\n        /// object which contains all snapshotted data.\n        /// @param frameAllocator - Allocate memory required\n        /// for rendering this frame from here\n        //------------------------------------------------\n        virtual void OnRenderSnapshot(TargetType targetType, RenderSnapshot& renderSnapshot, IAllocator* frameAllocator) noexcept {};\n        //------------------------------------------------\n        /// Called when the state transitions from\n        /// being active app into the background. This\n        /// is also called when the state is destroyed,\n        /// just prior to calling On Suspend. System\n        /// backgrounded is called in the reverse order\n        /// to which they were created.\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------\n        virtual void OnBackground() {};\n        //------------------------------------------------\n        /// Called when the state is suspended. This\n        /// is also called when the owning state is destroyed,\n        /// just prior to calling On Suspend. System\n        /// suspend is called in the reverse order to\n        /// which they were created.\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------\n        virtual void OnSuspend() {};\n        //------------------------------------------------\n        /// Called when the owning state is being destroyed.\n        /// This should be used to cleanup memory and\n        /// references to other systems. System destruction\n        /// occurs in the reverse order to which they\n        /// were created\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------\n        virtual void OnDestroy() {};\n        //------------------------------------------------\n        /// Called when the state receives a memory\n        /// warning while the owning state is active. This\n        /// should be used to clean up any non-essensial\n        /// memory.\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------\n        virtual void OnMemoryWarning() {};\n        //------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return returns the state that owns this state\n        /// system.\n        //------------------------------------------------\n        State* GetState() const;\n    private:\n        //------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param the state that owns this state system.\n        //------------------------------------------------\n        void SetState(State* in_state);\n        \n        State* m_state;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/System.h",
    "content": "//\n//  System.h\n//  ChilliSource\n//  Created by Ian Copland on 07/07/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_SYSTEM_H_\n#define _CHILLISOURCE_CORE_SYSTEM_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/System/AppSystem.h>\n#include <ChilliSource/Core/System/StateSystem.h>\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Threading/SingleThreadTaskPool.cpp",
    "content": "//\n//  SingleThreadTaskPool.cpp\n//  ChilliSource\n//  Created by Ian Copland on 07/04/2016.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Core/Threading/SingleThreadTaskPool.h>\n\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/Threading/TaskScheduler.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    SingleThreadTaskPool::SingleThreadTaskPool(TaskType in_taskContext)\n        : m_taskContext(in_taskContext)\n    {\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void SingleThreadTaskPool::AddTasks(const std::vector<Task>& in_tasks) noexcept\n    {\n        std::unique_lock<std::mutex> lock(m_taskQueueMutex);\n        m_taskQueue.insert(m_taskQueue.end(), in_tasks.begin(), in_tasks.end());\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void SingleThreadTaskPool::PerformTasks() noexcept\n    {\n        std::unique_lock<std::mutex> lock(m_taskQueueMutex);\n        auto localTaskQueue = m_taskQueue;\n        m_taskQueue.clear();\n        lock.unlock();\n\n        for (const auto& task : localTaskQueue)\n        {\n            task(m_taskContext);\n        }\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Core/Threading/SingleThreadTaskPool.h",
    "content": "//\n//  SingleThreadTaskPool.h\n//  ChilliSource\n//  Created by Ian Copland on 07/04/2016.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_THREADING_SINGLETHREADTASKPOOL_H_\n#define _CHILLISOURCE_CORE_THREADING_SINGLETHREADTASKPOOL_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Threading/TaskContext.h>\n\n#include <atomic>\n#include <condition_variable>\n#include <mutex>\n#include <thread>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    /// A collection of tasks which will be performed on a single thread.\n    ///\n    /// Adding tasks is thread safe, but the perform task methods must be called on\n    /// the relevant thread.\n    ///\n    /// @author Ian Copland\n    //------------------------------------------------------------------------------\n    class SingleThreadTaskPool final\n    {\n    public:\n        CS_DECLARE_NOCOPY(SingleThreadTaskPool);\n        //------------------------------------------------------------------------------\n        /// Constructs a new main thread task pool.\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------------------------------------\n        SingleThreadTaskPool(TaskType in_taskContext);\n        //------------------------------------------------------------------------------\n        /// Adds a series of tasks to the pool. The tasks will be executed when \n        /// PerformTasks() is called.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param in_tasks - The tasks to be added to the pool.\n        //------------------------------------------------------------------------------\n        void AddTasks(const std::vector<Task>& in_tasks) noexcept;\n        //------------------------------------------------------------------------------\n        /// Performs all tasks in the task pool. The task queue is copied locally and\n        /// cleared before processing all tasks. This means that any tasks queued while\n        /// performing single thread tasks will be perfomed during the next call to\n        /// PerformTasks() rather than the current one.\n        ///\n        /// This must be called from the relevant thread.\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------------------------------------\n        void PerformTasks() noexcept;\n        \n        const TaskContext m_taskContext;\n        \n        std::vector<Task> m_taskQueue;\n        std::mutex m_taskQueueMutex;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Threading/Task.h",
    "content": "//\n//  TaskScheduler.h\n//  ChilliSource\n//  Created by Ian Copland on 05/04/2016.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_THREADING_TASK_H_\n#define _CHILLISOURCE_CORE_THREADING_TASK_H_\n\n#include <ChilliSource/ChilliSource.h>\n\n#include <functional>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    /// A delegate describing a single task. A context is provided which provides\n    /// information on the task and provides the ability to launch child tasks.\n    ///\n    /// @author Ian Copland\n    ///\n    /// @param in_taskContext - The task context.\n    //------------------------------------------------------------------------------\n    using Task = std::function<void(const TaskContext& in_taskContext) noexcept>;\n}\n\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Threading/TaskContext.cpp",
    "content": "//\n//  TaskContext.cpp\n//  ChilliSource\n//  Created by Ian Copland on 05/04/2016.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Core/Threading/TaskContext.h>\n\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/Threading/TaskType.h>\n#include <ChilliSource/Core/Threading/TaskScheduler.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    TaskContext::TaskContext(TaskType in_taskType, TaskPool* in_taskPool) noexcept\n        : m_taskType(in_taskType), m_taskPool(in_taskPool)\n    {\n        if (m_taskType == TaskType::k_mainThread || m_taskType == TaskType::k_system || m_taskType == TaskType::k_file)\n        {\n            CS_ASSERT(!m_taskPool, \"Main thread, system thread, and file task contexts should not have a task pool.\");\n        }\n        else\n        {\n            CS_ASSERT(m_taskPool, \"Small, large and game logic task contexts must have a task pool.\");\n        }\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    TaskType TaskContext::GetType() const noexcept\n    {\n        return m_taskType;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void TaskContext::ProcessChildTasks(const std::vector<Task>& in_tasks) const noexcept\n    {\n\t\tCS_ASSERT(in_tasks.size() > 0, \"No tasks provided to run.\");\n        if (m_taskType == TaskType::k_mainThread || m_taskType == TaskType::k_system || m_taskType == TaskType::k_file)\n        {\n            for (const auto& task : in_tasks)\n            {\n                task(*this);\n            }\n        }\n        else if (m_taskType == TaskType::k_gameLogic)\n        {\n            std::vector<Task> gameLogicTasks;\n            for (const auto& task : in_tasks)\n            {\n                gameLogicTasks.push_back([=](const TaskContext&)\n                {\n                    task(*this);\n                });\n            }\n            \n            m_taskPool->AddTasksAndYield(gameLogicTasks);\n        }\n        else\n        {\n            m_taskPool->AddTasksAndYield(in_tasks);\n        }\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Core/Threading/TaskContext.h",
    "content": "//\n//  TaskContext.h\n//  ChilliSource\n//  Created by Ian Copland on 05/04/2016.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_THREADING_TASKCONTEXT_H_\n#define _CHILLISOURCE_CORE_THREADING_TASKCONTEXT_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Threading/Task.h>\n\n#include <vector>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    /// Provides information on a task and the means for it to execute child tasks.\n    ///\n    /// This is immutable and thread-safe.\n    ///\n    /// @author Ian Copland\n    //------------------------------------------------------------------------------\n    class TaskContext final\n    {\n    public:\n        //------------------------------------------------------------------------------\n        /// Constructs a task context of the given type.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param in_taskType - The type of task this context represents.\n        /// @param in_taskPool - The task pool that this task and its children should be\n        /// run within. This should not be provided for main thread and file task types.\n        //------------------------------------------------------------------------------\n        TaskContext(TaskType in_taskType, TaskPool* in_taskPool = nullptr) noexcept;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The type of task this context represents.\n        //------------------------------------------------------------------------------\n        TaskType GetType() const noexcept;\n        //------------------------------------------------------------------------------\n        /// Schedules the given child tasks and yields until they have completed. Child\n        /// tasks must be of the same type as the parent.\n        ///\n        /// Child tasks are provided with a task context.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param in_tasks - The tasks to be processed.\n        //------------------------------------------------------------------------------\n        void ProcessChildTasks(const std::vector<Task>& in_tasks) const noexcept;\n        \n        TaskType m_taskType;\n        TaskPool* m_taskPool = nullptr;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Threading/TaskPool.cpp",
    "content": "//\n//  TaskPool.cpp\n//  ChilliSource\n//  Created by Ian Copland on 06/04/2016.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Core/Threading/TaskPool.h>\n\n#include <ChilliSource/Core/Delegate/MakeDelegate.h>\n#include <ChilliSource/Core/Threading/TaskType.h>\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n#   include <CSBackend/Platform/Android/Main/JNI/Core/Java/JavaVirtualMachine.h>\n#endif\n\n#include <sstream>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    TaskPool::TaskPool(TaskType in_taskType, u32 in_numThreads) noexcept\n        : m_numThreads(in_numThreads), m_taskContext(in_taskType, this), m_isFinished(false), m_taskCountHeuristic(0)\n    {\n        CS_ASSERT(in_taskType == TaskType::k_small || in_taskType == TaskType::k_large, \"Task type must be small or large\");\n        \n        for (u32 i = 0; i < m_numThreads; ++i)\n        {\n            m_threads.push_back(std::thread(MakeDelegate(this, &TaskPool::ProcessTasks)));\n        }\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    u32 TaskPool::GetNumThreads() const noexcept\n    {\n        return m_numThreads;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void TaskPool::AddTasks(const std::vector<Task>& in_tasks) noexcept\n    {\n        std::unique_lock<std::mutex> queueLock(m_taskQueueMutex);\n        m_taskQueue.insert(m_taskQueue.begin(), in_tasks.begin(), in_tasks.end());\n        m_taskCountHeuristic += u32(in_tasks.size());\n        \n        if (in_tasks.size() > 1)\n        {\n            m_emptyWaitCondition.notify_all();\n        }\n        else\n        {\n            m_emptyWaitCondition.notify_one();\n        }\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void TaskPool::AddTasksAndYield(const std::vector<Task>& in_tasks) noexcept\n    {\n        std::atomic<u32> taskCount(u32(in_tasks.size()));\n        std::atomic<bool> finished(false);\n        \n        std::vector<Task> tasksWithCounter;\n        for (const auto& task : in_tasks)\n        {\n            tasksWithCounter.push_back([=, &task, &taskCount, &finished](const TaskContext& in_taskContext) noexcept\n            {\n                task(in_taskContext);\n\n                if (--taskCount == 0)\n                {\n                    std::unique_lock<std::mutex> queueLock(m_taskQueueMutex);\n                    finished = true;\n                    m_emptyWaitCondition.notify_all();\n                }\n            });\n        }\n        \n        AddTasks(tasksWithCounter);\n        \n        while (!finished)\n        {\n            PerformTask(finished);\n        }\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void TaskPool::PerformTask(const std::atomic<bool>& in_forceContinue) noexcept\n    {\n        std::unique_lock<std::mutex> queueLock(m_taskQueueMutex);\n        \n        if (m_taskQueue.empty() && !in_forceContinue)\n        {\n            m_emptyWaitCondition.wait(queueLock);\n        }\n        \n        if (m_taskQueue.empty())\n        {\n            return;\n        }\n        \n        Task task = m_taskQueue.front();\n        m_taskQueue.pop_front();\n        --m_taskCountHeuristic;\n            \n        queueLock.unlock();\n        \n        task(m_taskContext);\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void TaskPool::ProcessTasks() noexcept\n    {\n#ifdef CS_TARGETPLATFORM_ANDROID\n        CSBackend::Android::JavaVirtualMachine::Get()->AttachCurrentThread();\n#endif\n\n        while (!m_isFinished || m_taskCountHeuristic > 0)\n        {\n            PerformTask(m_isFinished);\n        }\n        \n#ifdef CS_TARGETPLATFORM_ANDROID\n        CSBackend::Android::JavaVirtualMachine::Get()->DetachCurrentThread();\n#endif\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    TaskPool::~TaskPool() noexcept\n    {\n        std::unique_lock<std::mutex> queueLock(m_taskQueueMutex);\n        m_isFinished = true;\n        queueLock.unlock();\n        \n        m_emptyWaitCondition.notify_all();\n        for (auto& thread : m_threads)\n        {\n            thread.join();\n        }\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Core/Threading/TaskPool.h",
    "content": "//\n//  TaskPool.h\n//  ChilliSource\n//  Created by Ian Copland on 06/04/2016.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_THREADING_TASKPOOL_H_\n#define _CHILLISOURCE_CORE_THREADING_TASKPOOL_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Threading/TaskContext.h>\n\n#include <atomic>\n#include <condition_variable>\n#include <deque>\n#include <mutex>\n#include <thread>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    /// A collection of tasks which will be performed on one of the worker threads\n    /// owned by the pool.\n    ///\n    /// Currently this does no task stealing or other clever tricks for performance;\n    /// all tasks are drawn from a single global queue which is locked on every\n    /// access.\n    ///\n    /// This is thread-safe.\n    ///\n    /// @author Ian Copland\n    //------------------------------------------------------------------------------\n    class TaskPool final\n    {\n    public:\n        CS_DECLARE_NOCOPY(TaskPool);\n        //------------------------------------------------------------------------------\n        /// Constructs a new task pool with the given number of threads.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param in_taskType - The type of task this task pool is for. Only small and\n        /// large can be specified here.\n        /// @param in_numThreads - The number of threads that this task pool should\n        /// create to run tasks on.\n        //------------------------------------------------------------------------------\n        TaskPool(TaskType in_taskType, u32 in_numThreads) noexcept;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The number of threads that this task pool has to run tasks on.\n        //------------------------------------------------------------------------------\n        u32 GetNumThreads() const noexcept;\n        //------------------------------------------------------------------------------\n        /// Adds a series of tasks to the pool. These task will be executed as soon as a\n        /// thread becomes free.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param in_tasks - The tasks to be added to the pool.\n        //------------------------------------------------------------------------------\n        void AddTasks(const std::vector<Task>& in_tasks) noexcept;\n        //------------------------------------------------------------------------------\n        /// Performs the given series of tasks and yields until they are finished. While\n        /// yielding, other tasks will be processed.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param in_tasks - The tasks to be added to the pool.\n        //------------------------------------------------------------------------------\n        void AddTasksAndYield(const std::vector<Task>& in_tasks) noexcept;\n        //------------------------------------------------------------------------------\n        /// Waits for any currently running tasks to finish then joins all owned threads.\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------------------------------------\n        ~TaskPool() noexcept;\n        \n    private:\n        //------------------------------------------------------------------------------\n        /// Performs a task from the task pool. This must be called from one of the\n        /// threads owned by the task pool.\n        ///\n        /// A flag is provided which can be changed by other threads to notify that\n        /// the current thread should continue regardless of whether there are any tasks\n        /// available. AwakenAllThreads() can be used in conjunction with this flag.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param in_forceContinue - The force continue flag.\n        //------------------------------------------------------------------------------\n        void PerformTask(const std::atomic<bool>& in_forceContinue) noexcept;\n        //------------------------------------------------------------------------------\n        /// Continues to perform tasks until the task pool is deallocated. If there are\n        /// no tasks currently available this will sleep until a task is added.\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------------------------------------\n        void ProcessTasks() noexcept;\n        \n        const u32 m_numThreads;\n        const TaskContext m_taskContext;\n\n        std::vector<std::thread> m_threads;\n        \n        std::atomic<u32> m_taskCountHeuristic;\n        std::deque<Task> m_taskQueue;\n        std::mutex m_taskQueueMutex;\n        std::condition_variable m_emptyWaitCondition;\n        \n        std::atomic<bool> m_isFinished;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Threading/TaskScheduler.cpp",
    "content": "//\n//  TaskScheduler.cpp\n//  ChilliSource\n//  Created by Ian Copland on 05/04/2016.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Core/Threading/TaskScheduler.h>\n\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/Base/Device.h>\n#include <ChilliSource/Core/Threading/TaskContext.h>\n#include <ChilliSource/Core/Threading/TaskType.h>\n\n#include <algorithm>\n\nnamespace ChilliSource\n{\n    CS_DEFINE_NAMEDTYPE(TaskScheduler);\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    TaskSchedulerUPtr TaskScheduler::Create() noexcept\n    {\n        return TaskSchedulerUPtr(new TaskScheduler());\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    TaskScheduler::TaskScheduler() noexcept\n        : m_gameLogicTaskCount(0)\n    {\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    bool TaskScheduler::IsA(InterfaceIDType in_interfaceId) const noexcept\n    {\n        return (TaskScheduler::InterfaceID == in_interfaceId);\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    bool TaskScheduler::IsMainThread() const noexcept\n    {\n        return m_mainThreadId == std::this_thread::get_id();\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void TaskScheduler::ScheduleTask(TaskType in_taskType, const Task& in_task) noexcept\n    {\n        std::vector<Task> tasks = { in_task };\n        ScheduleTasks(in_taskType, tasks);\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void TaskScheduler::ScheduleTasks(TaskType in_taskType, const std::vector<Task>& in_tasks) noexcept\n    {\n        switch (in_taskType)\n        {\n            case TaskType::k_small:\n            {\n                m_smallTaskPool->AddTasks(in_tasks);\n                break;\n            }\n            case TaskType::k_large:\n            {\n                m_largeTaskPool->AddTasks(in_tasks);\n                break;\n            }\n            case TaskType::k_mainThread:\n            {\n                m_mainThreadTaskPool->AddTasks(in_tasks);\n                break;\n            }\n            case TaskType::k_system:\n            {\n                m_systemThreadTaskPool->AddTasks(in_tasks);\n                break;\n            }\n            case TaskType::k_gameLogic:\n            {\n                std::vector<Task> gameLogicTasks;\n                gameLogicTasks.reserve(in_tasks.size());\n                for (const auto& task : in_tasks)\n                {\n                    gameLogicTasks.push_back([=](const TaskContext&)\n                    {\n                        task(TaskContext(TaskType::k_gameLogic, m_smallTaskPool.get()));\n\n                        if (--m_gameLogicTaskCount == 0)\n                        {\n                            m_gameLogicTaskCondition.notify_all();\n                        }\n                    });\n                }\n\n                m_gameLogicTaskCount += u32(gameLogicTasks.size());\n                m_smallTaskPool->AddTasks(gameLogicTasks);\n                break;\n            }\n            case TaskType::k_file:\n            {\n                std::unique_lock<std::mutex> lock(m_fileTaskMutex);\n\n                m_fileTaskQueue.insert(m_fileTaskQueue.begin(), in_tasks.begin(), in_tasks.end());\n\n                if (!m_isFileTaskRunning)\n                {\n                    m_isFileTaskRunning = true;\n                    auto task = m_fileTaskQueue.front();\n                    m_fileTaskQueue.pop_front();\n                    lock.unlock();\n\n                    StartNextFileTask(task);\n                }\n                break;\n            }\n        }\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void TaskScheduler::ScheduleTasks(TaskType in_taskType, const std::vector<Task>& in_tasks, const Task& in_completionTask) noexcept\n    {\n        //TODO: This should be allocated from a pool to reduce memory fragmentation.\n        auto taskCount = std::make_shared<std::atomic<u32>>(u32(in_tasks.size()));\n        \n        std::vector<Task> tasksWithCounter;\n        tasksWithCounter.reserve(in_tasks.size());\n\n        for (const auto& task : in_tasks)\n        {\n            tasksWithCounter.push_back([=](const TaskContext& in_taskContext)\n            {\n                task(in_taskContext);\n                \n                if (--(*taskCount) == 0)\n                {\n                    ScheduleTask(in_taskType, in_completionTask);\n                }\n            });\n        }\n\n        ScheduleTasks(in_taskType, tasksWithCounter);\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void TaskScheduler::ExecuteMainThreadTasks() noexcept\n    {\n        //wait on all game logic tasks completing.\n        std::unique_lock<std::mutex> lock(m_gameLogicTaskMutex);\n        \n        while (m_gameLogicTaskCount != 0)\n        {\n            m_gameLogicTaskCondition.wait(lock);\n        }\n        \n        lock.unlock();\n        \n        m_mainThreadTaskPool->PerformTasks();\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void TaskScheduler::ExecuteSystemThreadTasks() noexcept\n    {\n        m_systemThreadTaskPool->PerformTasks();\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void TaskScheduler::StartNextFileTask(const Task& in_task) noexcept\n    {\n        std::vector<Task> tasks;\n        tasks.reserve(1);\n\n        tasks.push_back([=](const TaskContext& in_taskContext)\n        {\n            in_task(TaskContext(TaskType::k_file));\n            \n            std::unique_lock<std::mutex> lock(m_fileTaskMutex);\n            \n            if (m_fileTaskQueue.empty())\n            {\n                m_isFileTaskRunning = false;\n                return;\n            }\n            \n            auto task = m_fileTaskQueue.front();\n            m_fileTaskQueue.pop_front();\n            \n            lock.unlock();\n            \n            StartNextFileTask(task);\n        });\n\n        m_largeTaskPool->AddTasks(tasks);\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void TaskScheduler::OnInit() noexcept\n    {\n        constexpr s32 k_minThreadsPerPool = 2;\n        constexpr s32 k_namedThreads = 2; //The main thread and render (system) thread.\n        \n        Device* device = Application::Get()->GetSystem<Device>();\n        \n        s32 numFreeCores = s32(device->GetNumberOfCPUCores()) - k_namedThreads;\n        s32 threadsPerPool = std::max(k_minThreadsPerPool, numFreeCores);\n        \n        m_smallTaskPool = TaskPoolUPtr(new TaskPool(TaskType::k_small, threadsPerPool));\n        m_largeTaskPool = TaskPoolUPtr(new TaskPool(TaskType::k_large, threadsPerPool));\n        m_mainThreadTaskPool = SingleThreadTaskPoolUPtr(new SingleThreadTaskPool(TaskType::k_mainThread));\n        m_systemThreadTaskPool = SingleThreadTaskPoolUPtr(new SingleThreadTaskPool(TaskType::k_system));\n\n        m_mainThreadId = std::this_thread::get_id();\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void TaskScheduler::Destroy() noexcept\n    {\n        m_smallTaskPool.reset();\n        m_largeTaskPool.reset();\n        m_mainThreadTaskPool.reset();\n    }\n}"
  },
  {
    "path": "Source/ChilliSource/Core/Threading/TaskScheduler.h",
    "content": "//\n//  TaskScheduler.h\n//  ChilliSource\n//  Created by Ian Copland on 05/04/2016.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_THREADING_TASKSCHEDULER_H_\n#define _CHILLISOURCE_CORE_THREADING_TASKSCHEDULER_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/System/AppSystem.h>\n#include <ChilliSource/Core/Threading/SingleThreadTaskPool.h>\n#include <ChilliSource/Core/Threading/Task.h>\n#include <ChilliSource/Core/Threading/TaskPool.h>\n#include <ChilliSource/Core/Threading/TaskType.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    /// A system for executing task on the main thread or background threads.\n    /// Several types of task are provided, each of which are processed in different\n    /// ways. See TaskType.h for more information on these types.\n    ///\n    /// The task scheduler can be used during the application OnInit lifecycle event,\n    /// but it should not be used during the OnDestroy event.\n    ///\n    /// This is thread-safe.\n    ///\n    /// @author Ian Copland\n    //------------------------------------------------------------------------------\n    class TaskScheduler final : public AppSystem\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(TaskScheduler);\n        //------------------------------------------------------------------------------\n        /// Allows querying of whether or not this system implements the interface\n        /// described by the given interface Id. Typically this is not called directly\n        /// as the templated equivalent IsA<Interface>() is preferred.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param in_interfaceId - The interface Id.\n        ///\n        /// @return Whether or not the interface is implemented.\n        //------------------------------------------------------------------------------\n        bool IsA(InterfaceIDType in_interfaceId) const noexcept override;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return Whether or not the current thread is the main thread.\n        //------------------------------------------------------------------------------\n        bool IsMainThread() const noexcept;\n        //------------------------------------------------------------------------------\n        /// Schedules a single task which will be executed in a manner dependant on the\n        /// task type.\n        ///\n        /// A task context is provided for launching child tasks.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param in_taskType - The type of task.\n        /// @param in_task - The task to be scheduled.\n        //------------------------------------------------------------------------------\n        void ScheduleTask(TaskType in_taskType, const Task& in_task) noexcept;\n        //------------------------------------------------------------------------------\n        /// Schedules a batch of tasks which will be executed in a manner dependant on\n        /// the task type.\n        ///\n        /// Task contexts are provided for launching child tasks.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param in_taskType - The type of task.\n        /// @param in_tasks - The tasks to be scheduled.\n        //------------------------------------------------------------------------------\n        void ScheduleTasks(TaskType in_taskType, const std::vector<Task>& in_tasks) noexcept;\n        //------------------------------------------------------------------------------\n        /// Schedules a batch of tasks which will be executed in a manner dependant on\n        /// the task type. Once all tasks have finished executing a completion task will\n        /// be scheduled.\n        ///\n        /// All tasks, including the completion task, will be of the same type.\n        ///\n        /// Task contexts are provided for launching child tasks or yeilding.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param in_taskType - The type of task.\n        /// @param in_tasks - The tasks to be scheduled.\n        /// @param in_completionTask - A task which is scheduled when the other tasks \n        /// have all completed.\n        //------------------------------------------------------------------------------\n        void ScheduleTasks(TaskType in_taskType, const std::vector<Task>& in_tasks, const Task& in_completionTask) noexcept;\n        \n    private:\n        friend class Application;\n        friend class LifecycleManager;\n        //------------------------------------------------------------------------------\n        /// A factory method for creating new instances of the task scheduler.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @return The new instance of the system.\n        //------------------------------------------------------------------------------\n        static TaskSchedulerUPtr Create() noexcept;\n        //------------------------------------------------------------------------------\n        /// Constructor. Declared private to ensure the system is created through\n        /// Application::CreateSystem<TaskScheduler>().\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------------------------------------\n        TaskScheduler() noexcept;\n        //------------------------------------------------------------------------------\n        /// Executes all main thread tasks. Prior to running them, this will wait on all\n        /// game logic tasks completing.\n        ///\n        /// This must be called from the main thread.\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------------------------------------\n        void ExecuteMainThreadTasks() noexcept;\n        //------------------------------------------------------------------------------\n        /// Executes all system thread tasks.\n        ///\n        /// This must be called from the system thread, which the task scheduler creates.\n        ///\n        /// @author Jordan Brown\n        //------------------------------------------------------------------------------\n        void ExecuteSystemThreadTasks() noexcept;\n    private:\n        //------------------------------------------------------------------------------\n        /// Adds the given task to the large task pool. Once the task is complete then\n        /// this is called again for the next task in the file queue. If the file queue\n        /// is empty then flag indication whether or not file tasks are running is set\n        /// to false.\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------------------------------------\n        void StartNextFileTask(const Task& in_task) noexcept;\n        //------------------------------------------------------------------------------\n        /// Cleans up the Task Scheduler, joining on all existing threads and then\n        /// destroying them.\n        ///\n        /// This should be called prior to the Application OnDestroy lifecycle event is\n        /// sent to each system.\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------------------------------------\n        void Destroy() noexcept;\n        //------------------------------------------------------------------------------\n        /// Initialises the Task Scheduler, creating all threads.\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------------------------------------\n        void OnInit() noexcept override;\n        \n        TaskPoolUPtr m_smallTaskPool;\n        TaskPoolUPtr m_largeTaskPool;\n        SingleThreadTaskPoolUPtr m_mainThreadTaskPool;\n        SingleThreadTaskPoolUPtr m_systemThreadTaskPool;\n        \n        std::atomic<u32> m_gameLogicTaskCount;\n        std::condition_variable m_gameLogicTaskCondition;\n        std::mutex m_gameLogicTaskMutex;\n        \n        std::mutex m_fileTaskMutex;\n        bool m_isFileTaskRunning = false;\n        std::deque<Task> m_fileTaskQueue;\n\n        std::thread::id m_mainThreadId;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Threading/TaskType.h",
    "content": "//\n//  TaskType.h\n//  ChilliSource\n//  Created by Ian Copland on 05/04/2016.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_THREADING_TASKTYPE_H_\n#define _CHILLISOURCE_CORE_THREADING_TASKTYPE_H_\n\n#include <ChilliSource/ChilliSource.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    /// An enum describing the various types of tasks which are available to be\n    /// scheduled.\n    ///\n    /// Small task: A task with a small execution time which should be processed\n    /// within a single frame. These have a high priority. Note that small tasks\n    /// which take a long time to execute will have a significant negative impact\n    /// on performance. Use large tasks where a longer execution time is required.\n    ///\n    /// Large task: A task with a large execution time which can be processed over\n    /// a number of frames and can take several seconds to process. These have a\n    /// low priority.\n    ///\n    /// Main thread task: A small task which is executed on the main thread. This\n    /// occurs after the game logic for each frame is executed.\n    ///\n    /// System thread task: A small task which is executed on the system thread.\n    /// These tasks are intended to be for lower-level operations.\n    ///\n    /// Game logic task: A small task which is executed on a background thread and\n    /// is guaranteed to be processed within the game logic stage, prior to\n    /// executing the main thread tasks.\n    ///\n    /// File Task: A large task specifically for processing file input or output.\n    /// All background processing of files should use this rather than standard\n    /// large tasks.\n    ///\n    /// @author Ian Copland\n    //------------------------------------------------------------------------------\n    enum class TaskType\n    {\n        k_small,\n        k_large,\n        k_mainThread,\n        k_system,\n        k_gameLogic,\n        k_file\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Threading.h",
    "content": "//\n//  Threading.h\n//  ChilliSource\n//  Created by Ian Copland on 07/07/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_THREADING_H_\n#define _CHILLISOURCE_CORE_THREADING_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Threading/SingleThreadTaskPool.h>\n#include <ChilliSource/Core/Threading/Task.h>\n#include <ChilliSource/Core/Threading/TaskContext.h>\n#include <ChilliSource/Core/Threading/TaskPool.h>\n#include <ChilliSource/Core/Threading/TaskScheduler.h>\n#include <ChilliSource/Core/Threading/TaskType.h>\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Time/CoreTimer.cpp",
    "content": "//\n//  CoreTimer.cpp\n//  ChilliSource\n//  Created by Scott Downie on 09/11/2010.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2010 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Core/Time/CoreTimer.h>\n\nnamespace ChilliSource\n{\n    Event<TimeEventDelegate> CoreTimer::mOnTimerUpdateEvent;\n    \n    //----------------------------------------------------\n    /// Get Timer Update Event\n    ///\n    /// @return The event\n    //----------------------------------------------------\n    IConnectableEvent<TimeEventDelegate>& CoreTimer::GetTimerUpdateEvent()\n    {\n        return mOnTimerUpdateEvent;\n    }\n    //----------------------------------------------------\n    /// Update\n    ///\n    /// @param Time since last frame\n    //----------------------------------------------------\n    void CoreTimer::Update(f32 infDT)\n    {\n        mOnTimerUpdateEvent.NotifyConnections(infDT);\n    }\n}\n\n"
  },
  {
    "path": "Source/ChilliSource/Core/Time/CoreTimer.h",
    "content": "//\n//  CoreTimer.h\n//  ChilliSource\n//  Created by Scott Downie on 09/11/2010.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2010 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_CORE_TIMER_H_\n#define _CHILLISOURCE_CORE_CORE_TIMER_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Event/Event.h>\n\n#include <functional>\n\nnamespace ChilliSource\n{\n    typedef std::function<void(const f32)> TimeEventDelegate;\n    \n    class CoreTimer\n    {\n    public:\n        \n        //----------------------------------------------------\n        /// Get Timer Update Event\n        ///\n        /// @return The event\n        //----------------------------------------------------\n        static IConnectableEvent<TimeEventDelegate>& GetTimerUpdateEvent();\n\n    private:\n        \n        //----------------------------------------------------\n        /// Update\n        ///\n        /// @param Time since last frame\n        //----------------------------------------------------\n        static void Update(f32 infDT);\n        \n    private:\n        \n        static Event<TimeEventDelegate> mOnTimerUpdateEvent;\n        \n        friend class Application; //Only application can invoke the update\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Time/PerformanceTimer.cpp",
    "content": "//\n//  PerformanceTimer.cpp\n//  ChilliSource\n//  Created by Scott Downie on 04/09/2012.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2012 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Core/Time/PerformanceTimer.h>\n\n#ifdef CS_TARGETPLATFORM_WINDOWS\n#include <windows.h>\n#endif\n\nnamespace ChilliSource\n{\n    PerformanceTimer::PerformanceTimer()\n        : m_lastDurationMicroS(0.0)\n    {\n#ifdef CS_TARGETPLATFORM_WINDOWS\n        LARGE_INTEGER frequency;\n        QueryPerformanceFrequency(&frequency);\n        m_frequency = frequency.QuadPart;\n        m_startTime = 0;\n#endif\n    }\n\n    void PerformanceTimer::Start()\n    {\n#if defined CS_TARGETPLATFORM_IOS || defined CS_TARGETPLATFORM_ANDROID || defined CS_TARGET_PLATFORM_RPI  \n        gettimeofday(&m_startTime, 0);\n#elif defined CS_TARGETPLATFORM_WINDOWS\n        LARGE_INTEGER startTime;\n        QueryPerformanceCounter(&startTime);\n        m_startTime = startTime.QuadPart;\n#endif\n    }\n    \n    void PerformanceTimer::Stop()\n    {\n#if defined CS_TARGETPLATFORM_IOS || defined CS_TARGETPLATFORM_ANDROID || defined CS_TARGET_PLATFORM_RPI\n        timeval stopTime;\n        gettimeofday(&stopTime, 0);\n        f64 startTimeMicro = (m_startTime.tv_sec * 1000000.0) + m_startTime.tv_usec;\n        f64 stopTimeMicro = (stopTime.tv_sec * 1000000.0) + stopTime.tv_usec;\n        m_lastDurationMicroS = stopTimeMicro - startTimeMicro;\n#elif defined CS_TARGETPLATFORM_WINDOWS\n        LARGE_INTEGER end;\n        QueryPerformanceCounter(&end);\n        m_lastDurationMicroS = (static_cast<f64>(end.QuadPart - m_startTime) / m_frequency) * 1000000.0;\n#endif\n    }\n    \n    f64 PerformanceTimer::GetTimeTakenS() const\n    {\n        return m_lastDurationMicroS * 0.000001;\n    }\n    \n    f64 PerformanceTimer::GetTimeTakenMS() const\n    {\n        return m_lastDurationMicroS * 0.001;\n    }\n    \n    f64 PerformanceTimer::GetTimeTakenMicroS() const\n    {\n        return m_lastDurationMicroS;\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Core/Time/PerformanceTimer.h",
    "content": "//\n//  PerformanceTimer.h\n//  ChilliSource\n//  Created by Scott Downie on 04/09/2012.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2012 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_PERFORMANCE_TIMER_H_\n#define _CHILLISOURCE_CORE_PERFORMANCE_TIMER_H_\n\n#include <ChilliSource/ChilliSource.h>\n\n#if defined CS_TARGETPLATFORM_IOS || defined CS_TARGETPLATFORM_ANDROID   \n#include <sys/time.h>\n#endif\n\nnamespace ChilliSource\n{\n    class PerformanceTimer final\n    {\n    public:\n        PerformanceTimer();\n        void Start();\n        void Stop();\n        f64 GetTimeTakenS() const;\n        f64 GetTimeTakenMS() const;\n        f64 GetTimeTakenMicroS() const;\n    private:\n        f64 m_lastDurationMicroS;\n\n#if defined CS_TARGETPLATFORM_IOS || defined CS_TARGETPLATFORM_ANDROID || defined CS_TARGET_PLATFORM_RPI \n        timeval m_startTime;\n#elif defined CS_TARGETPLATFORM_WINDOWS\n        s64 m_frequency;\n        s64 m_startTime;\n#endif\n    };\n}\n\n#endif\n\n"
  },
  {
    "path": "Source/ChilliSource/Core/Time/Timer.cpp",
    "content": "//\n//  Timer.cpp\n//  ChilliSource\n//  Created by Scott Downie on 23/09/2010.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2010 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Core/Time/Timer.h>\n\n#include <ChilliSource/Core/Delegate/MakeDelegate.h>\n#include <ChilliSource/Core/Event/EventConnection.h>\n\nnamespace ChilliSource\n{\n    //--------------------------------------------\n    //--------------------------------------------\n    Timer::Timer()\n    {\n        m_coreTimerUpdateConnection = CoreTimer::GetTimerUpdateEvent().OpenConnection(MakeDelegate(this, &Timer::Update));\n    }\n    //--------------------------------------------\n    /// Start\n    ///\n    /// Begin the timer \n    //--------------------------------------------\n    void Timer::Start()\n    {\n        m_isActive = true;\n    }\n    //--------------------------------------------\n    /// Reset \n    ///\n    /// Reset the elapsed time\n    //--------------------------------------------\n    void Timer::Reset()\n    {\n        m_elapsedTime = 0.0f;\n    }\n    //--------------------------------------------\n    /// Stop \n    ///\n    /// Stop the timer\n    //--------------------------------------------\n    void Timer::Stop()\n    {\n        m_isActive = false;\n    }\n    //----------------------------------------------------\n    //----------------------------------------------------\n    EventConnectionUPtr Timer::OpenConnection(f32 in_periodSecs, Delegate in_delegate)\n    {\n        EventConnectionUPtr connection(new EventConnection());\n        connection->SetOwningEvent(this);\n        \n        ConnectionDesc desc;\n        desc.m_delegate = in_delegate;\n        desc.m_connection = connection.get();\n        desc.m_elapsedSinceLastUpdate = 0.0f;\n        desc.m_updatePeriod = in_periodSecs;\n        m_connections.push_back(desc);\n        \n        return connection;\n    }\n    //----------------------------------------------------\n    //----------------------------------------------------\n    void Timer::Update(const f32 in_dt)\n    {\n        if(m_isActive)\n        {\n            m_elapsedTime += in_dt;\n            \n            m_isNotifying = true;\n            \n            //Take a snapshot of the number of delegates so any new ones added\n            //during the notify loop aren't notified themseleves.\n            auto numConnections = m_connections.size();\n            for(ConnectionList::size_type i=0; i<numConnections; ++i)\n            {\n                if(m_connections[i].m_connection != nullptr && (m_connections[i].m_elapsedSinceLastUpdate += in_dt) >= m_connections[i].m_updatePeriod)\n                {\n                    m_connections[i].m_elapsedSinceLastUpdate = 0.0f;\n                    m_connections[i].m_delegate();\n                }\n            }\n            \n            m_isNotifying = false;\n            \n            RemoveClosedConnections();\n        }\n    }\n    //-------------------------------------------------------------\n    //-------------------------------------------------------------\n    void Timer::CloseConnection(EventConnection* in_connection)\n    {\n        for(u32 i=0; i<m_connections.size(); ++i)\n        {\n            ConnectionDesc& desc = m_connections[i];\n            if(desc.m_connection == in_connection)\n            {\n                if(m_isNotifying == false)\n                {\n                    m_connections.erase(m_connections.begin() + i);\n                }\n                else\n                {\n                    desc.m_connection = nullptr;\n                }\n                \n                return;\n            }\n        }\n    }\n    //-------------------------------------------------------------------------\n    //-------------------------------------------------------------------------\n    void Timer::RemoveClosedConnections()\n    {\n        for(ConnectionList::iterator it = m_connections.begin(); it != m_connections.end(); )\n        {\n            if(it->m_connection == nullptr)\n            {\n                it = m_connections.erase(it);\n            }\n            else\n            {\n                ++it;\n            }\n        }\n    }\n    //-------------------------------------------------------------\n    //-------------------------------------------------------------\n    void Timer::CloseAllConnections()\n    {\n        for(u32 i=0; i<m_connections.size(); ++i)\n        {\n            if(m_connections[i].m_connection != nullptr)\n            {\n                m_connections[i].m_connection->SetOwningEvent(nullptr);\n            }\n        }\n        \n        m_connections.clear();\n    }\n    //--------------------------------------------\n    //--------------------------------------------\n    Timer::~Timer()\n    {\n        CloseAllConnections();\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Core/Time/Timer.h",
    "content": "//\n//  Timer.h\n//  ChilliSource\n//  Created by Scott Downie on 23/09/2010.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2010 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_TIMER_H_\n#define _CHILLISOURCE_CORE_TIMER_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Event/IDisconnectableEvent.h>\n#include <ChilliSource/Core/Time/CoreTimer.h>\n\n#include <vector>\n\nnamespace ChilliSource\n{\n    //---------------------------------------------------\n    /// Event style class that objects can connect to\n    /// and be notified periodically or after a set\n    /// period of time\n    ///\n    /// @author S Downie\n    //---------------------------------------------------\n    class Timer final : public IDisconnectableEvent\n    {\n    public:\n        \n        typedef std::function<void()> Delegate;\n        \n        //--------------------------------------------\n        /// Constructor\n        ///\n        /// @author S Downie\n        //--------------------------------------------\n        Timer();\n        //--------------------------------------------\n        /// Destructor\n        ///\n        /// @author S Downie\n        //--------------------------------------------\n        ~Timer();\n        //--------------------------------------------\n        /// Begin the timer\n        ///\n        /// @author S Downie\n        //--------------------------------------------\n        void Start();\n        //--------------------------------------------\n        /// Reset the elapsed time\n        ///\n        /// @author S Downie\n        //--------------------------------------------\n        void Reset();\n        //--------------------------------------------\n        /// Stop the timer\n        ///\n        /// @author S Downie\n        //--------------------------------------------\n        void Stop();\n        //--------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Whether timer is active\n        //--------------------------------------------\n        inline bool IsTimerActive() const\n        {\n            return m_isActive;\n        }\n        //--------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Time elapsed since first start\n        /// or last reset\n        //--------------------------------------------\n        inline f32 GetElapsedTime() const\n        {\n            return m_elapsedTime;\n        }\n        //----------------------------------------------------\n        /// Opens a scoped connection to the timers periodic update\n        /// event. The listener will be notified after every\n        /// period.\n        ///\n        /// @author S Downie\n        ///\n        /// @param Seconds after which connection is notified\n        /// @param Delegate\n        ///\n        /// @return Scoped connection\n        //----------------------------------------------------\n        EventConnectionUPtr OpenConnection(f32 in_periodSecs, Delegate in_delegate);\n        //-------------------------------------------------------------\n        /// Close connection to the event. The connection will\n        /// no longer be notified of the event\n        ///\n        /// @author S Downie\n        ///\n        /// @param Connection to close\n        //-------------------------------------------------------------\n        void CloseConnection(EventConnection* in_connection) override;\n        \n    private:\n        \n        //----------------------------------------------------\n        /// Updates the elapsed time\n        ///\n        /// @author S Downie\n        ///\n        /// @param Time since last update\n        //----------------------------------------------------\n        void Update(const f32 in_dt);\n        //-------------------------------------------------------------------------\n        /// Remove from the list any connections that have been flagged as closed\n        ///\n        /// @author S Downie\n        //-------------------------------------------------------------------------\n        void RemoveClosedConnections();\n        //-------------------------------------------------------------\n        /// Closes all the currently open connections\n        ///\n        /// @author S Downie\n        //-------------------------------------------------------------\n        void CloseAllConnections();\n        \n    private:\n        \n        struct ConnectionDesc\n        {\n            Delegate m_delegate;\n            EventConnection* m_connection = nullptr;\n            f32 m_updatePeriod;\n            f32 m_elapsedSinceLastUpdate = 0.0f;\n        };\n        \n        typedef std::vector<ConnectionDesc> ConnectionList;\n        ConnectionList m_connections;\n        \n        EventConnectionUPtr m_coreTimerUpdateConnection;\n        \n        f32 m_elapsedTime = 0.0f;\n        \n        bool m_isNotifying = false;\n        bool m_isActive = false;;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Time.h",
    "content": "//\n//  Time.h\n//  ChilliSource\n//  Created by Ian Copland on 07/07/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_TIME_H_\n#define _CHILLISOURCE_CORE_TIME_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Time/CoreTimer.h>\n#include <ChilliSource/Core/Time/PerformanceTimer.h>\n#include <ChilliSource/Core/Time/Timer.h>\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Tween/EaseBack.h",
    "content": "//\n//  EaseBack.h\n//  ChilliSource\n//  Created by Scott Downie on 12/05/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_TWEEN_EASEBACK_H_\n#define _CHILLISOURCE_CORE_TWEEN_EASEBACK_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Tween/Tween.h>\n\nnamespace ChilliSource\n{\n    namespace EaseBackTween\n    {\n        const f32 k_overshootFactor = 1.70158f;\n        \n        //-----------------------------------------------------------------------\n        /// Functor that performs easing in with back overshoot on the start and end\n        /// values based on the given normalised T (0 - 1)\n        ///\n        /// @author S Downie\n        //-----------------------------------------------------------------------\n        template <typename TValueType> struct EaseInInterpolate\n        {\n            TValueType m_startValue;\n            TValueType m_endValue;\n            \n            //-----------------------------------------------------------------------\n            /// Ease in with acceleration and inital back overshoot between the start and end\n            /// values based on the given normalised T (0 - 1)\n            ///\n            /// @author S Downie\n            ///\n            /// @param Normalised T (0 - 1)\n            ///\n            /// @return Back eased-in type\n            //-----------------------------------------------------------------------\n            TValueType operator()(f32 in_t) const\n            {\n                return (m_endValue - m_startValue) * in_t * in_t * ((k_overshootFactor + 1.0f) * in_t - k_overshootFactor) + m_startValue;\n            }\n        };\n        \n        //-----------------------------------------------------------------------\n        /// Functor that performs easing out with overshoot on the start and end\n        /// values based on the given normalised T (0 - 1)\n        ///\n        /// @author S Downie\n        //-----------------------------------------------------------------------\n        template <typename TValueType> struct EaseOutInterpolate\n        {\n            TValueType m_startValue;\n            TValueType m_endValue;\n\n            //-----------------------------------------------------------------------\n            /// Ease out with deceleration and overshoot between the start and end\n            /// values based on the given normalised T (0 - 1)\n            ///\n            /// @author S Downie\n            ///\n            /// @param Normalised T (0 - 1)\n            ///\n            /// @return Back eased-out type\n            //-----------------------------------------------------------------------\n            TValueType operator()(f32 in_t) const\n            {\n                in_t -= 1.0f;\n                return (m_endValue - m_startValue) * (in_t * in_t * ((k_overshootFactor + 1.0f) * in_t + k_overshootFactor) + 1.0f) + m_startValue;\n            }\n        };\n        \n        //-----------------------------------------------------------------------\n        /// Functor that performs easing in and out with overshoots\n        /// on the start and end values based on the given normalised T (0 - 1)\n        ///\n        /// @author S Downie\n        //-----------------------------------------------------------------------\n        template <typename TValueType> struct EaseInOutInterpolate\n        {\n            EaseInInterpolate<TValueType> m_easeIn;\n            EaseOutInterpolate<TValueType> m_easeOut;\n            //-----------------------------------------------------------------------\n            /// Ease in with acceleration until halfway then begin easing out\n            /// with deceleration. Overshoots on both ends.\n            /// This occurs between the start and end values based on the given normalised T (0 - 1)\n            ///\n            /// @author S Downie\n            ///\n            /// @param Normalised T (0 - 1)\n            ///\n            /// @return Back eased-in/out type\n            //-----------------------------------------------------------------------\n            TValueType operator()(f32 in_t) const\n            {\n                if (in_t < 0.5f)\n                {\n                    return m_easeIn(in_t * 2.0f);\n                }\n                \n                return m_easeOut((in_t - 0.5f) * 2.0f);\n            }\n        };\n    }\n\n    template <typename TValueType> using EaseInBackTween = Tween<EaseBackTween::EaseInInterpolate<TValueType>>;\n    //-----------------------------------------------------------------------\n    /// Convenience method to create an tween that performs\n    /// easing in with initial overshoot\n    ///\n    /// @author S Downie\n    ///\n    /// @param Start value\n    /// @param End value\n    /// @param Duration in seconds\n    /// @param Start delay in seconds\n    /// @param End delay in seconds\n    ///\n    /// @return Tween with back ease-in function\n    //-----------------------------------------------------------------------\n    template <typename TValueType>\n    EaseInBackTween<TValueType> MakeEaseInBackTween(TValueType in_start, TValueType in_end, f32 in_duration, f32 in_startDelay = 0.0f, f32 in_endDelay = 0.0f)\n    {\n        EaseBackTween::EaseInInterpolate<TValueType> func;\n        func.m_startValue = in_start;\n        func.m_endValue = in_end;\n        return EaseInBackTween<TValueType>(func, in_duration, in_startDelay, in_endDelay);\n    }\n    \n    template <typename TValueType> using EaseOutBackTween = Tween<EaseBackTween::EaseOutInterpolate<TValueType>>;\n    //-----------------------------------------------------------------------\n    /// Convenience method to create an tween that performs easing out\n    /// with overshoot\n    ///\n    /// @author S Downie\n    ///\n    /// @param Start value\n    /// @param End value\n    /// @param Duration in seconds\n    /// @param Start delay in seconds\n    /// @param End delay in seconds\n    ///\n    /// @return Tween with back ease-in function\n    //-----------------------------------------------------------------------\n    template <typename TValueType>\n    EaseOutBackTween<TValueType> MakeEaseOutBackTween(TValueType in_start, TValueType in_end, f32 in_duration, f32 in_startDelay = 0.0f, f32 in_endDelay = 0.0f)\n    {\n        EaseBackTween::EaseOutInterpolate<TValueType> func;\n        func.m_startValue = in_start;\n        func.m_endValue = in_end;\n        return EaseOutBackTween<TValueType>(func, in_duration, in_startDelay, in_endDelay);\n    }\n    \n    template <typename TValueType> using EaseInOutBackTween = Tween<EaseBackTween::EaseInOutInterpolate<TValueType>>;\n    //-----------------------------------------------------------------------\n    /// Convenience method to create an tween that performs\n    /// easing in til halfway then easing out with overshoots\n    ///\n    /// @author S Downie\n    ///\n    /// @param Start value\n    /// @param End value\n    /// @param Duration in seconds\n    /// @param Start delay in seconds\n    /// @param End delay in seconds\n    ///\n    /// @return Tween with back ease-in/out function\n    //-----------------------------------------------------------------------\n    template <typename TValueType>\n    EaseInOutBackTween<TValueType> MakeEaseInOutBackTween(TValueType in_start, TValueType in_end, f32 in_duration, f32 in_startDelay = 0.0f, f32 in_endDelay = 0.0f)\n    {\n        EaseBackTween::EaseInOutInterpolate<TValueType> func;\n        func.m_easeIn.m_startValue = in_start;\n        func.m_easeIn.m_endValue = (in_start + in_end)/2.0f;\n        func.m_easeOut.m_startValue = func.m_easeIn.m_endValue;\n        func.m_easeOut.m_endValue = in_end;\n        return EaseInOutBackTween<TValueType>(func, in_duration, in_startDelay, in_endDelay);\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Tween/EaseQuad.h",
    "content": "//\n//  EaseQuad.h\n//  ChilliSource\n//  Created by Scott Downie on 12/05/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_TWEEN_EASEQUAD_H_\n#define _CHILLISOURCE_CORE_TWEEN_EASEQUAD_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Tween/Tween.h>\n\nnamespace ChilliSource\n{\n    namespace EaseQuadTween\n    {\n        //-----------------------------------------------------------------------\n        /// Functor that performs quadratic easing in interpolation on the start and end\n        /// values based on the given normalised T (0 - 1)\n        ///\n        /// @author S Downie\n        //-----------------------------------------------------------------------\n        template <typename TValueType> struct EaseInInterpolate\n        {\n            TValueType m_startValue;\n            TValueType m_endValue;\n            \n            //-----------------------------------------------------------------------\n            /// Ease in with quadratic acceleration between the start and end\n            /// values based on the given normalised T (0 - 1)\n            ///\n            /// @author S Downie\n            ///\n            /// @param Normalised T (0 - 1)\n            ///\n            /// @return Quadratically eased-in type\n            //-----------------------------------------------------------------------\n            TValueType operator()(f32 in_t) const\n            {\n                return (m_endValue - m_startValue) * in_t * in_t + m_startValue;\n            }\n        };\n        \n        //-----------------------------------------------------------------------\n        /// Functor that performs quadratic easing out interpolation on the start and end\n        /// values based on the given normalised T (0 - 1)\n        ///\n        /// @author S Downie\n        //-----------------------------------------------------------------------\n        template <typename TValueType> struct EaseOutInterpolate\n        {\n            TValueType m_startValue;\n            TValueType m_endValue;\n\n            //-----------------------------------------------------------------------\n            /// Ease out with quadratic deceleration between the start and end\n            /// values based on the given normalised T (0 - 1)\n            ///\n            /// @author S Downie\n            ///\n            /// @param Normalised T (0 - 1)\n            ///\n            /// @return Quadratically eased-out type\n            //-----------------------------------------------------------------------\n            TValueType operator()(f32 in_t) const\n            {\n                return -(m_endValue - m_startValue) * in_t * (in_t - 2.0f) + m_startValue;\n            }\n        };\n        \n        //-----------------------------------------------------------------------\n        /// Functor that performs quadratic easing in and out interpolation\n        /// on the start and end values based on the given normalised T (0 - 1)\n        ///\n        /// @author S Downie\n        //-----------------------------------------------------------------------\n        template <typename TValueType> struct EaseInOutInterpolate\n        {\n            EaseInInterpolate<TValueType> m_easeIn;\n            EaseOutInterpolate<TValueType> m_easeOut;\n            //-----------------------------------------------------------------------\n            /// Ease in with quadratic acceleration until halfway then begin easing out\n            /// with quadratic deceleration. This occurs between the start and end\n            /// values based on the given normalised T (0 - 1)\n            ///\n            /// @author S Downie\n            ///\n            /// @param Normalised T (0 - 1)\n            ///\n            /// @return Quadratically eased-in/out type\n            //-----------------------------------------------------------------------\n            TValueType operator()(f32 in_t) const\n            {\n                if (in_t < 0.5f)\n                {\n                    return m_easeIn(in_t * 2.0f);\n                }\n                \n                return m_easeOut((in_t - 0.5f) * 2.0f);\n            }\n        };\n    }\n\n    template <typename TValueType> using EaseInQuadTween = Tween<EaseQuadTween::EaseInInterpolate<TValueType>>;\n    //-----------------------------------------------------------------------\n    /// Convenience method to create an tween that performs quadratic\n    /// easing in\n    ///\n    /// @author S Downie\n    ///\n    /// @param Start value\n    /// @param End value\n    /// @param Duration in seconds\n    /// @param Start delay in seconds\n    /// @param End delay in seconds\n    ///\n    /// @return Tween with quad ease-in function\n    //-----------------------------------------------------------------------\n    template <typename TValueType>\n    EaseInQuadTween<TValueType> MakeEaseInQuadTween(TValueType in_start, TValueType in_end, f32 in_duration, f32 in_startDelay = 0.0f, f32 in_endDelay = 0.0f)\n    {\n        EaseQuadTween::EaseInInterpolate<TValueType> func;\n        func.m_startValue = in_start;\n        func.m_endValue = in_end;\n        return EaseInQuadTween<TValueType>(func, in_duration, in_startDelay, in_endDelay);\n    }\n    \n    template <typename TValueType> using EaseOutQuadTween = Tween<EaseQuadTween::EaseOutInterpolate<TValueType>>;\n    //-----------------------------------------------------------------------\n    /// Convenience method to create an tween that performs quadratic\n    /// easing out\n    ///\n    /// @author S Downie\n    ///\n    /// @param Start value\n    /// @param End value\n    /// @param Duration in seconds\n    /// @param Start delay in seconds\n    /// @param End delay in seconds\n    ///\n    /// @return Tween with quad ease-in function\n    //-----------------------------------------------------------------------\n    template <typename TValueType>\n    EaseOutQuadTween<TValueType> MakeEaseOutQuadTween(TValueType in_start, TValueType in_end, f32 in_duration, f32 in_startDelay = 0.0f, f32 in_endDelay = 0.0f)\n    {\n        EaseQuadTween::EaseOutInterpolate<TValueType> func;\n        func.m_startValue = in_start;\n        func.m_endValue = in_end;\n        return EaseOutQuadTween<TValueType>(func, in_duration, in_startDelay, in_endDelay);\n    }\n    \n    template <typename TValueType> using EaseInOutQuadTween = Tween<EaseQuadTween::EaseInOutInterpolate<TValueType>>;\n    //-----------------------------------------------------------------------\n    /// Convenience method to create an tween that performs quadratic\n    /// easing in til halfway then easing out\n    ///\n    /// @author S Downie\n    ///\n    /// @param Start value\n    /// @param End value\n    /// @param Duration in seconds\n    /// @param Start delay in seconds\n    /// @param End delay in seconds\n    ///\n    /// @return Tween with quad ease-in/out function\n    //-----------------------------------------------------------------------\n    template <typename TValueType>\n    EaseInOutQuadTween<TValueType> MakeEaseInOutQuadTween(TValueType in_start, TValueType in_end, f32 in_duration, f32 in_startDelay = 0.0f, f32 in_endDelay = 0.0f)\n    {\n        EaseQuadTween::EaseInOutInterpolate<TValueType> func;\n        func.m_easeIn.m_startValue = in_start;\n        func.m_easeIn.m_endValue = (in_start + in_end)/2.0f;\n        func.m_easeOut.m_startValue = func.m_easeIn.m_endValue;\n        func.m_easeOut.m_endValue = in_end;\n        return EaseInOutQuadTween<TValueType>(func, in_duration, in_startDelay, in_endDelay);\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Tween/Linear.h",
    "content": "//\n//  Linear.h\n//  ChilliSource\n//  Created by Scott Downie on 12/05/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_TWEEN_LINEAR_H_\n#define _CHILLISOURCE_CORE_TWEEN_LINEAR_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Math/MathUtils.h>\n#include <ChilliSource/Core/Tween/Tween.h>\n\nnamespace ChilliSource\n{\n    //-----------------------------------------------------------------------\n    /// Functor that performs linear interpolation on the start and end\n    /// values based on the given normalised T (0 - 1)\n    ///\n    /// @author S Downie\n    //-----------------------------------------------------------------------\n    template <typename TValueType> struct LinearInterpolate\n    {\n        TValueType m_startValue;\n        TValueType m_endValue;\n        \n        //-----------------------------------------------------------------------\n        /// Linearly interpolate between the start and end\n        /// values based on the given normalised T (0 - 1)\n        ///\n        /// @author S Downie\n        ///\n        /// @param Normalised T (0 - 1)\n        ///\n        /// @return Linearly interpolated type\n        //-----------------------------------------------------------------------\n        TValueType operator()(f32 in_t) const\n        {\n            return MathUtils::Lerp(in_t, m_startValue, m_endValue);\n        }\n    };\n    template <typename TValueType> using LinearTween = Tween<LinearInterpolate<TValueType>>;\n    //-----------------------------------------------------------------------\n    /// Convenience method to create an tween that performs a linear\n    /// interpolation\n    ///\n    /// @author S Downie\n    ///\n    /// @param Start value\n    /// @param End value\n    /// @param Duration in seconds\n    /// @param Start delay in seconds\n    /// @param End delay in seconds\n    ///\n    /// @return Tween with linear interp function\n    //-----------------------------------------------------------------------\n    template <typename TValueType>\n    LinearTween<TValueType> MakeLinearTween(TValueType in_start, TValueType in_end, f32 in_duration, f32 in_startDelay = 0.0f, f32 in_endDelay = 0.0f)\n    {\n        LinearInterpolate<TValueType> func;\n        func.m_startValue = in_start;\n        func.m_endValue = in_end;\n        return LinearTween<TValueType>(func, in_duration, in_startDelay, in_endDelay);\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Tween/SmoothStep.h",
    "content": "//\n//  SmoothStep.h\n//  ChilliSource\n//  Created by Scott Downie on 04/07/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_TWEEN_SMOOTHSTEP_H_\n#define _CHILLISOURCE_CORE_TWEEN_SMOOTHSTEP_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Math/MathUtils.h>\n#include <ChilliSource/Core/Tween/Tween.h>\n\nnamespace ChilliSource\n{\n    //-----------------------------------------------------------------------\n    /// Functor that performs smoothstep interpolation on the start and end\n    /// values based on the given normalised T (0 - 1)\n    ///\n    /// @author S Downie\n    //-----------------------------------------------------------------------\n    template <typename TValueType> struct SmoothStepInterpolate\n    {\n        TValueType m_startValue;\n        TValueType m_endValue;\n        \n        //-----------------------------------------------------------------------\n        /// Smoothly interpolate between the start and end\n        /// values based on the given normalised T (0 - 1)\n        ///\n        /// @author S Downie\n        ///\n        /// @param Normalised T (0 - 1)\n        ///\n        /// @return SmoothStep interpolated type\n        //-----------------------------------------------------------------------\n        TValueType operator()(f32 in_t) const\n        {\n            return MathUtils::SmoothStep(in_t, m_startValue, m_endValue);\n        }\n    };\n    template <typename TValueType> using SmoothStepTween = Tween<SmoothStepInterpolate<TValueType>>;\n    //-----------------------------------------------------------------------\n    /// Convenience method to create an tween that performs a smoothstep\n    /// interpolation\n    ///\n    /// @author S Downie\n    ///\n    /// @param Start value\n    /// @param End value\n    /// @param Duration in seconds\n    /// @param Start delay in seconds\n    /// @param End delay in seconds\n    ///\n    /// @return Tween with smoothstep interp function\n    //-----------------------------------------------------------------------\n    template <typename TValueType>\n    SmoothStepTween<TValueType> MakeSmoothStepTween(TValueType in_start, TValueType in_end, f32 in_duration, f32 in_startDelay = 0.0f, f32 in_endDelay = 0.0f)\n    {\n        SmoothStepInterpolate<TValueType> func;\n        func.m_startValue = in_start;\n        func.m_endValue = in_end;\n        return SmoothStepTween<TValueType>(func, in_duration, in_startDelay, in_endDelay);\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Tween/Tween.h",
    "content": "//\n//  Tween.h\n//  ChilliSource\n//  Created by Scott Downie on 12/05/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_TWEEN_TWEEN_H_\n#define _CHILLISOURCE_CORE_TWEEN_TWEEN_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Math/MathUtils.h>\n\n#include <functional>\n\nnamespace ChilliSource\n{\n    //-----------------------------------------------------------------------\n    /// List of play modes for tweening.\n    ///\n    /// @author S Downie\n    //-----------------------------------------------------------------------\n    enum class TweenPlayMode\n    {\n        k_once,\n        k_looping,\n        k_pingPong,\n        k_pingPongLooping,\n        k_onceReverse,\n        k_loopingReverse,\n        k_pingPongReverse,\n        k_pingPongLoopingReverse\n    };\n    //-----------------------------------------------------------------------\n    /// Generic animation class that combines value types and an interpolation\n    /// function to animate values over time.\n    ///\n    /// @author S Downie\n    //-----------------------------------------------------------------------\n    template <typename TInterpFunc> class Tween\n    {\n    public:\n        //-----------------------------------------------------------------------\n        /// Delegate that is called on animation state change i.e. begin and end\n        ///\n        /// @author S Downie\n        ///\n        /// @param Tween on which state has changed\n        //-----------------------------------------------------------------------\n        using StateChangeDelegate = std::function<void(Tween*)>;\n        //-----------------------------------------------------------------------\n        /// Constructor for initialising later\n        ///\n        /// @author S Downie\n        //-----------------------------------------------------------------------\n        Tween() = default;\n        //-----------------------------------------------------------------------\n        /// Constructor\n        ///\n        /// @author S Downie\n        ///\n        /// @param Interpolation function\n        /// @param Duration of a single cycle in seconds\n        /// @param Delay of initial cycle in seconds\n        /// @param Delay at end of cycle in seconds\n        //-----------------------------------------------------------------------\n        Tween(const TInterpFunc& in_interpFunc, f32 in_duration, f32 in_startDelay = 0.0f, f32 in_endDelay = 0.0f);\n        //-----------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Function that is used to interpolate values based on\n        /// the current progress\n        //-----------------------------------------------------------------------\n        void SetInterpolateFunction(const TInterpFunc& in_interpFunc);\n        //-----------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Delegate to be triggered on tween start\n        //-----------------------------------------------------------------------\n        void SetOnStartDelegate(const StateChangeDelegate& in_delegate);\n        //-----------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Delegate to be triggered on tween end (not on looping)\n        //-----------------------------------------------------------------------\n        void SetOnEndDelegate(const StateChangeDelegate& in_delegate);\n        //-----------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Delay in seconds of start of initial cycle\n        //-----------------------------------------------------------------------\n        void SetStartDelay(f32 in_delay);\n        //-----------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Delay in seconds at end of initial cycle before calling end delegate\n        //-----------------------------------------------------------------------\n        void SetEndDelay(f32 in_delay);\n        //-----------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Duration in seconds of one cycle\n        //-----------------------------------------------------------------------\n        void SetDuration(f32 in_duration);\n        //-----------------------------------------------------------------------\n        /// Scales the update time to slow down or speed up the tween\n        ///\n        /// @author S Downie\n        ///\n        /// @param Scaler\n        //-----------------------------------------------------------------------\n        void SetTimeScaleFactor(f32 in_scaler);\n        //-----------------------------------------------------------------------\n        /// Start the tween and set the play mode\n        ///\n        /// @author S Downie\n        ///\n        /// @param Play mode\n        //-----------------------------------------------------------------------\n        void Play(TweenPlayMode in_playMode);\n        //-----------------------------------------------------------------------\n        /// Stop playback of the animation\n        ///\n        /// @author S Downie\n        //-----------------------------------------------------------------------\n        void Stop();\n        //-----------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Whether the tween is playing (tween is not playing if\n        /// delay is counting down)\n        //-----------------------------------------------------------------------\n        bool IsPlaying() const;\n        //-----------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Whether the tween has finished (can't be finished unless\n        /// started).\n        //-----------------------------------------------------------------------\n        bool IsFinished() const;\n        //-----------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Whether the tween has started (once finished it is no\n        /// longer started).\n        //-----------------------------------------------------------------------\n        bool IsStarted() const;\n        //-----------------------------------------------------------------------\n        /// Update the progress of the tween with respect to time\n        ///\n        /// @author S Downie\n        ///\n        /// @param Time in seconds since last update\n        ///\n        /// @return Interpolated value at end of update\n        //-----------------------------------------------------------------------\n        auto Update(f32 in_timeSinceLastUpdate) -> decltype(std::declval<TInterpFunc>()(f32()));\n        //-----------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Normalised T (0 - 1)\n        //-----------------------------------------------------------------------\n        void SetT(f32 in_t);\n        //-----------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Normalised T (0 - 1)\n        //-----------------------------------------------------------------------\n        f32 GetT() const;\n        //-----------------------------------------------------------------------\n        /// @author HMcLaughlin\n        ///\n        /// @return Duration in seconds of one cycle\n        //-----------------------------------------------------------------------\n        f32 GetDuration() const;\n        //-----------------------------------------------------------------------\n        /// Uses the set interpolation function to calculate an interpolated\n        /// value from the current normalised T\n        ///\n        /// @author S Downie\n        ///\n        /// @return Interpolated value at current T\n        //-----------------------------------------------------------------------\n        auto GetValue() const -> decltype(std::declval<TInterpFunc>()(f32()))\n        {\n            return m_interpFunc(m_currentT);\n        }\n\n    private:\n\n        StateChangeDelegate m_startDelegate;\n        StateChangeDelegate m_endDelegate;\n\n        TInterpFunc m_interpFunc;\n\n        f32 m_duration = 0.0f;\n        f32 m_stepDuration = 0.0f;\n        f32 m_startDelay = 0.0f;\n        f32 m_endDelay = 0.0f;\n        f32 m_currentStartDelay = 0.0f;\n        f32 m_currentEndDelay = 0.0f;\n        f32 m_currentTime = 0.0f;\n        f32 m_timeScaler = 1.0f;\n        f32 m_currentT = 0.0f;\n\n        u32 m_currentStep = 0;\n        u32 m_steps = 0;\n\n        bool m_isPlaying = false;\n        bool m_isFinished = false;\n        bool m_isStarted = false;\n        bool m_isReverse = false;\n        bool m_isPingPong = false;\n    };\n    //-----------------------------------------------------------------------\n    //-----------------------------------------------------------------------\n    template <typename TInterpFunc> Tween<TInterpFunc>::Tween(const TInterpFunc& in_interpFunc, f32 in_duration, f32 in_startDelay, f32 in_endDelay)\n    : m_interpFunc(in_interpFunc), m_duration(in_duration), m_startDelay(in_startDelay), m_endDelay(in_endDelay)\n    {\n        \n    }\n    //-----------------------------------------------------------------------\n    //-----------------------------------------------------------------------\n    template <typename TInterpFunc> void Tween<TInterpFunc>::SetInterpolateFunction(const TInterpFunc& in_interpFunc)\n    {\n        m_interpFunc = in_interpFunc;\n    }\n    //-----------------------------------------------------------------------\n    //-----------------------------------------------------------------------\n    template <typename TInterpFunc> void Tween<TInterpFunc>::SetOnStartDelegate(const StateChangeDelegate& in_delegate)\n    {\n        m_startDelegate = in_delegate;\n    }\n    //-----------------------------------------------------------------------\n    //-----------------------------------------------------------------------\n    template <typename TInterpFunc> void Tween<TInterpFunc>::SetOnEndDelegate(const StateChangeDelegate& in_delegate)\n    {\n        m_endDelegate = in_delegate;\n    }\n    //-----------------------------------------------------------------------\n    //-----------------------------------------------------------------------\n    template <typename TInterpFunc> void Tween<TInterpFunc>::SetStartDelay(f32 in_delay)\n    {\n        m_startDelay = in_delay;\n    }\n    //-----------------------------------------------------------------------\n    //-----------------------------------------------------------------------\n    template <typename TInterpFunc> void Tween<TInterpFunc>::SetEndDelay(f32 in_delay)\n    {\n        m_endDelay = in_delay;\n    }\n    //-----------------------------------------------------------------------\n    //-----------------------------------------------------------------------\n    template <typename TInterpFunc> void Tween<TInterpFunc>::SetDuration(f32 in_duration)\n    {\n        m_duration = in_duration;\n    }\n    //-----------------------------------------------------------------------\n    //-----------------------------------------------------------------------\n    template <typename TInterpFunc> void Tween<TInterpFunc>::SetTimeScaleFactor(f32 in_scaler)\n    {\n        m_timeScaler = in_scaler;\n    }\n    //-----------------------------------------------------------------------\n    //-----------------------------------------------------------------------\n    template <typename TInterpFunc> void Tween<TInterpFunc>::Play(TweenPlayMode in_playMode)\n    {\n        CS_ASSERT(m_duration >= 0.0f, \"Must set a valid duration\");\n\n        switch (in_playMode)\n        {\n        case TweenPlayMode::k_once:\n            m_steps = 1;\n            m_isReverse = false;\n            m_isPingPong = false;\n            m_stepDuration = m_duration;\n            break;\n        case TweenPlayMode::k_pingPong:\n            m_steps = 2;\n            m_isReverse = false;\n            m_isPingPong = true;\n            m_stepDuration = m_duration * 0.5f;\n            break;\n        case TweenPlayMode::k_looping:\n            //Zero is looping\n            m_steps = 0;\n            m_isReverse = false;\n            m_isPingPong = false;\n            m_stepDuration = m_duration;\n            break;\n        case TweenPlayMode::k_pingPongLooping:\n            //Zero is looping\n            m_steps = 0;\n            m_isReverse = false;\n            m_isPingPong = true;\n            m_stepDuration = m_duration * 0.5f;\n            break;\n        case TweenPlayMode::k_onceReverse:\n            m_steps = 1;\n            m_isReverse = true;\n            m_isPingPong = false;\n            m_stepDuration = m_duration;\n            break;\n        case TweenPlayMode::k_loopingReverse:\n            //Zero is looping\n            m_steps = 0;\n            m_isReverse = true;\n            m_isPingPong = false;\n            m_stepDuration = m_duration;\n            break;\n        case TweenPlayMode::k_pingPongReverse:\n            m_steps = 2;\n            m_isReverse = true;\n            m_isPingPong = true;\n            m_stepDuration = m_duration * 0.5f;\n            break;\n        case TweenPlayMode::k_pingPongLoopingReverse:\n            //Zero is looping\n            m_steps = 0;\n            m_isReverse = true;\n            m_isPingPong = true;\n            m_stepDuration = m_duration * 0.5f;\n            break;\n        }\n\n        m_currentStartDelay = m_startDelay;\n        m_currentEndDelay = m_endDelay;\n        m_currentTime = 0.0f;\n        m_currentStep = 0;\n\n        m_isStarted = false;\n        m_isPlaying = true;\n        m_isFinished = false;\n    }\n    //-----------------------------------------------------------------------\n    //-----------------------------------------------------------------------\n    template <typename TInterpFunc> void Tween<TInterpFunc>::Stop()\n    {\n        m_isPlaying = false;\n    }\n    //-----------------------------------------------------------------------\n    //-----------------------------------------------------------------------\n    template <typename TInterpFunc> bool Tween<TInterpFunc>::IsPlaying() const\n    {\n        return m_isPlaying;\n    }\n    //-----------------------------------------------------------------------\n    //-----------------------------------------------------------------------\n    template <typename TInterpFunc> bool Tween<TInterpFunc>::IsFinished() const\n    {\n        return m_isFinished;\n    }\n    //-----------------------------------------------------------------------\n    //-----------------------------------------------------------------------\n    template <typename TInterpFunc> bool Tween<TInterpFunc>::IsStarted() const\n    {\n        return m_isStarted;\n    }\n    //-----------------------------------------------------------------------\n    //-----------------------------------------------------------------------\n    template <typename TInterpFunc> auto Tween<TInterpFunc>::Update(f32 in_timeSinceLastUpdate) -> decltype(std::declval<TInterpFunc>()(f32()))\n    {\n        if (m_isPlaying == false)\n        {\n            return GetValue();\n        }\n\n        in_timeSinceLastUpdate *= m_timeScaler;\n\n        //Inform the delegate that the animation has begun\n        if (m_isStarted == false)\n        {\n            //We may have a countdown before starting\n            m_currentStartDelay -= in_timeSinceLastUpdate;\n            if (m_currentStartDelay > 0.0f)\n            {\n                return GetValue();\n            }\n\n            m_isStarted = true;\n\n            if (m_startDelegate != nullptr)\n            {\n                m_startDelegate(this);\n            }\n        }\n\n        m_currentTime = std::min(m_currentTime + in_timeSinceLastUpdate, m_stepDuration);\n\n        if (m_stepDuration != 0.0f)\n        {\n            m_currentT = m_currentTime / m_stepDuration;\n        }\n        else\n        {\n            m_currentT = 1.0f;\n        }\n        \n        if (m_isReverse)\n            m_currentT = 1.0f - m_currentT;\n\n        if (m_currentTime >= m_stepDuration)\n        {\n            m_currentEndDelay -= in_timeSinceLastUpdate;\n            if(m_currentEndDelay > 0.0f)\n            {\n                return GetValue();\n            }\n            m_currentStep++;\n            \n            // Reset end-delay\n            m_currentEndDelay = m_endDelay;\n\n            if (m_isPingPong == true)\n            {\n                m_isReverse = !m_isReverse;\n            }\n\n            //Step number of zero = looping\n            if (m_steps > 0 && m_currentStep >= m_steps)\n            {\n                m_isStarted = false;\n                m_isPlaying = false;\n                m_isFinished = true;\n\n                if (m_endDelegate != nullptr)\n                {\n                    m_endDelegate(this);\n                }\n            }\n            else\n            {\n                m_currentTime = 0.0f;\n            }\n        }\n\n        return GetValue();\n    }\n    //-----------------------------------------------------------------------\n    //-----------------------------------------------------------------------\n    template <typename TInterpFunc> void Tween<TInterpFunc>::SetT(f32 in_t)\n    {\n        CS_ASSERT(in_t >= 0.0f && in_t <= 1.0f, \"T must be between 0 and 1\");\n\n        m_currentTime = in_t * m_duration;\n        m_currentT = in_t;\n    }\n    //-----------------------------------------------------------------------\n    //-----------------------------------------------------------------------\n    template <typename TInterpFunc> f32 Tween<TInterpFunc>::GetT() const\n    {\n        return m_currentT;\n    }\n    //-----------------------------------------------------------------------\n    //-----------------------------------------------------------------------\n    template <typename TInterpFunc> f32 Tween<TInterpFunc>::GetDuration() const\n    {\n        return m_duration;\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Tween.h",
    "content": "//\n//  Tween.h\n//  ChilliSource\n//  Created by Ian Copland on 07/07/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_TWEEN_H_\n#define _CHILLISOURCE_CORE_TWEEN_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Tween/EaseBack.h>\n#include <ChilliSource/Core/Tween/EaseQuad.h>\n#include <ChilliSource/Core/Tween/Linear.h>\n#include <ChilliSource/Core/Tween/SmoothStep.h>\n#include <ChilliSource/Core/Tween/Tween.h>\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Volume/VolumeComponent.cpp",
    "content": "//\n//  VolumeComponent.cpp\n//  ChilliSource\n//  Created by Ian Copland on 12/01/2012.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2012 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Core/Volume/VolumeComponent.h>\n\nnamespace ChilliSource\n{\n    CS_DEFINE_NAMEDTYPE(VolumeComponent);\n}\n"
  },
  {
    "path": "Source/ChilliSource/Core/Volume/VolumeComponent.h",
    "content": "//\n//  VolumeComponent.h\n//  ChilliSource\n//  Created by Ian Copland on 09/01/2012.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2012 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_VOLUME_COMPONENT_H_\n#define _CHILLISOURCE_CORE_VOLUME_COMPONENT_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Entity/Component.h>\n#include <ChilliSource/Core/Math/Geometry/Shapes.h>\n\nnamespace ChilliSource\n{\n    //====================================================\n    /// Description:\n    ///\n    /// Any object that has a AABB, OOBB or Bounding\n    /// Sphere.\n    //====================================================\n    class VolumeComponent : public Component\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(VolumeComponent);\n        VolumeComponent() : mfQueryIntersectionValue(0.0f){};\n        virtual ~VolumeComponent(){}\n\n        //----------------------------------------------------\n        /// Get Axis Aligned Bounding Box\n        ///\n        /// All render components have a box used for culling\n        /// and coarse intersections. This is cached and\n        /// recomputed when required.\n        /// @return Axis aligned bounding box\n        //----------------------------------------------------\n        virtual const AABB& GetAABB() = 0;\n        //----------------------------------------------------\n        /// Get Object Oriented Bounding Box\n        ///\n        /// All render objects have an OOBB for\n        /// picking. This is cached and\n        /// recomputed when required.\n        /// @return OOBB\n        //----------------------------------------------------\n        virtual const OOBB& GetOOBB() = 0;\n        //----------------------------------------------------\n        /// Get Bounding Sphere\n        ///\n        /// All render objects have an bounding sphere for\n        /// culling. This is cached and\n        /// recomputed when required.\n        /// @return bounding sphere\n        //----------------------------------------------------\n        virtual const Sphere& GetBoundingSphere() = 0;\n        //----------------------------------------------------\n        /// Is Visible\n        ///\n        /// @return Whether or not to render\n        //----------------------------------------------------\n        virtual bool IsVisible() const = 0;\n\n        f32 mfQueryIntersectionValue;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/Volume.h",
    "content": "//\n//  Volume.h\n//  ChilliSource\n//  Created by Ian Copland on 07/07/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_VOLUME_H_\n#define _CHILLISOURCE_CORE_VOLUME_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Volume/VolumeComponent.h>\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/XML/XML.cpp",
    "content": "//\n//  XML.cpp\n//  ChilliSource\n//  Created by Ian Copland on 12/06/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n#include <ChilliSource/Core/XML/XML.h>\n\nnamespace ChilliSource\n{\n    //---------------------------------------------------------\n    //---------------------------------------------------------\n    XML::XML(std::unique_ptr<rapidxml::xml_document<>> in_document, std::unique_ptr<s8[]> in_data)\n        : m_document(std::move(in_document)), m_data(std::move(in_data))\n    {\n    }\n    //---------------------------------------------------------\n    //---------------------------------------------------------\n    rapidxml::xml_document<>* XML::GetDocument() const\n    {\n        return m_document.get();\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Core/XML/XML.h",
    "content": "//\n//  XML.h\n//  ChilliSource\n//  Created by Ian Copland on 12/06/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_XML_XML_H_\n#define _CHILLISOURCE_CORE_XML_XML_H_\n\n#include <ChilliSource/ChilliSource.h>\n\n#include <rapidxml/rapidxml.hpp>\n\nnamespace ChilliSource\n{\n    //----------------------------------------------------------------\n    /// A container class for an xml document. Rapid XML requires that\n    /// parsed data have a greater lifetime than the document, so this\n    /// holds on to and cleans up both.\n    ///\n    /// @author Ian Copland\n    //----------------------------------------------------------------\n    class XML final\n    {\n    public:\n        CS_DECLARE_NOCOPY(XML);\n        //---------------------------------------------------------\n        /// Convenience typedefs for all of the main rapid xml\n        /// types.\n        ///\n        /// @author Ian Copland\n        //---------------------------------------------------------\n        using Base = rapidxml::xml_base<>;\n        using Node = rapidxml::xml_node<>;\n        using Attribute = rapidxml::xml_attribute<>;\n        using Document = rapidxml::xml_document<>;\n        //---------------------------------------------------------\n        /// Constructor.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The rapid xml document.\n        /// @param The parsed xml data.\n        //---------------------------------------------------------\n        XML(std::unique_ptr<Document> in_document, std::unique_ptr<s8[]> in_data);\n        //---------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The xml document pointer.\n        //---------------------------------------------------------\n        Document* GetDocument() const;\n    private:\n        std::unique_ptr<Document> m_document;\n        std::unique_ptr<s8[]> m_data;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/XML/XMLUtils.cpp",
    "content": "//\n//  XMLUtils.cpp\n//  ChilliSource\n//  Created by Ian Copland on 10/06/2014\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Core/XML/XMLUtils.h>\n\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/File/FileSystem.h>\n\n#include <rapidxml/rapidxml_print.hpp>\n\n#include <cstring>\n\nnamespace ChilliSource\n{\n    namespace XMLUtils\n    {\n        //--------------------------------------------------\n        //--------------------------------------------------\n        XMLUPtr ReadDocument(StorageLocation in_storageLocation, const std::string& in_filePath)\n        {\n            auto stream = Application::Get()->GetFileSystem()->CreateTextInputStream(in_storageLocation, in_filePath);\n            if (stream != nullptr)\n            {\n                std::string contents = stream->ReadAll();\n                stream.reset();\n\n                XMLUPtr document = ParseDocument(contents);\n                return document;\n            }\n            \n            return XMLUPtr();\n        }\n        //--------------------------------------------------\n        //--------------------------------------------------\n        XMLUPtr ParseDocument(const std::string& in_xmlString)\n        {\n            std::unique_ptr<s8[]> data(new s8[in_xmlString.length() + 1]);\n            memcpy(data.get(), in_xmlString.c_str(), in_xmlString.length());\n            data[in_xmlString.length()] = '\\0';\n            \n            std::unique_ptr<XML::Document> document(new XML::Document());\n            document->parse<rapidxml::parse_default>(data.get());\n            return XMLUPtr(new XML(std::move(document), std::move(data)));\n        }\n        //--------------------------------------------------\n        //--------------------------------------------------\n        std::string GetName(const XML::Base* in_base)\n        {\n            return std::string(in_base->name(), in_base->name_size());\n        }\n        //--------------------------------------------------\n        //--------------------------------------------------\n        std::string GetValue(const XML::Base* in_base)\n        {\n            return std::string(in_base->value(), in_base->value_size());\n        }\n        //--------------------------------------------------\n        //--------------------------------------------------\n        XML::Node* GetFirstChildNode(const XML::Node* in_node, const std::string& in_name)\n        {\n            const s8* nameData = nullptr;\n            auto nameSize = in_name.length();\n            if (nameSize > 0)\n            {\n                nameData = in_name.c_str();\n            }\n            \n            return in_node->first_node(nameData, nameSize);\n        }\n        //--------------------------------------------------\n        //--------------------------------------------------\n        XML::Node* GetNextSiblingNode(const XML::Node* in_node, const std::string& in_name)\n        {\n            const s8* nameData = nullptr;\n            auto nameSize = in_name.length();\n            if (nameSize > 0)\n            {\n                nameData = in_name.c_str();\n            }\n            \n            return in_node->next_sibling(nameData, nameSize);\n        }\n        //--------------------------------------------------\n        //--------------------------------------------------\n        XML::Node* GetFirstChildElement(const XML::Node* in_node, const std::string& in_name)\n        {\n            const s8* nameData = nullptr;\n            auto nameSize = in_name.length();\n            if (nameSize > 0)\n            {\n                nameData = in_name.c_str();\n            }\n            \n            XML::Node* child = in_node->first_node(nameData, nameSize);\n            if (child != nullptr && child->type() == rapidxml::node_type::node_element)\n            {\n                return child;\n            }\n            else if (child != nullptr)\n            {\n                XML::Node* sibling = child;\n                do\n                {\n                    sibling = sibling->next_sibling(nameData, nameSize);\n                }\n                while(sibling != nullptr && sibling->type() != rapidxml::node_type::node_element);\n                return sibling;\n            }\n            \n            return nullptr;\n        }\n        //--------------------------------------------------\n        //--------------------------------------------------\n        XML::Node* GetNextSiblingElement(const XML::Node* in_node, const std::string& in_name)\n        {\n            const s8* nameData = nullptr;\n            auto nameSize = in_name.length();\n            if (nameSize > 0)\n            {\n                nameData = in_name.c_str();\n            }\n            \n            XML::Node* sibling = in_node->next_sibling(nameData, nameSize);\n            while (sibling != nullptr && sibling->type() != rapidxml::node_type::node_element)\n            {\n                sibling = sibling->next_sibling(nameData, nameSize);\n            }\n            return sibling;\n        }\n        //--------------------------------------------------\n        //--------------------------------------------------\n        XML::Attribute* GetFirstAttribute(const XML::Node* in_node)\n        {\n            return in_node->first_attribute();\n        }\n        //--------------------------------------------------\n        //--------------------------------------------------\n        XML::Attribute* GetNextAttribute(const XML::Attribute* in_attribute)\n        {\n            return in_attribute->next_attribute();\n        }\n        //--------------------------------------------------\n        //--------------------------------------------------\n        template <> std::string GetAttributeValue<std::string>(const XML::Node* in_node, const std::string& in_attributeName, const std::string& in_defaultValue)\n        {\n            for(rapidxml::xml_attribute<>* attribute = in_node->first_attribute(); attribute != nullptr; attribute = attribute->next_attribute())\n            {\n                if (GetName(attribute) == in_attributeName)\n                {\n                    return GetValue(attribute);\n                }\n            }\n            \n            return in_defaultValue;\n        }\n        //--------------------------------------------------\n        //--------------------------------------------------\n        template <> bool GetAttributeValue<bool>(const XML::Node* in_node, const std::string& in_attributeName, const bool& in_defaultValue)\n        {\n            for(rapidxml::xml_attribute<>* attribute = in_node->first_attribute(); attribute != nullptr; attribute = attribute->next_attribute())\n            {\n                if (GetName(attribute) == in_attributeName)\n                {\n                    return ParseBool(GetValue(attribute));\n                }\n            }\n            \n            return in_defaultValue;\n        }\n        //--------------------------------------------------\n        //--------------------------------------------------\n        template <> f32 GetAttributeValue<f32>(const XML::Node* in_node, const std::string& in_attributeName, const f32& in_defaultValue)\n        {\n            for(rapidxml::xml_attribute<>* attribute = in_node->first_attribute(); attribute != nullptr; attribute = attribute->next_attribute())\n            {\n                if (GetName(attribute) == in_attributeName)\n                {\n                    return ParseF32(GetValue(attribute));\n                }\n            }\n            \n            return in_defaultValue;\n        }\n        //--------------------------------------------------\n        //--------------------------------------------------\n        template <> s32 GetAttributeValue<s32>(const XML::Node* in_node, const std::string& in_attributeName, const s32& in_defaultValue)\n        {\n            for(rapidxml::xml_attribute<>* attribute = in_node->first_attribute(); attribute != nullptr; attribute = attribute->next_attribute())\n            {\n                if (GetName(attribute) == in_attributeName)\n                {\n                    return ParseS32(GetValue(attribute));\n                }\n            }\n            \n            return in_defaultValue;\n        }\n        //--------------------------------------------------\n        //--------------------------------------------------\n        template <> s64 GetAttributeValue<s64>(const XML::Node* in_node, const std::string& in_attributeName, const s64& in_defaultValue)\n        {\n            for(rapidxml::xml_attribute<>* attribute = in_node->first_attribute(); attribute != nullptr; attribute = attribute->next_attribute())\n            {\n                if (GetName(attribute) == in_attributeName)\n                {\n                    return ParseS64(GetValue(attribute));\n                }\n            }\n            \n            return in_defaultValue;\n        }\n        //--------------------------------------------------\n        //--------------------------------------------------\n        template <> u32 GetAttributeValue<u32>(const XML::Node* in_node, const std::string& in_attributeName, const u32& in_defaultValue)\n        {\n            for(rapidxml::xml_attribute<>* attribute = in_node->first_attribute(); attribute != nullptr; attribute = attribute->next_attribute())\n            {\n                if (GetName(attribute) == in_attributeName)\n                {\n                    return ParseU32(GetValue(attribute));\n                }\n            }\n            \n            return in_defaultValue;\n        }\n        //--------------------------------------------------\n        //--------------------------------------------------\n        template <> u64 GetAttributeValue<u64>(const XML::Node* in_node, const std::string& in_attributeName, const u64& in_defaultValue)\n        {\n            for(rapidxml::xml_attribute<>* attribute = in_node->first_attribute(); attribute != nullptr; attribute = attribute->next_attribute())\n            {\n                if (GetName(attribute) == in_attributeName)\n                {\n                    return ParseU64(GetValue(attribute));\n                }\n            }\n            \n            return in_defaultValue;\n        }\n        //--------------------------------------------------\n        //--------------------------------------------------\n        template <> Vector2 GetAttributeValue<Vector2>(const XML::Node* in_node, const std::string& in_attributeName, const Vector2& in_defaultValue)\n        {\n            for(rapidxml::xml_attribute<>* attribute = in_node->first_attribute(); attribute != nullptr; attribute = attribute->next_attribute())\n            {\n                if (GetName(attribute) == in_attributeName)\n                {\n                    return ParseVector2(GetValue(attribute));\n                }\n            }\n            \n            return in_defaultValue;\n        }\n        //--------------------------------------------------\n        //--------------------------------------------------\n        template <> Vector3 GetAttributeValue<Vector3>(const XML::Node* in_node, const std::string& in_attributeName, const Vector3& in_defaultValue)\n        {\n            for(rapidxml::xml_attribute<>* attribute = in_node->first_attribute(); attribute != nullptr; attribute = attribute->next_attribute())\n            {\n                if (GetName(attribute) == in_attributeName)\n                {\n                    return ParseVector3(GetValue(attribute));\n                }\n            }\n            \n            return in_defaultValue;\n        }\n        //--------------------------------------------------\n        //--------------------------------------------------\n        template <> Vector4 GetAttributeValue<Vector4>(const XML::Node* in_node, const std::string& in_attributeName, const Vector4& in_defaultValue)\n        {\n            for(rapidxml::xml_attribute<>* attribute = in_node->first_attribute(); attribute != nullptr; attribute = attribute->next_attribute())\n            {\n                if (GetName(attribute) == in_attributeName)\n                {\n                    return ParseVector4(GetValue(attribute));\n                }\n            }\n            \n            return in_defaultValue;\n        }\n        //--------------------------------------------------\n        //--------------------------------------------------\n        template <> Matrix3 GetAttributeValue<Matrix3>(const XML::Node* in_node, const std::string& in_attributeName, const Matrix3& in_defaultValue)\n        {\n            for(rapidxml::xml_attribute<>* attribute = in_node->first_attribute(); attribute != nullptr; attribute = attribute->next_attribute())\n            {\n                if (GetName(attribute) == in_attributeName)\n                {\n                    return ParseMatrix3(GetValue(attribute));\n                }\n            }\n            \n            return in_defaultValue;\n        }\n        //--------------------------------------------------\n        //--------------------------------------------------\n        template <> Matrix4 GetAttributeValue<Matrix4>(const XML::Node* in_node, const std::string& in_attributeName, const Matrix4& in_defaultValue)\n        {\n            for(rapidxml::xml_attribute<>* attribute = in_node->first_attribute(); attribute != nullptr; attribute = attribute->next_attribute())\n            {\n                if (GetName(attribute) == in_attributeName)\n                {\n                    return ParseMatrix4(GetValue(attribute));\n                }\n            }\n            \n            return in_defaultValue;\n        }\n        //--------------------------------------------------\n        //--------------------------------------------------\n        template <> Quaternion GetAttributeValue<Quaternion>(const XML::Node* in_node, const std::string& in_attributeName, const Quaternion& in_defaultValue)\n        {\n            for(rapidxml::xml_attribute<>* attribute = in_node->first_attribute(); attribute != nullptr; attribute = attribute->next_attribute())\n            {\n                if (GetName(attribute) == in_attributeName)\n                {\n                    return ParseQuaternion(GetValue(attribute));\n                }\n            }\n            \n            return in_defaultValue;\n        }\n        //--------------------------------------------------\n        //--------------------------------------------------\n        template <> Colour GetAttributeValue<Colour>(const XML::Node* in_node, const std::string& in_attributeName, const Colour& in_defaultValue)\n        {\n            for(rapidxml::xml_attribute<>* attribute = in_node->first_attribute(); attribute != nullptr; attribute = attribute->next_attribute())\n            {\n                if (GetName(attribute) == in_attributeName)\n                {\n                    return ParseColour(GetValue(attribute));\n                }\n            }\n            \n            return in_defaultValue;\n        }\n        //--------------------------------------------------\n        //--------------------------------------------------\n        std::string ToString(const XML::Node* in_base)\n        {\n            std::ostringstream stream;\n            stream << *in_base;\n            return stream.str();\n        }\n        //--------------------------------------------------\n        //--------------------------------------------------\n        bool WriteDocument(XML::Document* in_document, StorageLocation in_storageLocation, const std::string& in_filePath)\n        {\n            auto stream = Application::Get()->GetFileSystem()->CreateTextOutputStream(in_storageLocation, in_filePath);\n            if (stream != nullptr)\n            {\n                std::string contents = XMLUtils::ToString(in_document);\n                stream->Write(contents);\n                return true;\n            }\n            \n            return false;\n        }\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Core/XML/XMLUtils.h",
    "content": "//\n//  XMLUtils.h\n//  ChilliSource\n//  Created by Ian Copland on 10/06/2014\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_XML_XMLUTILS_H_\n#define _CHILLISOURCE_CORE_XML_XMLUTILS_H_\n\n#include <ChilliSource/ChilliSource.h>\n\n#include <ChilliSource/Core/String/StringParser.h>\n#include <ChilliSource/Core/XML/XML.h>\n\n#include <type_traits>\n\nnamespace ChilliSource\n{\n    //--------------------------------------------------------\n    /// A collection of functions for working with xml\n    /// in a ChilliSource project. This provides convenience\n    /// functions as well as functions for working within the\n    /// ChilliSource file system.\n    ///\n    /// @author Ian Copland\n    //--------------------------------------------------------\n    namespace XMLUtils\n    {\n        //--------------------------------------------------\n        /// Reads an xml document from file.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The storage location of the file.\n        /// @param The file path.\n        ///\n        /// @return the new document stored in an xml container.\n        //--------------------------------------------------\n        XMLUPtr ReadDocument(StorageLocation in_storageLocation, const std::string& in_filePath);\n        //--------------------------------------------------\n        /// Parses an xml document from string.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The xml string.\n        ///\n        /// @return the new document stored in an xml container.\n        //--------------------------------------------------\n        XMLUPtr ParseDocument(const std::string& in_xmlString);\n        //--------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param The node.\n        ///\n        /// @return The name of the given node.\n        //--------------------------------------------------\n        std::string GetName(const XML::Base* in_base);\n        //--------------------------------------------------\n        /// Returns the value of the given node. What the\n        /// value is is determined by the type of node.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The node.\n        ///\n        /// @return The value as a string.\n        //--------------------------------------------------\n        std::string GetValue(const XML::Base* in_base);\n        //--------------------------------------------------\n        /// Returns the first child with the given name. If\n        /// the name is empty, the first child regardless\n        /// of name will be returned. If there is no child with\n        /// a matching name, null will be returned.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The node.\n        /// @param [optional] The name.\n        ///\n        /// @return The child node or null.\n        //--------------------------------------------------\n        XML::Node* GetFirstChildNode(const XML::Node* in_node, const std::string& in_name = \"\");\n        //--------------------------------------------------\n        /// Returns the next sibling with the given name. If\n        /// the name is empty the next sibling regardless of\n        /// name will be returned. If there is no child with\n        /// a matching name, null will be returned.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The node.\n        /// @param [Optional] The name.\n        ///\n        /// @return The sibling node or null.\n        //--------------------------------------------------\n        XML::Node* GetNextSiblingNode(const XML::Node* in_node, const std::string& in_name = \"\");\n        //--------------------------------------------------\n        /// Returns the first child with the given name which\n        /// is of element type. If the name is empty, the\n        /// first child regardless of name will be returned.\n        /// If there is no child with a matching name, null\n        /// will be returned.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The node.\n        /// @param [optional] The name.\n        ///\n        /// @return The child node or null.\n        //--------------------------------------------------\n        XML::Node* GetFirstChildElement(const XML::Node* in_node, const std::string& in_name = \"\");\n        //--------------------------------------------------\n        /// Returns the next sibling with the given name which\n        /// is of element type. If the name is empty the next\n        /// sibling regardless of name will be returned. If\n        /// there is no child with a matching name, null will\n        /// be returned.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The node.\n        /// @param [Optional] The name.\n        ///\n        /// @return The sibling node or null.\n        //--------------------------------------------------\n        XML::Node* GetNextSiblingElement(const XML::Node* in_node, const std::string& in_name = \"\");\n        //--------------------------------------------------\n        /// Returns the first attribute in the node. Will\n        /// return null if there is no attributes.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The node.\n        ///\n        /// @return The first attribute in the node or null.\n        //--------------------------------------------------\n        XML::Attribute* GetFirstAttribute(const XML::Node* in_node);\n        //--------------------------------------------------\n        /// Returns the next attribute in the parent node\n        /// if there is one, otherwise returns null.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The current attribute.\n        ///\n        /// @return The next attribute or null.\n        //--------------------------------------------------\n        XML::Attribute* GetNextAttribute(const XML::Attribute* in_attribute);\n        //--------------------------------------------------\n        /// Returns the value for the requested attribute name.\n        /// If the attribute doesn't exist the default value\n        /// will be returned instead.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The node.\n        /// @param The attribute name.\n        /// @param The default value.\n        ///\n        /// @return The attribute value as a string.\n        //--------------------------------------------------\n        template <typename TType> TType GetAttributeValue(const XML::Node* in_node, const std::string& in_attributeName, const TType& in_defaultValue)\n        {\n            static_assert(std::is_void<TType>() && std::is_void<TType>() == false, \"No implementation for the given template type.\");\n        }\n        //--------------------------------------------------\n        /// Returns the value for the requested attribute name.\n        /// If the attribute doesn't exist the default value\n        /// will be returned instead.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The node.\n        /// @param The attribute name.\n        /// @param The default value.\n        ///\n        /// @return The attribute value as a string.\n        //--------------------------------------------------\n        template <> std::string GetAttributeValue<std::string>(const XML::Node* in_node, const std::string& in_attributeName, const std::string& in_defaultValue);\n        //--------------------------------------------------\n        /// Returns the value for the requested attribute name.\n        /// If the attribute doesn't exist the default value\n        /// will be returned instead.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The node.\n        /// @param The attribute name.\n        /// @param The default value.\n        ///\n        /// @return The attribute value as a boolean.\n        //--------------------------------------------------\n        template <> bool GetAttributeValue<bool>(const XML::Node* in_node, const std::string& in_attributeName, const bool& in_defaultValue);\n        //--------------------------------------------------\n        /// Returns the value for the requested attribute name.\n        /// If the attribute doesn't exist the default value\n        /// will be returned instead.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The node.\n        /// @param The attribute name.\n        /// @param The default value.\n        ///\n        /// @return The attribute value as a float.\n        //--------------------------------------------------\n        template <> f32 GetAttributeValue<f32>(const XML::Node* in_node, const std::string& in_attributeName, const f32& in_defaultValue);\n        //--------------------------------------------------\n        /// Returns the value for the requested attribute name.\n        /// If the attribute doesn't exist the default value\n        /// will be returned instead.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The node.\n        /// @param The attribute name.\n        /// @param The default value.\n        ///\n        /// @return The attribute value as a signed 32-bit\n        /// integer.\n        //--------------------------------------------------\n        template <> s32 GetAttributeValue<s32>(const XML::Node* in_node, const std::string& in_attributeName, const s32& in_defaultValue);\n        //--------------------------------------------------\n        /// Returns the value for the requested attribute name.\n        /// If the attribute doesn't exist the default value\n        /// will be returned instead.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The node.\n        /// @param The attribute name.\n        /// @param The default value.\n        ///\n        /// @return The attribute value as a signed 64-bit\n        /// integer.\n        //--------------------------------------------------\n        template <> s64 GetAttributeValue<s64>(const XML::Node* in_node, const std::string& in_attributeName, const s64& in_defaultValue);\n        //--------------------------------------------------\n        /// Returns the value for the requested attribute name.\n        /// If the attribute doesn't exist the default value\n        /// will be returned instead.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The node.\n        /// @param The attribute name.\n        /// @param The default value.\n        ///\n        /// @return The attribute value as an unsigned 32-bit\n        /// integer.\n        //--------------------------------------------------\n        template <> u32 GetAttributeValue<u32>(const XML::Node* in_node, const std::string& in_attributeName, const u32& in_defaultValue);\n        //--------------------------------------------------\n        /// Returns the value for the requested attribute name.\n        /// If the attribute doesn't exist the default value\n        /// will be returned instead.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The node.\n        /// @param The attribute name.\n        /// @param The default value.\n        ///\n        /// @return The attribute value as an unsigned 64-bit\n        /// integer.\n        //--------------------------------------------------\n        template <> u64 GetAttributeValue<u64>(const XML::Node* in_node, const std::string& in_attributeName, const u64& in_defaultValue);\n        //--------------------------------------------------\n        /// Returns the value for the requested attribute name.\n        /// If the attribute doesn't exist the default value\n        /// will be returned instead.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The node.\n        /// @param The attribute name.\n        /// @param The default value.\n        ///\n        /// @return The attribute value as a Vector2.\n        //--------------------------------------------------\n        template <> Vector2 GetAttributeValue<Vector2>(const XML::Node* in_node, const std::string& in_attributeName, const Vector2& in_defaultValue);\n        //--------------------------------------------------\n        /// Returns the value for the requested attribute name.\n        /// If the attribute doesn't exist the default value\n        /// will be returned instead.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The node.\n        /// @param The attribute name.\n        /// @param The default value.\n        ///\n        /// @return The attribute value as a Vector3.\n        //--------------------------------------------------\n        template <> Vector3 GetAttributeValue<Vector3>(const XML::Node* in_node, const std::string& in_attributeName, const Vector3& in_defaultValue);\n        //--------------------------------------------------\n        /// Returns the value for the requested attribute name.\n        /// If the attribute doesn't exist the default value\n        /// will be returned instead.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The node.\n        /// @param The attribute name.\n        /// @param The default value.\n        ///\n        /// @return The attribute value as a Vector4.\n        //--------------------------------------------------\n        template <> Vector4 GetAttributeValue<Vector4>(const XML::Node* in_node, const std::string& in_attributeName, const Vector4& in_defaultValue);\n        //--------------------------------------------------\n        /// Returns the value for the requested attribute name.\n        /// If the attribute doesn't exist the default value\n        /// will be returned instead.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The node.\n        /// @param The attribute name.\n        /// @param The default value.\n        ///\n        /// @return The attribute value as a Matrix3.\n        //--------------------------------------------------\n        template <> Matrix3 GetAttributeValue<Matrix3>(const XML::Node* in_node, const std::string& in_attributeName, const Matrix3& in_defaultValue);\n        //--------------------------------------------------\n        /// Returns the value for the requested attribute name.\n        /// If the attribute doesn't exist the default value\n        /// will be returned instead.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The node.\n        /// @param The attribute name.\n        /// @param The default value.\n        ///\n        /// @return The attribute value as a Matrix4.\n        //--------------------------------------------------\n        template <> Matrix4 GetAttributeValue<Matrix4>(const XML::Node* in_node, const std::string& in_attributeName, const Matrix4& in_defaultValue);\n        //--------------------------------------------------\n        /// Returns the value for the requested attribute name.\n        /// If the attribute doesn't exist the default value\n        /// will be returned instead.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The node.\n        /// @param The attribute name.\n        /// @param The default value.\n        ///\n        /// @return The attribute value as a Quaternion.\n        //--------------------------------------------------\n        template <> Quaternion GetAttributeValue<Quaternion>(const XML::Node* in_node, const std::string& in_attributeName, const Quaternion& in_defaultValue);\n        //--------------------------------------------------\n        /// Returns the value for the requested attribute name.\n        /// If the attribute doesn't exist the default value\n        /// will be returned instead.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The node.\n        /// @param The attribute name.\n        /// @param The default value.\n        ///\n        /// @return The attribute value as a Colour.\n        //--------------------------------------------------\n        template <> Colour GetAttributeValue<Colour>(const XML::Node* in_node, const std::string& in_attributeName, const Colour& in_defaultValue);\n        //--------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param The node.\n        ///\n        /// @return The node in string form.\n        //--------------------------------------------------\n        std::string ToString(const XML::Node* in_base);\n        //--------------------------------------------------\n        /// Reads an xml document from file.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The document to write to file.\n        /// @param The storage location of the file.\n        /// @param The file path.\n        ///\n        /// @return Whether or not the write succeeded.\n        //--------------------------------------------------\n        bool WriteDocument(XML::Document* in_document, StorageLocation in_storageLocation, const std::string& in_filePath);\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Core/XML.h",
    "content": "//\n//  XML.h\n//  ChilliSource\n//  Created by Ian Copland on 07/07/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_CORE_XML_H_\n#define _CHILLISOURCE_CORE_XML_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/XML/XML.h>\n#include <ChilliSource/Core/XML/XMLUtils.h>\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Input/Accelerometer/Accelerometer.cpp",
    "content": "//\n//  Accelerometer.cpp\n//  ChilliSource\n//  Created by Ian Copland on 13/06/2013\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2013 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Input/Accelerometer/Accelerometer.h>\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n#include <CSBackend/Platform/Android/Main/JNI/Input/Accelerometer/Accelerometer.h>\n#endif\n\n#ifdef CS_TARGETPLATFORM_IOS\n#include <CSBackend/Platform/iOS/Input/Accelerometer/Accelerometer.h>\n#endif\n\nnamespace ChilliSource\n{\n    CS_DEFINE_NAMEDTYPE(Accelerometer);\n    //----------------------------------------------------\n    //----------------------------------------------------\n    AccelerometerUPtr Accelerometer::Create()\n    {\n#if defined CS_TARGETPLATFORM_ANDROID\n        return AccelerometerUPtr(new CSBackend::Android::Accelerometer());\n#elif defined CS_TARGETPLATFORM_IOS\n        if (CSBackend::iOS::Accelerometer::IsSupportedByDevice() == true)\n        {\n            return AccelerometerUPtr(new CSBackend::iOS::Accelerometer());\n        }\n        else\n        {\n            return nullptr;\n        }\n#else\n        return nullptr;\n#endif\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Input/Accelerometer/Accelerometer.h",
    "content": "//\n//  Accelerometer.h\n//  ChilliSource\n//  Created by S McGaw on 15/11/2010\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2010 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_INPUT_ACCELEROMETER_ACCELEROMETER_H_\n#define _CHILLISOURCE_INPUT_ACCELEROMETER_ACCELEROMETER_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Event/Event.h>\n#include <ChilliSource/Core/Math/Vector3.h>\n#include <ChilliSource/Core/System/AppSystem.h>\n\n#include <functional>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------\n    /// Listens to and stores the acceleration read from the\n    /// hardware accelerometer.\n    ///\n    /// @author S McGaw\n    //------------------------------------------------------------\n    class Accelerometer : public AppSystem\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(Accelerometer);\n        //----------------------------------------------------\n        /// A delegate for receiving acceleratation updates\n        /// from the accerometer.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The new acceleration. This wont neccessarily\n        /// have changed since the last update.\n        //----------------------------------------------------\n        typedef std::function<void(const Vector3&)> AccelerationUpdatedDelegate;\n        //----------------------------------------------------\n        /// Creates a new platform specific instance of the\n        /// system.\n        ///\n        /// @author Ian Copland\n        //----------------------------------------------------\n        static AccelerometerUPtr Create();\n        //----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return whether or not the accelerometer is\n        /// currently updating.\n        //----------------------------------------------------\n        virtual bool IsUpdating() const = 0;\n        //----------------------------------------------------\n        /// Start listening for accelerometer changes.\n        ///\n        /// @author Ian Copland\n        //----------------------------------------------------\n        virtual void StartUpdating() = 0;\n        //----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The acceleration applied to the device\n        /// measured in \"G\"s.\n        //----------------------------------------------------\n        virtual Vector3 GetAcceleration() const = 0;\n        //----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return An event that is invoked every time the\n        /// acceleration is updated. The acceleration will not\n        /// necessarily have changed between updates.\n        //----------------------------------------------------\n        virtual IConnectableEvent<AccelerationUpdatedDelegate>& GetAccelerationUpdatedEvent() = 0;\n        //----------------------------------------------------\n        /// Stop listening for accelerometer changes.\n        ///\n        /// @author Ian Copland\n        //----------------------------------------------------\n        virtual void StopUpdating() = 0;\n        //----------------------------------------------------\n        /// Destructor\n        ///\n        /// @author Ian Copland\n        //----------------------------------------------------\n        virtual ~Accelerometer() {}\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Input/Accelerometer.h",
    "content": "//\n//  Accelerometer.h\n//  ChilliSource\n//  Created by Ian Copland on 07/07/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n\n#ifndef _CHILLISOURCE_INPUT_ACCELEROMETER_H_\n#define _CHILLISOURCE_INPUT_ACCELEROMETER_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Input/Accelerometer/Accelerometer.h>\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Input/Base/InputFilter.cpp",
    "content": "//\n//  Created by Scott Downie on 17/09/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Input/Base/InputFilter.h>\n\nnamespace ChilliSource\n{\n    //--------------------------------------------------------------\n    //--------------------------------------------------------------\n    bool InputFilter::IsFiltered() const\n    {\n        return m_isFiltered;\n    }\n    //--------------------------------------------------------------\n    //--------------------------------------------------------------\n    void InputFilter::SetFiltered()\n    {\n        m_isFiltered = true;\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Input/Base/InputFilter.h",
    "content": "//\n//  Created by Scott Downie on 17/09/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n\n#ifndef _CHILLISOURCE_INPUT_BASE_INPUTFILTER_H_\n#define _CHILLISOURCE_INPUT_BASE_INPUTFILTER_H_\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------\n    /// Simple class that holds whether something has been filtered\n    /// and allows the filter flag to be set\n    ///\n    /// @author S Downie\n    //------------------------------------------------------------------\n    class InputFilter final\n    {\n    public:\n        \n        //--------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Filtered or not\n        //--------------------------------------------------------------\n        bool IsFiltered() const;\n        //--------------------------------------------------------------\n        /// Flag as filtered\n        ///\n        /// @author S Downie\n        //--------------------------------------------------------------\n        void SetFiltered();\n        \n    private:\n        \n        bool m_isFiltered = false;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Input/Base.h",
    "content": "//\n//  Base.h\n//  ChilliSource\n//  Created by Scott Downie on 17/09/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n\n#ifndef _CHILLISOURCE_INPUT_BASE_H_\n#define _CHILLISOURCE_INPUT_BASE_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Input/Base/InputFilter.h>\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Input/DeviceButtons/DeviceButtonSystem.cpp",
    "content": "//\n//  DeviceButtonSystem.cpp\n//  ChilliSource\n//  Created by Ian Copland on 16/05/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Input/DeviceButtons/DeviceButtonSystem.h>\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n#include <CSBackend/Platform/Android/Main/JNI/Input/DeviceButtons/DeviceButtonSystem.h>\n#endif\n\n#ifdef CS_TARGETPLATFORM_IOS\n#import <CSBackend/Platform/iOS/Input/DeviceButtons/DeviceButtonSystem.h>\n#endif\n\n#ifdef CS_TARGETPLATFORM_WINDOWS\n#include <CSBackend/Platform/Windows/Input/DeviceButtons/DeviceButtonSystem.h>\n#endif\n\nnamespace ChilliSource\n{\n    CS_DEFINE_NAMEDTYPE(DeviceButtonSystem);\n    //----------------------------------------------------\n    //----------------------------------------------------\n    DeviceButtonSystemUPtr DeviceButtonSystem::Create()\n    {\n#if defined CS_TARGETPLATFORM_ANDROID\n        return DeviceButtonSystemUPtr(new CSBackend::Android::DeviceButtonSystem());\n#elif defined CS_TARGETPLATFORM_IOS\n        return DeviceButtonSystemUPtr(new CSBackend::iOS::DeviceButtonSystem());\n#elif defined CS_TARGETPLATFORM_WINDOWS\n        return DeviceButtonSystemUPtr(new CSBackend::Windows::DeviceButtonSystem());\n#else\n        return nullptr;\n#endif\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Input/DeviceButtons/DeviceButtonSystem.h",
    "content": "//\n//  DeviceButtonSystem.h\n//  ChilliSource\n//  Created by Ian Copland on 16/05/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_INPUT_DEVICEBUTTONS_DEVICEBUTTONSYSTEM_H_\n#define _CHILLISOURCE_INPUT_DEVICEBUTTONS_DEVICEBUTTONSYSTEM_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Event/Event.h>\n#include <ChilliSource/Core/System/AppSystem.h>\n\n#include <functional>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------\n    /// A system that provides access to hard buttons on the device.\n    /// This includes buttons like the back button on Android\n    /// devices. Different devices and platforms may have different\n    /// sets of hard buttons meaning there is no guarantee that\n    /// an event for that button will ever be received.\n    ///\n    /// @author Ian Copland\n    //------------------------------------------------------------\n    class DeviceButtonSystem : public AppSystem\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(DeviceButtons);\n        //----------------------------------------------------\n        /// An enum describing the possible Device Buttons.\n        ///\n        /// @author Ian Copland\n        //----------------------------------------------------\n        enum class DeviceButton\n        {\n            k_backButton\n        };\n        //----------------------------------------------------\n        /// A delegate which will be called when a device\n        /// button pressed event is received.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The received button.\n        //----------------------------------------------------\n        using TriggeredDelegate = std::function<void(DeviceButton)>;\n        //----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return An event that will be called whenever a\n        /// device button is triggered.\n        //----------------------------------------------------\n        virtual IConnectableEvent<TriggeredDelegate>& GetTriggeredEvent() = 0;\n        //----------------------------------------------------\n        /// Destructor\n        ///\n        /// @author Ian Copland\n        //----------------------------------------------------\n        virtual ~DeviceButtonSystem(){}\n    protected:\n        friend class Application;\n        \n        //----------------------------------------------------\n        /// Creates a new platfrom specific instance of pointer\n        /// system.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @return The new system instance.\n        //----------------------------------------------------\n        static DeviceButtonSystemUPtr Create();\n        //----------------------------------------------------\n        /// Constructor. Declared protected to force the\n        /// use of the factory creation method.\n        ///\n        /// @author Ian Copland\n        //----------------------------------------------------\n        DeviceButtonSystem() = default;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Input/DeviceButtons.h",
    "content": "//\n//  DeviceButtons.h\n//  ChilliSource\n//  Created by Ian Copland on 07/07/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n\n#ifndef _CHILLISOURCE_INPUT_DEVICEBUTTONS_H_\n#define _CHILLISOURCE_INPUT_DEVICEBUTTONS_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Input/DeviceButtons/DeviceButtonSystem.h>\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Input/ForwardDeclarations.h",
    "content": "//\n//  ForwardDeclarations.h\n//  ChilliSource\n//  Created by Ian Copland on 26/02/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_INPUT_FORWARDDECLARATIONS_H_\n#define _CHILLISOURCE_INPUT_FORWARDDECLARATIONS_H_\n\n#include <ChilliSource/Core/Base/StandardMacros.h>\n\n#include <memory>\n\nnamespace ChilliSource\n{\n    //--------------------------------------------------\n    /// Base\n    //--------------------------------------------------\n    CS_FORWARDDECLARE_CLASS(InputFilter);\n    //--------------------------------------------------\n    /// Accelerometer\n    //--------------------------------------------------\n    CS_FORWARDDECLARE_CLASS(Accelerometer);\n    //--------------------------------------------------\n    /// Device Buttons\n    //--------------------------------------------------\n    CS_FORWARDDECLARE_CLASS(DeviceButtonSystem);\n    //--------------------------------------------------\n    /// Gamepad\n    //--------------------------------------------------\n    CS_FORWARDDECLARE_CLASS(Gamepad);\n    CS_FORWARDDECLARE_CLASS(GamepadSystem);\n    enum class GamepadAxis;\n    //--------------------------------------------------\n    /// Gestures\n    //--------------------------------------------------\n    CS_FORWARDDECLARE_CLASS(DragGesture);\n    CS_FORWARDDECLARE_CLASS(HoldGesture);\n    CS_FORWARDDECLARE_CLASS(Gesture);\n    CS_FORWARDDECLARE_CLASS(GestureSystem);\n    CS_FORWARDDECLARE_CLASS(PinchGesture);\n    CS_FORWARDDECLARE_CLASS(RotationGesture);\n    CS_FORWARDDECLARE_CLASS(TapGesture);\n    //--------------------------------------------------\n    /// Gyroscope\n    //--------------------------------------------------\n    CS_FORWARDDECLARE_CLASS(Gyroscope);\n    //--------------------------------------------------\n    /// Keyboard\n    //--------------------------------------------------\n    CS_FORWARDDECLARE_CLASS(Keyboard);\n    enum class KeyCode;\n    enum class ModifierKeyCode;\n    //--------------------------------------------------\n    /// Pointer\n    //--------------------------------------------------\n    CS_FORWARDDECLARE_CLASS(Pointer);\n    CS_FORWARDDECLARE_CLASS(PointerSystem);\n    //--------------------------------------------------\n    /// Text Entry\n    //--------------------------------------------------\n    CS_FORWARDDECLARE_CLASS(TextEntry);\n    enum class TextEntryType;\n    enum class TextEntryCapitalisation;\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Input/Gamepad/Gamepad.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2017 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Input/Gamepad/Gamepad.h>\n\n#include <ChilliSource/Core/Cryptographic/HashCRC32.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    Gamepad::Gamepad(Id uniqueId, u32 index, u32 numButtons, u32 supportedAxisFlags, std::string name) noexcept\n    : m_uniqueId(uniqueId), m_index(index), m_supportedAxisFlags(supportedAxisFlags), m_name(std::move(name))\n    {\n        m_buttonStates.resize(numButtons, 0.0f);\n        m_axisStates = {{0.0f}};\n        m_nameHash = HashCRC32::GenerateHashCode(m_name);\n    }\n    \n    //------------------------------------------------------------------------------\n    f32 Gamepad::GetButtonPressure(u32 buttonIndex) const noexcept\n    {\n        return buttonIndex < m_buttonStates.size() ? m_buttonStates[buttonIndex] : 0.0f;\n    }\n    \n    //------------------------------------------------------------------------------\n    f32 Gamepad::GetAxisPosition(GamepadAxis axis) const noexcept\n    {\n        return m_axisStates[(u32)axis];\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Input/Gamepad/Gamepad.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2017 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_INPUT_GAMEPAD_GAMEPAD_H_\n#define _CHILLISOURCE_INPUT_GAMEPAD_GAMEPAD_H_\n\n#include <ChilliSource/ChilliSource.h>\n\n#include <ChilliSource/Input/Gamepad/GamepadAxis.h>\n\n#include <array>\n#include <vector>\n\nnamespace ChilliSource\n{\n    /// Contains the information for a single gamepad and is accessed\n    /// through the GamepadSystem.\n    ///\n    /// A gamepad contains information on the states of all buttons or inputs\n    /// provided by the gamepad as well as a unique id for the pad.\n    ///\n    /// All gamepad buttons are treated as analogue even if the hardware is digital (in that case the returned values\n    /// will just be 0.0 or 1.0).\n    ///\n    /// Axis are defined individually e.g. an analogue stick has 2 separate axes x and y.\n    ///\n    /// Button and axis indices and the directions of axis are all controller and platform dependent\n    ///\n    /// The index describes the active index of the pad at the point it was created, so if there were already\n    /// two active gamepads existing at creation, it will be have an index of 2.\n    ///\n    /// NOTE: Restrictions on the backend mean we can only support up to 32 buttons and 8 axis inputs (e.g. 4 analogue sticks).\n    ///\n    class Gamepad final\n    {\n    public:\n        \n        static const u32 k_maxGamepads = 8;\n\n        using Id = u64;\n        \n        ///\n        /// Default constructor required for TryGetPointer\n        ///\n        Gamepad() = default;\n        \n        /// @param uniqueId\n        ///     Unique id for the gamepad\n        /// @param index\n        ///     Index of the gamepad (describes the order it was created)\n        /// @param numButtons\n        ///     The number of buttons on the control pad\n        /// @param supportedAxisFlags\n        ///     Bits flagged on for each supported axis\n        /// @param name\n        ///     The identifying name of the control pad (as reported by the pad drivers).\n        ///\n        Gamepad(Id uniqueId, u32 index, u32 numButtons, u32 supportedAxisFlags, std::string name) noexcept;\n        \n        /// @param buttonIndex\n        ///     Index of the button to check\n        ///\n        /// @return The pressure applied to the button with 1.0 being full\n        ///     and 0.0 being none. For digital buttons the results are always 0 or 1. Returns 0.0 if unsupported\n        ///\n        f32 GetButtonPressure(u32 buttonIndex) const noexcept;\n        \n        /// @param axisIndex\n        ///     Id of the axis to check\n        ///\n        /// @return Position of the axis with from 0 in the range -1 : 1. Returns 0.0 if unsupported\n        ///\n        f32 GetAxisPosition(GamepadAxis axis) const noexcept;\n\n        /// @return Unique id of the gamepad\n        ///\n        Id GetId() const noexcept { return m_uniqueId; }\n        \n        /// @return Index describing the order the gamepad was attached (can be used for P1, P2, etc)\n        ///\n        u32 GetIndex() const noexcept { return m_index; }\n        \n        /// @return Number of buttons supported by this pad\n        ///\n        u32 GetNumButtons() const noexcept { return (u32)m_buttonStates.size(); }\n        \n        /// @param axis\n        ///     Axis to check for support\n        ///\n        /// @return TRUE if gamepad supports the given axis\n        ///\n        bool IsAxisSupported(GamepadAxis axis) const noexcept { return ((m_supportedAxisFlags >> (u32)axis) & 1u) > 0u; }\n        \n        /// @return Name as reported by gamepad drivers\n        ///\n        const std::string& GetName() const noexcept { return m_name; }\n        \n        /// @return CRC32 hash of the name as reported by gamepad drivers\n        ///\n        u32 GetNameHash() const noexcept { return m_nameHash; }\n        \n    private:\n        \n        friend class GamepadSystem;\n        \n        Id m_uniqueId;\n        u32 m_index;\n        u32 m_supportedAxisFlags = 0;\n        std::string m_name;\n        u32 m_nameHash;\n        \n        std::vector<f32> m_buttonStates;\n        std::array<f32, (u32)GamepadAxis::k_total> m_axisStates;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Input/Gamepad/GamepadAxis.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2017 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_INPUT_GAMEPAD_GAMEPADAXIS_H_\n#define _CHILLISOURCE_INPUT_GAMEPAD_GAMEPADAXIS_H_\n\nnamespace ChilliSource\n{\n    /// The axes supported by gamepads. Naming conventions are based on traditional joysticks and\n    /// are the conventions used by Windows and SFML.\n    ///\n    enum class GamepadAxis\n    {\n        k_x,\n        k_y,\n        k_z,\n        k_r,\n        k_u,\n        k_v,\n        k_povX,\n        k_povY,\n        \n        k_total\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Input/Gamepad/GamepadMappings.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2017 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_INPUT_GAMEPAD_GAMEPADMAPPINGS_H_\n#define _CHILLISOURCE_INPUT_GAMEPAD_GAMEPADMAPPINGS_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Input/Gamepad/GamepadAxis.h>\n\nnamespace ChilliSource\n{\n    /// Defines button mappings for some common controllers\n    ///\n    namespace GamepadMappings\n    {\n        namespace PS4\n        {\n            const std::string k_name = \"Wireless Controller\";\n            \n            const u32 k_square = 0;\n            const u32 k_cross = 1;\n            const u32 k_circle = 2;\n            const u32 k_triangle = 3;\n            const u32 k_l1 = 4;\n            const u32 k_r1 = 5;\n            const u32 k_l2 = 6;\n            const u32 k_r2 = 7;\n            const u32 k_share = 8;\n            const u32 k_options = 9;\n            const u32 k_l3 = 10;\n            const u32 k_r3 = 11;\n            const u32 k_ps = 12;\n            const u32 k_trackpad = 13;\n            \n            const GamepadAxis k_lStickX = GamepadAxis::k_x;\n            const GamepadAxis k_lStickY = GamepadAxis::k_y;\n            const GamepadAxis k_rStickX = GamepadAxis::k_z;\n            const GamepadAxis k_rStickY = GamepadAxis::k_r;\n            const GamepadAxis k_dpadX = GamepadAxis::k_povX;\n            const GamepadAxis k_dpadY = GamepadAxis::k_povY;\n            \n            const bool k_lStickXShouldInvert = false;\n            const bool k_lStickYShouldInvert = false;\n            const bool k_rStickXShouldInvert = false;\n            const bool k_rStickYShouldInvert = false;\n            const bool k_dpadXShouldInvert = false;\n            const bool k_l2TriggerShouldInvert = false;\n            const bool k_r2TriggerShouldInvert = false;\n            \n            \n#ifndef CS_TARGETPLATFORM_RPI\n            const GamepadAxis k_l2Trigger = GamepadAxis::k_v;\n            const GamepadAxis k_r2Trigger = GamepadAxis::k_u;\n            \n            const bool k_dpadYShouldInvert = true;\n#else\n            const GamepadAxis k_l2Trigger = GamepadAxis::k_u;\n            const GamepadAxis k_r2Trigger = GamepadAxis::k_v;\n            \n            const bool k_dpadYShouldInvert = false;\n#endif\n        }\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Input/Gamepad/GamepadSystem.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2017 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Input/Gamepad/GamepadSystem.h>\n\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Input/Base/InputFilter.h>\n\n#include <thread>\n#include <algorithm>\n\n#ifdef CS_TARGETPLATFORM_WINDOWS\n#include <CSBackend/Platform/Windows/Input/Gamepad/GamepadSystem.h>\n#endif\n\n#ifdef CS_TARGETPLATFORM_RPI\n#include <CSBackend/Platform/RPi/Input/Gamepad/GamepadSystem.h>\n#endif\n\nnamespace ChilliSource\n{\n    CS_DEFINE_NAMEDTYPE(GamepadSystem);\n    \n    namespace\n    {\n        /// Performs pairing (i.e. generating a unique number from the 2 given numbers) using the Cantor method.\n        ///\n        /// NOTE: f(a,b) != f(b,a)\n        ///\n        /// @param a\n        ///     First number to pair\n        /// @param b\n        ///     Second number to pair\n        ///\n        /// @return Unique paired result\n        ///\n        u32 CantorPairing(u32 a, u32 b) noexcept\n        {\n            return ((a + b) * (a + b + 1)) / 2 + b;\n        }\n        \n        /// Attemtps to get the action id firstly from the named mappings and then the default mappings\n        ///\n        /// @param gamepadNameHash\n        ///     Unique id of the gamepad type\n        /// @param eventIndex\n        ///     Button or axis\n        /// @param namedMappings\n        ///     Priority mappings using the gamepad name and button/axis\n        /// @param defaultMappings\n        ///     Fallback mappings using the button/axis only\n        /// @param [OUT] actionId\n        ///     Set if the mapping exists\n        ///\n        /// @return TRUE if actionId is set\n        ///\n        bool TryGetActionId(u32 gamepadNameHash, u32 eventIndex, const std::vector<std::pair<u32, u32>>& namedMappings, const std::vector<std::pair<u32, u32>>& defaultMappings, u32& out_actionId) noexcept\n        {\n            //Check if this button is mapped for this gamepad type\n            u32 mappingId = CantorPairing(gamepadNameHash, eventIndex);\n            auto mappingIt = std::find_if(namedMappings.begin(), namedMappings.end(), [mappingId](const std::pair<u32, u32>& mapping)\n            {\n                return (mapping.first == mappingId);\n            });\n            \n            if(mappingIt != namedMappings.end())\n            {\n                out_actionId = mappingIt->second;\n                return true;\n            }\n            \n            auto defaultMappingIt = std::find_if(defaultMappings.begin(), defaultMappings.end(), [eventIndex](const std::pair<u32, u32>& mapping)\n            {\n                return (mapping.first == eventIndex);\n            });\n            \n            if(defaultMappingIt != defaultMappings.end())\n            {\n                out_actionId = defaultMappingIt->second;\n                return true;\n            }\n            \n            return false;\n        }\n        \n        /// Attemtps to get the action id firstly from the named mappings and then the default mappings\n        ///\n        /// @param gamepadNameHash\n        ///     Unique id of the gamepad type\n        /// @param eventIndex\n        ///     Button or axis\n        /// @param namedMappings\n        ///     Priority mappings using the gamepad name and button/axis\n        /// @param defaultMappings\n        ///     Fallback mappings using the button/axis only\n        /// @param [OUT] out_actionId\n        ///     Set if the mapping exists\n        /// @param [OUT] out_scalar\n        ///     Set if mapping exists\n        ///\n        /// @return TRUE if out_actionId is set\n        ///\n        bool TryGetActionId(u32 gamepadNameHash, u32 eventIndex, const std::vector<std::tuple<u32, u32, f32>>& namedMappings, const std::vector<std::pair<u32, u32>>& defaultMappings, u32& out_actionId, f32& out_scalar) noexcept\n        {\n            //Check if this button is mapped for this gamepad type\n            u32 mappingId = CantorPairing(gamepadNameHash, eventIndex);\n            auto mappingIt = std::find_if(namedMappings.begin(), namedMappings.end(), [mappingId](const std::tuple<u32, u32, f32>& mapping)\n            {\n                return (std::get<0>(mapping) == mappingId);\n            });\n            \n            if(mappingIt != namedMappings.end())\n            {\n                out_actionId = std::get<1>(*mappingIt);\n                out_scalar = std::get<2>(*mappingIt);\n                return true;\n            }\n            \n            auto defaultMappingIt = std::find_if(defaultMappings.begin(), defaultMappings.end(), [eventIndex](const std::pair<u32, u32>& mapping)\n            {\n                return (mapping.first == eventIndex);\n            });\n            \n            if(defaultMappingIt != defaultMappings.end())\n            {\n                out_actionId = defaultMappingIt->second;\n                out_scalar = 1.0f;\n                return true;\n            }\n            \n            return false;\n        }\n    }\n    \n    //------------------------------------------------------------------------------\n    GamepadSystemUPtr GamepadSystem::Create() noexcept\n    {\n#if defined CS_TARGETPLATFORM_WINDOWS\n        return GamepadSystemUPtr(new CSBackend::Windows::GamepadSystem());\n#elif defined CS_TARGETPLATFORM_RPI\n        return GamepadSystemUPtr(new CSBackend::RPi::GamepadSystem());\n#else\n        return nullptr;\n#endif\n    }\n    \n    //------------------------------------------------------------------------------\n    void GamepadSystem::SetActionMapping(u32 actionId, const std::string& gamepadName, GamepadAxis axis, bool invert) noexcept\n    {\n        u32 gamepadNameHash = HashCRC32::GenerateHashCode(gamepadName);\n        u32 mappingId = CantorPairing(gamepadNameHash, (u32)axis);\n        \n        auto mappingIt = std::find_if(m_axisMappings.begin(), m_axisMappings.end(), [mappingId](const std::tuple<u32, u32, f32>& mapping)\n        {\n            return std::get<0>(mapping) == mappingId;\n        });\n        \n        if(mappingIt == m_axisMappings.end())\n        {\n            m_axisMappings.push_back(std::make_tuple(mappingId, actionId, invert == false ? 1.0f : -1.0f));\n        }\n        else\n        {\n            std::get<1>(*mappingIt) = actionId;\n            std::get<2>(*mappingIt) = invert == false ? 1.0f : -1.0f;\n        }\n    }\n    \n    //------------------------------------------------------------------------------\n    void GamepadSystem::SetActionMapping(u32 actionId, const std::string& gamepadName, u32 buttonIndex) noexcept\n    {\n        u32 gamepadNameHash = HashCRC32::GenerateHashCode(gamepadName);\n        u32 mappingId = CantorPairing(gamepadNameHash, buttonIndex);\n\n        auto mappingIt = std::find_if(m_buttonMappings.begin(), m_buttonMappings.end(), [mappingId](const std::pair<u32, u32>& mapping)\n        {\n            return (mapping.first == mappingId);\n        });\n        \n        if(mappingIt == m_buttonMappings.end())\n        {\n            m_buttonMappings.push_back(std::make_pair(mappingId, actionId));\n        }\n        else\n        {\n            mappingIt->second = actionId;\n        }\n    }\n    \n    //------------------------------------------------------------------------------\n    void GamepadSystem::SetDefaultActionMapping(u32 actionId, GamepadAxis axis) noexcept\n    {\n        u32 mappingId = (u32)axis;\n        \n        auto mappingIt = std::find_if(m_defaultAxisMappings.begin(), m_defaultAxisMappings.end(), [mappingId](const std::pair<u32, u32>& mapping)\n        {\n            return (mapping.first == mappingId);\n        });\n        \n        if(mappingIt == m_defaultAxisMappings.end())\n        {\n            m_defaultAxisMappings.push_back(std::make_pair(mappingId, actionId));\n        }\n        else\n        {\n            mappingIt->second = actionId;\n        }\n    }\n    \n    //------------------------------------------------------------------------------\n    void GamepadSystem::SetDefaultActionMapping(u32 actionId, u32 buttonIndex) noexcept\n    {\n        u32 mappingId = buttonIndex;\n        \n        auto mappingIt = std::find_if(m_defaultButtonMappings.begin(), m_defaultButtonMappings.end(), [mappingId](const std::pair<u32, u32>& mapping)\n        {\n            return (mapping.first == mappingId);\n        });\n        \n        if(mappingIt == m_defaultButtonMappings.end())\n        {\n            m_defaultButtonMappings.push_back(std::make_pair(mappingId, actionId));\n        }\n        else\n        {\n            mappingIt->second = actionId;\n        }\n    }\n\n    //------------------------------------------------------------------------------\n    bool GamepadSystem::TryGetGamepadWithId(Gamepad::Id uniqueId, Gamepad& out_gamepad) const noexcept\n    {\n        for (const auto& gamepad : m_gamepads)\n        {\n            if (gamepad.GetId() == uniqueId)\n            {\n                out_gamepad = gamepad;\n                return true;\n            }\n        }\n        \n        return false;\n    }\n    \n    //------------------------------------------------------------------------------\n    bool GamepadSystem::TryGetGamepadWithIndex(u32 index, Gamepad& out_gamepad) const noexcept\n    {\n        if(index < m_gamepads.size())\n        {\n            out_gamepad = m_gamepads[index];\n            return true;\n        }\n        \n        return false;\n    }\n\n    //------------------------------------------------------------------------------\n    void GamepadSystem::ProcessQueuedInput() noexcept\n    {\n        std::unique_lock<std::mutex> lock(m_mutex);\n        std::queue<GamepadCreateEventData> createEventQueue = m_createEventQueue;\n        std::queue<GamepadEventData> eventQueue = m_eventQueue;\n        while (m_createEventQueue.empty() == false)\n        {\n            m_createEventQueue.pop();\n        }\n        while (m_eventQueue.empty() == false)\n        {\n            m_eventQueue.pop();\n        }\n        lock.unlock();\n        \n        while (createEventQueue.empty() == false)\n        {\n            const GamepadCreateEventData& event = createEventQueue.front();\n            ProcessCreateEvent(event);\n            \n            createEventQueue.pop();\n        }\n        \n        while (eventQueue.empty() == false)\n        {\n            const GamepadEventData& event = eventQueue.front();\n            \n            switch (event.m_type)\n            {\n                case EventType::k_buttonPressure:\n                    ProcessButtonPressureEvent(event);\n                    break;\n                case EventType::k_axisPosition:\n                    ProcessAxisPositionEvent(event);\n                    break;\n                case EventType::k_remove:\n                    ProcessRemoveEvent(event);\n                    break;\n                default:\n                    CS_LOG_FATAL(\"Something has gone very wrong while processing gamepad queued input\");\n                    break;\n            }\n            \n            eventQueue.pop();\n        }\n    }\n    \n    //------------------------------------------------------------------------------\n    Gamepad::Id GamepadSystem::AddGamepadCreateEvent(std::string name, u32 numButtons, u32 supportedAxisFlags) noexcept\n    {\n        std::unique_lock<std::mutex> lock(m_mutex);\n        \n        auto uniqueId = m_nextUniqueId++;\n        m_createEventQueue.push(GamepadCreateEventData(uniqueId, std::move(name), numButtons, supportedAxisFlags, ((f64)Application::Get()->GetSystemTimeInMilliseconds()) / 1000.0));\n        \n        return uniqueId;\n    }\n\n    //------------------------------------------------------------------------------\n    void GamepadSystem::AddButtonPressureChangedEvent(Gamepad::Id uniqueId, u32 buttonIndex, f32 pressure) noexcept\n    {\n        std::unique_lock<std::mutex> lock(m_mutex);\n        m_eventQueue.push(GamepadEventData(EventType::k_buttonPressure, uniqueId, buttonIndex, pressure, ((f64)Application::Get()->GetSystemTimeInMilliseconds()) / 1000.0));\n    }\n    \n    //------------------------------------------------------------------------------\n    void GamepadSystem::AddAxisPositionChangedEvent(Gamepad::Id uniqueId, GamepadAxis axis, f32 position) noexcept\n    {\n        std::unique_lock<std::mutex> lock(m_mutex);\n        m_eventQueue.push(GamepadEventData(EventType::k_axisPosition, uniqueId, (u32)axis, position, ((f64)Application::Get()->GetSystemTimeInMilliseconds()) / 1000.0));\n    }\n    \n    //------------------------------------------------------------------------------\n    void GamepadSystem::AddGamepadRemoveEvent(Gamepad::Id uniqueId) noexcept\n    {\n        std::unique_lock<std::mutex> lock(m_mutex);\n        m_eventQueue.push(GamepadEventData(EventType::k_remove, uniqueId, 0, 0.0f, ((f64)Application::Get()->GetSystemTimeInMilliseconds()) / 1000.0));\n    }\n\n    //------------------------------------------------------------------------------\n    void GamepadSystem::RemoveAllGamepads() noexcept\n    {\n        std::unique_lock<std::mutex> lock(m_mutex);\n        \n        while (m_eventQueue.empty() == false)\n        {\n            m_eventQueue.pop();\n        }\n        \n        lock.unlock();\n        \n        m_gamepads.clear();\n    }\n    \n    //------------------------------------------------------------------------------\n    void GamepadSystem::ProcessCreateEvent(const GamepadCreateEventData& event) noexcept\n    {\n        //Find the first free index\n        u32 index = 0;\n        \n        while(true)\n        {\n            bool indexAvailable = true;\n            \n            for (const auto& gamepad : m_gamepads)\n            {\n                if (gamepad.GetIndex() == index)\n                {\n                    indexAvailable = false;\n                    break;\n                }\n            }\n            \n            if(indexAvailable == true)\n            {\n                break;\n            }\n            \n            ++index;\n        }\n        \n        m_gamepads.push_back(Gamepad(event.m_uniqueId, index, event.m_numButtons, event.m_supportedAxisFlags, std::move(event.m_name)));\n        \n        m_gamepadAddedEvent.NotifyConnections(m_gamepads.back(), event.m_timestamp);\n    }\n    \n    //------------------------------------------------------------------------------\n    void GamepadSystem::ProcessButtonPressureEvent(const GamepadEventData& event) noexcept\n    {\n        auto gamepadIt = std::find_if(m_gamepads.begin(), m_gamepads.end(), [&](const Gamepad& gamepad)\n        {\n            return (event.m_uniqueId == gamepad.GetId());\n        });\n        \n        if (gamepadIt != m_gamepads.end())\n        {\n            gamepadIt->m_buttonStates[event.m_index] = event.m_value;\n            m_buttonPressureChangedEvent.NotifyConnections(*gamepadIt, event.m_timestamp, event.m_index, event.m_value);\n            \n            u32 actionId = 0;\n            if(TryGetActionId(gamepadIt->GetNameHash(), event.m_index, m_buttonMappings, m_defaultButtonMappings, actionId) == true)\n            {\n                m_mappedButtonPressureChangedEvent.NotifyConnections(*gamepadIt, event.m_timestamp, actionId, event.m_value);\n            }\n        }\n        else\n        {\n            CS_LOG_FATAL(\"GamepadSystem: Received gamepad event for unknown Id.\");\n        }\n    }\n    \n    //------------------------------------------------------------------------------\n    void GamepadSystem::ProcessAxisPositionEvent(const GamepadEventData& event) noexcept\n    {\n        auto gamepadIt = std::find_if(m_gamepads.begin(), m_gamepads.end(), [&](const Gamepad& gamepad)\n        {\n            return (event.m_uniqueId == gamepad.GetId());\n        });\n        \n        if (gamepadIt != m_gamepads.end())\n        {\n            gamepadIt->m_axisStates[event.m_index] = event.m_value;\n            m_axisPositionChangedEvent.NotifyConnections(*gamepadIt, event.m_timestamp, (GamepadAxis)event.m_index, event.m_value);\n            \n            u32 actionId = 0;\n            f32 scalar = 1.0f;\n            if(TryGetActionId(gamepadIt->GetNameHash(), event.m_index, m_axisMappings, m_defaultAxisMappings, actionId, scalar) == true)\n            {\n                m_mappedAxisPositionChangedEvent.NotifyConnections(*gamepadIt, event.m_timestamp, actionId, event.m_value * scalar);\n            }\n        }\n        else\n        {\n            CS_LOG_FATAL(\"GamepadSystem: Received gamepad event for unknown Id.\");\n        }\n    }\n    \n    //------------------------------------------------------------------------------\n    void GamepadSystem::ProcessRemoveEvent(const GamepadEventData& event) noexcept\n    {\n        auto gamepadIt = std::find_if(m_gamepads.begin(), m_gamepads.end(), [&](const Gamepad& gamepad)\n        {\n            return (event.m_uniqueId == gamepad.GetId());\n        });\n        \n        if (gamepadIt != m_gamepads.end())\n        {\n            auto gamepad = *gamepadIt;\n            m_gamepads.erase(gamepadIt);\n            m_gamepadRemovedEvent.NotifyConnections(std::move(gamepad), event.m_timestamp);\n        }\n        else\n        {\n            CS_LOG_FATAL(\"GamepadSystem: Received gamepad event for unknown Id.\");\n        }\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Input/Gamepad/GamepadSystem.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2017 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_INPUT_GAMEPAD_GAMEPADSYSTEM_H_\n#define _CHILLISOURCE_INPUT_GAMEPAD_GAMEPADSYSTEM_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Event/Event.h>\n#include <ChilliSource/Core/Math/Vector2.h>\n#include <ChilliSource/Core/System/AppSystem.h>\n#include <ChilliSource/Input/Gamepad/Gamepad.h>\n\n#include <mutex>\n#include <queue>\n\nnamespace ChilliSource\n{\n    /// Provides access to any attached gamepads and has events to listen for changes to gamepad states\n    ///\n    /// Each platform has its own limitations in terms of number of buttons and axes\n    ///\n    class GamepadSystem : public AppSystem\n    {\n    public:\n        \n        CS_DECLARE_NAMEDTYPE(GamepadSystem);\n\n        /// Delegate signature to subscribe to events for whenever the OS detects that a new gamepad has been attached\n        ///\n        /// @param gamepad\n        ///     The newly attached gamepad\n        /// @param timestamp\n        ///     Time at which it was attached\n        ///\n        using GamepadAddedDelegate = std::function<void(const Gamepad& gamepad, f64 timestamp)>;\n        \n        /// Delegate signature to subscribe to events for whenever the user presses or releases a button on the gamepad\n        ///\n        /// @param gamepad\n        ///     The gamepad thats input changed\n        /// @param timestamp\n        ///     Time at which input changed\n        /// @param buttonIndex\n        ///     Index of button thats pressure changed\n        /// @param pressure\n        ///     Updated pressure on the button\n        ///\n        using GamepadButtonPressureChangedDelegate = std::function<void(const Gamepad& gamepad, f64 timestamp, u32 buttonIndex, f32 pressure)>;\n        \n        /// Delegate signature to subscribe to events for whenever the user moves an axis on the gamepad\n        ///\n        /// @param gamepad\n        ///     The gamepad thats input changed\n        /// @param timestamp\n        ///     Time at which input changed\n        /// @param axis\n        ///     Axis thats position changed\n        /// @param position\n        ///     Updated position of the axis\n        ///\n        using GamepadAxisPositionChangedDelegate = std::function<void(const Gamepad& gamepad, f64 timestamp, GamepadAxis axis, f32 position)>;\n        \n        /// Delegate signature to subscribe to events for whenever the user presses or releases a button on the gamepad for a registered mapping.\n        ///\n        /// @param gamepad\n        ///     The gamepad thats input changed\n        /// @param timestamp\n        ///     Time at which input changed\n        /// @param actionId\n        ///     Id used when mapping was registered\n        /// @param pressure\n        ///     Updated pressure on the button\n        ///\n        using GamepadMappedButtonPressureChangedDelegate = std::function<void(const Gamepad& gamepad, f64 timestamp, u32 actionId, f32 pressure)>;\n        \n        /// Delegate signature to subscribe to events for whenever the user moves an axis on the gamepad for a registered mapping.\n        ///\n        /// @param gamepad\n        ///     The gamepad thats input changed\n        /// @param timestamp\n        ///     Time at which input changed\n        /// @param actionId\n        ///     Id used when mapping was registered\n        /// @param position\n        ///     Updated position of the axis\n        ///\n        using GamepadMappedAxisPositionChangedDelegate = std::function<void(const Gamepad& gamepad, f64 timestamp, u32 actionId, f32 position)>;\n\n        /// Delegate signature to subscribe to events for whenever the OS detects that a new gamepad has been unattached\n        ///\n        /// @param gamepad\n        ///     The newly disconnected gamepad\n        /// @param timestamp\n        ///     Time at which it was disconnected\n        ///\n        using GamepadRemovedDelegate = std::function<void(const Gamepad& gamepad, f64 timestamp)>;\n        \n        /// Registers/updates a mapping such that whenever the given axis on the given gamepad is moved\n        /// an event is fired with the given actionId.\n        ///\n        /// If mapping for gamepad/axis combo doesn't exist it is created\n        /// If mapping for gamepad/axis combo does exist it is overwritten\n        ///\n        /// For example:    MoveVertically => XBox360 => GamepadMapping::XBox360::k_dpadY\n        ///                 MoveVertically => XBox360 => GamepadMapping::XBox360::k_lStickY\n        ///                 MoveVertically => PS3 => GamepadMapping::PS3::k_dpadY\n        ///                 MoveVertically => PS3 => GamepadMapping::PS3::k_lStickY\n        ///\n        /// @param actionId\n        ///     Identifier that is passed into the axis moved event\n        /// @param gamepadName\n        ///     Name of the gamepad that this mapping applies to\n        /// @param axis\n        ///     Axis on the gamepad that triggers this action\n        /// @param invert\n        ///     If TRUE flip the value returned by the axis (some controllers report +ve y as -1.0 some as 1.0\n        ///\n        void SetActionMapping(u32 actionId, const std::string& gamepadName, GamepadAxis axis, bool invert = false) noexcept;\n        \n        /// Registers/updates a mapping such that whenever the given button on the given gamepad is pressed or released\n        /// an event is fired with the given actionId.\n        ///\n        /// If mapping for gamepad/button combo doesn't exist it is created\n        /// If mapping for gamepad/button combo does exist it is overwritten\n        ///\n        /// For example:    Fire => XBox360 => GamepadMapping::XBox360::k_rBumper\n        ///                 Fire => PS3 => GamepadMapping::PS3::k_r2\n        ///\n        /// @param actionId\n        ///     Identifier that is passed into the button pressure event\n        /// @param gamepadName\n        ///     Name of the gamepad that this mapping applies to\n        /// @param buttonIndex\n        ///     Buttin on the gamepad that triggers this action\n        ///\n        void SetActionMapping(u32 actionId, const std::string& gamepadName, u32 buttonIndex) noexcept;\n        \n        /// Registers/updates a mapping such that whenever the given axis on a gamepad that is not explicity\n        /// registered is moved an event is fired with the given actionId.\n        ///\n        /// If mapping for axis doesn't exist it is created\n        /// If mapping for axis does exist it is overwritten\n        ///\n        /// For example: MoveVertically => GamepadAxis::k_y\n        ///\n        /// @param actionId\n        ///     Identifier that is passed into the axis moved event\n        /// @param axis\n        ///     Axis on the gamepad that triggers this action\n        ///\n        void SetDefaultActionMapping(u32 actionId, GamepadAxis axis) noexcept;\n        \n        /// Registers/updates a mapping such that whenever the given button on a gamepad not explcity registered\n        /// is pressed or released an event is fired with the given actionId.\n        ///\n        /// If mapping for button doesn't exist it is created\n        /// If mapping for button does exist it is overwritten\n        ///\n        /// For example: Fire => 0\n        ///\n        /// @param actionId\n        ///     Identifier that is passed into the button pressure event\n        /// @param buttonIndex\n        ///     Buttin on the gamepad that triggers this action\n        ///\n        void SetDefaultActionMapping(u32 actionId, u32 buttonIndex) noexcept;\n        \n        /// @return Event triggered when a new gamepad is connected\n        ///\n        IConnectableEvent<GamepadAddedDelegate>& GetGamepadAddedEvent() noexcept { return m_gamepadAddedEvent; }\n\n        /// @return Event triggered when the user presses or releases a button on the gamepad\n        ///\n        IConnectableEvent<GamepadButtonPressureChangedDelegate>& GetButtonPressureChangedEvent() noexcept { return m_buttonPressureChangedEvent; }\n\n        /// @return Event triggered when the user moved an axis input on the gamepad\n        ///\n        IConnectableEvent<GamepadAxisPositionChangedDelegate>& GetAxisPositionChangedEvent() noexcept { return m_axisPositionChangedEvent; }\n        \n        /// @return Event triggered when the user presses or releases a button on the gamepad if the button was registered against as part of a mapping\n        ///\n        IConnectableEvent<GamepadMappedButtonPressureChangedDelegate>& GetMappedButtonPressureChangedEvent() noexcept { return m_mappedButtonPressureChangedEvent; }\n        \n        /// @return Event triggered when the user moved an axis input on the gamepad if the axis was registered against as part of a mapping\n        ///\n        IConnectableEvent<GamepadMappedAxisPositionChangedDelegate>& GetMappedAxisPositionChangedEvent() noexcept { return m_mappedAxisPositionChangedEvent; }\n\n        /// @return Event triggered when a gamepad is disconnected\n        ///\n        IConnectableEvent<GamepadRemovedDelegate>& GetGamepadRemovedEvent() noexcept { return m_gamepadRemovedEvent; }\n\n        /// Attempt to find the gamepad with the given id.\n        ///\n        /// @param uniqueId\n        ///     Unique id of the gamepad to find\n        /// @param [OUT] out_gamepad\n        ///     Populated with found gamepad\n        ///\n        /// @return TRUE if gamepad is found\n        ///\n        bool TryGetGamepadWithId(Gamepad::Id uniqueId, Gamepad& out_gamepad) const noexcept;\n        \n        /// Attempt to find the gamepad with the given index.\n        ///\n        /// @param index\n        ///     Index of gamepad in list if (gamepad 0 is disconnected then gamepad 1 will move to 0 index)\n        /// @param [OUT] out_gamepad\n        ///     Populated with found gamepad\n        ///\n        /// @return TRUE if gamepad is found\n        ///\n        bool TryGetGamepadWithIndex(u32 index, Gamepad& out_gamepad) const noexcept;\n\n        /// @return List of connected gamepads\n        ///\n        std::vector<Gamepad> GetGamepads() const noexcept { return m_gamepads; }\n        \n        /// @return Number of attached gamepads\n        ///\n        u32 GetNumGamepads() const noexcept { return (u32)m_gamepads.size(); }\n        \n        /// Process all input events that have been received from the OS. This\n        /// will fire off events and updated the state of the gamepads\n        ///\n        void ProcessQueuedInput() noexcept;\n\n        ///\n        virtual ~GamepadSystem() {};\n        \n    protected:\n\n        ///\n        GamepadSystem() = default;\n        \n        /// Called by the concrete system implementation to inject a create event\n        ///\n        /// This method is thread safe and can be called on any thread.\n        ///\n        /// @param name\n        ///     Device name of the controller\n        /// @param numButtons\n        ///     Number of buttons on the controller\n        /// @param supportedAxisFlags\n        ///     Flagged bits stating which axes are supported\n        ///\n        /// @return The unique Id of the new gamepad.\n        ///\n        Gamepad::Id AddGamepadCreateEvent(std::string name, u32 numButtons, u32 supportedAxisFlags) noexcept;\n        \n        /// Called by the concrete system implementation to inject a pressure changed event\n        ///\n        /// This method is thread safe and can be called on any thread.\n        ///\n        /// @param uniqueId\n        ///     The unique Id of the gamepad on which button pressure has changed.\n        /// @param buttonIndex\n        ///     Index of button on the gamepad thats pressure has changed\n        /// @param pressure\n        ///     Updated pressure\n        ///\n        void AddButtonPressureChangedEvent(Gamepad::Id uniqueId, u32 buttonIndex, f32 pressure) noexcept;\n        \n        /// Called by the concrete system implementation to inject an axis changed event\n        ///\n        /// This method is thread safe and can be called on any thread.\n        ///\n        /// @param uniqueId\n        ///     The unique Id of the gamepad on which an axis (analogue stick) has moved.\n        /// @param axis\n        ///     Axis on the gamepad thats moved\n        /// @param position\n        ///     Updated position\n        ///\n        void AddAxisPositionChangedEvent(Gamepad::Id uniqueId, GamepadAxis axis, f32 position) noexcept;\n        \n        /// Called by the concrete system implementation to inject a remove event\n        ///\n        /// This method is thread safe and can be called on any thread.\n        ///\n        /// @param uniqueId\n        ///     The unique Id of the gamepad to disconnect.\n        ///\n        void AddGamepadRemoveEvent(Gamepad::Id uniqueId) noexcept;\n\n        /// Disconnects all gamepads. This must be called from the main thread\n        ///\n        void RemoveAllGamepads() noexcept;\n        \n    private:\n        friend class Application;\n\n        /// @return New platform specific system\n        ///\n        static GamepadSystemUPtr Create() noexcept;\n        \n        enum class EventType\n        {\n            k_buttonPressure,\n            k_axisPosition,\n            k_remove\n        };\n        \n        struct GamepadEventData\n        {\n            GamepadEventData(EventType type, Gamepad::Id uid, u32 index, f32 contextVal, f64 timestamp)\n            : m_type(type), m_uniqueId(uid), m_index(index), m_value(contextVal), m_timestamp(timestamp) {}\n\n            EventType m_type;\n            Gamepad::Id m_uniqueId;\n            u32 m_index;\n            f32 m_value;\n            f64 m_timestamp;\n        };\n        \n        struct GamepadCreateEventData\n        {\n            GamepadCreateEventData(Gamepad::Id uid, std::string name, u32 numButtons, u32 supportedAxisFlags, f64 timestamp)\n            : m_uniqueId(uid), m_name(std::move(name)), m_numButtons(numButtons), m_supportedAxisFlags(supportedAxisFlags), m_timestamp(timestamp) {}\n            \n            Gamepad::Id m_uniqueId;\n            std::string m_name;\n            u32 m_numButtons;\n            u32 m_supportedAxisFlags;\n            f64 m_timestamp;\n        };\n        \n        /// Update the state and fire off the external events for the given event\n        ///\n        /// @param event\n        ///     Data about the event\n        ///\n        void ProcessCreateEvent(const GamepadCreateEventData& event) noexcept;\n        \n        /// Update the state and fire off the external events for the given event\n        ///\n        /// @param event\n        ///     Data about the event\n        ///\n        void ProcessButtonPressureEvent(const GamepadEventData& event) noexcept;\n        \n        /// Update the state and fire off the external events for the given event\n        ///\n        /// @param event\n        ///     Data about the event\n        ///\n        void ProcessAxisPositionEvent(const GamepadEventData& event) noexcept;\n        \n        /// Update the state and fire off the external events for the given event\n        ///\n        /// @param event\n        ///     Data about the event\n        ///\n        void ProcessRemoveEvent(const GamepadEventData& event) noexcept;\n        \n        Event<GamepadAddedDelegate> m_gamepadAddedEvent;\n        Event<GamepadButtonPressureChangedDelegate> m_buttonPressureChangedEvent;\n        Event<GamepadAxisPositionChangedDelegate> m_axisPositionChangedEvent;\n        Event<GamepadMappedButtonPressureChangedDelegate> m_mappedButtonPressureChangedEvent;\n        Event<GamepadMappedAxisPositionChangedDelegate> m_mappedAxisPositionChangedEvent;\n        Event<GamepadRemovedDelegate> m_gamepadRemovedEvent;\n        \n        std::mutex m_mutex;\n        std::vector<Gamepad> m_gamepads;\n        std::queue<GamepadEventData> m_eventQueue;\n        std::queue<GamepadCreateEventData> m_createEventQueue;\n        std::vector<std::tuple<u32, u32, f32>> m_axisMappings;\n        std::vector<std::pair<u32, u32>> m_buttonMappings;\n        std::vector<std::pair<u32, u32>> m_defaultAxisMappings;\n        std::vector<std::pair<u32, u32>> m_defaultButtonMappings;\n        Gamepad::Id m_nextUniqueId = 0;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Input/Gamepad.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2017 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n\n#ifndef _CHILLISOURCE_INPUT_GAMEPAD_H_\n#define _CHILLISOURCE_INPUT_GAMEPAD_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Input/Gamepad/Gamepad.h>\n#include <ChilliSource/Input/Gamepad/GamepadAxis.h>\n#include <ChilliSource/Input/Gamepad/GamepadMappings.h>\n#include <ChilliSource/Input/Gamepad/GamepadSystem.h>\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Input/Gesture/DragGesture.cpp",
    "content": "//\n//  DragGesture.cpp\n//  ChilliSource\n//  Created by Ian Copland on 19/09/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Input/Gesture/DragGesture.h>\n\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/Base/Screen.h>\n\nnamespace ChilliSource\n{\n    namespace\n    {\n        const f32 k_minDisplacement = 20.0f;\n    }\n    \n    CS_DEFINE_NAMEDTYPE(DragGesture);\n    //----------------------------------------------------\n    //----------------------------------------------------\n    DragGesture::DragGesture(u32 in_numPointers, Pointer::InputType in_inputType)\n    : m_requiredPointerCount(in_numPointers), m_requiredInputType(in_inputType)\n    {\n        CS_ASSERT(m_requiredPointerCount > 0, \"Cannot have a drag gesture with 0 required pointers.\");\n        \n        Screen* screen = Application::Get()->GetScreen();\n        m_minDisplacementSquared = (k_minDisplacement * screen->GetDensityScale()) * (k_minDisplacement * screen->GetDensityScale());\n        \n        m_pendingPointers.reserve(m_requiredPointerCount);\n    }\n    //----------------------------------------------------\n    //----------------------------------------------------\n    bool DragGesture::IsA(InterfaceIDType in_gestureInterfaceId) const\n    {\n        return (Gesture::InterfaceID == in_gestureInterfaceId || DragGesture::InterfaceID == in_gestureInterfaceId);\n    }\n    //----------------------------------------------------\n    //----------------------------------------------------\n    u32 DragGesture::GetNumPointers() const\n    {\n        return m_requiredPointerCount;\n    }\n    //----------------------------------------------------\n    //----------------------------------------------------\n    Pointer::InputType DragGesture::GetInputType() const\n    {\n        return m_requiredInputType;\n    }\n    //----------------------------------------------------\n    //----------------------------------------------------\n    IConnectableEvent<DragGesture::Delegate>& DragGesture::GetDragStartedEvent()\n    {\n        return m_dragStartedEvent;\n    }\n    //----------------------------------------------------\n    //----------------------------------------------------\n    IConnectableEvent<DragGesture::Delegate>& DragGesture::GetDragMovedEvent()\n    {\n        return m_dragMovedEvent;\n    }\n    //----------------------------------------------------\n    //----------------------------------------------------\n    IConnectableEvent<DragGesture::Delegate>& DragGesture::GetDragEndedEvent()\n    {\n        return m_dragEndedEvent;\n    }\n    //--------------------------------------------------------\n    //--------------------------------------------------------\n    void DragGesture::TryStart(const Pointer& in_pointer)\n    {\n        u32 dragCount = 0;\n        u32 existingActive = 0;\n        for (const auto& pointer : m_pendingPointers)\n        {\n            if (pointer.m_isDrag == true)\n            {\n                ++dragCount;\n            }\n            \n            if (pointer.m_active == true)\n            {\n                ++existingActive;\n            }\n        }\n        \n        CS_ASSERT(existingActive < m_requiredPointerCount, \"gesture is already started if current active count is already at the required amount.\");\n        \n        if (dragCount >= m_requiredPointerCount)\n        {\n            if (IsActive() == false && ResolveConflicts() == false)\n            {\n                return;\n            }\n            \n            u32 activeCount = existingActive;\n            for (auto& pointer : m_pendingPointers)\n            {\n                if (pointer.m_isDrag == true && pointer.m_active == false && activeCount < m_requiredPointerCount)\n                {\n                    pointer.m_active = true;\n                    ++activeCount;\n                }\n            }\n            \n            m_paused = false;\n            \n            if (IsActive() == false)\n            {\n                SetActive(true);\n                m_currentDragInfo.m_position = CalculatePosition();\n                m_currentDragInfo.m_displacement = Vector2::k_zero;\n                m_currentDragInfo.m_delta = Vector2::k_zero;\n                m_dragStartedEvent.NotifyConnections(this, m_currentDragInfo);\n            }\n            else\n            {\n                m_currentDragInfo.m_position = CalculatePosition();\n                m_dragMovedEvent.NotifyConnections(this, m_currentDragInfo);\n            }\n        }\n    }\n    //----------------------------------------------------\n    //----------------------------------------------------\n    Vector2 DragGesture::CalculatePosition() const\n    {\n        Vector2 gesturePos = Vector2::k_zero;\n        if (m_pendingPointers.size() >= m_requiredPointerCount && IsActive() == true && m_paused == false)\n        {\n            for (const auto& pointer : m_pendingPointers)\n            {\n                if (pointer.m_active == true)\n                {\n                    gesturePos += pointer.m_currentPosition;\n                }\n            }\n            \n            gesturePos /= f32(m_requiredPointerCount);\n        }\n        \n        return gesturePos;\n    }\n    //--------------------------------------------------------\n    //--------------------------------------------------------\n    void DragGesture::Cancel()\n    {\n        CS_ASSERT(IsActive() == true, \"Cannot cancel a gesture that isn't active.\");\n        \n        for (auto& pointer : m_pendingPointers)\n        {\n            pointer.m_active = false;\n        }\n        \n        SetActive(false);\n        m_paused = false;\n        \n        m_currentDragInfo.m_delta = Vector2::k_zero;\n        m_dragEndedEvent.NotifyConnections(this, m_currentDragInfo);\n        \n        m_currentDragInfo.m_displacement = Vector2::k_zero;\n        m_currentDragInfo.m_position = Vector2::k_zero;\n    }\n    //--------------------------------------------------------\n    //--------------------------------------------------------\n    void DragGesture::Reset()\n    {\n        if (IsActive())\n        {\n            Cancel();\n        }\n        \n        m_pendingPointers.clear();\n    }\n    //--------------------------------------------------------\n    //--------------------------------------------------------\n    void DragGesture::OnPointerDown(const Pointer& in_pointer, f64 in_timestamp, Pointer::InputType in_inputType)\n    {\n        if (in_inputType == m_requiredInputType)\n        {\n            PointerInfo pointerInfo;\n            pointerInfo.m_pointerId = in_pointer.GetId();\n            pointerInfo.m_currentPosition = in_pointer.GetPosition();\n            m_pendingPointers.push_back(pointerInfo);\n        }\n    }\n    //--------------------------------------------------------\n    //--------------------------------------------------------\n    void DragGesture::OnPointerMoved(const Pointer& in_pointer, f64 in_timestamp)\n    {\n        if (m_pendingPointers.size() > 0)\n        {\n            bool isPending = false;\n            bool isActive = false;\n            for (auto& pointer : m_pendingPointers)\n            {\n                if (in_pointer.GetId() == pointer.m_pointerId)\n                {\n                    pointer.m_currentPosition = in_pointer.GetPosition();\n                    \n                    Vector2 displacement = pointer.m_currentPosition - pointer.m_initialPosition;\n                    if (displacement.LengthSquared() > m_minDisplacementSquared)\n                    {\n                        pointer.m_isDrag = true;\n                    }\n                    \n                    if (pointer.m_active == true)\n                    {\n                        isActive = true;\n                    }\n                    \n                    isPending = true;\n                }\n            }\n            \n            if (isPending == true)\n            {\n                if (IsActive() == false || m_paused == true)\n                {\n                    TryStart(in_pointer);\n                }\n                else if (isActive == true)\n                {\n                    Vector2 newPosition = CalculatePosition();\n                    m_currentDragInfo.m_delta = newPosition - m_currentDragInfo.m_position;\n                    m_currentDragInfo.m_displacement += m_currentDragInfo.m_delta;\n                    m_currentDragInfo.m_position = newPosition;\n                    m_dragMovedEvent.NotifyConnections(this, m_currentDragInfo);\n                }\n            }\n        }\n    }\n    //--------------------------------------------------------\n    //--------------------------------------------------------\n    void DragGesture::OnPointerUp(const Pointer& in_pointer, f64 in_timestamp, Pointer::InputType in_inputType)\n    {\n        if (in_inputType == m_requiredInputType)\n        {\n            if (m_pendingPointers.size() > 0)\n            {\n                for (auto pointerIt = m_pendingPointers.begin(); pointerIt != m_pendingPointers.end();)\n                {\n                    if (in_pointer.GetId() == pointerIt->m_pointerId)\n                    {\n                        if (pointerIt->m_active == true)\n                        {\n                            m_paused = true;\n                        }\n                        \n                        pointerIt = m_pendingPointers.erase(pointerIt);\n                        break;\n                    }\n                    else\n                    {\n                        ++pointerIt;\n                    }\n                }\n                \n                if (m_pendingPointers.empty() == true && IsActive() == true)\n                {\n                    Cancel();\n                }\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Input/Gesture/DragGesture.h",
    "content": "//\n//  DragGesture.h\n//  ChilliSource\n//  Created by Ian Copland on 19/09/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_INPUT_GESTURE_DRAGGESTURE_H_\n#define _CHILLISOURCE_INPUT_GESTURE_DRAGGESTURE_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Event/Event.h>\n#include <ChilliSource/Input/Gesture/Gesture.h>\n\n#include <functional>\n\nnamespace ChilliSource\n{\n    //----------------------------------------------------------\n    /// A gesture for receiving drag input events. This incudes\n    /// support for multi-finger events such as a two finger\n    /// drag.\n    ///\n    /// A drag gesture is started when the required pointer\n    /// count is reached.\n    ///\n    /// Drag moved events will be sent when any movement occurs\n    /// with exactly the correct number of pointers on the screen.\n    ///\n    /// A drag will end when all fingers are lifted from the\n    /// screen.\n    ///\n    /// @author Ian Copland\n    //----------------------------------------------------------\n    class DragGesture final : public Gesture\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(DragGesture);\n        //----------------------------------------------------\n        /// A container for information on a single drag event.\n        ///\n        /// @author Ian Copland\n        //----------------------------------------------------\n        struct DragInfo final\n        {\n            Vector2 m_position;        //The screen space location of the gesture.\n            Vector2 m_displacement;   //The displacement since the gesture started. Displacement caused by the currently tracked pointer changing is ignored.\n            Vector2 m_delta;          //The change in displacement since the last event. Displacement caused by the currently tracked pointer changing is ignored.\n        };\n        //----------------------------------------------------\n        /// A delegate called for any of the drag gesture\n        /// event.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param A pointer to the drag gesture.\n        /// @param Information on the drag.\n        //----------------------------------------------------\n        using Delegate = std::function<void(const DragGesture*, const DragInfo&)>;\n        //----------------------------------------------------\n        /// Constructor. Constructs the drag gesture with the\n        /// given settings.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The number of pointers that should be\n        /// down per tap. Defaults to 1.\n        /// @param The input type this gesture should listen\n        /// for. Defaults to using the default input type.\n        //----------------------------------------------------\n        DragGesture(u32 in_numPointers = 1, Pointer::InputType in_inputType = Pointer::GetDefaultInputType());\n        //----------------------------------------------------\n        /// Queries whether or not this implements the gesture\n        /// interface with the given Id.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The gesture interface Id.\n        ///\n        /// @return Whether or not the gesture inteface is\n        /// implemented.\n        //----------------------------------------------------\n        bool IsA(InterfaceIDType in_gestureInterfaceId) const override;\n        //----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The number of pointers required by this\n        /// gesture.\n        //----------------------------------------------------\n        u32 GetNumPointers() const;\n        //----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The input type this gesture will listen for.\n        //----------------------------------------------------\n        Pointer::InputType GetInputType() const;\n        //----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return An event that can be used to listen for the\n        /// start of a drag gesture.\n        //----------------------------------------------------\n        IConnectableEvent<Delegate>& GetDragStartedEvent();\n        //----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return An event that can be used to list for\n        /// movement events within a drag gesture.\n        //----------------------------------------------------\n        IConnectableEvent<Delegate>& GetDragMovedEvent();\n        //----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return An event that can be used to list for\n        /// the end of a drag gesture.\n        //----------------------------------------------------\n        IConnectableEvent<Delegate>& GetDragEndedEvent();\n    private:\n        //----------------------------------------------------\n        /// Information on a single pointer within the gesture.\n        ///\n        /// @author Ian Copland\n        //----------------------------------------------------\n        struct PointerInfo\n        {\n            Pointer::Id m_pointerId;\n            Vector2 m_initialPosition;\n            Vector2 m_currentPosition;\n            bool m_isDrag = false;\n            bool m_active = false;\n        };\n        //--------------------------------------------------------\n        /// Tries to activate or un-pause a drag gesture.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The pointer.\n        //--------------------------------------------------------\n        void TryStart(const Pointer& in_pointer);\n        //----------------------------------------------------\n        /// Calculates the current position of the gesture.\n        /// This will be the centre position between all pointers\n        /// involved in the gesture.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @return The calculated position.\n        //----------------------------------------------------\n        Vector2 CalculatePosition() const;\n        //--------------------------------------------------------\n        /// This will be called if the gesture is currently active\n        /// and conflict resolution deduces that it should end.\n        /// This will de-activate the current gesture and set all\n        /// pointers back to inactive.\n        ///\n        /// @author Ian Copland\n        //--------------------------------------------------------\n        void Cancel() override;\n        //--------------------------------------------------------\n        /// This is called to reset the gesture back to its\n        /// intials state. If the gesture was active, it will be\n        /// reset. Any data keeping track of the current state of\n        /// the gesture should be reset. This is typically called\n        /// when transitioning scenes, to ensure the gesture is\n        /// not in an invalid state when transitioning back.\n        ///\n        /// @author Ian Copland\n        //--------------------------------------------------------\n        void Reset() override;\n        //--------------------------------------------------------\n        /// Called when a pointer down event occurs.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The pointer.\n        /// @param The timestamp of the event.\n        /// @param The press type.\n        //--------------------------------------------------------\n        void OnPointerDown(const Pointer& in_pointer, f64 in_timestamp, Pointer::InputType in_inputType) override;\n        //--------------------------------------------------------\n        /// Called when a pointer moved event occurs.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The pointer\n        /// @param The timestamp of the event.\n        //--------------------------------------------------------\n        void OnPointerMoved(const Pointer& in_pointer, f64 in_timestamp) override;\n        //--------------------------------------------------------\n        /// Called when a pointer up event occurs.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The pointer\n        /// @param The timestamp of the event.\n        /// @param The press type.\n        //--------------------------------------------------------\n        void OnPointerUp(const Pointer& in_pointer, f64 in_timestamp, Pointer::InputType in_inputType) override;\n        \n        u32 m_requiredPointerCount;\n        Pointer::InputType m_requiredInputType;\n        Event<Delegate> m_dragStartedEvent;\n        Event<Delegate> m_dragMovedEvent;\n        Event<Delegate> m_dragEndedEvent;\n\n        f32 m_minDisplacementSquared = 0.0f;\n        \n        std::vector<PointerInfo> m_pendingPointers;\n        DragInfo m_currentDragInfo;\n        bool m_paused = false;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Input/Gesture/Gesture.cpp",
    "content": "//\n//  Gesture.cpp\n//  ChilliSource\n//  Created by Ian Copland on 17/09/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Input/Gesture/Gesture.h>\n\n#include <ChilliSource/Input/Gesture/GestureSystem.h>\n\nnamespace ChilliSource\n{\n    CS_DEFINE_NAMEDTYPE(Gesture);\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    bool Gesture::ResolveConflicts()\n    {\n        if (m_gestureSystem != nullptr)\n        {\n            return m_gestureSystem->ResolveConflicts(this);\n        }\n        \n        return false;\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    void Gesture::SetActive(bool in_active)\n    {\n        m_active = in_active;\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    bool Gesture::IsActive() const\n    {\n        return m_active;\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    void Gesture::SetGestureSystem(GestureSystem* in_gestureSystem)\n    {\n        m_gestureSystem = in_gestureSystem;\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Input/Gesture/Gesture.h",
    "content": "//\n//  Gesture.h\n//  ChilliSource\n//  Created by Ian Copland on 17/09/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_INPUT_GESTURE_GESTURE_H_\n#define _CHILLISOURCE_INPUT_GESTURE_GESTURE_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Base/QueryableInterface.h>\n#include <ChilliSource/Input/Pointer/Pointer.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------\n    /// The base class for all input gestures that can be registered\n    /// with the gesture system.\n    ///\n    /// @author Ian Copland\n    //------------------------------------------------------------\n    class Gesture : public QueryableInterface\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(Gesture);\n        CS_DECLARE_NOCOPY(Gesture);\n        //-------------------------------------------------------\n        /// Destructor\n        ///\n        /// @author Ian Copland\n        //-------------------------------------------------------\n        virtual ~Gesture() {};\n        \n    protected:\n        //-------------------------------------------------------\n        /// Protected default constructor\n        ///\n        /// @author Ian Copland\n        //-------------------------------------------------------\n        Gesture() = default;\n        //-------------------------------------------------------\n        /// Queries for gesture conficts to see if this can\n        /// activate. If the gesture cannot activate no events\n        /// should be fired. All gestures must call this prior to\n        /// the first event in a gesture instance being called.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param Whether or not to set active.\n        //-------------------------------------------------------\n        bool ResolveConflicts();\n        //-------------------------------------------------------\n        /// Sets the gesture active. This should be set for any\n        /// gesture that will be active for a sustained time like\n        /// a drag gesture. Instantious gestures such as a tap\n        /// should not. This is used to flag conflicts between\n        /// different gestures.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param Whether or not to set active.\n        //-------------------------------------------------------\n        void SetActive(bool in_active);\n        //-------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return Whether or not the gesture is currently\n        /// active. This will never be true for gestures that\n        /// are only active for a instant, such as a tap.\n        //-------------------------------------------------------\n        bool IsActive() const;\n        //--------------------------------------------------------\n        /// This will be called if the gesture is currently active\n        /// and conflict resolution deduces that it should end.\n        /// This will de-activate the current gesture and set all\n        /// pointers back to inactive.\n        ///\n        /// @author Ian Copland\n        //--------------------------------------------------------\n        virtual void Cancel() {}\n        //--------------------------------------------------------\n        /// This is called to reset the gesture back to its\n        /// intials state. If the gesture was active, it will be\n        /// reset. Any data keeping track of the current state of\n        /// the gesture should be reset. This is typically called\n        /// when transitioning scenes, to ensure the gesture is\n        /// not in an invalid state when transitioning back.\n        ///\n        /// @author Ian Copland\n        //--------------------------------------------------------\n        virtual void Reset() {}\n        //--------------------------------------------------------\n        /// A method that can optionally be implemented by the\n        /// implementing class to receive update events.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The delta time since the last update.\n        //--------------------------------------------------------\n        virtual void OnUpdate(f32 in_deltaTime) {};\n        //--------------------------------------------------------\n        /// A method that can optionally be implemented by the\n        /// implementing class to receive pointer down events.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The pointer.\n        /// @param The timestamp of the event.\n        /// @param The press type.\n        //--------------------------------------------------------\n        virtual void OnPointerDown(const Pointer& in_pointer, f64 in_timestamp, Pointer::InputType in_inputType) {};\n        //--------------------------------------------------------\n        /// A method that can optionally be implemented by the\n        /// implementing class to receive pointer moved events.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The pointer\n        /// @param The timestamp of the event.\n        //--------------------------------------------------------\n        virtual void OnPointerMoved(const Pointer& in_pointer, f64 in_timestamp) {};\n        //--------------------------------------------------------\n        /// A method that can optionally be implemented by the\n        /// implementing class to receive pointer up events.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The pointer\n        /// @param The timestamp of the event.\n        /// @param The press type.\n        //--------------------------------------------------------\n        virtual void OnPointerUp(const Pointer& in_pointer, f64 in_timestamp, Pointer::InputType in_inputType) {};\n        //--------------------------------------------------------\n        /// A method that can optionally be implemented by the\n        /// implementing class to receive pointer scrolled events.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The pointer\n        /// @param The timestamp of the event.\n        /// @param The scroll vector (x, y delta)\n        //--------------------------------------------------------\n        virtual void OnPointerScrolled(const Pointer& in_pointer, f64 in_timestamp, const Vector2& in_delta) {};\n        \n    private:\n        friend class GestureSystem;\n        //-------------------------------------------------------\n        /// Will be called by the gesture system when this is\n        /// added to it.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The gesture system. Can be null if removing\n        /// from a gesture system.\n        //-------------------------------------------------------\n        void SetGestureSystem(GestureSystem* in_gestureSystem);\n        \n        GestureSystem* m_gestureSystem = nullptr;\n        bool m_active = false;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Input/Gesture/GestureSystem.cpp",
    "content": "//\n//  GestureSystem.cpp\n//  ChilliSource\n//  Created by Ian Copland on 17/09/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Input/Gesture/GestureSystem.h>\n\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/Delegate/MakeDelegate.h>\n#include <ChilliSource/Input/Base/InputFilter.h>\n#include <ChilliSource/Input/Gesture/Gesture.h>\n#include <ChilliSource/Input/Pointer/PointerSystem.h>\n\nnamespace ChilliSource\n{\n    namespace\n    {\n        //-------------------------------------------------------\n        /// Searches the given gesture list for the given gesture\n        /// pointer to see if it exists.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The gesture list.\n        /// @param The gesture to look for.\n        ///\n        /// @return Whether or not it exists.\n        //-------------------------------------------------------\n#if CS_ENABLE_DEBUG\n        bool GestureExists(concurrent_vector<GestureSPtr>& in_gestureList, const Gesture* in_gesture)\n        {\n            in_gestureList.lock();\n            for (const auto& gesturePair : in_gestureList)\n            {\n                if (gesturePair.get() == in_gesture)\n                {\n                    return true;\n                }\n            }\n            in_gestureList.unlock();\n            return false;\n        }\n#endif\n    }\n    \n    CS_DEFINE_NAMEDTYPE(GestureSystem);\n    //--------------------------------------------------------\n    //--------------------------------------------------------\n    GestureSystemUPtr GestureSystem::Create()\n    {\n        return GestureSystemUPtr(new GestureSystem());\n    }\n    //--------------------------------------------------------\n    //--------------------------------------------------------\n    bool GestureSystem::IsA(InterfaceIDType in_interfaceId) const\n    {\n        return (GestureSystem::InterfaceID == in_interfaceId);\n    }\n    //--------------------------------------------------------\n    //--------------------------------------------------------\n    void GestureSystem::AddGesture(const GestureSPtr& in_gesture)\n    {\n        std::unique_lock<std::recursive_mutex> lock(m_mutex);\n        CS_ASSERT(GestureExists(m_gestures, in_gesture.get()) == false, \"Cannot add a gesture that has already been added to the Gesture System.\");\n        in_gesture->SetGestureSystem(this);\n        m_gestures.push_back(in_gesture);\n    }\n    //--------------------------------------------------------\n    //--------------------------------------------------------\n    void GestureSystem::RemoveGesture(const Gesture* in_gesture)\n    {\n        std::unique_lock<std::recursive_mutex> lock(m_mutex);\n        m_gestures.lock();\n        \n        CS_ASSERT(GestureExists(m_gestures, in_gesture) == true, \"Cannot remove a gesture that hasn't been added to the Gesture System.\");\n        \n        for (auto it = m_gestures.begin(); it != m_gestures.end();)\n        {\n            if (it->get() == in_gesture)\n            {\n                (*it)->SetGestureSystem(nullptr);\n                m_gestures.erase(it);\n                break;\n            }\n            else\n            {\n                ++it;\n            }\n        }\n        \n        m_gestures.unlock();\n    }\n    //--------------------------------------------------------\n    //--------------------------------------------------------\n    void GestureSystem::SetConflictResolutionDelegate(const ConflictResolutionDelegate& in_delegate)\n    {\n        std::unique_lock<std::recursive_mutex> lock(m_mutex);\n        m_conflictResolutionDelegate = in_delegate;\n    }\n    //--------------------------------------------------------\n    //--------------------------------------------------------\n    bool GestureSystem::ResolveConflicts(Gesture* in_gesture)\n    {\n        std::unique_lock<std::recursive_mutex> lock(m_mutex);\n        m_gestures.lock();\n        \n        bool canActivate = true;\n        \n        if (m_conflictResolutionDelegate != nullptr)\n        {\n            for (const auto& gesture : m_gestures)\n            {\n                if (gesture.get() != in_gesture && gesture->IsActive() == true)\n                {\n                    ConflictResult conflictResult = m_conflictResolutionDelegate(gesture.get(), in_gesture);\n                    \n                    switch (conflictResult)\n                    {\n                        case ConflictResult::k_neitherGesture:\n                            gesture->Cancel();\n                            canActivate = false;\n                            break;\n                        case ConflictResult::k_existingGesture:\n                            canActivate = false;\n                            break;\n                        case ConflictResult::k_newGesture:\n                            gesture->Cancel();\n                            break;\n                        case ConflictResult::k_bothGestures:\n                            break;\n                    }\n                }\n            }\n        }\n        \n        m_gestures.unlock();\n        return canActivate;\n    }\n    //--------------------------------------------------------\n    //--------------------------------------------------------\n    void GestureSystem::ResetAll()\n    {\n        std::unique_lock<std::recursive_mutex> lock(m_mutex);\n        m_gestures.lock();\n        \n        for (const auto& gesture : m_gestures)\n        {\n            gesture->Reset();\n        }\n        \n        m_gestures.unlock();\n    }\n    //--------------------------------------------------------\n    //--------------------------------------------------------\n    void GestureSystem::OnResume()\n    {\n        PointerSystem* pointerSystem = Application::Get()->GetSystem<PointerSystem>();\n        CS_ASSERT(pointerSystem != nullptr, \"Gesture system missing required system: Pointer System\");\n        \n        m_pointerDownConnection = pointerSystem->GetPointerDownEventInternal().OpenConnection(MakeDelegate(this, &GestureSystem::OnPointerDown));\n        m_pointerMovedConnection = pointerSystem->GetPointerMovedEvent().OpenConnection(MakeDelegate(this, &GestureSystem::OnPointerMoved));\n        m_pointerUpConnection = pointerSystem->GetPointerUpEvent().OpenConnection(MakeDelegate(this, &GestureSystem::OnPointerUp));\n        m_pointerScrolledConnection = pointerSystem->GetPointerScrollEventInternal().OpenConnection(MakeDelegate(this, &GestureSystem::OnPointerScrolled));\n    }\n    //--------------------------------------------------------\n    //--------------------------------------------------------\n    void GestureSystem::OnUpdate(f32 in_deltaTime)\n    {\n        std::unique_lock<std::recursive_mutex> lock(m_mutex);\n        m_gestures.lock();\n        \n        for (const auto& gesture : m_gestures)\n        {\n            gesture->OnUpdate(in_deltaTime);\n        }\n        \n        m_gestures.unlock();\n    }\n    //--------------------------------------------------------\n    //--------------------------------------------------------\n    void GestureSystem::OnPointerDown(const Pointer& in_pointer, f64 in_timestamp, Pointer::InputType in_inputType, InputFilter& in_filter)\n    {\n        if (in_filter.IsFiltered() == false)\n        {\n            std::unique_lock<std::recursive_mutex> lock(m_mutex);\n            m_gestures.lock();\n            \n            for (const auto& gesture : m_gestures)\n            {\n                gesture->OnPointerDown(in_pointer, in_timestamp, in_inputType);\n            }\n            \n            m_gestures.unlock();\n        }\n    }\n    //--------------------------------------------------------\n    //--------------------------------------------------------\n    void GestureSystem::OnPointerMoved(const Pointer& in_pointer, f64 in_timestamp)\n    {\n        std::unique_lock<std::recursive_mutex> lock(m_mutex);\n        m_gestures.lock();\n        \n        for (const auto& gesture : m_gestures)\n        {\n            gesture->OnPointerMoved(in_pointer, in_timestamp);\n        }\n        \n        m_gestures.unlock();\n    }\n    //--------------------------------------------------------\n    //--------------------------------------------------------\n    void GestureSystem::OnPointerUp(const Pointer& in_pointer, f64 in_timestamp, Pointer::InputType in_inputType)\n    {\n        std::unique_lock<std::recursive_mutex> lock(m_mutex);\n        m_gestures.lock();\n        \n        for (const auto& gesture : m_gestures)\n        {\n            gesture->OnPointerUp(in_pointer, in_timestamp, in_inputType);\n        }\n        \n        m_gestures.unlock();\n    }\n    //--------------------------------------------------------\n    //--------------------------------------------------------\n    void GestureSystem::OnPointerScrolled(const Pointer& in_pointer, f64 in_timestamp, const Vector2& in_delta, InputFilter& in_filter)\n    {\n        if (in_filter.IsFiltered() == false)\n        {\n            std::unique_lock<std::recursive_mutex> lock(m_mutex);\n            m_gestures.lock();\n            \n            for (const auto& gesture : m_gestures)\n            {\n                gesture->OnPointerScrolled(in_pointer, in_timestamp, in_delta);\n            }\n            \n            m_gestures.unlock();\n        }\n    }\n    //-------------------------------------------------------\n    //--------------------------------------------------------\n    void GestureSystem::OnPointerDownLegacy(const Pointer& in_pointer, f64 in_timestamp, Pointer::InputType in_inputType)\n    {\n        InputFilter filter;\n        OnPointerDown(in_pointer, in_timestamp, in_inputType, filter);\n    }\n    //--------------------------------------------------------\n    //--------------------------------------------------------\n    void GestureSystem::OnSuspend()\n    {\n        ResetAll();\n        \n        m_pointerScrolledConnection.reset();\n        m_pointerUpConnection.reset();\n        m_pointerMovedConnection.reset();\n        m_pointerDownConnection.reset();\n    }\n    //--------------------------------------------------------\n    //--------------------------------------------------------\n    void GestureSystem::OnDestroy()\n    {\n        std::unique_lock<std::recursive_mutex> lock(m_mutex);\n        m_gestures.lock();\n        \n        m_conflictResolutionDelegate = nullptr;\n        \n        for (const auto& gesture : m_gestures)\n        {\n            gesture->SetGestureSystem(nullptr);\n        }\n        m_gestures.clear();\n        \n        m_gestures.unlock();\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Input/Gesture/GestureSystem.h",
    "content": "//\n//  GestureSystem.h\n//  ChilliSource\n//  Created by Ian Copland on 17/09/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_INPUT_GESTURE_GESTURESYSTEM_H_\n#define _CHILLISOURCE_INPUT_GESTURE_GESTURESYSTEM_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Container/concurrent_vector.h>\n#include <ChilliSource/Core/Event/Event.h>\n#include <ChilliSource/Core/System/StateSystem.h>\n#include <ChilliSource/Input/Pointer/Pointer.h>\n\n#include <functional>\n#include <mutex>\n\nnamespace ChilliSource\n{\n    //---------------------------------------------------------------\n    /// A system for managing all input gestures. All gestures must\n    /// be registered with this system before they will recieve input\n    /// events. Gesture collision resolution can also be handled\n    /// through this system.\n    ///\n    /// @author Ian Copland\n    //---------------------------------------------------------------\n    class GestureSystem final : public StateSystem\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(GestureSystem);\n        //--------------------------------------------------------\n        /// An enum describing the possible results from a gesture\n        /// conflict.\n        ///\n        /// @author Ian Copland\n        //--------------------------------------------------------\n        enum class ConflictResult\n        {\n            k_neitherGesture,\n            k_existingGesture,\n            k_newGesture,\n            k_bothGestures\n        };\n        //--------------------------------------------------------\n        /// A delegate which will be called when the activation of\n        /// a gesture conflicts with another. The delegate should\n        /// return a Conflict Result decribing which gesture\n        /// should continue/activate.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The existing gesture that is already active.\n        /// @param The new gesture trying to activate.\n        ///\n        /// @return The result of the collision. The value returned\n        /// should reflect which gestures will be allowed to start\n        /// or continue.\n        //---------------------------------------------------------\n        using ConflictResolutionDelegate = std::function<ConflictResult(const Gesture*, const Gesture*)>;\n        //--------------------------------------------------------\n        /// Queries whether or not this implements the interface\n        /// with the given Id. This is threadsafe.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The interface Id.\n        ///\n        /// @return Whether or not the inteface is implemented.\n        //---------------------------------------------------------\n        bool IsA(InterfaceIDType in_interfaceId) const override;\n        //--------------------------------------------------------\n        /// Adds a gesture to the gesture system. When added to the\n        /// system a gesture will receive input events. This is\n        /// threadsafe.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The gesture to add to the system.\n        //---------------------------------------------------------\n        void AddGesture(const GestureSPtr& in_gesture);\n        //--------------------------------------------------------\n        /// Removes a gesture from the system. When removed from\n        /// the system a gesture will no longer recieve input\n        /// events. This is threadsafe.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The gesture which should be removed from the\n        /// system.\n        //---------------------------------------------------------\n        void RemoveGesture(const Gesture* in_gesture);\n        //--------------------------------------------------------\n        /// Sets a delegate that should be used to handle gesture\n        /// conflict resolution. If two gestures are active at\n        /// the same time the delegate will be called. The conflict\n        /// result enum describes what the result of the conflict\n        /// should be. If no delegate is set both will always be\n        /// allowed. This is threadsafe.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The delegate. Can be null.\n        //---------------------------------------------------------\n        void SetConflictResolutionDelegate(const ConflictResolutionDelegate& in_delegate);\n    private:\n\n        friend class State;\n        friend class Gesture;\n        //--------------------------------------------------------\n        /// Creates a new instance of this system. This shou\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The content downloader that should be used.\n        ///\n        /// @return The new system instance.\n        //--------------------------------------------------------\n        static GestureSystemUPtr Create();\n        //--------------------------------------------------------\n        /// Default constructor. Declared private to force the use\n        /// of the factory method.\n        ///\n        /// @author Ian Copland\n        //--------------------------------------------------------\n        GestureSystem() = default;\n        //--------------------------------------------------------\n        /// Process all deferred additions and removals to and\n        /// from the gesture list.\n        ///\n        /// @author Ian Copland\n        //--------------------------------------------------------\n        void ProcessDeferredAddAndRemovals();\n        //--------------------------------------------------------\n        /// Performs conflict resolution on the gestures and\n        /// returns whether or not the given gesture can be activated.\n        /// Any gestures that are currently active which should end\n        /// on conflict with this gesture will have their Cancel()\n        /// method called.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The gesture to perform conflict detection on.\n        ///\n        /// @param Whether or not the gesture can activate.\n        //--------------------------------------------------------\n        bool ResolveConflicts(Gesture* in_gesture);\n        //--------------------------------------------------------\n        /// Resets all gestures.\n        ///\n        /// @author Ian Copland\n        //--------------------------------------------------------\n        void ResetAll();\n        //--------------------------------------------------------\n        /// Called when the owning state is resumed. This\n        /// registers for the input events.\n        ///\n        /// @author Ian Copland\n        //--------------------------------------------------------\n        void OnResume() override;\n        //--------------------------------------------------------\n        /// Called when the owning state is updated. This passes\n        /// the event onto all registered gestures.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The delta time since the last update.\n        //--------------------------------------------------------\n        void OnUpdate(f32 in_deltaTime) override;\n        //--------------------------------------------------------\n        /// Called when a pointer down event is received from the\n        /// pointer system. This will be relayed onto each\n        /// active gesture in this gesture system.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The pointer.\n        /// @param The timestamp of the event.\n        /// @param The press type.\n        /// @param The filter, allowing exclusion from the filtered\n        /// input event.\n        //--------------------------------------------------------\n        void OnPointerDown(const Pointer& in_pointer, f64 in_timestamp, Pointer::InputType in_inputType, InputFilter& in_filter);\n        //--------------------------------------------------------\n        /// Called when a pointer moved event is received from the\n        /// pointer system. This will be relayed onto each active\n        /// gesture in this gesture system.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The pointer\n        /// @param The timestamp of the event.\n        //--------------------------------------------------------\n        void OnPointerMoved(const Pointer& in_pointer, f64 in_timestamp);\n        //--------------------------------------------------------\n        /// Called when a pointer up event is received from the\n        /// pointer system. This will be relayed onto each active\n        /// gesture in this system.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The pointer\n        /// @param The timestamp of the event.\n        /// @param The press type.\n        //--------------------------------------------------------\n        void OnPointerUp(const Pointer& in_pointer, f64 in_timestamp, Pointer::InputType in_inputType);\n        //--------------------------------------------------------\n        /// Called when a pointer scrolled event is received from\n        /// the pointer system. This will be relayed onto each\n        /// active gesture in this system.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The pointer\n        /// @param The timestamp of the event.\n        /// @param The scroll vector (x, y delta)\n        /// @param The filter, allowing exclusion from the filtered\n        /// input event.\n        //--------------------------------------------------------\n        void OnPointerScrolled(const Pointer& in_pointer, f64 in_timestamp, const Vector2& in_delta, InputFilter& in_filter);\n        //-------------------------------------------------------\n        /// A proxy method for calling GestureSystem::OnPointerDown()\n        /// using the old GUI consumption model. This simply relays\n        /// on the information to the new method with a unfiltered\n        /// filter.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The pointer.\n        /// @param The timestamp of the event.\n        /// @param The press type.\n        //--------------------------------------------------------\n        void OnPointerDownLegacy(const Pointer& in_pointer, f64 in_timestamp, Pointer::InputType in_inputType);\n        //--------------------------------------------------------\n        /// Called when the owning state is suspeneded. This\n        /// de-registers all of the input events.\n        ///\n        /// @author Ian Copland\n        //--------------------------------------------------------\n        void OnSuspend() override;\n        //--------------------------------------------------------\n        /// Called when the owning state is destroyed. \n        ///\n        /// @author Ian Copland\n        //--------------------------------------------------------\n        void OnDestroy() override;\n        \n        std::recursive_mutex m_mutex;\n        concurrent_vector<GestureSPtr> m_gestures;\n        \n        ConflictResolutionDelegate m_conflictResolutionDelegate;\n\n        EventConnectionUPtr m_pointerDownConnection;\n        EventConnectionUPtr m_pointerMovedConnection;\n        EventConnectionUPtr m_pointerUpConnection;\n        EventConnectionUPtr m_pointerScrolledConnection;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Input/Gesture/HoldGesture.cpp",
    "content": "//\n//  HoldGesture.cpp\n//  ChilliSource\n//  Created by Ian Copland on 19/09/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Input/Gesture/HoldGesture.h>\n\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/Base/Screen.h>\n\nnamespace ChilliSource\n{\n    namespace\n    {\n        const f32 k_minTimeBetweenAttempts = 0.015f;\n        const f32 k_maxDisplacement = 20.0f;\n        const f32 k_maxTimeBetweenPointers = 0.15f;\n        const f32 k_holdTime = 0.75f;\n    }\n    \n    CS_DEFINE_NAMEDTYPE(HoldGesture);\n    //----------------------------------------------------\n    //----------------------------------------------------\n    HoldGesture::HoldGesture(u32 in_numPointers, Pointer::InputType in_inputType)\n    : m_requiredPointerCount(in_numPointers), m_requiredInputType(in_inputType)\n    {\n        CS_ASSERT(m_requiredPointerCount > 0, \"Cannot have a hold gesture which requres 0 pointers.\");\n        \n        Screen* screen = Application::Get()->GetScreen();\n        \n        m_maxDisplacementSquared = (k_maxDisplacement * screen->GetDensityScale()) * (k_maxDisplacement * screen->GetDensityScale());\n        m_pendingPointers.reserve(m_requiredPointerCount);\n    }\n    //----------------------------------------------------\n    //----------------------------------------------------\n    bool HoldGesture::IsA(InterfaceIDType in_gestureInterfaceId) const\n    {\n        return (Gesture::InterfaceID == in_gestureInterfaceId || HoldGesture::InterfaceID == in_gestureInterfaceId);\n    }\n    //----------------------------------------------------\n    //----------------------------------------------------\n    u32 HoldGesture::GetNumPointers() const\n    {\n        return m_requiredPointerCount;\n    }\n    //----------------------------------------------------\n    //----------------------------------------------------\n    Pointer::InputType HoldGesture::GetInputType() const\n    {\n        return m_requiredInputType;\n    }\n    //----------------------------------------------------\n    //----------------------------------------------------\n    IConnectableEvent<HoldGesture::Delegate>& HoldGesture::GetHeldEvent()\n    {\n        return m_heldEvent;\n    }\n    //--------------------------------------------------------\n    //--------------------------------------------------------\n    void HoldGesture::Reset()\n    {\n        m_holdPending = false;\n        m_currentStartTimestamp = 0.0;\n        m_pendingPointers.clear();\n    }\n    //--------------------------------------------------------\n    //--------------------------------------------------------\n    void HoldGesture::OnUpdate(f32 in_deltaTime)\n    {\n        if (m_holdPending == true && m_pendingPointers.size() == m_requiredPointerCount)\n        {\n            f64 timestamp = ((f64)Application::Get()->GetSystemTimeInMilliseconds()) / 1000.0;\n            if (timestamp - m_currentStartTimestamp > k_holdTime)\n            {\n                Vector2 gesturePosition = Vector2::k_zero;\n                for (auto& pointerInfo : m_pendingPointers)\n                {\n                    gesturePosition += pointerInfo.m_initialPosition;\n                }\n                gesturePosition /= f32(m_pendingPointers.size());\n                \n                Reset();\n                \n                if (ResolveConflicts() == true)\n                {\n                    m_heldEvent.NotifyConnections(this, gesturePosition);\n                }\n            }\n        }\n    }\n    //--------------------------------------------------------\n    //--------------------------------------------------------\n    void HoldGesture::OnPointerDown(const Pointer& in_pointer, f64 in_timestamp, Pointer::InputType in_inputType)\n    {\n        if (in_inputType == m_requiredInputType)\n        {\n            if (m_holdPending == true && (m_pendingPointers.size() >= m_requiredPointerCount || in_timestamp - m_currentStartTimestamp > k_maxTimeBetweenPointers))\n            {\n                Reset();\n                m_lastEndTimestamp = in_timestamp;\n            }\n            else if (in_timestamp - m_lastEndTimestamp > k_minTimeBetweenAttempts)\n            {\n                if (m_holdPending == false && m_pendingPointers.size() == 0)\n                {\n                    m_holdPending = true;\n                    m_currentStartTimestamp = in_timestamp;\n                }\n                \n                PointerInfo pointerInfo;\n                pointerInfo.m_initialPosition = in_pointer.GetPosition();\n                pointerInfo.m_pointerId = in_pointer.GetId();\n                m_pendingPointers.push_back(pointerInfo);\n            }\n        }\n    }\n    //--------------------------------------------------------\n    //--------------------------------------------------------\n    void HoldGesture::OnPointerMoved(const Pointer& in_pointer, f64 in_timestamp)\n    {\n        if (m_holdPending == true)\n        {\n            bool shouldReset = false;\n            \n            for (const auto& pointerInfo : m_pendingPointers)\n            {\n                if (in_pointer.GetId() == pointerInfo.m_pointerId)\n                {\n                    const Vector2 displacement = in_pointer.GetPosition() - pointerInfo.m_initialPosition;\n                    if (displacement.LengthSquared() > m_maxDisplacementSquared)\n                    {\n                        shouldReset = true;\n                    }\n                    \n                    break;\n                }\n            }\n            \n            if (shouldReset == true)\n            {\n                Reset();\n                m_lastEndTimestamp = in_timestamp;\n            }\n        }\n    }\n    //--------------------------------------------------------\n    //--------------------------------------------------------\n    void HoldGesture::OnPointerUp(const Pointer& in_pointer, f64 in_timestamp, Pointer::InputType in_inputType)\n    {\n        if (in_inputType == m_requiredInputType && m_holdPending == true)\n        {\n            bool contains = false;\n            for (auto pointer : m_pendingPointers)\n            {\n                if (pointer.m_pointerId == in_pointer.GetId())\n                {\n                    contains = true;\n                }\n            }\n            \n            if (contains == true)\n            {\n                Reset();\n                m_lastEndTimestamp = in_timestamp;\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Input/Gesture/HoldGesture.h",
    "content": "//\n//  HoldGesture.h\n//  ChilliSource\n//  Created by Ian Copland on 19/09/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_INPUT_GESTURE_HOLDGESTURE_H_\n#define _CHILLISOURCE_INPUT_GESTURE_HOLDGESTURE_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Event/Event.h>\n#include <ChilliSource/Input/Gesture/Gesture.h>\n\n#include <functional>\n\nnamespace ChilliSource\n{\n    //----------------------------------------------------------\n    /// A gesture for receiving hold input events. Allows for\n    /// multi-finger events.\n    ///\n    /// A hold gesture requires that all intended pointers be\n    /// pressed down within a short period of each other. These\n    /// must then stay down in the same position until the hold\n    /// timer elapses.\n    ///\n    /// @author Ian Copland\n    //----------------------------------------------------------\n    class HoldGesture final : public Gesture\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(HoldGesture);\n        //----------------------------------------------------\n        /// A delegate called when a hold gesture is activated.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param A pointer to the hold gesture that was\n        /// activated.\n        /// @param The position at which the tap occurred.\n        //----------------------------------------------------\n        using Delegate = std::function<void(const HoldGesture*, const Vector2&)>;\n        //----------------------------------------------------\n        /// Constructor. Constructs the hold gesture with the\n        /// given settings.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The number of pointers that should be\n        /// down per tap. Defaults to 1.\n        /// @param The input type this gesture should listen\n        /// for. Defaults to using the default input type.\n        //----------------------------------------------------\n        HoldGesture(u32 in_numPointers = 1, Pointer::InputType in_inputType = Pointer::GetDefaultInputType());\n        //----------------------------------------------------\n        /// Queries whether or not this implements the gesture\n        /// interface with the given Id.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The gesture interface Id.\n        ///\n        /// @return Whether or not the gesture inteface is\n        /// implemented.\n        //----------------------------------------------------\n        bool IsA(InterfaceIDType in_gestureInterfaceId) const override;\n        //----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The number of pointers required by this\n        /// Gesture.\n        //----------------------------------------------------\n        u32 GetNumPointers() const;\n        //----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The input type this gesture will listen for.\n        //----------------------------------------------------\n        Pointer::InputType GetInputType() const;\n        //----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return An event that can be used to listen for\n        /// ocurrances of the gesture.\n        //----------------------------------------------------\n        IConnectableEvent<Delegate>& GetHeldEvent();\n    private:\n        //----------------------------------------------------\n        /// Information on the initial state of a single\n        /// pointer within a tap.\n        ///\n        /// @author Ian Copland\n        //----------------------------------------------------\n        struct PointerInfo final\n        {\n            Vector2 m_initialPosition;\n            Pointer::Id m_pointerId;\n        };\n        //--------------------------------------------------------\n        /// Resets the gesture if one is active.\n        ///\n        /// @author Ian Copland\n        //--------------------------------------------------------\n        void Reset() override;\n        //--------------------------------------------------------\n        /// Updates the hold gesture. Tests to see if the hold\n        /// time has exceeded.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The delta time since the last update.\n        //--------------------------------------------------------\n        void OnUpdate(f32 in_deltaTime) override;\n        //--------------------------------------------------------\n        /// Called when a pointer down event occurs.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The pointer.\n        /// @param The timestamp of the event.\n        /// @param The press type.\n        //--------------------------------------------------------\n        void OnPointerDown(const Pointer& in_pointer, f64 in_timestamp, Pointer::InputType in_inputType) override;\n        //--------------------------------------------------------\n        /// Called when a pointer moved event occurs.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The pointer\n        /// @param The timestamp of the event.\n        //--------------------------------------------------------\n        void OnPointerMoved(const Pointer& in_pointer, f64 in_timestamp) override;\n        //--------------------------------------------------------\n        /// Called when a pointer up event occurs.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The pointer\n        /// @param The timestamp of the event.\n        /// @param The press type.\n        //--------------------------------------------------------\n        void OnPointerUp(const Pointer& in_pointer, f64 in_timestamp, Pointer::InputType in_inputType) override;\n        \n        u32 m_requiredPointerCount;\n        Pointer::InputType m_requiredInputType;\n        Event<Delegate> m_heldEvent;\n        \n        f32 m_maxDisplacementSquared = 0.0f;\n        \n        bool m_holdPending = false;\n        std::vector<PointerInfo> m_pendingPointers;\n        f64 m_currentStartTimestamp = 0.0;\n        f64 m_lastEndTimestamp = 0.0;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Input/Gesture/PinchGesture.cpp",
    "content": "//\n//  PinchGesture.cpp\n//  ChilliSource\n//  Created by Ian Copland on 22/09/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Input/Gesture/PinchGesture.h>\n\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/Base/Screen.h>\n\nnamespace ChilliSource\n{\n    namespace\n    {\n        const f32 k_minDisplacement = 20.0f;\n        const u32 k_requiredPointerCount = 2;\n    }\n\n    CS_DEFINE_NAMEDTYPE(PinchGesture);\n    //----------------------------------------------------\n    //----------------------------------------------------\n    PinchGesture::PinchGesture(Pointer::InputType in_inputType)\n    : m_requiredInputType(in_inputType)\n    {\n        Screen* screen = Application::Get()->GetScreen();\n        m_minDisplacementSquared = (k_minDisplacement * screen->GetDensityScale()) * (k_minDisplacement * screen->GetDensityScale());\n        \n        m_pendingPointers.reserve(k_requiredPointerCount);\n    }\n    //----------------------------------------------------\n    //----------------------------------------------------\n    bool PinchGesture::IsA(InterfaceIDType in_gestureInterfaceId) const\n    {\n        return (Gesture::InterfaceID == in_gestureInterfaceId || PinchGesture::InterfaceID == in_gestureInterfaceId);\n    }\n    //----------------------------------------------------\n    //----------------------------------------------------\n    Pointer::InputType PinchGesture::GetInputType() const\n    {\n        return m_requiredInputType;\n    }\n    //----------------------------------------------------\n    //----------------------------------------------------\n    IConnectableEvent<PinchGesture::Delegate>& PinchGesture::GetPinchStartedEvent()\n    {\n        return m_pinchStartedEvent;\n    }\n    //----------------------------------------------------\n    //----------------------------------------------------\n    IConnectableEvent<PinchGesture::Delegate>& PinchGesture::GetPinchMovedEvent()\n    {\n        return m_pinchMovedEvent;\n    }\n    //----------------------------------------------------\n    //----------------------------------------------------\n    IConnectableEvent<PinchGesture::Delegate>& PinchGesture::GetPinchEndedEvent()\n    {\n        return m_pinchEndedEvent;\n    }\n    //----------------------------------------------------\n    //----------------------------------------------------\n    void PinchGesture::TryStart(const Pointer& in_pointer)\n    {\n        u32 dragCount = 0;\n        u32 existingActive = 0;\n        for (const auto& pointer : m_pendingPointers)\n        {\n            if (pointer.m_isDrag == true)\n            {\n                ++dragCount;\n            }\n            \n            if (pointer.m_active == true)\n            {\n                ++existingActive;\n            }\n        }\n        \n        CS_ASSERT(existingActive < k_requiredPointerCount, \"gesture is already started if current active count is already at the required amount.\");\n        \n        if (dragCount >= k_requiredPointerCount)\n        {\n            if (IsActive() == false && ResolveConflicts() == false)\n            {\n                return;\n            }\n            \n            u32 activeCount = existingActive;\n            for (auto& pointer : m_pendingPointers)\n            {\n                if (pointer.m_isDrag == true && pointer.m_active == false && activeCount < k_requiredPointerCount)\n                {\n                    pointer.m_active = true;\n                    ++activeCount;\n                }\n            }\n            \n            m_paused = false;\n            \n            if (IsActive() == false)\n            {\n                SetActive(true);\n                m_initialDistance = CalculateDistance();\n                m_currentPinchInfo.m_position = CalculatePosition();\n                m_currentPinchInfo.m_scale = CalculateScale();\n                m_pinchStartedEvent.NotifyConnections(this, m_currentPinchInfo);\n            }\n            else\n            {\n                //If we're re-placing a finger for a pinch we want to scale the initial distance such that the scale at the new\n                //finger position is the same as it was when the finger was removed.\n                if (m_currentPinchInfo.m_scale > 0.0f)\n                {\n                    f32 scaleFactor = CalculateScale() / m_currentPinchInfo.m_scale;\n                    m_initialDistance *= scaleFactor;\n                }\n                \n                m_currentPinchInfo.m_position = CalculatePosition();\n                m_currentPinchInfo.m_scale = CalculateScale();\n                m_pinchMovedEvent.NotifyConnections(this, m_currentPinchInfo);\n            }\n        }\n    }\n    //----------------------------------------------------\n    //----------------------------------------------------\n    Vector2 PinchGesture::CalculatePosition() const\n    {\n        Vector2 gesturePos = Vector2::k_zero;\n        if (m_pendingPointers.size() >= k_requiredPointerCount && IsActive() == true && m_paused == false)\n        {\n            for (const auto& pointer : m_pendingPointers)\n            {\n                if (pointer.m_active == true)\n                {\n                    gesturePos += pointer.m_currentPosition;\n                }\n            }\n            \n            gesturePos /= f32(k_requiredPointerCount);\n        }\n        \n        return gesturePos;\n    }\n    //----------------------------------------------------\n    //----------------------------------------------------\n    f32 PinchGesture::CalculateDistance() const\n    {\n        f32 distance = 0.0f;\n        \n        if (m_pendingPointers.size() >= k_requiredPointerCount && IsActive() == true && m_paused == false)\n        {\n            std::vector<Vector2> positions;\n            for (const auto& pointer : m_pendingPointers)\n            {\n                if (pointer.m_active == true)\n                {\n                    positions.push_back(pointer.m_currentPosition);\n                }\n            }\n            \n            CS_ASSERT(positions.size() == k_requiredPointerCount, \"There are more active pointers than required.\");\n            \n            Vector2 displacement = positions[1] - positions[0];\n            distance = displacement.Length();\n        }\n        \n        return distance;\n    }\n    //----------------------------------------------------\n    //----------------------------------------------------\n    f32 PinchGesture::CalculateScale() const\n    {\n        f32 scale = 0.0f;\n        if (m_initialDistance > 0.0f)\n        {\n            scale = CalculateDistance() / m_initialDistance;\n        }\n        \n        return scale;\n    }\n    //--------------------------------------------------------\n    //--------------------------------------------------------\n    void PinchGesture::Cancel()\n    {\n        CS_ASSERT(IsActive() == true, \"Cannot cancel a gesture that isn't active.\");\n        \n        for (auto& pointer : m_pendingPointers)\n        {\n            pointer.m_active = false;\n        }\n        \n        SetActive(false);\n        m_paused = false;\n        \n        m_pinchEndedEvent.NotifyConnections(this, m_currentPinchInfo);\n        m_currentPinchInfo.m_position = Vector2::k_zero;\n        m_currentPinchInfo.m_scale = 0.0f;\n    }\n    //--------------------------------------------------------\n    //--------------------------------------------------------\n    void PinchGesture::Reset()\n    {\n        if (IsActive())\n        {\n            Cancel();\n        }\n        \n        m_pendingPointers.clear();\n        m_initialDistance = 0.0f;\n    }\n    //--------------------------------------------------------\n    //--------------------------------------------------------\n    void PinchGesture::OnPointerDown(const Pointer& in_pointer, f64 in_timestamp, Pointer::InputType in_inputType)\n    {\n        if (in_inputType == m_requiredInputType)\n        {\n            PointerInfo pointerInfo;\n            pointerInfo.m_pointerId = in_pointer.GetId();\n            pointerInfo.m_currentPosition = in_pointer.GetPosition();\n            m_pendingPointers.push_back(pointerInfo);\n        }\n    }\n    //--------------------------------------------------------\n    //--------------------------------------------------------\n    void PinchGesture::OnPointerMoved(const Pointer& in_pointer, f64 in_timestamp)\n    {\n        if (m_pendingPointers.size() > 0)\n        {\n            bool isPending = false;\n            bool isActive = false;\n            for (auto& pointer : m_pendingPointers)\n            {\n                if (in_pointer.GetId() == pointer.m_pointerId)\n                {\n                    pointer.m_currentPosition = in_pointer.GetPosition();\n                    \n                    Vector2 displacement = pointer.m_currentPosition - pointer.m_initialPosition;\n                    if (displacement.LengthSquared() > m_minDisplacementSquared)\n                    {\n                        pointer.m_isDrag = true;\n                    }\n                    \n                    if (pointer.m_active == true)\n                    {\n                        isActive = true;\n                    }\n                    \n                    isPending = true;\n                }\n            }\n            \n            if (isPending == true)\n            {\n                if (IsActive() == false || m_paused == true)\n                {\n                    TryStart(in_pointer);\n                }\n                else if (isActive == true)\n                {\n                    m_currentPinchInfo.m_position = CalculatePosition();\n                    m_currentPinchInfo.m_scale = CalculateScale();\n                    m_pinchMovedEvent.NotifyConnections(this, m_currentPinchInfo);\n                }\n            }\n        }\n    }\n    //--------------------------------------------------------\n    //--------------------------------------------------------\n    void PinchGesture::OnPointerUp(const Pointer& in_pointer, f64 in_timestamp, Pointer::InputType in_inputType)\n    {\n        if (in_inputType == m_requiredInputType)\n        {\n            if (m_pendingPointers.size() > 0)\n            {\n                for (auto pointerIt = m_pendingPointers.begin(); pointerIt != m_pendingPointers.end();)\n                {\n                    if (in_pointer.GetId() == pointerIt->m_pointerId)\n                    {\n                        if (pointerIt->m_active == true)\n                        {\n                            m_paused = true;\n                        }\n                        \n                        pointerIt = m_pendingPointers.erase(pointerIt);\n                        break;\n                    }\n                    else\n                    {\n                        ++pointerIt;\n                    }\n                }\n                \n                if (m_pendingPointers.empty() == true && IsActive() == true)\n                {\n                    Cancel();\n                }\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Input/Gesture/PinchGesture.h",
    "content": "//\n//  PinchGesture.h\n//  ChilliSource\n//  Created by Ian Copland on 22/09/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_INPUT_GESTURE_PINCHGESTURE_H_\n#define _CHILLISOURCE_INPUT_GESTURE_PINCHGESTURE_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Event/Event.h>\n#include <ChilliSource/Input/Gesture/Gesture.h>\n\n#include <functional>\n\nnamespace ChilliSource\n{\n    //----------------------------------------------------------\n    /// A gesture for receiving pinch input events.\n    ///\n    /// A pinch gesture will start when at least two pointers\n    /// have moved.\n    ///\n    /// The gesture will update whenever there are two active\n    /// pointers and one of them moves. Other pointers will be\n    /// ignored.\n    ///\n    /// The gesture will end when all pointers have been\n    /// removed.\n    ///\n    /// @author Ian Copland\n    //----------------------------------------------------------\n    class PinchGesture final : public Gesture\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(PinchGesture);\n        //----------------------------------------------------\n        /// A container for information on a single pinch event.\n        ///\n        /// @author Ian Copland\n        //----------------------------------------------------\n        struct PinchInfo final\n        {\n            Vector2 m_position;   //The screen space location of the gesture. This is the centroid of the two active pointers.\n            f32 m_scale = 0.0f;         //The fraction difference between the initial pinch distance to the current. Change caused by the currently tracked pointer changing is ignored.\n        };\n        //----------------------------------------------------\n        /// A delegate called when a pinch gesture is activated.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param A pointer to the pinch gesture that was\n        /// activated.\n        /// @param Information on the pinch gesture.\n        //----------------------------------------------------\n        using Delegate = std::function<void(const PinchGesture*, const PinchInfo&)>;\n        //----------------------------------------------------\n        /// Constructor. Constructs the pinch gesture with the\n        /// given settings.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The input type this gesture should listen\n        /// for. Defaults to using the default input type.\n        //----------------------------------------------------\n        PinchGesture(Pointer::InputType in_inputType = Pointer::GetDefaultInputType());\n        //----------------------------------------------------\n        /// Queries whether or not this implements the gesture\n        /// interface with the given Id.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The gesture interface Id.\n        ///\n        /// @return Whether or not the gesture inteface is\n        /// implemented.\n        //----------------------------------------------------\n        bool IsA(InterfaceIDType in_gestureInterfaceId) const override;\n        //----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The input type this gesture will listen for.\n        //----------------------------------------------------\n        Pointer::InputType GetInputType() const;\n        //----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return An event that can be used to listen for\n        /// start of a pinch.\n        //----------------------------------------------------\n        IConnectableEvent<Delegate>& GetPinchStartedEvent();\n        //----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return An event that can be used to listen for\n        /// movement in a pinch\n        //----------------------------------------------------\n        IConnectableEvent<Delegate>& GetPinchMovedEvent();\n        //----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return An event that can be used to listen for\n        /// end of a pinch.\n        //----------------------------------------------------\n        IConnectableEvent<Delegate>& GetPinchEndedEvent();\n    private:\n        //----------------------------------------------------\n        /// Information on a single pointer within the gesture.\n        ///\n        /// @author Ian Copland\n        //----------------------------------------------------\n        struct PointerInfo final\n        {\n            Pointer::Id m_pointerId;\n            Vector2 m_initialPosition;\n            Vector2 m_currentPosition;\n            bool m_isDrag = false;\n            bool m_active = false;\n        };\n        //--------------------------------------------------------\n        /// Tries to activate or un-pause a pinch gesture.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The pointer.\n        //--------------------------------------------------------\n        void TryStart(const Pointer& in_pointer);\n        //----------------------------------------------------\n        /// Calculates the current position of the gesture.\n        /// This will be the centre position between the pointers\n        /// involved in the gesture.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @return The calculated position.\n        //----------------------------------------------------\n        Vector2 CalculatePosition() const;\n        //----------------------------------------------------\n        /// Calculates the current distance between the pointers\n        /// in the gesture.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @return The calculated scale.\n        //----------------------------------------------------\n        f32 CalculateDistance() const;\n        //----------------------------------------------------\n        /// Calculates the current fraction of the initial\n        /// distance to the current.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @return The calculated scale.\n        //----------------------------------------------------\n        f32 CalculateScale() const;\n        //--------------------------------------------------------\n        /// This will be called if the gesture is currently active\n        /// and conflict resolution deduces that it should end.\n        /// This will de-activate the current gesture and set all\n        /// pointers back to inactive.\n        ///\n        /// @author Ian Copland\n        //--------------------------------------------------------\n        void Cancel() override;\n        //--------------------------------------------------------\n        /// This is called to reset the gesture back to its\n        /// intials state. If the gesture was active, it will be\n        /// reset. Any data keeping track of the current state of\n        /// the gesture should be reset. This is typically called\n        /// when transitioning scenes, to ensure the gesture is\n        /// not in an invalid state when transitioning back.\n        ///\n        /// @author Ian Copland\n        //--------------------------------------------------------\n        void Reset() override;\n        //--------------------------------------------------------\n        /// Called when a pointer down event occurs.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The pointer.\n        /// @param The timestamp of the event.\n        /// @param The press type.\n        //--------------------------------------------------------\n        void OnPointerDown(const Pointer& in_pointer, f64 in_timestamp, Pointer::InputType in_inputType) override;\n        //--------------------------------------------------------\n        /// Called when a pointer moved event occurs.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The pointer\n        /// @param The timestamp of the event.\n        //--------------------------------------------------------\n        void OnPointerMoved(const Pointer& in_pointer, f64 in_timestamp) override;\n        //--------------------------------------------------------\n        /// Called when a pointer up event occurs.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The pointer\n        /// @param The timestamp of the event.\n        /// @param The press type.\n        //--------------------------------------------------------\n        void OnPointerUp(const Pointer& in_pointer, f64 in_timestamp, Pointer::InputType in_inputType) override;\n        \n        Pointer::InputType m_requiredInputType;\n        Event<Delegate> m_pinchStartedEvent;\n        Event<Delegate> m_pinchMovedEvent;\n        Event<Delegate> m_pinchEndedEvent;\n        \n        f32 m_minDisplacementSquared = 0.0f;\n        \n        std::vector<PointerInfo> m_pendingPointers;\n        f32 m_initialDistance = 0.0f;\n        PinchInfo m_currentPinchInfo;\n        bool m_paused = false;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Input/Gesture/RotationGesture.cpp",
    "content": "//\n//  RotationGesture.cpp\n//  ChilliSource\n//  Created by Ian Copland on 23/09/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Input/Gesture/RotationGesture.h>\n\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/Base/Screen.h>\n#include <ChilliSource/Core/Math/MathUtils.h>\n\nnamespace ChilliSource\n{\n    namespace\n    {\n        const f32 k_minDisplacement = 20.0f;\n        const u32 k_requiredPointerCount = 2;\n    }\n    \n    CS_DEFINE_NAMEDTYPE(RotationGesture);\n    //----------------------------------------------------\n    //----------------------------------------------------\n    RotationGesture::RotationGesture(Pointer::InputType in_inputType)\n    : m_requiredInputType(in_inputType)\n    {\n        Screen* screen = Application::Get()->GetScreen();\n        m_minDisplacementSquared = (k_minDisplacement * screen->GetDensityScale()) * (k_minDisplacement * screen->GetDensityScale());\n        \n        m_pendingPointers.reserve(k_requiredPointerCount);\n    }\n    //----------------------------------------------------\n    //----------------------------------------------------\n    bool RotationGesture::IsA(InterfaceIDType in_gestureInterfaceId) const\n    {\n        return (Gesture::InterfaceID == in_gestureInterfaceId || RotationGesture::InterfaceID == in_gestureInterfaceId);\n    }\n    //----------------------------------------------------\n    //----------------------------------------------------\n    Pointer::InputType RotationGesture::GetInputType() const\n    {\n        return m_requiredInputType;\n    }\n    //----------------------------------------------------\n    //----------------------------------------------------\n    IConnectableEvent<RotationGesture::Delegate>& RotationGesture::GetRotationStartedEvent()\n    {\n        return m_rotationStartedEvent;\n    }\n    //----------------------------------------------------\n    //----------------------------------------------------\n    IConnectableEvent<RotationGesture::Delegate>& RotationGesture::GetRotationMovedEvent()\n    {\n        return m_rotationMovedEvent;\n    }\n    //----------------------------------------------------\n    //----------------------------------------------------\n    IConnectableEvent<RotationGesture::Delegate>& RotationGesture::GetRotationEndedEvent()\n    {\n        return m_rotationEndedEvent;\n    }\n    //----------------------------------------------------\n    //----------------------------------------------------\n    void RotationGesture::TryStart(const Pointer& in_pointer)\n    {\n        u32 dragCount = 0;\n        u32 existingActive = 0;\n        for (const auto& pointer : m_pendingPointers)\n        {\n            if (pointer.m_isDrag == true)\n            {\n                ++dragCount;\n            }\n            \n            if (pointer.m_active == true)\n            {\n                ++existingActive;\n            }\n        }\n        \n        CS_ASSERT(existingActive < k_requiredPointerCount, \"gesture is already started if current active count is already at the required amount.\");\n        \n        if (dragCount >= k_requiredPointerCount)\n        {\n            if (IsActive() == false && ResolveConflicts() == false)\n            {\n                return;\n            }\n            \n            u32 activeCount = existingActive;\n            for (auto& pointer : m_pendingPointers)\n            {\n                if (pointer.m_isDrag == true && pointer.m_active == false && activeCount < k_requiredPointerCount)\n                {\n                    pointer.m_active = true;\n                    ++activeCount;\n                }\n            }\n            \n            m_paused = false;\n            \n            if (IsActive() == false)\n            {\n                SetActive(true);\n                m_initialAngle = CalculateAngle();\n                m_currentRotationInfo.m_position = CalculatePosition();\n                m_currentRotationInfo.m_rotation = CalculateRelativeRotation();\n                m_currentRotationInfo.m_rotationDelta = 0.0f;\n                m_rotationStartedEvent.NotifyConnections(this, m_currentRotationInfo);\n            }\n            else\n            {\n                //If we're re-placing a finger for a rotation we want to update the initial angle such that the rotation at the new\n                //finger position is the same as it was when the finger was removed.\n                m_initialAngle = CalculateAngle() - m_currentRotationInfo.m_rotation;\n                m_currentRotationInfo.m_position = CalculatePosition();\n                m_currentRotationInfo.m_rotation = CalculateRelativeRotation();\n                m_currentRotationInfo.m_rotationDelta = 0.0f;\n                m_rotationMovedEvent.NotifyConnections(this, m_currentRotationInfo);\n            }\n        }\n    }\n    //----------------------------------------------------\n    //----------------------------------------------------\n    Vector2 RotationGesture::CalculatePosition() const\n    {\n        Vector2 gesturePos = Vector2::k_zero;\n        if (m_pendingPointers.size() >= k_requiredPointerCount && IsActive() == true && m_paused == false)\n        {\n            for (const auto& pointer : m_pendingPointers)\n            {\n                if (pointer.m_active == true)\n                {\n                    gesturePos += pointer.m_currentPosition;\n                }\n            }\n            \n            gesturePos /= f32(k_requiredPointerCount);\n        }\n        \n        return gesturePos;\n    }\n    //----------------------------------------------------\n    //----------------------------------------------------\n    f32 RotationGesture::CalculateAngle() const\n    {\n        f32 angle = 0.0f;\n        if (m_pendingPointers.size() >= k_requiredPointerCount && IsActive() == true && m_paused == false)\n        {\n            std::vector<Vector2> positions;\n            for (const auto& pointer : m_pendingPointers)\n            {\n                if (pointer.m_active == true)\n                {\n                    positions.push_back(pointer.m_currentPosition);\n                }\n            }\n            \n            CS_ASSERT(positions.size() == k_requiredPointerCount, \"There are more active pointers than required.\");\n            \n            Vector2 displacement = positions[1] - positions[0];\n            \n            angle = -Vector2::Angle(Vector2::k_unitPositiveY, displacement);\n            \n            while (angle < 0.0f)\n            {\n                angle += MathUtils::k_pi * 2.0f;\n            }\n\n            while (angle >= MathUtils::k_pi * 2.0f)\n            {\n                angle -= MathUtils::k_pi * 2.0f;\n            }\n        }\n        \n        return angle;\n    }\n    //----------------------------------------------------\n    //----------------------------------------------------\n    f32 RotationGesture::CalculateRelativeRotation() const\n    {\n        f32 angle = CalculateAngle() - m_initialAngle;\n        \n        while (angle < -MathUtils::k_pi)\n        {\n            angle += MathUtils::k_pi * 2.0f;\n        }\n        \n        while (angle >= MathUtils::k_pi)\n        {\n            angle -= MathUtils::k_pi * 2.0f;\n        }\n        \n        return angle;\n    }\n    //--------------------------------------------------------\n    //--------------------------------------------------------\n    void RotationGesture::Cancel()\n    {\n        CS_ASSERT(IsActive() == true, \"Cannot cancel a gesture that isn't active.\");\n        \n        for (auto& pointer : m_pendingPointers)\n        {\n            pointer.m_active = false;\n        }\n        \n        SetActive(false);\n        m_paused = false;\n        \n        m_currentRotationInfo.m_rotationDelta = 0.0f;\n        m_rotationEndedEvent.NotifyConnections(this, m_currentRotationInfo);\n        m_currentRotationInfo.m_position = Vector2::k_zero;\n        m_currentRotationInfo.m_rotation = 0.0f;\n    }\n    //--------------------------------------------------------\n    //--------------------------------------------------------\n    void RotationGesture::Reset()\n    {\n        if (IsActive())\n        {\n            Cancel();\n        }\n        \n        m_pendingPointers.clear();\n        m_initialAngle = 0.0f;\n    }\n    //--------------------------------------------------------\n    //--------------------------------------------------------\n    void RotationGesture::OnPointerDown(const Pointer& in_pointer, f64 in_timestamp, Pointer::InputType in_inputType)\n    {\n        if (in_inputType == m_requiredInputType)\n        {\n            PointerInfo pointerInfo;\n            pointerInfo.m_pointerId = in_pointer.GetId();\n            pointerInfo.m_currentPosition = in_pointer.GetPosition();\n            m_pendingPointers.push_back(pointerInfo);\n        }\n    }\n    //--------------------------------------------------------\n    //--------------------------------------------------------\n    void RotationGesture::OnPointerMoved(const Pointer& in_pointer, f64 in_timestamp)\n    {\n        if (m_pendingPointers.size() > 0)\n        {\n            bool isPending = false;\n            bool isActive = false;\n            for (auto& pointer : m_pendingPointers)\n            {\n                if (in_pointer.GetId() == pointer.m_pointerId)\n                {\n                    pointer.m_currentPosition = in_pointer.GetPosition();\n                    \n                    Vector2 displacement = pointer.m_currentPosition - pointer.m_initialPosition;\n                    if (displacement.LengthSquared() > m_minDisplacementSquared)\n                    {\n                        pointer.m_isDrag = true;\n                    }\n                    \n                    if (pointer.m_active == true)\n                    {\n                        isActive = true;\n                    }\n                    \n                    isPending = true;\n                }\n            }\n            \n            if (isPending == true)\n            {\n                if (IsActive() == false || m_paused == true)\n                {\n                    TryStart(in_pointer);\n                }\n                else if (isActive == true)\n                {\n                    m_currentRotationInfo.m_position = CalculatePosition();\n                    f32 newRotation = CalculateRelativeRotation();\n                    m_currentRotationInfo.m_rotationDelta = newRotation - m_currentRotationInfo.m_rotation;\n                    m_currentRotationInfo.m_rotation = newRotation;\n                    m_rotationMovedEvent.NotifyConnections(this, m_currentRotationInfo);\n                }\n            }\n        }\n    }\n    //--------------------------------------------------------\n    //--------------------------------------------------------\n    void RotationGesture::OnPointerUp(const Pointer& in_pointer, f64 in_timestamp, Pointer::InputType in_inputType)\n    {\n        if (in_inputType == m_requiredInputType)\n        {\n            if (m_pendingPointers.size() > 0)\n            {\n                for (auto pointerIt = m_pendingPointers.begin(); pointerIt != m_pendingPointers.end();)\n                {\n                    if (in_pointer.GetId() == pointerIt->m_pointerId)\n                    {\n                        if (pointerIt->m_active == true)\n                        {\n                            m_paused = true;\n                        }\n                        \n                        pointerIt = m_pendingPointers.erase(pointerIt);\n                        break;\n                    }\n                    else\n                    {\n                        ++pointerIt;\n                    }\n                }\n                \n                if (m_pendingPointers.empty() == true && IsActive() == true)\n                {\n                    Cancel();\n                }\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Input/Gesture/RotationGesture.h",
    "content": "//\n//  RotationGesture.h\n//  ChilliSource\n//  Created by Ian Copland on 23/09/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_INPUT_GESTURE_ROTATIONGESTURE_H_\n#define _CHILLISOURCE_INPUT_GESTURE_ROTATIONGESTURE_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Event/Event.h>\n#include <ChilliSource/Input/Gesture/Gesture.h>\n\n#include <functional>\n\nnamespace ChilliSource\n{\n    //----------------------------------------------------------\n    /// A gesture for receiving rotation input events.\n    ///\n    /// A rotation gesture will start when at least two pointers\n    /// have moved.\n    ///\n    /// The gesture will update whenever there are two active\n    /// pointers and one of them moves. Other pointers will be\n    /// ignored.\n    ///\n    /// The gesture will end when all pointers have been\n    /// removed.\n    ///\n    /// @author Ian Copland\n    //----------------------------------------------------------\n    class RotationGesture final : public Gesture\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(RotationGesture);\n        //----------------------------------------------------\n        /// A container for information on a single rotation\n        /// event.\n        ///\n        /// @author Ian Copland\n        //----------------------------------------------------\n        struct RotationInfo final\n        {\n            Vector2 m_position;   //The screen space location of the gesture. This is the centroid of the two active pointers.\n            f32 m_rotation = 0.0f;      //The clockwise angle of the gesture from the initial orientation. Change caused by the currently tracked pointer changing is ignored.\n            f32 m_rotationDelta = 0.0f; //The change in the rotation since the last event. Change caused by the currently tracked pointer changing is ignored.\n        };\n        //----------------------------------------------------\n        /// A delegate called when a rotation gesture is activated.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param A pointer to the rotation gesture that was\n        /// activated.\n        /// @param Information on the rotation.\n        //----------------------------------------------------\n        using Delegate = std::function<void(const RotationGesture*, const RotationInfo&)>;\n        //----------------------------------------------------\n        /// Constructor. Constructs the rotation gesture with the\n        /// given settings.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The input type this gesture should listen\n        /// for. Defaults to using the default input type.\n        //----------------------------------------------------\n        RotationGesture(Pointer::InputType in_inputType = Pointer::GetDefaultInputType());\n        //----------------------------------------------------\n        /// Queries whether or not this implements the gesture\n        /// interface with the given Id.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The gesture interface Id.\n        ///\n        /// @return Whether or not the gesture inteface is\n        /// implemented.\n        //----------------------------------------------------\n        bool IsA(InterfaceIDType in_gestureInterfaceId) const override;\n        //----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The input type this gesture will listen for.\n        //----------------------------------------------------\n        Pointer::InputType GetInputType() const;\n        //----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return An event that can be used to listen for\n        /// start of a rotation.\n        //----------------------------------------------------\n        IConnectableEvent<Delegate>& GetRotationStartedEvent();\n        //----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return An event that can be used to listen for\n        /// movement in a rotation.\n        //----------------------------------------------------\n        IConnectableEvent<Delegate>& GetRotationMovedEvent();\n        //----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return An event that can be used to listen for\n        /// end of a rotation.\n        //----------------------------------------------------\n        IConnectableEvent<Delegate>& GetRotationEndedEvent();\n    private:\n        //----------------------------------------------------\n        /// Information on a single pointer within the gesture.\n        ///\n        /// @author Ian Copland\n        //----------------------------------------------------\n        struct PointerInfo final\n        {\n            Pointer::Id m_pointerId;\n            Vector2 m_initialPosition;\n            Vector2 m_currentPosition;\n            bool m_isDrag = false;\n            bool m_active = false;\n        };\n        //----------------------------------------------------\n        /// Tries to activate or un-pause a pinch gesture.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The pointer.\n        //----------------------------------------------------\n        void TryStart(const Pointer& in_pointer);\n        //----------------------------------------------------\n        /// Calculates the current position of the gesture.\n        /// This will be the centre position between the pointers\n        /// involved in the gesture.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @return The calculated position.\n        //----------------------------------------------------\n        Vector2 CalculatePosition() const;\n        //----------------------------------------------------\n        /// Calculates the clockwise angle of the gesture.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @return The calculated angle.\n        //----------------------------------------------------\n        f32 CalculateAngle() const;\n        //----------------------------------------------------\n        /// Calculates the clockwise rotation of the gesture\n        /// relative to the initial rotation.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @return The calculated rotation angle.\n        //----------------------------------------------------\n        f32 CalculateRelativeRotation() const;\n        //--------------------------------------------------------\n        /// This will be called if the gesture is currently active\n        /// and conflict resolution deduces that it should end.\n        /// This will de-activate the current gesture and set all\n        /// pointers back to inactive.\n        ///\n        /// @author Ian Copland\n        //--------------------------------------------------------\n        void Cancel() override;\n        //--------------------------------------------------------\n        /// This is called to reset the gesture back to its\n        /// intials state. If the gesture was active, it will be\n        /// reset. Any data keeping track of the current state of\n        /// the gesture should be reset. This is typically called\n        /// when transitioning scenes, to ensure the gesture is\n        /// not in an invalid state when transitioning back.\n        ///\n        /// @author Ian Copland\n        //--------------------------------------------------------\n        void Reset() override;\n        //----------------------------------------------------\n        /// Called when a pointer down event occurs.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The pointer.\n        /// @param The timestamp of the event.\n        /// @param The press type.\n        //----------------------------------------------------\n        void OnPointerDown(const Pointer& in_pointer, f64 in_timestamp, Pointer::InputType in_inputType) override;\n        //----------------------------------------------------\n        /// Called when a pointer moved event occurs.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The pointer\n        /// @param The timestamp of the event.\n        //----------------------------------------------------\n        void OnPointerMoved(const Pointer& in_pointer, f64 in_timestamp) override;\n        //----------------------------------------------------\n        /// Called when a pointer up event occurs.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The pointer\n        /// @param The timestamp of the event.\n        /// @param The press type.\n        //----------------------------------------------------\n        void OnPointerUp(const Pointer& in_pointer, f64 in_timestamp, Pointer::InputType in_inputType) override;\n        \n        Pointer::InputType m_requiredInputType;\n        Event<Delegate> m_rotationStartedEvent;\n        Event<Delegate> m_rotationMovedEvent;\n        Event<Delegate> m_rotationEndedEvent;\n        \n        f32 m_minDisplacementSquared = 0.0f;\n        \n        std::vector<PointerInfo> m_pendingPointers;\n        f32 m_initialAngle = 0.0f;\n        RotationInfo m_currentRotationInfo;\n        bool m_paused = false;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Input/Gesture/TapGesture.cpp",
    "content": "//\n//  TapGesture.cpp\n//  ChilliSource\n//  Created by Ian Copland on 17/09/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Input/Gesture/TapGesture.h>\n\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/Base/Screen.h>\n\nnamespace ChilliSource\n{\n    namespace\n    {\n        const f32 k_minTimeBetweenTaps = 0.015f;\n        const f32 k_maxTimeForTap = 0.15f;\n        const f32 k_maxTimeBetweenTaps = 0.25f;\n        const f32 k_maxTapDisplacement = 20.0f;\n        const f32 k_maxRepeatTapDisplacement = 40.0f;\n    }\n    \n    CS_DEFINE_NAMEDTYPE(TapGesture);\n    //----------------------------------------------------\n    //----------------------------------------------------\n    TapGesture::TapGesture(u32 in_numTaps, u32 in_numPointers, Pointer::InputType in_inputType)\n        : m_requiredTapCount(in_numTaps), m_requiredPointerCount(in_numPointers), m_requiredInputType(in_inputType)\n    {\n        CS_ASSERT(m_requiredTapCount > 0, \"Cannot have a tap gesture which requres 0 taps.\");\n        CS_ASSERT(m_requiredPointerCount > 0, \"Cannot have a tap gesture which requres 0 pointers.\");\n        \n        Screen* screen = Application::Get()->GetScreen();\n        \n        m_maxTapDisplacementSquared = (k_maxTapDisplacement * screen->GetDensityScale()) * (k_maxTapDisplacement * screen->GetDensityScale());\n        m_maxRepeatTapDisplacementSquared = (k_maxRepeatTapDisplacement * screen->GetDensityScale()) * (k_maxRepeatTapDisplacement * screen->GetDensityScale());\n        m_pendingPointers.reserve(m_requiredPointerCount);\n    }\n    //----------------------------------------------------\n    //----------------------------------------------------\n    bool TapGesture::IsA(InterfaceIDType in_gestureInterfaceId) const\n    {\n        return (Gesture::InterfaceID == in_gestureInterfaceId || TapGesture::InterfaceID == in_gestureInterfaceId);\n    }\n    //----------------------------------------------------\n    //----------------------------------------------------\n    u32 TapGesture::GetNumTaps() const\n    {\n        return m_requiredTapCount;\n    }\n    //----------------------------------------------------\n    //----------------------------------------------------\n    u32 TapGesture::GetNumPointers() const\n    {\n        return m_requiredPointerCount;\n    }\n    //----------------------------------------------------\n    //----------------------------------------------------\n    Pointer::InputType TapGesture::GetInputType() const\n    {\n        return m_requiredInputType;\n    }\n    //----------------------------------------------------\n    //----------------------------------------------------\n    IConnectableEvent<TapGesture::Delegate>& TapGesture::GetTappedEvent()\n    {\n        return m_tappedEvent;\n    }\n    //--------------------------------------------------------\n    //--------------------------------------------------------\n    void TapGesture::CheckForExpiration(f64 in_timestamp)\n    {\n        //Check whether an active tap has expired\n        if (m_tapPending == true && in_timestamp - m_currentTapStartTimestamp > k_maxTimeForTap)\n        {\n            ResetTap();\n        }\n        \n        if (m_tapPending == false && m_requiredTapCount > 0 && in_timestamp - m_lastTapEndTimestamp > k_maxTimeBetweenTaps)\n        {\n            Reset();\n        }\n    }\n    //--------------------------------------------------------\n    //--------------------------------------------------------\n    void TapGesture::ResetTap()\n    {\n        m_tapPending = false;\n        m_currentTapStartTimestamp = 0.0;\n        m_pendingPointers.clear();\n    }\n    //--------------------------------------------------------\n    //--------------------------------------------------------\n    void TapGesture::Reset()\n    {\n        ResetTap();\n        m_tapCount = 0;\n        m_lastTapEndTimestamp = 0.0;\n        m_firstTapPendingPointers.clear();\n    }\n    //--------------------------------------------------------\n    //--------------------------------------------------------\n    void TapGesture::OnPointerDown(const Pointer& in_pointer, f64 in_timestamp, Pointer::InputType in_inputType)\n    {\n        CheckForExpiration(in_timestamp);\n        \n        if (in_inputType == m_requiredInputType)\n        {\n            bool tapValid = false;\n            \n            if (m_tapCount == 0)\n            {\n                tapValid = true;\n            }\n            else\n            {\n                for (const auto& pointerInfo : m_firstTapPendingPointers)\n                {\n                    const Vector2 displacement = in_pointer.GetPosition() - pointerInfo.m_initialPosition;\n                    if (displacement.LengthSquared() <= m_maxRepeatTapDisplacementSquared)\n                    {\n                        tapValid = true;\n                        break;\n                    }\n                }\n            }\n            \n            if (tapValid == true)\n            {\n                if (m_tapPending == true)\n                {\n                    if (m_pendingPointers.size() < m_requiredPointerCount)\n                    {\n                        PointerInfo pointerInfo;\n                        pointerInfo.m_initialPosition = in_pointer.GetPosition();\n                        pointerInfo.m_pointerId = in_pointer.GetId();\n                        pointerInfo.m_isDown = true;\n                        m_pendingPointers.push_back(pointerInfo);\n                    }\n                    else\n                    {\n                        ResetTap();\n                    }\n                }\n                else if (m_tapCount == 0 || in_timestamp - m_lastTapStartTimestamp > k_minTimeBetweenTaps)\n                {\n                    m_tapPending = true;\n                    m_currentTapStartTimestamp = in_timestamp;\n                    m_lastTapStartTimestamp = m_currentTapStartTimestamp;\n                    \n                    PointerInfo pointerInfo;\n                    pointerInfo.m_initialPosition = in_pointer.GetPosition();\n                    pointerInfo.m_pointerId = in_pointer.GetId();\n                    pointerInfo.m_isDown = true;\n                    m_pendingPointers.push_back(pointerInfo);\n                }\n            }\n        }\n    }\n    //--------------------------------------------------------\n    //--------------------------------------------------------\n    void TapGesture::OnPointerMoved(const Pointer& in_pointer, f64 in_timestamp)\n    {\n        CheckForExpiration(in_timestamp);\n        \n        if (m_tapPending == true)\n        {\n            bool shouldReset = false;\n            \n            for (const auto& pointerInfo : m_pendingPointers)\n            {\n                if (in_pointer.GetId() == pointerInfo.m_pointerId)\n                {\n                    const Vector2 displacement = in_pointer.GetPosition() - pointerInfo.m_initialPosition;\n                    if (displacement.LengthSquared() > m_maxTapDisplacementSquared)\n                    {\n                        shouldReset = true;\n                    }\n                    \n                    break;\n                }\n            }\n            \n            if (shouldReset == true)\n            {\n                ResetTap();\n            }\n        }\n    }\n    //--------------------------------------------------------\n    //--------------------------------------------------------\n    void TapGesture::OnPointerUp(const Pointer& in_pointer, f64 in_timestamp, Pointer::InputType in_inputType)\n    {\n        CheckForExpiration(in_timestamp);\n        \n        if (in_inputType == m_requiredInputType && m_tapPending == true)\n        {\n            if (m_pendingPointers.size() == m_requiredPointerCount)\n            {\n                bool tapFinished = true;\n                \n                for (auto& pointerInfo : m_pendingPointers)\n                {\n                    if (in_pointer.GetId() == pointerInfo.m_pointerId)\n                    {\n                        pointerInfo.m_isDown = false;\n                    }\n                    else if (pointerInfo.m_isDown == true)\n                    {\n                        tapFinished = false;\n                    }\n                }\n                \n                if (tapFinished == true)\n                {\n                    if (m_tapCount == 0)\n                    {\n                        m_firstTapPendingPointers = m_pendingPointers;\n                    }\n                    \n                    ResetTap();\n                    m_tapCount++;\n                    m_lastTapEndTimestamp = in_timestamp;\n                    \n                    if (m_tapCount == m_requiredTapCount)\n                    {\n                        Vector2 gesturePosition = Vector2::k_zero;\n                        for (auto& pointerInfo : m_firstTapPendingPointers)\n                        {\n                            gesturePosition += pointerInfo.m_initialPosition;\n                        }\n                        gesturePosition /= f32(m_firstTapPendingPointers.size());\n                        \n                        Reset();\n                        \n                        if (ResolveConflicts() == true)\n                        {\n                            m_tappedEvent.NotifyConnections(this, gesturePosition);\n                        }\n                    }\n                }\n            }\n            else\n            {\n                ResetTap();\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Input/Gesture/TapGesture.h",
    "content": "//\n//  TapGesture.h\n//  ChilliSource\n//  Created by Ian Copland on 17/09/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_INPUT_GESTURE_TAPGESTURE_H_\n#define _CHILLISOURCE_INPUT_GESTURE_TAPGESTURE_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Event/Event.h>\n#include <ChilliSource/Input/Gesture/Gesture.h>\n\n#include <functional>\n\nnamespace ChilliSource\n{\n    //----------------------------------------------------------\n    /// A gesture for receiving tap input events. Allows for\n    /// multi-tap events like double and triple tap, and multi-\n    /// finger events.\n    ///\n    /// A tap gesture requires all intended pointers be pressed\n    /// down within a short period of each other, and all released\n    /// prior to the tap timer expiring, without moving.\n    ///\n    /// @author Ian Copland\n    //----------------------------------------------------------\n    class TapGesture final : public Gesture\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(TapGesture);\n        //----------------------------------------------------\n        /// A delegate called when a tap gesture is activated.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param A pointer to the tap gesture that was\n        /// activated.\n        /// @param The position at which the tap occurred.\n        //----------------------------------------------------\n        using Delegate = std::function<void(const TapGesture*, const Vector2&)>;\n        //----------------------------------------------------\n        /// Constructor. Constructs the tap gesture with the\n        /// given settings.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The number of taps required to activate\n        /// this tap gesture. Defaults to 1.\n        /// @param The number of pointers that should be\n        /// down per tap. Defaults to 1.\n        /// @param The input type this gesture should listen\n        /// for. Defaults to using the default input type.\n        //----------------------------------------------------\n        TapGesture(u32 in_numTaps = 1, u32 in_numPointers = 1, Pointer::InputType in_inputType = Pointer::GetDefaultInputType());\n        //----------------------------------------------------\n        /// Queries whether or not this implements the gesture\n        /// interface with the given Id.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The gesture interface Id.\n        ///\n        /// @return Whether or not the gesture inteface is\n        /// implemented.\n        //----------------------------------------------------\n        bool IsA(InterfaceIDType in_gestureInterfaceId) const override;\n        //----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The number of taps required by this Tap\n        /// Gesture before it will activate.\n        //----------------------------------------------------\n        u32 GetNumTaps() const;\n        //----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The number of pointers required by this Tap\n        /// Gesture for each tap.\n        //----------------------------------------------------\n        u32 GetNumPointers() const;\n        //----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The input type this gesture will listen for.\n        //----------------------------------------------------\n        Pointer::InputType GetInputType() const;\n        //----------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return An event that can be used to listen for\n        /// ocurrances of the gesture.\n        //----------------------------------------------------\n        IConnectableEvent<Delegate>& GetTappedEvent();\n    private:\n        //----------------------------------------------------\n        /// Information on the initial state of a single\n        /// pointer within a tap.\n        ///\n        /// @author Ian Copland\n        //----------------------------------------------------\n        struct PointerInfo final\n        {\n            Vector2 m_initialPosition;\n            Pointer::Id m_pointerId;\n            bool m_isDown = false;\n        };\n        //--------------------------------------------------------\n        /// Checks the timestamp to see if any active taps have\n        /// expired and resets the tap count if the time since the\n        /// last tap is exceeded.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The current timestamp.\n        //--------------------------------------------------------\n        void CheckForExpiration(f64 in_timestamp);\n        //--------------------------------------------------------\n        /// Resets the active tap if there is one.\n        ///\n        /// @author Ian Copland\n        //--------------------------------------------------------\n        void ResetTap();\n        //--------------------------------------------------------\n        /// Resets the gesture if one is active.\n        ///\n        /// @author Ian Copland\n        //--------------------------------------------------------\n        void Reset() override;\n        //--------------------------------------------------------\n        /// Called when a pointer down event occurs.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The pointer.\n        /// @param The timestamp of the event.\n        /// @param The press type.\n        //--------------------------------------------------------\n        void OnPointerDown(const Pointer& in_pointer, f64 in_timestamp, Pointer::InputType in_inputType) override;\n        //--------------------------------------------------------\n        /// Called when a pointer moved event occurs.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The pointer\n        /// @param The timestamp of the event.\n        //--------------------------------------------------------\n        void OnPointerMoved(const Pointer& in_pointer, f64 in_timestamp) override;\n        //--------------------------------------------------------\n        /// Called when a pointer up event occurs.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The pointer\n        /// @param The timestamp of the event.\n        /// @param The press type.\n        //--------------------------------------------------------\n        void OnPointerUp(const Pointer& in_pointer, f64 in_timestamp, Pointer::InputType in_inputType) override;\n        \n        u32 m_requiredTapCount;\n        u32 m_requiredPointerCount;\n        Pointer::InputType m_requiredInputType;\n        Event<Delegate> m_tappedEvent;\n        \n        f32 m_maxTapDisplacementSquared = 0.0f;\n        f32 m_maxRepeatTapDisplacementSquared = 0.0f;\n        \n        u32 m_tapCount = 0;\n        bool m_tapPending = false;\n        std::vector<PointerInfo> m_pendingPointers;\n        std::vector<PointerInfo> m_firstTapPendingPointers;\n        f64 m_currentTapStartTimestamp = 0.0;\n        f64 m_lastTapStartTimestamp = 0.0;\n        f64 m_lastTapEndTimestamp = 0.0;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Input/Gesture.h",
    "content": "//\n//  Gesture.h\n//  ChilliSource\n//  Created by Ian Copland on 07/07/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n\n#ifndef _CHILLISOURCE_INPUT_GESTURE_H_\n#define _CHILLISOURCE_INPUT_GESTURE_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Input/Gesture/DragGesture.h>\n#include <ChilliSource/Input/Gesture/Gesture.h>\n#include <ChilliSource/Input/Gesture/GestureSystem.h>\n#include <ChilliSource/Input/Gesture/HoldGesture.h>\n#include <ChilliSource/Input/Gesture/PinchGesture.h>\n#include <ChilliSource/Input/Gesture/RotationGesture.h>\n#include <ChilliSource/Input/Gesture/TapGesture.h>\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Input/Gyroscope/Gyroscope.cpp",
    "content": "//\n//  Gyroscope.cpp\n//  ChilliSource\n//  Created by Jordan Brown on 19/01/2017\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2017 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Input/Gyroscope/Gyroscope.h>\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n#include <CSBackend/Platform/Android/Main/JNI/Input/Gyroscope/Gyroscope.h>\n#include <CSBackend/Platform/Android/Main/JNI/Input/Gyroscope/GyroscopeJavaInterface.h>\n#include <CSBackend/Platform/Android/Main/JNI/ForwardDeclarations.h>\n#endif\n\n#ifdef CS_TARGETPLATFORM_IOS\n#include <CSBackend/Platform/iOS/Input/Gyroscope/Gyroscope.h>\n#endif\n\nnamespace ChilliSource\n{\n    CS_DEFINE_NAMEDTYPE(Gyroscope);\n    //----------------------------------------------------\n    //----------------------------------------------------\n    GyroscopeUPtr Gyroscope::Create()\n    {\n#if defined CS_TARGETPLATFORM_ANDROID\n        // Check if avail. on android\n        CSBackend::Android::GyroscopeJavaInterfaceSPtr gyroscopeJI = CSBackend::Android::GyroscopeJavaInterfaceSPtr(new CSBackend::Android::GyroscopeJavaInterface());\n\n        if(gyroscopeJI->IsAvailable())\n        {\n            return GyroscopeUPtr(new CSBackend::Android::Gyroscope());\n        }\n        else\n        {\n            return nullptr;\n        }\n#elif defined CS_TARGETPLATFORM_IOS\n        if (CSBackend::iOS::Gyroscope::IsSupportedByDevice() == true)\n        {\n            return GyroscopeUPtr(new CSBackend::iOS::Gyroscope());\n        }\n        else\n        {\n            return nullptr;\n        }\n#else\n        return nullptr;\n#endif\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Input/Gyroscope/Gyroscope.h",
    "content": "//\n//  Gyroscope.h\n//  ChilliSource\n//  Created by Jordan Brown on 10/01/2017\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2017 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_INPUT_GYROSCOPE_GYROSCOPE_H_\n#define _CHILLISOURCE_INPUT_GYROSCOPE_GYROSCOPE_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Event/Event.h>\n#include <ChilliSource/Core/Math/Quaternion.h>\n#include <ChilliSource/Core/System/AppSystem.h>\n\n#include <functional>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------\n    /// Listens to and stores the orientation/attitude read from the\n    /// hardware gyroscope.\n    ///\n    /// @author J Brown\n    //------------------------------------------------------------\n    class Gyroscope : public AppSystem\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(Gyroscope);\n        //----------------------------------------------------\n        /// A delegate for receiving orientation updates\n        /// from the gyroscope.\n        ///\n        /// @author J Brown\n        ///\n        /// @param The new orientation. This wont neccessarily\n        /// have changed since the last update.\n        //----------------------------------------------------\n        typedef std::function<void(const Quaternion&)> OrientationUpdatedDelegate;\n        //----------------------------------------------------\n        /// Creates a new platform specific instance of the\n        /// system.\n        ///\n        /// @author J Brown\n        //----------------------------------------------------\n        static GyroscopeUPtr Create();\n        //----------------------------------------------------\n        /// @author J Brown\n        ///\n        /// @return whether or not the gyroscope is\n        /// currently updating.\n        //----------------------------------------------------\n        virtual bool IsUpdating() const = 0;\n        //----------------------------------------------------\n        /// Start listening for orientation changes.\n        ///\n        /// @author J Brown\n        //----------------------------------------------------\n        virtual void StartUpdating() = 0;\n        //----------------------------------------------------\n        /// @author J Brown\n        ///\n        /// @return The physical orientation of the device,\n        /// as a quaternion.\n        //----------------------------------------------------\n        virtual Quaternion GetOrientation() const = 0;\n        //----------------------------------------------------\n        /// @author J Brown\n        ///\n        /// @return An event that is invoked every time the\n        /// orientation is updated. The orientation will not\n        /// necessarily have changed between updates.\n        //----------------------------------------------------\n        virtual IConnectableEvent<OrientationUpdatedDelegate>& GetOrientationUpdatedEvent() = 0;\n        //----------------------------------------------------\n        /// Stop listening for orientation changes.\n        ///\n        /// @author J Brown\n        //----------------------------------------------------\n        virtual void StopUpdating() = 0;\n        //----------------------------------------------------\n        /// Destructor\n        ///\n        /// @author J Brown\n        //----------------------------------------------------\n        virtual ~Gyroscope() {}\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Input/Gyroscope.h",
    "content": "//\n//  Gyroscope.h\n//  ChilliSource\n//  Created by Jordan Brown on 19/01/2017.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2017 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n\n#ifndef _CHILLISOURCE_INPUT_GYROSCOPE_H_\n#define _CHILLISOURCE_INPUT_GYROSCOPE_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Input/Gyroscope/Gyroscope.h>\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Input/Keyboard/KeyCode.cpp",
    "content": "//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Input/Keyboard/KeyCode.h>\n\n#include <string>\n\nnamespace ChilliSource\n{\n    //----------------------------------------------------------------------\n    std::string GetKeyName(const KeyCode& in_key)\n    {\n        switch (in_key)\n        {\n            case KeyCode::k_a:\n                return \"A\";\n            case KeyCode::k_b:\n                return \"B\";\n            case KeyCode::k_c:\n                return \"C\";\n            case KeyCode::k_d:\n                return \"D\";\n            case KeyCode::k_e:\n                return \"E\";\n            case KeyCode::k_f:\n                return \"F\";\n            case KeyCode::k_g:\n                return \"G\";\n            case KeyCode::k_h:\n                return \"H\";\n            case KeyCode::k_i:\n                return \"I\";\n            case KeyCode::k_j:\n                return \"J\";\n            case KeyCode::k_k:\n                return \"K\";\n            case KeyCode::k_l:\n                return \"L\";\n            case KeyCode::k_m:\n                return \"M\";\n            case KeyCode::k_n:\n                return \"N\";\n            case KeyCode::k_o:\n                return \"O\";\n            case KeyCode::k_p:\n                return \"P\";\n            case KeyCode::k_q:\n                return \"Q\";\n            case KeyCode::k_r:\n                return \"R\";\n            case KeyCode::k_s:\n                return \"S\";\n            case KeyCode::k_t:\n                return \"T\";\n            case KeyCode::k_u:\n                return \"U\";\n            case KeyCode::k_v:\n                return \"V\";\n            case KeyCode::k_w:\n                return \"W\";\n            case KeyCode::k_x:\n                return \"X\";\n            case KeyCode::k_y:\n                return \"Y\";\n            case KeyCode::k_z:\n                return \"Z\";\n            case KeyCode::k_num0:\n                return \"0\";\n            case KeyCode::k_num1:\n                return \"1\";\n            case KeyCode::k_num2:\n                return \"2\";\n            case KeyCode::k_num3:\n                return \"3\";\n            case KeyCode::k_num4:\n                return \"4\";\n            case KeyCode::k_num5:\n                return \"5\";\n            case KeyCode::k_num6:\n                return \"6\";\n            case KeyCode::k_num7:\n                return \"7\";\n            case KeyCode::k_num8:\n                return \"8\";\n            case KeyCode::k_num9:\n                return \"9\";\n            case KeyCode::k_f1:\n                return \"F1\";\n            case KeyCode::k_f2:\n                return \"F2\";\n            case KeyCode::k_f3:\n                return \"F3\";\n            case KeyCode::k_f4:\n                return \"F4\";\n            case KeyCode::k_f5:\n                return \"F5\";\n            case KeyCode::k_f6:\n                return \"F6\";\n            case KeyCode::k_f7:\n                return \"F7\";\n            case KeyCode::k_f8:\n                return \"F8\";\n            case KeyCode::k_f9:\n                return \"F9\";\n            case KeyCode::k_f10:\n                return \"F10\";\n            case KeyCode::k_f11:\n                return \"F11\";\n            case KeyCode::k_f12:\n                return \"F12\";\n            case KeyCode::k_f13:\n                return \"F13\";\n            case KeyCode::k_f14:\n                return \"F14\";\n            case KeyCode::k_f15:\n                return \"F15\";\n            case KeyCode::k_numpad0:\n                return \"Numpad 0\";\n            case KeyCode::k_numpad1:\n                return \"Numpad 1\";\n            case KeyCode::k_numpad2:\n                return \"Numpad 2\";\n            case KeyCode::k_numpad3:\n                return \"Numpad 3\";\n            case KeyCode::k_numpad4:\n                return \"Numpad 4\";\n            case KeyCode::k_numpad5:\n                return \"Numpad 5\";\n            case KeyCode::k_numpad6:\n                return \"Numpad 6\";\n            case KeyCode::k_numpad7:\n                return \"Numpad 7\";\n            case KeyCode::k_numpad8:\n                return \"Numpad 8\";\n            case KeyCode::k_numpad9:\n                return \"Numpad 9\";\n            case KeyCode::k_space:\n                return \"Space\";\n            case KeyCode::k_left:\n                return \"Left\";\n            case KeyCode::k_right:\n                return \"Right\";\n            case KeyCode::k_up:\n                return \"Up\";\n            case KeyCode::k_down:\n                return \"Down\";\n            case KeyCode::k_insert:\n                return \"Insert\";\n            case KeyCode::k_delete:\n                return \"Delete\";\n            case KeyCode::k_home:\n                return \"Home\";\n            case KeyCode::k_end:\n                return \"End\";\n            case KeyCode::k_pageUp:\n                return \"Page Up\";\n            case KeyCode::k_pageDown:\n                return \"Page Down\";\n            case KeyCode::k_pause:\n                return \"Pause\";\n            case KeyCode::k_backSpace:\n                return \"Backspace\";\n            case KeyCode::k_return:\n                return \"Return\";\n            case KeyCode::k_add:\n                return \"Numpad Add\";\n            case KeyCode::k_divide:\n                return \"Numpad Divide\";\n            case KeyCode::k_multiply:\n                return \"Numpad Multiply\";\n            case KeyCode::k_subtract:\n                return \"Numpad Subtract\";\n            case KeyCode::k_escape:\n                return \"Escape\";\n            case KeyCode::k_backSlash:\n                return \"Backslash\";\n            case KeyCode::k_comma:\n                return \"Comma\";\n            case KeyCode::k_period:\n                return \"Period\";\n            case KeyCode::k_forwardSlash:\n                return \"Forward Slash\";\n            case KeyCode::k_semiColon:\n                return \"Semicolon\";\n            case KeyCode::k_quote:\n                return \"Quote\";\n            case KeyCode::k_tilde:\n                return \"Tilde\";\n            case KeyCode::k_leftBracket:\n                return \"Left Bracket\";\n            case KeyCode::k_rightBracket:\n                return \"Right Bracket\";\n            case KeyCode::k_hyphen:\n                return \"Hyphen\";\n            case KeyCode::k_equals:\n                return \"Equals\";\n            case KeyCode::k_menu:\n                return \"Menu\";\n            case KeyCode::k_leftShift:\n                return \"Left Shift\";\n            case KeyCode::k_rightShift:\n                return \"Right Shift\";\n            case KeyCode::k_leftCtrl:\n                return \"Left Ctrl\";\n            case KeyCode::k_rightCtrl:\n                return \"Right Ctrl\";\n            case KeyCode::k_leftAlt:\n                return \"Left Alt\";\n            case KeyCode::k_rightAlt:\n                return \"Right Alt\";\n            case KeyCode::k_leftSystem:\n                return \"Left System\";\n            case KeyCode::k_rightSystem:\n                return \"Right System\";\n            case KeyCode::k_tab:\n                return \"Tab\";\n            case KeyCode::k_unknown:\n                return \"Unknown\";\n            case KeyCode::k_total:\n                break;\n        }\n        \n        CS_LOG_FATAL(\"Invalid keycode.\");\n        return \"\";\n    }\n}"
  },
  {
    "path": "Source/ChilliSource/Input/Keyboard/KeyCode.h",
    "content": "//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_INPUT_KEYBOARD_KEYCODE_H_\n#define _CHILLISOURCE_INPUT_KEYBOARD_KEYCODE_H_\n\n#include <ChilliSource/ChilliSource.h>\n\n#include <string>\n\nnamespace ChilliSource\n{\n    /// List of all the key-codes supported for keyboard events\n    ///\n    enum class KeyCode\n    {\n        k_unknown,\n        k_a,\n        k_b,\n        k_c,\n        k_d,\n        k_e,\n        k_f,\n        k_g,\n        k_h,\n        k_i,\n        k_j,\n        k_k,\n        k_l,\n        k_m,\n        k_n,\n        k_o,\n        k_p,\n        k_q,\n        k_r,\n        k_s,\n        k_t,\n        k_u,\n        k_v,\n        k_w,\n        k_x,\n        k_y,\n        k_z,\n        k_num0,\n        k_num1,\n        k_num2,\n        k_num3,\n        k_num4,\n        k_num5,\n        k_num6,\n        k_num7,\n        k_num8,\n        k_num9,\n        k_escape,\n        k_leftCtrl,\n        k_leftShift,\n        k_leftAlt,\n        k_leftSystem, //Windows key, Command key, etc\n        k_rightCtrl,\n        k_rightShift,\n        k_rightAlt,\n        k_rightSystem, //Windows key, Command key, etc\n        k_menu,\n        k_leftBracket,\n        k_rightBracket,\n        k_semiColon,\n        k_comma,\n        k_period,\n        k_quote,\n        k_forwardSlash,\n        k_backSlash,\n        k_tilde,\n        k_equals,\n        k_hyphen,\n        k_space,\n        k_return,\n        k_backSpace,\n        k_tab,\n        k_pageUp,\n        k_pageDown,\n        k_end,\n        k_home,\n        k_insert,\n        k_delete,\n        k_add,\n        k_subtract,\n        k_multiply,\n        k_divide,\n        k_left,\n        k_right,\n        k_up,\n        k_down,\n        k_numpad0,\n        k_numpad1,\n        k_numpad2,\n        k_numpad3,\n        k_numpad4,\n        k_numpad5,\n        k_numpad6,\n        k_numpad7,\n        k_numpad8,\n        k_numpad9,\n        k_f1,\n        k_f2,\n        k_f3,\n        k_f4,\n        k_f5,\n        k_f6,\n        k_f7,\n        k_f8,\n        k_f9,\n        k_f10,\n        k_f11,\n        k_f12,\n        k_f13,\n        k_f14,\n        k_f15,\n        k_pause,\n        \n        k_total\n    };\n    /// Retrieve a key name as a string for a given key code.\n    ///\n    /// @param in_key \n    ///     The key code to retrieve.\n    ///\n    std::string GetKeyName(const KeyCode& in_key);\n}\n\n#endif\n\n\n"
  },
  {
    "path": "Source/ChilliSource/Input/Keyboard/Keyboard.cpp",
    "content": "//\n//  Keyboard.cpp\n//  ChilliSource\n//  Created by Scott Downie on 09/07/2014\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Input/Keyboard/Keyboard.h>\n\n#ifdef CS_TARGETPLATFORM_WINDOWS\n#include <CSBackend/Platform/Windows/Input/Keyboard/Keyboard.h>\n#endif\n#ifdef CS_TARGETPLATFORM_RPI\n#include <CSBackend/Platform/RPi/Input/Keyboard/Keyboard.h>\n#endif\n\nnamespace ChilliSource\n{\n    CS_DEFINE_NAMEDTYPE(Keyboard);\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    KeyboardUPtr Keyboard::Create()\n    {\n#if defined CS_TARGETPLATFORM_WINDOWS\n        return KeyboardUPtr(new CSBackend::Windows::Keyboard());\n#elif defined CS_TARGETPLATFORM_RPI\n        return KeyboardUPtr(new CSBackend::RPi::Keyboard());\n#else\n        return nullptr;\n#endif\n\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Input/Keyboard/Keyboard.h",
    "content": "//\n//  Keyboard.h\n//  ChilliSource\n//  Created by Scott Downie on 09/07/2014\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_INPUT_KEYBOARD_KEYBOARD_H_\n#define _CHILLISOURCE_INPUT_KEYBOARD_KEYBOARD_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Event/Event.h>\n#include <ChilliSource/Core/System/AppSystem.h>\n\n#include <functional>\n#include <vector>\n\nnamespace ChilliSource\n{\n    //---------------------------------------------------------------\n    /// A system for receiving input from the current keyboard\n    ///\n    /// @author S Downie\n    //---------------------------------------------------------------\n    class Keyboard : public AppSystem\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(Keyboard);\n        \n        //-------------------------------------------------------\n        /// Delegate that receieves events on the key with the\n        /// given code when key is pressed\n        ///\n        /// @author S Downie\n        ///\n        /// @param Key code\n        /// @param List of modifier keys that are down\n        //-------------------------------------------------------\n        using KeyPressedDelegate = std::function<void(KeyCode, const std::vector<ModifierKeyCode>&)>;\n        //-------------------------------------------------------\n        /// Delegate that receieves events on the key with the\n        /// given code when key is released\n        ///\n        /// @author S Downie\n        ///\n        /// @param Key code\n        //-------------------------------------------------------\n        using KeyReleasedDelegate = std::function<void(KeyCode)>;\n        //-------------------------------------------------------\n        /// Check whether the key is currently down. This is\n        /// unbuffered so will only check the state of the key\n        /// at the moment in time when it is called\n        ///\n        /// @author S Downie\n        ///\n        /// @param Key code\n        ///\n        /// @return Whether the key is down\n        //-------------------------------------------------------\n        virtual bool IsKeyDown(KeyCode in_code) const = 0;\n        //-------------------------------------------------------\n        /// Get the event that is triggered whenever a key is pressed.\n        ///\n        /// This event is guaranteed and should be used for low\n        /// frequency events such as catching a confirm enter press.\n        /// The polling \"IsDown\" method should be used for realtime\n        /// events such as moving characters on arrow press, etc.\n        ///\n        /// The event also returns the current state of the modifier\n        /// keys (Ctrl, Alt, Shift, etc.)\n        ///\n        /// @author S Downie\n        ///\n        /// @return Event to register for key presses\n        //-------------------------------------------------------\n        virtual IConnectableEvent<KeyPressedDelegate>& GetKeyPressedEvent() = 0;\n        //-------------------------------------------------------\n        /// Get the event that is triggered whenever a key is released.\n        ///\n        /// This event is guaranteed and should be used for low\n        /// frequency events. The polling \"IsUp\" method should be\n        /// used for realtime events.\n        ///\n        /// @author S Downie\n        ///\n        /// @return Event to register for key releases\n        //-------------------------------------------------------\n        virtual IConnectableEvent<KeyReleasedDelegate>& GetKeyReleasedEvent() = 0;\n        //-------------------------------------------------------\n        /// Virtual destructor\n        ///\n        /// @author S Downie\n        //-------------------------------------------------------\n        virtual ~Keyboard(){}\n        \n    protected:\n        \n        friend class Application;\n        //-------------------------------------------------------\n        /// Factory method from creating a new platform specific\n        /// instance of the keyboard system.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @return The new instance of the system.\n        //-------------------------------------------------------\n        static KeyboardUPtr Create();\n    };\n}\n\n#endif\n\n\n"
  },
  {
    "path": "Source/ChilliSource/Input/Keyboard/ModifierKeyCode.h",
    "content": "//\n//  ModifierKeyCode.h\n//  ChilliSource\n//  Created by Scott Downie on 09/07/2014\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_INPUT_KEYBOARD_MODIFIERKEYCODE_H_\n#define _CHILLISOURCE_INPUT_KEYBOARD_MODIFIERKEYCODE_H_\n\nnamespace ChilliSource\n{\n    //---------------------------------------------------------------\n    /// List of all the modifier key-codes supported for keyboard events.\n    /// This makes no distinction between left and right keys and therefore\n    /// is independent of standard key codes\n    ///\n    /// @author S Downie\n    //---------------------------------------------------------------\n    enum class ModifierKeyCode\n    {\n        k_ctrl,\n        k_alt,\n        k_shift,\n        k_system, //Windows, Command, etc.\n        \n        k_total\n    };\n}\n\n#endif\n\n\n"
  },
  {
    "path": "Source/ChilliSource/Input/Keyboard.h",
    "content": "//\n//  Keyboard.h\n//  ChilliSource\n//  Created by Ian Copland on 07/07/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n\n#ifndef _CHILLISOURCE_INPUT_KEYBOARD_H_\n#define _CHILLISOURCE_INPUT_KEYBOARD_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Input/Keyboard/Keyboard.h>\n#include <ChilliSource/Input/Keyboard/KeyCode.h>\n#include <ChilliSource/Input/Keyboard/ModifierKeyCode.h>\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Input/Pointer/Pointer.cpp",
    "content": "//\n//  Pointer.cpp\n//  ChilliSource\n//  Created by Scott Downie on 08/07/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Input/Pointer/Pointer.h>\n\nnamespace ChilliSource\n{\n    //----------------------------------------------------\n    //----------------------------------------------------\n    Pointer::InputType Pointer::GetDefaultInputType()\n    {\n#if defined CS_TARGETPLATFORM_ANDROID\n        return Pointer::InputType::k_touch;\n#elif defined CS_TARGETPLATFORM_IOS\n        return Pointer::InputType::k_touch;\n#elif defined CS_TARGETPLATFORM_WINDOWS\n        return Pointer::InputType::k_leftMouseButton;\n#elif defined CS_TARGETPLATFORM_RPI\n        return Pointer::InputType::k_leftMouseButton;\n#else\n        return nullptr;\n#endif\n    }\n    //----------------------------------------------------\n    //----------------------------------------------------\n    Pointer::Pointer(Id in_uniqueId, u32 in_index, const Vector2& in_initialPosition)\n    : m_uniqueId(in_uniqueId), m_index(in_index), m_position(in_initialPosition), m_previousPosition(in_initialPosition)\n    {\n    }\n    //----------------------------------------------------\n    //----------------------------------------------------\n    Vector2 Pointer::GetPosition() const\n    {\n        return m_position;\n    }\n    //----------------------------------------------------\n    //----------------------------------------------------\n    Vector2 Pointer::GetPreviousPosition() const\n    {\n        return m_previousPosition;\n    }\n    //----------------------------------------------------\n    //----------------------------------------------------\n    bool Pointer::IsInputDown(InputType in_type) const\n    {\n        return m_activeInput.find(in_type) != m_activeInput.end();\n    }\n    //----------------------------------------------------\n    //----------------------------------------------------\n    bool Pointer::IsInputUp(InputType in_type) const\n    {\n        return m_activeInput.find(in_type) == m_activeInput.end();\n    }\n    //----------------------------------------------------\n    //----------------------------------------------------\n    Pointer::Id Pointer::GetId() const\n    {\n        return m_uniqueId;\n    }\n    //----------------------------------------------------\n    //----------------------------------------------------\n    u32 Pointer::GetIndex() const\n    {\n        return m_index;\n    }\n    //----------------------------------------------------\n    //----------------------------------------------------\n    const std::set<Pointer::InputType>& Pointer::GetActiveInputs() const\n    {\n        return m_activeInput;\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Input/Pointer/Pointer.h",
    "content": "//\n//  Pointer.h\n//  ChilliSource\n//  Created by Scott Downie on 08/07/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_INPUT_POINTER_POINTER_H_\n#define _CHILLISOURCE_INPUT_POINTER_POINTER_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Math/Vector2.h>\n\n#include <set>\n\nnamespace ChilliSource\n{\n    //----------------------------------------------------\n    /// A container for information on a single pointer.\n    /// A pointer contains positional information as well\n    /// as an index and unique Id. The Id is unique to that\n    /// specific pointer and can be used to query for it.\n    /// The index describes the active index of the pointer\n    /// at the point it was created, so if there were already\n    /// two active pointers existing at creation, it will be\n    /// have an index of 2.\n    ///\n    /// @author Ian Copland\n    //----------------------------------------------------\n    class Pointer final\n    {\n    public:\n\n        using Id = u64;\n        //----------------------------------------------------\n        /// An enum describing the different types of pointer\n        /// press.\n        ///\n        /// @author Ian Copland\n        //----------------------------------------------------\n        enum class InputType\n        {\n            k_none,\n            k_touch,\n            k_leftMouseButton,\n            k_middleMouseButton,\n            k_rightMouseButton\n        };\n        //----------------------------------------------------\n        /// Returns the default press type for the current platform.\n        /// This should be used where possible rather than\n        /// direct use of the press type to make cross platform\n        /// development easier.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @return the default press type.\n        //----------------------------------------------------\n        static InputType GetDefaultInputType();\n        \n        ///\n        /// Default constructor required for TryGetPointer\n        ///\n        Pointer() = default;\n        \n        //----------------------------------------------------\n        /// Constructor\n        ///\n        /// @author S Downie\n        ///\n        /// @param Unique Id\n        /// @param Index in list\n        /// @param Position\n        //----------------------------------------------------\n        Pointer(Id in_uniqueId, u32 in_index, const Vector2& in_initialPosition);\n        //----------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Current pointer location\n        //----------------------------------------------------\n        Vector2 GetPosition() const;\n        //----------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Previous pointer location\n        //----------------------------------------------------\n        Vector2 GetPreviousPosition() const;\n        //----------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Input type\n        ///\n        /// @return Whether the input type is down\n        //----------------------------------------------------\n        bool IsInputDown(InputType in_type) const;\n        //----------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Input type\n        ///\n        /// @return Whether the input type is up\n        //----------------------------------------------------\n        bool IsInputUp(InputType in_type) const;\n        //----------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Id\n        //----------------------------------------------------\n        Id GetId() const;\n        //----------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Index of pointer in pointer list\n        //----------------------------------------------------\n        u32 GetIndex() const;\n        //----------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Container of inout types that are currently\n        /// down\n        //----------------------------------------------------\n        const std::set<InputType>& GetActiveInputs() const;\n        \n    private:\n        \n        friend class PointerSystem;\n        \n        Vector2 m_position;\n        Vector2 m_previousPosition;\n        Id m_uniqueId;\n        u32 m_index;\n        std::set<InputType> m_activeInput;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Input/Pointer/PointerSystem.cpp",
    "content": "//\n//  PointerSystem.cpp\n//  ChilliSource\n//  Created by Ian Copland on 26/03/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Input/Pointer/PointerSystem.h>\n\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Input/Base/InputFilter.h>\n\n#include <thread>\n#include <algorithm>\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n#include <CSBackend/Platform/Android/Main/JNI/Input/Pointer/PointerSystem.h>\n#endif\n\n#ifdef CS_TARGETPLATFORM_IOS\n#include <CSBackend/Platform/iOS/Input/Pointer/PointerSystem.h>\n#endif\n\n#ifdef CS_TARGETPLATFORM_WINDOWS\n#include <CSBackend/Platform/Windows/Input/Pointer/PointerSystem.h>\n#endif\n\n#ifdef CS_TARGETPLATFORM_RPI\n#include <CSBackend/Platform/RPi/Input/Pointer/PointerSystem.h>\n#endif\n\nnamespace ChilliSource\n{\n    CS_DEFINE_NAMEDTYPE(PointerSystem);\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    PointerSystemUPtr PointerSystem::Create()\n    {\n#if defined CS_TARGETPLATFORM_ANDROID\n        return PointerSystemUPtr(new CSBackend::Android::PointerSystem());\n#elif defined CS_TARGETPLATFORM_IOS\n        return PointerSystemUPtr(new CSBackend::iOS::PointerSystem());\n#elif defined CS_TARGETPLATFORM_WINDOWS\n        return PointerSystemUPtr(new CSBackend::Windows::PointerSystem());\n#elif defined CS_TARGETPLATFORM_RPI\n        return PointerSystemUPtr(new CSBackend::RPi::PointerSystem());\n#else\n        return nullptr;\n#endif\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    PointerSystem::PointerSystem()\n        : m_nextUniqueId(0)\n    {\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    IConnectableEvent<PointerSystem::PointerAddedDelegate>& PointerSystem::GetPointerAddedEvent()\n    {\n        return m_pointerAddedEvent;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    IConnectableEvent<PointerSystem::PointerDownDelegate>& PointerSystem::GetPointerDownEvent()\n    {\n        return m_pointerDownEvent;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    IConnectableEvent<PointerSystem::PointerMovedDelegate>& PointerSystem::GetPointerMovedEvent()\n    {\n        return m_pointerMovedEvent;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    IConnectableEvent<PointerSystem::PointerUpDelegate>& PointerSystem::GetPointerUpEvent()\n    {\n        return m_pointerUpEvent;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    IConnectableEvent<PointerSystem::PointerScrollDelegate>& PointerSystem::GetPointerScrollEvent()\n    {\n        return m_pointerScrolledEvent;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    IConnectableEvent<PointerSystem::PointerDownDelegate>& PointerSystem::GetPointerDownEventFiltered()\n    {\n        return m_pointerDownEventFiltered;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    IConnectableEvent<PointerSystem::PointerUpDelegate>& PointerSystem::GetPointerUpEventFiltered()\n    {\n        return m_pointerUpEventFiltered;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    IConnectableEvent<PointerSystem::PointerScrollDelegate>& PointerSystem::GetPointerScrollEventFiltered()\n    {\n        return m_pointerScrolledEventFiltered;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    IConnectableEvent<PointerSystem::PointerDownDelegateInternal>& PointerSystem::GetPointerDownEventInternal()\n    {\n        return m_pointerDownEventInternal;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    IConnectableEvent<PointerSystem::PointerScrollDelegateInternal>& PointerSystem::GetPointerScrollEventInternal()\n    {\n        return m_pointerScrolledEventInternal;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    IConnectableEvent<PointerSystem::PointerRemovedDelegate>& PointerSystem::GetPointerRemovedEvent()\n    {\n        return m_pointerRemovedEvent;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    std::vector<Pointer> PointerSystem::GetPointers() const\n    {\n        return m_pointers;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    bool PointerSystem::TryGetPointerWithId(Pointer::Id in_uniqueId, Pointer& out_pointer) const\n    {\n        for (const Pointer& pointer : m_pointers)\n        {\n            if (pointer.GetId() == in_uniqueId)\n            {\n                out_pointer = pointer;\n                return true;\n            }\n        }\n        \n        return false;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    bool PointerSystem::TryGetPointerWithIndex(u32 in_index, Pointer& out_pointer) const\n    {\n        for (const Pointer& pointer : m_pointers)\n        {\n            if (pointer.GetIndex() == in_index)\n            {\n                out_pointer = pointer;\n                return true;\n            }\n        }\n        \n        return false;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void PointerSystem::ProcessQueuedInput()\n    {\n        std::unique_lock<std::mutex> lock(m_mutex);\n        std::queue<PointerEvent> eventQueue = m_eventQueue;\n        while (m_eventQueue.empty() == false)\n        {\n            m_eventQueue.pop();\n        }\n        lock.unlock();\n        \n        while (eventQueue.empty() == false)\n        {\n            PointerEvent& event = eventQueue.front();\n            \n            switch (event.m_type)\n            {\n                case PointerEventType::k_add:\n                    CreatePointer(event.m_pointerUniqueId, event.m_timestamp, event.m_position);\n                    break;\n                case PointerEventType::k_down:\n                    PointerDown(event.m_pointerUniqueId, event.m_timestamp, event.m_InputType);\n                    break;\n                case PointerEventType::k_move:\n                    PointerMoved(event.m_pointerUniqueId, event.m_timestamp, event.m_position);\n                    break;\n                case PointerEventType::k_up:\n                    PointerUp(event.m_pointerUniqueId, event.m_timestamp, event.m_InputType);\n                    break;\n                case PointerEventType::k_scroll:\n                    PointerScrolled(event.m_pointerUniqueId, event.m_timestamp, event.m_position);\n                    break;\n                case PointerEventType::k_remove:\n                    RemovePointer(event.m_pointerUniqueId, event.m_timestamp);\n                    break;\n                default:\n                    CS_LOG_FATAL(\"Something has gone very wrong while processing buffered input\");\n                    break;\n            }\n            \n            eventQueue.pop();\n        }\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    Pointer::Id PointerSystem::AddPointerCreateEvent(const Vector2& in_position)\n    {\n        std::unique_lock<std::mutex> lock(m_mutex);\n        \n        PointerEvent event;\n        auto uniqueId = m_nextUniqueId++;\n        event.m_type = PointerEventType::k_add;\n        event.m_pointerUniqueId = uniqueId;\n        event.m_InputType = Pointer::InputType::k_none;\n        event.m_position = in_position;\n        event.m_timestamp = 0.0;\n        \n        m_eventQueue.push(std::move(event));\n        \n        return uniqueId;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void PointerSystem::AddPointerDownEvent(Pointer::Id in_pointerUniqueId, Pointer::InputType in_inputType)\n    {\n        std::unique_lock<std::mutex> lock(m_mutex);\n        \n        PointerEvent event;\n        event.m_type = PointerEventType::k_down;\n        event.m_pointerUniqueId = in_pointerUniqueId;\n        event.m_InputType = in_inputType;\n        event.m_position = Vector2::k_zero;\n        event.m_timestamp = ((f64)Application::Get()->GetSystemTimeInMilliseconds()) / 1000.0;\n        \n        m_eventQueue.push(std::move(event));\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void PointerSystem::AddPointerMovedEvent(Pointer::Id in_pointerUniqueId, const Vector2& in_position)\n    {\n        std::unique_lock<std::mutex> lock(m_mutex);\n        \n        PointerEvent event;\n        event.m_type = PointerEventType::k_move;\n        event.m_pointerUniqueId = in_pointerUniqueId;\n        event.m_InputType = Pointer::InputType::k_none;\n        event.m_position = in_position;\n        event.m_timestamp = ((f64)Application::Get()->GetSystemTimeInMilliseconds()) / 1000.0;\n        \n        m_eventQueue.push(std::move(event));\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void PointerSystem::AddPointerUpEvent(Pointer::Id in_pointerUniqueId, Pointer::InputType in_inputType)\n    {\n        std::unique_lock<std::mutex> lock(m_mutex);\n        \n        PointerEvent event;\n        event.m_type = PointerEventType::k_up;\n        event.m_pointerUniqueId = in_pointerUniqueId;\n        event.m_InputType = in_inputType;\n        event.m_position = Vector2::k_zero;\n        event.m_timestamp = ((f64)Application::Get()->GetSystemTimeInMilliseconds()) / 1000.0;\n        \n        m_eventQueue.push(std::move(event));\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void PointerSystem::AddPointerScrollEvent(Pointer::Id in_pointerUniqueId, const Vector2& in_delta)\n    {\n        std::unique_lock<std::mutex> lock(m_mutex);\n        \n        PointerEvent event;\n        event.m_type = PointerEventType::k_scroll;\n        event.m_pointerUniqueId = in_pointerUniqueId;\n        event.m_InputType = Pointer::InputType::k_none;\n        event.m_timestamp = ((f64)Application::Get()->GetSystemTimeInMilliseconds()) / 1000.0;\n        event.m_position = in_delta;\n        \n        m_eventQueue.push(std::move(event));\n    }\n    //------------------------------------------------------------------------------\n    //-------------------------------------------------------------------------------\n    void PointerSystem::AddPointerRemoveEvent(Pointer::Id in_pointerUniqueId)\n    {\n        std::unique_lock<std::mutex> lock(m_mutex);\n        \n        PointerEvent event;\n        event.m_type = PointerEventType::k_remove;\n        event.m_pointerUniqueId = in_pointerUniqueId;\n        event.m_InputType = Pointer::InputType::k_none;\n        event.m_position = Vector2::k_zero;\n        event.m_timestamp = 0.0;\n        \n        m_eventQueue.push(std::move(event));\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void PointerSystem::RemoveAllPointers()\n    {\n        std::unique_lock<std::mutex> lock(m_mutex);\n        \n        while (m_eventQueue.empty() == false)\n        {\n            m_eventQueue.pop();\n        }\n        \n        lock.unlock();\n        \n        m_pointers.clear();\n    }\n    //------------------------------------------------------------------------------\n    //-------------------------------------------------------------------------------\n    void PointerSystem::CreatePointer(Pointer::Id in_uniqueId, f64 in_timestamp, const Vector2& in_initialPosition)\n    {\n        //Find the first free index\n        u32 index = 0;\n\n        while(true)\n        {\n            bool indexAvailable = true;\n            \n            for (const Pointer& pointer : m_pointers)\n            {\n                if (pointer.GetIndex() == index)\n                {\n                    indexAvailable = false;\n                    break;\n                }\n            }\n            \n            if(indexAvailable == true)\n            {\n                break;\n            }\n            \n            ++index;\n        }\n        \n        Pointer pointer(in_uniqueId, index, in_initialPosition);\n        m_pointers.push_back(pointer);\n        \n        //create the filtered input set.\n        CS_ASSERT(m_filteredPointerInput.find(pointer.m_uniqueId) == m_filteredPointerInput.end(), \"Filtered input already exists!\");\n        m_filteredPointerInput.emplace(pointer.m_uniqueId, std::set<Pointer::InputType>());\n        \n        m_pointerAddedEvent.NotifyConnections(pointer, in_timestamp);\n    }\n    //------------------------------------------------------------------------------\n    //-------------------------------------------------------------------------------\n    void PointerSystem::PointerDown(Pointer::Id in_uniqueId, f64 in_timestamp, Pointer::InputType in_inputType)\n    {\n        auto pointerIt = std::find_if(m_pointers.begin(), m_pointers.end(), [in_uniqueId](const Pointer& in_pointer)\n        {\n            return (in_uniqueId == in_pointer.GetId());\n        });\n        \n        if (pointerIt != m_pointers.end())\n        {\n            pointerIt->m_activeInput.insert(in_inputType);\n            Pointer copy = *pointerIt;\n            \n            //Notify unfiltered connections\n            m_pointerDownEvent.NotifyConnections(copy, in_timestamp, in_inputType);\n            \n            InputFilter filter;\n            //Notify internal engine connections which can filter the input\n            m_pointerDownEventInternal.NotifyConnections(copy, in_timestamp, in_inputType, filter);\n            \n            //Notify filtered connections if the input has not been filtered\n            if(filter.IsFiltered() == false)\n            {\n                m_pointerDownEventFiltered.NotifyConnections(copy, in_timestamp, in_inputType);\n            }\n            else\n            {\n                //update the filtered input set.\n                auto filteredInputSetIt = m_filteredPointerInput.find(in_uniqueId);\n                CS_ASSERT(filteredInputSetIt != m_filteredPointerInput.end(), \"Filtered input doesn't exist!\");\n                CS_ASSERT(filteredInputSetIt->second.find(in_inputType) == filteredInputSetIt->second.end(), \"Input already filtered!\");\n                \n                filteredInputSetIt->second.insert(in_inputType);\n            }\n        }\n        else\n        {\n            CS_LOG_FATAL(\"PointerSystem: Received pointer down event for unknown pointer Id.\");\n        }\n    }\n    //------------------------------------------------------------------------------\n    //-------------------------------------------------------------------------------\n    void PointerSystem::PointerMoved(Pointer::Id in_uniqueId, f64 in_timestamp, const Vector2& in_newPosition)\n    {\n        auto pointerIt = std::find_if(m_pointers.begin(), m_pointers.end(), [in_uniqueId](const Pointer& in_pointer)\n        {\n            return (in_uniqueId == in_pointer.GetId());\n        });\n        \n        if (pointerIt != m_pointers.end())\n        {\n            pointerIt->m_previousPosition = pointerIt->m_position;\n            pointerIt->m_position = in_newPosition;\n            Pointer copy = *pointerIt;\n\n            //Notify all connections\n            m_pointerMovedEvent.NotifyConnections(copy, in_timestamp);\n        }\n        else\n        {\n            CS_LOG_FATAL(\"PointerSystem: Received pointer moved event for unknown pointer Id.\");\n        }\n    }\n    //------------------------------------------------------------------------------\n    //-------------------------------------------------------------------------------\n    void PointerSystem::PointerUp(Pointer::Id in_uniqueId, f64 in_timestamp, Pointer::InputType in_inputType)\n    {\n        auto pointerIt = std::find_if(m_pointers.begin(), m_pointers.end(), [in_uniqueId](const Pointer& in_pointer)\n        {\n            return (in_uniqueId == in_pointer.GetId());\n        });\n        \n        if (pointerIt != m_pointers.end())\n        {\n            pointerIt->m_activeInput.erase(in_inputType);\n            Pointer copy = *pointerIt;\n\n            //Notify unfiltered connections\n            m_pointerUpEvent.NotifyConnections(copy, in_timestamp, in_inputType);\n            \n            //Notify filtered connections if the input has not been filtered\n            auto filteredInputSetIt = m_filteredPointerInput.find(in_uniqueId);\n            CS_ASSERT(filteredInputSetIt != m_filteredPointerInput.end(), \"Filtered input doesn't exist!\");\n\n            auto filteredInputIt = filteredInputSetIt->second.find(in_inputType);\n            if(filteredInputIt == filteredInputSetIt->second.end())\n            {\n                m_pointerUpEventFiltered.NotifyConnections(copy, in_timestamp, in_inputType);\n            }\n            else\n            {\n                filteredInputSetIt->second.erase(filteredInputIt);\n            }\n        }\n        else\n        {\n            CS_LOG_FATAL(\"PointerSystem: Received pointer down event for unknown pointer Id.\");\n        }\n    }\n    //------------------------------------------------------------------------------\n    //-------------------------------------------------------------------------------\n    void PointerSystem::PointerScrolled(Pointer::Id in_uniqueId, f64 in_timestamp, const Vector2& in_delta)\n    {\n        auto pointerIt = std::find_if(m_pointers.begin(), m_pointers.end(), [in_uniqueId](const Pointer& in_pointer)\n        {\n            return (in_uniqueId == in_pointer.GetId());\n        });\n        \n        if (pointerIt != m_pointers.end())\n        {\n            Pointer copy = *pointerIt;\n\n            //Notify unfiltered connections\n            m_pointerScrolledEvent.NotifyConnections(copy, in_timestamp, in_delta);\n            \n            InputFilter filter;\n            //Notify internal engine connections which can filter the input\n            m_pointerScrolledEventInternal.NotifyConnections(copy, in_timestamp, in_delta, filter);\n            \n            //Notify filtered connections if the input has not been filtered\n            if(filter.IsFiltered() == false)\n            {\n                m_pointerScrolledEventFiltered.NotifyConnections(copy, in_timestamp, in_delta);\n            }\n        }\n        else\n        {\n            CS_LOG_FATAL(\"PointerSystem: Received pointer scroll event for unknown pointer Id.\");\n        }\n    }\n    //------------------------------------------------------------------------------\n    //-------------------------------------------------------------------------------\n    void PointerSystem::RemovePointer(Pointer::Id in_uniqueId, f64 in_timestamp)\n    {\n        //remove the filtered input set.\n        auto filteredInputIt = m_filteredPointerInput.find(in_uniqueId);\n        CS_ASSERT(filteredInputIt != m_filteredPointerInput.end(), \"Filtered input doesn't exist!\");\n        \n        m_filteredPointerInput.erase(filteredInputIt);\n        \n        //find the pointer.\n        auto pointerIt = std::find_if(m_pointers.begin(), m_pointers.end(), [in_uniqueId](const Pointer& in_pointer)\n        {\n            return (in_uniqueId == in_pointer.GetId());\n        });\n        \n        auto pointer = *pointerIt;\n        \n        //remove the pointer\n        if (pointerIt != m_pointers.end())\n        {\n            m_pointers.erase(pointerIt);\n        }\n        else\n        {\n            CS_LOG_FATAL(\"PointerSystem: Received remove pointer event for unknown pointer Id.\");\n        }\n        \n        m_pointerRemovedEvent.NotifyConnections(pointer, in_timestamp);\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Input/Pointer/PointerSystem.h",
    "content": "//\n//  PointerSystem.h\n//  ChilliSource\n//  Created by Ian Copland on 26/03/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_INPUT_POINTER_POINTERSYSTEM_H_\n#define _CHILLISOURCE_INPUT_POINTER_POINTERSYSTEM_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Event/Event.h>\n#include <ChilliSource/Core/Math/Vector2.h>\n#include <ChilliSource/Core/System/AppSystem.h>\n#include <ChilliSource/Input/Pointer/Pointer.h>\n\n#include <mutex>\n#include <queue>\n#include <set>\n#include <unordered_map>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    /// A system that provides a generic API for working with pointer devices.\n    /// Pointers include touches on a touch screen and the mouse on a PC.\n    ///\n    /// @author Ian Copland\n    //------------------------------------------------------------------------------\n    class PointerSystem : public AppSystem\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(PointerSystem);\n        //------------------------------------------------------------------------------\n        /// A delegate that is used to receive pointer added events.\n        ///\n        /// On platforms which use a mouse this occurs once: when the mouse is first\n        /// created. On platforms with a touch screen this is called everytime a new\n        /// touch is added - immediately before the pointer down event.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param in_pointer - The pointer.\n        /// @param in_timestamp - The timestamp of the event.\n        //------------------------------------------------------------------------------\n        using PointerAddedDelegate = std::function<void(const Pointer& in_pointer, f64 in_timestamp)>;\n        //------------------------------------------------------------------------------\n        /// A delegate that is used to receive pointer down events. This could be\n        /// pressing a mouse button or touching a touch screen.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param in_pointer - The pointer.\n        /// @param in_timestamp - The timestamp of the event.\n        /// @param in_inputType - The press type.\n        //------------------------------------------------------------------------------\n        using PointerDownDelegate = std::function<void(const Pointer& in_pointer, f64 in_timestamp, Pointer::InputType in_inputType)>;\n        //------------------------------------------------------------------------------\n        /// A delegate that is used to receive pointer moved events. This could be\n        /// dragging a touch on screen or moving the mouse cursor.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param in_pointer - The pointer\n        /// @param in_timestamp - The timestamp of the event.\n        //------------------------------------------------------------------------------\n        using PointerMovedDelegate = std::function<void(const Pointer& in_pointer, f64 in_timestamp)>;\n        //------------------------------------------------------------------------------\n        /// A delegate that is used to receive pointer up events. This could be\n        /// releasing a mouse button or releasing a touch from the touch screen.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param in_pointer - The pointer\n        /// @param in_timestamp - The timestamp of the event.\n        /// @param in_inputType - The press type.\n        //------------------------------------------------------------------------------\n        using PointerUpDelegate = std::function<void(const Pointer& in_pointer, f64 in_timestamp, Pointer::InputType in_inputType)>;\n        //------------------------------------------------------------------------------\n        /// A delegate that is used to receive pointer scroll events (i.e. mouse wheel).\n        ///\n        /// @author Scott Downie\n        ///\n        /// @param in_pointer - The pointer\n        /// @param in_timestamp - The timestamp of the event.\n        /// @param in_delta - The scroll vector (x, y delta)\n        //------------------------------------------------------------------------------\n        using PointerScrollDelegate = std::function<void(const Pointer& in_pointer, f64 in_timestamp, const Vector2& in_delta)>;\n        //------------------------------------------------------------------------------\n        /// A delegate that is used to receive pointer removal events.\n        ///\n        /// On platforms which use a mouse this occurs once: when the mouse is destroyed\n        /// on application shutdown. On platforms with a touch screen this is called\n        /// everytime an existing touch is removed - immediately after the pointer up\n        /// event.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param in_pointer - The pointer.\n        /// @param in_timestamp - The timestamp of the event.\n        //------------------------------------------------------------------------------\n        using PointerRemovedDelegate = std::function<void(const Pointer& in_pointer, f64 in_timestamp)>;\n        //------------------------------------------------------------------------------\n        /// An event that is called whenever a new pointer is added.\n        ///\n        /// On platforms which use a mouse this occurs once: when the mouse is first\n        /// created. On platforms with a touch screen this is called everytime a new\n        /// touch is added - immediately before the pointer down event.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @return The pointer added event.\n        //------------------------------------------------------------------------------\n        IConnectableEvent<PointerAddedDelegate>& GetPointerAddedEvent();\n        //------------------------------------------------------------------------------\n        /// Event that is triggered when the pointer is first down.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @return The pointer down event.\n        //------------------------------------------------------------------------------\n        IConnectableEvent<PointerDownDelegate>& GetPointerDownEvent();\n        //------------------------------------------------------------------------------\n        /// Event that is triggered when the pointer moves.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @return The pointer moved event.\n        //------------------------------------------------------------------------------\n        IConnectableEvent<PointerMovedDelegate>& GetPointerMovedEvent();\n        //------------------------------------------------------------------------------\n        /// Event that is triggered when the pointer is first up having been down.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @return The pointer up event.\n        //------------------------------------------------------------------------------\n        IConnectableEvent<PointerUpDelegate>& GetPointerUpEvent();\n        //------------------------------------------------------------------------------\n        /// Event that is triggered when the scroll wheel ticks.\n        ///\n        /// @author S Downie\n        ///\n        /// @return The event triggered on scroll change (i.e. mouse wheel scroll).\n        //------------------------------------------------------------------------------\n        IConnectableEvent<PointerScrollDelegate>& GetPointerScrollEvent();\n        //------------------------------------------------------------------------------\n        /// Event that is triggered when the pointer is first down.\n        ///\n        /// NOTE: Filtered events are not always triggered as they can be consumed by\n        /// internal systems such as UI.\n        ///\n        /// @author S Downie\n        ///\n        /// @return The pointer down event.\n        //------------------------------------------------------------------------------\n        IConnectableEvent<PointerDownDelegate>& GetPointerDownEventFiltered();\n        //------------------------------------------------------------------------------\n        /// Event that is triggered when the pointer is first up having been down.\n        ///\n        /// NOTE: Filtered events are not always triggered as they can be consumed by\n        /// internal systems such as UI.\n        ///\n        /// @author S Downie\n        ///\n        /// @return The pointer up event.\n        //------------------------------------------------------------------------------\n        IConnectableEvent<PointerUpDelegate>& GetPointerUpEventFiltered();\n        //------------------------------------------------------------------------------\n        /// Event that is triggered when the scroll wheel ticks.\n        ///\n        /// NOTE: Filtered events are not always triggered as they can be consumed by\n        /// internal systems such as UI.\n        ///\n        /// @author S Downie\n        ///\n        /// @return The event triggered on scroll change (i.e. mouse wheel scroll).\n        //------------------------------------------------------------------------------\n        IConnectableEvent<PointerScrollDelegate>& GetPointerScrollEventFiltered();\n        //------------------------------------------------------------------------------\n        /// An event that is called whenever an existing pointer is removed.\n        ///\n        /// On platforms which use a mouse this occurs once: when the mouse is first\n        /// created. On platforms with a touch screen this is called everytime a new\n        /// touch is added - immediately before the pointer down event.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @return The pointer removed event.\n        //------------------------------------------------------------------------------\n        IConnectableEvent<PointerRemovedDelegate>& GetPointerRemovedEvent();\n        //------------------------------------------------------------------------------\n        /// Tries to get the pointer with the given unique Id.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param in_uniqueId - The unique Id of the pointer.\n        /// @param out_pointer - [Out] The output pointer if there was one with the\n        /// given Id.\n        ///\n        /// @return Whether or not there was a pointer with the given Id.\n        //------------------------------------------------------------------------------\n        bool TryGetPointerWithId(Pointer::Id in_uniqueId, Pointer& out_pointer) const;\n        //------------------------------------------------------------------------------\n        /// Tries to get the pointer with the given index.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param in_index - The index of the pointer.\n        /// @param out_pointer - [Out] The output pointer if there was one with the\n        /// given index.\n        ///\n        /// @return Whether or not there was a pointer with the given index.\n        //------------------------------------------------------------------------------\n        bool TryGetPointerWithIndex(u32 in_index, Pointer& out_pointer) const;\n        //------------------------------------------------------------------------------\n        /// Returns the list of currently active pointers.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @return The pointer up event.\n        //------------------------------------------------------------------------------\n        std::vector<Pointer> GetPointers() const;\n        \n        /// @return Number of attached pointers\n        ///\n        u32 GetNumPointers() const noexcept { return (u32)m_pointers.size(); }\n        \n        //------------------------------------------------------------------------------\n        /// Hide the pointer cursor if one exists\n        ///\n        /// @author S Downie\n        //------------------------------------------------------------------------------\n        virtual void HideSystemCursor() = 0;\n        //------------------------------------------------------------------------------\n        /// Show the pointer cursor if one exists\n        ///\n        /// @author S Downie\n        //------------------------------------------------------------------------------\n        virtual void ShowSystemCursor() = 0;\n        //------------------------------------------------------------------------------\n        /// Process all input events that have been received from the OS.\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------------------------------------\n        void ProcessQueuedInput();\n        //------------------------------------------------------------------------------\n        /// Destructor\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------------------------------------\n        virtual ~PointerSystem() {};\n        \n    protected:\n        //------------------------------------------------------------------------------\n        /// Constructor. Declared protected to force the use of the factory method.\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------------------------------------\n        PointerSystem();\n        //------------------------------------------------------------------------------\n        /// Adds a new Create Pointer event.\n        ///\n        /// This method is thread safe and can be called on any thread.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param in_position - The position to create the pointer at.\n        ///\n        /// @return The unique Id of the new pointer.\n        //------------------------------------------------------------------------------\n        Pointer::Id AddPointerCreateEvent(const Vector2& in_position);\n        //------------------------------------------------------------------------------\n        /// Adds a new pointer down event.\n        ///\n        /// This method is thread safe and can be called on any thread.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param in_pointerUniqueId - The unique Id of the pointer.\n        /// @param in_inputType - The input type.\n        //------------------------------------------------------------------------------\n        void AddPointerDownEvent(Pointer::Id in_pointerUniqueId, Pointer::InputType in_inputType);\n        //------------------------------------------------------------------------------\n        /// Adds a new pointer moved event.\n        ///\n        /// This method is threadsafe and can be called on any thread.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param in_pointerUniqueId - The unique Id of the pointer.\n        /// @param in_position - The position it has moved to.\n        //------------------------------------------------------------------------------\n        void AddPointerMovedEvent(Pointer::Id in_pointerUniqueId, const Vector2& in_position);\n        //------------------------------------------------------------------------------\n        /// Adds a new pointer up event.\n        ///\n        /// This method is thread safe and can be called on any thread.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param in_pointerUniqueId - The unique Id of the pointer.\n        /// @param in_inputType - The input type.\n        //------------------------------------------------------------------------------\n        void AddPointerUpEvent(Pointer::Id in_pointerUniqueId, Pointer::InputType in_inputType);\n        //------------------------------------------------------------------------------\n        /// Adds a new pointer scroll event.\n        ///\n        /// This method is thread safe and can be called on any thread.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param in_pointerUniqueId - The unique Id of the pointer.\n        /// @param in_delta - The scroll delta in the x-y plane\n        //------------------------------------------------------------------------------\n        void AddPointerScrollEvent(Pointer::Id in_pointerUniqueId, const Vector2& in_delta);\n        //------------------------------------------------------------------------------\n        /// Adds a new remove pointer event.\n        ///\n        /// This method is thread safe and can be called on any thread.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param in_pointerUniqueId - The unique Id of the pointer that should be\n        /// removed.\n        //------------------------------------------------------------------------------\n        void AddPointerRemoveEvent(Pointer::Id in_pointerUniqueId);\n        //------------------------------------------------------------------------------\n        /// Removes all existing pointers. This must be called from the main thread.\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------------------------------------\n        void RemoveAllPointers();\n        \n    private:\n        friend class Application;\n        friend class GestureSystem;\n        friend class Canvas;\n        //------------------------------------------------------------------------------\n        /// Creates a new platform specific instance of pointer system.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @return The new system instance.\n        //------------------------------------------------------------------------------\n        static PointerSystemUPtr Create();\n        //------------------------------------------------------------------------------\n        /// An enum describing the different types of pointer event.\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------------------------------------\n        enum class PointerEventType\n        {\n            k_add,\n            k_down,\n            k_move,\n            k_up,\n            k_scroll,\n            k_remove\n        };\n        //------------------------------------------------------------------------------\n        /// A container for information on a single pointer event.\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------------------------------------\n        struct PointerEvent\n        {\n            PointerEventType m_type;\n            Pointer::Id m_pointerUniqueId;\n            Vector2 m_position;\n            Pointer::InputType m_InputType;\n            f64 m_timestamp;\n        };\n        //------------------------------------------------------------------------------\n        /// Creates and adds a new pointer to the list.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param in_uniqueId - The unique pointer Id.\n        /// @param in_timestamp - The timestamp of the creation event.\n        /// @param in_initialPosition - The initial position.\n        //------------------------------------------------------------------------------\n        void CreatePointer(Pointer::Id in_uniqueId, f64 in_timestamp, const Vector2& in_initialPosition);\n        //------------------------------------------------------------------------------\n        /// Notifies listeners that the pointer with the given unique id is down.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param in_uniqueId - The unique pointer Id.\n        /// @param in_timestamp - The timestamp.\n        /// @param in_inputType - The press type.\n        //------------------------------------------------------------------------------\n        void PointerDown(Pointer::Id in_uniqueId, f64 in_timestamp, Pointer::InputType in_inputType);\n        //------------------------------------------------------------------------------\n        /// Updates the pointer with the given unique id and notifies listeners that it\n        /// has moved.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param in_uniqueId - The unique pointer Id.\n        /// @param in_timestamp - The timestamp.\n        /// @param in_newPosition - The new position.\n        //------------------------------------------------------------------------------\n        void PointerMoved(Pointer::Id in_uniqueId, f64 in_timestamp, const Vector2& in_newPosition);\n        //------------------------------------------------------------------------------\n        /// Notifies listeners that the pointer with the given unique id is up.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param in_uniqueId - The unique pointer Id.\n        /// @param in_timestamp - The timestamp.\n        /// @param in_inputType - The press type.\n        //------------------------------------------------------------------------------\n        void PointerUp(Pointer::Id in_uniqueId, f64 in_timestamp, Pointer::InputType in_inputType);\n        //------------------------------------------------------------------------------\n        /// Updates the pointer with the given unique id and notifies listeners that it\n        /// has scrolled.\n        ///\n        /// @author S Downie\n        ///\n        /// @param in_uniqueId - The unique pointer Id.\n        /// @param in_timestamp - The timestamp.\n        /// @param in_delta - The scroll delta.\n        //------------------------------------------------------------------------------\n        void PointerScrolled(Pointer::Id in_uniqueId, f64 in_timestamp, const Vector2& in_delta);\n        //------------------------------------------------------------------------------\n        /// Removes the pointer with the given Id.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param in_uniqueId - The unique pointer Id.\n        /// @param in_timestamp - The timestamp.\n        //------------------------------------------------------------------------------\n        void RemovePointer(Pointer::Id in_uniqueId, f64 in_timestamp);\n        \n        //---These are events used internally by the engine\n        //------------------------------------------------------------------------------\n        /// A delegate that is used to receive pointer down events. This could be\n        /// pressing a mouse button or touching a touch screen.\n        ///\n        /// Systems listening to this should check whether the event has already been\n        /// filtered prior to performing any action.\n        ///\n        /// Additionally, systems using this should also check whether they received\n        /// this event, unfiltered, prior to performing any action from a pointer moved\n        /// or pointer up event.\n        ///\n        /// @author S Downie\n        ///\n        /// @param in_pointer - The pointer.\n        /// @param in_timestamp - The timestamp of the event.\n        /// @param in_inputType - The input type.\n        /// @param in_filter - The filter.\n        //------------------------------------------------------------------------------\n        using PointerDownDelegateInternal = std::function<void(const Pointer& in_pointer, f64 in_timestamp, Pointer::InputType in_inputType, InputFilter& in_filter)>;\n        //------------------------------------------------------------------------------\n        /// A delegate that is used to receive pointer scroll events (i.e. mouse wheel).\n        ///\n        /// @author S Downie\n        ///\n        /// @param in_pointer - The pointer\n        /// @param in_timestamp - The timestamp of the event.\n        /// @param in_delta - The scroll vector (x, y delta)\n        /// @param in_filter - Filter\n        //------------------------------------------------------------------------------\n        using PointerScrollDelegateInternal = std::function<void(const Pointer& in_pointer, f64 in_timestamp, const Vector2& in_delta, InputFilter& in_filter)>;\n        //------------------------------------------------------------------------------\n        /// Event that is triggered when the pointer is first down.\n        ///\n        /// @author S Downie\n        ///\n        /// @return The pointer down event.\n        //------------------------------------------------------------------------------\n        IConnectableEvent<PointerDownDelegateInternal>& GetPointerDownEventInternal();\n        //------------------------------------------------------------------------------\n        /// Event that is triggered when the scroll wheel ticks.\n        ///\n        /// @author S Downie\n        ///\n        /// @return The event triggered on scroll change (i.e. mouse wheel scroll).\n        //------------------------------------------------------------------------------\n        IConnectableEvent<PointerScrollDelegateInternal>& GetPointerScrollEventInternal();\n        \n        Event<PointerAddedDelegate> m_pointerAddedEvent;\n        Event<PointerDownDelegate> m_pointerDownEvent;\n        Event<PointerMovedDelegate> m_pointerMovedEvent;\n        Event<PointerUpDelegate> m_pointerUpEvent;\n        Event<PointerScrollDelegate> m_pointerScrolledEvent;\n        Event<PointerRemovedDelegate> m_pointerRemovedEvent;\n        \n        Event<PointerDownDelegate> m_pointerDownEventFiltered;\n        Event<PointerUpDelegate> m_pointerUpEventFiltered;\n        Event<PointerScrollDelegate> m_pointerScrolledEventFiltered;\n        \n        Event<PointerDownDelegateInternal> m_pointerDownEventInternal;\n        Event<PointerScrollDelegateInternal> m_pointerScrolledEventInternal;\n        \n        std::mutex m_mutex;\n        std::vector<Pointer> m_pointers;\n        std::queue<PointerEvent> m_eventQueue;\n        Pointer::Id m_nextUniqueId;\n        \n        std::unordered_map<Pointer::Id, std::set<Pointer::InputType>> m_filteredPointerInput;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Input/Pointer.h",
    "content": "//\n//  Pointer.h\n//  ChilliSource\n//  Created by Ian Copland on 07/07/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n\n#ifndef _CHILLISOURCE_INPUT_POINTER_H_\n#define _CHILLISOURCE_INPUT_POINTER_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Input/Pointer/Pointer.h>\n#include <ChilliSource/Input/Pointer/PointerSystem.h>\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Input/TextEntry/TextEntry.cpp",
    "content": "//\n//  TextEntry.cpp\n//  ChilliSource\n//  Created by Scott Downie on 08/07/2014\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Input/TextEntry/TextEntry.h>\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n#include <CSBackend/Platform/Android/Main/JNI/Input/TextEntry/TextEntry.h>\n#endif\n\n#ifdef CS_TARGETPLATFORM_IOS\n#include <CSBackend/Platform/iOS/Input/TextEntry/TextEntry.h>\n#endif\n\n#ifdef CS_TARGETPLATFORM_WINDOWS\n#include <CSBackend/Platform/Windows/Input/TextEntry/TextEntry.h>\n#endif\n\n#ifdef CS_TARGETPLATFORM_RPI\n#include <CSBackend/Platform/RPi/Input/TextEntry/TextEntry.h>\n#endif\n\nnamespace ChilliSource\n{\n    CS_DEFINE_NAMEDTYPE(TextEntry);\n    \n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    TextEntryUPtr TextEntry::Create()\n    {\n#if defined CS_TARGETPLATFORM_ANDROID\n        return TextEntryUPtr(new CSBackend::Android::TextEntry());\n#elif defined CS_TARGETPLATFORM_IOS\n        return TextEntryUPtr(new CSBackend::iOS::TextEntry());\n#elif defined CS_TARGETPLATFORM_WINDOWS\n        return TextEntryUPtr(new CSBackend::Windows::TextEntry());\n#elif defined CS_TARGETPLATFORM_RPI\n        return TextEntryUPtr(new CSBackend::RPi::TextEntry());\n#else\n        return nullptr;\n#endif\n\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Input/TextEntry/TextEntry.h",
    "content": "//\n//  TextEntry.h\n//  ChilliSource\n//  Created by Scott Downie on 08/07/2014\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_INPUT_TEXTENTRY_TEXTENTRY_H_\n#define _CHILLISOURCE_INPUT_TEXTENTRY_TEXTENTRY_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/System/AppSystem.h>\n#include <ChilliSource/Input/TextEntry/TextEntryCapitalisation.h>\n#include <ChilliSource/Input/TextEntry/TextEntryType.h>\n\n#include <functional>\n\nnamespace ChilliSource\n{\n    //---------------------------------------------------------------\n    /// A system for receiving textual from both virtual and hardware\n    /// keyboards depending on the platform.\n    ///\n    /// @author S Downie\n    //---------------------------------------------------------------\n    class TextEntry : public AppSystem\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(TextEntry);\n        \n        //-------------------------------------------------------\n        /// A delegate used for recieving text input events.\n        ///\n        /// @author S Downie\n        ///\n        /// @param The new updated version of the text.\n        ///\n        /// @return Whether or not the change to the text\n        /// has been rejected.\n        //-------------------------------------------------------\n        typedef std::function<bool(const std::string&)> TextBufferChangedDelegate;\n        //-------------------------------------------------------\n        /// A delegate used for recieving events when input is disabled.\n        ///\n        /// @author S Downie\n        //-------------------------------------------------------\n        typedef std::function<void()> TextInputDeactivatedDelegate;\n        //-------------------------------------------------------\n        /// Factory method from creating a new platform specific\n        /// instance of the keyboard system.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @return The new instance of the system.\n        //-------------------------------------------------------\n        static TextEntryUPtr Create();\n        //-------------------------------------------------------\n        /// The system will now receive text input. This will also\n        /// show the virtual keyboard if required\n        ///\n        /// @author S Downie\n        ///\n        /// @param Initial buffer contents\n        /// @param Preferred keyboard type\n        /// @param Preferred capitalisation method\n        /// @param Text changed delegate\n        /// @param Deactivate delegate\n        //-------------------------------------------------------\n        virtual void Activate(const std::string& in_text, TextEntryType in_type, TextEntryCapitalisation in_capitalisation, const TextBufferChangedDelegate& in_changeDelegate, const TextInputDeactivatedDelegate& in_deactivateDelegate) = 0;\n        //-------------------------------------------------------\n        /// The system will no longer receive text input. This\n        /// will also hide the virtual keyboard if required\n        ///\n        /// @author S Downie\n        //-------------------------------------------------------\n        virtual void Deactivate() = 0;\n        //-------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Whether or not text input is currently\n        /// enabled.\n        //-------------------------------------------------------\n        virtual bool IsActive() const = 0;\n        //-------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return The current text input buffer (UTF-8).\n        //-------------------------------------------------------\n        virtual const std::string& GetTextBuffer() const = 0;\n        //-------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param The new text input buffer (UTF-8).\n        //-------------------------------------------------------\n        virtual void SetTextBuffer(const std::string& in_text) = 0;\n    };\n\n\n}\n\n#endif\n\n\n"
  },
  {
    "path": "Source/ChilliSource/Input/TextEntry/TextEntryCapitalisation.cpp",
    "content": "//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Input/TextEntry/TextEntryCapitalisation.h>\n#include <ChilliSource/Core/String/StringUtils.h>\n\nnamespace ChilliSource\n{\n    //-------------------------------------------------------------------\n    TextEntryCapitalisation ParseCapitalisationFormat(const std::string& string) noexcept\n    {\n        std::string capitalisationFormatString = string;\n        StringUtils::ToLowerCase(capitalisationFormatString);\n\n        if (capitalisationFormatString == \"none\")\n        {\n            return TextEntryCapitalisation::k_none;\n        }\n        else if (capitalisationFormatString == \"words\")\n        {\n            return TextEntryCapitalisation::k_words;\n        }\n        else if (capitalisationFormatString == \"sentences\")\n        {\n            return TextEntryCapitalisation::k_sentences;\n        }\n        else if (capitalisationFormatString == \"all\")\n        {\n            return TextEntryCapitalisation::k_all;\n        }\n\n        CS_LOG_FATAL(\"Invalid keyboard input type.\");\n        return TextEntryCapitalisation::k_sentences;\n    }\n}"
  },
  {
    "path": "Source/ChilliSource/Input/TextEntry/TextEntryCapitalisation.h",
    "content": "//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_INPUT_TEXTENTRY_TEXTENTRYCAPITALISATION_H_\n#define _CHILLISOURCE_INPUT_TEXTENTRY_TEXTENTRYCAPITALISATION_H_\n\n#include <ChilliSource/ChilliSource.h>\n\n#include <functional>\n\nnamespace ChilliSource\n{\n    /// An enum describing the various methods of keyboard\n    /// capitalisation that can be used.\n    ///\n    ///  - None: will not capitalise anything.\n    ///  - Words: will capitalise the first letter\n    ///\t   of each word.\n    ///  - Sentences: will capitalise the first letter\n    ///\t   of each sentence.\n    ///  - All: will capitalise every letter.\n    ///\n    enum class TextEntryCapitalisation\n    {\n        k_none,\n        k_words,\n        k_sentences,\n        k_all\n    };\n\n    /// Parses keyboard capitalisation method from a string.\n    ///\n    /// @param string\n    ///     The string.\n    ///\n    /// @return The capitalisation method.\n    ///\n    TextEntryCapitalisation ParseCapitalisationFormat(const std::string& string) noexcept;\n}\n\n#endif"
  },
  {
    "path": "Source/ChilliSource/Input/TextEntry/TextEntryType.cpp",
    "content": "//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Input/TextEntry/TextEntryType.h>\n#include <ChilliSource/Core/String/StringUtils.h>\n\nnamespace ChilliSource\n{\n    //-------------------------------------------------------------------\n    TextEntryType ParseKeyboardInputType(const std::string& string) noexcept\n    {\n        std::string keyboardInputString = string;\n        StringUtils::ToLowerCase(keyboardInputString);\n\n        StringUtils::ToLowerCase(keyboardInputString);\n\n        if (keyboardInputString == \"text\")\n        {\n            return TextEntryType::k_text;\n        }\n        else if (keyboardInputString == \"numeric\")\n        {\n            return TextEntryType::k_numeric;\n        }\n\n        CS_LOG_FATAL(\"Invalid keyboard input type.\");\n        return TextEntryType::k_text;\n    }\n}"
  },
  {
    "path": "Source/ChilliSource/Input/TextEntry/TextEntryType.h",
    "content": "//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_INPUT_TEXTENTRY_TEXTENTRYTYPE_H_\n#define _CHILLISOURCE_INPUT_TEXTENTRY_TEXTENTRYTYPE_H_\n\n#include <ChilliSource/ChilliSource.h>\n\n#include <functional>\n\nnamespace ChilliSource\n{\n    /// An enum describing the different types of keyboard.\n    ///\n    enum class TextEntryType\n    {\n        k_text,\n        k_numeric\n    };\n\n    /// Parses a keyboard type from a string.\n    ///\n    /// @param string\n    ///     The string.\n    ///\n    /// @return The keyboard input type\n    ///\n    TextEntryType ParseKeyboardInputType(const std::string& string) noexcept;\n}\n\n#endif"
  },
  {
    "path": "Source/ChilliSource/Input/TextEntry.h",
    "content": "//\n//  TextEntry.h\n//  ChilliSource\n//  Created by Scott Downie on 08/07/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n\n#ifndef _CHILLISOURCE_INPUT_TEXTENTRY_H_\n#define _CHILLISOURCE_INPUT_TEXTENTRY_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Input/TextEntry/TextEntry.h>\n#include <ChilliSource/Input/TextEntry/TextEntryCapitalisation.h>\n#include <ChilliSource/Input/TextEntry/TextEntryType.h>\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Networking/ContentDownload/ContentManagementSystem.cpp",
    "content": "//\n//  ContentManagementSystem.cpp\n//  ChilliSource\n//  Created by Scott Downie on 04/07/2011.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2011 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Networking/ContentDownload/ContentManagementSystem.h>\n\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/Container/VectorUtils.h>\n#include <ChilliSource/Core/Delegate/MakeDelegate.h>\n#include <ChilliSource/Core/Cryptographic/BaseEncoding.h>\n#include <ChilliSource/Core/Cryptographic/HashMD5.h>\n#include <ChilliSource/Core/File/FileSystem.h>\n#include <ChilliSource/Core/File/AppDataStore.h>\n#include <ChilliSource/Core/String/StringUtils.h>\n#include <ChilliSource/Core/Threading/TaskScheduler.h>\n\n#include <minizip/unzip.h>\n\nnamespace ChilliSource\n{\n    namespace\n    {\n        const char k_adsKeyHasCached[] = \"_CMSCachedDLC\";\n        const char k_tempDirectory[] = \"_Temp-CMS/\";\n        const char k_manifestFile[] = \"ContentManifest.moman\";\n        const char k_tempDownloadedManifestFile[] = \"DownloadedContentManifestTemp.moman\";\n        const char k_tempManifestFile[] = \"ContentManifestTemp.moman\";\n        const char k_packageExtension[] = \"packzip\";\n        const char k_packageExtensionFull[] = \".packzip\";\n        \n        const std::string k_tempManifestFilePath = std::string(k_tempDirectory) + k_tempManifestFile;\n        \n        //--------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param A filepath.\n        ///\n        /// @return Whether or not the given path contains a\n        /// directory path.\n        //--------------------------------------------------------\n        bool ContainsDirectoryPath(const std::string& instrPath)\n        {\n            return (instrPath.find_first_of(\"/\") != std::string::npos);\n        }\n        //--------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param A filepath.\n        ///\n        /// @return Whether or not the filepath points to a file.\n        //--------------------------------------------------------\n        bool IsFile(const std::string& instrPath)\n        {\n            return (instrPath.find_first_of(\".\") != std::string::npos);\n        }\n        //--------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param A filepath.\n        ///\n        /// @return The path of the directory the file is contained\n        /// in.\n        //--------------------------------------------------------\n        std::string GetPathExcludingFileName(const std::string& instrPath)\n        {\n            auto udwOffset = instrPath.find_last_of(\"/\");\n            if(udwOffset != std::string::npos)\n            {\n                return instrPath.substr(0, udwOffset);\n            }\n            \n            return \"\";\n        }\n        //-----------------------------------------------------------\n        /// Writes a checksum safe version of a manifest xml to path\n        /// i.e. Will remove the Timestamp key from the manifest\n        /// before saving, to ensure checksum correctness with any\n        /// new manifests downloaded later\n        ///\n        /// @author HMcLaughlin\n        ///\n        /// @param in_manifestDoc - Original Manifest XML Document\n        /// @param in_filePath - File path to save to\n        ///\n        /// @return If the saving was successful\n        //-----------------------------------------------------------\n        bool SaveTempManifest(const XML::Document* in_manifestDoc, const std::string& in_filePath)\n        {\n            //Clone the manifest before we modify it\n            auto xmlString = XMLUtils::ToString(in_manifestDoc);\n            auto doc = XMLUtils::ParseDocument(xmlString);\n            \n            //Remove the TimeStamp attribute as it interferes with the checksum comparison\n            auto manifestNode = doc->GetDocument()->first_node();\n            if(manifestNode)\n            {\n                for(rapidxml::xml_attribute<>* attribute = manifestNode->first_attribute(); attribute != nullptr; attribute = attribute->next_attribute())\n                {\n                    if (XMLUtils::GetName(attribute) == \"Timestamp\")\n                    {\n                        manifestNode->remove_attribute(attribute);\n                        break;\n                    }\n                }\n            }\n            \n            return XMLUtils::WriteDocument(doc->GetDocument(), StorageLocation::k_DLC, in_filePath);\n        }\n        //-----------------------------------------------------------\n        /// Deletes a directory from the DLC Storage Location.\n        ///\n        /// @author S Downie\n        //-----------------------------------------------------------\n        void DeleteDirectory(const std::string& in_directory)\n        {\n            Application::Get()->GetFileSystem()->DeleteDirectory(StorageLocation::k_DLC, in_directory);\n        }\n        //-----------------------------------------------------------\n        /// Clears the temp download folder\n        ///\n        /// @author HMcLaughlin\n        //-----------------------------------------------------------\n        void ClearTempDownloadFolder()\n        {\n            DeleteDirectory(k_tempDirectory);\n        }\n    }\n    \n    CS_DEFINE_NAMEDTYPE(ContentManagementSystem);\n    //--------------------------------------------------------\n    //--------------------------------------------------------\n    ContentManagementSystemUPtr ContentManagementSystem::Create(IContentDownloader* in_contentDownloader)\n    {\n        return ContentManagementSystemUPtr(new ContentManagementSystem(in_contentDownloader));\n    }\n    //-----------------------------------------------------------\n    //-----------------------------------------------------------\n    ContentManagementSystem::ContentManagementSystem(IContentDownloader* in_contentDownloader)\n    :m_contentDownloader(in_contentDownloader)\n    ,m_serverManifest(nullptr)\n    {\n    }\n    //------------------------------------------------------------\n    //-----------------------------------------------------------\n    void ContentManagementSystem::OnInit()\n    {\n        m_contentDirectory = Application::Get()->GetFileSystem()->GetAbsolutePathToStorageLocation(StorageLocation::k_DLC);\n    }\n    //-----------------------------------------------------------\n    //-----------------------------------------------------------\n    bool ContentManagementSystem::IsA(InterfaceIDType in_interfaceId) const\n    {\n        return in_interfaceId == ContentManagementSystem::InterfaceID;\n    }\n    //-----------------------------------------------------------\n    //-----------------------------------------------------------\n    XMLUPtr ContentManagementSystem::LoadLocalManifest()\n    {\n        //The manifest lives in the documents directory\n        XMLUPtr xml = XMLUtils::ReadDocument(StorageLocation::k_DLC, k_manifestFile);\n        if (xml != nullptr && xml->GetDocument() != nullptr)\n        {\n            XML::Node* rootNode = XMLUtils::GetFirstChildElement(xml->GetDocument());\n            \n            //If there is no DLC we should check to see if there ever was any\n            AppDataStore* ads = Application::Get()->GetSystem<AppDataStore>();\n            if(rootNode == nullptr && ads->Contains(k_adsKeyHasCached) == true)\n            {\n                m_dlcCachePurged = true;\n            }\n        }\n        return xml;\n    }\n    //-----------------------------------------------------------\n    //-----------------------------------------------------------\n    std::string ContentManagementSystem::GetManifestChecksumForFile(const std::string& in_filename) const\n    {\n        return CalculateChecksum(StorageLocation::k_DLC, in_filename);\n    }\n    //-----------------------------------------------------------\n    //-----------------------------------------------------------\n    std::string ContentManagementSystem::CalculateChecksum(StorageLocation in_location, const std::string& in_filePath) const\n    {\n        if(m_checksumDelegate)\n        {\n            // Custom checksum calculation\n            return m_checksumDelegate(in_location, in_filePath);\n        }\n        \n#ifdef CS_USE_SHA1_CHECKSUMS\n        std::string checksum = Application::Get()->GetFileSystem()->GetFileChecksumSHA1(in_location, in_filePath);\n#else\n        std::string checksum = Application::Get()->GetFileSystem()->GetFileChecksumSHA256(in_location, in_filePath);\n#endif\n        StringUtils::ToLowerCase(checksum);\n        std::string base64Encoded = BaseEncoding::Base64Encode(checksum);\n        StringUtils::ChopTrailingChars(base64Encoded, '=');\n        return base64Encoded;\n    }\n    //-----------------------------------------------------------\n    //-----------------------------------------------------------\n    void ContentManagementSystem::ClearDownloadData()\n    {\n        //Clear the old crap\n        m_serverManifest.reset();\n        m_removePackageIds.clear();\n        m_packageDetails.clear();\n        m_cachedPackageDetails.clear();\n    }\n    //-----------------------------------------------------------\n    //-----------------------------------------------------------\n    void ContentManagementSystem::CheckForUpdates(const ContentManagementSystem::CheckForUpdateDelegate& in_delegate)\n    {\n        CS_RELEASE_ASSERT(Application::Get()->GetTaskScheduler()->IsMainThread() == true, \"This can only be called on the main thread.\");\n        \n        //Clear any stale data from last update check\n        ClearDownloadData();\n        \n        m_onUpdateCheckCompleteDelegate = in_delegate;\n        \n        //Have the downloader request the manifest in its own way\n        m_contentDownloader->DownloadContentManifest(MakeDelegate(this, &ContentManagementSystem::OnContentManifestDownloadComplete));\n    }\n    //-----------------------------------------------------------\n    //-----------------------------------------------------------\n    void ContentManagementSystem::DownloadUpdates(const ContentManagementSystem::CompleteDelegate& in_delegate, const DownloadProgressDelegate& in_progressDelegate)\n    {\n        CS_RELEASE_ASSERT(Application::Get()->GetTaskScheduler()->IsMainThread() == true, \"This can only be called on the main thread.\");\n        \n        CS_ASSERT(!m_downloadInProgress, \"Cannot call DownloadUpdates while updates are being downloaded!\");\n\n        m_onDownloadCompleteDelegate = in_delegate;\n        m_onDownloadProgressDelegate = in_progressDelegate;\n        \n        m_currentPackageDownload = 0;\n        m_downloadInProgress = true;\n\n        if(!m_packageDetails.empty())\n        {\n            //Add a temp directory so that the packages are stored atomically and only overwrite\n            //the originals on full success\n            Application::Get()->GetFileSystem()->CreateDirectoryPath(StorageLocation::k_DLC, k_tempDirectory);\n            DownloadPackage(m_currentPackageDownload);\n        }\n        else\n        {\n            m_downloadInProgress = false;\n            m_onDownloadCompleteDelegate(Result::k_succeeded);\n        }\n    }\n    //-----------------------------------------------------------\n    //-----------------------------------------------------------\n    void ContentManagementSystem::DownloadNextPackage()\n    {\n        m_currentPackageDownload++;\n        DownloadPackage(m_currentPackageDownload);\n    }\n    //-----------------------------------------------------------\n    //-----------------------------------------------------------\n    void ContentManagementSystem::DownloadPackage(u32 in_packageIndex, bool in_checkCached)\n    {\n        CS_ASSERT(in_packageIndex < m_packageDetails.size(), \"Package index out of range\");\n        \n        const auto& package = m_packageDetails[in_packageIndex];\n        bool existsInCache = VectorUtils::Contains<PackageDetails>(m_cachedPackageDetails, package);\n        \n        if(in_checkCached && existsInCache)\n        {\n            //We call the progress function for this index\n            OnContentDownloadProgress(package.m_url, 1.0f);\n            \n            m_runningDownloadedTotal += package.m_size;\n            \n            //Check if this is the last download\n            if(in_packageIndex >= (m_packageDetails.size() - 1))\n            {\n                m_downloadInProgress = false;\n                m_onDownloadCompleteDelegate(Result::k_succeeded);\n            }\n            else\n            {\n                //Else move on to next package\n                DownloadNextPackage();\n            }\n        }\n        else\n        {\n            m_contentDownloader->DownloadPackage(package.m_url, MakeDelegate(this, &ContentManagementSystem::OnContentDownloadComplete),\n                                                 MakeDelegate(this, &ContentManagementSystem::OnContentDownloadProgress));\n        }\n    }\n    //-----------------------------------------------------------\n    //-----------------------------------------------------------\n    void ContentManagementSystem::InstallUpdates(const CompleteDelegate& inDelegate)\n    {\n        CS_RELEASE_ASSERT(Application::Get()->GetTaskScheduler()->IsMainThread() == true, \"This can only be called on the main thread.\");\n        \n        if(!m_packageDetails.empty() || !m_removePackageIds.empty())\n        {\n            if(!m_packageDetails.empty())\n            {\n                //Unzip all the files and overwrite the old manifest\n                for (const auto& details : m_packageDetails)\n                {\n                    ExtractFilesFromPackage(details);\n                }\n            }\n            \n            //Remove the temp zips\n            ClearTempDownloadFolder();\n            \n            m_packageDetails.clear();\n        \n            if(!m_removePackageIds.empty())\n            {\n                //Remove any unused files from the documents\n                for (const auto& packageId : m_removePackageIds)\n                {\n                    DeleteDirectory(packageId);\n                }\n            }\n            \n            //Save the new content manifest\n            XMLUtils::WriteDocument(m_serverManifest->GetDocument(), StorageLocation::k_DLC, k_manifestFile);\n            \n            m_dlcCachePurged = false;\n            \n            //Store that we have DLC cached. If there is no DLC on next check then \n            //we know the cache has been purged and we have to block on download\n            AppDataStore* ads = Application::Get()->GetSystem<AppDataStore>();\n            ads->SetValue(k_adsKeyHasCached, true);\n            \n            //Tell the delegate all is good\n            inDelegate(Result::k_succeeded);\n        }\n        else\n        {\n            //Tell the delegate all is bad\n            inDelegate(Result::k_failed);\n        }\n        \n        ClearDownloadData();\n    }\n    //-----------------------------------------------------------\n    //-----------------------------------------------------------\n    void ContentManagementSystem::OnContentManifestDownloadComplete(IContentDownloader::Result in_result, const std::string& in_manifest)\n    {\n        switch(in_result)\n        {\n            case IContentDownloader::Result::k_succeeded:\n                m_serverManifestData += in_manifest;\n                BuildDownloadList(m_serverManifestData);\n                m_serverManifestData.clear();\n                break;\n            case IContentDownloader::Result::k_failed:\n                m_serverManifestData.clear();\n                m_dlcCachePurged ? m_onUpdateCheckCompleteDelegate(CheckForUpdatesResult::k_checkFailedBlocking) : m_onUpdateCheckCompleteDelegate(CheckForUpdatesResult::k_checkFailed);\n                break;\n            case IContentDownloader::Result::k_flushed:\n                m_serverManifestData += in_manifest;\n                break;\n        };\n        \n        if(in_result != IContentDownloader::Result::k_flushed)\n        {\n            //Reset the listener\n            m_onUpdateCheckCompleteDelegate = nullptr;\n        }\n    }\n    //-----------------------------------------------------------\n    //-----------------------------------------------------------\n    void ContentManagementSystem::OnContentDownloadComplete(IContentDownloader::Result in_result, const std::string& in_data)\n    {\n        switch(in_result)\n        {\n            case IContentDownloader::Result::k_succeeded:\n            {\n                if(SavePackageToFile(m_packageDetails[m_currentPackageDownload], in_data, true))\n                {\n                    m_runningDownloadedTotal += m_packageDetails[m_currentPackageDownload].m_size;\n                    \n                    //Don't overwrite the old manifest until all the content has been downloaded \n                    if(m_currentPackageDownload >= (m_packageDetails.size() - 1))\n                    {\n                        m_downloadInProgress = false;\n                        m_onDownloadCompleteDelegate(Result::k_succeeded);\n                    }\n                    else\n                    {\n                        DownloadNextPackage();\n                    }\n                    \n                    break;\n                }\n            }\n            case IContentDownloader::Result::k_failed:\n            {\n                if(m_onDownloadCompleteDelegate)\n                {\n                    m_downloadInProgress = false;\n                    m_onDownloadCompleteDelegate(Result::k_failed);\n                }\n                break;\n            }\n            case IContentDownloader::Result::k_flushed:\n            {\n                SavePackageToFile(m_packageDetails[m_currentPackageDownload], in_data, false);\n                break;\n            }\n        }\n    }\n    //-----------------------------------------------------------\n    //-----------------------------------------------------------\n    void ContentManagementSystem::BuildDownloadList(const std::string& in_serverManifest)\n    {\n        //Validate the server manifest\n        m_serverManifest = XMLUtils::ParseDocument(in_serverManifest);\n        \n        XML::Node* serverManifestRootNode = XMLUtils::GetFirstChildElement(m_serverManifest->GetDocument());\n        if(serverManifestRootNode == nullptr)\n        {\n            CS_LOG_ERROR(\"CMS: Server content manifest is invalid\");\n            if(m_dlcCachePurged)\n            {\n                m_onUpdateCheckCompleteDelegate(CheckForUpdatesResult::k_checkFailedBlocking);\n            }\n            else\n            {\n                m_onUpdateCheckCompleteDelegate(CheckForUpdatesResult::k_checkFailed);\n            }\n\n            return;\n        }\n        \n        //Check if DLC is enabled\n        if(!XMLUtils::GetAttributeValue<bool>(serverManifestRootNode, \"DLCEnabled\", false))\n        {\n            m_onUpdateCheckCompleteDelegate(CheckForUpdatesResult::k_notAvailable);\n            return;\n        }\n        \n        XMLUPtr currentManifest = LoadLocalManifest();\n        \n        //If we have not successfully loaded a manifest from file we need to check if any of the assets \n        //are in the bundle and pull down the others\n        if(currentManifest == nullptr || XMLUtils::GetFirstChildElement(currentManifest->GetDocument()) == nullptr)\n        {\n            //Grab all the URL's from the new manifest\n            \n            XML::Node* serverPackageEl = XMLUtils::GetFirstChildElement(serverManifestRootNode, \"Package\");\n            \n            while(serverPackageEl)\n            {\n                //If the package is not in the bundle it will download\n                AddToDownloadListIfNotInBundle(serverPackageEl);\n                \n                //On to the next package\n                serverPackageEl = XMLUtils::GetNextSiblingElement(serverPackageEl, \"Package\");\n            }\n        }\n        //Lets find out what we need already have in the manifest\n        else\n        {\n            std::unordered_map<std::string, std::string> mapPackageIDToChecksum;\n            \n            //Store the data from the local manifest to make a comparison with the server manifest\n            XML::Node* currentRoot = XMLUtils::GetFirstChildElement(currentManifest->GetDocument());\n            if(currentRoot != nullptr)\n            {\n                //Loop round \n                XML::Node* pLocalPackageEl = XMLUtils::GetFirstChildElement(currentRoot, \"Package\");\n                while(pLocalPackageEl)\n                {\n                    //Store the local ID's and checksums for comparison later\n                    std::string strLocalPackageID = XMLUtils::GetAttributeValue<std::string>(pLocalPackageEl, \"ID\", \"\");\n                    std::string strLocalPackageChecksum = XMLUtils::GetAttributeValue<std::string>(pLocalPackageEl, \"Checksum\", \"\");\n                    \n                    mapPackageIDToChecksum.insert(std::make_pair(strLocalPackageID, strLocalPackageChecksum));\n                    \n                    //On to the next package\n                    pLocalPackageEl = XMLUtils::GetNextSiblingElement(pLocalPackageEl, \"Package\");\n                }\n            }\n            \n            //Now process the server manifest and see whats different between the two\n            XML::Node* pServerPackageEl = XMLUtils::GetFirstChildElement(serverManifestRootNode, \"Package\");\n            while(pServerPackageEl)\n            {\n                //Store the local ID's and checksums for comparison later\n                std::string strServerPackageID = XMLUtils::GetAttributeValue<std::string>(pServerPackageEl, \"ID\", \"\");\n                std::string strServerPackageChecksum = XMLUtils::GetAttributeValue<std::string>(pServerPackageEl, \"Checksum\", \"\");\n                std::string strMinVersionForPackage = XMLUtils::GetAttributeValue<std::string>(pServerPackageEl, \"MinVersion\", \"\");\n                \n                std::unordered_map<std::string, std::string>::iterator it = mapPackageIDToChecksum.find(strServerPackageID);\n            \n                //Based on the state of the file decide whether it needs updating\n                if(it != mapPackageIDToChecksum.end())\n                {\n                    //The package exists in the documents directory\n                    if(it->second != strServerPackageChecksum)\n                    {\n                        //The package in documents is outdated lets check if the files all exist in the bundle\n                        //that way we don't need to download\n                        AddToDownloadListIfNotInBundle(pServerPackageEl);                            \n                    }\n                    else\n                    {\n                        //The checksum in the local manifest matches that on the\n                        //server but the file may have been altered locally\n                        //Check if the files within are corrupt\n                        //Check all the file names\n                        XML::Node* pFileEl = XMLUtils::GetFirstChildElement(pServerPackageEl, \"File\");\n                        while(pFileEl)\n                        {\n                            std::string strFullPath = XMLUtils::GetAttributeValue<std::string>(pFileEl, \"Location\", \"\");\n                            std::string strChecksum = XMLUtils::GetAttributeValue<std::string>(pFileEl, \"Checksum\", \"\");\n                            \n                            if(strFullPath.empty()) //Maintain backwards compatability with old versions\n                            {\n                                std::string strFileName = XMLUtils::GetAttributeValue<std::string>(pFileEl, \"Name\", \"\");\n                                strFullPath = strServerPackageID + \"/\" + strFileName;\n                            }\n                            \n                            if(!DoesFileExist(strFullPath, strChecksum, false))\n                            {\n                                std::string strPackageUrl = XMLUtils::GetAttributeValue<std::string>(pServerPackageEl, \"URL\", \"\");\n                                u32 udwPackageSize = XMLUtils::GetAttributeValue<u32>(pServerPackageEl, \"Size\", 0);\n                                m_runningToDownloadTotal += udwPackageSize;\n\n                                PackageDetails packageDetails;\n                                packageDetails.m_id = strServerPackageID;\n                                packageDetails.m_url = strPackageUrl;\n                                packageDetails.m_checksum = strServerPackageChecksum;\n                                packageDetails.m_size = udwPackageSize;\n                                m_packageDetails.push_back(packageDetails);\n                                break;\n                            }\n                            \n                            pFileEl = XMLUtils::GetNextSiblingElement(pFileEl, \"File\");\n                        }\n                    }\n                    \n                    mapPackageIDToChecksum.erase(it);\n                }\n                else\n                {\n                    //Couldn't find the package in the local manifest if it isn't\n                    //in the bundle then we need to download it\n                    AddToDownloadListIfNotInBundle(pServerPackageEl);\n                }\n                \n                //On to the next package\n                pServerPackageEl = XMLUtils::GetNextSiblingElement(pServerPackageEl, \"Package\");\n            }\n           \n            //Any packages left in the local manifest need to be removed\n            for(std::unordered_map<std::string, std::string>::iterator it = mapPackageIDToChecksum.begin(); it != mapPackageIDToChecksum.end(); ++it)\n            {\n                m_removePackageIds.push_back(it->first);\n            }\n        }\n        \n        //Notify the delegate of our completion and whether the need to update anything\n        bool bRequiresUpdating = (!m_removePackageIds.empty() || !m_packageDetails.empty());\n        \n        if(bRequiresUpdating)\n        {\n            RefreshIncompleteDownloadInfo();\n        }\n        \n        if(bRequiresUpdating && m_dlcCachePurged)\n        {\n            m_onUpdateCheckCompleteDelegate(CheckForUpdatesResult::k_availableBlocking);\n        }\n        else if(bRequiresUpdating && !m_dlcCachePurged)\n        {\n            m_onUpdateCheckCompleteDelegate(CheckForUpdatesResult::k_available);\n        }\n        else\n        {\n            m_onUpdateCheckCompleteDelegate(CheckForUpdatesResult::k_notAvailable);\n        }\n    }\n    //-----------------------------------------------------------\n    //-----------------------------------------------------------\n    void ContentManagementSystem::AddToDownloadListIfNotInBundle(XML::Node* in_packageEl)\n    {\n        //Check all the file names\n        XML::Node* pFileEl = XMLUtils::GetFirstChildElement(in_packageEl, \"File\");\n        while(pFileEl)\n        {\n            const std::string& strFileName = XMLUtils::GetAttributeValue<std::string>(pFileEl, \"Name\", \"\");\n            const std::string& strLocation = XMLUtils::GetAttributeValue<std::string>(pFileEl, \"Location\", \"\");\n            const std::string& strChecksum = XMLUtils::GetAttributeValue<std::string>(pFileEl, \"Checksum\", \"\");\n            const std::string& strPackageID = XMLUtils::GetAttributeValue<std::string>(in_packageEl, \"ID\", \"\");\n            \n            std::string filePath = strLocation.empty() ? strPackageID + \"/\" + strFileName : strLocation;\n            if(!DoesFileExist(filePath, strChecksum, true))\n            {\n                //It doesn't exist in the bundle either!\n                std::string strPackageUrl = XMLUtils::GetAttributeValue<std::string>(in_packageEl, \"URL\", \"\");\n                std::string strPackageChecksum = XMLUtils::GetAttributeValue<std::string>(in_packageEl, \"Checksum\", \"\");\n                \n                u32 udwPackageSize = XMLUtils::GetAttributeValue<u32>(in_packageEl, \"Size\", 0);\n                m_runningToDownloadTotal += udwPackageSize;\n                \n                PackageDetails packageDetails;\n                packageDetails.m_id = strPackageID;\n                packageDetails.m_url = strPackageUrl;\n                packageDetails.m_checksum = strPackageChecksum;\n                packageDetails.m_size = udwPackageSize;\n                m_packageDetails.push_back(packageDetails);\n                //It doesn't matter if all the other files exist we need to pull down this package anyway\n                break;\n            }\n            else\n            {\n                //It exists in the bundle let's remove the old version from DLC cache\n                //Remove old content\n                Application::Get()->GetFileSystem()->DeleteFile(StorageLocation::k_DLC, filePath);\n                \n                //On to the next file\n                pFileEl = XMLUtils::GetNextSiblingElement(pFileEl, \"File\");\n            }\n        }\n    }\n    //-----------------------------------------------------------\n    //-----------------------------------------------------------\n    bool ContentManagementSystem::SavePackageToFile(const PackageDetails& in_packageDetails, const std::string& in_zippedPackage, bool in_fullyDownloaded)\n    {\n        std::string strFile = k_tempDirectory + in_packageDetails.m_id + k_packageExtensionFull;\n\n        //Append to the file as it can take multiple writes\n        auto pFileStream = Application::Get()->GetFileSystem()->CreateBinaryOutputStream(StorageLocation::k_DLC, strFile, CS::FileWriteMode::k_append);\n        if (pFileStream == nullptr)\n        {\n            CS_LOG_ERROR(\"CMS: \" + in_packageDetails.m_id + \" Couldn't write package.\");\n            return false;\n        }\n\n        pFileStream->Write(reinterpret_cast<const u8*>(in_zippedPackage.data()), (s32)in_zippedPackage.size());\n        pFileStream.reset();\n        \n        //Check if the full file has been written and perform a checksum validation \n        if(in_fullyDownloaded)\n        {\n            std::string strChecksum = CalculateChecksum(StorageLocation::k_DLC, strFile);\n            if(strChecksum != in_packageDetails.m_checksum)\n            {\n                CS_LOG_ERROR(\"CMS: \" + in_packageDetails.m_id + \" Package download corrupted\");\n                return false;\n            }\n        }\n        \n        return true;\n    }\n\n    //-----------------------------------------------------------\n    //-----------------------------------------------------------\n    void ContentManagementSystem::ExtractFilesFromPackage(const ContentManagementSystem::PackageDetails& in_packageDetails) const\n    {\n        //Open zip\n        std::string strZipFilePath(m_contentDirectory + \"/\" + k_tempDirectory + in_packageDetails.m_id + k_packageExtensionFull);\n        \n        unzFile ZippedFile = unzOpen(strZipFilePath.c_str());\n        if(!ZippedFile)\n        {\n            CS_LOG_ERROR(\"CMS: Cannot unzip content package: \" + in_packageDetails.m_id);\n            return;\n        }\n\n        //Remove old content before installing the new stuff\n        DeleteDirectory(in_packageDetails.m_id);\n        \n        //Go to the first file in the zip\n        const u64 uddwFilenameLength = 256;\n        s8 byaFileName[uddwFilenameLength];\n        \n        s32 dwStatus = unzGoToFirstFile(ZippedFile);\n        \n        while(dwStatus == UNZ_OK)\n        {\n            //Open the next file\n            if (unzOpenCurrentFile(ZippedFile) != UNZ_OK)\n                break;\n            \n            //Get file information\n            unz_file_info FileInfo;\n            unzGetCurrentFileInfo(ZippedFile, &FileInfo, byaFileName, uddwFilenameLength, nullptr, 0, nullptr, 0);\n            CS_ASSERT(FileInfo.uncompressed_size < static_cast<uLong>(std::numeric_limits<u32>::max()), \"File is too large. It cannot exceed \" + ToString(std::numeric_limits<u32>::max()) + \" bytes.\");\n            \n            //Load the file into memory and then save it out to the directory\n            s8* pbyDataBuffer =  new s8[FileInfo.uncompressed_size];\n            unzReadCurrentFile(ZippedFile, pbyDataBuffer, static_cast<unsigned>(FileInfo.uncompressed_size));\n            \n            //Create new stuff\n            std::string strFilePath = std::string(byaFileName);\n            if(ContainsDirectoryPath(strFilePath))\n            {\n                //There is a nested folder so we need to create the directory structure\n                std::string strPath = GetPathExcludingFileName(strFilePath);\n                Application::Get()->GetFileSystem()->CreateDirectoryPath(StorageLocation::k_DLC, \"/\" + strPath);\n            }\n            \n            if(IsFile(strFilePath))\n            {\n                Application::Get()->GetFileSystem()->WriteFile(StorageLocation::k_DLC, \"/\" + strFilePath, pbyDataBuffer, static_cast<u32>(FileInfo.uncompressed_size));\n            }\n            \n            //Close current file and jump to the next\n            CS_SAFEDELETE_ARRAY(pbyDataBuffer);\n            unzCloseCurrentFile(ZippedFile);\n            dwStatus = unzGoToNextFile(ZippedFile);\n        }\n        \n        //Close the zip\n        unzClose(ZippedFile);\n    }\n    //-----------------------------------------------------------\n    //-----------------------------------------------------------\n    u32 ContentManagementSystem::GetRunningTotalToDownload() const\n    {\n        return m_runningToDownloadTotal;\n    }\n    //-----------------------------------------------------------\n    //-----------------------------------------------------------\n    u32 ContentManagementSystem::GetRunningTotalDownloaded() const\n    {\n        return m_runningDownloadedTotal;\n    }\n    //-----------------------------------------------------------\n    //-----------------------------------------------------------\n    IContentDownloader* ContentManagementSystem::GetContentDownloader() const\n    {\n        return m_contentDownloader;\n    }\n    //-----------------------------------------------------------\n    //-----------------------------------------------------------\n    void ContentManagementSystem::SetChecksumDelegate(const ChecksumDelegate& in_delegate)\n    {\n        m_checksumDelegate = in_delegate;\n    }\n    //-----------------------------------------------------------\n    //-----------------------------------------------------------\n    bool ContentManagementSystem::DoesFileExist(const std::string& in_filename, const std::string in_checksum, bool in_checkOnlyBundle) const\n    {\n        if(in_checkOnlyBundle)\n        {\n            if(Application::Get()->GetFileSystem()->DoesFileExist(StorageLocation::k_package, Application::Get()->GetFileSystem()->GetPackageDLCPath() + in_filename))\n            {\n                //Check if the file has become corrupted\n                return (CalculateChecksum(StorageLocation::k_package, Application::Get()->GetFileSystem()->GetPackageDLCPath() + in_filename) == in_checksum);\n            }\n            \n            return false;\n        }\n        else\n        {\n            if(Application::Get()->GetFileSystem()->DoesFileExist(StorageLocation::k_DLC, in_filename))\n            {\n                //Check if the file has become corrupted\n                return (CalculateChecksum(StorageLocation::k_DLC, in_filename) == in_checksum);\n            }\n            \n            return false;\n        }\n    }\n    //-----------------------------------------------------------\n    //-----------------------------------------------------------\n    void ContentManagementSystem::OnContentDownloadProgress(const std::string& in_url, f32 in_progress)\n    {\n        if(m_onDownloadProgressDelegate)\n        {\n            CS_ASSERT(m_packageDetails.size() > m_currentPackageDownload,\n                      \"Current package index out of range - \" + ToString(m_currentPackageDownload) + \", \" + ToString((u32)m_packageDetails.size()));\n            \n            f32 increment = 1.0f / m_packageDetails.size();\n            f32 totalProgress = m_currentPackageDownload * increment + (in_progress * increment);\n            \n            m_onDownloadProgressDelegate(m_packageDetails[m_currentPackageDownload].m_id, totalProgress);\n        }\n    }\n    //-----------------------------------------------------------\n    //-----------------------------------------------------------\n    void ContentManagementSystem::RefreshIncompleteDownloadInfo()\n    {\n        //Check if the temp file exists before writing it, if it does then we are resuming\n        if(!Application::Get()->GetFileSystem()->DoesFileExist(StorageLocation::k_DLC, k_tempManifestFilePath))\n        {\n            Application::Get()->GetFileSystem()->CreateDirectoryPath(StorageLocation::k_DLC, k_tempDirectory);\n            \n            //Save the temperary manifest for resuming later\n            SaveTempManifest(m_serverManifest->GetDocument(), k_tempManifestFilePath);\n        }\n        else\n        {\n            const std::string tempDownloadedContentPath = std::string(k_tempDirectory) + k_tempDownloadedManifestFile;\n            \n            //We need to compare checksums to see if the downloaded one is different from the cached one\n            SaveTempManifest(m_serverManifest->GetDocument(), tempDownloadedContentPath);\n            \n            const std::string downloadedChecksum = CalculateChecksum(StorageLocation::k_DLC, tempDownloadedContentPath);\n            const std::string cachedChecksum = CalculateChecksum(StorageLocation::k_DLC, k_tempManifestFilePath);\n            \n            //Manifests are different, clear the temperary folder\n            if(downloadedChecksum != cachedChecksum)\n            {\n                //We should purge the cache\n                ClearTempDownloadFolder();\n            }\n            else\n            {\n                //Verify and store a list of already downloaded packages\n                VerifyTemporaryDownloads(k_tempManifestFilePath);\n            }\n        }\n    }\n    //-----------------------------------------------------------\n    //-----------------------------------------------------------\n    void ContentManagementSystem::VerifyTemporaryDownloads(const std::string& in_manifestPath)\n    {\n        auto manifest = XMLUtils::ReadDocument(StorageLocation::k_DLC, in_manifestPath);\n        XML::Node* manifestRootNode = XMLUtils::GetFirstChildElement(m_serverManifest->GetDocument());\n        \n        auto tempPackageFiles = Application::Get()->GetFileSystem()->GetFilePathsWithExtension(StorageLocation::k_DLC, k_tempDirectory, false, k_packageExtension);\n        \n        const XML::Node* serverPackageEl = XMLUtils::GetFirstChildElement(manifestRootNode, \"Package\");\n        \n        std::vector<ContentManagementSystem::PackageDetails> alreadyCachedPackages;\n        \n        while(serverPackageEl && (tempPackageFiles.size() != alreadyCachedPackages.size()))\n        {\n            //Check if this is the one were after\n            auto id = XMLUtils::GetAttributeValue<std::string>(serverPackageEl, \"ID\", \"\");\n            CS_ASSERT(!id.empty(), \"Cannot be empty!\");\n            \n            //Go through all packages and verify\n            for(const auto& packageName : tempPackageFiles)\n            {\n                std::string name;\n                std::string extension;\n                \n                StringUtils::SplitBaseFilename(packageName, name, extension);\n                \n                if(id == name)\n                {\n                    //Validate the file\n                    std::string cachedFilePath = k_tempDirectory + packageName;\n                    \n                    std::string cachedFileChecksum = CalculateChecksum(StorageLocation::k_DLC, cachedFilePath);\n                    std::string expectedChecksum = XMLUtils::GetAttributeValue<std::string>(serverPackageEl, \"Checksum\", \"\");\n                    CS_ASSERT(!expectedChecksum.empty(), \"Cannot be empty!\");\n                    \n                    if(cachedFileChecksum == expectedChecksum)\n                    {\n                        //Add a validated package\n                        std::string url = XMLUtils::GetAttributeValue<std::string>(serverPackageEl, \"URL\", \"\");\n                        u32 packageSize = XMLUtils::GetAttributeValue<u32>(serverPackageEl, \"Size\", 0);\n                        CS_ASSERT(packageSize > 0, \"Package size cannot be 0!\");\n                        \n                        PackageDetails details;\n                        details.m_url = url;\n                        details.m_size = packageSize;\n                        details.m_checksum = expectedChecksum;\n                        details.m_id = id;\n                        \n                        alreadyCachedPackages.push_back(details);\n                    }\n                    else\n                    {\n                        //Cached package is corrupt/incomplete, remove it\n                        Application::Get()->GetFileSystem()->DeleteFile(StorageLocation::k_DLC, cachedFilePath);\n                    }\n                }\n            }\n            \n            //On to the next package\n            serverPackageEl = XMLUtils::GetNextSiblingElement(serverPackageEl, \"Package\");\n        }\n        \n        m_cachedPackageDetails = alreadyCachedPackages;\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Networking/ContentDownload/ContentManagementSystem.h",
    "content": "//\n//  ContentManagementSystem.h\n//  ChilliSource\n//  Created by Scott Downie on 04/07/2011.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2011 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_NETWORKING_CONTENTDOWNLOAD_CONTENTMANAGEMENTSYSTEM_H_\n#define _CHILLISOURCE_NETWORKING_CONTENTDOWNLOAD_CONTENTMANAGEMENTSYSTEM_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Event/Event.h>\n#include <ChilliSource/Core/System/AppSystem.h>\n#include <ChilliSource/Core/XML/XMLUtils.h>\n#include <ChilliSource/Networking/ContentDownload/IContentDownloader.h>\n\nnamespace ChilliSource\n{\n    //---------------------------------------------------------------\n    /// A system for managing the downloading of content to the\n    /// DLC storage location.\n    ///\n    /// @author S Downie\n    //---------------------------------------------------------------\n    class ContentManagementSystem final : public AppSystem\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(ContentManagementSystem);\n        //--------------------------------------------------------\n        /// An enum describing the possible results from a Check\n        /// For Updates request.\n        ///\n        /// @author S Downie\n        //--------------------------------------------------------\n        enum class CheckForUpdatesResult\n        {\n            k_available,             //There are updates available to download and we are connected\n            k_availableBlocking,     //There are updates available to download and we must download them as the old assets have been purged\n            k_checkFailed,           //The downloading of the content manifest has failed\n            k_checkFailedBlocking,   //The DLC on the cache has been cleared and a download is required but the manifest has failed\n            k_notAvailable,          //There are no updates available\n        };\n        //--------------------------------------------------------\n        /// An enum describing the possible results from a content\n        /// download request.\n        ///\n        /// @author S Downie\n        //--------------------------------------------------------\n        enum class Result\n        {\n            k_succeeded,\n            k_failed\n        };\n        //--------------------------------------------------------\n        /// A delegate used for receiving the result of a Check\n        /// For Updates request.\n        ///\n        /// @author S Downie\n        ///\n        /// @param The result.\n        //--------------------------------------------------------\n        using CheckForUpdateDelegate = std::function<void(CheckForUpdatesResult)>;\n        //--------------------------------------------------------\n        /// A delegate used for receiving the result of a content\n        /// download request.\n        ///\n        /// @author S Downie\n        ///\n        /// @param The result.\n        //--------------------------------------------------------\n        using CompleteDelegate = std::function<void(Result)>;\n        //--------------------------------------------------------\n        /// A delegate used for receiving updates on the progress\n        /// of a download\n        ///\n        /// @author HMcLaughlin\n        ///\n        /// @param in_packageName - Package name that progressed.\n        /// @param in_progress - Total Progress through downloads\n        //--------------------------------------------------------\n        using DownloadProgressDelegate = std::function<void(const std::string& in_packageName, f32 in_progress)>;\n        //-----------------------------------------------------------\n        /// Called when a checksum needs to be calculated.\n        ///\n        /// @author N Tanda\n        ///\n        /// @param File location\n        /// @param File path\n        /// @return Checksum string\n        //-----------------------------------------------------------\n        using ChecksumDelegate = std::function<std::string(StorageLocation in_location, const std::string& in_filePath)>;\n        //--------------------------------------------------------\n        /// Creates a new instance of this system.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The content downloader that should be used.\n        ///\n        /// @return The new system instance.\n        //--------------------------------------------------------\n        static ContentManagementSystemUPtr Create(IContentDownloader* in_contentDownloader);\n        //--------------------------------------------------------\n        /// Queries whether or not this implements the interface\n        /// with the given Id.\n        ///\n        /// @author S Downie\n        ///\n        /// @param The interface Id.\n        ///\n        /// @return Whether or not the inteface is implemented.\n        //---------------------------------------------------------\n        bool IsA(InterfaceIDType in_interfaceId) const override;\n        //-----------------------------------------------------------\n        /// Get the content manifest from the asset server and\n        /// check for any changes with the local copy.\n        ///\n        /// The location of the asset server is usually the Tag \n        /// server but may be a third party storage solution based on\n        /// the SKU (i.e. Google's Asset Store). The URL is taken\n        /// from the tweakable constants.\n        ///\n        /// @author S Downie\n        ///\n        /// @param Delegate to callback notifying whether an update\n        /// is required\n        //-----------------------------------------------------------\n        void CheckForUpdates(const CheckForUpdateDelegate& in_delegate);\n        //-----------------------------------------------------------\n        /// Having checked for updates and been notified whether\n        /// there are updates pending this function should be\n        /// called to begin downloading any out of date content\n        ///\n        /// Call GetDownloadProgress to get the progress value\n        /// to update any progress UI\n        ///\n        /// @author S Downie\n        ///\n        /// @param Delegate to call when download is complete\n        /// @param Delegate to call when download is progressed\n        //-----------------------------------------------------------\n        void DownloadUpdates(const CompleteDelegate& in_delegate, const DownloadProgressDelegate& in_progressDelegate);\n        //-----------------------------------------------------------\n        /// Having downloaded the update packages this method\n        /// unzips the packages and overwrites any old assets\n        ///\n        /// @author S Downie\n        ///\n        /// @param Delegate to call when Install is complete\n        //-----------------------------------------------------------\n        void InstallUpdates(const CompleteDelegate& in_delegate);\n        //-----------------------------------------------------------\n        /// Data is cached in memory and only written to disc\n        /// when the download is successful; at which point\n        /// we can clear the data and delete any temp files\n        ///\n        /// @author S Downie\n        //-----------------------------------------------------------\n        void ClearDownloadData();\n        //-----------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param File name\n        /// @return Checksum of file as found in the current manifest\n        //-----------------------------------------------------------\n        std::string GetManifestChecksumForFile(const std::string& in_filename) const;\n        //-----------------------------------------------------------\n        /// Returns the current running total of the size of data to\n        /// download.\n        ///\n        /// @author S Downie\n        ///\n        /// @return The size of the data needing to be downloaded\n        //-----------------------------------------------------------\t\t\t\n        u32 GetRunningTotalToDownload() const;\n        //-----------------------------------------------------------\n        /// Returns the current running total of the size of data\n        /// downloaded\n        ///\n        /// @author S Downie\n        ///\n        /// @return The current running total of the size of data\n        /// downloaded\n        //-----------------------------------------------------------\n        u32 GetRunningTotalDownloaded() const;\n        //-----------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return The current content downloader\n        //-----------------------------------------------------------\n        IContentDownloader* GetContentDownloader() const;\n        //-----------------------------------------------------------\n        /// @author N Tanda\n        ///\n        /// @param The checksum calculation delegate\n        //-----------------------------------------------------------\n        void SetChecksumDelegate(const ChecksumDelegate& in_delegate);\n        \n    private:\n        //-----------------------------------------------------------\n        /// A container for information on a single downloaded\n        /// package.\n        ///\n        /// @author S Downie\n        //-----------------------------------------------------------\n        struct PackageDetails final\n        {\n            std::string m_url;\n            std::string m_id;\n            std::string m_checksum;\n            u32 m_size;\n            \n            //-----------------------------------------------------------\n            /// @author HMcLaughlin\n            ///\n            /// @param in_other - Package to compare to\n            ///\n            /// @return If equal\n            //-----------------------------------------------------------\n            bool operator==(const PackageDetails& in_other) const\n            {\n                if(m_id == in_other.m_id &&\n                   m_checksum == in_other.m_checksum &&\n                   m_size == in_other.m_size &&\n                   m_url == in_other.m_url)\n                {\n                    return true;\n                }\n                \n                return false;\n            }\n        };\n        //------------------------------------------------------------\n        /// Initialisation method called at a time when all App Systems\n        /// have been created. System initialisation occurs in the order\n        /// they were created.\n        ///\n        /// @author Ian Copland\n        //-----------------------------------------------------------\n        void OnInit() override;\n        //-----------------------------------------------------------\n        /// Constructor. Declared private to force the use of the\n        /// factory method.\n        ///\n        /// @author S Downie\n        ///\n        /// @param The content downloader to use.\n        //-----------------------------------------------------------\n        ContentManagementSystem(IContentDownloader* in_contentDownloader);\n        //-----------------------------------------------------------\n        /// Load the client side cached content manifest if one\n        /// exists\n        ///\n        /// @author S Downie\n        ///\n        /// @return The xml document.\n        //-----------------------------------------------------------\n        XMLUPtr LoadLocalManifest();\n        //-----------------------------------------------------------\n        /// The manifest file has downloaded we can now compare\n        /// and contrast to check for outdated files\n        ///\n        /// @author S Downie\n        ///\n        /// @param Request result\n        /// @param Request response\n        //-----------------------------------------------------------\n        void OnContentManifestDownloadComplete(IContentDownloader::Result in_result, const std::string& in_manifest);\n        //-----------------------------------------------------------\n        /// The file has downloaded we can now save it to the cache\n        ///\n        /// @author S Downie\n        ///\n        /// @param Request result\n        /// @param Request response\n        //-----------------------------------------------------------\n        void OnContentDownloadComplete(IContentDownloader::Result in_result, const std::string& in_data);\n        //-----------------------------------------------------------\n        /// Check if an existing content manifest exists and\n        /// construct a list of the files that require updating\n        /// then overwrite the old manifest with the new one\n        ///\n        /// @author S Downie\n        ///\n        /// @param String containing the server manifest\n        //-----------------------------------------------------------\n        void BuildDownloadList(const std::string& in_serverManifest);\n        //-----------------------------------------------------------\n        /// The package may be outdated in documents but are\n        /// all the files in bundle up to date\n        ///\n        /// @author S Downie\n        ///\n        /// @param Package element\n        //-----------------------------------------------------------\n        void AddToDownloadListIfNotInBundle(XML::Node* in_packageEl);\n        //-----------------------------------------------------------\n        /// Save the zip file to documents directory\n        ///\n        /// @author S Downie\n        ///\n        /// @param Package details\n        /// @param Binary zip\n        /// @param Whether the file has finished downloading\n        /// @return Success\n        //-----------------------------------------------------------\n        bool SavePackageToFile(const PackageDetails& in_packageDetails, const std::string& in_zippedPackage, bool in_fullyDownloaded);\n        //-----------------------------------------------------------\n        /// Unzip the package and save all the files to the\n        /// documents directory\n        ///\n        /// @author S Downie\n        ///\n        /// @param Zipped package\n        //-----------------------------------------------------------\n        void ExtractFilesFromPackage(const PackageDetails& in_packageDetails) const;\n        //-----------------------------------------------------------\n        /// Checks whether the file is within the application and if the\n        /// the checksums match\n        ///\n        /// @author S Downie\n        ///\n        /// @param Filename\n        /// @param Checksum\n        /// @param Whether to check only the bundle\n        ///\n        /// @return Whether the file exists\n        //-----------------------------------------------------------\n        bool DoesFileExist(const std::string& in_filename, const std::string in_checksum, bool in_checkOnlyBundle) const;\n        //-----------------------------------------------------------\n        /// Calculate a checksum for the file. Will call the custom\n        /// checksum delegate if provided. Otherwise, will perform an\n        /// SHA256 hash of the file and convert that to base 64 encoded\n        /// and then trim the trailing '='\n        ///\n        /// @author S Downie\n        ///\n        /// @param File location\n        /// @param File path\n        /// @return Checksum string\n        //-----------------------------------------------------------\n        std::string CalculateChecksum(StorageLocation in_location, const std::string& in_filePath) const;\n        //-----------------------------------------------------------\n        /// Perform the HTTP request for the next DLC package.\n        ///\n        /// @author S Downie\n        //-----------------------------------------------------------\n        void DownloadNextPackage();\n        //-----------------------------------------------------------\n        /// Perform the HTTP request for a DLC package.\n        ///\n        /// @author HMcLaughlin\n        ///\n        /// @param in_packageIndex - Index in m_packageDetails\n        /// @param in_checkCached - [Optional] Check if already cached\n        //-----------------------------------------------------------\n        void DownloadPackage(u32 in_packageIndex, bool in_checkCached = true);\n        //-----------------------------------------------------------\n        /// Callback for package download progress\n        ///\n        /// @author HMcLaughlin\n        ///\n        /// @param in_url - Url of downloading package\n        /// @param in_progress - Progress through download (0.0f - 1.0f)\n        //-----------------------------------------------------------\n        void OnContentDownloadProgress(const std::string& in_url, f32 in_progress);\n        //-----------------------------------------------------------\n        /// Checks if there is any incomplete downloads and refresh\n        /// the temporary data\n        ///\n        /// @author HMcLaughlin\n        //-----------------------------------------------------------\n        void RefreshIncompleteDownloadInfo();\n        //-----------------------------------------------------------\n        /// Verifies all temporary downloads with the passed in\n        /// manifest, stores a list of packageDetails for fully\n        /// cached files. This will remove any packages that do not\n        /// pass checksum validation\n        ///\n        /// @author HMcLaughlin\n        ///\n        /// @param in_manifestPath - Manifest path\n        //-----------------------------------------------------------\n        void VerifyTemporaryDownloads(const std::string& in_manifestPath);\n        \n    private:\n        std::vector<std::string> m_removePackageIds;\n        std::vector<PackageDetails> m_packageDetails;\n        std::vector<PackageDetails> m_cachedPackageDetails;\n        \n        u32\tm_runningToDownloadTotal = 0;\n        u32 m_runningDownloadedTotal = 0;\n        \n        XMLUPtr m_serverManifest;\n        \n        IContentDownloader* m_contentDownloader = nullptr;\n        \n        CheckForUpdateDelegate m_onUpdateCheckCompleteDelegate;\n        CompleteDelegate m_onDownloadCompleteDelegate;\n        DownloadProgressDelegate m_onDownloadProgressDelegate;\n        ChecksumDelegate m_checksumDelegate;\n        \n        std::string m_serverManifestData;\n        std::string m_contentDirectory;\n        \n        u32 m_currentPackageDownload = 0;\n        \n        bool m_dlcCachePurged = false;\n        bool m_downloadInProgress = false;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Networking/ContentDownload/IContentDownloader.h",
    "content": "//\n//  IContentDownloader.h\n//  ChilliSource\n//  Created by Scott Downie on 23/01/2012.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2012 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_NETWORKING_CONTENTDOWNLOAD_ICONTENTDOWNLOADER_H_\n#define _CHILLISOURCE_NETWORKING_CONTENTDOWNLOAD_ICONTENTDOWNLOADER_H_\n\n#include <ChilliSource/ChilliSource.h>\n\n#include <functional>\n\nnamespace ChilliSource\n{\n    //----------------------------------------------------------------\n    /// An interface for content downloaders. A downloader implementing\n    /// this interface should be used in conjunction with the Content\n    /// Management System.\n    ///\n    /// @author S Downie\n    //----------------------------------------------------------------\n    class IContentDownloader\n    {\n    public:\n        //----------------------------------------------------------\n        /// An enum describing the possible results from a download\n        /// request.\n        ///\n        /// @author S Downie\n        //----------------------------------------------------------\n        enum class Result\n        {\n            k_succeeded,\n            k_failed,\n            k_flushed\n        };\n        //----------------------------------------------------------\n        /// A delegate that can be used to get the response from a\n        /// download request.\n        ///\n        /// @param The result of the request\n        /// @param The response string.\n        ///\n        /// @author S Downie\n        //----------------------------------------------------------\n        using Delegate = std::function<void(Result, const std::string&)>;\n        //----------------------------------------------------------\n        /// A delegate that can be used to report the progress of a\n        /// download\n        ///\n        /// @param The url of the request\n        /// @param Progress.\n        ///\n        /// @author HMcLaughlin\n        //----------------------------------------------------------\n        using DownloadProgressDelegate = std::function<void(const std::string&, f32)>;\n        //----------------------------------------------------------\n        /// Pull the .csman file from the server and callback when\n        /// the download is complete\n        ///\n        /// @author S Downie\n        ///\n        /// @param The delegate.\n        //----------------------------------------------------------\n        virtual void DownloadContentManifest(const Delegate& in_delegate) = 0;\n        //----------------------------------------------------------\n        /// Download the package file from the given URL\n        ///\n        /// @author S Downie\n        ///\n        /// @param URL string\n        /// @param Delegate\n        /// @param Download Progress Delegate\n        //---------------------------------------------------------\n        virtual void DownloadPackage(const std::string& in_url, const Delegate& in_delegate, const DownloadProgressDelegate& in_progressDelegate) = 0;\n        //---------------------------------------------------------\n        /// The destructor.\n        ///\n        /// @author S Downie\n        //---------------------------------------------------------\n        virtual ~IContentDownloader() {}\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Networking/ContentDownload/MoContentDownloader.cpp",
    "content": "//\n//  MoContentDownloader.cpp\n//  ChilliSource\n//  Created by Scott Downie on 23/01/2012.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2012 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Networking/ContentDownload/MoContentDownloader.h>\n\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/Base/Device.h>\n#include <ChilliSource/Core/Delegate/MakeDelegate.h>\n#include <ChilliSource/Networking/Http/HttpResponse.h>\n\n#include <json/json.h>\n\nnamespace ChilliSource\n{\n    const f32 k_downloadProgressUpdateIntervalDefault = 1.0f / 30.0f;\n    \n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    MoContentDownloader::MoContentDownloader(HttpRequestSystem* inpRequestSystem, const std::string& instrAssetServerURL, const std::vector<std::string>& inastrTags)\n    : mpHttpRequestSystem(inpRequestSystem), mstrAssetServerURL(instrAssetServerURL), mastrTags(inastrTags)\n    {\n        m_downloadProgressUpdateTimer = TimerSPtr(new Timer());\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    void MoContentDownloader::DownloadContentManifest(const Delegate& inDelegate)\n    {\n        mOnContentManifestDownloadCompleteDelegate = inDelegate;\n        \n        //Request the content manifest\n        mpHttpRequestSystem->CheckReachability([=](bool in_reachable)\n        {\n            if(!in_reachable && mOnContentManifestDownloadCompleteDelegate)\n            {\n                mOnContentManifestDownloadCompleteDelegate(Result::k_failed, \"\");\n            }\n            else\n            {\n                Device* device = Application::Get()->GetSystem<Device>();\n                \n                //Build the JSON request with the device info so the server can decide what\n                //assets are suitable for us\n                Json::Value JDeviceData(Json::objectValue);\n                JDeviceData[\"Type\"] = device->GetManufacturer() + device->GetModel() + device->GetModelType();\n                JDeviceData[\"OS\"] = device->GetOSVersion();\n                JDeviceData[\"Locale\"] = device->GetLocale();\n                JDeviceData[\"Language\"] = device->GetLanguage();\n                \n                //The server uses the tags to determine which content to serve\n                Json::Value JTags(Json::arrayValue);\n                for(std::vector<std::string>::const_iterator it = mastrTags.begin(); it != mastrTags.end(); ++it)\n                {\n                    JTags.append(*it);\n                }\n                JDeviceData[\"Tags\"] = JTags;\n                \n                Json::FastWriter JWriter;\n                mpHttpRequestSystem->MakePostRequest(mstrAssetServerURL, JWriter.write(JDeviceData), MakeDelegate(this, &MoContentDownloader::OnContentManifestDownloadComplete));\n            }\n        });\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    void MoContentDownloader::DownloadPackage(const std::string& in_url, const Delegate& in_completiondelegate, const DownloadProgressDelegate& in_progressDelegate)\n    {\n        mOnContentDownloadCompleteDelegate = in_completiondelegate;\n        mpCurrentRequest = mpHttpRequestSystem->MakeGetRequest(in_url, MakeDelegate(this, &MoContentDownloader::OnContentDownloadComplete));\n        \n        //Reset the timer\n        m_downloadProgressUpdateTimer->Reset();\n        m_downloadProgressEventConnection = m_downloadProgressUpdateTimer->OpenConnection(k_downloadProgressUpdateIntervalDefault, [=]()\n        {\n            if(in_progressDelegate)\n            {\n                in_progressDelegate(in_url, GetDownloadProgress());\n            }\n        });\n        \n        m_downloadProgressUpdateTimer->Start();\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    void MoContentDownloader::OnContentManifestDownloadComplete(const HttpRequest* in_request, const HttpResponse& in_response)\n    {\n        switch(in_response.GetResult())\n        {\n            case HttpResponse::Result::k_completed:\n            {\n                //Check the response code for errors\n                switch(in_response.GetCode())\n                {\n                    default:   //OK \n                    case HttpResponseCode::k_ok:\n                    {\n                        mOnContentManifestDownloadCompleteDelegate(Result::k_succeeded, in_response.GetDataAsString());\n                        break;\n                    }\n                    case HttpResponseCode::k_error:      //Error\n                    case HttpResponseCode::k_unavailable://Temporary error try again later\n                    case HttpResponseCode::k_notFound:   //End point doesn't exist\n                    {\n                        mOnContentManifestDownloadCompleteDelegate(Result::k_failed, in_response.GetDataAsString());\n                        break;\n                    }\n                }\n                break;\n            }\n            case HttpResponse::Result::k_timeout:\n            case HttpResponse::Result::k_failed:\n            {\n                mOnContentManifestDownloadCompleteDelegate(Result::k_failed, in_response.GetDataAsString());\n                break;\n            }\n            case HttpResponse::Result::k_flushed:\n            {\n                //Check the response code for errors\n                switch(in_response.GetCode())\n                {\n                    default:   //OK \n                    case HttpResponseCode::k_ok:\n                    {\n                        mOnContentManifestDownloadCompleteDelegate(Result::k_flushed, in_response.GetDataAsString());\n                        break;\n                    }\n                    case HttpResponseCode::k_error:      //Error\n                    case HttpResponseCode::k_unavailable://Temporary error try again later\n                    case HttpResponseCode::k_notFound:   //End point doesn't exist\n                    {\n                        mOnContentManifestDownloadCompleteDelegate(Result::k_failed, in_response.GetDataAsString());\n                        break;\n                    }\n                }\n                break;\n            }\n        }\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    void MoContentDownloader::OnContentDownloadComplete(const HttpRequest* in_request, const HttpResponse& in_response)\n    {\n        if(in_response.GetResult() != HttpResponse::Result::k_flushed)\n        {\n            if(mpCurrentRequest == in_request)\n            {\n                mpCurrentRequest = nullptr;\n            }\n        \n            if(m_downloadProgressUpdateTimer)\n            {\n                m_downloadProgressEventConnection.reset();\n                m_downloadProgressUpdateTimer->Stop();\n            }\n        }\n        \n        switch(in_response.GetResult())\n        {\n            case HttpResponse::Result::k_completed:\n            {\n                // Check the response code for errors\n                switch(in_response.GetCode())\n                {\n                    default:   //OK\n                    case HttpResponseCode::k_ok:\n                        mOnContentDownloadCompleteDelegate(Result::k_succeeded, in_response.GetDataAsString());\n                        break;\n                }\n                break;\n            }\n            case HttpResponse::Result::k_timeout:\n            case HttpResponse::Result::k_failed:\n            {\n                mOnContentDownloadCompleteDelegate(Result::k_failed, in_response.GetDataAsString());\n                break;\n            }\n            case HttpResponse::Result::k_flushed:\n            {\n                mOnContentDownloadCompleteDelegate(Result::k_flushed, in_response.GetDataAsString());\n                break;\n            }\n        }\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    f32 MoContentDownloader::GetDownloadProgress() const\n    {\n        f32 progress = 0.0f;\n        \n        // Check if there is an active request\n        if(mpCurrentRequest)\n        {\n            if(mpCurrentRequest->GetExpectedSize() > 0)\n            {\n                // Calculate current scene download progress\n                progress = (f32)mpCurrentRequest->GetDownloadedBytes() / (f32)mpCurrentRequest->GetExpectedSize();\n            }\n        }\n        \n        return progress;\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Networking/ContentDownload/MoContentDownloader.h",
    "content": "//\n//  MoContentDownloader.h\n//  ChilliSource\n//  Created by Scott Downie on 23/01/2012.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2012 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_NETWORKING_MO_CONTENT_DOWNLOADER_H_\n#define _CHILLISOURCE_NETWORKING_MO_CONTENT_DOWNLOADER_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Time.h>\n#include <ChilliSource/Networking/ContentDownload/IContentDownloader.h>\n#include <ChilliSource/Networking/Http/HttpRequestSystem.h>\n\nnamespace ChilliSource\n{\n    class MoContentDownloader final : public IContentDownloader\n    {\n    public:\n        //----------------------------------------------------------------\n        /// Constructor\n        ///\n        /// @param HTTP request system\n        /// @param Asset server URL\n        /// @param Dynamic array of tags that determine content\n        //----------------------------------------------------------------\n        MoContentDownloader(HttpRequestSystem* inpRequestSystem, const std::string& instrAssetServerURL, const std::vector<std::string>& inastrTags);\n        //----------------------------------------------------------------\n        /// Download Content Manifest\n        ///\n        /// Pull the .moman file from the server and callback when\n        /// the download is complete\n        ///\n        /// @param Delegate\n        //----------------------------------------------------------------\n        void DownloadContentManifest(const Delegate& inDelegate);\n        //----------------------------------------------------------------\n        /// Download the package file from the given URL\n        ///\n        /// @author HMcLaughlin\n        ///\n        /// @param in_url - Url to download\n        /// @param in_completiondelegate - Delegate to call on completion\n        /// @param in_progressDelegate - Download Progress Delegate\n        //----------------------------------------------------------------\n        void DownloadPackage(const std::string& in_url, const Delegate& in_completiondelegate, const DownloadProgressDelegate& in_progressDelegate);\n        //----------------------------------------------------------------\n        /// Get Tags\n        ///\n        /// @return The current tags of this downloader\n        //----------------------------------------------------------------\n        inline const std::vector<std::string>& GetTags() const { return mastrTags; }\n        //----------------------------------------------------------------\n        /// Set Tags\n        ///\n        /// Set the tags for this downloader\n        //----------------------------------------------------------------\n        inline void SetTags(const std::vector<std::string>& inastrTags) { mastrTags = inastrTags; }\n        //------------------------------------------------------------\n        /// @author HMcLaughlin\n        ///\n        /// @return The progress of the current package\n        //------------------------------------------------------------\n        f32 GetDownloadProgress() const;\n        \n    private:\n        //----------------------------------------------------------------\n        /// Triggered when the manifest download has completed\n        ///\n        /// @author S Downie\n        ///\n        /// @param Original request\n        /// @param Request response\n        //----------------------------------------------------------------\n        void OnContentManifestDownloadComplete(const HttpRequest* in_request, const HttpResponse& in_response);\n        //----------------------------------------------------------------\n        /// Triggered when a package download has completed\n        ///\n        /// @author S Downie\n        ///\n        /// @param Original request\n        /// @param Request response\n        //----------------------------------------------------------------\n        void OnContentDownloadComplete(const HttpRequest* in_request, const HttpResponse& in_response);\n        \n    private:\n        \n        std::vector<std::string> mastrTags;\n        \n        std::string mstrAssetServerURL;\n        Delegate mOnContentManifestDownloadCompleteDelegate;\n        Delegate mOnContentDownloadCompleteDelegate;\n        \n        HttpRequestSystem* mpHttpRequestSystem;\n        \n        HttpRequest* mpCurrentRequest;\n        \n        TimerSPtr m_downloadProgressUpdateTimer;\n        EventConnectionUPtr m_downloadProgressEventConnection;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Networking/ContentDownload.h",
    "content": "//\n//  ContentDownload.h\n//  ChilliSource\n//  Created by Ian Copland on 07/07/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n\n#ifndef _CHILLISOURCE_NETWORKING_CONTENTDOWNLOAD_H_\n#define _CHILLISOURCE_NETWORKING_CONTENTDOWNLOAD_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Networking/ContentDownload/ContentManagementSystem.h>\n#include <ChilliSource/Networking/ContentDownload/IContentDownloader.h>\n#include <ChilliSource/Networking/ContentDownload/MoContentDownloader.h>\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Networking/ForwardDeclarations.h",
    "content": "//\n//  ForwardDeclarations.h\n//  ChilliSource\n//  Created by Ian Copland 26/02/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_NETWORKING_FORWARDDECLARATIONS_H_\n#define _CHILLISOURCE_NETWORKING_FORWARDDECLARATIONS_H_\n\n#include <ChilliSource/Core/Base/StandardMacros.h>\n\n#include <memory>\n\nnamespace ChilliSource\n{\n    //--------------------------------------------------\n    /// Content Download\n    //--------------------------------------------------\n    CS_FORWARDDECLARE_CLASS(IContentDownloader);\n    CS_FORWARDDECLARE_CLASS(ContentManagementSystem);\n    CS_FORWARDDECLARE_CLASS(MoContentDownloader);\n    //--------------------------------------------------\n    /// Http\n    //--------------------------------------------------\n    CS_FORWARDDECLARE_CLASS(HttpRequestSystem);\n    CS_FORWARDDECLARE_CLASS(HttpRequest);\n    CS_FORWARDDECLARE_CLASS(HttpResponse);\n    //--------------------------------------------------\n    /// IAP\n    //--------------------------------------------------\n    CS_FORWARDDECLARE_CLASS(IAPSystem);\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Networking/Http/HttpRequest.h",
    "content": "//\n//  HttpRequest.h\n//  ChilliSource\n//  Created by Scott Downie on 23/05/2011.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2011 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_NETWORKING_HTTP_HTTPREQUEST_H_\n#define _CHILLISOURCE_NETWORKING_HTTP_HTTPREQUEST_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Container/ParamDictionary.h>\n\n#include <functional>\n\nnamespace ChilliSource\n{\n    //----------------------------------------------------------------------------------------\n    /// Interface class to a platform dependent http request. A request can be issued\n    /// via the HttpRequestSystem to a given URL. Requests can be of type POST or GET. The\n    /// request object can be used to cancel the request\n    ///\n    /// @author S Downie\n    //----------------------------------------------------------------------------------------\n    class HttpRequest\n    {\n    public:\n        \n        CS_DECLARE_NOCOPY(HttpRequest);\n        \n        //----------------------------------------------------------------------------------------\n        /// Type of the Http request (Post or Get)\n        ///\n        /// @author S Downie\n        //----------------------------------------------------------------------------------------\n        enum class Type\n        {\n            k_get,\n            k_post\n        };\n        //----------------------------------------------------------------------------------------\n        /// Delegate called when the request completes (either with success of failure)\n        ///\n        /// @param Original request\n        /// @param Request response\n        ///\n        /// @author S Downie\n        //----------------------------------------------------------------------------------------\n        typedef std::function<void(const HttpRequest*, const HttpResponse&)> Delegate;\n        //----------------------------------------------------------------------------------------\n        /// Constructor\n        ///\n        /// @author S Downie\n        //----------------------------------------------------------------------------------------\n        HttpRequest() = default;\n        //----------------------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return The type of the request (POST or GET)\n        //----------------------------------------------------------------------------------------\n        virtual Type GetType() const = 0;\n        //----------------------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return The original url to which the request was sent\n        //----------------------------------------------------------------------------------------\n        virtual const std::string& GetUrl() const = 0;\n        //----------------------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return The body of the POST request (GET request will return empty)\n        //----------------------------------------------------------------------------------------\n        virtual const std::string& GetBody() const = 0;\n        //----------------------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return The original headers of the request as keys/values\n        //----------------------------------------------------------------------------------------\n        virtual const ParamDictionary& GetHeaders() const = 0;\n        //----------------------------------------------------------------------------------------\n        /// @author N Tanda\n        ///\n        /// @return The expected total size of the request. This will be 0 until the first\n        ///         response arrives\n        //----------------------------------------------------------------------------------------\n        virtual u64 GetExpectedSize() const = 0;\n        //----------------------------------------------------------------------------------------\n        /// @author N Tanda\n        ///\n        /// @return The current transferred size of the request\n        //----------------------------------------------------------------------------------------\n        virtual u64 GetDownloadedBytes() const = 0;\n        //----------------------------------------------------------------------------------------\n        /// Cancel the request. Does not invoke the completion delegate\n        ///\n        /// @author S Downie\n        //----------------------------------------------------------------------------------------\n        virtual void Cancel() = 0;\n        //----------------------------------------------------------------------------------------\n        /// Destructor\n        ///\n        /// @author S Downie\n        //----------------------------------------------------------------------------------------\n        virtual ~HttpRequest(){}\n    };\n}\n\n\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Networking/Http/HttpRequestSystem.cpp",
    "content": "//\n//  HttpRequestSystem.cpp\n//  ChilliSource\n//  Created by Scott Downie on 23/05/2011.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2011 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Networking/Http/HttpRequestSystem.h>\n\n#ifdef CS_TARGETPLATFORM_IOS\n#include <CSBackend/Platform/iOS/Networking/Http/HttpRequestSystem.h>\n#endif\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n#include <CSBackend/Platform/Android/Main/JNI/Networking/Http/HttpRequestSystem.h>\n#endif\n\n#ifdef CS_TARGETPLATFORM_WINDOWS\n#include <CSBackend/Platform/Windows/Networking/Http/HttpRequestSystem.h>\n#endif\n\n#ifdef CS_TARGETPLATFORM_RPI\n#include <CSBackend/Platform/RPi/Networking/Http/HttpRequestSystem.h>\n#endif\n\nnamespace ChilliSource\n{\n    CS_DEFINE_NAMEDTYPE(HttpRequestSystem);\n    \n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    HttpRequestSystemUPtr HttpRequestSystem::Create()\n    {\n#ifdef CS_TARGETPLATFORM_IOS\n        return HttpRequestSystemUPtr(new CSBackend::iOS::HttpRequestSystem());\n#endif\n#ifdef CS_TARGETPLATFORM_ANDROID\n        return HttpRequestSystemUPtr(new CSBackend::Android::HttpRequestSystem());\n#endif\n#ifdef CS_TARGETPLATFORM_WINDOWS\n        return HttpRequestSystemUPtr(new CSBackend::Windows::HttpRequestSystem());\n#endif\n#ifdef CS_TARGETPLATFORM_RPI\n        return HttpRequestSystemUPtr(new CSBackend::RPi::HttpRequestSystem());\n#endif\n        return nullptr;\n    }\n    //--------------------------------------------------------------------------------------------------\n    /// @author S Downie\n    ///\n    /// @param The number of bytes read before the buffer is flushed (0 is infinite)\n    //--------------------------------------------------------------------------------------------------\n    void HttpRequestSystem::SetMaxBufferSize(u32 in_sizeInBytes)\n    {\n        m_maxBufferSize = in_sizeInBytes;\n    }\n    //--------------------------------------------------------------------------------------------------\n    //--------------------------------------------------------------------------------------------------\n    u32 HttpRequestSystem::GetMaxBufferSize() const\n    {\n        return m_maxBufferSize;\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Networking/Http/HttpRequestSystem.h",
    "content": "//\n//  HttpRequestSystem.h\n//  ChilliSource\n//  Created by Scott Downie on 23/05/2011.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2011 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_NETWORKING_HTTP_HTTPREQUESTSYSTEM_H_\n#define _CHILLISOURCE_NETWORKING_HTTP_HTTPREQUESTSYSTEM_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Container/ParamDictionary.h>\n#include <ChilliSource/Core/System/AppSystem.h>\n#include <ChilliSource/Networking/Http/HttpRequest.h>\n\n#include <functional>\n\nnamespace ChilliSource\n{\n    //--------------------------------------------------------------------------------------------------\n    /// Common response codes\n    //--------------------------------------------------------------------------------------------------\n    namespace HttpResponseCode\n    {\n        const u32 k_ok = 200;\n        const u32 k_redirect = 301;\n        const u32 k_movedTemporarily = 302;\n        const u32 k_redirectTemporarily = 307;\n        const u32 k_notFound = 404;\n        const u32 k_conflict = 409;\n        const u32 k_error = 500;\n        const u32 k_unavailable = 503;\n    }\n    \n    //--------------------------------------------------------------------------------------------------\n    /// Base class for platform depended http request system. This system is responsible for making\n    /// http requests to a url and managing the lifetime of the requests and the connections.\n    ///\n    /// NOTE: On certain platforms you cannot redirect from https to http. You have been warned!\n    ///\n    /// @author S Downie\n    //--------------------------------------------------------------------------------------------------\n    class HttpRequestSystem : public AppSystem\n    {\n    public:\n        \n        CS_DECLARE_NAMEDTYPE(HttpRequestSystem);\n        \n        static const u32 k_defaultTimeoutSecs = 15;\n        \n        //----------------------------------------------------------------------------------------\n        /// Delegate called when a reachability request completes (either with success of failure)\n        ///\n        /// @param If network is reachable\n        ///\n        /// @author HMcLaughlin\n        //----------------------------------------------------------------------------------------\n        using ReachabilityResultDelegate = std::function<void(bool reachability)>;\n        \n        //--------------------------------------------------------------------------------------------------\n        /// Factory method\n        ///\n        /// @author S Downie\n        ///\n        /// @return New backend with ownership transferred\n        //--------------------------------------------------------------------------------------------------\n        static HttpRequestSystemUPtr Create();\n        //--------------------------------------------------------------------------------------------------\n        /// Causes the system to issue an Http GET request.\n        ///\n        /// @author S Downie\n        ///\n        /// @param URL\n        /// @param Delegate that is called on request completed. Completion can be failure as well as success\n        /// @param Request timeout in seconds\n        ///\n        /// @return A pointer to the request. The system owns this pointer.\n        //--------------------------------------------------------------------------------------------------\n        virtual HttpRequest* MakeGetRequest(const std::string& in_url, const HttpRequest::Delegate& in_delegate, u32 in_timeoutSecs = k_defaultTimeoutSecs) = 0;\n        //--------------------------------------------------------------------------------------------------\n        /// Causes the system to issue an Http GET request.\n        ///\n        /// @author S Downie\n        ///\n        /// @param URL\n        /// @param Key value headers to attach to the request\n        /// @param Delegate that is called on request completed. Completion can be failure as well as success\n        /// @param Request timeout in seconds\n        ///\n        /// @return A pointer to the request. The system owns this pointer.\n        //--------------------------------------------------------------------------------------------------\n        virtual HttpRequest* MakeGetRequest(const std::string& in_url, const ParamDictionary& in_headers, const HttpRequest::Delegate& in_delegate, u32 in_timeoutSecs = k_defaultTimeoutSecs) = 0;\n        //--------------------------------------------------------------------------------------------------\n        /// Causes the system to issue an Http POST request with the given body.\n        ///\n        /// @author S Downie\n        ///\n        /// @param URL\n        /// @param POST body\n        /// @param Delegate that is called on request completed. Completion can be failure as well as success\n        /// @param Request timeout in seconds\n        ///\n        /// @return A pointer to the request. The system owns this pointer.\n        //--------------------------------------------------------------------------------------------------\n        virtual HttpRequest* MakePostRequest(const std::string& in_url, const std::string& in_body, const HttpRequest::Delegate& in_delegate, u32 in_timeoutSecs = k_defaultTimeoutSecs) = 0;\n        //--------------------------------------------------------------------------------------------------\n        /// Causes the system to issue an Http POST request with the given body.\n        ///\n        /// @author S Downie\n        ///\n        /// @param URL\n        /// @param POST body\n        /// @param Key value headers to attach to the request\n        /// @param Delegate that is called on request completed. Completion can be failure as well as success\n        /// @param Request timeout in seconds\n        ///\n        /// @return A pointer to the request. The system owns this pointer.\n        //--------------------------------------------------------------------------------------------------\n        virtual HttpRequest* MakePostRequest(const std::string& in_url, const std::string& in_body, const ParamDictionary& in_headers, const HttpRequest::Delegate& in_delegate, u32 in_timeoutSecs = k_defaultTimeoutSecs) = 0;\n        //--------------------------------------------------------------------------------------------------\n        /// Equivalent to calling cancel on every incomplete request in progress.\n        ///\n        /// @author S Downie\n        //--------------------------------------------------------------------------------------------------\n        virtual void CancelAllRequests() = 0;\n        //--------------------------------------------------------------------------------------------------\n        /// Checks if the device is internet ready\n        ///\n        /// @author S Downie\n        ///\n        /// @param Delegate to call when reachability is determined\n        //--------------------------------------------------------------------------------------------------\n        virtual void CheckReachability(const ReachabilityResultDelegate& in_reachabilityDelegate) const = 0;\n        //--------------------------------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param The number of bytes read before the buffer is flushed (0 is unlimited)\n        //--------------------------------------------------------------------------------------------------\n        void SetMaxBufferSize(u32 in_sizeInBytes);\n        \n    protected:\n        \n        //--------------------------------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return The number of bytes read before the buffer is flushed\n        //--------------------------------------------------------------------------------------------------\n        u32 GetMaxBufferSize() const;\n        \n    private:\n        \n        u32 m_maxBufferSize = 0;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Networking/Http/HttpResponse.cpp",
    "content": "//\n//  HttpResponse.cpp\n//  ChilliSource\n//  Created by Scott Downie on 17/12/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2011 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Networking/Http/HttpResponse.h>\n\n#include <limits>\n\nnamespace ChilliSource\n{\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    HttpResponse::HttpResponse(Result in_result, u32 in_code, const std::string& in_data)\n    : m_data(in_data), m_result(in_result), m_code(in_code)\n    {\n        CS_ASSERT(m_data.size() < static_cast<std::string::size_type>(std::numeric_limits<u32>::max()), \"Response data is too large. Cannot exceed \"\n                  + ToString(std::numeric_limits<u32>::max()) + \" bytes.\");\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    HttpResponse::Result HttpResponse::GetResult() const\n    {\n        return m_result;\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    const u8* HttpResponse::GetData() const\n    {\n        return (const u8*)m_data.data();\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    u32 HttpResponse::GetDataSize() const\n    {\n        return static_cast<u32>(m_data.size());\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    const std::string& HttpResponse::GetDataAsString() const\n    {\n        return m_data;\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    u32 HttpResponse::GetCode() const\n    {\n        return m_code;\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Networking/Http/HttpResponse.h",
    "content": "//\n//  HttpResponse.h\n//  ChilliSource\n//  Created by Scott Downie on 17/12/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2011 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_NETWORKING_HTTP_HTTPRESPONSE_H_\n#define _CHILLISOURCE_NETWORKING_HTTP_HTTPRESPONSE_H_\n\n#include <ChilliSource/ChilliSource.h>\n\nnamespace ChilliSource\n{\n    //----------------------------------------------------------------------------------------\n    /// The response result of an http request. This contains the http response code and\n    /// the response data. The response also contains the result which is whether the request\n    /// succeeded or failed. If the request fails then the response data will be empty\n    ///\n    /// @author S Downie\n    //----------------------------------------------------------------------------------------\n    class HttpResponse final\n    {\n    public:\n        //----------------------------------------------------------------------------------------\n        /// Result of the http request\n        ///\n        /// @author S Downie\n        //----------------------------------------------------------------------------------------\n        enum class Result\n        {\n            k_completed,    //The request completed (response data is available)\n            k_failed,       //The request failed (no response data available)\n            k_timeout,      //The request timed out (no response data available)\n            k_flushed       //The request buffer is full and has been flushed. (response data is partial and more will follow)\n        };\n        //----------------------------------------------------------------------------------------\n        /// Constructor\n        ///\n        /// @param Result\n        /// @param Response code\n        /// @param Response data\n        ///\n        /// @author S Downie\n        //----------------------------------------------------------------------------------------\n        HttpResponse(Result in_result, u32 in_responseCode, const std::string& in_data);\n        //----------------------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return The result of the request (determines whether data is available)\n        //----------------------------------------------------------------------------------------\n        Result GetResult() const;\n        //----------------------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return The contents of the response. (This could be null if a failure occured)\n        //----------------------------------------------------------------------------------------\n        const u8* GetData() const;\n        //----------------------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Size of data in bytes (This could be 0 if a failure occured)\n        //----------------------------------------------------------------------------------------\n        u32 GetDataSize() const;\n        //----------------------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return The contents of the response as a string. (This could be binary data and could\n        /// also be empty if the result is failure. Some string operations may fail on binary data).\n        //----------------------------------------------------------------------------------------\n        const std::string& GetDataAsString() const;\n        //----------------------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return HTTP response code (i.e. 200 = OK).\n        //----------------------------------------------------------------------------------------\n        u32 GetCode() const;\n        \n    private:\n        \n        const std::string m_data;\n        const Result m_result;\n        const u32 m_code;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Networking/Http.h",
    "content": "//\n//  Http.h\n//  ChilliSource\n//  Created by Ian Copland on 07/07/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n\n#ifndef _CHILLISOURCE_NETWORKING_HTTP_H_\n#define _CHILLISOURCE_NETWORKING_HTTP_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Networking/Http/HttpRequest.h>\n#include <ChilliSource/Networking/Http/HttpRequestSystem.h>\n#include <ChilliSource/Networking/Http/HttpResponse.h>\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Networking/IAP/IAPSystem.cpp",
    "content": "//\n//  IAPSystem.cpp\n//  ChilliSource\n//  Created by Scott Downie on 10/06/2013.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2013 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Networking/IAP/IAPSystem.h>\n\n#ifdef CS_TARGETPLATFORM_IOS\n#include <CSBackend/Platform/iOS/Networking/IAP/IAPSystem.h>\n#endif\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n#ifdef CS_ANDROIDFLAVOUR_GOOGLEPLAY\n#include <CSBackend/Platform/Android/GooglePlay/JNI/Networking/IAP/GooglePlayIAPSystem.h>\n#elif defined(CS_ANDROIDFLAVOUR_AMAZON)\n#include <CSBackend/Platform/Android/Amazon/JNI/Networking/IAP/AmazonIAPSystem.h>\n#endif\n#endif\n\nnamespace ChilliSource\n{\n    CS_DEFINE_NAMEDTYPE(IAPSystem);\n    //---------------------------------------------------------------\n    //---------------------------------------------------------------\n    IAPSystemUPtr IAPSystem::Create(const ParamDictionary& inParams)\n    {\n#ifdef CS_TARGETPLATFORM_IOS\n        return IAPSystemUPtr(new CSBackend::iOS::IAPSystem());\n#elif defined(CS_TARGETPLATFORM_ANDROID)\n#\tifdef CS_ANDROIDFLAVOUR_GOOGLEPLAY\n        return IAPSystemUPtr(new CSBackend::Android::GooglePlayIAPSystem(inParams));\n#\telif defined(CS_ANDROIDFLAVOUR_AMAZON)\n        return IAPSystemUPtr(new CSBackend::Android::AmazonIAPSystem(inParams));\n#\tendif\n#endif\n        return nullptr;\n    }\n}\n\n"
  },
  {
    "path": "Source/ChilliSource/Networking/IAP/IAPSystem.h",
    "content": "//\n//  IAPSystem.h\n//  ChilliSource\n//  Created by Scott Downie on 10/06/2013.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2013 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_NETWORKING_IAP_IAPSYSTEM_H_\n#define _CHILLISOURCE_NETWORKING_IAP_IAPSYSTEM_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Container/ParamDictionary.h>\n#include <ChilliSource/Core/System/AppSystem.h>\n\n#include <functional>\n\nnamespace ChilliSource\n{\n    //----------------------------------------------------------------------------------\n    /// System that allows purchasing of IAPs from\n    /// the backend App Store. System allows product info\n    /// to be requested in ordrer to build displays and then\n    /// for products to be purchased. NOTE: Must StartListeningForTransactionUpdates()\n    /// before any purchases are made as this can be called with previously incomplete\n    /// transactions.\n    ///\n    /// @author S Downie\n    //----------------------------------------------------------------------------------\n    class IAPSystem : public AppSystem\n    {\n    public:\n        \n        //------------------------------------------------------\n        /// Holds the information relating to a single\n        /// transaction.\n        ///\n        /// @author S Downie\n        //------------------------------------------------------\n        struct Transaction\n        {\n            std::string m_productId;\n            std::string m_transactionId;\n            std::string m_receipt;\n            \n            enum class Status\n            {\n                k_succeeded,\n                k_failed,\n                k_cancelled,\n                k_refunded,\n                k_restored,\n                k_resumed\n            };\n        };\n        using TransactionSPtr = std::shared_ptr<Transaction>;\n        //------------------------------------------------------\n        /// Holds the description of a product as obtained\n        /// from the store\n        ///\n        /// @author S Downie\n        //------------------------------------------------------\n        struct ProductDesc\n        {\n            std::string m_id;\n            std::string m_name;\n            std::string m_description;\n            std::string m_formattedPrice;\n            std::string m_countryCode;\n        };\n        //------------------------------------------------------\n        /// Used to describe a product when registering it.\n        /// Products can be either managed or unmanaged\n        ///\n        /// @author S Downie\n        //------------------------------------------------------\n        struct ProductRegInfo\n        {\n            enum class Type\n            {\n                k_managed,\n                k_unmanaged\n            };\n            \n            std::string m_id;\n            Type m_type;\n        };\n        //------------------------------------------------------\n        /// Delegate that is triggered when a request for product\n        /// informations completes.\n        ///\n        /// @author S Downie\n        ///\n        /// @param List of product descriptions\n        //------------------------------------------------------\n        using ProductDescDelegate = std::function<void(const std::vector<ProductDesc>&)>;\n        //------------------------------------------------------\n        /// Delegate triggered when the status of a transaction\n        /// changes i.e. from pending to success.\n        ///\n        /// @author S Downie\n        ///\n        /// @param Transaction status\n        /// @param Transaction\n        //------------------------------------------------------\n        using TransactionStatusDelegate = std::function<void(Transaction::Status, const TransactionSPtr&)>;\n        //------------------------------------------------------\n        /// Delegate triggered when the transaction is closed.\n        ///\n        /// @author S Downie\n        ///\n        /// @param Product ID\n        /// @param Transaction ID\n        /// @param Success or failure\n        //------------------------------------------------------\n        using TransactionCloseDelegate = std::function<void(const std::string&, const std::string&, bool)>;\n        //------------------------------------------------------\n        /// Delegate to use in the querying of if purchasing is\n        /// enabled on the device.\n        ///\n        /// @author HMcLaughlin\n        ///\n        /// @param If purchasing is enabled\n        //------------------------------------------------------\n        using PurchasingEnabledDelegate = std::function<void(bool enabled)>;\n        \n        CS_DECLARE_NAMEDTYPE(IAPSystem);\n        \n        //---------------------------------------------------------------\n        /// Creates a new platform specfic instance of the IAP system.\n        ///\n        /// @author S Downie\n        ///\n        /// @param A param dictionary that contains platform specific\n        /// parameters for the IAP system. The possible values are:\n        /// \tGooglePlayPublicKey  \tThe public key used for connecting\n        ///\t\t\t\t\t\t\t\tto the Google Play store.\n        ///\t\tAmazonPrivateKey\t\tThe private key used to encrypt\n        ///\t\t\t\t\t\t\t\tthe on disk Amazon IAP cache.\n        //---------------------------------------------------------------\n        static IAPSystemUPtr Create(const ParamDictionary& in_params);\n        //---------------------------------------------------------------\n        /// Inform the system of which products are available for\n        /// purchase and whether they are managed or unmanaged\n        ///\n        /// @author S Downie\n        ///\n        /// @param List of products\n        //---------------------------------------------------------------\n        virtual void RegisterProducts(const std::vector<ProductRegInfo>& in_productInfos) = 0;\n        //---------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return The ID off the IAP provider as a string.\n        //---------------------------------------------------------------\n        virtual std::string GetProviderID() const = 0;\n        //---------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Purchasing enabled delegate\n        //---------------------------------------------------------------\n        virtual void IsPurchasingEnabled(const PurchasingEnabledDelegate& in_delegate) = 0;\n        //---------------------------------------------------------------\n        /// Calling this function will set the listener to which any\n        /// transaction events are directed. This is not necessarily\n        /// in response to a user action it may be previously outstanding\n        /// transactions.\n        ///\n        /// @author S Downie\n        ///\n        /// @param Transaction status changed delegate\n        //---------------------------------------------------------------\n        virtual void StartListeningForTransactionUpdates(const TransactionStatusDelegate& in_delegate) = 0;\n        //---------------------------------------------------------------\n        /// Prevent any more transaction uppdates from being triggered.\n        ///\n        /// @author S Downie\n        //---------------------------------------------------------------\n        virtual void StopListeningForTransactionUpdates() = 0;\n        //---------------------------------------------------------------\n        /// Starts a request to the store for details of all registered\n        /// products. These details are name, description and price\n        ///\n        /// @author S Downie\n        ///\n        /// @param Delegate to invoke when the request completes\n        //---------------------------------------------------------------\n        virtual void RequestAllProductDescriptions(const ProductDescDelegate& in_delegate) = 0;\n        //---------------------------------------------------------------\n        /// Starts a request to the store for details of the products.\n        /// These details are name, description and price\n        ///\n        /// @author S Downie\n        ///\n        /// @param List of product IDs to request descriptions for\n        /// @param Delegate to invoke when the request completes\n        //---------------------------------------------------------------\n        virtual void RequestProductDescriptions(const std::vector<std::string>& in_productIds, const ProductDescDelegate& in_delegate) = 0;\n        //---------------------------------------------------------------\n        /// Prevent the completion delegate being called for\n        /// any pending product description requests and attempt to\n        /// cancel the request to the store.\n        ///\n        /// @author S Downie\n        //---------------------------------------------------------------\n        virtual void CancelProductDescriptionsRequest() = 0;\n        //---------------------------------------------------------------\n        /// Make a request to the store to purchase the item.\n        /// This will trigger a call to the transaction listener delegate\n        ///\n        /// @author S Downie\n        ///\n        /// @param Product ID\n        //---------------------------------------------------------------\n        virtual void RequestProductPurchase(const std::string& in_productId) = 0;\n        //---------------------------------------------------------------\n        /// Tell the store to close the transaction as complete.\n        /// NOTE: This should only be called after the goods have been\n        /// awarded.\n        ///\n        /// @author S Downie\n        ///\n        /// @param Transaction to close\n        /// @param Delegate to call when closed (either with failure or success)\n        //---------------------------------------------------------------\n        virtual void CloseTransaction(const TransactionSPtr& in_transaction, const TransactionCloseDelegate& in_delegate) = 0;\n        //---------------------------------------------------------------\n        /// Request that the store trigger new purchase requests for\n        /// owned non-consumable items\n        ///\n        /// @author S Downie\n        //---------------------------------------------------------------\n        virtual void RestoreManagedPurchases() = 0;\n        //---------------------------------------------------------------\n        /// Virtual destructor\n        ///\n        /// @author S Downie\n        //---------------------------------------------------------------\n        virtual ~IAPSystem(){}\n    };\n}\n\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Networking/IAP.h",
    "content": "//\n//  IAP.h\n//  ChilliSource\n//  Created by Ian Copland on 07/07/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n\n#ifndef _CHILLISOURCE_NETWORKING_IAP_H_\n#define _CHILLISOURCE_NETWORKING_IAP_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Networking/IAP/IAPSystem.h>\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Base/AlignmentAnchors.cpp",
    "content": "//\n//  AlignmentAnchors.cpp\n//  ChilliSource\n//  Created by Scott Downie on 22/04/2011.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2011 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Base/AlignmentAnchors.h>\n\nnamespace ChilliSource\n{\n    //--------------------------------------------------------------\n    //---------------------------------------------------------------\n    Vector2 GetAnchorPoint(AlignmentAnchor in_alignment, const Vector2& in_halfSize)\n    {\n        Vector2 output;\n        \n        //Vertical alignment\n        switch (in_alignment)\n        {\n            case AlignmentAnchor::k_topLeft:\n            case AlignmentAnchor::k_topCentre:\n            case AlignmentAnchor::k_topRight:\n                output.y = in_halfSize.y;\n                break;\n            case AlignmentAnchor::k_middleLeft:\n            case AlignmentAnchor::k_middleCentre:\n            case AlignmentAnchor::k_middleRight:\n                output.y = 0;\n                break;\t\t\t\t\n            case AlignmentAnchor::k_bottomLeft:\n            case AlignmentAnchor::k_bottomCentre:\n            case AlignmentAnchor::k_bottomRight:\n                output.y = -in_halfSize.y;\n                break;\n            default:\n                break;\n        }\n        \n        //Horizontal alignment\n        switch (in_alignment)\n        {\n            case AlignmentAnchor::k_topLeft:\n            case AlignmentAnchor::k_middleLeft:\n            case AlignmentAnchor::k_bottomLeft:\n                output.x = -in_halfSize.x;\n                break;\n                \n            case AlignmentAnchor::k_topCentre:\n            case AlignmentAnchor::k_middleCentre:\n            case AlignmentAnchor::k_bottomCentre:\n                output.x = 0;\n                break;\t\n                \n            case AlignmentAnchor::k_topRight:\n            case AlignmentAnchor::k_middleRight:\n            case AlignmentAnchor::k_bottomRight:\n                output.x = in_halfSize.x;\n                break;\n            default:\n                break;\n        }\n        \n        return output;\n    }\n    //---------------------------------------------------------------\n    //---------------------------------------------------------------\n    AlignmentAnchor ParseAlignmentAnchor(const std::string& in_string)\n    {\n        if(in_string == \"MiddleCentre\")\n        {\n            return AlignmentAnchor::k_middleCentre;\n        }\n        else if(in_string == \"TopLeft\")\n        {\n            return AlignmentAnchor::k_topLeft;\n        }\n        else if(in_string == \"TopRight\")\n        {\n            return AlignmentAnchor::k_topRight;\n        }\n        else if(in_string == \"BottomLeft\")\n        {\n            return AlignmentAnchor::k_bottomLeft;\n        }\n        else if(in_string == \"BottomRight\")\n        {\n            return AlignmentAnchor::k_bottomRight;\n        }\n        else if(in_string == \"MiddleLeft\")\n        {\n            return AlignmentAnchor::k_middleLeft;\n        }\n        else if(in_string == \"MiddleRight\")\n        {\n            return AlignmentAnchor::k_middleRight;\n        }\n        else if(in_string == \"TopCentre\")\n        {\n            return AlignmentAnchor::k_topCentre;\n        }\n        else if(in_string == \"BottomCentre\")\n        {\n            return AlignmentAnchor::k_bottomCentre;\n        }\n        else\n        {\n            CS_LOG_ERROR(\"Alignment Anchor: Invalid string \" + in_string);\n            return AlignmentAnchor::k_middleCentre;\n        }\n    }\n    //---------------------------------------------------------------\n    //---------------------------------------------------------------\n    std::string StringFromAlignmentAnchor(AlignmentAnchor in_alignmentAnchor)\n    {\n        switch (in_alignmentAnchor)\n        {\n        case AlignmentAnchor::k_topLeft:\n            return \"TopLeft\";\n        case AlignmentAnchor::k_topRight:\n            return \"TopRight\";\n        case AlignmentAnchor::k_topCentre:\n            return \"TopCentre\";\n        case AlignmentAnchor::k_middleLeft:\n            return \"MiddleLeft\";\n        case AlignmentAnchor::k_middleRight:\n            return \"MiddleRight\";\n        case AlignmentAnchor::k_middleCentre:\n            return \"MiddleCentre\";\n        case AlignmentAnchor::k_bottomLeft:\n            return \"BottomLeft\";\n        case AlignmentAnchor::k_bottomRight:\n            return \"BottomRight\";\n        case AlignmentAnchor::k_bottomCentre:\n            return \"BottomCentre\";\n        default:\n            CS_LOG_ERROR(\"Invalid alignment anchor.\");\n            return \"\";\n        }\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Base/AlignmentAnchors.h",
    "content": "//\n//  AlignmentAnchors.h\n//  ChilliSource\n//  Created by Scott Downie on 22/04/2011.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2011 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n\n#ifndef _CHILLISOURCE_CORE_ALIGNMENT_ANCHORS_H_\n#define _CHILLISOURCE_CORE_ALIGNMENT_ANCHORS_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Math/Vector2.h>\n\nnamespace ChilliSource\n{\n    //---------------------------------------------------------------\n    /// Anchor points for view alignment.\n    ///\n    /// @author S Downie\n    //---------------------------------------------------------------\n    enum class AlignmentAnchor\n    {\n        k_topLeft,\n        k_topRight,\n        k_topCentre,\n        k_middleLeft,\n        k_middleRight,\n        k_middleCentre,\n        k_bottomLeft,\n        k_bottomRight,\n        k_bottomCentre\n    };\n    //---------------------------------------------------------------\n    /// Calculate the alignment anchor point based on the anchor\n    /// and the size\n    ///\n    /// @author S Downie\n    ///\n    /// @param Anchor type\n    /// @param Half size\n    ///\n    /// @return The anchor point.\n    //---------------------------------------------------------------\n    Vector2 GetAnchorPoint(AlignmentAnchor in_alignment, const Vector2& in_halfSize);\n    //---------------------------------------------------------------\n    /// @author S Downie\n    ///\n    /// @param The string to parse.\n    ///\n    /// @return Alignment anchor type corresponding to given string\n    //---------------------------------------------------------------\n    AlignmentAnchor ParseAlignmentAnchor(const std::string& in_string);\n    //---------------------------------------------------------------\n    /// @author S Downie\n    ///\n    /// @param Alignment Anchor\n    /// @return String.\n    //---------------------------------------------------------------\n    std::string StringFromAlignmentAnchor(AlignmentAnchor in_alignmentAnchor);\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Base/AspectRatioUtils.cpp",
    "content": "//\n//  AspectRatioUtils.cpp\n//  ChilliSource\n//  Created by S Downie on 24/06/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Base/AspectRatioUtils.h>\n\n#include <ChilliSource/Core/Math/Vector2.h>\n\nnamespace ChilliSource\n{\n    namespace AspectRatioUtils\n    {\n        //----------------------------------------------------------------------------------------\n        //----------------------------------------------------------------------------------------\n        Vector2 KeepOriginalWidthAdaptHeight(const Vector2& in_originalSize, f32 in_preferredAspectRatio)\n        {\n            CS_ASSERT(in_preferredAspectRatio > 0.0f, \"Aspect ratio must be greater than zero\");\n            \n            f32 targetAspectRatio = 1.0f/in_preferredAspectRatio;\n            f32 originalHeight = (targetAspectRatio * in_originalSize.x);\n            return Vector2(in_originalSize.x, originalHeight);\n        }\n        //----------------------------------------------------------------------------------------\n        //----------------------------------------------------------------------------------------\n        Vector2 KeepOriginalHeightAdaptWidth(const Vector2& in_originalSize, f32 in_preferredAspectRatio)\n        {\n            f32 originalWidth = (in_preferredAspectRatio * in_originalSize.y);\n            return Vector2(originalWidth, in_originalSize.y);\n        }\n        //----------------------------------------------------------------------------------------\n        //----------------------------------------------------------------------------------------\n        Vector2 FillOriginal(const Vector2& in_originalSize, f32 in_preferredAspectRatio)\n        {\n            f32 originalRatio = in_originalSize.x / in_originalSize.y;\n            \n            if(in_preferredAspectRatio <= originalRatio)\n            {\n                return KeepOriginalWidthAdaptHeight(in_originalSize, in_preferredAspectRatio);\n            }\n            else\n            {\n                return KeepOriginalHeightAdaptWidth(in_originalSize, in_preferredAspectRatio);\n            }\n        }\n        //----------------------------------------------------------------------------------------\n        //----------------------------------------------------------------------------------------\n        Vector2 FitOriginal(const Vector2& in_originalSize, f32 in_preferredAspectRatio)\n        {\n            f32 originalRatio = in_originalSize.x / in_originalSize.y;\n            \n            if(in_preferredAspectRatio > originalRatio)\n            {\n                return KeepOriginalWidthAdaptHeight(in_originalSize, in_preferredAspectRatio);\n            }\n            else\n            {\n                return KeepOriginalHeightAdaptWidth(in_originalSize, in_preferredAspectRatio);\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Base/AspectRatioUtils.h",
    "content": "//\n//  AspectRatioUtils.h\n//  ChilliSource\n//  Created by S Downie on 24/06/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_BASE_ASPECTRATIOUTILS_H_\n#define _CHILLISOURCE_RENDERING_BASE_ASPECTRATIOUTILS_H_\n\n#include <ChilliSource/ChilliSource.h>\n\nnamespace ChilliSource\n{\n    //--------------------------------------------------------------------\n    /// Utility methods for calculating a size based on the given\n    /// size and preferred aspect ratio.\n    ///\n    /// @author S Downie\n    //--------------------------------------------------------------------\n    namespace AspectRatioUtils\n    {\n        //----------------------------------------------------------------------------------------\n        /// Aspect ratio maintaining function that keeps the original width but adapts\n        /// the height to maintain the aspect ratio\n        ///\n        /// @author S Downie\n        ///\n        /// @param Original size\n        /// @param Preferred aspect ratio\n        ///\n        /// @return Size with aspect maintained\n        //----------------------------------------------------------------------------------------\n        Vector2 KeepOriginalWidthAdaptHeight(const Vector2& in_originalSize, f32 in_preferredAspectRatio);\n        //----------------------------------------------------------------------------------------\n        /// Aspect ratio maintaining function that keeps the original height but adapts\n        /// the width to maintain the aspect ratio\n        ///\n        /// @author S Downie\n        ///\n        /// @param Original size\n        /// @param Preferred aspect ratio\n        ///\n        /// @return Size with aspect maintained\n        //----------------------------------------------------------------------------------------\n        Vector2 KeepOriginalHeightAdaptWidth(const Vector2& in_originalSize, f32 in_preferredAspectRatio);\n        //----------------------------------------------------------------------------------------\n        /// Aspect ratio maintaining function that maintains the given target aspect ratio\n        /// while ensuring the size does not DROP BELOW the original size\n        ///\n        /// @author S Downie\n        ///\n        /// @param Original size\n        /// @param Preferred aspect ratio\n        ///\n        /// @return Size with aspect maintained\n        //----------------------------------------------------------------------------------------\n        Vector2 FillOriginal(const Vector2& in_originalSize, f32 in_preferredAspectRatio);\n        //----------------------------------------------------------------------------------------\n        /// Aspect ratio maintaining function that maintains the given target aspect ratio\n        /// while ensuring the size does not EXCEED the original size\n        ///\n        /// @author S Downie\n        ///\n        /// @param Original size\n        /// @param Preferred aspect ratio\n        ///\n        /// @return Size with aspect maintained\n        //----------------------------------------------------------------------------------------\n        Vector2 FitOriginal(const Vector2& in_originalSize, f32 in_preferredAspectRatio);\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Base/BlendMode.h",
    "content": "//\n//  BlendMode.h\n//  ChilliSource\n//  Created by Scott Downie on 09/04/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_BASE_BLENDMODE_H_\n#define _CHILLISOURCE_RENDERING_BASE_BLENDMODE_H_\n\nnamespace ChilliSource\n{\n    /// The blend modes that are used to describe\n    /// a blend function for rendering. The blend\n    /// function takes 2 modes - the source and\n    /// the destination.\n    ///\n    enum class BlendMode\n    {\n        k_zero,\n        k_one,\n        k_sourceCol,\n        k_oneMinusSourceCol,\n        k_sourceAlpha,\n        k_oneMinusSourceAlpha,\n        k_destCol,\n        k_oneMinusDestCol,\n        k_destAlpha,\n        k_oneMinusDestAlpha\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Base/CameraRenderPassGroup.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2010 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Base/CameraRenderPassGroup.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    CameraRenderPassGroup::CameraRenderPassGroup(const RenderCamera& camera, std::vector<RenderPass> renderPasses) noexcept\n        : m_camera(camera), m_renderPasses(std::move(renderPasses))\n    {\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Base/CameraRenderPassGroup.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_BASE_CAMERARENDERPASSGROUP_H_\n#define _CHILLISOURCE_RENDERING_BASE_CAMERARENDERPASSGROUP_H_\n\n#include <ChilliSource/ChilliSource.h>\n\n#include <ChilliSource/Rendering/Base/RenderPass.h>\n#include <ChilliSource/Rendering/Camera/RenderCamera.h>\n\n#include <vector>\n\nnamespace ChilliSource\n{\n    /// Provides the ability to group a number of render passes based on them sharing\n    /// the same camera\n    ///\n    /// This is immutable and therefore thread-safe\n    ///\n    class CameraRenderPassGroup final\n    {\n    public:\n        CS_DECLARE_NOCOPY(CameraRenderPassGroup);\n        \n        CameraRenderPassGroup() = default;\n        CameraRenderPassGroup(CameraRenderPassGroup&&) = default;\n        CameraRenderPassGroup& operator=(CameraRenderPassGroup&&) = default;\n        \n        /// @param camera\n        ///     The camera to use for this pass\n        /// @param renderPasses\n        ///     The list of render passes to carry out with the camera. Must be moved.\n        ///\n        CameraRenderPassGroup(const RenderCamera& camera, std::vector<RenderPass> renderPasses) noexcept;\n        \n        /// @return The camera to use for rendering the group\n        ///\n        const RenderCamera& GetCamera() const noexcept { return m_camera; }\n        \n        /// @return The list of render passes in this group\n        ///\n        const std::vector<RenderPass>& GetRenderPasses() const noexcept { return m_renderPasses; }\n        \n    private:\n        RenderCamera m_camera;\n        std::vector<RenderPass> m_renderPasses;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Base/CanvasDrawMode.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Base/CanvasDrawMode.h>\n\n#include <ChilliSource/Core/String/StringUtils.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    CanvasDrawMode ParseCanvasDrawMode(const std::string& modeString) noexcept\n    {\n        std::string lowerCase = modeString;\n        StringUtils::ToLowerCase(lowerCase);\n        \n        if(lowerCase == \"standard\") return CanvasDrawMode::k_standard;\n        if(lowerCase == \"mask\") return CanvasDrawMode::k_mask;\n        if(lowerCase == \"maskonly\") return CanvasDrawMode::k_maskOnly;\n        \n        CS_LOG_FATAL(\"Cannot parse canvas draw mode: \" + modeString);\n        return CanvasDrawMode::k_standard;\n    }\n}\n\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Base/CanvasDrawMode.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_BASE_CANVASDRAWMODE_H_\n#define _CHILLISOURCE_RENDERING_BASE_CANVASDRAWMODE_H_\n\n#include <ChilliSource/ChilliSource.h>\n\nnamespace ChilliSource\n{\n    /// Describes how the a canvas shape should be rendered\n    ///\n    /// - Standard - Renders to canvas in the standard way\n    /// - Mask - Renders to canvas and also creates a mask\n    /// - Mask Only - Doesn't render to canvas, only creates an invisible mask\n    ///\n    enum class CanvasDrawMode\n    {\n        k_standard,\n        k_mask,\n        k_maskOnly\n    };\n    \n    /// Converts a string to a draw mode (case insensitive)\n    /// Fails hard if mode unknown\n    ///\n    /// @param modeString\n    ///     Draw mode in string format\n    ///\n    /// @return CanvasDrawMode\n    ///\n    CanvasDrawMode ParseCanvasDrawMode(const std::string& modeString) noexcept;\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Base/CanvasMaterialPool.cpp",
    "content": "//\n//  CanvasMaterialPool.cpp\n//  ChilliSource\n//  Created by Ian Copland on 30/07/2015\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2015 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Base/CanvasMaterialPool.h>\n\n#include <ChilliSource/Rendering/Material/Material.h>\n#include <ChilliSource/Rendering/Material/MaterialFactory.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    CanvasMaterialPool::CanvasMaterialPool(MaterialFactory* materialFactory, const std::string& materialNamePrefix, const MaterialSetupDelegate& materialSetupDelegate)\n        : m_materialFactory(materialFactory), m_materialNamePrefix(materialNamePrefix), m_materialSetupDelegate(materialSetupDelegate)\n    {\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    MaterialCSPtr CanvasMaterialPool::GetMaterial(const TextureCSPtr& in_texture, s32 stencilRef)\n    {\n        auto it = m_associations.find(std::make_tuple(in_texture.get(), stencilRef));\n        if(it != m_associations.end())\n        {\n            return it->second;\n        }\n        \n        if (m_nextMaterial >= m_materials.size())\n        {\n            auto material = m_materialFactory->CreateCustom(m_materialNamePrefix + ToString(m_materials.size()));\n            m_materialSetupDelegate(material.get());\n            m_materials.push_back(material);\n            CS_ASSERT(m_nextMaterial < m_materials.size(), \"We've added a new material yet we still don't have enough - something has gone wrong.\");\n        }\n        \n        auto material = m_materials[m_nextMaterial++];\n        material->AddTexture(in_texture);\n        material->SetStencilTestFunc(material->GetStencilTestFunc(), stencilRef, material->GetStencilTestFuncMask());\n        material->SetLoadState(Resource::LoadState::k_loaded);\n        \n        m_associations.emplace(std::make_tuple(in_texture.get(), stencilRef), material);\n        return material;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void CanvasMaterialPool::Clear()\n    {\n        m_nextMaterial = 0;\n        m_associations.clear();\n        \n        for (auto& material : m_materials)\n        {\n            material->SetLoadState(Resource::LoadState::k_loading);\n            material->RemoveAllTextures();\n        }\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Base/CanvasMaterialPool.h",
    "content": "//\n//  CanvasMaterialPool.h\n//  ChilliSource\n//  Created by Ian Copland on 30/07/2015\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2015 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_BASE_CANVASMATERIALPOOL_H_\n#define _CHILLISOURCE_RENDERING_BASE_CANVASMATERIALPOOL_H_\n\n#include <ChilliSource/ChilliSource.h>\n\n#include <functional>\n#include <tuple>\n#include <vector>\n#include <unordered_map>\n\nnamespace ChilliSource\n{\n    /// Materials are not exposed to the user of the canvas renderer, but it still\n    /// internally uses materials for rendering. This manages those materials,\n    /// providing a means to get a shared material for the given texture and stencil mask,\n    /// ensuring objects with the same values can be rendered as part of the same batch.\n    /// Materials can be re-used for different textures in subsequent frames.\n    ///\n    class CanvasMaterialPool final\n    {\n    public:\n        \n        using MaterialSetupDelegate = std::function<void(Material*)>;\n        \n        /// @param materialFactory\n        ///     The material factory which is used to generate new materials as required.\n        /// @param materialNamePrefix\n        ///     The base name for any created materials\n        /// @param materialSetupDelegate\n        ///     Called after creating a material allowing it to be customised\n        ///\n        CanvasMaterialPool(MaterialFactory* materialFactory, const std::string& materialNamePrefix, const MaterialSetupDelegate& materialSetupDelegate);\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param in_texture - The texture for which to get a material\n        ///\n        /// @return The material associated with the given texture.\n        //------------------------------------------------------------------------------\n        MaterialCSPtr GetMaterial(const TextureCSPtr& texture, s32 stencilRef);\n        //------------------------------------------------------------------------------\n        /// Clears all associations between textures and materials, ensuring the\n        /// the materials no longer reference the previously associated texture.\n        /// After this is called the materials can be re-used for other textures.\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------------------------------------\n        void Clear();\n        \n    private:\n        \n        // Unique identifier for canvas materials (texture and stencil mask)\n        using Key = std::tuple<const Texture*, s32>;\n        \n        struct KeyHash : public std::unary_function<Key, std::size_t>\n        {\n            /// Custom hashing functor for the Key tuple.\n            ///\n            /// @param key\n            ///     Tuple containing texture and stencil\n            /// @return Hash of the given tuple\n            ///\n            std::size_t operator()(const Key& key) const\n            {\n                return std::size_t(std::get<0>(key)) ^ std::get<1>(key);\n            }\n        };\n        \n        MaterialSetupDelegate m_materialSetupDelegate;\n        std::string m_materialNamePrefix;\n        MaterialFactory* m_materialFactory = nullptr;\n        u32 m_nextMaterial = 0;\n        std::vector<MaterialSPtr> m_materials;\n        std::unordered_map<Key, MaterialCSPtr, KeyHash> m_associations;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Base/CanvasRenderer.cpp",
    "content": "//\n//  CanvasRenderer.cpp\n//  ChilliSource\n//  Created by Scott Downie on 12/01/2011.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2011 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Base/CanvasRenderer.h>\n\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/Base/ColourUtils.h>\n#include <ChilliSource/Core/Math/MathUtils.h>\n#include <ChilliSource/Core/Resource/ResourcePool.h>\n#include <ChilliSource/Core/State/State.h>\n#include <ChilliSource/Core/State/StateManager.h>\n#include <ChilliSource/Core/String/UTF8StringUtils.h>\n#include <ChilliSource/Rendering/Base/CanvasDrawMode.h>\n#include <ChilliSource/Rendering/Base/RenderSnapshot.h>\n#include <ChilliSource/Rendering/Base/StencilOp.h>\n#include <ChilliSource/Rendering/Base/TargetType.h>\n#include <ChilliSource/Rendering/Base/TestFunc.h>\n#include <ChilliSource/Rendering/Font/Font.h>\n#include <ChilliSource/Rendering/Material/Material.h>\n#include <ChilliSource/Rendering/Material/MaterialFactory.h>\n#include <ChilliSource/Rendering/Shader/Shader.h>\n#include <ChilliSource/Rendering/Sprite/SpriteMeshBuilder.h>\n#include <ChilliSource/Rendering/Texture/Texture.h>\n#include <ChilliSource/UI/Base/Canvas.h>\n#include <ChilliSource/UI/Base/CursorSystem.h>\n\n#include <algorithm>\n\nnamespace ChilliSource\n{\n    namespace\n    {\n        const f32 k_maxAutoScaleIterations = 10.0f;//Max number of recursions to find the correct scale\n        const f32 k_autoScaleTolerance = 0.01f;//Min difference in max/min scaling to warrant further recursion for AutoScaled text\n        const u32 k_uiStencilMaskChannel = 0x0000000f; //The \"channel\" of the stencil buffer used by the UI. If other systems use the stencil buffer they must use an alternate channel\n        \n        //------------------------------------------------------\n        /// Converts a 2D transformation matrix to a 3D\n        /// Transformation matrix. This will only work for\n        /// non-projective transforms.\n        ///\n        /// @author S Downie\n        ///\n        /// @param The 2D Transform.\n        ///\n        /// @return The 3D Transform.\n        //------------------------------------------------------\n        template <typename TType> GenericMatrix4<TType> Convert2DTransformTo3D(const GenericMatrix3<TType>& in_transform)\n        {\n            return GenericMatrix4<TType>(\n                in_transform.m[0], in_transform.m[1], in_transform.m[2], 0,\n                in_transform.m[3], in_transform.m[4], in_transform.m[5], 0,\n                0, 0, 1, 0,\n                in_transform.m[6], in_transform.m[7], 0, 1);\n        }\n        //----------------------------------------------------------------------------\n        /// Get the width of the character\n        ///\n        /// @author S Downie\n        ///\n        /// @param Character\n        /// @param Font\n        /// @param The absolute character spacing offset.\n        /// @param The text scale factor.\n        //----------------------------------------------------------------------------\n        f32 GetCharacterWidth(UTF8Char in_character, const FontCSPtr& in_font, f32 in_absCharSpacingOffset, f32 in_textScale)\n        {\n            Font::CharacterInfo charInfo;\n            if(in_font->TryGetCharacterInfo(in_character, charInfo) == true)\n            {\n                return (charInfo.m_advance + in_absCharSpacingOffset) * in_textScale;\n            }\n\n            return 0.0f;\n        }\n        //----------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Character\n        ///\n        /// @return Whether the character can safely be line broken on.\n        //----------------------------------------------------------------------------\n        bool IsBreakableCharacter(UTF8Char in_character)\n        {\n            return in_character == ' ' || in_character == '\\t' || in_character == '\\n' || in_character == '-';\n        }\n        //----------------------------------------------------------------------------\n        /// Calculate the distance in text space to the next 'breakable' character\n        ///\n        /// @author S Downie\n        ///\n        /// @param Iterator pointing to start\n        /// @param Iterator pointing to end\n        /// @param Font\n        /// @param The absolute character spacing offset.\n        /// @param The text scale factor.\n        //----------------------------------------------------------------------------\n        f32 CalculateDistanceToNextBreak(std::string::const_iterator in_itStart, std::string::const_iterator in_itEnd, const FontCSPtr& in_font, f32 in_absCharSpacingOffset, f32 in_textScale)\n        {\n            f32 totalWidth = 0.0f;\n            \n            while(in_itStart < in_itEnd)\n            {\n                auto nextCharacter = UTF8StringUtils::Next(in_itStart);\n                if (IsBreakableCharacter(nextCharacter) == true)\n                {\n                    break;\n                }\n                \n                totalWidth += GetCharacterWidth(nextCharacter, in_font, in_absCharSpacingOffset, in_textScale);\n            }\n\n            return totalWidth;\n        }\n        //----------------------------------------------------------------------------\n        /// Split the given text into lines based on any '\\n' characters. The newline\n        /// characters do not appear in the returned lines\n        ///\n        /// @author S Downie\n        ///\n        /// @param Text (UTF-8)\n        /// @param [Out] Array of lines split by '\\n'\n        //----------------------------------------------------------------------------\n        void SplitByNewLine(const std::string& in_text, std::vector<std::string>& out_lines)\n        {\n            auto it = in_text.begin();\n            std::string line;\n            while(it < in_text.end())\n            {\n                auto character = UTF8StringUtils::Next(it);\n\n                if(character != '\\n')\n                {\n                    UTF8StringUtils::Append(character, line);\n                }\n                else\n                {\n                    out_lines.push_back(line);\n                    line.clear();\n                }\n            }\n\n            if(line.size() > 0)\n            {\n                out_lines.push_back(line);\n            }\n        }\n        //----------------------------------------------------------------------------\n        /// Split the given text into lines based on the constrained bounds.\n        /// Splits will prefer to happen on breakable whitespace characters but\n        /// will split mid-word if neccessary.\n        ///\n        /// @author S Downie\n        ///\n        /// @param Text (UTF-8)\n        /// @param Font\n        /// @param Text scale\n        /// @param The absolute character spacing offset.\n        /// @param Bounds\n        /// @param [Out] Array of lines split to fit in bounds\n        //----------------------------------------------------------------------------\n        void SplitByBounds(const std::string& in_text, const FontCSPtr& in_font, f32 in_absCharSpacingOffset, f32 in_textScale, const Vector2& in_bounds, CanvasRenderer::WrappedText& out_lines)\n        {\n            f32 maxLineWidth = in_bounds.x;\n\n            auto it = in_text.begin();\n            std::string line;\n            f32 currentLineWidth = 0.0f;\n\n            while(it < in_text.end())\n            {\n                auto character = UTF8StringUtils::Next(it);\n                f32 characterWidth = GetCharacterWidth(character, in_font, in_absCharSpacingOffset, in_textScale);\n                \n                //If we come across a character on which we can wrap we need\n                //to check ahead to see if the next space is within the bounds or\n                //whether we need to wrap now\n                if(IsBreakableCharacter(character) == true)\n                {\n                    f32 nextBreakWidth = currentLineWidth + characterWidth + CalculateDistanceToNextBreak(it, in_text.end(), in_font, in_absCharSpacingOffset, in_textScale);\n\n                    if(nextBreakWidth >= maxLineWidth && line.size() > 0)\n                    {\n                        out_lines.push_back(line);\n                        line.clear();\n                        currentLineWidth = 0.0f;\n                        \n                        //since we've broken mid line we don't want to start the next line with\n                        //whitespace. To ensure this we want to jump the cursor forward to find\n                        //the next non-breakable character.\n                        auto nextIt = it;\n                        UTF8Char nextCharacter = UTF8StringUtils::Next(nextIt);\n                        while (IsBreakableCharacter(nextCharacter) == true)\n                        {\n                            it = nextIt;\n                            nextCharacter = UTF8StringUtils::Next(nextIt);\n                        }\n                        \n                        continue;\n                    }\n                }\n                \n                //If this is not a breakable character, but it is still beyond the bounds\n                //then wrap anyway, even though we are mid word.\n                else if((currentLineWidth + characterWidth) >= maxLineWidth)\n                {\n                    out_lines.push_back(line);\n                    line.clear();\n                    currentLineWidth = 0.0f;\n                }\n                \n                currentLineWidth += characterWidth;\n                UTF8StringUtils::Append(character, line);\n            }\n\n            if(line.size() > 0)\n            {\n                out_lines.push_back(line);\n            }\n        }\n        //----------------------------------------------------------------------------\n        /// Create the data required to display a character. This includes\n        /// the size, UV and position.\n        ///\n        /// @author S Downie\n        ///\n        /// @param Character\n        /// @param Font\n        /// @param Current cursor X pos\n        /// @param Current cursor Y pos\n        /// @param Text scale\n        /// @param The character spacing offset in pixels.\n        ///\n        /// @return Display characer info\n        //----------------------------------------------------------------------------\n        CanvasRenderer::DisplayCharacterInfo BuildCharacter(UTF8Char in_character, const FontCSPtr& in_font, f32 in_cursorX, f32 in_cursorY, f32 in_textScale, f32 in_absCharSpacingOffset)\n        {\n            CanvasRenderer::DisplayCharacterInfo result;\n\n            Font::CharacterInfo info;\n            if(in_font->TryGetCharacterInfo(in_character, info) == true)\n            {\n                result.m_UVs = info.m_UVs;\n                result.m_advance = ((info.m_advance + in_absCharSpacingOffset) * in_textScale);\n                result.m_packedImageSize = info.m_size * in_textScale;\n                result.m_position.x = in_cursorX + (info.m_offset.x - info.m_origin) * in_textScale;\n                result.m_position.y = in_cursorY - (info.m_offset.y - in_font->GetVerticalPadding()) * in_textScale;\n            }\n            else\n            {\n                CS_LOG_ERROR(\"Unknown character not provided by font: \" + in_font->GetName());\n            }\n\n            return result;\n        }\n        //----------------------------------------------------------------------------\n        /// The text by default is left justfied. If another justification\n        /// is required this function will update the character positions of a given line\n        ///\n        /// @author S Downie\n        ///\n        /// @param Horizontal justification\n        /// @param Bounds width\n        /// @param Index of the first character in a line\n        /// @param Index of the last character in a line\n        /// @param Line width in text space.\n        /// @param [In/Out] List of display character infos that will be manipulated.\n        ///         These are the charcters for all lines.\n        //----------------------------------------------------------------------------\n        void ApplyHorizontalTextJustifications(HorizontalTextJustification in_horizontal, f32 in_boundsWidth, u32 in_lineStartIdx, u32 in_lineEndIdx, f32 in_lineWidth,\n                                               std::vector<CanvasRenderer::DisplayCharacterInfo>& inout_characters)\n        {\n            f32 horizontalOffset = 0.0f;\n\n            switch(in_horizontal)\n            {\n                default:\n                case HorizontalTextJustification::k_left:\n                    return;\n                case HorizontalTextJustification::k_centre:\n                    horizontalOffset = (in_boundsWidth * 0.5f) - (in_lineWidth * 0.5f);\n                    break;\n                case HorizontalTextJustification::k_right:\n                    horizontalOffset = in_boundsWidth - in_lineWidth;\n                    break;\n            }\n\n            for(u32 i = in_lineStartIdx; i <= in_lineEndIdx; ++i)\n            {\n                inout_characters[i].m_position.x += horizontalOffset;\n            }\n        }\n        //----------------------------------------------------------------------------\n        /// The text by default is top justified. If another justification\n        /// is required this function will update all the characters positions\n        ///\n        /// @author S Downie\n        ///\n        /// @param Vertical justification\n        /// @param Bounds height\n        /// @param Height of all the built lines combined\n        /// @param [In/Out] List of display character infos that will be manipulated\n        //----------------------------------------------------------------------------\n        void ApplyVerticalTextJustifications(VerticalTextJustification in_vertical, f32 in_boundsHeight, f32 in_totalLinesHeight, std::vector<CanvasRenderer::DisplayCharacterInfo>& inout_characters)\n        {\n            f32 verticalOffset = 0.0f;\n\n            switch(in_vertical)\n            {\n                default:\n                case VerticalTextJustification::k_top:\n                    return;\n                case VerticalTextJustification::k_centre:\n                    verticalOffset = (in_boundsHeight * 0.5f) - (in_totalLinesHeight * 0.5f);\n                    break;\n                case VerticalTextJustification::k_bottom:\n                    verticalOffset = in_boundsHeight - in_totalLinesHeight;\n                    break;\n            }\n\n            for(auto& character : inout_characters)\n            {\n                character.m_position.y -= verticalOffset;\n            }\n        }\n        //----------------------------------------------------------------------------\n        /// Adds an ellipsis to the end of the line of text without increasing the\n        /// width of the line of text beyond the given length. If required, characters\n        /// will be removed from the string.\n        ///\n        /// If the font doesn't contain '.' the original string will simply be returned.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The string to add the ellipsis to.\n        /// @param The font the string will be renderered with.\n        /// @param The absolute pixel offset to regular character spacing.\n        /// @param The text scale factor.\n        /// @param The maximum pixel width of the text.\n        ///\n        /// @return The output string with ellipsis\n        //----------------------------------------------------------------------------\n        std::string AppendEllipsis(const std::string& in_text, const FontCSPtr& in_font, f32 in_absCharSpacingOffset, f32 in_textScale, f32 in_maxTextWidth)\n        {\n            const u32 k_numDots = 3;\n            \n            //Check the font contains '.' for building the ellipsis.\n            Font::CharacterInfo charInfo;\n            if (in_font->TryGetCharacterInfo((UTF8Char)'.', charInfo) == false)\n            {\n                return in_text;\n            }\n            \n            //get the width of an ellipsis\n            f32 dotWidth = GetCharacterWidth((UTF8Char)'.', in_font, in_absCharSpacingOffset, in_textScale);\n            f32 ellipsisWidth = dotWidth * k_numDots;\n            \n            //if there is space for some of the text and the ellipsis, then calculate the output string.\n            std::string outputText;\n            if (in_maxTextWidth > ellipsisWidth)\n            {\n                f32 currentLineWidth = 0.0f;\n                auto it = in_text.begin();\n                while(it < in_text.end())\n                {\n                    auto character = UTF8StringUtils::Next(it);\n                    \n                    currentLineWidth += GetCharacterWidth(character, in_font, in_absCharSpacingOffset, in_textScale);\n                    if (currentLineWidth > in_maxTextWidth - ellipsisWidth)\n                    {\n                        break;\n                    }\n                    \n                    UTF8StringUtils::Append(character, outputText);\n                }\n                \n                //append the ellipsis\n                for (u32 i = 0; i < k_numDots; ++i)\n                {\n                    UTF8StringUtils::Append((UTF8Char)'.', outputText);\n                }\n            }\n            \n            //otherwise don't bother trying to use the input text and just build the ellipsis text.\n            else\n            {\n                f32 currentLineWidth = 0.0f;\n                for (u32 i = 0; i < k_numDots; ++i)\n                {\n                    currentLineWidth += dotWidth;\n                    if (currentLineWidth > in_maxTextWidth)\n                    {\n                        break;\n                    }\n                    \n                    UTF8StringUtils::Append((UTF8Char)'.', outputText);\n                }\n            }\n            \n            return outputText;\n        }\n        //----------------------------------------------------------------------------\n        /// Returns if the given lines will fit completely in the number of allowed lines/bounds\n        ///\n        /// @author HMcLaughlin\n        ///\n        /// @param in_wrappedText - Vector of wrapped lines\n        /// @param in_properties - The text properties.\n        /// @param in_maxHeight - Absolute Bounded Height\n        /// @param in_lineHeight - Absolute Line Height\n        /// @param [Out] out_numLines - Number of lines used\n        ///\n        /// @return If the bounded lines fit\n        //----------------------------------------------------------------------------\n        bool DoesWrappedTextFit(const CanvasRenderer::WrappedText& in_wrappedText, const CanvasRenderer::TextProperties& in_properties, f32 in_maxHeight, f32 in_lineHeight, u32& out_numLines)\n        {\n            u32 numLinesOnBounds = static_cast<u32>(in_wrappedText.size());\n            u32 numLines = (in_properties.m_maxNumLines == 0) ? numLinesOnBounds : std::min(numLinesOnBounds, in_properties.m_maxNumLines);\n            \n            out_numLines = std::min(numLines, (u32)(in_maxHeight/in_lineHeight));\n            \n            if (in_wrappedText.size() > out_numLines)\n            {\n                return false;\n            }\n            \n            return true;\n        }\n        //----------------------------------------------------------------------------\n        /// Formats the text string into a vector representing each line of the text,\n        /// constrained in the bounds\n        ///\n        /// @author HMcLaughlin\n        ///\n        /// @param in_text - Text to convert to display characters (UTF-8)\n        /// @param in_textScale - Text Scale\n        /// @param in_font - Font to use\n        /// @param in_bounds - Max bounds to fit the text\n        /// @param in_properties - The text properties.\n        ///\n        /// @return Vector where each entry is a line of in_text,\n        ///         constrained by the in_bounds\n        //----------------------------------------------------------------------------\n        CanvasRenderer::WrappedText GetWrappedText(const std::string& in_text, f32 in_textScale, const FontCSPtr& in_font, const Vector2& in_bounds, const CanvasRenderer::TextProperties& in_properties)\n        {\n            //NOTE: | denotes the bounds of the box\n            //- |The quick brown fox| jumped over\\nthe ferocious honey badger\n            \n            //Split the string into lines by the forced line breaks (i.e. the \\n)\n            //- |The quick brown fox| jumped over\n            //- |the ferocious honey| badger\n            std::vector<std::string> linesOnNewLine;\n            SplitByNewLine(in_text, linesOnNewLine);\n            \n            //Split the lines further based on the line width, breakable characters and the bounds\n            //- |The quick brown fox|\n            //- |jumped over        |\n            //- |the ferocious honey|\n            //- |badger             |\n            CanvasRenderer::WrappedText linesOnBounds;\n            for(const auto& line : linesOnNewLine)\n            {\n                SplitByBounds(line, in_font, in_properties.m_absCharSpacingOffset, in_textScale, in_bounds, linesOnBounds);\n            }\n            \n            return linesOnBounds;\n        }\n        //----------------------------------------------------------------------------\n        /// Build the descriptions for all characters. The descriptions can then be\n        /// passed into the draw method for rendering. The characters will be\n        /// built to fit into the given bounds and will wrap and then clip in\n        /// order to fit. This will return if the text can fit into the bounds given\n        /// with the text scale provided\n        ///\n        /// @author HMcLaughlin\n        ///\n        /// @param in_text - Text to convert to display characters (UTF-8)\n        /// @param in_textScale - Text Scale\n        /// @param in_font - Font to use\n        /// @param in_bounds - Max bounds to fit the text\n        /// @param in_properties - The text properties.\n        /// @param out_builtText - Built text\n        //----------------------------------------------------------------------------\n        void BuildText(const std::string& in_text, f32 in_textScale, const FontCSPtr& in_font, const Vector2& in_bounds, const CanvasRenderer::TextProperties& in_properties, CanvasRenderer::BuiltText& out_builtText)\n        {\n            f32 lineHeight = in_properties.m_lineSpacingScale * ((in_font->GetLineHeight() + in_properties.m_absLineSpacingOffset) * in_textScale);\n            f32 maxHeight = in_bounds.y;\n            \n            CanvasRenderer::WrappedText linesOnBounds = GetWrappedText(in_text, in_textScale, in_font, in_bounds, in_properties);\n            \n            u32 numLines = 0;\n\n            //add an ellipsis if the text doesn't fit, unless there is no room for the ellipsis itself.\n            if (DoesWrappedTextFit(linesOnBounds, in_properties, maxHeight, lineHeight, numLines) == false && numLines > 0)\n            {\n                linesOnBounds[numLines-1] = AppendEllipsis(linesOnBounds[numLines-1], in_font, in_properties.m_absCharSpacingOffset, in_textScale, in_bounds.x);\n            }\n            \n            //The middle of the text label is 0,0. We want to be starting at the top left.\n            f32 cursorXReturnPos = -in_bounds.x * 0.5f;\n            f32 cursorX = cursorXReturnPos;\n            f32 cursorY = in_bounds.y * 0.5f;\n            \n            for(u32 lineIdx = 0; lineIdx < numLines; ++lineIdx)\n            {\n                u32 lineStartIdx = static_cast<u32>(out_builtText.m_characters.size());\n                \n                auto characterIt = linesOnBounds[lineIdx].begin();\n                while(characterIt != linesOnBounds[lineIdx].end())\n                {\n                    auto character = UTF8StringUtils::Next(characterIt);\n                    auto builtCharacter(BuildCharacter(character, in_font, cursorX, cursorY, in_textScale, in_properties.m_absCharSpacingOffset));\n                    \n                    cursorX += builtCharacter.m_advance;\n                    \n                    if(builtCharacter.m_packedImageSize.y > 0.0f)\n                    {\n                        //No point rendering whitespaces\n                        out_builtText.m_characters.push_back(std::move(builtCharacter));\n                    }\n                }\n                \n                f32 lineWidth = cursorX - cursorXReturnPos;\n                ApplyHorizontalTextJustifications(in_properties.m_horizontalJustification, in_bounds.x, lineStartIdx, static_cast<u32>(out_builtText.m_characters.size()) - 1, lineWidth, out_builtText.m_characters);\n                \n                out_builtText.m_width = std::max(lineWidth, out_builtText.m_width);\n                \n                cursorX = cursorXReturnPos;\n                cursorY -= lineHeight;\n            }\n            \n            out_builtText.m_height = numLines * lineHeight;\n            ApplyVerticalTextJustifications(in_properties.m_verticalJustification, in_bounds.y, out_builtText.m_height, out_builtText.m_characters);\n        }\n        //----------------------------------------------------------------------------\n        /// Recursively calculates the closest correct scale of text.\n        /// Performs a binary search to find the closest correct approximation within\n        /// a tolerance.\n        ///\n        /// @author HMcLaughlin\n        ///\n        /// @param in_text - Text to convert to display characters (UTF-8)\n        /// @param in_properties - The text properties.\n        /// @param in_font - Font to use\n        /// @param in_bounds - Max bounds to fit the text\n        /// @param in_minMax - Min/Max scales to search\n        /// @param in_currentIteration - Current level of recursion\n        ///\n        /// @return Close to best case fitting scale\n        //----------------------------------------------------------------------------\n        f32 GetBoundedTextScaleRecursive(const std::string& in_text, const CanvasRenderer::TextProperties& in_properties, const FontCSPtr& in_font, const Vector2& in_bounds, const Vector2& in_minMax, u32 in_currentIteration = 0)\n        {\n            f32 min = in_minMax.x;\n            f32 max = in_minMax.y;\n            \n            if(min == max)\n            {\n                return min;\n            }\n            \n            CS_ASSERT(min < max, \"Min is greater than the max!\");\n            \n            //Choose a midpoint value between the max and the min\n            f32 difference = max - min;\n            f32 midpointScale = min + (difference * 0.5f);\n            \n            //Check if the midpoint value is valid\n            const auto& wrappedText = GetWrappedText(in_text, midpointScale, in_font, in_bounds, in_properties);\n            \n            f32 lineHeight = in_properties.m_lineSpacingScale * ((in_font->GetLineHeight() + in_properties.m_absLineSpacingOffset) * midpointScale);\n            \n            u32 numLinesUsed = 0;\n            bool doesFit = DoesWrappedTextFit(wrappedText, in_properties, in_bounds.y, lineHeight, numLinesUsed);\n            \n            //Increment current iteration\n            ++in_currentIteration;\n            \n            if(difference <= k_autoScaleTolerance || in_currentIteration >= k_maxAutoScaleIterations)\n            {\n                //Reached a value below the tolerance/max iterations, return the current valid scale\n                return doesFit ? midpointScale : min;\n            }\n            \n            if(doesFit)\n            {\n                //We recurse further, the valid midpoint scale is now used as the min value\n                return GetBoundedTextScaleRecursive(in_text, in_properties, in_font, in_bounds, Vector2(midpointScale, max), in_currentIteration);\n            }\n            else\n            {\n                //Recurse further, the midpoint value is used as the max value for this recursion\n                //This is based on the assumption that the min value is always a valid fitting scale\n                return GetBoundedTextScaleRecursive(in_text, in_properties, in_font, in_bounds, Vector2(min, midpointScale), in_currentIteration);\n            }\n        }\n        \n        /// Creates a new render object containing a dynamic mesh that describes the sprite and\n        /// adds it to the snapshot.\n        ///\n        /// @param renderSnapshot\n        ///     The render snapshot.\n        /// @param frameAllocator\n        ///     Allocate memory for this render frame from here\n        /// @param localPosition\n        ///     The local position of the sprite. This is often used to represent the sprite offset\n        ///     when cropping when texture packing.\n        /// @param localSize\n        ///     The local size of the sprite.\n        /// @param uvs\n        ///     The UVs of the sprite.\n        /// @param colour\n        ///     The colour of the sprite.\n        /// @param alignmentAnchor\n        ///     The alignmentAnchor of the sprite.\n        /// @param worldMatrix\n        ///     The world matrix of the sprite.\n        /// @param material\n        ///     The material of the sprite.\n        /// @param priority\n        ///     the order priority of the render object.\n        ///\n        void AddSpriteRenderObject(RenderSnapshot* renderSnapshot, IAllocator* frameAllocator, const Vector3& localPosition, const Vector2& localSize, const UVs& uvs, const Colour& colour,\n                                   AlignmentAnchor alignmentAnchor, const Matrix4& worldMatrix, const MaterialCSPtr& material, u32 priority) noexcept\n        {\n            auto renderDynamicMesh = SpriteMeshBuilder::Build(frameAllocator, localPosition, localSize, uvs, colour, alignmentAnchor);\n            auto boundingSphere = Sphere::Transform(renderDynamicMesh->GetBoundingSphere(), worldMatrix.GetTranslation(), Quaternion::k_identity, Vector3(localSize, 0.0f));\n            \n            renderSnapshot->AddRenderObject(RenderObject(material->GetRenderMaterialGroup(), renderDynamicMesh.get(), worldMatrix, boundingSphere, false, RenderLayer::k_ui, priority));\n            renderSnapshot->AddRenderDynamicMesh(std::move(renderDynamicMesh));\n        }\n    }\n\n    \n    CS_DEFINE_NAMEDTYPE(CanvasRenderer);\n\n    //----------------------------------------------------------------------------\n    //----------------------------------------------------------------------------\n    CanvasRendererUPtr CanvasRenderer::Create()\n    {\n        return CanvasRendererUPtr(new CanvasRenderer());\n    }\n    //----------------------------------------------------------------------------\n    //----------------------------------------------------------------------------\n    bool CanvasRenderer::IsA(InterfaceIDType in_interfaceId) const\n    {\n        return in_interfaceId == CanvasRenderer::InterfaceID;\n    }\n    //----------------------------------------------------------------------------\n    //----------------------------------------------------------------------------\n    void CanvasRenderer::OnInit()\n    {\n        m_resourcePool = Application::Get()->GetResourcePool();\n        CS_ASSERT(m_resourcePool != nullptr, \"Must have a resource pool\");\n\n        m_screen = Application::Get()->GetSystem<Screen>();\n        CS_ASSERT(m_screen != nullptr, \"Canvas renderer cannot find screen system\");\n        \n        m_cursorSystem = Application::Get()->GetSystem<CursorSystem>();\n\n        auto materialFactory = Application::Get()->GetSystem<MaterialFactory>();\n        CS_ASSERT(materialFactory != nullptr, \"Must have a material factory\");\n        \n        // Masking works as follows:\n        // 1. When drawing a masked shape as well as writing to the colour buffer the shape also writes the current clip mask value to the stencil buffer\n        // 2. When rendering to colour buffer, both stencil and colour material are stencil tested using the current clip mask agains the value currently in the stencil buffer.\n        // 3. The current clip mask value is incremented after the mask has been rendered but before a widget renders its children.\n        // 4. The clip mask value is decremented after the masking widget has rendered its children.\n        //\n        // Example hierarchy showing clip mask in use:\n        //\n        // Here is a widget hierarchy where the number represents the draw order\n        //\n        //      0\n        //\n        //      1\n        //\n        //    2   4\n        //\n        //  3       5\n        //\n        // Here is the same widget hierarchy indicating which widgets clip (C = clips, D = doesn't)\n        //\n        //      D\n        //\n        //      C\n        //\n        //    C   D\n        //\n        //  D       D\n        //\n        // By incrementing and decrementing the clip mask prior to and post child rendering the child will only render on pixels of the screen where there parent rendered.\n        // Here is the same widget hierarchy showing the clip mask test value/write value at each stage. Essentially the child tests against the value written by the parent.\n        //\n        //     0|-\n        //\n        //     0|1\n        //\n        //   1|2 1|-\n        //\n        // 2|-     1|-\n        //\n        \n        //Shader for creating a mask\n        auto resourcePool = Application::Get()->GetResourcePool();\n        auto shader = resourcePool->LoadResource<Shader>(CS::StorageLocation::k_chilliSource, \"Shaders/Sprite-UnlitStencil.csshader\");\n        \n        //Pool for creating materials for standard rendering to canvas\n        m_screenMaterialPool = CanvasMaterialPoolUPtr(new CanvasMaterialPool(materialFactory, \"_CanvasCol-\", [](Material* material)\n        {\n            material->SetShadingType(MaterialShadingType::k_unlit);\n            material->SetTransparencyEnabled(true);\n            material->SetDepthTestEnabled(false);\n            material->SetStencilTestEnabled(true);\n            material->SetStencilPostTestOps(StencilOp::k_keep, StencilOp::k_keep, StencilOp::k_keep);\n            material->SetStencilTestFunc(TestFunc::k_equal, 0, k_uiStencilMaskChannel);\n        }));\n        \n        //Pool for creating materials for rendering to screen and creating a mask\n        m_screenMaskMaterialPool = CanvasMaterialPoolUPtr(new CanvasMaterialPool(materialFactory, \"_CanvasColStcl-\", [shader](Material* material)\n        {\n            material->SetShadingType(MaterialShadingType::k_custom);\n            material->PrepCustomShaders(VertexFormat::k_sprite, MaterialShadingType::k_custom);\n            material->AddCustomShader(shader, RenderPasses::k_transparent);\n            material->SetTransparencyEnabled(true);\n            material->SetDepthTestEnabled(false);\n            material->SetStencilTestEnabled(true);\n            material->SetStencilPostTestOps(StencilOp::k_keep, StencilOp::k_keep, StencilOp::k_increment);\n            material->SetStencilTestFunc(TestFunc::k_equal, 0, k_uiStencilMaskChannel);\n        }));\n        \n        //Pool for creating materials for only creating a mask\n        m_maskMaterialPool = CanvasMaterialPoolUPtr(new CanvasMaterialPool(materialFactory, \"_CanvasStcl-\", [shader](Material* material)\n        {\n            material->SetShadingType(MaterialShadingType::k_custom);\n            material->PrepCustomShaders(VertexFormat::k_sprite, MaterialShadingType::k_custom);\n            material->AddCustomShader(shader, RenderPasses::k_transparent);\n            material->SetTransparencyEnabled(true);\n            material->SetDepthTestEnabled(false);\n            material->SetColourWriteEnabled(false);\n            material->SetStencilTestEnabled(true);\n            material->SetStencilPostTestOps(StencilOp::k_keep, StencilOp::k_keep, StencilOp::k_increment);\n            material->SetStencilTestFunc(TestFunc::k_equal, 0, k_uiStencilMaskChannel);\n        }));\n    }\n    //----------------------------------------------------------------------------\n    //----------------------------------------------------------------------------\n    void CanvasRenderer::DrawBox(CanvasDrawMode drawMode, const Matrix3& transform, const Vector2& size, const Vector2& offset, const TextureCSPtr& texture, const UVs& uvs, const Colour& colour, AlignmentAnchor anchor)\n    {\n        MaterialCSPtr material;\n        \n        switch (drawMode)\n        {\n            case CanvasDrawMode::k_standard:\n                material = m_screenMaterialPool->GetMaterial(texture, m_clipMaskCount);\n                break;\n            case CanvasDrawMode::k_mask:\n                material = m_screenMaskMaterialPool->GetMaterial(texture, m_clipMaskCount);\n                break;\n            case CanvasDrawMode::k_maskOnly:\n                material = m_maskMaterialPool->GetMaterial(texture, m_clipMaskCount);\n                break;\n        }\n\n        AddSpriteRenderObject(m_currentRenderSnapshot, m_currentFrameAllocator, Vector3(offset, 0.0f), size, uvs, colour, anchor, Convert2DTransformTo3D(transform), material, m_nextPriority++);\n    }\n    //----------------------------------------------------------------------------\n    //----------------------------------------------------------------------------\n    CanvasRenderer::BuiltText CanvasRenderer::BuildText(const std::string& in_text, const FontCSPtr& in_font, const Vector2& in_bounds, const TextProperties& in_properties, f32& out_textScale) const\n    {\n        BuiltText result;\n        result.m_width = 0.0f;\n        result.m_height = 0.0f;\n        \n        f32 textScale = in_properties.m_textScale;\n        \n        //Don't build the text if scale is invalid\n        if(textScale <= 0.0f)\n        {\n            return result;\n        }\n        \n        f32 lineHeight = in_properties.m_lineSpacingScale * ((in_font->GetLineHeight() + in_properties.m_absLineSpacingOffset) * textScale);\n        \n        result.m_characters.reserve(in_text.size());\n\n        if(in_properties.m_shouldAutoScale)\n        {\n            CS_ASSERT(in_properties.m_minTextScale <= in_properties.m_textScale, \"Cannot autoscale as the MinTextAutoScale is more than the TextScale property!\");\n\n            bool doesFit = false;\n            u32 numLines = 0;\n            \n            //Recalculate line height for the ideal scale\n            lineHeight = in_properties.m_lineSpacingScale * ((in_font->GetLineHeight() + in_properties.m_absLineSpacingOffset) * textScale);\n\n            //Check to see if the text fits at ideal scale\n            auto idealWrappedText = GetWrappedText(in_text, textScale, in_font, in_bounds, in_properties);\n            doesFit = DoesWrappedTextFit(idealWrappedText, in_properties, in_bounds.y, lineHeight, numLines);\n            \n            //If the ideal doesn't fit then attempt the minimum, if that doesn't fit then there is nothing we can do scale-wise\n            if(!doesFit && textScale != in_properties.m_minTextScale)\n            {\n                //Recalculate line height for the minimum\n                lineHeight = in_properties.m_lineSpacingScale * ((in_font->GetLineHeight() + in_properties.m_absLineSpacingOffset) * in_properties.m_minTextScale);\n\n                //Check to see if the text can fit at the smallest scale\n                auto minWrappedText = GetWrappedText(in_text, in_properties.m_minTextScale, in_font, in_bounds, in_properties);\n                doesFit = DoesWrappedTextFit(minWrappedText, in_properties, in_bounds.y, lineHeight, numLines);\n                \n                if(!doesFit)\n                {\n                    CS_LOG_WARNING(\"Doesn't fit at min scale, consider resizing the label manually to fit the text better!\");\n                    textScale = in_properties.m_minTextScale;\n                }\n                else\n                {\n                    //We should search for a more optimal scale between the min and the ideal, while still fitting\n                    textScale = GetBoundedTextScaleRecursive(in_text, in_properties, in_font, in_bounds, Vector2(in_properties.m_minTextScale, textScale));\n                }\n            }\n        }\n\n        //Update the final scale\n        out_textScale = textScale;\n        \n        //Carry out the building of the text with the resolved scale\n        ChilliSource::BuildText(in_text, textScale, in_font, in_bounds, in_properties, result);\n        \n        return result;\n    }\n    //----------------------------------------------------------------------------\n    //----------------------------------------------------------------------------\n    void CanvasRenderer::DrawText(const std::vector<DisplayCharacterInfo>& characters, const Matrix3& transform, const Colour& colour, const TextureCSPtr& texture)\n    {\n        auto material = m_screenMaterialPool->GetMaterial(texture, m_clipMaskCount);\n\n        Matrix4 matTransform = Convert2DTransformTo3D(transform);\n\n        for (const auto& character : characters)\n        {\n            Matrix4 matTransformedLocal = Matrix4::CreateTranslation(Vector3(character.m_position, 0.0f)) * matTransform;\n            AddSpriteRenderObject(m_currentRenderSnapshot, m_currentFrameAllocator, Vector3::k_zero, character.m_packedImageSize, character.m_UVs, colour, AlignmentAnchor::k_topLeft, matTransformedLocal, material, m_nextPriority++);\n        }\n    }\n    //----------------------------------------------------------------------------\n    //----------------------------------------------------------------------------\n    void CanvasRenderer::OnRenderSnapshot(TargetType targetType, RenderSnapshot& renderSnapshot, IAllocator* frameAllocator) noexcept\n    {\n        if(targetType == TargetType::k_main)\n        {\n            auto activeState = CS::Application::Get()->GetStateManager()->GetActiveState();\n            CS_ASSERT(activeState, \"must have active state.\");\n            \n            auto activeUICanvas = activeState->GetUICanvas();\n            CS_ASSERT(activeUICanvas != nullptr, \"Cannot render null UI canvas\");\n            \n            m_currentFrameAllocator = frameAllocator;\n            m_currentRenderSnapshot = &renderSnapshot;\n            m_nextPriority = 0;\n            \n            activeUICanvas->Draw(this);\n            \n            if(m_cursorSystem != nullptr)\n            {\n                m_cursorSystem->Draw(this);\n            }\n            \n            m_currentRenderSnapshot = nullptr;\n            \n            m_screenMaterialPool->Clear();\n            m_screenMaskMaterialPool->Clear();\n            m_maskMaterialPool->Clear();\n        }\n    }\n    //----------------------------------------------------------------------------\n    //----------------------------------------------------------------------------\n    void CanvasRenderer::OnDestroy()\n    {\n        m_screenMaterialPool->Clear();\n        m_screenMaterialPool.reset();\n        \n        m_screenMaskMaterialPool->Clear();\n        m_screenMaskMaterialPool.reset();\n        \n        m_maskMaterialPool->Clear();\n        m_maskMaterialPool.reset();\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Base/CanvasRenderer.h",
    "content": "//\n//  CanvasRenderer.h\n//  ChilliSource\n//  Created by Scott Downie on 12/01/2011.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2011 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_BASE_CANVASRENDERER_H_\n#define _CHILLISOURCE_RENDERING_BASE_CANVASRENDERER_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Math/Geometry/Shapes.h>\n#include <ChilliSource/Core/System/AppSystem.h>\n#include <ChilliSource/Rendering/Base/CanvasMaterialPool.h>\n#include <ChilliSource/Rendering/Base/HorizontalTextJustification.h>\n#include <ChilliSource/Rendering/Base/VerticalTextJustification.h>\n#include <ChilliSource/Rendering/Texture/UVs.h>\n\nnamespace ChilliSource\n{\n    //----------------------------------------------------------------------------\n    /// System that renders simple shapes and text to screen space. Responsible\n    /// for rendering the UI system.\n    ///\n    /// @author S Downie\n    //----------------------------------------------------------------------------\n    class CanvasRenderer : public AppSystem\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(CanvasRenderer);\n    \n        //----------------------------------------------------------------------------\n        /// A container for text properties for altering the look of built text.\n        ///\n        /// @author Ian Copland\n        //----------------------------------------------------------------------------\n        struct TextProperties\n        {\n            f32 m_textScale = 1.0f;\n            f32 m_minTextScale = 0.75f;\n            f32 m_absCharSpacingOffset = 0.0f;\n            f32 m_absLineSpacingOffset = 0.0f;\n            f32 m_lineSpacingScale = 1.0f;\n            u32 m_maxNumLines = 0;\n            \n            bool m_shouldAutoScale = false;\n            \n            HorizontalTextJustification m_horizontalJustification = HorizontalTextJustification::k_centre;\n            VerticalTextJustification m_verticalJustification = VerticalTextJustification::k_centre;\n        };\n        //----------------------------------------------------------------------------\n        /// Holds the information required to build a sprite for a text character\n        ///\n        /// @author S Downie\n        //----------------------------------------------------------------------------\n        struct DisplayCharacterInfo\n        {\n            UVs m_UVs;\n            Vector2 m_position;\n            Vector2 m_packedImageSize;\n            f32 m_advance = 0.0f;\n        };\n        //----------------------------------------------------------------------------\n        /// Holds the return information for building text including all the characters\n        /// and the total width and height\n        ///\n        /// @author S Downie\n        //----------------------------------------------------------------------------\n        struct BuiltText\n        {\n            std::vector<DisplayCharacterInfo> m_characters;\n\n            f32 m_width;\n            f32 m_height;\n        };\n        //----------------------------------------------------------------------------\n        /// Defines a type for a vector of bounded lines\n        ///\n        /// @author HMcLaughlin\n        //----------------------------------------------------------------------------\n        using WrappedText = std::vector<std::string>;\n        //----------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Interface ID\n        ///\n        /// @return Whether the class implements the given interface\n        //----------------------------------------------------------------------------\n        bool IsA(InterfaceIDType in_interfaceId) const override;\n\n        /// Increment the the clip mask value. When performing a stencil clip test\n        /// this is the value that will be used. Generally it is incremented prior to\n        /// rendering the contents of a clipping box and decremented afterwards\n        ///\n        void IncrementClipMask() noexcept { ++m_clipMaskCount; }\n        \n        /// Decrement the clip mask\n        ///\n        void DecrementClipMask() noexcept { --m_clipMaskCount; }\n        \n\n        /// Renders the given sprite box to the screen or as a mask\n        ///\n        /// @param drawMode\n        ///     Describes whether to render the box to the canvas or as a mask\n        /// @param transform\n        ///     2D Transformation matrix\n        /// @param size\n        ///     Dimensions of the box in canvas space\n        /// @param offset\n        ///     Offset from TL of the bounds. Used to restore the cropped alpha\n        /// @param texture\n        ///     Texture\n        /// @param uvs\n        ///     UVs for texture\n        /// @param colour\n        ///     Colour to apply to the sprite box\n        /// @param anchor\n        ///     Origin anchor\n        ///\n        void DrawBox(CanvasDrawMode drawMode, const Matrix3& transform, const Vector2& size, const Vector2& offset, const TextureCSPtr& texture, const UVs& uvs, const Colour& colour, AlignmentAnchor anchor);\n        \n        //----------------------------------------------------------------------------\n        /// Build the descriptions for all characters. The descriptions can then be\n        /// passed into the draw method for rendering. The characters will be\n        /// build to fit into the given bounds and will wrap and then clip in\n        /// order to fit.\n        ///\n        /// @author S Downie\n        ///\n        /// @param in_text - Text to convert to display characters (UTF-8)\n        /// @param in_font - Font to use\n        /// @param in_bounds - Max bounds\n        /// @param in_textProperties - The text properties used to build.\n        /// @param [Out] out_textScale - Final scale that should be used\n        ///\n        /// @return Built text struct containing all the character infos\n        //----------------------------------------------------------------------------\n        BuiltText BuildText(const std::string& in_text, const FontCSPtr& in_font, const Vector2& in_bounds, const TextProperties& in_textProperties, f32& out_textScale) const;\n\n        /// Build the sprites for each given character and render them to screen.\n        ///\n        /// @param characters\n        ///     List of character display infos in text space\n        /// @param transform\n        ///     2D transform to screen space\n        /// @param colour\n        ///     Tint colour to apply to character sprites\n        /// @param texture\n        ///     Font texture\n        ///\n        void DrawText(const std::vector<DisplayCharacterInfo>& characters, const Matrix3& transform, const Colour& colour, const TextureCSPtr& texture);\n\n    private:\n\n        friend class Application;\n        //----------------------------------------------------------------------------\n        /// Creates a new instance of the system.\n        ///\n        /// @author S Downie\n        ///\n        /// @return New renderer instance\n        //----------------------------------------------------------------------------\n        static CanvasRendererUPtr Create();\n        //----------------------------------------------------------------------------\n        /// Private constructor to enforce use of factory method\n        ///\n        /// @author S Downie\n        //----------------------------------------------------------------------------\n        CanvasRenderer() = default;\n        //----------------------------------------------------------------------------\n        /// Called when the system is created\n        ///\n        /// @author S Downie\n        //----------------------------------------------------------------------------\n        void OnInit() override;\n        //----------------------------------------------------------------------------\n        /// Called when the render snapshot event occurs. This iterates over all UI\n        /// adding objects to the render snapshot as appropriate.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param targetType\n        ///     Whether the snapshot is for the main screen or an offscreen render target\n        /// @param renderSnapshot\n        ///     The render snapshot object which contains all snapshotted data.\n        /// @param frameAllocator\n        ///     Allocate memory for this render frame from here\n        //----------------------------------------------------------------------------\n        void OnRenderSnapshot(TargetType targetType, RenderSnapshot& renderSnapshot, IAllocator* frameAllocator) noexcept override;\n        //----------------------------------------------------------------------------\n        /// Called when the system is destroyed\n        ///\n        /// @author S Downie\n        //----------------------------------------------------------------------------\n        void OnDestroy() override;\n\n    private:\n        IAllocator* m_currentFrameAllocator = nullptr;\n        RenderSnapshot* m_currentRenderSnapshot = nullptr;\n        u32 m_nextPriority = 0;\n        \n        s32 m_clipMaskCount = 0;\n\n        CanvasMaterialPoolUPtr m_screenMaterialPool;\n        CanvasMaterialPoolUPtr m_screenMaskMaterialPool;\n        CanvasMaterialPoolUPtr m_maskMaterialPool;\n\n        ResourcePool* m_resourcePool;\n        Screen* m_screen;\n        CursorSystem* m_cursorSystem;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Base/CullFace.h",
    "content": "//\n//  CullFace.h\n//  ChilliSource\n//  Created by Scott Downie on 09/04/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_BASE_CULLFACE_H_\n#define _CHILLISOURCE_RENDERING_BASE_CULLFACE_H_\n\nnamespace ChilliSource\n{\n    //---------------------------------------------\n    /// Used in the face culling function to\n    /// describe which faces to remove.\n    ///\n    /// @author S Downie\n    //---------------------------------------------\n    enum class CullFace\n    {\n        k_front,\n        k_back\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Base/ForwardRenderPassCompiler.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Base/ForwardRenderPassCompiler.h>\n\n#include <ChilliSource/Core/Math/Geometry/ShapeIntersection.h>\n#include <ChilliSource/Core/Threading/TaskScheduler.h>\n#include <ChilliSource/Rendering/Base/RenderPasses.h>\n#include <ChilliSource/Rendering/Base/RenderFrame.h>\n#include <ChilliSource/Rendering/Base/RenderObject.h>\n#include <ChilliSource/Rendering/Base/RenderPass.h>\n#include <ChilliSource/Rendering/Base/RenderPassObject.h>\n#include <ChilliSource/Rendering/Base/RenderPassObjectSorter.h>\n#include <ChilliSource/Rendering/Base/RenderPassVisibilityChecker.h>\n#include <ChilliSource/Rendering/Model/RenderDynamicMesh.h>\n\n\nnamespace ChilliSource\n{\n    namespace\n    {\n        /// Converts the given RenderObject to a RenderPassObject using the given RenderMaterial.\n        /// if the given RenderMaterial does not exist in the RenderMaterialGroup contained by\n        /// the RenderObject, then this will assert.\n        ///\n        /// @param renderObject\n        ///     The renderObject to convert.\n        /// @param renderMaterial\n        ///     The render material that should be used by the new RenderPassObject.\n        ///\n        /// @return The new RenderPassObject.\n        ///\n        RenderPassObject ConvertToRenderPassObject(const RenderObject& renderObject, const RenderMaterial* renderMaterial) noexcept\n        {\n            CS_ASSERT(renderObject.GetRenderMaterialGroup()->Contains(renderMaterial), \"Invalid render material.\");\n            \n            switch (renderObject.GetType())\n            {\n                case RenderObject::Type::k_static:\n                    return RenderPassObject(renderMaterial, renderObject.GetRenderMesh(), renderObject.GetWorldMatrix(), renderObject.GetBoundingSphere(), renderObject.GetPriority());\n                case RenderObject::Type::k_staticAnimated:\n                    return RenderPassObject(renderMaterial, renderObject.GetRenderMesh(), renderObject.GetRenderSkinnedAnimation(), renderObject.GetWorldMatrix(), renderObject.GetBoundingSphere(),\n                                            renderObject.GetPriority());\n                case RenderObject::Type::k_dynamic:\n                    return RenderPassObject(renderMaterial, renderObject.GetRenderDynamicMesh(), renderObject.GetWorldMatrix(), renderObject.GetBoundingSphere(), renderObject.GetPriority());\n                case RenderObject::Type::k_dynamicAnimated:\n                    return RenderPassObject(renderMaterial, renderObject.GetRenderDynamicMesh(), renderObject.GetRenderSkinnedAnimation(), renderObject.GetWorldMatrix(), renderObject.GetBoundingSphere(),\n                                            renderObject.GetPriority());\n                default:\n                    CS_LOG_FATAL(\"Invalid RenderObject type.\");\n                    return RenderPassObject(nullptr, reinterpret_cast<const RenderMesh*>(NULL), Matrix4::k_identity, Sphere(), 0);\n            }\n        }\n        \n        /// Returns the vertex format of the given render object.\n        ///\n        /// @param renderObject\n        ///     The render object.\n        ///\n        /// @return The vertex format.\n        ///\n        const VertexFormat& GetVertexFormat(const RenderObject& renderObject)\n        {\n            switch (renderObject.GetType())\n            {\n                case RenderObject::Type::k_static:\n                case RenderObject::Type::k_staticAnimated:\n                    return renderObject.GetRenderMesh()->GetVertexFormat();\n                case RenderObject::Type::k_dynamic:\n                case RenderObject::Type::k_dynamicAnimated:\n                    return renderObject.GetRenderDynamicMesh()->GetVertexFormat();\n                default:\n                    CS_LOG_FATAL(\"Invalid RenderObject type.\");\n                    return renderObject.GetRenderMesh()->GetVertexFormat();\n            }\n        }\n        \n        /// Calculate the number of targets\n        ///\n        /// @param renderFrame\n        ///     The render frame from which to calculate the numer of passes.\n        ///\n        /// @return The number of passes.\n        ///\n        u32 CalcNumTargets(const RenderFrame& renderFrame) noexcept\n        {\n            // The main target\n            constexpr u32 k_reservedTargets = 1;\n            \n            u32 numShadowCastingLights = 0;\n            for (const auto& directionalRenderLight : renderFrame.GetDirectionalRenderLights())\n            {\n                if (directionalRenderLight.GetShadowMapTarget())\n                {\n                    ++numShadowCastingLights;\n                }\n            }\n            \n            return k_reservedTargets + numShadowCastingLights;\n        }\n        \n        /// Calculates main scene passes in the given render frame.\n        ///\n        /// @param renderFrame\n        ///     The render frame from which to calculate the numer of passes.\n        ///\n        /// @return The number of passes.\n        ///\n        u32 CalcNumSceneOpaquePasses(const RenderFrame& renderFrame) noexcept\n        {\n            // Base\n            constexpr u32 k_reservedRenderPasses = 1;\n            \n            u32 numDirectionalLightPasses = u32(renderFrame.GetDirectionalRenderLights().size());\n            u32 numPointLightPasses = u32(renderFrame.GetPointRenderLights().size());\n            \n            return k_reservedRenderPasses + numDirectionalLightPasses + numPointLightPasses;\n        }\n        \n        /// Filters the given list of objects to return only the objects which are a part of the requested\n        /// layer.\n        ///\n        /// @param renderLayer\n        ///     The render layer to filter on.\n        /// @param renderObjects\n        ///     The list of render objects which should be filtered.\n        ///\n        /// @return The list of render objects for the requested layer.\n        ///\n        std::vector<RenderObject> GetLayerRenderObjects(RenderLayer renderLayer, const std::vector<RenderObject>& renderObjects) noexcept\n        {\n            std::vector<RenderObject> layerRenderObjects;\n            \n            for (const auto& renderObject : renderObjects)\n            {\n                if (renderObject.GetRenderLayer() == renderLayer)\n                {\n                    layerRenderObjects.push_back(renderObject);\n                }\n            }\n            \n            return layerRenderObjects;\n        }\n        \n        /// Parses a list of RenderObjects and generates a list of RenderPassObjects for\n        /// each RenderObject that has a ShadowMap pass defined, and has shadow casting\n        /// enabled.\n        ///\n        /// @param renderObjects\n        ///     A list of RenderObjects to parse\n        ///\n        /// @return The collection of RenderPassObjects.\n        ///\n        std::vector<RenderPassObject> GetShadowMapRenderPassObjects(const std::vector<RenderObject>& renderObjects) noexcept\n        {\n            std::vector<RenderPassObject> baseRenderPassObjects;\n            \n            for (const auto& renderObject : renderObjects)\n            {\n                if (renderObject.ShouldCastShadows())\n                {\n                    auto renderMaterial = renderObject.GetRenderMaterialGroup()->GetRenderMaterial(GetVertexFormat(renderObject), static_cast<u32>(RenderPasses::k_shadowMap));\n                    \n                    if (renderMaterial)\n                    {\n                        baseRenderPassObjects.push_back(ConvertToRenderPassObject(renderObject, renderMaterial));\n                    }\n                }\n            }\n            \n            return baseRenderPassObjects;\n        }\n        \n        /// Parses a list of RenderObjects and generates a list of RenderPassObjects for\n        /// each RenderObject that has a Base pass defined.\n        ///\n        /// @param renderObjects\n        ///     A list of RenderObjects to parse\n        ///\n        /// @return A collection of RenderPassObjects, one for each RenderObject Base pass\n        ///\n        std::vector<RenderPassObject> GetBaseRenderPassObjects(const std::vector<RenderObject>& renderObjects) noexcept\n        {\n            std::vector<RenderPassObject> baseRenderPassObjects;\n            \n            for (const auto& renderObject : renderObjects)\n            {\n                auto renderMaterial = renderObject.GetRenderMaterialGroup()->GetRenderMaterial(GetVertexFormat(renderObject), static_cast<u32>(RenderPasses::k_base));\n                \n                if (renderMaterial)\n                {\n                    baseRenderPassObjects.push_back(ConvertToRenderPassObject(renderObject, renderMaterial));\n                }\n            }\n            \n            return baseRenderPassObjects;\n        }\n        \n        /// Parses a list of RenderObjects and generates a list of RenderPassObjects for\n        /// each RenderObject that has a Skybox pass defined.\n        ///\n        /// @param renderObjects\n        ///     A list of RenderObjects to parse\n        ///\n        /// @return A collection of RenderPassObjects, one for each RenderObject Skybox pass\n        ///\n        std::vector<RenderPassObject> GetSkyboxRenderPassObjects(const std::vector<RenderObject>& renderObjects) noexcept\n        {\n            std::vector<RenderPassObject> renderPassObjects;\n            \n            for (const auto& renderObject : renderObjects)\n            {\n                auto renderMaterial = renderObject.GetRenderMaterialGroup()->GetRenderMaterial(GetVertexFormat(renderObject), static_cast<u32>(RenderPasses::k_skybox));\n                \n                if (renderMaterial)\n                {\n                    renderPassObjects.push_back(ConvertToRenderPassObject(renderObject, renderMaterial));\n                }\n            }\n            \n            return renderPassObjects;\n        }\n        \n        /// Parses a list of RenderObjects and generates a list of RenderPassObjects for\n        /// each RenderObject that has either a DirectionalLight or DirectionalLightShadows\n        /// pass defined, depending on the type of directional light.\n        ///\n        /// @param renderObjects\n        ///     A list of RenderObjects to parse\n        /// @param directionalRenderLight\n        ///     The directional light to get objects for.\n        ///\n        /// @return A collection of RenderPassObjects, one for each RenderObject Directional pass\n        ///\n        std::vector<RenderPassObject> GetDirectionalLightRenderPassObjects(const std::vector<RenderObject>& renderObjects, const DirectionalRenderLight& directionalRenderLight) noexcept\n        {\n            RenderPasses passType = RenderPasses::k_directionalLight;\n            if (directionalRenderLight.GetShadowMapTarget())\n            {\n                passType = RenderPasses::k_directionalLightShadows;\n            }\n            \n            std::vector<RenderPassObject> renderPassObjects;\n            \n            for (const auto& renderObject : renderObjects)\n            {\n                auto renderMaterial = renderObject.GetRenderMaterialGroup()->GetRenderMaterial(GetVertexFormat(renderObject), static_cast<u32>(passType));\n                \n                if (renderMaterial)\n                {\n                    renderPassObjects.push_back(ConvertToRenderPassObject(renderObject, renderMaterial));\n                }\n            }\n            \n            return renderPassObjects;\n        }\n        \n        /// Parses a list of RenderObjects and generates a list of RenderPassObjects for\n        /// each RenderObject that has a PointLight pass defined, and is within the range\n        /// of influence of the given light.\n        ///\n        /// @param renderObjects\n        ///     A list of RenderObjects to parse\n        /// @param pointRenderLight\n        ///     The render light to get objects for.\n        ///\n        /// @return A collection of RenderPassObjects for the render light pass.\n        ///\n        std::vector<RenderPassObject> GetPointLightRenderPassObjects(const std::vector<RenderObject>& renderObjects, const PointRenderLight& pointRenderLight) noexcept\n        {\n            Sphere pointLightBoundingSphere(pointRenderLight.GetPosition(), pointRenderLight.GetRangeOfInfluence());\n            \n            std::vector<RenderPassObject> renderPassObjects;\n            \n            for (const auto& renderObject : renderObjects)\n            {\n                auto renderMaterial = renderObject.GetRenderMaterialGroup()->GetRenderMaterial(GetVertexFormat(renderObject), static_cast<u32>(RenderPasses::k_pointLight));\n                \n                if (renderMaterial && pointLightBoundingSphere.Contains(renderObject.GetBoundingSphere()))\n                {\n                    renderPassObjects.push_back(ConvertToRenderPassObject(renderObject, renderMaterial));\n                }\n            }\n            \n            return renderPassObjects;\n        }\n        \n        /// Parses a list of RenderObjects and generates a list of RenderPassObjects for\n        /// each RenderObject that has a Transparent pass defined.\n        ///\n        /// @param renderObjects\n        ///     A list of RenderObjects to parse\n        ///\n        /// @return A collection of RenderPassObjects, one for each RenderObject Transparent pass\n        ///\n        std::vector<RenderPassObject> GetTransparentRenderPassObjects(const std::vector<RenderObject>& renderObjects) noexcept\n        {\n            std::vector<RenderPassObject> transparentRenderPassObjects;\n            \n            for (const auto& renderObject : renderObjects)\n            {\n                auto renderMaterial = renderObject.GetRenderMaterialGroup()->GetRenderMaterial(GetVertexFormat(renderObject), static_cast<u32>(RenderPasses::k_transparent));\n                \n                if (renderMaterial)\n                {\n                    transparentRenderPassObjects.push_back(ConvertToRenderPassObject(renderObject, renderMaterial));\n                }\n            }\n            \n            return transparentRenderPassObjects;\n        }\n        \n        /// Gather all render objects in the frame that are to be renderered into the default RenderTarget\n        /// and parse them into different RenderPasses for each light source plus the required Base pass but\n        /// not the transparent pass (as the skybox must be rendered in between). These passes are then compiled into a CameraRenderPassGroup.\n        ///\n        /// @param taskContext\n        ///     Context to manage any spawned tasks\n        /// @param renderFrame\n        ///     Current frame data\n        ///\n        /// @return The CameraRenderPassGroup\n        ///\n        CameraRenderPassGroup CompileOpaqueSceneCameraRenderPassGroup(const TaskContext& taskContext, const RenderFrame& renderFrame) noexcept\n        {\n            auto standardRenderObjects = GetLayerRenderObjects(RenderLayer::k_standard, renderFrame.GetRenderObjects());\n            auto visibleStandardRenderObjects = RenderPassVisibilityChecker::CalculateVisibleObjects(taskContext, renderFrame.GetRenderCamera(), standardRenderObjects);\n            \n            u32 numPasses = CalcNumSceneOpaquePasses(renderFrame);\n            std::vector<RenderPass> renderPasses(numPasses);\n            std::vector<Task> tasks;\n            u32 nextPassIndex = 0;\n            \n            // Base pass\n            u32 basePassIndex = nextPassIndex++;\n            tasks.push_back([=, &renderPasses, &renderFrame, &visibleStandardRenderObjects](const TaskContext& innerTaskContext)\n            {\n                auto renderPassObjects = GetBaseRenderPassObjects(visibleStandardRenderObjects);\n                RenderPassObjectSorter::OpaqueSort(renderFrame.GetRenderCamera(), renderPassObjects);\n                renderPasses[basePassIndex] = RenderPass(renderFrame.GetAmbientRenderLight(), std::move(renderPassObjects));\n            });\n            \n            // Directional light pass\n            for (const auto& directionalLight : renderFrame.GetDirectionalRenderLights())\n            {\n                u32 directionLightPassIndex = nextPassIndex++;\n                tasks.push_back([=, &renderPasses, &renderFrame, &visibleStandardRenderObjects, &directionalLight](const TaskContext& innerTaskContext)\n                {\n                    auto renderPassObjects = GetDirectionalLightRenderPassObjects(visibleStandardRenderObjects, directionalLight);\n                    RenderPassObjectSorter::OpaqueSort(renderFrame.GetRenderCamera(), renderPassObjects);\n                    renderPasses[directionLightPassIndex] = RenderPass(directionalLight, std::move(renderPassObjects));\n                });\n            }\n            \n            // Point light pass\n            for (const auto& pointLight : renderFrame.GetPointRenderLights())\n            {\n                u32 pointLightPassIndex = nextPassIndex++;\n                tasks.push_back([=, &renderPasses, &renderFrame, &visibleStandardRenderObjects, &pointLight](const TaskContext& innerTaskContext)\n                {\n                    auto renderPassObjects = GetPointLightRenderPassObjects(visibleStandardRenderObjects, pointLight);\n                    RenderPassObjectSorter::OpaqueSort(renderFrame.GetRenderCamera(), renderPassObjects);\n                    renderPasses[pointLightPassIndex] = RenderPass(pointLight, std::move(renderPassObjects));\n                });\n            }\n            \n            taskContext.ProcessChildTasks(tasks);\n            \n            return CameraRenderPassGroup(renderFrame.GetRenderCamera(), std::move(renderPasses));\n        }\n        \n        /// Gather all render objects in the frame that are to be renderered into the default RenderTarget\n        /// for the transpaent pass. These passes are then compiled into a CameraRenderPassGroup.\n        ///\n        /// @param taskContext\n        ///     Context to manage any spawned tasks\n        /// @param renderFrame\n        ///     Current frame data\n        ///\n        /// @return The CameraRenderPassGroup\n        ///\n        CameraRenderPassGroup CompileTransparentSceneCameraRenderPassGroup(const TaskContext& taskContext, const RenderFrame& renderFrame) noexcept\n        {\n            std::vector<RenderPass> renderPasses(1);\n            std::vector<Task> tasks;\n\n            tasks.push_back([=, &renderPasses, &renderFrame](const TaskContext& innerTaskContext)\n            {\n                auto standardRenderObjects = GetLayerRenderObjects(RenderLayer::k_standard, renderFrame.GetRenderObjects());\n                auto visibleStandardRenderObjects = RenderPassVisibilityChecker::CalculateVisibleObjects(taskContext, renderFrame.GetRenderCamera(), standardRenderObjects);\n                \n                auto renderPassObjects = GetTransparentRenderPassObjects(visibleStandardRenderObjects);\n                RenderPassObjectSorter::TransparentSort(renderFrame.GetRenderCamera(), renderPassObjects);\n                renderPasses[0] = RenderPass(renderFrame.GetAmbientRenderLight(), std::move(renderPassObjects));\n            });\n            \n            taskContext.ProcessChildTasks(tasks);\n            \n            return CameraRenderPassGroup(renderFrame.GetRenderCamera(), std::move(renderPasses));\n        }\n        \n        /// Gathers all Skybox render objects in the frame that are to be rendered to the default Render Target\n        /// and compiles them into RenderPasses. These render passes are then compiled into a\n        /// CameraRenderPassGroup which uses the Skybox camera.\n        ///\n        /// Skybox is rendered last to reduce overdraw and relies on its custom shader and render settings to\n        /// prevent it rendering on top of everythin\n        ///\n        /// @param taskContext\n        ///     Context to manage any spawned tasks\n        /// @param renderFrame\n        ///     Current frame data\n        ///\n        /// @return The generated CameraRenderPassGroup\n        ///\n        CameraRenderPassGroup CompileSkyboxCameraRenderPassGroup(const TaskContext& taskContext, const RenderFrame& renderFrame) noexcept\n        {\n            //Use the main camera but ignore any scale or translation, as if the camera was at the origin\n            RenderCamera camera(Matrix4::CreateRotation(renderFrame.GetRenderCamera().GetOrientation()), renderFrame.GetRenderCamera().GetProjectionMatrix(), renderFrame.GetRenderCamera().GetOrientation());\n            \n            auto renderObjects = GetLayerRenderObjects(RenderLayer::k_skybox, renderFrame.GetRenderObjects());\n            auto renderPassObjects = GetSkyboxRenderPassObjects(renderObjects);\n            CS_ASSERT(renderObjects.size() == renderPassObjects.size(), \"Invalid number of render pass objects in skybox pass. All render objects in the Skybox layer should have a skybox material.\");\n            \n            std::vector<RenderPass> renderPasses;\n            if (renderPassObjects.size() > 0)\n            {\n                renderPasses.push_back(RenderPass(std::move(renderPassObjects)));\n            }\n            \n            return CameraRenderPassGroup(camera, std::move(renderPasses));\n        }\n\n        /// Gathers all UI render objects in the frame that are to be rendered to the default Render Target\n        /// and compiles them into RenderPasses. These render passes are then compiled into a\n        /// CameraRenderPassGroup which uses the UI camera.\n        ///\n        /// @param taskContext\n        ///     Context to manage any spawned tasks\n        /// @param renderFrame\n        ///     Current frame data\n        ///\n        /// @return The generated CameraRenderPassGroup\n        ///\n        CameraRenderPassGroup CompileUICameraRenderPassGroup(const TaskContext& taskContext, const RenderFrame& renderFrame) noexcept\n        {\n            constexpr f32 k_near = 0.0f;\n            constexpr f32 k_far = 1.0f;\n            auto projMatrix = Matrix4::CreateOrthographicProjectionLH(0, f32(renderFrame.GetResolution().x), 0, f32(renderFrame.GetResolution().y), k_near, k_far);\n            RenderCamera uiCamera(Matrix4::k_identity, projMatrix, Quaternion::k_identity);\n            \n            auto uiRenderObjects = GetLayerRenderObjects(RenderLayer::k_ui, renderFrame.GetRenderObjects());\n            auto visibleUIRenderObjects = RenderPassVisibilityChecker::CalculateVisibleObjects(taskContext, uiCamera, uiRenderObjects);\n            \n            auto uiRenderPassObjects = GetTransparentRenderPassObjects(visibleUIRenderObjects);\n            CS_ASSERT(visibleUIRenderObjects.size() == uiRenderPassObjects.size(), \"Invalid number of render pass objects in transparent pass. All render objects in the UI layer should have a transparent material.\");\n            \n            RenderPassObjectSorter::PrioritySort(uiRenderPassObjects);\n            \n            std::vector<RenderPass> renderPasses;\n            if (uiRenderPassObjects.size() > 0)\n            {\n                renderPasses.push_back(RenderPass(std::move(uiRenderPassObjects)));\n            }\n            \n            return CameraRenderPassGroup(uiCamera, std::move(renderPasses));\n        }\n        \n        /// Gather all render objects in the frame that are to be renderered into the default RenderTarget\n        /// into a TargetRenderPassGroup.\n        ///\n        /// @param taskContext\n        ///     Context to manage any spawned tasks\n        /// @param renderFrame\n        ///     Current frame data\n        ///\n        /// @return The TargetRenderPassGroup\n        ///\n        TargetRenderPassGroup CompileMainTargetRenderPassGroup(const TaskContext& taskContext, const RenderFrame& renderFrame) noexcept\n        {\n            constexpr u32 k_numGroups = 4;\n            \n            std::vector<CameraRenderPassGroup> cameraRenderPassGroups(k_numGroups);\n            std::vector<Task> tasks;\n            u32 nextIndex = 0;\n            \n            // Scene camera group - Opaque\n            u32 sceneIndexO = nextIndex++;\n            tasks.push_back([=, &cameraRenderPassGroups, &renderFrame](const TaskContext& innerTaskContext)\n            {\n                cameraRenderPassGroups[sceneIndexO] = CompileOpaqueSceneCameraRenderPassGroup(innerTaskContext, renderFrame);\n            });\n            \n            // Skybox camera group - Rendered after the other scene objects to reduce overdraw. The shader and material settings ensure\n            // that depth testing isn't an issue.\n            u32 skyboxIndex = nextIndex++;\n            tasks.push_back([=, &cameraRenderPassGroups, &renderFrame](const TaskContext& innerTaskContext)\n            {\n                cameraRenderPassGroups[skyboxIndex] = CompileSkyboxCameraRenderPassGroup(innerTaskContext, renderFrame);\n            });\n            \n            // Scene camera group - Transparent\n            u32 sceneIndexT = nextIndex++;\n            tasks.push_back([=, &cameraRenderPassGroups, &renderFrame](const TaskContext& innerTaskContext)\n            {\n                cameraRenderPassGroups[sceneIndexT] = CompileTransparentSceneCameraRenderPassGroup(innerTaskContext, renderFrame);\n            });\n            \n            // UI camera group\n            u32 uiIndex = nextIndex++;\n            tasks.push_back([=, &cameraRenderPassGroups, &renderFrame](const TaskContext& innerTaskContext)\n            {\n                cameraRenderPassGroups[uiIndex] = CompileUICameraRenderPassGroup(innerTaskContext, renderFrame);\n            });\n            \n            taskContext.ProcessChildTasks(tasks);\n            \n            if(renderFrame.GetOffscreenRenderTarget() == nullptr)\n            {\n                return TargetRenderPassGroup(renderFrame.GetResolution(), renderFrame.GetClearColour(), std::move(cameraRenderPassGroups));\n            }\n            else\n            {\n                return TargetRenderPassGroup(renderFrame.GetOffscreenRenderTarget(), renderFrame.GetClearColour(), std::move(cameraRenderPassGroups));\n            }\n        }\n        \n        /// Gather all render objects in the frame that are to be renderered into a shadow RenderTarget\n        /// into a TargetRenderPassGroup.\n        ///\n        /// @param taskContext\n        ///     Context to manage any spawned tasks\n        /// @param renderFrame\n        ///     Current frame data\n        /// @param directionalRenderLight\n        ///     The directional light that should have a shadow map built for it.\n        ///\n        /// @return The TargetRenderPassGroup\n        ///\n        TargetRenderPassGroup CompileShadowMapTargetRenderPassGroup(const TaskContext& taskContext, const RenderFrame& renderFrame, const DirectionalRenderLight& directionalRenderLight) noexcept\n        {\n            CS_ASSERT(directionalRenderLight.GetShadowMapTarget(), \"Cannot compile shadow map target with light that has no shadow map target.\");\n            \n            RenderCamera camera(directionalRenderLight.GetLightWorldMatrix(), directionalRenderLight.GetLightProjectionMatrix(), directionalRenderLight.GetLightOrientation());\n            \n            auto standardRenderObjects = GetLayerRenderObjects(RenderLayer::k_standard, renderFrame.GetRenderObjects());\n            auto visibleStandardRenderObjects = RenderPassVisibilityChecker::CalculateVisibleObjects(taskContext, renderFrame.GetRenderCamera(), standardRenderObjects);\n            auto renderPassObjects = GetShadowMapRenderPassObjects(visibleStandardRenderObjects);\n            RenderPassObjectSorter::OpaqueSort(renderFrame.GetRenderCamera(), renderPassObjects);\n            RenderPass renderPass(std::move(renderPassObjects));\n            \n            std::vector<RenderPass> renderPasses;\n            renderPasses.push_back(std::move(renderPass));\n            CameraRenderPassGroup cameraRenderPassGroup(camera, std::move(renderPasses));\n            \n            std::vector<CameraRenderPassGroup> cameraRenderPassGroups;\n            cameraRenderPassGroups.push_back(std::move(cameraRenderPassGroup));\n            return TargetRenderPassGroup(directionalRenderLight.GetShadowMapTarget(), Colour::k_black, std::move(cameraRenderPassGroups));\n        }\n    }\n    \n    //------------------------------------------------------------------------------\n    std::vector<TargetRenderPassGroup> ForwardRenderPassCompiler::CompileTargetRenderPassGroups(const TaskContext& taskContext, std::vector<RenderFrame>&& renderFrames) noexcept\n    {\n        u32 numTargets = 0;\n        for(const auto& renderFrame : renderFrames)\n        {\n            numTargets += CalcNumTargets(renderFrame);\n        }\n        \n        std::vector<TargetRenderPassGroup> targetRenderPassGroups(numTargets);\n        std::vector<Task> tasks;\n        u32 nextPassIndex = 0;\n        \n        for(const auto& renderFrame : renderFrames)\n        {\n            // Shadow targets\n            for (const auto& directionalRenderLight : renderFrame.GetDirectionalRenderLights())\n            {\n                if (directionalRenderLight.GetShadowMapTarget())\n                {\n                    u32 shadowPassIndex = nextPassIndex++;\n                    tasks.push_back([=, &targetRenderPassGroups, &renderFrame, &directionalRenderLight](const TaskContext& innerTaskContext)\n                    {\n                        targetRenderPassGroups[shadowPassIndex] = CompileShadowMapTargetRenderPassGroup(innerTaskContext, renderFrame, directionalRenderLight);\n                    });\n                }\n            }\n            \n            // Main target (screen or offscreen target)\n            u32 mainPassIndex = nextPassIndex++;\n            tasks.push_back([=, &targetRenderPassGroups, &renderFrame](const TaskContext& innerTaskContext)\n            {\n                targetRenderPassGroups[mainPassIndex] = CompileMainTargetRenderPassGroup(innerTaskContext, renderFrame);\n            });\n        }\n        \n        taskContext.ProcessChildTasks(tasks);\n        \n        return targetRenderPassGroups;\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Base/ForwardRenderPassCompiler.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_BASE_FORWARDRENDERPASSCOMPILER_H_\n#define _CHILLISOURCE_RENDERING_BASE_FORWARDRENDERPASSCOMPILER_H_\n\n#include <ChilliSource/ChilliSource.h>\n\n#include <ChilliSource/Rendering/Base/IRenderPassCompiler.h>\n#include <ChilliSource/Rendering/Base/CameraRenderPassGroup.h>\n\nnamespace ChilliSource\n{\n    /// Compiles the RenderPasses required when forward rendering. See ForwardRenderPasses.h for more\n    /// information on these passes.\n    ///\n    /// This breaks the RenderFrame down into a series of RenderPasses ensuring each pass only contains\n    /// the relevant objects by filtering for material type and visibility. Objects within a render pass\n    /// are also sorted into an appropriate order for the type of pass. These render passes are contained\n    /// by a TargetRenderPassGroup, which groups passes based on the framebuffer they are targetting.\n    /// All this is processed in a series of background tasks.\n    ///\n    class ForwardRenderPassCompiler final : public IRenderPassCompiler\n    {\n    public:\n        \n        /// Gather all render objects in the frame into a list of target render pass groups.\n        ///\n        /// @param taskContext\n        ///     Context to manage any spawned tasks\n        /// @param renderFrames\n        ///     Current frame data\n        ///\n        /// @return The list of target render pass groups\n        ///\n        std::vector<TargetRenderPassGroup> CompileTargetRenderPassGroups(const TaskContext& taskContext, std::vector<RenderFrame>&& renderFrames) noexcept override;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Base/FrameAllocatorQueue.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Base/FrameAllocatorQueue.h>\n\nnamespace ChilliSource\n{\n    namespace\n    {\n        constexpr u32 k_numAllocators = 3;\n        constexpr u32 k_allocatorPageSize = 1024 * 1024;\n    }\n    \n    //------------------------------------------------------------------------------\n    FrameAllocatorQueue::FrameAllocatorQueue() noexcept\n    {\n        for (u32 i = 0; i < k_numAllocators; ++i)\n        {\n            PagedLinearAllocatorUPtr allocator(new PagedLinearAllocator(k_allocatorPageSize));\n            m_queue.push_back(allocator.get());\n            m_allocators.push_back(std::move(allocator));\n        }\n    }\n    \n    //------------------------------------------------------------------------------\n    IAllocator* FrameAllocatorQueue::Pop() noexcept\n    {\n        std::unique_lock<std::mutex> lock(m_mutex);\n        \n        while (m_queue.empty())\n        {\n            m_condition.wait(lock);\n        }\n        \n        auto front = m_queue.front();\n        m_queue.pop_front();\n        \n        return front;\n    }\n    \n    //------------------------------------------------------------------------------\n    IAllocator* FrameAllocatorQueue::Front() noexcept\n    {\n        std::unique_lock<std::mutex> lock(m_mutex);\n        \n        while (m_queue.empty())\n        {\n            m_condition.wait(lock);\n        }\n        \n        auto front = m_queue.front();\n        \n        return front;\n    }\n    \n    //------------------------------------------------------------------------------\n    void FrameAllocatorQueue::Push(IAllocator* allocator) noexcept\n    {\n        std::unique_lock<std::mutex> lock(m_mutex);\n        \n#if CS_ENABLE_DEBUG\n        for (IAllocator* queuedAllocators : m_queue)\n        {\n            CS_ASSERT(queuedAllocators != allocator, \"Allocator is already in queue, cannot be pushed twice!\");\n        }\n#endif\n        \n        for (auto& pagedLinearAllocator : m_allocators)\n        {\n            if (pagedLinearAllocator.get() == allocator)\n            {\n                pagedLinearAllocator->Reset();\n                m_queue.push_back(allocator);\n                \n                m_condition.notify_one();\n                return;\n            }\n        }\n        \n        CS_LOG_FATAL(\"Cannot push an allocator that is not owned by this queue\");\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Base/FrameAllocatorQueue.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_BASE_FRAMEALLOCATORQUEUE_H_\n#define _CHILLISOURCE_RENDERING_BASE_FRAMEALLOCATORQUEUE_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Memory/PagedLinearAllocator.h>\n\n#include <condition_variable>\n#include <mutex>\n#include <deque>\n#include <vector>\n\nnamespace ChilliSource\n{\n    /// Creates and manages the frame allocators which will be used during the render\n    /// pipeline. These allocators are queued, allowing users to pop one when required\n    /// and pushed again once finished with. As there are three main stages to the\n    /// render pipeline (snapshot, preparation and command processing) there are three\n    /// allocators in the queue. If all are in use, then this will block until one is\n    /// returned to the manager.\n    ///\n    /// This is thread safe.\n    ///\n    class FrameAllocatorQueue final\n    {\n    public:\n        CS_DECLARE_NOCOPY(FrameAllocatorQueue);\n        \n        FrameAllocatorQueue() noexcept;\n        \n        /// Pops the first frame allocator from the queue. If the queue is empty this will wait\n        /// until one is pushed before popping.\n        ///\n        /// @return The popped frame allocator.\n        ///\n        IAllocator* Pop() noexcept;\n        \n        /// Reads the first frame allocator from the queue. If the queue is empty this will wait\n        /// until one is pushed before reading.\n        ///\n        /// @return The front frame allocator.\n        ///\n        IAllocator* Front() noexcept;\n        \n        /// Pushes an allocator back into the queue for reuse. Prior to being added to the queue\n        /// the allocator will be wiped.\n        ///\n        /// If the given allocator didn't originate from this queue then this will assert.\n        ///\n        /// @param allocator\n        ///     The allocator which should be returned to the queue.\n        ///\n        void Push(IAllocator* allocator) noexcept;\n        \n    private:\n        std::mutex m_mutex;\n        std::condition_variable m_condition;\n        std::deque<IAllocator*> m_queue;\n        std::vector<PagedLinearAllocatorUPtr> m_allocators;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Base/HorizontalTextJustification.cpp",
    "content": "//\n//  HorizontalTextJustification.cpp\n//  ChilliSource\n//  Created by Ian Copland on 10/11/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2011 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Base/HorizontalTextJustification.h>\n\n#include <ChilliSource/Core/String/StringUtils.h>\n\nnamespace ChilliSource\n{\n    //-------------------------------------------------------------------\n    //-------------------------------------------------------------------\n    HorizontalTextJustification ParseHorizontalTextJustification(const std::string& in_string)\n    {\n        std::string verticalJustificationString = in_string;\n        StringUtils::ToLowerCase(verticalJustificationString);\n        \n        if (verticalJustificationString == \"left\")\n        {\n            return HorizontalTextJustification::k_left;\n        }\n        else if (verticalJustificationString == \"centre\")\n        {\n            return HorizontalTextJustification::k_centre;\n        }\n        else if (verticalJustificationString == \"right\")\n        {\n            return HorizontalTextJustification::k_right;\n        }\n        \n        CS_LOG_FATAL(\"Invalid vertical justification.\");\n        return HorizontalTextJustification::k_centre;\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Base/HorizontalTextJustification.h",
    "content": "//\n//  HorizontalTextJustification.h\n//  ChilliSource\n//  Created by Ian Copland on 10/11/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2011 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_BASE_HORIZONTALTEXTJUSTIFICATION_H_\n#define _CHILLISOURCE_RENDERING_BASE_HORIZONTALTEXTJUSTIFICATION_H_\n\n#include <ChilliSource/ChilliSource.h>\n\nnamespace ChilliSource\n{\n    //-------------------------------------------------------------------\n    /// An enum describing the horizontal justification of text.\n    ///\n    /// @author Ian Copland\n    //-------------------------------------------------------------------\n    enum class HorizontalTextJustification\n    {\n        k_left,\n        k_centre,\n        k_right\n    };\n    //-------------------------------------------------------------------\n    /// Parses a horizontal text justification from a string.\n    ///\n    /// @author Ian Copland\n    ///\n    /// @param The string.\n    ///\n    /// @return The horizontal text justification.\n    //-------------------------------------------------------------------\n    HorizontalTextJustification ParseHorizontalTextJustification(const std::string& in_string);\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Base/IRenderCommandProcessor.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Base/IRenderCommandProcessor.h>\n\n#if defined(CS_TARGETPLATFORM_IOS) || defined(CS_TARGETPLATFORM_ANDROID) || defined(CS_TARGETPLATFORM_WINDOWS) || defined(CS_TARGETPLATFORM_RPI)\n#   include <CSBackend/Rendering/OpenGL/Base/RenderCommandProcessor.h>\n#endif\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    IRenderCommandProcessorUPtr IRenderCommandProcessor::Create() noexcept\n    {\n#if defined(CS_TARGETPLATFORM_IOS) || defined(CS_TARGETPLATFORM_ANDROID) || defined(CS_TARGETPLATFORM_WINDOWS) || defined(CS_TARGETPLATFORM_RPI)\n        return IRenderCommandProcessorUPtr(new CSBackend::OpenGL::RenderCommandProcessor());\n#else\n        return nullptr;\n#endif\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Base/IRenderCommandProcessor.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_BASE_IRENDERCOMMANDPROCESSOR_H_\n#define _CHILLISOURCE_RENDERING_BASE_IRENDERCOMMANDPROCESSOR_H_\n\n#include <ChilliSource/ChilliSource.h>\n\n#include <vector>\n\nnamespace ChilliSource\n{\n    /// The interface for RenderCommand processors. A render command processor takes a\n    /// RenderCommandBuffer and performs each action described by the RenderCommands it\n    /// is comprised of. The actions performed depend on the render API that the\n    /// processor represents.\n    ///\n    /// This is not thread safe and must be executed on the render thread.\n    ///\n    class IRenderCommandProcessor\n    {\n    public:\n        CS_DECLARE_NOCOPY(IRenderCommandProcessor);\n        \n        IRenderCommandProcessor() = default;\n        \n        /// Creates a new instance of the render command processor. The specific processor\n        /// type depends on the current platform.\n        ///\n        /// @return The newly created instance.\n        ///\n        static IRenderCommandProcessorUPtr Create() noexcept;\n        \n        /// Processes the given render command buffer, performing the required actions for\n        /// each command as per the render API that this represents.\n        ///\n        /// @param renderCommandBuffer\n        ///     The buffer of render commands that should be processed.\n        ///\n        virtual void Process(const ChilliSource::RenderCommandBuffer* renderCommandBuffer) noexcept = 0;\n        \n        /// Called when the GL context is lost, iterate any GL resources and place\n        /// them in an invalid state\n        ///\n        virtual void Invalidate() noexcept = 0;\n        \n        /// Called when the GL context is restored, need to rebuild any GL resources\n        ///\n        virtual void Restore() noexcept = 0;\n        \n        virtual ~IRenderCommandProcessor() noexcept {}\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Base/IRenderPassCompiler.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_BASE_IRENDERPASSCOMPILER_H_\n#define _CHILLISOURCE_RENDERING_BASE_IRENDERPASSCOMPILER_H_\n\n#include <ChilliSource/ChilliSource.h>\n\n#include <ChilliSource/Rendering/Base/TargetRenderPassGroup.h>\n\nnamespace ChilliSource\n{\n    /// Provides an interface for a render compiler. A render compiler breaks the RenderFrame down\n    /// into a series of RenderPasses ensuring each pass only contains the relevant objects by\n    /// filtering for material type and visibility. Objects within a render pass are also sorted\n    /// into an appropriate order for the type of pass. These render passes are contained by a\n    /// TargetRenderPassGroup, which groups passes based on the framebuffer they are targetting.\n    /// All this is processed in a series of background tasks.\n    ///\n    class IRenderPassCompiler\n    {\n    public:\n        \n        /// Gather all render objects in the frame into a list of target render pass groups.\n        ///\n        /// @param taskContext\n        ///     Context to manage any spawned tasks\n        /// @param renderFrames\n        ///     Current frame data\n        ///\n        /// @return The list of target render pass groups\n        ///\n        virtual std::vector<TargetRenderPassGroup> CompileTargetRenderPassGroups(const TaskContext& taskContext, std::vector<RenderFrame>&& renderFrame) noexcept = 0;\n        \n        virtual ~IRenderPassCompiler() noexcept {};\n        \n    };\n}\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Base/RenderCapabilities.cpp",
    "content": "//\n//  RenderCapabilities.cpp\n//  ChilliSource\n//  Created by Ian Copland on 27/01/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Base/RenderCapabilities.h>\n\nnamespace ChilliSource\n{\n    CS_DEFINE_NAMEDTYPE(RenderCapabilities);\n    \n    //-------------------------------------------------------\n    RenderCapabilitiesUPtr RenderCapabilities::Create(const RenderInfo& renderInfo) noexcept\n    {\n        return RenderCapabilitiesUPtr(new RenderCapabilities(renderInfo.IsShadowMappingSupported(), renderInfo.IsDepthTextureSupported(), renderInfo.IsMapBufferSupported(), renderInfo.IsVAOSupported(),\n                                                             renderInfo.IsHighPrecisionFloatsSupported(), renderInfo.GetMaxTextureSize(), renderInfo.GetNumTextureUnits(), renderInfo.GetNumVertexAttributes()));\n    }\n    \n    //-------------------------------------------------------\n    RenderCapabilities::RenderCapabilities(bool isShadowMapsSupported, bool isDepthTexturesSupported, bool isMapBuffersSupported, bool isVAOSupported, bool isHighPrecisionFloatsSupported, u32 maxTextureSize, u32 numTextureUnits, u32 maxVertexAttribs)\n    : m_isShadowMapsSupported(isShadowMapsSupported), m_isDepthTexturesSupported(isDepthTexturesSupported), m_isMapBuffersSupported(isMapBuffersSupported), m_isVAOSupported(isVAOSupported),\n    m_isHighPrecisionFloatsSupported(isHighPrecisionFloatsSupported), m_maxTextureSize(maxTextureSize), m_maxTextureUnits(numTextureUnits), m_maxVertexAttribs(maxVertexAttribs)\n    {\n    }\n    \n    //-------------------------------------------------------\n    bool RenderCapabilities::IsA(ChilliSource::InterfaceIDType interfaceId) const\n    {\n        return (RenderCapabilities::InterfaceID == interfaceId);\n    }\n    \n    //-------------------------------------------------------\n    bool RenderCapabilities::IsShadowMappingSupported() const noexcept\n    {\n        return m_isShadowMapsSupported;\n    }\n    \n    //-------------------------------------------------------\n    bool RenderCapabilities::IsDepthTextureSupported() const noexcept\n    {\n        return m_isDepthTexturesSupported;\n    }\n    \n    //-------------------------------------------------------\n    bool RenderCapabilities::IsMapBufferSupported() const noexcept\n    {\n        return m_isMapBuffersSupported;\n    }\n    \n    //-------------------------------------------------------\n    bool RenderCapabilities::IsVAOSupported() const noexcept\n    {\n        return m_isVAOSupported;\n    }\n    \n    //-------------------------------------------------------\n    bool RenderCapabilities::IsHighPrecisionFloatsSupported() const noexcept\n    {\n        return m_isHighPrecisionFloatsSupported;\n    }\n    \n    //-------------------------------------------------------\n    u32 RenderCapabilities::GetMaxTextureSize() const noexcept\n    {\n        return m_maxTextureSize;\n    }\n    \n    //-------------------------------------------------------\n    u32 RenderCapabilities::GetNumTextureUnits() const noexcept\n    {\n        return m_maxTextureUnits;\n    }\n    \n    //-------------------------------------------------------\n    u32 RenderCapabilities::GetNumVertexAttributes() const noexcept\n    {\n        return m_maxVertexAttribs;\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Base/RenderCapabilities.h",
    "content": "//\n//  RenderCapabilities.h\n//  ChilliSource\n//  Created by Ian Copland on 27/01/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_BASE_RENDERCAPABILITIES_H_\n#define _CHILLISOURCE_RENDERING_BASE_RENDERCAPABILITIES_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Base/RenderInfo.h>\n#include <ChilliSource/Core/System/AppSystem.h>\n\nnamespace ChilliSource\n{\n    //---------------------------------------------------------------\n    /// A system for getting information on the capabilities of the\n    /// renderer on this specfic device. This includes information\n    /// like whether specific features are available or the maximum\n    /// texture size. This should not be used prior to the render\n    /// system being initialised.\n    ///\n    /// @author Ian Copland\n    //---------------------------------------------------------------\n    class RenderCapabilities final: public AppSystem\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(RenderCapabilities);\n        \n        /// Create the platform dependent backend\n        ///\n        /// @param renderInfo\n        ///     The object containing the render info for the current device\n        ///\n        /// @return New RenderCapabilities instance\n        ///\n        static RenderCapabilitiesUPtr Create(const RenderInfo& renderInfo) noexcept;\n        \n        /// Query the interface type\n        ///\n        /// @param The interface to compare\n        ///\n        /// @return Whether the object implements that interface\n        ///\n        bool IsA(ChilliSource::InterfaceIDType interfaceId) const override;\n\n        /// @return Whether or not shadow mapping is supported.\n        ///\n        bool IsShadowMappingSupported() const noexcept;\n        \n        /// @return Whether or not depth textures are supported.\n        ///\n        bool IsDepthTextureSupported() const noexcept;\n        \n        /// @return Whether or not map buffer is supported\n        ///\n        bool IsMapBufferSupported() const noexcept;\n        \n        /// @return Whether or not vertex array objects are supported.\n        ///\n        bool IsVAOSupported() const noexcept;\n        \n        /// @return Whether or not the fragment shader supports highp floats.\n        ///\n        bool IsHighPrecisionFloatsSupported() const noexcept;\n        \n        /// @return The maximum texture size available on this device.\n        ///\n        u32 GetMaxTextureSize() const noexcept;\n        \n        /// @return The number of texture units supported by this device.\n        ///\n        u32 GetNumTextureUnits() const noexcept;\n        \n        /// @return The number of vertex attributes supported by this device.\n        ///\n        u32 GetNumVertexAttributes() const noexcept;\n       \n    private:\n        \n        /// @param isShadowMapsSupported\n        ///         Whether or not shadow mapping is supported.\n        /// @param isDepthTexturesSupported\n        ///         Whether or not depth textures are supported.\n        /// @param isMapBuffersSupported\n        ///         Whether or not map buffer is supported.\n        /// @param isVAOSupported\n        ///     Whether vertex array objects are supported\n        /// @param isHighPrecisionFloatsSupported\n        ///         Whether or not the fragment shader supports highp floats.\n        /// @param maxTextureSize\n        ///         The maximum texture size available on this device.\n        /// @param numTextureUnits\n        ///         The number of texture units supported by this device.\n        /// @param maxVertexAttribs\n        ///         The max. number of vertex attributes supported by this device.\n        ///\n        RenderCapabilities(bool isShadowMapsSupported, bool isDepthTexturesSupported, bool isMapBuffersSupported, bool isVAOSupported, bool isHighPrecisionFloatsSupported, u32 maxTextureSize, u32 numTextureUnits, u32 maxVertexAttribs);\n        \n    private:\n        \n        bool m_isShadowMapsSupported;\n        bool m_isDepthTexturesSupported;\n        bool m_isMapBuffersSupported;\n        bool m_isVAOSupported;\n        bool m_isHighPrecisionFloatsSupported;\n        \n        u32 m_maxTextureSize;\n        u32 m_maxTextureUnits;\n        u32 m_maxVertexAttribs;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Base/RenderCommandBufferManager.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Base/RenderCommandBufferManager.h>\n\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Rendering/Base/Renderer.h>\n#include <ChilliSource/Rendering/Base/RenderSnapshot.h>\n#include <ChilliSource/Rendering/Base/TargetType.h>\n#include <ChilliSource/Rendering/RenderCommand/RenderCommandBuffer.h>\n\nnamespace ChilliSource\n{\n    namespace\n    {\n        constexpr u32 k_maxQueueSize = 1;\n    }\n    \n    CS_DEFINE_NAMEDTYPE(RenderCommandBufferManager);\n    \n    //------------------------------------------------------------------------------\n    RenderCommandBufferManagerUPtr RenderCommandBufferManager::Create() noexcept\n    {\n        return RenderCommandBufferManagerUPtr(new RenderCommandBufferManager());\n    }\n    //------------------------------------------------------------------------------\n    RenderCommandBufferManager::RenderCommandBufferManager()\n    : m_discardCommands(false)\n    {\n    }\n    //------------------------------------------------------------------------------\n    bool RenderCommandBufferManager::IsA(InterfaceIDType interfaceId) const noexcept\n    {\n        return (RenderCommandBufferManager::InterfaceID == interfaceId);\n    }\n    //------------------------------------------------------------------------------\n    void RenderCommandBufferManager::OnInit() noexcept\n    {\n        m_renderer = Application::Get()->GetSystem<Renderer>();\n    }\n    //------------------------------------------------------------------------------\n    void RenderCommandBufferManager::OnResume() noexcept\n    {\n        m_discardCommands = false;\n    }\n    //------------------------------------------------------------------------------\n    void RenderCommandBufferManager::OnSystemSuspend() noexcept\n    {\n        m_discardCommands = true;\n\n        std::unique_lock<std::mutex> lock(m_renderCommandBuffersMutex);\n        \n        if(m_renderCommandBuffers.size() > 0)\n        {\n            for(auto& buffer : m_renderCommandBuffers)\n            {\n                RecycleRenderCommandBuffer(std::move(buffer));\n            }\n            \n            m_renderCommandBuffers.clear();\n        }\n        \n        lock.unlock();\n        \n        //Notify the condition since we have updated the command buffer\n        m_renderCommandBuffersCondition.notify_all();\n    }\n    //------------------------------------------------------------------------------\n    void RenderCommandBufferManager::OnRenderSnapshot(TargetType targetType, RenderSnapshot& renderSnapshot, IAllocator* frameAllocator) noexcept\n    {\n        if(!m_discardCommands && targetType == TargetType::k_main)\n        {\n            auto preRenderCommandList = renderSnapshot.GetPreRenderCommandList();\n            auto postRenderCommandList = renderSnapshot.GetPostRenderCommandList();\n            \n            std::unique_lock<std::mutex>(m_commandBufferMutex);\n            \n            for(auto& command : m_pendingShaderLoadCommands)\n            {\n                preRenderCommandList->AddLoadShaderCommand(command.GetRenderShader(), command.GetVertexShader(), command.GetFragmentShader());\n            }\n            \n            for(auto& command : m_pendingTextureLoadCommands)\n            {\n                preRenderCommandList->AddLoadTextureCommand(command.GetRenderTexture(), command.ClaimTextureData(), command.GetTextureDataSize());\n            }\n            \n            for(auto& command : m_pendingCubemapLoadCommands)\n            {\n                preRenderCommandList->AddLoadCubemapCommand(command.GetRenderTexture(), command.ClaimTextureData(), command.GetTextureDataSize());\n            }\n            \n            for(auto& command : m_pendingMeshLoadCommands)\n            {\n                preRenderCommandList->AddLoadMeshCommand(command.GetRenderMesh(), command.ClaimVertexData(), command.GetVertexDataSize(), command.ClaimIndexData(), command.GetIndexDataSize());\n            }\n            \n            for(auto& command : m_pendingMaterialGroupLoadCommands)\n            {\n                preRenderCommandList->AddLoadMaterialGroupCommand(command.GetRenderMaterialGroup());\n            }\n            \n            for(auto& command : m_pendingShaderUnloadCommands)\n            {\n                postRenderCommandList->AddUnloadShaderCommand(command.ClaimRenderShader());\n            }\n            \n            for(auto& command : m_pendingTextureUnloadCommands)\n            {\n                postRenderCommandList->AddUnloadTextureCommand(command.ClaimRenderTexture());\n            }\n            \n            for(auto& command : m_pendingCubemapUnloadCommands)\n            {\n                postRenderCommandList->AddUnloadCubemapCommand(command.ClaimRenderTexture());\n            }\n            \n            for(auto& command : m_pendingMeshUnloadCommands)\n            {\n                postRenderCommandList->AddUnloadMeshCommand(command.ClaimRenderMesh());\n            }\n            \n            for(auto& command : m_pendingMaterialGroupUnloadCommands)\n            {\n                postRenderCommandList->AddUnloadMaterialGroupCommand(command.ClaimRenderMaterialGroup());\n            }\n            \n            m_pendingShaderLoadCommands.clear();\n            m_pendingTextureLoadCommands.clear();\n            m_pendingCubemapLoadCommands.clear();\n            m_pendingMeshLoadCommands.clear();\n            m_pendingMaterialGroupLoadCommands.clear();\n            m_pendingShaderUnloadCommands.clear();\n            m_pendingTextureUnloadCommands.clear();\n            m_pendingCubemapUnloadCommands.clear();\n            m_pendingMeshUnloadCommands.clear();\n            m_pendingMaterialGroupUnloadCommands.clear();\n        }\n    }\n    //------------------------------------------------------------------------------\n    void RenderCommandBufferManager::RecycleRenderCommandBuffer(RenderCommandBufferUPtr buffer) noexcept\n    {\n        for(u32 i = 0; i < buffer->GetNumSlots(); ++i)\n        {\n            RecycleCommandList(buffer->GetRenderCommandList(i));\n        }\n        \n        auto frameAllocator = buffer->GetFrameAllocator();\n        buffer.reset();\n        m_renderer->GetFrameAllocatorQueue().Push(frameAllocator);\n    }\n    //------------------------------------------------------------------------------\n    void RenderCommandBufferManager::RecycleCommandList(RenderCommandList* renderCommandList) noexcept\n    {\n        std::unique_lock<std::mutex>(m_commandBufferMutex);\n        \n        for(u32 i = 0; i < renderCommandList->GetNumCommands(); ++i)\n        {\n            RecycleCommand(renderCommandList->GetCommand(i));\n        }\n    }\n    //------------------------------------------------------------------------------\n    void RenderCommandBufferManager::RecycleCommand(RenderCommand* renderCommand) noexcept\n    {\n        switch(renderCommand->GetType())\n        {\n            case RenderCommand::Type::k_loadShader:\n            {\n                LoadShaderRenderCommand* command = static_cast<LoadShaderRenderCommand*>(renderCommand);\n                m_pendingShaderLoadCommands.push_back(std::move(*command));\n                break;\n            }\n            case RenderCommand::Type::k_loadTexture:\n            {\n                LoadTextureRenderCommand* command = static_cast<LoadTextureRenderCommand*>(renderCommand);\n                m_pendingTextureLoadCommands.push_back(std::move(*command));\n                break;\n            }\n            case RenderCommand::Type::k_loadCubemap:\n            {\n                LoadCubemapRenderCommand* command = static_cast<LoadCubemapRenderCommand*>(renderCommand);\n                m_pendingCubemapLoadCommands.push_back(std::move(*command));\n                break;\n            }\n            case RenderCommand::Type::k_loadMesh:\n            {\n                LoadMeshRenderCommand* command = static_cast<LoadMeshRenderCommand*>(renderCommand);\n                m_pendingMeshLoadCommands.push_back(std::move(*command));\n                break;\n            }\n            case RenderCommand::Type::k_loadMaterialGroup:\n            {\n                LoadMaterialGroupRenderCommand* command = static_cast<LoadMaterialGroupRenderCommand*>(renderCommand);\n                m_pendingMaterialGroupLoadCommands.push_back(std::move(*command));\n                break;\n            }\n            case RenderCommand::Type::k_unloadShader:\n            {\n                UnloadShaderRenderCommand* command = static_cast<UnloadShaderRenderCommand*>(renderCommand);\n                m_pendingShaderUnloadCommands.push_back(std::move(*command));\n                break;\n            }\n            case RenderCommand::Type::k_unloadTexture:\n            {\n                UnloadTextureRenderCommand* command = static_cast<UnloadTextureRenderCommand*>(renderCommand);\n                m_pendingTextureUnloadCommands.push_back(std::move(*command));\n                break;\n            }\n            case RenderCommand::Type::k_unloadCubemap:\n            {\n                UnloadCubemapRenderCommand* command = static_cast<UnloadCubemapRenderCommand*>(renderCommand);\n                m_pendingCubemapUnloadCommands.push_back(std::move(*command));\n                break;\n            }\n            case RenderCommand::Type::k_unloadMesh:\n            {\n                UnloadMeshRenderCommand* command = static_cast<UnloadMeshRenderCommand*>(renderCommand);\n                m_pendingMeshUnloadCommands.push_back(std::move(*command));\n                break;\n            }\n            case RenderCommand::Type::k_unloadMaterialGroup:\n            {\n                UnloadMaterialGroupRenderCommand* command = static_cast<UnloadMaterialGroupRenderCommand*>(renderCommand);\n                m_pendingMaterialGroupUnloadCommands.push_back(std::move(*command));\n                break;\n            }\n            default:\n            {\n                break;\n            }\n        }\n    }\n    //------------------------------------------------------------------------------\n    void RenderCommandBufferManager::WaitThenPushCommandBuffer(RenderCommandBufferUPtr renderCommandBuffer) noexcept\n    {\n        std::unique_lock<std::mutex> lock(m_renderCommandBuffersMutex);\n        \n        while (m_renderCommandBuffers.size() >= k_maxQueueSize)\n        {\n            m_renderCommandBuffersCondition.wait(lock);\n        }\n        \n        if(m_discardCommands)\n        {\n            RecycleRenderCommandBuffer(std::move(renderCommandBuffer));\n        }\n        else\n        {\n            m_renderCommandBuffers.push_back(std::move(renderCommandBuffer));\n        }\n        \n        m_renderCommandBuffersCondition.notify_all();\n    }\n    //------------------------------------------------------------------------------\n    RenderCommandBufferCUPtr RenderCommandBufferManager::WaitThenPopCommandBuffer() noexcept\n    {\n        std::unique_lock<std::mutex> lock(m_renderCommandBuffersMutex);\n        \n        while (m_renderCommandBuffers.empty())\n        {\n            m_renderCommandBuffersCondition.wait(lock);\n        }\n        \n        auto buffer = std::move(m_renderCommandBuffers.front());\n        m_renderCommandBuffers.pop_front();\n        \n        m_renderCommandBuffersCondition.notify_all();\n        \n        return std::move(buffer);\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Base/RenderCommandBufferManager.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_BASE_RENDERCOMMANDBUFFERSYSTEM_H_\n#define _CHILLISOURCE_RENDERING_BASE_RENDERCOMMANDBUFFERSYSTEM_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/System/AppSystem.h>\n\n#include <ChilliSource/Rendering/Model/RenderMesh.h>\n#include <ChilliSource/Rendering/RenderCommand/Commands/LoadMaterialGroupRenderCommand.h>\n#include <ChilliSource/Rendering/RenderCommand/Commands/LoadMeshRenderCommand.h>\n#include <ChilliSource/Rendering/RenderCommand/Commands/LoadShaderRenderCommand.h>\n#include <ChilliSource/Rendering/RenderCommand/Commands/LoadTextureRenderCommand.h>\n#include <ChilliSource/Rendering/RenderCommand/Commands/LoadCubemapRenderCommand.h>\n#include <ChilliSource/Rendering/RenderCommand/Commands/UnloadMaterialGroupRenderCommand.h>\n#include <ChilliSource/Rendering/RenderCommand/Commands/UnloadMeshRenderCommand.h>\n#include <ChilliSource/Rendering/RenderCommand/Commands/UnloadShaderRenderCommand.h>\n#include <ChilliSource/Rendering/RenderCommand/Commands/UnloadTextureRenderCommand.h>\n#include <ChilliSource/Rendering/RenderCommand/Commands/UnloadCubemapRenderCommand.h>\n#include <ChilliSource/Rendering/RenderCommand/RenderCommandBuffer.h>\n#include <ChilliSource/Rendering/Shader/RenderShader.h>\n#include <ChilliSource/Rendering/Texture/RenderTexture.h>\n\n#include <atomic>\n#include <condition_variable>\n#include <deque>\n#include <mutex>\n\nnamespace ChilliSource\n{\n    /// System to manage a number of RenderCommandBuffers for the renderer. It primary function\n    /// is to queue/dequeue command buffers while it also provides means for recycling\n    /// of render commands from a frame on suspend to allow them to be entered at the next one.\n    ///\n    /// This is thread safe, though certain methods need to be called on certain threads.\n    ///\n    class RenderCommandBufferManager : public AppSystem\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(RenderCommandBufferManager);\n        \n        /// Allows querying of whether or not this system implements the interface described by the\n        /// given interface Id. Typically this is not called directly as the templated equivalent\n        /// IsA<Interface>() is preferred.\n        ///\n        /// @param interfaceId\n        ///     The Id of the interface.\n        ///\n        /// @return Whether or not the interface is implemented.\n        ///\n        bool IsA(InterfaceIDType interfaceId) const noexcept override;\n        \n        /// If the queue of command buffers is full then this waits until one has been popped to continue.\n        /// It then adds the given render buffer and notifies any threads which are waiting.\n        ///\n        /// @param renderCommandBuffer\n        ///     The render command buffer which should be pushed. Must be moved.\n        ///\n        void WaitThenPushCommandBuffer(RenderCommandBufferUPtr renderCommandBuffer) noexcept;\n        \n        /// If the queue of command buffers is empty then this waits until one has been pushed to continue.\n        /// It pops the command buffer from the list and notifies any threads which are waiting.\n        ///\n        /// @return The render command buffer that has been popped.\n        ///\n        RenderCommandBufferCUPtr WaitThenPopCommandBuffer() noexcept;\n        \n    private:\n        friend class Application;\n        friend class LifecycleManager;\n\n        /// A factory method for creating new instances of the system. This must be called by\n        /// Application.\n        ///\n        /// @return The new instance of the system.\n        ///\n        static RenderCommandBufferManagerUPtr Create() noexcept;\n\n        RenderCommandBufferManager();\n        \n        /// Will iterate an RenderCommandBuffer and extract any commands that can be recycled\n        /// for next frame.\n        ///\n        /// @param buffer\n        ///     The RenderCommandBuffer to recycle.\n        ///\n        void RecycleRenderCommandBuffer(RenderCommandBufferUPtr buffer) noexcept;\n        \n        /// Called to process a command queue and extract load/unload commands that we\n        /// can recycle and store for use next frame.\n        ///\n        /// @param renderCommandList\n        ///     The render command list to recycle\n        ///\n        void RecycleCommandList(RenderCommandList* renderCommandList) noexcept;\n        \n        /// Called to proccess a command to be recycled. Will decide if its a valid\n        /// recyclable command and then take a copy of its data so we can recreate the\n        /// command later.\n        ///\n        /// @param renderCommand\n        ///     The render command to recycle or ignore\n        ///\n        void RecycleCommand(RenderCommand* renderCommand) noexcept;\n        \n        /// Called when the app system is init.\n        ///\n        /// Called on the main thread.\n        ///\n        void OnInit() noexcept override;\n        \n        /// Called when the app system is resumed.\n        ///\n        /// Called on the main thread.\n        ///\n        void OnResume() noexcept override;\n        \n        /// Called during the Render Snapshot stage of the render pipeline. All pending load commands\n        /// are added to the render snapshot.\n        ///\n        /// @param targetType\n        ///     Whether the snapshot is for the main screen or an offscreen render target\n        /// @param renderSnapshot\n        ///     The render shapshot for storing snapshotted data.\n        /// @param frameAllocator\n        ///     Allocate memory for this render frame from here\n        ///\n        void OnRenderSnapshot(TargetType targetType, RenderSnapshot& renderSnapshot, IAllocator* frameAllocator) noexcept override;\n        \n        /// Called when the application delegate is suspended. This event is called directly\n        /// from the platform application implementation and will be called before the lifecycle\n        /// counterpart.\n        ///\n        /// This should only be called from the render thread by the\n        /// lifecycle manager.\n        ///\n        void OnSystemSuspend() noexcept;\n        \n        \n    private:\n        \n        std::mutex m_commandBufferMutex;\n        \n        std::vector<LoadShaderRenderCommand> m_pendingShaderLoadCommands;\n        std::vector<LoadTextureRenderCommand> m_pendingTextureLoadCommands;\n        std::vector<LoadCubemapRenderCommand> m_pendingCubemapLoadCommands;\n        std::vector<LoadMeshRenderCommand> m_pendingMeshLoadCommands;\n        std::vector<LoadMaterialGroupRenderCommand> m_pendingMaterialGroupLoadCommands;\n        \n        std::vector<UnloadShaderRenderCommand> m_pendingShaderUnloadCommands;\n        std::vector<UnloadTextureRenderCommand> m_pendingTextureUnloadCommands;\n        std::vector<UnloadCubemapRenderCommand> m_pendingCubemapUnloadCommands;\n        std::vector<UnloadMeshRenderCommand> m_pendingMeshUnloadCommands;\n        std::vector<UnloadMaterialGroupRenderCommand> m_pendingMaterialGroupUnloadCommands;\n        \n        std::atomic_bool m_discardCommands;\n        \n        std::mutex m_renderCommandBuffersMutex;\n        std::condition_variable m_renderCommandBuffersCondition;\n        std::deque<RenderCommandBufferUPtr> m_renderCommandBuffers;\n        \n        Renderer* m_renderer = nullptr;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Base/RenderCommandCompiler.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Base/RenderCommandCompiler.h>\n\n#include <ChilliSource/Core/Threading/TaskScheduler.h>\n#include <ChilliSource/Rendering/Base/CameraRenderPassGroup.h>\n#include <ChilliSource/Rendering/Base/RenderPass.h>\n#include <ChilliSource/Rendering/Base/TargetRenderPassGroup.h>\n#include <ChilliSource/Rendering/Model/SmallMeshBatcher.h>\n#include <ChilliSource/Rendering/Target/RenderTargetGroup.h>\n\nnamespace ChilliSource\n{\n    namespace\n    {\n        /// An container for the current cached state of a render command list.\n        ///\n        struct RenderCommandListStateCache final\n        {\n            const RenderMaterial* m_material = nullptr;\n            const RenderMesh* m_mesh = nullptr;\n            const RenderDynamicMesh* m_dynamicMesh = nullptr;\n            const RenderSkinnedAnimation* m_skinnedAnimation = nullptr;\n        };\n        \n        /// Calculates whether a Camera Render Pass Group contains at least one render pass\n        /// object.\n        ///\n        /// @param cameraRenderPassGroup\n        ///     The camera render pass group.\n        ///\n        /// @return Whether or not there is at least one object.\n        ///\n        bool ContainsRenderPassObject(const CameraRenderPassGroup& cameraRenderPassGroup) noexcept\n        {\n            for (const auto& renderPass : cameraRenderPassGroup.GetRenderPasses())\n            {\n                if (renderPass.GetRenderPassObjects().size() > 0)\n                {\n                    return true;\n                }\n            }\n            \n            return false;\n        }\n        \n        /// Calculates the number of render command lists required to process the given list\n        /// of target render pass groups, and pre and post command lists.\n        ///\n        /// @param targetRenderPassGroups\n        ///     The list of target render pass groups.\n        /// @param preRenderCommandList\n        ///     The render command list that should be inserted at the beginning of the queue if\n        ///     the list contains any commands.\n        /// @param postRenderCommandList\n        ///     The render command list that should be inserted at the end of the queue if\n        ///     the list contains any commands.\n        ///\n        /// @return The number of render command lists required.\n        ///\n        u32 CalcNumRenderCommandLists(const std::vector<TargetRenderPassGroup>& targetRenderPassGroups, const RenderCommandList* preRenderCommandList, const RenderCommandList* postRenderCommandList) noexcept\n        {\n            u32 count = 0;\n            \n            if (preRenderCommandList->GetOrderedList().size() > 0)\n            {\n                ++count;\n            }\n            \n            for (const auto& targetRenderPassGroup : targetRenderPassGroups)\n            {\n                ++count; // target setup\n                \n                for (const auto& cameraRenderPassGroup : targetRenderPassGroup.GetRenderCameraGroups())\n                {\n                    for (const auto& renderPass : cameraRenderPassGroup.GetRenderPasses())\n                    {\n                        if (renderPass.GetRenderPassObjects().size() > 0)\n                        {\n                            ++count;\n                        }\n                    }\n                }\n                \n                ++count; // target cleanup\n            }\n            \n            if (postRenderCommandList->GetOrderedList().size() > 0)\n            {\n                ++count;\n            }\n            \n            return count;\n        }\n        \n        /// Adds a new begin command or begin with target group command, depending on whether or\n        /// not a RenderTargetGroup exists.\n        ///\n        /// @param targetRenderPassGroup\n        ///     The target render pass group.\n        /// @param renderCommandList\n        ///     The render command list to add the command to.\n        ///\n        void AddBeginCommand(const TargetRenderPassGroup& targetRenderPassGroup, RenderCommandList* renderCommandList) noexcept\n        {\n            if (targetRenderPassGroup.GetRenderTargetGroup())\n            {\n                renderCommandList->AddBeginWithTargetGroupCommand(targetRenderPassGroup.GetRenderTargetGroup(), targetRenderPassGroup.GetClearColour());\n            }\n            else\n            {\n                renderCommandList->AddBeginCommand(targetRenderPassGroup.GetResolution(), targetRenderPassGroup.GetClearColour());\n            }\n        }\n        \n        /// Adds a new apply light command to the list for the given render pass.\n        ///\n        /// @param renderPass\n        ///     The render pass.\n        /// @param renderCommandList\n        ///     The render command list to add the command to.\n        ///\n        void AddApplyLightCommand(const RenderPass& renderPass, RenderCommandList* renderCommandList) noexcept\n        {\n            switch (renderPass.GetLightType())\n            {\n                case RenderPass::LightType::k_none:\n                {\n                    renderCommandList->AddApplyAmbientLightCommand(Colour::k_black);\n                    break;\n                }\n                case RenderPass::LightType::k_ambient:\n                {\n                    const auto& ambientLight = renderPass.GetAmbientLight();\n                    renderCommandList->AddApplyAmbientLightCommand(ambientLight.GetColour());\n                    break;\n                }\n                case RenderPass::LightType::k_directional:\n                {\n                    const auto& directionalLight = renderPass.GetDirectionalLight();\n                    auto viewProj = Matrix4::Inverse(directionalLight.GetLightWorldMatrix()) * directionalLight.GetLightProjectionMatrix();\n                    \n                    const auto& shadowMapTarget = directionalLight.GetShadowMapTarget();\n                    const RenderTexture* shadowMapTexture = nullptr;\n                    if (shadowMapTarget)\n                    {\n                        shadowMapTexture = shadowMapTarget->GetDepthTarget();\n                        CS_ASSERT(shadowMapTexture, \"Shadow map target must have depth texture.\");\n                    }\n                    \n                    renderCommandList->AddApplyDirectionalLightCommand(directionalLight.GetColour(), directionalLight.GetDirection(), viewProj, directionalLight.GetShadowTolerance(), shadowMapTexture);\n                    break;\n                }\n                case RenderPass::LightType::k_point:\n                {\n                    const auto& pointLight = renderPass.GetPointLight();\n                    renderCommandList->AddApplyPointLightCommand(pointLight.GetColour(), pointLight.GetPosition(), pointLight.GetAttenuation());\n                    break;\n                }\n                default:\n                {\n                    CS_LOG_FATAL(\"Invalid light type.\");\n                    break;\n                }\n            }\n        }\n        \n        /// Adds a new apply material command.\n        ///\n        /// If the cache already contains the material the no command will be generated.\n        ///\n        /// @param renderPassObject\n        ///     The render pass object to create the command for.\n        /// @param renderCommandList\n        ///     The render command list to add the command to.\n        /// @param cache\n        ///     The current render command list state cache.\n        /// @param batcher\n        ///     The current small mesh batcher.\n        ///\n        void AddApplyMaterialCommand(const RenderPassObject& renderPassObject, RenderCommandList* renderCommandList, RenderCommandListStateCache& cache, SmallMeshBatcher& batcher) noexcept\n        {\n            if (renderPassObject.GetRenderMaterial() != cache.m_material)\n            {\n                batcher.Flush();\n                \n                cache.m_material = renderPassObject.GetRenderMaterial();\n                cache.m_mesh = nullptr;\n                cache.m_dynamicMesh = nullptr;\n                cache.m_skinnedAnimation = nullptr;\n                \n                renderCommandList->AddApplyMaterialCommand(cache.m_material);\n            }\n        }\n        \n        /// Adds either a new apply mesh, or apply dynamic mesh command depending on the type of\n        /// render pass object.\n        ///\n        /// The the cache already contains the mesh then no command will be generated.\n        ///\n        /// @param renderPassObject\n        ///     The render pass object to create the command for.\n        /// @param renderCommandList\n        ///     The render command list to add the command to.\n        /// @param cache\n        ///     The current render command list state cache.\n        ///\n        void AddApplyMeshCommand(const RenderPassObject& renderPassObject, RenderCommandList* renderCommandList, RenderCommandListStateCache& cache) noexcept\n        {\n            switch (renderPassObject.GetType())\n            {\n                case RenderPassObject::Type::k_static:\n                case RenderPassObject::Type::k_staticAnimated:\n                {\n                    if (renderPassObject.GetRenderMesh() != cache.m_mesh)\n                    {\n                        cache.m_mesh = renderPassObject.GetRenderMesh();\n                        cache.m_dynamicMesh = nullptr;\n                        cache.m_skinnedAnimation = nullptr;\n                        \n                        renderCommandList->AddApplyMeshCommand(cache.m_mesh);\n                    }\n                    break;\n                }\n                case RenderPassObject::Type::k_dynamic:\n                case RenderPassObject::Type::k_dynamicAnimated:\n                {\n                    if (renderPassObject.GetRenderDynamicMesh() != cache.m_dynamicMesh)\n                    {\n                        cache.m_mesh = nullptr;\n                        cache.m_dynamicMesh = renderPassObject.GetRenderDynamicMesh();\n                        cache.m_skinnedAnimation = nullptr;\n                        \n                        renderCommandList->AddApplyDynamicMeshCommand(cache.m_dynamicMesh);\n                    }\n                    break;\n                }\n                default:\n                    CS_LOG_FATAL(\"Invalid RenderPassObject type.\");\n                    break;\n            }\n        }\n        \n        /// Adds either a new apply skinned animation command if the object has animation.\n        ///\n        /// The the cache already contains the skinned animation, then no command will be\n        /// generated.\n        ///\n        /// @param renderPassObject\n        ///     The render pass object to create the command for.\n        /// @param renderCommandList\n        ///     The render command list to add the command to.\n        /// @param cache\n        ///     The current render command list state cache.\n        ///\n        void AddApplySkinnedAnimationCommand(const RenderPassObject& renderPassObject, RenderCommandList* renderCommandList, RenderCommandListStateCache& cache) noexcept\n        {\n            if ((renderPassObject.GetType() == RenderPassObject::Type::k_staticAnimated || renderPassObject.GetType() == RenderPassObject::Type::k_dynamicAnimated)\n                && cache.m_skinnedAnimation != renderPassObject.GetRenderSkinnedAnimation())\n            {\n                cache.m_skinnedAnimation = renderPassObject.GetRenderSkinnedAnimation();\n                \n                renderCommandList->AddApplySkinnedAnimationCommand(cache.m_skinnedAnimation);\n            }\n        }\n        \n        /// Compiles the render commands for the given render pass. The render pass must contain\n        /// render pass objects otherwise this will assert.\n        ///\n        /// @param renderPass\n        ///     The render pass.\n        /// @param renderCommandList\n        ///     The render command list to add the commands to.\n        /// @param renderFrameData\n        ///     Container for all allocations which must live until the end of the frame.\n        ///\n        void CompileRenderCommandsForPass(const RenderPass& renderPass, RenderCommandList* renderCommandList) noexcept\n        {\n            AddApplyLightCommand(renderPass, renderCommandList);\n            \n            const auto& renderPassObjects = renderPass.GetRenderPassObjects();\n            CS_ASSERT(renderPassObjects.size() > 0, \"Cannot compile a pass with no objects.\");\n            \n            RenderCommandListStateCache cache;\n            SmallMeshBatcher batcher(renderCommandList);\n            \n            for (const auto& renderPassObject : renderPassObjects)\n            {\n                AddApplyMaterialCommand(renderPassObject, renderCommandList, cache, batcher);\n                \n                if (SmallMeshBatcher::CanBatch(renderPassObject))\n                {\n                    cache.m_mesh = nullptr;\n                    cache.m_dynamicMesh = nullptr;\n                \n                    batcher.Batch(renderPassObject);\n                }\n                else\n                {\n                    batcher.Flush();\n                    \n                    AddApplyMeshCommand(renderPassObject, renderCommandList, cache);\n                    AddApplySkinnedAnimationCommand(renderPassObject, renderCommandList, cache);\n                    renderCommandList->AddRenderInstanceCommand(renderPassObject.GetWorldMatrix());\n                }\n                \n            }\n            \n            batcher.Flush();\n        }\n    }\n    \n    //------------------------------------------------------------------------------\n    RenderCommandBufferUPtr RenderCommandCompiler::CompileRenderCommands(const TaskContext& taskContext, IAllocator* frameAllocator, const std::vector<TargetRenderPassGroup>& targetRenderPassGroups, RenderCommandListUPtr preRenderCommandList,\n                                                                         RenderCommandListUPtr postRenderCommandList, std::vector<RenderFrameData> renderFramesData) noexcept\n    {\n        u32 numLists = CalcNumRenderCommandLists(targetRenderPassGroups, preRenderCommandList.get(), postRenderCommandList.get());\n        RenderCommandBufferUPtr renderCommandBuffer(new RenderCommandBuffer(numLists, frameAllocator, std::move(renderFramesData)));\n        std::vector<Task> tasks;\n        u32 currentList = 0;\n        \n        if (preRenderCommandList->GetOrderedList().size() > 0)\n        {\n            *renderCommandBuffer->GetRenderCommandList(currentList++) = std::move(*preRenderCommandList);\n        }\n        \n        for (const auto& targetRenderPassGroup : targetRenderPassGroups)\n        {\n            AddBeginCommand(targetRenderPassGroup, renderCommandBuffer->GetRenderCommandList(currentList++));\n                \n            for (const auto& cameraRenderPassGroup : targetRenderPassGroup.GetRenderCameraGroups())\n            {\n                if (ContainsRenderPassObject(cameraRenderPassGroup))\n                {\n                    const auto& camera = cameraRenderPassGroup.GetCamera();\n                    renderCommandBuffer->GetRenderCommandList(currentList)->AddApplyCameraCommand(camera.GetWorldMatrix().GetTranslation(), Matrix4::Inverse(camera.GetWorldMatrix()), camera.GetViewProjectionMatrix());\n                    \n                    for (const auto& renderPass : cameraRenderPassGroup.GetRenderPasses())\n                    {\n                        if (renderPass.GetRenderPassObjects().size() > 0)\n                        {\n                            auto renderCommandList = renderCommandBuffer->GetRenderCommandList(currentList++);\n                            tasks.push_back([=, &renderPass, &renderCommandBuffer](const TaskContext& innerTaskContext)\n                            {\n                                CompileRenderCommandsForPass(renderPass, renderCommandList);\n                            });\n                        }\n                    }\n                }\n            }\n            \n            renderCommandBuffer->GetRenderCommandList(currentList++)->AddEndCommand();\n        }\n        \n        if (postRenderCommandList->GetOrderedList().size() > 0)\n        {\n            *renderCommandBuffer->GetRenderCommandList(currentList++) = std::move(*postRenderCommandList);\n        }\n        \n        if (tasks.size() > 0)\n        {\n            taskContext.ProcessChildTasks(tasks);\n        }\n        \n        return renderCommandBuffer;\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Base/RenderCommandCompiler.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_BASE_RENDERCOMMANDCOMPILER_H_\n#define _CHILLISOURCE_RENDERING_BASE_RENDERCOMMANDCOMPILER_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Rendering/RenderCommand/RenderCommandBuffer.h>\n\n#include <vector>\n\nnamespace ChilliSource\n{\n    /// A container for functions relating to the Compile Render Commands stage of the\n    /// render pipeline.\n    ///\n    namespace RenderCommandCompiler\n    {\n        /// Performs the Compile Render Commands stage of the render pipeline. This takes the\n        /// render passes generated during the Compile Render Passes stage and breaks them down\n        /// into a series of render commands. The output is an immutable render command buffer.\n        ///\n        /// @param frameAllocator\n        ///     Allocator that was used to build this render frame\n        /// @param taskContext\n        ///     The task context that child tasks should be run within. This assumes that the\n        ///     method is being called from within another task, as per the render pipeline\n        ///     design.\n        /// @param targetRenderPassGroups\n        ///     The list of TargetRenderPassGroups containing all of the render passes.\n        /// @param preRenderCommandList\n        ///     The RenderCommandList that should be included first. Must be moved.\n        /// @param postRenderCommandList\n        ///     The RenderCommandList that should be included last. Must be moved.\n        /// @param renderFramesData\n        ///     List of containers for all data allocated this frame that must persist to the end of the\n        ///     render pipeline. Must be moved.\n        ///\n        /// @return The render command buffer.\n        ///\n        RenderCommandBufferUPtr CompileRenderCommands(const TaskContext& taskContext, IAllocator* frameAllocator, const std::vector<TargetRenderPassGroup>& targetRenderPassGroups, RenderCommandListUPtr preRenderCommandList,\n                                                      RenderCommandListUPtr postRenderCommandList, std::vector<RenderFrameData> renderFramesData) noexcept;\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Base/RenderFrame.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Base/RenderFrame.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    RenderFrame::RenderFrame(const RenderTargetGroup* renderTarget, const Integer2& resolution, const Colour& clearColour, const RenderCamera& renderCamera, const AmbientRenderLight& renderAmbientLight,\n                             const std::vector<DirectionalRenderLight>& renderDirectionalLights, const std::vector<PointRenderLight>& renderPointLights, const std::vector<RenderObject>& renderObjects) noexcept\n        : m_offscreenRenderTarget(renderTarget), m_resolution(resolution), m_clearColour(clearColour), m_renderCamera(renderCamera), m_renderAmbientLight(renderAmbientLight), m_renderDirectionalLights(renderDirectionalLights),\n          m_renderPointLights(renderPointLights), m_renderObjects(renderObjects)\n    {\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Base/RenderFrame.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_BASE_RENDERFRAME_H_\n#define _CHILLISOURCE_RENDERING_BASE_RENDERFRAME_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Base/Colour.h>\n#include <ChilliSource/Core/Math/Vector2.h>\n#include <ChilliSource/Rendering/Base/RenderObject.h>\n#include <ChilliSource/Rendering/Camera/RenderCamera.h>\n#include <ChilliSource/Rendering/Lighting/AmbientRenderLight.h>\n#include <ChilliSource/Rendering/Lighting/DirectionalRenderLight.h>\n#include <ChilliSource/Rendering/Lighting/PointRenderLight.h>\n\n#include <vector>\n\nnamespace ChilliSource\n{\n    /// A container for the camera and all lights and objects within a single frame.\n    ///\n    /// This is immutable and therefore thread safe.\n    ///\n    class RenderFrame final\n    {\n    public:\n        \n        RenderFrame() = default;\n        \n        /// Creates a new instance with the given camera, lights and objects.\n        ///\n        /// @param renderTarget\n        ///     The render target to render into, if null renders to screen (frame buffer)\n        /// @param resolution\n        ///     The resolution of the viewport.\n        /// @param clearColour\n        ///     The clear colour of the default render target.\n        /// @param renderCamera\n        ///     The camera used for the frame.\n        /// @param renderAmbientLight\n        ///     An ambient light that represents the combination of all ambient lights in the\n        ///     scene.\n        /// @param renderDirectionalLights\n        ///     A list of directional lights in the frame.\n        /// @param renderPointLights\n        ///     A list of point lights in the frame.\n        /// @param renderObjects\n        ///     A list of objects in the frame.\n        ///\n        RenderFrame(const RenderTargetGroup* renderTarget, const Integer2& resolution, const Colour& clearColour, const RenderCamera& renderCamera, const AmbientRenderLight& renderAmbientLight, const std::vector<DirectionalRenderLight>& renderDirectionalLights,\n                    const std::vector<PointRenderLight>& renderPointLights, const std::vector<RenderObject>& renderObjects) noexcept;\n        \n        /// @return The resolution of the viewport.\n        ///\n        const Integer2& GetResolution() const noexcept { return m_resolution; }\n        \n        /// @return The clear colour of the default render target.\n        ///\n        const Colour& GetClearColour() const noexcept { return m_clearColour; }\n        \n        /// @return The camera used for the frame.\n        ///\n        const RenderCamera& GetRenderCamera() const noexcept { return m_renderCamera; }\n        \n        /// @return An ambient light that represents the combination of all ambient lights in the\n        ///     scene.\n        ///\n        const AmbientRenderLight& GetAmbientRenderLight() const noexcept { return m_renderAmbientLight; }\n        \n        /// @return A list of directional lights in the frame.\n        ///\n        const std::vector<DirectionalRenderLight>& GetDirectionalRenderLights() const noexcept { return m_renderDirectionalLights; }\n        \n        /// @return A list of point lights in the frame.\n        ///\n        const std::vector<PointRenderLight>& GetPointRenderLights() const noexcept { return m_renderPointLights; }\n        \n        /// @return A list of objects in the frame.\n        ///\n        const std::vector<RenderObject>& GetRenderObjects() const noexcept { return m_renderObjects; }\n        \n        ///@return Render target for this frame, if null defaults to the frame buffer\n        ///\n        const RenderTargetGroup* GetOffscreenRenderTarget() const noexcept { return m_offscreenRenderTarget; }\n        \n    private:\n        Integer2 m_resolution;\n        Colour m_clearColour;\n        RenderCamera m_renderCamera;\n        AmbientRenderLight m_renderAmbientLight;\n        std::vector<DirectionalRenderLight> m_renderDirectionalLights;\n        std::vector<PointRenderLight> m_renderPointLights;\n        std::vector<RenderObject> m_renderObjects;\n        const RenderTargetGroup* m_offscreenRenderTarget;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Base/RenderFrameCompiler.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Base/RenderFrameCompiler.h>\n\n#include <vector>\n\nnamespace ChilliSource\n{\n    namespace\n    {\n        /// There is no reason to perform the ambient pass for each light separately, so\n        /// the ambient light values can all be merged into a single light for the sake\n        /// of performance.\n        ///\n        /// @param renderAmbientLights\n        ///     The list of render ambient lights in the frame.\n        ///\n        /// @return A single ambient light representing all of the lights in the frame.\n        ///\n        AmbientRenderLight MergeAmbientRenderLights(const std::vector<AmbientRenderLight>& renderAmbientLights)\n        {\n            Colour mergedAmbientColour = Colour::k_transparent;\n            \n            for (const auto& renderAmbientLight : renderAmbientLights)\n            {\n                mergedAmbientColour += renderAmbientLight.GetColour();\n            }\n            \n            mergedAmbientColour.a = 1.0f;\n            \n            return AmbientRenderLight(mergedAmbientColour);\n        }\n    }\n    \n    //------------------------------------------------------------------------------\n    RenderFrame RenderFrameCompiler::CompileRenderFrame(const RenderTargetGroup* renderTarget, const Integer2& resolution, const Colour& clearColour, const RenderCamera& renderCamera, const std::vector<AmbientRenderLight>& renderAmbientLights,\n                                                        const std::vector<DirectionalRenderLight>& renderDirectionalLights, const std::vector<PointRenderLight>& renderPointLights,\n                                                        const std::vector<RenderObject>& renderObjects) noexcept\n    {\n        //TODO: Perform all render jobs in background tasks prior to building the complete render frame.\n        \n        auto renderAmbientLight = MergeAmbientRenderLights(renderAmbientLights);\n        \n        return RenderFrame(renderTarget, resolution, clearColour, renderCamera, renderAmbientLight, renderDirectionalLights, renderPointLights, renderObjects);\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Base/RenderFrameCompiler.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_BASE_RENDERFRAMECOMPILER_H_\n#define _CHILLISOURCE_RENDERING_BASE_RENDERFRAMECOMPILER_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Rendering/Base/RenderFrame.h>\n\n#include <vector>\n\nnamespace ChilliSource\n{\n    /// A container for functions relating to the Compile Render Frame stage of the\n    /// render pipeline.\n    ///\n    namespace RenderFrameCompiler\n    {\n        /// Performs the Compile Frame Frame state of the render pipeline. This takes\n        /// all render primitives from the render snapshot phase and compiles them into\n        /// a single immutable construct. During compilation all render jobs are performed\n        /// to generate additional render primitives.\n        ///\n        /// @param renderTarget\n        ///     The render target to render into, if null renders to screen (frame buffer)\n        /// @param resolution\n        ///     The resolution of the viewport.\n        /// @param clearColour\n        ///     The clar colour of the screen.\n        /// @param renderCamera\n        ///     The camera used for the frame.\n        /// @param renderAmbientLights\n        ///     A list of ambient lights in the frame.\n        /// @param renderDirectionalLights\n        ///     A list of directional lights in the frame.\n        /// @param renderPointLights\n        ///     A list of point lights in the frame.\n        /// @param renderObjects\n        ///     A list of objects in the frame.\n        ///\n        /// @return The compiled render frame.\n        ///\n        RenderFrame CompileRenderFrame(const RenderTargetGroup* renderTarget, const Integer2& resolution, const Colour& clearColour, const RenderCamera& renderCamera, const std::vector<AmbientRenderLight>& renderAmbientLights,\n                                       const std::vector<DirectionalRenderLight>& renderDirectionalLights, const std::vector<PointRenderLight>& renderPointLights,\n                                       const std::vector<RenderObject>& renderObjects) noexcept;\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Base/RenderFrameData.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Base/RenderFrameData.h>\n\n#include <vector>\n\nnamespace ChilliSource\n{\n    \n    //------------------------------------------------------------------------------\n    RenderFrameData::RenderFrameData() noexcept\n    {\n    }\n    \n    //------------------------------------------------------------------------------\n    void RenderFrameData::AddRenderDynamicMesh(RenderDynamicMeshAUPtr renderDynamicMesh) noexcept\n    {\n        CS_ASSERT(renderDynamicMesh, \"Cannot add null render frame data.\");\n        \n        m_renderDynamicMeshes.push_back(std::move(renderDynamicMesh));\n    }\n    \n    //------------------------------------------------------------------------------\n    void RenderFrameData::AddRenderSkinnedAnimation(RenderSkinnedAnimationAUPtr renderSkinnedAnimation) noexcept\n    {\n        CS_ASSERT(renderSkinnedAnimation, \"Cannot add null render frame data.\");\n        \n        m_renderSkinnedAnimations.push_back(std::move(renderSkinnedAnimation));\n    }\n};\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Base/RenderFrameData.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_BASE_RENDERFRAMEDATA_H_\n#define _CHILLISOURCE_RENDERING_BASE_RENDERFRAMEDATA_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Memory/IAllocator.h>\n#include <ChilliSource/Rendering/Model/RenderDynamicMesh.h>\n#include <ChilliSource/Rendering/Model/RenderSkinnedAnimation.h>\n\n#include <vector>\n\nnamespace ChilliSource\n{\n    /// A container for data which needs to persist for the full length of a frame, being passed\n    /// down the render pipeline. This includes dynamically created meshes and animation data.\n    /// This data is typically allocated frame allocator, so a handle to it is also held.\n    ///\n    /// This is not thread-safe and must only be accessed by one thread at a time.\n    ///\n    class RenderFrameData final\n    {\n    public:\n        CS_DECLARE_NOCOPY(RenderFrameData);\n        \n        RenderFrameData(RenderFrameData&&) = default;\n        RenderFrameData& operator=(RenderFrameData&&) = default;\n        RenderFrameData() noexcept;\n        \n        /// Adds a RenderDynamicMesh. This will be deleted at the end of the frame.\n        ///\n        /// @param renderDynamicMesh\n        ///     The render dynamic mesh.\n        ///\n        void AddRenderDynamicMesh(RenderDynamicMeshAUPtr renderDynamicMesh) noexcept;\n        \n        /// Adds a RenderSkinnedAnimation. This will be deleted at the end of the frame.\n        ///\n        /// @param renderSkinnedAnimation\n        ///     The render skinned animation.\n        ///\n        void AddRenderSkinnedAnimation(RenderSkinnedAnimationAUPtr renderSkinnedAnimation) noexcept;\n        \n    private:\n        std::vector<RenderDynamicMeshAUPtr> m_renderDynamicMeshes;\n        std::vector<RenderSkinnedAnimationAUPtr> m_renderSkinnedAnimations;\n    };\n};\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Base/RenderLayer.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_BASE_RENDERLAYER_H_\n#define _CHILLISOURCE_RENDERING_BASE_RENDERLAYER_H_\n\n#include <ChilliSource/ChilliSource.h>\n\nnamespace ChilliSource\n{\n    /// An enum describing the different render layers. These are used to filter different\n    /// render objects into different groups.\n    ///\n    /// \"Standard\": The standard scene layer, rendered using the main camera.\n    ///\n    /// \"UI\": The UI layer, rendered using an orthographic camera with the same resolution as\n    /// the viewport.\n    ///\n    /// \"Skybox\": The Skybox layer, rendered using the main camera's projection matrix and orientation but not any translation transforms.\n    /// Rendered behind all other scene objects.\n    ///\n    enum class RenderLayer\n    {\n        k_standard,\n        k_ui,\n        k_skybox\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Base/RenderObject.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Base/RenderObject.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    RenderObject::RenderObject(const RenderMaterialGroup* renderMaterialGroup, const RenderMesh* renderMesh, const Matrix4& worldMatrix, const Sphere& boundingSphere, bool shouldCastShadows,\n                               RenderLayer renderLayer, u32 priority) noexcept\n        : m_type(Type::k_static), m_renderMaterialGroup(renderMaterialGroup), m_renderMesh(renderMesh), m_worldMatrix(worldMatrix), m_boundingSphere(boundingSphere), m_shouldCastShadows(shouldCastShadows),\n          m_renderLayer(renderLayer), m_priority(priority)\n    {\n        CS_ASSERT(m_renderMaterialGroup, \"Cannot supply a null render material group.\");\n        CS_ASSERT(m_renderMesh, \"Cannot supply a null render mesh.\");\n    }\n    \n    //------------------------------------------------------------------------------\n    RenderObject::RenderObject(const RenderMaterialGroup* renderMaterialGroup, const RenderMesh* renderMesh, const RenderSkinnedAnimation* renderSkinnedAnimation, const Matrix4& worldMatrix,\n                               const Sphere& boundingSphere, bool shouldCastShadows, RenderLayer renderLayer, u32 priority) noexcept\n        : m_type(Type::k_staticAnimated), m_renderMaterialGroup(renderMaterialGroup), m_renderMesh(renderMesh), m_renderSkinnedAnimation(renderSkinnedAnimation), m_worldMatrix(worldMatrix),\n          m_boundingSphere(boundingSphere), m_shouldCastShadows(shouldCastShadows), m_renderLayer(renderLayer), m_priority(priority)\n    {\n        CS_ASSERT(m_renderMaterialGroup, \"Cannot supply a null render material group.\");\n        CS_ASSERT(m_renderMesh, \"Cannot supply a null render mesh.\");\n        CS_ASSERT(m_renderSkinnedAnimation, \"Cannot supply a null render skinned animation.\");\n    }\n    \n    //------------------------------------------------------------------------------\n    RenderObject::RenderObject(const RenderMaterialGroup* renderMaterialGroup, const RenderDynamicMesh* renderDynamicMesh, const Matrix4& worldMatrix, const Sphere& boundingSphere, bool shouldCastShadows,\n                               RenderLayer renderLayer, u32 priority) noexcept\n        : m_type(Type::k_dynamic), m_renderMaterialGroup(renderMaterialGroup), m_renderDynamicMesh(renderDynamicMesh), m_worldMatrix(worldMatrix), m_boundingSphere(boundingSphere),\n          m_shouldCastShadows(shouldCastShadows), m_renderLayer(renderLayer), m_priority(priority)\n    {\n        CS_ASSERT(m_renderMaterialGroup, \"Cannot supply a null render material group.\");\n        CS_ASSERT(m_renderDynamicMesh, \"Cannot supply a null render dynamic mesh.\");\n    }\n    \n    //------------------------------------------------------------------------------\n    RenderObject::RenderObject(const RenderMaterialGroup* renderMaterialGroup, const RenderDynamicMesh* renderDynamicMesh, const RenderSkinnedAnimation* renderSkinnedAnimation,\n                               const Matrix4& worldMatrix, const Sphere& boundingSphere, bool shouldCastShadows, RenderLayer renderLayer, u32 priority) noexcept\n        : m_type(Type::k_dynamicAnimated), m_renderMaterialGroup(renderMaterialGroup), m_renderDynamicMesh(renderDynamicMesh), m_renderSkinnedAnimation(renderSkinnedAnimation), m_worldMatrix(worldMatrix),\n          m_boundingSphere(boundingSphere), m_shouldCastShadows(shouldCastShadows), m_renderLayer(renderLayer), m_priority(priority)\n    {\n        CS_ASSERT(m_renderMaterialGroup, \"Cannot supply a null render material group.\");\n        CS_ASSERT(m_renderDynamicMesh, \"Cannot supply a null render dynamic mesh.\");\n        CS_ASSERT(m_renderSkinnedAnimation, \"Cannot supply a null render skinned animation.\");\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Base/RenderObject.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_BASE_RENDEROBJECT_H_\n#define _CHILLISOURCE_RENDERING_BASE_RENDEROBJECT_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Math/Matrix4.h>\n#include <ChilliSource/Core/Math/Geometry/Shapes.h>\n#include <ChilliSource/Rendering/Base/RenderLayer.h>\n#include <ChilliSource/Rendering/Material/RenderMaterialGroup.h>\n#include <ChilliSource/Rendering/Model/RenderMesh.h>\n\nnamespace ChilliSource\n{\n    /// A standard-layout container for data which the renderer requires that relates to a single\n    /// object in the scene, such as mesh data, materials and transform data.\n    ///\n    /// This is immutable and therefore thread safe.\n    ///\n    class RenderObject final\n    {\n    public:\n        /// An enum describing the type of mesh this object represents.\n        ///\n        enum class Type\n        {\n            k_static,\n            k_staticAnimated,\n            k_dynamic,\n            k_dynamicAnimated\n        };\n        \n        /// Creates a new instance with the given material group, mesh and transform data.\n        ///\n        /// @param renderMaterialGroup\n        ///     The material group that should be used when rendering this object.\n        /// @param renderMesh\n        ///     The mesh that should be used when rendering this object.\n        /// @param worldMatrix\n        ///     The world matrix describing the transform of the object.\n        /// @param boundingSphere\n        ///     The world space bounding sphere of the object. This should be build using the local mesh\n        ///     bounding sphere.\n        /// @param shouldCastShadows\n        ///     Whether or not the render object will try to cast shadows. Whether or not a shadow is\n        ///     actually cast is determined by the objects materials, and the lights in the scene.\n        /// @param renderLayer\n        ///     The layer the object should be rendered into.\n        /// @param priority\n        ///     (Optional) The order priority of the render object; lower values will be rendered first.\n        ///     This may or may not be used depending on the render pass the object will be included in.\n        ///     Objects with the same order value will return in an undefined order. Defaults to 0.\n        ///\n        RenderObject(const RenderMaterialGroup* renderMaterialGroup, const RenderMesh* renderMesh, const Matrix4& worldMatrix, const Sphere& boundingSphere, bool shouldCastShadows,\n                     RenderLayer renderLayer, u32 priority = 0) noexcept;\n        \n        /// Creates a new instance with the given material group, mesh, skinned animation and transform data.\n        ///\n        /// @param renderMaterialGroup\n        ///     The material group that should be used when rendering this object.\n        /// @param renderMesh\n        ///     The mesh that should be used when rendering this object.\n        /// @param skinnedAnimation\n        ///     The skinned animation that should be used when rendering this object.\n        /// @param worldMatrix\n        ///     The world matrix describing the transform of the object.\n        /// @param boundingSphere\n        ///     The world space bounding sphere of the object. This should be build using the local mesh\n        ///     bounding sphere.\n        /// @param shouldCastShadows\n        ///     Whether or not the render object will try to cast shadows. Whether or not a shadow is\n        ///     actually cast is determined by the objects materials, and the lights in the scene.\n        /// @param renderLayer\n        ///     The layer the object should be rendered into.\n        /// @param priority\n        ///     (Optional) The order priority of the render object; lower values will be rendered first.\n        ///     This may or may not be used depending on the render pass the object will be included in.\n        ///     Objects with the same order value will return in an undefined order. Defaults to 0.\n        ///\n        RenderObject(const RenderMaterialGroup* renderMaterialGroup, const RenderMesh* renderMesh, const RenderSkinnedAnimation* renderSkinnedAnimation, const Matrix4& worldMatrix, const Sphere& boundingSphere,\n                     bool shouldCastShadows, RenderLayer renderLayer, u32 priority = 0) noexcept;\n        \n        /// Creates a new instance with the given material group, mesh and transform data.\n        ///\n        /// @param renderMaterialGroup\n        ///     The material group that should be used when rendering this object.\n        /// @param renderDynamicMesh\n        ///     The dynamic mesh that should be used when rendering this object.\n        /// @param worldMatrix\n        ///     The world matrix describing the transform of the object.\n        /// @param boundingSphere\n        ///     The world space bounding sphere of the object. This should be build using the local mesh\n        ///     bounding sphere.\n        /// @param shouldCastShadows\n        ///     Whether or not the render object will try to cast shadows. Whether or not a shadow is\n        ///     actually cast is determined by the objects materials, and the lights in the scene.\n        /// @param renderLayer\n        ///     The layer the object should be rendered into.\n        /// @param priority\n        ///     (Optional) The order priority of the render object; lower values will be rendered first.\n        ///     This may or may not be used depending on the sort algorithm used, as is the order\n        ///     of objects with the same priority. Defaults to 0.\n        ///\n        RenderObject(const RenderMaterialGroup* renderMaterialGroup, const RenderDynamicMesh* renderDynamicMesh, const Matrix4& worldMatrix, const Sphere& boundingSphere, bool shouldCastShadows,\n                     RenderLayer renderLayer, u32 priority = 0) noexcept;\n        \n        /// Creates a new instance with the given material group, mesh, skinned animation data,  and\n        /// transform data.\n        ///\n        /// @param renderMaterialGroup\n        ///     The material group that should be used when rendering this object.\n        /// @param renderDynamicMesh\n        ///     The dynamic mesh that should be used when rendering this object.\n        /// @param skinnedAnimation\n        ///     The skinned animation that should be used when rendering this object.\n        /// @param worldMatrix\n        ///     The world matrix describing the transform of the object.\n        /// @param boundingSphere\n        ///     The world space bounding sphere of the object. This should be build using the local mesh\n        ///     bounding sphere.\n        /// @param shouldCastShadows\n        ///     Whether or not the render object will try to cast shadows. Whether or not a shadow is\n        ///     actually cast is determined by the objects materials, and the lights in the scene.\n        /// @param renderLayer\n        ///     The layer the object should be rendered into.\n        /// @param priority\n        ///     (Optional) The order priority of the render object; lower values will be rendered first.\n        ///     This may or may not be used depending on the sort algorithm used, as is the order\n        ///     of objects with the same priority. Defaults to 0.\n        ///\n        RenderObject(const RenderMaterialGroup* renderMaterialGroup, const RenderDynamicMesh* renderDynamicMesh, const RenderSkinnedAnimation* renderSkinnedAnimation, const Matrix4& worldMatrix,\n                     const Sphere& boundingSphere, bool shouldCastShadows, RenderLayer renderLayer, u32 priority = 0) noexcept;\n        \n        /// @return The mesh type of object this describes.\n        ///\n        Type GetType() const noexcept { return m_type; }\n        \n        /// @return The material group that should be used when rendering this object.\n        ///\n        const RenderMaterialGroup* GetRenderMaterialGroup() const noexcept { return m_renderMaterialGroup; }\n        \n        /// @return The static mesh that should be used when rendering this object if this is a static mesh\n        ///     object, otherwise this will return nullptr.\n        ///\n        const RenderMesh* GetRenderMesh() const noexcept { return m_renderMesh; }\n        \n        /// @return The dynamic mesh that should be used when rendering this object if this is a dynamic mesh\n        ///     object, otherwise this will return nullptr.\n        ///\n        const RenderDynamicMesh* GetRenderDynamicMesh() const noexcept { return m_renderDynamicMesh; }\n        \n        /// @return The skinned animation that should be used to animate this object. Can be null if the\n        ///     object is not animated.\n        ///\n        const RenderSkinnedAnimation* GetRenderSkinnedAnimation() const noexcept { return m_renderSkinnedAnimation; }\n        \n        /// @return The world matrix describing the transform of the object.\n        ///\n        const Matrix4& GetWorldMatrix() const noexcept { return m_worldMatrix; }\n        \n        /// @return The world space bounding sphere of the object.\n        ///\n        const Sphere& GetBoundingSphere() const noexcept { return m_boundingSphere; }\n        \n        /// @return Whether or not the render object will try to cast shadows. Whether or not a shadow is\n        ///     actually cast is determined by the objects materials, and the lights in the scene.\n        ///\n        bool ShouldCastShadows() const noexcept { return m_shouldCastShadows; }\n        \n        /// @return The layer the object should be rendered into.\n        ///\n        RenderLayer GetRenderLayer() const noexcept { return m_renderLayer; }\n        \n        /// @return The order priority of the render object; lower values will be rendered first. This may or\n        ///     may not be used depending on the sort algorithm used, as is the order of objects with the\n        ///     same priority.\n        ///\n        u32 GetPriority() const noexcept { return m_priority; }\n        \n    private:\n        Type m_type;\n        const RenderMaterialGroup* m_renderMaterialGroup;\n        const RenderMesh* m_renderMesh = nullptr;\n        const RenderDynamicMesh* m_renderDynamicMesh = nullptr;\n        const RenderSkinnedAnimation* m_renderSkinnedAnimation = nullptr;\n        Matrix4 m_worldMatrix;\n        Sphere m_boundingSphere;\n        bool m_shouldCastShadows;\n        RenderLayer m_renderLayer;\n        u32 m_priority;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Base/RenderPass.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2010 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Base/RenderPass.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    RenderPass::RenderPass() noexcept\n        : m_lightType(LightType::k_none), m_ambientLight(AmbientRenderLight(Colour::k_black))\n    {\n    }\n    \n    //------------------------------------------------------------------------------\n    RenderPass::RenderPass(std::vector<RenderPassObject> renderPassObjects) noexcept\n        : m_renderPassObjects(std::move(renderPassObjects)), m_lightType(LightType::k_none), m_ambientLight(AmbientRenderLight(Colour::k_black))\n    {\n    }\n    \n    //------------------------------------------------------------------------------\n    RenderPass::RenderPass(const AmbientRenderLight& light, std::vector<RenderPassObject> renderPassObjects) noexcept\n    : m_renderPassObjects(std::move(renderPassObjects)), m_lightType(LightType::k_ambient), m_ambientLight(light)\n    {\n    }\n    \n    //------------------------------------------------------------------------------\n    RenderPass::RenderPass(const PointRenderLight& light, std::vector<RenderPassObject> renderPassObjects) noexcept\n        : m_renderPassObjects(std::move(renderPassObjects)), m_lightType(LightType::k_point), m_pointLight(light)\n    {\n    }\n    \n    //------------------------------------------------------------------------------\n    RenderPass::RenderPass(const DirectionalRenderLight& light, std::vector<RenderPassObject> renderPassObjects) noexcept\n        : m_renderPassObjects(std::move(renderPassObjects)), m_lightType(LightType::k_directional), m_directionalLight(light)\n    {\n    }\n    \n    //------------------------------------------------------------------------------\n    const AmbientRenderLight& RenderPass::GetAmbientLight() const noexcept\n    {\n        CS_ASSERT(m_lightType == LightType::k_ambient, \"Ambient light not set for pass\");\n        \n        return m_ambientLight;\n    }\n    \n    //------------------------------------------------------------------------------\n    const PointRenderLight& RenderPass::GetPointLight() const noexcept\n    {\n        CS_ASSERT(m_lightType == LightType::k_point, \"Point light not set for pass\");\n        \n        return m_pointLight;\n    }\n    \n    //------------------------------------------------------------------------------\n    const DirectionalRenderLight& RenderPass::GetDirectionalLight() const noexcept\n    {\n        CS_ASSERT(m_lightType == LightType::k_directional, \"Ambient light not set for pass\");\n        \n        return m_directionalLight;\n    }\n}"
  },
  {
    "path": "Source/ChilliSource/Rendering/Base/RenderPass.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_BASE_RENDERPASS_H_\n#define _CHILLISOURCE_RENDERING_BASE_RENDERPASS_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Base/Colour.h>\n#include <ChilliSource/Rendering/Base/RenderPassObject.h>\n#include <ChilliSource/Rendering/ForwardDeclarations.h>\n#include <ChilliSource/Rendering/Lighting/AmbientRenderLight.h>\n#include <ChilliSource/Rendering/Lighting/DirectionalRenderLight.h>\n#include <ChilliSource/Rendering/Lighting/PointRenderLight.h>\n\n#include <vector>\n\nnamespace ChilliSource\n{\n    /// Provides the ability to store a number of render pass objecs to render\n    /// with a single light source.\n    ///\n    /// This is immutable and therefore thread-safe\n    ///\n    class RenderPass final\n    {\n    public:\n        CS_DECLARE_NOCOPY(RenderPass);\n        \n        /// Enum describing the light types a pass can hold\n        ///\n        enum class LightType\n        {\n            k_none,\n            k_ambient,\n            k_directional,\n            k_point\n        };\n        \n        RenderPass() noexcept;\n        RenderPass(RenderPass&&) = default;\n        RenderPass& operator=(RenderPass&&) = default;\n        \n        /// @param renderPassObjects\n        ///     The list of render pass objects for this pass. Should be moved.\n        ///\n        RenderPass(std::vector<RenderPassObject> renderPassObjects) noexcept;\n        \n        /// @param light\n        ///     The ambient light to use for this pass\n        /// @param renderPassObjects\n        ///     The list of render pass objects for this pass. Should be moved.\n        ///\n        RenderPass(const AmbientRenderLight& light, std::vector<RenderPassObject> renderPassObjects) noexcept;\n        \n        /// @param light\n        ///     The point light to use for this pass\n        /// @param renderPassObjects\n        ///     The list of render pass objects for this pass. Should be moved.\n        ///\n        RenderPass(const PointRenderLight& light, std::vector<RenderPassObject> renderPassObjects) noexcept;\n        \n        /// @param light\n        ///     The directional light to use for this pass\n        /// @param renderPassObjects\n        ///     The list of render pass objects for this pass. Should be moved.\n        ///\n        RenderPass(const DirectionalRenderLight& light, std::vector<RenderPassObject> renderPassObjects) noexcept;\n        \n        /// @return The light type set for this pass\n        ///\n        LightType GetLightType() const noexcept { return m_lightType; }\n        \n        /// Return the ambient light for this pass, if set. GetLightType() should be used\n        /// to determine if this is set, if not this function will assert\n        ///\n        /// @return The ambient light to use for this pass\n        ///\n        const AmbientRenderLight& GetAmbientLight() const noexcept;\n        \n        /// Return the point light for this pass, if set. GetLightType() should be used\n        /// to determine if this is set, if not this function will assert\n        ///\n        /// @return The ambient light to use for this pass\n        ///\n        const PointRenderLight& GetPointLight() const noexcept;\n        \n        /// Return the directional light for this pass, if set. GetLightType() should be used\n        /// to determine if this is set, if not this function will assert\n        ///\n        /// @return The ambient light to use for this pass\n        ///\n        const DirectionalRenderLight& GetDirectionalLight() const noexcept;\n        \n        /// @return The list of render pass objects for this pass\n        ///\n        const std::vector<RenderPassObject>& GetRenderPassObjects() const noexcept { return m_renderPassObjects; }\n        \n    private:\n        std::vector<RenderPassObject> m_renderPassObjects;\n        LightType m_lightType;\n        \n        union\n        {\n            AmbientRenderLight m_ambientLight;\n            PointRenderLight m_pointLight;\n            DirectionalRenderLight m_directionalLight;\n        };\n    };\n}\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Base/RenderPassObject.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2010 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Base/RenderPassObject.h>\n\n#include <ChilliSource/Rendering/Material/RenderMaterial.h>\n#include <ChilliSource/Rendering/Model/RenderMesh.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    RenderPassObject::RenderPassObject(const RenderMaterial* renderMaterial, const RenderMesh* renderMesh, const Matrix4& worldMatrix, const Sphere& boundingSphere, u32 priority) noexcept\n        : m_type(Type::k_static), m_renderMaterial(renderMaterial), m_renderMesh(renderMesh), m_worldMatrix(worldMatrix), m_boundingSphere(boundingSphere), m_priority(priority)\n    {\n        CS_ASSERT(m_renderMaterial, \"RenderMaterial cannot be null.\");\n        CS_ASSERT(m_renderMesh, \"RenderMesh cannot be null.\");\n    }\n    \n    //------------------------------------------------------------------------------\n    RenderPassObject::RenderPassObject(const RenderMaterial* renderMaterial, const RenderMesh* renderMesh, const RenderSkinnedAnimation* renderSkinnedAnimation, const Matrix4& worldMatrix,\n                                       const Sphere& boundingSphere, u32 priority) noexcept\n        : m_type(Type::k_staticAnimated), m_renderMaterial(renderMaterial), m_renderMesh(renderMesh), m_renderSkinnedAnimation(renderSkinnedAnimation), m_worldMatrix(worldMatrix),\n        m_boundingSphere(boundingSphere), m_priority(priority)\n    {\n        CS_ASSERT(m_renderMaterial, \"RenderMaterial cannot be null.\");\n        CS_ASSERT(m_renderMesh, \"RenderMesh cannot be null.\");\n        CS_ASSERT(m_renderSkinnedAnimation, \"RenderSkinnedAnimation cannot be null.\");\n    }\n    \n    //------------------------------------------------------------------------------\n    RenderPassObject::RenderPassObject(const RenderMaterial* renderMaterial, const RenderDynamicMesh* renderDynamicMesh, const Matrix4& worldMatrix, const Sphere& boundingSphere, u32 priority) noexcept\n        : m_type(Type::k_dynamic), m_renderMaterial(renderMaterial), m_renderDynamicMesh(renderDynamicMesh), m_worldMatrix(worldMatrix), m_boundingSphere(boundingSphere), m_priority(priority)\n    {\n        CS_ASSERT(m_renderMaterial, \"RenderMaterial cannot be null.\");\n        CS_ASSERT(m_renderDynamicMesh, \"RenderDynamicMesh cannot be null.\");\n    }\n    \n    //------------------------------------------------------------------------------\n    RenderPassObject::RenderPassObject(const RenderMaterial* renderMaterial, const RenderDynamicMesh* renderDynamicMesh, const RenderSkinnedAnimation* renderSkinnedAnimation,\n                                       const Matrix4& worldMatrix, const Sphere& boundingSphere, u32 priority) noexcept\n        : m_type(Type::k_dynamicAnimated), m_renderMaterial(renderMaterial), m_renderDynamicMesh(renderDynamicMesh), m_renderSkinnedAnimation(renderSkinnedAnimation), m_worldMatrix(worldMatrix),\n          m_boundingSphere(boundingSphere), m_priority(priority)\n    {\n        CS_ASSERT(m_renderMaterial, \"RenderMaterial cannot be null.\");\n        CS_ASSERT(m_renderDynamicMesh, \"RenderDynamicMesh cannot be null.\");\n        CS_ASSERT(m_renderSkinnedAnimation, \"RenderSkinnedAnimation cannot be null.\");\n    }\n}"
  },
  {
    "path": "Source/ChilliSource/Rendering/Base/RenderPassObject.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_BASE_RENDERPASSOBJECT_H_\n#define _CHILLISOURCE_RENDERING_BASE_RENDERPASSOBJECT_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Math/Geometry/Shapes.h>\n#include <ChilliSource/Core/Math/Matrix4.h>\n#include <ChilliSource/Rendering/ForwardDeclarations.h>\n\nnamespace ChilliSource\n{\n    /// A standard-layout container for data which the renderer requires that relates to a single render\n    /// pass for a single object in the scene, such as mesh data, material and transform data.\n    /// While a RenderObject contains a material group that has materials for all render passes, this\n    /// only contains a single material for the pass this object is be created for.\n    ///\n    /// This is immutable and therefore thread-safe\n    ///\n    class RenderPassObject final\n    {\n    public:\n        /// An enum describing the type of mesh this object represents.\n        ///\n        enum class Type\n        {\n            k_static,\n            k_staticAnimated,\n            k_dynamic,\n            k_dynamicAnimated\n        };\n        \n        /// Creates a new static mesh render pass object.\n        ///\n        /// @param renderMaterial\n        ///     The render material that should be used when rendering this object.\n        /// @param renderMesh\n        ///     The static mesh that should be used when rendering this object.\n        /// @param worldMatrix\n        ///     The world matrix describing the transform of the object.\n        /// @param boundingSphere\n        ///     The world space bounding sphere of the object. This should be build using the local mesh\n        ///     bounding sphere.\n        /// @param priority\n        ///     The order priority of the render object; lower values will be rendered first. This may or\n        ///     may not be used depending on the sort algorithm used, as is the order of objects with the\n        ///     same priority.\n        ///\n        RenderPassObject(const RenderMaterial* renderMaterial, const RenderMesh* renderMesh, const Matrix4& worldMatrix, const Sphere& boundingSphere, u32 priority) noexcept;\n        \n        /// Creates a new static mesh render pass object with skinned animation\n        ///\n        /// @param renderMaterial\n        ///     The render material that should be used when rendering this object.\n        /// @param renderMesh\n        ///     The static mesh that should be used when rendering this object.\n        /// @param renderSkinnedAnimation\n        ///     The skinned animation data.\n        /// @param worldMatrix\n        ///     The world matrix describing the transform of the object.\n        /// @param boundingSphere\n        ///     The world space bounding sphere of the object. This should be build using the local mesh\n        ///     bounding sphere.\n        /// @param priority\n        ///     The order priority of the render object; lower values will be rendered first. This may or\n        ///     may not be used depending on the sort algorithm used, as is the order of objects with the\n        ///     same priority.\n        ///\n        RenderPassObject(const RenderMaterial* renderMaterial, const RenderMesh* renderMesh, const RenderSkinnedAnimation* renderSkinnedAnimation, const Matrix4& worldMatrix,\n                         const Sphere& boundingSphere, u32 priority) noexcept;\n        \n        /// Creates a new dynamic mesh render pass object.\n        ///\n        /// @param renderMaterial\n        ///     The render material that should be used when rendering this object.\n        /// @param renderDynamicMesh\n        ///     The dynamic mesh that should be used when rendering this object.\n        /// @param worldMatrix\n        ///     The world matrix describing the transform of the object.\n        /// @param boundingSphere\n        ///     The world space bounding sphere of the object. This should be build using the local mesh\n        ///     bounding sphere.\n        /// @param priority\n        ///     The order priority of the render object; lower values will be rendered first. This may or\n        ///     may not be used depending on the sort algorithm used, as is the order of objects with the\n        ///     same priority.\n        ///\n        RenderPassObject(const RenderMaterial* renderMaterial, const RenderDynamicMesh* renderDynamicMesh, const Matrix4& worldMatrix, const Sphere& boundingSphere, u32 priority) noexcept;\n        \n        /// Creates a new dynamic mesh render pass object.\n        ///\n        /// @param renderMaterial\n        ///     The render material that should be used when rendering this object.\n        /// @param renderDynamicMesh\n        ///     The dynamic mesh that should be used when rendering this object.\n        /// @param renderSkinnedAnimation\n        ///     The skinned animation data.\n        /// @param worldMatrix\n        ///     The world matrix describing the transform of the object.\n        /// @param boundingSphere\n        ///     The world space bounding sphere of the object. This should be build using the local mesh\n        ///     bounding sphere.\n        /// @param priority\n        ///     The order priority of the render object; lower values will be rendered first. This may or\n        ///     may not be used depending on the sort algorithm used, as is the order of objects with the\n        ///     same priority.\n        ///\n        RenderPassObject(const RenderMaterial* renderMaterial, const RenderDynamicMesh* renderDynamicMesh, const RenderSkinnedAnimation* renderSkinnedAnimation, const Matrix4& worldMatrix,\n                         const Sphere& boundingSphere, u32 priority) noexcept;\n        \n        /// @return The type of object this describes.\n        ///\n        Type GetType() const noexcept { return m_type; }\n        \n        /// @return The render material that should be used when rendering this object.\n        ///\n        const RenderMaterial* GetRenderMaterial() const noexcept { return m_renderMaterial; }\n        \n        /// @return The static mesh that should be used when rendering this object if this is a\n        ///     static mesh object, otherwise this will return nullptr.\n        ///\n        const RenderMesh* GetRenderMesh() const noexcept { return m_renderMesh; }\n        \n        /// @return The dynamic mesh that should be used when rendering this object if this is\n        ///     a dynamic mesh object, otherwise this will return nullptr.\n        ///\n        const RenderDynamicMesh* GetRenderDynamicMesh() const noexcept { return m_renderDynamicMesh; }\n        \n        /// @return The skinned animation data for this object. Will be null if the object is not\n        ///     animated.\n        ///\n        const RenderSkinnedAnimation* GetRenderSkinnedAnimation() const noexcept { return m_renderSkinnedAnimation; }\n        \n        /// @return The world matrix describing the transform of the object.\n        ///\n        const Matrix4& GetWorldMatrix() const noexcept { return m_worldMatrix; }\n        \n        /// @return The world space bounding sphere of the object.\n        ///\n        const Sphere& GetBoundingSphere() const noexcept { return m_boundingSphere; }\n        \n        /// @return The order priority of the render object; lower values will be rendered first.\n        ///     This may or may not be used depending on the sort algorithm used, as is the order\n        ///     of objects with the same priority.\n        ///\n        u32 GetPriority() const noexcept { return m_priority; }\n        \n    private:\n        Type m_type;\n        const RenderMaterial* m_renderMaterial;\n        const RenderMesh* m_renderMesh = nullptr;\n        const RenderDynamicMesh* m_renderDynamicMesh = nullptr;\n        const RenderSkinnedAnimation* m_renderSkinnedAnimation = nullptr;\n        Matrix4 m_worldMatrix;\n        Sphere m_boundingSphere;\n        u32 m_priority;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Base/RenderPassObjectSorter.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Base/RenderPassObjectSorter.h>\n\n#include <ChilliSource/Rendering/Camera/RenderCamera.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    void RenderPassObjectSorter::OpaqueSort(const RenderCamera& camera, std::vector<RenderPassObject>& renderPassObjects) noexcept\n    {\n        //The tile base deferred renderer on all iOS hardware does not benefit from front to back sorting https://developer.apple.com/library/content/documentation/3DDrawing/Conceptual/OpenGLES_ProgrammingGuide/Performance/Performance.html\n#ifndef CS_TARGETPLATFORM_IOS\n        std::sort(renderPassObjects.begin(), renderPassObjects.end(), [&camera](const RenderPassObject& a, const RenderPassObject& b)\n        {\n            if (a.GetRenderMaterial() == b.GetRenderMaterial())\n            {\n                Matrix4 wvpA = a.GetWorldMatrix() * camera.GetViewProjectionMatrix();\n                Matrix4 wvpB = b.GetWorldMatrix() * camera.GetViewProjectionMatrix();\n                \n                if (wvpA.GetTranslation().z == wvpB.GetTranslation().z)\n                {\n                    return (a.GetRenderMesh() < b.GetRenderMesh());\n                }\n                else\n                {\n                    return (wvpA.GetTranslation().z > wvpB.GetTranslation().z);\n                }\n            }\n            else\n            {\n                return (a.GetRenderMaterial() < b.GetRenderMaterial());\n            }\n        });\n#endif\n    }\n    \n    //------------------------------------------------------------------------------\n    void RenderPassObjectSorter::TransparentSort(const RenderCamera& camera, std::vector<RenderPassObject>& renderPassObjects) noexcept\n    {\n        std::sort(renderPassObjects.begin(), renderPassObjects.end(), [&camera](const RenderPassObject& a, const RenderPassObject& b)\n        {\n            Matrix4 wvpA = a.GetWorldMatrix() * camera.GetViewProjectionMatrix();\n            Matrix4 wvpB = b.GetWorldMatrix() * camera.GetViewProjectionMatrix();\n            \n            if (wvpA.GetTranslation().z == wvpB.GetTranslation().z)\n            {\n                return (a.GetRenderMesh() < b.GetRenderMesh());\n            }\n            else\n            {\n                return (wvpA.GetTranslation().z > wvpB.GetTranslation().z);\n            }\n        });\n    }\n    \n    //------------------------------------------------------------------------------\n    void RenderPassObjectSorter::PrioritySort(std::vector<RenderPassObject>& renderPassObjects) noexcept\n    {\n        std::sort(renderPassObjects.begin(), renderPassObjects.end(), [](const RenderPassObject& a, const RenderPassObject& b)\n        {\n            if (a.GetPriority() == b.GetPriority())\n            {\n                return (a.GetRenderMaterial() < b.GetRenderMaterial());\n            }\n            else\n            {\n                return (a.GetPriority() < b.GetPriority());\n            }\n        });\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Base/RenderPassObjectSorter.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_BASE_RENDERSORT_H_\n#define _CHILLISOURCE_RENDERING_BASE_RENDERSORT_H_\n\n#include <ChilliSource/ChilliSource.h>\n\n#include <ChilliSource/Rendering/Base/RenderPassObject.h>\n#include <ChilliSource/Rendering/ForwardDeclarations.h>\n\n#include <functional>\n#include <vector>\n\nnamespace ChilliSource\n{\n    /// Collection of sort functions for render pass objects\n    ///\n    namespace RenderPassObjectSorter\n    {\n        /// Sorts a collection of opaque RenderPassObjects based on if they share a material\n        /// and then by z position (Front to back)\n        ///\n        /// @param camera\n        ///     The camera to use to determine z-distance.\n        /// @param renderPassObjects\n        ///     The list of render pass objects to sort.\n        ///\n        void OpaqueSort(const RenderCamera& camera, std::vector<RenderPassObject>& renderPassObjects) noexcept;\n        \n        /// Sorts a collection of transparent RenderPassObjects based on their z position (Back to front)\n        ///\n        /// @param camera\n        ///     The camera to use to determine z-distance\n        /// @param renderPassObjects\n        ///     The list of render pass objects to sort.\n        ///\n        void TransparentSort(const RenderCamera& camera, std::vector<RenderPassObject>& renderPassObjects) noexcept;\n        \n        /// Sorts a collection of RenderPassObjects based on their priority value. Lower priority values\n        /// will be rendered first. If objects have the same priority then they will be ordered by material.\n        ///\n        /// @param renderPassObjects\n        ///     The list of render pass objects to sort.\n        ///\n        void PrioritySort(std::vector<RenderPassObject>& renderPassObjects) noexcept;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Base/RenderPassVisibilityChecker.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Base/RenderPassVisibilityChecker.h>\n\n#include <ChilliSource/Core/Threading/TaskScheduler.h>\n#include <ChilliSource/Rendering/Base/RenderPasses.h>\n#include <ChilliSource/Rendering/Base/RenderFrame.h>\n#include <ChilliSource/Rendering/Base/RenderPass.h>\n#include <ChilliSource/Rendering/Base/RenderObject.h>\n#include <ChilliSource/Rendering/Base/RenderPassObject.h>\n\nnamespace ChilliSource\n{\n    namespace\n    {\n        constexpr u32 k_objectsPerVisibilityBatch = 50;\n    }\n    \n    //------------------------------------------------------------------------------\n    std::vector<RenderObject> RenderPassVisibilityChecker::CalculateVisibleObjects(const TaskContext& taskContext, const RenderCamera& camera, const std::vector<RenderObject>& renderObjects) noexcept\n    {\n        std::mutex visibleObjectsMutex;\n        std::vector<RenderObject> visibleRenderObjects;\n        \n        u32 numTasks = 1 + (u32(renderObjects.size()) / k_objectsPerVisibilityBatch);\n        std::vector<Task> tasks;\n        for (u32 taskIndex = 0; taskIndex < numTasks; ++taskIndex)\n        {\n            tasks.push_back([=, &camera, &renderObjects, &visibleObjectsMutex, &visibleRenderObjects](const TaskContext& innerTaskContext)\n            {\n                std::vector<RenderObject> taskVisibleObjects;\n                for(u32 objectIndex = 0; objectIndex < k_objectsPerVisibilityBatch; ++objectIndex)\n                {\n                    u32 index = taskIndex * k_objectsPerVisibilityBatch + objectIndex;\n                    if (index >= renderObjects.size())\n                    {\n                        break;\n                    }\n                    \n                    const auto& renderPassObject = renderObjects[index];\n                    \n                    if (camera.GetFrustrum().SphereCullTest(renderPassObject.GetBoundingSphere()))\n                    {\n                        taskVisibleObjects.push_back(renderPassObject);\n                    }\n                }\n                \n                std::unique_lock<std::mutex> lock(visibleObjectsMutex);\n                visibleRenderObjects.insert(visibleRenderObjects.end(), taskVisibleObjects.begin(), taskVisibleObjects.end());\n            });\n        }\n        \n        taskContext.ProcessChildTasks(tasks);\n        \n        return visibleRenderObjects;\n    }\n} \n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Base/RenderPassVisibilityChecker.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_BASE_RENDERPASSUTILS_H_\n#define _CHILLISOURCE_RENDERING_BASE_RENDERPASSUTILS_H_\n\n#include <ChilliSource/ChilliSource.h>\n\n#include <ChilliSource/Rendering/Base/RenderPass.h>\n#include <ChilliSource/Rendering/Base/RenderPassObjectSorter.h>\n\n#include <vector>\n\nnamespace ChilliSource\n{\n    /// Collection of functions for render pass objects\n    ///\n    namespace RenderPassVisibilityChecker\n    {\n        /// Parses a collection of RenderObjects and generates a list of them that are considered\n        /// to be visible and within the passed camera's view frustrum.\n        ///\n        /// @param taskContext\n        ///     Context to manage any spawned tasks\n        /// @param camera\n        ///     The camera who will decide the objects visibility\n        /// @param renderObjects\n        ///     The collection of RenderObjects whos visibility is to be checked\n        ///\n        /// @return Collection of visible RenderObjects\n        ///\n        std::vector<RenderObject> CalculateVisibleObjects(const TaskContext& taskContext, const RenderCamera& camera, const std::vector<RenderObject>& renderObjects) noexcept;\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Base/RenderPasses.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_BASE_RENDERPASSES_H_\n#define _CHILLISOURCE_RENDERING_BASE_RENDERPASSES_H_\n\n#include <ChilliSource/ChilliSource.h>\n\nnamespace ChilliSource\n{\n    /// An enum describing each of the passes in the multi-pass renderer. This consists of\n    ///\n    /// * The shadow map pass. This renders all shadow casting opaque objects in the scene to\n    ///   acquire the shadow map used by each shadow casting light.\n    /// * The base pass. This renders all opaque objects to the scene with only ambient lighting.\n    /// * The directional light pass. For each directional light in the scene which doesn't cast\n    ///   shadows, a pass over all lit, opaque objects in the scene is performed. This renders the\n    ///   applied lighting additively to the base pass and does not write to the depth buffer.\n    /// * The directional light shadows pass. For each directional light in the scene which does\n    ///   cast shadows, a pass over all lit, opaque objects in the scene is performed. This renders\n    ///   the applied lighting additively to the base pass and does not write to the depth buffer.\n    /// * The point light pass. For each point light in the scene, a pass over all lit opaque objects\n    ///   within the range of influence of the light is performed. This renders the applied lighting\n    ///   additively to the previous passes and does not write to the depth buffer.\n    /// * The transparent pass. This render all transparent objects in the scene with only ambient\n    ///   lighting. The depth buffer is not written to; the objects are first sorted to ensure no\n    ///   artefacts occur.\n    /// * The skybox pass. This renders any skyboxes after the rest of the scene has been rendered and relies\n    ///   on the material settings to ensure that the skybox appears beind the rest of the scene. The skybox\n    ///   is rendered using the camera orientation but does not take into account position.\n    ///\n    enum class RenderPasses\n    {\n        k_shadowMap,\n        k_base,\n        k_directionalLight,\n        k_directionalLightShadows,\n        k_pointLight,\n        k_transparent,\n        k_skybox\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Base/RenderSnapshot.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Base/RenderSnapshot.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    RenderSnapshot::RenderSnapshot(const RenderTargetGroup* renderTarget, const Integer2& resolution, const Colour& clearColour, const RenderCamera& in_renderCamera) noexcept\n        : m_offscreenRenderTarget(renderTarget), m_resolution(resolution), m_clearColour(clearColour), m_renderCamera(in_renderCamera), m_preRenderCommandList(new RenderCommandList()), m_postRenderCommandList(new RenderCommandList()),\n          m_renderFrameData()\n    {\n    }\n    \n    //------------------------------------------------------------------------------\n    void RenderSnapshot::AddAmbientRenderLight(const AmbientRenderLight& renderAmbientLight) noexcept\n    {\n        CS_ASSERT(!m_renderAmbientLightsClaimed, \"Render ambient light list cannot be changed after it has been claimed.\");\n        \n        m_renderAmbientLights.push_back(renderAmbientLight);\n    }\n    \n    //------------------------------------------------------------------------------\n    void RenderSnapshot::AddDirectionalRenderLight(const DirectionalRenderLight& renderDirectionalLight) noexcept\n    {\n        CS_ASSERT(!m_renderDirectionalLightsClaimed, \"Render directional light list cannot be changed after it has been claimed.\");\n        \n        m_renderDirectionalLights.push_back(renderDirectionalLight);\n    }\n    \n    //------------------------------------------------------------------------------\n    void RenderSnapshot::AddPointRenderLight(const PointRenderLight& renderPointLight) noexcept\n    {\n        CS_ASSERT(!m_renderPointLightsClaimed, \"Render point light list cannot be changed after it has been claimed.\");\n        \n        m_renderPointLights.push_back(renderPointLight);\n    }\n    \n    //------------------------------------------------------------------------------\n    void RenderSnapshot::AddRenderObject(const RenderObject& renderObject) noexcept\n    {\n        CS_ASSERT(!m_renderObjectsClaimed, \"Render object list cannot be changed after it has been claimed.\");\n        \n        m_renderObjects.push_back(renderObject);\n    }\n    \n    //------------------------------------------------------------------------------\n    void RenderSnapshot::AddRenderDynamicMesh(RenderDynamicMeshAUPtr renderDynamicMesh) noexcept\n    {\n        CS_ASSERT(!m_renderFrameDataClaimed, \"Cannot add RenderDynamicMesh after RenderFrameData has been claimed.\");\n        \n        m_renderFrameData.AddRenderDynamicMesh(std::move(renderDynamicMesh));\n    }\n    \n    //------------------------------------------------------------------------------\n    void RenderSnapshot::AddRenderSkinnedAnimation(RenderSkinnedAnimationAUPtr renderSkinnedAnimation) noexcept\n    {\n        CS_ASSERT(!m_renderFrameDataClaimed, \"Cannot add RenderDynamicMesh after RenderFrameData has been claimed.\");\n        \n        m_renderFrameData.AddRenderSkinnedAnimation(std::move(renderSkinnedAnimation));\n    }\n    \n    //------------------------------------------------------------------------------\n    RenderCommandList* RenderSnapshot::GetPreRenderCommandList() noexcept\n    {\n        CS_ASSERT(m_preRenderCommandList, \"Pre-RenderCommandList cannot be modified after it has been claimed.\");\n        \n        return m_preRenderCommandList.get();\n    }\n    \n    //------------------------------------------------------------------------------\n    RenderCommandList* RenderSnapshot::GetPostRenderCommandList() noexcept\n    {\n        CS_ASSERT(m_postRenderCommandList, \"Post-RenderCommandList cannot be modified after it has been claimed.\");\n        \n        return m_postRenderCommandList.get();\n    }\n    \n    //------------------------------------------------------------------------------\n    std::vector<AmbientRenderLight> RenderSnapshot::ClaimAmbientRenderLights() noexcept\n    {\n        CS_ASSERT(!m_renderAmbientLightsClaimed, \"Render ambient lights have already been claimed.\");\n        \n        m_renderAmbientLightsClaimed = true;\n        return std::move(m_renderAmbientLights);\n    }\n    \n    //------------------------------------------------------------------------------\n    std::vector<DirectionalRenderLight> RenderSnapshot::ClaimDirectionalRenderLights() noexcept\n    {\n        CS_ASSERT(!m_renderDirectionalLightsClaimed, \"Render directional lights have already been claimed.\");\n        \n        m_renderDirectionalLightsClaimed = true;\n        return std::move(m_renderDirectionalLights);\n    }\n    \n    //------------------------------------------------------------------------------\n    std::vector<PointRenderLight> RenderSnapshot::ClaimPointRenderLights() noexcept\n    {\n        CS_ASSERT(!m_renderPointLightsClaimed, \"Render point lights have already been claimed.\");\n        \n        m_renderPointLightsClaimed = true;\n        return std::move(m_renderPointLights);\n    }\n    \n    //------------------------------------------------------------------------------\n    std::vector<RenderObject> RenderSnapshot::ClaimRenderObjects() noexcept\n    {\n        CS_ASSERT(!m_renderObjectsClaimed, \"Render objects have already been claimed.\");\n        \n        m_renderObjectsClaimed = true;\n        return std::move(m_renderObjects);\n    }\n    \n    //------------------------------------------------------------------------------\n    RenderCommandListUPtr RenderSnapshot::ClaimPreRenderCommandList() noexcept\n    {\n        CS_ASSERT(m_preRenderCommandList, \"Pre-RenderCommandList has already been claimed.\");\n        \n        return std::move(m_preRenderCommandList);\n    }\n    \n    //------------------------------------------------------------------------------\n    RenderCommandListUPtr RenderSnapshot::ClaimPostRenderCommandList() noexcept\n    {\n        CS_ASSERT(m_postRenderCommandList, \"Post-RenderCommandList has already been claimed.\");\n        \n        return std::move(m_postRenderCommandList);\n    }\n    \n    //------------------------------------------------------------------------------\n    RenderFrameData RenderSnapshot::ClaimRenderFrameData() noexcept\n    {\n        CS_ASSERT(!m_renderFrameDataClaimed, \"RenderFrameData already claimed.\");\n        \n        m_renderFrameDataClaimed = true;\n        \n        return std::move(m_renderFrameData);\n    }\n};\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Base/RenderSnapshot.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_BASE_RENDERSNAPSHOT_H_\n#define _CHILLISOURCE_RENDERING_BASE_RENDERSNAPSHOT_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Base/Colour.h>\n#include <ChilliSource/Core/Math/Vector2.h>\n#include <ChilliSource/Core/Memory/PagedLinearAllocator.h>\n#include <ChilliSource/Rendering/Base/RenderFrameData.h>\n#include <ChilliSource/Rendering/Base/RenderObject.h>\n#include <ChilliSource/Rendering/Camera/RenderCamera.h>\n#include <ChilliSource/Rendering/Lighting/AmbientRenderLight.h>\n#include <ChilliSource/Rendering/Lighting/DirectionalRenderLight.h>\n#include <ChilliSource/Rendering/Lighting/PointRenderLight.h>\n#include <ChilliSource/Rendering/RenderCommand/RenderCommandList.h>\n\n#include <vector>\n\nnamespace ChilliSource\n{\n    /// A snapshot of the state of the scene, containing only information which the renderer\n    /// requires. The render snapshot is passed to all active systems and all components in\n    /// the scene allowing them to snapshot their state.\n    ///\n    /// Note that snapshotted data is moved rather than copied from the snapshot for the sake\n    /// of performance, meaning that each peice of data can only be claimed once.\n    ///\n    /// This is not thread-safe and must only be accessed by one thread at a time.\n    ///\n    class RenderSnapshot final\n    {\n    public:\n        CS_DECLARE_NOCOPY(RenderSnapshot);\n        \n        RenderSnapshot(RenderSnapshot&&) = default;\n        RenderSnapshot& operator=(RenderSnapshot&&) = default;\n        \n        /// Creates a new instance with the given viewport resolution and clear colour.\n        ///\n        /// @param renderTarget\n        ///     The render target to render into, if null renders to screen (frame buffer)\n        /// @param resolution\n        ///     The viewport resolution.\n        /// @param clearColour\n        ///     The clear colour\n        /// @param renderCamera\n        ///     The main camera that will be used to render the scene. Currently only one camera per\n        ///     scene is supported.\n        ///\n        RenderSnapshot(const RenderTargetGroup* renderTarget, const Integer2& resolution, const Colour& clearColour, const RenderCamera& renderCamera) noexcept;\n        \n        /// @return The viewport resolution.\n        ///\n        const Integer2& GetResolution() const noexcept { return m_resolution; }\n        \n        /// @return The clear colour that should be used during rendering.\n        ///\n        const Colour& GetClearColour() const noexcept { return m_clearColour; }\n        \n        /// @return  The main camera that will be used to render the scene.\n        ///\n        RenderCamera GetRenderCamera() noexcept { return m_renderCamera; }\n        \n        /// Adds an ambient light to the render snapshot.\n        ///\n        /// @param renderAmbientLight\n        ///     The ambient light which should be added.\n        ///\n        void AddAmbientRenderLight(const AmbientRenderLight& renderAmbientLight) noexcept;\n        \n        /// Adds a directional light to the render snapshot.\n        ///\n        /// @param renderDirectionalLight\n        ///     The directional light which should be added.\n        ///\n        void AddDirectionalRenderLight(const DirectionalRenderLight& renderDirectionalLight) noexcept;\n        \n        /// Adds a point light to the render snapshot.\n        ///\n        /// @param renderPointLight\n        ///     The point light which should be added.\n        ///\n        void AddPointRenderLight(const PointRenderLight& renderPointLight) noexcept;\n        \n        /// Adds an object to the render snapshot.\n        ///\n        /// @param renderObject\n        ///     The object which should be added.\n        ///\n        void AddRenderObject(const RenderObject& renderObject) noexcept;\n        \n        /// Adds a RenderDynamicMesh to the snapshot. This will be deleted at the end of the frame.\n        ///\n        /// @param The render dynamic mesh.\n        ///\n        void AddRenderDynamicMesh(RenderDynamicMeshAUPtr renderDynamicMesh) noexcept;\n        \n        /// Adds a RenderSkinnedAnimation to the snapshot. This will be deleted at the end of the frame.\n        ///\n        /// @param The render skinned animation.\n        ///\n        void AddRenderSkinnedAnimation(RenderSkinnedAnimationAUPtr renderSkinnedAnimation) noexcept;\n        \n        /// @return A modifiable version of the pre render command list. This can be used to populate\n        ///     The list with additional commands.\n        ///\n        RenderCommandList* GetPreRenderCommandList() noexcept;\n        \n        /// @return A modifiable version of the post render command list. This can be used to\n        ///     populate the list with additional commands.\n        ///\n        RenderCommandList* GetPostRenderCommandList() noexcept;\n        \n        /// Moves the list of ambient lights to a new external owner.\n        ///\n        /// @return The moved list of ambient lights.\n        ///\n        std::vector<AmbientRenderLight> ClaimAmbientRenderLights() noexcept;\n        \n        /// Moves the list of directional lights to a new external owner.\n        ///\n        /// @return The moved list of directional lights.\n        ///\n        std::vector<DirectionalRenderLight> ClaimDirectionalRenderLights() noexcept;\n        \n        /// Moves the list of point lights to a new external owner.\n        ///\n        /// @return The moved list of point lights.\n        ///\n        std::vector<PointRenderLight> ClaimPointRenderLights() noexcept;\n        \n        /// Moves the list of objects to a new external owner.\n        ///\n        /// @return The moved list of objects.\n        ///\n        std::vector<RenderObject> ClaimRenderObjects() noexcept;\n        \n        /// Moves the pre render command list to a new external owner.\n        ///\n        /// @return The moved pre render command list.\n        ///\n        RenderCommandListUPtr ClaimPreRenderCommandList() noexcept;\n    \n        /// Moves the post render command list to a new external owner.\n        ///\n        /// @return The moved post render command list.\n        ///\n        RenderCommandListUPtr ClaimPostRenderCommandList() noexcept;\n        \n        /// Moves the render frame data to a new external owner.\n        ///\n        /// @return The moved container for data which needs to persist to the end of the frame.\n        ///\n        RenderFrameData ClaimRenderFrameData() noexcept;\n        \n        ///@return Render target for this frame, if null defaults to the frame buffer\n        ///\n        const RenderTargetGroup* GetOffscreenRenderTarget() const noexcept { return m_offscreenRenderTarget; }\n        \n    private:\n        Integer2 m_resolution;\n        Colour m_clearColour;\n        RenderCamera m_renderCamera;\n        std::vector<AmbientRenderLight> m_renderAmbientLights;\n        std::vector<DirectionalRenderLight> m_renderDirectionalLights;\n        std::vector<PointRenderLight> m_renderPointLights;\n        std::vector<RenderObject> m_renderObjects;\n        RenderCommandListUPtr m_preRenderCommandList;\n        RenderCommandListUPtr m_postRenderCommandList;\n        RenderFrameData m_renderFrameData;\n        const RenderTargetGroup* m_offscreenRenderTarget;\n        \n        bool m_renderCameraClaimed = false;\n        bool m_renderAmbientLightsClaimed = false;\n        bool m_renderDirectionalLightsClaimed = false;\n        bool m_renderPointLightsClaimed = false;\n        bool m_renderObjectsClaimed = false;\n        bool m_renderFrameDataClaimed = false;\n    };\n};\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Base/Renderer.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Base/Renderer.h>\n\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/Threading/TaskScheduler.h>\n#include <ChilliSource/Rendering/Base/ForwardRenderPassCompiler.h>\n#include <ChilliSource/Rendering/Base/RenderCommandCompiler.h>\n#include <ChilliSource/Rendering/Base/RenderCommandBufferManager.h>\n#include <ChilliSource/Rendering/Base/RenderFrameCompiler.h>\n\nnamespace ChilliSource\n{\n    CS_DEFINE_NAMEDTYPE(Renderer);\n    \n    namespace\n    {\n        /// Converts the snapshot into a render frame\n        ///\n        /// @param snapshot\n        ///     Snapshot to convert. Some of the data will be moved\n        /// @return Render frame\n        ///\n        RenderFrame CompileRenderFrame(RenderSnapshot& snapshot)\n        {\n            auto resolution = snapshot.GetResolution();\n            auto clearColour = snapshot.GetClearColour();\n            auto renderCamera = snapshot.GetRenderCamera();\n            auto renderAmbientLights = snapshot.ClaimAmbientRenderLights();\n            auto renderDirectionalLights = snapshot.ClaimDirectionalRenderLights();\n            auto renderPointLights = snapshot.ClaimPointRenderLights();\n            auto renderObjects = snapshot.ClaimRenderObjects();\n            auto offscreenTarget = snapshot.GetOffscreenRenderTarget();\n            \n            return RenderFrameCompiler::CompileRenderFrame(offscreenTarget, resolution, clearColour, renderCamera, renderAmbientLights, renderDirectionalLights, renderPointLights, renderObjects);\n        }\n    }\n    \n    //------------------------------------------------------------------------------\n    RendererUPtr Renderer::Create() noexcept\n    {\n        return RendererUPtr(new Renderer());\n    }\n    \n    //------------------------------------------------------------------------------\n    Renderer::Renderer() noexcept\n        : m_currentMainSnapshot(nullptr, Integer2::k_zero, Colour::k_black, RenderCamera())\n\n    {\n\n    }\n    \n    //------------------------------------------------------------------------------\n    bool Renderer::IsA(InterfaceIDType interfaceId) const noexcept\n    {\n        return (Renderer::InterfaceID == interfaceId);\n    }\n    \n    //------------------------------------------------------------------------------\n    RenderSnapshot Renderer::CreateRenderSnapshot(const RenderTargetGroup* renderTarget, const Integer2& resolution, const Colour& clearColour, const RenderCamera& renderCamera) noexcept\n    {\n        return RenderSnapshot(renderTarget, resolution, clearColour, renderCamera);\n    }\n    \n    //------------------------------------------------------------------------------\n    void Renderer::ProcessRenderSnapshots(IAllocator* frameAllocator, RenderSnapshot mainRenderSnapshot, std::vector<RenderSnapshot> offscreenRenderSnapshots) noexcept\n    {\n        WaitThenStartRenderPrep();\n        \n        m_currentMainSnapshot = std::move(mainRenderSnapshot);\n        m_currentOffscreenSnapshots = std::move(offscreenRenderSnapshots);\n        \n        auto taskScheduler = Application::Get()->GetTaskScheduler();\n        \n        taskScheduler->ScheduleTask(TaskType::k_small, [=](const TaskContext& taskContext)\n        {\n            std::vector<RenderFrame> renderFrames(m_currentOffscreenSnapshots.size());\n            std::vector<RenderFrameData> renderFramesData(m_currentOffscreenSnapshots.size());\n            \n            for(auto i=0; i<m_currentOffscreenSnapshots.size(); ++i)\n            {\n                CS_ASSERT(m_currentOffscreenSnapshots[i].GetPreRenderCommandList()->GetOrderedList().size() == 0 && m_currentOffscreenSnapshots[i].GetPostRenderCommandList()->GetOrderedList().size() == 0, \"Offscreen render snapshots cannot have pre or post render commands\");\n                \n                auto renderFrameData = m_currentOffscreenSnapshots[i].ClaimRenderFrameData();\n                renderFramesData.push_back(std::move(renderFrameData));\n                \n                auto renderFrame = CompileRenderFrame(m_currentOffscreenSnapshots[i]);\n                renderFrames.push_back(std::move(renderFrame));\n            }\n            \n            auto preRenderCommandList = m_currentMainSnapshot.ClaimPreRenderCommandList();\n            auto postRenderCommandList = m_currentMainSnapshot.ClaimPostRenderCommandList();\n            \n            auto renderFrameData = m_currentMainSnapshot.ClaimRenderFrameData();\n            renderFramesData.push_back(std::move(renderFrameData));\n            \n            auto renderFrame = CompileRenderFrame(m_currentMainSnapshot);\n            renderFrames.push_back(std::move(renderFrame));\n            \n            auto targetRenderPassGroups = m_renderPassCompiler->CompileTargetRenderPassGroups(taskContext, std::move(renderFrames));\n            auto renderCommandBuffer = RenderCommandCompiler::CompileRenderCommands(taskContext, std::move(frameAllocator), targetRenderPassGroups, std::move(preRenderCommandList), std::move(postRenderCommandList), std::move(renderFramesData));\n            \n            m_commandRecycleSystem->WaitThenPushCommandBuffer(std::move(renderCommandBuffer));\n            \n            EndRenderPrep();\n        });\n    }\n    \n    //------------------------------------------------------------------------------\n    void Renderer::ProcessRenderCommandBuffer() noexcept\n    {\n        auto renderCommandBuffer = m_commandRecycleSystem->WaitThenPopCommandBuffer();\n        m_renderCommandProcessor->Process(renderCommandBuffer.get());\n        \n        auto allocator = renderCommandBuffer->GetFrameAllocator();\n        renderCommandBuffer.reset();\n        \n        m_frameAllocatorQueue.Push(allocator);\n    }\n    \n    //------------------------------------------------------------------------------\n    void Renderer::WaitThenStartRenderPrep() noexcept\n    {\n        std::unique_lock<std::mutex> lock(m_renderPrepMutex);\n        \n        while (m_renderPrepActive)\n        {\n            m_renderPrepCondition.wait(lock);\n        }\n        \n        m_renderPrepActive = true;\n    }\n    \n    //------------------------------------------------------------------------------\n    void Renderer::EndRenderPrep() noexcept\n    {\n        std::unique_lock<std::mutex> lock(m_renderPrepMutex);\n        m_currentOffscreenSnapshots.clear();\n        m_renderPrepActive = false;\n        m_renderPrepCondition.notify_all();\n    }\n    \n    //------------------------------------------------------------------------------\n    void Renderer::OnInit() noexcept\n    {\n        //TODO: Handle forward vs deferred rendering\n        m_renderPassCompiler = IRenderPassCompilerUPtr(new ForwardRenderPassCompiler());\n        m_renderCommandProcessor = IRenderCommandProcessor::Create();\n\n        m_commandRecycleSystem = Application::Get()->GetSystem<RenderCommandBufferManager>();\n    }\n    \n    //------------------------------------------------------------------------------\n    void Renderer::OnSystemResume() noexcept\n    {\n        if(m_initialised)\n        {\n#ifdef CS_TARGETPLATFORM_ANDROID\n            m_renderCommandProcessor->Restore();\n#endif\n        }\n        \n        m_initialised = true;\n    }\n\n    //------------------------------------------------------------------------------\n    void Renderer::OnDestroy() noexcept\n    {\n        m_commandRecycleSystem = nullptr;\n        m_renderCommandProcessor.reset();\n        m_renderPassCompiler.reset();\n    }\n    \n    //------------------------------------------------------------------------------\n    void Renderer::OnSystemSuspend() noexcept\n    {\n#ifdef CS_TARGETPLATFORM_ANDROID\n        m_renderCommandProcessor->Invalidate();\n#endif\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Base/Renderer.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_BASE_RENDERER_H_\n#define _CHILLISOURCE_RENDERING_BASE_RENDERER_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/System/AppSystem.h>\n#include <ChilliSource/Rendering/Base/IRenderCommandProcessor.h>\n#include <ChilliSource/Rendering/Base/IRenderPassCompiler.h>\n#include <ChilliSource/Rendering/Base/FrameAllocatorQueue.h>\n#include <ChilliSource/Rendering/Base/RenderSnapshot.h>\n#include <ChilliSource/Rendering/RenderCommand/RenderCommandBuffer.h>\n\n#include <condition_variable>\n#include <deque>\n#include <mutex>\n\nnamespace ChilliSource\n{\n    /// Provodes render API agnostic multi threaded render pipeline. This supports both forward\n    /// and deferred rendering.\n    ///\n    /// The render pipeline consists of five stages:\n    ///\n    /// * The Scene Snapshot stage queries every Entity in the scene as well as all active\n    ///   systems for a snapshot of their current render state. This occurs on the main\n    ///   thread.\n    ///\n    /// * The Frame Compilation stage takes the snapshotted data and processes it into a\n    ///   RenderFrame construct, which describes all the information required to render\n    ///   a single frame. This is processed in a series of background tasks.\n    ///\n    /// * The Pass Compilation stage breaks the RenderFrame down into a series of\n    ///   RenderPasses ensuring each pass only contains the relevant objects by filtering for\n    ///   material type and visibility. Objects within a render pass are also sorted into an\n    ///   appropriate order for the type of pass. This also takes into account whether the\n    ///   renderer is forward or deferred, compiling appropriate passes for each. This is\n    ///   processed in a series of background tasks.\n    ///\n    /// * The Render Command Queue Compilation stage takes the series of passes and breaks\n    ///   them down further into a buffer of render commands. This is processed as a series\n    ///   of background tasks.\n    ///\n    /// * The Render Command Processing stage takes the generated command buffer and processes\n    ///   each depending on render API (i.e OpenGL) that is being used. This is processed on\n    ///   the render thread.\n    ///\n    /// This is thread safe, though certain methods need to be called on certain threads.\n    ///\n    class Renderer final : public AppSystem\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(Renderer);\n        \n        /// Allows querying of whether or not this system implements the interface described by the\n        /// given interface Id. Typically this is not called directly as the templated equivalent\n        /// IsA<Interface>() is preferred.\n        ///\n        /// @param interfaceId\n        ///     The Id of the interface.\n        ///\n        /// @return Whether or not the interface is implemented.\n        ///\n        bool IsA(InterfaceIDType interfaceId) const noexcept override;\n        \n        /// Creates a new RenderSnapshot object which can be used to take a snapshot of the current\n        /// scene. This will be created with the next queued frame allocator; if one isn't available\n        /// this will block until one is.\n        ///\n        /// @param renderTarget\n        ///     The render target to render into, if null renders to screen (frame buffer)\n        /// @param resolution\n        ///     The viewport resolution.\n        /// @param clearColour\n        ///     The clear colour\n        /// @param renderCamera\n        ///     The main camera that will be used to render the scene. Currently only one camera per\n        ///     scene is supported.\n        ///\n        /// @return The new render snapshot object.\n        ///\n        RenderSnapshot CreateRenderSnapshot(const RenderTargetGroup* renderTarget, const Integer2& resolution, const Colour& clearColour, const RenderCamera& renderCamera) noexcept;\n        \n        /// Performs the Scene Snapshot through to the Render Command Queue Compilation Stages and\n        /// then stores the output render command buffer render to later be processed by the\n        /// ProcessRenderCommandBuffer() method.\n        ///\n        /// If the render pipeline is busy this will block until is it ready for the next snapshot\n        /// to be processed.\n        ///\n        /// This must be called from the main thread.\n        ///\n        /// @param frameAllocator\n        ///     Allocator used to allocate the render snapshots that should be released when the frame is rendererd\n        /// @param mainRenderSnapshot\n        ///     The render snapshot to process for the main scene. This should have already been populated by passing it\n        ///     to each system and component in the scene. This must be moved.\n        /// @param offscreenRenderSnapshots\n        ///     The render snapshots to process for offscreen targets. They should have already been populated by passing them\n        ///     to each system and component in the scene. They must be moved.\n        ///\n        void ProcessRenderSnapshots(IAllocator* frameAllocator, RenderSnapshot mainRenderSnapshot, std::vector<RenderSnapshot> offscreenRenderSnapshots) noexcept;\n        \n        /// Processes the next render command buffer. If there is no render command buffer ready to be\n        /// processed then this will block until there is.\n        ///\n        /// This must be called from the render thread.\n        ///\n        void ProcessRenderCommandBuffer() noexcept;\n        \n        /// @return The renderers frame allocator queue\n        ///\n        FrameAllocatorQueue& GetFrameAllocatorQueue() noexcept { return m_frameAllocatorQueue; }\n        \n    private:\n        friend class Application;\n        friend class LifecycleManager;\n        \n        /// A factory method for creating new instances of the system. This must be called by\n        /// Application.\n        ///\n        /// @return The new instance of the system.\n        ///\n        static RendererUPtr Create() noexcept;\n        \n        Renderer() noexcept;\n        \n        /// If the render preparation stages (Compile Render Frame, Compile Render Passes and Compile\n        /// Render Commands stages) are currently being processed this waits until they have finished\n        /// before continuing. It then again flags the render preparation stages as in-progress.\n        ///\n        void WaitThenStartRenderPrep() noexcept;\n        \n        /// Flags the render preparation stage as finished and notifies any threads that are currently\n        /// waiting.\n        ///\n        void EndRenderPrep() noexcept;\n        \n        /// Initialisation called when all App Systems have been created.\n        ///\n        void OnInit() noexcept override;\n        \n        /// Called when the application delegate is resumed. This is called directly\n        /// from lifecycle manager and will be called before the OnResume.\n        ///\n        void OnSystemResume() noexcept;\n        \n        /// Called when the application delegate is suspended. This is called directly\n        /// from lifecycle manager and will be called before the OnSuspend.\n        ///\n        void OnSystemSuspend() noexcept;\n\n        /// Destroy method called immediately before all systems are destroyed.\n        ///\n        void OnDestroy() noexcept override;\n        \n        FrameAllocatorQueue m_frameAllocatorQueue;\n        IRenderPassCompilerUPtr m_renderPassCompiler;\n        IRenderCommandProcessorUPtr m_renderCommandProcessor;\n        \n        std::mutex m_renderPrepMutex;\n        std::condition_variable m_renderPrepCondition;\n        bool m_renderPrepActive = false;\n        bool m_initialised = false;\n        \n        RenderSnapshot m_currentMainSnapshot;\n        std::vector<RenderSnapshot> m_currentOffscreenSnapshots;\n        \n        RenderCommandBufferManager* m_commandRecycleSystem = nullptr;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Base/SizePolicy.cpp",
    "content": "//\n//  SizePolicy.cpp\n//  ChilliSource\n//  Created by Scott Downie on 25/07/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Base/SizePolicy.h>\n\n#include <ChilliSource/Core/String/StringUtils.h>\n\nnamespace ChilliSource\n{\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    SizePolicy ParseSizePolicy(const std::string& in_policy)\n    {\n        std::string lowerCase = in_policy;\n        StringUtils::ToLowerCase(lowerCase);\n        \n        if(lowerCase == \"none\") return SizePolicy::k_none;\n        if(lowerCase == \"usepreferredsize\") return SizePolicy::k_usePreferredSize;\n        if(lowerCase == \"usewidthmaintainingaspect\") return SizePolicy::k_useWidthMaintainingAspect;\n        if(lowerCase == \"useheightmaintainingaspect\") return SizePolicy::k_useHeightMaintainingAspect;\n        if(lowerCase == \"fitmaintainingaspect\") return SizePolicy::k_fitMaintainingAspect;\n        if(lowerCase == \"fillmaintainingaspect\") return SizePolicy::k_fillMaintainingAspect;\n        \n        CS_LOG_FATAL(\"Cannot parse size policy type: \" + in_policy);\n        return SizePolicy::k_none;\n    }\n}"
  },
  {
    "path": "Source/ChilliSource/Rendering/Base/SizePolicy.h",
    "content": "//\n//  SizePolicy.h\n//  ChilliSource\n//  Created by Scott Downie on 25/07/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_BASE_SIZEPOLICY_H_\n#define _CHILLISOURCE_RENDERING_BASE_SIZEPOLICY_H_\n\n#include <ChilliSource/ChilliSource.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    /// Identifiers for functions that maintain the aspect ratio of the widget based\n    /// on current size and preferred size\n    ///\n    /// @author S Downie\n    //------------------------------------------------------------------------------\n    enum class SizePolicy\n    {\n        k_none,\n        k_usePreferredSize,\n        k_useWidthMaintainingAspect,\n        k_useHeightMaintainingAspect,\n        k_fitMaintainingAspect,\n        k_fillMaintainingAspect,\n        k_totalNum\n    };\n    //------------------------------------------------------------------------------\n    /// Parse the string and return the size policy\n    ///\n    /// @author S Downie\n    ///\n    /// @param String\n    ///\n    /// @return Size policy\n    //------------------------------------------------------------------------------\n    SizePolicy ParseSizePolicy(const std::string& in_policy);\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Base/StencilOp.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_BASE_STENCILOP_H_\n#define _CHILLISOURCE_RENDERING_BASE_STENCILOP_H_\n\nnamespace ChilliSource\n{\n    /// The stencil ops are used to determine which action to take\n    /// on a pixel after the result of stencil testing\n    ///\n    enum class StencilOp\n    {\n        k_keep,             // Keeps the current value\n        k_zero,             // Sets the stencil buffer value to zero\n        k_replace,          // Sets the stencil bufer value as specified by the stencil func\n        k_increment,        // Increments the stencil buffer value, clamps to max\n        k_incrementWrap,    // Increments the stencil buffer value, wraps to zero\n        k_decrement,        // Decrements the stencil buffer value, clamps to zero\n        k_decrementWrap,    // Decrements the stencil buffer value, wraps to max\n        k_invert            // Inverts the stencil buffer value\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Base/SurfaceFormat.h",
    "content": "//\n//  SurfaceFormat.h\n//  ChilliSource\n//  Created by Ian Copland on 03/06/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_BASE_SURFACEFORMAT_H_\n#define _CHILLISOURCE_RENDERING_BASE_SURFACEFORMAT_H_\n\n#include <ChilliSource/ChilliSource.h>\n\nnamespace ChilliSource\n{\n    //---------------------------------------------------------\n    /// An enum describing the different possible surface\n    /// formats.\n    ///\n    /// @author Ian Copland\n    //---------------------------------------------------------\n    enum class SurfaceFormat\n    {\n        k_rgb565_depth24,\n        k_rgb565_depth32,\n        k_rgb888_depth24,\n        k_rgb888_depth32,\n        k_rgb565_depth24_stencil8,\n        k_rgb565_depth32_stencil8,\n        k_rgb888_depth24_stencil8,\n        k_rgb888_depth32_stencil8\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Base/TargetRenderPassGroup.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2010 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Base/TargetRenderPassGroup.h>\n#include <ChilliSource/Rendering/Target/RenderTargetGroup.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    TargetRenderPassGroup::TargetRenderPassGroup(const Integer2& resolution, const Colour& clearColour, std::vector<CameraRenderPassGroup> cameraRenderPassGroups) noexcept\n        : m_resolution(resolution), m_renderCameraGroups(std::move(cameraRenderPassGroups)), m_clearColour(clearColour)\n    {\n    }\n    \n    //------------------------------------------------------------------------------\n    TargetRenderPassGroup::TargetRenderPassGroup(const RenderTargetGroup* renderTargetGroup, const Colour& clearColour, std::vector<CameraRenderPassGroup> cameraRenderPassGroups) noexcept\n        : m_renderTargetGroup(renderTargetGroup), m_clearColour(clearColour), m_renderCameraGroups(std::move(cameraRenderPassGroups))\n    {\n        CS_ASSERT(m_renderTargetGroup, \"Must supply a valid render target group.\");\n        \n        m_resolution = m_renderTargetGroup->GetResolution();\n    }\n}"
  },
  {
    "path": "Source/ChilliSource/Rendering/Base/TargetRenderPassGroup.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_BASE_TARGETRENDERPASSGROUP_H_\n#define _CHILLISOURCE_RENDERING_BASE_TARGETRENDERPASSGROUP_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Base/Colour.h>\n#include <ChilliSource/Rendering/Base/CameraRenderPassGroup.h>\n\nnamespace ChilliSource\n{\n    /// Provides the ability to group a number of camera render pass groups based on\n    /// them sharing the same render target\n    ///\n    /// This is immutable and therefore thread-safe\n    ///\n    class TargetRenderPassGroup final\n    {\n    public:\n        CS_DECLARE_NOCOPY(TargetRenderPassGroup);\n        \n        TargetRenderPassGroup() = default;\n        TargetRenderPassGroup(TargetRenderPassGroup&&) = default;\n        TargetRenderPassGroup& operator=(TargetRenderPassGroup&&) = default;\n        \n        /// Creates a new instance which will render to the default render target.\n        ///\n        /// @param resolution\n        ///     The resolution of the screen.\n        /// @param clearColour\n        ///     The targets clear colour.\n        /// @param cameraRenderPassGroups\n        ///     The list of camera render pass groups to render to the target. Must be moved.\n        ///\n        TargetRenderPassGroup(const Integer2& resolution, const Colour& clearColour, std::vector<CameraRenderPassGroup> cameraRenderPassGroups) noexcept;\n        \n        /// Creates a new instance which will render to the given render target group.\n        ///\n        /// @param renderTargetGroup\n        ///     The RenderTargetGroup that should be rendered into.\n        /// @param clearColour\n        ///     The targets clear colour.\n        /// @param cameraRenderPassGroups\n        ///     The list of camera render pass groups to render to the target. Must be moved.\n        ///\n        TargetRenderPassGroup(const RenderTargetGroup* renderTargetGroup, const Colour& clearColour, std::vector<CameraRenderPassGroup> cameraRenderPassGroups) noexcept;\n        \n        /// @return The render target group that the contained passes should be applied to. Null\n        ///     indicates that the default render target should be used.\n        ///\n        const RenderTargetGroup* GetRenderTargetGroup() const noexcept { return m_renderTargetGroup; }\n        \n        /// @return The resolution of the target.\n        ///\n        const Integer2& GetResolution() const noexcept { return m_resolution; }\n        \n        /// @return The targets clear colour.\n        ///\n        const Colour& GetClearColour() const noexcept { return m_clearColour; }\n        \n        /// @return The list of render camera groups\n        ///\n        const std::vector<CameraRenderPassGroup>& GetRenderCameraGroups() const noexcept { return m_renderCameraGroups; }\n\n    private:\n        const RenderTargetGroup* m_renderTargetGroup = nullptr;\n        Integer2 m_resolution;\n        Colour m_clearColour;\n        std::vector<CameraRenderPassGroup> m_renderCameraGroups;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Base/TargetType.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_BASE_TARGETTYPE_H_\n#define _CHILLISOURCE_RENDERING_BASE_TARGETTYPE_H_\n\nnamespace ChilliSource\n{\n    enum class TargetType\n    {\n        k_main,\n        k_offscreen\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Base/TestFunc.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_BASE_TESTFUNC_H_\n#define _CHILLISOURCE_RENDERING_BASE_TESTFUNC_H_\n\nnamespace ChilliSource\n{\n    /// Standard test functions that are used for depth and stencil testing\n    ///\n    enum class TestFunc\n    {\n        k_never,    \n        k_less,     \n        k_lessEqual,\n        k_greater,\n        k_greaterEqual,\n        k_equal,\n        k_notEqual,\n        k_always\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Base/VerticalTextJustification.cpp",
    "content": "//\n//  VerticalTextJustification.cpp\n//  ChilliSource\n//  Created by Ian Copland on 10/11/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2011 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Base/VerticalTextJustification.h>\n\n#include <ChilliSource/Core/String/StringUtils.h>\n\nnamespace ChilliSource\n{\n    //-------------------------------------------------------------------\n    //-------------------------------------------------------------------\n    VerticalTextJustification ParseVerticalTextJustification(const std::string& in_string)\n    {\n        std::string verticalJustificationString = in_string;\n        StringUtils::ToLowerCase(verticalJustificationString);\n        \n        if (verticalJustificationString == \"bottom\")\n        {\n            return VerticalTextJustification::k_bottom;\n        }\n        else if (verticalJustificationString == \"centre\")\n        {\n            return VerticalTextJustification::k_centre;\n        }\n        else if (verticalJustificationString == \"top\")\n        {\n            return VerticalTextJustification::k_top;\n        }\n        \n        CS_LOG_FATAL(\"Invalid vertical justification.\");\n        return VerticalTextJustification::k_centre;\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Base/VerticalTextJustification.h",
    "content": "//\n//  VerticalTextJustification.h\n//  ChilliSource\n//  Created by Ian Copland on 10/11/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2011 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_BASE_VERTICALTEXTJUSTIFICATION_H_\n#define _CHILLISOURCE_RENDERING_BASE_VERTICALTEXTJUSTIFICATION_H_\n\n#include <ChilliSource/ChilliSource.h>\n\nnamespace ChilliSource\n{\n    //-------------------------------------------------------------------\n    /// An enum describing the vertical justification of text.\n    ///\n    /// @author Ian Copland\n    //-------------------------------------------------------------------\n    enum class VerticalTextJustification\n    {\n        k_bottom,\n        k_centre,\n        k_top\n    };\n    //-------------------------------------------------------------------\n    /// Parses a vertical text justification from a string.\n    ///\n    /// @author Ian Copland\n    ///\n    /// @param The string.\n    ///\n    /// @return The vertical text justification.\n    //-------------------------------------------------------------------\n    VerticalTextJustification ParseVerticalTextJustification(const std::string& in_string);\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Base.h",
    "content": "//\n//  Base.h\n//  ChilliSource\n//  Created by Ian Copland on 07/07/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n\n#ifndef _CHILLISOURCE_RENDERING_BASE_H_\n#define _CHILLISOURCE_RENDERING_BASE_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Rendering/Base/AlignmentAnchors.h>\n#include <ChilliSource/Rendering/Base/AspectRatioUtils.h>\n#include <ChilliSource/Rendering/Base/BlendMode.h>\n#include <ChilliSource/Rendering/Base/CameraRenderPassGroup.h>\n#include <ChilliSource/Rendering/Base/CanvasDrawMode.h>\n#include <ChilliSource/Rendering/Base/CanvasMaterialPool.h>\n#include <ChilliSource/Rendering/Base/CanvasRenderer.h>\n#include <ChilliSource/Rendering/Base/CullFace.h>\n#include <ChilliSource/Rendering/Base/ForwardRenderPassCompiler.h>\n#include <ChilliSource/Rendering/Base/RenderPasses.h>\n#include <ChilliSource/Rendering/Base/FrameAllocatorQueue.h>\n#include <ChilliSource/Rendering/Base/HorizontalTextJustification.h>\n#include <ChilliSource/Rendering/Base/IRenderCommandProcessor.h>\n#include <ChilliSource/Rendering/Base/IRenderPassCompiler.h>\n#include <ChilliSource/Rendering/Base/RenderCapabilities.h>\n#include <ChilliSource/Rendering/Base/RenderCommandCompiler.h>\n#include <ChilliSource/Rendering/Base/Renderer.h>\n#include <ChilliSource/Rendering/Base/RenderFrame.h>\n#include <ChilliSource/Rendering/Base/RenderFrameCompiler.h>\n#include <ChilliSource/Rendering/Base/RenderFrameData.h>\n#include <ChilliSource/Rendering/Base/RenderLayer.h>\n#include <ChilliSource/Rendering/Base/RenderObject.h>\n#include <ChilliSource/Rendering/Base/RenderPass.h>\n#include <ChilliSource/Rendering/Base/RenderPassObject.h>\n#include <ChilliSource/Rendering/Base/RenderPassObjectSorter.h>\n#include <ChilliSource/Rendering/Base/RenderPassVisibilityChecker.h>\n#include <ChilliSource/Rendering/Base/RenderSnapshot.h>\n#include <ChilliSource/Rendering/Base/SizePolicy.h>\n#include <ChilliSource/Rendering/Base/StencilOp.h>\n#include <ChilliSource/Rendering/Base/SurfaceFormat.h>\n#include <ChilliSource/Rendering/Base/TargetRenderPassGroup.h>\n#include <ChilliSource/Rendering/Base/TargetType.h>\n#include <ChilliSource/Rendering/Base/TestFunc.h>\n#include <ChilliSource/Rendering/Base/VerticalTextJustification.h>\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Camera/CameraComponent.cpp",
    "content": "//\n//  CameraComponent.cpp\n//  ChilliSource\n//  Created by Scott Downie on 12/10/2010.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2010 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Camera/CameraComponent.h>\n\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/Base/Screen.h>\n#include <ChilliSource/Core/Delegate/MakeDelegate.h>\n#include <ChilliSource/Core/Entity/Entity.h>\n#include <ChilliSource/Core/Event/IConnectableEvent.h>\n#include <ChilliSource/Core/Scene/Scene.h>\n#include <ChilliSource/Rendering/Base/RenderSnapshot.h>\n\nnamespace ChilliSource\n{\n    CS_DEFINE_NAMEDTYPE(CameraComponent);\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    CameraComponent::CameraComponent(f32 in_nearClip, f32 in_farClip)\n    : m_nearClip(in_nearClip), m_farClip(in_farClip), m_screen(Application::Get()->GetScreen())\n    {\n        \n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void CameraComponent::SetNearClipping(f32 in_near)\n    {\n        m_nearClip = in_near;\n\n        m_projMat = CalculateProjectionMatrix();\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void CameraComponent::SetFarClipping(f32 in_far)\n    {\n        m_farClip = in_far;\n        \n        m_projMat = CalculateProjectionMatrix();\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    Ray CameraComponent::Unproject(const Vector2 &invScreenPos)\n    {\n        Matrix4 matProj = Matrix4::Inverse((GetView() * GetProjection()));\n        \n        Vector2 vScreenSize = m_screen->GetResolution();\n        //Normalise the screen space co-ordinates into clip space\n        f32 nx = ((2.0f * (invScreenPos.x/vScreenSize.x)) - 1.0f);\n        f32 ny = ((2.0f * (invScreenPos.y/vScreenSize.y)) - 1.0f);\n        \n        Vector4 vNear(nx, ny, -1.0f, 1.0f);\n        Vector4 vFar(nx,ny, 1.0f, 1.0f);\n        vNear = vNear * matProj;\n        vFar = vFar * matProj;\n        \n        Ray cRay;\n        \n        vNear /= vNear.w;\n        cRay.vOrigin = Vector3(vNear.x, vNear.y, vNear.z);\n\n        vFar /= vFar.w;\n        cRay.vDirection = Vector3(vFar.x, vFar.y, vFar.z) - cRay.vOrigin;\n        \n        cRay.fLength = cRay.vDirection.Length();\n        cRay.vDirection /= cRay.fLength;\n        \n        return cRay;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    Vector2 CameraComponent::Project(const Vector3 &invWorldPos)\n    {\n        //Convert the world space position to clip space\n        Matrix4 matToClip = (GetView() * GetProjection());\n        Vector4 vScreenPos = Vector4(invWorldPos, 1.0f) * matToClip;\n        \n        Vector2 vScreenSize = m_screen->GetResolution();\n        \n        // Normalize co-ordinates\n        vScreenPos.x = vScreenPos.x / vScreenPos.w;\n        vScreenPos.y = vScreenPos.y / vScreenPos.w;\n\n        //Convert from clip space to screen space\n        vScreenPos.x = (vScreenSize.x * 0.5f)* vScreenPos.x + vScreenSize.x * 0.5f;\n        vScreenPos.y = (vScreenSize.y * 0.5f)* vScreenPos.y + vScreenSize.y * 0.5f;\n\n        //Return 2D screen space co-ordinates\n        return Vector2(vScreenPos.x, vScreenPos.y);\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    const Matrix4& CameraComponent::GetProjection() const\n    {\n        return m_projMat;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    const Matrix4& CameraComponent::GetView()\n    {\n        if(GetEntity())\n        {\n            m_viewMat = Matrix4::Inverse(GetEntity()->GetTransform().GetWorldTransform());\n            return m_viewMat;\n        }\n\n        return Matrix4::k_identity;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    const Frustum& CameraComponent::GetFrustum()\n    {\n        if(m_isFrustumCacheValid == false)\n        {\n            UpdateFrustum();\n            m_isFrustumCacheValid = true;\n        }\n        \n        return m_frustum;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    Matrix4 CameraComponent::Billboard(const Matrix4& in_toBillboard)\n    {\n        const Matrix4& viewMat = GetView();\n        Matrix4 result = in_toBillboard * viewMat;\n        \n        result.m[12] = in_toBillboard.m[12];\n        result.m[13] = in_toBillboard.m[13];\n        result.m[14] = in_toBillboard.m[14];\n        \n        return result;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void CameraComponent::OnAddedToEntity()\n    {\n        m_transformChangedConnection = GetEntity()->GetTransform().GetTransformChangedEvent().OpenConnection([=]()\n        {\n            m_isFrustumCacheValid = false;\n        });\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void CameraComponent::OnAddedToScene()\n    {\n        m_resolutionChangedConnection = Application::Get()->GetScreen()->GetResolutionChangedEvent().OpenConnection([=](const Vector2& in_resolution)\n        {\n            m_isFrustumCacheValid = false;\n        });\n        \n        GetEntity()->GetScene()->SetActiveCamera(this);\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void CameraComponent::OnRemovedFromScene()\n    {\n        GetEntity()->GetScene()->SetActiveCamera(nullptr);\n        \n        m_resolutionChangedConnection.reset();\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void CameraComponent::OnRemovedFromEntity()\n    {\n        m_transformChangedConnection.reset();\n    }\n}\n\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Camera/CameraComponent.h",
    "content": "//\n//  CameraComponent.h\n//  ChilliSource\n//  Created by Scott Downie on 12/10/2010.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2010 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_CAMERA_CAMERACOMPONENT_H_\n#define _CHILLISOURCE_RENDERING_CAMERA_CAMERACOMPONENT_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Entity/Component.h>\n#include <ChilliSource/Core/Event/EventConnection.h>\n#include <ChilliSource/Core/Math/Geometry/Shapes.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    /// Base class for camera components. The camera is added to the scene and\n    /// provides the renderer with the view and projection matrices required to draw\n    /// the scene correctly\n    ///\n    /// @author S Downie\n    //------------------------------------------------------------------------------\n    class CameraComponent : public Component\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(CameraComponent);\n        //------------------------------------------------------------------------------\n        /// Governs how the viewport updates with screen resize\n        ///\n        /// @author S Downie\n        //------------------------------------------------------------------------------\n        enum class ViewportResizePolicy\n        {\n            k_none,\n            k_scaleWithScreen\n        };\n        //------------------------------------------------------------------------------\n        /// Constructor\n        ///\n        /// @author S Downie\n        ///\n        /// @param Near plane\n        /// @param Far plane\n        //------------------------------------------------------------------------------\n        CameraComponent(f32 in_nearClip, f32 in_farClip);\n        //------------------------------------------------------------------------------\n        /// Virtual Destructor\n        ///\n        /// @author S Downie\n        //------------------------------------------------------------------------------\n        virtual ~CameraComponent(){}\n        //------------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Near Z clipping distance in view space\n        //------------------------------------------------------------------------------\n        void SetNearClipping(f32 in_near);\n        //------------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Far Z clipping distance in view space\n        //------------------------------------------------------------------------------\n        void SetFarClipping(f32 in_far);\n        //------------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Projection matrix\n        //------------------------------------------------------------------------------\n        const Matrix4& GetProjection() const;\n        //------------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return View matrix\n        //------------------------------------------------------------------------------\n        const Matrix4& GetView();\n        //------------------------------------------------------------------------------\n        /// Unproject from a point in screen space to a ray in world space\n        ///\n        /// @param Point in screen space\n        ///\n        /// @return Ray in world space with camera view direction\n        //------------------------------------------------------------------------------\n        Ray Unproject(const Vector2& in_screenPos);\n        //------------------------------------------------------------------------------\n        /// Convert from a point in world space to a point in screen space\n        ///\n        /// @param World space pos\n        ///\n        /// @return Screen space pos\n        //------------------------------------------------------------------------------\n        Vector2 Project(const Vector3& in_worldPos);\n        //------------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Camera frustum\n        //------------------------------------------------------------------------------\n        const Frustum& GetFrustum();\n        //------------------------------------------------------------------------------\n        /// Orientate the given matrix to face the cameras view vector\n        ///\n        /// @author S Downie\n        ///\n        /// @param Matrix to billboard\n        ///\n        /// @return Billboarded matrix\n        //------------------------------------------------------------------------------\n        Matrix4 Billboard(const Matrix4& in_toBillboard);\n        \n    private:\n        //------------------------------------------------------------------------------\n        /// Delegates the calculation of the projection matrix to the concrete camera\n        /// types.\n        ///\n        /// @author S Downie\n        ///\n        /// @return Projection matrix\n        //------------------------------------------------------------------------------\n        virtual Matrix4 CalculateProjectionMatrix() = 0;\n        //------------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// Recalculate frustum planes\n        //------------------------------------------------------------------------------\n        virtual void UpdateFrustum() = 0;\n        //------------------------------------------------------------------------------\n        /// Called when the component is added to an entity.\n        ///\n        /// @author S Downie\n        //------------------------------------------------------------------------------\n        void OnAddedToEntity() override;\n        //------------------------------------------------------------------------------\n        /// Called when the component is added to the scene.\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------------------------------------\n        void OnAddedToScene() override;\n        //------------------------------------------------------------------------------\n        /// Called when the component is added to the scene.\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------------------------------------\n        void OnRemovedFromScene() override;\n        //------------------------------------------------------------------------------\n        /// Called when the component is removed from an entity.\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------------------------------------\n        void OnRemovedFromEntity() override;\n        \n    protected:\n        \n        Frustum m_frustum;\n        f32 m_nearClip;\n        f32 m_farClip;\n        bool m_isFrustumCacheValid = false;\n        Screen* m_screen = nullptr;\n        Matrix4 m_projMat;\n        Matrix4 m_viewMat;\n\n    private:\n        \n        EventConnectionUPtr m_transformChangedConnection;\n        EventConnectionUPtr m_resolutionChangedConnection;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Camera/OrthographicCameraComponent.cpp",
    "content": "//\n//  OrthographicCameraComponent.cpp\n//  ChilliSource\n//  Created by Scott Downie on 23/06/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Camera/OrthographicCameraComponent.h>\n\n#include <ChilliSource/Core/Base/Screen.h>\n#include <ChilliSource/Core/Delegate/MakeDelegate.h>\n#include <ChilliSource/Core/Event/IConnectableEvent.h>\n\nnamespace ChilliSource\n{\n    CS_DEFINE_NAMEDTYPE(OrthographicCameraComponent);\n    //----------------------------------------------------------\n    //----------------------------------------------------------\n    OrthographicCameraComponent::OrthographicCameraComponent(const Vector2& viewportSize, f32 nearClip, f32 farClip, ViewportResizePolicy resizePolicy)\n    : CameraComponent(nearClip, farClip), m_viewportSize(viewportSize), m_currentViewportSize(viewportSize), m_resizePolicy(resizePolicy)\n    {\n        switch(m_resizePolicy)\n        {\n            case ViewportResizePolicy::k_none:\n                break;\n            case ViewportResizePolicy::k_scaleWithScreen:\n                m_referenceScreenSize = m_screen->GetResolution();\n                m_screenResizedConnection = m_screen->GetResolutionChangedEvent().OpenConnection(MakeDelegate(this, &OrthographicCameraComponent::OnResolutionChanged));\n                break;\n        }\n        \n        m_projMat = CalculateProjectionMatrix();\n    }\n    //----------------------------------------------------------\n    //----------------------------------------------------------\n    bool OrthographicCameraComponent::IsA(InterfaceIDType in_interfaceId) const\n    {\n        return (in_interfaceId == CameraComponent::InterfaceID || in_interfaceId == OrthographicCameraComponent::InterfaceID);\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    void OrthographicCameraComponent::SetViewportSize(const Vector2& in_size)\n    {\n        m_viewportSize = in_size;\n        m_currentViewportSize = in_size;\n        m_referenceScreenSize = m_screen->GetResolution();\n        \n        m_projMat = CalculateProjectionMatrix();\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    Matrix4 OrthographicCameraComponent::CalculateProjectionMatrix()\n    {\n        return Matrix4::CreateOrthographicProjectionLH(m_currentViewportSize.x, m_currentViewportSize.y, m_nearClip, m_farClip);\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    void OrthographicCameraComponent::UpdateFrustum()\n    {\n        m_frustum.CalculateClippingPlanes(GetView() * GetProjection());\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    void OrthographicCameraComponent::OnResolutionChanged(const Vector2& in_resolution)\n    {\n        switch(m_resizePolicy)\n        {\n            case ViewportResizePolicy::k_none:\n                break;\n            case ViewportResizePolicy::k_scaleWithScreen:\n                m_currentViewportSize = m_viewportSize/m_referenceScreenSize * in_resolution;\n                m_projMat = CalculateProjectionMatrix();\n                break;\n        }\n    }\n}\n\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Camera/OrthographicCameraComponent.h",
    "content": "//\n//  OrthographicCameraComponent.h\n//  ChilliSource\n//  Created by Scott Downie on 23/06/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_CAMERA_ORTHOGRAPHICCAMERACOMPONENT_H_\n#define _CHILLISOURCE_RENDERING_CAMERA_ORTHOGRAPHICCAMERACOMPONENT_H_\n\n#include <ChilliSource/Rendering/Camera/CameraComponent.h>\n\nnamespace ChilliSource\n{\n    //----------------------------------------------------------\n    /// An orthographic camera. Objects do not scale with\n    /// distance from the camera.\n    ///\n    /// @author S Downie\n    //----------------------------------------------------------\n    class OrthographicCameraComponent final : public CameraComponent\n    {\n    public:\n\n        CS_DECLARE_NAMEDTYPE(OrthographicCameraComponent);\n\n        /// @param viewportSize\n        ///     Size of the viewport\n        /// @param nearClip\n        ///     Distance to the near clip plane in view space\n        /// @param farClip\n        ///     Distance to the far clip plane in view space\n        /// @param resizePolicy\n        ///     Governs how the viewport size responds to changes to the screen size\n        ///\n        OrthographicCameraComponent(const Vector2& viewportSize, f32 nearClip, f32 farClip, ViewportResizePolicy resizePolicy = ViewportResizePolicy::k_scaleWithScreen);\n        //----------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Comparison Type\n        ///\n        /// @return Whether the class matches the comparison type\n        //----------------------------------------------------------\n        bool IsA(InterfaceIDType in_interfaceId) const override;\n        //----------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Vector containing width and height of viewport\n        //----------------------------------------------------------\n        void SetViewportSize(const Vector2& in_size);\n        \n    private:\n\n        //------------------------------------------------------\n        /// Calculate the orthographic projection matrix\n        /// based on the current viewport size and near and\n        /// far planes\n        ///\n        /// @author S Downie\n        ///\n        /// @return Projection matrix\n        //------------------------------------------------------\n        Matrix4 CalculateProjectionMatrix() override;\n        //------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// Recalculate frustum planes\n        //------------------------------------------------------\n        void UpdateFrustum() override;\n        //------------------------------------------------------\n        /// Called when the resolution changes and resize with\n        /// screen is enabled.\n        ///\n        /// @author I Copland\n        //------------------------------------------------------\n        void OnResolutionChanged(const Vector2& in_resolution);\n\n    private:\n        \n        ViewportResizePolicy m_resizePolicy;\n        \n        Vector2 m_viewportSize;\n        Vector2 m_currentViewportSize;\n        Vector2 m_referenceScreenSize;\n        \n        EventConnectionUPtr m_screenResizedConnection;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Camera/PerspectiveCameraComponent.cpp",
    "content": "//\n//  PerspectiveCameraComponent.cpp\n//  ChilliSource\n//  Created by Scott Downie on 23/06/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Camera/PerspectiveCameraComponent.h>\n\n#include <ChilliSource/Core/Base/Screen.h>\n#include <ChilliSource/Core/Delegate/MakeDelegate.h>\n#include <ChilliSource/Core/Event/IConnectableEvent.h>\n\nnamespace ChilliSource\n{\n    CS_DEFINE_NAMEDTYPE(PerspectiveCameraComponent);\n    //----------------------------------------------------------\n    //----------------------------------------------------------\n    PerspectiveCameraComponent::PerspectiveCameraComponent(f32 aspectRatio, f32 fov, f32 nearClip, f32 farClip, ViewportResizePolicy resizePolicy)\n    : CameraComponent(nearClip, farClip), m_aspectRatio(aspectRatio), m_fov(fov), m_resizePolicy(resizePolicy)\n    {\n        switch(m_resizePolicy)\n        {\n            case ViewportResizePolicy::k_none:\n                break;\n            case ViewportResizePolicy::k_scaleWithScreen:\n                m_screenResizedConnection = m_screen->GetResolutionChangedEvent().OpenConnection(MakeDelegate(this, &PerspectiveCameraComponent::OnResolutionChanged));\n                break;\n        }\n        \n        m_projMat = CalculateProjectionMatrix();\n    }\n    //----------------------------------------------------------\n    //----------------------------------------------------------\n    bool PerspectiveCameraComponent::IsA(InterfaceIDType in_interfaceId) const\n    {\n        return (in_interfaceId == CameraComponent::InterfaceID || in_interfaceId == PerspectiveCameraComponent::InterfaceID);\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    void PerspectiveCameraComponent::SetFieldOfView(f32 in_fov)\n    {\n        m_fov = in_fov;\n        \n        m_projMat = CalculateProjectionMatrix();\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    void PerspectiveCameraComponent::SetAspectRatio(f32 in_aspectRatio)\n    {\n        m_aspectRatio = in_aspectRatio;\n        \n        m_projMat = CalculateProjectionMatrix();\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    f32 PerspectiveCameraComponent::GetFieldOfView() const\n    {\n        return m_fov;\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    f32 PerspectiveCameraComponent::GetAspectRatio() const\n    {\n        return m_aspectRatio;\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    Matrix4 PerspectiveCameraComponent::CalculateProjectionMatrix()\n    {\n        return Matrix4::CreatePerspectiveProjectionLH(m_fov, m_aspectRatio, m_nearClip, m_farClip);\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    void PerspectiveCameraComponent::UpdateFrustum()\n    {\n        m_frustum.CalculateClippingPlanes(GetView() * GetProjection());\n    }\n    //------------------------------------------------------\n    //------------------------------------------------------\n    void PerspectiveCameraComponent::OnResolutionChanged(const Vector2& in_resolution)\n    {\n        switch(m_resizePolicy)\n        {\n            case ViewportResizePolicy::k_none:\n                break;\n            case ViewportResizePolicy::k_scaleWithScreen:\n                SetAspectRatio(in_resolution.x / in_resolution.y);\n                break;\n        }\n    }\n}\n\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Camera/PerspectiveCameraComponent.h",
    "content": "//\n//  PerspectiveCameraComponent.h\n//  ChilliSource\n//  Created by Scott Downie on 23/06/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_CAMERA_PERSPECTIVECAMERACOMPONENT_H_\n#define _CHILLISOURCE_RENDERING_CAMERA_PERSPECTIVECAMERACOMPONENT_H_\n\n#include <ChilliSource/Rendering/Camera/CameraComponent.h>\n\nnamespace ChilliSource\n{\n    //----------------------------------------------------------\n    /// An perspective camera. Objects scale with\n    /// distance from the camera.\n    ///\n    /// @author S Downie\n    //----------------------------------------------------------\n    class PerspectiveCameraComponent final : public CameraComponent\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(PerspectiveCameraComponent);\n        \n        /// @param aspectRatio\n        ///     The aspect ratio of the camera viewport (usually screenWidth/screenHeight)\n        /// @param fov\n        ///     Full vertical field of view in radians\n        /// @param nearClip\n        ///     Distance to the near clip plane in view space\n        /// @param farClip\n        ///     Distance to the far clip plane in view space\n        /// @param resizePolicy\n        ///     How the viewport responds to the screen resizing (usually scaleWithScreen)\n        ///\n        PerspectiveCameraComponent(f32 aspectRatio, f32 fov, f32 nearClip, f32 farClip, ViewportResizePolicy resizePolicy = ViewportResizePolicy::k_scaleWithScreen);\n        \n        //----------------------------------------------------------\n        /// Is A\n        ///\n        /// Returns if it is of the type given\n        /// @param Comparison Type\n        /// @return Whether the class matches the comparison type\n        //----------------------------------------------------------\n        bool IsA(InterfaceIDType in_interfaceId) const override;\n        //------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Full vertical viewing angle in radians\n        //------------------------------------------------------\n        void SetFieldOfView(f32 in_fov);\n        //------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Aspect Ratio (Viewport width/viewport height)\n        //------------------------------------------------------\n        void SetAspectRatio(f32 in_aspectRatio);\n        //------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The full vertical viewing angle in radians.\n        //------------------------------------------------------\n        f32 GetFieldOfView() const;\n        //------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return Aspect Ratio (Viewport width/viewport height)\n        //------------------------------------------------------\n        f32 GetAspectRatio() const;\n        \n    private:\n        //------------------------------------------------------\n        /// Calculate the perspective projection matrix\n        /// based on the current FOV, aspect ratio and near and\n        /// far planes.\n        ///\n        /// @author S Downie\n        ///\n        /// @return Projection matrix\n        //------------------------------------------------------\n        Matrix4 CalculateProjectionMatrix() override;\n        //------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// Recalculate frustum planes\n        //------------------------------------------------------\n        void UpdateFrustum() override;\n        //------------------------------------------------------\n        /// Called when the resolution changes and resize with\n        /// screen is enabled.\n        ///\n        /// @author I Copland\n        //------------------------------------------------------\n        void OnResolutionChanged(const Vector2& in_resolution);\n\n    private:\n        \n        f32 m_fov;\n        f32 m_aspectRatio;\n        ViewportResizePolicy m_resizePolicy;\n        EventConnectionUPtr m_screenResizedConnection;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Camera/RenderCamera.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Camera/RenderCamera.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    RenderCamera::RenderCamera(const Matrix4& worldMatrix, const Matrix4& projectionMatrix, const Quaternion& orientation) noexcept\n        : m_worldMatrix(worldMatrix), m_projectionMatrix(projectionMatrix), m_orientation(orientation)\n    {\n        m_viewMatrix = Matrix4::Inverse(m_worldMatrix);\n        m_viewProjectionMatrix = m_viewMatrix * m_projectionMatrix;\n        m_frustrum.CalculateClippingPlanes(m_viewProjectionMatrix);\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Camera/RenderCamera.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_CAMERA_RENDERCAMERA_H_\n#define _CHILLISOURCE_RENDERING_CAMERA_RENDERCAMERA_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Math/Matrix4.h>\n#include <ChilliSource/Core/Math/Geometry/Shapes.h>\n\nnamespace ChilliSource\n{\n    /// A standard-layout container for data which the renderer requires that relates to a camera,\n    /// such as the projection and view matrices, as well as the screen resolution.\n    ///\n    /// This is immutable and therefore thread safe.\n    ///\n    class RenderCamera final\n    {\n    public:\n        RenderCamera() = default;\n        \n        /// Constructs a new instance of the container with the given camera world and projection\n        /// matrices.\n        ///\n        /// @param worldMatrix\n        ///     The world matrix of the camera. The view matrix will be derrived from this.\n        /// @param projectionMatrix\n        ///     The projection matrix of the camera.\n        /// @param orientation\n        ///     The orientation of the camera.\n        ///\n        RenderCamera(const Matrix4& worldMatrix, const Matrix4& projectionMatrix, const Quaternion& orientation) noexcept;\n        \n        /// @return The world matrix of the camera.\n        ///\n        const Matrix4& GetWorldMatrix() const noexcept { return m_worldMatrix; }\n        \n        /// @return The projection matrix of the camera.\n        ///\n        const Matrix4& GetProjectionMatrix() const noexcept { return m_projectionMatrix; }\n        \n        /// @return The view matrix of the camera.\n        ///\n        const Matrix4& GetViewMatrix() const noexcept { return m_viewMatrix; }\n        \n        /// @return The view projection matrix of the camera.\n        ///\n        const Matrix4& GetViewProjectionMatrix() const noexcept { return m_viewProjectionMatrix; }\n        \n        /// @return The orientation of the camera.\n        ///\n        const Quaternion& GetOrientation() const noexcept { return m_orientation; }\n        \n        /// @return The view frustrum of the camera.\n        ///\n        const Frustum& GetFrustrum() const noexcept { return m_frustrum; }\n        \n    private:\n        Matrix4 m_worldMatrix;\n        Matrix4 m_projectionMatrix;\n        Matrix4 m_viewMatrix;\n        Matrix4 m_viewProjectionMatrix;\n        Quaternion m_orientation;\n        Frustum m_frustrum;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Camera.h",
    "content": "//\n//  Camera.h\n//  ChilliSource\n//  Created by Ian Copland on 07/07/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n\n#ifndef _CHILLISOURCE_RENDERING_CAMERA_H_\n#define _CHILLISOURCE_RENDERING_CAMERA_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Rendering/Camera/CameraComponent.h>\n#include <ChilliSource/Rendering/Camera/OrthographicCameraComponent.h>\n#include <ChilliSource/Rendering/Camera/PerspectiveCameraComponent.h>\n#include <ChilliSource/Rendering/Camera/RenderCamera.h>\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Font/Font.cpp",
    "content": "//\n//  Font.cpp\n//  ChilliSource\n//  Created by Scott Downie on 26/10/2010.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2010 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Font/Font.h>\n\n#include <ChilliSource/Rendering/Texture/TextureAtlas.h>\n\n#include <algorithm>\n\nnamespace ChilliSource\n{\n    namespace\n    {\n        const u32 k_spacesPerTab = 5;\n    }\n    \n    CS_DEFINE_NAMEDTYPE(Font);\n    \n    //---------------------------------------------------------------------\n    //---------------------------------------------------------------------\n    FontUPtr Font::Create()\n    {\n        return FontUPtr(new Font());\n    }\n    //---------------------------------------------------------------------\n    //---------------------------------------------------------------------\n    bool Font::IsA(InterfaceIDType in_interfaceId) const\n    {\n        return in_interfaceId == Font::InterfaceID;\n    }\n    //-------------------------------------------\n    //-------------------------------------------\n    void Font::Build(const Descriptor& in_desc)\n    {\n        CS_ASSERT(in_desc.m_supportedCharacters.size() > 0, \"Font: Cannot build characters with empty character set\");\n        \n        m_characterInfos.clear();\n        m_characters = in_desc.m_supportedCharacters;\n        m_texture = in_desc.m_texture;\n        \n        const f32 textureAtlasWidth = (f32)in_desc.m_textureAtlasWidth;\n        const f32 textureAtlasHeight = (f32)in_desc.m_textureAtlasHeight;\n        \n        u32 frameIdx = 0;\n        \n        auto it = m_characters.begin();\n        while(it < m_characters.end())\n        {\n            auto character = UTF8StringUtils::Next(it);\n            \n            CharacterInfo info;\n            \n            const Frame& frame = in_desc.m_frames[frameIdx];\n            \n            info.m_UVs.m_u = (f32)(frame.m_texCoordU - 0.5f) / textureAtlasWidth;\n            info.m_UVs.m_v = (f32)(frame.m_texCoordV - 0.5f) / textureAtlasHeight;\n            info.m_UVs.m_s = (f32)(frame.m_width + 1.0f) / textureAtlasWidth;\n            info.m_UVs.m_t = (f32)(frame.m_height + 1.0f) / textureAtlasHeight;\n            \n            info.m_size.x = frame.m_width;\n            info.m_size.y = frame.m_height;\n            \n            info.m_offset.x = frame.m_offsetX;\n            info.m_offset.y = frame.m_offsetY;\n            \n            info.m_origin = frame.m_origin;\n            info.m_advance = frame.m_advance;\n            \n            m_lineHeight = std::max((f32)frame.m_height, m_lineHeight);\n            \n            m_characterInfos.insert(std::make_pair(character, info));\n            \n            ++frameIdx;\n        }\n        \n        m_pointSize = in_desc.m_pointSize;\n        \n        if(in_desc.m_lineHeight > 0)\n        {\n            m_lineHeight = (f32)in_desc.m_lineHeight;\n        }\n        \n        m_descent = f32(in_desc.m_descent);\n        m_verticalPadding = f32(in_desc.m_verticalPadding);\n        \n        //Just assign the width of a whitespaces based on the similar space character in the\n        //font. This means it will scale relative to the font\n        CharacterInfo spaceCharacter;\n        spaceCharacter.m_advance = f32(in_desc.m_spaceAdvance);\n        \n        //Space\n        m_characterInfos.insert(std::make_pair(k_spaceCharacter, spaceCharacter));\n        \n        //Non-breaking space\n        m_characterInfos.insert(std::make_pair(k_nbspCharacter, spaceCharacter));\n        \n        //Tab\n        spaceCharacter.m_size.x *= k_spacesPerTab;\n        m_characterInfos.insert(std::make_pair(k_tabCharacter, spaceCharacter));\n        \n        //Return\n        m_characterInfos.insert(std::make_pair(k_returnCharacter, CharacterInfo()));\n    }\n    //-------------------------------------------\n    //-------------------------------------------\n    const TextureCSPtr& Font::GetTexture() const\n    {\n        return m_texture;\n    }\n    //---------------------------------------------------------------------\n    //---------------------------------------------------------------------\n    u32 Font::GetPointSize() const\n    {\n        return m_pointSize;\n    }\n    //-------------------------------------------\n    //-------------------------------------------\n    f32 Font::GetLineHeight() const\n    {\n        return m_lineHeight;\n    }\n    //---------------------------------------------------------------------\n    //---------------------------------------------------------------------\n    f32 Font::GetDescent() const\n    {\n        return m_descent;\n    }\n    //---------------------------------------------------------------------\n    //---------------------------------------------------------------------\n    f32 Font::GetVerticalPadding() const\n    {\n        return m_verticalPadding;\n    }\n    //-------------------------------------------\n    //-------------------------------------------\n    bool Font::SupportsKerning() const\n    {\n        return false;\n    }\n    //-------------------------------------------\n    //-------------------------------------------\n    bool Font::TryGetCharacterInfo(UTF8Char in_char, CharacterInfo& out_info) const\n    {\n        auto itCharEntry = m_characterInfos.find(in_char);\n        \n        if (itCharEntry != m_characterInfos.end())\n        {\n            out_info = itCharEntry->second;\n            return true;\n        }\n        \n        return false;\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Font/Font.h",
    "content": "//\n//  Font.h\n//  ChilliSource\n//  Created by Scott Downie on 26/10/2010.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2010 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_FONT_FONT_H_\n#define _CHILLISOURCE_RENDERING_FONT_FONT_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Math/Geometry/Shapes.h>\n#include <ChilliSource/Core/Resource/Resource.h>\n#include <ChilliSource/Core/String/UTF8StringUtils.h>\n#include <ChilliSource/Rendering/Texture/UVs.h>\n\n#include <unordered_map>\n\nnamespace ChilliSource\n{\n    const UTF8Char k_returnCharacter = '\\n';\n    const UTF8Char k_tabCharacter = '\\t';\n    const UTF8Char k_spaceCharacter = ' ';\n    \n    //The nbsp character has the hex code C2A0 which converts to\n    //160 in decimal after utf-8 conversion\n    const UTF8Char k_nbspCharacter = 160;\n    \n    //---------------------------------------------------------------------\n    /// The font resource describing the size, spacing and kerning of\n    /// font characters.\n    ///\n    /// @author S Downie\n    //---------------------------------------------------------------------\n    class Font final : public Resource\n    {\n    public:\n        \n        typedef std::string CharacterSet;\n        \n        //---------------------------------------------------------------------\n        /// Holds the information relating to a single character such as\n        /// width, height and UVs\n        ///\n        /// @author S Downie\n        //---------------------------------------------------------------------\n        struct CharacterInfo\n        {\n            UVs m_UVs;\n            Vector2 m_size;\n            Vector2 m_offset;\n            f32 m_origin = 0.0f;\n            f32 m_advance = 0.0f;\n        };\n        //---------------------------------------------------------------------\n        /// Holds the description of a single character frame packed into\n        /// the font. This includes the size, UVs, etc\n        ///\n        /// @author S Downie\n        //---------------------------------------------------------------------\n        struct Frame\n        {\n            s16 m_texCoordU;\n            s16 m_texCoordV;\n            s16 m_width;\n            s16 m_height;\n            s16 m_offsetX;\n            s16 m_offsetY;\n            s16 m_originalWidth;\n            s16 m_originalHeight;\n            s16 m_origin;\n            s16 m_advance;\n        };\n        //---------------------------------------------------------------------\n        /// Holds the description of a font. Used to build the resource\n        ///\n        /// @author S Downie\n        //---------------------------------------------------------------------\n        struct Descriptor\n        {\n            std::vector<Frame> m_frames;\n            std::string m_supportedCharacters;\n            \n            TextureCSPtr m_texture;\n            \n            u32 m_textureAtlasWidth = 0;\n            u32 m_textureAtlasHeight = 0;\n            u32 m_pointSize = 0;\n            u32 m_lineHeight = 0;\n            u32 m_descent = 0;\n            u32 m_spaceAdvance = 0;\n            u32 m_verticalPadding = 0;\n        };\n        \n        CS_DECLARE_NAMEDTYPE(Font);\n        //---------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Interface ID\n        ///\n        /// @return Whether this object is of given type\n        //---------------------------------------------------------------------\n        bool IsA(InterfaceIDType in_interfaceId) const override;\n        //---------------------------------------------------------------------\n        /// Build the font from the given description\n        ///\n        /// @author S Downie\n        ///\n        /// @param Description containing texture, UVs and supported characters\n        //---------------------------------------------------------------------\n        void Build(const Descriptor& in_desc);\n        //---------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Font texture \n        //---------------------------------------------------------------------\n        const TextureCSPtr& GetTexture() const;\n        //---------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The point size of the font the bitmap font was created from.\n        //---------------------------------------------------------------------\n        u32 GetPointSize() const;\n        //---------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return The height of a line as determined by the font\n        //---------------------------------------------------------------------\n        f32 GetLineHeight() const;\n        //---------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The amount of space below the base line in the font.\n        //---------------------------------------------------------------------\n        f32 GetDescent() const;\n        //---------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The amount of padding added to the top and bottom of a\n        /// glyph image.\n        //---------------------------------------------------------------------\n        f32 GetVerticalPadding() const;\n        //---------------------------------------------------------------------\n        /// @author R Henning\n        ///\n        /// @return True is kerning supported, false otherwise\n        //---------------------------------------------------------------------\n        bool SupportsKerning() const;\n        //---------------------------------------------------------------------\n        /// @author S McGaw\n        ///\n        /// @param UTF-8 Character\n        /// @param [Out] Info struct to be filled with data for the character\n        ///\n        /// @return Whether the character exists in the font\n        //---------------------------------------------------------------------\n        bool TryGetCharacterInfo(UTF8Char in_char, CharacterInfo& out_info) const;\n    \n    private:\n        \n        friend class ResourcePool;\n        //---------------------------------------------------------------------\n        /// Factory method to create empty font resource. Used only by the\n        /// resource pool.\n        ///\n        /// @author S Downie\n        //---------------------------------------------------------------------\n        static FontUPtr Create();\n        //---------------------------------------------------------------------\n        /// Private constructor to enforce the use of factory method\n        ///\n        /// @author S Downie\n        //---------------------------------------------------------------------\n        Font() = default;\n        \n    private:\n        \n        std::unordered_map<UTF8Char, CharacterInfo> m_characterInfos;\n        CharacterSet m_characters;\n        \n        TextureCSPtr m_texture;\n        \n        u32 m_pointSize = 0;\n        f32 m_lineHeight = 0.0f;\n        f32 m_descent = 0.0f;\n        f32 m_verticalPadding;\n        \n        static f32 s_globalKerningOffset;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Font/FontProvider.cpp",
    "content": "//\n//  FontProvider.cpp\n//  ChilliSource\n//  Created by Scott Downie on 26/10/2010.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2010 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Font/FontProvider.h>\n\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/Base/Utils.h>\n#include <ChilliSource/Core/File/CSBinaryChunk.h>\n#include <ChilliSource/Core/File/CSBinaryInputStream.h>\n#include <ChilliSource/Core/Resource/ResourcePool.h>\n#include <ChilliSource/Core/String/UTF8StringUtils.h>\n#include <ChilliSource/Core/Threading/TaskScheduler.h>\n#include <ChilliSource/Rendering/Font/Font.h>\n#include <ChilliSource/Rendering/Texture/Texture.h>\n\nnamespace ChilliSource\n{\n    namespace\n    {\n        const std::string k_fontFileExtension(\"csfont\");\n        const std::string k_textureFileExtension(\"csimage\");\n        const u32 k_fileFormatId = 1;\n        const u32 k_fileFormatVersion = 2;\n        //----------------------------------------------------------------------------\n        /// Reads the contents of the INFO chunk in a CSFont file. This contains\n        /// information relating to the source font, and data that applies to all\n        /// glyphs.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The INFO binary chunk.\n        /// @param [Out] The font describing containing the output info.\n        ///\n        /// @return Whether or not the read was successful.\n        //----------------------------------------------------------------------------\n        bool ReadINFOChunk(CSBinaryChunk* in_chunk, Font::Descriptor& out_desc)\n        {\n            const u32 k_infoChunkSize = 7 * 4;\n            \n            CS_ASSERT(in_chunk != nullptr, \"INFO chunk cannot be null.\");\n            CS_ASSERT(in_chunk->GetSize() == k_infoChunkSize, \"INFO chunk is the wrong size.\");\n            \n            if (in_chunk != nullptr && in_chunk->GetSize() == k_infoChunkSize)\n            {\n                out_desc.m_pointSize = in_chunk->Read<u32>();\n                out_desc.m_lineHeight = in_chunk->Read<u32>();\n                out_desc.m_descent = in_chunk->Read<u32>();\n                out_desc.m_spaceAdvance = in_chunk->Read<u32>();\n                \n                out_desc.m_textureAtlasWidth = in_chunk->Read<u32>();\n                out_desc.m_textureAtlasHeight = in_chunk->Read<u32>();\n                out_desc.m_verticalPadding = in_chunk->Read<u32>();\n                \n                return true;\n            }\n            \n            return false;\n        }\n        //----------------------------------------------------------------------------\n        /// Reads the contents of the CHAR chunk in a CSFont file. This contains the\n        /// list of glyphs that the font can display.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The CHAR binary chunk.\n        /// @param [Out] The font describing containing the output info.\n        ///\n        /// @return Whether or not the read was successful.\n        //----------------------------------------------------------------------------\n        bool ReadCHARChunk(CSBinaryChunk* in_chunk, Font::Descriptor& out_desc)\n        {\n            CS_ASSERT(in_chunk != nullptr, \"CHAR chunk cannot be null.\");\n            \n            if (in_chunk != nullptr)\n            {\n                const u8* characterData = in_chunk->Read(in_chunk->GetSize());\n                out_desc.m_supportedCharacters = std::string(reinterpret_cast<const s8*>(characterData), in_chunk->GetSize());\n                return true;\n            }\n            \n            return false;\n        }\n        //----------------------------------------------------------------------------\n        /// Reads the contents of the GLPH chunk in a CSFont file. This contains the\n        /// glyph data.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The GLPH binary chunk.\n        /// @param [Out] The font describing containing the output info.\n        ///\n        /// @return Whether or not the read was successful.\n        //----------------------------------------------------------------------------\n        bool ReadGLPHChunk(CSBinaryChunk* in_chunk, Font::Descriptor& out_desc)\n        {\n            const u32 k_glyphInfoSize = 10 * 2;\n            \n            CS_ASSERT(in_chunk != nullptr, \"GLPH chunk cannot be null.\");\n            CS_ASSERT(in_chunk->GetSize() % k_glyphInfoSize == 0, \"GLPH chunk is the wrong size.\");\n            \n            if (in_chunk != nullptr && in_chunk->GetSize() % k_glyphInfoSize == 0)\n            {\n                const u32 numGlyphs = in_chunk->GetSize() / k_glyphInfoSize;\n                for (u32 i = 0; i < numGlyphs; ++i)\n                {\n                    Font::Frame frame;\n                    frame.m_texCoordU = in_chunk->Read<s16>();\n                    frame.m_texCoordV = in_chunk->Read<s16>();\n                    frame.m_width = in_chunk->Read<s16>();\n                    frame.m_height = in_chunk->Read<s16>();\n                    frame.m_offsetX = in_chunk->Read<s16>();\n                    frame.m_offsetY = in_chunk->Read<s16>();\n                    frame.m_originalWidth = in_chunk->Read<s16>();\n                    frame.m_originalHeight = in_chunk->Read<s16>();\n                    frame.m_origin = in_chunk->Read<s16>();\n                    frame.m_advance = in_chunk->Read<s16>();\n                    out_desc.m_frames.push_back(frame);\n                }\n                \n                return true;\n            }\n            \n            return false;\n        }\n        //----------------------------------------------------------------------------\n        /// Loads the contents of a CSFont file into the given font description.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The storage location of the file.\n        /// @param The file path.\n        /// @param [Out] Font description populated by this function\n        ///\n        /// @return Whether or not the read was successful.\n        //----------------------------------------------------------------------------\n        bool LoadCSFont(StorageLocation in_storageLocation, const std::string& in_filePath, Font::Descriptor& out_desc)\n        {\n            //create the stream.\n            CSBinaryInputStream stream(in_storageLocation, in_filePath);\n            if (stream.IsValid() == false || stream.GetFileFormatId() != k_fileFormatId || stream.GetFileFormatVersion() != k_fileFormatVersion)\n            {\n                CS_LOG_ERROR(\"Could not open csfont file: \" + in_filePath);\n                return false;\n            }\n            \n            //Read the INFO chunk.\n            CSBinaryChunkUPtr chunk = stream.ReadChunk(\"INFO\");\n            if (chunk == nullptr || ReadINFOChunk(chunk.get(), out_desc) == false)\n            {\n                CS_LOG_ERROR(\"Could not read INFO chunk in csfont file: \" + in_filePath);\n                return false;\n            }\n            \n            \n            //Read the CHAR chunk.\n            chunk = stream.ReadChunk(\"CHAR\");\n            if (chunk == nullptr || ReadCHARChunk(chunk.get(), out_desc) == false)\n            {\n                CS_LOG_ERROR(\"Could not read CHAR chunk in csfont file: \" + in_filePath);\n                return false;\n            }\n            \n            //Read the GLPH chunk.\n            chunk = stream.ReadChunk(\"GLPH\");\n            if (chunk == nullptr || ReadGLPHChunk(chunk.get(), out_desc) == false)\n            {\n                CS_LOG_ERROR(\"Could not read GLPH chunk in csfont file: \" + in_filePath);\n                return false;\n            }\n            \n            //ensure the data makes sense\n            u32 numCharacters = UTF8StringUtils::CalcLength(out_desc.m_supportedCharacters.begin(), out_desc.m_supportedCharacters.end());\n            if (out_desc.m_frames.size() != numCharacters)\n            {\n                CS_LOG_ERROR(\"Glyph count different to character count in font: \" + in_filePath);\n                return false;\n            }\n            \n            return true;\n        }\n    }\n    \n    CS_DEFINE_NAMEDTYPE(FontProvider);\n    \n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    FontProviderUPtr FontProvider::Create()\n    {\n        return FontProviderUPtr(new FontProvider());\n    }\n    //-------------------------------------------------------------------------e\n    //-------------------------------------------------------------------------\n    bool FontProvider::IsA(InterfaceIDType in_interfaceId) const\n    {\n        return in_interfaceId == ResourceProvider::InterfaceID || in_interfaceId == FontProvider::InterfaceID;\n    }\n    //----------------------------------------------------------------------------\n    //----------------------------------------------------------------------------\n    InterfaceIDType FontProvider::GetResourceType() const\n    {\n        return Font::InterfaceID;\n    }\n    //----------------------------------------------------------------------------\n    //----------------------------------------------------------------------------\n    bool FontProvider::CanCreateResourceWithFileExtension(const std::string& in_extension) const\n    {\n        return in_extension == k_fontFileExtension;\n    }\n    //----------------------------------------------------------------------------\n    //----------------------------------------------------------------------------\n    void FontProvider::CreateResourceFromFile(StorageLocation in_location, const std::string& in_filePath, const IResourceOptionsBaseCSPtr& in_options, const ResourceSPtr& out_resource)\n    {\n        LoadFont(in_location, in_filePath, nullptr, out_resource);\n    }\n    //----------------------------------------------------------------------------\n    //----------------------------------------------------------------------------\n    void FontProvider::CreateResourceFromFileAsync(StorageLocation in_location, const std::string& in_filePath, const IResourceOptionsBaseCSPtr& in_options, const ResourceProvider::AsyncLoadDelegate& in_delegate, const ResourceSPtr& out_resource)\n    {\n        Application::Get()->GetTaskScheduler()->ScheduleTask(TaskType::k_file, [=](const TaskContext&) noexcept\n        {\n            LoadFont(in_location, in_filePath, in_delegate, out_resource);\n        });\n    }\n    //----------------------------------------------------------------------------\n    //----------------------------------------------------------------------------\n    void FontProvider::LoadFont(StorageLocation in_location, const std::string& in_filePath, const ResourceProvider::AsyncLoadDelegate& in_delegate, const ResourceSPtr& out_resource)\n    {\n        std::string fileName, fileExtension;\n        StringUtils::SplitBaseFilename(in_filePath, fileName, fileExtension);\n        \n        const std::string textureFilePath(fileName + \".\" + k_textureFileExtension);\n        \n        if(in_delegate == nullptr)\n        {\n            Font::Descriptor desc;\n            desc.m_texture = Application::Get()->GetResourcePool()->LoadResource<Texture>(in_location, textureFilePath);\n            if(desc.m_texture == nullptr)\n            {\n                out_resource->SetLoadState(Resource::LoadState::k_failed);\n                return;\n            }\n            \n            if (LoadCSFont(in_location, in_filePath, desc) == false)\n            {\n                out_resource->SetLoadState(Resource::LoadState::k_failed);\n                return;\n            }\n            \n            Font* font = (Font*)(out_resource.get());\n            font->Build(desc);\n            out_resource->SetLoadState(Resource::LoadState::k_loaded);\n        }\n        else\n        {\n            Application::Get()->GetResourcePool()->LoadResourceAsync<Texture>(in_location, textureFilePath, [=](const TextureCSPtr& in_texture)\n            {\n                if(in_texture != nullptr)\n                {\n                    Application::Get()->GetTaskScheduler()->ScheduleTask(TaskType::k_file, [=](const TaskContext&) noexcept\n                    {\n                        Font::Descriptor desc;\n                        desc.m_texture = in_texture;\n                        \n                        if (LoadCSFont(in_location, in_filePath, desc) == true)\n                        {\n                            Font* font = (Font*)(out_resource.get());\n                            font->Build(desc);\n                            out_resource->SetLoadState(Resource::LoadState::k_loaded);\n                        }\n                        else\n                        {\n                            out_resource->SetLoadState(Resource::LoadState::k_failed);\n                        }\n\n                        Application::Get()->GetTaskScheduler()->ScheduleTask(TaskType::k_mainThread, [=](const TaskContext&) noexcept\n                        {\n                            in_delegate(out_resource);\n                        });\n                    });\n                }\n                else\n                {\n                    //Already on main thread\n                    out_resource->SetLoadState(Resource::LoadState::k_failed);\n                    in_delegate(out_resource);\n                }\n            });\n        }\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Font/FontProvider.h",
    "content": "//\n//  FontProvider.h\n//  ChilliSource\n//  Created by Scott Downie on 26/10/2010.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2010 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_FONT_FONTPROVIDER_H_\n#define _CHILLISOURCE_RENDERING_FONT_FONTPROVIDER_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Resource/ResourceProvider.h>\n\nnamespace ChilliSource\n{\n    //-------------------------------------------------------\n    /// Factory class from loading font resources\n    /// from file. The font resource is actually a compound\n    /// resource of supported characters and kerning info\n    ///\n    /// @author S Downie\n    //-------------------------------------------------------\n    class FontProvider final : public ResourceProvider\n    {\n    public:\n\n        CS_DECLARE_NAMEDTYPE(FontProvider);\n        \n        //-------------------------------------------------------\n        /// Factory method\n        ///\n        /// @author S Downie\n        ///\n        /// @return New backend with ownership transferred\n        //-------------------------------------------------------\n        static FontProviderUPtr Create();\n        //-------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Interface to compare\n        ///\n        /// @return Whether the object implements the given interface\n        //-------------------------------------------------------------------------\n        bool IsA(InterfaceIDType in_interfaceId) const override;\n        //----------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return The type of resource loaded by this provider\n        //----------------------------------------------------------------------------\n        InterfaceIDType GetResourceType() const override;\n        //----------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Extension to compare\n        ///\n        /// @return Whether the object can create a resource with the given extension\n        //----------------------------------------------------------------------------\n        bool CanCreateResourceWithFileExtension(const std::string& in_extension) const override;\n        \n    private:\n        //-------------------------------------------------------\n        /// Private constructor to force use of factory method\n        ///\n        /// @author S Downie\n        //-------------------------------------------------------\n        FontProvider() = default;\n        //----------------------------------------------------------------------------\n        /// Load the font from the external file into a resource. Check resource\n        /// load state for success or failure\n        ///\n        /// @author S Downie\n        ///\n        /// @param The storage location to load from\n        /// @param File path\n        /// @param Options to customise the creation\n        /// @param [Out] Resource object\n        //----------------------------------------------------------------------------\n        void CreateResourceFromFile(StorageLocation in_location, const std::string& in_filePath, const IResourceOptionsBaseCSPtr& in_options, const ResourceSPtr& out_resource) override;\n        //----------------------------------------------------------------------------\n        /// Load the font from the external file into a resource on a background\n        /// thread. Delegate is called when the load is complete. Check resource\n        /// load state for success or failure.\n        ///\n        /// @author S Downie\n        ///\n        /// @param The storage location to load from\n        /// @param File path\n        /// @param Options to customise the creation\n        /// @param Completion delegate\n        /// @param [Out] Resource object\n        //----------------------------------------------------------------------------\n        void CreateResourceFromFileAsync(StorageLocation in_location, const std::string& in_filePath, const IResourceOptionsBaseCSPtr& in_options, const ResourceProvider::AsyncLoadDelegate& in_delegate, const ResourceSPtr& out_resource) override;\n        //----------------------------------------------------------------------------\n        /// Function that does the heavy lifting of font loading. The 2 creation\n        /// methods delegate to this one.\n        ///\n        /// @author S Downie\n        ///\n        /// @param The storage location to load from\n        /// @param Filename\n        /// @param Completion delegate\n        /// @param [Out] Font resource\n        //----------------------------------------------------------------------------\n        void LoadFont(StorageLocation in_location, const std::string& in_filePath, const ResourceProvider::AsyncLoadDelegate& in_delegate, const ResourceSPtr& out_resource);\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Font.h",
    "content": "//\n//  Font.h\n//  ChilliSource\n//  Created by Ian Copland on 07/07/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n\n#ifndef _CHILLISOURCE_RENDERING_FONT_H_\n#define _CHILLISOURCE_RENDERING_FONT_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Rendering/Font/Font.h>\n#include <ChilliSource/Rendering/Font/FontProvider.h>\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/ForwardDeclarations.h",
    "content": "//\n//  ForwardDeclarations.h\n//  ChilliSource\n//  Created by Ian Copland on 26/02/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_FORWARDDECLARATIONS_H_\n#define _CHILLISOURCE_RENDERING_FORWARDDECLARATIONS_H_\n\n#include <ChilliSource/Core/Base/StandardMacros.h>\n\n#include <memory>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------\n    /// Base\n    //------------------------------------------------------------\n    CS_FORWARDDECLARE_CLASS(CanvasMaterialPool);\n    CS_FORWARDDECLARE_CLASS(CanvasRenderer);\n    CS_FORWARDDECLARE_CLASS(IRenderCommandProcessor);\n    CS_FORWARDDECLARE_CLASS(IRenderPassCompiler);\n    CS_FORWARDDECLARE_CLASS(ForwardRenderPassCompiler);\n    CS_FORWARDDECLARE_CLASS(FrameAllocatorQueue);\n    CS_FORWARDDECLARE_CLASS(RenderCapabilities);\n    CS_FORWARDDECLARE_CLASS(Renderer);\n    CS_FORWARDDECLARE_CLASS(RenderFrame);\n    CS_FORWARDDECLARE_CLASS(RenderFrameData);\n    CS_FORWARDDECLARE_CLASS(RenderObject);\n    CS_FORWARDDECLARE_CLASS(RenderPass);\n    CS_FORWARDDECLARE_CLASS(RenderPassObject);\n    CS_FORWARDDECLARE_CLASS(RenderSnapshot);\n    CS_FORWARDDECLARE_CLASS(TargetRenderPassGroup);\n    CS_FORWARDDECLARE_CLASS(CameraRenderPassGroup);\n    enum class AlignmentAnchor;\n    enum class BlendEqn;\n    enum class BlendMode;\n    enum class CanvasDrawMode;\n    enum class CullFace;\n    enum class DepthTestComparison;\n    enum class HorizontalTextJustification;\n    enum class RenderLayer;\n    enum class RenderPasses;\n    enum class SizePolicy;\n    enum class StencilOp;\n    enum class SurfaceFormat;\n    enum class TestFunc;\n    enum class TargetType;\n    enum class VerticalTextJustification;\n    //------------------------------------------------------------\n    /// Camera\n    //------------------------------------------------------------\n    CS_FORWARDDECLARE_CLASS(CameraComponent);\n    CS_FORWARDDECLARE_CLASS(OrthographicCameraComponent);\n    CS_FORWARDDECLARE_CLASS(PerspectiveCameraComponent);\n    CS_FORWARDDECLARE_CLASS(RenderCamera);\n    //------------------------------------------------------------\n    /// Font\n    //------------------------------------------------------------\n    CS_FORWARDDECLARE_CLASS(Font);\n    CS_FORWARDDECLARE_CLASS(FontProvider);\n    //------------------------------------------------------------\n    /// Lighting\n    //------------------------------------------------------------\n    CS_FORWARDDECLARE_CLASS(AmbientLightComponent);\n    CS_FORWARDDECLARE_CLASS(DirectionalLightComponent);\n    CS_FORWARDDECLARE_CLASS(LightComponent);\n    CS_FORWARDDECLARE_CLASS(PointLightComponent);\n    CS_FORWARDDECLARE_CLASS(AmbientRenderLight);\n    CS_FORWARDDECLARE_CLASS(DirectionalRenderLight);\n    CS_FORWARDDECLARE_CLASS(PointRenderLight);\n    //------------------------------------------------------------\n    /// Material\n    //------------------------------------------------------------\n    CS_FORWARDDECLARE_CLASS(ForwardRenderMaterialGroupManager);\n    CS_FORWARDDECLARE_CLASS(Material);\n    CS_FORWARDDECLARE_CLASS(MaterialFactory);\n    CS_FORWARDDECLARE_CLASS(MaterialProvider);\n    CS_FORWARDDECLARE_CLASS(RenderMaterial);\n    CS_FORWARDDECLARE_CLASS(RenderMaterialGroup);\n    CS_FORWARDDECLARE_CLASS(RenderMaterialGroupManager);\n    enum class MaterialShadingType;\n    //------------------------------------------------------------\n    /// Model\n    //------------------------------------------------------------\n    CS_FORWARDDECLARE_CLASS(AnimatedModelComponent);\n    CS_FORWARDDECLARE_CLASS(CSAnimProvider);\n    CS_FORWARDDECLARE_CLASS(CSModelProvider);\n    CS_FORWARDDECLARE_CLASS(MeshDesc);\n    CS_FORWARDDECLARE_CLASS(Model);\n    CS_FORWARDDECLARE_CLASS(ModelDesc);\n    CS_FORWARDDECLARE_CLASS(PrimitiveModelFactory);\n    CS_FORWARDDECLARE_CLASS(RenderDynamicMesh);\n    CS_FORWARDDECLARE_CLASS(RenderMesh);\n    CS_FORWARDDECLARE_CLASS(RenderMeshBatch);\n    CS_FORWARDDECLARE_CLASS(RenderMeshManager);\n    CS_FORWARDDECLARE_CLASS(RenderSkinnedAnimation);\n    CS_FORWARDDECLARE_CLASS(Skeleton);\n    CS_FORWARDDECLARE_CLASS(SkeletonDesc);\n    CS_FORWARDDECLARE_STRUCT(SkeletonNode);\n    CS_FORWARDDECLARE_CLASS(SkinnedAnimation);\n    CS_FORWARDDECLARE_CLASS(SkinnedAnimationGroup);\n    CS_FORWARDDECLARE_CLASS(SmallMeshBatcher);\n    CS_FORWARDDECLARE_CLASS(StaticModelComponent);\n    CS_FORWARDDECLARE_CLASS(VertexFormat);\n    enum class IndexFormat;\n    enum class PolygonType;\n    //------------------------------------------------------------\n    /// Particle\n    //------------------------------------------------------------\n    CS_FORWARDDECLARE_CLASS(ConcurrentParticleData);\n    CS_FORWARDDECLARE_CLASS(CSParticleProvider);\n    CS_FORWARDDECLARE_CLASS(ParticleEffect);\n    CS_FORWARDDECLARE_CLASS(ParticleEffectComponent);\n    CS_FORWARDDECLARE_STRUCT(Particle);\n    CS_FORWARDDECLARE_CLASS(ParticleDrawable);\n    CS_FORWARDDECLARE_CLASS(ParticleDrawableDef);\n    CS_FORWARDDECLARE_CLASS(ParticleDrawableDefFactory);\n    CS_FORWARDDECLARE_CLASS(ParticleEmitter);\n    CS_FORWARDDECLARE_CLASS(ParticleEmitterDef);\n    CS_FORWARDDECLARE_CLASS(ParticleEmitterDefFactory);\n    CS_FORWARDDECLARE_CLASS(ParticleAffector);\n    CS_FORWARDDECLARE_CLASS(ParticleAffectorDef);\n    CS_FORWARDDECLARE_CLASS(ParticleAffectorDefFactory);\n    CS_FORWARDDECLARE_CLASS(StaticBillboardParticleDrawable);\n    CS_FORWARDDECLARE_CLASS(StaticBillboardParticleDrawableDef);\n    CS_FORWARDDECLARE_CLASS(AccelerationParticleAffector);\n    CS_FORWARDDECLARE_CLASS(AccelerationParticleAffectorDef);\n    CS_FORWARDDECLARE_CLASS(AngularAccelerationParticleAffector);\n    CS_FORWARDDECLARE_CLASS(AngularAccelerationParticleAffectorDef);\n    CS_FORWARDDECLARE_CLASS(ColourOverLifetimeParticleAffector);\n    CS_FORWARDDECLARE_CLASS(ColourOverLifetimeParticleAffectorDef);\n    CS_FORWARDDECLARE_CLASS(ScaleOverLifetimeParticleAffector);\n    CS_FORWARDDECLARE_CLASS(ScaleOverLifetimeParticleAffectorDef);\n    CS_FORWARDDECLARE_CLASS(SphereParticleEmitter);\n    CS_FORWARDDECLARE_CLASS(SphereParticleEmitterDef);\n    CS_FORWARDDECLARE_CLASS(CircleParticleEmitter);\n    CS_FORWARDDECLARE_CLASS(CircleParticleEmitterDef);\n    CS_FORWARDDECLARE_CLASS(PointParticleEmitter);\n    CS_FORWARDDECLARE_CLASS(PointParticleEmitterDef);\n    CS_FORWARDDECLARE_CLASS(ConeParticleEmitter);\n    CS_FORWARDDECLARE_CLASS(ConeParticleEmitterDef);\n    CS_FORWARDDECLARE_CLASS(Cone2DParticleEmitter);\n    CS_FORWARDDECLARE_CLASS(Cone2DParticleEmitterDef);\n    template <typename TPropertyType> class ParticleProperty;\n    template <typename TPropertyType> using ParticlePropertyUPtr = std::unique_ptr<ParticleProperty<TPropertyType>>;\n    template <typename TPropertyType> using ParticlePropertyCUPtr = std::unique_ptr<const ParticleProperty<TPropertyType>>;\n    template <typename TPropertyType> class ConstantParticleProperty;\n    template <typename TPropertyType> class RandomConstantParticleProperty;\n    template <typename TPropertyType> class ComponentwiseRandomConstantParticleProperty;\n    template <typename TPropertyType> class CurveParticleProperty;\n    template <typename TPropertyType> class RandomCurveParticleProperty;\n    template <typename TPropertyType> class ComponentwiseRandomCurveParticleProperty;\n    //------------------------------------------------------------\n    /// Render Command\n    //------------------------------------------------------------\n    CS_FORWARDDECLARE_CLASS(ApplyAmbientLightRenderCommand);\n    CS_FORWARDDECLARE_CLASS(ApplyCameraRenderCommand);\n    CS_FORWARDDECLARE_CLASS(ApplyDirectionalLightRenderCommand);\n    CS_FORWARDDECLARE_CLASS(ApplyDynamicMeshRenderCommand);\n    CS_FORWARDDECLARE_CLASS(ApplyMaterialRenderCommand);\n    CS_FORWARDDECLARE_CLASS(ApplyMeshRenderCommand);\n    CS_FORWARDDECLARE_CLASS(ApplyMeshBatchRenderCommand);\n    CS_FORWARDDECLARE_CLASS(ApplyPointLightRenderCommand);\n    CS_FORWARDDECLARE_CLASS(ApplySkinnedAnimationRenderCommand);\n    CS_FORWARDDECLARE_CLASS(BeginRenderCommand);\n    CS_FORWARDDECLARE_CLASS(BeginWithTargetGroupRenderCommand);\n    CS_FORWARDDECLARE_CLASS(EndRenderCommand);\n    CS_FORWARDDECLARE_CLASS(LoadMaterialGroupRenderCommand);\n    CS_FORWARDDECLARE_CLASS(LoadMeshRenderCommand);\n    CS_FORWARDDECLARE_CLASS(LoadShaderRenderCommand);\n    CS_FORWARDDECLARE_CLASS(LoadTargetGroupRenderCommand);\n    CS_FORWARDDECLARE_CLASS(LoadTextureRenderCommand);\n    CS_FORWARDDECLARE_CLASS(LoadCubemapRenderCommand);\n    CS_FORWARDDECLARE_CLASS(RestoreMeshRenderCommand);\n    CS_FORWARDDECLARE_CLASS(RestoreRenderTargetGroupCommand);\n    CS_FORWARDDECLARE_CLASS(RestoreTextureRenderCommand);\n    CS_FORWARDDECLARE_CLASS(RestoreCubemapRenderCommand);\n    CS_FORWARDDECLARE_CLASS(RenderCommand);\n    CS_FORWARDDECLARE_CLASS(RenderCommandBuffer);\n    CS_FORWARDDECLARE_CLASS(RenderCommandBufferManager);\n    CS_FORWARDDECLARE_CLASS(RenderCommandList);\n    CS_FORWARDDECLARE_CLASS(RenderInstanceRenderCommand);\n    CS_FORWARDDECLARE_CLASS(UnloadMaterialGroupRenderCommand);\n    CS_FORWARDDECLARE_CLASS(UnloadMeshRenderCommand);\n    CS_FORWARDDECLARE_CLASS(UnloadShaderRenderCommand);\n    CS_FORWARDDECLARE_CLASS(UnloadTargetGroupRenderCommand);\n    CS_FORWARDDECLARE_CLASS(UnloadTextureRenderCommand);\n    CS_FORWARDDECLARE_CLASS(UnloadCubemapRenderCommand);\n    //------------------------------------------------------------\n    /// Shader\n    //------------------------------------------------------------\n    CS_FORWARDDECLARE_CLASS(CSShaderProvider);\n    CS_FORWARDDECLARE_CLASS(RenderShader);\n    CS_FORWARDDECLARE_CLASS(RenderShaderManager);\n    CS_FORWARDDECLARE_CLASS(RenderShaderVariables);\n    CS_FORWARDDECLARE_CLASS(Shader);\n    //------------------------------------------------------------\n    /// Skybox\n    //------------------------------------------------------------\n    CS_FORWARDDECLARE_CLASS(SkyboxComponent);\n    //------------------------------------------------------------\n    /// Sprite\n    //------------------------------------------------------------\n    CS_FORWARDDECLARE_CLASS(SpriteComponent);\n    //------------------------------------------------------------\n    /// Target\n    //------------------------------------------------------------\n    CS_FORWARDDECLARE_CLASS(RenderTargetGroup);\n    CS_FORWARDDECLARE_CLASS(RenderTargetGroupManager);\n    CS_FORWARDDECLARE_CLASS(TargetGroup);\n    enum class RenderTargetGroupType;\n    //------------------------------------------------------------\n    /// Texture\n    //------------------------------------------------------------\n    CS_FORWARDDECLARE_CLASS(Cubemap);\n    CS_FORWARDDECLARE_CLASS(CubemapProvider);\n    CS_FORWARDDECLARE_CLASS(RenderTexture);\n    CS_FORWARDDECLARE_CLASS(RenderTextureManager);\n    CS_FORWARDDECLARE_CLASS(Texture);\n    CS_FORWARDDECLARE_CLASS(TextureAtlas);\n    CS_FORWARDDECLARE_CLASS(TextureAtlasProvider);\n    CS_FORWARDDECLARE_CLASS(TextureDesc);\n    CS_FORWARDDECLARE_CLASS(TextureProvider);\n    CS_FORWARDDECLARE_CLASS(UVs);\n    enum class TextureFilterMode;\n    enum class TextureType;\n    enum class TextureWrapMode;\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Lighting/AmbientLightComponent.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Lighting/AmbientLightComponent.h>\n\n#include <ChilliSource/Rendering/Base/RenderSnapshot.h>\n#include <ChilliSource/Rendering/Lighting/AmbientRenderLight.h>\n\nnamespace ChilliSource\n{\n    CS_DEFINE_NAMEDTYPE(AmbientLightComponent);\n    \n    //------------------------------------------------------------------------------\n    AmbientLightComponent::AmbientLightComponent(const Colour& colour, f32 intensity) noexcept\n        : m_colour(colour), m_intensity(intensity)\n    {\n    }\n    \n    //------------------------------------------------------------------------------\n    bool AmbientLightComponent::IsA(InterfaceIDType interfaceId) const noexcept\n    {\n        return AmbientLightComponent::InterfaceID == interfaceId;\n    }\n    \n    //------------------------------------------------------------------------------\n    void AmbientLightComponent::OnRenderSnapshot(RenderSnapshot& renderSnapshot, IAllocator* frameAllocator) noexcept\n    {\n        renderSnapshot.AddAmbientRenderLight(AmbientRenderLight(GetFinalColour()));\n    }\n}\n\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Lighting/AmbientLightComponent.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_AMBIENTLIGHTCOMPONENT_H_\n#define _CHILLISOURCE_RENDERING_AMBIENTLIGHTCOMPONENT_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Base/Colour.h>\n#include <ChilliSource/Core/Entity/Component.h>\n\nnamespace ChilliSource\n{\n    /// A component which describes an ambient light. While this is in the scene, all\n    /// lit objects will have the light colour descibed applied to it.\n    ///\n    /// This is not thread-safe and should only be accessed from the main thread.\n    ///\n    class AmbientLightComponent final : public Component\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(AmbientLightComponent);\n        \n        /// Creates a new ambient light with the given colour and intensity.\n        ///\n        /// @param colour\n        ///     The colour of the ambient light.\n        /// @param intensity\n        ///     (Optional) The intensity of the ambient light. This defaults to 1.0.\n        ///\n        AmbientLightComponent(const Colour& colour, f32 intensity = 1.0f) noexcept;\n        \n        /// Allows querying of whether or not this system implements the interface described by the\n        /// given interface Id. Typically this is not called directly as the templated equivalent\n        /// IsA<Interface>() is preferred.\n        ///\n        /// @param interfaceId\n        ///     The Id of the interface.\n        ///\n        /// @return Whether or not the interface is implemented.\n        ///\n        bool IsA(InterfaceIDType interfaceId) const noexcept override;\n        \n        /// @return The colour of the ambient light.\n        ///\n        void SetColour(const Colour& colour) noexcept { m_colour = colour; }\n        \n        /// @return The intensity of the ambient light.\n        ///\n        void SetIntensity(f32 intensity) noexcept { m_intensity = intensity; }\n        \n        /// @return The colour of the ambient light.\n        ///\n        const Colour& GetColour() const noexcept { return m_colour; }\n        \n        /// @return The intensity of the ambient light.\n        ///\n        f32 GetIntensity() const noexcept { return m_intensity; }\n        \n        /// @return The colour of the ambient light with the intesity applied to it.\n        ///\n        Colour GetFinalColour() const noexcept { return m_colour * m_intensity; }\n        \n    private:\n        /// This is called during the render snapshot stage of the render pipeline to collect a copy of\n        /// the current state of the renderable portion of the scene. This will add all relevant light\n        /// data to this snapshot.\n        ///\n        /// @param renderSnapshot\n        ///     The snapshot that the light data will be added to.\n        /// @param frameAllocator\n        ///     Allocate any render memory for this frame from here\n        ///\n        void OnRenderSnapshot(RenderSnapshot& renderSnapshot, IAllocator* frameAllocator) noexcept override;\n        \n        Colour m_colour;\n        f32 m_intensity;\n    };\n}\n\n#endif"
  },
  {
    "path": "Source/ChilliSource/Rendering/Lighting/AmbientRenderLight.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Lighting/AmbientRenderLight.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    AmbientRenderLight::AmbientRenderLight() noexcept\n        : m_colour(Colour::k_black)\n    {\n    }\n    //------------------------------------------------------------------------------\n    AmbientRenderLight::AmbientRenderLight(const Colour& colour) noexcept\n        : m_colour(colour)\n    {\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Lighting/AmbientRenderLight.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_LIGHTING_RENDERAMBIENTLIGHT_H_\n#define _CHILLISOURCE_RENDERING_LIGHTING_RENDERAMBIENTLIGHT_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Base/Colour.h>\n\nnamespace ChilliSource\n{\n    /// A standard-layout container for data the renderer needs which pertains to a single\n    /// ambient light, such as the colour.\n    class AmbientRenderLight final\n    {\n    public:\n        \n        /// Creates a new instance of the container with default black colour.\n        ///\n        AmbientRenderLight() noexcept;\n        \n        /// Creates a new instance of the container with the given light colour.\n        ///\n        /// @param colour\n        ///     The colour of the light.\n        ///\n        AmbientRenderLight(const Colour& colour) noexcept;\n        \n        /// @return The colour of the light.\n        ///\n        const Colour& GetColour() const noexcept { return m_colour; }\n        \n    private:\n        Colour m_colour;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Lighting/DirectionalLightComponent.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Lighting/DirectionalLightComponent.h>\n\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/Delegate/MakeDelegate.h>\n#include <ChilliSource/Core/Image/ImageCompression.h>\n#include <ChilliSource/Core/Image/ImageFormat.h>\n#include <ChilliSource/Core/Resource/ResourcePool.h>\n#include <ChilliSource/Core/Entity/Entity.h>\n#include <ChilliSource/Core/Resource/ResourcePool.h>\n#include <ChilliSource/Rendering/Base/RenderCapabilities.h>\n#include <ChilliSource/Rendering/Base/RenderSnapshot.h>\n#include <ChilliSource/Rendering/Target/RenderTargetGroupManager.h>\n#include <ChilliSource/Rendering/Texture/Texture.h>\n#include <ChilliSource/Rendering/Texture/TextureDesc.h>\n\nnamespace ChilliSource\n{\n    namespace\n    {\n        constexpr f32 k_defaultShadowTolerance = 0.005f;\n        constexpr f32 k_defaultShadowVolumeWidth = 50.0f;\n        constexpr f32 k_defaultShadowVolumeHeight = 50.0f;\n        constexpr f32 k_defaultShadowVolumeNear = 5.0f;\n        constexpr f32 k_defaultShadowVolumeFar = 50.0f;\n        \n        u32 g_nextShadowMapId = 0;\n        \n        /// Gets the shadow map resolution for the given ShadowQuality.\n        ///\n        /// @param shadowQuality\n        ///     The quality of the shadows.\n        ///\n        /// @return The resolution.\n        ///\n        Integer2 GetShadowMapResolution(DirectionalLightComponent::ShadowQuality shadowQuality) noexcept\n        {\n            switch (shadowQuality)\n            {\n                case DirectionalLightComponent::ShadowQuality::k_low:\n                    return Integer2(512, 512);\n                case DirectionalLightComponent::ShadowQuality::k_medium:\n                    return Integer2(1024, 1024);\n                case DirectionalLightComponent::ShadowQuality::k_high:\n                    return Integer2(2048, 2048);\n                default:\n                    CS_LOG_FATAL(\"Invalid shadow quality.\");\n                    return Integer2::k_zero;\n            }\n        }\n    }\n    \n    CS_DEFINE_NAMEDTYPE(DirectionalLightComponent);\n    \n    //------------------------------------------------------------------------------\n    DirectionalLightComponent::DirectionalLightComponent(const Colour& colour, f32 intensity) noexcept\n        : m_colour(colour), m_intensity(intensity)\n    {\n    }\n    \n    //------------------------------------------------------------------------------\n    DirectionalLightComponent::DirectionalLightComponent(ShadowQuality shadowQuality, const Colour& colour, f32 intensity) noexcept\n        : m_colour(colour), m_intensity(intensity)\n    {\n        auto renderCapabilities = Application::Get()->GetSystem<RenderCapabilities>();\n        if (renderCapabilities->IsShadowMappingSupported())\n        {\n            m_shadowMapId = ++g_nextShadowMapId;\n            m_shadowMapResolution = GetShadowMapResolution(shadowQuality);\n            m_shadowTolerance = k_defaultShadowTolerance;\n            \n            SetShadowVolume(k_defaultShadowVolumeWidth, k_defaultShadowVolumeHeight, k_defaultShadowVolumeNear, k_defaultShadowVolumeFar);\n            \n            TryCreateShadowMapTarget();\n        }\n    }\n    \n    //------------------------------------------------------------------------------\n    bool DirectionalLightComponent::IsA(InterfaceIDType interfaceId) const noexcept\n    {\n        return (DirectionalLightComponent::InterfaceID == interfaceId);\n    }\n    \n    //------------------------------------------------------------------------------\n    void DirectionalLightComponent::SetShadowVolume(f32 width, f32 height, f32 near, f32 far) noexcept\n    {\n        m_lightProjection = Matrix4::CreateOrthographicProjectionLH(width, height, near, far);\n    }\n    \n    //------------------------------------------------------------------------------\n    void DirectionalLightComponent::TryCreateShadowMapTarget() noexcept\n    {\n        CS_ASSERT(!m_shadowMap, \"Shadow map already exists.\");\n        CS_ASSERT(!m_shadowMapTarget, \"Shadow map target already exists.\");\n\n        if(m_shadowMapResolution.x > 0 && m_shadowMapResolution.y > 0)\n        {\n            auto mutableShadowMap = Application::Get()->GetResourcePool()->CreateResource<Texture>(\"_DirectionalLightShadowMap\" + ToString(m_shadowMapId));\n            \n            TextureDesc desc(m_shadowMapResolution, ImageFormat::k_Depth16, ImageCompression::k_none, false);\n            mutableShadowMap->Build(nullptr, 0, desc);\n            mutableShadowMap->SetLoadState(Resource::LoadState::k_loaded);\n            \n            m_shadowMap = mutableShadowMap;\n            \n            m_shadowMapTarget = TargetGroup::CreateDepthTargetGroup(m_shadowMap);\n        }\n    }\n    \n    //------------------------------------------------------------------------------\n    void DirectionalLightComponent::TryDestroyShadowMapTarget() noexcept\n    {\n        if (m_shadowMapTarget)\n        {\n            m_shadowMapTarget.reset();\n        }\n        \n        if (m_shadowMap)\n        {\n            auto resourcePool = Application::Get()->GetResourcePool();\n            \n            auto release = m_shadowMap.get();\n            m_shadowMap.reset();\n            resourcePool->Release(release);\n        }\n    }\n    \n    //------------------------------------------------------------------------------\n    void DirectionalLightComponent::OnAddedToScene() noexcept\n    {\n        auto& transform = GetEntity()->GetTransform();\n        \n        m_direction = Vector3::Rotate(Vector3::k_unitPositiveZ, transform.GetWorldOrientation());\n        \n        m_transformChangedConnection = transform.GetTransformChangedEvent().OpenConnection(MakeDelegate(this, &DirectionalLightComponent::OnEntityTransformChanged));\n    }\n    \n    //------------------------------------------------------------------------------\n    void DirectionalLightComponent::OnEntityTransformChanged() noexcept\n    {\n        auto& transform = GetEntity()->GetTransform();\n        \n        m_direction = Vector3::Rotate(Vector3::k_unitPositiveZ, transform.GetWorldOrientation());\n    }\n    \n    //------------------------------------------------------------------------------\n    void DirectionalLightComponent::OnRenderSnapshot(RenderSnapshot& renderSnapshot, IAllocator* frameAllocator) noexcept\n    {\n        if (m_shadowMap)\n        {\n            const auto& transform = GetEntity()->GetTransform();\n            auto worldMatrix = transform.GetWorldTransform();\n            auto orientation = transform.GetWorldOrientation();\n            renderSnapshot.AddDirectionalRenderLight(DirectionalRenderLight(GetFinalColour(), m_direction, worldMatrix, m_lightProjection, orientation, m_shadowTolerance, m_shadowMapTarget->GetRenderTargetGroup()));\n        }\n        else\n        {\n            renderSnapshot.AddDirectionalRenderLight(DirectionalRenderLight(GetFinalColour(), m_direction));\n        }\n    }\n    \n    //------------------------------------------------------------------------------\n    void DirectionalLightComponent::OnRemovedFromScene() noexcept\n    {\n        m_transformChangedConnection.reset();\n    }\n    \n    //------------------------------------------------------------------------------\n    DirectionalLightComponent::~DirectionalLightComponent() noexcept\n    {\n        TryDestroyShadowMapTarget();\n    }\n}\n\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Lighting/DirectionalLightComponent.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_LIGHTING_DIRECTIONALLIGHTCOMPONENT_H_\n#define _CHILLISOURCE_RENDERING_LIGHTING_DIRECTIONALLIGHTCOMPONENT_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Base/Colour.h>\n#include <ChilliSource/Core/Entity/Component.h>\n#include <ChilliSource/Core/Math/Matrix4.h>\n#include <ChilliSource/Rendering/Target/TargetGroup.h>\n\nnamespace ChilliSource\n{\n    /// A component which describes a directional light. While this is in the scene all lit\n    /// objects will have directional lighting applied to it. Optionally, the light can\n    /// cast shadows.\n    ///\n    /// This is not thread-safe and should only be accessed from the main thread.\n    ///\n    class DirectionalLightComponent final : public Component\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(DirectionalLightComponent);\n        \n        /// An enum describing the different levels of shadow quality. The shadow quality affects the\n        /// size of the shadow map texture used: low uses 512 x 512; medium uses 1024 x 1024; and\n        /// high uses 2048 x 2048.\n        ///\n        enum class ShadowQuality\n        {\n            k_low,\n            k_medium,\n            k_high\n        };\n        \n        /// Creates a new directional light which does not cast shadows with the given colour and\n        /// intensity.\n        ///\n        /// @param colour\n        ///     The colour of the ambient light.\n        /// @param intensity\n        ///     (Optional) The intensity of the ambient light. This defaults to 1.0.\n        ///\n        DirectionalLightComponent(const Colour& colour, f32 intensity = 1.0f) noexcept;\n        \n        /// Creates a new directional light which cast shadows with the given colour\n        /// and intensity.\n        ///\n        /// @param colour\n        ///     The colour of the ambient light.\n        /// @param intensity\n        ///     (Optional) The intensity of the ambient light. This defaults to 1.0.\n        ///\n        DirectionalLightComponent(ShadowQuality shadowQuality, const Colour& colour, f32 intensity = 1.0f) noexcept;\n        \n        /// Allows querying of whether or not this system implements the interface described by the\n        /// given interface Id. Typically this is not called directly as the templated equivalent\n        /// IsA<Interface>() is preferred.\n        ///\n        /// @param interfaceId\n        ///     The Id of the interface.\n        ///\n        /// @return Whether or not the interface is implemented.\n        ///\n        bool IsA(InterfaceIDType interfaceId) const noexcept override;\n        \n        /// @return The colour of the directional light.\n        ///\n        void SetColour(const Colour& colour) noexcept { m_colour = colour; }\n        \n        /// @return The intensity of the directional light.\n        ///\n        void SetIntensity(f32 intensity) noexcept { m_intensity = intensity; }\n        \n        /// Sets the shadow tolerance factor which affects the distance an object must be behind another\n        /// object to be considered in shadow. Too small a value will result in shadow banding, however\n        /// too large a value will result in \"peter panning\", where shadows become detatched from their\n        /// casting object.\n        ///\n        /// @param tolerance\n        ///     The shadow tolerance.\n        ///\n        void SetShadowTolerance(f32 tolerance) noexcept { m_shadowTolerance = tolerance; }\n        \n        /// Sets the shadow volume; the box around the light in which shadows can be cast. The box\n        /// is oriented to the direction of the light, with near and far dictating how near and far\n        /// along the light direction shadows can be cast, and with and height describing distance\n        /// perpendicular to the light direction.\n        ///\n        /// A smaller shadow volume results in higher quality shadows, but also a smaller area with\n        /// shadows cast.\n        ///\n        /// @param width\n        ///     The width of the shadow volume.\n        /// @param height\n        ///     The height of the shadow volume.\n        /// @param near\n        ///     The near plane of the shadow volume.\n        /// @param far\n        ///     The far plane of the shadow volume.\n        ///\n        void SetShadowVolume(f32 width, f32 height, f32 near, f32 far) noexcept;\n        \n        /// @return The colour of the directional light.\n        ///\n        const Colour& GetColour() const noexcept { return m_colour; }\n        \n        /// @return The intensity of the directional light.\n        ///\n        f32 GetIntensity() const noexcept { return m_intensity; }\n        \n        /// @return The colour of the directional light with the intesity applied to it.\n        ///\n        Colour GetFinalColour() const noexcept { return m_colour * m_intensity; }\n        \n        /// @return The shadow tolerance factor which affects the distance an object must be behind\n        ///     another object to be considered in shadow. Too small a value will result in shadow\n        ///     banding, however too large a value will result in \"peter panning\", where shadows\n        ///     become detatched from their casting object.\n        ///\n        f32 GetShadowTolerance() const noexcept { return m_shadowTolerance; }\n        \n        /// Cleans up shadow textures if required.\n        ///\n        ~DirectionalLightComponent() noexcept;\n        \n    private:\n        /// Create the shadow map target and texture if required.\n        ///\n        void TryCreateShadowMapTarget() noexcept;\n        \n        /// Destroys the shadow map target and texture if required.\n        ///\n        void TryDestroyShadowMapTarget() noexcept;\n        \n        /// Triggered when either the component is attached to an entity which is already in the\n        /// scene or when the owning entity is added to the scene.\n        ///\n        void OnAddedToScene() noexcept override;\n        \n        /// Triggered when the entity transform changes, updating the light view matrix.\n        ///\n        void OnEntityTransformChanged() noexcept;\n        \n        /// This is called during the render snapshot stage of the render pipeline to collect a copy of\n        /// the current state of the renderable portion of the scene. This will add all relevant light\n        /// data to this snapshot.\n        ///\n        /// @param renderSnapshot - Add anything to this that must be captured for rendering\n        /// @param frameAllocator - Allocate any memory required for rendering from this\n        ///\n        /// @return renderSnapshot\n        ///     The snapshot that the light data will be added to.\n        ///\n        void OnRenderSnapshot(RenderSnapshot& renderSnapshot, IAllocator* frameAllocator) noexcept override;\n        \n        /// Triggered when either the component is removed from an entity which is currently in the\n        /// scene, or the owning entity is removed from the scene.\n        ///\n        void OnRemovedFromScene() noexcept override;\n        \n        Colour m_colour;\n        f32 m_intensity;\n        f32 m_shadowTolerance = 0.0f;\n        \n        Vector3 m_direction;\n        Matrix4 m_lightProjection;\n        Integer2 m_shadowMapResolution;\n        s32 m_shadowMapId = -1;\n        TextureCSPtr m_shadowMap;\n        TargetGroupUPtr m_shadowMapTarget = nullptr;\n        \n        EventConnectionUPtr m_transformChangedConnection;\n    };\n}\n\n#endif"
  },
  {
    "path": "Source/ChilliSource/Rendering/Lighting/DirectionalRenderLight.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Lighting/DirectionalRenderLight.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    DirectionalRenderLight::DirectionalRenderLight() noexcept\n        : m_colour(Colour::k_black), m_direction(Vector3::k_unitNegativeY)\n    {\n    }\n    \n    //------------------------------------------------------------------------------\n    DirectionalRenderLight::DirectionalRenderLight(const Colour& colour, const Vector3& direction) noexcept\n        : m_colour(colour), m_direction(direction)\n    {\n    }\n    \n    //------------------------------------------------------------------------------\n    DirectionalRenderLight::DirectionalRenderLight(const Colour& colour, const Vector3& direction, const Matrix4& lightWorldMatrix, const Matrix4& lightProjectionMatrix, const Quaternion& lightOrientation,\n                                                   f32 shadowTolerance, const RenderTargetGroup* shadowMapTarget) noexcept\n        : m_colour(colour), m_direction(direction), m_lightWorldMatrix(lightWorldMatrix), m_lightProjectionMatrix(lightProjectionMatrix), m_lightOrientation(lightOrientation),\n          m_shadowTolerance(shadowTolerance), m_shadowMapTarget(shadowMapTarget)\n    {\n        CS_ASSERT(m_shadowMapTarget, \"Shadow map target cannot be null.\");\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Lighting/DirectionalRenderLight.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_LIGHTING_RENDERDIRECTIONALLIGHT_H_\n#define _CHILLISOURCE_RENDERING_LIGHTING_RENDERDIRECTIONALLIGHT_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Base/Colour.h>\n#include <ChilliSource/Core/Math/Matrix4.h>\n#include <ChilliSource/Core/Math/Quaternion.h>\n#include <ChilliSource/Core/Math/Vector3.h>\n\nnamespace ChilliSource\n{\n    /// A standard-layout container for data the renderer needs which pertains to a single\n    /// direction light, such as the colour and direction.\n    ///\n    class DirectionalRenderLight final\n    {\n    public:\n        \n        /// Creates a new instance of the container with default black colour and v-down direction\n        /// with no shadow map.\n        ///\n        DirectionalRenderLight() noexcept;\n        \n        /// Creates a new instance of the container with the given light colour and direction\n        /// with no shadow map.\n        ///\n        /// @param colour\n        ///     The colour of the light.\n        /// @param direction\n        ///     The direction of the light.\n        ///\n        DirectionalRenderLight(const Colour& colour, const Vector3& direction) noexcept;\n        \n        /// Creates a new instance of the container with the given light colour and direction\n        /// and shadow map data.\n        ///\n        /// @param colour\n        ///     The colour of the light.\n        /// @param direction\n        ///     The direction of the light.\n        /// @param lightWorldMatrix\n        ///     The light world matrix, required for rendering the shadow map.\n        /// @param lightProjectionMatrix\n        ///     The light projection matrix, required for rendering the shadow map.\n        /// @param lightOrientation\n        ///     The light orientation, required for rendering the shadow map.\n        /// @param shadowTolerance\n        ///     The tolerence used to judge if an object is in shadow.\n        /// @param shadowMapTarget\n        ///     The render target group which should be used for the shadow map.\n        ///\n        DirectionalRenderLight(const Colour& colour, const Vector3& direction, const Matrix4& lightWorldMatrix, const Matrix4& lightProjectionMatrix, const Quaternion& lightOrientation,\n                               f32 shadowTolerance, const RenderTargetGroup* shadowMapTarget) noexcept;\n        \n        /// @return The colour of the light.\n        ///\n        const Colour& GetColour() const noexcept { return m_colour; }\n        \n        /// @return The direction of the light.\n        ///\n        const Vector3& GetDirection() const noexcept { return m_direction; }\n        \n        /// @return The light world matrix, required for rendering the shadow map.\n        ///\n        const Matrix4& GetLightWorldMatrix() const noexcept { return m_lightWorldMatrix; }\n        \n        /// @return The light projection matrix, required for rendering the shadow map.\n        ///\n        const Matrix4& GetLightProjectionMatrix() const noexcept { return m_lightProjectionMatrix; }\n        \n        /// @return The light orientation, required for rendering the shadow map.\n        ///\n        const Quaternion& GetLightOrientation() const noexcept { return m_lightOrientation; }\n        \n        /// @return The tolerence used to judge if an object is in shadow.\n        ///\n        f32 GetShadowTolerance() const noexcept { return m_shadowTolerance; }\n        \n        /// @return The render texture group which should be used for the shadow map. Will be null if there is\n        ///     no shadow map.\n        ///\n        const RenderTargetGroup* GetShadowMapTarget() const noexcept { return m_shadowMapTarget; }\n        \n    private:\n        Colour m_colour;\n        Vector3 m_direction;\n        Matrix4 m_lightWorldMatrix;\n        Matrix4 m_lightProjectionMatrix;\n        Quaternion m_lightOrientation;\n        f32 m_shadowTolerance = 0.0f;\n        const RenderTargetGroup* m_shadowMapTarget = nullptr;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Lighting/PointLightComponent.cpp",
    "content": "//\n//  PointLightComponent.cpp\n//  ChilliSource\n//  Created by Scott Downie on 31/01/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Lighting/PointLightComponent.h>\n\n#include <ChilliSource/Core/Delegate/MakeDelegate.h>\n#include <ChilliSource/Core/Entity/Entity.h>\n#include <ChilliSource/Rendering/Base/RenderSnapshot.h>\n#include <ChilliSource/Rendering/Lighting/PointRenderLight.h>\n\n#include <limits>\n\nnamespace ChilliSource\n{\n    namespace\n    {\n        constexpr f32 m_defaultMinLightInfluence = 0.05f;\n    }\n    \n    CS_DEFINE_NAMEDTYPE(PointLightComponent);\n\n    //------------------------------------------------------------------------------\n    PointLightComponent::PointLightComponent(const Colour& colour, f32 radius, f32 intensity) noexcept\n        : m_colour(colour), m_intensity(intensity)\n    {\n        SetRadius(radius);\n        SetMinLightInfluence(m_defaultMinLightInfluence);\n    }\n    \n    //------------------------------------------------------------------------------\n    bool PointLightComponent::IsA(InterfaceIDType interfaceId) const noexcept\n    {\n        return (PointLightComponent::InterfaceID == interfaceId);\n    }\n    \n    //------------------------------------------------------------------------------\n    void PointLightComponent::SetRadius(f32 radius) noexcept\n    {\n        CS_ASSERT(radius > 0.0f, \"Point light radius must be greater than zero.\");\n        \n        m_radius = radius;\n        \n        m_attenuation.x = 1;\n        m_attenuation.y = 2 / m_radius;\n        m_attenuation.z = 1 / (m_radius * m_radius);\n        \n        CalcRangeOfInfluence();\n    }\n    \n    //------------------------------------------------------------------------------\n    void PointLightComponent::SetMinLightInfluence(f32 minLightInfluence) noexcept\n    {\n        CS_ASSERT(minLightInfluence > 0.0f, \"Point light min light influence must be greater than zero.\");\n        \n        m_minLightInfluence = minLightInfluence;\n        \n        CalcRangeOfInfluence();\n    }\n    \n    //------------------------------------------------------------------------------\n    void PointLightComponent::CalcRangeOfInfluence() noexcept\n    {\n        m_rangeOfInfluence = m_radius * (sqrt(GetIntensity() / m_minLightInfluence) + 1);\n    }\n    \n    //------------------------------------------------------------------------------\n    void PointLightComponent::OnAddedToScene() noexcept\n    {\n        auto& transform = GetEntity()->GetTransform();\n        \n        m_lightPosition = transform.GetWorldPosition();\n        \n        m_transformChangedConnection = transform.GetTransformChangedEvent().OpenConnection(MakeDelegate(this, &PointLightComponent::OnEntityTransformChanged));\n    }\n    \n    //------------------------------------------------------------------------------\n    void PointLightComponent::OnEntityTransformChanged() noexcept\n    {\n        m_lightPosition = GetEntity()->GetTransform().GetWorldPosition();\n    }\n    \n    //------------------------------------------------------------------------------\n    void PointLightComponent::OnRenderSnapshot(RenderSnapshot& renderSnapshot, IAllocator* frameAllocator) noexcept\n    {\n        renderSnapshot.AddPointRenderLight(PointRenderLight(GetFinalColour(), m_lightPosition, m_attenuation, m_rangeOfInfluence));\n    }\n    \n    //------------------------------------------------------------------------------\n    void PointLightComponent::OnRemovedFromScene() noexcept\n    {\n        m_transformChangedConnection.reset();\n    }\n}\n\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Lighting/PointLightComponent.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_LIGHTING_POINTLIGHTCOMPONENT_H_\n#define _CHILLISOURCE_RENDERING_LIGHTING_POINTLIGHTCOMPONENT_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Base/Colour.h>\n#include <ChilliSource/Core/Math/Vector3.h>\n#include <ChilliSource/Core/Entity/Component.h>\n\nnamespace ChilliSource\n{\n    /// A component which describes a directional light. While this is in the scene all lit\n    /// objects in range will have point lighting applied to it.\n    ///\n    /// A point light is described in terms of a radius and a minimum light influence which\n    /// are used to calculate the light attenuation and range of influence. Where d is\n    /// the distance from the fragment to the light, the formulae for these are as follows:\n    ///\n    ///   attenuationConstant = 1\n    ///   attenuationLinear = 2 / radius\n    ///   attenuationQuatratic = 1 / (radius * radius)\n    ///   attenuation = 1 / (attenuationConstant + attenuationLinear * d + attenuationQuatratic * d * d)\n    ///\n    /// rangeOfInfluence = radius * (sqrt(intensity / minLightInfluence) + 1)\n    ///\n    /// This is not thread-safe and should only be accessed from the main thread.\n    ///\n    class PointLightComponent final : public Component\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(PointLightComponent);\n        \n        /// Creates a new point light with the given colour, radius and intensity.\n        ///\n        /// @param colour\n        ///     The colour of the point light.\n        /// @param radius\n        ///     The radius of the point light.\n        /// @param intensity\n        ///     (Optional) The intensity of the ambient light. This defaults to 1.0.\n        ///\n        PointLightComponent(const Colour& colour, f32 radius, f32 intensity = 1.0f) noexcept;\n\n        /// Allows querying of whether or not this system implements the interface described by the\n        /// given interface Id. Typically this is not called directly as the templated equivalent\n        /// IsA<Interface>() is preferred.\n        ///\n        /// @param interfaceId\n        ///     The Id of the interface.\n        ///\n        /// @return Whether or not the interface is implemented.\n        ///\n        bool IsA(InterfaceIDType interfaceId) const noexcept override;\n        \n        /// @return The colour of the point light.\n        ///\n        void SetColour(const Colour& colour) noexcept { m_colour = colour; }\n        \n        /// @return The intensity of the point light.\n        ///\n        void SetIntensity(f32 intensity) noexcept { m_intensity = intensity; }\n        \n        /// Sets the radius of the point light. See the class documentation for more information.\n        ///\n        /// @param radius\n        ///     The lights radius.\n        ///\n        void SetRadius(f32 radius) noexcept;\n        \n        /// Sets the minimum light influence. See the class documentation for more information.\n        ///\n        /// @param minLightInfluence\n        ///     The minimum light influence.\n        ///\n        void SetMinLightInfluence(f32 minLightInfluence) noexcept;\n        \n        /// @return The colour of the point light.\n        ///\n        const Colour& GetColour() const noexcept { return m_colour; }\n        \n        /// @return The intensity of the point light.\n        ///\n        f32 GetIntensity() const noexcept { return m_intensity; }\n        \n        /// @return The colour of the point light with the intesity applied to it.\n        ///\n        Colour GetFinalColour() const noexcept { return m_colour * m_intensity; }\n        \n        /// @return The light radius.\n        ///\n        f32 GetRadius() const noexcept { return m_radius; };\n        \n        /// @return The min light influence.\n        ///\n        f32 GetMinLightInfluence() const noexcept { return m_minLightInfluence; };\n\n        /// @return The range in which the light has influence on objects. This is calculated based on\n        ///     the Min Light Influence and the radius of the light.\n        ///\n        f32 GetRangeOfInfluence() const noexcept { return m_rangeOfInfluence; };\n\n    private:\n        /// Calculates the range of influence of the light based on the formula described in the\n        /// class documentation.\n        ///\n        void CalcRangeOfInfluence() noexcept;\n        \n        /// Triggered when either the component is attached to an entity which is already in the\n        /// scene or when the owning entity is added to the scene.\n        ///\n        void OnAddedToScene() noexcept override;\n        \n        /// Triggered when the entity transform changes, updating the light view matrix.\n        ///\n        void OnEntityTransformChanged() noexcept;\n        \n        /// This is called during the render snapshot stage of the render pipeline to collect a copy of\n        /// the current state of the renderable portion of the scene. This will add all relevant light\n        /// data to this snapshot.\n        ///\n        /// @param renderSnapshot\n        ///     The snapshot that the light data will be added to.\n        /// @param frameAllocator\n        ///     Allocate any memory for rendering this frame from here\n        ///\n        void OnRenderSnapshot(RenderSnapshot& renderSnapshot, IAllocator* frameAllocator) noexcept override;\n        \n        /// Triggered when either the component is removed from an entity which is currently in the\n        /// scene, or the owning entity is removed from the scene.\n        ///\n        void OnRemovedFromScene() noexcept override;\n        \n        Colour m_colour;\n        f32 m_intensity;\n        f32 m_radius;\n        f32 m_minLightInfluence;\n        \n        Vector3 m_lightPosition;\n        f32 m_rangeOfInfluence = 0.0f;\n        Vector3 m_attenuation;\n        \n        EventConnectionUPtr m_transformChangedConnection;\n    };\n}\n\n#endif"
  },
  {
    "path": "Source/ChilliSource/Rendering/Lighting/PointRenderLight.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Lighting/PointRenderLight.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    PointRenderLight::PointRenderLight() noexcept\n        : m_colour(Colour::k_black), m_position(Vector3::k_zero), m_attenuation(1.0f, 0.0f, 0.0f), m_rangeOfInfluence(0.0f)\n    {\n    }\n    //------------------------------------------------------------------------------\n    PointRenderLight::PointRenderLight(const Colour& colour, const Vector3& position, const Vector3& attenuation, f32 rangeOfInfluence) noexcept\n        : m_colour(colour), m_position(position), m_attenuation(attenuation), m_rangeOfInfluence(rangeOfInfluence)\n    {\n    }\n}"
  },
  {
    "path": "Source/ChilliSource/Rendering/Lighting/PointRenderLight.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_LIGHTING_RENDERPOINTLIGHT_H_\n#define _CHILLISOURCE_RENDERING_LIGHTING_RENDERPOINTLIGHT_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Base/Colour.h>\n#include <ChilliSource/Core/Math/Vector3.h>\n\nnamespace ChilliSource\n{\n    /// A standard-layout container for data the renderer needs which pertains to a single\n    /// point light, such as the colour and position.\n    ///\n    class PointRenderLight final\n    {\n    public:\n        \n        /// Creates a new instance of the container with default black colour with\n        /// position and attenuation zeroed.\n        ///\n        PointRenderLight() noexcept;\n        \n        /// Creates a new instance of the container with the given light colour and position.\n        ///\n        /// @param colour\n        ///     The colour of the light.\n        /// @param position\n        ///     The position of the light.\n        /// @param attenuation\n        ///     The attenuation of the light.\n        /// @param rangeOfInfluence\n        ///     The range of influence of the light.\n        ///\n        PointRenderLight(const Colour& colour, const Vector3& position, const Vector3& attenuation, f32 rangeOfInfluence) noexcept;\n        \n        /// @return The colour of the light.\n        ///\n        const Colour& GetColour() const noexcept { return m_colour; }\n        \n        /// @return The position of the light.\n        ///\n        const Vector3& GetPosition() const noexcept { return m_position; }\n        \n        /// @return The attenuation of the light.\n        ///\n        const Vector3& GetAttenuation() const noexcept { return m_attenuation; }\n        \n        /// @return The range of influence of the light.\n        ///\n        f32 GetRangeOfInfluence() const noexcept { return m_rangeOfInfluence; }\n        \n    private:\n        Colour m_colour;\n        Vector3 m_position;\n        Vector3 m_attenuation;\n        f32 m_rangeOfInfluence;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Lighting.h",
    "content": "//\n//  Lighting.h\n//  ChilliSource\n//  Created by Ian Copland on 07/07/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n\n#ifndef _CHILLISOURCE_RENDERING_LIGHTING_H_\n#define _CHILLISOURCE_RENDERING_LIGHTING_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Rendering/Lighting/AmbientLightComponent.h>\n#include <ChilliSource/Rendering/Lighting/DirectionalLightComponent.h>\n#include <ChilliSource/Rendering/Lighting/PointLightComponent.h>\n#include <ChilliSource/Rendering/Lighting/AmbientRenderLight.h>\n#include <ChilliSource/Rendering/Lighting/DirectionalRenderLight.h>\n#include <ChilliSource/Rendering/Lighting/PointRenderLight.h>\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Material/ForwardRenderMaterialGroupManager.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n#include <ChilliSource/Rendering/Material/ForwardRenderMaterialGroupManager.h>\n\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/Memory/UniquePtr.h>\n#include <ChilliSource/Core/Resource/ResourcePool.h>\n#include <ChilliSource/Rendering/Base/BlendMode.h>\n#include <ChilliSource/Rendering/Base/CullFace.h>\n#include <ChilliSource/Rendering/Base/RenderPasses.h>\n#include <ChilliSource/Rendering/Base/RenderCapabilities.h>\n#include <ChilliSource/Rendering/Base/StencilOp.h>\n#include <ChilliSource/Rendering/Base/TestFunc.h>\n#include <ChilliSource/Rendering/Material/MaterialShadingType.h>\n#include <ChilliSource/Rendering/Shader/Shader.h>\n\nnamespace ChilliSource\n{\n    namespace\n    {\n        constexpr u32 k_materialPoolSize = 150;\n        constexpr u32 k_groupPoolSize = 100;\n        \n        /// Creates a new unlit render material with the given settings.\n        ///\n        /// @param renderMaterialPool\n        ///     Allocator from which to allocate\n        /// @param shader\n        ///     The shader that should be used.\n        /// @param renderTexture\n        ///     The render texture.\n        /// @param isTransparencyEnabled\n        ///     Whether or not transparency is enabled.\n        /// @param isColourWriteEnabled\n        ///     Whether or not colour write is enabled.\n        /// @param isDepthWriteEnabled\n        ///     Whether or not depth write is enabled.\n        /// @param isDepthTestEnabled\n        ///     Whether or not the depth test will be performed.\n        /// @param isFaceCullingEnabled\n        ///     Whether or not face culling will be performed.\n        /// @param isStencilTestEnabled\n        ///     Whether or not to perform stencil testing\n        /// @param depthTestFunc\n        ///     Function that determines whether a depth test comparison should pass or fail\n        /// @param sourceBlendMode\n        ///     The source blend mode. This only applies if transparency is enabled.\n        /// @param destinationBlendMode\n        ///     The destination blend mode. This only applies if transparency is enabled.\n        /// @param stencilFailOp\n        ///     Op applied if stencil test fails\n        /// @param stencilDepthFailOp\n        ///     Op applied if stencil depth test fails\n        /// @param stencilPassOp\n        ///     Op applied if stencil and depth tests pass\n        /// @param stencilTestFunc\n        ///     Function that determines whether a stencil test comparison should pass or fail\n        /// @param stencilRef\n        ///     Value used as comparison for stencil tests\n        /// @param stencilMask\n        ///     Value ANDed to with the comparison and stencil value\n        /// @param cullFace\n        ///     The face which should be called. This only applies if face culling is enabled.\n        /// @param ambientColour\n        ///     The ambient colour.\n        /// @param emissiveColour\n        ///     The ambient colour.\n        ///\n        /// @return The new RenderMaterial.\n        ///\n        UniquePtr<RenderMaterial> CreateUnlit(IAllocator& renderMaterialPool, const ShaderCSPtr& shader, const RenderTexture* renderTexture,\n                                       bool isTransparencyEnabled, bool isColourWriteEnabled, bool isDepthWriteEnabled, bool isDepthTestEnabled, bool isFaceCullingEnabled, bool isStencilTestEnabled,\n                                       TestFunc depthTestFunc,\n                                       BlendMode sourceBlendMode, BlendMode destinationBlendMode,\n                                       StencilOp stencilFailOp, StencilOp stencilDepthFailOp, StencilOp stencilPassOp, TestFunc stencilTestFunc, s32 stencilRef, u32 stencilMask,\n                                       CullFace cullFace, const Colour& emissiveColour, const Colour& ambientColour) noexcept\n        {\n            auto renderShader = shader->GetRenderShader();\n            std::vector<const RenderTexture*> renderTextures { renderTexture };\n            std::vector<const RenderTexture*> renderCubemaps;\n            auto diffuseColour = Colour::k_black;\n            auto specularColour = Colour::k_black;\n            RenderShaderVariablesUPtr renderShaderVariables = nullptr;\n            \n            return MakeUnique<RenderMaterial>(renderMaterialPool, renderShader, std::move(renderTextures), std::move(renderCubemaps), isTransparencyEnabled, isColourWriteEnabled, isDepthWriteEnabled, isDepthTestEnabled, isFaceCullingEnabled, isStencilTestEnabled,\n                                                         depthTestFunc,\n                                                         sourceBlendMode, destinationBlendMode,\n                                                         stencilFailOp, stencilDepthFailOp, stencilPassOp, stencilTestFunc, stencilRef, stencilMask,\n                                                         cullFace, emissiveColour, ambientColour, diffuseColour, specularColour, std::move(renderShaderVariables));\n        }\n        \n        /// Creates a new shadow map RenderMaterial with the given shader.\n        ///\n        /// @param renderMaterialPool\n        ///     Allocator from which to allocate\n        /// @param shader\n        ///     The shader that should be used.\n        ///\n        /// @return The new RenderMaterial.\n        ///\n        UniquePtr<RenderMaterial> CreateShadowMap(IAllocator& renderMaterialPool, const ShaderCSPtr& shader) noexcept\n        {\n            auto renderShader = shader->GetRenderShader();\n            std::vector<const RenderTexture*> renderTextures;\n            std::vector<const RenderTexture*> renderCubemaps;\n            auto isTransparencyEnabled = false;\n            auto isColourWriteEnabled = false;\n            auto isDepthWriteEnabled = true;\n            auto isDepthTestEnabled = true;\n            auto isFaceCullingEnabled = true;\n            auto isStencilTestEnabled = false;\n            auto depthTestFunc = TestFunc::k_lessEqual;\n            auto sourceBlendMode = BlendMode::k_one;\n            auto destinationBlendMode = BlendMode::k_one;\n            auto stencilFailOp = StencilOp::k_keep;\n            auto stencilDepthFailOp = StencilOp::k_keep;\n            auto stencilPassOp = StencilOp::k_keep;\n            auto stencilTestFunc = TestFunc::k_always;\n            auto stencilRef = 1;\n            auto stencilMask = 0xff;\n            auto cullFace = CullFace::k_front;\n            auto emissiveColour = Colour::k_black;\n            auto ambientColour = Colour::k_black;\n            auto diffuseColour = Colour::k_black;\n            auto specularColour = Colour::k_black;\n            RenderShaderVariablesUPtr renderShaderVariables = nullptr;\n            \n            return MakeUnique<RenderMaterial>(renderMaterialPool, renderShader, std::move(renderTextures), std::move(renderCubemaps), isTransparencyEnabled, isColourWriteEnabled, isDepthWriteEnabled, isDepthTestEnabled, isFaceCullingEnabled, isStencilTestEnabled,\n                                                         depthTestFunc,\n                                                         sourceBlendMode, destinationBlendMode,\n                                                         stencilFailOp, stencilDepthFailOp, stencilPassOp, stencilTestFunc, stencilRef, stencilMask,\n                                                         cullFace, emissiveColour, ambientColour, diffuseColour, specularColour, std::move(renderShaderVariables));\n        }\n        \n        /// Creates a new skybox pass RenderMaterial with the given info.\n        ///\n        /// @param renderMaterialPool\n        ///     Allocator from which to allocate\n        /// @param renderCubemap\n        ///     The render cubemap.\n        ///\n        /// @return The new RenderMaterial.\n        ///\n        UniquePtr<RenderMaterial> CreateSkybox(IAllocator& renderMaterialPool, const ShaderCSPtr& shader, const RenderTexture* renderCubemap) noexcept\n        {\n            auto renderShader = shader->GetRenderShader();\n            std::vector<const RenderTexture*> renderTextures;\n            std::vector<const RenderTexture*> renderCubemaps { renderCubemap };\n            auto isTransparencyEnabled = false;\n            auto isColourWriteEnabled = true;\n            auto isDepthWriteEnabled = false;\n            auto isDepthTestEnabled = true;\n            auto isFaceCullingEnabled = true;\n            auto isStencilTestEnabled = false;\n            auto depthTestFunc = TestFunc::k_lessEqual;\n            auto sourceBlendMode = BlendMode::k_one;\n            auto destinationBlendMode = BlendMode::k_oneMinusSourceAlpha;\n            auto stencilFailOp = StencilOp::k_keep;\n            auto stencilDepthFailOp = StencilOp::k_keep;\n            auto stencilPassOp = StencilOp::k_keep;\n            auto stencilTestFunc = TestFunc::k_always;\n            auto stencilRef = 1;\n            auto stencilMask = 0xff;\n            auto cullFace = CullFace::k_back;\n            auto ambientColour = Colour::k_black;\n            auto emissiveColour = Colour::k_black;\n            auto diffuseColour = Colour::k_black;\n            auto specularColour = Colour::k_black;\n            RenderShaderVariablesUPtr renderShaderVariables = nullptr;\n            \n            return MakeUnique<RenderMaterial>(renderMaterialPool, renderShader, std::move(renderTextures), std::move(renderCubemaps), isTransparencyEnabled, isColourWriteEnabled, isDepthWriteEnabled, isDepthTestEnabled, isFaceCullingEnabled, isStencilTestEnabled,\n                                                         depthTestFunc,\n                                                         sourceBlendMode, destinationBlendMode,\n                                                         stencilFailOp, stencilDepthFailOp, stencilPassOp, stencilTestFunc, stencilRef, stencilMask,\n                                                         cullFace, emissiveColour, ambientColour, diffuseColour, specularColour, std::move(renderShaderVariables));\n        }\n        \n        /// Creates a new base pass blinn RenderMaterial with the given info.\n        ///\n        /// @param renderMaterialPool\n        ///     Allocator from which to allocate\n        /// @param renderTexture\n        ///     The render texture.\n        /// @param ambientColour\n        ///     The ambient colour.\n        /// @param emissiveColour\n        ///     The ambient colour.\n        /// @param diffuseColour\n        ///     The diffuse colour.\n        /// @param specularColour\n        ///     The specular colour.\n        ///\n        /// @return The new RenderMaterial.\n        ///\n        UniquePtr<RenderMaterial> CreateBlinnBase(IAllocator& renderMaterialPool, const ShaderCSPtr& shader, const RenderTexture* renderTexture, const Colour& emissiveColour, const Colour& ambientColour) noexcept\n        {\n            auto renderShader = shader->GetRenderShader();\n            std::vector<const RenderTexture*> renderTextures { renderTexture };\n            std::vector<const RenderTexture*> renderCubemaps;\n            auto isTransparencyEnabled = false;\n            auto isColourWriteEnabled = true;\n            auto isDepthWriteEnabled = true;\n            auto isDepthTestEnabled = true;\n            auto isFaceCullingEnabled = true;\n            auto isStencilTestEnabled = false;\n            auto depthTestFunc = TestFunc::k_lessEqual;\n            auto sourceBlendMode = BlendMode::k_one;\n            auto destinationBlendMode = BlendMode::k_oneMinusSourceAlpha;\n            auto stencilFailOp = StencilOp::k_keep;\n            auto stencilDepthFailOp = StencilOp::k_keep;\n            auto stencilPassOp = StencilOp::k_keep;\n            auto stencilTestFunc = TestFunc::k_always;\n            auto stencilRef = 1;\n            auto stencilMask = 0xff;\n            auto cullFace = CullFace::k_back;\n            auto diffuseColour = Colour::k_black;\n            auto specularColour = Colour::k_black;\n            RenderShaderVariablesUPtr renderShaderVariables = nullptr;\n            \n            return MakeUnique<RenderMaterial>(renderMaterialPool, renderShader, std::move(renderTextures), std::move(renderCubemaps), isTransparencyEnabled, isColourWriteEnabled, isDepthWriteEnabled, isDepthTestEnabled, isFaceCullingEnabled, isStencilTestEnabled,\n                                                         depthTestFunc,\n                                                         sourceBlendMode, destinationBlendMode,\n                                                         stencilFailOp, stencilDepthFailOp, stencilPassOp, stencilTestFunc, stencilRef, stencilMask,\n                                                         cullFace, emissiveColour, ambientColour, diffuseColour, specularColour, std::move(renderShaderVariables));\n        }\n        \n        /// Creates a new light pass (directional or point) blinn RenderMaterial with the given info.\n        ///\n        /// @param renderMaterialPool\n        ///     Allocator from which to allocate\n        /// @param renderTexture\n        ///     The render texture.\n        /// @param ambientColour\n        ///     The ambient colour.\n        /// @param emissiveColour\n        ///     The ambient colour.\n        /// @param diffuseColour\n        ///     The diffuse colour.\n        /// @param specularColour\n        ///     The specular colour.\n        ///\n        /// @return The new RenderMaterial.\n        ///\n        UniquePtr<RenderMaterial> CreateBlinnLight(IAllocator& renderMaterialPool, const ShaderCSPtr& shader, const RenderTexture* renderTexture, const Colour& diffuseColour, const Colour& specularColour) noexcept\n        {\n            auto renderShader = shader->GetRenderShader();\n            std::vector<const RenderTexture*> renderTextures { renderTexture };\n            std::vector<const RenderTexture*> renderCubemaps;\n            auto isTransparencyEnabled = true;\n            auto isColourWriteEnabled = true;\n            auto isDepthWriteEnabled = false;\n            auto isDepthTestEnabled = true;\n            auto isFaceCullingEnabled = true;\n            auto isStencilTestEnabled = false;\n            auto depthTestFunc = TestFunc::k_lessEqual;\n            auto sourceBlendMode = BlendMode::k_one;\n            auto destinationBlendMode = BlendMode::k_one;\n            auto stencilFailOp = StencilOp::k_keep;\n            auto stencilDepthFailOp = StencilOp::k_keep;\n            auto stencilPassOp = StencilOp::k_keep;\n            auto stencilTestFunc = TestFunc::k_always;\n            auto stencilRef = 1;\n            auto stencilMask = 0xff;\n            auto cullFace = CullFace::k_back;\n            auto emissiveColour = Colour::k_black;\n            auto ambientColour = Colour::k_black;\n            RenderShaderVariablesUPtr renderShaderVariables = nullptr;\n            \n            return MakeUnique<RenderMaterial>(renderMaterialPool, renderShader, std::move(renderTextures), std::move(renderCubemaps), isTransparencyEnabled, isColourWriteEnabled, isDepthWriteEnabled, isDepthTestEnabled, isFaceCullingEnabled, isStencilTestEnabled,\n                                                         depthTestFunc,\n                                                         sourceBlendMode, destinationBlendMode,\n                                                         stencilFailOp, stencilDepthFailOp, stencilPassOp, stencilTestFunc, stencilRef, stencilMask,\n                                                         cullFace, emissiveColour, ambientColour, diffuseColour, specularColour, std::move(renderShaderVariables));\n        }\n    }\n    \n    CS_DEFINE_NAMEDTYPE(ForwardRenderMaterialGroupManager);\n    \n    //------------------------------------------------------------------------------\n    ForwardRenderMaterialGroupManager::ForwardRenderMaterialGroupManager()\n    : m_renderMaterialPool(k_materialPoolSize, ObjectPoolAllocatorLimitPolicy::k_expand), m_renderMaterialGroupPool(k_groupPoolSize, ObjectPoolAllocatorLimitPolicy::k_expand)\n    {\n        \n    }\n    \n    //------------------------------------------------------------------------------\n    bool ForwardRenderMaterialGroupManager::IsA(InterfaceIDType interfaceId) const noexcept\n    {\n        return (RenderMaterialGroupManager::InterfaceID == interfaceId || ForwardRenderMaterialGroupManager::InterfaceID == interfaceId);\n    }\n    \n    //------------------------------------------------------------------------------\n    UniquePtr<RenderMaterialGroup> ForwardRenderMaterialGroupManager::CreateUnlitRenderMaterialGroup(const RenderTexture* renderTexture,\n                                                                                                 bool isTransparencyEnabled, bool isColourWriteEnabled, bool isDepthWriteEnabled, bool isDepthTestEnabled, bool isFaceCullingEnabled, bool isStencilTestEnabled,\n                                                                                                 TestFunc depthTestFunc,\n                                                                                                 BlendMode sourceBlendMode, BlendMode destinationBlendMode,\n                                                                                                 StencilOp stencilFailOp, StencilOp stencilDepthFailOp, StencilOp stencilPassOp, TestFunc stencilTestFunc, s32 stencilRef, u32 stencilMask,\n                                                                                                 CullFace cullFace, const Colour& emissiveColour, const Colour& ambientColour) noexcept\n    {\n        std::array<const RenderMaterial*, RenderMaterialGroup::k_numMaterialSlots> spriteRenderMaterials {};\n        std::array<const RenderMaterial*, RenderMaterialGroup::k_numMaterialSlots> staticRenderMaterials {};\n        std::array<const RenderMaterial*, RenderMaterialGroup::k_numMaterialSlots> animatedRenderMaterials {};\n        std::vector<UniquePtr<RenderMaterial>> renderMaterials;\n        \n        CreateUnlitRenderMaterialGroupCollection(VertexFormat::k_sprite, renderTexture, isTransparencyEnabled, isColourWriteEnabled, isDepthWriteEnabled, isDepthTestEnabled, isFaceCullingEnabled, isStencilTestEnabled, depthTestFunc, sourceBlendMode, destinationBlendMode, stencilFailOp, stencilDepthFailOp, stencilPassOp, stencilTestFunc, stencilRef, stencilMask, cullFace, emissiveColour, ambientColour, spriteRenderMaterials, renderMaterials);\n        CreateUnlitRenderMaterialGroupCollection(VertexFormat::k_staticMesh, renderTexture, isTransparencyEnabled, isColourWriteEnabled, isDepthWriteEnabled, isDepthTestEnabled, isFaceCullingEnabled, isStencilTestEnabled, depthTestFunc, sourceBlendMode, destinationBlendMode, stencilFailOp, stencilDepthFailOp, stencilPassOp, stencilTestFunc, stencilRef, stencilMask, cullFace, emissiveColour, ambientColour, staticRenderMaterials, renderMaterials);\n        CreateUnlitRenderMaterialGroupCollection(VertexFormat::k_animatedMesh, renderTexture, isTransparencyEnabled, isColourWriteEnabled, isDepthWriteEnabled, isDepthTestEnabled, isFaceCullingEnabled, isStencilTestEnabled, depthTestFunc, sourceBlendMode, destinationBlendMode, stencilFailOp, stencilDepthFailOp, stencilPassOp, stencilTestFunc, stencilRef, stencilMask, cullFace, emissiveColour, ambientColour, animatedRenderMaterials, renderMaterials);\n        \n        std::vector<RenderMaterialGroup::Collection> collections\n        {\n            RenderMaterialGroup::Collection(VertexFormat::k_sprite, spriteRenderMaterials),\n            RenderMaterialGroup::Collection(VertexFormat::k_staticMesh, staticRenderMaterials),\n            RenderMaterialGroup::Collection(VertexFormat::k_animatedMesh, animatedRenderMaterials)\n        };\n        \n        auto renderMaterialGroup(MakeUnique<RenderMaterialGroup>(m_renderMaterialGroupPool, std::move(renderMaterials), std::move(collections)));\n        auto renderMaterialGroupRaw = renderMaterialGroup.get();\n        AddRenderMaterialGroup(renderMaterialGroupRaw);\n        \n        return renderMaterialGroup;\n    }\n    \n    //------------------------------------------------------------------------------\n    void ForwardRenderMaterialGroupManager::CreateUnlitRenderMaterialGroupCollection(const VertexFormat& format, const RenderTexture* renderTexture,\n                                                                                     bool isTransparencyEnabled, bool isColourWriteEnabled, bool isDepthWriteEnabled, bool isDepthTestEnabled, bool isFaceCullingEnabled, bool isStencilTestEnabled,\n                                                                                     TestFunc depthTestFunc,\n                                                                                     BlendMode sourceBlendMode, BlendMode destinationBlendMode,\n                                                                                     StencilOp stencilFailOp, StencilOp stencilDepthFailOp, StencilOp stencilPassOp, TestFunc stencilTestFunc, s32 stencilRef, u32 stencilMask,\n                                                                                     CullFace cullFace, const Colour& emissiveColour, const Colour& ambientColour,\n                                                                                     std::array<const RenderMaterial*, RenderMaterialGroup::k_numMaterialSlots>& out_renderMaterialSlots, std::vector<UniquePtr<RenderMaterial>>& out_renderMaterials) noexcept\n    {\n        if(format == VertexFormat::k_sprite)\n        {\n            auto spriteRM = CreateUnlit(m_renderMaterialPool,\n                                        m_spriteUnlit, renderTexture, isTransparencyEnabled, isColourWriteEnabled, isDepthWriteEnabled, isDepthTestEnabled, isFaceCullingEnabled, isStencilTestEnabled,\n                                        depthTestFunc,\n                                        sourceBlendMode, destinationBlendMode,\n                                        stencilFailOp, stencilDepthFailOp, stencilPassOp, stencilTestFunc, stencilRef, stencilMask,\n                                        cullFace, emissiveColour, ambientColour);\n            out_renderMaterialSlots[static_cast<u32>(isTransparencyEnabled == true ? RenderPasses::k_transparent : RenderPasses::k_base)] = spriteRM.get();\n            out_renderMaterials.push_back(std::move(spriteRM));\n        }\n        else if(format == VertexFormat::k_staticMesh)\n        {\n            auto staticRM = CreateUnlit(m_renderMaterialPool,\n                                        m_staticUnlit, renderTexture, isTransparencyEnabled, isColourWriteEnabled, isDepthWriteEnabled, isDepthTestEnabled, isFaceCullingEnabled, isStencilTestEnabled,\n                                        depthTestFunc,\n                                        sourceBlendMode, destinationBlendMode,\n                                        stencilFailOp, stencilDepthFailOp, stencilPassOp, stencilTestFunc, stencilRef, stencilMask,\n                                        cullFace, emissiveColour, ambientColour);\n            out_renderMaterialSlots[static_cast<u32>(isTransparencyEnabled == true ? RenderPasses::k_transparent : RenderPasses::k_base)] = staticRM.get();\n            out_renderMaterials.push_back(std::move(staticRM));\n\n            if (m_shadowsSupported && !isTransparencyEnabled)\n            {\n                auto staticShadowMapRM = CreateShadowMap(m_renderMaterialPool, m_staticShadowMap);\n                out_renderMaterialSlots[static_cast<u32>(RenderPasses::k_shadowMap)] = staticShadowMapRM.get();\n                out_renderMaterials.push_back(std::move(staticShadowMapRM));\n            }\n        }\n        else if(format == VertexFormat::k_animatedMesh)\n        {\n            auto animatedRM = CreateUnlit(m_renderMaterialPool,\n                                          m_animatedUnlit, renderTexture, isTransparencyEnabled, isColourWriteEnabled, isDepthWriteEnabled, isDepthTestEnabled, isFaceCullingEnabled, isStencilTestEnabled,\n                                          depthTestFunc,\n                                          sourceBlendMode, destinationBlendMode,\n                                          stencilFailOp, stencilDepthFailOp, stencilPassOp, stencilTestFunc, stencilRef, stencilMask,\n                                          cullFace, emissiveColour, ambientColour);\n            out_renderMaterialSlots[static_cast<u32>(isTransparencyEnabled == true ? RenderPasses::k_transparent : RenderPasses::k_base)] = animatedRM.get();\n            out_renderMaterials.push_back(std::move(animatedRM));\n\n            if (m_shadowsSupported && !isTransparencyEnabled)\n            {\n                auto animatedShadowMapRM = CreateShadowMap(m_renderMaterialPool, m_animatedShadowMap);\n                out_renderMaterialSlots[static_cast<u32>(RenderPasses::k_shadowMap)] = animatedShadowMapRM.get();\n                out_renderMaterials.push_back(std::move(animatedShadowMapRM));\n            }\n        }\n    }\n    \n    //------------------------------------------------------------------------------\n    UniquePtr<RenderMaterialGroup> ForwardRenderMaterialGroupManager::CreateSkyboxRenderMaterialGroup(const RenderTexture* renderCubmap) noexcept\n    {\n        std::array<const RenderMaterial*, RenderMaterialGroup::k_numMaterialSlots> staticRenderMaterials {};\n        std::vector<UniquePtr<RenderMaterial>> renderMaterials;\n        \n        CreateSkyboxRenderMaterialGroupCollection(VertexFormat::k_staticMesh, renderCubmap, staticRenderMaterials, renderMaterials);\n        \n        std::vector<RenderMaterialGroup::Collection> collections\n        {\n            RenderMaterialGroup::Collection(VertexFormat::k_staticMesh, staticRenderMaterials),\n        };\n        \n        auto renderMaterialGroup(MakeUnique<RenderMaterialGroup>(m_renderMaterialGroupPool, std::move(renderMaterials), std::move(collections)));\n        auto renderMaterialGroupRaw = renderMaterialGroup.get();\n        AddRenderMaterialGroup(renderMaterialGroupRaw);\n        \n        return renderMaterialGroup;\n    }\n    \n    //------------------------------------------------------------------------------\n    void ForwardRenderMaterialGroupManager::CreateSkyboxRenderMaterialGroupCollection(const VertexFormat& format, const RenderTexture* renderCubemap,\n                                                                                     std::array<const RenderMaterial*, RenderMaterialGroup::k_numMaterialSlots>& out_renderMaterialSlots, std::vector<UniquePtr<RenderMaterial>>& out_renderMaterials) noexcept\n    {\n        CS_ASSERT(format == VertexFormat::k_staticMesh, \"Skybox materials only work with static meshes\");\n\n        auto staticRM = CreateSkybox(m_renderMaterialPool, m_skybox, renderCubemap);\n        out_renderMaterialSlots[static_cast<u32>(RenderPasses::k_skybox)] = staticRM.get();\n        out_renderMaterials.push_back(std::move(staticRM));\n    }\n    \n    //------------------------------------------------------------------------------\n    UniquePtr<RenderMaterialGroup> ForwardRenderMaterialGroupManager::CreateBlinnRenderMaterialGroup(const RenderTexture* renderTexture, const Colour& emissiveColour, const Colour& ambientColour, const Colour& diffuseColour, const Colour& specularColour) noexcept\n    {\n        std::array<const RenderMaterial*, RenderMaterialGroup::k_numMaterialSlots> staticRenderMaterials {};\n        std::array<const RenderMaterial*, RenderMaterialGroup::k_numMaterialSlots> animatedRenderMaterials {};\n        std::vector<UniquePtr<RenderMaterial>> renderMaterials;\n        \n        CreateBlinnRenderMaterialGroupCollection(VertexFormat::k_staticMesh, renderTexture, emissiveColour, ambientColour, diffuseColour, specularColour, staticRenderMaterials, renderMaterials);\n        CreateBlinnRenderMaterialGroupCollection(VertexFormat::k_animatedMesh, renderTexture, emissiveColour, ambientColour, diffuseColour, specularColour, animatedRenderMaterials, renderMaterials);\n        \n        std::vector<RenderMaterialGroup::Collection> collections\n        {\n            RenderMaterialGroup::Collection(VertexFormat::k_staticMesh, staticRenderMaterials),\n            RenderMaterialGroup::Collection(VertexFormat::k_animatedMesh, animatedRenderMaterials)\n        };\n        \n        auto renderMaterialGroup(MakeUnique<RenderMaterialGroup>(m_renderMaterialGroupPool, std::move(renderMaterials), std::move(collections)));\n        auto renderMaterialGroupRaw = renderMaterialGroup.get();\n        AddRenderMaterialGroup(renderMaterialGroupRaw);\n        \n        return renderMaterialGroup;\n    }\n    \n    //------------------------------------------------------------------------------\n    void ForwardRenderMaterialGroupManager::CreateBlinnRenderMaterialGroupCollection(const VertexFormat& format, const RenderTexture* renderTexture, const Colour& emissiveColour, const Colour& ambientColour, const Colour& diffuseColour, const Colour& specularColour,\n                                                                                     std::array<const RenderMaterial*, RenderMaterialGroup::k_numMaterialSlots>& out_renderMaterialSlots, std::vector<UniquePtr<RenderMaterial>>& out_renderMaterials) noexcept\n    {\n        if(format == VertexFormat::k_staticMesh)\n        {\n            auto staticBaseRM = CreateBlinnBase(m_renderMaterialPool, m_staticBlinnBase, renderTexture, emissiveColour, ambientColour);\n            out_renderMaterialSlots[static_cast<u32>(RenderPasses::k_base)] = staticBaseRM.get();\n            out_renderMaterials.push_back(std::move(staticBaseRM));\n            \n            auto staticDirectionalRM = CreateBlinnLight(m_renderMaterialPool, m_staticBlinnDirectional, renderTexture, diffuseColour, specularColour);\n            out_renderMaterialSlots[static_cast<u32>(RenderPasses::k_directionalLight)] = staticDirectionalRM.get();\n            out_renderMaterials.push_back(std::move(staticDirectionalRM));\n            \n            auto staticPointRM = CreateBlinnLight(m_renderMaterialPool, m_staticBlinnPoint, renderTexture, diffuseColour, specularColour);\n            out_renderMaterialSlots[static_cast<u32>(RenderPasses::k_pointLight)] = staticPointRM.get();\n            out_renderMaterials.push_back(std::move(staticPointRM));\n            \n            if (m_shadowsSupported)\n            {\n                auto staticShadowMapRM = CreateShadowMap(m_renderMaterialPool, m_staticShadowMap);\n                out_renderMaterialSlots[static_cast<u32>(RenderPasses::k_shadowMap)] = staticShadowMapRM.get();\n                out_renderMaterials.push_back(std::move(staticShadowMapRM));\n                \n                auto staticDirectionalShadowsRM = CreateBlinnLight(m_renderMaterialPool, m_staticBlinnDirectionalShadows, renderTexture, diffuseColour, specularColour);\n                out_renderMaterialSlots[static_cast<u32>(RenderPasses::k_directionalLightShadows)] = staticDirectionalShadowsRM.get();\n                out_renderMaterials.push_back(std::move(staticDirectionalShadowsRM));\n            }\n        }\n        else if(format == VertexFormat::k_animatedMesh)\n        {\n            auto animatedBaseRM = CreateBlinnBase(m_renderMaterialPool, m_animatedBlinnBase, renderTexture, emissiveColour, ambientColour);\n            out_renderMaterialSlots[static_cast<u32>(RenderPasses::k_base)] = animatedBaseRM.get();\n            out_renderMaterials.push_back(std::move(animatedBaseRM));\n            \n            auto animatedDirectionalRM = CreateBlinnLight(m_renderMaterialPool, m_animatedBlinnDirectional, renderTexture, diffuseColour, specularColour);\n            out_renderMaterialSlots[static_cast<u32>(RenderPasses::k_directionalLight)] = animatedDirectionalRM.get();\n            out_renderMaterials.push_back(std::move(animatedDirectionalRM));\n            \n            auto animatedPointRM = CreateBlinnLight(m_renderMaterialPool, m_animatedBlinnPoint, renderTexture, diffuseColour, specularColour);\n            out_renderMaterialSlots[static_cast<u32>(RenderPasses::k_pointLight)] = animatedPointRM.get();\n            out_renderMaterials.push_back(std::move(animatedPointRM));\n            \n            if (m_shadowsSupported)\n            {\n                auto animatedShadowMapRM = CreateShadowMap(m_renderMaterialPool, m_animatedShadowMap);\n                out_renderMaterialSlots[static_cast<u32>(RenderPasses::k_shadowMap)] = animatedShadowMapRM.get();\n                out_renderMaterials.push_back(std::move(animatedShadowMapRM));\n                \n                auto animatedDirectionalShadowsRM = CreateBlinnLight(m_renderMaterialPool, m_animatedBlinnDirectionalShadows, renderTexture, diffuseColour, specularColour);\n                out_renderMaterialSlots[static_cast<u32>(RenderPasses::k_directionalLightShadows)] = animatedDirectionalShadowsRM.get();\n                out_renderMaterials.push_back(std::move(animatedDirectionalShadowsRM));\n            }\n        }\n    }\n    \n    //------------------------------------------------------------------------------\n    UniquePtr<RenderMaterialGroup> ForwardRenderMaterialGroupManager::CreateCustomRenderMaterialGroup(MaterialShadingType fallbackType, const VertexFormat& vertexFormat, const std::vector<std::pair<const RenderShader*, RenderPasses>>& renderShaders, const std::vector<const RenderTexture*>& renderTextures2D, const std::vector<const RenderTexture*>& renderTexturesCubemap,\n                                                                                                  bool isTransparencyEnabled, bool isColourWriteEnabled, bool isDepthWriteEnabled, bool isDepthTestEnabled, bool isFaceCullingEnabled, bool isStencilTestEnabled,\n                                                                                                  TestFunc depthTestFunc,\n                                                                                                  BlendMode sourceBlendMode, BlendMode destinationBlendMode,\n                                                                                                  StencilOp stencilFailOp, StencilOp stencilDepthFailOp, StencilOp stencilPassOp, TestFunc stencilTestFunc, s32 stencilRef, u32 stencilMask,\n                                                                                                  CullFace cullFace, const Colour& emissiveColour, const Colour& ambientColour, const Colour& diffuseColour, const Colour& specularColour,\n                                                                                                  RenderShaderVariablesUPtr renderShaderVariables) noexcept\n    {\n        std::array<const RenderMaterial*, RenderMaterialGroup::k_numMaterialSlots> renderMaterialsSlots {};\n        std::vector<UniquePtr<RenderMaterial>> renderMaterials;\n        \n        switch(fallbackType)\n        {\n            case MaterialShadingType::k_unlit:\n                CS_ASSERT(renderTextures2D.size() > 0, \"If custom shader material falling back on Unlit type a texture must be supplied\");\n                CreateUnlitRenderMaterialGroupCollection(vertexFormat, renderTextures2D[0], isTransparencyEnabled, isColourWriteEnabled, isDepthWriteEnabled, isDepthTestEnabled, isFaceCullingEnabled, isStencilTestEnabled, depthTestFunc, sourceBlendMode, destinationBlendMode, stencilFailOp, stencilDepthFailOp, stencilPassOp, stencilTestFunc, stencilRef, stencilMask, cullFace, emissiveColour, ambientColour, renderMaterialsSlots, renderMaterials);\n                break;\n            case MaterialShadingType::k_blinn:\n                CS_ASSERT(renderTextures2D.size() > 0, \"If custom shader material falling back on Blinn type a texture must be supplied\");\n                CreateBlinnRenderMaterialGroupCollection(vertexFormat, renderTextures2D[0], emissiveColour, ambientColour, diffuseColour, specularColour, renderMaterialsSlots, renderMaterials);\n                break;\n            case MaterialShadingType::k_skybox:\n                CS_ASSERT(renderTexturesCubemap.size() > 0, \"If custom shader material falling back on Skybox type a cubemap must be supplied\");\n                CreateSkyboxRenderMaterialGroupCollection(vertexFormat, renderTexturesCubemap[0], renderMaterialsSlots, renderMaterials);\n                break;\n            case MaterialShadingType::k_custom:\n            default:\n                //Don't create any fallback for missing passes\n                break;\n        }\n        \n        for(const auto& shaderPass : renderShaders)\n        {\n            auto renderMaterial = MakeUnique<RenderMaterial>(m_renderMaterialPool, shaderPass.first, renderTextures2D, renderTexturesCubemap,\n                                                                        isTransparencyEnabled, isColourWriteEnabled, isDepthWriteEnabled, isDepthTestEnabled, isFaceCullingEnabled, isStencilTestEnabled,\n                                                                        depthTestFunc,\n                                                                        sourceBlendMode, destinationBlendMode,\n                                                                        stencilFailOp, stencilDepthFailOp, stencilPassOp, stencilTestFunc, stencilRef, stencilMask,\n                                                                        cullFace, emissiveColour, ambientColour, diffuseColour, specularColour, std::move(renderShaderVariables));\n\n            renderMaterialsSlots[static_cast<u32>(shaderPass.second)] = renderMaterial.get();\n            renderMaterials.push_back(std::move(renderMaterial));\n        }\n\n\n        std::vector<RenderMaterialGroup::Collection> collections { RenderMaterialGroup::Collection(vertexFormat, renderMaterialsSlots) };\n        \n        auto renderMaterialGroup(MakeUnique<RenderMaterialGroup>(m_renderMaterialGroupPool, std::move(renderMaterials), std::move(collections)));\n        auto renderMaterialGroupRaw = renderMaterialGroup.get();\n        AddRenderMaterialGroup(renderMaterialGroupRaw);\n        \n        return renderMaterialGroup;\n    }\n    \n    //------------------------------------------------------------------------------\n    void ForwardRenderMaterialGroupManager::OnInit() noexcept\n    {\n        auto renderCapabilities = Application::Get()->GetSystem<RenderCapabilities>();\n        m_shadowsSupported = renderCapabilities->IsShadowMappingSupported();\n        \n        auto resourcePool = Application::Get()->GetResourcePool();\n        \n        m_spriteUnlit = resourcePool->LoadResource<Shader>(StorageLocation::k_chilliSource, \"Shaders/Sprite-Unlit.csshader\");\n        \n        m_staticUnlit = resourcePool->LoadResource<Shader>(StorageLocation::k_chilliSource, \"Shaders/Static-Unlit.csshader\");\n        m_staticBlinnBase = resourcePool->LoadResource<Shader>(StorageLocation::k_chilliSource, \"Shaders/Static-Blinn-Base.csshader\");\n        m_staticBlinnDirectional = resourcePool->LoadResource<Shader>(StorageLocation::k_chilliSource, \"Shaders/Static-Blinn-Directional.csshader\");\n        m_staticBlinnPoint = resourcePool->LoadResource<Shader>(StorageLocation::k_chilliSource, \"Shaders/Static-Blinn-Point.csshader\");\n        \n        m_animatedUnlit = resourcePool->LoadResource<Shader>(StorageLocation::k_chilliSource, \"Shaders/Animated-Unlit.csshader\");\n        m_animatedBlinnBase = resourcePool->LoadResource<Shader>(StorageLocation::k_chilliSource, \"Shaders/Animated-Blinn-Base.csshader\");\n        m_animatedBlinnDirectional = resourcePool->LoadResource<Shader>(StorageLocation::k_chilliSource, \"Shaders/Animated-Blinn-Directional.csshader\");\n        m_animatedBlinnPoint = resourcePool->LoadResource<Shader>(StorageLocation::k_chilliSource, \"Shaders/Animated-Blinn-Point.csshader\");\n        \n        m_skybox = resourcePool->LoadResource<Shader>(StorageLocation::k_chilliSource, \"Shaders/Skybox.csshader\");\n        \n        if (m_shadowsSupported)\n        {\n            m_staticShadowMap = resourcePool->LoadResource<Shader>(StorageLocation::k_chilliSource, \"Shaders/Static-ShadowMap.csshader\");\n            m_staticBlinnDirectionalShadows = resourcePool->LoadResource<Shader>(StorageLocation::k_chilliSource, \"Shaders/Static-Blinn-DirectionalShadows.csshader\");\n            \n            m_animatedShadowMap = resourcePool->LoadResource<Shader>(StorageLocation::k_chilliSource, \"Shaders/Animated-ShadowMap.csshader\");\n            m_animatedBlinnDirectionalShadows = resourcePool->LoadResource<Shader>(StorageLocation::k_chilliSource, \"Shaders/Animated-Blinn-DirectionalShadows.csshader\");\n        }\n    }\n    \n    //------------------------------------------------------------------------------\n    void ForwardRenderMaterialGroupManager::OnDestroy() noexcept\n    {\n        m_spriteUnlit.reset();\n        \n        m_skybox.reset();\n        \n        m_staticShadowMap.reset();\n        m_staticUnlit.reset();\n        m_staticBlinnBase.reset();\n        m_staticBlinnDirectional.reset();\n        m_staticBlinnPoint.reset();\n        m_staticBlinnDirectionalShadows.reset();\n\n        m_animatedShadowMap.reset();\n        m_animatedUnlit.reset();\n        m_animatedBlinnBase.reset();\n        m_animatedBlinnDirectional.reset();\n        m_animatedBlinnPoint.reset();\n        m_animatedBlinnDirectionalShadows.reset();\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Material/ForwardRenderMaterialGroupManager.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_MATERIAL_FORWARDRENDERMATERIALGROUPMANAGER_H_\n#define _CHILLISOURCE_RENDERING_MATERIAL_FORWARDRENDERMATERIALGROUPMANAGER_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Memory/ObjectPoolAllocator.h>\n#include <ChilliSource/Rendering/Material/RenderMaterialGroupManager.h>\n\nnamespace ChilliSource\n{\n    /// The forward rendered version of the RenderMaterialGroupManager. This creates the\n    /// necessary materials to perform multi-pass forward rendering for each of the different\n    /// material types. The various passes are described in ForwardRenderPasses.h\n    ///\n    /// This is thread safe.\n    ///\n    class ForwardRenderMaterialGroupManager final : public RenderMaterialGroupManager\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(ForwardRenderMaterialGroupManager);\n        \n        /// Allows querying of whether or not this system implements the interface described by the\n        /// given interface Id. Typically this is not called directly as the templated equivalent\n        /// IsA<Interface>() is preferred.\n        ///\n        /// @param interfaceId\n        ///     The Id of the interface.\n        ///\n        /// @return Whether or not the interface is implemented.\n        ///\n        bool IsA(InterfaceIDType interfaceId) const noexcept override;\n        \n        /// Creates a new unlit RenderMaterialGroup and queues a LoadMaterialGroupRenderCommand for the next\n        /// Render Snapshot stage in the render pipeline.\n        ///\n        /// @param renderTexture\n        ///     The render texture.\n        /// @param isTransparencyEnabled\n        ///     Whether or not transparency is enabled.\n        /// @param isColourWriteEnabled\n        ///     Whether or not colour write is enabled.\n        /// @param isDepthWriteEnabled\n        ///     Whether or not depth write is enabled.\n        /// @param isDepthTestEnabled\n        ///     Whether or not the depth test will be performed.\n        /// @param isFaceCullingEnabled\n        ///     Whether or not face culling will be performed.\n        /// @param isStencilTestEnabled\n        ///     Whether or not to perform stencil testing\n        /// @param depthTestFunc\n        ///     Function that determines whether a depth test comparison should pass or fail\n        /// @param sourceBlendMode\n        ///     The source blend mode. This only applies if transparency is enabled.\n        /// @param destinationBlendMode\n        ///     The destination blend mode. This only applies if transparency is enabled.\n        /// @param stencilFailOp\n        ///     Op applied if stencil test fails\n        /// @param stencilDepthFailOp\n        ///     Op applied if stencil depth test fails\n        /// @param stencilPassOp\n        ///     Op applied if stencil and depth tests pass\n        /// @param stencilTestFunc\n        ///     Function that determines whether a stencil test comparison should pass or fail\n        /// @param stencilRef\n        ///     Value used as comparison for stencil tests\n        /// @param stencilMask\n        ///     Value ANDed to with the comparison and stencil value\n        /// @param cullFace\n        ///     The face which should be called. This only applies if face culling is enabled.\n        /// @param ambientColour\n        ///     The ambient colour.\n        /// @param emissiveColour\n        ///     The ambient colour.\n        ///\n        /// @return The new material group.\n        ///\n        UniquePtr<RenderMaterialGroup> CreateUnlitRenderMaterialGroup(const RenderTexture* renderTexture,\n                                                                  bool isTransparencyEnabled, bool isColourWriteEnabled, bool isDepthWriteEnabled, bool isDepthTestEnabled, bool isFaceCullingEnabled, bool isStencilTestEnabled,\n                                                                  TestFunc depthTestFunc,\n                                                                  BlendMode sourceBlendMode, BlendMode destinationBlendMode,\n                                                                  StencilOp stencilFailOp, StencilOp stencilDepthFailOp, StencilOp stencilPassOp, TestFunc stencilTestFunc, s32 stencilRef, u32 stencilMask,\n                                                                  CullFace cullFace, const Colour& emissiveColour, const Colour& ambientColour) noexcept override;\n        \n        /// Creates a new skybox RenderMaterialGroup and queues a LoadMaterialGroupRenderCommand for the next\n        /// Render Snapshot stage in the render pipeline.\n        ///\n        /// @param renderCubmap\n        ///     The render cubemap.\n        ///\n        /// @return The new material group.\n        ///\n        UniquePtr<RenderMaterialGroup> CreateSkyboxRenderMaterialGroup(const RenderTexture* renderCubmap) noexcept override;\n        \n        /// Creates a new blinn RenderMaterialGroup and queues a LoadMaterialGroupRenderCommand for the next\n        /// Render Snapshot stage in the render pipeline.\n        ///\n        /// @param renderTexture\n        ///     The render texture.\n        /// @param ambientColour\n        ///     The ambient colour.\n        /// @param emissiveColour\n        ///     The ambient colour.\n        /// @param diffuseColour\n        ///     The diffuse colour.\n        /// @param specularColour\n        ///     The specular colour.\n        ///\n        /// @return The new material group.\n        ///\n        UniquePtr<RenderMaterialGroup> CreateBlinnRenderMaterialGroup(const RenderTexture* renderTexture, const Colour& emissiveColour, const Colour& ambientColour, const Colour& diffuseColour,\n                                                                  const Colour& specularColour) noexcept override;\n        \n        /// Creates a new custom RenderMaterialGroup and queues a LoadMaterialGroupRenderCommand for the next\n        /// Render Snapshot stage in the render pipeline.\n        ///\n        /// @param fallbackType\n        ///     Any unspecified render pass shaders us the equivalent shader from the fallback type\n        /// @param vertexFormat\n        ///     The vertex format this material is for.\n        /// @param renderShaders\n        ///     The render shaders for each pass.\n        /// @param renderTextures2D\n        ///     The list of render textures.\n        /// @param renderTexturesCubemap\n        ///     The list of render cubemaps.\n        /// @param isTransparencyEnabled\n        ///     Whether or not transparency is enabled.\n        /// @param isColourWriteEnabled\n        ///     Whether or not colour write is enabled.\n        /// @param isDepthWriteEnabled\n        ///     Whether or not depth write is enabled.\n        /// @param isDepthTestEnabled\n        ///     Whether or not the depth test will be performed.\n        /// @param isFaceCullingEnabled\n        ///     Whether or not face culling will be performed.\n        /// @param isStencilTestEnabled\n        ///     Whether or not to perform stencil testing\n        /// @param depthTestFunc\n        ///     Function that determines whether a depth test comparison should pass or fail\n        /// @param sourceBlendMode\n        ///     The source blend mode. This only applies if transparency is enabled.\n        /// @param destinationBlendMode\n        ///     The destination blend mode. This only applies if transparency is enabled.\n        /// @param stencilFailOp\n        ///     Op applied if stencil test fails\n        /// @param stencilDepthFailOp\n        ///     Op applied if stencil depth test fails\n        /// @param stencilPassOp\n        ///     Op applied if stencil and depth tests pass\n        /// @param stencilTestFunc\n        ///     Function that determines whether a stencil test comparison should pass or fail\n        /// @param stencilRef\n        ///     Value used as comparison for stencil tests\n        /// @param stencilMask\n        ///     Value ANDed to with the comparison and stencil value\n        /// @param cullFace\n        ///     The face which should be called. This only applies if face culling is enabled.\n        /// @param emissiveColour\n        ///     The ambient colour.\n        /// @param ambientColour\n        ///     The ambient colour.\n        /// @param diffuseColour\n        ///     The diffuse colour.\n        /// @param specularColour\n        ///     The specular colour.\n        /// @param renderShaderVariables\n        ///     The container for all render shader variables.\n        ///\n        /// @return The new material group.\n        ///\n        UniquePtr<RenderMaterialGroup> CreateCustomRenderMaterialGroup(MaterialShadingType fallbackType, const VertexFormat& vertexFormat, const std::vector<std::pair<const RenderShader*, RenderPasses>>& renderShaders, const std::vector<const RenderTexture*>& renderTextures2D, const std::vector<const RenderTexture*>& renderTexturesCubemap,\n                                                                   bool isTransparencyEnabled, bool isColourWriteEnabled, bool isDepthWriteEnabled, bool isDepthTestEnabled, bool isFaceCullingEnabled, bool isStencilTestEnabled,\n                                                                   TestFunc depthTestFunc,\n                                                                   BlendMode sourceBlendMode, BlendMode destinationBlendMode,\n                                                                   StencilOp stencilFailOp, StencilOp stencilDepthFailOp, StencilOp stencilPassOp, TestFunc stencilTestFunc, s32 stencilRef, u32 stencilMask,\n                                                                   CullFace cullFace, const Colour& emissiveColour, const Colour& ambientColour, const Colour& diffuseColour, const Colour& specularColour,\n                                                                   RenderShaderVariablesUPtr renderShaderVariables) noexcept override;\n        \n    private:\n        friend class RenderMaterialGroupManager;\n        \n        /// The init lifecycle event. Loads all shaders used by the system.\n        ///\n        void OnInit() noexcept override;\n        \n        /// The destroy lifecycle event. Unloads all shaders used by the system.\n        ///\n        void OnDestroy() noexcept override;\n        \n        ForwardRenderMaterialGroupManager();\n        \n        ///\n        /// Helper methods that creates the render materials on behalf of the CreateXXXXGroup methods for the given vertex format\n        ///\n        void CreateUnlitRenderMaterialGroupCollection(const VertexFormat& format, const RenderTexture* renderTexture,\n                                                      bool isTransparencyEnabled, bool isColourWriteEnabled, bool isDepthWriteEnabled, bool isDepthTestEnabled, bool isFaceCullingEnabled, bool isStencilTestEnabled,\n                                                      TestFunc depthTestFunc,\n                                                      BlendMode sourceBlendMode, BlendMode destinationBlendMode,\n                                                      StencilOp stencilFailOp, StencilOp stencilDepthFailOp, StencilOp stencilPassOp, TestFunc stencilTestFunc, s32 stencilRef, u32 stencilMask,\n                                                      CullFace cullFace, const Colour& emissiveColour, const Colour& ambientColour,\n                                                      std::array<const RenderMaterial*, RenderMaterialGroup::k_numMaterialSlots>& out_renderMaterialSlots, std::vector<UniquePtr<RenderMaterial>>& out_renderMaterials) noexcept;\n        \n        ///\n        /// Helper methods that creates the render materials on behalf of the CreateXXXXGroup methods for the given vertex format\n        ///\n        void CreateSkyboxRenderMaterialGroupCollection(const VertexFormat& format, const RenderTexture* renderCubemap,\n                                                      std::array<const RenderMaterial*, RenderMaterialGroup::k_numMaterialSlots>& out_renderMaterialSlots, std::vector<UniquePtr<RenderMaterial>>& out_renderMaterials) noexcept;\n        \n        ///\n        /// Helper methods that creates the render materials on behalf of the CreateXXXXGroup methods for the given vertex format\n        ///\n        void CreateBlinnRenderMaterialGroupCollection(const VertexFormat& format, const RenderTexture* renderTexture, const Colour& emissiveColour, const Colour& ambientColour, const Colour& diffuseColour, const Colour& specularColour,\n                                                      std::array<const RenderMaterial*, RenderMaterialGroup::k_numMaterialSlots>& out_renderMaterialSlots, std::vector<UniquePtr<RenderMaterial>>& out_renderMaterials) noexcept;\n        \n        \n        ObjectPoolAllocator<RenderMaterial> m_renderMaterialPool;\n        ObjectPoolAllocator<RenderMaterialGroup> m_renderMaterialGroupPool;\n        \n        bool m_shadowsSupported = false;\n        \n        ShaderCSPtr m_spriteUnlit;\n        \n        ShaderCSPtr m_skybox;\n        \n        ShaderCSPtr m_staticShadowMap;\n        ShaderCSPtr m_staticUnlit;\n        ShaderCSPtr m_staticBlinnBase;\n        ShaderCSPtr m_staticBlinnDirectional;\n        ShaderCSPtr m_staticBlinnDirectionalShadows;\n        ShaderCSPtr m_staticBlinnPoint;\n        \n        ShaderCSPtr m_animatedShadowMap;\n        ShaderCSPtr m_animatedUnlit;\n        ShaderCSPtr m_animatedBlinnBase;\n        ShaderCSPtr m_animatedBlinnDirectional;\n        ShaderCSPtr m_animatedBlinnDirectionalShadows;\n        ShaderCSPtr m_animatedBlinnPoint;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Material/Material.cpp",
    "content": "//\n//  Material.cpp\n//  ChilliSource\n//  Created by Scott Downie on 14/10/2010.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2010 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Material/Material.h>\n\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/Threading/TaskScheduler.h>\n#include <ChilliSource/Rendering/Base/BlendMode.h>\n#include <ChilliSource/Rendering/Base/CullFace.h>\n#include <ChilliSource/Rendering/Base/StencilOp.h>\n#include <ChilliSource/Rendering/Base/TestFunc.h>\n#include <ChilliSource/Rendering/Material/RenderMaterialGroupManager.h>\n#include <ChilliSource/Rendering/Shader/RenderShaderVariables.h>\n#include <ChilliSource/Rendering/Shader/Shader.h>\n#include <ChilliSource/Rendering/Texture/Texture.h>\n#include <ChilliSource/Rendering/Texture/Cubemap.h>\n\nnamespace ChilliSource\n{\n    CS_DEFINE_NAMEDTYPE(Material);\n\n    //----------------------------------------------------------\n    //----------------------------------------------------------\n    MaterialUPtr Material::Create()\n    {\n        return MaterialUPtr(new Material());\n    }\n    //------------------------------------------------\n    //------------------------------------------------\n    Material::Material() noexcept\n    :   m_srcBlendMode(BlendMode::k_one), m_dstBlendMode(BlendMode::k_oneMinusSourceAlpha),\n        m_depthTestFunc(TestFunc::k_lessEqual),\n        m_cullFace(CullFace::k_back),\n        m_stencilPassOp(StencilOp::k_keep), m_stencilFailOp(StencilOp::k_keep), m_stencilDepthFailOp(StencilOp::k_keep)\n    {\n        m_renderMaterialGroupManager = Application::Get()->GetSystem<RenderMaterialGroupManager>();\n        CS_ASSERT(m_renderMaterialGroupManager, \"RenderMaterialGroupManager is required.\");\n    }\n    //----------------------------------------------------------\n    //----------------------------------------------------------\n    bool Material::IsA(InterfaceIDType in_interfaceId) const\n    {\n        return in_interfaceId == Material::InterfaceID;\n    }\n    //----------------------------------------------------------\n    //----------------------------------------------------------\n    MaterialShadingType Material::GetShadingType() const noexcept\n    {\n        return m_shadingType;\n    }\n    //----------------------------------------------------------\n    //----------------------------------------------------------\n    void Material::SetShadingType(MaterialShadingType in_shadingType) noexcept\n    {\n        m_shadingType = in_shadingType;\n    }\n    //----------------------------------------------------------\n    //----------------------------------------------------------\n    void Material::RemoveAllTextures() noexcept\n    {\n        m_textures.clear();\n        m_isCacheValid = false;\n    }\n    //----------------------------------------------------------\n    //----------------------------------------------------------\n    void Material::AddTexture(const TextureCSPtr& in_texture) noexcept\n    {\n        CS_ASSERT(in_texture != nullptr, \"Cannot add null texture to material\");\n        m_textures.push_back(in_texture);\n        \n        m_isCacheValid = false;\n    }\n    //----------------------------------------------------------\n    //----------------------------------------------------------\n    void Material::SetTexture(const TextureCSPtr& in_texture, u32 in_texIndex) noexcept\n    {\n        CS_ASSERT(in_texIndex < m_textures.size(), \"Texture index out of bounds\");\n        \n        m_textures[in_texIndex] = in_texture;\n        \n        m_isCacheValid = false;\n    }\n    //----------------------------------------------------------\n    //----------------------------------------------------------\n    const TextureCSPtr& Material::GetTexture(u32 in_index) const noexcept\n    {\n        CS_ASSERT(in_index < m_textures.size(), \"Texture index out of bounds\");\n        return m_textures[in_index];\n    }\n    //----------------------------------------------------------\n    //----------------------------------------------------------\n    u32 Material::GetNumTextures() const noexcept\n    {\n        return static_cast<u32>(m_textures.size());\n    }\n    \n    //----------------------------------------------------------\n    void Material::RemoveAllCubemaps() noexcept\n    {\n        m_cubemaps.clear();\n        m_isCacheValid = false;\n    }\n    \n    //----------------------------------------------------------\n    void Material::AddCubemap(const CubemapCSPtr& cubemap) noexcept\n    {\n        CS_ASSERT(cubemap != nullptr, \"Cannot add null cubemap to material\");\n        m_cubemaps.push_back(cubemap);\n        \n        m_isCacheValid = false;\n    }\n    \n    //----------------------------------------------------------\n    void Material::SetCubemap(const CubemapCSPtr& cubemap, u32 index) noexcept\n    {\n        CS_ASSERT(index < m_cubemaps.size(), \"Cubemap index out of bounds\");\n        \n        m_cubemaps[index] = cubemap;\n        \n        m_isCacheValid = false;\n    }\n    \n    //----------------------------------------------------------\n    const CubemapCSPtr& Material::GetCubemap(u32 index) const noexcept\n    {\n        CS_ASSERT(index < m_cubemaps.size(), \"Cubemap index out of bounds\");\n        return m_cubemaps[index];\n    }\n    \n    //----------------------------------------------------------\n    u32 Material::GetNumCubemaps() const noexcept\n    {\n        return static_cast<u32>(m_cubemaps.size());\n    }\n    \n    //----------------------------------------------------------\n    //----------------------------------------------------------\n    bool Material::IsTransparencyEnabled() const noexcept\n    {\n        return m_isAlphaBlendingEnabled;\n    }\n    //----------------------------------------------------------\n    //----------------------------------------------------------\n    void Material::SetTransparencyEnabled(bool in_enable) noexcept\n    {\n        m_isCacheValid = m_isAlphaBlendingEnabled != in_enable;\n        \n        m_isAlphaBlendingEnabled = in_enable;\n        m_isDepthWriteEnabled = !in_enable;\n    }\n    //----------------------------------------------------------\n    //----------------------------------------------------------\n    bool Material::IsColourWriteEnabled() const noexcept\n    {\n        return m_isColWriteEnabled;\n    }\n    //----------------------------------------------------------\n    //----------------------------------------------------------\n    void Material::SetColourWriteEnabled(bool in_enable) noexcept\n    {\n        m_isCacheValid = m_isColWriteEnabled != in_enable;\n        \n        m_isColWriteEnabled = in_enable;\n    }\n    //----------------------------------------------------------\n    //----------------------------------------------------------\n    bool Material::IsDepthWriteEnabled() const noexcept\n    {\n        return m_isDepthWriteEnabled;\n    }\n    //----------------------------------------------------------\n    //----------------------------------------------------------\n    void Material::SetDepthWriteEnabled(bool in_enable) noexcept\n    {\n        CS_ASSERT(m_isAlphaBlendingEnabled == false, \"Cannot enable depth write on transparent object\");\n        \n        m_isCacheValid = m_isDepthWriteEnabled != in_enable;\n        \n        m_isDepthWriteEnabled = in_enable;\n    }\n    //----------------------------------------------------------\n    //----------------------------------------------------------\n    bool Material::IsDepthTestEnabled() const noexcept\n    {\n        return m_isDepthTestEnabled;\n    }\n    //----------------------------------------------------------\n    //----------------------------------------------------------\n    void Material::SetDepthTestEnabled(bool in_enable) noexcept\n    {\n        m_isCacheValid = m_isDepthTestEnabled != in_enable;\n        \n        m_isDepthTestEnabled = in_enable;\n    }\n    //----------------------------------------------------------\n    //----------------------------------------------------------\n    bool Material::IsFaceCullingEnabled() const noexcept\n    {\n        return m_isFaceCullingEnabled;\n    }\n    //----------------------------------------------------------\n    //----------------------------------------------------------\n    void Material::SetFaceCullingEnabled(bool in_enable) noexcept\n    {\n        m_isCacheValid = m_isFaceCullingEnabled != in_enable;\n        \n        m_isFaceCullingEnabled = in_enable;\n    }\n    //----------------------------------------------------------\n    //----------------------------------------------------------\n    void Material::SetBlendModes(BlendMode in_source, BlendMode in_dest) noexcept\n    {\n        m_srcBlendMode = in_source;\n        m_dstBlendMode = in_dest;\n        \n        m_isCacheValid = false;\n    }\n    //----------------------------------------------------------\n    //----------------------------------------------------------\n    BlendMode Material::GetSourceBlendMode() const noexcept\n    {\n        return m_srcBlendMode;\n    }\n    //----------------------------------------------------------\n    //----------------------------------------------------------\n    BlendMode Material::GetDestBlendMode() const noexcept\n    {\n        return m_dstBlendMode;\n    }\n    //----------------------------------------------------------\n    //----------------------------------------------------------\n    void Material::SetStencilPostTestOps(StencilOp stencilFail, StencilOp depthFail, StencilOp pass) noexcept\n    {\n        m_stencilFailOp = stencilFail;\n        m_stencilDepthFailOp = depthFail;\n        m_stencilPassOp = pass;\n    }\n    //----------------------------------------------------------\n    //----------------------------------------------------------\n    void Material::SetStencilTestFunc(TestFunc testFunc, s32 ref, u32 mask) noexcept\n    {\n        m_stencilTestFunc = testFunc;\n        m_stencilTestFuncRef = ref;\n        m_stencilTestFuncMask = mask;\n    }\n    //----------------------------------------------------------\n    //----------------------------------------------------------\n    void Material::SetCullFace(CullFace in_cullFace) noexcept\n    {\n        m_cullFace = in_cullFace;\n    }\n    //----------------------------------------------------------\n    //----------------------------------------------------------\n    CullFace Material::GetCullFace() const noexcept\n    {\n        return m_cullFace;\n    }\n    //----------------------------------------------------------\n    //----------------------------------------------------------\n    void Material::SetEmissive(const Colour& in_emissive) noexcept\n    {\n        m_emissive = in_emissive;\n        \n        m_isCacheValid = false;\n    }\n    //----------------------------------------------------------\n    //----------------------------------------------------------\n    const Colour& Material::GetEmissive() const noexcept\n    {\n        return m_emissive;\n    }\n    //----------------------------------------------------------\n    //----------------------------------------------------------\n    void Material::SetAmbient(const Colour& in_ambient) noexcept\n    {\n        m_ambient = in_ambient;\n        \n        m_isCacheValid = false;\n    }\n    //----------------------------------------------------------\n    //----------------------------------------------------------\n    const Colour& Material::GetAmbient() const noexcept\n    {\n        return m_ambient;\n    }\n    //----------------------------------------------------------\n    //----------------------------------------------------------\n    void Material::SetDiffuse(const Colour& in_diffuse) noexcept\n    {\n        m_diffuse = in_diffuse;\n        \n        m_isCacheValid = false;\n    }\n    //----------------------------------------------------------\n    //----------------------------------------------------------\n    const Colour& Material::GetDiffuse() const noexcept\n    {\n        return m_diffuse;\n    }\n    //----------------------------------------------------------\n    //----------------------------------------------------------\n    void Material::SetSpecular(const Colour& in_specular) noexcept\n    {\n        m_specular = in_specular;\n        \n        m_isCacheValid = false;\n    }\n    //----------------------------------------------------------\n    //----------------------------------------------------------\n    const Colour& Material::GetSpecular() const noexcept\n    {\n        return m_specular;\n    }\n    //-----------------------------------------------------------\n    //-----------------------------------------------------------\n    void Material::PrepCustomShaders(const VertexFormat& vertexFormat, MaterialShadingType fallbackType) noexcept\n    {\n        m_customShaderVertexFormat = vertexFormat;\n        m_customShaderFallbackType = fallbackType;\n        m_customShaders.clear();\n        \n        m_isCacheValid = false;\n    }\n    //-----------------------------------------------------------\n    //-----------------------------------------------------------\n    void Material::AddCustomShader(const ShaderCSPtr& shader, RenderPasses pass) noexcept\n    {\n        m_customShaders.push_back(std::make_pair(shader, pass));\n        \n        m_isCacheValid = false;\n    }\n    //-----------------------------------------------------------\n    //-----------------------------------------------------------\n    void Material::SetShaderVar(const std::string& in_varName, f32 in_value) noexcept\n    {\n        m_floatVars[in_varName] = in_value;\n        \n        m_isCacheValid = false;\n        m_isVariableCacheValid = false;\n    }\n    //-----------------------------------------------------------\n    //-----------------------------------------------------------\n    void Material::SetShaderVar(const std::string& in_varName, const Vector2& in_value) noexcept\n    {\n        m_vec2Vars[in_varName] = in_value;\n        \n        m_isCacheValid = false;\n        m_isVariableCacheValid = false;\n    }\n    //-----------------------------------------------------------\n    //-----------------------------------------------------------\n    void Material::SetShaderVar(const std::string& in_varName, const Vector3& in_value) noexcept\n    {\n        m_vec3Vars[in_varName] = in_value;\n        \n        m_isCacheValid = false;\n        m_isVariableCacheValid = false;\n    }\n    //-----------------------------------------------------------\n    //-----------------------------------------------------------\n    void Material::SetShaderVar(const std::string& in_varName, const Vector4& in_value) noexcept\n    {\n        m_vec4Vars[in_varName] = in_value;\n        \n        m_isCacheValid = false;\n        m_isVariableCacheValid = false;\n    }\n    //-----------------------------------------------------------\n    //-----------------------------------------------------------\n    void Material::SetShaderVar(const std::string& in_varName, const Matrix4& in_value) noexcept\n    {\n        m_mat4Vars[in_varName] = in_value;\n        \n        m_isCacheValid = false;\n        m_isVariableCacheValid = false;\n    }\n    //-----------------------------------------------------------\n    //-----------------------------------------------------------\n    void Material::SetShaderVar(const std::string& in_varName, const Colour& in_value) noexcept\n    {\n        m_colourVars[in_varName] = in_value;\n        \n        m_isCacheValid = false;\n        m_isVariableCacheValid = false;\n    }\n    //-----------------------------------------------------------\n    //-----------------------------------------------------------\n    const RenderMaterialGroup* Material::GetRenderMaterialGroup() const noexcept\n    {\n        CS_RELEASE_ASSERT(Application::Get()->GetTaskScheduler()->IsMainThread(), \"Must be run in main thread.\");\n        \n        if (!m_isCacheValid || !m_isVariableCacheValid || !m_renderMaterialGroup || !VerifyTexturesAreValid())\n        {\n            DestroyRenderMaterialGroup();\n            \n            m_cachedRenderTextures.clear();\n            for(const auto& texture : m_textures)\n            {\n                m_cachedRenderTextures.push_back(texture->GetRenderTexture());\n            }\n            \n            for(const auto& cubemap : m_cubemaps)\n            {\n                m_cachedRenderTextures.push_back(cubemap->GetRenderTexture());\n            }\n            \n            m_isCacheValid = true;\n            m_isVariableCacheValid = true;\n            \n            switch (m_shadingType)\n            {\n                case MaterialShadingType::k_unlit:\n                    CreateUnlitRenderMaterialGroup();\n                    break;\n                case MaterialShadingType::k_blinn:\n                    CreateBlinnRenderMaterialGroup();\n                    break;\n                case MaterialShadingType::k_custom:\n                    CreateCustomRenderMaterialGroup();\n                    break;\n                case MaterialShadingType::k_skybox:\n                    CreateSkyboxRenderMaterialGroup();\n                    break;\n                default:\n                    CS_LOG_FATAL(\"Invalid shading type.\");\n                    \n            }\n        }\n        \n        return m_renderMaterialGroup.get();\n    }\n    //----------------------------------------------------------\n    //----------------------------------------------------------\n    void Material::CreateUnlitRenderMaterialGroup() const noexcept\n    {\n        CS_ASSERT(!m_renderMaterialGroup, \"Render material group must be null.\");\n        CS_ASSERT(m_textures.size() == 1, \"Unlit materials must have one texture.\");\n        CS_ASSERT(m_cubemaps.size() == 0, \"Unlit materials must have no cubemaps.\");\n        CS_ASSERT(m_customShaders.size() == 0, \"Unlit materials cannot have custom shaders.\");\n        CS_ASSERT(m_floatVars.size() == 0, \"Unlit materials cannot have custom shader variables.\");\n        CS_ASSERT(m_vec2Vars.size() == 0, \"Unlit materials cannot have custom shader variables.\");\n        CS_ASSERT(m_vec3Vars.size() == 0, \"Unlit materials cannot have custom shader variables.\");\n        CS_ASSERT(m_vec4Vars.size() == 0, \"Unlit materials cannot have custom shader variables.\");\n        CS_ASSERT(m_mat4Vars.size() == 0, \"Unlit materials cannot have custom shader variables.\");\n        CS_ASSERT(m_colourVars.size() == 0, \"Unlit materials cannot have custom shader variables.\");\n        \n        auto renderTexture = m_textures[0]->GetRenderTexture();\n        m_renderMaterialGroup = m_renderMaterialGroupManager->CreateUnlitRenderMaterialGroup(renderTexture,\n                                                                                             m_isAlphaBlendingEnabled, m_isColWriteEnabled, m_isDepthWriteEnabled, m_isDepthTestEnabled, m_isFaceCullingEnabled, m_isStencilTestEnabled,\n                                                                                             m_depthTestFunc,\n                                                                                             m_srcBlendMode, m_dstBlendMode,\n                                                                                             m_stencilFailOp, m_stencilDepthFailOp, m_stencilPassOp, m_stencilTestFunc, m_stencilTestFuncRef, m_stencilTestFuncMask,\n                                                                                             m_cullFace, m_emissive, m_ambient);\n    }\n    //----------------------------------------------------------\n    //----------------------------------------------------------\n    void Material::CreateSkyboxRenderMaterialGroup() const noexcept\n    {\n        CS_ASSERT(!m_renderMaterialGroup, \"Render material group must be null.\");\n        CS_ASSERT(m_textures.size() == 0, \"Skybox materials must have no textures.\");\n        CS_ASSERT(m_cubemaps.size() == 1, \"Skybox materials must have 1 cubemap.\");\n        CS_ASSERT(m_customShaders.size() == 0, \"Skybox materials cannot have custom shaders.\");\n        CS_ASSERT(m_floatVars.size() == 0, \"Skybox materials cannot have custom shader variables.\");\n        CS_ASSERT(m_vec2Vars.size() == 0, \"Skybox materials cannot have custom shader variables.\");\n        CS_ASSERT(m_vec3Vars.size() == 0, \"Skybox materials cannot have custom shader variables.\");\n        CS_ASSERT(m_vec4Vars.size() == 0, \"Skybox materials cannot have custom shader variables.\");\n        CS_ASSERT(m_mat4Vars.size() == 0, \"Skybox materials cannot have custom shader variables.\");\n        CS_ASSERT(m_colourVars.size() == 0, \"Skybox materials cannot have custom shader variables.\");\n        \n        auto renderCubemap = m_cubemaps[0]->GetRenderTexture();\n        m_renderMaterialGroup = m_renderMaterialGroupManager->CreateSkyboxRenderMaterialGroup(renderCubemap);\n    }\n    //----------------------------------------------------------\n    //----------------------------------------------------------\n    void Material::CreateBlinnRenderMaterialGroup() const noexcept\n    {\n        CS_ASSERT(!m_renderMaterialGroup, \"Render material group must be null.\");\n        CS_ASSERT(m_textures.size() == 1, \"Blinn materials must have one texture.\");\n        CS_ASSERT(m_cubemaps.size() == 0, \"Blinn materials must have no cubemaps.\");\n        CS_ASSERT(!m_isAlphaBlendingEnabled, \"Blinn materials must have transparency disabled.\");\n        CS_ASSERT(m_isDepthWriteEnabled, \"Blinn materials must have depth write enabled.\");\n        CS_ASSERT(m_isColWriteEnabled, \"Blinn materials must have colour write enabled.\");\n        CS_ASSERT(m_isDepthTestEnabled, \"Blinn materials must have depth test enabled.\");\n        CS_ASSERT(m_isFaceCullingEnabled, \"Blinn materials must have face culling enabled.\");\n        CS_ASSERT(m_cullFace == CullFace::k_back, \"Blinn materials must use back-face culling.\");\n        CS_ASSERT(m_customShaders.size() == 0, \"Blinn materials cannot have custom shaders.\");\n        CS_ASSERT(m_floatVars.size() == 0, \"Blinn materials cannot have custom shader variables.\");\n        CS_ASSERT(m_vec2Vars.size() == 0, \"Blinn materials cannot have custom shader variables.\");\n        CS_ASSERT(m_vec3Vars.size() == 0, \"Blinn materials cannot have custom shader variables.\");\n        CS_ASSERT(m_vec4Vars.size() == 0, \"Blinn materials cannot have custom shader variables.\");\n        CS_ASSERT(m_mat4Vars.size() == 0, \"Blinn materials cannot have custom shader variables.\");\n        CS_ASSERT(m_colourVars.size() == 0, \"Blinn materials cannot have custom shader variables.\");\n        \n        auto renderTexture = m_textures[0]->GetRenderTexture();\n        m_renderMaterialGroup = m_renderMaterialGroupManager->CreateBlinnRenderMaterialGroup(renderTexture, m_emissive, m_ambient, m_diffuse, m_specular);\n    }\n    //----------------------------------------------------------\n    //----------------------------------------------------------\n    void Material::CreateCustomRenderMaterialGroup() const noexcept\n    {\n        CS_ASSERT(!m_renderMaterialGroup, \"Render material group must be null.\");\n        CS_ASSERT(m_customShaders.size() > 0, \"Custom material must have at least one custom shader.\");\n        \n        \n        std::vector<const RenderTexture*> renderTextures;\n        renderTextures.reserve(m_textures.size());\n        for (const auto& texture : m_textures)\n        {\n            CS_ASSERT(texture, \"Cannot have a null texture in material\");\n            renderTextures.push_back(texture->GetRenderTexture());\n        }\n        \n        std::vector<const RenderTexture*> renderCubemaps;\n        renderCubemaps.reserve(m_cubemaps.size());\n        for (const auto& cubemap : m_cubemaps)\n        {\n            CS_ASSERT(cubemap, \"Cannot have a null cubemap in material\");\n            renderCubemaps.push_back(cubemap->GetRenderTexture());\n        }\n        \n        std::vector<std::pair<const RenderShader*, RenderPasses>> renderShaders;\n        renderShaders.reserve(m_customShaders.size());\n        for(const auto& shader : m_customShaders)\n        {\n            renderShaders.push_back(std::make_pair(shader.first->GetRenderShader(), shader.second));\n        }\n        \n        RenderShaderVariablesUPtr renderShaderVariables(new RenderShaderVariables(m_floatVars, m_vec2Vars, m_vec3Vars, m_vec4Vars, m_mat4Vars, m_colourVars));\n        \n        m_renderMaterialGroup = m_renderMaterialGroupManager->CreateCustomRenderMaterialGroup(m_customShaderFallbackType, m_customShaderVertexFormat, renderShaders, renderTextures, renderCubemaps,\n                                                                                              m_isAlphaBlendingEnabled, m_isColWriteEnabled, m_isDepthWriteEnabled, m_isDepthTestEnabled, m_isFaceCullingEnabled, m_isStencilTestEnabled,\n                                                                                              m_depthTestFunc,\n                                                                                              m_srcBlendMode, m_dstBlendMode,\n                                                                                              m_stencilFailOp, m_stencilDepthFailOp, m_stencilPassOp, m_stencilTestFunc, m_stencilTestFuncRef, m_stencilTestFuncMask,\n                                                                                              m_cullFace, m_emissive, m_ambient, m_diffuse, m_specular, std::move(renderShaderVariables));\n    }\n    //----------------------------------------------------------\n    //----------------------------------------------------------\n    void Material::DestroyRenderMaterialGroup() const noexcept\n    {\n        if (m_renderMaterialGroup)\n        {\n            auto renderMaterialGroupManager = Application::Get()->GetSystem<RenderMaterialGroupManager>();\n            CS_ASSERT(renderMaterialGroupManager, \"RenderMaterialGroupManager is required.\");\n            \n            renderMaterialGroupManager->DestroyRenderMaterialGroup(std::move(m_renderMaterialGroup));\n        }\n    }\n    //----------------------------------------------------------\n    //----------------------------------------------------------\n    bool Material::VerifyTexturesAreValid() const noexcept\n    {\n        if(m_textures.size() != m_cachedRenderTextures.size())\n        {\n            return false;\n        }\n        else\n        {\n            u32 cacheIndex = 0;\n            for(u32 i = 0; i < m_textures.size(); ++i, ++cacheIndex)\n            {\n                const auto& texture = m_textures[i];\n                if(texture->GetRenderTexture() != m_cachedRenderTextures[cacheIndex])\n                {\n                    return false;\n                }\n            }\n            \n            for(u32 i = 0; i < m_cubemaps.size(); ++i, ++cacheIndex)\n            {\n                const auto& cubemap = m_cubemaps[i];\n                if(cubemap->GetRenderTexture() != m_cachedRenderTextures[cacheIndex])\n                {\n                    return false;\n                }\n            }\n        }\n        \n        return true;\n    }\n    //----------------------------------------------------------\n    //----------------------------------------------------------\n    Material::~Material() noexcept\n    {\n        DestroyRenderMaterialGroup();\n    }\n}\n\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Material/Material.h",
    "content": "//\n//  Material.h\n//  ChilliSource\n//  Created by Scott Downie on 14/10/2010.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2010 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_MATERIAL_MATERIAL_H_\n#define _CHILLISOURCE_RENDERING_MATERIAL_MATERIAL_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Base/Colour.h>\n#include <ChilliSource/Core/Math/Vector2.h>\n#include <ChilliSource/Core/Math/Vector3.h>\n#include <ChilliSource/Core/Math/Vector4.h>\n#include <ChilliSource/Core/Math/Matrix4.h>\n#include <ChilliSource/Core/Memory/UniquePtr.h>\n#include <ChilliSource/Core/Resource/Resource.h>\n#include <ChilliSource/Rendering/Model/VertexFormat.h>\n#include <ChilliSource/Rendering/Base/RenderPasses.h>\n#include <ChilliSource/Rendering/Material/MaterialShadingType.h>\n\n#include <array>\n#include <unordered_map>\n\nnamespace ChilliSource\n{\n    //----------------------------------------------------------\n    /// Holds the render state of an object. Used to organise\n    /// the rendering of objects and to alter their surface\n    /// appearance via lighting, texture, shader, etc.\n    ///\n    /// NOTE: Textures and cubemaps are different types with their own\n    /// data and methods but both will use up texture units on OpenGL.\n    ///\n    /// @author S Downie\n    //----------------------------------------------------------\n    class Material final : public Resource\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(Material);\n        \n        //----------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Comparison Type\n        ///\n        /// @return Whether the class matches the comparison type\n        //----------------------------------------------------------\n        bool IsA(InterfaceIDType in_interfaceId) const override;\n        //----------------------------------------------------------\n        ///Sets the shading type that this material uses.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param in_shadingType - The shading type to use.\n        //----------------------------------------------------------\n        void SetShadingType(MaterialShadingType in_shadingType) noexcept;\n        //----------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The shading type that this material uses.\n        //----------------------------------------------------------\n        MaterialShadingType GetShadingType() const noexcept;\n        //----------------------------------------------------------\n        /// Clear the textures from the slots\n        ///\n        /// @author S Downie\n        //----------------------------------------------------------\n        void RemoveAllTextures() noexcept;\n        //----------------------------------------------------------\n        /// Add the texture to the end of the list. The index of the\n        /// texture in the list corresponds to the texture handle in\n        /// the shader.\n        ///\n        /// NOTE: Due to devices supporting different numbers of\n        /// textures it is possible that textures at the end will be\n        /// ignored by the renderer.\n        ///\n        /// @author S Downie\n        ///\n        /// @param Texture\n        //----------------------------------------------------------\n        void AddTexture(const TextureCSPtr& in_texture) noexcept;\n        //----------------------------------------------------------\n        /// Overwrite an existing added texture with the given\n        /// texture at the given index. If a texture does not\n        /// already exist at that slot then it asserts\n        ///\n        /// @author S Downie\n        ///\n        /// @param Texture\n        /// @param Index\n        //----------------------------------------------------------\n        void SetTexture(const TextureCSPtr& in_texture, u32 in_texIndex = 0) noexcept;\n        //----------------------------------------------------------\n        /// Get Texture at the given index. Will assert\n        /// if index is out of bounds.\n        ///\n        /// @author S Downie\n        ///\n        /// @param Texture index\n        ///\n        /// @return Texture or null\n        //----------------------------------------------------------\n        const TextureCSPtr& GetTexture(u32 in_texIndex = 0) const noexcept;\n        //----------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Number of textures set on the material\n        //----------------------------------------------------------\n        u32 GetNumTextures() const noexcept;;\n\n        ///\n        /// Remove all cubemaps from the material\n        ///\n        void RemoveAllCubemaps() noexcept;\n        \n        ///\n        /// Add the texture to the end of the list. The index of the\n        /// texture in the list corresponds to the cubemaps handle in the shader. e.g. u_cubemap[0-N]\n        ///\n        /// NOTE: Due to devices supporting different numbers of textures it is possible that cubemaps at the end will be ignored by the renderer.\n        /// NOTE: Although cubemaps and textures are different objects they share the same slot system on OpenGL for example you could\n        /// have 8 textures and 0 cubemaps or 5 textures and 3 cubemaps.\n        ///\n        /// @param cubemap\n        ///     Cubemap resource to add\n        ///\n        void AddCubemap(const CubemapCSPtr& cubemap) noexcept;\n        \n        ///\n        /// Overwrite an existing added cubemap with the given cubemap at the given index. If a cubemap does not\n        /// already exist at that slot then it asserts\n        ///\n        /// @param cubemap\n        ///     Cubemap resource to set\n        /// @param index\n        ///     Slot index to overwrite\n        ///\n        void SetCubemap(const CubemapCSPtr& cubemap, u32 index = 0) noexcept;\n        \n        ///\n        /// Get cubemap at the given index. Will assert if index is out of bounds.\n        ///\n        /// @param index\n        ///     Index to fetch from\n        ///\n        /// @return Cubemap at given index or null\n        ///\n        const CubemapCSPtr& GetCubemap(u32 index = 0) const noexcept;\n        \n        ///\n        /// @return Number of cubemaps set on the material\n        ///\n        u32 GetNumCubemaps() const noexcept;\n        \n        //----------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Whether the object has transparency enabled \n        //----------------------------------------------------------\n        bool IsTransparencyEnabled() const noexcept;\n        //----------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Whether transparency is enabled\n        //----------------------------------------------------------\n        void SetTransparencyEnabled(bool in_enable) noexcept;\n        //----------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Whether the object has colour write enabled\n        //----------------------------------------------------------\n        bool IsColourWriteEnabled() const noexcept;\n        //----------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Whether colour write is enabled\n        //----------------------------------------------------------\n        void SetColourWriteEnabled(bool in_enable) noexcept;\n        //----------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Whether the object has depth write enabled \n        //----------------------------------------------------------\n        bool IsDepthWriteEnabled() const noexcept;\n        //----------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Whether depth write is enabled\n        //----------------------------------------------------------\n        void SetDepthWriteEnabled(bool in_enable) noexcept;\n        //----------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Whether the object has depth test enabled \n        //----------------------------------------------------------\n        bool IsDepthTestEnabled() const noexcept;\n        //----------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Whether depth test is enabled\n        //----------------------------------------------------------\n        void SetDepthTestEnabled(bool in_enable) noexcept;\n        //----------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Whether the object has face culling enabled \n        //----------------------------------------------------------\n        bool IsFaceCullingEnabled() const noexcept;\n        //----------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Whether face culling is enabled\n        //----------------------------------------------------------\n        void SetFaceCullingEnabled(bool in_enable) noexcept;\n    \n        /// @return Whether or not to perform stencil testing\n        ///\n        bool IsStencilTestEnabled() const noexcept { return m_isStencilTestEnabled; }\n\n        /// @param in_enable\n        ///     Whether to turn stencil testing on or off\n        ///\n        void SetStencilTestEnabled(bool in_enable) noexcept { m_isStencilTestEnabled = in_enable; }\n        \n        /// @param Function that handles comparing depth values for pass/fail testing\n        ///\n        void SetDepthTestFunc(TestFunc testFunc) noexcept { m_depthTestFunc = testFunc; }\n        \n        /// @return Function that handles comparing depth values for pass/fail testing\n        ///\n        TestFunc GetDepthTestFunc() const noexcept { return m_depthTestFunc; }\n        \n        //----------------------------------------------------------\n        /// Tells the render system how to blend pixels based on the\n        /// source and destination mode\n        ///\n        /// @author S Downie\n        ///\n        /// @param Source mode\n        /// @param Destination mode\n        //----------------------------------------------------------\n        void SetBlendModes(BlendMode in_source, BlendMode in_dest) noexcept;\n        //----------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Source mode of blending functions\n        //----------------------------------------------------------\n        BlendMode GetSourceBlendMode() const noexcept;\n        //----------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Dest BlendMode of blending functions\n        //----------------------------------------------------------\n        BlendMode GetDestBlendMode() const noexcept;\n        \n        /// Tells the render system what action to take with the result of a stencil test\n        ///\n        /// @param stencilFail\n        ///     Action to take if the stencil test fails\n        /// @param depthFail\n        ///     Action to take if the stencil test passes but depth test fails\n        /// @param pass\n        ///     Action to take when stencil and depth tests pass\n        ///\n        void SetStencilPostTestOps(StencilOp stencilFail, StencilOp depthFail, StencilOp pass) noexcept;\n        \n        /// Tells the render system what comparison function to apply when performing a stencil test\n        ///\n        /// @param testFunc\n        ///     Function that uses the value in the stencil and the ref to decide whether a comparison passes or fails\n        /// @param ref\n        ///     Comparison value for the test func\n        /// @param mask\n        ///     ANDed with the ref and the sampled value prior to the comparison test\n        ///\n        void SetStencilTestFunc(TestFunc testFunc, s32 ref, u32 mask) noexcept;\n        \n        /// @return Op to use if stencil test fails\n        ///\n        StencilOp GetStencilFailOp() const noexcept { return m_stencilFailOp; }\n        \n        /// @return Op to use if stencil test passes but depth test fails\n        ///\n        StencilOp GetStencilDepthFailOp() const noexcept { return m_stencilDepthFailOp; }\n        \n        /// @return Op to use if stencil and depth tests pass\n        ///\n        StencilOp GetStencilPassOp() const noexcept { return m_stencilPassOp; }\n        \n        /// @return Function that handles comparing stencil values for pass/fail testing\n        ///\n        TestFunc GetStencilTestFunc() const noexcept { return m_stencilTestFunc; }\n        \n        /// @return The comparison value for the stencil test function\n        ///\n        s32 GetStencilTestFuncRef() const noexcept { return m_stencilTestFuncRef; }\n        \n        /// @return The mask that is ANDed with the ref and stored value\n        ///\n        u32 GetStencilTestFuncMask() const noexcept { return m_stencilTestFuncMask; }\n        \n        //----------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param The face of the polygon that should be culled\n        /// if culling is enabled\n        //----------------------------------------------------------\n        void SetCullFace(CullFace in_face) noexcept;\n        //----------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return The face of the polygon that should be culled\n        /// if face culling is enabled\n        //----------------------------------------------------------\n        CullFace GetCullFace() const noexcept;\n        //----------------------------------------------------------\n        /// The emissive colour is used to simulate the light emitted\n        /// by the surface of an object (effectively its colour)\n        ///\n        /// @author S Downie\n        ///\n        /// @param Emissive colour used in ambient pass\n        //----------------------------------------------------------\n        void SetEmissive(const Colour& in_emissive) noexcept;\n        //----------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Emissive colour used in ambient pass\n        //----------------------------------------------------------\n        const Colour& GetEmissive() const noexcept;\n        //----------------------------------------------------------\n        /// The ambient colour is used to simulate the light absorbed\n        /// by the object from light reflections in the scene.\n        ///\n        /// @author S Downie\n        ///\n        /// @param Ambient colour used in ambient pass\n        //----------------------------------------------------------\n        void SetAmbient(const Colour& in_ambient) noexcept;\n        //----------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Ambient colour used in ambient pass\n        //----------------------------------------------------------\n        const Colour& GetAmbient() const noexcept;\n        //----------------------------------------------------------\n        /// The diffuse colour is used to simulate the light absorbed\n        /// by the object directly from the light source.\n        ///\n        /// @author S Downie\n        ///\n        /// @param Diffuse light colour used in subsequent light passes\n        //----------------------------------------------------------\n        void SetDiffuse(const Colour& in_diffuse) noexcept;\n        //----------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Diffuse light colour used in subsequent light passes\n        //----------------------------------------------------------\n        const Colour& GetDiffuse() const noexcept;\n        //----------------------------------------------------------\n        /// The specular colour is used to simulate the light reflected\n        /// back by the object creating a highlight.\n        ///\n        /// @author S Downie\n        ///\n        /// @param Specular light colour used in subsequent light passes\n        //----------------------------------------------------------\n        void SetSpecular(const Colour& in_specular) noexcept;\n        //----------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Specular light colour used in subsequent light passes\n        //----------------------------------------------------------\n        const Colour& GetSpecular() const noexcept;\n        //-----------------------------------------------------------\n        /// Sets the custom shaders vertex format and fallback type.\n        /// Shaders are then added via AddCustomShaders\n        /// The shading type must be set to custom or this will assert.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param vertexFormat - The vertex format that the custom shader will be applied to.\n        /// @param fallbackType - The shader types to fallback on for any passes not specified in shaders\n        //-----------------------------------------------------------\n        void PrepCustomShaders(const VertexFormat& vertexFormat, MaterialShadingType fallbackType) noexcept;\n        //-----------------------------------------------------------\n        /// Add the custom shaders for the given passes.\n        /// The shading type must be set to custom or this will assert.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param shader - The custom shader.\n        /// @param pass - The render pass that the shader is bound to\n        //-----------------------------------------------------------\n        void AddCustomShader(const ShaderCSPtr& shader, RenderPasses pass) noexcept;\n        //-----------------------------------------------------------\n        /// Set the value of the variable with the given name to the\n        /// given value\n        ///\n        /// @author S Downie\n        ///\n        /// @param Variable name\n        /// @param Float value\n        //-----------------------------------------------------------\n        void SetShaderVar(const std::string& in_varName, f32 in_value) noexcept;\n        //-----------------------------------------------------------\n        /// Set the value of the variable with the given name to the\n        /// given value\n        ///\n        /// @author S Downie\n        ///\n        /// @param Variable name\n        /// @param Vec2 value\n        //-----------------------------------------------------------\n        void SetShaderVar(const std::string& in_varName, const Vector2& in_value) noexcept;\n        //-----------------------------------------------------------\n        /// Set the value of the variable with the given name to the\n        /// given value\n        ///\n        /// @author S Downie\n        ///\n        /// @param Variable name\n        /// @param Vec3 value\n        //-----------------------------------------------------------\n        void SetShaderVar(const std::string& in_varName, const Vector3& in_value) noexcept;\n        //-----------------------------------------------------------\n        /// Set the value of the variable with the given name to the\n        /// given value\n        ///\n        /// @author S Downie\n        ///\n        /// @param Variable name\n        /// @param Vec4 value\n        //-----------------------------------------------------------\n        void SetShaderVar(const std::string& in_varName, const Vector4& in_value) noexcept;\n        //-----------------------------------------------------------\n        /// Set the value of the variable with the given name to the\n        /// given value\n        ///\n        /// @author S Downie\n        ///\n        /// @param Variable name\n        /// @param Mat4 value\n        //-----------------------------------------------------------\n        void SetShaderVar(const std::string& in_varName, const Matrix4& in_value) noexcept;\n        //-----------------------------------------------------------\n        /// Set the value of the variable with the given name to the\n        /// given value\n        ///\n        /// @author S Downie\n        ///\n        /// @param Variable name\n        /// @param Colour value\n        //-----------------------------------------------------------\n        void SetShaderVar(const std::string& in_varName, const Colour& in_value) noexcept;\n        //-----------------------------------------------------------\n        /// Generates the RenderMaterialGroup that describes this\n        /// material. This generated RenderMaterialGroup is cached\n        /// and only re-generated when necessary.\n        ///\n        /// This is not thread safe and should only be called from\n        /// the main thread.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @return The RenderMaterialGroup that describes this\n        /// material.\n        //-----------------------------------------------------------\n        const RenderMaterialGroup* GetRenderMaterialGroup() const noexcept;\n        \n        ~Material() noexcept;\n        \n    private:\n        friend class ResourcePool;\n        //----------------------------------------------------------\n        /// Factory method to create an new instance of an empty\n        /// material resource. Only called by the resource pool\n        ///\n        /// @author S Downie\n        //----------------------------------------------------------\n        static MaterialUPtr Create();\n        //----------------------------------------------------------\n        /// Private constructor to ensure that the factory method\n        /// is used\n        ///\n        /// @author S Downie\n        //----------------------------------------------------------\n        Material() noexcept;\n        \n        ///\n        /// Generates an skybox render material group using the\n        /// current material setting. If any of the settings are\n        /// not allowed in an skybox render material group then this\n        /// will assert.\n        ///\n        void CreateSkyboxRenderMaterialGroup() const noexcept;\n        //----------------------------------------------------------\n        /// Generates an unlit render material group using the\n        /// current material setting. If any of the settings are\n        /// not allowed in an unlit render material group then this\n        /// will assert.\n        ///\n        /// @author Ian Copland\n        //----------------------------------------------------------\n        void CreateUnlitRenderMaterialGroup() const noexcept;\n        //----------------------------------------------------------\n        /// Generates an blinn render material group using the\n        /// current material setting. If any of the settings are\n        /// not allowed in an blinn render material group then this\n        /// will assert.\n        ///\n        /// @author Ian Copland\n        //----------------------------------------------------------\n        void CreateBlinnRenderMaterialGroup() const noexcept;\n        //----------------------------------------------------------\n        /// Generates a custom render material group using the\n        /// current material setting. \n        ///\n        /// @author Ian Copland\n        //----------------------------------------------------------\n        void CreateCustomRenderMaterialGroup() const noexcept;\n        //----------------------------------------------------------\n        /// Destroys the render material group if there is one.\n        ///\n        /// @author Ian Copland\n        //----------------------------------------------------------\n        void DestroyRenderMaterialGroup() const noexcept;\n        //----------------------------------------------------------\n        /// Checks if the current textures are still valid, i.e. the containing\n        /// render textures match the ones cached on creation.\n        ///\n        /// @author HMcLaughlin\n        ///\n        /// @return If the current texture list is invalid\n        //----------------------------------------------------------\n        bool VerifyTexturesAreValid() const noexcept;\n        \n        std::vector<TextureCSPtr> m_textures;\n        std::vector<CubemapCSPtr> m_cubemaps;\n        \n        MaterialShadingType m_shadingType = MaterialShadingType::k_custom;\n        \n        Colour m_emissive;\n        Colour m_ambient;\n        Colour m_diffuse;\n        Colour m_specular;\n        \n        TestFunc m_depthTestFunc;\n        \n        BlendMode m_srcBlendMode;\n        BlendMode m_dstBlendMode;\n        \n        CullFace m_cullFace;\n        \n        StencilOp m_stencilFailOp;\n        StencilOp m_stencilDepthFailOp;\n        StencilOp m_stencilPassOp;\n        s32 m_stencilTestFuncRef = 1;\n        u32 m_stencilTestFuncMask = 0xff;\n        TestFunc m_stencilTestFunc;\n\n        bool m_isAlphaBlendingEnabled = false;\n        bool m_isColWriteEnabled = true;\n        bool m_isDepthWriteEnabled = true;\n        bool m_isDepthTestEnabled = true;\n        bool m_isFaceCullingEnabled = true;\n        bool m_isStencilTestEnabled = false;\n        \n        std::vector<std::pair<ShaderCSPtr, RenderPasses>> m_customShaders;\n        VertexFormat m_customShaderVertexFormat = VertexFormat::k_sprite;\n        MaterialShadingType m_customShaderFallbackType;\n        \n        std::unordered_map<std::string, f32> m_floatVars;\n        std::unordered_map<std::string, Vector2> m_vec2Vars;\n        std::unordered_map<std::string, Vector3> m_vec3Vars;\n        std::unordered_map<std::string, Vector4> m_vec4Vars;\n        std::unordered_map<std::string, Matrix4> m_mat4Vars;\n        std::unordered_map<std::string, Colour> m_colourVars;\n        \n        RenderMaterialGroupManager* m_renderMaterialGroupManager = nullptr;\n        \n        //TODO: When the material system is improved, remove the need to make this mutable.\n        mutable bool m_isCacheValid = false;\n        mutable bool m_isVariableCacheValid = true;\n        mutable UniquePtr<RenderMaterialGroup> m_renderMaterialGroup;\n        mutable std::vector<const RenderTexture*> m_cachedRenderTextures;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Material/MaterialFactory.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2013 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Material/MaterialFactory.h>\n\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/Resource/ResourcePool.h>\n#include <ChilliSource/Rendering/Base/CullFace.h>\n#include <ChilliSource/Rendering/Base/TestFunc.h>\n#include <ChilliSource/Rendering/Material/Material.h>\n#include <ChilliSource/Rendering/Shader/Shader.h>\n\nnamespace ChilliSource\n{\n    CS_DEFINE_NAMEDTYPE(MaterialFactory);\n    \n    //------------------------------------------------------------------------------\n    MaterialFactoryUPtr MaterialFactory::Create() noexcept\n    {\n        return MaterialFactoryUPtr(new MaterialFactory());\n    }\n    \n    //------------------------------------------------------------------------------\n    bool MaterialFactory::IsA(InterfaceIDType interfaceId) const noexcept\n    {\n        return interfaceId == MaterialFactory::InterfaceID;\n    }\n    \n    //------------------------------------------------------------------------------\n    MaterialCSPtr MaterialFactory::CreateUnlit(const std::string& uniqueId, const TextureCSPtr& texture, bool isTransparent, const Colour& colour) const noexcept\n    {\n        MaterialSPtr material(CreateCustom(uniqueId));\n        material->SetShadingType(MaterialShadingType::k_unlit);\n        material->AddTexture(texture);\n        material->SetTransparencyEnabled(isTransparent);\n        material->SetEmissive(colour);\n        material->SetLoadState(Resource::LoadState::k_loaded);\n        return material;\n    }\n    \n    //------------------------------------------------------------------------------\n    MaterialCSPtr MaterialFactory::CreateSkybox(const std::string& uniqueId, const CubemapCSPtr& cubemap) const noexcept\n    {\n        MaterialSPtr material(CreateCustom(uniqueId));\n        material->SetShadingType(MaterialShadingType::k_skybox);\n        material->AddCubemap(cubemap);\n        material->SetTransparencyEnabled(false);\n        material->SetDepthWriteEnabled(false);\n        material->SetDepthTestFunc(TestFunc::k_lessEqual);\n        material->SetLoadState(Resource::LoadState::k_loaded);\n        return material;\n    }\n    \n    //------------------------------------------------------------------------------\n    MaterialCSPtr MaterialFactory::CreateBlinn(const std::string& uniqueId, const TextureCSPtr& texture, const Colour& emissiveColour, const Colour& ambientColour, const Colour& diffuseColour,\n                              const Colour& specularColour, f32 shininess) const noexcept\n    {\n        MaterialSPtr material(CreateCustom(uniqueId));\n        material->SetShadingType(MaterialShadingType::k_blinn);\n        material->AddTexture(texture);\n        material->SetEmissive(emissiveColour);\n        material->SetAmbient(ambientColour);\n        material->SetDiffuse(diffuseColour);\n        material->SetSpecular(Colour(specularColour.r, specularColour.g, specularColour.b, shininess));\n        material->SetLoadState(Resource::LoadState::k_loaded);\n        return material;\n    }\n    \n    //------------------------------------------------------------------------------\n    MaterialSPtr MaterialFactory::CreateCustom(const std::string& uniqueId) const noexcept\n    {\n        ResourcePool* resourcePool = Application::Get()->GetResourcePool();\n        return resourcePool->CreateResource<Material>(uniqueId);\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Material/MaterialFactory.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2013 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_MATERIAL_MATERIALFACTORY_H\n#define _CHILLISOURCE_RENDERING_MATERIAL_MATERIALFACTORY_H\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Base/Colour.h>\n#include <ChilliSource/Core/System/AppSystem.h>\n\nnamespace ChilliSource\n{\n    /// A convenience factory for creating new materials of the requested types.\n    ///\n    /// This is not thread-safe and must be called from the main thread.\n    ///\n    class MaterialFactory final : public AppSystem\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(MaterialFactory);\n\n        /// Allows querying of whether or not this system implements the interface described by the\n        /// given interface Id. Typically this is not called directly as the templated equivalent\n        /// IsA<Interface>() is preferred.\n        ///\n        /// @param interfaceId\n        ///     The Id of the interface.\n        ///\n        /// @return Whether or not the interface is implemented.\n        ///\n        bool IsA(InterfaceIDType interfaceId) const noexcept override;\n        \n        /// Creates a new material with unlit shaders that can be used with static, animated and\n        /// sprites.\n        ///\n        /// @param uniqueId\n        ///     The unique Id that will be used to identify the material in the resource pool. Note\n        ///     that Id's which are prefixed with an underscore (_) are reserved from engine use.\n        /// @param texture\n        ///     The texture that the material will use.\n        /// @param isTransparent\n        ///     Whether or not transparency is enabled for the material.\n        /// @param colour\n        ///     (Optional) The colour of the material. Defaults to white.\n        ///\n        /// @return The newly created material.\n        ///\n        MaterialCSPtr CreateUnlit(const std::string& uniqueId, const TextureCSPtr& texture, bool isTransparent, const Colour& colour = Colour::k_white) const noexcept;\n        \n        /// Creates a new material with skybox shaders that can be used with static models\n        /// in order to render a skybox behind all other objects in the scene and infinetely far away.\n        ///\n        /// @param uniqueId\n        ///     The unique Id that will be used to identify the material in the resource pool. Note\n        ///     that Id's which are prefixed with an underscore (_) are reserved from engine use.\n        /// @param cubemap\n        ///     The cubemap that the material will use.\n        ///\n        /// @return The newly created material.\n        ///\n        MaterialCSPtr CreateSkybox(const std::string& uniqueId, const CubemapCSPtr& cubemap) const noexcept;\n        \n        /// Creates a new material with blinn shaders that can be used with static and animated meshes.\n        ///\n        /// @param uniqueId\n        ///     The unique Id that will be used to identify the material in the resource pool. Note\n        ///     that Id's which are prefixed with an underscore (_) are reserved from engine use.\n        /// @param texture\n        ///     The texture that the material will use.\n        /// @param ambientColour\n        ///     The ambient colour.\n        /// @param emissiveColour\n        ///     The ambient colour.\n        /// @param diffuseColour\n        ///     The diffuse colour.\n        /// @param specularColour\n        ///     The specular colour, note that the alpha value is ignored.\n        /// @param shininess\n        ///     The specular shininess of the material.\n        ///\n        /// @return The newly created material.\n        ///\n        MaterialCSPtr CreateBlinn(const std::string& uniqueId, const TextureCSPtr& texture, const Colour& emissiveColour, const Colour& ambientColour, const Colour& diffuseColour,\n                                  const Colour& specularColour, f32 shininess) const noexcept;\n        \n        /// Creates a new custom material, on which all shader settings can be changed. The shading\n        /// type defaults to Unlit, but other types can be set. The types of mesh that the material\n        /// can be used with depends on the shading type set.\n        ///\n        /// The material must have it's load state set manually to loaded before it can be used.\n        ///\n        /// @param uniqueId\n        ///     The unique Id that will be used to identify the material in the resource pool. Note\n        ///     that Id's which are prefixed with an underscore (_) are reserved from engine use.\n        ///\n        /// @return The new empty, mutable material.\n        ///\n        MaterialSPtr CreateCustom(const std::string& uniqueId) const noexcept;\n        \n    private:\n        friend class Application;\n        \n        /// A factory method for creating new instances of the system. This must be called by\n        /// Application.\n        ///\n        /// @return The new instance of the system.\n        ///\n        static MaterialFactoryUPtr Create() noexcept;\n        \n        MaterialFactory() = default;\n    };\n}\n\n#endif \n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Material/MaterialProvider.cpp",
    "content": "//\n//  MaterialProvider.cpp\n//  ChilliSource\n//  Created by Scott Downie on 22/11/2010.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2010 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Material/MaterialProvider.h>\n\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/Base/Colour.h>\n#include <ChilliSource/Core/String/StringParser.h>\n#include <ChilliSource/Core/Threading/TaskScheduler.h>\n#include <ChilliSource/Core/Resource/ResourcePool.h>\n#include <ChilliSource/Core/XML/XMLUtils.h>\n#include <ChilliSource/Rendering/Base/BlendMode.h>\n#include <ChilliSource/Rendering/Base/CullFace.h>\n#include <ChilliSource/Rendering/Base/RenderCapabilities.h>\n#include <ChilliSource/Rendering/Base/TestFunc.h>\n#include <ChilliSource/Rendering/Material/Material.h>\n#include <ChilliSource/Rendering/Shader/Shader.h>\n#include <ChilliSource/Rendering/Texture/Cubemap.h>\n#include <ChilliSource/Rendering/Texture/CubemapResourceOptions.h>\n#include <ChilliSource/Rendering/Texture/TextureResourceOptions.h>\n#include <ChilliSource/Rendering/Texture/TextureType.h>\n\nnamespace ChilliSource\n{\n    namespace\n    {\n        const std::string k_materialExtension(\"csmaterial\");\n        \n        //----------------------------------------------------------------------------\n        /// The resource types supported by materials\n        //----------------------------------------------------------------------------\n        enum class ResourceType\n        {\n            k_shader,\n            k_texture\n        };\n        //-------------------------------------------------------------------------\n        /// Holds the description of a generic resource load from the supported types\n        ///\n        /// @author S Downie\n        //-------------------------------------------------------------------------\n        struct ChainedLoadDesc\n        {\n            ResourceType m_type;\n            std::string m_filePath;\n            StorageLocation m_location;\n            bool m_shouldMipMap;\n            TextureFilterMode m_filterMode;\n            TextureWrapMode m_wrapModeU;\n            TextureWrapMode m_wrapModeV;\n            RenderPasses m_pass;\n            TextureType m_textureType;\n        };\n        //----------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param String describing mode\n        ///\n        /// @return Blend mode\n        //----------------------------------------------------------------------------\n        BlendMode ConvertStringToBlendMode(const std::string& in_blendMode)\n        {\n            constexpr char k_zero[] = \"zero\";\n            constexpr char k_one[] = \"one\";\n            constexpr char k_sourceColour[] = \"sourcecolour\";\n            constexpr char k_oneMinusSourceColour[] = \"oneminussourcecolour\";\n            constexpr char k_sourceAlpha[] = \"sourcealpha\";\n            constexpr char k_oneMinusSourceAlpha[] = \"oneminussourcealpha\";\n            constexpr char k_destColour[] = \"destcolour\";\n            constexpr char k_oneMinusDestColour[] = \"oneminusdestcolour\";\n            constexpr char k_destAlpha[] = \"destalpha\";\n            constexpr char k_oneMinusDestAlpha[] = \"oneminusdestalpha\";\n            \n            std::string blendModeLower = in_blendMode;\n            StringUtils::ToLowerCase(blendModeLower);\n            \n            if (blendModeLower == k_zero)\n            {\n                return BlendMode::k_zero;\n            }\n            else if (blendModeLower == k_one)\n            {\n                return BlendMode::k_one;\n            }\n            else if (blendModeLower == k_sourceColour)\n            {\n                return BlendMode::k_sourceCol;\n            }\n            else if (blendModeLower == k_oneMinusSourceColour)\n            {\n                return BlendMode::k_oneMinusSourceCol;\n            }\n            else if (blendModeLower == k_sourceAlpha)\n            {\n                return BlendMode::k_sourceAlpha;\n            }\n            else if (blendModeLower == k_oneMinusSourceAlpha)\n            {\n                 return BlendMode::k_oneMinusSourceAlpha;\n            }\n            else if (blendModeLower == k_destColour)\n            {\n                return BlendMode::k_destCol;\n            }\n            else if (blendModeLower == k_oneMinusDestColour)\n            {\n                return BlendMode::k_oneMinusDestCol;\n            }\n            else if (blendModeLower == k_destAlpha)\n            {\n                return BlendMode::k_destAlpha;\n            }\n            else if (blendModeLower == k_oneMinusDestAlpha)\n            {\n                return BlendMode::k_oneMinusDestAlpha;\n            }\n            \n            CS_LOG_FATAL(\"Invalid BlendMode: \" + in_blendMode);\n            return BlendMode::k_one;\n        }\n        //----------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param String describing func\n        ///\n        /// @return Depth test func\n        //----------------------------------------------------------------------------\n        TestFunc ConvertStringToDepthFunc(const std::string& depthFunc)\n        {\n            std::string depthFuncLower = depthFunc;\n            StringUtils::ToLowerCase(depthFuncLower);\n            \n            if(depthFuncLower == \"never\")\n            {\n                return TestFunc::k_never;\n            }\n            else if(depthFuncLower == \"less\")\n            {\n                return TestFunc::k_less;\n            }\n            else if(depthFuncLower == \"lequal\")\n            {\n                return TestFunc::k_lessEqual;\n            }\n            else if(depthFuncLower == \"greater\")\n            {\n                return TestFunc::k_greater;\n            }\n            else if(depthFuncLower == \"gequal\")\n            {\n                return TestFunc::k_greaterEqual;\n            }\n            else if(depthFuncLower == \"equal\")\n            {\n                return TestFunc::k_equal;\n            }\n            else if(depthFuncLower == \"notequal\")\n            {\n                return TestFunc::k_notEqual;\n            }\n            else if(depthFuncLower == \"always\")\n            {\n                return TestFunc::k_always;\n            }\n            \n            CS_LOG_FATAL(\"Invalid DepthTestFunc: \" + depthFunc);\n            return TestFunc::k_never;\n        }\n        //----------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param String describing cull function\n        ///\n        /// @return Cull face type\n        //----------------------------------------------------------------------------\n        CullFace ConvertStringToCullFace(const std::string& in_cullFace)\n        {\n            constexpr char k_front[] = \"front\";\n            constexpr char k_back[] = \"back\";\n            \n            std::string cullFaceLower = in_cullFace;\n            StringUtils::ToLowerCase(cullFaceLower);\n            \n            if (cullFaceLower == k_front)\n            {\n                return CullFace::k_front;\n            }\n            else if (cullFaceLower == k_back)\n            {\n                return CullFace::k_back;\n            }\n            \n            CS_LOG_FATAL(\"Invalid CullFace: \" + in_cullFace);\n            return CullFace::k_front;\n        }\n        //----------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param A string describing the texture wrap mode.\n        ///\n        /// @return The wrap mode. If the string was not a valid wrap mode this will\n        /// default to clamp.\n        //----------------------------------------------------------------------------\n        TextureWrapMode ConvertStringToWrapMode(const std::string& in_wrapModeString)\n        {\n            constexpr char k_clamp[] = \"clamp\";\n            constexpr char k_repeat[] = \"repeat\";\n            \n            std::string lowerWrapModeString = in_wrapModeString;\n            StringUtils::ToLowerCase(lowerWrapModeString);\n            \n            if (lowerWrapModeString == k_clamp)\n            {\n                return TextureWrapMode::k_clamp;\n            }\n            else if (lowerWrapModeString == k_repeat)\n            {\n                return TextureWrapMode::k_repeat;\n            }\n            \n            CS_LOG_FATAL(\"Invalid WrapMode: \" + in_wrapModeString);\n            return TextureWrapMode::k_clamp;\n        }\n        //----------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param A string describing the texture filter mode.\n        ///\n        /// @return The filter mode. If the string was not a valid filter mode this will\n        /// default to bilinear.\n        //----------------------------------------------------------------------------\n        TextureFilterMode ConvertStringToFilterMode(const std::string& in_filterModeString)\n        {\n            constexpr char k_nearest[] = \"nearest\";\n            constexpr char k_bilinear[] = \"bilinear\";\n            \n            std::string lowerFilterModeString = in_filterModeString;\n            StringUtils::ToLowerCase(lowerFilterModeString);\n            \n            if (lowerFilterModeString == k_nearest)\n            {\n                return TextureFilterMode::k_nearest;\n            }\n            else if (lowerFilterModeString == k_bilinear)\n            {\n                return TextureFilterMode::k_bilinear;\n            }\n            \n            CS_LOG_FATAL(\"Invalid FilterMode: \" + in_filterModeString);\n            return TextureFilterMode::k_bilinear;\n        }\n        //----------------------------------------------------------------------------\n        /// Returns the shading type for the given material type.\n        ///\n        /// @param in_materialType - The material type.\n        ///\n        /// @return The shading type.\n        //----------------------------------------------------------------------------\n        MaterialShadingType ConvertStringToShadingType(const std::string& in_materialType) noexcept\n        {\n            constexpr char k_unlit[] = \"unlit\";\n            constexpr char k_blinn[] = \"blinn\";\n            constexpr char k_custom[] = \"custom\";\n            constexpr char k_skybox[] = \"skybox\";\n            \n            auto materialTypeLower = in_materialType;\n            StringUtils::ToLowerCase(materialTypeLower);\n            \n            if (materialTypeLower == k_unlit)\n            {\n                return MaterialShadingType::k_unlit;\n            }\n            else if (materialTypeLower == k_blinn)\n            {\n                return MaterialShadingType::k_blinn;\n            }\n            else if (materialTypeLower == k_custom)\n            {\n                return MaterialShadingType::k_custom;\n            }\n            else if (materialTypeLower == k_skybox)\n            {\n                return MaterialShadingType::k_skybox;\n            }\n            \n            CS_LOG_FATAL(\"Invalid material type: \" + in_materialType);\n            return MaterialShadingType::k_unlit;\n        }\n\n        ///\n        /// @param pass\n        ///     The render pass as a string.\n        ///\n        /// @return The render pass as an type.\n        ///\n        RenderPasses ConvertStringToRenderPass(const std::string& pass) noexcept\n        {\n            auto passLower = pass;\n            StringUtils::ToLowerCase(passLower);\n            \n            if (passLower == \"shadowmap\")\n            {\n                return RenderPasses::k_shadowMap;\n            }\n            else if (passLower == \"base\")\n            {\n                return RenderPasses::k_base;\n            }\n            else if (passLower == \"directionallight\")\n            {\n                return RenderPasses::k_directionalLight;\n            }\n            else if (passLower == \"directionallightshadows\")\n            {\n                return RenderPasses::k_directionalLightShadows;\n            }\n            else if (passLower == \"pointlight\")\n            {\n                return RenderPasses::k_pointLight;\n            }\n            else if (passLower == \"transparent\")\n            {\n                return RenderPasses::k_transparent;\n            }\n            else if (passLower == \"skybox\")\n            {\n                return RenderPasses::k_skybox;\n            }\n            \n            CS_LOG_FATAL(\"Invalid render pass: \" + pass);\n            return RenderPasses::k_base;\n        }\n        ///\n        /// @param type\n        ///     The texture type as a string.\n        ///\n        /// @return The texture type as an type.\n        ///\n        TextureType ConvertStringToTextureType(const std::string& type) noexcept\n        {\n            auto typeLower = type;\n            StringUtils::ToLowerCase(typeLower);\n            \n            if (typeLower == \"texture\")\n            {\n                return TextureType::k_texture;\n            }\n            else if (typeLower == \"cubemap\")\n            {\n                return TextureType::k_cubemap;\n            }\n            \n            CS_LOG_FATAL(\"Invalid texture type: \" + type);\n            return TextureType::k_texture;\n        }\n        //----------------------------------------------------------------------------\n        /// Parse the vertex format from the given string name. If the name doesn't\n        /// exist this will assert. Note that materials loaded from file cannot\n        /// describe custom vertex formats.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param in_vertexFormatName\n        ///\n        /// @return The vertex format with the given name.\n        //----------------------------------------------------------------------------\n        VertexFormat ParseVertexFormat(const std::string& in_vertexFormatName) noexcept\n        {\n            constexpr char k_sprite[] = \"sprite\";\n            constexpr char k_staticMesh[] = \"staticmesh\";\n            constexpr char k_animatedmesh[] = \"animatedmesh\";\n            \n            auto vertexFormatNameTypeLower = in_vertexFormatName;\n            StringUtils::ToLowerCase(vertexFormatNameTypeLower);\n            \n            if (vertexFormatNameTypeLower == k_sprite)\n            {\n                return VertexFormat::k_sprite;\n            }\n            else if (vertexFormatNameTypeLower == k_staticMesh)\n            {\n                return VertexFormat::k_staticMesh;\n            }\n            else if (vertexFormatNameTypeLower == k_animatedmesh)\n            {\n                return VertexFormat::k_animatedMesh;\n            }\n            \n            CS_LOG_FATAL(\"Invalid vertex format: \" + in_vertexFormatName);\n            return VertexFormat::k_sprite;\n        }\n        //----------------------------------------------------------------------------\n        /// Parse the render states from the XML element to the material\n        ///\n        /// @author S Downie\n        ///\n        /// @param Root element\n        /// @param [Out] Material to populate\n        //----------------------------------------------------------------------------\n        void ParseRenderStates(XML::Node* in_rootElement, Material* out_material)\n        {\n            \n            XML::Node* renderStatesEl = XMLUtils::GetFirstChildElement(in_rootElement, \"RenderStates\");\n            if(renderStatesEl)\n            {\n                //---Depth Writing\n                XML::Node* depthWriteStateEl =  XMLUtils::GetFirstChildElement(renderStatesEl, \"DepthWrite\");\n                if(depthWriteStateEl)\n                {\n                    out_material->SetDepthWriteEnabled(XMLUtils::GetAttributeValue(depthWriteStateEl, \"enabled\", true));\n                }\n                //---Depth Testing\n                XML::Node* depthTestStateEl = XMLUtils::GetFirstChildElement(renderStatesEl, \"DepthTest\");\n                if(depthTestStateEl)\n                {\n                    out_material->SetDepthTestEnabled(XMLUtils::GetAttributeValue<bool>(depthTestStateEl, \"enabled\", true));\n                }\n                //---Transparency\n                XML::Node* transparentStateEl = XMLUtils::GetFirstChildElement(renderStatesEl, \"Transparency\");\n                if(transparentStateEl)\n                {\n                    out_material->SetTransparencyEnabled(XMLUtils::GetAttributeValue<bool>(transparentStateEl, \"enabled\", false));\n                }\n                //---Culling\n                XML::Node* cullingStateEl = XMLUtils::GetFirstChildElement(renderStatesEl, \"Culling\");\n                if(cullingStateEl)\n                {\n                    out_material->SetFaceCullingEnabled(XMLUtils::GetAttributeValue<bool>(cullingStateEl, \"enabled\", true));\n                }\n            }\n        }\n        //----------------------------------------------------------------------------\n        /// Parse the alpha blend function from the XML element to the material\n        ///\n        /// @author S Downie\n        ///\n        /// @param Root element\n        /// @param [Out] Material to populate\n        //----------------------------------------------------------------------------\n        void ParseAlphaBlendFunction(XML::Node* in_rootElement, Material* out_material)\n        {\n            XML::Node* blendFuncEl = XMLUtils::GetFirstChildElement(in_rootElement, \"BlendFunc\");\n            if(blendFuncEl)\n            {\n                const std::string srcFuncString = XMLUtils::GetAttributeValue<std::string>(blendFuncEl, \"src\", \"One\");\n                BlendMode srcFunc = ConvertStringToBlendMode(srcFuncString);\n                \n                const std::string dstFuncString = XMLUtils::GetAttributeValue<std::string>(blendFuncEl, \"dst\", \"One\");\n                BlendMode dstFunc = ConvertStringToBlendMode(dstFuncString);\n                \n                out_material->SetBlendModes(srcFunc, dstFunc);\n            }\n        }\n        //----------------------------------------------------------------------------\n        /// Parse the depth test function from the XML element to the material\n        ///\n        /// @author S Downie\n        ///\n        /// @param Root element\n        /// @param [Out] Material to populate\n        //----------------------------------------------------------------------------\n        void ParseDepthTestFunction(XML::Node* in_rootElement, Material* out_material)\n        {\n            XML::Node* depthFuncEl = XMLUtils::GetFirstChildElement(in_rootElement, \"DepthTestFunc\");\n            if(depthFuncEl)\n            {\n                const std::string funcString = XMLUtils::GetAttributeValue<std::string>(depthFuncEl, \"func\", \"lequal\");\n                out_material->SetDepthTestFunc(ConvertStringToDepthFunc(funcString));\n            }\n        }\n        //----------------------------------------------------------------------------\n        /// Parse the cull function from the XML element to the material\n        ///\n        /// @author S Downie\n        ///\n        /// @param Root element\n        /// @param [Out] Material to populate\n        //----------------------------------------------------------------------------\n        void ParseCullFunction(XML::Node* in_rootElement, Material* out_material)\n        {\n            XML::Node* cullFaceEl = XMLUtils::GetFirstChildElement(in_rootElement, \"Culling\");\n            if(cullFaceEl)\n            {\n                const std::string& cullFaceString = XMLUtils::GetAttributeValue<std::string>(cullFaceEl, \"face\", \"Front\");\n                CullFace cullFace = ConvertStringToCullFace(cullFaceString);\n                out_material->SetCullFace(cullFace);\n            }\n        }\n        //----------------------------------------------------------------------------\n        /// Parse the surface date such as shininess etc from the XML element\n        /// to the material\n        ///\n        /// @author S Downie\n        ///\n        /// @param Root element\n        /// @param [Out] Material to populate\n        //----------------------------------------------------------------------------\n        void ParseSurface(XML::Node* in_rootElement, Material* out_material)\n        {\n            XML::Node* lightingEl = XMLUtils::GetFirstChildElement(in_rootElement, \"Lighting\");\n            if(lightingEl)\n            {\n                //---Emissive\n                XML::Node* emissiveEl = XMLUtils::GetFirstChildElement(lightingEl, \"Emissive\");\n                if(emissiveEl)\n                {\n                    out_material->SetEmissive(XMLUtils::GetAttributeValue<Colour>(emissiveEl, \"value\", Colour::k_white));\n                }\n                //---Ambient Lighting\n                XML::Node* ambientEl = XMLUtils::GetFirstChildElement(lightingEl, \"Ambient\");\n                if(ambientEl)\n                {\n                    out_material->SetAmbient(XMLUtils::GetAttributeValue<Colour>(ambientEl, \"value\", Colour::k_white));\n                }\n                //---Diffuse Lighting\n                XML::Node* diffuseEl = XMLUtils::GetFirstChildElement(lightingEl, \"Diffuse\");\n                if(diffuseEl)\n                {\n                    out_material->SetDiffuse(XMLUtils::GetAttributeValue<Colour>(diffuseEl, \"value\", Colour::k_white));\n                }\n                //---Specular Lighting\n                Colour specular(1.0f, 1.0f, 1.0f, 0.0f);\n                XML::Node* specularEl = XMLUtils::GetFirstChildElement(lightingEl, \"Specular\");\n                if(specularEl)\n                {\n                    specular = XMLUtils::GetAttributeValue<Colour>(specularEl, \"value\", Colour::k_white);\n                }\n                \n                //---Intensity\n                XML::Node* shininessEl = XMLUtils::GetFirstChildElement(lightingEl, \"Shininess\");\n                if(shininessEl)\n                {\n                    specular.a = XMLUtils::GetAttributeValue<f32>(shininessEl, \"value\", 0.0f);\n                }\n                \n                out_material->SetSpecular(specular);\n            }\n        }\n        //----------------------------------------------------------------------------\n        /// Parse the shader file paths\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param Root element\n        /// @param [Out] Shader files to populate\n        /// @param [Out] Material to populate\n        //----------------------------------------------------------------------------\n        void ParseShaders(XML::Node* in_rootElement, std::vector<MaterialProvider::ShaderDesc>& out_shaderFiles, Material* out_material)\n        {\n            XML::Node* shadersEl = XMLUtils::GetFirstChildElement(in_rootElement, \"Shaders\");\n            if(shadersEl)\n            {\n                CS_ASSERT(out_material->GetShadingType() == MaterialShadingType::k_custom, \"Only custom materials can have shaders.\");\n                \n                //Get the fallback shader type which will populate all the other passes\n                out_material->PrepCustomShaders(ParseVertexFormat(XMLUtils::GetAttributeValue<std::string>(shadersEl, \"vertex-format\", \"StaticMesh\")), ConvertStringToShadingType(XMLUtils::GetAttributeValue<std::string>(shadersEl, \"fallback-type\", \"Custom\")));\n                \n                XML::Node* shaderEl = XMLUtils::GetFirstChildElement(shadersEl, \"Shader\");\n                while(shaderEl)\n                {\n                    MaterialProvider::ShaderDesc desc;\n                    desc.m_location = ParseStorageLocation(XMLUtils::GetAttributeValue<std::string>(shaderEl, \"location\", \"Package\"));\n                    desc.m_filePath = XMLUtils::GetAttributeValue<std::string>(shaderEl, \"file-name\", \"\");\n                    desc.m_pass = ConvertStringToRenderPass(XMLUtils::GetAttributeValue<std::string>(shaderEl, \"pass\", \"Base\"));\n                    out_shaderFiles.push_back(desc);\n                    \n                    // Get the shader variables\n                    XML::Node* shaderVarEl = XMLUtils::GetFirstChildElement(shaderEl, \"Var\");\n                    while(shaderVarEl)\n                    {\n                        //Get the variable type\n                        std::string strType = XMLUtils::GetAttributeValue<std::string>(shaderVarEl, \"type\", \"\");\n                        //Get the variable name\n                        std::string strName = XMLUtils::GetAttributeValue<std::string>(shaderVarEl, \"name\", \"\");\n                        //Add the variable to the material\n                        if(strType == \"Float\")\n                        {\n                            out_material->SetShaderVar(strName, XMLUtils::GetAttributeValue<f32>(shaderVarEl, \"value\", 0.0f));\n                        }\n                        else if(strType == \"Vec2\")\n                        {\n                            out_material->SetShaderVar(strName, XMLUtils::GetAttributeValue<Vector2>(shaderVarEl, \"value\", Vector2::k_zero));\n                        }\n                        else if(strType == \"Vec3\")\n                        {\n                            out_material->SetShaderVar(strName, XMLUtils::GetAttributeValue<Vector3>(shaderVarEl, \"value\", Vector3::k_zero));\n                        }\n                        else if(strType == \"Vec4\")\n                        {\n                            out_material->SetShaderVar(strName, XMLUtils::GetAttributeValue<Vector4>(shaderVarEl, \"value\", Vector4::k_zero));\n                        }\n                        else if(strType == \"Colour\")\n                        {\n                            out_material->SetShaderVar(strName, XMLUtils::GetAttributeValue<Colour>(shaderVarEl, \"value\", Colour::k_white));\n                        }\n                        else if(strType == \"Matrix\")\n                        {\n                            out_material->SetShaderVar(strName, XMLUtils::GetAttributeValue<Matrix4>(shaderVarEl, \"value\", Matrix4::k_identity));\n                        }\n                        //Move on to the next variable\n                        shaderVarEl =  XMLUtils::GetNextSiblingElement(shaderVarEl, \"Var\");\n                    }\n                    \n                    shaderEl =  XMLUtils::GetNextSiblingElement(shaderEl, \"Shader\");\n                }\n            }\n        }\n        //----------------------------------------------------------------------------\n        /// Parse the texture file paths\n        ///\n        /// @author S Downie\n        ///\n        /// @param Root element\n        /// @param [Out] Texture files to populate\n        //----------------------------------------------------------------------------\n        void ParseTextures(XML::Node* in_rootElement, std::vector<MaterialProvider::TextureDesc>& out_textureFiles)\n        {\n            XML::Node* texturesEl = XMLUtils::GetFirstChildElement(in_rootElement, \"Textures\");\n            if(texturesEl)\n            {\n                //---Texture\n                XML::Node* textureEl = XMLUtils::GetFirstChildElement(texturesEl, \"Texture\");\n                while(textureEl)\n                {\n                    MaterialProvider::TextureDesc desc;\n                    desc.m_location = ParseStorageLocation(XMLUtils::GetAttributeValue<std::string>(textureEl, \"location\", \"Package\"));\n                    desc.m_filePath = XMLUtils::GetAttributeValue<std::string>(textureEl, \"file-name\", \"\");\n                    desc.m_shouldMipMap = XMLUtils::GetAttributeValue<bool>(textureEl, \"mipmapped\", false);\n                    desc.m_filterMode = ConvertStringToFilterMode(XMLUtils::GetAttributeValue<std::string>(textureEl, \"filter-mode\", \"Bilinear\"));\n                    desc.m_wrapModeU = ConvertStringToWrapMode(XMLUtils::GetAttributeValue<std::string>(textureEl, \"wrap-mode-u\", \"Clamp\"));\n                    desc.m_wrapModeV = ConvertStringToWrapMode(XMLUtils::GetAttributeValue<std::string>(textureEl, \"wrap-mode-v\", \"Clamp\"));\n                    desc.m_type = ConvertStringToTextureType(XMLUtils::GetAttributeValue<std::string>(textureEl, \"type\", \"Texture\"));\n                    out_textureFiles.push_back(desc);\n                    \n                    textureEl =  XMLUtils::GetNextSiblingElement(textureEl, \"Texture\");\n                }\n            }\n        }\n        //----------------------------------------------------------------------------\n        /// Load the resource from the given descs at the given index. On\n        /// completion this will recursively kick off the next load if one\n        /// is required, otherwise will call the delegate\n        ///\n        /// @author S Downie\n        ///\n        /// @param Index of desc to load\n        /// @param Descs\n        /// @param Completion delegate\n        /// @param [Out] Material\n        //----------------------------------------------------------------------------\n        void LoadResourcesChained(u32 in_loadIndex, const std::vector<ChainedLoadDesc>& in_descs, const ResourceProvider::AsyncLoadDelegate& in_delegate, const MaterialSPtr& out_material)\n        {\n            ResourcePool* resourcePool = Application::Get()->GetResourcePool();\n            \n            switch(in_descs[in_loadIndex].m_type)\n            {\n                case ResourceType::k_shader:\n                {\n                    resourcePool->LoadResourceAsync<Shader>(in_descs[in_loadIndex].m_location, in_descs[in_loadIndex].m_filePath, [in_loadIndex, in_descs, in_delegate, out_material](const ShaderCSPtr& in_shader)\n                    {\n                        if(in_shader->GetLoadState() == Resource::LoadState::k_loaded)\n                        {\n                            out_material->AddCustomShader(in_shader, in_descs[in_loadIndex].m_pass);\n                            \n                            u32 newLoadIndex = in_loadIndex + 1;\n                            \n                            if(newLoadIndex < in_descs.size())\n                            {\n                                LoadResourcesChained(newLoadIndex, in_descs, in_delegate, out_material);\n                            }\n                            else\n                            {\n                                out_material->SetLoadState(Resource::LoadState::k_loaded);\n                                Application::Get()->GetTaskScheduler()->ScheduleTask(TaskType::k_mainThread, [=](const TaskContext&) noexcept\n                                {\n                                    in_delegate(out_material);\n                                });\n                                return;\n                            }\n                        }\n                        else\n                        {\n                            out_material->SetLoadState(Resource::LoadState::k_failed);\n                            Application::Get()->GetTaskScheduler()->ScheduleTask(TaskType::k_mainThread, [=](const TaskContext&) noexcept\n                            {\n                                in_delegate(out_material);\n                            });\n                            return;\n                        }\n                    });\n                    break;\n                }\n                case ResourceType::k_texture:\n                {\n                    switch(in_descs[in_loadIndex].m_textureType)\n                    {\n                        case TextureType::k_texture:\n                        {\n                            auto options(std::make_shared<TextureResourceOptions>(in_descs[in_loadIndex].m_shouldMipMap, in_descs[in_loadIndex].m_filterMode, in_descs[in_loadIndex].m_wrapModeU, in_descs[in_loadIndex].m_wrapModeV));\n                            \n                            resourcePool->LoadResourceAsync<Texture>(in_descs[in_loadIndex].m_location, in_descs[in_loadIndex].m_filePath, options, [=](const TextureCSPtr& in_texture)\n                             {\n                                 if(in_texture->GetLoadState() == Resource::LoadState::k_loaded)\n                                 {\n                                     out_material->AddTexture(in_texture);\n                                     \n                                     u32 newLoadIndex = in_loadIndex + 1;\n                                     \n                                     if(newLoadIndex < in_descs.size())\n                                     {\n                                         LoadResourcesChained(newLoadIndex, in_descs, in_delegate, out_material);\n                                     }\n                                     else\n                                     {\n                                         out_material->SetLoadState(Resource::LoadState::k_loaded);\n                                         Application::Get()->GetTaskScheduler()->ScheduleTask(TaskType::k_mainThread, [=](const TaskContext&) noexcept { in_delegate(out_material); });\n                                         return;\n                                     }\n                                 }\n                                 else\n                                 {\n                                     out_material->SetLoadState(Resource::LoadState::k_failed);\n                                     Application::Get()->GetTaskScheduler()->ScheduleTask(TaskType::k_mainThread, [=](const TaskContext&) noexcept { in_delegate(out_material); });\n                                     return;\n                                 }\n                             });\n                            break;\n                        }\n                        case TextureType::k_cubemap:\n                        {\n                            auto options(std::make_shared<CubemapResourceOptions>(in_descs[in_loadIndex].m_shouldMipMap, in_descs[in_loadIndex].m_filterMode, in_descs[in_loadIndex].m_wrapModeU, in_descs[in_loadIndex].m_wrapModeV));\n                            \n                            resourcePool->LoadResourceAsync<Cubemap>(in_descs[in_loadIndex].m_location, in_descs[in_loadIndex].m_filePath, options, [=](const CubemapCSPtr& cubemap)\n                             {\n                                 if(cubemap->GetLoadState() == Resource::LoadState::k_loaded)\n                                 {\n                                     out_material->AddCubemap(cubemap);\n                                     \n                                     u32 newLoadIndex = in_loadIndex + 1;\n                                     \n                                     if(newLoadIndex < in_descs.size())\n                                     {\n                                         LoadResourcesChained(newLoadIndex, in_descs, in_delegate, out_material);\n                                     }\n                                     else\n                                     {\n                                         out_material->SetLoadState(Resource::LoadState::k_loaded);\n                                         Application::Get()->GetTaskScheduler()->ScheduleTask(TaskType::k_mainThread, [=](const TaskContext&) noexcept { in_delegate(out_material); });\n                                         return;\n                                     }\n                                 }\n                                 else\n                                 {\n                                     out_material->SetLoadState(Resource::LoadState::k_failed);\n                                     Application::Get()->GetTaskScheduler()->ScheduleTask(TaskType::k_mainThread, [=](const TaskContext&) noexcept { in_delegate(out_material); });\n                                     return;\n                                 }\n                             });\n                            break;\n                        }\n                    }\n                    break;\n                }\n            }\n        }\n    }\n    \n    CS_DEFINE_NAMEDTYPE(MaterialProvider);\n    \n    //-------------------------------------------------------------------------\n    //-------------------------------------------------------------------------\n    MaterialProviderUPtr MaterialProvider::Create()\n    {\n        return MaterialProviderUPtr(new MaterialProvider());\n    }\n    //-------------------------------------------------------------------------\n    //-------------------------------------------------------------------------\n    bool MaterialProvider::IsA(InterfaceIDType in_interfaceId) const\n    {\n        return in_interfaceId == ResourceProvider::InterfaceID || in_interfaceId == MaterialProvider::InterfaceID;\n    }\n    //----------------------------------------------------------------------------\n    //----------------------------------------------------------------------------\n    InterfaceIDType MaterialProvider::GetResourceType() const\n    {\n        return Material::InterfaceID;\n    }\n    //----------------------------------------------------------------------------\n    //----------------------------------------------------------------------------\n    bool MaterialProvider::CanCreateResourceWithFileExtension(const std::string& in_extension) const\n    {\n        return in_extension == k_materialExtension;\n    }\n    //----------------------------------------------------------------------------\n    //----------------------------------------------------------------------------\n    void MaterialProvider::CreateResourceFromFile(StorageLocation in_location, const std::string& in_filePath, const IResourceOptionsBaseCSPtr& in_options, const ResourceSPtr& out_resource)\n    {\n        std::vector<ShaderDesc> shaderFiles;\n        std::vector<TextureDesc> textureFiles;\n        \n        if(BuildMaterialFromFile(in_location, in_filePath, shaderFiles, textureFiles, (Material*)out_resource.get()) == false)\n        {\n            out_resource->SetLoadState(Resource::LoadState::k_failed);\n            return;\n        }\n        \n        MaterialSPtr material = std::static_pointer_cast<Material>(out_resource);\n        \n        ResourcePool* resourcePool = Application::Get()->GetResourcePool();\n        \n        for(u32 i=0; i<shaderFiles.size(); ++i)\n        {\n            if(shaderFiles[i].m_filePath.empty() == false)\n            {\n                ShaderCSPtr shader = resourcePool->LoadResource<Shader>(shaderFiles[i].m_location, shaderFiles[i].m_filePath);\n                if(shader == nullptr)\n                {\n                    out_resource->SetLoadState(Resource::LoadState::k_failed);\n                    return;\n                }\n                \n                material->AddCustomShader(shader, shaderFiles[i].m_pass);\n            }\n        }\n        \n        for(u32 i=0; i<textureFiles.size(); ++i)\n        {\n            if(textureFiles[i].m_filePath.empty() == false)\n            {\n                switch (textureFiles[i].m_type)\n                {\n                    case TextureType::k_texture:\n                    {\n                        auto options(std::make_shared<TextureResourceOptions>(textureFiles[i].m_shouldMipMap, textureFiles[i].m_filterMode, textureFiles[i].m_wrapModeU, textureFiles[i].m_wrapModeV));\n                        \n                        TextureCSPtr texture = resourcePool->LoadResource<Texture>(textureFiles[i].m_location, textureFiles[i].m_filePath, options);\n                        if(texture == nullptr)\n                        {\n                            out_resource->SetLoadState(Resource::LoadState::k_failed);\n                            return;\n                        }\n                        material->AddTexture(texture);\n                        break;\n                    }\n                    case TextureType::k_cubemap:\n                    {\n                        auto options(std::make_shared<CubemapResourceOptions>(textureFiles[i].m_shouldMipMap, textureFiles[i].m_filterMode, textureFiles[i].m_wrapModeU, textureFiles[i].m_wrapModeV));\n                        \n                        CubemapCSPtr cubemap = resourcePool->LoadResource<Cubemap>(textureFiles[i].m_location, textureFiles[i].m_filePath, options);\n                        if(cubemap == nullptr)\n                        {\n                            out_resource->SetLoadState(Resource::LoadState::k_failed);\n                            return;\n                        }\n                        material->AddCubemap(cubemap);\n                        break;\n                    }\n                }\n\n            }\n        }\n        \n        out_resource->SetLoadState(Resource::LoadState::k_loaded);\n    }\n    //----------------------------------------------------------------------------\n    //----------------------------------------------------------------------------\n    void MaterialProvider::CreateResourceFromFileAsync(StorageLocation in_location, const std::string& in_filePath, const IResourceOptionsBaseCSPtr& in_options, const ResourceProvider::AsyncLoadDelegate& in_delegate, const ResourceSPtr& out_resource)\n    {\n        Application::Get()->GetTaskScheduler()->ScheduleTask(TaskType::k_file, [=](const TaskContext&) noexcept\n        {\n            BuildMaterialTask(in_location, in_filePath, in_delegate, out_resource);\n        });\n    }\n    //----------------------------------------------------------------------------\n    //----------------------------------------------------------------------------\n    void MaterialProvider::BuildMaterialTask(StorageLocation in_location, const std::string& in_filePath, const ResourceProvider::AsyncLoadDelegate& in_delegate, const ResourceSPtr& out_resource)\n    {\n        std::vector<ShaderDesc> shaderFiles;\n        std::vector<TextureDesc> textureFiles;\n        if(BuildMaterialFromFile(in_location, in_filePath, shaderFiles, textureFiles, (Material*)out_resource.get()) == false)\n        {\n            out_resource->SetLoadState(Resource::LoadState::k_failed);\n            Application::Get()->GetTaskScheduler()->ScheduleTask(TaskType::k_mainThread, [=](const TaskContext&) noexcept\n            {\n                in_delegate(out_resource);\n            });\n            return;\n        }\n        \n        CS_ASSERT(shaderFiles.size() < 2, \"Can have zero or one shaders.\");\n        \n        MaterialSPtr material = std::static_pointer_cast<Material>(out_resource);\n        \n        std::vector<ChainedLoadDesc> resourceFiles;\n        resourceFiles.reserve(textureFiles.size());\n        \n        for(const auto& shaderDesc : shaderFiles)\n        {\n            ChainedLoadDesc desc;\n            desc.m_filePath = shaderDesc.m_filePath;\n            desc.m_location = shaderDesc.m_location;\n            desc.m_type = ResourceType::k_shader;\n            desc.m_pass = shaderDesc.m_pass;\n            resourceFiles.push_back(desc);\n        }\n        \n        for(const auto& textureDesc : textureFiles)\n        {\n            ChainedLoadDesc desc;\n            desc.m_filePath = textureDesc.m_filePath;\n            desc.m_location = textureDesc.m_location;\n            desc.m_shouldMipMap = textureDesc.m_shouldMipMap;\n            desc.m_filterMode = textureDesc.m_filterMode;\n            desc.m_wrapModeU = textureDesc.m_wrapModeU;\n            desc.m_wrapModeV = textureDesc.m_wrapModeV;\n            desc.m_textureType = textureDesc.m_type;\n            desc.m_type = ResourceType::k_texture;\n            resourceFiles.push_back(desc);\n        }\n        \n        LoadResourcesChained(0, resourceFiles, in_delegate, material);\n    }\n    //----------------------------------------------------------------------------\n    //----------------------------------------------------------------------------\n    bool MaterialProvider::BuildMaterialFromFile(StorageLocation in_location, const std::string& in_filePath,\n                                                 std::vector<ShaderDesc>& out_shaderFiles,\n                                                 std::vector<TextureDesc>& out_textureFiles,\n                                                Material* out_material)\n    {\n        //Load the XML file\n        XMLUPtr xml = XMLUtils::ReadDocument(in_location, in_filePath);\n        XML::Node* rootElement = XMLUtils::GetFirstChildElement(xml->GetDocument());\n        \n        if(rootElement == nullptr || XMLUtils::GetName(rootElement) != \"Material\")\n        {\n            return false;\n        }\n        \n        std::string materialType = XMLUtils::GetAttributeValue<std::string>(rootElement, \"type\", \"Static\");\n        out_material->SetShadingType(ConvertStringToShadingType(materialType));\n\n        ParseRenderStates(rootElement, out_material);\n        ParseAlphaBlendFunction(rootElement, out_material);\n        ParseCullFunction(rootElement, out_material);\n        ParseDepthTestFunction(rootElement, out_material);\n        ParseSurface(rootElement, out_material);\n        \n        ParseShaders(rootElement, out_shaderFiles, out_material);\n        ParseTextures(rootElement, out_textureFiles);\n        \n        return true;\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Material/MaterialProvider.h",
    "content": "//\n//  MaterialProvider.h\n//  ChilliSource\n//  Created by Scott Downie on 22/11/2010.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2010 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_MATERIAL_MATERIALPROVIDER_H_\n#define _CHILLISOURCE_RENDERING_MATERIAL_MATERIALPROVIDER_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Resource/ResourceProvider.h>\n#include <ChilliSource/Rendering/Model/VertexFormat.h>\n#include <ChilliSource/Rendering/Texture/Texture.h>\n\nnamespace ChilliSource\n{\n    //-------------------------------------------------------------------------\n    /// Factory for creating material resources from material files\n    ///\n    /// @author S Downie\n    //-------------------------------------------------------------------------\n    class MaterialProvider final : public ResourceProvider\n    {\n    public:\n        \n        CS_DECLARE_NAMEDTYPE(MaterialProvider);\n        \n        //-------------------------------------------------------------------------\n        /// Holds the description of a shader as required by the material\n        /// including which vertex format it applies to.\n        ///\n        /// @author Ian Copland\n        //-------------------------------------------------------------------------\n        struct ShaderDesc\n        {\n            std::string m_filePath;\n            StorageLocation m_location;\n            RenderPasses m_pass;\n        };\n        //-------------------------------------------------------------------------\n        /// Holds the description of a texture as required by the material\n        /// including where the texture file is\n        ///\n        /// @author S Downie\n        //-------------------------------------------------------------------------\n        struct TextureDesc\n        {\n            std::string m_filePath;\n            StorageLocation m_location;\n            bool m_shouldMipMap;\n            TextureWrapMode m_wrapModeU;\n            TextureWrapMode m_wrapModeV;\n            TextureFilterMode m_filterMode;\n            TextureType m_type;\n        };\n        //-------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Interface to compare\n        ///\n        /// @return Whether the object implements the given interface\n        //-------------------------------------------------------------------------\n        bool IsA(InterfaceIDType in_interfaceId) const override;\n        //----------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return The resource type this provider creates\n        //----------------------------------------------------------------------------\n        InterfaceIDType GetResourceType() const override;\n        //----------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Extension to compare\n        ///\n        /// @return Whether the object can create a resource with the given extension\n        //----------------------------------------------------------------------------\n        bool CanCreateResourceWithFileExtension(const std::string& in_extension) const override;\n        \n    private:\n        friend class Application;\n        //-------------------------------------------------------------------------\n        /// Factory method\n        ///\n        /// @author S Downie\n        ///\n        /// @param The render capabilities.\n        ///\n        /// @return New instance with ownership transferred\n        //-------------------------------------------------------------------------\n        static MaterialProviderUPtr Create();\n        //-------------------------------------------------------\n        /// Private constructor to force use of factory method\n        ///\n        /// @author S Downie\n        ///\n        /// @param The render capabilities.\n        //-------------------------------------------------------\n        MaterialProvider() = default;\n        //----------------------------------------------------------------------------\n        /// Load the material resource from the given material file. Check the\n        /// resource load state for success or failure.\n        ///\n        /// @author S Downie\n        ///\n        /// @param The storage location to load from\n        /// @param File path\n        /// @param Options to customise the creation\n        /// @param [Out] Resource object\n        //----------------------------------------------------------------------------\n        void CreateResourceFromFile(StorageLocation in_location, const std::string& in_filePath, const IResourceOptionsBaseCSPtr& in_options, const ResourceSPtr& out_resource) override;\n        //----------------------------------------------------------------------------\n        /// Load the material resource from the given material file on a background\n        /// thread. Calls the delegate on completion. Check the\n        /// resource load state for success or failure.\n        ///\n        /// @author S Downie\n        ///\n        /// @param The storage location to load from\n        /// @param File path\n        /// @param Options to customise the creation\n        /// @param Completion delegate\n        /// @param [Out] Resource object\n        //----------------------------------------------------------------------------\n        void CreateResourceFromFileAsync(StorageLocation in_location, const std::string& in_filePath, const IResourceOptionsBaseCSPtr& in_options, const ResourceProvider::AsyncLoadDelegate& in_delegate, const ResourceSPtr& out_resource) override;\n        //----------------------------------------------------------------------------\n        /// Build Material Task\n        ///\n        /// @param The storage location to load from\n        /// @param File path\n        /// @param Completion delegate\n        ///\n        /// @param [Out] Resource object\n        //----------------------------------------------------------------------------\n        void BuildMaterialTask(StorageLocation in_location, const std::string& in_filePath, const ResourceProvider::AsyncLoadDelegate& in_delegate, const ResourceSPtr& out_resource);\n        //----------------------------------------------------------------------------\n        /// Build Material From File\n        ///\n        /// @param The storage location to load from\n        /// @param File path\n        /// @param [Out] Shaders to load\n        /// @param [Out] Textures to load\n        /// @param [Out] Material resource\n        ///\n        /// @return Whether the resource was loaded \n        //----------------------------------------------------------------------------\n        bool BuildMaterialFromFile(StorageLocation in_location, const std::string& in_filePath,\n                                   std::vector<ShaderDesc>& out_shaderFiles,\n                                   std::vector<TextureDesc>& out_textureFiles,\n                                   Material* out_material);\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Material/MaterialShadingType.h",
    "content": "//\n//  ChilliSource\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2010 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_MATERIAL_MATERIALSHADINGTYPE_H_\n#define _CHILLISOURCE_RENDERING_MATERIAL_MATERIALSHADINGTYPE_H_\n\nnamespace ChilliSource\n{\n\n    ///\n    /// Describes the different shading types that materials can\n    /// use. These affect the shaders that the render system\n    /// will use when rendering objects with this material.\n    ///\n    enum class MaterialShadingType\n    {\n        k_unlit,\n        k_blinn,\n        k_skybox,\n        k_custom\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Material/RenderMaterial.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Material/RenderMaterial.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    RenderMaterial::RenderMaterial(const RenderShader* renderShader, std::vector<const RenderTexture*> renderTextures2D, std::vector<const RenderTexture*> renderTexturesCubemap,\n                                   bool isTransparencyEnabled, bool isColourWriteEnabled, bool isDepthWriteEnabled, bool isDepthTestEnabled, bool isFaceCullingEnabled, bool isStencilTestEnabled,\n                                   TestFunc depthTestFunc,\n                                   BlendMode sourceBlendMode, BlendMode destinationBlendMode,\n                                   StencilOp stencilFailOp, StencilOp stencilDepthFailOp, StencilOp stencilPassOp, TestFunc stencilTestFunc, s32 stencilRef, u32 stencilMask,\n                                   CullFace cullFace,\n                                   const Colour& emissiveColour, const Colour& ambientColour, const Colour& diffuseColour, const Colour& specularColour,\n                                   RenderShaderVariablesUPtr renderShaderVariables) noexcept\n    :   m_renderShader(renderShader), m_renderTextures2D(std::move(renderTextures2D)), m_renderTexturesCubemap(std::move(renderTexturesCubemap)),\n            m_isTransparencyEnabled(isTransparencyEnabled), m_isColourWriteEnabled(isColourWriteEnabled), m_isDepthWriteEnabled(isDepthWriteEnabled), m_isDepthTestEnabled(isDepthTestEnabled), m_isFaceCullingEnabled(isFaceCullingEnabled), m_isStencilTestEnabled(isStencilTestEnabled),\n            m_depthTestFunc(depthTestFunc),\n            m_sourceBlendMode(sourceBlendMode), m_destinationBlendMode(destinationBlendMode),\n            m_stencilFailOp(stencilFailOp), m_stencilDepthFailOp(stencilDepthFailOp), m_stencilPassOp(stencilPassOp), m_stencilTestFunc(stencilTestFunc), m_stencilTestFuncRef(stencilRef), m_stencilTestFuncMask(stencilMask),\n            m_cullFace(cullFace), m_emissiveColour(emissiveColour), m_ambientColour(ambientColour), m_diffuseColour(diffuseColour), m_specularColour(specularColour), m_renderShaderVariables(std::move(renderShaderVariables))\n    {\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Material/RenderMaterial.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_MATERIAL_RENDERMATERIAL_H_\n#define _CHILLISOURCE_RENDERING_MATERIAL_RENDERMATERIAL_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Base/Colour.h>\n#include <ChilliSource/Rendering/Shader/RenderShaderVariables.h>\n\n#include <vector>\n\nnamespace ChilliSource\n{\n    /// A container for information which the renderer needs pertaining to a single material.\n    ///\n    /// This is immutable and therefore thread-safe, aside from the extra data pointer\n    /// which should only be accessed on the render thread.\n    ///\n    class RenderMaterial final\n    {\n    public:\n        CS_DECLARE_NOCOPY(RenderMaterial);\n        \n        /// Creates a new instance with the given material data.\n        ///\n        /// @param renderShader\n        ///     The shader applied by this material.\n        /// @param renderTextures2D\n        ///     The list of textures applied by this material. Should be moved in\n        /// @param renderTexturesCubemap\n        ///     The list of cubemaps applied by this material. Should be moved in\n        /// @param isTransparencyEnabled\n        ///     Whether or not transparency is enabled.\n        /// @param isColourWriteEnabled\n        ///     Whether or not colour write is enabled.\n        /// @param isDepthWriteEnabled\n        ///     Whether or not depth write is enabled.\n        /// @param isDepthTestEnabled\n        ///     Whether or not the depth test will be performed.\n        /// @param isFaceCullingEnabled\n        ///     Whether or not face culling will be performed.\n        /// @param isStencilTestEnabled\n        ///     Whether or not to perform stencil testing\n        /// @param depthTestFunc\n        ///     Function that determines whether a depth test comparison should pass or fail\n        /// @param sourceBlendMode\n        ///     The source blend mode. This only applies if transparency is enabled.\n        /// @param destinationBlendMode\n        ///     The destination blend mode. This only applies if transparency is enabled.\n        /// @param stencilFailOp\n        ///     Op applied if stencil test fails\n        /// @param stencilDepthFailOp\n        ///     Op applied if stencil depth test fails\n        /// @param stencilPassOp\n        ///     Op applied if stencil and depth tests pass\n        /// @param stencilTestFunc\n        ///     Function that determines whether a stencil test comparison should pass or fail\n        /// @param stencilRef\n        ///     Value used as comparison for stencil tests\n        /// @param stencilMask\n        ///     Value ANDed to with the comparison and stencil value\n        /// @param cullFace\n        ///     The face which should be called. This only applies if face culling is enabled.\n        /// @param emissiveColour\n        ///     The emissive colour.\n        /// @param ambientColour\n        ///     The ambient colour.\n        /// @param diffuseColour\n        ///     The diffuseColour.\n        /// @param specularColour\n        ///     The specularColour.\n        /// @param renderShaderVariables\n        ///     The container for all render shader variables. May be null if there are no shader variables.\n        ///\n        RenderMaterial(const RenderShader* renderShader, std::vector<const RenderTexture*> renderTextures2D, std::vector<const RenderTexture*> renderTexturesCubemap,\n                       bool isTransparencyEnabled, bool isColourWriteEnabled, bool isDepthWriteEnabled, bool isDepthTestEnabled, bool isFaceCullingEnabled, bool isStencilTestEnabled,\n                       TestFunc depthTestFunc,\n                       BlendMode sourceBlendMode, BlendMode destinationBlendMode,\n                       StencilOp stencilFailOp, StencilOp stencilDepthFailOp, StencilOp stencilPassOp, TestFunc stencilTestFunc, s32 stencilRef, u32 stencilMask,\n                       CullFace cullFace,\n                       const Colour& emissiveColour, const Colour& ambientColour, const Colour& diffuseColour, const Colour& specularColour,\n                       RenderShaderVariablesUPtr renderShaderVariables) noexcept;\n        \n        /// @return The shader applied by this material.\n        ///\n        const RenderShader* GetRenderShader() const noexcept { return m_renderShader; }\n        \n        /// @return The list of textures applied by this material.\n        ///\n        const std::vector<const RenderTexture*>& GetRenderTextures2D() const noexcept { return m_renderTextures2D; }\n        \n        /// @return The list of cubemaps applied by this material.\n        ///\n        const std::vector<const RenderTexture*>& GetRenderTexturesCubemap() const noexcept { return m_renderTexturesCubemap; }\n        \n        /// @return Whether or not transparency is enabled.\n        ///\n        bool IsTransparencyEnabled() const noexcept { return m_isTransparencyEnabled; }\n        \n        /// @return Whether or not colour write is enabled.\n        ///\n        bool IsColourWriteEnabled() const noexcept { return m_isColourWriteEnabled; }\n        \n        /// @return Whether or not depth write is enabled.\n        ///\n        bool IsDepthWriteEnabled() const noexcept { return m_isDepthWriteEnabled; }\n        \n        /// @return Whether or not depth write is enabled.\n        ///\n        bool IsDepthTestEnabled() const noexcept { return m_isDepthTestEnabled; }\n        \n        /// @return Whether or not face culling is enabled.\n        ///\n        bool IsFaceCullingEnabled() const noexcept { return m_isFaceCullingEnabled; }\n        \n        /// @return Whether or not to perform stencil testing\n        ///\n        bool IsStencilTestEnabled() const noexcept { return m_isStencilTestEnabled; }\n        \n        /// @return Function that handles comparing depth values for pass/fail testing\n        ///\n        TestFunc GetDepthTestFunc() const noexcept { return m_depthTestFunc; }\n        \n        /// @return The source blend mode. This only applies if transparency is enabled.\n        ///\n        BlendMode GetSourceBlendMode() const noexcept { return m_sourceBlendMode; }\n        \n        /// @return The destination blend mode. This only applies if transparency is enabled.\n        ///\n        BlendMode GetDestinationBlendMode() const noexcept { return m_destinationBlendMode; }\n        \n        /// @return The face which should be called. This only applies if face culling is enabled.\n        ///\n        CullFace GetCullFace() const noexcept { return m_cullFace; }\n        \n        /// @return Op to use if stencil test fails\n        ///\n        StencilOp GetStencilFailOp() const noexcept { return m_stencilFailOp; }\n        \n        /// @return Op to use if stencil test passes but depth test fails\n        ///\n        StencilOp GetStencilDepthFailOp() const noexcept { return m_stencilDepthFailOp; }\n        \n        /// @return Op to use if stencil and depth tests pass\n        ///\n        StencilOp GetStencilPassOp() const noexcept { return m_stencilPassOp; }\n        \n        /// @return Function that handles comparing stencil values for pass/fail testing\n        ///\n        TestFunc GetStencilTestFunc() const noexcept { return m_stencilTestFunc; }\n        \n        /// @return The comparison value for the stencil test function\n        ///\n        s32 GetStencilTestFuncRef() const noexcept { return m_stencilTestFuncRef; }\n        \n        /// @return The mask that is ANDed with the ref and stored value\n        ///\n        u32 GetStencilTestFuncMask() const noexcept { return m_stencilTestFuncMask; }\n        \n        /// @return The emissive colour\n        ///\n        const Colour& GetEmissiveColour() const noexcept { return m_emissiveColour; }\n        \n        /// @return The ambient colour\n        ///\n        const Colour& GetAmbientColour() const noexcept { return m_ambientColour; }\n        \n        /// @return The diffuse colour\n        ///\n        const Colour& GetDiffuseColour() const noexcept { return m_diffuseColour; }\n        \n        /// @return The specular colour\n        ///\n        const Colour& GetSpecularColour() const noexcept { return m_specularColour; }\n        \n        /// @return The render shader variables. May be null if there are no shader variables.\n        ///\n        const RenderShaderVariables* GetRenderShaderVariables() const noexcept { return m_renderShaderVariables.get(); }\n        \n        /// This is not thread safe and should only be called from the render thread.\n        ///\n        /// @return A pointer to render system specific additional information.\n        ///\n        void* GetExtraData() const noexcept { return m_extraData; }\n        \n        /// This is not thread safe and should only be called from the render thread.\n        ///\n        /// @param extraData\n        ///     A pointer to render system specific additional information.\n        ///\n        void SetExtraData(void* extraData) noexcept { m_extraData = extraData; }\n        \n    private:\n        const RenderShader* m_renderShader;\n        std::vector<const RenderTexture*> m_renderTextures2D;\n        std::vector<const RenderTexture*> m_renderTexturesCubemap;\n        bool m_isTransparencyEnabled;\n        bool m_isColourWriteEnabled;\n        bool m_isDepthWriteEnabled;\n        bool m_isDepthTestEnabled;\n        bool m_isFaceCullingEnabled;\n        bool m_isStencilTestEnabled;\n        TestFunc m_depthTestFunc;\n        BlendMode m_sourceBlendMode;\n        BlendMode m_destinationBlendMode;\n        StencilOp m_stencilFailOp;\n        StencilOp m_stencilDepthFailOp;\n        StencilOp m_stencilPassOp;\n        s32 m_stencilTestFuncRef;\n        u32 m_stencilTestFuncMask;\n        TestFunc m_stencilTestFunc;\n        CullFace m_cullFace;\n        Colour m_emissiveColour;\n        Colour m_ambientColour;\n        Colour m_diffuseColour;\n        Colour m_specularColour;\n        RenderShaderVariablesUPtr m_renderShaderVariables;\n        void* m_extraData = nullptr;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Material/RenderMaterialGroup.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Material/RenderMaterialGroup.h>\n\n#include <ChilliSource/Rendering/Model/VertexFormat.h>\n\n#include <vector>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    RenderMaterialGroup::RenderMaterialGroup(std::vector<UniquePtr<RenderMaterial>> renderMaterials, std::vector<Collection> collections) noexcept\n        : m_renderMaterials(std::move(renderMaterials)), m_collections(collections)\n    {\n        m_renderMaterialsRaw.reserve(m_renderMaterials.size());\n        for (const auto& renderMaterial : m_renderMaterials)\n        {\n            m_renderMaterialsRaw.push_back(renderMaterial.get());\n        }\n    }\n    \n    //------------------------------------------------------------------------------\n    bool RenderMaterialGroup::Contains(const RenderMaterial* renderMaterial) const noexcept\n    {\n        for (const auto& material : m_renderMaterialsRaw)\n        {\n            if (material == renderMaterial)\n            {\n                return true;\n            }\n        }\n        \n        return false;\n    }\n\n    //------------------------------------------------------------------------------\n    const RenderMaterial* RenderMaterialGroup::GetRenderMaterial(const VertexFormat& vertexFormat, u32 passIndex) const noexcept\n    {\n        CS_ASSERT(passIndex < k_numMaterialSlots, \"Pass index is out of bounds.\");\n        \n        for (const auto& collection : m_collections)\n        {\n            if (collection.GetVertexFormat() == vertexFormat)\n            {\n                return collection.GetRenderMaterial(passIndex);\n            }\n        }\n        \n        CS_LOG_FATAL(\"Material group does not support the requested vertex format.\");\n        return nullptr;\n    }\n    \n    //------------------------------------------------------------------------------\n    RenderMaterialGroup::Collection::Collection(const VertexFormat& vertexFormat, const std::array<const RenderMaterial*, k_numMaterialSlots>& renderMaterials) noexcept\n        : m_vertexFormat(vertexFormat), m_renderMaterials(renderMaterials)\n    {\n    }\n    \n    //------------------------------------------------------------------------------\n    const RenderMaterial* RenderMaterialGroup::Collection::GetRenderMaterial(u32 passIndex) const noexcept\n    {\n        CS_ASSERT(passIndex < k_numMaterialSlots, \"Pass index is out of bounds.\");\n        \n        return m_renderMaterials[passIndex];\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Material/RenderMaterialGroup.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_MATERIAL_RENDERMATERIALGROUP_H_\n#define _CHILLISOURCE_RENDERING_MATERIAL_RENDERMATERIALGROUP_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Memory/UniquePtr.h>\n#include <ChilliSource/Rendering/Material/RenderMaterial.h>\n#include <ChilliSource/Rendering/Model/VertexFormat.h>\n\n#include <array>\n#include <vector>\n\nnamespace ChilliSource\n{\n    /// A series of RenderMaterials. There are multiple collections of render materials, one for each\n    /// type of vertex format. Each of these sets contain a list of RenderMaterials which pertain\n    /// to different passes in the render system, the combination of which describes the complete\n    /// material of an object.\n    ///\n    /// If the render material for a pass is null, this indicates that RenderObjects with the\n    /// RenderMaterialGroup should not be included in the pass.\n    ///\n    /// If there are no materials for a given vertex format then the format isn't supported and this\n    /// will assert.\n    ///\n    /// This is immutable and therefore thread safe.\n    ///\n    class RenderMaterialGroup final\n    {\n    public:\n        CS_DECLARE_NOCOPY(RenderMaterialGroup);\n        \n        static constexpr u32 k_numMaterialSlots = 7;\n        \n        /// A collection of RenderMaterials for a single vertex format.\n        ///\n        /// This is immutable and therefore thread safe.\n        ///\n        class Collection final\n        {\n        public:\n            /// Creates a new instance with the given vertex format and series of RenderMaterials\n            ///\n            /// @param vertexFormat\n            ///     The vertex format.\n            /// @param renderMaterials\n            ///     The render materials for each pass.\n            ///\n            Collection(const VertexFormat& vertexFormat, const std::array<const RenderMaterial*, k_numMaterialSlots>& renderMaterials) noexcept;\n            \n            /// @return The vertex format.\n            ///\n            const VertexFormat& GetVertexFormat() const noexcept { return m_vertexFormat; }\n            \n            /// Looks up a render material for the given pass index.\n            ///\n            /// @param passIndex\n            ///     The pass index to look up.\n            ///\n            /// @return The render materials array\n            ///\n            const RenderMaterial* GetRenderMaterial(u32 passIndex) const noexcept;\n            \n        private:\n            VertexFormat m_vertexFormat;\n            std::array<const RenderMaterial*, k_numMaterialSlots> m_renderMaterials;\n        };\n        \n        /// Creates a new instance with the given collections of RenderMaterials.\n        ///\n        /// SHOULD ONLY BE CREATED VIA RenderMaterialGroupManager\n        ///\n        /// @param renderMaterials\n        ///     The list of all materials in the group.\n        /// @param collections\n        ///     The list of material collections. Should be moved\n        ///\n        RenderMaterialGroup(std::vector<UniquePtr<RenderMaterial>> renderMaterials, std::vector<Collection> collections) noexcept;\n        \n        /// Evaluates whether or not the given RenderMaterial is part of this group.\n        ///\n        /// @param renderMaterial\n        ///     The RenderMaterial which should be checked.\n        ///\n        /// @return Whether or not the RenderMaterial is part of this group.\n        ///\n        bool Contains(const RenderMaterial* renderMaterial) const noexcept;\n        \n        /// Looks up the render material for the given vertex format and pass index.\n        ///\n        /// @param vertexFormat\n        ///     The vertex format for which to get a render material.\n        /// @param passIndex\n        ///     The pass to look up.\n        ///\n        /// @return The static mesh render material. May be null.\n        ///\n        const RenderMaterial* GetRenderMaterial(const VertexFormat& vertexFormat, u32 passIndex) const noexcept;\n        \n        /// Exposes the render materials so their extra data can be set during loading\n        /// and unloading.\n        ///\n        /// @return An unsorted list of all RenderMaterials in the group.\n        ///\n        const std::vector<RenderMaterial*>& GetRenderMaterials() noexcept { return m_renderMaterialsRaw; }\n        \n    private:\n        \n        std::vector<UniquePtr<RenderMaterial>> m_renderMaterials;\n        std::vector<RenderMaterial*> m_renderMaterialsRaw;\n        std::vector<Collection> m_collections;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Material/RenderMaterialGroupManager.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Material/RenderMaterialGroupManager.h>\n\n#include <ChilliSource/Rendering/Base/RenderSnapshot.h>\n#include <ChilliSource/Rendering/Base/TargetType.h>\n#include <ChilliSource/Rendering/Material/ForwardRenderMaterialGroupManager.h>\n#include <ChilliSource/Rendering/RenderCommand/RenderCommandList.h>\n\nnamespace ChilliSource\n{\n    CS_DEFINE_NAMEDTYPE(RenderMaterialGroupManager);\n\n    //------------------------------------------------------------------------------\n    RenderMaterialGroupManagerUPtr RenderMaterialGroupManager::Create() noexcept\n    {\n        //TODO: Handle creation of deferred rendering version of the manager\n        return RenderMaterialGroupManagerUPtr(new ForwardRenderMaterialGroupManager());\n    }\n    \n    //------------------------------------------------------------------------------\n    void RenderMaterialGroupManager::DestroyRenderMaterialGroup(UniquePtr<RenderMaterialGroup> renderMaterialGroup) noexcept\n    {\n        std::unique_lock<std::mutex> lock(m_mutex);\n        m_pendingUnloadCommands.push_back(std::move(renderMaterialGroup));\n    }\n    \n    //------------------------------------------------------------------------------\n    void RenderMaterialGroupManager::AddRenderMaterialGroup(RenderMaterialGroup* renderMaterialGroup) noexcept\n    {\n        std::unique_lock<std::mutex> lock(m_mutex);\n        m_pendingLoadCommands.push_back(renderMaterialGroup);\n    }\n    \n    //------------------------------------------------------------------------------\n    void RenderMaterialGroupManager::OnRenderSnapshot(TargetType targetType, RenderSnapshot& renderSnapshot, IAllocator* frameAllocator) noexcept\n    {\n        if(targetType == TargetType::k_main)\n        {\n            auto preRenderCommandList = renderSnapshot.GetPreRenderCommandList();\n            auto postRenderCommandList = renderSnapshot.GetPostRenderCommandList();\n            \n            std::unique_lock<std::mutex> lock(m_mutex);\n            \n            for (auto& loadCommand : m_pendingLoadCommands)\n            {\n                preRenderCommandList->AddLoadMaterialGroupCommand(loadCommand);\n            }\n            m_pendingLoadCommands.clear();\n            \n            for (auto& unloadCommand : m_pendingUnloadCommands)\n            {\n                postRenderCommandList->AddUnloadMaterialGroupCommand(std::move(unloadCommand));\n            }\n            m_pendingUnloadCommands.clear();\n        }\n    }\n    \n    //------------------------------------------------------------------------------\n    void RenderMaterialGroupManager::Destroy()\n    {\n        m_pendingLoadCommands.clear();\n        m_pendingUnloadCommands.clear();\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Material/RenderMaterialGroupManager.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_MATERIAL_RENDERMATERIALGROUPMANAGER_H_\n#define _CHILLISOURCE_RENDERING_MATERIAL_RENDERMATERIALGROUPMANAGER_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Memory/UniquePtr.h>\n#include <ChilliSource/Core/System/AppSystem.h>\n#include <ChilliSource/Rendering/Material/RenderMaterialGroup.h>\n\n#include <mutex>\n\nnamespace ChilliSource\n{\n    /// Manages the lifecycle of all RenderMaterialGroup instances.\n    ///\n    /// On creation of a RenderMaterialGroup, a LoadMaterialRenderCommand is queued for each\n    /// of the contained materials in the next render snapshot phase, ensuring that related\n    /// material data is processed before the RenderMaterial is used.\n    ///\n    /// On deletion an UnloadMaterialRenderCommand is queued for each RenderMaterialand given ownership of the\n    /// RenderMesh. The RenderMesh is then deleted once the command has been processed.\n    ///\n    /// This is thread-safe and can be called from any thread. If it is called on a background\n    /// thread, care needs to be taken to ensure any created RenderMeshes are not used prior\n    /// to being loaded.\n    ///\n    class RenderMaterialGroupManager : public AppSystem\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(RenderMaterialGroupManager);\n        \n        /// Creates a new unlit RenderMaterialGroup and queues a LoadMaterialGroupRenderCommand for the next\n        /// Render Snapshot stage in the render pipeline.\n        ///\n        /// @param renderTexture\n        ///     The render texture.\n        /// @param isTransparencyEnabled\n        ///     Whether or not transparency is enabled.\n        /// @param isColourWriteEnabled\n        ///     Whether or not colour write is enabled.\n        /// @param isDepthWriteEnabled\n        ///     Whether or not depth write is enabled.\n        /// @param isDepthTestEnabled\n        ///     Whether or not the depth test will be performed.\n        /// @param isFaceCullingEnabled\n        ///     Whether or not face culling will be performed.\n        /// @param isStencilTestEnabled\n        ///     Whether or not to perform stencil testing\n        /// @param depthTestFunc\n        ///     Function that determines whether a depth test comparison should pass or fail\n        /// @param sourceBlendMode\n        ///     The source blend mode. This only applies if transparency is enabled.\n        /// @param destinationBlendMode\n        ///     The destination blend mode. This only applies if transparency is enabled.\n        /// @param stencilFailOp\n        ///     Op applied if stencil test fails\n        /// @param stencilDepthFailOp\n        ///     Op applied if stencil depth test fails\n        /// @param stencilPassOp\n        ///     Op applied if stencil and depth tests pass\n        /// @param stencilTestFunc\n        ///     Function that determines whether a stencil test comparison should pass or fail\n        /// @param stencilRef\n        ///     Value used as comparison for stencil tests\n        /// @param stencilMask\n        ///     Value ANDed to with the comparison and stencil value\n        /// @param cullFace\n        ///     The face which should be called. This only applies if face culling is enabled.\n        /// @param ambientColour\n        ///     The ambient colour.\n        /// @param emissiveColour\n        ///     The ambient colour.\n        ///\n        /// @return The new material group.\n        ///\n        virtual UniquePtr<RenderMaterialGroup> CreateUnlitRenderMaterialGroup(const RenderTexture* renderTexture,\n                                                                  bool isTransparencyEnabled, bool isColourWriteEnabled, bool isDepthWriteEnabled, bool isDepthTestEnabled, bool isFaceCullingEnabled, bool isStencilTestEnabled,\n                                                                  TestFunc depthTestFunc,\n                                                                  BlendMode sourceBlendMode, BlendMode destinationBlendMode,\n                                                                  StencilOp stencilFailOp, StencilOp stencilDepthFailOp, StencilOp stencilPassOp, TestFunc stencilTestFunc, s32 stencilRef, u32 stencilMask,\n                                                                  CullFace cullFace, const Colour& emissiveColour, const Colour& ambientColour) noexcept = 0;\n        \n        /// Creates a new skybox RenderMaterialGroup and queues a LoadMaterialGroupRenderCommand for the next\n        /// Render Snapshot stage in the render pipeline.\n        ///\n        /// @param renderCubmap\n        ///     The render cubemap.\n        ///\n        /// @return The new material group.\n        ///\n        virtual UniquePtr<RenderMaterialGroup> CreateSkyboxRenderMaterialGroup(const RenderTexture* renderCubmap) noexcept = 0;\n        \n        /// Creates a new blinn RenderMaterialGroup and queues a LoadMaterialGroupRenderCommand for the next\n        /// Render Snapshot stage in the render pipeline.\n        ///\n        /// @param renderTexture\n        ///     The render texture.\n        /// @param ambientColour\n        ///     The ambient colour.\n        /// @param emissiveColour\n        ///     The ambient colour.\n        /// @param diffuseColour\n        ///     The diffuse colour.\n        /// @param specularColour\n        ///     The specular colour.\n        ///\n        /// @return The new material group.\n        ///\n        virtual UniquePtr<RenderMaterialGroup> CreateBlinnRenderMaterialGroup(const RenderTexture* renderTexture, const Colour& emissiveColour, const Colour& ambientColour, const Colour& diffuseColour,\n                                                                          const Colour& specularColour) noexcept = 0;\n        \n        \n        /// Creates a new custom RenderMaterialGroup and queues a LoadMaterialGroupRenderCommand for the next\n        /// Render Snapshot stage in the render pipeline.\n        ///\n        /// @param fallbackType\n        ///     Any unspecified render pass shaders us the equivalent shader from the fallback type\n        /// @param vertexFormat\n        ///     The vertex format this material is for.\n        /// @param renderShaders\n        ///     The render shaders for each pass.\n        /// @param renderTextures2D\n        ///     The list of render textures.\n        /// @param renderTexturesCubemap\n        ///     The list of render cubemaps.\n        /// @param isTransparencyEnabled\n        ///     Whether or not transparency is enabled.\n        /// @param isColourWriteEnabled\n        ///     Whether or not colour write is enabled.\n        /// @param isDepthWriteEnabled\n        ///     Whether or not depth write is enabled.\n        /// @param isDepthTestEnabled\n        ///     Whether or not the depth test will be performed.\n        /// @param isFaceCullingEnabled\n        ///     Whether or not face culling will be performed.\n        /// @param isStencilTestEnabled\n        ///     Whether or not to perform stencil testing\n        /// @param depthTestFunc\n        ///     Function that determines whether a depth test comparison should pass or fail\n        /// @param sourceBlendMode\n        ///     The source blend mode. This only applies if transparency is enabled.\n        /// @param destinationBlendMode\n        ///     The destination blend mode. This only applies if transparency is enabled.\n        /// @param stencilFailOp\n        ///     Op applied if stencil test fails\n        /// @param stencilDepthFailOp\n        ///     Op applied if stencil depth test fails\n        /// @param stencilPassOp\n        ///     Op applied if stencil and depth tests pass\n        /// @param stencilTestFunc\n        ///     Function that determines whether a stencil test comparison should pass or fail\n        /// @param stencilRef\n        ///     Value used as comparison for stencil tests\n        /// @param stencilMask\n        ///     Value ANDed to with the comparison and stencil value\n        /// @param cullFace\n        ///     The face which should be called. This only applies if face culling is enabled.\n        /// @param emissiveColour\n        ///     The ambient colour.\n        /// @param ambientColour\n        ///     The ambient colour.\n        /// @param diffuseColour\n        ///     The diffuse colour.\n        /// @param specularColour\n        ///     The specular colour.\n        /// @param renderShaderVariables\n        ///     The container for all render shader variables.\n        ///\n        /// @return The new material group.\n        ///\n        virtual UniquePtr<RenderMaterialGroup> CreateCustomRenderMaterialGroup(MaterialShadingType fallbackType, const VertexFormat& vertexFormat, const std::vector<std::pair<const RenderShader*, RenderPasses>>& renderShaders, const std::vector<const RenderTexture*>& renderTextures2D, const std::vector<const RenderTexture*>& renderTexturesCubemap,\n                                                                   bool isTransparencyEnabled, bool isColourWriteEnabled, bool isDepthWriteEnabled, bool isDepthTestEnabled, bool isFaceCullingEnabled, bool isStencilTestEnabled,\n                                                                   TestFunc depthTestFunc,\n                                                                   BlendMode sourceBlendMode, BlendMode destinationBlendMode,\n                                                                   StencilOp stencilFailOp, StencilOp stencilDepthFailOp, StencilOp stencilPassOp, TestFunc stencilTestFunc, s32 stencilRef, u32 stencilMask,\n                                                                   CullFace cullFace, const Colour& emissiveColour, const Colour& ambientColour, const Colour& diffuseColour, const Colour& specularColour,\n                                                                   RenderShaderVariablesUPtr renderShaderVariables) noexcept = 0;\n        \n        /// Removes the RenderMaterialGroup from the manager and queues an UnloadMaterialGroupRenderCommand\n        /// for the next Render Snapshot stage in the render pipeline. The render command is given ownership\n        /// of the RenderMaterialGroup, ensuring it won't be destroyed until it is no longer used.\n        ///\n        /// @param renderMaterialGroup\n        ///     The RenderMaterialGroup which should be destroyed.\n        ///\n        void DestroyRenderMaterialGroup(UniquePtr<RenderMaterialGroup> renderMaterialGroup) noexcept;\n        \n        virtual ~RenderMaterialGroupManager() noexcept {};\n        \n    protected:\n        RenderMaterialGroupManager() = default;\n        \n        /// Adds a new RenderMaterialGroup to the manager and schedules the load material commands.\n        ///\n        /// @param renderMaterialGroup\n        ///     The new render material group to add.\n        ///\n        void AddRenderMaterialGroup(RenderMaterialGroup* renderMaterialGroup) noexcept;\n        \n    private:\n        friend class Application;\n        \n        /// A factory method for creating new instances of the system. This must be called by\n        /// Application.\n        ///\n        /// @return The new instance of the system.\n        ///\n        static RenderMaterialGroupManagerUPtr Create() noexcept;\n        \n        /// Called during the Render Snapshot stage of the render pipeline. All pending load and\n        /// unload commands are added to the render snapshot.\n        ///\n        /// @param targetType\n        ///     Whether the snapshot is for the main screen or an offscreen render target\n        /// @param renderSnapshot\n        ///     The render shapshot for storing snapshotted data.\n        /// @param frameAllocator\n        ///     Allocate memory for this render frame from here\n        ///\n        void OnRenderSnapshot(TargetType targetType, RenderSnapshot& renderSnapshot, IAllocator* frameAllocator) noexcept override;\n        \n        /// Clears up any pending commands\n        ///\n        void Destroy();\n        \n        std::mutex m_mutex;\n        std::vector<RenderMaterialGroup*> m_pendingLoadCommands;\n        std::vector<UniquePtr<RenderMaterialGroup>> m_pendingUnloadCommands;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Material.h",
    "content": "//\n//  Material.h\n//  ChilliSource\n//  Created by Ian Copland on 07/07/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n\n#ifndef _CHILLISOURCE_RENDERING_MATERIAL_H_\n#define _CHILLISOURCE_RENDERING_MATERIAL_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Rendering/Material/ForwardRenderMaterialGroupManager.h>\n#include <ChilliSource/Rendering/Material/Material.h>\n#include <ChilliSource/Rendering/Material/MaterialFactory.h>\n#include <ChilliSource/Rendering/Material/MaterialProvider.h>\n#include <ChilliSource/Rendering/Material/RenderMaterial.h>\n#include <ChilliSource/Rendering/Material/RenderMaterialGroup.h>\n#include <ChilliSource/Rendering/Material/RenderMaterialGroupManager.h>\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Model/AnimatedModelComponent.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2011 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Model/AnimatedModelComponent.h>\n\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/Entity/Entity.h>\n#include <ChilliSource/Rendering/Base/RenderSnapshot.h>\n#include <ChilliSource/Rendering/Material/Material.h>\n#include <ChilliSource/Rendering/Model/Skeleton.h>\n\n#include <algorithm>\n#include <limits>\n\nnamespace ChilliSource\n{\n    CS_DEFINE_NAMEDTYPE(AnimatedModelComponent);\n    \n    //------------------------------------------------------------------------------\n    AnimatedModelComponent::AnimatedModelComponent(const ModelCSPtr& in_model, const MaterialCSPtr& material, const SkinnedAnimationCSPtr& skinnedAnimation, PlaybackType playbackType) noexcept\n    :  m_model(in_model)\n    {\n        CS_ASSERT(in_model, \"Model cannot be null\");\n        CS_ASSERT(in_model->GetLoadState() == Resource::LoadState::k_loaded, \"Cannot use a model that hasn't been loaded yet.\");\n        CS_ASSERT(material, \"Material cannot be null\");\n        CS_ASSERT(material->GetLoadState() == Resource::LoadState::k_loaded, \"Cannot use a material that hasn't been loaded yet.\");\n        \n        m_materials.resize(in_model->GetNumMeshes());\n        for (u32 i = 0; i < u32(m_materials.size()); ++i)\n        {\n            m_materials[i] = material;\n        }\n        \n        Reset();\n        SetAnimation(skinnedAnimation, playbackType);\n    }\n    \n    //------------------------------------------------------------------------------\n    AnimatedModelComponent::AnimatedModelComponent(const ModelCSPtr& model, const std::vector<MaterialCSPtr>& materials, const SkinnedAnimationCSPtr& skinnedAnimation, PlaybackType playbackType) noexcept\n        : m_model(model), m_materials(materials)\n    {\n#if CS_ENABLE_DEBUG\n        CS_ASSERT(m_model, \"Model cannot be null\");\n        CS_ASSERT(m_model->GetLoadState() == Resource::LoadState::k_loaded, \"Cannot use a model that hasn't been loaded yet.\");\n        CS_ASSERT(m_materials.size() == m_model->GetNumMeshes(), \"Model component must have the same number of materials as there are meshes in the model.\");\n        \n        for (const auto& material : m_materials)\n        {\n            CS_ASSERT(material, \"Material cannot be null\");\n            CS_ASSERT(material->GetLoadState() == Resource::LoadState::k_loaded, \"Cannot use a material that hasn't been loaded yet.\");\n        }\n#endif\n        \n        Reset();\n        SetAnimation(skinnedAnimation, playbackType);\n    }\n    \n    //------------------------------------------------------------------------------\n    bool AnimatedModelComponent::IsA(InterfaceIDType interfaceId) const noexcept\n    {\n        return  (interfaceId == VolumeComponent::InterfaceID || interfaceId == AnimatedModelComponent::InterfaceID);\n    }\n    \n    //------------------------------------------------------------------------------\n    const AABB& AnimatedModelComponent::GetAABB() noexcept\n    {\n        if(GetEntity())\n        {\n            //Rebuild the box\n            const AABB& cAABB = m_model->GetAABB();\n            const Matrix4& matWorld = GetEntity()->GetTransform().GetWorldTransform();\n            Vector3 vBackBottomLeft(cAABB.BackBottomLeft() * matWorld);\n            Vector3 vBackBottomRight(cAABB.BackBottomRight() * matWorld);\n            Vector3 vBackTopLeft(cAABB.BackTopLeft() * matWorld);\n            Vector3 vBackTopRight(cAABB.BackTopRight() * matWorld);\n            Vector3 vFrontBottomLeft(cAABB.FrontBottomLeft() * matWorld);\n            Vector3 vFrontBottomRight(cAABB.FrontBottomRight() * matWorld);\n            Vector3 vFrontTopLeft(cAABB.FrontTopLeft() *matWorld);\n            Vector3 vFrontTopRight(cAABB.FrontTopRight() * matWorld);\n            \n            Vector3 vMin(std::numeric_limits<f32>::infinity(), std::numeric_limits<f32>::infinity(), std::numeric_limits<f32>::infinity());\n            vMin.x = std::min(vMin.x, vBackBottomLeft.x);\n            vMin.x = std::min(vMin.x, vBackBottomRight.x);\n            vMin.x = std::min(vMin.x, vBackTopLeft.x);\n            vMin.x = std::min(vMin.x, vBackTopRight.x);\n            vMin.x = std::min(vMin.x, vFrontBottomLeft.x);\n            vMin.x = std::min(vMin.x, vFrontBottomRight.x);\n            vMin.x = std::min(vMin.x, vFrontTopLeft.x);\n            vMin.x = std::min(vMin.x, vFrontTopRight.x);\n            \n            vMin.y = std::min(vMin.y, vBackBottomLeft.y);\n            vMin.y = std::min(vMin.y, vBackBottomRight.y);\n            vMin.y = std::min(vMin.y, vBackTopLeft.y);\n            vMin.y = std::min(vMin.y, vBackTopRight.y);\n            vMin.y = std::min(vMin.y, vFrontBottomLeft.y);\n            vMin.y = std::min(vMin.y, vFrontBottomRight.y);\n            vMin.y = std::min(vMin.y, vFrontTopLeft.y);\n            vMin.y = std::min(vMin.y, vFrontTopRight.y);\n            \n            vMin.z = std::min(vMin.z, vBackBottomLeft.z);\n            vMin.z = std::min(vMin.z, vBackBottomRight.z);\n            vMin.z = std::min(vMin.z, vBackTopLeft.z);\n            vMin.z = std::min(vMin.z, vBackTopRight.z);\n            vMin.z = std::min(vMin.z, vFrontBottomLeft.z);\n            vMin.z = std::min(vMin.z, vFrontBottomRight.z);\n            vMin.z = std::min(vMin.z, vFrontTopLeft.z);\n            vMin.z = std::min(vMin.z, vFrontTopRight.z);\n            \n            Vector3 vMax(-std::numeric_limits<f32>::infinity(), -std::numeric_limits<f32>::infinity(), -std::numeric_limits<f32>::infinity());\n            vMax.x = std::max(vMax.x, vBackBottomLeft.x);\n            vMax.x = std::max(vMax.x, vBackBottomRight.x);\n            vMax.x = std::max(vMax.x, vBackTopLeft.x);\n            vMax.x = std::max(vMax.x, vBackTopRight.x);\n            vMax.x = std::max(vMax.x, vFrontBottomLeft.x);\n            vMax.x = std::max(vMax.x, vFrontBottomRight.x);\n            vMax.x = std::max(vMax.x, vFrontTopLeft.x);\n            vMax.x = std::max(vMax.x, vFrontTopRight.x);\n            \n            vMax.y = std::max(vMax.y, vBackBottomLeft.y);\n            vMax.y = std::max(vMax.y, vBackBottomRight.y);\n            vMax.y = std::max(vMax.y, vBackTopLeft.y);\n            vMax.y = std::max(vMax.y, vBackTopRight.y);\n            vMax.y = std::max(vMax.y, vFrontBottomLeft.y);\n            vMax.y = std::max(vMax.y, vFrontBottomRight.y);\n            vMax.y = std::max(vMax.y, vFrontTopLeft.y);\n            vMax.y = std::max(vMax.y, vFrontTopRight.y);\n            \n            vMax.z = std::max(vMax.z, vBackBottomLeft.z);\n            vMax.z = std::max(vMax.z, vBackBottomRight.z);\n            vMax.z = std::max(vMax.z, vBackTopLeft.z);\n            vMax.z = std::max(vMax.z, vBackTopRight.z);\n            vMax.z = std::max(vMax.z, vFrontBottomLeft.z);\n            vMax.z = std::max(vMax.z, vFrontBottomRight.z);\n            vMax.z = std::max(vMax.z, vFrontTopLeft.z);\n            vMax.z = std::max(vMax.z, vFrontTopRight.z);\n            \n            m_aabb.SetSize( vMax - vMin );\n            m_aabb.SetOrigin( cAABB.Centre() * matWorld);\n            \n        }\n        \n        return m_aabb;\n    }\n    \n    //------------------------------------------------------------------------------\n    const OOBB& AnimatedModelComponent::GetOOBB() noexcept\n    {\n        if(GetEntity())\n        {\n            m_oobb.SetTransform(GetEntity()->GetTransform().GetWorldTransform());\n        }\n        return m_oobb;\n    }\n    \n    //------------------------------------------------------------------------------\n    const Sphere& AnimatedModelComponent::GetBoundingSphere() noexcept\n    {\n        if(GetEntity())\n        {\n            const AABB& sAABB = GetAABB();\n            m_boundingSphere.vOrigin = sAABB.GetOrigin();\n            m_boundingSphere.fRadius = (sAABB.BackTopRight() - sAABB.FrontBottomLeft()).Length() * 0.5f;\n        }\n        return m_boundingSphere;\n    }\n    \n    //------------------------------------------------------------------------------\n    const ModelCSPtr& AnimatedModelComponent::GetModel() const noexcept\n    {\n        return m_model;\n    }\n    \n    //------------------------------------------------------------------------------\n    void AnimatedModelComponent::SetModel(const ModelCSPtr& model) noexcept\n    {\n        CS_ASSERT(model, \"Cannot set null model.\");\n        CS_ASSERT(model->GetLoadState() == Resource::LoadState::k_loaded, \"Cannot use a model that hasn't been loaded yet.\");\n        \n        m_model = model;\n        m_materials.resize(model->GetNumMeshes());\n        \n        m_oobb.SetSize(m_model->GetAABB().GetSize());\n        m_oobb.SetOrigin(m_model->GetAABB().GetOrigin());\n        \n        SetMaterial(GetMaterialForMesh(0));\n        \n        Reset();\n    }\n    \n    //------------------------------------------------------------------------------\n    void AnimatedModelComponent::SetModel(const ModelCSPtr& model, const MaterialCSPtr& material) noexcept\n    {\n        CS_ASSERT(model, \"Cannot set null model.\");\n        CS_ASSERT(model->GetLoadState() == Resource::LoadState::k_loaded, \"Cannot use a model that hasn't been loaded yet.\");\n        CS_ASSERT(material, \"Cannot set null material.\");\n        CS_ASSERT(material->GetLoadState() == Resource::LoadState::k_loaded, \"Cannot use a material that hasn't been loaded yet.\");\n        \n        m_model = model;\n        m_materials.resize(m_model->GetNumMeshes());\n        \n        m_oobb.SetSize(m_model->GetAABB().GetSize());\n        m_oobb.SetOrigin(m_model->GetAABB().GetOrigin());\n        \n        SetMaterial(material);\n        \n        Reset();\n    }\n    \n    //------------------------------------------------------------------------------\n    void AnimatedModelComponent::SetModel(const ModelCSPtr& model, const std::vector<MaterialCSPtr>& materials) noexcept\n    {\n#if CS_ENABLE_DEBUG\n        CS_ASSERT(model, \"Cannot set null model.\");\n        CS_ASSERT(model->GetLoadState() == Resource::LoadState::k_loaded, \"Cannot use a model that hasn't been loaded yet.\");\n        CS_ASSERT(materials.size() == model->GetNumMeshes(), \"Model component must have the same number of materials as there are meshes in the model.\");\n        \n        for (const auto& material : materials)\n        {\n            CS_ASSERT(material, \"Material cannot be null\");\n            CS_ASSERT(material->GetLoadState() == Resource::LoadState::k_loaded, \"Cannot use a material that hasn't been loaded yet.\");\n        }\n#endif\n        m_model = model;\n        m_materials = materials;\n        \n        m_oobb.SetSize(m_model->GetAABB().GetSize());\n        m_oobb.SetOrigin(m_model->GetAABB().GetOrigin());\n        \n        Reset();\n    }\n    \n    //------------------------------------------------------------------------------\n    void AnimatedModelComponent::SetModel(const ModelCSPtr& model, const SkinnedAnimationCSPtr& skinnedAnimation, PlaybackType playbackType) noexcept\n    {\n        SetModel(model);\n        SetAnimation(skinnedAnimation, playbackType);\n    }\n    \n    //------------------------------------------------------------------------------\n    void AnimatedModelComponent::SetModel(const ModelCSPtr& model, const MaterialCSPtr& material, const SkinnedAnimationCSPtr& skinnedAnimation, PlaybackType playbackType) noexcept\n    {\n        SetModel(model, material);\n        SetAnimation(skinnedAnimation, playbackType);\n    }\n    \n    //------------------------------------------------------------------------------\n    void AnimatedModelComponent::SetModel(const ModelCSPtr& model, const std::vector<MaterialCSPtr>& materials, const SkinnedAnimationCSPtr& skinnedAnimation, PlaybackType playbackType) noexcept\n    {\n        SetModel(model, materials);\n        SetAnimation(skinnedAnimation, playbackType);\n    }\n    \n    //------------------------------------------------------------------------------\n    const MaterialCSPtr& AnimatedModelComponent::GetMaterialForMesh(u32 meshIndex) const noexcept\n    {\n        CS_ASSERT(meshIndex < s32(m_materials.size()), \"Invalid mesh index.\");\n        \n        return m_materials[meshIndex];\n    }\n    \n    //------------------------------------------------------------------------------\n    const MaterialCSPtr& AnimatedModelComponent::GetMaterialForMesh(const std::string& meshName) const noexcept\n    {\n        CS_ASSERT(m_model, \"Cannot get material without a model.\");\n        \n        auto meshIndex = m_model->GetMeshIndex(meshName);\n        CS_ASSERT(meshIndex >= 0 && meshIndex < s32(m_materials.size()), \"Invalid mesh index.\");\n        \n        return m_materials[meshIndex];\n    }\n    \n    //------------------------------------------------------------------------------\n    void AnimatedModelComponent::SetMaterial(const MaterialCSPtr& material) noexcept\n    {\n        CS_ASSERT(m_model, \"Cannot set material without a model.\");\n        CS_ASSERT(material, \"Cannot set null material.\");\n        CS_ASSERT(material->GetLoadState() == Resource::LoadState::k_loaded, \"Cannot use a material that hasn't been loaded yet.\");\n        \n        for (u32 i = 0; i < m_materials.size(); i++)\n        {\n            m_materials[i] = material;\n        }\n    }\n    \n    //------------------------------------------------------------------------------\n    void AnimatedModelComponent::SetMaterialForMesh(const MaterialCSPtr& material, u32 meshIndex) noexcept\n    {\n        CS_ASSERT(m_model, \"Cannot set material without a model.\");\n        CS_ASSERT(material, \"Cannot set null material.\");\n        CS_ASSERT(material->GetLoadState() == Resource::LoadState::k_loaded, \"Cannot use a material that hasn't been loaded yet.\");\n        CS_ASSERT(meshIndex < s32(m_materials.size()), \"Invalid mesh index.\");\n        \n        m_materials[meshIndex] = material;\n    }\n    \n    //------------------------------------------------------------------------------\n    void AnimatedModelComponent::SetMaterialForMesh(const MaterialCSPtr& material, const std::string& meshName) noexcept\n    {\n        CS_ASSERT(m_model, \"Cannot set material without a model.\");\n        CS_ASSERT(material, \"Cannot set null material.\");\n        CS_ASSERT(material->GetLoadState() == Resource::LoadState::k_loaded, \"Cannot use a material that hasn't been loaded yet.\");\n        \n        auto meshIndex = m_model->GetMeshIndex(meshName);\n        CS_ASSERT(meshIndex >= 0 && meshIndex < s32(m_materials.size()), \"Invalid mesh index.\");\n        \n        m_materials[meshIndex] = material;\n    }\n    \n    //------------------------------------------------------------------------------\n    std::vector<SkinnedAnimationCSPtr> AnimatedModelComponent::GetAnimations() const noexcept\n    {\n        CS_ASSERT(m_activeAnimationGroup, \"There must be an active animation group.\");\n        \n        std::vector<SkinnedAnimationCSPtr> output;\n        m_activeAnimationGroup->GetAnimations(output);\n        \n        return output;\n    }\n    \n    //------------------------------------------------------------------------------\n    void AnimatedModelComponent::SetAnimation(const SkinnedAnimationCSPtr& animation, PlaybackType playbackType) noexcept\n    {\n        ClearAnimations();\n        AttachAnimation(animation, 0.0f);\n        SetPlaybackType(playbackType);\n    }\n    \n    //------------------------------------------------------------------------------\n    void AnimatedModelComponent::AttachAnimation(const SkinnedAnimationCSPtr& animation, f32 blendlinePosition) noexcept\n    {\n        CS_ASSERT(m_activeAnimationGroup, \"There must be an active animation group.\");\n        \n        m_activeAnimationGroup->AttachAnimation(animation, blendlinePosition);\n        m_animationDataDirty = true;\n    }\n    \n    //------------------------------------------------------------------------------\n    void AnimatedModelComponent::DetatchAnimation(const SkinnedAnimationCSPtr& animation) noexcept\n    {\n        CS_ASSERT(m_activeAnimationGroup, \"There must be an active animation group.\");\n\n        m_activeAnimationGroup->DetatchAnimation(animation);\n    }\n    \n    //------------------------------------------------------------------------------\n    void AnimatedModelComponent::FadeTo(const SkinnedAnimationCSPtr& animation, PlaybackType playbackType, AnimationBlendType fadeType, f32 fadeOutTime) noexcept\n    {\n        FadeOut(fadeType, fadeOutTime);\n        AttachAnimation(animation, 0.0f);\n        SetPlaybackType(playbackType);\n    }\n    \n    //------------------------------------------------------------------------------\n    void AnimatedModelComponent::FadeOut(AnimationBlendType fadeType, f32 fadeOutTime) noexcept\n    {\n        CS_ASSERT(m_activeAnimationGroup, \"There must be an active animation group.\");\n        \n        if (m_activeAnimationGroup->IsPrepared())\n        {\n            m_fadingAnimationGroup = m_activeAnimationGroup;\n            m_activeAnimationGroup = SkinnedAnimationGroupSPtr(new SkinnedAnimationGroup(m_model->GetSkeleton()));\n            m_fadePlaybackPosition = m_playbackPosition;\n            m_fadeBlendlinePosition = m_blendlinePosition;\n            m_maxFadeTime = fadeOutTime;\n            m_fadeTimer = 0.0f;\n            SetPlaybackPosition(0.0f);\n            m_animationChangedEvent.NotifyConnections(this);\n        }\n        else\n        {\n            m_activeAnimationGroup->ClearAnimations();\n        }\n    }\n    \n    //------------------------------------------------------------------------------\n    void AnimatedModelComponent::ClearAnimations() noexcept\n    {\n        CS_ASSERT(m_activeAnimationGroup, \"There must be an active animation group.\");\n\n        m_activeAnimationGroup->ClearAnimations();\n        m_fadingAnimationGroup.reset();\n        SetPlaybackPosition(0.0f);\n        m_blendlinePosition = 0.0f;\n        m_fadeTimer = 0.0f;\n        m_animationChangedEvent.NotifyConnections(this);\n    }\n    \n    //------------------------------------------------------------------------------\n    void AnimatedModelComponent::SetBlendlinePosition(f32 blendlinePosition) noexcept\n    {\n        m_blendlinePosition = blendlinePosition;\n    }\n    \n    //------------------------------------------------------------------------------\n    void AnimatedModelComponent::SetPlaybackType(PlaybackType playbackType) noexcept\n    {\n        m_playbackType = playbackType;\n        m_finished = false;\n    }\n    \n    //------------------------------------------------------------------------------\n    void AnimatedModelComponent::SetPlaybackPosition(f32 position) noexcept\n    {\n        m_playbackPosition = position;\n        m_finished = false;\n        m_animationDataDirty = true;\n    }\n    \n    //------------------------------------------------------------------------------\n    void AnimatedModelComponent::SetPlaybackPositionNormalised(f32 position) noexcept\n    {\n        m_playbackPosition = position * GetAnimationLength();\n        m_finished = false;\n    }\n    \n    //------------------------------------------------------------------------------\n    f32 AnimatedModelComponent::GetAnimationLength() const noexcept\n    {\n        CS_ASSERT(m_activeAnimationGroup, \"There must be an active animation group.\");\n        \n        return m_activeAnimationGroup->GetAnimationLength();\n    }\n\n    //------------------------------------------------------------------------------\n    void AnimatedModelComponent::AttachEntity(const EntitySPtr& entity, const std::string& nodeName) noexcept\n    {\n        if (nullptr == GetEntity())\n        {\n            CS_LOG_ERROR(\"Could not attach entity to animated mesh because the mesh is not yet attached to an entity.\");\n            return;\n        }\n        \n        if (nullptr != entity->GetParent() || nullptr != entity->GetScene())\n        {\n            CS_LOG_ERROR(\"Could not attach entity to animated mesh because the entity already has a parent.\");\n            return;\n        }\n        \n        //check that it has not already been added.\n        for (auto it = m_attachedEntities.begin(); it != m_attachedEntities.end(); ++it)\n        {\n            if (EntitySPtr attachedEntity = it->first.lock())\n            {\n                CS_ASSERT(attachedEntity.get() != entity.get(), \"Entity is already attached.\");\n            }\n        }\n        \n        s32 dwNodeIndex = m_model->GetSkeleton().GetNodeIndexByName(nodeName);\n        CS_ASSERT(dwNodeIndex != -1, \"Could not attach entity to the animated mesh because the skeleton node name could not be found.\");\n\n        GetEntity()->AddEntity(entity);\n        m_attachedEntities.push_back(std::pair<EntityWPtr, s32>(EntityWPtr(entity), dwNodeIndex));\n    }\n    \n    //------------------------------------------------------------------------------\n    void AnimatedModelComponent::DetatchEntity(const Entity* inpEntity) noexcept\n    {\n        AttachedEntityList::iterator it;\n        for (it = m_attachedEntities.begin(); it != m_attachedEntities.end(); ++it)\n        {\n            if (EntitySPtr pEntity = it->first.lock())\n            {\n                if (pEntity.get() == inpEntity)\n                {\n                    pEntity->RemoveFromParent();\n                    break;\n                }\n            }\n        }\n        \n        if (it != m_attachedEntities.end())\n        {\n            m_attachedEntities.erase(it);\n        }\n    }\n    \n    //------------------------------------------------------------------------------\n    void AnimatedModelComponent::DetatchAllEntities() noexcept\n    {\n        for (AttachedEntityList::const_iterator it = m_attachedEntities.begin(); it != m_attachedEntities.end(); ++it)\n        {\n            if (EntitySPtr pEntity = it->first.lock())\n            {\n                pEntity->RemoveFromParent();\n            }\n        }\n        \n        m_attachedEntities.clear();\n    }\n    \n    //------------------------------------------------------------------------------\n    void AnimatedModelComponent::UpdateAnimation(f32 deltaTime) noexcept\n    {\n        CS_ASSERT(GetEntity(), \"Must be attached to an entity.\");\n        CS_ASSERT(GetEntity()->GetScene(), \"Must be attached to the scene.\");\n        CS_ASSERT(m_activeAnimationGroup, \"Must have an active animation group.\");\n        CS_ASSERT(m_activeAnimationGroup->GetAnimationCount() > 0, \"Must have at least one attached animation.\");\n        \n        UpdateAnimationTimer(deltaTime);\n        m_activeAnimationGroup->BuildAnimationData(m_animationBlendType, m_playbackPosition, m_blendlinePosition);\n        \n        //if there is a group fading out, then apply this to the active data.\n        if (m_fadingAnimationGroup)\n        {\n            if (m_maxFadeTime > 0.0f && m_fadeTimer < m_maxFadeTime)\n            {\n                m_fadingAnimationGroup->BuildAnimationData(m_animationBlendType, m_fadePlaybackPosition, m_fadeBlendlinePosition);\n                f32 fGroupBlendFactor = 1.0f - (m_fadeTimer / m_maxFadeTime);\n                m_activeAnimationGroup->BlendGroup(m_animationBlendType, m_fadingAnimationGroup, fGroupBlendFactor);\n            }\n            else\n            {\n                m_fadingAnimationGroup.reset();\n            }\n        }\n        \n        m_activeAnimationGroup->BuildMatrices();\n        UpdateAttachedEntities();\n        \n        m_animationDataDirty = false;\n    }\n    \n    //------------------------------------------------------------------------------\n    void AnimatedModelComponent::UpdateAnimationTimer(f32 deltaTime) noexcept\n    {\n        CS_ASSERT(m_activeAnimationGroup, \"Must have an active animation group.\");\n        \n        //Update the playback position\n        m_playbackPosition += deltaTime * m_playbackSpeedMultiplier;\n        \n        switch (m_playbackType)\n        {\n            case PlaybackType::k_once:\n            {\n                if (m_playbackPosition >= m_activeAnimationGroup->GetAnimationLength())\n                {\n                    m_playbackPosition = m_activeAnimationGroup->GetAnimationLength();\n                    m_finished = true;\n                    m_animationCompletionEvent.NotifyConnections(this);\n                }\n                break;\n            }\n            case PlaybackType::k_looping:\n            {\n                while (m_playbackPosition >= m_activeAnimationGroup->GetAnimationLength() && m_activeAnimationGroup->GetAnimationLength() > 0.0f)\n                {\n                    m_playbackPosition -= m_activeAnimationGroup->GetAnimationLength();\n                    m_animationLoopedEvent.NotifyConnections(this);\n                }\n                break;\n            }\n        }\n        \n        //update the fade timer\n        if (m_fadingAnimationGroup)\n        {\n            m_fadeTimer += deltaTime;\n        }\n    }\n    \n    //------------------------------------------------------------------------------\n    void AnimatedModelComponent::UpdateAttachedEntities() noexcept\n    {\n        CS_ASSERT(m_activeAnimationGroup, \"Must have an active animation group.\");\n\n        for (AttachedEntityList::iterator it = m_attachedEntities.begin(); it != m_attachedEntities.end();)\n        {\n            if (EntitySPtr pEntity = it->first.lock())\n            {\n                s32 dwNodeIndex = it->second;\n                \n                const Matrix4& matTransform = m_activeAnimationGroup->GetMatrixAtIndex(dwNodeIndex);\n                pEntity->GetTransform().SetLocalTransform(matTransform);\n                ++it;\n            }\n            else\n            {\n                it = m_attachedEntities.erase(it);\n            }\n        }\n    }\n    \n    //------------------------------------------------------------------------------\n    void AnimatedModelComponent::Reset() noexcept\n    {\n        DetatchAllEntities();\n        m_activeAnimationGroup = SkinnedAnimationGroupSPtr(new SkinnedAnimationGroup(m_model->GetSkeleton()));\n        m_fadingAnimationGroup.reset();\n        m_blendlinePosition = 0.0f;\n        m_fadeTimer = 0.0f;\n        SetPlaybackPosition(0.0f);\n    }\n    \n    //------------------------------------------------------------------------------\n    void AnimatedModelComponent::OnAddedToScene() noexcept\n    {\n        SetPlaybackPosition(0.0f);\n    }\n    \n    //------------------------------------------------------------------------------\n    void AnimatedModelComponent::OnUpdate(f32 deltaTime) noexcept\n    {\n        UpdateAnimation(deltaTime);\n    }\n    \n    //------------------------------------------------------------------------------\n    void AnimatedModelComponent::OnRenderSnapshot(RenderSnapshot& renderSnapshot, IAllocator* frameAllocator) noexcept\n    {\n        CS_ASSERT(m_model->GetLoadState() == Resource::LoadState::k_loaded, \"Cannot use a model that hasn't been loaded yet.\");\n        CS_ASSERT(m_model->GetNumMeshes() == m_materials.size(), \"Invalid number of materials.\");\n        CS_ASSERT(m_activeAnimationGroup, \"An animated model must always have an active animation group.\");\n        \n        if (m_animationDataDirty == true)\n        {\n            UpdateAnimation(0.0f);\n        }\n        \n        for (u32 index = 0; index < m_model->GetNumMeshes(); ++index)\n        {\n            CS_ASSERT(m_materials[index]->GetLoadState() == Resource::LoadState::k_loaded, \"Cannot use a material that hasn't been loaded yet.\");\n            \n            auto renderMaterialGroup = m_materials[index]->GetRenderMaterialGroup();\n            auto renderMesh = m_model->GetRenderMesh(index);\n            \n            const auto& transform = GetEntity()->GetTransform();\n            auto boundingSphere = Sphere::Transform(renderMesh->GetBoundingSphere(), transform.GetWorldPosition(), transform.GetWorldOrientation(), transform.GetWorldScale());\n            \n            RenderSkinnedAnimationAUPtr renderSkinnedAnimation;\n            if (m_activeAnimationGroup->IsPrepared() == true)\n            {\n                renderSkinnedAnimation = m_activeAnimationGroup->BuildRenderSkinnedAnimation(frameAllocator, renderMesh->GetInverseBindPoseMatrices());\n            }\n            else if (m_fadingAnimationGroup != nullptr && m_fadingAnimationGroup->IsPrepared() == true)\n            {\n                renderSkinnedAnimation = m_fadingAnimationGroup->BuildRenderSkinnedAnimation(frameAllocator, renderMesh->GetInverseBindPoseMatrices());\n            }\n            \n            CS_ASSERT(renderSkinnedAnimation, \"No render skinned animation.\");\n            renderSnapshot.AddRenderObject(RenderObject(renderMaterialGroup, renderMesh, renderSkinnedAnimation.get(), GetEntity()->GetTransform().GetWorldTransform(), boundingSphere,\n                                                           m_shadowCastingEnabled, RenderLayer::k_standard));\n            renderSnapshot.AddRenderSkinnedAnimation(std::move(renderSkinnedAnimation));\n        }\n    }\n    \n    //------------------------------------------------------------------------------\n    void AnimatedModelComponent::OnRemovedFromScene() noexcept\n    {\n        DetatchAllEntities();\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Model/AnimatedModelComponent.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2011 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_ANIMATED_MESH_COMPONENT_H_\n#define _CHILLISOURCE_RENDERING_ANIMATED_MESH_COMPONENT_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Event/Event.h>\n#include <ChilliSource/Core/File/FileSystem.h>\n#include <ChilliSource/Core/Volume/VolumeComponent.h>\n#include <ChilliSource/Rendering/Model/SkinnedAnimationGroup.h>\n#include <ChilliSource/Rendering/Model/Model.h>\n\n#include <functional>\n\nnamespace ChilliSource\n{\n    /// A component for playback of skinned animations. Animations can be set either through\n    /// the constructor or by using SetAnimation(). An animation must always be active (though not\n    /// necessarily playing) on a AnimatedModelComponent, otherwise it will assert.\n    ///\n    /// Animations can be played back either looping on set to \"once\". Looping animations will loop\n    /// indefinitely and send the animation looped event every time it re-starts from the\n    /// beginning. A playback type of \"once\" will result in the animation playing through to the\n    /// end and the remaining on the final frame indefinitely. The animation completion event\n    /// will also be sent.\n    ///\n    /// At any time while an animation is playing a new animation be faded into by calling FadeTo(),\n    /// supplying the new animation that should be played.\n    ///\n    /// Although basic animation can be handled by setting a single animation at a time, more\n    /// complex animations can be handled though animation blending. Instead of setting animations\n    /// using SetAnimation(), models using blended animation have multiple animations attached using\n    /// AttachAnimation(), which allows the animation to be attached to a specific point on the\n    /// \"Blend line\". The current blendline value can be altered at anytime and determines what\n    /// portion of each animation is blended.\n    ///\n    /// When using Animation blending FadeOut() can be used instead of FadeTo(), in which a new\n    /// animation or series of animations must be attached immediately.\n    ///\n    /// This is not thread-safe and should only be accessed from the main thread.\n    ///\n    class AnimatedModelComponent final : public VolumeComponent\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(AnimatedModelComponent);\n        \n        /// An enum describing the different types of playback that are available.\n        ///\n        /// Looping animations will loop indefinitely and send the animation looped event every time it re-starts\n        /// from the beginning.\n        ///\n        /// A playback type of \"once\" will result in the animation playing through to the end and the remaining on\n        /// the final frame indefinitely. The animation completion event will also be sent.\n        ///\n        enum class PlaybackType\n        {\n            k_once,\n            k_looping\n        };\n        \n        /// A delegate which is called whenever the animation changes.\n        ///\n        /// @param animatedModelComponent\n        ///     The animated model component which has changed.\n        ///\n        using AnimationChangedDelegate = std::function<void(AnimatedModelComponent* animatedModelComponent)>;\n\n        /// A delegate which is called when animations with a playback type of \"once\" finish animating.\n        ///\n        /// @param animatedModelComponent\n        ///     The animated model component which has completed.\n        ///\n        typedef std::function<void(AnimatedModelComponent*)> AnimationCompletionDelegate;\n\n        /// A delegate which is called when animations with a playback type of \"looping\" finish a single\n        /// playthrough of the animation and start again.\n        ///\n        /// @param animatedModelComponent\n        ///     The animated model component which has completed.\n        ///\n        typedef std::function<void(AnimatedModelComponent*)> AnimationLoopedDelegate;\n        \n        /// Creates a new animated model component with the given model, material and animation.\n        ///\n        /// @param model\n        ///     The model which should be rendered. Must have animation data or this will assert.\n        /// @param material\n        ///     The material that will be applied to all meshes in the model.\n        /// @param skinnedAnimation\n        ///     The initial animation of the model.\n        /// @param playbackType\n        ///     The playback type that should be used.\n        ///\n        AnimatedModelComponent(const ModelCSPtr& model, const MaterialCSPtr& material, const SkinnedAnimationCSPtr& skinnedAnimation, PlaybackType playbackType) noexcept;\n        \n        /// Creates a new animated model component with the given model, material and animation.\n        ///\n        /// @param model\n        ///     The model which should be rendered. Must have animation data or this will assert.\n        /// @param materials\n        ///     The material for each mesh in the model. Must have the same number of elements as\n        ///     there are meshes in the given model.\n        /// @param skinnedAnimation\n        ///     The initial animation of the model.\n        /// @param playbackType\n        ///     The playback type that should be used.\n        ///\n        AnimatedModelComponent(const ModelCSPtr& in_model, const std::vector<MaterialCSPtr>& materials, const SkinnedAnimationCSPtr& skinnedAnimation, PlaybackType playbackType) noexcept;\n\n        /// Allows querying of whether or not this component implements the interface described\n        /// by the given interface Id. Typically this is not called directly as the templated\n        /// equivalent IsA<Interface>() is preferred.\n        ///\n        /// @param interfaceId\n        ///     The Id of the interface.\n        ///\n        /// @return Whether or not the interface is implemented.\n        ///\n        bool IsA(InterfaceIDType interfaceId) const noexcept override;\n\n        /// Calculates and returns the world space AABB of the model. This is cached and only\n        /// recomputed when required.\n        ///\n        /// @return The world space axis-aligned bounding box\n        ///\n        const AABB& GetAABB() noexcept override;\n        \n        /// Calculates and returns the world space OOBB of the model. This is cached and only\n        /// recomputed when required.\n        ///\n        /// @return The world space OOBB\n        ///\n        const OOBB& GetOOBB() noexcept override;\n        \n        /// Calculates and returns the world space bounding sphere of the model. This is cached\n        /// and only recomputed when required.\n        ///\n        /// @return The world space bounding sphere\n        ///\n        const Sphere& GetBoundingSphere() noexcept override;\n        \n        /// @return Whether or not the object should be rendered.\n        ///\n        bool IsVisible() const noexcept override { return m_isVisible; }\n        \n        /// @param isVisible\n        ///     Whether or not the object should be rendered.\n        ///\n        void SetVisible(bool isVisible) noexcept { m_isVisible = isVisible; }\n        \n        /// @return The model that will be rendered.\n        ///\n        const ModelCSPtr& GetModel() const noexcept;\n        \n        /// Sets the model the component should use.\n        ///\n        /// The material currently applied to the first mesh will be applied to the entire model.\n        ///\n        /// The current animation will be invalidated meaning that a new animation must be attached\n        /// prior to the next render snapshot or an assertion will occur.\n        ///\n        /// @param model\n        ///     The model which should be used.\n        ///\n        void SetModel(const ModelCSPtr& model) noexcept;\n        \n        /// Sets the model the component should use. The given material will be applied to all meshes.\n        ///\n        /// The current animation will be invalidated meaning that a new animation must be attached\n        /// prior to the next render snapshot or an assertion will occur.\n        ///\n        /// @param model\n        ///     The model which should be used.\n        /// @param material\n        ///     The material which should be used.\n        ///\n        void SetModel(const ModelCSPtr& model, const MaterialCSPtr& material) noexcept;\n        \n        /// Sets the model the component should use. The given materials will be applied to the\n        /// respective meshes.\n        ///\n        /// The current animation will be invalidated meaning that a new animation must be attached\n        /// prior to the next render snapshot or an assertion will occur.\n        ///\n        /// @param model\n        ///     The model which should be used.\n        /// @param materials\n        ///     The material for each mesh in the model. Must have the same number of elements as\n        ///     there are meshes in the given model.\n        ///\n        void SetModel(const ModelCSPtr& model, const std::vector<MaterialCSPtr>& materials) noexcept;\n        \n        /// Sets the model and animation the component should use.\n        ///\n        /// The material currently applied to the first mesh will be applied to the entire model.\n        ///\n        /// @param model\n        ///     The model which should be used.\n        /// @param skinnedAnimation\n        ///     The skinned animation that should be used.\n        /// @param playbackType\n        ///     The playback type that should be used.\n        ///\n        void SetModel(const ModelCSPtr& model, const SkinnedAnimationCSPtr& skinnedAnimation, PlaybackType playbackType) noexcept;\n        \n        /// Sets the model and animation the component should use. The given material will be applied\n        /// to all meshes.\n        ///\n        /// @param model\n        ///     The model which should be used.\n        /// @param material\n        ///     The material which should be used.\n        /// @param skinnedAnimation\n        ///     The skinned animation that should be used.\n        /// @param playbackType\n        ///     The playback type that should be used.\n        ///\n        void SetModel(const ModelCSPtr& model, const MaterialCSPtr& material, const SkinnedAnimationCSPtr& skinnedAnimation, PlaybackType playbackType) noexcept;\n        \n        /// Sets the model and animation the component should use. The given materials will be applied\n        /// to the respective meshes.\n        ///\n        /// @param model\n        ///     The model which should be used.\n        /// @param materials\n        ///     The material for each mesh in the model. Must have the same number of elements as\n        ///     there are meshes in the given model.\n        /// @param skinnedAnimation\n        ///     The skinned animation that should be used.\n        /// @param playbackType\n        ///     The playback type that should be used.\n        ///\n        void SetModel(const ModelCSPtr& model, const std::vector<MaterialCSPtr>& materials, const SkinnedAnimationCSPtr& skinnedAnimation, PlaybackType playbackType) noexcept;\n        \n        /// Get the material of a single mesh.\n        ///\n        /// @param meshIndex\n        ///     Index to the mesh\n        ///\n        /// @return Handle to material\n        ///\n        const MaterialCSPtr& GetMaterialForMesh(u32 meshIndex) const noexcept;\n        \n        /// Get the material of a single mesh.\n        ///\n        /// @param meshName\n        ///     The name of the mesh.\n        ///\n        /// @return Handle to material\n        ///\n        const MaterialCSPtr& GetMaterialForMesh(const std::string& meshName) const noexcept;\n        \n        /// Set the material that the model will use. Applies the material to all meshes.\n        ///\n        /// @param material\n        ///     The material that should be used.\n        ///\n        void SetMaterial(const MaterialCSPtr& material) noexcept;\n        \n        /// Sets the material for a single mesh.\n        ///\n        /// @param material\n        ///     The material that should be used.\n        /// @param meshIndex\n        ///     The index of the mesh.\n        ///\n        void SetMaterialForMesh(const MaterialCSPtr& material, u32 meshIndex) noexcept;\n        \n        /// Sets the material for a single mesh.\n        ///\n        /// @param material\n        ///     The material that should be used.\n        /// @param meshName\n        ///     The name of the mesh\n        ///\n        void SetMaterialForMesh(const MaterialCSPtr& material, const std::string& meshName) noexcept;\n        \n        /// @return Whether the render component casts shadows\n        ///\n        bool IsShadowCastingEnabled() const noexcept { return m_shadowCastingEnabled; };\n        \n        /// @param enabled\n        ///     Whether the render component casts shadows\n        ///\n        void SetShadowCastingEnabled(bool enabled) noexcept { m_shadowCastingEnabled = enabled; };\n        \n        /// @return The list of all active animations.\n        ///\n        std::vector<SkinnedAnimationCSPtr> GetAnimations() const noexcept;\n        \n        /// Sets the currently playing animation with the given playback type.\n        ///\n        /// This will change the animation immediately; if fade is required, then FadeTo() or FadeOut()\n        /// should be used instead.\n        ///\n        /// The animation will replace all animations currently on the blendline and attach the\n        /// animation at 0.0. If other blending behaviour is desired then AttachAnimation() should be\n        /// used instead.\n        ///\n        /// @param animation\n        ///     The animation to change to.\n        /// @param playbackType\n        ///     The playback type that should be used.\n        ///\n        void SetAnimation(const SkinnedAnimationCSPtr& animation, PlaybackType playbackType) noexcept;\n        \n        /// Attached a new animation to the animation blend line. The animation will be attached to the\n        /// active animation group at the given blendline position.\n        ///\n        /// This is used for animation blending; if blending isn't required then SetAnimation() should\n        /// be used instead.\n        ///\n        /// @param animation\n        ///     The animation that should be attached to the blendline.\n        /// @param blendlinePosition\n        ///     The position on the blendline that the animation should be attached.\n        ///\n        void AttachAnimation(const SkinnedAnimationCSPtr& animation, f32 blendlinePosition) noexcept;\n\n        /// Removes the given animation from the active animation group. If the animation is not\n        /// currently attached to the active animation group this will assert.\n        ///\n        /// @param animation\n        ///     The animation that should be removed.\n        ///\n        void DetatchAnimation(const SkinnedAnimationCSPtr& animation) noexcept;\n        \n        /// Fades the currently playing animation to the given animation.\n        ///\n        /// The new animation will be attached to the active blendline at 0.0; if different blending\n        /// behaviour is desired then FadeOut() should be used.\n        ///\n        /// @param animation\n        ///     The animation to fade to.\n        /// @param playbackType\n        ///     The playback type that should be used for the new animation.\n        /// @param fadeType\n        ///     The type of blending that should be used during the fade.\n        /// @param fadeOutTime\n        ///     The length of time that the fade should take in seconds.\n        ///\n        void FadeTo(const SkinnedAnimationCSPtr& animation, PlaybackType playbackType, AnimationBlendType fadeType, f32 fadeOutTime) noexcept;\n        \n        /// Fades out the active animation group, replacing it with a new group. This new group will\n        /// have no animations attached to it, meaning that AttachAnimation must be called prior to\n        /// the next render snapshot or an assertion will occur.\n        ///\n        /// If only basic animation is required, the convenience method FadeTo() should be used\n        /// instead.\n        ///\n        /// @param fadeType\n        ///     The type of blending that should be used during the fade.\n        /// @param fadeOutTime\n        ///     The length of time that the fade should take in seconds.\n        ///\n        void FadeOut(AnimationBlendType fadeType, f32 fadeOutTime) noexcept;\n        \n        /// Clears the component of all animations--both active and fading--and creates a new\n        /// active animation group. This new group will have no animations attached to it, meaning\n        /// that AttachAnimation must be called prior to the next render snapshot or an assertion\n        /// will occur.\n        ///\n        void ClearAnimations() noexcept;\n        \n        /// @return the current position in the blendline.\n        ///\n        f32 GetBlendlinePosition() const noexcept { return m_blendlinePosition; };\n        \n        /// Sets the current position on the blendline.\n        ///\n        /// @param The blendline position.\n        ///\n        void SetBlendlinePosition(f32 blendlinePosition) noexcept;\n        \n        /// @return The current playback type.\n        ///\n        PlaybackType GetPlaybackType() const noexcept { return m_playbackType; }\n        \n        /// Sets the current playback type, looping, etc.\n        ///\n        /// @param playbackType\n        ///     The playback type.\n        ///\n        void SetPlaybackType(PlaybackType playbackType) noexcept;\n        \n        /// @return The multiplier that is applied to the playback speed.\n        ///\n        f32 GetPlaybackSpeedMultiplier() const noexcept { return m_playbackSpeedMultiplier; }\n\n        /// Sets the current playback speed multiplier.\n        ///\n        /// @param speedMultiplier\n        ///     The playback speed multiplier.\n        ///\n        void SetPlaybackSpeedMultiplier(f32 speedMultiplier) noexcept { m_playbackSpeedMultiplier = speedMultiplier; }\n        \n        /// @return the number of seconds into the animation.\n        ///\n        f32 GetPlaybackPosition() const noexcept { return m_playbackPosition; }\n        \n        /// Sets the current position through the animation.\n        ///\n        /// @param position\n        ///     The position\n        ///\n        void SetPlaybackPosition(f32 position) noexcept;\n        \n        /// @return distance through the animation normalised to between 0 and 1.\n        ///\n        f32 GetPlaybackPositionNormalised() const noexcept { return GetPlaybackPosition() / GetAnimationLength(); }\n        \n        /// Sets the current position through the animation normalised to between 0.0 and 1.0.\n        ///\n        /// @param position\n        ///     The position normalised.\n        ///\n        void SetPlaybackPositionNormalised(f32 position) noexcept;\n        \n        /// @return the blend type used for all animation blending.\n        ///\n        AnimationBlendType GetBlendType() const noexcept { return m_animationBlendType; }\n        \n        /// Sets the type of blending to be used when blending animations.\n        ///\n        /// @param blendType\n        ///     The blend type.\n        ///\n        void SetBlendType(AnimationBlendType blendType) noexcept { m_animationBlendType = blendType; }\n        \n        /// @return The animation length in seconds.\n        ///\n        f32 GetAnimationLength() const noexcept;\n        \n        /// @return whether or not the animation has finished.\n        ///\n        bool HasFinished() const noexcept { return m_finished; }\n        \n        /// Attached an entity to a node on the animated models skeleton.\n        ///\n        /// @param entity\n        ///     The entity.\n        /// @param nodeName\n        ///     The name of the node to attach to.\n        ////\n        void AttachEntity(const EntitySPtr& entity, const std::string& nodeName) noexcept;\n        \n        /// Removes an entity that has previously been attached to the animated models skeleton.\n        ///\n        /// @param The entity.\n        ///\n        void DetatchEntity(const Entity* inpEntity) noexcept;\n        \n        /// Removes all entities that have previously been attached to the animated models skeleton.\n        ///\n        void DetatchAllEntities() noexcept;\n        \n        /// @param The animation changed event. This is invoked every time the current animation\n        /// group changes, e.g Fade Out or Clear Animations is called.\n        ///\n        Event<AnimationChangedDelegate>& GetAnimationChangedEvent() noexcept { return m_animationChangedEvent; }\n\n        /// @param The animation completion event. This is invoked whenever a non-looping animation\n        /// reaches its end.\n        ///\n        Event<AnimationCompletionDelegate>& GetAnimationCompletionEvent() noexcept { return m_animationCompletionEvent; }\n\n        /// @param The animation looped event. This is invoked every time an animation loops back\n        ///     to the start of an animation.\n        ///\n        Event<AnimationLoopedDelegate>& GetAnimationLoopedEvent() noexcept { return m_animationLoopedEvent; }\n        \n    private:\n        /// Updates the animation, rebuilding the animation matrices.\n        ///\n        /// @param deltaTime\n        ///     The delta time.\n        ///\n        void UpdateAnimation(f32 deltaTime) noexcept;\n\n        /// Updates the animation timer.\n        ///\n        /// @param deltaTime\n        ///     The delta time.\n        ///\n        void UpdateAnimationTimer(f32 deltaTime) noexcept;\n\n        /// Update the transforms of all entities attached to this animated model components skeleton.\n        ///\n        void UpdateAttachedEntities() noexcept;\n\n        /// Resets the component back to a state where it is ready to start a new animation.\n        ///\n        void Reset() noexcept;\n        \n        /// Triggered when the component is added to the scene.\n        ///\n        void OnAddedToScene() noexcept override;\n\n        /// Updates the animation.\n        ///\n        /// @param deltaTime\n        ///     The delta time.\n        ///\n        void OnUpdate(f32 deltaTime) noexcept override;\n        \n        /// Called during the render snapshot phase. Adds render objects to the scene describing\n        /// the model.\n        ///\n        /// @param renderSnapshot\n        ///     The render snapshot.\n        /// @param frameAllocator - Use this to allocate any memory\n        /// for this render frame\n        ///\n        void OnRenderSnapshot(RenderSnapshot& renderSnapshot, IAllocator* frameAllocator) noexcept override;\n        \n        /// Triggered when the component is removed to the scene.\n        ///\n        void OnRemovedFromScene() noexcept override;\n        \n    private:\n        typedef std::vector<std::pair<EntityWPtr, s32> > AttachedEntityList;\n        \n        AttachedEntityList m_attachedEntities;\n        ModelCSPtr m_model;\n        std::vector<MaterialCSPtr> m_materials;\n        SkinnedAnimationGroupSPtr m_activeAnimationGroup;\n        SkinnedAnimationGroupSPtr m_fadingAnimationGroup;\n        f32 m_playbackPosition = 0.0f;\n        f32 m_playbackSpeedMultiplier = 1.0f;\n        f32 m_blendlinePosition = 0.0f;\n        PlaybackType m_playbackType;\n        AnimationBlendType m_animationBlendType = AnimationBlendType::k_linear;\n        AnimationBlendType m_fadeType = AnimationBlendType::k_linear;\n        f32 m_fadeTimer = 0.0f;\n        f32 m_maxFadeTime = 1.0f;\n        f32 m_fadePlaybackPosition = 0.0f;\n        f32 m_fadeBlendlinePosition = 0.0f;\n        bool m_finished = false;\n        bool m_animationDataDirty = true;\n        Event<AnimationCompletionDelegate> m_animationCompletionEvent;\n        Event<AnimationLoopedDelegate> m_animationLoopedEvent;\n        Event<AnimationChangedDelegate> m_animationChangedEvent;\n        \n        AABB m_aabb;\n        OOBB m_oobb;\n        Sphere m_boundingSphere;\n        bool m_shadowCastingEnabled = true;\n        bool m_isVisible = true;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Model/CSAnimProvider.cpp",
    "content": "//\n//  CSAnimProvider.cpp\n//  ChilliSource\n//  Created by Ian Copland on 17/10/2011.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2011 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Model/CSAnimProvider.h>\n\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/File.h>\n#include <ChilliSource/Core/Math/Quaternion.h>\n#include <ChilliSource/Core/Math/Vector3.h>\n#include <ChilliSource/Core/Threading/TaskScheduler.h>\n#include <ChilliSource/Rendering/Model/SkinnedAnimation.h>\n\nnamespace ChilliSource\n{\n    namespace\n    {\n        const std::string k_fileExtension(\"csanim\");\n        \n        const u32 k_minVersion = 4;\n        const u32 k_maxVersion = 4;\n        const u32 k_fileCheckValue = 7777;\n        \n        //----------------------------------------------------------------------------\n        /// Reads all of the data for the animation into the SkinnedAnimation resource\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The file stream.\n        /// @param The number of frames.\n        /// @param The number of skeleton nodes.\n        /// @param [Out] Animation resource to populate\n        //----------------------------------------------------------------------------\n        void ReadAnimationData(const IBinaryInputStreamUPtr& in_fileStream, u32 in_numFrames, s32 in_numSkeletonNodes, const SkinnedAnimationSPtr& out_resource)\n        {\n            for (u32 frameCount=0; frameCount<in_numFrames; ++frameCount)\n            {\n                //create new frame\n                SkinnedAnimation::FrameUPtr frame(new SkinnedAnimation::Frame());\n                \n                //add all skeleton nodes matrices\n                for (u32 skelNodeCount=0; skelNodeCount<(u32)in_numSkeletonNodes; ++skelNodeCount)\n                {\n                    //create new translation\n                    Vector3 translation;\n                    translation.x = in_fileStream->Read<f32>();\n                    translation.y = in_fileStream->Read<f32>();\n                    translation.z = in_fileStream->Read<f32>();\n                    \n                    //create new orientation\n                    Quaternion orientation;\n                    orientation.x = in_fileStream->Read<f32>();\n                    orientation.y = in_fileStream->Read<f32>();\n                    orientation.z = in_fileStream->Read<f32>();\n                    orientation.w = in_fileStream->Read<f32>();\n                    \n                    //create new scale\n                    Vector3 scale;\n                    scale.x = in_fileStream->Read<f32>();\n                    scale.y = in_fileStream->Read<f32>();\n                    scale.z = in_fileStream->Read<f32>();\n                    \n                    //add to the frame\n                    frame->m_nodeTranslations.push_back(translation);\n                    frame->m_nodeOrientations.push_back(orientation);\n                    frame->m_nodeScales.push_back(scale);\n                }\n                \n                //add frame to animation\n                out_resource->AddFrame(std::move(frame));\n            }\n        }\n        //----------------------------------------------------------------------------\n        /// Parses the header of the anim file.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The file stream.\n        /// @param the Skeletal Animation that this data is being loaded into.\n        ///\n        /// @return whether or not this was successful\n        //----------------------------------------------------------------------------\n        bool ReadHeader(const IBinaryInputStreamUPtr& in_stream, const std::string & in_filePath, const SkinnedAnimationSPtr& out_resource, u32& out_numFrames, s32& out_numSkeletonNodes)\n        {\n            //Check file for corruption\n            if(in_stream == nullptr)\n            {\n                CS_LOG_ERROR(\"Cannot open CSAnim file: \" + in_filePath);\n                return false;\n            }\n            \n            u32 fileCheckValue = in_stream->Read<u32>();\n            if(fileCheckValue != k_fileCheckValue)\n            {\n                CS_LOG_ERROR(\"CSAnim file has corruption(incorrect File Check Value): \" + in_filePath);\n                return false;\n            }\n            \n            u32 versionNum = in_stream->Read<u32>();\n            if (versionNum < k_minVersion || versionNum > k_maxVersion)\n            {\n                CS_LOG_ERROR(\"Unsupported CSAnim version: \" + in_filePath);\n                return false;\n            }\n            \n            //build the feature declaration from the file\n            u32 numFeatures = (u32)in_stream->Read<u8>();\n            if (numFeatures != 0)\n            {\n                CS_LOG_ERROR(\"Unknown feature type in CSAnim (\" + in_filePath + \") feature declaration!\");\n            }\n            \n            //read num frames and skeleton nodes\n            out_numFrames = (u32)in_stream->Read<u16>();\n            out_numSkeletonNodes = (s32)in_stream->Read<s16>();\n            \n            //read frame time\n            f32 frameTime = in_stream->Read<f32>();\n            out_resource->SetFrameTime(frameTime);\n            return true;\n        }\n    }\n    \n    CS_DEFINE_NAMEDTYPE(CSAnimProvider);\n    \n    //-------------------------------------------------------------------------\n    //-------------------------------------------------------------------------\n    CSAnimProviderUPtr CSAnimProvider::Create()\n    {\n        return CSAnimProviderUPtr(new CSAnimProvider());\n    }\n    //-------------------------------------------------------------------------\n    //-------------------------------------------------------------------------\n    bool CSAnimProvider::IsA(InterfaceIDType in_interfaceId) const\n    {\n        return in_interfaceId == ResourceProvider::InterfaceID || in_interfaceId == CSAnimProvider::InterfaceID;\n    }\n    //----------------------------------------------------\n    //----------------------------------------------------\n    InterfaceIDType CSAnimProvider::GetResourceType() const\n    {\n        return SkinnedAnimation::InterfaceID;\n    }\n    //----------------------------------------------------------------------------\n    //----------------------------------------------------------------------------\n    bool CSAnimProvider::CanCreateResourceWithFileExtension(const std::string& in_extension) const\n    {\n        return (in_extension == k_fileExtension);\n    }\n    //----------------------------------------------------------------------------\n    //----------------------------------------------------------------------------\n    void CSAnimProvider::CreateResourceFromFile(StorageLocation in_location, const std::string& in_filePath, const IResourceOptionsBaseCSPtr& in_options, const ResourceSPtr& out_resource)\n    {\n        SkinnedAnimationSPtr anim = std::static_pointer_cast<SkinnedAnimation>(out_resource);\n        \n        ReadSkinnedAnimationFromFile(in_location, in_filePath, nullptr, anim);\n    }\n    //----------------------------------------------------------------------------\n    //----------------------------------------------------------------------------\n    void CSAnimProvider::CreateResourceFromFileAsync(StorageLocation in_location, const std::string& in_filePath, const IResourceOptionsBaseCSPtr& in_options, const ResourceProvider::AsyncLoadDelegate& in_delegate, const ResourceSPtr& out_resource)\n    {\n        SkinnedAnimationSPtr anim = std::static_pointer_cast<SkinnedAnimation>(out_resource);\n        Application::Get()->GetTaskScheduler()->ScheduleTask(TaskType::k_file, [=](const TaskContext&) noexcept\n        {\n            ReadSkinnedAnimationFromFile(in_location, in_filePath, in_delegate, anim);\n        });\n    }\n    //----------------------------------------------------------------------------\n    //----------------------------------------------------------------------------\n    void CSAnimProvider::ReadSkinnedAnimationFromFile(StorageLocation in_location, const std::string& in_filePath, const ResourceProvider::AsyncLoadDelegate& in_delegate, const SkinnedAnimationSPtr& out_resource) const\n    {\n        IBinaryInputStreamUPtr stream = Application::Get()->GetFileSystem()->CreateBinaryInputStream(in_location, in_filePath);\n\n        u32 numFrames = 0;\n        s32 numSkeletonNodes = 0;\n        if(ReadHeader(stream, in_filePath, out_resource, numFrames, numSkeletonNodes) == false)\n        {\n            CS_LOG_ERROR(\"Failed to read header in anim: \" + in_filePath);\n            out_resource->SetLoadState(Resource::LoadState::k_failed);\n            if(in_delegate != nullptr)\n            {\n                Application::Get()->GetTaskScheduler()->ScheduleTask(TaskType::k_mainThread, [=](const TaskContext&) noexcept\n                {\n                    in_delegate(out_resource);\n                });\n            }\n            return;\n        }\n        \n        ReadAnimationData(stream, numFrames, numSkeletonNodes, out_resource);\n        \n        out_resource->SetLoadState(Resource::LoadState::k_loaded);\n        \n        if(in_delegate != nullptr)\n        {\n            Application::Get()->GetTaskScheduler()->ScheduleTask(TaskType::k_mainThread, [=](const TaskContext&) noexcept\n            {\n                in_delegate(out_resource);\n            });\n        }\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Model/CSAnimProvider.h",
    "content": "//\n//  CSAnimProvider.h\n//  ChilliSource\n//  Created by Ian Copland on 17/10/2011.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2011 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_MODEL_CSANIMPROVIDER_H_\n#define _CHILLISOURCE_RENDERING_MODEL_CSANIMPROVIDER_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Resource/ResourceProvider.h>\n\nnamespace ChilliSource\n{\n    //-------------------------------------------------------------------------\n    /// Loads CS Anim files into a SkinnedAnimation resource\n    ///\n    /// @author Ian Copland\n    //-------------------------------------------------------------------------\n    class CSAnimProvider final : public ResourceProvider\n    {\n    public:\n        \n        CS_DECLARE_NAMEDTYPE(CSAnimProvider);\n        \n        //-------------------------------------------------------------------------\n        /// Factory method for creating new anim loader\n        ///\n        /// @author Ian Copland\n        //-------------------------------------------------------------------------\n        static CSAnimProviderUPtr Create();\n        //-------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param Interface to compare\n        ///\n        /// @return Whether the object implements the given interface\n        //-------------------------------------------------------------------------\n        bool IsA(InterfaceIDType in_interfaceId) const override;\n        //----------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return The resource type this provider can create\n        //----------------------------------------------------\n        InterfaceIDType GetResourceType() const override;\n        //----------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param Extension to compare\n        ///\n        /// @return Whether the object can create a resource with the given extension\n        //----------------------------------------------------------------------------\n        bool CanCreateResourceWithFileExtension(const std::string& in_extension) const override;\n\n    private:\n        //----------------------------------------------------------------------------\n        /// Load a skinned animation from the given CSAnim file. Check the load state of the\n        /// resource for success or failure.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The storage location to load from\n        /// @param File path\n        /// @param Options to customise the creation\n        /// @param [Out] the output resource pointer\n        //----------------------------------------------------------------------------\n        void CreateResourceFromFile(StorageLocation in_location, const std::string& in_filePath, const IResourceOptionsBaseCSPtr& in_options, const ResourceSPtr& out_resource) override;\n        //----------------------------------------------------------------------------\n        /// Load a skinned animation from the given CSAnim file on a background\n        /// thread. Delegate is called on completion. Check the load state of the\n        /// resource for success or failure\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The storage location to load from\n        /// @param File path\n        /// @param Options to customise the creation\n        /// @param Delegate\n        /// @param [Out] the output resource pointer\n        //----------------------------------------------------------------------------\n        void CreateResourceFromFileAsync(StorageLocation in_location, const std::string& in_filePath, const IResourceOptionsBaseCSPtr& in_options, const ResourceProvider::AsyncLoadDelegate& in_delegate, const ResourceSPtr& out_resource) override;\n        //----------------------------------------------------------------------------\n        /// Loads an anim file into a SkinnedAnimation.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The storage location to load from\n        /// @param File path\n        /// @param Completion delegate\n        /// @param [Out] the output resource pointer\n        //----------------------------------------------------------------------------\n        void ReadSkinnedAnimationFromFile(StorageLocation in_location, const std::string& in_filePath, const ResourceProvider::AsyncLoadDelegate& in_delegate, const SkinnedAnimationSPtr& out_resource) const;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Model/CSModelProvider.cpp",
    "content": "//\n//  CSModelProvider.cpp\n//  ChilliSource\n//  Created by Ian Copland on 25/08/2011.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2011 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Model/CSModelProvider.h>\n\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/Threading/TaskScheduler.h>\n#include <ChilliSource/Rendering/Model/Model.h>\n#include <ChilliSource/Rendering/Model/ModelDesc.h>\n#include <ChilliSource/Rendering/Model/IndexFormat.h>\n#include <ChilliSource/Rendering/Model/PolygonType.h>\n\n#include <unordered_map>\n\nnamespace ChilliSource\n{\n    namespace\n    {\n        const std::string k_modelFileExtension(\"csmodel\");\n        \n        constexpr u32 k_minVersion = 13;\n        constexpr u32 k_maxVersion = 13;\n        constexpr u32 k_fileCheckValue = 6666;\n        \n        //---------------------------------------------\n        /// Features implemented by the model resource.\n        /// Models can opt in and out of features.\n        ///\n        /// @author Ian Copland.\n        //---------------------------------------------\n        enum class Feature\n        {\n            k_none,\n            k_hasAnimation,\n        };\n        //---------------------------------------------\n        /// Model resources can have flexible attribute\n        /// formats described by mixing and matching the\n        /// following.\n        ///\n        /// @author Ian Copland.\n        //---------------------------------------------\n        enum class VertexAttribute\n        {\n            k_none,\n            k_position,\n            k_normal,\n            k_tangent,\n            k_bitangent,\n            k_texcoord,\n            k_colour,\n            k_weights,\n            k_jointIndices\n        };\n        //----------------------------------------------------------------------------\n        /// Model Data Quantities\n        ///\n        /// A struct containing the quantities of different pieces of mesh data.\n        //----------------------------------------------------------------------------\n        struct MeshDataQuantities\n        {\n            u32 m_numMeshes = 0;\n            s32 m_numSkeletonNodes = 0;\n            u32 m_numJoints = 0;\n        };\n        //----------------------------------------------------------------------------\n        /// A container for mesh header data.\n        ///\n        /// @author Ian Copland.\n        //----------------------------------------------------------------------------\n        struct MeshHeader final\n        {\n            std::string m_name;\n            u32 m_numVertices = 0;\n            u32 m_numIndices = 0;\n            AABB m_aabb;\n        };\n        //----------------------------------------------------------------------------\n        /// A container for mesh data.\n        ///\n        /// @author Ian Copland.\n        //----------------------------------------------------------------------------\n        struct MeshData final\n        {\n            std::unique_ptr<const u8[]> m_vertexData;\n            std::unique_ptr<const u8[]> m_indexData;\n            std::vector<Matrix4> m_inverseBindPoses;\n        };\n        //----------------------------------------------------------------------------\n        /// A container for model header data.\n        ///\n        /// @author Ian Copland.\n        //----------------------------------------------------------------------------\n        struct ModelHeader final\n        {\n            bool m_hasAnimationData = false;\n            VertexFormat m_vertexFormat;\n            IndexFormat m_indexFormat = IndexFormat::k_short;\n            AABB m_aabb;\n        };\n        //----------------------------------------------------------------------------\n        /// Read block of data in for given type\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param File stream\n        /// @param Num to read\n        /// @param [Out] data\n        //----------------------------------------------------------------------------\n        template <typename TType> void ReadBlock(IBinaryInputStream* in_meshStream, u32 in_numToRead, TType* out_data)\n        {\n            in_meshStream->Read(reinterpret_cast<u8*>(out_data), sizeof(TType) * in_numToRead);\n        }\n        //----------------------------------------------------------------------------\n        /// Reads a null terminated string from the stream.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param File stream\n        ///\n        /// @return The string.\n        //----------------------------------------------------------------------------\n        std::string ReadString(IBinaryInputStream* in_meshStream) noexcept\n        {\n            std::string output;\n            \n            u8 nextChar = 0;\n            do\n            {\n                nextChar = in_meshStream->Read<u8>();\n                output += nextChar;\n                \n            } while(nextChar != 0);\n            \n            return output;\n        }\n        //-----------------------------------------------------------------------------\n        /// Read the vertex format from the mesh filestream.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param Model stream\n        ///\n        /// @return the vertex description.\n        //-----------------------------------------------------------------------------\n        VertexFormat ReadVertexFormat(IBinaryInputStream* in_meshStream)\n        {\n            //build the vertex declaration from the file\n            u8 numVertexElements = in_meshStream->Read<u8>();\n            \n            std::vector<VertexFormat::ElementType> elements;\n            for (int i = 0; i < numVertexElements; ++i)\n            {\n                u8 vertexAttrib = in_meshStream->Read<u8>();\n                \n                switch (VertexAttribute(vertexAttrib))\n                {\n                    case VertexAttribute::k_position:\n                        elements.push_back(VertexFormat::ElementType::k_position4);\n                        break;\n                    case VertexAttribute::k_normal:\n                        elements.push_back(VertexFormat::ElementType::k_normal3);\n                        break;\n                    case VertexAttribute::k_tangent:\n                        elements.push_back(VertexFormat::ElementType::k_tangent3);\n                        break;\n                    case VertexAttribute::k_bitangent:\n                        elements.push_back(VertexFormat::ElementType::k_bitangent3);\n                        break;\n                    case VertexAttribute::k_texcoord:\n                        elements.push_back(VertexFormat::ElementType::k_uv2);\n                        break;\n                    case VertexAttribute::k_colour:\n                        elements.push_back(VertexFormat::ElementType::k_colour4);\n                        break;\n                    case VertexAttribute::k_weights:\n                        elements.push_back(VertexFormat::ElementType::k_weight4);\n                        break;\n                    case VertexAttribute::k_jointIndices:\n                        elements.push_back(VertexFormat::ElementType::k_jointIndex4);\n                        break;\n                    default:\n                        CS_LOG_ERROR(\"Unknown vertex type in vertex declaration!\");\n                        break;\n                }\n            }\n            \n            return VertexFormat(elements);\n        }\n        //-----------------------------------------------------------------------------\n        /// Calculates a bounding sphere from the given AABB.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param in_aabb - The AABB from which to generate a bounding sphere.\n        ///\n        /// @return The bounding sphere generated.\n        //-----------------------------------------------------------------------------\n        Sphere CalcBoundingSphere(const AABB& in_aabb) noexcept\n        {\n            return Sphere(in_aabb.Centre(), in_aabb.GetSize().Length() * 0.5f);\n        }\n        //-----------------------------------------------------------------------------\n        /// Reads the sub-mesh header section of the file\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param File stream\n        /// @param Model description\n        /// @param [Out] Sube mesh description\n        //-----------------------------------------------------------------------------\n        MeshHeader ReadMeshHeader(IBinaryInputStream* in_meshStream, IndexFormat in_indexFormat)\n        {\n            MeshHeader meshHeader;\n            \n            meshHeader.m_name = ReadString(in_meshStream);\n            \n            CS_ASSERT(in_indexFormat == IndexFormat::k_short, \"Only short indices are currently supported.\");\n            \n            constexpr u32 k_indicesPerTriangle = 3;\n            meshHeader.m_numVertices = (u32)in_meshStream->Read<u16>();\n            meshHeader.m_numIndices = ((u32)in_meshStream->Read<u16>()) * k_indicesPerTriangle;\n            \n            Vector3 minBound, maxBound;\n            minBound.x = in_meshStream->Read<f32>();\n            minBound.y = in_meshStream->Read<f32>();\n            minBound.z = in_meshStream->Read<f32>();\n            maxBound.x = in_meshStream->Read<f32>();\n            maxBound.y = in_meshStream->Read<f32>();\n            maxBound.z = in_meshStream->Read<f32>();\n            \n            meshHeader.m_aabb = AABB((maxBound + minBound) * 0.5f, maxBound - minBound);\n            \n            return meshHeader;\n        }\n        //-----------------------------------------------------------------------------\n        /// Read the mesh section of the file\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param in_meshStream - File stream\n        /// @param in_vertexDataSize - The vertex data size.\n        /// @param in_indexDataSize - The index data size.\n        /// @param in_numJoints - The number of joints in the mesh. Defaults to 0.\n        ///\n        /// @return The mesh data\n        //-----------------------------------------------------------------------------\n        MeshData ReadMeshData(IBinaryInputStream*in_meshStream, u32 in_vertexDataSize, u32 in_indexDataSize, u32 in_numJoints = 0)\n        {\n            MeshData meshData;\n            \n            for(u32 i = 0; i < in_numJoints; ++i)\n            {\n                Matrix4 IBPMat;\n                ReadBlock<f32>(in_meshStream, 16, IBPMat.m);\n                \n                meshData.m_inverseBindPoses.push_back(IBPMat);\n            }\n            \n            auto vertexData = new u8[in_vertexDataSize];\n            in_meshStream->Read(vertexData, in_vertexDataSize);\n            meshData.m_vertexData = std::unique_ptr<const u8[]>(vertexData);\n            \n            auto indexData = new u8[in_indexDataSize];\n            in_meshStream->Read(indexData, in_indexDataSize);\n            meshData.m_indexData = std::unique_ptr<const u8[]>(indexData);\n            \n            return meshData;\n        }\n        //-----------------------------------------------------------------------------\n        /// Reads the skeleton section of the file\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param File stream\n        /// @param Container holding the num of meshes, joints and bones\n        ///\n        /// @return The skeleton description.\n        //-----------------------------------------------------------------------------\n        SkeletonDesc ReadSkeletonData(IBinaryInputStream* in_meshStream, const MeshDataQuantities& in_quantities)\n        {\n            std::vector<std::string> names;\n            std::vector<s32> parentNodeIndices;\n            \n            names.reserve(in_quantities.m_numSkeletonNodes);\n            parentNodeIndices.reserve(in_quantities.m_numSkeletonNodes);\n            \n            std::unordered_map<u32, s32> jointToNodeMap;\n            for (u32 i = 0; i<(u32)in_quantities.m_numSkeletonNodes; ++i)\n            {\n                names.push_back(ReadString(in_meshStream));\n                \n                //get the parent index\n                parentNodeIndices.push_back(s32(in_meshStream->Read<s16>()));\n                \n                //get the type\n                constexpr u32 k_isJoint = 1;\n                u8 type = in_meshStream->Read<u8>();\n                if (type == k_isJoint)\n                {\n                    u32 jointIndex = (u32)in_meshStream->Read<u8>();\n                    jointToNodeMap.insert(std::pair<u32, s32>(jointIndex, (s32)i));\n                }\n            }\n            \n            CS_ASSERT(names.size() == parentNodeIndices.size(), \"Invalid number of node names and indices in skeleton\");\n            \n            \n            std::vector<s32> jointIndices;\n            for (u32 i = 0; i < in_quantities.m_numJoints; ++i)\n            {\n                jointIndices.push_back(jointToNodeMap[i]);\n            }\n            \n            return SkeletonDesc(names, parentNodeIndices, jointIndices);\n        }\n        //-----------------------------------------------------------------------------\n        /// Reads the header of the file\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param File stream\n        /// @param the file path\n        /// @param [Out] Model description\n        /// @param [Out] A struct containing info on the number of meshes, nodes and joints.\n        ///\n        /// @return Whether the file is correct\n        //-----------------------------------------------------------------------------\n        void ReadGlobalHeader(IBinaryInputStream* in_meshStream, const std::string& in_filePath, ModelHeader& out_modelHeader, MeshDataQuantities& out_meshQuantities)\n        {\n            u32 fileCheckValue = in_meshStream->Read<u32>();\n            CS_RELEASE_ASSERT(fileCheckValue == k_fileCheckValue, \"csmodel file is corrupt (incorrect File Check Value): \" + in_filePath);\n            \n            u32 versionNum = in_meshStream->Read<u32>();\n            CS_RELEASE_ASSERT(versionNum >= k_minVersion && versionNum <= k_maxVersion, \"Unsupported csmodel version: \" + in_filePath);\n            \n            u32 numFeatures = (u32)in_meshStream->Read<u8>();\n            for (u32 i=0; i<numFeatures; ++i)\n            {\n                u32 featureType = (u32)in_meshStream->Read<u8>();\n                \n                switch (Feature(featureType))\n                {\n                    case Feature::k_hasAnimation:\n                        out_modelHeader.m_hasAnimationData = true;\n                        break;\n                    default:\n                        CS_LOG_ERROR(\"Unknown feature type in csmodel (\" + in_filePath + \") feature declaration!\");\n                        break;\n                }\n            }\n            \n            out_modelHeader.m_vertexFormat = ReadVertexFormat(in_meshStream);\n            \n            constexpr u8 k_shortIndexFormatSize = 2;\n            auto indexSize = in_meshStream->Read<u8>();\n            CS_RELEASE_ASSERT(indexSize == k_shortIndexFormatSize, \"Invalid index size.\");\n            \n            Vector3 minBounds, maxBounds;\n            minBounds.x = in_meshStream->Read<f32>();\n            minBounds.y = in_meshStream->Read<f32>();\n            minBounds.z = in_meshStream->Read<f32>();\n            maxBounds.x = in_meshStream->Read<f32>();\n            maxBounds.y = in_meshStream->Read<f32>();\n            maxBounds.z = in_meshStream->Read<f32>();\n            out_modelHeader.m_aabb = AABB((maxBounds + minBounds) * 0.5f, maxBounds - minBounds);\n            \n            out_meshQuantities.m_numMeshes = (u32)in_meshStream->Read<u16>();\n            if (out_modelHeader.m_hasAnimationData)\n            {\n                out_meshQuantities.m_numSkeletonNodes = (s32)in_meshStream->Read<s16>();\n                out_meshQuantities.m_numJoints = (u32)in_meshStream->Read<u8>();\n            }\n        }\n        //----------------------------------------------------------------------------\n        /// Read the mesh data from file and creates a mesh descriptor.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The storage location to load from\n        /// @param File path\n        /// @param [Out] Model description\n        ///\n        /// @return true if successful, false if not\n        //----------------------------------------------------------------------------\n        bool ReadFile(StorageLocation in_location, const std::string& in_filePath, ModelDesc& out_modelDesc)\n        {\n            auto meshStream = Application::Get()->GetFileSystem()->CreateBinaryInputStream(in_location, in_filePath);\n            \n            //Check file for corruption\n            if(nullptr == meshStream)\n            {\n                CS_LOG_ERROR(\"Cannot open csmodel file: \" + in_filePath);\n                return false;\n            }\n            \n            ModelHeader modelHeader;\n            MeshDataQuantities quantities;\n            ReadGlobalHeader(meshStream.get(), in_filePath, modelHeader, quantities);\n            \n            SkeletonDesc skeletonDesc;\n            if (modelHeader.m_hasAnimationData)\n            {\n                skeletonDesc = ReadSkeletonData(meshStream.get(), quantities);\n            }\n            \n            std::vector<MeshDesc> meshDescs;\n            for(u32 i = 0; i < quantities.m_numMeshes; ++i)\n            {\n                auto meshHeader = ReadMeshHeader(meshStream.get(), modelHeader.m_indexFormat);\n                \n                CS_ASSERT(modelHeader.m_indexFormat == IndexFormat::k_short, \"Invalid index format.\");\n                constexpr u32 k_indexSize = 2;\n                auto meshData = ReadMeshData(meshStream.get(), meshHeader.m_numVertices * modelHeader.m_vertexFormat.GetSize(), meshHeader.m_numIndices * k_indexSize, quantities.m_numJoints);\n                auto meshBoundingSphere = CalcBoundingSphere(meshHeader.m_aabb);\n                \n                meshDescs.push_back(MeshDesc(meshHeader.m_name, PolygonType::k_triangle, modelHeader.m_vertexFormat, modelHeader.m_indexFormat, meshHeader.m_aabb, meshBoundingSphere, meshHeader.m_numVertices,\n                                             meshHeader.m_numIndices, std::move(meshData.m_vertexData), std::move(meshData.m_indexData), std::move(meshData.m_inverseBindPoses)));\n                \n            }\n            \n            auto modelBoundingSphere = CalcBoundingSphere(modelHeader.m_aabb);\n            out_modelDesc = ModelDesc(std::move(meshDescs), modelHeader.m_aabb, modelBoundingSphere, skeletonDesc, false);\n\n            return true;\n        }\n    }\n    \n    CS_DEFINE_NAMEDTYPE(CSModelProvider);\n    \n    //-------------------------------------------------------------------------\n    //-------------------------------------------------------------------------\n    CSModelProviderUPtr CSModelProvider::Create()\n    {\n        return CSModelProviderUPtr(new CSModelProvider());\n    }\n    //-------------------------------------------------------------------------\n    //-------------------------------------------------------------------------\n    bool CSModelProvider::IsA(InterfaceIDType in_interfaceId) const\n    {\n        return in_interfaceId == ResourceProvider::InterfaceID || in_interfaceId == CSModelProvider::InterfaceID;\n    }\n    //----------------------------------------------------\n    //----------------------------------------------------\n    InterfaceIDType CSModelProvider::GetResourceType() const\n    {\n        return Model::InterfaceID;\n    }\n    //----------------------------------------------------------------------------\n    //----------------------------------------------------------------------------\n    bool CSModelProvider::CanCreateResourceWithFileExtension(const std::string& in_extension) const\n    {\n        return in_extension == k_modelFileExtension;\n    }\n    //----------------------------------------------------------------------------\n    //----------------------------------------------------------------------------\n    void CSModelProvider::CreateResourceFromFile(StorageLocation in_location, const std::string& in_filePath, const IResourceOptionsBaseCSPtr& in_options, const ResourceSPtr& out_resource)\n    {\n        auto modelResource = static_cast<Model*>(out_resource.get());\n        \n        ModelDesc modelDesc;\n        \n        if (ReadFile(in_location, in_filePath, modelDesc) == false)\n        {\n            modelResource->SetLoadState(Resource::LoadState::k_failed);\n            return;\n        }\n        \n        modelResource->Build(std::move(modelDesc));\n        modelResource->SetLoadState(Resource::LoadState::k_loaded);\n    }\n    //----------------------------------------------------------------------------\n    //----------------------------------------------------------------------------\n    void CSModelProvider::CreateResourceFromFileAsync(StorageLocation in_location, const std::string& in_filePath, const IResourceOptionsBaseCSPtr& in_options, const AsyncLoadDelegate& in_delegate, const ResourceSPtr& out_resource)\n    {\n        CS_ASSERT(in_delegate != nullptr, \"Cannot load mesh async with null delegate\");\n        \n        ModelSPtr meshResource = std::static_pointer_cast<Model>(out_resource);\n        \n        //Load model as task\n        Application::Get()->GetTaskScheduler()->ScheduleTask(TaskType::k_file, [=](const TaskContext&) noexcept\n        {\n            LoadMeshDataTask(in_location, in_filePath, in_delegate, meshResource);\n        });\n    }\n    //----------------------------------------------------------------------------\n    //----------------------------------------------------------------------------\n    void CSModelProvider::LoadMeshDataTask(StorageLocation in_location, const std::string& in_filePath, const AsyncLoadDelegate& in_delegate, const ModelSPtr& out_resource)\n    {\n        //read the mesh data into a MoStaticDeclaration\n        ModelDescSPtr modelDesc(new ModelDesc());\n        if (false == ReadFile(in_location, in_filePath, *modelDesc))\n        {\n            out_resource->SetLoadState(Resource::LoadState::k_failed);\n            Application::Get()->GetTaskScheduler()->ScheduleTask(TaskType::k_mainThread, [=](const TaskContext&) noexcept\n            {\n                in_delegate(out_resource);\n            });\n        }\n        \n        //start a main thread task for loading the data into a mesh\n        Application::Get()->GetTaskScheduler()->ScheduleTask(TaskType::k_large, [=](const TaskContext&) noexcept\n        {\n            out_resource->Build(std::move(*modelDesc));\n            out_resource->SetLoadState(Resource::LoadState::k_loaded);\n            \n           in_delegate(out_resource);\n        });\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Model/CSModelProvider.h",
    "content": "//\n//  CSModelProvider.h\n//  ChilliSource\n//  Created by Ian Copland on 25/08/2011.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2011 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_MODEL_CSMODELPROVIDER_H_\n#define _CHILLISOURCE_RENDERING_MODEL_CSMODELPROVIDER_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Resource/ResourceProvider.h>\n\nnamespace ChilliSource\n{\n    //-------------------------------------------------------------------------\n    /// Loads model files into a Model resource.\n    //-------------------------------------------------------------------------\n    class CSModelProvider final : public ResourceProvider\n    {\n    public:\n        \n        CS_DECLARE_NAMEDTYPE(CSModelProvider);\n        \n        //-------------------------------------------------------------------------\n        /// Factory method for creating provider\n        ///\n        /// @author Ian Copland\n        //-------------------------------------------------------------------------\n        static CSModelProviderUPtr Create();\n        //-------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param Interface to compare\n        ///\n        /// @return Whether the object implements the given interface\n        //-------------------------------------------------------------------------\n        bool IsA(InterfaceIDType in_interfaceId) const override;\n        //----------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return The resource type this provider can create\n        //----------------------------------------------------\n        InterfaceIDType GetResourceType() const override;\n        //----------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param Extension to compare\n        ///\n        /// @return Whether the object can create a resource with the given extension\n        //----------------------------------------------------------------------------\n        bool CanCreateResourceWithFileExtension(const std::string& in_extension) const override;\n\n    private:\n        \n        //----------------------------------------------------------------------------\n        /// Private constructor to force use of factory method\n        ///\n        /// @author S Downie\n        //----------------------------------------------------------------------------\n        CSModelProvider() = default;\n        //----------------------------------------------------------------------------\n        /// Create mesh resource from model file\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The storage location to load from\n        /// @param File path\n        /// @param Options to customise the creation\n        /// @param [Out] the output resource pointer\n        //----------------------------------------------------------------------------\n        void CreateResourceFromFile(StorageLocation in_location, const std::string& in_filePath, const IResourceOptionsBaseCSPtr& in_options, const ResourceSPtr& out_resource) override;\n        //----------------------------------------------------------------------------\n        /// Create mesh resource from model file on a background thread\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The storage location to load from\n        /// @param File path\n        /// @param Options to customise the creation\n        /// @param Delegate to callback on completion either success or failure\n        /// @param [Out] the output resource pointer\n        //----------------------------------------------------------------------------\n        void CreateResourceFromFileAsync(StorageLocation in_location, const std::string& in_filePath, const IResourceOptionsBaseCSPtr& in_options, const AsyncLoadDelegate& in_delegate, const ResourceSPtr& out_resource) override;\n        //----------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param The storage location to load from\n        /// @param File path\n        /// @param Delegate to callback on completion either success or failure\n        /// @param the output resource pointer\n        //----------------------------------------------------------------------------\n        void LoadMeshDataTask(StorageLocation in_location, const std::string& in_filePath, const AsyncLoadDelegate& in_delegate, const ModelSPtr& out_resource);\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Model/IndexFormat.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Model/IndexFormat.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    u32 GetIndexSize(IndexFormat indexFormat) noexcept\n    {\n        switch (indexFormat)\n        {\n            case IndexFormat::k_short:\n                return 2;\n            default:\n                CS_LOG_FATAL(\"Invalid index format.\");\n                return 0;\n        }\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Model/IndexFormat.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_MODEL_INDEXFORMAT_H_\n#define _CHILLISOURCE_RENDERING_MODEL_INDEXFORMAT_H_\n\n#include <ChilliSource/ChilliSource.h>\n\nnamespace ChilliSource\n{\n    /// An enum describing the type used to describe indices.\n    ///\n    /// Currently the only supported type is Short, which allows for an index range of\n    /// 0 - 65535.\n    ///\n    ///\n    enum class IndexFormat\n    {\n        k_short\n    };\n    \n    /// Gets the size of the given index format in bytes.\n    ///\n    /// @param indexFormat\n    ///     The index format.\n    ///\n    /// @return The size of the index format in bytes.\n    ///\n    u32 GetIndexSize(IndexFormat indexFormat) noexcept;\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Model/MeshDesc.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Model/MeshDesc.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    MeshDesc::MeshDesc(const std::string& name, PolygonType polygonType, const VertexFormat& vertexFormat, IndexFormat indexFormat, const AABB& aabb, const Sphere& boundingSphere,\n                       u32 numVertices, u32 numIndices, std::unique_ptr<const u8[]> vertexData, std::unique_ptr<const u8[]> indexData) noexcept\n        : m_name(name), m_polygonType(polygonType), m_vertexFormat(vertexFormat), m_indexFormat(indexFormat), m_aabb(aabb), m_boundingSphere(boundingSphere), m_numVertices(numVertices),\n          m_numIndices(numIndices), m_vertexData(std::move(vertexData)), m_indexData(std::move(indexData))\n    {\n        CS_ASSERT(m_vertexData, \"Mesh must not have vertex data.\");\n        CS_ASSERT(m_indexData, \"Mesh must not have vertex data.\");\n    }\n    \n    //------------------------------------------------------------------------------\n    MeshDesc::MeshDesc(const std::string& name, PolygonType polygonType, const VertexFormat& vertexFormat, IndexFormat indexFormat, const AABB& aabb, const Sphere& boundingSphere,\n                       u32 numVertices, u32 numIndices, std::unique_ptr<const u8[]> vertexData, std::unique_ptr<const u8[]> indexData, std::vector<Matrix4> inverseBindPoseMatrices) noexcept\n        : m_name(name), m_polygonType(polygonType), m_vertexFormat(vertexFormat), m_indexFormat(indexFormat), m_aabb(aabb), m_boundingSphere(boundingSphere), m_numVertices(numVertices),\n          m_numIndices(numIndices), m_vertexData(std::move(vertexData)), m_indexData(std::move(indexData)), m_inverseBindPoseMatrixes(std::move(inverseBindPoseMatrices))\n    {\n        CS_ASSERT(m_vertexData, \"Mesh must not have vertex data.\");\n        CS_ASSERT(m_indexData, \"Mesh must not have vertex data.\");\n    }\n    \n    //------------------------------------------------------------------------------\n    std::unique_ptr<const u8[]> MeshDesc::ClaimVertexData() noexcept\n    {\n        CS_ASSERT(m_vertexData, \"Vertex data has already been claimed.\");\n        \n        return std::move(m_vertexData);\n    }\n    \n    //------------------------------------------------------------------------------\n    std::unique_ptr<const u8[]> MeshDesc::ClaimIndexData() noexcept\n    {\n        CS_ASSERT(m_indexData, \"Index data has already been claimed.\");\n        \n        return std::move(m_indexData);\n    }\n    \n    //------------------------------------------------------------------------------\n    std::vector<Matrix4> MeshDesc::ClaimInverseBindPoseMatrices() noexcept\n    {\n        return std::move(m_inverseBindPoseMatrixes);\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Model/MeshDesc.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_MODEL_MESHDESC_H_\n#define _CHILLISOURCE_RENDERING_MODEL_MESHDESC_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Math/Matrix4.h>\n#include <ChilliSource/Core/Math/Geometry/Shapes.h>\n#include <ChilliSource/Rendering/Model/IndexFormat.h>\n#include <ChilliSource/Rendering/Model/PolygonType.h>\n#include <ChilliSource/Rendering/Model/VertexFormat.h>\n\nnamespace ChilliSource\n{\n    /// A description of a single mesh within a model. This can only be used to create\n    /// a single mesh as the mesh data is moved.\n    ///\n    /// This is not thread safe and should only be accessed by one thread at a time.\n    ///\n    class MeshDesc final\n    {\n    public:\n        CS_DECLARE_NOCOPY(MeshDesc);\n        \n        MeshDesc(MeshDesc&&) = default;\n        MeshDesc& operator=(MeshDesc&&) = default;\n        \n        /// Creates a new mesh description with the given format and mesh data.\n        ///\n        /// @param name\n        ///     The name of the mesh.\n        /// @param polygonType\n        ///     The type of polygon that this mesh uses.\n        /// @param vertexFormat\n        ///     The format of a single vertex.\n        /// @param indexFormat\n        ///     The format of a single index.\n        /// @param aabb\n        ///     The local AABB of the mesh.\n        /// @parma boundingSphere\n        ///     The local bounding sphere of the mesh.\n        /// @param numVertices\n        ///     The number of vertices in the mesh.\n        /// @param numIndices\n        ///     The number of indices in the mesh.\n        /// @param vertexData\n        ///     The vertex data for the mesh.\n        /// @param indexData\n        ///     The index data for the mesh.\n        ///\n        MeshDesc(const std::string& name, PolygonType polygonType, const VertexFormat& vertexFormat, IndexFormat indexFormat, const AABB& aabb, const Sphere& boundingSphere, u32 numVertices, u32 numIndices,\n                 std::unique_ptr<const u8[]> vertexData, std::unique_ptr<const u8[]> indexData) noexcept;\n        \n        /// Creates a new mesh description with the given format, mesh data and inverse bind pose\n        /// matrices.\n        ///\n        /// @param name\n        ///     The name of the mesh.\n        /// @param polygonType\n        ///     The type of polygon that this mesh uses.\n        /// @param vertexFormat\n        ///     The format of a single vertex.\n        /// @param indexFormat\n        ///     The format of a single index.\n        /// @param aabb\n        ///     The local AABB of the mesh.\n        /// @param numVertices\n        ///     The number of vertices in the mesh.\n        /// @param numIndices\n        ///     The number of indices in the mesh.\n        /// @param vertexData\n        ///     The vertex data for the mesh.\n        /// @param indexData\n        ///     The index data for the mesh.\n        /// @param inverseBindPoseMatrices\n        ///     The inverse bind pose matices.\n        ///\n        MeshDesc(const std::string& name, PolygonType polygonType, const VertexFormat& vertexFormat, IndexFormat indexFormat, const AABB& aabb, const Sphere& boundingSphere, u32 numVertices, u32 numIndices,\n                 std::unique_ptr<const u8[]> vertexData, std::unique_ptr<const u8[]> indexData, std::vector<Matrix4> inverseBindPoseMatrices) noexcept;\n        \n        /// @return The name of the mesh\n        ///\n        const std::string& GetName() const noexcept { return m_name; }\n        \n        /// @return The type of polygon that this mesh uses.\n        ///\n        PolygonType GetPolygonType() const noexcept { return m_polygonType; }\n        \n        /// @return The format of single vertex.\n        ///\n        const VertexFormat& GetVertexFormat() const noexcept { return m_vertexFormat; }\n        \n        /// @return The format of a single index.\n        ///\n        IndexFormat GetIndexFormat() const noexcept { return m_indexFormat; }\n        \n        /// @return The local AABB of the mesh.\n        ///\n        const AABB& GetAABB() const noexcept { return m_aabb; }\n        \n        /// @return The local bounding sphere of the mesh.\n        ///\n        const Sphere& GetBoundingSphere() const noexcept { return m_boundingSphere; }\n        \n        /// @return The number of vertices in the mesh.\n        ///\n        u32 GetNumVertices() const noexcept { return m_numVertices; }\n        \n        /// @return The number of indices in the mesh.\n        ///\n        u32 GetNumIndices() const noexcept { return m_numIndices; }\n        \n        /// Moves the vertex data from the description to a new owner. This must not\n        /// be called twice, otherwise it will assert.\n        ///\n        /// @return The vertex data for the mesh.\n        ///\n        std::unique_ptr<const u8[]> ClaimVertexData() noexcept;\n        \n        /// Moves the index data from the description to a new owner. This must not\n        /// be called twice, otherwise it will assert.\n        ///\n        /// @return The index data for the mesh.\n        ///\n        std::unique_ptr<const u8[]> ClaimIndexData() noexcept;\n        \n        /// Moves the inverse bind pose matrices from the description to a new owner.\n        ///\n        /// @return The index data for the mesh.\n        ///\n        std::vector<Matrix4> ClaimInverseBindPoseMatrices() noexcept;\n        \n    private:\n        std::string m_name;\n        PolygonType m_polygonType;\n        VertexFormat m_vertexFormat;\n        IndexFormat m_indexFormat;\n        AABB m_aabb;\n        Sphere m_boundingSphere;\n        u32 m_numVertices;\n        u32 m_numIndices;\n        std::unique_ptr<const u8[]> m_vertexData;\n        std::unique_ptr<const u8[]> m_indexData;\n        std::vector<Matrix4> m_inverseBindPoseMatrixes;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Model/Model.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2010 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Model/Model.h>\n\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Rendering/Material/Material.h>\n#include <ChilliSource/Rendering/Model/ModelDesc.h>\n#include <ChilliSource/Rendering/Model/RenderMeshManager.h>\n\n#include <algorithm>\n\nnamespace ChilliSource\n{\n    CS_DEFINE_NAMEDTYPE(Model);\n\n    //------------------------------------------------------------------------------\n    ModelUPtr Model::Create() noexcept\n    {\n        return ModelUPtr(new Model());\n    }\n    \n    //------------------------------------------------------------------------------\n    bool Model::IsA(InterfaceIDType in_interfaceId) const noexcept\n    {\n        return in_interfaceId == Model::InterfaceID;\n    }\n    \n    //------------------------------------------------------------------------------\n    void Model::Build(ModelDesc modelDesc) noexcept\n    {\n        DestroyRenderMeshes();\n        \n        m_aabb = modelDesc.GetAABB();\n        m_boundingSphere = modelDesc.GetBoundingSphere();\n        m_skeleton = Skeleton(modelDesc.GetSkeletonDesc());\n        \n        auto renderMeshManager = Application::Get()->GetSystem<RenderMeshManager>();\n        for (u32 meshIndex = 0; meshIndex < modelDesc.GetNumMeshDescs(); ++meshIndex)\n        {\n            auto& meshDesc = modelDesc.GetMeshDesc(meshIndex);\n            \n            m_meshNames.push_back(meshDesc.GetName());\n            \n            auto poylgonType = meshDesc.GetPolygonType();\n            auto vertexFormat = meshDesc.GetVertexFormat();\n            auto indexFormat = meshDesc.GetIndexFormat();\n            auto numVertices = meshDesc.GetNumVertices();\n            auto numIndices = meshDesc.GetNumIndices();\n            auto boundingSphere = meshDesc.GetBoundingSphere();\n            auto vertexData = meshDesc.ClaimVertexData();\n            auto indexData = meshDesc.ClaimIndexData();\n            auto vertexDataSize = meshDesc.GetNumVertices() * meshDesc.GetVertexFormat().GetSize();\n            auto indexDataSize = meshDesc.GetNumIndices() * GetIndexSize(meshDesc.GetIndexFormat());\n            auto inverseBindPoseMatrices = meshDesc.ClaimInverseBindPoseMatrices();\n            \n            auto renderMesh = renderMeshManager->CreateRenderMesh(poylgonType, vertexFormat, indexFormat, numVertices, numIndices, boundingSphere, std::move(vertexData), vertexDataSize, std::move(indexData), indexDataSize,\n                                                                  modelDesc.ShouldBackupData(), std::move(inverseBindPoseMatrices));\n            m_renderMeshes.push_back(std::move(renderMesh));\n        }\n    }\n    \n    //------------------------------------------------------------------------------\n    const AABB& Model::GetAABB() const noexcept\n    {\n        CS_ASSERT(GetLoadState() == LoadState::k_loaded, \"Cannot access a model before it is loaded.\");\n        CS_ASSERT(m_renderMeshes.size() > 0, \"Cannot access a model which has not been built.\");\n        \n        return m_aabb;\n    }\n    \n    //------------------------------------------------------------------------------\n    const Sphere& Model::GetBoundingSphere() const noexcept\n    {\n        CS_ASSERT(GetLoadState() == LoadState::k_loaded, \"Cannot access a model before it is loaded.\");\n        CS_ASSERT(m_renderMeshes.size() > 0, \"Cannot access a model which has not been built.\");\n        \n        return m_boundingSphere;\n    }\n    \n    //------------------------------------------------------------------------------\n    const Skeleton& Model::GetSkeleton() const noexcept\n    {\n        CS_ASSERT(GetLoadState() == LoadState::k_loaded, \"Cannot access a model before it is loaded.\");\n        CS_ASSERT(m_renderMeshes.size() > 0, \"Cannot access a model which has not been built.\");\n        \n        return m_skeleton;\n    }\n    \n    //------------------------------------------------------------------------------\n    u32 Model::GetNumMeshes() const noexcept\n    {\n        CS_ASSERT(GetLoadState() == LoadState::k_loaded, \"Cannot access a model before it is loaded.\");\n        CS_ASSERT(m_renderMeshes.size() > 0, \"Cannot access a model which has not been built.\");\n        \n        return u32(m_renderMeshes.size());\n    }\n    \n    //------------------------------------------------------------------------------\n    const std::string& Model::GetMeshName(u32 index) const noexcept\n    {\n        CS_ASSERT(GetLoadState() == LoadState::k_loaded, \"Cannot access a model before it is loaded.\");\n        CS_ASSERT(m_renderMeshes.size() > 0, \"Cannot access a model which has not been built.\");\n        CS_ASSERT(index < m_meshNames.size(), \"Index is out of bounds.\");\n        \n        return m_meshNames[index];\n    }\n    \n    //------------------------------------------------------------------------------\n    const u32 Model::GetMeshIndex(const std::string& name) const noexcept\n    {\n        CS_ASSERT(GetLoadState() == LoadState::k_loaded, \"Cannot access a model before it is loaded.\");\n        CS_ASSERT(m_renderMeshes.size() > 0, \"Cannot access a model which has not been built.\");\n        \n        for (u32 index = 0; index < m_meshNames.size(); ++index)\n        {\n            if (m_meshNames[index] == name)\n            {\n                return index;\n            }\n        }\n        \n        CS_LOG_FATAL(\"Could not find mesh name with name '\" + name + \"' in model.\");\n        return 0;\n    }\n    \n    //------------------------------------------------------------------------------\n    const RenderMesh* Model::GetRenderMesh(u32 index) const noexcept\n    {\n        CS_ASSERT(GetLoadState() == LoadState::k_loaded, \"Cannot access a model before it is loaded.\");\n        CS_ASSERT(m_renderMeshes.size() > 0, \"Cannot access a model which has not been built.\");\n        CS_ASSERT(index < m_meshNames.size(), \"Index is out of bounds.\");\n        \n        return m_renderMeshes[index].get();\n    }\n    \n    //------------------------------------------------------------------------------\n    void Model::DestroyRenderMeshes() noexcept\n    {\n        auto renderMeshManager = Application::Get()->GetSystem<RenderMeshManager>();\n        for (auto& renderMesh : m_renderMeshes)\n        {\n            renderMeshManager->DestroyRenderMesh(std::move(renderMesh));\n        }\n        m_renderMeshes.clear();\n        m_meshNames.clear();\n    }\n    \n    //------------------------------------------------------------------------------\n    Model::~Model() noexcept\n    {\n        DestroyRenderMeshes();\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Model/Model.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2010 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_MODEL_MODEL_H_\n#define _CHILLISOURCE_RENDERING_MODEL_MODEL_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Math/Geometry/Shapes.h>\n#include <ChilliSource/Core/Memory/UniquePtr.h>\n#include <ChilliSource/Core/Resource/Resource.h>\n#include <ChilliSource/Rendering/Model/Skeleton.h>\n\nnamespace ChilliSource\n{\n    /// A single renderable model which is comprised of one or more meshes.\n    ///\n    /// This is not thread safe and should only be accessed from one thread at a time.\n    ///\n    class Model final : public Resource\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(Model);\n        \n        /// Allows querying of whether or not this resource implements the interface described by the\n        /// given interface Id. Typically this is not called directly as the templated equivalent\n        /// IsA<Interface>() is preferred.\n        ///\n        /// @param interfaceId\n        ///     The Id of the interface.\n        ///\n        /// @return Whether or not the interface is implemented.\n        ///\n        bool IsA(InterfaceIDType interfaceId) const noexcept override;\n        \n        /// Build the model from the given description, creating all required meshes and a skeleton\n        /// if required. The model must not already be in the loaded state.\n        ///\n        /// The description must be passed by move, rather than copy to avoid duplicating mesh data.\n        ///\n        /// @param modelDesc\n        ///     The model description. Can only be used once to build a model.\n        ///\n        void Build(ModelDesc modelDesc) noexcept;\n        \n        /// This must not be called until the model is built and loaded.\n        ///\n        /// @return The local space axis-aligned bounding box of the Model.\n        ///\n        const AABB& GetAABB() const noexcept;\n        \n        /// This must not be called until the model is built and loaded.\n        ///\n        /// @return The local space bounding sphere of the Model.\n        ///\n        const Sphere& GetBoundingSphere() const noexcept;\n        \n        /// This must not be called until the model is built and loaded.\n        ///\n        /// @return The skeleton.\n        ///\n        const Skeleton& GetSkeleton() const noexcept;\n        \n        /// This must not be called until the model is built and loaded.\n        ///\n        /// @return The number of meshes that make up the model.\n        ///\n        u32 GetNumMeshes() const noexcept;\n        \n        /// Looks up the name of the mesh with the given index. If the index is out of bounds, this will\n        /// assert.\n        ///\n        /// This must not be called until the model is built and loaded.\n        ///\n        /// @param index\n        ///     The index of the mesh.\n        ///\n        /// @return The name of the mesh.\n        ///\n        const std::string& GetMeshName(u32 index) const noexcept;\n        \n        /// Looks up the index of the mesh with the given name. If the name doesn't exist, this will assert.\n        ///\n        /// This must not be called until the model is built and loaded.\n        ///\n        /// @param name\n        ///     The name of the mesh.\n        ///\n        /// @return The index of the mesh with the given name.\n        ///\n        const u32 GetMeshIndex(const std::string& name) const noexcept;\n        \n        /// Looks up the RenderMesh of the mesh with the given index. If the index is out of bounds, this will\n        /// assert.\n        ///\n        /// This must not be called until the model is built and loaded.\n        ///\n        /// @param index\n        ///     The index of the mesh.\n        ///\n        /// @return The render mesh.\n        ///\n        const RenderMesh* GetRenderMesh(u32 index) const noexcept;\n        \n        ~Model() noexcept;\n        \n    private:\n        friend class ResourcePool;\n        friend class CSModelProvider;\n        \n        /// A factory method for creating new, empty instances of the resource. This must only be\n        /// called by ResourcePool.\n        ///\n        /// @return The new instance of the resource.\n        ///\n        static ModelUPtr Create() noexcept;\n        \n        /// Destroys the RenderMeshes if there currently are any\n        ///\n        void DestroyRenderMeshes() noexcept;\n        \n        Model() = default;\n\n        std::vector<std::string> m_meshNames;\n        std::vector<UniquePtr<RenderMesh>> m_renderMeshes;\n        Skeleton m_skeleton;\n        AABB m_aabb;\n        Sphere m_boundingSphere;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Model/ModelDesc.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Model/ModelDesc.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    ModelDesc::ModelDesc(std::vector<MeshDesc> meshDescs, const AABB& aabb, const Sphere& boundingSphere, bool shouldBackupData) noexcept\n        : m_meshDescs(std::move(meshDescs)), m_aabb(aabb), m_boundingSphere(boundingSphere), m_shouldBackupData(shouldBackupData)\n    {\n    }\n    \n    //------------------------------------------------------------------------------\n    ModelDesc::ModelDesc(std::vector<MeshDesc> meshDescs, const AABB& aabb, const Sphere& boundingSphere, const SkeletonDesc& skeletonDesc, bool shouldBackupData) noexcept\n    : m_meshDescs(std::move(meshDescs)), m_aabb(aabb), m_boundingSphere(boundingSphere), m_skeletonDesc(skeletonDesc), m_shouldBackupData(shouldBackupData)\n    {\n    }\n    \n    //------------------------------------------------------------------------------\n    MeshDesc& ModelDesc::GetMeshDesc(u32 index) noexcept\n    {\n        CS_ASSERT(index < GetNumMeshDescs(), \"Index out of bounds.\");\n        \n        return m_meshDescs[index];\n    }\n    \n    //------------------------------------------------------------------------------\n    const MeshDesc& ModelDesc::GetMeshDesc(u32 index) const noexcept\n    {\n        CS_ASSERT(index < GetNumMeshDescs(), \"Index out of bounds.\");\n        \n        return m_meshDescs[index];\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Model/ModelDesc.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_MODEL_MODELDESC_H_\n#define _CHILLISOURCE_RENDERING_MODEL_MODELDESC_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Math/Geometry/Shapes.h>\n#include <ChilliSource/Rendering/Model/MeshDesc.h>\n#include <ChilliSource/Rendering/Model/SkeletonDesc.h>\n\nnamespace ChilliSource\n{\n    /// A description of a model. This is used to build a single model instance. Attempting\n    /// to use the same model description to create a second model will assert, as the mesh\n    /// data will have been moved to the first model instance.\n    ///\n    /// This is not thread safe and should only be accessed by one thread at a time.\n    ///\n    class ModelDesc final\n    {\n    public:\n        CS_DECLARE_NOCOPY(ModelDesc);\n        \n        ModelDesc() = default;\n        ModelDesc(ModelDesc&&) = default;\n        ModelDesc& operator=(ModelDesc&&) = default;\n        \n        /// Creates a new model description with the given mesh data and bounds.\n        ///\n        /// @param meshDescs\n        ///     The list of mesh descriptions.\n        /// @param aabb\n        ///     The local AABB of the model.\n        /// @param boundingSphere\n        ///     The local bounding sphere of the model.\n        /// @param shouldBackupData\n        ///     If the model mesh data should be backed up in main memory for restoring it later.\n        ///\n        ModelDesc(std::vector<MeshDesc> meshDescs, const AABB& aabb, const Sphere& boundingSphere, bool shouldBackupData = true) noexcept;\n        \n        /// Creates a new model description with the given mesh data, bounds and skeleton\n        /// description.\n        ///\n        /// @param meshDescs\n        ///     The list of mesh descriptions. This must be passed by move to avoid duplicating\n        ///     mesh data.\n        /// @param aabb\n        ///     The local AABB of the model.\n        /// @param boundingSphere\n        ///     The local bounding sphere of the model.\n        /// @param skeletonDesc\n        ///     The skeleton description.\n        /// @param shouldBackupData\n        ///     If the model mesh data should be backed up in main memory for restoring it later.\n        ///\n        ModelDesc(std::vector<MeshDesc> meshDescs, const AABB& aabb, const Sphere& boundingSphere, const SkeletonDesc& skeletonDesc, bool shouldBackupData = true) noexcept;\n        \n        /// @return The list of mesh descriptions.\n        ///\n        u32 GetNumMeshDescs() const noexcept { return u32(m_meshDescs.size()); }\n        \n        /// @param index\n        ///     The mesh description index. Must be lower than the value returned from\n        ///     GetNumMeshDesc() else this will assert.\n        ///\n        /// @return The mesh description at the given index.\n        ///\n        MeshDesc& GetMeshDesc(u32 index) noexcept;\n        \n        /// @param index\n        ///     The mesh description index. Must be lower than the value returned from\n        ///     GetNumMeshDesc() else this will assert.\n        ///\n        /// @return The mesh description at the given index.\n        ///\n        const MeshDesc& GetMeshDesc(u32 index) const noexcept;\n        \n        /// @return The local AABB of the mode.\n        ///\n        const AABB& GetAABB() const noexcept { return m_aabb;  }\n        \n        /// @return The local bounding sphere of the mode.\n        ///\n        const Sphere& GetBoundingSphere() const noexcept { return m_boundingSphere;  }\n        \n        /// @return The skeleton description.\n        ///\n        const SkeletonDesc& GetSkeletonDesc() const noexcept { return m_skeletonDesc; }\n        \n        /// @return If the data should be backed up for restoration.\n        ///\n        bool ShouldBackupData() const noexcept { return m_shouldBackupData; }\n        \n    private:\n        std::vector<MeshDesc> m_meshDescs;\n        AABB m_aabb;\n        Sphere m_boundingSphere;\n        SkeletonDesc m_skeletonDesc;\n        bool m_shouldBackupData = true;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Model/PolygonType.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_MODEL_POLYGONTYPE_H_\n#define _CHILLISOURCE_RENDERING_MODEL_POLYGONTYPE_H_\n\n#include <ChilliSource/ChilliSource.h>\n\nnamespace ChilliSource\n{\n    /// An enum describing the various different types of Polygon.\n    ///\n    enum class PolygonType\n    {\n        k_line,\n        k_triangle,\n        k_triangleStrip\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Model/PrimitiveModelFactory.cpp",
    "content": "//\n//  PrimitiveModelFactory.cpp\n//  ChilliSource\n//  Created by Ian Copland on 03/08/2015.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2015 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Model/PrimitiveModelFactory.h>\n\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/Resource/ResourcePool.h>\n#include <ChilliSource/Core/Threading/TaskScheduler.h>\n#include <ChilliSource/Rendering/Model/Model.h>\n#include <ChilliSource/Rendering/Model/ModelDesc.h>\n\nnamespace ChilliSource\n{\n    namespace\n    {\n        //------------------------------------------------------------------------------\n        /// Creates a new model description describing a plane model.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param in_size - The size of the model.\n        /// @param in_textureRepeat - The number of times the texture is repeated.\n        ///\n        /// @return The new model description.\n        //------------------------------------------------------------------------------\n        ModelDesc CreatePlaneDesc(const Vector2& in_size, const Vector2& in_textureRepeat)\n        {\n            constexpr u32 k_numVertices = 4;\n            constexpr u32 k_numIndices = 6;\n            const Vector2 halfSize = in_size * 0.5f;\n\n            // Vertices\n            auto vertices = new StaticMeshVertex[k_numVertices];\n            vertices[0] = { Vector4(-halfSize.x, 0.0f, -halfSize.y, 1.0f), Vector3(0.0f, 1.0f, 0.0f), Vector3(1.0f, 0.0f, 0.0f), Vector3(0.0f, 0.0f, -1.0f), Vector2(0.0f, 0.0f) };\n            vertices[1] = { Vector4(-halfSize.x, 0.0f, halfSize.y, 1.0f), Vector3(0.0f, 1.0f, 0.0f), Vector3(1.0f, 0.0f, 0.0f), Vector3(0.0f, 0.0f, -1.0f), Vector2(0.0f, in_textureRepeat.y) };\n            vertices[2] = { Vector4(halfSize.x, 0.0f, -halfSize.y, 1.0f), Vector3(0.0f, 1.0f, 0.0f), Vector3(1.0f, 0.0f, 0.0f), Vector3(0.0f, 0.0f, -1.0f), Vector2(in_textureRepeat.x, 0.0f) };\n            vertices[3] = { Vector4(halfSize.x, 0.0f, halfSize.y, 1.0f), Vector3(0.0f, 1.0f, 0.0f), Vector3(1.0f, 0.0f, 0.0f), Vector3(0.0f, 0.0f, -1.0f), Vector2(in_textureRepeat.x, in_textureRepeat.y) };\n            \n            // Indices\n            u16* indices(new u16[k_numIndices]);\n            indices[0] = 0;\n            indices[1] = 2;\n            indices[2] = 1;\n            indices[3] = 1;\n            indices[4] = 2;\n            indices[5] = 3;\n            \n            auto name = \"PlaneMesh\";\n            auto polygonType = PolygonType::k_triangle;\n            auto vertexFormat = VertexFormat::k_staticMesh;\n            auto indexFormat = IndexFormat::k_short;\n            AABB aabb(Vector3::k_zero, Vector3(in_size.x, 0.0f, in_size.y));\n            Sphere boundingSphere(Vector3::k_zero, in_size.Length() * 0.5f);\n            std::unique_ptr<const u8[]> vertexData(reinterpret_cast<const u8*>(vertices));\n            std::unique_ptr<const u8[]> indexData(reinterpret_cast<const u8*>(indices));\n            \n            std::vector<MeshDesc> meshDescs;\n            meshDescs.push_back(MeshDesc(name, polygonType, vertexFormat, indexFormat, aabb, boundingSphere, k_numVertices, k_numIndices, std::move(vertexData), std::move(indexData)));\n            \n            return ModelDesc(std::move(meshDescs), aabb, boundingSphere);\n        }\n        //------------------------------------------------------------------------------\n        /// Creates a new model description describing a box model.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param in_size - The size of the model.\n        /// @param in_textureRepeat - The number of times the texture is repeated on\n        /// each face.\n        /// @param in_flipNormals - Whether or not to flip the box inside out.\n        /// This is useful for creating rooms\n        ///\n        /// @return The new model description.\n        //------------------------------------------------------------------------------\n        ModelDesc CreateBoxDesc(const Vector3& in_size, const Vector2& in_textureRepeat, bool in_flipNormals)\n        {\n            constexpr u32 k_numVertices = 24;\n            constexpr u32 k_numIndices = 36;\n            const Vector3 halfSize = in_size * 0.5f;\n            \n            //Vertices\n            auto vertices = new StaticMeshVertex[k_numVertices];\n            float normalDir = (in_flipNormals == false) ? 1.0f : -1.0f;\n            \n            //bottom\n            vertices[0] = { Vector4(-halfSize.x, -halfSize.y, -halfSize.z, 1.0f), Vector3(0.0f, -normalDir, 0.0f), Vector3(-normalDir, 0.0f, 0.0f), Vector3(0.0f, 0.0f, normalDir), Vector2(0.0f, 0.0f) };\n            vertices[1] = { Vector4(-halfSize.x, -halfSize.y, halfSize.z, 1.0f), Vector3(0.0f, -normalDir, 0.0f), Vector3(-normalDir, 0.0f, 0.0f), Vector3(0.0f, 0.0f, normalDir), Vector2(0.0f, in_textureRepeat.y) };\n            vertices[2] = { Vector4(halfSize.x, -halfSize.y, -halfSize.z, 1.0f), Vector3(0.0f, -normalDir, 0.0f), Vector3(-normalDir, 0.0f, 0.0f), Vector3(0.0f, 0.0f, normalDir), Vector2(in_textureRepeat.x, 0.0f) };\n            vertices[3] = { Vector4(halfSize.x, -halfSize.y, halfSize.z, 1.0f), Vector3(0.0f, -normalDir, 0.0f), Vector3(-normalDir, 0.0f, 0.0f), Vector3(0.0f, 0.0f, normalDir), Vector2(in_textureRepeat.x, in_textureRepeat.y) };\n            \n            //top\n            vertices[4] = { Vector4(halfSize.x, halfSize.y, -halfSize.z, 1.0f), Vector3(0.0f, normalDir, 0.0f), Vector3(normalDir, 0.0f, 0.0f), Vector3(0.0f, 0.0f, -normalDir), Vector2(0.0f, 0.0f) };\n            vertices[5] = { Vector4(halfSize.x, halfSize.y, halfSize.z, 1.0f), Vector3(0.0f, normalDir, 0.0f), Vector3(normalDir, 0.0f, 0.0f), Vector3(0.0f, 0.0f, -normalDir), Vector2(0.0f, in_textureRepeat.y) };\n            vertices[6] = { Vector4(-halfSize.x, halfSize.y, -halfSize.z, 1.0f), Vector3(0.0f, normalDir, 0.0f), Vector3(normalDir, 0.0f, 0.0f), Vector3(0.0f, 0.0f, -normalDir), Vector2(in_textureRepeat.x, 0.0f) };\n            vertices[7] = { Vector4(-halfSize.x, halfSize.y, halfSize.z, 1.0f), Vector3(0.0f, normalDir, 0.0f), Vector3(normalDir, 0.0f, 0.0f), Vector3(0.0f, 0.0f, -normalDir), Vector2(in_textureRepeat.x, in_textureRepeat.y) };\n            \n            //left\n            vertices[8] = { Vector4(-halfSize.x, halfSize.y, -halfSize.z, 1.0f), Vector3(-normalDir, 0.0f, 0.0f), Vector3(0.0f, -normalDir, 0.0f), Vector3(0.0f, 0.0f, -normalDir), Vector2(0.0f, 0.0f) };\n            vertices[9] = { Vector4(-halfSize.x, halfSize.y, halfSize.z, 1.0f), Vector3(-normalDir, 0.0f, 0.0f), Vector3(0.0f, -normalDir, 0.0f), Vector3(0.0f, 0.0f, -normalDir), Vector2(0.0f, in_textureRepeat.y) };\n            vertices[10] = { Vector4(-halfSize.x, -halfSize.y, -halfSize.z, 1.0f), Vector3(-normalDir, 0.0f, 0.0f), Vector3(0.0f, -normalDir, 0.0f), Vector3(0.0f, 0.0f, -normalDir), Vector2(in_textureRepeat.x, 0.0f) };\n            vertices[11] = { Vector4(-halfSize.x, -halfSize.y, halfSize.z, 1.0f), Vector3(-normalDir, 0.0f, 0.0f), Vector3(0.0f, -normalDir, 0.0f), Vector3(0.0f, 0.0f, -normalDir), Vector2(in_textureRepeat.x, in_textureRepeat.y) };\n            \n            //right\n            vertices[12] = { Vector4(halfSize.x, -halfSize.y, -halfSize.z, 1.0f), Vector3(normalDir, 0.0f, 0.0f), Vector3(0.0f, normalDir, 0.0f), Vector3(0.0f, 0.0f, -normalDir), Vector2(0.0f, 0.0f) };\n            vertices[13] = { Vector4(halfSize.x, -halfSize.y, halfSize.z, 1.0f), Vector3(normalDir, 0.0f, 0.0f), Vector3(0.0f, normalDir, 0.0f), Vector3(0.0f, 0.0f, -normalDir), Vector2(0.0f, in_textureRepeat.y) };\n            vertices[14] = { Vector4(halfSize.x, halfSize.y, -halfSize.z, 1.0f), Vector3(normalDir, 0.0f, 0.0f), Vector3(0.0f, normalDir, 0.0f), Vector3(0.0f, 0.0f, -normalDir), Vector2(in_textureRepeat.x, 0.0f) };\n            vertices[15] = { Vector4(halfSize.x, halfSize.y, halfSize.z, 1.0f), Vector3(normalDir, 0.0f, 0.0f), Vector3(0.0f, normalDir, 0.0f), Vector3(0.0f, 0.0f, -normalDir), Vector2(in_textureRepeat.x, in_textureRepeat.y) };\n            \n            //front\n            vertices[16] = { Vector4(-halfSize.x, halfSize.y, -halfSize.z, 1.0f), Vector3(0.0f, 0.0f, -normalDir), Vector3(normalDir, 0.0f, 0.0f), Vector3(0.0f, normalDir, 0.0f), Vector2(0.0f, 0.0f) };\n            vertices[17] = { Vector4(-halfSize.x, -halfSize.y, -halfSize.z, 1.0f), Vector3(0.0f, 0.0f, -normalDir), Vector3(normalDir, 0.0f, 0.0f), Vector3(0.0f, normalDir, 0.0f), Vector2(0.0f, in_textureRepeat.y) };\n            vertices[18] = { Vector4(halfSize.x, halfSize.y, -halfSize.z, 1.0f), Vector3(0.0f, 0.0f, -normalDir), Vector3(normalDir, 0.0f, 0.0f), Vector3(0.0f, normalDir, 0.0f), Vector2(in_textureRepeat.x, 0.0f) };\n            vertices[19] = { Vector4(halfSize.x, -halfSize.y, -halfSize.z, 1.0f), Vector3(0.0f, 0.0f, -normalDir), Vector3(normalDir, 0.0f, 0.0f), Vector3(0.0f, normalDir, 0.0f), Vector2(in_textureRepeat.x, in_textureRepeat.y) };\n            \n            //back\n            vertices[20] = { Vector4(-halfSize.x, -halfSize.y, halfSize.z, 1.0f), Vector3(0.0f, 0.0f, normalDir), Vector3(normalDir, 0.0f, 0.0f), Vector3(0.0f, -normalDir, 0.0f), Vector2(0.0f, 0.0f) };\n            vertices[21] = { Vector4(-halfSize.x, halfSize.y, halfSize.z, 1.0f), Vector3(0.0f, 0.0f, normalDir), Vector3(normalDir, 0.0f, 0.0f), Vector3(0.0f, -normalDir, 0.0f), Vector2(0.0f, in_textureRepeat.y) };\n            vertices[22] = { Vector4(halfSize.x, -halfSize.y, halfSize.z, 1.0f), Vector3(0.0f, 0.0f, normalDir), Vector3(normalDir, 0.0f, 0.0f), Vector3(0.0f, -normalDir, 0.0f), Vector2(in_textureRepeat.x, 0.0f) };\n            vertices[23] = { Vector4(halfSize.x, halfSize.y, halfSize.z, 1.0f), Vector3(0.0f, 0.0f, normalDir), Vector3(normalDir, 0.0f, 0.0f), Vector3(0.0f, -normalDir, 0.0f), Vector2(in_textureRepeat.x, in_textureRepeat.y) };\n            \n            //Indices\n            u16 *indices(new u16[k_numIndices]);\n            \n            //bottom\n            indices[0] = 0;\n            indices[1] = 1;\n            indices[2] = 2;\n            indices[3] = 1;\n            indices[4] = 3;\n            indices[5] = 2;\n            \n            //top\n            indices[6] = 4;\n            indices[7] = 5;\n            indices[8] = 6;\n            indices[9] = 5;\n            indices[10] = 7;\n            indices[11] = 6;\n            \n            //left\n            indices[12] = 8;\n            indices[13] = 9;\n            indices[14] = 10;\n            indices[15] = 9;\n            indices[16] = 11;\n            indices[17] = 10;\n            \n            //right\n            indices[18] = 12;\n            indices[19] = 13;\n            indices[20] = 14;\n            indices[21] = 13;\n            indices[22] = 15;\n            indices[23] = 14;\n            \n            //front\n            indices[24] = 16;\n            indices[25] = 17;\n            indices[26] = 18;\n            indices[27] = 17;\n            indices[28] = 19;\n            indices[29] = 18;\n            \n            //back\n            indices[30] = 20;\n            indices[31] = 21;\n            indices[32] = 22;\n            indices[33] = 21;\n            indices[34] = 23;\n            indices[35] = 22;\n            \n            if (in_flipNormals == true)\n            {\n                for (u32 i = 0; i < k_numIndices; i += 3)\n                {\n                    u16 temp = indices[i + 1];\n                    indices[i + 1] = indices[i + 2];\n                    indices[i + 2] = temp;\n                }\n            }\n        \n            auto name = \"BoxMesh\";\n            auto polygonType = PolygonType::k_triangle;\n            auto vertexFormat = VertexFormat::k_staticMesh;\n            auto indexFormat = IndexFormat::k_short;\n            AABB aabb(Vector3::k_zero, in_size);\n            Sphere boundingSphere(Vector3::k_zero, in_size.Length() / 0.5f);\n            std::unique_ptr<const u8[]> vertexData(reinterpret_cast<const u8*>(vertices));\n            std::unique_ptr<const u8[]> indexData(reinterpret_cast<const u8*>(indices));\n            \n            std::vector<MeshDesc> meshDescs;\n            meshDescs.push_back(MeshDesc(name, polygonType, vertexFormat, indexFormat, aabb, boundingSphere, k_numVertices, k_numIndices, std::move(vertexData), std::move(indexData)));\n            \n            return ModelDesc(std::move(meshDescs), aabb, boundingSphere);\n        }\n    }\n    \n    CS_DEFINE_NAMEDTYPE(PrimitiveModelFactory);\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    PrimitiveModelFactoryUPtr PrimitiveModelFactory::Create()\n    {\n        return PrimitiveModelFactoryUPtr(new PrimitiveModelFactory());\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    bool PrimitiveModelFactory::IsA(InterfaceIDType in_interfaceId) const\n    {\n        return (PrimitiveModelFactory::InterfaceID == in_interfaceId);\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    ModelCSPtr PrimitiveModelFactory::CreatePlane(const Vector2& in_size, const Vector2& in_textureRepeat) const\n    {\n        CS_RELEASE_ASSERT(Application::Get()->GetTaskScheduler()->IsMainThread(), \"Cannot create models on a background thread.\");\n        \n        auto resourcePool = Application::Get()->GetResourcePool();\n        auto meshName = \"_PrimitivePlane(\" + ToString(in_size) + \")\";\n        auto mesh = resourcePool->GetResource<Model>(meshName);\n        \n        if (mesh == nullptr)\n        {\n            auto mutableMesh = resourcePool->CreateResource<Model>(meshName);\n            \n            auto desc = CreatePlaneDesc(in_size, in_textureRepeat);\n            mutableMesh->Build(std::move(desc));\n            mutableMesh->SetLoadState(Resource::LoadState::k_loaded);\n            \n            mesh = mutableMesh;\n        }\n        \n        return mesh;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    ModelCSPtr PrimitiveModelFactory::CreateBox(const Vector3& in_size, const Vector2& in_textureRepeat, bool in_flipNormals) const\n    {\n        CS_RELEASE_ASSERT(Application::Get()->GetTaskScheduler()->IsMainThread(), \"Cannot create models on a background thread.\");\n        \n        auto resourcePool = Application::Get()->GetResourcePool();\n        auto meshName = \"_PrimitiveBox(\" + ToString(in_size) + \"|\" + ToString(in_textureRepeat) + \"|\" + ToString(in_flipNormals) + \")\";\n        auto mesh = resourcePool->GetResource<Model>(meshName);\n        \n        if (mesh == nullptr)\n        {\n            auto mutableMesh = resourcePool->CreateResource<Model>(meshName);\n            \n            auto desc = CreateBoxDesc(in_size, in_textureRepeat, in_flipNormals);\n            mutableMesh->Build(std::move(desc));\n            mutableMesh->SetLoadState(Resource::LoadState::k_loaded);\n            \n            mesh = mutableMesh;\n        }\n        \n        return mesh;\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Model/PrimitiveModelFactory.h",
    "content": "//\n//  PrimitiveModelFactory.h\n//  ChilliSource\n//  Created by Ian Copland on 03/08/2015.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2015 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_MODEL_PRIMITIVEMODELFACTORY_H_\n#define _CHILLISOURCE_RENDERING_MODEL_PRIMITIVEMODELFACTORY_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Math/Vector2.h>\n#include <ChilliSource/Core/Math/Vector3.h>\n#include <ChilliSource/Core/System/AppSystem.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    /// A PrimitiveModelFactory is a factory for creating primitive models types\n    /// such as boxes and planes. Prior to creating the requested model the factory\n    /// will check if an identical model already exists. If one does, it will be\n    /// returned rather than creating a new model.\n    ///\n    /// PrimitiveModelFactory is not a default system, so it will need to be added\n    /// using Application::CreateSystem() prior to use.\n    ///\n    /// Models can only be created on the main thread as PrimitiveModelFactory is\n    /// not thread-safe.\n    ///\n    /// @author Ian Copland\n    //------------------------------------------------------------------------------\n    class PrimitiveModelFactory final : public AppSystem\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(PrimitiveModelFactory);\n        //------------------------------------------------------------------------------\n        /// Allows querying of whether or not this system implements the interface\n        /// described by the given interface Id. Typically this is not called directly\n        /// as the templated equivalent IsA<Interface>() is preferred.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param in_interfaceId - The interface Id.\n        ///\n        /// @return Whether or not the interface is implemented.\n        //------------------------------------------------------------------------------\n        bool IsA(InterfaceIDType in_interfaceId) const override;\n        //------------------------------------------------------------------------------\n        /// Creates a new plane model perpendicular to the Y axis of the given size. If\n        /// an identical plane already exists it will be returned instead of creating\n        /// a new instance.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param in_size - The size of the plane.\n        /// @param in_textureRepeat - [Optional] The number of times a texture is\n        /// repeated on the plane in each axis. Defaults to [1, 1]\n        ///\n        /// @return The plane model.\n        //------------------------------------------------------------------------------\n        ModelCSPtr CreatePlane(const Vector2& in_size, const Vector2& in_textureRepeat = Vector2::k_one) const;\n        //------------------------------------------------------------------------------\n        /// Creates a box model of the given size. If an identical box already exists\n        /// it will be returned instead of creating a new instance.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param in_size - [Optional] The size of the plane.\n        /// @param in_textureRepeat - [Optional] The number of times a texture is\n        /// repeated on each face of the model in each axis. Defaults to [1, 1]\n        /// @param in_flipNormals -[Optional] Whether or not to flip the box inside out.\n        /// This is useful for creating rooms. Defaults to false.\n        ///\n        /// @return The plane model.\n        //------------------------------------------------------------------------------\n        ModelCSPtr CreateBox(const Vector3& in_size, const Vector2& in_textureRepeat = Vector2::k_one, bool in_flipNormals = false) const;\n        \n    private:\n        friend class Application;\n        //------------------------------------------------------------------------------\n        /// A factory method for creating new instances of the system.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @return The new instance.\n        //------------------------------------------------------------------------------\n        static PrimitiveModelFactoryUPtr Create();\n        //------------------------------------------------------------------------------\n        /// Default constructor. Declared private to ensure the system is created\n        /// through State::CreateSystem<>().\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------------------------------------\n        PrimitiveModelFactory() = default;\n    };\n}\n\n#endif"
  },
  {
    "path": "Source/ChilliSource/Rendering/Model/RenderDynamicMesh.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Model/RenderDynamicMesh.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    RenderDynamicMesh::RenderDynamicMesh(PolygonType polygonType, const VertexFormat& vertexFormat, IndexFormat indexFormat, u32 numVertices, u32 numIndices, const Sphere& boundingSphere,\n                      UniquePtr<u8[]> vertexData, u32 vertexDataSize, UniquePtr<u8[]> indexData, u32 indexDataSize) noexcept\n    : m_polygonType(polygonType), m_vertexFormat(vertexFormat), m_indexFormat(indexFormat), m_numVertices(numVertices), m_numIndices(numIndices), m_boundingSphere(boundingSphere),\n      m_vertexData(std::move(vertexData)), m_vertexDataSize(vertexDataSize), m_indexData(std::move(indexData)), m_indexDataSize(indexDataSize)\n    {\n        CS_ASSERT(vertexDataSize <= k_maxVertexDataSize, \"Vertex data too large.\");\n        CS_ASSERT(indexDataSize <= k_maxIndexDataSize, \"Index data too large.\");\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Model/RenderDynamicMesh.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_MODEL_RENDERDYNAMICMESH_H_\n#define _CHILLISOURCE_RENDERING_MODEL_RENDERDYNAMICMESH_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Base/ByteBuffer.h>\n#include <ChilliSource/Core/Math/Geometry/Shapes.h>\n#include <ChilliSource/Core/Memory/UniquePtr.h>\n#include <ChilliSource/Core/Memory/SharedPtr.h>\n#include <ChilliSource/Rendering/Model/VertexFormat.h>\n\nnamespace ChilliSource\n{\n    /// A container for information which the renderer needs pertaining to a single dynamic\n    /// mesh. This data is stored here, rather than in graphics memory, due to it's temporary\n    /// nature.\n    ///\n    /// This is immutable and therefore thread-safe.\n    ///\n    class RenderDynamicMesh final\n    {\n    public:\n        CS_DECLARE_NOCOPY(RenderDynamicMesh);\n        \n        static constexpr u32 k_maxVertexDataSize = 512 * 1024;\n        static constexpr u32 k_maxIndexDataSize = 32 * 1024;\n        \n        /// Creates a new instance with the given mesh description data.\n        ///\n        /// @param polygonType\n        ///     The type of polygon the mesh uses.\n        /// @param vertexFormat\n        ///     The vertex format.\n        /// @param indexFormat\n        ///     The type of index.\n        /// @param numVertices\n        ///     The number of vertices in the mesh. The maximum number is determined by the type of index.\n        /// @param numIndices\n        ///     The number of indices in the mesh.\n        /// @param boundingSphere\n        ///     A local space sphere enclosing the mesh.\n        /// @param vertexData\n        ///     The vertex data. This must have been allocated from an IAllocator.\n        /// @param vertexDataSize\n        ///     The size of the vertex data in bytes.\n        /// @param indexData\n        ///     The index data. This must have been allocated from an IAllocator.\n        /// @param indexDataSize\n        ///     The size of the index data in bytes.\n        ///\n        RenderDynamicMesh(PolygonType polygonType, const VertexFormat& vertexFormat, IndexFormat indexFormat, u32 numVertices, u32 numIndices, const Sphere& boundingSphere,\n                          UniquePtr<u8[]> vertexData, u32 vertexDataSize, UniquePtr<u8[]> indexData, u32 indexDataSize) noexcept;\n        \n        /// @return The type of polygon the mesh uses.\n        ///\n        PolygonType GetPolygonType() const noexcept { return m_polygonType; }\n        \n        /// @return The vertex format.\n        ///\n        const VertexFormat& GetVertexFormat() const noexcept { return m_vertexFormat; }\n        \n        /// @return The type of index.\n        ///\n        IndexFormat GetIndexFormat() const noexcept { return m_indexFormat; }\n        \n        /// @return The number of vertices in the mesh. The maximum number is determined by the type of index.\n        ///\n        u32 GetNumVertices() const noexcept { return m_numVertices; }\n        \n        /// @return The number of indices in the mesh.\n        ///\n        u32 GetNumIndices() const noexcept { return m_numIndices; }\n        \n        /// @return A local space sphere enclosing the mesh.\n        ///\n        const Sphere& GetBoundingSphere() const noexcept { return m_boundingSphere; }\n        \n        /// @return The vertex data buffer.\n        ///\n        const u8* GetVertexData() const noexcept { return m_vertexData.get(); }\n        \n        /// @return The size of the vertex data in bytes.\n        ///\n        u32 GetVertexDataSize() const noexcept { return m_vertexDataSize; }\n        \n        /// @return The index data buffer.\n        ///\n        const u8* GetIndexData() const noexcept { return m_indexData.get(); }\n        \n        /// @return The size of the index data in bytes.\n        ///\n        u32 GetIndexDataSize() const noexcept { return m_indexDataSize; }\n        \n    private:\n        friend class RenderMeshManager;\n        \n        PolygonType m_polygonType;\n        VertexFormat m_vertexFormat;\n        IndexFormat m_indexFormat;\n        u32 m_numVertices;\n        u32 m_numIndices;\n        Sphere m_boundingSphere;\n        UniquePtr<u8[]> m_vertexData;\n        u32 m_vertexDataSize;\n        UniquePtr<u8[]> m_indexData;\n        u32 m_indexDataSize;\n    };\n    \n    using RenderDynamicMeshAUPtr = UniquePtr<RenderDynamicMesh>;\n    using RenderDynamicMeshASPtr = SharedPtr<RenderDynamicMesh>;\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Model/RenderMesh.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Model/RenderMesh.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    RenderMesh::RenderMesh(PolygonType polygonType, const VertexFormat& vertexFormat, IndexFormat indexFormat, u32 numVertices, u32 numIndices, const Sphere& boundingSphere,\n                           bool shouldBackupData, std::vector<Matrix4> inverseBindPoseMatrices) noexcept\n        : m_polygonType(polygonType), m_vertexFormat(vertexFormat), m_indexFormat(indexFormat), m_numVertices(numVertices), m_numIndices(numIndices), m_boundingSphere(boundingSphere),\n          m_shouldBackupData(shouldBackupData), m_inverseBindPoseMatrices(std::move(inverseBindPoseMatrices))\n    {\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Model/RenderMesh.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_MODEL_RENDERMESH_H_\n#define _CHILLISOURCE_RENDERING_MODEL_RENDERMESH_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Math/Geometry/Shapes.h>\n#include <ChilliSource/Rendering/Model/VertexFormat.h>\n\nnamespace ChilliSource\n{\n    /// A standard-layout container for information which the renderer needs pertaining to a\n    /// single mesh. This doesn't store render data, but acts as a handle which the underlying\n    /// render system can use to reference it.\n    ///\n    /// This is immutable and therefore thread-safe, aside from the extra data pointer\n    /// which should only be accessed on the render thread.\n    ///\n    class RenderMesh final\n    {\n    public:\n        CS_DECLARE_NOCOPY(RenderMesh);\n        \n        /// Creates a new instance with the given mesh description data.\n        ///\n        /// SHOULD ONLY BE CREATED VIA RenderMeshManager\n        ///\n        /// @param polygonType\n        ///     The type of polygon the mesh uses.\n        /// @param vertexFormat\n        ///     The vertex format.\n        /// @param indexFormat\n        ///     The type of index.\n        /// @param numVertices\n        ///     The number of vertices in the mesh. The maximum number is determined by the type of index.\n        /// @param numIndices\n        ///     The number of indices in the mesh.\n        /// @param boundingSphere\n        ///     A local space sphere enclosing the mesh.\n        /// @param shouldBackupData\n        ///     If the mesh data should be backed up in main memory for restoring it later.\n        /// @param inverseBindPoseMatrices\n        ///     (Optional) The inverse bind pose matices for this mesh. Only applies to animated models.\n        ///     Should be moved.\n        ///\n        RenderMesh(PolygonType polygonType, const VertexFormat& vertexFormat, IndexFormat indexFormat, u32 numVertices, u32 numIndices, const Sphere& boundingSphere,\n                   bool shouldBackupData, std::vector<Matrix4> inverseBindPoseMatrices = std::vector<Matrix4>()) noexcept;\n        \n        /// @return The type of polygon the mesh uses.\n        ///\n        PolygonType GetPolygonType() const noexcept { return m_polygonType; }\n        \n        /// @return The vertex format.\n        ///\n        const VertexFormat& GetVertexFormat() const noexcept { return m_vertexFormat; }\n        \n        /// @return The type of index.\n        ///\n        IndexFormat GetIndexFormat() const noexcept { return m_indexFormat; }\n        \n        /// @return The number of vertices in the mesh. The maximum number is determined by the type of index.\n        ///\n        u32 GetNumVertices() const noexcept { return m_numVertices; }\n        \n        /// @return The number of indices in the mesh.\n        ///\n        u32 GetNumIndices() const noexcept { return m_numIndices; }\n        \n        /// @return A local space sphere enclosing the mesh.\n        ///\n        const Sphere& GetBoundingSphere() const noexcept { return m_boundingSphere; }\n\n        /// @return If the mesh should backup its data.\n        ///\n        bool ShouldBackupData() const noexcept { return m_shouldBackupData; }\n        \n        /// @return The inverse bind pose matrices for this mesh. Only applies to animated meshes.\n        ///\n        const std::vector<Matrix4>& GetInverseBindPoseMatrices() const noexcept { return m_inverseBindPoseMatrices; }\n\n        /// This is not thread safe and should only be called from the render thread.\n        ///\n        /// @return A pointer to render system specific additional information.\n        ///\n        void* GetExtraData() const noexcept { return m_extraData; }\n        \n        /// This is not thread safe and should only be called from the render thread.\n        ///\n        /// @param extraData\n        ///     A pointer to render system specific additional information.\n        ///\n        void SetExtraData(void* extraData) noexcept { m_extraData = extraData; }\n        \n    private:\n        \n        PolygonType m_polygonType;\n        VertexFormat m_vertexFormat;\n        IndexFormat m_indexFormat;\n        u32 m_numVertices;\n        u32 m_numIndices;\n        Sphere m_boundingSphere;\n        bool m_shouldBackupData;\n        std::vector<Matrix4> m_inverseBindPoseMatrices;\n        \n        void* m_extraData = nullptr;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Model/RenderMeshBatch.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Model/RenderMeshBatch.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    RenderMeshBatch::Mesh::Mesh(const Matrix4& worldMatrix, u32 numVertices, u32 numIndices, const u8* vertexData, u32 vertexDataSize, const u8* indexData, u32 indexDataSize) noexcept\n        : m_worldMatrix(worldMatrix), m_numVertices(numVertices), m_numIndices(numIndices), m_vertexData(vertexData), m_vertexDataSize(vertexDataSize), m_indexData(indexData), m_indexDataSize(indexDataSize)\n    {\n        CS_ASSERT(vertexData, \"Must supply vertex data.\");\n        CS_ASSERT(vertexDataSize > 0, \"Vertex data must have a greater than zero size.\");\n        CS_ASSERT(m_numVertices > 0, \"Must have some vertices.\");\n        CS_ASSERT((!m_indexData && m_indexDataSize == 0 && m_numIndices == 0) || (m_indexData && m_indexDataSize > 0 && m_numIndices > 0),\n                  \"If there is index data then the size must be greater than zero, other wise in must be zero.\");\n    }\n\n    //------------------------------------------------------------------------------\n    RenderMeshBatch::RenderMeshBatch(PolygonType polygonType, const VertexFormat& vertexFormat, IndexFormat indexFormat, std::vector<Mesh> meshes) noexcept\n        : m_polygonType(polygonType), m_vertexFormat(vertexFormat), m_indexFormat(indexFormat), m_meshes(std::move(meshes))\n    {\n        CS_ASSERT(m_meshes.size() > 0, \"Cannot create a batch with zero size.\");\n        \n        for (const auto& mesh : m_meshes)\n        {\n            CS_ASSERT((mesh.GetIndexDataSize() > 0) == (m_meshes[0].GetIndexDataSize() > 0), \"Either all meshes must have indices, or all meshes must have no indices.\");\n            \n            m_numVertices += mesh.GetNumVertices();\n            m_numIndices += mesh.GetNumIndices();\n            m_vertexDataSize += mesh.GetVertexDataSize();\n            m_indexDataSize += mesh.GetIndexDataSize();\n        }\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Model/RenderMeshBatch.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_MODEL_RENDERMESHBATCH_H_\n#define _CHILLISOURCE_RENDERING_MODEL_RENDERMESHBATCH_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Math/Matrix4.h>\n#include <ChilliSource/Rendering/Model/IndexFormat.h>\n#include <ChilliSource/Rendering/Model/PolygonType.h>\n#include <ChilliSource/Rendering/Model/VertexFormat.h>\n\n#include <vector>\n\nnamespace ChilliSource\n{\n    /// Contains the description of a series of meshes which can be combined in a single draw\n    /// call. All meshes must have the same polygon type, vertex and index format, and if one\n    /// mesh contains indices, then they all must.\n    ///\n    /// A render mesh batch doesn't directly contain any mesh data, merely holding handles to\n    /// the data. This means that the described data must outlive the mesh batch.\n    ///\n    /// This is immutable and therefore thread-safe.\n    ///\n    class RenderMeshBatch final\n    {\n    public:\n        /// A container for information on a single mesh within the mesh batch.\n        ///\n        /// This is immutable and therefore thread-safe.\n        ///\n        class Mesh final\n        {\n        public:\n            /// Creates a new mesh with the given mesh data.\n            ///\n            /// @param worldMatrix\n            ///     The world matrix of the mesh.\n            /// @param numVertices\n            ///     The number of vertices in the mesh.\n            /// @param numIndices\n            ///     The number of indicews in the mesh.\n            /// @param vertexData\n            ///     The vertex data of the mesh.\n            /// @param vertexDataSize\n            ///     The size of the vertex data in bytes.\n            /// @param indexData\n            ///     The index data of the mesh. May be null if the mesh has no indices.\n            /// @param indexDataSize\n            ///     The size of the index data in bytes. May be zero if the mesh has no indices.\n            ///\n            Mesh(const Matrix4& worldMatrix, u32 numVertices, u32 numIndices, const u8* vertexData, u32 vertexDataSize, const u8* indexData, u32 indexDataSize) noexcept;\n            \n            /// @return The world matrix of the mesh.\n            ///\n            const Matrix4& GetWorldMatrix() const noexcept { return m_worldMatrix; }\n            \n            /// @return The number of vertices.\n            ///\n            u32 GetNumVertices() const noexcept { return m_numVertices; }\n            \n            /// @return The number of indices.\n            ///\n            u32 GetNumIndices() const noexcept { return m_numIndices; }\n            \n            /// @return The vertex data of the mesh.\n            ///\n            const u8* GetVertexData() const noexcept { return m_vertexData; }\n            \n            /// @return The size of the vertex data in bytes.\n            ///\n            u32 GetVertexDataSize() const noexcept { return m_vertexDataSize; }\n            \n            /// @return The index data of the mesh. May be null if the mesh has no indices.\n            ///\n            const u8* GetIndexData() const noexcept { return m_indexData; }\n            \n            /// @return The size of the index data in bytes. May be zero if the mesh has no indices.\n            ///\n            u32 GetIndexDataSize() const noexcept { return m_indexDataSize; }\n            \n        private:\n            Matrix4 m_worldMatrix;\n            u32 m_numVertices;\n            u32 m_numIndices;\n            const u8* m_vertexData;\n            u32 m_vertexDataSize;\n            const u8* m_indexData;\n            u32 m_indexDataSize;\n        };\n        \n        /// Creates a new batch with the given mesh type info and meshes to batch.\n        ///\n        /// @param polygonType\n        ///     The polygonType of the batch.\n        /// @param vertexFormat\n        ////    The vertex format of the batch.\n        /// @param indexFormat\n        ///     The index format of the batch.\n        /// @param meshes\n        ///     The meshes included in the batch. Should be moved.\n        ///\n        RenderMeshBatch(PolygonType polygonType, const VertexFormat& vertexFormat, IndexFormat indexFormat, std::vector<Mesh> meshes) noexcept;\n        \n        /// @return The polygonType of the batch.\n        ///\n        PolygonType GetPolygonType() const noexcept { return m_polygonType; }\n        \n        /// @return The vertex format of the batch.\n        ///\n        const VertexFormat& GetVertexFormat() const noexcept { return m_vertexFormat; }\n        \n        /// @return The index format of the batch.\n        ///\n        IndexFormat GetIndexFormat() const noexcept { return m_indexFormat; }\n        \n        /// @return The total number of vertices in the batch.\n        ///\n        u32 GetNumVertices() const noexcept { return m_numVertices; }\n        \n        /// @return The total number of indices in the batch.\n        ///\n        u32 GetNumIndices() const noexcept { return m_numIndices; }\n        \n        /// @return The total size of the vertex data in the batch.\n        ///\n        u32 GetVertexDataSize() const noexcept { return m_vertexDataSize; }\n        \n        /// @return The total size of the index data in the batch.\n        ///\n        u32 GetIndexDataSize() const noexcept { return m_indexDataSize; }\n        \n        /// @return The meshes included in the batch.\n        ///\n        const std::vector<Mesh>& GetMeshes() const noexcept { return m_meshes; }\n        \n    private:\n        PolygonType m_polygonType;\n        VertexFormat m_vertexFormat;\n        IndexFormat m_indexFormat;\n        u32 m_numVertices = 0;\n        u32 m_numIndices = 0;\n        u32 m_vertexDataSize = 0;\n        u32 m_indexDataSize = 0;\n        std::vector<Mesh> m_meshes;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Model/RenderMeshManager.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Model/RenderMeshManager.h>\n\n#include <ChilliSource/Rendering/Base/RenderSnapshot.h>\n#include <ChilliSource/Rendering/Base/TargetType.h>\n\n#include <mutex>\n\nnamespace ChilliSource\n{\n    namespace\n    {\n        constexpr u32 k_meshPoolSize = 100;\n    }\n    \n    CS_DEFINE_NAMEDTYPE(RenderMeshManager);\n\n    //------------------------------------------------------------------------------\n    RenderMeshManagerUPtr RenderMeshManager::Create() noexcept\n    {\n        return RenderMeshManagerUPtr(new RenderMeshManager());\n    }\n    \n    //------------------------------------------------------------------------------\n    RenderMeshManager::RenderMeshManager()\n    : m_renderMeshPool(k_meshPoolSize, ObjectPoolAllocatorLimitPolicy::k_expand)\n    {\n        \n    }\n\n    //------------------------------------------------------------------------------\n    bool RenderMeshManager::IsA(InterfaceIDType interfaceId) const noexcept\n    {\n        return (RenderMeshManager::InterfaceID == interfaceId);\n    }\n\n    //------------------------------------------------------------------------------\n    UniquePtr<RenderMesh> RenderMeshManager::CreateRenderMesh(PolygonType polygonType, const VertexFormat& vertexFormat, IndexFormat indexFormat, u32 numVertices, u32 numIndices, const Sphere& boundingSphere,\n                                                          std::unique_ptr<const u8[]> vertexData, u32 vertexDataSize, std::unique_ptr<const u8[]> indexData, u32 indexDataSize, bool shouldBackupData,\n                                                          std::vector<Matrix4> inverseBindPoseMatrices) noexcept\n    {\n        UniquePtr<RenderMesh> renderMesh = MakeUnique<RenderMesh>(m_renderMeshPool, polygonType, vertexFormat, indexFormat, numVertices, numIndices, boundingSphere, shouldBackupData, std::move(inverseBindPoseMatrices));\n\n        auto rawRenderMesh = renderMesh.get();\n        \n        PendingLoadCommand loadCommand;\n        loadCommand.m_renderMesh = rawRenderMesh;\n        loadCommand.m_vertexData = std::move(vertexData);\n        loadCommand.m_vertexDataSize = vertexDataSize;\n        loadCommand.m_indexData = std::move(indexData);\n        loadCommand.m_indexDataSize = indexDataSize;\n        \n        std::unique_lock<std::mutex> lock(m_mutex);\n        m_pendingLoadCommands.push_back(std::move(loadCommand));\n        \n        return renderMesh;\n    }\n\n    //------------------------------------------------------------------------------\n    void RenderMeshManager::DestroyRenderMesh(UniquePtr<RenderMesh> renderMesh) noexcept\n    {\n        std::unique_lock<std::mutex> lock(m_mutex);\n        m_pendingUnloadCommands.push_back(std::move(renderMesh));\n    }\n\n    //------------------------------------------------------------------------------\n    void RenderMeshManager::OnRenderSnapshot(TargetType targetType, RenderSnapshot& renderSnapshot, IAllocator* frameAllocator) noexcept\n    {\n        if(targetType == TargetType::k_main)\n        {\n            auto preRenderCommandList = renderSnapshot.GetPreRenderCommandList();\n            auto postRenderCommandList = renderSnapshot.GetPostRenderCommandList();\n            \n            std::unique_lock<std::mutex> lock(m_mutex);\n            \n            for (auto& loadCommand : m_pendingLoadCommands)\n            {\n                preRenderCommandList->AddLoadMeshCommand(loadCommand.m_renderMesh, std::move(loadCommand.m_vertexData), loadCommand.m_vertexDataSize, std::move(loadCommand.m_indexData), loadCommand.m_indexDataSize);\n            }\n            m_pendingLoadCommands.clear();\n            \n            for (auto& unloadCommand : m_pendingUnloadCommands)\n            {\n                postRenderCommandList->AddUnloadMeshCommand(std::move(unloadCommand));\n            }\n            m_pendingUnloadCommands.clear();\n        }\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Model/RenderMeshManager.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_SHADER_RENDERMESHMANAGER_H_\n#define _CHILLISOURCE_RENDERING_SHADER_RENDERMESHMANAGER_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Memory/ObjectPoolAllocator.h>\n#include <ChilliSource/Core/Memory/UniquePtr.h>\n#include <ChilliSource/Core/System/AppSystem.h>\n#include <ChilliSource/Rendering/Model/RenderMesh.h>\n\n#include <mutex>\n\nnamespace ChilliSource\n{\n    /// Manages the lifecycle of all RenderMesh instances.\n    ///\n    /// On creation of a RenderMesh a LoadMeshRenderCommand is queued for the next render\n    /// snapshot phase, ensuring that related mesh data is processed before the RenderMesh\n    /// is used.\n    ///\n    /// On deletion an UnloadMeshRenderCommand is queued and given ownership of the\n    /// RenderMesh. The RenderMesh is then deleted once the command has been processed.\n    ///\n    /// This is thread-safe and can be called from any thread. If it is called on a background\n    /// thread, care needs to be taken to ensure any created RenderMeshes are not used prior\n    /// to being loaded.\n    ///\n    class RenderMeshManager final : public AppSystem\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(RenderMeshManager);\n        \n        /// Allows querying of whether or not this system implements the interface described by the\n        /// given interface Id. Typically this is not called directly as the templated equivalent\n        /// IsA<Interface>() is preferred.\n        ///\n        /// @param interfaceId\n        ///     The Id of the interface.\n        ///\n        /// @return Whether or not the interface is implemented.\n        ///\n        bool IsA(InterfaceIDType interfaceId) const noexcept override;\n        \n        /// Creates a new RenderMesh and queues a LoadMeshRenderCommand for the next Render Snapshot\n        /// stage in the render pipeline.\n        ///\n        /// @param polygonType\n        ///     The type of polygon the mesh uses.\n        /// @param vertexFormat\n        ///     The vertex format.\n        /// @param indexFormat\n        ///     The type of index.\n        /// @param numVertices\n        ///     The number of vertices in the mesh. The maximum number is determined by the type of index.\n        /// @param numIndices\n        ///     The number of indices in the mesh.\n        /// @param boundingSphere\n        ///     A local space sphere enclosing the mesh.\n        /// @param vertexData\n        ///     The vertex data buffer.\n        /// @param vertexDataSize\n        ///     The size of the vertex data buffer.\n        /// @param indexData\n        ///     The index data buffer.\n        /// @param indexDataSize\n        ///     The size of the index data buffer.\n        /// @param shouldBackupData\n        ///     If the mesh data should be backed up in main memory for restoring it later.\n        /// @param inverseBindPoseMatrices\n        ///     (Optional) The inverse bind pose matices for this mesh. Only applies to animated models.\n        ///     Should be moved.\n        ///\n        /// @return The RenderMesh instance.\n        ///\n        UniquePtr<RenderMesh> CreateRenderMesh(PolygonType polygonType, const VertexFormat& vertexFormat, IndexFormat indexFormat, u32 numVertices, u32 numIndices, const Sphere& boundingSphere,\n                                           std::unique_ptr<const u8[]> vertexData, u32 vertexDataSize, std::unique_ptr<const u8[]> indexData, u32 indexDataSize, bool shouldBackupData,\n                                           std::vector<Matrix4> inverseBindPoseMatrices = std::vector<Matrix4>()) noexcept;\n        \n        /// Removes the RenderMesh from the manager and queues an UnloadMeshRenderCommand for the\n        /// next Render Snapshot stage in the render pipeline. The render command is given ownership\n        /// of the RenderMesh, ensuring it won't be destroyed until it is no longer used.\n        ///\n        /// @param renderMesh\n        ///     The RenderMesh which should be destroyed.\n        ///\n        void DestroyRenderMesh(UniquePtr<RenderMesh> renderMesh) noexcept;\n\n        \n    private:\n        friend class Application;\n        \n        /// A container for information relating to pending LoadMeshRenderCommands, such as the\n        /// index and vertex buffers and the related RenderMesh.\n        ///\n        struct PendingLoadCommand final\n        {\n            RenderMesh* m_renderMesh = nullptr;\n            std::unique_ptr<const u8[]> m_vertexData;\n            u32 m_vertexDataSize = 0;\n            std::unique_ptr<const u8[]> m_indexData;\n            u32 m_indexDataSize = 0;\n        };\n        \n        /// A factory method for creating new instances of the system. This must be called by\n        /// Application.\n        ///\n        /// @return The new instance of the system.\n        ///\n        static RenderMeshManagerUPtr Create() noexcept;\n        \n        RenderMeshManager();\n        \n        /// Called during the Render Snapshot stage of the render pipeline. All pending load and\n        /// unload commands are added to the render snapshot.\n        ///\n        /// @param targetType\n        ///     Whether the snapshot is for the main screen or an offscreen render target\n        /// @param renderSnapshot\n        ///     The render shapshot for storing snapshotted data.\n        /// @param frameAllocator\n        ///     Allocate memory for this render frame from here\n        ///\n        void OnRenderSnapshot(TargetType targetType, RenderSnapshot& renderSnapshot, IAllocator* frameAllocator) noexcept override;\n        \n        std::mutex m_mutex;\n        ObjectPoolAllocator<RenderMesh> m_renderMeshPool;\n        std::vector<PendingLoadCommand> m_pendingLoadCommands;\n        std::vector<UniquePtr<RenderMesh>> m_pendingUnloadCommands;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Model/RenderSkinnedAnimation.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Model/RenderSkinnedAnimation.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    RenderSkinnedAnimation::RenderSkinnedAnimation(UniquePtr<Vector4[]> jointData, u32 jointDataSize) noexcept\n        : m_jointData(std::move(jointData)), m_jointDataSize(jointDataSize)\n    {\n        CS_ASSERT(m_jointData, \"Joint data cannot be null.\");\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Model/RenderSkinnedAnimation.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_MODEL_RENDERSKINNEDANIMATION_H_\n#define _CHILLISOURCE_RENDERING_MODEL_RENDERSKINNEDANIMATION_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Math/Vector4.h>\n#include <ChilliSource/Core/Memory/SharedPtr.h>\n#include <ChilliSource/Core/Memory/UniquePtr.h>\n#include <ChilliSource/Rendering/Model/VertexFormat.h>\n\nnamespace ChilliSource\n{\n    /// A standard-layout container for information which the renderer needs pertaining to a\n    /// single skinned animation.\n    ///\n    /// This is immutable and therefore thread-safe.\n    ///\n    class RenderSkinnedAnimation final\n    {\n    public:\n        CS_DECLARE_NOCOPY(RenderSkinnedAnimation);\n        \n        /// Creates a new instance with the given skinned animation joint data.\n        ///\n        /// @param jointData\n        ///     The combined inverse bind pose and joint frame data matrixes. The matrices are\n        ///     broken up into a collection of Vector4, so the final column, which is always\n        ///     [0, 0, 0, 1] can be omitted.\n        /// @param jointDataSize\n        ///     The number of Vector4's that comprise the joint data.\n        ///\n        RenderSkinnedAnimation(UniquePtr<Vector4[]> jointData, u32 jointDataSize) noexcept;\n        \n        /// @return The combined inverse bind pose and joint frame data matrixes. The matrices are\n        ///     broken up into a collection of Vector4, so the final column, which is always\n        ///     [0, 0, 0, 1] can be omitted.\n        ///\n        const Vector4* GetJointData() const noexcept { return m_jointData.get(); }\n        \n        /// @return The number of Vector4's that comprise the joint data.\n        ///\n        u32 GetJointDataSize() const noexcept { return m_jointDataSize; }\n        \n    private:\n        friend class RenderMeshManager;\n\n        UniquePtr<Vector4[]> m_jointData;\n        u32 m_jointDataSize;\n    };\n    \n    using RenderSkinnedAnimationAUPtr = UniquePtr<RenderSkinnedAnimation>;\n    using RenderSkinnedAnimationASPtr = SharedPtr<RenderSkinnedAnimation>;\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Model/Skeleton.cpp",
    "content": "//\n//  Skeleton.cpp\n//  ChilliSource\n//  Created by Ian Copland on 13/10/2011.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2011 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Model/Skeleton.h>\n\n#include <ChilliSource/Rendering/Model/SkeletonDesc.h>\n\n#include <vector>\n\nnamespace ChilliSource\n{\n    //-------------------------------------------------------------------------\n    //-------------------------------------------------------------------------\n    Skeleton::Skeleton(const SkeletonDesc& in_desc) noexcept\n    {\n        mapNodes.reserve(in_desc.GetNodeNames().size());\n        \n        for(u32 i=0; i<in_desc.GetNodeNames().size(); ++i)\n        {\n            SkeletonNode* node(new SkeletonNode());\n            node->mstrName = in_desc.GetNodeNames()[i];\n            node->mdwParentIndex = in_desc.GetParentNodeIndices()[i];\n            mapNodes.push_back(SkeletonNodeCUPtr(node));\n        }\n        \n        madwJoints = in_desc.GetJointIndices();\n    }\n    //-------------------------------------------------------------------------\n    /// Get Node By Name\n    //-------------------------------------------------------------------------\n    const SkeletonNode* Skeleton::GetNodeByName(const std::string& instrName) const\n    {\n        for (auto it = mapNodes.begin(); it != mapNodes.end(); ++it)\n        {\n            if (instrName == (*it)->mstrName)\n                return it->get();\n        }\n        \n        return nullptr;\n    }\n    //-------------------------------------------------------------------------\n    /// Get Node Index By Name\n    //-------------------------------------------------------------------------\n    s32 Skeleton::GetNodeIndexByName(const std::string& instrName) const\n    {\n        s32 dwIndex = 0;\n        for (auto it = mapNodes.begin(); it != mapNodes.end(); ++it)\n        {\n            if (instrName == (*it)->mstrName)\n                return dwIndex;\n            dwIndex++;\n        }\n        return -1;\n    }\n    //-------------------------------------------------------------------------\n    /// Get Node By Index\n    //-------------------------------------------------------------------------\n    const SkeletonNode* Skeleton::GetNodeByIndex(u32 indwIndex) const\n    {\n        if (indwIndex < mapNodes.size())\n        {\n            return mapNodes[indwIndex].get();\n        }\n        \n        return nullptr;\n    }\n    //-------------------------------------------------------------------------\n    /// Get Num Nodes\n    //-------------------------------------------------------------------------\n    s32 Skeleton::GetNumNodes() const\n    {\n        return (s32)mapNodes.size();\n    }\n    //-------------------------------------------------------------------------\n    /// Get Num Joints\n    ///\n    /// returns the number of joints in the skeleton\n    ///\n    /// @return the number of joints.\n    //-------------------------------------------------------------------------\n    u32 Skeleton::GetNumJoints() const\n    {\n        return static_cast<u32>(madwJoints.size());\n    }\n    //-------------------------------------------------------------------------\n    /// Get Nodes\n    //-------------------------------------------------------------------------\n    const std::vector<SkeletonNodeCUPtr>& Skeleton::GetNodes() const\n    {\n        return mapNodes;\n    }\n    //-------------------------------------------------------------------------\n    /// Get Joint Indices\n    //-------------------------------------------------------------------------\n    const std::vector<s32>& Skeleton::GetJointIndices() const\n    {\n        return madwJoints;\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Model/Skeleton.h",
    "content": "//\n//  Skeleton.h\n//  ChilliSource\n//  Created by Ian Copland on 13/10/2011.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2011 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_SKELETON_H_\n#define _CHILLISOURCE_RENDERING_SKELETON_H_\n\n#include <ChilliSource/ChilliSource.h>\n\n#include <vector>\n\nnamespace ChilliSource\n{\n    //=========================================================================\n    /// Skeleton Node\n    ///\n    /// a struct describing a single skeleton node.\n    //=========================================================================\n    struct SkeletonNode\n    {\n        std::string mstrName;\n        s32 mdwParentIndex;\n    };\n    //=========================================================================\n    /// Skeleton\n    ///\n    /// a simple class that describes a skeleton for skeletal animation.\n    //=========================================================================\n    class Skeleton\n    {\n    public:\n        Skeleton() = default;\n        //-------------------------------------------------------------------------\n        /// Construct the skeleton from the given descriptor.\n        ///\n        /// @author S Downie\n        ///\n        /// @param Skeleton descriptor\n        //-------------------------------------------------------------------------\n        Skeleton(const SkeletonDesc& in_desc) noexcept;\n        //-------------------------------------------------------------------------\n        /// Get Node By Name\n        ///\n        /// returns the node with the given name.\n        ///\n        /// @param the nodes name\n        /// @return a smart pointer to the node\n        //-------------------------------------------------------------------------\n        const SkeletonNode* GetNodeByName(const std::string& instrName) const;\n        //-------------------------------------------------------------------------\n        /// Get Node Index By Name\n        ///\n        /// returns the index of the node with the given name. This will return\n        /// -1 if no node with the given name could be found.\n        ///\n        /// @param the nodes name\n        /// @return The nodes index\n        //-------------------------------------------------------------------------\n        s32 GetNodeIndexByName(const std::string& instrName) const;\n        //-------------------------------------------------------------------------\n        /// Get Node By Index\n        ///\n        /// returns the node at the given index.\n        ///\n        /// @param the index.\n        /// @param a smart pointer to the node.\n        //-------------------------------------------------------------------------\n        const SkeletonNode* GetNodeByIndex(u32 indwIndex) const;\n        //-------------------------------------------------------------------------\n        /// Get Num Nodes\n        ///\n        /// returns the number of nodes in the skeleton\n        ///\n        /// @return the number of nodes\n        //-------------------------------------------------------------------------\n        s32 GetNumNodes() const;\n        //-------------------------------------------------------------------------\n        /// Get Num Joints\n        ///\n        /// returns the number of joints in the skeleton\n        ///\n        /// @return the number of joints.\n        //-------------------------------------------------------------------------\n        u32 GetNumJoints() const;\n        //-------------------------------------------------------------------------\n        /// Get Nodes\n        ///\n        /// returns the array of nodes\n        ///\n        /// @return the dynamic array of nodes\n        //-------------------------------------------------------------------------\n        const std::vector<SkeletonNodeCUPtr>& GetNodes() const;\n        //-------------------------------------------------------------------------\n        /// Get Joint Indices\n        ///\n        /// @return the array of joint indices\n        //-------------------------------------------------------------------------\n        const std::vector<s32>& GetJointIndices() const;\n        \n    private:\n        \n        std::vector<SkeletonNodeCUPtr> mapNodes;\n        std::vector<s32> madwJoints;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Model/SkeletonDesc.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Model/SkeletonDesc.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    SkeletonDesc::SkeletonDesc(const std::vector<std::string>& nodeNames, const std::vector<s32>& parentNodeIndices, const std::vector<s32>& jointIndices) noexcept\n        : m_nodeNames(nodeNames), m_parentNodeIndices(parentNodeIndices), m_jointIndices(jointIndices)\n    {\n        CS_ASSERT(m_nodeNames.size() == m_parentNodeIndices.size(), \"Provided skeleton data is invalid.\");\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Model/SkeletonDesc.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_MODEL_SKELETONDESC_H_\n#define _CHILLISOURCE_RENDERING_MODEL_SKELETONDESC_H_\n\n#include <ChilliSource/ChilliSource.h>\n\n#include <vector>\n\nnamespace ChilliSource\n{\n    /// A description of a skeleton.\n    ///\n    /// This is immutable and therefore thread safe.\n    ///\n    class SkeletonDesc final\n    {\n    public:\n        SkeletonDesc() = default;\n        \n        /// Instantiates a new skeleton description with the given node data. Each of the\n        /// lists must be identical in length.\n        ///\n        /// @param nodeNames\n        ///     A list containing the names of each node.\n        /// @param parentNodeIndices\n        ///     A list containing the parent index of each node.\n        /// @param jointIndices\n        ///     A list containing the joint indices.\n        ///\n        SkeletonDesc(const std::vector<std::string>& nodeNames, const std::vector<s32>& parentNodeIndices, const std::vector<s32>& jointIndices) noexcept;\n        \n        /// @return A list containing the names of each node.\n        ///\n        const std::vector<std::string>& GetNodeNames() const noexcept { return m_nodeNames; }\n        \n        /// @return A list containing the parent index of each node.\n        ///\n        const std::vector<s32>& GetParentNodeIndices() const noexcept { return m_parentNodeIndices; }\n        \n        /// @return A list containing the joint indices.\n        ///\n        const std::vector<s32>& GetJointIndices() const noexcept { return m_jointIndices; }\n        \n    private:\n        std::vector<std::string> m_nodeNames;\n        std::vector<s32> m_parentNodeIndices;\n        std::vector<s32> m_jointIndices;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Model/SkinnedAnimation.cpp",
    "content": "//\n//  SkinnedAnimation.cpp\n//  ChilliSource\n//  Created by Ian Copland on 17/10/2011.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2011 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Model/SkinnedAnimation.h>\n\nnamespace ChilliSource\n{\n    CS_DEFINE_NAMEDTYPE(SkinnedAnimation);\n    //---------------------------------------------------------------------\n    //---------------------------------------------------------------------\n    SkinnedAnimationUPtr SkinnedAnimation::Create()\n    {\n        return SkinnedAnimationUPtr(new SkinnedAnimation());\n    }\n    //--------------------------------------------------------------------\n    //--------------------------------------------------------------------\n    SkinnedAnimation::SkinnedAnimation()\n    : m_frameTime(0.0f)\n    {\n    }\n    //---------------------------------------------------------------------\n    //---------------------------------------------------------------------\n    bool SkinnedAnimation::IsA(InterfaceIDType in_interfaceId) const\n    {\n        return in_interfaceId == SkinnedAnimation::InterfaceID;\n    }\n    //---------------------------------------------------------------------\n    //---------------------------------------------------------------------\n    const SkinnedAnimation::Frame* SkinnedAnimation::GetFrameAtIndex(u32 in_index) const\n    {\n        CS_ASSERT(in_index < m_frames.size(), \"Skinned animation frame out of bounds\");\n        return m_frames[in_index].get();\n    }\n    //---------------------------------------------------------------------\n    //---------------------------------------------------------------------\n    f32 SkinnedAnimation::GetFrameTime() const\n    {\n        return m_frameTime;\n    }\n    //---------------------------------------------------------------------\n    //---------------------------------------------------------------------\n    u32 SkinnedAnimation::GetNumFrames() const\n    {\n        return static_cast<u32>(m_frames.size());\n    }\n    //---------------------------------------------------------------------\n    //---------------------------------------------------------------------\n    void SkinnedAnimation::AddFrame(SkinnedAnimation::FrameCUPtr in_frame)\n    {\n        m_frames.push_back(std::move(in_frame));\n    }\n    //---------------------------------------------------------------------\n    //---------------------------------------------------------------------\n    void SkinnedAnimation::SetFrameTime(f32 in_timeBetweenFrames)\n    {\n        m_frameTime = in_timeBetweenFrames;\n    }\n}\n\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Model/SkinnedAnimation.h",
    "content": "//\n//  SkinnedAnimation.h\n//  ChilliSource\n//  Created by Ian Copland on 17/10/2011.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2011 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_MODEL_SKINNEDANIMATION_H_\n#define _CHILLISOURCE_RENDERING_MODEL_SKINNEDANIMATION_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Math/Matrix4.h>\n#include <ChilliSource/Core/Math/Quaternion.h>\n#include <ChilliSource/Core/Math/Vector3.h>\n#include <ChilliSource/Core/Resource/Resource.h>\n\nnamespace ChilliSource\n{\n    //---------------------------------------------------------------------\n    /// A resource that holds data for a single skinned animation.\n    /// This largely consists of the transformations for each key frame.\n    ///\n    /// @author Ian Copland\n    //---------------------------------------------------------------------\n    class SkinnedAnimation final : public Resource\n    {\n    public:\n        \n        //---------------------------------------------------------------------\n        /// Contains all relevant data for a single frame of animation.\n        ///\n        /// @author Ian Copland\n        //---------------------------------------------------------------------\n        struct Frame\n        {\n            std::vector<Vector3> m_nodeTranslations;\n            std::vector<Quaternion> m_nodeOrientations;\n            std::vector<Vector3> m_nodeScales;\n        };\n        using FrameUPtr = std::unique_ptr<Frame>;\n        using FrameSPtr = std::shared_ptr<Frame>;\n        using FrameCUPtr = std::unique_ptr<const Frame>;\n        using FrameCSPtr = std::shared_ptr<const Frame>;\n        \n        CS_DECLARE_NAMEDTYPE(SkinnedAnimation);\n        \n        //---------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param Interface ID type\n        ///\n        /// @return Whether this object is of given type\n        //---------------------------------------------------------------------\n        bool IsA(InterfaceIDType in_interfaceId) const override;\n        //---------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param the index to the frame\n        /// @return the AnimationFramePtr at the given index\n        //---------------------------------------------------------------------\n        const SkinnedAnimation::Frame* GetFrameAtIndex(u32 in_index) const;\n        //---------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return the time between frames in seconds\n        //---------------------------------------------------------------------\n        f32 GetFrameTime() const;\n        //---------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return the number of frames in the animation.\n        //---------------------------------------------------------------------\n        u32 GetNumFrames() const;\n        //---------------------------------------------------------------------\n        /// Adds a new frame to the end of the animation.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The new frame which is no owned by the resource\n        //---------------------------------------------------------------------\n        void AddFrame(SkinnedAnimation::FrameCUPtr in_frame);\n        //---------------------------------------------------------------------\n        /// Sets the frame rate of the animation. Do not use this for changing\n        /// the speed of an animation. Instead changing the speed through\n        /// the animated component.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The time between frames in seconds\n        //---------------------------------------------------------------------\n        void SetFrameTime(f32 in_timeBetweenFrames);\n        \n    private:\n        \n        friend class ResourcePool;\n        //---------------------------------------------------------------------\n        /// Factory method for creating mesh resource instance. Only accessed\n        /// by the resource pool\n        ///\n        /// @author S Downie\n        ///\n        /// @return Ownership of new instance\n        //---------------------------------------------------------------------\n        static SkinnedAnimationUPtr Create();\n        //---------------------------------------------------------------------\n        /// Declared private so that this can only be created via the create\n        /// method\n        ///\n        /// @author Ian Copland\n        //---------------------------------------------------------------------\n        SkinnedAnimation();\n        \n    private:\n        \n        f32 m_frameTime;\n        std::vector<SkinnedAnimation::FrameCUPtr> m_frames;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Model/SkinnedAnimationGroup.cpp",
    "content": "//\n//  SkinnedAnimationGroup.cpp\n//  ChilliSource\n//  Created by Ian Copland on 08/06/2012.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2011 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Model/SkinnedAnimationGroup.h>\n#include <ChilliSource/Core/Math/Quaternion.h>\n#include <ChilliSource/Core/Math/Vector3.h>\n#include <ChilliSource/Core/Math/MathUtils.h>\n#include <ChilliSource/Rendering/Model/SkinnedAnimation.h>\n#include <ChilliSource/Rendering/Model/Skeleton.h>\n\nnamespace ChilliSource\n{\n    //-----------------------------------------------------------\n    /// Constructor\n    //-----------------------------------------------------------\n    SkinnedAnimationGroup::SkinnedAnimationGroup(const Skeleton& inpSkeleton)\n    : mpSkeleton(inpSkeleton), mbAnimationLengthDirty(true), mfAnimationLength(0.0f), mbPrepared(false)\n    {\n        for (s32 i = 0; i < mpSkeleton.GetNumNodes(); ++i)\n        {\n            mCurrentAnimationMatrices.push_back(Matrix4());\n        }\n    }\n    //----------------------------------------------------------\n    /// Attach Animation\n    //----------------------------------------------------------\n    void SkinnedAnimationGroup::AttachAnimation(const SkinnedAnimationCSPtr& inpAnimation, f32 infBlendlinePosition)\n    {\n        mbAnimationLengthDirty = true;\n        AnimationItemPtr pItem(new AnimationItem());\n        pItem->pSkinnedAnimation = inpAnimation;\n        pItem->fBlendlinePosition = infBlendlinePosition;\n        mAnimations.push_back(pItem);\n    }\n    //----------------------------------------------------------\n    /// Detatch Animation\n    //----------------------------------------------------------\n    void SkinnedAnimationGroup::DetatchAnimation(const SkinnedAnimationCSPtr& inpAnimation)\n    {\n        mbAnimationLengthDirty = true;\n        for (std::vector<AnimationItemPtr>::iterator it = mAnimations.begin(); it != mAnimations.end(); ++it)\n        {\n            if ((*it)->pSkinnedAnimation.get() == inpAnimation.get())\n            {\n                mAnimations.erase(it);\n                break;\n            }\n        }\n    }\n    //----------------------------------------------------------\n    /// Clear Animations\n    //----------------------------------------------------------\n    void SkinnedAnimationGroup::ClearAnimations()\n    {\n        mAnimations.clear();\n    }\n    //----------------------------------------------------------\n    /// Build Animation Data\n    //----------------------------------------------------------\n    void SkinnedAnimationGroup::BuildAnimationData(AnimationBlendType ineBlendType, f32 infPlaybackPosition, f32 infBlendlinePosition)\n    {\n        //check how many animations we have. if we only have 1 then dont try and blend. If we have none then error.\n        if (mAnimations.size() > 1)\n        {\n            //find which two animations should be blended together\n            AnimationItemPtr pAnimItem1;\n            AnimationItemPtr pAnimItem2;\n            for (std::vector<AnimationItemPtr>::iterator it = mAnimations.begin(); it != mAnimations.end(); ++it)\n            {\n                f32 fBlendlinePosition = (*it)->fBlendlinePosition;\n                if (fBlendlinePosition <= infBlendlinePosition && (pAnimItem1 == nullptr || fBlendlinePosition > pAnimItem1->fBlendlinePosition))\n                {\n                    pAnimItem1 = (*it);\n                }\n                if (fBlendlinePosition >= infBlendlinePosition && (pAnimItem2 == nullptr || fBlendlinePosition < pAnimItem2->fBlendlinePosition))\n                {\n                    pAnimItem2 = (*it);\n                }\n            }\n            \n            //get the animation frames\n            SkinnedAnimation::FrameCUPtr pFrame1;\n            if (pAnimItem1 != nullptr)\n                pFrame1 = CalculateAnimationFrame(pAnimItem1->pSkinnedAnimation, infPlaybackPosition);\n            \n            SkinnedAnimation::FrameCUPtr pFrame2;\n            if (pAnimItem2 != nullptr)\n                pFrame2 = CalculateAnimationFrame(pAnimItem2->pSkinnedAnimation, infPlaybackPosition);\n            \n            //check that we do indeed have two animations to blend. if not, just return the frame we do have.\n            if (pFrame1 != nullptr && pFrame2 != nullptr && pAnimItem1.get() != pAnimItem2.get())\n            {\n                //get the interpolation factor and then apply the requested blend to the two frames.\n                f32 fFactor = (infBlendlinePosition - pAnimItem1->fBlendlinePosition) / (pAnimItem2->fBlendlinePosition - pAnimItem1->fBlendlinePosition);\n                switch (ineBlendType)\n                {\n                    case AnimationBlendType::k_linear:\n                        mCurrentAnimationData = LerpBetweenFrames(pFrame1.get(), pFrame2.get(), fFactor);\n                        break;\n                    default:\n                        CS_LOG_ERROR(\"Invalid animation blend type given.\");\n                        mCurrentAnimationData = std::move(pFrame1);\n                        break;\n                }\n            }\n            else if (pFrame1 != nullptr)\n            {\n                mCurrentAnimationData = std::move(pFrame1);\n            }\n            else if (pFrame2 != nullptr)\n            {\n                mCurrentAnimationData = std::move(pFrame2);\n            }\n            else \n            {\n                CS_LOG_ERROR(\"Something has gone wrong when blending animations.\");\n                return;\n            }\n            mbPrepared = true;\n        }\n        else if (mAnimations.size() > 0) \n        {\n            const SkinnedAnimationCSPtr& pAnim = mAnimations[0]->pSkinnedAnimation;\n            mCurrentAnimationData = CalculateAnimationFrame(pAnim, infPlaybackPosition);\n            mbPrepared = true;\n        }\n        else\n        {\n            CS_LOG_ERROR(\"No animations attached to the animation group!\");\n            return;\n        }\n    }\n    //----------------------------------------------------------\n    /// Blend Group\n    //----------------------------------------------------------\n    void SkinnedAnimationGroup::BlendGroup(AnimationBlendType ineBlendType, const SkinnedAnimationGroupSPtr& inpAnimationGroup, f32 infBlendFactor)\n    {\n        switch (ineBlendType)\n        {\n            case AnimationBlendType::k_linear:\n                mCurrentAnimationData = LerpBetweenFrames(mCurrentAnimationData.get(), inpAnimationGroup->mCurrentAnimationData.get(), infBlendFactor);\n                break;\n            default:\n                CS_LOG_ERROR(\"Invalid animation blend type given.\");\n                break;\n        }\n    }\n    //----------------------------------------------------------\n    /// Build Matrices\n    //----------------------------------------------------------\n    void SkinnedAnimationGroup::BuildMatrices(s32 indwCurrentParent, const Matrix4& inParentMatrix)\n    {\n        const std::vector<SkeletonNodeCUPtr>& nodes = mpSkeleton.GetNodes();\n        u32 currIndex = 0;\n        for (auto it = nodes.begin(); it != nodes.end(); ++it)\n        {\n            if ((*it)->mdwParentIndex == indwCurrentParent)\n            {\n                //get the world translation and orientation\n                Matrix4 localMat;\n                if(mCurrentAnimationData->m_nodeTranslations.empty() == false)\n                {\n                    localMat = Matrix4::CreateTransform(mCurrentAnimationData->m_nodeTranslations[currIndex], mCurrentAnimationData->m_nodeScales[currIndex], mCurrentAnimationData->m_nodeOrientations[currIndex]);\n                }\n                \n                //convert to matrix and store\n                mCurrentAnimationMatrices[currIndex] =  localMat * inParentMatrix;\n                \n                //Apply to all children\n                BuildMatrices(currIndex, mCurrentAnimationMatrices[currIndex]);\n            }\n            \n            currIndex++;\n        }\n    }\n    //----------------------------------------------------------\n    /// Get Matrix At Index\n    //----------------------------------------------------------\n    const Matrix4& SkinnedAnimationGroup::GetMatrixAtIndex(s32 indwIndex) const\n    {\n        if (indwIndex < (s32)mCurrentAnimationMatrices.size())\n        {\n            return mCurrentAnimationMatrices[indwIndex];\n        }\n        return Matrix4::k_identity;\n    }\n    //----------------------------------------------------------\n    //----------------------------------------------------------\n    RenderSkinnedAnimationAUPtr SkinnedAnimationGroup::BuildRenderSkinnedAnimation(IAllocator* in_allocator, const std::vector<Matrix4>& in_inverseBindPoseMatrices) const noexcept\n    {\n        const std::vector<s32>& joints = mpSkeleton.GetJointIndices();\n        CS_ASSERT(joints.size() == in_inverseBindPoseMatrices.size(), \"Cannot apply bind pose matrices to joint matrices, because they are not from the same skeleton.\");\n        \n        constexpr u32 k_numVectorsPerJoint = 3;\n        auto jointDataSize = joints.size() * k_numVectorsPerJoint;\n        auto jointData = MakeUniqueArray<Vector4>(*in_allocator, jointDataSize);\n        \n        s32 count = 0;\n        std::vector<s32>::const_iterator joint = joints.begin();\n        for (auto ibp = in_inverseBindPoseMatrices.begin(); joint != joints.end() && ibp != in_inverseBindPoseMatrices.end();)\n        {\n            Matrix4 combinedMatrix = ((*ibp) * (mCurrentAnimationMatrices[*joint]));\n            \n            jointData[count * 3 + 0] = Vector4(combinedMatrix.m[0], combinedMatrix.m[4], combinedMatrix.m[8], combinedMatrix.m[12]);\n            jointData[count * 3 + 1] = Vector4(combinedMatrix.m[1], combinedMatrix.m[5], combinedMatrix.m[9], combinedMatrix.m[13]);\n            jointData[count * 3 + 2] = Vector4(combinedMatrix.m[2], combinedMatrix.m[6], combinedMatrix.m[10], combinedMatrix.m[14]);\n            \n            //incriment the iterators\n            ++joint;\n            ++ibp;\n            count++;\n        }\n        \n        return MakeUnique<RenderSkinnedAnimation>(*in_allocator, std::move(jointData), u32(jointDataSize));\n    }\n    //----------------------------------------------------------\n    /// Get Animation Length\n    //----------------------------------------------------------\n    f32 SkinnedAnimationGroup::GetAnimationLength()\n    {\n        CalculateAnimationLength();\n        return mfAnimationLength;\n    }\n    //----------------------------------------------------------\n    /// Get Animation Count\n    //----------------------------------------------------------\n    u32 SkinnedAnimationGroup::GetAnimationCount() const\n    {\n        return static_cast<u32>(mAnimations.size());\n    }\n    //----------------------------------------------------------\n    /// Is Prepared\n    //----------------------------------------------------------\n    bool SkinnedAnimationGroup::IsPrepared() const\n    {\n        return mbPrepared;\n    }\n    //----------------------------------------------------------\n    /// Get Animation\n    //----------------------------------------------------------\n    void SkinnedAnimationGroup::GetAnimations(std::vector<SkinnedAnimationCSPtr>& outapSkinnedAnimationList)\n    {\n        for (std::vector<AnimationItemPtr>::iterator it = mAnimations.begin(); it != mAnimations.end(); ++it)\n        {\n            outapSkinnedAnimationList.push_back((*it)->pSkinnedAnimation);\n        }\n    }\n    //----------------------------------------------------------\n    /// Calculate Animation Length\n    //----------------------------------------------------------\n    void SkinnedAnimationGroup::CalculateAnimationLength()\n    {\n        if (mbAnimationLengthDirty)\n        {\n            mfAnimationLength = 0.0f;\n            \n            for (std::vector<AnimationItemPtr>::iterator it = mAnimations.begin(); it != mAnimations.end(); ++it)\n            {\n                const SkinnedAnimationCSPtr& pAnim = (*it)->pSkinnedAnimation;\n                f32 fAnimationLength = pAnim->GetFrameTime() * ((f32)(pAnim->GetNumFrames() - 1));\n                \n                if (mfAnimationLength != 0.0f && mfAnimationLength != fAnimationLength)\n                {\n                    CS_LOG_ERROR(\"All grouped animations must have the same length!\");\n                    mfAnimationLength = 0.0f;\n                    return;\n                }\n                \n                mfAnimationLength = fAnimationLength;\n            }\n            \n            mbAnimationLengthDirty = false;\n        }\n    }\n    //----------------------------------------------------------\n    /// Calculate Animation Frame\n    //----------------------------------------------------------\n    SkinnedAnimation::FrameCUPtr SkinnedAnimationGroup::CalculateAnimationFrame(const SkinnedAnimationCSPtr& inpAnimation, f32 infPlaybackPosition)\n    {\n        //report errors if the playback position provided does not make sense\n        if (infPlaybackPosition < 0.0f)\n        {\n            CS_LOG_ERROR(\"A playback position below 0 does not make sense.\");\n        }\n        \n        //calculate the two frame indices this is between\n        f32 frames = infPlaybackPosition / inpAnimation->GetFrameTime();\n        s32 dwFrameAIndex = (s32)floorf(frames);\n        s32 dwFrameBIndex = (s32)ceilf(frames);\n        \n        //ensure the frame numbers make sense\n        if(dwFrameAIndex < 0)\n        {\n            dwFrameAIndex = 0;\n        }\n        \n        if(dwFrameAIndex >= (s32)inpAnimation->GetNumFrames())\n        {\n            dwFrameAIndex = inpAnimation->GetNumFrames() - 1;\n        }\n        \n        if(dwFrameBIndex < 0)\n        {\n            dwFrameBIndex = 0;\n        }\n        \n        if (dwFrameBIndex >= (s32)inpAnimation->GetNumFrames())\n        {\n            dwFrameBIndex = inpAnimation->GetNumFrames() - 1;\n        }\n        \n        //get the frames\n        const SkinnedAnimation::Frame* frameA = inpAnimation->GetFrameAtIndex(dwFrameAIndex);\n        const SkinnedAnimation::Frame* frameB = inpAnimation->GetFrameAtIndex(dwFrameBIndex);\n        \n        //get the ratio of one frame to the next\n        f32 interpFactor = (infPlaybackPosition - (dwFrameAIndex * inpAnimation->GetFrameTime())) / inpAnimation->GetFrameTime();\n        \n        //blend between frames\n        return LerpBetweenFrames(frameA, frameB, interpFactor);\n    }\n    //--------------------------------------------------------------\n    /// Lerp Between Frames\n    //--------------------------------------------------------------\n    SkinnedAnimation::FrameCUPtr SkinnedAnimationGroup::LerpBetweenFrames(const SkinnedAnimation::Frame* inFrameA, const SkinnedAnimation::Frame* inFrameB, f32 infInterpFactor)\n    {\n        SkinnedAnimation::FrameUPtr outFrame(new SkinnedAnimation::Frame());\n        \n        if(inFrameA != nullptr && inFrameB != nullptr)\n        {\n            //iterate through each translation\n            outFrame->m_nodeTranslations.reserve(inFrameB->m_nodeTranslations.size());\n            std::vector<Vector3>::const_iterator transAIt = inFrameA->m_nodeTranslations.begin();\n            for (std::vector<Vector3>::const_iterator transBIt = inFrameB->m_nodeTranslations.begin();\n                 transAIt != inFrameA->m_nodeTranslations.end() && transBIt != inFrameB->m_nodeTranslations.end();)\n            {\n                //lerp\n                Vector3 newTrans = MathUtils::Lerp(infInterpFactor, *transAIt, *transBIt);\n                \n                //add to frame\n                outFrame->m_nodeTranslations.push_back(newTrans);\n                \n                //incriment the iterators\n                ++transAIt;\n                ++transBIt;\n            }\n            \n            //iterate through each orientation\n            outFrame->m_nodeOrientations.reserve(inFrameB->m_nodeOrientations.size());\n            std::vector<Quaternion>::const_iterator orientAIt = inFrameA->m_nodeOrientations.begin();\n            for (std::vector<Quaternion>::const_iterator orientBIt = inFrameB->m_nodeOrientations.begin();\n                 orientAIt != inFrameA->m_nodeOrientations.end() && orientBIt != inFrameB->m_nodeOrientations.end();)\n            {\n                //lerp\n                Quaternion newOrient = Quaternion::Slerp(*orientAIt, *orientBIt, infInterpFactor);\n                \n                //add to frame\n                outFrame->m_nodeOrientations.push_back(newOrient);\n                \n                //incriment the iterators\n                ++orientAIt;\n                ++orientBIt;\n            }\n            \n            //iterate through each scale\n            outFrame->m_nodeScales.reserve(inFrameB->m_nodeScales.size());\n            std::vector<Vector3>::const_iterator scaleAIt = inFrameA->m_nodeScales.begin();\n            for (std::vector<Vector3>::const_iterator scaleBIt = inFrameB->m_nodeScales.begin();\n                 scaleAIt != inFrameA->m_nodeScales.end() && scaleBIt != inFrameB->m_nodeScales.end();)\n            {\n                //lerp\n                Vector3 newScale = MathUtils::Lerp(infInterpFactor, *scaleAIt, *scaleBIt);\n                \n                //add to frame\n                outFrame->m_nodeScales.push_back(newScale);\n                \n                //incriment the iterators\n                ++scaleAIt;\n                ++scaleBIt;\n            }\n        }\n        \n        return SkinnedAnimation::FrameCUPtr(std::move(outFrame));\n    }\n}\n\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Model/SkinnedAnimationGroup.h",
    "content": "//\n//  SkinnedAnimationGroup.h\n//  ChilliSource\n//  Created by Ian Copland on 08/06/2012.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2011 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_SKINNEDANIMATIONGROUP_H_\n#define _CHILLISOURCE_RENDERING_SKINNEDANIMATIONGROUP_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/File/FileSystem.h>\n#include <ChilliSource/Core/Math/Matrix4.h>\n#include <ChilliSource/Rendering/Model/RenderSkinnedAnimation.h>\n#include <ChilliSource/Rendering/Model/SkinnedAnimation.h>\n\nnamespace ChilliSource\n{\n    //===============================================================\n    /// Animation Blend Type\n    ///\n    /// Describes the different types of animation blend.\n    //===============================================================\n    enum class AnimationBlendType\n    {\n        k_linear\n    };\n    //===============================================================\n    /// Skinned Animation Group\n    ///\n    /// A group of animations that can be blended.\n    //===============================================================\n    class SkinnedAnimationGroup final\n    {\n    public:\n        \n        CS_DECLARE_NOCOPY(SkinnedAnimationGroup);\n        \n        //-----------------------------------------------------------\n        /// Constructor\n        //-----------------------------------------------------------\n        SkinnedAnimationGroup(const Skeleton& inpSkeleton);\n        //----------------------------------------------------------\n        /// Attach Animation\n        ///\n        /// Attaches an animation.\n        ///\n        /// @param The animation pointer.\n        /// @param the position of the animation on the blendline.\n        //----------------------------------------------------------\n        void AttachAnimation(const SkinnedAnimationCSPtr& inpAnimation, f32 infBlendlinePosition);\n        //----------------------------------------------------------\n        /// Detatch Animation\n        ///\n        /// Removes an animation.\n        ///\n        /// @param The animation pointer.\n        //----------------------------------------------------------\n        void DetatchAnimation(const SkinnedAnimationCSPtr& inpAnimation);\n        //----------------------------------------------------------\n        /// Clear Animations\n        ///\n        /// Clears all animations\n        //----------------------------------------------------------\n        void ClearAnimations();\n        //----------------------------------------------------------\n        /// Build Animation Data\n        ///\n        /// Builds a new set of animation data with the given\n        /// parameters\n        ///\n        /// @param The blend type.\n        /// @param the playback position.\n        /// @param the blendline position.\n        //----------------------------------------------------------\n        void BuildAnimationData(AnimationBlendType ineBlendType, f32 infPlaybackPosition, f32 infBlendlinePosition);\n        //----------------------------------------------------------\n        /// Blend Group\n        ///\n        /// Blends between another group and this.\n        ///\n        /// @param The fade type.\n        /// @param the playback position.\n        /// @param the blendline position.\n        //----------------------------------------------------------\n        void BlendGroup(AnimationBlendType ineBlendType, const SkinnedAnimationGroupSPtr& inpAnimationGroup, f32 infBlendFactor);\n        //----------------------------------------------------------\n        /// Build Matrices\n        ///\n        /// Builds the animation matrix data from the current\n        /// animation data.\n        ///\n        /// @param the current parent.\n        /// @param the parent matrix.\n        //----------------------------------------------------------\n        void BuildMatrices(s32 indwCurrentParent = -1, const Matrix4& inParentMatrix = Matrix4());\n        //----------------------------------------------------------\n        /// Get Matrix At Index\n        ///\n        /// @param the index of the required matrix.\n        /// @return the matrix.\n        //----------------------------------------------------------\n        const Matrix4& GetMatrixAtIndex(s32 indwIndex) const;\n        //----------------------------------------------------------\n        /// Generates the joint data that will be passed to the\n        /// shaders by first combining the current animation frame\n        /// joint matrices with the supplied inverse bind pose\n        /// matrices. The resultant matrices are then each stripped\n        /// down to 3 Vector4s, each representing a single column\n        /// in the matrix, so that the final column can be omitted\n        /// as it will always be [0, 0, 0, 1] and can be rebuilt\n        /// manually in the shader.\n        ///\n        /// The animation data will be allocated from the given\n        /// IAllocator.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param in_allocator - The allocator that will be used for\n        /// allocating the joint data.\n        /// @param in_inverseBindPoseMatrices - The inverse bind\n        /// pose matrices that will be applied.\n        //----------------------------------------------------------\n        RenderSkinnedAnimationAUPtr BuildRenderSkinnedAnimation(IAllocator* in_allocator, const std::vector<Matrix4>& in_inverseBindPoseMatrices) const noexcept;\n        //----------------------------------------------------------\n        /// Get Animation Length\n        ///\n        /// @return the length of the animation in seconds.\n        //----------------------------------------------------------\n        f32 GetAnimationLength();\n        //----------------------------------------------------------\n        /// Get Animation Count\n        ///\n        /// @return the number of attached animations.\n        //----------------------------------------------------------\n        u32 GetAnimationCount() const;\n        //----------------------------------------------------------\n        /// Is Prepared\n        ///\n        /// @return whether or not the group is ready for being used\n        /// in rendering;\n        //----------------------------------------------------------\n        bool IsPrepared() const;\n        //----------------------------------------------------------\n        /// Get Animations\n        ///\n        /// @param OUT: The list of animations.\n        //----------------------------------------------------------\n        void GetAnimations(std::vector<SkinnedAnimationCSPtr>& outapSkinnedAnimationList);\n    private:\n        //----------------------------------------------------------\n        /// Animation Item\n        ///\n        /// A single animation item for containing in an animation group.\n        //----------------------------------------------------------\n        struct AnimationItem\n        {\n            SkinnedAnimationCSPtr pSkinnedAnimation;\n            f32 fBlendlinePosition;\n        };\n        typedef std::shared_ptr<AnimationItem> AnimationItemPtr;\n        //----------------------------------------------------------\n        /// Calculate Animation Length\n        ///\n        /// calculates the length of the animation group and ensures\n        /// all attached animations are of the same length.\n        //----------------------------------------------------------\n        void CalculateAnimationLength();\n        //----------------------------------------------------------\n        /// Calculate Animation Frame\n        ///\n        /// Gets the frame data from a single animation.\n        ///\n        /// @param The blend type.\n        /// @param the animation.\n        /// @param the playback position.\n        //----------------------------------------------------------\n        SkinnedAnimation::FrameCUPtr CalculateAnimationFrame(const SkinnedAnimationCSPtr& inpAnimation, f32 infPlaybackPosition);\n        //--------------------------------------------------------------\n        /// Lerp Between Frames\n        ///\n        /// Linearly interpolates between two animation frames.\n        ///\n        /// @param frame 1\n        /// @param frame 2\n        /// @param the interpolation factor\n        /// @return output interpolated frame.\n        //--------------------------------------------------------------\n        SkinnedAnimation::FrameCUPtr LerpBetweenFrames(const SkinnedAnimation::Frame* inFrameA, const SkinnedAnimation::Frame* inFrameB, f32 infInterpFactor);\n        \n        const Skeleton& mpSkeleton;\n        std::vector<AnimationItemPtr> mAnimations;\n        SkinnedAnimation::FrameCUPtr mCurrentAnimationData;\n        std::vector<Matrix4> mCurrentAnimationMatrices;\n        bool mbAnimationLengthDirty;\n        f32 mfAnimationLength;\n        bool mbPrepared;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Model/SmallMeshBatcher.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Model/SmallMeshBatcher.h>\n\n#include <ChilliSource/Rendering/Base/RenderFrameData.h>\n#include <ChilliSource/Rendering/Base/RenderPassObject.h>\n#include <ChilliSource/Rendering/Model/RenderDynamicMesh.h>\n#include <ChilliSource/Rendering/Model/RenderMeshBatch.h>\n#include <ChilliSource/Rendering/Model/RenderMesh.h>\n#include <ChilliSource/Rendering/RenderCommand/RenderCommandList.h>\n\nnamespace ChilliSource\n{\n    namespace\n    {\n        constexpr u32 k_batchVertexCountThreshold = 100;\n    }\n    \n    //------------------------------------------------------------------------------\n    bool SmallMeshBatcher::CanBatch(const RenderPassObject& renderPassObject) noexcept\n    {\n        //TODO: Add support for static render pass objects\n        //TODO: Add support for static mesh vertex formats\n        \n        if (renderPassObject.GetType() == RenderPassObject::Type::k_dynamic)\n        {\n            auto renderDynamicMesh = renderPassObject.GetRenderDynamicMesh();\n            CS_ASSERT(renderDynamicMesh, \"Must have render dynamic mesh.\");\n            \n            if (renderDynamicMesh->GetVertexFormat() == VertexFormat::k_sprite)\n            {\n                if (renderDynamicMesh->GetNumVertices() <= k_batchVertexCountThreshold)\n                {\n                    return true;\n                }\n            }\n        }\n        \n        return false;\n    }\n\n    //------------------------------------------------------------------------------\n    SmallMeshBatcher::SmallMeshBatcher(RenderCommandList* renderCommandList) noexcept\n        : m_renderCommandList(renderCommandList)\n    {\n    }\n\n    //------------------------------------------------------------------------------\n    void SmallMeshBatcher::Batch(const RenderPassObject& renderPassObject) noexcept\n    {\n        CS_ASSERT(CanBatch(renderPassObject), \"Cannot batch the given object.\");\n        \n        if (TryUpdateRenderState(renderPassObject))\n        {\n            Flush();\n        }\n        \n        AddToBatch(renderPassObject);\n    }\n\n    //------------------------------------------------------------------------------\n    void SmallMeshBatcher::Flush() noexcept\n    {\n        if (!m_currentMeshes.empty())\n        {\n            auto renderMeshBatch = RenderMeshBatchUPtr(new RenderMeshBatch(m_currentPolygonType, m_currentVertexFormat, m_currentIndexFormat, std::move(m_currentMeshes)));\n            \n            m_renderCommandList->AddApplyMeshBatchCommand(std::move(renderMeshBatch));\n            m_renderCommandList->AddRenderInstanceCommand(Matrix4::k_identity);\n            \n            m_currentVertexDataSize = 0;\n            m_currentIndexDataSize = 0;\n        }\n    }\n    \n    //------------------------------------------------------------------------------\n    bool SmallMeshBatcher::TryUpdateRenderState(const RenderPassObject& renderPassObject) noexcept\n    {\n        //TODO: Add support for static render pass objects\n        \n        PolygonType newPolygonType = PolygonType::k_triangle;\n        const VertexFormat* newVertexFormat = nullptr;\n        IndexFormat newIndexFormat = IndexFormat::k_short;\n        bool newHasIndices = false;\n        \n        switch (renderPassObject.GetType())\n        {\n            case RenderPassObject::Type::k_dynamic:\n            {\n                auto renderDynamicMesh = renderPassObject.GetRenderDynamicMesh();\n                CS_ASSERT(renderDynamicMesh, \"Must have render dynamic mesh.\");\n                \n                newPolygonType = renderDynamicMesh->GetPolygonType();\n                newVertexFormat = &renderDynamicMesh->GetVertexFormat();\n                newIndexFormat = renderDynamicMesh->GetIndexFormat();\n                newHasIndices = (renderDynamicMesh->GetNumIndices() > 0);\n                break;\n            }\n            default:\n                CS_LOG_FATAL(\"Invalid render pass object type.\");\n                break;\n        }\n        \n        if (m_currentPolygonType != newPolygonType || m_currentVertexFormat != *newVertexFormat || m_currentIndexFormat != newIndexFormat || m_hasIndices != newHasIndices)\n        {\n            m_currentPolygonType = newPolygonType;\n            m_currentVertexFormat = *newVertexFormat;\n            m_currentIndexFormat = newIndexFormat;\n            m_hasIndices = newHasIndices;\n            \n            return true;\n        }\n        else\n        {\n            return false;\n        }\n    }\n    \n    //------------------------------------------------------------------------------\n    void SmallMeshBatcher::AddToBatch(const RenderPassObject& renderPassObject) noexcept\n    {\n        //TODO: Add support for static render pass objects.\n        \n        u32 numVertices = 0;\n        u32 numIndices = 0;\n        const u8* vertexData = nullptr;\n        u32 vertexDataSize = 0;\n        const u8* indexData = nullptr;\n        u32 indexDataSize = 0;\n        \n        switch (renderPassObject.GetType())\n        {\n            case RenderPassObject::Type::k_dynamic:\n            {\n                auto renderDynamicMesh = renderPassObject.GetRenderDynamicMesh();\n                CS_ASSERT(renderDynamicMesh, \"Must have render dynamic mesh.\");\n                \n                numVertices = renderDynamicMesh->GetNumVertices();\n                numIndices = renderDynamicMesh->GetNumIndices();\n                vertexData = renderDynamicMesh->GetVertexData();\n                vertexDataSize = renderDynamicMesh->GetVertexDataSize();\n                indexData = renderDynamicMesh->GetIndexData();\n                indexDataSize = renderDynamicMesh->GetIndexDataSize();\n                break;\n            }\n            default:\n                CS_LOG_FATAL(\"Invalid render pass object type.\");\n                break;\n        }\n        \n        if (m_currentVertexDataSize + vertexDataSize >= RenderDynamicMesh::k_maxVertexDataSize || m_currentIndexDataSize + indexDataSize >= RenderDynamicMesh::k_maxIndexDataSize)\n        {\n            Flush();\n        }\n        \n        m_currentVertexDataSize += vertexDataSize;\n        m_currentIndexDataSize += indexDataSize;\n        m_currentMeshes.push_back(RenderMeshBatch::Mesh(renderPassObject.GetWorldMatrix(), numVertices, numIndices, vertexData, vertexDataSize, indexData, indexDataSize));\n    }\n\n    //------------------------------------------------------------------------------\n    SmallMeshBatcher::~SmallMeshBatcher() noexcept\n    {\n        CS_ASSERT(m_currentMeshes.empty(), \"Deleting small mesh batcher without flushing.\");\n    }\n}"
  },
  {
    "path": "Source/ChilliSource/Rendering/Model/SmallMeshBatcher.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_MODEL_SMALLMESHBATCHER_H_\n#define _CHILLISOURCE_RENDERING_MODEL_SMALLMESHBATCHER_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Rendering/Model/IndexFormat.h>\n#include <ChilliSource/Rendering/Model/PolygonType.h>\n#include <ChilliSource/Rendering/Model/RenderMeshBatch.h>\n#include <ChilliSource/Rendering/Model/VertexFormat.h>\n\n#include <vector>\n\nnamespace ChilliSource\n{\n    /// Manages the batching of small objects into a single mesh to reduce the number of draw calls\n    /// that are performed. This is primarily for sprites and UI elements, but it will also batch\n    /// static meshes under a certain vertex count.\n    ///\n    /// This works by converting combining all of the meshes together into a single vertex and index\n    /// buffer. The vertex data will be converted into world space, and the index data will be offset\n    /// to the updated position of the vertex data in the buffer. This is an expensive operation, so\n    /// it should only be applied to small meshes.\n    ///\n    /// Only objects of the same mesh type can be batched. When a new mesh type is encountered the\n    /// current mesh batch is flushed and a new batch started. Flushing applies the dynamic mesh and\n    /// then sends a render instance command. A flush is also required before the current material\n    /// changes else the render instance command will occur when the new material is bound. This has\n    /// to be handled manually by calling Flush().\n    ///\n    /// This is not thread-safe and each instance should only be accessed from one thread at a time.\n    ///\n    class SmallMeshBatcher final\n    {\n    public:\n        /// Evaluates whether or not the given render pass object can be batched. This is based on the type\n        /// of mesh, and the number of vertices in the mesh. This should be checked prior to calling batch.\n        ///\n        /// @param renderPassObject\n        ///     The render pass object which should be checked.\n        ///\n        /// @return Whether or not the render pass object can be batched.\n        ///\n        static bool CanBatch(const RenderPassObject& renderPassObject) noexcept;\n        \n        /// Creates a new instance with the given render command list. This is the list that all generated\n        /// commands will be added to.\n        ///\n        /// @param renderCommandList\n        ///     The render command list commands should be added to.\n        ///\n        SmallMeshBatcher(RenderCommandList* renderCommandList) noexcept;\n        \n        /// Adds the given render pass object to the batch. If the object contains a different mesh type\n        /// than the current batch, the batch will first be flushed. If the render pass object cannot be\n        /// batched this will assert.\n        ///\n        /// @param renderPassObject\n        ///     The render pass object which should be batched.\n        ///\n        void Batch(const RenderPassObject& renderPassObject) noexcept;\n        \n        /// Flushes the batch, adding the appropriate commands to the renderCommandList.\n        ///\n        void Flush() noexcept;\n        \n        ~SmallMeshBatcher() noexcept;\n        \n    private:\n        /// Checks the current state versus the the state described by the given render pass object. If\n        /// the state is different then the internal state is updated.\n        ///\n        /// @return renderPassObject\n        ///     The render pass object whose state should be checked.\n        ///\n        /// @return Whether or not the state has changed.\n        ///\n        bool TryUpdateRenderState(const RenderPassObject& renderPassObject) noexcept;\n        \n        /// Adds the given object to the batch. Will flush the batch if there is no room left in the buffer.\n        ///\n        /// @param renderPassObject\n        ///     The render pass object which should be added.\n        ///\n        void AddToBatch(const RenderPassObject& renderPassObject) noexcept;\n        \n        RenderCommandList* m_renderCommandList;\n        \n        PolygonType m_currentPolygonType = PolygonType::k_triangle;\n        VertexFormat m_currentVertexFormat = VertexFormat::k_staticMesh;\n        IndexFormat m_currentIndexFormat = IndexFormat::k_short;\n        bool m_hasIndices = false;\n        std::vector<RenderMeshBatch::Mesh> m_currentMeshes;\n        u32 m_currentVertexDataSize = 0;\n        u32 m_currentIndexDataSize = 0;\n    };\n}\n\n#endif"
  },
  {
    "path": "Source/ChilliSource/Rendering/Model/StaticModelComponent.cpp",
    "content": "//\n//  StaticModelComponent.cpp\n//  ChilliSource\n//  Created by Scott Downie on 07/10/2010.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2010 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Model/StaticModelComponent.h>\n\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/Delegate/MakeDelegate.h>\n#include <ChilliSource/Core/Entity/Entity.h>\n#include <ChilliSource/Core/Math/Matrix4.h>\n#include <ChilliSource/Core/Math/Geometry/Shapes.h>\n#include <ChilliSource/Rendering/Base/RenderSnapshot.h>\n#include <ChilliSource/Rendering/Material/Material.h>\n\n#include <algorithm>\n#include <limits>\n\nnamespace ChilliSource\n{\n    CS_DEFINE_NAMEDTYPE(StaticModelComponent);\n    \n    //------------------------------------------------------------------------------\n    StaticModelComponent::StaticModelComponent(const ModelCSPtr& model, const MaterialCSPtr& material) noexcept\n    : m_model(model)\n    {\n        CS_ASSERT(m_model, \"Model cannot be null\");\n        CS_ASSERT(m_model->GetLoadState() == Resource::LoadState::k_loaded, \"Cannot use a model that hasn't been loaded yet.\");\n        CS_ASSERT(material, \"Material cannot be null\");\n        CS_ASSERT(material->GetLoadState() == Resource::LoadState::k_loaded, \"Cannot use a material that hasn't been loaded yet.\");\n        \n        m_materials.resize(model->GetNumMeshes());\n        \n        for (u32 i = 0; i < u32(m_materials.size()); ++i)\n        {\n            m_materials[i] = material;\n        }\n    }\n    \n    //------------------------------------------------------------------------------\n    StaticModelComponent::StaticModelComponent(const ModelCSPtr& model, const std::vector<MaterialCSPtr>& materials) noexcept\n    : m_model(model), m_materials(materials)\n    {\n#if CS_ENABLE_DEBUG\n        CS_ASSERT(m_model, \"Model cannot be null\");\n        CS_ASSERT(m_model->GetLoadState() == Resource::LoadState::k_loaded, \"Cannot use a model that hasn't been loaded yet.\");\n        CS_ASSERT(m_materials.size() == m_model->GetNumMeshes(), \"Model component must have the same number of materials as there are meshes in the model.\");\n        \n        for (const auto& material : m_materials)\n        {\n            CS_ASSERT(material, \"Material cannot be null\");\n            CS_ASSERT(material->GetLoadState() == Resource::LoadState::k_loaded, \"Cannot use a material that hasn't been loaded yet.\");\n        }\n#endif\n    }\n    \n    //------------------------------------------------------------------------------\n    bool StaticModelComponent::IsA(InterfaceIDType interfaceId) const noexcept\n    {\n        return  (interfaceId == VolumeComponent::InterfaceID || interfaceId == StaticModelComponent::InterfaceID);\n    }\n    \n    //------------------------------------------------------------------------------\n    const AABB& StaticModelComponent::GetAABB() noexcept\n    {\n        if(GetEntity() && !m_isAABBValid)\n        {\n            m_isAABBValid = true;\n            \n            //Rebuild the box\n            const AABB& cAABB = m_model->GetAABB();\n            const Matrix4& matWorld = GetEntity()->GetTransform().GetWorldTransform();\n            Vector3 vBackBottomLeft(cAABB.BackBottomLeft() * matWorld);\n            Vector3 vBackBottomRight(cAABB.BackBottomRight() * matWorld);\n            Vector3 vBackTopLeft(cAABB.BackTopLeft() * matWorld);\n            Vector3 vBackTopRight(cAABB.BackTopRight() * matWorld);\n            Vector3 vFrontBottomLeft(cAABB.FrontBottomLeft() * matWorld);\n            Vector3 vFrontBottomRight(cAABB.FrontBottomRight() * matWorld);\n            Vector3 vFrontTopLeft(cAABB.FrontTopLeft() *matWorld);\n            Vector3 vFrontTopRight(cAABB.FrontTopRight() * matWorld);\n            \n            Vector3 vMin(std::numeric_limits<f32>::infinity(), std::numeric_limits<f32>::infinity(), std::numeric_limits<f32>::infinity());\n            vMin.x = std::min(vMin.x, vBackBottomLeft.x);\n            vMin.x = std::min(vMin.x, vBackBottomRight.x);\n            vMin.x = std::min(vMin.x, vBackTopLeft.x);\n            vMin.x = std::min(vMin.x, vBackTopRight.x);\n            vMin.x = std::min(vMin.x, vFrontBottomLeft.x);\n            vMin.x = std::min(vMin.x, vFrontBottomRight.x);\n            vMin.x = std::min(vMin.x, vFrontTopLeft.x);\n            vMin.x = std::min(vMin.x, vFrontTopRight.x);\n\n            vMin.y = std::min(vMin.y, vBackBottomLeft.y);\n            vMin.y = std::min(vMin.y, vBackBottomRight.y);\n            vMin.y = std::min(vMin.y, vBackTopLeft.y);\n            vMin.y = std::min(vMin.y, vBackTopRight.y);\n            vMin.y = std::min(vMin.y, vFrontBottomLeft.y);\n            vMin.y = std::min(vMin.y, vFrontBottomRight.y);\n            vMin.y = std::min(vMin.y, vFrontTopLeft.y);\n            vMin.y = std::min(vMin.y, vFrontTopRight.y);\n            \n            vMin.z = std::min(vMin.z, vBackBottomLeft.z);\n            vMin.z = std::min(vMin.z, vBackBottomRight.z);\n            vMin.z = std::min(vMin.z, vBackTopLeft.z);\n            vMin.z = std::min(vMin.z, vBackTopRight.z);\n            vMin.z = std::min(vMin.z, vFrontBottomLeft.z);\n            vMin.z = std::min(vMin.z, vFrontBottomRight.z);\n            vMin.z = std::min(vMin.z, vFrontTopLeft.z);\n            vMin.z = std::min(vMin.z, vFrontTopRight.z);\n            \n            Vector3 vMax(-std::numeric_limits<f32>::infinity(), -std::numeric_limits<f32>::infinity(), -std::numeric_limits<f32>::infinity());\n            vMax.x = std::max(vMax.x, vBackBottomLeft.x);\n            vMax.x = std::max(vMax.x, vBackBottomRight.x);\n            vMax.x = std::max(vMax.x, vBackTopLeft.x);\n            vMax.x = std::max(vMax.x, vBackTopRight.x);\n            vMax.x = std::max(vMax.x, vFrontBottomLeft.x);\n            vMax.x = std::max(vMax.x, vFrontBottomRight.x);\n            vMax.x = std::max(vMax.x, vFrontTopLeft.x);\n            vMax.x = std::max(vMax.x, vFrontTopRight.x);\n            \n            vMax.y = std::max(vMax.y, vBackBottomLeft.y);\n            vMax.y = std::max(vMax.y, vBackBottomRight.y);\n            vMax.y = std::max(vMax.y, vBackTopLeft.y);\n            vMax.y = std::max(vMax.y, vBackTopRight.y);\n            vMax.y = std::max(vMax.y, vFrontBottomLeft.y);\n            vMax.y = std::max(vMax.y, vFrontBottomRight.y);\n            vMax.y = std::max(vMax.y, vFrontTopLeft.y);\n            vMax.y = std::max(vMax.y, vFrontTopRight.y);\n            \n            vMax.z = std::max(vMax.z, vBackBottomLeft.z);\n            vMax.z = std::max(vMax.z, vBackBottomRight.z);\n            vMax.z = std::max(vMax.z, vBackTopLeft.z);\n            vMax.z = std::max(vMax.z, vBackTopRight.z);\n            vMax.z = std::max(vMax.z, vFrontBottomLeft.z);\n            vMax.z = std::max(vMax.z, vFrontBottomRight.z);\n            vMax.z = std::max(vMax.z, vFrontTopLeft.z);\n            vMax.z = std::max(vMax.z, vFrontTopRight.z);\n            \n            m_aabb.SetSize( vMax - vMin );\n            m_aabb.SetOrigin( cAABB.Centre() * matWorld);\n        }\n\n        return m_aabb;\n    }\n    \n    //------------------------------------------------------------------------------\n    const OOBB& StaticModelComponent::GetOOBB() noexcept\n    {\n        if(GetEntity() && !m_isOOBBValid)\n        {\n            m_isOOBBValid = true;\n            \n            m_oobb.SetTransform(GetEntity()->GetTransform().GetWorldTransform());\n            // Origin and Size updated in SetModel\n        }\n        return m_oobb;\n    }\n    \n    //------------------------------------------------------------------------------\n    const Sphere& StaticModelComponent::GetBoundingSphere() noexcept\n    {\n        if(GetEntity() && !m_isBoundingSphereValid)\n        {\n            m_isBoundingSphereValid = true;\n            \n            const AABB& sAABB = GetAABB();\n            m_boundingSphere.vOrigin = sAABB.GetOrigin();\n            m_boundingSphere.fRadius = (sAABB.BackTopRight() - sAABB.FrontBottomLeft()).Length() * 0.5f;\n        }\n        return m_boundingSphere;\n    }\n    \n    //------------------------------------------------------------------------------\n    const ModelCSPtr& StaticModelComponent::GetModel() const noexcept\n    {\n        return m_model;\n    }\n    \n    //------------------------------------------------------------------------------\n    void StaticModelComponent::SetModel(const ModelCSPtr& model) noexcept\n    {\n        CS_ASSERT(model, \"Cannot set null model.\");\n        CS_ASSERT(model->GetLoadState() == Resource::LoadState::k_loaded, \"Cannot use a model that hasn't been loaded yet.\");\n        \n        m_model = model;\n        m_materials.resize(model->GetNumMeshes());\n        \n        m_oobb.SetSize(m_model->GetAABB().GetSize());\n        m_oobb.SetOrigin(m_model->GetAABB().GetOrigin());\n        \n        SetMaterial(GetMaterialForMesh(0));\n    }\n    \n    //------------------------------------------------------------------------------\n    void StaticModelComponent::SetModel(const ModelCSPtr& model, const MaterialCSPtr& material) noexcept\n    {\n        CS_ASSERT(model, \"Cannot set null model.\");\n        CS_ASSERT(model->GetLoadState() == Resource::LoadState::k_loaded, \"Cannot use a model that hasn't been loaded yet.\");\n        CS_ASSERT(material, \"Cannot set null material.\");\n        CS_ASSERT(material->GetLoadState() == Resource::LoadState::k_loaded, \"Cannot use a material that hasn't been loaded yet.\");\n        \n        m_model = model;\n        m_materials.resize(m_model->GetNumMeshes());\n        \n        m_oobb.SetSize(m_model->GetAABB().GetSize());\n        m_oobb.SetOrigin(m_model->GetAABB().GetOrigin());\n        \n        SetMaterial(material);\n    }\n    \n    //------------------------------------------------------------------------------\n    void StaticModelComponent::SetModel(const ModelCSPtr& model, const std::vector<MaterialCSPtr>& materials) noexcept\n    {\n#if CS_ENABLE_DEBUG\n        CS_ASSERT(model, \"Cannot set null model.\");\n        CS_ASSERT(model->GetLoadState() == Resource::LoadState::k_loaded, \"Cannot use a model that hasn't been loaded yet.\");\n        CS_ASSERT(materials.size() == model->GetNumMeshes(), \"Model component must have the same number of materials as there are meshes in the model.\");\n        \n        for (const auto& material : materials)\n        {\n            CS_ASSERT(material, \"Material cannot be null\");\n            CS_ASSERT(material->GetLoadState() == Resource::LoadState::k_loaded, \"Cannot use a material that hasn't been loaded yet.\");\n        }\n#endif\n        \n        m_model = model;\n        m_materials = materials;\n        \n        m_oobb.SetSize(m_model->GetAABB().GetSize());\n        m_oobb.SetOrigin(m_model->GetAABB().GetOrigin());\n    }\n    \n    //------------------------------------------------------------------------------\n    const MaterialCSPtr& StaticModelComponent::GetMaterialForMesh(u32 meshIndex) const noexcept\n    {\n        CS_ASSERT(meshIndex < s32(m_materials.size()), \"Invalid mesh index.\");\n        \n        return m_materials[meshIndex];\n    }\n    \n    //------------------------------------------------------------------------------\n    const MaterialCSPtr& StaticModelComponent::GetMaterialForMesh(const std::string& meshName) const noexcept\n    {\n        CS_ASSERT(m_model, \"Cannot get material without a model.\");\n        \n        auto meshIndex = m_model->GetMeshIndex(meshName);\n        CS_ASSERT(meshIndex >= 0 && meshIndex < s32(m_materials.size()), \"Invalid mesh index.\");\n        \n        return m_materials[meshIndex];\n    }\n    \n    //------------------------------------------------------------------------------\n    void StaticModelComponent::SetMaterial(const MaterialCSPtr& material) noexcept\n    {\n        CS_ASSERT(m_model, \"Cannot set material without a model.\");\n        CS_ASSERT(material, \"Cannot set null material.\");\n        CS_ASSERT(material->GetLoadState() == Resource::LoadState::k_loaded, \"Cannot use a material that hasn't been loaded yet.\");\n        \n        for (u32 i = 0; i < m_materials.size(); i++)\n        {\n            m_materials[i] = material;\n        }\n    }\n    \n    //------------------------------------------------------------------------------\n    void StaticModelComponent::SetMaterialForMesh(const MaterialCSPtr& material, u32 meshIndex) noexcept\n    {\n        CS_ASSERT(m_model, \"Cannot set material without a model.\");\n        CS_ASSERT(material, \"Cannot set null material.\");\n        CS_ASSERT(material->GetLoadState() == Resource::LoadState::k_loaded, \"Cannot use a material that hasn't been loaded yet.\");\n        CS_ASSERT(meshIndex < s32(m_materials.size()), \"Invalid mesh index.\");\n        \n        m_materials[meshIndex] = material;\n    }\n    \n    //------------------------------------------------------------------------------\n    void StaticModelComponent::SetMaterialForMesh(const MaterialCSPtr& material, const std::string& meshName) noexcept\n    {\n        CS_ASSERT(m_model, \"Cannot set material without a model.\");\n        CS_ASSERT(material, \"Cannot set null material.\");\n        CS_ASSERT(material->GetLoadState() == Resource::LoadState::k_loaded, \"Cannot use a material that hasn't been loaded yet.\");\n        \n        auto meshIndex = m_model->GetMeshIndex(meshName);\n        CS_ASSERT(meshIndex >= 0 && meshIndex < s32(m_materials.size()), \"Invalid mesh index.\");\n        \n        m_materials[meshIndex] = material;\n    }\n\n    //------------------------------------------------------------------------------\n    bool StaticModelComponent::IsShadowCastingEnabled() const noexcept\n    {\n        return m_shadowCastingEnabled;\n    }\n    \n    //------------------------------------------------------------------------------\n    void StaticModelComponent::SetShadowCastingEnabled(bool enabled) noexcept\n    {\n        m_shadowCastingEnabled = enabled;\n    }\n    \n    //------------------------------------------------------------------------------\n    void StaticModelComponent::OnAddedToScene() noexcept\n    {\n        m_transformChangedConnection = GetEntity()->GetTransform().GetTransformChangedEvent().OpenConnection(MakeDelegate(this, &StaticModelComponent::OnEntityTransformChanged));\n        \n        OnEntityTransformChanged();\n    }\n    \n    //------------------------------------------------------------------------------\n    void StaticModelComponent::OnEntityTransformChanged() noexcept\n    {\n        m_isAABBValid = false;\n        m_isOOBBValid = false;\n        m_isBoundingSphereValid = false;\n    }\n    \n    //------------------------------------------------------------------------------\n    void StaticModelComponent::OnRenderSnapshot(RenderSnapshot& renderSnapshot, IAllocator* frameAllocator) noexcept\n    {\n        CS_ASSERT(m_model->GetLoadState() == Resource::LoadState::k_loaded, \"Cannot use a model that hasn't been loaded yet.\");\n        CS_ASSERT(m_model->GetNumMeshes() == m_materials.size(), \"Invalid number of materials.\");\n        \n        for (u32 index = 0; index < m_model->GetNumMeshes(); ++index)\n        {\n            CS_ASSERT(m_materials[index]->GetLoadState() == Resource::LoadState::k_loaded, \"Cannot use a material that hasn't been loaded yet.\");\n            \n            auto renderMaterialGroup = m_materials[index]->GetRenderMaterialGroup();\n            auto renderMesh = m_model->GetRenderMesh(index);\n            \n            const auto& transform = GetEntity()->GetTransform();\n            auto boundingSphere = Sphere::Transform(renderMesh->GetBoundingSphere(), transform.GetWorldPosition(), transform.GetWorldOrientation(), transform.GetWorldScale());\n            \n            renderSnapshot.AddRenderObject(RenderObject(renderMaterialGroup, renderMesh, GetEntity()->GetTransform().GetWorldTransform(), boundingSphere, m_shadowCastingEnabled, RenderLayer::k_standard));\n        }\n    }\n    \n    //------------------------------------------------------------------------------\n    void StaticModelComponent::OnRemovedFromScene() noexcept\n    {\n        m_transformChangedConnection.reset();\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Model/StaticModelComponent.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2010 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_MODEL_STATICMODELCOMPONENT_H_\n#define _CHILLISOURCE_RENDERING_MODEL_STATICMODELCOMPONENT_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Volume/VolumeComponent.h>\n#include <ChilliSource/Rendering/Model/Model.h>\n\nnamespace ChilliSource\n{\n    /// A static model component. This defines a 3D model that can be manipulated, textured\n    /// but not animated.\n    ///\n    /// This is not thread safe and should not be used on multiple threads at once.\n    ///\n    class StaticModelComponent final : public VolumeComponent\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(StaticModelComponent);\n        \n        /// Creates a new static model component with the given model and material. The\n        /// material will be applied to all meshes in the model.\n        ///\n        /// @param model\n        ///     The model that should be used.\n        /// @param material\n        ///     The material that should be applied to each mesh in the model.\n        ///\n        StaticModelComponent(const ModelCSPtr& model, const MaterialCSPtr& material) noexcept;\n        \n        /// Creates a new static model component with the given model and a list of materials,\n        /// one for each mesh in the model. If the number of materials and meshes is not the\n        /// same, this will assert.\n        ///\n        /// @param model\n        ///     The model that should be used.\n        /// @param materials\n        ///     The list of materials for each mesh in the model.\n        ///\n        StaticModelComponent(const ModelCSPtr& model, const std::vector<MaterialCSPtr>& materials) noexcept;\n\n        /// Allows querying of whether or not this component implements the interface described\n        /// by the given interface Id. Typically this is not called directly as the templated\n        /// equivalent IsA<Interface>() is preferred.\n        ///\n        /// @param interfaceId\n        ///     The Id of the interface.\n        ///\n        /// @return Whether or not the interface is implemented.\n        ///\n        bool IsA(InterfaceIDType interfaceId) const noexcept override;\n\n        /// Calculates and returns the world space AABB of the model. This is cached and only\n        /// recomputed when required.\n        ///\n        /// @return The world space axis-aligned bounding box\n        ///\n        const AABB& GetAABB() noexcept override;\n        \n        /// Calculates and returns the world space OOBB of the model. This is cached and only\n        /// recomputed when required.\n        ///\n        /// @return The world space OOBB\n        ///\n        const OOBB& GetOOBB() noexcept override;\n        \n        /// Calculates and returns the world space bounding sphere of the model. This is cached\n        /// and only recomputed when required.\n        ///\n        /// @return The world space bounding sphere\n        ///\n        const Sphere& GetBoundingSphere() noexcept override;\n        \n        /// @return Whether or not the object should be rendered.\n        ///\n        bool IsVisible() const noexcept override { return m_isVisible; }\n        \n        /// @param isVisible\n        ///     Whether or not the object should be rendered.\n        ///\n        void SetVisible(bool isVisible) noexcept { m_isVisible = isVisible; }\n        \n        /// @return The model that will be rendered.\n        ///\n        const ModelCSPtr& GetModel() const noexcept;\n        \n        /// Sets the model the component should use.\n        ///\n        /// The material currently applied to the first mesh will be applied to the entire model.\n        ///\n        /// @param model\n        ///     The model.\n        ///\n        void SetModel(const ModelCSPtr& model) noexcept;\n        \n        /// Sets the model the component should use. The given material will be applied to all meshes.\n        ///\n        /// @param model\n        ///     The model which should be used.\n        /// @param material\n        ///     The material which should be used.\n        ///\n        void SetModel(const ModelCSPtr& model, const MaterialCSPtr& material) noexcept;\n        \n        /// Sets the model the component should use. The given materials will be applied to the\n        /// respective meshes.\n        ///\n        /// @param model\n        ///     The model which should be used.\n        /// @param materials\n        ///     The material for each mesh in the model. Must have the same number of elements as\n        ///     there are meshes in the given model.\n        ///\n        void SetModel(const ModelCSPtr& model, const std::vector<MaterialCSPtr>& materials) noexcept;\n        \n        /// Get the material of a single mesh.\n        ///\n        /// @param meshIndex\n        ///     Index to the mesh\n        ///\n        /// @return Handle to material\n        ///\n        const MaterialCSPtr& GetMaterialForMesh(u32 meshIndex) const noexcept;\n        \n        /// Get the material of a single mesh.\n        ///\n        /// @param meshName\n        ///     The name of the mesh.\n        ///\n        /// @return Handle to material\n        ///\n        const MaterialCSPtr& GetMaterialForMesh(const std::string& meshName) const noexcept;\n        \n        /// Set the material that the model will use. Applies the material to all meshes.\n        ///\n        /// @param material\n        ///     The material that should be used.\n        ///\n        void SetMaterial(const MaterialCSPtr& material) noexcept;\n        \n        /// Sets the material for a single mesh.\n        ///\n        /// @param material\n        ///     The material that should be used.\n        /// @param meshIndex\n        ///     The index of the mesh.\n        ///\n        void SetMaterialForMesh(const MaterialCSPtr& material, u32 meshIndex) noexcept;\n        \n        /// Sets the material for a single mesh.\n        ///\n        /// @param material\n        ///     The material that should be used.\n        /// @param meshName\n        ///     The name of the mesh\n        ///\n        void SetMaterialForMesh(const MaterialCSPtr& material, const std::string& meshName) noexcept;\n        \n        /// @return Whether the render component casts shadows\n        ///\n        bool IsShadowCastingEnabled() const noexcept;\n        \n        /// @param enabled\n        ///     Whether the render component casts shadows\n        ///\n        void SetShadowCastingEnabled(bool enabled) noexcept;\n        \n    private:\n        /// Triggered when the component is attached to an entity on the scene\n        ///\n        void OnAddedToScene() noexcept override;\n        \n        /// Delegate called when the owning entities transform changes. This is used to dirty\n        /// the bounding volumes\n        ///\n        void OnEntityTransformChanged() noexcept;\n        \n        /// Called during the render snapshot phase. Adds render objects to the scene\n        /// describing the model.\n        ///\n        /// @param renderSnapshot\n        ///     The render snapshot.\n        /// @param frameAllocator\n        ///     Allocate any memory required for rendering stuff from here\n        ///\n        void OnRenderSnapshot(RenderSnapshot& renderSnapshot, IAllocator* frameAllocator) noexcept override;\n        \n        /// Triggered when the component is removed from an entity on the scene.\n        ///\n        void OnRemovedFromScene() noexcept override;\n        \n        ModelCSPtr m_model;\n        std::vector<MaterialCSPtr> m_materials;\n        AABB m_aabb;\n        OOBB m_oobb;\n        Sphere m_boundingSphere;\n        bool m_shadowCastingEnabled = true;\n        bool m_isVisible = true;\n        \n        bool m_isAABBValid = false;\n        bool m_isOOBBValid = false;\n        bool m_isBoundingSphereValid = false;\n        EventConnectionUPtr m_transformChangedConnection;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Model/VertexFormat.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2010 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Model/VertexFormat.h>\n\nnamespace ChilliSource\n{\n    namespace\n    {\n        const std::vector<VertexFormat::ElementType> k_staticMeshElements =\n        {\n            VertexFormat::ElementType::k_position4,\n            VertexFormat::ElementType::k_normal3,\n            VertexFormat::ElementType::k_tangent3,\n            VertexFormat::ElementType::k_bitangent3,\n            VertexFormat::ElementType::k_uv2\n        };\n        \n        const std::vector<VertexFormat::ElementType> k_animatedMeshElements =\n        {\n            VertexFormat::ElementType::k_position4,\n            VertexFormat::ElementType::k_normal3,\n            VertexFormat::ElementType::k_tangent3,\n            VertexFormat::ElementType::k_bitangent3,\n            VertexFormat::ElementType::k_uv2,\n            VertexFormat::ElementType::k_weight4,\n            VertexFormat::ElementType::k_jointIndex4\n        };\n        \n        const std::vector<VertexFormat::ElementType> k_spriteElements =\n        {\n            VertexFormat::ElementType::k_position4,\n            VertexFormat::ElementType::k_uv2,\n            VertexFormat::ElementType::k_colour4\n        };\n    }\n    \n    const VertexFormat VertexFormat::k_staticMesh(k_staticMeshElements);\n    const VertexFormat VertexFormat::k_animatedMesh(k_animatedMeshElements);\n    const VertexFormat VertexFormat::k_sprite(k_spriteElements);\n    \n    //------------------------------------------------------------------------------\n    VertexFormat::DataType VertexFormat::GetDataType(ElementType elementType) noexcept\n    {\n        switch (elementType)\n        {\n            case ElementType::k_position4:\n                return DataType::k_float;\n            case ElementType::k_normal3:\n                return DataType::k_float;\n            case ElementType::k_tangent3:\n                return DataType::k_float;\n            case ElementType::k_bitangent3:\n                return DataType::k_float;\n            case ElementType::k_uv2:\n                return DataType::k_float;\n            case ElementType::k_colour4:\n                return DataType::k_byte;\n            case ElementType::k_weight4:\n                return DataType::k_float;\n            case ElementType::k_jointIndex4:\n                return DataType::k_byte;\n            default:\n                CS_LOG_FATAL(\"Invalid vertex element type.\");\n                return DataType::k_byte;\n        }\n    }\n    \n    //------------------------------------------------------------------------------\n    u32 VertexFormat::GetNumComponents(ElementType elementType) noexcept\n    {\n        switch (elementType)\n        {\n            case ElementType::k_position4:\n                return 4;\n            case ElementType::k_normal3:\n                return 3;\n            case ElementType::k_tangent3:\n                return 3;\n            case ElementType::k_bitangent3:\n                return 3;\n            case ElementType::k_uv2:\n                return 2;\n            case ElementType::k_colour4:\n                return 4;\n            case ElementType::k_weight4:\n                return 4;\n            case ElementType::k_jointIndex4:\n                return 4;\n            default:\n                CS_LOG_FATAL(\"Invalid vertex element type.\");\n                return 0;\n        }\n    }\n    \n    //------------------------------------------------------------------------------\n    u32 VertexFormat::GetSize(ElementType elementType) noexcept\n    {\n        return GetSize(GetDataType(elementType)) * GetNumComponents(elementType);\n    }\n    \n    //------------------------------------------------------------------------------\n    u32 VertexFormat::GetSize(DataType dataType) noexcept\n    {\n        switch (dataType)\n        {\n            case DataType::k_byte:\n                return sizeof(u8);\n            case DataType::k_float:\n                return sizeof(f32);\n            default:\n                CS_LOG_FATAL(\"Invalid vertex data type.\");\n                return 0;\n        }\n    }\n    \n    //------------------------------------------------------------------------------\n    VertexFormat::VertexFormat(const std::vector<ElementType>& elements) noexcept\n        : m_numElements(u32(elements.size()))\n    {\n        for (u32 index = 0; index < m_numElements; ++index)\n        {\n            m_elements[index] = elements[index];\n            \n            m_size += GetSize(m_elements[index]);\n        }\n    }\n\n    //------------------------------------------------------------------------------\n    VertexFormat::ElementType VertexFormat::GetElement(u32 index) const noexcept\n    {\n        CS_ASSERT(index < m_numElements, \"Index out of bounds.\");\n        \n        return m_elements[index];\n    }\n\n    //------------------------------------------------------------------------------\n    u32 VertexFormat::GetElementOffset(u32 index) const noexcept\n    {\n        CS_ASSERT(index < m_numElements, \"Index out of bounds\");\n        \n        u32 offset = 0;\n        \n        for (u32 i = 0; i < index; ++i)\n        {\n            offset += GetSize(m_elements[i]);\n        }\n        \n        return offset;\n    }\n    \n    //------------------------------------------------------------------------------\n    bool VertexFormat::operator==(const VertexFormat& other) const noexcept\n    {\n        if (this == &other)\n        {\n            return true;\n        }\n        \n        if (m_numElements != other.m_numElements || m_size != other.m_size)\n        {\n            return false;\n        }\n        \n        for (u32 index = 0; index < m_numElements; ++index)\n        {\n            if (m_elements[index] != other.m_elements[index])\n            {\n                return false;\n            }\n        }\n        \n        return true;\n    }\n    \n    //------------------------------------------------------------------------------\n    bool VertexFormat::operator!=(const VertexFormat& other) const noexcept\n    {\n        return !(*this == other);\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Model/VertexFormat.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2010 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_MODEL_VERTEXFORMAT_H_\n#define _CHILLISOURCE_RENDERING_MODEL_VERTEXFORMAT_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Base/ByteColour.h>\n#include <ChilliSource/Core/Math/Vector2.h>\n#include <ChilliSource/Core/Math/Vector3.h>\n#include <ChilliSource/Core/Math/Vector4.h>\n\n#include <array>\n#include <vector>\n\nnamespace ChilliSource\n{\n    /// A container for the data in a single sprite vertex.\n    ///\n    struct SpriteVertex final\n    {\n        Vector4 m_position;\n        Vector2 m_texCoord;\n        ByteColour m_colour;\n    };\n    \n    /// A container for the data in a single static mesh vertex.\n    ///\n    struct StaticMeshVertex\n    {\n        Vector4 m_position;\n        Vector3 m_normal;\n        Vector3 m_tangent;\n        Vector3 m_bitangent;\n        Vector2 m_texCoord;\n    };\n    \n    /// Describes the format and layout of the vertices used in a single mesh. This\n    /// consists of a series of vertex elements.\n    ///\n    /// Standard format types describe the common formats used in the engine, but\n    /// custom types can also be declared.\n    ///\n    /// This is immutable and therefore thread-safe.\n    ///\n    class VertexFormat\n    {\n    public:\n        static constexpr u32 k_maxElements = 8;\n        \n        static const VertexFormat k_staticMesh;\n        static const VertexFormat k_animatedMesh;\n        static const VertexFormat k_sprite;\n        \n        /// An enum describing the various possible element types in a vertex format.\n        /// The number suffix indicates the number of components in the element, i.e\n        /// k_position4 represents a position vector with [ X, Y, Z, W ] components.\n        ///\n\t\t/// The order of this enum is important, as the elements are used as indices when\n\t\t/// setting shader attributes. See GLShader.cpp.\n        enum class ElementType\n        {\n            k_position4,\n            k_normal3,\n\t\t\tk_tangent3,\n\t\t\tk_bitangent3,\n            k_uv2,\n            k_colour4,\n            k_weight4,\n            k_jointIndex4\n  \n        };\n        \n        /// An enum describing the possible data types for each component in a vertex\n        /// element.\n        enum class DataType\n        {\n            k_byte,\n            k_float\n        };\n        \n        /// @param elementType\n        ///     The element type.\n        ///\n        /// @return The data type used for this element.\n        ///\n        static DataType GetDataType(ElementType elementType) noexcept;\n        \n        /// @param elementType\n        ///     The element type.\n        ///\n        /// @return The number of components that make up the given element type.\n        ///\n        static u32 GetNumComponents(ElementType elementType) noexcept;\n        \n        /// @param elementType\n        ///     The element type.\n        ///\n        /// @return The size of the given element type in bytes.\n        ///\n        static u32 GetSize(ElementType elementType) noexcept;\n        \n        /// @param dataType\n        ///     The data type.\n        ///\n        /// @return The size of the given data type in bytes.\n        ///\n        static u32 GetSize(DataType dataType) noexcept;\n        \n        VertexFormat() = default;\n        \n        /// Creates a new vertex format with the given vector of elements.\n        ///\n        /// @param elements\n        ///     The elements that make up the format.\n        ///\n        VertexFormat(const std::vector<ElementType>& elements) noexcept;\n        \n        /// @return The number of elements in the vertex format.\n        ///\n        u32 GetNumElements() const noexcept { return m_numElements; }\n        \n        /// Gets the element type at the requested index.\n        ///\n        /// @return index\n        ///     The index of the element\n        ///\n        /// @return The element at the requested index.\n        ///\n        ElementType GetElement(u32 index) const noexcept;\n        \n        /// @return The total size of the vertex this this describes in bytes.\n        ///\n        u32 GetSize() const noexcept { return m_size; }\n        \n        /// Gets the offset of the element at the given index.\n        ///\n        /// @param index\n        ///     The index of the element.\n        ///\n        /// @return The offset of the element at the given index.\n        ///\n        u32 GetElementOffset(u32 index) const noexcept;\n        \n        /// @param other\n        ///     The other vertex format to compare.\n        ///\n        /// @return Whether or not the two are equal in value.\n        ///\n        bool operator==(const VertexFormat& other) const noexcept;\n        \n        /// @param other\n        ///     The other vertex format to compare.\n        ///\n        /// @return Whether or not the two are inequal in value.\n        ///\n        bool operator!=(const VertexFormat& other) const noexcept;\n        \n    private:\n        u32 m_numElements = 0;\n        u32 m_size = 0;\n        std::array<ElementType, k_maxElements> m_elements;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Model.h",
    "content": "//\n//  Model.h\n//  ChilliSource\n//  Created by Ian Copland on 07/07/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n\n#ifndef _CHILLISOURCE_RENDERING_MODEL_H_\n#define _CHILLISOURCE_RENDERING_MODEL_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Rendering/Model/AnimatedModelComponent.h>\n#include <ChilliSource/Rendering/Model/CSAnimProvider.h>\n#include <ChilliSource/Rendering/Model/CSModelProvider.h>\n#include <ChilliSource/Rendering/Model/IndexFormat.h>\n#include <ChilliSource/Rendering/Model/MeshDesc.h>\n#include <ChilliSource/Rendering/Model/Model.h>\n#include <ChilliSource/Rendering/Model/ModelDesc.h>\n#include <ChilliSource/Rendering/Model/PolygonType.h>\n#include <ChilliSource/Rendering/Model/PrimitiveModelFactory.h>\n#include <ChilliSource/Rendering/Model/RenderDynamicMesh.h>\n#include <ChilliSource/Rendering/Model/RenderMesh.h>\n#include <ChilliSource/Rendering/Model/RenderMeshBatch.h>\n#include <ChilliSource/Rendering/Model/RenderMeshManager.h>\n#include <ChilliSource/Rendering/Model/RenderSkinnedAnimation.h>\n#include <ChilliSource/Rendering/Model/Skeleton.h>\n#include <ChilliSource/Rendering/Model/SkeletonDesc.h>\n#include <ChilliSource/Rendering/Model/SkinnedAnimation.h>\n#include <ChilliSource/Rendering/Model/SkinnedAnimationGroup.h>\n#include <ChilliSource/Rendering/Model/SmallMeshBatcher.h>\n#include <ChilliSource/Rendering/Model/StaticModelComponent.h>\n#include <ChilliSource/Rendering/Model/VertexFormat.h>\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Particle/Affector/AccelerationParticleAffector.cpp",
    "content": "//\n//  AccelerationParticleAffector.cpp\n//  ChilliSource\n//  Created by Ian Copland on 03/11/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Particle/Affector/AccelerationParticleAffector.h>\n\n#include <ChilliSource/Core/Math/MathUtils.h>\n#include <ChilliSource/Rendering/Particle/Particle.h>\n#include <ChilliSource/Rendering/Particle/ParticleEffect.h>\n#include <ChilliSource/Rendering/Particle/Affector/AccelerationParticleAffectorDef.h>\n\nnamespace ChilliSource\n{\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    AccelerationParticleAffector::AccelerationParticleAffector(const ParticleAffectorDef* in_affectorDef, dynamic_array<Particle>* in_particleArray)\n        : ParticleAffector(in_affectorDef, in_particleArray), m_particleAcceleration(in_particleArray->size())\n    {\n        //This can only be created by the AccelerationParticleAffectorDef so this is safe.\n        m_accelerationAffectorDef = static_cast<const AccelerationParticleAffectorDef*>(in_affectorDef);\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    void AccelerationParticleAffector::ActivateParticle(u32 in_index, f32 in_effectProgress)\n    {\n        CS_ASSERT(in_index >= 0 && in_index < m_particleAcceleration.size(), \"Index out of bounds!\");\n\n        m_particleAcceleration[in_index] = m_accelerationAffectorDef->GetAccelerationProperty()->GenerateValue(in_effectProgress);\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    void AccelerationParticleAffector::AffectParticles(f32 in_deltaTime, f32 in_effectProgress)\n    {\n        dynamic_array<Particle>* particleArray = GetParticleArray();\n        for (u32 i = 0; i < particleArray->size(); ++i)\n        {\n            Particle& particle = particleArray->at(i);\n            Vector3& acceleration = m_particleAcceleration[i];\n\n            particle.m_velocity += acceleration * in_deltaTime;\n        }\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Particle/Affector/AccelerationParticleAffector.h",
    "content": "//\n//  AccelerationParticleAffector.h\n//  ChilliSource\n//  Created by Ian Copland on 03/11/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_PARTICLE_AFFECTOR_ACCELERATIONPARTICLEAFFECTOR_H_\n#define _CHILLISOURCE_RENDERING_PARTICLE_AFFECTOR_ACCELERATIONPARTICLEAFFECTOR_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Base/Colour.h>\n#include <ChilliSource/Core/Container/dynamic_array.h>\n#include <ChilliSource/Rendering/Particle/Affector/ParticleAffector.h>\n\nnamespace ChilliSource\n{\n    //---------------------------------------------------------------------\n    /// A particle affector which will change the speed of particles over\n    /// time.\n    ///\n    /// @author Ian Copland\n    //---------------------------------------------------------------------\n    class AccelerationParticleAffector final : public ParticleAffector\n    {\n    public:\n        //----------------------------------------------------------------\n        /// Generates an acceleration for the activated particle.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The index of the particle to activate.\n        /// @param The current normalised (0.0 to 1.0) progress through\n        /// playback of the particle effect.\n        //----------------------------------------------------------------\n        void ActivateParticle(u32 in_index, f32 in_effectProgress) override;\n        //----------------------------------------------------------------\n        /// Accelerates all active particles.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The delta time.\n        /// @param The current normalised (0.0 to 1.0) progress through\n        /// playback of the particle effect.\n        //----------------------------------------------------------------\n        void AffectParticles(f32 in_deltaTime, f32 in_effectProgress) override;\n        //----------------------------------------------------------------\n        /// Destructor\n        ///\n        /// @author Ian Copland\n        //----------------------------------------------------------------\n        virtual ~AccelerationParticleAffector() {};\n    private:\n        friend class AccelerationParticleAffectorDef;\n        //----------------------------------------------------------------\n        /// Constructor.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The particle affector definition.\n        /// @param The particle array.\n        //----------------------------------------------------------------\n        AccelerationParticleAffector(const ParticleAffectorDef* in_affectorDef, dynamic_array<Particle>* in_particleArray);\n\n        const AccelerationParticleAffectorDef* m_accelerationAffectorDef = nullptr;\n        dynamic_array<Vector3> m_particleAcceleration;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Particle/Affector/AccelerationParticleAffectorDef.cpp",
    "content": "//\n//  AccelerationParticleAffectorDef.cpp\n//  ChilliSource\n//  Created by Ian Copland on 03/11/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Particle/Affector/AccelerationParticleAffectorDef.h>\n\n#include <ChilliSource/Rendering/Particle/Affector/AccelerationParticleAffector.h>\n#include <ChilliSource/Rendering/Particle/Property/ParticlePropertyFactory.h>\n\nnamespace ChilliSource\n{\n    CS_DEFINE_NAMEDTYPE(AccelerationParticleAffectorDef);\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    AccelerationParticleAffectorDef::AccelerationParticleAffectorDef(ParticlePropertyUPtr<Vector3> in_accelerationProperty)\n        : m_accelerationProperty(std::move(in_accelerationProperty))\n    {\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    AccelerationParticleAffectorDef::AccelerationParticleAffectorDef(const Json::Value& in_paramsJson, const LoadedDelegate& in_asyncDelegate)\n    {\n        //Acceleration\n        Json::Value jsonValue = in_paramsJson.get(\"AccelerationProperty\", Json::nullValue);\n        CS_ASSERT(jsonValue.isNull() == false, \"No acceleration property provided.\");\n        m_accelerationProperty = ParticlePropertyFactory::CreateProperty<Vector3>(jsonValue);\n\n        //call the loaded delegate if required.\n        if (in_asyncDelegate != nullptr)\n        {\n            in_asyncDelegate(this);\n        }\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    bool AccelerationParticleAffectorDef::IsA(InterfaceIDType in_interfaceId) const\n    {\n        return (ParticleAffectorDef::InterfaceID == in_interfaceId || AccelerationParticleAffectorDef::InterfaceID == in_interfaceId);\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    ParticleAffectorUPtr AccelerationParticleAffectorDef::CreateInstance(dynamic_array<Particle>* in_particleArray) const\n    {\n        return ParticleAffectorUPtr(new AccelerationParticleAffector(this, in_particleArray));\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    const ParticleProperty<Vector3>* AccelerationParticleAffectorDef::GetAccelerationProperty() const\n    {\n        return m_accelerationProperty.get();\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Particle/Affector/AccelerationParticleAffectorDef.h",
    "content": "//\n//  AccelerationParticleAffectorDef.h\n//  ChilliSource\n//  Created by Ian Copland on 03/11/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_PARTICLE_AFFECTOR_ACCELERATIONPARTICLEAFFECTORDEF_H_\n#define _CHILLISOURCE_RENDERING_PARTICLE_AFFECTOR_ACCELERATIONPARTICLEAFFECTORDEF_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Math/Vector3.h>\n#include <ChilliSource/Rendering/Particle/Affector/ParticleAffectorDef.h>\n#include <ChilliSource/Rendering/Particle/Property/ParticleProperty.h>\n\n#include <json/json.h>\n\nnamespace ChilliSource\n{\n    //-----------------------------------------------------------------------\n    /// The definition for an acceleration particle affector. This describes \n    /// a particle affector which will alter the speed of a particle over\n    /// time.\n    ///\n    /// An acceleration particle affector contains the following params:\n    ///\n    /// \"AccelerationProperty\": The property describing the acceleration of a\n    /// particle.\n    ///\n    /// @author Ian Copland\n    //-----------------------------------------------------------------------\n    class AccelerationParticleAffectorDef final : public ParticleAffectorDef\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(AccelerationParticleAffectorDef);\n        //----------------------------------------------------------------\n        /// Constructor.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The property which describes the acceleration of a\n        /// particle.\n        //----------------------------------------------------------------\n        AccelerationParticleAffectorDef(ParticlePropertyUPtr<Vector3> in_accelerationProperty);\n        //----------------------------------------------------------------\n        /// Constructor. Loads the params for the affector def from the \n        /// given param dictionary. If the async delegate is not null, then\n        /// any resource loading will occur as a background task. Once \n        /// complete the delegate will be called. The parameters read from\n        /// json are described in the class documentation.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param A json object describing the parameters for the particle\n        /// emitter def.\n        /// @param The loaded delegate. If this is supplied any resources\n        /// will be loaded as a background task. Once complete, this\n        /// delegate will be called.\n        //----------------------------------------------------------------\n        AccelerationParticleAffectorDef(const Json::Value& in_paramsJson, const LoadedDelegate& in_asyncDelegate = nullptr);\n        //----------------------------------------------------------------\n        /// Allows querying of whether or not this implements the interface \n        /// described by the given Id.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The interface Id.\n        ///\n        /// @return Whether or not the interface is implemented.\n        //----------------------------------------------------------------\n        bool IsA(InterfaceIDType in_interfaceId) const override;\n        //----------------------------------------------------------------\n        /// Creates an instance of the particle affector described by this.\n        ///\n        /// @author Ian Copland.\n        ///\n        /// @param The particle array.\n        ///\n        /// @return the instance.\n        //----------------------------------------------------------------\n        ParticleAffectorUPtr CreateInstance(dynamic_array<Particle>* in_particleArray) const override;\n        //----------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return A property describing the acceleration.\n        //----------------------------------------------------------------\n        const ParticleProperty<Vector3>* GetAccelerationProperty() const;\n        //----------------------------------------------------------------\n        /// Destructor\n        ///\n        /// @author Ian Copland.\n        //----------------------------------------------------------------\n        virtual ~AccelerationParticleAffectorDef() {}\n    private:\n\n        ParticlePropertyUPtr<Vector3> m_accelerationProperty;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Particle/Affector/AngularAccelerationParticleAffector.cpp",
    "content": "//\n//  AngularAccelerationParticleAffector.cpp\n//  ChilliSource\n//  Created by Ian Copland on 03/11/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Particle/Affector/AngularAccelerationParticleAffector.h>\n\n#include <ChilliSource/Core/Math/MathUtils.h>\n#include <ChilliSource/Rendering/Particle/Particle.h>\n#include <ChilliSource/Rendering/Particle/ParticleEffect.h>\n#include <ChilliSource/Rendering/Particle/Affector/AngularAccelerationParticleAffectorDef.h>\n\nnamespace ChilliSource\n{\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    AngularAccelerationParticleAffector::AngularAccelerationParticleAffector(const ParticleAffectorDef* in_affectorDef, dynamic_array<Particle>* in_particleArray)\n        : ParticleAffector(in_affectorDef, in_particleArray), m_particleAngularAcceleration(in_particleArray->size())\n    {\n        //This can only be created by the AngularAccelerationParticleAffectorDef so this is safe.\n        m_angularAccelerationAffectorDef = static_cast<const AngularAccelerationParticleAffectorDef*>(in_affectorDef);\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    void AngularAccelerationParticleAffector::ActivateParticle(u32 in_index, f32 in_effectProgress)\n    {\n        CS_ASSERT(in_index >= 0 && in_index < m_particleAngularAcceleration.size(), \"Index out of bounds!\");\n\n        m_particleAngularAcceleration[in_index] = m_angularAccelerationAffectorDef->GetAngularAccelerationProperty()->GenerateValue(in_effectProgress);\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    void AngularAccelerationParticleAffector::AffectParticles(f32 in_deltaTime, f32 in_effectProgress)\n    {\n        dynamic_array<Particle>* particleArray = GetParticleArray();\n        for (u32 i = 0; i < particleArray->size(); ++i)\n        {\n            Particle& particle = particleArray->at(i);\n            f32 angularAcceleration = m_particleAngularAcceleration[i];\n            particle.m_angularVelocity += angularAcceleration * in_deltaTime;\n        }\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Particle/Affector/AngularAccelerationParticleAffector.h",
    "content": "//\n//  AngularAccelerationParticleAffector.h\n//  ChilliSource\n//  Created by Ian Copland on 03/11/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_PARTICLE_AFFECTOR_ANGULARACCELERATIONPARTICLEAFFECTOR_H_\n#define _CHILLISOURCE_RENDERING_PARTICLE_AFFECTOR_ANGULARACCELERATIONPARTICLEAFFECTOR_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Container/dynamic_array.h>\n#include <ChilliSource/Rendering/Particle/Affector/ParticleAffector.h>\n\nnamespace ChilliSource\n{\n    //---------------------------------------------------------------------\n    /// A particle affector which will change the angular velocity of a\n    /// particle over time.\n    ///\n    /// @author Ian Copland\n    //---------------------------------------------------------------------\n    class AngularAccelerationParticleAffector final : public ParticleAffector\n    {\n    public:\n        //----------------------------------------------------------------\n        /// Generates a new angular acceleration from the property for\n        /// the activated particle.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The index of the particle to activate.\n        /// @param The current normalised (0.0 to 1.0) progress through\n        /// playback of the particle effect.\n        //----------------------------------------------------------------\n        void ActivateParticle(u32 in_index, f32 in_effectProgress) override;\n        //----------------------------------------------------------------\n        /// Angularly accelerates each active particle.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The delta time.\n        /// @param The current normalised (0.0 to 1.0) progress through\n        /// playback of the particle effect.\n        //----------------------------------------------------------------\n        void AffectParticles(f32 in_deltaTime, f32 in_effectProgress) override;\n        //----------------------------------------------------------------\n        /// Destructor\n        ///\n        /// @author Ian Copland\n        //----------------------------------------------------------------\n        virtual ~AngularAccelerationParticleAffector() {};\n    private:\n        friend class AngularAccelerationParticleAffectorDef;\n        //----------------------------------------------------------------\n        /// Constructor.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The particle affector definition.\n        /// @param The particle array.\n        //----------------------------------------------------------------\n        AngularAccelerationParticleAffector(const ParticleAffectorDef* in_affectorDef, dynamic_array<Particle>* in_particleArray);\n\n        const AngularAccelerationParticleAffectorDef* m_angularAccelerationAffectorDef = nullptr;\n        dynamic_array<f32> m_particleAngularAcceleration;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Particle/Affector/AngularAccelerationParticleAffectorDef.cpp",
    "content": "//\n//  AngularAccelerationParticleAffectorDef.cpp\n//  ChilliSource\n//  Created by Ian Copland on 03/11/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Particle/Affector/AngularAccelerationParticleAffectorDef.h>\n\n#include <ChilliSource/Rendering/Particle/Affector/AngularAccelerationParticleAffector.h>\n#include <ChilliSource/Rendering/Particle/Property/ParticlePropertyFactory.h>\n\nnamespace ChilliSource\n{\n    CS_DEFINE_NAMEDTYPE(AngularAccelerationParticleAffectorDef);\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    AngularAccelerationParticleAffectorDef::AngularAccelerationParticleAffectorDef(ParticlePropertyUPtr<f32> in_angularAccelerationProperty)\n        : m_angularAccelerationProperty(std::move(in_angularAccelerationProperty))\n    {\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    AngularAccelerationParticleAffectorDef::AngularAccelerationParticleAffectorDef(const Json::Value& in_paramsJson, const LoadedDelegate& in_asyncDelegate)\n    {\n        //Angular Acceleration\n        Json::Value jsonValue = in_paramsJson.get(\"AngularAccelerationProperty\", Json::nullValue);\n        CS_ASSERT(jsonValue.isNull() == false, \"No angular acceleration property provided.\");\n        m_angularAccelerationProperty = ParticlePropertyFactory::CreateProperty<f32>(jsonValue);\n\n        //call the loaded delegate if required.\n        if (in_asyncDelegate != nullptr)\n        {\n            in_asyncDelegate(this);\n        }\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    bool AngularAccelerationParticleAffectorDef::IsA(InterfaceIDType in_interfaceId) const\n    {\n        return (ParticleAffectorDef::InterfaceID == in_interfaceId || AngularAccelerationParticleAffectorDef::InterfaceID == in_interfaceId);\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    ParticleAffectorUPtr AngularAccelerationParticleAffectorDef::CreateInstance(dynamic_array<Particle>* in_particleArray) const\n    {\n        return ParticleAffectorUPtr(new AngularAccelerationParticleAffector(this, in_particleArray));\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    const ParticleProperty<f32>* AngularAccelerationParticleAffectorDef::GetAngularAccelerationProperty() const\n    {\n        return m_angularAccelerationProperty.get();\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Particle/Affector/AngularAccelerationParticleAffectorDef.h",
    "content": "//\n//  AngularAccelerationParticleAffectorDef.h\n//  ChilliSource\n//  Created by Ian Copland on 03/11/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_PARTICLE_AFFECTOR_ANGULARACCELERATIONPARTICLEAFFECTORDEF_H_\n#define _CHILLISOURCE_RENDERING_PARTICLE_AFFECTOR_ANGULARACCELERATIONPARTICLEAFFECTORDEF_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Rendering/Particle/Affector/ParticleAffectorDef.h>\n#include <ChilliSource/Rendering/Particle/Property/ParticleProperty.h>\n\n#include <json/json.h>\n\nnamespace ChilliSource\n{\n    //-----------------------------------------------------------------------\n    /// The definition for an angular acceleration particle affector. This\n    /// describes a particle effector which will change the angular velocity\n    /// of a particle over time.\n    ///\n    /// An angular acceleration particle affector contains the following \n    /// params:\n    ///\n    /// \"AngularAccelerationProperty\": The property describing the angular\n    /// acceleration.\n    ///\n    /// @author Ian Copland\n    //-----------------------------------------------------------------------\n    class AngularAccelerationParticleAffectorDef final : public ParticleAffectorDef\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(AngularAccelerationParticleAffectorDef);\n        //----------------------------------------------------------------\n        /// Constructor.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The property which describes the angular acceleration.\n        //----------------------------------------------------------------\n        AngularAccelerationParticleAffectorDef(ParticlePropertyUPtr<f32> in_angularAccelerationProperty);\n        //----------------------------------------------------------------\n        /// Constructor. Loads the params for the affector def from the \n        /// given param dictionary. If the async delegate is not null, then\n        /// any resource loading will occur as a background task. Once \n        /// complete the delegate will be called. The parameters read from\n        /// json are described in the class documentation.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param A json object describing the parameters for the particle\n        /// emitter def.\n        /// @param The loaded delegate. If this is supplied any resources\n        /// will be loaded as a background task. Once complete, this\n        /// delegate will be called.\n        //----------------------------------------------------------------\n        AngularAccelerationParticleAffectorDef(const Json::Value& in_paramsJson, const LoadedDelegate& in_asyncDelegate = nullptr);\n        //----------------------------------------------------------------\n        /// Allows querying of whether or not this implements the interface \n        /// described by the given Id.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The interface Id.\n        ///\n        /// @return Whether or not the interface is implemented.\n        //----------------------------------------------------------------\n        bool IsA(InterfaceIDType in_interfaceId) const override;\n        //----------------------------------------------------------------\n        /// Creates an instance of the particle affector described by this.\n        ///\n        /// @author Ian Copland.\n        ///\n        /// @param The particle array.\n        ///\n        /// @return the instance.\n        //----------------------------------------------------------------\n        ParticleAffectorUPtr CreateInstance(dynamic_array<Particle>* in_particleArray) const override;\n        //----------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return A property describing the angular acceleration.\n        //----------------------------------------------------------------\n        const ParticleProperty<f32>* GetAngularAccelerationProperty() const;\n        //----------------------------------------------------------------\n        /// Destructor\n        ///\n        /// @author Ian Copland.\n        //----------------------------------------------------------------\n        virtual ~AngularAccelerationParticleAffectorDef() {}\n    private:\n\n        ParticlePropertyUPtr<f32> m_angularAccelerationProperty;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Particle/Affector/ColourOverLifetimeParticleAffector.cpp",
    "content": "//\n//  ColourOverLifetimeParticleAffector.cpp\n//  ChilliSource\n//  Created by Ian Copland on 02/11/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Particle/Affector/ColourOverLifetimeParticleAffector.h>\n\n#include <ChilliSource/Core/Math/MathUtils.h>\n#include <ChilliSource/Rendering/Particle/Particle.h>\n#include <ChilliSource/Rendering/Particle/ParticleEffect.h>\n#include <ChilliSource/Rendering/Particle/Affector/ColourOverLifetimeParticleAffectorDef.h>\n\nnamespace ChilliSource\n{\n    namespace\n    {\n        //----------------------------------------------------------------\n        /// @author Nicolas Tanda\n        ///\n        /// @param Value to clamp\n        ///\n        /// @return The value clamped between 0.0f and 1.0f\n        //----------------------------------------------------------------\n        f32 Clamp(f32 in_value)\n        {\n            return MathUtils::Clamp(in_value, 0.0f, 1.0f);\n        }\n    }\n    \n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    ColourOverLifetimeParticleAffector::ColourOverLifetimeParticleAffector(const ParticleAffectorDef* in_affectorDef, dynamic_array<Particle>* in_particleArray)\n    :ParticleAffector(in_affectorDef, in_particleArray)\n    ,m_particleColourData(0)\n    {\n        m_colourOverLifetimeAffectorDef = static_cast<const ColourOverLifetimeParticleAffectorDef*>(in_affectorDef);\n        m_intermediateParticles = static_cast<u32>(m_colourOverLifetimeAffectorDef->GetIntermediateColours().size());\n        m_particleColourData = dynamic_array<ColourData>(in_particleArray->size() * (2 + m_intermediateParticles));\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    void ColourOverLifetimeParticleAffector::ActivateParticle(u32 in_index, f32 in_effectProgress)\n    {\n        u32 colourDataIndex = in_index * (2 + m_intermediateParticles);\n        CS_ASSERT(colourDataIndex >= 0 && colourDataIndex < m_particleColourData.size(), \"colourDataIndex out of bounds!\");\n        \n        ColourData& colourDataInitial = m_particleColourData[colourDataIndex];\n        const Particle& particle = GetParticleArray()->at(in_index);\n        \n        colourDataInitial.m_time = 0.0f;\n        colourDataInitial.m_colour = particle.m_colour;\n        ++colourDataIndex;\n        \n        // Get the intermediate colours\n        std::vector<ColourData> intermediateColours;\n        intermediateColours.reserve(m_intermediateParticles);\n        for(const auto& intermediateColour : m_colourOverLifetimeAffectorDef->GetIntermediateColours())\n        {\n            intermediateColours.push_back(ColourData());\n            intermediateColours.back().m_colour = intermediateColour.m_colourProperty->GenerateValue(in_effectProgress);\n            intermediateColours.back().m_time = intermediateColour.m_timeProperty->GenerateValue(in_effectProgress);\n        }\n        \n        // Sort by time\n        std::sort(intermediateColours.begin(), intermediateColours.end(), [](const ColourData& in_r, const ColourData& in_l)-> bool\n        {\n            return in_r.m_time < in_l.m_time;\n        });\n        \n        // Add to the particles colour data\n        for(const auto& intermediateColour : intermediateColours)\n        {\n            ColourData& colourDataIntermediate = m_particleColourData[colourDataIndex];\n            colourDataIntermediate = intermediateColour;\n            ++colourDataIndex;\n        }\n        \n        ColourData& colourDataTarget = m_particleColourData[colourDataIndex];\n        colourDataTarget.m_time = 1.0f;\n        colourDataTarget.m_colour = m_colourOverLifetimeAffectorDef->GetTargetColourProperty()->GenerateValue(in_effectProgress);\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    void ColourOverLifetimeParticleAffector::AffectParticles(f32 in_deltaTime, f32 in_effectProgress)\n    {\n        const auto& interpolation = m_colourOverLifetimeAffectorDef->GetInterpolation();\n        \n        dynamic_array<Particle>* particleArray = GetParticleArray();\n        for (u32 i = 0; i < particleArray->size(); ++i)\n        {\n            Particle& particle = particleArray->at(i);\n            \n            if(particle.m_isActive == false)\n            {\n                continue;\n            }\n            \n            u32 colourIndex = i * (2 + m_intermediateParticles);\n            ColourData& colourDataInitial = m_particleColourData[colourIndex];\n\n            f32 normalisedLifeProgress = 1.0f - (particle.m_energy / particle.m_lifetime);\n            f32 progress = interpolation(normalisedLifeProgress);\n            \n            particle.m_colour = colourDataInitial.m_colour;\n            for(u32 offset = 0; offset < m_intermediateParticles + 1; ++offset)\n            {\n                ColourData& colourData = m_particleColourData[colourIndex + offset];\n                ColourData& colourDataNext = m_particleColourData[colourIndex + offset + 1];\n                f32 timeProgress = Clamp(Clamp(progress - colourData.m_time) / (colourDataNext.m_time - colourData.m_time));\n                particle.m_colour += (colourDataNext.m_colour - colourData.m_colour) * timeProgress;\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Particle/Affector/ColourOverLifetimeParticleAffector.h",
    "content": "//\n//  ColourOverLifetimeParticleAffector.h\n//  ChilliSource\n//  Created by Ian Copland on 02/11/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_PARTICLE_AFFECTOR_COLOUROVERLIFETIMEPARTICLEAFFECTOR_H_\n#define _CHILLISOURCE_RENDERING_PARTICLE_AFFECTOR_COLOUROVERLIFETIMEPARTICLEAFFECTOR_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Base/Colour.h>\n#include <ChilliSource/Core/Container/dynamic_array.h>\n#include <ChilliSource/Rendering/Particle/Affector/ParticleAffector.h>\n\nnamespace ChilliSource\n{\n    //---------------------------------------------------------------------\n    /// A particle affector which will change the colour of particles over\n    /// its lifetime.\n    ///\n    /// @author Ian Copland\n    //---------------------------------------------------------------------\n    class ColourOverLifetimeParticleAffector final : public ParticleAffector\n    {\n    public:\n        //----------------------------------------------------------------\n        /// Stores the initial colour and generates a target colour for the\n        /// activated particle so it can be used to generate the \n        /// interpolated colour during updates.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The index of the particle to activate.\n        /// @param The current normalised (0.0 to 1.0) progress through\n        /// playback of the particle effect.\n        //----------------------------------------------------------------\n        void ActivateParticle(u32 in_index, f32 in_effectProgress) override;\n        //----------------------------------------------------------------\n        /// Updates the colour of each particle.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The delta time.\n        /// @param The current normalised (0.0 to 1.0) progress through\n        /// playback of the particle effect.\n        //----------------------------------------------------------------\n        void AffectParticles(f32 in_deltaTime, f32 in_effectProgress) override;\n        //----------------------------------------------------------------\n        /// Destructor\n        ///\n        /// @author Ian Copland\n        //----------------------------------------------------------------\n        virtual ~ColourOverLifetimeParticleAffector() {};\n        \n    private:\n        friend class ColourOverLifetimeParticleAffectorDef;\n        //----------------------------------------------------------------\n        /// A container for the colours of a single particle.\n        ///\n        /// @author Nicolas Tanda\n        //----------------------------------------------------------------\n        struct ColourData final\n        {\n            Colour m_colour;\n            f32 m_time;\n        };\n        //----------------------------------------------------------------\n        /// Constructor.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The particle affector definition.\n        /// @param The particle array.\n        //----------------------------------------------------------------\n        ColourOverLifetimeParticleAffector(const ParticleAffectorDef* in_affectorDef, dynamic_array<Particle>* in_particleArray);\n        \n    private:\n        const ColourOverLifetimeParticleAffectorDef* m_colourOverLifetimeAffectorDef = nullptr;\n        dynamic_array<ColourData> m_particleColourData;\n        \n        u32 m_intermediateParticles = 0;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Particle/Affector/ColourOverLifetimeParticleAffectorDef.cpp",
    "content": "//\n//  ColourOverLifetimeParticleAffectorDef.cpp\n//  ChilliSource\n//  Created by Ian Copland on 02/11/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Particle/Affector/ColourOverLifetimeParticleAffectorDef.h>\n\n#include <ChilliSource/Rendering/Particle/Affector/ColourOverLifetimeParticleAffector.h>\n#include <ChilliSource/Rendering/Particle/Property/ParticlePropertyFactory.h>\n\nnamespace ChilliSource\n{\n    namespace\n    {\n        const char k_intermediateColours[] = \"IntermediateColours\";\n        const char k_targetColourProperty[] = \"TargetColourProperty\";\n        const char k_colourProperty[] = \"ColourProperty\";\n        const char k_timeProperty[] = \"TimeProperty\";\n        \n        const char k_interpolationKey[] = \"Interpolation\";\n        const char k_defaultInterpolation[] = \"Linear\";\n    }\n    \n    CS_DEFINE_NAMEDTYPE(ColourOverLifetimeParticleAffectorDef);\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    ColourOverLifetimeParticleAffectorDef::IntermediateColour::IntermediateColour(IntermediateColour&& in_toMove)\n    {\n        m_colourProperty = std::move(in_toMove.m_colourProperty);\n        m_timeProperty = std::move(in_toMove.m_timeProperty);\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    ColourOverLifetimeParticleAffectorDef::IntermediateColour& ColourOverLifetimeParticleAffectorDef::IntermediateColour::operator=(IntermediateColour&& in_toMove)\n    {\n        m_colourProperty = std::move(in_toMove.m_colourProperty);\n        m_timeProperty = std::move(in_toMove.m_timeProperty);\n\n        return *this;\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    ColourOverLifetimeParticleAffectorDef::ColourOverLifetimeParticleAffectorDef(ParticlePropertyUPtr<Colour> in_targetColour, std::vector<IntermediateColour> in_intermediateColours,\n        const std::function<f32(f32)>& in_interpolation)\n        : m_targetColourProperty(std::move(in_targetColour)), m_intermediateColours(std::move(in_intermediateColours)), m_interpolation(in_interpolation)\n    {\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    ColourOverLifetimeParticleAffectorDef::ColourOverLifetimeParticleAffectorDef(const Json::Value& in_paramsJson, const LoadedDelegate& in_asyncDelegate)\n    {\n        // Target Colour\n        const auto& jsonValue = in_paramsJson.get(k_targetColourProperty, Json::nullValue);\n        CS_ASSERT(jsonValue.isNull() == false, \"No target colour property provided.\");\n        m_targetColourProperty = ParticlePropertyFactory::CreateProperty<Colour>(jsonValue);\n        \n        // Intermediate Colours\n        const auto& jsonArray = in_paramsJson.get(k_intermediateColours, Json::nullValue);\n        m_intermediateColours.reserve(jsonArray.size());\n        for(const auto& jsonIntermediateColour : jsonArray)\n        {\n            m_intermediateColours.push_back(IntermediateColour());\n            \n            const auto& jsonColour = jsonIntermediateColour.get(k_colourProperty, Json::nullValue);\n            m_intermediateColours.back().m_colourProperty = ParticlePropertyFactory::CreateProperty<Colour>(jsonColour);\n            \n            const auto& jsonTime = jsonIntermediateColour.get(k_timeProperty, Json::nullValue);\n            m_intermediateColours.back().m_timeProperty = ParticlePropertyFactory::CreateProperty<f32>(jsonTime);\n        }\n        \n        // Curve\n        auto interpolationName = in_paramsJson.get(k_interpolationKey, k_defaultInterpolation).asString();\n        m_interpolation = Interpolate::GetInterpolateFunction(interpolationName);\n\n        // Call the loaded delegate if required.\n        if (in_asyncDelegate != nullptr)\n        {\n            in_asyncDelegate(this);\n        }\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    bool ColourOverLifetimeParticleAffectorDef::IsA(InterfaceIDType in_interfaceId) const\n    {\n        return (ParticleAffectorDef::InterfaceID == in_interfaceId || ColourOverLifetimeParticleAffectorDef::InterfaceID == in_interfaceId);\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    ParticleAffectorUPtr ColourOverLifetimeParticleAffectorDef::CreateInstance(dynamic_array<Particle>* in_particleArray) const\n    {\n        return ParticleAffectorUPtr(new ColourOverLifetimeParticleAffector(this, in_particleArray));\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    const ParticleProperty<Colour>* ColourOverLifetimeParticleAffectorDef::GetTargetColourProperty() const\n    {\n        return m_targetColourProperty.get();\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    const std::function<f32(f32)>& ColourOverLifetimeParticleAffectorDef::GetInterpolation() const\n    {\n        return m_interpolation;\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    const std::vector<ColourOverLifetimeParticleAffectorDef::IntermediateColour>& ColourOverLifetimeParticleAffectorDef::GetIntermediateColours() const\n    {\n        return m_intermediateColours;\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Particle/Affector/ColourOverLifetimeParticleAffectorDef.h",
    "content": "//\n//  ColourOverLifetimeParticleAffectorDef.h\n//  ChilliSource\n//  Created by Ian Copland on 02/11/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_PARTICLE_AFFECTOR_COLOUROVERLIFETIMEPARTICLEAFFECTORDEF_H_\n#define _CHILLISOURCE_RENDERING_PARTICLE_AFFECTOR_COLOUROVERLIFETIMEPARTICLEAFFECTORDEF_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Base/Colour.h>\n#include <ChilliSource/Rendering/Particle/Affector/ParticleAffectorDef.h>\n#include <ChilliSource/Rendering/Particle/Property/ParticleProperty.h>\n#include <ChilliSource/Core/Math/Interpolate.h>\n\n#include <json/json.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    /// The definition for a Colour Over Lifetime particle affector. This\n    /// describes a particle effector which will change the colour of a particle \n    /// from its initial colour to the defined colour over the course of the \n    /// particles life.\n    ///\n    /// A colour over lifetime particle affector contains the following params:\n    ///\n    /// \"TargetColourProperty\": The property describing the target colour.\n    ///\n    /// \"IntermediateColours\": The list of intermediate colours to go through\n    /// before interpolating to the target colour. Each intermediate colour\n    /// has the following properties:\n    ///\n    ///     \"ColourProperty\": The property describing the intermediate colour.\n    ///\n    ///     \"TimeProperty\": The property defining the target time for that\n    ///     colour.\n    ///\n    /// \"Interpolation\": The interpolation curve used to transition from one\n    /// colour to another.\n    ///\n    /// @author Nicolas Tanda\n    //------------------------------------------------------------------------------\n    class ColourOverLifetimeParticleAffectorDef final : public ParticleAffectorDef\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(ColourOverLifetimeParticleAffectorDef);\n        //------------------------------------------------------------------------------\n        /// Definition of an intermediate colour of a single particle.\n        ///\n        /// @author Nicolas Tanda\n        //------------------------------------------------------------------------------\n        struct IntermediateColour final\n        {\n            ParticlePropertyUPtr<Colour> m_colourProperty;\n            ParticlePropertyUPtr<f32> m_timeProperty;\n\n            //------------------------------------------------------------------------------\n            /// As the move constructor is explicit, the constructor also needs to be.\n            ///\n            /// @author Ian Copland\n            //------------------------------------------------------------------------------\n            IntermediateColour() = default;\n            //------------------------------------------------------------------------------\n            /// Visual C++ 12 doesn't support implicit move constructors so for now they \n            /// need to be manually specified.\n            ///\n            /// @author Ian Copland\n            //------------------------------------------------------------------------------\n            IntermediateColour(IntermediateColour&& in_toMove);\n            //------------------------------------------------------------------------------\n            /// Visual C++ 12 doesn't support implicit move assignment operators so for now\n            /// they need to be manually specified.\n            ///\n            /// @author Ian Copland\n            //------------------------------------------------------------------------------\n            IntermediateColour& operator=(IntermediateColour&& in_toMove);\n        };\n        //------------------------------------------------------------------------------\n        /// Constructor.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param in_targetColour - The property which describes the colour to change \n        /// to.\n        /// @param in_intermediateColours - [Optional] Intermediate colours to transition\n        /// to between the initial and target colours. \n        /// @param in_interpolation - [Optional] The function used for interpolation\n        /// between colours. Defaults to linear interpolation.\n        //------------------------------------------------------------------------------\n        ColourOverLifetimeParticleAffectorDef(ParticlePropertyUPtr<Colour> in_targetColour, std::vector<IntermediateColour> in_intermediateColours = std::vector<IntermediateColour>(), \n            const std::function<f32(f32)>& in_interpolation = Interpolate::Linear);\n        //------------------------------------------------------------------------------\n        /// Constructor. Loads the params for the affector def from the given param \n        /// dictionary. If the async delegate is not null, then any resource loading \n        /// will occur as a background task. Once complete the delegate will be called.\n        /// The parameters read from json are described in the class documentation.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param in_paramsJson - A json object describing the parameters for the \n        /// particle emitter def.\n        /// @param in_asyncDelegate - The loaded delegate. If this is supplied any\n        /// resources will be loaded as a background task. Once complete, this delegate \n        /// will be called.\n        //------------------------------------------------------------------------------\n        ColourOverLifetimeParticleAffectorDef(const Json::Value& in_paramsJson, const LoadedDelegate& in_asyncDelegate = nullptr);\n        //------------------------------------------------------------------------------\n        /// Allows querying of whether or not this implements the interface described \n        /// by the given Id.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param in_interfaceId - The interface Id.\n        ///\n        /// @return Whether or not the interface is implemented.\n        //------------------------------------------------------------------------------\n        bool IsA(InterfaceIDType in_interfaceId) const override;\n        //------------------------------------------------------------------------------\n        /// Creates an instance of the particle affector described by this.\n        ///\n        /// @author Ian Copland.\n        ///\n        /// @param in_particleArray - The particle array.\n        ///\n        /// @return the instance.\n        //------------------------------------------------------------------------------\n        ParticleAffectorUPtr CreateInstance(dynamic_array<Particle>* in_particleArray) const override;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return A property describing the target colour.\n        //------------------------------------------------------------------------------\n        const ParticleProperty<Colour>* GetTargetColourProperty() const;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The interpolation function used to transition between colours.\n        //------------------------------------------------------------------------------\n        const std::function<f32(f32)>& GetInterpolation() const;\n        //------------------------------------------------------------------------------\n        /// @author Nicolas Tanda\n        ///\n        /// @return An array of intermediate colours\n        //------------------------------------------------------------------------------\n        const std::vector<IntermediateColour>& GetIntermediateColours() const;\n        //------------------------------------------------------------------------------\n        /// Destructor\n        ///\n        /// @author Ian Copland.\n        //------------------------------------------------------------------------------\n        virtual ~ColourOverLifetimeParticleAffectorDef() {}\n        \n    private:\n        std::function<f32(f32)> m_interpolation;\n        ParticlePropertyUPtr<Colour> m_targetColourProperty;\n        \n        std::vector<IntermediateColour> m_intermediateColours;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Particle/Affector/ParticleAffector.cpp",
    "content": "//\n//  ParticleAffector.cpp\n//  ChilliSource\n//  Created by Ian Copland on 02/11/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Particle/Affector/ParticleAffector.h>\n\nnamespace ChilliSource\n{\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    ParticleAffector::ParticleAffector(const ParticleAffectorDef* in_affectorDef, dynamic_array<Particle>* in_particleArray)\n        : m_affectorDef(in_affectorDef), m_particleArray(in_particleArray)\n    {\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    const ParticleAffectorDef* ParticleAffector::GetAffectorDef() const\n    {\n        return m_affectorDef;\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    dynamic_array<Particle>* ParticleAffector::GetParticleArray() const\n    {\n        return m_particleArray;\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Particle/Affector/ParticleAffector.h",
    "content": "//\n//  ParticleAffector.h\n//  ChilliSource\n//  Created by Ian Copland on 21/10/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_PARTICLE_AFFECTOR_PARTICLEAFFECTOR_H_\n#define _CHILLISOURCE_RENDERING_PARTICLE_AFFECTOR_PARTICLEAFFECTOR_H_\n\n#include <ChilliSource/ChilliSource.h>\n\nnamespace ChilliSource\n{\n    //---------------------------------------------------------------------\n    /// The base class for all particle affectors. Particle affectors are \n    /// reponsible for applying any sort of effect to particles every update\n    /// frame.\n    ///\n    /// Particle affectors will be updated as part of a background task and \n    /// should not be accessed from other threads.\n    //---------------------------------------------------------------------\n    class ParticleAffector\n    {\n    public:\n        CS_DECLARE_NOCOPY(ParticleAffector);\n        //----------------------------------------------------------------\n        /// Constructor.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The particle affector definition.\n        /// @param The particle array.\n        //----------------------------------------------------------------\n        ParticleAffector(const ParticleAffectorDef* in_affectorDef, dynamic_array<Particle>* in_particleArray);\n        //----------------------------------------------------------------\n        /// Activates the particle with the given index.\n        ///\n        /// This will be called on a background thread.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The index of the particle to activate.\n        /// @param The current normalised (0.0 to 1.0) progress through\n        /// playback of the particle effect.\n        //----------------------------------------------------------------\n        virtual void ActivateParticle(u32 in_index, f32 in_effectProgress) = 0;\n        //----------------------------------------------------------------\n        /// Applies the affect to each of the active particles.\n        ///\n        /// This will be called on a background thread.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The delta time.\n        /// @param The current normalised (0.0 to 1.0) progress through\n        /// playback of the particle effect.\n        //----------------------------------------------------------------\n        virtual void AffectParticles(f32 in_deltaTime, f32 in_effectProgress) = 0;\n        //----------------------------------------------------------------\n        /// Destructor\n        ///\n        /// @author Ian Copland\n        //----------------------------------------------------------------\n        virtual ~ParticleAffector() {};\n    protected:\n        //----------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The particle affector definition\n        //----------------------------------------------------------------\n        const ParticleAffectorDef* GetAffectorDef() const;\n        //----------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The particle array.\n        //----------------------------------------------------------------\n        dynamic_array<Particle>* GetParticleArray() const;\n    private:\n\n        const ParticleAffectorDef* m_affectorDef = nullptr;\n        dynamic_array<Particle>* m_particleArray = nullptr;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Particle/Affector/ParticleAffectorDef.cpp",
    "content": "//\n//  ParticleAffectorDef.cpp\n//  ChilliSource\n//  Created by Ian Copland on 02/11/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Particle/Affector/ParticleAffectorDef.h>\n\nnamespace ChilliSource\n{\n    CS_DEFINE_NAMEDTYPE(ParticleAffectorDef);\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    const ParticleEffect* ParticleAffectorDef::GetParticleEffect() const\n    {\n        return m_particleEffect;\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    void ParticleAffectorDef::SetParticleEffect(const ParticleEffect* in_particleEffect)\n    {\n        m_particleEffect = in_particleEffect;\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Particle/Affector/ParticleAffectorDef.h",
    "content": "//\n//  ParticleAffectorDef.h\n//  ChilliSource\n//  Created by Ian Copland on 21/10/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_PARTICLE_AFFECTOR_PARTICLEAFFECTORDEF_H_\n#define _CHILLISOURCE_RENDERING_PARTICLE_AFFECTOR_PARTICLEAFFECTORDEF_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Base/QueryableInterface.h>\n\n#include <functional>\n\nnamespace ChilliSource\n{\n    //-----------------------------------------------------------------------\n    /// A particle affector def describes the properties that should be used \n    /// to create a particle affector and creates the affector instances.\n    ///\n    /// As a particle affector def's contents can potentially be read from \n    /// multiple threads, it is immutable after construction. The exception \n    /// to this is if it was created from a param dictionary with a \n    /// asynchronous delegate, in which case it is immutable after the\n    /// delegate is called. Classes inheriting from this should also follow \n    /// these rules.\n    ///\n    /// @author Ian Copland\n    //-----------------------------------------------------------------------\n    class ParticleAffectorDef : public QueryableInterface\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(ParticleAffectorDef);\n        CS_DECLARE_NOCOPY(ParticleAffectorDef);\n        //----------------------------------------------------------------\n        /// The affector def loaded delegate. This is used when background \n        /// loading the particle affector def, once it has finished loading \n        /// this delegate should be called.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The particle affector def.\n        //----------------------------------------------------------------\n        using LoadedDelegate = std::function<void(ParticleAffectorDef* in_affectorDef)>;\n        //----------------------------------------------------------------\n        /// Constructor.\n        ///\n        /// @author Ian Copland\n        //----------------------------------------------------------------\n        ParticleAffectorDef() = default;\n        //----------------------------------------------------------------\n        /// Creates an instance of the particle affector described by this.\n        ///\n        /// @author Ian Copland.\n        ///\n        /// @param The particle array.\n        ///\n        /// @return the instance.\n        //----------------------------------------------------------------\n        virtual ParticleAffectorUPtr CreateInstance(dynamic_array<Particle>* in_particleArray) const = 0;\n        //----------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The particle effect that owns this particle drawable\n        /// definition.\n        //----------------------------------------------------------------\n        const ParticleEffect* GetParticleEffect() const;\n        //----------------------------------------------------------------\n        /// Destructor\n        ///\n        /// @author Ian Copland.\n        //----------------------------------------------------------------\n        virtual ~ParticleAffectorDef() {}\n    private:\n        friend class ParticleEffect;\n        //----------------------------------------------------------------\n        /// Sets the owning particle effect. This can only be called by the \n        /// particle effect itself when this is added to it.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The particle effect.\n        //----------------------------------------------------------------\n        void SetParticleEffect(const ParticleEffect* in_particleEffect);\n\n        const ParticleEffect* m_particleEffect = nullptr;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Particle/Affector/ParticleAffectorDefFactory.cpp",
    "content": "//\n//  ParticleAffectorDefFactory.cpp\n//  ChilliSource\n//  Created by Ian Copland on 08/11/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Particle/Affector/ParticleAffectorDefFactory.h>\n\n#include <ChilliSource/Rendering/Particle/Affector/AccelerationParticleAffectorDef.h>\n#include <ChilliSource/Rendering/Particle/Affector/AngularAccelerationParticleAffectorDef.h>\n#include <ChilliSource/Rendering/Particle/Affector/ColourOverLifetimeParticleAffectorDef.h>\n#include <ChilliSource/Rendering/Particle/Affector/ScaleOverLifetimeParticleAffectorDef.h>\n\nnamespace ChilliSource\n{\n    CS_DEFINE_NAMEDTYPE(ParticleAffectorDefFactory);\n    //-----------------------------------------------------------------\n    //-----------------------------------------------------------------\n    ParticleAffectorDefFactoryUPtr ParticleAffectorDefFactory::Create()\n    {\n        return ParticleAffectorDefFactoryUPtr(new ParticleAffectorDefFactory());\n    }\n    //-----------------------------------------------------------------\n    //-----------------------------------------------------------------\n    bool ParticleAffectorDefFactory::IsA(InterfaceIDType in_interfaceId) const\n    {\n        return (ParticleAffectorDefFactory::InterfaceID == in_interfaceId);\n    }\n    //-----------------------------------------------------------------\n    //-----------------------------------------------------------------\n    void ParticleAffectorDefFactory::RegisterDefaults()\n    {\n        Register<AccelerationParticleAffectorDef>(\"Acceleration\");\n        Register<AngularAccelerationParticleAffectorDef>(\"AngularAcceleration\");\n        Register<ColourOverLifetimeParticleAffectorDef>(\"ColourOverLifetime\");\n        Register<ScaleOverLifetimeParticleAffectorDef>(\"ScaleOverLifetime\");\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Particle/Affector/ParticleAffectorDefFactory.h",
    "content": "//\n//  ParticleAffectorDefFactory.h\n//  ChilliSource\n//  Created by Ian Copland on 08/11/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _ICENGINE_RENDERING_PARTICLES_PARTICLEAFFECTORDEFFACTORY_H_\n#define _ICENGINE_RENDERING_PARTICLES_PARTICLEAFFECTORDEFFACTORY_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Base/GenericFactory.h>\n#include <ChilliSource/Core/Delegate/MakeDelegate.h>\n#include <ChilliSource/Rendering/Particle/Affector/ParticleAffectorDef.h>\n\n#include <json/json.h>\n\n#include <functional>\n#include <unordered_map>\n\nnamespace ChilliSource\n{\n    //--------------------------------------------------------------------------\n    /// A factory for creating particle affector definitions. This allows \n    /// particle affector definition types to be registered with the class. A\n    /// Particle Provider can then create new instances of the registered \n    /// affector def with a Json descriptor.\n    ///\n    /// @author Ian Copland\n    //--------------------------------------------------------------------------\n    class ParticleAffectorDefFactory final : public GenericFactory<ParticleAffectorDef>\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(ParticleAffectorDefFactory);\n        //-----------------------------------------------------------------\n        /// Allows querying of whether or not this implements the interface\n        /// described by the given interface Id.\n        /// \n        /// @author Ian Copland\n        ///\n        /// @param The interface Id.\n        ///\n        /// @return Whether this implements the interface.\n        //-----------------------------------------------------------------\n        bool IsA(InterfaceIDType in_interfaceId) const override;\n    private:\n        friend class Application;\n        //-----------------------------------------------------------------\n        /// A factory method for creating new instances of a particle \n        /// affector def factory.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @return The new instance of the system.\n        //-----------------------------------------------------------------\n        static ParticleAffectorDefFactoryUPtr Create();\n        //-----------------------------------------------------------------\n        /// Default constructor. Declared private to force the use of the\n        /// CreateSystem() method in Application.\n        ///\n        /// @author Ian Copland\n        //-----------------------------------------------------------------\n        ParticleAffectorDefFactory() = default;\n        //-----------------------------------------------------------------\n        /// Registers the default particle affector definitions.\n        ///\n        /// @author Ian Copland\n        //-----------------------------------------------------------------\n        void RegisterDefaults() override;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Particle/Affector/ScaleOverLifetimeParticleAffector.cpp",
    "content": "//\n//  ScaleOverLifetimeParticleAffector.cpp\n//  ChilliSource\n//  Created by Ian Copland on 03/11/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Particle/Affector/ScaleOverLifetimeParticleAffector.h>\n\n#include <ChilliSource/Core/Math/MathUtils.h>\n#include <ChilliSource/Rendering/Particle/Particle.h>\n#include <ChilliSource/Rendering/Particle/ParticleEffect.h>\n#include <ChilliSource/Rendering/Particle/Affector/ScaleOverLifetimeParticleAffectorDef.h>\n\nnamespace ChilliSource\n{\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    ScaleOverLifetimeParticleAffector::ScaleOverLifetimeParticleAffector(const ParticleAffectorDef* in_affectorDef, dynamic_array<Particle>* in_particleArray)\n        : ParticleAffector(in_affectorDef, in_particleArray), m_particleScaleData(in_particleArray->size())\n    {\n        //This can only be created by the ScaleOverLifetimeParticleAffectorDef so this is safe.\n        m_scaleOverLifetimeAffectorDef = static_cast<const ScaleOverLifetimeParticleAffectorDef*>(in_affectorDef);\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    void ScaleOverLifetimeParticleAffector::ActivateParticle(u32 in_index, f32 in_effectProgress)\n    {\n        CS_ASSERT(in_index >= 0 && in_index < m_particleScaleData.size(), \"Index out of bounds!\");\n\n        ScaleData& scaleData = m_particleScaleData[in_index];\n        const Particle& particle = GetParticleArray()->at(in_index);\n        \n        scaleData.m_initialScale = particle.m_scale;\n\n        scaleData.m_targetScale = scaleData.m_initialScale * m_scaleOverLifetimeAffectorDef->GetScaleProperty()->GenerateValue(in_effectProgress);\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    void ScaleOverLifetimeParticleAffector::AffectParticles(f32 in_deltaTime, f32 in_effectProgress)\n    {\n        dynamic_array<Particle>* particleArray = GetParticleArray();\n        for (u32 i = 0; i < particleArray->size(); ++i)\n        {\n            Particle& particle = particleArray->at(i);\n            ScaleData& scaleData = m_particleScaleData[i];\n\n            f32 normalisedLifeProgress = 1.0f - (particle.m_energy / particle.m_lifetime);\n            particle.m_scale = scaleData.m_initialScale + (scaleData.m_targetScale - scaleData.m_initialScale) * normalisedLifeProgress;\n        }\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Particle/Affector/ScaleOverLifetimeParticleAffector.h",
    "content": "//\n//  ScaleOverLifetimeParticleAffector.h\n//  ChilliSource\n//  Created by Ian Copland on 03/11/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_PARTICLE_AFFECTOR_SCALEOVERLIFETIMEPARTICLEAFFECTOR_H_\n#define _CHILLISOURCE_RENDERING_PARTICLE_AFFECTOR_SCALEOVERLIFETIMEPARTICLEAFFECTOR_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Math/Vector2.h>\n#include <ChilliSource/Core/Container/dynamic_array.h>\n#include <ChilliSource/Rendering/Particle/Affector/ParticleAffector.h>\n\nnamespace ChilliSource\n{\n    //---------------------------------------------------------------------\n    /// A particle affector which will change the size of particles over\n    /// its lifetime by the calculated scale factor.\n    ///\n    /// @author Ian Copland\n    //---------------------------------------------------------------------\n    class ScaleOverLifetimeParticleAffector final : public ParticleAffector\n    {\n    public:\n        //----------------------------------------------------------------\n        /// Stores the initial size and generates the scale factor for the\n        /// activated particle so it can be used to generate the \n        /// interpolated size during updates.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The index of the particle to activate.\n        /// @param The current normalised (0.0 to 1.0) progress through\n        /// playback of the particle effect.\n        //----------------------------------------------------------------\n        void ActivateParticle(u32 in_index, f32 in_effectProgress) override;\n        //----------------------------------------------------------------\n        /// Updates the size of each particle.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The delta time.\n        /// @param The current normalised (0.0 to 1.0) progress through\n        /// playback of the particle effect.\n        //----------------------------------------------------------------\n        void AffectParticles(f32 in_deltaTime, f32 in_effectProgress) override;\n        //----------------------------------------------------------------\n        /// Destructor\n        ///\n        /// @author Ian Copland\n        //----------------------------------------------------------------\n        virtual ~ScaleOverLifetimeParticleAffector() {};\n    private:\n        friend class ScaleOverLifetimeParticleAffectorDef;\n        //----------------------------------------------------------------\n        /// Constructor.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The particle affector definition.\n        /// @param The particle array.\n        //----------------------------------------------------------------\n        ScaleOverLifetimeParticleAffector(const ParticleAffectorDef* in_affectorDef, dynamic_array<Particle>* in_particleArray);\n        //----------------------------------------------------------------\n        /// A container for the initial scale and scale factor of a single \n        /// particle.\n        ///\n        /// @author Ian Copland.\n        //----------------------------------------------------------------\n        struct ScaleData\n        {\n            Vector2 m_initialScale;\n            Vector2 m_targetScale;\n        };\n\n        const ScaleOverLifetimeParticleAffectorDef* m_scaleOverLifetimeAffectorDef = nullptr;\n        dynamic_array<ScaleData> m_particleScaleData;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Particle/Affector/ScaleOverLifetimeParticleAffectorDef.cpp",
    "content": "//\n//  ScaleOverLifetimeParticleAffectorDef.cpp\n//  ChilliSource\n//  Created by Ian Copland on 03/11/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Particle/Affector/ScaleOverLifetimeParticleAffectorDef.h>\n\n#include <ChilliSource/Rendering/Particle/Affector/ScaleOverLifetimeParticleAffector.h>\n#include <ChilliSource/Rendering/Particle/Property/ParticlePropertyFactory.h>\n\nnamespace ChilliSource\n{\n    CS_DEFINE_NAMEDTYPE(ScaleOverLifetimeParticleAffectorDef);\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    ScaleOverLifetimeParticleAffectorDef::ScaleOverLifetimeParticleAffectorDef(ParticlePropertyUPtr<Vector2> in_scaleProperty)\n        : m_scaleProperty(std::move(in_scaleProperty))\n    {\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    ScaleOverLifetimeParticleAffectorDef::ScaleOverLifetimeParticleAffectorDef(const Json::Value& in_paramsJson, const LoadedDelegate& in_asyncDelegate)\n    {\n        //scale\n        Json::Value jsonValue = in_paramsJson.get(\"ScaleProperty\", Json::nullValue);\n        CS_ASSERT(jsonValue.isNull() == false, \"No scale property provided.\");\n        m_scaleProperty = ParticlePropertyFactory::CreateProperty<Vector2>(jsonValue);\n\n        //call the loaded delegate if required.\n        if (in_asyncDelegate != nullptr)\n        {\n            in_asyncDelegate(this);\n        }\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    bool ScaleOverLifetimeParticleAffectorDef::IsA(InterfaceIDType in_interfaceId) const\n    {\n        return (ParticleAffectorDef::InterfaceID == in_interfaceId || ScaleOverLifetimeParticleAffectorDef::InterfaceID == in_interfaceId);\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    ParticleAffectorUPtr ScaleOverLifetimeParticleAffectorDef::CreateInstance(dynamic_array<Particle>* in_particleArray) const\n    {\n        return ParticleAffectorUPtr(new ScaleOverLifetimeParticleAffector(this, in_particleArray));\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    const ParticleProperty<Vector2>* ScaleOverLifetimeParticleAffectorDef::GetScaleProperty() const\n    {\n        return m_scaleProperty.get();\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Particle/Affector/ScaleOverLifetimeParticleAffectorDef.h",
    "content": "//\n//  ScaleOverLifetimeParticleAffectorDef.h\n//  ChilliSource\n//  Created by Ian Copland on 03/11/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_PARTICLE_AFFECTOR_SCALEOVERLIFETIMEPARTICLEAFFECTORDEF_H_\n#define _CHILLISOURCE_RENDERING_PARTICLE_AFFECTOR_SCALEOVERLIFETIMEPARTICLEAFFECTORDEF_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Math/Vector2.h>\n#include <ChilliSource/Rendering/Particle/Affector/ParticleAffectorDef.h>\n#include <ChilliSource/Rendering/Particle/Property/ParticleProperty.h>\n\n#include <json/json.h>\n\nnamespace ChilliSource\n{\n    //-----------------------------------------------------------------------\n    /// The definition for a Scale Over Lifetime particle affector. This\n    /// describes a particle effector which will change the particle from its\n    /// initial size by the given scale factor over the course of the life\n    /// time of the particle.\n    ///\n    /// A scale over lifetime particle affector contains the following params:\n    ///\n    /// \"ScaleProperty\": The property describing the scale factor. \n    ///\n    /// @author Ian Copland\n    //-----------------------------------------------------------------------\n    class ScaleOverLifetimeParticleAffectorDef final : public ParticleAffectorDef\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(ScaleOverLifetimeParticleAffectorDef);\n        //----------------------------------------------------------------\n        /// Constructor.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The property which describes the scale factor.\n        //----------------------------------------------------------------\n        ScaleOverLifetimeParticleAffectorDef(ParticlePropertyUPtr<Vector2> in_scaleProperty);\n        //----------------------------------------------------------------\n        /// Constructor. Loads the params for the affector def from the \n        /// given param dictionary. If the async delegate is not null, then\n        /// any resource loading will occur as a background task. Once \n        /// complete the delegate will be called. The parameters read from\n        /// json are described in the class documentation.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param A json object describing the parameters for the particle\n        /// emitter def.\n        /// @param The loaded delegate. If this is supplied any resources\n        /// will be loaded as a background task. Once complete, this\n        /// delegate will be called.\n        //----------------------------------------------------------------\n        ScaleOverLifetimeParticleAffectorDef(const Json::Value& in_paramsJson, const LoadedDelegate& in_asyncDelegate = nullptr);\n        //----------------------------------------------------------------\n        /// Allows querying of whether or not this implements the interface \n        /// described by the given Id.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The interface Id.\n        ///\n        /// @return Whether or not the interface is implemented.\n        //----------------------------------------------------------------\n        bool IsA(InterfaceIDType in_interfaceId) const override;\n        //----------------------------------------------------------------\n        /// Creates an instance of the particle affector described by this.\n        ///\n        /// @author Ian Copland.\n        ///\n        /// @param The particle array.\n        ///\n        /// @return the instance.\n        //----------------------------------------------------------------\n        ParticleAffectorUPtr CreateInstance(dynamic_array<Particle>* in_particleArray) const override;\n        //----------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return A property describing the scale factor.\n        //----------------------------------------------------------------\n        const ParticleProperty<Vector2>* GetScaleProperty() const;\n        //----------------------------------------------------------------\n        /// Destructor\n        ///\n        /// @author Ian Copland.\n        //----------------------------------------------------------------\n        virtual ~ScaleOverLifetimeParticleAffectorDef() {}\n    private:\n\n        ParticlePropertyUPtr<Vector2> m_scaleProperty;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Particle/CSParticleProvider.cpp",
    "content": "//\n//  CSParticleProvider.cpp\n//  ChilliSource\n//  Created by Ian Copland on 04/11/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Particle/CSParticleProvider.h>\n\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/Json/JsonUtils.h>\n#include <ChilliSource/Core/String/StringParser.h>\n#include <ChilliSource/Core/Threading/TaskScheduler.h>\n#include <ChilliSource/Rendering/Particle/ParticleEffect.h>\n#include <ChilliSource/Rendering/Particle/Affector/ParticleAffectorDefFactory.h>\n#include <ChilliSource/Rendering/Particle/Drawable/ParticleDrawableDefFactory.h>\n#include <ChilliSource/Rendering/Particle/Emitter/ParticleEmitterDefFactory.h>\n#include <ChilliSource/Rendering/Particle/Property/ParticlePropertyFactory.h>\n\n#include <json/json.h>\n\nnamespace ChilliSource\n{\n    namespace\n    {\n        const std::string k_fileExtension = \"csparticle\";\n        //-----------------------------------------------------------------\n        /// A delegate called when one of the asynchronous loading stages \n        /// has completed.\n        ///\n        /// @author Ian Copland\n        //-----------------------------------------------------------------\n        using AsyncCompleteDelegate = std::function<void()>;\n        //-----------------------------------------------------------------\n        /// Parses a simulation space string value.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The string value.\n        ///\n        /// @return The simulation space described by the string.\n        //-----------------------------------------------------------------\n        ParticleEffect::SimulationSpace ParseSimulationSpace(const std::string& in_string)\n        {\n            std::string simulationSpaceString = in_string;\n            StringUtils::ToLowerCase(simulationSpaceString);\n\n            if (simulationSpaceString == \"world\")\n            {\n                return ParticleEffect::SimulationSpace::k_world;\n            }\n            else if (simulationSpaceString == \"local\")\n            {\n                return ParticleEffect::SimulationSpace::k_local;\n            }\n\n            CS_LOG_FATAL(\"Invalid simulation space in particle effect: \" + in_string);\n            return ParticleEffect::SimulationSpace::k_world;\n        }\n        //-----------------------------------------------------------------\n        /// Reads the base properties in the particle effect such as the\n        /// effect duration, the number of particles and the initial\n        /// particle values.\n        ///\n        /// This is thread-safe.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The root json object\n        /// @param [Out] The particle effect that should be populated.\n        //-----------------------------------------------------------------\n        void ReadBaseValues(const Json::Value& in_jsonRoot, const ParticleEffectSPtr& out_particleEffect)\n        {\n            //Duration\n            Json::Value jsonValue = in_jsonRoot.get(\"Duration\", Json::nullValue);\n            if (jsonValue.isNull() == false)\n            {\n                CS_ASSERT(jsonValue.isString(), \"Duration value must be a string.\");\n                out_particleEffect->SetDuration(ParseF32(jsonValue.asString()));\n            }\n\n            //Max Particles\n            jsonValue = in_jsonRoot.get(\"MaxParticles\", Json::nullValue);\n            if (jsonValue.isNull() == false)\n            {\n                CS_ASSERT(jsonValue.isString(), \"Max particles value must be a string.\");\n                out_particleEffect->SetMaxParticles(ParseU32(jsonValue.asString()));\n            }\n\n            //Simulation Space\n            jsonValue = in_jsonRoot.get(\"SimulationSpace\", Json::nullValue);\n            if (jsonValue.isNull() == false)\n            {\n                CS_ASSERT(jsonValue.isString(), \"SimulationSpace value must be a string.\");\n                out_particleEffect->SetSimulationSpace(ParseSimulationSpace(jsonValue.asString()));\n            }\n\n            //Lifetime Property\n            jsonValue = in_jsonRoot.get(\"LifetimeProperty\", Json::nullValue);\n            if (jsonValue.isNull() == false)\n            {\n                auto prop = ParticlePropertyFactory::CreateProperty<f32>(jsonValue);\n                out_particleEffect->SetLifetimeProperty(std::move(prop));\n            }\n\n            //Initial Scale Property\n            jsonValue = in_jsonRoot.get(\"InitialScaleProperty\", Json::nullValue);\n            if (jsonValue.isNull() == false)\n            {\n                auto prop = ParticlePropertyFactory::CreateProperty<Vector2>(jsonValue);\n                out_particleEffect->SetInitialScaleProperty(std::move(prop));\n            }\n\n            //Initial Rotation Property\n            jsonValue = in_jsonRoot.get(\"InitialRotationProperty\", Json::nullValue);\n            if (jsonValue.isNull() == false)\n            {\n                auto prop = ParticlePropertyFactory::CreateProperty<f32>(jsonValue);\n                out_particleEffect->SetInitialRotationProperty(std::move(prop));\n            }\n\n            //Initial Colour Property\n            jsonValue = in_jsonRoot.get(\"InitialColourProperty\", Json::nullValue);\n            if (jsonValue.isNull() == false)\n            {\n                auto prop = ParticlePropertyFactory::CreateProperty<Colour>(jsonValue);\n                out_particleEffect->SetInitialColourProperty(std::move(prop));\n            }\n\n            //Initial Speed Property\n            jsonValue = in_jsonRoot.get(\"InitialSpeedProperty\", Json::nullValue);\n            if (jsonValue.isNull() == false)\n            {\n                auto prop = ParticlePropertyFactory::CreateProperty<f32>(jsonValue);\n                out_particleEffect->SetInitialSpeedProperty(std::move(prop));\n            }\n\n            //Initial Angular Velocity Property\n            jsonValue = in_jsonRoot.get(\"InitialAngularVelocityProperty\", Json::nullValue);\n            if (jsonValue.isNull() == false)\n            {\n                auto prop = ParticlePropertyFactory::CreateProperty<f32>(jsonValue);\n                out_particleEffect->SetInitialAngularVelocityProperty(std::move(prop));\n            }\n        }\n        //-----------------------------------------------------------------\n        /// Reads the drawable def from the csparticle json.\n        ///\n        /// This is not thread safe and must be run on the main thread.\n        /// ReadDrawableDefAsync() should be used for background loading.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The root json object\n        /// @param The particle drawable def factory.\n        /// @param [Out] The particle effect that should be populated.\n        //-----------------------------------------------------------------\n        void ReadDrawableDef(const Json::Value& in_jsonRoot, const ParticleDrawableDefFactory* in_drawableDefFactory, const ParticleEffectSPtr& out_particleEffect)\n        {\n            Json::Value drawableJson = in_jsonRoot.get(\"Drawable\", Json::nullValue);\n            CS_ASSERT(drawableJson.isNull() == false && drawableJson.isObject() == true, \"CSParticle file '\" + out_particleEffect->GetName() + \"' does not contain a drawable.\");\n\n            Json::Value typeJson = drawableJson.get(\"Type\", Json::nullValue);\n            CS_ASSERT(typeJson.isNull() == false && typeJson.isString() == true, \"CSParticle file '\" + out_particleEffect->GetName() + \"' has a drawable with an invalid type.\");\n\n            out_particleEffect->SetDrawableDef(in_drawableDefFactory->CreateInstance(typeJson.asString(), drawableJson));\n        }\n        //-----------------------------------------------------------------\n        /// Reads the emitter def from the csparticle json.\n        ///\t\t\t\n        /// This is not thread safe and must be run on the main thread.\n        /// ReadEmitterDefAsync() should be used for background loading.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The root json object\n        /// @param The particle emitter def factory.\n        /// @param [Out] The particle effect that should be populated.\n        //-----------------------------------------------------------------\n        void ReadEmitterDef(const Json::Value& in_jsonRoot, const ParticleEmitterDefFactory* in_emitterDefFactory, const ParticleEffectSPtr& out_particleEffect)\n        {\n            Json::Value emitterJson = in_jsonRoot.get(\"Emitter\", Json::nullValue);\n            CS_ASSERT(emitterJson.isNull() == false && emitterJson.isObject() == true, \"CSParticle file '\" + out_particleEffect->GetName() + \"' does not contain an emitter.\");\n\n            Json::Value typeJson = emitterJson.get(\"Type\", Json::nullValue);\n            CS_ASSERT(typeJson.isNull() == false && typeJson.isString() == true, \"CSParticle file '\" + out_particleEffect->GetName() + \"' has an emitter with an invalid type.\");\n\n            out_particleEffect->SetEmitterDef(in_emitterDefFactory->CreateInstance(typeJson.asString(), emitterJson));\n        }\n        //-----------------------------------------------------------------\n        /// Reads the affector defs from the csparticle json.\n        ///\t\t\t\n        /// This is not thread safe and must be run on the main thread.\n        /// ReadAffectorDefsAsync() should be used for background loading.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The root json object\n        /// @param The particle affector def factory.\n        /// @param [Out] The particle effect that should be populated.\n        //-----------------------------------------------------------------\n        void ReadAffectorDefs(const Json::Value& in_jsonRoot, const ParticleAffectorDefFactory* in_affectorDefFactory, const ParticleEffectSPtr& out_particleEffect)\n        {\n            Json::Value affectorsJson = in_jsonRoot.get(\"Affectors\", Json::nullValue);\n            if (affectorsJson.isNull() == false)\n            {\n                CS_ASSERT(affectorsJson.isArray() == true, \"CSParticle file '\" + out_particleEffect->GetName() + \"' contains an 'Affectors' object that isn't an array.\");\n\n                std::vector<ParticleAffectorDefUPtr> affectorDefs;\n                for (const Json::Value& affectorJson : affectorsJson)\n                {\n                    CS_ASSERT(affectorJson.isObject() == true, \"CSParticle file '\" + out_particleEffect->GetName() + \"' contains affector json that isn't an object.\");\n\n                    Json::Value typeJson = affectorJson.get(\"Type\", Json::nullValue);\n                    CS_ASSERT(typeJson.isNull() == false && typeJson.isString() == true, \"CSParticle file '\" + out_particleEffect->GetName() + \"' has an affector with an invalid type.\");\n\n                    affectorDefs.push_back(in_affectorDefFactory->CreateInstance(typeJson.asString(), affectorJson));\n                }\n\n                out_particleEffect->SetAffectorDefs(std::move(affectorDefs));\n            }\n        }\n        //-----------------------------------------------------------------\n        /// Reads the CSParticle json file and populates the particle effect.\n        ///\n        /// This is not thread safe and must be run on the main thread.\n        /// LoadCSParticleAsync() should be used for background loading.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The storage location of the csparticle json file.\n        /// @param The file path to the csparticle json file.\n        /// @param The particle drawable def factory.\n        /// @param The particle emitter def factory.\n        /// @param The particle affector def factory.\n        /// @param [Out] The particle effect that should be populated.\n        //-----------------------------------------------------------------\n        void LoadCSParticle(StorageLocation in_storageLocation, const std::string& in_filePath, const ParticleDrawableDefFactory* in_drawableDefFactory,\n            const ParticleEmitterDefFactory* in_emitterDefFactory, const ParticleAffectorDefFactory* in_affectorDefFactory, const ParticleEffectSPtr& out_particleEffect)\n        {\n            Json::Value jsonRoot;\n            if (JsonUtils::ReadJson(in_storageLocation, in_filePath, jsonRoot) == false)\n            {\n                out_particleEffect->SetLoadState(Resource::LoadState::k_failed);\n                return;\n            }\n\n            ReadBaseValues(jsonRoot, out_particleEffect);\n            ReadDrawableDef(jsonRoot, in_drawableDefFactory, out_particleEffect);\n            ReadEmitterDef(jsonRoot, in_emitterDefFactory, out_particleEffect);\n            ReadAffectorDefs(jsonRoot, in_affectorDefFactory, out_particleEffect);\n\n            out_particleEffect->SetLoadState(Resource::LoadState::k_loaded);\n        }\n        //-----------------------------------------------------------------\n        /// Reads the drawable def from the csparticle json asynchronously.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The root json object\n        /// @param The particle drawable def factory.\n        /// @param [Out] The particle effect that should be populated.\n        /// @param The completion delegate.\n        //-----------------------------------------------------------------\n        void ReadDrawableDefAsync(const Json::Value& in_jsonRoot, const ParticleDrawableDefFactory* in_drawableDefFactory, const ParticleEffectSPtr& out_particleEffect, \n            const AsyncCompleteDelegate& in_completionDelegate)\n        {\n            Json::Value drawableJson = in_jsonRoot.get(\"Drawable\", Json::nullValue);\n            CS_ASSERT(drawableJson.isNull() == false && drawableJson.isObject() == true, \"CSParticle file '\" + out_particleEffect->GetName() + \"' does not contain a drawable.\");\n\n            Json::Value typeJson = drawableJson.get(\"Type\", Json::nullValue);\n            CS_ASSERT(typeJson.isNull() == false && typeJson.isString() == true, \"CSParticle file '\" + out_particleEffect->GetName() + \"' has a drawable with an invalid type.\");\n\n            in_drawableDefFactory->CreateInstanceAsync(typeJson.asString(), drawableJson, [=](ParticleDrawableDefUPtr in_drawableDef)\n            {\n                out_particleEffect->SetDrawableDef(std::move(in_drawableDef));\n                in_completionDelegate();\n            });\n        }\n        //-----------------------------------------------------------------\n        /// Reads the emitter def from the csparticle json asynchronously.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The root json object\n        /// @param The particle emitter def factory.\n        /// @param [Out] The particle effect that should be populated.\n        /// @param The completion delegate.\n        //-----------------------------------------------------------------\n        void ReadEmitterDefAsync(const Json::Value& in_jsonRoot, const ParticleEmitterDefFactory* in_emitterDefFactory, const ParticleEffectSPtr& out_particleEffect, \n            const AsyncCompleteDelegate& in_completionDelegate)\n        {\n            Json::Value emitterJson = in_jsonRoot.get(\"Emitter\", Json::nullValue);\n            CS_ASSERT(emitterJson.isNull() == false && emitterJson.isObject() == true, \"CSParticle file '\" + out_particleEffect->GetName() + \"' does not contain an emitter.\");\n\n            Json::Value typeJson = emitterJson.get(\"Type\", Json::nullValue);\n            CS_ASSERT(typeJson.isNull() == false && typeJson.isString() == true, \"CSParticle file '\" + out_particleEffect->GetName() + \"' has an emitter with an invalid type.\");\n\n            in_emitterDefFactory->CreateInstanceAsync(typeJson.asString(), emitterJson, [=](ParticleEmitterDefUPtr in_emitterDef)\n            {\n                out_particleEffect->SetEmitterDef(std::move(in_emitterDef));\n                in_completionDelegate();\n            });\n        }\n        //-----------------------------------------------------------------\n        /// Reads a single affector def from the csparticle json \n        /// asynchronously.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The vetor of affector def json.\n        /// @param The current index into the vector.\n        /// @param The particle affector def factory.\n        /// @param [Out] The particle effect that should be populated.\n        /// @param The completion delegate.\n        //-----------------------------------------------------------------\n        void ReadAffectorDefAsync(const std::vector<Json::Value>& in_affectorDefJsons, u32 in_affectorIndex, const ParticleAffectorDefFactory* in_affectorDefFactory, \n            std::shared_ptr<std::vector<ParticleAffectorDefUPtr>> in_particleAffectorDefs, const AsyncCompleteDelegate& in_completionDelegate)\n        {\n            Json::Value affectorJson = in_affectorDefJsons[in_affectorIndex];\n            Json::Value typeJson = affectorJson.get(\"Type\", Json::nullValue);\n            CS_ASSERT(typeJson.isNull() == false && typeJson.isString() == true, \"Invalid affector type.\");\n\n            in_affectorDefFactory->CreateInstanceAsync(typeJson.asString(), affectorJson, [=](ParticleAffectorDefUPtr in_drawableDef)\n            {\n                in_particleAffectorDefs->push_back(std::move(in_drawableDef));\n\n                u32 nextIndex = in_affectorIndex + 1;\n                if (nextIndex < in_affectorDefJsons.size())\n                {\n                    ReadAffectorDefAsync(in_affectorDefJsons, nextIndex, in_affectorDefFactory, in_particleAffectorDefs, in_completionDelegate);\n                }\n                else\n                {\n                    in_completionDelegate();\n                }\n            });\n        }\n        //-----------------------------------------------------------------\n        /// Reads the affector defs from the csparticle json asynchronously.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The root json object\n        /// @param The particle affector def factory.\n        /// @param [Out] The particle effect that should be populated.\n        /// @param The completion delegate.\n        //-----------------------------------------------------------------\n        void ReadAffectorDefsAsync(const Json::Value& in_jsonRoot, const ParticleAffectorDefFactory* in_affectorDefFactory, const ParticleEffectSPtr& out_particleEffect, \n            const AsyncCompleteDelegate& in_completionDelegate)\n        {\n            Json::Value affectorsJson = in_jsonRoot.get(\"Affectors\", Json::nullValue);\n            if (affectorsJson.isNull() == false)\n            {\n                CS_ASSERT(affectorsJson.isArray() == true, \"CSParticle file '\" + out_particleEffect->GetName() + \"' contains an 'Affectors' object that isn't an array.\");\n\n                std::vector<Json::Value> affectorJsons;\n                for (const Json::Value& affectorJson : affectorsJson)\n                {\n                    CS_ASSERT(affectorJson.isObject() == true, \"CSParticle file '\" + out_particleEffect->GetName() + \"' contains affector json that isn't an object.\");\n                    affectorJsons.push_back(affectorJson);\n                }\n                CS_ASSERT(affectorJsons.empty() == false, \"CSParticle file '\" + out_particleEffect->GetName() + \"' has Affectors key with no affectors.\");\n\n                std::shared_ptr<std::vector<ParticleAffectorDefUPtr>> particleAffectorDefs(new std::vector<ParticleAffectorDefUPtr>());\n                ReadAffectorDefAsync(affectorJsons, 0, in_affectorDefFactory, particleAffectorDefs, [=]()\n                {\n                    out_particleEffect->SetAffectorDefs(std::move(*particleAffectorDefs));\n                    in_completionDelegate();\n                });\n            }\n            else\n            {\n                in_completionDelegate();\n            }\n        }\n        //-----------------------------------------------------------------\n        /// Asynchonously Reads the CSParticle json file and populates the \n        /// particle effect.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The storage location of the csparticle json file.\n        /// @param The file path to the csparticle json file.\n        /// @param The particle drawable def factory.\n        /// @param The particle emitter def factory.\n        /// @param The particle affector def factory.\n        /// @param [Out] The particle effect that should be populated.\n        //-----------------------------------------------------------------\n        void LoadCSParticleAsync(StorageLocation in_storageLocation, const std::string& in_filePath, const ParticleDrawableDefFactory* in_drawableDefFactory,\n            const ParticleEmitterDefFactory* in_emitterDefFactory, const ParticleAffectorDefFactory* in_affectorDefFactory, const ResourceProvider::AsyncLoadDelegate& in_delegate,\n            const ParticleEffectSPtr& out_particleEffect)\n        {\n            Json::Value jsonRoot;\n            if (JsonUtils::ReadJson(in_storageLocation, in_filePath, jsonRoot) == false)\n            {\n                out_particleEffect->SetLoadState(Resource::LoadState::k_failed);\n                Application::Get()->GetTaskScheduler()->ScheduleTask(TaskType::k_mainThread, [=](const TaskContext&) noexcept\n                {\n                    in_delegate(out_particleEffect);\n                });\n                return;\n            }\n\n            ReadBaseValues(jsonRoot, out_particleEffect);\n\n            ReadDrawableDefAsync(jsonRoot, in_drawableDefFactory, out_particleEffect, [=]()\n            {\n                ReadEmitterDefAsync(jsonRoot, in_emitterDefFactory, out_particleEffect, [=]()\n                {\n                    ReadAffectorDefsAsync(jsonRoot, in_affectorDefFactory, out_particleEffect, [=]()\n                    {\n                        out_particleEffect->SetLoadState(Resource::LoadState::k_loaded);\n                        Application::Get()->GetTaskScheduler()->ScheduleTask(TaskType::k_mainThread, [=](const TaskContext&) noexcept\n                        {\n                            in_delegate(out_particleEffect);\n                        });\n                    });\n                });\n            });\n        }\n    }\n\n    CS_DEFINE_NAMEDTYPE(CSParticleProvider);\n    //-----------------------------------------------------------------\n    //-----------------------------------------------------------------\n    CSParticleProviderUPtr CSParticleProvider::Create()\n    {\n        return CSParticleProviderUPtr(new CSParticleProvider());\n    }\n    //-----------------------------------------------------------------\n    //-----------------------------------------------------------------\n    bool CSParticleProvider::IsA(InterfaceIDType in_interfaceId) const\n    {\n        return (ResourceProvider::InterfaceID == in_interfaceId || CSParticleProvider::InterfaceID == in_interfaceId);\n    }\n    //-----------------------------------------------------------------\n    //-----------------------------------------------------------------\n    InterfaceIDType CSParticleProvider::GetResourceType() const\n    {\n        return ParticleEffect::InterfaceID;\n    }\n    //-----------------------------------------------------------------\n    //-----------------------------------------------------------------\n    bool CSParticleProvider::CanCreateResourceWithFileExtension(const std::string& in_extension) const\n    {\n        std::string lowerExtension = in_extension;\n        StringUtils::ToLowerCase(lowerExtension);\n        return (lowerExtension == k_fileExtension);\n    }\n    //-----------------------------------------------------------------\n    //-----------------------------------------------------------------\n    void CSParticleProvider::CreateResourceFromFile(StorageLocation in_location, const std::string& in_filePath, const IResourceOptionsBaseCSPtr& in_options, \n        const ResourceSPtr& out_resource)\n    {\n        CS_ASSERT(out_resource != nullptr, \"resource cannot be null.\");\n        CS_ASSERT(out_resource->IsA<ParticleEffect>() == true, \"resource must be a particle effect.\");\n\n        ParticleEffectSPtr particleEffect = std::static_pointer_cast<ParticleEffect>(out_resource);\n        LoadCSParticle(in_location, in_filePath, m_drawableDefFactory, m_emitterDefFactory, m_affectorDefFactory, particleEffect);\n    }\n    //-----------------------------------------------------------------\n    //------------------------------------------------------------------\n    void CSParticleProvider::CreateResourceFromFileAsync(StorageLocation in_location, const std::string& in_filePath, const IResourceOptionsBaseCSPtr& in_options, \n        const ResourceProvider::AsyncLoadDelegate& in_delegate, const ResourceSPtr& out_resource)\n    {\n        CS_ASSERT(out_resource != nullptr, \"resource cannot be null.\");\n        CS_ASSERT(out_resource->IsA<ParticleEffect>() == true, \"resource must be a particle effect.\"); \n        CS_ASSERT(in_delegate != nullptr, \"Async load delegate cannot be null.\");\n\n        ParticleEffectSPtr particleEffect = std::static_pointer_cast<ParticleEffect>(out_resource);\n        Application::Get()->GetTaskScheduler()->ScheduleTask(TaskType::k_file, [=](const TaskContext&) noexcept\n        {\n            LoadCSParticleAsync(in_location, in_filePath, m_drawableDefFactory, m_emitterDefFactory, m_affectorDefFactory, in_delegate, particleEffect);\n        });\n    }\n    //------------------------------------------------------------------\n    //------------------------------------------------------------------\n    void CSParticleProvider::OnInit()\n    {\n        m_drawableDefFactory = Application::Get()->GetSystem<ParticleDrawableDefFactory>();\n        CS_ASSERT(m_drawableDefFactory != nullptr, \"CSParticle Provider is missing required system: ParticleDrawableDefFactory.\");\n\n        m_emitterDefFactory = Application::Get()->GetSystem<ParticleEmitterDefFactory>();\n        CS_ASSERT(m_emitterDefFactory != nullptr, \"CSParticle Provider is missing required system: ParticleEmitterDefFactory.\");\n\n        m_affectorDefFactory = Application::Get()->GetSystem<ParticleAffectorDefFactory>();\n        CS_ASSERT(m_affectorDefFactory != nullptr, \"CSParticle Provider is missing required system: ParticleAffectorDefFactory.\");\n    }\n    //------------------------------------------------------------------\n    //------------------------------------------------------------------\n    void CSParticleProvider::OnDestroy()\n    {\n        m_drawableDefFactory = nullptr;\n        m_emitterDefFactory = nullptr;\n        m_affectorDefFactory = nullptr;\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Particle/CSParticleProvider.h",
    "content": "//\n//  CSParticleProvider.h\n//  ChilliSource\n//  Created by Ian Copland on 04/11/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_PARTICLE_CSPARTICLEPROVIDER_H_\n#define _CHILLISOURCE_RENDERING_PARTICLE_CSPARTICLEPROVIDER_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Resource/ResourceProvider.h>\n\nnamespace ChilliSource\n{\n    //-------------------------------------------------------------------------\n    /// A resource provider which creates Particle Effect resources from\n    /// CSParticle files.\n    ///\n    /// @author Ian Copland\n    //-------------------------------------------------------------------------\n    class CSParticleProvider final : public ResourceProvider\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(CSParticleProvider);\n        //-----------------------------------------------------------------\n        /// Allows querying of whether or not this implements the interface\n        /// described by the given interface Id.\n        /// \n        /// @author Ian Copland\n        ///\n        /// @param The interface Id.\n        ///\n        /// @return Whether this implements the interface.\n        //-----------------------------------------------------------------\n        bool IsA(InterfaceIDType in_interfaceId) const override;\n        //-----------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The type of resource loaded by this provider.\n        //-----------------------------------------------------------------\n        InterfaceIDType GetResourceType() const override;\n        //-----------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param The extension to check.\n        ///\n        /// @return Whether or not this can load from files with the\n        /// given extension.\n        //-----------------------------------------------------------------\n        bool CanCreateResourceWithFileExtension(const std::string& in_extension) const override;\n    private:\n        friend class Application;\n        //-----------------------------------------------------------------\n        /// Factory method for creating new instances of this system.\n        ///\n        /// @author S Downie\n        ///\n        /// @return The instance of this system.\n        //-----------------------------------------------------------------\n        static CSParticleProviderUPtr Create();\n        //-----------------------------------------------------------------\n        /// Default constructor. Declared private to force the use of the\n        /// CreateSystem() method in Application.\n        ///\n        /// @author Ian Copland\n        //-----------------------------------------------------------------\n        CSParticleProvider() = default;\n        //-----------------------------------------------------------------\n        /// Populates the given Particle Effect resource with data from the\n        /// given file. The resource should be checked to ensure it has\n        /// loaded after this method is called.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The storage location of the file.\n        /// @param The file path.\n        /// @param The resource options. This is always empty for a particle \n        /// effect.\n        /// @param [Out] The output particle effect resource.\n        //-----------------------------------------------------------------\n        void CreateResourceFromFile(StorageLocation in_location, const std::string& in_filePath, const IResourceOptionsBaseCSPtr& in_options, \n            const ResourceSPtr& out_resource) override;\n        //-----------------------------------------------------------------\n        /// Populates the given Particle Effect resource with data from the\n        /// given file. The loading is performed as a background task, the \n        /// resource should not be used until the completion delegate has\n        /// been called. When the completion delegate is called the resource\n        /// should be checked to confirm it has successfully loaded.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The storage location of the file.\n        /// @param The file path.\n        /// @param The resource options. This is always empty for a particle \n        /// effect.\n        /// @param The completion delegate. This should never be null.\n        /// @param [Out] Resource object\n        //------------------------------------------------------------------\n        void CreateResourceFromFileAsync(StorageLocation in_location, const std::string& in_filePath, const IResourceOptionsBaseCSPtr& in_options, \n            const ResourceProvider::AsyncLoadDelegate& in_delegate, const ResourceSPtr& out_resource) override;\n        //------------------------------------------------------------------\n        /// Tries to acquire references to the drawable, emitter and affector\n        /// definition factories. If they don't exist this will try to assert.\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------------------------\n        void OnInit() override;\n        //------------------------------------------------------------------\n        /// Cleans up the handles to the drawable, emitter and affector\n        /// definition factories.\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------------------------\n        void OnDestroy() override;\n\n        const ParticleDrawableDefFactory* m_drawableDefFactory = nullptr;\n        const ParticleEmitterDefFactory* m_emitterDefFactory = nullptr;\n        const ParticleAffectorDefFactory* m_affectorDefFactory = nullptr;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Particle/ConcurrentParticleData.cpp",
    "content": "//\n//  ConcurrentParticleData.cpp\n//  ChilliSource\n//  Created by Ian Copland on 02/11/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Particle/ConcurrentParticleData.h>\n\n#include <ChilliSource/Rendering/Particle/Particle.h>\n\nnamespace ChilliSource\n{\n    //-----------------------------------------------------------------\n    //-----------------------------------------------------------------\n    ConcurrentParticleData::ConcurrentParticleData(u32 in_particleCount)\n        : m_particles(in_particleCount), m_lock(m_mutex, std::defer_lock)\n    {\n    }\n    //-----------------------------------------------------------------\n    //-----------------------------------------------------------------\n    bool ConcurrentParticleData::StartUpdate()\n    {\n        std::unique_lock<std::recursive_mutex> lock(m_mutex);\n        if (m_updating == false)\n        {\n            m_updating = true;\n            return true;\n        }\n\n        return false;\n    }\n    //-----------------------------------------------------------------\n    //-----------------------------------------------------------------\n    bool ConcurrentParticleData::HasActiveParticles() const\n    {\n        std::unique_lock<std::recursive_mutex> lock(m_mutex);\n        return m_activeParticles;\n    }\n    //-----------------------------------------------------------------\n    //-----------------------------------------------------------------\n    AABB ConcurrentParticleData::GetAABB() const\n    {\n        std::unique_lock<std::recursive_mutex> lock(m_mutex);\n        return m_aabb;\n    }\n    //-----------------------------------------------------------------\n    //-----------------------------------------------------------------\n    Sphere ConcurrentParticleData::GetBoundingSphere() const\n    {\n        std::unique_lock<std::recursive_mutex> lock(m_mutex);\n        return m_boundingSphere;\n    }\n    //-----------------------------------------------------------------\n    //-----------------------------------------------------------------\n    void ConcurrentParticleData::Lock() const\n    {\n        m_lock.lock();\n    }\n    //-----------------------------------------------------------------\n    //-----------------------------------------------------------------\n    std::vector<u32> ConcurrentParticleData::TakeNewIndices()\n    {\n        CS_ASSERT(m_lock.owns_lock() == true, \"Must be locked when taking new indices!\")\n\n        std::vector<u32> output = m_newParticleIndices;\n        m_newParticleIndices.clear();\n        return output;\n    }\n    //-----------------------------------------------------------------\n    //-----------------------------------------------------------------\n    const dynamic_array<ConcurrentParticleData::Particle>& ConcurrentParticleData::GetParticles() const\n    {\n        CS_ASSERT(m_lock.owns_lock() == true, \"Must be locked when getting particles!\");\n\n        return m_particles;\n    }\n    //-----------------------------------------------------------------\n    //-----------------------------------------------------------------\n    void ConcurrentParticleData::Unlock() const\n    {\n        m_lock.unlock();\n    }\n    //-----------------------------------------------------------------\n    //-----------------------------------------------------------------\n    void ConcurrentParticleData::CommitParticleData(const dynamic_array<ChilliSource::Particle>* in_particles, const std::vector<u32>& in_newIndices, const AABB& in_aabb, const Sphere& in_boundingSphere)\n    {\n        std::unique_lock<std::recursive_mutex> lock(m_mutex);\n\n        CS_ASSERT(in_particles->size() == m_particles.size(), \"Particle data lists must be the same size.\");\n\n        m_activeParticles = false;\n        for (u32 i = 0; i < m_particles.size(); ++i)\n        {\n            Particle& concurrentParticle = m_particles[i];\n            const ChilliSource::Particle& particle = (*in_particles)[i];\n\n            concurrentParticle.m_isActive = particle.m_isActive;\n            concurrentParticle.m_position = particle.m_position;\n            concurrentParticle.m_rotation = particle.m_rotation;\n            concurrentParticle.m_scale = particle.m_scale;\n            concurrentParticle.m_colour = particle.m_colour;\n\n            if (concurrentParticle.m_isActive == true)\n            {\n                m_activeParticles = true;\n            }\n        }\n\n        m_newParticleIndices.insert(m_newParticleIndices.end(), in_newIndices.begin(), in_newIndices.end());\n        m_aabb = in_aabb;\n        m_boundingSphere = in_boundingSphere;\n        m_updating = false;\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Particle/ConcurrentParticleData.h",
    "content": "//\n//  ConcurrentParticleData.h\n//  ChilliSource\n//  Created by Ian Copland on 02/11/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_PARTICLE_CONCURRENTPARTICLEDATA_H_\n#define _CHILLISOURCE_RENDERING_PARTICLE_CONCURRENTPARTICLEDATA_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Base/Colour.h>\n#include <ChilliSource/Core/Container/dynamic_array.h>\n#include <ChilliSource/Core/Math/Vector2.h>\n#include <ChilliSource/Core/Math/Vector3.h>\n#include <ChilliSource/Core/Math/Geometry/Shapes.h>\n\n#include <mutex>\n#include <vector>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------\n    /// A container for particle effect data that needs to be shared across\n    /// the main thread and the particle update thread. This includes the\n    /// draw information for each particle, the list of newly updated particles\n    /// and the total bounds of the particle effect.\n    ///\n    /// @author Ian Copland\n    //------------------------------------------------------------------------\n    class ConcurrentParticleData final\n    {\n    public:\n        //-----------------------------------------------------------------\n        /// A struct containing just the information required for drawing a\n        /// particle.\n        ///\n        /// @author Ian Copland\n        //-----------------------------------------------------------------\n        struct Particle final\n        {\n            bool m_isActive = false;\n            Vector3 m_position;\n            Vector2 m_scale = Vector2::k_zero;\n            f32 m_rotation = 0.0f;\n            Colour m_colour = Colour::k_white;\n        };\n        //-----------------------------------------------------------------\n        /// Constructor\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The number of particles.\n        //-----------------------------------------------------------------\n        ConcurrentParticleData(u32 in_particleCount);\n        //-----------------------------------------------------------------\n        /// This will return false if no particle data has been commited\n        /// since the last time this was called. If false is returned a \n        /// new update should not be started.\n        ///\n        /// This is thread-safe.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param Whether or not the update can start.\n        //-----------------------------------------------------------------\n        bool StartUpdate();\n        //-----------------------------------------------------------------\n        /// This is thread-safe, lock doesn't need to be called first.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param Whether or not there are any active particles.\n        //-----------------------------------------------------------------\n        bool HasActiveParticles() const;\n        //-----------------------------------------------------------------\n        /// This is thread-safe, lock doesn't need to be called first.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @author The AABB for the particle effect. Whether or not this\n        /// is in world or local space is determined by the simulation space\n        /// of a particle.\n        //-----------------------------------------------------------------\n        AABB GetAABB() const;\n        //-----------------------------------------------------------------\n        /// This is thread-safe, lock doesn't need to be called first.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @author The bounding sphere for the particle effect. Whether or \n        /// not this is in world or local space is determined by the \n        /// simulation space of a particle.\n        //-----------------------------------------------------------------\n        Sphere GetBoundingSphere() const;\n        //-----------------------------------------------------------------\n        /// Locks the container so other threads cannot update it while\n        /// accessing the new indices and particle list.\n        ///\n        /// @author Ian Copland\n        //-----------------------------------------------------------------\n        void Lock() const;\n        //-----------------------------------------------------------------\n        /// Returns the list of indices that have changed since the last\n        /// time this was called. The list will be cleared when called.\n        /// Before this is called the container must be locked to ensure\n        /// that new particles are not activated prior to being rendered.\n        /// If the container is not locked the app is considered to be\n        /// in an irrecoverable state and will terminate.\n        /// \n        /// @author Ian Copland\n        ///\n        /// @author A vector of particle indices.\n        //-----------------------------------------------------------------\n        std::vector<u32> TakeNewIndices();\n        //-----------------------------------------------------------------\n        /// Before this is called the container must be locked to ensure\n        /// that any iteration over the particle data is safe. If not the\n        /// app is considered to be in an irrecoverable state and will\n        /// terminate.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The particle list.\n        //-----------------------------------------------------------------\n        const dynamic_array<ConcurrentParticleData::Particle>& GetParticles() const;\n        //-----------------------------------------------------------------\n        /// Unlocks the container. This should be called as soon as possible\n        /// after dealing with data that needs to be locked.\n        ///\n        /// @author Ian Copland\n        //-----------------------------------------------------------------\n        void Unlock() const;\n        //-----------------------------------------------------------------\n        /// Updates the particle data.\n        ///\n        /// This is thread-safe, lock doesn't need to be called first.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The list of particles.\n        /// @param The new indices.\n        /// @param The aabb.\n        /// @param The obb.\n        /// @param The bounding sphere.\n        //-----------------------------------------------------------------\n        void CommitParticleData(const dynamic_array<ChilliSource::Particle>* in_particles, const std::vector<u32>& in_newIndices, const AABB& in_aabb, const Sphere& in_boundingSphere);\n    private:\n\n        dynamic_array<ConcurrentParticleData::Particle> m_particles;\n        std::vector<u32> m_newParticleIndices;\n        AABB m_aabb;\n        Sphere m_boundingSphere;\n        bool m_updating = false;\n        bool m_activeParticles = false;\n        \n        mutable std::recursive_mutex m_mutex;\n        mutable std::unique_lock<std::recursive_mutex> m_lock;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Particle/Drawable/ParticleDrawable.cpp",
    "content": "//\n//  ParticleDrawable.cpp\n//  ChilliSource\n//  Created by Ian Copland on 13/10/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Particle/Drawable/ParticleDrawable.h>\n\n#include <ChilliSource/Rendering/Particle/ConcurrentParticleData.h>\n\nnamespace ChilliSource\n{\n    //----------------------------------------------\n    //----------------------------------------------\n    ParticleDrawable::ParticleDrawable(const Entity* in_entity, const ParticleDrawableDef* in_drawableDef, ConcurrentParticleData* in_concurrentParticleData)\n        : m_entity(in_entity), m_drawableDef(in_drawableDef), m_concurrentParticleData(in_concurrentParticleData)\n    {\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    void ParticleDrawable::Draw(RenderSnapshot& renderSnapshot, IAllocator* frameAllocator) noexcept\n    {\n        m_concurrentParticleData->Lock();\n\n        auto newIndices = m_concurrentParticleData->TakeNewIndices();\n        for (const auto& index : newIndices)\n        {\n            ActivateParticle(m_concurrentParticleData->GetParticles(), index);\n        }\n\n        DrawParticles(m_concurrentParticleData->GetParticles(), renderSnapshot, frameAllocator);\n\n        m_concurrentParticleData->Unlock();\n    }\n    //----------------------------------------------\n    //----------------------------------------------\n    const Entity* ParticleDrawable::GetEntity() const\n    {\n        return m_entity;\n    }\n    //----------------------------------------------\n    //----------------------------------------------\n    const ParticleDrawableDef* ParticleDrawable::GetDrawableDef() const\n    {\n        return m_drawableDef;\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Particle/Drawable/ParticleDrawable.h",
    "content": "//\n//  ParticleDrawable.h\n//  ChilliSource\n//  Created by Ian Copland on 13/10/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_PARTICLE_DRAWABLE_PARTICLEDRAWABLE_H_\n#define _CHILLISOURCE_RENDERING_PARTICLE_DRAWABLE_PARTICLEDRAWABLE_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Rendering/Particle/ConcurrentParticleData.h>\n\nnamespace ChilliSource\n{\n    //-----------------------------------------------------------------------\n    /// The base class for all particle drawables. Particle drawables are \n    /// reponsible for the actual rendering  of the particles. \n    ///\n    /// Particle drawables are drawn from the main thread, however particles \n    /// are updated from a background task. Information is passed between \n    /// threads using the concurrent particle draw data array. This contains \n    /// just the information needed to render a particle and can be locked \n    /// before use.\n    ///\n    /// @author Ian Copland\n    //-----------------------------------------------------------------------\n    class ParticleDrawable\n    {\n    public:\n        CS_DECLARE_NOCOPY(ParticleDrawable);\n        //----------------------------------------------------------------\n        /// Constructor.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The entity the effect is attached to.\n        /// @param The particle drawable definition.\n        /// @param The concurrent particle data.\n        //----------------------------------------------------------------\n        ParticleDrawable(const Entity* in_entity, const ParticleDrawableDef* in_drawableDef, ConcurrentParticleData* in_concurrentParticleData);\n        //----------------------------------------------------------------\n        /// Updates the particle drawable and renders all active particles\n        /// in the effect. \n        ///\n        /// This must be called on the main thread.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param renderSnapshot - The render snapshot that particles\n        /// will be added to.\n        /// @param frameAllocator - Allocate memory for this render frame\n        /// from here\n        //----------------------------------------------------------------\n        void Draw(RenderSnapshot& renderSnapshot, IAllocator* frameAllocator) noexcept;\n        //----------------------------------------------------------------\n        /// Destructor\n        ///\n        /// @author Ian Copland\n        //----------------------------------------------------------------\n        virtual ~ParticleDrawable() {};\n    protected:\n        //----------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The entity the owning particle component is attached \n        /// to. This should never be null.\n        //----------------------------------------------------------------\n        const Entity* GetEntity() const;\n        //----------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The particle drawable definition\n        //----------------------------------------------------------------\n        const ParticleDrawableDef* GetDrawableDef() const;\n        //----------------------------------------------------------------\n        /// Activates the particle with the given index.\n        ///\n        /// This is called on the main thread, but the particle data can \n        /// be modified on other threads so make sure to lock it prior to \n        /// use.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The particle draw data.\n        /// @param The index of the particle to activate.\n        //----------------------------------------------------------------\n        virtual void ActivateParticle(const dynamic_array<ConcurrentParticleData::Particle>& in_particleData, u32 in_index) = 0;\n        //----------------------------------------------------------------\n        /// Renders all active particles in the effect. \n        ///\n        /// This is always called on the main thread.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param in_particleData - The particle draw data.\n        /// @param in_renderSnapshot - The render snapshot that particles\n        /// will be added to.\n        /// @param frameAllocator - Allocate memory for this render frame\n        /// from here\n        //----------------------------------------------------------------\n        virtual void DrawParticles(const dynamic_array<ConcurrentParticleData::Particle>& particleData, RenderSnapshot& renderSnapshot, IAllocator* frameAllocator) = 0;\n        \n    private:\n        const Entity* m_entity = nullptr;\n        const ParticleDrawableDef* m_drawableDef = nullptr;\n        ConcurrentParticleData* m_concurrentParticleData = nullptr;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Particle/Drawable/ParticleDrawableDef.cpp",
    "content": "//\n//  ParticleDrawableDef.cpp\n//  ChilliSource\n//  Created by Ian Copland on 13/10/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Particle/Drawable/ParticleDrawableDef.h>\n\nnamespace ChilliSource\n{\n    CS_DEFINE_NAMEDTYPE(ParticleDrawableDef);\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    const ParticleEffect* ParticleDrawableDef::GetParticleEffect() const\n    {\n        return m_particleEffect;\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    void ParticleDrawableDef::SetParticleEffect(const ParticleEffect* in_particleEffect)\n    {\n        m_particleEffect = in_particleEffect;\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Particle/Drawable/ParticleDrawableDef.h",
    "content": "//\n//  ParticleDrawableDef.h\n//  ChilliSource\n//  Created by Ian Copland on 13/10/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_PARTICLE_DRAWABLE_PARTICLEDRAWABLEDEF_H_\n#define _CHILLISOURCE_RENDERING_PARTICLE_DRAWABLE_PARTICLEDRAWABLEDEF_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Base/QueryableInterface.h>\n\n#include <functional>\n\nnamespace ChilliSource\n{\n    //-----------------------------------------------------------------------\n    /// A particle drawable def describes the properties that should be used \n    /// to create a particle drawable and creates the drawable instances.\n    ///\n    /// As a particle drawable def's contents can potentially be read from \n    /// multiple threads, it is immutable after construction. The exception \n    /// to this is if it was created from a param dictionary with a asynchronous \n    /// delegate, in which case it is immutable after the delegate returns. \n    /// Classes inheriting from this should also follow these rules.\n    ///\n    /// @author Ian Copland\n    //-----------------------------------------------------------------------\n    class ParticleDrawableDef : public QueryableInterface\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(ParticleDrawableDef);\n        CS_DECLARE_NOCOPY(ParticleDrawableDef);\n        //----------------------------------------------------------------\n        /// The drawable def loaded delegate. This is used when background \n        /// loading the particle drawable def, once it has finished loading\n        /// this delegate should be called.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The particle drawable def.\n        //----------------------------------------------------------------\n        using LoadedDelegate = std::function<void(ParticleDrawableDef* in_drawableDef)>;\n        //----------------------------------------------------------------\n        /// Constructor.\n        ///\n        /// @author Ian Copland\n        //----------------------------------------------------------------\n        ParticleDrawableDef() = default;\n        //----------------------------------------------------------------\n        /// Creates an instance of the particle drawable described by this.\n        ///\n        /// @author Ian Copland.\n        ///\n        /// @param The entity that owns the effect.\n        /// @param The concurrent particle data.\n        ///\n        /// @return the instance.\n        //----------------------------------------------------------------\n        virtual ParticleDrawableUPtr CreateInstance(const Entity* in_entity, ConcurrentParticleData* in_concurrentParticleData) const = 0;\n        //----------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The particle effect that owns this particle drawable\n        /// definition.\n        //----------------------------------------------------------------\n        const ParticleEffect* GetParticleEffect() const;\n        //----------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The material that will be used to render the particles.\n        //----------------------------------------------------------------\n        virtual const MaterialCSPtr& GetMaterial() const = 0;\n        //----------------------------------------------------------------\n        /// Destructor\n        ///\n        /// @author Ian Copland.\n        //----------------------------------------------------------------\n        virtual ~ParticleDrawableDef() {}\n    private:\n        friend class ParticleEffect;\n        //----------------------------------------------------------------\n        /// Sets the owning particle effect. This can only be called by the \n        /// particle effect itself when this is added to it.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The particle effect.\n        //----------------------------------------------------------------\n        void SetParticleEffect(const ParticleEffect* in_particleEffect);\n\n        const ParticleEffect* m_particleEffect = nullptr;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Particle/Drawable/ParticleDrawableDefFactory.cpp",
    "content": "//\n//  ParticleDrawableDefFactory.cpp\n//  ChilliSource\n//  Created by Ian Copland on 07/11/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Particle/Drawable/ParticleDrawableDefFactory.h>\n\n#include <ChilliSource/Rendering/Particle/Drawable/StaticBillboardParticleDrawableDef.h>\n\nnamespace ChilliSource\n{\n    CS_DEFINE_NAMEDTYPE(ParticleDrawableDefFactory);\n    //-----------------------------------------------------------------\n    //-----------------------------------------------------------------\n    ParticleDrawableDefFactoryUPtr ParticleDrawableDefFactory::Create()\n    {\n        return ParticleDrawableDefFactoryUPtr(new ParticleDrawableDefFactory());\n    }\n    //-----------------------------------------------------------------\n    //-----------------------------------------------------------------\n    bool ParticleDrawableDefFactory::IsA(InterfaceIDType in_interfaceId) const\n    {\n        return (ParticleDrawableDefFactory::InterfaceID == in_interfaceId);\n    }\n    //-----------------------------------------------------------------\n    //-----------------------------------------------------------------\n    void ParticleDrawableDefFactory::RegisterDefaults()\n    {\n        Register<StaticBillboardParticleDrawableDef>(\"StaticBillboard\");\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Particle/Drawable/ParticleDrawableDefFactory.h",
    "content": "//\n//  ParticleDrawableDefFactory.h\n//  ChilliSource\n//  Created by Ian Copland on 07/11/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _ICENGINE_RENDERING_PARTICLES_PARTICLEDRAWABLEDEFFACTORY_H_\n#define _ICENGINE_RENDERING_PARTICLES_PARTICLEDRAWABLEDEFFACTORY_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Base/GenericFactory.h>\n#include <ChilliSource/Core/Delegate/MakeDelegate.h>\n#include <ChilliSource/Rendering/Particle/Drawable/ParticleDrawableDef.h>\n\n#include <json/json.h>\n\n#include <functional>\n#include <unordered_map>\n\nnamespace ChilliSource\n{\n    //--------------------------------------------------------------------------\n    /// A factory for creating particle drawable definitions. This allows \n    /// particle drawable definition types to be registered with the class. A\n    /// Particle Provider can then create new instances of the registered \n    /// drawable def with a Json descriptor.\n    ///\n    /// @author Ian Copland\n    //--------------------------------------------------------------------------\n    class ParticleDrawableDefFactory final : public GenericFactory<ParticleDrawableDef>\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(ParticleDrawableDefFactory);\n        //-----------------------------------------------------------------\n        /// Allows querying of whether or not this implements the interface\n        /// described by the given interface Id.\n        /// \n        /// @author Ian Copland\n        ///\n        /// @param The interface Id.\n        ///\n        /// @return Whether this implements the interface.\n        //-----------------------------------------------------------------\n        bool IsA(InterfaceIDType in_interfaceId) const override;\n    private:\n        friend class Application;\n        //-----------------------------------------------------------------\n        /// A factory method for creating new instances of a particle \n        /// drawable def factory.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @return The new instance of the system.\n        //-----------------------------------------------------------------\n        static ParticleDrawableDefFactoryUPtr Create();\n        //-----------------------------------------------------------------\n        /// Default constructor. Declared private to force the use of the\n        /// CreateSystem() method in Application.\n        ///\n        /// @author Ian Copland\n        //-----------------------------------------------------------------\n        ParticleDrawableDefFactory() = default;\n        //-----------------------------------------------------------------\n        /// Registers the default particle drawable definitions.\n        ///\n        /// @author Ian Copland\n        //-----------------------------------------------------------------\n        void RegisterDefaults() override;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Particle/Drawable/StaticBillboardParticleDrawable.cpp",
    "content": "//\n//  StaticBillboardParticleDrawable.cpp\n//  ChilliSource\n//  Created by Ian Copland on 13/10/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Particle/Drawable/StaticBillboardParticleDrawable.h>\n\n#include <ChilliSource/Core/Container/dynamic_array.h>\n#include <ChilliSource/Core/Math/Random.h>\n#include <ChilliSource/Rendering/Base/RenderSnapshot.h>\n#include <ChilliSource/Rendering/Particle/ConcurrentParticleData.h>\n#include <ChilliSource/Rendering/Particle/ParticleEffect.h>\n#include <ChilliSource/Rendering/Particle/Drawable/StaticBillboardParticleDrawableDef.h>\n\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/Base/ColourUtils.h>\n#include <ChilliSource/Core/Entity/Entity.h>\n#include <ChilliSource/Core/Math/Matrix4.h>\n#include <ChilliSource/Core/Math/Quaternion.h>\n#include <ChilliSource/Core/Math/Vector3.h>\n#include <ChilliSource/Rendering/Base/AlignmentAnchors.h>\n#include <ChilliSource/Rendering/Base/AspectRatioUtils.h>\n#include <ChilliSource/Rendering/Camera/CameraComponent.h>\n#include <ChilliSource/Rendering/Material/Material.h>\n#include <ChilliSource/Rendering/Sprite/SpriteMeshBuilder.h>\n#include <ChilliSource/Rendering/Texture/Texture.h>\n#include <ChilliSource/Rendering/Texture/TextureAtlas.h>\n\nnamespace ChilliSource\n{\n    namespace\n    {\n        //-----------------------------------------------------------------------------\n        /// Returns the billboard size for the given size of image with the given \n        /// size policy\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The particle size.\n        /// @param The image size.\n        /// @param The size policy.\n        ///\n        /// @param The billboard size.\n        //-----------------------------------------------------------------------------\n        Vector2 CalcBillboardSize(const Vector2& in_particleSize, const Vector2& in_imageSize, SizePolicy in_sizePolicy)\n        {\n            switch (in_sizePolicy)\n            {\n            case SizePolicy::k_none:\n                return in_particleSize;\n            case SizePolicy::k_usePreferredSize:\n                return in_imageSize;\n            case SizePolicy::k_useWidthMaintainingAspect:\n                return AspectRatioUtils::KeepOriginalWidthAdaptHeight(in_particleSize, in_imageSize.x / in_imageSize.y);\n            case SizePolicy::k_useHeightMaintainingAspect:\n                return AspectRatioUtils::KeepOriginalHeightAdaptWidth(in_particleSize, in_imageSize.x / in_imageSize.y);\n            case SizePolicy::k_fitMaintainingAspect:\n                return AspectRatioUtils::FitOriginal(in_particleSize, in_imageSize.x / in_imageSize.y);\n            case SizePolicy::k_fillMaintainingAspect:\n                return AspectRatioUtils::FillOriginal(in_particleSize, in_imageSize.x / in_imageSize.y);\n            default:\n                CS_LOG_FATAL(\"Invalid size policy.\");\n                return Vector2::k_zero;\n            }\n        }\n    }\n\n    //----------------------------------------------\n    //----------------------------------------------\n    StaticBillboardParticleDrawable::StaticBillboardParticleDrawable(const Entity* in_entity, const ParticleDrawableDef* in_drawableDef, ConcurrentParticleData* in_concurrentParticleData)\n        : ParticleDrawable(in_entity, in_drawableDef, in_concurrentParticleData), m_billboardDrawableDef(static_cast<const StaticBillboardParticleDrawableDef*>(in_drawableDef)),\n        m_particleBillboardIndices(in_drawableDef->GetParticleEffect()->GetMaxParticles())\n    {\n        BuildBillboardImageData();\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    void StaticBillboardParticleDrawable::ActivateParticle(const dynamic_array<ConcurrentParticleData::Particle>& in_particleData, u32 in_index)\n    {\n        CS_ASSERT(in_index >= 0 && in_index < m_particleBillboardIndices.size(), \"Index out of bounds!\");\n\n        switch (m_billboardDrawableDef->GetImageSelectionType())\n        {\n        case StaticBillboardParticleDrawableDef::ImageSelectionType::k_cycle:\n            m_particleBillboardIndices[in_index] = m_nextBillboardIndex++;\n            if (m_nextBillboardIndex >= m_billboards->size())\n            {\n                m_nextBillboardIndex = 0;\n            }\n            break;\n        case StaticBillboardParticleDrawableDef::ImageSelectionType::k_random:\n            m_particleBillboardIndices[in_index] = Random::Generate<u32>(0, static_cast<s32>(m_billboards->size()) - 1);\n            break;\n        default:\n            CS_LOG_FATAL(\"Invalid image selection type.\");\n            break;\n        }\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    void StaticBillboardParticleDrawable::DrawParticles(const dynamic_array<ConcurrentParticleData::Particle>& particleData, RenderSnapshot& renderSnapshot, IAllocator* frameAllocator)\n    {\n        switch (GetDrawableDef()->GetParticleEffect()->GetSimulationSpace())\n        {\n        case ParticleEffect::SimulationSpace::k_local:\n            DrawLocalSpace(particleData, renderSnapshot, frameAllocator);\n            break;\n        case ParticleEffect::SimulationSpace::k_world:\n            DrawWorldSpace(particleData, renderSnapshot, frameAllocator);\n            break;\n        default:\n            CS_LOG_FATAL(\"Invalid simulation space.\");\n        }\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    void StaticBillboardParticleDrawable::BuildBillboardImageData()\n    {\n        const auto& textureAtlas = m_billboardDrawableDef->GetTextureAltas();\n        const auto& atlasIds = m_billboardDrawableDef->GetAtlasIds();\n\n        if (textureAtlas != nullptr && atlasIds.empty() == false)\n        {\n            m_billboards = std::unique_ptr<dynamic_array<BillboardData>>(new dynamic_array<BillboardData>(m_billboardDrawableDef->GetAtlasIds().size()));\n            for (u32 i = 0; i < m_billboards->size(); ++i)\n            {\n                const auto& frame = textureAtlas->GetFrame(m_billboardDrawableDef->GetAtlasIds()[i]);\n\n                //calculate the normalised bounds.\n                f32 left = (-0.5f * frame.m_originalSize.x + frame.m_offset.x) / frame.m_originalSize.x;\n                f32 right = (0.5f * frame.m_originalSize.x - (frame.m_originalSize.x - frame.m_offset.x - frame.m_croppedSize.x)) / frame.m_originalSize.x;\n                f32 top = (0.5f * frame.m_originalSize.y - frame.m_offset.y) / frame.m_originalSize.y;\n                f32 bottom = (-0.5f * frame.m_originalSize.y + (frame.m_originalSize.y - frame.m_offset.y - frame.m_croppedSize.y)) / frame.m_originalSize.y;\n\n                //Get the billboard size. This is determined by the size policy.\n                Vector2 billboardSize = CalcBillboardSize(m_billboardDrawableDef->GetParticleSize(), frame.m_originalSize, m_billboardDrawableDef->GetSizePolicy());\n\n                //build the billboard data.\n                BillboardData& billboardData = m_billboards->at(i);\n                billboardData.m_localSize = Vector2(right - left, top - bottom) * billboardSize;\n                billboardData.m_localCentre = Vector2(left, bottom) * billboardSize + 0.5f * billboardData.m_localSize;\n                billboardData.m_uvs = frame.m_uvs;\n            }\n        }\n        else\n        {\n            auto texture = m_billboardDrawableDef->GetMaterial()->GetTexture();\n            CS_ASSERT(texture != nullptr, \"Particle effect material cannot have no texture.\");\n\n            m_billboards = std::unique_ptr<dynamic_array<BillboardData>>(new dynamic_array<BillboardData>(1));\n\n            Vector2 billboardSize = CalcBillboardSize(m_billboardDrawableDef->GetParticleSize(), Vector2(f32(texture->GetDimensions().x), f32(texture->GetDimensions().y)),\n                m_billboardDrawableDef->GetSizePolicy());\n\n            BillboardData& billboardData = m_billboards->at(0);\n            billboardData.m_localSize = billboardSize;\n            billboardData.m_localCentre = Vector2(0.0f, 0.0f);\n            billboardData.m_uvs = UVs(0.0f, 0.0f, 1.0f, 1.0f);\n        }\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    void StaticBillboardParticleDrawable::DrawLocalSpace(const dynamic_array<ConcurrentParticleData::Particle>& particleData, RenderSnapshot& renderSnapshot, IAllocator* frameAllocator) const\n    {\n        auto renderMaterialGroup = m_billboardDrawableDef->GetMaterial()->GetRenderMaterialGroup();\n        auto entityWorldTransform = GetEntity()->GetTransform().GetWorldTransform();\n\n        //we can't directly apply the parent entities scale to the particles as this would look strange as\n        //the camera moved around an emitting entity with a non-uniform scale, so this works out a uniform\n        //scale from the average of the components.\n        auto entityScale = GetEntity()->GetTransform().GetWorldScale();\n        f32 particleScaleFactor = (entityScale.x + entityScale.y + entityScale.z) / 3.0f;\n\n        //billboard by applying the inverse of the view orientation. The view orientation is the inverse of the camera entity orientation.\n        auto inverseView = renderSnapshot.GetRenderCamera().GetOrientation();\n\n        for (u32 i = 0; i < particleData.size(); ++i)\n        {\n            const auto& particle = particleData[i];\n\n            if (particle.m_isActive == true && particle.m_colour != Colour::k_transparent)\n            {\n                const auto& billboardData = m_billboards->at(m_particleBillboardIndices[i]);\n                \n                auto worldPosition = particle.m_position * entityWorldTransform;\n                auto worldScale = Vector3(particle.m_scale * particleScaleFactor, 1.0f);\n                auto worldOrientation = Quaternion(Vector3::k_unitPositiveZ, particle.m_rotation) * inverseView; //rotate locally in the XY plane before rotating to face the camera.\n                auto worldMatrix = Matrix4::CreateTransform(worldPosition, worldScale, worldOrientation);\n                \n                auto renderDynamicMesh = SpriteMeshBuilder::Build(frameAllocator, Vector3(billboardData.m_localCentre, 0.0f), billboardData.m_localSize, billboardData.m_uvs,\n                                                                  particle.m_colour, AlignmentAnchor::k_middleCentre);\n                auto worldBoundingSphere = Sphere::Transform(renderDynamicMesh->GetBoundingSphere(), worldPosition, worldOrientation, worldScale);\n                \n                renderSnapshot.AddRenderObject(RenderObject(renderMaterialGroup, renderDynamicMesh.get(), worldMatrix, worldBoundingSphere, false, RenderLayer::k_standard));\n                renderSnapshot.AddRenderDynamicMesh(std::move(renderDynamicMesh));\n            }\n        }\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    void StaticBillboardParticleDrawable::DrawWorldSpace(const dynamic_array<ConcurrentParticleData::Particle>& particleData, RenderSnapshot& renderSnapshot, IAllocator* frameAllocator) const\n    {\n        auto renderMaterialGroup = m_billboardDrawableDef->GetMaterial()->GetRenderMaterialGroup();\n\n        //billboard by applying the inverse of the view orientation. The view orientation is the inverse of the camera entity orientation.\n        auto inverseView = renderSnapshot.GetRenderCamera().GetOrientation();\n\n        for (u32 i = 0; i < particleData.size(); ++i)\n        {\n            const auto& particle = particleData[i];\n\n            if (particle.m_isActive == true && particle.m_colour != Colour::k_transparent)\n            {\n                const auto& billboardData = m_billboards->at(m_particleBillboardIndices[i]);\n                \n                auto worldPosition = particle.m_position;\n                auto worldScale = Vector3(particle.m_scale, 1.0f);\n                auto worldOrientation = Quaternion(Vector3::k_unitPositiveZ, particle.m_rotation) * inverseView;  //rotate locally in the XY plane before rotating to face the camera.\n                auto worldMatrix = Matrix4::CreateTransform(worldPosition, worldScale, worldOrientation);\n\n                auto renderDynamicMesh = SpriteMeshBuilder::Build(frameAllocator, Vector3(billboardData.m_localCentre, 0.0f), billboardData.m_localSize, billboardData.m_uvs,\n                                                                  particle.m_colour, AlignmentAnchor::k_middleCentre);\n                auto worldBoundingSphere = Sphere::Transform(renderDynamicMesh->GetBoundingSphere(), worldPosition, worldOrientation, worldScale);\n                \n                renderSnapshot.AddRenderObject(RenderObject(renderMaterialGroup, renderDynamicMesh.get(), worldMatrix, worldBoundingSphere, false, RenderLayer::k_standard));\n                renderSnapshot.AddRenderDynamicMesh(std::move(renderDynamicMesh));\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Particle/Drawable/StaticBillboardParticleDrawable.h",
    "content": "//\n//  StaticBillboardParticleDrawable.h\n//  ChilliSource\n//  Created by Ian Copland on 13/10/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_PARTICLE_DRAWABLE_BILLBOARDPARTICLEDRAWABLE_H_\n#define _CHILLISOURCE_RENDERING_PARTICLE_DRAWABLE_BILLBOARDPARTICLEDRAWABLE_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Container/dynamic_array.h>\n#include <ChilliSource/Core/Math/Vector2.h>\n#include <ChilliSource/Rendering/Particle/Drawable/ParticleDrawable.h>\n#include <ChilliSource/Rendering/Texture/TextureAtlas.h>\n\nnamespace ChilliSource\n{\n    //-----------------------------------------------------------------------\n    /// A particle drawable for rendering particles as billboards.\n    ///\n    /// @author Ian Copland\n    //-----------------------------------------------------------------------\n    class StaticBillboardParticleDrawable final : public ParticleDrawable\n    {\n    private:\n        friend class StaticBillboardParticleDrawableDef;\n        //----------------------------------------------------------------\n        /// A container for information on a single billboard, such as\n        /// the UVs and the local vertex position data.\n        ///\n        /// @author Ian Copland\n        //----------------------------------------------------------------\n        struct BillboardData\n        {\n            UVs m_uvs;\n            Vector2 m_localCentre;\n            Vector2 m_localSize;\n        };\n        //----------------------------------------------------------------\n        /// Constructor.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The entity the effect is attached to.\n        /// @param The particle drawable definition.\n        /// @param The concurrent particle data.\n        //----------------------------------------------------------------\n        StaticBillboardParticleDrawable(const Entity* in_entity, const ParticleDrawableDef* in_drawableDef, ConcurrentParticleData* in_concurrentParticleData);\n        //----------------------------------------------------------------\n        /// Activates the particle with the given index.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The particle draw data.\n        /// @param The index of the particle to activate.\n        //----------------------------------------------------------------\n        void ActivateParticle(const dynamic_array<ConcurrentParticleData::Particle>& in_particleData, u32 in_index) override;\n        //----------------------------------------------------------------\n        /// Renders all active particles in the effect.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param particleData - The particle draw data.\n        /// @param renderSnapshot - The render snapshot that particles\n        /// will be added to.\n        /// @param frameAllocator - Allocate memory for this render frame\n        /// from here\n        //----------------------------------------------------------------\n        void DrawParticles(const dynamic_array<ConcurrentParticleData::Particle>& particleData, RenderSnapshot& renderSnapshot, IAllocator* frameAllocator) override;\n        //----------------------------------------------------------------\n        /// Builds the billboard image data from the provided texture\n        /// or texture atlas.\n        ///\n        /// @author Ian Copland\n        //----------------------------------------------------------------\n        void BuildBillboardImageData();\n        //----------------------------------------------------------------\n        /// Prepares the particle billboard indices. This will either set\n        /// them in order, or randomise them based on the settings for\n        /// the drawable.\n        ///\n        /// @author Ian Copland\n        //----------------------------------------------------------------\n        void PrepareParticleBillboardIndices();\n        //----------------------------------------------------------------\n        /// Draws the particles taking into account the world space\n        /// transform of the owning entity.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param particleData - The particle draw data.\n        /// @param renderSnapshot - The render snapshot that particles\n        /// will be added to.\n        /// @param frameAllocator - Allocate memory for this render frame\n        /// from here\n        //----------------------------------------------------------------\n        void DrawLocalSpace(const dynamic_array<ConcurrentParticleData::Particle>& particleData, RenderSnapshot& renderSnapshot, IAllocator* frameAllocator) const;\n        //----------------------------------------------------------------\n        /// Draws the particles without taking into account the world\n        /// space transform of the owning entity as the particles are\n        /// already in world space.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param particleData - The particle draw data.\n        /// @param renderSnapshot - The render snapshot that particles\n        /// will be added to.\n        /// @param frameAllocator - Allocate memory for this render frame\n        /// from here\n        //----------------------------------------------------------------\n        void DrawWorldSpace(const dynamic_array<ConcurrentParticleData::Particle>& particleData, RenderSnapshot& renderSnapshot, IAllocator* frameAllocator) const;\n\n        const StaticBillboardParticleDrawableDef* m_billboardDrawableDef;\n        std::unique_ptr <dynamic_array<BillboardData>> m_billboards;\n        dynamic_array<u32> m_particleBillboardIndices;\n        u32 m_nextBillboardIndex = 0;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Particle/Drawable/StaticBillboardParticleDrawableDef.cpp",
    "content": "//\n//  StaticBillboardParticleDrawableDef.cpp\n//  ChilliSource\n//  Created by Ian Copland on 13/10/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Particle/Drawable/StaticBillboardParticleDrawableDef.h>\n\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/Resource/ResourcePool.h>\n#include <ChilliSource/Core/String/StringUtils.h>\n#include <ChilliSource/Core/String/StringParser.h>\n#include <ChilliSource/Rendering/Material/Material.h>\n#include <ChilliSource/Rendering/Particle/Drawable/StaticBillboardParticleDrawable.h>\n#include <ChilliSource/Rendering/Texture/TextureAtlas.h>\n\nnamespace ChilliSource\n{\n    namespace\n    {\n        //-----------------------------------------------------------------\n        /// Parse an image selection type from the given string. This is\n        /// case insensitive. If the string is not a valid image selection\n        /// type this will error.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The string to parse.\n        ///\n        /// @return the parsed image selection type.\n        //-----------------------------------------------------------------\n        StaticBillboardParticleDrawableDef::ImageSelectionType ParseImageSelectionType(const std::string& in_imageSelectionTypeString)\n        {\n            std::string imageSelectionTypeString = in_imageSelectionTypeString;\n            StringUtils::ToLowerCase(imageSelectionTypeString);\n\n            if (imageSelectionTypeString == \"cycle\")\n            {\n                return StaticBillboardParticleDrawableDef::ImageSelectionType::k_cycle;\n            }\n            else if (imageSelectionTypeString == \"random\")\n            {\n                return StaticBillboardParticleDrawableDef::ImageSelectionType::k_random;\n            }\n\n            CS_LOG_FATAL(\"Invalid image selection type: \" + in_imageSelectionTypeString);\n            return StaticBillboardParticleDrawableDef::ImageSelectionType::k_random;\n        }\n        //-----------------------------------------------------------------\n        /// Parse a list of space separated strings.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The string to parse.\n        ///\n        /// @return the parsed list of strings.\n        //-----------------------------------------------------------------\n        std::vector<std::string> ParseStringList(const std::string& in_stringList)\n        {\n            return StringUtils::Split(in_stringList, \" \");\n        }\n    }\n\n    CS_DEFINE_NAMEDTYPE(StaticBillboardParticleDrawableDef);\n    //--------------------------------------------------\n    //--------------------------------------------------\n    StaticBillboardParticleDrawableDef::StaticBillboardParticleDrawableDef(const MaterialCSPtr& in_material, const Vector2& in_particleSize, SizePolicy in_sizePolicy)\n        : m_material(in_material), m_particleSize(in_particleSize), m_sizePolicy(in_sizePolicy)\n    {\n        CS_ASSERT(m_material != nullptr, \"Cannot create a Billboard Particle Drawable Def with a null material.\");\n    }\n    //--------------------------------------------------\n    //--------------------------------------------------\n    StaticBillboardParticleDrawableDef::StaticBillboardParticleDrawableDef(const MaterialCSPtr& in_material, const TextureAtlasCSPtr& in_textureAtlas, const std::string& in_atlasId, const Vector2& in_particleSize, SizePolicy in_sizePolicy)\n        : m_material(in_material), m_textureAtlas(in_textureAtlas), m_particleSize(in_particleSize), m_sizePolicy(in_sizePolicy)\n    {\n        CS_ASSERT(m_material != nullptr, \"Cannot create a Billboard Particle Drawable Def with a null material.\");\n        CS_ASSERT(m_textureAtlas != nullptr, \"Cannot create a Billboard Particle Drawable Def with a null texture atlas.\");\n\n        m_atlasIds.push_back(in_atlasId);\n    }\n    //--------------------------------------------------\n    //--------------------------------------------------\n    StaticBillboardParticleDrawableDef::StaticBillboardParticleDrawableDef(const MaterialCSPtr& in_material, const TextureAtlasCSPtr& in_textureAtlas, const std::vector<std::string>& in_atlasIds, ImageSelectionType in_imageSelectionType, const Vector2& in_particleSize, SizePolicy in_sizePolicy)\n        : m_material(in_material), m_textureAtlas(in_textureAtlas), m_atlasIds(in_atlasIds), m_imageSelectionType(in_imageSelectionType), m_particleSize(in_particleSize), m_sizePolicy(in_sizePolicy)\n    {\n        CS_ASSERT(m_material != nullptr, \"Cannot create a Billboard Particle Drawable Def with a null material.\");\n        CS_ASSERT(m_textureAtlas != nullptr, \"Cannot create a Billboard Particle Drawable Def with a null texture atlas.\");\n    }\n    //--------------------------------------------------\n    //--------------------------------------------------\n    StaticBillboardParticleDrawableDef::StaticBillboardParticleDrawableDef(const Json::Value& in_paramsJson, const LoadedDelegate& in_asyncDelegate)\n    {\n        //Image selection type\n        Json::Value jsonValue = in_paramsJson.get(\"ImageSelectionType\", Json::nullValue);\n        if (jsonValue.isNull() == false)\n        {\n            CS_ASSERT(jsonValue.isString(), \"Image selection type must be a string.\");\n            m_imageSelectionType = ParseImageSelectionType(jsonValue.asString());\n        }\n\n        //Particle size\n        jsonValue = in_paramsJson.get(\"ParticleSize\", Json::nullValue);\n        if (jsonValue.isNull() == false)\n        {\n            CS_ASSERT(jsonValue.isString(), \"particle size must be a string.\");\n            m_particleSize = ParseVector2(jsonValue.asString());\n        }\n\n        //Size Policy\n        jsonValue = in_paramsJson.get(\"SizePolicy\", Json::nullValue);\n        if (jsonValue.isNull() == false)\n        {\n            CS_ASSERT(jsonValue.isString(), \"size policy must be a string.\");\n            m_sizePolicy = ParseSizePolicy(jsonValue.asString());\n        }\n\n        //load the resources.\n        if (in_asyncDelegate == nullptr)\n        {\n            LoadResources(in_paramsJson);\n        }\n        else\n        {\n            LoadResourcesAsync(in_paramsJson, in_asyncDelegate);\n        }\n    }\n    //--------------------------------------------------\n    //-------------------------------------------------\n    bool StaticBillboardParticleDrawableDef::IsA(InterfaceIDType in_interfaceId) const\n    {\n        return (ParticleDrawableDef::InterfaceID == in_interfaceId || StaticBillboardParticleDrawableDef::InterfaceID == in_interfaceId);\n    }\n    //--------------------------------------------------\n    //--------------------------------------------------\n    ParticleDrawableUPtr StaticBillboardParticleDrawableDef::CreateInstance(const Entity* in_entity, ConcurrentParticleData* in_concurrentParticleData) const\n    {\n        return ParticleDrawableUPtr(new StaticBillboardParticleDrawable(in_entity, this, in_concurrentParticleData));\n    }\n    //--------------------------------------------------\n    //--------------------------------------------------\n    const MaterialCSPtr& StaticBillboardParticleDrawableDef::GetMaterial() const\n    {\n        return m_material;\n    }\n    //--------------------------------------------------\n    //--------------------------------------------------\n    const TextureAtlasCSPtr& StaticBillboardParticleDrawableDef::GetTextureAltas() const\n    {\n        return m_textureAtlas;\n    }\n    //--------------------------------------------------\n    //--------------------------------------------------\n    const std::vector<std::string>& StaticBillboardParticleDrawableDef::GetAtlasIds() const\n    {\n        return m_atlasIds;\n    }\n    //--------------------------------------------------\n    //--------------------------------------------------\n    StaticBillboardParticleDrawableDef::ImageSelectionType StaticBillboardParticleDrawableDef::GetImageSelectionType() const\n    {\n        return m_imageSelectionType;\n    }\n    //--------------------------------------------------\n    //--------------------------------------------------\n    const Vector2& StaticBillboardParticleDrawableDef::GetParticleSize() const\n    {\n        return m_particleSize;\n    }\n    //--------------------------------------------------\n    //--------------------------------------------------\n    SizePolicy StaticBillboardParticleDrawableDef::GetSizePolicy() const\n    {\n        return m_sizePolicy;\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    void StaticBillboardParticleDrawableDef::LoadResources(const Json::Value& in_paramsJson)\n    {\n        auto resourcePool = Application::Get()->GetResourcePool();\n\n        //material\n        Json::Value materialLocationJson = in_paramsJson.get(\"MaterialLocation\", \"Package\");\n        Json::Value materialPathJson = in_paramsJson.get(\"MaterialPath\", Json::nullValue);\n        CS_ASSERT(materialLocationJson.isNull() == false && materialLocationJson.isString() == true && materialPathJson.isNull() == false &&\n            materialPathJson.isString() == true, \"Must provide a valid material for a billboard particle drawable.\");\n\n        m_material = resourcePool->LoadResource<Material>(ParseStorageLocation(materialLocationJson.asString()), materialPathJson.asString());\n        CS_ASSERT((m_material != nullptr && m_material->GetLoadState() == Resource::LoadState::k_loaded), \"Could not load material: \" + materialPathJson.asString());\n\n        //texture atlas\n        Json::Value atlasPathJson = in_paramsJson.get(\"AtlasPath\", Json::nullValue);\n        if (atlasPathJson.isNull() == false)\n        {\n            CS_ASSERT(atlasPathJson.isString() == true, \"Atlas path must be a string.\");\n\n            Json::Value imageIdsJson = in_paramsJson.get(\"ImageIds\", Json::nullValue);\n            CS_ASSERT(imageIdsJson.isNull() == false && imageIdsJson.isString() == true, \"Must provide valid Image Ids if using a texture atlas.\");\n\n            m_atlasIds = ParseStringList(imageIdsJson.asString());\n            CS_ASSERT(m_atlasIds.empty() == false, \"Atlas Ids empty.\");\n\n            Json::Value atlasLocationJson = in_paramsJson.get(\"AtlasLocation\", \"Package\");\n            CS_ASSERT(atlasLocationJson.isNull() == false && atlasLocationJson.isString() == true, \"Invalid atlas path and location.\");\n\n            m_textureAtlas = resourcePool->LoadResource<TextureAtlas>(ParseStorageLocation(atlasLocationJson.asString()), atlasPathJson.asString());\n            CS_ASSERT((m_textureAtlas != nullptr && m_textureAtlas->GetLoadState() == Resource::LoadState::k_loaded), \"Could not load texture atlas: \" + atlasPathJson.asString());\n        }\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    void StaticBillboardParticleDrawableDef::LoadResourcesAsync(const Json::Value& in_paramsJson, const LoadedDelegate& in_asyncDelegate)\n    {\n        auto resourcePool = Application::Get()->GetResourcePool();\n\n        //material\n        Json::Value materialLocationJson = in_paramsJson.get(\"MaterialLocation\", \"Package\");\n        Json::Value materialPathJson = in_paramsJson.get(\"MaterialPath\", Json::nullValue);\n        CS_ASSERT(materialLocationJson.isNull() == false && materialLocationJson.isString() == true && materialPathJson.isNull() == false &&\n            materialPathJson.isString() == true, \"Must provide a valid material for a billboard particle drawable.\");\n\n        resourcePool->LoadResourceAsync<Material>(ParseStorageLocation(materialLocationJson.asString()), materialPathJson.asString(), [=](const MaterialCSPtr& in_material)\n        {\n            m_material = in_material;\n            CS_ASSERT((m_material != nullptr && m_material->GetLoadState() == Resource::LoadState::k_loaded), \"Could not load material: \" + materialPathJson.asString());\n\n            //texture atlas\n            Json::Value atlasPathJson = in_paramsJson.get(\"AtlasPath\", Json::nullValue);\n            if (atlasPathJson.isNull() == false)\n            {\n                CS_ASSERT(atlasPathJson.isString() == true, \"Atlas path must be a string.\");\n\n                Json::Value imageIdsJson = in_paramsJson.get(\"ImageIds\", Json::nullValue);\n                CS_ASSERT(imageIdsJson.isNull() == false && imageIdsJson.isString() == true, \"Must provide valid Image Ids if using a texture atlas.\");\n\n                m_atlasIds = ParseStringList(imageIdsJson.asString());\n                CS_ASSERT(m_atlasIds.empty() == false, \"Atlas Ids empty.\");\n\n                Json::Value atlasLocationJson = in_paramsJson.get(\"AtlasLocation\", \"Package\");\n                CS_ASSERT(atlasLocationJson.isNull() == false && atlasLocationJson.isString() == true, \"Invalid atlas path and location.\");\n\n                resourcePool->LoadResourceAsync<TextureAtlas>(ParseStorageLocation(atlasLocationJson.asString()), atlasPathJson.asString(), [=](const TextureAtlasCSPtr& in_textureAtlas)\n                {\n                    m_textureAtlas = in_textureAtlas;\n                    CS_ASSERT((m_textureAtlas != nullptr && m_textureAtlas->GetLoadState() == Resource::LoadState::k_loaded), \"Could not load texture atlas: \" + atlasPathJson.asString());\n\n                    in_asyncDelegate(this);\n                });\n            }\n        });\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Particle/Drawable/StaticBillboardParticleDrawableDef.h",
    "content": "//\n//  StaticBillboardParticleDrawableDef.h\n//  ChilliSource\n//  Created by Ian Copland on 13/10/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_PARTICLE_DRAWABLE_BILLBOARDPARTICLEDRAWABLEDEF_H_\n#define _CHILLISOURCE_RENDERING_PARTICLE_DRAWABLE_BILLBOARDPARTICLEDRAWABLEDEF_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Math/Vector2.h>\n#include <ChilliSource/Rendering/Base/SizePolicy.h>\n#include <ChilliSource/Rendering/Particle/Drawable/ParticleDrawableDef.h>\n\n#include <json/json.h>\n\nnamespace ChilliSource\n{\n    //-----------------------------------------------------------------------\n    /// The definition for a billboard particle drawable. This enables the \n    /// drawing of individual particles as camera facing sprites.\n    ///\n    /// As a particle drawable def's contents can potentially be read from \n    /// multiple threads, it is immutable after construction. The exception \n    /// to this is if it was created from a param dictionary with a \n    /// asynchronous delegate, in which case it is immutable after the\n    /// delegate returns.\n    ///\n    /// The following are the parameters of a billboard particle drawable\n    /// def:\n    ///\n    /// \"MaterialLocation\": The storage location of the material that \n    /// will be used to render the particles.\n    ///\n    /// \"MaterialPath\": The file path of the material that will be used\n    /// to render the particles.\n    ///\n    /// \"AtlasLocation\": The storage location of the texture atlas \n    /// that will be used to render the particles.\n    ///\n    /// \"AtlasPath\": The file path of the texture atlas that will be \n    /// used to render the particles.\n    ///\n    /// \"AtlasIds\": A space separated list of texture atlas Ids that \n    /// will be used to render the particles.\n    ///\n    /// \"ImageSelectionType\": A string describing the method used to \n    /// select the atlas Id. Possible values are \"Random\" or \"Cycle\".\n    ///\n    /// \"ParticleSize\": The base size for a billboard.\n    ///\n    /// \"SizePolicy\": The size policy describing how the particle is \n    /// rendered when the rendered image has a different aspect ratio\n    /// to the given size. Possible values are: “None”,\n    /// “FillMaintainingAspect”, “FitMaintainingAspect”,\n    /// “UseHeightMaintainingAspect”, “UsePreferredSize”,\n    /// “UseWidthMaintainingAspect”\n    ///\n    /// @author Ian Copland\n    //-----------------------------------------------------------------------\n    class StaticBillboardParticleDrawableDef final : public ParticleDrawableDef\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(StaticBillboardParticleDrawableDef);\n        //----------------------------------------------------------------\n        /// An enum describing the different types of image selection. \n        /// Random will pick an image from the list at random, while cycle\n        /// will cycle through each image in the list in order.\n        ///\n        /// @author Ian Copland\n        //----------------------------------------------------------------\n        enum class ImageSelectionType\n        {\n            k_random,\n            k_cycle\n        };\n        //----------------------------------------------------------------\n        /// Constructor for creating a billboard particle drawable\n        /// definition which uses just a material.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The material that will be used to render the particles.\n        /// @param The base size for a particles.\n        /// @param The size policy describing how the particle is rendered\n        /// when the rendered image has a different aspect ratio to the \n        /// given size.\n        //----------------------------------------------------------------\n        StaticBillboardParticleDrawableDef(const MaterialCSPtr& in_material, const Vector2& in_particleSize, SizePolicy in_sizePolicy);\n        //----------------------------------------------------------------\n        /// Constructor for creating a billboard particle drawable definition\n        /// which uses a texture atlas and multiple atlas Ids.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The material that will be used to render the particles.\n        /// @param The texture altas that will be used to render the \n        /// particles.\n        /// @param The atlas Id.\n        /// @param The base size for a particles.\n        /// @param The size policy describing how the particle is rendered \n        /// when the rendered image has a different aspect ratio to the \n        /// given size.\n        //----------------------------------------------------------------\n        StaticBillboardParticleDrawableDef(const MaterialCSPtr& in_material, const TextureAtlasCSPtr& in_textureAtlas, const std::string& in_atlasId, const Vector2& in_particleSize, SizePolicy in_sizePolicy);\n        //----------------------------------------------------------------\n        /// Constructor for creating a billboard particle drawable \n        /// definition which uses a texture atlas and multiple atlas Ids.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The material that will be used to render the particles.\n        /// @param The texture altas that will be used to render the \n        /// particles.\n        /// @param A list of Image Ids describing the various images that\n        /// will be used to render the particles.\n        /// @param The method that will be used to select Image Ids.\n        /// @param The base size for a particles.\n        /// @param The size policy describing how the particle is rendered\n        /// when the rendered image has a different aspect ratio to the \n        /// given size.\n        //----------------------------------------------------------------\n        StaticBillboardParticleDrawableDef(const MaterialCSPtr& in_material, const TextureAtlasCSPtr& in_textureAtlas, const std::vector<std::string>& in_atlasIds, ImageSelectionType in_imageSelectionType, const Vector2& in_particleSize, SizePolicy in_sizePolicy);\n        //----------------------------------------------------------------\n        /// Constructor. Loads the params for the drawable def from the \n        /// given json params. If the async delegate is not null, then\n        /// any resource loading will occur as a background task. Once \n        /// complete the delegate will be called. The values read from\n        /// json are described in the class documentation.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The json params.\n        /// @param The asynchronous load delegate.\n        //----------------------------------------------------------------\n        StaticBillboardParticleDrawableDef(const Json::Value& in_paramsJson, const LoadedDelegate& in_asyncDelegate = nullptr);\n        //----------------------------------------------------------------\n        /// Allows querying of whether or not this implements the interface \n        /// described by the given Id.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The interface Id.\n        ///\n        /// @return Whether or not the interface is implemented.\n        //----------------------------------------------------------------\n        bool IsA(InterfaceIDType in_interfaceId) const override;\n        //----------------------------------------------------------------\n        /// Creates an instance of the particle drawable described by this.\n        ///\n        /// @author Ian Copland.\n        ///\n        /// @param The entity that owns the effect.\n        /// @param The concurrent particle data.\n        ///\n        /// @return the instance.\n        //----------------------------------------------------------------\n        ParticleDrawableUPtr CreateInstance(const Entity* in_entity, ConcurrentParticleData* in_concurrentParticleData) const override;\n        //----------------------------------------------------------------\n        /// @author Ian Copland.\n        ///\n        /// @return The material that will be used to render the particles.\n        //----------------------------------------------------------------\n        const MaterialCSPtr& GetMaterial() const override;\n        //----------------------------------------------------------------\n        /// @author Ian Copland.\n        ///\n        /// @return The texture atlas that will be used to render the \n        /// particles. If this is null then the particles will be rendered\n        /// using the whole texture.\n        //----------------------------------------------------------------\n        const TextureAtlasCSPtr& GetTextureAltas() const;\n        //----------------------------------------------------------------\n        /// @author Ian Copland.\n        ///\n        /// @return The list of texture Ids that will be used to render \n        /// the particles. If this is empty then the particles will be \n        /// rendered using the whole texture.\n        //----------------------------------------------------------------\n        const std::vector<std::string>& GetAtlasIds() const;\n        //----------------------------------------------------------------\n        /// @author Ian Copland.\n        ///\n        /// @return The method that will be used to select the next image \n        /// from the atlas id list. \n        //----------------------------------------------------------------\n        ImageSelectionType GetImageSelectionType() const;\n        //----------------------------------------------------------------\n        /// @author Ian Copland.\n        ///\n        /// @return The particle size.\n        //----------------------------------------------------------------\n        const Vector2& GetParticleSize() const;\n        //----------------------------------------------------------------\n        /// @author Ian Copland.\n        ///\n        /// @return The method that will be used to size a particle when \n        /// the image size and the particle size have a different aspect \n        /// ratio.\n        //----------------------------------------------------------------\n        SizePolicy GetSizePolicy() const;\n    private:\n        //----------------------------------------------------------------\n        /// Loads the billboard resources on the main thread.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param A json object describing the resources.\n        //----------------------------------------------------------------\n        void LoadResources(const Json::Value& in_paramsJson);\n        //----------------------------------------------------------------\n        /// Loads the billboard resources on a background thread. Once\n        /// complete the async delegate will be called.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param A json object describing the resources.\n        /// @param The async delegate.\n        //----------------------------------------------------------------\n        void LoadResourcesAsync(const Json::Value& in_paramsJson, const LoadedDelegate& in_asyncDelegate);\n\n        MaterialCSPtr m_material;\n        TextureAtlasCSPtr m_textureAtlas;\n        std::vector<std::string> m_atlasIds;\n        ImageSelectionType m_imageSelectionType = ImageSelectionType::k_cycle;\n        Vector2 m_particleSize = Vector2::k_one;\n        SizePolicy m_sizePolicy = SizePolicy::k_none;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Particle/Emitter/CircleParticleEmitter.cpp",
    "content": "//\n//  CircleParticleEmitter.cpp\n//  ChilliSource\n//  Created by Ian Copland on 02/11/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Particle/Emitter/CircleParticleEmitter.h>\n\n#include <ChilliSource/Core/Math/Random.h>\n#include <ChilliSource/Rendering/Particle/ParticleEffect.h>\n#include <ChilliSource/Rendering/Particle/Emitter/CircleParticleEmitterDef.h>\n\nnamespace ChilliSource\n{\n    namespace\n    {\n        //----------------------------------------------------------------\n        /// Generates a point within a circle with even distribution. \n        ///\n        /// @author Ian Copland\n        ///\n        /// @return A random point in a unit circle.\n        //----------------------------------------------------------------\n        Vector2 GeneratePointInUnitCircle()\n        {\n            f32 dist = std::sqrt(Random::GenerateNormalised<f32>());\n            return Random::GenerateDirection2D<f32>() * dist;\n        }\n    }\n\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    CircleParticleEmitter::CircleParticleEmitter(const ParticleEmitterDef* in_particleEmitter, dynamic_array<Particle>* in_particleArray)\n        : ParticleEmitter(in_particleEmitter, in_particleArray)\n    {\n        //Only the circle emitter def can create this, so this is safe.\n        m_circleParticleEmitterDef = static_cast<const CircleParticleEmitterDef*>(in_particleEmitter);\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    void CircleParticleEmitter::GenerateEmission(f32 in_normalisedEmissionTime, Vector3& out_position, Vector3& out_direction)\n    {\n        f32 radius = m_circleParticleEmitterDef->GetRadiusProperty()->GenerateValue(in_normalisedEmissionTime);\n\n        //calculate the position.\n        switch (m_circleParticleEmitterDef->GetEmitFromType())\n        {\n        case CircleParticleEmitterDef::EmitFromType::k_inside:\n            out_position = Vector3(GeneratePointInUnitCircle() * radius, 0.0f);\n            break;\n        case CircleParticleEmitterDef::EmitFromType::k_surface:\n            out_position = Vector3(Random::GenerateDirection2D<f32>() * radius, 0.0f);\n            break;\n        default:\n            CS_LOG_FATAL(\"Invalid 'Emit From' type.\");\n            break;\n        }\n\n        //calculate the direction.\n        switch (m_circleParticleEmitterDef->GetEmitDirectionType())\n        {\n        case CircleParticleEmitterDef::EmitDirectionType::k_random:\n            out_direction = Vector3(Random::GenerateDirection2D<f32>(), 0.0f);\n            break;\n        case CircleParticleEmitterDef::EmitDirectionType::k_awayFromCentre:\n            out_direction = Vector3::Normalise(out_position);\n            break;\n        default:\n            CS_LOG_FATAL(\"Invalid 'Emit Direction' type.\");\n            break;\n        }\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Particle/Emitter/CircleParticleEmitter.h",
    "content": "//\n//  CircleParticleEmitter.h\n//  ChilliSource\n//  Created by Ian Copland on 02/11/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_PARTICLES_EMITTER_CIRCLEPARTICLEEMITTER_H_\n#define _CHILLISOURCE_RENDERING_PARTICLES_EMITTER_CIRCLEPARTICLEEMITTER_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Rendering/Particle/Emitter/ParticleEmitter.h>\n\nnamespace ChilliSource\n{\n    //-----------------------------------------------------------------------\n    /// A circle particle emitter. This spawns particles either within a \n    /// circle or on the circle's perimeter, with a random direction or moving\n    /// away from the centre of the circle. \n    ///\n    /// Particle emitters will be updated as a background task and should not\n    /// be accessed from other threads.\n    ///\n    /// @author Ian Copland\n    //-----------------------------------------------------------------------\n    class CircleParticleEmitter final : public ParticleEmitter\n    {\n    public:\n        //----------------------------------------------------------------\n        /// Generates the position and direction of a new emission. These \n        /// values are in local space. This will be called as part of a \n        /// background task.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The normalised emission playback time.\n        /// @param [Out] The generated position in local space.\n        /// @param [Out] The generate direction in local space.\n        //----------------------------------------------------------------\n        void GenerateEmission(f32 in_normalisedEmissionTime, Vector3& out_position, Vector3& out_direction) override;\n    private:\n        friend class CircleParticleEmitterDef;\n        //----------------------------------------------------------------\n        /// Constructor.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The particle emitter definition.\n        /// @param The particle array.\n        //----------------------------------------------------------------\n        CircleParticleEmitter(const ParticleEmitterDef* in_particleEmitter, dynamic_array<Particle>* in_particleArray);\n\n        const CircleParticleEmitterDef* m_circleParticleEmitterDef = nullptr;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Particle/Emitter/CircleParticleEmitterDef.cpp",
    "content": "//\n//  CircleParticleEmitterDef.cpp\n//  ChilliSource\n//  Created by Ian Copland on 02/11/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Particle/Emitter/CircleParticleEmitterDef.h>\n\n#include <ChilliSource/Rendering/Particle/Emitter/CircleParticleEmitter.h>\n#include <ChilliSource/Rendering/Particle/Property/ParticlePropertyFactory.h>\n\nnamespace ChilliSource\n{\n    namespace\n    {\n        //-----------------------------------------------------------------\n        /// Parse an emit from type from the given string. This is case \n        /// insensitive. If the string is not a valid emit from type this \n        /// will error.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The string to parse.\n        ///\n        /// @return the parsed emit from type.\n        //-----------------------------------------------------------------\n        CircleParticleEmitterDef::EmitFromType ParseEmitFromType(const std::string& in_emitFromTypeString)\n        {\n            std::string emitFromTypeString = in_emitFromTypeString;\n            StringUtils::ToLowerCase(emitFromTypeString);\n\n            if (emitFromTypeString == \"inside\")\n            {\n                return CircleParticleEmitterDef::EmitFromType::k_inside;\n            }\n            else if (emitFromTypeString == \"surface\")\n            {\n                return CircleParticleEmitterDef::EmitFromType::k_surface;\n            }\n\n            CS_LOG_FATAL(\"Invalid emit from type: \" + in_emitFromTypeString);\n            return CircleParticleEmitterDef::EmitFromType::k_inside;\n        }\n        //-----------------------------------------------------------------\n        /// Parse an emit direction type from the given string. This is case \n        /// insensitive. If the string is not a valid direction from type this \n        /// will error.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The string to parse.\n        ///\n        /// @return the parsed emit direction type.\n        //-----------------------------------------------------------------\n        CircleParticleEmitterDef::EmitDirectionType ParseEmitDirectionType(const std::string& in_emitDirectionTypeString)\n        {\n            std::string emitDirectionTypeString = in_emitDirectionTypeString;\n            StringUtils::ToLowerCase(emitDirectionTypeString);\n\n            if (emitDirectionTypeString == \"awayfromcentre\")\n            {\n                return CircleParticleEmitterDef::EmitDirectionType::k_awayFromCentre;\n            }\n            else if (emitDirectionTypeString == \"random\")\n            {\n                return CircleParticleEmitterDef::EmitDirectionType::k_random;\n            }\n\n            CS_LOG_FATAL(\"Invalid emit direction type: \" + in_emitDirectionTypeString);\n            return CircleParticleEmitterDef::EmitDirectionType::k_awayFromCentre;\n        }\n    }\n\n    CS_DEFINE_NAMEDTYPE(CircleParticleEmitterDef);\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    CircleParticleEmitterDef::CircleParticleEmitterDef(EmissionMode in_emissionMode, ParticlePropertyUPtr<f32> in_emissionRateProperty, ParticlePropertyUPtr<u32> in_particlesPerEmissionProperty,\n        ParticlePropertyUPtr<f32> in_emissionChanceProperty, EmitFromType in_emitFromType, EmitDirectionType in_emitDirectionType, ParticlePropertyUPtr<f32> in_radiusProperty)\n        : ParticleEmitterDef(in_emissionMode, std::move(in_emissionRateProperty), std::move(in_particlesPerEmissionProperty), std::move(in_emissionChanceProperty)), m_emitFromType(in_emitFromType),\n        m_emitDirectionType(in_emitDirectionType), m_radiusProperty(std::move(in_radiusProperty))\n    {\n        CS_ASSERT(m_radiusProperty != nullptr, \"Cannot create a Circle Particle Emitter Def with a null 'radius' property.\");\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    CircleParticleEmitterDef::CircleParticleEmitterDef(const Json::Value& in_paramsJson, const LoadedDelegate& in_loadedDelegate)\n        : ParticleEmitterDef(in_paramsJson)\n    {\n        //Emit from type\n        Json::Value jsonValue = in_paramsJson.get(\"EmitFromType\", Json::nullValue);\n        if (jsonValue.isNull() == false)\n        {\n            CS_ASSERT(jsonValue.isString(), \"Emit from type must be a string.\");\n            m_emitFromType = ParseEmitFromType(jsonValue.asString());\n        }\n\n        //Emit direction type\n        jsonValue = in_paramsJson.get(\"EmitDirectionType\", Json::nullValue);\n        if (jsonValue.isNull() == false)\n        {\n            CS_ASSERT(jsonValue.isString(), \"Emit direction type must be a string.\");\n            m_emitDirectionType = ParseEmitDirectionType(jsonValue.asString());\n        }\n\n        //Radius\n        jsonValue = in_paramsJson.get(\"RadiusProperty\", Json::nullValue);\n        if (jsonValue.isNull() == false)\n        {\n            m_radiusProperty = ParticlePropertyFactory::CreateProperty<f32>(jsonValue);\n        }\n\n        //call the loaded delegate if required.\n        if (in_loadedDelegate != nullptr)\n        {\n            in_loadedDelegate(this);\n        }\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    bool CircleParticleEmitterDef::IsA(InterfaceIDType in_interfaceId) const\n    {\n        return (ParticleEmitterDef::InterfaceID == in_interfaceId || CircleParticleEmitterDef::InterfaceID == in_interfaceId);\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    ParticleEmitterUPtr CircleParticleEmitterDef::CreateInstance(dynamic_array<Particle>* in_particleArray) const\n    {\n        return ParticleEmitterUPtr(new CircleParticleEmitter(this, in_particleArray));\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    CircleParticleEmitterDef::EmitFromType CircleParticleEmitterDef::GetEmitFromType() const\n    {\n        return m_emitFromType;\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    CircleParticleEmitterDef::EmitDirectionType CircleParticleEmitterDef::GetEmitDirectionType() const\n    {\n        return m_emitDirectionType;\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    const ParticleProperty<f32>* CircleParticleEmitterDef::GetRadiusProperty() const\n    {\n        return m_radiusProperty.get();\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Particle/Emitter/CircleParticleEmitterDef.h",
    "content": "//\n//  CircleParticleEmitterDef.h\n//  ChilliSource\n//  Created by Ian Copland on 02/11/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_PARTICLE_EMITTER_CIRCLEPARTICLEEMITTERDEF_H_\n#define _CHILLISOURCE_RENDERING_PARTICLE_EMITTER_CIRCLEPARTICLEEMITTERDEF_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Rendering/Particle/Emitter/ParticleEmitterDef.h>\n\nnamespace ChilliSource\n{\n    //-----------------------------------------------------------------------\n    /// A particle emitter def describing the properties for a Circle Particle\n    /// Emitter and provides a means to create instances.\n    ///\n    /// As a particle emitter def's contents can potentially be read from \n    /// multiple threads, it is immutable after construction. The exception \n    /// to this is if it was created from a param dictionary with a \n    /// asynchronous delegate, in which case it is immutable after the\n    /// delegate is called.\n    ///\n    /// The following are properties that a circle particle emitter \n    /// contains in addition to the standard emitter properties:\n    ///\n    /// \"EmitFromType\": Where on the particle emitter particles can be\n    /// emitted from. The possible values are \"Inside\" or \"Surface\".\n    /// The default value is \"Inside\".\n    ///\n    /// \"EmitDirectionType\": Describes how the direction of an emitted\n    /// particle will be generated. The possible values are \"AwayFromCentre\"\n    /// and \"Random\". This defaults to \"AwayFromCentre\".\n    ///\n    /// \"RadiusProperty\": A property describing the radius of the emitter.\n    ///\n    /// @author Ian Copland\n    //-----------------------------------------------------------------------\n    class CircleParticleEmitterDef final : public ParticleEmitterDef\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(CircleParticleEmitterDef);\n        //----------------------------------------------------------------\n        /// An enum describing where in the emitter a particle can be\n        /// generated. If inside is used, the particle can be emitted from\n        /// anywhere inside the circle. If surface is used, particles will\n        /// only be emitted from the circumference of the circle.\n        /// \n        /// @author Ian Copland\n        //----------------------------------------------------------------\n        enum class EmitFromType\n        {\n            k_inside,\n            k_surface\n        };\n        //----------------------------------------------------------------\n        /// An enum describing the possible ways the emission direction\n        /// of a particle can be generated. If Away From Centre is used the \n        /// particle will always move in a direction away from the centre\n        /// of the emitter. If random is used, the direction will be\n        /// random, within the plane of the circle.\n        /// \n        /// @author Ian Copland\n        //----------------------------------------------------------------\n        enum class EmitDirectionType\n        {\n            k_awayFromCentre,\n            k_random\n        };\n        //----------------------------------------------------------------\n        /// Constructor\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The emission mode.\n        /// @param The emission rate property. This is ignored for when in \n        /// burst emission mode.\n        /// @param The property describing the number of particles in each\n        /// emission.\n        /// @param The property describing the chance that a particle will \n        /// actually emit each time an emission is attempted. This is used\n        /// to make an effect look more random.\n        /// @param Where in the circle a particle can be emitted from.\n        /// @param Describes how the direction of a particle will be\n        /// determined.\n        /// @param The property describing the radius of the emitter.\n        //----------------------------------------------------------------\n        CircleParticleEmitterDef(EmissionMode in_emissionMode, ParticlePropertyUPtr<f32> in_emissionRateProperty, ParticlePropertyUPtr<u32> in_particlesPerEmissionProperty,\n            ParticlePropertyUPtr<f32> in_emissionChanceProperty, EmitFromType in_emitFromType, EmitDirectionType in_emitDirectionType, ParticlePropertyUPtr<f32> in_radiusProperty);\n        //----------------------------------------------------------------\n        /// Constructor. Initialises with parameters read from the given \n        /// param dictionary. If the async delegate is not null, then any \n        /// resource loading will occur as a background task. Once complete \n        /// the delegate will be called. The parameters read from json are\n        /// described in the class documentation.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param A json object describing the parameters for the particle\n        /// emitter def.\n        /// @param The loaded delegate. If this is supplied any resources\n        /// will be loaded as a background task. Once complete, this\n        /// delegate will be called.\n        //----------------------------------------------------------------\n        CircleParticleEmitterDef(const Json::Value& in_paramsJson, const LoadedDelegate& in_loadedDelegate = nullptr);\n        //----------------------------------------------------------------\n        /// Allows querying of whether or not this implements the interface\n        /// described by the given Id.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The interface Id.\n        ///\n        /// @return Whether or not the interface is implemented.\n        //----------------------------------------------------------------\n        bool IsA(InterfaceIDType in_interfaceId) const override;\n        //----------------------------------------------------------------\n        /// Creates a new instance of a Circle Particle Emitter.\n        ///\n        /// @author Ian Copland.\n        ///\n        /// @param The particle array.\n        ///\n        /// @return the instance.\n        //----------------------------------------------------------------\n        ParticleEmitterUPtr CreateInstance(dynamic_array<Particle>* in_particleArray) const override;\n        //----------------------------------------------------------------\n        /// @author Ian Copland.\n        ///\n        /// @param Where in the circle a particle can be emitted from.\n        //----------------------------------------------------------------\n        EmitFromType GetEmitFromType() const;\n        //----------------------------------------------------------------\n        /// @author Ian Copland.\n        ///\n        /// @param The emit direction type, i.e how the direction of a \n        /// particle will be  determined.\n        //----------------------------------------------------------------\n        EmitDirectionType GetEmitDirectionType() const;\n        //----------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return A property describing the radius of the particle\n        /// emitter.\n        //----------------------------------------------------------------\n        const ParticleProperty<f32>* GetRadiusProperty() const;\n    private:\n        EmitFromType m_emitFromType = EmitFromType::k_inside;\n        EmitDirectionType m_emitDirectionType = EmitDirectionType::k_awayFromCentre;\n        ParticlePropertyUPtr<f32> m_radiusProperty = ParticlePropertyUPtr<f32>(new ConstantParticleProperty<f32>(1.0f));\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Particle/Emitter/Cone2DParticleEmitter.cpp",
    "content": "//\n//  Cone2DParticleEmitter.cpp\n//  ChilliSource\n//  Created by Ian Copland on 03/12/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Particle/Emitter/Cone2DParticleEmitter.h>\n\n#include <ChilliSource/Core/Math/Random.h>\n#include <ChilliSource/Rendering/Particle/ParticleEffect.h>\n#include <ChilliSource/Rendering/Particle/Emitter/Cone2DParticleEmitterDef.h>\n\n#include <cmath>\n\nnamespace ChilliSource\n{\n    namespace\n    {\n        //----------------------------------------------------------------\n        /// Generates a 2D direction within the given angle range with even\n        /// distribution.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The angle.\n        ///\n        /// @return The direction.\n        //----------------------------------------------------------------\n        Vector2 GenerateDirectionWithinAngle(f32 in_angle)\n        {\n            f32 angle = MathUtils::k_pi * 0.5f + Random::GenerateNormalised<f32>() * in_angle - 0.5f * in_angle;\n            Vector2 direction(std::cos(angle), std::sin(angle));\n            return direction;\n        }\n        //----------------------------------------------------------------\n        /// Generates a direction with the given angle with even\n        /// distribution.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The angle.\n        ///\n        /// @return The direction.\n        //----------------------------------------------------------------\n        Vector2 GenerateDirectionWithAngle(f32 in_angle)\n        {\n            f32 angle = 0.0f;\n            if (Random::Generate<u32>(0, 1) == 0)\n            {\n                angle = MathUtils::k_pi * 0.5f - 0.5f * in_angle;\n            }\n            else\n            {\n                angle = MathUtils::k_pi * 0.5f + 0.5f * in_angle;\n            }\n            Vector2 direction(std::cos(angle), std::sin(angle));\n            return direction;\n        }\n        //----------------------------------------------------------------\n        /// Generates a position in a unit 2D cone with the given angle, with\n        /// even distribution.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The angle.\n        ///\n        /// @return The position.\n        //----------------------------------------------------------------\n        Vector2 GeneratePositionInUnitCone2D(f32 in_angle)\n        {\n            f32 dist = std::sqrt(Random::GenerateNormalised<f32>());\n            return GenerateDirectionWithinAngle(in_angle) * dist;\n        }\n        //----------------------------------------------------------------\n        /// Generates a position on a the surface of a unit 2D cone with the\n        /// given angle, with even distribution.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The angle.\n        ///\n        /// @return The direction.\n        //----------------------------------------------------------------\n        Vector2 GeneratePositionOnUnitCone2D(f32 in_angle)\n        {\n            f32 dist = std::sqrt(Random::GenerateNormalised<f32>());\n            return GenerateDirectionWithAngle(in_angle) * dist;\n        }\n    }\n\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    Cone2DParticleEmitter::Cone2DParticleEmitter(const ParticleEmitterDef* in_particleEmitter, dynamic_array<Particle>* in_particleArray)\n        : ParticleEmitter(in_particleEmitter, in_particleArray)\n    {\n        //Only the sphere emitter def can create this, so this is safe.\n        m_coneParticleEmitterDef = static_cast<const Cone2DParticleEmitterDef*>(in_particleEmitter);\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    void Cone2DParticleEmitter::GenerateEmission(f32 in_normalisedEmissionTime, Vector3& out_position, Vector3& out_direction)\n    {\n        f32 radius = m_coneParticleEmitterDef->GetRadiusProperty()->GenerateValue(in_normalisedEmissionTime);\n        f32 angle = m_coneParticleEmitterDef->GetAngleProperty()->GenerateValue(in_normalisedEmissionTime);\n\n        //calculate the position.\n        switch (m_coneParticleEmitterDef->GetEmitFromType())\n        {\n        case Cone2DParticleEmitterDef::EmitFromType::k_inside:\n            out_position = Vector3(GeneratePositionInUnitCone2D(angle) * radius, 0.0f);\n            break;\n        case Cone2DParticleEmitterDef::EmitFromType::k_edge:\n            out_position = Vector3(GeneratePositionOnUnitCone2D(angle) * radius, 0.0f);\n            break;\n        case Cone2DParticleEmitterDef::EmitFromType::k_base:\n            out_position = Vector3::k_zero;\n            break;\n        default:\n            CS_LOG_FATAL(\"Invalid 'Emit From' type.\");\n            break;\n        }\n\n        //calculate the direction.\n        switch (m_coneParticleEmitterDef->GetEmitDirectionType())\n        {\n        case Cone2DParticleEmitterDef::EmitDirectionType::k_random:\n            out_direction = Vector3(GenerateDirectionWithinAngle(angle), 0.0f);\n            break;\n        case Cone2DParticleEmitterDef::EmitDirectionType::k_awayFromBase:\n            if (out_position != Vector3::k_zero)\n            {\n                out_direction = Vector3(Vector2::Normalise(out_position.XY()), 0.0f);\n            }\n            else\n            {\n                out_direction = Vector3(GenerateDirectionWithinAngle(angle), 0.0f);\n            }\n            break;\n        default:\n            CS_LOG_FATAL(\"Invalid 'Emit Direction' type.\");\n            break;\n        }\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Particle/Emitter/Cone2DParticleEmitter.h",
    "content": "//\n//  Cone2DParticleEmitter.h\n//  ChilliSource\n//  Created by Ian Copland on 03/12/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_PARTICLES_EMITTER_CONE2DPARTICLEEMITTER_H_\n#define _CHILLISOURCE_RENDERING_PARTICLES_EMITTER_CONE2DPARTICLEEMITTER_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Rendering/Particle/Emitter/ParticleEmitter.h>\n\nnamespace ChilliSource\n{\n    //-----------------------------------------------------------------------\n    /// A cone particle emitter. This spawns particles either within a\n    /// 2D cone, on the 2D cones edge or at its base, with a random direction \n    /// or moving away from the base of the 2D cone. \n    ///\n    /// Particle emitters will be updated as a background task and should not\n    /// be accessed from other threads.\n    ///\n    /// @author Ian Copland\n    //-----------------------------------------------------------------------\n    class Cone2DParticleEmitter final : public ParticleEmitter\n    {\n    public:\n        //----------------------------------------------------------------\n        /// Generates the position and direction of a new emission. These \n        /// values are in local space. This will be called as part of a \n        /// background task.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The normalised emission playback time.\n        /// @param [Out] The generated position in local space.\n        /// @param [Out] The generate direction in local space.\n        //----------------------------------------------------------------\n        void GenerateEmission(f32 in_normalisedEmissionTime, Vector3& out_position, Vector3& out_direction) override;\n    private:\n        friend class Cone2DParticleEmitterDef;\n        //----------------------------------------------------------------\n        /// Constructor.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The particle emitter definition.\n        /// @param The particle array.\n        //----------------------------------------------------------------\n        Cone2DParticleEmitter(const ParticleEmitterDef* in_particleEmitter, dynamic_array<Particle>* in_particleArray);\n\n        const Cone2DParticleEmitterDef* m_coneParticleEmitterDef = nullptr;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Particle/Emitter/Cone2DParticleEmitterDef.cpp",
    "content": "//\n//  Cone2DParticleEmitterDef.cpp\n//  ChilliSource\n//  Created by Ian Copland on 03/12/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Particle/Emitter/Cone2DParticleEmitterDef.h>\n\n#include <ChilliSource/Rendering/Particle/Emitter/Cone2DParticleEmitter.h>\n#include <ChilliSource/Rendering/Particle/Property/ParticlePropertyFactory.h>\n\nnamespace ChilliSource\n{\n    namespace\n    {\n        //-----------------------------------------------------------------\n        /// Parse an emit from type from the given string. This is case \n        /// insensitive. If the string is not a valid emit from type this \n        /// will error.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The string to parse.\n        ///\n        /// @return the parsed emit from type.\n        //-----------------------------------------------------------------\n        Cone2DParticleEmitterDef::EmitFromType ParseEmitFromType(const std::string& in_emitFromTypeString)\n        {\n            std::string emitFromTypeString = in_emitFromTypeString;\n            StringUtils::ToLowerCase(emitFromTypeString);\n\n            if (emitFromTypeString == \"base\")\n            {\n                return Cone2DParticleEmitterDef::EmitFromType::k_base;\n            }\n            else if (emitFromTypeString == \"edge\")\n            {\n                return Cone2DParticleEmitterDef::EmitFromType::k_edge;\n            }\n            else if (emitFromTypeString == \"inside\")\n            {\n                return Cone2DParticleEmitterDef::EmitFromType::k_inside;\n            }\n\n            CS_LOG_FATAL(\"Invalid emit from type: \" + in_emitFromTypeString);\n            return Cone2DParticleEmitterDef::EmitFromType::k_base;\n        }\n        //-----------------------------------------------------------------\n        /// Parse an emit direction type from the given string. This is case \n        /// insensitive. If the string is not a valid direction from type this \n        /// will error.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The string to parse.\n        ///\n        /// @return the parsed emit direction type.\n        //-----------------------------------------------------------------\n        Cone2DParticleEmitterDef::EmitDirectionType ParseEmitDirectionType(const std::string& in_emitDirectionTypeString)\n        {\n            std::string emitDirectionTypeString = in_emitDirectionTypeString;\n            StringUtils::ToLowerCase(emitDirectionTypeString);\n\n            if (emitDirectionTypeString == \"awayfrombase\")\n            {\n                return Cone2DParticleEmitterDef::EmitDirectionType::k_awayFromBase;\n            }\n            else if (emitDirectionTypeString == \"random\")\n            {\n                return Cone2DParticleEmitterDef::EmitDirectionType::k_random;\n            }\n\n            CS_LOG_FATAL(\"Invalid emit direction type: \" + in_emitDirectionTypeString);\n            return Cone2DParticleEmitterDef::EmitDirectionType::k_awayFromBase;\n        }\n    }\n\n    CS_DEFINE_NAMEDTYPE(Cone2DParticleEmitterDef);\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    Cone2DParticleEmitterDef::Cone2DParticleEmitterDef(EmissionMode in_emissionMode, ParticlePropertyUPtr<f32> in_emissionRateProperty, ParticlePropertyUPtr<u32> in_particlesPerEmissionProperty,\n        ParticlePropertyUPtr<f32> in_emissionChanceProperty, EmitFromType in_emitFromType, EmitDirectionType in_emitDirectionType, ParticlePropertyUPtr<f32> in_radiusProperty, \n        ParticlePropertyUPtr<f32> in_angleProperty)\n        : ParticleEmitterDef(in_emissionMode, std::move(in_emissionRateProperty), std::move(in_particlesPerEmissionProperty), std::move(in_emissionChanceProperty)), m_emitFromType(in_emitFromType),\n        m_emitDirectionType(in_emitDirectionType), m_radiusProperty(std::move(in_radiusProperty)), m_angleProperty(std::move(in_angleProperty))\n    {\n        CS_ASSERT(m_radiusProperty != nullptr, \"Cannot create a Sphere Particle Emitter Def with a null 'radius' property.\");\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    Cone2DParticleEmitterDef::Cone2DParticleEmitterDef(const Json::Value& in_paramsJson, const LoadedDelegate& in_loadedDelegate)\n        : ParticleEmitterDef(in_paramsJson)\n    {\n        //Emit from type\n        Json::Value jsonValue = in_paramsJson.get(\"EmitFromType\", Json::nullValue);\n        if (jsonValue.isNull() == false)\n        {\n            CS_ASSERT(jsonValue.isString(), \"Emit from type must be a string.\");\n            m_emitFromType = ParseEmitFromType(jsonValue.asString());\n        }\n\n        //Emit direction type\n        jsonValue = in_paramsJson.get(\"EmitDirectionType\", Json::nullValue);\n        if (jsonValue.isNull() == false)\n        {\n            CS_ASSERT(jsonValue.isString(), \"Emit direction type must be a string.\");\n            m_emitDirectionType = ParseEmitDirectionType(jsonValue.asString());\n        }\n\n        //Radius\n        jsonValue = in_paramsJson.get(\"RadiusProperty\", Json::nullValue);\n        if (jsonValue.isNull() == false)\n        {\n            m_radiusProperty = ParticlePropertyFactory::CreateProperty<f32>(jsonValue);\n        }\n\n        //Angle\n        jsonValue = in_paramsJson.get(\"AngleProperty\", Json::nullValue);\n        if (jsonValue.isNull() == false)\n        {\n            m_angleProperty = ParticlePropertyFactory::CreateProperty<f32>(jsonValue);\n        }\n\n        //call the loaded delegate if required.\n        if (in_loadedDelegate != nullptr)\n        {\n            in_loadedDelegate(this);\n        }\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    bool Cone2DParticleEmitterDef::IsA(InterfaceIDType in_interfaceId) const\n    {\n        return (ParticleEmitterDef::InterfaceID == in_interfaceId || Cone2DParticleEmitterDef::InterfaceID == in_interfaceId);\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    ParticleEmitterUPtr Cone2DParticleEmitterDef::CreateInstance(dynamic_array<Particle>* in_particleArray) const\n    {\n        return ParticleEmitterUPtr(new Cone2DParticleEmitter(this, in_particleArray));\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    Cone2DParticleEmitterDef::EmitFromType Cone2DParticleEmitterDef::GetEmitFromType() const\n    {\n        return m_emitFromType;\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    Cone2DParticleEmitterDef::EmitDirectionType Cone2DParticleEmitterDef::GetEmitDirectionType() const\n    {\n        return m_emitDirectionType;\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    const ParticleProperty<f32>* Cone2DParticleEmitterDef::GetRadiusProperty() const\n    {\n        return m_radiusProperty.get();\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    const ParticleProperty<f32>* Cone2DParticleEmitterDef::GetAngleProperty() const\n    {\n        return m_angleProperty.get();\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Particle/Emitter/Cone2DParticleEmitterDef.h",
    "content": "//\n//  Cone2DParticleEmitterDef.h\n//  ChilliSource\n//  Created by Ian Copland on 03/12/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_PARTICLE_EMITTER_CONE2DPARTICLEEMITTERDEF_H_\n#define _CHILLISOURCE_RENDERING_PARTICLE_EMITTER_CONE2DPARTICLEEMITTERDEF_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Math/MathUtils.h>\n#include <ChilliSource/Rendering/Particle/Emitter/ParticleEmitterDef.h>\n\nnamespace ChilliSource\n{\n    //-----------------------------------------------------------------------\n    /// A particle emitter def describing the properties for a 2D Cone Particle\n    /// Emitter and provides a means to create instances.\n    ///\n    /// As a particle emitter def's contents can potentially be read from \n    /// multiple threads, it is immutable after construction. The exception \n    /// to this is if it was created from a param dictionary with a \n    /// asynchronous delegate, in which case it is immutable after the\n    /// delegate is called.\n    ///\n    /// The following are properties that a 2D cone particle emitter \n    /// contains in addition to the standard emitter properties:\n    ///\t\t\t\n    /// \"EmitFromType\": Where on the particle emitter particles can be\n    /// emitted from. The possible values are \"Inside\", \"Edge\" or\n    /// \"Base\". The default value is \"Base\".\n    /// \n    /// \"EmitDirectionType\": Describes how the direction of an emitted\n    /// particle will be generated. The possible values are \"AwayFromBase\"\n    /// and \"Random\". This defaults to \"AwayFromBase\".\n    ///\n    /// \"RadiusProperty\": A property describing the radius of the emitter.\n    ///\n    /// \"AngleProperty\": A property describing the angle of the emitter.\n    ///\n    /// @author Ian Copland\n    //-----------------------------------------------------------------------\n    class Cone2DParticleEmitterDef final : public ParticleEmitterDef\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(Cone2DParticleEmitterDef);\n        //----------------------------------------------------------------\n        /// An enum describing where in the emitter a particle can be\n        /// generated. If inside is used, the particle can be \n        /// emitted from anywhere inside the 2D cone. If edge is used the \n        /// particle can spawn anywhere on the outer edges of the 2D cone.\n        /// If base is used, particles will always spawn at the base of\n        /// the emitter. \n        /// \n        /// @author Ian Copland\n        //----------------------------------------------------------------\n        enum class EmitFromType\n        {\n            k_inside,\n            k_edge,\n            k_base,\n        };\n        //----------------------------------------------------------------\n        /// An enum describing the possible ways the emission direction\n        /// of a particle can be generated. If Away From Base is used the \n        /// particle will always move in a direction away from the base\n        /// of the emitter. If random is used, the direction will be\n        /// random, but still within the range given by the angle of the\n        /// 2D cone.\n        /// \n        /// @author Ian Copland\n        //----------------------------------------------------------------\n        enum class EmitDirectionType\n        {\n            k_awayFromBase,\n            k_random\n        };\n        //----------------------------------------------------------------\n        /// Constructor\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The emission mode.\n        /// @param The emission rate property. This is ignored for when in \n        /// burst emission mode.\n        /// @param The property describing the number of particles in each\n        /// emission.\n        /// @param The property describing the chance that a particle will \n        /// actually emit each time an emission is attempted. This is used \n        /// to make an effect look more random.\n        /// @param Where in the 2D cone a particle can be emitted from.\n        /// @param Describes how the direction of a particle will be\n        /// determined.\n        /// @param The property describing the radius of the emitter.\n        /// @param The property describing the angle of the 2D cone.\n        //----------------------------------------------------------------\n        Cone2DParticleEmitterDef(EmissionMode in_emissionMode, ParticlePropertyUPtr<f32> in_emissionRateProperty, ParticlePropertyUPtr<u32> in_particlesPerEmissionProperty,\n            ParticlePropertyUPtr<f32> in_emissionChanceProperty, EmitFromType in_emitFromType, EmitDirectionType in_emitDirectionType, ParticlePropertyUPtr<f32> in_radiusProperty,\n            ParticlePropertyUPtr<f32> in_angle);\n        //----------------------------------------------------------------\n        /// Constructor. Initialises with parameters read from the given \n        /// param dictionary.  If the async delegate is not null, then any \n        /// resource loading will occur as a background task. Once complete \n        /// the delegate will be called. The parameters read from json are\n        /// described in the class documentation.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param A json object describing the parameters for the particle\n        /// emitter def.\n        /// @param The loaded delegate. If this is supplied any resources\n        /// will be loaded as a background task. Once complete, this\n        /// delegate will be called.\n        //----------------------------------------------------------------\n        Cone2DParticleEmitterDef(const Json::Value& in_paramsJson, const LoadedDelegate& in_loadedDelegate = nullptr);\n        //----------------------------------------------------------------\n        /// Allows querying of whether or not this implements the interface\n        /// described by the given Id.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The interface Id.\n        ///\n        /// @return Whether or not the interface is implemented.\n        //----------------------------------------------------------------\n        bool IsA(InterfaceIDType in_interfaceId) const override;\n        //----------------------------------------------------------------\n        /// Creates a new instance of a 2D Cone Particle Emitter.\n        ///\n        /// @author Ian Copland.\n        ///\n        /// @param The particle array.\n        ///\n        /// @return the instance.\n        //----------------------------------------------------------------\n        ParticleEmitterUPtr CreateInstance(dynamic_array<Particle>* in_particleArray) const override;\n        //----------------------------------------------------------------\n        /// @author Ian Copland.\n        ///\n        /// @param Where in the 2D cone a particle can be emitted from.\n        //----------------------------------------------------------------\n        EmitFromType GetEmitFromType() const;\n        //----------------------------------------------------------------\n        /// @author Ian Copland.\n        ///\n        /// @param The emit direction type, i.e how the direction of a \n        /// particle will be determined.\n        //----------------------------------------------------------------\n        EmitDirectionType GetEmitDirectionType() const;\n        //----------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return A property describing the radius of the particle\n        /// emitter.\n        //----------------------------------------------------------------\n        const ParticleProperty<f32>* GetRadiusProperty() const;\n        //----------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return A property describing the radius of the particle\n        /// emitter.\n        //----------------------------------------------------------------\n        const ParticleProperty<f32>* GetAngleProperty() const;\n    private:\n        EmitFromType m_emitFromType = EmitFromType::k_base;\n        EmitDirectionType m_emitDirectionType = EmitDirectionType::k_awayFromBase;\n        ParticlePropertyUPtr<f32> m_radiusProperty = ParticlePropertyUPtr<f32>(new ConstantParticleProperty<f32>(1.0f));\n        ParticlePropertyUPtr<f32> m_angleProperty = ParticlePropertyUPtr<f32>(new ConstantParticleProperty<f32>(MathUtils::k_pi / 4.0f));\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Particle/Emitter/ConeParticleEmitter.cpp",
    "content": "//\n//  ConeParticleEmitter.cpp\n//  ChilliSource\n//  Created by Ian Copland on 02/11/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Particle/Emitter/ConeParticleEmitter.h>\n\n#include <ChilliSource/Core/Math/Random.h>\n#include <ChilliSource/Rendering/Particle/ParticleEffect.h>\n#include <ChilliSource/Rendering/Particle/Emitter/ConeParticleEmitterDef.h>\n\n#include <cmath>\n\nnamespace ChilliSource\n{\n    namespace\n    {\n        //----------------------------------------------------------------\n        /// Generates a direction within the given angle range with even\n        /// distribution.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The angle.\n        ///\n        /// @return The direction.\n        //----------------------------------------------------------------\n        Vector3 GenerateDirectionWithinAngle(f32 in_angle)\n        {\n            //get the y value that would ensure the top of the cone is a circle of unit radius.\n            f32 y = 1.0f / tan(in_angle * 0.5f);\n\n            //get a random point within the circle at the top of the cone. the square root of the\n            //random distance is used to acheive even distribution.\n            Vector2 topDirection = Random::GenerateDirection2D<f32>();\n            f32 dist = std::sqrt(Random::GenerateNormalised<f32>());\n\n            //normalise this to get a direction vector.\n            Vector3 output(topDirection.x * dist, y, topDirection.y * dist);\n            output.Normalise();\n            return output;\n        }\n        //----------------------------------------------------------------\n        /// Generates a direction with the given angle with even\n        /// distribution.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The angle.\n        ///\n        /// @return The direction.\n        //----------------------------------------------------------------\n        Vector3 GenerateDirectionWithAngle(f32 in_angle)\n        {\n            //get the y value that would ensure the top of the cone is a circle of unit radius.\n            f32 y = 1.0f / tan(in_angle * 0.5f);\n\n            //get a random point on the surface the circle at the top of the cone.\n            Vector2 topDirection = Random::GenerateDirection2D<f32>();\n\n            //normalise this to get a direction vector.\n            Vector3 output(topDirection.x, y, topDirection.y);\n            output.Normalise();\n            return output;\n        }\n        //----------------------------------------------------------------\n        /// Generates a position in a unit cone with the given angle, with\n        /// even distribution.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The angle.\n        ///\n        /// @return The position.\n        //----------------------------------------------------------------\n        Vector3 GeneratePositionInUnitCone(f32 in_angle)\n        {\n            const f32 oneOverThree = 1.0f / 3.0f;\n\n            f32 dist = std::pow(Random::GenerateNormalised<f32>(), oneOverThree);\n            return GenerateDirectionWithinAngle(in_angle) * dist;\n        }\n        //----------------------------------------------------------------\n        /// Generates a position on a the surface of a unit cone with the\n        /// given angle, with even distribution.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The angle.\n        ///\n        /// @return The direction.\n        //----------------------------------------------------------------\n        Vector3 GeneratePositionOnUnitCone(f32 in_angle)\n        {\n            const f32 oneOverThree = 1.0f / 3.0f;\n\n            f32 dist = std::pow(Random::GenerateNormalised<f32>(), oneOverThree);\n            return GenerateDirectionWithAngle(in_angle) * dist;\n        }\n    }\n\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    ConeParticleEmitter::ConeParticleEmitter(const ParticleEmitterDef* in_particleEmitter, dynamic_array<Particle>* in_particleArray)\n        : ParticleEmitter(in_particleEmitter, in_particleArray)\n    {\n        //Only the sphere emitter def can create this, so this is safe.\n        m_coneParticleEmitterDef = static_cast<const ConeParticleEmitterDef*>(in_particleEmitter);\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    void ConeParticleEmitter::GenerateEmission(f32 in_normalisedEmissionTime, Vector3& out_position, Vector3& out_direction)\n    {\n        f32 radius = m_coneParticleEmitterDef->GetRadiusProperty()->GenerateValue(in_normalisedEmissionTime);\n        f32 angle = m_coneParticleEmitterDef->GetAngleProperty()->GenerateValue(in_normalisedEmissionTime);\n\n        //calculate the position.\n        switch (m_coneParticleEmitterDef->GetEmitFromType())\n        {\n        case ConeParticleEmitterDef::EmitFromType::k_inside:\n            out_position = GeneratePositionInUnitCone(angle) * radius;\n            break;\n        case ConeParticleEmitterDef::EmitFromType::k_surface:\n            out_position = GeneratePositionOnUnitCone(angle) * radius;\n            break;\n        case ConeParticleEmitterDef::EmitFromType::k_base:\n            out_position = Vector3::k_zero;\n            break;\n        default:\n            CS_LOG_FATAL(\"Invalid 'Emit From' type.\");\n            break;\n        }\n\n        //calculate the direction.\n        switch (m_coneParticleEmitterDef->GetEmitDirectionType())\n        {\n        case ConeParticleEmitterDef::EmitDirectionType::k_random:\n            out_direction = GenerateDirectionWithinAngle(angle);\n            break;\n        case ConeParticleEmitterDef::EmitDirectionType::k_awayFromBase:\n            if (out_position != Vector3::k_zero)\n            {\n                out_direction = Vector3::Normalise(out_position);\n            }\n            else\n            {\n                out_direction = GenerateDirectionWithinAngle(angle);\n            }\n            break;\n        default:\n            CS_LOG_FATAL(\"Invalid 'Emit Direction' type.\");\n            break;\n        }\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Particle/Emitter/ConeParticleEmitter.h",
    "content": "//\n//  ConeParticleEmitter.h\n//  ChilliSource\n//  Created by Ian Copland on 02/11/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_PARTICLES_EMITTER_CONEPARTICLEEMITTER_H_\n#define _CHILLISOURCE_RENDERING_PARTICLES_EMITTER_CONEPARTICLEEMITTER_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Rendering/Particle/Emitter/ParticleEmitter.h>\n\nnamespace ChilliSource\n{\n    //-----------------------------------------------------------------------\n    /// A cone particle emitter. This spawns particles either within a \n    /// cone, on the cones surface or at its base, with a random direction or \n    /// moving away from the base of the cone. \n    ///\n    /// Particle emitters will be updated as a background task and should not\n    /// be accessed from other threads.\n    ///\n    /// @author Ian Copland\n    //-----------------------------------------------------------------------\n    class ConeParticleEmitter final : public ParticleEmitter\n    {\n    public:\n        //----------------------------------------------------------------\n        /// Generates the position and direction of a new emission. These \n        /// values are in local space. This will be called as part of a \n        /// background task.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The normalised emission playback time.\n        /// @param [Out] The generated position in local space.\n        /// @param [Out] The generate direction in local space.\n        //----------------------------------------------------------------\n        void GenerateEmission(f32 in_normalisedEmissionTime, Vector3& out_position, Vector3& out_direction) override;\n    private:\n        friend class ConeParticleEmitterDef;\n        //----------------------------------------------------------------\n        /// Constructor.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The particle emitter definition.\n        /// @param The particle array.\n        //----------------------------------------------------------------\n        ConeParticleEmitter(const ParticleEmitterDef* in_particleEmitter, dynamic_array<Particle>* in_particleArray);\n\n        const ConeParticleEmitterDef* m_coneParticleEmitterDef = nullptr;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Particle/Emitter/ConeParticleEmitterDef.cpp",
    "content": "//\n//  ConeParticleEmitterDef.cpp\n//  ChilliSource\n//  Created by Ian Copland on 02/11/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Particle/Emitter/ConeParticleEmitterDef.h>\n\n#include <ChilliSource/Rendering/Particle/Emitter/ConeParticleEmitter.h>\n#include <ChilliSource/Rendering/Particle/Property/ParticlePropertyFactory.h>\n\nnamespace ChilliSource\n{\n    namespace\n    {\n        //-----------------------------------------------------------------\n        /// Parse an emit from type from the given string. This is case \n        /// insensitive. If the string is not a valid emit from type this \n        /// will error.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The string to parse.\n        ///\n        /// @return the parsed emit from type.\n        //-----------------------------------------------------------------\n        ConeParticleEmitterDef::EmitFromType ParseEmitFromType(const std::string& in_emitFromTypeString)\n        {\n            std::string emitFromTypeString = in_emitFromTypeString;\n            StringUtils::ToLowerCase(emitFromTypeString);\n\n            if (emitFromTypeString == \"base\")\n            {\n                return ConeParticleEmitterDef::EmitFromType::k_base;\n            }\n            else if (emitFromTypeString == \"surface\")\n            {\n                return ConeParticleEmitterDef::EmitFromType::k_surface;\n            }\n            else if (emitFromTypeString == \"inside\")\n            {\n                return ConeParticleEmitterDef::EmitFromType::k_inside;\n            }\n\n            CS_LOG_FATAL(\"Invalid emit from type: \" + in_emitFromTypeString);\n            return ConeParticleEmitterDef::EmitFromType::k_base;\n        }\n        //-----------------------------------------------------------------\n        /// Parse an emit direction type from the given string. This is case \n        /// insensitive. If the string is not a valid direction from type this \n        /// will error.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The string to parse.\n        ///\n        /// @return the parsed emit direction type.\n        //-----------------------------------------------------------------\n        ConeParticleEmitterDef::EmitDirectionType ParseEmitDirectionType(const std::string& in_emitDirectionTypeString)\n        {\n            std::string emitDirectionTypeString = in_emitDirectionTypeString;\n            StringUtils::ToLowerCase(emitDirectionTypeString);\n\n            if (emitDirectionTypeString == \"awayfrombase\")\n            {\n                return ConeParticleEmitterDef::EmitDirectionType::k_awayFromBase;\n            }\n            else if (emitDirectionTypeString == \"random\")\n            {\n                return ConeParticleEmitterDef::EmitDirectionType::k_random;\n            }\n\n            CS_LOG_FATAL(\"Invalid emit direction type: \" + in_emitDirectionTypeString);\n            return ConeParticleEmitterDef::EmitDirectionType::k_awayFromBase;\n        }\n    }\n\n    CS_DEFINE_NAMEDTYPE(ConeParticleEmitterDef);\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    ConeParticleEmitterDef::ConeParticleEmitterDef(EmissionMode in_emissionMode, ParticlePropertyUPtr<f32> in_emissionRateProperty, ParticlePropertyUPtr<u32> in_particlesPerEmissionProperty,\n        ParticlePropertyUPtr<f32> in_emissionChanceProperty, EmitFromType in_emitFromType, EmitDirectionType in_emitDirectionType, ParticlePropertyUPtr<f32> in_radiusProperty, \n        ParticlePropertyUPtr<f32> in_angleProperty)\n        : ParticleEmitterDef(in_emissionMode, std::move(in_emissionRateProperty), std::move(in_particlesPerEmissionProperty), std::move(in_emissionChanceProperty)), m_emitFromType(in_emitFromType),\n        m_emitDirectionType(in_emitDirectionType), m_radiusProperty(std::move(in_radiusProperty)), m_angleProperty(std::move(in_angleProperty))\n    {\n        CS_ASSERT(m_radiusProperty != nullptr, \"Cannot create a Sphere Particle Emitter Def with a null 'radius' property.\");\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    ConeParticleEmitterDef::ConeParticleEmitterDef(const Json::Value& in_paramsJson, const LoadedDelegate& in_loadedDelegate)\n        : ParticleEmitterDef(in_paramsJson)\n    {\n        //Emit from type\n        Json::Value jsonValue = in_paramsJson.get(\"EmitFromType\", Json::nullValue);\n        if (jsonValue.isNull() == false)\n        {\n            CS_ASSERT(jsonValue.isString(), \"Emit from type must be a string.\");\n            m_emitFromType = ParseEmitFromType(jsonValue.asString());\n        }\n\n        //Emit direction type\n        jsonValue = in_paramsJson.get(\"EmitDirectionType\", Json::nullValue);\n        if (jsonValue.isNull() == false)\n        {\n            CS_ASSERT(jsonValue.isString(), \"Emit direction type must be a string.\");\n            m_emitDirectionType = ParseEmitDirectionType(jsonValue.asString());\n        }\n\n        //Radius\n        jsonValue = in_paramsJson.get(\"RadiusProperty\", Json::nullValue);\n        if (jsonValue.isNull() == false)\n        {\n            m_radiusProperty = ParticlePropertyFactory::CreateProperty<f32>(jsonValue);\n        }\n\n        //Angle\n        jsonValue = in_paramsJson.get(\"AngleProperty\", Json::nullValue);\n        if (jsonValue.isNull() == false)\n        {\n            m_angleProperty = ParticlePropertyFactory::CreateProperty<f32>(jsonValue);\n        }\n\n        //call the loaded delegate if required.\n        if (in_loadedDelegate != nullptr)\n        {\n            in_loadedDelegate(this);\n        }\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    bool ConeParticleEmitterDef::IsA(InterfaceIDType in_interfaceId) const\n    {\n        return (ParticleEmitterDef::InterfaceID == in_interfaceId || ConeParticleEmitterDef::InterfaceID == in_interfaceId);\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    ParticleEmitterUPtr ConeParticleEmitterDef::CreateInstance(dynamic_array<Particle>* in_particleArray) const\n    {\n        return ParticleEmitterUPtr(new ConeParticleEmitter(this, in_particleArray));\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    ConeParticleEmitterDef::EmitFromType ConeParticleEmitterDef::GetEmitFromType() const\n    {\n        return m_emitFromType;\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    ConeParticleEmitterDef::EmitDirectionType ConeParticleEmitterDef::GetEmitDirectionType() const\n    {\n        return m_emitDirectionType;\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    const ParticleProperty<f32>* ConeParticleEmitterDef::GetRadiusProperty() const\n    {\n        return m_radiusProperty.get();\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    const ParticleProperty<f32>* ConeParticleEmitterDef::GetAngleProperty() const\n    {\n        return m_angleProperty.get();\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Particle/Emitter/ConeParticleEmitterDef.h",
    "content": "//\n//  ConeParticleEmitterDef.h\n//  ChilliSource\n//  Created by Ian Copland on 02/11/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_PARTICLE_EMITTER_CONEPARTICLEEMITTERDEF_H_\n#define _CHILLISOURCE_RENDERING_PARTICLE_EMITTER_CONEPARTICLEEMITTERDEF_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Math/MathUtils.h>\n#include <ChilliSource/Rendering/Particle/Emitter/ParticleEmitterDef.h>\n\nnamespace ChilliSource\n{\n    //-----------------------------------------------------------------------\n    /// A particle emitter def describing the properties for a Cone Particle\n    /// Emitter and provides a means to create instances.\n    ///\n    /// As a particle emitter def's contents can potentially be read from \n    /// multiple threads, it is immutable after construction. The exception \n    /// to this is if it was created from a param dictionary with a \n    /// asynchronous delegate, in which case it is immutable after the\n    /// delegate is called.\n    ///\n    /// The following are properties that a cone particle emitter \n    /// contains in addition to the standard emitter properties:\n    ///\t\t\t\n    /// \"EmitFromType\": Where on the particle emitter particles can be\n    /// emitted from. The possible values are \"Inside\",  \"Surface\" or\n    /// \"Base\". The default value is \"Base\".\n    /// \n    /// \"EmitDirectionType\": Describes how the direction of an emitted\n    /// particle will be generated. The possible values are \"AwayFromBase\"\n    /// and \"Random\". This defaults to \"AwayFromBase\".\n    ///\n    /// \"RadiusProperty\": A property describing the radius of the emitter.\n    ///\n    /// \"AngleProperty\": A property describing the angle of the emitter.\n    ///\n    /// @author Ian Copland\n    //-----------------------------------------------------------------------\n    class ConeParticleEmitterDef final : public ParticleEmitterDef\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(ConeParticleEmitterDef);\n        //----------------------------------------------------------------\n        /// An enum describing where in the emitter a particle can be\n        /// generated. If inside is used, the particle can be \n        /// emitted from anywhere inside the cone. If surface is used the \n        /// particle can spawn anywhere on the outer shell of the cone.\n        /// If base is used, particles will always spawn at the base of\n        /// the emitter. \n        /// \n        /// @author Ian Copland\n        //----------------------------------------------------------------\n        enum class EmitFromType\n        {\n            k_inside,\n            k_surface,\n            k_base,\n        };\n        //----------------------------------------------------------------\n        /// An enum describing the possible ways the emission direction\n        /// of a particle can be generated. If Away From Base is used the \n        /// particle will always move in a direction away from the base\n        /// of the emitter. If random is used, the direction will be\n        /// random, but still within the range given by the angle of the\n        /// cone.\n        /// \n        /// @author Ian Copland\n        //----------------------------------------------------------------\n        enum class EmitDirectionType\n        {\n            k_awayFromBase,\n            k_random\n        };\n        //----------------------------------------------------------------\n        /// Constructor\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The emission mode.\n        /// @param The emission rate property. This is ignored for when in \n        /// burst emission mode.\n        /// @param The property describing the number of particles in each\n        /// emission.\n        /// @param The property describing the chance that a particle will \n        /// actually emit each time an emission is attempted. This is used \n        /// to make an effect look more random.\n        /// @param Where in the cone a particle can be emitted from.\n        /// @param Describes how the direction of a particle will be\n        /// determined.\n        /// @param The property describing the radius of the emitter.\n        /// @param The property describing the angle of the cone.\n        //----------------------------------------------------------------\n        ConeParticleEmitterDef(EmissionMode in_emissionMode, ParticlePropertyUPtr<f32> in_emissionRateProperty, ParticlePropertyUPtr<u32> in_particlesPerEmissionProperty,\n            ParticlePropertyUPtr<f32> in_emissionChanceProperty, EmitFromType in_emitFromType, EmitDirectionType in_emitDirectionType, ParticlePropertyUPtr<f32> in_radiusProperty,\n            ParticlePropertyUPtr<f32> in_angle);\n        //----------------------------------------------------------------\n        /// Constructor. Initialises with parameters read from the given \n        /// param dictionary. If the async delegate is not null, then any\n        /// resource loading will occur as a background task. Once complete \n        /// the delegate will be called. The parameters read from json are\n        /// described in the class documentation.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param A json object describing the parameters for the particle\n        /// emitter def.\n        /// @param The loaded delegate. If this is supplied any resources\n        /// will be loaded as a background task. Once complete, this\n        /// delegate will be called.\n        //----------------------------------------------------------------\n        ConeParticleEmitterDef(const Json::Value& in_paramsJson, const LoadedDelegate& in_loadedDelegate = nullptr);\n        //----------------------------------------------------------------\n        /// Allows querying of whether or not this implements the interface\n        /// described by the given Id.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The interface Id.\n        ///\n        /// @return Whether or not the interface is implemented.\n        //----------------------------------------------------------------\n        bool IsA(InterfaceIDType in_interfaceId) const override;\n        //----------------------------------------------------------------\n        /// Creates a new instance of a Cone Particle Emitter.\n        ///\n        /// @author Ian Copland.\n        ///\n        /// @param The particle array.\n        ///\n        /// @return the instance.\n        //----------------------------------------------------------------\n        ParticleEmitterUPtr CreateInstance(dynamic_array<Particle>* in_particleArray) const override;\n        //----------------------------------------------------------------\n        /// @author Ian Copland.\n        ///\n        /// @param Where in the cone a particle can be emitted from.\n        //----------------------------------------------------------------\n        EmitFromType GetEmitFromType() const;\n        //----------------------------------------------------------------\n        /// @author Ian Copland.\n        ///\n        /// @param The emit direction type, i.e how the direction of a \n        /// particle will be determined.\n        //----------------------------------------------------------------\n        EmitDirectionType GetEmitDirectionType() const;\n        //----------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return A property describing the radius of the particle\n        /// emitter.\n        //----------------------------------------------------------------\n        const ParticleProperty<f32>* GetRadiusProperty() const;\n        //----------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return A property describing the radius of the particle\n        /// emitter.\n        //----------------------------------------------------------------\n        const ParticleProperty<f32>* GetAngleProperty() const;\n    private:\n        EmitFromType m_emitFromType = EmitFromType::k_base;\n        EmitDirectionType m_emitDirectionType = EmitDirectionType::k_awayFromBase;\n        ParticlePropertyUPtr<f32> m_radiusProperty = ParticlePropertyUPtr<f32>(new ConstantParticleProperty<f32>(1.0f));\n        ParticlePropertyUPtr<f32> m_angleProperty = ParticlePropertyUPtr<f32>(new ConstantParticleProperty<f32>(MathUtils::k_pi / 4.0f));\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Particle/Emitter/ParticleEmitter.cpp",
    "content": "//\n//  ParticleEmitter.cpp\n//  ChilliSource\n//  Created by Ian Copland on 10/10/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Particle/Emitter/ParticleEmitter.h>\n\n#include <ChilliSource/Core/Container/dynamic_array.h>\n#include <ChilliSource/Core/Entity/Entity.h>\n#include <ChilliSource/Core/Entity/Transform.h>\n#include <ChilliSource/Core/Math/Random.h>\n#include <ChilliSource/Rendering/Particle/Particle.h>\n#include <ChilliSource/Rendering/Particle/ParticleEffect.h>\n#include <ChilliSource/Rendering/Particle/Emitter/ParticleEmitterDef.h>\n\n#include <algorithm>\n\nnamespace ChilliSource\n{\n    //----------------------------------------------\n    //----------------------------------------------\n    ParticleEmitter::ParticleEmitter(const ParticleEmitterDef* in_emitterDef, dynamic_array<Particle>* in_particleArray)\n        : m_emitterDef(in_emitterDef), m_particleArray(in_particleArray)\n    {\n        CS_ASSERT(m_emitterDef != nullptr, \"Cannot create particle emitter with null emitter def.\");\n        CS_ASSERT(m_particleArray != nullptr, \"Cannot create particle emitter with null particle array.\");\n    }\n    //----------------------------------------------\n    //----------------------------------------------\n    std::vector<u32> ParticleEmitter::TryEmit(f32 in_playbackTime, const Vector3& in_emitterPosition, const Vector3& in_emitterScale, const Quaternion& in_emitterOrientation, bool in_interpolateEmission)\n    {\n        CS_ASSERT(in_playbackTime >= 0.0f, \"Playback time cannot be below zero.\");\n\n        //If this is the first emission, then setup the correct entity positions.\n        if (in_interpolateEmission == false)\n        {\n            m_emissionPosition = in_emitterPosition;\n            m_emissionScale = in_emitterScale;\n            m_emissionOrientation = in_emitterOrientation;\n        }\n\n        //wrap the emission timer if required.\n        while (m_emissionTime > in_playbackTime)\n        {\n            m_emissionTime -= m_emitterDef->GetParticleEffect()->GetDuration();\n            \n            m_hasEmitted = false;\n        }\n\n        //emit based on emission mode.\n        switch (m_emitterDef->GetEmissionMode())\n        {\n        case ParticleEmitterDef::EmissionMode::k_stream:\n            return TryEmitStream(in_playbackTime, in_emitterPosition, in_emitterScale, in_emitterOrientation);\n        case ParticleEmitterDef::EmissionMode::k_burst:\n            return TryEmitBurst(in_playbackTime, in_emitterPosition, in_emitterScale, in_emitterOrientation);\n        default:\n            CS_LOG_FATAL(\"Invalid emission mode.\");\n            return std::vector<u32>();\n        }\n    }\n    //----------------------------------------------\n    //----------------------------------------------\n    const ParticleEmitterDef* ParticleEmitter::GetEmitterDef() const\n    {\n        return m_emitterDef;\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    std::vector<u32> ParticleEmitter::TryEmitStream(f32 in_playbackTime, const Vector3& in_emitterPosition, const Vector3& in_emitterScale, const Quaternion& in_emitterOrientation)\n    {\n        std::vector<u32> emittedParticles;\n\n        const ParticleEffect* particleEffect = m_emitterDef->GetParticleEffect();\n\n        //Get the time between emissions at this stage in the playback timer. Note that this doesn't take into account\n        //the interpolation between the last frame and this, but should be close enough.\n        const f32 normalisedPlaybackTime = in_playbackTime / particleEffect->GetDuration();\n        const f32 timeBetweenEmissions = 1.0f / m_emitterDef->GetEmissionRateProperty()->GenerateValue(normalisedPlaybackTime);\n\n        f32 prevEmissionTime = m_emissionTime;\n        Vector3 prevEntityPosition = m_emissionPosition;\n        Vector3 prevEntityScale = m_emissionScale;\n        Quaternion prevOrientation = m_emissionOrientation;\n\n        f32 nextEmissionTime = prevEmissionTime + timeBetweenEmissions;\n        \n        while (nextEmissionTime <= in_playbackTime)\n        {\n            m_emissionTime = nextEmissionTime;\n            f32 t = (m_emissionTime - prevEmissionTime) / (in_playbackTime - prevEmissionTime);\n            m_emissionPosition = Vector3::Lerp(prevEntityPosition, in_emitterPosition, t);\n            m_emissionScale = Vector3::Lerp(prevEntityScale, in_emitterScale, t);\n            m_emissionOrientation = Quaternion::Slerp(prevOrientation, in_emitterOrientation, t);\n\n            f32 normalisedEmissionTime = m_emissionTime / particleEffect->GetDuration();\n            while (normalisedEmissionTime < 0.0f)\n            {\n                normalisedEmissionTime += 1.0f;\n            }\n            CS_ASSERT(normalisedEmissionTime >= 0.0f && normalisedEmissionTime <= 1.0f, \"Invalid emission time.\");\n            \n            u32 particlesPerEmission = m_emitterDef->GetParticlesPerEmissionProperty()->GenerateValue(normalisedEmissionTime);\n            for (u32 i = 0; i < particlesPerEmission; ++i)\n            {\n                f32 chanceOfEmission = m_emitterDef->GetEmissionChanceProperty()->GenerateValue(normalisedEmissionTime);\n                f32 random = Random::GenerateNormalised<f32>();\n                if (random <= chanceOfEmission)\n                {\n                    Emit(normalisedEmissionTime, m_emissionPosition, m_emissionScale, m_emissionOrientation, emittedParticles);\n                }\n            }\n\n            nextEmissionTime += timeBetweenEmissions;\n        }\n\n        return emittedParticles;\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    std::vector<u32> ParticleEmitter::TryEmitBurst(f32 in_playbackTime, const Vector3& in_emitterPosition, const Vector3& in_emitterScale, const Quaternion& in_emitterOrientation)\n    {\n        std::vector<u32> emittedParticles;\n\n        m_emissionTime = in_playbackTime;\n\n        if (m_hasEmitted == false)\n        {\n            m_emissionPosition = in_emitterPosition;\n            m_emissionScale = in_emitterScale;\n            m_emissionOrientation = in_emitterOrientation;\n\n            const f32 normalisedPlaybackTime = 0.0f;\n            u32 particlesPerEmission = m_emitterDef->GetParticlesPerEmissionProperty()->GenerateValue(normalisedPlaybackTime);\n            for (u32 i = 0; i < particlesPerEmission; ++i)\n            {\n                f32 chanceOfEmission = m_emitterDef->GetEmissionChanceProperty()->GenerateValue(normalisedPlaybackTime);\n                f32 random = Random::GenerateNormalised<f32>();\n                if (random <= chanceOfEmission)\n                {\n                    Emit(normalisedPlaybackTime, m_emissionPosition, m_emissionScale, m_emissionOrientation, emittedParticles);\n                }\n            }\n\n            m_hasEmitted = true;\n        }\n\n        return emittedParticles;\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    void ParticleEmitter::Emit(f32 in_normalisedEmissionTime, const Vector3& in_emissionPosition, const Vector3& in_emissionScale, const Quaternion& in_emissionOrientation, std::vector<u32>& inout_emittedParticles)\n    {\n        const ParticleEffect* particleEffect = m_emitterDef->GetParticleEffect();\n\n        u32 particleIndex = m_nextParticleIndex++;\n        Particle& particle = m_particleArray->at(particleIndex);\n        if (m_nextParticleIndex >= particleEffect->GetMaxParticles())\n        {\n            m_nextParticleIndex = 0;\n        }\n\n        if (particle.m_isActive == false)\n        {\n            inout_emittedParticles.push_back(particleIndex);\n\n            //Get the emission position and direction.\n            Vector3 localPosition;\n            Vector3 localDirection;\n            GenerateEmission(in_normalisedEmissionTime, localPosition, localDirection);\n\n            //calculate the local space properties.\n            Vector2 localScale = particleEffect->GetInitialScaleProperty()->GenerateValue(in_normalisedEmissionTime);\n            f32 localRotation = particleEffect->GetInitialRotationProperty()->GenerateValue(in_normalisedEmissionTime);\n            f32 localSpeed = particleEffect->GetInitialSpeedProperty()->GenerateValue(in_normalisedEmissionTime);\n\n            //apply these in the correct simulation space.\n            switch (particleEffect->GetSimulationSpace())\n            {\n                case ParticleEffect::SimulationSpace::k_world:\n                {\n                    //transform the position into world space.\n                    const Matrix4 worldTransform = Matrix4::CreateTransform(in_emissionPosition, in_emissionScale, in_emissionOrientation);\n                    particle.m_position = localPosition * worldTransform;\n\n                    //we can't directly apply the emission scale to the particles as this would look strange as\n                    //the camera moved around an emitting entity with a non-uniform scale, so this works out a uniform\n                    //scale from the average of the components.\n                    f32 particleScaleFactor = (in_emissionScale.x + in_emissionScale.y + in_emissionScale.z) / 3.0f;\n                    particle.m_scale = localScale * particleScaleFactor;\n\n                    //transform the velocity into world space.\n                    particle.m_velocity = Vector3::Rotate(((localDirection * localSpeed) * in_emissionScale), in_emissionOrientation);\n                    break;\n                }\n                case ParticleEffect::SimulationSpace::k_local:\n                {\n                    particle.m_position = localPosition;\n                    particle.m_scale = localScale;\n                    particle.m_velocity = localDirection * localSpeed;\n                    break;\n                }\n                default:\n                {\n                    CS_LOG_FATAL(\"Invalid simulation space.\");\n                    break;\n                }\n            }\n\n            //apply the remaining properties.\n            particle.m_lifetime = particleEffect->GetLifetimeProperty()->GenerateValue(in_normalisedEmissionTime);\n            particle.m_energy = particle.m_lifetime;\n            particle.m_colour = particleEffect->GetInitialColourProperty()->GenerateValue(in_normalisedEmissionTime);\n            particle.m_rotation = localRotation;\n            particle.m_angularVelocity = particleEffect->GetInitialAngularVelocityProperty()->GenerateValue(in_normalisedEmissionTime);\n            particle.m_isActive = true;\n        }\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Particle/Emitter/ParticleEmitter.h",
    "content": "//\n//  ParticleEmitter.h\n//  ChilliSource\n//  Created by Ian Copland on 10/10/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_PARTICLE_EMITTER_PARTICLEEMITTER_H_\n#define _CHILLISOURCE_RENDERING_PARTICLE_EMITTER_PARTICLEEMITTER_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Math/Vector3.h>\n#include <ChilliSource/Core/Math/Quaternion.h>\n\n#include <random>\n#include <vector>\n\nnamespace ChilliSource\n{\n    //-----------------------------------------------------------------------\n    /// The base class for all particle emitters. Particle emitters are \n    /// reponsible for decided when, where and in what direction a new \n    /// particle should be spawned. \n    ///\n    /// Particle emitters will be updated as part of a background task and \n    /// should not be accessed from other threads.\n    ///\n    /// @author Ian Copland\n    //-----------------------------------------------------------------------\n    class ParticleEmitter\n    {\n    public:\n        CS_DECLARE_NOCOPY(ParticleEmitter);\n        //----------------------------------------------------------------\n        /// Constructor.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The particle emitter definition.\n        /// @param The particle array.\n        //----------------------------------------------------------------\n        ParticleEmitter(const ParticleEmitterDef* in_particleEmitter, dynamic_array<Particle>* in_particleArray);\n        //----------------------------------------------------------------\n        /// Tries to emit new particles if required. This will be called \n        /// as part of a background task.\n        ///\n        /// @author Ian Copland\n        /// \n        /// @param The current playback time of the particle effect.\n        /// @param The current world space position of the emitter.\n        /// @param The current world space scale of the emitter.\n        /// @param The current world space orientation of the emitter.\n        /// @param Whether or not to interpolate the emission position\n        /// since the last frame.\n        ///\n        /// @return The list of newly emitted particle indices.\n        //----------------------------------------------------------------\n        std::vector<u32> TryEmit(f32 in_playbackTime, const Vector3& in_emitterPosition, const Vector3& in_emitterScale, const Quaternion& in_emitterOrientation, bool in_interpolateEmission);\n        //----------------------------------------------------------------\n        /// Destructor.\n        ///\n        /// @author Ian Copland\n        //----------------------------------------------------------------\n        virtual ~ParticleEmitter() {};\n    protected:\n        //----------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return the particle emitter definition.\n        //----------------------------------------------------------------\n        const ParticleEmitterDef* GetEmitterDef() const;\n        //----------------------------------------------------------------\n        /// Generates the position and direction of a new emission. These \n        /// values are in local space. This will be called as part of a \n        /// background task.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The normalised playback time of the emission.\n        /// @param [Out] The generated position in local space.\n        /// @param [Out] The generate direction in local space.\n        //----------------------------------------------------------------\n        virtual void GenerateEmission(f32 in_normalisedEmissionTime, Vector3& out_position, Vector3& out_direction) = 0;\n    private:\n        //----------------------------------------------------------------\n        /// Tries to emit new particles in stream mode.\n        ///\n        /// @author Ian Copland\n        /// \n        /// @param The current playback time of the particle effect.\n        /// @param The current world space position of the emitter.\n        /// @param The current world space scale of the emitter.\n        /// @param The current world space orientation of the emitter.\n        //----------------------------------------------------------------\n        std::vector<u32> TryEmitStream(f32 in_playbackTime, const Vector3& in_emitterPosition, const Vector3& in_emitterScale, const Quaternion& in_emitterOrientation);\n        //----------------------------------------------------------------\n        /// Tries to emit new particles in burst mode.\n        ///\n        /// @author Ian Copland\n        /// \n        /// @param The current playback time of the particle effect.\n        /// @param The current world space position of the emitter.\n        /// @param The current world space scale of the emitter.\n        /// @param The current world space orientation of the emitter.\n        //----------------------------------------------------------------\n        std::vector<u32> TryEmitBurst(f32 in_playbackTime, const Vector3& in_emitterPosition, const Vector3& in_emitterScale, const Quaternion& in_emitterOrientation);\n        //----------------------------------------------------------------\n        /// Emits a new particle if the next particle in the list is free\n        /// to be emitted. \n        ///\n        /// @author Ian Copland\n        /// \n        /// @param The normalised playback time of emission.\n        /// @param The world space position of the emitter at the time\n        /// of emission.\n        /// @param The world space scale of the emitter at the time\n        /// of emission.\n        /// @param The world orientation of the emitter at the time of\n        /// emission.\n        /// @param [In/Out] The list of emitted particles, will add to the\n        /// list if a particle is successfully emitted.\n        ///\n        /// @param The index of the emitted particle. \n        //----------------------------------------------------------------\n        void Emit(f32 in_normalisedEmissionTime, const Vector3& in_emissionPosition, const Vector3& in_emissionScale, const Quaternion& in_emissionOrientation, std::vector<u32>& inout_emittedParticles);\n\n        const ParticleEmitterDef* m_emitterDef = nullptr;\n        dynamic_array<Particle>* m_particleArray = nullptr;\n\n        Vector3 m_emissionPosition;\n        Vector3 m_emissionScale;\n        Quaternion m_emissionOrientation;\n        f32 m_emissionTime = 0.0f;\n        bool m_hasEmitted = false;\n        u32 m_nextParticleIndex = 0;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Particle/Emitter/ParticleEmitterDef.cpp",
    "content": "//\n//  ParticleEmitterDef.cpp\n//  ChilliSource\n//  Created by Ian Copland on 06/10/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Particle/Emitter/ParticleEmitterDef.h>\n\n#include <ChilliSource/Core/Container/ParamDictionary.h>\n#include <ChilliSource/Rendering/Particle/Property/ParticlePropertyFactory.h>\n\nnamespace ChilliSource\n{\n    namespace\n    {\n        //-----------------------------------------------------------------\n        /// Parse an emission mode from the given string. This is case \n        /// insensitive. If the string is not a valid emission mode this \n        /// will error.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The string to parse.\n        ///\n        /// @return the parsed emission mode.\n        //-----------------------------------------------------------------\n        ParticleEmitterDef::EmissionMode ParseEmissionMode(const std::string& in_emissionModeString)\n        {\n            std::string emissionModeString = in_emissionModeString;\n            StringUtils::ToLowerCase(emissionModeString);\n\n            if (emissionModeString == \"stream\")\n            {\n                return ParticleEmitterDef::EmissionMode::k_stream;\n            }\n            else if (emissionModeString == \"burst\")\n            {\n                return ParticleEmitterDef::EmissionMode::k_burst;\n            }\n\n            CS_LOG_FATAL(\"Invalid emission mode: \" + in_emissionModeString);\n            return ParticleEmitterDef::EmissionMode::k_stream;\n        }\n    }\n\n    CS_DEFINE_NAMEDTYPE(ParticleEmitterDef);\n    //-----------------------------------------------\n    //-----------------------------------------------\n    ParticleEmitterDef::ParticleEmitterDef(EmissionMode in_emissionMode, ParticlePropertyUPtr<f32> in_emissionRateProperty, ParticlePropertyUPtr<u32> in_particlesPerEmissionProperty, ParticlePropertyUPtr<f32> in_emissionChanceProperty)\n        : m_emissionMode(in_emissionMode), m_emissionRateProperty(std::move(in_emissionRateProperty)), m_particlesPerEmissionProperty(std::move(in_particlesPerEmissionProperty)), m_emissionChanceProperty(std::move(in_emissionChanceProperty))\n    {\n        CS_ASSERT(m_particlesPerEmissionProperty != nullptr, \"Cannot create a Particle Emitter Def with a null 'particles per emission' property.\");\n        CS_ASSERT(m_emissionChanceProperty != nullptr, \"Cannot create a Particle Emitter Def with a null 'emission chance' property.\");\n\n#ifdef CS_ENABLE_DEBUG\n        if (m_emissionMode == EmissionMode::k_burst)\n        {\n            CS_ASSERT(m_emissionRateProperty == nullptr, \"Cannot create a Particle Emitter Def with an 'emission rate' property if in burst mode.\");\n        }\n        else\n        {\n            CS_ASSERT(m_emissionRateProperty != nullptr, \"Cannot create a Particle Emitter Def with a null 'emission rate' property if in stream mode.\");\n        }\n#endif\n    }\n    //-----------------------------------------------\n    //-----------------------------------------------\n    ParticleEmitterDef::ParticleEmitterDef(const Json::Value& in_paramsJson)\n    {\n        //Emission mode.\n        Json::Value jsonValue = in_paramsJson.get(\"EmissionMode\", Json::nullValue);\n        if (jsonValue.isNull() == false)\n        {\n            CS_ASSERT(jsonValue.isString(), \"Emission mode must be a string.\");\n            m_emissionMode = ParseEmissionMode(jsonValue.asString());\n        }\n\n        //Emission rate.\n        jsonValue = in_paramsJson.get(\"EmissionRateProperty\", Json::nullValue);\n        if (jsonValue.isNull() == false)\n        {\n            CS_ASSERT(m_emissionMode == EmissionMode::k_stream, \"Emission rate is an invalid parameter when in burst mode.\");\n            m_emissionRateProperty = ParticlePropertyFactory::CreateProperty<f32>(jsonValue);\n        }\n\n        //Particles per emission.\n        jsonValue = in_paramsJson.get(\"ParticlesPerEmissionProperty\", Json::nullValue);\n        if (jsonValue.isNull() == false)\n        {\n            m_particlesPerEmissionProperty = ParticlePropertyFactory::CreateProperty<u32>(jsonValue);\n        }\n\n        //Emission chance.\n        jsonValue = in_paramsJson.get(\"EmissionChanceProperty\", Json::nullValue);\n        if (jsonValue.isNull() == false)\n        {\n            m_emissionChanceProperty = ParticlePropertyFactory::CreateProperty<f32>(jsonValue);\n        }\n\n        if (m_emissionMode == EmissionMode::k_burst)\n        {\n            m_emissionRateProperty.reset();\n        }\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    const ParticleEffect* ParticleEmitterDef::GetParticleEffect() const\n    {\n        return m_particleEffect;\n    }\n    //-----------------------------------------------\n    //-----------------------------------------------\n    ParticleEmitterDef::EmissionMode ParticleEmitterDef::GetEmissionMode() const\n    {\n        return m_emissionMode;\n    }\n    //-----------------------------------------------\n    //-----------------------------------------------\n    const ParticleProperty<f32>* ParticleEmitterDef::GetEmissionRateProperty() const\n    {\n        return m_emissionRateProperty.get();\n    }\n    //-----------------------------------------------\n    //-----------------------------------------------\n    const ParticleProperty<u32>* ParticleEmitterDef::GetParticlesPerEmissionProperty() const\n    {\n        return m_particlesPerEmissionProperty.get();\n    }\n    //-----------------------------------------------\n    //-----------------------------------------------\n    const ParticleProperty<f32>* ParticleEmitterDef::GetEmissionChanceProperty() const\n    {\n        return m_emissionChanceProperty.get();\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    void ParticleEmitterDef::SetParticleEffect(const ParticleEffect* in_particleEffect)\n    {\n        m_particleEffect = in_particleEffect;\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Particle/Emitter/ParticleEmitterDef.h",
    "content": "//\n//  ParticleEmitterDef.h\n//  ChilliSource\n//  Created by Ian Copland on 06/10/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_PARTICLE_EMITTER_PARTICLEEMITTERDEF_H_\n#define _CHILLISOURCE_RENDERING_PARTICLE_EMITTER_PARTICLEEMITTERDEF_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Base/QueryableInterface.h>\n#include <ChilliSource/Rendering/Particle/Property/ConstantParticleProperty.h>\n#include <ChilliSource/Rendering/Particle/Property/ParticleProperty.h>\n\n#include <json/json.h>\n\n#include <functional>\n\nnamespace ChilliSource\n{\n    //-----------------------------------------------------------------------\n    /// A particle emitter def describes the properties that should be used \n    /// to create a particle emitter and creates the emitter instances.\n    ///\n    /// As a particle emitter def's contents can potentially be read from \n    /// multiple threads, it is immutable after construction. The exception \n    /// to this is if it was created from a param dictionary with a \n    /// asynchronous delegate, in which case it is immutable after the\n    /// delegate is called. Classes inheriting from this should also follow \n    /// these rules.\n    ///\n    /// The following are the parameters that all particle emitter definitions\n    /// contain. Specific particle emitter types may contain additional\n    /// parameters.\n    ///\n    /// \"EmissionMode\": Describes the emission mode. Possible values are \n    /// \"Stream\" or \"Burst\". Defaults to \"Stream\".\n    ///\n    /// \"EmissionRateProperty\": A property describing the rate of emission\n    /// when in stream emission mode. Ignored in burst emission mode.\n    /// \n    /// \"ParticlesPerEmissionProperty\": A property describing the number of \n    /// particles in each emission.\n    ///\n    /// \"EmissionChanceProperty\": A property describing the chance that a \n    /// particle will actually be emitted during each attempt.\n    ///\n    /// @author Ian Copland\n    //-----------------------------------------------------------------------\n    class ParticleEmitterDef : public QueryableInterface\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(ParticleEmitterDef);\n        CS_DECLARE_NOCOPY(ParticleEmitterDef);\n        //----------------------------------------------------------------\n        /// The emitter def loaded delegate. This is used when background \n        /// loading the particle emitter def, once it has finished loading \n        /// this delegate should be called.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The particle emitter def.\n        //----------------------------------------------------------------\n        using LoadedDelegate = std::function<void(ParticleEmitterDef* in_emitterdef)>;\n        //----------------------------------------------------------------\n        /// An enum describing the possible emission modes for an emitter.\n        ///\n        /// @author Ian Copland\n        //----------------------------------------------------------------\n        enum class EmissionMode\n        {\n            k_stream,\n            k_burst\n        };\n        //----------------------------------------------------------------\n        /// Constructor\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The emission mode.\n        /// @param The emission rate property. This is ignored for when in \n        /// burst emission mode.\n        /// @param The property describing the number of particles in each \n        /// emission.\n        /// @param The property describing the chance that a particle will \n        /// actually emit each time a  emission is attempted. This is used \n        /// to make an effect look more random.\n        //----------------------------------------------------------------\n        ParticleEmitterDef(EmissionMode in_emissionMode, ParticlePropertyUPtr<f32> in_emissionRateProperty, ParticlePropertyUPtr<u32> in_particlesPerEmissionProperty,\n            ParticlePropertyUPtr<f32> in_emissionChanceProperty);\n        //----------------------------------------------------------------\n        /// Constructor. Initialises with parameters read from the given \n        /// param dictionary. Inheriting classes should also take a delegate \n        /// as a parameter for their equivelent constructor. If the delegate \n        /// is not null, resources should be loaded asynchronously and the \n        /// delegate should be called once finished. The parameters takem\n        /// by a particle emitter def are described in the class documentation.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param A json object describing the parameters for the\n        /// particle emitter def.\n        //----------------------------------------------------------------\n        ParticleEmitterDef(const Json::Value& in_paramsJson);\n        //----------------------------------------------------------------\n        /// Creates an instance of the particle emitter described by this.\n        ///\n        /// @author Ian Copland.\n        ///\n        /// @param The particle effect.\n        /// @param The particle array.\n        ///\n        /// @return the instance.\n        //----------------------------------------------------------------\n        virtual ParticleEmitterUPtr CreateInstance(dynamic_array<Particle>* in_particleArray) const = 0;\n        //----------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The particle effect that owns this particle emitter\n        /// definition.\n        //----------------------------------------------------------------\n        const ParticleEffect* GetParticleEffect() const;\n        //----------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The emission mode.\n        //----------------------------------------------------------------\n        EmissionMode GetEmissionMode() const;\n        //----------------------------------------------------------------\n        /// @author Ian Copland\n        /// \n        /// @return The number of particles per second that this will emit. \n        /// This is always null when in burst emission mode.\n        //----------------------------------------------------------------\n        const ParticleProperty<f32>* GetEmissionRateProperty() const;\n        //----------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The number of particles in each emission. In a burst \n        /// mode particle this is the number of paricles in the burst.\n        //----------------------------------------------------------------\n        const ParticleProperty<u32>* GetParticlesPerEmissionProperty() const;\n        //----------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The chance of actually emitting a particle during each\n        /// attempt.\n        //----------------------------------------------------------------\n        const ParticleProperty<f32>* GetEmissionChanceProperty() const;\n        //----------------------------------------------------------------\n        /// Destructor\n        ///\n        /// @author Ian Copland\n        //----------------------------------------------------------------\n        virtual ~ParticleEmitterDef() {};\n    private:\n        friend class ParticleEffect;\n        //----------------------------------------------------------------\n        /// Sets the owning particle effect. This can only be called by the \n        /// particle effect itself when this is added to it.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The particle effect.\n        //----------------------------------------------------------------\n        void SetParticleEffect(const ParticleEffect* in_particleEffect);\n\n        const ParticleEffect* m_particleEffect = nullptr;\n        EmissionMode m_emissionMode = EmissionMode::k_stream;\n        ParticlePropertyUPtr<f32> m_emissionRateProperty = ParticlePropertyUPtr<f32>(new ConstantParticleProperty<f32>(10.0f));\n        ParticlePropertyUPtr<u32> m_particlesPerEmissionProperty = ParticlePropertyUPtr<u32>(new ConstantParticleProperty<u32>(1));\n        ParticlePropertyUPtr<f32> m_emissionChanceProperty = ParticlePropertyUPtr<f32>(new ConstantParticleProperty<f32>(1.0f));\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Particle/Emitter/ParticleEmitterDefFactory.cpp",
    "content": "//\n//  ParticleEmitterDefFactory.cpp\n//  ChilliSource\n//  Created by Ian Copland on 08/11/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Particle/Emitter/ParticleEmitterDefFactory.h>\n\n#include <ChilliSource/Rendering/Particle/Emitter/CircleParticleEmitterDef.h>\n#include <ChilliSource/Rendering/Particle/Emitter/ConeParticleEmitterDef.h>\n#include <ChilliSource/Rendering/Particle/Emitter/Cone2DParticleEmitterDef.h>\n#include <ChilliSource/Rendering/Particle/Emitter/PointParticleEmitterDef.h>\n#include <ChilliSource/Rendering/Particle/Emitter/SphereParticleEmitterDef.h>\n\nnamespace ChilliSource\n{\n    CS_DEFINE_NAMEDTYPE(ParticleEmitterDefFactory);\n    //-----------------------------------------------------------------\n    //-----------------------------------------------------------------\n    ParticleEmitterDefFactoryUPtr ParticleEmitterDefFactory::Create()\n    {\n        return ParticleEmitterDefFactoryUPtr(new ParticleEmitterDefFactory());\n    }\n    //-----------------------------------------------------------------\n    //-----------------------------------------------------------------\n    bool ParticleEmitterDefFactory::IsA(InterfaceIDType in_interfaceId) const\n    {\n        return (ParticleEmitterDefFactory::InterfaceID == in_interfaceId);\n    }\n    //-----------------------------------------------------------------\n    //-----------------------------------------------------------------\n    void ParticleEmitterDefFactory::RegisterDefaults()\n    {\n        Register<CircleParticleEmitterDef>(\"Circle\");\n        Register<ConeParticleEmitterDef>(\"Cone\");\n        Register<Cone2DParticleEmitterDef>(\"Cone2D\");\n        Register<PointParticleEmitterDef>(\"Point\");\n        Register<SphereParticleEmitterDef>(\"Sphere\");\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Particle/Emitter/ParticleEmitterDefFactory.h",
    "content": "//\n//  ParticleEmitterDefFactory.h\n//  ChilliSource\n//  Created by Ian Copland on 08/11/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _ICENGINE_RENDERING_PARTICLES_PARTICLEEMITTERDEFFACTORY_H_\n#define _ICENGINE_RENDERING_PARTICLES_PARTICLEEMITTERDEFFACTORY_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Base/GenericFactory.h>\n#include <ChilliSource/Core/Delegate/MakeDelegate.h>\n#include <ChilliSource/Rendering/Particle/Emitter/ParticleEmitterDef.h>\n\n#include <json/json.h>\n\n#include <functional>\n#include <unordered_map>\n\nnamespace ChilliSource\n{\n    //--------------------------------------------------------------------------\n    /// A factory for creating particle emitter definitions. This allows \n    /// particle emitter definition types to be registered with the class. A\n    /// Particle Provider can then create new instances of the registered \n    /// emitter def with a Json descriptor.\n    ///\n    /// @author Ian Copland\n    //--------------------------------------------------------------------------\n    class ParticleEmitterDefFactory final : public GenericFactory<ParticleEmitterDef>\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(ParticleEmitterDefFactory);\n        //-----------------------------------------------------------------\n        /// Allows querying of whether or not this implements the interface\n        /// described by the given interface Id.\n        /// \n        /// @author Ian Copland\n        ///\n        /// @param The interface Id.\n        ///\n        /// @return Whether this implements the interface.\n        //-----------------------------------------------------------------\n        bool IsA(InterfaceIDType in_interfaceId) const override;\n    private:\n        friend class Application;\n        //-----------------------------------------------------------------\n        /// A factory method for creating new instances of a particle \n        /// emitter def factory.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @return The new instance of the system.\n        //-----------------------------------------------------------------\n        static ParticleEmitterDefFactoryUPtr Create();\n        //-----------------------------------------------------------------\n        /// Default constructor. Declared private to force the use of the\n        /// CreateSystem() method in Application.\n        ///\n        /// @author Ian Copland\n        //-----------------------------------------------------------------\n        ParticleEmitterDefFactory() = default;\n        //-----------------------------------------------------------------\n        /// Registers the default particle emitter definitions.\n        ///\n        /// @author Ian Copland\n        //-----------------------------------------------------------------\n        void RegisterDefaults() override;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Particle/Emitter/PointParticleEmitter.cpp",
    "content": "//\n//  PointParticleEmitter.cpp\n//  ChilliSource\n//  Created by Ian Copland on 02/11/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Particle/Emitter/PointParticleEmitter.h>\n\n#include <ChilliSource/Core/Math/Random.h>\n#include <ChilliSource/Rendering/Particle/ParticleEffect.h>\n#include <ChilliSource/Rendering/Particle/Emitter/PointParticleEmitterDef.h>\n\nnamespace ChilliSource\n{\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    PointParticleEmitter::PointParticleEmitter(const ParticleEmitterDef* in_particleEmitter, dynamic_array<Particle>* in_particleArray)\n        : ParticleEmitter(in_particleEmitter, in_particleArray)\n    {\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    void PointParticleEmitter::GenerateEmission(f32 in_normalisedEmissionTime, Vector3& out_position, Vector3& out_direction)\n    {\n        out_position = Vector3::k_zero;\n        out_direction = Random::GenerateDirection3D<f32>();\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Particle/Emitter/PointParticleEmitter.h",
    "content": "//\n//  PointParticleEmitter.h\n//  ChilliSource\n//  Created by Ian Copland on 02/11/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_PARTICLES_EMITTER_POINTPARTICLEEMITTER_H_\n#define _CHILLISOURCE_RENDERING_PARTICLES_EMITTER_POINTPARTICLEEMITTER_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Rendering/Particle/Emitter/ParticleEmitter.h>\n\nnamespace ChilliSource\n{\n    //-----------------------------------------------------------------------\n    /// A point particle emitter. The spawns particles at the entity's\n    /// position with a random direction.\n    ///\n    /// Particle emitters will be updated as a background task and should not\n    /// be accessed from other threads.\n    ///\n    /// @author Ian Copland\n    //-----------------------------------------------------------------------\n    class PointParticleEmitter final : public ParticleEmitter\n    {\n    public:\n        //----------------------------------------------------------------\n        /// Generates the position and direction of a new emission. These \n        /// values are in local space. This will be called as part of a \n        /// background task.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The normalised emission playback time.\n        /// @param [Out] The generated position in local space.\n        /// @param [Out] The generate direction in local space.\n        //----------------------------------------------------------------\n        void GenerateEmission(f32 in_normalisedEmissionTime, Vector3& out_position, Vector3& out_direction) override;\n    private:\n        friend class PointParticleEmitterDef;\n        //----------------------------------------------------------------\n        /// Constructor.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The particle emitter definition.\n        /// @param The particle array.\n        //----------------------------------------------------------------\n        PointParticleEmitter(const ParticleEmitterDef* in_particleEmitter, dynamic_array<Particle>* in_particleArray);\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Particle/Emitter/PointParticleEmitterDef.cpp",
    "content": "//\n//  PointParticleEmitterDef.cpp\n//  ChilliSource\n//  Created by Ian Copland on 02/11/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Particle/Emitter/PointParticleEmitterDef.h>\n\n#include <ChilliSource/Rendering/Particle/Emitter/PointParticleEmitter.h>\n\nnamespace ChilliSource\n{\n    CS_DEFINE_NAMEDTYPE(PointParticleEmitterDef);\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    PointParticleEmitterDef::PointParticleEmitterDef(EmissionMode in_emissionMode, ParticlePropertyUPtr<f32> in_emissionRateProperty, ParticlePropertyUPtr<u32> in_particlesPerEmissionProperty,\n        ParticlePropertyUPtr<f32> in_emissionChanceProperty)\n        : ParticleEmitterDef(in_emissionMode, std::move(in_emissionRateProperty), std::move(in_particlesPerEmissionProperty), std::move(in_emissionChanceProperty))\n    {\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    PointParticleEmitterDef::PointParticleEmitterDef(const Json::Value& in_paramsJson, const LoadedDelegate& in_loadedDelegate)\n        : ParticleEmitterDef(in_paramsJson)\n    {\n        //call the loaded delegate if required.\n        if (in_loadedDelegate != nullptr)\n        {\n            in_loadedDelegate(this);\n        }\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    bool PointParticleEmitterDef::IsA(InterfaceIDType in_interfaceId) const\n    {\n        return (ParticleEmitterDef::InterfaceID == in_interfaceId || PointParticleEmitterDef::InterfaceID == in_interfaceId);\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    ParticleEmitterUPtr PointParticleEmitterDef::CreateInstance(dynamic_array<Particle>* in_particleArray) const\n    {\n        return ParticleEmitterUPtr(new PointParticleEmitter(this, in_particleArray));\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Particle/Emitter/PointParticleEmitterDef.h",
    "content": "//\n//  PointParticleEmitterDef.h\n//  ChilliSource\n//  Created by Ian Copland on 02/11/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_PARTICLE_EMITTER_POINTPARTICLEEMITTERDEF_H_\n#define _CHILLISOURCE_RENDERING_PARTICLE_EMITTER_POINTPARTICLEEMITTERDEF_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Rendering/Particle/Emitter/ParticleEmitterDef.h>\n\nnamespace ChilliSource\n{\n    //-----------------------------------------------------------------------\n    /// A particle emitter def describing the properties for a Point Particle\n    /// Emitter and provides a means to create instances.\n    ///\n    /// As a particle emitter def's contents can potentially be read from \n    /// multiple threads, it is immutable after construction. The exception \n    /// to this is if it was created from a param dictionary with a \n    /// asynchronous delegate, in which case it is immutable after the\n    /// delegate is called.\n    ///\n    /// A point emitter def only contains the parameters provided by the base\n    /// particle emitter.\n    ///\n    /// @author Ian Copland\n    //-----------------------------------------------------------------------\n    class PointParticleEmitterDef final : public ParticleEmitterDef\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(PointParticleEmitterDef);\n        //----------------------------------------------------------------\n        /// Constructor\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The emission mode.\n        /// @param The emission rate property. This is ignored for when in \n        /// burst emission mode.\n        /// @param The property describing the number of particles in each\n        /// emission.\n        /// @param The property describing the chance that a particle will \n        /// actually emit each time an emission is attempted. This is used \n        /// to make an effect look more random.\n        //----------------------------------------------------------------\n        PointParticleEmitterDef(EmissionMode in_emissionMode, ParticlePropertyUPtr<f32> in_emissionRateProperty, ParticlePropertyUPtr<u32> in_particlesPerEmissionProperty,\n            ParticlePropertyUPtr<f32> in_emissionChanceProperty);\n        //----------------------------------------------------------------\n        /// Constructor. Initialises with parameters read from the given \n        /// param dictionary. If the async delegate is not null, then any \n        /// resource loading will occur as a background task. Once complete \n        /// the delegate will be called. The parameters read from json are\n        /// described in the base class's class documentation.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param A json object describing the parameters for the particle\n        /// emitter def.\n        /// @param The loaded delegate. If this is supplied any resources\n        /// will be loaded as a background task. Once complete, this\n        /// delegate will be called.\n        //----------------------------------------------------------------\n        PointParticleEmitterDef(const Json::Value& in_paramsJson, const LoadedDelegate& in_loadedDelegate = nullptr);\n        //----------------------------------------------------------------\n        /// Allows querying of whether or not this implements the interface\n        /// described by the given Id.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The interface Id.\n        ///\n        /// @return Whether or not the interface is implemented.\n        //----------------------------------------------------------------\n        bool IsA(InterfaceIDType in_interfaceId) const override;\n        //----------------------------------------------------------------\n        /// Creates a new instance of a Point Particle Emitter.\n        ///\n        /// @author Ian Copland.\n        ///\n        /// @param The particle array.\n        ///\n        /// @return the instance.\n        //----------------------------------------------------------------\n        ParticleEmitterUPtr CreateInstance(dynamic_array<Particle>* in_particleArray) const override;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Particle/Emitter/SphereParticleEmitter.cpp",
    "content": "//\n//  SphereParticleEmitter.cpp\n//  ChilliSource\n//  Created by Ian Copland on 19/10/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Particle/Emitter/SphereParticleEmitter.h>\n\n#include <ChilliSource/Core/Math/Random.h>\n#include <ChilliSource/Rendering/Particle/ParticleEffect.h>\n#include <ChilliSource/Rendering/Particle/Emitter/SphereParticleEmitterDef.h>\n\nnamespace ChilliSource\n{\n    namespace\n    {\n        //----------------------------------------------------------------\n        /// Generates a point within a sphere with even distribution. \n        ///\n        /// @author Ian Copland\n        ///\n        /// @return A random point in a unit sphere.\n        //----------------------------------------------------------------\n        Vector3 GeneratePointInUnitSphere()\n        {\n            f32 dist = std::pow(Random::GenerateNormalised<f32>(), (1.0f / 3.0f));\n            return Random::GenerateDirection3D<f32>() * dist;\n        }\n    }\n\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    SphereParticleEmitter::SphereParticleEmitter(const ParticleEmitterDef* in_particleEmitter, dynamic_array<Particle>* in_particleArray)\n        : ParticleEmitter(in_particleEmitter, in_particleArray)\n    {\n        //Only the sphere emitter def can create this, so this is safe.\n        m_sphereParticleEmitterDef = static_cast<const SphereParticleEmitterDef*>(in_particleEmitter);\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    void SphereParticleEmitter::GenerateEmission(f32 in_normalisedEmissionTime, Vector3& out_position, Vector3& out_direction)\n    {\n        f32 radius = m_sphereParticleEmitterDef->GetRadiusProperty()->GenerateValue(in_normalisedEmissionTime);\n\n        //calculate the position.\n        switch (m_sphereParticleEmitterDef->GetEmitFromType())\n        {\n        case SphereParticleEmitterDef::EmitFromType::k_inside:\n            out_position = GeneratePointInUnitSphere() * radius;\n            break;\n        case SphereParticleEmitterDef::EmitFromType::k_surface:\n            out_position = Random::GenerateDirection3D<f32>() * radius;\n            break;\n        default:\n            CS_LOG_FATAL(\"Invalid 'Emit From' type.\");\n            break;\n        }\n\n        //calculate the direction.\n        switch (m_sphereParticleEmitterDef->GetEmitDirectionType())\n        {\n        case SphereParticleEmitterDef::EmitDirectionType::k_random:\n            out_direction = Random::GenerateDirection3D<f32>();\n            break;\n        case SphereParticleEmitterDef::EmitDirectionType::k_awayFromCentre:\n            out_direction = Vector3::Normalise(out_position);\n            break;\n        default:\n            CS_LOG_FATAL(\"Invalid 'Emit Direction' type.\");\n            break;\n        }\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Particle/Emitter/SphereParticleEmitter.h",
    "content": "//\n//  SphereParticleEmitter.h\n//  ChilliSource\n//  Created by Ian Copland on 19/10/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_PARTICLES_EMITTER_SPHEREPARTICLEEMITTER_H_\n#define _CHILLISOURCE_RENDERING_PARTICLES_EMITTER_SPHEREPARTICLEEMITTER_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Rendering/Particle/Emitter/ParticleEmitter.h>\n\nnamespace ChilliSource\n{\n    //-----------------------------------------------------------------------\n    /// A sphere particle emitter. This spawns particles either within a \n    /// sphere or on the sphere's surface, with a random direction or moving\n    /// away from the centre of the sphere. \n    ///\n    /// Particle emitters will be updated as a background task and should not\n    /// be accessed from other threads.\n    ///\n    /// @author Ian Copland\n    //-----------------------------------------------------------------------\n    class SphereParticleEmitter final : public ParticleEmitter\n    {\n    public:\n        //----------------------------------------------------------------\n        /// Generates the position and direction of a new emission. These \n        /// values are in local space. This will be called as part of a \n        /// background task.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The normalised emission playback time.\n        /// @param [Out] The generated position in local space.\n        /// @param [Out] The generate direction in local space.\n        //----------------------------------------------------------------\n        void GenerateEmission(f32 in_normalisedEmissionTime, Vector3& out_position, Vector3& out_direction) override;\n    private:\n        friend class SphereParticleEmitterDef;\n        //----------------------------------------------------------------\n        /// Constructor.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The particle emitter definition.\n        /// @param The particle array.\n        //----------------------------------------------------------------\n        SphereParticleEmitter(const ParticleEmitterDef* in_particleEmitter, dynamic_array<Particle>* in_particleArray);\n\n        const SphereParticleEmitterDef* m_sphereParticleEmitterDef = nullptr;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Particle/Emitter/SphereParticleEmitterDef.cpp",
    "content": "//\n//  SphereParticleEmitterDef.cpp\n//  ChilliSource\n//  Created by Ian Copland on 19/10/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Particle/Emitter/SphereParticleEmitterDef.h>\n\n#include <ChilliSource/Rendering/Particle/Emitter/SphereParticleEmitter.h>\n#include <ChilliSource/Rendering/Particle/Property/ParticlePropertyFactory.h>\n\nnamespace ChilliSource\n{\n    namespace\n    {\n        //-----------------------------------------------------------------\n        /// Parse an emit from type from the given string. This is case \n        /// insensitive. If the string is not a valid emit from type this \n        /// will error.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The string to parse.\n        ///\n        /// @return the parsed emit from type.\n        //-----------------------------------------------------------------\n        SphereParticleEmitterDef::EmitFromType ParseEmitFromType(const std::string& in_emitFromTypeString)\n        {\n            std::string emitFromTypeString = in_emitFromTypeString;\n            StringUtils::ToLowerCase(emitFromTypeString);\n\n            if (emitFromTypeString == \"inside\")\n            {\n                return SphereParticleEmitterDef::EmitFromType::k_inside;\n            }\n            else if (emitFromTypeString == \"surface\")\n            {\n                return SphereParticleEmitterDef::EmitFromType::k_surface;\n            }\n\n            CS_LOG_FATAL(\"Invalid emit from type: \" + in_emitFromTypeString);\n            return SphereParticleEmitterDef::EmitFromType::k_inside;\n        }\n        //-----------------------------------------------------------------\n        /// Parse an emit direction type from the given string. This is case \n        /// insensitive. If the string is not a valid direction from type this \n        /// will error.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The string to parse.\n        ///\n        /// @return the parsed emit direction type.\n        //-----------------------------------------------------------------\n        SphereParticleEmitterDef::EmitDirectionType ParseEmitDirectionType(const std::string& in_emitDirectionTypeString)\n        {\n            std::string emitDirectionTypeString = in_emitDirectionTypeString;\n            StringUtils::ToLowerCase(emitDirectionTypeString);\n\n            if (emitDirectionTypeString == \"awayfromcentre\")\n            {\n                return SphereParticleEmitterDef::EmitDirectionType::k_awayFromCentre;\n            }\n            else if (emitDirectionTypeString == \"random\")\n            {\n                return SphereParticleEmitterDef::EmitDirectionType::k_random;\n            }\n\n            CS_LOG_FATAL(\"Invalid emit direction type: \" + in_emitDirectionTypeString);\n            return SphereParticleEmitterDef::EmitDirectionType::k_awayFromCentre;\n        }\n    }\n\n    CS_DEFINE_NAMEDTYPE(SphereParticleEmitterDef);\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    SphereParticleEmitterDef::SphereParticleEmitterDef(EmissionMode in_emissionMode, ParticlePropertyUPtr<f32> in_emissionRateProperty, ParticlePropertyUPtr<u32> in_particlesPerEmissionProperty,\n        ParticlePropertyUPtr<f32> in_emissionChanceProperty, EmitFromType in_emitFromType, EmitDirectionType in_emitDirectionType, ParticlePropertyUPtr<f32> in_radiusProperty)\n        : ParticleEmitterDef(in_emissionMode, std::move(in_emissionRateProperty), std::move(in_particlesPerEmissionProperty), std::move(in_emissionChanceProperty)), m_emitFromType(in_emitFromType),\n        m_emitDirectionType(in_emitDirectionType), m_radiusProperty(std::move(in_radiusProperty))\n    {\n        CS_ASSERT(m_radiusProperty != nullptr, \"Cannot create a Sphere Particle Emitter Def with a null 'radius' property.\");\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    SphereParticleEmitterDef::SphereParticleEmitterDef(const Json::Value& in_paramsJson, const LoadedDelegate& in_loadedDelegate)\n        : ParticleEmitterDef(in_paramsJson)\n    {\n        //Emit from type\n        Json::Value jsonValue = in_paramsJson.get(\"EmitFromType\", Json::nullValue);\n        if (jsonValue.isNull() == false)\n        {\n            CS_ASSERT(jsonValue.isString(), \"Emit from type must be a string.\");\n            m_emitFromType = ParseEmitFromType(jsonValue.asString());\n        }\n\n        //Emit direction type\n        jsonValue = in_paramsJson.get(\"EmitDirectionType\", Json::nullValue);\n        if (jsonValue.isNull() == false)\n        {\n            CS_ASSERT(jsonValue.isString(), \"Emit direction type must be a string.\");\n            m_emitDirectionType = ParseEmitDirectionType(jsonValue.asString());\n        }\n\n        //Radius\n        jsonValue = in_paramsJson.get(\"RadiusProperty\", Json::nullValue);\n        if (jsonValue.isNull() == false)\n        {\n            m_radiusProperty = ParticlePropertyFactory::CreateProperty<f32>(jsonValue);\n        }\n\n        //call the loaded delegate if required.\n        if (in_loadedDelegate != nullptr)\n        {\n            in_loadedDelegate(this);\n        }\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    bool SphereParticleEmitterDef::IsA(InterfaceIDType in_interfaceId) const\n    {\n        return (ParticleEmitterDef::InterfaceID == in_interfaceId || SphereParticleEmitterDef::InterfaceID == in_interfaceId);\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    ParticleEmitterUPtr SphereParticleEmitterDef::CreateInstance(dynamic_array<Particle>* in_particleArray) const\n    {\n        return ParticleEmitterUPtr(new SphereParticleEmitter(this, in_particleArray));\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    SphereParticleEmitterDef::EmitFromType SphereParticleEmitterDef::GetEmitFromType() const\n    {\n        return m_emitFromType;\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    SphereParticleEmitterDef::EmitDirectionType SphereParticleEmitterDef::GetEmitDirectionType() const\n    {\n        return m_emitDirectionType;\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    const ParticleProperty<f32>* SphereParticleEmitterDef::GetRadiusProperty() const\n    {\n        return m_radiusProperty.get();\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Particle/Emitter/SphereParticleEmitterDef.h",
    "content": "//\n//  SphereParticleEmitterDef.h\n//  ChilliSource\n//  Created by Ian Copland on 19/10/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_PARTICLE_EMITTER_SPHEREPARTICLEEMITTERDEF_H_\n#define _CHILLISOURCE_RENDERING_PARTICLE_EMITTER_SPHEREPARTICLEEMITTERDEF_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Rendering/Particle/Emitter/ParticleEmitterDef.h>\n\nnamespace ChilliSource\n{\n    //-----------------------------------------------------------------------\n    /// A particle emitter def describing the properties for a Sphere Particle\n    /// Emitter and provides a means to create instances.\n    ///\n    /// As a particle emitter def's contents can potentially be read from \n    /// multiple threads, it is immutable after construction. The exception \n    /// to this is if it was created from a param dictionary with a \n    /// asynchronous delegate, in which case it is immutable after the\n    /// delegate is called.\n    ///\n    /// The following are properties that a sphere particle emitter \n    /// contains in addition to the standard emitter properties:\n    ///\n    /// \"EmitFromType\": Where on the particle emitter particles can be\n    /// emitted from. The possible values are \"Inside\" or \"Surface\".\n    /// The default value is \"Inside\".\n    ///\n    /// \"EmitDirectionType\": Describes how the direction of an emitted\n    /// particle will be generated. The possible values are \"AwayFromCentre\"\n    /// and \"Random\". This defaults to \"AwayFromCentre\".\n    ///\n    /// \"RadiusProperty\": A property describing the radius of the emitter.\n    ///\n    /// @author Ian Copland\n    //-----------------------------------------------------------------------\n    class SphereParticleEmitterDef final : public ParticleEmitterDef\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(SphereParticleEmitterDef);\n        //----------------------------------------------------------------\n        /// An enum describing where in the emitter a particle can be\n        /// generated. If inside is used, the particle can be emitted from\n        /// anywhere inside the sphere. If surface is used, particles will\n        /// only be emitted from the surface of the sphere.\n        /// \n        /// @author Ian Copland\n        //----------------------------------------------------------------\n        enum class EmitFromType\n        {\n            k_inside,\n            k_surface\n        };\n        //----------------------------------------------------------------\n        /// An enum describing the possible ways the emission direction\n        /// of a particle can be generated. If Away From Centre is used the \n        /// particle will always move in a direction away from the centre\n        /// of the emitter. If random is used, the direction will be\n        /// entirely random.\n        /// \n        /// @author Ian Copland\n        //----------------------------------------------------------------\n        enum class EmitDirectionType\n        {\n            k_awayFromCentre,\n            k_random\n        };\n        //----------------------------------------------------------------\n        /// Constructor\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The emission mode.\n        /// @param The emission rate property. This is ignored for when in \n        /// burst emission mode.\n        /// @param The property describing the number of particles in each\n        /// emission.\n        /// @param The property describing the chance that a particle will \n        /// actually emit each time an emission is attempted. This is used \n        /// to make an effect look more random.\n        /// @param Where in the sphere a particle can be emitted from.\n        /// @param Describes how the direction of a particle will be\n        /// determined.\n        /// @param The property describing the radius of the emitter.\n        //----------------------------------------------------------------\n        SphereParticleEmitterDef(EmissionMode in_emissionMode, ParticlePropertyUPtr<f32> in_emissionRateProperty, ParticlePropertyUPtr<u32> in_particlesPerEmissionProperty,\n            ParticlePropertyUPtr<f32> in_emissionChanceProperty, EmitFromType in_emitFromType, EmitDirectionType in_emitDirectionType, ParticlePropertyUPtr<f32> in_radiusProperty);\n        //----------------------------------------------------------------\n        /// Constructor. Initialises with parameters read from the given \n        /// param dictionary. If the async delegate is not null, then any \n        /// resource loading will occur as a background task. Once complete \n        /// the delegate will be called. The parameters read from json are\n        /// described in the class documentation.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param A json object describing the parameters for the particle\n        /// emitter def.\n        /// @param The loaded delegate. If this is supplied any resources\n        /// will be loaded as a background task. Once complete, this\n        /// delegate will be called.\n        //----------------------------------------------------------------\n        SphereParticleEmitterDef(const Json::Value& in_paramsJson, const LoadedDelegate& in_loadedDelegate = nullptr);\n        //----------------------------------------------------------------\n        /// Allows querying of whether or not this implements the interface\n        /// described by the given Id.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The interface Id.\n        ///\n        /// @return Whether or not the interface is implemented.\n        //----------------------------------------------------------------\n        bool IsA(InterfaceIDType in_interfaceId) const override;\n        //----------------------------------------------------------------\n        /// Creates a new instance of a Sphere Particle Emitter.\n        ///\n        /// @author Ian Copland.\n        ///\n        /// @param The particle array.\n        ///\n        /// @return the instance.\n        //----------------------------------------------------------------\n        ParticleEmitterUPtr CreateInstance(dynamic_array<Particle>* in_particleArray) const override;\n        //----------------------------------------------------------------\n        /// @author Ian Copland.\n        ///\n        /// @param Where in the sphere a particle can be emitted from.\n        //----------------------------------------------------------------\n        EmitFromType GetEmitFromType() const;\n        //----------------------------------------------------------------\n        /// @author Ian Copland.\n        ///\n        /// @param The emit direction type, i.e how the direction of a \n        /// particle will be  determined.\n        //----------------------------------------------------------------\n        EmitDirectionType GetEmitDirectionType() const;\n        //----------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return A property describing the radius of the particle\n        /// emitter.\n        //----------------------------------------------------------------\n        const ParticleProperty<f32>* GetRadiusProperty() const;\n    private:\n        EmitFromType m_emitFromType = EmitFromType::k_inside;\n        EmitDirectionType m_emitDirectionType = EmitDirectionType::k_awayFromCentre;\n        ParticlePropertyUPtr<f32> m_radiusProperty = ParticlePropertyUPtr<f32>(new ConstantParticleProperty<f32>(1.0f));\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Particle/Particle.h",
    "content": "//\n//  Particle.h\n//  ChilliSource\n//  Created by Ian Copland on 07/10/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_PARTICLE_PARTICLE_H_\n#define _CHILLISOURCE_RENDERING_PARTICLE_PARTICLE_H_\n\n#include <ChilliSource/ChilliSource.h>\n\n#include <ChilliSource/Core/Math/Vector3.h>\n#include <ChilliSource/Core/Math/Vector2.h>\n#include <ChilliSource/Core/Math/Quaternion.h>\n#include <ChilliSource/Core/Base/Colour.h>\n\nnamespace ChilliSource\n{\n    //-----------------------------------------------------------------------\n    /// A struct containing the properties for a single particle.\n    ///\n    /// @author Ian Copland\n    //-----------------------------------------------------------------------\n    struct Particle final\n    {\n        bool m_isActive = false;\n        f32 m_lifetime = 0.0f;\n        f32 m_energy = 0.0f;\n        Vector3 m_position;\n        Vector2 m_scale = Vector2::k_one;\n        f32 m_rotation = 0.0f;\n        Colour m_colour = Colour::k_white;\n        Vector3 m_velocity;\n        f32 m_angularVelocity = 0.0f;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Particle/ParticleEffect.cpp",
    "content": "//\n//  ParticleEffect.cpp\n//  ChilliSource\n//  Created by Ian Copland on 06/10/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Particle/ParticleEffect.h>\n\nnamespace ChilliSource\n{\n    CS_DEFINE_NAMEDTYPE(ParticleEffect);\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    ParticleEffectUPtr ParticleEffect::Create()\n    {\n        return ParticleEffectUPtr(new ParticleEffect());\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    ParticleEffect::ParticleEffect()\n    {\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    bool ParticleEffect::IsA(InterfaceIDType in_interfaceId) const\n    {\n        return (ParticleEffect::InterfaceID == in_interfaceId);\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    f32 ParticleEffect::GetDuration() const\n    {\n        return m_duration;\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    u32 ParticleEffect::GetMaxParticles() const\n    {\n        return m_maxParticles;\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    ParticleEffect::SimulationSpace ParticleEffect::GetSimulationSpace() const\n    {\n        return m_simulationSpace;\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    const ParticleProperty<f32>* ParticleEffect::GetLifetimeProperty() const\n    {\n        return m_lifetimeProperty.get();\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    const ParticleProperty<Vector2>* ParticleEffect::GetInitialScaleProperty() const\n    {\n        return m_initialScaleProperty.get();\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    const ParticleProperty<f32>* ParticleEffect::GetInitialRotationProperty() const\n    {\n        return m_initialRotationProperty.get();\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    const ParticleProperty<Colour>* ParticleEffect::GetInitialColourProperty() const\n    {\n        return m_initialColourProperty.get();\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    const ParticleProperty<f32>* ParticleEffect::GetInitialSpeedProperty() const\n    {\n        return m_initialSpeedProperty.get();\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    const ParticleProperty<f32>* ParticleEffect::GetInitialAngularVelocityProperty() const\n    {\n        return m_initialAngularVelocityProperty.get();\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    const ParticleDrawableDef* ParticleEffect::GetDrawableDef() const\n    {\n        return m_drawableDef.get();\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    const ParticleEmitterDef* ParticleEffect::GetEmitterDef() const\n    {\n        return m_emitterDef.get();\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    std::vector<const ParticleAffectorDef*> ParticleEffect::GetAffectorDefs() const\n    {\n        std::vector<const ParticleAffectorDef*> output;\n\n        for (const auto& affectorDef : m_affectorDefs)\n        {\n            output.push_back(affectorDef.get());\n        }\n\n        return output;\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    void ParticleEffect::SetDuration(f32 in_duration)\n    {\n        m_duration = in_duration;\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    void ParticleEffect::SetMaxParticles(u32 in_maxParticles)\n    {\n        m_maxParticles = in_maxParticles;\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    void ParticleEffect::SetSimulationSpace(SimulationSpace in_simulationSpace)\n    {\n        m_simulationSpace = in_simulationSpace;\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    void ParticleEffect::SetLifetimeProperty(ParticlePropertyUPtr<f32> in_lifetimeProperty)\n    {\n        m_lifetimeProperty = std::move(in_lifetimeProperty);\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    void ParticleEffect::SetInitialScaleProperty(ParticlePropertyUPtr<Vector2> in_initialScaleProperty)\n    {\n        m_initialScaleProperty = std::move(in_initialScaleProperty);\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    void ParticleEffect::SetInitialRotationProperty(ParticlePropertyUPtr<f32> in_initialRotationProperty)\n    {\n        m_initialRotationProperty = std::move(in_initialRotationProperty);\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    void ParticleEffect::SetInitialColourProperty(ParticlePropertyUPtr<Colour> in_initialColourProperty)\n    {\n        m_initialColourProperty = std::move(in_initialColourProperty);\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    void ParticleEffect::SetInitialSpeedProperty(ParticlePropertyUPtr<f32> in_initialSpeedProperty)\n    {\n        m_initialSpeedProperty = std::move(in_initialSpeedProperty);\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    void ParticleEffect::SetInitialAngularVelocityProperty(ParticlePropertyUPtr<f32> in_initialAngularVelocityProperty)\n    {\n        m_initialAngularVelocityProperty = std::move(in_initialAngularVelocityProperty);\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    void ParticleEffect::SetDrawableDef(ParticleDrawableDefUPtr in_drawableDef)\n    {\n        CS_ASSERT(m_drawableDef == nullptr, \"Cannot change the drawable definition in a Particle Effect.\");\n\n        m_drawableDef = std::move(in_drawableDef);\n        m_drawableDef->SetParticleEffect(this);\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    void ParticleEffect::SetEmitterDef(ParticleEmitterDefUPtr in_emitterDef)\n    {\n        CS_ASSERT(m_emitterDef == nullptr, \"Cannot change the drawable definition in a Particle Effect.\");\n\n        m_emitterDef = std::move(in_emitterDef);\n        m_emitterDef->SetParticleEffect(this);\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    void ParticleEffect::SetAffectorDefs(std::vector<ParticleAffectorDefUPtr> in_affectorDefs)\n    {\n        CS_ASSERT(m_affectorDefs.empty() == true, \"Cannot change the affector definitions in a Particle Effect.\");\n\n        m_affectorDefs = std::move(in_affectorDefs);\n        for (auto& affectorDef : m_affectorDefs)\n        {\n            affectorDef->SetParticleEffect(this);\n        }\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    ParticleEffect::~ParticleEffect()\n    {\n        m_lifetimeProperty.reset();\n        m_initialScaleProperty.reset();\n        m_initialRotationProperty.reset();\n        m_initialColourProperty.reset();\n        m_initialSpeedProperty.reset();\n        m_initialAngularVelocityProperty.reset();\n\n        m_drawableDef.reset();\n        m_emitterDef.reset();\n        m_affectorDefs.clear();\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Particle/ParticleEffect.h",
    "content": "//\n//  ParticleEffect.h\n//  ChilliSource\n//  Created by Ian Copland on 06/10/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_PARTICLE_PARTICLEEFFECT_H_\n#define _CHILLISOURCE_RENDERING_PARTICLE_PARTICLEEFFECT_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Base/Colour.h>\n#include <ChilliSource/Core/Resource/Resource.h>\n#include <ChilliSource/Core/Math/Vector2.h>\n#include <ChilliSource/Rendering/Particle/Affector/ParticleAffectorDef.h>\n#include <ChilliSource/Rendering/Particle/Drawable/ParticleDrawableDef.h>\n#include <ChilliSource/Rendering/Particle/Emitter/ParticleEmitterDef.h>\n#include <ChilliSource/Rendering/Particle/Property/ParticleProperty.h>\n#include <ChilliSource/Rendering/Particle/Property/ConstantParticleProperty.h>\n\n#include <vector>\n\nnamespace ChilliSource\n{\n    //-----------------------------------------------------------------------\n    /// A Particle Effect contains all the properties and definitions for the\n    /// drawable, emitter and effectors of a particle effect. This can be used\n    /// in conjunction with a Particle Effect Component to display an instance\n    /// of the effect in the scene.\n    ///\n    /// A particle effects properties and definitions should not be changed \n    /// while it is in use. Particle Effect Components update in a background\n    /// task and rely on Particle Effect being immutable for lockless thread\n    /// safety.\n    ///\n    /// @author Ian Copland\n    //-----------------------------------------------------------------------\n    class ParticleEffect final : public Resource\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(ParticleEffect);\n        //----------------------------------------------------------------\n        /// An enum describing the possible simulation space values, i.e \n        /// local or world space.\n        ///\n        /// @author Ian Copland\n        //----------------------------------------------------------------\n        enum class SimulationSpace\n        {\n            k_local,\n            k_world\n        };\n        //----------------------------------------------------------------\n        /// Allows querying of whether or not this implements the interface\n        /// described by the given Id.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The interface Id.\n        ///\n        /// @return Whether or not the interface is implemented.\n        //----------------------------------------------------------------\n        bool IsA(InterfaceIDType in_interfaceId) const override;\n        //----------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The duration of the particle effect.\n        //----------------------------------------------------------------\n        f32 GetDuration() const;\n        //----------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The max number of particles in the effect.\n        //----------------------------------------------------------------\n        u32 GetMaxParticles() const;\n        //----------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The space in which the particle effect is simulated.\n        //----------------------------------------------------------------\n        SimulationSpace GetSimulationSpace() const;\n        //----------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The property used to generate the lifetime of a new \n        /// particle.\n        //----------------------------------------------------------------\n        const ParticleProperty<f32>* GetLifetimeProperty() const;\n        //----------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The property used to generate the initial scale of a \n        /// new particle.\n        //----------------------------------------------------------------\n        const ParticleProperty<Vector2>* GetInitialScaleProperty() const;\n        //----------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The property used to generate the initial rotation of \n        /// a new particle.\n        //----------------------------------------------------------------\n        const ParticleProperty<f32>* GetInitialRotationProperty() const;\n        //----------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The property used to generate the initial colour of \n        /// a new particle.\n        //----------------------------------------------------------------\n        const ParticleProperty<Colour>* GetInitialColourProperty() const;\n        //----------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The property used to generate the initial speed of a \n        /// new particle. The initial direction of motion is described by \n        /// the emitter.\n        //----------------------------------------------------------------\n        const ParticleProperty<f32>* GetInitialSpeedProperty() const;\n        //----------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The property used to generate the initial angular \n        /// velocity of a new particle.\n        //----------------------------------------------------------------\n        const ParticleProperty<f32>* GetInitialAngularVelocityProperty() const;\n        //----------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return This particle effect's drawable definition.\n        //----------------------------------------------------------------\n        const ParticleDrawableDef* GetDrawableDef() const;\n        //----------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The particle emitter definition for this effect.\n        //----------------------------------------------------------------\n        const ParticleEmitterDef* GetEmitterDef() const;\n        //----------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The list of affector definitions for this effect.\n        //----------------------------------------------------------------\n        std::vector<const ParticleAffectorDef*> GetAffectorDefs() const;\n        //----------------------------------------------------------------\n        /// Sets the duration of the particle effect. \n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The duration.\n        //----------------------------------------------------------------\n        void SetDuration(f32 in_duration);\n        //----------------------------------------------------------------\n        /// Sets the maximum number of particles in the effect.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The max number of particles.\n        //----------------------------------------------------------------\n        void SetMaxParticles(u32 in_maxParticles);\n        //----------------------------------------------------------------\n        /// Sets the simulation space of the particle effect.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The simulation space.\n        //----------------------------------------------------------------\n        void SetSimulationSpace(SimulationSpace in_simulationSpace);\n        //----------------------------------------------------------------\n        /// Sets the property used to generate the lifetime of a new \n        /// particle.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The propery. \n        //----------------------------------------------------------------\n        void SetLifetimeProperty(ParticlePropertyUPtr<f32> in_lifetimeProperty);\n        //----------------------------------------------------------------\n        /// Sets the property used to generate the initial scale of a new \n        /// particle.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The property\n        //----------------------------------------------------------------\n        void SetInitialScaleProperty(ParticlePropertyUPtr<Vector2> in_initialScaleProperty);\n        //----------------------------------------------------------------\n        /// Sets the property used to generate the initial rotation of a \n        /// new particle.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The property\n        //----------------------------------------------------------------\n        void SetInitialRotationProperty(ParticlePropertyUPtr<f32> in_initialRotationProperty);\n        //----------------------------------------------------------------\n        /// Sets the property used to generate the initial colour of a new \n        /// particle.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The property\n        //----------------------------------------------------------------\n        void SetInitialColourProperty(ParticlePropertyUPtr<Colour> in_initialColourProperty);\n        //----------------------------------------------------------------\n        /// Sets the property used to generate the initial speed of a new \n        /// particle. The initial direction of motion is described by the \n        /// emitter.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The property\n        //----------------------------------------------------------------\n        void SetInitialSpeedProperty(ParticlePropertyUPtr<f32> in_initialSpeedProperty);\n        //----------------------------------------------------------------\n        /// Sets the property used to generate the initial angular \n        /// velocity of a new particle.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The property\n        //----------------------------------------------------------------\n        void SetInitialAngularVelocityProperty(ParticlePropertyUPtr<f32> in_initialAngularVelocityProperty);\n        //----------------------------------------------------------------\n        /// Sets the particle drawable for this particle effect.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The particle graphic definition.\n        //----------------------------------------------------------------\n        void SetDrawableDef(ParticleDrawableDefUPtr in_drawableDef);\n        //----------------------------------------------------------------\n        /// Sets the particle emitter definition for this particle effect.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The particle emitter definition.\n        //----------------------------------------------------------------\n        void SetEmitterDef(ParticleEmitterDefUPtr in_emitterDef);\n        //----------------------------------------------------------------\n        /// Sets the particle affector definitions for this particle effect.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The particle Affector definition.\n        //----------------------------------------------------------------\n        void SetAffectorDefs(std::vector<ParticleAffectorDefUPtr> in_affectorDefs);\n        //----------------------------------------------------------------\n        /// Destructor\n        ///\n        /// @author Ian Copland\n        //----------------------------------------------------------------\n        virtual ~ParticleEffect();\n    private:\n        friend class ResourcePool;\n        //----------------------------------------------------------------\n        /// Factory method to create an new instance of an empty material \n        /// resource. Only called by the resource pool.\n        ///\n        /// @author Ian Copland\n        //----------------------------------------------------------------\n        static ParticleEffectUPtr Create();\n        //----------------------------------------------------------------\n        /// Private constructor to ensure that the factory method is used\n        ///\n        /// @author Ian Copland\n        //----------------------------------------------------------------\n        ParticleEffect();\n\n        f32 m_duration = 1.0f;\n        u32 m_maxParticles = 100;\n        SimulationSpace m_simulationSpace = SimulationSpace::k_local;\n\n        ParticlePropertyUPtr<f32> m_lifetimeProperty;\n        ParticlePropertyUPtr<Vector2> m_initialScaleProperty = ParticlePropertyUPtr<Vector2>(new ConstantParticleProperty<Vector2>(Vector2::k_one));\n        ParticlePropertyUPtr<f32> m_initialRotationProperty = ParticlePropertyUPtr<f32>(new ConstantParticleProperty<f32>(0.0f));\n        ParticlePropertyUPtr<Colour> m_initialColourProperty = ParticlePropertyUPtr<Colour>(new ConstantParticleProperty<Colour>(Colour::k_white));\n        ParticlePropertyUPtr<f32> m_initialSpeedProperty = ParticlePropertyUPtr<f32>(new ConstantParticleProperty<f32>(0.0f));\n        ParticlePropertyUPtr<f32> m_initialAngularVelocityProperty = ParticlePropertyUPtr<f32>(new ConstantParticleProperty<f32>(0.0f));\n\n        ParticleDrawableDefUPtr m_drawableDef;\n        ParticleEmitterDefUPtr m_emitterDef;\n        std::vector<ParticleAffectorDefUPtr> m_affectorDefs;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Particle/ParticleEffectComponent.cpp",
    "content": "//\n//  ParticleEffectComponent.cpp\n//  ChilliSource\n//  Created by Ian Copland on 06/10/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Particle/ParticleEffectComponent.h>\n\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/Container/dynamic_array.h>\n#include <ChilliSource/Core/Delegate/MakeDelegate.h>\n#include <ChilliSource/Core/Entity/Entity.h>\n#include <ChilliSource/Core/State/State.h>\n#include <ChilliSource/Core/Threading/TaskScheduler.h>\n#include <ChilliSource/Rendering/Camera/PerspectiveCameraComponent.h>\n#include <ChilliSource/Rendering/Particle/ConcurrentParticleData.h>\n#include <ChilliSource/Rendering/Particle/Particle.h>\n#include <ChilliSource/Rendering/Particle/ParticleEffect.h>\n#include <ChilliSource/Rendering/Particle/Affector/ParticleAffector.h>\n#include <ChilliSource/Rendering/Particle/Affector/ParticleAffectorDef.h>\n#include <ChilliSource/Rendering/Particle/Drawable/ParticleDrawable.h>\n#include <ChilliSource/Rendering/Particle/Drawable/ParticleDrawableDef.h>\n#include <ChilliSource/Rendering/Particle/Emitter/ParticleEmitter.h>\n#include <ChilliSource/Rendering/Particle/Emitter/ParticleEmitterDef.h>\n\n#include <limits>\n#include <tuple>\n\nnamespace ChilliSource\n{\n    namespace\n    {\n        //----------------------------------------------------------------\n        /// A container for all information required by the background\n        /// particle update.\n        ///\n        /// @author Ian Copland\n        //----------------------------------------------------------------\n        struct ParticleUpdateDesc final\n        {\n            ParticleEffectCSPtr m_particleEffect;\n            ParticleEmitterSPtr m_particleEmitter;\n            std::vector<ParticleAffectorSPtr> m_particleAffectors;\n            std::shared_ptr<dynamic_array<Particle>> m_particleArray;\n            ConcurrentParticleDataSPtr m_concurrentParticleData;\n            f32 m_playbackTime = 0.0f;\n            f32 m_deltaTime = 0.0f; \n            Vector3 m_entityPosition;\n            Vector3 m_entityScale;\n            Quaternion m_entityOrientation;\n            bool m_interpolateEmission = false;\n        };\n        //----------------------------------------------------------------\n        /// Performs a series of assertions to ensure the given particle \n        /// effect is ready for use.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The particle effect.\n        //----------------------------------------------------------------\n        void ValidateParticleEffect(const ParticleEffectCSPtr& in_particleEffect)\n        {\n            CS_ASSERT(in_particleEffect->GetDrawableDef() != nullptr, \"Trying to use incomplete particle effect: Drawable missing.\");\n            CS_ASSERT(in_particleEffect->GetEmitterDef() != nullptr, \"Trying to use incomplete particle effect: Emitter missing.\");\n            CS_ASSERT(in_particleEffect->GetLifetimeProperty() != nullptr, \"Trying to use incomplete particle effect: Lifetime property missing.\");\n            CS_ASSERT(in_particleEffect->GetInitialScaleProperty() != nullptr, \"Trying to use incomplete particle effect: Initial scale property missing.\");\n            CS_ASSERT(in_particleEffect->GetInitialRotationProperty() != nullptr, \"Trying to use incomplete particle effect: Initial rotation property missing.\");\n            CS_ASSERT(in_particleEffect->GetInitialColourProperty() != nullptr, \"Trying to use incomplete particle effect: Initial colour property missing.\");\n            CS_ASSERT(in_particleEffect->GetInitialSpeedProperty() != nullptr, \"Trying to use incomplete particle effect: Initial speed property missing.\");\n            CS_ASSERT(in_particleEffect->GetInitialAngularVelocityProperty() != nullptr, \"Trying to use incomplete particle effect: Initial angular velocity property missing.\");\n        }\n        //----------------------------------------------------------------\n        /// Calculates the bounding shapes for the given set of particles.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The particle effect.\n        /// @param The array of particles.\n        /// \n        /// @return a pair containing the AABB and the Bounding Sphere.\n        //----------------------------------------------------------------\n        std::pair<AABB, Sphere> CalculateBoundingShapes(const ParticleEffect* in_particleEffect, const dynamic_array<Particle>* in_particleArray)\n        {\n            Vector3 min = Vector3(std::numeric_limits<f32>::max(), std::numeric_limits<f32>::max(), std::numeric_limits<f32>::max());\n            Vector3 max = Vector3(-std::numeric_limits<f32>::max(), -std::numeric_limits<f32>::max(), -std::numeric_limits<f32>::max());\n\n            bool anyActive = false;\n            for (const auto& particle : *in_particleArray)\n            {\n                if (particle.m_isActive == true)\n                {\n                    anyActive = true;\n\n                    if (particle.m_position.x < min.x)\n                        min.x = particle.m_position.x;\n                    if (particle.m_position.y < min.y)\n                        min.y = particle.m_position.y;\n                    if (particle.m_position.z < min.z)\n                        min.z = particle.m_position.z;\n\n                    if (particle.m_position.x > max.x)\n                        max.x = particle.m_position.x;\n                    if (particle.m_position.y > max.y)\n                        max.y = particle.m_position.y;\n                    if (particle.m_position.z > max.z)\n                        max.z = particle.m_position.z;\n                }\n            }\n\n            if (anyActive == false)\n            {\n                min = Vector3::k_zero;\n                max = Vector3::k_zero;\n            }\n\n            Vector3 size = max - min;\n            Vector3 centre = min + 0.5f * size;\n\n            return std::make_pair(AABB(centre, size), Sphere(centre, size.Length() * 0.5f));\n        }\n        //----------------------------------------------------------------\n        /// Updates the particles on a background thread. This will emit\n        /// new particles, update existing particles and apply particle\n        /// affectors. These changes will then be committed to the \n        /// draw data array to update the next render.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param in_desc - The particle update description. This contains\n        /// a snapshot of all data required to update the particle effect.\n        //----------------------------------------------------------------\n        void ParticleUpdateTask(const ParticleUpdateDesc& in_desc)\n        {\n            CS_ASSERT(in_desc.m_particleEffect != nullptr, \"Cannot update particles with null particle effect.\");\n            CS_ASSERT(in_desc.m_particleArray != nullptr, \"Cannot update particles with null particle array.\");\n            CS_ASSERT(in_desc.m_concurrentParticleData != nullptr, \"Cannot update particles with null concurrent particle data.\");\n\n            //update the particles\n            for (auto& particle : *in_desc.m_particleArray)\n            {\n                if (particle.m_isActive == true)\n                {\n                    particle.m_energy -= in_desc.m_deltaTime;\n                    if (particle.m_energy > 0.0f)\n                    {\n                        particle.m_position += particle.m_velocity * in_desc.m_deltaTime;\n                        particle.m_rotation += particle.m_angularVelocity * in_desc.m_deltaTime;\n                    }\n                    else\n                    {\n                        particle.m_energy = 0.0f;\n                        particle.m_isActive = false;\n                    }\n                }\n            }\n\n            //calculate the normalised playback progress.\n            const f32 effectProgress = in_desc.m_playbackTime / in_desc.m_particleEffect->GetDuration();\n            \n            //apply affectors\n            for (auto& affector : in_desc.m_particleAffectors)\n            {\n                affector->AffectParticles(in_desc.m_deltaTime, effectProgress);\n            }\n\n            //try to emit\n            std::vector<u32> newIndices;\n            if (in_desc.m_particleEmitter != nullptr)\n            {\n                newIndices = in_desc.m_particleEmitter->TryEmit(in_desc.m_playbackTime, in_desc.m_entityPosition, in_desc.m_entityScale, in_desc.m_entityOrientation, in_desc.m_interpolateEmission);\n            }\n\n            //Initialise any new particles in each affector.\n            for (u32 newIndex : newIndices)\n            {\n                for (auto& affector : in_desc.m_particleAffectors)\n                {\n                    affector->ActivateParticle(newIndex, effectProgress);\n                }\n            }\n\n            auto boundingShapes = CalculateBoundingShapes(in_desc.m_particleEffect.get(), in_desc.m_particleArray.get());\n            in_desc.m_concurrentParticleData->CommitParticleData(in_desc.m_particleArray.get(), newIndices, boundingShapes.first, boundingShapes.second);\n        }\n    }\n    CS_DEFINE_NAMEDTYPE(ParticleEffectComponent);\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    ParticleEffectComponent::ParticleEffectComponent(const ParticleEffectCSPtr& in_particleEffect)\n    {\n        SetParticleEffect(in_particleEffect);\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    bool ParticleEffectComponent::IsA(InterfaceIDType in_interfaceId) const\n    {\n        return (VolumeComponent::InterfaceID == in_interfaceId || ParticleEffectComponent::InterfaceID == in_interfaceId);\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    ParticleEffectCSPtr ParticleEffectComponent::GetParticleEffect() const\n    {\n        CS_RELEASE_ASSERT(Application::Get()->GetTaskScheduler()->IsMainThread() == true, \"Can only get the Particle Effect on the main thread.\");\n\n        return m_particleEffect;\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    ParticleEffectComponent::PlaybackType ParticleEffectComponent::GetPlaybackType() const\n    {\n        CS_RELEASE_ASSERT(Application::Get()->GetTaskScheduler()->IsMainThread() == true, \"Can only get the playback type of a particle effect on the main thread.\");\n\n        return m_playbackType;\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    bool ParticleEffectComponent::IsPlaying() const\n    {\n        CS_RELEASE_ASSERT(Application::Get()->GetTaskScheduler()->IsMainThread() == true, \"Can only query whether a particle effect is playing on the main thread.\");\n\n        return (m_playbackState == PlaybackState::k_starting || m_playbackState == PlaybackState::k_playing || m_playbackState == PlaybackState::k_stopping);\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    bool ParticleEffectComponent::IsEmitting() const\n    {\n        CS_RELEASE_ASSERT(Application::Get()->GetTaskScheduler()->IsMainThread() == true, \"Can only query whether a particle effect is emitting on the main thread.\");\n\n        return (m_playbackState == PlaybackState::k_starting || m_playbackState == PlaybackState::k_playing);\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    const AABB& ParticleEffectComponent::GetAABB()\n    {\n        CS_RELEASE_ASSERT(Application::Get()->GetTaskScheduler()->IsMainThread() == true, \"Can only query for particle effect bounding shapes on the main thread.\");\n\n        UpdateWorldBoundingShapes();\n        return mBoundingBox;\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    const OOBB& ParticleEffectComponent::GetOOBB()\n    {\n        CS_RELEASE_ASSERT(Application::Get()->GetTaskScheduler()->IsMainThread() == true, \"Can only query for particle effect bounding shapes on the main thread.\");\n\n        UpdateWorldBoundingShapes();\n        return mOBBoundingBox;\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    const Sphere& ParticleEffectComponent::GetBoundingSphere()\n    {\n        CS_RELEASE_ASSERT(Application::Get()->GetTaskScheduler()->IsMainThread() == true, \"Can only query for particle effect bounding shapes on the main thread.\");\n\n        UpdateWorldBoundingShapes();\n        return mBoundingSphere;\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    void ParticleEffectComponent::SetParticleEffect(const ParticleEffectCSPtr& in_particleEffect)\n    {\n        CS_RELEASE_ASSERT(Application::Get()->GetTaskScheduler()->IsMainThread() == true, \"Particle Effect type must be set on the main thread.\");\n\n        m_particleEffect = in_particleEffect;\n\n        if (GetEntity() != nullptr)\n        {\n            PrepareParticleEffect();\n        }\n\n        m_playbackTimer = 0.0f;\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    void ParticleEffectComponent::SetPlaybackType(PlaybackType in_playbackType)\n    {\n        CS_RELEASE_ASSERT(Application::Get()->GetTaskScheduler()->IsMainThread() == true, \"Play back type must be set on the main thread.\");\n\n        m_playbackType = in_playbackType;\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    void ParticleEffectComponent::Play()\n    {\n        CS_RELEASE_ASSERT(Application::Get()->GetTaskScheduler()->IsMainThread() == true, \"Play must be called on the main thread.\");\n        CS_ASSERT((m_playbackState == PlaybackState::k_notPlaying || m_playbackState == PlaybackState::k_stopping), \"Cannot play a particle effect when it is already playing.\");\n\n        if (m_playbackState == PlaybackState::k_notPlaying)\n        {\n\n            m_playbackState = PlaybackState::k_starting;\n        }\n        else if (m_playbackState == PlaybackState::k_stopping)\n        {\n            m_playbackState = PlaybackState::k_playing;\n        }\n\n        m_playbackTimer = 0.0f;\n        m_accumulatedDeltaTime = 0.0f;\n        m_firstFrame = true;\n\n        //reset the bounding shapes.\n        m_localAABB = AABB();\n        m_localBoundingSphere = Sphere();\n        m_invalidateBoundingShapeCache = true;\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    void ParticleEffectComponent::Stop()\n    {\n        CS_RELEASE_ASSERT(Application::Get()->GetTaskScheduler()->IsMainThread() == true, \"Stop must be called on the main thread.\");\n        CS_ASSERT((m_playbackState == PlaybackState::k_playing || m_playbackState == PlaybackState::k_starting || m_playbackState == PlaybackState::k_stopping), \"Cannot stop a particle effect when it is already stopped.\");\n\n        if (m_playbackState == PlaybackState::k_starting || m_playbackState == PlaybackState::k_playing)\n        {\n            StopEmitting();\n        }\n        m_playbackState = PlaybackState::k_notPlaying;\n        m_finishedEvent.NotifyConnections(this);\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    void ParticleEffectComponent::StopEmitting()\n    {\n        CS_RELEASE_ASSERT(Application::Get()->GetTaskScheduler()->IsMainThread() == true, \"Stop Emitting must be called on the main thread.\");\n        CS_ASSERT((m_playbackState == PlaybackState::k_playing || m_playbackState == PlaybackState::k_starting), \"Cannot stop a particle effect emitting when it is not emitting.\");\n\n        m_playbackTimer = m_particleEffect->GetDuration();\n        m_playbackState = PlaybackState::k_stopping;\n        m_finishedEmittingEvent.NotifyConnections(this);\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    IConnectableEvent<ParticleEffectComponent::Delegate>& ParticleEffectComponent::GetFinishedEvent()\n    {\n        CS_RELEASE_ASSERT(Application::Get()->GetTaskScheduler()->IsMainThread() == true, \"Can only get the Finished Event on the main thread.\");\n\n        return m_finishedEvent;\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    IConnectableEvent<ParticleEffectComponent::Delegate>& ParticleEffectComponent::GetFinishedEmittingEvent()\n    {\n        CS_RELEASE_ASSERT(Application::Get()->GetTaskScheduler()->IsMainThread() == true, \"Can only get the Finished Emitting Event on the main thread.\");\n\n        return m_finishedEmittingEvent;\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    void ParticleEffectComponent::PrepareParticleEffect()\n    {\n        CleanupParticleEffect();\n\n        if (m_particleEffect != nullptr)\n        {\n            ValidateParticleEffect(m_particleEffect);\n\n            m_particleArray = std::make_shared<dynamic_array<Particle>>(m_particleEffect->GetMaxParticles());\n            m_concurrentParticleData = std::make_shared<ConcurrentParticleData>(m_particleEffect->GetMaxParticles());\n\n            m_drawable = m_particleEffect->GetDrawableDef()->CreateInstance(GetEntity(), m_concurrentParticleData.get());\n            CS_ASSERT(m_drawable != nullptr, \"Failed to create particle drawable.\");\n\n            m_emitter = m_particleEffect->GetEmitterDef()->CreateInstance(m_particleArray.get());\n            CS_ASSERT(m_emitter != nullptr, \"Failed to create particle emitter.\");\n\n            const std::vector<const ParticleAffectorDef*> affectorDefs = m_particleEffect->GetAffectorDefs();\n            for (const auto& affectorDef : affectorDefs)\n            {\n                ParticleAffectorSPtr affector = affectorDef->CreateInstance(m_particleArray.get());\n                CS_ASSERT(affector != nullptr, \"Failed to create particle emitter.\");\n\n                m_affectors.push_back(affector);\n            }\n\n            mpMaterial = m_particleEffect->GetDrawableDef()->GetMaterial();\n\n            //reset the bounding shapes.\n            m_localAABB = AABB();\n            m_localBoundingSphere = Sphere();\n            m_invalidateBoundingShapeCache = true;\n        }\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    void ParticleEffectComponent::CleanupParticleEffect()\n    {\n        m_particleArray.reset();\n        m_concurrentParticleData.reset();\n        m_drawable.reset();\n        m_emitter.reset();\n        m_affectors.clear();\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    void ParticleEffectComponent::StoreLocalBoundingShapes()\n    {\n        CS_ASSERT((m_playbackState == PlaybackState::k_playing || m_playbackState == PlaybackState::k_stopping), \"Can only store local bounding shapes when playing or stopping.\");\n\n        m_localAABB = m_concurrentParticleData->GetAABB();\n        m_localBoundingSphere = m_concurrentParticleData->GetBoundingSphere();\n        m_invalidateBoundingShapeCache = true;\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    void ParticleEffectComponent::UpdateWorldBoundingShapes()\n    {\n        CS_ASSERT(GetEntity() != nullptr, \"Cannot get world bounding shapes without being attached to an entity.\");\n\n        if (m_invalidateBoundingShapeCache == true)\n        {\n            if (m_particleEffect != nullptr && m_particleEffect->GetSimulationSpace() == ParticleEffect::SimulationSpace::k_world)\n            {\n                mBoundingBox = m_localAABB;\n                mOBBoundingBox = OOBB(m_localAABB.GetOrigin(), m_localAABB.GetSize());\n                mOBBoundingBox.SetTransform(Matrix4::k_identity);\n                mBoundingSphere = m_localBoundingSphere;\n            }\n            else\n            {\n                const Matrix4& worldMatrix = GetEntity()->GetTransform().GetWorldTransform();\n\n                //OBB is the AABB with the entity transform.\n                mOBBoundingBox = OOBB(m_localAABB.GetOrigin(), m_localAABB.GetSize());\n                mOBBoundingBox.SetTransform(worldMatrix);\n\n                //transform the 8 points of the AABB into world space and recalculate.\n                std::vector<Vector3> points;\n                points.push_back(m_localAABB.BackBottomLeft() * worldMatrix);\n                points.push_back(m_localAABB.BackBottomRight() * worldMatrix);\n                points.push_back(m_localAABB.BackTopLeft() * worldMatrix);\n                points.push_back(m_localAABB.BackTopRight() * worldMatrix);\n                points.push_back(m_localAABB.FrontBottomLeft() * worldMatrix);\n                points.push_back(m_localAABB.FrontBottomRight() * worldMatrix);\n                points.push_back(m_localAABB.FrontTopLeft() * worldMatrix);\n                points.push_back(m_localAABB.FrontTopRight() * worldMatrix);\n\n                Vector3 min = Vector3(std::numeric_limits<f32>::max(), std::numeric_limits<f32>::max(), std::numeric_limits<f32>::max());\n                Vector3 max = Vector3(-std::numeric_limits<f32>::max(), -std::numeric_limits<f32>::max(), -std::numeric_limits<f32>::max());\n                for (auto& point : points)\n                {\n                    if (point.x < min.x)\n                        min.x = point.x;\n                    if (point.y < min.y)\n                        min.y = point.y;\n                    if (point.z < min.z)\n                        min.z = point.z;\n\n                    if (point.x > max.x)\n                        max.x = point.x;\n                    if (point.y > max.y)\n                        max.y = point.y;\n                    if (point.z > max.z)\n                        max.z = point.z;\n                }\n\n                Vector3 size = max - min;\n                Vector3 centre = min + 0.5f * size;\n\n                mBoundingBox = AABB(centre, size);\n\n                //bounding sphere encapsulates the AABB.\n                mBoundingSphere = Sphere(centre, size.Length() * 0.5f);\n            }\n\n            m_invalidateBoundingShapeCache = false;\n        }\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    void ParticleEffectComponent::OnAddedToEntity()\n    {\n        PrepareParticleEffect();\n\n        m_entityTransformConnection = GetEntity()->GetTransform().GetTransformChangedEvent().OpenConnection(MakeDelegate(this, &ParticleEffectComponent::OnEntityTransformChanged));\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    void ParticleEffectComponent::OnAddedToScene()\n    {\n        Play();\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    void ParticleEffectComponent::OnUpdate(f32 in_deltaTime)\n    {\n        if (m_particleEffect != nullptr)\n        {\n            switch (m_playbackState)\n            {\n            case PlaybackState::k_notPlaying:\n                //Do nothing.\n                break;\n            case PlaybackState::k_starting:\n                UpdateStartingState(in_deltaTime);\n                break;\n            case PlaybackState::k_playing:\n                UpdatePlayingState(in_deltaTime);\n                break;\n            case PlaybackState::k_stopping:\n                UpdateStoppingState(in_deltaTime);\n                break;\n            default:\n                CS_LOG_FATAL(\"Invalid playback state.\");\n                break;\n            }\n        }\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    void ParticleEffectComponent::UpdateStartingState(f32 in_deltaTime)\n    {\n        if (m_concurrentParticleData->StartUpdate() == true)\n        {\n            //intialise the particles by disabling them all.\n            for (auto& particle : *m_particleArray)\n            {\n                particle.m_isActive = false;\n            }\n            m_concurrentParticleData->CommitParticleData(m_particleArray.get(), std::vector<u32>(), AABB(), Sphere());\n\n            m_playbackState = PlaybackState::k_playing;\n            UpdatePlayingState(in_deltaTime);\n        }\n        else\n        {\n            m_playbackTimer += in_deltaTime;\n            m_accumulatedDeltaTime += in_deltaTime;\n        }\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    void ParticleEffectComponent::UpdatePlayingState(f32 in_deltaTime)\n    {\n        m_playbackTimer += in_deltaTime;\n\n        //Update the playback timer. If we're not looping and time's up, then stop emitting.\n        if (m_playbackType == PlaybackType::k_once && m_playbackTimer >= m_particleEffect->GetDuration())\n        {\n            StopEmitting();\n            UpdateStoppingState(in_deltaTime);\n            return;\n        }\n        else\n        {\n            while (m_playbackTimer >= m_particleEffect->GetDuration())\n            {\n                m_playbackTimer -= m_particleEffect->GetDuration();\n            }\n        }\n\n        m_accumulatedDeltaTime += in_deltaTime;\n        if (m_concurrentParticleData->StartUpdate() == true)\n        {\n            StoreLocalBoundingShapes();\n\n            ParticleUpdateDesc desc;\n            desc.m_particleEffect = m_particleEffect;\n            desc.m_particleEmitter = m_emitter;\n            desc.m_particleAffectors = m_affectors;\n            desc.m_particleArray = m_particleArray;\n            desc.m_concurrentParticleData = m_concurrentParticleData;\n            desc.m_playbackTime = m_playbackTimer;\n            desc.m_deltaTime = m_accumulatedDeltaTime;\n            desc.m_entityPosition = GetEntity()->GetTransform().GetWorldPosition();\n            desc.m_entityScale = GetEntity()->GetTransform().GetWorldScale();\n            desc.m_entityOrientation = GetEntity()->GetTransform().GetWorldOrientation();\n            desc.m_interpolateEmission = (m_firstFrame == false);\n            Application::Get()->GetTaskScheduler()->ScheduleTask(TaskType::k_small, [=](const TaskContext&) noexcept\n            {\n                ParticleUpdateTask(desc);\n            });\n\n            m_firstFrame = false;\n            m_accumulatedDeltaTime = 0.0f;\n        }\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    void ParticleEffectComponent::UpdateStoppingState(f32 in_deltaTime)\n    {\n        if (m_concurrentParticleData->HasActiveParticles() == false)\n        {\n            Stop();\n        }\n        else\n        {\n            m_accumulatedDeltaTime += in_deltaTime;\n            if (m_concurrentParticleData->StartUpdate() == true)\n            {\n                StoreLocalBoundingShapes();\n\n                ParticleUpdateDesc desc;\n                desc.m_particleEffect = m_particleEffect;\n                desc.m_particleEmitter = nullptr;\n                desc.m_particleAffectors = m_affectors;\n                desc.m_particleArray = m_particleArray;\n                desc.m_concurrentParticleData = m_concurrentParticleData;\n                desc.m_playbackTime = m_playbackTimer;\n                desc.m_deltaTime = m_accumulatedDeltaTime;\n                desc.m_entityPosition = GetEntity()->GetTransform().GetWorldPosition();\n                desc.m_entityScale = GetEntity()->GetTransform().GetWorldScale();\n                desc.m_entityOrientation = GetEntity()->GetTransform().GetWorldOrientation();\n                desc.m_interpolateEmission = (m_firstFrame == false);\n                Application::Get()->GetTaskScheduler()->ScheduleTask(TaskType::k_small, [=](const TaskContext&) noexcept\n                {\n                    ParticleUpdateTask(desc);\n                });\n\n                m_firstFrame = false;\n                m_accumulatedDeltaTime = 0.0f;\n            }\n        }\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    void ParticleEffectComponent::OnRenderSnapshot(RenderSnapshot& renderSnapshot, IAllocator* frameAllocator) noexcept\n    {\n        if (m_particleEffect != nullptr && (m_playbackState == PlaybackState::k_playing || m_playbackState == PlaybackState::k_stopping))\n        {\n            CS_ASSERT(m_drawable != nullptr, \"Cannot render without a drawable.\");\n            \n            m_drawable->Draw(renderSnapshot, frameAllocator);\n        }\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    void ParticleEffectComponent::OnEntityTransformChanged()\n    {\n        m_invalidateBoundingShapeCache = true;\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    void ParticleEffectComponent::OnRemovedFromScene()\n    {\n        if (IsPlaying() == true)\n        {\n            Stop();\n        }\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    void ParticleEffectComponent::OnRemovedFromEntity()\n    {\n        m_entityTransformConnection.reset();\n\n        CleanupParticleEffect();\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Particle/ParticleEffectComponent.h",
    "content": "//\n//  ParticleEffectComponent.h\n//  ChilliSource\n//  Created by Ian Copland on 06/10/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_PARTICLE_PARTICLEEFFECTCOMPONENT_H_\n#define _CHILLISOURCE_RENDERING_PARTICLE_PARTICLEEFFECTCOMPONENT_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Event/Event.h>\n#include <ChilliSource/Core/Volume/VolumeComponent.h>\n#include <ChilliSource/Rendering/Particle/Drawable/ParticleDrawable.h>\n\n#include <atomic>\n#include <functional>\n#include <mutex>\n#include <vector>\n\nnamespace ChilliSource\n{\n    //-----------------------------------------------------------------------\n    /// A component for rendering a single instance of a particle effect.\n    ///\n    /// @author Ian Copland\n    //-----------------------------------------------------------------------\n    class ParticleEffectComponent final : public VolumeComponent\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(ParticleEffectComponent);\n        //----------------------------------------------------------------\n        /// The different possible playback types used to play the particle\n        /// effect.\n        ///\n        /// @author Ian Copland\n        //----------------------------------------------------------------\n        enum class PlaybackType\n        {\n            k_once,\n            k_looping\n        };\n        //----------------------------------------------------------------\n        /// A delegate used for particle related event such as the effect \n        /// completed event.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The particle effect component the event related to.\n        //----------------------------------------------------------------\n        using Delegate = std::function<void(ParticleEffectComponent*)>;\n        //----------------------------------------------------------------\n        /// Constructor. \n        ///\n        /// @author Ian Copland\n        //----------------------------------------------------------------\n        ParticleEffectComponent() = default;\n        //----------------------------------------------------------------\n        /// Constructor. Creates a particle effect component using the \n        /// parameters described in the given particle effect.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The particle effect.\n        //----------------------------------------------------------------\n        ParticleEffectComponent(const ParticleEffectCSPtr& in_particleEffect);\n        //----------------------------------------------------------------\n        /// Allows querying of whether or not this implements the interface\n        /// described by the given Id.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The interface Id.\n        ///\n        /// @return Whether or not the interface is implemented.\n        //----------------------------------------------------------------\n        bool IsA(InterfaceIDType in_interfaceId) const override;\n        //----------------------------------------------------------------\n        /// Returns the current particle effect. \n        ///\n        /// This is not thread-safe and should only be called on the main\n        /// thread.\n        ///\n        /// @author Ian Copland\n        /// \n        /// @return The particle effect.\n        //----------------------------------------------------------------\n        ParticleEffectCSPtr GetParticleEffect() const;\n        //----------------------------------------------------------------\n        /// Returns the current playback type. \n        ///\n        /// This is not thread-safe and should only be called on the main\n        /// thread.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @return The playback type.\n        //----------------------------------------------------------------\n        PlaybackType GetPlaybackType() const;\n        //----------------------------------------------------------------\n        /// Returns whether or not the particle effect is currently playing.\n        /// This will return true if the particle effect is no longer \n        /// emitting but particles are still alive.\n        ///\n        /// This is not thread-safe and should only be called on the main\n        /// thread.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @return Whether or not the particle effect is currently playing.\n        //----------------------------------------------------------------\n        bool IsPlaying() const;\n        //----------------------------------------------------------------\n        /// Returns whether or not the particle effect is currently \n        /// emitting. \n        ///\n        /// This is not thread-safe and should only be called on the main\n        /// thread.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @return whether or not the particle effect is currently \n        /// emitting.\n        //----------------------------------------------------------------\n        bool IsEmitting() const;\n        //----------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The world space AABB of the effect.\n        //----------------------------------------------------------------\n        const AABB& GetAABB() override;\n        //----------------------------------------------------------------\n        /// @author Ian Copland\n        /// \n        /// @return The world space OBB of the effect.\n        //----------------------------------------------------------------\n        const OOBB& GetOOBB() override;\n        //----------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param The world space bounding sphere of the effect.\n        //----------------------------------------------------------------\n        const Sphere& GetBoundingSphere() override;\n        //----------------------------------------------------\n        /// Is Visible\n        ///\n        /// @return Whether or not to render\n        //----------------------------------------------------\n        bool IsVisible() const override { return m_isVisible; }\n        //----------------------------------------------------\n        /// Is Visible\n        ///\n        /// @param in_isVisible - Whether or not to render\n        //----------------------------------------------------\n        void SetVisible(bool in_isVisible) { m_isVisible = in_isVisible; }\n        //----------------------------------------------------------------\n        /// Sets a new particle effect for the component to play. If the\n        /// component was playing, it will start playing the new effect\n        /// from the beginning. Any existing particles will be removed from\n        /// the scene.\n        ///\n        /// This is not thread-safe and should only be called on the main\n        /// thread.\n        /// \n        /// @author Ian Copland\n        ///\n        /// @param The particle effect that this should playback.\n        //----------------------------------------------------------------\n        void SetParticleEffect(const ParticleEffectCSPtr& in_particleEffect);\n        //----------------------------------------------------------------\n        /// Sets the playback mode that should be used when playing this \n        /// particle effect.\n        ///\n        /// This is not thread-safe and should only be called on the main\n        /// thread.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The playback type.\n        //----------------------------------------------------------------\n        void SetPlaybackType(PlaybackType in_playbackType);\n        //----------------------------------------------------------------\n        /// Starts the particle effect playing.\n        ///\n        /// This is not thread-safe and should only be called on the main\n        /// thread.\n        ///\n        /// @author Ian Copland\n        //----------------------------------------------------------------\n        void Play();\n        //----------------------------------------------------------------\n        /// Stops the particle effect playing and removes all existing \n        /// particles.\n        ///\n        /// This is not thread-safe and should only be called on the main\n        /// thread.\n        ///\n        /// @author Ian Copland\n        //----------------------------------------------------------------\n        void Stop();\n        //----------------------------------------------------------------\n        /// Stops the particle effect emitting. Existing particles will \n        /// continue their life cycle. The stopped event will be sent when \n        /// all remaining particles are inactive.\n        ///\n        /// This is not thread-safe and should only be called on the main\n        /// thread.\n        ///\n        /// @author Ian Copland\n        //----------------------------------------------------------------\n        void StopEmitting();\n        //----------------------------------------------------------------\n        /// Returns an event that will be fired when a particle effect\n        /// fully completes, i.e the effect has finished emitting and \n        /// there are no particles left alive.\n        ///\n        /// This is not thread-safe and should only be called on the main\n        /// thread.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @return The event.\n        //----------------------------------------------------------------\n        IConnectableEvent<Delegate>& GetFinishedEvent();\n        //----------------------------------------------------------------\n        /// Returns an event that will be fired when the particle effect\n        /// finishes emitting. Particles may still be alive when this event\n        /// is called.\n        ///\n        /// This is not thread-safe and should only be called on the main\n        /// thread.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @return The event.\n        //----------------------------------------------------------------\n        IConnectableEvent<Delegate>& GetFinishedEmittingEvent();\n        //----------------------------------------------------------------\n        /// Destructor\n        ///\n        /// @author Ian Copland\n        //----------------------------------------------------------------\n        ~ParticleEffectComponent() {};\n    private:\n        //----------------------------------------------------------------\n        /// An enum describing the current playback state of the particle\n        /// effect.\n        ///\n        /// @author Ian Copland\n        //----------------------------------------------------------------\n        enum class PlaybackState\n        {\n            k_notPlaying,\n            k_starting,\n            k_playing,\n            k_stopping\n        };\n        //----------------------------------------------------------------\n        /// Sets up the particle effect, ready to be played.\n        ///\n        /// @author Ian Copland\n        //----------------------------------------------------------------\n        void PrepareParticleEffect();\n        //----------------------------------------------------------------\n        /// Cleans up the particle effect, deleting all particles.\n        ///\n        /// @author Ian Copland\n        //----------------------------------------------------------------\n        void CleanupParticleEffect();\n        //----------------------------------------------------------------\n        /// Takes the calculated local bounds of the particle effect and\n        /// stores them for later calculating the world bounds.\n        ///\n        /// @author Ian Copland\n        //----------------------------------------------------------------\n        void StoreLocalBoundingShapes();\n        //----------------------------------------------------------------\n        /// Re-calculates the world space bounding shapes if the bounding \n        /// shape cache has been invalidated.\n        ///\n        /// @author Ian Copland\n        //----------------------------------------------------------------\n        void UpdateWorldBoundingShapes();\n        //----------------------------------------------------------------\n        /// Called when this is added to an entity.\n        ///\n        /// @author Ian Copland\n        //----------------------------------------------------------------\n        void OnAddedToEntity() override;\n        //----------------------------------------------------------------\n        /// Called either when this is added to an entity that is already \n        /// in the scene, or when the entity this is already added to is \n        /// added to the scene. This will start the effect playing.\n        ///\n        /// @author Ian Copland\n        //----------------------------------------------------------------\n        void OnAddedToScene() override;\n        //----------------------------------------------------------------\n        /// Called every frame the particle effect is in the scene. This\n        /// will update depending on the current playback state of the\n        /// effect.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The delta time.\n        //----------------------------------------------------------------\n        void OnUpdate(f32 in_deltaTime) override;\n        //----------------------------------------------------------------\n        /// Updates while the particle effect is starting. This will wait\n        /// until an appropriate time to send a background task to initialise \n        /// the particles and start updating.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The delta time.\n        //----------------------------------------------------------------\n        void UpdateStartingState(f32 in_deltaTime);\n        //----------------------------------------------------------------\n        /// This will fire off a new particle update background task.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The delta time.\n        //----------------------------------------------------------------\n        void UpdatePlayingState(f32 in_deltaTime);\n        //----------------------------------------------------------------\n        /// This waits for all activate particles effects to finish then\n        /// will end the effect.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The delta time.\n        //----------------------------------------------------------------\n        void UpdateStoppingState(f32 in_deltaTime);\n        //----------------------------------------------------------------\n        /// Called during the render snapshot phase of the render pipeline\n        /// to acquire all render primitives in the scene. This adds new\n        /// render objects for each a particle in the effect.\n        ///\n        /// @param renderSnapshot - Add anything to this that must be\n        ///     captured for this frame\n        /// @param frameAllocator - Allocate any memory for this frame from here\n        ///\n        /// @author Ian Copland\n        //----------------------------------------------------------------\n        void OnRenderSnapshot(RenderSnapshot& renderSnapshot, IAllocator* frameAllocator) noexcept override;\n        //----------------------------------------------------------------\n        /// Called when the entities transform changes. This invalidates\n        /// the bounding shape cache.\n        ///\n        /// @author Ian Copland\n        //----------------------------------------------------------------\n        void OnEntityTransformChanged();\n        //----------------------------------------------------------------\n        /// Called either when this is removed from an entity that is\n        /// attached to the scene or when an entity this is attached to is \n        /// removed from the scene. This will stop the particle effect \n        /// playing and reset all active particles.\n        ///\n        /// @author Ian Copland\n        //----------------------------------------------------------------\n        void OnRemovedFromScene() override;\n        //----------------------------------------------------------------\n        /// Called when this is removed from an entity.\n        ///\n        /// @author Ian Copland\n        //----------------------------------------------------------------\n        void OnRemovedFromEntity() override;\n\n        ParticleEffectCSPtr m_particleEffect;\n        ParticleDrawableUPtr m_drawable;\n        ParticleEmitterSPtr m_emitter;\n        std::vector<ParticleAffectorSPtr> m_affectors;\n        std::shared_ptr<dynamic_array<Particle>> m_particleArray;\n        ConcurrentParticleDataSPtr m_concurrentParticleData;\n\n        PlaybackType m_playbackType = PlaybackType::k_once;\n        PlaybackState m_playbackState = PlaybackState::k_notPlaying;\n        f32 m_playbackTimer = 0.0f;\n        f32 m_accumulatedDeltaTime = 0.0f;\n        Event<Delegate> m_finishedEvent;\n        Event<Delegate> m_finishedEmittingEvent;\n        bool m_firstFrame = false;\n\n        AABB m_localAABB;\n        Sphere m_localBoundingSphere;\n        bool m_invalidateBoundingShapeCache = true;\n        EventConnectionUPtr m_entityTransformConnection;\n        \n        AABB mBoundingBox;\n        OOBB mOBBoundingBox;\n        Sphere mBoundingSphere;\n        MaterialCSPtr mpMaterial;\n        bool m_isVisible = true;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Particle/Property/ComponentwiseRandomConstantParticleProperty.h",
    "content": "//\n//  ComponentwiseRandomConstantParticleProperty.h\n//  ChilliSource\n//  Created by Ian Copland on 29/12/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_PARTICLE_PROPERTY_COMPONENTWISERANDOMCONSTANTPARTICLEPROPERTY_H_\n#define _CHILLISOURCE_RENDERING_PARTICLE_PROPERTY_COMPONENTWISERANDOMCONSTANTPARTICLEPROPERTY_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Math/Random.h>\n#include <ChilliSource/Rendering/Particle/Property/ParticleProperty.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    /// A particle property for getting a random value between the given lower and\n    /// upper value. If the value has multiple components (i.e Vector2, Matrix4,\n    /// Colour, etc) then each component will be randomised individually.\n    ///\n    /// @author Ian Copland\n    //------------------------------------------------------------------------------\n    template <typename TPropertyType> class ComponentwiseRandomConstantParticleProperty final : public ParticleProperty<TPropertyType>\n    {\n    public:\n        //------------------------------------------------------------------------------\n        /// Constructor.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The lower value.\n        /// @param The upper value.\n        //------------------------------------------------------------------------------\n        ComponentwiseRandomConstantParticleProperty(TPropertyType in_lowerValue, TPropertyType in_upperValue);\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param The normalised (0.0 - 1.0) particle effect playback progress. This is\n        /// ignored for a random property.\n        ///\n        /// @return a random value between the lower and upper values the property was\n        /// created with.\n        //------------------------------------------------------------------------------\n        TPropertyType GenerateValue(f32 in_playbackProgress) const override;\n        \n    private:\n        TPropertyType m_lowerValue;\n        TPropertyType m_upperValue;\n    };\n    \n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    template <typename TPropertyType> ComponentwiseRandomConstantParticleProperty<TPropertyType>::ComponentwiseRandomConstantParticleProperty(TPropertyType in_lowerValue, TPropertyType in_upperValue)\n        : m_lowerValue(in_lowerValue), m_upperValue(in_upperValue)\n    {\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    template <typename TPropertyType> TPropertyType ComponentwiseRandomConstantParticleProperty<TPropertyType>::GenerateValue(f32 in_playbackProgress) const\n    {\n        return Random::GenerateComponentwise(m_lowerValue, m_upperValue);\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Particle/Property/ComponentwiseRandomCurveParticleProperty.h",
    "content": "//\n//  ComponentwiseRandomCurveParticleProperty.h\n//  ChilliSource\n//  Created by Ian Copland on 29/12/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_PARTICLE_PROPERTY_COMPONENTWISERANDOMCURVEPARTICLEPROPERTY_H_\n#define _CHILLISOURCE_RENDERING_PARTICLE_PROPERTY_COMPONENTWISERANDOMCURVEPARTICLEPROPERTY_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Math/Random.h>\n#include <ChilliSource/Rendering/Particle/Property/ParticleProperty.h>\n\n#include <functional>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    /// A particle property describing a value which is randomly generated between\n    /// bounds. The bounds changes over the lifetime of the particle effect. The\n    /// curve function is described by a delegate provided in the constructor.\n    ///\n    /// @author Ian Copland\n    //------------------------------------------------------------------------------\n    template <typename TPropertyType> class ComponentwiseRandomCurveParticleProperty final : public ParticleProperty<TPropertyType>\n    {\n    public:\n        //------------------------------------------------------------------------------\n        /// A delegate for a function which describes the curve. This must accept values\n        /// in the range 0.0 - 1.0 and output values in the range 0.0 - 1.0.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The current normalised (0.0 - 1.0) particle effect progress.\n        ///\n        /// @return The interpolation factor.\n        //------------------------------------------------------------------------------\n        using CurveFunction = std::function<f32(f32)>;\n        //------------------------------------------------------------------------------\n        /// Constructor.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The start lower value.\n        /// @param The start upper value.\n        /// @param The end lower value.\n        /// @param The end upper value.\n        /// @param The curve function.\n        //------------------------------------------------------------------------------\n        ComponentwiseRandomCurveParticleProperty(TPropertyType in_startLowerValue, TPropertyType in_startUpperValue, TPropertyType in_endLowerValue, TPropertyType in_endUpperValue, const CurveFunction& in_curveFunction);\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param The normalised (0.0 - 1.0) particle effect playback progress.\n        ///\n        /// @return The generated value.\n        //------------------------------------------------------------------------------\n        TPropertyType GenerateValue(f32 in_playbackProgress) const override;\n        \n    private:\n        TPropertyType m_startLowerValue;\n        TPropertyType m_startUpperValue;\n        TPropertyType m_endLowerValue;\n        TPropertyType m_endUpperValue;\n        CurveFunction m_curveFunction;\n    };\n    \n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    template <typename TPropertyType> ComponentwiseRandomCurveParticleProperty<TPropertyType>::ComponentwiseRandomCurveParticleProperty(TPropertyType in_startLowerValue, TPropertyType in_startUpperValue, TPropertyType in_endLowerValue,\n                                                                                                              TPropertyType in_endUpperValue, const CurveFunction& in_curveFunction)\n    : m_startLowerValue(in_startLowerValue), m_startUpperValue(in_startUpperValue), m_endLowerValue(in_endLowerValue), m_endUpperValue(in_endUpperValue), m_curveFunction(in_curveFunction)\n    {\n        CS_ASSERT(m_curveFunction != nullptr, \"A curve function must be provided.\");\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    template <typename TPropertyType> TPropertyType ComponentwiseRandomCurveParticleProperty<TPropertyType>::GenerateValue(f32 in_playbackProgress) const\n    {\n        CS_ASSERT(in_playbackProgress >= 0.0f && in_playbackProgress <= 1.0f, \"Playback progress must be in the range 0.0 to 1.0.\");\n        \n        f32 interpolationFactor = m_curveFunction(in_playbackProgress);\n        \n        TPropertyType lowerBound = TPropertyType(m_startLowerValue + (m_endLowerValue - m_startLowerValue) * interpolationFactor);\n        TPropertyType upperBound = TPropertyType(m_startUpperValue + (m_endUpperValue - m_startUpperValue) * interpolationFactor);\n        \n        return Random::GenerateComponentwise(lowerBound, upperBound);\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Particle/Property/ConstantParticleProperty.h",
    "content": "//\n//  ConstantParticleProperty.h\n//  ChilliSource\n//  Created by Ian Copland on 06/10/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_PARTICLE_PROPERTY_CONSTANTPARTICLEPROPERTY_H_\n#define _CHILLISOURCE_RENDERING_PARTICLE_PROPERTY_CONSTANTPARTICLEPROPERTY_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Rendering/Particle/Property/ParticleProperty.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    /// A simple particle property for containing a value that remains constant over\n    /// the lifetime of a particle effect.\n    ///\n    /// @author Ian Copland\n    //------------------------------------------------------------------------------\n    template <typename TPropertyType> class ConstantParticleProperty final : public ParticleProperty<TPropertyType>\n    {\n    public:\n        //------------------------------------------------------------------------------\n        /// Constructor.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The static value.\n        //------------------------------------------------------------------------------\n        ConstantParticleProperty(TPropertyType in_value);\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param The normalised (0.0 - 1.0) particle effect playback progress.\n        ///\n        /// @return simply returns the static value.\n        //------------------------------------------------------------------------------\n        TPropertyType GenerateValue(f32 in_playbackProgress) const override;\n        \n    private:\n        TPropertyType m_value;\n    };\n    \n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    template <typename TPropertyType> ConstantParticleProperty<TPropertyType>::ConstantParticleProperty(TPropertyType in_value)\n        : m_value(in_value)\n    {\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    template <typename TPropertyType> TPropertyType ConstantParticleProperty<TPropertyType>::GenerateValue(f32 in_playbackProgress) const\n    {\n        return m_value;\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Particle/Property/CurveParticleProperty.h",
    "content": "//\n//  CurveParticleProperty.h\n//  ChilliSource\n//  Created by Ian Copland on 29/12/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_PARTICLE_PROPERTY_CURVEPARTICLEPROPERTY_H_\n#define _CHILLISOURCE_RENDERING_PARTICLE_PROPERTY_CURVEPARTICLEPROPERTY_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Rendering/Particle/Property/ParticleProperty.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    /// A particle property describing a value which changes over the lifetime of\n    /// the particle effect. The curve function is described by a delegate provided\n    /// in the constructor.\n    ///\n    /// @author Ian Copland\n    //------------------------------------------------------------------------------\n    template <typename TPropertyType> class CurveParticleProperty final : public ParticleProperty<TPropertyType>\n    {\n    public:\n        //------------------------------------------------------------------------------\n        /// A delegate for a function which describes the curve. This must accept values\n        /// in the range 0.0 - 1.0 and output values in the range 0.0 - 1.0.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The current normalised (0.0 - 1.0) particle effect progress.\n        ///\n        /// @return The interpolation factor.\n        //------------------------------------------------------------------------------\n        using CurveFunction = std::function<f32(f32)>;\n        //------------------------------------------------------------------------------\n        /// Constructor.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The start value.\n        /// @param The end value.\n        /// @param The curve function.\n        //------------------------------------------------------------------------------\n        CurveParticleProperty(TPropertyType in_startValue, TPropertyType in_endValue, const CurveFunction& in_curveFunction);\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param The normalised (0.0 - 1.0) particle effect playback progress.\n        ///\n        /// @return The generated value.\n        //------------------------------------------------------------------------------\n        TPropertyType GenerateValue(f32 in_playbackProgress) const override;\n        \n    private:\n        TPropertyType m_startValue;\n        TPropertyType m_endValue;\n        CurveFunction m_curveFunction;\n    };\n    \n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    template <typename TPropertyType> CurveParticleProperty<TPropertyType>::CurveParticleProperty(TPropertyType in_startValue, TPropertyType in_endValue, const CurveFunction& in_curveFunction)\n        : m_startValue(in_startValue), m_endValue(in_endValue), m_curveFunction(in_curveFunction)\n    {\n        CS_ASSERT(m_curveFunction != nullptr, \"A curve function must be provided.\");\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    template <typename TPropertyType> TPropertyType CurveParticleProperty<TPropertyType>::GenerateValue(f32 in_playbackProgress) const\n    {\n        CS_ASSERT(in_playbackProgress >= 0.0f && in_playbackProgress <= 1.0f, \"Playback progress must be in the range 0.0 to 1.0.\");\n        \n        f32 interpolationFactor = m_curveFunction(in_playbackProgress);\n        \n        return TPropertyType(m_startValue + (m_endValue - m_startValue) * interpolationFactor);\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Particle/Property/ParticleProperty.h",
    "content": "//\n//  ParticleProperty.h\n//  ChilliSource\n//  Created by Ian Copland on 06/10/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_PARTICLE_PROPERTY_PARTICLEPROPERTY_H_\n#define _CHILLISOURCE_RENDERING_PARTICLE_PROPERTY_PARTICLEPROPERTY_H_\n\n#include <ChilliSource/ChilliSource.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    /// A base class for different particle property types. This allows properties\n    /// more complex than just a single value, for example a property that selects a\n    /// random value within a certain range, or that changes over the life of the\n    /// particle effect.\n    ///\n    /// The documentation for Particle Property Factory describes the various types\n    /// of particle property that can be created.\n    ///\n    /// @author Ian Copland\n    //------------------------------------------------------------------------------\n    template <typename TPropertyType> class ParticleProperty\n    {\n    public:\n        //------------------------------------------------------------------------------\n        /// Generates a new value within the confines of the property's settings.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The normalised (0.0 - 1.0) particle effect playback progress.\n        ///\n        /// @return The generated value.\n        //------------------------------------------------------------------------------\n        virtual TPropertyType GenerateValue(f32 in_playbackProgress) const = 0;\n        //------------------------------------------------------------------------------\n        /// Destructor.\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------------------------------------\n        virtual ~ParticleProperty() {};\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Particle/Property/ParticlePropertyFactory.h",
    "content": "//\n//  ParticlePropertyFactory.h\n//  ChilliSource\n//  Created by Ian Copland on 04/11/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_PARTICLE_PROPERTY_PARTICLEPROPERTYFACTORY_H_\n#define _CHILLISOURCE_RENDERING_PARTICLE_PROPERTY_PARTICLEPROPERTYFACTORY_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/String/StringUtils.h>\n\n#include <json/json.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    /// A collection of methods for creating particle properties.\n    ///\n    /// @author Ian Copland\n    //------------------------------------------------------------------------------\n    namespace ParticlePropertyFactory\n    {\n        //------------------------------------------------------------------------------\n        /// Creates a new particle property for the type described in the template\n        /// parameter from the given json.\n        ///\n        /// The following are the different types of particle property:\n        ///\n        /// \"Constant\": A simple constant value. If the given JSON is just a string\n        /// as opposed to a json object the type is assumed to be a constant. This takes\n        /// only one parameter: 'Value'.\n        ///\n        /// \"RandomConstant\": A random value between two bounds. The bounds remain\n        /// constant over the life of the particle effect. This takes two arguments:\n        /// 'LowerValue' and 'UpperValue'.\n        ///\n        /// \"ComponentwiseRandomConstant\": A random value between two bounds. The bounds\n        /// remain constant over the life of the particle effect. If the value is\n        /// comprised of multiple components (i.e Vector3, Matrix4, Colour, etc) each is\n        /// randomised separately. This takes two arguments: 'LowerValue' and\n        /// 'UpperValue'.\n        ///\n        /// \"Curve\": A value that changes over the life time of the particle effect.\n        /// Different curve types can be supplied to describe how the start and end\n        /// values are interpolated. This takes three arguments: 'Curve', 'StartValue'\n        /// and 'EndValue'.\n        ///\n        /// \"RandomCurve\": A random value between two bounds. The bounds change over the\n        /// lifetime of the particle effect. Different curve types can be supplied to\n        /// describe how the start and end values are interpolated. This takes five\n        /// arguments: 'Curve', 'StartLowerValue', 'StartUpperValue', 'EndLowerValue'\n        /// and 'EndUpperValue'.\n        ///\n        /// \"ComponentwiseRandomCurve\": A random value between two bounds. The bounds\n        /// change over the lifetime of the particle effect. Different curve types can\n        /// be supplied to describe how the start and end values are interpolated. If\n        /// the value is comprised of multiple components (i.e Vector3, Matrix4, Colour,\n        /// etc) each is randomised separately. This takes five arguments: 'Curve',\n        /// 'StartLowerValue', 'StartUpperValue', 'EndLowerValue' and 'EndUpperValue'.\n        ///\n        /// The following are the different curve types available:\n        ///\n        /// \"Linear\"\n        /// \"EaseInQuad\"\n        /// \"EaseOutQuad\"\n        /// \"SmoothStep\"\n        /// \"LinearPingPong\"\n        /// \"EaseInQuadPingPong\"\n        /// \"EaseOutQuadPingPong\"\n        /// \"SmoothStepPingPong\"\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The json value.\n        ///\n        /// @return The output particle property.\n        //------------------------------------------------------------------------------\n        template <typename TType> ParticlePropertyUPtr<TType> CreateProperty(const Json::Value& in_json);\n    }\n}\n\n#include <ChilliSource/Rendering/Particle/Property/ParticlePropertyFactoryImpl.h>\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Particle/Property/ParticlePropertyFactoryImpl.cpp",
    "content": "//\n//  ParticlePropertyFactory.cpp\n//  ChilliSource\n//  Created by Ian Copland on 04/11/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Particle/Property/ParticlePropertyFactory.h>\n\n#include <ChilliSource/Core/Delegate/MakeDelegate.h>\n#include <ChilliSource/Core/String/StringParser.h>\n\nnamespace ChilliSource\n{\n    namespace ParticlePropertyFactory\n    {\n        namespace Impl\n        {\n            //------------------------------------------------------------------------------\n            //------------------------------------------------------------------------------\n            template <> u32 ParseValue(const std::string& in_value)\n            {\n                return ParseU32(in_value);\n            }\n            //------------------------------------------------------------------------------\n            //------------------------------------------------------------------------------\n            template <> s32 ParseValue(const std::string& in_value)\n            {\n                return ParseS32(in_value);\n            }\n            //------------------------------------------------------------------------------\n            //------------------------------------------------------------------------------\n            template <> u64 ParseValue(const std::string& in_value)\n            {\n                return ParseU64(in_value);\n            }\n            //------------------------------------------------------------------------------\n            //------------------------------------------------------------------------------\n            template <> s64 ParseValue(const std::string& in_value)\n            {\n                return ParseS64(in_value);\n            }\n            //------------------------------------------------------------------------------\n            //------------------------------------------------------------------------------\n            template <> f32 ParseValue(const std::string& in_value)\n            {\n                return ParseF32(in_value);\n            }\n            //------------------------------------------------------------------------------\n            //------------------------------------------------------------------------------\n            template <> Vector2 ParseValue(const std::string& in_value)\n            {\n                return ParseVector2(in_value);\n            }\n            //------------------------------------------------------------------------------\n            //------------------------------------------------------------------------------\n            template <> Vector3 ParseValue(const std::string& in_value)\n            {\n                return ParseVector3(in_value);\n            }\n            //------------------------------------------------------------------------------\n            //------------------------------------------------------------------------------\n            template <> Vector4 ParseValue(const std::string& in_value)\n            {\n                return ParseVector4(in_value);\n            }\n            //------------------------------------------------------------------------------\n            //------------------------------------------------------------------------------\n            template <> Matrix3 ParseValue(const std::string& in_value)\n            {\n                return ParseMatrix3(in_value);\n            }\n            //------------------------------------------------------------------------------\n            //------------------------------------------------------------------------------\n            template <> Matrix4 ParseValue(const std::string& in_value)\n            {\n                return ParseMatrix4(in_value);\n            }\n            //------------------------------------------------------------------------------\n            //------------------------------------------------------------------------------\n            template <> Quaternion ParseValue(const std::string& in_value)\n            {\n                return ParseQuaternion(in_value);\n            }\n            //------------------------------------------------------------------------------\n            //------------------------------------------------------------------------------\n            template <> Colour ParseValue(const std::string& in_value)\n            {\n                return ParseColour(in_value);\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Particle/Property/ParticlePropertyFactoryImpl.h",
    "content": "//\n//  ParticlePropertyFactoryImpl.h\n//  ChilliSource\n//  Created by Ian Copland on 29/12/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_PARTICLE_PROPERTY_PARTICLEPROPERTYFACTORYIMPL_H_\n#define _CHILLISOURCE_RENDERING_PARTICLE_PROPERTY_PARTICLEPROPERTYFACTORYIMPL_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Math/Interpolate.h>\n#include <ChilliSource/Core/String/StringUtils.h>\n#include <ChilliSource/Rendering/Particle/Property/ComponentwiseRandomConstantParticleProperty.h>\n#include <ChilliSource/Rendering/Particle/Property/ComponentwiseRandomCurveParticleProperty.h>\n#include <ChilliSource/Rendering/Particle/Property/ConstantParticleProperty.h>\n#include <ChilliSource/Rendering/Particle/Property/CurveParticleProperty.h>\n#include <ChilliSource/Rendering/Particle/Property/RandomConstantParticleProperty.h>\n#include <ChilliSource/Rendering/Particle/Property/RandomCurveParticleProperty.h>\n\n#include <json/json.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    /// A collection of implementation functions for the particle property factory.\n    /// These should not be accessed directly, the particle effect factory functions\n    /// should be called instead.\n    ///\n    /// @author Ian Copland\n    //------------------------------------------------------------------------------\n    namespace ParticlePropertyFactory\n    {\n        namespace Impl\n        {\n            static const char k_constantType[] = \"constant\";\n            static const char k_randomConstantType[] = \"randomconstant\";\n            static const char k_componentwiseRandomConstantType[] = \"componentwiserandomconstant\";\n            static const char k_curveType[] = \"curve\";\n            static const char k_randomCurveType[] = \"randomcurve\";\n            static const char k_componentwiseRandomCurveType[] = \"componentwiserandomcurve\";\n            \n            static const char k_typeKey[] = \"Type\";\n            static const char k_valueKey[] = \"Value\";\n            static const char k_lowerValueKey[] = \"LowerValue\";\n            static const char k_upperValueKey[] = \"UpperValue\";\n            static const char k_startValueKey[] = \"StartValue\";\n            static const char k_endValueKey[] = \"EndValue\";\n            static const char k_startLowerValueKey[] = \"StartLowerValue\";\n            static const char k_startUpperValueKey[] = \"StartUpperValue\";\n            static const char k_endLowerValueKey[] = \"EndLowerValue\";\n            static const char k_endUpperValueKey[] = \"EndUpperValue\";\n            static const char k_curveKey[] = \"Curve\";\n            \n            //------------------------------------------------------------------------------\n            /// A templated method for parsing values from a string.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param The string to parse.\n            ///\n            /// @return The parsed value.\n            //------------------------------------------------------------------------------\n            template <typename TType> TType ParseValue(const std::string& in_value)\n            {\n                CS_LOG_FATAL(\"Cannot parse value of this type.\");\n            }\n            //------------------------------------------------------------------------------\n            /// Creates a new constant particle property with the value described in the\n            /// given string.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param The string value.\n            ///\n            /// @return The output particle property.\n            //------------------------------------------------------------------------------\n            template <typename TType> ParticlePropertyUPtr<TType> CreateConstantProperty(const std::string& in_string)\n            {\n                return ParticlePropertyUPtr<TType>(new ConstantParticleProperty<TType>(ParseValue<TType>(in_string)));\n            }\n            //------------------------------------------------------------------------------\n            /// Creates a new constant particle property with value described in the given\n            /// json.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param The json value.\n            ///\n            /// @return The output particle property.\n            //------------------------------------------------------------------------------\n            template <typename TType> ParticlePropertyUPtr<TType> CreateConstantProperty(const Json::Value& in_json)\n            {\n                Json::Value value = in_json.get(k_valueKey, Json::nullValue);\n                CS_ASSERT(value != Json::nullValue, \"Must supply '\" + std::string(k_valueKey) + \"' in '\" + std::string(k_constantType) + \"' property.\");\n                CS_ASSERT(value.isString(), \"'\" + std::string(k_valueKey) + \"' in '\" + std::string(k_constantType) + \"' property must be a string.\");\n                \n                return ParticlePropertyUPtr<TType>(new ConstantParticleProperty<TType>(ParseValue<TType>(value.asString())));\n            }\n            //------------------------------------------------------------------------------\n            /// Creates a new random constant particle property with the value described in\n            /// the given json.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param The json value.\n            ///\n            /// @return The output particle property.\n            //------------------------------------------------------------------------------\n            template <typename TType> ParticlePropertyUPtr<TType> CreateRandomConstantProperty(const Json::Value& in_json)\n            {\n                Json::Value lowerValue = in_json.get(k_lowerValueKey, Json::nullValue);\n                CS_ASSERT(lowerValue != Json::nullValue, \"Must supply '\" + std::string(k_lowerValueKey) + \"' in '\" + std::string(k_randomConstantType) + \"' property.\");\n                CS_ASSERT(lowerValue.isString(), \"'\" + std::string(k_lowerValueKey) + \"' in '\" + std::string(k_randomConstantType) + \"' property must be a string.\");\n                \n                Json::Value upperValue = in_json.get(k_upperValueKey, Json::nullValue);\n                CS_ASSERT(upperValue != Json::nullValue, \"Must supply '\" + std::string(k_upperValueKey) + \"' in '\" + std::string(k_randomConstantType) + \"' property.\");\n                CS_ASSERT(upperValue.isString(), \"'\" + std::string(k_upperValueKey) + \"' in '\" + std::string(k_randomConstantType) + \"' property must be a string.\");\n                \n                return ParticlePropertyUPtr<TType>(new RandomConstantParticleProperty<TType>(ParseValue<TType>(lowerValue.asString()), ParseValue<TType>(upperValue.asString())));\n            }\n            //------------------------------------------------------------------------------\n            /// Creates a new componentwise random constant particle property with the value\n            /// described in the given json.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param The json value.\n            ///\n            /// @return The output particle property.\n            //------------------------------------------------------------------------------\n            template <typename TType> ParticlePropertyUPtr<TType> CreateComponentwiseRandomConstantProperty(const Json::Value& in_json)\n            {\n                Json::Value lowerValue = in_json.get(k_lowerValueKey, Json::nullValue);\n                CS_ASSERT(lowerValue != Json::nullValue, \"Must supply '\" + std::string(k_lowerValueKey) + \"' in '\" + std::string(k_componentwiseRandomConstantType) + \"' property.\");\n                CS_ASSERT(lowerValue.isString(), \"'\" + std::string(k_lowerValueKey) + \"' in '\" + std::string(k_componentwiseRandomConstantType) + \"' property must be a string.\");\n                \n                Json::Value upperValue = in_json.get(k_upperValueKey, Json::nullValue);\n                CS_ASSERT(upperValue != Json::nullValue, \"Must supply '\" + std::string(k_upperValueKey) + \"' in '\" + std::string(k_componentwiseRandomConstantType) + \"' property.\");\n                CS_ASSERT(upperValue.isString(), \"'\" + std::string(k_upperValueKey) + \"' in '\" + std::string(k_componentwiseRandomConstantType) + \"' property must be a string.\");\n                \n                return ParticlePropertyUPtr<TType>(new ComponentwiseRandomConstantParticleProperty<TType>(ParseValue<TType>(lowerValue.asString()), ParseValue<TType>(upperValue.asString())));\n            }\n            //------------------------------------------------------------------------------\n            /// Creates a new curve particle property with the value described in the given\n            /// json.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param The json value.\n            ///\n            /// @return The output particle property.\n            //------------------------------------------------------------------------------\n            template <typename TType> ParticlePropertyUPtr<TType> CreateCurveProperty(const Json::Value& in_json)\n            {\n                Json::Value curve = in_json.get(k_curveKey, Json::nullValue);\n                CS_ASSERT(curve != Json::nullValue, \"Must supply '\" + std::string(k_curveKey) + \"' in '\" + std::string(k_curveType) + \"' property.\");\n                CS_ASSERT(curve.isString(), \"'\" + std::string(k_curveKey) + \"' in '\" + std::string(k_curveType) + \"' property must be a string.\");\n                \n                Json::Value startValue = in_json.get(k_startValueKey, Json::nullValue);\n                CS_ASSERT(startValue != Json::nullValue, \"Must supply '\" + std::string(k_startValueKey) + \"' in '\" + std::string(k_curveType) + \"' property.\");\n                CS_ASSERT(startValue.isString(), \"'\" + std::string(k_startValueKey) + \"' in '\" + std::string(k_curveType) + \"' property must be a string.\");\n                \n                Json::Value endValue = in_json.get(k_endValueKey, Json::nullValue);\n                CS_ASSERT(endValue != Json::nullValue, \"Must supply '\" + std::string(k_endValueKey) + \"' in '\" + std::string(k_curveType) + \"' property.\");\n                CS_ASSERT(endValue.isString(), \"'\" + std::string(k_endValueKey) + \"' in '\" + std::string(k_curveType) + \"' property must be a string.\");\n                \n                return ParticlePropertyUPtr<TType>(new CurveParticleProperty<TType>(ParseValue<TType>(startValue.asString()), ParseValue<TType>(endValue.asString()), Interpolate::GetInterpolateFunction(curve.asString())));\n            }\n            //------------------------------------------------------------------------------\n            /// Creates a new random curve particle property with the value described in the\n            /// given json.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param The json value.\n            ///\n            /// @return The output particle property.\n            //------------------------------------------------------------------------------\n            template <typename TType> ParticlePropertyUPtr<TType> CreateRandomCurveProperty(const Json::Value& in_json)\n            {\n                Json::Value curve = in_json.get(k_curveKey, Json::nullValue);\n                CS_ASSERT(curve != Json::nullValue, \"Must supply '\" + std::string(k_curveKey) + \"' in '\" + std::string(k_randomCurveType) + \"' property.\");\n                CS_ASSERT(curve.isString(), \"'\" + std::string(k_curveKey) + \"' in '\" + std::string(k_randomCurveType) + \"' property must be a string.\");\n                \n                Json::Value startLowerValue = in_json.get(k_startLowerValueKey, Json::nullValue);\n                CS_ASSERT(startLowerValue != Json::nullValue, \"Must supply '\" + std::string(k_startLowerValueKey) + \"' in '\" + std::string(k_randomCurveType) + \"' property.\");\n                CS_ASSERT(startLowerValue.isString(), \"'\" + std::string(k_startLowerValueKey) + \"' in '\" + std::string(k_randomCurveType) + \"' property must be a string.\");\n                \n                Json::Value startUpperValue = in_json.get(k_startUpperValueKey, Json::nullValue);\n                CS_ASSERT(startUpperValue != Json::nullValue, \"Must supply '\" + std::string(k_startUpperValueKey) + \"' in '\" + std::string(k_randomCurveType) + \"' property.\");\n                CS_ASSERT(startUpperValue.isString(), \"'\" + std::string(k_startUpperValueKey) + \"' in '\" + std::string(k_randomCurveType) + \"' property must be a string.\");\n                \n                Json::Value endLowerValue = in_json.get(k_endLowerValueKey, Json::nullValue);\n                CS_ASSERT(endLowerValue != Json::nullValue, \"Must supply '\" + std::string(k_endLowerValueKey) + \"' in '\" + std::string(k_randomCurveType) + \"' property.\");\n                CS_ASSERT(endLowerValue.isString(), \"'\" + std::string(k_endLowerValueKey) + \"' in '\" + std::string(k_randomCurveType) + \"' property must be a string.\");\n                \n                Json::Value endUpperValue = in_json.get(k_endUpperValueKey, Json::nullValue);\n                CS_ASSERT(endUpperValue != Json::nullValue, \"Must supply '\" + std::string(k_endUpperValueKey) + \"' in '\" + std::string(k_randomCurveType) + \"' property.\");\n                CS_ASSERT(endUpperValue.isString(), \"'\" + std::string(k_endUpperValueKey) + \"' in '\" + std::string(k_randomCurveType) + \"' property must be a string.\");\n                \n                return ParticlePropertyUPtr<TType>(new RandomCurveParticleProperty<TType>(ParseValue<TType>(startLowerValue.asString()), ParseValue<TType>(startUpperValue.asString()),\n                    ParseValue<TType>(endLowerValue.asString()), ParseValue<TType>(endUpperValue.asString()), Interpolate::GetInterpolateFunction(curve.asString())));\n            }\n            //------------------------------------------------------------------------------\n            /// Creates a new componentwise random curve particle property with the value\n            /// described in the given json.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param The json value.\n            ///\n            /// @return The output particle property.\n            //------------------------------------------------------------------------------\n            template <typename TType> ParticlePropertyUPtr<TType> CreateComponentwiseRandomCurveProperty(const Json::Value& in_json)\n            {\n                Json::Value curve = in_json.get(k_curveKey, Json::nullValue);\n                CS_ASSERT(curve != Json::nullValue, \"Must supply '\" + std::string(k_curveKey) + \"' in '\" + std::string(k_componentwiseRandomCurveType) + \"' property.\");\n                CS_ASSERT(curve.isString(), \"'\" + std::string(k_curveKey) + \"' in '\" + std::string(k_componentwiseRandomCurveType) + \"' property must be a string.\");\n                \n                Json::Value startLowerValue = in_json.get(k_startLowerValueKey, Json::nullValue);\n                CS_ASSERT(startLowerValue != Json::nullValue, \"Must supply '\" + std::string(k_startLowerValueKey) + \"' in '\" + std::string(k_componentwiseRandomCurveType) + \"' property.\");\n                CS_ASSERT(startLowerValue.isString(), \"'\" + std::string(k_startLowerValueKey) + \"' in '\" + std::string(k_componentwiseRandomCurveType) + \"' property must be a string.\");\n                \n                Json::Value startUpperValue = in_json.get(k_startUpperValueKey, Json::nullValue);\n                CS_ASSERT(startUpperValue != Json::nullValue, \"Must supply '\" + std::string(k_startUpperValueKey) + \"' in '\" + std::string(k_componentwiseRandomCurveType) + \"' property.\");\n                CS_ASSERT(startUpperValue.isString(), \"'\" + std::string(k_startUpperValueKey) + \"' in '\" + std::string(k_componentwiseRandomCurveType) + \"' property must be a string.\");\n                \n                Json::Value endLowerValue = in_json.get(k_endLowerValueKey, Json::nullValue);\n                CS_ASSERT(endLowerValue != Json::nullValue, \"Must supply '\" + std::string(k_endLowerValueKey) + \"' in '\" + std::string(k_componentwiseRandomCurveType) + \"' property.\");\n                CS_ASSERT(endLowerValue.isString(), \"'\" + std::string(k_endLowerValueKey) + \"' in '\" + std::string(k_componentwiseRandomCurveType) + \"' property must be a string.\");\n                \n                Json::Value endUpperValue = in_json.get(k_endUpperValueKey, Json::nullValue);\n                CS_ASSERT(endUpperValue != Json::nullValue, \"Must supply '\" + std::string(k_endUpperValueKey) + \"' in '\" + std::string(k_componentwiseRandomCurveType) + \"' property.\");\n                CS_ASSERT(endUpperValue.isString(), \"'\" + std::string(k_endUpperValueKey) + \"' in '\" + std::string(k_componentwiseRandomCurveType) + \"' property must be a string.\");\n                \n                return ParticlePropertyUPtr<TType>(new ComponentwiseRandomCurveParticleProperty<TType>(ParseValue<TType>(startLowerValue.asString()), ParseValue<TType>(startUpperValue.asString()),\n                    ParseValue<TType>(endLowerValue.asString()), ParseValue<TType>(endUpperValue.asString()), Interpolate::GetInterpolateFunction(curve.asString())));\n            }\n            //------------------------------------------------------------------------------\n            /// Specialisation for parsing u32 values.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param The string to parse.\n            ///\n            /// @return The parsed value.\n            //------------------------------------------------------------------------------\n            template <> u32 ParseValue(const std::string& in_value);\n            //------------------------------------------------------------------------------\n            /// Specialisation for parsing s32 values.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param The string to parse.\n            ///\n            /// @return The parsed value.\n            //------------------------------------------------------------------------------\n            template <> s32 ParseValue(const std::string& in_value);\n            //------------------------------------------------------------------------------\n            /// Specialisation for parsing u64 values.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param The string to parse.\n            ///\n            /// @return The parsed value.\n            //------------------------------------------------------------------------------\n            template <> u64 ParseValue(const std::string& in_value);\n            //------------------------------------------------------------------------------\n            /// Specialisation for parsing s64 values.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param The string to parse.\n            ///\n            /// @return The parsed value.\n            //------------------------------------------------------------------------------\n            template <> s64 ParseValue(const std::string& in_value);\n            //------------------------------------------------------------------------------\n            /// Specialisation for parsing float values.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param The string to parse.\n            ///\n            /// @return The parsed value.\n            //------------------------------------------------------------------------------\n            template <> f32 ParseValue(const std::string& in_value);\n            //------------------------------------------------------------------------------\n            /// Specialisation for parsing Vector2 values.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param The string to parse.\n            ///\n            /// @return The parsed value.\n            //------------------------------------------------------------------------------\n            template <> Vector2 ParseValue(const std::string& in_value);\n            //------------------------------------------------------------------------------\n            /// Specialisation for parsing Vector3 values.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param The string to parse.\n            ///\n            /// @return The parsed value.\n            //------------------------------------------------------------------------------\n            template <> Vector3 ParseValue(const std::string& in_value);\n            //------------------------------------------------------------------------------\n            /// Specialisation for parsing Vector4 values.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param The string to parse.\n            ///\n            /// @return The parsed value.\n            //------------------------------------------------------------------------------\n            template <> Vector4 ParseValue(const std::string& in_value);\n            //------------------------------------------------------------------------------\n            /// Specialisation for parsing Matrix3 values.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param The string to parse.\n            ///\n            /// @return The parsed value.\n            //------------------------------------------------------------------------------\n            template <> Matrix3 ParseValue(const std::string& in_value);\n            //------------------------------------------------------------------------------\n            /// Specialisation for parsing Matrix4 values.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param The string to parse.\n            ///\n            /// @return The parsed value.\n            //------------------------------------------------------------------------------\n            template <> Matrix4 ParseValue(const std::string& in_value);\n            //------------------------------------------------------------------------------\n            /// Specialisation for parsing Quaternion values.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param The string to parse.\n            ///\n            /// @return The parsed value.\n            //------------------------------------------------------------------------------\n            template <> Quaternion ParseValue(const std::string& in_value);\n            //------------------------------------------------------------------------------\n            /// Specialisation for parsing Colour values.\n            ///\n            /// @author Ian Copland\n            ///\n            /// @param The string to parse.\n            ///\n            /// @return The parsed value.\n            //------------------------------------------------------------------------------\n            template <> Colour ParseValue(const std::string& in_value);\n        }\n        \n        //------------------------------------------------------------------------------\n        //------------------------------------------------------------------------------\n        template <typename TType> ParticlePropertyUPtr<TType> CreateProperty(const Json::Value& in_json)\n        {\n            //if it's a string value then default to a constant property.\n            if (in_json.isNull() == false && in_json.isString() == true)\n            {\n                return Impl::CreateConstantProperty<TType>(in_json.asString());\n            }\n            \n            //otherwise get the type.\n            else if (in_json.isNull() == false && in_json.isObject() == true)\n            {\n                Json::Value typeValue = in_json.get(Impl::k_typeKey, Json::nullValue);\n                CS_ASSERT(typeValue != Json::nullValue, \"A '\" + std::string(Impl::k_typeKey) + \"' must be supplied for a Particle Property.\")\n                CS_ASSERT(typeValue.isString() == true, \"'\" + std::string(Impl::k_typeKey) + \"' in a Particle Property must be a string.\")\n                \n                std::string typeString = typeValue.asString();\n                StringUtils::ToLowerCase(typeString);\n                    \n                if (typeString == Impl::k_constantType)\n                {\n                    return Impl::CreateConstantProperty<TType>(in_json);\n                }\n                else if (typeString == Impl::k_randomConstantType)\n                {\n                    return Impl::CreateRandomConstantProperty<TType>(in_json);\n                }\n                else if (typeString == Impl::k_componentwiseRandomConstantType)\n                {\n                    return Impl::CreateComponentwiseRandomConstantProperty<TType>(in_json);\n                }\n                else if (typeString == Impl::k_curveType)\n                {\n                    return Impl::CreateCurveProperty<TType>(in_json);\n                }\n                else if (typeString == Impl::k_randomCurveType)\n                {\n                    return Impl::CreateRandomCurveProperty<TType>(in_json);\n                }\n                else if (typeString == Impl::k_componentwiseRandomCurveType)\n                {\n                    return Impl::CreateComponentwiseRandomCurveProperty<TType>(in_json);\n                }\n            }\n            \n            CS_LOG_FATAL(\"Failed to create particle property.\");\n            return nullptr;\n        }\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Particle/Property/RandomConstantParticleProperty.h",
    "content": "//\n//  RandomConstantParticleProperty.h\n//  ChilliSource\n//  Created by Ian Copland on 26/10/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_PARTICLE_PROPERTY_RANDOMCONSTANTPARTICLEPROPERTY_H_\n#define _CHILLISOURCE_RENDERING_PARTICLE_PROPERTY_RANDOMCONSTANTPARTICLEPROPERTY_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Math/Random.h>\n#include <ChilliSource/Rendering/Particle/Property/ParticleProperty.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    /// A particle property for getting a random value between the given lower and\n    /// upper value.\n    ///\n    /// @author Ian Copland\n    //------------------------------------------------------------------------------\n    template <typename TPropertyType> class RandomConstantParticleProperty final : public ParticleProperty<TPropertyType>\n    {\n    public:\n        //------------------------------------------------------------------------------\n        /// Constructor.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The lower value.\n        /// @param The upper value.\n        //------------------------------------------------------------------------------\n        RandomConstantParticleProperty(TPropertyType in_lowerValue, TPropertyType in_upperValue);\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param The normalised (0.0 - 1.0) particle effect playback progress. This is\n        /// ignored for a random property.\n        ///\n        /// @return a random value between the lower and upper values the property was\n        /// created with.\n        //------------------------------------------------------------------------------\n        TPropertyType GenerateValue(f32 in_playbackProgress) const override;\n        \n    private:\n        TPropertyType m_lowerValue;\n        TPropertyType m_upperValue;\n    };\n    \n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    template <typename TPropertyType> RandomConstantParticleProperty<TPropertyType>::RandomConstantParticleProperty(TPropertyType in_lowerValue, TPropertyType in_upperValue)\n        : m_lowerValue(in_lowerValue), m_upperValue(in_upperValue)\n    {\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    template <typename TPropertyType> TPropertyType RandomConstantParticleProperty<TPropertyType>::GenerateValue(f32 in_playbackProgress) const\n    {\n        return Random::Generate(m_lowerValue, m_upperValue);\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Particle/Property/RandomCurveParticleProperty.h",
    "content": "//\n//  RandomCurveParticleProperty.h\n//  ChilliSource\n//  Created by Ian Copland on 29/12/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_PARTICLE_PROPERTY_RANDOMCURVEPARTICLEPROPERTY_H_\n#define _CHILLISOURCE_RENDERING_PARTICLE_PROPERTY_RANDOMCURVEPARTICLEPROPERTY_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Math/Random.h>\n#include <ChilliSource/Rendering/Particle/Property/ParticleProperty.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    /// A particle property describing a value which is randomly generated between\n    /// bounds. The bounds changes over the lifetime of the particle effect. The\n    /// curve function is described by a delegate provided in the constructor.\n    ///\n    /// @author Ian Copland\n    //------------------------------------------------------------------------------\n    template <typename TPropertyType> class RandomCurveParticleProperty final : public ParticleProperty<TPropertyType>\n    {\n    public:\n        //------------------------------------------------------------------------------\n        /// A delegate for a function which describes the curve. This must accept values\n        /// in the range 0.0 - 1.0 and output values in the range 0.0 - 1.0.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The current normalised (0.0 - 1.0) particle effect progress.\n        ///\n        /// @return The interpolation factor.\n        //------------------------------------------------------------------------------\n        using CurveFunction = std::function<f32(f32)>;\n        //------------------------------------------------------------------------------\n        /// Constructor.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The start lower value.\n        /// @param The start upper value.\n        /// @param The end lower value.\n        /// @param The end upper value.\n        /// @param The curve function.\n        //------------------------------------------------------------------------------\n        RandomCurveParticleProperty(TPropertyType in_startLowerValue, TPropertyType in_startUpperValue, TPropertyType in_endLowerValue, TPropertyType in_endUpperValue, const CurveFunction& in_curveFunction);\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param The normalised (0.0 - 1.0) particle effect playback progress.\n        ///\n        /// @return The generated value.\n        //------------------------------------------------------------------------------\n        TPropertyType GenerateValue(f32 in_playbackProgress) const override;\n        \n    private:\n        TPropertyType m_startLowerValue;\n        TPropertyType m_startUpperValue;\n        TPropertyType m_endLowerValue;\n        TPropertyType m_endUpperValue;\n        CurveFunction m_curveFunction;\n    };\n    \n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    template <typename TPropertyType> RandomCurveParticleProperty<TPropertyType>::RandomCurveParticleProperty(TPropertyType in_startLowerValue, TPropertyType in_startUpperValue, TPropertyType in_endLowerValue,\n                                                                                                              TPropertyType in_endUpperValue, const CurveFunction& in_curveFunction)\n        : m_startLowerValue(in_startLowerValue), m_startUpperValue(in_startUpperValue), m_endLowerValue(in_endLowerValue), m_endUpperValue(in_endUpperValue), m_curveFunction(in_curveFunction)\n    {\n        CS_ASSERT(m_curveFunction != nullptr, \"A curve function must be provided.\");\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    template <typename TPropertyType> TPropertyType RandomCurveParticleProperty<TPropertyType>::GenerateValue(f32 in_playbackProgress) const\n    {\n        CS_ASSERT(in_playbackProgress >= 0.0f && in_playbackProgress <= 1.0f, \"Playback progress must be in the range 0.0 to 1.0.\");\n        \n        f32 interpolationFactor = m_curveFunction(in_playbackProgress);\n        \n        TPropertyType lowerBound = TPropertyType(m_startLowerValue + (m_endLowerValue - m_startLowerValue) * interpolationFactor);\n        TPropertyType upperBound = TPropertyType(m_startUpperValue + (m_endUpperValue - m_startUpperValue) * interpolationFactor);\n        \n        return Random::Generate(lowerBound, upperBound);\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Particle.h",
    "content": "//\n//  Particle.h\n//  ChilliSource\n//  Created by Ian Copland on 07/07/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_PARTICLE_H_\n#define _CHILLISOURCE_RENDERING_PARTICLE_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Rendering/Particle/CSParticleProvider.h>\n#include <ChilliSource/Rendering/Particle/ConcurrentParticleData.h>\n#include <ChilliSource/Rendering/Particle/Particle.h>\n#include <ChilliSource/Rendering/Particle/ParticleEffect.h>\n#include <ChilliSource/Rendering/Particle/ParticleEffectComponent.h>\n#include <ChilliSource/Rendering/Particle/Affector/AccelerationParticleAffector.h>\n#include <ChilliSource/Rendering/Particle/Affector/AccelerationParticleAffectorDef.h>\n#include <ChilliSource/Rendering/Particle/Affector/AngularAccelerationParticleAffector.h>\n#include <ChilliSource/Rendering/Particle/Affector/AngularAccelerationParticleAffectorDef.h>\n#include <ChilliSource/Rendering/Particle/Affector/ColourOverLifetimeParticleAffector.h>\n#include <ChilliSource/Rendering/Particle/Affector/ColourOverLifetimeParticleAffectorDef.h>\n#include <ChilliSource/Rendering/Particle/Affector/ParticleAffector.h>\n#include <ChilliSource/Rendering/Particle/Affector/ParticleAffectorDef.h>\n#include <ChilliSource/Rendering/Particle/Affector/ParticleAffectorDefFactory.h>\n#include <ChilliSource/Rendering/Particle/Affector/ScaleOverLifetimeParticleAffector.h>\n#include <ChilliSource/Rendering/Particle/Affector/ScaleOverLifetimeParticleAffectorDef.h>\n#include <ChilliSource/Rendering/Particle/Drawable/StaticBillboardParticleDrawable.h>\n#include <ChilliSource/Rendering/Particle/Drawable/StaticBillboardParticleDrawableDef.h>\n#include <ChilliSource/Rendering/Particle/Drawable/ParticleDrawable.h>\n#include <ChilliSource/Rendering/Particle/Drawable/ParticleDrawableDef.h>\n#include <ChilliSource/Rendering/Particle/Drawable/ParticleDrawableDefFactory.h>\n#include <ChilliSource/Rendering/Particle/Emitter/CircleParticleEmitter.h>\n#include <ChilliSource/Rendering/Particle/Emitter/CircleParticleEmitterDef.h>\n#include <ChilliSource/Rendering/Particle/Emitter/ConeParticleEmitter.h>\n#include <ChilliSource/Rendering/Particle/Emitter/ConeParticleEmitterDef.h>\n#include <ChilliSource/Rendering/Particle/Emitter/Cone2DParticleEmitter.h>\n#include <ChilliSource/Rendering/Particle/Emitter/Cone2DParticleEmitterDef.h>\n#include <ChilliSource/Rendering/Particle/Emitter/ParticleEmitter.h>\n#include <ChilliSource/Rendering/Particle/Emitter/ParticleEmitterDef.h>\n#include <ChilliSource/Rendering/Particle/Emitter/ParticleEmitterDefFactory.h>\n#include <ChilliSource/Rendering/Particle/Emitter/PointParticleEmitter.h>\n#include <ChilliSource/Rendering/Particle/Emitter/PointParticleEmitterDef.h>\n#include <ChilliSource/Rendering/Particle/Emitter/SphereParticleEmitter.h>\n#include <ChilliSource/Rendering/Particle/Emitter/SphereParticleEmitterDef.h>\n#include <ChilliSource/Rendering/Particle/Property/ParticleProperty.h>\n#include <ChilliSource/Rendering/Particle/Property/ComponentwiseRandomConstantParticleProperty.h>\n#include <ChilliSource/Rendering/Particle/Property/ConstantParticleProperty.h>\n#include <ChilliSource/Rendering/Particle/Property/RandomConstantParticleProperty.h>\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/RenderCommand/Commands/ApplyAmbientLightRenderCommand.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/RenderCommand/Commands/ApplyAmbientLightRenderCommand.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    ApplyAmbientLightRenderCommand::ApplyAmbientLightRenderCommand(const Colour& colour) noexcept\n        : RenderCommand(Type::k_applyAmbientLight), m_colour(colour)\n    {\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/RenderCommand/Commands/ApplyAmbientLightRenderCommand.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_RENDERCOMMAND_COMMANDS_APPLYAMBIENTLIGHTRENDERCOMMAND_H_\n#define _CHILLISOURCE_RENDERING_RENDERCOMMAND_COMMANDS_APPLYAMBIENTLIGHTRENDERCOMMAND_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Base/Colour.h>\n#include <ChilliSource/Rendering/RenderCommand/RenderCommand.h>\n\nnamespace ChilliSource\n{\n    /// A render command for applying the described ambient light to the current context\n    /// state.\n    ///\n    /// This must be instantiated via a RenderCommandList.\n    ///\n    /// This is immutable and therefore thread-safe.\n    ///\n    class ApplyAmbientLightRenderCommand final : public RenderCommand\n    {\n    public:\n        /// @return The colour of the ambient light.\n        ///\n        const Colour& GetColour() const noexcept { return m_colour; };\n        \n    private:\n        friend class RenderCommandList;\n        \n        /// Creates a new instance with the given light colour.\n        ///\n        /// @param colour\n        ///     The ambient light colour.\n        ///\n        ApplyAmbientLightRenderCommand(const Colour& colour) noexcept;\n        \n        Colour m_colour;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/RenderCommand/Commands/ApplyCameraRenderCommand.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/RenderCommand/Commands/ApplyCameraRenderCommand.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    ApplyCameraRenderCommand::ApplyCameraRenderCommand(const Vector3& position, const Matrix4& viewMatrix, const Matrix4& viewProjectionMatrix) noexcept\n        : RenderCommand(Type::k_applyCamera), m_position(position), m_viewMatrix(viewMatrix), m_viewProjectionMatrix(viewProjectionMatrix)\n    {\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/RenderCommand/Commands/ApplyCameraRenderCommand.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_RENDERCOMMAND_COMMANDS_APPLYCAMERARENDERCOMMAND_H_\n#define _CHILLISOURCE_RENDERING_RENDERCOMMAND_COMMANDS_APPLYCAMERARENDERCOMMAND_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Math/Matrix4.h>\n#include <ChilliSource/Core/Math/Vector3.h>\n#include <ChilliSource/Rendering/RenderCommand/RenderCommand.h>\n\nnamespace ChilliSource\n{\n    /// A render command for applying the described camera to the current context state.\n    ///\n    /// This must be instantiated via a RenderCommandList.\n    ///\n    /// This is immutable and therefore thread-safe.\n    ///\n    class ApplyCameraRenderCommand final : public RenderCommand\n    {\n    public:\n        /// @return The world space position of the camera.\n        ///\n        const Vector3& GetPosition() const noexcept { return m_position; };\n        \n        /// @return The view matrix of the camera.\n        ///\n        const Matrix4& GetViewMatrix() const noexcept { return m_viewMatrix; };\n        \n        /// @return The view projection matrix of the camera.\n        ///\n        const Matrix4& GetViewProjectionMatrix() const noexcept { return m_viewProjectionMatrix; };\n        \n    private:\n        friend class RenderCommandList;\n        \n        /// Creates a new instance with the given position and view projection matrix.\n        ///\n        /// @param position\n        ///     The world space position of the camera.\n        /// @param viewMatrix\n        ///     The view matrix (inverse transform) of the camera\n        /// @param viewProjectionMatrix\n        ///     The view projection matrix of the camera.\n        ///\n        ApplyCameraRenderCommand(const Vector3& position, const Matrix4& viewMatrix, const Matrix4& viewProjectionMatrix) noexcept;\n        \n        Vector3 m_position;\n        Matrix4 m_viewMatrix;\n        Matrix4 m_viewProjectionMatrix;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/RenderCommand/Commands/ApplyDirectionalLightRenderCommand.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/RenderCommand/Commands/ApplyDirectionalLightRenderCommand.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    ApplyDirectionalLightRenderCommand::ApplyDirectionalLightRenderCommand(const Colour& colour, const Vector3& direction, const Matrix4& lightViewProjection, f32 shadowTolerance,\n                                                                           const RenderTexture* shadowMapRenderTexture) noexcept\n        : RenderCommand(Type::k_applyDirectionalLight), m_colour(colour), m_direction(direction), m_lightViewProjection(lightViewProjection), m_shadowTolerance(shadowTolerance),\n          m_shadowMapRenderTexture(shadowMapRenderTexture)\n    {\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/RenderCommand/Commands/ApplyDirectionalLightRenderCommand.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_RENDERCOMMAND_COMMANDS_APPLYDIRECTIONALLIGHTRENDERCOMMAND_H_\n#define _CHILLISOURCE_RENDERING_RENDERCOMMAND_COMMANDS_APPLYDIRECTIONALLIGHTRENDERCOMMAND_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Base/Colour.h>\n#include <ChilliSource/Core/Math/Matrix4.h>\n#include <ChilliSource/Core/Math/Vector3.h>\n#include <ChilliSource/Rendering/RenderCommand/RenderCommand.h>\n\nnamespace ChilliSource\n{\n    /// A render command for applying the described directional light to the current context\n    /// state.\n    ///\n    /// This must be instantiated via a RenderCommandList.\n    ///\n    /// This is immutable and therefore thread-safe.\n    ///\n    class ApplyDirectionalLightRenderCommand final : public RenderCommand\n    {\n    public:\n        /// @return The colour of the light.\n        ///\n        const Colour& GetColour() const noexcept { return m_colour; }\n        \n        /// @return The direction of the light.\n        ///\n        const Vector3& GetDirection() const noexcept { return m_direction; }\n        \n        /// @return The view projection matrix of the light which is used as the camera when rendering\n        ///     the shadow map.\n        ///\n        const Matrix4& GetLightViewProjection() const noexcept { return m_lightViewProjection; }\n        \n        /// @return The tolerence used to judge if an object is in shadow.\n        ///\n        f32 GetShadowTolerance() const noexcept { return m_shadowTolerance; }\n        \n        /// @return The render texture which should be used for the shadow map. Will be null if there is\n        ///     no shadow map.\n        ///\n        const RenderTexture* GetShadowMapRenderTexture() const noexcept { return m_shadowMapRenderTexture; }\n        \n    private:\n        friend class RenderCommandList;\n        \n        /// Creates a new instance with the given light colour.\n        ///\n        /// @param colour\n        ///     The colour of the light.\n        /// @param direction\n        ///     The direction of the light.\n        /// @param lightViewProjection\n        ///     The view projection matrix of the light which is used as the camera when rendering\n        ///     the shadow map.\n        /// @param shadowTolerance\n        ///     The tolerence used to judge if an object is in shadow.\n        /// @param shadowMapRenderTexture\n        ///     The render texture which should be used for the shadow map. Can be null if there is no\n        ///     shadow map.\n        ///\n        ApplyDirectionalLightRenderCommand(const Colour& colour, const Vector3& direction, const Matrix4& lightViewProjection, f32 shadowTolerance, const RenderTexture* shadowMapRenderTexture) noexcept;\n        \n        Colour m_colour;\n        Vector3 m_direction;\n        Matrix4 m_lightViewProjection;\n        f32 m_shadowTolerance;\n        const RenderTexture* m_shadowMapRenderTexture;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/RenderCommand/Commands/ApplyDynamicMeshRenderCommand.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/RenderCommand/Commands/ApplyDynamicMeshRenderCommand.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    ApplyDynamicMeshRenderCommand::ApplyDynamicMeshRenderCommand(const RenderDynamicMesh* renderDynamicMesh) noexcept\n    : RenderCommand(Type::k_applyDynamicMesh), m_renderDynamicMesh(renderDynamicMesh)\n    {\n        CS_ASSERT(m_renderDynamicMesh, \"Render dynamic mesh cannot be null.\");\n    }\n}"
  },
  {
    "path": "Source/ChilliSource/Rendering/RenderCommand/Commands/ApplyDynamicMeshRenderCommand.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_RENDERCOMMAND_COMMANDS_APPLYDYNAMICMESHRENDERCOMMAND_H_\n#define _CHILLISOURCE_RENDERING_RENDERCOMMAND_COMMANDS_APPLYDYNAMICMESHRENDERCOMMAND_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Rendering/RenderCommand/RenderCommand.h>\n\nnamespace ChilliSource\n{\n    /// A render command for applying the given render dynamic mesh to the current context state.\n    ///\n    /// This must be instantiated via a RenderCommandList.\n    ///\n    /// This is immutable and therefore thread-safe.\n    ///\n    class ApplyDynamicMeshRenderCommand final : public RenderCommand\n    {\n    public:\n        /// @return The render mesh to apply.\n        ///\n        const RenderDynamicMesh* GetRenderDynamicMesh() const noexcept { return m_renderDynamicMesh; };\n        \n    private:\n        friend class RenderCommandList;\n        \n        /// Creates a new instance with the given render dynamic mesh.\n        ///\n        /// @param renderDynamicMesh\n        ///     The render dynamic mesh to apply.\n        ///\n        ApplyDynamicMeshRenderCommand(const RenderDynamicMesh* renderDynamicMesh) noexcept;\n        \n        const RenderDynamicMesh* m_renderDynamicMesh;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/RenderCommand/Commands/ApplyMaterialRenderCommand.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/RenderCommand/Commands/ApplyMaterialRenderCommand.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    ApplyMaterialRenderCommand::ApplyMaterialRenderCommand(const RenderMaterial* renderMaterial) noexcept\n        : RenderCommand(Type::k_applyMaterial), m_renderMaterial(renderMaterial)\n    {\n        CS_ASSERT(m_renderMaterial, \"Render material cannot be null.\");\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/RenderCommand/Commands/ApplyMaterialRenderCommand.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_RENDERCOMMAND_COMMANDS_APPLYMATERIALRENDERCOMMAND_H_\n#define _CHILLISOURCE_RENDERING_RENDERCOMMAND_COMMANDS_APPLYMATERIALRENDERCOMMAND_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Rendering/RenderCommand/RenderCommand.h>\n\nnamespace ChilliSource\n{\n    /// A render command for applying the given render material to the current context state.\n    ///\n    /// This must be instantiated via a RenderCommandList.\n    ///\n    /// This is immutable and therefore thread-safe.\n    ///\n    class ApplyMaterialRenderCommand final : public RenderCommand\n    {\n    public:\n        /// @return The render material to apply.\n        ///\n        const RenderMaterial* GetRenderMaterial() const noexcept { return m_renderMaterial; };\n        \n    private:\n        friend class RenderCommandList;\n        \n        /// Creates a new instance with the given render material.\n        ///\n        /// @param renderMaterial\n        ///     The render material to apply.\n        ///\n        ApplyMaterialRenderCommand(const RenderMaterial* renderMaterial) noexcept;\n        \n        const RenderMaterial* m_renderMaterial;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/RenderCommand/Commands/ApplyMeshBatchRenderCommand.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/RenderCommand/Commands/ApplyMeshBatchRenderCommand.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    ApplyMeshBatchRenderCommand::ApplyMeshBatchRenderCommand(RenderMeshBatchUPtr renderMeshBatch) noexcept\n        : RenderCommand(Type::k_applyMeshBatch), m_renderMeshBatch(std::move(renderMeshBatch))\n    {\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/RenderCommand/Commands/ApplyMeshBatchRenderCommand.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_RENDERCOMMAND_COMMANDS_APPLYMESHBATCHRENDERCOMMAND_H_\n#define _CHILLISOURCE_RENDERING_RENDERCOMMAND_COMMANDS_APPLYMESHBATCHRENDERCOMMAND_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Rendering/Model/RenderMeshBatch.h>\n#include <ChilliSource/Rendering/RenderCommand/RenderCommand.h>\n\n#include <vector>\n\nnamespace ChilliSource\n{\n    /// A render command for batching the given set of meshes into a single mesh and applying\n    /// it to the context state.\n    ///\n    /// This must be instantiated via a RenderCommandList.\n    ///\n    /// This is immutable and therefore thread-safe.\n    ///\n    class ApplyMeshBatchRenderCommand final : public RenderCommand\n    {\n    public:\n        /// @return The render mesh batch that should be applied.\n        ///\n        const RenderMeshBatch* GetRenderMeshBatch() const noexcept { return m_renderMeshBatch.get(); }\n        \n    private:\n        friend class RenderCommandList;\n        \n        /// Creates a new instance with the given render mesh batch.\n        ///\n        /// @param renderMeshBatch\n        ///     The render mesh batch that should be applied. Must be moved.\n        ///\n        ApplyMeshBatchRenderCommand(RenderMeshBatchUPtr renderMeshBatch) noexcept;\n        \n        RenderMeshBatchUPtr m_renderMeshBatch;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/RenderCommand/Commands/ApplyMeshRenderCommand.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Rendering/RenderCommand/Commands/ApplyMeshRenderCommand.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    ApplyMeshRenderCommand::ApplyMeshRenderCommand(const RenderMesh* renderMesh) noexcept\n        : RenderCommand(Type::k_applyMesh), m_renderMesh(renderMesh)\n    {\n        CS_ASSERT(m_renderMesh, \"Render mesh cannot be null.\");\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/RenderCommand/Commands/ApplyMeshRenderCommand.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_RENDERCOMMAND_COMMANDS_APPLYMESHRENDERCOMMAND_H_\n#define _CHILLISOURCE_RENDERING_RENDERCOMMAND_COMMANDS_APPLYMESHRENDERCOMMAND_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Rendering/RenderCommand/RenderCommand.h>\n\nnamespace ChilliSource\n{\n    /// A render command for applying the given render mesh to the current context state.\n    ///\n    /// This must be instantiated via a RenderCommandList.\n    ///\n    /// This is immutable and therefore thread-safe.\n    ///\n    class ApplyMeshRenderCommand final : public RenderCommand\n    {\n    public:\n        /// @return The render mesh to apply.\n        ///\n        const RenderMesh* GetRenderMesh() const noexcept { return m_renderMesh; };\n        \n    private:\n        friend class RenderCommandList;\n        \n        /// Creates a new instance with the given render mesh.\n        ///\n        /// @param renderMesh\n        ///     The render mesh to apply.\n        ///\n        ApplyMeshRenderCommand(const RenderMesh* renderMesh) noexcept;\n        \n        const RenderMesh* m_renderMesh;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/RenderCommand/Commands/ApplyPointLightRenderCommand.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/RenderCommand/Commands/ApplyPointLightRenderCommand.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    ApplyPointLightRenderCommand::ApplyPointLightRenderCommand(const Colour& colour, const Vector3& position, const Vector3& attenuation) noexcept\n        : RenderCommand(Type::k_applyPointLight), m_colour(colour), m_position(position), m_attenuation(attenuation)\n    {\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/RenderCommand/Commands/ApplyPointLightRenderCommand.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_RENDERCOMMAND_COMMANDS_APPLYPOINTLIGHTRENDERCOMMAND_H_\n#define _CHILLISOURCE_RENDERING_RENDERCOMMAND_COMMANDS_APPLYPOINTLIGHTRENDERCOMMAND_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Base/Colour.h>\n#include <ChilliSource/Core/Math/Vector3.h>\n#include <ChilliSource/Rendering/RenderCommand/RenderCommand.h>\n\nnamespace ChilliSource\n{\n    /// A render command for applying the described point light to the current context state.\n    ///\n    /// This must be instantiated via a RenderCommandList.\n    ///\n    /// This is immutable and therefore thread-safe.\n    ///\n    class ApplyPointLightRenderCommand final : public RenderCommand\n    {\n    public:\n        /// @return The colour of the light.\n        ///\n        const Colour& GetColour() const noexcept { return m_colour; }\n        \n        /// @return The world space position of the light.\n        ///\n        const Vector3& GetPosition() const noexcept { return m_position; }\n        \n        /// @return The vector containing the constant, linear and quadratic attenuation values of the\n        ///     light.\n        ///\n        const Vector3& GetAttenuation() const noexcept { return m_attenuation; }\n        \n    private:\n        friend class RenderCommandList;\n        \n        /// Creates a new instance with the given light colour, position and attenuation.\n        ///\n        /// @param colour\n        ///     The colour of the light.\n        /// @param position\n        ///     The world space position of the light.\n        /// @param attenuation\n        ///     The vector containing the constant, linear and quadratic attenuation values of the\n        ///     light.\n        ///\n        ApplyPointLightRenderCommand(const Colour& colour, const Vector3& position, const Vector3& attenuation) noexcept;\n        \n        Colour m_colour;\n        Vector3 m_position;\n        Vector3 m_attenuation;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/RenderCommand/Commands/ApplySkinnedAnimationRenderCommand.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Rendering/RenderCommand/Commands/ApplySkinnedAnimationRenderCommand.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    ApplySkinnedAnimationRenderCommand::ApplySkinnedAnimationRenderCommand(const RenderSkinnedAnimation* renderSkinnedAnimation) noexcept\n        : RenderCommand(Type::k_applySkinnedAnimation), m_renderSkinnedAnimation(renderSkinnedAnimation)\n    {\n        CS_ASSERT(m_renderSkinnedAnimation, \"RenderSkinnedAnimation must not be null.\");\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/RenderCommand/Commands/ApplySkinnedAnimationRenderCommand.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_RENDERCOMMAND_COMMANDS_APPLYSKINNEDANIMATIONRENDERCOMMAND_H_\n#define _CHILLISOURCE_RENDERING_RENDERCOMMAND_COMMANDS_APPLYSKINNEDANIMATIONRENDERCOMMAND_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Rendering/RenderCommand/RenderCommand.h>\n\nnamespace ChilliSource\n{\n    /// A render command for applying the given skinned animation to the current context state.\n    ///\n    /// This must be instantiated via a RenderCommandList.\n    ///\n    /// This is immutable and therefore thread-safe.\n    ///\n    class ApplySkinnedAnimationRenderCommand final : public RenderCommand\n    {\n    public:\n        /// @return The render skinned animation to apply.\n        ///\n        const RenderSkinnedAnimation* GetRenderSkinnedAnimation() const noexcept { return m_renderSkinnedAnimation; };\n        \n    private:\n        friend class RenderCommandList;\n        \n        /// Creates a new instance with the given render skinned animation.\n        ///\n        /// @param renderSkinnedAnimation\n        ///     The render skinned animation to apply.\n        ///\n        ApplySkinnedAnimationRenderCommand(const RenderSkinnedAnimation* renderSkinnedAnimation) noexcept;\n        \n        const RenderSkinnedAnimation* m_renderSkinnedAnimation;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/RenderCommand/Commands/BeginRenderCommand.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/RenderCommand/Commands/BeginRenderCommand.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    BeginRenderCommand::BeginRenderCommand(const Integer2& resolution, const Colour& clearColour) noexcept\n        : RenderCommand(Type::k_begin), m_resolution(resolution), m_clearColour(clearColour)\n    {\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/RenderCommand/Commands/BeginRenderCommand.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_RENDERCOMMAND_COMMANDS_BEGINRENDERCOMMAND_H_\n#define _CHILLISOURCE_RENDERING_RENDERCOMMAND_COMMANDS_BEGINRENDERCOMMAND_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Base/Colour.h>\n#include <ChilliSource/Core/Math/Vector2.h>\n#include <ChilliSource/Rendering/RenderCommand/RenderCommand.h>\n\nnamespace ChilliSource\n{\n    /// A render command for beginning rendering to the default render target with the given\n    /// resolution and clear colour.\n    ///\n    /// This must be instantiated via a RenderCommandList.\n    ///\n    /// This is immutable and therefore thread-safe.\n    ///\n    class BeginRenderCommand final : public RenderCommand\n    {\n    public:\n        /// @return The resolution of the viewport.\n        ///\n        const Integer2& GetResolution() const noexcept { return m_resolution; };\n        \n        /// @return The clear colour.\n        ///\n        const Colour& GetClearColour() const noexcept { return m_clearColour; };\n        \n    private:\n        friend class RenderCommandList;\n        \n        /// Creates a new instance with the given resolution and clear colour.\n        ///\n        /// @param resolution\n        ///     The resolution of the viewport.\n        /// @param clearColour\n        ///     The clear colour.\n        ///\n        BeginRenderCommand(const Integer2& resolution, const Colour& clearColour) noexcept;\n        \n        Integer2 m_resolution;\n        Colour m_clearColour;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/RenderCommand/Commands/BeginWithTargetGroupRenderCommand.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/RenderCommand/Commands/BeginWithTargetGroupRenderCommand.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    BeginWithTargetGroupRenderCommand::BeginWithTargetGroupRenderCommand(const RenderTargetGroup* renderTargetGroup, const Colour& clearColour) noexcept\n        : RenderCommand(Type::k_beginWithTargetGroup), m_renderTargetGroup(renderTargetGroup), m_clearColour(clearColour)\n    {\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/RenderCommand/Commands/BeginWithTargetGroupRenderCommand.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_RENDERCOMMAND_COMMANDS_BEGINWITHTARGETGROUPRENDERCOMMAND_H_\n#define _CHILLISOURCE_RENDERING_RENDERCOMMAND_COMMANDS_BEGINWITHTARGETGROUPRENDERCOMMAND_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Base/Colour.h>\n#include <ChilliSource/Rendering/RenderCommand/RenderCommand.h>\n\nnamespace ChilliSource\n{\n    /// A render command for beginning rendering to the the given target group with the given\n    /// clear colour.\n    ///\n    /// This must be instantiated via a RenderCommandList.\n    ///\n    /// This is immutable and therefore thread-safe.\n    ///\n    class BeginWithTargetGroupRenderCommand final : public RenderCommand\n    {\n    public:\n        /// @return The render target group that\n        ///\n        const RenderTargetGroup* GetRenderTargetGroup() const noexcept { return m_renderTargetGroup; };\n        \n        /// @return The clear colour.\n        ///\n        const Colour& GetClearColour() const noexcept { return m_clearColour; };\n        \n    private:\n        friend class RenderCommandList;\n        \n        /// Creates a new instance with the given RenderTargetGroup and clear colour.\n        ///\n        /// @param renderTargetGroup\n        ///     The render target group to render into.\n        /// @param clearColour\n        ///     The clear colour.\n        ///\n        BeginWithTargetGroupRenderCommand(const RenderTargetGroup* renderTargetGroup, const Colour& clearColour) noexcept;\n        \n        const RenderTargetGroup* m_renderTargetGroup;\n        Colour m_clearColour;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/RenderCommand/Commands/EndRenderCommand.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/RenderCommand/Commands/EndRenderCommand.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    EndRenderCommand::EndRenderCommand() noexcept\n        : RenderCommand(Type::k_end)\n    {\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/RenderCommand/Commands/EndRenderCommand.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_RENDERCOMMAND_COMMANDS_ENDRENDERCOMMAND_H_\n#define _CHILLISOURCE_RENDERING_RENDERCOMMAND_COMMANDS_ENDRENDERCOMMAND_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Rendering/RenderCommand/RenderCommand.h>\n\nnamespace ChilliSource\n{\n    /// A render command for ending rendering to the current render target.\n    ///\n    /// This must be instantiated via a RenderCommandList.\n    ///\n    /// This is immutable and therefore thread-safe.\n    ///\n    class EndRenderCommand final : public RenderCommand\n    {\n    private:\n        friend class RenderCommandList;\n        \n        EndRenderCommand() noexcept;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/RenderCommand/Commands/LoadCubemapRenderCommand.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/RenderCommand/Commands/LoadCubemapRenderCommand.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    LoadCubemapRenderCommand::LoadCubemapRenderCommand(RenderTexture* renderTexture, std::array<std::unique_ptr<const u8[]>, 6> textureData, u32 textureDataSize) noexcept\n        : RenderCommand(Type::k_loadCubemap), m_renderTexture(renderTexture), m_textureData(std::move(textureData)), m_textureDataSize(textureDataSize)\n    {\n    }\n    //------------------------------------------------------------------------------\n    std::array<std::unique_ptr<const u8[]>, 6> LoadCubemapRenderCommand::ClaimTextureData() noexcept\n    {\n        CS_ASSERT(m_textureData[0], \"Cannot claim nullptr data! Data may have already been claimed.\");\n        return std::move(m_textureData);\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/RenderCommand/Commands/LoadCubemapRenderCommand.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_RENDERCOMMAND_COMMANDS_LOADCUBEMAPRENDERCOMMAND_H_\n#define _CHILLISOURCE_RENDERING_RENDERCOMMAND_COMMANDS_LOADCUBEMAPRENDERCOMMAND_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Rendering/RenderCommand/RenderCommand.h>\n#include <ChilliSource/Rendering/Texture/RenderTexture.h>\n\n#include <array>\n\nnamespace ChilliSource\n{\n    /// A render command for loading the cubemap data for each face pertaining to a single render texture into\n    /// render memory.\n    ///\n    /// This must be instantiated via a RenderCommandList.\n    ///\n    /// This is immutable and therefore thread-safe.\n    ///\n    class LoadCubemapRenderCommand final : public RenderCommand\n    {\n    public:\n        /// @return The render texture that should be loaded.\n        ///\n        RenderTexture* GetRenderTexture() const noexcept { return m_renderTexture; };\n        \n        /// @return The data describing the texture.\n        ///\n        const std::array<std::unique_ptr<const u8[]>, 6>& GetTextureData() const noexcept { return m_textureData; }\n        \n        /// Moves the texture data out of this class. Use with caution as this command\n        /// will be in a broken state after this is used.\n        ///\n        /// @return The data describing the texture for each face.\n        ///\n        std::array<std::unique_ptr<const u8[]>, 6> ClaimTextureData() noexcept;\n        \n        /// @return The size of the texture data in bytes.\n        ///\n        u32 GetTextureDataSize() const noexcept { return m_textureDataSize; }\n        \n    private:\n        friend class RenderCommandList;\n        \n        /// Constructs a new instance with the given render texture and texture data.\n        ///\n        /// @param renderTexture\n        ///     The render texture that should be loaded.\n        /// @param textureData\n        ///     The data describing the texture for each face.\n        /// @param textureDataSize\n        ///     The size of the texture data in bytes.\n        ///\n        LoadCubemapRenderCommand(RenderTexture* renderTexture, std::array<std::unique_ptr<const u8[]>, 6> textureData, u32 textureDataSize) noexcept;\n        \n        RenderTexture* m_renderTexture;\n        std::array<std::unique_ptr<const u8[]>, 6> m_textureData;\n        u32 m_textureDataSize;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/RenderCommand/Commands/LoadMaterialGroupRenderCommand.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/RenderCommand/Commands/LoadMaterialGroupRenderCommand.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    LoadMaterialGroupRenderCommand::LoadMaterialGroupRenderCommand(RenderMaterialGroup* renderMaterialGroup) noexcept\n        : RenderCommand(Type::k_loadMaterialGroup), m_renderMaterialGroup(renderMaterialGroup)\n    {\n    }\n}   \n"
  },
  {
    "path": "Source/ChilliSource/Rendering/RenderCommand/Commands/LoadMaterialGroupRenderCommand.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_RENDERCOMMAND_COMMANDS_LOADMATERIALGROUPRENDERCOMMAND_H_\n#define _CHILLISOURCE_RENDERING_RENDERCOMMAND_COMMANDS_LOADMATERIALGROUPRENDERCOMMAND_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Rendering/RenderCommand/RenderCommand.h>\n#include <ChilliSource/Rendering/Material/RenderMaterialGroup.h>\n\nnamespace ChilliSource\n{\n    /// A render command for loading the data pertaining to a single render material group.\n    ///\n    /// This must be instantiated via a RenderCommandList.\n    ///\n    /// This is immutable and therefore thread-safe.\n    ///\n    class LoadMaterialGroupRenderCommand final : public RenderCommand\n    {\n    public:\n        /// @return The render material that should be loaded.\n        ///\n        RenderMaterialGroup* GetRenderMaterialGroup() const noexcept { return m_renderMaterialGroup; }\n        \n    private:\n        friend class RenderCommandList;\n        \n        /// Constructs a new instance with the given render render material group.\n        ///\n        /// @param renderMaterialGroup\n        ///     The render material group that should be loaded.\n        ///\n        LoadMaterialGroupRenderCommand(RenderMaterialGroup* renderMaterialGroup) noexcept;\n        \n        RenderMaterialGroup* m_renderMaterialGroup;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/RenderCommand/Commands/LoadMeshRenderCommand.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Rendering/RenderCommand/Commands/LoadMeshRenderCommand.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    LoadMeshRenderCommand::LoadMeshRenderCommand(RenderMesh* renderMesh, std::unique_ptr<const u8[]> vertexData, u32 vertexDataSize, std::unique_ptr<const u8[]> indexData, u32 indexDataSize) noexcept\n        : RenderCommand(Type::k_loadMesh), m_renderMesh(renderMesh), m_vertexData(std::move(vertexData)), m_vertexDataSize(vertexDataSize), m_indexData(std::move(indexData)), m_indexDataSize(indexDataSize)\n    {\n    }\n    //------------------------------------------------------------------------------\n    std::unique_ptr<const u8[]> LoadMeshRenderCommand::ClaimVertexData() noexcept\n    {\n        CS_ASSERT(m_vertexData, \"Cannot claim nullptr data! Data may have already been claimed.\");\n        return std::move(m_vertexData);\n    }\n    //------------------------------------------------------------------------------\n    std::unique_ptr<const u8[]> LoadMeshRenderCommand::ClaimIndexData() noexcept\n    {\n        CS_ASSERT(m_indexData, \"Cannot claim nullptr data! Data may have already been claimed.\");\n        return std::move(m_indexData);\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/RenderCommand/Commands/LoadMeshRenderCommand.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_RENDERCOMMAND_COMMANDS_LOADMESHRENDERCOMMAND_H_\n#define _CHILLISOURCE_RENDERING_RENDERCOMMAND_COMMANDS_LOADMESHRENDERCOMMAND_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Rendering/RenderCommand/RenderCommand.h>\n#include <ChilliSource/Rendering/Model/RenderMesh.h>\n\nnamespace ChilliSource\n{\n    /// A render command for loading the mesh data pertaining to a single render mesh into\n    /// render memory.\n    ///\n    /// This must be instantiated via a RenderCommandList.\n    ///\n    /// This is immutable and therefore thread-safe.\n    ///\n    class LoadMeshRenderCommand final : public RenderCommand\n    {\n    public:\n        /// @return The render mesh that should be loaded.\n        ///\n        RenderMesh* GetRenderMesh() const noexcept { return m_renderMesh; }\n        \n        /// @return The vertex data buffer.\n        ///\n        const u8* GetVertexData() const noexcept { return m_vertexData.get(); }\n        \n        /// Moves the Vertex data out of this class. Use with caution as this command\n        /// will be in a broken state after this is used.\n        ///\n        /// @return The vertex data buffer.\n        ///\n        std::unique_ptr<const u8[]> ClaimVertexData() noexcept;\n        \n        /// @return The size of the vertex data buffer.\n        ///\n        u32 GetVertexDataSize() const noexcept { return m_vertexDataSize; }\n        \n        /// @return The index data buffer.\n        ///\n        const u8* GetIndexData() const noexcept { return m_indexData.get(); }\n        \n        /// Moves the Index data out of this class. Use with caution as this command\n        /// will be in a broken state after this is used.\n        ///\n        /// @return The index data buffer.\n        ///\n        std::unique_ptr<const u8[]> ClaimIndexData() noexcept;\n        \n        /// @return The size of the index data buffer.\n        ///\n        u32 GetIndexDataSize() const noexcept { return m_indexDataSize; }\n        \n    private:\n        friend class RenderCommandList;\n        \n        /// Constructs a new instance with the given render mesh and mesh data.\n        ///\n        /// @param renderMesh\n        ///     The render mesh that should be loaded.\n        /// @param vertexData\n        ///     The vertex data buffer.\n        /// @param vertexDataSize\n        ///     The size of the vertex data buffer.\n        /// @param indexData\n        ///     The index data buffer.\n        /// @param indexDataSize\n        ///     The size of the index data buffer.\n        ///\n        LoadMeshRenderCommand(RenderMesh* renderMesh, std::unique_ptr<const u8[]> vertexData, u32 vertexDataSize, std::unique_ptr<const u8[]> indexData, u32 indexDataSize) noexcept;\n        \n        RenderMesh* m_renderMesh;\n        std::unique_ptr<const u8[]> m_vertexData;\n        u32 m_vertexDataSize;\n        std::unique_ptr<const u8[]> m_indexData;\n        u32 m_indexDataSize;\n        bool m_shouldBackupData = false;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/RenderCommand/Commands/LoadShaderRenderCommand.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/RenderCommand/Commands/LoadShaderRenderCommand.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    LoadShaderRenderCommand::LoadShaderRenderCommand(RenderShader* renderShader, const std::string& vertexShader, const std::string& fragmentShader) noexcept\n        : RenderCommand(Type::k_loadShader), m_renderShader(renderShader), m_vertexShader(vertexShader), m_fragmentShader(fragmentShader)\n    {\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/RenderCommand/Commands/LoadShaderRenderCommand.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_RENDERCOMMAND_COMMANDS_LOADSHADERRENDERCOMMAND_H_\n#define _CHILLISOURCE_RENDERING_RENDERCOMMAND_COMMANDS_LOADSHADERRENDERCOMMAND_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Rendering/RenderCommand/RenderCommand.h>\n#include <ChilliSource/Rendering/Shader/RenderShader.h>\n\nnamespace ChilliSource\n{\n    /// A render command for loading a single shader.\n    ///\n    /// This must be instantiated via a RenderCommandList.\n    ///\n    /// This is immutable and therefore thread-safe.\n    ///\n    class LoadShaderRenderCommand final : public RenderCommand\n    {\n    public:\n        /// @return The render shader that should be loaded.\n        ///\n        RenderShader* GetRenderShader() const noexcept { return m_renderShader; };\n        \n        /// @return The vertex shader string.\n        ///\n        const std::string& GetVertexShader() const noexcept { return m_vertexShader; }\n        \n        /// @return The fragment shader string.\n        ///\n        const std::string& GetFragmentShader() const noexcept { return m_fragmentShader; }\n        \n    private:\n        friend class RenderCommandList;\n        \n        /// Constructs a new instance with the given vertex and fragment shader.\n        ///\n        /// @param renderShader\n        ///     The render shader that should be loaded.\n        /// @param vertexShader\n        ///     The vertex shader string.\n        /// @param fragmentShader\n        ///     The fragment shader string.\n        ///\n        LoadShaderRenderCommand(RenderShader* renderShader, const std::string& vertexShader, const std::string& fragmentShader) noexcept;\n        \n        RenderShader* m_renderShader;\n        std::string m_vertexShader;\n        std::string m_fragmentShader;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/RenderCommand/Commands/LoadTargetGroupRenderCommand.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/RenderCommand/Commands/LoadTargetGroupRenderCommand.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    LoadTargetGroupRenderCommand::LoadTargetGroupRenderCommand(RenderTargetGroup* renderTargetGroup) noexcept\n        : RenderCommand(Type::k_loadTargetGroup), m_renderTargetGroup(renderTargetGroup)\n    {\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/RenderCommand/Commands/LoadTargetGroupRenderCommand.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_RENDERCOMMAND_COMMANDS_LOADTARGETGROUPRENDERCOMMAND_H_\n#define _CHILLISOURCE_RENDERING_RENDERCOMMAND_COMMANDS_LOADTARGETGROUPRENDERCOMMAND_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Rendering/RenderCommand/RenderCommand.h>\n#include <ChilliSource/Rendering/Target/RenderTargetGroup.h>\n\nnamespace ChilliSource\n{\n    /// A render command for loading the data pertaining to a single render target group.\n    ///\n    /// This must be instantiated via a RenderCommandList.\n    ///\n    /// This is immutable and therefore thread-safe.\n    ///\n    class LoadTargetGroupRenderCommand final : public RenderCommand\n    {\n    public:\n        /// @return The render target that should be loaded.\n        ///\n        RenderTargetGroup* GetRenderTargetGroup() const noexcept { return m_renderTargetGroup; }\n        \n    private:\n        friend class RenderCommandList;\n        \n        /// Constructs a new instance with the given render render target group.\n        ///\n        /// @param renderTargetGroup\n        ///     The render target group that should be loaded.\n        ///\n        LoadTargetGroupRenderCommand(RenderTargetGroup* renderTargetGroup) noexcept;\n        \n        RenderTargetGroup* m_renderTargetGroup;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/RenderCommand/Commands/LoadTextureRenderCommand.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/RenderCommand/Commands/LoadTextureRenderCommand.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    LoadTextureRenderCommand::LoadTextureRenderCommand(RenderTexture* renderTexture, std::unique_ptr<const u8[]> textureData, u32 textureDataSize) noexcept\n        : RenderCommand(Type::k_loadTexture), m_renderTexture(renderTexture), m_textureData(std::move(textureData)), m_textureDataSize(textureDataSize)\n    {\n    }\n    //------------------------------------------------------------------------------\n    std::unique_ptr<const u8[]> LoadTextureRenderCommand::ClaimTextureData() noexcept\n    {\n        CS_ASSERT(m_textureData, \"Cannot claim nullptr data! Data may have already been claimed.\");\n        return std::move(m_textureData);\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/RenderCommand/Commands/LoadTextureRenderCommand.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_RENDERCOMMAND_COMMANDS_LOADTEXTURERENDERCOMMAND_H_\n#define _CHILLISOURCE_RENDERING_RENDERCOMMAND_COMMANDS_LOADTEXTURERENDERCOMMAND_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Rendering/RenderCommand/RenderCommand.h>\n#include <ChilliSource/Rendering/Texture/RenderTexture.h>\n\nnamespace ChilliSource\n{\n    /// A render command for loading the texture data pertaining to a single render texture into\n    /// render memory.\n    ///\n    /// This must be instantiated via a RenderCommandList.\n    ///\n    /// This is immutable and therefore thread-safe.\n    ///\n    class LoadTextureRenderCommand final : public RenderCommand\n    {\n    public:\n        /// @return The render texture that should be loaded.\n        ///\n        RenderTexture* GetRenderTexture() const noexcept { return m_renderTexture; };\n        \n        /// @return The data describing the texture.\n        ///\n        const u8* GetTextureData() const noexcept { return m_textureData.get(); }\n        \n        /// Moves the texture data out of this class. Use with caution as this command\n        /// will be in a broken state after this is used.\n        ///\n        /// @return The data describing the texture.\n        ///\n        std::unique_ptr<const u8[]> ClaimTextureData() noexcept;\n        \n        /// @return The size of the texture data in bytes.\n        ///\n        u32 GetTextureDataSize() const noexcept { return m_textureDataSize; }\n        \n    private:\n        friend class RenderCommandList;\n        \n        /// Constructs a new instance with the given render texture and texture data.\n        ///\n        /// @param renderTexture\n        ///     The render texture that should be loaded.\n        /// @param textureData\n        ///     The data describing the texture.\n        /// @param textureDataSize\n        ///     The size of the texture data in bytes.\n        ///\n        LoadTextureRenderCommand(RenderTexture* renderTexture, std::unique_ptr<const u8[]> textureData, u32 textureDataSize) noexcept;\n        \n        RenderTexture* m_renderTexture;\n        std::unique_ptr<const u8[]> m_textureData;\n        u32 m_textureDataSize;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/RenderCommand/Commands/RenderInstanceRenderCommand.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/RenderCommand/Commands/RenderInstanceRenderCommand.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    RenderInstanceRenderCommand::RenderInstanceRenderCommand(const Matrix4& worldMatrix) noexcept\n        : RenderCommand(Type::k_renderInstance), m_worldMatrix(worldMatrix)\n    {\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/RenderCommand/Commands/RenderInstanceRenderCommand.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_RENDERCOMMAND_COMMANDS_RENDERINSTANCERENDERCOMMAND_H_\n#define _CHILLISOURCE_RENDERING_RENDERCOMMAND_COMMANDS_RENDERINSTANCERENDERCOMMAND_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Math/Matrix4.h>\n#include <ChilliSource/Rendering/RenderCommand/RenderCommand.h>\n\nnamespace ChilliSource\n{\n    /// A render command for rendering an instance of the mesh currently described by the\n    /// context state with the given world trasform.\n    ///\n    /// This must be instantiated via a RenderCommandList.\n    ///\n    /// This is immutable and therefore thread-safe.\n    ///\n    class RenderInstanceRenderCommand final : public RenderCommand\n    {\n    public:\n        /// @return The world matrix of the instance.\n        ///\n        const Matrix4& GetWorldMatrix() const noexcept { return m_worldMatrix; };\n        \n    private:\n        friend class RenderCommandList;\n        \n        /// Creates a new command with the given world matrix.\n        ///\n        /// @param renderMesh\n        ///     The world matrix of the instance.\n        ///\n        RenderInstanceRenderCommand(const Matrix4& worldMatrix) noexcept;\n        \n        Matrix4 m_worldMatrix;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/RenderCommand/Commands/RestoreCubemapRenderCommand.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/RenderCommand/Commands/RestoreCubemapRenderCommand.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    RestoreCubemapRenderCommand::RestoreCubemapRenderCommand(const RenderTexture* renderTexture) noexcept\n        : RenderCommand(Type::k_restoreCubemap), m_renderTexture(renderTexture)\n    {\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/RenderCommand/Commands/RestoreCubemapRenderCommand.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_RENDERCOMMAND_COMMANDS_RESTORECUBEMAPRENDERCOMMAND_H_\n#define _CHILLISOURCE_RENDERING_RENDERCOMMAND_COMMANDS_RESTORECUBEMAPRENDERCOMMAND_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Rendering/RenderCommand/RenderCommand.h>\n\nnamespace ChilliSource\n{\n    /// A render command for restoring a cubemap from cached memory. A restore command\n    /// that is issued on a render texture without a backup will use empty data.\n    ///\n    /// This must be instantiated via a RenderCommandList.\n    ///\n    /// This is immutable and therefore thread-safe.\n    ///\n    class RestoreCubemapRenderCommand final : public RenderCommand\n    {\n    public:\n        \n        /// Creates a new instance with the given texture to restore.\n        ///\n        /// @param renderTexture\n        ///     The render texture to restore.\n        ///\n        RestoreCubemapRenderCommand(const RenderTexture* renderMesh) noexcept;\n        \n        /// @return The render material to apply.\n        ///\n        const RenderTexture* GetRenderTexture() const noexcept { return m_renderTexture; };\n        \n    private:\n        \n        const RenderTexture* m_renderTexture;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/RenderCommand/Commands/RestoreMeshRenderCommand.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/RenderCommand/Commands/RestoreMeshRenderCommand.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    RestoreMeshRenderCommand::RestoreMeshRenderCommand(const RenderMesh* renderMesh) noexcept\n        : RenderCommand(Type::k_restoreMesh), m_renderMesh(renderMesh)\n    {\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/RenderCommand/Commands/RestoreMeshRenderCommand.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_RENDERCOMMAND_COMMANDS_RESTOREMESHRENDERCOMMAND_H_\n#define _CHILLISOURCE_RENDERING_RENDERCOMMAND_COMMANDS_RESTOREMESHRENDERCOMMAND_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Rendering/RenderCommand/RenderCommand.h>\n\nnamespace ChilliSource\n{\n    /// A render command for restoring a mesh from cached memory. A restore command\n    /// should only be issued for a mesh that has had its contexts backed up at creation,\n    /// otherwise this command will assert when applied.\n    ///\n    /// This must be instantiated via a RenderCommandList.\n    ///\n    /// This is immutable and therefore thread-safe.\n    ///\n    class RestoreMeshRenderCommand final : public RenderCommand\n    {\n    public:\n        \n        /// Creates a new instance with the given mesh to restore.\n        ///\n        /// @param renderMesh\n        ///     The render mesh to restore.\n        ///\n        RestoreMeshRenderCommand(const RenderMesh* renderMesh) noexcept;\n        \n        /// @return The render material to apply.\n        ///\n        const RenderMesh* GetRenderMesh() const noexcept { return m_renderMesh; };\n        \n    private:\n        \n        const RenderMesh* m_renderMesh;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/RenderCommand/Commands/RestoreRenderTargetGroupCommand.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/RenderCommand/Commands/RestoreRenderTargetGroupCommand.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    RestoreRenderTargetGroupCommand::RestoreRenderTargetGroupCommand(const RenderTargetGroup* renderTargetGroup) noexcept\n        : RenderCommand(Type::k_restoreRenderTargetGroup), m_renderTargetGroup(renderTargetGroup)\n    {\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/RenderCommand/Commands/RestoreRenderTargetGroupCommand.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_RENDERCOMMAND_COMMANDS_RESTORERENDERTARGETGROUPCOMMAND_H_\n#define _CHILLISOURCE_RENDERING_RENDERCOMMAND_COMMANDS_RESTORERENDERTARGETGROUPCOMMAND_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Rendering/RenderCommand/RenderCommand.h>\n\nnamespace ChilliSource\n{\n    /// A render command for restoring a TargetRenderGroup.\n    ///\n    /// This must be instantiated via a RenderCommandList.\n    ///\n    /// This is immutable and therefore thread-safe.\n    ///\n    class RestoreRenderTargetGroupCommand final : public RenderCommand\n    {\n    public:\n        \n        /// Creates a new instance with the given RenderTargetGroup to restore.\n        ///\n        /// @param renderGroup\n        ///     The render target group to restore.\n        ///\n        RestoreRenderTargetGroupCommand(const RenderTargetGroup* renderGroup) noexcept;\n        \n        /// @return The render target group to restore.\n        ///\n        const RenderTargetGroup* GetTargetRenderGroup() const noexcept { return m_renderTargetGroup; };\n        \n    private:\n        \n        const RenderTargetGroup* m_renderTargetGroup = nullptr;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/RenderCommand/Commands/RestoreTextureRenderCommand.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/RenderCommand/Commands/RestoreTextureRenderCommand.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    RestoreTextureRenderCommand::RestoreTextureRenderCommand(const RenderTexture* renderTexture) noexcept\n        : RenderCommand(Type::k_restoreTexture), m_renderTexture(renderTexture)\n    {\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/RenderCommand/Commands/RestoreTextureRenderCommand.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_RENDERCOMMAND_COMMANDS_RESTORETEXTURERENDERCOMMAND_H_\n#define _CHILLISOURCE_RENDERING_RENDERCOMMAND_COMMANDS_RESTORETEXTURERENDERCOMMAND_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Rendering/RenderCommand/RenderCommand.h>\n\nnamespace ChilliSource\n{\n    /// A render command for restoring a texture from cached memory. A restore command\n    /// that is issued on a render texture without a backup will use empty data.\n    ///\n    /// This must be instantiated via a RenderCommandList.\n    ///\n    /// This is immutable and therefore thread-safe.\n    ///\n    class RestoreTextureRenderCommand final : public RenderCommand\n    {\n    public:\n        \n        /// Creates a new instance with the given texture to restore.\n        ///\n        /// @param renderTexture\n        ///     The render texture to restore.\n        ///\n        RestoreTextureRenderCommand(const RenderTexture* renderMesh) noexcept;\n        \n        /// @return The render material to apply.\n        ///\n        const RenderTexture* GetRenderTexture() const noexcept { return m_renderTexture; };\n        \n    private:\n        \n        const RenderTexture* m_renderTexture;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/RenderCommand/Commands/UnloadCubemapRenderCommand.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/RenderCommand/Commands/UnloadCubemapRenderCommand.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    UnloadCubemapRenderCommand::UnloadCubemapRenderCommand(UniquePtr<RenderTexture> renderTexture) noexcept\n        : RenderCommand(Type::k_unloadCubemap), m_renderTexture(std::move(renderTexture))\n    {\n    }\n    //------------------------------------------------------------------------------\n    UniquePtr<RenderTexture> UnloadCubemapRenderCommand::ClaimRenderTexture() noexcept\n    {\n        CS_ASSERT(m_renderTexture, \"Cannot claim nullptr data! Data may have already been claimed.\");\n        return std::move(m_renderTexture);\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/RenderCommand/Commands/UnloadCubemapRenderCommand.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_RENDERCOMMAND_COMMANDS_UNLOADCUBEMAPRENDERCOMMAND_H_\n#define _CHILLISOURCE_RENDERING_RENDERCOMMAND_COMMANDS_UNLOADCUBEMAPRENDERCOMMAND_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Memory/UniquePtr.h>\n#include <ChilliSource/Rendering/RenderCommand/RenderCommand.h>\n#include <ChilliSource/Rendering/Texture/RenderTexture.h>\n\nnamespace ChilliSource\n{\n    /// A render command for unloading the cubemap data\n    ///\n    /// This must be instantiated via a RenderCommandList.\n    ///\n    /// This is immutable and therefore thread-safe.\n    ///\n    class UnloadCubemapRenderCommand final : public RenderCommand\n    {\n    public:\n        /// @return The render texture that should be unloaded.\n        ///\n        const RenderTexture* GetRenderTexture() const noexcept { return m_renderTexture.get(); };\n    \n        /// Takes ownership of the RenderTexture from this class. This will leave\n        /// this command in an unusable state and should be used with caution.\n        ///\n        /// @return The render texture that should be unloaded.\n        ///\n        UniquePtr<RenderTexture> ClaimRenderTexture() noexcept;\n        \n    private:\n        friend class RenderCommandList;\n        \n        /// Constructs a new instance with the given render texture.\n        ///\n        /// @param renderTexture\n        ///     The render texture that should be unloaded.\n        ///\n        UnloadCubemapRenderCommand(UniquePtr<RenderTexture> renderTexture) noexcept;\n        \n        UniquePtr<RenderTexture> m_renderTexture;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/RenderCommand/Commands/UnloadMaterialGroupRenderCommand.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/RenderCommand/Commands/UnloadMaterialGroupRenderCommand.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    UnloadMaterialGroupRenderCommand::UnloadMaterialGroupRenderCommand(UniquePtr<RenderMaterialGroup> renderMaterialGroup) noexcept\n        : RenderCommand(Type::k_unloadMaterialGroup), m_renderMaterialGroup(std::move(renderMaterialGroup))\n    {\n    }\n    //------------------------------------------------------------------------------\n    UniquePtr<RenderMaterialGroup> UnloadMaterialGroupRenderCommand::ClaimRenderMaterialGroup() noexcept\n    {\n        CS_ASSERT(m_renderMaterialGroup, \"Cannot claim nullptr data! Data may have already been claimed.\");\n        return std::move(m_renderMaterialGroup);\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/RenderCommand/Commands/UnloadMaterialGroupRenderCommand.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_RENDERCOMMAND_COMMANDS_UNLOADMATERIALGROUPRENDERCOMMAND_H_\n#define _CHILLISOURCE_RENDERING_RENDERCOMMAND_COMMANDS_UNLOADMATERIALGROUPRENDERCOMMAND_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Memory/UniquePtr.h>\n#include <ChilliSource/Rendering/RenderCommand/RenderCommand.h>\n#include <ChilliSource/Rendering/Material/RenderMaterialGroup.h>\n\nnamespace ChilliSource\n{\n    /// A render command for unloading the data pertaining to a single render material group.\n    ///\n    /// This must be instantiated via a RenderCommandList.\n    ///\n    /// This is immutable and therefore thread-safe.\n    ///\n    class UnloadMaterialGroupRenderCommand final : public RenderCommand\n    {\n    public:\n        /// @return The render material that should be unloaded.\n        ///\n        RenderMaterialGroup* GetRenderMaterialGroup() const noexcept { return m_renderMaterialGroup.get(); }\n        \n        /// Takes ownership of the RenderMaterialGroup from this class. This will leave\n        /// this command in an unusable state and should be used with caution.\n        ///\n        /// @return The render material group that should be unloaded.\n        ///\n        UniquePtr<RenderMaterialGroup> ClaimRenderMaterialGroup() noexcept;\n        \n    private:\n        friend class RenderCommandList;\n        \n        /// Constructs a new instance with the given render render material group.\n        ///\n        /// @param renderMaterialGroup\n        ///     The render material group that should be unloaded.\n        ///\n        UnloadMaterialGroupRenderCommand(UniquePtr<RenderMaterialGroup> renderMaterialGroup) noexcept;\n        \n        UniquePtr<RenderMaterialGroup> m_renderMaterialGroup;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/RenderCommand/Commands/UnloadMeshRenderCommand.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/RenderCommand/Commands/UnloadMeshRenderCommand.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    UnloadMeshRenderCommand::UnloadMeshRenderCommand(UniquePtr<RenderMesh> renderMesh) noexcept\n        : RenderCommand(Type::k_unloadMesh), m_renderMesh(std::move(renderMesh))\n    {\n    }\n    //------------------------------------------------------------------------------\n    UniquePtr<RenderMesh> UnloadMeshRenderCommand::ClaimRenderMesh() noexcept\n    {\n        CS_ASSERT(m_renderMesh, \"Cannot claim nullptr data! Data may have already been claimed.\");\n        return std::move(m_renderMesh);\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/RenderCommand/Commands/UnloadMeshRenderCommand.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_RENDERCOMMAND_COMMANDS_UNLOADMESHRENDERCOMMAND_H_\n#define _CHILLISOURCE_RENDERING_RENDERCOMMAND_COMMANDS_UNLOADMESHRENDERCOMMAND_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Memory/UniquePtr.h>\n#include <ChilliSource/Rendering/RenderCommand/RenderCommand.h>\n#include <ChilliSource/Rendering/Model/RenderMesh.h>\n\nnamespace ChilliSource\n{\n    /// A render command for unloading the mesh data pertaining to a single render mesh from\n    /// render memory.\n    ///\n    /// This must be instantiated via a RenderCommandList.\n    ///\n    /// This is immutable and therefore thread-safe.\n    ///\n    class UnloadMeshRenderCommand final : public RenderCommand\n    {\n    public:\n        /// @return The render mesh that should be unloaded.\n        ///\n        const RenderMesh* GetRenderMesh() const noexcept { return m_renderMesh.get(); }\n        \n        /// Takes ownership of the RenderMesh from this class. This will leave\n        /// this command in an unusable state and should be used with caution.\n        ///\n        /// @return The render mesh that should be unloaded.\n        ///\n        UniquePtr<RenderMesh> ClaimRenderMesh() noexcept;\n        \n    private:\n        friend class RenderCommandList;\n        \n        /// Constructs a new instance with the given render mesh.\n        ///\n        /// @param renderMesh\n        ///     The render mesh that should be unloaded.\n        ///\n        UnloadMeshRenderCommand(UniquePtr<RenderMesh> renderMesh) noexcept;\n        \n        UniquePtr<RenderMesh> m_renderMesh;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/RenderCommand/Commands/UnloadShaderRenderCommand.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/RenderCommand/Commands/UnloadShaderRenderCommand.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    UnloadShaderRenderCommand::UnloadShaderRenderCommand(UniquePtr<RenderShader> renderShader) noexcept\n        : RenderCommand(Type::k_unloadShader), m_renderShader(std::move(renderShader))\n    {\n    }\n    //------------------------------------------------------------------------------\n    UniquePtr<RenderShader> UnloadShaderRenderCommand::ClaimRenderShader() noexcept\n    {\n        CS_ASSERT(m_renderShader, \"Cannot claim nullptr data! Data may have already been claimed.\");\n        return std::move(m_renderShader);\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/RenderCommand/Commands/UnloadShaderRenderCommand.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_RENDERCOMMAND_COMMANDS_UNLOADSHADERRENDERCOMMAND_H_\n#define _CHILLISOURCE_RENDERING_RENDERCOMMAND_COMMANDS_UNLOADSHADERRENDERCOMMAND_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Memory/UniquePtr.h>\n#include <ChilliSource/Rendering/RenderCommand/RenderCommand.h>\n#include <ChilliSource/Rendering/Shader/RenderShader.h>\n\nnamespace ChilliSource\n{\n    /// A render command for unloading a single shader.\n    ///\n    /// This must be instantiated via a RenderCommandList.\n    ///\n    /// This is immutable and therefore thread-safe.\n    ///\n    class UnloadShaderRenderCommand final : public RenderCommand\n    {\n    public:\n        /// @return The render shader that should be unloaded.\n        ///\n        const RenderShader* GetRenderShader() const noexcept { return m_renderShader.get(); };\n        \n        /// Takes ownership of the RenderShader from this class. This will leave\n        /// this command in an unusable state and should be used with caution.\n        ///\n        /// @return The render shader that should be unloaded.\n        ///\n        UniquePtr<RenderShader> ClaimRenderShader() noexcept;\n        \n    private:\n        friend class RenderCommandList;\n        \n        /// Constructs a new instance with the render shader.\n        ///\n        /// @param renderShader\n        ///     The render shader that should be unloaded.\n        ///\n        UnloadShaderRenderCommand(UniquePtr<RenderShader> renderShader) noexcept;\n        \n        UniquePtr<RenderShader> m_renderShader;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/RenderCommand/Commands/UnloadTargetGroupRenderCommand.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/RenderCommand/Commands/UnloadTargetGroupRenderCommand.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    UnloadTargetGroupRenderCommand::UnloadTargetGroupRenderCommand(UniquePtr<RenderTargetGroup> renderTargetGroup) noexcept\n    : RenderCommand(Type::k_unloadTargetGroup), m_renderTargetGroup(std::move(renderTargetGroup))\n    {\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/RenderCommand/Commands/UnloadTargetGroupRenderCommand.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_RENDERCOMMAND_COMMANDS_UNLOADTARGETGROUPRENDERCOMMAND_H_\n#define _CHILLISOURCE_RENDERING_RENDERCOMMAND_COMMANDS_UNLOADTARGETGROUPRENDERCOMMAND_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Memory/UniquePtr.h>\n#include <ChilliSource/Rendering/RenderCommand/RenderCommand.h>\n#include <ChilliSource/Rendering/Target/RenderTargetGroup.h>\n\nnamespace ChilliSource\n{\n    /// A render command for unloading the data pertaining to a single render target group.\n    ///\n    /// This must be instantiated via a RenderCommandList.\n    ///\n    /// This is immutable and therefore thread-safe.\n    ///\n    class UnloadTargetGroupRenderCommand final : public RenderCommand\n    {\n    public:\n        /// @return The render target that should be unloaded.\n        ///\n        RenderTargetGroup* GetRenderTargetGroup() const noexcept { return m_renderTargetGroup.get(); }\n        \n    private:\n        friend class RenderCommandList;\n        \n        /// Constructs a new instance with the given render render target group.\n        ///\n        /// @param renderTargetGroup\n        ///     The render target group that should be unloaded.\n        ///\n        UnloadTargetGroupRenderCommand(UniquePtr<RenderTargetGroup> renderTargetGroup) noexcept;\n        \n        UniquePtr<RenderTargetGroup> m_renderTargetGroup;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/RenderCommand/Commands/UnloadTextureRenderCommand.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/RenderCommand/Commands/UnloadTextureRenderCommand.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    UnloadTextureRenderCommand::UnloadTextureRenderCommand(UniquePtr<RenderTexture> renderTexture) noexcept\n        : RenderCommand(Type::k_unloadTexture), m_renderTexture(std::move(renderTexture))\n    {\n    }\n    //------------------------------------------------------------------------------\n    UniquePtr<RenderTexture> UnloadTextureRenderCommand::ClaimRenderTexture() noexcept\n    {\n        CS_ASSERT(m_renderTexture, \"Cannot claim nullptr data! Data may have already been claimed.\");\n        return std::move(m_renderTexture);\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/RenderCommand/Commands/UnloadTextureRenderCommand.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_RENDERCOMMAND_COMMANDS_UNLOADTEXTURERENDERCOMMAND_H_\n#define _CHILLISOURCE_RENDERING_RENDERCOMMAND_COMMANDS_UNLOADTEXTURERENDERCOMMAND_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Memory/UniquePtr.h>\n#include <ChilliSource/Rendering/RenderCommand/RenderCommand.h>\n#include <ChilliSource/Rendering/Texture/RenderTexture.h>\n\nnamespace ChilliSource\n{\n    /// A render command for unloading the texture data for a single render texture from\n    /// render memory.\n    ///\n    /// This must be instantiated via a RenderCommandList.\n    ///\n    /// This is immutable and therefore thread-safe.\n    ///\n    class UnloadTextureRenderCommand final : public RenderCommand\n    {\n    public:\n        /// @return The render texture that should be unloaded.\n        ///\n        const RenderTexture* GetRenderTexture() const noexcept { return m_renderTexture.get(); };\n    \n        /// Takes ownership of the RenderTexture from this class. This will leave\n        /// this command in an unusable state and should be used with caution.\n        ///\n        /// @return The render texture that should be unloaded.\n        ///\n        UniquePtr<RenderTexture> ClaimRenderTexture() noexcept;\n        \n    private:\n        friend class RenderCommandList;\n        \n        /// Constructs a new instance with the given render texture.\n        ///\n        /// @param renderTexture\n        ///     The render texture that should be unloaded.\n        ///\n        UnloadTextureRenderCommand(UniquePtr<RenderTexture> renderTexture) noexcept;\n        \n        UniquePtr<RenderTexture> m_renderTexture;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/RenderCommand/RenderCommand.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/RenderCommand/RenderCommand.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    RenderCommand::RenderCommand(Type type) noexcept\n        : m_type(type)\n    {\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/RenderCommand/RenderCommand.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_RENDERCOMMAND_RENDERCOMMAND_H_\n#define _CHILLISOURCE_RENDERING_RENDERCOMMAND_RENDERCOMMAND_H_\n\n#include <ChilliSource/ChilliSource.h>\n\nnamespace ChilliSource\n{\n\n    /// The base class for render commands. This is required for type erasure so that render\n    /// disparate render commands can be stored in the same container. A render command contains\n    /// a type, which can be used to safely cast down to the concrete type, without the need for\n    /// virtual calls or RTTI.\n    ///\n    /// Render commands should be instantiated within a RenderCommandList.\n    ///\n    /// A render command should be immutable and therefore thread safe.\n    ///\n    class RenderCommand\n    {\n    public:\n        /// An enum which describes the various different types of render command.\n        ///\n        enum class Type\n        {\n            k_loadTexture,\n            k_loadCubemap,\n            k_loadShader,\n            k_loadMaterialGroup,\n            k_loadMesh,\n            k_restoreTexture,\n            k_restoreCubemap,\n            k_restoreMesh,\n            k_restoreRenderTargetGroup,\n            k_loadTargetGroup,\n            k_begin,\n            k_beginWithTargetGroup,\n            k_applyCamera,\n            k_applyAmbientLight,\n            k_applyDirectionalLight,\n            k_applyPointLight,\n            k_applyMaterial,\n            k_applyMesh,\n            k_applyDynamicMesh,\n            k_applyMeshBatch,\n            k_applySkinnedAnimation,\n            k_renderInstance,\n            k_end,\n            k_unloadTargetGroup,\n            k_unloadMesh,\n            k_unloadMaterialGroup,\n            k_unloadShader,\n            k_unloadTexture,\n            k_unloadCubemap\n        };\n        \n        /// @return The type of render command that this is.\n        ///\n        Type GetType() const noexcept { return m_type; }\n        \n        virtual ~RenderCommand() noexcept {}\n        \n    protected:\n        /// Constructs the RenderCommand with the given type.\n        ///\n        /// @param type\n        ///     The type of render command that this describes.\n        ///\n        RenderCommand(Type type) noexcept;\n        \n    private:\n        Type m_type;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/RenderCommand/RenderCommandBuffer.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/RenderCommand/RenderCommandBuffer.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    RenderCommandBuffer::RenderCommandBuffer(u32 numSlots, IAllocator* frameAllocator, std::vector<RenderFrameData> renderFramesData) noexcept\n        : m_renderFramesData(std::move(renderFramesData)), m_frameAllocator(frameAllocator)\n    {\n        m_renderCommandLists.reserve(numSlots);\n        for (u32 i = 0; i < numSlots; ++i)\n        {\n            m_renderCommandLists.push_back(RenderCommandListUPtr(new RenderCommandList()));\n        }\n        \n        m_queue.reserve(numSlots);\n        for (const auto& renderCommandList : m_renderCommandLists)\n        {\n            m_queue.push_back(renderCommandList.get());\n        }\n    }\n    \n    //------------------------------------------------------------------------------\n    RenderCommandList* RenderCommandBuffer::GetRenderCommandList(u32 slotIndex) noexcept\n    {\n        CS_ASSERT(slotIndex < GetNumSlots(), \"Index out of bounds.\");\n        \n        return m_renderCommandLists[slotIndex].get();\n    }\n}"
  },
  {
    "path": "Source/ChilliSource/Rendering/RenderCommand/RenderCommandBuffer.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_RENDERCOMMAND_RENDERCOMMANDQUEUE_H_\n#define _CHILLISOURCE_RENDERING_RENDERCOMMAND_RENDERCOMMANDQUEUE_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Rendering/Base/RenderFrameData.h>\n#include <ChilliSource/Rendering/Model/RenderDynamicMesh.h>\n#include <ChilliSource/Rendering/Model/RenderSkinnedAnimation.h>\n#include <ChilliSource/Rendering/RenderCommand/RenderCommandList.h>\n\n#include <vector>\n\nnamespace ChilliSource\n{\n    /// Provides the ability to create a buffer of Render Command Lists. By creating and ordering\n    /// all of the Render Command Lists up front, the Render Command Lists can be safely\n    /// populated on separate threads without locking.\n    ///\n    /// This also holds frame data required by commands to ensure that the data exists for as long\n    /// as the commands require them.\n    ///\n    /// This is not thread-safe but can be safely used accross threads as long as each thread\n    /// only accessed one queue slot.\n    ///\n    class RenderCommandBuffer final\n    {\n    public:\n        CS_DECLARE_NOCOPY(RenderCommandBuffer);\n        \n        RenderCommandBuffer(RenderCommandBuffer&&) = default;\n        RenderCommandBuffer& operator=(RenderCommandBuffer&&) = default;\n        \n        /// Creates a new render command buffer with the requested number of slots.\n        ///\n        /// @param numSlots\n        ///     The number of slots in the queue.\n        /// @param frameAllocator\n        ///     The allocator used for this render frame\n        /// @param renderFramesData\n        ///     The render frame data that must persist to the end of the frame. Must be moved.\n        ///\n        RenderCommandBuffer(u32 numSlots, IAllocator* frameAllocator, std::vector<RenderFrameData> renderFramesData) noexcept;\n        \n        /// @return The allocator from which all frame allocations should occur.\n        ///\n        IAllocator* GetFrameAllocator() const noexcept { return m_frameAllocator; }\n        \n        /// @return The number of slots in the queue.\n        ///\n        u32 GetNumSlots() const noexcept { return u32(m_queue.size()); }\n        \n        /// @param slotIndex\n        ///     The requested slot index.\n        ///\n        /// @return The RenderCommandList at the requested slot index.\n        ///\n        RenderCommandList* GetRenderCommandList(u32 slotIndex) noexcept;\n        \n        /// @return The queue of command lists.\n        ///\n        const std::vector<const RenderCommandList*>& GetQueue() const noexcept { return m_queue; }\n        \n    private:\n        std::vector<RenderDynamicMeshAUPtr> m_renderDynamicMeshes;\n        std::vector<RenderSkinnedAnimationAUPtr> m_renderSkinnedAnimations;\n        std::vector<const RenderCommandList*> m_queue;\n        std::vector<RenderCommandListUPtr> m_renderCommandLists; //TODO: This should be changed to a pool.\n        const std::vector<RenderFrameData> m_renderFramesData;\n        IAllocator* m_frameAllocator;\n    };\n}\n\n#endif"
  },
  {
    "path": "Source/ChilliSource/Rendering/RenderCommand/RenderCommandList.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/RenderCommand/RenderCommandList.h>\n\n#include <ChilliSource/Rendering/RenderCommand/Commands/ApplyAmbientLightRenderCommand.h>\n#include <ChilliSource/Rendering/RenderCommand/Commands/ApplyCameraRenderCommand.h>\n#include <ChilliSource/Rendering/RenderCommand/Commands/ApplyDirectionalLightRenderCommand.h>\n#include <ChilliSource/Rendering/RenderCommand/Commands/ApplyDynamicMeshRenderCommand.h>\n#include <ChilliSource/Rendering/RenderCommand/Commands/ApplyMaterialRenderCommand.h>\n#include <ChilliSource/Rendering/RenderCommand/Commands/ApplyMeshRenderCommand.h>\n#include <ChilliSource/Rendering/RenderCommand/Commands/ApplyMeshBatchRenderCommand.h>\n#include <ChilliSource/Rendering/RenderCommand/Commands/ApplyPointLightRenderCommand.h>\n#include <ChilliSource/Rendering/RenderCommand/Commands/ApplySkinnedAnimationRenderCommand.h>\n#include <ChilliSource/Rendering/RenderCommand/Commands/BeginRenderCommand.h>\n#include <ChilliSource/Rendering/RenderCommand/Commands/BeginWithTargetGroupRenderCommand.h>\n#include <ChilliSource/Rendering/RenderCommand/Commands/EndRenderCommand.h>\n#include <ChilliSource/Rendering/RenderCommand/Commands/LoadMaterialGroupRenderCommand.h>\n#include <ChilliSource/Rendering/RenderCommand/Commands/LoadMeshRenderCommand.h>\n#include <ChilliSource/Rendering/RenderCommand/Commands/LoadShaderRenderCommand.h>\n#include <ChilliSource/Rendering/RenderCommand/Commands/LoadTargetGroupRenderCommand.h>\n#include <ChilliSource/Rendering/RenderCommand/Commands/LoadTextureRenderCommand.h>\n#include <ChilliSource/Rendering/RenderCommand/Commands/LoadCubemapRenderCommand.h>\n#include <ChilliSource/Rendering/RenderCommand/Commands/RenderInstanceRenderCommand.h>\n#include <ChilliSource/Rendering/RenderCommand/Commands/RestoreMeshRenderCommand.h>\n#include <ChilliSource/Rendering/RenderCommand/Commands/RestoreRenderTargetGroupCommand.h>\n#include <ChilliSource/Rendering/RenderCommand/Commands/RestoreTextureRenderCommand.h>\n#include <ChilliSource/Rendering/RenderCommand/Commands/RestoreCubemapRenderCommand.h>\n#include <ChilliSource/Rendering/RenderCommand/Commands/UnloadMaterialGroupRenderCommand.h>\n#include <ChilliSource/Rendering/RenderCommand/Commands/UnloadMeshRenderCommand.h>\n#include <ChilliSource/Rendering/RenderCommand/Commands/UnloadShaderRenderCommand.h>\n#include <ChilliSource/Rendering/RenderCommand/Commands/UnloadTargetGroupRenderCommand.h>\n#include <ChilliSource/Rendering/RenderCommand/Commands/UnloadTextureRenderCommand.h>\n#include <ChilliSource/Rendering/RenderCommand/Commands/UnloadCubemapRenderCommand.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    void RenderCommandList::AddLoadShaderCommand(RenderShader* renderShader, const std::string& vertexShader, const std::string& fragmentShader) noexcept\n    {\n        RenderCommandUPtr renderCommand(new LoadShaderRenderCommand(renderShader, vertexShader, fragmentShader));\n        \n        m_orderedCommands.push_back(renderCommand.get());\n        m_renderCommands.push_back(std::move(renderCommand));\n    }\n    \n    //------------------------------------------------------------------------------\n    void RenderCommandList::AddLoadTextureCommand(RenderTexture* renderTexture, std::unique_ptr<const u8[]> textureData, u32 textureDataSize) noexcept\n    {\n        RenderCommandUPtr renderCommand(new LoadTextureRenderCommand(renderTexture, std::move(textureData), textureDataSize));\n        \n        m_orderedCommands.push_back(renderCommand.get());\n        m_renderCommands.push_back(std::move(renderCommand));\n    }\n    \n    //------------------------------------------------------------------------------\n    void RenderCommandList::AddLoadCubemapCommand(RenderTexture* renderTexture, std::array<std::unique_ptr<const u8[]>, 6> textureData, u32 textureDataSize) noexcept\n    {\n        RenderCommandUPtr renderCommand(new LoadCubemapRenderCommand(renderTexture, std::move(textureData), textureDataSize));\n        \n        m_orderedCommands.push_back(renderCommand.get());\n        m_renderCommands.push_back(std::move(renderCommand));\n    }\n    \n    //------------------------------------------------------------------------------\n    void RenderCommandList::AddLoadMaterialGroupCommand(RenderMaterialGroup* renderMaterialGroup) noexcept\n    {\n        RenderCommandUPtr renderCommand(new LoadMaterialGroupRenderCommand(renderMaterialGroup));\n        \n        m_orderedCommands.push_back(renderCommand.get());\n        m_renderCommands.push_back(std::move(renderCommand));\n    }\n    \n    //------------------------------------------------------------------------------\n    void RenderCommandList::AddLoadMeshCommand(RenderMesh* renderMesh, std::unique_ptr<const u8[]> vertexData, u32 vertexDataSize, std::unique_ptr<const u8[]> indexData, u32 indexDataSize) noexcept\n    {\n        RenderCommandUPtr renderCommand(new LoadMeshRenderCommand(renderMesh, std::move(vertexData), vertexDataSize, std::move(indexData), indexDataSize));\n        \n        m_orderedCommands.push_back(renderCommand.get());\n        m_renderCommands.push_back(std::move(renderCommand));\n    }\n    \n    //------------------------------------------------------------------------------\n    void RenderCommandList::AddRestoreTextureCommand(const RenderTexture* renderTexture) noexcept\n    {\n        RenderCommandUPtr renderCommand(new RestoreTextureRenderCommand(renderTexture));\n        \n        m_orderedCommands.push_back(renderCommand.get());\n        m_renderCommands.push_back(std::move(renderCommand));\n    }\n    \n    //------------------------------------------------------------------------------\n    void RenderCommandList::AddRestoreCubemapCommand(const RenderTexture* renderTexture) noexcept\n    {\n        RenderCommandUPtr renderCommand(new RestoreCubemapRenderCommand(renderTexture));\n        \n        m_orderedCommands.push_back(renderCommand.get());\n        m_renderCommands.push_back(std::move(renderCommand));\n    }\n    \n    //------------------------------------------------------------------------------\n    void RenderCommandList::AddRestoreMeshCommand(const RenderMesh* renderMesh) noexcept\n    {\n        RenderCommandUPtr renderCommand(new RestoreMeshRenderCommand(renderMesh));\n\n        m_orderedCommands.push_back(renderCommand.get());\n        m_renderCommands.push_back(std::move(renderCommand));\n    }\n    \n    //------------------------------------------------------------------------------\n    void RenderCommandList::AddRestoreRenderTargetGroupCommand(const RenderTargetGroup* renderTargetGroup) noexcept\n    {\n        RenderCommandUPtr renderCommand(new RestoreRenderTargetGroupCommand(renderTargetGroup));\n        \n        m_orderedCommands.push_back(renderCommand.get());\n        m_renderCommands.push_back(std::move(renderCommand));\n    }\n    \n    //------------------------------------------------------------------------------\n    void RenderCommandList::AddLoadTargetGroupCommand(RenderTargetGroup* renderTargetGroup) noexcept\n    {\n        RenderCommandUPtr renderCommand(new LoadTargetGroupRenderCommand(renderTargetGroup));\n\n        m_orderedCommands.push_back(renderCommand.get());\n        m_renderCommands.push_back(std::move(renderCommand));\n    }\n    //------------------------------------------------------------------------------\n    void RenderCommandList::AddBeginCommand(const Integer2& resolution, const Colour& clearColour) noexcept\n    {\n        RenderCommandUPtr renderCommand(new BeginRenderCommand(resolution, clearColour));\n        \n        m_orderedCommands.push_back(renderCommand.get());\n        m_renderCommands.push_back(std::move(renderCommand));\n    }\n    \n    //------------------------------------------------------------------------------\n    void RenderCommandList::AddBeginWithTargetGroupCommand(const RenderTargetGroup* renderTargetGroup, const Colour& clearColour) noexcept\n    {\n        RenderCommandUPtr renderCommand(new BeginWithTargetGroupRenderCommand(renderTargetGroup, clearColour));\n        \n        m_orderedCommands.push_back(renderCommand.get());\n        m_renderCommands.push_back(std::move(renderCommand));\n    }\n    \n    //------------------------------------------------------------------------------\n    void RenderCommandList::AddApplyCameraCommand(const Vector3& position, const Matrix4& viewMatrix, const Matrix4& viewProjectionMatrix) noexcept\n    {\n        RenderCommandUPtr renderCommand(new ApplyCameraRenderCommand(position, viewMatrix, viewProjectionMatrix));\n        \n        m_orderedCommands.push_back(renderCommand.get());\n        m_renderCommands.push_back(std::move(renderCommand));\n    }\n    \n    //------------------------------------------------------------------------------\n    void RenderCommandList::AddApplyAmbientLightCommand(const Colour& colour) noexcept\n    {\n        RenderCommandUPtr renderCommand(new ApplyAmbientLightRenderCommand(colour));\n        \n        m_orderedCommands.push_back(renderCommand.get());\n        m_renderCommands.push_back(std::move(renderCommand));\n    }\n    \n    //------------------------------------------------------------------------------\n    void RenderCommandList::AddApplyDirectionalLightCommand(const Colour& colour, const Vector3& direction, const Matrix4& lightViewProjection, f32 shadowTolerance, const RenderTexture* shadowMapRenderTexture) noexcept\n    {\n        RenderCommandUPtr renderCommand(new ApplyDirectionalLightRenderCommand(colour, direction, lightViewProjection, shadowTolerance, shadowMapRenderTexture));\n        \n        m_orderedCommands.push_back(renderCommand.get());\n        m_renderCommands.push_back(std::move(renderCommand));\n    }\n    \n    //------------------------------------------------------------------------------\n    void RenderCommandList::AddApplyPointLightCommand(const Colour& colour, const Vector3& position, const Vector3& attenuation) noexcept\n    {\n        RenderCommandUPtr renderCommand(new ApplyPointLightRenderCommand(colour, position, attenuation));\n        \n        m_orderedCommands.push_back(renderCommand.get());\n        m_renderCommands.push_back(std::move(renderCommand));\n    }\n    \n    //------------------------------------------------------------------------------\n    void RenderCommandList::AddApplyMaterialCommand(const RenderMaterial* renderMaterial) noexcept\n    {\n        RenderCommandUPtr renderCommand(new ApplyMaterialRenderCommand(renderMaterial));\n        \n        m_orderedCommands.push_back(renderCommand.get());\n        m_renderCommands.push_back(std::move(renderCommand));\n    }\n    \n    //------------------------------------------------------------------------------\n    void RenderCommandList::AddApplyMeshCommand(const RenderMesh* renderMesh) noexcept\n    {\n        RenderCommandUPtr renderCommand(new ApplyMeshRenderCommand(renderMesh));\n        \n        m_orderedCommands.push_back(renderCommand.get());\n        m_renderCommands.push_back(std::move(renderCommand));\n    }\n    \n    //------------------------------------------------------------------------------\n    void RenderCommandList::AddApplyDynamicMeshCommand(const RenderDynamicMesh* renderDynamicMesh) noexcept\n    {\n        RenderCommandUPtr renderCommand(new ApplyDynamicMeshRenderCommand(renderDynamicMesh));\n        \n        m_orderedCommands.push_back(renderCommand.get());\n        m_renderCommands.push_back(std::move(renderCommand));\n    }\n    \n    //------------------------------------------------------------------------------\n    void RenderCommandList::AddApplyMeshBatchCommand(RenderMeshBatchUPtr renderMeshBatch) noexcept\n    {\n        RenderCommandUPtr renderCommand(new ApplyMeshBatchRenderCommand(std::move(renderMeshBatch)));\n        \n        m_orderedCommands.push_back(renderCommand.get());\n        m_renderCommands.push_back(std::move(renderCommand));\n    }\n    \n    //------------------------------------------------------------------------------\n    void RenderCommandList::AddApplySkinnedAnimationCommand(const RenderSkinnedAnimation* renderSkinnedAnimation) noexcept\n    {\n        RenderCommandUPtr renderCommand(new ApplySkinnedAnimationRenderCommand(renderSkinnedAnimation));\n        \n        m_orderedCommands.push_back(renderCommand.get());\n        m_renderCommands.push_back(std::move(renderCommand));\n    }\n    \n    //------------------------------------------------------------------------------\n    void RenderCommandList::AddRenderInstanceCommand(const Matrix4& worldMatrix) noexcept\n    {\n        RenderCommandUPtr renderCommand(new RenderInstanceRenderCommand(worldMatrix));\n        \n        m_orderedCommands.push_back(renderCommand.get());\n        m_renderCommands.push_back(std::move(renderCommand));\n    }\n    \n    //------------------------------------------------------------------------------\n    void RenderCommandList::AddEndCommand() noexcept\n    {\n        RenderCommandUPtr renderCommand(new EndRenderCommand());\n        \n        m_orderedCommands.push_back(renderCommand.get());\n        m_renderCommands.push_back(std::move(renderCommand));\n    }\n    \n    //------------------------------------------------------------------------------\n    void RenderCommandList::AddUnloadTargetGroupCommand(UniquePtr<RenderTargetGroup> renderTargetGroup) noexcept\n    {\n        RenderCommandUPtr renderCommand(new UnloadTargetGroupRenderCommand(std::move(renderTargetGroup)));\n        \n        m_orderedCommands.push_back(renderCommand.get());\n        m_renderCommands.push_back(std::move(renderCommand));\n    }\n\n    //------------------------------------------------------------------------------\n    void RenderCommandList::AddUnloadMeshCommand(UniquePtr<RenderMesh> renderMesh) noexcept\n    {\n        RenderCommandUPtr renderCommand(new UnloadMeshRenderCommand(std::move(renderMesh)));\n        \n        m_orderedCommands.push_back(renderCommand.get());\n        m_renderCommands.push_back(std::move(renderCommand));\n    }\n    \n    //------------------------------------------------------------------------------\n    void RenderCommandList::AddUnloadMaterialGroupCommand(UniquePtr<RenderMaterialGroup> renderMaterialGroup) noexcept\n    {\n        RenderCommandUPtr renderCommand(new UnloadMaterialGroupRenderCommand(std::move(renderMaterialGroup)));\n        \n        m_orderedCommands.push_back(renderCommand.get());\n        m_renderCommands.push_back(std::move(renderCommand));\n    }\n    \n    //------------------------------------------------------------------------------\n    void RenderCommandList::AddUnloadTextureCommand(UniquePtr<RenderTexture> renderTexture) noexcept\n    {\n        RenderCommandUPtr renderCommand(new UnloadTextureRenderCommand(std::move(renderTexture)));\n        \n        m_orderedCommands.push_back(renderCommand.get());\n        m_renderCommands.push_back(std::move(renderCommand));\n    }\n    \n    //------------------------------------------------------------------------------\n    void RenderCommandList::AddUnloadCubemapCommand(UniquePtr<RenderTexture> renderTexture) noexcept\n    {\n        RenderCommandUPtr renderCommand(new UnloadCubemapRenderCommand(std::move(renderTexture)));\n        \n        m_orderedCommands.push_back(renderCommand.get());\n        m_renderCommands.push_back(std::move(renderCommand));\n    }\n    \n    //------------------------------------------------------------------------------\n    void RenderCommandList::AddUnloadShaderCommand(UniquePtr<RenderShader> renderShader) noexcept\n    {\n        RenderCommandUPtr renderCommand(new UnloadShaderRenderCommand(std::move(renderShader)));\n        \n        m_orderedCommands.push_back(renderCommand.get());\n        m_renderCommands.push_back(std::move(renderCommand));\n    }\n    //------------------------------------------------------------------------------\n    RenderCommand* RenderCommandList::GetCommand(u32 index) noexcept\n    {\n        CS_ASSERT(index < GetNumCommands(), \"Index out of bounds.\");\n        \n        return m_renderCommands[index].get();\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/RenderCommand/RenderCommandList.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_RENDERCOMMAND_RENDERCOMMANDLIST_H_\n#define _CHILLISOURCE_RENDERING_RENDERCOMMAND_RENDERCOMMANDLIST_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Memory/UniquePtr.h>\n#include <ChilliSource/Rendering/RenderCommand/RenderCommand.h>\n\n#include <array>\n#include <vector>\n\nnamespace ChilliSource\n{\n    /// Provides the ability to create an ordered list of render commands. Commands are\n    /// created contiguously in memory to improve cache locality and reduce fragmentation.\n    ///\n    /// This is not thread-safe and therefore should only be accessed from one thread\n    /// at a time.\n    ///\n    class RenderCommandList final\n    {\n    public:\n        CS_DECLARE_NOCOPY(RenderCommandList);\n        \n        RenderCommandList() = default;\n        RenderCommandList(RenderCommandList&&) = default;\n        RenderCommandList& operator=(RenderCommandList&&) = default;\n        \n        /// Creates and adds a new load shader command to the render command list.\n        ///\n        /// @param renderShader\n        ///     The render shader that should be loaded.\n        /// @param vertexShader\n        ///     The vertex shader string.\n        /// @param fragmentShader\n        ///     The fragment shader string\n        ///\n        void AddLoadShaderCommand(RenderShader* renderShader, const std::string& vertexShader, const std::string& fragmentShader) noexcept;\n        \n        /// Creates and adds a new load texture command to the render command list.\n        ///\n        /// @param renderTexture\n        ///     The render texture that should be loaded.\n        /// @param textureData\n        ///     The data describing the texture.\n        /// @param textureDataSize\n        ///     The size of the texture data in bytes.\n        ///\n        void AddLoadTextureCommand(RenderTexture* renderTexture, std::unique_ptr<const u8[]> textureData, u32 textureDataSize) noexcept;\n        \n        /// Creates and adds a new load cubemap command to the render command list.\n        ///\n        /// @param renderTexture\n        ///     The render texture that should be loaded.\n        /// @param textureData\n        ///     The data describing the texture for each face.\n        /// @param textureDataSize\n        ///     The size of the texture data in bytes.\n        ///\n        void AddLoadCubemapCommand(RenderTexture* renderTexture, std::array<std::unique_ptr<const u8[]>, 6> textureData, u32 textureDataSize) noexcept;\n        \n        /// Creates and adds a new load material group command to the render command list.\n        ///\n        /// @param renderMaterialGroup\n        ///     The RenderMaterialGroup that should be loaded.\n        ///\n        void AddLoadMaterialGroupCommand(RenderMaterialGroup* renderMaterialGroup) noexcept;\n        \n        /// Creates and adds a new load mesh command to the render command list.\n        ///\n        /// @param renderMesh\n        ///     The render mesh that should be loaded.\n        /// @param vertexData\n        ///     The vertex data buffer.\n        /// @param vertexDataSize\n        ///     The size of the vertex data buffer.\n        /// @param indexData\n        ///     The index data buffer.\n        /// @param indexDataSize\n        ///     The size of the index data buffer.\n        ///\n        void AddLoadMeshCommand(RenderMesh* renderMesh, std::unique_ptr<const u8[]> vertexData, u32 vertexDataSize, std::unique_ptr<const u8[]> indexData, u32 indexDataSize) noexcept;\n        \n        /// Creates and adds a new restore texture command to the render command list.\n        ///\n        /// @param renderTexture\n        ///     The render texture that should be restored.\n        ///\n        void AddRestoreTextureCommand(const RenderTexture* renderTexture) noexcept;\n        \n        /// Creates and adds a new restore cubemap command to the render command list.\n        ///\n        /// @param renderTexture\n        ///     The render texture that should be restored.\n        ///\n        void AddRestoreCubemapCommand(const RenderTexture* renderTexture) noexcept;\n        \n        /// Creates and adds a new restore mesh command to the render command list.\n        ///\n        /// @param renderMesh\n        ///     The render mesh that should be restored.\n        ///\n        void AddRestoreMeshCommand(const RenderMesh* renderMesh) noexcept;\n\n        /// Creates and adds a new restore render target group command to the render command list.\n        ///\n        /// @param renderTargetGroup\n        ///     The render target group that should be restored.\n        ///\n        void AddRestoreRenderTargetGroupCommand(const RenderTargetGroup* renderTargetGroup) noexcept;\n        \n        /// Creates and adds a new load target group command to the render command list.\n        ///\n        /// @param renderTargetGroup\n        ///     The RenderTargetGroup that should be loaded.\n        ///\n        void AddLoadTargetGroupCommand(RenderTargetGroup* renderTargetGroup) noexcept;\n        \n        /// Creates and adds a new begin rendering command to the render command list.\n        ///\n        /// @param resolution\n        ///     The resolution of the viewport.\n        /// @param clearColour\n        ///     The clear colour.\n        ///\n        void AddBeginCommand(const Integer2& resolution, const Colour& clearColour) noexcept;\n        \n        /// Creates and adds a new begin with target group rendering command to the render\n        /// command list.\n        ///\n        /// @param renderTargetGroup\n        ///     The RenderTargetGroup to render into.\n        /// @param clearColour\n        ///     The clear colour.\n        ///\n        void AddBeginWithTargetGroupCommand(const RenderTargetGroup* renderTargetGroup, const Colour& clearColour) noexcept;\n        \n        /// Creates and adds a new apply camera command to the render command list.\n        ///\n        /// @param position\n        ///     The world space position of the camera.\n        /// @param viewMatrix\n        ///     The view matrix (inverse transform) of the camera.\n        /// @param viewProjectionMatrix\n        ///     The view projection matrix of the camera.\n        ///\n        void AddApplyCameraCommand(const Vector3& position, const Matrix4& viewMatrix, const Matrix4& viewProjectionMatrix) noexcept;\n        \n        /// Creates and adds a new apply ambient light command to the render command list.\n        ///\n        /// @param colour\n        ///     The colour of the light.\n        ///\n        void AddApplyAmbientLightCommand(const Colour& colour) noexcept;\n        \n        /// Creates and adds a new apply directional light command to the render command list.\n        ///\n        /// @param colour\n        ///     The colour of the light.\n        /// @param direction\n        ///     The direction of the light.\n        /// @param lightViewProjection\n        ///     The view projection matrix of the light which is used as the camera when rendering\n        ///     the shadow map.\n        /// @param shadowTolerance\n        ///     The tolerence used to judge if an object is in shadow.\n        /// @param shadowMapRenderTexture\n        ///     The render texture which should be used for the shadow map. Can be null if there is no\n        ///     shadow map.\n        ///\n        void AddApplyDirectionalLightCommand(const Colour& colour, const Vector3& direction, const Matrix4& lightViewProjection, f32 shadowTolerance, const RenderTexture* shadowMapRenderTexture) noexcept;\n        \n        /// Creates and adds a new apply point light command to the render command list.\n        ///\n        /// @param colour\n        ///     The colour of the light.\n        /// @param position\n        ///     The world space position of the light.\n        /// @param attenuation\n        ///     The vector containing the constant, linear and quadratic attenuation values of the\n        ///     light.\n        ///\n        void AddApplyPointLightCommand(const Colour& colour, const Vector3& position, const Vector3& attenuation) noexcept;\n        \n        /// Creates and adds a new apply material command to the render command list.\n        ///\n        /// @param renderMaterial\n        ///     The render material to apply.\n        ///\n        void AddApplyMaterialCommand(const RenderMaterial* renderMaterial) noexcept;\n        \n        /// Creates and adds a new apply mesh command to the render command list.\n        ///\n        /// @param renderMesh\n        ///     The render mesh to apply.\n        ///\n        void AddApplyMeshCommand(const RenderMesh* renderMesh) noexcept;\n        \n        /// Creates and adds a new apply dynamic mesh command to the render command list.\n        ///\n        /// @param renderDynamicMesh\n        ///     The render dynamic mesh to apply.\n        ///\n        void AddApplyDynamicMeshCommand(const RenderDynamicMesh* renderDynamicMesh) noexcept;\n        \n        /// Creates and adds a new apply mesh batch command to the render command list.\n        ///\n        /// @param renderMeshBatch\n        ///     The render mesh batch which should be applied. Must be moved.\n        ///\n        void AddApplyMeshBatchCommand(RenderMeshBatchUPtr renderMeshBatch) noexcept;\n        \n        /// Creates and adds a new apply skinned animation command to the render command list.\n        ///\n        /// @param renderSkinnedAnimation\n        ///     The render skinned animation to apply.\n        ///\n        void AddApplySkinnedAnimationCommand(const RenderSkinnedAnimation* renderSkinnedAnimation) noexcept;\n        \n        /// Creates and adds a new render instance command to the render command list.\n        ///\n        /// @param renderMesh\n        ///     The world matrix of the instance.\n        ///\n        void AddRenderInstanceCommand(const Matrix4& worldMatrix) noexcept;\n        \n        /// Creates and adds a new end command to the render command list.\n        ///\n        void AddEndCommand() noexcept;\n        \n        /// Creates and adds a new unload target group command to the render command list.\n        ///\n        /// @param renderTargetGroup\n        ///     The render target group that should be unloaded.\n        ///\n        void AddUnloadTargetGroupCommand(UniquePtr<RenderTargetGroup> renderTargetGroup) noexcept;\n        \n        /// Creates and adds a new unload mesh command to the render command list.\n        ///\n        /// @param renderMesh\n        ///     The render mesh that should be unloaded.\n        ///\n        void AddUnloadMeshCommand(UniquePtr<RenderMesh> renderMesh) noexcept;\n        \n        /// Creates and adds a new unload material group command to the render command list.\n        ///\n        /// @param renderMaterialGroup\n        ///     The render material group that should be unloaded.\n        ///\n        void AddUnloadMaterialGroupCommand(UniquePtr<RenderMaterialGroup> renderMaterialGroup) noexcept;\n\n        /// Creates and adds a new unload texture command to the render command list.\n        ///\n        /// @param renderTexture\n        ///     The render texture that should be unloaded.\n        ///\n        void AddUnloadTextureCommand(UniquePtr<RenderTexture> renderTexture) noexcept;\n        \n        /// Creates and adds a new unload cubemap command to the render command list.\n        ///\n        /// @param renderTexture\n        ///     The render texture that should be unloaded.\n        ///\n        void AddUnloadCubemapCommand(UniquePtr<RenderTexture> renderTexture) noexcept;\n        \n        /// Creates and adds a new unload shader command to the render command list.\n        ///\n        /// @param renderShader\n        ///     The render shader that should be unloaded.\n        ///\n        void AddUnloadShaderCommand(UniquePtr<RenderShader> renderShader) noexcept;\n\n        /// @return The number of render commands in the list.\n        ///\n        u32 GetNumCommands() const noexcept { return u32(m_renderCommands.size()); }\n        \n        /// @return The ordered list of render commands.\n        ///\n        const std::vector<const RenderCommand*>& GetOrderedList() const noexcept { return m_orderedCommands; };\n        \n        /// @return The RenderCommand at the given index\n        ///\n        RenderCommand* GetCommand(u32 index) noexcept;\n        \n    private:\n        std::vector<const RenderCommand*> m_orderedCommands;\n        std::vector<RenderCommandUPtr> m_renderCommands; //TODO: This should be changed to a series of pools of individial render command types.\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/RenderCommand.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_RENDERCOMMAND_H_\n#define _CHILLISOURCE_RENDERING_RENDERCOMMAND_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Rendering/RenderCommand/RenderCommand.h>\n#include <ChilliSource/Rendering/RenderCommand/RenderCommandBuffer.h>\n#include <ChilliSource/Rendering/RenderCommand/RenderCommandList.h>\n#include <ChilliSource/Rendering/RenderCommand/Commands/ApplyAmbientLightRenderCommand.h>\n#include <ChilliSource/Rendering/RenderCommand/Commands/ApplyCameraRenderCommand.h>\n#include <ChilliSource/Rendering/RenderCommand/Commands/ApplyDirectionalLightRenderCommand.h>\n#include <ChilliSource/Rendering/RenderCommand/Commands/ApplyDynamicMeshRenderCommand.h>\n#include <ChilliSource/Rendering/RenderCommand/Commands/ApplyMaterialRenderCommand.h>\n#include <ChilliSource/Rendering/RenderCommand/Commands/ApplyMeshRenderCommand.h>\n#include <ChilliSource/Rendering/RenderCommand/Commands/ApplyMeshBatchRenderCommand.h>\n#include <ChilliSource/Rendering/RenderCommand/Commands/ApplyPointLightRenderCommand.h>\n#include <ChilliSource/Rendering/RenderCommand/Commands/ApplySkinnedAnimationRenderCommand.h>\n#include <ChilliSource/Rendering/RenderCommand/Commands/BeginRenderCommand.h>\n#include <ChilliSource/Rendering/RenderCommand/Commands/BeginWithTargetGroupRenderCommand.h>\n#include <ChilliSource/Rendering/RenderCommand/Commands/EndRenderCommand.h>\n#include <ChilliSource/Rendering/RenderCommand/Commands/LoadMaterialGroupRenderCommand.h>\n#include <ChilliSource/Rendering/RenderCommand/Commands/LoadMeshRenderCommand.h>\n#include <ChilliSource/Rendering/RenderCommand/Commands/LoadShaderRenderCommand.h>\n#include <ChilliSource/Rendering/RenderCommand/Commands/LoadTargetGroupRenderCommand.h>\n#include <ChilliSource/Rendering/RenderCommand/Commands/LoadTextureRenderCommand.h>\n#include <ChilliSource/Rendering/RenderCommand/Commands/LoadCubemapRenderCommand.h>\n#include <ChilliSource/Rendering/RenderCommand/Commands/RenderInstanceRenderCommand.h>\n#include <ChilliSource/Rendering/RenderCommand/Commands/UnloadMaterialGroupRenderCommand.h>\n#include <ChilliSource/Rendering/RenderCommand/Commands/UnloadMeshRenderCommand.h>\n#include <ChilliSource/Rendering/RenderCommand/Commands/UnloadShaderRenderCommand.h>\n#include <ChilliSource/Rendering/RenderCommand/Commands/UnloadTargetGroupRenderCommand.h>\n#include <ChilliSource/Rendering/RenderCommand/Commands/UnloadTextureRenderCommand.h>\n#include <ChilliSource/Rendering/RenderCommand/Commands/UnloadCubemapRenderCommand.h>\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Shader/CSShaderProvider.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Shader/CSShaderProvider.h>\n\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/File/FileSystem.h>\n#include <ChilliSource/Core/Threading/TaskScheduler.h>\n#include <ChilliSource/Rendering/Shader/Shader.h>\n\nnamespace ChilliSource\n{\n    namespace\n    {\n        const std::string k_shaderFileExtension(\"csshader\");\n        const std::string k_languageTag(\"GLSL\");\n        const std::string k_vsTag(\"VertexShader\");\n        const std::string k_fsTag(\"FragmentShader\");\n        \n        /// Grabs the contents of a chunk identified by the given tag\n        ///\n        ///\t\tTag\n        ///\t\t{\n        ///\t\t\tContents\n        ///\t\t}\n        ///\n        /// If no chunk can be found an empty string will be returned.\n        ///\n        /// @param chunkTag\n        ///     The chunk tag\n        /// @param text\n        ///     The string data to search in.\n        ///\n        /// @return Contents of the chunk or empty\n        ///\n        std::string GetChunk(const std::string& chunkTag, const std::string& text) noexcept\n        {\n            //Find the chunk key\n            auto tagStartIdx = text.find(chunkTag);\n            CS_ASSERT(tagStartIdx != text.npos, \"Missing '\" + chunkTag + \"' tag from shader.\");\n            \n            //Find the open brace\n            auto openBraceLocation = text.find(\"{\", tagStartIdx);\n            CS_ASSERT(openBraceLocation != text.npos, \"Missing open brace in tag '\" + chunkTag + \"'.\");\n            \n            //Grab all the data between the open and close braces\n            auto closeBraceLocation = openBraceLocation;\n            u32 additionalOpenBraceCount = 0;\n            for (auto i = openBraceLocation + 1; i < text.size(); ++i)\n            {\n                bool shouldContinue = true;\n                switch (text[i])\n                {\n                    case '{':\n                        ++additionalOpenBraceCount;\n                        break;\n                    case '}':\n                        if (additionalOpenBraceCount <= 0)\n                        {\n                            closeBraceLocation = i;\n                            shouldContinue = false;\n                        }\n                        else\n                        {\n                            --additionalOpenBraceCount;\n                        }\n                        break;\n                    default:\n                        break;\n                }\n                \n                if (shouldContinue == false)\n                {\n                    break;\n                }\n            }\n            \n            CS_ASSERT(openBraceLocation != closeBraceLocation, \"Missing closing brace in tag '\" + chunkTag + \"'.\");\n            return text.substr(openBraceLocation + 1, closeBraceLocation - (openBraceLocation + 1));\n        }\n        \n        /// Performs the actual loading for the 2 create methods\n        ///\n        /// @param location\n        ///     The storage location.\n        /// @param filePath\n        ///     The file path.\n        /// @param delegate\n        ///     The Completion delegate\n        /// @param shader\n        ///     The output shader resource.\n        ///\n        void LoadShader(StorageLocation location, const std::string& filePath, const ResourceProvider::AsyncLoadDelegate& delegate, const ShaderSPtr& shader) noexcept\n        {\n            auto shaderStream = Application::Get()->GetFileSystem()->CreateTextInputStream(location, filePath);\n            if(shaderStream == nullptr)\n            {\n                CS_LOG_ERROR(\"Failed to open shader file: \" + filePath);\n                shader->SetLoadState(Resource::LoadState::k_failed);\n                if(delegate != nullptr)\n                {\n                    Application::Get()->GetTaskScheduler()->ScheduleTask(TaskType::k_mainThread, [=](const TaskContext&) noexcept\n                    {\n                        delegate(shader);\n                    });\n                }\n                return;\n            }\n            \n            std::string fileContents = shaderStream->ReadAll();\n            shaderStream.reset();\n            \n            std::string languageChunk = GetChunk(k_languageTag, fileContents);\n            if (languageChunk.empty() == true)\n            {\n                CS_LOG_ERROR(\"Failed to find GLSL chunk in shader: \" + filePath);\n                shader->SetLoadState(Resource::LoadState::k_failed);\n                if (delegate != nullptr)\n                {\n                    Application::Get()->GetTaskScheduler()->ScheduleTask(TaskType::k_mainThread, [=](const TaskContext&) noexcept\n                    {\n                        delegate(shader);\n                    });\n                }\n                return;\n            }\n            \n            std::string vsChunk = GetChunk(k_vsTag, languageChunk);\n            if (vsChunk.empty() == true)\n            {\n                CS_LOG_ERROR(\"Failed to find VertexShader chunk in shader: \" + filePath);\n                shader->SetLoadState(Resource::LoadState::k_failed);\n                if (delegate != nullptr)\n                {\n                    Application::Get()->GetTaskScheduler()->ScheduleTask(TaskType::k_mainThread, [=](const TaskContext&) noexcept\n                    {\n                        delegate(shader);\n                    });\n                }\n                return;\n            }\n            \n            std::string fsChunk = GetChunk(k_fsTag, languageChunk);\n            if (fsChunk.empty() == true)\n            {\n                CS_LOG_ERROR(\"Failed to find FragmentShader chunk in shader: \" + filePath);\n                shader->SetLoadState(Resource::LoadState::k_failed);\n                if (delegate != nullptr)\n                {\n                    Application::Get()->GetTaskScheduler()->ScheduleTask(TaskType::k_mainThread, [=](const TaskContext&) noexcept\n                    {\n                        delegate(shader);\n                    });\n                }\n                return;\n            }\n            \n            if (delegate == nullptr)\n            {\n                shader->Build(vsChunk, fsChunk);\n                shader->SetLoadState(Resource::LoadState::k_loaded);\n            }\n            else\n            {\n                //All GL related tasks must be performed on the main thread.\n                Application::Get()->GetTaskScheduler()->ScheduleTask(TaskType::k_mainThread, [=](const TaskContext&) noexcept\n                {\n                    shader->Build(vsChunk, fsChunk);\n                    shader->SetLoadState(Resource::LoadState::k_loaded);\n                    delegate(shader);\n                });\n            }\n        }\n    }\n    \n    CS_DEFINE_NAMEDTYPE(CSShaderProvider);\n    \n    //------------------------------------------------------------------------------\n    CSShaderProviderUPtr CSShaderProvider::Create() noexcept\n    {\n        return CSShaderProviderUPtr(new CSShaderProvider());\n    }\n    \n    //------------------------------------------------------------------------------\n    bool CSShaderProvider::IsA(InterfaceIDType interfaceId) const noexcept\n    {\n        return interfaceId == ResourceProvider::InterfaceID || interfaceId == CSShaderProvider::InterfaceID;\n    }\n    \n    //------------------------------------------------------------------------------\n    InterfaceIDType CSShaderProvider::GetResourceType() const noexcept\n    {\n        return Shader::InterfaceID;\n    }\n    \n    //------------------------------------------------------------------------------\n    bool CSShaderProvider::CanCreateResourceWithFileExtension(const std::string& extension) const noexcept\n    {\n        return extension == k_shaderFileExtension;\n    }\n    \n    //------------------------------------------------------------------------------\n    void CSShaderProvider::CreateResourceFromFile(StorageLocation location, const std::string& filePath, const IResourceOptionsBaseCSPtr& options, const ResourceSPtr& resource) noexcept\n    {\n        ShaderSPtr shaderResource = std::static_pointer_cast<Shader>(resource);\n        LoadShader(location, filePath, nullptr, shaderResource);\n    }\n    \n    //------------------------------------------------------------------------------\n    void CSShaderProvider::CreateResourceFromFileAsync(StorageLocation location, const std::string& filePath, const IResourceOptionsBaseCSPtr& options, const ResourceProvider::AsyncLoadDelegate& delegate, const ResourceSPtr& resource) noexcept\n    {\n        ShaderSPtr shaderResource = std::static_pointer_cast<Shader>(resource);\n        LoadShader(location, filePath, delegate, shaderResource);\n    }\n}\n\n\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Shader/CSShaderProvider.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CSBACKEND_RENDERING_SHADER_CSSHADERPROVIDER_H_\n#define _CSBACKEND_RENDERING_SHADER_CSSHADERPROVIDER_H_\n\n#include <CSBackend/Rendering/OpenGL/ForwardDeclarations.h>\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Resource/ResourceProvider.h>\n\nnamespace ChilliSource\n{\n    /// Loads CS shader from shader files into a shader resource. The file contains both\n    /// vertex and fragment shaders\n    ///\n    class CSShaderProvider final : public ResourceProvider\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(CSShaderProvider);\n\n        /// Allows querying of whether or not this system implements the interface described by the\n        /// given interface Id. Typically this is not called directly as the templated equivalent\n        /// IsA<Interface>() is preferred.\n        ///\n        /// @param interfaceId\n        ///     The Id of the interface.\n        ///\n        /// @return Whether or not the interface is implemented.\n        ///\n        bool IsA(InterfaceIDType interfaceId) const noexcept override;\n        \n        /// @return The type of resource loaded by this provider\n        ///\n        InterfaceIDType GetResourceType() const noexcept override;\n        \n        /// @param extension\n        ///     The extension to compare.\n        ///\n        /// @return Whether the object can create a resource with the given extension\n        ///\n        bool CanCreateResourceWithFileExtension(const std::string& extension) const noexcept override;\n        \n    private:\n        friend class Application;\n        \n        /// A factory method for creating new instances of the system. This must be called by\n        /// Application.\n        ///\n        /// @return The new instance of the system.\n        ///\n        static CSShaderProviderUPtr Create() noexcept;\n        \n        CSShaderProvider() noexcept = default;\n        \n        /// Load the shader from the external file into a resource. Check resource\n        /// load state for success or failure\n        ///\n        /// @param location\n        ///     The storage location to load from\n        /// @param filePath\n        ///     The file path\n        /// @param options\n        ///     Options to customise the creation of the resource.\n        /// @param resource\n        ///     The output resource.\n        ///\n        void CreateResourceFromFile(StorageLocation location, const std::string& filePath, const IResourceOptionsBaseCSPtr& options, const ResourceSPtr& resource) noexcept override;\n\n        /// Load the shader from the external file into a resource on a background\n        /// thread. Delegate is called when the load is complete. Check resource\n        /// load state for success or failure.\n        ///\n        /// @param location\n        ///     The storage location to load from\n        /// @param filePath\n        ///     The file path\n        /// @param options\n        ///     Options to customise the creation of the resource.\n        /// @param delegate\n        ///     The completion delegate.\n        /// @param resource\n        ///     The output resource.\n        ///\n        void CreateResourceFromFileAsync(StorageLocation location, const std::string& filePath, const IResourceOptionsBaseCSPtr& options, const ResourceProvider::AsyncLoadDelegate& delegate, const ResourceSPtr& resource) noexcept override;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Shader/RenderShader.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_SHADER_RENDERSHADER_H_\n#define _CHILLISOURCE_RENDERING_SHADER_RENDERSHADER_H_\n\n#include <ChilliSource/ChilliSource.h>\n\nnamespace ChilliSource\n{\n    /// A standard-layout container which acts as a handle which the underlying render system\n    /// can use to reference a specific shader.\n    ///\n    /// This is immutable and therefore thread-safe, aside from the extra data pointer\n    /// which should only be accessed on the render thread.\n    ///\n    class RenderShader final\n    {\n    public:\n        CS_DECLARE_NOCOPY(RenderShader);\n        \n        /// SHOULD ONLY BE CREATED VIA RenderShaderManager\n        ///\n        RenderShader() = default;\n        \n        /// This is not thread safe and should only be called from the render thread.\n        ///\n        /// @return A pointer to render system specific additional information.\n        ///\n        void* GetExtraData() const noexcept { return m_extraData; }\n        \n        /// This is not thread safe and should only be called from the render thread.\n        ///\n        /// @param extraData\n        ///     A pointer to render system specific additional information.\n        ///\n        void SetExtraData(void* extraData) noexcept { m_extraData = extraData; }\n        \n    private:\n        \n        void* m_extraData = nullptr;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Shader/RenderShaderManager.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Shader/RenderShaderManager.h>\n\n#include <ChilliSource/Rendering/Base/RenderSnapshot.h>\n#include <ChilliSource/Rendering/Base/TargetType.h>\n\nnamespace ChilliSource\n{\n    namespace\n    {\n        constexpr u32 k_shaderPoolSize = 30;\n    }\n    \n    CS_DEFINE_NAMEDTYPE(RenderShaderManager);\n    \n    //------------------------------------------------------------------------------\n    RenderShaderManagerUPtr RenderShaderManager::Create() noexcept\n    {\n        return RenderShaderManagerUPtr(new RenderShaderManager());\n    }\n    \n    //------------------------------------------------------------------------------\n    RenderShaderManager::RenderShaderManager()\n    : m_renderShaderPool(k_shaderPoolSize, ObjectPoolAllocatorLimitPolicy::k_expand)\n    {\n        \n    }\n    \n    //------------------------------------------------------------------------------\n    bool RenderShaderManager::IsA(InterfaceIDType interfaceId) const noexcept\n    {\n        return (RenderShaderManager::InterfaceID == interfaceId);\n    }\n    \n    //------------------------------------------------------------------------------\n    UniquePtr<RenderShader> RenderShaderManager::CreateRenderShader(const std::string& vertexShader, const std::string& fragmentShader) noexcept\n    {\n        UniquePtr<RenderShader> renderShader(MakeUnique<RenderShader>(m_renderShaderPool));\n        auto rawRenderShader = renderShader.get();\n        \n        PendingLoadCommand loadCommand;\n        loadCommand.m_vertexShader = vertexShader;\n        loadCommand.m_fragmentShader = fragmentShader;\n        loadCommand.m_renderShader = rawRenderShader;\n        \n        std::unique_lock<std::mutex> lock(m_mutex);\n        m_pendingLoadCommands.push_back(std::move(loadCommand));\n        \n        return renderShader;\n    }\n    \n    //------------------------------------------------------------------------------\n    void RenderShaderManager::DestroyRenderShader(UniquePtr<RenderShader> renderShader) noexcept\n    {\n        std::unique_lock<std::mutex> lock(m_mutex);\n        m_pendingUnloadCommands.push_back(std::move(renderShader));\n    }\n    \n    //------------------------------------------------------------------------------\n    void RenderShaderManager::OnRenderSnapshot(TargetType targetType, RenderSnapshot& renderSnapshot, IAllocator* frameAllocator) noexcept\n    {\n        if(targetType == TargetType::k_main)\n        {\n            auto preRenderCommandList = renderSnapshot.GetPreRenderCommandList();\n            auto postRenderCommandList = renderSnapshot.GetPostRenderCommandList();\n            \n            std::unique_lock<std::mutex> lock(m_mutex);\n            \n            for (auto& loadCommand : m_pendingLoadCommands)\n            {\n                preRenderCommandList->AddLoadShaderCommand(loadCommand.m_renderShader, loadCommand.m_vertexShader, loadCommand.m_fragmentShader);\n            }\n            m_pendingLoadCommands.clear();\n            \n            for (auto& unloadCommand : m_pendingUnloadCommands)\n            {\n                postRenderCommandList->AddUnloadShaderCommand(std::move(unloadCommand));\n            }\n            m_pendingUnloadCommands.clear();\n        }\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Shader/RenderShaderManager.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_SHADER_RENDERSHADERMANAGER_H_\n#define _CHILLISOURCE_RENDERING_SHADER_RENDERSHADERMANAGER_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/System/AppSystem.h>\n#include <ChilliSource/Core/Memory/ObjectPoolAllocator.h>\n#include <ChilliSource/Core/Memory/UniquePtr.h>\n#include <ChilliSource/Rendering/Shader/RenderShader.h>\n\n#include <mutex>\n\nnamespace ChilliSource\n{\n    /// Manages the lifecycle of all RenderShader instances.\n    ///\n    /// On creation of a RenderShader a LoadShaderRenderCommand is queued for the next render\n    /// snapshot phase, ensuring that related shader data is processed before the RenderShader\n    /// is used.\n    ///\n    /// On deletion an UnloadShaderRenderCommand is queued and given ownership of the\n    /// RenderShader. The render shader is then deleted once the command has been processed.\n    ///\n    /// This is thread-safe and can be called from any thread. If it is called on a background\n    /// thread, care needs to be taken to ensure any created RenderShaders are not used prior\n    /// to being loaded.\n    ///\n    class RenderShaderManager final : public AppSystem\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(RenderShaderManager);\n        \n        /// Allows querying of whether or not this system implements the interface described by the\n        /// given interface Id. Typically this is not called directly as the templated equivalent\n        /// IsA<Interface>() is preferred.\n        ///\n        /// @param interfaceId\n        ///     The Id of the interface.\n        ///\n        /// @return Whether or not the interface is implemented.\n        ///\n        bool IsA(InterfaceIDType interfaceId) const noexcept override;\n        \n        /// Creates a new render shader and queues a LoadShaderRenderCommand for the next\n        /// Render Snapshot stage in the render pipeline.\n        ///\n        /// @param vertexShader\n        ///     The vertex shader string.\n        /// @param fragmentShader\n        ///     The fragment shader string.\n        ///\n        /// @return The render shader instance.\n        ///\n        UniquePtr<RenderShader> CreateRenderShader(const std::string& vertexShader, const std::string& fragmentShader) noexcept;\n        \n        /// Removes the render shader from the manager and queues an UnloadShaderRenderCommand for\n        /// the next Render Snapshot stage in the render pipeline. The render command is given\n        /// ownership of the render shader, ensuring it won't be destroyed until it is no longer\n        /// used.\n        ///\n        /// @param renderShader\n        ///     The render shader which should be destroyed.\n        ///\n        void DestroyRenderShader(UniquePtr<RenderShader> renderShader) noexcept;\n        \n    private:\n        friend class Application;\n        \n        /// A container for information relating to pending shader load commands, such as the\n        /// vertex shader, fragment shader and the related RenderShader.\n        ///\n        struct PendingLoadCommand final\n        {\n            std::string m_vertexShader;\n            std::string m_fragmentShader;\n            RenderShader* m_renderShader = nullptr;\n        };\n        \n        /// A factory method for creating new instances of the system. This must be called by\n        /// Application.\n        ///\n        /// @return The new instance of the system.\n        ///\n        static RenderShaderManagerUPtr Create() noexcept;\n        \n        RenderShaderManager();\n        \n        /// Called during the Render Snapshot stage of the render pipeline. All pending load and\n        /// unload commands are added to the render snapshot.\n        ///\n        /// @param targetType\n        ///     Whether the snapshot is for the main screen or an offscreen render target\n        /// @param renderSnapshot\n        ///     The render shapshot for storing snapshotted data.\n        /// @param frameAllocator\n        ///     Allocate memory for this render frame from here\n        ///\n        void OnRenderSnapshot(TargetType targetType, RenderSnapshot& renderSnapshot, IAllocator* frameAllocator) noexcept override;\n        \n        std::mutex m_mutex;\n        ObjectPoolAllocator<RenderShader> m_renderShaderPool;\n        std::vector<PendingLoadCommand> m_pendingLoadCommands;\n        std::vector<UniquePtr<RenderShader>> m_pendingUnloadCommands;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Shader/RenderShaderVariables.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Shader/RenderShaderVariables.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    RenderShaderVariables::RenderShaderVariables(const std::unordered_map<std::string, f32>& floatVars, const std::unordered_map<std::string, Vector2>& vec2Vars, const std::unordered_map<std::string, Vector3>& vec3Vars,\n                                                 const std::unordered_map<std::string, Vector4>& vec4Vars, const std::unordered_map<std::string, Matrix4>& mat4Vars,\n                                                 const std::unordered_map<std::string, Colour>& colourVars) noexcept\n        : m_floatVars(floatVars), m_vec2Vars(vec2Vars), m_vec3Vars(vec3Vars), m_vec4Vars(vec4Vars), m_mat4Vars(mat4Vars), m_colourVars(colourVars)\n    {\n    }\n    \n    //------------------------------------------------------------------------------\n    RenderShaderVariables::RenderShaderVariables(const RenderShaderVariables& toCopy)\n    {\n        m_floatVars = toCopy.m_floatVars;\n        m_vec2Vars = toCopy.m_vec2Vars;\n        m_vec3Vars = toCopy.m_vec3Vars;\n        m_vec4Vars = toCopy.m_vec4Vars;\n        m_colourVars = toCopy.m_colourVars;\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Shader/RenderShaderVariables.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_SHADER_RENDERSHADERVARIABLES_H_\n#define _CHILLISOURCE_RENDERING_SHADER_RENDERSHADERVARIABLES_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Base/Colour.h>\n#include <ChilliSource/Core/Math/Vector2.h>\n#include <ChilliSource/Core/Math/Vector3.h>\n#include <ChilliSource/Core/Math/Vector4.h>\n#include <ChilliSource/Core/Math/Matrix4.h>\n\n#include <unordered_map>\n\nnamespace ChilliSource\n{\n    /// A container for custom shader variables.\n    ///\n    /// This is immutable and therefore thread-safe.\n    ///\n    class RenderShaderVariables final\n    {\n    public:\n        \n        /// Creates a new instance with the given shader variables.\n        ///\n        /// @param floatVars\n        ///     The variables of type: float.\n        /// @param vec2Vars\n        ///     The variables of type: Vector2.\n        /// @param vec3Vars\n        ///     The variables of type: Vector3.\n        /// @param vec4Vars\n        ///     The variables of type: Vector4.\n        /// @param mat4Vars\n        ///     The variables of type: Matrix4.\n        /// @param colourVars\n        ///     The variables of type: Colour.\n        ///\n        RenderShaderVariables(const std::unordered_map<std::string, f32>& floatVars, const std::unordered_map<std::string, Vector2>& vec2Vars, const std::unordered_map<std::string, Vector3>& vec3Vars,\n                              const std::unordered_map<std::string, Vector4>& vec4Vars, const std::unordered_map<std::string, Matrix4>& mat4Vars, const std::unordered_map<std::string, Colour>& colourVars) noexcept;\n        \n        ///\n        /// Copy constructor\n        ///\n        RenderShaderVariables(const RenderShaderVariables& toCopy);\n        \n        /// @return The variables of type: float.\n        ///\n        const std::unordered_map<std::string, f32>& GetFloatVariables() const noexcept { return m_floatVars; }\n        \n        /// @return The variables of type: Vector2.\n        ///\n        const std::unordered_map<std::string, Vector2>& GetVector2Variables() const noexcept { return m_vec2Vars; }\n        \n        /// @return The variables of type: Vector3.\n        ///\n        const std::unordered_map<std::string, Vector3>& GetVector3Variables() const noexcept { return m_vec3Vars; }\n        \n        /// @return The variables of type: Vector4.\n        ///\n        const std::unordered_map<std::string, Vector4>& GetVector4Variables() const noexcept { return m_vec4Vars; }\n        \n        /// @return The variables of type: Matrix4.\n        ///\n        const std::unordered_map<std::string, Matrix4>& GetMatrix4Variables() const noexcept { return m_mat4Vars; }\n        \n        /// @return The variables of type: Colour.\n        ///\n        const std::unordered_map<std::string, Colour>& GetColourVariables() const noexcept { return m_colourVars; }\n        \n    private:\n        std::unordered_map<std::string, f32> m_floatVars;\n        std::unordered_map<std::string, Vector2> m_vec2Vars;\n        std::unordered_map<std::string, Vector3> m_vec3Vars;\n        std::unordered_map<std::string, Vector4> m_vec4Vars;\n        std::unordered_map<std::string, Matrix4> m_mat4Vars;\n        std::unordered_map<std::string, Colour> m_colourVars;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Shader/Shader.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2010 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Shader/Shader.h>\n\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Rendering/Shader/RenderShaderManager.h>\n\nnamespace ChilliSource\n{\n    CS_DEFINE_NAMEDTYPE(Shader);\n\n    //------------------------------------------------------------------------------\n    ShaderUPtr Shader::Create() noexcept\n    {\n        return ShaderUPtr(new Shader());\n    }\n\n    //------------------------------------------------------------------------------\n    bool Shader::IsA(InterfaceIDType interfaceId) const noexcept\n    {\n        return Shader::InterfaceID == interfaceId;\n    }\n\n    //------------------------------------------------------------------------------\n    void Shader::Build(const std::string& vertexShader, const std::string& fragmentShader) noexcept\n    {\n        DestroyRenderShader();\n        \n        auto renderShaderManager = Application::Get()->GetSystem<RenderShaderManager>();\n        CS_ASSERT(renderShaderManager, \"RenderShaderManager must exist.\");\n        \n        m_renderShader = renderShaderManager->CreateRenderShader(vertexShader, fragmentShader);\n    }\n\n    //------------------------------------------------------------------------------\n    const RenderShader* Shader::GetRenderShader() const noexcept\n    {\n        CS_ASSERT(GetLoadState() == LoadState::k_loaded, \"Cannot access shader before it is loaded.\");\n        CS_ASSERT(m_renderShader, \"Cannot access shader which has not been built.\");\n        \n        return m_renderShader.get();\n    }\n    \n    //------------------------------------------------------------------------------\n    void Shader::DestroyRenderShader() noexcept\n    {\n        if (m_renderShader)\n        {\n            auto renderShaderManager = Application::Get()->GetSystem<RenderShaderManager>();\n            CS_ASSERT(renderShaderManager, \"RenderShaderManager must exist.\");\n            \n            renderShaderManager->DestroyRenderShader(std::move(m_renderShader));\n        }\n    }\n\n    //------------------------------------------------------------------------------\n    Shader::~Shader() noexcept\n    {\n        DestroyRenderShader();\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Shader/Shader.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2010 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_SHADER_SHADER_H_\n#define _CHILLISOURCE_RENDERING_SHADER_SHADER_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Resource/Resource.h>\n#include <ChilliSource/Core/Memory/UniquePtr.h>\n\nnamespace ChilliSource\n{\n    /// A resource which represents a shader in the underlying render system.\n    ///\n    /// This is not thread safe and should only be accessed from one thread at a time.\n    ///\n    class Shader final : public Resource\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(Shader);\n        \n        /// Allows querying of whether or not this system implements the interface described by the\n        /// given interface Id. Typically this is not called directly as the templated equivalent\n        /// IsA<Interface>() is preferred.\n        ///\n        /// @param interfaceId\n        ///     The Id of the interface.\n        ///\n        /// @return Whether or not the interface is implemented.\n        ///\n        bool IsA(InterfaceIDType interfaceId) const noexcept override;\n        \n        /// Builds the shader with the given shader data. The shader must not already be\n        /// in the loaded state.\n        ///\n        /// @param vertexShader\n        ///     The vertex shader string.\n        /// @param fragmentShaderData\n        ///     The fragment shader string.\n        ///\n        void Build(const std::string& vertexShader, const std::string& fragmentShader) noexcept;\n        \n        /// @return The underlying RenderShader used by the render system.\n        ///\n        const RenderShader* GetRenderShader() const noexcept;\n        \n        ~Shader() noexcept;\n        \n    protected:\n        friend class ResourcePool;\n        \n        /// A factory method for creating new, empty instances of the resource. This must only be\n        /// called by ResourcePool.\n        ///\n        /// @return The new instance of the resource.\n        ///\n        static ShaderUPtr Create() noexcept;\n        \n        /// Destroys the render shader if there is currently one available.\n        ///\n        void DestroyRenderShader() noexcept;\n        \n        Shader() = default;\n        \n        UniquePtr<RenderShader> m_renderShader;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Shader.h",
    "content": "//\n//  Shader.h\n//  ChilliSource\n//  Created by Ian Copland on 07/07/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n\n#ifndef _CHILLISOURCE_RENDERING_SHADER_H_\n#define _CHILLISOURCE_RENDERING_SHADER_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Rendering/Shader/CSShaderProvider.h>\n#include <ChilliSource/Rendering/Shader/RenderShader.h>\n#include <ChilliSource/Rendering/Shader/RenderShaderManager.h>\n#include <ChilliSource/Rendering/Shader/RenderShaderVariables.h>\n#include <ChilliSource/Rendering/Shader/Shader.h>\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Skybox/SkyboxComponent.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2017 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Skybox/SkyboxComponent.h>\n\n#include <ChilliSource/Rendering/Base/RenderSnapshot.h>\n#include <ChilliSource/Rendering/Material/Material.h>\n\nnamespace ChilliSource\n{\n    CS_DEFINE_NAMEDTYPE(SkyboxComponent);\n    \n    //------------------------------------------------------------------------------\n    SkyboxComponent::SkyboxComponent(const ModelCSPtr& model, const MaterialCSPtr& material) noexcept\n    : m_model(model), m_material(material)\n    {\n        CS_ASSERT(m_model, \"Model cannot be null\");\n        CS_ASSERT(m_model->GetLoadState() == Resource::LoadState::k_loaded, \"Cannot use a model that hasn't been loaded yet.\");\n        CS_ASSERT(m_model->GetNumMeshes() == 1, \"Skybox model should only have a single mesh\");\n        CS_ASSERT(material, \"Material cannot be null\");\n        CS_ASSERT(material->GetLoadState() == Resource::LoadState::k_loaded, \"Cannot use a material that hasn't been loaded yet.\");\n    }\n    \n    //------------------------------------------------------------------------------\n    bool SkyboxComponent::IsA(InterfaceIDType interfaceId) const noexcept\n    {\n        return  (interfaceId == SkyboxComponent::InterfaceID);\n    }\n    \n    //------------------------------------------------------------------------------\n    const ModelCSPtr& SkyboxComponent::GetModel() const noexcept\n    {\n        return m_model;\n    }\n    \n    //------------------------------------------------------------------------------\n    void SkyboxComponent::SetModel(const ModelCSPtr& model) noexcept\n    {\n        CS_ASSERT(model, \"Cannot set null model.\");\n        CS_ASSERT(model->GetLoadState() == Resource::LoadState::k_loaded, \"Cannot use a model that hasn't been loaded yet.\");\n        CS_ASSERT(model->GetNumMeshes() == 1, \"Skybox model should only have a single mesh\");\n        \n        m_model = model;\n    }\n    \n    //------------------------------------------------------------------------------\n    void SkyboxComponent::SetModel(const ModelCSPtr& model, const MaterialCSPtr& material) noexcept\n    {\n        CS_ASSERT(model, \"Cannot set null model.\");\n        CS_ASSERT(model->GetLoadState() == Resource::LoadState::k_loaded, \"Cannot use a model that hasn't been loaded yet.\");\n        CS_ASSERT(model->GetNumMeshes() == 1, \"Skybox model should only have a single mesh\");\n        CS_ASSERT(material, \"Cannot set null material.\");\n        CS_ASSERT(material->GetLoadState() == Resource::LoadState::k_loaded, \"Cannot use a material that hasn't been loaded yet.\");\n        \n        m_model = model;\n        m_material = material;\n    }\n    \n    //------------------------------------------------------------------------------\n    const MaterialCSPtr& SkyboxComponent::GetMaterial() const noexcept\n    {\n        return m_material;\n    }\n    \n    //------------------------------------------------------------------------------\n    void SkyboxComponent::SetMaterial(const MaterialCSPtr& material) noexcept\n    {\n        CS_ASSERT(m_model, \"Cannot set material without a model.\");\n        CS_ASSERT(material, \"Cannot set null material.\");\n        CS_ASSERT(material->GetLoadState() == Resource::LoadState::k_loaded, \"Cannot use a material that hasn't been loaded yet.\");\n        \n        m_material = material;\n    }\n    \n    //------------------------------------------------------------------------------\n    void SkyboxComponent::OnRenderSnapshot(RenderSnapshot& renderSnapshot, IAllocator* frameAllocator) noexcept\n    {\n        CS_ASSERT(m_model->GetLoadState() == Resource::LoadState::k_loaded, \"Cannot use a model that hasn't been loaded yet.\");\n        CS_ASSERT(m_material->GetLoadState() == Resource::LoadState::k_loaded, \"Cannot use a material that hasn't been loaded yet.\");\n        \n        auto renderMaterialGroup = m_material->GetRenderMaterialGroup();\n        auto renderMesh = m_model->GetRenderMesh(0);\n        \n        renderSnapshot.AddRenderObject(RenderObject(renderMaterialGroup, renderMesh, Matrix4::k_identity, renderMesh->GetBoundingSphere(), false, RenderLayer::k_skybox));\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Skybox/SkyboxComponent.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2017 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_SKYBOX_SKYBOXCOMPONENT_H_\n#define _CHILLISOURCE_RENDERING_SKYBOX_SKYBOXCOMPONENT_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Entity/Component.h>\n#include <ChilliSource/Rendering/Model/Model.h>\n\nnamespace ChilliSource\n{\n    /// A static skybox component. A 3D model that is rendered behind the rest of the scene\n    /// and infinetely far away.\n    ///\n    /// NOTE: \"Skybox\" is a convention only the model can be a sphere or dome, etc.\n    /// NOTE: Ignores any transformations applied to the entity\n    /// NOTE: Model must consist of a single mesh\n    ///\n    /// This is not thread safe and should not be used on multiple threads at once.\n    ///\n    class SkyboxComponent final : public Component\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(SkyboxComponent);\n        \n        /// Creates a new skybox component with the given model and material. The\n        /// material will be applied to all meshes in the model.\n        ///\n        /// @param model\n        ///     The model that should be used.\n        /// @param material\n        ///     The material that should be applied to each mesh in the model.\n        ///\n        SkyboxComponent(const ModelCSPtr& model, const MaterialCSPtr& material) noexcept;\n\n        /// Allows querying of whether or not this component implements the interface described\n        /// by the given interface Id. Typically this is not called directly as the templated\n        /// equivalent IsA<Interface>() is preferred.\n        ///\n        /// @param interfaceId\n        ///     The Id of the interface.\n        ///\n        /// @return Whether or not the interface is implemented.\n        ///\n        bool IsA(InterfaceIDType interfaceId) const noexcept override;\n\n        \n        /// @return The model that will be rendered.\n        ///\n        const ModelCSPtr& GetModel() const noexcept;\n        \n        /// Sets the model the component should use.\n        ///\n        /// The material currently applied to the first mesh will be applied to the entire model.\n        ///\n        /// @param model\n        ///     The model.\n        ///\n        void SetModel(const ModelCSPtr& model) noexcept;\n        \n        /// Sets the model the component should use. The given material will be applied to all meshes.\n        ///\n        /// @param model\n        ///     The model which should be used.\n        /// @param material\n        ///     The material which should be used.\n        ///\n        void SetModel(const ModelCSPtr& model, const MaterialCSPtr& material) noexcept;\n        \n        /// Get the material.\n        ///\n        /// @return Handle to material\n        ///\n        const MaterialCSPtr& GetMaterial() const noexcept;\n        \n        /// Set the material that the model will use. Applies the material to all meshes.\n        ///\n        /// @param material\n        ///     The material that should be used.\n        ///\n        void SetMaterial(const MaterialCSPtr& material) noexcept;\n        \n    private:\n        \n        /// Called during the render snapshot phase. Adds render objects to the scene\n        /// describing the model.\n        ///\n        /// @param renderSnapshot\n        ///     The render snapshot.\n        /// @param frameAllocator\n        ///     Allocate any memory required for rendering stuff from here\n        ///\n        void OnRenderSnapshot(RenderSnapshot& renderSnapshot, IAllocator* frameAllocator) noexcept override;\n        \n        ModelCSPtr m_model;\n        MaterialCSPtr m_material;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Skybox.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2017 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n\n#ifndef _CHILLISOURCE_RENDERING_SKYBOX_H_\n#define _CHILLISOURCE_RENDERING_SKYBOX_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Rendering/Skybox/SkyboxComponent.h>\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Sprite/SpriteComponent.cpp",
    "content": "//\n//  SpriteComponent.cpp\n//  ChilliSource\n//  Created by Scott Downie on 29/09/2010.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2010 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Sprite/SpriteComponent.h>\n\n#include <ChilliSource/Core/Base/ByteColour.h>\n#include <ChilliSource/Core/Base/ColourUtils.h>\n#include <ChilliSource/Core/Delegate/MakeDelegate.h>\n#include <ChilliSource/Core/Entity/Entity.h>\n#include <ChilliSource/Rendering/Base/AspectRatioUtils.h>\n#include <ChilliSource/Rendering/Base/RenderObject.h>\n#include <ChilliSource/Rendering/Base/RenderSnapshot.h>\n#include <ChilliSource/Rendering/Base/SizePolicy.h>\n#include <ChilliSource/Rendering/Material/Material.h>\n#include <ChilliSource/Rendering/Model/RenderDynamicMesh.h>\n#include <ChilliSource/Rendering/Sprite/SpriteMeshBuilder.h>\n#include <ChilliSource/Rendering/Texture/Texture.h>\n#include <ChilliSource/Rendering/Texture/TextureAtlas.h>\n\n#include <algorithm>\n\nnamespace ChilliSource\n{\n    namespace\n    {\n        //----------------------------------------------------------\n        /// Aspect ratio maintaing function that returns the original\n        /// size. This is used despite the fact it doesn't do much to\n        /// prevent multiple code paths when calculating size.\n        ///\n        /// @author S Downie\n        ///\n        /// @param Original size\n        /// @param Preferred size\n        ///\n        /// @return Original size\n        //----------------------------------------------------------\n        Vector2 UseOriginalSize(const Vector2& in_originalSize, const Vector2& in_preferredSize)\n        {\n            return in_originalSize;\n        }\n        //----------------------------------------------------------\n        /// Aspect ratio maintaing function that returns the preferred\n        /// size. This is used despite the fact it doesn't do much to\n        /// prevent multiple code paths when calculating size.\n        ///\n        /// @author S Downie\n        ///\n        /// @param Original size\n        /// @param Preferred size\n        ///\n        /// @return Preferred size\n        //----------------------------------------------------------\n        Vector2 UsePreferredSize(const Vector2& in_originalSize, const Vector2& in_preferredSize)\n        {\n            return in_preferredSize;\n        }\n        //----------------------------------------------------------------------------------------\n        /// Aspect ratio maintaining function that keeps the original width but adapts\n        /// the height to maintain the aspect ratio\n        ///\n        /// @author S Downie\n        ///\n        /// @param Original size\n        /// @param Preferred size\n        ///\n        /// @return Size with aspect maintained\n        //----------------------------------------------------------------------------------------\n        Vector2 KeepOriginalWidthAdaptHeight(const Vector2& in_originalSize, const Vector2& in_preferredSize)\n        {\n            return AspectRatioUtils::KeepOriginalWidthAdaptHeight(in_originalSize, in_preferredSize.x/in_preferredSize.y);\n        }\n        //----------------------------------------------------------------------------------------\n        /// Aspect ratio maintaining function that keeps the original height but adapts\n        /// the width to maintain the aspect ratio\n        ///\n        /// @author S Downie\n        ///\n        /// @param Original size\n        /// @param Preferred size\n        ///\n        /// @return Size with aspect maintained\n        //----------------------------------------------------------------------------------------\n        Vector2 KeepOriginalHeightAdaptWidth(const Vector2& in_originalSize, const Vector2& in_preferredSize)\n        {\n            return AspectRatioUtils::KeepOriginalHeightAdaptWidth(in_originalSize, in_preferredSize.x/in_preferredSize.y);\n        }\n        //----------------------------------------------------------------------------------------\n        /// Aspect ratio maintaining function that maintains the given target aspect ratio\n        /// while ensuring the size does not DROP BELOW the original size\n        ///\n        /// @author S Downie\n        ///\n        /// @param Original size\n        /// @param Preferred size\n        ///\n        /// @return Size with aspect maintained\n        //----------------------------------------------------------------------------------------\n        Vector2 FillOriginal(const Vector2& in_originalSize, const Vector2& in_preferredSize)\n        {\n            return AspectRatioUtils::FillOriginal(in_originalSize, in_preferredSize.x/in_preferredSize.y);\n        }\n        //----------------------------------------------------------------------------------------\n        /// Aspect ratio maintaining function that maintains the given target aspect ratio\n        /// while ensuring the size does not EXCEED the original size\n        ///\n        /// @author S Downie\n        ///\n        /// @param Original size\n        /// @param Preferred size\n        ///\n        /// @return Size with aspect maintained\n        //----------------------------------------------------------------------------------------\n        Vector2 FitOriginal(const Vector2& in_originalSize, const Vector2& in_preferredSize)\n        {\n            return AspectRatioUtils::FitOriginal(in_originalSize, in_preferredSize.x/in_preferredSize.y);\n        }\n        \n        const SpriteComponent::SizePolicyDelegate k_sizeDelegates[(u32)SizePolicy::k_totalNum] =\n        {\n            UseOriginalSize,\n            UsePreferredSize,\n            KeepOriginalWidthAdaptHeight,\n            KeepOriginalHeightAdaptWidth,\n            FitOriginal,\n            FillOriginal\n        };\n    }\n    \n    CS_DEFINE_NAMEDTYPE(SpriteComponent);\n    \n    //----------------------------------------------------------\n    SpriteComponent::SpriteComponent()\n    : m_uvs(0.0f, 0.0f, 1.0f, 1.0f)\n    {\n        m_sizePolicyDelegate = k_sizeDelegates[(u32)SizePolicy::k_none];\n    }\n    \n    //----------------------------------------------------------\n    SpriteComponent::SpriteComponent(const MaterialCSPtr& material, const Vector2& size, SizePolicy sizePolicy)\n    : m_uvs(0.0f, 0.0f, 1.0f, 1.0f)\n    {\n        SetMaterial(material);\n        SetSize(size);\n        SetSizePolicy(sizePolicy);\n    }\n    \n    //----------------------------------------------------------\n    SpriteComponent::SpriteComponent(const MaterialCSPtr& material, const TextureAtlasCSPtr& atlas, const std::string& atlasId, const Vector2& size, SizePolicy sizePolicy)\n    : m_uvs(0.0f, 0.0f, 1.0f, 1.0f)\n    {\n        SetMaterial(material);\n        SetTextureAtlas(atlas);\n        SetTextureAtlasId(atlasId);\n        SetSize(size);\n        SetSizePolicy(sizePolicy);\n    }\n    \n    //----------------------------------------------------------\n    //----------------------------------------------------------\n    bool SpriteComponent::IsA(InterfaceIDType in_interfaceId) const\n    {\n        return  (in_interfaceId == VolumeComponent::InterfaceID || in_interfaceId == SpriteComponent::InterfaceID);\n    }\n    //----------------------------------------------------\n    //----------------------------------------------------\n    const AABB& SpriteComponent::GetAABB()\n    {\n        if(IsTextureSizeCacheValid() == false)\n        {\n            OnTransformChanged();\n            SetTextureSizeCacheValid();\n        }\n        \n        if(GetEntity() && m_isAABBValid == false)\n        {\n            m_isAABBValid = true;\n            \n            Vector2 transformedSize = GetSize();\n            \n            // Realign the origin\n            Vector2 anchorPoint = GetAnchorPoint(m_originAlignment, transformedSize * 0.5f);\n            \n            // Rebuild the box\n            mBoundingBox.SetSize(Vector3(transformedSize, 0.0f));\n            mBoundingBox.SetOrigin(GetEntity()->GetTransform().GetWorldPosition() - Vector3(anchorPoint, 0.0f));\n        }\n        return mBoundingBox;\n    }\n    //----------------------------------------------------\n    //----------------------------------------------------\n    const OOBB& SpriteComponent::GetOOBB()\n    {\n        if(IsTextureSizeCacheValid() == false)\n        {\n            OnTransformChanged();\n            SetTextureSizeCacheValid();\n        }\n        \n        if(GetEntity() && m_isOOBBValid == false)\n        {\n            m_isOOBBValid = true;\n            \n            Vector2 transformedSize = GetSize();\n            \n            // Realign the origin\n            Vector2 anchorPoint = GetAnchorPoint(m_originAlignment, transformedSize * 0.5f);\n            \n            // Rebuild the box\n            mOBBoundingBox.SetOrigin(Vector3(-anchorPoint, 0.0f));\n            mOBBoundingBox.SetSize(Vector3(transformedSize, 0.0f));\n            mOBBoundingBox.SetTransform(GetEntity()->GetTransform().GetWorldTransform());\n        }\n        return mOBBoundingBox;\n    }\n    //----------------------------------------------------\n    //----------------------------------------------------\n    const Sphere& SpriteComponent::GetBoundingSphere()\n    {\n        if(IsTextureSizeCacheValid() == false)\n        {\n            OnTransformChanged();\n            SetTextureSizeCacheValid();\n        }\n        \n        if(GetEntity() && m_isBSValid == false)\n        {\n            m_isBSValid = true;\n            \n            Vector2 transformedSize = GetSize();\n            \n            // Realign the origin\n            Vector2 anchorPoint = GetAnchorPoint(m_originAlignment, transformedSize * 0.5f);\n            \n            mBoundingSphere.vOrigin = GetEntity()->GetTransform().GetWorldPosition() - Vector3(anchorPoint, 0.0f);\n            mBoundingSphere.fRadius = std::sqrt((transformedSize.x * transformedSize.x) + (transformedSize.y * transformedSize.y)) * 0.5f;\n        }\n        return mBoundingSphere;\n    }\n    //-----------------------------------------------------------\n    /// The texture atlas has the priority, then the texture\n    //-----------------------------------------------------------\n    Vector2 SpriteComponent::GetPreferredSize() const\n    {\n        if(m_textureAtlas != nullptr && m_hashedTextureAtlasId > 0)\n        {\n            return m_textureAtlas->GetOriginalFrameSize(m_hashedTextureAtlasId);\n        }\n        else if(mpMaterial != nullptr && mpMaterial->GetTexture() != nullptr)\n        {\n            auto texture = mpMaterial->GetTexture().get();\n            return Vector2((f32)texture->GetDimensions().x, (f32)texture->GetDimensions().y);\n        }\n        \n        return Vector2::k_one;\n    }\n    //-----------------------------------------------------------\n    //-----------------------------------------------------------\n    void SpriteComponent::SetSize(const Vector2& in_size)\n    {\n        OnTransformChanged();\n        \n        m_originalSize = in_size;\n    }\n    //-----------------------------------------------------------\n    //-----------------------------------------------------------\n    void SpriteComponent::SetSize(f32 in_width, f32 in_height)\n    {\n        SetSize(Vector2(in_width, in_height));\n    }\n    //-----------------------------------------------------------\n    //-----------------------------------------------------------\n    void SpriteComponent::SetSizePolicy(SizePolicy in_sizePolicy)\n    {\n        OnTransformChanged();\n        \n        m_sizePolicyDelegate = k_sizeDelegates[(u32)in_sizePolicy];\n    }\n    //-----------------------------------------------------------\n    //-----------------------------------------------------------\n    Vector2 SpriteComponent::GetSize() const\n    {\n        Vector2 preferredSize = GetPreferredSize();\n        return m_sizePolicyDelegate(m_originalSize, preferredSize);\n    }\n    //-----------------------------------------------------------\n    //-----------------------------------------------------------\n    void SpriteComponent::SetMaterial(const MaterialCSPtr& in_material)\n    {\n        mpMaterial = in_material;\n    }\n    //-----------------------------------------------------------\n    //-----------------------------------------------------------\n    const MaterialCSPtr& SpriteComponent::GetMaterial() const\n    {\n        return mpMaterial;\n    }\n    //-----------------------------------------------------------\n    //-----------------------------------------------------------\n    void SpriteComponent::SetTextureAtlas(const TextureAtlasCSPtr& in_atlas)\n    {\n        OnTransformChanged();\n        \n        m_textureAtlas = in_atlas;\n    }\n    //-----------------------------------------------------------\n    //-----------------------------------------------------------\n    void SpriteComponent::SetTextureAtlasId(const std::string& in_atlasId)\n    {\n        CS_ASSERT(m_textureAtlas != nullptr, \"SpriteComponent: Cannot set texture atlas id until atlas has been set\");\n        \n        OnTransformChanged();\n        \n        m_hashedTextureAtlasId = HashCRC32::GenerateHashCode(in_atlasId);\n        m_uvs = m_textureAtlas->GetFrameUVs(m_hashedTextureAtlasId);\n    }\n    //-----------------------------------------------------------\n    //-----------------------------------------------------------\n    void SpriteComponent::SetUVs(const UVs& in_uvs)\n    {\n        m_uvs = in_uvs;\n    }\n    //-----------------------------------------------------------\n    //-----------------------------------------------------------\n    void SpriteComponent::SetUVs(f32 in_u, f32 in_v, f32 in_s, f32 in_t)\n    {\n        m_uvs = UVs(in_u, in_v, in_s, in_t);\n    }\n    //-----------------------------------------------------------\n    //-----------------------------------------------------------\n    void SpriteComponent::SetColour(const Colour& in_colour)\n    {\n        m_colour = in_colour;\n    }\n    //-----------------------------------------------------------\n    //-----------------------------------------------------------\n    void SpriteComponent::SetColour(f32 in_r, f32 in_g, f32 in_b, f32 in_a)\n    {\n        SetColour(Colour(in_r, in_g, in_b, in_a));\n    }\n    //-----------------------------------------------------------\n    //-----------------------------------------------------------\n    const Colour& SpriteComponent::GetColour() const\n    {\n        return m_colour;\n    }\n    //-----------------------------------------------------------\n    //-----------------------------------------------------------\n    void SpriteComponent::SetFlippedHorizontally(bool in_flip)\n    {\n        m_flippedHorizontally = in_flip;\n        m_vertexPositionsValid = false;\n    }\n    //-----------------------------------------------------------\n    //-----------------------------------------------------------\n    bool SpriteComponent::IsFlippedHorizontally() const\n    {\n        return m_flippedHorizontally;\n    }\n    //-----------------------------------------------------------\n    //-----------------------------------------------------------\n    void SpriteComponent::SetFlippedVertically(bool in_flip)\n    {\n        m_flippedVertically = in_flip;\n        m_vertexPositionsValid = false;\n    }\n    //-----------------------------------------------------------\n    //-----------------------------------------------------------\n    bool SpriteComponent::IsFlippedVertically() const\n    {\n        return m_flippedVertically;\n    }\n    //-----------------------------------------------------------\n    //-----------------------------------------------------------\n    void SpriteComponent::SetOriginAlignment(AlignmentAnchor in_alignment)\n    {\n        m_originAlignment = in_alignment;\n        m_vertexPositionsValid = false;\n    }\n    //-----------------------------------------------------------\n    //-----------------------------------------------------------\n    AlignmentAnchor SpriteComponent::GetOriginAlignment() const\n    {\n        return m_originAlignment;\n    }\n    //------------------------------------------------------------\n    //------------------------------------------------------------\n    void SpriteComponent::OnTransformChanged()\n    {\n        m_vertexPositionsValid = false;\n        m_isBSValid = false;\n        m_isAABBValid = false;\n        m_isOOBBValid = false;\n    }\n    //-----------------------------------------------------------\n    //-----------------------------------------------------------\n    bool SpriteComponent::IsTextureSizeCacheValid() const\n    {\n        if(m_textureAtlas == nullptr || m_hashedTextureAtlasId == 0)\n        {\n            if(mpMaterial != nullptr && mpMaterial->GetTexture() != nullptr)\n            {\n                auto texture = mpMaterial->GetTexture().get();\n                Vector2 texSize((f32)texture->GetDimensions().x, (f32)texture->GetDimensions().y);\n                \n                return texSize == m_cachedTextureSize;\n            }\n        }\n        \n        return true;\n    }\n    //-----------------------------------------------------------\n    //-----------------------------------------------------------\n    void SpriteComponent::SetTextureSizeCacheValid()\n    {\n        if(mpMaterial != nullptr && mpMaterial->GetTexture() != nullptr)\n        {\n            auto texture = mpMaterial->GetTexture().get();\n            Vector2 texSize((f32)texture->GetDimensions().x, (f32)texture->GetDimensions().y);\n            m_cachedTextureSize = texSize;\n        }\n    }\n    //----------------------------------------------------\n    //----------------------------------------------------\n    void SpriteComponent::OnAddedToScene()\n    {\n        m_transformChangedConnection = GetEntity()->GetTransform().GetTransformChangedEvent().OpenConnection(MakeDelegate(this, &SpriteComponent::OnTransformChanged));\n        \n        OnTransformChanged();\n    }\n    //------------------------------------------------------------\n    //------------------------------------------------------------\n    void SpriteComponent::OnRenderSnapshot(RenderSnapshot& renderSnapshot, IAllocator* frameAllocator) noexcept\n    {\n        Vector2 frameCenter;\n        Vector2 frameSize;\n        if(m_textureAtlas != nullptr && m_hashedTextureAtlasId > 0)\n        {\n            CalcFrameCentreAndSize(frameCenter, frameSize);\n        }\n        else if(mpMaterial != nullptr && mpMaterial->GetTexture() != nullptr)\n        {\n            auto texture = mpMaterial->GetTexture().get();\n            frameSize = m_sizePolicyDelegate(m_originalSize, Vector2((f32)texture->GetDimensions().x, (f32)texture->GetDimensions().y));\n        }\n        \n        UVs transformedUVs = m_uvs;\n        \n        if(m_flippedHorizontally == true && m_flippedVertically == true)\n        {\n            transformedUVs = UVs::FlipDiagonally(transformedUVs);\n        }\n        else if(m_flippedHorizontally == true)\n        {\n            transformedUVs = UVs::FlipHorizontally(transformedUVs);\n        }\n        else if(m_flippedVertically == true)\n        {\n            transformedUVs = UVs::FlipVertically(transformedUVs);\n        }\n        \n        const auto& transform = GetEntity()->GetTransform();\n        auto renderDynamicMesh = SpriteMeshBuilder::Build(frameAllocator, Vector3(frameCenter, 0.0f), frameSize, transformedUVs, m_colour, m_originAlignment);\n        auto boundingSphere = Sphere::Transform(renderDynamicMesh->GetBoundingSphere(), transform.GetWorldPosition(), transform.GetWorldOrientation(), transform.GetWorldScale());\n        renderSnapshot.AddRenderObject(RenderObject(GetMaterial()->GetRenderMaterialGroup(), renderDynamicMesh.get(), transform.GetWorldTransform(), boundingSphere, false, RenderLayer::k_standard));\n        renderSnapshot.AddRenderDynamicMesh(std::move(renderDynamicMesh));\n    }\n    //----------------------------------------------------\n    //----------------------------------------------------\n    void SpriteComponent::OnRemovedFromScene()\n    {\n        m_transformChangedConnection = nullptr;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void SpriteComponent::CalcFrameCentreAndSize(Vector2& out_centre, Vector2& out_size) const\n    {\n        CS_ASSERT((m_textureAtlas != nullptr && m_hashedTextureAtlasId > 0), \"Texture atlas and atlas Id must be valid.\");\n        \n        const auto& frame = m_textureAtlas->GetFrame(m_hashedTextureAtlasId);\n        Vector2 spriteSize = m_sizePolicyDelegate(m_originalSize, frame.m_originalSize);\n        \n        if (m_flippedHorizontally == true)\n        {\n            out_centre.x = (frame.m_originalSize.x * 0.5f) - frame.m_offset.x - (frame.m_croppedSize.x * 0.5f);\n        }\n        else\n        {\n            out_centre.x = (-frame.m_originalSize.x * 0.5f) +  frame.m_offset.x + (frame.m_croppedSize.x * 0.5f);\n        }\n        \n        if (m_flippedVertically == true)\n        {\n            out_centre.y = (-frame.m_originalSize.y * 0.5f) + frame.m_offset.y + (frame.m_croppedSize.y * 0.5f);\n        }\n        else\n        {\n            out_centre.y = (frame.m_originalSize.y * 0.5f) - frame.m_offset.y - (frame.m_croppedSize.y * 0.5f);\n        }\n        \n        Vector2 frameScale = spriteSize / frame.m_originalSize;\n        out_centre = out_centre * frameScale;\n        out_size = frame.m_croppedSize * frameScale;\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Sprite/SpriteComponent.h",
    "content": "//\n//  SpriteComponent.h\n//  ChilliSource\n//  Created by Scott Downie on 29/09/2010.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2010 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_SPRITE_SPRITECOMPONENT_H_\n#define _CHILLISOURCE_RENDERING_SPRITE_SPRITECOMPONENT_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Base/Colour.h>\n#include <ChilliSource/Core/Math/Vector2.h>\n#include <ChilliSource/Core/Math/Geometry/Shapes.h>\n#include <ChilliSource/Core/Volume/VolumeComponent.h>\n#include <ChilliSource/Rendering/Base/AlignmentAnchors.h>\n#include <ChilliSource/Rendering/Texture/UVs.h>\n\n#include <functional>\n\nnamespace ChilliSource\n{\n    //---------------------------------------------------------------\n    /// A render component that draws a 2D textured quad. Sprites\n    /// are rendered using a \"Sprite\" material and can be coloured,\n    /// aligned and have thier UVs changed manually or via a texture\n    /// atlas.\n    ///\n    /// @author S Downie\n    //---------------------------------------------------------------\n    class SpriteComponent final : public VolumeComponent\n    {\n    public: \n        \n        CS_DECLARE_NAMEDTYPE(SpriteComponent);\n        \n        //----------------------------------------------------------------------------------------\n        /// Delegate for size policy functions.\n        ///\n        /// @author S Downie\n        ///\n        /// @param Original size\n        /// @param Preferred size\n        ///\n        /// @return New size with function applied\n        //----------------------------------------------------------------------------------------\n        using SizePolicyDelegate = std::function<Vector2(const Vector2&, const Vector2&)>;\n\n        ///\n        SpriteComponent();\n        \n        /// Creates a sprite with the given material and size\n        ///\n        /// @param material\n        ///     Material the describes how the sprite should be rendered\n        /// @param size\n        ///    Size of the sprite in world units\n        /// @param sizePolicy\n        ///     How the sprite should maintain its aspect ratio when resized\n        ///\n        SpriteComponent(const MaterialCSPtr& material, const Vector2& size, SizePolicy sizePolicy);\n        \n        /// Creates a sprite with the given material and size that references\n        /// a sprite on the given texture atlas.\n        ///\n        /// @param material\n        ///     Material the describes how the sprite should be rendered\n        /// @param atlas\n        ///     Resource that describes where all the sprites are on a texture\n        /// @param atlasId\n        ///     Which of the sprites on the texture should this component use\n        /// @param size\n        ///    Size of the sprite in world units\n        /// @param sizePolicy\n        ///     How the sprite should maintain its aspect ratio when resized\n        ///\n        SpriteComponent(const MaterialCSPtr& material, const TextureAtlasCSPtr& atlas, const std::string& atlasId, const Vector2& size, SizePolicy sizePolicy);\n        \n        //----------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Comparison Type\n        ///\n        /// @return Whether the class matches the comparison type\n        //----------------------------------------------------------\n        bool IsA(InterfaceIDType in_interfaceId) const override;\n        //----------------------------------------------------\n        /// The axis aligned bounding box is positioned in\n        /// world space but the orientation is aligned to\n        /// the x-y plane. This is cached and recomputed when\n        /// tranform is changed.\n        ///\n        /// @author S Downie\n        ///\n        /// @return AABB in world space\n        //----------------------------------------------------\n        const AABB& GetAABB() override;\n        //----------------------------------------------------\n        /// The object oriented bounding box complete with transform to\n        /// transform from local space to world space. This is cached\n        /// and recomputed when tranform is changed.\n        ///\n        /// @author S Downie\n        ///\n        /// @return OOBB in local space with world transform\n        //----------------------------------------------------\n        const OOBB& GetOOBB() override;\n        //----------------------------------------------------\n        /// All render objects have an bounding sphere for\n        /// culling. This is cached and recomputed when tranform\n        /// is changed. The bounding sphere encompasses\n        /// the diagonal axis of the sprite\n        ///\n        /// @author S Downie\n        ///\n        /// @return world space bounding sphere\n        //----------------------------------------------------\n        const Sphere& GetBoundingSphere() override;\n        //----------------------------------------------------\n        /// Is Visible\n        ///\n        /// @return Whether or not to render\n        //----------------------------------------------------\n        bool IsVisible() const override { return m_isVisible; }\n        //----------------------------------------------------\n        /// Is Visible\n        ///\n        /// @param in_isVisible - Whether or not to render\n        //----------------------------------------------------\n        void SetVisible(bool in_isVisible) { m_isVisible = in_isVisible; }\n        //-----------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Vector containing width and height of sprite in\n        /// local space\n        //-----------------------------------------------------------\n        void SetSize(const Vector2& in_size);\n        //-----------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Width in local space\n        /// @param Height in local space\n        //-----------------------------------------------------------\n        void SetSize(f32 in_width, f32 in_height);\n        //-----------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Size policy that governs how the set size and\n        /// the image size are accommodated. Usually by maintaining\n        /// the aspect ratio of the image.\n        //-----------------------------------------------------------\n        void SetSizePolicy(SizePolicy in_sizePolicy);\n        //-----------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Size after the size policy has been applied\n        //-----------------------------------------------------------\n        Vector2 GetSize() const;\n        //-----------------------------------------------------------\n        /// Sets the material\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param in_material - The material\n        //-----------------------------------------------------------\n        void SetMaterial(const MaterialCSPtr& in_material);\n        //-----------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The material\n        //-----------------------------------------------------------\n        const MaterialCSPtr& GetMaterial() const;\n        //-----------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Texture atlas\n        //-----------------------------------------------------------\n        void SetTextureAtlas(const TextureAtlasCSPtr& in_atlas);\n        //-----------------------------------------------------------\n        /// Set the id of the frame that will be used to texture\n        /// the sprite. This will supercede and UVs that have been\n        /// set on the sprite\n        ///\n        /// @author S Downie\n        ///\n        /// @param Texture atlas id\n        //-----------------------------------------------------------\n        void SetTextureAtlasId(const std::string& in_atlasId);\n        //-----------------------------------------------------------\n        /// Set the texture co-ordinates\n        ///\n        /// @author S Downie\n        ///\n        /// @param Rect containing uv, st\n        //-----------------------------------------------------------\n        void SetUVs(const UVs& in_uvs);\n        //-----------------------------------------------------------\n        /// Set the UV texture coordinates\n        ///\n        /// @author S Downie\n        ///\n        /// @param U\n        /// @param V\n        /// @param S\n        /// @param T\n        //-----------------------------------------------------------\n        void SetUVs(f32 in_u, f32 in_v, f32 in_s, f32 in_t);\n        //-----------------------------------------------------------\n        /// Set the RGBA colour of the sprite. This is independent\n        /// of the material colour and is applied on a per sprite\n        /// basis\n        ///\n        /// @author S Downie\n        ///\n        /// @param Colour containing RGBA\n        //-----------------------------------------------------------\n        void SetColour(const Colour& in_colour);\n        //-----------------------------------------------------------\n        /// Set the RGBA colour of the sprite. This is independent\n        /// of the material colour and is applied on a per sprite\n        /// basis\n        ///\n        /// @author S Downie\n        ///\n        /// @param Red\n        /// @param Green\n        /// @param Blue\n        /// @param Alpha\n        //-----------------------------------------------------------\n        void SetColour(f32 in_r, f32 in_g, f32 in_b, f32 in_a);\n        //-----------------------------------------------------------\n        /// Get Colour\n        ///\n        /// @return Sprite colour\n        //-----------------------------------------------------------\n        const Colour& GetColour() const;\n        //-----------------------------------------------------------\n        /// Flip the sprite UVs about it's local x-axis\n        ///\n        /// @author S Downie\n        ///\n        /// @param Whether to flip or not\n        //-----------------------------------------------------------\n        void SetFlippedHorizontally(bool in_flip);\n        //-----------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Whether sprite is flipped about it's local x-axis\n        //-----------------------------------------------------------\n        bool IsFlippedHorizontally() const;\n        //-----------------------------------------------------------\n        /// Flip the sprite UVs about it's local y-axis\n        ///\n        /// @author S Downie\n        ///\n        /// @param Whether to flip or not\n        //-----------------------------------------------------------\n        void SetFlippedVertically(bool in_flip);\n        //-----------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Whether sprite is flipped about it's local y-axis\n        //-----------------------------------------------------------\n        bool IsFlippedVertically() const;\n        //-----------------------------------------------------------\n        /// Controls the origin of the sprite relative to its position.\n        /// An origin of middle centre will draw the sprite with its\n        /// centre at its world position. An origin of bottom centre\n        /// will draw the sprite with its base at its world position\n        ///\n        /// @author S Downie\n        ///\n        /// @param Alignment (middle-centre by default)\n        //-----------------------------------------------------------\n        void SetOriginAlignment(AlignmentAnchor in_alignment);\n        //-----------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Returns alignment of this sprite's origin\n        //-----------------------------------------------------------\n        AlignmentAnchor GetOriginAlignment() const;\n        \n    private:\n        //------------------------------------------------------------\n        /// Triggered when the component is attached to an entity on\n        /// the scene\n        ///\n        /// @author S Downie\n        //------------------------------------------------------------\n        void OnAddedToScene() override;\n        //------------------------------------------------------------\n        /// Called during the Render Snapshot phase of the render\n        /// pipeline to capture all render primitives in the scene.\n        /// This builds a new dynamic mesh for the sprite described\n        /// by this component and adds a new render object which uses\n        /// it.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param renderSnapshot - The snapshot containing all\n        /// data pertaining to a single frame.\n        /// @param frameAllocator - Use this to allocate any memory\n        /// for this render frame\n        //------------------------------------------------------------\n        void OnRenderSnapshot(RenderSnapshot& renderSnapshot, IAllocator* frameAllocator) noexcept override;\n        //------------------------------------------------------------\n        /// Triggered when the component is removed from an entity on\n        /// the scene\n        ///\n        /// @author S Downie\n        //------------------------------------------------------------\n        void OnRemovedFromScene() override;\n        //------------------------------------------------------------\n        /// On Transform Changed\n        ///\n        /// Our local transform or our parent transform has changed\n        /// We must rebuild our sprite data\n        //------------------------------------------------------------\n        void OnTransformChanged();\n        //-----------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Preferred size based on the current atlas, id or texture\n        //-----------------------------------------------------------\n        Vector2 GetPreferredSize() const;\n        //-----------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Whether the texture has changed in a manner to\n        /// invalidate the size cache\n        //-----------------------------------------------------------\n        bool IsTextureSizeCacheValid() const;\n        //-----------------------------------------------------------\n        /// Once the sprite has adjusted to the new texture size\n        /// it can flag it as no longer dirty\n        ///\n        /// @author S Downie\n        //-----------------------------------------------------------\n        void SetTextureSizeCacheValid();\n        //------------------------------------------------------------------------------\n        /// Calculates the frame centre and size for the current texture atlas. Vertical\n        /// and horizontal flipping are taken into account when calculating the centre.\n        /// This should only be called when there is a texture atlas, otherwise the\n        /// app is considered to be in an irrecoverable state and will exit.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param out_centre - [Output] The frame centre from the centre of the sprite.\n        /// @param out_size - [Output] The sprite frame size.\n        //------------------------------------------------------------------------------\n        void CalcFrameCentreAndSize(Vector2& out_centre, Vector2& out_size) const;\n\n    private:\n        EventConnectionUPtr m_transformChangedConnection;\n    \n        TextureAtlasCSPtr m_textureAtlas;\n        u32 m_hashedTextureAtlasId = 0;\n    \n        SizePolicyDelegate m_sizePolicyDelegate;\n        Vector2 m_cachedTextureSize;\n        Vector2 m_originalSize;\n        \n        UVs m_uvs;\n        \n        Colour m_colour;\n        \n        AlignmentAnchor m_originAlignment = AlignmentAnchor::k_middleCentre;\n        \n        bool m_flippedHorizontally = false;\n        bool m_flippedVertically = false;\n        bool m_vertexPositionsValid = false;\n        \n        bool m_isBSValid = false;\n        bool m_isAABBValid = false;\n        bool m_isOOBBValid = false;\n        \n        AABB mBoundingBox;\n        OOBB mOBBoundingBox;\n        Sphere mBoundingSphere;\n        MaterialCSPtr mpMaterial;\n        bool m_isVisible = true;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Sprite/SpriteMeshBuilder.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Sprite/SpriteMeshBuilder.h>\n\n#include <ChilliSource/Core/Base/ByteBuffer.h>\n#include <ChilliSource/Core/Base/ByteColour.h>\n#include <ChilliSource/Core/Base/Colour.h>\n#include <ChilliSource/Core/Base/ColourUtils.h>\n#include <ChilliSource/Core/Math/Vector2.h>\n#include <ChilliSource/Core/Math/Vector4.h>\n#include <ChilliSource/Core/Math/Geometry/Shapes.h>\n#include <ChilliSource/Core/Memory/UniquePtr.h>\n#include <ChilliSource/Rendering/Base/AlignmentAnchors.h>\n#include <ChilliSource/Rendering/Model/IndexFormat.h>\n#include <ChilliSource/Rendering/Model/PolygonType.h>\n#include <ChilliSource/Rendering/Model/RenderDynamicMesh.h>\n#include <ChilliSource/Rendering/Model/VertexFormat.h>\n#include <ChilliSource/Rendering/Texture/UVs.h>\n\n#include <cstring>\n\nnamespace ChilliSource\n{\n    namespace\n    {\n        constexpr u32 k_numVertices = 4;\n        constexpr u32 k_numIndices = 6;\n        \n        const u16 k_indices[k_numIndices] { 0, 1, 2, 1, 3, 2 };\n        \n        /// A description of a sprite vertex.\n        ///\n        struct SpriteVertex final\n        {\n            Vector4 m_position;\n            Vector2 m_uv;\n            ByteColour m_colour;\n        };\n        \n        /// An enum describing each of the vertices in a sprite.\n        ///\n        enum class SpriteVertices\n        {\n            k_topLeft,\n            k_bottomLeft,\n            k_topRight,\n            k_bottomRight\n        };\n        \n        constexpr u32 k_vertexDataSize = sizeof(SpriteVertex) * k_numVertices;\n        constexpr u32 k_indexDataSize = sizeof(u16) * k_numIndices;\n        \n        /// Apples the positional data derrived from the given description to the vertices.\n        ///\n        /// @param vertices\n        ///     The vertices to apply the positional data to.\n        /// @param localPosition\n        ///     The local position of the sprite. This is often used to offset the sprite as required\n        ///     by the cropping performed by texture packing.\n        /// @param localSize\n        ///     The local size of the sprite.\n        /// @param alignmentAnchor\n        ///     The alignmentAnchor of the sprite.\n        ///\n        void ApplyVertexPosition(SpriteVertex* vertices, const Vector3& localPosition, const Vector2& localSize, AlignmentAnchor alignmentAnchor) noexcept\n        {\n            Vector2 halfSize = 0.5f * localSize;\n            Vector2 anchor = GetAnchorPoint(alignmentAnchor, halfSize);\n            Vector4 centre = Vector4(localPosition, 1.0f) + Vector4(-anchor.x, -anchor.y, 0.0f, 0.0f);\n            \n            vertices[static_cast<u32>(SpriteVertices::k_topLeft)].m_position = centre + Vector4(-halfSize.x, halfSize.y, 0.0f, 0.0f);\n            vertices[static_cast<u32>(SpriteVertices::k_bottomLeft)].m_position = centre + Vector4(-halfSize.x, -halfSize.y, 0.0f, 0.0f);\n            vertices[static_cast<u32>(SpriteVertices::k_topRight)].m_position = centre + Vector4(halfSize.x, halfSize.y, 0.0f, 0.0f);\n            vertices[static_cast<u32>(SpriteVertices::k_bottomRight)].m_position = centre + Vector4(halfSize.x, -halfSize.y, 0.0f, 0.0f);\n        }\n        \n        /// Apples the given UVs to the vertices that make up a sprite.\n        ///\n        /// @param vertices\n        ///     The vertices to apply the colour to.\n        /// @param uvs\n        ///     The UVs which should be applied.\n        ///\n        void ApplyVertexUvs(SpriteVertex* vertices, const UVs& uvs) noexcept\n        {\n            vertices[static_cast<u32>(SpriteVertices::k_topLeft)].m_uv.x = uvs.m_u;\n            vertices[static_cast<u32>(SpriteVertices::k_topLeft)].m_uv.y = uvs.m_v;\n            vertices[static_cast<u32>(SpriteVertices::k_bottomLeft)].m_uv.x = uvs.m_u;\n            vertices[static_cast<u32>(SpriteVertices::k_bottomLeft)].m_uv.y = uvs.m_v + uvs.m_t;\n            vertices[static_cast<u32>(SpriteVertices::k_topRight)].m_uv.x = uvs.m_u + uvs.m_s;\n            vertices[static_cast<u32>(SpriteVertices::k_topRight)].m_uv.y = uvs.m_v;\n            vertices[static_cast<u32>(SpriteVertices::k_bottomRight)].m_uv.x = uvs.m_u + uvs.m_s;\n            vertices[static_cast<u32>(SpriteVertices::k_bottomRight)].m_uv.y = uvs.m_v + uvs.m_t;\n        }\n        \n        /// Applies the given colour to all of the vertices in the sprite.\n        ///\n        /// @param vertices\n        ///     The vertices to apply the colour to.\n        /// @param colour\n        ///     The colour to apply.\n        ///\n        void ApplyVertexColour(SpriteVertex* vertices, const Colour& colour) noexcept\n        {\n            ByteColour byteColour = ColourUtils::ColourToByteColour(colour);\n            \n            vertices[static_cast<u32>(SpriteVertices::k_topLeft)].m_colour = byteColour;\n            vertices[static_cast<u32>(SpriteVertices::k_bottomLeft)].m_colour = byteColour;\n            vertices[static_cast<u32>(SpriteVertices::k_topRight)].m_colour = byteColour;\n            vertices[static_cast<u32>(SpriteVertices::k_bottomRight)].m_colour = byteColour;\n        }\n        \n        /// Creates the sprite vertex data from the given description. The data will be allocated from\n        /// the given allocator.\n        ///\n        /// @param allocator\n        ///     The allocator which should be used to create the buffer.\n        /// @param localPosition\n        ///     The local position of the sprite. This is often used to offset the sprite as required\n        ///     by the cropping performed by texture packing.\n        /// @param localSize\n        ///     The local size of the sprite.\n        /// @param uvs\n        ///     The UVs which should be applied.\n        /// @param colour\n        ///     The colour to apply.\n        /// @param alignmentAnchor\n        ///     The alignmentAnchor of the sprite.\n        ///\n        UniquePtr<u8[]> BuildVertexData(IAllocator* allocator, const Vector3& localPosition, const Vector2& localSize, const UVs& uvs, const Colour& colour, AlignmentAnchor alignmentAnchor) noexcept\n        {\n            auto vertexData = MakeUniqueArray<u8>(*allocator, k_vertexDataSize);\n            \n            ApplyVertexPosition(reinterpret_cast<SpriteVertex*>(vertexData.get()), localPosition, localSize, alignmentAnchor);\n            ApplyVertexUvs(reinterpret_cast<SpriteVertex*>(vertexData.get()), uvs);\n            ApplyVertexColour(reinterpret_cast<SpriteVertex*>(vertexData.get()), colour);\n            \n            return vertexData;\n        }\n        \n        /// Creates the index data. This data will be allocated from the given allocator.\n        ///\n        /// @return A new instance of the index data. This will always be the same 6 indices.\n        ///\n        UniquePtr<u8[]> BuildIndexData(IAllocator* allocator) noexcept\n        {\n            auto indexData = MakeUniqueArray<u8>(*allocator, k_indexDataSize);\n            \n            memcpy(indexData.get(), k_indices, k_indexDataSize);\n            \n            return indexData;\n        }\n        \n        /// Calculates the bounding sphere required for sprite with the given positional data.\n        ///\n        /// @param localPosition\n        ///     The local position of the sprite.\n        /// @param localSize\n        ///     The local size of the sprite.\n        /// @param alignmentAnchor\n        ///     The alignment anchor of the sprite.\n        ///\n        Sphere CalcBoundingSphere(const Vector3& localPosition, const Vector2& localSize, AlignmentAnchor alignmentAnchor) noexcept\n        {\n            Vector2 halfSize = 0.5f * localSize;\n            Vector2 anchor = GetAnchorPoint(alignmentAnchor, halfSize);\n            \n            Vector3 centre = localPosition + Vector3(-anchor.x, -anchor.y, 0.0f);\n            f32 radius = halfSize.Length();\n            \n            return Sphere(centre, radius);\n        }\n    }\n    \n    //------------------------------------------------------------------------------\n    RenderDynamicMeshAUPtr SpriteMeshBuilder::Build(IAllocator* allocator, const Vector3& localPosition, const Vector2& localSize, const UVs& uvs, const Colour& colour, AlignmentAnchor alignmentAnchor) noexcept\n    {\n        auto polygonType = PolygonType::k_triangle;\n        auto vertexData = BuildVertexData(allocator, localPosition, localSize, uvs, colour, alignmentAnchor);\n        auto indexData = BuildIndexData(allocator);\n        Sphere boundingSphere = CalcBoundingSphere(localPosition, localSize, alignmentAnchor);\n        \n        return MakeUnique<RenderDynamicMesh>(*allocator, polygonType, VertexFormat::k_sprite, IndexFormat::k_short, k_numVertices, k_numIndices, boundingSphere, std::move(vertexData), k_vertexDataSize, std::move(indexData), k_indexDataSize);\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Sprite/SpriteMeshBuilder.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_SPRITE_SPRITEMESHBUILDER_H_\n#define _CHILLISOURCE_RENDERING_SPRITE_SPRITEMESHBUILDER_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Rendering/Model/RenderDynamicMesh.h>\n\nnamespace ChilliSource\n{\n    /// A collection of methods for building sprite RenderDynamicMeshes.\n    ///\n    /// These are thread-safe.\n    ///\n    namespace SpriteMeshBuilder\n    {\n        /// Generates a new RenderDynamicMesh for a sprite with the given properties. The sprite\n        /// will be generated as a plane with its normal facing down the negative z axis.\n        ///\n        /// All required memory will be allocated from the given allocator.\n        ///\n        /// @param allocator\n        ///     The allocator which should be used for all allocations.\n        /// @param localPosition\n        ///     The local position of the sprite. This is often used for offsetting the\n        ///     sprite to account for cropping during texture packing.\n        /// @param localSize\n        ///     The size of the sprite in local space. The rendered size may be different\n        ///     depending on the world transform.\n        /// @param worldTransform\n        ///     The world transform of the sprite.\n        /// @param uvs\n        ///     The UVs of each of the four vertices of the sprite.\n        /// @param colour\n        ///     The colour of the sprite. This will be applied to the vertex colours.\n        /// @param alignmentAchor\n        ///     The alignmentAnchor of the sprite.\n        ///\n        RenderDynamicMeshAUPtr Build(IAllocator* allocator, const Vector3& localPosition, const Vector2& localSize, const UVs& uvs, const Colour& colour, AlignmentAnchor alignmentAnchor) noexcept;\n    }\n}\n\n#endif"
  },
  {
    "path": "Source/ChilliSource/Rendering/Sprite.h",
    "content": "//\n//  Sprite.h\n//  ChilliSource\n//  Created by Ian Copland on 07/07/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n\n#ifndef _CHILLISOURCE_RENDERING_SPRITE_H_\n#define _CHILLISOURCE_RENDERING_SPRITE_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Rendering/Sprite/SpriteComponent.h>\n#include <ChilliSource/Rendering/Sprite/SpriteMeshBuilder.h>\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Target/RenderTargetGroup.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Target/RenderTargetGroup.h>\n\n#include <ChilliSource/Rendering/Texture/RenderTexture.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    RenderTargetGroup::RenderTargetGroup(const RenderTexture* colourTarget, const RenderTexture* depthTarget, RenderTargetGroupType type) noexcept\n        : m_colourTarget(colourTarget), m_depthTarget(depthTarget), m_type(type)\n    {\n        CS_ASSERT(colourTarget || depthTarget, \"Must supply either a colour target or a depth target.\");\n        \n        if (colourTarget && depthTarget)\n        {\n            CS_ASSERT(colourTarget->GetDimensions() == depthTarget->GetDimensions(), \"All render targets must have the same dimensions\");\n        }\n        \n        if (colourTarget)\n        {\n            CS_ASSERT(colourTarget->GetImageFormat() != ImageFormat::k_Depth16 && colourTarget->GetImageFormat() != ImageFormat::k_Depth32, \"Colour target cannot be depth texture.\");\n            CS_ASSERT(colourTarget->GetImageCompression() == ImageCompression::k_none, \"Colour target cannot be compressed.\");\n            CS_ASSERT(colourTarget->IsMipmapped() == false, \"Colour target cannot be mipmapped.\");\n            \n            m_resolution = colourTarget->GetDimensions();\n        }\n        \n        if (depthTarget)\n        {\n            CS_ASSERT(depthTarget->GetImageFormat() == ImageFormat::k_Depth16 || depthTarget->GetImageFormat() == ImageFormat::k_Depth32, \"Depth target must be depth texture.\");\n            CS_ASSERT(depthTarget->GetImageCompression() == ImageCompression::k_none, \"Depth target cannot be compressed.\");\n            CS_ASSERT(depthTarget->IsMipmapped() == false, \"Depth target cannot be mipmapped.\");\n            CS_ASSERT(m_type == RenderTargetGroupType::k_colour, \"If a depth target is supplied, type must be colour only.\");\n            \n            m_resolution = depthTarget->GetDimensions();\n        }\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Target/RenderTargetGroup.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_TARGET_RENDERTARGETGROUP_H_\n#define _CHILLISOURCE_RENDERING_TARGET_RENDERTARGETGROUP_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Math/Vector2.h>\n\nnamespace ChilliSource\n{\n    enum class RenderTargetGroupType\n    {\n        k_colour,\n        k_colourDepth,\n        k_colourDepthStencil\n    };\n    \n    /// Represents a group of colour and depth render targets that can be bound for rendering.\n    /// There are two types of render target: colour and depth. Fragment colour data will be\n    /// written to the colour target, while fragment depth data will be written to the depth\n    /// target.\n    ///\n    /// This is immutable and therefore thread safe, aside from extra data which should only\n    /// be accessed from the render thread.\n    ///\n    class RenderTargetGroup final\n    {\n    public:\n        \n        CS_DECLARE_NOCOPY(RenderTargetGroup);\n        \n        /// Creates a new instance with the given colour and depth targets. At least one target\n        /// must be supplied or this will assert.\n        ///\n        /// SHOULD ONLY BE CREATED VIA RenderTargetGroupManager\n        ///\n        /// @param colourTarget\n        ///     The colour render target. Can be null if no colour target is needed.\n        /// @param depthTarget\n        ///     The depth render target. Can be null if no depth target is needed.\n        /// @param type\n        ///     Whether or not to use an internal depth buffer or stencil buffer.\n        ///     NOTE: Stencil requires depth and type must be colour only if explicit depth target is supplied\n        ///\n        RenderTargetGroup(const RenderTexture* colourTarget, const RenderTexture* depthTarget, RenderTargetGroupType type) noexcept;\n        \n        /// @return The colour render target. Can be null if no colour target is needed.\n        ///\n        const RenderTexture* GetColourTarget() const noexcept { return m_colourTarget; }\n        \n        /// @return The depth render target. Can be null if no depth target is needed.\n        ///\n        const RenderTexture* GetDepthTarget() const noexcept { return m_depthTarget; }\n        \n        /// @return Whether or not to use an internal depth buffer if no depth target was specified.\n        ///     This should always be false if a depth target was supplied.\n        ///\n        bool ShouldUseDepthBuffer() const noexcept { return m_type == RenderTargetGroupType::k_colourDepth || m_type == RenderTargetGroupType::k_colourDepthStencil; }\n        \n        /// @return Whether or not to use an internal stencil buffer.\n        ///     This should always be false if not using a depth buffer.\n        ///\n        bool ShouldUseStencilBuffer() const noexcept { return m_type == RenderTargetGroupType::k_colourDepthStencil; }\n        \n        /// @return The resolution of the render target.\n        ///\n        const Integer2& GetResolution() const noexcept { return m_resolution; }\n        \n        /// This is not thread safe and should only be called from the render thread.\n        ///\n        /// @return A pointer to render system specific additional information.\n        ///\n        void* GetExtraData() const noexcept { return m_extraData; }\n        \n        /// This is not thread safe and should only be called from the render thread.\n        ///\n        /// @param extraData\n        ///     A pointer to render system specific additional information.\n        ///\n        void SetExtraData(void* extraData) noexcept { m_extraData = extraData; }\n        \n    private:\n        \n        const RenderTexture* m_colourTarget;\n        const RenderTexture* m_depthTarget;\n        RenderTargetGroupType m_type;\n        Integer2 m_resolution;\n        void* m_extraData = nullptr;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Target/RenderTargetGroupManager.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Target/RenderTargetGroupManager.h>\n\n#include <ChilliSource/Rendering/Base/RenderSnapshot.h>\n#include <ChilliSource/Rendering/Base/TargetType.h>\n\nnamespace ChilliSource\n{\n    namespace\n    {\n        constexpr u32 k_groupPoolSize = 10;\n    }\n    \n    CS_DEFINE_NAMEDTYPE(RenderTargetGroupManager);\n\n    //------------------------------------------------------------------------------\n    RenderTargetGroupManagerUPtr RenderTargetGroupManager::Create() noexcept\n    {\n        return RenderTargetGroupManagerUPtr(new RenderTargetGroupManager());\n    }\n    \n    //------------------------------------------------------------------------------\n    RenderTargetGroupManager::RenderTargetGroupManager()\n    : m_renderTargetGroupPool(k_groupPoolSize, ObjectPoolAllocatorLimitPolicy::k_expand)\n    {\n        \n    }\n\n    //------------------------------------------------------------------------------\n    bool RenderTargetGroupManager::IsA(InterfaceIDType interfaceId) const noexcept\n    {\n        return (RenderTargetGroupManager::InterfaceID == interfaceId);\n    }\n\n    //------------------------------------------------------------------------------\n    UniquePtr<RenderTargetGroup> RenderTargetGroupManager::CreateRenderTargetGroup(const RenderTexture* colourTarget, const RenderTexture* depthTarget) noexcept\n    {\n        CS_ASSERT(colourTarget, \"Must supply a colour target.\");\n        CS_ASSERT(depthTarget, \"Must supply a depth target.\");\n        \n        UniquePtr<RenderTargetGroup> renderTargetGroup(MakeUnique<RenderTargetGroup>(m_renderTargetGroupPool, colourTarget, depthTarget, RenderTargetGroupType::k_colour));\n        auto renderTargetGroupRaw = renderTargetGroup.get();\n        \n        std::unique_lock<std::mutex> lock(m_mutex);\n        m_renderTargetGroups.push_back(renderTargetGroupRaw);\n        m_pendingLoadCommands.push_back(renderTargetGroupRaw);\n        \n        return renderTargetGroup;\n    }\n\n    //------------------------------------------------------------------------------\n    UniquePtr<RenderTargetGroup> RenderTargetGroupManager::CreateColourRenderTargetGroup(const RenderTexture* colourTarget, RenderTargetGroupType type) noexcept\n    {\n        CS_ASSERT(colourTarget, \"Must supply a colour target.\");\n        \n        UniquePtr<RenderTargetGroup> renderTargetGroup(MakeUnique<RenderTargetGroup>(m_renderTargetGroupPool, colourTarget, nullptr, type));\n        auto renderTargetGroupRaw = renderTargetGroup.get();\n        \n        std::unique_lock<std::mutex> lock(m_mutex);\n        m_renderTargetGroups.push_back(renderTargetGroupRaw);\n        m_pendingLoadCommands.push_back(renderTargetGroupRaw);\n        \n        return renderTargetGroup;\n    }\n\n    //------------------------------------------------------------------------------\n    UniquePtr<RenderTargetGroup> RenderTargetGroupManager::CreateDepthRenderTargetGroup(const RenderTexture* depthTarget) noexcept\n    {\n        CS_ASSERT(depthTarget, \"Must supply a depth target.\");\n        \n        UniquePtr<RenderTargetGroup> renderTargetGroup(MakeUnique<RenderTargetGroup>(m_renderTargetGroupPool, nullptr, depthTarget, RenderTargetGroupType::k_colour));\n        auto renderTargetGroupRaw = renderTargetGroup.get();\n        \n        std::unique_lock<std::mutex> lock(m_mutex);\n        m_renderTargetGroups.push_back(renderTargetGroupRaw);\n        m_pendingLoadCommands.push_back(renderTargetGroupRaw);\n        \n        return renderTargetGroup;\n    }\n    \n    //------------------------------------------------------------------------------\n    std::vector<const RenderTargetGroup*> RenderTargetGroupManager::GetRenderTargetGroups() noexcept\n    {\n        std::unique_lock<std::mutex> lock(m_mutex);\n        return m_renderTargetGroups;\n    }\n    \n    //------------------------------------------------------------------------------\n    void RenderTargetGroupManager::DestroyRenderTargetGroup(UniquePtr<RenderTargetGroup> renderTargetGroup) noexcept\n    {\n        std::unique_lock<std::mutex> lock(m_mutex);\n        \n        for (auto it = m_renderTargetGroups.begin(); it != m_renderTargetGroups.end(); ++it)\n        {\n            if (*it == renderTargetGroup.get())\n            {\n                std::swap(m_renderTargetGroups.back(), *it);\n                m_renderTargetGroups.pop_back();\n                break;\n            }\n        }\n        \n        m_pendingUnloadCommands.push_back(std::move(renderTargetGroup));\n    }\n\n    //------------------------------------------------------------------------------\n    void RenderTargetGroupManager::OnRenderSnapshot(TargetType targetType, RenderSnapshot& renderSnapshot, IAllocator* frameAllocator) noexcept\n    {\n        if(targetType == TargetType::k_main)\n        {\n            auto preRenderCommandList = renderSnapshot.GetPreRenderCommandList();\n            auto postRenderCommandList = renderSnapshot.GetPostRenderCommandList();\n            \n            std::unique_lock<std::mutex> lock(m_mutex);\n            \n            for (auto& loadCommand : m_pendingLoadCommands)\n            {\n                preRenderCommandList->AddLoadTargetGroupCommand(loadCommand);\n            }\n            m_pendingLoadCommands.clear();\n            \n            for (auto& unloadCommand : m_pendingUnloadCommands)\n            {\n                postRenderCommandList->AddUnloadTargetGroupCommand(std::move(unloadCommand));\n            }\n            m_pendingUnloadCommands.clear();\n        }\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Target/RenderTargetGroupManager.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_TARGET_RENDERTARGETGROUPMANAGER_H_\n#define _CHILLISOURCE_RENDERING_TARGET_RENDERTARGETGROUPMANAGER_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Memory/ObjectPoolAllocator.h>\n#include <ChilliSource/Core/Memory/UniquePtr.h>\n#include <ChilliSource/Core/System/AppSystem.h>\n#include <ChilliSource/Rendering/Target/RenderTargetGroup.h>\n\n#include <mutex>\n#include <vector>\n\nnamespace ChilliSource\n{\n    /// Manages the lifecycle of all RenderTargetGroup instances.\n    ///\n    /// On creation of a RenderTarget a LoadTargetGroupRenderCommand is queued for the next render\n    /// snapshot phase, ensuring that related target data is processed before the RenderTargetGroup\n    /// is used.\n    ///\n    /// On deletion an UnloadTargetGroupRenderCommand is queued and given ownership of the\n    /// RenderTargetGroup. The render texture is then deleted once the command has been processed.\n    ///\n    /// This is thread-safe and can be called from any thread. If it is called on a background\n    /// thread, care needs to be taken to ensure any created RenderTargetGroups are not used prior\n    /// to being loaded.\n    ///\n    class RenderTargetGroupManager final : public AppSystem\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(RenderTargetGroupManager);\n        \n        /// Allows querying of whether or not this system implements the interface described by the\n        /// given interface Id. Typically this is not called directly as the templated equivalent\n        /// IsA<Interface>() is preferred.\n        ///\n        /// @param interfaceId\n        ///     The Id of the interface.\n        ///\n        /// @return Whether or not the interface is implemented.\n        ///\n        bool IsA(InterfaceIDType interfaceId) const noexcept override;\n        \n        /// Creates a new RenderTargetGroup and queues a LoadTargetGroupRenderCommand for the next RenderSnapshot\n        /// stage in the render pipeline.\n        ///\n        /// @param colourTarget\n        ///     The texture that will be used as the colour target. must not be null.\n        /// @param depthTarget\n        ///     The texture that will be used as the depth target. must not be null.\n        ///\n        /// @return The new render target group instance.\n        ///\n        UniquePtr<RenderTargetGroup> CreateRenderTargetGroup(const RenderTexture* colourTarget, const RenderTexture* depthTarget) noexcept;\n        \n        /// Creates a new colour only RenderTargetGroup and queues a LoadTargetGroupRenderCommand for the next\n        /// RenderSnapshot stage in the render pipeline.\n        ///\n        /// @param colourTarget\n        ///     The texture that will be used as the colour target. must not be null.\n        /// @param type\n        ///     Whether or not an internal, efficient, depth buffer or stencil buffer should be used.\n        ///\n        /// @return The new render target group instance.\n        ///\n        UniquePtr<RenderTargetGroup> CreateColourRenderTargetGroup(const RenderTexture* colourTarget, RenderTargetGroupType type) noexcept;\n        \n        /// Creates a new depth only RenderTargetGroup and queues a LoadTargetGroupRenderCommand for the next\n        /// RenderSnapshot stage in the render pipeline.\n        ///\n        /// @param depthTarget\n        ///     The texture that will be used as the depth target. must not be null.\n        ///\n        /// @return The new render target group instance.\n        ///\n        UniquePtr<RenderTargetGroup> CreateDepthRenderTargetGroup(const RenderTexture* depthTarget) noexcept;\n     \n        /// @return A copy of the render target groups\n        ///\n        std::vector<const RenderTargetGroup*> GetRenderTargetGroups() noexcept;\n        \n        /// Removes the render target group from the manager and queues an UnloadTargetGroupRenderCommand\n        /// for the next Render Snapshot stage in the render pipeline. The render command is given\n        /// ownership of the render target group, ensuring it won't be destroyed until it is no longer\n        /// used.\n        ///\n        /// @param renderTargetGroup\n        ///     The render target group which should be destroyed.\n        ///\n        void DestroyRenderTargetGroup(UniquePtr<RenderTargetGroup> renderTargetGroup) noexcept;\n        \n    private:\n        friend class Application;\n        \n        /// A factory method for creating new instances of the system. This must be called by\n        /// Application.\n        ///\n        /// @return The new instance of the system.\n        ///\n        static RenderTargetGroupManagerUPtr Create() noexcept;\n        \n        RenderTargetGroupManager();\n        \n        /// Called during the Render Snapshot stage of the render pipeline. All pending load and\n        /// unload commands are added to the render snapshot.\n        ///\n        /// @param targetType\n        ///     Whether the snapshot is for the main screen or an offscreen render target\n        /// @param renderSnapshot\n        ///     The render shapshot for storing snapshotted data.\n        /// @param frameAllocator\n        ///     Allocate memory for this render frame from here\n        ///\n        void OnRenderSnapshot(TargetType targetType, RenderSnapshot& renderSnapshot, IAllocator* frameAllocator) noexcept override;\n        \n        std::mutex m_mutex;\n        ObjectPoolAllocator<RenderTargetGroup> m_renderTargetGroupPool;\n        std::vector<const RenderTargetGroup*> m_renderTargetGroups;\n        std::vector<RenderTargetGroup*> m_pendingLoadCommands;\n        std::vector<UniquePtr<RenderTargetGroup>> m_pendingUnloadCommands;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Target/TargetGroup.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Target/TargetGroup.h>\n\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Rendering/Target/RenderTargetGroupManager.h>\n#include <ChilliSource/Rendering/Texture/Texture.h>\n\nnamespace ChilliSource\n{\n    namespace\n    {\n        /// Creates a RenderTargetGroup for the passed in combination of colour/depth targets.\n        ///\n        /// @param colourTarget\n        ///     The colour render target. Can be null if no colour target is needed.\n        /// @param depthTarget\n        ///     The depth render target. Can be null if no depth target is needed.\n        /// @param type\n        ///    Whether or not an internal, efficient, depth or stencil buffer should be used.\n        ///\n        UniquePtr<RenderTargetGroup> CreateRenderTargetGroup(const RenderTexture* colourTarget, const RenderTexture* depthTarget, RenderTargetGroupType type)\n        {\n            auto renderTargetGroupManager = Application::Get()->GetSystem<RenderTargetGroupManager>();\n            if (colourTarget && depthTarget)\n            {\n                return renderTargetGroupManager->CreateRenderTargetGroup(colourTarget, depthTarget);\n            }\n            else if (colourTarget)\n            {\n                return renderTargetGroupManager->CreateColourRenderTargetGroup(colourTarget, type);\n            }\n            else if (depthTarget)\n            {\n                return renderTargetGroupManager->CreateDepthRenderTargetGroup(depthTarget);\n            }\n            \n            return nullptr;\n        }\n    }\n    \n    //------------------------------------------------------------------------------\n    TargetGroupUPtr TargetGroup::CreateTargetGroup(const TextureCSPtr& colourTarget, const TextureCSPtr& depthTarget) noexcept\n    {\n        return TargetGroupUPtr(new TargetGroup(colourTarget, depthTarget, RenderTargetGroupType::k_colour));\n    }\n    \n    //------------------------------------------------------------------------------\n    TargetGroupUPtr TargetGroup::CreateColourTargetGroup(const TextureCSPtr& colourTarget, RenderTargetGroupType type) noexcept\n    {\n        return TargetGroupUPtr(new TargetGroup(colourTarget, nullptr, type));\n    }\n    \n    //------------------------------------------------------------------------------\n    TargetGroupUPtr TargetGroup::CreateDepthTargetGroup(const TextureCSPtr& depthTarget) noexcept\n    {\n        return TargetGroupUPtr(new TargetGroup(nullptr, depthTarget, RenderTargetGroupType::k_colour));\n    }\n    \n    //------------------------------------------------------------------------------\n    const RenderTargetGroup* TargetGroup::GetRenderTargetGroup() noexcept\n    {\n        //Check if the cached textures are invalid\n        if((m_cachedColourTargetTexture != nullptr && m_cachedColourTargetTexture->GetRenderTexture() != m_cachedColourTargetRenderTexture) ||\n           (m_cachedDepthTargetTexture != nullptr && m_cachedDepthTargetTexture->GetRenderTexture() != m_cachedDepthTargetRenderTexture))\n        {\n            DestroyRenderTargetGroup();\n            \n            m_cachedColourTargetRenderTexture = m_cachedColourTargetTexture == nullptr ? nullptr : m_cachedColourTargetTexture->GetRenderTexture();\n            m_cachedDepthTargetRenderTexture = m_cachedDepthTargetTexture == nullptr ? nullptr : m_cachedDepthTargetTexture->GetRenderTexture();\n            \n            m_renderTargetGroup = CreateRenderTargetGroup(m_cachedColourTargetRenderTexture, m_cachedDepthTargetRenderTexture, m_type);\n        }\n        \n        return m_renderTargetGroup.get();\n    }\n    \n    //------------------------------------------------------------------------------\n    void TargetGroup::DestroyRenderTargetGroup() noexcept\n    {\n        if (m_renderTargetGroup)\n        {\n            auto renderTargetGroupManager = Application::Get()->GetSystem<RenderTargetGroupManager>();\n            CS_ASSERT(renderTargetGroupManager, \"RenderTargetGroupManager is required.\");\n            \n            renderTargetGroupManager->DestroyRenderTargetGroup(std::move(m_renderTargetGroup));\n        }\n        \n        if(m_cachedDepthTargetTexture)\n        {\n            m_cachedDepthTargetTexture.reset();\n        }\n        \n        if(m_cachedColourTargetTexture)\n        {\n            m_cachedColourTargetTexture.reset();\n        }\n    }\n    \n    //------------------------------------------------------------------------------\n    TargetGroup::TargetGroup(const TextureCSPtr& colourTarget, const TextureCSPtr& depthTarget, RenderTargetGroupType type) noexcept\n        : m_cachedColourTargetTexture(colourTarget), m_cachedDepthTargetTexture(depthTarget), m_type(type)\n    {\n        m_cachedColourTargetRenderTexture = colourTarget == nullptr ? nullptr : colourTarget->GetRenderTexture();\n        m_cachedDepthTargetRenderTexture = depthTarget == nullptr ? nullptr : depthTarget->GetRenderTexture();\n        \n        m_renderTargetGroup = CreateRenderTargetGroup(m_cachedColourTargetRenderTexture, m_cachedDepthTargetRenderTexture, type);\n    }\n    \n    //------------------------------------------------------------------------------\n    TargetGroup::~TargetGroup() noexcept\n    {\n        DestroyRenderTargetGroup();\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Target/TargetGroup.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_TARGET_TARGETGROUP_H_\n#define _CHILLISOURCE_RENDERING_TARGET_TARGETGROUP_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Memory/UniquePtr.h>\n\nnamespace ChilliSource\n{\n    /// Represents a group of colour and depth render targets that can be bound for rendering.\n    /// There are two types of render target: colour and depth. Fragment colour data will be\n    /// written to the colour target, while fragment depth data will be written to the depth\n    /// target.\n    ///\n    /// If creating a target group that only contains a colour target then, optionally,\n    /// an efficient depth buffer can be created.\n    ///\n    /// This is mutable and therefore not thread safe\n    ///\n    class TargetGroup final\n    {\n    public:\n        \n        /// Creates a new TargetGroup\n        ///\n        /// @param colourTarget\n        ///     The texture that will be used as the colour target. must not be null.\n        /// @param depthTarget\n        ///     The texture that will be used as the depth target. must not be null.\n        ///\n        /// @return The new render group instance.\n        ///\n        static TargetGroupUPtr CreateTargetGroup(const TextureCSPtr& colourTarget, const TextureCSPtr& depthTarget) noexcept;\n        \n        /// Creates a new colour only TargetGroup.\n        ///\n        /// @param colourTarget\n        ///     The texture that will be used as the colour target. must not be null.\n        /// @param shouldUseDepthBuffer\n        ///     Whether or not an internal, efficient, depth or stencil buffer should be used.\n        ///\n        /// @return The new render group instance.\n        ///\n        static TargetGroupUPtr CreateColourTargetGroup(const TextureCSPtr& colourTarget, RenderTargetGroupType type) noexcept;\n        \n        /// Creates a new depth only TargetGroup\n        ///\n        /// @param depthTarget\n        ///     The texture that will be used as the depth target. must not be null.\n        ///\n        /// @return The new render group instance.\n        ///\n        static TargetGroupUPtr CreateDepthTargetGroup(const TextureCSPtr& depthTarget) noexcept;\n        \n        /// Gets the current RenderTargetGroup. If the colour/depth target has\n        /// changed since the last access, then a new RenderTargetGroup will\n        /// be created.\n        ///\n        /// @return The render target group.\n        ///\n        const RenderTargetGroup* GetRenderTargetGroup() noexcept;\n        \n        ~TargetGroup() noexcept;\n        \n    private:\n        \n        /// @param colourTarget\n        ///     The colour render target. Can be null if no colour target is needed.\n        /// @param depthTarget\n        ///     The depth render target. Can be null if no depth target is needed.\n        /// @param type\n        ///     Whether or not an internal, efficient, depth or stencil buffer should be used.\n        ///\n        TargetGroup(const TextureCSPtr& colourTarget, const TextureCSPtr& depthTarget, RenderTargetGroupType type) noexcept;\n        \n        /// Destroys the render target group if there is one.\n        ///\n        void DestroyRenderTargetGroup() noexcept;\n        \n    private:\n        \n        UniquePtr<RenderTargetGroup> m_renderTargetGroup;\n        \n        TextureCSPtr m_cachedColourTargetTexture = nullptr;\n        TextureCSPtr m_cachedDepthTargetTexture = nullptr;\n        \n        const RenderTexture* m_cachedColourTargetRenderTexture = nullptr;\n        const RenderTexture* m_cachedDepthTargetRenderTexture = nullptr;\n        \n        RenderTargetGroupType m_type;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Target.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n\n#ifndef _CHILLISOURCE_RENDERING_TARGET_H_\n#define _CHILLISOURCE_RENDERING_TARGET_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Rendering/Target/RenderTargetGroup.h>\n#include <ChilliSource/Rendering/Target/RenderTargetGroupManager.h>\n\n#endif"
  },
  {
    "path": "Source/ChilliSource/Rendering/Texture/Cubemap.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2010 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Texture/Cubemap.h>\n\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Rendering/Texture/RenderTexture.h>\n#include <ChilliSource/Rendering/Texture/RenderTextureManager.h>\n#include <ChilliSource/Rendering/Texture/TextureDesc.h>\n\nnamespace ChilliSource\n{\n    CS_DEFINE_NAMEDTYPE(Cubemap);\n\n    //------------------------------------------------------------------------------\n    CubemapUPtr Cubemap::Create() noexcept\n    {\n        return CubemapUPtr(new Cubemap());\n    }\n    \n    //------------------------------------------------------------------------------\n    bool Cubemap::IsA(InterfaceIDType interfaceId) const noexcept\n    {\n        return (Cubemap::InterfaceID == interfaceId);\n    }\n\n    //------------------------------------------------------------------------------\n    void Cubemap::Build(std::array<DataUPtr, 6> textureData, u32 dataSize, const TextureDesc& textureDesc) noexcept\n    {\n        DestroyRenderTexture();\n        \n        auto renderTextureManager = Application::Get()->GetSystem<RenderTextureManager>();\n        CS_ASSERT(renderTextureManager, \"RenderTextureManager must exist.\");\n        \n        m_restoreTextureDataEnabled = textureDesc.IsRestoreTextureDataEnabled();\n        \n        m_renderTexture = renderTextureManager->CreateCubemap(std::move(textureData), dataSize, textureDesc.GetDimensions(), textureDesc.GetImageFormat(), textureDesc.GetImageCompression(),\n                                                              textureDesc.GetFilterMode(), textureDesc.GetWrapModeS(), textureDesc.GetWrapModeT(), textureDesc.IsMipmappingEnabled(), m_restoreTextureDataEnabled);\n    }\n\n    //------------------------------------------------------------------------------\n    const Integer2& Cubemap::GetDimensions() const noexcept\n    {\n        CS_ASSERT(GetLoadState() == LoadState::k_loaded, \"Cannot access texture before it is loaded.\");\n        CS_ASSERT(m_renderTexture, \"Cannot access texture which has not been built.\");\n        \n        return m_renderTexture->GetDimensions();\n    }\n\n    //------------------------------------------------------------------------------\n    ImageFormat Cubemap::GetImageFormat() const noexcept\n    {\n        CS_ASSERT(GetLoadState() == LoadState::k_loaded, \"Cannot access texture before it is loaded.\");\n        CS_ASSERT(m_renderTexture, \"Cannot access texture which has not been built.\");\n        \n        return m_renderTexture->GetImageFormat();\n    }\n\n    //------------------------------------------------------------------------------\n    ImageCompression Cubemap::GetImageCompression() const noexcept\n    {\n        CS_ASSERT(GetLoadState() == LoadState::k_loaded, \"Cannot access texture before it is loaded.\");\n        CS_ASSERT(m_renderTexture, \"Cannot access texture which has not been built.\");\n        \n        return m_renderTexture->GetImageCompression();\n    }\n    \n    //------------------------------------------------------------------------------\n    TextureFilterMode Cubemap::GetFilterMode() const noexcept\n    {\n        CS_ASSERT(GetLoadState() == LoadState::k_loaded, \"Cannot access texture before it is loaded.\");\n        CS_ASSERT(m_renderTexture, \"Cannot access texture which has not been built.\");\n        \n        return m_renderTexture->GetFilterMode();\n    }\n\n    //------------------------------------------------------------------------------\n    TextureWrapMode Cubemap::GetWrapModeS() const noexcept\n    {\n        CS_ASSERT(GetLoadState() == LoadState::k_loaded, \"Cannot access texture before it is loaded.\");\n        CS_ASSERT(m_renderTexture, \"Cannot access texture which has not been built.\");\n        \n        return m_renderTexture->GetWrapModeS();\n    }\n\n    //------------------------------------------------------------------------------\n    TextureWrapMode Cubemap::GetWrapModeT() const noexcept\n    {\n        CS_ASSERT(GetLoadState() == LoadState::k_loaded, \"Cannot access texture before it is loaded.\");\n        CS_ASSERT(m_renderTexture, \"Cannot access texture which has not been built.\");\n        \n        return m_renderTexture->GetWrapModeT();\n    }\n\n    //------------------------------------------------------------------------------\n    bool Cubemap::IsMipmappingEnabled() const noexcept\n    {\n        CS_ASSERT(GetLoadState() == LoadState::k_loaded, \"Cannot access texture before it is loaded.\");\n        CS_ASSERT(m_renderTexture, \"Cannot access texture which has not been built.\");\n        \n        return m_renderTexture->IsMipmapped();\n    }\n\n    //------------------------------------------------------------------------------\n    bool Cubemap::IsRestoreTextureDataEnabled() const noexcept\n    {\n        CS_ASSERT(GetLoadState() == LoadState::k_loaded, \"Cannot access texture before it is loaded.\");\n        CS_ASSERT(m_renderTexture, \"Cannot access texture which has not been built.\");\n        \n        return m_restoreTextureDataEnabled;\n    }\n\n    //------------------------------------------------------------------------------\n    const RenderTexture* Cubemap::GetRenderTexture() const noexcept\n    {\n        CS_ASSERT(GetLoadState() == LoadState::k_loaded, \"Cannot access texture before it is loaded.\");\n        CS_ASSERT(m_renderTexture, \"Cannot access texture which has not been built.\");\n        \n        return m_renderTexture.get();\n    }\n    \n    //------------------------------------------------------------------------------\n    void Cubemap::DestroyRenderTexture() noexcept\n    {\n        if (m_renderTexture)\n        {\n            auto renderTextureManager = Application::Get()->GetSystem<RenderTextureManager>();\n            CS_ASSERT(renderTextureManager, \"RenderTextureManager must exist.\");\n            \n            renderTextureManager->DestroyRenderTextureCubemap(std::move(m_renderTexture));\n        }\n    }\n    \n    //------------------------------------------------------------------------------\n    Cubemap::~Cubemap() noexcept\n    {\n        DestroyRenderTexture();\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Texture/Cubemap.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2010 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_TEXTURE_CUBEMAP_H_\n#define _CHILLISOURCE_RENDERING_TEXTURE_CUBEMAP_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Memory/UniquePtr.h>\n#include <ChilliSource/Core/Image/ImageFormat.h>\n#include <ChilliSource/Core/Image/ImageCompression.h>\n#include <ChilliSource/Core/Resource/Resource.h>\n\n#include <array>\n\nnamespace ChilliSource\n{\n    /// A cubemap texture resource consisting of 6 textures. All 6 textures must share\n    /// the same dimensions, filter mode, etc.\n    ///\n    /// This is not thread safe and should only be accessed from one thread at a time.\n    ///\n    /// NOTE: Texture data is specified in the following order:\n    ///     * PosX, NegX, PosY, NegY, PosZ, NegZ\n    ///\n    class Cubemap final : public Resource\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(Cubemap);\n        \n        /// The buffer used to hold texture data.\n        ///\n        using DataUPtr = std::unique_ptr<const u8[]>;\n        \n        /// Allows querying of whether or not this system implements the interface described by the\n        /// given interface Id. Typically this is not called directly as the templated equivalent\n        /// IsA<Interface>() is preferred.\n        ///\n        /// @param interfaceId\n        ///     The Id of the interface.\n        ///\n        /// @return Whether or not the interface is implemented.\n        ///\n        bool IsA(InterfaceIDType interfaceId) const noexcept override;\n        \n        /// Construct the texture from the given image data. The texture will take ownership of\n        /// the image data. The texture must not already be in the loaded state.\n        ///\n        /// @param textureData\n        ///     The texture data buffer and size for each face.\n        /// @param dataSize\n        ///     Size of each face texture data. Only 1 value as all faces must be the same format and dimensions\n        /// @param textureDesc\n        ///     The texture description.\n        ///\n        void Build(std::array<DataUPtr, 6> textureData, u32 dataSize, const TextureDesc& textureDesc) noexcept;\n\n        /// @return The texture dimensions.\n        ///\n        const Integer2& GetDimensions() const noexcept;\n        \n        /// @return The format of the image.\n        ///\n        ImageFormat GetImageFormat() const noexcept;\n        \n        /// @return The compression type of the image.\n        ///\n        ImageCompression GetImageCompression() const noexcept;\n        \n        /// @return The texture filter mode used when rendering the texture.\n        ///\n        TextureFilterMode GetFilterMode() const noexcept;\n        \n        /// @return The s-coordinate texture wrap mode used when rendering the texture.\n        ///\n        TextureWrapMode GetWrapModeS() const noexcept;\n        \n        /// @return The t-coordinate texture wrap mode used when rendering the texture.\n        ///\n        TextureWrapMode GetWrapModeT() const noexcept;\n        \n        /// @return Whether or not the texture should be mipmapped.\n        ///\n        bool IsMipmappingEnabled() const noexcept;\n        \n        /// @return Whether or not texture data should be restored on context loss.\n        ///\n        bool IsRestoreTextureDataEnabled() const noexcept;\n        \n        /// @return The underlying RenderTexture used by the render system.\n        ///\n        const RenderTexture* GetRenderTexture() const noexcept;\n        \n        ~Cubemap() noexcept;\n        \n    private:\n        friend class ResourcePool;\n        \n        /// A factory method for creating new, empty instances of the resource. This must only be\n        /// called by ResourcePool.\n        ///\n        /// @return The new instance of the resource.\n        ///\n        static CubemapUPtr Create() noexcept;\n        \n        /// Destroys the render texture if one currently exists.\n        ///\n        void DestroyRenderTexture() noexcept;\n        \n        Cubemap() = default;\n        \n        UniquePtr<RenderTexture> m_renderTexture;\n        bool m_restoreTextureDataEnabled = false;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Texture/CubemapProvider.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Texture/CubemapProvider.h>\n\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/String/StringParser.h>\n#include <ChilliSource/Core/Image/Image.h>\n#include <ChilliSource/Core/Json/JsonUtils.h>\n#include <ChilliSource/Core/Threading/TaskScheduler.h>\n#include <ChilliSource/Rendering/Texture/Cubemap.h>\n#include <ChilliSource/Rendering/Texture/TextureDesc.h>\n#include <ChilliSource/Rendering/Texture/CubemapResourceOptions.h>\n\n#include <json/json.h>\n\nnamespace ChilliSource\n{\n    CS_DEFINE_NAMEDTYPE(CubemapProvider);\n    \n    const IResourceOptionsBaseCSPtr CubemapProvider::s_defaultOptions(std::make_shared<CubemapResourceOptions>());\n    \n    namespace\n    {\n        const std::string k_cubemapExtension(\"cscubemap\");\n    }\n    \n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    CubemapProviderUPtr CubemapProvider::Create()\n    {\n        return CubemapProviderUPtr(new CubemapProvider());\n    }\n    //-------------------------------------------------------------------------\n    //-------------------------------------------------------------------------\n    bool CubemapProvider::IsA(InterfaceIDType in_interfaceId) const\n    {\n        return in_interfaceId == ResourceProvider::InterfaceID || in_interfaceId == CubemapProvider::InterfaceID;\n    }\n    //----------------------------------------------------------------------------\n    //----------------------------------------------------------------------------\n    void CubemapProvider::PostCreate()\n    {\n        auto resourceProviders = Application::Get()->GetSystems<ResourceProvider>();\n        \n        for(u32 i=0; i<resourceProviders.size(); ++i)\n        {\n            if(resourceProviders[i]->GetResourceType() == Image::InterfaceID)\n            {\n                m_imageProviders.push_back(resourceProviders[i]);\n            }\n        }\n    }\n    //----------------------------------------------------------------------------\n    //----------------------------------------------------------------------------\n    InterfaceIDType CubemapProvider::GetResourceType() const\n    {\n        return Cubemap::InterfaceID;\n    }\n    //----------------------------------------------------------------------------\n    //----------------------------------------------------------------------------\n    bool CubemapProvider::CanCreateResourceWithFileExtension(const std::string& in_extension) const\n    {\n        return in_extension == k_cubemapExtension;\n    }\n    //----------------------------------------------------\n    //----------------------------------------------------\n    IResourceOptionsBaseCSPtr CubemapProvider::GetDefaultOptions() const\n    {\n        return s_defaultOptions;\n    }\n    //----------------------------------------------------------------------------\n    //----------------------------------------------------------------------------\n    void CubemapProvider::CreateResourceFromFile(StorageLocation in_location, const std::string& in_filePath, const IResourceOptionsBaseCSPtr& in_options, const ResourceSPtr& out_resource)\n    {\n        LoadCubemap(in_location, in_filePath, in_options, nullptr, out_resource);\n    }\n    //----------------------------------------------------------------------------\n    //----------------------------------------------------------------------------\n    void CubemapProvider::CreateResourceFromFileAsync(StorageLocation in_location, const std::string& in_filePath, const IResourceOptionsBaseCSPtr& in_options, const ResourceProvider::AsyncLoadDelegate& in_delegate, const ResourceSPtr& out_resource)\n    {\n        Application::Get()->GetTaskScheduler()->ScheduleTask(TaskType::k_file, [=](const TaskContext&) noexcept\n        {\n            LoadCubemap(in_location, in_filePath, in_options, in_delegate, out_resource);\n        });\n    }\n    //----------------------------------------------------------------------------\n    //----------------------------------------------------------------------------\n    void CubemapProvider::LoadCubemap(StorageLocation in_location, const std::string& in_filePath, const IResourceOptionsBaseCSPtr& in_options, const ResourceProvider::AsyncLoadDelegate& in_delegate, const ResourceSPtr& out_resource)\n    {\n        CS_ASSERT(in_options != nullptr, \"Options for cubemap load cannot be null\");\n        \n        //Load the JSON description file that holds the names of the 6 textures\n        StorageLocation imageLocation = StorageLocation::k_package;\n        std::array<std::string, 6> imagePaths;\n        Json::Value root;\n        if(JsonUtils::ReadJson(in_location, in_filePath, root) == true)\n        {\n            imageLocation = ParseStorageLocation(root.get(\"StorageLocation\", \"Package\").asString());\n            \n            const auto& faces = root[\"Faces\"];\n            CS_ASSERT(faces.size() == 6, \"Cubemap must have 6 images specified\");\n            for(auto i=0u; i<faces.size(); ++i)\n            {\n                imagePaths[i] = faces[i].asString();\n            }\n        }\n        else\n        {\n            CS_LOG_ERROR(\"Cannot find cubemap \" + in_filePath);\n            out_resource->SetLoadState(Resource::LoadState::k_failed);\n            if(in_delegate != nullptr)\n            {\n                Application::Get()->GetTaskScheduler()->ScheduleTask(TaskType::k_mainThread, [=](const TaskContext&) noexcept{ in_delegate(out_resource); });\n            }\n            return;\n        }\n        \n        //Load the actual images\n        std::array<ImageSPtr, 6> images;\n        \n        for(auto i=0; i<imagePaths.size(); ++i)\n        {\n            std::string fileName;\n            std::string fileExtension;\n            StringUtils::SplitBaseFilename(imagePaths[i], fileName, fileExtension);\n            \n            ResourceProvider* imageProvider = nullptr;\n            for(u32 i=0; i<m_imageProviders.size(); ++i)\n            {\n                if(m_imageProviders[i]->CanCreateResourceWithFileExtension(fileExtension))\n                {\n                    imageProvider = m_imageProviders[i];\n                    break;\n                }\n            }\n            \n            if(imageProvider == nullptr)\n            {\n                CS_LOG_ERROR(\"Cannot find provider for \" + imagePaths[i]);\n                out_resource->SetLoadState(Resource::LoadState::k_failed);\n                if(in_delegate != nullptr)\n                {\n                    Application::Get()->GetTaskScheduler()->ScheduleTask(TaskType::k_mainThread, [=](const TaskContext&) noexcept{ in_delegate(out_resource); });\n                }\n                return;\n            }\n            \n            ResourceSPtr imageResource(Image::Create());\n            imageProvider->CreateResourceFromFile(imageLocation, imagePaths[i], nullptr, imageResource);\n            ImageSPtr image(std::static_pointer_cast<Image>(imageResource));\n            \n            if(image->GetLoadState() == Resource::LoadState::k_failed)\n            {\n                CS_LOG_ERROR(\"Failed to load image \" + in_filePath);\n                out_resource->SetLoadState(Resource::LoadState::k_failed);\n                if(in_delegate != nullptr)\n                {\n                    Application::Get()->GetTaskScheduler()->ScheduleTask(TaskType::k_mainThread, [=](const TaskContext&) noexcept { in_delegate(out_resource); });\n                }\n                return;\n            }\n            \n            images[i] = image;\n        }\n        \n        if(in_delegate == nullptr)\n        {\n            auto cubemap = static_cast<Cubemap*>(out_resource.get());\n            auto options = static_cast<const CubemapResourceOptions*>(in_options.get());\n            \n            std::array<std::unique_ptr<const u8[]>, 6> textureData;\n            for(auto i=0; i<images.size(); ++i)\n            {\n                textureData[i] = std::move(images[i]->MoveData());\n            }\n            \n            TextureDesc desc(Integer2(images[0]->GetWidth(), images[0]->GetHeight()), images[0]->GetFormat(), images[0]->GetCompression(), false);\n            desc.SetFilterMode(options->GetFilterMode());\n            desc.SetWrapModeS(options->GetWrapModeS());\n            desc.SetWrapModeT(options->GetWrapModeT());\n            desc.SetMipmappingEnabled(options->IsMipMapsEnabled());\n            \n            cubemap->Build(std::move(textureData), images[0]->GetDataSize(), desc);\n            cubemap->SetLoadState(Resource::LoadState::k_loaded);\n        }\n        else\n        {\n            Application::Get()->GetTaskScheduler()->ScheduleTask(TaskType::k_mainThread, [=](const TaskContext&) noexcept\n             {\n                 auto cubemap = static_cast<Cubemap*>(out_resource.get());\n                 auto options = static_cast<const CubemapResourceOptions*>(in_options.get());\n                 \n                 std::array<std::unique_ptr<const u8[]>, 6> textureData;\n                 for(auto i=0; i<images.size(); ++i)\n                 {\n                     textureData[i] = std::move(images[i]->MoveData());\n                 }\n                 \n                 TextureDesc desc(Integer2(images[0]->GetWidth(), images[0]->GetHeight()), images[0]->GetFormat(), images[0]->GetCompression(), false);\n                 desc.SetFilterMode(options->GetFilterMode());\n                 desc.SetWrapModeS(options->GetWrapModeS());\n                 desc.SetWrapModeT(options->GetWrapModeT());\n                 desc.SetMipmappingEnabled(options->IsMipMapsEnabled());\n                 \n                 cubemap->Build(std::move(textureData), images[0]->GetDataSize(), desc);\n                 cubemap->SetLoadState(Resource::LoadState::k_loaded);\n                 in_delegate(out_resource);\n             });\n        }\n    }\n}\n\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Texture/CubemapProvider.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_TEXTURE_CUBEMAPPROVIDER_H_\n#define _CHILLISOURCE_RENDERING_TEXTURE_CUBEMAPPROVIDER_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Resource/ResourceProvider.h>\n\nnamespace ChilliSource\n{\n    ///\n    /// Loads the cubemap description file and then the 6 textures that constitute a\n    /// cubemap.\n    ///\n    class CubemapProvider final : public ResourceProvider\n    {\n    public:\n        \n        CS_DECLARE_NAMEDTYPE(CubemapProvider);\n        \n        //----------------------------------------------------------------------------\n        /// Called when the system is initialised. Retrieves the image providers\n        /// to delegate image loading to\n        ///\n        /// @author S Downie\n        //----------------------------------------------------------------------------\n        void PostCreate();\n        //-------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Interface to compare\n        ///\n        /// @return Whether the object implements the given interface\n        //-------------------------------------------------------------------------\n        bool IsA(InterfaceIDType in_interfaceId) const override;\n        //----------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return The resource type this provider loads\n        //----------------------------------------------------------------------------\n        InterfaceIDType GetResourceType() const override;\n        //----------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Extension to compare\n        ///\n        /// @return Whether the object can create a resource with the given extension\n        //----------------------------------------------------------------------------\n        bool CanCreateResourceWithFileExtension(const std::string& in_extension) const override;\n        //----------------------------------------------------------------------------\n        /// Loads the image and generate the texture via the output resource.\n        /// Check the resource load state for success or failure.\n        ///\n        /// @author S Downie\n        ///\n        /// @param Location to load from\n        /// @param File path\n        /// @param Options to customise the creation\n        /// @param [Out] Resource object\n        //----------------------------------------------------------------------------\n        void CreateResourceFromFile(StorageLocation in_location, const std::string& in_filePath, const IResourceOptionsBaseCSPtr& in_options, const ResourceSPtr& out_resource) override;\n        //----------------------------------------------------------------------------\n        /// Loads the image on a background thread and generate the texture via the output resource.\n        /// Delegate is called on completion. Check the resource load state for success or failure\n        ///\n        /// @author S Downie\n        ///\n        /// @param Location to load from\n        /// @param File path\n        /// @param Options to customise the creation\n        /// @param Completion delegate\n        /// @param [Out] Resource object\n        //----------------------------------------------------------------------------\n        void CreateResourceFromFileAsync(StorageLocation in_location, const std::string& in_filePath, const IResourceOptionsBaseCSPtr& in_options, const ResourceProvider::AsyncLoadDelegate& in_delegate, const ResourceSPtr& out_resource) override;\n        //----------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @retrun Default options for texture loading\n        //----------------------------------------------------\n        IResourceOptionsBaseCSPtr GetDefaultOptions() const override;\n        \n    private:\n        friend class Application;\n        //-------------------------------------------------------\n        /// Factory method\n        ///\n        /// @author S Downie\n        ///\n        /// @return New provider with ownership transferred\n        //-------------------------------------------------------\n        static CubemapProviderUPtr Create();\n        //----------------------------------------------------------------------------\n        /// Private constructor to force use of factory method\n        ///\n        /// @author S Downie\n        //----------------------------------------------------------------------------\n        CubemapProvider() = default;\n        //----------------------------------------------------------------------------\n        /// Does the heavy lifting for the 2 create methods. The building of the cubemap\n        /// is always done on the renderer thread\n        ///\n        /// @author S Downie\n        ///\n        /// @param Location to load from\n        /// @param File path\n        /// @param Options to customise the creation\n        /// @param Completion delegate\n        /// @param [Out] Resource object\n        //----------------------------------------------------------------------------\n        void LoadCubemap(StorageLocation in_location, const std::string& in_filePath, const IResourceOptionsBaseCSPtr& in_options, const ResourceProvider::AsyncLoadDelegate& in_delegate, const ResourceSPtr& out_resource);\n        \n    private:\n        \n        std::vector<ResourceProvider*> m_imageProviders;\n        static const IResourceOptionsBaseCSPtr s_defaultOptions;\n    };\n}\n\n#endif\n\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Texture/CubemapResourceOptions.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Texture/CubemapResourceOptions.h>\n\n#include <ChilliSource/Core/Cryptographic/HashCRC32.h>\n\nnamespace ChilliSource\n{\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    CubemapResourceOptions::CubemapResourceOptions(bool in_mipmaps, TextureFilterMode in_filter, TextureWrapMode in_wrapS, TextureWrapMode in_wrapT)\n    {\n        m_options.m_hasMipMaps = in_mipmaps;\n        m_options.m_filterMode = in_filter;\n        m_options.m_wrapModeS = in_wrapS;\n        m_options.m_wrapModeT = in_wrapT;\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    u32 CubemapResourceOptions::GenerateHash() const\n    {\n        return HashCRC32::GenerateHashCode((const s8*)&m_options, sizeof(Options));\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    bool CubemapResourceOptions::IsMipMapsEnabled() const\n    {\n        return m_options.m_hasMipMaps;\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    TextureWrapMode CubemapResourceOptions::GetWrapModeS() const\n    {\n        return m_options.m_wrapModeS;\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    TextureWrapMode CubemapResourceOptions::GetWrapModeT() const\n    {\n        return m_options.m_wrapModeT;\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    TextureFilterMode CubemapResourceOptions::GetFilterMode() const\n    {\n        return m_options.m_filterMode;\n    }\n}\n\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Texture/CubemapResourceOptions.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n\n#ifndef _CHILLISOURCE_RENDERING_TEXTURE_CUBEMAPRESOURCEOPTIONS_H_\n#define _CHILLISOURCE_RENDERING_TEXTURE_CUBEMAPRESOURCEOPTIONS_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Resource/IResourceOptions.h>\n#include <ChilliSource/Rendering/Texture/Texture.h>\n#include <ChilliSource/Rendering/Texture/TextureFilterMode.h>\n#include <ChilliSource/Rendering/Texture/TextureWrapMode.h>\n\nnamespace ChilliSource\n{\n    //-------------------------------------------------------\n    /// Custom options for loading a cubempap\n    ///\n    /// @author S Downie\n    //-------------------------------------------------------\n    class CubemapResourceOptions final : public IResourceOptions<Cubemap>\n    {\n    public:\n        //-------------------------------------------------------\n        /// Constructor\n        ///\n        /// @author S Downie\n        //-------------------------------------------------------\n        CubemapResourceOptions() = default;\n        //-------------------------------------------------------\n        /// Constructor\n        ///\n        /// @author S Downie\n        ///\n        /// @param MipMaps enabled\n        /// @param Filter mode\n        /// @param Wrap mode S\n        /// @param Wrap mode T\n        /// @param Whether or not the texture data should be\n        /// restored after a context loss. This involves maintaining\n        /// a copy of the texture data in memory which is costly\n        /// so this should be disabled for any textures that can\n        /// easily be recreated, i.e any texture that is rendered\n        /// into every frame. This has no effect on textures that\n        /// are loaded from file as they are always restored from\n        /// disk. This will only work for RGBA8888, RGB888, RGBA4444\n        /// and RGB565 textures.\n        //-------------------------------------------------------\n        CubemapResourceOptions(bool in_mipmaps, TextureFilterMode in_filter, TextureWrapMode in_wrapS, TextureWrapMode in_wrapT);\n        //-------------------------------------------------------\n        /// Generate a unique hash based on the\n        /// currently set options\n        ///\n        /// @author S Downie\n        ///\n        /// @return Hash of the options contents\n        //-------------------------------------------------------\n        u32 GenerateHash() const override;\n        //-------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Whether the texture should be created with\n        /// mip-maps\n        //-------------------------------------------------------\n        bool IsMipMapsEnabled() const;\n        //-------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Wrap S direction mode to create texture with\n        //-------------------------------------------------------\n        TextureWrapMode GetWrapModeS() const;\n        //-------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Wrap T direction mode to create texture with\n        //-------------------------------------------------------\n        TextureWrapMode GetWrapModeT() const;\n        //-------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Filter mode to create texture with\n        //-------------------------------------------------------\n        TextureFilterMode GetFilterMode() const;\n        \n    private:\n        \n        //-------------------------------------------------------\n        /// The options for loading textures. These are held\n        /// in a struct to more easily allow hashing of the data\n        ///\n        /// @author S Downie\n        //-------------------------------------------------------\n        struct Options\n        {\n            TextureWrapMode m_wrapModeS = TextureWrapMode::k_clamp;\n            TextureWrapMode m_wrapModeT = TextureWrapMode::k_clamp;\n            TextureFilterMode m_filterMode = TextureFilterMode::k_bilinear;\n            bool m_hasMipMaps = false;\n        };\n        \n        Options m_options;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Texture/RenderTexture.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Texture/RenderTexture.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    RenderTexture::RenderTexture(const Integer2& dimensions, ImageFormat imageFormat, ImageCompression imageCompression, TextureFilterMode filterMode, TextureWrapMode wrapModeS,  TextureWrapMode wrapModeT,\n                                 bool isMipmapped, bool shouldBackupData) noexcept\n        : m_dimensions(dimensions), m_imageFormat(imageFormat), m_imageCompression(imageCompression), m_filterMode(filterMode), m_wrapModeS(wrapModeS), m_wrapModeT(wrapModeT), m_isMipmapped(isMipmapped), m_shouldBackupData(shouldBackupData)\n    {\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Texture/RenderTexture.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_TEXTURE_RENDERTEXTURE_H_\n#define _CHILLISOURCE_RENDERING_TEXTURE_RENDERTEXTURE_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Image/ImageFormat.h>\n#include <ChilliSource/Core/Image/ImageCompression.h>\n#include <ChilliSource/Core/Math/Vector2.h>\n#include <ChilliSource/Rendering/Texture/TextureFilterMode.h>\n#include <ChilliSource/Rendering/Texture/TextureWrapMode.h>\n\nnamespace ChilliSource\n{\n    /// A standard-layout container for all information needed by the renderer pertaining\n    /// to a single texture. This includes things like dimensions, imagine format and\n    /// filtering. The render texture does not directly contain texture data, but acts\n    /// as a handle which the underlying render system (i.e OpenGL) can use to access the\n    /// data.\n    ///\n    /// This is immutable and therefore thread-safe, aside from the extra data pointer\n    /// which should only be accessed on the render thread.\n    ///\n    class RenderTexture final\n    {\n    public:\n        CS_DECLARE_NOCOPY(RenderTexture);\n        \n        /// Creates a new instance with the given texture information.\n        ///\n        /// SHOULD ONLY BE CREATED VIA RenderTextureManager\n        ///\n        /// @param dimensions\n        ///     The texture dimensions.\n        /// @param imageFormat\n        ///     The image format.\n        /// @param imageCompression\n        ///     The image compression type.\n        /// @param filterMode\n        ///     The texture filter mode.\n        /// @param wrapModeS\n        ///     The s-coordinate wrap mode.\n        /// @param wrapModeT\n        ///     The t-coordinate wrap mode.\n        /// @param isMipmapped\n        ///     Whether or not mipmaps are generated for the texture.\n        /// @param shouldBackupData\n        ///     If the mesh data should be backed up in main memory for restoring it later.\n        ///\n        RenderTexture(const Integer2& dimensions, ImageFormat imageFormat, ImageCompression imageCompression, TextureFilterMode filterMode, TextureWrapMode wrapModeS, TextureWrapMode wrapModeT, bool isMipmapped, bool shouldBackupData) noexcept;\n        \n        \n        /// @return The texture dimensions.\n        ///\n        const Integer2& GetDimensions() const noexcept { return m_dimensions; }\n        \n        /// @return The image format.\n        ///\n        ImageFormat GetImageFormat() const noexcept { return m_imageFormat; }\n        \n        /// @return The image compression type.\n        ///\n        ImageCompression GetImageCompression() const noexcept { return m_imageCompression; }\n        \n        /// @return The texture filter mode.\n        ///\n        TextureFilterMode GetFilterMode() const noexcept { return m_filterMode; }\n        \n        /// @return The s-coordinate wrap mode.\n        ///\n        TextureWrapMode GetWrapModeS() const noexcept { return m_wrapModeS; }\n        \n        /// @return The t-coordinate wrap mode.\n        ///\n        TextureWrapMode GetWrapModeT() const noexcept { return m_wrapModeT; }\n        \n        /// @return Whether or not mipmaps are generated for the texture.\n        ///\n        bool IsMipmapped() const noexcept { return m_isMipmapped; }\n        \n        /// @return If the mesh should backup its data.\n        ///\n        bool ShouldBackupData() const noexcept { return m_shouldBackupData; }\n        \n        /// This is not thread safe and should only be called from the render thread.\n        ///\n        /// @return A pointer to render system specific additional information.\n        ///\n        void* GetExtraData() const noexcept { return m_extraData; }\n        \n        /// This is not thread safe and should only be called from the render thread.\n        ///\n        /// @param extraData\n        ///     A pointer to render system specific additional information.\n        ///\n        void SetExtraData(void* extraData) noexcept { m_extraData = extraData; }\n        \n    private:\n\n        Integer2 m_dimensions;\n        ImageFormat m_imageFormat;\n        ImageCompression m_imageCompression;\n        TextureFilterMode m_filterMode;\n        TextureWrapMode m_wrapModeS;\n        TextureWrapMode m_wrapModeT;\n        bool m_isMipmapped;\n        bool m_shouldBackupData = true;\n        void* m_extraData = nullptr;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Texture/RenderTextureManager.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Texture/RenderTextureManager.h>\n\n#include <ChilliSource/Rendering/Base/RenderSnapshot.h>\n#include <ChilliSource/Rendering/Base/TargetType.h>\n\nnamespace ChilliSource\n{\n    namespace\n    {\n        constexpr u32 k_texturePoolSize = 100;\n    }\n    \n    CS_DEFINE_NAMEDTYPE(RenderTextureManager);\n\n    //------------------------------------------------------------------------------\n    RenderTextureManagerUPtr RenderTextureManager::Create() noexcept\n    {\n        return RenderTextureManagerUPtr(new RenderTextureManager());\n    }\n    \n    //------------------------------------------------------------------------------\n    RenderTextureManager::RenderTextureManager()\n    : m_renderTexturePool(k_texturePoolSize, ObjectPoolAllocatorLimitPolicy::k_expand)\n    {\n        \n    }\n    \n    //------------------------------------------------------------------------------\n    bool RenderTextureManager::IsA(InterfaceIDType interfaceId) const noexcept\n    {\n        return (RenderTextureManager::InterfaceID == interfaceId);\n    }\n        \n    //------------------------------------------------------------------------------\n    UniquePtr<RenderTexture> RenderTextureManager::CreateTexture2D(std::unique_ptr<const u8[]> textureData, u32 textureDataSize, const Integer2& dimensions, ImageFormat imageFormat, ImageCompression imageCompression,\n                                                               TextureFilterMode filterMode, TextureWrapMode wrapModeS, TextureWrapMode wrapModeT, bool isMipmapped, bool shouldBackupData) noexcept\n    {\n        UniquePtr<RenderTexture> renderTexture(MakeUnique<RenderTexture>(m_renderTexturePool, dimensions, imageFormat, imageCompression, filterMode, wrapModeS, wrapModeT, isMipmapped, shouldBackupData));\n        auto rawRenderTexture = renderTexture.get();\n        \n        PendingLoadCommand2D loadCommand;\n        loadCommand.m_textureData = std::move(textureData);\n        loadCommand.m_textureDataSize = textureDataSize;\n        loadCommand.m_renderTexture = rawRenderTexture;\n        \n        std::unique_lock<std::mutex> lock(m_mutex);\n        m_pendingLoadCommands2D.push_back(std::move(loadCommand));\n        \n        return renderTexture;\n    }\n    \n    //------------------------------------------------------------------------------\n    UniquePtr<RenderTexture> RenderTextureManager::CreateCubemap(std::array<std::unique_ptr<const u8[]>, 6> textureData, u32 textureDataSize, const Integer2& dimensions, ImageFormat imageFormat, ImageCompression imageCompression,\n                                                             TextureFilterMode filterMode, TextureWrapMode wrapModeS, TextureWrapMode wrapModeT, bool isMipmapped, bool shouldBackupData) noexcept\n    {\n        UniquePtr<RenderTexture> renderTexture(MakeUnique<RenderTexture>(m_renderTexturePool, dimensions, imageFormat, imageCompression, filterMode, wrapModeS, wrapModeT, isMipmapped, shouldBackupData));\n        auto rawRenderTexture = renderTexture.get();\n        \n        PendingLoadCommandCubemap loadCommand;\n        loadCommand.m_textureData = std::move(textureData);\n        loadCommand.m_textureDataSize = textureDataSize;\n        loadCommand.m_renderTexture = rawRenderTexture;\n        \n        std::unique_lock<std::mutex> lock(m_mutex);\n        m_pendingLoadCommandsCubemap.push_back(std::move(loadCommand));\n        \n        return renderTexture;\n    }\n    \n    //------------------------------------------------------------------------------\n    void RenderTextureManager::DestroyRenderTexture2D(UniquePtr<RenderTexture> renderTexture) noexcept\n    {\n        std::unique_lock<std::mutex> lock(m_mutex);\n        m_pendingUnloadCommands2D.push_back(std::move(renderTexture));\n    }\n    \n    //------------------------------------------------------------------------------\n    void RenderTextureManager::DestroyRenderTextureCubemap(UniquePtr<RenderTexture> renderTexture) noexcept\n    {\n        std::unique_lock<std::mutex> lock(m_mutex);\n        m_pendingUnloadCommandsCubemap.push_back(std::move(renderTexture));\n    }\n    \n    //------------------------------------------------------------------------------\n    void RenderTextureManager::OnRenderSnapshot(TargetType targetType, RenderSnapshot& renderSnapshot, IAllocator* frameAllocator) noexcept\n    {\n        if(targetType == TargetType::k_main)\n        {\n            auto preRenderCommandList = renderSnapshot.GetPreRenderCommandList();\n            auto postRenderCommandList = renderSnapshot.GetPostRenderCommandList();\n            \n            std::unique_lock<std::mutex> lock(m_mutex);\n            \n            for (auto& loadCommand : m_pendingLoadCommands2D)\n            {\n                preRenderCommandList->AddLoadTextureCommand(loadCommand.m_renderTexture, std::move(loadCommand.m_textureData), loadCommand.m_textureDataSize);\n            }\n            m_pendingLoadCommands2D.clear();\n            \n            for (auto& loadCommand : m_pendingLoadCommandsCubemap)\n            {\n                preRenderCommandList->AddLoadCubemapCommand(loadCommand.m_renderTexture, std::move(loadCommand.m_textureData), loadCommand.m_textureDataSize);\n            }\n            m_pendingLoadCommandsCubemap.clear();\n            \n            for (auto& unloadCommand : m_pendingUnloadCommands2D)\n            {\n                postRenderCommandList->AddUnloadTextureCommand(std::move(unloadCommand));\n            }\n            m_pendingUnloadCommands2D.clear();\n            \n            for (auto& unloadCommand : m_pendingUnloadCommandsCubemap)\n            {\n                postRenderCommandList->AddUnloadCubemapCommand(std::move(unloadCommand));\n            }\n            m_pendingUnloadCommandsCubemap.clear();\n        }\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Texture/RenderTextureManager.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_TEXTURE_RENDERTEXTUREMANAGER_H_\n#define _CHILLISOURCE_RENDERING_TEXTURE_RENDERTEXTUREMANAGER_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Memory/ObjectPoolAllocator.h>\n#include <ChilliSource/Core/Memory/UniquePtr.h>\n#include <ChilliSource/Core/System/AppSystem.h>\n#include <ChilliSource/Rendering/Texture/RenderTexture.h>\n\n#include <mutex>\n#include <array>\n\nnamespace ChilliSource\n{\n    /// Manages the lifecycle of all RenderTexture instances.\n    ///\n    /// On creation of a RenderTexture a LoadTextureRenderCommand is queued for the next render\n    /// snapshot phase, ensuring that related textured data is processed before the RenderTexture\n    /// is used.\n    ///\n    /// On deletion an UnloadTextureRenderCommand is queued and given ownership of the\n    /// RenderTexture. The render texture is then deleted once the command has been processed.\n    ///\n    /// This is thread-safe and can be called from any thread. If it is called on a background\n    /// thread, care needs to be taken to ensure any created RenderTextures are not used prior\n    /// to being loaded.\n    ///\n    class RenderTextureManager final : public AppSystem\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(RenderTextureManager);\n        \n        /// Allows querying of whether or not this system implements the interface described by the\n        /// given interface Id. Typically this is not called directly as the templated equivalent\n        /// IsA<Interface>() is preferred.\n        ///\n        /// @param interfaceId\n        ///     The Id of the interface.\n        ///\n        /// @return Whether or not the interface is implemented.\n        ///\n        bool IsA(InterfaceIDType interfaceId) const noexcept override;\n        \n        /// Creates a new render texture and queues a LoadTextureRenderCommand for the next\n        /// Render Snapshot stage in the render pipeline.\n        ///\n        /// @param textureData\n        ///     The texture data buffer.\n        /// @param textureDataSize\n        ///     The size of the texture data buffer.\n        /// @param dimensions\n        ///     The texture dimensions.\n        /// @param imageFormat\n        ///     The image format.\n        /// @param imageCompression\n        ///     The image compression type.\n        /// @param filterMode\n        ///     The texture filter mode.\n        /// @param wrapModeS\n        ///     The s-coordinate wrap mode.\n        /// @param wrapModeT\n        ///     The t-coordinate wrap mode.\n        /// @param isMipmapped\n        ///     Whether or not mipmaps are generated for the texture.\n        /// @param shouldBackupData\n        ///     If the texture data should be backed up in main memory for restoring it later.\n        ///\n        /// @return The new render texture instance.\n        ///\n        UniquePtr<RenderTexture> CreateTexture2D(std::unique_ptr<const u8[]> textureData, u32 textureDataSize, const Integer2& dimensions, ImageFormat imageFormat, ImageCompression imageCompression,\n                                             TextureFilterMode filterMode, TextureWrapMode wrapModeS, TextureWrapMode wrapModeT, bool isMipmapped, bool shouldBackupData) noexcept;\n        \n        /// Creates a new render texture and queues a LoadCubemapRenderCommand for the next\n        /// Render Snapshot stage in the render pipeline.\n        ///\n        /// @param textureData\n        ///     The texture data buffer for all 6 faces.\n        /// @param textureDataSize\n        ///     The size of the texture data buffer.\n        /// @param dimensions\n        ///     The texture dimensions.\n        /// @param imageFormat\n        ///     The image format.\n        /// @param imageCompression\n        ///     The image compression type.\n        /// @param filterMode\n        ///     The texture filter mode.\n        /// @param wrapModeS\n        ///     The s-coordinate wrap mode.\n        /// @param wrapModeT\n        ///     The t-coordinate wrap mode.\n        /// @param isMipmapped\n        ///     Whether or not mipmaps are generated for the texture.\n        /// @param shouldBackupData\n        ///     If the texture data should be backed up in main memory for restoring it later.\n        ///\n        /// @return The new render texture instance.\n        ///\n        UniquePtr<RenderTexture> CreateCubemap(std::array<std::unique_ptr<const u8[]>, 6> textureData, u32 textureDataSize, const Integer2& dimensions, ImageFormat imageFormat, ImageCompression imageCompression,\n                                           TextureFilterMode filterMode, TextureWrapMode wrapModeS, TextureWrapMode wrapModeT, bool isMipmapped, bool shouldBackupData) noexcept;\n        \n        /// Removes the render texture from the manager and queues an UnloadTextureRenderCommand for\n        /// the next Render Snapshot stage in the render pipeline. The render command is given\n        /// ownership of the render texture, ensuring it won't be destroyed until it is no longer\n        /// used.\n        ///\n        /// @param renderTexture\n        ///     The render texture which should be destroyed.\n        ///\n        void DestroyRenderTexture2D(UniquePtr<RenderTexture> renderTexture) noexcept;\n        \n        /// Removes the render texture from the manager and queues an UnloadTextureRenderCommand for\n        /// the next Render Snapshot stage in the render pipeline. The render command is given\n        /// ownership of the render texture, ensuring it won't be destroyed until it is no longer\n        /// used.\n        ///\n        /// @param renderTexture\n        ///     The render texture which should be destroyed.\n        ///\n        void DestroyRenderTextureCubemap(UniquePtr<RenderTexture> renderTexture) noexcept;\n        \n    private:\n        friend class Application;\n        \n        /// A container for information relating to pending texture load commands, such as the\n        /// texture data, data size and the related RenderTexture.\n        ///\n        struct PendingLoadCommand2D final\n        {\n            std::unique_ptr<const u8[]> m_textureData;\n            u32 m_textureDataSize = 0;\n            RenderTexture* m_renderTexture = nullptr;\n        };\n        \n        /// A container for information relating to pending cubemap load commands, such as the\n        /// texture data, data size and the related RenderTexture.\n        ///\n        struct PendingLoadCommandCubemap final\n        {\n            std::array<std::unique_ptr<const u8[]>, 6> m_textureData;\n            u32 m_textureDataSize = 0;\n            RenderTexture* m_renderTexture = nullptr;\n        };\n        \n        /// A factory method for creating new instances of the system. This must be called by\n        /// Application.\n        ///\n        /// @return The new instance of the system.\n        ///\n        static RenderTextureManagerUPtr Create() noexcept;\n        \n        RenderTextureManager();\n        \n        /// Called during the Render Snapshot stage of the render pipeline. All pending load and\n        /// unload commands are added to the render snapshot.\n        ///\n        /// @param targetType\n        ///     Whether the snapshot is for the main screen or an offscreen render target\n        /// @param renderSnapshot\n        ///     The render shapshot for storing snapshotted data.\n        /// @param frameAllocator\n        ///     Allocate memory from this render frame from here\n        ///\n        void OnRenderSnapshot(TargetType targetType, RenderSnapshot& renderSnapshot, IAllocator* frameAllocator) noexcept override;\n        \n        std::mutex m_mutex;\n        ObjectPoolAllocator<RenderTexture> m_renderTexturePool;\n        std::vector<PendingLoadCommand2D> m_pendingLoadCommands2D;\n        std::vector<PendingLoadCommandCubemap> m_pendingLoadCommandsCubemap;\n        std::vector<UniquePtr<RenderTexture>> m_pendingUnloadCommands2D;\n        std::vector<UniquePtr<RenderTexture>> m_pendingUnloadCommandsCubemap;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Texture/Texture.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2010 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Texture/Texture.h>\n\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Rendering/Texture/RenderTexture.h>\n#include <ChilliSource/Rendering/Texture/RenderTextureManager.h>\n#include <ChilliSource/Rendering/Texture/TextureDesc.h>\n\nnamespace ChilliSource\n{\n    CS_DEFINE_NAMEDTYPE(Texture);\n\n    //------------------------------------------------------------------------------\n    TextureUPtr Texture::Create() noexcept\n    {\n        return TextureUPtr(new Texture());\n    }\n    \n    //------------------------------------------------------------------------------\n    bool Texture::IsA(InterfaceIDType interfaceId) const noexcept\n    {\n        return (Texture::InterfaceID == interfaceId);\n    }\n\n    //------------------------------------------------------------------------------\n    void Texture::Build(DataUPtr textureData, u32 textureDataSize, const TextureDesc& textureDesc) noexcept\n    {\n        DestroyRenderTexture();\n        \n        auto renderTextureManager = Application::Get()->GetSystem<RenderTextureManager>();\n        CS_ASSERT(renderTextureManager, \"RenderTextureManager must exist.\");\n        \n        m_restoreTextureDataEnabled = textureDesc.IsRestoreTextureDataEnabled();\n        \n        m_renderTexture = renderTextureManager->CreateTexture2D(std::move(textureData), textureDataSize, textureDesc.GetDimensions(), textureDesc.GetImageFormat(), textureDesc.GetImageCompression(),\n                                                                    textureDesc.GetFilterMode(), textureDesc.GetWrapModeS(), textureDesc.GetWrapModeT(), textureDesc.IsMipmappingEnabled(), m_restoreTextureDataEnabled);\n    }\n\n    //------------------------------------------------------------------------------\n    const Integer2& Texture::GetDimensions() const noexcept\n    {\n        CS_ASSERT(GetLoadState() == LoadState::k_loaded, \"Cannot access texture before it is loaded.\");\n        CS_ASSERT(m_renderTexture, \"Cannot access texture which has not been built.\");\n        \n        return m_renderTexture->GetDimensions();\n    }\n\n    //------------------------------------------------------------------------------\n    ImageFormat Texture::GetImageFormat() const noexcept\n    {\n        CS_ASSERT(GetLoadState() == LoadState::k_loaded, \"Cannot access texture before it is loaded.\");\n        CS_ASSERT(m_renderTexture, \"Cannot access texture which has not been built.\");\n        \n        return m_renderTexture->GetImageFormat();\n    }\n\n    //------------------------------------------------------------------------------\n    ImageCompression Texture::GetImageCompression() const noexcept\n    {\n        CS_ASSERT(GetLoadState() == LoadState::k_loaded, \"Cannot access texture before it is loaded.\");\n        CS_ASSERT(m_renderTexture, \"Cannot access texture which has not been built.\");\n        \n        return m_renderTexture->GetImageCompression();\n    }\n    \n    //------------------------------------------------------------------------------\n    TextureFilterMode Texture::GetFilterMode() const noexcept\n    {\n        CS_ASSERT(GetLoadState() == LoadState::k_loaded, \"Cannot access texture before it is loaded.\");\n        CS_ASSERT(m_renderTexture, \"Cannot access texture which has not been built.\");\n        \n        return m_renderTexture->GetFilterMode();\n    }\n\n    //------------------------------------------------------------------------------\n    TextureWrapMode Texture::GetWrapModeS() const noexcept\n    {\n        CS_ASSERT(GetLoadState() == LoadState::k_loaded, \"Cannot access texture before it is loaded.\");\n        CS_ASSERT(m_renderTexture, \"Cannot access texture which has not been built.\");\n        \n        return m_renderTexture->GetWrapModeS();\n    }\n\n    //------------------------------------------------------------------------------\n    TextureWrapMode Texture::GetWrapModeT() const noexcept\n    {\n        CS_ASSERT(GetLoadState() == LoadState::k_loaded, \"Cannot access texture before it is loaded.\");\n        CS_ASSERT(m_renderTexture, \"Cannot access texture which has not been built.\");\n        \n        return m_renderTexture->GetWrapModeT();\n    }\n\n    //------------------------------------------------------------------------------\n    bool Texture::IsMipmappingEnabled() const noexcept\n    {\n        CS_ASSERT(GetLoadState() == LoadState::k_loaded, \"Cannot access texture before it is loaded.\");\n        CS_ASSERT(m_renderTexture, \"Cannot access texture which has not been built.\");\n        \n        return m_renderTexture->IsMipmapped();\n    }\n\n    //------------------------------------------------------------------------------\n    bool Texture::IsRestoreTextureDataEnabled() const noexcept\n    {\n        CS_ASSERT(GetLoadState() == LoadState::k_loaded, \"Cannot access texture before it is loaded.\");\n        CS_ASSERT(m_renderTexture, \"Cannot access texture which has not been built.\");\n        \n        return m_restoreTextureDataEnabled;\n    }\n\n    //------------------------------------------------------------------------------\n    const RenderTexture* Texture::GetRenderTexture() const noexcept\n    {\n        CS_ASSERT(GetLoadState() == LoadState::k_loaded, \"Cannot access texture before it is loaded.\");\n        CS_ASSERT(m_renderTexture, \"Cannot access texture which has not been built.\");\n        \n        return m_renderTexture.get();\n    }\n    \n    //------------------------------------------------------------------------------\n    void Texture::DestroyRenderTexture() noexcept\n    {\n        if (m_renderTexture)\n        {\n            auto renderTextureManager = Application::Get()->GetSystem<RenderTextureManager>();\n            CS_ASSERT(renderTextureManager, \"RenderTextureManager must exist.\");\n            \n            renderTextureManager->DestroyRenderTexture2D(std::move(m_renderTexture));\n        }\n    }\n    \n    //------------------------------------------------------------------------------\n    Texture::~Texture() noexcept\n    {\n        DestroyRenderTexture();\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Texture/Texture.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2010 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_TEXTURE_TEXTURE_H_\n#define _CHILLISOURCE_RENDERING_TEXTURE_TEXTURE_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Memory/UniquePtr.h>\n#include <ChilliSource/Core/Image/ImageFormat.h>\n#include <ChilliSource/Core/Image/ImageCompression.h>\n#include <ChilliSource/Core/Resource/Resource.h>\n\nnamespace ChilliSource\n{\n    /// A basic 2D texture resource. One or more textures can be applied to a model using\n    /// a material.\n    ///\n    /// This is not thread safe and should only be accessed from one thread at a time.\n    ///\n    class Texture final : public Resource\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(Texture);\n        \n        /// The buffer used to hold texture data.\n        ///\n        using DataUPtr = std::unique_ptr<const u8[]>;\n\n        /// Allows querying of whether or not this system implements the interface described by the\n        /// given interface Id. Typically this is not called directly as the templated equivalent\n        /// IsA<Interface>() is preferred.\n        ///\n        /// @param interfaceId\n        ///     The Id of the interface.\n        ///\n        /// @return Whether or not the interface is implemented.\n        ///\n        bool IsA(InterfaceIDType interfaceId) const noexcept override;\n        \n        /// Construct the texture from the given image data. The texture will take ownership of\n        /// the image data. The texture must not already be in the loaded state.\n        ///\n        /// @param textureData\n        ///     The texture data buffer.\n        /// @param textureDataSize\n        ///     The size of the texture data buffer.\n        /// @param textureDesc\n        ///     The texture description.\n        ///\n        void Build(DataUPtr textureData, u32 textureDataSize, const TextureDesc& textureDesc) noexcept;\n\n        /// @return The texture dimensions.\n        ///\n        const Integer2& GetDimensions() const noexcept;\n        \n        /// @return The format of the image.\n        ///\n        ImageFormat GetImageFormat() const noexcept;\n        \n        /// @return The compression type of the image.\n        ///\n        ImageCompression GetImageCompression() const noexcept;\n        \n        /// @return The texture filter mode used when rendering the texture.\n        ///\n        TextureFilterMode GetFilterMode() const noexcept;\n        \n        /// @return The s-coordinate texture wrap mode used when rendering the texture.\n        ///\n        TextureWrapMode GetWrapModeS() const noexcept;\n        \n        /// @return The t-coordinate texture wrap mode used when rendering the texture.\n        ///\n        TextureWrapMode GetWrapModeT() const noexcept;\n        \n        /// @return Whether or not the texture should be mipmapped.\n        ///\n        bool IsMipmappingEnabled() const noexcept;\n        \n        /// @return Whether or not texture data should be restored on context loss.\n        ///\n        bool IsRestoreTextureDataEnabled() const noexcept;\n        \n        /// @return The underlying RenderTexture used by the render system.\n        ///\n        const RenderTexture* GetRenderTexture() const noexcept;\n        \n        ~Texture() noexcept;\n        \n    private:\n        friend class ResourcePool;\n        \n        /// A factory method for creating new, empty instances of the resource. This must only be\n        /// called by ResourcePool.\n        ///\n        /// @return The new instance of the resource.\n        ///\n        static TextureUPtr Create() noexcept;\n        \n        /// Destroys the render texture if one currently exists.\n        ///\n        void DestroyRenderTexture() noexcept;\n        \n        Texture() = default;\n        \n        UniquePtr<RenderTexture> m_renderTexture;\n        bool m_restoreTextureDataEnabled = false;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Texture/TextureAtlas.cpp",
    "content": "//\n//  TextureAtlas.cpp\n//  ChilliSource\n//  Created by Scott Downie on 22/10/2010.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2010 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Texture/TextureAtlas.h>\n\n#include <ChilliSource/Core/Cryptographic/HashCRC32.h>\n\nnamespace ChilliSource\n{\n    namespace\n    {\n        const f32 k_texelOffset = 1.0f;\n        const f32 k_halfTexelOffset = k_texelOffset * 0.5f;\n    }\n    \n    CS_DEFINE_NAMEDTYPE(TextureAtlas);\n    \n    //---------------------------------------------------------------------\n    //---------------------------------------------------------------------\n    TextureAtlasUPtr TextureAtlas::Create()\n    {\n        return TextureAtlasUPtr(new TextureAtlas());\n    }\n    //---------------------------------------------------------------------\n    //---------------------------------------------------------------------\n    bool TextureAtlas::IsA(InterfaceIDType in_interfaceId) const\n    {\n        return in_interfaceId == TextureAtlas::InterfaceID;\n    }\n    //---------------------------------------------------------------------\n    //---------------------------------------------------------------------\n    void TextureAtlas::Build(const Descriptor& in_desc)\n    {\n        m_textureAtlasWidth = in_desc.m_textureAtlasWidth;\n        m_textureAtlasHeight = in_desc.m_textureAtlasHeight;\n        \n        for(u32 i=0; i<in_desc.m_keys.size(); ++i)\n        {\n            Frame frame;\n            const FrameRaw& frameRaw = in_desc.m_frames[i];\n            \n            //Calculate normalise UVs\n            f32 inverseWidth = 1.0f / m_textureAtlasWidth;\n            f32 inverseHeight = 1.0f / m_textureAtlasHeight;\n            frame.m_uvs.m_u = (f32)(frameRaw.m_texCoordU + k_halfTexelOffset) * inverseWidth;\n            frame.m_uvs.m_v = (f32)(frameRaw.m_texCoordV + k_halfTexelOffset) * inverseHeight;\n            frame.m_uvs.m_s = (f32)(frameRaw.m_croppedWidth - k_texelOffset) * inverseWidth;\n            frame.m_uvs.m_t = (f32)(frameRaw.m_croppedHeight - k_texelOffset) * inverseHeight;\n            \n            frame.m_originalSize = Vector2(frameRaw.m_originalWidth, frameRaw.m_originalHeight);\n            frame.m_croppedSize = Vector2(frameRaw.m_croppedWidth, frameRaw.m_croppedHeight);\n            frame.m_offset = Vector2(frameRaw.m_offsetX, frameRaw.m_offsetY);\n            \n            m_frames.insert(std::make_pair(in_desc.m_keys[i], frame));\n        }\n    }\n    //---------------------------------------------------------------------\n    //---------------------------------------------------------------------\n    const TextureAtlas::Frame& TextureAtlas::GetFrame(const std::string& in_textureId) const\n    {\n        u32 hashedId = HashCRC32::GenerateHashCode(in_textureId);\n        \n        auto it = m_frames.find(hashedId);\n        \n        CS_ASSERT(it != m_frames.end(), \"Texture in atlas not found for key: \" + in_textureId);\n        \n        return it->second;\n    }\n    //---------------------------------------------------------------------\n    //---------------------------------------------------------------------\n    bool TextureAtlas::HasFrameWithId(const std::string& in_textureId) const\n    {\n        u32 hashedId = HashCRC32::GenerateHashCode(in_textureId);\n        \n        return HasFrameWithId(hashedId);\n    }\t\n    //---------------------------------------------------------------------\n    //---------------------------------------------------------------------\n    UVs TextureAtlas::GetFrameUVs(const std::string& in_textureId) const\n    {\n        const Frame& frame = GetFrame(in_textureId);\n        return frame.m_uvs;\n    }\n    //---------------------------------------------------------------------\n    //---------------------------------------------------------------------\n    Vector2 TextureAtlas::GetCroppedFrameSize(const std::string& in_textureId) const\n    {\n        const Frame& frame = GetFrame(in_textureId);\n        return frame.m_croppedSize;\n    }\n    //---------------------------------------------------------------------\n    //---------------------------------------------------------------------\n    Vector2 TextureAtlas::GetOriginalFrameSize(const std::string& in_textureId) const\n    {\n        const Frame& frame = GetFrame(in_textureId);\n        return frame.m_originalSize;\n    }\n    //---------------------------------------------------------------------\n    //---------------------------------------------------------------------\n    Vector2 TextureAtlas::GetFrameOffset(const std::string& in_textureId) const\n    {\n        const Frame& frame = GetFrame(in_textureId);\n        return frame.m_offset;\n    }\n    //---------------------------------------------------------------------\n    //---------------------------------------------------------------------\n    const TextureAtlas::Frame& TextureAtlas::GetFrame(u32 in_hashedTextureId) const\n    {\n        auto it = m_frames.find(in_hashedTextureId);\n        \n        CS_ASSERT(it != m_frames.end(), \"Texture in atlas not found for hashed key: \" + ToString(in_hashedTextureId));\n        \n        return it->second;\n    }\n    //---------------------------------------------------------------------\n    //---------------------------------------------------------------------\n    bool TextureAtlas::HasFrameWithId(u32 in_hashedTextureId) const\n    {\n        auto it = m_frames.find(in_hashedTextureId);\n        return (it != m_frames.end());\n    }\n    //---------------------------------------------------------------------\n    //---------------------------------------------------------------------\n    UVs TextureAtlas::GetFrameUVs(u32 in_hashedTextureId) const\n    {\n        const Frame& frame = GetFrame(in_hashedTextureId);\n        return frame.m_uvs;\n    }\n    //---------------------------------------------------------------------\n    //---------------------------------------------------------------------\n    Vector2 TextureAtlas::GetCroppedFrameSize(u32 in_hashedTextureId) const\n    {\n        const Frame& frame = GetFrame(in_hashedTextureId);\n        return frame.m_croppedSize;\n    }\n    //---------------------------------------------------------------------\n    //---------------------------------------------------------------------\n    Vector2 TextureAtlas::GetOriginalFrameSize(u32 in_hashedTextureId) const\n    {\n        const Frame& frame = GetFrame(in_hashedTextureId);\n        return frame.m_originalSize;\n    }\n    //---------------------------------------------------------------------\n    //---------------------------------------------------------------------\n    Vector2 TextureAtlas::GetFrameOffset(u32 in_hashedTextureId) const\n    {\n        const Frame& frame = GetFrame(in_hashedTextureId);\n        return frame.m_offset;\n    }\n    //---------------------------------------------------------------------\n    //---------------------------------------------------------------------\n    u32 TextureAtlas::GetWidth() const\n    {\n        return m_textureAtlasWidth;\n    }\n    //---------------------------------------------------------------------\n    //---------------------------------------------------------------------\n    u32 TextureAtlas::GetHeight() const\n    {\n        return m_textureAtlasHeight;\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Texture/TextureAtlas.h",
    "content": "//\n//  TextureAtlas.h\n//  ChilliSource\n//  Created by Scott Downie on 22/10/2010.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2010 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_TEXTURE_TEXTUREATLAS_H_\n#define _CHILLISOURCE_RENDERING_TEXTURE_TEXTUREATLAS_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Math/Geometry/Shapes.h>\n#include <ChilliSource/Core/Resource/Resource.h>\n#include <ChilliSource/Rendering/Texture/UVs.h>\n\n#include <unordered_map>\n\nnamespace ChilliSource\n{\n    //---------------------------------------------------------------------\n    /// A resource that holds the information about packed textures in a\n    /// texture page. Includes methods for accessing the individual texture\n    /// data (such as UVs, size, etc) by name.\n    ///\n    /// @author S Downie\n    //---------------------------------------------------------------------\n    class TextureAtlas final : public Resource\n    {\n    public:\n        \n        //---------------------------------------------------------------------\n        /// Holds the description of a single frame (or texture) packed into\n        /// the atlas. This includes the size, UVs, etc. The UVs are\n        /// in texels\n        ///\n        /// @author S Downie\n        //---------------------------------------------------------------------\n        struct FrameRaw\n        {\n            s16 m_texCoordU;\n            s16 m_texCoordV;\n            s16 m_croppedWidth;\n            s16 m_croppedHeight;\n            s16 m_offsetX;\n            s16 m_offsetY;\n            s16 m_originalWidth;\n            s16 m_originalHeight;\n        };\n        //---------------------------------------------------------------------\n        /// Holds the description of a single frame (or texture) packed into\n        /// the atlas. This includes the size, UVs, etc. The UVs are normalised\n        ///\n        /// @author S Downie\n        //---------------------------------------------------------------------\n        struct Frame\n        {\n            UVs m_uvs;\n            Vector2 m_croppedSize;\n            Vector2 m_originalSize;\n            Vector2 m_offset;\n        };\n        //---------------------------------------------------------------------\n        /// Holds the description of a texture atlas. Used to build the resource\n        ///\n        /// @author S Downie\n        //---------------------------------------------------------------------\n        struct Descriptor\n        {\n            std::vector<FrameRaw> m_frames;\n            std::vector<u32> m_keys;\n            \n            u32 m_textureAtlasWidth = 0;\n            u32 m_textureAtlasHeight = 0;\n        };\n        \n        CS_DECLARE_NAMEDTYPE(TextureAtlas);\n        \n        //---------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Interface type\n        ///\n        /// @return Whether this object is of given type\n        //---------------------------------------------------------------------\n        bool IsA(InterfaceIDType in_interfaceId) const override;\n        //---------------------------------------------------------------------\n        /// Construct the sprite sheet data from the given descriptor\n        /// this populates the resource ready for use\n        ///\n        /// @author S Downie\n        ///\n        /// @param Sprite sheet descriptor\n        //---------------------------------------------------------------------\n        void Build(const Descriptor& in_desc);\n        //---------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Texture Id as generated by the sprite tool\n        ///\n        /// @return Frame data\n        //---------------------------------------------------------------------\n        const Frame& GetFrame(const std::string& in_textureId) const;\n        //---------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Texture Id as generated by the sprite tool\n        ///\n        /// @return Whether frame exists with given Id\n        //---------------------------------------------------------------------\n        bool HasFrameWithId(const std::string& in_textureId) const;\n        //---------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Texture Id as generated by the sprite tool\n        ///\n        /// @return Rect containing UV coords for the given frame\n        //---------------------------------------------------------------------\n        UVs GetFrameUVs(const std::string& in_textureId) const;\n        //---------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Texture Id as generated by the sprite tool\n        ///\n        /// @return Size of the given frame in pixels\n        //---------------------------------------------------------------------\n        Vector2 GetCroppedFrameSize(const std::string& in_textureId) const;\n        //---------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Texture Id as generated by the sprite tool\n        ///\n        /// @return Size of the given frame in pixels prior to alpha cropping\n        //---------------------------------------------------------------------\n        Vector2 GetOriginalFrameSize(const std::string& in_textureId) const;\n        //---------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Texture Id as generated by the sprite tool\n        ///\n        /// @return The value in pixels of the X, Y crop offset from the original\n        /// sprite.\n        //---------------------------------------------------------------------\n        Vector2 GetFrameOffset(const std::string& in_textureId) const;\n        //---------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Hashed texture id from tool name\n        ///\n        /// @return Frame data\n        //---------------------------------------------------------------------\n        const Frame& GetFrame(u32 in_hashedTextureId) const;\n        //---------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Hashed texture id from tool name\n        ///\n        /// @return Whether frame exists with given Id\n        //---------------------------------------------------------------------\n        bool HasFrameWithId(u32 in_hashedTextureId) const;\n        //---------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Hashed texture id from tool name\n        ///\n        /// @return Rect containing UV coords for the given frame\n        //---------------------------------------------------------------------\n        UVs GetFrameUVs(u32 in_hashedTextureId) const;\n        //---------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Hashed texture id from tool name\n        ///\n        /// @return Size of the given frame in pixels\n        //---------------------------------------------------------------------\n        Vector2 GetCroppedFrameSize(u32 in_hashedTextureId) const;\n        //---------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Hashed texture id from tool name\n        ///\n        /// @return Size of the given frame in pixels prior to alpha cropping\n        //---------------------------------------------------------------------\n        Vector2 GetOriginalFrameSize(u32 in_hashedTextureId) const;\n        //---------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Hashed texture id from tool name\n        ///\n        /// @return The value in pixels of the X, Y crop offset from the original\n        /// sprite.\n        //---------------------------------------------------------------------\n        Vector2 GetFrameOffset(u32 in_hashedTextureId) const;\n        //---------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Width of TextureAtlas in pixels\n        //---------------------------------------------------------------------\n        u32 GetWidth() const;\n        //---------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Height of TextureAtlas in pixels\n        //---------------------------------------------------------------------\n        u32 GetHeight() const;\n        \n    private:\n        \n        friend class ResourcePool;\n        //---------------------------------------------------------------------\n        /// Factory method to create empty sprite sheet resource. Only called\n        /// by the resource pool\n        ///\n        /// @author S Downie\n        ///\n        /// @return Ownership of resource\n        //---------------------------------------------------------------------\n        static TextureAtlasUPtr Create();\n        //---------------------------------------------------------------------\n        /// Private constructor to enforce use of factory create method\n        ///\n        /// @author S Downie\n        //---------------------------------------------------------------------\n        TextureAtlas() = default;\n        \n    private:\n        \n        std::unordered_map<u32, Frame> m_frames;\n        \n        u32 m_textureAtlasWidth = 0;\n        u32 m_textureAtlasHeight = 0;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Texture/TextureAtlasProvider.cpp",
    "content": "//\n//  TextureAtlasProvider.cpp\n//  ChilliSource\n//  Created by Scott Downie on 22/10/2010.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2010 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Texture/TextureAtlasProvider.h>\n\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/Base/Utils.h>\n#include <ChilliSource/Core/File.h>\n#include <ChilliSource/Core/Cryptographic/HashCRC32.h>\n#include <ChilliSource/Core/Threading/TaskScheduler.h>\n\nnamespace ChilliSource\n{\n    namespace\n    {\n        const std::string k_framesFileExtension(\"csatlas\");\n        const std::string k_keysFileExtension(\"csatlasid\");\n        \n        const u32 k_numElementsPerFrame = 8;\n    }\n    \n    CS_DEFINE_NAMEDTYPE(TextureAtlasProvider);\n    \n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    TextureAtlasProviderUPtr TextureAtlasProvider::Create()\n    {\n        return TextureAtlasProviderUPtr(new TextureAtlasProvider());\n    }\n    //-------------------------------------------------------------------------\n    //-------------------------------------------------------------------------\n    bool TextureAtlasProvider::IsA(InterfaceIDType in_interfaceId) const\n    {\n        return in_interfaceId == ResourceProvider::InterfaceID || in_interfaceId == TextureAtlasProvider::InterfaceID;\n    }\n    //----------------------------------------------------------------------------\n    //----------------------------------------------------------------------------\n    InterfaceIDType TextureAtlasProvider::GetResourceType() const\n    {\n        return TextureAtlas::InterfaceID;\n    }\n    //----------------------------------------------------------------------------\n    //----------------------------------------------------------------------------\n    bool TextureAtlasProvider::CanCreateResourceWithFileExtension(const std::string& in_extension) const\n    {\n        return in_extension == k_framesFileExtension;\n    }\n    //----------------------------------------------------------------------------\n    //----------------------------------------------------------------------------\n    void TextureAtlasProvider::CreateResourceFromFile(StorageLocation in_location, const std::string& in_filePath, const IResourceOptionsBaseCSPtr& in_options, const ResourceSPtr& out_resource)\n    {\n        LoadResource(in_location, in_filePath, nullptr, out_resource);\n    }\n    //----------------------------------------------------------------------------\n    //----------------------------------------------------------------------------\n    void TextureAtlasProvider::CreateResourceFromFileAsync(StorageLocation in_location, const std::string& in_filePath, const IResourceOptionsBaseCSPtr& in_options, const ResourceProvider::AsyncLoadDelegate& in_delegate, const ResourceSPtr& out_resource)\n    {\n        Application::Get()->GetTaskScheduler()->ScheduleTask(TaskType::k_file, [=](const TaskContext&) noexcept\n        {\n            LoadResource(in_location, in_filePath, in_delegate, out_resource);\n        });\n    }\n    //----------------------------------------------------------------------------\n    //----------------------------------------------------------------------------\n    void TextureAtlasProvider::LoadResource(StorageLocation in_location, const std::string& in_filePath, const ResourceProvider::AsyncLoadDelegate& in_delegate, const ResourceSPtr& out_resource)\n    {\n        TextureAtlas* spriteResource(static_cast<TextureAtlas*>(out_resource.get()));\n        \n        TextureAtlas::Descriptor desc;\n        LoadFrames(in_location, in_filePath, desc);\n        LoadMap(in_location, in_filePath, desc);\n        \n        if(desc.m_frames.size() > 0 && desc.m_keys.size() > 0)\n        {\n            spriteResource->SetLoadState(Resource::LoadState::k_loaded);\n            spriteResource->Build(desc);\n        }\n        else\n        {\n            spriteResource->SetLoadState(Resource::LoadState::k_failed);\n        }\n        \n        if(in_delegate != nullptr)\n        {\n            Application::Get()->GetTaskScheduler()->ScheduleTask(TaskType::k_mainThread, [=](const TaskContext&) noexcept\n            {\n                in_delegate(out_resource);\n            });\n        }\n    }\n    //----------------------------------------------------------------------------\n    //----------------------------------------------------------------------------\n    void TextureAtlasProvider::LoadFrames(StorageLocation in_location, const std::string& in_filePath, TextureAtlas::Descriptor& out_desc)\n    {\n        IBinaryInputStreamUPtr frameFile = Application::Get()->GetFileSystem()->CreateBinaryInputStream(in_location, in_filePath);\n        \n        if(frameFile == nullptr)\n        {\n            return;\n        }\n        \n        s16 numFrames = 0;\n        frameFile->Read(reinterpret_cast<u8*>(&numFrames), sizeof(s16));\n        \n        s16 binVersion = 0;\n        frameFile->Read(reinterpret_cast<u8*>(&binVersion), sizeof(s16));\n        \n        CS_ASSERT(binVersion >= 3, \"TextureAtlas minimum version supported is 2.0\");\n        \n        s16 textureAtlasWidth = 0;\n        frameFile->Read(reinterpret_cast<u8*>(&textureAtlasWidth), sizeof(s16));\n        \n        s16 textureAtlasHeight = 0;\n        frameFile->Read(reinterpret_cast<u8*>(&textureAtlasHeight), sizeof(s16));\n        \n        //Temporary buffer to hold our unformatted data\n        const u32 numElements = numFrames * k_numElementsPerFrame;\n        s16* buffer = new s16[numElements];\n        \n        //Fetch the binary data in one read.\n        frameFile->Read(reinterpret_cast<u8*>(buffer), numElements * sizeof(s16));\n        frameFile.reset();\n        \n        //Now copy the data into our sprite data buffer as it is now in the correct format\n        out_desc.m_textureAtlasWidth = (u32)textureAtlasWidth;\n        out_desc.m_textureAtlasHeight = (u32)textureAtlasHeight;\n        out_desc.m_frames.reserve(numFrames);\n        \n        s16* framePtr = buffer;\n        for(u32 i=0; i<(u32)numFrames; ++i)\n        {\n            TextureAtlas::FrameRaw frame;\n            \n            frame.m_texCoordU = framePtr[0];\n            frame.m_texCoordV = framePtr[1];\n            frame.m_croppedWidth = framePtr[2];\n            frame.m_croppedHeight = framePtr[3];\n            frame.m_offsetX = framePtr[4];\n            frame.m_offsetY = framePtr[5];\n            frame.m_originalWidth = framePtr[6];\n            frame.m_originalHeight = framePtr[7];\n            \n            out_desc.m_frames.push_back(frame);\n            framePtr += k_numElementsPerFrame;\n        }\n        \n        CS_SAFEDELETE_ARRAY(buffer);\n    }\n    //----------------------------------------------------------------------------\n    //----------------------------------------------------------------------------\n    void TextureAtlasProvider::LoadMap(StorageLocation in_location, const std::string& in_filePath, TextureAtlas::Descriptor& out_desc)\n    {\n        //The string IDs are loaded as a by-product so we have to deduce their file type\n        std::string fileName;\n        std::string fileExtension;\n        \n        StringUtils::SplitBaseFilename(in_filePath, fileName, fileExtension);\n        auto mapFile = Application::Get()->GetFileSystem()->CreateTextInputStream(in_location, fileName + \".csatlasid\");\n        \n        if(mapFile != nullptr)\n        {\n            std::vector<u32> IDHashedLookup;\n            \n            std::string spriteID;\n            while(mapFile->ReadLine(spriteID))\n            {\n                if(spriteID.empty() == false)\n                {\n                    out_desc.m_keys.push_back(HashCRC32::GenerateHashCode(spriteID));\n                    spriteID.clear();\n                }\n            }\n        }\n    }\n}\n\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Texture/TextureAtlasProvider.h",
    "content": "//\n//  TextureAtlasProvider.h\n//  ChilliSource\n//  Created by Scott Downie on 22/10/2010.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2010 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_TEXTURE_TEXTUREATLASPROVIDER_H_\n#define _CHILLISOURCE_RENDERING_TEXTURE_TEXTUREATLASPROVIDER_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Resource/ResourceProvider.h>\n#include <ChilliSource/Rendering/Texture/TextureAtlas.h>\n\nnamespace ChilliSource\n{\n    //-------------------------------------------------------\n    /// Factory loader for creating texture atlas resources\n    /// from file. This loader is responsible for loading the\n    /// keys and frame values.\n    ///\n    /// @author S Downie\n    //-------------------------------------------------------\n    class TextureAtlasProvider final : public ResourceProvider\n    {\n    public:\n        \n        CS_DECLARE_NAMEDTYPE(TextureAtlasProvider);\n        \n        //-------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Interface to compare\n        ///\n        /// @return Whether the object implements the given interface\n        //-------------------------------------------------------------------------\n        bool IsA(InterfaceIDType in_interfaceId) const override;\n        //----------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return The resource type this provider loads\n        //----------------------------------------------------------------------------\n        InterfaceIDType GetResourceType() const override;\n        //----------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Extension to compare\n        ///\n        /// @return Whether the object can create a resource with the given extension\n        //----------------------------------------------------------------------------\n        bool CanCreateResourceWithFileExtension(const std::string& in_extension) const override;\n        \n    private:\n        friend class Application;\n        //-------------------------------------------------------\n        /// Factory method\n        ///\n        /// @author S Downie\n        ///\n        /// @return New backend with ownership transferred\n        //-------------------------------------------------------\n        static TextureAtlasProviderUPtr Create();\n        //-------------------------------------------------------\n        /// Private constructor to force use of factory method\n        ///\n        /// @author S Downie\n        //-------------------------------------------------------\n        TextureAtlasProvider() = default;\n        //----------------------------------------------------------------------------\n        /// Loads the two files that constitute an atlas resource and\n        /// parses them into the output resource. Check the resource load state\n        /// for success or failure.\n        ///\n        /// @author S Downie\n        ///\n        /// @param Location to load from\n        /// @param File path\n        /// @param Options to customise the creation\n        /// @param [Out] Resource object\n        //----------------------------------------------------------------------------\n        void CreateResourceFromFile(StorageLocation in_location, const std::string& in_filePath, const IResourceOptionsBaseCSPtr& in_options, const ResourceSPtr& out_resource) override;\n        //----------------------------------------------------------------------------\n        /// Loads the two files that constitute a atlas resource and\n        /// parses them into the output resource on a background thread. Delegate\n        /// is called on completion. Check the resource load state for success or failure\n        ///\n        /// @author S Downie\n        ///\n        /// @param Location to load from\n        /// @param File path\n        /// @param Options to customise the creation\n        /// @param Completion delegate\n        /// @param [Out] Resource object\n        //----------------------------------------------------------------------------\n        void CreateResourceFromFileAsync(StorageLocation in_location, const std::string& in_filePath, const IResourceOptionsBaseCSPtr& in_options, const ResourceProvider::AsyncLoadDelegate& in_delegate, const ResourceSPtr& out_resource) override;\n        //----------------------------------------------------------------------------\n        /// Performs the actual loading delegated to by the 2 create methods\n        ///\n        /// @author S Downie\n        ///\n        /// @param Location to load from\n        /// @param Filename\n        /// @param Completion delegate\n        /// @param [Out] Resource object\n        //----------------------------------------------------------------------------\n        void LoadResource(StorageLocation in_location, const std::string& in_filePath, const ResourceProvider::AsyncLoadDelegate& in_delegate, const ResourceSPtr& out_resource);\n        //----------------------------------------------------------------------------\n        /// Loads the file containing the frame data for each texture in the atlas\n        ///\n        /// @author S Downie\n        ///\n        /// @param Location to load from\n        /// @param Filename\n        /// @param [Out] Descriptor\n        //----------------------------------------------------------------------------\n        void LoadFrames(StorageLocation in_location, const std::string& in_filePath, TextureAtlas::Descriptor& out_desc);\n        //----------------------------------------------------------------------------\n        /// Loads the file containing the map key data for each texture in the atlas\n        ///\n        /// @author S Downie\n        ///\n        /// @param Location to load from\n        /// @param Filename\n        /// @param [Out] Descriptor\n        //----------------------------------------------------------------------------\n        void LoadMap(StorageLocation in_location, const std::string& in_filePath, TextureAtlas::Descriptor& out_desc);\n    };\n}\n\n#endif\n\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Texture/TextureDesc.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Texture/TextureDesc.h>\n\nnamespace ChilliSource\n{\n    namespace\n    {\n        /// @param imageFormat\n        ///     The image format to check.\n        ///\n        /// @return Whether or not the given image format can be restored.\n        ///\n#if CS_ENABLE_DEBUG\n        constexpr bool IsImageFormatRestorable(ImageFormat imageFormat) noexcept\n        {\n            return (imageFormat == ImageFormat::k_RGBA8888 || imageFormat == ImageFormat::k_RGB888 || imageFormat == ImageFormat::k_RGBA4444 || imageFormat == ImageFormat::k_RGB565);\n        }\n#endif  \n    }\n    \n    //------------------------------------------------------------------------------\n    TextureDesc::TextureDesc(const Integer2& dimensions, ImageFormat imageFormat, ImageCompression imageCompression, bool restorable) noexcept\n        : m_dimensions(dimensions), m_imageFormat(imageFormat), m_imageCompression(imageCompression)\n    {\n        SetTextureDataRestoreEnabled(restorable);\n    }\n\n    //------------------------------------------------------------------------------\n    void TextureDesc::SetTextureDataRestoreEnabled(bool restoreTextureDataEnabled) noexcept\n    {\n        CS_ASSERT(restoreTextureDataEnabled == false || IsImageFormatRestorable(m_imageFormat), \"Only RGBA8888, RGB888, RGBA4444 and RGB565 image formats can have their data restored.\");\n        \n        m_restoreTextureDataEnabled = restoreTextureDataEnabled;\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Texture/TextureDesc.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_TEXTURE_TEXTUREDESC_H_\n#define _CHILLISOURCE_RENDERING_TEXTURE_TEXTUREDESC_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Math/Vector2.h>\n#include <ChilliSource/Core/Image/ImageFormat.h>\n#include <ChilliSource/Core/Image/ImageCompression.h>\n#include <ChilliSource/Rendering/Texture/TextureFilterMode.h>\n#include <ChilliSource/Rendering/Texture/TextureWrapMode.h>\n\nnamespace ChilliSource\n{\n    /// A description of a texture, containing information such as the image format, image\n    /// compression type and filter mode. This is used to build new texture instances.\n    ///\n    /// This is not thread safe and should only be accessed from one thread at a time.\n    ///\n    class TextureDesc final\n    {\n    public:\n        TextureDesc() = default;\n        \n        /// Constructs a new instance with the given texture data, dimensions, format and compression.\n        ///\n        /// @param dimensions\n        ///     The texture dimensions.\n        /// @param imageFormat\n        ///     The format of the image.\n        /// @param imageCompression\n        ///     The compression type applied to the texture data.\n        /// @param restorable\n        ///     Whether or not the texture is restored automatically after context loss\n        ///\n        TextureDesc(const Integer2& dimensions, ImageFormat imageFormat, ImageCompression imageCompression, bool restorable) noexcept;\n        \n        /// Sets the texture filter mode that will be used when rendering the texture.\n        ///\n        /// @param filterMode\n        ///     The texture filter mode.\n        ///\n        void SetFilterMode(TextureFilterMode filterMode) noexcept { m_filterMode = filterMode; };\n        \n        /// Sets the s-coordinate texture wrap mode that will be used when rendering the texture.\n        ///\n        /// @param wrapModeS\n        ///     The s-coordinate texture wrap mode.\n        ///\n        void SetWrapModeS(TextureWrapMode wrapModeS) noexcept { m_wrapModeS = wrapModeS; };\n        \n        /// Sets the t-coordinate texture wrap mode that will be used when rendering the texture.\n        ///\n        /// @param wrapModeS\n        ///     The t-coordinate texture wrap mode.\n        ///\n        void SetWrapModeT(TextureWrapMode wrapModeT) noexcept { m_wrapModeT = wrapModeT; };\n        \n        /// Sets whether or not the texture should be mipmapped.\n        ///\n        /// @param mipmappingEnabled\n        ///     Whether or not the texture should be mipmapped.\n        ///\n        void SetMipmappingEnabled(bool mipmappingEnabled) noexcept { m_mipmappingEnabled = mipmappingEnabled; };\n        \n        /// @return The texture dimensions.\n        ///\n        const Integer2& GetDimensions() const noexcept { return m_dimensions; }\n        \n        /// @return The format of the image.\n        ///\n        ImageFormat GetImageFormat() const noexcept { return m_imageFormat; }\n        \n        /// @return The compression type of the image.\n        ///\n        ImageCompression GetImageCompression() const noexcept { return m_imageCompression; }\n        \n        /// @return The texture filter mode used when rendering the texture.\n        ///\n        TextureFilterMode GetFilterMode() const noexcept { return m_filterMode; }\n        \n        /// @return The s-coordinate texture wrap mode used when rendering the texture.\n        ///\n        TextureWrapMode GetWrapModeS() const noexcept { return m_wrapModeS; }\n        \n        /// @return The t-coordinate texture wrap mode used when rendering the texture.\n        ///\n        TextureWrapMode GetWrapModeT() const noexcept { return m_wrapModeT; }\n        \n        /// @return Whether or not the texture should be mipmapped.\n        ///\n        bool IsMipmappingEnabled() const noexcept { return m_mipmappingEnabled; }\n        \n        /// @return Whether or not texture data should be restored on context loss.\n        ///\n        bool IsRestoreTextureDataEnabled() const noexcept { return m_restoreTextureDataEnabled; }\n        \n    private:\n        \n        /// Sets whether or not the texture data should be restored after a context loss. This involves\n        /// maintaining a copy of the texture data in memory which is costly so this should be disabled\n        /// for any textures that can easily be recreated, i.e any texture that is rendered into every\n        /// frame.\n        ///\n        /// This has no effect on textures that are loaded from file as they are always restored from\n        /// disk.\n        ///\n        /// This will only work for RGBA8888, RGB888, RGBA4444 and RGB565 textures.\n        ///\n        /// @param restoreTextureDataEnabled\n        ///     Whether or not texture data should be restored on context loss.\n        ///\n        void SetTextureDataRestoreEnabled(bool restoreTextureDataEnabled) noexcept;\n        \n    private:\n        Integer2 m_dimensions;\n        ImageFormat m_imageFormat = ImageFormat::k_RGBA8888;\n        ImageCompression m_imageCompression = ImageCompression::k_none;\n        TextureFilterMode m_filterMode = TextureFilterMode::k_bilinear;\n        TextureWrapMode m_wrapModeS = TextureWrapMode::k_clamp;\n        TextureWrapMode m_wrapModeT = TextureWrapMode::k_clamp;\n        bool m_mipmappingEnabled = false;\n        bool m_restoreTextureDataEnabled = true;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Texture/TextureFilterMode.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_TEXTURE_TEXTUREFILTERMODE_H_\n#define _CHILLISOURCE_RENDERING_TEXTURE_TEXTUREFILTERMODE_H_\n\n#include <ChilliSource/ChilliSource.h>\n\nnamespace ChilliSource\n{\n    /// The filter mode for determining how to sample texels based on nearby texels in\n    /// order to reduce texture aliasing.\n    ///\n    /// * Nearest: Fastest method. Chooses the closest texel\n    /// * Bilinear: Samples from 4 texels and uses weighted average\n    ///\n    enum class TextureFilterMode\n    {\n        k_nearest,\n        k_bilinear\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Texture/TextureProvider.cpp",
    "content": "//\n//  TextureProvider.cpp\n//  ChilliSource\n//  Created by Scott Downie on 15/04/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Texture/TextureProvider.h>\n\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/Image/Image.h>\n#include <ChilliSource/Core/Threading/TaskScheduler.h>\n#include <ChilliSource/Rendering/Texture/Texture.h>\n#include <ChilliSource/Rendering/Texture/TextureDesc.h>\n#include <ChilliSource/Rendering/Texture/TextureResourceOptions.h>\n\nnamespace ChilliSource\n{\n    CS_DEFINE_NAMEDTYPE(TextureProvider);\n    \n    const IResourceOptionsBaseCSPtr TextureProvider::s_defaultOptions(std::make_shared<TextureResourceOptions>());\n    \n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    TextureProviderUPtr TextureProvider::Create()\n    {\n        return TextureProviderUPtr(new TextureProvider());\n    }\n    //-------------------------------------------------------------------------\n    //-------------------------------------------------------------------------\n    bool TextureProvider::IsA(InterfaceIDType in_interfaceId) const\n    {\n        return in_interfaceId == ResourceProvider::InterfaceID || in_interfaceId == TextureProvider::InterfaceID;\n    }\n    //----------------------------------------------------------------------------\n    //----------------------------------------------------------------------------\n    void TextureProvider::PostCreate()\n    {\n        auto resourceProviders = Application::Get()->GetSystems<ResourceProvider>();\n        \n        for(u32 i=0; i<resourceProviders.size(); ++i)\n        {\n            if(resourceProviders[i]->GetResourceType() == Image::InterfaceID)\n            {\n                m_imageProviders.push_back(resourceProviders[i]);\n            }\n        }\n    }\n    //----------------------------------------------------------------------------\n    //----------------------------------------------------------------------------\n    InterfaceIDType TextureProvider::GetResourceType() const\n    {\n        return Texture::InterfaceID;\n    }\n    //----------------------------------------------------------------------------\n    //----------------------------------------------------------------------------\n    bool TextureProvider::CanCreateResourceWithFileExtension(const std::string& in_extension) const\n    {\n        for(u32 i=0; i<m_imageProviders.size(); ++i)\n        {\n            if(m_imageProviders[i]->CanCreateResourceWithFileExtension(in_extension))\n            {\n                return true;\n            }\n        }\n        \n        return false;\n    }\n    //----------------------------------------------------\n    //----------------------------------------------------\n    IResourceOptionsBaseCSPtr TextureProvider::GetDefaultOptions() const\n    {\n        return s_defaultOptions;\n    }\n    //----------------------------------------------------------------------------\n    //----------------------------------------------------------------------------\n    void TextureProvider::CreateResourceFromFile(StorageLocation in_location, const std::string& in_filePath, const IResourceOptionsBaseCSPtr& in_options, const ResourceSPtr& out_resource)\n    {\n        LoadTexture(in_location, in_filePath, in_options, nullptr, out_resource);\n    }\n    //----------------------------------------------------------------------------\n    //----------------------------------------------------------------------------\n    void TextureProvider::CreateResourceFromFileAsync(StorageLocation in_location, const std::string& in_filePath, const IResourceOptionsBaseCSPtr& in_options, const ResourceProvider::AsyncLoadDelegate& in_delegate, const ResourceSPtr& out_resource)\n    {\n        Application::Get()->GetTaskScheduler()->ScheduleTask(TaskType::k_file, [=](const TaskContext&) noexcept\n        {\n            LoadTexture(in_location, in_filePath, in_options, in_delegate, out_resource);\n        });\n    }\n    //----------------------------------------------------------------------------\n    //----------------------------------------------------------------------------\n    void TextureProvider::LoadTexture(StorageLocation in_location, const std::string& in_filePath, const IResourceOptionsBaseCSPtr& in_options, const ResourceProvider::AsyncLoadDelegate& in_delegate, const ResourceSPtr& out_resource)\n    {\n        CS_ASSERT(in_options != nullptr, \"Options for texture load cannot be null\");\n        \n        std::string fileName;\n        std::string fileExtension;\n        StringUtils::SplitBaseFilename(in_filePath, fileName, fileExtension);\n        \n        ResourceProvider* imageProvider = nullptr;\n        for(u32 i=0; i<m_imageProviders.size(); ++i)\n        {\n            if(m_imageProviders[i]->CanCreateResourceWithFileExtension(fileExtension))\n            {\n                imageProvider = m_imageProviders[i];\n                break;\n            }\n        }\n        \n        if(imageProvider == nullptr)\n        {\n            CS_LOG_ERROR(\"Cannot find provider for \" + in_filePath);\n            out_resource->SetLoadState(Resource::LoadState::k_failed);\n            if(in_delegate != nullptr)\n            {\n                Application::Get()->GetTaskScheduler()->ScheduleTask(TaskType::k_mainThread, [=](const TaskContext&) noexcept\n                {\n                    in_delegate(out_resource);\n                });\n            }\n            return;\n        }\n        \n        ResourceSPtr imageResource(Image::Create());\n        imageProvider->CreateResourceFromFile(in_location, in_filePath, nullptr, imageResource);\n        ImageSPtr image(std::static_pointer_cast<Image>(imageResource));\n        \n        if(image->GetLoadState() == Resource::LoadState::k_failed)\n        {\n            CS_LOG_ERROR(\"Failed to load image \" + in_filePath);\n            out_resource->SetLoadState(Resource::LoadState::k_failed);\n            if(in_delegate != nullptr)\n            {\n                Application::Get()->GetTaskScheduler()->ScheduleTask(TaskType::k_mainThread, [=](const TaskContext&) noexcept\n                {\n                    in_delegate(out_resource);\n                });\n            }\n            return;\n        }\n        \n        if(in_delegate == nullptr)\n        {\n            auto texture = static_cast<Texture*>(out_resource.get());\n            auto options = static_cast<const TextureResourceOptions*>(in_options.get());\n            \n            TextureDesc desc(Integer2(image->GetWidth(), image->GetHeight()), image->GetFormat(), image->GetCompression(), false);\n            desc.SetFilterMode(options->GetFilterMode());\n            desc.SetWrapModeS(options->GetWrapModeS());\n            desc.SetWrapModeT(options->GetWrapModeT());\n            desc.SetMipmappingEnabled(options->IsMipMapsEnabled());\n\n            texture->Build(Texture::DataUPtr(image->MoveData()), image->GetDataSize(), desc);\n            texture->SetLoadState(Resource::LoadState::k_loaded);\n        }\n        else\n        {\n            Application::Get()->GetTaskScheduler()->ScheduleTask(TaskType::k_mainThread, [=](const TaskContext&) noexcept\n            {\n                auto texture = static_cast<Texture*>(out_resource.get());\n                auto options = static_cast<const TextureResourceOptions*>(in_options.get());\n\n                TextureDesc desc(Integer2(image->GetWidth(), image->GetHeight()), image->GetFormat(), image->GetCompression(), false);\n                desc.SetFilterMode(options->GetFilterMode());\n                desc.SetWrapModeS(options->GetWrapModeS());\n                desc.SetWrapModeT(options->GetWrapModeT());\n                desc.SetMipmappingEnabled(options->IsMipMapsEnabled());\n\n                texture->Build(Texture::DataUPtr(image->MoveData()), image->GetDataSize(), desc);\n                texture->SetLoadState(Resource::LoadState::k_loaded);\n                in_delegate(out_resource);\n            });\n        }\n    }\n}\n\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Texture/TextureProvider.h",
    "content": "//\n//  TextureProvider.h\n//  ChilliSource\n//  Created by Scott Downie on 15/04/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_TEXTURE_TEXTUREPROVIDER_H_\n#define _CHILLISOURCE_RENDERING_TEXTURE_TEXTUREPROVIDER_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Resource/ResourceProvider.h>\n\nnamespace ChilliSource\n{\n    //-------------------------------------------------------\n    /// Factory loader for creating texture resources\n    /// from file. This loader is responsible for loading the\n    /// image data and building the texture.\n    ///\n    /// @author S Downie\n    //-------------------------------------------------------\n    class TextureProvider final : public ResourceProvider\n    {\n    public:\n        \n        CS_DECLARE_NAMEDTYPE(TextureProvider);\n        \n        //----------------------------------------------------------------------------\n        /// Called when the system is initialised. Retrieves the image providers\n        /// to delegate image loading to\n        ///\n        /// @author S Downie\n        //----------------------------------------------------------------------------\n        void PostCreate();\n        //-------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Interface to compare\n        ///\n        /// @return Whether the object implements the given interface\n        //-------------------------------------------------------------------------\n        bool IsA(InterfaceIDType in_interfaceId) const override;\n        //----------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return The resource type this provider loads\n        //----------------------------------------------------------------------------\n        InterfaceIDType GetResourceType() const override;\n        //----------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Extension to compare\n        ///\n        /// @return Whether the object can create a resource with the given extension\n        //----------------------------------------------------------------------------\n        bool CanCreateResourceWithFileExtension(const std::string& in_extension) const override;\n        //----------------------------------------------------------------------------\n        /// Loads the image and generate the texture via the output resource.\n        /// Check the resource load state for success or failure.\n        ///\n        /// @author S Downie\n        ///\n        /// @param Location to load from\n        /// @param File path\n        /// @param Options to customise the creation\n        /// @param [Out] Resource object\n        //----------------------------------------------------------------------------\n        void CreateResourceFromFile(StorageLocation in_location, const std::string& in_filePath, const IResourceOptionsBaseCSPtr& in_options, const ResourceSPtr& out_resource) override;\n        //----------------------------------------------------------------------------\n        /// Loads the image on a background thread and generate the texture via the output resource.\n        /// Delegate is called on completion. Check the resource load state for success or failure\n        ///\n        /// @author S Downie\n        ///\n        /// @param Location to load from\n        /// @param File path\n        /// @param Options to customise the creation\n        /// @param Completion delegate\n        /// @param [Out] Resource object\n        //----------------------------------------------------------------------------\n        void CreateResourceFromFileAsync(StorageLocation in_location, const std::string& in_filePath, const IResourceOptionsBaseCSPtr& in_options, const ResourceProvider::AsyncLoadDelegate& in_delegate, const ResourceSPtr& out_resource) override;\n        //----------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @retrun Default options for texture loading\n        //----------------------------------------------------\n        IResourceOptionsBaseCSPtr GetDefaultOptions() const override;\n        \n    private:\n        friend class Application;\n        //-------------------------------------------------------\n        /// Factory method\n        ///\n        /// @author S Downie\n        ///\n        /// @return New provider with ownership transferred\n        //-------------------------------------------------------\n        static TextureProviderUPtr Create();\n        //----------------------------------------------------------------------------\n        /// Private constructor to force use of factory method\n        ///\n        /// @author S Downie\n        //----------------------------------------------------------------------------\n        TextureProvider() = default;\n        //----------------------------------------------------------------------------\n        /// Does the heavy lifting for the 2 create methods. The building of the texture\n        /// is always done on the main thread\n        ///\n        /// @author S Downie\n        ///\n        /// @param Location to load from\n        /// @param File path\n        /// @param Options to customise the creation\n        /// @param Completion delegate\n        /// @param [Out] Resource object\n        //----------------------------------------------------------------------------\n        void LoadTexture(StorageLocation in_location, const std::string& in_filePath, const IResourceOptionsBaseCSPtr& in_options, const ResourceProvider::AsyncLoadDelegate& in_delegate, const ResourceSPtr& out_resource);\n        \n    private:\n        \n        std::vector<ResourceProvider*> m_imageProviders;\n        static const IResourceOptionsBaseCSPtr s_defaultOptions;\n    };\n}\n\n#endif\n\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Texture/TextureResourceOptions.cpp",
    "content": "//\n//  TextureResourceOptions.cpp\n//  ChilliSource\n//  Created by Scott Downie on 16/05/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Texture/TextureResourceOptions.h>\n\n#include <ChilliSource/Core/Cryptographic/HashCRC32.h>\n\nnamespace ChilliSource\n{\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    TextureResourceOptions::TextureResourceOptions(bool in_mipmaps, TextureFilterMode in_filter, TextureWrapMode in_wrapS, TextureWrapMode in_wrapT)\n    {\n        m_options.m_hasMipMaps = in_mipmaps;\n        m_options.m_filterMode = in_filter;\n        m_options.m_wrapModeS = in_wrapS;\n        m_options.m_wrapModeT = in_wrapT;\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    u32 TextureResourceOptions::GenerateHash() const\n    {\n        return HashCRC32::GenerateHashCode((const s8*)&m_options, sizeof(Options));\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    bool TextureResourceOptions::IsMipMapsEnabled() const\n    {\n        return m_options.m_hasMipMaps;\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    TextureWrapMode TextureResourceOptions::GetWrapModeS() const\n    {\n        return m_options.m_wrapModeS;\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    TextureWrapMode TextureResourceOptions::GetWrapModeT() const\n    {\n        return m_options.m_wrapModeT;\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    TextureFilterMode TextureResourceOptions::GetFilterMode() const\n    {\n        return m_options.m_filterMode;\n    }\n}\n\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Texture/TextureResourceOptions.h",
    "content": "//\n//  TextureResourceOptions.h\n//  ChilliSource\n//  Created by Scott Downie on 16/05/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n\n#ifndef _CHILLISOURCE_RENDERING_TEXTURE_TEXTURERESOURCEOPTIONS_H_\n#define _CHILLISOURCE_RENDERING_TEXTURE_TEXTURERESOURCEOPTIONS_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Resource/IResourceOptions.h>\n#include <ChilliSource/Rendering/Texture/Texture.h>\n#include <ChilliSource/Rendering/Texture/TextureFilterMode.h>\n#include <ChilliSource/Rendering/Texture/TextureWrapMode.h>\n\nnamespace ChilliSource\n{\n    //-------------------------------------------------------\n    /// Custom options for loading a texture\n    ///\n    /// @author S Downie\n    //-------------------------------------------------------\n    class TextureResourceOptions final : public IResourceOptions<Texture>\n    {\n    public:\n        //-------------------------------------------------------\n        /// Constructor\n        ///\n        /// @author S Downie\n        //-------------------------------------------------------\n        TextureResourceOptions() = default;\n        //-------------------------------------------------------\n        /// Constructor\n        ///\n        /// @author S Downie\n        ///\n        /// @param MipMaps enabled\n        /// @param Filter mode\n        /// @param Wrap mode S\n        /// @param Wrap mode T\n        /// @param Whether or not the texture data should be\n        /// restored after a context loss. This involves maintaining\n        /// a copy of the texture data in memory which is costly\n        /// so this should be disabled for any textures that can\n        /// easily be recreated, i.e any texture that is rendered\n        /// into every frame. This has no effect on textures that\n        /// are loaded from file as they are always restored from\n        /// disk. This will only work for RGBA8888, RGB888, RGBA4444\n        /// and RGB565 textures.\n        //-------------------------------------------------------\n        TextureResourceOptions(bool in_mipmaps, TextureFilterMode in_filter, TextureWrapMode in_wrapS, TextureWrapMode in_wrapT);\n        //-------------------------------------------------------\n        /// Generate a unique hash based on the\n        /// currently set options\n        ///\n        /// @author S Downie\n        ///\n        /// @return Hash of the options contents\n        //-------------------------------------------------------\n        u32 GenerateHash() const override;\n        //-------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Whether the texture should be created with\n        /// mip-maps\n        //-------------------------------------------------------\n        bool IsMipMapsEnabled() const;\n        //-------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Wrap S direction mode to create texture with\n        //-------------------------------------------------------\n        TextureWrapMode GetWrapModeS() const;\n        //-------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Wrap T direction mode to create texture with\n        //-------------------------------------------------------\n        TextureWrapMode GetWrapModeT() const;\n        //-------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Filter mode to create texture with\n        //-------------------------------------------------------\n        TextureFilterMode GetFilterMode() const;\n        \n    private:\n        \n        //-------------------------------------------------------\n        /// The options for loading textures. These are held\n        /// in a struct to more easily allow hashing of the data\n        ///\n        /// @author S Downie\n        //-------------------------------------------------------\n        struct Options\n        {\n            TextureWrapMode m_wrapModeS = TextureWrapMode::k_clamp;\n            TextureWrapMode m_wrapModeT = TextureWrapMode::k_clamp;\n            TextureFilterMode m_filterMode = TextureFilterMode::k_bilinear;\n            bool m_hasMipMaps = false;\n        };\n        \n        Options m_options;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Texture/TextureType.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_TEXTURE_TEXTURETYPE_H_\n#define _CHILLISOURCE_RENDERING_TEXTURE_TEXTURETYPE_H_\n\n#include <ChilliSource/ChilliSource.h>\n\nnamespace ChilliSource\n{\n    ///\n    /// * Texture: Standard 2D texture\n    /// * Cubemap: Created from 6 2D textures\n    ///\n    enum class TextureType\n    {\n        k_texture,\n        k_cubemap\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Texture/TextureWrapMode.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_TEXTURE_TEXTUREWRAPMODE_H_\n#define _CHILLISOURCE_RENDERING_TEXTURE_TEXTUREWRAPMODE_H_\n\n#include <ChilliSource/ChilliSource.h>\n\nnamespace ChilliSource\n{\n    /// The wrap mode for determining how a texel should be sampled if the texture\n    /// coordinates exceed the bounds\n    ///\n    /// * Clamp: Clamps the texcoord between 0 and 1\n    /// * Wrap: Tex coord > 1 will wrap to be (x - 1) and vice-versa\n    ///\n    enum class TextureWrapMode\n    {\n        k_clamp,\n        k_repeat\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Texture/UVs.cpp",
    "content": "//\n//  UVs.cpp\n//  ChilliSource\n//  Created by Scott Downie on 13/06/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Rendering/Texture/UVs.h>\n\nnamespace ChilliSource\n{\n    //----------------------------------------------------------\n    //----------------------------------------------------------\n    UVs::UVs(f32 in_u, f32 in_v, f32 in_s, f32 in_t)\n    : m_u(in_u), m_v(in_v), m_s(in_s), m_t(in_t)\n    {\n        \n    }\n    //----------------------------------------------------------\n    //----------------------------------------------------------\n    UVs UVs::FlipVertically(const UVs& in_uvs)\n    {\n        UVs result = in_uvs;\n        \n        result.m_v += result.m_t;\n        result.m_t *= -1;\n        \n        return result;\n    }\n    //----------------------------------------------------------\n    //----------------------------------------------------------\n    UVs UVs::FlipHorizontally(const UVs& in_uvs)\n    {\n        UVs result = in_uvs;\n        \n        result.m_u += result.m_s;\n        result.m_s *= -1;\n        \n        return result;\n    }\n    //----------------------------------------------------------\n    //----------------------------------------------------------\n    UVs UVs::FlipDiagonally(const UVs& in_uvs)\n    {\n        UVs result = in_uvs;\n        \n        result.m_u += result.m_s;\n        result.m_s *= -1;\n        \n        result.m_v += result.m_t;\n        result.m_t *= -1;\n        \n        return result;\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Texture/UVs.h",
    "content": "//\n//  UVs.h\n//  ChilliSource\n//  Created by Scott Downie on 13/06/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_RENDERING_TEXTURE_UVS_H_\n#define _CHILLISOURCE_RENDERING_TEXTURE_UVS_H_\n\n#include <ChilliSource/ChilliSource.h>\n\nnamespace ChilliSource\n{\n    //--------------------------------------------------------------\n    /// Holds the description of UV coordinates (normalised)\n    /// U-V (Top-Left) S-T (Width-Height)\n    ///\n    /// @author S Downie\n    //--------------------------------------------------------------\n    class UVs\n    {\n    public:\n        //----------------------------------------------------------\n        /// Constructor\n        ///\n        /// @author S Downie\n        //----------------------------------------------------------\n        UVs() = default;\n        //----------------------------------------------------------\n        /// Constructor\n        ///\n        /// @author S Downie\n        ///\n        /// @param U (normalised 0.0 - 1.0)\n        /// @param V (normalised 0.0 - 1.0)\n        /// @param S (normalised 0.0 - 1.0)\n        /// @param T (normalised 0.0 - 1.0)\n        //----------------------------------------------------------\n        UVs(f32 in_u, f32 in_v, f32 in_s, f32 in_t);\n        //----------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param UVs\n        ///\n        /// @return UVs flipped around the horizontal axis\n        //----------------------------------------------------------\n        static UVs FlipVertically(const UVs& in_uvs);\n        //----------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param UVs\n        ///\n        /// @return UVs flipped around the vertical axis\n        //----------------------------------------------------------\n        static UVs FlipHorizontally(const UVs& in_uvs);\n        //----------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param UVs\n        ///\n        /// @return UVs flipped around the vertical axis and the\n        /// horizontal axis\n        //----------------------------------------------------------\n        static UVs FlipDiagonally(const UVs& in_uvs);\n        \n    public:\n        \n        f32 m_u = 0.0f;\n        f32 m_v = 0.0f;\n        f32 m_s = 1.0f;\n        f32 m_t = 1.0f;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Rendering/Texture.h",
    "content": "//\n//  Texture.h\n//  ChilliSource\n//  Created by Ian Copland on 07/07/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n\n#ifndef _CHILLISOURCE_RENDERING_TEXTURE_H_\n#define _CHILLISOURCE_RENDERING_TEXTURE_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Rendering/Texture/Cubemap.h>\n#include <ChilliSource/Rendering/Texture/CubemapProvider.h>\n#include <ChilliSource/Rendering/Texture/CubemapResourceOptions.h>\n#include <ChilliSource/Rendering/Texture/RenderTexture.h>\n#include <ChilliSource/Rendering/Texture/RenderTextureManager.h>\n#include <ChilliSource/Rendering/Texture/Texture.h>\n#include <ChilliSource/Rendering/Texture/TextureAtlas.h>\n#include <ChilliSource/Rendering/Texture/TextureAtlasProvider.h>\n#include <ChilliSource/Rendering/Texture/TextureDesc.h>\n#include <ChilliSource/Rendering/Texture/TextureFilterMode.h>\n#include <ChilliSource/Rendering/Texture/TextureProvider.h>\n#include <ChilliSource/Rendering/Texture/TextureResourceOptions.h>\n#include <ChilliSource/Rendering/Texture/TextureType.h>\n#include <ChilliSource/Rendering/Texture/TextureWrapMode.h>\n#include <ChilliSource/Rendering/Texture/UVs.h>\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Social/Communications/EmailComposer.cpp",
    "content": "//\n//  EmailComposer.cpp\n//  ChilliSource\n//  Created by Ian Copland on 06/03/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Social/Communications/EmailComposer.h>\n\n#ifdef CS_TARGETPLATFORM_IOS\n#import <CSBackend/Platform/iOS/Social/Communications/EmailComposer.h>\n#endif\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n#include <CSBackend/Platform/Android/Main/JNI/Social/Communications/EmailComposer.h>\n#endif\n\nnamespace ChilliSource\n{\n    CS_DEFINE_NAMEDTYPE(EmailComposer);\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    EmailComposerUPtr EmailComposer::Create()\n    {\n#ifdef CS_TARGETPLATFORM_IOS\n        if (CSBackend::iOS::EmailComposer::IsSupportedByDevice() == true)\n        {\n            return EmailComposerUPtr(new CSBackend::iOS::EmailComposer());\n        }\n        else\n        {\n            return nullptr;\n        }\n#elif defined CS_TARGETPLATFORM_ANDROID\n        return EmailComposerUPtr(new CSBackend::Android::EmailComposer());\n#else\n        return nullptr;\n#endif\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Social/Communications/EmailComposer.h",
    "content": "//\n//  EmailComposer.h\n//  ChilliSource\n//  Created by Stuart McGaw on 08/06/2011.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2011 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_SOCIAL_COMMUNICATIONS_EMAILCOMPOSER_H_\n#define _CHILLISOURCE_SOCIAL_COMMUNICATIONS_EMAILCOMPOSER_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Event/Event.h>\n#include <ChilliSource/Core/System/StateSystem.h>\n\n#include <functional>\n#include <vector>\n\nnamespace ChilliSource\n{\n    //---------------------------------------------------------------\n    /// A state system for presenting the user with an email\n    /// composition view.\n    ///\n    /// @author S McGaw\n    //---------------------------------------------------------------\n    class EmailComposer : public StateSystem\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(EmailComposer);\n        //-------------------------------------------------------\n        /// An enum describing the result of the email intent.\n        ///\n        /// @author S McGaw\n        //-------------------------------------------------------\n        enum class SendResult\n        {\n            k_succeed,\n            k_failed,\n            k_cancelled\n        };\n        //-------------------------------------------------------\n        /// Describes the format of the email contents.\n        ///\n        /// @author Ian Copland\n        //-------------------------------------------------------\n        enum class ContentFormat\n        {\n            k_plainText,\n            k_html\n        };\n        //-------------------------------------------------------\n        /// A container for information describing a single\n        /// attachment file.\n        ///\n        /// @author Ian Copland\n        //-------------------------------------------------------\n        struct Attachment\n        {\n            StorageLocation m_storageLocation;\n            std::string m_filename;\n            std::string m_mimeType;\n        };\n        //-------------------------------------------------------\n        /// A delegate that is called when the email view is\n        /// dismissed, returning the result.\n        ///\n        /// @author S McGaw\n        ///\n        /// @param The result of the email composition.\n        //-------------------------------------------------------\n        typedef std::function<void(SendResult)> SendResultDelegate;\n        //-------------------------------------------------------\n        /// Displays the email activity with the given recipients,\n        /// subject and contents.\n        ///\n        /// @author S Downie\n        ///\n        /// @param A list of recipients (UTF8).\n        /// @param The subject (UTF8).\n        /// @param The body of the email (UTF8).\n        /// @param The format of the body of the email.\n        /// @param The callback describing the result of the email.\n        //-------------------------------------------------------\n        virtual void Present(const std::vector<std::string>& in_recipientAddresses, const std::string& in_subject, const std::string& in_contents, ContentFormat in_contentFormat,\n                             const SendResultDelegate& in_callback) = 0;\n        //-------------------------------------------------------\n        /// Displays the email activity with the given recipients,\n        /// subject and contents, and adds a list of attachments\n        /// to the email.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param A list of recipients (UTF8).\n        /// @param The subject (UTF8).\n        /// @param The body of the email (UTF8).\n        /// @param The format of the body of the email.\n        /// @param The attachment.\n        /// @param The callback describing the result of the email.\n        //-------------------------------------------------------\n        virtual void PresentWithAttachment(const std::vector<std::string>& in_recipientAddresses, const std::string& in_subject, const std::string& in_contents, ContentFormat in_contentFormat,\n                                           const Attachment& in_attachment, const SendResultDelegate& in_callback) = 0;\n        //-------------------------------------------------------\n        /// Determines whether or not the composer is presented.\n        ///\n        /// @author Jordan Brown\n        //-------------------------------------------------------\n        virtual bool IsPresented() = 0;\n        //-------------------------------------------------------\n        /// Destructor\n        //-------------------------------------------------------\n        virtual ~EmailComposer() {};\n    protected:\n        friend class State;\n        //-------------------------------------------------------\n        /// Creates a new instance of the email composition\n        /// activity.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @return the new activity instance.\n        //-------------------------------------------------------\n        static EmailComposerUPtr Create();\n        //-------------------------------------------------------\n        /// Protected constructor to force use of the factory\n        /// method.\n        ///\n        /// @author Ian Copland.\n        //-------------------------------------------------------\n        EmailComposer() = default;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Social/Communications.h",
    "content": "//\n//  Communications.h\n//  ChilliSource\n//  Created by Ian Copland on 07/07/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n\n#ifndef _CHILLISOURCE_SOCIAL_COMMUNICATIONS_H_\n#define _CHILLISOURCE_SOCIAL_COMMUNICATIONS_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Social/Communications/EmailComposer.h>\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Social/ForwardDeclarations.h",
    "content": "//\n//  ForwardDeclarations.h\n//  ChilliSource\n//  Created by Stuart McGaw on 07/06/2011.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2011 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_SOCIAL_FORWARDDECLARATIONS_H_\n#define _CHILLISOURCE_SOCIAL_FORWARDDECLARATIONS_H_\n\n#include <ChilliSource/Core/Base/StandardMacros.h>\n\n#include <memory>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------\n    /// Communications\n    //------------------------------------------------------\n    CS_FORWARDDECLARE_CLASS(EmailComposer);\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/UI/Base/Canvas.cpp",
    "content": "//\n//  Canvas.cpp\n//  ChilliSource\n//  Created by Scott Downie on 21/04/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/UI/Base/Canvas.h>\n\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/Base/Screen.h>\n#include <ChilliSource/Core/Delegate/MakeDelegate.h>\n#include <ChilliSource/Core/Event/IConnectableEvent.h>\n#include <ChilliSource/Input/Pointer/PointerSystem.h>\n#include <ChilliSource/UI/Base/WidgetFactory.h>\n\nnamespace ChilliSource\n{\n    CS_DEFINE_NAMEDTYPE(Canvas);\n    //----------------------------------------------------\n    //----------------------------------------------------\n    CanvasUPtr Canvas::Create()\n    {\n        return CanvasUPtr(new Canvas());\n    }\n    //----------------------------------------------------\n    //----------------------------------------------------\n    bool Canvas::IsA(InterfaceIDType in_interfaceId) const\n    {\n        return in_interfaceId == Canvas::InterfaceID;\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    void Canvas::OnInit()\n    {\n        m_screen = Application::Get()->GetSystem<Screen>();\n        CS_ASSERT(m_screen != nullptr, \"Canvas must have access to screen\");\n        \n        WidgetFactory* widgetFactory = Application::Get()->GetWidgetFactory();\n        \n        m_canvas = widgetFactory->CreateWidget();\n        m_canvas->SetName(\"Canvas\");\n        m_canvas->SetAbsoluteSize(GetSize());\n        m_canvas->SetCanvas(m_canvas.get());\n        m_canvas->SetAbsolutePosition(GetSize() * 0.5f);\n        m_canvas->SetInputEnabled(true);\n        m_canvas->SetInputConsumeEnabled(false);\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void Canvas::OnPointerAdded(const Pointer& in_pointer, f64 in_timestamp)\n    {\n        m_canvas->OnPointerAdded(in_pointer, in_timestamp);\n    }\n    //------------------------------------------------------------------------------\n    /// UI can filter input events to prevent them from being forwarded to the\n    /// external app.\n    //------------------------------------------------------------------------------\n    void Canvas::OnPointerDown(const Pointer& in_pointer, f64 in_timestamp, Pointer::InputType in_inputType, InputFilter& in_filter)\n    {\n        m_canvas->OnPointerDown(in_pointer, in_timestamp, in_inputType, in_filter);\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void Canvas::OnPointerMoved(const Pointer& in_pointer, f64 in_timestamp)\n    {\n        m_canvas->OnPointerMoved(in_pointer, in_timestamp);\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void Canvas::OnPointerUp(const Pointer& in_pointer, f64 in_timestamp, Pointer::InputType in_inputType)\n    {\n        m_canvas->OnPointerUp(in_pointer, in_timestamp, in_inputType);\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void Canvas::OnPointerRemoved(const Pointer& in_pointer, f64 in_timestamp)\n    {\n        m_canvas->OnPointerRemoved(in_pointer, in_timestamp);\n    }\n    //--------------------------------------------------------\n    //--------------------------------------------------------\n    void Canvas::OnScreenResolutionChanged(const Vector2& in_resolution)\n    {\n        m_canvas->SetAbsoluteSize(in_resolution);\n        m_canvas->SetAbsolutePosition(in_resolution * 0.5f);\n    }\n    //----------------------------------------------------\n    //----------------------------------------------------\n    const Vector2& Canvas::GetSize() const\n    {\n        return m_screen->GetResolution();\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    void Canvas::OnResume()\n    {\n        m_screenResizedConnection = m_screen->GetResolutionChangedEvent().OpenConnection(MakeDelegate(this, &Canvas::OnScreenResolutionChanged));\n        \n        auto pointerSystem = Application::Get()->GetSystem<PointerSystem>();\n        m_pointerAddedConnection = pointerSystem->GetPointerAddedEvent().OpenConnection(MakeDelegate(this, &Canvas::OnPointerAdded));\n        m_pointerDownConnection = pointerSystem->GetPointerDownEventInternal().OpenConnection(MakeDelegate(this, &Canvas::OnPointerDown));\n        m_pointerMovedConnection = pointerSystem->GetPointerMovedEvent().OpenConnection(MakeDelegate(this, &Canvas::OnPointerMoved));\n        m_pointerUpConnection = pointerSystem->GetPointerUpEvent().OpenConnection(MakeDelegate(this, &Canvas::OnPointerUp));\n        m_pointerRemovedConnection = pointerSystem->GetPointerRemovedEvent().OpenConnection(MakeDelegate(this, &Canvas::OnPointerRemoved));\n        \n        m_canvas->OnResume();\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    void Canvas::OnForeground()\n    {\n        m_canvas->OnForeground();\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    void Canvas::OnUpdate(f32 in_timeSinceLastUpdate)\n    {\n        m_canvas->OnUpdate(in_timeSinceLastUpdate);\n    }\n    //----------------------------------------------------\n    //----------------------------------------------------\n    void Canvas::Draw(CanvasRenderer* in_renderer) const\n    {\n        m_canvas->OnDraw(in_renderer);\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    void Canvas::OnBackground()\n    {\n        m_canvas->OnBackground();\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    void Canvas::OnSuspend()\n    {\n        m_canvas->OnSuspend();\n        \n        m_screenResizedConnection.reset();\n        \n        m_pointerAddedConnection.reset();\n        m_pointerDownConnection.reset();\n        m_pointerMovedConnection.reset();\n        m_pointerUpConnection.reset();\n        m_pointerRemovedConnection.reset();\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    void Canvas::AddWidget(const WidgetSPtr& in_widget)\n    {\n        m_canvas->AddWidget(in_widget);\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    void Canvas::RemoveWidget(Widget* in_widget)\n    {\n        m_canvas->RemoveWidget(in_widget);\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    WidgetSPtr Canvas::GetWidget(const std::string& in_name)\n    {\n        return m_canvas->GetWidget(in_name);\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    WidgetCSPtr Canvas::GetWidget(const std::string& in_name) const\n    {\n        return m_canvas->GetWidget(in_name);\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    WidgetSPtr Canvas::GetWidgetRecursive(const std::string& in_name)\n    {\n        return m_canvas->GetWidgetRecursive(in_name);\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    WidgetCSPtr Canvas::GetWidgetRecursive(const std::string& in_name) const\n    {\n        return m_canvas->GetWidgetRecursive(in_name);\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    void Canvas::OnDestroy()\n    {\n        m_canvas.reset();\n        m_screenResizedConnection.reset();\n        m_pointerRemovedConnection.reset();\n        m_pointerDownConnection.reset();\n        m_pointerMovedConnection.reset();\n        m_pointerUpConnection.reset();\n        m_pointerAddedConnection.reset();\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/UI/Base/Canvas.h",
    "content": "//\n//  Canvas.h\n//  ChilliSource\n//  Created by Scott Downie on 21/04/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_UI_BASE_CANVAS_H_\n#define _CHILLISOURCE_UI_BASE_CANVAS_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Event/EventConnection.h>\n#include <ChilliSource/Core/System/StateSystem.h>\n#include <ChilliSource/UI/Base/Widget.h>\n\nnamespace ChilliSource\n{\n    //-----------------------------------------------------------\n    /// A state system that holds and renders the UI\n    /// scene.\n    ///\n    /// @author S Downie\n    //-----------------------------------------------------------\n    class Canvas final : public StateSystem\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(Canvas);\n        \n        //----------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Interface ID\n        ///\n        /// @return Whether the object is of the given type\n        //----------------------------------------------------\n        bool IsA(InterfaceIDType in_interfaceId) const override;\n        //----------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Size of the canvas in pixels\n        //----------------------------------------------------\n        const Vector2& GetSize() const;\n        //----------------------------------------------------\n        /// Traverse the hierarchy and render each widget\n        /// using the canvas renderer\n        ///\n        /// @author S Downie\n        ///\n        /// @param Renderer\n        //----------------------------------------------------\n        void Draw(CanvasRenderer* in_renderer) const;\n        //----------------------------------------------------\n        /// Adds a widget to the canvas. The widget\n        /// will be rendered and updated. Any relative coordinates\n        /// will now be in relation to this widget.\n        ///\n        /// NOTE: Will assert if the widget already has a parent\n        ///\n        /// @author S Downie\n        ///\n        /// @param Widget\n        //----------------------------------------------------\n        void AddWidget(const WidgetSPtr& in_widget);\n        //----------------------------------------------------\n        /// Remove widget from the canvas.\n        ///\n        /// NOTE: Will assert if the widget is not on this canvas\n        ///\n        /// @author S Downie\n        ///\n        /// @param Widget\n        //----------------------------------------------------\n        void RemoveWidget(Widget* in_widget);\n        //----------------------------------------------------\n        /// Searches the immediate children for a widget with\n        /// the given name and returns it.\n        /// If the child cannot be found this will return null.\n        /// If there are multiple children with the name,\n        /// the first with be returned.\n        ///\n        /// @author Nicolas Tanda\n        ///\n        /// @return The child with the given name or null if one doesn't exist.\n        //----------------------------------------------------\n        WidgetSPtr GetWidget(const std::string& in_name);\n        //----------------------------------------------------\n        /// Searches the immediate children for a widget with\n        /// the given name and returns a constant version it.\n        /// If the child cannot be found this will return null.\n        /// If there are multiple children with the name,\n        /// the first with be returned.\n        ///\n        /// @author Nicolas Tanda\n        ///\n        /// @return A constant version of the child with the\n        /// given name or null if one doesn't exist.\n        //----------------------------------------------------\n        WidgetCSPtr GetWidget(const std::string& in_name) const;\n        //----------------------------------------------------\n        /// Recurses through the widget hierarchy seaching for\n        /// a widget with the given name and returns it.\n        /// If the child cannot be found this will return null.\n        /// If there are multiple children with the same name,\n        /// the first found will be returned.\n        /// The hierarchy will be navigated breadth first.\n        ///\n        /// @author Nicolas Tanda\n        ///\n        /// @return The child with the given name or null if one doesn't exist.\n        //----------------------------------------------------\n        WidgetSPtr GetWidgetRecursive(const std::string& in_name);\n        //----------------------------------------------------\n        /// Recurses through the widget hierarchy seaching for\n        /// a widget with the given name and returns a constant\n        /// version of it. If the child cannot be found this will\n        /// return null.\n        /// If there are multiple children with the same name\n        /// the first found will be returned.\n        /// The hierarchy will be navigated breadth first.\n        ///\n        /// @author Nicolas Tanda\n        ///\n        /// @return A constant version of the child with the\n        /// given name or null if one doesn't exist.\n        //----------------------------------------------------\n        WidgetCSPtr GetWidgetRecursive(const std::string& in_name) const;\n        \n    private:\n        friend class State;\n        \n        //----------------------------------------------------\n        /// Creates a new instance of this system.\n        ///\n        /// @author S Downie\n        ///\n        /// @return The new instance.\n        //----------------------------------------------------\n        static CanvasUPtr Create();\n        //-------------------------------------------------------\n        /// Private constructor to force use of factory method\n        ///\n        /// @author S Downie\n        //-------------------------------------------------------\n        Canvas() = default;\n        //-------------------------------------------------------\n        /// Called when the system is created to initialise the\n        /// canvas widget\n        ///\n        /// @author S Downie\n        //-------------------------------------------------------\n        void OnInit() override;\n        //-------------------------------------------------------\n        /// Called when the owning state is resumed.\n        ///\n        /// @author Ian Copland\n        //-------------------------------------------------------\n        void OnResume() override;\n        //-------------------------------------------------------\n        /// Called when the owning state is foregrounded.\n        ///\n        /// @author Ian Copland\n        //-------------------------------------------------------\n        void OnForeground() override;\n        //-------------------------------------------------------\n        /// Called every frame that the canvas is active\n        ///\n        /// @author S Downie\n        ///\n        /// @param Time in seconds since last update\n        //-------------------------------------------------------\n        void OnUpdate(f32 in_timeSinceLastUpdate) override;\n        //-------------------------------------------------------\n        /// Called when the owning state is backgrounded.\n        ///\n        /// @author Ian Copland\n        //-------------------------------------------------------\n        void OnBackground() override;\n        //-------------------------------------------------------\n        /// Called when the owning state is suspended.\n        ///\n        /// @author Ian Copland\n        //-------------------------------------------------------\n        void OnSuspend() override;\n        //-------------------------------------------------------\n        /// Called when the system is destroyed to destroy the\n        /// canvas widget\n        ///\n        /// @author S Downie\n        //-------------------------------------------------------\n        void OnDestroy() override;\n        //-----------------------------------------------------------\n        /// Triggered if the screen resizes\n        ///\n        /// @param The new resolution\n        //-----------------------------------------------------------\n        void OnScreenResolutionChanged(const Vector2& in_resolution);\n        //------------------------------------------------------------------------------\n        /// Called when a new pointer is added to the canvas.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param in_pointer - The pointer.\n        /// @param in_timestamp - The timestamp.\n        //------------------------------------------------------------------------------\n        void OnPointerAdded(const Pointer& in_pointer, f64 in_timestamp);\n        //------------------------------------------------------------------------------\n        /// Called when the canvas receives cursor/touch input\n        ///\n        /// @author S Downie\n        ///\n        /// @param in_pointer - The pointer\n        /// @param in_timestamp - The timestamp.\n        /// @param in_inputType - The press type.\n        /// @param in_filter - Filter object to check if the event has been filtered or to filter it\n        //------------------------------------------------------------------------------\n        void OnPointerDown(const Pointer& in_pointer, f64 in_timestamp, Pointer::InputType in_inputType, InputFilter& in_filter);\n        //------------------------------------------------------------------------------\n        /// Called when the canvas receives cursor/touch move input\n        ///\n        /// @author S Downie\n        ///\n        /// @param in_pointer - The pointer\n        /// @param in_timestamp - The timestamp.\n        //------------------------------------------------------------------------------\n        void OnPointerMoved(const Pointer& in_pointer, f64 in_timestamp);\n        //------------------------------------------------------------------------------\n        /// Called when the canvas receiving cursor/touch release input\n        ///\n        /// @author S Downie\n        ///\n        /// @param in_pointer - The pointer\n        /// @param in_timestamp - The timestamp.\n        /// @param in_inputType - The press type.\n        //------------------------------------------------------------------------------\n        void OnPointerUp(const Pointer& in_pointer, f64 in_timestamp, Pointer::InputType in_inputType);\n        //------------------------------------------------------------------------------\n        /// Called when an existing pointer is removed to the canvas.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param in_pointer - The pointer.\n        /// @param in_timestamp - The timestamp.\n        //------------------------------------------------------------------------------\n        void OnPointerRemoved(const Pointer& in_pointer, f64 in_timestamp);\n        \n    private:\n        \n        WidgetUPtr m_canvas;\n        EventConnectionUPtr m_screenResizedConnection;\n        EventConnectionUPtr m_pointerAddedConnection;\n        EventConnectionUPtr m_pointerDownConnection;\n        EventConnectionUPtr m_pointerMovedConnection;\n        EventConnectionUPtr m_pointerUpConnection;\n        EventConnectionUPtr m_pointerRemovedConnection;\n        \n        Screen* m_screen;\n\t};\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/UI/Base/CursorSystem.cpp",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2017 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/UI/Base/CursorSystem.h>\n\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/Base/AppConfig.h>\n#include <ChilliSource/Core/Resource/ResourcePool.h>\n#include <ChilliSource/Core/Delegate/MakeDelegate.h>\n#include <ChilliSource/Core/Event/IConnectableEvent.h>\n#include <ChilliSource/Input/Pointer/PointerSystem.h>\n#include <ChilliSource/UI/Base/WidgetFactory.h>\n#include <ChilliSource/UI/Base/WidgetTemplate.h>\n\nnamespace ChilliSource\n{\n    CS_DEFINE_NAMEDTYPE(CursorSystem);\n    \n    //------------------------------------------------------------------------------\n    CursorSystemUPtr CursorSystem::Create() noexcept\n    {\n        return CursorSystemUPtr(new CursorSystem());\n    }\n    \n    //------------------------------------------------------------------------------\n    bool CursorSystem::IsA(InterfaceIDType interfaceId) const noexcept\n    {\n        return interfaceId == CursorSystem::InterfaceID;\n    }\n    \n    //------------------------------------------------------------------------------\n    void CursorSystem::ShowCursor()\n    {\n        m_enabled = true;\n        m_cursor->SetVisible(m_pointerSystem->GetNumPointers() > 0);\n    }\n    \n    //------------------------------------------------------------------------------\n    void CursorSystem::HideCursor()\n    {\n        m_enabled = false;\n        m_cursor->SetVisible(false);\n    }\n    \n    //------------------------------------------------------------------------------\n    void CursorSystem::OnInit() noexcept\n    {\n        auto appConfig = Application::Get()->GetAppConfig();\n        m_enabled = appConfig->GetCursorType() == CursorType::k_nonSystem;\n        \n        WidgetFactory* widgetFactory = Application::Get()->GetWidgetFactory();\n        \n        auto resourcePool = CS::Application::Get()->GetResourcePool();\n        auto pointerTemplate = resourcePool->LoadResource<CS::WidgetTemplate>(appConfig->GetDefaultCursorUILocation(), appConfig->GetDefaultCursorUIPath());\n        m_cursor = widgetFactory->Create(pointerTemplate);\n        m_cursor->SetCanvas(m_cursor.get());\n        \n        m_pointerSystem = Application::Get()->GetSystem<PointerSystem>();\n        \n        Pointer pointer;\n        bool pointerExists = m_pointerSystem->TryGetPointerWithIndex(0, pointer);\n        m_cursor->SetAbsolutePosition(pointer.GetPosition());\n        m_cursor->SetVisible(m_enabled && pointerExists);\n    }\n    \n    //------------------------------------------------------------------------------\n    void CursorSystem::OnPointerAdded(const Pointer& pointer, f64 timestamp) noexcept\n    {\n        m_cursor->OnPointerAdded(pointer, timestamp);\n        m_cursor->SetVisible(m_enabled);\n    }\n    \n    //------------------------------------------------------------------------------\n    void CursorSystem::OnPointerMoved(const Pointer& pointer, f64 timestamp) noexcept\n    {\n        m_cursor->OnPointerMoved(pointer, timestamp);\n        m_cursor->SetAbsolutePosition(pointer.GetPosition());\n    }\n    \n    //------------------------------------------------------------------------------\n    void CursorSystem::OnPointerRemoved(const Pointer& pointer, f64 timestamp) noexcept\n    {\n        m_cursor->OnPointerRemoved(pointer, timestamp);\n        \n        if(m_pointerSystem->GetNumPointers() == 0)\n        {\n            m_cursor->SetVisible(false);\n        }\n    }\n\n    //------------------------------------------------------------------------------\n    void CursorSystem::OnResume() noexcept\n    {\n        m_pointerAddedConnection = m_pointerSystem->GetPointerAddedEvent().OpenConnection(MakeDelegate(this, &CursorSystem::OnPointerAdded));\n        m_pointerMovedConnection = m_pointerSystem->GetPointerMovedEvent().OpenConnection(MakeDelegate(this, &CursorSystem::OnPointerMoved));\n        m_pointerRemovedConnection = m_pointerSystem->GetPointerRemovedEvent().OpenConnection(MakeDelegate(this, &CursorSystem::OnPointerRemoved));\n        \n        m_cursor->OnResume();\n    }\n    \n    //------------------------------------------------------------------------------\n    void CursorSystem::OnForeground() noexcept\n    {\n        m_cursor->OnForeground();\n    }\n    \n    //------------------------------------------------------------------------------\n    void CursorSystem::OnUpdate(f32 timeSinceLastUpdate) noexcept\n    {\n        m_cursor->OnUpdate(timeSinceLastUpdate);\n    }\n    \n    //------------------------------------------------------------------------------\n    void CursorSystem::Draw(CanvasRenderer* renderer) const noexcept\n    {\n        m_cursor->OnDraw(renderer);\n    }\n    \n    //------------------------------------------------------------------------------\n    void CursorSystem::OnBackground() noexcept\n    {\n        m_cursor->OnBackground();\n    }\n    \n    //------------------------------------------------------------------------------\n    void CursorSystem::OnSuspend() noexcept\n    {\n        m_cursor->OnSuspend();\n        \n        m_pointerAddedConnection.reset();\n        m_pointerMovedConnection.reset();\n        m_pointerRemovedConnection.reset();\n    }\n\n    //------------------------------------------------------------------------------\n    void CursorSystem::OnDestroy() noexcept\n    {\n        m_cursor.reset();\n        m_pointerRemovedConnection.reset();\n        m_pointerMovedConnection.reset();\n        m_pointerAddedConnection.reset();\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/UI/Base/CursorSystem.h",
    "content": "//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2017 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_UI_BASE_CURSOR_H_\n#define _CHILLISOURCE_UI_BASE_CURSOR_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Event/EventConnection.h>\n#include <ChilliSource/Core/System/AppSystem.h>\n#include <ChilliSource/UI/Base/Widget.h>\n\nnamespace ChilliSource\n{\n    /// Used to render a UI (non-system) cursor on top of the active UI canvas.\n    /// The cursor uses the PointerSystem to determine the current location to render at.\n    ///\n    /// NOTE: The cursor will track movement by any pointer. So if you have more than one mouse attached\n    /// the cursor will be moved by each mouse\n    ///\n    class CursorSystem final : public AppSystem\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(CursorSystem);\n        \n        ///\n        bool IsA(InterfaceIDType interfaceId) const noexcept override;\n\n        /// Makes the cursor visible (if a pointer is attached)\n        ///\n        void ShowCursor();\n        \n        /// Makes the cursor invisible\n        ///\n        void HideCursor();\n        \n        /// @param cursorWidget\n        ///     The widget that will be rendered as the pointer cursor\n        ///\n        void SetCursorWidget(WidgetUPtr cursorWidget) noexcept { m_cursor = std::move(cursorWidget); }\n        \n    private:\n        friend class Application;\n        friend class CanvasRenderer;\n        \n        ///\n        static CursorSystemUPtr Create() noexcept;\n        \n        ///\n        CursorSystem() = default;\n\n        /// Forwarded onto cursor widget. Creates the default cursor\n        ///\n        void OnInit() noexcept override;\n\n        /// Forwarded onto cursor widget\n        ///\n        void OnResume() noexcept override;\n\n        /// Forwarded onto cursor widget\n        ///\n        void OnForeground() noexcept override;\n\n        /// Forwarded onto cursor widget\n        ///\n        void OnUpdate(f32 timeSinceLastUpdate) noexcept override;\n\n        /// Forwarded onto cursor widget\n        ///\n        void OnBackground() noexcept override;\n\n        /// Forwarded onto cursor widget\n        ///\n        void OnSuspend() noexcept override;\n\n        /// Forwarded onto cursor widget\n        ///\n        void OnDestroy() noexcept override;\n        \n        /// Draw the cursor widget using the canvas renderer.\n        ///\n        /// @param renderer\n        ///     Canvas renderer used by the widget and children to draw themselves\n        ///\n        void Draw(CanvasRenderer* renderer) const noexcept;\n\n        /// Called when a new pointer is attached. If this is the first pointer\n        /// then the cursor is shown\n        ///\n        /// @param pointer\n        ///     Pointer added\n        /// @param timestamp\n        ///     Time at which the pointer was added\n        ///\n        void OnPointerAdded(const Pointer& pointer, f64 timestamp) noexcept;\n\n        /// Will move the cursor to the location of the pointer\n        ///\n        /// @param pointer\n        ///     Pointer moved\n        /// @param timestamp\n        ///     Time at which the pointer was moved\n        ///\n        void OnPointerMoved(const Pointer& pointer, f64 timestamp) noexcept;\n\n        /// Called when a pointer is detached. If this is the last pointer\n        /// then the cursor is hidden\n        ///\n        /// @param pointer\n        ///     Pointer removed\n        /// @param timestamp\n        ///     Time at which the pointer was removed\n        ///\n        void OnPointerRemoved(const Pointer& in_pointer, f64 in_timestamp) noexcept;\n        \n    private:\n        \n        WidgetUPtr m_cursor;\n        EventConnectionUPtr m_pointerAddedConnection;\n        EventConnectionUPtr m_pointerMovedConnection;\n        EventConnectionUPtr m_pointerRemovedConnection;\n        \n        bool m_enabled = false;\n        \n        PointerSystem* m_pointerSystem;\n\t};\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/UI/Base/PropertyLink.cpp",
    "content": "//\n//  PropertyLink.cpp\n//  ChilliSource\n//  Created by Ian Copland on 24/11/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/UI/Base/PropertyLink.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------\n    //------------------------------------------------------------------\n    PropertyLink::PropertyLink(const std::string& in_linkName, const std::string& in_linkedOwner, const std::string& in_linkedProperty)\n        : m_linkName(in_linkName), m_linkedOwner(in_linkedOwner), m_linkedProperty(in_linkedProperty)\n    {\n    }\n    //------------------------------------------------------------------\n    //------------------------------------------------------------------\n    const std::string& PropertyLink::GetLinkName() const\n    {\n        return m_linkName;\n    }\n    //------------------------------------------------------------------\n    //------------------------------------------------------------------\n    const std::string& PropertyLink::GetLinkedOwner() const\n    {\n        return m_linkedOwner;\n    }\n    //------------------------------------------------------------------\n    //------------------------------------------------------------------\n    const std::string& PropertyLink::GetLinkedProperty() const\n    {\n        return m_linkedProperty;\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/UI/Base/PropertyLink.h",
    "content": "//\n//  PropertyLink.h\n//  ChilliSource\n//  Created by Ian Copland on 24/11/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_UI_BASE_PROPERTYLINK_H_\n#define _CHILLISOURCE_UI_BASE_PROPERTYLINK_H_\n\n#include <ChilliSource/ChilliSource.h>\n\nnamespace ChilliSource\n{\n    //--------------------------------------------------------------------------\n    /// A container for a description of a property which links to another. This\n    /// provides a name for the link, the name of the linked propery owner and\n    /// the linked property name. This is immutable after construction.\n    ///\n    /// @param Ian Copland\n    //--------------------------------------------------------------------------\n    class PropertyLink final\n    {\n    public:\n        //------------------------------------------------------------------\n        /// Constructor. Creates an empty property link.\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------------------------\n        PropertyLink() = default;\n        //------------------------------------------------------------------\n        /// Constructor.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The name of the property link.\n        /// @param The name of the linked property owner.\n        /// @param The name of the linked property.\n        //------------------------------------------------------------------\n        PropertyLink(const std::string& in_linkName, const std::string& in_linkedOwner, const std::string& in_linkedProperty);\n        //------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The name of the property link.\n        //------------------------------------------------------------------\n        const std::string& GetLinkName() const;\n        //------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The name of the linked property owner\n        //------------------------------------------------------------------\n        const std::string& GetLinkedOwner() const;\n        //------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The name of the linked property.\n        //------------------------------------------------------------------\n        const std::string& GetLinkedProperty() const;\n    private:\n        std::string m_linkName = \"\";\n        std::string m_linkedOwner = \"\";\n        std::string m_linkedProperty = \"\";\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/UI/Base/PropertyTypes.cpp",
    "content": "//\n//  WidgetPropertyTypes.cpp\n//  ChilliSource\n//  Created by Ian Copland on 04/12/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/UI/Base/PropertyTypes.h>\n\n#include <ChilliSource/UI/Drawable/UIDrawableDef.h>\n#include <ChilliSource/UI/Layout/UILayoutDef.h>\n#include <ChilliSource/UI/ProgressBar/ProgressBarDirection.h>\n#include <ChilliSource/UI/ProgressBar/ProgressBarType.h>\n#include <ChilliSource/UI/Slider/SliderDirection.h>\n#include <ChilliSource/Input/TextEntry.h>\n#include <ChilliSource/Rendering/Base/AlignmentAnchors.h>\n#include <ChilliSource/Rendering/Base/HorizontalTextJustification.h>\n#include <ChilliSource/Rendering/Base/SizePolicy.h>\n#include <ChilliSource/Rendering/Base/VerticalTextJustification.h>\n\nnamespace ChilliSource\n{\n    namespace PropertyTypes\n    {\n        CS_DEFINE_PROPERTYTYPE(ChilliSource::AlignmentAnchor, AlignmentAnchor, ChilliSource::AlignmentAnchor::k_middleCentre, &ParseAlignmentAnchor);\n        CS_DEFINE_PROPERTYTYPE(ChilliSource::SizePolicy, SizePolicy, ChilliSource::SizePolicy::k_none, &ParseSizePolicy);\n        CS_DEFINE_PROPERTYTYPE(UIDrawableDefCSPtr, UIDrawableDef, nullptr, nullptr);\n        CS_DEFINE_PROPERTYTYPE(UILayoutDefCSPtr, UILayoutDef, nullptr, nullptr);\n        CS_DEFINE_PROPERTYTYPE(TextureCSPtr, Texture, nullptr, nullptr);\n        CS_DEFINE_PROPERTYTYPE(TextureAtlasCSPtr, TextureAtlas, nullptr, nullptr);\n        CS_DEFINE_PROPERTYTYPE(FontCSPtr, Font, nullptr, nullptr);\n        CS_DEFINE_PROPERTYTYPE(LocalisedTextCSPtr, LocalisedText, nullptr, nullptr);\n        CS_DEFINE_PROPERTYTYPE(ChilliSource::HorizontalTextJustification, HorizontalTextJustification, ChilliSource::HorizontalTextJustification::k_centre, &ParseHorizontalTextJustification);\n        CS_DEFINE_PROPERTYTYPE(ChilliSource::VerticalTextJustification, VerticalTextJustification, ChilliSource::VerticalTextJustification::k_centre, &ParseVerticalTextJustification);\n        CS_DEFINE_PROPERTYTYPE(ChilliSource::SliderDirection, SliderDirection, ChilliSource::SliderDirection::k_horizontal, &ParseSliderDirection);\n        CS_DEFINE_PROPERTYTYPE(ChilliSource::ProgressBarDirection, ProgressBarDirection, ChilliSource::ProgressBarDirection::k_horizontal, &ParseProgressBarDirection);\n        CS_DEFINE_PROPERTYTYPE(ChilliSource::ProgressBarType, ProgressBarType, ChilliSource::ProgressBarType::k_stretch, &ParseProgressBarType);\n        CS_DEFINE_PROPERTYTYPE(ChilliSource::TextEntryType, InputType, ChilliSource::TextEntryType::k_text, &ParseKeyboardInputType);\n        CS_DEFINE_PROPERTYTYPE(ChilliSource::TextEntryCapitalisation, CapitalisationFormat, ChilliSource::TextEntryCapitalisation::k_sentences, &ParseCapitalisationFormat);\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/UI/Base/PropertyTypes.h",
    "content": "//\n//  WidgetPropertyTypes.h\n//  ChilliSource\n//  Created by Ian Copland on 04/12/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_UI_BASE_PROPERTYTYPES_H_\n#define _CHILLISOURCE_UI_BASE_PROPERTYTYPES_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Container/Property/PropertyType.h>\n#include <ChilliSource/Input/TextEntry.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------\n    /// Additional property types that are specific to UI.\n    ///\n    /// @author Ian Copland\n    //------------------------------------------------------------------------\n    namespace PropertyTypes\n    {\n        CS_DECLARE_PROPERTYTYPE(AlignmentAnchor, AlignmentAnchor);\n        CS_DECLARE_PROPERTYTYPE(SizePolicy, SizePolicy);\n        CS_DECLARE_PROPERTYTYPE(UIDrawableDefCSPtr, UIDrawableDef);\n        CS_DECLARE_PROPERTYTYPE(UILayoutDefCSPtr, UILayoutDef);\n        CS_DECLARE_PROPERTYTYPE(TextureCSPtr, Texture);\n        CS_DECLARE_PROPERTYTYPE(TextureAtlasCSPtr, TextureAtlas);\n        CS_DECLARE_PROPERTYTYPE(FontCSPtr, Font);\n        CS_DECLARE_PROPERTYTYPE(LocalisedTextCSPtr, LocalisedText);\n        CS_DECLARE_PROPERTYTYPE(HorizontalTextJustification, HorizontalTextJustification);\n        CS_DECLARE_PROPERTYTYPE(VerticalTextJustification, VerticalTextJustification);\n        CS_DECLARE_PROPERTYTYPE(SliderDirection, SliderDirection);\n        CS_DECLARE_PROPERTYTYPE(ProgressBarDirection, ProgressBarDirection);\n        CS_DECLARE_PROPERTYTYPE(ProgressBarType, ProgressBarType);\n        CS_DECLARE_PROPERTYTYPE(TextEntryType, InputType);\n        CS_DECLARE_PROPERTYTYPE(TextEntryCapitalisation, CapitalisationFormat);\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/UI/Base/UIComponent.cpp",
    "content": "//\n//  UIComponent.cpp\n//  ChilliSource\n//  Created by Ian Copland on 14/11/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/UI/Base/UIComponent.h>\n\n#include <ChilliSource/Core/Base/Colour.h>\n#include <ChilliSource/Core/Container/Property/PropertyMap.h>\n#include <ChilliSource/Core/Math/Vector2.h>\n#include <ChilliSource/Core/Math/Vector3.h>\n#include <ChilliSource/Core/Math/Vector4.h>\n#include <ChilliSource/Core/String/StringUtils.h>\n#include <ChilliSource/UI/Base/PropertyTypes.h>\n\nnamespace ChilliSource\n{\n    CS_DEFINE_NAMEDTYPE(UIComponent);\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    UIComponent::UIComponent(const std::string& in_name)\n        : m_widget(nullptr), m_name(in_name)\n    {\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    const std::string& UIComponent::GetName() const\n    {\n        return m_name;\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    bool UIComponent::HasProperty(const std::string& in_propertyName) const\n    {\n        std::string lowerPropertyName = in_propertyName;\n        StringUtils::ToLowerCase(lowerPropertyName);\n        \n        auto it = m_properties.find(lowerPropertyName);\n        return (it != m_properties.end());\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    void UIComponent::SetProperty(const std::string& in_propertyName, const char* in_propertyValue)\n    {\n        SetProperty(in_propertyName, std::string(in_propertyValue));\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    Widget* UIComponent::GetWidget()\n    {\n        return m_widget;\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    const Widget* UIComponent::GetWidget() const\n    {\n        return m_widget;\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    void UIComponent::ApplyRegisteredProperties(const PropertyMap& in_properties)\n    {\n        CS_ASSERT(m_propertyRegistrationComplete == false, \"Registered properties have already been applied.\");\n        \n        m_propertyRegistrationComplete = true;\n        \n        for (const auto& key : in_properties.GetKeys())\n        {\n            if (in_properties.HasValue(key) == true)\n            {\n                SetProperty(key, in_properties.GetPropertyObject(key));\n            }\n        }\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    void UIComponent::SetWidget(Widget* in_widget)\n    {\n        CS_ASSERT(m_propertyRegistrationComplete == true, \"Cannot add component to a widget before property registration is complete.\");\n        CS_ASSERT(m_widget == nullptr, \"Cannot change the owning widget on a component.\");\n        \n        m_widget = in_widget;\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    void UIComponent::SetProperty(const std::string& in_propertyName, const IProperty* in_property)\n    {\n        CS_ASSERT(m_propertyRegistrationComplete == true, \"Cannot set a property on a UIComponent prior to property registration completion.\");\n        \n        std::string lowerPropertyName = in_propertyName;\n        StringUtils::ToLowerCase(lowerPropertyName);\n        \n        auto it = m_properties.find(lowerPropertyName);\n        if(it == m_properties.end())\n        {\n            CS_LOG_FATAL(\"Cannot find property with name '\" + in_propertyName + \"' in UIComponent.\");\n        }\n        \n        it->second->Set(in_property);\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/UI/Base/UIComponent.h",
    "content": "//\n//  UIComponent.h\n//  ChilliSource\n//  Created by Ian Copland on 14/11/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_UI_BASE_UICOMPONENT_H_\n#define _CHILLISOURCE_UI_BASE_UICOMPONENT_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Base/QueryableInterface.h>\n#include <ChilliSource/Core/Container/Property/Property.h>\n#include <ChilliSource/Core/Container/Property/PropertyType.h>\n\n#include <type_traits>\n#include <unordered_map>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------\n    /// A component which can be attached to a widget to provide additional\n    /// functionality. Components are attached to a widget on construction\n    /// and live for the entire life of the widget. A component def is used\n    /// to create an instance of a widget.\n    ///\n    /// @author Ian Copland\n    //------------------------------------------------------------------------\n    class UIComponent : public QueryableInterface\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(UIComponent);\n        CS_DECLARE_NOCOPY(UIComponent);\n        //----------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The name of the component instance.\n        //----------------------------------------------------------------\n        const std::string& GetName() const;\n        //----------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return A pointer to the widget that owns this component.\n        //----------------------------------------------------------------\n        Widget* GetWidget();\n        //----------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return A constant pointer to the widget that owns this\n        /// component.\n        //----------------------------------------------------------------\n        const Widget* GetWidget() const;\n        //----------------------------------------------------------------\n        /// Allows querying of whether or not the component has a property\n        /// with the given name.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The name of the property. This is case insensitive.\n        ///\n        /// @return Whether or not the property exists.\n        //----------------------------------------------------------------\n        bool HasProperty(const std::string& in_propertyName) const;\n        //----------------------------------------------------------------\n        /// Allows querying for the value of properties in the component\n        /// using a string name. If there is no property with the given\n        /// name or it is not of the requested type the app is considered\n        /// to be in an irrecoverable state and will terminate.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The name of the property to get. This is case insensitive.\n        ///\n        /// @return The value of the requested property.\n        //----------------------------------------------------------------\n        template <typename TPropertyType> TPropertyType GetProperty(const std::string& in_propertyName) const;\n        //----------------------------------------------------------------\n        /// Allows setting of properties in the component using a string\n        /// name. If there is no property with the given name or it is not\n        /// of the requested type the app is considered to be in an\n        /// irrecoverable state and will terminate.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The name of the property. This is case insensitive.\n        /// @param The value of the property.\n        //----------------------------------------------------------------\n        template <typename TPropertyType> void SetProperty(const std::string& in_propertyName, TPropertyType&& in_propertyValue);\n        //----------------------------------------------------------------\n        /// Allows setting of properties in the component using a string\n        /// name. If there is no property with the given name or it is not\n        /// of the requested type the app is considered to be in an\n        /// irrecoverable state and will terminate.\n        ///\n        /// This is an overload of the templated version of SetProperty\n        /// which will convert a string literal to a std::string.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The name of the property. This is case insensitive.\n        /// @param The value of the property.\n        //----------------------------------------------------------------\n        void SetProperty(const std::string& in_propertyName, const char* in_propertyValue);\n        //----------------------------------------------------------------\n        /// Destructor\n        ///\n        /// @author Ian Copland\n        //----------------------------------------------------------------\n        virtual ~UIComponent() {}\n    protected:\n        //----------------------------------------------------------------\n        /// Constructor\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The name of the component instance.\n        //----------------------------------------------------------------\n        UIComponent(const std::string& in_name);\n        //----------------------------------------------------------------\n        /// This registers a property such that it can be called using the\n        /// set property method. This takes two function pointers, one\n        /// for getting the value of a property and one for setting the\n        /// value of a property. Property names must be unique; if a\n        /// duplicate property name is registered the app is considered to\n        /// be in an irrecoverable state and will terminate.\n        ///\n        /// This should only be called during construction of the component.\n        /// Once finished adding properties ApplyProperties should be called.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The property type.\n        /// @param The name of the registered property. This is case\n        /// insensitive.\n        /// @param The getter delegate for the property.\n        /// @param The setter delegate for the property.\n        //----------------------------------------------------------------\n        template <typename TPropertyType> void RegisterProperty(const PropertyType<TPropertyType>* in_propertyType, const std::string& in_name, std::function<TPropertyType()>&& in_getter, std::function<void(TPropertyType)>&& in_setter);\n        //----------------------------------------------------------------\n        /// Finalises any registered properties and applies the default\n        /// values for them as supplied by the given property map.\n        ///\n        /// This must only be called once, and should be called during\n        /// the construction of a component, after registering all\n        /// properties.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The property map\n        //----------------------------------------------------------------\n        void ApplyRegisteredProperties(const PropertyMap& in_properties);\n        //----------------------------------------------------------------\n        /// A method which is called when all components owned by the parent\n        /// widget have been created and added. Inheriting classes should use\n        /// this for any required initialisation.\n        ///\n        /// All registration of properties should occur at this stage.\n        ///\n        /// @author Ian Copland\n        //----------------------------------------------------------------\n        virtual void OnInit() {}\n        //----------------------------------------------------------------\n        /// This is called when the owning widget is added to the canvas.\n        ///\n        /// @author Ian Copland\n        //----------------------------------------------------------------\n        virtual void OnAddedToCanvas() {}\n        //----------------------------------------------------------------\n        /// This is called when the application is resumed while the owning\n        /// widget is attached to the canvas. This is also also called\n        /// when added to the canvas if the application is already active.\n        ///\n        /// @author Ian Copland\n        //----------------------------------------------------------------\n        virtual void OnResume() {}\n        //----------------------------------------------------------------\n        /// This is called when the application is foregrounded while the\n        /// owning widget is attached to the canvas. This is also called\n        /// when added to the canvas if the application is already\n        /// foregrounded.\n        ///\n        /// @author Ian Copland\n        //----------------------------------------------------------------\n        virtual void OnForeground() {}\n        //----------------------------------------------------------------\n        /// This is called every frame while the application is active\n        /// and the owning widget is on the canvas. This should be used\n        /// for any update logic in the component.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The delta time since the last update.\n        //----------------------------------------------------------------\n        virtual void OnUpdate(f32 in_deltaTime) {}\n        //----------------------------------------------------------------\n        /// This is called during the draw event whenever the application\n        /// is active and the owning widget in on the canvas. This should\n        /// be used for any rendering.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The canvas renderer.\n        /// @param The final screen space transform.\n        /// @param The final screen space size.\n        /// @param The final colour.\n        //----------------------------------------------------------------\n        virtual void OnDraw(CanvasRenderer* in_renderer, const Matrix3& in_transform, const Vector2& in_absSize, const Colour& in_absColour) {}\n        //----------------------------------------------------------------\n        /// Called prior to the widget drawing its children\n        ///\n        /// @param The canvas renderer.\n        //----------------------------------------------------------------\n        virtual void OnPreDrawChildren(CanvasRenderer* in_renderer) {}\n        //----------------------------------------------------------------\n        /// Called after the widget draws its children\n        ///\n        /// @param The canvas renderer.\n        //----------------------------------------------------------------\n        virtual void OnPostDrawChildren(CanvasRenderer* in_renderer) {}\n        //----------------------------------------------------------------\n        /// This is called when the application is backgrounded while the\n        /// owning widget is on the canvas. This will also be called when\n        /// the owning widget is removed from the canvas if the application\n        /// is foregrounded.\n        ///\n        /// @author Ian Copland\n        //----------------------------------------------------------------\n        virtual void OnBackground() {}\n        //----------------------------------------------------------------\n        /// This is called when the application is suspended while the\n        /// owning widget is on the canvas. This will also be called when\n        /// the owning widget is removed from the canvas if the application\n        /// is active.\n        ///\n        /// @author Ian Copland\n        //----------------------------------------------------------------\n        virtual void OnSuspend() {}\n        //----------------------------------------------------------------\n        /// This is called when the owning widget is removed from the\n        /// canvas.\n        ///\n        /// @author Ian Copland\n        //----------------------------------------------------------------\n        virtual void OnRemovedFromCanvas() {}\n        //----------------------------------------------------------------\n        /// This is called when the component--and the owning widget--is\n        /// about to be destroyed. Components are destroyed in reverse\n        /// initialisation order.\n        ///\n        /// @author Ian Copland\n        //----------------------------------------------------------------\n        virtual void OnDestroy() {}\n    private:\n        friend class Widget;\n        //----------------------------------------------------------------\n        /// Sets the owning widget. This should be called by the owning\n        /// widget when it is first added, prior to calling OnInit().\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The owning widget.\n        //----------------------------------------------------------------\n        void SetWidget(Widget* in_widget);\n        //----------------------------------------------------------------\n        /// Sets the value of a property from another property. The given\n        /// property must be of the same type as the given property or\n        /// the app will be considered to be in an irrecoverable state\n        /// and will terminate.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The property name.\n        /// @param The property used to set the value.\n        //----------------------------------------------------------------\n        void SetProperty(const std::string& in_propertyName, const IProperty* in_property);\n\n        bool m_propertyRegistrationComplete = false;\n        std::unordered_map<std::string, IPropertyUPtr> m_properties;\n        Widget* m_widget = nullptr;\n        std::string m_name;\n    };\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    template <typename TPropertyType> TPropertyType UIComponent::GetProperty(const std::string& in_propertyName) const\n    {\n        CS_ASSERT(m_propertyRegistrationComplete == true, \"Cannot get a property on a UIComponent prior to property registration completion.\");\n        \n        std::string lowerPropertyName = in_propertyName;\n        StringUtils::ToLowerCase(lowerPropertyName);\n        \n        auto it = m_properties.find(lowerPropertyName);\n        if(it == m_properties.end())\n        {\n            CS_LOG_FATAL(\"Cannot find property with name '\" + in_propertyName + \"' in UIComponent.\");\n        }\n        \n        auto accessor = CS_SMARTCAST(const Property<typename std::decay<TPropertyType>::type>*, it->second.get(), \"Incorrect type for property with name: \" + in_propertyName);\n        return accessor->Get();\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    template <typename TPropertyType> void UIComponent::SetProperty(const std::string& in_propertyName, TPropertyType&& in_propertyValue)\n    {\n        CS_ASSERT(m_propertyRegistrationComplete == true, \"Cannot set a property on a UIComponent prior to property registration completion.\");\n        \n        std::string lowerPropertyName = in_propertyName;\n        StringUtils::ToLowerCase(lowerPropertyName);\n        \n        auto it = m_properties.find(lowerPropertyName);\n        if(it == m_properties.end())\n        {\n            CS_LOG_FATAL(\"Cannot find property with name '\" + in_propertyName + \"' in UIComponent.\");\n        }\n        \n        auto accessor = CS_SMARTCAST(Property<typename std::decay<TPropertyType>::type>*, it->second.get(), \"Incorrect type for property with name: \" + in_propertyName);\n        accessor->Set(std::forward<TPropertyType>(in_propertyValue));\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    template <typename TPropertyType> void UIComponent::RegisterProperty(const PropertyType<TPropertyType>* in_propertyType, const std::string& in_name, std::function<TPropertyType()>&& in_getter, std::function<void(TPropertyType)>&& in_setter)\n    {\n        CS_ASSERT(m_propertyRegistrationComplete == false, \"UIComponent properties cannot be registered after property registration completion.\");\n        \n        std::string lowerPropertyName = in_name;\n        StringUtils::ToLowerCase(lowerPropertyName);\n        \n        CS_ASSERT(m_properties.find(lowerPropertyName) == m_properties.end(), \"Cannot register duplicate property name '\" + in_name + \"' in a UIComponent.\");\n        \n        m_properties.emplace(lowerPropertyName, in_propertyType->CreateProperty(std::forward<std::function<TPropertyType()>>(in_getter), std::forward<std::function<void(TPropertyType)>>(in_setter)));\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/UI/Base/UIComponentDesc.cpp",
    "content": "//\n//  UIComponentDesc.cpp\n//  ChilliSource\n//  Created by Ian Copland on 19/11/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/UI/Base/UIComponentDesc.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------\n    //------------------------------------------------------------------\n    UIComponentDesc::UIComponentDesc(const std::string& in_type, const std::string& in_name, const PropertyMap& in_propertyMap)\n        : m_type(in_type), m_name(in_name), m_propertyMap(in_propertyMap)\n    {\n    }\n    //------------------------------------------------------------------\n    //------------------------------------------------------------------\n    const std::string& UIComponentDesc::GetType() const\n    {\n        return m_type;\n    }\n    //------------------------------------------------------------------\n    //------------------------------------------------------------------\n    const std::string& UIComponentDesc::GetName() const\n    {\n        return m_name;\n    }\n    //------------------------------------------------------------------\n    //------------------------------------------------------------------\n    const PropertyMap& UIComponentDesc::GetProperties() const\n    {\n        return m_propertyMap;\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/UI/Base/UIComponentDesc.h",
    "content": "//\n//  UIComponentDesc.h\n//  ChilliSource\n//  Created by Ian Copland on 19/11/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_UI_BASE_UICOMPONENTDESC_H_\n#define _CHILLISOURCE_UI_BASE_UICOMPONENTDESC_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Container/Property/PropertyMap.h>\n\nnamespace ChilliSource\n{\n    //--------------------------------------------------------------------------\n    /// A container for a description of a single UIComponent, comprising of a\n    /// type and a map of properties for the given component type. Typically\n    /// this is only used in the creation of a WidgetDef. In most cases a user\n    /// will not need to deal with this directly, creating a WidgetDef from\n    /// file where this will be handled by the resource provider. This is\n    /// immutable after construction.\n    ///\n    /// @param Ian Copland\n    //--------------------------------------------------------------------------\n    class UIComponentDesc final\n    {\n    public:\n        //------------------------------------------------------------------\n        /// Constructor. Creates an empty description.\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------------------------\n        UIComponentDesc() = default;\n        //------------------------------------------------------------------\n        /// Constructor.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The name of the component type this desc can create.\n        /// @param The name of the component instance.\n        /// @param The map of properties the component should be created\n        /// with.\n        //------------------------------------------------------------------\n        UIComponentDesc(const std::string& in_type, const std::string& in_name, const PropertyMap& in_propertyMap);\n        //------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The name of the component type this desc can create.\n        //------------------------------------------------------------------\n        const std::string& GetType() const;\n        //------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The name of the component instance.\n        //------------------------------------------------------------------\n        const std::string& GetName() const;\n        //------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The map of properties the component should be created\n        /// with.\n        //------------------------------------------------------------------\n        const PropertyMap& GetProperties() const;\n    private:\n        std::string m_type;\n        std::string m_name;\n        PropertyMap m_propertyMap;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/UI/Base/UIComponentFactory.cpp",
    "content": "//\n//  UIComponentFactory.cpp\n//  ChilliSource\n//  Created by Ian Copland on 14/11/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/UI/Base/UIComponentFactory.h>\n\n#include <ChilliSource/UI/Button/HighlightUIComponent.h>\n#include <ChilliSource/UI/Button/ToggleHighlightUIComponent.h>\n#include <ChilliSource/UI/Drawable/DrawableUIComponent.h>\n#include <ChilliSource/UI/Layout/LayoutUIComponent.h>\n#include <ChilliSource/UI/ProgressBar/ProgressBarUIComponent.h>\n#include <ChilliSource/UI/Slider/SliderUIComponent.h>\n#include <ChilliSource/UI/Text/TextUIComponent.h>\n#include <ChilliSource/UI/Text/EditableTextUIComponent.h>\n\nnamespace ChilliSource\n{\n    CS_DEFINE_NAMEDTYPE(UIComponentFactory);\n    //-----------------------------------------------------------------\n    //-----------------------------------------------------------------\n    UIComponentFactoryUPtr UIComponentFactory::Create()\n    {\n        return UIComponentFactoryUPtr(new UIComponentFactory());\n    }\n    //-----------------------------------------------------------------\n    //-----------------------------------------------------------------\n    bool UIComponentFactory::IsA(InterfaceIDType in_interfaceId) const\n    {\n        return (UIComponentFactory::InterfaceID == in_interfaceId);\n    }\n    //-----------------------------------------------------------------\n    //-----------------------------------------------------------------\n    std::vector<PropertyMap::PropertyDesc> UIComponentFactory::GetPropertyDescs(const std::string& in_componentTypeName) const\n    {\n        auto descsIt = m_descsMap.find(in_componentTypeName);\n        CS_ASSERT(descsIt != m_descsMap.end(), \"Could not get property descs for component with name: \" + in_componentTypeName);\n        \n        return descsIt->second;\n    }\n    //-----------------------------------------------------------------\n    //-----------------------------------------------------------------\n    UIComponentUPtr UIComponentFactory::CreateComponent(const std::string& in_componentTypeName, const std::string& in_name, const PropertyMap& in_propertyMap) const\n    {\n        auto delegateIt = m_creatorDelegateMap.find(in_componentTypeName);\n        CS_ASSERT(delegateIt != m_creatorDelegateMap.end(), \"Could not create component with name: \" + in_componentTypeName);\n        \n        return delegateIt->second(in_name, in_propertyMap);\n    }\n    //-----------------------------------------------------------------\n    //-----------------------------------------------------------------\n    void UIComponentFactory::OnInit()\n    {\n        Register<DrawableUIComponent>(\"Drawable\");\n        Register<LayoutUIComponent>(\"Layout\");\n        Register<HighlightUIComponent>(\"Highlight\");\n        Register<ToggleHighlightUIComponent>(\"ToggleHighlight\");\n        Register<TextUIComponent>(\"Text\");\n        Register<ProgressBarUIComponent>(\"ProgressBar\");\n        Register<SliderUIComponent>(\"Slider\");\n        Register<EditableTextUIComponent>(\"EditableText\");\n    }\n    //-----------------------------------------------------------------\n    //-----------------------------------------------------------------\n    void UIComponentFactory::OnDestroy()\n    {\n        m_creatorDelegateMap.clear();\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/UI/Base/UIComponentFactory.h",
    "content": "//\n//  UIComponentFactory.h\n//  ChilliSource\n//  Created by Ian Copland on 14/11/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_UI_BASE_UICOMPONENTFACTORY_H_\n#define _CHILLISOURCE_UI_BASE_UICOMPONENTFACTORY_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Container/Property/PropertyMap.h>\n#include <ChilliSource/Core/Delegate/MakeDelegate.h>\n#include <ChilliSource/Core/System/AppSystem.h>\n#include <ChilliSource/UI/Base/UIComponent.h>\n\n#include <functional>\n#include <unordered_map>\n\nnamespace ChilliSource\n{\n    //--------------------------------------------------------------------------\n    /// A factory for creating new instances of UIComponents from a string\n    /// identifier and a property factory. UIComponent types must be registered\n    /// with the factory using the Register<>() method before they can be\n    /// used in a WidgetDef. UIComponent implementations should provide a\n    /// constructor and a static method with the following signatures:\n    ///\n    /// TComponent(const std::string& in_name, const PropertyMap& in_propMap);\n    /// static const std::vector<PropertyMap::PropertyDesc>& GetPropertyDescs();\n    ///\n    /// @author Ian Copland\n    //--------------------------------------------------------------------------\n    class UIComponentFactory final : public AppSystem\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(UIComponentFactory);\n        //-----------------------------------------------------------------\n        /// Allows querying of whether or not the system implements the\n        /// interface associated with the given interface Id.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The interface Id.\n        ///\n        /// @return Whether or not the interface is implemented.\n        //-----------------------------------------------------------------\n        bool IsA(InterfaceIDType in_interfaceId) const override;\n        //-----------------------------------------------------------------\n        /// Registers a new component type with the factory. Future calls\n        /// to CreateComponent() with the given name will instantiate a\n        /// component of this type. The given name must be unique; if a\n        /// duplicate component name is registered the app is considered\n        /// to be in an irrecoverable state and will terminate.\n        ///\n        /// This is not thread-safe and should only be called on the main\n        /// thread.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The unique name of the component.\n        //-----------------------------------------------------------------\n        template <typename TComponentType> void Register(const std::string& in_componentTypeName);\n        //-----------------------------------------------------------------\n        /// Returns the property descs for the given component type. This\n        /// will log a fatal error if the component type has not been\n        /// registered.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The name of the component type to get the property descs\n        /// for.\n        ///\n        /// @return The property descs.\n        //-----------------------------------------------------------------\n        std::vector<PropertyMap::PropertyDesc> GetPropertyDescs(const std::string& in_componentTypeName) const;\n        //-----------------------------------------------------------------\n        /// Creates an instance of the component type registered under the\n        /// given name with the given owner widget and property map.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The name of the property type previously registered with\n        /// the factory.\n        /// @param The name of the component instance.\n        /// @param The property map to create the component with.\n        ///\n        /// @return The new component instance.\n        //-----------------------------------------------------------------\n        UIComponentUPtr CreateComponent(const std::string& in_componentTypeName, const std::string& in_name, const PropertyMap& in_propertyMap) const;\n    private:\n        friend class Application;\n        //-----------------------------------------------------------------\n        /// A factory method for creating new instances of the system.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @return A new instance of the system.\n        //-----------------------------------------------------------------\n        static UIComponentFactoryUPtr Create();\n        //-----------------------------------------------------------------\n        /// A delegate which is used to instantiate the registered component\n        /// types.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The name of the component instance.\n        /// @param The property map to create the component with.\n        ///\n        /// @return The newly created component.\n        //-----------------------------------------------------------------\n        using CreatorDelegate = std::function<UIComponentUPtr(const std::string& in_name, const PropertyMap& in_propertyMap)>;\n        //-----------------------------------------------------------------\n        /// Creates a new instance of the given component type. This is the\n        /// method referred to by the creator delegates.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The name of the component instance.\n        /// @param The property map to create the component with.\n        ///\n        /// @return The newly created component.\n        //-----------------------------------------------------------------\n        template <typename TComponentType> std::unique_ptr<TComponentType> CreateComponent(const std::string& in_name, const PropertyMap& in_propertyMap) const;\n        //-----------------------------------------------------------------\n        /// Initialised the factory, registering all default component\n        /// types.\n        ///\n        /// @author Ian Copland\n        //-----------------------------------------------------------------\n        void OnInit() override;\n        //-----------------------------------------------------------------\n        /// Deregisters all component types classes.\n        ///\n        /// @author Ian Copland\n        //-----------------------------------------------------------------\n        void OnDestroy() override;\n        \n        std::unordered_map<std::string, CreatorDelegate> m_creatorDelegateMap;\n        std::unordered_map<std::string, std::vector<PropertyMap::PropertyDesc>> m_descsMap;\n    };\n    //-----------------------------------------------------------------\n    //-----------------------------------------------------------------\n    template <typename TComponentType> void UIComponentFactory::Register(const std::string& in_componentTypeName)\n    {\n        m_creatorDelegateMap.insert(std::make_pair(in_componentTypeName, MakeDelegate(this, &UIComponentFactory::CreateComponent<TComponentType>)));\n        m_descsMap.insert(std::make_pair(in_componentTypeName, TComponentType::GetPropertyDescs()));\n    }\n    //-----------------------------------------------------------------\n    //-----------------------------------------------------------------\n    template <typename TComponentType> std::unique_ptr<TComponentType> UIComponentFactory::CreateComponent(const std::string& in_name, const PropertyMap& in_propertyMap) const\n    {\n        return std::unique_ptr<TComponentType>(new TComponentType(in_name, in_propertyMap));\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/UI/Base/Widget.cpp",
    "content": "//\n//  Widget.cpp\n//  ChilliSource\n//  Created by Scott Downie on 17/04/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/UI/Base/Widget.h>\n\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/Base/Screen.h>\n#include <ChilliSource/Core/Container/Property/PropertyMap.h>\n#include <ChilliSource/Core/Container/Property/PropertyTypes.h>\n#include <ChilliSource/Core/Delegate/MakeDelegate.h>\n#include <ChilliSource/Input/Pointer/PointerSystem.h>\n#include <ChilliSource/Rendering/Base/AlignmentAnchors.h>\n#include <ChilliSource/Rendering/Base/AspectRatioUtils.h>\n#include <ChilliSource/Rendering/Base/CanvasRenderer.h>\n#include <ChilliSource/UI/Base/PropertyTypes.h>\n#include <ChilliSource/UI/Drawable/UIDrawable.h>\n#include <ChilliSource/UI/Drawable/DrawableUIComponent.h>\n#include <ChilliSource/UI/Layout/LayoutUIComponent.h>\n\nnamespace ChilliSource\n{\n    namespace\n    {\n        const char k_properyNameName[] = \"name\";\n        const char k_properyNameRelPosition[] = \"relposition\";\n        const char k_properyNameAbsPosition[] = \"absposition\";\n        const char k_properyNameRelSize[] = \"relsize\";\n        const char k_properyNameAbsSize[] = \"abssize\";\n        const char k_properyNamePreferredSize[] = \"preferredsize\";\n        const char k_properyNameScale[] = \"scale\";\n        const char k_properyNameColour[] = \"colour\";\n        const char k_properyNameRotation[] = \"rotation\";\n        const char k_properyNameOriginAnchor[] = \"originanchor\";\n        const char k_properyNameParentalAnchor[] = \"parentalanchor\";\n        const char k_properyNameVisible[] = \"visible\";\n        const char k_properyNameInputEnabled[] = \"inputenabled\";\n        const char k_properyNameInputConsumeEnabled[] = \"inputconsumeenabled\";\n        const char k_properyNameSizePolicy[] = \"sizepolicy\";\n        \n        const std::vector<PropertyMap::PropertyDesc> k_propertyDescs =\n        {\n            {PropertyTypes::String(), k_properyNameName},\n            {PropertyTypes::Vector2(), k_properyNameRelPosition},\n            {PropertyTypes::Vector2(), k_properyNameAbsPosition},\n            {PropertyTypes::Vector2(), k_properyNameRelSize},\n            {PropertyTypes::Vector2(), k_properyNameAbsSize},\n            {PropertyTypes::Vector2(), k_properyNamePreferredSize},\n            {PropertyTypes::Vector2(), k_properyNameScale},\n            {PropertyTypes::Colour(), k_properyNameColour},\n            {PropertyTypes::Float(), k_properyNameRotation},\n            {PropertyTypes::AlignmentAnchor(), k_properyNameOriginAnchor},\n            {PropertyTypes::AlignmentAnchor(), k_properyNameParentalAnchor},\n            {PropertyTypes::Bool(), k_properyNameVisible},\n            {PropertyTypes::Bool(), k_properyNameInputEnabled},\n            {PropertyTypes::Bool(), k_properyNameInputConsumeEnabled},\n            {PropertyTypes::SizePolicy(), k_properyNameSizePolicy},\n        };\n        \n        //----------------------------------------------------------------------------------------\n        /// Perform a rough check to see if the widget is offscreen\n        ///\n        /// @author S Downie\n        ///\n        /// @param Absolute position\n        /// @param Absolute size\n        /// @param Canvas size\n        ///\n        /// @return Whether the widget is considered offscreen and should be culled\n        //----------------------------------------------------------------------------------------\n        bool ShouldCull(const Vector2& in_absPos, const Vector2& in_absSize, const Vector2& in_canvasSize)\n        {\n            Vector2 halfSize(in_absSize * 0.5f);\n            //Treat it like a square so that we do not need to take rotation into account\n            halfSize.x = std::max(halfSize.x, halfSize.y);\n            halfSize.y = std::max(halfSize.y, halfSize.y);\n            \n            Vector2 bottomLeft = GetAnchorPoint(AlignmentAnchor::k_bottomLeft, halfSize);\n            bottomLeft += in_absPos;\n            \n            Vector2 topRight = GetAnchorPoint(AlignmentAnchor::k_topRight, halfSize);\n            topRight += in_absPos;\n            \n            return (topRight.y < 0 || bottomLeft.y > in_canvasSize.y || topRight.x < 0 || bottomLeft.x > in_canvasSize.x);\n        }\n        \n        namespace SizePolicyFuncs\n        {\n            //----------------------------------------------------------\n            /// Aspect ratio maintaing function that returns the original\n            /// size. This is used despite the fact it doesn't do much to\n            /// prevent multiple code paths when calculating size.\n            ///\n            /// @author S Downie\n            ///\n            /// @param Original size\n            /// @param Preferred size\n            ///\n            /// @return Original size\n            //----------------------------------------------------------\n            Vector2 UseOriginalSize(const Vector2& in_originalSize, const Vector2& in_preferredSize)\n            {\n                return in_originalSize;\n            }\n            //----------------------------------------------------------\n            /// Aspect ratio maintaing function that returns the preferred\n            /// size. This is used despite the fact it doesn't do much to\n            /// prevent multiple code paths when calculating size.\n            ///\n            /// @author S Downie\n            ///\n            /// @param Original size\n            /// @param Preferred size\n            ///\n            /// @return Preferred size\n            //----------------------------------------------------------\n            Vector2 UsePreferredSize(const Vector2& in_originalSize, const Vector2& in_preferredSize)\n            {\n                return in_preferredSize;\n            }\n            //----------------------------------------------------------------------------------------\n            /// Aspect ratio maintaining function that keeps the original width but adapts\n            /// the height to maintain the aspect ratio\n            ///\n            /// @author S Downie\n            ///\n            /// @param Original size\n            /// @param Preferred size\n            ///\n            /// @return Size with aspect maintained\n            //----------------------------------------------------------------------------------------\n            Vector2 KeepOriginalWidthAdaptHeight(const Vector2& in_originalSize, const Vector2& in_preferredSize)\n            {\n                return AspectRatioUtils::KeepOriginalWidthAdaptHeight(in_originalSize, in_preferredSize.x/in_preferredSize.y);\n            }\n            //----------------------------------------------------------------------------------------\n            /// Aspect ratio maintaining function that keeps the original height but adapts\n            /// the width to maintain the aspect ratio\n            ///\n            /// @author S Downie\n            ///\n            /// @param Original size\n            /// @param Preferred size\n            ///\n            /// @return Size with aspect maintained\n            //----------------------------------------------------------------------------------------\n            Vector2 KeepOriginalHeightAdaptWidth(const Vector2& in_originalSize, const Vector2& in_preferredSize)\n            {\n                return AspectRatioUtils::KeepOriginalHeightAdaptWidth(in_originalSize, in_preferredSize.x/in_preferredSize.y);\n            }\n            //----------------------------------------------------------------------------------------\n            /// Aspect ratio maintaining function that maintains the given target aspect ratio\n            /// while ensuring the size does not DROP BELOW the original size\n            ///\n            /// @author S Downie\n            ///\n            /// @param Original size\n            /// @param Preferred size\n            ///\n            /// @return Size with aspect maintained\n            //----------------------------------------------------------------------------------------\n            Vector2 FillOriginal(const Vector2& in_originalSize, const Vector2& in_preferredSize)\n            {\n                return AspectRatioUtils::FillOriginal(in_originalSize, in_preferredSize.x/in_preferredSize.y);\n            }\n            //----------------------------------------------------------------------------------------\n            /// Aspect ratio maintaining function that maintains the given target aspect ratio\n            /// while ensuring the size does not EXCEED the original size\n            ///\n            /// @author S Downie\n            ///\n            /// @param Original size\n            /// @param Preferred size\n            ///\n            /// @return Size with aspect maintained\n            //----------------------------------------------------------------------------------------\n            Vector2 FitOriginal(const Vector2& in_originalSize, const Vector2& in_preferredSize)\n            {\n                return AspectRatioUtils::FitOriginal(in_originalSize, in_preferredSize.x/in_preferredSize.y);\n            }\n            \n            const Widget::SizePolicyDelegate k_sizePolicyFuncs[(u32)SizePolicy::k_totalNum] =\n            {\n                UseOriginalSize,\n                UsePreferredSize,\n                KeepOriginalWidthAdaptHeight,\n                KeepOriginalHeightAdaptWidth,\n                FitOriginal,\n                FillOriginal\n            };\n        }\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    std::vector<PropertyMap::PropertyDesc> Widget::GetPropertyDescs()\n    {\n        return k_propertyDescs;\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    Widget::Widget(const PropertyMap& in_properties, std::vector<UIComponentUPtr> in_components, const std::vector<PropertyLink>& in_componentPropertyLinks, std::vector<WidgetUPtr> in_internalChildren,\n                   const std::vector<PropertyLink>& in_childPropertyLinks)\n    {\n        m_screen = Application::Get()->GetSystem<Screen>();\n        m_pointerSystem = Application::Get()->GetSystem<PointerSystem>();\n        \n        //ensure the size policy delegate is correct.\n        SetSizePolicy(m_sizePolicy);\n        \n        InitBaseProperties();\n        InitComponents(std::move(in_components));\n        InitInternalWidgets(std::move(in_internalChildren));\n        InitPropertyLinks(in_componentPropertyLinks, in_childPropertyLinks);\n        InitPropertyValues(in_properties);\n        \n        for (const auto& component : m_components)\n        {\n            component->OnInit();\n        }\n        \n        m_layoutComponent = GetComponent<LayoutUIComponent>();\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    void Widget::InitBaseProperties()\n    {\n        m_baseProperties.emplace(k_properyNameName, PropertyTypes::String()->CreateProperty(MakeDelegate(this, &Widget::GetName), MakeDelegate(this, &Widget::SetName)));\n        m_baseProperties.emplace(k_properyNameRelPosition, PropertyTypes::Vector2()->CreateProperty(MakeDelegate(this, &Widget::GetLocalRelativePosition), MakeDelegate(this, &Widget::SetRelativePosition)));\n        m_baseProperties.emplace(k_properyNameAbsPosition, PropertyTypes::Vector2()->CreateProperty(MakeDelegate(this, &Widget::GetLocalAbsolutePosition), MakeDelegate(this, &Widget::SetAbsolutePosition)));\n        m_baseProperties.emplace(k_properyNameRelSize, PropertyTypes::Vector2()->CreateProperty(MakeDelegate(this, &Widget::GetLocalRelativeSize), MakeDelegate(this, &Widget::SetRelativeSize)));\n        m_baseProperties.emplace(k_properyNameAbsSize, PropertyTypes::Vector2()->CreateProperty(MakeDelegate(this, &Widget::GetLocalAbsoluteSize), MakeDelegate(this, &Widget::SetAbsoluteSize)));\n        m_baseProperties.emplace(k_properyNamePreferredSize, PropertyTypes::Vector2()->CreateProperty(MakeDelegate(this, &Widget::GetPreferredSize), MakeDelegate(this, &Widget::SetDefaultPreferredSize)));\n        m_baseProperties.emplace(k_properyNameScale, PropertyTypes::Vector2()->CreateProperty(MakeDelegate(this, &Widget::GetLocalScale), MakeDelegate(this, &Widget::ScaleTo)));\n        m_baseProperties.emplace(k_properyNameColour, PropertyTypes::Colour()->CreateProperty(MakeDelegate(this, &Widget::GetLocalColour), MakeDelegate(this, &Widget::SetColour)));\n        m_baseProperties.emplace(k_properyNameRotation, PropertyTypes::Float()->CreateProperty(MakeDelegate(this, &Widget::GetLocalRotation), MakeDelegate(this, &Widget::RotateTo)));\n        m_baseProperties.emplace(k_properyNameOriginAnchor, PropertyTypes::AlignmentAnchor()->CreateProperty(MakeDelegate(this, &Widget::GetOriginAnchor), MakeDelegate(this, &Widget::SetOriginAnchor)));\n        m_baseProperties.emplace(k_properyNameParentalAnchor, PropertyTypes::AlignmentAnchor()->CreateProperty(MakeDelegate(this, &Widget::GetParentalAnchor), MakeDelegate(this, &Widget::SetParentalAnchor)));\n        m_baseProperties.emplace(k_properyNameVisible, PropertyTypes::Bool()->CreateProperty(MakeDelegate(this, &Widget::IsVisible), MakeDelegate(this, &Widget::SetVisible)));\n        m_baseProperties.emplace(k_properyNameInputEnabled, PropertyTypes::Bool()->CreateProperty(MakeDelegate(this, &Widget::IsInputEnabled), MakeDelegate(this, &Widget::SetInputEnabled)));\n        m_baseProperties.emplace(k_properyNameInputConsumeEnabled, PropertyTypes::Bool()->CreateProperty(MakeDelegate(this, &Widget::IsInputConsumeEnabled), MakeDelegate(this, &Widget::SetInputConsumeEnabled)));\n        m_baseProperties.emplace(k_properyNameSizePolicy, PropertyTypes::SizePolicy()->CreateProperty(MakeDelegate(this, &Widget::GetSizePolicy), MakeDelegate(this, &Widget::SetSizePolicy)));\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    void Widget::InitComponents(std::vector<UIComponentUPtr> in_components)\n    {\n        m_components = std::move(in_components);\n        \n        for (auto& component : m_components)\n        {\n            component->SetWidget(this);\n        }\n        \n#ifdef CS_ENABLE_DEBUG\n        //ensure there are no duplicate names\n        for (const auto& componentA : m_components)\n        {\n            for (const auto& componentB : m_components)\n            {\n                if (componentA != componentB)\n                {\n                    CS_ASSERT(componentA->GetName() != componentB->GetName(), \"Duplicate widget component name '\" + componentA->GetName() + \"'.\");\n                }\n            }\n        }\n#endif\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    void Widget::InitInternalWidgets(std::vector<WidgetUPtr> in_widgets)\n    {\n        for (auto& widget : in_widgets)\n        {\n            CS_ASSERT(widget->GetParent() == nullptr, \"Cannot add a widget as a child of more than 1 parent\");\n            \n            Widget* widgetRaw = widget.get();\n            m_internalChildren.push_back(std::move(widget));\n            widgetRaw->m_parent = this;\n            \n            if (m_canvas != nullptr)\n            {\n                widgetRaw->SetCanvas(m_canvas);\n            }\n        }\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    void Widget::InitPropertyLinks(const std::vector<PropertyLink>& in_componentPropertyLinks, const std::vector<PropertyLink>& in_childPropertyLinks)\n    {\n        //Hook up any links to our components\n        for(const auto& link : in_componentPropertyLinks)\n        {\n            CS_ASSERT(m_baseProperties.find(link.GetLinkName()) == m_baseProperties.end(), \"Cannot add duplicate property: \" + link.GetLinkName());\n            CS_ASSERT(m_componentPropertyLinks.find(link.GetLinkName()) == m_componentPropertyLinks.end(), \"Cannot add duplicate property: \" + link.GetLinkName());\n            CS_ASSERT(m_childPropertyLinks.find(link.GetLinkName()) == m_childPropertyLinks.end(), \"Cannot add duplicate property: \" + link.GetLinkName());\n            \n            UIComponent* component = GetComponentWithName(link.GetLinkedOwner());\n            CS_ASSERT(component != nullptr, \"Cannot create property link for property '\" + link.GetLinkName() + \"' because target component '\" + link.GetLinkedOwner() + \"' doesn't exist.\");\n            CS_ASSERT(component->HasProperty(link.GetLinkName()) == true, \"Cannot create property link for property '\" + link.GetLinkName() + \"' because target component '\" +\n                      link.GetLinkedOwner() + \"' doesn't contain a property called '\" + link.GetLinkedProperty() + \"'.\");\n            \n            std::string lowerLinkName = link.GetLinkName();\n            StringUtils::ToLowerCase(lowerLinkName);\n            \n            m_componentPropertyLinks.emplace(lowerLinkName, std::make_pair(component, link.GetLinkedProperty()));\n        }\n        \n        //Hook up any links to our childrens properties\n        for(const auto& link : in_childPropertyLinks)\n        {\n            CS_ASSERT(m_baseProperties.find(link.GetLinkName()) == m_baseProperties.end(), \"Cannot add duplicate property: \" + link.GetLinkName());\n            CS_ASSERT(m_componentPropertyLinks.find(link.GetLinkName()) == m_componentPropertyLinks.end(), \"Cannot add duplicate property: \" + link.GetLinkName());\n            CS_ASSERT(m_childPropertyLinks.find(link.GetLinkName()) == m_childPropertyLinks.end(), \"Cannot add duplicate property: \" + link.GetLinkName());\n            \n            Widget* childWidget = GetInternalWidgetRecursive(link.GetLinkedOwner());\n            CS_ASSERT(childWidget != nullptr, \"Cannot create property link for property '\" + link.GetLinkName() + \"' because target widget '\" + link.GetLinkedOwner() + \"' doesn't exist.\");\n            \n            std::string lowerLinkName = link.GetLinkName();\n            StringUtils::ToLowerCase(lowerLinkName);\n            \n            m_childPropertyLinks.emplace(lowerLinkName, std::make_pair(childWidget, link.GetLinkedProperty()));\n        }\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    void Widget::InitPropertyValues(const PropertyMap& in_propertyMap)\n    {\n        for (const auto& key : in_propertyMap.GetKeys())\n        {\n            if (in_propertyMap.HasValue(key) == true)\n            {\n                SetProperty(key, in_propertyMap.GetPropertyObject(key));\n            }\n        }\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    UIComponent* Widget::GetComponentWithName(const std::string& in_name)\n    {\n        return ConstMethodCast(this, &Widget::GetComponentWithName, in_name);\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    const UIComponent* Widget::GetComponentWithName(const std::string& in_name) const\n    {\n        for (const auto& component : m_components)\n        {\n            if (component->GetName() == in_name)\n            {\n                return component.get();\n            }\n        }\n        \n        return nullptr;\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    IConnectableEvent<Widget::InputDelegate>& Widget::GetPressedInsideEvent()\n    {\n        return m_pressedInsideEvent;\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    IConnectableEvent<Widget::InputDelegate>& Widget::GetReleasedInsideEvent()\n    {\n        return m_releasedInsideEvent;\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    IConnectableEvent<Widget::InputDelegate>& Widget::GetReleasedOutsideEvent()\n    {\n        return m_releasedOutsideEvent;\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    IConnectableEvent<Widget::InputMovedDelegate>& Widget::GetMoveExitedEvent()\n    {\n        return m_moveExitedEvent;\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    IConnectableEvent<Widget::InputMovedDelegate>& Widget::GetMoveEnteredEvent()\n    {\n        return m_moveEnteredEvent;\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    IConnectableEvent<Widget::InputMovedDelegate>& Widget::GetDraggedInsideEvent()\n    {\n        return m_draggedInsideEvent;\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    IConnectableEvent<Widget::InputMovedDelegate>& Widget::GetDraggedOutsideEvent()\n    {\n        return m_draggedOutsideEvent;\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    void Widget::SetName(const std::string& in_name)\n    {\n        m_name = in_name;\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    const std::string& Widget::GetName() const\n    {\n        return m_name;\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    void Widget::SetRelativeSize(const Vector2& in_size)\n    {\n        m_localSize.vRelative = in_size;\n        \n        ForceLayout();\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    Vector2 Widget::GetLocalRelativeSize() const\n    {\n        return m_localSize.vRelative;\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    void Widget::SetAbsoluteSize(const Vector2& in_size)\n    {\n        m_localSize.vAbsolute = in_size;\n        \n        ForceLayout();\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    Vector2 Widget::GetLocalAbsoluteSize() const\n    {\n        return m_localSize.vAbsolute;\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    void Widget::SetDefaultPreferredSize(const Vector2& in_size)\n    {\n        m_preferredSize = in_size;\n        \n        ForceLayout();\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    void Widget::SetSizePolicy(SizePolicy in_policy)\n    {\n        CS_ASSERT(in_policy != SizePolicy::k_totalNum, \"k_totalNum is not a size policy\");\n        \n        m_sizePolicy = in_policy;\n        m_sizePolicyDelegate = SizePolicyFuncs::k_sizePolicyFuncs[(u32)m_sizePolicy];\n        \n        ForceLayout();\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    SizePolicy Widget::GetSizePolicy() const\n    {\n        return m_sizePolicy;\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    void Widget::SetRelativePosition(const Vector2& in_pos)\n    {\n        m_localPosition.vRelative = in_pos;\n        \n        ForceLayout();\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    Vector2 Widget::GetLocalRelativePosition() const\n    {\n        return m_localPosition.vRelative;\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    void Widget::SetAbsolutePosition(const Vector2& in_pos)\n    {\n        m_localPosition.vAbsolute = in_pos;\n        \n        ForceLayout();\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    Vector2 Widget::GetLocalAbsolutePosition() const\n    {\n        return m_localPosition.vAbsolute;\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    void Widget::RelativeMoveBy(const Vector2& in_translate)\n    {\n        m_localPosition.vRelative += in_translate;\n        \n        ForceLayout();\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    void Widget::AbsoluteMoveBy(const Vector2& in_translate)\n    {\n        m_localPosition.vAbsolute += in_translate;\n        \n        ForceLayout();\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    void Widget::RotateBy(f32 in_angleRads)\n    {\n        m_localRotation += in_angleRads;\n        \n        ForceLayout();\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    void Widget::RotateTo(f32 in_angleRads)\n    {\n        m_localRotation = in_angleRads;\n        \n        ForceLayout();\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    f32 Widget::GetLocalRotation() const\n    {\n        return m_localRotation;\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    void Widget::ScaleBy(const Vector2& in_scale)\n    {\n        m_localScale *= in_scale;\n        \n        ForceLayout();\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    void Widget::ScaleTo(const Vector2& in_scale)\n    {\n        m_localScale = in_scale;\n        \n        ForceLayout();\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    Vector2 Widget::GetLocalScale() const\n    {\n        return m_localScale;\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    void Widget::SetParentalAnchor(AlignmentAnchor in_anchor)\n    {\n        m_parentalAnchor = in_anchor;\n        \n        ForceLayout();\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    AlignmentAnchor Widget::GetParentalAnchor() const\n    {\n        return m_parentalAnchor;\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    void Widget::SetOriginAnchor(AlignmentAnchor in_anchor)\n    {\n        m_originAnchor = in_anchor;\n        \n        ForceLayout();\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    AlignmentAnchor Widget::GetOriginAnchor() const\n    {\n        return m_originAnchor;\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    void Widget::SetOriginAbsolutePosition(const Vector2& in_position)\n    {\n        m_originPosition.vAbsolute = in_position;\n        \n        ForceLayout();\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    const Vector2& Widget::GetOriginAbsolutePosition() const\n    {\n        return m_originPosition.vAbsolute;\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    void Widget::SetOriginRelativePosition(const Vector2& in_position)\n    {\n        m_originPosition.vRelative = in_position;\n        \n        ForceLayout();\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    const Vector2& Widget::GetOriginRelativePosition() const\n    {\n        return m_originPosition.vRelative;\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    void Widget::SetColour(const Colour& in_colour)\n    {\n        m_localColour = Colour::Clamp(in_colour);\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    Colour Widget::GetLocalColour() const\n    {\n        return m_localColour;\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    void Widget::SetVisible(bool in_visible)\n    {\n        m_isVisible = in_visible;\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    bool Widget::IsVisible() const\n    {\n        return m_isVisible;\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    void Widget::SetInputEnabled(bool in_input)\n    {\n        bool wasEnabled = m_isInputEnabled;\n        \n        m_isInputEnabled = in_input;\n        \n        if (m_canvas != nullptr)\n        {\n            if (wasEnabled == false && m_isInputEnabled == true)\n            {\n                UpdateAllContainedPointers();\n            }\n            else if (wasEnabled == true && m_isInputEnabled == false)\n            {\n                RemoveAllContainedPointers();\n            }\n        }\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    bool Widget::IsInputEnabled() const\n    {\n        return m_isInputEnabled;\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    void Widget::SetInputConsumeEnabled(bool in_consume)\n    {\n        m_isInputConsumeEnabled = in_consume;\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    bool Widget::IsInputConsumeEnabled() const\n    {\n        return m_isInputConsumeEnabled;\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    void Widget::AddWidget(const WidgetSPtr& in_widget)\n    {\n        CS_ASSERT(in_widget->GetParent() == nullptr, \"Cannot add a widget as a child of more than 1 parent\");\n        CS_ASSERT(m_children.size() < static_cast<std::vector<WidgetSPtr>::size_type>(std::numeric_limits<u32>::max()), \"There are too many widgets in the scene. It cannot exceed \"\n                  + ToString(std::numeric_limits<u32>::max()) + \".\");\n        \n        m_children.push_back(in_widget);\n        in_widget->m_parent = this;\n        \n        if (m_canvas != nullptr)\n        {\n            in_widget->SetCanvas(m_canvas);\n        }\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    void Widget::RemoveWidget(Widget* in_widget)\n    {\n        CS_ASSERT(in_widget->GetParent() == this, \"Widget is a child of a different parent\");\n        \n        for(auto it = std::begin(m_children); it != std::end(m_children); ++it)\n        {\n            if(it->get() == in_widget)\n            {\n                if (m_canvas != nullptr)\n                {\n                    (*it)->SetCanvas(nullptr);\n                }\n                \n                (*it)->m_parent = nullptr;\n                m_children.erase(it);\n                return;\n            }\n        }\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    void Widget::RemoveFromParent()\n    {\n        CS_ASSERT(m_parent != nullptr, \"Widget has no parent to remove from\");\n        \n        m_parent->RemoveWidget(this);\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    WidgetSPtr Widget::GetWidget(const std::string& in_name)\n    {\n        return ConstMethodCast(this, &Widget::GetWidget, in_name);\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    WidgetCSPtr Widget::GetWidget(const std::string& in_name) const\n    {\n        for(const auto& child : m_children)\n        {\n            if(child->m_name == in_name)\n            {\n                return child;\n            }\n        }\n        \n        return nullptr;\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    WidgetSPtr Widget::GetWidgetRecursive(const std::string& in_name)\n    {\n        return ConstMethodCast(this, &Widget::GetWidgetRecursive, in_name);\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    WidgetCSPtr Widget::GetWidgetRecursive(const std::string& in_name) const\n    {\n        for(const auto& child : m_children)\n        {\n            if(child->m_name == in_name)\n            {\n                return child;\n            }\n        }\n        \n        for(const auto& child : m_children)\n        {\n            auto childsChild = child->GetWidgetRecursive(in_name);\n            if (childsChild != nullptr)\n            {\n                return childsChild;\n            }\n        }\n        \n        return nullptr;\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    std::vector<WidgetSPtr> Widget::GetWidgets()\n    {\n        std::vector<WidgetSPtr> children;\n        for(const auto& widget : m_children)\n        {\n            children.push_back(widget);\n        }\n        \n        return children;\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    std::vector<WidgetCSPtr> Widget::GetWidgets() const\n    {\n        std::vector<WidgetCSPtr> children;\n        for(const auto& widget : m_children)\n        {\n            children.push_back(widget);\n        }\n        \n        return children;\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    Widget* Widget::GetInternalWidget(const std::string& in_name)\n    {\n        return ConstMethodCast(this, &Widget::GetInternalWidget, in_name);\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    const Widget* Widget::GetInternalWidget(const std::string& in_name) const\n    {\n        for(const auto& child : m_internalChildren)\n        {\n            if(child->m_name == in_name)\n            {\n                return child.get();\n            }\n        }\n        \n        return nullptr;\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    Widget* Widget::GetInternalWidgetRecursive(const std::string& in_name)\n    {\n        return ConstMethodCast(this, &Widget::GetInternalWidgetRecursive, in_name);\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    const Widget* Widget::GetInternalWidgetRecursive(const std::string& in_name) const\n    {\n        for(const auto& child : m_internalChildren)\n        {\n            if(child->m_name == in_name)\n            {\n                return child.get();\n            }\n        }\n        \n        for(const auto& child : m_internalChildren)\n        {\n            auto childsChild = child->GetWidgetRecursive(in_name);\n            if (childsChild != nullptr)\n            {\n                return childsChild.get();\n            }\n        }\n        \n        return nullptr;\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    std::vector<Widget*> Widget::GetInternalWidgets()\n    {\n        std::vector<Widget*> internalChildren;\n        for(const auto& widget : m_internalChildren)\n        {\n            internalChildren.push_back(widget.get());\n        }\n        \n        return internalChildren;\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    std::vector<const Widget*> Widget::GetInternalWidgets() const\n    {\n        std::vector<const Widget*> internalChildren;\n        for(const auto& widget : m_internalChildren)\n        {\n            internalChildren.push_back(widget.get());\n        }\n        \n        return internalChildren;\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    Widget* Widget::GetParent()\n    {\n        return m_parent;\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    const Widget* Widget::GetParent() const\n    {\n        return m_parent;\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    bool Widget::IsOnCanvas() const\n    {\n        return (m_canvas != nullptr);\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    void Widget::BringToFront()\n    {\n        CS_ASSERT(m_parent != nullptr, \"Widget has no parent to rearrange from\");\n        \n        s32 length = static_cast<s32>(m_parent->m_children.size()) - 1;\n        for(s32 i=0; i<length; ++i)\n        {\n            if(m_parent->m_children[i].get() == this)\n            {\n                std::swap(m_parent->m_children[i], m_parent->m_children[i+1]);\n            }\n        }\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    void Widget::BringForward()\n    {\n        CS_ASSERT(m_parent != nullptr, \"Widget has no parent to rearrange from\");\n        \n        s32 length = static_cast<s32>(m_parent->m_children.size()) - 1;\n        for(s32 i=0; i<length; ++i)\n        {\n            if(m_parent->m_children[i].get() == this)\n            {\n                std::swap(m_parent->m_children[i], m_parent->m_children[i+1]);\n                return;\n            }\n        }\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    void Widget::SendBackward()\n    {\n        CS_ASSERT(m_parent != nullptr, \"Widget has no parent to rearrange from\");\n        \n        auto length = m_parent->m_children.size();\n        for(std::size_t i = 1; i < length; ++i)\n        {\n            if(m_parent->m_children[i].get() == this)\n            {\n                std::swap(m_parent->m_children[i], m_parent->m_children[i-1]);\n                return;\n            }\n        }\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    void Widget::SendToBack()\n    {\n        CS_ASSERT(m_parent != nullptr, \"Widget has no parent to rearrange from\");\n        \n        auto length = m_parent->m_children.size();\n        for(std::size_t i = length-1; i > 1; --i)\n        {\n            if(m_parent->m_children[i].get() == this)\n            {\n                std::swap(m_parent->m_children[i], m_parent->m_children[i-1]);\n            }\n        }\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    void Widget::SetCanvas(const Widget* in_canvas)\n    {\n        CS_ASSERT((in_canvas == nullptr && m_canvas != nullptr) || (in_canvas != nullptr && m_canvas == nullptr), \"Cannot set canvas to null if already null or set to non-null if already not null.\");\n        \n        m_canvas = in_canvas;\n        \n        if (m_canvas == nullptr)\n        {\n            if (m_isInputEnabled == true)\n            {\n                RemoveAllContainedPointers();\n            }\n            \n            for (const auto& component : m_components)\n            {\n                component->OnRemovedFromCanvas();\n            }\n        }\n        \n        for(auto& child : m_internalChildren)\n        {\n            child->SetCanvas(m_canvas);\n        }\n        \n        for(auto& child : m_children)\n        {\n            child->SetCanvas(m_canvas);\n        }\n        \n        if(m_canvas != nullptr)\n        {\n            for (const auto& component : m_components)\n            {\n                component->OnAddedToCanvas();\n            }\n        }\n        \n        ForceLayout();\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    void Widget::SetParent(Widget* in_parent)\n    {\n        m_parent = in_parent;\n        \n        ForceLayout();\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    void Widget::SetProperty(const std::string& in_name, const char* in_value)\n    {\n        SetProperty<std::string>(in_name, in_value);\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    bool Widget::Contains(const Vector2& in_point) const\n    {\n        //Convert the point into our local space allowing us to do an AABB check\n        Vector2 halfSize = GetFinalSize() * 0.5f;\n        \n        Vector2 bottLeft(-halfSize.x, -halfSize.y);\n        Vector2 topRight(halfSize.x, halfSize.y);\n        \n        Vector2 localPoint = ToLocalSpace(in_point, AlignmentAnchor::k_middleCentre);\n        return localPoint.x >= bottLeft.x && localPoint.y >= bottLeft.y && localPoint.x <= topRight.x && localPoint.y <= topRight.y;\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    Vector2 Widget::ToLocalSpace(const Vector2& in_point, AlignmentAnchor in_alignmentAnchor) const\n    {\n        Vector2 localPointCentreRelative = in_point * Matrix3::Inverse(GetFinalTransform());\n        Vector2 localPointAligned = localPointCentreRelative - GetAnchorPoint(in_alignmentAnchor, GetFinalSize());\n        return localPointAligned;\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    Matrix3 Widget::GetLocalTransform() const\n    {\n        if(m_isLocalTransformCacheValid == true)\n        {\n            return m_cachedLocalTransform;\n        }\n        \n        Vector2 anchorPoint = GetLocalOriginCombinedPosition();\n        const Vector2 renderSpacePositionCentred = GetLocalRenderSpaceCombinedPosition() - anchorPoint;\n        \n        Matrix3 pivot(Matrix3::CreateTransform(-anchorPoint, Vector2::k_one, 0.0f));\n        Matrix3 rotate(Matrix3::CreateTransform(Vector2::k_zero, Vector2::k_one, -m_localRotation));\n        Matrix3 translate(Matrix3::CreateTransform(renderSpacePositionCentred + anchorPoint, Vector2::k_one, 0.0f));\n        \n        m_cachedLocalTransform = pivot * rotate * translate;\n        \n        m_isLocalTransformCacheValid = true;\n        return m_cachedLocalTransform;\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    Matrix3 Widget::GetFinalTransform() const\n    {\n        if(m_isParentTransformCacheValid == true && m_isLocalTransformCacheValid == true)\n        {\n            return m_cachedFinalTransform;\n        }\n        \n        if(m_canvas == this)\n        {\n            auto pos = m_localPosition.vAbsolute - GetLocalOriginCombinedPosition();\n            m_cachedFinalTransform = Matrix3::CreateTransform(pos, Vector2::k_one, -m_localRotation);\n            m_cachedFinalPosition = pos;\n            \n            m_isParentTransformCacheValid = true;\n            m_isLocalTransformCacheValid = true;\n            return m_cachedFinalTransform;\n        }\n        \n        m_cachedFinalTransform = GetLocalTransform() * m_parent->GetFinalTransform();\n        m_cachedFinalPosition = GetLocalRenderSpaceCombinedPosition() * m_parent->GetFinalTransform();\n        m_isParentTransformCacheValid = true;\n        \n        return m_cachedFinalTransform;\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    Vector2 Widget::GetFinalPosition() const\n    {\n        //get the final transform to ensure the final position cache is up to date.\n        GetFinalTransform();\n        return m_cachedFinalPosition;\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    Vector2 Widget::GetFinalPositionOfCentre() const\n    {\n        Matrix3 finalTransform(GetFinalTransform());\n        return Vector2(finalTransform.m[6], finalTransform.m[7]);\n    }\n    //----------------------------------------------------------------------------------------\n    /// The position of the widget is calculated based on the local absolute and\n    /// relative positions as well as the local alignment anchors and layout. The local relative\n    /// position is relative to the final parent position and cannot be calculated until\n    /// there is an absolute reference point in the widget hierarchy.\n    //----------------------------------------------------------------------------------------\n    Vector2 Widget::GetLocalRenderSpaceCombinedPosition() const\n    {\n        CS_ASSERT(m_canvas != nullptr, \"Cannot get the local render space combined position of widget without attaching it to the canvas.\");\n        CS_ASSERT(m_parent != nullptr, \"Cannot get the local render space combined position of widget without a parent.\");\n        \n        const Vector2 parentSize(m_parent->GetFinalSize());\n        const Vector2 parentHalfSize(parentSize * 0.5f);\n        \n        auto layoutPair = m_parent->GetLayoutForChild(this);\n        \n        if(layoutPair.first == nullptr)\n        {\n            //Get the anchor point to which the widget is aligned\n            Vector2 parentAnchorPos = GetAnchorPoint(m_parentalAnchor, parentHalfSize);\n            \n            //Calculate the position relative to the anchor point\n            Vector2 localRenderSpacePos = parentAnchorPos + (parentSize * m_localPosition.vRelative) + m_localPosition.vAbsolute;\n            return localRenderSpacePos;\n        }\n        else\n        {\n            CS_ASSERT(layoutPair.second >= 0, \"Cannot find child\");\n            \n            //The parental anchor pertains to the cell when using a layout rather than the parent widget\n            Vector2 parentAnchorPos = GetAnchorPoint(AlignmentAnchor::k_bottomLeft, parentHalfSize);\n            Vector2 cellSize(layoutPair.first->GetSizeForIndex((u32)layoutPair.second));\n            Vector2 cellAnchorPos = GetAnchorPoint(m_parentalAnchor, cellSize * 0.5f);\n            \n            //Transform into local render space then layout/cell space\n            Vector2 localRenderSpacePos = parentAnchorPos;\n            Vector2 layoutSpacePos = cellAnchorPos + (cellSize * m_localPosition.vRelative) + m_localPosition.vAbsolute + layoutPair.first->GetPositionForIndex((u32)layoutPair.second);\n            \n            return localRenderSpacePos + layoutSpacePos;\n        }\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    Vector2 Widget::GetLocalOriginCombinedPosition() const\n    {\n        Vector2 originAnchorPos = GetAnchorPoint(m_originAnchor, GetFinalSize() * 0.5f);\n        Vector2 originPos = originAnchorPos + (GetRelativeReferenceSize() * m_originPosition.vRelative) + m_originPosition.vAbsolute;\n        return originPos;\n    }\n    //----------------------------------------------------------------------------------------\n    /// The final size of the widget is calculated based on the local absolute and the\n    /// local relative size. The local relative size is relative to the final parent size and\n    /// cannot be calculated until there is an absolute reference point in the widget\n    /// hierarchy\n    //----------------------------------------------------------------------------------------\n    Vector2 Widget::GetFinalSize() const\n    {\n        CS_ASSERT(m_canvas != nullptr, \"Cannot get the absolute size of widget without attaching it to the canvas\");\n        \n        if(m_isParentSizeCacheValid == true && m_isLocalSizeCacheValid == true)\n        {\n            return m_cachedFinalSize;\n        }\n        \n        Vector2 finalSize;\n        \n        if(m_parent != nullptr)\n        {\n            finalSize = (m_parent->CalculateRelativeReferenceSizeForChild(this) * m_localSize.vRelative) + m_localSize.vAbsolute;\n        }\n        else\n        {\n            finalSize = m_localSize.vAbsolute;\n        }\n        \n        finalSize = m_sizePolicyDelegate(finalSize, GetPreferredSize()) * m_localScale;\n        \n        m_cachedFinalSize = finalSize;\n        \n        m_isLocalSizeCacheValid = true;\n        m_isParentSizeCacheValid = true;\n        \n        return finalSize;\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    Vector2 Widget::GetRelativeReferenceSize() const\n    {\n        CS_ASSERT(m_canvas != nullptr, \"Cannot get the absolute size of widget without attaching it to the canvas\");\n        \n        if(m_parent != nullptr)\n        {\n            return m_parent->CalculateRelativeReferenceSizeForChild(this);\n        }\n        else\n        {\n            return m_canvas->GetFinalSize();\n        }\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    Vector2 Widget::GetPreferredSize() const\n    {\n        //This should be improved to make the acquisition of preferred size from components\n        //more generic, i.e handled via an interface. This will allow other component types\n        //to also prefer sizes.\n        const DrawableUIComponent* drawableComponent = GetComponent<DrawableUIComponent>();\n        if(drawableComponent != nullptr)\n        {\n            auto drawable = drawableComponent->GetDrawable();\n            if (drawable != nullptr)\n            {\n                return drawable->GetPreferredSize();\n            }\n        }\n        \n        return m_preferredSize;\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    f32 Widget::GetFinalRotation() const\n    {\n        if(m_parent != nullptr)\n        {\n            return m_localRotation + m_parent->GetFinalRotation();\n        }\n        \n        return m_localRotation;\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    Vector2 Widget::GetFinalScale() const\n    {\n        if(m_parent != nullptr)\n        {\n            return m_localScale * m_parent->GetFinalScale();\n        }\n        \n        return m_localScale;\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    Colour Widget::GetFinalColour() const\n    {\n        if(m_parent != nullptr)\n        {\n            return m_localColour * m_parent->GetFinalColour();\n        }\n        \n        return m_localColour;\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    Vector2 Widget::CalculateRelativeReferenceSizeForChild(const Widget* in_child)\n    {\n        auto layoutPair = GetLayoutForChild(in_child);\n        \n        if(layoutPair.first == nullptr)\n        {\n            return (GetFinalSize());\n        }\n        \n        CS_ASSERT(layoutPair.second >= 0, \"Cannot find child\");\n        return layoutPair.first->GetSizeForIndex((u32)layoutPair.second);\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    std::pair<LayoutUIComponent*, s32> Widget::GetLayoutForChild(const Widget* in_child)\n    {\n        LayoutUIComponent* layout = nullptr;\n        s32 childIndex = -1;\n        \n        if (m_layoutComponent != nullptr)\n        {\n            for(u32 i=0; i<m_children.size(); ++i)\n            {\n                if(m_children[i].get() == in_child)\n                {\n                    childIndex = (s32)i;\n                    layout = m_layoutComponent;\n                    break;\n                }\n            }\n        }\n        \n        return std::make_pair(layout, childIndex);\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    void Widget::SetProperty(const std::string& in_propertyName, const IProperty* in_property)\n    {\n        std::string lowerName = in_propertyName;\n        StringUtils::ToLowerCase(lowerName);\n        \n        auto basePropIt = m_baseProperties.find(lowerName);\n        if(basePropIt != m_baseProperties.end())\n        {\n            basePropIt->second->Set(in_property);\n            return;\n        }\n        \n        auto componentPropIt = m_componentPropertyLinks.find(lowerName);\n        if(componentPropIt != m_componentPropertyLinks.end())\n        {\n            componentPropIt->second.first->SetProperty(componentPropIt->second.second, in_property);\n            return;\n        }\n        \n        auto childPropIt = m_childPropertyLinks.find(lowerName);\n        if(childPropIt != m_childPropertyLinks.end())\n        {\n            childPropIt->second.first->SetProperty(childPropIt->second.second, in_property);\n            return;\n        }\n        \n        CS_LOG_FATAL(\"Invalid property name for Widget: \" + in_propertyName);\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void Widget::UpdateContainedPointer(const Pointer& in_pointer)\n    {\n        auto pointerIdIt = m_containedPointers.find(in_pointer.GetId());\n        \n        bool wasContained = (pointerIdIt != m_containedPointers.end());\n        bool isContained = Contains(in_pointer.GetPosition());\n        \n        if (wasContained == false && isContained == true)\n        {\n            m_containedPointers.insert(in_pointer.GetId());\n            m_moveEnteredEvent.NotifyConnections(this, in_pointer);\n        }\n        else if (wasContained == true && isContained == false)\n        {\n            m_containedPointers.erase(pointerIdIt);\n            m_moveExitedEvent.NotifyConnections(this, in_pointer);\n        }\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void Widget::RemoveContainedPointer(const Pointer& in_pointer)\n    {\n        auto pointerIdIt = m_containedPointers.find(in_pointer.GetId());\n        if (pointerIdIt != m_containedPointers.end())\n        {\n            m_containedPointers.erase(pointerIdIt);\n            m_moveExitedEvent.NotifyConnections(this, in_pointer);\n        }\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void Widget::UpdateAllContainedPointers()\n    {\n        auto pointers = m_pointerSystem->GetPointers();\n        for (const auto& pointer : pointers)\n        {\n            UpdateContainedPointer(pointer);\n        }\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void Widget::RemoveAllContainedPointers()\n    {\n        auto pointers = m_pointerSystem->GetPointers();\n        for (const auto& pointer : pointers)\n        {\n            RemoveContainedPointer(pointer);\n        }\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    bool Widget::IsContainedPointer(const Pointer& in_pointer)\n    {\n        return (m_containedPointers.find(in_pointer.GetId()) != m_containedPointers.end());\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    void Widget::OnParentTransformChanged()\n    {\n        m_isParentTransformCacheValid = false;\n        m_isParentSizeCacheValid = false;\n        \n        ForceLayout();\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    void Widget::OnResume()\n    {\n        CS_ASSERT(m_canvas != nullptr, \"Cannot resume without a canvas.\");\n        \n        for (const auto& component : m_components)\n        {\n            component->OnResume();\n        }\n        \n        m_internalChildren.lock();\n        for(auto& child : m_internalChildren)\n        {\n            child->OnResume();\n        }\n        m_internalChildren.unlock();\n        \n        m_children.lock();\n        for(auto& child : m_children)\n        {\n            child->OnResume();\n        }\n        m_children.unlock();\n        \n        ForceLayout();\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    void Widget::OnForeground()\n    {\n        for (const auto& component : m_components)\n        {\n            component->OnForeground();\n        }\n        \n        m_internalChildren.lock();\n        for(auto& child : m_internalChildren)\n        {\n            child->OnForeground();\n        }\n        m_internalChildren.unlock();\n        \n        m_children.lock();\n        for(auto& child : m_children)\n        {\n            child->OnForeground();\n        }\n        m_children.unlock();\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    void Widget::OnUpdate(f32 in_timeSinceLastUpdate)\n    {\n        for (const auto& component : m_components)\n        {\n            component->OnUpdate(in_timeSinceLastUpdate);\n        }\n        \n        m_internalChildren.lock();\n        for(auto& child : m_internalChildren)\n        {\n            child->OnUpdate(in_timeSinceLastUpdate);\n        }\n        m_internalChildren.unlock();\n        \n        m_children.lock();\n        for(auto& child : m_children)\n        {\n            child->OnUpdate(in_timeSinceLastUpdate);\n        }\n        m_children.unlock();\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    void Widget::OnDraw(CanvasRenderer* in_renderer)\n    {\n        if(m_isVisible == false)\n        {\n            return;\n        }\n        \n        Vector2 finalSize(GetFinalSize());\n        \n        if (ShouldCull(GetFinalPositionOfCentre(), finalSize, m_screen->GetResolution()) == false)\n        {\n            for (auto& component : m_components)\n            {\n                component->OnDraw(in_renderer, GetFinalTransform(), finalSize, GetFinalColour());\n            }\n        }\n        \n        for (auto& component : m_components)\n        {\n            component->OnPreDrawChildren(in_renderer);\n        }\n        \n        m_internalChildren.lock();\n        for(auto& child : m_internalChildren)\n        {\n            child->OnDraw(in_renderer);\n        }\n        m_internalChildren.unlock();\n        \n        m_children.lock();\n        for(auto& child : m_children)\n        {\n            child->OnDraw(in_renderer);\n        }\n        m_children.unlock();\n        \n        for (auto& component : m_components)\n        {\n            component->OnPostDrawChildren(in_renderer);\n        }\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    void Widget::OnBackground()\n    {\n        m_children.lock();\n        for(auto& child : m_children)\n        {\n            child->OnBackground();\n        }\n        m_children.unlock();\n        \n        m_internalChildren.lock();\n        for(auto& child : m_internalChildren)\n        {\n            child->OnBackground();\n        }\n        m_internalChildren.unlock();\n        \n        for (const auto& component : m_components)\n        {\n            component->OnBackground();\n        }\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    void Widget::OnSuspend()\n    {\n        CS_ASSERT(m_canvas != nullptr, \"Cannot suspend without a canvas.\");\n        \n        if (m_isInputEnabled == true)\n        {\n            RemoveAllContainedPointers();\n        }\n        \n        m_children.lock();\n        for(auto& child : m_children)\n        {\n            child->OnSuspend();\n        }\n        m_children.unlock();\n        \n        m_internalChildren.lock();\n        for(auto& child : m_internalChildren)\n        {\n            child->OnSuspend();\n        }\n        m_internalChildren.unlock();\n        \n        for (const auto& component : m_components)\n        {\n            component->OnSuspend();\n        }\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    void Widget::ForceLayout()\n    {\n        m_isLocalTransformCacheValid = false;\n        m_isLocalSizeCacheValid = false;\n        \n        if(m_canvas != nullptr)\n        {\n            if(m_layoutComponent != nullptr)\n            {\n                m_layoutComponent->BuildLayout();\n            }\n        }\n        \n        for(auto& child : m_internalChildren)\n        {\n            child->OnParentTransformChanged();\n        }\n        \n        for(auto& child : m_children)\n        {\n            child->OnParentTransformChanged();\n        }\n        \n        if (m_canvas != nullptr && m_isInputEnabled == true)\n        {\n            UpdateAllContainedPointers();\n        }\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void Widget::OnPointerAdded(const Pointer& in_pointer, f64 in_timestamp)\n    {\n        if(m_isInputEnabled == false)\n            return;\n        \n        m_children.lock();\n        for(auto it = m_children.rbegin(); it != m_children.rend(); ++it)\n        {\n            (*it)->OnPointerAdded(in_pointer, in_timestamp);\n        }\n        m_children.unlock();\n        \n        m_internalChildren.lock();\n        for(auto it = m_internalChildren.rbegin(); it != m_internalChildren.rend(); ++it)\n        {\n            (*it)->OnPointerAdded(in_pointer, in_timestamp);\n        }\n        m_internalChildren.unlock();\n        \n        UpdateContainedPointer(in_pointer);\n    }\n    //------------------------------------------------------------------------------\n    /// UI can filter input events to prevent them from being forwarded to the\n    /// external app. Input events are notified from the front most child widget to\n    /// the back most and can be consumed.\n    //------------------------------------------------------------------------------\n    void Widget::OnPointerDown(const Pointer& in_pointer, f64 in_timestamp, Pointer::InputType in_inputType, InputFilter& in_filter)\n    {\n        if(m_isInputEnabled == false)\n            return;\n        \n        m_children.lock();\n        for(auto it = m_children.rbegin(); it != m_children.rend(); ++it)\n        {\n            (*it)->OnPointerDown(in_pointer, in_timestamp, in_inputType, in_filter);\n            \n            if(in_filter.IsFiltered() == true)\n            {\n                m_children.unlock();\n                return;\n            }\n        }\n        m_children.unlock();\n        \n        m_internalChildren.lock();\n        for(auto it = m_internalChildren.rbegin(); it != m_internalChildren.rend(); ++it)\n        {\n            (*it)->OnPointerDown(in_pointer, in_timestamp, in_inputType, in_filter);\n            \n            if(in_filter.IsFiltered() == true)\n            {\n                m_internalChildren.unlock();\n                return;\n            }\n        }\n        m_internalChildren.unlock();\n        \n        UpdateContainedPointer(in_pointer);\n        if(IsContainedPointer(in_pointer) == true)\n        {\n            //Track the input that is down on the widget as\n            //this will effect how we trigger the release events\n            auto it = m_pressedInput.find(in_pointer.GetId());\n            if (it != m_pressedInput.end())\n            {\n                it->second.insert(in_inputType);\n            }\n            else\n            {\n                std::set<Pointer::InputType> inputTypeSet = { in_inputType };\n                m_pressedInput.emplace(in_pointer.GetId(), inputTypeSet);\n            }\n            \n            m_pressedInsideEvent.NotifyConnections(this, in_pointer, in_inputType);\n            \n            if(m_isInputConsumeEnabled == true)\n            {\n                in_filter.SetFiltered();\n            }\n        }\n    }\n    //------------------------------------------------------------------------------\n    /// UI can filter input events to prevent them from being forwarded to the\n    /// external app.\n    //------------------------------------------------------------------------------\n    void Widget::OnPointerMoved(const Pointer& in_pointer, f64 in_timestamp)\n    {\n        if(m_isInputEnabled == false)\n            return;\n        \n        m_children.lock();\n        for(auto it = m_children.rbegin(); it != m_children.rend(); ++it)\n        {\n            (*it)->OnPointerMoved(in_pointer, in_timestamp);\n        }\n        m_children.unlock();\n        \n        m_internalChildren.lock();\n        for(auto it = m_internalChildren.rbegin(); it != m_internalChildren.rend(); ++it)\n        {\n            (*it)->OnPointerMoved(in_pointer, in_timestamp);\n        }\n        m_internalChildren.unlock();\n        \n        bool containsPrevious = IsContainedPointer(in_pointer);\n        UpdateContainedPointer(in_pointer);\n        bool containsCurrent = IsContainedPointer(in_pointer);\n        \n        if (containsPrevious == false && containsCurrent == false)\n        {\n            auto itPressedInput = m_pressedInput.find(in_pointer.GetId());\n            if (itPressedInput != m_pressedInput.end())\n            {\n                m_draggedOutsideEvent.NotifyConnections(this, in_pointer);\n            }\n        }\n        else if (containsPrevious == true && containsCurrent == true)\n        {\n            auto itPressedInput = m_pressedInput.find(in_pointer.GetId());\n            if (itPressedInput != m_pressedInput.end())\n            {\n                m_draggedInsideEvent.NotifyConnections(this, in_pointer);\n            }\n        }\n    }\n    //------------------------------------------------------------------------------\n    /// UI can filter input events to prevent them from being forwarded to the\n    /// external app.\n    //------------------------------------------------------------------------------\n    void Widget::OnPointerUp(const Pointer& in_pointer, f64 in_timestamp, Pointer::InputType in_inputType)\n    {\n        if(m_isInputEnabled == false)\n            return;\n        \n        m_children.lock();\n        for(auto it = m_children.rbegin(); it != m_children.rend(); ++it)\n        {\n            (*it)->OnPointerUp(in_pointer, in_timestamp, in_inputType);\n        }\n        m_children.unlock();\n        \n        m_internalChildren.lock();\n        for(auto it = m_internalChildren.rbegin(); it != m_internalChildren.rend(); ++it)\n        {\n            (*it)->OnPointerUp(in_pointer, in_timestamp, in_inputType);\n        }\n        m_internalChildren.unlock();\n        \n        UpdateContainedPointer(in_pointer);\n        auto itPressedInput = m_pressedInput.find(in_pointer.GetId());\n        if (itPressedInput != m_pressedInput.end())\n        {\n            auto itPressedInputType = itPressedInput->second.find(in_inputType);\n            if (itPressedInputType != itPressedInput->second.end())\n            {\n                itPressedInput->second.erase(itPressedInputType);\n                if (itPressedInput->second.empty() == true)\n                {\n                    m_pressedInput.erase(itPressedInput);\n                }\n\n                if(IsContainedPointer(in_pointer) == true)\n                {\n                    m_releasedInsideEvent.NotifyConnections(this, in_pointer, in_inputType);\n                }\n                else\n                {\n                    m_releasedOutsideEvent.NotifyConnections(this, in_pointer, in_inputType);\n                }\n            }\n        }\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void Widget::OnPointerRemoved(const Pointer& in_pointer, f64 in_timestamp)\n    {\n        if(m_isInputEnabled == false)\n            return;\n        \n        m_children.lock();\n        for(auto it = m_children.rbegin(); it != m_children.rend(); ++it)\n        {\n            (*it)->OnPointerRemoved(in_pointer, in_timestamp);\n        }\n        m_children.unlock();\n        \n        m_internalChildren.lock();\n        for(auto it = m_internalChildren.rbegin(); it != m_internalChildren.rend(); ++it)\n        {\n            (*it)->OnPointerRemoved(in_pointer, in_timestamp);\n        }\n        m_internalChildren.unlock();\n        \n        RemoveContainedPointer(in_pointer);\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    Widget::~Widget()\n    {\n        CS_ASSERT(m_canvas == this || m_canvas == nullptr, \"Canvas should be null at this point!\");\n        \n        //First destroy children in reverse order\n        while (m_children.rbegin() != m_children.rend())\n        {\n            RemoveWidget((*m_children.rbegin()).get());\n        }\n        \n        //Then Call onDestroy on components in reverse order\n        for (auto componentIt = m_components.rbegin(); componentIt != m_components.rend(); ++componentIt)\n        {\n            (*componentIt)->OnDestroy();\n        }\n        \n        //Then we remove the internal widgets\n        while (m_internalChildren.rbegin() != m_internalChildren.rend())\n        {\n            auto internalChildIt = m_internalChildren.rbegin();\n\n            (*internalChildIt)->m_canvas = nullptr;\n            (*internalChildIt)->m_parent = nullptr;\n            \n            m_internalChildren.erase(internalChildIt);\n        }\n        \n        m_components.clear();\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/UI/Base/Widget.h",
    "content": "//\n//  Widget.h\n//  ChilliSource\n//  Created by Scott Downie on 17/04/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_UI_BASE_WIDGET_H_\n#define _CHILLISOURCE_UI_BASE_WIDGET_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Base/Colour.h>\n#include <ChilliSource/Core/Base/ConstMethodCast.h>\n#include <ChilliSource/Core/Container/concurrent_vector.h>\n#include <ChilliSource/Core/Container/Property/PropertyMap.h>\n#include <ChilliSource/Core/Event/Event.h>\n#include <ChilliSource/Core/Event/EventConnection.h>\n#include <ChilliSource/Core/Math/Matrix3.h>\n#include <ChilliSource/Core/Math/UnifiedCoordinates.h>\n#include <ChilliSource/Input/Base/InputFilter.h>\n#include <ChilliSource/Input/Pointer/Pointer.h>\n#include <ChilliSource/Rendering/Base/AlignmentAnchors.h>\n#include <ChilliSource/Rendering/Base/SizePolicy.h>\n#include <ChilliSource/UI/Base/UIComponent.h>\n#include <ChilliSource/UI/Base/PropertyLink.h>\n\n#include <cassert>\n#include <functional>\n#include <mutex>\n#include <unordered_set>\n\nnamespace ChilliSource\n{\n    //----------------------------------------------------------------------------------------\n    /// The Widget class that holds the components for laying out, rendering and manipulating\n    /// UI widgets. A widget can be a single widget or a collection of widgets. Widgets can be\n    /// added to other widgets to create a hierarchy. Widgets are layed out using a mixture of\n    /// absolute and relative coordinates in which relative coordinates are relative to the\n    /// parent.\n    ///\n    /// Some widgets have private 'internal' child widgets. These are not exposed through APIs\n    /// like GetWidget() and allow the widget to be treated as a solid black box while\n    /// maintaining the flexibility  of building widgets from smaller blocks.\n    ///\n    /// The default properties exposed to UI files are as follows:\n    ///\n    /// \"Name\": A string used to identity a widget.\n    ///\n    /// \"RelPosition\": A Vector2 describing the position of local anchor relative to parent\n    /// anchor and parent size.\n    ///\n    /// \"AbsPosition\" A Vector2 describing the absolute position of local anchor relative to\n    /// parent anchor.\n    ///\n    /// \"RelSize\": A Vector2 describing the size relative to the parent size.\n    ///\n    /// \"AbsSize\": A Vector2 describing the absolute size.\n    ///\n    /// \"PreferredSize\": A Vector2 describing the default prefered size. This may be overriden\n    /// by the prefered size of certain components.\n    ///\n    /// \"Scale\": A Vector2 describing the scale of the widget.\n    ///\n    /// \"Rotation\": A float describing the rotation of a widget in radians.\n    ///\n    /// \"Colour\": The colour of the widget.\n    ///\n    /// \"Visible\": A boolean describing whether or not the widget and it's children are visible.\n    ///\n    /// \"OriginAnchor\": The anchor point of the widgets origin. Possible values are: 'TopLeft',\n    /// 'TopCentre', 'TopRight', 'MiddleLeft', 'MiddleCentre', 'MiddleRight', 'BottomLeft',\n    /// 'BottomCentre', 'BottomRight'\n    ///\n    /// \"ParentalAnchor\": The anchor in the parent that local coordinates are relative to.\n    /// Possible values are: 'TopLeft', 'TopCentre', 'TopRight', 'MiddleLeft', 'MiddleCentre',\n    /// 'MiddleRight', 'BottomLeft', 'BottomCentre', 'BottomRight'\n    ///\n    /// \"SizePolicy\": A description of how the widget will be sized if the aspect ratio of the\n    /// widget differs from the perferred size. The possible values are: 'None', 'UsePreferredSize',\n    /// 'UseWidthMaintainingAspect', 'UseHeightMaintainingAspect', 'FitMaintainingAspect',\n    /// 'FillMaintainingAspect'\n    ///\n    /// @author S Downie\n    //----------------------------------------------------------------------------------------\n    class Widget final\n    {\n    public:\n\n        CS_DECLARE_NOCOPY(Widget);\n        //----------------------------------------------------------------------------------------\n        /// Delegate for size policy functions.\n        ///\n        /// @author S Downie\n        ///\n        /// @param Widget absolute size\n        /// @param Widget absolute preferred size\n        ///\n        /// @return New size with function applied\n        //----------------------------------------------------------------------------------------\n        using SizePolicyDelegate = std::function<Vector2(const Vector2&, const Vector2&)>;\n        //----------------------------------------------------------------------------------------\n        /// Delegate for standard input events such as pressed and released.\n        ///\n        /// @author S Downie\n        ///\n        /// @param Widget that the input event occurred on\n        /// @param The pointer.\n        /// @param The input that triggered the event\n        //----------------------------------------------------------------------------------------\n        using InputDelegate = std::function<void(Widget*, const Pointer&, Pointer::InputType)>;\n        //----------------------------------------------------------------------------------------\n        /// Delegate for moving input events.\n        ///\n        /// @author S Downie\n        ///\n        /// @param Widget that the input event occurred on\n        /// @param The pointer\n        //----------------------------------------------------------------------------------------\n        using InputMovedDelegate = std::function<void(Widget*, const Pointer&)>;\n        //----------------------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return The list of properties supported by widget\n        //----------------------------------------------------------------------------------------\n        static std::vector<PropertyMap::PropertyDesc> GetPropertyDescs();\n        //----------------------------------------------------------------------------------------\n        /// Event triggered when a pointer is pressed inside the widget\n        ///\n        /// @author S Downie\n        ///\n        /// @return Connectable event\n        //----------------------------------------------------------------------------------------\n        IConnectableEvent<InputDelegate>& GetPressedInsideEvent();\n        //----------------------------------------------------------------------------------------\n        /// Event triggered when a pointer is released inside the widget if it was originally pressed\n        /// within the widget.\n        ///\n        /// NOTE: This event is best to use for buttons.\n        ///\n        /// @author S Downie\n        ///\n        /// @return Connectable event\n        //----------------------------------------------------------------------------------------\n        IConnectableEvent<InputDelegate>& GetReleasedInsideEvent();\n        //----------------------------------------------------------------------------------------\n        /// Event triggered when a pointer is released outside the widget if it was originally pressed within\n        /// the widget\n        ///\n        /// @author S Downie\n        ///\n        /// @return Connectable event\n        //----------------------------------------------------------------------------------------\n        IConnectableEvent<InputDelegate>& GetReleasedOutsideEvent();\n        //----------------------------------------------------------------------------------------\n        /// Event triggered when a pointer is moved outwith the widget having previously been\n        /// within it\n        ///\n        /// @author S Downie\n        ///\n        /// @return Connectable event\n        //----------------------------------------------------------------------------------------\n        IConnectableEvent<InputMovedDelegate>& GetMoveExitedEvent();\n        //----------------------------------------------------------------------------------------\n        /// Event triggered when a pointer is moved inside the widget have previously been outwith it\n        ///\n        /// @author S Downie\n        ///\n        /// @return Connectable event\n        //----------------------------------------------------------------------------------------\n        IConnectableEvent<InputMovedDelegate>& GetMoveEnteredEvent();\n        //----------------------------------------------------------------------------------------\n        /// Event triggered when a pointer is moved within the widget if it was originally pressed\n        /// within the widget while one or more of the input buttons are down\n        ///\n        /// @author S Downie\n        ///\n        /// @return Connectable event\n        //----------------------------------------------------------------------------------------\n        IConnectableEvent<InputMovedDelegate>& GetDraggedInsideEvent();\n        //----------------------------------------------------------------------------------------\n        /// Event triggered when a pointer is moved outwith the widget if it was originally pressed\n        /// within the widget and while one or more of the input buttons are down\n        ///\n        /// @author S Downie\n        ///\n        /// @return Connectable event\n        //----------------------------------------------------------------------------------------\n        IConnectableEvent<InputMovedDelegate>& GetDraggedOutsideEvent();\n        //----------------------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Name of widget\n        //----------------------------------------------------------------------------------------\n        void SetName(const std::string& in_name);\n        //----------------------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Name of widget\n        //----------------------------------------------------------------------------------------\n        const std::string& GetName() const;\n        //----------------------------------------------------------------------------------------\n        /// Set the percentage size of the widget relative to its parent size i.e. 0.5, 0.5 will\n        /// make the widget half the width of the parent and half the height\n        ///\n        /// @author S Downie\n        ///\n        /// @param Percentage size of parent (0.0 - 1.0, 0.0 - 1.0)\n        //----------------------------------------------------------------------------------------\n        void SetRelativeSize(const Vector2& in_size);\n        //----------------------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Percentage size of parent (0.0 - 1.0, 0.0 - 1.0)\n        //----------------------------------------------------------------------------------------\n        Vector2 GetLocalRelativeSize() const;\n        //----------------------------------------------------------------------------------------\n        /// Set the size of the widget in pixels\n        ///\n        /// @author S Downie\n        ///\n        /// @param Size in pixels\n        //----------------------------------------------------------------------------------------\n        void SetAbsoluteSize(const Vector2& in_size);\n        //----------------------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Size in pixels\n        //----------------------------------------------------------------------------------------\n        Vector2 GetLocalAbsoluteSize() const;\n        //----------------------------------------------------------------------------------------\n        /// The default preferred size is used in cases when there is no drawable to query for its\n        /// preferred size. The preferred size is used to maintain aspect ratio depending on the\n        /// aspect policy.\n        ///\n        /// @author S Downie\n        ///\n        /// @param The preferred size of the widget in absolutes\n        //----------------------------------------------------------------------------------------\n        void SetDefaultPreferredSize(const Vector2& in_size);\n        //----------------------------------------------------------------------------------------\n        /// Set the function that will be used to alter the size in order to maintain the\n        /// aspect ratio of the widget. This is usually based on the drawable image size and aspect\n        ///\n        /// @author S Downie\n        ///\n        /// @param Size policy\n        //----------------------------------------------------------------------------------------\n        void SetSizePolicy(SizePolicy in_policy);\n        //----------------------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Size policy\n        //----------------------------------------------------------------------------------------\n        SizePolicy GetSizePolicy() const;\n        //----------------------------------------------------------------------------------------\n        /// Set the position of the widget relative to its parent size and anchor point i.e.\n        /// if the anchor is bottom left then 0.5, 0.5 will place it in the middle of the parent\n        ///\n        /// @author S Downie\n        ///\n        /// @param Offset as percentage size of parent (0.0 - 1.0, 0.0 - 1.0)\n        //----------------------------------------------------------------------------------------\n        void SetRelativePosition(const Vector2& in_pos);\n        //----------------------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Offset as percentage size of parent (0.0 - 1.0, 0.0 - 1.0)\n        //----------------------------------------------------------------------------------------\n        Vector2 GetLocalRelativePosition() const;\n        //----------------------------------------------------------------------------------------\n        /// Set the position of the widget from the parental anchor in pixels\n        ///\n        /// @author S Downie\n        ///\n        /// @param Position in pixels from parent anchor\n        //----------------------------------------------------------------------------------------\n        void SetAbsolutePosition(const Vector2& in_pos);\n        //----------------------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Position in pixels from parent anchor\n        //----------------------------------------------------------------------------------------\n        Vector2 GetLocalAbsolutePosition() const;\n        //----------------------------------------------------------------------------------------\n        /// Move the position of the widget from the parental anchor by the given percentages\n        /// of the parent height and width\n        ///\n        /// @author S Downie\n        ///\n        /// @param Offset as percentage size of parent (0.0 - 1.0, 0.0 - 1.0)\n        //----------------------------------------------------------------------------------------\n        void RelativeMoveBy(const Vector2& in_translate);\n        //----------------------------------------------------------------------------------------\n        /// Move the position of the widget from the parental anchor by the given pixels\n        ///\n        /// @author S Downie\n        ///\n        /// @param Translation in pixels\n        //----------------------------------------------------------------------------------------\n        void AbsoluteMoveBy(const Vector2& in_translate);\n        //----------------------------------------------------------------------------------------\n        /// Rotate the widget about its origin by the given radians\n        ///\n        /// @author S Downie\n        ///\n        /// @param Angle or rotation in radians\n        //----------------------------------------------------------------------------------------\n        void RotateBy(f32 in_angleRads);\n        //----------------------------------------------------------------------------------------\n        /// Rotate the widget about its origin to the given radians\n        ///\n        /// @author S Downie\n        ///\n        /// @param Angle or rotation in radians\n        //----------------------------------------------------------------------------------------\n        void RotateTo(f32 in_angleRads);\n        //----------------------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Rotation in radians without any parent rotation applied\n        //----------------------------------------------------------------------------------------\n        f32 GetLocalRotation() const;\n        //----------------------------------------------------------------------------------------\n        /// Scale the widgets current size about its origin by the given scaler\n        ///\n        /// @author S Downie\n        ///\n        /// @param Scaler width and height\n        //----------------------------------------------------------------------------------------\n        void ScaleBy(const Vector2& in_scale);\n        //----------------------------------------------------------------------------------------\n        /// Scale the widgets current size about its origin to the given scaler\n        ///\n        /// @author S Downie\n        ///\n        /// @param Scaler width and height\n        //----------------------------------------------------------------------------------------\n        void ScaleTo(const Vector2& in_scale);\n        //----------------------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Local scale X Y\n        //----------------------------------------------------------------------------------------\n        Vector2 GetLocalScale() const;\n        //----------------------------------------------------------------------------------------\n        /// Set the alignment anchor of the widget to its parent i.e. if the anchor is middle\n        /// centre then the origin of the widget will be at the middle centre of the parent\n        ///\n        /// @author S Downie\n        ///\n        /// @param Alignment anchor\n        //----------------------------------------------------------------------------------------\n        void SetParentalAnchor(AlignmentAnchor in_anchor);\n        //----------------------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Alignment anchor\n        //----------------------------------------------------------------------------------------\n        AlignmentAnchor GetParentalAnchor() const;\n        //----------------------------------------------------------------------------------------\n        /// Sets the anchor to which the widget's origin position is aligned. The widgets origin\n        /// is the position which the object is rendered and at the position arround which it will\n        /// be rotated.\n        ///\n        /// @author S Downie\n        ///\n        /// @param The alignment anchor\n        //----------------------------------------------------------------------------------------\n        void SetOriginAnchor(AlignmentAnchor in_anchor);\n        //----------------------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return The anchor to which the widget's origin position is aligned. The widgets origin\n        /// is the position which the object is rendered and at the position arround which it will\n        /// be rotated.\n        //----------------------------------------------------------------------------------------\n        AlignmentAnchor GetOriginAnchor() const;\n        //----------------------------------------------------------------------------------------\n        /// Sets the widget origin's absolute position. The widgets origin is the position which\n        /// the object is rendered and at the position arround which it will  be rotated. This\n        /// position is relative to the Origin Anchor.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The origin's absolute position.\n        //----------------------------------------------------------------------------------------\n        void SetOriginAbsolutePosition(const Vector2& in_position);\n        //----------------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param The widget's origin absolute position. The widgets origin is the position which\n        /// the object is rendered and at the position arround which it will  be rotated. This\n        /// position is relative to the Origin Anchor.\n        //----------------------------------------------------------------------------------------\n        const Vector2& GetOriginAbsolutePosition() const;\n        //----------------------------------------------------------------------------------------\n        /// Sets the widget origin's relative position. The widgets origin is the position which\n        /// the object is rendered and at the position arround which it will  be rotated. This\n        /// position is relative to the Origin Anchor.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The origin's relative position.\n        //----------------------------------------------------------------------------------------\n        void SetOriginRelativePosition(const Vector2& in_position);\n        //----------------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param The widget's origin relative position. The widgets origin is the position which\n        /// the object is rendered and at the position arround which it will  be rotated. This\n        /// position is relative to the Origin Anchor.\n        //----------------------------------------------------------------------------------------\n        const Vector2& GetOriginRelativePosition() const;\n        //----------------------------------------------------------------------------------------\n        /// Set the colour that is multiplied into the widget. Widgets inherit their parent's\n        /// colour.\n        ///\n        /// @author S Downie\n        ///\n        /// @param Colour\n        //----------------------------------------------------------------------------------------\n        void SetColour(const Colour& in_colour);\n        //----------------------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Local colour\n        //----------------------------------------------------------------------------------------\n        Colour GetLocalColour() const;\n        //----------------------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Set whether the widget hierarchy from here down is visible\n        //----------------------------------------------------------------------------------------\n        void SetVisible(bool in_visible);\n        //----------------------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Whether the widget hierarchy from here down is visible\n        //----------------------------------------------------------------------------------------\n        bool IsVisible() const;\n        //----------------------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Whether the widget should accept and respond to user input\n        //----------------------------------------------------------------------------------------\n        void SetInputEnabled(bool in_input);\n        //----------------------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Whether the widget accepts and responds to user input\n        //----------------------------------------------------------------------------------------\n        bool IsInputEnabled() const;\n        //----------------------------------------------------------------------------------------\n        /// Set whether this widget consumes input events and prevents them being continuing down the\n        /// event chain. Only press and release events are consumed.\n        ///\n        /// @author S Downie\n        ///\n        /// @param Whether press and release input events are consumed\n        //----------------------------------------------------------------------------------------\n        void SetInputConsumeEnabled(bool in_consume);\n        //----------------------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Whether press and release input events are consumed\n        //----------------------------------------------------------------------------------------\n        bool IsInputConsumeEnabled() const;\n        //----------------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return the first component found of the specified type or nullptr if there isn't one.\n        //----------------------------------------------------------------------------------------\n        template <typename TComponentType> TComponentType* GetComponent();\n        //----------------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return A const version of the first component found of the specified type or nullptr\n        /// if there isn't one.\n        //----------------------------------------------------------------------------------------\n        template <typename TComponentType> const TComponentType* GetComponent() const;\n        //----------------------------------------------------------------------------------------\n        /// Adds a widget as a child of this widget. The widget will be rendered as part of this\n        /// hierarchy and any relative coordinates will now be in relation to this widget.\n        ///\n        /// NOTE: Will assert if the widget already has a parent\n        ///\n        /// @author S Downie\n        ///\n        /// @param Widget to add\n        //----------------------------------------------------------------------------------------\n        void AddWidget(const WidgetSPtr& in_widget);\n        //----------------------------------------------------------------------------------------\n        /// Remove the child widget from this widget. It will no longer be rendered and may\n        /// be destroyed if this is the last reference.\n        ///\n        /// NOTE: Will assert if the parents do not match\n        ///\n        /// @author S Downie\n        ///\n        /// @param Widget to remove\n        //----------------------------------------------------------------------------------------\n        void RemoveWidget(Widget* in_widget);\n        //----------------------------------------------------------------------------------------\n        /// Remove the widget from the child list of its parent. It will no longer be rendered and may\n        /// be destroyed if the parent holds the last reference\n        ///\n        /// NOTE: Will assert if has no parent\n        ///\n        /// @author S Downie\n        //----------------------------------------------------------------------------------------\n        void RemoveFromParent();\n        //----------------------------------------------------------------------------------------\n        /// Searches the immediate children for a widget with the given name and returns it.\n        /// If the child cannot be found this will return null. If there are multiple children\n        /// with the name the first with be returned.\n        ///\n        /// @author S Downie\n        ///\n        /// @return The child with the given name or null if one doesn't exist.\n        //----------------------------------------------------------------------------------------\n        WidgetSPtr GetWidget(const std::string& in_name);\n        //----------------------------------------------------------------------------------------\n        /// Searches the immediate children for a widget with the given name and returns a\n        /// constant version of it. If the child cannot be found this will return null. If there\n        /// are multiple children with the name the first found will be returned.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @return A constant version of the child with the given name or null if one doesn't\n        /// exist.\n        //----------------------------------------------------------------------------------------\n        WidgetCSPtr GetWidget(const std::string& in_name) const;\n        //----------------------------------------------------------------------------------------\n        /// Recurses through the widget hierarchy seaching for a widget with the given name and\n        /// returns it. If the child cannot be found this will return null. If there are multiple\n        /// children with the same name the first found will be returned. The hierarchy will be\n        /// navigated breadth first.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @return The child with the given name or null if one doesn't exist.\n        //----------------------------------------------------------------------------------------\n        WidgetSPtr GetWidgetRecursive(const std::string& in_name);\n        //----------------------------------------------------------------------------------------\n        /// Recurses through the widget hierarchy seaching for a widget with the given name and\n        /// returns a constant version of it. If the child cannot be found this will return null.\n        /// If there are multiple children with the same name the first found will be returned.\n        /// The hierarchy will be navigated breadth first.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @return A constant version of the child with the given name or null if one doesn't\n        /// exist.\n        //----------------------------------------------------------------------------------------\n        WidgetCSPtr GetWidgetRecursive(const std::string& in_name) const;\n        //----------------------------------------------------------------------------------------\n        /// Returns a list of the widgets immediate children. A copy of the internal list is\n        /// created so this is relatively expensive if the widget has a lot of children.\n        ///\n        /// @author HMcLaughlin\n        ///\n        /// @return A vector of all child widgets\n        //----------------------------------------------------------------------------------------\n        std::vector<WidgetSPtr> GetWidgets();\n        //----------------------------------------------------------------------------------------\n        /// Returns a const list of the widgets immediate children. A copy of the internal list is\n        /// created so this is relatively expensive if the widget has a lot of children.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @return A const list of the child widgets.\n        //----------------------------------------------------------------------------------------\n        std::vector<WidgetCSPtr> GetWidgets() const;\n        //----------------------------------------------------------------------------------------\n        /// Searches the immediate internal children for a widget with the given name and returns\n        /// it. If the child cannot be found this will return null. If there are multiple children\n        /// with the name the first with be returned.\n        ///\n        /// @author S Downie\n        ///\n        /// @return The internal child with the given name or null if one doesn't exist.\n        //----------------------------------------------------------------------------------------\n        Widget* GetInternalWidget(const std::string& in_name);\n        //----------------------------------------------------------------------------------------\n        /// Searches the immediate internal children for a widget with the given name and returns\n        /// a constant version of it. If the child cannot be found this will return null. If there\n        /// are multiple children with the name the first with be returned.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @return A constant version of the internal child with the given name or null if one\n        /// doesn't exist.\n        //----------------------------------------------------------------------------------------\n        const Widget* GetInternalWidget(const std::string& in_name) const;\n        //----------------------------------------------------------------------------------------\n        /// Searches the immediate internal children and recurses through their external children\n        /// for a widget with the given name and returns it. If the child cannot be found this will\n        /// return null. If there are multiple children with the name the first with be returned.\n        /// The hierarchy will be navigated breadth first.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @return The internal child with the given name or null if one doesn't exist.\n        //----------------------------------------------------------------------------------------\n        Widget* GetInternalWidgetRecursive(const std::string& in_name);\n        //----------------------------------------------------------------------------------------\n        /// Searches the immediate internal children and recurses through their external children\n        /// for a widget with the given name and returns a constant version of it. If the child\n        /// cannot be found this will return null. If there are multiple children with the name\n        /// the first with be returned. The hierarchy will be navigated breadth first.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @return A constant version of the internal child with the given name or null if one\n        /// doesn't exist.\n        //----------------------------------------------------------------------------------------\n        const Widget* GetInternalWidgetRecursive(const std::string& in_name) const;\n        //----------------------------------------------------------------------------------------\n        /// Returns a list of the widgets immediate internal children. A copy of the internal list\n        /// is created so this is relatively expensive if the widget has a lot of internal\n        /// children.\n        ///\n        /// @author HMcLaughlin\n        ///\n        /// @return A vector of all child widgets\n        //----------------------------------------------------------------------------------------\n        std::vector<Widget*> GetInternalWidgets();\n        //----------------------------------------------------------------------------------------\n        /// Returns a const list of the widgets immediate internal children. A copy of the internal\n        /// list is created so this is relatively expensive if the widget has a lot of internal\n        /// children.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @return A const list of the child widgets.\n        //----------------------------------------------------------------------------------------\n        std::vector<const Widget*> GetInternalWidgets() const;\n        //----------------------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Parent widget of this widget or null\n        //----------------------------------------------------------------------------------------\n        Widget* GetParent();\n        //----------------------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Parent widget of this widget or null\n        //----------------------------------------------------------------------------------------\n        const Widget* GetParent() const;\n        //----------------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return Whether or not the widget is currently on a canvas.\n        //----------------------------------------------------------------------------------------\n        bool IsOnCanvas() const;\n        //----------------------------------------------------------------------------------------\n        /// Bring the subview to the front of its siblings. It will now be rendered on top\n        ///\n        /// @author S Downie\n        //----------------------------------------------------------------------------------------\n        void BringToFront();\n        //----------------------------------------------------------------------------------------\n        /// Bring the subview one place forward to the front of the sibling in front of it.\n        ///\n        /// @author S Downie\n        //----------------------------------------------------------------------------------------\n        void BringForward();\n        //----------------------------------------------------------------------------------------\n        /// Send the subview one place backward to behind the sibling in behind it.\n        ///\n        /// @author S Downie\n        //----------------------------------------------------------------------------------------\n        void SendBackward();\n        //----------------------------------------------------------------------------------------\n        /// Send the subview to the back of its siblings. It will be rendered behind all other\n        /// siblings\n        ///\n        /// @author S Downie\n        //----------------------------------------------------------------------------------------\n        void SendToBack();\n        //----------------------------------------------------------------------------------------\n        /// Calculate the screen space position of the origin of the object object based on the\n        /// local position, local alignment to parent and the parents final position.\n        ///\n        /// NOTE: As the relative final position cannot be calculated until the widget is part of\n        /// an absolute tree (i.e. one of the widgets up the tree is absolute) Therefore will assert\n        /// if the widget is not on the root canvas\n        ///\n        /// @author Ian Copland\n        ///\n        /// @return Screen space position of the origin in pixels\n        //----------------------------------------------------------------------------------------\n        Vector2 GetFinalPosition() const;\n        //----------------------------------------------------------------------------------------\n        /// Calculate the screen space position of the centre of the object object based on the\n        /// local position, local alignment to parent, local alignment to origin and the parents\n        /// final position.\n        ///\n        /// NOTE: As the relative final position cannot be calculated until the widget is part of\n        /// an absolute tree (i.e. one of the widgets up the tree is absolute) Therefore will assert\n        /// if the widget is not on the root canvas\n        ///\n        /// @author S Downie\n        ///\n        /// @return Screen space position of the centre of the object in pixels\n        //----------------------------------------------------------------------------------------\n        Vector2 GetFinalPositionOfCentre() const;\n        //----------------------------------------------------------------------------------------\n        /// Calculate the screen space size of the object based on the local size and the\n        /// parent size.\n        ///\n        /// NOTE: As the relative the final size cannot be calculated until\n        /// the widget is part of an absolute tree (i.e. one of the widgets up the tree is absolute)\n        /// Therefore will assert if the widget is not on the root canvas\n        ///\n        /// @author S Downie\n        ///\n        /// @return Screen space size in pixels\n        //----------------------------------------------------------------------------------------\n        Vector2 GetFinalSize() const;\n        //----------------------------------------------------------------------------------------\n        /// Returns the size of the rectange this widget will be positioned and sized relative to.\n        /// This will either be the size of the parent or the size of the cell within the parents\n        /// layout.\n        ///\n        /// NOTE: As the relative component of the final size cannot be calculated until the\n        /// widget is part of an absolute tree (i.e. one of the widgets up the tree is absolute).\n        /// Therefore will assert if the widget is not on the root canvas.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @return The screen space size that relative positions and size are relative to.\n        /// This is in pixels.\n        //----------------------------------------------------------------------------------------\n        Vector2 GetRelativeReferenceSize() const;\n        //----------------------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return The preferred size of the widget based on the current drawable or the\n        /// fallback value if there is no drawable\n        //----------------------------------------------------------------------------------------\n        Vector2 GetPreferredSize() const;\n        //----------------------------------------------------------------------------------------\n        /// Calculate the rotation of the object based on the local rotation and the\n        /// parent rotation.\n        ///\n        /// @author S Downie\n        ///\n        /// @return Final rotation in radians\n        //----------------------------------------------------------------------------------------\n        f32 GetFinalRotation() const;\n        //----------------------------------------------------------------------------------------\n        /// Calculate the scale of the object based on the local scale and the\n        /// parent scale.\n        ///\n        /// @author S Downie\n        ///\n        /// @return Final scale\n        //----------------------------------------------------------------------------------------\n        Vector2 GetFinalScale() const;\n        //----------------------------------------------------------------------------------------\n        /// Calculate the colour of the object based on the local colour and the\n        /// parent colour.\n        ///\n        /// @author S Downie\n        ///\n        /// @return Final colour\n        //----------------------------------------------------------------------------------------\n        Colour GetFinalColour() const;\n        //----------------------------------------------------------------------------------------\n        /// Set the value of the property with the given name. If no property exists\n        /// with the name then it will assert.\n        ///\n        /// @author S Downie\n        ///\n        /// @param Name. This is case insensitive.\n        /// @param Value\n        //----------------------------------------------------------------------------------------\n        template<typename TType> void SetProperty(const std::string& in_name, TType&& in_value);\n        //----------------------------------------------------------------------------------------\n        /// Specialisation to store property value for const char* as a std::string\n        ///\n        /// @author S Downie\n        ///\n        /// @param Property name. This is case insensitive.\n        /// @param Property value\n        //----------------------------------------------------------------------------------------\n        void SetProperty(const std::string& in_name, const char* in_value);\n        //----------------------------------------------------------------------------------------\n        /// Get the value of the property with the given name. If no property exists\n        /// with the name then it will assert.\n        ///\n        /// @author S Downie\n        ///\n        /// @param Name. This is case insensitive.\n        ///\n        /// @return Value\n        //----------------------------------------------------------------------------------------\n        template<typename TType> TType GetProperty(const std::string& in_name) const;\n        //----------------------------------------------------------------------------------------\n        /// Performs a calculation to check if the given position is within the OOBB\n        /// of the widget\n        ///\n        /// @author S Downie\n        ///\n        /// @param Position to check\n        ///\n        /// @return Whther the widget contains the point\n        //----------------------------------------------------------------------------------------\n        bool Contains(const Vector2& in_point) const;\n        //----------------------------------------------------------------------------------------\n        /// Converts the input screen space point to local space relative to the given alignment\n        /// anchor. As this requires the final transform of the widget this will assert if the\n        /// widget is not on the canvas.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The position to convert to local space. This must be in screen space.\n        /// @param The anchor to align it to.\n        ///\n        /// @return The local space position relative to the given anchor.\n        //----------------------------------------------------------------------------------------\n        Vector2 ToLocalSpace(const Vector2& in_point, AlignmentAnchor in_alignmentAnchor) const;\n        //------------------------------------------------------------------------------\n        /// Invalidates all caches, ensuring the transform for the widget and its\n        /// children are re-calculated the next time it is rendered.\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------------------------------------\n        void ForceLayout();\n        //----------------------------------------------------------------------------------------\n        /// Destructor. Sends the OnDestroy event to all components.\n        ///\n        /// @author Ian Copland\n        //----------------------------------------------------------------------------------------\n        ~Widget();\n    private:\n        friend class Canvas;\n        friend class WidgetFactory;\n        friend class CursorSystem;\n        //----------------------------------------------------------------------------------------\n        /// Constructor that builds the widget from the given definition. The default properties\n        /// of a widget are described in the class documentation.\n        ///\n        /// @author S Downie\n        ///\n        /// @param The property map containing the initial values for properties.\n        /// @param The list of components.\n        /// @param The list of component property links.\n        /// @param The list of internal children.\n        /// @param The list of internal children property links.\n        //----------------------------------------------------------------------------------------\n        Widget(const PropertyMap& in_properties, std::vector<UIComponentUPtr> in_components, const std::vector<PropertyLink>& in_componentPropertyLinks, std::vector<WidgetUPtr> in_internalChildren,\n               const std::vector<PropertyLink>& in_childPropertyLinks);\n        //----------------------------------------------------------------------------------------\n        /// Initialises the internal mapping to base properties. This allows base properties,\n        /// such as Relative Position or Size Policy to be set via the SetProperty method.\n        ///\n        /// @author Ian Copland\n        //----------------------------------------------------------------------------------------\n        void InitBaseProperties();\n        //----------------------------------------------------------------------------------------\n        /// Initialises the widgets components. This can only be called once and each component\n        /// must have a unique name. If called a second time the app will be considered to be\n        /// in an irrecoverable state and will terminate.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The list of components.\n        //----------------------------------------------------------------------------------------\n        void InitComponents(std::vector<UIComponentUPtr> in_components);\n        //----------------------------------------------------------------------------------------\n        /// Adds all of the internal widgets. The given widgets must not already have a parent,\n        /// if they do the app will be considered to be in an irrecoverable state and will\n        /// terminate.\n        ///\n        /// @author S Downie\n        ///\n        /// @param The list of widgets.\n        //----------------------------------------------------------------------------------------\n        void InitInternalWidgets(std::vector<WidgetUPtr> in_widgets);\n        //----------------------------------------------------------------------------------------\n        /// Set up the links so that this widget can access the properties of another via the\n        /// SetProperty and GetProperty\n        ///\n        /// @author S Downie\n        ///\n        /// @param Links to default properties of the specified widget\n        /// @param Links to custom properties of the specified widget\n        //----------------------------------------------------------------------------------------\n        void InitPropertyLinks(const std::vector<PropertyLink>& in_componentPropertyLinks, const std::vector<PropertyLink>& in_childPropertyLinks);\n        //----------------------------------------------------------------------------------------\n        /// Initialise the values of all properties from the given property map.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The property map.\n        //----------------------------------------------------------------------------------------\n        void InitPropertyValues(const PropertyMap& in_propertyMap);\n        //----------------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param The name of the component. There should only be one component with the name.\n        ///\n        /// @return The component with the given name. This will return nullptr is no component\n        /// could be found.\n        //----------------------------------------------------------------------------------------\n        UIComponent* GetComponentWithName(const std::string& in_name);\n        //----------------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param The name of the component. There should only be one component with the name.\n        ///\n        /// @return A const version of the component with the given name. This will return nullptr\n        /// is no component could be found.\n        //----------------------------------------------------------------------------------------\n        const UIComponent* GetComponentWithName(const std::string& in_name) const;\n        //----------------------------------------------------------------------------------------\n        /// Set the pointer to the canvas\n        ///\n        /// @author S Downie\n        ///\n        /// @param Canvas\n        //----------------------------------------------------------------------------------------\n        void SetCanvas(const Widget* in_canvas);\n        //----------------------------------------------------------------------------------------\n        /// Set the pointer to the parent.\n        ///\n        /// @author S Downie\n        ///\n        /// @param Parent\n        //----------------------------------------------------------------------------------------\n        void SetParent(Widget* in_parent);\n        //----------------------------------------------------------------------------------------\n        /// Calculate the transform matrix of the object based on the local scale, rotation and\n        /// position\n        ///\n        /// @author S Downie\n        ///\n        /// @return Local transformation matrix\n        //----------------------------------------------------------------------------------------\n        Matrix3 GetLocalTransform() const;\n        //----------------------------------------------------------------------------------------\n        /// Calculate the transform matrix of the object based on the local transform and the\n        /// parent transform.\n        ///\n        /// @author S Downie\n        ///\n        /// @return Screen space transformation matrix\n        //----------------------------------------------------------------------------------------\n        Matrix3 GetFinalTransform() const;\n        //----------------------------------------------------------------------------------------\n        /// Calculates the position on the widget's origin in Local Render space, combining the\n        /// relative and absolute components of the local position. Local Render space is relative\n        /// to the centre of the parent. This takes into account the parents final size, the\n        /// parental anchor and the absolute and relative position.\n        ///\n        /// NOTE: As the position takes into account the size of the parent, this cannot be\n        /// calculated until the widget is part of an absolute tree, i.e. one of the widgets up\n        /// the tree is absolute. Therefore this will assert if the widget is not on the root\n        /// canvas.\n        ///\n        /// @author S Downie\n        ///\n        /// @return The position in local render space. This is in pixels.\n        //----------------------------------------------------------------------------------------\n        Vector2 GetLocalRenderSpaceCombinedPosition() const;\n        //----------------------------------------------------------------------------------------\n        /// Calculates the local position of the origin, combining the relative and absolute\n        /// components of the origin position. This is relative to the origin anchor point. This\n        /// takes into account the final size of the parent and the relative and absolute origin\n        /// position.\n        ///\n        /// NOTE: As part of the origin's position is relative the combined local space position\n        /// cannot be calculated until the widget is part of an absolute tree, i.e. one of the\n        /// widgets up the tree is absolute. Therefore this will assert if the widget is not on\n        /// the rootcanvas.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @return Position of the origin anchor in local space. This is in pixels.\n        //----------------------------------------------------------------------------------------\n        Vector2 GetLocalOriginCombinedPosition() const;\n        //----------------------------------------------------------------------------------------\n        /// Calculates the reference size of the given child widget. This will be either the size\n        /// of the cell in the layout the child is in, or the size of this if there is no layout.\n        ///\n        /// As this takes into account the final size, this must be part of an absolute hierarchy,\n        /// i.e it must be in the canvas widget's hierarchy. If not, this will assert.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The child widget.\n        ///\n        /// @return The reference size in absolute screen space pixels.\n        //----------------------------------------------------------------------------------------\n        Vector2 CalculateRelativeReferenceSizeForChild(const Widget* in_child);\n        //----------------------------------------------------------------------------------------\n        /// Returns the layout and index into that layout for the given children.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The child widget.\n        ///\n        /// @return A pair containing the layout and index. The layout can be null if the child\n        /// is not in a layout.\n        //----------------------------------------------------------------------------------------\n        std::pair<LayoutUIComponent*, s32> GetLayoutForChild(const Widget* in_child);\n        //----------------------------------------------------------------------------------------\n        /// Sets the value of a property from another property. The given property must be of the\n        /// same type as the given property or the app will be considered to be in an irrecoverable\n        /// state and will terminate.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The property name.\n        /// @param The property used to set the value.\n        //----------------------------------------------------------------------------------------\n        void SetProperty(const std::string& in_propertyName, const IProperty* in_property);\n        //------------------------------------------------------------------------------\n        /// Checks the given pointer and updates the contained pointer set accordingly.\n        /// If the pointer has changed state a pointer entered or exited event will be\n        /// fired.\n        ///\n        /// This doesn't handle whether or not input is enabled - only call this if\n        /// input is enabled.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param in_pointer - The pointer to check.\n        //------------------------------------------------------------------------------\n        void UpdateContainedPointer(const Pointer& in_pointer);\n        //------------------------------------------------------------------------------\n        /// Removes the given pointer from the contained pointer set if it is present.\n        /// If removed, the pointer exited event will be fired.\n        ///\n        /// This doesn't handle whether or not input is enabled - only call this if\n        /// input is enabled.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param in_pointer - The pointer to check.\n        //------------------------------------------------------------------------------\n        void RemoveContainedPointer(const Pointer& in_pointer);\n        //------------------------------------------------------------------------------\n        /// Checks all existing pointers and updates the contained pointer set\n        /// accordingly. For each pointer which has changed state a pointer exited or\n        /// entered event will be fired.\n        ///\n        /// This doesn't handle whether or not input is enabled - only call this if\n        /// input is enabled.\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------------------------------------\n        void UpdateAllContainedPointers();\n        //------------------------------------------------------------------------------\n        /// Removes all pointers from the contained pointers set. Pointer exited events\n        /// will be fired for those that are removed.\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------------------------------------\n        void RemoveAllContainedPointers();\n        //------------------------------------------------------------------------------\n        /// Checks the contained pointer set to confirm if this pointer is contained\n        /// within the widget. Note that the set is not updated by this method and\n        /// UpdateContainedPointer() or UpdateAllContainedPointers() will need to be\n        /// called prior to this to ensure it is up to date.\n        ///\n        /// This doesn't handle whether or not input is enabled - only call this if\n        /// input is enabled.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param in_pointer - The pointer which should be checked.\n        ///\n        /// @return Whether or not the pointer is within the bounds.\n        //------------------------------------------------------------------------------\n        bool IsContainedPointer(const Pointer& in_pointer);\n        //----------------------------------------------------------------------------------------\n        /// Called when the parent transform changes forcing this to update its caches\n        ///\n        /// @author S Downie\n        //----------------------------------------------------------------------------------------\n        void OnParentTransformChanged();\n        //----------------------------------------------------------------------------------------\n        /// Resumes the widget, its components and its children. This is called when the widget\n        /// is attached to the canvas and every time the state that owns the canvas is resumed while\n        /// the widget is attached.\n        ///\n        /// @author Ian Copland\n        //----------------------------------------------------------------------------------------\n        void OnResume();\n        //----------------------------------------------------------------------------------------\n        /// Foregrounds the widget, its components and its children. This is called when the widget\n        /// is attached to the canvas and every time the state that owns the canvas is foregrounded\n        /// while the widget is attached.\n        ///\n        /// @author Ian Copland\n        //----------------------------------------------------------------------------------------\n        void OnForeground();\n        //----------------------------------------------------------------------------------------\n        /// Update this widget and any sub widgets\n        ///\n        /// @author S Downie\n        ///\n        /// @param Time in seconds since last update\n        //----------------------------------------------------------------------------------------\n        void OnUpdate(f32 in_timeSinceLastUpdate);\n        //----------------------------------------------------------------------------------------\n        /// Tells any components or child widgets to draw.\n        ///\n        /// @author S Downie\n        ///\n        /// @param Canvas renderer\n        //----------------------------------------------------------------------------------------\n        void OnDraw(CanvasRenderer* in_renderer);\n        //----------------------------------------------------------------------------------------\n        /// Backgrounds the widget, its components and its children. This is called when the widget\n        /// is removed from the canvas and every time the state that owns the canvas is backgrounded\n        /// while the widget is attached.\n        ///\n        /// @author Ian Copland\n        //----------------------------------------------------------------------------------------\n        void OnBackground();\n        //----------------------------------------------------------------------------------------\n        /// Suspends the widget, its components and its children. This is called when the widget\n        /// is removed from the canvas and every time the state that owns the canvas is suspended\n        /// while the widget is attached.\n        ///\n        /// @author Ian Copland\n        //----------------------------------------------------------------------------------------\n        void OnSuspend();\n        //------------------------------------------------------------------------------\n        /// Called whenever a new pointer is added to the canvas.\n        ///\n        /// @author Ian Copland.\n        ///\n        /// @param in_pointer - The new pointer which was added.\n        /// @param in_timestamp - The time the new pointer was added.\n        //------------------------------------------------------------------------------\n        void OnPointerAdded(const Pointer& in_pointer, f64 in_timestamp);\n        //------------------------------------------------------------------------------\n        /// Called when the canvas receives cursor/touch input\n        ///\n        /// @author S Downie\n        ///\n        /// @param in_pointer - The pointer\n        /// @param in_timestamp - The timestamp.\n        /// @param in_inputType - The press type.\n        /// @param in_filter - Filter object to check if the event has been filtered or\n        /// to filter it\n        //------------------------------------------------------------------------------\n        void OnPointerDown(const Pointer& in_pointer, f64 in_timestamp, Pointer::InputType in_inputType, InputFilter& in_filter);\n        //------------------------------------------------------------------------------\n        /// Called when the canvas receives cursor/touch move input\n        ///\n        /// @author S Downie\n        ///\n        /// @param in_pointer - The pointer\n        /// @param in_timestamp - The timestamp.\n        //------------------------------------------------------------------------------\n        void OnPointerMoved(const Pointer& in_pointer, f64 in_timestamp);\n        //-----------------------------------------------------------\n        /// Called when the canvas receiving cursor/touch release input\n        ///\n        /// @author S Downie\n        ///\n        /// @param in_pointer - The pointer\n        /// @param in_timestamp - The timestamp.\n        /// @param in_inputType - The input type.\n        //------------------------------------------------------------------------------\n        void OnPointerUp(const Pointer& in_pointer, f64 in_timestamp, Pointer::InputType in_inputType);\n        //------------------------------------------------------------------------------\n        /// Called whenever an existing pointer is removed from the canvas.\n        ///\n        /// @author Ian Copland.\n        ///\n        /// @param in_pointer - The new pointer which was removed.\n        /// @param in_timestamp - The time the pointer was removed.\n        //------------------------------------------------------------------------------\n        void OnPointerRemoved(const Pointer& in_pointer, f64 in_timestamp);\n        \n    private:\n        \n        std::unordered_map<std::string, IPropertyUPtr> m_baseProperties;\n        std::unordered_map<std::string, std::pair<UIComponent*, std::string>> m_componentPropertyLinks;\n        std::unordered_map<std::string, std::pair<Widget*, std::string>> m_childPropertyLinks;\n        \n        std::unordered_map<Pointer::Id, std::set<Pointer::InputType>> m_pressedInput;\n        std::unordered_set<Pointer::Id> m_containedPointers;\n        \n        Event<InputDelegate> m_pressedInsideEvent;\n        Event<InputDelegate> m_releasedInsideEvent;\n        Event<InputDelegate> m_releasedOutsideEvent;\n        Event<InputMovedDelegate> m_moveExitedEvent;\n        Event<InputMovedDelegate> m_moveEnteredEvent;\n        Event<InputMovedDelegate> m_draggedInsideEvent;\n        Event<InputMovedDelegate> m_draggedOutsideEvent;\n        \n        UnifiedVector2 m_localPosition;\n        UnifiedVector2 m_localSize = UnifiedVector2(1.0f, 1.0f, 0.0f, 0.0f);\n        Vector2 m_preferredSize = Vector2::k_one;\n        Vector2 m_localScale = Vector2::k_one;\n        Colour m_localColour;\n        f32 m_localRotation = 0.0f;\n        \n        mutable Matrix3 m_cachedLocalTransform;\n        mutable Matrix3 m_cachedFinalTransform;\n        mutable Vector2 m_cachedFinalPosition;\n        mutable Vector2 m_cachedFinalSize;\n        \n        SizePolicy m_sizePolicy = SizePolicy::k_none;\n        SizePolicyDelegate m_sizePolicyDelegate;\n        \n        concurrent_vector<WidgetUPtr> m_internalChildren;\n        concurrent_vector<WidgetSPtr> m_children;\n        \n        std::string m_name;\n        \n        std::vector<UIComponentUPtr> m_components;\n\n        LayoutUIComponent* m_layoutComponent = nullptr;\n        \n        Widget* m_parent = nullptr;\n        const Widget* m_canvas = nullptr;\n        \n        AlignmentAnchor m_parentalAnchor = AlignmentAnchor::k_middleCentre;\n        AlignmentAnchor m_originAnchor = AlignmentAnchor::k_middleCentre;\n        UnifiedVector2 m_originPosition;\n        \n        bool m_isVisible = true;\n        bool m_isInputEnabled = true;\n        bool m_isInputConsumeEnabled = false;\n        \n        mutable bool m_isParentTransformCacheValid = false;\n        mutable bool m_isLocalTransformCacheValid = false;\n        mutable bool m_isLocalSizeCacheValid = false;\n        mutable bool m_isParentSizeCacheValid = false;\n\n        Screen* m_screen = nullptr;\n        PointerSystem* m_pointerSystem = nullptr;\n    };\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    template <typename TComponentType> TComponentType* Widget::GetComponent()\n    {\n        return ConstMethodCast(this, &Widget::GetComponent<TComponentType>);\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    template <typename TComponentType> const TComponentType* Widget::GetComponent() const\n    {\n        for (const auto& component : m_components)\n        {\n            if (component->IsA<TComponentType>() == true)\n            {\n                return static_cast<const TComponentType*>(component.get());\n            }\n        }\n        \n        return nullptr;\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    template<typename TType> void Widget::SetProperty(const std::string& in_name, TType&& in_value)\n    {\n        std::string lowerName = in_name;\n        StringUtils::ToLowerCase(lowerName);\n        \n        auto basePropIt = m_baseProperties.find(lowerName);\n        if(basePropIt != m_baseProperties.end())\n        {\n            auto property = CS_SMARTCAST(Property<TType>*, basePropIt->second.get(), \"Incorrect type for property with name: \" + in_name);\n            property->Set(std::forward<TType>(in_value));\n            return;\n        }\n        \n        auto componentPropIt = m_componentPropertyLinks.find(lowerName);\n        if(componentPropIt != m_componentPropertyLinks.end())\n        {\n            componentPropIt->second.first->SetProperty<TType>(componentPropIt->second.second, std::forward<TType>(in_value));\n            return;\n        }\n        \n        auto childPropIt = m_childPropertyLinks.find(lowerName);\n        if(childPropIt != m_childPropertyLinks.end())\n        {\n            childPropIt->second.first->SetProperty<TType>(childPropIt->second.second, std::forward<TType>(in_value));\n            return;\n        }\n        \n        CS_LOG_FATAL(\"Invalid property name for Widget: \" + in_name);\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    template<typename TType> TType Widget::GetProperty(const std::string& in_name) const\n    {\n        std::string lowerName = in_name;\n        StringUtils::ToLowerCase(lowerName);\n        \n        auto basePropIt = m_baseProperties.find(lowerName);\n        if(basePropIt != m_baseProperties.end())\n        {\n            auto property = CS_SMARTCAST(Property<TType>*, basePropIt->second.get(), \"Incorrect type for property with name: \" + in_name);\n            return property->Get();\n        }\n        \n        auto componentPropIt = m_componentPropertyLinks.find(lowerName);\n        if(componentPropIt != m_componentPropertyLinks.end())\n        {\n            return componentPropIt->second.first->GetProperty<TType>(componentPropIt->second.second);\n        }\n        \n        auto childPropIt = m_childPropertyLinks.find(lowerName);\n        if(childPropIt != m_childPropertyLinks.end())\n        {\n            return childPropIt->second.first->GetProperty<TType>(childPropIt->second.second);\n        }\n        \n        CS_LOG_FATAL(\"Invalid property name for Widget: \" + in_name);\n        return TType();\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/UI/Base/WidgetDef.cpp",
    "content": "//\n//  WidgetDef.cpp\n//  ChilliSource\n//  Created by Scott Downie on 25/07/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/UI/Base/WidgetDef.h>\n\nnamespace ChilliSource\n{\n    CS_DEFINE_NAMEDTYPE(WidgetDef);\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    WidgetDefUPtr WidgetDef::Create()\n    {\n        return WidgetDefUPtr(new WidgetDef());\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    bool WidgetDef::IsA(InterfaceIDType in_interfaceId) const\n    {\n        return in_interfaceId == WidgetDef::InterfaceID;\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    void WidgetDef::Build(const std::string& in_typeName, const PropertyMap& in_defaultProperties, const std::vector<UIComponentDesc>& in_componentDescs, const std::vector<PropertyLink>& in_componentPropertyLinks,\n                          const std::vector<WidgetDesc>& in_childDescs, const std::vector<PropertyLink>& in_childPropertyLinks)\n    {\n        CS_ASSERT(GetLoadState() == LoadState::k_loading, \"A WidgetDef can only be built while in the loading state.\");\n        \n        m_typeName = in_typeName;\n        m_defaultProperties = in_defaultProperties;\n        m_childDescs = in_childDescs;\n        m_childPropertyLinks = in_childPropertyLinks;\n        m_componentDescs = in_componentDescs;\n        m_componentPropertyLinks = in_componentPropertyLinks;\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    const std::string& WidgetDef::GetTypeName() const\n    {\n        return m_typeName;\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    const PropertyMap& WidgetDef::GetDefaultProperties() const\n    {\n        return m_defaultProperties;\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    const std::vector<UIComponentDesc>& WidgetDef::GetComponentDescs() const\n    {\n        return m_componentDescs;\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    const std::vector<PropertyLink>& WidgetDef::GetComponentPropertyLinks() const\n    {\n        return m_componentPropertyLinks;\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    const std::vector<WidgetDesc>& WidgetDef::GetChildDescs() const\n    {\n        return m_childDescs;\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    const std::vector<PropertyLink>& WidgetDef::GetChildPropertyLinks() const\n    {\n        return m_childPropertyLinks;\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/UI/Base/WidgetDef.h",
    "content": "//\n//  WidgetDef.h\n//  ChilliSource\n//  Created by Scott Downie on 25/07/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_UI_BASE_WIDGETDEF_H_\n#define _CHILLISOURCE_UI_BASE_WIDGETDEF_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Container/Property/PropertyMap.h>\n#include <ChilliSource/Core/Resource/Resource.h>\n#include <ChilliSource/UI/Base/UIComponentDesc.h>\n#include <ChilliSource/UI/Base/PropertyLink.h>\n#include <ChilliSource/UI/Base/WidgetDesc.h>\n\n#include <vector>\n\nnamespace ChilliSource\n{\n    //-------------------------------------------------------------\n    /// A resource that holds the description for defining new\n    /// widget types. Widgets created from defines have provate implementation\n    /// details such as child widgets and are supposed to be treated as\n    /// as single widget rather than as a screen. Widgets created from\n    /// defines rarely have any properties set only their behaviour and\n    /// hiearchy is fixed and there they require positioning and drawables\n    /// etc before they can be added to the canvas.\n    ///\n    /// @author S Downie\n    //-------------------------------------------------------------\n    class WidgetDef final : public Resource\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(WidgetDef);\n        //-------------------------------------------------------\n        /// Is the object of the given interface type.\n        ///\n        /// @author S Downie\n        ///\n        /// @param Interface type to query\n        ///\n        /// @return Whether the object is of given type\n        //-------------------------------------------------------\n        bool IsA(InterfaceIDType in_interfaceId) const override;\n        //-------------------------------------------------------\n        /// Build the widget def resource, consisting of its\n        /// default properties, components and children.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The name of the widget type.\n        /// @param The property map containing all of the keys\n        /// for this widget type--both the base properties all\n        /// widgets have and linked properties. The values of\n        /// each property is the default value in any instance\n        /// of the widget being used.\n        /// @param The list of components. This can be empty if\n        /// no components are required.\n        /// @param The links between properties of the widget def\n        /// and properties of components.\n        /// @param The list of internal child descriptions. This\n        /// can be empty if no internal children are required.\n        /// @param The links between properties of the widget\n        /// def and properties of internal children.\n        //-------------------------------------------------------\n        void Build(const std::string& in_typeName, const PropertyMap& in_defaultProperties, const std::vector<UIComponentDesc>& in_componentDescs, const std::vector<PropertyLink>& in_componentPropertyLinks,\n                   const std::vector<WidgetDesc>& in_childDescs, const std::vector<PropertyLink>& in_childPropertyLinks);\n        //-------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The name of the widget type.\n        //-------------------------------------------------------\n        const std::string& GetTypeName() const;\n        //-------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The property map containing all of the keys\n        /// for this widget type--both the base properties all\n        /// widgets have and linked properties. All values are\n        /// set to their default value.\n        //-------------------------------------------------------\n        const PropertyMap& GetDefaultProperties() const;\n        //-------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The list of component descriptions.\n        //-------------------------------------------------------\n        const std::vector<UIComponentDesc>& GetComponentDescs() const;\n        //-------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The links between properties of the widget\n        /// def and properties of components.\n        //-------------------------------------------------------\n        const std::vector<PropertyLink>& GetComponentPropertyLinks() const;\n        //-------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The list of internal child descriptions.\n        //-------------------------------------------------------\n        const std::vector<WidgetDesc>& GetChildDescs() const;\n        //-------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The links between properties of the widget\n        /// def and properties of internal children.\n        //-------------------------------------------------------\n        const std::vector<PropertyLink>& GetChildPropertyLinks() const;\n        \n    private:\n        friend class ResourcePool;\n        //-------------------------------------------------------\n        /// Factory method\n        ///\n        /// @author S Downie\n        ///\n        /// @return New backend with ownership transferred\n        //-------------------------------------------------------\n        static WidgetDefUPtr Create();\n        //-------------------------------------------------------\n        /// Private constructor to force use of factory method\n        ///\n        /// @author S Downie\n        //-------------------------------------------------------\n        WidgetDef() = default;\n        \n    private:\n        std::string m_typeName;\n        PropertyMap m_defaultProperties;\n        std::vector<UIComponentDesc> m_componentDescs;\n        std::vector<PropertyLink> m_componentPropertyLinks;\n        std::vector<WidgetDesc> m_childDescs;\n        std::vector<PropertyLink> m_childPropertyLinks;\n    };\n}\n\n#endif\n\n"
  },
  {
    "path": "Source/ChilliSource/UI/Base/WidgetDefProvider.cpp",
    "content": "//\n//  WidgetDefProvider.cpp\n//  ChilliSource\n//  Created by Scott Downie on 25/07/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/UI/Base/WidgetDefProvider.h>\n\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/Container/Property/PropertyMap.h>\n#include <ChilliSource/Core/Json/JsonUtils.h>\n#include <ChilliSource/Core/Resource/ResourcePool.h>\n#include <ChilliSource/Core/String/StringParser.h>\n#include <ChilliSource/Core/Threading/TaskScheduler.h>\n#include <ChilliSource/UI/Base/UIComponentFactory.h>\n#include <ChilliSource/UI/Base/Widget.h>\n#include <ChilliSource/UI/Base/WidgetDef.h>\n#include <ChilliSource/UI/Base/WidgetParserUtils.h>\n#include <ChilliSource/UI/Base/WidgetTemplate.h>\n#include <ChilliSource/UI/Base/WidgetTemplateProvider.h>\n\n#include <json/json.h>\n\nnamespace ChilliSource\n{\n    namespace\n    {\n        const std::string k_extension(\"csuidef\");\n        \n        const char k_widgetNameKey[] = \"Name\";\n        \n        const char k_componentTypeKey[] = \"Type\";\n        const char k_componentNameKey[] = \"Name\";\n\n        //-------------------------------------------------------\n        /// Searches the given widget desc list for a widget\n        /// description with the given name. This is recursive and\n        /// will navigate down the widget desc tree to find the\n        /// widget. Recursion is breadth first. If one cannot\n        /// be found the app is considered to be in an\n        /// irrecoverable state and will terminate.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The list of widget descriptions.\n        /// @param The name to look for.\n        /// @param [Out] The widget description with the given\n        /// name.\n        //-------------------------------------------------------\n        bool GetWidgetDescWithName(const std::vector<WidgetDesc>& in_widgets, const std::string& in_name, WidgetDesc& out_widgetDesc)\n        {\n            for (const auto& desc : in_widgets)\n            {\n                if (desc.GetProperties().GetPropertyOrDefault(k_widgetNameKey, \"\") == in_name)\n                {\n                    out_widgetDesc = desc;\n                    return true;\n                }\n            }\n            \n            for (const auto& desc : in_widgets)\n            {\n                if (GetWidgetDescWithName(desc.GetChildDescs(), in_name, out_widgetDesc) == true)\n                {\n                    return true;\n                }\n            }\n            \n            return false;\n        }\n        //-------------------------------------------------------\n        /// Searches the given component desc list for a component\n        /// description with the given name. If one cannot be\n        /// found the app is considered to be in an irrecoverable\n        /// state and will terminate.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The list of component descriptions.\n        /// @param The name to look for.\n        ///\n        /// @return The widget description with the given name.\n        //-------------------------------------------------------\n        UIComponentDesc GetComponentDescWithName(const std::vector<UIComponentDesc>& in_componentDescs, const std::string& in_name)\n        {\n            for (const auto& desc : in_componentDescs)\n            {\n                if (desc.GetName() == in_name)\n                {\n                    return desc;\n                }\n            }\n            \n            CS_LOG_FATAL(\"Could not find component description with name: \" + in_name);\n            return UIComponentDesc();\n        }\n        //-------------------------------------------------------\n        /// Parses the given json to create a single component\n        /// object.\n        ///\n        /// A component may contain file path properties which may\n        /// be relative to the widget def if a storage location\n        /// is not supplied.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The component json object.\n        /// @param The storage location of the definition.\n        /// @param The directory path of the definition.\n        ///\n        /// @return The output component description.\n        //-------------------------------------------------------\n        UIComponentDesc ParseComponent(const Json::Value& in_componentJson, StorageLocation in_definitionLocation, const std::string& in_definitionPath, UIComponentFactory* in_componentFactory)\n        {\n            CS_ASSERT(in_componentJson.isNull() == false, \"Cannot parse null component json.\");\n            CS_ASSERT(in_componentJson.isObject() == true, \"UIComponent json must be an object.\");\n            CS_ASSERT(in_componentJson.isMember(k_componentTypeKey) == true, \"UIComponent json must contain a '\" + std::string(k_componentTypeKey) + \"' key.\");\n            CS_ASSERT(in_componentJson.isMember(k_componentNameKey) == true, \"UIComponent json must contain a '\" + std::string(k_componentNameKey) + \"' key.\");\n            \n            Json::Value typeJson = in_componentJson.get(k_componentTypeKey, Json::nullValue);\n            Json::Value nameJson = in_componentJson.get(k_componentNameKey, Json::nullValue);\n            CS_ASSERT(typeJson.isString() == true, \"The '\" + std::string(k_componentTypeKey) + \"' in component json must be a string.\");\n            CS_ASSERT(nameJson.isString() == true, \"The '\" + std::string(k_componentNameKey) + \"' in component json must be a string.\");\n            \n            std::string type = typeJson.asString();\n            std::string name = nameJson.asString();\n            PropertyMap propertyMap(in_componentFactory->GetPropertyDescs(type));\n            \n            for(auto it = in_componentJson.begin(); it != in_componentJson.end(); ++it)\n            {\n                std::string propertyName = it.memberName();\n                \n                //ignore the type and name key since they're already handled\n                if (propertyName != k_componentTypeKey && propertyName != k_componentNameKey)\n                {\n                    if (propertyMap.HasKey(propertyName) == true)\n                    {\n                        WidgetParserUtils::SetProperty(propertyName, (*it), in_definitionLocation, in_definitionPath, propertyMap);\n                    }\n                    else\n                    {\n                        CS_LOG_FATAL(\"Property '\" + propertyName + \"' in component '\" + name + \"' of type '\" + type + \"' does not exist.\");\n                    }\n                }\n                \n            }\n            \n            return UIComponentDesc(type, name, propertyMap);\n        }\n        //-------------------------------------------------------\n        /// Parses the given json to create a list of component\n        /// descriptions.\n        ///\n        /// Components may contain file path properties which may\n        /// be relative to the widget def if a storage location\n        /// is not supplied.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The components json object.\n        /// @param The storage location of the definition.\n        /// @param The directory path of the definition.\n        ///\n        /// @return The output component descriptions.\n        //-------------------------------------------------------\n        std::vector<UIComponentDesc> ParseComponents(const Json::Value& in_componentsJson, StorageLocation in_definitionLocation, const std::string& in_definitionPath, UIComponentFactory* in_componentFactory)\n        {\n            CS_ASSERT(in_componentsJson.isNull() == false, \"Cannot parse null components json.\");\n            CS_ASSERT(in_componentsJson.isArray() == true, \"Components json must be an array.\");\n            \n            std::vector<UIComponentDesc> output;\n            for(auto& componentJson : in_componentsJson)\n            {\n                output.push_back(ParseComponent(componentJson, in_definitionLocation, in_definitionPath, in_componentFactory));\n            }\n            \n            return output;\n        }\n        //-------------------------------------------------------\n        /// From the given JSON value parse the hierarchy and\n        /// create definitions for all child widgets. Some of the\n        /// properties require conversion from relative to absolute\n        /// paths hence the definition path info.\n        ///\n        /// @author S Downie\n        ///\n        /// @param Json children.\n        /// @param Definition location\n        /// @param Defintion path (no file name)\n        ///\n        /// @return The child widget descriptions.\n        //-------------------------------------------------------\n        std::vector<WidgetDesc> ParseChildWidgets(const Json::Value& in_children, StorageLocation in_definitionLocation, const std::string& in_definitionPath)\n        {\n            std::vector<WidgetDesc> output;\n            \n            for(u32 i = 0; i < in_children.size(); ++i)\n            {\n                const Json::Value& childJson = in_children[i];\n                WidgetDesc childDesc = WidgetParserUtils::ParseWidget(childJson, in_definitionLocation, in_definitionPath);\n                output.push_back(childDesc);\n            }\n            \n            return output;\n        }\n        //-------------------------------------------------------\n        /// Builds a property map containing all of the properties\n        /// that the intended widget type can contain. This includes\n        /// all base widget properties plus the linked component\n        /// and child properties.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The component descriptions.\n        /// @param The component property links.\n        /// @param The child descriptions.\n        /// @param The child property links.\n        ///\n        /// @return The property map.\n        //-------------------------------------------------------\n        PropertyMap BuildPropertyMap(const std::vector<UIComponentDesc>& in_componentDescs, const std::vector<PropertyLink>& in_componentPropertyLinks,\n                                     const std::vector<WidgetDesc>& in_childDescs, const std::vector<PropertyLink>& in_childPropertyLinks)\n        {\n            //define the properties.\n            std::vector<PropertyMap::PropertyDesc> descs = Widget::GetPropertyDescs();\n            \n            //add linked component properties\n            for (auto& link : in_componentPropertyLinks)\n            {\n                auto componentDesc = GetComponentDescWithName(in_componentDescs, link.GetLinkedOwner());\n                PropertyMap::PropertyDesc desc;\n                desc.m_type = componentDesc.GetProperties().GetType(link.GetLinkedProperty());\n                desc.m_name = link.GetLinkName();\n                descs.push_back(desc);\n            }\n            \n            //add linked properties\n            for (auto& link : in_childPropertyLinks)\n            {\n                WidgetDesc widgetDesc;\n                if (GetWidgetDescWithName(in_childDescs, link.GetLinkedOwner(), widgetDesc) == false)\n                {\n                    CS_LOG_FATAL(\"Could not find widget desc with name: \" + link.GetLinkedOwner());\n                }\n                PropertyMap::PropertyDesc desc;\n                desc.m_type = widgetDesc.GetProperties().GetType(link.GetLinkedProperty());\n                desc.m_name = link.GetLinkName();\n                descs.push_back(desc);\n            }\n            \n            //build the property map\n            PropertyMap output(descs);\n            \n            return output;\n        }\n        //-------------------------------------------------------\n        /// From the given JSON value parse the values of the property\n        /// types into the given container. Some of the properties\n        /// require conversion from relative to absolute paths\n        /// hence the definition path info.\n        ///\n        /// @author S Downie\n        ///\n        /// @param Json defaults\n        /// @param Definition location\n        /// @param Defintion path (no file name)\n        /// @param [Out] Default property values\n        /// @param [Out] Custom property values\n        //-------------------------------------------------------\n        void ParseDefaultValues(const Json::Value& in_defaults, StorageLocation in_definitionLocation, const std::string& in_definitionPath, PropertyMap& out_properties)\n        {\n            for(auto it = in_defaults.begin(); it != in_defaults.end(); ++it)\n            {\n                if(out_properties.HasKey(it.memberName()) == true)\n                {\n                    WidgetParserUtils::SetProperty(it.memberName(), (*it), in_definitionLocation, in_definitionPath, out_properties);\n                }\n                else\n                {\n                    CS_LOG_FATAL(\"Property with name does not exist: \" + std::string(it.memberName()));\n                }\n            }\n        }\n        //-------------------------------------------------------\n        /// Parses and builds the linked properties between the\n        /// widget and components.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The component properties json.\n        ///\n        /// @return The list of component property links.\n        //-------------------------------------------------------\n        std::vector<PropertyLink> ParseLinkedComponentProperties(const Json::Value& in_properties, const std::vector<UIComponentDesc>& in_componentDescs)\n        {\n            const char k_componentLinkTypeAllKey[] = \"all\";\n            const char k_componentLinkTypeNoneKey[] = \"none\";\n            \n            std::vector<PropertyLink> links;\n            \n            for (auto linkedComponentIt = in_properties.begin(); linkedComponentIt != in_properties.end(); ++linkedComponentIt)\n            {\n                std::string linkedComponentName = linkedComponentIt.memberName();\n                Json::Value linkedComponentJson = (*linkedComponentIt);\n                CS_ASSERT((linkedComponentJson.isString() == true || linkedComponentJson.isObject() == true), \"A component link must be an object or a string (containing either 'all' or 'none').\");\n                \n                if (linkedComponentJson.isString() == true)\n                {\n                    \n                    std::string lowerValue = linkedComponentJson.asString();\n                    StringUtils::ToLowerCase(lowerValue);\n                    \n                    if (lowerValue == k_componentLinkTypeAllKey)\n                    {\n                        UIComponentDesc componentDesc = GetComponentDescWithName(in_componentDescs, linkedComponentName);\n                        for (const auto& propertyName : componentDesc.GetProperties().GetKeys())\n                        {\n                            links.push_back(PropertyLink(propertyName, linkedComponentName, propertyName));\n                        }\n                    }\n                    else if (lowerValue == k_componentLinkTypeNoneKey)\n                    {\n                        //If none is selected we don't want any links, so do nothing.\n                    }\n                    else\n                    {\n                        CS_LOG_FATAL(\"Invalid property link value for component: \" + linkedComponentName);\n                    }\n                }\n                else if (linkedComponentJson.isObject() == true)\n                {\n                    for (auto linkedPropertyIt = linkedComponentJson.begin(); linkedPropertyIt != linkedComponentJson.end(); ++linkedPropertyIt)\n                    {\n                        std::string linkName = linkedPropertyIt.memberName();\n                        Json::Value linkedPropertyJson = (*linkedPropertyIt);\n                        CS_ASSERT(linkedPropertyJson.isString(), \"A linked property name must be a string.\");\n                        \n                        std::string linkedPropertyName = linkedPropertyJson.asString();\n                        links.push_back(PropertyLink(linkName, linkedComponentName, linkedPropertyName));\n                    }\n                }\n            }\n            \n            return links;\n        }\n        //-------------------------------------------------------\n        /// Parses and builds the links for a parent property\n        /// that directly affects a child property\n        ///\n        /// @author S Downie\n        ///\n        /// @param JSON object containing all exposed properties\n        ///\n        /// @return The list of child links.\n        //-------------------------------------------------------\n        std::vector<PropertyLink> ParseLinkedChildProperties(const Json::Value& in_properties)\n        {\n            std::vector<PropertyLink> links;\n            \n            for (auto linkedWidgetIt = in_properties.begin(); linkedWidgetIt != in_properties.end(); ++linkedWidgetIt)\n            {\n                std::string linkedWidgetName = linkedWidgetIt.memberName();\n                Json::Value linkedWidgetJson = (*linkedWidgetIt);\n                CS_ASSERT(linkedWidgetJson.isObject() == true, \"A child link must be an object.\");\n                \n                for (auto linkedPropertyIt = linkedWidgetJson.begin(); linkedPropertyIt != linkedWidgetJson.end(); ++linkedPropertyIt)\n                {\n                    std::string linkName = linkedPropertyIt.memberName();\n                    Json::Value linkedPropertyJson = (*linkedPropertyIt);\n                    CS_ASSERT(linkedPropertyJson.isString(), \"A linked property name must be a string.\");\n                    \n                    std::string linkedPropertyName = linkedPropertyJson.asString();\n                    links.push_back(PropertyLink(linkName, linkedWidgetName, linkedPropertyName));\n                }\n            }\n            \n            return links;\n        }\n        //-------------------------------------------------------\n        /// Performs the heavy lifting for loading a UI\n        /// widget description from file\n        ///\n        /// @author S Downie\n        ///\n        /// @param Storage location\n        /// @param File path\n        /// @param Async load delegate\n        /// @param [Out] Resource\n        //-------------------------------------------------------\n        void LoadDesc(StorageLocation in_storageLocation, const std::string& in_filepath, const ResourceProvider::AsyncLoadDelegate& in_delegate, const ResourceSPtr& out_resource)\n        {\n            const char k_widgetTypeKey[] = \"Type\";\n            const char k_widgetComponentsKey[] = \"Components\";\n            const char k_widgetComponentPropertiesKey[] = \"ComponentPropertyLinks\";\n            const char k_widgetChildrenKey[] = \"Children\";\n            const char k_widgetChildPropertiesKey[] = \"ChildPropertyLinks\";\n            const char k_widgetPropertyDefaultsKey[] = \"DefaultPropertyValues\";\n            \n            UIComponentFactory* componentFactory = Application::Get()->GetSystem<UIComponentFactory>();\n            \n            //read the json\n            Json::Value root;\n            if (JsonUtils::ReadJson(in_storageLocation, in_filepath, root) == false)\n            {\n                CS_LOG_ERROR(\"Cannot read widget def file: \" + in_filepath);\n                out_resource->SetLoadState(Resource::LoadState::k_failed);\n                if(in_delegate != nullptr)\n                {\n                    Application::Get()->GetTaskScheduler()->ScheduleTask(TaskType::k_mainThread, [=](const TaskContext&) noexcept\n                    {\n                       in_delegate(out_resource);\n                    });\n                }\n                return;\n            }\n            \n            //get the type\n            WidgetDef* widgetDef = (WidgetDef*)out_resource.get();\n            \n            CS_ASSERT(root.isMember(k_widgetTypeKey), \"Widget def must have Type\");\n            std::string typeName = root[k_widgetTypeKey].asString();\n            \n            //parse components\n            std::string definitionFileName;\n            std::string pathToDefinition;\n            StringUtils::SplitFilename(in_filepath, definitionFileName, pathToDefinition);\n        \n            const Json::Value& componentsJson = root[k_widgetComponentsKey];\n            std::vector<UIComponentDesc> componentDescs;\n            if(componentsJson.isNull() == false)\n            {\n                componentDescs = ParseComponents(componentsJson, in_storageLocation, pathToDefinition, componentFactory);\n            }\n            \n            //parse component property links\n            std::vector<PropertyLink> componentPropertyLinks;\n            const Json::Value& componentPropertiesJson = root[k_widgetComponentPropertiesKey];\n            if(componentPropertiesJson.isNull() == false)\n            {\n                componentPropertyLinks = ParseLinkedComponentProperties(componentPropertiesJson, componentDescs);\n            }\n            \n            //parse children\n            const Json::Value& childrenJson = root[k_widgetChildrenKey];\n            std::vector<WidgetDesc> childDescs;\n            if(childrenJson.isNull() == false)\n            {\n                CS_ASSERT(childrenJson.isArray() == true, \"'\" + std::string(k_widgetChildrenKey) + \"' in a Widget Def must be an array.\");\n                childDescs = ParseChildWidgets(childrenJson, in_storageLocation, pathToDefinition);\n            }\n            \n            //parse child property links\n            std::vector<PropertyLink> childPropertyLinks;\n            const Json::Value& childProperties = root[k_widgetChildPropertiesKey];\n            if(childProperties.isNull() == false)\n            {\n                childPropertyLinks = ParseLinkedChildProperties(childProperties);\n            }\n            \n            //build the default values property map and read the default values from the json\n            PropertyMap defaultProperties = BuildPropertyMap(componentDescs, componentPropertyLinks, childDescs, childPropertyLinks);\n            const Json::Value& defaults = root[k_widgetPropertyDefaultsKey];\n            if(defaults.isNull() == false)\n            {\n                ParseDefaultValues(defaults, in_storageLocation, pathToDefinition, defaultProperties);\n            }\n\n            //build the widget def.\n            widgetDef->Build(typeName, defaultProperties, componentDescs, componentPropertyLinks, childDescs, childPropertyLinks);\n            out_resource->SetLoadState(Resource::LoadState::k_loaded);\n            \n            if(in_delegate != nullptr)\n            {\n                Application::Get()->GetTaskScheduler()->ScheduleTask(TaskType::k_mainThread, [=](const TaskContext&) noexcept\n                {\n                    in_delegate(out_resource);\n                });\n            }\n        }\n    }\n    \n    CS_DEFINE_NAMEDTYPE(WidgetDefProvider);\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    WidgetDefProviderUPtr WidgetDefProvider::Create()\n    {\n        return WidgetDefProviderUPtr(new WidgetDefProvider());\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    bool WidgetDefProvider::IsA(InterfaceIDType in_interfaceId) const\n    {\n        return (in_interfaceId == ResourceProvider::InterfaceID || in_interfaceId == WidgetDefProvider::InterfaceID);\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    InterfaceIDType WidgetDefProvider::GetResourceType() const\n    {\n        return WidgetDef::InterfaceID;\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    bool WidgetDefProvider::CanCreateResourceWithFileExtension(const std::string& in_extension) const\n    {\n        return (in_extension == k_extension);\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    void WidgetDefProvider::CreateResourceFromFile(StorageLocation in_storageLocation, const std::string& in_filepath, const IResourceOptionsBaseCSPtr& in_options, const ResourceSPtr& out_resource)\n    {\n        LoadDesc(in_storageLocation, in_filepath, nullptr, out_resource);\n    }\n    //----------------------------------------------------\n    //----------------------------------------------------\n    void WidgetDefProvider::CreateResourceFromFileAsync(StorageLocation in_storageLocation, const std::string& in_filepath, const IResourceOptionsBaseCSPtr& in_options, const AsyncLoadDelegate& in_delegate, const ResourceSPtr& out_resource)\n    {\n        //TODO: Async support.\n        CS_LOG_FATAL(\"Asynchronous loading of Widget Def is currently not supported. Feature coming soon!\");\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/UI/Base/WidgetDefProvider.h",
    "content": "//\n//  WidgetDefProvider.h\n//  ChilliSource\n//  Created by Scott Downie on 25/07/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_UI_BASE_WIDGETDEFPROVIDER_H_\n#define _CHILLISOURCE_UI_BASE_WIDGETDEFPROVIDER_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Resource/ResourceProvider.h>\n\nnamespace ChilliSource\n{\n    //-------------------------------------------------------------\n    /// A resource provider that creates widget descriptions for\n    /// file\n    ///\n    /// @author S Downie\n    //-------------------------------------------------------------\n    class WidgetDefProvider final : public ResourceProvider\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(WidgetDefProvider);\n\n        //-------------------------------------------------------\n        /// Is the object of the given interface type.\n        ///\n        /// @author S Downie\n        ///\n        /// @param Interface type to query\n        ///\n        /// @return Whether the object is of given type\n        //-------------------------------------------------------\n        bool IsA(InterfaceIDType in_interfaceId) const override;\n        //-------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return The resource type this provider can load\n        //-------------------------------------------------------\n        InterfaceIDType GetResourceType() const override;\n        //-------------------------------------------------------\n        /// Queries whether or not this provider can create\n        /// resources from files with the given extension.\n        ///\n        /// @author S Downie\n        ///\n        /// @param Extension to compare against\n        ///\n        /// @return Whether the object can load a resource with\n        /// that extension\n        //-------------------------------------------------------\n        bool CanCreateResourceWithFileExtension(const std::string& in_extension) const override;\n        //-------------------------------------------------------\n        /// Creates a new desc from file. Check the resource\n        /// load state for success or failure\n        ///\n        /// @author S Downie\n        ///\n        /// @param The storage location to load from\n        /// @param File path to resource\n        /// @param Options to customise the creation\n        /// @param [Out] Resource\n        //-------------------------------------------------------\n        void CreateResourceFromFile(StorageLocation in_storageLocation, const std::string& in_filepath, const IResourceOptionsBaseCSPtr& in_options, const ResourceSPtr& out_resource) override;\n        //----------------------------------------------------\n        /// Creates a new resource from file asynchronously.\n        /// Completion delegate is called on finish. Check\n        /// the resource load state for success or failure\n        ///\n        /// @author S Downie\n        ///\n        /// @param The storage location.\n        /// @param The filepath.\n        /// @param Options to customise the creation\n        /// @param Completion delegate\n        /// @param [Out] The output resource.\n        //----------------------------------------------------\n        void CreateResourceFromFileAsync(StorageLocation in_storageLocation, const std::string& in_filepath, const IResourceOptionsBaseCSPtr& in_options, const AsyncLoadDelegate& in_delegate, const ResourceSPtr& out_resource) override;\n    private:\n        \n        friend class Application;\n        //-------------------------------------------------------\n        /// Factory method\n        ///\n        /// @author S Downie\n        ///\n        /// @return New backend with ownership transferred\n        //-------------------------------------------------------\n        static WidgetDefProviderUPtr Create();\n    };\n}\n\n#endif\n\n"
  },
  {
    "path": "Source/ChilliSource/UI/Base/WidgetDesc.cpp",
    "content": "//\n//  WidgetDesc.cpp\n//  ChilliSource\n//  Created by Ian Copland on 19/11/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/UI/Base/WidgetDesc.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------\n    //------------------------------------------------------------------\n    WidgetDesc::WidgetDesc(const std::string& in_type, const PropertyMap& in_propertyMap, const std::vector<WidgetDesc>& in_childDescs)\n        : m_type(in_type), m_propertyMap(in_propertyMap), m_childDescs(in_childDescs)\n    {\n    }\n    //------------------------------------------------------------------\n    //------------------------------------------------------------------\n    const std::string& WidgetDesc::GetType() const\n    {\n        return m_type;\n    }\n    //------------------------------------------------------------------\n    //------------------------------------------------------------------\n    const PropertyMap& WidgetDesc::GetProperties() const\n    {\n        return m_propertyMap;\n    }\n    //------------------------------------------------------------------\n    //------------------------------------------------------------------\n    const std::vector<WidgetDesc>& WidgetDesc::GetChildDescs() const\n    {\n        return m_childDescs;\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/UI/Base/WidgetDesc.h",
    "content": "//\n//  WidgetDesc.h\n//  ChilliSource\n//  Created by Ian Copland on 19/11/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_UI_BASE_WIDGETDESC_H_\n#define _CHILLISOURCE_UI_BASE_WIDGETDESC_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Container/Property/PropertyMap.h>\n\n#include <vector>\n\nnamespace ChilliSource\n{\n    //--------------------------------------------------------------------------\n    /// A container for a description of a single widget, comprising of a type\n    /// and a map of properties for the given widget type and a list of child\n    /// widgets. Typically this is only used in the creation of a WidgetDef and\n    /// in most cases this does not need to be dealt with directly as the\n    /// resource provider handles it when loading a widget from file. This is\n    /// immutable after construction.\n    ///\n    /// @param Ian Copland\n    //--------------------------------------------------------------------------\n    class WidgetDesc final\n    {\n    public:\n        //------------------------------------------------------------------\n        /// Constructor. Creates an empty description.\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------------------------\n        WidgetDesc() = default;\n        //------------------------------------------------------------------\n        /// Constructor.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The name of the widget type this desc will create.\n        /// @param The map of properties the widget should be created with.\n        /// @param The list of child widget descriptions.\n        //------------------------------------------------------------------\n        WidgetDesc(const std::string& in_type, const PropertyMap& in_properties, const std::vector<WidgetDesc>& in_childDescs);\n        //------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The name of the widget type this desc will create.\n        //------------------------------------------------------------------\n        const std::string& GetType() const;\n        //------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The map of properties the widget should be created with.\n        //------------------------------------------------------------------\n        const PropertyMap& GetProperties() const;\n        //------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The list of child widget descriptions.\n        //------------------------------------------------------------------\n        const std::vector<WidgetDesc>& GetChildDescs() const;\n    private:\n        std::string m_type = \"\";\n        PropertyMap m_propertyMap;\n        std::vector<WidgetDesc> m_childDescs;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/UI/Base/WidgetFactory.cpp",
    "content": "//\n//  WidgetFactory.cpp\n//  ChilliSource\n//  Created by Scott Downie on 25/07/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n\n#include <ChilliSource/UI/Base/WidgetFactory.h>\n\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/Delegate/MakeDelegate.h>\n#include <ChilliSource/Core/Resource/ResourcePool.h>\n#include <ChilliSource/Input/Pointer/PointerSystem.h>\n#include <ChilliSource/Rendering/Base/AlignmentAnchors.h>\n#include <ChilliSource/UI/Base/UIComponent.h>\n#include <ChilliSource/UI/Base/UIComponentFactory.h>\n#include <ChilliSource/UI/Base/Widget.h>\n#include <ChilliSource/UI/Base/WidgetDef.h>\n#include <ChilliSource/UI/Base/WidgetTemplate.h>\n#include <ChilliSource/UI/Drawable/NinePatchUIDrawable.h>\n#include <ChilliSource/UI/Drawable/StandardUIDrawable.h>\n#include <ChilliSource/UI/Drawable/ThreePatchUIDrawable.h>\n#include <ChilliSource/UI/Layout/GridUILayout.h>\n#include <ChilliSource/UI/Layout/HListUILayout.h>\n#include <ChilliSource/UI/Layout/VListUILayout.h>\n\nnamespace ChilliSource\n{\n    CS_DEFINE_NAMEDTYPE(WidgetFactory);\n    \n    namespace\n    {\n        const std::string k_widgetKey = \"Widget\";\n        const std::string k_imageKey = \"Image\";\n        const std::string k_highlightButtonKey = \"HighlightButton\";\n        const std::string k_toggleButtonKey = \"ToggleButton\";\n        const std::string k_labelKey = \"Label\";\n        const std::string k_layoutKey = \"Layout\";\n        const std::string k_verticalSliderKey = \"VerticalSlider\";\n        const std::string k_horizontalSliderKey = \"HorizontalSlider\";\n        const std::string k_verticalFillProgressBarKey = \"VerticalFillProgressBar\";\n        const std::string k_horizontalFillProgressBarKey = \"HorizontalFillProgressBar\";\n        const std::string k_verticalStretchProgressBarKey = \"VerticalStretchProgressBar\";\n        const std::string k_horizontalStretchProgressBarKey = \"HorizontalStretchProgressBar\";\n        const std::string k_editableLabelKey = \"EditableLabel\";\n    }\n    \n    //---------------------------------------------------------------------------\n    //---------------------------------------------------------------------------\n    WidgetFactoryUPtr WidgetFactory::Create()\n    {\n        return WidgetFactoryUPtr(new WidgetFactory());\n    }\n    //---------------------------------------------------------------------------\n    //---------------------------------------------------------------------------\n    bool WidgetFactory::IsA(InterfaceIDType in_interfaceId) const\n    {\n        return in_interfaceId == WidgetFactory::InterfaceID;\n    }\n    //---------------------------------------------------------------------------\n    //---------------------------------------------------------------------------\n    void WidgetFactory::OnInit()\n    {\n        m_componentFactory = Application::Get()->GetSystem<UIComponentFactory>();\n        CS_ASSERT(m_componentFactory != nullptr, \"WidgetFactory is missing required system: UIComponentFactory\");\n        \n        auto resPool = Application::Get()->GetResourcePool();\n\n        WidgetDefCSPtr widgetDef = resPool->LoadResource<WidgetDef>(StorageLocation::k_chilliSource, \"Widgets/Widget.csuidef\");\n        RegisterDefinition(widgetDef);\n        \n        WidgetDefCSPtr imageDef = resPool->LoadResource<WidgetDef>(StorageLocation::k_chilliSource, \"Widgets/Image.csuidef\");\n        RegisterDefinition(imageDef);\n        \n        WidgetDefCSPtr layoutDef = resPool->LoadResource<WidgetDef>(StorageLocation::k_chilliSource, \"Widgets/Layout.csuidef\");\n        RegisterDefinition(layoutDef);\n        \n        WidgetDefCSPtr highlightButtonDef = resPool->LoadResource<WidgetDef>(StorageLocation::k_chilliSource, \"Widgets/HighlightButton.csuidef\");\n        RegisterDefinition(highlightButtonDef);\n        \n        WidgetDefCSPtr toggleButtonDef = resPool->LoadResource<WidgetDef>(StorageLocation::k_chilliSource, \"Widgets/ToggleButton.csuidef\");\n        RegisterDefinition(toggleButtonDef);\n        \n        WidgetDefCSPtr horizontalSliderDef = resPool->LoadResource<WidgetDef>(StorageLocation::k_chilliSource, \"Widgets/HorizontalSlider.csuidef\");\n        RegisterDefinition(horizontalSliderDef);\n        \n        WidgetDefCSPtr verticalSliderDef = resPool->LoadResource<WidgetDef>(StorageLocation::k_chilliSource, \"Widgets/VerticalSlider.csuidef\");\n        RegisterDefinition(verticalSliderDef);\n\n        WidgetDefCSPtr horizontalFillProgressBarDef = resPool->LoadResource<WidgetDef>(StorageLocation::k_chilliSource, \"Widgets/HorizontalFillProgressBar.csuidef\");\n        RegisterDefinition(horizontalFillProgressBarDef);\n        \n        WidgetDefCSPtr horizontalStretchProgressBarDef = resPool->LoadResource<WidgetDef>(StorageLocation::k_chilliSource, \"Widgets/HorizontalStretchProgressBar.csuidef\");\n        RegisterDefinition(horizontalStretchProgressBarDef);\n        \n        WidgetDefCSPtr verticalFillProgressBarDef = resPool->LoadResource<WidgetDef>(StorageLocation::k_chilliSource, \"Widgets/VerticalFillProgressBar.csuidef\");\n        RegisterDefinition(verticalFillProgressBarDef);\n        \n        WidgetDefCSPtr verticalStretchProgressBarDef = resPool->LoadResource<WidgetDef>(StorageLocation::k_chilliSource, \"Widgets/VerticalStretchProgressBar.csuidef\");\n        RegisterDefinition(verticalStretchProgressBarDef);\n        \n        WidgetDefCSPtr labelDef = resPool->LoadResource<WidgetDef>(StorageLocation::k_chilliSource, \"Widgets/Label.csuidef\");\n        RegisterDefinition(labelDef);\n\n        WidgetDefCSPtr editableLabelDef = resPool->LoadResource<WidgetDef>(StorageLocation::k_chilliSource, \"Widgets/EditableLabel.csuidef\");\n        RegisterDefinition(editableLabelDef);\n    }\n    //---------------------------------------------------------------------------\n    //---------------------------------------------------------------------------\n    void WidgetFactory::RegisterDefinition(const WidgetDefCSPtr& in_def)\n    {\n        m_widgetDefNameMap.insert(std::make_pair(in_def->GetTypeName(), in_def));\n    }\n    //---------------------------------------------------------------------------\n    //---------------------------------------------------------------------------\n    WidgetDefCSPtr WidgetFactory::GetDefinition(const std::string& in_nameKey) const\n    {\n        auto it = m_widgetDefNameMap.find(in_nameKey);\n        CS_ASSERT(it != m_widgetDefNameMap.end(), \"No such widget def with name: \" + in_nameKey);\n        return it->second;\n    }\n    //---------------------------------------------------------------------------\n    //---------------------------------------------------------------------------\n    WidgetUPtr WidgetFactory::Create(const WidgetDefCSPtr& in_def) const\n    {\n        WidgetDesc desc(in_def->GetTypeName(), in_def->GetDefaultProperties(), std::vector<WidgetDesc>());\n        \n        return CreateRecursive(in_def, desc);\n    }\n    //---------------------------------------------------------------------------\n    //---------------------------------------------------------------------------\n    WidgetUPtr WidgetFactory::Create(const WidgetTemplateCSPtr& in_template) const\n    {\n        auto def = m_widgetDefNameMap.find(in_template->GetWidgetDesc().GetType())->second;\n        CS_ASSERT(def != nullptr, \"Invalid widget type in widget template: \" + in_template->GetFilePath());\n        \n        return CreateRecursive(def, in_template->GetWidgetDesc());\n    }\n    //---------------------------------------------------------------------------\n    //---------------------------------------------------------------------------\n    WidgetUPtr WidgetFactory::CreateWidget() const\n    {\n        return Create(m_widgetDefNameMap.find(k_widgetKey)->second);\n    }\n    //---------------------------------------------------------------------------\n    //---------------------------------------------------------------------------\n    WidgetUPtr WidgetFactory::CreateImage() const\n    {\n        return Create(m_widgetDefNameMap.find(k_imageKey)->second);\n    }\n    //---------------------------------------------------------------------------\n    //---------------------------------------------------------------------------\n    WidgetUPtr WidgetFactory::CreateHighlightButton() const\n    {\n        return Create(m_widgetDefNameMap.find(k_highlightButtonKey)->second);\n    }\n    //---------------------------------------------------------------------------\n    //---------------------------------------------------------------------------\n    WidgetUPtr WidgetFactory::CreateToggleButton() const\n    {\n        return Create(m_widgetDefNameMap.find(k_toggleButtonKey)->second);\n    }\n    //---------------------------------------------------------------------------\n    //---------------------------------------------------------------------------\n    WidgetUPtr WidgetFactory::CreateLabel() const\n    {\n        return Create(m_widgetDefNameMap.find(k_labelKey)->second);\n    }\n    //---------------------------------------------------------------------------\n    //---------------------------------------------------------------------------\n    WidgetUPtr WidgetFactory::CreateLayout() const\n    {\n        return Create(m_widgetDefNameMap.find(k_layoutKey)->second);\n    }\n    //---------------------------------------------------------------------------\n    //---------------------------------------------------------------------------\n    WidgetUPtr WidgetFactory::CreateHorizontalSlider() const\n    {\n        return Create(m_widgetDefNameMap.find(k_horizontalSliderKey)->second);\n    }\n    //---------------------------------------------------------------------------\n    //---------------------------------------------------------------------------\n    WidgetUPtr WidgetFactory::CreateVerticalSlider() const\n    {\n        return Create(m_widgetDefNameMap.find(k_verticalSliderKey)->second);\n    }\n    //---------------------------------------------------------------------------\n    //---------------------------------------------------------------------------\n    WidgetUPtr WidgetFactory::CreateHorizontalFillProgressBar() const\n    {\n        return Create(m_widgetDefNameMap.find(k_horizontalFillProgressBarKey)->second);\n    }\n    //---------------------------------------------------------------------------\n    //---------------------------------------------------------------------------\n    WidgetUPtr WidgetFactory::CreateVerticalFillProgressBar() const\n    {\n        return Create(m_widgetDefNameMap.find(k_verticalFillProgressBarKey)->second);\n    }\n    //---------------------------------------------------------------------------\n    //---------------------------------------------------------------------------\n    WidgetUPtr WidgetFactory::CreateHorizontalStretchProgressBar() const\n    {\n        return Create(m_widgetDefNameMap.find(k_horizontalStretchProgressBarKey)->second);\n    }\n    //---------------------------------------------------------------------------\n    //---------------------------------------------------------------------------\n    WidgetUPtr WidgetFactory::CreateVerticalStretchProgressBar() const\n    {\n        return Create(m_widgetDefNameMap.find(k_verticalStretchProgressBarKey)->second);\n    }\n    //---------------------------------------------------------------------------\n    //---------------------------------------------------------------------------\n    WidgetUPtr WidgetFactory::CreateEditableLabel() const\n    {\n        return Create(m_widgetDefNameMap.find(k_editableLabelKey)->second);\n    }\n    //---------------------------------------------------------------------------\n    //---------------------------------------------------------------------------\n    WidgetUPtr WidgetFactory::CreateRecursive(const WidgetDefCSPtr& in_widgetDef, const WidgetDesc& in_widgetDesc) const\n    {\n        //create the components\n        std::vector<UIComponentUPtr> components;\n        for (const auto& componentDesc : in_widgetDef->GetComponentDescs())\n        {\n            components.push_back(m_componentFactory->CreateComponent(componentDesc.GetType(), componentDesc.GetName(), componentDesc.GetProperties()));\n        }\n        \n        //create the internal children\n        std::vector<WidgetUPtr> internalChildren;\n        for (const auto& internalChild : in_widgetDef->GetChildDescs())\n        {\n            auto def = m_widgetDefNameMap.find(internalChild.GetType())->second;\n            CS_ASSERT(def != nullptr, \"Invalid widget def type in internal child widget.\");\n            \n            WidgetUPtr childWidget = CreateRecursive(def, internalChild);\n            internalChildren.push_back(std::move(childWidget));\n        }\n        \n        //create the widget.\n        WidgetUPtr widget(new Widget(in_widgetDesc.GetProperties(), std::move(components), in_widgetDef->GetComponentPropertyLinks(), std::move(internalChildren), in_widgetDef->GetChildPropertyLinks()));\n        \n        //create and add the external children.\n        for(const auto& childDesc : in_widgetDesc.GetChildDescs())\n        {\n            auto def = m_widgetDefNameMap.find(childDesc.GetType())->second;\n            CS_ASSERT(def != nullptr, \"Invalid widget def type in internal child widget.\");\n            \n            WidgetSPtr childWidget = CreateRecursive(def, childDesc);\n            widget->AddWidget(childWidget);\n        }\n        \n        return widget;\n    }\n    //---------------------------------------------------------------------------\n    //---------------------------------------------------------------------------\n    void WidgetFactory::OnDestroy()\n    {\n        m_widgetDefNameMap.clear();\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/UI/Base/WidgetFactory.h",
    "content": "//\n//  WidgetFactory.h\n//  ChilliSource\n//  Created by Scott Downie on 25/07/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_UI_BASE_WIDGETFACTORY_H_\n#define _CHILLISOURCE_UI_BASE_WIDGETFACTORY_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/System/AppSystem.h>\n\n#include <unordered_map>\n\nnamespace ChilliSource\n{\n    //--------------------------------------------------------\n    /// System that has convenience methods for creating\n    /// widgets\n    ///\n    /// @author S Downie\n    //--------------------------------------------------------\n    class WidgetFactory final : public AppSystem\n    {\n    public:\n        \n        CS_DECLARE_NAMEDTYPE(WidgetFactory);\n\n        //---------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Interface Id\n        ///\n        /// @return If the object is of the given interface type\n        //---------------------------------------------------------------------------\n        bool IsA(InterfaceIDType in_interfaceId) const override;\n        //---------------------------------------------------------------------------\n        /// Register the given widget definition so it is accessible via its type name.\n        /// This allows UI files to reference the definition by a readable name\n        ///\n        /// @author S Downie\n        ///\n        /// @param Widget def resource\n        //---------------------------------------------------------------------------\n        void RegisterDefinition(const WidgetDefCSPtr& in_def);\n        //---------------------------------------------------------------------------\n        /// Get the widget definition that is keyed on the given name\n        ///\n        /// @author S Downie\n        ///\n        /// @param Name key\n        ///\n        /// @return Widget def resource\n        //---------------------------------------------------------------------------\n        WidgetDefCSPtr GetDefinition(const std::string& in_nameKey) const;\n        //---------------------------------------------------------------------------\n        /// Creates a new widget based on the given definition. The type of the\n        /// widget is described by its children, behaviour and properties\n        ///\n        /// @author S Downie\n        ///\n        /// @param Widget def resource\n        ///\n        /// @return Widget with look and behaviour described by definition\n        //---------------------------------------------------------------------------\n        WidgetUPtr Create(const WidgetDefCSPtr& in_def) const;\n        //---------------------------------------------------------------------------\n        /// Creates a new widget based on the given template. The type of the\n        /// widget is set within the template\n        ///\n        /// @author S Downie\n        ///\n        /// @param Widget template resource\n        ///\n        /// @return Widget\n        //---------------------------------------------------------------------------\n        WidgetUPtr Create(const WidgetTemplateCSPtr& in_template) const;\n        //---------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return A new standard widget.\n        //---------------------------------------------------------------------------\n        WidgetUPtr CreateWidget() const;\n        //---------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return A new image widget.\n        //---------------------------------------------------------------------------\n        WidgetUPtr CreateImage() const;\n        //---------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return A new highlight button widget.\n        //---------------------------------------------------------------------------\n        WidgetUPtr CreateHighlightButton() const;\n        //---------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return A new toggle button widget.\n        //---------------------------------------------------------------------------\n        WidgetUPtr CreateToggleButton() const;\n        //---------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return A new label widget.\n        //---------------------------------------------------------------------------\n        WidgetUPtr CreateLabel() const;\n        //---------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return A new layout widget.\n        //---------------------------------------------------------------------------\n        WidgetUPtr CreateLayout() const;\n        //---------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return A new horizontal slider widget.\n        //---------------------------------------------------------------------------\n        WidgetUPtr CreateHorizontalSlider() const;\n        //---------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return A new vertical slider widget.\n        //---------------------------------------------------------------------------\n        WidgetUPtr CreateVerticalSlider() const;\n        //---------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return A new horizontal fill progress bar.\n        //---------------------------------------------------------------------------\n        WidgetUPtr CreateHorizontalFillProgressBar() const;\n        //---------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return A new vertical fill progress bar.\n        //---------------------------------------------------------------------------\n        WidgetUPtr CreateVerticalFillProgressBar() const;\n        //---------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return A new horizontal stretch progress bar.\n        //---------------------------------------------------------------------------\n        WidgetUPtr CreateHorizontalStretchProgressBar() const;\n        //---------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return A new vertical stretch progress bar.\n        //---------------------------------------------------------------------------\n        WidgetUPtr CreateVerticalStretchProgressBar() const;\n        //---------------------------------------------------------------------------\n        /// @author Jordan Brown\n        ///\n        /// @return A new editable label.\n        //---------------------------------------------------------------------------\n        WidgetUPtr CreateEditableLabel() const;\n        \n    private:\n        \n        friend class Application;\n        //---------------------------------------------------------------------------\n        /// Creation method used by application to instantiate\n        /// the system\n        ///\n        /// @author S Downie\n        ///\n        /// @return Ownership of new factory\n        //---------------------------------------------------------------------------\n        static WidgetFactoryUPtr Create();\n        //---------------------------------------------------------------------------\n        /// Private constructor to enforce the use of factory\n        /// method\n        ///\n        /// @author S Downie\n        //---------------------------------------------------------------------------\n        WidgetFactory() = default;\n        //---------------------------------------------------------------------------\n        /// Called when the system is created in order to create the built-in\n        /// widget types\n        ///\n        /// @author S Downie\n        //---------------------------------------------------------------------------\n        void OnInit() override;\n        //---------------------------------------------------------------------------\n        /// Recursively create the widget hierarchy from the hierarchy desc\n        ///\n        /// @author S Downie\n        ///\n        /// @param The widget definition.\n        /// @param The widget description.\n        ///\n        /// @return The output widget\n        //---------------------------------------------------------------------------\n        WidgetUPtr CreateRecursive(const WidgetDefCSPtr& in_widgetDef, const WidgetDesc& in_widgetDesc) const;\n        //---------------------------------------------------------------------------\n        /// Called when the system is destroyed and will release\n        /// any memory held\n        ///\n        /// @author S Downie\n        //---------------------------------------------------------------------------\n        void OnDestroy() override;\n        \n    private:\n        \n        UIComponentFactory* m_componentFactory;\n        std::unordered_map<std::string, WidgetDefCSPtr> m_widgetDefNameMap;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/UI/Base/WidgetParserUtils.cpp",
    "content": "//\n//  WidgetParserUtils.cpp\n//  ChilliSource\n//  Created by Scott Downie on 25/07/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/UI/Base/WidgetParserUtils.h>\n\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/Container/Property/PropertyMap.h>\n#include <ChilliSource/Core/Json/JsonUtils.h>\n#include <ChilliSource/Core/Localisation/LocalisedText.h>\n#include <ChilliSource/Core/Resource/ResourcePool.h>\n#include <ChilliSource/Core/String/StringParser.h>\n#include <ChilliSource/Rendering/Base/HorizontalTextJustification.h>\n#include <ChilliSource/Rendering/Base/VerticalTextJustification.h>\n#include <ChilliSource/Rendering/Font/Font.h>\n#include <ChilliSource/Rendering/Texture/Texture.h>\n#include <ChilliSource/Rendering/Texture/TextureAtlas.h>\n#include <ChilliSource/UI/Base/PropertyTypes.h>\n#include <ChilliSource/UI/Base/Widget.h>\n#include <ChilliSource/UI/Base/WidgetDef.h>\n#include <ChilliSource/UI/Base/WidgetDesc.h>\n#include <ChilliSource/UI/Base/WidgetFactory.h>\n#include <ChilliSource/UI/Base/WidgetTemplate.h>\n#include <ChilliSource/UI/Drawable/UIDrawableDef.h>\n#include <ChilliSource/UI/Layout/UILayoutDef.h>\n\n#include <json/json.h>\n\nnamespace ChilliSource\n{\n    namespace WidgetParserUtils\n    {\n        //-------------------------------------------------------\n        /// Loads a storage location and file path from the given\n        /// json. If a storage location is not specified this\n        /// will use the resource is considered to be relative\n        /// to the given path and location.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The json object.\n        /// @param The relative storage location.\n        /// @param The relative directory path.\n        ///\n        /// @return a pair containing the storage location and\n        /// file path of the resource.\n        //-------------------------------------------------------\n        std::pair<StorageLocation, std::string> ParseResource(const Json::Value& in_jsonValue, StorageLocation in_relStorageLocation, const std::string& in_relDirectoryPath)\n        {\n            const char k_resourceFilePathKey[] = \"Path\";\n            const char k_resourceLocationKey[] = \"Location\";\n            \n            CS_ASSERT(in_jsonValue.isObject(), \"Resource json must be an object.\");\n            CS_ASSERT(in_jsonValue.isMember(k_resourceFilePathKey) == true, \"Resource json must contain a '\" + std::string(k_resourceFilePathKey) + \"' key.\");\n            \n            const Json::Value& pathJson = in_jsonValue.get(k_resourceFilePathKey, Json::nullValue);\n            CS_ASSERT(pathJson.isString() == true, \"'\" + std::string(k_resourceFilePathKey) + \"' must be a string.\");\n            \n            std::string outputPath = pathJson.asString();\n            \n            StorageLocation outputLocation;\n            if (in_jsonValue.isMember(k_resourceLocationKey) == true)\n            {\n                const Json::Value& locationJson = in_jsonValue.get(k_resourceLocationKey, Json::nullValue);\n                CS_ASSERT(locationJson.isString() == true, \"'\" + std::string(k_resourceLocationKey) + \"' must be a string.\");\n\n                outputLocation = ParseStorageLocation(locationJson.asString());\n            }\n            else\n            {\n                outputLocation = in_relStorageLocation;\n                outputPath = StringUtils::StandardiseDirectoryPath(in_relDirectoryPath) + outputPath;\n            }\n            \n            return std::make_pair(outputLocation, outputPath);\n        }\n        //-------------------------------------------------------\n        //-------------------------------------------------------\n        void SetProperty(const std::string& in_propertyName, const Json::Value& in_jsonValue, StorageLocation in_relStorageLocation, const std::string& in_relDirectoryPath, PropertyMap& out_propertyMap)\n        {\n            auto propertyType = out_propertyMap.GetType(in_propertyName);\n            \n            if (propertyType == PropertyTypes::Texture())\n            {\n                auto resourcePair = ParseResource(in_jsonValue, in_relStorageLocation, in_relDirectoryPath);\n                auto texture = Application::Get()->GetResourcePool()->LoadResource<Texture>(resourcePair.first, resourcePair.second);\n                out_propertyMap.SetProperty(in_propertyName, texture);\n            }\n            else if (propertyType == PropertyTypes::TextureAtlas())\n            {\n                auto resourcePair = ParseResource(in_jsonValue, in_relStorageLocation, in_relDirectoryPath);\n                auto textureAtlas = Application::Get()->GetResourcePool()->LoadResource<TextureAtlas>(resourcePair.first, resourcePair.second);\n                out_propertyMap.SetProperty(in_propertyName, textureAtlas);\n            }\n            else if (propertyType == PropertyTypes::Font())\n            {\n                auto resourcePair = ParseResource(in_jsonValue, in_relStorageLocation, in_relDirectoryPath);\n                auto font = Application::Get()->GetResourcePool()->LoadResource<Font>(resourcePair.first, resourcePair.second);\n                out_propertyMap.SetProperty(in_propertyName, font);\n            }\n            else if (propertyType == PropertyTypes::LocalisedText())\n            {\n                auto resourcePair = ParseResource(in_jsonValue, in_relStorageLocation, in_relDirectoryPath);\n                auto localisedText = Application::Get()->GetResourcePool()->LoadResource<LocalisedText>(resourcePair.first, resourcePair.second);\n                out_propertyMap.SetProperty(in_propertyName, localisedText);\n            }\n            else if (propertyType == PropertyTypes::UIDrawableDef())\n            {\n                CS_ASSERT(in_jsonValue.isObject(), \"Value can only be specified as an object: \" + in_propertyName);\n                UIDrawableDefCSPtr drawableDef = UIDrawableDef::Create(in_jsonValue, in_relStorageLocation, in_relDirectoryPath);\n                out_propertyMap.SetProperty(in_propertyName, drawableDef);\n            }\n            else if (propertyType == PropertyTypes::UILayoutDef())\n            {\n                CS_ASSERT(in_jsonValue.isObject(), \"Value can only be specified as an object: \" + in_propertyName);\n                UILayoutDefCSPtr layoutDef = UILayoutDef::Create(in_jsonValue);\n                out_propertyMap.SetProperty(in_propertyName, layoutDef);\n            }\n            else\n            {\n                CS_ASSERT(in_jsonValue.isString(), \"Value can only be specified as a string: \" + in_propertyName);\n                out_propertyMap.ParseProperty(in_propertyName, in_jsonValue.asString());\n            }\n        }\n        //-------------------------------------------------------\n        //-------------------------------------------------------\n        WidgetDesc ParseWidget(const Json::Value& in_widget, StorageLocation in_templateLocation, const std::string& in_templatePath)\n        {\n            const char k_widgetTypeKey[] = \"Type\";\n            const char k_widgetChildrenKey[] = \"Children\";\n            const char k_templateTypeName[] = \"Template\";\n            const char k_templateFilePathKey[] = \"TemplatePath\";\n            const char k_templateLocationKey[] = \"TemplateLocation\";\n            \n            CS_ASSERT(in_widget.isMember(k_widgetTypeKey) == true, \"Widget must have '\" + std::string(k_widgetTypeKey) + \"' key.\");\n            \n            std::string outputType = in_widget[k_widgetTypeKey].asString();\n            PropertyMap outputProperties;\n            std::vector<WidgetDesc> outputChildren;\n            \n            if(outputType == k_templateTypeName)\n            {\n                //This type is a special case in which the property values are read from a separate template file\n                CS_ASSERT(in_widget.isMember(k_templateFilePathKey), \"Link to template file must have '\" + std::string(k_templateFilePathKey) + \"' key.\");\n                \n                bool relativePath = in_widget.isMember(k_templateLocationKey) == false;\n                StorageLocation location = in_templateLocation;\n                std::string path = in_widget[k_templateFilePathKey].asString();\n                \n                if(relativePath == false)\n                {\n                    location = ParseStorageLocation(in_widget[k_templateLocationKey].asString());\n                }\n                else\n                {\n                    path = StringUtils::ResolveParentedDirectories(in_templatePath + path);\n                }\n                \n                //Template widgets need to be created as a hierarchy so that we can set properties such as layout\n                //on the widget without affecting the contents of the template and vice-versa.\n                outputType = \"Widget\";\n                outputProperties = PropertyMap(Widget::GetPropertyDescs());\n\n                //TODO: this will not work with async loading.\n                WidgetTemplateCSPtr widgetTemplate = Application::Get()->GetResourcePool()->LoadResource<WidgetTemplate>(location, path);\n                outputChildren.push_back(widgetTemplate->GetWidgetDesc());\n            }\n            else\n            {\n                auto widgetFactory = Application::Get()->GetWidgetFactory();\n                WidgetDefCSPtr widgetDef = widgetFactory->GetDefinition(outputType);\n                outputProperties = widgetDef->GetDefaultProperties();\n            }\n            \n            for(auto it = in_widget.begin(); it != in_widget.end(); ++it)\n            {\n                std::string propertyName = it.memberName();\n                \n                //ignore template properties, children and type since they're already handled.\n                if (propertyName != k_templateLocationKey && propertyName != k_templateFilePathKey && propertyName != k_widgetChildrenKey && propertyName != k_widgetTypeKey)\n                {\n                    if (outputProperties.HasKey(propertyName) == true)\n                    {\n                        SetProperty(propertyName, (*it), in_templateLocation, in_templatePath, outputProperties);\n                    }\n                    else\n                    {\n                        CS_LOG_FATAL(\"Property with name does not exist: \" + std::string(propertyName));\n                    }\n                }\n            }\n            \n            const Json::Value& childrenJson = in_widget.get(k_widgetChildrenKey, Json::nullValue);\n            if(childrenJson.isNull() == false)\n            {\n                CS_ASSERT(childrenJson.isArray() == true, \"The '\" + std::string(k_widgetChildrenKey) + \"' must be in an array.\");\n                \n                for(u32 i = 0; i < childrenJson.size(); ++i)\n                {\n                    const Json::Value& childJson = childrenJson[i];\n                    WidgetDesc childDesc = ParseWidget(childJson, in_templateLocation, in_templatePath);\n                    outputChildren.push_back(childDesc);\n                }\n            }\n            \n            return WidgetDesc(outputType, outputProperties, outputChildren);\n        }\n    }\n}\n\n"
  },
  {
    "path": "Source/ChilliSource/UI/Base/WidgetParserUtils.h",
    "content": "//\n//  WidgetParserUtils.h\n//  ChilliSource\n//  Created by Scott Downie on 29/07/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_UI_BASE_WIDGETPARSERUTILS_H_\n#define _CHILLISOURCE_UI_BASE_WIDGETPARSERUTILS_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Container/Property/PropertyMap.h>\n#include <ChilliSource/Core/File/StorageLocation.h>\n\n#include <json/forwards.h>\n\nnamespace ChilliSource\n{\n    namespace WidgetParserUtils\n    {\n        //-------------------------------------------------------\n        /// Loads a storage location and file path from the given\n        /// json. If a storage location is not specified this\n        /// will use the resource is considered to be relative\n        /// to the given path and location.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The json object.\n        /// @param [Optional] The relative storage location.\n        /// @param [Optional] The relative directory path.\n        ///\n        /// @return a pair containing the storage location and\n        /// file path of the resource.\n        //-------------------------------------------------------\n        std::pair<StorageLocation, std::string> ParseResource(const Json::Value& in_jsonValue, StorageLocation in_relStorageLocation = StorageLocation::k_package, const std::string& in_relDirectoryPath = \"\");\n        //-------------------------------------------------------\n        /// Sets a property in a property map from a json value.\n        /// The value type must be a string or a json object or\n        /// this will assert.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The property name.\n        /// @param The json value.\n        /// @param [Out] The output property map.\n        //-------------------------------------------------------\n        void SetProperty(const std::string& in_propertyName, const Json::Value& in_jsonValue, StorageLocation in_relStorageLocation, const std::string& in_relDirectoryPath, PropertyMap& out_propertyMap);\n        //-------------------------------------------------------\n        /// From the given JSON value parse the values of the property\n        /// types into the given container. Some of the properties\n        /// require conversion from relative to absolute paths\n        /// hence the definition path info.\n        ///\n        /// @author S Downie\n        ///\n        /// @param The widget json.\n        /// @param Template location.\n        /// @param Template path (no file name)\n        ///\n        /// @return The output widget description.\n        //-------------------------------------------------------\n        WidgetDesc ParseWidget(const Json::Value& in_widget, StorageLocation in_templateLocation, const std::string& in_templatePath);\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/UI/Base/WidgetTemplate.cpp",
    "content": "//\n//  WidgetTemplate.cpp\n//  ChilliSource\n//  Created by Scott Downie on 30/07/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/UI/Base/WidgetTemplate.h>\n\n#include <ChilliSource/Core/Container/Property/PropertyMap.h>\n\nnamespace ChilliSource\n{\n    CS_DEFINE_NAMEDTYPE(WidgetTemplate);\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    WidgetTemplateUPtr WidgetTemplate::Create()\n    {\n        return WidgetTemplateUPtr(new WidgetTemplate());\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    WidgetTemplate::WidgetTemplate()\n        : m_desc(\"\", PropertyMap(), std::vector<WidgetDesc>())\n    {\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    bool WidgetTemplate::IsA(InterfaceIDType in_interfaceId) const\n    {\n        return in_interfaceId == WidgetTemplate::InterfaceID;\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    void WidgetTemplate::Build(const WidgetDesc& in_desc)\n    {\n        m_desc = in_desc;\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    const WidgetDesc& WidgetTemplate::GetWidgetDesc() const\n    {\n        return m_desc;\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/UI/Base/WidgetTemplate.h",
    "content": "//\n//  WidgetTemplate.h\n//  ChilliSource\n//  Created by Scott Downie on 30/07/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_UI_BASE_WIDGETTEMPLATE_H_\n#define _CHILLISOURCE_UI_BASE_WIDGETTEMPLATE_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Resource/Resource.h>\n#include <ChilliSource/UI/Base/WidgetDesc.h>\n\nnamespace ChilliSource\n{\n    //-------------------------------------------------------------\n    /// A resource that holds the description for creating new\n    /// widget instances. A widget template is used to create\n    /// instances of mutable UI i.e. screens. Widgets created\n    /// from templates are fully defined usually with drawables,\n    /// sizes, positions, etc and are ready for adding to the canvas.\n    ///\n    /// @author S Downie\n    //-------------------------------------------------------------\n    class WidgetTemplate final : public Resource\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(WidgetTemplate);\n        \n        //-------------------------------------------------------\n        /// Is the object of the given interface type.\n        ///\n        /// @author S Downie\n        ///\n        /// @param Interface type to query\n        ///\n        /// @return Whether the object is of given type\n        //-------------------------------------------------------\n        bool IsA(InterfaceIDType in_interfaceId) const override;\n        //-------------------------------------------------------\n        /// Build the resource which consists of the description\n        /// of a widget and all its children\n        ///\n        /// @author S Downie\n        ///\n        /// @param The widget description.\n        //-------------------------------------------------------\n        void Build(const WidgetDesc& in_desc);\n        //-------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Hierarchy description\n        //-------------------------------------------------------\n        const WidgetDesc& GetWidgetDesc() const;\n        \n    private:\n        \n        friend class ResourcePool;\n        //-------------------------------------------------------\n        /// Factory method\n        ///\n        /// @author S Downie\n        ///\n        /// @return New backend with ownership transferred\n        //-------------------------------------------------------\n        static WidgetTemplateUPtr Create();\n        //-------------------------------------------------------\n        /// Private constructor to force use of factory method\n        ///\n        /// @author S Downie\n        //-------------------------------------------------------\n        WidgetTemplate();\n        \n    private:\n        \n        WidgetDesc m_desc;\n    };\n}\n\n#endif\n\n"
  },
  {
    "path": "Source/ChilliSource/UI/Base/WidgetTemplateProvider.cpp",
    "content": "//\n//  WidgetTemplateProvider.cpp\n//  ChilliSource\n//  Created by Scott Downie on 30/07/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/UI/Base/WidgetTemplateProvider.h>\n\n#include <ChilliSource/Core/Json/JsonUtils.h>\n#include <ChilliSource/Core/Container/Property/PropertyMap.h>\n#include <ChilliSource/Core/Resource/ResourcePool.h>\n#include <ChilliSource/Core/Threading/TaskScheduler.h>\n#include <ChilliSource/UI/Base/Widget.h>\n#include <ChilliSource/UI/Base/WidgetDesc.h>\n#include <ChilliSource/UI/Base/WidgetParserUtils.h>\n#include <ChilliSource/UI/Base/WidgetTemplate.h>\n\n#include <json/json.h>\n\nnamespace ChilliSource\n{\n    namespace\n    {\n        const std::string k_extension(\"csui\");\n        \n        //-------------------------------------------------------\n        /// Performs the heavy lifting for loading a UI\n        /// widget description from file\n        ///\n        /// @author S Downie\n        ///\n        /// @param Storage location\n        /// @param File path\n        /// @param Async load delegate\n        /// @param [Out] Resource\n        //-------------------------------------------------------\n        void LoadDesc(StorageLocation in_storageLocation, const std::string& in_filepath, const ResourceProvider::AsyncLoadDelegate& in_delegate, const ResourceSPtr& out_resource)\n        {\n            Json::Value root;\n            if (JsonUtils::ReadJson(in_storageLocation, in_filepath, root) == false)\n            {\n                CS_LOG_ERROR(\"Cannot read widget file: \" + in_filepath);\n                out_resource->SetLoadState(Resource::LoadState::k_failed);\n                if(in_delegate != nullptr)\n                {\n                    Application::Get()->GetTaskScheduler()->ScheduleTask(TaskType::k_mainThread, [=](const TaskContext&) noexcept\n                    {\n                        in_delegate(out_resource);\n                    });\n                }\n                return;\n            }\n            \n            WidgetTemplate* widgetTemplate = (WidgetTemplate*)out_resource.get();\n            \n            std::string definitionFileName;\n            std::string pathToDefinition;\n            StringUtils::SplitFilename(in_filepath, definitionFileName, pathToDefinition);\n            \n            WidgetDesc desc = WidgetParserUtils::ParseWidget(root, in_storageLocation, pathToDefinition);\n            \n            widgetTemplate->Build(desc);\n            \n            out_resource->SetLoadState(Resource::LoadState::k_loaded);\n            if(in_delegate != nullptr)\n            {\n                Application::Get()->GetTaskScheduler()->ScheduleTask(TaskType::k_mainThread, [=](const TaskContext&) noexcept\n                {\n                    in_delegate(out_resource);\n                });\n            }\n        }\n    }\n    \n    CS_DEFINE_NAMEDTYPE(WidgetTemplateProvider);\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    WidgetTemplateProviderUPtr WidgetTemplateProvider::Create()\n    {\n        return WidgetTemplateProviderUPtr(new WidgetTemplateProvider());\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    bool WidgetTemplateProvider::IsA(InterfaceIDType in_interfaceId) const\n    {\n        return (in_interfaceId == ResourceProvider::InterfaceID || in_interfaceId == WidgetTemplateProvider::InterfaceID);\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    InterfaceIDType WidgetTemplateProvider::GetResourceType() const\n    {\n        return WidgetTemplate::InterfaceID;\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    bool WidgetTemplateProvider::CanCreateResourceWithFileExtension(const std::string& in_extension) const\n    {\n        return (in_extension == k_extension);\n    }\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    void WidgetTemplateProvider::CreateResourceFromFile(StorageLocation in_storageLocation, const std::string& in_filepath, const IResourceOptionsBaseCSPtr& in_options, const ResourceSPtr& out_resource)\n    {\n        LoadDesc(in_storageLocation, in_filepath, nullptr, out_resource);\n    }\n    //----------------------------------------------------\n    //----------------------------------------------------\n    void WidgetTemplateProvider::CreateResourceFromFileAsync(StorageLocation in_storageLocation, const std::string& in_filepath, const IResourceOptionsBaseCSPtr& in_options, const AsyncLoadDelegate& in_delegate, const ResourceSPtr& out_resource)\n    {\n        //TODO: Async support.\n        CS_LOG_FATAL(\"Asynchronous loading of Widget Templates is currently not supported. Feature coming soon!\");\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/UI/Base/WidgetTemplateProvider.h",
    "content": "//\n//  WidgetTemplateProvider.h\n//  ChilliSource\n//  Created by Scott Downie on 30/07/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_UI_BASE_WIDGETTEMPLATEPROVIDER_H_\n#define _CHILLISOURCE_UI_BASE_WIDGETTEMPLATEPROVIDER_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Resource/ResourceProvider.h>\n\n#include <json/forwards.h>\n\nnamespace ChilliSource\n{\n    //-------------------------------------------------------------\n    /// A resource provider that creates widget descriptions for\n    /// file\n    ///\n    /// @author S Downie\n    //-------------------------------------------------------------\n    class WidgetTemplateProvider final : public ResourceProvider\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(WidgetTemplateProvider);\n\n        //-------------------------------------------------------\n        /// Is the object of the given interface type.\n        ///\n        /// @author S Downie\n        ///\n        /// @param Interface type to query\n        ///\n        /// @return Whether the object is of given type\n        //-------------------------------------------------------\n        bool IsA(InterfaceIDType in_interfaceId) const override;\n        //-------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return The resource type this provider can load\n        //-------------------------------------------------------\n        InterfaceIDType GetResourceType() const override;\n        //-------------------------------------------------------\n        /// Queries whether or not this provider can create\n        /// resources from files with the given extension.\n        ///\n        /// @author S Downie\n        ///\n        /// @param Extension to compare against\n        ///\n        /// @return Whether the object can load a resource with\n        /// that extension\n        //-------------------------------------------------------\n        bool CanCreateResourceWithFileExtension(const std::string& in_extension) const override;\n        //-------------------------------------------------------\n        /// Creates a new desc from file. Check the resource\n        /// load state for success or failure\n        ///\n        /// @author S Downie\n        ///\n        /// @param The storage location to load from\n        /// @param File path to resource\n        /// @param Options to customise the creation\n        /// @param [Out] Resource\n        //-------------------------------------------------------\n        void CreateResourceFromFile(StorageLocation in_storageLocation, const std::string& in_filepath, const IResourceOptionsBaseCSPtr& in_options, const ResourceSPtr& out_resource) override;\n        //----------------------------------------------------\n        /// Creates a new resource from file asynchronously.\n        /// Completion delegate is called on finish. Check\n        /// the resource load state for success or failure\n        ///\n        /// @author S Downie\n        ///\n        /// @param The storage location.\n        /// @param The filepath.\n        /// @param Options to customise the creation\n        /// @param Completion delegate\n        /// @param [Out] The output resource.\n        //----------------------------------------------------\n        void CreateResourceFromFileAsync(StorageLocation in_storageLocation, const std::string& in_filepath, const IResourceOptionsBaseCSPtr& in_options, const AsyncLoadDelegate& in_delegate, const ResourceSPtr& out_resource) override;\n    private:\n        \n        friend class Application;\n        //-------------------------------------------------------\n        /// Factory method\n        ///\n        /// @author S Downie\n        ///\n        /// @return New backend with ownership transferred\n        //-------------------------------------------------------\n        static WidgetTemplateProviderUPtr Create();\n    };\n}\n\n#endif\n\n"
  },
  {
    "path": "Source/ChilliSource/UI/Base.h",
    "content": "//\n//  Base.h\n//  ChilliSource\n//  Created by Scott Downie on 25/07/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n\n#ifndef _CHILLISOURCE_UI_BASE_H_\n#define _CHILLISOURCE_UI_BASE_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/UI/Base/Canvas.h>\n#include <ChilliSource/UI/Base/CursorSystem.h>\n#include <ChilliSource/UI/Base/UIComponent.h>\n#include <ChilliSource/UI/Base/UIComponentDesc.h>\n#include <ChilliSource/UI/Base/UIComponentFactory.h>\n#include <ChilliSource/UI/Base/PropertyLink.h>\n#include <ChilliSource/UI/Base/Widget.h>\n#include <ChilliSource/UI/Base/WidgetDef.h>\n#include <ChilliSource/UI/Base/WidgetDefProvider.h>\n#include <ChilliSource/UI/Base/WidgetTemplate.h>\n#include <ChilliSource/UI/Base/WidgetTemplateProvider.h>\n#include <ChilliSource/UI/Base/WidgetFactory.h>\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/UI/Button/HighlightUIComponent.cpp",
    "content": "//\n//  HighlightUIComponent.cpp\n//  ChilliSource\n//  Created by Ian Copland on 28/11/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/UI/Button/HighlightUIComponent.h>\n\n#include <ChilliSource/Core/Container/VectorUtils.h>\n#include <ChilliSource/Core/Container/Property/PropertyMap.h>\n#include <ChilliSource/Core/Container/Property/PropertyTypes.h>\n#include <ChilliSource/Core/Delegate/MakeDelegate.h>\n#include <ChilliSource/UI/Base/Widget.h>\n#include <ChilliSource/UI/Base/PropertyTypes.h>\n#include <ChilliSource/UI/Drawable/DrawableUIComponent.h>\n#include <ChilliSource/UI/Drawable/UIDrawableDef.h>\n\n\nnamespace ChilliSource\n{\n    namespace\n    {\n        const char k_normalDrawableKey[] = \"NormalDrawable\";\n        const char k_highlightDrawableKey[] = \"HighlightDrawable\";\n        const char k_highlightColourKey[] = \"HighlightColour\";\n        \n        const std::vector<PropertyMap::PropertyDesc> k_propertyDescs =\n        {\n            {PropertyTypes::UIDrawableDef(), k_normalDrawableKey},\n            {PropertyTypes::UIDrawableDef(), k_highlightDrawableKey},\n            {PropertyTypes::Colour(), k_highlightColourKey}\n        };\n    }\n    \n    CS_DEFINE_NAMEDTYPE(HighlightUIComponent);\n    //-------------------------------------------------------------------\n    //-------------------------------------------------------------------\n    const std::vector<PropertyMap::PropertyDesc>& HighlightUIComponent::GetPropertyDescs()\n    {\n        return k_propertyDescs;\n    }\n    //-------------------------------------------------------------------\n    //-------------------------------------------------------------------\n    HighlightUIComponent::HighlightUIComponent(const std::string& in_componentName, const PropertyMap& in_properties)\n        : UIComponent(in_componentName)\n    {\n        RegisterProperty<UIDrawableDefCSPtr>(PropertyTypes::UIDrawableDef(), k_normalDrawableKey, MakeDelegate(this, &HighlightUIComponent::GetNormalDrawableDef), MakeDelegate(this, &HighlightUIComponent::SetNormalDrawableDef));\n        RegisterProperty<UIDrawableDefCSPtr>(PropertyTypes::UIDrawableDef(), k_highlightDrawableKey, MakeDelegate(this, &HighlightUIComponent::GetHighlightDrawableDef), MakeDelegate(this, &HighlightUIComponent::SetHighlightDrawableDef));\n        RegisterProperty<Colour>(PropertyTypes::Colour(), k_highlightColourKey, MakeDelegate(this, &HighlightUIComponent::GetHighlightColour), MakeDelegate(this, &HighlightUIComponent::SetHighlightColour));\n        ApplyRegisteredProperties(in_properties);\n    }\n    //-------------------------------------------------------------------\n    //-------------------------------------------------------------------\n    bool HighlightUIComponent::IsA(InterfaceIDType in_interfaceId) const\n    {\n        return (UIComponent::InterfaceID == in_interfaceId || HighlightUIComponent::InterfaceID == in_interfaceId);\n    }\n    //-------------------------------------------------------------------\n    //-------------------------------------------------------------------\n    const UIDrawableDefCSPtr& HighlightUIComponent::GetNormalDrawableDef() const\n    {\n        return m_normalDrawableDef;\n    }\n    //-------------------------------------------------------------------\n    //-------------------------------------------------------------------\n    const UIDrawableDefCSPtr& HighlightUIComponent::GetHighlightDrawableDef() const\n    {\n        return m_highlightDrawableDef;\n    }\n    //-------------------------------------------------------------------\n    //-------------------------------------------------------------------\n    const Colour& HighlightUIComponent::GetHighlightColour() const\n    {\n        return m_highlightColour;\n    }\n    //-------------------------------------------------------------------\n    //-------------------------------------------------------------------\n    void HighlightUIComponent::SetNormalDrawableDef(const UIDrawableDefCSPtr& in_drawableDef)\n    {\n        m_normalDrawableDef = in_drawableDef;\n        \n        if (m_highlighted == false)\n        {\n            Unhighlight();\n        }\n    }\n    //-------------------------------------------------------------------\n    //-------------------------------------------------------------------\n    void HighlightUIComponent::SetHighlightDrawableDef(const UIDrawableDefCSPtr& in_drawable)\n    {\n        m_highlightDrawableDef = in_drawable;\n        \n        if (m_highlighted == true)\n        {\n            Highlight();\n        }\n    }\n    //-------------------------------------------------------------------\n    //-------------------------------------------------------------------\n    void HighlightUIComponent::SetHighlightColour(const Colour& in_colour)\n    {\n        m_highlightColour = in_colour;\n        \n        if (m_highlighted == true)\n        {\n            Highlight();\n        }\n    }\n    //-------------------------------------------------------------------\n    //-------------------------------------------------------------------\n    void HighlightUIComponent::Highlight()\n    {\n        m_highlighted = true;\n        \n        if (m_drawableComponent != nullptr)\n        {\n            if (m_highlightDrawableDef != nullptr)\n            {\n                m_drawableComponent->ApplyDrawableDef(m_highlightDrawableDef);\n                \n                auto drawable = m_drawableComponent->GetDrawable();\n                drawable->SetColour(m_highlightColour * m_highlightDrawableDef->GetColour());\n            }\n            else\n            {\n                m_drawableComponent->ApplyDrawableDef(m_normalDrawableDef);\n                \n                auto drawable = m_drawableComponent->GetDrawable();\n                drawable->SetColour(m_highlightColour * m_normalDrawableDef->GetColour());\n            }\n        }\n    }\n    //-------------------------------------------------------------------\n    //-------------------------------------------------------------------\n    void HighlightUIComponent::Unhighlight()\n    {\n        m_highlighted = false;\n        \n        if (m_drawableComponent != nullptr)\n        {\n            m_drawableComponent->ApplyDrawableDef(m_normalDrawableDef);\n        }\n    }\n    //-------------------------------------------------------------------\n    //-------------------------------------------------------------------\n    void HighlightUIComponent::OnInit()\n    {\n        m_drawableComponent = GetWidget()->GetComponent<DrawableUIComponent>();\n        CS_ASSERT(m_drawableComponent != nullptr, \"Widgets with a Highlight UIComponent must also contain a UIDrawable UIComponent.\");\n        \n        if (m_highlighted == false)\n        {\n            Unhighlight();\n        }\n        else\n        {\n            Highlight();\n        }\n        \n        m_pressedInsideConnection = GetWidget()->GetPressedInsideEvent().OpenConnection(MakeDelegate(this, &HighlightUIComponent::OnPressedInside));\n        m_moveEnteredConnection = GetWidget()->GetMoveEnteredEvent().OpenConnection(MakeDelegate(this, &HighlightUIComponent::OnMoveEntered));\n        m_moveExitedConnection = GetWidget()->GetMoveExitedEvent().OpenConnection(MakeDelegate(this, &HighlightUIComponent::OnMoveExited));\n        m_releasedInsideConnection = GetWidget()->GetReleasedInsideEvent().OpenConnection(MakeDelegate(this, &HighlightUIComponent::OnReleasedInside));\n        m_releasedOutsideConnection = GetWidget()->GetReleasedOutsideEvent().OpenConnection(MakeDelegate(this, &HighlightUIComponent::OnReleasedOutside));\n    }\n    //-------------------------------------------------------------------\n    //-------------------------------------------------------------------\n    void HighlightUIComponent::OnPressedInside(Widget* in_widget, const Pointer& in_pointer, Pointer::InputType in_inputType)\n    {\n        if (in_inputType == Pointer::GetDefaultInputType())\n        {\n            CS_ASSERT(VectorUtils::Contains(m_activePointerIds, in_pointer.GetId()) == false, \"Received pressed event for already pressed Id.\");\n            CS_ASSERT(VectorUtils::Contains(m_highlightingPointerIds, in_pointer.GetId()) == false, \"Received pressed event for already highlighting Id.\");\n            \n            m_activePointerIds.push_back(in_pointer.GetId());\n            m_highlightingPointerIds.push_back(in_pointer.GetId());\n            \n            if (m_highlighted == false)\n            {\n                Highlight();\n            }\n        }\n    }\n    //-------------------------------------------------------------------\n    //-------------------------------------------------------------------\n    void HighlightUIComponent::OnMoveEntered(Widget* in_widget, const Pointer& in_pointer)\n    {\n        if (VectorUtils::Contains(m_activePointerIds, in_pointer.GetId()) == true)\n        {\n            CS_ASSERT(VectorUtils::Contains(m_highlightingPointerIds, in_pointer.GetId()) == false, \"Received move entered for already highlighting Id.\");\n            \n            m_highlightingPointerIds.push_back(in_pointer.GetId());\n            \n            if (m_highlighted == false)\n            {\n                Highlight();\n            }\n        }\n    }\n    //-------------------------------------------------------------------\n    //-------------------------------------------------------------------\n    void HighlightUIComponent::OnMoveExited(Widget* in_widget, const Pointer& in_pointer)\n    {\n        if (VectorUtils::Contains(m_activePointerIds, in_pointer.GetId()) == true)\n        {\n            CS_ASSERT(VectorUtils::Contains(m_highlightingPointerIds, in_pointer.GetId()) == true, \"Received move exited event for an id that is not in the highlighting list.\");\n            \n            VectorUtils::Remove(m_highlightingPointerIds, in_pointer.GetId());\n            \n            if (m_highlighted == true && m_highlightingPointerIds.empty() == true)\n            {\n                Unhighlight();\n            }\n        }\n    }\n    //-------------------------------------------------------------------\n    //-------------------------------------------------------------------\n    void HighlightUIComponent::OnReleasedInside(Widget* in_widget, const Pointer& in_pointer, Pointer::InputType in_inputType)\n    {\n        if (VectorUtils::Contains(m_activePointerIds, in_pointer.GetId()) == true)\n        {\n            CS_ASSERT(VectorUtils::Contains(m_highlightingPointerIds, in_pointer.GetId()) == true, \"Received released inside event for an id that is not in the highlighting list.\");\n            \n            VectorUtils::Remove(m_activePointerIds, in_pointer.GetId());\n            VectorUtils::Remove(m_highlightingPointerIds, in_pointer.GetId());\n            \n            if (m_highlighted == true && m_highlightingPointerIds.empty() == true)\n            {\n                Unhighlight();\n            }\n        }\n    }\n    //-------------------------------------------------------------------\n    //-------------------------------------------------------------------\n    void HighlightUIComponent::OnReleasedOutside(Widget* in_widget, const Pointer& in_pointer, Pointer::InputType in_inputType)\n    {\n        if (VectorUtils::Contains(m_activePointerIds, in_pointer.GetId()) == true)\n        {\n            CS_ASSERT(VectorUtils::Contains(m_highlightingPointerIds, in_pointer.GetId()) == false, \"Received released inside event for an id that is in the highlighting list.\");\n            \n            VectorUtils::Remove(m_activePointerIds, in_pointer.GetId());\n            \n            if (m_highlighted == true && m_highlightingPointerIds.empty() == true)\n            {\n                Unhighlight();\n            }\n        }\n    }\n    //-------------------------------------------------------------------\n    //-------------------------------------------------------------------\n    void HighlightUIComponent::OnDestroy()\n    {\n        m_pressedInsideConnection.reset();\n        m_moveEnteredConnection.reset();\n        m_moveExitedConnection.reset();\n        m_releasedInsideConnection.reset();\n        m_releasedOutsideConnection.reset();\n        \n        if (m_highlighted == true)\n        {\n            Unhighlight();\n        }\n        \n        m_activePointerIds.clear();\n        m_highlightingPointerIds.clear();\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/UI/Button/HighlightUIComponent.h",
    "content": "//\n//  HighlightUIComponent.h\n//  ChilliSource\n//  Created by Ian Copland on 28/11/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_UI_BUTTON_HIGHLIGHTUICOMPONENT_H_\n#define _CHILLISOURCE_UI_BUTTON_HIGHLIGHTUICOMPONENT_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Base/Colour.h>\n#include <ChilliSource/Core/Container/Property/PropertyMap.h>\n#include <ChilliSource/Core/Event/EventConnection.h>\n#include <ChilliSource/Input/Pointer/Pointer.h>\n#include <ChilliSource/UI/Base/UIComponent.h>\n\nnamespace ChilliSource\n{\n    //--------------------------------------------------------------------------\n    /// A logic component for changing the drawable used to render a widget\n    /// when it has been pressed down. A highlight component has the following\n    /// properties:\n    ///\n    /// \"NormalDrawable\": A description of the drawable that will be used when\n    /// the parent widget is not highlighted.\n    ///\n    /// \"HighlightDrawable\": A description of the drawable that will be used when\n    /// the parent widget is highlighted. If no highlight drawable is set the\n    /// normal drawable will be used instead.\n    ///\n    /// \"HighlightColour\": The colour that the widget will be set to while\n    /// highlighted. This defaults to white.\n    ///\n    /// @author Ian Copland\n    //--------------------------------------------------------------------------\n    class HighlightUIComponent final : public UIComponent\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(HighlightUIComponent);\n        //-------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The list of properties supported by a highlight component.\n        //-------------------------------------------------------------------\n        static const std::vector<PropertyMap::PropertyDesc>& GetPropertyDescs();\n        //-------------------------------------------------------------------\n        /// Allows querying of whether or not the component implements the\n        /// interface associated with the given interface Id. Typically\n        /// this won't be called directly, instead the templated version\n        /// IsA<Interface>() should be used.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The interface Id.\n        ///\n        /// @return Whether the object implements the given interface.\n        //-------------------------------------------------------------------\n        bool IsA(InterfaceIDType in_interfaceId) const override;\n        //-------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return the drawable that will be set on the owning widget when\n        /// it is not pressed.\n        //-------------------------------------------------------------------\n        const UIDrawableDefCSPtr& GetNormalDrawableDef() const;\n        //-------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return the drawable that will be set on the owning widget when\n        /// it is pressed.\n        //-------------------------------------------------------------------\n        const UIDrawableDefCSPtr& GetHighlightDrawableDef() const;\n        //-------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The highlight colour\n        //-------------------------------------------------------------------\n        const Colour& GetHighlightColour() const;\n        //-------------------------------------------------------------------\n        /// Sets the drawable that will be set on the owning widget when\n        /// it is not pressed.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The drawable.\n        //-------------------------------------------------------------------\n        void SetNormalDrawableDef(const UIDrawableDefCSPtr& in_drawableDef);\n        //-------------------------------------------------------------------\n        /// Sets the drawable that will be set on the owning widget when\n        /// it is pressed.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The drawable.\n        //-------------------------------------------------------------------\n        void SetHighlightDrawableDef(const UIDrawableDefCSPtr& in_drawableDef);\n        //-------------------------------------------------------------------\n        /// Sets the highlight colour.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The colour.\n        //-------------------------------------------------------------------\n        void SetHighlightColour(const Colour& in_colour);\n        \n    private:\n        friend class UIComponentFactory;\n        //-------------------------------------------------------------------\n        /// Constructor that builds the component from key-value properties.\n        /// The properties used to create a highlight component are described\n        /// in the class documentation.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The component name.\n        /// @param The property map.\n        //-------------------------------------------------------------------\n        HighlightUIComponent(const std::string& in_componentName, const PropertyMap& in_properties);\n        //-------------------------------------------------------------------\n        /// Enables the highlight on the owning widget.\n        ///\n        /// @author Ian Copland\n        //-------------------------------------------------------------------\n        void Highlight();\n        //-------------------------------------------------------------------\n        /// Enables the highlight on the owning widget.\n        ///\n        /// @author Ian Copland\n        //-------------------------------------------------------------------\n        void Unhighlight();\n        //-------------------------------------------------------------------\n        /// Called when the component is first added to the owning widget.\n        ///\n        /// @author Ian Copland\n        //-------------------------------------------------------------------\n        void OnInit() override;\n        //-------------------------------------------------------------------\n        /// Called when a pointer is pressed inside the bounds of the owning\n        /// widget. This will enable the highlight.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The owning widget.\n        /// @param The pointer that was pressed.\n        /// @param The type of input.\n        //-------------------------------------------------------------------\n        void OnPressedInside(Widget* in_widget, const Pointer& in_pointer, Pointer::InputType in_inputType);\n        //-------------------------------------------------------------------\n        /// Called when the owning widget receives an input move event within\n        /// its bounds having previously received one outside the bounds.\n        /// This will enable the highlight if the pointer was previously\n        /// pressed inside the widget.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The owning widget.\n        /// @param The pointer that was pressed.\n        //-------------------------------------------------------------------\n        void OnMoveEntered(Widget* in_widget, const Pointer& in_pointer);\n        //-------------------------------------------------------------------\n        /// Called when the owning widget receives an input move event outside\n        /// its bounds having previously received one inside the bounds.\n        /// This will disable the highlight if there are no other pointers\n        /// down on the widget.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The owning widget.\n        /// @param The pointer that was pressed.\n        //-------------------------------------------------------------------\n        void OnMoveExited(Widget* in_widget, const Pointer& in_pointer);\n        //-------------------------------------------------------------------\n        /// Called when a pointer is released inside the bounds of the owning\n        /// widget after having been pressed inside.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The owning widget.\n        /// @param The pointer that was pressed.\n        /// @param The type of input.\n        //-------------------------------------------------------------------\n        void OnReleasedInside(Widget* in_widget, const Pointer& in_pointer, Pointer::InputType in_inputType);\n        //-------------------------------------------------------------------\n        /// Called when a pointer is released outside the bounds of the owning\n        /// widget after having been pressed inside.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The owning widget.\n        /// @param The pointer that was pressed.\n        /// @param The type of input.\n        //-------------------------------------------------------------------\n        void OnReleasedOutside(Widget* in_widget, const Pointer& in_pointer, Pointer::InputType in_inputType);\n        //-------------------------------------------------------------------\n        /// Called when the owning widget is being destructed.\n        ///\n        /// @author Ian Copland\n        //-------------------------------------------------------------------\n        void OnDestroy() override;\n        \n        UIDrawableDefCSPtr m_normalDrawableDef;\n        UIDrawableDefCSPtr m_highlightDrawableDef;\n        Colour m_highlightColour;\n        \n        DrawableUIComponent* m_drawableComponent = nullptr;\n        \n        bool m_highlighted = false;\n        std::vector<Pointer::Id> m_activePointerIds;\n        std::vector<Pointer::Id> m_highlightingPointerIds;\n        \n        EventConnectionUPtr m_pressedInsideConnection;\n        EventConnectionUPtr m_moveEnteredConnection;\n        EventConnectionUPtr m_moveExitedConnection;\n        EventConnectionUPtr m_releasedInsideConnection;\n        EventConnectionUPtr m_releasedOutsideConnection;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/UI/Button/ToggleHighlightUIComponent.cpp",
    "content": "//\n//  ToggleHighlightUIComponent.cpp\n//  ChilliSource\n//  Created by Ian Copland on 01/12/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/UI/Button/ToggleHighlightUIComponent.h>\n\n#include <ChilliSource/Core/Container/VectorUtils.h>\n#include <ChilliSource/Core/Container/Property/PropertyTypes.h>\n#include <ChilliSource/Core/Delegate/MakeDelegate.h>\n#include <ChilliSource/UI/Base/Widget.h>\n#include <ChilliSource/UI/Base/PropertyTypes.h>\n#include <ChilliSource/UI/Drawable/DrawableUIComponent.h>\n#include <ChilliSource/UI/Drawable/UIDrawableDef.h>\n\nnamespace ChilliSource\n{\n    namespace\n    {\n        const char k_normalOffDrawableKey[] = \"NormalOffDrawable\";\n        const char k_highlightOffDrawableKey[] = \"HighlightOffDrawable\";\n        const char k_highlightOffColourKey[] = \"HighlightOffColour\";\n        const char k_normalOnDrawableKey[] = \"NormalOnDrawable\";\n        const char k_highlightOnDrawableKey[] = \"HighlightOnDrawable\";\n        const char k_highlightOnColourKey[] = \"HighlightOnColour\";\n        const char k_toggledOnKey[] = \"ToggledOn\";\n        \n        const std::vector<PropertyMap::PropertyDesc> k_propertyDescs =\n        {\n            {PropertyTypes::UIDrawableDef(), k_normalOffDrawableKey},\n            {PropertyTypes::UIDrawableDef(), k_highlightOffDrawableKey},\n            {PropertyTypes::Colour(), k_highlightOffColourKey},\n            {PropertyTypes::UIDrawableDef(), k_normalOnDrawableKey},\n            {PropertyTypes::UIDrawableDef(), k_highlightOnDrawableKey},\n            {PropertyTypes::Colour(), k_highlightOnColourKey},\n            {PropertyTypes::Bool(), k_toggledOnKey}\n        };\n    }\n    \n    CS_DEFINE_NAMEDTYPE(ToggleHighlightUIComponent);\n    //-------------------------------------------------------------------\n    //-------------------------------------------------------------------\n    const std::vector<PropertyMap::PropertyDesc>& ToggleHighlightUIComponent::GetPropertyDescs()\n    {\n        return k_propertyDescs;\n    }\n    //-------------------------------------------------------------------\n    //-------------------------------------------------------------------\n    ToggleHighlightUIComponent::ToggleHighlightUIComponent(const std::string& in_componentName, const PropertyMap& in_properties)\n        : UIComponent(in_componentName)\n    {\n        RegisterProperty<UIDrawableDefCSPtr>(PropertyTypes::UIDrawableDef(), k_normalOffDrawableKey, MakeDelegate(this, &ToggleHighlightUIComponent::GetNormalOffDrawableDef), MakeDelegate(this, &ToggleHighlightUIComponent::SetNormalOffDrawableDef));\n        RegisterProperty<UIDrawableDefCSPtr>(PropertyTypes::UIDrawableDef(), k_highlightOffDrawableKey, MakeDelegate(this, &ToggleHighlightUIComponent::GetHighlightOffDrawableDef), MakeDelegate(this, &ToggleHighlightUIComponent::SetHighlightOffDrawableDef));\n        RegisterProperty<Colour>(PropertyTypes::Colour(), k_highlightOffColourKey, MakeDelegate(this, &ToggleHighlightUIComponent::GetHighlightOffColour), MakeDelegate(this, &ToggleHighlightUIComponent::SetHighlightOffColour));\n        RegisterProperty<UIDrawableDefCSPtr>(PropertyTypes::UIDrawableDef(), k_normalOnDrawableKey, MakeDelegate(this, &ToggleHighlightUIComponent::GetNormalOnDrawableDef), MakeDelegate(this, &ToggleHighlightUIComponent::SetNormalOnDrawableDef));\n        RegisterProperty<UIDrawableDefCSPtr>(PropertyTypes::UIDrawableDef(), k_highlightOnDrawableKey, MakeDelegate(this, &ToggleHighlightUIComponent::GetHighlightOnDrawableDef), MakeDelegate(this, &ToggleHighlightUIComponent::SetHighlightOnDrawableDef));\n        RegisterProperty<Colour>(PropertyTypes::Colour(), k_highlightOnColourKey, MakeDelegate(this, &ToggleHighlightUIComponent::GetHighlightOnColour), MakeDelegate(this, &ToggleHighlightUIComponent::SetHighlightOnColour));\n        RegisterProperty<bool>(PropertyTypes::Bool(), k_toggledOnKey, MakeDelegate(this, &ToggleHighlightUIComponent::IsToggledOn), MakeDelegate(this, &ToggleHighlightUIComponent::SetToggleOn));\n        ApplyRegisteredProperties(in_properties);\n    }\n    //-------------------------------------------------------------------\n    //-------------------------------------------------------------------\n    bool ToggleHighlightUIComponent::IsA(InterfaceIDType in_interfaceId) const\n    {\n        return (UIComponent::InterfaceID == in_interfaceId || ToggleHighlightUIComponent::InterfaceID == in_interfaceId);\n    }\n    //-------------------------------------------------------------------\n    //-------------------------------------------------------------------\n    const UIDrawableDefCSPtr& ToggleHighlightUIComponent::GetNormalOffDrawableDef() const\n    {\n        return m_normalOffDrawableDef;\n    }\n    //-------------------------------------------------------------------\n    //-------------------------------------------------------------------\n    const UIDrawableDefCSPtr& ToggleHighlightUIComponent::GetHighlightOffDrawableDef() const\n    {\n        return m_highlightOffDrawableDef;\n    }\n    //-------------------------------------------------------------------\n    //-------------------------------------------------------------------\n    const Colour& ToggleHighlightUIComponent::GetHighlightOffColour() const\n    {\n        return m_highlightOffColour;\n    }\n    //-------------------------------------------------------------------\n    //-------------------------------------------------------------------\n    const UIDrawableDefCSPtr& ToggleHighlightUIComponent::GetNormalOnDrawableDef() const\n    {\n        return m_normalOnDrawableDef;\n    }\n    //-------------------------------------------------------------------\n    //-------------------------------------------------------------------\n    const UIDrawableDefCSPtr& ToggleHighlightUIComponent::GetHighlightOnDrawableDef() const\n    {\n        return m_normalOffDrawableDef;\n    }\n    //-------------------------------------------------------------------\n    //-------------------------------------------------------------------\n    const Colour& ToggleHighlightUIComponent::GetHighlightOnColour() const\n    {\n        return m_highlightOnColour;\n    }\n    //-------------------------------------------------------------------\n    //-------------------------------------------------------------------\n    bool ToggleHighlightUIComponent::IsToggledOn() const\n    {\n        return (m_state == ToggleHighlightState::k_normalOn || m_state == ToggleHighlightState::k_highlightedOn);\n    }\n    //-------------------------------------------------------------------\n    //-------------------------------------------------------------------\n    void ToggleHighlightUIComponent::SetNormalOffDrawableDef(const UIDrawableDefCSPtr& in_drawableDef)\n    {\n        m_normalOffDrawableDef = in_drawableDef;\n        \n        if (m_state == ToggleHighlightState::k_normalOff)\n        {\n            ApplyOffNormal();\n        }\n    }\n    //-------------------------------------------------------------------\n    //-------------------------------------------------------------------\n    void ToggleHighlightUIComponent::SetHighlightOffDrawableDef(const UIDrawableDefCSPtr& in_drawableDef)\n    {\n        m_highlightOffDrawableDef = in_drawableDef;\n        \n        if (m_state == ToggleHighlightState::k_highlightedOff)\n        {\n            ApplyOffHighlighted();\n        }\n    }\n    //-------------------------------------------------------------------\n    //-------------------------------------------------------------------\n    void ToggleHighlightUIComponent::SetHighlightOffColour(const Colour& in_colour)\n    {\n        m_highlightOffColour = in_colour;\n        \n        if (m_state == ToggleHighlightState::k_highlightedOff)\n        {\n            ApplyOffHighlighted();\n        }\n    }\n    //-------------------------------------------------------------------\n    //-------------------------------------------------------------------\n    void ToggleHighlightUIComponent::SetNormalOnDrawableDef(const UIDrawableDefCSPtr& in_drawableDef)\n    {\n        m_normalOnDrawableDef = in_drawableDef;\n        \n        if (m_state == ToggleHighlightState::k_normalOn)\n        {\n            ApplyOnNormal();\n        }\n    }\n    //-------------------------------------------------------------------\n    //-------------------------------------------------------------------\n    void ToggleHighlightUIComponent::SetHighlightOnDrawableDef(const UIDrawableDefCSPtr& in_drawableDef)\n    {\n        m_highlightOnDrawableDef = in_drawableDef;\n        \n        if (m_state == ToggleHighlightState::k_highlightedOn)\n        {\n            ApplyOnHightlighted();\n        }\n    }\n    //-------------------------------------------------------------------\n    //-------------------------------------------------------------------\n    void ToggleHighlightUIComponent::SetHighlightOnColour(const Colour& in_colour)\n    {\n        m_highlightOnColour = in_colour;\n        \n        if (m_state == ToggleHighlightState::k_highlightedOn)\n        {\n            ApplyOnHightlighted();\n        }\n    }\n    //-------------------------------------------------------------------\n    //-------------------------------------------------------------------\n    void ToggleHighlightUIComponent::SetToggleOn(bool in_toggleOn)\n    {\n        if (in_toggleOn == true && m_state == ToggleHighlightState::k_normalOff)\n        {\n            ApplyOnNormal();\n        }\n        else if (in_toggleOn == true && m_state == ToggleHighlightState::k_highlightedOff)\n        {\n            ApplyOnHightlighted();\n        }\n        else if (in_toggleOn == false && m_state == ToggleHighlightState::k_normalOn)\n        {\n            ApplyOffNormal();\n        }\n        else if (in_toggleOn == false && m_state == ToggleHighlightState::k_highlightedOn)\n        {\n            ApplyOffHighlighted();\n        }\n    }\n    //-------------------------------------------------------------------\n    //-------------------------------------------------------------------\n    bool ToggleHighlightUIComponent::IsHighlighted() const\n    {\n        return (m_state == ToggleHighlightState::k_highlightedOff || m_state == ToggleHighlightState::k_highlightedOn);\n    }\n    //-------------------------------------------------------------------\n    //-------------------------------------------------------------------\n    void ToggleHighlightUIComponent::Toggle()\n    {\n        if (IsToggledOn() == true)\n        {\n            SetToggleOn(false);\n        }\n        else\n        {\n            SetToggleOn(true);\n        }\n    }\n    //-------------------------------------------------------------------\n    //-------------------------------------------------------------------\n    void ToggleHighlightUIComponent::Highlight()\n    {\n        switch (m_state)\n        {\n            case ToggleHighlightState::k_normalOff:\n            case ToggleHighlightState::k_highlightedOff:\n                ApplyOffHighlighted();\n                break;\n            case ToggleHighlightState::k_normalOn:\n            case ToggleHighlightState::k_highlightedOn:\n                ApplyOnHightlighted();\n                break;\n            default:\n                CS_LOG_FATAL(\"Invalid state.\");\n                break;\n        }\n    }\n    //-------------------------------------------------------------------\n    //-------------------------------------------------------------------\n    void ToggleHighlightUIComponent::Unhighlight()\n    {\n        switch (m_state)\n        {\n            case ToggleHighlightState::k_normalOff:\n            case ToggleHighlightState::k_highlightedOff:\n                ApplyOffNormal();\n                break;\n            case ToggleHighlightState::k_normalOn:\n            case ToggleHighlightState::k_highlightedOn:\n                ApplyOnNormal();\n                break;\n            default:\n                CS_LOG_FATAL(\"Invalid state.\");\n                break;\n        }\n    }\n    //-------------------------------------------------------------------\n    //-------------------------------------------------------------------\n    void ToggleHighlightUIComponent::ApplyOffNormal()\n    {\n        m_state = ToggleHighlightState::k_normalOff;\n        \n        if (m_drawableComponent != nullptr)\n        {\n            m_drawableComponent->ApplyDrawableDef(m_normalOffDrawableDef);\n        }\n    }\n    //-------------------------------------------------------------------\n    //-------------------------------------------------------------------\n    void ToggleHighlightUIComponent::ApplyOffHighlighted()\n    {\n        m_state = ToggleHighlightState::k_highlightedOff;\n        \n        if (m_drawableComponent != nullptr)\n        {\n            if (m_highlightOffDrawableDef != nullptr)\n            {\n                m_drawableComponent->ApplyDrawableDef(m_highlightOffDrawableDef);\n                \n                auto drawable = m_drawableComponent->GetDrawable();\n                drawable->SetColour(m_highlightOffColour * m_highlightOffDrawableDef->GetColour());\n            }\n            else\n            {\n                m_drawableComponent->ApplyDrawableDef(m_normalOffDrawableDef);\n                \n                auto drawable = m_drawableComponent->GetDrawable();\n                drawable->SetColour(m_highlightOffColour * m_normalOffDrawableDef->GetColour());\n            }\n        }\n    }\n    //-------------------------------------------------------------------\n    //-------------------------------------------------------------------\n    void ToggleHighlightUIComponent::ApplyOnNormal()\n    {\n        m_state = ToggleHighlightState::k_normalOn;\n        \n        if (m_drawableComponent != nullptr)\n        {\n            m_drawableComponent->ApplyDrawableDef(m_normalOnDrawableDef);\n        }\n    }\n    //-------------------------------------------------------------------\n    //-------------------------------------------------------------------\n    void ToggleHighlightUIComponent::ApplyOnHightlighted()\n    {\n        m_state = ToggleHighlightState::k_highlightedOn;\n        \n        if (m_drawableComponent != nullptr)\n        {\n            if (m_highlightOnDrawableDef != nullptr)\n            {\n                m_drawableComponent->ApplyDrawableDef(m_highlightOnDrawableDef);\n                \n                auto drawable = m_drawableComponent->GetDrawable();\n                drawable->SetColour(m_highlightOnColour * m_highlightOnDrawableDef->GetColour());\n            }\n            else\n            {\n                m_drawableComponent->ApplyDrawableDef(m_normalOnDrawableDef);\n                \n                auto drawable = m_drawableComponent->GetDrawable();\n                drawable->SetColour(m_highlightOnColour * m_normalOnDrawableDef->GetColour());\n            }\n        }\n    }\n    //-------------------------------------------------------------------\n    //-------------------------------------------------------------------\n    void ToggleHighlightUIComponent::OnInit()\n    {\n        m_drawableComponent = GetWidget()->GetComponent<DrawableUIComponent>();\n        CS_ASSERT(m_drawableComponent != nullptr, \"Widgets with a Toggle Highlight UIComponent must also contain a UIDrawable UIComponent.\");\n        \n        if (IsToggledOn() == false)\n        {\n            Unhighlight();\n        }\n        else\n        {\n            Highlight();\n        }\n        \n        m_pressedInsideConnection = GetWidget()->GetPressedInsideEvent().OpenConnection(MakeDelegate(this, &ToggleHighlightUIComponent::OnPressedInside));\n        m_moveEnteredConnection = GetWidget()->GetMoveEnteredEvent().OpenConnection(MakeDelegate(this, &ToggleHighlightUIComponent::OnMoveEntered));\n        m_moveExitedConnection = GetWidget()->GetMoveExitedEvent().OpenConnection(MakeDelegate(this, &ToggleHighlightUIComponent::OnMoveExited));\n        m_releasedInsideConnection = GetWidget()->GetReleasedInsideEvent().OpenConnection(MakeDelegate(this, &ToggleHighlightUIComponent::OnReleasedInside));\n        m_releasedOutsideConnection = GetWidget()->GetReleasedOutsideEvent().OpenConnection(MakeDelegate(this, &ToggleHighlightUIComponent::OnReleasedOutside));\n    }\n    //-------------------------------------------------------------------\n    //-------------------------------------------------------------------\n    void ToggleHighlightUIComponent::OnPressedInside(Widget* in_widget, const Pointer& in_pointer, Pointer::InputType in_inputType)\n    {\n        if (in_inputType == Pointer::GetDefaultInputType())\n        {\n            CS_ASSERT(VectorUtils::Contains(m_activePointerIds, in_pointer.GetId()) == false, \"Received pressed event for already pressed Id.\");\n            CS_ASSERT(VectorUtils::Contains(m_highlightingPointerIds, in_pointer.GetId()) == false, \"Received pressed event for already highlighting Id.\");\n            \n            m_activePointerIds.push_back(in_pointer.GetId());\n            m_highlightingPointerIds.push_back(in_pointer.GetId());\n            \n            if (IsHighlighted() == false)\n            {\n                Highlight();\n            }\n        }\n    }\n    //-------------------------------------------------------------------\n    //-------------------------------------------------------------------\n    void ToggleHighlightUIComponent::OnMoveEntered(Widget* in_widget, const Pointer& in_pointer)\n    {\n        if (VectorUtils::Contains(m_activePointerIds, in_pointer.GetId()) == true)\n        {\n            CS_ASSERT(VectorUtils::Contains(m_highlightingPointerIds, in_pointer.GetId()) == false, \"Received move entered for already highlighting Id.\");\n            \n            m_highlightingPointerIds.push_back(in_pointer.GetId());\n            \n            if (IsHighlighted() == false)\n            {\n                Highlight();\n            }\n        }\n    }\n    //-------------------------------------------------------------------\n    //-------------------------------------------------------------------\n    void ToggleHighlightUIComponent::OnMoveExited(Widget* in_widget, const Pointer& in_pointer)\n    {\n        if (VectorUtils::Contains(m_activePointerIds, in_pointer.GetId()) == true)\n        {\n            CS_ASSERT(VectorUtils::Contains(m_highlightingPointerIds, in_pointer.GetId()) == true, \"Received move exited event for an id that is not in the highlighting list.\");\n            \n            VectorUtils::Remove(m_highlightingPointerIds, in_pointer.GetId());\n            \n            if (IsHighlighted() == true && m_highlightingPointerIds.empty() == true)\n            {\n                Unhighlight();\n            }\n        }\n    }\n    //-------------------------------------------------------------------\n    //-------------------------------------------------------------------\n    void ToggleHighlightUIComponent::OnReleasedInside(Widget* in_widget, const Pointer& in_pointer, Pointer::InputType in_inputType)\n    {\n        if (VectorUtils::Contains(m_activePointerIds, in_pointer.GetId()) == true)\n        {\n            CS_ASSERT(VectorUtils::Contains(m_highlightingPointerIds, in_pointer.GetId()) == true, \"Received released inside event for an id that is not in the highlighting list.\");\n            \n            VectorUtils::Remove(m_activePointerIds, in_pointer.GetId());\n            VectorUtils::Remove(m_highlightingPointerIds, in_pointer.GetId());\n            \n            if (IsHighlighted() == true && m_highlightingPointerIds.empty() == true)\n            {\n                Unhighlight();\n                Toggle();\n            }\n        }\n    }\n    //-------------------------------------------------------------------\n    //-------------------------------------------------------------------\n    void ToggleHighlightUIComponent::OnReleasedOutside(Widget* in_widget, const Pointer& in_pointer, Pointer::InputType in_inputType)\n    {\n        if (VectorUtils::Contains(m_activePointerIds, in_pointer.GetId()) == true)\n        {\n            CS_ASSERT(VectorUtils::Contains(m_highlightingPointerIds, in_pointer.GetId()) == false, \"Received released inside event for an id that is in the highlighting list.\");\n            \n            VectorUtils::Remove(m_activePointerIds, in_pointer.GetId());\n            \n            if (IsHighlighted() == true && m_highlightingPointerIds.empty() == true)\n            {\n                Unhighlight();\n            }\n        }\n    }\n    //-------------------------------------------------------------------\n    //-------------------------------------------------------------------\n    void ToggleHighlightUIComponent::OnDestroy()\n    {\n        m_pressedInsideConnection.reset();\n        m_moveEnteredConnection.reset();\n        m_moveExitedConnection.reset();\n        m_releasedInsideConnection.reset();\n        m_releasedOutsideConnection.reset();\n        \n        if (IsToggledOn() == false)\n        {\n            m_drawableComponent->ApplyDrawableDef(m_normalOffDrawableDef);\n        }\n        else\n        {\n            m_drawableComponent->ApplyDrawableDef(m_normalOnDrawableDef);\n        }\n        \n        m_activePointerIds.clear();\n        m_highlightingPointerIds.clear();\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/UI/Button/ToggleHighlightUIComponent.h",
    "content": "//\n//  ToggleHighlightUIComponent.h\n//  ChilliSource\n//  Created by Ian Copland on 01/12/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_UI_BUTTON_TOGGLEHIGHLIGHTUICOMPONENT_H_\n#define _CHILLISOURCE_UI_BUTTON_TOGGLEHIGHLIGHTUICOMPONENT_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Base/Colour.h>\n#include <ChilliSource/Core/Container/Property/PropertyMap.h>\n#include <ChilliSource/Core/Event/EventConnection.h>\n#include <ChilliSource/Input/Pointer/Pointer.h>\n#include <ChilliSource/UI/Base/UIComponent.h>\n\nnamespace ChilliSource\n{\n    //--------------------------------------------------------------------------\n    /// A logic component for changing the drawable used to render a widget\n    /// when it has been pressed down. A highlight component has the following\n    /// properties:\n    ///\n    /// \"NormalOffDrawable\": A description of the drawable that will be used when\n    /// the parent widget is not highlighted and is toggled off.\n    ///\n    /// \"HighlightOffDrawable\": A description of the drawable that will be used when\n    /// the parent widget is highlighted and is toggled off.\n    ///\n    /// \"HighlightOffColour\": The colour set when the button is highlighted while\n    /// off.\n    ///\n    /// \"NormalOnDrawable\": A description of the drawable that will be used when\n    /// the parent widget is not highlighted and is toggled on.\n    ///\n    /// \"HighlightOnDrawable\": A description of the drawable that will be used when\n    /// the parent widget is highlighted and is toggled on.\n    ///\n    /// \"HighlightOnColour\": The colour set when the button is highlighted while\n    /// on.\n    ///\n    /// \"ToggledOn\": A boolean describing whether or not the toggle is on of\n    /// off.\n    ///\n    /// @author Ian Copland\n    //--------------------------------------------------------------------------\n    class ToggleHighlightUIComponent final : public UIComponent\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(ToggleHighlightUIComponent);\n        //-------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The list of properties supported by a highlight component.\n        //-------------------------------------------------------------------\n        static const std::vector<PropertyMap::PropertyDesc>& GetPropertyDescs();\n        //-------------------------------------------------------------------\n        /// Allows querying of whether or not the component implements the\n        /// interface associated with the given interface Id. Typically\n        /// this won't be called directly, instead the templated version\n        /// IsA<Interface>() should be used.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The interface Id.\n        ///\n        /// @return Whether the object implements the given interface.\n        //-------------------------------------------------------------------\n        bool IsA(InterfaceIDType in_interfaceId) const override;\n        //-------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return the drawable that will be set on the owning widget when\n        /// it is not pressed while toggled off.\n        //-------------------------------------------------------------------\n        const UIDrawableDefCSPtr& GetNormalOffDrawableDef() const;\n        //-------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return the drawable that will be set on the owning widget when\n        /// it is pressed while toggled off.\n        //-------------------------------------------------------------------\n        const UIDrawableDefCSPtr& GetHighlightOffDrawableDef() const;\n        //-------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The colour set when the button is highlighted while off.\n        //-------------------------------------------------------------------\n        const Colour& GetHighlightOffColour() const;\n        //-------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return the drawable that will be set on the owning widget when\n        /// it is not pressed while toggled on.\n        //-------------------------------------------------------------------\n        const UIDrawableDefCSPtr& GetNormalOnDrawableDef() const;\n        //-------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return the drawable that will be set on the owning widget when\n        /// it is pressed while toggled on.\n        //-------------------------------------------------------------------\n        const UIDrawableDefCSPtr& GetHighlightOnDrawableDef() const;\n        //-------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The colour set when the button is highlighted while on.\n        //-------------------------------------------------------------------\n        const Colour& GetHighlightOnColour() const;\n        //-------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return Whether or not the toggle is currently on or off.\n        //-------------------------------------------------------------------\n        bool IsToggledOn() const;\n        //-------------------------------------------------------------------\n        /// Sets the drawable that will be set on the owning widget when\n        /// it is not pressed and is toggled off.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The drawable.\n        //-------------------------------------------------------------------\n        void SetNormalOffDrawableDef(const UIDrawableDefCSPtr& in_drawableDef);\n        //-------------------------------------------------------------------\n        /// Sets the drawable that will be set on the owning widget when\n        /// it is pressed and is toggled off.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The drawable.\n        //-------------------------------------------------------------------\n        void SetHighlightOffDrawableDef(const UIDrawableDefCSPtr& in_drawableDef);\n        //-------------------------------------------------------------------\n        /// Sets the colour used when the button is highlighted while off.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The colour.\n        //-------------------------------------------------------------------\n        void SetHighlightOffColour(const Colour& in_colour);\n        //-------------------------------------------------------------------\n        /// Sets the drawable that will be set on the owning widget when\n        /// it is not pressed and is toggled on.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The drawable.\n        //-------------------------------------------------------------------\n        void SetNormalOnDrawableDef(const UIDrawableDefCSPtr& in_drawableDef);\n        //-------------------------------------------------------------------\n        /// Sets the drawable that will be set on the owning widget when\n        /// it is pressed and is toggled on.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The drawable.\n        //-------------------------------------------------------------------\n        void SetHighlightOnDrawableDef(const UIDrawableDefCSPtr& in_drawableDef);\n        //-------------------------------------------------------------------\n        /// Sets the colour used when the button is highlighted while on.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The colour.\n        //-------------------------------------------------------------------\n        void SetHighlightOnColour(const Colour& in_colour);\n        //-------------------------------------------------------------------\n        /// Sets whether or not the toggle is on or off.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param Whether or not it is on or off.\n        //-------------------------------------------------------------------\n        void SetToggleOn(bool in_toggleOn);\n        \n    private:\n        friend class UIComponentFactory;\n        //-------------------------------------------------------------------\n        /// An enum describing the current state of the toggle highlight.\n        ///\n        /// @author Ian Copland\n        //-------------------------------------------------------------------\n        enum class ToggleHighlightState\n        {\n            k_normalOff,\n            k_highlightedOff,\n            k_normalOn,\n            k_highlightedOn\n        };\n        //-------------------------------------------------------------------\n        /// Constructor that builds the component from key-value properties.\n        /// The properties used to create a toggle highlight component are\n        /// described in the class documentation.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The component name.\n        /// @param The property map.\n        //-------------------------------------------------------------------\n        ToggleHighlightUIComponent(const std::string& in_componentName, const PropertyMap& in_properties);\n        //-------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return Whether or not the component is highlighted.\n        //-------------------------------------------------------------------\n        bool IsHighlighted() const;\n        //-------------------------------------------------------------------\n        /// Toggles the current state of the toggle button.\n        ///\n        /// @author Ian Copland\n        //-------------------------------------------------------------------\n        void Toggle();\n        //-------------------------------------------------------------------\n        /// Highlights the toggle button depending on the current toggle\n        /// state.\n        ///\n        /// @author Ian Copland\n        //-------------------------------------------------------------------\n        void Highlight();\n        //-------------------------------------------------------------------\n        /// Unhighlights the toggle button depending on the current toggle\n        /// state.\n        ///\n        /// @author Ian Copland\n        //-------------------------------------------------------------------\n        void Unhighlight();\n        //-------------------------------------------------------------------\n        /// Puts the toggle highlight component in the normal 'Off' state.\n        ///\n        /// @author Ian Copland\n        //-------------------------------------------------------------------\n        void ApplyOffNormal();\n        //-------------------------------------------------------------------\n        /// Puts the toggle highlight component in the highlighted 'Off' state.\n        ///\n        /// @author Ian Copland\n        //-------------------------------------------------------------------\n        void ApplyOffHighlighted();\n        //-------------------------------------------------------------------\n        /// Puts the toggle highlight component in the normal 'On' state.\n        ///\n        /// @author Ian Copland\n        //-------------------------------------------------------------------\n        void ApplyOnNormal();\n        //-------------------------------------------------------------------\n        /// Puts the toggle highlight component in the highlighted 'On' state.\n        ///\n        /// @author Ian Copland\n        //-------------------------------------------------------------------\n        void ApplyOnHightlighted();\n        //-------------------------------------------------------------------\n        /// Called when the component is first added to the owning widget.\n        ///\n        /// @author Ian Copland\n        //-------------------------------------------------------------------\n        void OnInit() override;\n        //-------------------------------------------------------------------\n        /// Called when a pointer is pressed inside the bounds of the owning\n        /// widget. This will enable the highlight.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The owning widget.\n        /// @param The pointer that was pressed.\n        /// @param The type of input.\n        //-------------------------------------------------------------------\n        void OnPressedInside(Widget* in_widget, const Pointer& in_pointer, Pointer::InputType in_inputType);\n        //-------------------------------------------------------------------\n        /// Called when the owning widget receives an input move event within\n        /// its bounds having previously received one outside the bounds.\n        /// This will enable the highlight if the pointer was previously\n        /// pressed inside the widget.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The owning widget.\n        /// @param The pointer that was pressed.\n        //-------------------------------------------------------------------\n        void OnMoveEntered(Widget* in_widget, const Pointer& in_pointer);\n        //-------------------------------------------------------------------\n        /// Called when the owning widget receives an input move event outside\n        /// its bounds having previously received one inside the bounds.\n        /// This will disable the highlight if there are no other pointers\n        /// down on the widget.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The owning widget.\n        /// @param The pointer that was pressed.\n        //-------------------------------------------------------------------\n        void OnMoveExited(Widget* in_widget, const Pointer& in_pointer);\n        //-------------------------------------------------------------------\n        /// Called when a pointer is released inside the bounds of the owning\n        /// widget after having been pressed inside.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The owning widget.\n        /// @param The pointer that was pressed.\n        /// @param The type of input.\n        //-------------------------------------------------------------------\n        void OnReleasedInside(Widget* in_widget, const Pointer& in_pointer, Pointer::InputType in_inputType);\n        //-------------------------------------------------------------------\n        /// Called when a pointer is released outside the bounds of the owning\n        /// widget after having been pressed inside.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The owning widget.\n        /// @param The pointer that was pressed.\n        /// @param The type of input.\n        //-------------------------------------------------------------------\n        void OnReleasedOutside(Widget* in_widget, const Pointer& in_pointer, Pointer::InputType in_inputType);\n        //-------------------------------------------------------------------\n        /// Called when the owning widget is being destructed.\n        ///\n        /// @author Ian Copland\n        //-------------------------------------------------------------------\n        void OnDestroy() override;\n        \n        UIDrawableDefCSPtr m_normalOffDrawableDef;\n        UIDrawableDefCSPtr m_highlightOffDrawableDef;\n        Colour m_highlightOffColour;\n        UIDrawableDefCSPtr m_normalOnDrawableDef;\n        UIDrawableDefCSPtr m_highlightOnDrawableDef;\n        Colour m_highlightOnColour;\n\n        DrawableUIComponent* m_drawableComponent = nullptr;\n        \n        ToggleHighlightState m_state = ToggleHighlightState::k_normalOff;\n        std::vector<Pointer::Id> m_activePointerIds;\n        std::vector<Pointer::Id> m_highlightingPointerIds;\n        \n        EventConnectionUPtr m_pressedInsideConnection;\n        EventConnectionUPtr m_moveEnteredConnection;\n        EventConnectionUPtr m_moveExitedConnection;\n        EventConnectionUPtr m_releasedInsideConnection;\n        EventConnectionUPtr m_releasedOutsideConnection;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/UI/Button.h",
    "content": "//\n//  Button.h\n//  ChilliSource\n//  Created by Ian Copland on 28/11/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n\n#ifndef _CHILLISOURCE_UI_BUTTON_H_\n#define _CHILLISOURCE_UI_BUTTON_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/UI/Button/HighlightUIComponent.h>\n#include <ChilliSource/UI/Button/ToggleHighlightUIComponent.h>\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/UI/Drawable/DrawableUIComponent.cpp",
    "content": "//\n//  DrawableUIComponent.cpp\n//  ChilliSource\n//  Created by Ian Copland on 28/11/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/UI/Drawable/DrawableUIComponent.h>\n\n#include <ChilliSource/Core/Delegate/MakeDelegate.h>\n#include <ChilliSource/Rendering/Base/CanvasDrawMode.h>\n#include <ChilliSource/Rendering/Base/CanvasRenderer.h>\n#include <ChilliSource/UI/Base/PropertyTypes.h>\n#include <ChilliSource/UI/Drawable/UIDrawable.h>\n#include <ChilliSource/UI/Drawable/UIDrawableDef.h>\n\nnamespace ChilliSource\n{\n    namespace\n    {\n        const char k_drawableKey[] = \"Drawable\";\n        \n        const std::vector<PropertyMap::PropertyDesc> k_propertyDescs =\n        {\n            {PropertyTypes::UIDrawableDef(), k_drawableKey},\n        };\n    }\n    \n    CS_DEFINE_NAMEDTYPE(DrawableUIComponent);\n    //-------------------------------------------------------------------\n    //-------------------------------------------------------------------\n    const std::vector<PropertyMap::PropertyDesc>& DrawableUIComponent::GetPropertyDescs()\n    {\n        return k_propertyDescs;\n    }\n    //-------------------------------------------------------------------\n    //-------------------------------------------------------------------\n    DrawableUIComponent::DrawableUIComponent(const std::string& in_componentName, const PropertyMap& in_properties)\n        : UIComponent(in_componentName)\n    {\n        RegisterProperty<UIDrawableDefCSPtr>(PropertyTypes::UIDrawableDef(), k_drawableKey, MakeDelegate(this, &DrawableUIComponent::GetDrawableDef), MakeDelegate(this, &DrawableUIComponent::ApplyDrawableDef));\n        ApplyRegisteredProperties(in_properties);\n    }\n    //-------------------------------------------------------------------\n    //-------------------------------------------------------------------\n    bool DrawableUIComponent::IsA(InterfaceIDType in_interfaceId) const\n    {\n        return (UIComponent::InterfaceID == in_interfaceId || DrawableUIComponent::InterfaceID == in_interfaceId);\n    }\n    //-------------------------------------------------------------------\n    //-------------------------------------------------------------------\n    UIDrawable* DrawableUIComponent::GetDrawable()\n    {\n        return m_drawable.get();\n    }\n    //-------------------------------------------------------------------\n    //-------------------------------------------------------------------\n    const UIDrawable* DrawableUIComponent::GetDrawable() const\n    {\n        return m_drawable.get();\n    }\n    //-------------------------------------------------------------------\n    //-------------------------------------------------------------------\n    void DrawableUIComponent::ApplyDrawableDef(const UIDrawableDefCSPtr& in_drawableDef)\n    {\n        m_drawable.reset();\n        m_drawableDef = in_drawableDef;\n        \n        if (m_drawableDef != nullptr)\n        {\n            m_drawable = m_drawableDef->CreateDrawable();\n        }\n    }\n    //-------------------------------------------------------------------\n    //-------------------------------------------------------------------\n    const UIDrawableDefCSPtr& DrawableUIComponent::GetDrawableDef() const\n    {\n        return m_drawableDef;\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    void DrawableUIComponent::OnDraw(CanvasRenderer* in_renderer, const Matrix3& in_transform, const Vector2& in_absSize, const Colour& in_absColour)\n    {\n        if (m_drawable != nullptr)\n        {\n            m_drawable->Draw(in_renderer, in_transform, in_absSize, in_absColour, m_drawableDef->GetDrawMode());\n        }\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    void DrawableUIComponent::OnPreDrawChildren(CanvasRenderer* in_renderer)\n    {\n        auto drawMode = m_drawableDef->GetDrawMode();\n        \n        if(m_drawable != nullptr && (drawMode == CanvasDrawMode::k_mask || drawMode == CanvasDrawMode::k_maskOnly))\n        {\n            in_renderer->IncrementClipMask();\n        }\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    void DrawableUIComponent::OnPostDrawChildren(CanvasRenderer* in_renderer)\n    {\n        auto drawMode = m_drawableDef->GetDrawMode();\n        \n        if(m_drawable != nullptr && (drawMode == CanvasDrawMode::k_mask || drawMode == CanvasDrawMode::k_maskOnly))\n        {\n            in_renderer->DecrementClipMask();\n        }\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/UI/Drawable/DrawableUIComponent.h",
    "content": "//\n//  DrawableUIComponent.h\n//  ChilliSource\n//  Created by Ian Copland on 28/11/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_UI_DRAWABLE_DRAWABLEUICOMPONENT_H_\n#define _CHILLISOURCE_UI_DRAWABLE_DRAWABLEUICOMPONENT_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Container/Property/PropertyMap.h>\n#include <ChilliSource/Core/Event/EventConnection.h>\n#include <ChilliSource/Input/Pointer/Pointer.h>\n#include <ChilliSource/UI/Base/UIComponent.h>\n#include <ChilliSource/UI/Drawable/UIDrawable.h>\n\nnamespace ChilliSource\n{\n    //--------------------------------------------------------------------------\n    /// A component for rendering image in a widget. This is handled through\n    /// setting a UIDrawable. Drawables come in 3 different types: Standard,\n    /// Three-Patch and Nine-Patch. A Standard drawable renders a basic image,\n    /// A Three-Patch drawable will stretch without distorting the image in\n    /// 1 direction and a Nine-Patch can stretch in any direction without\n    /// distorting the image. Any drawable type can be created using an entire\n    /// texture or using a texture atlas, which describes the portion of a\n    /// texture which should be rendered.\n    ///\n    /// A DrawableUIComponent contains the following properties:\n    ///\n    /// \"Drawable\": The description of the drawable that will be rendered. The\n    /// contents of a drawable are described in each of the drawable def types\n    /// documentation.\n    ///\n    /// @author Ian Copland\n    //--------------------------------------------------------------------------\n    class DrawableUIComponent final : public UIComponent\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(DrawableUIComponent);\n        //-------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The list of properties supported by a drawable component.\n        //-------------------------------------------------------------------\n        static const std::vector<PropertyMap::PropertyDesc>& GetPropertyDescs();\n        //-------------------------------------------------------------------\n        /// Allows querying of whether or not the component implements the\n        /// interface associated with the given interface Id. Typically\n        /// this won't be called directly, instead the templated version\n        /// IsA<Interface>() should be used.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The interface Id.\n        ///\n        /// @return Whether the object implements the given interface.\n        //-------------------------------------------------------------------\n        bool IsA(InterfaceIDType in_interfaceId) const override;\n        //-------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The drawable object that performs the rendering. This\n        /// can be used to directly change properties such as the UVs and\n        /// colour of the rendered image.\n        //-------------------------------------------------------------------\n        UIDrawable* GetDrawable();\n        //-------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return A const pointer to the drawable object that performs the\n        /// rendering. \n        //-------------------------------------------------------------------\n        const UIDrawable* GetDrawable() const;\n        //-------------------------------------------------------------------\n        /// Sets the drawable definition that is used to create the underlying\n        /// drawable object.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The drawable defintion.\n        //-------------------------------------------------------------------\n        void ApplyDrawableDef(const UIDrawableDefCSPtr& in_drawableDef);\n        \n    private:\n        friend class UIComponentFactory;\n        //-------------------------------------------------------------------\n        /// Constructor that builds the component from key-value properties.\n        /// The properties used to create a drawable component are described\n        /// in the class documentation.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The component name.\n        /// @param The property map.\n        //-------------------------------------------------------------------\n        DrawableUIComponent(const std::string& in_componentName, const PropertyMap& in_properties);\n        //-------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The drawable definition that was used to create the\n        /// underlying drawable object.\n        //-------------------------------------------------------------------\n        const UIDrawableDefCSPtr& GetDrawableDef() const;\n        //----------------------------------------------------------------\n        /// This is called during the draw event whenever the application\n        /// is active and the owning widget in on the canvas. This will\n        /// render the contained drawable to the screen.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The canvas renderer.\n        /// @param The final screen space transform.\n        /// @param The final screen space size.\n        /// @param The final colour.\n        /// @param Number of the layer in the UI hierarchy\n        //----------------------------------------------------------------\n        void OnDraw(CanvasRenderer* in_renderer, const Matrix3& in_transform, const Vector2& in_absSize, const Colour& in_absColour) override;\n        //----------------------------------------------------------------\n        /// Called prior to the widget drawing its children. Used for\n        /// setting up subview clipping\n        ///\n        /// @param The canvas renderer.\n        //----------------------------------------------------------------\n        void OnPreDrawChildren(CanvasRenderer* in_renderer) override;\n        //----------------------------------------------------------------\n        /// Called after the widget draws its children. Used for cleaning\n        /// up subview clipping\n        ///\n        /// @param The canvas renderer.\n        //----------------------------------------------------------------\n        void OnPostDrawChildren(CanvasRenderer* in_renderer) override;\n        \n        UIDrawableDefCSPtr m_drawableDef;\n        UIDrawableUPtr m_drawable;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/UI/Drawable/NinePatchUIDrawable.cpp",
    "content": "//\n//  NinePatchUIDrawable.cpp\n//  ChilliSource\n//  Created by Scott Downie on 24/07/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/UI/Drawable/NinePatchUIDrawable.h>\n\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/Math/MathUtils.h>\n#include <ChilliSource/Core/Resource/ResourcePool.h>\n#include <ChilliSource/Core/String/StringParser.h>\n#include <ChilliSource/Rendering/Base/AlignmentAnchors.h>\n#include <ChilliSource/Rendering/Base/AspectRatioUtils.h>\n#include <ChilliSource/Rendering/Base/CanvasRenderer.h>\n#include <ChilliSource/Rendering/Texture/Texture.h>\n#include <ChilliSource/UI/Drawable/UIDrawableUtils.h>\n\nnamespace ChilliSource\n{\n    namespace\n    {\n        //----------------------------------------------------------------------------------------\n        /// Identifier for each patch in the 9 patch. Can be used as index look-ups into\n        /// arrays of UVs, positions, etc.\n        ///\n        /// @author S Downie\n        //----------------------------------------------------------------------------------------\n        enum class Patch\n        {\n            k_topLeft,\n            k_topCentre,\n            k_topRight,\n            k_middleLeft,\n            k_middleCentre,\n            k_middleRight,\n            k_bottomLeft,\n            k_bottomCentre,\n            k_bottomRight\n        };\n        //----------------------------------------------------------------------------------------\n        /// Based on the insets and the given UVs calculate the UVs for each of the 9 patches\n        ///\n        /// @author S Downie\n        ///\n        /// @param Image frame\n        /// @param Left inset as normalised percentage\n        /// @param Right inset as normalised percentage\n        /// @param Top inset as normalised percentage\n        /// @param Bottom inset as normalised percentage\n        ///\n        /// @return UVs for the 9 patches\n        //----------------------------------------------------------------------------------------\n        std::array<UVs, NinePatchUIDrawable::k_numPatches> CalculateNinePatchUVs(const TextureAtlas::Frame& in_frame, f32 in_left, f32 in_right, f32 in_top, f32 in_bottom)\n        {\n            std::array<UVs, NinePatchUIDrawable::k_numPatches> result;\n            \n            f32 uvWidth = (in_frame.m_originalSize.x/in_frame.m_croppedSize.x) * in_frame.m_uvs.m_s;\n            \n            f32 leftU = in_frame.m_uvs.m_u - uvWidth + in_frame.m_uvs.m_s;\n            f32 middleU = leftU + (uvWidth * in_left);\n            f32 rightU = middleU + (uvWidth * (1.0f - in_right - in_left));\n            \n            f32 leftUS = middleU;\n            f32 middleUS = rightU;\n            f32 rightUS = leftU + uvWidth;\n\n            f32 uvHeight = (in_frame.m_originalSize.y/in_frame.m_croppedSize.y) * in_frame.m_uvs.m_t;\n            \n            f32 topV = in_frame.m_uvs.m_v - uvHeight + in_frame.m_uvs.m_t;\n            f32 middleV = topV + (uvHeight * in_top);\n            f32 bottomV = middleV + (uvHeight * (1.0f - in_top - in_bottom));\n            \n            f32 topVT = middleV;\n            f32 middleVT = bottomV;\n            f32 bottomVT = topV + uvHeight;\n            \n            leftU = std::max(leftU, in_frame.m_uvs.m_u);\n            middleU = std::max(middleU, in_frame.m_uvs.m_u);\n            rightU = std::max(rightU, in_frame.m_uvs.m_u);\n            \n            topV = std::max(topV, in_frame.m_uvs.m_v);\n            middleV = std::max(middleV, in_frame.m_uvs.m_v);\n            bottomV = std::max(bottomV, in_frame.m_uvs.m_v);\n            \n            leftUS = std::min(leftUS, in_frame.m_uvs.m_u + in_frame.m_uvs.m_s);\n            middleUS = std::min(middleUS, in_frame.m_uvs.m_u + in_frame.m_uvs.m_s);\n            rightUS = std::min(rightUS, in_frame.m_uvs.m_u + in_frame.m_uvs.m_s);\n            \n            topVT = std::min(topVT, in_frame.m_uvs.m_v + in_frame.m_uvs.m_t);\n            middleVT = std::min(middleVT, in_frame.m_uvs.m_v + in_frame.m_uvs.m_t);\n            bottomVT = std::min(bottomVT, in_frame.m_uvs.m_v + in_frame.m_uvs.m_t);\n            \n            f32 leftS = leftUS - leftU;\n            f32 middleS = middleUS - middleU;\n            f32 rightS = rightUS - rightU;\n            \n            f32 topT = topVT - topV;\n            f32 middleT = middleVT - middleV;\n            f32 bottomT = bottomVT - bottomV;\n            \n            result[(u32)Patch::k_topLeft].m_u = leftU;\n            result[(u32)Patch::k_topLeft].m_s = leftS;\n            result[(u32)Patch::k_middleLeft].m_u = leftU;\n            result[(u32)Patch::k_middleLeft].m_s = leftS;\n            result[(u32)Patch::k_bottomLeft].m_u = leftU;\n            result[(u32)Patch::k_bottomLeft].m_s = leftS;\n            \n            result[(u32)Patch::k_topCentre].m_u = middleU;\n            result[(u32)Patch::k_topCentre].m_s = middleS;\n            result[(u32)Patch::k_middleCentre].m_u = middleU;\n            result[(u32)Patch::k_middleCentre].m_s = middleS;\n            result[(u32)Patch::k_bottomCentre].m_u = middleU;\n            result[(u32)Patch::k_bottomCentre].m_s = middleS;\n            \n            result[(u32)Patch::k_topRight].m_u = rightU;\n            result[(u32)Patch::k_topRight].m_s = rightS;\n            result[(u32)Patch::k_middleRight].m_u = rightU;\n            result[(u32)Patch::k_middleRight].m_s = rightS;\n            result[(u32)Patch::k_bottomRight].m_u = rightU;\n            result[(u32)Patch::k_bottomRight].m_s = rightS;\n            \n            result[(u32)Patch::k_topLeft].m_v = topV;\n            result[(u32)Patch::k_topLeft].m_t = topT;\n            result[(u32)Patch::k_topCentre].m_v = topV;\n            result[(u32)Patch::k_topCentre].m_t = topT;\n            result[(u32)Patch::k_topRight].m_v = topV;\n            result[(u32)Patch::k_topRight].m_t = topT;\n            \n            result[(u32)Patch::k_middleLeft].m_v = middleV;\n            result[(u32)Patch::k_middleLeft].m_t = middleT;\n            result[(u32)Patch::k_middleCentre].m_v = middleV;\n            result[(u32)Patch::k_middleCentre].m_t = middleT;\n            result[(u32)Patch::k_middleRight].m_v = middleV;\n            result[(u32)Patch::k_middleRight].m_t = middleT;\n            \n            result[(u32)Patch::k_bottomLeft].m_v = bottomV;\n            result[(u32)Patch::k_bottomLeft].m_t = bottomT;\n            result[(u32)Patch::k_bottomCentre].m_v = bottomV;\n            result[(u32)Patch::k_bottomCentre].m_t = bottomT;\n            result[(u32)Patch::k_bottomRight].m_v = bottomV;\n            result[(u32)Patch::k_bottomRight].m_t = bottomT;\n            \n            return result;\n        }\n        //----------------------------------------------------------------------------------------\n        /// Based on the widget size and the given insets calculate the absolute size of each patch\n        ///\n        /// @author S Downie\n        ///\n        /// @param Widget absolute size\n        /// @param Image frame\n        /// @param Left inset as normalised percentage\n        /// @param Right inset as normalised percentage\n        /// @param Top inset as normalised percentage\n        /// @param Bottom inset as normalised percentage\n        ///\n        /// @return Sizes for the 9 patches\n        //----------------------------------------------------------------------------------------\n        std::array<Vector2, NinePatchUIDrawable::k_numPatches> CalculateNinePatchSizes(const Vector2& in_widgetSize, const TextureAtlas::Frame& in_frame, f32 in_left, f32 in_right, f32 in_top, f32 in_bottom)\n        {\n            std::array<Vector2, NinePatchUIDrawable::k_numPatches> result;\n            \n            f32 widthImageLeft = in_frame.m_originalSize.x * in_left;\n            f32 widthVisibleLeft = MathUtils::Clamp(-in_frame.m_offset.x + widthImageLeft, 0.0f, in_frame.m_croppedSize.x);\n        \n            f32 offsetRight = -(in_frame.m_originalSize.x - (in_frame.m_offset.x + in_frame.m_croppedSize.x));\n            f32 widthImageRight = in_frame.m_originalSize.x * in_right;\n            f32 widthVisibleRight = MathUtils::Clamp(offsetRight + widthImageRight, 0.0f, in_frame.m_croppedSize.x);\n            \n            f32 heightImageTop = in_frame.m_originalSize.y * in_top;\n            f32 heightVisibleTop = MathUtils::Clamp(-in_frame.m_offset.y + heightImageTop, 0.0f, in_frame.m_croppedSize.y);\n            \n            f32 offsetBottom = -(in_frame.m_originalSize.y - (in_frame.m_offset.y + in_frame.m_croppedSize.y));\n            f32 heightImageBottom = in_frame.m_originalSize.y * in_bottom;\n            f32 heightVisibleBottom = MathUtils::Clamp(offsetBottom + heightImageBottom, 0.0f, in_frame.m_croppedSize.y);\n            \n            //If the fixed dimensions are too big to fit in the widget then we need to downscale them\n            f32 heightTotal = heightVisibleTop + heightVisibleBottom;\n            if(heightTotal > in_widgetSize.y)\n            {\n                f32 scale = in_widgetSize.y/heightTotal;\n                heightVisibleTop *= scale;\n                heightVisibleBottom *= scale;\n            }\n            f32 widthTotal = widthVisibleLeft + widthVisibleRight;\n            if(widthTotal > in_widgetSize.x)\n            {\n                f32 scale = in_widgetSize.x/widthTotal;\n                widthVisibleLeft *= scale;\n                widthVisibleRight *= scale;\n            }\n            \n            f32 widthImageCentre = in_frame.m_originalSize.x * (1.0f - in_right - in_left);\n            f32 widthVisibleCentre = MathUtils::Clamp(widthImageCentre - (in_frame.m_offset.x + widthVisibleLeft - widthImageLeft), 0.0f, in_frame.m_croppedSize.x);\n            f32 widthStretched = in_widgetSize.x - widthVisibleLeft - widthVisibleRight;\n            f32 widthWidgetCentre = widthVisibleCentre * (widthStretched/widthImageCentre);\n            \n            f32 heightImageCentre = in_frame.m_originalSize.y * (1.0f - in_bottom - in_top);\n            f32 heightVisibleCentre = MathUtils::Clamp(heightImageCentre - (in_frame.m_offset.y + heightVisibleTop - heightImageTop), 0.0f, in_frame.m_croppedSize.y);\n            f32 heightStretched = in_widgetSize.y - heightVisibleTop - heightVisibleBottom;\n            f32 heightWidgetCentre = heightVisibleCentre * (heightStretched/heightImageCentre);\n            \n            result[(u32)Patch::k_topLeft].x = widthVisibleLeft;\n            result[(u32)Patch::k_topLeft].y = heightVisibleTop;\n            result[(u32)Patch::k_topRight].x = widthVisibleRight;\n            result[(u32)Patch::k_topRight].y = heightVisibleTop;\n            result[(u32)Patch::k_bottomLeft].x = widthVisibleLeft;\n            result[(u32)Patch::k_bottomLeft].y = heightVisibleBottom;\n            result[(u32)Patch::k_bottomRight].x = widthVisibleRight;\n            result[(u32)Patch::k_bottomRight].y = heightVisibleBottom;\n            result[(u32)Patch::k_middleLeft].x = widthVisibleLeft;\n            result[(u32)Patch::k_middleRight].x = widthVisibleRight;\n            result[(u32)Patch::k_topCentre].y = heightVisibleTop;\n            result[(u32)Patch::k_bottomCentre].y = heightVisibleBottom;\n            result[(u32)Patch::k_topCentre].x = widthWidgetCentre;\n            result[(u32)Patch::k_bottomCentre].x = widthWidgetCentre;\n            result[(u32)Patch::k_middleCentre].x = widthWidgetCentre;\n            result[(u32)Patch::k_middleCentre].y = heightWidgetCentre;\n            result[(u32)Patch::k_middleLeft].y = heightWidgetCentre;\n            result[(u32)Patch::k_middleRight].y = heightWidgetCentre;\n\n            return result;\n        }\n        //----------------------------------------------------------------------------------------\n        /// Calculate the local space positions for each patch with the origin of the overall\n        /// widget at the top left\n        ///\n        /// @author S Downie\n        ///\n        /// @param Widget size\n        /// @param Patch sizes\n        ///\n        /// @return Sizes for the 9 patches\n        //----------------------------------------------------------------------------------------\n        std::array<Vector2, NinePatchUIDrawable::k_numPatches> CalculateNinePatchPositions(const Vector2& in_widgetSize, const std::array<Vector2, NinePatchUIDrawable::k_numPatches>& in_sizes)\n        {\n            std::array<Vector2, NinePatchUIDrawable::k_numPatches> result;\n            \n            Vector2 halfWidgetSize = in_widgetSize * 0.5f;\n            Vector2 halfMiddleCentre = in_sizes[(u32)Patch::k_middleCentre] * 0.5f;\n            Vector2 halfMiddleLeft = in_sizes[(u32)Patch::k_middleLeft] * 0.5f;\n            Vector2 halfMiddleRight = in_sizes[(u32)Patch::k_middleRight] * 0.5f;\n            Vector2 halfTopCentre = in_sizes[(u32)Patch::k_topCentre] * 0.5f;\n            Vector2 halfTopLeft = in_sizes[(u32)Patch::k_topLeft] * 0.5f;\n            Vector2 halfTopRight = in_sizes[(u32)Patch::k_topRight] * 0.5f;\n            Vector2 halfBottomCentre = in_sizes[(u32)Patch::k_bottomCentre] * 0.5f;\n            Vector2 halfBottomLeft = in_sizes[(u32)Patch::k_bottomLeft] * 0.5f;\n            Vector2 halfBottomRight = in_sizes[(u32)Patch::k_bottomRight] * 0.5f;\n            \n            result[(u32)Patch::k_topLeft].x = -halfWidgetSize.x + halfTopLeft.x;\n            result[(u32)Patch::k_topLeft].y = halfWidgetSize.y - halfTopLeft.y;\n            \n            result[(u32)Patch::k_middleLeft].x = -halfWidgetSize.x + halfMiddleLeft.x;\n            result[(u32)Patch::k_middleLeft].y = result[(u32)Patch::k_topLeft].y - halfTopLeft.y - halfMiddleLeft.y;\n            \n            result[(u32)Patch::k_bottomLeft].x = -halfWidgetSize.x + halfBottomLeft.x;\n            result[(u32)Patch::k_bottomLeft].y = result[(u32)Patch::k_middleLeft].y - halfMiddleLeft.y - halfBottomLeft.y;\n            \n            result[(u32)Patch::k_topCentre].x = result[(u32)Patch::k_topLeft].x + halfTopLeft.x + halfTopCentre.x;\n            result[(u32)Patch::k_topCentre].y = halfWidgetSize.y - halfTopCentre.y;\n            \n            result[(u32)Patch::k_middleCentre].x = result[(u32)Patch::k_middleLeft].x + halfMiddleLeft.x + halfMiddleCentre.x;\n            result[(u32)Patch::k_middleCentre].y = result[(u32)Patch::k_topCentre].y - halfTopCentre.y - halfMiddleCentre.y;\n            \n            result[(u32)Patch::k_bottomCentre].x = result[(u32)Patch::k_bottomLeft].x + halfBottomLeft.x + halfBottomCentre.x;\n            result[(u32)Patch::k_bottomCentre].y = result[(u32)Patch::k_middleCentre].y - halfMiddleCentre.y - halfBottomCentre.y;\n            \n            result[(u32)Patch::k_topRight].x = result[(u32)Patch::k_topCentre].x + halfTopCentre.x + halfTopRight.x;\n            result[(u32)Patch::k_topRight].y = halfWidgetSize.y - halfTopRight.y;\n            \n            result[(u32)Patch::k_middleRight].x = result[(u32)Patch::k_middleCentre].x + halfMiddleCentre.x + halfMiddleRight.x;\n            result[(u32)Patch::k_middleRight].y = result[(u32)Patch::k_topRight].y - halfTopRight.y - halfMiddleRight.y;\n            \n            result[(u32)Patch::k_bottomRight].x = result[(u32)Patch::k_bottomCentre].x + halfBottomCentre.x + halfBottomRight.x;\n            result[(u32)Patch::k_bottomRight].y = result[(u32)Patch::k_middleRight].y - halfMiddleRight.y - halfBottomRight.y;\n            \n            return result;\n        }\n        //----------------------------------------------------------------------------------------\n        /// Calculate the offset for the patches that will position them as if they still had\n        /// their cropped space\n        ///\n        /// @author S Downie\n        ///\n        /// @param Widget absolute size\n        /// @param Image frame\n        /// @param Left inset as normalised percentage\n        /// @param Right inset as normalised percentage\n        /// @param Top inset as normalised percentage\n        /// @param Bottom inset as normalised percentage\n        ///\n        /// @return Offset from top left\n        //----------------------------------------------------------------------------------------\n        Vector2 CalculatePatchesOffset(const Vector2& in_widgetSize, const TextureAtlas::Frame& in_frame, f32 in_left, f32 in_right, f32 in_top, f32 in_bottom)\n        {\n            Vector2 result;\n            \n            f32 leftImageEnd = in_frame.m_originalSize.x * in_left;\n            f32 leftImageWidth = leftImageEnd;\n            f32 rightImageWidth = in_frame.m_originalSize.x * in_right;\n            f32 centreImageEnd = in_frame.m_originalSize.x * (1.0f - in_right);\n            \n            //Left patch\n            f32 offsetLeftImage = std::min(in_frame.m_offset.x, leftImageWidth);\n            result.x += offsetLeftImage;\n            \n            if(in_frame.m_offset.x > leftImageEnd)\n            {\n                //Centre patch\n                f32 centreWidgetWidthStretched = in_widgetSize.x - leftImageWidth - rightImageWidth;\n                f32 centreImageWidth = centreImageEnd - leftImageEnd;\n                f32 centreOffset = std::min(in_frame.m_offset.x - leftImageWidth, centreImageWidth);\n                f32 centreOffsetWidget = (centreOffset/centreImageWidth) * centreWidgetWidthStretched;\n                \n                result.x += std::min(centreOffsetWidget, centreWidgetWidthStretched);\n            }\n            if(in_frame.m_offset.x > centreImageEnd)\n            {\n                //Right patch\n                f32 rightOffsetImage = in_frame.m_offset.x - centreImageEnd;\n                result.x += rightOffsetImage;\n            }\n            \n\n            f32 topImageEnd = in_frame.m_originalSize.y * in_top;\n            f32 topImageHeight = topImageEnd;\n            f32 bottomImageHeight = in_frame.m_originalSize.y * in_bottom;\n            f32 middleImageEnd = in_frame.m_originalSize.y * (1.0f - in_bottom);\n            \n            //Top patch\n            f32 offsetTopImage = std::min(in_frame.m_offset.y, topImageHeight);\n            result.y -= offsetTopImage;\n            \n            if(in_frame.m_offset.y > topImageEnd)\n            {\n                //Middle patch\n                f32 centreWidgetHeightStretched = in_widgetSize.y - topImageHeight - bottomImageHeight;\n                f32 centreImageHeight = middleImageEnd - topImageEnd;\n                f32 centreOffset = std::min(in_frame.m_offset.y - topImageHeight, centreImageHeight);\n                f32 centreOffsetWidget = (centreOffset/centreImageHeight) * centreWidgetHeightStretched;\n                \n                result.y -= std::min(centreOffsetWidget, centreWidgetHeightStretched);\n            }\n            if(in_frame.m_offset.y > middleImageEnd)\n            {\n                //Bottom patch\n                f32 bottomOffsetImage = in_frame.m_offset.y - middleImageEnd;\n                result.y -= bottomOffsetImage;\n            }\n            \n            return result;\n        }\n    }\n    \n    CS_DEFINE_NAMEDTYPE(NinePatchUIDrawable);\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    NinePatchUIDrawable::NinePatchUIDrawable(const TextureCSPtr& in_texture, f32 in_leftInset, f32 in_rightInset, f32 in_topInset, f32 in_bottomInset)\n    {\n        SetTexture(in_texture);\n        SetInsets(in_leftInset, in_rightInset, in_topInset, in_bottomInset);\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    NinePatchUIDrawable::NinePatchUIDrawable(const TextureCSPtr& in_texture, const TextureAtlasCSPtr& in_atlas, const std::string& in_atlasId, f32 in_leftInset, f32 in_rightInset,\n                                         f32 in_topInset, f32 in_bottomInset)\n    {\n        CS_ASSERT(in_atlas != nullptr, \"Texture atlas cannot be null.\");\n        CS_ASSERT(in_atlas->HasFrameWithId(in_atlasId) == true, \"Texture atlas must contain provided Id.\");\n        \n        SetTexture(in_texture);\n        SetTextureAtlas(in_atlas);\n        SetTextureAtlasId(in_atlasId);\n        SetInsets(in_leftInset, in_rightInset, in_topInset, in_bottomInset);\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    bool NinePatchUIDrawable::IsA(InterfaceIDType in_interfaceId) const\n    {\n        return (UIDrawable::InterfaceID == in_interfaceId || NinePatchUIDrawable::InterfaceID == in_interfaceId);\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    const TextureCSPtr& NinePatchUIDrawable::GetTexture() const\n    {\n        return m_texture;\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    const TextureAtlasCSPtr& NinePatchUIDrawable::GetTextureAtlas() const\n    {\n        return m_atlas;\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    const std::string& NinePatchUIDrawable::GetTextureAtlasId() const\n    {\n        return m_atlasId;\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    const UVs& NinePatchUIDrawable::GetUVs() const\n    {\n        return m_uvs;\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    const Colour& NinePatchUIDrawable::GetColour() const\n    {\n        return m_colour;\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    void NinePatchUIDrawable::SetTexture(const TextureCSPtr& in_texture)\n    {\n        CS_ASSERT(in_texture != nullptr, \"Texture cannot be null in a nine-patch drawable.\");\n        \n        m_texture = in_texture;\n        \n        m_atlasFrame = UIDrawableUtils::BuildFrame(m_texture.get(), m_atlas.get(), m_atlasId, m_uvs);\n        m_isPatchCatchValid = false;\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    void NinePatchUIDrawable::SetTextureAtlas(const TextureAtlasCSPtr& in_atlas)\n    {\n        m_atlas = in_atlas;\n        m_atlasId = \"\";\n        \n        m_atlasFrame = UIDrawableUtils::BuildFrame(m_texture.get(), m_atlas.get(), m_atlasId, m_uvs);\n        m_isPatchCatchValid = false;\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    void NinePatchUIDrawable::SetTextureAtlasId(const std::string& in_atlasId)\n    {\n        CS_ASSERT(m_atlas != nullptr, \"NinePatchUIDrawable::SetTextureAtlasId: Atlas Id cannot be set without first setting an atlas\");\n        \n        m_atlasId = in_atlasId;\n        \n        m_atlasFrame = UIDrawableUtils::BuildFrame(m_texture.get(), m_atlas.get(), m_atlasId, m_uvs);\n        m_isPatchCatchValid = false;\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    void NinePatchUIDrawable::SetUVs(const UVs& in_UVs)\n    {\n        m_uvs = in_UVs;\n        \n        m_atlasFrame = UIDrawableUtils::BuildFrame(m_texture.get(), m_atlas.get(), m_atlasId, m_uvs);\n        m_isPatchCatchValid = false;\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    void NinePatchUIDrawable::SetColour(const Colour& in_colour)\n    {\n        m_colour = in_colour;\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    void NinePatchUIDrawable::SetInsets(f32 in_left, f32 in_right, f32 in_top, f32 in_bottom)\n    {\n        CS_ASSERT(in_left > 0.0f && in_right > 0.0f && in_top > 0.0f && in_bottom > 0.0f, \"Insets must be greater than 0\");\n        CS_ASSERT(in_left + in_right <= 1.0f, \"Insets must not overlap i.e. sum to more than 1\");\n        CS_ASSERT(in_top + in_bottom <= 1.0f, \"Insets must not overlap i.e. sum to more than 1\");\n        \n        m_leftInset = in_left;\n        m_rightInset = in_right;\n        m_topInset = in_top;\n        m_bottomInset = in_bottom;\n        \n        m_isPatchCatchValid = false;\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    Vector2 NinePatchUIDrawable::GetPreferredSize() const\n    {\n        return m_atlasFrame.m_originalSize;\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    void NinePatchUIDrawable::UpdatePatchCache(const Vector2& absSize)\n    {\n        if(m_cachedWidgetSize != absSize)\n        {\n            m_isPatchCatchValid = false;\n            m_cachedWidgetSize = absSize;\n        }\n        \n        if(m_isPatchCatchValid == false)\n        {\n            //When textures are packed into an atlas their alpha space is cropped. This functionality restores the alpha space by resizing and offsetting the patches.\n            m_cachedUvs = CalculateNinePatchUVs(m_atlasFrame, m_leftInset, m_rightInset, m_topInset, m_bottomInset);\n            m_cachedSizes = CalculateNinePatchSizes(absSize, m_atlasFrame, m_leftInset, m_rightInset, m_topInset, m_bottomInset);\n            m_cachedPositions = CalculateNinePatchPositions(absSize, m_cachedSizes);\n            m_cachedOffsetTL = CalculatePatchesOffset(absSize, m_atlasFrame, m_leftInset, m_rightInset, m_topInset, m_bottomInset);\n            \n            m_isPatchCatchValid = true;\n        }\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    void NinePatchUIDrawable::Draw(CanvasRenderer* renderer, const Matrix3& transform, const Vector2& absSize, const Colour& absColour, CanvasDrawMode drawMode) noexcept\n    {\n        CS_ASSERT(m_texture != nullptr, \"NinePatchUIDrawable cannot draw without texture\");\n        \n        UpdatePatchCache(absSize);\n        \n        for(u32 i=0; i<k_numPatches; ++i)\n        {\n            Matrix3 patchTransform = Matrix3::CreateTranslation(m_cachedPositions[i]);\n            renderer->DrawBox(drawMode, patchTransform * transform, m_cachedSizes[i], m_cachedOffsetTL, m_texture, m_cachedUvs[i], absColour * m_colour, AlignmentAnchor::k_middleCentre);\n        }\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/UI/Drawable/NinePatchUIDrawable.h",
    "content": "//\n//  NinePatchUIDrawable.h\n//  ChilliSource\n//  Created by Scott Downie on 24/07/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n\n#ifndef _CHILLISOURCE_UI_DRAWABLE_NINEPATCHUIDRAWABLE_H_\n#define _CHILLISOURCE_UI_DRAWABLE_NINEPATCHUIDRAWABLE_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Base/Colour.h>\n#include <ChilliSource/Rendering/Texture/TextureAtlas.h>\n#include <ChilliSource/Rendering/Texture/UVs.h>\n#include <ChilliSource/UI/Drawable/UIDrawable.h>\n\n#include <array>\n\nnamespace ChilliSource\n{\n    //----------------------------------------------------------------------------------------\n    /// Interface for rendering widget with a texture and UVs as a 9 patch. This allows the\n    /// widget to be scaled without distorting the edges. The patches are specified by percentage\n    /// insets from the edges of the widget.\n    ///\n    /// The right and left patches should be designed to stretch vertically.\n    /// The top and bottom patches should be designed to stretch horizontally.\n    /// The centre patch should be designed to stretch horizontally and vertically\n    ///\n    /// @author S Downie\n    //----------------------------------------------------------------------------------------\n    class NinePatchUIDrawable final : public UIDrawable\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(NinePatchUIDrawable);\n        \n        static const u32 k_numPatches = 9;\n        //----------------------------------------------------------------------------------------\n        /// Allows querying of whether or not the component implements the interface associated\n        /// with the given interface Id. Typically this won't be called directly, instead the\n        /// templated version IsA<Interface>() should be used.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The interface Id.\n        ///\n        /// @return Whether the object implements the given interface.\n        //----------------------------------------------------------------------------------------\n        bool IsA(InterfaceIDType in_interfaceId) const override;\n        //----------------------------------------------------------------------------------------\n        /// Get the texture that is currently used.\n        ///\n        /// @author HMcLaughlin\n        ///\n        /// @return Texture\n        //----------------------------------------------------------------------------------------\n        const TextureCSPtr& GetTexture() const override;\n        //----------------------------------------------------------------------------------------\n        /// Get the texture atlas that is currently used.\n        ///\n        /// @author HMcLaughlin\n        ///\n        /// @return Texture atlas\n        //----------------------------------------------------------------------------------------\n        const TextureAtlasCSPtr& GetTextureAtlas() const override;\n        //----------------------------------------------------------------------------------------\n        /// Get the texture atlas frame Id that is currently used.\n        ///\n        /// @author HMcLaughlin\n        ///\n        /// @return Frame Id\n        //----------------------------------------------------------------------------------------\n        const std::string& GetTextureAtlasId() const override;\n        //----------------------------------------------------------------------------------------\n        /// Get the UVs that are currently used. UVs are relative to the\n        /// frame and not the overall atlas\n        ///\n        /// @author HMcLaughlin\n        ///\n        /// @return Rectangle containing U, V, S, T\n        //----------------------------------------------------------------------------------------\n        const UVs& GetUVs() const override;\n        //----------------------------------------------------------------------------------------\n        /// Gets the colour of the drawable.\n        ///\n        /// @author HMcLaughlin\n        ///\n        /// @param The colour.\n        //----------------------------------------------------------------------------------------\n        const Colour& GetColour() const override;\n        //----------------------------------------------------------------------------------------\n        /// Set the texture that should be used in subsequent draws\n        ///\n        /// @author S Downie\n        ///\n        /// @param Texture\n        //----------------------------------------------------------------------------------------\n        void SetTexture(const TextureCSPtr& in_texture) override;\n        //----------------------------------------------------------------------------------------\n        /// Set the texture atlas that should be used in subsequent draws.\n        ///\n        /// @author S Downie\n        ///\n        /// @param Texture atlas\n        //----------------------------------------------------------------------------------------\n        void SetTextureAtlas(const TextureAtlasCSPtr& in_atlas) override;\n        //----------------------------------------------------------------------------------------\n        /// Set the texture atlas frame Id that should be used in subsequent draws.\n        ///\n        /// NOTE: An atlas must have been set prior to calling this\n        ///\n        /// @author S Downie\n        ///\n        /// @param Frame Id\n        //----------------------------------------------------------------------------------------\n        void SetTextureAtlasId(const std::string& in_atlasId) override;\n        //----------------------------------------------------------------------------------------\n        /// Set the UVs that should be used in subsequent draws. UVs are relative to the\n        /// frame and not the overall atlas\n        ///\n        /// @author S Downie\n        ///\n        /// @param Rectangle containing U, V, S, T\n        //----------------------------------------------------------------------------------------\n        void SetUVs(const UVs& in_UVs) override;\n        //----------------------------------------------------------------------------------------\n        /// Sets the colour of the drawable. The final colour of the drawable takes into account\n        /// the owning widgets colour and this colour.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The colour.\n        //----------------------------------------------------------------------------------------\n        void SetColour(const Colour& in_colour) override;\n        //----------------------------------------------------------------------------------------\n        /// Set the UV insets that should be used to create the patches. Insets are from the edge\n        /// and therefore no negative numbers need to be specified for right and bottom insets.\n        ///\n        /// NOTE: Insets must compliment each other i.e. left and right cannot sum to more than 1.0\n        /// as they would overlap and insets cannot be zero or less.\n        ///\n        /// @author S Downie\n        ///\n        /// @param Left inset as normalised fraction (0 - 1)\n        /// @param Right inset as normalised fraction (0 - 1)\n        /// @param Top inset as normalised fraction (0 - 1)\n        /// @param Bottom inset as normalised fraction (0 - 1)\n        //----------------------------------------------------------------------------------------\n        void SetInsets(f32 in_left, f32 in_right, f32 in_top, f32 in_bottom);\n        //----------------------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return The preferred size that the drawable wishes to de drawn at based on the\n        /// texture size\n        //----------------------------------------------------------------------------------------\n        Vector2 GetPreferredSize() const override;\n        \n        /// Render the widget using the canvas renderer.\n        ///\n        /// @param renderer\n        ///     Performs the actual drawing to canvas\n        /// @param transform\n        ///     Absolute screen transform\n        /// @param absSize\n        ///     Asbolute screen size\n        /// @param absColour\n        ///     Absolute colour\n        /// @param drawMode\n        ///     Whether or not to create a clip mask for this drawable or just render to screen\n        ///\n        void Draw(CanvasRenderer* renderer, const Matrix3& transform, const Vector2& absSize, const Colour& absColour, CanvasDrawMode drawMode) noexcept override;\n        \n    private:\n        friend class NinePatchUIDrawableDef;\n        //----------------------------------------------------------------------------------------\n        /// Constructor\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The texture.\n        /// @param The left inset.\n        /// @param The right inset.\n        /// @param The top inset.\n        /// @param The bottom inset.\n        //----------------------------------------------------------------------------------------\n        NinePatchUIDrawable(const TextureCSPtr& in_texture, f32 in_leftInset, f32 in_rightInset, f32 in_topInset, f32 in_bottomInset);\n        //----------------------------------------------------------------------------------------\n        /// Constructor\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The texture.\n        /// @param The texture atlas.\n        /// @param The atlas id.\n        /// @param The left inset.\n        /// @param The right inset.\n        /// @param The top inset.\n        /// @param The bottom inset.\n        //----------------------------------------------------------------------------------------\n        NinePatchUIDrawable(const TextureCSPtr& in_texture, const TextureAtlasCSPtr& in_atlas, const std::string& in_atlasId, f32 in_leftInset, f32 in_rightInset, f32 in_topInset, f32 in_bottomInset);\n        \n        /// Patches (size, pos, etc) are calculated and cached. This function when called will\n        /// update the cache if required, otherwise it will do nothing\n        ///\n        /// @param absSize\n        ///     Canvas space size of the widget, if changed from last draw, update the cache\n        ///\n        void UpdatePatchCache(const Vector2& absSize);\n        \n        TextureCSPtr m_texture;\n        TextureAtlasCSPtr m_atlas;\n        TextureAtlas::Frame m_atlasFrame;\n        UVs m_uvs;\n        std::string m_atlasId;\n        \n        std::array<UVs, k_numPatches> m_cachedUvs;\n        std::array<Vector2, k_numPatches> m_cachedSizes;\n        std::array<Vector2, k_numPatches> m_cachedPositions;\n        Vector2 m_cachedOffsetTL;\n        Vector2 m_cachedWidgetSize;\n        Colour m_colour;\n        \n        f32 m_leftInset = 0.01f;\n        f32 m_rightInset = 0.01f;\n        f32 m_topInset = 0.01f;\n        f32 m_bottomInset = 0.01f;\n        \n        bool m_isPatchCatchValid = false;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/UI/Drawable/NinePatchUIDrawableDef.cpp",
    "content": "//\n//  NinePatchUIDrawableDef.cpp\n//  ChilliSource\n//  Created by Ian Copland on 15/12/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/UI/Drawable/NinePatchUIDrawableDef.h>\n\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/Resource/ResourcePool.h>\n#include <ChilliSource/Core/String/StringParser.h>\n#include <ChilliSource/Rendering/Base/CanvasDrawMode.h>\n#include <ChilliSource/Rendering/Texture/Texture.h>\n#include <ChilliSource/Rendering/Texture/TextureAtlas.h>\n#include <ChilliSource/UI/Drawable/NinePatchUIDrawable.h>\n\nnamespace ChilliSource\n{\n    CS_DEFINE_NAMEDTYPE(NinePatchUIDrawableDef);\n    //--------------------------------------------------------------\n    //--------------------------------------------------------------\n    NinePatchUIDrawableDef::NinePatchUIDrawableDef(const Json::Value& in_json, StorageLocation in_defaultLocation, const std::string& in_defaultPath)\n    : m_drawMode(CanvasDrawMode::k_standard)\n    {\n        const char k_typeKey[] = \"Type\";\n        const char k_textureLocationKey[] = \"TextureLocation\";\n        const char k_textureFilePathKey[] = \"TexturePath\";\n        const char k_atlasLocationKey[] = \"AtlasLocation\";\n        const char k_atlasFilePathKey[] = \"AtlasPath\";\n        const char k_atlasIdKey[] = \"AtlasId\";\n        const char k_uvsKey[] = \"UVs\";\n        const char k_colourKey[] = \"Colour\";\n        const char k_insetsKey[] = \"Insets\";\n        const char k_drawModeKey[] = \"DrawMode\";\n        \n        CS_ASSERT(in_json.isObject() == true, \"UIDrawable Def must be created from a json value of type Object.\");\n        \n        //read all the properties from JSON.\n        StorageLocation textureLocation = StorageLocation::k_none;\n        StorageLocation atlasLocation = StorageLocation::k_none;\n        std::string texturePath;\n        std::string atlasPath;\n        for(auto it = in_json.begin(); it != in_json.end(); ++it)\n        {\n            CS_ASSERT((*it).isString() == true, \"All properties in a UIDrawable Def must be a string: \" + std::string(it.memberName()));\n            \n            std::string key = it.memberName();\n            std::string value = (*it).asString();\n            \n            if (key == k_textureLocationKey)\n            {\n                textureLocation = ParseStorageLocation(value);\n            }\n            else if (key == k_textureFilePathKey)\n            {\n                texturePath = value;\n            }\n            else if (key == k_atlasLocationKey)\n            {\n                atlasLocation = ParseStorageLocation(value);\n            }\n            else if (key == k_atlasFilePathKey)\n            {\n                atlasPath = value;\n            }\n            else if (key == k_atlasIdKey)\n            {\n                m_atlasId = value;\n            }\n            else if (key == k_uvsKey)\n            {\n                auto vec =  ParseVector4(value);;\n                m_uvs = UVs(vec.x, vec.y, vec.z, vec.w);\n            }\n            else if (key == k_colourKey)\n            {\n                m_colour = ParseColour(value);\n            }\n            else if (key == k_insetsKey)\n            {\n                m_insets = ParseVector4(value);\n            }\n            else if (key == k_drawModeKey)\n            {\n                m_drawMode = ParseCanvasDrawMode(value);\n            }\n            else if (key == k_typeKey)\n            {\n                //ignore\n            }\n            else\n            {\n                CS_LOG_FATAL(\"Invalid property found in a Nine-Patch UIDrawable Def: \" + key);\n            }\n        }\n        \n        //load the texture.\n        CS_ASSERT(texturePath.empty() == false, \"A texture must be supplied in a Nine-Patch UIDrawable Def.\")\n        \n        auto resPool = Application::Get()->GetResourcePool();\n        if (textureLocation == StorageLocation::k_none)\n        {\n            textureLocation = in_defaultLocation;\n            texturePath = StringUtils::StandardiseDirectoryPath(in_defaultPath) + texturePath;\n        }\n        \n        m_texture = resPool->LoadResource<Texture>(textureLocation, texturePath);\n        CS_ASSERT(m_texture != nullptr, \"Invalid texture supplied in a Nine-Patch UIDrawable Def.\");\n        \n        //try and load the atlas\n        if (atlasPath.empty() == false)\n        {\n            if (atlasLocation == StorageLocation::k_none)\n            {\n                atlasLocation = in_defaultLocation;\n                atlasPath = StringUtils::StandardiseDirectoryPath(in_defaultPath) + atlasPath;\n            }\n            \n            m_atlas = resPool->LoadResource<TextureAtlas>(atlasLocation, atlasPath);\n            CS_ASSERT(m_texture, \"Invalid texture atlas supplied in a Nine-Patch UIDrawable Def.\");\n            CS_ASSERT(m_atlasId.empty() == false, \"A texture atlas Id must be specified when using a texture atlas in a Nine-Patch UIDrawable Def.\");\n        }\n        else\n        {\n            CS_ASSERT(m_atlasId.empty() == true, \"Cannot specify a texture atlas Id without a texture atlas in a Nine-Patch UIDrawable Def.\");\n        }\n    }\n    //--------------------------------------------------------------\n    //--------------------------------------------------------------\n    NinePatchUIDrawableDef::NinePatchUIDrawableDef(const TextureCSPtr& in_texture, const Vector4& in_insets, const Colour& in_colour, const UVs& in_uvs)\n    : m_texture(in_texture), m_insets(in_insets), m_colour(in_colour), m_uvs(in_uvs), m_drawMode(CanvasDrawMode::k_standard)\n    {\n        CS_ASSERT(m_texture != nullptr, \"The texture cannot be null in a Nine-Patch UIDrawable Def.\");\n    }\n    //--------------------------------------------------------------\n    //--------------------------------------------------------------\n    NinePatchUIDrawableDef::NinePatchUIDrawableDef(const TextureCSPtr& in_texture, const TextureAtlasCSPtr& in_atlas, const std::string& in_atlasId, const Vector4& in_insets,\n                                               const Colour& in_colour, const UVs& in_uvs)\n    : m_texture(in_texture), m_atlas(in_atlas), m_atlasId(in_atlasId), m_insets(in_insets), m_colour(in_colour), m_uvs(in_uvs), m_drawMode(CanvasDrawMode::k_standard)\n    {\n        CS_ASSERT(m_texture != nullptr, \"The texture cannot be null in a Nine-Patch UIDrawable Def.\");\n        CS_ASSERT(m_atlas != nullptr, \"Cannot specify a null texture atlas in a Nine-Patch UIDrawable Def. Use the texture only constructor instead.\");\n        CS_ASSERT(m_atlas->HasFrameWithId(m_atlasId) == true, \"Invalid texture atlas Id provided in a Nine-Patch UIDrawable Def.\");\n    }\n    //--------------------------------------------------------------\n    //--------------------------------------------------------------\n    bool NinePatchUIDrawableDef::IsA(InterfaceIDType in_interfaceId) const\n    {\n        return (UIDrawableDef::InterfaceID == in_interfaceId || NinePatchUIDrawableDef::InterfaceID == in_interfaceId);\n    }\n    //--------------------------------------------------------------\n    //--------------------------------------------------------------\n    const TextureCSPtr& NinePatchUIDrawableDef::GetTexture() const\n    {\n        return m_texture;\n    }\n    //--------------------------------------------------------------\n    //--------------------------------------------------------------\n    const TextureAtlasCSPtr& NinePatchUIDrawableDef::GetAtlas() const\n    {\n        return m_atlas;\n    }\n    //--------------------------------------------------------------\n    //--------------------------------------------------------------\n    const std::string& NinePatchUIDrawableDef::GetAtlasId() const\n    {\n        return m_atlasId;\n    }\n    //--------------------------------------------------------------\n    //--------------------------------------------------------------\n    const UVs& NinePatchUIDrawableDef::GetUVs() const\n    {\n        return m_uvs;\n    }\n    //--------------------------------------------------------------\n    //--------------------------------------------------------------\n    const Colour& NinePatchUIDrawableDef::GetColour() const\n    {\n        return m_colour;\n    }\n    //--------------------------------------------------------------\n    //--------------------------------------------------------------\n    const Vector4& NinePatchUIDrawableDef::GetInsets() const\n    {\n        return m_insets;\n    }\n    //--------------------------------------------------------------\n    //--------------------------------------------------------------\n    UIDrawableUPtr NinePatchUIDrawableDef::CreateDrawable() const\n    {\n        NinePatchUIDrawableUPtr drawable;\n        \n        if (m_atlas != nullptr)\n        {\n            drawable = NinePatchUIDrawableUPtr(new NinePatchUIDrawable(m_texture, m_atlas, m_atlasId, m_insets.x, m_insets.y, m_insets.z, m_insets.w));\n        }\n        else\n        {\n            drawable = NinePatchUIDrawableUPtr(new NinePatchUIDrawable(m_texture, m_insets.x, m_insets.y, m_insets.z, m_insets.w));\n        }\n        \n        drawable->SetUVs(m_uvs);\n        drawable->SetColour(m_colour);\n        \n        UIDrawableUPtr output = std::move(drawable);\n        return output;\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/UI/Drawable/NinePatchUIDrawableDef.h",
    "content": "//\n//  NinePatchUIDrawableDef.h\n//  ChilliSource\n//  Created by Ian Copland on 15/12/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_UI_DRAWABLE_NINEPATCHUIDRAWABLEDEF_H_\n#define _CHILLISOURCE_UI_DRAWABLE_NINEPATCHUIDRAWABLEDEF_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Base/Colour.h>\n#include <ChilliSource/Core/Math/Vector4.h>\n#include <ChilliSource/Rendering/Texture/UVs.h>\n#include <ChilliSource/UI/Drawable/UIDrawableDef.h>\n\nnamespace ChilliSource\n{\n    //---------------------------------------------------------------------\n    /// A definition of a Nine-Patch UIDrawable which can be built from a\n    /// json object. This is effectively an immutable container for the\n    /// properties of a Nine-Patch UIDrawable.\n    ///\n    /// A Nine-Patch UIDrawable Def contains the following property in\n    /// addition to those defined in the UIDrawable Def base class\n    /// documentation:\n    ///\n    /// \"Insets\": The insets from the edges of the stretchable portion of\n    /// the image. \n    ///\n    /// @author Ian Copland\n    //---------------------------------------------------------------------\n    class NinePatchUIDrawableDef final : public UIDrawableDef\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(NinePatchUIDrawableDef);\n        //--------------------------------------------------------------\n        /// Constructor. Creates an empty standard drawable definition.\n        ///\n        /// @author Ian Copland\n        //--------------------------------------------------------------\n        NinePatchUIDrawableDef() = default;\n        //--------------------------------------------------------------\n        /// Constructor. Creates a standard drawable definition from\n        /// json.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The JSON object containing the drawable properties.\n        /// @param [Optional] The relative storage location which will\n        /// be used if there is no storage location specified in the\n        /// json. Defaults to package.\n        /// @param [Optional] The directory paths will be relative to if\n        /// there is no storage location specified in the json. Defaults\n        /// to empty.\n        //--------------------------------------------------------------\n        NinePatchUIDrawableDef(const Json::Value& in_json, StorageLocation in_defaultLocation = StorageLocation::k_package, const std::string& in_defaultPath = \"\");\n        //--------------------------------------------------------------\n        /// Constructor. Creates a standard drawable definition from\n        /// with just a texture.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The texture.\n        /// @param The insets.\n        /// @param [Optional] The colour. Defaults to white.\n        /// @param [Optional] The UVs. Defaults to (0, 0, 1, 1)\n        //--------------------------------------------------------------\n        NinePatchUIDrawableDef(const TextureCSPtr& in_texture, const Vector4& in_insets, const Colour& in_colour = Colour::k_white, const UVs& in_uvs = UVs());\n        //--------------------------------------------------------------\n        /// Constructor. Creates a standard drawable definition from\n        /// with a texture atlas.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The texture.\n        /// @param The texture atlas.\n        /// @param The texture atlas id.\n        /// @param The insets.\n        /// @param [Optional] The colour. Defaults to white.\n        /// @param [Optional] The UVs. Defaults to (0, 0, 1, 1)\n        //--------------------------------------------------------------\n        NinePatchUIDrawableDef(const TextureCSPtr& in_texture, const TextureAtlasCSPtr& in_atlas, const std::string& in_atlasId, const Vector4& in_insets,\n                             const Colour& in_colour = Colour::k_white, const UVs& in_uvs = UVs());\n        //--------------------------------------------------------------\n        /// Allows querying of whether or not the component implements\n        /// the interface associated with the given interface Id.\n        /// Typically this won't be called directly, instead the templated\n        /// version IsA<Interface>() should be used.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The interface Id.\n        ///\n        /// @return Whether the object implements the given interface.\n        //--------------------------------------------------------------\n        bool IsA(InterfaceIDType in_interfaceId) const override;\n        //--------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param The texture that will be rendered by the drawable.\n        //--------------------------------------------------------------\n        const TextureCSPtr& GetTexture() const override;\n        //--------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param The texture atlas. If is supplied the drawable will\n        /// render only the portion of the texture described by this and\n        /// the atlas id.\n        //--------------------------------------------------------------\n        const TextureAtlasCSPtr& GetAtlas() const override;\n        //--------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param The Id of the image in the texture atlas. This will\n        /// be empty if there is no texture altas.\n        //--------------------------------------------------------------\n        const std::string& GetAtlasId() const override;\n        //--------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param The UVs of the image within the texture. If a texture\n        /// atlas is used the UVs are virtual and are relative to the\n        /// atlas image.\n        //--------------------------------------------------------------\n        const UVs& GetUVs() const override;\n        //--------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param The colour of the drawable.\n        //--------------------------------------------------------------\n        const Colour& GetColour() const override;\n        //--------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param The insets from the edges of the stretchable portion\n        /// of the image.\n        //--------------------------------------------------------------\n        const Vector4& GetInsets() const;\n        \n        /// @return Draw mode of the drawable\n        ///\n        CanvasDrawMode GetDrawMode() const noexcept override { return m_drawMode; }\n        \n    private:\n        //--------------------------------------------------------------\n        /// Creates a new instance of a standard drawable as described\n        /// by this definition. This should typically only be called by\n        /// a drawable component.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @return a new drawable instance.\n        //--------------------------------------------------------------\n        UIDrawableUPtr CreateDrawable() const override;\n        \n        TextureCSPtr m_texture;\n        TextureAtlasCSPtr m_atlas;\n        std::string m_atlasId;\n        UVs m_uvs;\n        Colour m_colour;\n        Vector4 m_insets;\n        CanvasDrawMode m_drawMode;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/UI/Drawable/StandardUIDrawable.cpp",
    "content": "//\n//  StandardUIDrawable.cpp\n//  ChilliSource\n//  Created by Scott Downie on 17/04/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/UI/Drawable/StandardUIDrawable.h>\n\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/Resource/ResourcePool.h>\n#include <ChilliSource/Core/String/StringParser.h>\n#include <ChilliSource/Rendering/Base/AlignmentAnchors.h>\n#include <ChilliSource/Rendering/Base/CanvasRenderer.h>\n#include <ChilliSource/Rendering/Texture/Texture.h>\n#include <ChilliSource/UI/Drawable/UIDrawableUtils.h>\n\nnamespace ChilliSource\n{\n    namespace\n    {\n        /// When textures are packed into an atlas their alpha space is cropped from the top left. This function\n        /// calculates the positional offset required to restore the alpha space to the box\n        ///\n        /// @param atlasFrame\n        ///     Frame from the atlas that holds info on how much cropping occurred\n        /// @param absSize\n        ///     Canvas space size of the box\n        /// @return Offset from top left required to \"restore\" the cropped alpha\n        ///\n        Vector2 CalculateAlphaRestoreOffset(const TextureAtlas::Frame& atlasFrame, const Vector2& absSize)\n        {\n            //When textures are packed into an atlas their alpha space is cropped. This functionality restores the alpha space by resizing and offsetting the box.\n            Vector2 offsetTL\n            (\n             (-atlasFrame.m_originalSize.x * 0.5f) + (atlasFrame.m_croppedSize.x * 0.5f) + atlasFrame.m_offset.x,\n             (atlasFrame.m_originalSize.y * 0.5f) - (atlasFrame.m_croppedSize.y * 0.5f) - atlasFrame.m_offset.y\n             );\n            offsetTL = absSize/atlasFrame.m_originalSize * offsetTL;\n            \n            return offsetTL;\n        }\n        \n        /// When textures are packed into an atlas their alpha space is cropped from the top left. This function\n        /// calculates the size required to restore the alpha space to the box\n        ///\n        /// @param atlasFrame\n        ///     Frame from the atlas that holds info on how much cropping occurred\n        /// @param absSize\n        ///     Canvas space size of the box\n        /// @return Updated size of the box once the alpha has been \"restored\"\n        ///\n        Vector2 CalculateAlphaRestoreSize(const TextureAtlas::Frame& atlasFrame, const Vector2& absSize)\n        {\n            return absSize/atlasFrame.m_originalSize * atlasFrame.m_croppedSize;\n        }\n    }\n    CS_DEFINE_NAMEDTYPE(StandardUIDrawable);\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    StandardUIDrawable::StandardUIDrawable(const TextureCSPtr& in_texture)\n    {\n        SetTexture(in_texture);\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    StandardUIDrawable::StandardUIDrawable(const TextureCSPtr& in_texture, const TextureAtlasCSPtr& in_atlas, const std::string& in_atlasId)\n    {\n        CS_ASSERT(in_atlas != nullptr, \"The given texture atlas cannot be null.\");\n        CS_ASSERT(in_atlas->HasFrameWithId(in_atlasId) == true, \"The texture atlas id \\\"\" + in_atlasId + \"\\\" must exist in the atlas.\");\n        \n        SetTexture(in_texture);\n        SetTextureAtlas(in_atlas);\n        SetTextureAtlasId(in_atlasId);\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    bool StandardUIDrawable::IsA(InterfaceIDType in_interfaceId) const\n    {\n        return (UIDrawable::InterfaceID == in_interfaceId || StandardUIDrawable::InterfaceID == in_interfaceId);\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    const TextureCSPtr& StandardUIDrawable::GetTexture() const\n    {\n        return m_texture;\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    const TextureAtlasCSPtr& StandardUIDrawable::GetTextureAtlas() const\n    {\n        return m_atlas;\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    const std::string& StandardUIDrawable::GetTextureAtlasId() const\n    {\n        return m_atlasId;\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    const UVs& StandardUIDrawable::GetUVs() const\n    {\n        return m_uvs;\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    const Colour& StandardUIDrawable::GetColour() const\n    {\n        return m_colour;\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    void StandardUIDrawable::SetTexture(const TextureCSPtr& in_texture)\n    {\n        CS_ASSERT(in_texture != nullptr, \"Cannot set a null texture on a drawable.\");\n        \n        m_texture = in_texture;\n        \n        m_atlasFrame = UIDrawableUtils::BuildFrame(m_texture.get(), m_atlas.get(), m_atlasId, m_uvs);\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    void StandardUIDrawable::SetTextureAtlas(const TextureAtlasCSPtr& in_atlas)\n    {\n        m_atlas = in_atlas;\n        m_atlasId = \"\";\n        \n        m_atlasFrame = UIDrawableUtils::BuildFrame(m_texture.get(), m_atlas.get(), m_atlasId, m_uvs);\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    void StandardUIDrawable::SetTextureAtlasId(const std::string& in_atlasId)\n    {\n        CS_ASSERT(m_atlas != nullptr, \"StandardUIDrawable::SetTextureAtlasId: Atlas Id cannot be set without first setting an atlas\");\n        \n        m_atlasId = in_atlasId;\n        \n        m_atlasFrame = UIDrawableUtils::BuildFrame(m_texture.get(), m_atlas.get(), m_atlasId, m_uvs);\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    void StandardUIDrawable::SetUVs(const UVs& in_UVs)\n    {\n        m_uvs = in_UVs;\n        \n        m_atlasFrame = UIDrawableUtils::BuildFrame(m_texture.get(), m_atlas.get(), m_atlasId, m_uvs);\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    void StandardUIDrawable::SetColour(const Colour& in_colour)\n    {\n        m_colour = in_colour;\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    Vector2 StandardUIDrawable::GetPreferredSize() const\n    {\n        return m_atlasFrame.m_originalSize;\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    void StandardUIDrawable::Draw(CanvasRenderer* renderer, const Matrix3& transform, const Vector2& absSize, const Colour& absColour, CanvasDrawMode drawMode) noexcept\n    {\n        CS_ASSERT(m_texture != nullptr, \"StandardUIDrawable cannot draw without texture\");\n\n        renderer->DrawBox(drawMode, transform, CalculateAlphaRestoreSize(m_atlasFrame, absSize), CalculateAlphaRestoreOffset(m_atlasFrame, absSize), m_texture, m_atlasFrame.m_uvs, absColour * m_colour, AlignmentAnchor::k_middleCentre);\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/UI/Drawable/StandardUIDrawable.h",
    "content": "//\n//  StandardUIDrawable.h\n//  ChilliSource\n//  Created by Scott Downie on 17/04/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n\n#ifndef _CHILLISOURCE_UI_DRAWABLE_STANADARDUIDRAWABLE_H_\n#define _CHILLISOURCE_UI_DRAWABLE_STANADARDUIDRAWABLE_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Base/Colour.h>\n#include <ChilliSource/Core/Math/Vector2.h>\n#include <ChilliSource/Rendering/Texture/TextureAtlas.h>\n#include <ChilliSource/Rendering/Texture/UVs.h>\n#include <ChilliSource/UI/Drawable/UIDrawable.h>\n\nnamespace ChilliSource\n{\n    //----------------------------------------------------------------------------------------\n    /// Interface for rendering widget with a texture and UVs.\n    ///\n    /// @author S Downie\n    //----------------------------------------------------------------------------------------\n    class StandardUIDrawable final : public UIDrawable\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(StandardUIDrawable);\n        //----------------------------------------------------------------------------------------\n        /// Allows querying of whether or not the component implements the interface associated\n        /// with the given interface Id. Typically this won't be called directly, instead the\n        /// templated version IsA<Interface>() should be used.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The interface Id.\n        ///\n        /// @return Whether the object implements the given interface.\n        //----------------------------------------------------------------------------------------\n        bool IsA(InterfaceIDType in_interfaceId) const override;\n        //----------------------------------------------------------------------------------------\n        /// Get the texture that is currently used.\n        ///\n        /// @author HMcLaughlin\n        ///\n        /// @return Texture\n        //----------------------------------------------------------------------------------------\n        const TextureCSPtr& GetTexture() const override;\n        //----------------------------------------------------------------------------------------\n        /// Get the texture atlas that is currently used.\n        ///\n        /// @author HMcLaughlin\n        ///\n        /// @return Texture atlas\n        //----------------------------------------------------------------------------------------\n        const TextureAtlasCSPtr& GetTextureAtlas() const override;\n        //----------------------------------------------------------------------------------------\n        /// Get the texture atlas frame Id that is currently used.\n        ///\n        /// @author HMcLaughlin\n        ///\n        /// @return Frame Id\n        //----------------------------------------------------------------------------------------\n        const std::string& GetTextureAtlasId() const override;\n        //----------------------------------------------------------------------------------------\n        /// Get the UVs that are currently used. UVs are relative to the\n        /// frame and not the overall atlas\n        ///\n        /// @author HMcLaughlin\n        ///\n        /// @return Rectangle containing U, V, S, T\n        //----------------------------------------------------------------------------------------\n        const UVs& GetUVs() const override;\n        //----------------------------------------------------------------------------------------\n        /// Gets the colour of the drawable.\n        ///\n        /// @author HMcLaughlin\n        ///\n        /// @param The colour.\n        //----------------------------------------------------------------------------------------\n        const Colour& GetColour() const override;\n        //----------------------------------------------------------------------------------------\n        /// Set the texture that should be used in subsequent draws\n        ///\n        /// @author S Downie\n        ///\n        /// @param Texture\n        //----------------------------------------------------------------------------------------\n        void SetTexture(const TextureCSPtr& in_texture) override;\n        //----------------------------------------------------------------------------------------\n        /// Set the texture atlas that should be used in subsequent draws.\n        ///\n        /// @author S Downie\n        ///\n        /// @param Texture atlas\n        //----------------------------------------------------------------------------------------\n        void SetTextureAtlas(const TextureAtlasCSPtr& in_atlas) override;\n        //----------------------------------------------------------------------------------------\n        /// Set the texture atlas frame Id that should be used in subsequent draws.\n        ///\n        /// NOTE: An atlas must have been set prior to calling this\n        ///\n        /// @author S Downie\n        ///\n        /// @param Frame Id\n        //----------------------------------------------------------------------------------------\n        void SetTextureAtlasId(const std::string& in_atlasId) override;\n        //----------------------------------------------------------------------------------------\n        /// Set the UVs that should be used in subsequent draws. UVs are relative to the\n        /// frame and not the overall atlas\n        ///\n        /// @author S Downie\n        ///\n        /// @param Rectangle containing U, V, S, T\n        //----------------------------------------------------------------------------------------\n        void SetUVs(const UVs& in_UVs) override;\n        //----------------------------------------------------------------------------------------\n        /// Sets the colour of the drawable. The final colour of the drawable takes into account\n        /// the owning widgets colour and this colour.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The colour.\n        //----------------------------------------------------------------------------------------\n        void SetColour(const Colour& in_colour) override;\n        //----------------------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return The preferred size that the drawable wishes to de drawn at based on the\n        /// texture size\n        //----------------------------------------------------------------------------------------\n        Vector2 GetPreferredSize() const override;\n        \n        /// Render the widget using the canvas renderer.\n        ///\n        /// @param renderer\n        ///     Performs the actual drawing to canvas\n        /// @param transform\n        ///     Absolute screen transform\n        /// @param absSize\n        ///     Asbolute screen size\n        /// @param absColour\n        ///     Absolute colour\n        /// @param drawMode\n        ///     Whether to create a clip mask for this drawable or just render it\n        ///\n        void Draw(CanvasRenderer* renderer, const Matrix3& transform, const Vector2& absSize, const Colour& absColour, CanvasDrawMode drawMode) noexcept override;\n        \n    private:\n        friend class StandardUIDrawableDef;\n        //----------------------------------------------------------------------------------------\n        /// Constructor\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The texture.\n        //----------------------------------------------------------------------------------------\n        StandardUIDrawable(const TextureCSPtr& in_texture);\n        //----------------------------------------------------------------------------------------\n        /// Constructor\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The texture.\n        /// @param The texture atlas.\n        /// @param The atlas id.\n        //----------------------------------------------------------------------------------------\n        StandardUIDrawable(const TextureCSPtr& in_texture, const TextureAtlasCSPtr& in_atlas, const std::string& in_atlasId);\n        \n        TextureCSPtr m_texture;\n        TextureAtlasCSPtr m_atlas;\n        TextureAtlas::Frame m_atlasFrame;\n        UVs m_uvs;\n        std::string m_atlasId;\n        Colour m_colour;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/UI/Drawable/StandardUIDrawableDef.cpp",
    "content": "//\n//  StandardUIDrawableDef.cpp\n//  ChilliSource\n//  Created by Ian Copland on 15/12/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/UI/Drawable/StandardUIDrawableDef.h>\n\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/Resource/ResourcePool.h>\n#include <ChilliSource/Core/String/StringParser.h>\n#include <ChilliSource/Rendering/Base/CanvasDrawMode.h>\n#include <ChilliSource/Rendering/Texture/Texture.h>\n#include <ChilliSource/Rendering/Texture/TextureAtlas.h>\n#include <ChilliSource/UI/Drawable/StandardUIDrawable.h>\n\n#include <json/json.h>\n\nnamespace ChilliSource\n{\n    CS_DEFINE_NAMEDTYPE(StandardUIDrawableDef);\n    //--------------------------------------------------------------\n    //--------------------------------------------------------------\n    StandardUIDrawableDef::StandardUIDrawableDef(const Json::Value& in_json, StorageLocation in_defaultLocation, const std::string& in_defaultPath)\n    : m_drawMode(CanvasDrawMode::k_standard)\n    {\n        const char k_typeKey[] = \"Type\";\n        const char k_textureLocationKey[] = \"TextureLocation\";\n        const char k_textureFilePathKey[] = \"TexturePath\";\n        const char k_atlasLocationKey[] = \"AtlasLocation\";\n        const char k_atlasFilePathKey[] = \"AtlasPath\";\n        const char k_atlasIdKey[] = \"AtlasId\";\n        const char k_uvsKey[] = \"UVs\";\n        const char k_colourKey[] = \"Colour\";\n        const char k_drawModeKey[] = \"DrawMode\";\n        \n        CS_ASSERT(in_json.isObject() == true, \"UIDrawable Def must be created from a json value of type Object.\");\n        \n        //read all the properties from JSON.\n        StorageLocation textureLocation = StorageLocation::k_none;\n        StorageLocation atlasLocation = StorageLocation::k_none;\n        std::string texturePath;\n        std::string atlasPath;\n        for(auto it = in_json.begin(); it != in_json.end(); ++it)\n        {\n            CS_ASSERT((*it).isString() == true, \"All properties in a UIDrawable Def must be a string: \" + std::string(it.memberName()));\n            \n            std::string key = it.memberName();\n            std::string value = (*it).asString();\n            \n            if (key == k_textureLocationKey)\n            {\n                textureLocation = ParseStorageLocation(value);\n            }\n            else if (key == k_textureFilePathKey)\n            {\n                texturePath = value;\n            }\n            else if (key == k_atlasLocationKey)\n            {\n                atlasLocation = ParseStorageLocation(value);\n            }\n            else if (key == k_atlasFilePathKey)\n            {\n                atlasPath = value;\n            }\n            else if (key == k_atlasIdKey)\n            {\n                m_atlasId = value;\n            }\n            else if (key == k_uvsKey)\n            {\n                auto vec =  ParseVector4(value);;\n                m_uvs = UVs(vec.x, vec.y, vec.z, vec.w);\n            }\n            else if (key == k_colourKey)\n            {\n                m_colour = ParseColour(value);\n            }\n            else if (key == k_drawModeKey)\n            {\n                m_drawMode = ParseCanvasDrawMode(value);\n            }\n            else if (key == k_typeKey)\n            {\n                //ignore\n            }\n            else\n            {\n                CS_LOG_FATAL(\"Invalid property found in a Standard UIDrawable Def: \" + key);\n            }\n        }\n        \n        //load the texture.\n        CS_ASSERT(texturePath.empty() == false, \"A texture must be supplied in a Standard UIDrawable Def.\")\n        \n        auto resPool = Application::Get()->GetResourcePool();\n        if (textureLocation == StorageLocation::k_none)\n        {\n            textureLocation = in_defaultLocation;\n            texturePath = StringUtils::StandardiseDirectoryPath(in_defaultPath) + texturePath;\n        }\n        \n        m_texture = resPool->LoadResource<Texture>(textureLocation, texturePath);\n        CS_ASSERT(m_texture != nullptr, \"Invalid texture supplied in a Standard UIDrawable Def.\");\n        \n        //try and load the atlas\n        if (atlasPath.empty() == false)\n        {\n            if (atlasLocation == StorageLocation::k_none)\n            {\n                atlasLocation = in_defaultLocation;\n                atlasPath = StringUtils::StandardiseDirectoryPath(in_defaultPath) + atlasPath;\n            }\n            \n            m_atlas = resPool->LoadResource<TextureAtlas>(atlasLocation, atlasPath);\n            CS_ASSERT(m_texture, \"Invalid texture atlas supplied in a Standard UIDrawable Def.\");\n            CS_ASSERT(m_atlasId.empty() == false, \"A texture atlas Id must be specified when using a texture atlas in a Standard UIDrawable Def.\");\n        }\n        else\n        {\n            CS_ASSERT(m_atlasId.empty() == true, \"Cannot specify a texture atlas Id without a texture atlas in a Standard UIDrawable Def.\");\n        }\n    }\n    //--------------------------------------------------------------\n    //--------------------------------------------------------------\n    StandardUIDrawableDef::StandardUIDrawableDef(const TextureCSPtr& in_texture, const Colour& in_colour, const UVs& in_uvs)\n    : m_texture(in_texture), m_colour(in_colour), m_uvs(in_uvs), m_drawMode(CanvasDrawMode::k_standard)\n    {\n        CS_ASSERT(m_texture != nullptr, \"The texture cannot be null in a Standard UIDrawable Def.\");\n    }\n    //--------------------------------------------------------------\n    //--------------------------------------------------------------\n    StandardUIDrawableDef::StandardUIDrawableDef(const TextureCSPtr& in_texture, const TextureAtlasCSPtr& in_atlas, const std::string& in_atlasId, const Colour& in_colour, const UVs& in_uvs)\n    : m_texture(in_texture), m_atlas(in_atlas), m_atlasId(in_atlasId), m_colour(in_colour), m_uvs(in_uvs), m_drawMode(CanvasDrawMode::k_standard)\n    {\n        CS_ASSERT(m_texture != nullptr, \"The texture cannot be null in a Standard UIDrawable Def.\");\n        CS_ASSERT(m_atlas != nullptr, \"Cannot specify a null texture atlas in a Standard UIDrawable Def. Use the texture only constructor instead.\");\n        CS_ASSERT(m_atlas->HasFrameWithId(m_atlasId) == true, \"Invalid texture atlas Id provided in a Standard UIDrawable Def.\");\n    }\n    //--------------------------------------------------------------\n    //--------------------------------------------------------------\n    bool StandardUIDrawableDef::IsA(InterfaceIDType in_interfaceId) const\n    {\n        return (UIDrawableDef::InterfaceID == in_interfaceId || StandardUIDrawableDef::InterfaceID == in_interfaceId);\n    }\n    //--------------------------------------------------------------\n    //--------------------------------------------------------------\n    const TextureCSPtr& StandardUIDrawableDef::GetTexture() const\n    {\n        return m_texture;\n    }\n    //--------------------------------------------------------------\n    //--------------------------------------------------------------\n    const TextureAtlasCSPtr& StandardUIDrawableDef::GetAtlas() const\n    {\n        return m_atlas;\n    }\n    //--------------------------------------------------------------\n    //--------------------------------------------------------------\n    const std::string& StandardUIDrawableDef::GetAtlasId() const\n    {\n        return m_atlasId;\n    }\n    //--------------------------------------------------------------\n    //--------------------------------------------------------------\n    const UVs& StandardUIDrawableDef::GetUVs() const\n    {\n        return m_uvs;\n    }\n    //--------------------------------------------------------------\n    //--------------------------------------------------------------\n    const Colour& StandardUIDrawableDef::GetColour() const\n    {\n        return m_colour;\n    }\n    //--------------------------------------------------------------\n    //--------------------------------------------------------------\n    UIDrawableUPtr StandardUIDrawableDef::CreateDrawable() const\n    {\n        StandardUIDrawableUPtr drawable;\n        \n        if (m_atlas != nullptr)\n        {\n            drawable = StandardUIDrawableUPtr(new StandardUIDrawable(m_texture, m_atlas, m_atlasId));\n        }\n        else\n        {\n            drawable = StandardUIDrawableUPtr(new StandardUIDrawable(m_texture));\n        }\n        \n        drawable->SetUVs(m_uvs);\n        drawable->SetColour(m_colour);\n\n        UIDrawableUPtr output = std::move(drawable);\n        return output;\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/UI/Drawable/StandardUIDrawableDef.h",
    "content": "//\n//  StandardUIDrawableDef.h\n//  ChilliSource\n//  Created by Ian Copland on 15/12/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_UI_DRAWABLE_STANDARDUIDRAWABLEDEF_H_\n#define _CHILLISOURCE_UI_DRAWABLE_STANDARDUIDRAWABLEDEF_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Base/Colour.h>\n#include <ChilliSource/Rendering/Texture/UVs.h>\n#include <ChilliSource/UI/Drawable/UIDrawableDef.h>\n\nnamespace ChilliSource\n{\n    //---------------------------------------------------------------------\n    /// A definition of a Standard UIDrawable which can be built from a json\n    /// object. This is effectively an immutable container for the\n    /// properties of a Standard UIDrawable.\n    ///\n    /// A standard drawable def doesn't contain any additional properties\n    /// over those described in the UIDrawable Def base class documentation.\n    ///\n    /// @author Ian Copland\n    //---------------------------------------------------------------------\n    class StandardUIDrawableDef final : public UIDrawableDef\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(StandardUIDrawableDef);\n        //--------------------------------------------------------------\n        /// Constructor. Creates an empty standard drawable definition.\n        ///\n        /// @author Ian Copland\n        //--------------------------------------------------------------\n        StandardUIDrawableDef() = default;\n        //--------------------------------------------------------------\n        /// Constructor. Creates a standard drawable definition from\n        /// json.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The JSON object containing the drawable properties.\n        /// @param [Optional] The relative storage location which will\n        /// be used if there is no storage location specified in the\n        /// json. Defaults to package.\n        /// @param [Optional] The directory paths will be relative to if\n        /// there is no storage location specified in the json. Defaults\n        /// to empty.\n        //--------------------------------------------------------------\n        StandardUIDrawableDef(const Json::Value& in_json, StorageLocation in_defaultLocation = StorageLocation::k_package, const std::string& in_defaultPath = \"\");\n        //--------------------------------------------------------------\n        /// Constructor. Creates a standard drawable definition from\n        /// with just a texture.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The texture.\n        /// @param [Optional] The colour. Defaults to white.\n        /// @param [Optional] The UVs. Defaults to (0, 0, 1, 1)\n        //--------------------------------------------------------------\n        StandardUIDrawableDef(const TextureCSPtr& in_texture, const Colour& in_colour = Colour::k_white, const UVs& in_uvs = UVs());\n        //--------------------------------------------------------------\n        /// Constructor. Creates a standard drawable definition from\n        /// with a texture atlas.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The texture.\n        /// @param The texture atlas.\n        /// @param The texture atlas id.\n        /// @param [Optional] The colour. Defaults to white.\n        /// @param [Optional] The UVs. Defaults to (0, 0, 1, 1)\n        //--------------------------------------------------------------\n        StandardUIDrawableDef(const TextureCSPtr& in_texture, const TextureAtlasCSPtr& in_atlas, const std::string& in_atlasId, const Colour& in_colour = Colour::k_white,\n                            const UVs& in_uvs = UVs());\n        //--------------------------------------------------------------\n        /// Allows querying of whether or not the component implements\n        /// the interface associated with the given interface Id.\n        /// Typically this won't be called directly, instead the\n        /// templated version IsA<Interface>() should be used.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The interface Id.\n        ///\n        /// @return Whether the object implements the given interface.\n        //--------------------------------------------------------------\n        bool IsA(InterfaceIDType in_interfaceId) const override;\n        //--------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param The texture that will be rendered by the drawable.\n        //--------------------------------------------------------------\n        const TextureCSPtr& GetTexture() const override;\n        //--------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param The texture atlas. If is supplied the drawable will\n        /// render only the portion of the texture described by this and\n        /// the atlas id.\n        //--------------------------------------------------------------\n        const TextureAtlasCSPtr& GetAtlas() const override;\n        //--------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param The Id of the image in the texture atlas. This will\n        /// be empty if there is no texture altas.\n        //--------------------------------------------------------------\n        const std::string& GetAtlasId() const override;\n        //--------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param The UVs of the image within the texture. If a texture\n        /// atlas is used the UVs are virtual and are relative to the\n        /// atlas image.\n        //--------------------------------------------------------------\n        const UVs& GetUVs() const override;\n        //--------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param The colour of the drawable.\n        //--------------------------------------------------------------\n        const Colour& GetColour() const override;\n        \n        /// @return Draw mode of the drawable\n        ///\n        CanvasDrawMode GetDrawMode() const noexcept override { return m_drawMode; }\n        \n    private:\n        //--------------------------------------------------------------\n        /// Creates a new instance of a standard drawable as described\n        /// by this definition. This should typically only be called by\n        /// a drawable component.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @return a new drawable instance.\n        //--------------------------------------------------------------\n        UIDrawableUPtr CreateDrawable() const override;\n        \n        TextureCSPtr m_texture;\n        TextureAtlasCSPtr m_atlas;\n        std::string m_atlasId;\n        UVs m_uvs;\n        Colour m_colour;\n        CanvasDrawMode m_drawMode;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/UI/Drawable/ThreePatchUIDrawable.cpp",
    "content": "//\n//  ThreePatchUIDrawable.cpp\n//  ChilliSource\n//  Created by Scott Downie on 24/07/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/UI/Drawable/ThreePatchUIDrawable.h>\n\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/Math/MathUtils.h>\n#include <ChilliSource/Core/Resource/ResourcePool.h>\n#include <ChilliSource/Core/String/StringParser.h>\n#include <ChilliSource/Rendering/Base/AlignmentAnchors.h>\n#include <ChilliSource/Rendering/Base/AspectRatioUtils.h>\n#include <ChilliSource/Rendering/Base/CanvasRenderer.h>\n#include <ChilliSource/Rendering/Texture/Texture.h>\n#include <ChilliSource/UI/Drawable/UIDrawableUtils.h>\n\nnamespace ChilliSource\n{\n    namespace\n    {\n        //----------------------------------------------------------------------------------------\n        /// Identifier for each patch in the 3 patch. Can be used as index look-ups into\n        /// arrays of UVs, positions, etc.\n        ///\n        /// @author S Downie\n        //----------------------------------------------------------------------------------------\n        enum class Patch\n        {\n            k_leftOrBottom,\n            k_centre,\n            k_rightOrTop\n        };\n        //----------------------------------------------------------------------------------------\n        /// Based on the insets and the given UVs calculate the UVs for each of the 3 patches\n        ///\n        /// @author S Downie\n        ///\n        /// @param UVs\n        /// @param Image frame\n        /// @param Left inset as normalised percentage\n        /// @param Right inset as normalised percentage\n        ///\n        /// @return UVs for the 3 patches\n        //----------------------------------------------------------------------------------------\n        std::array<UVs, ThreePatchUIDrawable::k_numPatches> CalculateThreePatchUVsHorizontal(const TextureAtlas::Frame& in_frame, f32 in_left, f32 in_right)\n        {\n            std::array<UVs, ThreePatchUIDrawable::k_numPatches> result;\n            \n            f32 uvWidth = (in_frame.m_originalSize.x/in_frame.m_croppedSize.x) * in_frame.m_uvs.m_s;\n            \n            f32 leftU = in_frame.m_uvs.m_u - uvWidth + in_frame.m_uvs.m_s;\n            f32 middleU = leftU + (uvWidth * in_left);\n            f32 rightU = middleU + (uvWidth * (1.0f - in_right - in_left));\n            \n            f32 leftUS = middleU;\n            f32 middleUS = rightU;\n            f32 rightUS = leftU + uvWidth;\n            \n            f32 uvHeight = (in_frame.m_originalSize.y/in_frame.m_croppedSize.y) * in_frame.m_uvs.m_t;\n            \n            f32 V = in_frame.m_uvs.m_v - uvHeight + in_frame.m_uvs.m_t;\n            f32 VT = V + uvHeight;\n            \n            leftU = std::max(leftU, in_frame.m_uvs.m_u);\n            middleU = std::max(middleU, in_frame.m_uvs.m_u);\n            rightU = std::max(rightU, in_frame.m_uvs.m_u);\n            \n            V = std::max(V, in_frame.m_uvs.m_v);\n            \n            leftUS = std::min(leftUS, in_frame.m_uvs.m_u + in_frame.m_uvs.m_s);\n            middleUS = std::min(middleUS, in_frame.m_uvs.m_u + in_frame.m_uvs.m_s);\n            rightUS = std::min(rightUS, in_frame.m_uvs.m_u + in_frame.m_uvs.m_s);\n            \n            VT = std::min(VT, in_frame.m_uvs.m_v + in_frame.m_uvs.m_t);\n            \n            f32 leftS = leftUS - leftU;\n            f32 middleS = middleUS - middleU;\n            f32 rightS = rightUS - rightU;\n            \n            f32 T = VT - V;\n            \n            result[(u32)Patch::k_leftOrBottom].m_u = leftU;\n            result[(u32)Patch::k_leftOrBottom].m_s = leftS;\n            \n            result[(u32)Patch::k_centre].m_u = middleU;\n            result[(u32)Patch::k_centre].m_s = middleS;\n            \n            result[(u32)Patch::k_rightOrTop].m_u = rightU;\n            result[(u32)Patch::k_rightOrTop].m_s = rightS;\n            \n            result[(u32)Patch::k_rightOrTop].m_v = V;\n            result[(u32)Patch::k_rightOrTop].m_t = T;\n            \n            result[(u32)Patch::k_centre].m_v = V;\n            result[(u32)Patch::k_centre].m_t = T;\n            \n            result[(u32)Patch::k_leftOrBottom].m_v = V;\n            result[(u32)Patch::k_leftOrBottom].m_t = T;\n            \n            return result;\n        }\n        //----------------------------------------------------------------------------------------\n        /// Based on the insets and the given UVs calculate the UVs for each of the 3 patches\n        ///\n        /// @author S Downie\n        ///\n        /// @param Image frame\n        /// @param Bottom inset as normalised percentage\n        /// @param Top inset as normalised percentage\n        ///\n        /// @return UVs for the 3 patches\n        //----------------------------------------------------------------------------------------\n        std::array<UVs, ThreePatchUIDrawable::k_numPatches> CalculateThreePatchUVsVertical(const TextureAtlas::Frame& in_frame, f32 in_bottom, f32 in_top)\n        {\n            std::array<UVs, ThreePatchUIDrawable::k_numPatches> result;\n            \n            f32 uvWidth = (in_frame.m_originalSize.x/in_frame.m_croppedSize.x) * in_frame.m_uvs.m_s;\n            \n            f32 U = in_frame.m_uvs.m_u - uvWidth + in_frame.m_uvs.m_s;\n            f32 US = U + uvWidth;\n            \n            f32 uvHeight = (in_frame.m_originalSize.y/in_frame.m_croppedSize.y) * in_frame.m_uvs.m_t;\n            \n            f32 topV = in_frame.m_uvs.m_v - uvHeight + in_frame.m_uvs.m_t;\n            f32 middleV = topV + (uvHeight * in_top);\n            f32 bottomV = middleV + (uvHeight * (1.0f - in_top - in_bottom));\n            \n            f32 topVT = middleV;\n            f32 middleVT = bottomV;\n            f32 bottomVT = topV + uvHeight;\n            \n            U = std::max(U, in_frame.m_uvs.m_u);\n            \n            topV = std::max(topV, in_frame.m_uvs.m_v);\n            middleV = std::max(middleV, in_frame.m_uvs.m_v);\n            bottomV = std::max(bottomV, in_frame.m_uvs.m_v);\n            \n            US = std::min(US, in_frame.m_uvs.m_u + in_frame.m_uvs.m_s);\n            \n            topVT = std::min(topVT, in_frame.m_uvs.m_v + in_frame.m_uvs.m_t);\n            middleVT = std::min(middleVT, in_frame.m_uvs.m_v + in_frame.m_uvs.m_t);\n            bottomVT = std::min(bottomVT, in_frame.m_uvs.m_v + in_frame.m_uvs.m_t);\n            \n            f32 S = US - U;\n            \n            f32 topT = topVT - topV;\n            f32 middleT = middleVT - middleV;\n            f32 bottomT = bottomVT - bottomV;\n            \n            result[(u32)Patch::k_leftOrBottom].m_u = U;\n            result[(u32)Patch::k_leftOrBottom].m_s = S;\n            \n            result[(u32)Patch::k_centre].m_u = U;\n            result[(u32)Patch::k_centre].m_s = S;\n            \n            result[(u32)Patch::k_rightOrTop].m_u = U;\n            result[(u32)Patch::k_rightOrTop].m_s = S;\n            \n            result[(u32)Patch::k_rightOrTop].m_v = topV;\n            result[(u32)Patch::k_rightOrTop].m_t = topT;\n            \n            result[(u32)Patch::k_centre].m_v = middleV;\n            result[(u32)Patch::k_centre].m_t = middleT;\n            \n            result[(u32)Patch::k_leftOrBottom].m_v = bottomV;\n            result[(u32)Patch::k_leftOrBottom].m_t = bottomT;\n            \n            return result;\n        }\n        //----------------------------------------------------------------------------------------\n        /// Based on the widget size and the given insets calculate the absolute size of each patch\n        ///\n        /// @author S Downie\n        ///\n        /// @param Widget absolute size\n        /// @param Image absolute actual size\n        /// @param Image absolute preferred size\n        /// @param Image offset from top left\n        /// @param Left inset as normalised percentage\n        /// @param Right inset as normalised percentage\n        ///\n        /// @return Sizes for the 3 patches\n        //----------------------------------------------------------------------------------------\n        std::array<Vector2, ThreePatchUIDrawable::k_numPatches> CalculateThreePatchSizesHorizontal(const Vector2& in_widgetSize, const TextureAtlas::Frame& in_frame, f32 in_left, f32 in_right)\n        {\n            std::array<Vector2, ThreePatchUIDrawable::k_numPatches> result;\n            \n            f32 height = in_widgetSize.y/in_frame.m_originalSize.y * in_frame.m_croppedSize.y;\n            Vector2 widgetSizeAspectMaintained = AspectRatioUtils::KeepOriginalHeightAdaptWidth(Vector2(in_frame.m_originalSize.x, height), in_frame.m_originalSize.x/in_frame.m_originalSize.y);\n            \n            f32 widthImageLeft = in_frame.m_originalSize.x * in_left;\n            f32 widthVisibleLeft = MathUtils::Clamp(-in_frame.m_offset.x + widthImageLeft, 0.0f, in_frame.m_croppedSize.x);\n\n            f32 offsetRight = -(in_frame.m_originalSize.x - (in_frame.m_offset.x + in_frame.m_croppedSize.x));\n            f32 widthImageRight = in_frame.m_originalSize.x * in_right;\n            f32 widthVisibleRight = MathUtils::Clamp(offsetRight + widthImageRight, 0.0f, in_frame.m_croppedSize.x);\n            \n            f32 widthImageCentre = in_frame.m_originalSize.x * (1.0f - in_right - in_left);\n            f32 widthVisibleCentre = MathUtils::Clamp(widthImageCentre - (in_frame.m_offset.x + widthVisibleLeft - widthImageLeft), 0.0f, in_frame.m_croppedSize.x);\n            f32 widthStretched = in_widgetSize.x - widthVisibleLeft - widthVisibleRight;\n            f32 widthWidgetCentre = widthVisibleCentre * (widthStretched/widthImageCentre);\n            \n            result[(u32)Patch::k_leftOrBottom].x = widthVisibleLeft;\n            result[(u32)Patch::k_leftOrBottom].y = widgetSizeAspectMaintained.y;\n            result[(u32)Patch::k_centre].x = widthWidgetCentre;\n            result[(u32)Patch::k_centre].y = widgetSizeAspectMaintained.y;\n            result[(u32)Patch::k_rightOrTop].x = widthVisibleRight;\n            result[(u32)Patch::k_rightOrTop].y = widgetSizeAspectMaintained.y;\n            \n            return result;\n        }\n        //----------------------------------------------------------------------------------------\n        /// Based on the widget size and the given insets calculate the absolute size of each patch\n        ///\n        /// @author S Downie\n        ///\n        /// @param Widget absolute size\n        /// @param Image absolute actual size\n        /// @param Image absolute preferred size\n        /// @param Image offset from top left\n        /// @param Bottom inset as normalised percentage\n        /// @param Top inset as normalised percentage\n        ///\n        /// @return Sizes for the 3 patches\n        //----------------------------------------------------------------------------------------\n        std::array<Vector2, ThreePatchUIDrawable::k_numPatches> CalculateThreePatchSizesVertical(const Vector2& in_widgetSize, const TextureAtlas::Frame& in_frame, f32 in_bottom, f32 in_top)\n        {\n            std::array<Vector2, ThreePatchUIDrawable::k_numPatches> result;\n            \n            f32 width = in_widgetSize.x/in_frame.m_originalSize.x * in_frame.m_croppedSize.x;\n            Vector2 widgetSizeAspectMaintained = AspectRatioUtils::KeepOriginalWidthAdaptHeight(Vector2(width, in_frame.m_originalSize.y), in_frame.m_originalSize.x/in_frame.m_originalSize.y);\n            \n            f32 heightImageTop = in_frame.m_originalSize.y * in_top;\n            f32 heightVisibleTop = MathUtils::Clamp(-in_frame.m_offset.y + heightImageTop, 0.0f, in_frame.m_croppedSize.y);\n            \n            f32 offsetBottom = -(in_frame.m_originalSize.y - (in_frame.m_offset.y + in_frame.m_croppedSize.y));\n            f32 heightImageBottom = in_frame.m_originalSize.y * in_bottom;\n            f32 heightVisibleBottom = MathUtils::Clamp(offsetBottom + heightImageBottom, 0.0f, in_frame.m_croppedSize.y);\n            \n            f32 heightImageCentre = in_frame.m_originalSize.y * (1.0f - in_bottom - in_top);\n            f32 heightVisibleCentre = MathUtils::Clamp(heightImageCentre - (in_frame.m_offset.y + heightVisibleTop - heightImageTop), 0.0f, in_frame.m_croppedSize.y);\n            f32 heightStretched = in_widgetSize.y - heightVisibleTop - heightVisibleBottom;\n            f32 heightWidgetCentre = heightVisibleCentre * (heightStretched/heightImageCentre);\n            \n            result[(u32)Patch::k_rightOrTop].y = heightVisibleTop;\n            result[(u32)Patch::k_rightOrTop].x = widgetSizeAspectMaintained.x;\n            result[(u32)Patch::k_centre].y = heightWidgetCentre;\n            result[(u32)Patch::k_centre].x = widgetSizeAspectMaintained.x;\n            result[(u32)Patch::k_leftOrBottom].y = heightVisibleBottom;\n            result[(u32)Patch::k_leftOrBottom].x = widgetSizeAspectMaintained.x;\n            \n            return result;\n        }\n        //----------------------------------------------------------------------------------------\n        /// Calculate the local space positions for each patch with the origin of the overall\n        /// widget at the top left\n        ///\n        /// @author S Downie\n        ///\n        /// @param Widget size\n        /// @param Patch sizes\n        ///\n        /// @return Sizes for the 3 patches\n        //----------------------------------------------------------------------------------------\n        std::array<Vector2, ThreePatchUIDrawable::k_numPatches> CalculateThreePatchPositionsHorizontal(const Vector2& in_widgetSize, const std::array<Vector2, ThreePatchUIDrawable::k_numPatches>& in_sizes)\n        {\n            std::array<Vector2, ThreePatchUIDrawable::k_numPatches> result;\n            \n            Vector2 halfWidgetSize = in_widgetSize * 0.5f;\n            Vector2 halfLeft = in_sizes[(u32)Patch::k_leftOrBottom] * 0.5f;\n            Vector2 halfMiddle = in_sizes[(u32)Patch::k_centre] * 0.5f;\n            Vector2 halfRight = in_sizes[(u32)Patch::k_rightOrTop] * 0.5f;\n            \n            result[(u32)Patch::k_leftOrBottom].x = -halfWidgetSize.x + halfLeft.x;\n            result[(u32)Patch::k_leftOrBottom].y = halfWidgetSize.y - halfLeft.y;\n            \n            result[(u32)Patch::k_centre].x = result[(u32)Patch::k_leftOrBottom].x + halfLeft.x + halfMiddle.x;\n            result[(u32)Patch::k_centre].y = halfWidgetSize.y - halfMiddle.y;\n            \n            result[(u32)Patch::k_rightOrTop].x = result[(u32)Patch::k_centre].x + halfMiddle.x + halfRight.x;\n            result[(u32)Patch::k_rightOrTop].y = halfWidgetSize.y - halfRight.y;\n            \n            return result;\n        }\n        //----------------------------------------------------------------------------------------\n        /// Calculate the local space positions for each patch with the origin of the overall\n        /// widget at the top left\n        ///\n        /// @author S Downie\n        ///\n        /// @param Widget size\n        /// @param Patch sizes\n        ///\n        /// @return Sizes for the 3 patches\n        //----------------------------------------------------------------------------------------\n        std::array<Vector2, ThreePatchUIDrawable::k_numPatches> CalculateThreePatchPositionsVertical(const Vector2& in_widgetSize, const std::array<Vector2, ThreePatchUIDrawable::k_numPatches>& in_sizes)\n        {\n            std::array<Vector2, ThreePatchUIDrawable::k_numPatches> result;\n            \n            Vector2 halfWidgetSize = in_widgetSize * 0.5f;\n            Vector2 halfTop = in_sizes[(u32)Patch::k_rightOrTop] * 0.5f;\n            Vector2 halfMiddle = in_sizes[(u32)Patch::k_centre] * 0.5f;\n            Vector2 halfBottom = in_sizes[(u32)Patch::k_leftOrBottom] * 0.5f;\n            \n            result[(u32)Patch::k_rightOrTop].x = -halfWidgetSize.x + halfTop.x;\n            result[(u32)Patch::k_rightOrTop].y = halfWidgetSize.y - halfTop.y;\n            \n            result[(u32)Patch::k_centre].x = -halfWidgetSize.x + halfMiddle.x;\n            result[(u32)Patch::k_centre].y = result[(u32)Patch::k_rightOrTop].y - halfTop.y - halfMiddle.y;\n            \n            result[(u32)Patch::k_leftOrBottom].x = -halfWidgetSize.x + halfBottom.x;\n            result[(u32)Patch::k_leftOrBottom].y = result[(u32)Patch::k_centre].y - halfMiddle.y - halfBottom.y;\n            \n            return result;\n        }\n        //----------------------------------------------------------------------------------------\n        /// Calculate the offset for the patches that will position them as if they still had\n        /// their cropped space\n        ///\n        /// @author S Downie\n        ///\n        /// @param Widget absolute size\n        /// @param Image frame\n        /// @param Left inset as normalised percentage\n        /// @param Right inset as normalised percentage\n        ///\n        /// @return Offset from top left\n        //----------------------------------------------------------------------------------------\n        Vector2 CalculateThreePatchOffsetHorizontal(const Vector2& in_widgetSize, const TextureAtlas::Frame& in_frame, f32 in_left, f32 in_right)\n        {\n            Vector2 result;\n            \n            f32 leftImageEnd = in_frame.m_originalSize.x * in_left;\n            f32 leftImageWidth = leftImageEnd;\n            f32 rightImageWidth = in_frame.m_originalSize.x * in_right;\n            f32 centreImageEnd = in_frame.m_originalSize.x * (1.0f - in_right);\n            \n            //Left patch\n            f32 offsetLeftImage = std::min(in_frame.m_offset.x, leftImageWidth);\n            result.x += offsetLeftImage;\n            \n            if(in_frame.m_offset.x > leftImageEnd)\n            {\n                //Centre patch\n                f32 centreWidgetWidthStretched = in_widgetSize.x - leftImageWidth - rightImageWidth;\n                f32 centreImageWidth = centreImageEnd - leftImageEnd;\n                f32 centreOffset = std::min(in_frame.m_offset.x - leftImageWidth, centreImageWidth);\n                f32 centreOffsetWidget = (centreOffset/centreImageWidth) * centreWidgetWidthStretched;\n                \n                result.x += std::min(centreOffsetWidget, centreWidgetWidthStretched);\n            }\n            if(in_frame.m_offset.x > centreImageEnd)\n            {\n                //Right patch\n                f32 rightOffsetImage = in_frame.m_offset.x - centreImageEnd;\n                result.x += rightOffsetImage;\n            }\n            \n            result.y = -(in_frame.m_offset.y/in_frame.m_originalSize.y) * in_widgetSize.y;\n            \n            return result;\n        }\n        //----------------------------------------------------------------------------------------\n        /// Calculate the offset for the patches that will position them as if they still had\n        /// their cropped space\n        ///\n        /// @author S Downie\n        ///\n        /// @param Widget absolute size\n        /// @param Image frame\n        /// @param Top inset as normalised percentage\n        /// @param Bottom inset as normalised percentage\n        ///\n        /// @return Offset from top left\n        //----------------------------------------------------------------------------------------\n        Vector2 CalculateThreePatchOffsetVertical(const Vector2& in_widgetSize, const TextureAtlas::Frame& in_frame, f32 in_top, f32 in_bottom)\n        {\n            Vector2 result;\n            \n            result.x = (in_frame.m_offset.x/in_frame.m_originalSize.x) * in_widgetSize.x;\n            \n            f32 topImageEnd = in_frame.m_originalSize.y * in_top;\n            f32 topImageHeight = topImageEnd;\n            f32 bottomImageHeight = in_frame.m_originalSize.y * in_bottom;\n            f32 middleImageEnd = in_frame.m_originalSize.y * (1.0f - in_bottom);\n            \n            //Top patch\n            f32 offsetTopImage = std::min(in_frame.m_offset.y, topImageHeight);\n            result.y -= offsetTopImage;\n            \n            if(in_frame.m_offset.y > topImageEnd)\n            {\n                //Middle patch\n                f32 centreWidgetHeightStretched = in_widgetSize.y - topImageHeight - bottomImageHeight;\n                f32 centreImageHeight = middleImageEnd - topImageEnd;\n                f32 centreOffset = std::min(in_frame.m_offset.y - topImageHeight, centreImageHeight);\n                f32 centreOffsetWidget = (centreOffset/centreImageHeight) * centreWidgetHeightStretched;\n                \n                result.y -= std::min(centreOffsetWidget, centreWidgetHeightStretched);\n            }\n            if(in_frame.m_offset.y > middleImageEnd)\n            {\n                //Bottom patch\n                f32 bottomOffsetImage = in_frame.m_offset.y - middleImageEnd;\n                result.y -= bottomOffsetImage;\n            }\n            \n            return result;\n        }\n    }\n    \n    CS_DEFINE_NAMEDTYPE(ThreePatchUIDrawable);\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    ThreePatchUIDrawable::ThreePatchUIDrawable(const TextureCSPtr& in_texture, Direction in_direction, f32 in_leftOrBottom, f32 in_rightOrTop)\n    {\n        switch (in_direction)\n        {\n            case Direction::k_horizontal:\n                m_uvCalculationDelegate = CalculateThreePatchUVsHorizontal;\n                m_sizeCalculationDelegate = CalculateThreePatchSizesHorizontal;\n                m_positionCalculationDelegate = CalculateThreePatchPositionsHorizontal;\n                m_offsetCalculationDelegate = CalculateThreePatchOffsetHorizontal;\n                break;\n            case Direction::k_vertical:\n                m_uvCalculationDelegate = CalculateThreePatchUVsVertical;\n                m_sizeCalculationDelegate = CalculateThreePatchSizesVertical;\n                m_positionCalculationDelegate = CalculateThreePatchPositionsVertical;\n                m_offsetCalculationDelegate = CalculateThreePatchOffsetVertical;\n                break;\n        }\n        \n        SetTexture(in_texture);\n        SetInsets(in_leftOrBottom, in_rightOrTop);\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    ThreePatchUIDrawable::ThreePatchUIDrawable(const TextureCSPtr& in_texture, const TextureAtlasCSPtr& in_atlas, const std::string& in_atlasId, Direction in_direction,\n                                           f32 in_leftOrBottom, f32 in_rightOrTop)\n    {\n        CS_ASSERT(in_atlas != nullptr, \"The given texture atlas cannot be null.\");\n        CS_ASSERT(in_atlas->HasFrameWithId(in_atlasId) == true, \"The given atlas Id must exist in the texture atlas.\");\n        \n        switch (in_direction)\n        {\n            case Direction::k_horizontal:\n                m_uvCalculationDelegate = CalculateThreePatchUVsHorizontal;\n                m_sizeCalculationDelegate = CalculateThreePatchSizesHorizontal;\n                m_positionCalculationDelegate = CalculateThreePatchPositionsHorizontal;\n                m_offsetCalculationDelegate = CalculateThreePatchOffsetHorizontal;\n                break;\n            case Direction::k_vertical:\n                m_uvCalculationDelegate = CalculateThreePatchUVsVertical;\n                m_sizeCalculationDelegate = CalculateThreePatchSizesVertical;\n                m_positionCalculationDelegate = CalculateThreePatchPositionsVertical;\n                m_offsetCalculationDelegate = CalculateThreePatchOffsetVertical;\n                break;\n        }\n        \n        SetTexture(in_texture);\n        SetTextureAtlas(in_atlas);\n        SetTextureAtlasId(in_atlasId);\n        SetInsets(in_leftOrBottom, in_rightOrTop);\n    }\n    \n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    bool ThreePatchUIDrawable::IsA(InterfaceIDType in_interfaceId) const\n    {\n        return (UIDrawable::InterfaceID == in_interfaceId || ThreePatchUIDrawable::InterfaceID == in_interfaceId);\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    const TextureCSPtr& ThreePatchUIDrawable::GetTexture() const\n    {\n        return m_texture;\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    const TextureAtlasCSPtr& ThreePatchUIDrawable::GetTextureAtlas() const\n    {\n        return m_atlas;\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    const std::string& ThreePatchUIDrawable::GetTextureAtlasId() const\n    {\n        return m_atlasId;\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    const UVs& ThreePatchUIDrawable::GetUVs() const\n    {\n        return m_uvs;\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    const Colour& ThreePatchUIDrawable::GetColour() const\n    {\n        return m_colour;\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    void ThreePatchUIDrawable::SetTexture(const TextureCSPtr& in_texture)\n    {\n        CS_ASSERT(in_texture != nullptr, \"Cannot set a null texture on a drawable.\");\n        \n        m_texture = in_texture;\n        \n        m_atlasFrame = UIDrawableUtils::BuildFrame(m_texture.get(), m_atlas.get(), m_atlasId, m_uvs);\n        m_isPatchCatchValid = false;\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    void ThreePatchUIDrawable::SetTextureAtlas(const TextureAtlasCSPtr& in_atlas)\n    {\n        m_atlas = in_atlas;\n        m_atlasId = \"\";\n        \n        m_atlasFrame = UIDrawableUtils::BuildFrame(m_texture.get(), m_atlas.get(), m_atlasId, m_uvs);\n        m_isPatchCatchValid = false;\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    void ThreePatchUIDrawable::SetTextureAtlasId(const std::string& in_atlasId)\n    {\n        CS_ASSERT(m_atlas != nullptr, \"ThreePatchUIDrawable::SetTextureAtlasId: Atlas Id cannot be set without first setting an atlas\");\n        \n        m_atlasId = in_atlasId;\n        \n        m_atlasFrame = UIDrawableUtils::BuildFrame(m_texture.get(), m_atlas.get(), m_atlasId, m_uvs);\n        m_isPatchCatchValid = false;\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    void ThreePatchUIDrawable::SetUVs(const UVs& in_UVs)\n    {\n        m_uvs = in_UVs;\n        \n        m_atlasFrame = UIDrawableUtils::BuildFrame(m_texture.get(), m_atlas.get(), m_atlasId, m_uvs);\n        m_isPatchCatchValid = false;\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    void ThreePatchUIDrawable::SetColour(const Colour& in_colour)\n    {\n        m_colour = in_colour;\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    void ThreePatchUIDrawable::SetInsets(f32 in_leftOrBottom, f32 in_rightOrTop)\n    {\n        CS_ASSERT(in_leftOrBottom > 0.0f && in_rightOrTop > 0.0f, \"Insets must be greater than 0\");\n        CS_ASSERT(in_leftOrBottom + in_rightOrTop <= 1.0f, \"Insets must not overlap i.e. sum to more than 1\");\n        \n        m_leftOrBottomInset = in_leftOrBottom;\n        m_rightOrTopInset = in_rightOrTop;\n        \n        m_isPatchCatchValid = false;\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    Vector2 ThreePatchUIDrawable::GetPreferredSize() const\n    {\n        return m_atlasFrame.m_originalSize;\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    void ThreePatchUIDrawable::UpdatePatchCache(const Vector2& absSize)\n    {\n        if(m_cachedWidgetSize != absSize)\n        {\n            m_isPatchCatchValid = false;\n            m_cachedWidgetSize = absSize;\n        }\n        \n        if(m_isPatchCatchValid == false)\n        {\n            //When textures are packed into an atlas their alpha space is cropped. This functionality restores the alpha space by resizing and offsetting the patches.\n            m_cachedUvs = m_uvCalculationDelegate(m_atlasFrame, m_leftOrBottomInset, m_rightOrTopInset);\n            m_cachedSizes = m_sizeCalculationDelegate(absSize, m_atlasFrame, m_leftOrBottomInset, m_rightOrTopInset);\n            m_cachedPositions = m_positionCalculationDelegate(absSize, m_cachedSizes);\n            m_cachedOffsetTL = m_offsetCalculationDelegate(absSize, m_atlasFrame, m_leftOrBottomInset, m_rightOrTopInset);\n        }\n    }\n    //----------------------------------------------------------------------------------------\n    //----------------------------------------------------------------------------------------\n    void ThreePatchUIDrawable::Draw(CanvasRenderer* renderer, const Matrix3& transform, const Vector2& absSize, const Colour& absColour, CanvasDrawMode drawMode) noexcept\n    {\n        CS_ASSERT(m_texture != nullptr, \"ThreePatchUIDrawable cannot draw without texture\");\n        \n        UpdatePatchCache(absSize);\n\n        for(u32 i=0; i<k_numPatches; ++i)\n        {\n            Matrix3 patchTransform = Matrix3::CreateTranslation(m_cachedPositions[i]);\n            renderer->DrawBox(drawMode, patchTransform * transform, m_cachedSizes[i], m_cachedOffsetTL, m_texture, m_cachedUvs[i], absColour * m_colour, AlignmentAnchor::k_middleCentre);\n        }\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/UI/Drawable/ThreePatchUIDrawable.h",
    "content": "//\n//  ThreePatchUIDrawable.h\n//  ChilliSource\n//  Created by Scott Downie on 24/07/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n\n#ifndef _CHILLISOURCE_UI_DRAWABLE_THREEPATCHUIDRAWABLE_H_\n#define _CHILLISOURCE_UI_DRAWABLE_THREEPATCHUIDRAWABLE_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Base/Colour.h>\n#include <ChilliSource/Core/Math/Vector2.h>\n#include <ChilliSource/Rendering/Texture/TextureAtlas.h>\n#include <ChilliSource/Rendering/Texture/UVs.h>\n#include <ChilliSource/UI/Drawable/UIDrawable.h>\n\n#include <array>\n#include <functional>\n\nnamespace ChilliSource\n{\n    //----------------------------------------------------------------------------------------\n    /// Interface for rendering widget with a texture and UVs as a 3 patch either horizontally\n    /// or vertically. This allows the widget to be scaled in one direction without distorting the edges.\n    /// The patches are specified by percentage insets from the edges of the widget\n    ///\n    /// The centre patch should be designed to stretch horizontally or vertically.\n    ///\n    /// @author S Downie\n    //----------------------------------------------------------------------------------------\n    class ThreePatchUIDrawable final : public UIDrawable\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(ThreePatchUIDrawable);\n        \n        static const u32 k_numPatches = 3;\n        //----------------------------------------------------------------------------------------\n        /// The type of the 3-patch i.e. horizontal or vertical\n        ///\n        /// @author S Downie\n        //----------------------------------------------------------------------------------------\n        enum class Direction\n        {\n            k_horizontal,\n            k_vertical\n        };\n        //----------------------------------------------------------------------------------------\n        /// Allows querying of whether or not the component implements the interface associated\n        /// with the given interface Id. Typically this won't be called directly, instead the\n        /// templated version IsA<Interface>() should be used.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The interface Id.\n        ///\n        /// @return Whether the object implements the given interface.\n        //----------------------------------------------------------------------------------------\n        bool IsA(InterfaceIDType in_interfaceId) const override;\n        //----------------------------------------------------------------------------------------\n        /// Get the texture that is currently used.\n        ///\n        /// @author HMcLaughlin\n        ///\n        /// @return Texture\n        //----------------------------------------------------------------------------------------\n        const TextureCSPtr& GetTexture() const override;\n        //----------------------------------------------------------------------------------------\n        /// Get the texture atlas that is currently used.\n        ///\n        /// @author HMcLaughlin\n        ///\n        /// @return Texture atlas\n        //----------------------------------------------------------------------------------------\n        const TextureAtlasCSPtr& GetTextureAtlas() const override;\n        //----------------------------------------------------------------------------------------\n        /// Get the texture atlas frame Id that is currently used.\n        ///\n        /// @author HMcLaughlin\n        ///\n        /// @return Frame Id\n        //----------------------------------------------------------------------------------------\n        const std::string& GetTextureAtlasId() const override;\n        //----------------------------------------------------------------------------------------\n        /// Get the UVs that are currently used. UVs are relative to the\n        /// frame and not the overall atlas\n        ///\n        /// @author HMcLaughlin\n        ///\n        /// @return Rectangle containing U, V, S, T\n        //----------------------------------------------------------------------------------------\n        const UVs& GetUVs() const override;\n        //----------------------------------------------------------------------------------------\n        /// Gets the colour of the drawable.\n        ///\n        /// @author HMcLaughlin\n        ///\n        /// @param The colour.\n        //----------------------------------------------------------------------------------------\n        const Colour& GetColour() const override;\n        //----------------------------------------------------------------------------------------\n        /// Set the texture that should be used in subsequent draws\n        ///\n        /// @author S Downie\n        ///\n        /// @param Texture\n        //----------------------------------------------------------------------------------------\n        void SetTexture(const TextureCSPtr& in_texture) override;\n        //----------------------------------------------------------------------------------------\n        /// Set the texture atlas that should be used in subsequent draws.\n        ///\n        /// @author S Downie\n        ///\n        /// @param Texture atlas\n        //----------------------------------------------------------------------------------------\n        void SetTextureAtlas(const TextureAtlasCSPtr& in_atlas) override;\n        //----------------------------------------------------------------------------------------\n        /// Set the texture atlas frame Id that should be used in subsequent draws.\n        ///\n        /// NOTE: An atlas must have been set prior to calling this\n        ///\n        /// @author S Downie\n        ///\n        /// @param Frame Id\n        //----------------------------------------------------------------------------------------\n        void SetTextureAtlasId(const std::string& in_atlasId) override;\n        //----------------------------------------------------------------------------------------\n        /// Set the UVs that should be used in subsequent draws. UVs are relative to the\n        /// frame and not the overall atlas\n        ///\n        /// @author S Downie\n        ///\n        /// @param Rectangle containing U, V, S, T\n        //----------------------------------------------------------------------------------------\n        void SetUVs(const UVs& in_UVs) override;\n        //----------------------------------------------------------------------------------------\n        /// Sets the colour of the drawable. The final colour of the drawable takes into account\n        /// the owning widgets colour and this colour.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The colour.\n        //----------------------------------------------------------------------------------------\n        void SetColour(const Colour& in_colour) override;\n        //----------------------------------------------------------------------------------------\n        /// Set the UV insets that should be used to create the patches. Insets are from the edge\n        /// and therefore no negative numbers need to be specified for right and bottom insets.\n        ///\n        /// NOTE: Insets must compliment each other i.e. left and right cannot sum to more than 1.0\n        /// as they would overlap and insets cannot be zero or less.\n        ///\n        /// @author S Downie\n        ///\n        /// @param Left inset if horizontal 3-patch bottom inset if vertical 3-patch (as normalised fraction 0 - 1)\n        /// @param Right inset if horizontal 3-patch top inset if vertical 3-patch (as normalised fraction 0 - 1)\n        //----------------------------------------------------------------------------------------\n        void SetInsets(f32 in_leftOrBottom, f32 in_rightOrTop);\n        //----------------------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return The preferred size that the drawable wishes to de drawn at based on the\n        /// texture size\n        //----------------------------------------------------------------------------------------\n        Vector2 GetPreferredSize() const override;\n        \n        /// Render the widget using the canvas renderer.\n        ///\n        /// @param renderer\n        ///     Performs the actual drawing to canvas\n        /// @param transform\n        ///     Absolute screen transform\n        /// @param absSize\n        ///     Asbolute screen size\n        /// @param absColour\n        ///     Absolute colour\n        /// @param drawMode\n        ///     Whether or not to create a clipping mask from this drawable or just render to screen\n        ///\n        void Draw(CanvasRenderer* renderer, const Matrix3& transform, const Vector2& absSize, const Colour& absColour, CanvasDrawMode drawMode) noexcept override;\n        \n    private:\n        friend class ThreePatchUIDrawableDef;\n        \n        //----------------------------------------------------------------------------------------\n        /// Calculates the UVs for each patch.\n        ///\n        /// @author S Downie\n        ///\n        /// @param Image frame\n        /// @param Left inset if horizontal 3-patch bottom inset if vertical 3-patch (as normalised fraction 0 - 1)\n        /// @param Right inset if horizontal 3-patch top inset if vertical 3-patch (as normalised fraction 0 - 1)\n        ///\n        /// @return UVs for each patch\n        //----------------------------------------------------------------------------------------\n        using CalculateUVsDelegate = std::function<std::array<UVs, k_numPatches>(const TextureAtlas::Frame&, f32, f32)>;\n        //----------------------------------------------------------------------------------------\n        /// Calculates the sizes for each patch.\n        ///\n        /// @author S Downie\n        ///\n        /// @param Widget absolute size\n        /// @param Image frame\n        /// @param Left inset if horizontal 3-patch bottom inset if vertical 3-patch (as normalised fraction 0 - 1)\n        /// @param Right inset if horizontal 3-patch top inset if vertical 3-patch (as normalised fraction 0 - 1)\n        ///\n        /// @return Size for each patch\n        //----------------------------------------------------------------------------------------\n        using CalculateSizesDelegate = std::function<std::array<Vector2, k_numPatches>(const Vector2&, const TextureAtlas::Frame&, f32, f32)>;\n        //----------------------------------------------------------------------------------------\n        /// Calculates the local space positions for each patch.\n        ///\n        /// @author S Downie\n        ///\n        /// @param Widget absolute size\n        /// @param Patch sizes\n        ///\n        /// @return Positions for each patch\n        //----------------------------------------------------------------------------------------\n        using CalculatePositionsDelegate = std::function<std::array<Vector2, k_numPatches>(const Vector2&, const std::array<Vector2, k_numPatches>&)>;\n        //----------------------------------------------------------------------------------------\n        /// Calculate the offset for the patches that will position them as if they still had\n        /// their cropped space\n        ///\n        /// @author S Downie\n        ///\n        /// @param Widget absolute size\n        /// @param Image frame\n        /// @param Left inset if horizontal 3-patch bottom inset if vertical 3-patch (as normalised fraction 0 - 1)\n        /// @param Right inset if horizontal 3-patch top inset if vertical 3-patch (as normalised fraction 0 - 1)\n        ///\n        /// @return Offset from top left\n        //----------------------------------------------------------------------------------------\n        using CalculateOffsetDelegate = std::function<Vector2(const Vector2&, const TextureAtlas::Frame&, f32, f32)>;\n        //----------------------------------------------------------------------------------------\n        /// Constructor\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The texture.\n        /// @param The direction the drawable will stretch.\n        /// @param The left inset if a horizontal 3-patch or the bottom inset if a vertical\n        /// 3-patch. This should be provided as a normalised fraction, 0.0 - 1.0.\n        /// @param The right inset if a horizontal 3-patch or the top inset if a vertical 3-patch.\n        /// This should be provided as a normalised fraction, 0.0 - 1.0.\n        //----------------------------------------------------------------------------------------\n        ThreePatchUIDrawable(const TextureCSPtr& in_texture, Direction in_direction, f32 in_leftOrBottom, f32 in_rightOrTop);\n        //----------------------------------------------------------------------------------------\n        /// Constructor\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The texture.\n        /// @param The texture atlas.\n        /// @param The atlas id.\n        /// @param The direction the drawable will stretch.\n        /// @param The left inset if a horizontal 3-patch or the bottom inset if a vertical\n        /// 3-patch. This should be provided as a normalised fraction, 0.0 - 1.0.\n        /// @param The right inset if a horizontal 3-patch or the top inset if a vertical 3-patch.\n        /// This should be provided as a normalised fraction, 0.0 - 1.0.\n        //----------------------------------------------------------------------------------------\n        ThreePatchUIDrawable(const TextureCSPtr& in_texture, const TextureAtlasCSPtr& in_atlas, const std::string& in_atlasId, Direction in_direction, f32 in_leftOrBottom, f32 in_rightOrTop);\n        \n        /// Patches (size, pos, etc) are calculated and cached. This function when called will\n        /// update the cache if required, otherwise it will do nothing\n        ///\n        /// @param absSize\n        ///     Canvas space size of the widget, if changed from last draw, update the cache\n        ///\n        void UpdatePatchCache(const Vector2& absSize);\n        \n        CalculateUVsDelegate m_uvCalculationDelegate;\n        CalculateSizesDelegate m_sizeCalculationDelegate;\n        CalculatePositionsDelegate m_positionCalculationDelegate;\n        CalculateOffsetDelegate m_offsetCalculationDelegate;\n        \n        TextureCSPtr m_texture;\n        TextureAtlasCSPtr m_atlas;\n        TextureAtlas::Frame m_atlasFrame;\n        UVs m_uvs;\n        std::string m_atlasId;\n        Colour m_colour;\n        \n        std::array<UVs, k_numPatches> m_cachedUvs;\n        std::array<Vector2, k_numPatches> m_cachedSizes;\n        std::array<Vector2, k_numPatches> m_cachedPositions;\n        Vector2 m_cachedOffsetTL;\n        Vector2 m_cachedWidgetSize;\n        \n        f32 m_leftOrBottomInset = 0.01f;\n        f32 m_rightOrTopInset = 0.01f;\n        \n        bool m_isPatchCatchValid = false;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/UI/Drawable/ThreePatchUIDrawableDef.cpp",
    "content": "//\n//  ThreePatchUIDrawableDef.cpp\n//  ChilliSource\n//  Created by Ian Copland on 15/12/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/UI/Drawable/ThreePatchUIDrawableDef.h>\n\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/Resource/ResourcePool.h>\n#include <ChilliSource/Core/String/StringParser.h>\n#include <ChilliSource/Rendering/Base/CanvasDrawMode.h>\n#include <ChilliSource/Rendering/Texture/Texture.h>\n#include <ChilliSource/Rendering/Texture/TextureAtlas.h>\n\nnamespace ChilliSource\n{\n    namespace\n    {\n        //--------------------------------------------------------------\n        /// Parses a three-patch drawable direction from the given\n        /// string. If the given string is not a valid direction the app\n        /// is considered to be in an irrecoverable state and will\n        /// terminate.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The string to parse.\n        ///\n        /// @return The output three-patch drawable direction.\n        //--------------------------------------------------------------\n        ThreePatchUIDrawable::Direction ParseThreePatchDirection(const std::string& in_directionString)\n        {\n            const char k_horizontalType[] = \"horizontal\";\n            const char k_verticalType[] = \"vertical\";\n            \n            std::string directionString = in_directionString;\n            StringUtils::ToLowerCase(directionString);\n            \n            if (directionString == k_horizontalType)\n            {\n                return ThreePatchUIDrawable::Direction::k_horizontal;\n            }\n            else if (directionString == k_verticalType)\n            {\n                return ThreePatchUIDrawable::Direction::k_vertical;\n            }\n            \n            CS_LOG_FATAL(\"Cannot parse invalid three-patch direction.\");\n            return ThreePatchUIDrawable::Direction::k_horizontal;\n        }\n    }\n    \n    CS_DEFINE_NAMEDTYPE(ThreePatchUIDrawableDef);\n    //--------------------------------------------------------------\n    //--------------------------------------------------------------\n    ThreePatchUIDrawableDef::ThreePatchUIDrawableDef(const Json::Value& in_json, StorageLocation in_defaultLocation, const std::string& in_defaultPath)\n    : m_drawMode(CanvasDrawMode::k_standard)\n    {\n        const char k_typeKey[] = \"Type\";\n        const char k_textureLocationKey[] = \"TextureLocation\";\n        const char k_textureFilePathKey[] = \"TexturePath\";\n        const char k_atlasLocationKey[] = \"AtlasLocation\";\n        const char k_atlasFilePathKey[] = \"AtlasPath\";\n        const char k_atlasIdKey[] = \"AtlasId\";\n        const char k_uvsKey[] = \"UVs\";\n        const char k_colourKey[] = \"Colour\";\n        const char k_insetsKey[] = \"Insets\";\n        const char k_directionKey[] = \"Direction\";\n        const char k_drawModeKey[] = \"DrawMode\";\n        \n        CS_ASSERT(in_json.isObject() == true, \"UIDrawable Def must be created from a json value of type Object.\");\n        \n        //read all the properties from JSON.\n        StorageLocation textureLocation = StorageLocation::k_none;\n        StorageLocation atlasLocation = StorageLocation::k_none;\n        std::string texturePath;\n        std::string atlasPath;\n        for(auto it = in_json.begin(); it != in_json.end(); ++it)\n        {\n            CS_ASSERT((*it).isString() == true, \"All properties in a UIDrawable Def must be a string: \" + std::string(it.memberName()));\n            \n            std::string key = it.memberName();\n            std::string value = (*it).asString();\n            \n            if (key == k_textureLocationKey)\n            {\n                textureLocation = ParseStorageLocation(value);\n            }\n            else if (key == k_textureFilePathKey)\n            {\n                texturePath = value;\n            }\n            else if (key == k_atlasLocationKey)\n            {\n                atlasLocation = ParseStorageLocation(value);\n            }\n            else if (key == k_atlasFilePathKey)\n            {\n                atlasPath = value;\n            }\n            else if (key == k_atlasIdKey)\n            {\n                m_atlasId = value;\n            }\n            else if (key == k_uvsKey)\n            {\n                auto vec =  ParseVector4(value);;\n                m_uvs = UVs(vec.x, vec.y, vec.z, vec.w);\n            }\n            else if (key == k_colourKey)\n            {\n                m_colour = ParseColour(value);\n            }\n            else if (key == k_insetsKey)\n            {\n                m_insets = ParseVector2(value);\n            }\n            else if (key == k_directionKey)\n            {\n                m_direction = ParseThreePatchDirection(value);\n            }\n            else if (key == k_drawModeKey)\n            {\n                m_drawMode = ParseCanvasDrawMode(value);\n            }\n            else if (key == k_typeKey)\n            {\n                //ignore\n            }\n            else\n            {\n                CS_LOG_FATAL(\"Invalid property found in a Three-Patch UIDrawable Def: \" + key);\n            }\n        }\n        \n        //load the texture.\n        CS_ASSERT(texturePath.empty() == false, \"A texture must be supplied in a Three-Patch UIDrawable Def.\")\n        \n        auto resPool = Application::Get()->GetResourcePool();\n        if (textureLocation == StorageLocation::k_none)\n        {\n            textureLocation = in_defaultLocation;\n            texturePath = StringUtils::StandardiseDirectoryPath(in_defaultPath) + texturePath;\n        }\n        \n        m_texture = resPool->LoadResource<Texture>(textureLocation, texturePath);\n        CS_ASSERT(m_texture != nullptr, \"Invalid texture supplied in a Three-Patch UIDrawable Def.\");\n        \n        //try and load the atlas\n        if (atlasPath.empty() == false)\n        {\n            if (atlasLocation == StorageLocation::k_none)\n            {\n                atlasLocation = in_defaultLocation;\n                atlasPath = StringUtils::StandardiseDirectoryPath(in_defaultPath) + atlasPath;\n            }\n            \n            m_atlas = resPool->LoadResource<TextureAtlas>(atlasLocation, atlasPath);\n            CS_ASSERT(m_texture, \"Invalid texture atlas supplied in a Three-Patch UIDrawable Def.\");\n            CS_ASSERT(m_atlasId.empty() == false, \"A texture atlas Id must be specified when using a texture atlas in a Three-Patch UIDrawable Def.\");\n        }\n        else\n        {\n            CS_ASSERT(m_atlasId.empty() == true, \"Cannot specify a texture atlas Id without a texture atlas in a Three-Patch UIDrawable Def.\");\n        }\n    }\n    //--------------------------------------------------------------\n    //--------------------------------------------------------------\n    ThreePatchUIDrawableDef::ThreePatchUIDrawableDef(const TextureCSPtr& in_texture, const Vector2& in_insets, ThreePatchUIDrawable::Direction in_direction, const Colour& in_colour, const UVs& in_uvs)\n    : m_texture(in_texture), m_insets(in_insets), m_direction(in_direction), m_colour(in_colour), m_uvs(in_uvs), m_drawMode(CanvasDrawMode::k_standard)\n    {\n        CS_ASSERT(m_texture != nullptr, \"The texture cannot be null in a Three-Patch UIDrawable Def.\");\n    }\n    //--------------------------------------------------------------\n    //--------------------------------------------------------------\n    ThreePatchUIDrawableDef::ThreePatchUIDrawableDef(const TextureCSPtr& in_texture, const TextureAtlasCSPtr& in_atlas, const std::string& in_atlasId, const Vector2& in_insets, ThreePatchUIDrawable::Direction in_direction,\n                                                 const Colour& in_colour, const UVs& in_uvs)\n    : m_texture(in_texture), m_atlas(in_atlas), m_atlasId(in_atlasId), m_insets(in_insets), m_direction(in_direction), m_colour(in_colour), m_uvs(in_uvs), m_drawMode(CanvasDrawMode::k_standard)\n    {\n        CS_ASSERT(m_texture != nullptr, \"The texture cannot be null in a Three-Patch UIDrawable Def.\");\n        CS_ASSERT(m_atlas != nullptr, \"Cannot specify a null texture atlas in a Three-Patch UIDrawable Def. Use the texture only constructor instead.\");\n        CS_ASSERT(m_atlas->HasFrameWithId(m_atlasId) == true, \"Invalid texture atlas Id provided in a Three-Patch UIDrawable Def.\");\n    }\n    //--------------------------------------------------------------\n    //--------------------------------------------------------------\n    bool ThreePatchUIDrawableDef::IsA(InterfaceIDType in_interfaceId) const\n    {\n        return (UIDrawableDef::InterfaceID == in_interfaceId || ThreePatchUIDrawableDef::InterfaceID == in_interfaceId);\n    }\n    //--------------------------------------------------------------\n    //--------------------------------------------------------------\n    const TextureCSPtr& ThreePatchUIDrawableDef::GetTexture() const\n    {\n        return m_texture;\n    }\n    //--------------------------------------------------------------\n    //--------------------------------------------------------------\n    const TextureAtlasCSPtr& ThreePatchUIDrawableDef::GetAtlas() const\n    {\n        return m_atlas;\n    }\n    //--------------------------------------------------------------\n    //--------------------------------------------------------------\n    const std::string& ThreePatchUIDrawableDef::GetAtlasId() const\n    {\n        return m_atlasId;\n    }\n    //--------------------------------------------------------------\n    //--------------------------------------------------------------\n    const UVs& ThreePatchUIDrawableDef::GetUVs() const\n    {\n        return m_uvs;\n    }\n    //--------------------------------------------------------------\n    //--------------------------------------------------------------\n    const Colour& ThreePatchUIDrawableDef::GetColour() const\n    {\n        return m_colour;\n    }\n    //--------------------------------------------------------------\n    //--------------------------------------------------------------\n    const Vector2& ThreePatchUIDrawableDef::GetInsets() const\n    {\n        return m_insets;\n    }\n    //--------------------------------------------------------------\n    //--------------------------------------------------------------\n    ThreePatchUIDrawable::Direction ThreePatchUIDrawableDef::GetDirection() const\n    {\n        return m_direction;\n    }\n    //--------------------------------------------------------------\n    //--------------------------------------------------------------\n    UIDrawableUPtr ThreePatchUIDrawableDef::CreateDrawable() const\n    {\n        ThreePatchUIDrawableUPtr drawable;\n        \n        if (m_atlas != nullptr)\n        {\n            drawable = ThreePatchUIDrawableUPtr(new ThreePatchUIDrawable(m_texture, m_atlas, m_atlasId, m_direction, m_insets.x, m_insets.y));\n        }\n        else\n        {\n            drawable = ThreePatchUIDrawableUPtr(new ThreePatchUIDrawable(m_texture, m_direction, m_insets.x, m_insets.y));\n        }\n        \n        drawable->SetUVs(m_uvs);\n        drawable->SetColour(m_colour);\n        \n        UIDrawableUPtr output = std::move(drawable);\n        return output;\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/UI/Drawable/ThreePatchUIDrawableDef.h",
    "content": "//\n//  ThreePatchUIDrawableDef.h\n//  ChilliSource\n//  Created by Ian Copland on 15/12/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_UI_DRAWABLE_THREEPATCHUIDRAWABLEDEF_H_\n#define _CHILLISOURCE_UI_DRAWABLE_THREEPATCHUIDRAWABLEDEF_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Base/Colour.h>\n#include <ChilliSource/Core/Math/Vector2.h>\n#include <ChilliSource/Rendering/Texture/UVs.h>\n#include <ChilliSource/UI/Drawable/UIDrawableDef.h>\n#include <ChilliSource/UI/Drawable/ThreePatchUIDrawable.h>\n\nnamespace ChilliSource\n{\n    //---------------------------------------------------------------------\n    /// A definition of a Three-Patch UIDrawable which can be built from a\n    /// json object. This is effectively an immutable container for the\n    /// properties of a Three-Patch UIDrawable.\n    ///\n    /// A Three-Patch UIDrawable Def contains the following properties in\n    /// addition to those defined in the UIDrawable Def base class\n    /// documentation:\n    ///\n    /// \"Insets\": The insets from the edges of the stretchable portion of\n    /// the image. \n    ///\n    /// \"Direction\": The direction the Three-Patch will stretch in:\n    /// horizontal or vertical. Defaults to horizontal.\n    ///\n    /// @author Ian Copland\n    //---------------------------------------------------------------------\n    class ThreePatchUIDrawableDef final : public UIDrawableDef\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(ThreePatchUIDrawableDef);\n        //--------------------------------------------------------------\n        /// Constructor. Creates an empty standard drawable definition.\n        ///\n        /// @author Ian Copland\n        //--------------------------------------------------------------\n        ThreePatchUIDrawableDef() = default;\n        //--------------------------------------------------------------\n        /// Constructor. Creates a standard drawable definition from\n        /// json.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The JSON object containing the drawable properties.\n        /// @param [Optional] The relative storage location which will\n        /// be used if there is no storage location specified in the\n        /// json. Defaults to package.\n        /// @param [Optional] The directory paths will be relative to if\n        /// there is no storage location specified in the json. Defaults\n        /// to empty.\n        //--------------------------------------------------------------\n        ThreePatchUIDrawableDef(const Json::Value& in_json, StorageLocation in_defaultLocation = StorageLocation::k_package, const std::string& in_defaultPath = \"\");\n        //--------------------------------------------------------------\n        /// Constructor. Creates a standard drawable definition from\n        /// with just a texture.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The texture.\n        /// @param The insets.\n        /// @param The stretch direction.\n        /// @param [Optional] The colour. Defaults to white.\n        /// @param [Optional] The UVs. Defaults to (0, 0, 1, 1)\n        //--------------------------------------------------------------\n        ThreePatchUIDrawableDef(const TextureCSPtr& in_texture, const Vector2& in_insets, ThreePatchUIDrawable::Direction in_direction, const Colour& in_colour = Colour::k_white,\n                              const UVs& in_uvs = UVs());\n        //--------------------------------------------------------------\n        /// Constructor. Creates a standard drawable definition from\n        /// with a texture atlas.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The texture.\n        /// @param The texture atlas.\n        /// @param The texture atlas id.\n        /// @param The insets.\n        /// @param The stretch direction.\n        /// @param [Optional] The colour. Defaults to white.\n        /// @param [Optional] The UVs. Defaults to (0, 0, 1, 1)\n        //--------------------------------------------------------------\n        ThreePatchUIDrawableDef(const TextureCSPtr& in_texture, const TextureAtlasCSPtr& in_atlas, const std::string& in_atlasId, const Vector2& in_insets,\n                              ThreePatchUIDrawable::Direction in_direction, const Colour& in_colour = Colour::k_white, const UVs& in_uvs = UVs());\n        //--------------------------------------------------------------\n        /// Allows querying of whether or not the component implements\n        /// the interface associated with the given interface Id.\n        /// Typically this won't be called directly, instead the\n        /// templated version IsA<Interface>() should be used.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The interface Id.\n        ///\n        /// @return Whether the object implements the given interface.\n        //--------------------------------------------------------------\n        bool IsA(InterfaceIDType in_interfaceId) const override;\n        //--------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param The texture that will be rendered by the drawable.\n        //--------------------------------------------------------------\n        const TextureCSPtr& GetTexture() const override;\n        //--------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param The texture atlas. If is supplied the drawable will\n        /// render only the portion of the texture described by this and\n        /// the atlas id.\n        //--------------------------------------------------------------\n        const TextureAtlasCSPtr& GetAtlas() const override;\n        //--------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param The Id of the image in the texture atlas. This will\n        /// be empty if there is no texture altas.\n        //--------------------------------------------------------------\n        const std::string& GetAtlasId() const override;\n        //--------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param The UVs of the image within the texture. If a texture\n        /// atlas is used the UVs are virtual and are relative to the\n        /// atlas image.\n        //--------------------------------------------------------------\n        const UVs& GetUVs() const override;\n        //--------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param The colour of the drawable.\n        //--------------------------------------------------------------\n        const Colour& GetColour() const override;\n        //--------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param The insets from the edges of the stretchable portion\n        /// of the image.\n        //--------------------------------------------------------------\n        const Vector2& GetInsets() const;\n        //--------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param The direction that a Three-Patch drawable will stretch.\n        //--------------------------------------------------------------\n        ThreePatchUIDrawable::Direction GetDirection() const;\n        \n        /// @return Draw mode of the drawable\n        ///\n        CanvasDrawMode GetDrawMode() const noexcept override { return m_drawMode; }\n        \n    private:\n        //--------------------------------------------------------------\n        /// Creates a new instance of a standard drawable as described\n        /// by this definition. This should typically only be called by\n        /// a drawable component.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @return a new drawable instance.\n        //--------------------------------------------------------------\n        UIDrawableUPtr CreateDrawable() const override;\n        \n        TextureCSPtr m_texture;\n        TextureAtlasCSPtr m_atlas;\n        std::string m_atlasId;\n        UVs m_uvs;\n        Colour m_colour;\n        Vector2 m_insets;\n        ThreePatchUIDrawable::Direction m_direction;\n        CanvasDrawMode m_drawMode;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/UI/Drawable/UIDrawable.cpp",
    "content": "//\n//  UIDrawable.cpp\n//  ChilliSource\n//  Created by Scott Downie on 18/04/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/UI/Drawable/UIDrawable.h>\n\nnamespace ChilliSource\n{\n    CS_DEFINE_NAMEDTYPE(UIDrawable);\n}\n"
  },
  {
    "path": "Source/ChilliSource/UI/Drawable/UIDrawable.h",
    "content": "//\n//  Drawble.h\n//  ChilliSource\n//  Created by Scott Downie on 17/04/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n\n#ifndef _CHILLISOURCE_UI_DRAWABLE_UIDRAWABLE_H_\n#define _CHILLISOURCE_UI_DRAWABLE_UIDRAWABLE_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Base/QueryableInterface.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------\n    /// Interface for rendering widgets\n    ///\n    /// @author S Downie\n    //------------------------------------------------------------------------\n    class UIDrawable : public QueryableInterface\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(UIDrawable);\n        CS_DECLARE_NOCOPY(UIDrawable);\n        //----------------------------------------------------------------------------------------\n        /// Constructor\n        ///\n        /// @author S Downie\n        //----------------------------------------------------------------------------------------\n        UIDrawable() = default;\n        //----------------------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return The preferred size that the drawable wishes to de drawn at. This is usually\n        /// based on an underlying image\n        //----------------------------------------------------------------------------------------\n        virtual Vector2 GetPreferredSize() const = 0;\n        //----------------------------------------------------------------------------------------\n        /// Get the texture that is currently used.\n        ///\n        /// @author HMcLaughlin\n        ///\n        /// @return Texture\n        //----------------------------------------------------------------------------------------\n        virtual const TextureCSPtr& GetTexture() const = 0;\n        //----------------------------------------------------------------------------------------\n        /// Get the texture atlas that is currently used.\n        ///\n        /// @author HMcLaughlin\n        ///\n        /// @return Texture atlas\n        //----------------------------------------------------------------------------------------\n        virtual const TextureAtlasCSPtr& GetTextureAtlas() const = 0;\n        //----------------------------------------------------------------------------------------\n        /// Get the texture atlas frame Id that is currently used.\n        ///\n        /// @author HMcLaughlin\n        ///\n        /// @return Frame Id\n        //----------------------------------------------------------------------------------------\n        virtual const std::string& GetTextureAtlasId() const = 0;\n        //----------------------------------------------------------------------------------------\n        /// Get the UVs that are currently used. UVs are relative to the\n        /// frame and not the overall atlas\n        ///\n        /// @author HMcLaughlin\n        ///\n        /// @return Rectangle containing U, V, S, T\n        //----------------------------------------------------------------------------------------\n        virtual const UVs& GetUVs() const = 0;\n        //----------------------------------------------------------------------------------------\n        /// Gets the colour of the drawable.\n        ///\n        /// @author HMcLaughlin\n        ///\n        /// @param The colour.\n        //----------------------------------------------------------------------------------------\n        virtual const Colour& GetColour() const = 0;\n        //----------------------------------------------------------------------------------------\n        /// Set the texture that should be used in subsequent draws\n        ///\n        /// @author S Downie\n        ///\n        /// @param Texture\n        //----------------------------------------------------------------------------------------\n        virtual void SetTexture(const TextureCSPtr& in_texture) = 0;\n        //----------------------------------------------------------------------------------------\n        /// Set the texture atlas that should be used in subsequent draws. This will\n        /// potentially affect the UVs of a drawable.\n        ///\n        /// @author S Downie\n        ///\n        /// @param Texture atlas\n        //----------------------------------------------------------------------------------------\n        virtual void SetTextureAtlas(const TextureAtlasCSPtr& in_atlas) = 0;\n        //----------------------------------------------------------------------------------------\n        /// Set the texture atlas frame Id that should be used in subsequent draws. This will\n        /// potentially affect the UVs of a drawable.\n        ///\n        /// NOTE: An atlas must have been set prior to calling this\n        ///\n        /// @author S Downie\n        ///\n        /// @param Frame Id\n        //----------------------------------------------------------------------------------------\n        virtual void SetTextureAtlasId(const std::string& in_atlasId) = 0;\n        //----------------------------------------------------------------------------------------\n        /// Set the UVs that should be used in subsequent draws. UVs are relative to the\n        /// frame and not the overall atlas\n        ///\n        /// @author S Downie\n        ///\n        /// @param Rectangle containing U, V, S, T\n        //----------------------------------------------------------------------------------------\n        virtual void SetUVs(const UVs& in_UVs) = 0;\n        //----------------------------------------------------------------------------------------\n        /// Sets the colour of the drawable. The final colour of the drawable takes into account\n        /// the owning widgets colour and this colour.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The colour.\n        //----------------------------------------------------------------------------------------\n        virtual void SetColour(const Colour& in_colour) = 0;\n        \n        /// Render the widget using the canvas renderer.\n        ///\n        /// @param renderer\n        ///     Performs the actual drawing to canvas\n        /// @param transform\n        ///     Absolute screen transform\n        /// @param absSize\n        ///     Asbolute screen size\n        /// @param absColour\n        ///     Absolute colour\n        /// @param drawMode\n        ///     Whether or not to create a clipping mask from this drawable or just render it\n        ///\n        virtual void Draw(CanvasRenderer* renderer, const Matrix3& transform, const Vector2& absSize, const Colour& absColour, CanvasDrawMode drawMode) noexcept = 0;\n        //----------------------------------------------------------------------------------------\n        /// Virtual destructor\n        ///\n        /// @author S Downie\n        //----------------------------------------------------------------------------------------\n        virtual ~UIDrawable(){};\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/UI/Drawable/UIDrawableDef.cpp",
    "content": "//\n//  UIDrawableDef.cpp\n//  ChilliSource\n//  Created by Ian Copland on 21/11/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/UI/Drawable/UIDrawableDef.h>\n\n#include <ChilliSource/UI/Drawable/NinePatchUIDrawableDef.h>\n#include <ChilliSource/UI/Drawable/StandardUIDrawableDef.h>\n#include <ChilliSource/UI/Drawable/ThreePatchUIDrawableDef.h>\n\n#include <json/json.h>\n\nnamespace ChilliSource\n{\n    namespace\n    {\n        //--------------------------------------------------------------\n        /// Identifiers for the different drawable definition types.\n        ///\n        /// @author S Downie\n        //--------------------------------------------------------------\n        enum class DrawableType\n        {\n            k_none,\n            k_standard,\n            k_ninePatch,\n            k_threePatch\n        };\n        //--------------------------------------------------------------\n        /// Converts a string to a drawable type\n        ///\n        /// @author S Downie\n        ///\n        /// @param String\n        ///\n        /// @return UIDrawable type\n        //--------------------------------------------------------------\n        DrawableType ParseDrawableType(const std::string& in_type)\n        {\n            std::string lowerCase = in_type;\n            StringUtils::ToLowerCase(lowerCase);\n            \n            if(lowerCase == \"none\") return DrawableType::k_none;\n            if(lowerCase == \"standard\") return DrawableType::k_standard;\n            if(lowerCase == \"ninepatch\") return DrawableType::k_ninePatch;\n            if(lowerCase == \"threepatch\") return DrawableType::k_threePatch;\n            \n            CS_LOG_FATAL(\"Cannot parse drawable type: \" + in_type);\n            return DrawableType::k_none;\n        }\n    }\n    \n    CS_DEFINE_NAMEDTYPE(UIDrawableDef);\n    //--------------------------------------------------------------\n    //--------------------------------------------------------------\n    UIDrawableDefCUPtr UIDrawableDef::Create(const Json::Value& in_json, StorageLocation in_defaultLocation, const std::string& in_defaultPath)\n    {\n        const char k_typeKey[] = \"Type\";\n        \n        CS_ASSERT(in_json.isObject() == true, \"UIDrawable Def must be created from a json value of type Object.\");\n        \n        const auto& typeJson = in_json.get(k_typeKey, Json::nullValue);\n        CS_ASSERT(typeJson != Json::nullValue, \"'\" + std::string(k_typeKey) + \"' must be specified in a UIDrawable Def.\");\n        \n        DrawableType type = ParseDrawableType(typeJson.asString());\n        \n        switch (type)\n        {\n            case DrawableType::k_standard:\n                return UIDrawableDefCUPtr(new StandardUIDrawableDef(in_json, in_defaultLocation, in_defaultPath));\n            case DrawableType::k_threePatch:\n                return UIDrawableDefCUPtr(new ThreePatchUIDrawableDef(in_json, in_defaultLocation, in_defaultPath));\n            case DrawableType::k_ninePatch:\n                return UIDrawableDefCUPtr(new NinePatchUIDrawableDef(in_json, in_defaultLocation, in_defaultPath));\n            case DrawableType::k_none:\n                return nullptr;\n            default:\n                CS_LOG_FATAL(\"Invalid drawable def type.\");\n                return nullptr;\n        }\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/UI/Drawable/UIDrawableDef.h",
    "content": "//\n//  UIDrawableDef.h\n//  ChilliSource\n//  Created by Ian Copland on 21/11/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_UI_DRAWABLE_UIDRAWABLEDEF_H_\n#define _CHILLISOURCE_UI_DRAWABLE_UIDRAWABLEDEF_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Base/QueryableInterface.h>\n#include <ChilliSource/Core/File/StorageLocation.h>\n\n#include <json/forwards.h>\n\nnamespace ChilliSource\n{\n    //---------------------------------------------------------------------\n    /// A definition of a drawable which can be built from a json object.\n    /// This is effectively an immutable container for the properties of a\n    /// specific type of drawable.\n    ///\n    /// UIDrawable Defs can be either created using the concrete def's\n    /// constructor or using the Create() method. This creates the def\n    /// from json which describes the type and properties of the def.\n    ///\n    /// All drawable defs contain the following properties. Specific def\n    /// types can also contain further properties.\n    ///\n    /// \"Type\": Describes the type of drawable def.\n    ///\n    /// \"TextureLocation\": The storage location of the texture that is\n    /// used. If this is not specified a relative path will be instead used,\n    /// loading the drawable relative to the parent resource.\n    ///\n    /// \"TexturePath\": The path to the texture the drawable will render.\n    /// A texture must always be supplied.\n    ///\n    /// \"AtlasLocation\": The storage location of the texture atlas. This\n    /// defaults to Package.\n    ///\n    /// \"AtlasPath\": The file path of the texture atlas. A texture atlas\n    /// is optional, if one is not supplied the whole texture will be used.\n    ///\n    /// \"AtlasId\": The Id of the image in the texture atlas. This should\n    /// not be supplied unless a texture atlas is used.\n    ///\n    /// \"UVs\": The UVs of the image within the texture. If a texture atlas\n    /// is used the UVs are virtual and are relative to the atlas image.\n    /// UV wrapping does not work for texture atlased images.\n    ///\n    /// \"Colour\": The colour of the drawable.\n    ///\n    /// \"DrawMode\": Describes the draw mode for this drawable\n    ///     \"Standard\" - Draw to canvas as usual\n    ///     \"Mask\" - Draw to canvas and create a clip mask\n    ///     \"MaskOnly\" - Don't render to canvas just create the clip mask\n    ///\n    /// @author Ian Copland\n    //---------------------------------------------------------------------\n    class UIDrawableDef : public QueryableInterface\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(UIDrawableDef);\n        //--------------------------------------------------------------\n        /// Creates a new drawable def from json which describes the\n        /// type of def and its properties.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The JSON object containing the drawable properties.\n        /// @param [Optional] The relative storage location which will\n        /// be used if there is no storage location specified in the\n        /// json. Defaults to package.\n        /// @param [Optional] The directory paths will be relative to if\n        /// there is no storage location specified in the json. Defaults\n        /// to empty.\n        //--------------------------------------------------------------\n        static UIDrawableDefCUPtr Create(const Json::Value& in_json, StorageLocation in_defaultLocation = StorageLocation::k_package, const std::string& in_defaultPath = \"\");\n        //--------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param The texture that will be rendered by the drawable.\n        //--------------------------------------------------------------\n        virtual const TextureCSPtr& GetTexture() const = 0;\n        //--------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param The texture atlas. If is supplied the drawable will\n        /// render only the portion of the texture described by this and\n        /// the atlas id.\n        //--------------------------------------------------------------\n        virtual const TextureAtlasCSPtr& GetAtlas() const = 0;\n        //--------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param The Id of the image in the texture atlas. This will\n        /// be empty if there is no texture altas.\n        //--------------------------------------------------------------\n        virtual const std::string& GetAtlasId() const = 0;\n        //--------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param The UVs of the image within the texture. If a texture\n        /// atlas is used the UVs are virtual and are relative to the\n        /// atlas image.\n        //--------------------------------------------------------------\n        virtual const UVs& GetUVs() const = 0;\n        //--------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param The colour of the drawable.\n        //--------------------------------------------------------------\n        virtual const Colour& GetColour() const = 0;\n        \n        /// @return Draw mode of the drawable\n        ///\n        virtual CanvasDrawMode GetDrawMode() const noexcept = 0;\n        \n        //--------------------------------------------------------------\n        /// Destructor\n        ///\n        /// @author Ian Copland\n        //--------------------------------------------------------------\n        virtual ~UIDrawableDef() {};\n    protected:\n        friend class DrawableUIComponent;\n        //--------------------------------------------------------------\n        /// Creates a new instance of the drawable described by this\n        /// definition. This should typically only be called by a\n        /// drawable component.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @return a new drawable instance.\n        //--------------------------------------------------------------\n        virtual UIDrawableUPtr CreateDrawable() const = 0;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/UI/Drawable/UIDrawableUtils.cpp",
    "content": "//\n//  UIDrawableUtils.cpp\n//  ChilliSource\n//  Created by Scott Downie on 03/10/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/UI/Drawable/UIDrawableUtils.h>\n\n#include <ChilliSource/Rendering/Texture/Texture.h>\n#include <ChilliSource/Rendering/Texture/UVs.h>\n\nnamespace ChilliSource\n{\n    namespace UIDrawableUtils\n    {\n        //----------------------------------------------------------------------------\n        //----------------------------------------------------------------------------\n        TextureAtlas::Frame BuildFrame(const Texture* in_texture, const TextureAtlas* in_textureAtlas, const std::string& in_atlasId, const UVs& in_virtualUVs)\n        {\n            TextureAtlas::Frame outputFrame;\n            \n            if (in_textureAtlas != nullptr && in_atlasId.empty() == false)\n            {\n                outputFrame = in_textureAtlas->GetFrame(in_atlasId);\n                outputFrame.m_uvs.m_u += (in_virtualUVs.m_u * outputFrame.m_uvs.m_s);\n                outputFrame.m_uvs.m_v += (in_virtualUVs.m_v * outputFrame.m_uvs.m_t);\n                outputFrame.m_uvs.m_s *= in_virtualUVs.m_s;\n                outputFrame.m_uvs.m_t *= in_virtualUVs.m_t;\n            }\n            else\n            {\n                Vector2 texSize;\n                if(in_texture != nullptr)\n                {\n                    texSize.x = (f32)in_texture->GetDimensions().x * in_virtualUVs.m_s;\n                    texSize.y = (f32)in_texture->GetDimensions().y * in_virtualUVs.m_t;\n                }\n                \n                outputFrame.m_croppedSize = texSize;\n                outputFrame.m_originalSize = texSize;\n                outputFrame.m_uvs = in_virtualUVs;\n                outputFrame.m_offset = Vector2::k_zero;\n            }\n            \n            return outputFrame;\n        }\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/UI/Drawable/UIDrawableUtils.h",
    "content": "//\n//  UIDrawableUtils.h\n//  ChilliSource\n//  Created by Scott Downie on 03/10/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_UI_DRAWABLE_UIDRAWABLEUTILS_H_\n#define _CHILLISOURCE_UI_DRAWABLE_UIDRAWABLEUTILS_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Rendering/Texture/TextureAtlas.h>\n\nnamespace ChilliSource\n{\n    //----------------------------------------------------------------------------\n    /// Collection of utility methods shared by drawables\n    ///\n    /// @author S Downie\n    //----------------------------------------------------------------------------\n    namespace UIDrawableUtils\n    {\n        //----------------------------------------------------------------------------\n        /// Creates the texture atlas frame from the given atlas, atlas id, and UVs.\n        /// If there is no atlas or atlas id, the frame will be calculated from the\n        /// texture and the UVs. If there is also no texture, a zero sized frame\n        /// will be created.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The texture. Can be null.\n        /// @param The texture atlas. Can be null.\n        /// @param The atlas Id string. Can be null.\n        /// @param The virtual UVs.\n        ///\n        /// @return Atlas frame\n        //----------------------------------------------------------------------------\n        TextureAtlas::Frame BuildFrame(const Texture* in_texture, const TextureAtlas* in_textureAtlas, const std::string& in_atlasId, const UVs& in_virtualUVs);\n    }\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/UI/Drawable.h",
    "content": "//\n//  UIDrawable.h\n//  ChilliSource\n//  Created by Scott Downie on 25/07/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_UI_DRAWABLE_H_\n#define _CHILLISOURCE_UI_DRAWABLE_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/UI/Drawable/UIDrawable.h>\n#include <ChilliSource/UI/Drawable/DrawableUIComponent.h>\n#include <ChilliSource/UI/Drawable/UIDrawableDef.h>\n#include <ChilliSource/UI/Drawable/NinePatchUIDrawable.h>\n#include <ChilliSource/UI/Drawable/NinePatchUIDrawableDef.h>\n#include <ChilliSource/UI/Drawable/StandardUIDrawable.h>\n#include <ChilliSource/UI/Drawable/StandardUIDrawableDef.h>\n#include <ChilliSource/UI/Drawable/ThreePatchUIDrawable.h>\n#include <ChilliSource/UI/Drawable/ThreePatchUIDrawableDef.h>\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/UI/ForwardDeclarations.h",
    "content": "//\n//  ForwardDeclarations.h\n//  ChilliSource\n//  Created by Scott Downie on 18/04/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_UI_FORWARDDECLARATIONS_H_\n#define _CHILLISOURCE_UI_FORWARDDECLARATIONS_H_\n\n#include <ChilliSource/Core/Base/StandardMacros.h>\n\n#include <memory>\n\nnamespace ChilliSource\n{\n    //---------------------------------------------------------\n    /// Base\n    //---------------------------------------------------------\n    CS_FORWARDDECLARE_CLASS(Canvas);\n    CS_FORWARDDECLARE_CLASS(CursorSystem);\n    CS_FORWARDDECLARE_CLASS(UIComponent);\n    CS_FORWARDDECLARE_CLASS(UIComponentDesc);\n    CS_FORWARDDECLARE_CLASS(UIComponentFactory);\n    CS_FORWARDDECLARE_CLASS(PropertyLink);\n    CS_FORWARDDECLARE_CLASS(Widget);\n    CS_FORWARDDECLARE_CLASS(WidgetDef);\n    CS_FORWARDDECLARE_CLASS(WidgetDesc);\n    CS_FORWARDDECLARE_CLASS(WidgetDefProvider);\n    CS_FORWARDDECLARE_CLASS(WidgetFactory);\n    CS_FORWARDDECLARE_CLASS(WidgetTemplate);\n    CS_FORWARDDECLARE_CLASS(WidgetTemplateProvider);\n    //---------------------------------------------------------\n    /// Button\n    //---------------------------------------------------------\n    CS_FORWARDDECLARE_CLASS(HighlightUIComponent);\n    CS_FORWARDDECLARE_CLASS(ToggleHighlightUIComponent);\n    //---------------------------------------------------------\n    /// UIDrawable\n    //---------------------------------------------------------\n    CS_FORWARDDECLARE_CLASS(UIDrawable);\n    CS_FORWARDDECLARE_CLASS(DrawableUIComponent);\n    CS_FORWARDDECLARE_CLASS(UIDrawableDef);\n    CS_FORWARDDECLARE_CLASS(NinePatchUIDrawable);\n    CS_FORWARDDECLARE_CLASS(NinePatchUIDrawableDef);\n    CS_FORWARDDECLARE_CLASS(StandardUIDrawable);\n    CS_FORWARDDECLARE_CLASS(StandardUIDrawableDef);\n    CS_FORWARDDECLARE_CLASS(ThreePatchUIDrawable);\n    CS_FORWARDDECLARE_CLASS(ThreePatchUIDrawableDef);\n    //---------------------------------------------------------\n    /// UILayout\n    //---------------------------------------------------------\n    CS_FORWARDDECLARE_CLASS(UILayout);\n    CS_FORWARDDECLARE_CLASS(LayoutUIComponent);\n    CS_FORWARDDECLARE_CLASS(UILayoutDef);\n    CS_FORWARDDECLARE_CLASS(GridUILayout);\n    CS_FORWARDDECLARE_CLASS(GridUILayoutDef);\n    CS_FORWARDDECLARE_CLASS(HListUILayout);\n    CS_FORWARDDECLARE_CLASS(HListUILayoutDef);\n    CS_FORWARDDECLARE_CLASS(VListUILayout);\n    CS_FORWARDDECLARE_CLASS(VListUILayoutDef);\n    //---------------------------------------------------------\n    /// Progress Bar\n    //---------------------------------------------------------\n    CS_FORWARDDECLARE_CLASS(ProgressBarUIComponent);\n    enum class ProgressBarDirection;\n    enum class ProgressBarType;\n    //---------------------------------------------------------\n    /// Slider\n    //---------------------------------------------------------\n    CS_FORWARDDECLARE_CLASS(SliderUIComponent);\n    enum class SliderDirection;\n    //---------------------------------------------------------\n    /// Text\n    //---------------------------------------------------------\n    CS_FORWARDDECLARE_CLASS(TextUIComponent);\n    CS_FORWARDDECLARE_CLASS(TextIcon);\n    CS_FORWARDDECLARE_CLASS(EditableTextUIComponent);\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/UI/Layout/GridUILayout.cpp",
    "content": "//\n//  GridUILayout.cpp\n//  ChilliSource\n//  Created by Scott Downie on 09/06/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/UI/Layout/GridUILayout.h>\n\n#include <ChilliSource/Core/Math/Vector4.h>\n#include <ChilliSource/UI/Base/Widget.h>\n#include <ChilliSource/UI/Layout/LayoutUIComponent.h>\n\nnamespace ChilliSource\n{\n    CS_DEFINE_NAMEDTYPE(GridUILayout);\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    GridUILayout::GridUILayout(LayoutUIComponent* in_layoutComponent, GridUILayout::CellOrder in_cellOrder, u32 in_numRows, u32 in_numCols, const Vector4& in_relMargins, const Vector4& in_absMargins,\n                           f32 in_relHorizSpacing, f32 in_absHorizSpacing, f32 in_relVertSpacing, f32 in_absVertSpacing)\n        : UILayout(in_layoutComponent), m_cellOrder(in_cellOrder), m_numRows(in_numRows), m_numCols(in_numCols), m_marginSizeTop(in_relMargins.x, in_absMargins.x), m_marginSizeRight(in_relMargins.y, in_absMargins.y),\n        m_marginSizeBottom(in_relMargins.z, in_absMargins.z), m_marginSizeLeft(in_relMargins.w, in_absMargins.w), m_spacingSizeH(in_relHorizSpacing, in_absHorizSpacing), m_spacingSizeV(in_relVertSpacing, in_absVertSpacing)\n    {\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    bool GridUILayout::IsA(InterfaceIDType in_interfaceId) const\n    {\n        return (UILayout::InterfaceID == in_interfaceId || GridUILayout::InterfaceID == in_interfaceId);\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    u32 GridUILayout::GetNumRows() const\n    {\n        return m_numRows;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    u32 GridUILayout::GetNumCols() const\n    {\n        return m_numCols;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    Vector4 GridUILayout::GetRelativeMargins() const\n    {\n        return Vector4(m_marginSizeTop.x, m_marginSizeRight.x, m_marginSizeBottom.x, m_marginSizeLeft.x);\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    Vector4 GridUILayout::GetAbsoluteMargins() const\n    {\n        return Vector4(m_marginSizeTop.y, m_marginSizeRight.y, m_marginSizeBottom.y, m_marginSizeLeft.y);\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    f32 GridUILayout::GetRelativeHSpacing() const\n    {\n        return m_spacingSizeH.x;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    f32 GridUILayout::GetAbsoluteHSpacing() const\n    {\n        return m_spacingSizeH.y;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    f32 GridUILayout::GetRelativeVSpacing() const\n    {\n        return m_spacingSizeV.x;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    f32 GridUILayout::GetAbsoluteVSpacing() const\n    {\n        return m_spacingSizeV.y;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    GridUILayout::CellOrder GridUILayout::GetCellOrder() const\n    {\n        return m_cellOrder;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void GridUILayout::SetNumRows(u32 in_numRos)\n    {\n        CS_ASSERT(in_numRos > 0, \"Cannot create a grid with 0 rows\");\n        m_numRows = in_numRos;\n        \n        GetComponent()->OnLayoutChanged();\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void GridUILayout::SetNumCols(u32 in_numCols)\n    {\n        CS_ASSERT(in_numCols > 0, \"Cannot create a grid with 0 columns\");\n        m_numCols = in_numCols;\n        \n        GetComponent()->OnLayoutChanged();\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void GridUILayout::SetRelativeMargins(f32 in_top, f32 in_right, f32 in_bottom, f32 in_left)\n    {\n        m_marginSizeTop.x = in_top;\n        m_marginSizeRight.x = in_right;\n        m_marginSizeBottom.x = in_bottom;\n        m_marginSizeLeft.x = in_left;\n        \n        GetComponent()->OnLayoutChanged();\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void GridUILayout::SetAbsoluteMargins(f32 in_top, f32 in_right, f32 in_bottom, f32 in_left)\n    {\n        m_marginSizeTop.y = in_top;\n        m_marginSizeRight.y = in_right;\n        m_marginSizeBottom.y = in_bottom;\n        m_marginSizeLeft.y = in_left;\n        \n        GetComponent()->OnLayoutChanged();\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void GridUILayout::SetRelativeHSpacing(f32 in_spacing)\n    {\n        m_spacingSizeH.x = in_spacing;\n        \n        GetComponent()->OnLayoutChanged();\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void GridUILayout::SetAbsoluteHSpacing(f32 in_spacing)\n    {\n        m_spacingSizeH.y = in_spacing;\n        \n        GetComponent()->OnLayoutChanged();\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void GridUILayout::SetRelativeVSpacing(f32 in_spacing)\n    {\n        m_spacingSizeV.x = in_spacing;\n        \n        GetComponent()->OnLayoutChanged();\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void GridUILayout::SetAbsoluteVSpacing(f32 in_spacing)\n    {\n        m_spacingSizeV.y = in_spacing;\n        \n        GetComponent()->OnLayoutChanged();\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void GridUILayout::SetCellOrder(CellOrder in_order)\n    {\n        m_cellOrder = in_order;\n        \n        GetComponent()->OnLayoutChanged();\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void GridUILayout::BuildLayout()\n    {\n        CS_ASSERT(GetComponent()->GetWidget() != nullptr, \"Cannot build layout when UILayout UIComponent is not attached to widget.\");\n        \n        //The list doesn't care about the widgets as the size and position of each cell\n        //is only relative to the number of cells and the root widget size\n        Vector2 rootSize = GetComponent()->GetWidget()->GetFinalSize();\n        \n        //The margins and spacing are relative to the root widget size\n        m_finalSpacingSizeH = m_spacingSizeH.y + (rootSize.x * m_spacingSizeH.x);\n        m_finalSpacingSizeV = m_spacingSizeV.y + (rootSize.y * m_spacingSizeV.x);\n        \n        f32 finalMarginTop = m_marginSizeTop.y + (rootSize.y * m_marginSizeTop.x);\n        f32 finalMarginBottom = m_marginSizeBottom.y + (rootSize.y * m_marginSizeBottom.x);\n        f32 finalMarginLeft = m_marginSizeLeft.y + (rootSize.x * m_marginSizeLeft.x);\n        f32 finalMarginRight = m_marginSizeRight.y + (rootSize.x * m_marginSizeRight.x);\n        \n        m_cellSize.x = (rootSize.x - finalMarginLeft - finalMarginRight - (m_finalSpacingSizeH * (m_numCols-1)))/m_numCols;\n        m_cellSize.y = (rootSize.y - finalMarginTop - finalMarginBottom - (m_finalSpacingSizeV * (m_numRows-1)))/m_numRows;\n        \n        m_firstCellPosX = finalMarginLeft;\n        m_firstCellPosY = rootSize.y - finalMarginTop;\n    }\n    //------------------------------------------------------------------------------\n    /// The cell size if fixed and uniform so the index is not required\n    //------------------------------------------------------------------------------\n    Vector2 GridUILayout::GetSizeForIndex(u32 in_index) const\n    {\n        CS_ASSERT(in_index < (m_numRows * m_numCols), \"Cannot have more items in grid than number of cells(\" + ToString(m_numRows * m_numCols) + \")\");\n        return m_cellSize;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    Vector2 GridUILayout::GetPositionForIndex(u32 in_index) const\n    {\n        //Aligned to the middle centre in cell space\n        CS_ASSERT(in_index < (m_numRows * m_numCols), \"Cannot have more items in grid than number of cells(\" + ToString(m_numRows * m_numCols) + \")\");\n        \n        u32 indexCol = 0;\n        u32 indexRow = 0;\n        switch(m_cellOrder)\n        {\n            case CellOrder::k_colMajor:\n                indexCol = in_index / m_numRows;\n                indexRow = in_index % m_numRows;\n                break;\n            case CellOrder::k_rowMajor:\n                indexCol = in_index % m_numCols;\n                indexRow = in_index / m_numCols;\n                break;\n        }\n    \n        //Col\n        f32 spacingSizeH = indexCol == 0 ? 0.0f : m_finalSpacingSizeH;\n        f32 xPos = m_firstCellPosX + (m_cellSize.x * (indexCol + 1)) + (spacingSizeH * indexCol);\n        xPos -= (m_cellSize.x * 0.5f);\n        \n        //Row\n        f32 spacingSizeV = indexRow == 0 ? 0.0f : m_finalSpacingSizeV;\n        f32 yPos = m_firstCellPosY - (m_cellSize.y * (indexRow + 1)) - (spacingSizeV * indexRow);\n        yPos += (m_cellSize.y * 0.5f);\n        \n        return Vector2(xPos, yPos);\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/UI/Layout/GridUILayout.h",
    "content": "//\n//  GridUILayout.h\n//  ChilliSource\n//  Created by Scott Downie on 09/06/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_UI_LAYOUT_GRIDUILAYOUT_H_\n#define _CHILLISOURCE_UI_LAYOUT_GRIDUILAYOUT_H_\n\n#include <ChilliSource/ChilliSource.h>\n\n#include <ChilliSource/Core/Math/Vector2.h>\n#include <ChilliSource/Core/Math/Vector4.h>\n#include <ChilliSource/UI/Layout/UILayout.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    /// Lays out widgets in a grid where each widget has a single cell. The cells\n    /// have spacing between them and the entire grid has a surrounding margin.\n    ///\n    /// The grid size is fixed and will not expand\n    ///\n    /// @author S Downie\n    //------------------------------------------------------------------------------\n    class GridUILayout final : public UILayout\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(GridUILayout);\n        //------------------------------------------------------------------------------\n        /// Describes the increment order of the cells.\n        ///\n        /// Row. Major: 0123\n        ///             4567\n        ///\n        /// Col. Major: 0246\n        ///             1357\n        ///\n        /// @author S Downie\n        //------------------------------------------------------------------------------\n        enum class CellOrder\n        {\n            k_colMajor,\n            k_rowMajor\n        };\n        //------------------------------------------------------------------------------\n        /// Allows querying of whether or not this system implements the interface\n        /// described by the given interface Id. Typically this is not called directly\n        /// as the templated equivalent IsA<Interface>() is preferred.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The interface Id.\n        ///\n        /// @return Whether or not the interface is implemented.\n        //------------------------------------------------------------------------------\n        bool IsA(InterfaceIDType in_interfaceId) const override;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The number of rows that make up the grid. The size of each row is\n        /// based on the number of rows and the overall layout size, governed by the\n        /// owning widget.\n        //------------------------------------------------------------------------------\n        u32 GetNumRows() const;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The number of columns that make up the grid. The size of each column\n        /// is based on the number of columns and the overall layout size, governed by\n        /// the owning widget.\n        //------------------------------------------------------------------------------\n        u32 GetNumCols() const;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The relative border size margins for each edge. These are relative\n        /// to the overall layout size (i.e owning widget size). X is top, Y is right,\n        /// Z is bottom and W is left.\n        //------------------------------------------------------------------------------\n        Vector4 GetRelativeMargins() const;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The absolute border size margins for each edge. X is top, Y is\n        /// right, Z is bottom and W is left.\n        //------------------------------------------------------------------------------\n        Vector4 GetAbsoluteMargins() const;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The relative spacing between items horizontally. This is relative to\n        /// the overall layout size (i.e. the owning widget)\n        //------------------------------------------------------------------------------\n        f32 GetRelativeHSpacing() const;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The absolute spacing between items horizontally.\n        //------------------------------------------------------------------------------\n        f32 GetAbsoluteHSpacing() const;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return the relative spacing between items vertically. This is relative to\n        /// the overall layout size (i.e. the owning widget)\n        //------------------------------------------------------------------------------\n        f32 GetRelativeVSpacing() const;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The absolute spacing between items vertically.\n        //------------------------------------------------------------------------------\n        f32 GetAbsoluteVSpacing() const;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return the cell order to be row or column major\n        //------------------------------------------------------------------------------\n        CellOrder GetCellOrder() const;\n        //------------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param The number of rows that make up the grid. The size of each row is\n        /// based on the number of rows and the overall layout size, governed by the\n        /// owning widget\n        //------------------------------------------------------------------------------\n        void SetNumRows(u32 in_numRows);\n        //------------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param The number of columns that make up the grid. The size of each column\n        /// is based on the number of columns and the overall layout size, governed by\n        /// the owning widget\n        //------------------------------------------------------------------------------\n        void SetNumCols(u32 in_numCols);\n        //------------------------------------------------------------------------------\n        /// Set the relative border size margins for each edge. These are relative to\n        /// the overall layout size (i.e owning widget size).\n        ///\n        /// @author S Downie\n        ///\n        /// @param Top\n        /// @param Right\n        /// @param Bottom\n        /// @param Left\n        //------------------------------------------------------------------------------\n        void SetRelativeMargins(f32 in_top, f32 in_right, f32 in_bottom, f32 in_left);\n        //------------------------------------------------------------------------------\n        /// Set the absolute border size margins for each edge.\n        ///\n        /// @author S Downie\n        ///\n        /// @param Top\n        /// @param Right\n        /// @param Bottom\n        /// @param Left\n        //------------------------------------------------------------------------------\n        void SetAbsoluteMargins(f32 in_top, f32 in_right, f32 in_bottom, f32 in_left);\n        //------------------------------------------------------------------------------\n        /// Set the relative spacing between items horizontally. This is relative to the\n        /// overall layout size (i.e. the owning widget)\n        ///\n        /// @author S Downie\n        ///\n        /// @param Spacing\n        //------------------------------------------------------------------------------\n        void SetRelativeHSpacing(f32 in_spacing);\n        //------------------------------------------------------------------------------\n        /// Set the absolute spacing between items horizontally.\n        ///\n        /// @author S Downie\n        ///\n        /// @param Spacing\n        //------------------------------------------------------------------------------\n        void SetAbsoluteHSpacing(f32 in_spacing);\n        //------------------------------------------------------------------------------\n        /// Set the relative spacing between items vertically. This is relative to the\n        /// overall layout size (i.e. the owning widget)\n        ///\n        /// @author S Downie\n        ///\n        /// @param Spacing\n        //------------------------------------------------------------------------------\n        void SetRelativeVSpacing(f32 in_spacing);\n        //------------------------------------------------------------------------------\n        /// Set the absolute spacing between items vertically.\n        ///\n        /// @author S Downie\n        ///\n        /// @param Spacing\n        //------------------------------------------------------------------------------\n        void SetAbsoluteVSpacing(f32 in_spacing);\n        //------------------------------------------------------------------------------\n        /// Set the cell order to be row or column major\n        ///\n        /// @author S Downie\n        ///\n        /// @param Cell order\n        //------------------------------------------------------------------------------\n        void SetCellOrder(CellOrder in_order);\n        \n    private:\n        friend class GridUILayoutDef;\n        friend class HListUILayout;\n        friend class VListUILayout;\n        //------------------------------------------------------------------------------\n        /// Constructor. Creates a grid layout with the given properties.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The owning component.\n        /// @param The cell order.\n        /// @param The number of rows.\n        /// @param The number of columns.\n        /// @param The relative margins.\n        /// @param The absolute margins.\n        /// @param The relative horizontal spacing.\n        /// @param The absolute horizontal spacing.\n        /// @param The relative vertical spacing.\n        /// @param The absolute vertical spacing.\n        //------------------------------------------------------------------------------\n        GridUILayout(LayoutUIComponent* in_layoutComponent, GridUILayout::CellOrder in_cellOrder, u32 in_numRows, u32 in_numCols, const Vector4& in_relMargins, const Vector4& in_absMargins,\n                   f32 in_relHorizSpacing, f32 in_absHorizSpacing, f32 in_relVertSpacing, f32 in_absVertSpacing);\n        //------------------------------------------------------------------------------\n        /// Create the grid layout sizes and positions based on the current layout\n        /// properties and the owning widget.\n        ///\n        /// @author S Downie\n        //------------------------------------------------------------------------------\n        void BuildLayout() override;\n        //------------------------------------------------------------------------------\n        /// Get the final size of the widget that occupies the space at the given index\n        ///\n        /// @author S Downie\n        ///\n        /// @param Space index\n        ///\n        /// @return Final absolute screen size\n        //------------------------------------------------------------------------------\n        Vector2 GetSizeForIndex(u32 in_index) const override;\n        //------------------------------------------------------------------------------\n        /// Get the local position of the widget that occupies the space at the given\n        /// index\n        ///\n        /// @author S Downie\n        ///\n        /// @param Space index\n        ///\n        /// @return Local position in layout space (aligned middle centre of the cell)\n        //------------------------------------------------------------------------------\n        Vector2 GetPositionForIndex(u32 in_index) const override;\n        \n        Vector2 m_cellSize;\n        \n        Vector2 m_marginSizeTop;\n        Vector2 m_marginSizeBottom;\n        Vector2 m_marginSizeLeft;\n        Vector2 m_marginSizeRight;\n        \n        Vector2 m_spacingSizeH;\n        Vector2 m_spacingSizeV;\n        f32 m_finalSpacingSizeH = 0.0f;\n        f32 m_finalSpacingSizeV = 0.0f;\n        f32 m_firstCellPosX = 0.0f;\n        f32 m_firstCellPosY = 0.0f;\n        \n        u32 m_numRows = 1;\n        u32 m_numCols = 1;\n        \n        CellOrder m_cellOrder = CellOrder::k_colMajor;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/UI/Layout/GridUILayoutDef.cpp",
    "content": "//\n//  GridUILayoutDef.cpp\n//  ChilliSource\n//  Created by Ian Copland on 07/01/2015.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2015 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/UI/Layout/GridUILayoutDef.h>\n\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/String/StringParser.h>\n#include <ChilliSource/UI/Layout/GridUILayout.h>\n\n#include <json/json.h>\n\nnamespace ChilliSource\n{\n    namespace\n    {\n        //------------------------------------------------------------------------------\n        /// Parses the given cell order string. If the string is not a valid cell order\n        /// the app is considered to be in an irrecoverable state and will terminate.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The cell order in string form.\n        ///\n        /// @return The parsed cell order.\n        //------------------------------------------------------------------------------\n        GridUILayout::CellOrder ParseCellOrder(const std::string& in_cellOrderString)\n        {\n            const char k_columnMajor[] = \"colmajor\";\n            const char k_rowMajor[] = \"rowmajor\";\n\n            std::string cellOrderString = in_cellOrderString;\n            StringUtils::ToLowerCase(cellOrderString);\n\n            if(cellOrderString == k_columnMajor)\n            {\n                return GridUILayout::CellOrder::k_colMajor;\n            }\n            else if(cellOrderString == k_rowMajor)\n            {\n                return GridUILayout::CellOrder::k_rowMajor;\n            }\n            \n            CS_LOG_FATAL(\"Unknown GridUILayout cell order: \" + in_cellOrderString);\n            return GridUILayout::CellOrder::k_colMajor;\n        }\n    }\n    \n    CS_DEFINE_NAMEDTYPE(GridUILayoutDef);\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    GridUILayoutDef::GridUILayoutDef(const Json::Value& in_json)\n    {\n        const char k_typeKey[] = \"Type\";\n        const char k_cellOrderKey[] = \"CellOrder\";\n        const char k_numRowsKey[] = \"NumRows\";\n        const char k_numColumnsKey[] = \"NumCols\";\n        const char k_relativeMarginsKey[] = \"RelMargins\";\n        const char k_absoluteMarginsKey[] = \"AbsMargins\";\n        const char k_relativeHSpacingKey[] = \"RelHSpacing\";\n        const char k_absoluteHSpacingKey[] = \"AbsHSpacing\";\n        const char k_relativeVSpacingKey[] = \"RelVSpacing\";\n        const char k_absoluteVSpacingKey[] = \"AbsVSpacing\";\n\n        for(auto it = in_json.begin(); it != in_json.end(); ++it)\n        {\n            CS_ASSERT((*it).isString() == true, \"All properties in a UILayout Def must be a string: \" + std::string(it.memberName()));\n\n            std::string key = it.memberName();\n            std::string value = (*it).asString();\n\n            if (key == k_relativeMarginsKey)\n            {\n                m_relativeMargins = ParseVector4(value);\n            }\n            else if (key == k_absoluteMarginsKey)\n            {\n                m_absoluteMargins = ParseVector4(value);\n            }\n            else if (key == k_numRowsKey)\n            {\n                m_numRows = ParseU32(value);\n            }\n            else if (key == k_numColumnsKey)\n            {\n                m_numCols = ParseU32(value);\n            }\n            else if (key == k_relativeHSpacingKey)\n            {\n                m_relativeHSpacing = ParseF32(value);\n            }\n            else if (key == k_absoluteHSpacingKey)\n            {\n                m_absoluteHSpacing = ParseF32(value);\n            }\n            else if (key == k_relativeVSpacingKey)\n            {\n                m_relativeVSpacing = ParseF32(value);\n            }\n            else if (key == k_absoluteVSpacingKey)\n            {\n                m_absoluteVSpacing = ParseF32(value);\n            }\n            else if (key == k_cellOrderKey)\n            {\n                m_cellOrder = ParseCellOrder(value);\n            }\n            else if (key == k_typeKey)\n            {\n                //ignore\n            }\n            else\n            {\n                CS_LOG_FATAL(\"Invalid property found in a Grid layout description: \" + key);\n            }\n        }\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    GridUILayoutDef::GridUILayoutDef(GridUILayout::CellOrder in_cellOrder, u32 in_numRows, u32 in_numCols, const Vector4& in_relMargins, const Vector4& in_absMargins,\n                  f32 in_relHorizSpacing, f32 in_absHorizSpacing, f32 in_relVertSpacing, f32 in_absVertSpacing)\n        : m_cellOrder(in_cellOrder), m_numRows(in_numRows), m_numCols(in_numCols), m_relativeMargins(in_relMargins), m_absoluteMargins(in_absMargins), m_relativeHSpacing(in_relHorizSpacing),\n          m_absoluteHSpacing(in_absHorizSpacing), m_relativeVSpacing(in_relVertSpacing), m_absoluteVSpacing(in_absVertSpacing)\n    {\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    bool GridUILayoutDef::IsA(InterfaceIDType in_interfaceId) const\n    {\n        return (UILayoutDef::InterfaceID == in_interfaceId || GridUILayoutDef::InterfaceID == in_interfaceId);\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    u32 GridUILayoutDef::GetNumRows() const\n    {\n        return m_numRows;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    u32 GridUILayoutDef::GetNumCols() const\n    {\n        return m_numCols;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    Vector4 GridUILayoutDef::GetRelativeMargins() const\n    {\n        return m_relativeMargins;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    Vector4 GridUILayoutDef::GetAbsoluteMargins() const\n    {\n        return m_absoluteMargins;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    f32 GridUILayoutDef::GetRelativeHSpacing() const\n    {\n        return m_relativeHSpacing;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    f32 GridUILayoutDef::GetAbsoluteHSpacing() const\n    {\n        return m_absoluteHSpacing;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    f32 GridUILayoutDef::GetRelativeVSpacing() const\n    {\n        return m_relativeVSpacing;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    f32 GridUILayoutDef::GetAbsoluteVSpacing() const\n    {\n        return m_absoluteVSpacing;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    GridUILayout::CellOrder GridUILayoutDef::GetCellOrder() const\n    {\n        return m_cellOrder;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    UILayoutUPtr GridUILayoutDef::CreateLayout(LayoutUIComponent* in_owner) const\n    {\n        return UILayoutUPtr(new GridUILayout(in_owner, m_cellOrder, m_numRows, m_numCols, m_relativeMargins, m_absoluteMargins, m_relativeHSpacing, m_absoluteHSpacing, m_relativeVSpacing, m_absoluteVSpacing));\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/UI/Layout/GridUILayoutDef.h",
    "content": "//\n//  GridUILayoutDef.h\n//  ChilliSource\n//  Created by Ian Copland on 07/01/2015.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2015 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_UI_LAYOUT_GRIDUILAYOUTDEF_H_\n#define _CHILLISOURCE_UI_LAYOUT_GRIDUILAYOUTDEF_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Math/Vector2.h>\n#include <ChilliSource/Core/Math/Vector4.h>\n#include <ChilliSource/UI/Layout/GridUILayout.h>\n#include <ChilliSource/UI/Layout/UILayoutDef.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    /// A definition of a Grid UILayout which can be built from a json object. This is\n    /// effectively an immutable container for the properties of a Grid UILayout.\n    ///\n    /// A Grid UILayout Def contains the following property in addition to those\n    /// defined in the UILayout Def base class documentation:\n    ///\n    /// \"CellOrder\": The order that cells will be placed: row or column major order.\n    ///\n    /// \"NumRows\": The number of rows.\n    ///\n    /// \"NumCols\": The number of columns.\n    ///\n    /// \"RelMargins\": The relative padding from the widget edge to the cells\n    /// in any layout.\n    ///\n    /// \"AbsMargins\": The absolute padding from the widget edge to the cells\n    /// in any layout.\n    ///\n    /// \"RelHSpacing\": The relative horizontal spacing between cells.\n    ///\n    /// \"AbsHSpacing\": The absolute horizonal spacing between cells.\n    ///\n    /// \"RelVSpacing\": The relative vertical spacing between cells.\n    ///\n    /// \"AbsVSpacing\": The absolute vertical spacing between cells.\n    ///\n    ///\n    /// @author Ian Copland\n    //------------------------------------------------------------------------------\n    class GridUILayoutDef final : public UILayoutDef\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(GridUILayoutDef);\n        //------------------------------------------------------------------------------\n        /// Constructor. Creates an empty grid layout definition.\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------------------------------------\n        GridUILayoutDef() = default;\n        //------------------------------------------------------------------------------\n        /// Constructor. Creates a standard grid layout definition from json.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The JSON object containing the drawable properties.\n        //------------------------------------------------------------------------------\n        GridUILayoutDef(const Json::Value& in_json);\n        //------------------------------------------------------------------------------\n        /// Constructor. Creates a grid layout definition with the given properties.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The cell order.\n        /// @param The number of rows.\n        /// @param The number of columns.\n        /// @param The relative margins.\n        /// @param The absolute margins.\n        /// @param The relative horizontal spacing.\n        /// @param The absolute horizontal spacing.\n        /// @param The relative vertical spacing.\n        /// @param The absolute vertical spacing.\n        //------------------------------------------------------------------------------\n        GridUILayoutDef(GridUILayout::CellOrder in_cellOrder, u32 in_numRows, u32 in_numCols, const Vector4& in_relMargins, const Vector4& in_absMargins,\n                      f32 in_relHorizSpacing, f32 in_absHorizSpacing, f32 in_relVertSpacing, f32 in_absVertSpacing);\n        //------------------------------------------------------------------------------\n        /// Allows querying of whether or not this system implements the interface\n        /// described by the given interface Id. Typically this is not called directly\n        /// as the templated equivalent IsA<Interface>() is preferred.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The interface Id.\n        ///\n        /// @return Whether or not the interface is implemented.\n        //------------------------------------------------------------------------------\n        bool IsA(InterfaceIDType in_interfaceId) const override;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return the cell order to be row or column major.\n        //------------------------------------------------------------------------------\n        GridUILayout::CellOrder GetCellOrder() const;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The number of rows that make up the grid. The size of each row is\n        /// based on the number of rows and the overall layout size, governed by the\n        /// owning widget.\n        //------------------------------------------------------------------------------\n        u32 GetNumRows() const;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The number of columns that make up the grid. The size of each column\n        /// is based on the number of columns and the overall layout size, governed by\n        /// the owning widget.\n        //------------------------------------------------------------------------------\n        u32 GetNumCols() const;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The relative border size margins for each edge. These are relative\n        /// to the overall layout size (i.e owning widget size). X is top, Y is right,\n        /// Z is bottom and W is left.\n        //------------------------------------------------------------------------------\n        Vector4 GetRelativeMargins() const;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The absolute border size margins for each edge. X is top, Y is\n        /// right, Z is bottom and W is left.\n        //------------------------------------------------------------------------------\n        Vector4 GetAbsoluteMargins() const;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The relative spacing between items horizontally. This is relative to\n        /// the overall layout size (i.e. the owning widget)\n        //------------------------------------------------------------------------------\n        f32 GetRelativeHSpacing() const;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The absolute spacing between items horizontally.\n        //------------------------------------------------------------------------------\n        f32 GetAbsoluteHSpacing() const;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return the relative spacing between items vertically. This is relative to\n        /// the overall layout size (i.e. the owning widget)\n        //------------------------------------------------------------------------------\n        f32 GetRelativeVSpacing() const;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The absolute spacing between items vertically.\n        //------------------------------------------------------------------------------\n        f32 GetAbsoluteVSpacing() const;\n        \n    private:\n        //------------------------------------------------------------------------------\n        /// Creates a new instance of a grid layout as described by this definition.\n        /// This should typically only be called by a layout component.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The owning component.\n        ///\n        /// @return a new layout instance.\n        //------------------------------------------------------------------------------\n        UILayoutUPtr CreateLayout(LayoutUIComponent* in_owner) const override;\n        \n        GridUILayout::CellOrder m_cellOrder = GridUILayout::CellOrder::k_rowMajor;\n        u32 m_numRows = 1;\n        u32 m_numCols = 1;\n        Vector4 m_relativeMargins;\n        Vector4 m_absoluteMargins;\n        f32 m_relativeHSpacing = 0.0f;\n        f32 m_absoluteHSpacing = 0.0f;\n        f32 m_relativeVSpacing = 0.0f;\n        f32 m_absoluteVSpacing = 0.0f;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/UI/Layout/HListUILayout.cpp",
    "content": "//\n//  HListUILayout.cpp\n//  ChilliSource\n//  Created by Scott Downie on 23/04/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/UI/Layout/HListUILayout.h>\n\n#include <ChilliSource/Core/Math/Vector4.h>\n#include <ChilliSource/UI/Base/Widget.h>\n\nnamespace ChilliSource\n{\n    CS_DEFINE_NAMEDTYPE(HListUILayout);\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    HListUILayout::HListUILayout(LayoutUIComponent* in_layoutComponent, u32 in_numCells, const Vector4& in_relMargins, const Vector4& in_absMargins, f32 in_relSpacing, f32 in_absSpacing)\n        : UILayout(in_layoutComponent), m_gridLayout(in_layoutComponent, GridUILayout::CellOrder::k_rowMajor, 1, in_numCells, in_relMargins, in_absMargins, in_relSpacing, in_absSpacing, 0.0f, 0.0f)\n    {\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    bool HListUILayout::IsA(InterfaceIDType in_interfaceId) const\n    {\n        return (UILayout::InterfaceID == in_interfaceId || HListUILayout::InterfaceID == in_interfaceId);\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    u32 HListUILayout::GetNumCells() const\n    {\n        return m_gridLayout.GetNumCols();\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    Vector4 HListUILayout::GetRelativeMargins() const\n    {\n        return m_gridLayout.GetRelativeMargins();\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    Vector4 HListUILayout::GetAbsoluteMargins() const\n    {\n        return m_gridLayout.GetAbsoluteMargins();\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    f32 HListUILayout::GetRelativeSpacing() const\n    {\n        return m_gridLayout.GetRelativeHSpacing();\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    f32 HListUILayout::GetAbsoluteSpacing() const\n    {\n        return m_gridLayout.GetAbsoluteHSpacing();\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void HListUILayout::SetNumCells(u32 in_numCells)\n    {\n        CS_ASSERT(in_numCells > 0, \"Cannot create a list with 0 cells\");\n        m_gridLayout.SetNumCols(in_numCells);\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void HListUILayout::SetRelativeMargins(f32 in_top, f32 in_right, f32 in_bottom, f32 in_left)\n    {\n        m_gridLayout.SetRelativeMargins(in_top, in_right, in_bottom, in_left);\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void HListUILayout::SetAbsoluteMargins(f32 in_top, f32 in_right, f32 in_bottom, f32 in_left)\n    {\n        m_gridLayout.SetAbsoluteMargins(in_top, in_right, in_bottom, in_left);\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void HListUILayout::SetRelativeSpacing(f32 in_spacing)\n    {\n        m_gridLayout.SetRelativeHSpacing(in_spacing);\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void HListUILayout::SetAbsoluteSpacing(f32 in_spacing)\n    {\n        m_gridLayout.SetAbsoluteHSpacing(in_spacing);\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void HListUILayout::BuildLayout()\n    {\n        m_gridLayout.BuildLayout();\n    }\n    //------------------------------------------------------------------------------\n    /// The cell size if fixed and uniform so the index is not required\n    //------------------------------------------------------------------------------\n    Vector2 HListUILayout::GetSizeForIndex(u32 in_index) const\n    {\n        return m_gridLayout.GetSizeForIndex(in_index);\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    Vector2 HListUILayout::GetPositionForIndex(u32 in_index) const\n    {\n        return m_gridLayout.GetPositionForIndex(in_index);\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/UI/Layout/HListUILayout.h",
    "content": "//\n//  HListUILayout.h\n//  ChilliSource\n//  Created by Scott Downie on 09/06/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n\n#ifndef _CHILLISOURCE_UI_LAYOUT_HLISTUILAYOUT_H_\n#define _CHILLISOURCE_UI_LAYOUT_HLISTUILAYOUT_H_\n\n#include <ChilliSource/ChilliSource.h>\n\n#include <ChilliSource/Core/Math/Vector2.h>\n#include <ChilliSource/UI/Layout/GridUILayout.h>\n#include <ChilliSource/UI/Layout/UILayout.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    /// Lays out widgets in a horizontal list where each widget has a single column.\n    /// The columns have spacing between them and the entire list has a surrounding\n    /// margin. The list is filled left to right.\n    ///\n    /// The list size is fixed and will not expand\n    ///\n    /// @author S Downie\n    //------------------------------------------------------------------------------\n    class HListUILayout final : public UILayout\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(HListUILayout);\n        //------------------------------------------------------------------------------\n        /// Allows querying of whether or not this system implements the interface\n        /// described by the given interface Id. Typically this is not called directly\n        /// as the templated equivalent IsA<Interface>() is preferred.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The interface Id.\n        ///\n        /// @return Whether or not the interface is implemented.\n        //------------------------------------------------------------------------------\n        bool IsA(InterfaceIDType in_interfaceId) const override;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The number of cells that make up the list. The size of each cell is\n        /// based on the number of cells and the overall layout size, governed by the\n        /// owning widget\n        //------------------------------------------------------------------------------\n        u32 GetNumCells() const;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The relative border size margins for each edge. These are relative\n        /// to the overall layout size (i.e owning widget size).X is top, Y is right,\n        /// Z is bottom and W is left.\n        //------------------------------------------------------------------------------\n        Vector4 GetRelativeMargins() const;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The absolute border size margins for each edge. X is top, Y is\n        /// right, Z is bottom and W is left.\n        //------------------------------------------------------------------------------\n        Vector4 GetAbsoluteMargins() const;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The relative spacing between items. This is relative to the overall\n        /// layout size (i.e. the owning widget)\n        //------------------------------------------------------------------------------\n        f32 GetRelativeSpacing() const;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The absolute spacing between items.\n        //------------------------------------------------------------------------------\n        f32 GetAbsoluteSpacing() const;\n        //------------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param The number of cells that make up the list. The size of each cell is\n        /// based on the number of cells and the overall layout size, governed by the\n        /// owning widget\n        //------------------------------------------------------------------------------\n        void SetNumCells(u32 in_numCells);\n        //------------------------------------------------------------------------------\n        /// Set the relative border size margins for each edge. These are relative to\n        /// the overall layout size (i.e owning widget size).\n        ///\n        /// @author S Downie\n        ///\n        /// @param Top\n        /// @param Right\n        /// @param Bottom\n        /// @param Left\n        //------------------------------------------------------------------------------\n        void SetRelativeMargins(f32 in_top, f32 in_right, f32 in_bottom, f32 in_left);\n        //------------------------------------------------------------------------------\n        /// Set the absolute border size margins for each edge.\n        ///\n        /// @author S Downie\n        ///\n        /// @param Top\n        /// @param Right\n        /// @param Bottom\n        /// @param Left\n        //------------------------------------------------------------------------------\n        void SetAbsoluteMargins(f32 in_top, f32 in_right, f32 in_bottom, f32 in_left);\n        //------------------------------------------------------------------------------\n        /// Set the relative spacing between items. This is relative to the overall\n        /// layout size (i.e. the owning widget)\n        ///\n        /// @author S Downie\n        ///\n        /// @param Spacing\n        //------------------------------------------------------------------------------\n        void SetRelativeSpacing(f32 in_spacing);\n        //------------------------------------------------------------------------------\n        /// Set the absolute spacing between items.\n        ///\n        /// @author S Downie\n        ///\n        /// @param Spacing\n        //------------------------------------------------------------------------------\n        void SetAbsoluteSpacing(f32 in_spacing);\n        \n    private:\n        friend class HListUILayoutDef;\n        //------------------------------------------------------------------------------\n        /// Constructor. Creates a hlist layout with the given properties.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The owning component.\n        /// @param The number of cells.\n        /// @param The relative margins.\n        /// @param The absolute margins.\n        /// @param The relative spacing.\n        /// @param The absolute spacing.\n        //------------------------------------------------------------------------------\n        HListUILayout(LayoutUIComponent* in_layoutComponent, u32 in_numCells, const Vector4& in_relMargins, const Vector4& in_absMargins, f32 in_relSpacing, f32 in_absSpacing);\n        //------------------------------------------------------------------------------\n        /// Create the list layout sizes and positions based on the current layout\n        /// properties and the owning widget.\n        ///\n        /// @author S Downie\n        //------------------------------------------------------------------------------\n        void BuildLayout() override;\n        //------------------------------------------------------------------------------\n        /// Get the final size of the widget that occupies the space at the given index\n        ///\n        /// @author S Downie\n        ///\n        /// @param Space index\n        ///\n        /// @return Final absolute screen size\n        //------------------------------------------------------------------------------\n        Vector2 GetSizeForIndex(u32 in_index) const override;\n        //------------------------------------------------------------------------------\n        /// Get the local position of the widget that occupies the space at the given index\n        ///\n        /// @author S Downie\n        ///\n        /// @param Space index\n        ///\n        /// @return Local position in layout space (aligned middle centre of the cell)\n        //------------------------------------------------------------------------------\n        Vector2 GetPositionForIndex(u32 in_index) const override;\n        \n        GridUILayout m_gridLayout;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/UI/Layout/HListUILayoutDef.cpp",
    "content": "//\n//  HListUILayoutDef.cpp\n//  ChilliSource\n//  Created by Ian Copland on 07/01/2015.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2015 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/UI/Layout/HListUILayoutDef.h>\n\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/String/StringParser.h>\n#include <ChilliSource/UI/Layout/HListUILayout.h>\n\n#include <json/json.h>\n\nnamespace ChilliSource\n{\n    CS_DEFINE_NAMEDTYPE(HListUILayoutDef);\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    HListUILayoutDef::HListUILayoutDef(const Json::Value& in_json)\n    {\n        const char k_typeKey[] = \"Type\";\n        const char k_numCellsKey[] = \"NumCells\";\n        const char k_relativeMarginsKey[] = \"RelMargins\";\n        const char k_absoluteMarginsKey[] = \"AbsMargins\";\n        const char k_relativeSpacingKey[] = \"RelSpacing\";\n        const char k_absoluteSpacingKey[] = \"AbsSpacing\";\n        \n        for(auto it = in_json.begin(); it != in_json.end(); ++it)\n        {\n            CS_ASSERT((*it).isString() == true, \"All properties in a UILayout Description must be a string: \" + std::string(it.memberName()));\n            \n            std::string key = it.memberName();\n            std::string value = (*it).asString();\n            \n            if (key == k_relativeMarginsKey)\n            {\n                m_relativeMargins = ParseVector4(value);\n            }\n            else if (key == k_absoluteMarginsKey)\n            {\n                m_absoluteMargins = ParseVector4(value);\n            }\n            else if (key == k_numCellsKey)\n            {\n                m_numCells = ParseU32(value);\n            }\n            else if (key == k_relativeSpacingKey)\n            {\n                m_relativeSpacing = ParseF32(value);\n            }\n            else if (key == k_absoluteSpacingKey)\n            {\n                m_absoluteSpacing = ParseF32(value);\n            }\n            else if (key == k_typeKey)\n            {\n                //ignore\n            }\n            else\n            {\n                CS_LOG_FATAL(\"Invalid property found in a List layout description: \" + key);\n            }\n        }\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    HListUILayoutDef::HListUILayoutDef(u32 in_numCells, const Vector4& in_relMargins, const Vector4& in_absMargins, f32 in_relSpacing, f32 in_absSpacing)\n        : m_numCells(in_numCells), m_relativeMargins(in_relMargins), m_absoluteMargins(in_absMargins), m_relativeSpacing(in_relSpacing), m_absoluteSpacing(in_absSpacing)\n    {\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    bool HListUILayoutDef::IsA(InterfaceIDType in_interfaceId) const\n    {\n        return (UILayoutDef::InterfaceID == in_interfaceId || HListUILayoutDef::InterfaceID == in_interfaceId);\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    u32 HListUILayoutDef::GetNumCells() const\n    {\n        return m_numCells;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    Vector4 HListUILayoutDef::GetRelativeMargins() const\n    {\n        return m_relativeMargins;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    Vector4 HListUILayoutDef::GetAbsoluteMargins() const\n    {\n        return m_absoluteMargins;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    f32 HListUILayoutDef::GetRelativeSpacing() const\n    {\n        return m_relativeSpacing;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    f32 HListUILayoutDef::GetAbsoluteSpacing() const\n    {\n        return m_absoluteSpacing;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    UILayoutUPtr HListUILayoutDef::CreateLayout(LayoutUIComponent* in_owner) const\n    {\n        return UILayoutUPtr(new HListUILayout(in_owner, m_numCells, m_relativeMargins, m_absoluteMargins, m_relativeSpacing, m_absoluteSpacing));\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/UI/Layout/HListUILayoutDef.h",
    "content": "//\n//  HListUILayoutDef.h\n//  ChilliSource\n//  Created by Ian Copland on 07/01/2015.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2015 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_UI_LAYOUT_HLISTUILAYOUTDEF_H_\n#define _CHILLISOURCE_UI_LAYOUT_HLISTUILAYOUTDEF_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Math/Vector2.h>\n#include <ChilliSource/Core/Math/Vector4.h>\n#include <ChilliSource/UI/Layout/HListUILayout.h>\n#include <ChilliSource/UI/Layout/UILayoutDef.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    /// A definition of a HList UILayout which can be built from a json object. This is\n    /// effectively an immutable container for the properties of a HList UILayout.\n    ///\n    /// A HList UILayout Def contains the following property in addition to those\n    /// defined in the Layouy Def base class documentation:\n    ///\n    /// \"NumCells\": The number of cells.\n    ///\n    /// \"RelMargins\": The relative padding from the widget edge to the cells\n    ///\n    /// \"AbsMargins\": The absolute padding from the widget edge to the cells\n    ///\n    /// \"RelSpacing\": The relative spacing between cells\n    ///\n    /// \"AbsSpacing\": The absolute spacing between cells\n    ///\n    /// @author Ian Copland\n    //------------------------------------------------------------------------------\n    class HListUILayoutDef final : public UILayoutDef\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(HListUILayoutDef);\n        //------------------------------------------------------------------------------\n        /// Constructor. Creates an empty hlist layout definition.\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------------------------------------\n        HListUILayoutDef() = default;\n        //------------------------------------------------------------------------------\n        /// Constructor. Creates a standard hlist layout definition from json.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The JSON object containing the drawable properties.\n        //------------------------------------------------------------------------------\n        HListUILayoutDef(const Json::Value& in_json);\n        //------------------------------------------------------------------------------\n        /// Constructor. Creates a hlist layout definition with the given properties.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The cell order.\n        /// @param The number of cells.\n        /// @param The relative margins.\n        /// @param The absolute margins.\n        /// @param The relative spacing.\n        /// @param The absolute spacing.\n        //------------------------------------------------------------------------------\n        HListUILayoutDef(u32 in_numCells, const Vector4& in_relMargins, const Vector4& in_absMargins, f32 in_relSpacing, f32 in_absSpacing);\n        //------------------------------------------------------------------------------\n        /// Allows querying of whether or not this system implements the interface\n        /// described by the given interface Id. Typically this is not called directly\n        /// as the templated equivalent IsA<Interface>() is preferred.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The interface Id.\n        ///\n        /// @return Whether or not the interface is implemented.\n        //------------------------------------------------------------------------------\n        bool IsA(InterfaceIDType in_interfaceId) const override;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The number of cells.\n        //------------------------------------------------------------------------------\n        u32 GetNumCells() const;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The relative border size margins for each edge. These are relative\n        /// to the overall layout size (i.e owning widget size). X is top, Y is right,\n        /// Z is bottom and W is left.\n        //------------------------------------------------------------------------------\n        Vector4 GetRelativeMargins() const;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The absolute border size margins for each edge. X is top, Y is\n        /// right, Z is bottom and W is left.\n        //------------------------------------------------------------------------------\n        Vector4 GetAbsoluteMargins() const;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The relative spacing between cells.\n        //------------------------------------------------------------------------------\n        f32 GetRelativeSpacing() const;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The absolute spacing between cells.\n        //------------------------------------------------------------------------------\n        f32 GetAbsoluteSpacing() const;\n        \n    protected:\n        //------------------------------------------------------------------------------\n        /// Creates a new instance of a hlist layout as described by this definition.\n        /// This should typically only be called by a layout component.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The owning component.\n        ///\n        /// @return a new layout instance.\n        //------------------------------------------------------------------------------\n        UILayoutUPtr CreateLayout(LayoutUIComponent* in_owner) const override;\n        \n        u32 m_numCells = 1;\n        Vector4 m_relativeMargins;\n        Vector4 m_absoluteMargins;\n        f32 m_relativeSpacing = 0.0f;\n        f32 m_absoluteSpacing = 0.0f;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/UI/Layout/LayoutDef.h",
    "content": "//\n//  UILayoutDef.h\n//  ChilliSource\n//  Created by Ian Copland on 08/05/2015.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2015 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_UI_LAYOUT_LAYOUTDEF_H_\n#define _CHILLISOURCE_UI_LAYOUT_LAYOUTDEF_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Base/QueryableInterface.h>\n#include <ChilliSource/Core/File/StorageLocation.h>\n\n#include <json/forwards.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    /// A definition of a layout which can be built from a json object. This is\n    /// effectively an immutable container for the properties of a specific type of\n    /// layout.\n    ///\n    /// UILayout Defs can be either created using the concrete def's constructor or\n    /// using the Create() method. This creates the def from json which describes the\n    /// type and properties of the def.\n    ///\n    /// All layouts defs contain the following property. Specific def types can also\n    /// contain further properties.\n    ///\n    /// \"Type\": Describes the type of layout def.\n    ///\n    /// @author Ian Copland\n    //------------------------------------------------------------------------------\n    class UILayoutDef : public QueryableInterface\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(UILayoutDef);\n        //------------------------------------------------------------------------------\n        /// Creates a new layout def from json which describes the type of def and its\n        /// properties.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The JSON object containing the layout properties.\n        //------------------------------------------------------------------------------\n        static UILayoutDefCUPtr Create(const Json::Value& in_json);\n        //------------------------------------------------------------------------------\n        /// Destructor\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------------------------------------\n        virtual ~UILayoutDef() {};\n    protected:\n        friend class LayoutUIComponent;\n        //------------------------------------------------------------------------------\n        /// Creates a new instance of the layout described by this definition. This\n        /// should typically only be called by a layout component.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The owning component.\n        ///\n        /// @return a new layout instance.\n        //------------------------------------------------------------------------------\n        virtual UILayoutUPtr CreateLayout(LayoutUIComponent* in_owner) const = 0;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/UI/Layout/LayoutUIComponent.cpp",
    "content": "//\n//  LayoutUIComponent.cpp\n//  ChilliSource\n//  Created by Ian Copland on 07/01/2015.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2015 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/UI/Layout/LayoutUIComponent.h>\n\n#include <ChilliSource/Core/Delegate/MakeDelegate.h>\n#include <ChilliSource/UI/Base/PropertyTypes.h>\n#include <ChilliSource/UI/Base/Widget.h>\n#include <ChilliSource/UI/Layout/UILayout.h>\n#include <ChilliSource/UI/Layout/UILayoutDef.h>\n\nnamespace ChilliSource\n{\n    namespace\n    {\n        const char k_layoutKey[] = \"Layout\";\n        \n        const std::vector<PropertyMap::PropertyDesc> k_propertyDescs =\n        {\n            {PropertyTypes::UILayoutDef(), k_layoutKey},\n        };\n    }\n    \n    CS_DEFINE_NAMEDTYPE(LayoutUIComponent);\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    const std::vector<PropertyMap::PropertyDesc>& LayoutUIComponent::GetPropertyDescs()\n    {\n        return k_propertyDescs;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    LayoutUIComponent::LayoutUIComponent(const std::string& in_componentName, const PropertyMap& in_properties)\n        : UIComponent(in_componentName)\n    {\n        RegisterProperty<UILayoutDefCSPtr>(PropertyTypes::UILayoutDef(), k_layoutKey, MakeDelegate(this, &LayoutUIComponent::GetLayoutDef), MakeDelegate(this, &LayoutUIComponent::ApplyLayoutDef));\n        ApplyRegisteredProperties(in_properties);\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    bool LayoutUIComponent::IsA(InterfaceIDType in_interfaceId) const\n    {\n        return (LayoutUIComponent::InterfaceID == in_interfaceId);\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    UILayout* LayoutUIComponent::GetLayout()\n    {\n        return m_layout.get();\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    const UILayout* LayoutUIComponent::GetLayout() const\n    {\n        return m_layout.get();\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void LayoutUIComponent::ApplyLayoutDef(const UILayoutDefCSPtr& in_layoutDef)\n    {\n        CS_ASSERT(in_layoutDef != nullptr, \"Cannot set null layout def on a layout component.\");\n        \n        m_layoutDef = in_layoutDef;\n        m_layout = m_layoutDef->CreateLayout(this);\n        \n        OnLayoutChanged();\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void LayoutUIComponent::BuildLayout()\n    {\n        m_layout->BuildLayout();\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    Vector2 LayoutUIComponent::GetSizeForIndex(u32 in_index) const\n    {\n        return m_layout->GetSizeForIndex(in_index);\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    Vector2 LayoutUIComponent::GetPositionForIndex(u32 in_index) const\n    {\n        return m_layout->GetPositionForIndex(in_index);\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    const UILayoutDefCSPtr& LayoutUIComponent::GetLayoutDef() const\n    {\n        return m_layoutDef;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void LayoutUIComponent::OnLayoutChanged()\n    {\n        GetWidget()->ForceLayout();\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/UI/Layout/LayoutUIComponent.h",
    "content": "//\n//  LayoutUIComponent.h\n//  ChilliSource\n//  Created by Ian Copland on 07/01/2015.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2015 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_UI_LAYOUT_LAYOUTUICOMPONENT_H_\n#define _CHILLISOURCE_UI_LAYOUT_LAYOUTUICOMPONENT_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Container/Property/PropertyMap.h>\n#include <ChilliSource/Core/Event/EventConnection.h>\n#include <ChilliSource/Core/Math/Vector2.h>\n#include <ChilliSource/Input/Pointer/Pointer.h>\n#include <ChilliSource/UI/Base/UIComponent.h>\n#include <ChilliSource/UI/Layout/UILayout.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    /// A component for applying layouts to the children of the owning widget.\n    /// There are 3 types of layout: Grid, HList and VList.\n    ///\n    /// A LayoutUIComponent contains the following properties:\n    ///\n    /// \"Layout\": The definition of the layout that will be applied. The\n    /// contents of a layout def are described in the layout def documentation.\n    ///\n    /// @author Ian Copland\n    //------------------------------------------------------------------------------\n    class LayoutUIComponent final : public UIComponent\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(LayoutUIComponent);\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The list of properties supported by a layout component.\n        //------------------------------------------------------------------------------\n        static const std::vector<PropertyMap::PropertyDesc>& GetPropertyDescs();\n        //------------------------------------------------------------------------------\n        /// Allows querying of whether or not this system implements the interface\n        /// described by the given interface Id. Typically this is not called directly\n        /// as the templated equivalent IsA<Interface>() is preferred.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The interface Id.\n        ///\n        /// @return Whether or not the interface is implemented.\n        //------------------------------------------------------------------------------\n        bool IsA(InterfaceIDType in_interfaceId) const override;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The layout object that will be used to apply the layout to children.\n        /// This can be changed directly, for example to increase the number of cells,\n        /// etc.\n        //------------------------------------------------------------------------------\n        UILayout* GetLayout();\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return A const pointer to the layout object that will be used to apply the\n        /// layout to children.\n        //------------------------------------------------------------------------------\n        const UILayout* GetLayout() const;\n        //------------------------------------------------------------------------------\n        /// Applies a new UILayout from the given layout definition.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The layout defintion.\n        //------------------------------------------------------------------------------\n        void ApplyLayoutDef(const UILayoutDefCSPtr& in_layoutDef);\n        //------------------------------------------------------------------------------\n        /// Create the grid layout sizes and positions based on the current layout\n        /// properties and the owning widget.\n        ///\n        /// @author S Downie\n        //------------------------------------------------------------------------------\n        void BuildLayout();\n        //------------------------------------------------------------------------------\n        /// Get the final size of the widget that occupies the space at the given index\n        ///\n        /// @author S Downie\n        ///\n        /// @param Space index\n        ///\n        /// @return Final absolute screen size\n        //------------------------------------------------------------------------------\n        Vector2 GetSizeForIndex(u32 in_index) const;\n        //------------------------------------------------------------------------------\n        /// Get the local position of the widget that occupies the space at the given\n        /// index\n        ///\n        /// @author S Downie\n        ///\n        /// @param Space index\n        ///\n        /// @return Local position in layout space (aligned middle centre of the cell)\n        //------------------------------------------------------------------------------\n        Vector2 GetPositionForIndex(u32 in_index) const;\n        //------------------------------------------------------------------------------\n        /// Called when the internal layout changes so that the widget can be told to\n        /// update its children. This is for internal use and should not be called by\n        /// the user of the API.\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------------------------------------\n        void OnLayoutChanged();\n    private:\n        friend class UIComponentFactory;\n        //------------------------------------------------------------------------------\n        /// Constructor that builds the component from key-value properties. The\n        /// properties used to create a drawable component are described in the class\n        /// documentation.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The component name.\n        /// @param The property map.\n        //------------------------------------------------------------------------------\n        LayoutUIComponent(const std::string& in_componentName, const PropertyMap& in_properties);\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The layout definition that was used to create the underlying layout\n        /// object.\n        //------------------------------------------------------------------------------\n        const UILayoutDefCSPtr& GetLayoutDef() const;\n        \n        UILayoutDefCSPtr m_layoutDef;\n        UILayoutUPtr m_layout;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/UI/Layout/UILayout.cpp",
    "content": "//\n//  ILayout.cpp\n//  ChilliSource\n//  Created by Scott Downie on 18/04/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/UI/Layout/UILayout.h>\n\nnamespace ChilliSource\n{\n    CS_DEFINE_NAMEDTYPE(UILayout);\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    UILayout::UILayout(LayoutUIComponent* in_layoutComponent)\n        : m_component(in_layoutComponent)\n    {\n        CS_ASSERT(m_component != nullptr, \"A layout must have an owning component.\");\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    LayoutUIComponent* UILayout::GetComponent()\n    {\n        return m_component;\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/UI/Layout/UILayout.h",
    "content": "//\n//  UILayout.h\n//  ChilliSource\n//  Created by Scott Downie on 18/04/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_UI_LAYOUT_UILAYOUT_H_\n#define _CHILLISOURCE_UI_LAYOUT_UILAYOUT_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Base/QueryableInterface.h>\n\n#include <vector>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    /// Interface for laying out widgets. This is used by UILayout UIComponent to\n    /// apply the described layout.\n    ///\n    /// @author S Downie\n    //------------------------------------------------------------------------------\n    class UILayout : public QueryableInterface\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(ILayout);\n        CS_DECLARE_NOCOPY(UILayout);\n        //------------------------------------------------------------------------------\n        /// Constructor\n        ///\n        /// @author S Downie\n        ///\n        /// @param The layout component that owns this layout.\n        //------------------------------------------------------------------------------\n        UILayout(LayoutUIComponent* in_layoutComponent);\n        //------------------------------------------------------------------------------\n        /// Virtual destructor\n        ///\n        /// @author S Downie\n        //------------------------------------------------------------------------------\n        virtual ~UILayout() {}\n        \n    protected:\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The owning component.\n        //------------------------------------------------------------------------------\n        LayoutUIComponent* GetComponent();\n        \n    private:\n        friend class LayoutUIComponent;\n        //------------------------------------------------------------------------------\n        /// Create the layout sizes and positions based on the current layout properties\n        /// and the owning widget.\n        ///\n        /// @author S Downie\n        //------------------------------------------------------------------------------\n        virtual void BuildLayout() = 0;\n        //------------------------------------------------------------------------------\n        /// Get the final size of the widget that occupies the space at the given index\n        ///\n        /// @author S Downie\n        ///\n        /// @param Space index\n        ///\n        /// @return Final absolute screen size\n        //------------------------------------------------------------------------------\n        virtual Vector2 GetSizeForIndex(u32 in_index) const = 0;\n        //------------------------------------------------------------------------------\n        /// Get the local position of the widget that occupies the space at the given\n        /// index\n        ///\n        /// @author S Downie\n        ///\n        /// @param Space index\n        ///\n        /// @return Local position (aligned middle centre of the cell)\n        //------------------------------------------------------------------------------\n        virtual Vector2 GetPositionForIndex(u32 in_index) const = 0;\n        \n        LayoutUIComponent* m_component = nullptr;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/UI/Layout/UILayoutDef.cpp",
    "content": "//\n//  UILayoutDef.cpp\n//  ChilliSource\n//  Created by Ian Copland on 07/01/2015.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2015 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/UI/Layout/UILayoutDef.h>\n\n#include <ChilliSource/UI/Layout/GridUILayoutDef.h>\n#include <ChilliSource/UI/Layout/HListUILayoutDef.h>\n#include <ChilliSource/UI/Layout/VListUILayoutDef.h>\n\n#include <json/json.h>\n\nnamespace ChilliSource\n{\n    namespace\n    {\n        //------------------------------------------------------------------------------\n        /// Identifiers for classes that are responsible for laying out the child content\n        /// of a widget\n        ///\n        /// @author S Downie\n        //------------------------------------------------------------------------------\n        enum class LayoutType\n        {\n            k_none,\n            k_grid,\n            k_hList,\n            k_vList\n        };\n        //------------------------------------------------------------------------------\n        /// Converts a string to a drawable type\n        ///\n        /// @author S Downie\n        ///\n        /// @param String\n        ///\n        /// @return UIDrawable type\n        //------------------------------------------------------------------------------\n        LayoutType ParseLayoutType(const std::string& in_type)\n        {\n            std::string lowerCase = in_type;\n            StringUtils::ToLowerCase(lowerCase);\n\n            if(lowerCase == \"none\") return LayoutType::k_none;\n            if(lowerCase == \"grid\") return LayoutType::k_grid;\n            if(lowerCase == \"hlist\") return LayoutType::k_hList;\n            if(lowerCase == \"vlist\") return LayoutType::k_vList;\n\n            CS_LOG_FATAL(\"Cannot parse layout type: \" + in_type);\n            return LayoutType::k_none;\n        }\n    }\n    \n    CS_DEFINE_NAMEDTYPE(UILayoutDef);\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    UILayoutDefCUPtr UILayoutDef::Create(const Json::Value& in_json)\n    {\n        const char k_typeKey[] = \"Type\";\n        \n        CS_ASSERT(in_json.isObject() == true, \"UILayout Def must be created from a json value of type Object.\");\n        \n        const auto& typeJson = in_json.get(k_typeKey, Json::nullValue);\n        CS_ASSERT(typeJson != Json::nullValue, \"'\" + std::string(k_typeKey) + \"' must be specified in a UILayout Def.\");\n        \n        LayoutType type = ParseLayoutType(typeJson.asString());\n        \n        switch (type)\n        {\n            case LayoutType::k_grid:\n                return UILayoutDefCUPtr(new GridUILayoutDef(in_json));\n            case LayoutType::k_hList:\n                return UILayoutDefCUPtr(new HListUILayoutDef(in_json));\n            case LayoutType::k_vList:\n                return UILayoutDefCUPtr(new VListUILayoutDef(in_json));\n            default:\n                CS_LOG_FATAL(\"Invalid layout def type.\");\n                return nullptr;\n        }\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/UI/Layout/UILayoutDef.h",
    "content": "//\n//  UILayoutDef.h\n//  ChilliSource\n//  Created by Ian Copland on 08/05/2015.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2015 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_UI_LAYOUT_UILAYOUTDEF_H_\n#define _CHILLISOURCE_UI_LAYOUT_UILAYOUTDEF_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Base/QueryableInterface.h>\n#include <ChilliSource/Core/File/StorageLocation.h>\n\n#include <json/forwards.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    /// A definition of a layout which can be built from a json object. This is\n    /// effectively an immutable container for the properties of a specific type of\n    /// layout.\n    ///\n    /// UILayout Defs can be either created using the concrete def's constructor or\n    /// using the Create() method. This creates the def from json which describes the\n    /// type and properties of the def.\n    ///\n    /// All layouts defs contain the following property. Specific def types can also\n    /// contain further properties.\n    ///\n    /// \"Type\": Describes the type of layout def.\n    ///\n    /// @author Ian Copland\n    //------------------------------------------------------------------------------\n    class UILayoutDef : public QueryableInterface\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(UILayoutDef);\n        //------------------------------------------------------------------------------\n        /// Creates a new layout def from json which describes the type of def and its\n        /// properties.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The JSON object containing the layout properties.\n        //------------------------------------------------------------------------------\n        static UILayoutDefCUPtr Create(const Json::Value& in_json);\n        //------------------------------------------------------------------------------\n        /// Destructor\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------------------------------------\n        virtual ~UILayoutDef() {};\n    protected:\n        friend class LayoutUIComponent;\n        //------------------------------------------------------------------------------\n        /// Creates a new instance of the layout described by this definition. This\n        /// should typically only be called by a layout component.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The owning component.\n        ///\n        /// @return a new layout instance.\n        //------------------------------------------------------------------------------\n        virtual UILayoutUPtr CreateLayout(LayoutUIComponent* in_owner) const = 0;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/UI/Layout/VListUILayout.cpp",
    "content": "//\n//  VListUILayout.cpp\n//  ChilliSource\n//  Created by Scott Downie on 23/04/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/UI/Layout/VListUILayout.h>\n\n#include <ChilliSource/Core/Math/Vector4.h>\n#include <ChilliSource/UI/Base/Widget.h>\n\nnamespace ChilliSource\n{\n    CS_DEFINE_NAMEDTYPE(VListUILayout);\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    VListUILayout::VListUILayout(LayoutUIComponent* in_layoutComponent, u32 in_numCells, const Vector4& in_relMargins, const Vector4& in_absMargins, f32 in_relSpacing, f32 in_absSpacing)\n        : UILayout(in_layoutComponent), m_gridLayout(in_layoutComponent, GridUILayout::CellOrder::k_colMajor, in_numCells, 1, in_relMargins, in_absMargins, 0.0f, 0.0f, in_relSpacing, in_absSpacing)\n    {\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    bool VListUILayout::IsA(InterfaceIDType in_interfaceId) const\n    {\n        return (UILayout::InterfaceID == in_interfaceId || VListUILayout::InterfaceID == in_interfaceId);\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    u32 VListUILayout::GetNumCells() const\n    {\n        return m_gridLayout.GetNumRows();\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    Vector4 VListUILayout::GetRelativeMargins() const\n    {\n        return m_gridLayout.GetRelativeMargins();\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    Vector4 VListUILayout::GetAbsoluteMargins() const\n    {\n        return m_gridLayout.GetAbsoluteMargins();\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    f32 VListUILayout::GetRelativeSpacing() const\n    {\n        return m_gridLayout.GetRelativeVSpacing();\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    f32 VListUILayout::GetAbsoluteSpacing() const\n    {\n        return m_gridLayout.GetAbsoluteVSpacing();\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void VListUILayout::SetNumCells(u32 in_numCells)\n    {\n        CS_ASSERT(in_numCells > 0, \"Cannot create a list with 0 cells\");\n        m_gridLayout.SetNumRows(in_numCells);\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void VListUILayout::SetRelativeMargins(f32 in_top, f32 in_right, f32 in_bottom, f32 in_left)\n    {\n        m_gridLayout.SetRelativeMargins(in_top, in_right, in_bottom, in_left);\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void VListUILayout::SetAbsoluteMargins(f32 in_top, f32 in_right, f32 in_bottom, f32 in_left)\n    {\n        m_gridLayout.SetAbsoluteMargins(in_top, in_right, in_bottom, in_left);\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void VListUILayout::SetRelativeSpacing(f32 in_spacing)\n    {\n        m_gridLayout.SetRelativeVSpacing(in_spacing);\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void VListUILayout::SetAbsoluteSpacing(f32 in_spacing)\n    {\n        m_gridLayout.SetAbsoluteVSpacing(in_spacing);\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void VListUILayout::BuildLayout()\n    {\n        m_gridLayout.BuildLayout();\n    }\n    //------------------------------------------------------------------------------\n    /// The cell size if fixed and uniform so the index is not required\n    //------------------------------------------------------------------------------\n    Vector2 VListUILayout::GetSizeForIndex(u32 in_index) const\n    {\n        return m_gridLayout.GetSizeForIndex(in_index);\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    Vector2 VListUILayout::GetPositionForIndex(u32 in_index) const\n    {\n        return m_gridLayout.GetPositionForIndex(in_index);\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/UI/Layout/VListUILayout.h",
    "content": "//\n//  VListUILayout.h\n//  ChilliSource\n//  Created by Scott Downie on 23/04/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_UI_LAYOUT_VLISTUILAYOUT_H_\n#define _CHILLISOURCE_UI_LAYOUT_VLISTUILAYOUT_H_\n\n#include <ChilliSource/ChilliSource.h>\n\n#include <ChilliSource/Core/Math/Vector2.h>\n#include <ChilliSource/UI/Layout/GridUILayout.h>\n#include <ChilliSource/UI/Layout/UILayout.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    /// Lays out widgets in a vertical list where each widget has a single row. The\n    /// rows have spacing between them and the entire list has a surrounding margin.\n    /// The list is filled top to bottom.\n    ///\n    /// The list size is fixed and will not expand\n    ///\n    /// @author S Downie\n    //------------------------------------------------------------------------------\n    class VListUILayout final : public UILayout\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(VListUILayout);\n        //------------------------------------------------------------------------------\n        /// Allows querying of whether or not this system implements the interface\n        /// described by the given interface Id. Typically this is not called directly\n        /// as the templated equivalent IsA<Interface>() is preferred.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The interface Id.\n        ///\n        /// @return Whether or not the interface is implemented.\n        //------------------------------------------------------------------------------\n        bool IsA(InterfaceIDType in_interfaceId) const override;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The number of cells that make up the list. The size of each cell is\n        /// based on the number of cells and the overall layout size, governed by the\n        /// owning widget\n        //------------------------------------------------------------------------------\n        u32 GetNumCells() const;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The relative border size margins for each edge. These are relative\n        /// to the overall layout size (i.e owning widget size).X is top, Y is right,\n        /// Z is bottom and W is left.\n        //------------------------------------------------------------------------------\n        Vector4 GetRelativeMargins() const;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The absolute border size margins for each edge. X is top, Y is\n        /// right, Z is bottom and W is left.\n        //------------------------------------------------------------------------------\n        Vector4 GetAbsoluteMargins() const;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The relative spacing between items. This is relative to the overall\n        /// layout size (i.e. the owning widget)\n        //------------------------------------------------------------------------------\n        f32 GetRelativeSpacing() const;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The absolute spacing between items.\n        //------------------------------------------------------------------------------\n        f32 GetAbsoluteSpacing() const;\n        //------------------------------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param The number of cells that make up the list. The size of each cell is\n        /// based on the number of cells and the overall layout size, governed by the\n        /// owning widget\n        //------------------------------------------------------------------------------\n        void SetNumCells(u32 in_numCells);\n        //------------------------------------------------------------------------------\n        /// Set the relative border size margins for each edge. These are relative to\n        /// the overall layout size (i.e owning widget size).\n        ///\n        /// @author S Downie\n        ///\n        /// @param Top\n        /// @param Right\n        /// @param Bottom\n        /// @param Left\n        //------------------------------------------------------------------------------\n        void SetRelativeMargins(f32 in_top, f32 in_right, f32 in_bottom, f32 in_left);\n        //------------------------------------------------------------------------------\n        /// Set the absolute border size margins for each edge.\n        ///\n        /// @author S Downie\n        ///\n        /// @param Top\n        /// @param Right\n        /// @param Bottom\n        /// @param Left\n        //------------------------------------------------------------------------------\n        void SetAbsoluteMargins(f32 in_top, f32 in_right, f32 in_bottom, f32 in_left);\n        //------------------------------------------------------------------------------\n        /// Set the relative spacing between items. This is relative to the overall\n        /// layout size (i.e. the owning widget)\n        ///\n        /// @author S Downie\n        ///\n        /// @param Spacing\n        //------------------------------------------------------------------------------\n        void SetRelativeSpacing(f32 in_spacing);\n        //------------------------------------------------------------------------------\n        /// Set the absolute spacing between items.\n        ///\n        /// @author S Downie\n        ///\n        /// @param Spacing\n        //------------------------------------------------------------------------------\n        void SetAbsoluteSpacing(f32 in_spacing);\n        \n    private:\n        friend class VListUILayoutDef;\n        //------------------------------------------------------------------------------\n        /// Constructor. Creates a vlist layout with the given properties.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The owning component.\n        /// @param The number of cells.\n        /// @param The relative margins.\n        /// @param The absolute margins.\n        /// @param The relative spacing.\n        /// @param The absolute spacing.\n        //------------------------------------------------------------------------------\n        VListUILayout(LayoutUIComponent* in_layoutComponent, u32 in_numCells, const Vector4& in_relMargins, const Vector4& in_absMargins, f32 in_relSpacing, f32 in_absSpacing);\n        //------------------------------------------------------------------------------\n        /// Create the list layout sizes and positions based on the current layout\n        /// properties and the owning widget.\n        ///\n        /// @author S Downie\n        //------------------------------------------------------------------------------\n        void BuildLayout() override;\n        //------------------------------------------------------------------------------\n        /// Get the final size of the widget that occupies the space at the given index\n        ///\n        /// @author S Downie\n        ///\n        /// @param Space index\n        ///\n        /// @return Final absolute screen size\n        //------------------------------------------------------------------------------\n        Vector2 GetSizeForIndex(u32 in_index) const override;\n        //------------------------------------------------------------------------------\n        /// Get the local position of the widget that occupies the space at the given\n        /// index\n        ///\n        /// @author S Downie\n        ///\n        /// @param Space index\n        ///\n        /// @return Local position in layout space (aligned middle centre of the cell)\n        //------------------------------------------------------------------------------\n        Vector2 GetPositionForIndex(u32 in_index) const override;\n        \n        GridUILayout m_gridLayout;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/UI/Layout/VListUILayoutDef.cpp",
    "content": "//\n//  VListUILayoutDef.cpp\n//  ChilliSource\n//  Created by Ian Copland on 07/01/2015.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2015 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/UI/Layout/VListUILayoutDef.h>\n\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/String/StringParser.h>\n#include <ChilliSource/UI/Layout/VListUILayout.h>\n\n#include <json/json.h>\n\nnamespace ChilliSource\n{\n    CS_DEFINE_NAMEDTYPE(VListUILayoutDef);\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    VListUILayoutDef::VListUILayoutDef(const Json::Value& in_json)\n    {\n        const char k_typeKey[] = \"Type\";\n        const char k_numCellsKey[] = \"NumCells\";\n        const char k_relativeMarginsKey[] = \"RelMargins\";\n        const char k_absoluteMarginsKey[] = \"AbsMargins\";\n        const char k_relativeSpacingKey[] = \"RelSpacing\";\n        const char k_absoluteSpacingKey[] = \"AbsSpacing\";\n        \n        for(auto it = in_json.begin(); it != in_json.end(); ++it)\n        {\n            CS_ASSERT((*it).isString() == true, \"All properties in a UILayout Description must be a string: \" + std::string(it.memberName()));\n            \n            std::string key = it.memberName();\n            std::string value = (*it).asString();\n            \n            if (key == k_relativeMarginsKey)\n            {\n                m_relativeMargins = ParseVector4(value);\n            }\n            else if (key == k_absoluteMarginsKey)\n            {\n                m_absoluteMargins = ParseVector4(value);\n            }\n            else if (key == k_numCellsKey)\n            {\n                m_numCells = ParseU32(value);\n            }\n            else if (key == k_relativeSpacingKey)\n            {\n                m_relativeSpacing = ParseF32(value);\n            }\n            else if (key == k_absoluteSpacingKey)\n            {\n                m_absoluteSpacing = ParseF32(value);\n            }\n            else if (key == k_typeKey)\n            {\n                //ignore\n            }\n            else\n            {\n                CS_LOG_FATAL(\"Invalid property found in a List layout description: \" + key);\n            }\n        }\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    VListUILayoutDef::VListUILayoutDef(u32 in_numCells, const Vector4& in_relMargins, const Vector4& in_absMargins, f32 in_relSpacing, f32 in_absSpacing)\n    : m_numCells(in_numCells), m_relativeMargins(in_relMargins), m_absoluteMargins(in_absMargins), m_relativeSpacing(in_relSpacing), m_absoluteSpacing(in_absSpacing)\n    {\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    bool VListUILayoutDef::IsA(InterfaceIDType in_interfaceId) const\n    {\n        return (UILayoutDef::InterfaceID == in_interfaceId || VListUILayoutDef::InterfaceID == in_interfaceId);\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    u32 VListUILayoutDef::GetNumCells() const\n    {\n        return m_numCells;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    Vector4 VListUILayoutDef::GetRelativeMargins() const\n    {\n        return m_relativeMargins;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    Vector4 VListUILayoutDef::GetAbsoluteMargins() const\n    {\n        return m_absoluteMargins;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    f32 VListUILayoutDef::GetRelativeSpacing() const\n    {\n        return m_relativeSpacing;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    f32 VListUILayoutDef::GetAbsoluteSpacing() const\n    {\n        return m_absoluteSpacing;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    UILayoutUPtr VListUILayoutDef::CreateLayout(LayoutUIComponent* in_owner) const\n    {\n        return UILayoutUPtr(new VListUILayout(in_owner, m_numCells, m_relativeMargins, m_absoluteMargins, m_relativeSpacing, m_absoluteSpacing));\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/UI/Layout/VListUILayoutDef.h",
    "content": "//\n//  VListUILayoutDef.h\n//  ChilliSource\n//  Created by Ian Copland on 07/01/2015.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2015 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_UI_LAYOUT_VLISTUILAYOUTDEF_H_\n#define _CHILLISOURCE_UI_LAYOUT_VLISTUILAYOUTDEF_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Math/Vector2.h>\n#include <ChilliSource/Core/Math/Vector4.h>\n#include <ChilliSource/UI/Layout/VListUILayout.h>\n#include <ChilliSource/UI/Layout/UILayoutDef.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    /// A definition of a VList UILayout which can be built from a json object. This is\n    /// effectively an immutable container for the properties of a VList UILayout.\n    ///\n    /// A VList UILayout Def contains the following property in addition to those\n    /// defined in the Layouy Def base class documentation:\n    ///\n    /// \"NumCells\": The number of cells.\n    ///\n    /// \"RelMargins\": The relative padding from the widget edge to the cells\n    ///\n    /// \"AbsMargins\": The absolute padding from the widget edge to the cells\n    ///\n    /// \"RelSpacing\": The relative spacing between cells\n    ///\n    /// \"AbsSpacing\": The absolute spacing between cells\n    ///\n    /// @author Ian Copland\n    //------------------------------------------------------------------------------\n    class VListUILayoutDef final : public UILayoutDef\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(VListUILayoutDef);\n        //------------------------------------------------------------------------------\n        /// Constructor. Creates an empty hlist layout definition.\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------------------------------------\n        VListUILayoutDef() = default;\n        //------------------------------------------------------------------------------\n        /// Constructor. Creates a standard hlist layout definition from json.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The JSON object containing the drawable properties.\n        //------------------------------------------------------------------------------\n        VListUILayoutDef(const Json::Value& in_json);\n        //------------------------------------------------------------------------------\n        /// Constructor. Creates a hlist layout definition with the given properties.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The cell order.\n        /// @param The number of cells.\n        /// @param The relative margins.\n        /// @param The absolute margins.\n        /// @param The relative spacing.\n        /// @param The absolute spacing.\n        //------------------------------------------------------------------------------\n        VListUILayoutDef(u32 in_numCells, const Vector4& in_relMargins, const Vector4& in_absMargins, f32 in_relSpacing, f32 in_absSpacing);\n        //------------------------------------------------------------------------------\n        /// Allows querying of whether or not this system implements the interface\n        /// described by the given interface Id. Typically this is not called directly\n        /// as the templated equivalent IsA<Interface>() is preferred.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The interface Id.\n        ///\n        /// @return Whether or not the interface is implemented.\n        //------------------------------------------------------------------------------\n        bool IsA(InterfaceIDType in_interfaceId) const override;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The number of cells.\n        //------------------------------------------------------------------------------\n        u32 GetNumCells() const;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The relative border size margins for each edge. These are relative\n        /// to the overall layout size (i.e owning widget size). X is top, Y is right,\n        /// Z is bottom and W is left.\n        //------------------------------------------------------------------------------\n        Vector4 GetRelativeMargins() const;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The absolute border size margins for each edge. X is top, Y is\n        /// right, Z is bottom and W is left.\n        //------------------------------------------------------------------------------\n        Vector4 GetAbsoluteMargins() const;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The relative spacing between cells.\n        //------------------------------------------------------------------------------\n        f32 GetRelativeSpacing() const;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The absolute spacing between cells.\n        //------------------------------------------------------------------------------\n        f32 GetAbsoluteSpacing() const;\n        \n    protected:\n        //------------------------------------------------------------------------------\n        /// Creates a new instance of a vlist layout as described by this definition.\n        /// This should typically only be called by a layout component.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The owning component.\n        ///\n        /// @return a new layout instance.\n        //------------------------------------------------------------------------------\n        UILayoutUPtr CreateLayout(LayoutUIComponent* in_owner) const override;\n        \n        u32 m_numCells = 1;\n        Vector4 m_relativeMargins;\n        Vector4 m_absoluteMargins;\n        f32 m_relativeSpacing = 0.0f;\n        f32 m_absoluteSpacing = 0.0f;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/UI/Layout.h",
    "content": "//\n//  UILayout.h\n//  ChilliSource\n//  Created by Scott Downie on 25/07/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n\n#ifndef _CHILLISOURCE_UI_LAYOUT_H_\n#define _CHILLISOURCE_UI_LAYOUT_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/UI/Layout/GridUILayout.h>\n#include <ChilliSource/UI/Layout/GridUILayoutDef.h>\n#include <ChilliSource/UI/Layout/HListUILayout.h>\n#include <ChilliSource/UI/Layout/HListUILayoutDef.h>\n#include <ChilliSource/UI/Layout/UILayout.h>\n#include <ChilliSource/UI/Layout/LayoutUIComponent.h>\n#include <ChilliSource/UI/Layout/UILayoutDef.h>\n#include <ChilliSource/UI/Layout/VListUILayout.h>\n#include <ChilliSource/UI/Layout/VListUILayoutDef.h>\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/UI/ProgressBar/ProgressBarDirection.cpp",
    "content": "//\n//  ProgressBarDirection.cpp\n//  ChilliSource\n//  Created by Ian Copland on 17/12/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/UI/ProgressBar/ProgressBarDirection.h>\n\n#include <ChilliSource/Core/String/StringUtils.h>\n\nnamespace ChilliSource\n{\n    const char k_directionHorizontal[] = \"horizontal\";\n    const char k_directionVertical[] = \"vertical\";\n    \n    //------------------------------------------------------------------------\n    //------------------------------------------------------------------------\n    ProgressBarDirection ParseProgressBarDirection(const std::string& in_stringDirection)\n    {\n        std::string lowerDirection = in_stringDirection;\n        StringUtils::ToLowerCase(lowerDirection);\n        \n        if (lowerDirection == k_directionHorizontal)\n        {\n            return ProgressBarDirection::k_horizontal;\n        }\n        else if (lowerDirection == k_directionVertical)\n        {\n            return ProgressBarDirection::k_vertical;\n        }\n        \n        CS_LOG_FATAL(\"Could not parse progress bar direction: \" + in_stringDirection);\n        return ProgressBarDirection::k_horizontal;\n    }\n    //------------------------------------------------------------------------\n    //------------------------------------------------------------------------\n    std::string ToString(ProgressBarDirection in_direction)\n    {\n        switch (in_direction)\n        {\n            case ProgressBarDirection::k_horizontal:\n                return k_directionHorizontal;\n            case ProgressBarDirection::k_vertical:\n                return k_directionVertical;\n            default:\n                CS_LOG_FATAL(\"Invalid progress bar direction.\");\n                return k_directionHorizontal;\n                \n        }\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/UI/ProgressBar/ProgressBarDirection.h",
    "content": "//\n//  ProgressBarDirection.h\n//  ChilliSource\n//  Created by Ian Copland on 17/12/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_UI_PROGRESSBAR_PROGRESSBARDIRECTION_H_\n#define _CHILLISOURCE_UI_PROGRESSBAR_PROGRESSBARDIRECTION_H_\n\n#include <ChilliSource/ChilliSource.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------\n    /// An enum describing the direction of a progress bar: vertical or\n    /// horizontal.\n    ///\n    /// @author Ian Copland\n    //------------------------------------------------------------------------\n    enum class ProgressBarDirection\n    {\n        k_horizontal,\n        k_vertical\n    };\n    //------------------------------------------------------------------------\n    /// Parse a progress bar direction from string. This is case insensitive.\n    /// If the string is not a valid direction then the app is considered to\n    /// be in an irrecoverable state and will terminate.\n    ///\n    /// @author Ian Copland\n    ///\n    /// @param The string to parse.\n    ///\n    /// @return The parsed direction.\n    //------------------------------------------------------------------------\n    ProgressBarDirection ParseProgressBarDirection(const std::string& in_stringDirection);\n    //------------------------------------------------------------------------\n    /// Converts the given progress bar direction to a string.\n    ///\n    /// @author Ian Copland\n    ///\n    /// @param The progress bar direction to convert to string.\n    ///\n    /// @return The direction in string form.\n    //------------------------------------------------------------------------\n    std::string ToString(ProgressBarDirection in_direction);\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/UI/ProgressBar/ProgressBarType.cpp",
    "content": "//\n//  ProgressBarType.cpp\n//  ChilliSource\n//  Created by Ian Copland on 17/12/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/UI/ProgressBar/ProgressBarType.h>\n\n#include <ChilliSource/Core/String/StringUtils.h>\n\nnamespace ChilliSource\n{\n    namespace\n    {\n        const char k_typeFill[] = \"fill\";\n        const char k_typeStretch[] = \"stretch\";\n    }\n    \n    //------------------------------------------------------------------------\n    //------------------------------------------------------------------------\n    ProgressBarType ParseProgressBarType(const std::string& in_stringType)\n    {\n        std::string lowerType = in_stringType;\n        StringUtils::ToLowerCase(lowerType);\n        \n        if (lowerType == k_typeFill)\n        {\n            return ProgressBarType::k_fill;\n        }\n        else if (lowerType == k_typeStretch)\n        {\n            return ProgressBarType::k_stretch;\n        }\n        \n        CS_LOG_FATAL(\"Could not parse progress bar type: \" + in_stringType);\n        return ProgressBarType::k_fill;\n    }\n    //------------------------------------------------------------------------\n    //------------------------------------------------------------------------\n    std::string ToString(ProgressBarType in_direction)\n    {\n        switch (in_direction)\n        {\n            case ProgressBarType::k_fill:\n                return k_typeFill;\n            case ProgressBarType::k_stretch:\n                return k_typeStretch;\n            default:\n                CS_LOG_FATAL(\"Invalid progress bar type.\");\n                return k_typeFill;\n                \n        }\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/UI/ProgressBar/ProgressBarType.h",
    "content": "//\n//  ProgressBarType.h\n//  ChilliSource\n//  Created by Ian Copland on 17/12/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_UI_PROGRESSBAR_ProgressBarType_H_\n#define _CHILLISOURCE_UI_PROGRESSBAR_ProgressBarType_H_\n\n#include <ChilliSource/ChilliSource.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------\n    /// An enum describing the type of a progress bar: fill or stretch.\n    ///\n    /// @author Ian Copland\n    //------------------------------------------------------------------------\n    enum class ProgressBarType\n    {\n        k_fill,\n        k_stretch\n    };\n    //------------------------------------------------------------------------\n    /// Parse a progress bar type from string. This is case insensitive.\n    /// If the string is not a valid type then the app is considered to\n    /// be in an irrecoverable state and will terminate.\n    ///\n    /// @author Ian Copland\n    ///\n    /// @param The string to parse.\n    ///\n    /// @return The parsed direction.\n    //------------------------------------------------------------------------\n    ProgressBarType ParseProgressBarType(const std::string& in_stringType);\n    //------------------------------------------------------------------------\n    /// Converts the given progress bar type to a string.\n    ///\n    /// @author Ian Copland\n    ///\n    /// @param The progress bar type to convert to string.\n    ///\n    /// @return The type in string form.\n    //------------------------------------------------------------------------\n    std::string ToString(ProgressBarType in_type);\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/UI/ProgressBar/ProgressBarUIComponent.cpp",
    "content": "//\n//  ProgressBarUIComponent.cpp\n//  ChilliSource\n//  Created by Ian Copland on 01/12/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/UI/ProgressBar/ProgressBarUIComponent.h>\n\n#include <ChilliSource/Core/Delegate/MakeDelegate.h>\n#include <ChilliSource/Core/Container/Property/PropertyTypes.h>\n#include <ChilliSource/Rendering/Texture/UVs.h>\n#include <ChilliSource/UI/Base/PropertyTypes.h>\n#include <ChilliSource/UI/Base/Widget.h>\n#include <ChilliSource/UI/Drawable/UIDrawable.h>\n#include <ChilliSource/UI/Drawable/DrawableUIComponent.h>\n\nnamespace ChilliSource\n{\n    namespace\n    {\n        const char k_relBarSizeKey[] = \"RelBarSize\";\n        const char k_progressKey[] = \"Progress\";\n        const char k_barTypeKey[] = \"BarType\";\n        const char k_barDirectionKey[] = \"BarDirection\";\n        const char k_barWidgetName[] = \"BarWidgetName\";\n        \n        const std::vector<PropertyMap::PropertyDesc> k_propertyDescs =\n        {\n            {PropertyTypes::Vector2(), k_relBarSizeKey},\n            {PropertyTypes::Float(), k_progressKey},\n            {PropertyTypes::ProgressBarType(), k_barTypeKey},\n            {PropertyTypes::ProgressBarDirection(), k_barDirectionKey},\n            {PropertyTypes::String(), k_barWidgetName}\n        };\n    }\n    \n    CS_DEFINE_NAMEDTYPE(ProgressBarUIComponent);\n    //-------------------------------------------------------------------\n    //-------------------------------------------------------------------\n    const std::vector<PropertyMap::PropertyDesc>& ProgressBarUIComponent::GetPropertyDescs()\n    {\n        return k_propertyDescs;\n    }\n    //-------------------------------------------------------------------\n    //-------------------------------------------------------------------\n    ProgressBarUIComponent::ProgressBarUIComponent(const std::string& in_componentName, const PropertyMap& in_properties)\n        : UIComponent(in_componentName), m_relBarSize(1.0f, 1.0f)\n    {\n        RegisterProperty<Vector2>(PropertyTypes::Vector2(), k_relBarSizeKey, MakeDelegate(this, &ProgressBarUIComponent::GetRelativeBarSize), MakeDelegate(this, &ProgressBarUIComponent::SetRelativeBarSize));\n        RegisterProperty<f32>(PropertyTypes::Float(), k_progressKey, MakeDelegate(this, &ProgressBarUIComponent::GetProgress), MakeDelegate(this, &ProgressBarUIComponent::SetProgress));\n        RegisterProperty<ProgressBarType>(PropertyTypes::ProgressBarType(), k_barTypeKey, MakeDelegate(this, &ProgressBarUIComponent::GetBarType), MakeDelegate(this, &ProgressBarUIComponent::SetBarType));\n        RegisterProperty<ProgressBarDirection>(PropertyTypes::ProgressBarDirection(), k_barDirectionKey, MakeDelegate(this, &ProgressBarUIComponent::GetBarDirection), MakeDelegate(this, &ProgressBarUIComponent::SetBarDirection));\n        RegisterProperty<std::string>(PropertyTypes::String(), k_barWidgetName, MakeDelegate(this, &ProgressBarUIComponent::GetBarWidgetName), MakeDelegate(this, &ProgressBarUIComponent::SetBarWidgetName));\n        ApplyRegisteredProperties(in_properties);\n        \n        CS_ASSERT(m_barWidgetName.empty() == false, \"Bar widget name must be set on a progress bar component.\");\n    }\n    //-------------------------------------------------------------------\n    //-------------------------------------------------------------------\n    bool ProgressBarUIComponent::IsA(InterfaceIDType in_interfaceId) const\n    {\n        return (UIComponent::InterfaceID == in_interfaceId || ProgressBarUIComponent::InterfaceID == in_interfaceId);\n    }\n    //-------------------------------------------------------------------\n    //-------------------------------------------------------------------\n    const Vector2& ProgressBarUIComponent::GetRelativeBarSize() const\n    {\n        return m_relBarSize;\n    }\n    //-------------------------------------------------------------------\n    //-------------------------------------------------------------------\n    f32 ProgressBarUIComponent::GetProgress() const\n    {\n        return m_progress;\n    }\n    //-------------------------------------------------------------------\n    //-------------------------------------------------------------------\n    ProgressBarType ProgressBarUIComponent::GetBarType() const\n    {\n        return m_barType;\n    }\n    //-------------------------------------------------------------------\n    //-------------------------------------------------------------------\n    ProgressBarDirection ProgressBarUIComponent::GetBarDirection() const\n    {\n        return m_direction;\n    }\n    //-------------------------------------------------------------------\n    //-------------------------------------------------------------------\n    const std::string& ProgressBarUIComponent::GetBarWidgetName() const\n    {\n        return m_barWidgetName;\n    }\n    //-------------------------------------------------------------------\n    //-------------------------------------------------------------------\n    void ProgressBarUIComponent::SetRelativeBarSize(const Vector2& in_relSize)\n    {\n        m_relBarSize = in_relSize;\n        \n        UpdateBar();\n    }\n    //-------------------------------------------------------------------\n    //-------------------------------------------------------------------\n    void ProgressBarUIComponent::SetProgress(f32 in_progress)\n    {\n        CS_ASSERT(in_progress >= 0.0f && in_progress <= 1.0f, \"Progress must be in the range: 0.0 - 1.0\");\n        \n        m_progress = in_progress;\n        \n        UpdateBar();\n    }\n    //-------------------------------------------------------------------\n    //-------------------------------------------------------------------\n    void ProgressBarUIComponent::SetBarType(ProgressBarType in_barType)\n    {\n        m_barType = in_barType;\n        \n        UpdateBar();\n    }\n    //-------------------------------------------------------------------\n    //-------------------------------------------------------------------\n    void ProgressBarUIComponent::SetBarDirection(ProgressBarDirection in_direction)\n    {\n        m_direction = in_direction;\n        \n        UpdateBar();\n    }\n    //-------------------------------------------------------------------\n    //-------------------------------------------------------------------\n    void ProgressBarUIComponent::SetBarWidgetName(const std::string& in_name)\n    {\n        CS_ASSERT(m_barWidgetName.empty(), \"Cannot change the bar widget on a progress bar component.\");\n        \n        m_barWidgetName = in_name;\n        \n        UpdateBar();\n    }\n    //-------------------------------------------------------------------\n    //-------------------------------------------------------------------\n    void ProgressBarUIComponent::UpdateBar()\n    {\n        if (m_barWidget != nullptr)\n        {\n            if (m_direction == ProgressBarDirection::k_horizontal)\n            {\n                UpdateHorizontalBar();\n            }\n            else\n            {\n                UpdateVerticalBar();\n            }\n        }\n    }\n    //-------------------------------------------------------------------\n    //-------------------------------------------------------------------\n    void ProgressBarUIComponent::UpdateHorizontalBar()\n    {\n        Vector2 relBarPosition = Vector2(0.5f * (1.0f - m_relBarSize.x), 0.0f);\n        Vector2 relBarSize = m_relBarSize;\n        relBarSize.x *= m_progress;\n        \n        m_barWidget->SetParentalAnchor(AlignmentAnchor::k_middleLeft);\n        m_barWidget->SetOriginAnchor(AlignmentAnchor::k_middleLeft);\n        m_barWidget->SetRelativePosition(relBarPosition);\n        m_barWidget->SetRelativeSize(relBarSize);\n        \n        if (m_barType == ProgressBarType::k_fill)\n        {\n            CS_ASSERT(m_barDrawableComponent != nullptr, \"Fill type progress bar cannot have a bar widget without a drawable component.\");\n            \n            if (m_barDrawableComponent->GetDrawable() != nullptr)\n            {\n                m_barDrawableComponent->GetDrawable()->SetUVs(UVs(0.0f, 0.0f, m_progress, 1.0f));\n            }\n        }\n        else if (m_barDrawableComponent != nullptr && m_barDrawableComponent->GetDrawable() != nullptr)\n        {\n            m_barDrawableComponent->GetDrawable()->SetUVs(UVs(0.0f, 0.0f, 1.0f, 1.0f));\n        }\n    }\n    //-------------------------------------------------------------------\n    //-------------------------------------------------------------------\n    void ProgressBarUIComponent::UpdateVerticalBar()\n    {\n        Vector2 relBarPosition = Vector2(0.0f, 0.5f * (1.0f - m_relBarSize.y));\n        Vector2 relBarSize = m_relBarSize;\n        relBarSize.y *= m_progress;\n        \n        m_barWidget->SetParentalAnchor(AlignmentAnchor::k_bottomCentre);\n        m_barWidget->SetOriginAnchor(AlignmentAnchor::k_bottomCentre);\n        m_barWidget->SetRelativePosition(relBarPosition);\n        m_barWidget->SetRelativeSize(relBarSize);\n        \n        if (m_barType == ProgressBarType::k_fill)\n        {\n            CS_ASSERT(m_barDrawableComponent != nullptr, \"Fill type progress bar cannot have a bar widget without a drawable component.\");\n            \n            if (m_barDrawableComponent->GetDrawable() != nullptr)\n            {\n                m_barDrawableComponent->GetDrawable()->SetUVs(UVs(0.0f, 1.0f - m_progress, 1.0f, m_progress));\n            }\n        }\n        else if (m_barDrawableComponent != nullptr && m_barDrawableComponent->GetDrawable() != nullptr)\n        {\n            m_barDrawableComponent->GetDrawable()->SetUVs(UVs(0.0f, 0.0f, 1.0f, 1.0f));\n        }\n    }\n    //-------------------------------------------------------------------\n    //-------------------------------------------------------------------\n    void ProgressBarUIComponent::OnInit()\n    {\n        m_barWidget = GetWidget()->GetInternalWidget(m_barWidgetName);\n        CS_ASSERT(m_barWidget != nullptr, \"Could not find bar widget with name: \" + m_barWidgetName);\n        \n        m_barDrawableComponent = m_barWidget->GetComponent<DrawableUIComponent>();\n        \n        UpdateBar();\n    }\n    //-------------------------------------------------------------------\n    //-------------------------------------------------------------------\n    void ProgressBarUIComponent::OnDestroy()\n    {\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/UI/ProgressBar/ProgressBarUIComponent.h",
    "content": "//\n//  ProgressBarUIComponent.h\n//  ChilliSource\n//  Created by Ian Copland on 01/12/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_UI_PROGRESSBAR_PROGRESSBARUICOMPONENT_H_\n#define _CHILLISOURCE_UI_PROGRESSBAR_PROGRESSBARUICOMPONENT_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Container/Property/PropertyMap.h>\n#include <ChilliSource/Core/Event/EventConnection.h>\n#include <ChilliSource/Input/Pointer/Pointer.h>\n#include <ChilliSource/UI/Base/UIComponent.h>\n#include <ChilliSource/UI/ProgressBar/ProgressBarDirection.h>\n#include <ChilliSource/UI/ProgressBar/ProgressBarType.h>\n\nnamespace ChilliSource\n{\n    //--------------------------------------------------------------------------\n    /// A logic component for controlling a progress bar. This handles both\n    /// vertical and horizontal progress bar types.\n    ///\n    /// \"RelBarSize\": A Vector2 describing the relative size of the bar when\n    /// progress is at 100%. This defaults to (1.0, 1.0).\n    ///\n    /// \"Progress\": A float describing the current progress of the bar. This\n    /// must be in the range 0.0-1.0. If a value outside this range is provided\n    /// the app is considered to be in an irrecoverable state and will terminate.\n    /// This defaults to 0.0.\n    ///\n    /// \"BarType\": A string describing the type of progress bar. The possible\n    /// values for this are \"Fill\" or \"Stretch\". A stretch progress bar\n    /// simply changes the size of the bar widget as progress changes. A\n    /// fill progress bar will also alter the UVs of the widgets drawable\n    /// such that it appears to reveal more of the bar as it progresses. This\n    /// defaults to \"Fill\". If using Fill the underlying bar widget must\n    /// have a UIDrawable UIComponent, otherwise the app is considered to be in an\n    /// irrecoverable state and will terminate.\n    ///\n    /// \"BarDirection\": A string describing the direction of the progress bar.\n    /// The possible values are 'Horizontal' or 'Vertical' and defaults to\n    /// 'Horizontal'.\n    ///\n    /// \"BarWidgetName\": The name of the internal widget that should be used\n    /// as the progress bar. This cannot be changed after the initial creation\n    /// of the component. Attempting to set it using SetProperty will cause the\n    /// app to be in an irrecoverable state and terminate. Typically this is not\n    /// exposed to the user of the widget.\n    ///\n    /// @author Ian Copland\n    //--------------------------------------------------------------------------\n    class ProgressBarUIComponent final : public UIComponent\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(ProgressBarUIComponent);\n        //-------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The list of properties supported by a progress bar component.\n        //-------------------------------------------------------------------\n        static const std::vector<PropertyMap::PropertyDesc>& GetPropertyDescs();\n        //-------------------------------------------------------------------\n        /// Allows querying of whether or not the component implements the\n        /// interface associated with the given interface Id. Typically\n        /// this won't be called directly, instead the templated version\n        /// IsA<Interface>() should be used.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The interface Id.\n        ///\n        /// @return Whether the object implements the given interface.\n        //-------------------------------------------------------------------\n        bool IsA(InterfaceIDType in_interfaceId) const override;\n        //-------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param The relative size of the bar when it is at 100% progress.\n        //-------------------------------------------------------------------\n        const Vector2& GetRelativeBarSize() const;\n        //-------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param The current progress of the bar.\n        //-------------------------------------------------------------------\n        f32 GetProgress() const;\n        //-------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param The type of the progress bar: Fill or Stretch.\n        //-------------------------------------------------------------------\n        ProgressBarType GetBarType() const;\n        //-------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param The direction of the progress bar: horizontal or vertical.\n        //-------------------------------------------------------------------\n        ProgressBarDirection GetBarDirection() const;\n        //-------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The name of the bar widget.\n        //-------------------------------------------------------------------\n        const std::string& GetBarWidgetName() const;\n        //-------------------------------------------------------------------\n        /// Sets the relative size of the bar when it is at 100% progress.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The new relative size.\n        //-------------------------------------------------------------------\n        void SetRelativeBarSize(const Vector2& in_relSize);\n        //-------------------------------------------------------------------\n        /// Sets the current progress of the bar. This must be in the range\n        /// 0.0 to 1.0. If a value outside this range is provided the app\n        /// is considered to be in an irrecoverable state and will terminate.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The new progress.\n        //-------------------------------------------------------------------\n        void SetProgress(f32 in_progress);\n        //-------------------------------------------------------------------\n        /// Sets the type of the progress bar: Fill or Stretch.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The bar type.\n        //-------------------------------------------------------------------\n        void SetBarType(ProgressBarType in_barType);\n        //-------------------------------------------------------------------\n        /// Sets the direction of the progress bar: horizontal or vertical.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The direction.\n        //-------------------------------------------------------------------\n        void SetBarDirection(ProgressBarDirection in_direction);\n\n    private:\n        friend class UIComponentFactory;\n        //-------------------------------------------------------------------\n        /// Constructor that builds the component from key-value properties.\n        /// The properties used to create a progress bar component are described\n        /// in the class documentation.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The component name.\n        /// @param The property map.\n        //-------------------------------------------------------------------\n        ProgressBarUIComponent(const std::string& in_componentName, const PropertyMap& in_properties);\n        //-------------------------------------------------------------------\n        /// Sets the name of the bar widget. This can only be called once,\n        /// on construction. If this is called a second time the app is\n        /// considered to be in an irrecoverable state and will terminate.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @return The name of the bar widget.\n        //-------------------------------------------------------------------\n        void SetBarWidgetName(const std::string& in_name);\n        //-------------------------------------------------------------------\n        /// Updates the size of the bar and applies fill if the bar is of\n        /// the \"fill\" type.\n        ///\n        /// @author Ian Copland\n        //-------------------------------------------------------------------\n        void UpdateBar();\n        //-------------------------------------------------------------------\n        /// Updates the size of the bar and applies fill if the bar is of\n        /// the \"fill\" type for horizontal bar types.\n        ///\n        /// @author Ian Copland\n        //-------------------------------------------------------------------\n        void UpdateHorizontalBar();\n        //-------------------------------------------------------------------\n        /// Updates the size of the bar and applies fill if the bar is of\n        /// the \"fill\" type for vertical bar types.\n        ///\n        /// @author Ian Copland\n        //-------------------------------------------------------------------\n        void UpdateVerticalBar();\n        //-------------------------------------------------------------------\n        /// Called when the component is first added to the owning widget.\n        ///\n        /// @author Ian Copland\n        //-------------------------------------------------------------------\n        void OnInit() override;\n        //-------------------------------------------------------------------\n        /// Called when the owning widget is being destructed.\n        ///\n        /// @author Ian Copland\n        //-------------------------------------------------------------------\n        void OnDestroy() override;\n        \n        Vector2 m_relBarSize;\n        f32 m_progress = 0.0f;\n        ProgressBarType m_barType = ProgressBarType::k_fill;\n        ProgressBarDirection m_direction = ProgressBarDirection::k_horizontal;\n        std::string m_barWidgetName;\n        \n        Widget* m_barWidget = nullptr;\n        DrawableUIComponent* m_barDrawableComponent = nullptr;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/UI/ProgressBar.h",
    "content": "//\n//  ProgressBar.h\n//  ChilliSource\n//  Created by Ian Copland on 01/12/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n\n#ifndef _CHILLISOURCE_UI_PROGRESSBAR_H_\n#define _CHILLISOURCE_UI_PROGRESSBAR_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/UI/ProgressBar/ProgressBarUIComponent.h>\n#include <ChilliSource/UI/ProgressBar/ProgressBarDirection.h>\n#include <ChilliSource/UI/ProgressBar/ProgressBarType.h>\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/UI/Slider/SliderDirection.cpp",
    "content": "//\n//  SliderDirection.cpp\n//  ChilliSource\n//  Created by Ian Copland on 18/12/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/UI/Slider/SliderDirection.h>\n\n#include <ChilliSource/Core/String/StringUtils.h>\n\nnamespace ChilliSource\n{\n    const char k_directionHorizontal[] = \"horizontal\";\n    const char k_directionVertical[] = \"vertical\";\n    \n    //------------------------------------------------------------------------\n    //------------------------------------------------------------------------\n    SliderDirection ParseSliderDirection(const std::string& in_stringDirection)\n    {\n        std::string lowerDirection = in_stringDirection;\n        StringUtils::ToLowerCase(lowerDirection);\n        \n        if (lowerDirection == k_directionHorizontal)\n        {\n            return SliderDirection::k_horizontal;\n        }\n        else if (lowerDirection == k_directionVertical)\n        {\n            return SliderDirection::k_vertical;\n        }\n        \n        CS_LOG_FATAL(\"Could not parse slider direction: \" + in_stringDirection);\n        return SliderDirection::k_horizontal;\n    }\n    //------------------------------------------------------------------------\n    //------------------------------------------------------------------------\n    std::string ToString(SliderDirection in_direction)\n    {\n        switch (in_direction)\n        {\n            case SliderDirection::k_horizontal:\n                return k_directionHorizontal;\n            case SliderDirection::k_vertical:\n                return k_directionVertical;\n            default:\n                CS_LOG_FATAL(\"Invalid slider direction.\");\n                return k_directionHorizontal;\n                \n        }\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/UI/Slider/SliderDirection.h",
    "content": "//\n//  SliderDirection.h\n//  ChilliSource\n//  Created by Ian Copland on 18/12/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_UI_SLIDER_SLIDERDIRECTION_H_\n#define _CHILLISOURCE_UI_SLIDER_SLIDERDIRECTION_H_\n\n#include <ChilliSource/ChilliSource.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------\n    /// An enum describing the direction of a slider: vertical or\n    /// horizontal.\n    ///\n    /// @author Ian Copland\n    //------------------------------------------------------------------------\n    enum class SliderDirection\n    {\n        k_horizontal,\n        k_vertical\n    };\n    //------------------------------------------------------------------------\n    /// Parse a slider direction from string. This is case insensitive.\n    /// If the string is not a valid direction then the app is considered to\n    /// be in an irrecoverable state and will terminate.\n    ///\n    /// @author Ian Copland\n    ///\n    /// @param The string to parse.\n    ///\n    /// @return The parsed direction.\n    //------------------------------------------------------------------------\n    SliderDirection ParseSliderDirection(const std::string& in_stringDirection);\n    //------------------------------------------------------------------------\n    /// Converts the given slider direction to a string.\n    ///\n    /// @author Ian Copland\n    ///\n    /// @param The slider direction to convert to string.\n    ///\n    /// @return The direction in string form.\n    //------------------------------------------------------------------------\n    std::string ToString(SliderDirection in_direction);\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/UI/Slider/SliderUIComponent.cpp",
    "content": "//\n//  SliderUIComponent.cpp\n//  ChilliSource\n//  Created by Ian Copland on 18/12/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/UI/Slider/SliderUIComponent.h>\n\n#include <ChilliSource/Core/Delegate/MakeDelegate.h>\n#include <ChilliSource/Core/Container/VectorUtils.h>\n#include <ChilliSource/Core/Container/Property/PropertyTypes.h>\n#include <ChilliSource/Core/Math/MathUtils.h>\n#include <ChilliSource/Rendering/Texture/UVs.h>\n#include <ChilliSource/UI/Base/PropertyTypes.h>\n#include <ChilliSource/UI/Base/Widget.h>\n#include <ChilliSource/UI/Drawable/UIDrawable.h>\n#include <ChilliSource/UI/Drawable/DrawableUIComponent.h>\n\nnamespace ChilliSource\n{\n    namespace\n    {\n        const char k_sliderSizeKey[] = \"SliderSize\";\n        const char k_sliderPositionKey[] = \"SliderPosition\";\n        const char k_sliderDirectionKey[] = \"SliderDirection\";\n        const char k_sliderWidgetName[] = \"SliderWidgetName\";\n        \n        const std::vector<PropertyMap::PropertyDesc> k_propertyDescs =\n        {\n            {PropertyTypes::Float(), k_sliderSizeKey},\n            {PropertyTypes::Float(), k_sliderPositionKey},\n            {PropertyTypes::SliderDirection(), k_sliderDirectionKey},\n            {PropertyTypes::String(), k_sliderWidgetName}\n        };\n    }\n    \n    CS_DEFINE_NAMEDTYPE(SliderUIComponent);\n    //-------------------------------------------------------------------\n    //-------------------------------------------------------------------\n    const std::vector<PropertyMap::PropertyDesc>& SliderUIComponent::GetPropertyDescs()\n    {\n        return k_propertyDescs;\n    }\n    //-------------------------------------------------------------------\n    //-------------------------------------------------------------------\n    SliderUIComponent::SliderUIComponent(const std::string& in_componentName, const PropertyMap& in_properties)\n        : UIComponent(in_componentName)\n    {\n        RegisterProperty<f32>(PropertyTypes::Float(), k_sliderSizeKey, MakeDelegate(this, &SliderUIComponent::GetSliderSize), MakeDelegate(this, &SliderUIComponent::SetSliderSize));\n        RegisterProperty<f32>(PropertyTypes::Float(), k_sliderPositionKey, MakeDelegate(this, &SliderUIComponent::GetSliderPosition), MakeDelegate(this, &SliderUIComponent::SetSliderPosition));\n        RegisterProperty<SliderDirection>(PropertyTypes::SliderDirection(), k_sliderDirectionKey, MakeDelegate(this, &SliderUIComponent::GetSliderDirection), MakeDelegate(this, &SliderUIComponent::SetSliderDirection));\n        RegisterProperty<std::string>(PropertyTypes::String(), k_sliderWidgetName, MakeDelegate(this, &SliderUIComponent::GetSliderWidgetName), MakeDelegate(this, &SliderUIComponent::SetSliderWidgetName));\n        ApplyRegisteredProperties(in_properties);\n        \n        CS_ASSERT(m_sliderWidgetName.empty() == false, \"Slider widget name must be set on a Slider component.\");\n    }\n    //-------------------------------------------------------------------\n    //-------------------------------------------------------------------\n    bool SliderUIComponent::IsA(InterfaceIDType in_interfaceId) const\n    {\n        return (UIComponent::InterfaceID == in_interfaceId || SliderUIComponent::InterfaceID == in_interfaceId);\n    }\n    //-------------------------------------------------------------------\n    //-------------------------------------------------------------------\n    f32 SliderUIComponent::GetSliderSize() const\n    {\n        return m_sliderSize;\n    }\n    //-------------------------------------------------------------------\n    //-------------------------------------------------------------------\n    f32 SliderUIComponent::GetSliderPosition() const\n    {\n        return m_sliderPos;\n    }\n    //-------------------------------------------------------------------\n    //-------------------------------------------------------------------\n    SliderDirection SliderUIComponent::GetSliderDirection() const\n    {\n        return m_direction;\n    }\n    //-------------------------------------------------------------------\n    //-------------------------------------------------------------------\n    const std::string& SliderUIComponent::GetSliderWidgetName() const\n    {\n        return m_sliderWidgetName;\n    }\n    //-------------------------------------------------------------------\n    //-------------------------------------------------------------------\n    void SliderUIComponent::SetSliderSize(f32 in_size)\n    {\n        m_sliderSize = in_size;\n        \n        UpdateSlider();\n    }\n    //-------------------------------------------------------------------\n    //-------------------------------------------------------------------\n    void SliderUIComponent::SetSliderPosition(f32 in_sliderPos)\n    {\n        CS_ASSERT(in_sliderPos >= 0.0f && in_sliderPos <= 1.0f, \"Slider must be in the range: 0.0 - 1.0\");\n        \n        m_sliderPos = in_sliderPos;\n        \n        UpdateSlider();\n    }\n    //-------------------------------------------------------------------\n    //-------------------------------------------------------------------\n    void SliderUIComponent::SetSliderDirection(SliderDirection in_direction)\n    {\n        m_direction = in_direction;\n        \n        UpdateSlider();\n    }\n    //-------------------------------------------------------------------\n    //-------------------------------------------------------------------\n    void SliderUIComponent::SetSliderWidgetName(const std::string& in_name)\n    {\n        CS_ASSERT(m_sliderWidgetName.empty(), \"Cannot change the bar widget on a Slider component.\");\n        \n        m_sliderWidgetName = in_name;\n        \n        UpdateSlider();\n    }\n    //-------------------------------------------------------------------\n    //-------------------------------------------------------------------\n    void SliderUIComponent::UpdateSlider()\n    {\n        if (m_sliderWidget != nullptr && GetWidget() != nullptr && GetWidget()->IsOnCanvas() == true)\n        {\n            if (m_direction == SliderDirection::k_horizontal)\n            {\n                m_sliderWidget->SetParentalAnchor(AlignmentAnchor::k_middleLeft);\n                m_sliderWidget->SetOriginAnchor(AlignmentAnchor::k_middleLeft);\n                m_sliderWidget->SetSizePolicy(SizePolicy::k_useHeightMaintainingAspect);\n                m_sliderWidget->SetRelativeSize(Vector2(0.0f, m_sliderSize));\n                \n                f32 padding = m_sliderWidget->GetFinalSize().x / GetWidget()->GetFinalSize().x;\n                m_sliderWidget->SetRelativePosition(Vector2(m_sliderPos * (1.0f - padding), 0.0f));\n            }\n            else\n            {\n                m_sliderWidget->SetParentalAnchor(AlignmentAnchor::k_bottomCentre);\n                m_sliderWidget->SetOriginAnchor(AlignmentAnchor::k_bottomCentre);\n                m_sliderWidget->SetSizePolicy(SizePolicy::k_useWidthMaintainingAspect);\n                m_sliderWidget->SetRelativeSize(Vector2(m_sliderSize, 0.0f));\n                \n                f32 padding = m_sliderWidget->GetFinalSize().y / GetWidget()->GetFinalSize().y;\n                m_sliderWidget->SetRelativePosition(Vector2(0.0f, m_sliderPos * (1.0f - padding)));\n            }\n        }\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void SliderUIComponent::UpdateSliderFromScreenPosition(const Vector2& in_screenSpacePos)\n    {\n        CS_ASSERT(GetWidget() != nullptr, \"Must have an owning widget to update slider from screen position.\");\n        CS_ASSERT(GetWidget()->IsOnCanvas() == true, \"Owning widget must be on the canvas to update slider from screen position.\");\n        \n        Vector2 localSpacePoint = GetWidget()->ToLocalSpace(in_screenSpacePos, AlignmentAnchor::k_middleCentre);\n        Vector2 ownerSize = GetWidget()->GetFinalSize();\n        \n        if (m_direction == SliderDirection::k_horizontal)\n        {\n            f32 padding = m_sliderWidget->GetFinalSize().x;\n            f32 range = ownerSize.x - padding;\n            f32 pointClamped = MathUtils::Clamp(0.5f * range + localSpacePoint.x, 0.0f, range);\n            f32 relativePoint = pointClamped / range;\n            SetSliderPosition(relativePoint);\n        }\n        else\n        {\n            f32 padding = m_sliderWidget->GetFinalSize().y;\n            f32 range = ownerSize.y - padding;\n            f32 pointClamped = MathUtils::Clamp(0.5f * range + localSpacePoint.y, 0.0f, range);\n            f32 relativePoint = pointClamped / range;\n            SetSliderPosition(relativePoint);\n        }\n    }\n    //-------------------------------------------------------------------\n    //-------------------------------------------------------------------\n    void SliderUIComponent::OnInit()\n    {\n        m_sliderWidget = GetWidget()->GetInternalWidget(m_sliderWidgetName);\n        CS_ASSERT(m_sliderWidget != nullptr, \"Could not find bar widget with name: \" + m_sliderWidgetName);\n        \n        m_pressedInsideConnection = GetWidget()->GetPressedInsideEvent().OpenConnection(MakeDelegate(this, &SliderUIComponent::OnPressedInside));\n        m_draggedInsideConnection = GetWidget()->GetDraggedInsideEvent().OpenConnection(MakeDelegate(this, &SliderUIComponent::OnDraggedInside));\n        m_draggedOutsideConnection = GetWidget()->GetDraggedOutsideEvent().OpenConnection(MakeDelegate(this, &SliderUIComponent::OnDraggedOutside));\n        m_releasedInsideConnection = GetWidget()->GetReleasedInsideEvent().OpenConnection(MakeDelegate(this, &SliderUIComponent::OnReleasedInside));\n        m_releasedOutsideConnection = GetWidget()->GetReleasedOutsideEvent().OpenConnection(MakeDelegate(this, &SliderUIComponent::OnReleasedOutside));\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void SliderUIComponent::OnAddedToCanvas()\n    {\n        UpdateSlider();\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void SliderUIComponent::OnPressedInside(Widget* in_widget, const Pointer& in_pointer, Pointer::InputType in_inputType)\n    {\n        if (in_inputType == Pointer::GetDefaultInputType())\n        {\n            m_activePointerIds.push_back(in_pointer.GetId());\n            UpdateSliderFromScreenPosition(in_pointer.GetPosition());\n        }\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void SliderUIComponent::OnDraggedInside(Widget* in_widget, const Pointer& in_pointer)\n    {\n        if (VectorUtils::Contains(m_activePointerIds, in_pointer.GetId()) == true)\n        {\n            UpdateSliderFromScreenPosition(in_pointer.GetPosition());\n        }\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void SliderUIComponent::OnDraggedOutside(Widget* in_widget, const Pointer& in_pointer)\n    {\n        if (VectorUtils::Contains(m_activePointerIds, in_pointer.GetId()) == true)\n        {\n            UpdateSliderFromScreenPosition(in_pointer.GetPosition());\n        }\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void SliderUIComponent::OnReleasedInside(Widget* in_widget, const Pointer& in_pointer, Pointer::InputType in_inputType)\n    {\n        if (VectorUtils::Contains(m_activePointerIds, in_pointer.GetId()) == true)\n        {\n            UpdateSliderFromScreenPosition(in_pointer.GetPosition());\n            VectorUtils::Remove(m_activePointerIds, in_pointer.GetId());\n        }\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void SliderUIComponent::OnReleasedOutside(Widget* in_widget, const Pointer& in_pointer, Pointer::InputType in_inputType)\n    {\n        if (VectorUtils::Contains(m_activePointerIds, in_pointer.GetId()) == true)\n        {\n            UpdateSliderFromScreenPosition(in_pointer.GetPosition());\n            VectorUtils::Remove(m_activePointerIds, in_pointer.GetId());\n        }\n    }\n    //-------------------------------------------------------------------\n    //-------------------------------------------------------------------\n    void SliderUIComponent::OnDestroy()\n    {\n        m_pressedInsideConnection.reset();\n        m_draggedInsideConnection.reset();\n        m_draggedOutsideConnection.reset();\n        m_releasedInsideConnection.reset();\n        m_releasedOutsideConnection.reset();\n        \n        m_activePointerIds.clear();\n        m_sliderWidget = nullptr;\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/UI/Slider/SliderUIComponent.h",
    "content": "//\n//  SliderUIComponent.h\n//  ChilliSource\n//  Created by Ian Copland on 18/12/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_UI_SLIDER_SLIDERUICOMPONENT_H_\n#define _CHILLISOURCE_UI_SLIDER_SLIDERUICOMPONENT_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Container/Property/PropertyMap.h>\n#include <ChilliSource/Core/Event/EventConnection.h>\n#include <ChilliSource/Input/Pointer/Pointer.h>\n#include <ChilliSource/UI/Base/UIComponent.h>\n#include <ChilliSource/UI/Slider/SliderDirection.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    /// A logic component for controlling a slider. This handles both vertical\n    /// and horizontal slider types.\n    ///\n    /// \"SliderSize\": A float describing the size of the slider relative to the\n    /// slider background. The size is dependant on the direction of the slider,\n    /// a horzontal slider bases the size of the height of the background, a\n    /// vertical slider bases the size of the width of the background. In either\n    /// case the slider maintains it aspect ratio based on this size. This\n    /// defaults to 1.0.\n    ///\n    /// \"SliderPosition\": A float describing the current postition of the slider.\n    /// This must be in the range 0.0-1.0. If a value outside this range is provided\n    /// the app is considered to be in an irrecoverable state and will terminate.\n    /// This defaults to 0.0.\n    ///\n    /// \"SliderDirection\": A string describing the direction of the slider. The\n    /// possible values are 'Horizontal' or 'Vertical' and defaults to Horizontal'.\n    ///\n    /// \"SliderWidgetName\": The name of the internal widget that should be used as\n    /// the slider. This cannot be changed after the initial creation of the component.\n    /// Attempting to set it using SetProperty will cause the app to be in an\n    /// irrecoverable state and terminate. Typically this is not exposed to the user\n    /// of the widget.\n    ///\n    /// @author Ian Copland\n    //------------------------------------------------------------------------------\n    class SliderUIComponent final : public UIComponent\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(SliderUIComponent);\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The list of properties supported by a progress bar component.\n        //------------------------------------------------------------------------------\n        static const std::vector<PropertyMap::PropertyDesc>& GetPropertyDescs();\n        //------------------------------------------------------------------------------\n        /// Allows querying of whether or not the component implements the interface\n        /// associated with the given interface Id. Typically this won't be called\n        /// directly, instead the templated version IsA<Interface>() should be used.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The interface Id.\n        ///\n        /// @return Whether the object implements the given interface.\n        //------------------------------------------------------------------------------\n        bool IsA(InterfaceIDType in_interfaceId) const override;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param The size of the slider relative to the slider background. The size is\n        /// dependant on the direction of the slider, a horzontal slider bases the size\n        /// of the height of the background, a vertical slider bases the size of the\n        /// width of the background. In either case the slider maintains it aspect ratio\n        /// based on this size.\n        //------------------------------------------------------------------------------\n        f32 GetSliderSize() const;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param The current position of the slider. This is in the range 0.0 - 1.0.\n        //------------------------------------------------------------------------------\n        f32 GetSliderPosition() const;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param The direction of the slider: horizontal or vertical.\n        //------------------------------------------------------------------------------\n        SliderDirection GetSliderDirection() const;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The name of the slider widget.\n        //------------------------------------------------------------------------------\n        const std::string& GetSliderWidgetName() const;\n        //------------------------------------------------------------------------------\n        /// Sets the size of the slider relative to the slider background. The size is\n        /// dependant on the direction of the slider, a horzontal slider bases the size\n        /// of the height of the background, a vertical slider bases the size of the\n        /// width of the background. In either case the slider maintains it aspect ratio\n        /// based on this size.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The new relative size.\n        //------------------------------------------------------------------------------\n        void SetSliderSize(f32 in_size);\n        //------------------------------------------------------------------------------\n        /// Sets the position of the slider. This has to be in the range 0.0 - 1.0. If\n        /// it is out of that range the app is considered to be in an irrecoverable\n        /// state and will terminate.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The slider position.\n        //------------------------------------------------------------------------------\n        void SetSliderPosition(f32 in_sliderPos);\n        //------------------------------------------------------------------------------\n        /// Sets the direction of the slider: horizontal or vertical.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The direction.\n        //------------------------------------------------------------------------------\n        void SetSliderDirection(SliderDirection in_direction);\n\n    private:\n        friend class UIComponentFactory;\n        //------------------------------------------------------------------------------\n        /// Constructor that builds the component from key-value properties. The\n        /// properties used to create a slider component are described in the class\n        /// documentation.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The component name.\n        /// @param The property map.\n        //------------------------------------------------------------------------------\n        SliderUIComponent(const std::string& in_componentName, const PropertyMap& in_properties);\n        //------------------------------------------------------------------------------\n        /// Sets the name of the slider widget. This can only be called once, on\n        /// construction. If this is called a second time the app is considered to be in\n        /// an irrecoverable state and will terminate.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @return The name of the slider widget.\n        //------------------------------------------------------------------------------\n        void SetSliderWidgetName(const std::string& in_name);\n        //------------------------------------------------------------------------------\n        /// Updates the size and position of the slider.\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------------------------------------\n        void UpdateSlider();\n        //------------------------------------------------------------------------------\n        /// Updates the size and position of the slider from a screen space position.\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------------------------------------\n        void UpdateSliderFromScreenPosition(const Vector2& in_screenSpacePos);\n        //------------------------------------------------------------------------------\n        /// Called when the component is first added to the owning widget.\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------------------------------------\n        void OnInit() override;\n        //------------------------------------------------------------------------------\n        /// This is called when the owning widget is added to the canvas.\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------------------------------------\n        void OnAddedToCanvas() override;\n        //------------------------------------------------------------------------------\n        /// Called when a pointer is pressed inside the bounds of the owning widget.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The owning widget.\n        /// @param The pointer that was pressed.\n        /// @param The type of input.\n        //------------------------------------------------------------------------------\n        void OnPressedInside(Widget* in_widget, const Pointer& in_pointer, Pointer::InputType in_inputType);\n        //------------------------------------------------------------------------------\n        /// Called when the owning widget receives an input drag event inside its bounds\n        /// having previously received one inside the bounds.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The owning widget.\n        /// @param The pointer that was pressed.\n        //------------------------------------------------------------------------------\n        void OnDraggedInside(Widget* in_widget, const Pointer& in_pointer);\n        //------------------------------------------------------------------------------\n        /// Called when the owning widget receives an input move event outside its\n        /// bounds having previously received one inside the bounds.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The owning widget.\n        /// @param The pointer that was pressed.\n        //------------------------------------------------------------------------------\n        void OnDraggedOutside(Widget* in_widget, const Pointer& in_pointer);\n        //------------------------------------------------------------------------------\n        /// Called when a pointer is released inside the bounds of the owning widget\n        /// after having been pressed inside.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The owning widget.\n        /// @param The pointer that was pressed.\n        /// @param The type of input.\n        //------------------------------------------------------------------------------\n        void OnReleasedInside(Widget* in_widget, const Pointer& in_pointer, Pointer::InputType in_inputType);\n        //------------------------------------------------------------------------------\n        /// Called when a pointer is released outside the bounds of the owning widget\n        /// after having been pressed inside.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The owning widget.\n        /// @param The pointer that was pressed.\n        /// @param The type of input.\n        //------------------------------------------------------------------------------\n        void OnReleasedOutside(Widget* in_widget, const Pointer& in_pointer, Pointer::InputType in_inputType);\n        //------------------------------------------------------------------------------\n        /// Called when the owning widget is being destructed.\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------------------------------------\n        void OnDestroy() override;\n        \n        f32 m_sliderSize = 1.0f;\n        f32 m_sliderPos = 0.5f;\n        SliderDirection m_direction = SliderDirection::k_horizontal;\n        std::string m_sliderWidgetName;\n        \n        Widget* m_sliderWidget = nullptr;\n        std::vector<Pointer::Id> m_activePointerIds;\n        \n        EventConnectionUPtr m_pressedInsideConnection;\n        EventConnectionUPtr m_draggedInsideConnection;\n        EventConnectionUPtr m_draggedOutsideConnection;\n        EventConnectionUPtr m_releasedInsideConnection;\n        EventConnectionUPtr m_releasedOutsideConnection;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/UI/Slider.h",
    "content": "//\n//  Slider.h\n//  ChilliSource\n//  Created by Ian Copland on 18/12/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n\n#ifndef _CHILLISOURCE_UI_SLIDER_H_\n#define _CHILLISOURCE_UI_SLIDER_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/UI/Slider/SliderUIComponent.h>\n#include <ChilliSource/UI/Slider/SliderDirection.h>\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/UI/Text/EditableTextUIComponent.cpp",
    "content": "//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n\n#include <ChilliSource/UI/Text/EditableTextUIComponent.h>\n\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/Container/VectorUtils.h>\n#include <ChilliSource/Core/Container/Property/PropertyMap.h>\n#include <ChilliSource/Core/Container/Property/PropertyTypes.h>\n#include <ChilliSource/Core/Delegate/MakeDelegate.h>\n#include <ChilliSource/UI/Base/Widget.h>\n#include <ChilliSource/UI/Base/PropertyTypes.h>\n\nnamespace ChilliSource\n{\n    namespace\n    {\n        const char k_initialTextKey[] = \"InitialText\";\n        const char k_maxCharactersKey[] = \"MaxCharacters\";\n        const char k_multilineDisabledKey[] = \"MultilineDisabled\";\n        const char k_inputTypeKey[] = \"InputType\";\n        const char k_capitalisationFormatKey[] = \"CapitalisationFormat\";\n\n        const std::vector<PropertyMap::PropertyDesc> k_propertyDescs =\n        {\n            { PropertyTypes::String(), k_initialTextKey },\n            { PropertyTypes::Int(), k_maxCharactersKey },\n            { PropertyTypes::Bool(), k_multilineDisabledKey },\n            { PropertyTypes::InputType(), k_inputTypeKey },\n            { PropertyTypes::CapitalisationFormat(), k_capitalisationFormatKey }\n        };\n    }\n\n    CS_DEFINE_NAMEDTYPE(EditableTextUIComponent);\n\n    //-------------------------------------------------------\n    const std::vector<PropertyMap::PropertyDesc>& EditableTextUIComponent::GetPropertyDescs() noexcept\n    {\n        return k_propertyDescs;\n    }\n\n    //-------------------------------------------------------\n    EditableTextUIComponent::EditableTextUIComponent(const std::string& componentName, const PropertyMap& properties) noexcept\n        : UIComponent(componentName) \n    {\n        RegisterProperty<std::string>(PropertyTypes::String(), k_initialTextKey, MakeDelegate(this, &EditableTextUIComponent::GetInitialText), MakeDelegate(this, &EditableTextUIComponent::SetInitialText));\n        RegisterProperty<s32>(PropertyTypes::Int(), k_maxCharactersKey, MakeDelegate(this, &EditableTextUIComponent::GetMaxCharacters), MakeDelegate(this, &EditableTextUIComponent::SetMaxCharacters));\n        RegisterProperty<bool>(PropertyTypes::Bool(), k_multilineDisabledKey, MakeDelegate(this, &EditableTextUIComponent::GetMultilineDisabled), MakeDelegate(this, &EditableTextUIComponent::SetMultilineDisabled));\n        RegisterProperty<ChilliSource::TextEntryType>(PropertyTypes::InputType(), k_inputTypeKey, MakeDelegate(this, &EditableTextUIComponent::GetInputType), MakeDelegate(this, &EditableTextUIComponent::SetInputType));\n        RegisterProperty<ChilliSource::TextEntryCapitalisation>(PropertyTypes::CapitalisationFormat(), k_capitalisationFormatKey, MakeDelegate(this, &EditableTextUIComponent::GetCapitalisationFormat), MakeDelegate(this, &EditableTextUIComponent::SetCapitalisationFormat));\n        ApplyRegisteredProperties(properties);\n    }\n\n    //--------------------------------------------------------\n    bool EditableTextUIComponent::IsA(InterfaceIDType interfaceId) const noexcept\n    {\n        return (UIComponent::InterfaceID == interfaceId || EditableTextUIComponent::InterfaceID == interfaceId);\n    }\n\n    //--------------------------------------------------------\n    const std::string& EditableTextUIComponent::GetInitialText() const noexcept\n    {\n        return m_initialText;\n    }\n\n    //--------------------------------------------------------\n    s32 EditableTextUIComponent::GetMaxCharacters() const noexcept\n    {\n        return m_maxCharacters;\n    }\n\n    //--------------------------------------------------------\n    bool EditableTextUIComponent::GetMultilineDisabled() const noexcept\n    {\n        return m_multilineDisabled;\n    }\n\n    //--------------------------------------------------------\n    const ChilliSource::TextEntryType& EditableTextUIComponent::GetInputType() const noexcept\n    {\n        return m_inputType;\n    }\n\n    //--------------------------------------------------------\n    const ChilliSource::TextEntryCapitalisation& EditableTextUIComponent::GetCapitalisationFormat() const noexcept\n    {\n        return m_capitalisationFormat;\n    }\n\n    //--------------------------------------------------------\n    void EditableTextUIComponent::SetInitialText(const std::string& text) noexcept\n    {\n        m_initialText = text;\n    }\n\n    //--------------------------------------------------------\n    void EditableTextUIComponent::SetMaxCharacters(s32 numCharacters) noexcept\n    {\n        m_maxCharacters = numCharacters;\n    }\n\n    //--------------------------------------------------------\n    void EditableTextUIComponent::SetMultilineDisabled(bool disabled) noexcept\n    {\n        m_multilineDisabled = disabled;\n    }\n\n    //--------------------------------------------------------\n    void EditableTextUIComponent::SetInputType(ChilliSource::TextEntryType type) noexcept\n    {\n        m_inputType = type;\n    }\n\n    //--------------------------------------------------------\n    void EditableTextUIComponent::SetCapitalisationFormat(ChilliSource::TextEntryCapitalisation format) noexcept\n    {\n        m_capitalisationFormat = format;\n    }\n\n    //--------------------------------------------------------\n    void EditableTextUIComponent::Activate() noexcept\n    {\n        CS_ASSERT(!m_active, \"Can't activate text entry if it is already active.\");\n        m_active = true;\n\n        if (m_textEntrySystem->IsActive())\n        {\n            m_textEntrySystem->Deactivate();\n        }\n\n        m_textEntrySystem->Activate(m_initialText, m_inputType, m_capitalisationFormat, MakeDelegate(this, &EditableTextUIComponent::OnTextChanged), MakeDelegate(this, &EditableTextUIComponent::OnTextEntryDismissed));\n    }\n\n    //---------------------------------------------------------\n    void EditableTextUIComponent::Deactivate() noexcept\n    {\n        CS_ASSERT(m_active, \"Can't deactivate text entry if it is not active.\");\n        m_active = false;\n\n        m_textEntrySystem->Deactivate();\n    }\n\n    //----------------------------------------------------------\n    bool EditableTextUIComponent::OnTextChanged(const std::string& newText) noexcept\n    {\n        // Make sure text is within set size, otherwise reject.\n        if (newText.size() > m_maxCharacters)\n        {\n            return false;\n        }\n\n        // Make sure the font can handle all the characters going in, otherwise reject text.\n        for (auto character : newText)\n        {\n            ChilliSource::Font::CharacterInfo info;\n            if (!m_textComponent->GetFont()->TryGetCharacterInfo(character, info))\n            {\n                return false;\n            }\n        }\n\n        m_textComponent->SetText(newText);\n\n        return true;\n    }\n\n    //----------------------------------------------------------\n    void EditableTextUIComponent::OnTextEntryDismissed() noexcept\n    {\n        // Update activation state.\n        m_active = false;\n    }\n\n    //-----------------------------------------------------------\n    void EditableTextUIComponent::OnReleasedInside(Widget* widget, const Pointer& pointer, Pointer::InputType inputType) noexcept\n    {\n        // Toggle activation status when element is pressed.\n        if (m_active)\n        {\n            Deactivate();\n        }\n        else\n        {\n            Activate();\n        }\n    }\n\n    //-----------------------------------------------------------\n    void EditableTextUIComponent::OnReleasedOutside(Widget* widget, const Pointer& pointer, Pointer::InputType inputType) noexcept\n    {\n        // If user presses outside of element, defocus and deactivate.\n        if (m_active)\n        {\n            Deactivate();\n        }\n    }\n\n    //------------------------------------------------------------\n    void EditableTextUIComponent::OnInit() noexcept\n    {\n        m_textEntrySystem = ChilliSource::Application::Get()->GetSystem<ChilliSource::TextEntry>();\n        CS_ASSERT(m_textEntrySystem, \"No active text entry system found.\");\n        m_textEntrySystem->SetTextBuffer(m_initialText);\n\n        m_textComponent = GetWidget()->GetComponent<TextUIComponent>();\n        CS_ASSERT(m_textComponent, \"No text component found in editable text widget.\");\n        m_textComponent->SetText(m_initialText);\n\n        m_releasedInsideConnection = GetWidget()->GetReleasedInsideEvent().OpenConnection(MakeDelegate(this, &EditableTextUIComponent::OnReleasedInside));\n        m_releasedOutsideConnection = GetWidget()->GetReleasedOutsideEvent().OpenConnection(MakeDelegate(this, &EditableTextUIComponent::OnReleasedOutside));\n    }\n\n    //-------------------------------------------------------------\n    void EditableTextUIComponent::OnDestroy() noexcept\n    {\n        if (m_active)\n        {\n            Deactivate();\n        }\n\n        // Clear text from buffer.\n        m_textEntrySystem->SetTextBuffer(\"\");\n\n        m_releasedInsideConnection.reset();\n        m_releasedOutsideConnection.reset();\n    }\n}"
  },
  {
    "path": "Source/ChilliSource/UI/Text/EditableTextUIComponent.h",
    "content": "//  The MIT License (MIT)\n//\n//  Copyright (c) 2016 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n\n#ifndef _CHILLISOURCE_UI_TEXT_EDITABLETEXTUICOMPONENT_H_\n#define _CHILLISOURCE_UI_TEXT_EDITABLETEXTUICOMPONENT_H_\n\n#include <ChilliSource/Core/Container/Property/PropertyMap.h>\n#include <ChilliSource/Core/Event/EventConnection.h>\n#include <ChilliSource/Input/Pointer/Pointer.h>\n#include <ChilliSource/Input/TextEntry/TextEntry.h>\n#include <ChilliSource/UI/Base/UIComponent.h>\n#include <ChilliSource/UI/Text/TextUIComponent.h>\n\nnamespace ChilliSource\n{\n    /// A component which can be added to a widget to provide an editable text\n    /// field. Editable text contains the following properties:\n    ///\n    /// \"InitialText\": The text present in the text field upon creation.\n    /// Defaults to nothing.\n    ///\n    /// \"MaxCharacters\": The maximum number of characters allowed in this text field.\n    /// Defaults to 50.\n    ///\n    /// \"MultilineDisabled\": Setting this to True will disable the display of newlines\n    /// within the text field. This is False by default.\n    /// \n    /// \"InputType\": Keyboard type; currently supported values are \"Text\" and \"Numeric\".\n    /// Defaults to \"Text\".\n    ///\n    /// \"CapitalisationFormat\": Capitalisation format for the virtual keyboard.\n    /// Currently supported values are: \"None\", \"Words\", \"Sentences\" and \"All\".\n    /// Defaults to \"Sentences\".\n    ///\n    class EditableTextUIComponent final : public UIComponent\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(EditableTextUIComponent);\n\n        /// @return The list of properties supported by an editable text component.\n        ///\n        static const std::vector<PropertyMap::PropertyDesc>& GetPropertyDescs() noexcept;\n\n        /// Allows querying of whether or not the component implements the\n        /// interface associated with the given interface Id. Typically\n        /// this won't be called directly, instead the templated version\n        /// IsA<Interface>() should be used.\n        ///\n        /// @param \n        ///     The interface Id.\n        ///\n        /// @return Whether the object implements the given interface.\n        ///\n        bool IsA(InterfaceIDType interfaceId) const noexcept override;\n\n        /// @return The initial text present in the field upon creation.\n        ///\n        const std::string& GetInitialText() const noexcept;\n\n        /// @return The maximum number of characters allowed in the field.\n        ///\n        s32 GetMaxCharacters() const noexcept;\n\n        /// @return Whether or not multi-line text is enabled.\n        ///\n        bool GetMultilineDisabled() const noexcept;\n\n        /// @return The keyboard input type.\n        ///\n        const ChilliSource::TextEntryType&  GetInputType() const noexcept;\n\n        /// @return The capitalisation format.\n        ///\n        const ChilliSource::TextEntryCapitalisation& GetCapitalisationFormat() const noexcept;\n\n        /// Set initial text present in the field.\n        /// \n        /// @param text\n        ///     The desired text.\n        ///\n        void SetInitialText(const std::string& text) noexcept;\n\n        /// Set maximum number of characters allowed in the field.\n        ///\n        /// @param numCharacters\n        ///     The maximum number of characters required.\n        ///\n        void SetMaxCharacters(s32 numCharacters) noexcept;\n\n        /// Set whether multi-line text is disabled or not.\n        ///\n        /// @param disable\n        ///     Whether or not to disable multiline text.\n        ///\n        void SetMultilineDisabled(bool disable) noexcept;\n\n        /// Set keyboard input type.\n        ///\n        /// @param type\n        ///     The desired keyboard input type.\n        ///\n        void SetInputType(ChilliSource::TextEntryType type) noexcept;\n\n        /// Set capitalisation format. \n        ///\n        /// @param format\n        ///     The desired capitalisation format.\n        ///\n        void SetCapitalisationFormat(ChilliSource::TextEntryCapitalisation format) noexcept;\n\n        /// Enables text entry and invokes virtual keyboard on mobile devices.\n        ///\n        void Activate() noexcept;\n\n        /// Disables text entry and dismisses virtual keyboard on mobile devices.\n        ///\n        void Deactivate() noexcept;\n\n    private:\n        friend class UIComponentFactory;\n\n        /// Constructor that builds the component from key-value properties.\n        /// The properties used to create a highlight component are described\n        /// in the class documentation.\n        /// @param componentName\n        ///     The component name.\n        /// @param properties\n        ///     The property map.\n        ///\n        EditableTextUIComponent(const std::string& componentName, const PropertyMap& properties) noexcept;\n\n        /// Called when text entry is active and the text has been changed.\n        ///\n        /// @return If the new text is valid or not.\n        ///\n        bool OnTextChanged(const std::string& newText) noexcept;\n        \n        /// Called when the virtual keyboard is dismissed.\n        ///\n        void OnTextEntryDismissed() noexcept;\n\n        /// Called when the component is first added to the owning widget.\n        ///\n        void OnInit() noexcept override;\n\n        /// Called when a pointer is released inside the bounds of the owning\n        /// widget. This will toggle the text entry & virtual keyboard.\n        ///\n        /// @param widget\n        ///     The owning widget.\n        /// @param pointer\n        ///     The pointer that was pressed.\n        /// @param inputType\n        ///     The type of input.\n        ///\n        void OnReleasedInside(Widget* widget, const Pointer& pointer, Pointer::InputType inputType) noexcept;\n\n        /// Called when a pointer is released outside the bounds of the owning\n        /// widget. This will disable the text entry & virtual keyboard.\n        ///\n        /// @param widget\n        ///     The owning widget.\n        /// @param pointer\n        ///     The pointer that was pressed.\n        /// @param inputType\n        ///     The type of input.\n        ///\n        void OnReleasedOutside(Widget* widget, const Pointer& pointer, Pointer::InputType inputType) noexcept;\n\n        /// Called when the owning widget is destructed.\n        ///\n        void OnDestroy() noexcept override;\n\n        TextUIComponent* m_textComponent = nullptr;\n        TextEntry* m_textEntrySystem = nullptr;\n\n        bool m_active = false;\n        bool m_multilineDisabled = false;\n        s32 m_maxCharacters = 50;\n        std::string m_initialText = \"\";\n        ChilliSource::TextEntryType m_inputType = ChilliSource::TextEntryType::k_text;\n        ChilliSource::TextEntryCapitalisation m_capitalisationFormat = ChilliSource::TextEntryCapitalisation::k_sentences;\n\n        EventConnectionUPtr m_releasedInsideConnection;\n        EventConnectionUPtr m_releasedOutsideConnection;\n    };\n}\n\n#endif"
  },
  {
    "path": "Source/ChilliSource/UI/Text/TextComponent.h",
    "content": "//\n//  TextUIComponent.h\n//  ChilliSource\n//  Created by Ian Copland on 05/11/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_UI_TEXT_TEXTCOMPONENT_H_\n#define _CHILLISOURCE_UI_TEXT_TEXTCOMPONENT_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Base/Colour.h>\n#include <ChilliSource/Core/Container/Property/PropertyMap.h>\n#include <ChilliSource/Core/String/StringMarkupParser.h>\n#include <ChilliSource/Rendering/Base/CanvasRenderer.h>\n#include <ChilliSource/Rendering/Base/HorizontalTextJustification.h>\n#include <ChilliSource/Rendering/Base/VerticalTextJustification.h>\n#include <ChilliSource/Rendering/Font/Font.h>\n#include <ChilliSource/Rendering/Texture/UVs.h>\n#include <ChilliSource/UI/Base/UIComponent.h>\n#include <ChilliSource/UI/Text/TextIcon.h>\n\n#include <vector>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    /// A component which can be added to a widget to provide text rendering\n    /// functionality. Text drawable contains the following properties:\n    ///\n    /// \"Font\": The description of the font resource that will be used to render\n    /// the text. This default to the default font built into ChilliSource.\n    ///\n    /// \"LocalisedText\": The description of the localised text resource which\n    /// will be used to generate the text.\n    ///\n    /// \"LocalisedTextId\": The Id of the string in the given localised text\n    /// file.\n    ///\n    /// \"Text\": The UTF-8 format string that should be displayed. Using this is\n    /// not recommended, it is usually better to create text using a localised\n    /// text resource.\n    ///\n    /// \"TextColour\": The colour of the text. Defaults to white.\n    ///\n    /// \"HorizontalJustification\": The justification of the text horizontally.\n    /// This can be set to \"Left\", \"Centre\" or \"Right\". Defaults to \"Centre\".\n    ///\n    /// \"VerticalJustification\": The justification of the text vertically. This\n    /// can be set to \"Bottom\", \"Centre\" or \"Top\". Defaults to \"Centre\".\n    ///\n    /// \"AbsCharSpacingOffset\": An offset from the standard character spacing in\n    /// pixels. This allows characters to be moved appart or closer together.\n    /// Defaults to 0.\n    ///\n    /// \"AbsLineSpacingOffset\": An offset from the standard line spacing. This\n    /// allows lines of text to be moved closer together or further apart.\n    /// Defaults to 0.\n    ///\n    /// \"LineSpacingScale\": A scale factor to alter the line spacing. This\n    /// allows lines of text to be moved closer together or further apart.\n    /// Defaults to 1.0\n    ///\n    /// \"MaxNumberOfLines\": The maximum number of lines the text will be displayed\n    /// across. If 0, there is no limit. Defaults to 0.\n    ///\n    /// \"TextScale\": The scale factor that should be used to render the text.\n    /// Scaling text significantly reduces the text quality so this should only\n    /// be used when absolutely necessary. Defaults to 1.0.\n    ///\n    /// @author Ian Copland\n    //------------------------------------------------------------------------------\n    class TextUIComponent final : public UIComponent\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(TextUIComponent);\n        //------------------------------------------------------------------------------\n        /// Dictionary used to replace [img=Variable] flags with images\n        ///\n        /// @author Nicolas Tanda\n        //------------------------------------------------------------------------------\n        using TextIconDictionary = std::unordered_map<std::string, TextIcon>;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The list of properties supported by text.\n        //------------------------------------------------------------------------------\n        static const std::vector<PropertyMap::PropertyDesc>& GetPropertyDescs();\n        //------------------------------------------------------------------------------\n        /// Allows querying of whether or not the component implements the interface\n        /// associated with the given interface Id. Typically this won't be called\n        /// directly, instead the templated version IsA<Interface>() should be used.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The interface Id.\n        ///\n        /// @return Whether the object implements the given interface.\n        //------------------------------------------------------------------------------\n        bool IsA(InterfaceIDType in_interfaceId) const override;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The font that will be used to render the text.\n        //------------------------------------------------------------------------------\n        const FontCSPtr& GetFont() const;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The localised text resource that will be used to render text.\n        //------------------------------------------------------------------------------\n        const LocalisedTextCSPtr& GetLocalisedText() const;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The localised text Id that will be used to render text.\n        //------------------------------------------------------------------------------\n        const std::string& GetLocalisedTextId() const;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The UTF-8 format string that will be rendered. This is typically\n        /// not used, use of localised text is prefered.\n        //------------------------------------------------------------------------------\n        const std::string& GetText() const;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The colour of the text.\n        //------------------------------------------------------------------------------\n        const Colour& GetTextColour() const;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The horizontal justification of the text within the owning widget's\n        /// bounds.\n        //------------------------------------------------------------------------------\n        HorizontalTextJustification GetHorizontalJustification() const;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The vertical justification of the text within the owning widget's\n        /// bounds.\n        //------------------------------------------------------------------------------\n        VerticalTextJustification GetVerticalJustification() const;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The absolute pixel offset to the standard character spacing. This is\n        /// used to increase of reduce the space between characters in the rendered text.\n        //------------------------------------------------------------------------------\n        f32 GetAbsoluteCharacterSpacingOffset() const;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The absolute pixel offset to the standard line spacing spacing. This\n        /// is used to increase of reduce the space between lines in the rendered text.\n        //------------------------------------------------------------------------------\n        f32 GetAbsoluteLineSpacingOffset() const;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return A scale factor which is applied to the line spacing. This is used to\n        /// increase of reduce the space between lines in the rendered text.\n        //------------------------------------------------------------------------------\n        f32 GetLineSpacingScale() const;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The maximum number of lines of text that will be rendered. A value\n        /// of 0 means there is no limit to the number of lines.\n        //------------------------------------------------------------------------------\n        s32 GetMaxNumberOfLines() const;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The text scale. Scaling text significantly reduces the quality of\n        /// the text rendered so this should only be used when absolutely necessary.\n        //------------------------------------------------------------------------------\n        f32 GetTextScale() const;\n        //------------------------------------------------------------------------------\n        /// @author HMcLaughlin\n        ///\n        /// @return The minimum text scale that will be used when auto scaling text.\n        /// Scaling text significantly reduces the quality of the text rendered so this\n        /// should only be used when absolutely necessary.\n        //------------------------------------------------------------------------------\n        f32 GetMinAutoTextScale() const;\n        //------------------------------------------------------------------------------\n        /// @author HMcLaughlin\n        ///\n        /// @return If auto text scaling is enabled\n        //------------------------------------------------------------------------------\n        bool IsTextAutoScaleEnabled() const;\n        //------------------------------------------------------------------------------\n        /// Sets the font that will be used to render the text.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The font.\n        //------------------------------------------------------------------------------\n        void SetFont(const FontCSPtr& in_font);\n        //------------------------------------------------------------------------------\n        /// Sets the localised text that should be used to render text. A valid\n        /// localised text id should also be set.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The localised text resource.\n        //------------------------------------------------------------------------------\n        void SetLocalisedText(const LocalisedTextCSPtr& in_localisedText);\n        //------------------------------------------------------------------------------\n        /// The Id of the entry in the localised text resource that should be used to\n        /// render text.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The localised text Id.\n        //------------------------------------------------------------------------------\n        void SetLocalisedTextId(const std::string& in_localisedTextId);\n        //------------------------------------------------------------------------------\n        /// Sets the rendered text from a localised text resource. Text can contain\n        /// basic markup for inserting variables into the string. The markup is in the\n        /// form [var=VariableName], and the value for the variable is looked up in the\n        /// given param dictionary.\n        ///\n        /// For example \"Time remaining: [var=TimeRemaining]\" with a param dictionary\n        /// containing \"TimeRemaining\"=\"12\" will become \"Time Remaining: 12\".\n        ///\n        /// The markup is also recursive, meaning that the following is valid:\n        /// \"[var=EntryNumber_[var=Number]]\".\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The localised text id which is used to lookup the string in the\n        /// localised text resource.\n        /// @param The param dictionary which contains the values which should be used\n        /// for each variable in the string.\n        /// @param The image data dictionary which contains the values which should be\n        /// used for each image in the string.\n        //------------------------------------------------------------------------------\n        void SetLocalisedTextId(const std::string& in_localisedTextId, const ParamDictionary& in_params, const TextIconDictionary& in_imageData = TextIconDictionary());\n        //------------------------------------------------------------------------------\n        /// Directly sets the text that will be rendered. This is not recommended,\n        /// usually is it better to set the text using a localised text resource.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The text.\n        //------------------------------------------------------------------------------\n        void SetText(const std::string& in_text);\n        //------------------------------------------------------------------------------\n        /// Directly sets the text that will be rendered. This is not recommended,\n        /// usually is it better to set the text using a localised text resource.\n        ///\n        /// Will replace flags [img=Variable] with images.\n        ///\n        /// For example \"You have earned 100 [img=Currency]\" with a map containing\n        /// the data for \"Currency\" will display an icon for it.\n        ///\n        /// @author Nicolas Tanda\n        ///\n        /// @param The text.\n        /// @param The image data dictionary which contains the values which should be\n        /// used for each image in the string.\n        //------------------------------------------------------------------------------\n        void SetText(const std::string& in_text, const TextIconDictionary& in_imageData);\n        //------------------------------------------------------------------------------\n        /// Sets the colour of the rendered text.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The colour.\n        //------------------------------------------------------------------------------\n        void SetTextColour(const Colour& in_textColour);\n        //------------------------------------------------------------------------------\n        /// Sets the horizontal justification of the text within the owning widget's\n        /// bounds.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The justfication.\n        //------------------------------------------------------------------------------\n        void SetHorizontalJustification(HorizontalTextJustification in_horizontalJustification);\n        //------------------------------------------------------------------------------\n        /// Sets the vertical justification of the text within the owning widget's\n        /// bounds.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The justification.\n        //------------------------------------------------------------------------------\n        void SetVerticalJustification(VerticalTextJustification in_verticalJustification);\n        //------------------------------------------------------------------------------\n        /// Sets the absolute pixel offset to the standard character spacing. This is\n        /// used to increase of reduce the space between characters in the rendered text.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The offset.\n        //------------------------------------------------------------------------------\n        void SetAbsoluteCharacterSpacingOffset(f32 in_offset);\n        //------------------------------------------------------------------------------\n        /// Sets the absolute pixel offset to the standard line spacing spacing. This is\n        /// used to increase of reduce the space between lines in the rendered text.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The offset.\n        //------------------------------------------------------------------------------\n        void SetAbsoluteLineSpacingOffset(f32 in_offset);\n        //------------------------------------------------------------------------------\n        /// Sets the scale factor which is applied to the line spacing. This is used to\n        /// increase of reduce the space between lines in the rendered text.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The scale factor.\n        //------------------------------------------------------------------------------\n        void SetLineSpacingScale(f32 in_scale);\n        //------------------------------------------------------------------------------\n        /// Sets the maximum number of lines of text that will be rendered. A value of 0\n        /// means there is no limit to the number of lines.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The number of lines, or 0 if no limit.\n        //------------------------------------------------------------------------------\n        void SetMaxNumberOfLines(s32 in_numLines);\n        //------------------------------------------------------------------------------\n        /// Sets the text scale. Scaling text significantly reduces the quality of the\n        /// text rendered so this should only be used when absolutely necessary.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The scale factor.\n        //------------------------------------------------------------------------------\n        void SetTextScale(f32 in_scale);\n        //------------------------------------------------------------------------------\n        /// Sets the minimum text scale that will be used in scale calculations if\n        /// EnableAutoTextScale is true. Scaling text significantly reduces the quality\n        /// of the text rendered so this should only be used when absolutely necessary.\n        ///\n        /// @author HMcLaughlin\n        ///\n        /// @param in_scale - The scale factor. (Must be <= TextScale)\n        //------------------------------------------------------------------------------\n        void SetMinAutoTextScale(f32 in_scale);\n        //------------------------------------------------------------------------------\n        /// Sets if this text component should attempt to auto scale the text to fit\n        /// into the labels bounds. This will achieve approximate best case fit scaling\n        /// for the current string and label size. This will only attempt to scale\n        /// downwards.\n        ///\n        /// @author HMcLaughlin\n        ///\n        /// @param in_enable - Enable auto scaling text\n        //------------------------------------------------------------------------------\n        void SetTextAutoScaleEnabled(bool in_enable);\n        \n    private:\n        friend class UIComponentFactory;\n        //------------------------------------------------------------------------------\n        /// A container for matching Text Icons to their position in the text string.\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------------------------------------\n        struct TextIconIndex final\n        {\n            TextIcon m_icon;\n            u32 m_indexInText = 0;\n        };\n        //------------------------------------------------------------------------------\n        /// A container for \"cached\" Text Icon data used to render the icon as part of\n        /// the label.\n        ///\n        /// Note that the offset combines both the texture atlas \"cropped\" offset\n        /// (if there is one) and the position of the image in the local space of the\n        /// label.\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------------------------------------\n        struct TextIconCachedData final\n        {\n            TextureCSPtr m_texture;\n            Vector2 m_size;\n            Vector2 m_offset;\n            UVs m_uvs;\n        };\n        //------------------------------------------------------------------------------\n        /// Inserts variables into the given string with the values using basic markup.\n        /// The markup is in the form [var=VariableName], and the value for the variable\n        /// is looked up in the cached param dictionary.\n        ///\n        /// For example \"Time remaining: [var=TimeRemaining]\" with a param dictionary\n        /// containing \"TimeRemaining\"=\"12\" will become \"Time Remaining: 12\".\n        ///\n        /// The markup is also recursive, meaning that the following is valid:\n        /// \"[var=TextValue[var=ValueIndex]]\".\n        ///\n        /// This will also replace any [img= variable] flags with markers and spacing\n        /// for the TextUIComponent to draw icons using the cached images data map.\n        ///\n        /// @author Nicolas Tanda\n        ///\n        /// @param in_text - The text containing mark-ups\n        /// @param in_params - The param dictionary which contains the values which\n        /// should be used for each variable in the string.\n        /// @param in_imageData - The image data dictionary which contains the values\n        /// which should be used for each image in the string.\n        //------------------------------------------------------------------------------\n        void ReplaceVariables(const std::string& in_text, const ParamDictionary& in_params, const TextIconDictionary& in_imageData);\n        //------------------------------------------------------------------------------\n        /// Adds the icon described by the [img] tag to the Text Icon Indices list. Also\n        /// makes space in the rendered text string for the icon.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param in_font - The font which will be used to render the text.\n        /// @param in_iconDictionary - The icon dictionary.\n        /// @param in_iconName - The name of the icon image in the dictionary.\n        /// @param in_spaceInfo - Character info on a single space.\n        /// @param in_markerInfo - Character info on the marker character.\n        /// @param out_index - [Out] The current index of the text\n        /// @param out_iconIndices - [Out] The output list of icons.\n        ///\n        /// @return The text replacement for the icon.\n        //------------------------------------------------------------------------------\n        static std::string AddIcon(const FontCSPtr& in_font, const TextIconDictionary& in_iconDictionary, const std::string& in_iconName, const Font::CharacterInfo& in_spaceInfo,\n                                   const Font::CharacterInfo& in_markerInfo, u32& out_index, std::vector<TextIconIndex>& out_iconIndices);\n        //------------------------------------------------------------------------------\n        /// Builds the cachable Icon data from the list of icon indicies.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param in_font - The font which will be used to render the text.\n        /// @param in_builtText - The built text.\n        /// @param in_iconIndices - The icon indices.\n        /// @param in_textScale - The actual scale factor used to render the text, i.e\n        /// After auto-sizing has been taken into account.\n        ///\n        /// @return The vector of cachable icon data.\n        //------------------------------------------------------------------------------\n        static std::vector<TextIconCachedData> BuildIcons(const FontCSPtr& in_font, const CanvasRenderer::BuiltText& in_builtText, const std::vector<TextIconIndex>& in_iconIndices, f32 in_textScale);\n        //------------------------------------------------------------------------------\n        /// Constructor that builds the text from key-value properties. The properties\n        /// used to create the text are described in the class documentation.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The component name.\n        /// @param The property map.\n        //------------------------------------------------------------------------------\n        TextUIComponent(const std::string& in_componentName, const PropertyMap& in_properties);\n        //------------------------------------------------------------------------------\n        /// Render the text using the transform and size of the owning widget.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The canvas renderer.\n        /// @param The final screen space transform.\n        /// @param The final screen space size.\n        /// @param The final colour.\n        //-------------------------------------------------------------------------------\n        void OnDraw(CanvasRenderer* in_renderer, const Matrix3& in_transform, const Vector2& in_absSize, const Colour& in_absColour) override;\n        \n        FontCSPtr m_font;\n        LocalisedTextCSPtr m_localisedText;\n        std::string m_localisedTextId;\n        std::string m_text;\n        CanvasRenderer::TextProperties m_textProperties;\n        Colour m_textColour;\n        std::vector<TextIconIndex> m_iconIndices;\n        \n        bool m_invalidateCache = true;\n        Vector2 m_cachedSize;\n        CanvasRenderer::BuiltText m_cachedText;\n        std::vector<TextIconCachedData> m_cachedIcons;\n        \n        StringMarkupParser m_markupParser;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/UI/Text/TextIcon.cpp",
    "content": "//\n//  TextIcon.cpp\n//  ChilliSource\n//  Created by Nicolas Tanda on 23/02/2015.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2015 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/UI/Text/TextIcon.h>\n\n#include <ChilliSource/Core/Localisation/LocalisedText.h>\n#include <ChilliSource/Core/Resource/ResourcePool.h>\n#include <ChilliSource/Rendering/Texture/Texture.h>\n#include <ChilliSource/Rendering/Texture/TextureAtlas.h>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    TextIcon::TextIcon(const TextureCSPtr& in_texture, f32 in_scale)\n    :m_texture(in_texture), m_scale(in_scale)\n    {\n        CS_ASSERT(in_texture != nullptr, \"Need to provide a texture for a Text Icon\");\n        \n        m_originalSize.x = m_croppedSize.x = f32(m_texture->GetDimensions().x);\n        m_originalSize.y = m_croppedSize.y = f32(m_texture->GetDimensions().y);\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    TextIcon::TextIcon(const TextureCSPtr& in_texture, const TextureAtlasCSPtr& in_atlas, const std::string& in_atlasID, f32 in_scale)\n    :TextIcon(in_texture, in_scale)\n    {\n        CS_ASSERT(in_atlas != nullptr, \"Need to provide a texture atlas for a Text Icon\");\n        CS_ASSERT(in_texture != nullptr, \"Need to provide a texture for a Text Icon\");\n        \n        m_atlas = in_atlas;\n        m_atlasID = in_atlasID;\n        \n        m_originalSize = m_atlas->GetOriginalFrameSize(m_atlasID);\n        m_croppedSize = m_atlas->GetCroppedFrameSize(m_atlasID);\n        m_offset = m_atlas->GetFrameOffset(m_atlasID);\n        m_uvs = m_atlas->GetFrameUVs(m_atlasID);\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    const TextureCSPtr& TextIcon::GetTexture() const\n    {\n        return m_texture;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    const TextureAtlasCSPtr& TextIcon::GetTextureAtlas() const\n    {\n        return m_atlas;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    const std::string& TextIcon::GetTextureAtlasID() const\n    {\n        return m_atlasID;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    f32 TextIcon::GetScale() const\n    {\n        return m_scale;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    const Vector2& TextIcon::GetOriginalSize() const\n    {\n        return m_originalSize;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    const Vector2& TextIcon::GetCroppedSize() const\n    {\n        return m_croppedSize;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    const Vector2& TextIcon::GetOffset() const\n    {\n        return m_offset;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    const UVs& TextIcon::GetUVs() const\n    {\n        return m_uvs;\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/UI/Text/TextIcon.h",
    "content": "//\n//  TextIcon.h\n//  ChilliSource\n//  Created by Nicolas Tanda on 23/02/2015.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2015 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_UI_TEXT_TEXTICON_H_\n#define _CHILLISOURCE_UI_TEXT_TEXTICON_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Math/Vector2.h>\n#include <ChilliSource/Rendering/Texture/UVs.h>\n\n#include <unordered_map>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    /// A text specific image data\n    ///\n    /// @author Nicolas Tanda\n    //------------------------------------------------------------------------------\n    class TextIcon final\n    {\n    public:\n        //------------------------------------------------------------------------------\n        /// Default constructor\n        ///\n        /// @author Nicolas Tanda\n        //------------------------------------------------------------------------------\n        TextIcon() = default;\n        //------------------------------------------------------------------------------\n        /// @author Nicolas Tanda\n        ///\n        /// @param in_texture - Texture\n        /// @param in_scale - [Optional] Scale of the image, relative to the text height\n        //------------------------------------------------------------------------------\n        TextIcon(const TextureCSPtr& in_texture, f32 in_scale = 1.0f);\n        //------------------------------------------------------------------------------\n        /// @author Nicolas Tanda\n        ///\n        /// @param in_texture - Texture\n        /// @param in_atlas - Texture atlas\n        /// @param in_atlasID - Texture atlas ID\n        /// @param in_scale - [Optional] Scale of the image, relative to the text height\n        //------------------------------------------------------------------------------\n        TextIcon(const TextureCSPtr& in_texture, const TextureAtlasCSPtr& in_atlas, const std::string& in_atlasID, f32 in_scale = 1.0f);\n        \n        //------------------------------------------------------------------------------\n        /// @author Nicolas Tanda\n        ///\n        /// @return The texture of the image\n        //------------------------------------------------------------------------------\n        const TextureCSPtr& GetTexture() const;\n        //------------------------------------------------------------------------------\n        /// @author Nicolas Tanda\n        ///\n        /// @return The texture atlas of the image\n        //------------------------------------------------------------------------------\n        const TextureAtlasCSPtr& GetTextureAtlas() const;\n        //------------------------------------------------------------------------------\n        /// @author Nicolas Tanda\n        ///\n        /// @return The texture atlas ID of the image\n        //------------------------------------------------------------------------------\n        const std::string& GetTextureAtlasID() const;\n        //------------------------------------------------------------------------------\n        /// @author Nicolas Tanda\n        ///\n        /// @return The scale of the image\n        //------------------------------------------------------------------------------\n        f32 GetScale() const;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The full size of the image prior to cropping.\n        //------------------------------------------------------------------------------\n        const Vector2& GetOriginalSize() const;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The size of the image after cropping. Icons which are not part of a\n        /// texture atlas will return the same as GetOriginalSize().\n        //------------------------------------------------------------------------------\n        const Vector2& GetCroppedSize() const;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The \"cropping\" offset of the image. Icons which are not part of a\n        /// texture atlas this will always return [0.0, 0.0].\n        //------------------------------------------------------------------------------\n        const Vector2& GetOffset() const;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The UVs of the image. Icons which are not part of a texture atlas\n        /// will always return [0.0, 0.0, 1.0, 1.0].\n        //------------------------------------------------------------------------------\n        const UVs& GetUVs() const;\n        \n    private:\n        TextureCSPtr m_texture;\n        TextureAtlasCSPtr m_atlas;\n        std::string m_atlasID;\n        \n        f32 m_scale = 1.0f;\n        \n        Vector2 m_originalSize;\n        Vector2 m_croppedSize;\n        Vector2 m_offset;\n        UVs m_uvs;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/UI/Text/TextUIComponent.cpp",
    "content": "//\n//  TextUIComponent.cpp\n//  ChilliSource\n//  Created by Ian Copland on 05/11/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/UI/Text/TextUIComponent.h>\n\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/Container/Property/PropertyTypes.h>\n#include <ChilliSource/Core/Delegate/MakeDelegate.h>\n#include <ChilliSource/Core/Localisation/LocalisedText.h>\n#include <ChilliSource/Core/Resource/ResourcePool.h>\n#include <ChilliSource/Core/String/StringParser.h>\n#include <ChilliSource/Rendering/Base/CanvasDrawMode.h>\n#include <ChilliSource/Rendering/Font/Font.h>\n#include <ChilliSource/Rendering/Texture/Texture.h>\n#include <ChilliSource/Rendering/Texture/TextureAtlas.h>\n#include <ChilliSource/UI/Base/PropertyTypes.h>\n#include <ChilliSource/UI/Base/Widget.h>\n\nnamespace ChilliSource\n{\n    namespace\n    {\n        const char k_imageReplacementKey = ':';\n        \n        const char k_fontKey[] = \"Font\";\n        const char k_localisedTextKey[] = \"LocalisedText\";\n        const char k_localisedTextIdKey[] = \"LocalisedTextId\";\n        const char k_textKey[] = \"Text\";\n        const char k_textColourKey[] = \"TextColour\";\n        const char k_horizontalJustificationKey[] = \"HorizontalJustification\";\n        const char k_verticalJustificationKey[] = \"VerticalJustification\";\n        const char k_absCharSpacingOffsetKey[] = \"AbsCharSpacingOffset\";\n        const char k_absLineSpacingOffsetKey[] = \"AbsLineSpacingOffset\";\n        const char k_lineSpacingScaleKey[] = \"LineSpacingScale\";\n        const char k_maxNumberOfLinesKey[] = \"MaxNumberOfLines\";\n        const char k_textScaleKey[] = \"TextScale\";\n        const char k_minTextScaleKey[] = \"MinTextAutoScale\";\n        const char k_enableAutoScaledTextKey[] = \"EnableAutoTextScale\";\n        \n        const char k_keywordImage[] = \"img\";\n        const char k_keywordVariable[] = \"var\";\n        \n        \n        const std::vector<PropertyMap::PropertyDesc> k_propertyDescs =\n        {\n            {PropertyTypes::Font(), k_fontKey},\n            {PropertyTypes::LocalisedText(), k_localisedTextKey},\n            {PropertyTypes::String(), k_localisedTextIdKey},\n            {PropertyTypes::String(), k_textKey},\n            {PropertyTypes::Colour(), k_textColourKey},\n            {PropertyTypes::HorizontalTextJustification(), k_horizontalJustificationKey},\n            {PropertyTypes::VerticalTextJustification(), k_verticalJustificationKey},\n            {PropertyTypes::Float(), k_absCharSpacingOffsetKey},\n            {PropertyTypes::Float(), k_absLineSpacingOffsetKey},\n            {PropertyTypes::Float(), k_lineSpacingScaleKey},\n            {PropertyTypes::Int(), k_maxNumberOfLinesKey},\n            {PropertyTypes::Float(), k_textScaleKey},\n            {PropertyTypes::Float(), k_minTextScaleKey},\n            {PropertyTypes::Bool(), k_enableAutoScaledTextKey}\n        };\n    }\n    \n    CS_DEFINE_NAMEDTYPE(TextUIComponent);\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    const std::vector<PropertyMap::PropertyDesc>& TextUIComponent::GetPropertyDescs()\n    {\n        return k_propertyDescs;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    TextUIComponent::TextUIComponent(const std::string& in_componentName, const PropertyMap& in_properties)\n        : UIComponent(in_componentName)\n    {\n        auto resourcePool = Application::Get()->GetResourcePool();\n        SetFont(resourcePool->LoadResource<Font>(StorageLocation::k_chilliSource, \"Fonts/CarlitoMed.csfont\"));\n        \n        RegisterProperty<FontCSPtr>(PropertyTypes::Font(), k_fontKey, MakeDelegate(this, &TextUIComponent::GetFont), MakeDelegate(this, &TextUIComponent::SetFont));\n        RegisterProperty<LocalisedTextCSPtr>(PropertyTypes::LocalisedText(), k_localisedTextKey, MakeDelegate(this, &TextUIComponent::GetLocalisedText), MakeDelegate(this, &TextUIComponent::SetLocalisedText));\n        RegisterProperty<std::string>(PropertyTypes::String(), k_localisedTextIdKey, MakeDelegate(this, &TextUIComponent::GetLocalisedTextId), MakeDelegate<TextUIComponent, TextUIComponent, void, const std::string&>(this, &TextUIComponent::SetLocalisedTextId));\n        RegisterProperty<std::string>(PropertyTypes::String(), k_textKey, MakeDelegate(this, &TextUIComponent::GetText), MakeDelegate<TextUIComponent, TextUIComponent, void, const std::string&>(this, &TextUIComponent::SetText));\n        RegisterProperty<Colour>(PropertyTypes::Colour(), k_textColourKey, MakeDelegate(this, &TextUIComponent::GetTextColour), MakeDelegate(this, &TextUIComponent::SetTextColour));\n        RegisterProperty<HorizontalTextJustification>(PropertyTypes::HorizontalTextJustification(), k_horizontalJustificationKey, MakeDelegate(this, &TextUIComponent::GetHorizontalJustification), MakeDelegate(this, &TextUIComponent::SetHorizontalJustification));\n        RegisterProperty<VerticalTextJustification>(PropertyTypes::VerticalTextJustification(), k_verticalJustificationKey, MakeDelegate(this, &TextUIComponent::GetVerticalJustification), MakeDelegate(this, &TextUIComponent::SetVerticalJustification));\n        RegisterProperty<f32>(PropertyTypes::Float(), k_absCharSpacingOffsetKey, MakeDelegate(this, &TextUIComponent::GetAbsoluteCharacterSpacingOffset), MakeDelegate(this, &TextUIComponent::SetAbsoluteCharacterSpacingOffset));\n        RegisterProperty<f32>(PropertyTypes::Float(), k_absLineSpacingOffsetKey, MakeDelegate(this, &TextUIComponent::GetAbsoluteLineSpacingOffset), MakeDelegate(this, &TextUIComponent::SetAbsoluteLineSpacingOffset));\n        RegisterProperty<f32>(PropertyTypes::Float(), k_lineSpacingScaleKey, MakeDelegate(this, &TextUIComponent::GetLineSpacingScale), MakeDelegate(this, &TextUIComponent::SetLineSpacingScale));\n        RegisterProperty<s32>(PropertyTypes::Int(), k_maxNumberOfLinesKey, MakeDelegate(this, &TextUIComponent::GetMaxNumberOfLines), MakeDelegate(this, &TextUIComponent::SetMaxNumberOfLines));\n        RegisterProperty<f32>(PropertyTypes::Float(), k_textScaleKey, MakeDelegate(this, &TextUIComponent::GetTextScale), MakeDelegate(this, &TextUIComponent::SetTextScale));\n        RegisterProperty<f32>(PropertyTypes::Float(), k_minTextScaleKey, MakeDelegate(this, &TextUIComponent::GetMinAutoTextScale), MakeDelegate(this, &TextUIComponent::SetMinAutoTextScale));\n        RegisterProperty<bool>(PropertyTypes::Bool(), k_enableAutoScaledTextKey, MakeDelegate(this, &TextUIComponent::IsTextAutoScaleEnabled), MakeDelegate(this, &TextUIComponent::SetTextAutoScaleEnabled));\n        \n        ApplyRegisteredProperties(in_properties);\n        \n        // Register a new parser\n        MarkupDef markupDef;\n        markupDef.AddKeyword(k_keywordImage, false);\n        markupDef.AddKeyword(k_keywordVariable, true);\n        m_markupParser = StringMarkupParser(markupDef);\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    bool TextUIComponent::IsA(InterfaceIDType in_interfaceId) const\n    {\n        return (UIComponent::InterfaceID == in_interfaceId || TextUIComponent::InterfaceID == in_interfaceId);\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    const FontCSPtr& TextUIComponent::GetFont() const\n    {\n        return m_font;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    const LocalisedTextCSPtr& TextUIComponent::GetLocalisedText() const\n    {\n        return m_localisedText;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    const std::string& TextUIComponent::GetLocalisedTextId() const\n    {\n        return m_localisedTextId;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    const std::string& TextUIComponent::GetText() const\n    {\n        return m_text;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    const Colour& TextUIComponent::GetTextColour() const\n    {\n        return m_textColour;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    HorizontalTextJustification TextUIComponent::GetHorizontalJustification() const\n    {\n        return m_textProperties.m_horizontalJustification;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    VerticalTextJustification TextUIComponent::GetVerticalJustification() const\n    {\n        return m_textProperties.m_verticalJustification;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    f32 TextUIComponent::GetAbsoluteCharacterSpacingOffset() const\n    {\n        return m_textProperties.m_absCharSpacingOffset;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    f32 TextUIComponent::GetAbsoluteLineSpacingOffset() const\n    {\n        return m_textProperties.m_absLineSpacingOffset;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    f32 TextUIComponent::GetLineSpacingScale() const\n    {\n        return m_textProperties.m_lineSpacingScale;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    s32 TextUIComponent::GetMaxNumberOfLines() const\n    {\n        return m_textProperties.m_maxNumLines;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    f32 TextUIComponent::GetTextScale() const\n    {\n        return m_textProperties.m_textScale;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    f32 TextUIComponent::GetMinAutoTextScale() const\n    {\n        return m_textProperties.m_minTextScale;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    bool TextUIComponent::IsTextAutoScaleEnabled() const\n    {\n        return m_textProperties.m_shouldAutoScale;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void TextUIComponent::SetFont(const FontCSPtr& in_font)\n    {\n        CS_ASSERT(in_font != nullptr, \"Cannot set a null font on a Text UIDrawable.\");\n        CS_ASSERT(in_font->GetLoadState() == Resource::LoadState::k_loaded, \"Cannot set an incomplete font on a Text UIDrawable.\");\n        \n        m_font = in_font;\n        \n        m_invalidateCache = true;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void TextUIComponent::SetLocalisedText(const LocalisedTextCSPtr& in_localisedText)\n    {\n#ifdef CS_ENABLE_DEBUG\n        if (in_localisedText != nullptr)\n        {\n            CS_ASSERT(in_localisedText->GetLoadState() == Resource::LoadState::k_loaded, \"Cannot set text using an incomplete localised text.\");\n        }\n#endif\n        \n        m_iconIndices.clear();\n        m_localisedText = in_localisedText;\n        \n        if (m_localisedText != nullptr && m_localisedText->Contains(m_localisedTextId) == true)\n        {\n            m_text = m_localisedText->GetText(m_localisedTextId);\n        }\n        else\n        {\n            m_text = \"\";\n        }\n        \n        m_invalidateCache = true;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void TextUIComponent::SetLocalisedTextId(const std::string& in_localisedTextId)\n    {\n        m_iconIndices.clear();\n        m_localisedTextId = in_localisedTextId;\n        \n        if (m_localisedText != nullptr && m_localisedText->Contains(m_localisedTextId) == true)\n        {\n            m_text = m_localisedText->GetText(m_localisedTextId);\n        }\n        else\n        {\n            m_text = \"\";\n        }\n        \n        m_invalidateCache = true;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void TextUIComponent::SetLocalisedTextId(const std::string& in_localisedTextId, const ParamDictionary& in_params, const TextIconDictionary& in_imageData)\n    {\n        CS_ASSERT(m_localisedText != nullptr, \"Cannot set text using a null localised text.\");\n        \n        ReplaceVariables(m_localisedText->GetText(in_localisedTextId), in_params, in_imageData);\n        \n        m_invalidateCache = true;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void TextUIComponent::SetText(const std::string& in_text)\n    {\n        m_iconIndices.clear();\n        m_text = in_text;\n        \n        m_invalidateCache = true;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void TextUIComponent::SetText(const std::string& in_text, const TextIconDictionary& in_imageData)\n    {\n        ReplaceVariables(in_text, {}, in_imageData);\n        \n        m_invalidateCache = true;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void TextUIComponent::SetTextColour(const Colour& in_textColour)\n    {\n        m_textColour = in_textColour;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void TextUIComponent::SetHorizontalJustification(HorizontalTextJustification in_horizontalJustification)\n    {\n        m_textProperties.m_horizontalJustification = in_horizontalJustification;\n        \n        m_invalidateCache = true;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void TextUIComponent::SetVerticalJustification(VerticalTextJustification in_verticalJustification)\n    {\n        m_textProperties.m_verticalJustification = in_verticalJustification;\n        \n        m_invalidateCache = true;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void TextUIComponent::SetAbsoluteCharacterSpacingOffset(f32 in_offset)\n    {\n        m_textProperties.m_absCharSpacingOffset = in_offset;\n        \n        m_invalidateCache = true;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void TextUIComponent::SetAbsoluteLineSpacingOffset(f32 in_offset)\n    {\n        m_textProperties.m_absLineSpacingOffset = in_offset;\n        \n        m_invalidateCache = true;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void TextUIComponent::SetLineSpacingScale(f32 in_scale)\n    {\n        m_textProperties.m_lineSpacingScale = in_scale;\n        \n        m_invalidateCache = true;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void TextUIComponent::SetMaxNumberOfLines(s32 in_numLines)\n    {\n        CS_ASSERT(in_numLines >= 0, \"The maximum number of lines cannot be below 0.\");\n        \n        m_textProperties.m_maxNumLines = in_numLines;\n        \n        m_invalidateCache = true;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void TextUIComponent::SetTextScale(f32 in_scale)\n    {\n        m_textProperties.m_textScale = in_scale;\n        \n        m_invalidateCache = true;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void TextUIComponent::SetMinAutoTextScale(f32 in_scale)\n    {\n        m_textProperties.m_minTextScale = in_scale;\n        \n        m_invalidateCache = true;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void TextUIComponent::SetTextAutoScaleEnabled(bool in_enable)\n    {\n        m_textProperties.m_shouldAutoScale = in_enable;\n        \n        m_invalidateCache = true;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void TextUIComponent::ReplaceVariables(const std::string& in_text, const ParamDictionary& in_params, const TextIconDictionary& in_iconDictionary)\n    {\n        m_text.clear();\n        m_text.shrink_to_fit();\n        \n        m_iconIndices.clear();\n        m_iconIndices.shrink_to_fit();\n        \n        // Marker for images\n        Font::CharacterInfo markerInfo;\n        m_font->TryGetCharacterInfo(k_imageReplacementKey, markerInfo);\n        \n        // Spacing info\n        Font::CharacterInfo spaceInfo;\n        m_font->TryGetCharacterInfo(' ', spaceInfo);\n        \n        // Parses the text to replace variables\n        m_text = m_markupParser.Parse(in_text, [=](const std::string& in_name, const std::string& in_keywordValue, u32 in_indexInString) -> std::string\n        {\n            std::string value;\n            if (in_name == k_keywordVariable)\n            {\n                in_params.TryGetValue(in_keywordValue, value);\n            }\n            else if (in_name == k_keywordImage)\n            {\n                value = AddIcon(m_font, in_iconDictionary, in_keywordValue, spaceInfo, markerInfo, in_indexInString, m_iconIndices);\n            }\n            \n            return value;\n        });\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    std::string TextUIComponent::AddIcon(const FontCSPtr& in_font, const TextIconDictionary& in_iconDictionary, const std::string& in_iconName, const Font::CharacterInfo& in_spaceInfo,\n                                       const Font::CharacterInfo& in_markerInfo, u32& out_index, std::vector<TextIconIndex>& out_iconIndices)\n    {\n        std::string iconText;\n        \n        auto iconIt = in_iconDictionary.find(in_iconName);\n        \n        CS_ASSERT(iconIt != in_iconDictionary.end(), \"Unknown icon name in TextUIComponent: \" + in_iconName);\n        \n        //Create the Text Icon Index entry.\n        TextIconIndex iconIndex;\n        iconIndex.m_icon = iconIt->second;\n        iconIndex.m_indexInText = out_index + static_cast<u32>(out_iconIndices.size());\n        out_iconIndices.push_back(iconIndex);\n        \n        //Make space for the Icon in the string. This doesn't include the text scale since that will be accounted for later.\n        f32 aspectRatio = iconIndex.m_icon.GetOriginalSize().x / iconIndex.m_icon.GetOriginalSize().y;\n        f32 width = aspectRatio * in_font->GetLineHeight() * iconIndex.m_icon.GetScale();\n        \n        u32 spacesNeeded = 0;\n        if(in_spaceInfo.m_advance > 0.0f)\n        {\n            spacesNeeded = u32(std::ceil((width - in_spaceInfo.m_size.x) / in_spaceInfo.m_advance));\n            if(spacesNeeded % 2 == 1)\n            {\n                ++spacesNeeded;\n            }\n        }\n        \n        iconText.append(&k_imageReplacementKey, 1);\n        for(u32 i = 0; i < spacesNeeded / 2; ++i)\n        {\n            iconText = \" \" + iconText + \" \";\n        }\n        \n        ++out_index;\n        \n        return iconText;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    std::vector<TextUIComponent::TextIconCachedData> TextUIComponent::BuildIcons(const FontCSPtr& in_font, const CanvasRenderer::BuiltText& in_builtText,\n                                                                             const std::vector<TextIconIndex>& in_iconIndices, f32 in_textScale)\n    {\n        std::vector<TextIconCachedData> output;\n        \n        for(const auto& iconIndex : in_iconIndices)\n        {\n            if (iconIndex.m_indexInText < in_builtText.m_characters.size())\n            {\n                const Vector2& charSize = in_builtText.m_characters[iconIndex.m_indexInText].m_packedImageSize;\n                f32 charPosX = in_builtText.m_characters[iconIndex.m_indexInText].m_position.x + charSize.x * 0.5f;\n                f32 charPosY = in_builtText.m_characters[iconIndex.m_indexInText].m_position.y - charSize.y * 0.5f;\n                \n                f32 croppedHeightRatio = iconIndex.m_icon.GetCroppedSize().y / iconIndex.m_icon.GetOriginalSize().y;\n                f32 height = in_font->GetLineHeight() * croppedHeightRatio * iconIndex.m_icon.GetScale() * in_textScale;\n                \n                f32 croppedIconAspectRatio = iconIndex.m_icon.GetCroppedSize().x / iconIndex.m_icon.GetCroppedSize().y;\n                f32 width = croppedIconAspectRatio * height;\n                \n                //calculate the offset from the centre of the original image quad to cropped\n                f32 croppedOffsetFromCentreX = iconIndex.m_icon.GetOffset().x + iconIndex.m_icon.GetCroppedSize().x * 0.5f - iconIndex.m_icon.GetOriginalSize().x * 0.5f;\n                f32 croppedOffsetFromCentreY = -(iconIndex.m_icon.GetOffset().y + iconIndex.m_icon.GetCroppedSize().y * 0.5f - iconIndex.m_icon.GetOriginalSize().y * 0.5f);\n                auto croppedOffset = Vector2(croppedOffsetFromCentreX, croppedOffsetFromCentreY) * iconIndex.m_icon.GetScale() * in_textScale;\n                \n                TextIconCachedData iconData;\n                iconData.m_texture = iconIndex.m_icon.GetTexture();\n                iconData.m_size = Vector2(width, height);\n                iconData.m_uvs = iconIndex.m_icon.GetUVs();\n                iconData.m_offset.x = croppedOffset.x + charPosX;\n                iconData.m_offset.y = croppedOffset.y + charPosY;\n                \n                output.push_back(iconData);\n            }\n        }\n        \n        return output;\n    }\n    //------------------------------------------------------------------------------\n    //------------------------------------------------------------------------------\n    void TextUIComponent::OnDraw(CanvasRenderer* in_renderer, const Matrix3& in_transform, const Vector2& in_absSize, const Colour& in_absColour)\n    {\n        if (m_cachedSize != in_absSize)\n        {\n            m_cachedSize = in_absSize;\n            m_invalidateCache = true;\n        }\n        \n        if (m_invalidateCache == true)\n        {\n            m_invalidateCache = false;\n            \n            f32 textScale = 1.0f;\n            m_cachedText = in_renderer->BuildText(m_text, m_font, in_absSize, m_textProperties, textScale);\n            m_cachedIcons = BuildIcons(m_font, m_cachedText, m_iconIndices, textScale);\n        }\n        \n        // Draw text\n        in_renderer->DrawText(m_cachedText.m_characters, in_transform, m_textColour * GetWidget()->GetFinalColour(), m_font->GetTexture());\n        \n        // Draw images\n        for(const auto& iconData : m_cachedIcons)\n        {\n            in_renderer->DrawBox(CanvasDrawMode::k_standard, in_transform, iconData.m_size, iconData.m_offset, iconData.m_texture, iconData.m_uvs, GetWidget()->GetFinalColour(), AlignmentAnchor::k_middleCentre);\n        }\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/UI/Text/TextUIComponent.h",
    "content": "//\n//  TextUIComponent.h\n//  ChilliSource\n//  Created by Ian Copland on 05/11/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_UI_TEXT_TEXTUICOMPONENT_H_\n#define _CHILLISOURCE_UI_TEXT_TEXTUICOMPONENT_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Base/Colour.h>\n#include <ChilliSource/Core/Container/Property/PropertyMap.h>\n#include <ChilliSource/Core/String/StringMarkupParser.h>\n#include <ChilliSource/Rendering/Base/CanvasRenderer.h>\n#include <ChilliSource/Rendering/Base/HorizontalTextJustification.h>\n#include <ChilliSource/Rendering/Base/VerticalTextJustification.h>\n#include <ChilliSource/Rendering/Font/Font.h>\n#include <ChilliSource/Rendering/Texture/UVs.h>\n#include <ChilliSource/UI/Base/UIComponent.h>\n#include <ChilliSource/UI/Text/TextIcon.h>\n\n#include <vector>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------------------------------\n    /// A component which can be added to a widget to provide text rendering\n    /// functionality. Text drawable contains the following properties:\n    ///\n    /// \"Font\": The description of the font resource that will be used to render\n    /// the text. This default to the default font built into ChilliSource.\n    ///\n    /// \"LocalisedText\": The description of the localised text resource which\n    /// will be used to generate the text.\n    ///\n    /// \"LocalisedTextId\": The Id of the string in the given localised text\n    /// file.\n    ///\n    /// \"Text\": The UTF-8 format string that should be displayed. Using this is\n    /// not recommended, it is usually better to create text using a localised\n    /// text resource.\n    ///\n    /// \"TextColour\": The colour of the text. Defaults to white.\n    ///\n    /// \"HorizontalJustification\": The justification of the text horizontally.\n    /// This can be set to \"Left\", \"Centre\" or \"Right\". Defaults to \"Centre\".\n    ///\n    /// \"VerticalJustification\": The justification of the text vertically. This\n    /// can be set to \"Bottom\", \"Centre\" or \"Top\". Defaults to \"Centre\".\n    ///\n    /// \"AbsCharSpacingOffset\": An offset from the standard character spacing in\n    /// pixels. This allows characters to be moved appart or closer together.\n    /// Defaults to 0.\n    ///\n    /// \"AbsLineSpacingOffset\": An offset from the standard line spacing. This\n    /// allows lines of text to be moved closer together or further apart.\n    /// Defaults to 0.\n    ///\n    /// \"LineSpacingScale\": A scale factor to alter the line spacing. This\n    /// allows lines of text to be moved closer together or further apart.\n    /// Defaults to 1.0\n    ///\n    /// \"MaxNumberOfLines\": The maximum number of lines the text will be displayed\n    /// across. If 0, there is no limit. Defaults to 0.\n    ///\n    /// \"TextScale\": The scale factor that should be used to render the text.\n    /// Scaling text significantly reduces the text quality so this should only\n    /// be used when absolutely necessary. Defaults to 1.0.\n    ///\n    /// @author Ian Copland\n    //------------------------------------------------------------------------------\n    class TextUIComponent final : public UIComponent\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(TextUIComponent);\n        //------------------------------------------------------------------------------\n        /// Dictionary used to replace [img=Variable] flags with images\n        ///\n        /// @author Nicolas Tanda\n        //------------------------------------------------------------------------------\n        using TextIconDictionary = std::unordered_map<std::string, TextIcon>;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The list of properties supported by text.\n        //------------------------------------------------------------------------------\n        static const std::vector<PropertyMap::PropertyDesc>& GetPropertyDescs();\n        //------------------------------------------------------------------------------\n        /// Allows querying of whether or not the component implements the interface\n        /// associated with the given interface Id. Typically this won't be called\n        /// directly, instead the templated version IsA<Interface>() should be used.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The interface Id.\n        ///\n        /// @return Whether the object implements the given interface.\n        //------------------------------------------------------------------------------\n        bool IsA(InterfaceIDType in_interfaceId) const override;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The font that will be used to render the text.\n        //------------------------------------------------------------------------------\n        const FontCSPtr& GetFont() const;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The localised text resource that will be used to render text.\n        //------------------------------------------------------------------------------\n        const LocalisedTextCSPtr& GetLocalisedText() const;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The localised text Id that will be used to render text.\n        //------------------------------------------------------------------------------\n        const std::string& GetLocalisedTextId() const;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The UTF-8 format string that will be rendered. This is typically\n        /// not used, use of localised text is prefered.\n        //------------------------------------------------------------------------------\n        const std::string& GetText() const;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The colour of the text.\n        //------------------------------------------------------------------------------\n        const Colour& GetTextColour() const;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The horizontal justification of the text within the owning widget's\n        /// bounds.\n        //------------------------------------------------------------------------------\n        HorizontalTextJustification GetHorizontalJustification() const;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The vertical justification of the text within the owning widget's\n        /// bounds.\n        //------------------------------------------------------------------------------\n        VerticalTextJustification GetVerticalJustification() const;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The absolute pixel offset to the standard character spacing. This is\n        /// used to increase of reduce the space between characters in the rendered text.\n        //------------------------------------------------------------------------------\n        f32 GetAbsoluteCharacterSpacingOffset() const;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The absolute pixel offset to the standard line spacing spacing. This\n        /// is used to increase of reduce the space between lines in the rendered text.\n        //------------------------------------------------------------------------------\n        f32 GetAbsoluteLineSpacingOffset() const;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return A scale factor which is applied to the line spacing. This is used to\n        /// increase of reduce the space between lines in the rendered text.\n        //------------------------------------------------------------------------------\n        f32 GetLineSpacingScale() const;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The maximum number of lines of text that will be rendered. A value\n        /// of 0 means there is no limit to the number of lines.\n        //------------------------------------------------------------------------------\n        s32 GetMaxNumberOfLines() const;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return The text scale. Scaling text significantly reduces the quality of\n        /// the text rendered so this should only be used when absolutely necessary.\n        //------------------------------------------------------------------------------\n        f32 GetTextScale() const;\n        //------------------------------------------------------------------------------\n        /// @author HMcLaughlin\n        ///\n        /// @return The minimum text scale that will be used when auto scaling text.\n        /// Scaling text significantly reduces the quality of the text rendered so this\n        /// should only be used when absolutely necessary.\n        //------------------------------------------------------------------------------\n        f32 GetMinAutoTextScale() const;\n        //------------------------------------------------------------------------------\n        /// @author HMcLaughlin\n        ///\n        /// @return If auto text scaling is enabled\n        //------------------------------------------------------------------------------\n        bool IsTextAutoScaleEnabled() const;\n        //------------------------------------------------------------------------------\n        /// Sets the font that will be used to render the text.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The font.\n        //------------------------------------------------------------------------------\n        void SetFont(const FontCSPtr& in_font);\n        //------------------------------------------------------------------------------\n        /// Sets the localised text that should be used to render text. A valid\n        /// localised text id should also be set.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The localised text resource.\n        //------------------------------------------------------------------------------\n        void SetLocalisedText(const LocalisedTextCSPtr& in_localisedText);\n        //------------------------------------------------------------------------------\n        /// The Id of the entry in the localised text resource that should be used to\n        /// render text.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The localised text Id.\n        //------------------------------------------------------------------------------\n        void SetLocalisedTextId(const std::string& in_localisedTextId);\n        //------------------------------------------------------------------------------\n        /// Sets the rendered text from a localised text resource. Text can contain\n        /// basic markup for inserting variables into the string. The markup is in the\n        /// form [var=VariableName], and the value for the variable is looked up in the\n        /// given param dictionary.\n        ///\n        /// For example \"Time remaining: [var=TimeRemaining]\" with a param dictionary\n        /// containing \"TimeRemaining\"=\"12\" will become \"Time Remaining: 12\".\n        ///\n        /// The markup is also recursive, meaning that the following is valid:\n        /// \"[var=EntryNumber_[var=Number]]\".\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The localised text id which is used to lookup the string in the\n        /// localised text resource.\n        /// @param The param dictionary which contains the values which should be used\n        /// for each variable in the string.\n        /// @param The image data dictionary which contains the values which should be\n        /// used for each image in the string.\n        //------------------------------------------------------------------------------\n        void SetLocalisedTextId(const std::string& in_localisedTextId, const ParamDictionary& in_params, const TextIconDictionary& in_imageData = TextIconDictionary());\n        //------------------------------------------------------------------------------\n        /// Directly sets the text that will be rendered. This is not recommended,\n        /// usually is it better to set the text using a localised text resource.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The text.\n        //------------------------------------------------------------------------------\n        void SetText(const std::string& in_text);\n        //------------------------------------------------------------------------------\n        /// Directly sets the text that will be rendered. This is not recommended,\n        /// usually is it better to set the text using a localised text resource.\n        ///\n        /// Will replace flags [img=Variable] with images.\n        ///\n        /// For example \"You have earned 100 [img=Currency]\" with a map containing\n        /// the data for \"Currency\" will display an icon for it.\n        ///\n        /// @author Nicolas Tanda\n        ///\n        /// @param The text.\n        /// @param The image data dictionary which contains the values which should be\n        /// used for each image in the string.\n        //------------------------------------------------------------------------------\n        void SetText(const std::string& in_text, const TextIconDictionary& in_imageData);\n        //------------------------------------------------------------------------------\n        /// Sets the colour of the rendered text.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The colour.\n        //------------------------------------------------------------------------------\n        void SetTextColour(const Colour& in_textColour);\n        //------------------------------------------------------------------------------\n        /// Sets the horizontal justification of the text within the owning widget's\n        /// bounds.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The justfication.\n        //------------------------------------------------------------------------------\n        void SetHorizontalJustification(HorizontalTextJustification in_horizontalJustification);\n        //------------------------------------------------------------------------------\n        /// Sets the vertical justification of the text within the owning widget's\n        /// bounds.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The justification.\n        //------------------------------------------------------------------------------\n        void SetVerticalJustification(VerticalTextJustification in_verticalJustification);\n        //------------------------------------------------------------------------------\n        /// Sets the absolute pixel offset to the standard character spacing. This is\n        /// used to increase of reduce the space between characters in the rendered text.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The offset.\n        //------------------------------------------------------------------------------\n        void SetAbsoluteCharacterSpacingOffset(f32 in_offset);\n        //------------------------------------------------------------------------------\n        /// Sets the absolute pixel offset to the standard line spacing spacing. This is\n        /// used to increase of reduce the space between lines in the rendered text.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The offset.\n        //------------------------------------------------------------------------------\n        void SetAbsoluteLineSpacingOffset(f32 in_offset);\n        //------------------------------------------------------------------------------\n        /// Sets the scale factor which is applied to the line spacing. This is used to\n        /// increase of reduce the space between lines in the rendered text.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The scale factor.\n        //------------------------------------------------------------------------------\n        void SetLineSpacingScale(f32 in_scale);\n        //------------------------------------------------------------------------------\n        /// Sets the maximum number of lines of text that will be rendered. A value of 0\n        /// means there is no limit to the number of lines.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The number of lines, or 0 if no limit.\n        //------------------------------------------------------------------------------\n        void SetMaxNumberOfLines(s32 in_numLines);\n        //------------------------------------------------------------------------------\n        /// Sets the text scale. Scaling text significantly reduces the quality of the\n        /// text rendered so this should only be used when absolutely necessary.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The scale factor.\n        //------------------------------------------------------------------------------\n        void SetTextScale(f32 in_scale);\n        //------------------------------------------------------------------------------\n        /// Sets the minimum text scale that will be used in scale calculations if\n        /// EnableAutoTextScale is true. Scaling text significantly reduces the quality\n        /// of the text rendered so this should only be used when absolutely necessary.\n        ///\n        /// @author HMcLaughlin\n        ///\n        /// @param in_scale - The scale factor. (Must be <= TextScale)\n        //------------------------------------------------------------------------------\n        void SetMinAutoTextScale(f32 in_scale);\n        //------------------------------------------------------------------------------\n        /// Sets if this text component should attempt to auto scale the text to fit\n        /// into the labels bounds. This will achieve approximate best case fit scaling\n        /// for the current string and label size. This will only attempt to scale\n        /// downwards.\n        ///\n        /// @author HMcLaughlin\n        ///\n        /// @param in_enable - Enable auto scaling text\n        //------------------------------------------------------------------------------\n        void SetTextAutoScaleEnabled(bool in_enable);\n        \n    private:\n        friend class UIComponentFactory;\n        //------------------------------------------------------------------------------\n        /// A container for matching Text Icons to their position in the text string.\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------------------------------------\n        struct TextIconIndex final\n        {\n            TextIcon m_icon;\n            u32 m_indexInText = 0;\n        };\n        //------------------------------------------------------------------------------\n        /// A container for \"cached\" Text Icon data used to render the icon as part of\n        /// the label.\n        ///\n        /// Note that the offset combines both the texture atlas \"cropped\" offset\n        /// (if there is one) and the position of the image in the local space of the\n        /// label.\n        ///\n        /// @author Ian Copland\n        //------------------------------------------------------------------------------\n        struct TextIconCachedData final\n        {\n            TextureCSPtr m_texture;\n            Vector2 m_size;\n            Vector2 m_offset;\n            UVs m_uvs;\n        };\n        //------------------------------------------------------------------------------\n        /// Inserts variables into the given string with the values using basic markup.\n        /// The markup is in the form [var=VariableName], and the value for the variable\n        /// is looked up in the cached param dictionary.\n        ///\n        /// For example \"Time remaining: [var=TimeRemaining]\" with a param dictionary\n        /// containing \"TimeRemaining\"=\"12\" will become \"Time Remaining: 12\".\n        ///\n        /// The markup is also recursive, meaning that the following is valid:\n        /// \"[var=TextValue[var=ValueIndex]]\".\n        ///\n        /// This will also replace any [img= variable] flags with markers and spacing\n        /// for the TextUIComponent to draw icons using the cached images data map.\n        ///\n        /// @author Nicolas Tanda\n        ///\n        /// @param in_text - The text containing mark-ups\n        /// @param in_params - The param dictionary which contains the values which\n        /// should be used for each variable in the string.\n        /// @param in_imageData - The image data dictionary which contains the values\n        /// which should be used for each image in the string.\n        //------------------------------------------------------------------------------\n        void ReplaceVariables(const std::string& in_text, const ParamDictionary& in_params, const TextIconDictionary& in_imageData);\n        //------------------------------------------------------------------------------\n        /// Adds the icon described by the [img] tag to the Text Icon Indices list. Also\n        /// makes space in the rendered text string for the icon.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param in_font - The font which will be used to render the text.\n        /// @param in_iconDictionary - The icon dictionary.\n        /// @param in_iconName - The name of the icon image in the dictionary.\n        /// @param in_spaceInfo - Character info on a single space.\n        /// @param in_markerInfo - Character info on the marker character.\n        /// @param out_index - [Out] The current index of the text\n        /// @param out_iconIndices - [Out] The output list of icons.\n        ///\n        /// @return The text replacement for the icon.\n        //------------------------------------------------------------------------------\n        static std::string AddIcon(const FontCSPtr& in_font, const TextIconDictionary& in_iconDictionary, const std::string& in_iconName, const Font::CharacterInfo& in_spaceInfo,\n                                   const Font::CharacterInfo& in_markerInfo, u32& out_index, std::vector<TextIconIndex>& out_iconIndices);\n        //------------------------------------------------------------------------------\n        /// Builds the cachable Icon data from the list of icon indicies.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param in_font - The font which will be used to render the text.\n        /// @param in_builtText - The built text.\n        /// @param in_iconIndices - The icon indices.\n        /// @param in_textScale - The actual scale factor used to render the text, i.e\n        /// After auto-sizing has been taken into account.\n        ///\n        /// @return The vector of cachable icon data.\n        //------------------------------------------------------------------------------\n        static std::vector<TextIconCachedData> BuildIcons(const FontCSPtr& in_font, const CanvasRenderer::BuiltText& in_builtText, const std::vector<TextIconIndex>& in_iconIndices, f32 in_textScale);\n        //------------------------------------------------------------------------------\n        /// Constructor that builds the text from key-value properties. The properties\n        /// used to create the text are described in the class documentation.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The component name.\n        /// @param The property map.\n        //------------------------------------------------------------------------------\n        TextUIComponent(const std::string& in_componentName, const PropertyMap& in_properties);\n        //------------------------------------------------------------------------------\n        /// Render the text using the transform and size of the owning widget.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The canvas renderer.\n        /// @param The final screen space transform.\n        /// @param The final screen space size.\n        /// @param The final colour.\n        //-------------------------------------------------------------------------------\n        void OnDraw(CanvasRenderer* in_renderer, const Matrix3& in_transform, const Vector2& in_absSize, const Colour& in_absColour) override;\n        \n        FontCSPtr m_font;\n        LocalisedTextCSPtr m_localisedText;\n        std::string m_localisedTextId;\n        std::string m_text;\n        CanvasRenderer::TextProperties m_textProperties;\n        Colour m_textColour;\n        std::vector<TextIconIndex> m_iconIndices;\n        \n        bool m_invalidateCache = true;\n        Vector2 m_cachedSize;\n        CanvasRenderer::BuiltText m_cachedText;\n        std::vector<TextIconCachedData> m_cachedIcons;\n        \n        StringMarkupParser m_markupParser;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/UI/Text.h",
    "content": "//\n//  Text.h\n//  ChilliSource\n//  Created by Ian Copland on 05/11/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n\n#ifndef _CHILLISOURCE_UI_TEXT_H_\n#define _CHILLISOURCE_UI_TEXT_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/UI/Text/EditableTextUIComponent.h>\n#include <ChilliSource/UI/Text/TextUIComponent.h>\n#include <ChilliSource/UI/Text/TextIcon.h>\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Video/Base/CSSubtitlesProvider.cpp",
    "content": "//\n//  CSSubtitlesProvider.cpp\n//  ChilliSource\n//  Created by Ian Copland 21/02/2013.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2013 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Video/Base/CSSubtitlesProvider.h>\n\n#include <ChilliSource/Core/Base/Application.h>\n#include <ChilliSource/Core/Json/JsonUtils.h>\n#include <ChilliSource/Core/Localisation/LocalisedText.h>\n#include <ChilliSource/Core/Resource/ResourcePool.h>\n#include <ChilliSource/Core/String/StringParser.h>\n#include <ChilliSource/Core/Threading/TaskScheduler.h>\n#include <ChilliSource/Video/Base/Subtitles.h>\n\n#include <json/json.h>\n\nnamespace ChilliSource\n{\n    namespace\n    {\n        //----------------------------------------------------------------\n        // Constants\n        //----------------------------------------------------------------\n        const std::string k_CSSubtitlesExtension(\"cssubtitles\");\n        const std::string k_tagVersionNumber = \"VersionNumber\";\n        const std::string k_tagStyles = \"Styles\";\n        const std::string k_tagSubtitles = \"Subtitles\";\n        const std::string k_tagStyleName = \"Name\";\n        const std::string k_tagStyleFont = \"Font\";\n        const std::string k_tagStyleFontSize = \"FontSize\";\n        const std::string k_tagStyleFontColour = \"FontColour\";\n        const std::string k_tagStyleFadeTime = \"FadeTime\";\n        const std::string k_tagStyleAlignment = \"Alignment\";\n        const std::string k_tagStyleBounds = \"Bounds\";\n        const std::string k_tagStyleBoundsTop = \"Top\";\n        const std::string k_tagStyleBoundsBottom = \"Bottom\";\n        const std::string k_tagStyleBoundsLeft = \"Left\";\n        const std::string k_tagStyleBoundsRight = \"Right\";\n        const std::string k_tagSubtitlestyle = \"Style\";\n        const std::string k_tagSubtitlestartTime = \"StartTime\";\n        const std::string k_tagSubtitleEndTime = \"EndTime\";\n        const std::string k_tagLocalisedText = \"LocalisedText\";\n        const std::string k_tagSubtitleTextID = \"LocalisedTextID\";\n        const std::string k_defaultFont = \"Arial\";\n        const std::string k_defaultColour = \"1.0 1.0 1.0 1.0\";\n        const std::string k_defaultAlignment = \"MiddleCentre\";\n        const u32 k_defaultFontSize = 18;\n        const TimeIntervalMs k_defaultFadeTimeMS = 250;\n        const f32 k_defaultTop = 0.0f;\n        const f32 k_defaultLeft = 0.0f;\n        const f32 k_defaultRight = 1.0f;\n        const f32 k_defaultBottom = 1.0f;\n    }\n    \n    CS_DEFINE_NAMEDTYPE(CSSubtitlesProvider);\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    CSSubtitlesProviderUPtr CSSubtitlesProvider::Create()\n    {\n        return CSSubtitlesProviderUPtr(new CSSubtitlesProvider());\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    bool CSSubtitlesProvider::IsA(InterfaceIDType in_interfaceId) const\n    {\n        return in_interfaceId == ResourceProvider::InterfaceID || in_interfaceId == CSSubtitlesProvider::InterfaceID;\n    }\n    //----------------------------------------------------\n    //----------------------------------------------------\n    InterfaceIDType CSSubtitlesProvider::GetResourceType() const\n    {\n        return Subtitles::InterfaceID;\n    }\n    //----------------------------------------------------------------\n    //----------------------------------------------------------------\n    bool CSSubtitlesProvider::CanCreateResourceWithFileExtension(const std::string& in_extension) const\n    {\n        return in_extension == k_CSSubtitlesExtension;\n    }\n    //--------------------------------------------------------------\n    //--------------------------------------------------------------\n    void CSSubtitlesProvider::CreateResourceFromFile(StorageLocation in_storageLocation, const std::string& in_filePath, const IResourceOptionsBaseCSPtr& in_options, const ResourceSPtr& out_resource)\n    {\n        SubtitlesSPtr pSubtitles = std::static_pointer_cast<Subtitles>(out_resource);\n        LoadSubtitles(in_storageLocation, in_filePath, nullptr, pSubtitles);\n    }\n    //--------------------------------------------------------------\n    //--------------------------------------------------------------\n    void CSSubtitlesProvider::CreateResourceFromFileAsync(StorageLocation in_storageLocation, const std::string& in_filePath, const IResourceOptionsBaseCSPtr& in_options, const ResourceProvider::AsyncLoadDelegate& in_delegate, const ResourceSPtr& out_resource)\n    {\n        SubtitlesSPtr pSubtitles = std::static_pointer_cast<Subtitles>(out_resource);\n        \n        //Load model as task\n        Application::Get()->GetTaskScheduler()->ScheduleTask(TaskType::k_file, [=](const TaskContext&) noexcept\n        {\n            LoadSubtitles(in_storageLocation, in_filePath, in_delegate, pSubtitles);\n        });\n    }\n    //--------------------------------------------------------------\n    //--------------------------------------------------------------\n    void CSSubtitlesProvider::LoadSubtitles(StorageLocation in_storageLocation, const std::string& in_filePath, const ResourceProvider::AsyncLoadDelegate& in_delegate, const SubtitlesSPtr& out_resource) const\n    {\n        //read the JSON\n        Json::Value root;\n        if (JsonUtils::ReadJson(in_storageLocation, in_filePath, root) == false)\n        {\n            CS_LOG_ERROR(\"Subtitles file '\" + in_filePath + \"' could not be read.\");\n            out_resource->SetLoadState(Resource::LoadState::k_failed);\n            if(in_delegate != nullptr)\n            {\n                Application::Get()->GetTaskScheduler()->ScheduleTask(TaskType::k_mainThread, [=](const TaskContext&) noexcept\n                {\n                    in_delegate(out_resource);\n                });\n            }\n            return;\n        }\n        \n        //get the version number\n        u32 udwVersionNumber = root.get(k_tagVersionNumber, 0).asUInt();\n        if (udwVersionNumber != 1)\n        {\n            CS_LOG_ERROR(\"Subtitles file '\" + in_filePath + \"' has version number '\" + ToString(udwVersionNumber) + \"'. Only version 1 is supported.\");\n            out_resource->SetLoadState(Resource::LoadState::k_failed);\n            if(in_delegate != nullptr)\n            {\n                Application::Get()->GetTaskScheduler()->ScheduleTask(TaskType::k_mainThread, [=](const TaskContext&) noexcept\n                {\n                    in_delegate(out_resource);\n                });\n            }\n            return;\n        }\n        \n        //get the localised text\n        if (root.isMember(k_tagLocalisedText) == false)\n        {\n            CS_LOG_ERROR(\"Subtitles file '\" + in_filePath + \"' must have localised text resource\");\n            out_resource->SetLoadState(Resource::LoadState::k_failed);\n            if(in_delegate != nullptr)\n            {\n                Application::Get()->GetTaskScheduler()->ScheduleTask(TaskType::k_mainThread, [=](const TaskContext&) noexcept\n                {\n                    in_delegate(out_resource);\n                });\n            }\n            return;\n        }\n        \n        Json::Value localisedTextJson(root[k_tagLocalisedText]);\n        StorageLocation textLocation = ParseStorageLocation(localisedTextJson.get(\"Location\", \"Package\").asString());\n        \n        auto localisedText = Application::Get()->GetResourcePool()->LoadResource<LocalisedText>(textLocation, localisedTextJson.get(\"Path\", \"\").asString());\n        if (localisedText == nullptr)\n        {\n            CS_LOG_ERROR(\"Subtitles file '\" + in_filePath + \"' must have localised text resource\");\n            out_resource->SetLoadState(Resource::LoadState::k_failed);\n            if(in_delegate != nullptr)\n            {\n                Application::Get()->GetTaskScheduler()->ScheduleTask(TaskType::k_mainThread, [=](const TaskContext&) noexcept\n                {\n                    in_delegate(out_resource);\n                });\n            }\n            return;\n        }\n        \n        out_resource->SetLocalisedText(localisedText);\n        \n        //get the styles\n        if (root.isMember(k_tagStyles) == true)\n        {\n            for (Json::ValueIterator it = root[k_tagStyles].begin(); it != root[k_tagStyles].end(); ++it)\n            {\n                Subtitles::StyleCUPtr pStyle = LoadStyle((*it));\n                if (pStyle != nullptr)\n                {\n                    out_resource->AddStyle(std::move(pStyle));\n                }\n                else\n                {\n                    CS_LOG_ERROR(\"Subtitles file '\" + in_filePath + \"' failed to load.\");\n                    out_resource->SetLoadState(Resource::LoadState::k_failed);\n                    if(in_delegate != nullptr)\n                    {\n                        Application::Get()->GetTaskScheduler()->ScheduleTask(TaskType::k_mainThread, [=](const TaskContext&) noexcept\n                        {\n                            in_delegate(out_resource);\n                        });\n                    }\n                    return;\n                }\n            }\n        }\n        else\n        {\n            CS_LOG_ERROR(\"Subtitles file '\" + in_filePath + \"' does not have styles.\");\n            out_resource->SetLoadState(Resource::LoadState::k_failed);\n            if(in_delegate != nullptr)\n            {\n                Application::Get()->GetTaskScheduler()->ScheduleTask(TaskType::k_mainThread, [=](const TaskContext&) noexcept\n                {\n                    in_delegate(out_resource);\n                });\n            }\n            return;\n        }\n        \n        //get the subtitles\n        if (root.isMember(k_tagSubtitles) == true)\n        {\n            for (Json::ValueIterator it = root[k_tagSubtitles].begin(); it != root[k_tagSubtitles].end(); ++it)\n            {\n                Subtitles::SubtitleCUPtr pSubtitle = LoadSubtitle((*it));\n                if (pSubtitle != nullptr)\n                {\n                    out_resource->AddSubtitle(std::move(pSubtitle));\n                }\n                else\n                {\n                    CS_LOG_ERROR(\"Subtitles file '\" + in_filePath + \"' failed to load.\");\n                    out_resource->SetLoadState(Resource::LoadState::k_failed);\n                    if(in_delegate != nullptr)\n                    {\n                        Application::Get()->GetTaskScheduler()->ScheduleTask(TaskType::k_mainThread, [=](const TaskContext&) noexcept\n                        {\n                            in_delegate(out_resource);\n                        });\n                    }\n                    return;\n                }\n            }\n        }\n        else\n        {\n            CS_LOG_ERROR(\"Subtitles file '\" + in_filePath + \"' does not have subtitles.\");\n            out_resource->SetLoadState(Resource::LoadState::k_failed);\n            if(in_delegate != nullptr)\n            {\n                Application::Get()->GetTaskScheduler()->ScheduleTask(TaskType::k_mainThread, [=](const TaskContext&) noexcept\n                {\n                    in_delegate(out_resource);\n                });\n            }\n            return;\n        }\n        \n        out_resource->SetLoadState(Resource::LoadState::k_loaded);\n        \n        if(in_delegate != nullptr)\n        {\n            Application::Get()->GetTaskScheduler()->ScheduleTask(TaskType::k_mainThread, [=](const TaskContext&) noexcept\n            {\n                in_delegate(out_resource);\n            });\n        }\n    }\n    //-------------------------------------------------------------------------\n    //-------------------------------------------------------------------------\n    Subtitles::StyleCUPtr CSSubtitlesProvider::LoadStyle(const Json::Value& in_styleJSON) const\n    {\n        Subtitles::StyleUPtr pStyle(new Subtitles::Style());\n        \n        //name\n        pStyle->m_name = in_styleJSON.get(k_tagStyleName,\"\").asString();\n        if(pStyle->m_name == \"\")\n        {\n            CS_LOG_ERROR(\"Subtitle style must have a name.\");\n            return Subtitles::StyleUPtr();\n        }\n        \n        pStyle->m_fontName = in_styleJSON.get(k_tagStyleFont, k_defaultFont).asString();\n        pStyle->m_fontSize = in_styleJSON.get(k_tagStyleFontSize, k_defaultFontSize).asUInt();\n        pStyle->m_colour = ParseColour(in_styleJSON.get(k_tagStyleFontColour, k_defaultColour).asString());\n        pStyle->m_fadeTimeMS = ParseTime(in_styleJSON.get(k_tagStyleFadeTime, (s32)k_defaultFadeTimeMS).asString());\n        pStyle->m_alignment = ParseAlignmentAnchor(in_styleJSON.get(k_tagStyleAlignment, k_defaultAlignment).asString());\n        pStyle->m_bounds = LoadBounds(in_styleJSON.get(k_tagStyleBounds, \"\"));\n        \n        return Subtitles::StyleUPtr(std::move(pStyle));\n    }\n    //-------------------------------------------------------------------------\n    //-------------------------------------------------------------------------\n    Subtitles::SubtitleCUPtr CSSubtitlesProvider::LoadSubtitle(const Json::Value& in_subtitleJSON) const\n    {\n        Subtitles::SubtitleUPtr pSubtitle(new Subtitles::Subtitle());\n        \n        //style\n        pSubtitle->m_styleName = in_subtitleJSON.get(k_tagSubtitlestyle, \"\").asString();\n        if (pSubtitle->m_styleName == \"\")\n        {\n            CS_LOG_ERROR(\"Subtitle must have a style.\");\n            return Subtitles::SubtitleCUPtr();\n        }\n\n        //text id\n        pSubtitle->m_localisedTextId = in_subtitleJSON.get(k_tagSubtitleTextID, \"\").asString();\n        if (pSubtitle->m_localisedTextId == \"\")\n        {\n            CS_LOG_ERROR(\"Subtitle must have a text ID.\");\n            return Subtitles::SubtitleCUPtr();\n        }\n        \n        pSubtitle->m_startTimeMS = ParseTime(in_subtitleJSON.get(k_tagSubtitlestartTime, \"0\").asString());\n        pSubtitle->m_endTimeMS = ParseTime(in_subtitleJSON.get(k_tagSubtitleEndTime, \"0\").asString());\n\n        return Subtitles::SubtitleCUPtr(std::move(pSubtitle));\n    }\n    //-------------------------------------------------------------------------\n    //-------------------------------------------------------------------------\n    Rectangle CSSubtitlesProvider::LoadBounds(const Json::Value& in_boundsJSON) const\n    {\n        f32 fTop = (f32)in_boundsJSON.get(k_tagStyleBoundsTop, k_defaultTop).asDouble();\n        f32 fBottom = (f32)in_boundsJSON.get(k_tagStyleBoundsBottom, k_defaultBottom).asDouble();\n        f32 fLeft = (f32)in_boundsJSON.get(k_tagStyleBoundsLeft, k_defaultLeft).asDouble();\n        f32 fRight = (f32)in_boundsJSON.get(k_tagStyleBoundsRight, k_defaultRight).asDouble();\n\n        return Rectangle(Vector2(fLeft + (fRight - fLeft) * 0.5f, fBottom + (fTop - fBottom) * 0.5f), Vector2(fRight - fLeft, fTop - fBottom));\n    }\n    //-------------------------------------------------------------------------\n    //-------------------------------------------------------------------------\n    TimeIntervalMs CSSubtitlesProvider::ParseTime(const std::string& in_time) const\n    {\n        u32 udwHours, udwMinutes, udwSeconds, udwMilliseconds;\n\n        CS_SSCANF(in_time.c_str(), \"%d:%d:%d:%d\", &udwHours, &udwMinutes, &udwSeconds, &udwMilliseconds);\n\n        TimeIntervalMs outputMS = ((TimeIntervalMs)udwHours) * 60 * 60 * 1000 + ((TimeIntervalMs)udwMinutes) * 60 * 1000 + ((TimeIntervalMs)udwSeconds) * 1000 + ((TimeIntervalMs)udwMilliseconds);\n        return outputMS;\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Video/Base/CSSubtitlesProvider.h",
    "content": "//\n//  CSSubtitlesProvider.h\n//  ChilliSource\n//  Created by Ian Copland 21/02/2013.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2013 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_VIDEO_BASE_CSSUBTITLESPROVIDER_H_\n#define _CHILLISOURCE_VIDEO_BASE_CSSUBTITLESPROVIDER_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Resource/ResourceProvider.h>\n#include <ChilliSource/Video/Base/Subtitles.h>\n\n#include <json/json.h>\n\nnamespace ChilliSource\n{\n    //-------------------------------------------------------------------------\n    /// Factory loader for creating subtitle resources from file.\n    ///\n    /// @param Ian Copland\n    //-------------------------------------------------------------------------\n    class CSSubtitlesProvider final : public ResourceProvider\n    {\n    public:\n        \n        CS_DECLARE_NAMEDTYPE(CSSubtitlesProvider);\n        \n        //-------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param Interface to compare\n        ///\n        /// @return Whether the object implements the given interface\n        //-------------------------------------------------------------------------\n        bool IsA(InterfaceIDType in_interfaceId) const override;\n        //----------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return The resource type this provider can create\n        //----------------------------------------------------\n        InterfaceIDType GetResourceType() const override;\n        //-------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param Type to compare\n        /// @param Extension to compare\n        ///\n        /// @return Whether the object can create a resource with the given extension\n        //-------------------------------------------------------------------------\n        bool CanCreateResourceWithFileExtension(const std::string& in_extension) const override;\n    private:\n        friend class Application;\n        //-------------------------------------------------------\n        /// Creates a new instance of the subtitle provider.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @return The new instance.\n        //-------------------------------------------------------\n        static CSSubtitlesProviderUPtr Create();\n        //-------------------------------------------------------\n        /// Private constructor to force use of factory method\n        ///\n        /// @author Ian Copland\n        //-------------------------------------------------------\n        CSSubtitlesProvider() = default;\n        //-------------------------------------------------------------------------\n        /// Load the subtitles resource from the given file location. Check\n        /// the resource load state for success\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The storage location to load from\n        /// @param File path\n        /// @param Options to customise the creation\n        /// @param [Out] Resource object\n        //-------------------------------------------------------------------------\n        void CreateResourceFromFile(StorageLocation in_storageLocation, const std::string& in_filePath, const IResourceOptionsBaseCSPtr& in_options, const ResourceSPtr& out_resource) override;\n        //-------------------------------------------------------------------------\n        /// Load the subtitles resource on a background thread from the given\n        /// file location. Calls the completion delegate on completion. Check\n        /// the resource load state for success.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The storage location to load from\n        /// @param File path\n        /// @param Options to customise the creation\n        /// @param Delegate\n        /// @param [Out] Resource object\n        //-------------------------------------------------------------------------\n        void CreateResourceFromFileAsync(StorageLocation in_storageLocation, const std::string& in_filePath, const IResourceOptionsBaseCSPtr& in_options, const ResourceProvider::AsyncLoadDelegate& in_delegate, const ResourceSPtr& out_resource) override;\n        //-------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param The storage location to load from\n        /// @param File path\n        /// @param Completion delegate\n        /// @param [Out] Resource object\n        //-------------------------------------------------------------------------\n        void LoadSubtitles(StorageLocation in_storageLocation, const std::string& in_filePath, const ResourceProvider::AsyncLoadDelegate& in_delegate, const SubtitlesSPtr& out_resource) const;\n        //-------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param The style JSON object.\n        ///\n        /// @return the style.\n        //-------------------------------------------------------------------------\n        Subtitles::StyleCUPtr LoadStyle(const Json::Value& in_styleJSON) const;\n        //-------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param The subtitle JSON object.\n        ///\n        /// @return the subtitle.\n        //-------------------------------------------------------------------------\n        Subtitles::SubtitleCUPtr LoadSubtitle(const Json::Value& in_subtitleJSON) const;\n        //-------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param The bounds JSON object.\n        ///\n        /// @return the rectangle representing the bounding box that contains the\n        /// subtitles.\n        //-------------------------------------------------------------------------\n        Rectangle LoadBounds(const Json::Value& in_boundsJSON) const;\n        //-------------------------------------------------------------------------\n        /// Parses a time string in the format Hours:Minutes:Seconds:Milliseconds.\n        /// For example 01:05:34:123.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The string time.\n        ///\n        /// @return the integer time in milliseconds.\n        //-------------------------------------------------------------------------\n        TimeIntervalMs ParseTime(const std::string& in_time) const;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Video/Base/Subtitles.cpp",
    "content": "//\n//  Subtitles.cpp\n//  ChilliSource\n//  Created by Ian Copland 21/02/2013.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2013 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Video/Base/Subtitles.h>\n\nnamespace ChilliSource\n{\n    CS_DEFINE_NAMEDTYPE(Subtitles);\n    \n    //----------------------------------------------------------\n    //----------------------------------------------------------\n    SubtitlesUPtr Subtitles::Create()\n    {\n        return SubtitlesUPtr(new Subtitles());\n    }\n    //----------------------------------------------------------\n    //----------------------------------------------------------\n    bool Subtitles::IsA(InterfaceIDType in_interfaceId) const\n    {\n        return in_interfaceId == Subtitles::InterfaceID;\n    }\n    //----------------------------------------------------------\n    //----------------------------------------------------------\n    void Subtitles::AddStyle(StyleCUPtr in_style)\n    {\n        CS_ASSERT(in_style != nullptr, \"Cannot add null style to subtitles\");\n        m_styles.insert(std::make_pair(in_style->m_name, std::move(in_style)));\n    }\n    //----------------------------------------------------------\n    //----------------------------------------------------------\n    void Subtitles::AddSubtitle(SubtitleCUPtr in_subtitle)\n    {\n        CS_ASSERT(in_subtitle != nullptr, \"Cannot add null subtitle to subtitles\");\n        m_subtitles.push_back(std::move(in_subtitle));\n    }\n    //----------------------------------------------------------\n    //----------------------------------------------------------\n    void Subtitles::SetLocalisedText(const LocalisedTextCSPtr& in_text)\n    {\n        m_localisedText = in_text;\n    }\n    //----------------------------------------------------------\n    //----------------------------------------------------------\n    const LocalisedTextCSPtr& Subtitles::GetLocalisedText() const\n    {\n        return m_localisedText;\n    }\n    //----------------------------------------------------------\n    //----------------------------------------------------------\n    std::vector<const Subtitles::Subtitle*> Subtitles::GetSubtitlesAtTime(TimeIntervalMs in_timeMS) const\n    {\n        std::vector<const Subtitles::Subtitle*> subtitles;\n        \n        for (auto it = m_subtitles.begin(); it != m_subtitles.end(); ++it)\n        {\n            if (in_timeMS >= (*it)->m_startTimeMS && in_timeMS <= (*it)->m_endTimeMS)\n            {\n                subtitles.push_back(it->get());\n            }\n        }\n        \n        return subtitles;\n    }\n    //----------------------------------------------------------\n    //----------------------------------------------------------\n    const Subtitles::Style* Subtitles::GetStyleWithName(const std::string& in_name) const\n    {\n        auto found = m_styles.find(in_name);\n        if (found != m_styles.end())\n        {\n            return found->second.get();\n        }\n        \n        CS_LOG_WARNING(\"Could not find style '\" + in_name + \"' in Subtitles '\" + GetName() + \"'\");\n        return nullptr;\n    }\n}\n\n"
  },
  {
    "path": "Source/ChilliSource/Video/Base/Subtitles.h",
    "content": "//\n//  Subtitles.h\n//  ChilliSource\n//  Created by Ian Copland 21/02/2013.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2013 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_VIDEO_BASE_SUBTITLES_H_\n#define _CHILLISOURCE_VIDEO_BASE_SUBTITLES_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Base/Colour.h>\n#include <ChilliSource/Core/Resource/Resource.h>\n#include <ChilliSource/Core/Math/Geometry/Shapes.h>\n#include <ChilliSource/Rendering/Base/AlignmentAnchors.h>\n\n#include <unordered_map>\n\nnamespace ChilliSource\n{\n    //----------------------------------------------------------\n    /// A subtitles resource. This is used for displaying\n    /// subtitles over videos played using the video player\n    /// activity.\n    ///\n    /// @author Ian Copland\n    //----------------------------------------------------------\n    class Subtitles final : public Resource\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(Subtitles);\n        //----------------------------------------------------------\n        /// Holds the style of the subtitles such as colour,\n        /// font, etc.\n        ///\n        /// @author Ian Copland\n        //----------------------------------------------------------\n        struct Style\n        {\n            std::string m_name;\n            std::string m_fontName;\n            u32 m_fontSize;\n            Colour m_colour;\n            Rectangle m_bounds;\n            AlignmentAnchor m_alignment;\n            TimeIntervalMs m_fadeTimeMS;\n        };\n        typedef std::unique_ptr<const Style> StyleCUPtr;\n        typedef std::unique_ptr<Style> StyleUPtr;\n        //----------------------------------------------------------\n        /// Holds the information about a single subtitle instance\n        ///\n        /// @author Ian Copland\n        //----------------------------------------------------------\n        struct Subtitle\n        {\n            std::string m_styleName;\n            TimeIntervalMs m_startTimeMS;\n            TimeIntervalMs m_endTimeMS;\n            std::string m_localisedTextId;\n        };\n        typedef std::unique_ptr<const Subtitle> SubtitleCUPtr;\n        typedef std::unique_ptr<Subtitle> SubtitleUPtr;\n        //----------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param Comparison Type\n        ///\n        /// @return Whether the class matches the comparison type\n        //----------------------------------------------------------\n        bool IsA(InterfaceIDType in_interfaceId) const override;\n        //----------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param The Style to add to the available styles\n        //----------------------------------------------------------\n        void AddStyle(StyleCUPtr in_style);\n        //----------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param The subtitle to add to the current list of subtitles\n        //----------------------------------------------------------\n        void AddSubtitle(SubtitleCUPtr in_subtitle);\n        //----------------------------------------------------------\n        /// Returns all the active subtitles at the given time.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param Time in MS from the start if the subtitle sequence.\n        ///\n        /// @return List subtitles.\n        //----------------------------------------------------------\n        std::vector<const Subtitles::Subtitle*> GetSubtitlesAtTime(TimeIntervalMs in_timeMS) const;\n        //----------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @param Style name\n        ///\n        /// @return The style with the given name or null\n        //----------------------------------------------------------\n        const Style* GetStyleWithName(const std::string& in_name) const;\n        //----------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @param Localised text resource used by the internal\n        /// subtitles\n        //----------------------------------------------------------\n        void SetLocalisedText(const LocalisedTextCSPtr& in_text);\n        //----------------------------------------------------------\n        /// @author S Downie\n        ///\n        /// @return Localised text resource used by the internal\n        /// subtitles\n        //----------------------------------------------------------\n        const LocalisedTextCSPtr& GetLocalisedText() const;\n        \n    private:\n        \n        friend class ResourcePool;\n        //----------------------------------------------------------\n        /// Factory create method that creates a new empty subtitle\n        /// resource. Only accessed by the resource pool\n        ///\n        /// @author S Downie\n        //----------------------------------------------------------\n        static SubtitlesUPtr Create();\n        //----------------------------------------------------------\n        /// Private constructor to force the use of the factory\n        /// create method\n        ///\n        /// @author S Downie\n        //----------------------------------------------------------\n        Subtitles() = default;\n        \n    private:\n        \n        std::unordered_map<std::string, StyleCUPtr> m_styles;\n        std::vector<SubtitleCUPtr> m_subtitles;\n        \n        LocalisedTextCSPtr m_localisedText;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Video/Base/VideoPlayer.cpp",
    "content": "//\n//  VideoPlayer.cpp\n//  ChilliSource\n//  Created by S Downie on 12/05/2011.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2011 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Video/Base/VideoPlayer.h>\n\n#ifdef CS_TARGETPLATFORM_IOS\n#import <CSBackend/Platform/iOS/Video/Base/VideoPlayer.h>\n#endif\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n#include <CSBackend/Platform/Android/Main/JNI/Video/Base/VideoPlayer.h>\n#endif\n\nnamespace ChilliSource\n{\n    CS_DEFINE_NAMEDTYPE(VideoPlayer);\n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    VideoPlayerUPtr VideoPlayer::Create()\n    {\n#ifdef CS_TARGETPLATFORM_IOS\n        return VideoPlayerUPtr(new CSBackend::iOS::VideoPlayer());\n#endif\n#ifdef CS_TARGETPLATFORM_ANDROID\n        return VideoPlayerUPtr(new CSBackend::Android::VideoPlayer());\n#endif\n        return nullptr;\n    }\n}\n"
  },
  {
    "path": "Source/ChilliSource/Video/Base/VideoPlayer.h",
    "content": "//\n//  VideoPlayer.h\n//  ChilliSource\n//  Created by S Downie on 12/05/2011.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2011 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_VIDEO_BASE_VIDEOPLAYER_H_\n#define _CHILLISOURCE_VIDEO_BASE_VIDEOPLAYER_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Base/Colour.h>\n#include <ChilliSource/Core/Delegate/ConnectableDelegate.h>\n#include <ChilliSource/Core/Event/Event.h>\n#include <ChilliSource/Core/File/StorageLocation.h>\n#include <ChilliSource/Core/System/StateSystem.h>\n\n#include <functional>\n\nnamespace ChilliSource\n{\n    //--------------------------------------------------------------\n    /// A state system for cross platform playback of videos.\n    ///\n    /// @author S Downie\n    //--------------------------------------------------------------\n    class VideoPlayer : public StateSystem\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(VideoPlayer);\n        //-------------------------------------------------------\n        /// A delegate called when the video finishes playback.\n        ///\n        /// @author S Downie\n        //-------------------------------------------------------\n        using VideoCompleteDelegate = ConnectableDelegate<void()>;\n        //-------------------------------------------------------\n        /// Begin streaming the video from file\n        ///\n        /// @author S Downie\n        ///\n        /// @param The storage location of the video.\n        /// @param The video file name.\n        /// @param Connection to the completion delegate.\n        /// @param [Optional] Whether or not the video can be\n        /// dismissed by tapping. Defaults to true.\n        /// @param [Optional] The video background colour. Defaults\n        /// to black.\n        //--------------------------------------------------------\n        virtual void Present(StorageLocation in_storageLocation, const std::string& in_fileName, VideoCompleteDelegate::Connection&& in_delegateConnection, bool in_dismissWithTap = true,\n                             const Colour& in_backgroundColour = Colour::k_black) = 0;\n        //--------------------------------------------------------\n        /// Begin streaming the video from file with subtitles.\n        ///\n        /// @author Ian Copland\n        ///\n        /// @param The storage location of the video.\n        /// @param The video file name.\n        /// @param The subtitles resource.\n        /// @param Connection to the completion delegate.\n        /// @param [Optional] Whether or not the video can be\n        /// dismissed by tapping. Defaults to true.\n        /// @param [Optional] The video background colour. Defaults\n        /// to black.\n        //--------------------------------------------------------\n        virtual void PresentWithSubtitles(StorageLocation in_storageLocation, const std::string& in_fileName, const SubtitlesCSPtr& in_subtitles, VideoCompleteDelegate::Connection&& in_delegateConnection,\n                                          bool in_dismissWithTap, const Colour& in_backgroundColour = Colour::k_black) = 0;\n        //-------------------------------------------------------\n        /// Returns whether or not the player is currently\n        /// presented.\n        ///\n        /// @author Jordan Brown\n        //-------------------------------------------------------\n        virtual bool IsPresented() const noexcept = 0;\n        //--------------------------------------------------------\n        /// Destructor\n        ///\n        /// @author S Downie\n        //--------------------------------------------------------\n        virtual ~VideoPlayer(){}\n    protected:\n        friend class State;\n        //-------------------------------------------------------\n        /// Create the platform dependent backend\n        ///\n        /// @author S Downie\n        ///\n        /// @return New backend instance\n        //-------------------------------------------------------\n        static VideoPlayerUPtr Create();\n        //-------------------------------------------------------\n        /// Private constructor to force use of factory method\n        ///\n        /// @author S Downie\n        //-------------------------------------------------------\n        VideoPlayer() = default;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Video/Base.h",
    "content": "//\n//  Base.h\n//  ChilliSource\n//  Created by Ian Copland on 07/07/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n\n#ifndef _CHILLISOURCE_VIDEO_BASE_H_\n#define _CHILLISOURCE_VIDEO_BASE_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Video/Base/CSSubtitlesProvider.h>\n#include <ChilliSource/Video/Base/Subtitles.h>\n#include <ChilliSource/Video/Base/VideoPlayer.h>\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Video/ForwardDeclarations.h",
    "content": "//\n//  ForwardDeclarations.h\n//  ChilliSource\n//  Created by Scott Downie on 12/05/2011.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2011 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_VIDEO_FORWARDDECLARATIONS_H_\n#define _CHILLISOURCE_VIDEO_FORWARDDECLARATIONS_H_\n\n#include <ChilliSource/Core/Base/StandardMacros.h>\n\n#include <memory>\n\nnamespace ChilliSource\n{\n    //------------------------------------------------------\n    /// Base\n    //------------------------------------------------------\n    CS_FORWARDDECLARE_CLASS(CSSubtitlesProvider);\n    CS_FORWARDDECLARE_CLASS(Subtitles);\n    CS_FORWARDDECLARE_CLASS(SubtitlesManager);\n    CS_FORWARDDECLARE_CLASS(VideoPlayer);\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Web/Base/WebView.cpp",
    "content": "//\n//  WebView.cpp\n//  ChilliSource\n//  Created by Scott Downie on 25/07/2011.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2011 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#include <ChilliSource/Web/Base/WebView.h>\n\n#ifdef CS_TARGETPLATFORM_IOS\n#import <CSBackend/Platform/iOS/Web/Base/WebView.h>\n#endif\n\n#ifdef CS_TARGETPLATFORM_ANDROID\n#include <CSBackend/Platform/Android/Main/JNI/Web/Base/WebView.h>\n#endif\n\nnamespace ChilliSource\n{\n    CS_DEFINE_NAMEDTYPE(WebView);\n    \n    //-------------------------------------------------------\n    //-------------------------------------------------------\n    WebViewUPtr WebView::Create()\n    {\n#ifdef CS_TARGETPLATFORM_IOS\n        return WebViewUPtr(new CSBackend::iOS::WebView());\n#endif\n#ifdef CS_TARGETPLATFORM_ANDROID\n        return WebViewUPtr(new CSBackend::Android::WebView());\n#endif\n        return nullptr;\n    }\n}\n\n"
  },
  {
    "path": "Source/ChilliSource/Web/Base/WebView.h",
    "content": "//\n//  WebView.h\n//  ChilliSource\n//  Created by Scott Downie on 25/07/2011.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2011 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_WEB_BASE_WEBVIEW_H_\n#define _CHILLISOURCE_WEB_BASE_WEBVIEW_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Core/Event/Event.h>\n#include <ChilliSource/Core/File/FileSystem.h>\n#include <ChilliSource/Core/Math/UnifiedCoordinates.h>\n#include <ChilliSource/Core/System/StateSystem.h>\n\n#include <functional>\n\nnamespace ChilliSource\n{\n    //---------------------------------------------------------------\n    /// A state system for displaying Web pages, either in application\n    /// or in an external browser.\n    ///\n    /// @author S Downie\n    //---------------------------------------------------------------\n    class WebView : public StateSystem\n    {\n    public:\n        CS_DECLARE_NAMEDTYPE(WebViewActivity);\n        //------------------------------------------------------------------------------\n        /// A delegate called when the webview is dismissed.\n        ///\n        /// @author S Downie\n        //------------------------------------------------------------------------------\n        using DismissedDelegate = std::function<void()>;\n        //------------------------------------------------------------------------------\n        /// A delegate called when a link is clicked on an\n        /// internal webview.\n        ///\n        /// @author HMcLaughlin\n        ///\n        /// @param in_url - URL clicked on\n        ///\n        /// @return True if the URL will be handled by the\n        /// delegate owner, False will allow the webview to\n        /// display as normal\n        //------------------------------------------------------------------------------\n        using CustomLinkHandlerDelegate = std::function<bool(const std::string& in_url)>;\n        //------------------------------------------------------------------------------\n        /// Displays the website at the given URL in an in-app\n        /// web view.\n        ///\n        /// @author S Downie\n        ///\n        /// @param in_url - The Url.\n        /// @param in_size - The size of the webview in GUI coordinates.\n        /// @param in_dismissButtonRelativeSize - The relative size of the dismiss\n        /// button.\n        /// @param in_delegate - The dismissed delegate.\n        /// @param in_customURLClickHandler - The delegate to call when a link is\n        /// clicked on the displayed page\n        //------------------------------------------------------------------------------\n        virtual void Present(const std::string& in_url, const UnifiedVector2& in_size, f32 in_dismissButtonRelativeSize, const DismissedDelegate& in_delegate, const CustomLinkHandlerDelegate& in_customLinkHandler = nullptr) = 0;\n        //------------------------------------------------------------------------------\n        /// Displays the website at the given location on disk in\n        /// an in-app web view.\n        ///\n        /// @author S Downie\n        ///\n        /// @param in_storageLocation - The storage location.\n        /// @param in_filePath - The file path.\n        /// @param in_size - The size of the webview in GUI coordinates.\n        /// @param in_dismissButtonRelativeSize - The relative size of the dismiss\n        /// button.\n        /// @param in_delegate - The dismissed delegate.\n        /// @param in_customURLClickHandler - The delegate to call when a link is\n        /// clicked on the displayed page\n        //------------------------------------------------------------------------------\n        virtual void PresentFromFile(StorageLocation in_storageLocation, const std::string& in_filePath, const UnifiedVector2& in_size, f32 in_dismissButtonRelativeSize, const DismissedDelegate& in_delegate, const CustomLinkHandlerDelegate& in_customLinkHandler = nullptr) = 0;\n        //------------------------------------------------------------------------------\n        /// Displays the website at the given Url in an external\n        /// browser.\n        ///\n        /// @author S Downie\n        ///\n        /// @param The Url.\n        //------------------------------------------------------------------------------\n        virtual void PresentInExternalBrowser(const std::string& in_url) = 0;\n        //------------------------------------------------------------------------------\n        /// Dismiss the web view if it is currently presented.\n        ///\n        /// @author S Downie\n        //------------------------------------------------------------------------------\n        virtual void Dismiss() = 0;\n        //------------------------------------------------------------------------------\n        /// @author Ian Copland\n        ///\n        /// @return Whether or not the web view is currently\n        /// presented.\n        //------------------------------------------------------------------------------\n        virtual bool IsPresented() const = 0;\n        \n    protected:\n        friend class State;\n        //------------------------------------------------------------------------------\n        /// Create the platform dependent backend.\n        ///\n        /// @author S Downie\n        ///\n        /// @return New backend instance\n        //------------------------------------------------------------------------------\n        static WebViewUPtr Create();\n        //------------------------------------------------------------------------------\n        /// protected constructor to force use of factory method\n        ///\n        /// @author S Downie\n        //------------------------------------------------------------------------------\n        WebView() = default;\n    };\n}\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Web/Base.h",
    "content": "//\n//  Base.h\n//  ChilliSource\n//  Created by Ian Copland on 07/07/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n\n#ifndef _CHILLISOURCE_WEB_BASE_H_\n#define _CHILLISOURCE_WEB_BASE_H_\n\n#include <ChilliSource/ChilliSource.h>\n#include <ChilliSource/Web/Base/WebView.h>\n\n#endif\n"
  },
  {
    "path": "Source/ChilliSource/Web/ForwardDeclarations.h",
    "content": "//\n//  ForwardDeclarations.h\n//  ChilliSource\n//  Created by Ian Copland 25/02/2014.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2014 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\n#ifndef _CHILLISOURCE_WEB_FORWARDDECLARATIONS_H_\n#define _CHILLISOURCE_WEB_FORWARDDECLARATIONS_H_\n\n#include <ChilliSource/Core/Base/StandardMacros.h>\n\n#include <memory>\n\nnamespace ChilliSource\n{\n    //---------------------------------------------------\n    /// Base\n    //---------------------------------------------------\n    CS_FORWARDDECLARE_CLASS(WebView);\n}\n\n#endif\n"
  },
  {
    "path": "Tools/Scripts/AndroidApplicationConfig.mk",
    "content": "#\n#  AndroidApplicationConfig.mk\n#  ChilliSource\n#  Created by Ian Copland on 19/06/2014.\n#\n#  The MIT License (MIT)\n#\n#  Copyright (c) 2014 Tag Games Limited\n#\n#  Permission is hereby granted, free of charge, to any person obtaining a copy\n#  of this software and associated documentation files (the \"Software\"), to deal\n#  in the Software without restriction, including without limitation the rights\n#  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n#  copies of the Software, and to permit persons to whom the Software is\n#  furnished to do so, subject to the following conditions:\n#\n#  The above copyright notice and this permission notice shall be included in\n#  all copies or substantial portions of the Software.\n#\n#  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n#  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n#  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n#  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n#  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n#  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n#  THE SOFTWARE.\n#\n\nCS_NDK_TOOLCHAIN_VERSION := 4.9\nCS_APP_STL := gnustl_static\nCS_LOCAL_CPP_FEATURES := exceptions rtti\nCS_APP_PLATFORM = android-9\n"
  },
  {
    "path": "Tools/Scripts/AndroidBuildConfig.mk",
    "content": "#\n#  AndroidBuildConfig.mk\n#  ChilliSource\n#  Created by Ian Copland on 12/03/2015.\n#\n#  The MIT License (MIT)\n#\n#  Copyright (c) 2015 Tag Games Limited\n#\n#  Permission is hereby granted, free of charge, to any person obtaining a copy\n#  of this software and associated documentation files (the \"Software\"), to deal\n#  in the Software without restriction, including without limitation the rights\n#  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n#  copies of the Software, and to permit persons to whom the Software is\n#  furnished to do so, subject to the following conditions:\n#\n#  The above copyright notice and this permission notice shall be included in\n#  all copies or substantial portions of the Software.\n#\n#  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n#  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n#  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n#  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n#  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n#  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n#  THE SOFTWARE.\n\n#------------------------------------------------------------------------------\n# This provides all of the standard build settings for a ChilliSource project.\n# This shouldn't be included directly in most cases, AndroidBuildInitialise.mk \n# should be included instead.\n#\n# CS_PROJECT_ROOT must be set to the relative path to the root of the project\n# prior to calling this.\n#\n# @author Ian Copland\n#------------------------------------------------------------------------------\n\nLOCAL_PATH = .\n\n#store the location of the Get Files script\nCS_SCRIPT_GETFILESWITHEXTENSIONS := $(CS_PROJECT_ROOT)/ChilliSource/Tools/Scripts/get_file_paths_with_extensions.py\n\n#setup the module names.\nCS_MODULENAME_CHILLISOURCE := ChilliSource-prebuilt\nCS_MODULENAME_CSBASE := CSBase-prebuilt\nCS_MODULENAME_CK := ck-prebuilt\nCS_MODULENAME_APPLICATION := Application\n\n#debug or release specific build flags.\nifeq ($(NDK_DEBUG),1)\nCS_CXXFLAGS_TARGET := -g -DDEBUG -DCS_ENABLE_DEBUG -DCS_LOGLEVEL_VERBOSE\nelse\nCS_CXXFLAGS_TARGET := -O3 -DNDEBUG -DCS_LOGLEVEL_WARNING\nendif\n\n#add in the appropriate android extensions\nifeq ($(CS_FLAVOUR_SKU), googleplay)\nCS_CXXFLAGS_TARGET += -DCS_ANDROIDFLAVOUR_GOOGLEPLAY\nelse ifeq ($(CS_FLAVOUR_SKU), amazon)\nCS_CXXFLAGS_TARGET += -DCS_ANDROIDFLAVOUR_AMAZON\nendif\n\n#setup warnings\nCS_WARNINGS := -Wfatal-errors -Wchar-subscripts -Wcomment -Wnonnull -Winit-self -Wmissing-braces -Wmissing-include-dirs -Wparentheses -Wsequence-point -Wreturn-type -Wswitch -Wunused-function -Wunused -Wuninitialized -Wno-reorder\n\n#setup build settings\nCS_CXXFLAGS := -fsigned-char -std=c++11 -pthread -fexceptions -frtti -DCS_TARGETPLATFORM_ANDROID $(CS_WARNINGS) $(CS_CXXFLAGS_TARGET)\nCS_STATIC_LIBRARIES := $(CS_MODULENAME_CSBASE) $(CS_MODULENAME_CK) $(CS_MODULENAME_CHILLISOURCE) cpufeatures\nCS_LDLIBS := -lz -llog -lGLESv2 -lEGL\nCS_C_INCLUDES := $(CS_PROJECT_ROOT)/ChilliSource/Source/ $(CS_PROJECT_ROOT)/ChilliSource/Libraries/Core/Android/Headers/ $(CS_PROJECT_ROOT)/ChilliSource/Libraries/CricketAudio/Android/Headers/\n"
  },
  {
    "path": "Tools/Scripts/AndroidBuildInitialise.mk",
    "content": "#\n#  AndroidBuildInitialise.mk\n#  ChilliSource\n#  Created by Ian Copland on 12/03/2015.\n#\n#  The MIT License (MIT)\n#\n#  Copyright (c) 2015 Tag Games Limited\n#\n#  Permission is hereby granted, free of charge, to any person obtaining a copy\n#  of this software and associated documentation files (the \"Software\"), to deal\n#  in the Software without restriction, including without limitation the rights\n#  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n#  copies of the Software, and to permit persons to whom the Software is\n#  furnished to do so, subject to the following conditions:\n#\n#  The above copyright notice and this permission notice shall be included in\n#  all copies or substantial portions of the Software.\n#\n#  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n#  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n#  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n#  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n#  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n#  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n#  THE SOFTWARE.\n#\n\n#------------------------------------------------------------------------------\n# This copies the required static libraries to the currently built project. \n# The android build settings are also included, so this is the only thing that\n# a makefile building a ChilliSource shared library will need to include. \n# \n# Prior to including this, CS_PROJECT_ROOT must be set to the relative path to\n# the root of the project, i.e, the directory ChilliSource is located in.\n#\n# @author Ian Copland\n#------------------------------------------------------------------------------\n\ninclude $(call my-dir)/AndroidBuildConfig.mk\n\nifndef CS_CLEAN\n\n#copy pre-built static libraries\ninclude $(CLEAR_VARS)\nLOCAL_MODULE := $(CS_MODULENAME_CSBASE)\nLOCAL_SRC_FILES := $(CS_PROJECT_ROOT)/ChilliSource/Libraries/Core/Android/Libs/$(TARGET_ARCH_ABI)/libCSBase.a\ninclude $(PREBUILT_STATIC_LIBRARY)\n\ninclude $(CLEAR_VARS)\nLOCAL_MODULE := $(CS_MODULENAME_CK)\nLOCAL_SRC_FILES := $(CS_PROJECT_ROOT)/ChilliSource/Libraries/CricketAudio/Android/Libs/$(TARGET_ARCH_ABI)/libck.a\ninclude $(PREBUILT_STATIC_LIBRARY)\n\ninclude $(CLEAR_VARS)\nLOCAL_MODULE := $(CS_MODULENAME_CHILLISOURCE)\nLOCAL_SRC_FILES := $(CS_PROJECT_ROOT)/ChilliSource/Projects/Android/chillisource/src/main/libs/$(TARGET_ARCH_ABI)/libChilliSource.a\ninclude $(PREBUILT_STATIC_LIBRARY)\n\nendif\n\n"
  },
  {
    "path": "Tools/Scripts/AndroidManifestTemplateAmazon.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n\n<!--  \nAndroidManifestTemplateAmazon.xml\nChilliSource\nCreated by Ian Copland on 21/07/2015.\n\nThe MIT License (MIT)\n\nCopyright (c) 2015 Tag Games Limited\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE. \n-->\n\n<!-- NOTE: This is auto generated, do not change! -->\n\n<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\" package=\"[[PACKAGE]]\" android:installLocation=\"preferExternal\" >\n\n    <uses-feature android:glEsVersion=\"0x00020000\" android:required=\"true\" />\n    <uses-feature android:name=\"android.hardware.touchscreen.multitouch\" android:required=\"true\" />\n\n    <!-- permissions -->\n\t[[PERMISSIONS]]\n\n    <!-- Manifest extra information -->\n    [[MANIFESTEXTRA]]\n\n    <application android:icon=\"@drawable/ic_launcher\" android:label=\"@string/app_name\"  android:allowBackup=\"false\" [[MULTIDEXENABLED]] >\n        \n        <!-- provide access to the package name, prior to it being replaced by the applicationId -->\n        <meta-data android:name=\"packageName\" android:value=\"[[PACKAGE]]\" />\n        \n        <!-- ChilliSource main -->\n        <activity android:name=\"com.chilliworks.chillisource.core.CSActivity\"\n            android:screenOrientation=\"[[ORIENTATION]]\"\n            android:label=\"@string/app_name\"\n            android:launchMode=\"singleTask\"\n            android:configChanges=\"orientation|mcc|mnc|locale|touchscreen|navigation|fontScale|screenSize\">\n\n            <intent-filter>\n                <action android:name=\"android.intent.action.MAIN\" />\n                <category android:name=\"android.intent.category.LAUNCHER\" />\n            </intent-filter>\n\n        </activity>\n\n        <!-- ChilliSource video player -->\n        <activity android:name=\"com.chilliworks.chillisource.video.VideoPlayerActivity\" \n            android:screenOrientation=\"[[ORIENTATION]]\" \n            android:label=\"@string/app_name\"\n            android:windowSoftInputMode=\"stateHidden\"\n            android:configChanges=\"keyboard|keyboardHidden|orientation|mcc|mnc|locale|touchscreen|navigation|fontScale|screenSize\" />\n\n        <!-- ChilliSource local notifications -->\n        <receiver android:exported=\"false\" android:name=\"com.chilliworks.chillisource.core.LocalNotificationReceiver\">\n            <intent-filter>\n                <action android:name=\"com.chilliworks.chillisource.core.ALARM_NOTIFICATION_INTENT\" />\n            </intent-filter>\n        </receiver>\n        \n        <!-- Google Play services -->\n        <meta-data android:name=\"com.google.android.gms.version\" android:value=\"@integer/google_play_services_version\" />\n\n        <!-- Amazon iap -->\n        <receiver android:name=\"com.amazon.inapp.purchasing.ResponseReceiver\">\n            <intent-filter>\n                <action android:name=\"com.amazon.inapp.purchasing.NOTIFY\" android:permission=\"com.amazon.inapp.purchasing.Permission.NOTIFY\" />\n            </intent-filter>\n        </receiver>\n\n        <!-- Application extra information -->\n        [[APPLICATIONEXTRA]]\n\n    </application>\n\n</manifest>\n"
  },
  {
    "path": "Tools/Scripts/AndroidManifestTemplateGooglePlay.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n\n<!--  \nAndroidManifestTemplateGooglePlay.xml\nChilliSource\nCreated by Ian Copland on 21/07/2015.\n\nThe MIT License (MIT)\n\nCopyright (c) 2015 Tag Games Limited\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE. \n-->\n\n<!-- NOTE: This is auto generated, do not change! -->\n\n<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\" package=\"[[PACKAGE]]\" android:installLocation=\"preferExternal\" >\n\n    <uses-feature android:glEsVersion=\"0x00020000\" android:required=\"true\" />\n    <uses-feature android:name=\"android.hardware.touchscreen.multitouch\" android:required=\"true\" />\n\n    <!-- permissions -->\n    <permission android:name=\"${applicationId}.permission.C2D_MESSAGE\" android:protectionLevel=\"signature\" />\n    <uses-permission android:name=\"${applicationId}.permission.C2D_MESSAGE\" />\n\t<uses-permission android:name=\"com.google.android.c2dm.permission.RECEIVE\" />\n\t[[PERMISSIONS]]\n\n    <!-- Manifest extra information -->\n    [[MANIFESTEXTRA]]\n\n    <application android:icon=\"@drawable/ic_launcher\" android:label=\"@string/app_name\"  android:allowBackup=\"false\" [[MULTIDEXENABLED]]>\n        \n        <!-- provide access to the package name, prior to it being replaced by the applicationId -->\n        <meta-data android:name=\"packageName\" android:value=\"[[PACKAGE]]\" />\n\n        <!-- ChilliSource main -->\n        <activity android:name=\"com.chilliworks.chillisource.core.CSActivity\"\n            android:screenOrientation=\"[[ORIENTATION]]\"\n            android:label=\"@string/app_name\"\n            android:launchMode=\"singleTask\"\n            android:configChanges=\"orientation|mcc|mnc|locale|touchscreen|navigation|fontScale|screenSize\">\n\n            <intent-filter>\n                <action android:name=\"android.intent.action.MAIN\" />\n                <category android:name=\"android.intent.category.LAUNCHER\" />\n            </intent-filter>\n\n        </activity>\n\n        <!-- ChilliSource video player -->\n        <activity android:name=\"com.chilliworks.chillisource.video.VideoPlayerActivity\" \n            android:screenOrientation=\"[[ORIENTATION]]\" \n            android:label=\"@string/app_name\"\n            android:windowSoftInputMode=\"stateHidden\"\n            android:configChanges=\"keyboard|keyboardHidden|orientation|mcc|mnc|locale|touchscreen|navigation|fontScale|screenSize\" />\n\n        <!-- ChilliSource local notifications -->\n        <receiver android:exported=\"false\" android:name=\"com.chilliworks.chillisource.core.LocalNotificationReceiver\">\n            <intent-filter>\n                <action android:name=\"com.chilliworks.chillisource.core.ALARM_NOTIFICATION_INTENT\" />\n            </intent-filter>\n        </receiver>\n        \n        <!-- Google Play services -->\n        <meta-data android:name=\"com.google.android.gms.version\" android:value=\"@integer/google_play_services_version\" />\n\n        <!-- Google Play Expansion Downloader -->\n        <activity android:name=\"com.chilliworks.chillisource.networking.ApkExpansionDownloadActivity\"\n            android:screenOrientation=\"[[ORIENTATION]]\"\n            android:label=\"@string/app_name\"\n            android:configChanges=\"orientation|mcc|mnc|locale|touchscreen|navigation|fontScale|screenSize\">\n        </activity>\n\n        <service android:name=\"com.chilliworks.chillisource.networking.ApkExpansionDownloadService\" />\n        <receiver android:name=\"com.chilliworks.chillisource.networking.ApkExpansionDownloadAlarmReceiver\" />\n\n        <!-- Google Play apk expansion content provider -->\n        <provider android:name=\"com.chilliworks.chillisource.core.ApkExpansionContentProvider\" android:authorities=\"${applicationId}.apkexpansioncontentprovider\" android:enabled=\"true\" android:exported=\"false\" />\n\n        <!-- Google Play Apk Expansion Download View -->\n        <meta-data android:name=\"apkExpansionDownloadView\" android:value=\"[[APKEXPANSIONDOWNLOADVIEW]]\" />\n\n        <!-- Application extra information -->\n        [[APPLICATIONEXTRA]]\n\n    </application>\n\n</manifest>\n"
  },
  {
    "path": "Tools/Scripts/android-build-manifest.gradle",
    "content": "//\n//  android-build-manifest.gradle\n//  ChilliSource\n//  Created by Ian Copland on 26/06/2015.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2015 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\napply from: '../../../../ChilliSource/Tools/Scripts/android-execute-command.gradle'\n\n/**\n * Generates a new android manifest from the CSAndroidManifest.xml using the specified\n * android manifest template.\n *\n * @author Ian Copland\n * \n * @param in_templateFilePath - The path to the template relative to the root of the\n * project.\n */\ndef generateAndroidManifest(String in_templateFilePath)\n{\n    def absRootProjectDirectoryPath = file(\"../../../..\").absolutePath\n    def absAndroidProjectDirectoryPath = file(\"src/main\").absolutePath\n    def toolPath = absRootProjectDirectoryPath + \"/ChilliSource/Tools/AndroidManifestBuilder.jar\"\n    def templateFilePath = absRootProjectDirectoryPath + in_templateFilePath\n    def manifestFilePath = absAndroidProjectDirectoryPath + \"/AndroidManifest.xml\"\n    def csManifestFilePath = absAndroidProjectDirectoryPath + \"/CSAndroidManifest.xml\"\n\n    csExecuteCommand([ \"java\", \"-Djava.awt.headless=true\", \"-Xmx512m\", \"-jar\", toolPath, \"--input\", csManifestFilePath, \"--template\", templateFilePath, \"--output\", manifestFilePath ] as String[])\n}\n\next {\n    /**\n     * Generates the google play android manifest from the CSAndroidManifest.xml.\n     *\n     * @author Ian Copland\n     */\n    csGenerateGooglePlayAndroidManifest = { in_sky ->\n        generateAndroidManifest(\"/ChilliSource/Tools/Scripts/AndroidManifestTemplateGooglePlay.xml\");\n    }\n    /**\n     * Generates the amazon android manifest from the CSAndroidManifest.xml.\n     *\n     * @author Ian Copland\n     */\n    csGenerateAmazonAndroidManifest = { in_sky ->\n        generateAndroidManifest(\"/ChilliSource/Tools/Scripts/AndroidManifestTemplateAmazon.xml\");\n    }\n}\n"
  },
  {
    "path": "Tools/Scripts/android-build-ndk.gradle",
    "content": "//\n//  android-build-ndk.gradle\n//  ChilliSource\n//  Created by Ian Copland on 26/06/2015.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2015 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\napply from: '../../../../ChilliSource/Tools/Scripts/android-execute-command.gradle'\n\nimport org.apache.tools.ant.taskdefs.condition.Os\nimport java.util.zip.CRC32\nimport java.nio.file.Files\nimport java.nio.file.Path\nimport java.nio.file.Paths\n\n/**\n * Reads the local.properties file to get the location of the ndk-build script. This also takes\n * into account the OS - returning ndk-build.cmd on windows and ndk-build on other platforms.\n *\n * @author Ian Copland\n *\n * @return The path to ndk-build.\n */\ndef getNDKBuildScriptPath() {\n    String rootDir = project.rootDir\n    def localProperties = new File(rootDir, \"local.properties\")\n    if (localProperties.exists()) {\n        def properties = new Properties()\n        localProperties.withInputStream {\n            stream -> properties.load(stream)\n        }\n        def ndkDir = properties.getProperty('ndk.dir')\n        if (ndkDir == null) {\n            throw new GradleException(\"The ndk.dir property in local.propeties is not set\")\n        }\n        def ndkBuild = Os.isFamily(Os.FAMILY_WINDOWS) ? \"$ndkDir/ndk-build.cmd\" : \"$ndkDir/ndk-build\" as String\n        return ndkBuild\n\n    } else {\n        throw new GradleException(\"The local.properties file does not exist\")\n    }\n}\n/**\n * @author Ian Copland\n *\n * @return The directory all object files will be built to. On windows this will be a directory\n * located at C:/.CSTemp/<project hash> to shorten the path to keep the build under the windows\n * path length limit.  On other platforms this will be the <Project>/src/main/obj directory.\n */\ndef getBuildDirectory() {\n    if (Os.isFamily(Os.FAMILY_WINDOWS) == true) {\n        String projPath = file('.').absolutePath\n        def crc = new CRC32()\n        crc.update(projPath.getBytes())\n        return System.getenv(\"SystemDrive\") + \"/.CSTemp/\" + crc.getValue()\n    } else {\n        return file('src/main/obj').absolutePath\n    }\n}\n\next {\n    /**\n     * Builds native source for the given SKU, ABI and debug mode.\n     *\n     * @author Ian Copland\n     *\n     * @param in_sku - The SKU which the source should be built for.\n     * @param in_abi - The ABI thes source should be built for.\n     * @param in_debug - Whether or not the build should have debug symbols.\n     */\n    csNdkBuild = { in_sku, in_abi, in_debug ->\n        def lowerSKU = in_sku.toLowerCase()\n        def jniPath = file('src/main/jni').absolutePath\n        ArrayList<String> commands\n        if (in_debug == true) {\n            commands = [ getNDKBuildScriptPath(), \"-C\", jniPath, \"-j4\", \"CS_FLAVOUR_SKU=$lowerSKU\", \"APP_ABI=$in_abi\", \"NDK_DEBUG=1\" ] as ArrayList<String>\n        }\n        else {\n            commands = [ getNDKBuildScriptPath(), \"-C\", jniPath, \"-j4\", \"CS_FLAVOUR_SKU=$lowerSKU\", \"APP_ABI=$in_abi\" ] as ArrayList<String>\n        }\n\n        if (Os.isFamily(Os.FAMILY_WINDOWS) == true) {\n            def buildDir = getBuildDirectory()\n            commands.add(\"NDK_OUT=\" + buildDir)\n            Files.createDirectories(Paths.get(buildDir))\n        }\n\n        csExecuteCommand(commands as String[])\n    }\n    /**\n     * Builds native source for the given sku, abi and debug mode and also copies the static library\n     * to the output directory.\n     *\n     * @author Ian Copland\n     *\n     * @param in_sku - The SKU which the source should be built for.\n     * @param in_abi - The ABI thes source should be built for.\n     * @param in_debug - Whether or not the build should have debug symbols.\n     * @param in_libName - The name of the static library that should be copied to the output\n     * directory.\n     */\n    csNdkBuildStaticLib = { in_sku, in_abi, in_debug, in_libName ->\n        csNdkBuild(in_sku, in_abi, in_debug)\n\n        def inputDir = getBuildDirectory() + \"/local/\" + in_abi\n        def outputDir = file('src/main/libs/' + in_abi).absolutePath\n        def fileName = \"lib\" + in_libName + \".a\"\n\n        Files.createDirectories(Paths.get(outputDir))\n\n        def outputFilePath = Paths.get(outputDir + \"/\" + fileName)\n        if (Files.exists(outputFilePath)) {\n            Files.delete(outputFilePath)\n        }\n\n        Files.copy(Paths.get(inputDir + \"/\" + fileName), outputFilePath)\n    }\n    /**\n     * Cleans native source for all abis, skus and both debug and release.\n     *\n     * @author Ian Copland\n     */\n    csNdkBuildClean = { ->\n        def jniPath = file('src/main/jni').absolutePath\n\n        def commands = [ getNDKBuildScriptPath(), \"-C\", jniPath, \"clean\", \"APP_ABI=armeabi,armeabi-v7a,arm64-v8a,x86,x86_64\", \"CS_CLEAN=1\" ]\n        if (Os.isFamily(Os.FAMILY_WINDOWS) == true) {\n            def buildDir = getBuildDirectory()\n            Files.createDirectories(Paths.get(buildDir))\n            commands.add(\"NDK_OUT=\" + buildDir)\n        }\n        \n        println \"Clean release:\"\n        csExecuteCommand(commands as String[])\n\n        println \"Clean debug:\"\n        commands.add(\"NDK_DEBUG=1\")\n        csExecuteCommand(commands as String[])\n    }\n    /**\n     * Performs a clean build of all native source and removes the built static libraries from the libs\n     * directory.\n     *\n     * @author Ian Copland\n     */\n    csNdkBuildCleanStaticLib = { in_libName ->\n        csNdkBuildClean()\n        \n        def abis = [ \"armeabi\", \"armeabi-v7a\", \"arm64-v8a\", \"x86\", \"x86_64\" ]\n        for (def abi : abis)\n        {\n            def filePath = Paths.get(file('src/main/libs/' + abi).absolutePath + \"/lib\" + in_libName + \".a\")\n            if (Files.exists(filePath)) {\n                Files.delete(filePath)\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "Tools/Scripts/android-build-resources.gradle",
    "content": "//\n//  android-build-resources.gradle\n//  ChilliSource\n//  Created by Ian Copland on 26/06/2015.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2015 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\napply from: '../../../../ChilliSource/Tools/Scripts/android-execute-command.gradle'\n\nimport java.io.*\nimport java.nio.file.*\nimport java.nio.file.attribute.*\n\ndef g_assetsDirectory = \"src/main/assets\"\ndef g_rng = new Random()\n\n/**\n * @author Ian Copland\n * \n * @param in_fileName - The file name that should be checked.\n * @param in_ignoreFilesWith - Any files that contain any of the values in this\n * list should be ignored\n * @param in_forceIncludeFilesWith - Any files that contain any of the values in\n * this this should be included, regardless of whether or not they contain values\n * from the ignore list.\n * \n * @return Whether or not the file should be included, based of the file name\n */\ndef canInclude(String in_fileName, String[] in_ignoreFilesWith, String[] in_forceIncludeFilesWith) {\n    for (String forceInclude : in_forceIncludeFilesWith) {\n        if (in_fileName.contains(forceInclude)) {\n            return true\n        }\n    }\n    for (String ignore : in_ignoreFilesWith) {\n        if (in_fileName.contains(ignore)) {\n            return false\n        }\n    }\n    return true\n}\n/**\n * copies the source directory to the destination directory. File names which contain\n * entries in the ignore list will not be copied. File names which contain entries in\n * the force include list will be copied, regardless of whether or not they contained\n * entries in the ignore list.\n * \n * @author Ian Copland\n *\n * @param in_sourceDirectoryPath - The source directory path.\n * @param in_destDirectoryPath - The destination directory path.\n * @param in_ignoreFilesWith - The ignore list.\n * @param in_forceIncludeFilesWith - The force include list.\n */\ndef copyDirectory(String in_sourceDirectoryPath, String in_destDirectoryPath, String[] in_ignoreFilesWith, String[] in_forceIncludeFilesWith) {\n    File destinationDir = new File(in_destDirectoryPath)\n    destinationDir.mkdir()\n    \n    File sourceDir = new File(in_sourceDirectoryPath)\n\n    def directoryContents = sourceDir.list()\n    for (String directoryItem : directoryContents) {\n\n        File entry = new File(sourceDir, directoryItem)\n        if (entry.isDirectory()) {\n            def sourceSubDir = Paths.get(in_sourceDirectoryPath, directoryItem).toString()\n            def destSubDir = Paths.get(in_destDirectoryPath, directoryItem).toString()\n            copyDirectory(sourceSubDir, destSubDir, in_ignoreFilesWith, in_forceIncludeFilesWith)\n\n        } else if (canInclude(directoryItem, in_ignoreFilesWith, in_forceIncludeFilesWith) == true) {\n            def sourceFilePath = Paths.get(in_sourceDirectoryPath, directoryItem)\n            def destFilePath = Paths.get(in_destDirectoryPath, directoryItem)\n            Files.copy(sourceFilePath, destFilePath)\n        }\n    }\n}\n/**\n * Copy the resource directories (AppResources/ and CSResources) to the given directory. \n * Files which contain other platform tags (i.e '.ios' or '.windows') will be not be copied\n * unless the android tag is also declared.\n *\n * @author Ian Copland\n *\n * @param in_directoryPath - The directory to copy the resource directories to.\n */\ndef copyResourcesToDirectory(String in_directoryPath) {\n    def excludes = [ \".ios\", \".windows\", \".rpi\", \".DS_Store\", \"Thumbs.db\" ] as String[]\n    def includes = [ \".android\" ] as String[]\n\n    File directory = new File(in_directoryPath)\n    directory.mkdir()\n\n    String appSourceDirectory = file('../../../../Content/AppResources').absolutePath\n    String appDestDirectory = in_directoryPath + \"/AppResources\"\n    copyDirectory(appSourceDirectory, appDestDirectory, excludes, includes) \n\n    String csSourceDirectory = file('../../../../ChilliSource/CSResources').absolutePath\n    String csDestDirectory = in_directoryPath + \"/CSResources\"\n    copyDirectory(csSourceDirectory, csDestDirectory, excludes, includes)\n}\n/**\n * Premultiples the Alpha for all PNGs in the given directory, recursively.\n *\n * @author Ian Copland\n *\n * @param in_directoryPath - The directory to operate on.\n */\ndef premultiplyPngsInDirectory(String in_directoryPath) {\n    def jarPath = file(\"../../../../ChilliSource/Tools/PNGAlphaPremultiplier.jar\").absolutePath\n\n    def directory = new File(in_directoryPath)\n    def directoryContents = directory.list()\n    for (def directoryItemName : directoryContents) {\n        def directoryItem = new File(directory, directoryItemName)\n\n        if (directoryItem.isDirectory()) {\n            premultiplyPngsInDirectory(directoryItem.getAbsolutePath())\n        }\n        else if (directoryItemName.toLowerCase().endsWith(\".png\")) {\n            def fullPath = directoryItem.getAbsolutePath()\n            csExecuteCommand([ \"java\", \"-Djava.awt.headless=true\", \"-Xmx512m\", \"-jar\", jarPath, \"--input\", fullPath, \"--output\", fullPath ] as String[])\n        }\n    }\n}\n/**\n * Creates the Apk Expansion OBB zip file from the given directory.\n *\n * @author Ian Copland\n *\n * @param in_directoryPath - The directory to create the OBB from.\n * @param in_applicationId - The application Id that will be used in the OBB file name.\n * @param in_versionCode - The version code that will be used in the OBB file name.\n */\ndef createApkExpansionFromDirectory(String in_directoryPath, String in_applicationId, int in_versionCode) {\n    def jarPath = file(\"../../../../ChilliSource/Tools/Zip.jar\").absolutePath\n    def uncompressedExtensions = \".jpg, .jpeg, .png, .gif, .wav, .mp2, .mp3, .ogg, .aac, .mpg, .mpeg, .mid, .midi,\" +\n        \" .smf, .jet, .rtttl, .imy, .xmf, .mp4, .m4a, .m4v, .3gp, .3gpp, .3g2, .3gpp2, .amr, .awb, .wma, .wmv, .cks\"\n    \n    File directory = new File(file(\"build/outputs/obb\").absolutePath as String)\n    if (!directory.exists()) {\n        directory.mkdirs()\n    }\n\n    def fileName = \"main.\" + in_versionCode + \".\" + in_applicationId + \".obb\"\n    String filePath = directory.getAbsolutePath() + \"/\" + fileName\n\n    File zipFile = new File(filePath)\n    if (zipFile.exists()) {\n        zipFile.delete()\n    }\n\n    csExecuteCommand([ \"java\", \"-Djava.awt.headless=true\", \"-Xmx512m\", \"-jar\", jarPath, \"--input\", in_directoryPath, \"--output\", filePath, \n        \"--uncompressedext\", uncompressedExtensions ] as String[])\n\n    def obbFile = new File(filePath)\n    return obbFile.length()\n}\n/**\n * Deletes the given directory. This does nothing if the directory doesn't exist.\n *\n * @author Ian Copland\n *\n * @param in_directoryPath - The directory to delete.\n */\ndef deleteDirectory(String in_directoryPath) {\n    File directoryFile = new File(in_directoryPath)\n    if (directoryFile.exists() && directoryFile.isDirectory())\n    {\n        Path directoryPath = Paths.get(in_directoryPath)\n        Files.walkFileTree(directoryPath, new SimpleFileVisitor<Path>() {\n           @Override public FileVisitResult visitFile(Path in_file, BasicFileAttributes in_attrubutes) throws IOException {\n               Files.delete(in_file)\n               return FileVisitResult.CONTINUE\n           }\n           @Override public FileVisitResult postVisitDirectory(Path in_dir, IOException in_exception) throws IOException {\n               Files.delete(in_dir)\n               return FileVisitResult.CONTINUE\n           }\n       })\n    }\n}\n/**\n * Writes the ApkExpansion.config to the assets/ directory. Also removed other\n * resources from the directory to remove residual assets from previous builds.\n *\n * @author Ian Copland\n *\n * @param in_assetsDirectoryPath - The assets directory\n * @param in_versionCode - The version code used in the OBB file name.\n * @param in_obbSize - The file size of the OBB.\n */\ndef writeApkExpansionConfig(String in_assetsDirectoryPath, int in_versionCode, long in_obbSize) {\n    deleteDirectory(in_assetsDirectoryPath)\n    def directory = new File(in_assetsDirectoryPath)\n    directory.mkdir();\n\n    FileWriter fileWriter = null\n    try {\n        fileWriter = new FileWriter(new File(directory, \"ApkExpansion.config\"))\n        fileWriter.write(\"{ \\\"VersionCode\\\": \" + in_versionCode + \", \\\"FileSize\\\": \" + in_obbSize + \" }\" as String)\n    }\n    catch(Exception e) {\n        throw GradleException(\"Could create ApkExpansion.config.\", e)\n    }\n    finally {\n        if (fileWriter != null){\n            fileWriter.close()\n        }\n    }\n}\n\next {\n    /**\n     * Generates the APK Expansion zip file from the resource directories (AppResources and\n     * and CSResources). Files which contain other platform tags (i.e '.ios' or '.windows') \n     * will be not be included unless the android tag is also declared.\n     *\n     * The 'assets/' directory will also be deleted to ensure resources aren't included in\n     * both the Apk and Expansion file.\n     *\n     * @author Ian Copland\n     *\n     * @param in_applicationId - The application Id that will be used in the OBB file name.\n     * @param in_versionCode - The version code that will be used in the OBB file name.\n     */\n    csGenerateApkExpansion = { in_applicationId, in_versionCode ->\n        def tempDirectoryPath = file(\"build/_resources-\" + g_rng.nextLong()).absolutePath\n        copyResourcesToDirectory(tempDirectoryPath)\n        premultiplyPngsInDirectory(tempDirectoryPath)\n        def obbSize = createApkExpansionFromDirectory(tempDirectoryPath, in_applicationId, in_versionCode)\n        deleteDirectory(tempDirectoryPath)\n\n        def assetsDirectoryPath = file(g_assetsDirectory).absolutePath\n        writeApkExpansionConfig(assetsDirectoryPath, in_versionCode, obbSize)\n    }\n    /**\n     * Generates the APK assets directory from the resource directories (AppResources and\n     * and CSResources). Files which contain other platform tags (i.e '.ios' or '.windows') \n     * will be not be included unless the android tag is also declared.\n     *\n     * @author Ian Copland\n     */\n    csGenerateApkAssets = { ->\n        def assetsDirectoryPath = file(g_assetsDirectory).absolutePath\n        deleteDirectory(assetsDirectoryPath)\n        copyResourcesToDirectory(assetsDirectoryPath)\n        premultiplyPngsInDirectory(assetsDirectoryPath)\n    }\n}\n"
  },
  {
    "path": "Tools/Scripts/android-build-variant-utils.gradle",
    "content": "//\n//  android-build-variant-utils.gradle\n//  ChilliSource\n//  Created by Ian Copland on 21/07/2015.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2015 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\next {\n    /**\n     * @author Ian Copland\n     *\n     * @param in_abi - The abi\n     *\n     * @return The shorter form of the abi name.\n     */\n    csGetAbiShortForm = { String in_abi ->\n        if (in_abi == 'arm64-v8a') {\n            return \"arm64\"\n        } else if (in_abi == 'armeabi-v7a') {\n            return 'armv7'\n        } else if (in_abi == 'armeabi') {\n            return \"arm\"\n        } else if (in_abi == 'x86_64') {\n            return \"x64\"\n        } else if (in_abi == 'x86') {\n            return \"x86\"\n        } else {\n            throw GradleException(\"ABI '$in_abi' does not exist.\")\n        }\n    }\n    /**\n     * @author Ian Copland\n     *\n     * @param in_string - The string\n     *\n     * @return The given string with the first letter in the string converted to upper case.\n     */\n    csUpperCaseFirstLetter = { String in_string ->\n        if (in_string.length() > 0) {\n            String start = in_string.substring(0, 1)\n            start = start.toUpperCase();\n            return start + in_string.substring(1)\n        }\n        return in_string\n    }\n    /**\n     * @author Ian Copland\n     *\n     * @param in_sku - The name of the SKU.\n     * @param in_abi - The name of the ABI.\n     * @param in_debug - Whether or not it's a debug build.\n     *\n     * @return Each of the params combined into a single variant name. The first letter of each will be\n     * made upper case\n     */\n   csGenerateVariantName = { String in_sku, String in_abi, boolean in_debug ->\n        def shortAbiName = csGetAbiShortForm(in_abi)\n        def buildType = (in_debug == true) ? \"debug\" : \"release\"\n        return csUpperCaseFirstLetter(in_sku) + csUpperCaseFirstLetter(shortAbiName) + csUpperCaseFirstLetter(buildType)\n    }\n    /**\n     * @author Ian Copland\n     *\n     * @param in_taskName - The name of the task.\n     *\n     * @return Whether or not the given task name follows the convention set for Task tasks.\n     */\n    csIsTestFromTaskName = { String in_taskName ->\n        def lowerTaskName = in_taskName.toLowerCase()\n        if (lowerTaskName.contains('unittest') || lowerTaskName.contains('androidtest')) {\n            return true\n        }\n        return false\n    }\n    /**\n     * @author Ian Copland\n     *\n     * @param in_taskName - The name of the task.\n     *\n     * @return Whether or not the given task name follows the convention set for debug tasks.\n     */\n    csIsDebugFromTaskName = { String in_taskName ->\n        def lowerTaskName = in_taskName.toLowerCase()\n        if (lowerTaskName.contains('debug')) {\n            return true\n        } else if (lowerTaskName.contains('release')){\n            return false\n        } else {\n            throw GradleException(\"Task '$taskName' does not specify release or debug.\")\n        }\n    }\n    /**\n     * @author Ian Copland\n     *\n     * @param in_taskName - The name of the task.\n     *\n     * @return The name of the ABI the task relates to, based on the naming convention.\n     */\n    csGetAbiFromTaskName = { String in_taskName ->\n        def lowerTaskName = in_taskName.toLowerCase()\n        if (lowerTaskName.contains('arm64')) {\n            return \"arm64-v8a\"\n        } else if (lowerTaskName.contains('armv7')) {\n            return \"armeabi-v7a\"\n        } else if (lowerTaskName.contains('arm')){\n            return \"armeabi\"\n        } else if (lowerTaskName.contains('x64')){\n            return \"x86_64\"\n        } else if (lowerTaskName.contains('x86')){\n            return \"x86\"\n        } else {\n            throw GradleException(\"Task '$taskName' does not specify an abi.\")\n        }\n    }\n    /**\n     * @author Ian Copland\n     *\n     * @param in_taskName - The name of the task.\n     *\n     * @return The name of the SKU the task relates to, based on the naming convention.\n     */\n    csGetSkuFromTaskName = { String in_taskName ->\n        def lowerTaskName = in_taskName.toLowerCase()\n        if (lowerTaskName.contains('googleplay')) {\n            return \"googlePlay\"\n        } else if (lowerTaskName.contains('amazon')){\n            return \"amazon\"\n        } else {\n            throw GradleException(\"Task '$taskName' does not specify a sku.\")\n        }\n    }\n    /**\n     * @author Ian Copland\n     *\n     * @param in_sku - The SKU name.\n     *\n     * @return Whether or not the given SKU is Google Play.\n     */\n    csIsGooglePlaySku = { String in_sku ->\n        return (in_sku == 'googlePlay')\n    }\n    /**\n     * @author Ian Copland\n     *\n     * @param in_sku - The SKU name.\n     *\n     * @return Whether or not the given SKU is Amazon.\n     */\n    csIsAmazonSku = { String in_sku ->\n        return (in_sku == 'amazon')\n    }\n}"
  },
  {
    "path": "Tools/Scripts/android-build.gradle",
    "content": "//\n//  android-build.gradle\n//  ChilliSource\n//  Created by Ian Copland on 13/03/2015.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2015 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\napply from: '../../../../ChilliSource/Tools/Scripts/android-build-manifest.gradle'\napply from: '../../../../ChilliSource/Tools/Scripts/android-build-ndk.gradle'\napply from: '../../../../ChilliSource/Tools/Scripts/android-build-variant-utils.gradle'\napply from: '../../../../ChilliSource/Tools/Scripts/android-build-resources.gradle'\napply from: '../../../../ChilliSource/Tools/Scripts/android-push-apk-expansion.gradle'\n\nimport com.sun.tools.classfile.Dependency\n\n/**\n * Adds the static library clean ndk task to the given task as a dependency.\n *\n * @author Ian Copland\n *\n * @param in_task - The task to add the dependency to.\n * @param in_libName - The name of the static library.\n */\ndef addCleanNdkStaticLibTask(def in_task, String in_libName) {\n    def cleanTask = task(\"csCleanNdk\", overwrite: true) << {\n        csNdkBuildCleanStaticLib(in_libName)\n    }\n    in_task.dependsOn(cleanTask)\n}\n/**\n * Adds the static library compile ndk task to the given task as a dependency.\n *\n * @author Ian Copland\n *\n * @param in_task - The task to add the dependency to.\n * @param in_libName - The name of the static library.\n */\ndef addCompileNdkStaticLibTask(def in_task, String in_libName) {\n    def sku = csGetSkuFromTaskName(in_task.name)\n    def abi = csGetAbiFromTaskName(in_task.name)\n    def debug = csIsDebugFromTaskName(in_task.name)\n    def variantName = csGenerateVariantName(sku, abi, debug)\n\n    def csCompileTask = task(\"csCompileNdk$variantName\", overwrite: true) << {\n        csNdkBuildStaticLib(sku, abi, debug, in_libName)\n    }\n\n    //This is a hack to ensure ChilliSource is only built for the ABI/SKU/config that the\n    //application is being built for. This has the draw-back that ChilliSource can no longer\n    //be built on its own, so hopefully a better solution presents itself in the future.\n    csCompileTask.onlyIf {\n        def taskGraph = gradle.taskGraph\n        for (def aTask : taskGraph.getAllTasks()) {\n            if (aTask.project.name.equals(\"app\") && aTask.name.equals(csCompileTask.name)) {\n                return true\n            }\n        }\n        return false\n    }\n    in_task.dependsOn(csCompileTask)\n}\n/**\n * Adds the application ndk clean task to the given task as a dependency.\n *\n * @author Ian Copland\n *\n * @param in_task - The task to add the dependency to.\n */\ndef addCleanNdkTask(def in_task) {\n    def cleanTask = task(\"csCleanNdk\", overwrite: true) << {\n        csNdkBuildClean()\n    }\n    in_task.dependsOn(cleanTask)\n}\n/**\n * Adds the application generate android manifest task to the given task as a dependency.\n *\n * @author Ian Copland\n *\n * @param in_task - The task to add the dependency to.\n */\ndef addGenerateAndroidManifestTask(def in_task) {\n    def sku = csGetSkuFromTaskName(in_task.name);\n    if (csIsGooglePlaySku(sku)) {\n        task \"csGenerateGooglePlayAndroidManifest\" (overwrite: true) << {\n            csGenerateGooglePlayAndroidManifest()\n        }\n        in_task.dependsOn(\"csGenerateGooglePlayAndroidManifest\")\n        \n    } else if (csIsAmazonSku(sku)) {\n        task \"csGenerateAmazonAndroidManifest\" (overwrite: true) << {\n            csGenerateAmazonAndroidManifest()\n        }\n        in_task.dependsOn(\"csGenerateAmazonAndroidManifest\")\n        \n    } else { \n        throw new GradleException(\"Invalid sku for task '${in_task.name}'\") as Throwable\n    }\n    \n}\n/**\n * Adds the application ndk compile task to the given task as a dependency.\n *\n * @author Ian Copland\n *\n * @param in_task - The task to add the dependency to.\n */\ndef addCompileNdkTask(def in_task) {\n    def sku = csGetSkuFromTaskName(in_task.name)\n    def abi = csGetAbiFromTaskName(in_task.name)\n    def debug = csIsDebugFromTaskName(in_task.name)\n    def variantName = csGenerateVariantName(sku, abi, debug)\n\n    task \"csCompileNdk$variantName\" (dependsOn: \":chillisource:csCompileNdk$variantName\", overwrite: true) << {\n        csNdkBuild(sku, abi, debug)\n    }\n\n    in_task.dependsOn(\"csCompileNdk$variantName\")\n}\n/**\n * Adds the application generate resources task to the given task as a dependency. This only applies\n * to Amazon builds.\n *\n * @author Ian Copland\n *\n * @param in_task - The task to add the dependency to.\n */\ndef addGenerateResourcesTask(def in_task) {\n    def sku = csGetSkuFromTaskName(in_task.name)\n    if (csIsAmazonSku(sku)) {\n        task \"csGenerateApkResources\" (dependsOn: \"csGenerateAmazonAndroidManifest\", overwrite: true) << {\n            csGenerateApkAssets()\n        }\n        in_task.dependsOn(\"csGenerateApkResources\")\n    }\n}\n/**\n * Adds the task for the getting the applicationId and versionCode to each of the check manifest\n * tasks as a depedency.\n *\n * @author Ian Copland\n *\n * @param in_defaultConfig - The default configuration\n * @param in_applicationVariants - The list of application variants\n */\ndef addGetInfoTasks(def in_defaultConfig, def in_applicationVariants) {\n    in_applicationVariants.all() { in_variant ->\n        in_variant.outputs.each { in_output ->\n            def getInfoTask = task \"csGetVariantInfo${csUpperCaseFirstLetter(in_output.name)}\"() << {\n                g_applicationId = in_defaultConfig.applicationId\n\n                for (def i = 0; i < in_variant.productFlavors.size(); ++i)\n                {\n                    def flavourApplicationId = in_variant.productFlavors.get(i).applicationId\n                    if (flavourApplicationId != null && flavourApplicationId.length() > 0) {\n                        g_applicationId = flavourApplicationId\n                    }\n                }\n\n                def suffix = in_variant.buildType.applicationIdSuffix\n                if (suffix != null && suffix.length() > 0) {\n                    g_applicationId += suffix\n                }\n\n                g_versionCode = in_defaultConfig.versionCode\n                g_versionName = in_defaultConfig.versionName\n\n                for (def i = 0; i < in_variant.productFlavors.size(); ++i)\n                {\n                    def productFlavour = in_variant.productFlavors.get(i)\n                    if (productFlavour.versionCode != null && productFlavour.versionCode > 0) {\n                        g_versionCode = productFlavour.versionCode\n                        g_versionName = productFlavour.versionName\n                    }\n                }\n            }\n            in_output.processManifest.dependsOn getInfoTask\n        }\n    }\n}\n/**\n * Adds the push Apk Expansion task.\n *\n * @author Ian Copland\n *\n * @param in_applicationVariants - The list of application variants\n */\ndef addApkExpansionTasks(def in_applicationVariants) {\n    in_applicationVariants.all() { in_variant ->\n        in_variant.outputs.each { in_output ->\n            def sku = csGetSkuFromTaskName(in_output.name)\n            if (csIsGooglePlaySku(sku)) {\n                task \"csAssembleApkExpansion${csUpperCaseFirstLetter(in_output.name)}\"(group: 'buildApkExpansion', dependsOn: in_output.processManifest) << {\n                    csGenerateApkExpansion(g_applicationId, g_versionCode)\n                }\n\n                task \"csInstallApkExpansion${csUpperCaseFirstLetter(in_output.name)}\"(group: 'installApkExpansion', dependsOn: \"csAssembleApkExpansion${csUpperCaseFirstLetter(in_output.name)}\") << {\n                    csPushApkExpansionToDevice(g_applicationId, g_versionCode)\n                }\n            }\n        }\n    }\n}\n\next {\n    g_applicationId = \"\"\n    g_versionCode = 0\n    g_versionName = \"\"\n\n    /**\n     * Adds task dependencies as required for building a ChilliSource library.\n     *\n     * @author Ian Copland\n     *\n     * @param in_tasks - The gradle tasks dependencies will be added to.\n     * @param in_libName - The name of the library, without the lib prefix and .a suffix.\n     */\n    csInitLibrary = { in_tasks, in_libName ->\n        in_tasks.all() { currentTask ->\n            def taskName = currentTask.name.toLowerCase()\n\n            //If it is the \"clean\" task also hook in the ChilliSource clean event.\n            if (taskName == \"clean\") {\n                addCleanNdkStaticLibTask(currentTask, in_libName)\n\n            //if it is a ndk compile task, replace it with the ChilliSource ndk compile task.\n            } else if (taskName.startsWith(\"compile\") == true && taskName.endsWith(\"ndk\") == true) {\n                currentTask.dependsOn.clear()\n                currentTask.deleteAllActions()\n\n                //exclude test tasks to avoid duplicate version of the created task.\n                if (csIsTestFromTaskName(taskName) == false) {\n                    addCompileNdkStaticLibTask(currentTask, in_libName)\n                }\n            }\n        }\n    }\n    /**\n     * Adds task dependencies as requires for building a ChilliSource application.\n     *\n     * @author Ian Copland\n     *\n     * @param in_tasks - The applications gradle project\n     * @param in_defaultConfig - The default configuration\n     * @param in_applicationVariants - The list of application variants\n     */\n    csInitApplication = { in_tasks, in_defaultConfig, in_applicationVariants ->\n        addGetInfoTasks(in_defaultConfig, in_applicationVariants)\n\n        addApkExpansionTasks(in_applicationVariants)\n\n        in_tasks.all() { currentTask ->\n            def taskName = currentTask.name.toLowerCase()\n\n            //if it is the 'clean' task also hook in the ChilliSource clean event.\n            if (taskName == \"clean\") {\n                addCleanNdkTask(currentTask)\n\n            //if it is a process manifest task, add the genate manifest task as a dependancy\n            } else if (taskName.startsWith(\"check\") == true && taskName.endsWith(\"manifest\") == true) {\n                addGenerateAndroidManifestTask(currentTask)\n                addGenerateResourcesTask(currentTask)\n\n            //if it is a ndk compile task, replace it with the ChilliSource ndk compile task.\n            } else if (taskName.startsWith(\"compile\") == true && taskName.endsWith(\"ndk\") == true) {\n                currentTask.dependsOn.clear()\n                currentTask.deleteAllActions()\n\n                //exclude test tasks to avoid duplicate version of the created task.\n                if (csIsTestFromTaskName(taskName) == false) {\n                    addCompileNdkTask(currentTask)\n                }\n            }\n        }\n    }\n    /**\n     * Adds the default library dependencies required by ChilliSource.\n     *\n     * @author Ian Copland\n     *\n     * @param in_dependencies - The dependencies.\n     */\n    csAddDefaultDependencies = { in_dependencies ->\n        in_dependencies.compile('com.android.support:appcompat-v7:22.2.0')\n        in_dependencies.compile('com.google.android.gms:play-services:7.5.0')\n        in_dependencies.googlePlayCompile(in_dependencies.project(path: \":playapkexpansion\"))\n        in_dependencies.googlePlayCompile(in_dependencies.project(path: \":playlicensing\"))\n    }\n    /**\n     * Android Gradle currently does not support dependencies for specific combinations of build\n     * type and product flavour. This provides a means to handle it, by mapping application\n     * build variant to a ChilliSource build variant.\n     *\n     * @author Ian Copland\n     *\n     * @param in_dependencies - The dependencies.\n     * @param in_configurations - The configurations.\n     * @param in_csDependencyMap - The map of application variants to ChilliSource variants.\n     */\n    csAddCSDependencies = { in_dependencies, in_configurations, in_csDependencyMap ->\n        def depsMap = new HashMap<String, Dependency>()\n        for (def entry : in_csDependencyMap) {\n            depsMap.put(\"${entry.getKey()}Compile\" as String, in_dependencies.project(path: \":chillisource\", configuration: entry.getValue()))\n        }\n\n        in_configurations.all() { config ->\n            def dep = depsMap.get(\"${config.name}\" as String)\n            if(dep != null) {\n                config.dependencies.add(dep)\n            }\n        }\n    }\n    /**\n     * External library projects are currently bugged such that they depend on all build variants\n     * in a project. This causes a number of issues (and long build times!) for native projects,\n     * so this can be used to solve the issue for the default dependencies.\n     *\n     * @author Ian Copland\n     *\n     * @param in_tasks - All tasks in the android project.\n     */\n    csFixDefaultLibraryDependancies = { in_tasks ->\n        in_tasks.all() { task ->\n            tasksToClear = [\n                \"prepareComAndroidSupportAppcompatV72220Library\",\n                \"prepareComAndroidSupportMediarouterV72200Library\",\n                \"prepareComAndroidSupportSupportV42220Library\",\n                \"prepareComGoogleAndroidGmsPlayServices750Library\",\n                \"prepareComGoogleAndroidGmsPlayServicesAds750Library\",\n                \"prepareComGoogleAndroidGmsPlayServicesAnalytics750Library\",\n                \"prepareComGoogleAndroidGmsPlayServicesAppindexing750Library\",\n                \"prepareComGoogleAndroidGmsPlayServicesAppinvite750Library\",\n                \"prepareComGoogleAndroidGmsPlayServicesAppstate750Library\",\n                \"prepareComGoogleAndroidGmsPlayServicesBase750Library\",\n                \"prepareComGoogleAndroidGmsPlayServicesCast750Library\",\n                \"prepareComGoogleAndroidGmsPlayServicesDrive750Library\",\n                \"prepareComGoogleAndroidGmsPlayServicesFitness750Library\",\n                \"prepareComGoogleAndroidGmsPlayServicesGames750Library\",\n                \"prepareComGoogleAndroidGmsPlayServicesGcm750Library\",\n                \"prepareComGoogleAndroidGmsPlayServicesIdentity750Library\",\n                \"prepareComGoogleAndroidGmsPlayServicesLocation750Library\",\n                \"prepareComGoogleAndroidGmsPlayServicesMaps750Library\",\n                \"prepareComGoogleAndroidGmsPlayServicesNearby750Library\",\n                \"prepareComGoogleAndroidGmsPlayServicesPanorama750Library\",\n                \"prepareComGoogleAndroidGmsPlayServicesPlus750Library\",\n                \"prepareComGoogleAndroidGmsPlayServicesSafetynet750Library\",\n                \"prepareComGoogleAndroidGmsPlayServicesWallet750Library\",\n                \"prepareComGoogleAndroidGmsPlayServicesWearable750Library\",\n            ]\n\n            if (tasksToClear.contains(task.name)) {\n                task.dependsOn.clear()\n            }\n        }\n    }\n}"
  },
  {
    "path": "Tools/Scripts/android-execute-command.gradle",
    "content": "//\n//  android-execute-command.gradle\n//  ChilliSource\n//  Created by Ian Copland on 26/06/2015.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2015 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\nimport java.lang.Process\nimport java.lang.reflect.Array\n\n/**\n * Prints anything in the given buffered stream.\n *\n * @author Ian Copland\n *\n * @param in_stream - The input stream.\n * @param in_printAsError - If true, any messages will be printed as an error message.\n */\ndef printStream(InputStream in_stream, boolean in_printAsError) {\n    try {\n        def bufferedInputReader = new BufferedReader(new InputStreamReader(in_stream))\n        String line\n        while ((line = bufferedInputReader.readLine()) != null) {\n            if (in_printAsError) {\n                System.err.println(line)\n            } else {\n                System.out.println(line)\n            }\n        }\n    }\n    catch (Exception e) {\n        throw new GradleException(\"Failed to print stream.\", e) as Throwable\n    }\n}\n/**\n * adds the given stream to the given string builder.\n *\n * @author Ian Copland\n *\n * @param in_stream - The input stream.\n * @param in_stringBuilder - The string builder\n */\ndef addStreamToString(InputStream in_stream, StringBuilder in_stringBuilder) {\n    try {\n        def bufferedInputReader = new BufferedReader(new InputStreamReader(in_stream))\n        String line\n        while ((line = bufferedInputReader.readLine()) != null) {\n            in_stringBuilder.append(line)\n        }\n    }\n    catch (Exception e) {\n        throw new GradleException(\"Failed to add stream to string.\", e) as Throwable\n    }\n}\n\next {\n    /**\n     * Executes the given command line parameters. Outputs the contents of both the input stream\n     * and error stream to console.\n     *\n     * @author Ian Copland\n     *\n     * @param in_commands - The array of commands\n     */\n    csExecuteCommand = { in_commands ->\n        final def process = new ProcessBuilder(in_commands as String[]).start()\n\n        def inputRunnable = new Runnable() {\n            @Override public void run() {\n                printStream(process.getInputStream(), false)\n            }\n        }\n        def errorRunnable = new Runnable() {\n            @Override public void run() {\n                printStream(process.getErrorStream(), true)\n            }\n        }\n\n        def inputThread = new Thread(inputRunnable)\n        def errorThread = new Thread(errorRunnable)\n        inputThread.start()\n        errorThread.start()\n        inputThread.join()\n        errorThread.join()\n        process.waitFor()\n        process.destroy()\n\n        if (process.exitValue() != 0) {\n            throw new GradleException(\"Process exited with the error code \" + process.exitValue() + \". See above for details if available.\") as Throwable\n        }\n    }\n    /**\n     * Executes the given command line parameters and returns the contents of the input stream.\n     *\n     * @author Ian Copland\n     *\n     * @param in_commands - The array of commands\n     *\n     * @return The contents of the input stream.\n     */\n    csExecuteCommandAndGetOutput = { in_commands ->\n        final def process = new ProcessBuilder(in_commands as String[]).start()\n\n        final def stringBuilder = new StringBuilder()\n        def inputRunnable = new Runnable() {\n            @Override public void run() {\n                addStreamToString(process.getInputStream(), stringBuilder)\n            }\n        }\n        def errorRunnable = new Runnable() {\n            @Override public void run() {\n                printStream(process.getErrorStream(), true)\n            }\n        }\n\n        def inputThread = new Thread(inputRunnable)\n        def errorThread = new Thread(errorRunnable)\n        inputThread.start()\n        errorThread.start()\n        inputThread.join()\n        errorThread.join()\n        process.waitFor()\n        process.destroy()\n\n        if (process.exitValue() != 0) {\n            throw new GradleException(\"Process exited the error code \" + process.exitValue() + \". See above for more information, if available.\") as Throwable\n        }\n\n        return stringBuilder.toString()\n    }\n}"
  },
  {
    "path": "Tools/Scripts/android-proguard-rules.pro",
    "content": "#\n#  android-proguard-rules.pro\n#  ChilliSource\n#  Created by Ian Copland on 24/03/2015.\n#\n#  The MIT License (MIT)\n#\n#  Copyright (c) 2015 Tag Games Limited\n#\n#  Permission is hereby granted, free of charge, to any person obtaining a copy\n#  of this software and associated documentation files (the \"Software\"), to deal\n#  in the Software without restriction, including without limitation the rights\n#  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n#  copies of the Software, and to permit persons to whom the Software is\n#  furnished to do so, subject to the following conditions:\n#\n#  The above copyright notice and this permission notice shall be included in\n#  all copies or substantial portions of the Software.\n#\n#  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n#  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n#  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n#  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n#  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n#  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n#  THE SOFTWARE.\n#\n\n-dontpreverify\n-repackageclasses ''\n-allowaccessmodification\n-optimizations !code/simplification/arithmetic\n\n#keep all of the classes accessible through the AndroidManifest.xml\n-keep public class * extends android.app.Activity\n-keep public class * extends android.app.Application\n-keep public class * extends android.app.Service\n-keep public class * extends android.content.BroadcastReceiver\n-keep public class * extends android.content.ContentProvider\n\n#keep everthing in R\n-keep public class **.R { public *; }\n-keep public class **.R$* { public *; }\n\n#Keep all classes with native methods\n-keepclasseswithmembers class * {\n    native <methods>;\n}\n\n#Keep all java systems as these are typically accessed from native\n-keep public class com.chilliworks.chillisource.core.System { public *; }\n-keep public class * extends com.chilliworks.chillisource.core.System { public *; }\n\n#Keep boxed pointers\n-keep public class com.chilliworks.chillisource.core.BoxedPointer { public *; }\n\n#also keep old-style Native Interfaces. This will be removed in the future\n-keep public class **NativeInterface { *; }\n\n#keep anything which extends ApkExpansionDownloader, since reflection is used create them\n-keep public class * extends com.chilliworks.chillisource.networking.ApkExpansionDownloadView { public *; }\n\n#keep the following classes are they are accessed from native\n-keep public class com.chilliworks.chillisource.core.LocalNotification { public *; }\n-keep public class com.chilliworks.chillisource.core.ApkExpansionInfo { public *; }\n-keep public class com.chilliworks.chillisource.core.ApkExpansionContentProvider { public *; }\n-keep public class com.chilliworks.chillisource.networking.HttpRequest { public *; }\n\n#keep google play classes\n-keep class com.google.android.vending.expansion.downloader.impl.DownloadsDB\n\n#keep amazon classes\n-dontwarn com.amazon.**\n-keep class com.amazon.** {*;}\n-keepattributes *Annotation*\n"
  },
  {
    "path": "Tools/Scripts/android-push-apk-expansion.gradle",
    "content": "//\n//  android-push-apk-expansion.gradle\n//  ChilliSource\n//  Created by Ian Copland on 02/07/2015.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2015 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\napply from: '../../../../ChilliSource/Tools/Scripts/android-execute-command.gradle'\n\nimport org.apache.tools.ant.taskdefs.condition.Os\n\n/**\n * Reads the local.properties file to get the location of the ndk-build script. This also takes\n * into account the OS - returning ndk-build.cmd on windows and ndk-build on other platforms.\n *\n * @author Ian Copland\n *\n * @return The path to ndk-build.\n */\ndef getAdbFilePath() {\n    String rootDir = project.rootDir\n    def localProperties = new File(rootDir, \"local.properties\")\n    if (localProperties.exists()) {\n        def properties = new Properties()\n        localProperties.withInputStream {\n            stream -> properties.load(stream)\n        }\n        def ndkDir = properties.getProperty('sdk.dir')\n        if (ndkDir == null) {\n            throw new GradleException(\"The sdk.dir property in local.propeties is not set\") as Throwable\n        }\n        def ndkBuild = Os.isFamily(Os.FAMILY_WINDOWS) ? \"$ndkDir/platform-tools/adb.exe\" : \"$ndkDir/platform-tools/adb\" as String\n        return ndkBuild\n\n    } else {\n        throw new GradleException(\"The local.properties file does not exist\")\n    }\n}\n\next {\n    /**\n     * Pushes the generated Apk Expansion file to device.\n     *\n     * @author Ian Copland\n     *\n     * @param in_applicationId - The application Id\n     * @param in_versionCode - The version code\n     */\n    csPushApkExpansionToDevice = { in_applicationId, in_versionCode ->\n        def fileName = \"main.\" + in_versionCode + \".\" + in_applicationId + \".obb\"\n        String filePath = file(\"build/outputs/obb\").absolutePath + \"/\" + fileName\n\n        if (!new File(filePath).exists()) {\n            throw new GradleException(\"Cannot push Apk Expansion file to device becuase it doesn't exist!\") as Throwable\n        }\n\n        String adb = getAdbFilePath()\n        csExecuteCommand([ adb, \"start-server\" ] as String[])\n        \n        String storagePath = csExecuteCommandAndGetOutput([adb, 'shell', 'echo', '$EXTERNAL_STORAGE'])\n\n        String destinationFilePath = storagePath + '/Android/obb/' + in_applicationId + '/' + fileName\n        csExecuteCommand([ adb, \"push\", filePath, destinationFilePath ] as String[])\n    }\n}"
  },
  {
    "path": "Tools/Scripts/android-settings.gradle",
    "content": "//\n//  android-settings.gradle\n//  ChilliSource\n//  Created by Ian Copland on 22/04/2015.\n//\n//  The MIT License (MIT)\n//\n//  Copyright (c) 2015 Tag Games Limited\n//\n//  Permission is hereby granted, free of charge, to any person obtaining a copy\n//  of this software and associated documentation files (the \"Software\"), to deal\n//  in the Software without restriction, including without limitation the rights\n//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n//  copies of the Software, and to permit persons to whom the Software is\n//  furnished to do so, subject to the following conditions:\n//\n//  The above copyright notice and this permission notice shall be included in\n//  all copies or substantial portions of the Software.\n//\n//  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n//  THE SOFTWARE.\n//\n\next {\n    csProjectRoot = \"../../..\"\n\n    /**\n     * Adds the 3 android library project modules to the project.\n     *\n     * @author Ian Copland\n     */\n    csApplyDefaultSettings = { ->\n        include ':chillisource'\n        project(':chillisource').projectDir = new File(settingsDir as String, \"$csProjectRoot/ChilliSource/Projects/Android/chillisource\")\n\n        include ':playapkexpansion'\n        project(':playapkexpansion').projectDir = new File(settingsDir as String, \"$csProjectRoot/ChilliSource/Projects/Android/playapkexpansion\")\n\n        include ':playlicensing'\n        project(':playlicensing').projectDir = new File(settingsDir as String, \"$csProjectRoot/ChilliSource/Projects/Android/playlicensing\")\n    }\n}\n"
  },
  {
    "path": "Tools/Scripts/copy_ios_resources.py",
    "content": "#!/usr/bin/python\n#\n#  copy_ios_resources.py\n#  ChilliSource\n#  Created by Scott Downie on 23/06/2014.\n#\n#  The MIT License (MIT)\n#\n#  Copyright (c) 2014 Tag Games Limited\n#\n#  Permission is hereby granted, free of charge, to any person obtaining a copy\n#  of this software and associated documentation files (the \"Software\"), to deal\n#  in the Software without restriction, including without limitation the rights\n#  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n#  copies of the Software, and to permit persons to whom the Software is\n#  furnished to do so, subject to the following conditions:\n#\n#  The above copyright notice and this permission notice shall be included in\n#  all copies or substantial portions of the Software.\n#\n#  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n#  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n#  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n#  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n#  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n#  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n#  THE SOFTWARE.\n#\n\nimport sys\nimport file_system_utils\nimport os\nimport shutil\n\n#----------------------------------------------------------------------\n# Copies the resource from CSResources and AppResources\n# into a single directory linked to by XCode.\n#\n# @author S Downie\n#----------------------------------------------------------------------\n\n#----------------------------------------------------------------------\n# Copies the files from src directory to dst directory but excludes\n# those that are tagged for the other platforms\n#\n# @author S Downie\n#\n# @param Source path\n# @param Destination path\n#----------------------------------------------------------------------\ndef copy_file_tree(src_path, dst_path):\n    excludes = [\".android\", \".windows\", \".rpi\", \".DS_Store\", \"Thumbs.db\"]\n    includes = [\".ios\"]\n\n    filter_func = lambda name: any(include in name for include in includes) or not any(exclude in name for exclude in excludes)\n\n    if os.path.exists(dst_path) == False:\n        os.makedirs(dst_path)\n\n    for item in os.listdir(src_path):\n        src = os.path.join(src_path, item)\n        dst = os.path.join(dst_path, item)\n        if os.path.isdir(src):\n            copy_file_tree(src, dst)\n        else:\n            if filter_func(item):\n                shutil.copy2(src, dst)\n\n#----------------------------------------------------------------------\n# Copies the resource from CSResources and AppResources\n#\n# @author S Downie\n#\n# @param Project directory path\n#----------------------------------------------------------------------\ndef copy_resources(project_dir):\n    file_system_utils.delete_directory(os.path.join(project_dir, \"XcodeBuiltAssets\"))\n\n    app_src_path = os.path.join(project_dir, \"..\", \"..\", \"Content\", \"AppResources\")\n    cs_src_path = os.path.join(project_dir, \"..\", \"..\", \"ChilliSource\", \"CSResources\")\n\n    app_dst_path = os.path.join(project_dir, \"XcodeBuiltAssets\", \"AppResources\")\n    cs_dst_path = os.path.join(project_dir, \"XcodeBuiltAssets\", \"CSResources\")\n\n    copy_file_tree(app_src_path, app_dst_path)\n    copy_file_tree(cs_src_path, cs_dst_path)\n\n#----------------------------------------------------------------------\n# The entry point into the script.\n#\n# @author S Downie\n#\n# @param The list of arguments.\n#----------------------------------------------------------------------\ndef main(args):\n    if not len(args) is 2:\n        print(\"ERROR: Missing project path\")\n        return\n\n    project_dir = args[1]\n    copy_resources(project_dir)\n\nif __name__ == \"__main__\":\n    main(sys.argv)\n"
  },
  {
    "path": "Tools/Scripts/copy_rpi_resources.py",
    "content": "#!/usr/bin/python\n#\n#  The MIT License (MIT)\n#\n#  Copyright (c) 2017 Tag Games Limited\n#\n#  Permission is hereby granted, free of charge, to any person obtaining a copy\n#  of this software and associated documentation files (the \"Software\"), to deal\n#  in the Software without restriction, including without limitation the rights\n#  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n#  copies of the Software, and to permit persons to whom the Software is\n#  furnished to do so, subject to the following conditions:\n#\n#  The above copyright notice and this permission notice shall be included in\n#  all copies or substantial portions of the Software.\n#\n#  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n#  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n#  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n#  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n#  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n#  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n#  THE SOFTWARE.\n#\n\nimport sys\nimport file_system_utils\nimport subprocess\nimport shutil\nimport os\n\n# Copies the resources from AppResources and CSResources\n# into Raspberry Pi target directories\n#\n# Premulitplies all the PNGs\n#\n\n# Copies the files from src directory to dst directory but excludes\n# those that are tagged for other platforms\n#\n# @param src_path\n#   Path to copy from\n# @param dst_path\n#   Path to copy to\n#\ndef copy_file_tree(src_path, dst_path):\n    excludes = [\".ios\", \".android\", \".windows\", \".DS_Store\", \"Thumbs.db\"]\n    includes = [\".rpi\"]\n\n    filter_func = lambda name: any(include in name for include in includes) or not any(exclude in name for exclude in excludes)\n\n    if os.path.exists(dst_path) == False:\n        os.makedirs(dst_path)\n\n    for item in os.listdir(src_path):\n        src = os.path.join(src_path, item)\n        dst = os.path.join(dst_path, item)\n        if os.path.isdir(src):\n            copy_file_tree(src, dst)\n        else:\n            if filter_func(item):\n                shutil.copy2(src, dst)\n\n# Copies the resource from CSResources and AppResources\n# into target directory.\n#\n# @param project_dir\n#   Project directory path\n# @param target_dir\n#   Target directory path\n#\ndef copy_resources(project_dir, target_dir):\n    assetsDir = os.path.join(target_dir, \"assets\")\n\n    file_system_utils.delete_directory(assetsDir)\n\n    app_src_path = os.path.join(project_dir, \"Content\", \"AppResources\")\n    cs_src_path = os.path.join(project_dir, \"ChilliSource\", \"CSResources\")\n\n    app_dst_path = os.path.join(assetsDir, \"AppResources\")\n    cs_dst_path = os.path.join(assetsDir, \"CSResources\")\n\n    copy_file_tree(app_src_path, app_dst_path)\n    copy_file_tree(cs_src_path, cs_dst_path)\n\n# Copies the libs/dlls into target directory.\n#\n# @param project_dir\n#   Project directory path\n# @param target_dir\n#   Target directory path\n#\ndef copy_libs(project_dir, target_dir):\n    libs_src_path = os.path.join(project_dir, \"ChilliSource\", \"Libraries\", \"Core\", \"RPi\", \"Libs\")\n    dll_files = file_system_utils.get_file_paths_with_extensions(libs_src_path, [\"dll\"])\n\n    for dll_file in dll_files:\n        shutil.copy(dll_file, target_dir)\n\n# Premulitplies all the PNGs in assets\n#\n# @param project_dir\n#   Project directory path\n# @param target_dir\n#   Target directory path\n#\ndef premultiply_pngs(project_dir, target_dir):\n    assetsDir = os.path.join(target_dir, \"assets\")\n\n    jarFile = os.path.join(project_dir, \"ChilliSource\", \"Tools\", \"PNGAlphaPremultiplier.jar\")\n    png_files = file_system_utils.get_file_paths_with_extensions(assetsDir, [\"png\"])\n\n    for png_file in png_files:\n        subprocess.call([\"java\", \"-Djava.awt.headless=true\", \"-Xmx512m\", \"-jar\", jarFile, \"--input\", png_file, \"--output\", png_file]);\n\n# The entry point into the script.\n#\n# @param args\n#   The list of arguments.\n#\ndef main(args):\n    if not len(args) is 3:\n        print(\"ERROR: Missing project path or target path\")\n        return\n\n    project_dir = args[1]\n    target_dir = args[2]\n\n    copy_resources(project_dir, target_dir)\n    copy_libs(project_dir, target_dir)\n    premultiply_pngs(project_dir, target_dir)\n\nif __name__ == \"__main__\":\n    main(sys.argv)\n"
  },
  {
    "path": "Tools/Scripts/copy_windows_resources.py",
    "content": "#!/usr/bin/python\n#\n#  copy_windows_resources.py\n#  ChilliSource\n#  Created by Scott Downie on 12/06/2014.\n#\n#  The MIT License (MIT)\n#\n#  Copyright (c) 2014 Tag Games Limited\n#\n#  Permission is hereby granted, free of charge, to any person obtaining a copy\n#  of this software and associated documentation files (the \"Software\"), to deal\n#  in the Software without restriction, including without limitation the rights\n#  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n#  copies of the Software, and to permit persons to whom the Software is\n#  furnished to do so, subject to the following conditions:\n#\n#  The above copyright notice and this permission notice shall be included in\n#  all copies or substantial portions of the Software.\n#\n#  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n#  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n#  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n#  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n#  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n#  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n#  THE SOFTWARE.\n#\n\nimport sys\nimport file_system_utils\nimport subprocess\nimport shutil\nimport os\n\n#----------------------------------------------------------------------\n# Copies the resources from AppResources and CSResources\n# into windows target directories\n#\n# Premulitplies all the PNGs\n#\n# @author S Downie\n#----------------------------------------------------------------------\n\n#----------------------------------------------------------------------\n# Copies the files from src directory to dst directory but excludes\n# those that are tagged for other platforms\n#\n# @author S Downie\n#\n# @param Source path\n# @param Destination path\n#----------------------------------------------------------------------\ndef copy_file_tree(src_path, dst_path):\n    excludes = [\".ios\", \".android\", \".rpi\", \".DS_Store\", \"Thumbs.db\"]\n    includes = [\".windows\"]\n\n    filter_func = lambda name: any(include in name for include in includes) or not any(exclude in name for exclude in excludes)\n\n    if os.path.exists(dst_path) == False:\n        os.makedirs(dst_path)\n\n    for item in os.listdir(src_path):\n        src = os.path.join(src_path, item)\n        dst = os.path.join(dst_path, item)\n        if os.path.isdir(src):\n            copy_file_tree(src, dst)\n        else:\n            if filter_func(item):\n                shutil.copy2(src, dst)\n\n#----------------------------------------------------------------------\n# Copies the resource from CSResources and AppResources\n# into target directory.\n#\n# @author S Downie\n#\n# @param Project directory path\n# @param Target directory path\n#----------------------------------------------------------------------\ndef copy_resources(project_dir, target_dir):\n    assetsDir = os.path.join(target_dir, \"assets\")\n\n    file_system_utils.delete_directory(assetsDir)\n\n    app_src_path = os.path.join(project_dir, \"..\", \"..\", \"Content\", \"AppResources\")\n    cs_src_path = os.path.join(project_dir, \"..\", \"..\", \"ChilliSource\", \"CSResources\")\n\n    app_dst_path = os.path.join(assetsDir, \"AppResources\")\n    cs_dst_path = os.path.join(assetsDir, \"CSResources\")\n\n    copy_file_tree(app_src_path, app_dst_path)\n    copy_file_tree(cs_src_path, cs_dst_path)\n\n#----------------------------------------------------------------------\n# Copies the libs/dlls into target directory.\n#\n# @author S Downie\n#\n# @param Project directory path\n# @param Target directory path\n#----------------------------------------------------------------------\ndef copy_libs(project_dir, target_dir):\n    libs_src_path = os.path.join(project_dir, \"..\", \"..\", \"ChilliSource\", \"Libraries\", \"Core\", \"Windows\", \"Libs\")\n    dll_files = file_system_utils.get_file_paths_with_extensions(libs_src_path, [\"dll\"])\n\n    for dll_file in dll_files:\n        shutil.copy(dll_file, target_dir)\n\n#----------------------------------------------------------------------\n# Premulitplies all the PNGs in assets\n#\n# @author S Downie\n#\n# @param Project directory path\n# @param Target directory path\n#----------------------------------------------------------------------\ndef premultiply_pngs(project_dir, target_dir):\n    assetsDir = os.path.join(target_dir, \"assets\")\n\n    jarFile = os.path.join(project_dir, \"..\", \"..\", \"ChilliSource\", \"Tools\", \"PNGAlphaPremultiplier.jar\")\n    png_files = file_system_utils.get_file_paths_with_extensions(assetsDir, [\"png\"])\n\n    for png_file in png_files:\n        subprocess.call([\"java\", \"-Djava.awt.headless=true\", \"-Xmx512m\", \"-jar\", jarFile, \"--input\", png_file, \"--output\", png_file]);\n\n#----------------------------------------------------------------------\n# The entry point into the script.\n#\n# @author S Downie\n#\n# @param The list of arguments.\n#----------------------------------------------------------------------\ndef main(args):\n    if not len(args) is 3:\n        print(\"ERROR: Missing project path or target path\")\n        return\n\n    project_dir = args[1]\n    target_dir = args[2]\n\n    copy_resources(project_dir, target_dir)\n    copy_libs(project_dir, target_dir)\n    premultiply_pngs(project_dir, target_dir)\n\nif __name__ == \"__main__\":\n    main(sys.argv)\n"
  },
  {
    "path": "Tools/Scripts/extract_headers.py",
    "content": "#!/usr/bin/python\n#\n#  extract_headers.py\n#  ChilliSource\n#  Created by Ian Copland on 13/06/2014.\n#\n#  The MIT License (MIT)\n#\n#  Copyright (c) 2014 Tag Games Limited\n#\n#  Permission is hereby granted, free of charge, to any person obtaining a copy\n#  of this software and associated documentation files (the \"Software\"), to deal\n#  in the Software without restriction, including without limitation the rights\n#  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n#  copies of the Software, and to permit persons to whom the Software is\n#  furnished to do so, subject to the following conditions:\n#\n#  The above copyright notice and this permission notice shall be included in\n#  all copies or substantial portions of the Software.\n#\n#  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n#  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n#  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n#  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n#  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n#  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n#  THE SOFTWARE.\n#\n\n#----------------------------------------------------------------------\n# Copies all header files in the given source directory and places them\n# in the output\n#\n# The parameters to the tool are:\n#\n#    '--input' or '-i'   -> The input directory path to look for headers.\n#    '--output' or '-o'  -> The output directory whether the extracted\n#                           headers will be placed.\n#\n# @author I Copland\n#----------------------------------------------------------------------\n\nimport sys\nimport os\nimport shutil\nimport file_system_utils\n\n#----------------------------------------------------------------------\n# Extracts the headers.\n#\n# @author I Copland\n#\n# @param The input header directory path.\n# @param The output header directory path.\n#----------------------------------------------------------------------\ndef extract(input_directory_path, output_directory_path):\n\n    #create the output directory.\n    print(\"Creating directory '\" + output_directory_path + \"'\")\n    file_system_utils.delete_directory(output_directory_path)\n    os.makedirs(output_directory_path)\n\n    #copy all headers\n    header_file_paths = file_system_utils.get_file_paths_with_extensions(input_directory_path, [\"h\", \"hpp\", \"inl\"])\n    for header_file_path in header_file_paths:\n        relative_header_file_path = header_file_path[len(input_directory_path):len(header_file_path)];\n        input_header_file_path = os.path.join(input_directory_path, relative_header_file_path)\n        output_header_file_path = os.path.join(output_directory_path, relative_header_file_path)\n        print(\"Copying header '\" + input_header_file_path + \"' to \" + output_header_file_path + \"'\")\n        if os.path.exists(os.path.dirname(output_header_file_path)) == False:\n            os.makedirs(os.path.dirname(output_header_file_path))\n        shutil.copy2(input_header_file_path, output_header_file_path)\n\n#----------------------------------------------------------------------\n# The entry point into the script.\n#\n# @author I Copland\n#\n# @param The list of arguments.\n#----------------------------------------------------------------------\ndef main(args):\n    input_directory_path = \"\"\n    output_directory_path = \"\"\n\n    argCount = len(args)\n    for i in range(0, argCount):\n        arg = args[i]\n\n        if (arg == \"--input\" or arg == \"-i\") and i+1 < argCount:\n            input_directory_path = args[i+1]\n        if (arg == \"--output\" or arg == \"-o\") and i+1 < argCount:\n            output_directory_path = args[i+1]\n\n    if len(input_directory_path) > 0 and len(output_directory_path) > 0:\n        extract(input_directory_path, output_directory_path)\n    else:\n        print(\"Incorrect arguments supplied.\")\n\nif __name__ == \"__main__\":\n    main(sys.argv)\n"
  },
  {
    "path": "Tools/Scripts/file_system_utils.py",
    "content": "#!/usr/bin/python\n#\n#  FileSystemUtils.py\n#  ChilliSource\n#  Created by Ian Copland on 20/08/2012.\n#\n#  The MIT License (MIT)\n#\n#  Copyright (c) 2012 Tag Games Limited\n#\n#  Permission is hereby granted, free of charge, to any person obtaining a copy\n#  of this software and associated documentation files (the \"Software\"), to deal\n#  in the Software without restriction, including without limitation the rights\n#  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n#  copies of the Software, and to permit persons to whom the Software is\n#  furnished to do so, subject to the following conditions:\n#\n#  The above copyright notice and this permission notice shall be included in\n#  all copies or substantial portions of the Software.\n#\n#  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n#  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n#  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n#  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n#  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n#  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n#  THE SOFTWARE.\n#\n\nimport sys\nimport os\nimport shutil\nimport zipfile\nimport errno\nfrom zipfile import ZipFile, ZIP_DEFLATED\nimport fnmatch\n\n#----------------------------------------\n# Calculates the absolute path from a path\n# relative to this script file.\n#\n# @author I Copland\n#\n# @param The path relative to this source\n# file.\n# @return The absolute path.\n#----------------------------------------\ndef get_path_from_here(path):\n    return os.path.realpath(os.path.join(os.path.dirname(os.path.realpath(__file__)), path));\n#----------------------------------------\n# Overwrite the given dst directory or create\n# it if it doesn't exist with the contents\n# of the src directory\n#\n# @author S Downie\n#----------------------------------------\ndef overwrite_directory(src_path, dst_path):\n    delete_directory(dst_path)\n    try:\n        shutil.copytree(src_path, dst_path)\n    except OSError as e:\n        # If the error was caused because the source wasn't a directory\n        if e.errno == errno.ENOTDIR:\n            shutil.copy(src_path, dst_path)\n        else:\n            print('Directory not copied. Error: %s' % e)\n\n#----------------------------------------\n# Copy the given dst directory or create\n# it if it doesn't exist with the contents\n# of the src directory. This will overwrite\n# exisiting files of the same name in the dst\n# directory\n#\n# @author S Downie\n#----------------------------------------\ndef copy_directory(src_path, dst_path):\n    if os.path.exists(dst_path) == False:\n        os.makedirs(dst_path)\n\n    for item in os.listdir(src_path):\n        src = os.path.join(src_path, item)\n        dst = os.path.join(dst_path, item)\n        if os.path.isdir(src):\n            copy_directory(src, dst)\n        else:\n            shutil.copy2(src, dst)\n#----------------------------------------\n# Deletes a directory if it exists. Does\n# not return an error if trying to delete\n# a directory that doesn't exist.\n#\n# @author I Copland\n#\n# @param The path to the directory to delete.\n#----------------------------------------\ndef delete_directory(directory_path):\n    if os.path.exists(directory_path) == True:\n        shutil.rmtree(directory_path)\n#----------------------------------------\n# Deletes a file if it exists. Does not\n# return an error if trying to delete a\n# file that doesn't exist.\n#\n# @author I Copland\n#\n# @param The path to the file to delete.\n#----------------------------------------\ndef delete_file(file_path):\n    if os.path.isfile(file_path) == True:\n        os.remove(file_path)\n#----------------------------------------\n# @author I Copland\n#\n# @param The path.\n# @param The extension. This is not case\n# sensitive.\n# @return Whether or not the path has\n# the given extension.\n#----------------------------------------\ndef has_extension(file_path, extension):\n    lowercase_filepath = file_path.lower()\n    lowercase_extension = extension.lower()\n    ext = os.path.splitext(lowercase_filepath)[1]\n    return ext == (\".\"+lowercase_extension)\n#----------------------------------------\n# Returns a list of all file paths with\n# any of the given extensions in the\n# requested directory.\n#\n# @author I Copland\n#\n# @param The directory path.\n# @param A list of possible extensions. This\n# is not case sensitive.\n#----------------------------------------\ndef get_file_paths_with_extensions(directory_path, extensions):\n    output = []\n    for curr_directory_path, child_directory_paths, file_paths in os.walk(directory_path):\n        for file_path in file_paths:\n            for extension in extensions:\n                if has_extension(file_path, extension) == True:\n                    output.append(os.path.join(curr_directory_path, file_path))\n    return output\n"
  },
  {
    "path": "Tools/Scripts/get_file_paths_with_extensions.py",
    "content": "#!/usr/bin/python\n#\n#  get_file_paths_with_extensions.py\n#  ChilliSource\n#  Created by Ian Copland on 28/05/2014.\n#\n#  The MIT License (MIT)\n#\n#  Copyright (c) 2014 Tag Games Limited\n#\n#  Permission is hereby granted, free of charge, to any person obtaining a copy\n#  of this software and associated documentation files (the \"Software\"), to deal\n#  in the Software without restriction, including without limitation the rights\n#  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n#  copies of the Software, and to permit persons to whom the Software is\n#  furnished to do so, subject to the following conditions:\n#\n#  The above copyright notice and this permission notice shall be included in\n#  all copies or substantial portions of the Software.\n#\n#  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n#  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n#  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n#  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n#  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n#  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n#  THE SOFTWARE.\n#\n\nimport sys\nimport file_system_utils\n\n#----------------------------------------\n# The entry point into the script.\n# \n# @author I Copland\n#\n# @param The list of arguments.\n#----------------------------------------\ndef main(args):\n\n    directory_path = \"\"\n    directory_prefix = \"\"\n    extensions = []\n\n    argCount = len(args)\n    for i in range(0, argCount):\n        arg = args[i]\n        \n        if (arg == \"--directory\" or arg == \"-d\") and i+1 < argCount:\n            directory_path = args[i+1]\n        if (arg == \"--prefix\" or arg == \"-p\") and i+1 < argCount:\n            directory_prefix = args[i+1]\n        if (arg == \"--extensions\" or arg == \"-e\") and i+1 < argCount:\n            extensions = args[i+1].split(\",\")\n\n    file_paths = file_system_utils.get_file_paths_with_extensions(directory_path, extensions)\n\n    output = \"\"\n    first = True\n    for file_path in file_paths:\n        if first == False:\n            output += \" \"\n        first = False\n        addition = directory_prefix + file_path\n        addition = addition.replace('\\\\', '/')\n        output += addition\n\n    # Write to stdout so that other programs can read the files\n    sys.stdout.write(output)\n\nif __name__ == \"__main__\":\n    main(sys.argv)\n"
  },
  {
    "path": "Tools/Scripts/ninja_syntax.py",
    "content": "#!/usr/bin/python\n\n\"\"\"Python module for generating .ninja files.\n\nNote that this is emphatically not a required piece of Ninja; it's\njust a helpful utility for build-file-generation systems that already\nuse Python.\n\"\"\"\n\nimport textwrap\nimport re\n\ndef escape_path(word):\n    return word.replace('$ ','$$ ').replace(' ','$ ').replace(':', '$:')\n\nclass Writer(object):\n    def __init__(self, output, width=78):\n        self.output = output\n        self.width = width\n\n    def newline(self):\n        self.output.write('\\n')\n\n    def comment(self, text):\n        for line in textwrap.wrap(text, self.width - 2):\n            self.output.write('# ' + line + '\\n')\n\n    def variable(self, key, value, indent=0):\n        if value is None:\n            return\n        if isinstance(value, list):\n            value = ' '.join(filter(None, value))  # Filter out empty strings.\n        self._line('%s = %s' % (key, value), indent)\n\n    def pool(self, name, depth):\n        self._line('pool %s' % name)\n        self.variable('depth', depth, indent=1)\n\n    def rule(self, name, command, description=None, depfile=None,\n             generator=False, pool=None, restat=False, rspfile=None,\n             rspfile_content=None, deps=None):\n        self._line('rule %s' % name)\n        self.variable('command', command, indent=1)\n        if description:\n            self.variable('description', description, indent=1)\n        if depfile:\n            self.variable('depfile', depfile, indent=1)\n        if generator:\n            self.variable('generator', '1', indent=1)\n        if pool:\n            self.variable('pool', pool, indent=1)\n        if restat:\n            self.variable('restat', '1', indent=1)\n        if rspfile:\n            self.variable('rspfile', rspfile, indent=1)\n        if rspfile_content:\n            self.variable('rspfile_content', rspfile_content, indent=1)\n        if deps:\n            self.variable('deps', deps, indent=1)\n\n    def build(self, outputs, rule, inputs=None, implicit=None, order_only=None,\n              variables=None):\n        outputs = self._as_list(outputs)\n        all_inputs = self._as_list(inputs)[:]\n        out_outputs = list(map(escape_path, outputs))\n        all_inputs = list(map(escape_path, all_inputs))\n\n        if implicit:\n            implicit = map(escape_path, self._as_list(implicit))\n            all_inputs.append('|')\n            all_inputs.extend(implicit)\n        if order_only:\n            order_only = map(escape_path, self._as_list(order_only))\n            all_inputs.append('||')\n            all_inputs.extend(order_only)\n\n        self._line('build %s: %s' % (' '.join(out_outputs),\n                                        ' '.join([rule] + all_inputs)))\n\n        if variables:\n            if isinstance(variables, dict):\n                iterator = iter(variables.items())\n            else:\n                iterator = iter(variables)\n\n            for key, val in iterator:\n                self.variable(key, val, indent=1)\n\n        return outputs\n\n    def include(self, path):\n        self._line('include %s' % path)\n\n    def subninja(self, path):\n        self._line('subninja %s' % path)\n\n    def default(self, paths):\n        self._line('default %s' % ' '.join(self._as_list(paths)))\n\n    def _count_dollars_before_index(self, s, i):\n      \"\"\"Returns the number of '$' characters right in front of s[i].\"\"\"\n      dollar_count = 0\n      dollar_index = i - 1\n      while dollar_index > 0 and s[dollar_index] == '$':\n        dollar_count += 1\n        dollar_index -= 1\n      return dollar_count\n\n    def _line(self, text, indent=0):\n        \"\"\"Write 'text' word-wrapped at self.width characters.\"\"\"\n        leading_space = '  ' * indent\n        while len(leading_space) + len(text) > self.width:\n            # The text is too wide; wrap if possible.\n\n            # Find the rightmost space that would obey our width constraint and\n            # that's not an escaped space.\n            available_space = self.width - len(leading_space) - len(' $')\n            space = available_space\n            while True:\n              space = text.rfind(' ', 0, space)\n              if space < 0 or \\\n                 self._count_dollars_before_index(text, space) % 2 == 0:\n                break\n\n            if space < 0:\n                # No such space; just use the first unescaped space we can find.\n                space = available_space - 1\n                while True:\n                  space = text.find(' ', space + 1)\n                  if space < 0 or \\\n                     self._count_dollars_before_index(text, space) % 2 == 0:\n                    break\n            if space < 0:\n                # Give up on breaking.\n                break\n\n            self.output.write(leading_space + text[0:space] + ' $\\n')\n            text = text[space+1:]\n\n            # Subsequent lines are continuations, so indent them.\n            leading_space = '  ' * (indent+2)\n\n        self.output.write(leading_space + text + '\\n')\n\n    def _as_list(self, input):\n        if input is None:\n            return []\n        if isinstance(input, list):\n            return input\n        return [input]\n\n\ndef escape(string):\n    \"\"\"Escape a string such that it can be embedded into a Ninja file without\n    further interpretation.\"\"\"\n    assert '\\n' not in string, 'Ninja syntax does not allow newlines'\n    # We only have one special metacharacter: '$'.\n    return string.replace('$', '$$')\n"
  },
  {
    "path": "Tools/Scripts/rpi_build.py",
    "content": "#!/usr/bin/python\n#  The MIT License (MIT)\n#\n#  Copyright (c) 2017 Tag Games Limited\n#\n#  Permission is hereby granted, free of charge, to any person obtaining a copy\n#  of this software and associated documentation files (the \"Software\"), to deal\n#  in the Software without restriction, including without limitation the rights\n#  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n#  copies of the Software, and to permit persons to whom the Software is\n#  furnished to do so, subject to the following conditions:\n#\n#  The above copyright notice and this permission notice shall be included in\n#  all copies or substantial portions of the Software.\n#\n#  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n#  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n#  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n#  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n#  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n#  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n#  THE SOFTWARE.\n#-----------------------------------------------------------------------------------\nimport os\nimport subprocess\nimport sys\nfrom ninja_syntax import Writer\nfrom file_system_utils import delete_directory\n\nCOMPILER_FLAGS_DEFAULT = \"-c -std=c++11 -fsigned-char -pthread -fexceptions -frtti -DCS_TARGETPLATFORM_RPI\"\nCOMPILER_FLAGS_TARGET_MAP = { \"debug\":\"-g -DDEBUG -DCS_ENABLE_DEBUG\",  \t\"release\":\"-O3 -DNDEBUG\" }\nINCLUDE_PATHS = \"-I{0}/ChilliSource/Libraries/Core/RPi/Headers -I{0}/ChilliSource/Source -I{0}/ChilliSource/Libraries/CricketAudio/RPi/Headers\"\nLIBRARY_PATHS = \"-L{0}/ChilliSource/Libraries/Core/RPi/Libs -L{0}/ChilliSource/Libraries/CricketAudio/RPi/Libs\"\nLIBRARIES = \"-lChilliSource -lCSBase -lvcos -lbcm_host -lGLESv2 -lEGL -lvchiq_arm -lpthread -l:libX11.so.6.3.0 -l:libXau.so.6.0.0 -l:libXdmcp.so.6.0.0 -l:libxcb.so.1.1.0 -l:libxcb-xkb.so.1.0.0 -l:libxkbcommon.so.0.0.0 -l:libxkbcommon-x11.so.0.0.0 -l:libcurl.so.4.3.0 -l:libidn.so.11.6.12 -l:librtmp.so.1 -l:libssh2.so.1.0.1 -l:libssl.so.1.0.0 -l:libcrypto.so.1.0.0 -l:libgssapi_krb5.so.2.2 -l:libkrb5.so.3.3 -l:libk5crypto.so.3.1 -l:libcom_err.so.2.1 -l:liblber-2.4.so.2.10.3 -l:libldap_r-2.4.so.2.10.3 -l:libz.so.1.2.8 -l:libgnutls-deb0.so.28.41.0 -l:libhogweed.so.2.5 -l:libnettle.so.4.7 -l:libgmp.so.10.2.0 -l:libgcrypt.so.20.0.3 -l:libkrb5support.so.0.1 -l:libkeyutils.so.1.5 -l:libsasl2.so.2.0.25 -l:libp11-kit.so.0.0.0 -l:libtasn1.so.6.3.2 -l:libgpg-error.so.0.13.0 -l:libffi.so.6.0.2 -l:libevdev.so.2.1.3 -l:libudev.so.1.5.0\"\n\n# Write build commands to the given ninja file for all source files that have the given extension in the given directories\n#\n# @param ninja_file\n#\tFile to write commands to\n# @param dirs\n#\tList of directories to search for source files\n# @param exts\n# \tThe list source file extension to look for in the format \"a,b,c\"\n# @param compile_rule\n# \tName of the compile rule to compile this type of source file\n# @param dep_rule\n# \tName of the rule to generate depencencies for this type of source file\n# @param project_root\n# \tPath to the root of the project\n# @param build_dir\n# \tLocation to output compiled files to\n# \n# @return List of output file paths\n# \ndef _write_build_command(ninja_file, dirs, exts, compile_rule, dep_rule, project_root, build_dir):\n\n\tget_files_script = os.path.normpath(\"{}/ChilliSource/Tools/Scripts/get_file_paths_with_extensions.py\".format(project_root))\n\tsource_files = []\n\tfor d in dirs:\n\t\tsource_files += subprocess.check_output(['python', get_files_script, '--directory', d, '--extensions', exts], universal_newlines=True).split(\" \")\n\n\tsource_files = list(filter(lambda x: len(x) > 0, source_files))\n\tsource_files = list(filter(lambda x: len(x) > 0, source_files))\n\t# Convert the source files extensions from .c/cpp etc. to .o\n\toutput_files = map(lambda x: os.path.splitext(x)[0]+'.o', source_files)\n\t# Make the file paths relative to the build dir\n\toutput_files = map(lambda x: os.path.normpath(x).replace(project_root, build_dir, 1), output_files)\n\t# Convert from windows separators to unix ones as Ninja has a bug where it doesn't escape windows properly\n\toutput_files = list(map(lambda x: x.replace('\\\\', '/'), output_files))\n\n\tfor source_file, output_file in zip(source_files, output_files):\n\t\tninja_file.build(rule=compile_rule, inputs=source_file, outputs=output_file)\n\t\tninja_file.build(rule=dep_rule, inputs=source_file, outputs=output_file+\".d\")\n\n\treturn output_files\n\n# Generate a ninja \"makefile\"\n#\n# @param app_name\n# \tName of the executable to generate\n# @param compiler_path\n# \tPath to the gcc compiler\n# @param linker_path\n# \tPath to the gcc linker\n# @param archiver_path\n# \tPath to the gcc archiver for making static libs\n# @param compiler_flags\n#\tFlags and defines for the compiler to use when compiling the source\n# @param linker_flags\n#\tFlags for the linker to use when linking the exe\n# @param app_source_dirs\n#  \tList of directories that have the app source files to compile\n# @param project_root\n# \tRoot of the project e.g. the one containing ChilliSource, Content, AppSource, etc\n# @param build_dir\n# \tLocation to output temp build files to\n# @param output_dir\n# \tLocation to output executable and required assets\n# @param lib_cs_path\n#\tpath to temporary lib directory\n# @param lib_app_path\n#\tpath to temporary lib directory\n#\ndef _generate_ninja_file(app_name,\n\tcompiler_path, linker_path, archiver_path, \n\tcompiler_flags, linker_flags,\n\tapp_source_dirs,\n\tproject_root, build_dir, output_dir, lib_cs_path, lib_app_path):\n\n\twith open(os.path.join(build_dir, \"Application.ninja\"), \"w\") as build_file:\n\t\tninja_file = Writer(build_file)\n\n\t\tninja_file.variable(key=\"builddir\", value=build_dir)\n\n\t\t# Write the compiler rule for c, cpp and cc\n\t\tninja_file.rule(\"compile\", command=\"{} {} -o $out $in\".format(compiler_path, compiler_flags), description=\"Compiling source: $in\", depfile=\"$out.o.d\", deps=\"gcc\")\n\n\t\t# Write the rule that generates the dependencies\n\t\tninja_file.rule(\"dependencies\", command=\"{} {} -MM -MG -MF $out $in\".format(compiler_path, compiler_flags), description=\"Generating dependency: $in\")\n\n\t\t# Write the rule to build the static library. Note we use response files as on Windows the command is too long for CreateProcess\n\t\tninja_file.rule(\"archive\", command=\"{} rcs $out @$out.rsp\".format(archiver_path), description=\"Building static library: $out\", rspfile=\"$out.rsp\", rspfile_content=\"$in\")\n\n\t\t# Write the rule to link. Note we use response files as on Windows the command is too long for CreateProcess\n\t\tninja_file.rule(\"link\", command=\"{} @$out.rsp {} -o $out\".format(linker_path, linker_flags), description=\"Linking: $out\", rspfile=\"$out.rsp\", rspfile_content=\"$in\")\n\n\t\t# Write the compile command for all source files.\n\t\tcs_source_dirs = [os.path.normpath('{}/ChilliSource/Source/ChilliSource'.format(project_root)), os.path.normpath('{}/ChilliSource/Source/CSBackend/Platform/RPi/'.format(project_root)), os.path.normpath('{}/ChilliSource/Source/CSBackend/Rendering/OpenGL/'.format(project_root))]\n\t\tcs_output_files = _write_build_command(ninja_file, cs_source_dirs, 'c,cpp,cc', 'compile', 'dependencies', project_root, build_dir)\n\t\tapp_output_files = _write_build_command(ninja_file, app_source_dirs, 'c,cpp,cc', 'compile', 'dependencies', project_root, build_dir)\n\t\tall_output_files = cs_output_files + app_output_files\n\n\t\t# Write the command to generate the static library for ChilliSource and the application\n\t\tninja_file.build(rule=\"archive\", inputs=cs_output_files, outputs=lib_cs_path)\n\t\tninja_file.build(rule=\"archive\", inputs=app_output_files, outputs=lib_app_path)\n\n\t\t# Write the rule to link the libraries into the executable\n\t\tninja_file.build(rule=\"link\", inputs=all_output_files, outputs=os.path.join(output_dir, app_name))\n\n# Generates the ninja \"makefile\", builds the application and copies\n# the assets to the output folder\n#\n# @param target_scheme\n# \tUsed to apply compiler flags\n# @param num_jobs\n# \tUsed to restrict the number of concurrent build jobs. If None then unrestricted\n# @param app_name\n# \tName of the executable to generate\n# @param compiler_path\n# \tPath to the gcc compiler\n# @param linker_path\n# \tPath to the gcc linker\n# @param archiver_path\n# \tPath to the gcc archiver for making static libs\n# @param additional_libs\n# \tAny additional libraries in the format \"-lLib1 -lLib2\"\n# @param additional_lib_paths\n# \tAny additional libraries directories in the format \"-LLib/Path1 -LLib/Path2\"\n# @param additional_include_paths\n# \tAny additional header file directories in the format \"-IInclude/Path1 -IInclude/Path2\"\n# @param additional_compiler_flags_map\n# \tDict containing compiler flags for debug/release in the format -DDEBUG -g\"\n# @param app_source_dirs\n#  \tList of directories that have the app source files to compile\n# @param project_root\n# \tRoot of the project e.g. the one containing ChilliSource, Content, AppSource, etc\n# @param build_dir\n# \tLocation to output temp build files to\n# @param output_dir\n# \tLocation to output executable and required assets\n# @param lib_cs_path\n#\tpath to temporary lib directory\n# @param lib_app_path\n#\tpath to temporary lib directory\n#\ndef _build(target_scheme,\n\tnum_jobs,\n\tapp_name,\n\tcompiler_path, linker_path, archiver_path, \n\tadditional_libs, additional_lib_paths, additional_include_paths,\n\tadditional_compiler_flags_map,\n\tapp_source_dirs,\n\tproject_root, build_dir, output_dir, lib_cs_path, lib_app_path):\n\n\ttry:\n\t\tos.makedirs(build_dir)\n\texcept OSError:\n\t\tprint(\"Build directory already exists\")\n\n\ttry:\n\t\tos.makedirs(output_dir)\n\texcept OSError:\n\t\tprint(\"Output directory already exists\")\n\n\tcompiler_flags = COMPILER_FLAGS_DEFAULT + \" \" + COMPILER_FLAGS_TARGET_MAP[target_scheme] + \" \" + additional_compiler_flags_map[target_scheme] + \" \" + additional_include_paths + \" \" + INCLUDE_PATHS.format(project_root)\n\tlinker_flags = additional_lib_paths + \" \" + LIBRARY_PATHS.format(project_root) + \" -L\" + build_dir + \" \" + additional_libs + \" \" + \"-l{}\".format(app_name) + \" \" + LIBRARIES\n\n\t# Remove the old libraries and exes but not the compiled files\n\t_clean(None, output_dir, lib_cs_path, lib_app_path)\n\n\t# Generate the ninja \"makefile\" based on the target scheme and platform\n\t_generate_ninja_file(app_name, compiler_path, linker_path, archiver_path, compiler_flags, linker_flags, app_source_dirs, project_root, build_dir, output_dir, lib_cs_path, lib_app_path)\n\n\t# Build the exe using ninja\n\tif num_jobs == None:\n\t\tsubprocess.call(['ninja', '-f', os.path.join(build_dir, 'Application.ninja')])\n\telse:\n\t\tsubprocess.call(['ninja', '-f', os.path.join(build_dir, 'Application.ninja'), '-j', str(num_jobs)])\n\t\n\t# Copy the assets ready for packaging\n\tcopy_resources_script = os.path.normpath('{}/ChilliSource/Tools/Scripts/copy_rpi_resources.py'.format(project_root))\n\tsubprocess.call(['python', copy_resources_script, project_root, output_dir])\n\n# Cleans the output, build and libs. Passing None\n# will prevent them from being cleaned\n#\n# @param build_dir\n#\tLocation for temporary build files\n# @param output_dir\n#\tLocation for output exe and assets\n# @param lib_cs_path\n#\tpath to temporary lib directory\n# @param lib_app_path\n#\tpath to temporary lib directory\n#\ndef _clean(build_dir, output_dir, lib_cs_path, lib_app_path):\n\n\tif lib_cs_path != None and os.path.isfile(lib_cs_path):\n\t\tos.remove(lib_cs_path)\n\tif lib_app_path != None and os.path.isfile(lib_app_path):\n\t\tos.remove(lib_app_path)\n\tif build_dir != None and os.path.isdir(build_dir):\n\t\tdelete_directory(build_dir)\n\tif output_dir != None and os.path.isdir(output_dir):\n\t\tdelete_directory(output_dir)\n\n# Begin building for Raspberry Pi\n#\n# @param args \n#\tThe list of arguments - Should have an additional argument \"debug\" or \"release\" optionally followed by \"clean\"\n# @param num_jobs\n# \tUsed to restrict the number of concurrent build jobs. If None then unrestricted\n# @param app_name\n# \tName of the executable to generate\n# @param compiler_path\n# \tPath to the gcc compiler\n# @param linker_path\n# \tPath to the gcc linker\n# @param archiver_path\n# \tPath to the gcc archiver for making static libs\n# @param additional_libs\n# \tAny additional libraries in the format \"-lLib1 -lLib2\"\n# @param additional_lib_paths\n# \tAny additional libraries directories in the format \"-LLib/Path1 -LLib/Path2\"\n# @param additional_include_paths\n# \tAny additional header file directories in the format \"-IInclude/Path1 -IInclude/Path2\"\n# @param additional_compiler_flags_map\n# \tDict containing compiler flags for debug/release in the format -DDEBUG -g\"\n# @param app_source_dirs\n#  \tList of directories that have the app source files to compile\n# @param project_root\n# \tRoot of the project e.g. the one containing ChilliSource, Content, AppSource, etc\n# @param build_root\n# \tLocation to output temp build files to\n# @param output_root\n# \tLocation to output executable and required assets\n#\ndef run(args,\n\tnum_jobs,\n\tapp_name,\n\tcompiler_path, linker_path, archiver_path, \n\tadditional_libs, additional_lib_paths, additional_include_paths,\n\tadditional_compiler_flags_map,\n\tapp_source_dirs,\n\tproject_root, build_root, output_root):\n\n\tif len(args) < 1:\n\t\tprint(\"Too few args. Usage: debug|release [clean]\")\n\t\treturn\n\n\ttarget_scheme = args[0].lower()\n\n\tif target_scheme not in ['debug', 'release']:\n\t\tprint(\"Incorrect target scheme {}. Usage: debug|release [clean]\".format(target_scheme))\n\t\treturn\n\n\tbuild_dir = os.path.normpath(\"{}/{}\".format(build_root, target_scheme))\n\toutput_dir = os.path.normpath(\"{}/{}\".format(output_root, target_scheme))\n\tlib_cs_path = os.path.normpath(\"{}/libChilliSource.a\".format(build_dir))\n\tlib_app_path = os.path.normpath(\"{}/lib{}.a\".format(build_dir, app_name))\n\n\tif len(args) > 1 and args[1].lower() == \"clean\":\n\t\t# Remove all libraries, exes and compiled files\n\t\t_clean(build_dir, output_dir, lib_cs_path, lib_app_path)\n\telse:\n\t\t_build(target_scheme, num_jobs, app_name, compiler_path, linker_path, archiver_path, additional_libs, additional_lib_paths, additional_include_paths, additional_compiler_flags_map, app_source_dirs, project_root, build_dir, output_dir, lib_cs_path, lib_app_path)\n"
  },
  {
    "path": "readme.md",
    "content": "![alt link](Documents/Images/ChilliSourceLogo.png)\n\nChilliSource v2.2.3\n====================\n\nChilliSource is an open source, cross-platform game engine designed by game developers for game developers. It is completely free to use (now and forever), released under the MIT License.\n\n|               | iOS           | Android       | Windows\t\t| Raspberry Pi\n| ------------- |:-------------:|:-------------:|:-------------:|:-------------:|\n| Build Status  | [![Build Status](https://travis-ci.org/ChilliWorks/CSTest.svg?branch=master)](https://travis-ci.org/ChilliWorks/CSTest) | *TODO* | *TODO* | *TODO* | |\n\nLinks\n-----\n* [ChilliSource Website](http://www.chillisourceengine.com/)\n* [ChilliSource Documentation](http://www.chillisourceengine.com/tutorials/)\n* [ChilliSource Samples Repository](https://github.com/ChilliWorks/CSSamples)\n* [ChilliSource Testing Repository](https://github.com/ChilliWorks/CSTest)\n* [ChilliSource Forum](http://forums.chilli-works.com/)\n\nMain Features\n---------------\n* **Tried and Tested** - *Has been used to build commercial games for large companies.*\n* **Cross-platform** - *Write once and deploy to multiple platforms: **iOS**, **Android** and **Windows PC**.*\n* **Modern C++** - *Take advantage of modern C++ features including lambdas, smart pointers, etc.*\n* **3D** - *Create games in 3D using skeletal animations, shaders, lighting and shadows.*\n* **2D** - *Create 2D games using sprites and atlases.*\n* **UI** - *Create dynamic UI that adapts to different devices using ChilliSource's widget library and support for adding custom widgets.*\n* **Audio** - *Play music and sound effects using the popular Cricket Audio library.*\n* **Expand** - *Hook into OS lifecycle events to add your own 3rd party libs.*\n\nGetting Started\n---------------\nThe [Getting Started: What You'll Need](http://www.chillisourceengine.com/what-youll-need) tutorial provides a good starting point for working with ChilliSource. It demonstrates how to create and build a new project. Also check out the other tutorials for more information.\n\nIf you have any development questions or suggestions for the engine please post them on the [ChilliSource Forum](http://forums.chilli-works.com/). Any bugs encountered should be reported using [Github Issues](https://github.com/chilliworks/chillisource/issues).\n\n---\n\n![alt link](Documents/Images/CricketLogo.png)\n\nBuilt with Cricket Audio  \n[www.crickettechnology.com](www.crickettechnology.com)\n\nUsage of the Cricket Audio System is covered by the Cricket Audio free license (described at [http://www.crickettechnology.com/free_license](http://www.crickettechnology.com/free_license)).  \nFor other licensing options, please visit [http://www.crickettechnology.com/source_license](http://www.crickettechnology.com/source_license).\n"
  }
]